[
  {
    "path": ".clang-format",
    "content": "---\nBasedOnStyle: LLVM\nAccessModifierOffset: -4\nAlignAfterOpenBracket: Align\nAlignConsecutiveAssignments: false\nAlignConsecutiveDeclarations: false\nAlignEscapedNewlines: Right\nAlignOperands: true\nAlignTrailingComments: true\nAllowAllParametersOfDeclarationOnNextLine: true\nAllowShortBlocksOnASingleLine: false\nAllowShortCaseLabelsOnASingleLine: false\nAllowShortFunctionsOnASingleLine: InlineOnly\nAllowShortIfStatementsOnASingleLine: true\nAllowShortLoopsOnASingleLine: true\nAlwaysBreakAfterReturnType: None\nAlwaysBreakBeforeMultilineStrings: true\nAlwaysBreakTemplateDeclarations: true\nBinPackArguments: false\nBinPackParameters: false\nBraceWrapping:\n    AfterClass: false\n    AfterControlStatement: false\n    AfterEnum: false\n    AfterFunction: true\n    AfterNamespace: false\n    AfterObjCDeclaration: false\n    AfterStruct: false\n    AfterUnion: false\n    AfterExternBlock: false\n    BeforeCatch: false\n    BeforeElse: false\n    IndentBraces: false\n    SplitEmptyFunction: true\n    SplitEmptyRecord: true\n    SplitEmptyNamespace: true\nBreakBeforeBinaryOperators: All\nBreakBeforeBraces: Custom\nBreakBeforeTernaryOperators: false\nBreakConstructorInitializers: BeforeComma\nBreakStringLiterals: false\nColumnLimit: 0\nCompactNamespaces: false\nConstructorInitializerAllOnOneLineOrOnePerLine: true\nConstructorInitializerIndentWidth: 0\nContinuationIndentWidth: 0\nCpp11BracedListStyle: false\nDerivePointerAlignment: true\nFixNamespaceComments: true\nIncludeBlocks: Preserve\nIndentCaseLabels: false\nIndentPPDirectives: None  \nIndentWidth: 4\nIndentWrappedFunctionNames: false\nKeepEmptyLinesAtTheStartOfBlocks: false\nMaxEmptyLinesToKeep: 1\nNamespaceIndentation: None\nObjCBinPackProtocolList: Auto\nObjCBlockIndentWidth: 4\nObjCSpaceAfterProperty: true\nObjCSpaceBeforeProtocolList: true\nPenaltyBreakAssignment: 1\nPenaltyBreakBeforeFirstCallParameter: 1\nPenaltyBreakComment: 1\nPenaltyBreakFirstLessLess: 1\nPenaltyBreakString: 1\nPenaltyExcessCharacter: 1\nPenaltyReturnTypeOnItsOwnLine: 1\nPointerAlignment: Right\nReflowComments: false\nSortIncludes: true\nSortUsingDeclarations: false\nSpaceAfterCStyleCast: true\nSpaceAfterTemplateKeyword: false\nSpaceBeforeAssignmentOperators: true\nSpaceBeforeCtorInitializerColon: true\nSpaceBeforeInheritanceColon: true\nSpaceBeforeParens: ControlStatements\nSpaceBeforeRangeBasedForLoopColon: true\nSpaceInEmptyParentheses: false\nSpacesBeforeTrailingComments: 1\nSpacesInAngles: false\nSpacesInCStyleCastParentheses: false\nSpacesInContainerLiterals: true\nSpacesInParentheses: false\nSpacesInSquareBrackets: false\nStandard: Auto\nTabWidth: 4\nUseTab: Never\n---\nLanguage: Cpp\nColumnLimit: 80\n---\nLanguage: ObjC\nColumnLimit: 0\n"
  },
  {
    "path": ".github/stale.yml",
    "content": "# Number of days of inactivity before an issue becomes stale\ndaysUntilStale: 7\n# Number of days of inactivity before a stale issue is closed\ndaysUntilClose: 7\n# Issues with these labels will never be considered stale\nexemptLabels:\n  - bug\n  - enhancement\n# Label to use when marking an issue as stale\nstaleLabel: stale\n# Comment to post when marking an issue as stale. Set to `false` to disable\nmarkComment: >\n  This issue has been automatically marked as stale because it has not had\n  recent activity. It will be closed if no further activity occurs. Thank you\n  for your contributions.\n# Comment to post when closing a stale issue. Set to `false` to disable\ncloseComment: true\n"
  },
  {
    "path": ".gitignore",
    "content": "# Visual Studio Code\n.vscode\n\n# Visual Studio\n.vs\n\n# Android Studio, Gradle\n*.iml\n.gradle\n.idea\n.settings\n.project\n.classpath\n.DS_Store\n.externalNativeBuild\n\n# Xcode\n*.pbxuser\nxcuserdata\nxcuserdata/*\n*.xcworkspace/*\n*.xcworkspace\nDerivedData\n\n#CMake\nsrc/build/\n\n# WCDB\nWCDB.framework\n\n# SwiftPM\n/.build\nPackage.resolved\n\n# WeChat\nWeChat/conan/*\n\n# Mac Catalyst\ntools/version/build\n\n# wconan\nWeChat/.wconan2/\nWeChat/wconan_build/\nWeChat/wconan_libs/\nWeChat/wconan_local_build/\nWeChat/wconan_package.lock\nWeChat/wconan_publish.py\nWeChat/cmake-build-*/\nWeChat/compile.log\nWeChat/apple_build/\nWeChat/export_headers/"
  },
  {
    "path": ".gitmodules",
    "content": "[submodule \"sqlcipher\"]\n\tpath = sqlcipher\n\turl = https://github.com/Tencent/sqlcipher.git\n[submodule \"openssl\"]\n\tpath = openssl\n\turl = https://github.com/openssl/openssl.git\n[submodule \"zstd\"]\n\tpath = zstd\n\turl = https://github.com/facebook/zstd.git\n"
  },
  {
    "path": ".swift-version",
    "content": "5"
  },
  {
    "path": "CHANGELOG.md",
    "content": "## v2.1.15\n\n* Fix build error on Xcode 26\n* Support Mac Catalyst\n* Fix mmap crash In windows\n* Fix some known bugs\n\n## v2.1.14\n\n* Support 16kb pagesize for Android\n* Supports using ksp in Kotlin version 2.1.0+\n* Fix stack overflow crash\n* Fix some known bugs\n\n## v2.1.13\n\n* Fix compile error of Swift Package Manager\n* Fix crash caused by in-transaction handle\n* Convert ANSI error msg in windows to UTF8\n\n## v2.1.12\n\n* Fix build error on Xcode 26 beta\n* Fix empty string crash in java/kotlin winq\n* Fix linking error on linux x86\n\n## v2.1.11\n\n* Support to open database in readonly mode\n* Support to create in-memory database in java/c++/swift\n* Fix the exception problem of tableExist method in Java/Kotlin\n\n## v2.1.10\n\n* Disable checkpoint fullsync in apple platform, it will significantly reduce disk IO\n* Add main db file protection to windows\n* Reduce memory cost of data compression\n* Reduce handle usage of data backup\n* Support to detect schema corruption\n* Fix some known bugs and compile issues\n\n## v2.1.9\n\n* Add lite mode (Set journal mode and synchronous flag to OFF)\n* Fix memory leak and other known bug\n\n## v2.1.8\n\n* Increase migration speed\n* Fix compile error of SwiftPM in Xcode 16\n\n## v2.1.7\n\n* WCDB C++ supports OpenHarmony OS\n* Support to recompress existing data with new configuration\n* Support auto vacuum\n* Support Swift6\n* Fix some compile issues\n\n## v2.1.6\n\n* Some bugfix for data repair, Java/Kotlin ORM and Swift query\n* Fix some compile error and warning\n\n## v2.1.5\n\n* Support legacy mmicu tokenizer in WCDB Java/Kotlin\n* Support to rollback compression\n* Improve performance of vacuum\n* Add valueOr interface to Optional\n* Some bugfix for compression and vacuum\n\n## v2.1.4\n\n* Fix the compile error of WCDB Java/Koltin caused by minifyEnabled flag\n* Add regular memory verification to Zstd dict\n\n## v2.1.3\n\n* Add ProGuard config for WCDB Java/Kotlin\n* Support to build WCDB C++ as a framework on Apple platform with CMake\n* Support to insert an array of object pointers or object shared pointers in WCDB C++\n* Fix the bug that error cannot be obtained through database\n\n## v2.1.2\n\n* Some bugfix for data compression\n* Fix compile error of WCDB Objc on Carthage\n* Fix compile error of WCDB C++ when built as a CMake submodule\n\n## v2.1.1\n\n* Some bugfix for WCDB C++ and WCDB Swift\n* Fix compile error on Mac Catalyst\n\n## v2.1.0\n\n* Add WCDB Java/Kotlin\n* Support data compression\n* Support incremental data backup\n* Support to configure a filter condition for data migration\n* Support to use std::optional and std::shared_ptr in C++ ORM\n* C++ ORM supports inheritance\n* Add more monitoring capabilities\n* WCDB Swift supports Swift Package Manager\n\n## v2.0.4\n\n* Support to asynchronously interrupt database operations\n* Optimize the handle management mechanism\n* Some bugfix for WCDB C++ in Windows\n\n## v2.0.3\n\n* Transaction supports nesting\n* Some bug fix for data migration\n* Fix compile error in new Xcode\n\n## v2.0.2.5\n\n* Fix compile issue caused by header\n\n## v2.0.2\n\n* WCDB C++ supports Windows\n* Optimizie C++ ORM performance\n* Downgrade the minimum supported system version for iPhone and Apple watch\n\n## v2.0.1\n\n* Support databases created by old versions of sqlcipher\n* Fix crash of WCDB Swift in x86 emulator\n* Support insertOrIgnore\n\n## v2.0.0\n\n* Add WCDB C++\n* New implementation of WCDB Swift\n* New implementation of Winq\n* New implementation of database repair\n* Support data migration\n* Support FTS5\n\n## v1.1.0\n\n#### iOS/macOS\n* Support Swift 5 for Xcode 14.\n* Fix compile error for SQLCipher 4.1.0.\n* Fix some bug.\n\n## v1.0.8.2\n\n#### iOS/macOS\n* Support Swift 4.2 for Xcode 10.2\n\n## v1.0.8.1\n\n#### iOS/macOS\n* Fix a bug that archive failed with Xcode new build system.\n\n## v1.0.8\n\n#### Android\n\n* Support for [Room library](https://developer.android.com/topic/libraries/architecture/room) from Android Jetpack. See README and [Wiki](https://github.com/Tencent/wcdb/wiki/Android-WCDB-%E4%BD%BF%E7%94%A8-Room-ORM-%E4%B8%8E%E6%95%B0%E6%8D%AE%E7%BB%91%E5%AE%9A) for details.\n\n## v1.0.7.5\n\n#### iOS/macOS\n\n* Compatible with Swift 4.2.\n* Enable FTS5 macro for sqlcipher.\n\n## v1.0.7\n\n#### iOS/macOS\n\n* Fix nil string bug while inserting empty string.\n* Code template is not installed automatically now.\n* Reduce size of binary and provide a non-bitcode scheme for Carthage.\n* Avoid conflict between builtin SQLCipher and other SQLite based library(including system library).\n\n## v1.0.6.2\n\n#### iOS/macOS\n\nIt's a bug fixed version. Since Swift 4.1.x contains [bugs](https://github.com/Tencent/wcdb/issues/283) that make WCDB fails to compile, developers should use Xcode 10(with Swift 4.2).\n\n##### Swift\n* Compatible with Swift 4.2. The `ColumnEncodable` and `ColumnDecodable` is now changed. Check the code snippet, file template or wiki for the new usage.\n* Use `Double` column type for `Date`.\n\nFYI, a refactor is needed to fit the new conditional conformance design of Swift 4.2. We will finish it in next version.\n\n#### Android\n\n* Use C++14 and libc++_static runtime on JNI routines.\n* Fix \"no implementation found\" log on libwcdb.so initialization.\n* Fix ProGuard rules when importing from AAR package.\n\n## v1.0.6\n\n#### iOS/macOS\n\nIt's the first release for WCDB Swift, which contains exactly the same features as the ObjC version, including:\n\n* Object-Relational-Mapping based on Swift 4.0 `Codable` protocol.\n* WCDB Integrated Language Query.\n* Multithreading safety and concurrency.\n* Encryption based on SQLCipher.\n* Protection for SQL injection.\n* Full text search.\n* Corruption recovery.\n* ...\n\nFor further information, please check tutorial on wiki.\n\n#### Android\n\n* Migrate to gradle plugin 3.0.0, target API 26, and minimal API 14.\n* Support NDK r16, change default toolchain to clang.\n* Various bug fixes.\n\n## v1.0.5\n\n#### iOS/macOS\n\n* Builtin full-text search support for ORM.\n```objc\nWCTProperty *tableProperty = WCTSampleFTSData.PropertyNamed(tableNameFTS).match(\"Eng*\")];\n\n[databaseFTS getObjectsOfClass:WCTSampleFTSData.class fromTable:tableNameFTS where:tableProperty.match(\"Eng*\")];\n```\n* Support read-only databases.\n* Some minor bug fixes and code refactor.\n\n#### Android\n\n* Optimize asynchronous checkpointer, greatly improve write performance with WAL and asynchronous checkpointing.\n```java\nSQLiteDatabase db = SQLiteDatabase.openOrCreateDatabaseInWalMode(...);\ndb.setAsyncCheckpointEnabled(true);\n```\n* Add benchmark for asynchronous checkpointer.\n* Add connection pooling friendly interface. `SQLiteDatabase.setSynchronousMode()` to set database synchronization mode.\n* Enable `dbstat` virtual table while compiling.\n\n## v1.0.4\n\n#### Repair Kit\n\n* Add `sqliterk_cancel` function to cancel ongoing output operations.\n* Add corresponding Java interface to cancel operations on Android.\n\n#### iOS/macOS\n\n* Builtin `WCTColumnCoding` supports all `id<NSCoding>` objects now.\n* Compatible with iOS 11.\n* `Fullfsync` is used by default for data integrity.\n* Add `-initWithExistingTag:` for `WCTDatabase` to get existing database without path.\n\n```objc\nWCTDatabase* database = [WCTDatabase [alloc] initWithPath:path];\ndatabase.tag = 123;\nWCTDatabase* withoutPath = [[WCTDatabase alloc] initWithExistingTag:123];\n```\n\n* Some minor bug fixes, performance improvement and code refactor.\n\n#### Android\n\n* Add asynchronous checkpointing support and custom checkpointing callback. This can\n  improve performance in WAL mode.\n\n```java\nSQLiteDatabase db = SQLiteDatabase.openOrCreateDatabaseInWalMode(...);\n\n// Use asynchronous checkpointing.\ndb.setAsyncCheckpointEnabled(true);\n\n// OR use custom checkpointer.\nSQLiteCheckpointListener callback = new SQLiteCheckpointListener() {\n    //...\n};\ndb.setCheckpointCallback(callback);\n```\n\n* Add `SQLiteTrace.onConnectionObtained(...)` interface to trace concurrency performance.\n* Add cancelable version of `SQLiteDatabase.execSQL()`. See `CancellationSignal` for details.\n\n```java\nCancellationSignal signal = new CancellationSignal();\ndb.execSQL(longRunningSQL, args, signal);\n\n// on another thread\nsignal.cancel();\n```\n\n* Enable `SQLITE_ENABLE_FTS3_PARENTHESIS` compilation option on SQLCipher, which enables `AND`, `OR` operators in FTS3/4.\n* Use `CancellationSignal` for canceling `BackupKit`, `RecoverKit` and `RepairKit` operations. See repair sample for details.\n* Add callback interface for `RepairKit` to show progress to the users. See `RepairKit.Callback` and `RepairKit.setCallback()`.\n* Do not load `libwcdb.so` if it's already loaded on the first use. This makes WCDB compatible to Tinker framework.\n* Various bug fixes.\n\n## v1.0.3\n\n#### Repair Kit\n\n* Fix INTEGER PRIMARY KEY columns not properly recovered.\n\n#### iOS/macOS\n\n* Add `WCTColumnCoding` support for all `WCTValue`. Developers can use `id<WCTColumnCoding>` objects for WINQ and all interfaces.\n```objc\n//WINQ\nNSDate *now = [NSDate date];\n[database getObjectsOfClass:Message.class fromTable:tableName where:Message.modifedTime==now];\n\n//Interfaces\n[database updateAllRowsInTable:tableName \n          onProperty:Message.modifiedTime \n            withValue:[NSDate date]];\n```\n* Add monitor for all executed SQL to check WINQ correctness.\n```objc\n//SQL Execution Monitor\n[WCTStatistics SetGlobalSQLTrace:^(NSString *sql) {\n  NSLog(@\"SQL: %@\", sql);\n}];\n```\n* Update `WCTTableCoding` XCode file template for the best practice of isolating Objective C++ codes. See Wiki page for details.\n* Some minor bug fixes.\n\n#### Android\n\n* Add `CursorWindow.windowSize(int)` static method to set or get default size for cursor windows.\n* `SQLiteDatabase.dump()` reports IDs for all threads that hold database connections, to aid dead-lock debugging.\n* Fix crashing on devices fail to load ICU library.\n* Fix `SQLiteTrace.onSQLExecuted(...)` reports negative execution time.\n\n## v1.0.2\n\n#### iOS/macOS\n\n* Performance optimization and benchmark. See Wiki page for details.\n* Change builtin `NSData` or `NSMutableData` column coding to raw data format. To be compatible with earlier versions, call `[WCTCompatible sharedCompatible].builtinNSDataColumnCodingCompatibleEnabled = YES`.\n* Add `attach`, `detach`, `vacuum`, `savepoiint`, `rollback`, `release`, `reindex`, `explain` statement and SQLCipher related pragma to WINQ.\n* Remove auto increment for `insertOrReplace`.\n* Rename `updateTable` to `updateRowsInTables`, and `statictics`(typo) to `statistics`.\n* Some minor bug fixes.\n\n#### Android\n\n* Performance optimization and benchmark. See Wiki page for details.\n* Expose ProGuard rules to AAR package. Fix crash when minify is enabled in gradle.\n\n## v1.0.1\n\n#### iOS/macOS\n\n* Add CocoaPods support.\n* Add iOS 7 and macOS 10.9 support. Apps using WCDB can target iOS 7 now.\n* Fix an issue that `[WCTDatabase canOpen]` never return YES.\n* Fix an issue that the global tracer return some odd values.\n* Add `@autoreleasepool` in `runTransaction` to avoid OOM.\n\n#### Android\n\n* Add `x86_64` ABI support.\n* Publish debug version of AAR and native symbols. To reference debug version of WCDB library, modify your `build.gradle`.\n\n```gradle\ndependencies {\n    // Append \":debug@aar\" to reference debug library.\n    compile 'com.tencent.wcdb:wcdb-android:1.0.1:debug@aar'\n}\n```\n\n* **Device-locking** is available in cipher options. Databases created with device-locking enabled can be only accessed in\n  the same device where the databases are created. Device-locking is currently **in alpha stage**. You can enable it with\n  the following code:\n\n```java\nSQLiteCipherSpec cipher = new SQLiteCipherSpec()\n        // add the following line to enable device-locking\n        .setCipher(SQLiteCipherSpec.CIPHER_DEVLOCK);\nSQLiteDatabase db = SQLiteDatabase.openOrCreateDatabase(path, key, cipher, ...);\n```\n\n* Various bug fixes.\n\n## v1.0.0\n\nInitial release.\n"
  },
  {
    "path": "CONTRIBUTING.md",
    "content": "# Contributing to WCDB\nWelcome to [report issues](https://github.com/Tencent/wcdb/issues) or [pull requests](https://github.com/Tencent/wcdb/pulls). It's recommended to read the following Contributing\nGuide first before contributing. \n\n## Issues\nWe use Github Issues to track public bugs and feature requests.\n\n### Search Known Issues First\nPlease search the existing issues to see if any similar issue or feature request has already been filed. You should make sure your issue isn't redundant.\n\n### Reporting New Issues\nIf you open an issue, the more information the better. Such as detailed description, screenshot or video of your problem, logcat or code blocks for your crash.\n\n## Pull Requests\nWe strongly welcome your pull request to make WCDB better. \n\n### Branch Management\nThere are three main branches here:\n\n1. `master` branch.\n\t* It is the latest (pre-)release branch. We use `master` for tags, with version number `1.1.0`, `1.2.0`, `1.3.0`...\n\t* **Don't submit any PR on `master` branch.**\n2. `dev` branch. \n\t* It is our stable developing branch. After full testing, `dev` will be merged to `master` branch for the next release.\n\t* **You are recommended to submit bugfix or feature PR on `dev` branch.**\n3. `hotfix` branch. \n\t* It is the latest tag version for hot fix. If we accept your pull request, we may just tag with version number `1.1.1`, `1.2.3`.\n\t* **Only submit urgent PR on `hotfix` branch for next specific release.**\n\nNormal bugfix or feature request should be submitted to `dev` branch. After full testing, we will merge them to `master` branch for the next release. \n\nIf you have some urgent bugfixes on a published version, but the `master` branch have already far away with the latest tag version, you can submit a PR on hotfix. And it will be cherry picked to `dev` branch if it is possible.\n\n```\nmaster\n ↑\ndev        <--- hotfix PR\n ↑ \nfeature/bugfix PR\n```  \n\n### Make Pull Requests\nThe code team will monitor all pull request, we run some code check and test on it. After all tests passed, we will accept this PR. But it won't merge to `master` branch at once, which have some delay.\n\nBefore submitting a pull request, please make sure the followings are done:\n\n1. Fork the repo and create your branch from `master` or `hotfix`.\n2. Update code or documentation if you have changed APIs.\n3. Add the copyright notice to the top of any new files you've added.\n4. Check your code lints and checkstyles.\n5. Test and test again your code.\n6. Now, you can submit your pull request on `dev` or `hotfix` branch.\n\n## License\nBy contributing to WCDB, you agree that your contributions will be licensed\nunder its [BSD LICENSE](https://github.com/Tencent/wcdb/blob/master/LICENSE.txt)"
  },
  {
    "path": "ISSUE_TEMPLATE.md",
    "content": "### The language of WCDB\n\n> e.g. Objective-C, Swift or Java \n\n\n\n### The version of WCDB\n\n> e.g. v1.0.5\n\n\n\n### The platform of WCDB\n\n> e.g. iOS, macOS or Android\n\n\n\n### The installation of WCDB\n\n> e.g. Cocoapods, Carthage, Maven, AAR Package or Git clone\n\n\n\n### What's the issue?\n\n> Post the outputs or screenshots for errors.\n> \n> Explain what you want by example or code **in English**.\n\n\n\n\n\n\n\n"
  },
  {
    "path": "LICENSE",
    "content": "Tencent is pleased to support the open source community by making WCDB available.  \n\nCopyright (C) 2017 THL A29 Limited, a Tencent company.  All rights reserved.\nIf you have downloaded a copy of the WCDB binary from Tencent, please note that \nthe WCDB binary is licensed under the BSD 3-Clause License.\n\nIf you have downloaded a copy of the WCDB source code from Tencent, please note \nthat WCDB source code is licensed under the BSD 3-Clause License, except for \nthe third-party components listed below which are subject to different license \nterms.  Your integration of WCDB into your own projects may require compliance \nwith the BSD 3-Clause License, as well as the other licenses applicable to the \nthird-party components included within WCDB.\n\nA copy of the BSD 3-Clause License is included in this file.\nOther dependencies and licenses:\n \nOpen Source Software Licensed Under the Apache License, Version 2.0: \nThe below software in this distribution may have been modified by THL A29 Limited \n(“Tencent Modifications”). \nAll Tencent Modifications are Copyright (C) 2017 THL A29 Limited.\n\n----------------------------------------------------------------------------------------\n1. Android Source Code  4.3\nCopyright (C) 2006-2011 The Android Open Source Project \n \n \nTerms of the Apache License, Version 2.0:\n---------------------------------------------------\nApache License\n\nVersion 2.0, January 2004\n\nhttp://www.apache.org/licenses/\n \nTERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION\n \n1. Definitions.\n \n“License” shall mean the terms and conditions for use, reproduction, and distribution\nas defined by Sections 1 through 9 of this document.\n \n“Licensor” shall mean the copyright owner or entity authorized by the copyright owner\nthat is granting the License.\n \n“Legal Entity” shall mean the union of the acting entity and all other entities that \ncontrol, are controlled by, or are under common control with that entity. For the \npurposes of this definition, “control” means (i) the power, direct or indirect, to \ncause the direction or management of such entity, whether by contract or otherwise, \nor (ii) ownership of fifty percent (50%) or more of the outstanding shares, or \n(iii) beneficial ownership of such entity.\n \n“You” (or “Your”) shall mean an individual or Legal Entity exercising permissions \ngranted by this License.\n \n“Source” form shall mean the preferred form for making modifications, including but \nnot limited to software source code, documentation source, and configuration files.\n \n“Object” form shall mean any form resulting from mechanical transformation or \ntranslation of a Source form, including but not limited to compiled object code, \ngenerated documentation, and conversions to other media types.\n \n“Work” shall mean the work of authorship, whether in Source or Object form, made \navailable under the License, as indicated by a copyright notice that is included \nin or attached to the work (an example is provided in the Appendix below).\n \n“Derivative Works” shall mean any work, whether in Source or Object form, that is \nbased on (or derived from) the Work and for which the editorial revisions, \nannotations, elaborations, or other modifications represent, as a whole, an \noriginal work of authorship. For the purposes of this License, Derivative Works \nshall not include works that remain separable from, or merely link (or bind by \nname) to the interfaces of, the Work and Derivative Works thereof.\n \n“Contribution” shall mean any work of authorship, including the original version \nof the Work and any modifications or additions to that Work or Derivative Works \nthereof, that is intentionally submitted to Licensor for inclusion in the Work \nby the copyright owner or by an individual or Legal Entity authorized to submit \non behalf of the copyright owner. For the purposes of this definition, “submitted” \nmeans any form of electronic, verbal, or written communication sent to the \nLicensor or its representatives, including but not limited to communication on \nelectronic mailing lists, source code control systems, and issue tracking systems \nthat are managed by, or on behalf of, the Licensor for the purpose of discussing \nand improving the Work, but excluding communication that is conspicuously marked \nor otherwise designated in writing by the copyright owner as “Not a Contribution.”\n \n“Contributor” shall mean Licensor and any individual or Legal Entity on behalf \nof whom a Contribution has been received by Licensor and subsequently \nincorporated within the Work.\n \n2. Grant of Copyright License. Subject to the terms and conditions of this License, \neach Contributor hereby grants to You a perpetual, worldwide, non-exclusive, \nno-charge, royalty-free, irrevocable copyright license to reproduce, prepare \nDerivative Works of, publicly display, publicly perform, sublicense, and distribute \nthe Work and such Derivative Works in Source or Object form.\n \n3. Grant of Patent License. Subject to the terms and conditions of this License, \neach Contributor hereby grants to You a perpetual, worldwide, non-exclusive, \nno-charge, royalty-free, irrevocable (except as stated in this section) patent \nlicense to make, have made, use, offer to sell, sell, import, and otherwise transfer \nthe Work, where such license applies only to those patent claims licensable by such \nContributor that are necessarily infringed by their Contribution(s) alone or by \ncombination of their Contribution(s) with the Work to which such Contribution(s) was \nsubmitted. If You institute patent litigation against any entity (including a \ncross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution \nincorporated within the Work constitutes direct or contributory patent infringement, \nthen any patent licenses granted to You under this License for that Work shall \nterminate as of the date such litigation is filed.\n \n4. Redistribution. You may reproduce and distribute copies of the Work or Derivative \nWorks thereof in any medium, with or without modifications, and in Source or Object \nform, provided that You meet the following conditions:\n \na) You must give any other recipients of the Work or Derivative Works a copy of this \nLicense; and\n \nb) You must cause any modified files to carry prominent notices stating that You \nchanged the files; and\n \nc) You must retain, in the Source form of any Derivative Works that You distribute, \nall copyright, patent, trademark, and attribution notices from the Source form of \nthe Work, excluding those notices that do not pertain to any part of the Derivative \nWorks; and\n \nd) If the Work includes a “NOTICE” text file as part of its distribution, then any \nDerivative Works that You distribute must include a readable copy of the attribution \nnotices contained within such NOTICE file, excluding those notices that do not pertain \nto any part of the Derivative Works, in at least one of the following places: within \na NOTICE text file distributed as part of the Derivative Works; within the Source \nform or documentation, if provided along with the Derivative Works; or, within a \ndisplay generated by the Derivative Works, if and wherever such third-party notices \nnormally appear. The contents of the NOTICE file are for informational purposes only \nand do not modify the License. You may add Your own attribution notices within \nDerivative Works that You distribute, alongside or as an addendum to the NOTICE text \nfrom the Work, provided that such additional attribution notices cannot be construed \nas modifying the License. \n \nYou may add Your own copyright statement to Your modifications and may provide \nadditional or different license terms and conditions for use, reproduction, or \ndistribution of Your modifications, or for any such Derivative Works as a whole, \nprovided Your use, reproduction, and distribution of the Work otherwise complies with \nthe conditions stated in this License. \n \n5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution \nintentionally submitted for inclusion in the Work by You to the Licensor shall be under \nthe terms and conditions of this License, without any additional terms or conditions. \nNotwithstanding the above, nothing herein shall supersede or modify the terms of any \nseparate license agreement you may have executed with Licensor regarding such \nContributions.\n \n6. Trademarks. This License does not grant permission to use the trade names, trademarks, \nservice marks, or product names of the Licensor, except as required for reasonable and \ncustomary use in describing the origin of the Work and reproducing the content of the \nNOTICE file.\n \n7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, \nLicensor provides the Work (and each Contributor provides its Contributions) on an \n“AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, \nincluding, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, \nMERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for \ndetermining the appropriateness of using or redistributing the Work and assume any risks \nassociated with Your exercise of permissions under this License.\n \n8. Limitation of Liability. In no event and under no legal theory, whether in tort \n(including negligence), contract, or otherwise, unless required by applicable law (such \nas deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor \nbe liable to You for damages, including any direct, indirect, special, incidental, or \nconsequential damages of any character arising as a result of this License or out of the \nuse or inability to use the Work (including but not limited to damages for loss of \ngoodwill, work stoppage, computer failure or malfunction, or any and all other commercial \ndamages or losses), even if such Contributor has been advised of the possibility of such \ndamages.\n\n9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative \nWorks thereof, You may choose to offer, and charge a fee for, acceptance of support, \nwarranty, indemnity, or other liability obligations and/or rights consistent with this \nLicense. However, in accepting such obligations, You may act only on Your own behalf and \non Your sole responsibility, not on behalf of any other Contributor, and only if You agree \nto indemnify, defend, and hold each Contributor harmless for any liability incurred by, or \nclaims asserted against, such Contributor by reason of your accepting any such warranty or \nadditional liability.\n \nEND OF TERMS AND CONDITIONS\n \nAPPENDIX: How to apply the Apache License to your work\nTo apply the Apache License to your work, attach the following boilerplate notice, with the \nfields enclosed by brackets \"[]\" replaced with your own identifying information. (Don't \ninclude the brackets!) The text should be enclosed in the appropriate comment syntax for \nthe file format. We also recommend that a file or class name and description of purpose be \nincluded on the same \"printed page\" as the copyright notice for easier identification within \nthird-party archives.\n \nCopyright [yyyy] [name of copyright owner]\n \nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\nhttp://www.apache.org/licenses/LICENSE-2.0\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n \n \n \nOpen Source Software Licensed Under Public Domain: \nThe below software in this distribution may have been modified by THL A29 Limited \n(“Tencent Modifications”). \nAll Tencent Modifications are Copyright (C) 2017 THL A29 Limited.\n----------------------------------------------------------------------------------------\n1. SQLite  3.11.0\n \n \n \nOpen Source Software Licensed Under the OpenSSL License: \nThe below software in this distribution may have been modified by THL A29 Limited \n(“Tencent Modifications”). \nAll Tencent Modifications are Copyright (C) 2017 THL A29 Limited.\n----------------------------------------------------------------------------------------\n1. OpenSSL  1.0.2j\nCopyright (c) 1998-2016 The OpenSSL Project.\nAll rights reserved.\nCopyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)\nAll rights reserved.\n \n \n \nTerms of the OpenSSL License:\n---------------------------------------------------\nLICENSE ISSUES:\n--------------------------------------------------------------------\n \nThe OpenSSL toolkit stays under a dual license, i.e. both the conditions of the \nOpenSSL License and the original SSLeay license apply to the toolkit.\nSee below for the actual license texts.\n \nOpenSSL License:\n--------------------------------------------------------------------\nCopyright (c) 1998-2016 The OpenSSL Project.  All rights reserved.\n \nRedistribution and use in source and binary forms, with or without modification, \nare permitted provided that the following conditions are met:\n \n1. Redistributions of source code must retain the above copyright notice, this list \nof conditions and the following disclaimer.\n \n2. Redistributions in binary form must reproduce the above copyright notice, this \nlist of conditions and the following disclaimer in the documentation and/or other \nmaterials provided with the distribution.\n \n3. All advertising materials mentioning features or use of this software must \ndisplay the following acknowledgment:\n\"This product includes software developed by the OpenSSL Project for use in the \nOpenSSL Toolkit. (http://www.openssl.org/)\"\n \n4. The names \"OpenSSL Toolkit\" and \"OpenSSL Project\" must not be used to endorse or \npromote products derived from this software without prior written permission. For \nwritten permission, please contact openssl-core@openssl.org.\n \n5. Products derived from this software may not be called \"OpenSSL\" nor may \"OpenSSL\" \nappear in their names without prior written permission of the OpenSSL Project.\n \n6. Redistributions of any form whatsoever must retain the following acknowledgment: \n\"This product includes software developed by the OpenSSL Project for use in the \nOpenSSL Toolkit (http://www.openssl.org/)\"\n \nTHIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY EXPRESSED OR \nIMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF \nMERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT \nSHALL THE OpenSSL PROJECT OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, \nINCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT \nLIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR \nPROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, \nWHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) \nARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE \nPOSSIBILITY OF SUCH DAMAGE. \n====================================================================\n* This product includes cryptographic software written by Eric Young (eay@cryptsoft.com).  \nThis product includes software written by Tim Hudson (tjh@cryptsoft.com).\n \n \nOriginal SSLeay License:\n--------------------------------------------------------------------\nCopyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)\nAll rights reserved.\n \nThis package is an SSL implementation written by Eric Young (eay@cryptsoft.com).\nThe implementation was written so as to conform with Netscapes SSL.\n \nThis library is free for commercial and non-commercial use as long as the following \nconditions are aheared to. The following conditions apply to all code found in this \ndistribution, be it the RC4, RSA, lhash, DES, etc., code; not just the SSL code. \nThe SSL documentation included with this distribution is covered by the same copyright \nterms except that the holder is Tim Hudson (tjh@cryptsoft.com). \n \nCopyright remains Eric Young's, and as such any Copyright notices in the code are not \nto be removed.  If this package is used in a product, Eric Young should be given \nattribution as the author of the parts of the library used. This can be in the form \nof a textual message at program startup or in documentation (online or textual) \nprovided with the package. \n  \nRedistribution and use in source and binary forms, with or without modification, are \npermitted provided that the following conditions are met:\n\n1. Redistributions of source code must retain the copyright notice, this list of \nconditions and the following disclaimer.\n\n2. Redistributions in binary form must reproduce the above copyright notice, this list \nof conditions and the following disclaimer in the documentation and/or other materials \nprovided with the distribution.\n\n3. All advertising materials mentioning features or use of this software must display \nthe following acknowledgement:\" This product includes cryptographic software written \nby Eric Young (eay@cryptsoft.com)\" The word 'cryptographic' can be left out if the \nrouines from the library being used are not cryptographic related :-).\n\n4. If you include any Windows specific code (or a derivative thereof) from the apps \ndirectory (application code) you must include an acknowledgement: \"This product includes \nsoftware written by Tim Hudson (tjh@cryptsoft.com)\"\n \nTHIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, \nINCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR \nA PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE \nLIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES \n(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, \nDATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, \nWHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING \nIN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH \nDAMAGE. \n  \nThe licence and distribution terms for any publically available version or derivative of \nthis code cannot be changed.  i.e. this code cannot simply be copied and put under another \ndistribution licence [including the GNU Public Licence.]\n \n \n \nOpen Source Software Licensed Under the ICU License: \n----------------------------------------------------------------------------------------\n1. ICU4C  50.1\nCopyright (c) 1995-2012 International Business Machines Corporation and others\nAll rights reserved.\n \n \nTerms of the ICU License:\n--------------------------------------------------------------------\nICU License - ICU 1.8.1 and later\n \nCOPYRIGHT AND PERMISSION NOTICE\n \nCopyright (c) 1995-2012 International Business Machines Corporation and others\n \nAll rights reserved.\n \nPermission is hereby granted, free of charge, to any person obtaining a copy of \nthis software and associated documentation files (the \"Software\"), to deal in the \nSoftware without restriction, including without limitation the rights to use, copy, \nmodify, merge, publish, distribute, and/or sell copies of the Software, and to permit \npersons to whom the Software is furnished to do so, provided that the above copyright \nnotice(s) and this permission notice appear in all copies of the Software and that both \nthe above copyright notice(s) and this permission notice appear in supporting \ndocumentation.\n \nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, \nINCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR \nPURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER \nOR HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR \nCONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR \nPROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING \nOUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.\n \nExcept as contained in this notice, the name of a copyright holder shall not be used in \nadvertising or otherwise to promote the sale, use or other dealings in this Software \nwithout prior written authorization of the copyright holder.\n \nAll trademarks and registered trademarks mentioned herein are the property of their \nrespective owners.\n \n \nOpen Source Software Licensed Under the BSD 3-Clause License: \nThe below software in this distribution may have been modified by THL A29 Limited \n(“Tencent Modifications”). \nAll Tencent Modifications are Copyright (C) 2017 THL A29 Limited.\n----------------------------------------------------------------------------------------\n1. SQLCipher  3.4.0\nCopyright (c) 2008, ZETETIC LLC\nAll rights reserved.\n \n \n \nTerms of the BSD 3-Clause License:\n--------------------------------------------------------------------\n \nRedistribution and use in source and binary forms, with or without modification, \nare permitted provided that the following conditions are met:\n\nl  Redistributions of source code must retain the above copyright notice, this list \nof conditions and the following disclaimer.\n\nl  Redistributions in binary form must reproduce the above copyright notice, this \nlist of conditions and the following disclaimer in the documentation and/or other \nmaterials provided with the distribution.\n\nl  Neither the name of [copyright holder] nor the names of its contributors may be \nused to endorse or promote products derived from this software without specific \nprior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" \nAND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED \nWARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. \nIN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, \nINDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT \nNOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR \nPROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, \nWHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) \nARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE \nPOSSIBILITY OF SUCH DAMAGE.\n"
  },
  {
    "path": "Package.swift",
    "content": "// swift-tools-version: 5.5\n// The swift-tools-version declares the minimum version of Swift required to build this package.\n\nimport PackageDescription\n\nlet package = Package(\n    name: \"WCDBSwift\",\n    platforms: [\n        .macOS(.v10_13),\n        .watchOS(.v4),\n        .tvOS(.v12),\n        .iOS(.v12)],\n    products: [\n        .library(name: \"WCDBSwift\", targets: [\"WCDBSwift\"]),\n        .library(name: \"WCDBSwiftDynamic\", type: .dynamic, targets: [\"WCDBSwift\"]),\n    ],\n    dependencies: [\n        .package(url: \"https://github.com/Tencent/sqlcipher\", .exactItem(\"1.4.7\"))\n    ],\n    targets: [\n        .target(\n            name: \"objc-core\",\n            path: \"src/objc/core\",\n            sources: [\"WCTFileManager.mm\", \"WCTFoundation.mm\", \"WCTFTSTokenizerUtil.mm\", \"WCTOperationQueue.mm\"],\n            publicHeadersPath:\"\",\n            cSettings: [\n//                .headerSearchPath(\"../../**\"),\n                .headerSearchPath(\"../../bridge\"),\n                .headerSearchPath(\"../../objc\"),\n                .headerSearchPath(\"../../bridge/objcbridge\"),\n                .headerSearchPath(\"../../bridge/cppbridge\"),\n                .headerSearchPath(\"../../bridge/winqbridge\"),\n                .headerSearchPath(\"../../bridge/base\"),\n                .headerSearchPath(\"../../bridge/winqbridge/statement\"),\n                .headerSearchPath(\"../../bridge/winqbridge/identifier\"),\n                .headerSearchPath(\"../../common/core\"),\n                .headerSearchPath(\"../../common/platform\"),\n                .headerSearchPath(\"../../common/winq\"),\n                .headerSearchPath(\"../../common/repair\"),\n                .headerSearchPath(\"../../common/base\"),\n                .headerSearchPath(\"../../common/utility\"),\n                .headerSearchPath(\"../../common/core/config\"),\n                .headerSearchPath(\"../../common/core/assemble\"),\n                .headerSearchPath(\"../../common/core/vacuum\"),\n                .headerSearchPath(\"../../common/core/cipher\"),\n                .headerSearchPath(\"../../common/core/sqlite\"),\n                .headerSearchPath(\"../../common/core/function\"),\n                .headerSearchPath(\"../../common/core/fts\"),\n                .headerSearchPath(\"../../common/core/operate\"),\n                .headerSearchPath(\"../../common/core/compression\"),\n                .headerSearchPath(\"../../common/core/integrity\"),\n                .headerSearchPath(\"../../common/core/migration\"),\n                .headerSearchPath(\"../../common/core/function/scalar\"),\n                .headerSearchPath(\"../../common/core/fts/auxfunction\"),\n                .headerSearchPath(\"../../common/core/fts/tokenizer\"),\n                .headerSearchPath(\"../../common/winq/extension\"),\n                .headerSearchPath(\"../../common/winq/statement\"),\n                .headerSearchPath(\"../../common/winq/identifier\"),\n                .headerSearchPath(\"../../common/winq/syntax\"),\n                .headerSearchPath(\"../../common/winq/syntax/stmt\"),\n                .headerSearchPath(\"../../common/winq/syntax/const\"),\n                .headerSearchPath(\"../../common/winq/syntax/identifier\"),\n                .headerSearchPath(\"../../common/repair/mechanic\"),\n                .headerSearchPath(\"../../common/repair/parse\"),\n                .headerSearchPath(\"../../common/repair/basic\"),\n                .headerSearchPath(\"../../common/repair/sqlite\"),\n                .headerSearchPath(\"../../common/repair/crawl\"),\n                .headerSearchPath(\"../../common/repair/factory\"),\n                .headerSearchPath(\"../../common/repair/utility\"),\n                .headerSearchPath(\"../../objc/transaction\"),\n                .headerSearchPath(\"../../objc/database\"),\n                .headerSearchPath(\"../../objc/monitor\"),\n                .headerSearchPath(\"../../objc/core\"),\n                .headerSearchPath(\"../../objc/handle\"),\n                .headerSearchPath(\"../../objc/bridge\"),\n                .headerSearchPath(\"../../objc/statement\"),\n                .headerSearchPath(\"../../objc/fts\"),\n                .headerSearchPath(\"../../objc/chaincall\"),\n                .headerSearchPath(\"../../objc/table\"),\n                .headerSearchPath(\"../../objc/compression\"),\n                .headerSearchPath(\"../../objc/orm\"),\n                .headerSearchPath(\"../../objc/convenient\"),\n                .headerSearchPath(\"../../objc/migration\"),\n                .headerSearchPath(\"../../objc/builtin\"),\n                .headerSearchPath(\"../../objc/orm/accessor\"),\n                .headerSearchPath(\"../../objc/orm/binding\"),\n                .headerSearchPath(\"../../objc/orm/macro\"),\n                .headerSearchPath(\"../../objc/orm/coding\")\n            ],\n            linkerSettings: [\n                .linkedFramework(\"UIKit\", .when(platforms: [.iOS])),\n            ]\n        ),\n        .target(\n            name: \"common\",\n            dependencies: [\"sqlcipher\", .target(name: \"objc-core\")],\n            path: \"src/common\",\n            exclude: [\n                \"repair/sqlite\",\n                \"platform/WCTFileManager.cpp\",\n                \"platform/WCTOperationQueue.cpp\",\n            ],\n            publicHeadersPath:\"\",\n            cSettings: [\n                .define(\"SQLITE_WCDB\", to: \"1\"),\n                .define(\"SQLITE_WCDB_LOCK_HOOK\", to: \"1\"),\n                .define(\"SQLITE_WCDB_CHECKPOINT_HANDLER\", to: \"1\"),\n                .define(\"SQLITE_WCDB_SUSPEND\", to: \"1\"),\n                .define(\"SQLITE_WCDB_IMPROVED_CHECKPOINT\", to: \"1\"),\n                .define(\"SQLITE_HAS_CODEC\"),\n                .define(\"SQLITE_DEFAULT_PAGE_SIZE\", to: \"4096\"),\n                .define(\"SQLITE_DEFAULT_SYNCHRONOUS\", to: \"1\"),\n                .define(\"SQLITE_DEFAULT_WAL_SYNCHRONOUS\", to: \"1\"),\n                .define(\"SQLITE_DEFAULT_LOCKING_MODE\", to: \"0\"),\n                .define(\"SQLITE_DEFAULT_WAL_AUTOCHECKPOINT\", to: \"0\"),\n//                .headerSearchPath(\"**\")\n                .headerSearchPath(\"core\"),\n                .headerSearchPath(\"platform\"),\n                .headerSearchPath(\"winq\"),\n                .headerSearchPath(\"repair\"),\n                .headerSearchPath(\"base\"),\n                .headerSearchPath(\"utility\"),\n                .headerSearchPath(\"core/config\"),\n                .headerSearchPath(\"core/assemble\"),\n                .headerSearchPath(\"core/vacuum\"),\n                .headerSearchPath(\"core/cipher\"),\n                .headerSearchPath(\"core/sqlite\"),\n                .headerSearchPath(\"core/function\"),\n                .headerSearchPath(\"core/fts\"),\n                .headerSearchPath(\"core/operate\"),\n                .headerSearchPath(\"core/compression\"),\n                .headerSearchPath(\"core/integrity\"),\n                .headerSearchPath(\"core/migration\"),\n                .headerSearchPath(\"core/function/scalar\"),\n                .headerSearchPath(\"core/fts/auxfunction\"),\n                .headerSearchPath(\"core/fts/tokenizer\"),\n                .headerSearchPath(\"winq/extension\"),\n                .headerSearchPath(\"winq/statement\"),\n                .headerSearchPath(\"winq/identifier\"),\n                .headerSearchPath(\"winq/syntax\"),\n                .headerSearchPath(\"winq/syntax/stmt\"),\n                .headerSearchPath(\"winq/syntax/const\"),\n                .headerSearchPath(\"winq/syntax/identifier\"),\n                .headerSearchPath(\"repair/mechanic\"),\n                .headerSearchPath(\"repair/parse\"),\n                .headerSearchPath(\"repair/basic\"),\n                .headerSearchPath(\"repair/sqlite\"),\n                .headerSearchPath(\"repair/crawl\"),\n                .headerSearchPath(\"repair/factory\"),\n                .headerSearchPath(\"repair/utility\")\n            ],\n            linkerSettings: [\n                .linkedLibrary(\"z\"),\n            ]\n        ),\n        .target(\n            name: \"bridge\",\n            dependencies: [.target(name: \"common\")],\n            path: \"src/bridge\",\n            exclude: [\n                \"tests\",\n            ],\n            cSettings: [\n//                .headerSearchPath(\"../**\")\n                .headerSearchPath(\"../bridge\"),\n                .headerSearchPath(\"../objc\"),\n                .headerSearchPath(\"../bridge/objcbridge\"),\n                .headerSearchPath(\"../bridge/cppbridge\"),\n                .headerSearchPath(\"../bridge/winqbridge\"),\n                .headerSearchPath(\"../bridge/base\"),\n                .headerSearchPath(\"../bridge/winqbridge/statement\"),\n                .headerSearchPath(\"../bridge/winqbridge/identifier\"),\n                .headerSearchPath(\"../common/core\"),\n                .headerSearchPath(\"../common/platform\"),\n                .headerSearchPath(\"../common/winq\"),\n                .headerSearchPath(\"../common/repair\"),\n                .headerSearchPath(\"../common/base\"),\n                .headerSearchPath(\"../common/utility\"),\n                .headerSearchPath(\"../common/core/config\"),\n                .headerSearchPath(\"../common/core/assemble\"),\n                .headerSearchPath(\"../common/core/vacuum\"),\n                .headerSearchPath(\"../common/core/cipher\"),\n                .headerSearchPath(\"../common/core/sqlite\"),\n                .headerSearchPath(\"../common/core/function\"),\n                .headerSearchPath(\"../common/core/fts\"),\n                .headerSearchPath(\"../common/core/operate\"),\n                .headerSearchPath(\"../common/core/compression\"),\n                .headerSearchPath(\"../common/core/integrity\"),\n                .headerSearchPath(\"../common/core/migration\"),\n                .headerSearchPath(\"../common/core/function/scalar\"),\n                .headerSearchPath(\"../common/core/fts/auxfunction\"),\n                .headerSearchPath(\"../common/core/fts/tokenizer\"),\n                .headerSearchPath(\"../common/winq/extension\"),\n                .headerSearchPath(\"../common/winq/statement\"),\n                .headerSearchPath(\"../common/winq/identifier\"),\n                .headerSearchPath(\"../common/winq/syntax\"),\n                .headerSearchPath(\"../common/winq/syntax/stmt\"),\n                .headerSearchPath(\"../common/winq/syntax/const\"),\n                .headerSearchPath(\"../common/winq/syntax/identifier\"),\n                .headerSearchPath(\"../common/repair/mechanic\"),\n                .headerSearchPath(\"../common/repair/parse\"),\n                .headerSearchPath(\"../common/repair/basic\"),\n                .headerSearchPath(\"../common/repair/sqlite\"),\n                .headerSearchPath(\"../common/repair/crawl\"),\n                .headerSearchPath(\"../common/repair/factory\"),\n                .headerSearchPath(\"../common/repair/utility\"),\n                .headerSearchPath(\"../objc/transaction\"),\n                .headerSearchPath(\"../objc/database\"),\n                .headerSearchPath(\"../objc/monitor\"),\n                .headerSearchPath(\"../objc/core\"),\n                .headerSearchPath(\"../objc/handle\"),\n                .headerSearchPath(\"../objc/bridge\"),\n                .headerSearchPath(\"../objc/statement\"),\n                .headerSearchPath(\"../objc/fts\"),\n                .headerSearchPath(\"../objc/chaincall\"),\n                .headerSearchPath(\"../objc/table\"),\n                .headerSearchPath(\"../objc/compression\"),\n                .headerSearchPath(\"../objc/orm\"),\n                .headerSearchPath(\"../objc/convenient\"),\n                .headerSearchPath(\"../objc/migration\"),\n                .headerSearchPath(\"../objc/builtin\"),\n                .headerSearchPath(\"../objc/orm/accessor\"),\n                .headerSearchPath(\"../objc/orm/binding\"),\n                .headerSearchPath(\"../objc/orm/macro\"),\n                .headerSearchPath(\"../objc/orm/coding\")\n            ]\n        ),\n        .target(\n            name: \"WCDBSwift\",\n            dependencies: [.target(name: \"bridge\")],\n            path: \"src/swift\",\n            exclude: [\n                \"tests\"\n            ],\n            publicHeadersPath: \".\",\n            cSettings: [\n//                .headerSearchPath(\"../bridge/**\")\n                .headerSearchPath(\"../bridge\"),\n                .headerSearchPath(\"../bridge/objcbridge\"),\n                .headerSearchPath(\"../bridge/cppbridge\"),\n                .headerSearchPath(\"../bridge/winqbridge\"),\n                .headerSearchPath(\"../bridge/base\"),\n                .headerSearchPath(\"../bridge/winqbridge/statement\"),\n                .headerSearchPath(\"../bridge/winqbridge/identifier\")\n            ]\n        )\n    ],\n    cLanguageStandard: .c11,\n    cxxLanguageStandard: .cxx14\n)\n"
  },
  {
    "path": "README.md",
    "content": "# WCDB\n\n[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](https://github.com/Tencent/wcdb/pulls)\n[![Release Version](https://img.shields.io/badge/Release-2.1.15-brightgreen.svg)](https://github.com/Tencent/wcdb/releases)\n[![Language](https://img.shields.io/badge/Language-%20C++%20%7C%20Java%20%7C%20Kotlin%20%7C%20Swift%20%7C%20Objc-brightgreen.svg)](https://github.com/Tencent/wcdb/wiki)[![Platform](https://img.shields.io/badge/Platform-%20iOS%20%7C%20macOS%20%7C%20Android%20%7C%20Windows%20%7C%20Linux%20%7C%20OpenHarmony-brightgreen.svg)](https://github.com/Tencent/wcdb/wiki)\n\n中文版本请参看[这里][wcdb-wiki]\n\nWCDB is an **efficient**, **complete**, **easy-to-use** mobile database framework used in the WeChat application. It's based on SQLite and SQLCipher, and supports five languages: C++, Java, Kotlin, Swift and Objective-C.\n\n# Feature\n\n## **Easy-to-use**\n\n* **ORM** (Object Relational Mapping): WCDB provides a flexible, easy-to-use ORM for creating tables, indices and constraints, as well as CRUD through C++/Java/Kotlin/Swift/Objc objects.\n* **WINQ** (WCDB language integrated query): WINQ is a native data querying capability which frees developers from writing glue code to concatenate SQL query strings.\n\nWith ORM and WINQ, you can insert, update, query and delete objects from database in one line code: \n\n```c++\n// C++\ndatabase.insertObjects<Sample>(Sample(1, \"text\"), myTable);\ndatabase.updateRow(\"text2\", WCDB_FIELD(Sample::content), myTable, WCDB_FIELD(Sample::id) == 1);\nauto objects = database.getAllObjects<Sample>(myTable, WCDB_FIELD(Sample::id) > 0);\ndatabase.deleteObjects(myTable, WCDB_FIELD(Sample::id) == 1);\n```\n\n```java\n// Java\ndatabase.insertObject(new Sample(1, \"text\"), DBSample.allFields(), myTable);\ndatabase.updateValue(\"text2\", DBSample.content, myTable, DBSample.id.eq(1));\nList<Sample> objects = database.getAllObjects(DBSample.allFields(), myTable, DBSample.id.gt(0));\ndatabase.deleteObjects(myTable, DBSample.id.eq(1));\n```\n\n```kotlin\n// Kotlin\ndatabase.insertObject<Sample>(Sample(1, \"text\"), DBSample.allFields(), myTable)\ndatabase.updateValue(\"text2\", DBSample.content, myTable, DBSample.id.eq(1))\nval objects = database.getAllObjects<Sample>(DBSample.allFields(), myTable, DBSample.id.gt(0))\ndatabase.deleteObjects(myTable, DBSample.id.eq(1))\n```\n\n```swift\n// Swift\ntry database.insert(Sample(id:1, content:\"text\"), intoTable: myTable)\ntry database.update(table: myTable,\n                    on: Sample.Properties.content,\n                    with: \"text2\"\n                    where:Sample.Properties.id == 1)\nlet objects: [Sample] = try database.getObjects(fromTable: myTable,\n                                                where: Sample.Properties.id > 0)\ntry database.delete(fromTable: myTable where: Sample.Properties.id == 1)\n```\n\n```objective-c\n// Objc\n[database insertObject:sample intoTable:myTable];\n[database updateTable:myTable\n          setProperty:Sample.content\n              toValue:@\"text2\"\n                where:Sample.id == 1];\nNSArray* objects = [database getObjectsOfClass:Sample.class\n                                     fromTable:myTable\n                                         where:Sample.id > 0];\n[database deleteFromTable:myTable where:Sample.id == 1];\n```\n\n## **Efficient**\n\nThrough the framework layer and sqlcipher source optimization, WCDB have more efficient performance.\n\n* **Multi-threaded concurrency**: WCDB supports concurrent read-read and read-write access via connection pooling.\n* **Deeply optimized**: WCDB has deeply optimized the source code and configuration of SQLite to adapt to the development scenarios of mobile terminals. At the same time, WCDB has also been optimized for common time-consuming scenarios, such as writing data in batches.\n\n## **Complete**\n\nWCDB summarizes common problems in practice to provide a more complete development experience for database development:\n\n* **Encryption Support**: WCDB supports database encryption via [SQLCipher][sqlcipher].\n* **Corruption recovery**: WCDB provides a built-in repair kit for database corruption recovery.\n* **Anti-injection**: WCDB provides a built-in protection from SQL injection.\n* **Database model upgrade**: The database model is bound to the class definition, so that the addition, deletion and modification of database fields are consistent with the definition of class variables.\n* **Full-text search**: WCDB provides an easy-to-use full-text search interface and includes tokenizers for multiple languages.\n* **Data Migration**: WCDB supports to migrate data from one databasse to another with simple configuration. And developers don't need to care about the intermediate status and progress of the migration.\n* **Data Compression**: WCDB supports to compress content via [Zstd][Zstd] within specific fields of a database table through a simple configuration. Once configured, the details of data compression and decompression become transparent to developers, and WCDB can automatically compress existing data.\n\n## **Compatibility**\n\nWCDB has interfaces in five languages: C++, Java, Kotlin, Swift, and Objc. Interfaces in different languages share the same underlying logic. The code structure of WCDB is shown in the figure below:\n\n<div align=center><img style=\"display:inline-block\" src=\"https://raw.githubusercontent.com/wiki/Tencent/wcdb/assets/common/CodeStructure-English.png\" width = 600/></div>\n\nUnder such architecture, WCDB in different languages can have the same interface structure and interface capabilities. In one project, you can write database code in different languages with one WCDB. Database logic in different languages will not conflict. Some global interfaces such as error monitoring can work on database logic in different languages at the same time. \n\n# Build and Install\n\nFollowing wikies contain the detailed instructions about building and installing of WCDB.\n\n* [Building and Installing of WCDB C++][wcdb-cpp-build-and-install]\n* [Building and Installing of WCDB Java/Kotlin][wcdb-java-build-and-install]\n* [Building and Installing of WCDB Swift][wcdb-swift-build-and-install]\n* [Building and Installing of WCDB Objc][wcdb-objc-build-and-install]\n\n# Tutorials\n\nTutorials of different languages can be found below:\n\n* [Tutorials for WCDB C++][wcdb-cpp-tutorials]\n* [Tutorials for WCDB Java/Kotlin][wcdb-java-tutorials]\n* [Tutorials for WCDB Swift][wcdb-swift-tutorials]\n* [Tutorials for WCDB Objc][wcdb-objc-tutorials]\n\n# Contributing\n\nIf you are interested in contributing, check out the [CONTRIBUTING.md], also join our [Tencent OpenSource Plan](https://opensource.tencent.com/contribution).\n\nWCDB 正式加入[TDS 腾讯端服务产品联盟](https://tds-union.qq.com/)，携手联盟其他成员，共同致力于构建开放共赢的大前端技术产品生态。\n\n# 信息公示\n\n* 开发者: 深圳市腾讯计算机系统有限公司\n\n* [WCDB 个人信息保护规则][wcdb-privacy]\n\n[wcdb-wiki]: https://github.com/Tencent/wcdb/wiki\n[wcdb-docs-android]: https://tencent.github.io/wcdb/references/android/index.html\n[sqlcipher]:https://www.zetetic.net/sqlcipher/\n[Zstd]:https://github.com/facebook/zstd\n[room]: https://developer.android.com/topic/libraries/architecture/room\n[room-codelabs]: https://codelabs.developers.google.com/codelabs/android-room-with-a-view\n[wcdb-cpp-build-and-install]: https://github.com/Tencent/wcdb/wiki/C++-%E5%AE%89%E8%A3%85%E4%B8%8E%E5%85%BC%E5%AE%B9%E6%80%A7\n[wcdb-java-build-and-install]:https://github.com/Tencent/wcdb/wiki/Java%7CKotlin-%e5%ae%89%e8%a3%85%e4%b8%8e%e5%85%bc%e5%ae%b9%e6%80%a7\n[wcdb-objc-build-and-install]:https://github.com/Tencent/wcdb/wiki/Objc-%E5%AE%89%E8%A3%85%E4%B8%8E%E5%85%BC%E5%AE%B9%E6%80%A7\n[wcdb-swift-build-and-install]: https://github.com/Tencent/wcdb/wiki/Swift-%E5%AE%89%E8%A3%85%E4%B8%8E%E5%85%BC%E5%AE%B9%E6%80%A7\n[wcdb-cpp-tutorials]:https://github.com/Tencent/wcdb/wiki/C++-%E5%BF%AB%E9%80%9F%E5%85%A5%E9%97%A8\n[wcdb-java-tutorials]:https://github.com/Tencent/wcdb/wiki/Java%7CKotlin-%E5%BF%AB%E9%80%9F%E5%85%A5%E9%97%A8\n[wcdb-swift-tutorials]:https://github.com/Tencent/wcdb/wiki/Swift-%E5%BF%AB%E9%80%9F%E5%85%A5%E9%97%A8\n[wcdb-objc-tutorials]:https://github.com/Tencent/wcdb/wiki/Objc-%E5%BF%AB%E9%80%9F%E5%85%A5%E9%97%A8\n[Benchmark-iOS]: https://github.com/Tencent/wcdb/wiki/WCDB-iOS-benchmark\n[wcdb-privacy]: https://support.weixin.qq.com/cgi-bin/mmsupportacctnodeweb-bin/pages/GepveGs4q4eAgpoh\n\n"
  },
  {
    "path": "VERSION",
    "content": "2.1.15"
  },
  {
    "path": "WCDB.cpp.podspec",
    "content": "# pod repo update\n# pod repo remove trunk\n# pod lib lint --verbose --skip-import-validation --allow-warnings WCDB.cpp.podspec --sources='https://github.com/CocoaPods/Specs.git'\n# pod trunk push WCDB.cpp.podspec --verbose --skip-import-validation --allow-warnings\nPod::Spec.new do |wcdb|\n  wcdb.name         = \"WCDB.cpp\"\n  wcdb.version      = \"2.1.15\"\n  wcdb.summary      = \"WCDB is a cross-platform database framework developed by WeChat.\"\n  wcdb.description  = <<-DESC\n                      The WeChat Database, for C++. (If you want to use WCDB for Swift or Objective-C, see the \"WCDB.swift\" pod or \"WCDB.objc\" pod. If you want to use WCDB for C++/Objc/Swift in one project, see the \"WCDB\" pod)\n\n                      WCDB is an efficient, complete, easy-to-use mobile database framework used in the WeChat application.\n                      It can be a replacement for Core Data, SQLite & FMDB.\n                      DESC\n  wcdb.homepage     = \"https://github.com/Tencent/wcdb\"\n  wcdb.license      = { :type => \"BSD\", :file => \"LICENSE\" }\n  wcdb.author       = { \"Qiuwen-Chen\" => \"qwchen2008@163.com\" }\n  wcdb.module_name  = \"WCDBCpp\"\n  wcdb.ios.deployment_target = \"11.0\"\n  wcdb.osx.deployment_target = \"10.13\"\n  wcdb.watchos.deployment_target = \"6.0\"\n  wcdb.tvos.deployment_target = \"12.4\"\n  wcdb.source       = { :git => \"https://github.com/Tencent/wcdb.git\", :tag => \"v#{wcdb.version}\" }\n  wcdb.public_header_files = [\n  \t\"src/cpp/WCDBCpp.h\",\n\t\"src/cpp/**/*.{h,hpp}\",\n\t\"src/common/winq/*.{h,hpp}\",\n\t\"src/common/winq/**/*.{h,hpp}\",\n\t\"src/common/platform/SysTypes.h\",\n\t\"src/common/utility/Shadow.hpp\",\n\t\"src/common/utility/Macro.h\",\n\t\"src/common/utility/CaseInsensitiveList.hpp\",\n\t\"src/common/core/function/scalar/ScalarFunctionModule.hpp\",\n  \"src/common/core/function/scalar/ScalarFunctionTemplate.hpp\", \n\t\"src/common/core/fts/FTSConst.h\",\n\t\"src/common/core/fts/tokenizer/TokenizerModule.hpp\",\n\t\"src/common/core/fts/tokenizer/TokenizerModuleTemplate.hpp\",\n\t\"src/common/core/fts/tokenizer/BaseTokenizerUtil.hpp\",\n\t\"src/common/core/fts/tokenizer/PinyinTokenizer.hpp\",\n\t\"src/common/core/fts/tokenizer/OneOrBinaryTokenizer.hpp\",\n\t\"src/common/core/fts/auxfunction/FTS5AuxiliaryFunctionTemplate.hpp\",\n\t\"src/common/core/fts/auxfunction/AuxiliaryFunctionModule.hpp\",\n\t\"src/common/core/fts/auxfunction/SubstringMatchInfo.hpp\",\n\t\"src/common/core/fts/FTSError.hpp\",\n\t\"src/common/core/RecyclableHandle.hpp\",\n\t\"src/common/core/Tag.hpp\",\n\t\"src/common/base/Recyclable.hpp\",\n\t\"src/common/base/SharedThreadedErrorProne.hpp\",\n\t\"src/common/base/StringView.hpp\",\n\t\"src/common/base/WCDBOptional.hpp\",\n\t\"src/common/base/WCDBError.hpp\",\n\t\"src/common/base/Data.hpp\",\n\t\"src/common/base/UnsafeData.hpp\",\n\t\"src/common/base/MemberPointer.hpp\" \n  ]\n  wcdb.source_files  = [\n  \t\"src/common/**/*.{h,hpp,c,cpp}\",\n\t\"src/cpp/**/*.{h,hpp,c,cpp}\",\n\t\"src/objc/core/WCTFileManager.mm\",\n  \"src/objc/core/WCTOperationQueue.mm\",\n\t\"src/objc/core/WCTFoundation.h\",\n\t\"src/objc/core/WCTFoundation.mm\"\n  ]\n  wcdb.exclude_files = [\n  \t\"src/cpp/tests/**/*.{h,hpp,c,cpp}\",\n  \t\"src/common/platform/WCTFileManager.cpp\",\n  \t\"src/common/platform/WCTOperationQueue.cpp\",\n  ]\n  wcdb.frameworks = \"CoreFoundation\", \"Security\", \"Foundation\"\n  wcdb.ios.frameworks = \"UIKit\"\n  wcdb.libraries = \"z\", \"c++\"\n  wcdb.requires_arc = true\n  wcdb.pod_target_xcconfig = { \n    \"GCC_PREPROCESSOR_DEFINITIONS\" =>   \"SQLITE_WCDB=1 \" +\n\t\t\t\t\t\t\t\t\t\t\"SQLITE_WCDB_LOCK_HOOK=1 \" +\n\t\t\t\t\t\t\t\t\t\t\"SQLITE_WCDB_CHECKPOINT_HANDLER=1 \" +\n\t\t\t\t\t\t\t\t\t\t\"SQLITE_WCDB_SUSPEND=1 \" +\n\t\t\t\t\t\t\t\t\t\t\"SQLITE_WCDB_IMPROVED_CHECKPOINT=1 \" +\n\t\t\t\t\t\t\t\t\t\t\"SQLITE_HAS_CODEC \" +\n\t\t\t\t\t\t\t\t\t\t\"SQLITE_DEFAULT_PAGE_SIZE=4096 \" +\n\t\t\t\t\t\t\t\t\t\t\"SQLITE_DEFAULT_SYNCHRONOUS=1 \" +\n\t\t\t\t\t\t\t\t\t\t\"SQLITE_DEFAULT_WAL_SYNCHRONOUS=1 \" +\n\t\t\t\t\t\t\t\t\t\t\"SQLITE_DEFAULT_LOCKING_MODE=0 \" +\n\t\t\t\t\t\t\t\t\t\t\"SQLITE_DEFAULT_WAL_AUTOCHECKPOINT=0\",\n    \"HEADER_SEARCH_PATHS\" => \"${PODS_ROOT}/WCDB\",\n    \"LIBRARY_SEARCH_PATHS[sdk=macosx*]\" => \"$(SDKROOT)/usr/lib/system\",\n    \"CLANG_CXX_LANGUAGE_STANDARD\" => \"gnu++14\",\n    \"CLANG_CXX_LIBRARY\" => \"libc++\",\n    \"GCC_C_LANGUAGE_STANDARD\" => \"gnu11\",\n    \"VALID_ARCHS\" => \"arm64e arm64 x86_64\",\n    \"VALID_ARCHS[sdk=watchos*]\" => \"arm64_32 arm64 x86_64\",\n    \"OTHER_CFLAGS\" => \"-fvisibility-inlines-hidden\",\n    \"OTHER_CPLUSPLUSFLAGS\" => \"-fvisibility-inlines-hidden\",\n  }\n  wcdb.user_target_xcconfig = { \n    \"VALID_ARCHS\" => \"arm64e arm64 x86_64\",\n    \"VALID_ARCHS[sdk=watchos*]\" => \"arm64_32 armv7k\",\n  }\n  wcdb.header_dir = \"WCDB\"\n  wcdb.dependency 'WCDBOptimizedSQLCipher', '1.4.8'\nend\n"
  },
  {
    "path": "WCDB.objc.podspec",
    "content": "# pod repo update\n# pod repo remove trunk\n# pod lib lint --verbose --skip-import-validation --allow-warnings WCDB.objc.podspec --sources='https://github.com/CocoaPods/Specs.git'\n# pod trunk push WCDB.objc.podspec --verbose --skip-import-validation --allow-warnings\nPod::Spec.new do |wcdb|\n  wcdb.name         = \"WCDB.objc\"\n  wcdb.version      = \"2.1.15\"\n  wcdb.summary      = \"WCDB is a cross-platform database framework developed by WeChat.\"\n  wcdb.description  = <<-DESC\n                      The WeChat Database, for Objective-C. (If you want to use WCDB for Swift or C++, see the \"WCDB.swift\" pod or \"WCDB.cpp\" pod. If you want to use WCDB for C++/Objc/Swift in one project, see the \"WCDB\" pod)\n\n                      WCDB is an efficient, complete, easy-to-use mobile database framework used in the WeChat application.\n                      It can be a replacement for Core Data, SQLite & FMDB.\n                      DESC\n  wcdb.homepage     = \"https://github.com/Tencent/wcdb\"\n  wcdb.license      = { :type => \"BSD\", :file => \"LICENSE\" }\n  wcdb.author       = { \"Qiuwen-Chen\" => \"qwchen2008@163.com\" }\n  wcdb.module_name  = \"WCDBObjc\"\n  wcdb.ios.deployment_target = \"11.0\"\n  wcdb.osx.deployment_target = \"10.13\"\n  wcdb.watchos.deployment_target = \"7.0\"\n  wcdb.tvos.deployment_target = \"12.4\"\n  wcdb.source       = { :git => \"https://github.com/Tencent/wcdb.git\", :tag => \"v#{wcdb.version}\" }\n  wcdb.public_header_files = [\n  \t\"src/objc/WCDBObjc.h\", \n\t\"src/objc/Interface.h\", \n\t\"src/objc/core/*.{h,hpp}\", \n\t\"src/objc/builtin/*.{h,hpp}\", \n\t\"src/objc/statement/WCTPreparedStatement.h\", \n\t\"src/objc/migration/WCTDatabase+Migration.h\", \n\t\"src/objc/migration/WCTMigrationInfo.h\", \n\t\"src/objc/compression/WCTDatabase+Compression.h\", \n\t\"src/objc/compression/WCTCompressionInfo.h\", \n\t\"src/objc/transaction/*.{h,hpp}\", \n\t\"src/objc/handle/WCTDatabase+Handle.h\", \n\t\"src/objc/handle/WCTHandle.h\", \n\t\"src/objc/handle/WCTCancellationSignal.h\", \n\t\"src/objc/fts/*.{h,hpp}\", \n\t\"src/objc/monitor/WCTError.h\", \n\t\"src/objc/monitor/WCTDatabase+Monitor.h\", \n\t\"src/objc/monitor/WCTPerformanceInfo.h\", \n\t\"src/objc/chaincall/WCTInsert.h\", \n\t\"src/objc/chaincall/WCTDelete.h\", \n\t\"src/objc/chaincall/WCTUpdate.h\", \n\t\"src/objc/chaincall/WCTSelectable.h\", \n\t\"src/objc/chaincall/WCTSelect.h\", \n\t\"src/objc/chaincall/WCTMultiSelect.h\", \n\t\"src/objc/chaincall/WCTHandle+ChainCall.h\", \n\t\"src/objc/chaincall/WCTTable+ChainCall.h\", \n\t\"src/objc/chaincall/WCTDatabase+ChainCall.h\", \n\t\"src/objc/chaincall/WCTChainCall.h\", \n\t\"src/objc/convenient/*.{h,hpp}\", \n\t\"src/objc/database/WCTDatabase.h\", \n\t\"src/objc/database/WCTDatabase+File.h\", \n\t\"src/objc/database/WCTDatabase+Repair.h\", \n\t\"src/objc/database/WCTDatabase+Config.h\", \n\t\"src/objc/database/WCTDatabase+Memory.h\", \n\t\"src/objc/orm/*.{h,hpp}\", \n\t\"src/objc/orm/**/*.{h,hpp}\", \n\t\"src/objc/table/WCTTable.h\", \n\t\"src/objc/table/WCTTableProtocol.h\", \n\t\"src/objc/table/WCTTable+Table.h\", \n\t\"src/objc/table/WCTDatabase+Table.h\", \n\t\"src/objc/table/WCTHandle+Table.h\", \n\t\"src/objc/bridge/WCTBridgeProperty.h\", \n\t\"src/objc/bridge/WCTBridgeProperty+Cpp.h\", \n\t\"src/common/winq/*.{h,hpp}\", \n\t\"src/common/winq/**/*.{h,hpp}\", \n\t\"src/common/platform/SysTypes.h\", \n\t\"src/common/utility/Shadow.hpp\", \n\t\"src/common/utility/Macro.h\", \n\t\"src/common/utility/CaseInsensitiveList.hpp\", \n\t\"src/common/core/function/scalar/ScalarFunctionModule.hpp\", \n\t\"src/common/core/function/scalar/ScalarFunctionTemplate.hpp\", \n\t\"src/common/core/fts/tokenizer/TokenizerModule.hpp\", \n\t\"src/common/core/fts/tokenizer/TokenizerModuleTemplate.hpp\", \n\t\"src/common/core/fts/tokenizer/BaseTokenizerUtil.hpp\", \n\t\"src/common/core/fts/tokenizer/PinyinTokenizer.hpp\", \n\t\"src/common/core/fts/tokenizer/OneOrBinaryTokenizer.hpp\", \n\t\"src/common/core/fts/auxfunction/FTS5AuxiliaryFunctionTemplate.hpp\", \n\t\"src/common/core/fts/auxfunction/AuxiliaryFunctionModule.hpp\", \n\t\"src/common/core/fts/auxfunction/SubstringMatchInfo.hpp\", \n\t\"src/common/core/fts/FTSError.hpp\", \n\t\"src/common/core/RecyclableHandle.hpp\", \n\t\"src/common/core/Tag.hpp\", \n\t\"src/common/base/Recyclable.hpp\", \n\t\"src/common/base/SharedThreadedErrorProne.hpp\", \n\t\"src/common/base/StringView.hpp\", \n\t\"src/common/base/WCDBOptional.hpp\", \n\t\"src/common/base/WCDBError.hpp\", \n\t\"src/common/base/Data.hpp\", \n\t\"src/common/base/UnsafeData.hpp\", \n\t\"src/common/base/MemberPointer.hpp\",\n\t\"src/common/base/Assertion.hpp\",\n\t\"src/common/base/Console.hpp\",\n\t\"src/common/utility/Enum.hpp\"\n  ]\n  wcdb.source_files  = [\n  \t\"src/common/**/*.{h,hpp,c,cpp}\", \n\t\"src/objc/**/*.{h,hpp,c,cpp,m,mm}\", \n  ]\n  wcdb.exclude_files = [\n  \t\"src/common/platform/WCTFileManager.cpp\", \n\t\"src/common/platform/WCTOperationQueue.cpp\", \n\t\"src/objc/tests/**/*.{h,hpp,c,cpp,m,mm}\"\n  ]\n  wcdb.frameworks = \"CoreFoundation\", \"Security\", \"Foundation\"\n  wcdb.ios.frameworks = \"UIKit\"\n  wcdb.libraries = \"z\", \"c++\"\n  wcdb.requires_arc = true\n  wcdb.pod_target_xcconfig = { \n    \"GCC_PREPROCESSOR_DEFINITIONS\" =>   \"SQLITE_WCDB=1 \" +\n\t\t\t\t\t\t\t\t\t\t\"SQLITE_WCDB_LOCK_HOOK=1 \" +\n\t\t\t\t\t\t\t\t\t\t\"SQLITE_WCDB_CHECKPOINT_HANDLER=1 \" +\n\t\t\t\t\t\t\t\t\t\t\"SQLITE_WCDB_SUSPEND=1 \" +\n\t\t\t\t\t\t\t\t\t\t\"SQLITE_WCDB_IMPROVED_CHECKPOINT=1 \" +\n\t\t\t\t\t\t\t\t\t\t\"SQLITE_HAS_CODEC \" +\n\t\t\t\t\t\t\t\t\t\t\"SQLITE_DEFAULT_PAGE_SIZE=4096 \" +\n\t\t\t\t\t\t\t\t\t\t\"SQLITE_DEFAULT_SYNCHRONOUS=1 \" +\n\t\t\t\t\t\t\t\t\t\t\"SQLITE_DEFAULT_WAL_SYNCHRONOUS=1 \" +\n\t\t\t\t\t\t\t\t\t\t\"SQLITE_DEFAULT_LOCKING_MODE=0 \" +\n\t\t\t\t\t\t\t\t\t\t\"SQLITE_DEFAULT_WAL_AUTOCHECKPOINT=0\",\n    \"HEADER_SEARCH_PATHS\" => \"${PODS_ROOT}/WCDB\",\n    \"LIBRARY_SEARCH_PATHS[sdk=macosx*]\" => \"$(SDKROOT)/usr/lib/system\",\n    \"CLANG_CXX_LANGUAGE_STANDARD\" => \"gnu++14\",\n    \"CLANG_CXX_LIBRARY\" => \"libc++\",\n    \"GCC_C_LANGUAGE_STANDARD\" => \"gnu11\",\n    \"VALID_ARCHS\" => \"arm64e arm64 x86_64\",\n    \"VALID_ARCHS[sdk=watchos*]\" => \"arm64_32 arm64 x86_64\",\n    \"OTHER_CFLAGS\" => \"-fvisibility-inlines-hidden\",\n    \"OTHER_CPLUSPLUSFLAGS\" => \"-fvisibility-inlines-hidden\",\n  }\n  wcdb.header_dir = \"WCDB\"\n  wcdb.dependency 'WCDBOptimizedSQLCipher', '1.4.8'\nend\n"
  },
  {
    "path": "WCDB.podspec",
    "content": "# pod repo update\n# pod repo remove trunk\n# pod lib lint --verbose --skip-import-validation --allow-warnings WCDB.podspec --sources='https://github.com/CocoaPods/Specs.git'\n# pod trunk push --verbose --allow-warnings WCDB.podspec --skip-import-validation\nPod::Spec.new do |wcdb|\n  wcdb.name         = \"WCDB\"\n  wcdb.version      = \"2.1.15\"\n  wcdb.summary      = \"WCDB is a cross-platform database framework developed by WeChat.\"\n  wcdb.description  = <<-DESC\n                      The WeChat Database, for Objc/Swift/C++. (If you want to use WCDB for Objc/Swift/C++ separately, see the \"WCDB.objc\", \"WCDB.swift\" or \"WCDB.cpp\" pod.)\n\n                      WCDB is an efficient, complete, easy-to-use mobile database framework used in the WeChat application.\n                      It can be a replacement for Core Data, SQLite & FMDB.\n                      DESC\n  wcdb.homepage     = \"https://github.com/Tencent/wcdb\"\n  wcdb.license      = { :type => \"BSD\", :file => \"LICENSE\" }\n  wcdb.author       = { \"Qiuwen-Chen\" => \"qwchen2008@163.com\" }\n  wcdb.module_name  = \"WCDB\"\n  wcdb.ios.deployment_target = \"11.0\"\n  wcdb.osx.deployment_target = \"10.13\"\n  wcdb.watchos.deployment_target = \"7.0\"\n  wcdb.tvos.deployment_target = \"12.4\"\n  wcdb.source       = { :git => \"https://github.com/Tencent/wcdb.git\", :tag => \"v#{wcdb.version}\" }\n  wcdb.public_header_files = [\n  \t\"src/WCDB.h\", \n\t\"src/objc/WCDBObjc.h\", \n\t\"src/objc/Interface.h\", \n\t\"src/objc/core/*.{h,hpp}\", \n\t\"src/objc/builtin/*.{h,hpp}\", \n\t\"src/objc/statement/WCTPreparedStatement.h\", \n\t\"src/objc/migration/WCTDatabase+Migration.h\", \n\t\"src/objc/migration/WCTMigrationInfo.h\", \n\t\"src/objc/compression/WCTDatabase+Compression.h\", \n\t\"src/objc/compression/WCTCompressionInfo.h\", \n\t\"src/objc/transaction/*.{h,hpp}\", \n\t\"src/objc/handle/WCTDatabase+Handle.h\", \n\t\"src/objc/handle/WCTHandle.h\", \n\t\"src/objc/handle/WCTCancellationSignal.h\", \n\t\"src/objc/fts/*.{h,hpp}\", \n\t\"src/objc/monitor/WCTError.h\", \n\t\"src/objc/monitor/WCTDatabase+Monitor.h\", \n\t\"src/objc/monitor/WCTPerformanceInfo.h\", \n\t\"src/objc/chaincall/WCTInsert.h\", \n\t\"src/objc/chaincall/WCTDelete.h\", \n\t\"src/objc/chaincall/WCTUpdate.h\", \n\t\"src/objc/chaincall/WCTSelectable.h\", \n\t\"src/objc/chaincall/WCTSelect.h\", \n\t\"src/objc/chaincall/WCTMultiSelect.h\", \n\t\"src/objc/chaincall/WCTHandle+ChainCall.h\", \n\t\"src/objc/chaincall/WCTTable+ChainCall.h\", \n\t\"src/objc/chaincall/WCTDatabase+ChainCall.h\", \n\t\"src/objc/chaincall/WCTChainCall.h\", \n\t\"src/objc/convenient/*.{h,hpp}\", \n\t\"src/objc/database/WCTDatabase.h\", \n\t\"src/objc/database/WCTDatabase+File.h\", \n\t\"src/objc/database/WCTDatabase+Repair.h\", \n\t\"src/objc/database/WCTDatabase+Config.h\", \n\t\"src/objc/database/WCTDatabase+Memory.h\", \n\t\"src/objc/orm/*.{h,hpp}\", \n\t\"src/objc/orm/**/*.{h,hpp}\", \n\t\"src/objc/table/WCTTable.h\", \n\t\"src/objc/table/WCTTableProtocol.h\", \n\t\"src/objc/table/WCTTable+Table.h\", \n\t\"src/objc/table/WCTDatabase+Table.h\", \n\t\"src/objc/table/WCTHandle+Table.h\", \n\t\"src/objc/bridge/WCTBridgeProperty.h\", \n\t\"src/objc/bridge/WCTBridgeProperty+Cpp.h\", \n\t\"src/common/winq/*.{h,hpp}\", \n\t\"src/common/winq/**/*.{h,hpp}\", \n\t\"src/common/platform/SysTypes.h\", \n\t\"src/common/utility/Shadow.hpp\", \n\t\"src/common/utility/Macro.h\", \n\t\"src/common/utility/CaseInsensitiveList.hpp\", \n\t\"src/common/core/function/scalar/ScalarFunctionModule.hpp\", \n\t\"src/common/core/function/scalar/ScalarFunctionTemplate.hpp\", \n\t\"src/common/core/fts/FTSConst.h\", \n\t\"src/common/core/fts/tokenizer/TokenizerModule.hpp\", \n\t\"src/common/core/fts/tokenizer/TokenizerModuleTemplate.hpp\", \n\t\"src/common/core/fts/tokenizer/BaseTokenizerUtil.hpp\", \n\t\"src/common/core/fts/tokenizer/PinyinTokenizer.hpp\", \n\t\"src/common/core/fts/tokenizer/OneOrBinaryTokenizer.hpp\", \n\t\"src/common/core/fts/auxfunction/FTS5AuxiliaryFunctionTemplate.hpp\", \n\t\"src/common/core/fts/auxfunction/AuxiliaryFunctionModule.hpp\", \n\t\"src/common/core/fts/auxfunction/SubstringMatchInfo.hpp\", \n\t\"src/common/core/fts/FTSError.hpp\", \n\t\"src/common/core/RecyclableHandle.hpp\", \n\t\"src/common/core/Tag.hpp\", \n\t\"src/common/base/Recyclable.hpp\", \n\t\"src/common/base/SharedThreadedErrorProne.hpp\", \n\t\"src/common/base/StringView.hpp\", \n\t\"src/common/base/WCDBOptional.hpp\", \n\t\"src/common/base/WCDBError.hpp\", \n\t\"src/common/base/Data.hpp\", \n\t\"src/common/base/UnsafeData.hpp\", \n\t\"src/common/base/MemberPointer.hpp\", \n\t\"src/cpp/WCDBCpp.h\", \n\t\"src/cpp/**/*.{h,hpp}\", \n\t\"src/bridge/objcbridge/WCTBridgeMacro.h\", \n  ]\n  wcdb.private_header_files = [\n  \t\"src/bridge/WCDBBridging.h\",\n\t\"src/bridge/base/**/*.{h}\",\n\t\"src/bridge/cppbridge/**/*.{h}\",\n\t\"src/bridge/winqbridge/**/*.{h}\",\n\t\"src/bridge/objcbridge/WCTAPIBridge.h\"\n  ]\n  wcdb.source_files  = [\n  \t\"src/WCDB.h\",\n\t\"src/common/**/*.{swift,h,hpp,c,cpp,m,mm}\",\n\t\"src/objc/**/*.{swift,h,hpp,c,cpp,m,mm}\",\n\t\"src/cpp/**/*.{swift,h,hpp,c,cpp,m,mm}\",\n\t\"src/swift/**/*.{swift,h,hpp,c,cpp,m,mm}\",\n\t\"src/bridge/**/*.{swift,h,hpp,c,cpp,m,mm}\"\n  ]\n  wcdb.exclude_files = [\n  \t\"src/common/platform/WCTFileManager.cpp\",\n\t\"src/common/platform/WCTOperationQueue.cpp\",\n\t\"src/cpp/tests/**/*.{swift,h,hpp,c,cpp,m,mm}\",\n\t\"src/objc/tests/**/*.{swift,h,hpp,c,cpp,m,mm}\",\n\t\"src/swift/tests/**/*.{swift,h,hpp,c,cpp,m,mm}\",\n\t\"src/bridge/tests/**/*.{swift,h,hpp,c,cpp,m,mm}\",\n\t\"src/bridge/include/**/*.{swift,h,hpp,c,cpp,m,mm}\",\n  ]\n  wcdb.preserve_path = \"src/support/WCDB.modulemap\"\n  wcdb.module_map = \"src/support/WCDB.modulemap\"\n  wcdb.frameworks = \"CoreFoundation\", \"Security\", \"Foundation\"\n  wcdb.ios.frameworks = \"UIKit\"\n  wcdb.libraries = \"z\", \"c++\"\n  wcdb.requires_arc = true\n  wcdb.pod_target_xcconfig = {\n    \"GCC_PREPROCESSOR_DEFINITIONS\" =>   \"SQLITE_WCDB=1 \" +\n\t\t\t\t\t\t\t\t\t\t\"SQLITE_WCDB_LOCK_HOOK=1 \" +\n\t\t\t\t\t\t\t\t\t\t\"SQLITE_WCDB_CHECKPOINT_HANDLER=1 \" +\n\t\t\t\t\t\t\t\t\t\t\"SQLITE_WCDB_SUSPEND=1 \" +\n\t\t\t\t\t\t\t\t\t\t\"SQLITE_WCDB_IMPROVED_CHECKPOINT=1 \" +\n\t\t\t\t\t\t\t\t\t\t\"SQLITE_HAS_CODEC \" +\n\t\t\t\t\t\t\t\t\t\t\"SQLITE_DEFAULT_PAGE_SIZE=4096 \" +\n\t\t\t\t\t\t\t\t\t\t\"SQLITE_DEFAULT_SYNCHRONOUS=1 \" +\n\t\t\t\t\t\t\t\t\t\t\"SQLITE_DEFAULT_WAL_SYNCHRONOUS=1 \" +\n\t\t\t\t\t\t\t\t\t\t\"SQLITE_DEFAULT_LOCKING_MODE=0 \" +\n\t\t\t\t\t\t\t\t\t\t\"SQLITE_DEFAULT_WAL_AUTOCHECKPOINT=0 \" +\n\t\t\t\t\t\t\t\t\t\t\"WCDB_SWIFT_BRIDGE_OBJC=1\",\n    \"HEADER_SEARCH_PATHS\" => \"${PODS_ROOT}/WCDB\",\n    \"LIBRARY_SEARCH_PATHS[sdk=macosx*]\" => \"$(SDKROOT)/usr/lib/system\",\n    \"CLANG_CXX_LANGUAGE_STANDARD\" => \"gnu++14\",\n    \"CLANG_CXX_LIBRARY\" => \"libc++\",\n    \"GCC_C_LANGUAGE_STANDARD\" => \"gnu11\",\n    \"VALID_ARCHS\" => \"arm64e arm64 x86_64\",\n    \"VALID_ARCHS[sdk=watchos*]\" => \"arm64_32 arm64 86_64\",\n    \"OTHER_CFLAGS\" => \"-fvisibility-inlines-hidden\",\n    \"OTHER_CPLUSPLUSFLAGS\" => \"-fvisibility-inlines-hidden\",\n    \"OTHER_SWIFT_FLAGS\" => \"-no-verify-emitted-module-interface\",\n    \"SWIFT_ACTIVE_COMPILATION_CONDITIONS\" => \"WCDB_SWIFT_BRIDGE_OBJC\",\n  }\n  wcdb.header_dir = \"WCDB\"\n  wcdb.swift_versions = '5'\n  wcdb.dependency 'WCDBOptimizedSQLCipher', '1.4.8'\nend\n"
  },
  {
    "path": "WCDB.swift.podspec",
    "content": "# pod repo update\n# pod repo remove trunk\n# pod lib lint --verbose --allow-warnings WCDB.swift.podspec --sources='https://github.com/CocoaPods/Specs.git'\n# pod trunk push --verbose --allow-warnings WCDB.swift.podspec\nPod::Spec.new do |wcdb|\n  wcdb.name         = \"WCDB.swift\"\n  wcdb.version      = \"2.1.15\"\n  wcdb.summary      = \"WCDB is a cross-platform database framework developed by WeChat.\"\n  wcdb.description  = <<-DESC\n                      The WeChat Database, for Swift. (If you want to use WCDB for Objective-C or C++, see the \"WCDB.objc\" pod or \"WCDB.cpp\" pod. If you want to use WCDB for C++/Objc/Swift in one project, see the \"WCDB\" pod)\n\n                      WCDB is an efficient, complete, easy-to-use mobile database framework used in the WeChat application.\n                      It can be a replacement for Core Data, SQLite & FMDB.\n                      DESC\n  wcdb.homepage     = \"https://github.com/Tencent/wcdb\"\n  wcdb.module_name  = \"WCDBSwift\"\n  wcdb.license      = { :type => \"BSD\", :file => \"LICENSE\" }\n  wcdb.author       = { \"Qiuwen-Chen\" => \"qwchen2008@163.com\" }\n  wcdb.ios.deployment_target = \"11.0\"\n  wcdb.osx.deployment_target = \"10.13\"\n  wcdb.watchos.deployment_target = \"7.0\"\n  wcdb.tvos.deployment_target = \"12.4\"\n  wcdb.source       = { :git => \"https://github.com/Tencent/wcdb.git\", :tag => \"v#{wcdb.version}\" }\n  wcdb.private_header_files = \"src/bridge/**/*.{h}\"\n  wcdb.source_files  = [\n  \t\"src/swift/**/*.{swift}\",\n  \t\"src/bridge/**/*.{swift,h,hpp,c,cpp,m,mm}\",\n  \t\"src/common/**/*.{swift,h,hpp,c,cpp,m,mm}\",\n  \t\"src/objc/core/WCTFileManager.mm\",\n    \"src/objc/core/WCTOperationQueue.mm\", \n  \t\"src/objc/core/WCTFoundation.h\",\n  \t\"src/objc/core/WCTFoundation.mm\",\n  \t\"src/objc/core/WCTFTSTokenizerUtil.h\",\n  \t\"src/objc/core/WCTFTSTokenizerUtil.mm\",\n  \t\"src/objc/core/WCTDeclaration.h\",\n  \t\"src/objc/core/WCTValue.h\",\n  \t\"src/objc/orm/coding/WCTColumnCoding.h\",\n  \t\"src/objc/orm/macro/WCTPropertyMacro.h\",\n  \t\"src/objc/orm/coding/WCTTableCoding.h\",\n  \t\"src/objc/core/WCTConvertible.h\",\n  \t\"src/objc/core/WCTCommon.h\",\n  \t\"src/objc/core/WCTOptional.h\",\n  \t\"src/objc/core/WCTTag.h\"\n  ]\n  wcdb.exclude_files = [\n  \t\"src/swift/tests/**/*.{swift,h,hpp,c,cpp,m,mm}\",\n  \t\"src/bridge/tests/**/*.{swift,h,hpp,c,cpp,m,mm}\",\n    \"src/bridge/include/**/*.{swift,h,hpp,c,cpp,m,mm}\",\n  \t\"src/common/platform/WCTFileManager.cpp\",\n  \t\"src/common/platform/WCTOperationQueue.cpp\",\n  ]\n  wcdb.requires_arc = true\n  wcdb.preserve_path = \"src/support/WCDBSwift.modulemap\"\n  wcdb.module_map = \"src/support/WCDBSwift.modulemap\"\n  wcdb.frameworks = \"CoreFoundation\", \"Security\", \"Foundation\"\n  wcdb.libraries = \"z\", \"c++\"\n  wcdb.pod_target_xcconfig = { \n    \"GCC_PREPROCESSOR_DEFINITIONS\" =>   \"SQLITE_WCDB=1 \" +\n\t\t\t\t\t\t\t\t\t\t\"SQLITE_WCDB_LOCK_HOOK=1 \" +\n\t\t\t\t\t\t\t\t\t\t\"SQLITE_WCDB_CHECKPOINT_HANDLER=1 \" +\n\t\t\t\t\t\t\t\t\t\t\"SQLITE_WCDB_SUSPEND=1 \" +\n\t\t\t\t\t\t\t\t\t\t\"SQLITE_WCDB_IMPROVED_CHECKPOINT=1 \" +\n\t\t\t\t\t\t\t\t\t\t\"SQLITE_HAS_CODEC \" +\n\t\t\t\t\t\t\t\t\t\t\"SQLITE_DEFAULT_PAGE_SIZE=4096 \" +\n\t\t\t\t\t\t\t\t\t\t\"SQLITE_DEFAULT_SYNCHRONOUS=1 \" +\n\t\t\t\t\t\t\t\t\t\t\"SQLITE_DEFAULT_WAL_SYNCHRONOUS=1 \" +\n\t\t\t\t\t\t\t\t\t\t\"SQLITE_DEFAULT_LOCKING_MODE=0 \" +\n\t\t\t\t\t\t\t\t\t\t\"SQLITE_DEFAULT_WAL_AUTOCHECKPOINT=0\",\n    'SWIFT_WHOLE_MODULE_OPTIMIZATION' => 'YES',\n    'APPLICATION_EXTENSION_API_ONLY' => 'YES',\n    \"HEADER_SEARCH_PATHS\" => \"${PODS_ROOT}/WCDBSwift\",\n    \"LIBRARY_SEARCH_PATHS[sdk=macosx*]\" => \"$(SDKROOT)/usr/lib/system\",\n    \"CLANG_CXX_LANGUAGE_STANDARD\" => \"gnu++14\",\n    \"CLANG_CXX_LIBRARY\" => \"libc++\",\n    \"GCC_C_LANGUAGE_STANDARD\" => \"gnu11\",\n    \"VALID_ARCHS\" => \"arm64e arm64 x86_64\",\n    \"VALID_ARCHS[sdk=watchos*]\" => \"arm64_32 arm64 x86_64\",\n    \"OTHER_CFLAGS\" => \"-fvisibility-inlines-hidden\",\n    \"OTHER_CPLUSPLUSFLAGS\" => \"-fvisibility-inlines-hidden\",\n    \"OTHER_SWIFT_FLAGS\" => \"-no-verify-emitted-module-interface\",\n    \"SWIFT_ACTIVE_COMPILATION_CONDITIONS\" => \"WCDB_SWIFT_TARGET\",\n  }\n  wcdb.swift_versions = '5'\n  wcdb.dependency 'WCDBOptimizedSQLCipher', '1.4.8'\nend\n"
  },
  {
    "path": "deprecated/android/.gitignore",
    "content": "# Visual Studio\n/vsproj/*\n!/vsproj/*.sln\n!/vsproj/*.vcxproj*\n\n# Android Studio, Gradle\n/local.properties\n/build\n/captures\n**/local.gradle\n"
  },
  {
    "path": "deprecated/android/Android.mk",
    "content": "real_local_path := $(call my-dir)\nroot_path := $(call parent-dir, $(real_local_path))\nprebuilt_path := $(root_path)/android/prebuilt/$(TARGET_ARCH)\nbuild_info_path := $(NDK_OUT)\n\ncommon_cflags := -Wall -Werror -Wno-unused-const-variable \\\n\t-ffunction-sections -fdata-sections \\\n\t-DSQLITE_HAS_CODEC -DSQLITE_CORE -DSQLITE_OS_UNIX\ncommon_cppflags := -std=c++17 -fno-exceptions -fno-rtti\ncommon_c_includes := \\\n\t$(prebuilt_path)/include \\\n\t$(root_path)/android/sqlcipher \\\n\t$(root_path)/icucompat\n\n# Main library\nLOCAL_PATH := $(root_path)/android/jni\ninclude $(CLEAR_VARS)\nLOCAL_MODULE := wcdb\nLOCAL_CFLAGS := $(common_cflags)\nLOCAL_CPPFLAGS := $(common_cppflags)\nLOCAL_C_INCLUDES := $(common_c_includes)\nLOCAL_SRC_FILES := \\\n\t$(subst $(LOCAL_PATH)/,,$(wildcard $(LOCAL_PATH)/*.c)) \\\n\t$(subst $(LOCAL_PATH)/,,$(wildcard $(LOCAL_PATH)/*.cpp))\n\nLOCAL_LDLIBS := -llog -lz -ldl -latomic\nLOCAL_LDFLAGS := -Wl,--gc-sections -Wl,--version-script=$(root_path)/android/wcdb.map\n\nLOCAL_STATIC_LIBRARIES := \\\n\twcdb-repair \\\n\twcdb-backup \\\n\twcdb-vfslog \\\n\twcdb-fts \\\n\twcdb-icucompat \\\n\tsqlcipher \\\n\tcrypto-static\n\ninclude $(BUILD_SHARED_LIBRARY)\n\n# Repair\nLOCAL_PATH := $(root_path)/repair\ninclude $(CLEAR_VARS)\nLOCAL_MODULE := wcdb-repair\nLOCAL_CFLAGS := $(common_cflags)\nLOCAL_CPPFLAGS := $(common_cppflags)\nLOCAL_C_INCLUDES := $(common_c_includes)\nLOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)\nLOCAL_SRC_FILES := \\\n\t$(subst $(LOCAL_PATH)/,,$(wildcard $(LOCAL_PATH)/*.c)) \\\n\t$(subst $(LOCAL_PATH)/,,$(wildcard $(LOCAL_PATH)/*.cpp))\ninclude $(BUILD_STATIC_LIBRARY)\n\n# Backup\nLOCAL_PATH := $(root_path)/backup\ninclude $(CLEAR_VARS)\nLOCAL_MODULE := wcdb-backup\nLOCAL_CFLAGS := $(common_cflags)\nLOCAL_CPPFLAGS := $(common_cppflags)\nLOCAL_C_INCLUDES := $(common_c_includes)\nLOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)\nLOCAL_SRC_FILES := \\\n\t$(subst $(LOCAL_PATH)/,,$(wildcard $(LOCAL_PATH)/*.c)) \\\n\t$(subst $(LOCAL_PATH)/,,$(wildcard $(LOCAL_PATH)/*.cpp))\ninclude $(BUILD_STATIC_LIBRARY)\n\n# ICU compat\nLOCAL_PATH := $(root_path)/icucompat\ninclude $(CLEAR_VARS)\nLOCAL_MODULE := wcdb-icucompat\nLOCAL_CFLAGS := $(common_cflags)\nLOCAL_CPPFLAGS := $(common_cppflags)\nLOCAL_C_INCLUDES := $(common_c_includes)\nLOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)\nLOCAL_SRC_FILES := \\\n\t$(subst $(LOCAL_PATH)/,,$(wildcard $(LOCAL_PATH)/*.c)) \\\n\t$(subst $(LOCAL_PATH)/,,$(wildcard $(LOCAL_PATH)/*.cpp))\ninclude $(BUILD_STATIC_LIBRARY)\n\n# FTS\nLOCAL_PATH := $(root_path)/fts\ninclude $(CLEAR_VARS)\nLOCAL_MODULE := wcdb-fts\nLOCAL_CFLAGS := $(common_cflags)\nLOCAL_CPPFLAGS := $(common_cppflags)\nLOCAL_C_INCLUDES := $(common_c_includes)\nLOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)\nLOCAL_SRC_FILES := \\\n\t$(subst $(LOCAL_PATH)/,,$(wildcard $(LOCAL_PATH)/*.c)) \\\n\t$(subst $(LOCAL_PATH)/,,$(wildcard $(LOCAL_PATH)/*.cpp))\ninclude $(BUILD_STATIC_LIBRARY)\n\n# VFSLOG\nLOCAL_PATH := $(root_path)/vfslog\ninclude $(CLEAR_VARS)\nLOCAL_MODULE := wcdb-vfslog\nLOCAL_CFLAGS := $(common_cflags)\nLOCAL_CPPFLAGS := $(common_cppflags)\nLOCAL_C_INCLUDES := $(common_c_includes)\nLOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)\nLOCAL_SRC_FILES := \\\n\t$(subst $(LOCAL_PATH)/,,$(wildcard $(LOCAL_PATH)/*.c)) \\\n\t$(subst $(LOCAL_PATH)/,,$(wildcard $(LOCAL_PATH)/*.cpp))\ninclude $(BUILD_STATIC_LIBRARY)\n\n# SQLCipher\nLOCAL_PATH := $(root_path)/android/sqlcipher\ninclude $(CLEAR_VARS)\nLOCAL_MODULE := sqlcipher\nLOCAL_CFLAGS := $(common_cflags) -Wno-unused -Wno-missing-braces \\\n\t-DSQLITE_UNTESTABLE \\\n\t-DSQLITE_ENABLE_MEMORY_MANAGEMENT=1 \\\n\t-DHAVE_USLEEP=1 \\\n\t-DHAVE_FDATASYNC=1 \\\n\t-DSQLITE_HAVE_ISNAN \\\n\t-DSQLITE_DEFAULT_FILE_FORMAT=4 \\\n\t-DSQLITE_THREADSAFE=2 \\\n\t-DSQLITE_TEMP_STORE=2 \\\n\t-DSQLITE_ENABLE_FTS3 -DSQLITE_ENABLE_FTS4 \\\n\t-DSQLITE_ENABLE_FTS5 -DSQLITE_ENABLE_JSON1 \\\n\t-DSQLITE_ENABLE_RTREE -DSQLITE_ENABLE_UPDATE_DELETE_LIMIT \\\n\t-DSQLITE_ENABLE_SESSION -DSQLITE_ENABLE_PREUPDATE_HOOK \\\n\t-DSQLITE_DEFAULT_WORKER_THREADS=2 \\\n  \t-DSQLITE_DEFAULT_JOURNAL_SIZE_LIMIT=1048576 \\\n  \t-DUSE_PREAD64=1 \\\n\t-DSQLITE_ENABLE_FTS3_PARENTHESIS \\\n  \t-DSQLITE_ENABLE_FTS3_TOKENIZER \\\n  \t-DSQLITE_ENABLE_STAT4 \\\n  \t-DSQLITE_ENABLE_EXPLAIN_COMMENTS \\\n\t-DSQLITE_ENABLE_DBSTAT_VTAB \\\n\t-DOMIT_MEMLOCK \\\n\t-DOMIT_MEM_SECURITY \\\n\t-DSQLCIPHER_CRYPTO_OPENSSL \\\n\t-DSQLITE_MALLOC_SOFT_LIMIT=0 \\\n\t-DSQLITE_ENABLE_COLUMN_METADATA \\\n\t-DSQLITE_LIKE_DOESNT_MATCH_BLOBS \\\n\t-DSQLITE_MAX_ATTACHED=64 \\\n\t-DSQLITE_MAX_EXPR_DEPTH=0 \\\n\t-DSQLITE_OMIT_COMPILEOPTION_DIAGS \\\n\t-DSQLITE_OMIT_DEPRECATED \\\n\t-DSQLITE_PRINT_BUF_SIZE=256 \\\n\t-DSQLITE_WCDB=1 \\\n\t-DSQLITE_WCDB_CHECKPOINT_HANDLER=1 \\\n\t-DSQLITE_WCDB_IMPROVED_CHECKPOINT=1 \\\n\t-DSQLITE_WCDB_LOCK_HOOK=1 \\\n\t-DSQLITE_WCDB_SUSPEND=1\n\nLOCAL_C_INCLUDES := $(common_c_includes)\nLOCAL_SRC_FILES := sqlite3.c\ninclude $(BUILD_STATIC_LIBRARY)\n\n# Prebuilt libcrypto\nLOCAL_PATH := $(prebuilt_path)\ninclude $(CLEAR_VARS)\nLOCAL_MODULE := crypto-static\nLOCAL_SRC_FILES := lib/libcrypto.a\ninclude $(PREBUILT_STATIC_LIBRARY)\n"
  },
  {
    "path": "deprecated/android/Application.mk",
    "content": "LOCAL_PATH:= $(call my-dir)\n\nNDK_PROJECT_PATH := $(LOCAL_PATH)/build\nAPP_BUILD_SCRIPT := $(LOCAL_PATH)/Android.mk\nAPP_ABI := armeabi armeabi-v7a arm64-v8a x86 x86_64\nAPP_PLATFORM := android-14\nAPP_STL := c++_static\nAPP_PIE := true\nAPP_DEPRECATED_HEADERS := true\n\nifdef USE_GCC\n\tNDK_TOOLCHAIN_VERSION := 4.9\nendif\n"
  },
  {
    "path": "deprecated/android/addons/backup/mm_backup.c",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#define MM_BACKUP_INCLUDE_INTERNAL\n#include \"mm_backup.h\"\n#include <errno.h>\n#include <pthread.h>\n#include <stddef.h>\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include <sys/stat.h>\n\n#include <openssl/rc4.h>\n#include <zlib.h>\n\n#define INPUT_BUFFER_SIZE 8192\n#define OUTPUT_BUFFER_SIZE 8192\nstruct mm_backup_ctx {\n    sqlite3 *db; // database connection, not initialized until actual running.\n    z_stream zstrm;  // output compression stream.\n    RC4_KEY rc4_key; // output file encryption key.\n    FILE *fp;        // output file handle.\n    uint32_t flags;  // configuration flags.\n    mm_logfunc log;  // log function.\n    uint32_t stmt_count;\n    uint32_t sec_size;\n    uint32_t sec_pos;\n\n    mm_backup_tabdesc *tabdesc;\n    int num_tabdesc;\n\n    volatile char canceled; // task status.\n\n    char writable_schema; // whether PRAGMA writable_schema has been set.\n    char corrupted;       // whether database is corrupted.\n\n    pthread_t write_thread;\n    pthread_mutex_t buf_lock;\n    pthread_cond_t buf_cond;\n    char in_finish;\n    char in_avail;\n    char in_full;\n    char write_error;\n\n    struct mm_backup_buffer {\n        uint_t avail;\n        uint8_t data[INPUT_BUFFER_SIZE];\n    } * p_buf, buffer[2];\n\n    char errmsg[2048];\n};\n\nstatic void *write_thread_entry(void *ud)\n{\n    mm_backup_ctx *ctx = (mm_backup_ctx *) ud;\n\n    for (;;) {\n        int finish;\n\n        pthread_mutex_lock(&ctx->buf_lock);\n        {\n            while (!ctx->in_avail && !ctx->in_finish && !ctx->canceled)\n                pthread_cond_wait(&ctx->buf_cond, &ctx->buf_lock);\n\n            ctx->zstrm.next_in = ctx->p_buf->data;\n            ctx->zstrm.avail_in = ctx->p_buf->avail;\n            finish = ctx->in_finish;\n\n            ctx->p_buf = (ctx->p_buf == &ctx->buffer[0]) ? &ctx->buffer[1]\n                                                         : &ctx->buffer[0];\n            ctx->p_buf->avail = 0;\n\n            ctx->in_avail = 0;\n            ctx->in_full = 0;\n        }\n        pthread_mutex_unlock(&ctx->buf_lock);\n        pthread_cond_signal(&ctx->buf_cond);\n\n        int ret;\n        uint8_t out_buf[OUTPUT_BUFFER_SIZE];\n\n        if (ctx->canceled)\n            return NULL;\n        do {\n            ctx->zstrm.next_out = out_buf;\n            ctx->zstrm.avail_out = sizeof(out_buf);\n            ret = deflate(&ctx->zstrm, finish ? Z_FINISH : Z_NO_FLUSH);\n            if (ret == Z_BUF_ERROR)\n                break;\n            if (ret != Z_OK && ret != Z_STREAM_END)\n                goto bail;\n\n            uint_t out_len = sizeof(out_buf) - ctx->zstrm.avail_out;\n            if ((ctx->flags & MMBAK_FLAG_NO_CIPHER) == 0)\n                RC4(&ctx->rc4_key, out_len, out_buf, out_buf);\n\n            const uint8_t *p = out_buf;\n            while (out_len > 0) {\n                size_t ret = fwrite(p, 1, out_len, ctx->fp);\n                if (ret == 0 && ferror(ctx->fp))\n                    goto bail;\n                out_len -= ret;\n                p += ret;\n                ctx->sec_size += ret;\n            }\n        } while (ctx->zstrm.avail_out == 0 && ret != Z_STREAM_END);\n        if (ctx->zstrm.avail_in != 0)\n            goto bail;\n\n        if (ret == Z_STREAM_END)\n            break;\n    }\n    return NULL;\n\nbail:\n    pthread_mutex_lock(&ctx->buf_lock);\n    ctx->write_error = 1;\n    pthread_cond_signal(&ctx->buf_cond);\n    pthread_mutex_unlock(&ctx->buf_lock);\n    return NULL;\n}\n\nstatic int dump_write_stream(mm_backup_ctx *ctx, const void *data, uint_t size)\n{\n    struct mm_backup_buffer *p_buf;\n    const uint8_t *p_data = (const uint8_t *) data;\n\n    pthread_mutex_lock(&ctx->buf_lock);\n    while (size > 0) {\n        while (ctx->in_full && !ctx->canceled && !ctx->write_error)\n            pthread_cond_wait(&ctx->buf_cond, &ctx->buf_lock);\n\n        if (ctx->write_error) {\n            pthread_mutex_unlock(&ctx->buf_lock);\n            LOGE_(\"Writing thread reported error.\");\n            return -1;\n        }\n\n        p_buf = ctx->p_buf;\n\n        uint_t size_to_write = (p_buf->avail + size > INPUT_BUFFER_SIZE)\n                                   ? INPUT_BUFFER_SIZE - p_buf->avail\n                                   : size;\n        memcpy(p_buf->data + p_buf->avail, p_data, size_to_write);\n        size -= size_to_write;\n        p_buf->avail += size_to_write;\n        p_data += size_to_write;\n\n        ctx->in_avail = p_buf->avail > INPUT_BUFFER_SIZE / 4;\n        ctx->in_full = p_buf->avail == INPUT_BUFFER_SIZE;\n        if (ctx->in_avail || ctx->in_full)\n            pthread_cond_signal(&ctx->buf_cond);\n    }\n    pthread_mutex_unlock(&ctx->buf_lock);\n    return 0;\n}\n\nstatic int dump_write_end(mm_backup_ctx *ctx)\n{\n    int ret;\n\n    // flush padding input.\n    pthread_mutex_lock(&ctx->buf_lock);\n    {\n        ctx->in_finish = 1;\n        if (ctx->write_error) {\n            LOGE_(\"Writing thread reported error.\");\n            ret = -1;\n        } else\n            ret = 0;\n    }\n    pthread_mutex_unlock(&ctx->buf_lock);\n    pthread_cond_signal(&ctx->buf_cond);\n\n    return ret;\n}\n\n#define dump_write_byte(ctx, v)                                                \\\n    ({                                                                         \\\n        int _ret;                                                              \\\n        uint8_t b1 = (uint8_t)(v);                                             \\\n        _ret = dump_write_stream((ctx), &b1, 1);                               \\\n        _ret;                                                                  \\\n    })\n\n// assume little-endian\n#define dump_write_short(ctx, v)                                               \\\n    ({                                                                         \\\n        int _ret;                                                              \\\n        uint16_t s1 = (uint16_t)(v);                                           \\\n        _ret = dump_write_stream((ctx), &s1, 2);                               \\\n        _ret;                                                                  \\\n    })\n\n#define dump_write_byte_byte(ctx, b1, b2)                                      \\\n    ({                                                                         \\\n        int _ret;                                                              \\\n        uint8_t buf[2];                                                        \\\n        buf[0] = (uint8_t)(b1);                                                \\\n        buf[1] = (uint8_t)(b2);                                                \\\n        _ret = dump_write_stream((ctx), buf, 2);                               \\\n        _ret;                                                                  \\\n    })\n\n// assume little-endian\n#define dump_write_byte_short(ctx, b, s)                                       \\\n    ({                                                                         \\\n        int _ret;                                                              \\\n        uint8_t buf[3];                                                        \\\n        uint16_t s1 = (uint16_t)(s);                                           \\\n        buf[0] = (uint8_t)(b);                                                 \\\n        buf[1] = (uint8_t)(s1 & 0xFF);                                         \\\n        buf[2] = (uint8_t)((s1 >> 8) & 0xFF);                                  \\\n        _ret = dump_write_stream((ctx), buf, 3);                               \\\n        _ret;                                                                  \\\n    })\n\nstatic int dump_write_varint(mm_backup_ctx *ctx, int64_t val)\n{\n    uint8_t buf[12];\n    uint8_t *p = buf;\n\n    if (val < 0) {\n        *p++ = MMBAK_TAG_BIND_VARINT_MINUS;\n        val = ~val;\n    } else\n        *p++ = MMBAK_TAG_BIND_VARINT;\n\n    do {\n        uint8_t b = val & 0x7F;\n        val >>= 7;\n        if (val)\n            b |= 0x80;\n        *p++ = b;\n    } while (val);\n\n    return dump_write_stream(ctx, buf, p - buf);\n}\n\n#define string_literal(str) (str), (sizeof(str) - 1)\n\nstatic int\ndump_write_blob(mm_backup_ctx *ctx, uint8_t tag, const void *data, int size)\n{\n    const char *p = (const char *) data;\n    int ret;\n\n    if (size < 0)\n        size = strlen(p);\n\n    if (size >= 65536) {\n        uint32_t ext_size = size & 0xFFFF0000;\n        uint16_t blocks = ext_size >> 16;\n        ret = dump_write_byte(ctx, MMBAK_TAG_LARGE_DATA);\n        ret |= dump_write_short(ctx, blocks);\n        ret |= dump_write_stream(ctx, p, ext_size);\n        if (ret != 0)\n            return -1;\n        size -= ext_size;\n        p += ext_size;\n    }\n\n    if (size < 256 &&\n        (tag == MMBAK_TAG_BIND_TEXT || tag == MMBAK_TAG_BIND_BLOB))\n        ret = dump_write_byte_byte(ctx, ++tag, (uint8_t) size);\n    else\n        ret = dump_write_byte_short(ctx, tag, (uint16_t) size);\n    ret |= dump_write_stream(ctx, p, size);\n    if (ret != 0)\n        return -1;\n\n    return 0;\n}\n\nstatic int dump_rows(mm_backup_ctx *ctx,\n                     const char *table,\n                     const char *condition,\n                     int reverse)\n{\n    // find out number of columns, which is used in INSERT statements.\n    int i, ret;\n    int num_columns = 0;\n    char sql_buf[8192];\n    sqlite3_stmt *stmt = NULL;\n    int row_count = 0;\n\n    sql_buf[0] = '\\0';\n\n    int sql_len =\n        snprintf(sql_buf, sizeof(sql_buf), \"PRAGMA table_info(\\\"%s\\\")\", table);\n    ret = sqlite3_prepare_v2(ctx->db, sql_buf, sql_len, &stmt, NULL);\n    if (ret != SQLITE_OK)\n        goto bail_log_sql;\n\n    ret = sqlite3_step(stmt);\n    while (ret == SQLITE_ROW) {\n        num_columns++;\n        ret = sqlite3_step(stmt);\n    }\n    ret = sqlite3_finalize(stmt);\n    stmt = NULL;\n    if (ret != SQLITE_OK)\n        goto bail_log_sql;\n\n    if (num_columns == 0)\n        return SQLITE_OK;\n\n    // dump rows in table.\n    if (condition)\n        sql_len = snprintf(sql_buf, sizeof(sql_buf),\n                           \"SELECT * FROM \\\"%s\\\" WHERE %s;\", table, condition);\n    else\n        sql_len = snprintf(sql_buf, sizeof(sql_buf), \"SELECT * FROM \\\"%s\\\"%s;\",\n                           table, reverse ? \" ORDER BY rowid DESC\" : \"\");\n\n    ret = sqlite3_prepare_v2(ctx->db, sql_buf, sql_len, &stmt, NULL);\n    if (ret != SQLITE_OK)\n        goto bail_log_sql;\n\n    row_count = 0;\n    ret = sqlite3_step(stmt);\n    if (ret == SQLITE_ROW) {\n        // output INSERT statement with parameters.\n        sql_len = snprintf(sql_buf, sizeof(sql_buf),\n                           \"REPLACE INTO \\\"%s\\\" VALUES(\", table);\n        for (i = 0; i < num_columns; i++)\n            sql_len +=\n                strlcpy(sql_buf + sql_len, \"?,\", sizeof(sql_buf) - sql_len);\n        sql_len--;\n        sql_len += strlcpy(sql_buf + sql_len, \");\", sizeof(sql_buf) - sql_len);\n        if (dump_write_blob(ctx, MMBAK_TAG_SQL_REPEATED, sql_buf, sql_len)) {\n            ret = SQLITE_ERROR;\n            goto bail;\n        }\n    }\n    while (ret == SQLITE_ROW) {\n        // check cancel flag.\n        if (ctx->canceled) {\n            ret = SQLITE_ABORT;\n            goto bail;\n        }\n\n        for (i = 0; i < num_columns; i++) {\n            int type = sqlite3_column_type(stmt, i);\n            switch (type) {\n                case SQLITE_INTEGER: {\n                    int64_t value = sqlite3_column_int64(stmt, i);\n                    ret = dump_write_varint(ctx, value);\n                } break;\n\n                case SQLITE_FLOAT: {\n                    double value = sqlite3_column_double(stmt, i);\n                    ret = dump_write_byte(ctx, MMBAK_TAG_BIND_FLOAT);\n                    ret |= dump_write_stream(ctx, &value, 8);\n                } break;\n\n                case SQLITE_TEXT: {\n                    const char *value =\n                        (const char *) sqlite3_column_text(stmt, i);\n                    int len = sqlite3_column_bytes(stmt, i);\n                    ret = dump_write_blob(ctx, MMBAK_TAG_BIND_TEXT, value, len);\n                } break;\n\n                case SQLITE_BLOB: {\n                    const void *value = sqlite3_column_blob(stmt, i);\n                    int len = sqlite3_column_bytes(stmt, i);\n                    ret = dump_write_blob(ctx, MMBAK_TAG_BIND_BLOB, value, len);\n                } break;\n\n                case SQLITE_NULL:\n                    ret = dump_write_byte(ctx, MMBAK_TAG_BIND_NULL);\n                    break;\n\n                default:\n                    LOGE(\"Unreconized SQLite type: %d\", type);\n                    ret = SQLITE_INTERNAL;\n                    goto bail;\n            }\n\n            if (ret != 0) {\n                ret = SQLITE_ERROR;\n                goto bail;\n            }\n\n            row_count++;\n        }\n\n        if (dump_write_byte(ctx, MMBAK_TAG_END_ROW)) {\n            ret = SQLITE_ERROR;\n            goto bail;\n        }\n        ctx->stmt_count++;\n\n        ret = sqlite3_step(stmt);\n    }\n    if (row_count > 0)\n        if (dump_write_byte(ctx, MMBAK_TAG_END_SQL)) {\n            ret = SQLITE_ERROR;\n            goto bail;\n        }\n\n    ret = sqlite3_finalize(stmt);\n    stmt = NULL;\n    if (ret != SQLITE_OK) {\n        if (ret == SQLITE_CORRUPT)\n            goto bail_log_corrupt;\n        goto bail_log_sql;\n    }\n    return ret;\n\nbail_log_corrupt:\n    LOGE(\"Database corruption detected. [table: %s, condition: %s, row: %d, \"\n         \"reverse: %s]\",\n         table, condition ? condition : \"null\", row_count,\n         reverse ? \"yes\" : \"no\");\n    goto bail;\nbail_log_sql:\n    LOGE(\"SQL execution failed: %s, [SQL: %s]\", sqlite3_errmsg(ctx->db),\n         stmt ? sqlite3_sql(stmt) : sql_buf);\nbail:\n    if (stmt)\n        sqlite3_finalize(stmt);\n    return ret;\n}\n\nstatic int compar_table_tabdesc(const void *key, const void *value)\n{\n    return strcmp((const char *) key,\n                  ((const mm_backup_tabdesc *) value)->table);\n}\n\nstatic int\ndump_callback(void *ud, int num_columns, char **values, char **columns)\n{\n    mm_backup_ctx *ctx = (mm_backup_ctx *) ud;\n    const char *table = values[0];\n    const char *type = values[1];\n    const char *sql = values[2];\n    int ret;\n\n    // check exit status.\n    if (ctx->canceled)\n        return -1;\n\n    // deal with system tables.\n    if (!strcmp(table, \"sqlite_sequence\")) {\n        if (dump_write_blob(ctx, MMBAK_TAG_SQL_ONESHOT,\n                            string_literal(\"DELETE FROM sqlite_sequence;\")) !=\n            0)\n            return -1;\n    } else if (!sqlite3_strglob(\"sqlite_stat?\", table)) {\n        if (dump_write_blob(ctx, MMBAK_TAG_SQL_ONESHOT,\n                            string_literal(\"ANALYZE sqlite_master;\")))\n            return -1;\n    } else if (!strncmp(table, \"sqlite_\", 7)) {\n        return 0;\n    }\n\n    // find whether in dump list.\n    const char *table_condition = NULL;\n    if (ctx->tabdesc) {\n        const mm_backup_tabdesc *desc = (const mm_backup_tabdesc *) bsearch(\n            table, ctx->tabdesc, ctx->num_tabdesc, sizeof(mm_backup_tabdesc),\n            compar_table_tabdesc);\n        if (!desc)\n            return 0;\n\n        table_condition = desc->condition;\n    }\n\n    if (!strncmp(sql, \"CREATE VIRTUAL TABLE\", 20)) {\n        if (!(ctx->flags & MMBAK_FLAG_NO_CREATE_TABLE)) {\n            if (!ctx->writable_schema) {\n                if (dump_write_blob(\n                        ctx, MMBAK_TAG_SQL_ONESHOT,\n                        string_literal(\"PRAGMA writable_schema=ON;\")))\n                    return -1;\n                ctx->writable_schema = 1;\n            }\n\n            char *vt_sql = sqlite3_mprintf(\n                \"INSERT INTO sqlite_master(type,name,tbl_name,rootpage,sql)\"\n                \"VALUES('table','%q','%q',0,'%q');\",\n                table, table, sql);\n            if (dump_write_blob(ctx, MMBAK_TAG_SQL_ONESHOT, vt_sql, -1))\n                return -1;\n            sqlite3_free(vt_sql);\n        }\n\n        return 0;\n    } else if (!(ctx->flags & MMBAK_FLAG_NO_CREATE_TABLE)) {\n        if (dump_write_blob(ctx, MMBAK_TAG_SQL_ONESHOT, sql, -1))\n            return -1;\n    }\n\n    // for tables, dump all rows.\n    if (!strcmp(type, \"table\")) {\n        ret = dump_rows(ctx, table, table_condition, 0);\n        if (ret == SQLITE_CORRUPT && !table_condition &&\n            (ctx->flags & MMBAK_FLAG_FIX_CORRUPTION)) {\n            ret = dump_rows(ctx, table, table_condition, 1);\n            if (ret == SQLITE_CORRUPT)\n                ret = SQLITE_OK;\n        }\n        if (ret != SQLITE_OK)\n            return -1;\n    }\n    return 0;\n}\n\nstatic int run_schema_dump_query(mm_backup_ctx *ctx, const char *query_sql)\n{\n    // check cancel status.\n    if (ctx->canceled)\n        return MMBAK_RET_CANCELED;\n\n    // dump all tables.\n    char *errmsg = NULL;\n    int ret = sqlite3_exec(ctx->db, query_sql, dump_callback, ctx, &errmsg);\n    if (ret == SQLITE_ABORT) {\n        // abort due to user cancellation or error.\n        if (errmsg)\n            sqlite3_free(errmsg);\n        return (ctx->canceled) ? MMBAK_RET_CANCELED : MMBAK_RET_FAILED;\n    }\n\n    if (ret == SQLITE_CORRUPT && (ctx->flags & MMBAK_FLAG_FIX_CORRUPTION)) {\n        // in case of database corruption, dump tables in reverse order.\n        if (errmsg) {\n            LOGE(\"SQL execution failed: %s [SQL: %s]\", errmsg, query_sql);\n            sqlite3_free(errmsg);\n            errmsg = NULL;\n        }\n\n        size_t len = strlen(query_sql);\n        char *query_sql_reverse = (char *) malloc(len + 32);\n        if (!query_sql_reverse)\n            return ret;\n        sqlite3_snprintf(len + 32, query_sql_reverse, \"%s ORDER BY rowid DESC\",\n                         query_sql);\n\n        ret = sqlite3_exec(ctx->db, query_sql_reverse, dump_callback, ctx,\n                           &errmsg);\n        free(query_sql_reverse);\n    }\n\n    if (errmsg) {\n        LOGE(\"SQL execution failed: %s [SQL: %s]\", errmsg, query_sql);\n        sqlite3_free(errmsg);\n    }\n    return (ret == SQLITE_OK) ? MMBAK_RET_OK : MMBAK_RET_FAILED;\n}\n\nmm_backup_ctx *mm_backup_init(const unsigned char *key,\n                              int key_len,\n                              const char *out_path,\n                              unsigned int flags,\n                              mm_logfunc logfunc)\n{\n    if (!logfunc)\n        logfunc = dummy_log;\n\n    mm_backup_ctx *ctx = (mm_backup_ctx *) malloc(sizeof(mm_backup_ctx));\n    if (!ctx) {\n        logfunc(MMBAK_LOG_ERROR, \"Memory allocation failed.\");\n        return NULL;\n    }\n    memset(ctx, 0, sizeof(mm_backup_ctx));\n    ctx->log = logfunc;\n\n    int compress_level =\n        (flags & MMBAK_FLAG_NO_COMPRESS) ? 0 : Z_DEFAULT_COMPRESSION;\n    if (Z_OK != deflateInit(&ctx->zstrm, compress_level))\n        LOG_AND_FAIL(\"Failed to initialize deflate: %s\",\n                     ctx->zstrm.msg ? ctx->zstrm.msg : \"Unknown\");\n\n    if (key && key_len > 0)\n        RC4_set_key(&ctx->rc4_key, key_len, key);\n    else\n        flags |= MMBAK_FLAG_NO_CIPHER;\n\n    if (flags & MMBAK_FLAG_INCREMENTAL) {\n        ctx->fp = fopen(out_path, \"rb+\");\n        if (!ctx->fp)\n            LOG_AND_FAIL(\"Cannot open file '%s' for appending: %s\", out_path,\n                         strerror(errno));\n\n        // check header and version.\n        mm_backup_header header;\n        int ret = fread(&header, sizeof(mm_backup_header), 1, ctx->fp);\n        if (ret < 1)\n            LOG_AND_FAIL(\"Invalid header in base file '%s'.\", out_path);\n\n        if (memcmp(header.magic, MMBAK_MAGIC, sizeof(MMBAK_MAGIC) - 1) != 0 ||\n            header.version != MMBAK_VERSION)\n            LOG_AND_FAIL(\"Invalid header in base file '%s'.\", out_path);\n\n        // seek to end.\n        ret = fseek(ctx->fp, 0, SEEK_END);\n        if (ret != 0)\n            LOG_AND_FAIL(\"Cannot seek in file '%s': %s\", out_path,\n                         strerror(errno));\n    } else {\n        ctx->fp = fopen(out_path, \"wb\");\n        if (!ctx->fp)\n            LOG_AND_FAIL(\"Cannot open file '%s' for writing: %s\", out_path,\n                         strerror(errno));\n\n        // write file header.\n        mm_backup_header header;\n        memcpy(header.magic, MMBAK_MAGIC, sizeof(MMBAK_MAGIC) - 1);\n        header.version = MMBAK_VERSION;\n        int ret = fwrite(&header, sizeof(header), 1, ctx->fp);\n        if (ret < 1)\n            LOG_AND_FAIL(\"Cannot write to file '%s': %s\", out_path,\n                         strerror(errno));\n    }\n    ctx->sec_pos = (uint32_t) ftell(ctx->fp);\n\n    pthread_mutex_init(&ctx->buf_lock, NULL);\n    pthread_cond_init(&ctx->buf_cond, NULL);\n    ctx->flags = flags;\n    ctx->canceled = 1;\n    ctx->in_finish = 0;\n    ctx->in_avail = 0;\n    ctx->in_full = 0;\n    ctx->write_error = 0;\n    ctx->buffer[0].avail = 0;\n    ctx->buffer[1].avail = 0;\n    ctx->p_buf = &ctx->buffer[0];\n\n    LOGI(\"Database backup context initialized. [output: %s, flags: 0x%04x]\",\n         out_path, flags);\n    return ctx;\n\nbail:\n    if (ctx) {\n        deflateEnd(&ctx->zstrm);\n        if (ctx->fp)\n            fclose(ctx->fp);\n        free(ctx);\n    }\n    return NULL;\n}\n\nstatic int compar_tabdesc(const void *a, const void *b)\n{\n    return strcmp(((const mm_backup_tabdesc *) a)->table,\n                  ((const mm_backup_tabdesc *) b)->table);\n}\n\nint mm_backup_run(mm_backup_ctx *ctx,\n                  sqlite3 *db,\n                  const mm_backup_tabdesc *desc,\n                  int num_desc)\n{\n    char *errmsg = NULL;\n    int ret = MMBAK_RET_FAILED;\n\n    const char *dbfile = sqlite3_db_filename(db, \"main\");\n    LOGI(\"Database backup started. [db: %s]\",\n         dbfile ? dbfile : \"(temp or memory)\");\n\n    // Make a sorted copy of tabdesc.\n    if (desc && num_desc > 0) {\n        ctx->tabdesc =\n            (mm_backup_tabdesc *) malloc(sizeof(mm_backup_tabdesc) * num_desc);\n        if (!ctx->tabdesc)\n            LOG_AND_FAIL(\"Not enough memory.\");\n        memcpy(ctx->tabdesc, desc, sizeof(mm_backup_tabdesc) * num_desc);\n        qsort(ctx->tabdesc, num_desc, sizeof(mm_backup_tabdesc),\n              compar_tabdesc);\n\n        ctx->num_tabdesc = num_desc;\n\n        // adjust/print tabdesc.\n        LOGI(\"Backup with table descriptors. [count: %d]\", ctx->num_tabdesc);\n        int i;\n        for (i = 0; i < num_desc; i++) {\n            if (ctx->tabdesc[i].condition && ctx->tabdesc[i].condition[0] == 0)\n                ctx->tabdesc[i].condition = NULL;\n            LOGI(\"  > table: %s, condition: %s\", ctx->tabdesc[i].table,\n                 ctx->tabdesc[i].condition ? ctx->tabdesc[i].condition\n                                           : \"null\");\n        }\n    } else {\n        ctx->tabdesc = NULL;\n        ctx->num_tabdesc = 0;\n    }\n\n    ctx->db = db;\n    ctx->canceled = 0;\n    ctx->stmt_count = 0;\n    ctx->sec_size = 0;\n\n    // initialize write thread.\n    if (pthread_create(&ctx->write_thread, NULL, write_thread_entry, ctx) != 0)\n        LOG_AND_FAIL(\"Cannot initialize writer thread.\");\n\n    if (sqlite3_exec(db, \"SAVEPOINT dump; PRAGMA writable_schema=ON;\", 0, 0,\n                     &errmsg) != SQLITE_OK)\n        LOG_AND_FAIL(\"Cannot execute startup SQL: %s\",\n                     errmsg ? errmsg : \"Unknown\");\n\n    // write section placeholder.\n    mm_backup_section section = {.flags = ctx->flags, .sec_size = 0};\n    if (fwrite(&section, sizeof(mm_backup_section), 1, ctx->fp) < 1)\n        LOG_AND_FAIL(\"Cannot write to file: %s\", strerror(errno));\n\n    // dump tables.\n    if ((ret = run_schema_dump_query(\n             ctx, \"SELECT name, type, sql FROM sqlite_master WHERE sql NOT NULL\"\n                  \" AND type=='table' AND name!='sqlite_sequence'\")) !=\n        MMBAK_RET_OK)\n        goto bail;\n    if ((ret = run_schema_dump_query(\n             ctx, \"SELECT name, type, sql FROM sqlite_master WHERE \"\n                  \"name=='sqlite_sequence'\")) != MMBAK_RET_OK)\n        goto bail;\n    if ((ret = run_schema_dump_query(\n             ctx, \"SELECT name, type, sql FROM sqlite_master WHERE sql NOT NULL\"\n                  \" AND type IN ('index','trigger','view')\")) != MMBAK_RET_OK)\n        goto bail;\n\n    // recover writable_schema.\n    if (ctx->writable_schema)\n        if (dump_write_blob(ctx, MMBAK_TAG_SQL_ONESHOT,\n                            string_literal(\"PRAGMA writable_schema=OFF;\")) != 0)\n            goto bail;\n\n    if (dump_write_end(ctx) != 0)\n        goto bail;\n\n    sqlite3_exec(db, \"PRAGMA writable_schema=OFF; RELEASE dump;\", 0, 0, 0);\n    pthread_join(ctx->write_thread, NULL);\n\n    // write section header.\n    section.sec_size = ctx->sec_size;\n    ret = fseek(ctx->fp, ctx->sec_pos, SEEK_SET);\n    if (ret != 0)\n        LOG_AND_FAIL(\"Cannot seek in file: %s\", strerror(errno));\n    ret = fwrite(&section, sizeof(mm_backup_section), 1, ctx->fp);\n    if (ret < 1)\n        LOG_AND_FAIL(\"Cannot write to file: %s\", strerror(errno));\n    fflush(ctx->fp);\n\n    ctx->canceled = 1;\n\n    LOGI(\"Database backup finished. [items: %u, section size: %u]\",\n         ctx->stmt_count, ctx->sec_size);\n    return 0;\n\nbail:\n    if (!ctx->canceled) {\n        ctx->canceled = 1;\n        pthread_cond_broadcast(&ctx->buf_cond);\n    }\n    pthread_detach(ctx->write_thread);\n    sqlite3_exec(db, \"PRAGMA writable_schema=OFF; RELEASE dump;\", 0, 0, 0);\n    if (errmsg)\n        sqlite3_free(errmsg);\n    return ret;\n}\n\nvoid mm_backup_cancel(mm_backup_ctx *ctx)\n{\n    ctx->canceled = 1;\n    pthread_cond_broadcast(&ctx->buf_cond);\n    LOGI_(\"Backup operation canceled.\");\n}\n\nvoid mm_backup_finish(mm_backup_ctx *ctx)\n{\n    if (!ctx->canceled) {\n        ctx->canceled = 1;\n        pthread_cond_broadcast(&ctx->buf_cond);\n        pthread_detach(ctx->write_thread);\n    }\n\n    free(ctx->tabdesc);\n    pthread_mutex_destroy(&ctx->buf_lock);\n    pthread_cond_destroy(&ctx->buf_cond);\n\n    if (ctx->fp)\n        fclose(ctx->fp);\n    deflateEnd(&ctx->zstrm);\n    free(ctx);\n}\n\nvoid mm_backup_statistics(mm_backup_ctx *ctx, unsigned int *stmt_count)\n{\n    if (stmt_count)\n        *stmt_count = ctx->stmt_count;\n}\n\nconst char *mm_backup_last_error(mm_backup_ctx *ctx)\n{\n    return ctx->errmsg;\n}\n"
  },
  {
    "path": "deprecated/android/addons/backup/mm_backup.h",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#ifndef __MM_BACKUP_H__\n#define __MM_BACKUP_H__\n\n#include <sqlite3.h>\n#include <stdint.h>\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n#define MMBAK_RET_FAILED (-1)\n#define MMBAK_RET_OK 0\n#define MMBAK_RET_CANCELED 1\n\n#define MMBAK_FLAG_NO_CIPHER 0x0001\n#define MMBAK_FLAG_NO_COMPRESS 0x0002\n#define MMBAK_FLAG_FIX_CORRUPTION 0x0004\n#define MMBAK_FLAG_NO_CREATE_TABLE 0x0008\n#define MMBAK_FLAG_INCREMENTAL 0x0010\n\n#define MMBAK_LOG_DEBUG 0\n#define MMBAK_LOG_INFO 1\n#define MMBAK_LOG_ERROR 2\n\ntypedef struct mm_backup_ctx mm_backup_ctx;\ntypedef struct mm_recover_ctx mm_recover_ctx;\n\ntypedef void (*mm_logfunc)(int prio, const char *msg);\n\ntypedef struct mm_backup_tabdesc {\n    const char *table;\n    const char *condition;\n} mm_backup_tabdesc;\n\nmm_backup_ctx *mm_backup_init(const unsigned char *key,\n                              int key_len,\n                              const char *out_path,\n                              unsigned int flags,\n                              mm_logfunc logfunc);\nint mm_backup_run(mm_backup_ctx *ctx,\n                  sqlite3 *db,\n                  const mm_backup_tabdesc *desc,\n                  int num_desc);\nvoid mm_backup_statistics(mm_backup_ctx *ctx, unsigned int *stmt_count);\nvoid mm_backup_cancel(mm_backup_ctx *ctx);\nvoid mm_backup_finish(mm_backup_ctx *ctx);\nconst char *mm_backup_last_error(mm_backup_ctx *ctx);\n\nmm_recover_ctx *mm_recover_init(const char *in_path,\n                                const unsigned char *key,\n                                int key_len,\n                                mm_logfunc logfunc);\nint mm_recover_run(mm_recover_ctx *ctx, sqlite3 *db, int fatal);\nvoid mm_recover_statistics(mm_recover_ctx *ctx,\n                           unsigned int *succeeded,\n                           unsigned int *failed);\nvoid mm_recover_cancel(mm_recover_ctx *ctx);\nvoid mm_recover_finish(mm_recover_ctx *ctx);\nconst char *mm_recover_last_error(mm_recover_ctx *ctx);\n\n#if defined(MM_BACKUP_INCLUDE_INTERNAL)\n\n#define MMBAK_TAG_LARGE_DATA 0x80\n#define MMBAK_TAG_SQL_ONESHOT 0x81\n#define MMBAK_TAG_SQL_REPEATED 0x82\n#define MMBAK_TAG_END_ROW 0x83\n#define MMBAK_TAG_END_SQL 0x84\n\n#define MMBAK_TAG_BIND_NULL 0x00\n#define MMBAK_TAG_BIND_VARINT 0x01\n#define MMBAK_TAG_BIND_VARINT_MINUS 0x02\n#define MMBAK_TAG_BIND_FLOAT 0x03\n#define MMBAK_TAG_BIND_TEXT 0x04\n#define MMBAK_TAG_BIND_TEXT_SHORT 0x05\n#define MMBAK_TAG_BIND_BLOB 0x06\n#define MMBAK_TAG_BIND_BLOB_SHORT 0x07\n\n#define MMBAK_MAGIC \"\\0dBbAk\"\n#define MMBAK_VERSION 0x0002\n\ntypedef struct mm_backup_header {\n    char magic[6];    // file format magic, always MMBAK_MAGIC\n    uint16_t version; // file format version, current version is MMBAK_VERSION\n} mm_backup_header;\n\ntypedef struct mm_backup_section {\n    uint32_t flags;    // flags used in mm_backup_init, see MMBAK_FLAG_*\n    uint32_t sec_size; // section sizes\n} mm_backup_section;\n\nvoid mm_print_log(mm_logfunc logfunc, int prio, const char *fmt, ...)\n#if defined(__GNUC__)\n    __attribute__((format(printf, 3, 4)))\n#endif\n    ;\nvoid mm_print_err(mm_logfunc logfunc, char *errmsg, const char *fmt, ...)\n#if defined(__GNUC__)\n    __attribute__((format(printf, 3, 4)))\n#endif\n    ;\nvoid dummy_log(int prio, const char *msg);\n\n#define LOGD(fmt, ...)                                                         \\\n    mm_print_log(ctx->log, MMBAK_LOG_DEBUG, (fmt), __VA_ARGS__)\n#define LOGI(fmt, ...)                                                         \\\n    mm_print_log(ctx->log, MMBAK_LOG_INFO, (fmt), __VA_ARGS__)\n#define LOGE(fmt, ...)                                                         \\\n    mm_print_log(ctx->log, MMBAK_LOG_ERROR, (fmt), __VA_ARGS__)\n#define LOGD_(msg) ctx->log(MMBAK_LOG_DEBUG, (msg));\n#define LOGI_(msg) ctx->log(MMBAK_LOG_INFO, (msg));\n#define LOGE_(msg) ctx->log(MMBAK_LOG_ERROR, (msg));\n\n#define LOG_AND_FAIL(fmt, args...)                                             \\\n    do {                                                                       \\\n        mm_print_err(ctx->log, ctx->errmsg, (fmt), ##args);                    \\\n        goto bail;                                                             \\\n    } while (0)\n\n#endif\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif\n"
  },
  {
    "path": "deprecated/android/addons/backup/mm_recover.c",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#define MM_BACKUP_INCLUDE_INTERNAL\n#include \"mm_backup.h\"\n#include <errno.h>\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n\n#include <openssl/rc4.h>\n#include <zlib.h>\n\nstruct mm_recover_ctx {\n    sqlite3 *db; // database connection, not initialized until actual running.\n    uint32_t flags;         // section flags.\n    z_stream zstrm;         // input compression stream.\n    RC4_KEY rc4_template;   // key template.\n    RC4_KEY rc4_key;        // input file decryption key.\n    FILE *fp;               // input file handle.\n    mm_logfunc log;         // log function.\n    uint32_t sec_size;      // section size.\n    uint32_t succ_count;    // count of successfully executed statments.\n    uint32_t fail_count;    // count of failed statments.\n    uint32_t section_count; // count of processed sections.\n    uint16_t version;       // dump file version.\n\n    volatile char canceled; // task status.\n\n    uint8_t in_buf[4096]; // gzip input buffer.\n\n    char errmsg[2048];\n};\n\nstatic const char *const BIND_TAG_TEXT[] = {\n    \"BIND_NULL\",         // 0x00\n    \"BIND_VARINT\",       // 0x01\n    \"BIND_VARINT_MINUS\", // 0x02\n    \"BIND_FLOAT\",        // 0x03\n    \"BIND_TEXT\",         // 0x04\n    \"BIND_TEXT_SHORT\",   // 0x05\n    \"BIND_BLOB\",         // 0x06\n    \"BIND_BLOB_SHORT\",   // 0x07\n};\nstatic const char *const FUNC_TAG_TEXT[] = {\n    \"LARGE_DATA\",   // 0x80\n    \"SQL_ONESHOT\",  // 0x81\n    \"SQL_REPEATED\", // 0x82\n    \"END_ROW\",      // 0x83\n    \"END_SQL\",      // 0x84\n};\nstatic const char *tag2text(uint8_t tag)\n{\n    return (tag & 0x80) ? FUNC_TAG_TEXT[tag & 0x7F] : BIND_TAG_TEXT[tag];\n}\n\nstatic int read_header(mm_recover_ctx *ctx)\n{\n    mm_backup_header header;\n\n    int ret = fread(&header, sizeof(header), 1, ctx->fp);\n    if (ret != 1)\n        LOG_AND_FAIL(\"Cannot read backup header.\");\n\n    if (memcmp(header.magic, MMBAK_MAGIC, sizeof(MMBAK_MAGIC) - 1) != 0)\n        LOG_AND_FAIL(\"Invalid backup file format.\");\n\n    if (header.version != 1 && header.version != 2)\n        LOG_AND_FAIL(\"Invalid backup file version: %d\", header.version);\n\n    ctx->version = header.version;\n    return 0;\n\nbail:\n    return MMBAK_RET_FAILED;\n}\n\nstatic int dump_read_stream(mm_recover_ctx *ctx, void *buf, uint_t size)\n{\n    int ret;\n\n    if (size == 0)\n        return 0;\n\n    ctx->zstrm.next_out = (uint8_t *) buf;\n    ctx->zstrm.avail_out = size;\n\n    do {\n        if (ctx->zstrm.avail_in == 0 && ctx->sec_size > 0) {\n            ret = (ctx->sec_size > sizeof(ctx->in_buf)) ? sizeof(ctx->in_buf)\n                                                        : ctx->sec_size;\n\n            ret = fread(ctx->in_buf, 1, ret, ctx->fp);\n            if (ret == 0 && ferror(ctx->fp))\n                LOG_AND_FAIL(\"Failed reading stream: %s\", strerror(errno));\n            if (ret > 0) {\n                if ((ctx->flags & MMBAK_FLAG_NO_CIPHER) == 0)\n                    RC4(&ctx->rc4_key, ret, ctx->in_buf, ctx->in_buf);\n                ctx->zstrm.next_in = ctx->in_buf;\n                ctx->zstrm.avail_in = ret;\n\n                ctx->sec_size -= ret;\n            }\n        }\n\n        ret = inflate(&ctx->zstrm, Z_NO_FLUSH);\n        if (ret != Z_OK && ret != Z_STREAM_END)\n            LOG_AND_FAIL(\"Inflate error: %s\",\n                         ctx->zstrm.msg ? ctx->zstrm.msg : \"Unknown\");\n\n    } while (ctx->zstrm.avail_out > 0 && ret != Z_STREAM_END);\n\n    return size - ctx->zstrm.avail_out;\n\nbail:\n    return MMBAK_RET_FAILED;\n}\n\nstatic int dump_read_varint(mm_recover_ctx *ctx, int64_t *val, int minus)\n{\n    uint8_t b;\n    int ret;\n    int64_t v = 0;\n    int shift = 0;\n\n    do {\n        ret = dump_read_stream(ctx, &b, 1);\n        if (ret != 1)\n            return MMBAK_RET_FAILED;\n\n        v |= (int64_t)(b & 0x7F) << shift;\n        shift += 7;\n    } while (b & 0x80);\n\n    if (minus)\n        v = ~v;\n    *val = v;\n    return 0;\n}\n\n#define READ_STREAM_FAIL(tag, len, ret)                                        \\\n    LOG_AND_FAIL(\"Read stream failed. [tag: %s, length: %d, ret: %d]\",         \\\n                 tag2text((tag)), (len), (ret))\n#define MEMORY_ALLOC_FAIL(tag, len)                                            \\\n    LOG_AND_FAIL(\"Memory allocation failed. [tag: %s, length: %d]\",            \\\n                 tag2text((tag)), (len))\n#define SQLITE_FAIL_ERRMSG(tag, sql, errmsg)                                   \\\n    LOG_AND_FAIL(\"SQL execution failed. [tag: %s, err: %s, sql: %s]\",          \\\n                 tag2text((tag)), (errmsg), (sql))\n#define SQLITE_FAIL_GETMSG(tag, sql, db)                                       \\\n    LOG_AND_FAIL(\"SQL execution failed. [tag: %s, err: %s, sql: %s]\",          \\\n                 tag2text((tag)), sqlite3_errmsg((db)), (sql))\n#define CUSTOM_FAIL(tag, msg)                                                  \\\n    LOG_AND_FAIL(\"%s [tag: %s]\", (msg), tag2text((tag)))\n\n#define SQLITE_FAIL_ERRMSG_WARN(tag, sql, errmsg)                              \\\n    LOGE(\"SQL execution failed. [tag: %s, err: %s, sql: %s]\", tag2text((tag)), \\\n         (errmsg), (sql))\n#define SQLITE_FAIL_GETMSG_WARN(tag, sql, db)                                  \\\n    LOGE(\"SQL execution failed. [tag: %s, err: %s, sql: %s]\", tag2text((tag)), \\\n         sqlite3_errmsg((db)), (sql))\n\nstatic int dump_read_and_run_tag(mm_recover_ctx *ctx, int fatal)\n{\n    int ret;\n    uint8_t tag;\n    uint8_t length_short;\n    uint16_t length;\n    char *data = NULL;\n    char *p_data = NULL;\n    sqlite3_stmt *stmt = NULL;\n    int bind_idx;\n    char *errmsg = NULL;\n    char databuf[8192];\n\n    while (!ctx->canceled) {\n        ret = dump_read_stream(ctx, &tag, 1);\n        if (ret == 0)\n            return MMBAK_RET_OK;\n        else if (ret != 1)\n            return MMBAK_RET_FAILED;\n\n        switch (tag) {\n            case MMBAK_TAG_LARGE_DATA:\n                if (data != NULL)\n                    CUSTOM_FAIL(tag, \"Internal error.\");\n                if ((ret = dump_read_stream(ctx, &length, 2)) != 2)\n                    READ_STREAM_FAIL(tag, 2, ret);\n\n                data = (char *) malloc((length + 1) * 65536);\n                if (!data)\n                    MEMORY_ALLOC_FAIL(tag, (length + 1) * 65536);\n\n                if ((ret = dump_read_stream(ctx, data, length * 65536)) !=\n                    length * 65536)\n                    READ_STREAM_FAIL(tag, length * 65536, ret);\n\n                p_data = data;\n                //LOGD(\"[%s] len=%u * 65536\", \"LARGE_DATA\", length);\n                break;\n\n            case MMBAK_TAG_SQL_ONESHOT:\n                if ((ret = dump_read_stream(ctx, &length, 2)) != 2)\n                    READ_STREAM_FAIL(tag, 2, ret);\n\n                if (!p_data) {\n                    if (length < sizeof(databuf))\n                        data = databuf;\n                    else {\n                        data = (char *) malloc(length + 1);\n                        if (!data)\n                            MEMORY_ALLOC_FAIL(tag, length + 1);\n                    }\n                    p_data = data;\n                }\n\n                if ((ret = dump_read_stream(ctx, p_data, length)) != length)\n                    READ_STREAM_FAIL(tag, length, ret);\n                p_data[length] = '\\0';\n\n                ret = sqlite3_exec(ctx->db, data, 0, 0, &errmsg);\n                if (ret != SQLITE_OK) {\n                    SQLITE_FAIL_ERRMSG_WARN(tag, data, errmsg);\n                    if (fatal)\n                        goto bail;\n\n                    sqlite3_free(errmsg);\n                    ctx->fail_count++;\n                } else\n                    ctx->succ_count++;\n\n                //LOGD(\"[%s] sql=%s\", \"SQL_ONESHOT\", data);\n                if (data != databuf)\n                    free(data);\n                p_data = data = NULL;\n                break;\n\n            case MMBAK_TAG_SQL_REPEATED:\n                if ((ret = dump_read_stream(ctx, &length, 2)) != 2)\n                    READ_STREAM_FAIL(tag, 2, ret);\n\n                if (!p_data) {\n                    if (length < sizeof(databuf))\n                        data = databuf;\n                    else {\n                        data = (char *) malloc(length + 1);\n                        if (!data)\n                            MEMORY_ALLOC_FAIL(tag, length + 1);\n                    }\n                    p_data = data;\n                }\n                if ((ret = dump_read_stream(ctx, p_data, length)) != length)\n                    READ_STREAM_FAIL(tag, length, ret);\n                p_data[length] = '\\0';\n\n                ret = sqlite3_prepare_v2(ctx->db, data,\n                                         (p_data - data) + length, &stmt, NULL);\n                if (ret != SQLITE_OK) {\n                    SQLITE_FAIL_GETMSG_WARN(tag, data, ctx->db);\n                    if (fatal)\n                        goto bail;\n\n                    stmt = NULL;\n                }\n\n                //LOGD(\"[%s] sql=%s\", \"SQL_REPEATED\", data);\n                if (data != databuf)\n                    free(data);\n                p_data = data = NULL;\n\n                bind_idx = 0;\n                do {\n                    // check exit status.\n                    if (ctx->canceled) {\n                        if (data && data != databuf)\n                            free(data);\n                        if (stmt)\n                            sqlite3_finalize(stmt);\n                        return MMBAK_RET_CANCELED;\n                    }\n\n                    if ((ret = dump_read_stream(ctx, &tag, 1)) != 1)\n                        READ_STREAM_FAIL(tag, 1, ret);\n\n                    switch (tag) {\n                        union {\n                            int64_t i;\n                            double f;\n                        } value;\n\n                        case MMBAK_TAG_LARGE_DATA:\n                            if (data != NULL)\n                                CUSTOM_FAIL(tag, \"Internal error.\");\n                            if ((ret = dump_read_stream(ctx, &length, 2)) != 2)\n                                READ_STREAM_FAIL(tag, 2, ret);\n\n                            data = (char *) malloc((length + 1) * 65536);\n                            if (!data)\n                                MEMORY_ALLOC_FAIL(tag, (length + 1) * 65536);\n\n                            if ((ret = dump_read_stream(ctx, data,\n                                                        length * 65536)) !=\n                                length * 65536)\n                                READ_STREAM_FAIL(tag, length * 65536, ret);\n\n                            p_data = data;\n                            //LOGD(\" > [%s] len=%u * 65536\", \"LARGE_DATA\", length);\n                            break;\n\n                        case MMBAK_TAG_END_ROW:\n                            if (!stmt)\n                                ctx->fail_count++;\n                            else {\n                                while (sqlite3_step(stmt) == SQLITE_ROW) {\n                                }\n                                ret = sqlite3_reset(stmt);\n                                if (ret != SQLITE_OK) {\n                                    SQLITE_FAIL_GETMSG_WARN(\n                                        tag, sqlite3_sql(stmt), ctx->db);\n                                    if (fatal)\n                                        goto bail;\n\n                                    ctx->fail_count++;\n                                } else {\n                                    ctx->succ_count++;\n                                    if (ctx->succ_count % 256 == 0) {\n                                        // We have run 256 insertions, do a transaction commit.\n                                        ret = sqlite3_exec(ctx->db,\n                                                           \"COMMIT; BEGIN;\", 0,\n                                                           0, &errmsg);\n                                        if (ret != SQLITE_OK) {\n                                            SQLITE_FAIL_ERRMSG_WARN(tag, data,\n                                                                    errmsg);\n                                            if (fatal)\n                                                goto bail;\n\n                                            sqlite3_free(errmsg);\n                                            ctx->fail_count++;\n                                        }\n                                    }\n                                }\n                            }\n\n                            bind_idx = 0;\n                            //LOGD(\" > [%s]\", \"END_ROW\");\n                            break;\n\n                        case MMBAK_TAG_END_SQL:\n                            //LOGD(\" > [%s]\", \"END_SQL\");\n                            break; // end of loop\n\n                        case MMBAK_TAG_BIND_NULL:\n                            if (stmt)\n                                sqlite3_bind_null(stmt, ++bind_idx);\n                            //LOGD(\" > [%s]\", \"BIND_NULL\");\n                            break;\n\n                        case MMBAK_TAG_BIND_VARINT:\n                        case MMBAK_TAG_BIND_VARINT_MINUS:\n                            if (dump_read_varint(\n                                    ctx, &value.i,\n                                    tag == MMBAK_TAG_BIND_VARINT_MINUS) != 0)\n                                CUSTOM_FAIL(tag, \"Read varint failed.\");\n                            if (stmt)\n                                sqlite3_bind_int64(stmt, ++bind_idx, value.i);\n                            //LOGD(\" > [%s] value=%lld\", tag2text(tag), value.i);\n                            break;\n\n                        case MMBAK_TAG_BIND_FLOAT:\n                            if ((ret = dump_read_stream(ctx, &value, 8)) != 8)\n                                READ_STREAM_FAIL(tag, 8, ret);\n                            if (stmt)\n                                sqlite3_bind_double(stmt, ++bind_idx, value.f);\n                            //LOGD(\" > [%s] value=%f\", \"BIND_FLOAT\", value.f);\n                            break;\n\n                        case MMBAK_TAG_BIND_TEXT:\n                        case MMBAK_TAG_BIND_BLOB:\n                            if ((ret = dump_read_stream(ctx, &length, 2)) != 2)\n                                READ_STREAM_FAIL(tag, 2, ret);\n                            if (!p_data) {\n                                data = (char *) malloc(length);\n                                if (!data)\n                                    MEMORY_ALLOC_FAIL(tag, length);\n                                p_data = data;\n                            }\n                            if ((ret = dump_read_stream(ctx, p_data, length)) !=\n                                length)\n                                READ_STREAM_FAIL(tag, length, ret);\n\n                            //LOGD(\" > [%s] value=%s\", tag2text(tag), tag == MMBAK_TAG_BIND_TEXT ? data : \"(BLOB)\");\n                            if (stmt) {\n                                if (tag == MMBAK_TAG_BIND_TEXT)\n                                    sqlite3_bind_text(stmt, ++bind_idx, data,\n                                                      (p_data - data) + length,\n                                                      free);\n                                else\n                                    sqlite3_bind_blob(stmt, ++bind_idx, data,\n                                                      (p_data - data) + length,\n                                                      free);\n                            } else\n                                free(data);\n\n                            p_data = data = NULL;\n                            break;\n\n                        case MMBAK_TAG_BIND_TEXT_SHORT:\n                        case MMBAK_TAG_BIND_BLOB_SHORT:\n                            if ((ret = dump_read_stream(ctx, &length_short,\n                                                        1)) != 1)\n                                READ_STREAM_FAIL(tag, 1, ret);\n                            length = length_short;\n                            if (!p_data) {\n                                data = (char *) malloc(length);\n                                if (!data)\n                                    MEMORY_ALLOC_FAIL(tag, length);\n                                p_data = data;\n                            }\n                            if ((ret = dump_read_stream(ctx, p_data, length)) !=\n                                length)\n                                READ_STREAM_FAIL(tag, length, ret);\n\n                            //LOGD(\" > [%s] value=%s\", tag2text(tag), tag == MMBAK_TAG_BIND_TEXT_SHORT ? data : \"(BLOB)\");\n                            if (stmt) {\n                                if (tag == MMBAK_TAG_BIND_TEXT_SHORT)\n                                    sqlite3_bind_text(stmt, ++bind_idx, data,\n                                                      (p_data - data) + length,\n                                                      free);\n                                else\n                                    sqlite3_bind_blob(stmt, ++bind_idx, data,\n                                                      (p_data - data) + length,\n                                                      free);\n                            } else\n                                free(data);\n\n                            p_data = data = NULL;\n                            break;\n\n                        default:\n                            LOG_AND_FAIL(\"Unrecognized tag: %d\", tag);\n                    }\n                } while (tag != MMBAK_TAG_END_SQL);\n\n                if (stmt && sqlite3_finalize(stmt) != SQLITE_OK)\n                    SQLITE_FAIL_GETMSG(tag, \"(FINALIZE)\", ctx->db);\n                break;\n\n            default:\n                LOG_AND_FAIL(\"Unrecognized tag: %d\", tag);\n        }\n    }\n    return MMBAK_RET_CANCELED;\n\nbail:\n    if (data && data != databuf)\n        free(data);\n    if (errmsg)\n        sqlite3_free(errmsg);\n    if (stmt)\n        sqlite3_finalize(stmt);\n    LOGE(\"Fatal Offset [in: %lu, out: %lu]\", ctx->zstrm.total_in,\n         ctx->zstrm.total_out);\n    return MMBAK_RET_FAILED;\n}\n\nmm_recover_ctx *mm_recover_init(const char *in_path,\n                                const unsigned char *key,\n                                int key_len,\n                                mm_logfunc logfunc)\n{\n    if (!logfunc)\n        logfunc = dummy_log;\n\n    mm_recover_ctx *ctx = (mm_recover_ctx *) malloc(sizeof(mm_recover_ctx));\n    if (!ctx) {\n        logfunc(MMBAK_LOG_ERROR, \"Memory allocation failed.\");\n        return NULL;\n    }\n    memset(ctx, 0, sizeof(mm_recover_ctx));\n    ctx->log = logfunc;\n\n    if (key && key_len > 0)\n        RC4_set_key(&ctx->rc4_template, key_len, key);\n    else\n        ctx->flags |= MMBAK_FLAG_NO_CIPHER;\n\n    ctx->fp = fopen(in_path, \"rb\");\n    if (!ctx->fp)\n        LOG_AND_FAIL(\"Cannot open file '%s' for reading: %s\", in_path,\n                     strerror(errno));\n\n    // read header from dump file.\n    if (read_header(ctx) != 0)\n        goto bail;\n\n    LOGI(\"Database recover context initialized. [input: %s]\", in_path);\n    return ctx;\n\nbail:\n    if (ctx) {\n        inflateEnd(&ctx->zstrm);\n        if (ctx->fp)\n            fclose(ctx->fp);\n        free(ctx);\n    }\n    return NULL;\n}\n\nint mm_recover_run(mm_recover_ctx *ctx, sqlite3 *db, int fatal)\n{\n    mm_backup_section section;\n    int ret = MMBAK_RET_FAILED;\n    char *errmsg = NULL;\n    ctx->db = db;\n\n    const char *dbfile = sqlite3_db_filename(db, \"main\");\n    LOGI(\"Database recover started. [db: %s]\",\n         dbfile ? dbfile : \"(temp or memory)\");\n\n    // run startup SQLs.\n    if (sqlite3_exec(db, \"PRAGMA foreign_keys=OFF; BEGIN TRANSACTION;\", 0, 0,\n                     &errmsg) != SQLITE_OK)\n        LOG_AND_FAIL(\"Cannot execute startup SQL: %s\",\n                     errmsg ? errmsg : \"Unknown\");\n\n    ctx->succ_count = 0;\n    ctx->fail_count = 0;\n    ctx->section_count = 0;\n\n    while ((ret = fread(&section, sizeof(section), 1, ctx->fp)) == 1) {\n        ctx->flags = section.flags;\n        ctx->sec_size = section.sec_size;\n        ctx->section_count++;\n\n        // re-initialize inflate and key context.\n        if (Z_OK != inflateInit(&ctx->zstrm))\n            LOG_AND_FAIL(\"Failed to initialize inflate context.\");\n        ctx->zstrm.next_in = ctx->in_buf;\n        ctx->zstrm.avail_in = 0;\n\n        if (!(ctx->flags & MMBAK_FLAG_NO_CIPHER))\n            memcpy(&ctx->rc4_key, &ctx->rc4_template, sizeof(RC4_KEY));\n\n        // read and run dump tags.\n        ret = dump_read_and_run_tag(ctx, fatal);\n        if (ret != MMBAK_RET_OK)\n            break;\n    }\n\n    // run endup SQLs.\n    if (sqlite3_exec(db, \"COMMIT;\", 0, 0, &errmsg) != SQLITE_OK)\n        LOG_AND_FAIL(\"Cannot execute 'COMMIT': %s\",\n                     errmsg ? errmsg : \"Unknown\");\n\n    LOGI(\"Database recover %s. [sections: %u, succeeded: %u, failed: %u]\",\n         ret == MMBAK_RET_OK\n             ? \"finished\"\n             : (ret == MMBAK_RET_CANCELED) ? \"canceled\" : \"failed\",\n         ctx->section_count, ctx->succ_count, ctx->fail_count);\n    return ret;\n\nbail:\n    return MMBAK_RET_FAILED;\n}\n\nvoid mm_recover_cancel(mm_recover_ctx *ctx)\n{\n    ctx->canceled = 1;\n}\n\nvoid mm_recover_finish(mm_recover_ctx *ctx)\n{\n    if (ctx->fp)\n        fclose(ctx->fp);\n    inflateEnd(&ctx->zstrm);\n    free(ctx);\n}\n\nvoid mm_recover_statistics(mm_recover_ctx *ctx,\n                           unsigned int *succeed,\n                           unsigned int *failed)\n{\n    if (succeed)\n        *succeed = ctx->succ_count;\n    if (failed)\n        *failed = ctx->fail_count;\n}\n\nconst char *mm_recover_last_error(mm_recover_ctx *ctx)\n{\n    return ctx->errmsg;\n}\n\nvoid mm_print_log(mm_logfunc logfunc, int prio, const char *fmt, ...)\n{\n    char buf[2048];\n    va_list ap;\n\n    va_start(ap, fmt);\n    vsnprintf(buf, sizeof(buf), fmt, ap);\n    va_end(ap);\n\n    logfunc(prio, buf);\n}\n\nvoid mm_print_err(mm_logfunc logfunc, char *errmsg, const char *fmt, ...)\n{\n    // errmsg should be 2048 bytes long.\n    va_list ap;\n\n    va_start(ap, fmt);\n    vsnprintf(errmsg, 2048, fmt, ap);\n    va_end(ap);\n\n    logfunc(MMBAK_LOG_ERROR, errmsg);\n}\n\nvoid dummy_log(int prio, const char *msg)\n{\n    // do nothing.\n}\n"
  },
  {
    "path": "deprecated/android/addons/fts/fts3_tokenizer.h",
    "content": "/*\n** 2006 July 10\n**\n** The author disclaims copyright to this source code.\n**\n*************************************************************************\n** Defines the interface to tokenizers used by fulltext-search.  There\n** are three basic components:\n**\n** sqlite3_tokenizer_module is a singleton defining the tokenizer\n** interface functions.  This is essentially the class structure for\n** tokenizers.\n**\n** sqlite3_tokenizer is used to define a particular tokenizer, perhaps\n** including customization information defined at creation time.\n**\n** sqlite3_tokenizer_cursor is generated by a tokenizer to generate\n** tokens from a particular input.\n*/\n#ifndef _FTS3_TOKENIZER_H_\n#define _FTS3_TOKENIZER_H_\n\n/* TODO(shess) Only used for SQLITE_OK and SQLITE_DONE at this time.\n** If tokenizers are to be allowed to call sqlite3_*() functions, then\n** we will need a way to register the API consistently.\n*/\n#include \"sqlite3.h\"\n\n/*\n** Structures used by the tokenizer interface. When a new tokenizer\n** implementation is registered, the caller provides a pointer to\n** an sqlite3_tokenizer_module containing pointers to the callback\n** functions that make up an implementation.\n**\n** When an fts3 table is created, it passes any arguments passed to\n** the tokenizer clause of the CREATE VIRTUAL TABLE statement to the\n** sqlite3_tokenizer_module.xCreate() function of the requested tokenizer\n** implementation. The xCreate() function in turn returns an \n** sqlite3_tokenizer structure representing the specific tokenizer to\n** be used for the fts3 table (customized by the tokenizer clause arguments).\n**\n** To tokenize an input buffer, the sqlite3_tokenizer_module.xOpen()\n** method is called. It returns an sqlite3_tokenizer_cursor object\n** that may be used to tokenize a specific input buffer based on\n** the tokenization rules supplied by a specific sqlite3_tokenizer\n** object.\n*/\ntypedef struct sqlite3_tokenizer_module sqlite3_tokenizer_module;\ntypedef struct sqlite3_tokenizer sqlite3_tokenizer;\ntypedef struct sqlite3_tokenizer_cursor sqlite3_tokenizer_cursor;\n\nstruct sqlite3_tokenizer_module {\n\n  /*\n  ** Structure version. Should always be set to 0.\n  */\n  int iVersion;\n\n  /*\n  ** Create a new tokenizer. The values in the argv[] array are the\n  ** arguments passed to the \"tokenizer\" clause of the CREATE VIRTUAL\n  ** TABLE statement that created the fts3 table. For example, if\n  ** the following SQL is executed:\n  **\n  **   CREATE .. USING fts3( ... , tokenizer <tokenizer-name> arg1 arg2)\n  **\n  ** then argc is set to 2, and the argv[] array contains pointers\n  ** to the strings \"arg1\" and \"arg2\".\n  **\n  ** This method should return either SQLITE_OK (0), or an SQLite error \n  ** code. If SQLITE_OK is returned, then *ppTokenizer should be set\n  ** to point at the newly created tokenizer structure. The generic\n  ** sqlite3_tokenizer.pModule variable should not be initialised by\n  ** this callback. The caller will do so.\n  */\n  int (*xCreate)(\n    int argc,                           /* Size of argv array */\n    const char *const*argv,             /* Tokenizer argument strings */\n    sqlite3_tokenizer **ppTokenizer     /* OUT: Created tokenizer */\n  );\n\n  /*\n  ** Destroy an existing tokenizer. The fts3 module calls this method\n  ** exactly once for each successful call to xCreate().\n  */\n  int (*xDestroy)(sqlite3_tokenizer *pTokenizer);\n\n  /*\n  ** Create a tokenizer cursor to tokenize an input buffer. The caller\n  ** is responsible for ensuring that the input buffer remains valid\n  ** until the cursor is closed (using the xClose() method). \n  */\n  int (*xOpen)(\n    sqlite3_tokenizer *pTokenizer,       /* Tokenizer object */\n    const char *pInput, int nBytes,      /* Input buffer */\n    sqlite3_tokenizer_cursor **ppCursor  /* OUT: Created tokenizer cursor */\n  );\n\n  /*\n  ** Destroy an existing tokenizer cursor. The fts3 module calls this \n  ** method exactly once for each successful call to xOpen().\n  */\n  int (*xClose)(sqlite3_tokenizer_cursor *pCursor);\n\n  /*\n  ** Retrieve the next token from the tokenizer cursor pCursor. This\n  ** method should either return SQLITE_OK and set the values of the\n  ** \"OUT\" variables identified below, or SQLITE_DONE to indicate that\n  ** the end of the buffer has been reached, or an SQLite error code.\n  **\n  ** *ppToken should be set to point at a buffer containing the \n  ** normalized version of the token (i.e. after any case-folding and/or\n  ** stemming has been performed). *pnBytes should be set to the length\n  ** of this buffer in bytes. The input text that generated the token is\n  ** identified by the byte offsets returned in *piStartOffset and\n  ** *piEndOffset. *piStartOffset should be set to the index of the first\n  ** byte of the token in the input buffer. *piEndOffset should be set\n  ** to the index of the first byte just past the end of the token in\n  ** the input buffer.\n  **\n  ** The buffer *ppToken is set to point at is managed by the tokenizer\n  ** implementation. It is only required to be valid until the next call\n  ** to xNext() or xClose(). \n  */\n  /* TODO(shess) current implementation requires pInput to be\n  ** nul-terminated.  This should either be fixed, or pInput/nBytes\n  ** should be converted to zInput.\n  */\n  int (*xNext)(\n    sqlite3_tokenizer_cursor *pCursor,   /* Tokenizer cursor */\n    const char **ppToken, int *pnBytes,  /* OUT: Normalized text for token */\n    int *piStartOffset,  /* OUT: Byte offset of token in input buffer */\n    int *piEndOffset,    /* OUT: Byte offset of end of token in input buffer */\n    int *piPosition      /* OUT: Number of tokens returned before this one */\n  );\n};\n\nstruct sqlite3_tokenizer {\n  const sqlite3_tokenizer_module *pModule;  /* The module for this tokenizer */\n  /* Tokenizer implementations will typically add additional fields */\n};\n\nstruct sqlite3_tokenizer_cursor {\n  sqlite3_tokenizer *pTokenizer;       /* Tokenizer for this cursor. */\n  /* Tokenizer implementations will typically add additional fields */\n};\n\nint fts3_global_term_cnt(int iTerm, int iCol);\nint fts3_term_cnt(int iTerm, int iCol);\n\n\n#endif /* _FTS3_TOKENIZER_H_ */\n"
  },
  {
    "path": "deprecated/android/addons/fts/mm_cipher.c",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"mm_fts.h\"\n#include <icucompat.h>\n#include <openssl/rc4.h>\n#include <stdlib.h>\n#include <string.h>\n#include <unicode/ucnv.h>\n\ntypedef struct mm_cipher_context_t {\n    int ref_count;\n\n    UConverter *cnv;\n    uint8_t key[16];\n} mm_cipher_context_t;\n\nstatic void do_rc4(mm_cipher_context_t *ctx, void *buf, int buf_len)\n{\n    RC4_KEY rc4_key;\n\n    RC4_set_key(&rc4_key, 16, ctx->key);\n    RC4(&rc4_key, (size_t) buf_len, (const unsigned char *) buf,\n        (unsigned char *) buf);\n}\n\nstatic void mmenc_func(sqlite3_context *db, int argc, sqlite3_value **argv)\n{\n    mm_cipher_context_t *ctx;\n    const UChar *src;\n    int32_t src_len;\n    char buf[1024];\n    char *dst = buf;\n    int32_t dst_len;\n    UErrorCode status = U_ZERO_ERROR;\n    int arg_type;\n\n    // only accept 1 argument.\n    if (argc != 1)\n        goto error_misuse;\n\n    // encoding BLOB data type is not supported.\n    arg_type = sqlite3_value_type(argv[0]);\n    if (arg_type == SQLITE_BLOB)\n        goto error_misuse;\n\n    // for data types other than TEXT, just return them.\n    if (arg_type != SQLITE_TEXT) {\n        sqlite3_result_value(db, argv[0]);\n        return;\n    }\n\n    ctx = (mm_cipher_context_t *) sqlite3_user_data(db);\n    src_len = sqlite3_value_bytes16(argv[0]) / 2;\n    src = (const UChar *) sqlite3_value_text16(argv[0]);\n\n    // transform input string to BOCU-1 encoding.\n    // try stack buffer first, if it doesn't fit, malloc a new buffer.\n    dst_len =\n        ucnv_fromUChars(ctx->cnv, dst, sizeof(buf), src, src_len, &status);\n    if (status == U_BUFFER_OVERFLOW_ERROR) {\n        status = U_ZERO_ERROR;\n        dst = (char *) sqlite3_malloc(dst_len);\n        dst_len =\n            ucnv_fromUChars(ctx->cnv, dst, dst_len, src, src_len, &status);\n    }\n    if (U_FAILURE(status) && status != U_STRING_NOT_TERMINATED_WARNING) {\n        sqlite3_mm_set_last_error(\n            \"Failed transforming text to internal encoding.\");\n        goto error_error;\n    }\n\n    // encrypt transformed BOCU-1 string.\n    do_rc4(ctx, dst, dst_len);\n\n    // return\n    sqlite3_result_blob(db, dst, dst_len, SQLITE_TRANSIENT);\n    if (dst != buf)\n        sqlite3_free(dst);\n    return;\n\nerror_error:\n    if (dst != buf)\n        sqlite3_free(dst);\n    sqlite3_result_error_code(db, SQLITE_ERROR);\n    return;\n\nerror_misuse:\n    if (dst != buf)\n        sqlite3_free(dst);\n    sqlite3_result_error_code(db, SQLITE_MISUSE);\n    return;\n}\n\nstatic void mmdec_func(sqlite3_context *db, int argc, sqlite3_value **argv)\n{\n    mm_cipher_context_t *ctx;\n    char src_buf[1024];\n    char *src = src_buf;\n    int32_t src_len;\n    UChar buf[512];\n    UChar *dst = buf;\n    int32_t dst_len;\n    UErrorCode status = U_ZERO_ERROR;\n    int arg_type;\n\n    // only accept 1 argument.\n    if (argc != 1)\n        goto error_misuse;\n\n    arg_type = sqlite3_value_type(argv[0]);\n\n    // for data types other than BLOB, just return them.\n    if (arg_type != SQLITE_BLOB) {\n        sqlite3_result_value(db, argv[0]);\n        return;\n    }\n\n    ctx = (mm_cipher_context_t *) sqlite3_user_data(db);\n    src_len = sqlite3_value_bytes(argv[0]);\n    if (src_len > sizeof(src_buf)) {\n        src = (char *) sqlite3_malloc(src_len);\n        if (!src)\n            goto error_error;\n    }\n    memcpy(src, sqlite3_value_blob(argv[0]), src_len);\n\n    // decrypt transformed BOCU-1 string.\n    do_rc4(ctx, src, src_len);\n\n    // transform input string from BOCU-1 encoding.\n    // try stack buffer first, if it doesn't fit, malloc a new buffer.\n    dst_len = ucnv_toUChars(ctx->cnv, dst, sizeof(buf), src, src_len, &status);\n    if (status == U_BUFFER_OVERFLOW_ERROR) {\n        status = U_ZERO_ERROR;\n        dst = (UChar *) sqlite3_malloc(dst_len * sizeof(UChar));\n        dst_len = ucnv_toUChars(ctx->cnv, dst, dst_len, src, src_len, &status);\n    }\n    if (U_FAILURE(status) && status != U_STRING_NOT_TERMINATED_WARNING) {\n        sqlite3_mm_set_last_error(\n            \"Failed transforming text from internal encoding.\");\n        goto error_error;\n    }\n\n    // return\n    sqlite3_result_text16(db, dst, dst_len * sizeof(UChar), SQLITE_TRANSIENT);\n    if (src != src_buf)\n        sqlite3_free(src);\n    if (dst != buf)\n        sqlite3_free(dst);\n    return;\n\nerror_error:\n    if (src != src_buf)\n        sqlite3_free(src);\n    if (dst != buf)\n        sqlite3_free(dst);\n    sqlite3_result_error_code(db, SQLITE_ERROR);\n    return;\n\nerror_misuse:\n    if (src != src_buf)\n        sqlite3_free(src);\n    if (dst != buf)\n        sqlite3_free(dst);\n    sqlite3_result_error_code(db, SQLITE_MISUSE);\n    return;\n}\n\nstatic void\nmm_cipher_key_func(sqlite3_context *db, int argc, sqlite3_value **argv)\n{\n    mm_cipher_context_t *ctx;\n\n    // only accept 1 BLOB argument.\n    if (argc != 1)\n        goto error_misuse;\n    if (sqlite3_value_type(argv[0]) != SQLITE_BLOB)\n        goto error_misuse;\n    if (sqlite3_value_bytes(argv[0]) != 16)\n        goto error_misuse;\n\n    ctx = (mm_cipher_context_t *) sqlite3_user_data(db);\n    memcpy(ctx->key, sqlite3_value_blob(argv[0]), 16);\n\n    sqlite3_result_null(db);\n    return;\n\nerror_misuse:\n    sqlite3_result_error_code(db, SQLITE_MISUSE);\n    return;\n}\n\nstatic void mm_func_destroy(void *ptr)\n{\n    mm_cipher_context_t *ctx = (mm_cipher_context_t *) ptr;\n    if (--ctx->ref_count == 0) {\n        ucnv_close(ctx->cnv);\n        sqlite3_free(ctx);\n    }\n}\n\nint sqlite3_register_mm_cipher(sqlite3 *db, const unsigned char *key)\n{\n    UErrorCode status = U_ZERO_ERROR;\n    int sqlite_err;\n    mm_cipher_context_t *ctx;\n\n    // XXX: if we failed to load ICU functions, just skip initializing.\n    if (!ucnv_openCCSID)\n        return SQLITE_OK;\n\n    ctx = sqlite3_malloc(sizeof(mm_cipher_context_t));\n    if (!ctx)\n        return SQLITE_NOMEM;\n\n    sqlite_err = SQLITE_ERROR;\n    // open converter using CCSID instead of converter name to hide \"BOCU-1\" string.\n    ctx->cnv = ucnv_openCCSID(1214, UCNV_IBM, &status);\n    if (!ctx->cnv)\n        goto error;\n\n    memcpy(ctx->key, key, 16);\n    ctx->ref_count = 3;\n\n    sqlite_err =\n        sqlite3_create_function_v2(db, \"mmenc\", 1, SQLITE_ANY, ctx, mmenc_func,\n                                   NULL, NULL, mm_func_destroy);\n    if (sqlite_err != SQLITE_OK)\n        goto error;\n\n    sqlite_err =\n        sqlite3_create_function_v2(db, \"mmdec\", 1, SQLITE_ANY, ctx, mmdec_func,\n                                   NULL, NULL, mm_func_destroy);\n    if (sqlite_err != SQLITE_OK)\n        goto error;\n\n    sqlite_err = sqlite3_create_function_v2(db, \"mm_cipher_key\", 1, SQLITE_ANY,\n                                            ctx, mm_cipher_key_func, NULL, NULL,\n                                            mm_func_destroy);\n    if (sqlite_err != SQLITE_OK)\n        goto error;\n\n    return SQLITE_OK;\n\nerror:\n    if (ctx)\n        sqlite3_free(ctx);\n    return sqlite_err;\n}\n\nint sqlite3_mm_set_cipher_key(sqlite3 *db, const void *key, int key_len)\n{\n    sqlite3_stmt *stmt;\n    int ret =\n        sqlite3_prepare_v2(db, \"SELECT mm_cipher_key(?)\", -1, &stmt, NULL);\n    if (ret != SQLITE_OK)\n        return ret;\n\n    sqlite3_bind_blob(stmt, 1, key, key_len, SQLITE_STATIC);\n    sqlite3_step(stmt);\n\n    return sqlite3_finalize(stmt);\n}\n"
  },
  {
    "path": "deprecated/android/addons/fts/mm_fts.h",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#ifndef __MM_FTS_H__\n#define __MM_FTS_H__\n\n#include <sqlite3ext.h>\nSQLITE_EXTENSION_INIT3\n\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\nint sqlite3_mmftsext_init(sqlite3 *db, char **pzErrMsg, const sqlite3_api_routines *pApi);\n\nint sqlite3_register_mm_tokenizer(sqlite3 *db);\nint sqlite3_register_mm_cipher(sqlite3 *db, const unsigned char *key);\nint sqlite3_register_mm_utils(sqlite3 *db);\nint sqlite3_mm_set_cipher_key(sqlite3 *db, const void *key, int key_len);\nvoid sqlite3_mm_set_last_error(const char *fmt, ...);\nvoid sqlite3_mm_clear_error();\n\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif\t// __MM_FTS_H__\n"
  },
  {
    "path": "deprecated/android/addons/fts/mm_sqliteext.c",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include <sqlite3ext.h>\nSQLITE_EXTENSION_INIT1\n\n#include \"mm_fts.h\"\n#include <icucompat.h>\n\nconst static uint8_t g_default_key[16] = {0x8e, 0x65, 0xd8, 0x50, 0x1f, 0x94,\n                                          0x06, 0x22, 0xfa, 0x45, 0x68, 0xb6,\n                                          0x69, 0x56, 0x34, 0x9c};\n\n#ifdef _WIN32\n__declspec(dllexport)\n#endif\nint sqlite3_mmftsext_init(sqlite3 *db,\n\t\t\t\t\t\t\tchar **pzErrMsg,\n\t\t\t\t\t\t\tconst sqlite3_api_routines *pApi)\n{\n    int rc;\n    const char *errmsg;\n    SQLITE_EXTENSION_INIT2(pApi);\n\n    // Load and initialize ICU library.\n    if (init_icucompat() != 0) {\n        *pzErrMsg = sqlite3_mprintf(\"failed to load ICU library.\");\n        return SQLITE_ERROR;\n    }\n\n    // Register tokenizer.\n    rc = sqlite3_register_mm_tokenizer(db);\n    if (rc != SQLITE_OK)\n        goto bail;\n\n    // Register text cipher.\n    rc = sqlite3_register_mm_cipher(db, g_default_key);\n    if (rc != SQLITE_OK)\n        goto bail;\n\n    // Register utility functions.\n    rc = sqlite3_register_mm_utils(db);\n    if (rc != SQLITE_OK)\n        goto bail;\n\n    *pzErrMsg = NULL;\n    return SQLITE_OK;\n\nbail:\n    errmsg = sqlite3_errmsg(db);\n    if (!errmsg)\n        errmsg = \"\";\n    *pzErrMsg = sqlite3_mprintf(\n        \"Failed to register SQLite functions: %s, ErrCode: %d\", errmsg, rc);\n    return rc;\n}\n"
  },
  {
    "path": "deprecated/android/addons/fts/mm_tokenizer.c",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"fts3_tokenizer.h\"\n#include \"mm_fts.h\"\n#include <icucompat.h>\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include <unicode/ubrk.h>\n#include <unicode/unorm.h>\n#include <unicode/utf16.h>\n#include <unicode/utf8.h>\n\n\n#ifdef _WIN32\n#include <malloc.h>\n#endif\n\n#define ROUND4(n) (((n) + 3) & ~3)\n\ntypedef struct mm_tokenizer_t {\n    sqlite3_tokenizer base;\n    char locale[16];\n} mm_tokenizer_t;\n\ntypedef struct mm_cursor_t {\n    sqlite3_tokenizer_cursor base;\n\n    UBreakIterator *iter;   // UBreakIterator for the text.\n    UChar *in_buffer;       // whole input text buffer, in UTF-16, \n                            // allocated altogather with mm_cursor_t.\n    int *in_offset;\n    int in_length;          // input text length.\n\n    char *out_buffer;       // output token buffer, int UTF-8, \n                            // allocated in mmtok_next.\n    int out_length;         // output token buffer length.\n    int token_count;\n\n    int32_t ideo_start; // ideographic unary/binary tokenizing cursor.\n    int32_t ideo_end;   // ideographic unary/binary tokenizing end point.\n    int ideo_state;     // 0 for unary output, -1 for invalid status.\n} mm_cursor_t;\n#define MINIMAL_OUT_BUFFER_LENGTH 512\n\nstatic char *generate_token_printable_code(const UChar *buf, int32_t length)\n{\n    char *out = (char *) malloc(length * 5 + 1);\n    char *pc = out;\n    if (!out)\n        return \"\";\n\n    while (length > 0) {\n        snprintf(pc, 6, \"%04hX \", *buf);\n        length--;\n        buf++;\n        pc += 5;\n    }\n\n    return out;\n}\n\nstatic int output_token(mm_cursor_t *cur,\n                        int32_t start,\n                        int32_t end,\n                        const char **ppToken,\n                        int *pnBytes,\n                        int *piStartOffset,\n                        int *piEndOffset,\n                        int *piPosition)\n{\n    UChar buf1[256];\n    UChar buf2[256];\n    UErrorCode status = U_ZERO_ERROR;\n    int32_t result;\n    int32_t length;\n\n    length = end - start;\n    if (length > 256)\n        length = 256;\n    result = unorm_normalize(cur->in_buffer + start, length, UNORM_NFKD, 0,\n                             buf1, sizeof(buf1) / sizeof(UChar), &status);\n    // currently, only try fixed length buffer, failed if overflowed.\n    if (U_FAILURE(status) || result > sizeof(buf1) / sizeof(UChar)) {\n        char *seq =\n            generate_token_printable_code(cur->in_buffer + start, length);\n        sqlite3_mm_set_last_error(\n            \"Normalize token failed. ICU status: %d, input: %s\", status, seq);\n        free(seq);\n        return SQLITE_ERROR;\n    }\n\n    length = result;\n    result = u_strFoldCase(buf2, sizeof(buf2) / sizeof(UChar), buf1, length,\n                           U_FOLD_CASE_DEFAULT, &status);\n    // currently, only try fixed length buffer, failed if overflowed.\n    if (U_FAILURE(status) || result > sizeof(buf2) / sizeof(UChar)) {\n        char *seq = generate_token_printable_code(buf1, length);\n        sqlite3_mm_set_last_error(\n            \"FoldCase token failed. ICU status: %d, input: %s\", status, seq);\n        free(seq);\n        return SQLITE_ERROR;\n    }\n\n    if (cur->out_buffer == NULL) {\n        cur->out_buffer =\n            (char *) sqlite3_malloc(MINIMAL_OUT_BUFFER_LENGTH * sizeof(char));\n        if (!cur->out_buffer)\n            return SQLITE_NOMEM;\n        cur->out_length = MINIMAL_OUT_BUFFER_LENGTH;\n    }\n\n    length = result;\n    u_strToUTF8(cur->out_buffer, cur->out_length, &result, buf2, length,\n                &status);\n    if (result > cur->out_length) {\n        char *b =\n            (char *) sqlite3_realloc(cur->out_buffer, result * sizeof(char));\n        if (!b)\n            return SQLITE_NOMEM;\n\n        cur->out_buffer = b;\n        cur->out_length = result;\n\n        status = U_ZERO_ERROR;\n        u_strToUTF8(cur->out_buffer, cur->out_length, &result, buf2, length,\n                    &status);\n    }\n    if (U_FAILURE(status) || result > cur->out_length) {\n        char *seq = generate_token_printable_code(buf2, length);\n        sqlite3_mm_set_last_error(\n            \"Transform token to UTF-8 failed. ICU status: %d, input: %s\",\n            status, seq);\n        free(seq);\n        return SQLITE_ERROR;\n    }\n\n    *ppToken = cur->out_buffer;\n    *pnBytes = result;\n    *piStartOffset = cur->in_offset[start];\n    *piEndOffset = cur->in_offset[end];\n    *piPosition = cur->token_count++;\n\n    return SQLITE_OK;\n}\n\nstatic int\nfind_splited_ideo_token(mm_cursor_t *cur, int32_t *start, int32_t *end)\n{\n    int32_t s, e;\n    UChar32 c;\n\n    if (cur->ideo_state < 0)\n        return 0;\n\n    if (cur->ideo_start == cur->ideo_end) {\n        cur->ideo_state = -1;\n        return 0;\n    }\n\n    // check UTF-16 surrogates, output 2 UChars if it's a lead surrogates, otherwise 1.\n    s = cur->ideo_start;\n    e = s + 1;\n    c = cur->in_buffer[s];\n    if (U16_IS_LEAD(c) && cur->ideo_end - s >= 2)\n        e++;\n\n    *start = s;\n    *end = e;\n    cur->ideo_start = e;\n    return 1;\n}\n\nstatic int\nmmtok_create(int argc, const char *const *argv, sqlite3_tokenizer **ppTokenizer)\n{\n    mm_tokenizer_t *tok = sqlite3_malloc(sizeof(mm_tokenizer_t));\n    if (!tok)\n        return SQLITE_NOMEM;\n\n    if (argc > 0) {\n        strncpy(tok->locale, argv[0], 15);\n        tok->locale[15] = 0;\n    } else\n        tok->locale[0] = 0;\n\n    *ppTokenizer = (sqlite3_tokenizer *) tok;\n    return SQLITE_OK;\n}\n\nstatic int mmtok_destroy(sqlite3_tokenizer *pTokenizer)\n{\n    mm_tokenizer_t *tok = (mm_tokenizer_t *) pTokenizer;\n    sqlite3_free(tok);\n    return SQLITE_OK;\n}\n\nstatic int mmtok_open(sqlite3_tokenizer *pTokenizer,\n                      const char *zInput,\n                      int nInput,\n                      sqlite3_tokenizer_cursor **ppCursor)\n{\n    mm_tokenizer_t *tok = (mm_tokenizer_t *) pTokenizer;\n    mm_cursor_t *cur;\n    int i_input;\n    int i_output;\n\n    UErrorCode status = U_ZERO_ERROR;\n    int32_t dst_len;\n    UChar32 c;\n\n    //__android_log_print(ANDROID_LOG_VERBOSE, \"TOKENIZER\", \"Begin: %s\", zInput);\n\n    if (nInput < 0)\n        nInput = strlen(zInput);\n\n    dst_len = ROUND4(nInput + 1);\n    cur = (mm_cursor_t *) sqlite3_malloc(\n        sizeof(mm_cursor_t) + dst_len * sizeof(UChar) // in_buffer\n        + (dst_len + 1) * sizeof(int)                 // in_offset\n        );\n    if (!cur)\n        return SQLITE_NOMEM;\n\n    memset(cur, 0, sizeof(mm_cursor_t));\n    cur->in_buffer = (UChar *) &cur[1];\n    cur->in_offset = (int *) &cur->in_buffer[dst_len];\n    cur->out_buffer = NULL;\n    cur->out_length = 0;\n    cur->token_count = 0;\n    cur->ideo_start = -1;\n    cur->ideo_end = -1;\n    cur->ideo_state = -1;\n\n    i_input = 0;\n    i_output = 0;\n    cur->in_offset[i_output] = i_input;\n    for (;;) {\n        if (i_input >= nInput)\n            break;\n\n        U8_NEXT(zInput, i_input, nInput, c);\n        if (!c)\n            break;\n        if (c < 0)\n            c = ' ';\n\n        int is_error = 0;\n        U16_APPEND(cur->in_buffer, i_output, dst_len, c, is_error);\n        if (is_error) {\n            sqlite3_free(cur);\n            sqlite3_mm_set_last_error(\n                \"Writing UTF-16 character failed. Code point: 0x%x\", c);\n            return SQLITE_ERROR;\n        }\n        cur->in_offset[i_output] = i_input;\n    }\n\n    cur->iter =\n        ubrk_open(UBRK_WORD, tok->locale, cur->in_buffer, i_output, &status);\n    if (U_FAILURE(status)) {\n        sqlite3_mm_set_last_error(\n            \"Open UBreakIterator failed. ICU error code: %d\", status);\n        return SQLITE_ERROR;\n    }\n    cur->in_length = i_output;\n\n    ubrk_first(cur->iter);\n    *ppCursor = (sqlite3_tokenizer_cursor *) cur;\n    return SQLITE_OK;\n}\n\nstatic int mmtok_close(sqlite3_tokenizer_cursor *pCursor)\n{\n    mm_cursor_t *cur = (mm_cursor_t *) pCursor;\n    ubrk_close(cur->iter);\n    if (cur->out_buffer)\n        sqlite3_free(cur->out_buffer);\n    sqlite3_free(cur);\n    return SQLITE_OK;\n}\n\nstatic int\nmmtok_next(sqlite3_tokenizer_cursor *pCursor, // Cursor returned by simpleOpen\n           const char **ppToken,              // OUT: *ppToken is the token text\n           int *pnBytes,                      // OUT: Number of bytes in token\n           int *piStartOffset,                // OUT: Starting offset of token\n           int *piEndOffset,                  // OUT: Ending offset of token\n           int *piPosition                    // OUT: Position integer of token\n           )\n{\n    mm_cursor_t *cur = (mm_cursor_t *) pCursor;\n    int32_t start, end;\n    int32_t token_type;\n\n    // process pending ideographic token.\n    if (find_splited_ideo_token(cur, &start, &end))\n        return output_token(cur, start, end, ppToken, pnBytes, piStartOffset,\n                            piEndOffset, piPosition);\n\n    start = ubrk_current(cur->iter);\n\n    // find first non-NONE token.\n    for (;;) {\n        end = ubrk_next(cur->iter);\n        if (end == UBRK_DONE) {\n            sqlite3_mm_clear_error();\n            return SQLITE_DONE;\n        }\n\n        token_type = ubrk_getRuleStatus(cur->iter);\n        if (token_type >= UBRK_WORD_NONE && token_type < UBRK_WORD_NONE_LIMIT) {\n            // look at the first character, if it's a space or ZWSP, ignore this token.\n            // also ignore '*' because sqlite parser uses it as prefix operator.\n            UChar32 c = cur->in_buffer[start];\n            if (c == '*' || c == 0x200b || u_isspace(c)) {\n                start = end;\n                continue;\n            }\n        }\n\n        break;\n    }\n\n    // for non-IDEO tokens, just return.\n    if (token_type < UBRK_WORD_IDEO || token_type >= UBRK_WORD_IDEO_LIMIT)\n        return output_token(cur, start, end, ppToken, pnBytes, piStartOffset,\n                            piEndOffset, piPosition);\n\n    // for IDEO tokens, find all suffix ideo tokens.\n    for (;;) {\n        int32_t e = ubrk_next(cur->iter);\n        if (e == UBRK_DONE)\n            break;\n        token_type = ubrk_getRuleStatus(cur->iter);\n        if (token_type < UBRK_WORD_IDEO || token_type >= UBRK_WORD_IDEO_LIMIT)\n            break;\n        end = e;\n    }\n    ubrk_isBoundary(cur->iter, end);\n\n    cur->ideo_start = start;\n    cur->ideo_end = end;\n    cur->ideo_state = 0;\n    if (find_splited_ideo_token(cur, &start, &end))\n        return output_token(cur, start, end, ppToken, pnBytes, piStartOffset,\n                            piEndOffset, piPosition);\n\n    sqlite3_mm_set_last_error(\"IDEO token found but can't output token.\");\n    return SQLITE_ERROR;\n}\n\nstatic const sqlite3_tokenizer_module mm_tokenizer_module = {\n    0, mmtok_create, mmtok_destroy, mmtok_open, mmtok_close, mmtok_next};\n\nint sqlite3_register_mm_tokenizer(sqlite3 *db)\n{\n    const sqlite3_tokenizer_module *module = &mm_tokenizer_module;\n    sqlite3_stmt *stmt = NULL;\n    int result;\n\n    result =\n        sqlite3_prepare_v2(db, \"SELECT fts3_tokenizer(?, ?)\", -1, &stmt, 0);\n    if (result != SQLITE_OK)\n        return result;\n\n    sqlite3_bind_text(stmt, 1, \"mmicu\", -1, SQLITE_STATIC);\n    sqlite3_bind_blob(stmt, 2, &module, sizeof(sqlite3_tokenizer_module *),\n                      SQLITE_STATIC);\n    sqlite3_step(stmt);\n\n    return sqlite3_finalize(stmt);\n}\n"
  },
  {
    "path": "deprecated/android/addons/fts/mm_utils.c",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"mm_fts.h\"\n#include <stdarg.h>\n#include <stdio.h>\n#include <stdlib.h>\n\nstatic char g_errmsg_buffer[1024];\n\nvoid sqlite3_mm_set_last_error(const char *fmt, ...)\n{\n    va_list args;\n    va_start(args, fmt);\n\n    vsnprintf(g_errmsg_buffer, sizeof(g_errmsg_buffer), fmt, args);\n    g_errmsg_buffer[sizeof(g_errmsg_buffer) - 1] = 0;\n\n    va_end(args);\n}\n\nvoid sqlite3_mm_clear_error()\n{\n    g_errmsg_buffer[0] = 0;\n}\n\nstatic void mm_last_error(sqlite3_context *db, int argc, sqlite3_value **argv)\n{\n    sqlite3_result_text(db, g_errmsg_buffer, -1, SQLITE_STATIC);\n}\n\nint sqlite3_register_mm_utils(sqlite3 *db)\n{\n    return sqlite3_create_function_v2(db, \"mm_last_error\", 0, SQLITE_ANY, NULL,\n                                      mm_last_error, NULL, NULL, NULL);\n}\n"
  },
  {
    "path": "deprecated/android/addons/icucompat/icucompat.c",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#if defined(__ANDROID__) && !defined(WCDB_ICU_DIRECT_LINKING)\n\n#define ICUCOMPAT_IMPL\n\n#include \"icucompat.h\"\n#include <dirent.h>\n#include <dlfcn.h>\n#include <stdio.h>\n#include <string.h>\n\nstatic void *s_libicuuc_so = NULL;\nstatic void *s_libicui18n_so = NULL;\nicu_compat_t __g_icucompat_iface__ = {0};\n\nstatic void *\nload_function(void *lib_handle, const char *func_name, const char *suffix)\n{\n    char buf[128];\n    size_t len = strlcpy(buf, func_name, sizeof(buf));\n    strlcpy(buf + len, suffix, sizeof(buf) - len);\n\n    return dlsym(lib_handle, buf);\n}\n\nstatic void load_functions(const char *suffix)\n{\n#define ICUCOMPAT_UC_FUNC(ret_type, func_name, arg_list)                       \\\n    (__g_icucompat_iface__.func_name##_) =                                     \\\n        (ret_type(*) arg_list) load_function(s_libicuuc_so, #func_name,        \\\n                                             suffix);\n#define ICUCOMPAT_I18N_FUNC(ret_type, func_name, arg_list)                     \\\n    (__g_icucompat_iface__.func_name##_) =                                     \\\n        (ret_type(*) arg_list) load_function(s_libicui18n_so, #func_name,      \\\n                                             suffix);\n\n#include \"icuprototype.h\"\n\n#undef ICUCOMPAT_UC_FUNC\n#undef ICUCOMPAT_I18N_FUNC\n}\n\nstatic const char *find_icu_suffix(void *lib_handle, char *buf, size_t buflen)\n{\n    DIR *icudir = opendir(\"/system/usr/icu\");\n    if (!icudir)\n        return NULL;\n\n    struct dirent *dp;\n    while ((dp = readdir(icudir)) != NULL) {\n        if (dp->d_type == DT_REG) {\n            // Find /system/usr/icu/icudt??l.dat\n            const char *name = dp->d_name;\n            if (strlen(name) == 12 && !strncmp(\"icudt\", name, 5) &&\n                name[5] >= '0' && name[5] <= '9' && name[6] >= '0' &&\n                name[6] <= '9' && !strncmp(\"l.dat\", &name[7], 6)) {\n                snprintf(buf, buflen, \"_%c%c\", name[5], name[6]);\n\n                // Try loading with suffix.\n                if (load_function(lib_handle, \"u_getVersion\", buf)) {\n                    closedir(icudir);\n                    return buf;\n                }\n            }\n        }\n    }\n    closedir(icudir);\n\n    // Failed, try plain names without suffix.\n    if (load_function(lib_handle, \"u_getVersion\", \"\")) {\n        buf[0] = 0;\n        return buf;\n    }\n\n    return NULL;\n}\n\nint init_icucompat()\n{\n    char suffix[16];\n    if (s_libicuuc_so || s_libicui18n_so)\n        return 0;\n\n    s_libicuuc_so = dlopen(\"libicuuc.so\", RTLD_LAZY);\n    s_libicui18n_so = dlopen(\"libicui18n.so\", RTLD_LAZY);\n    if (!s_libicuuc_so || !s_libicui18n_so)\n        goto bail;\n\n    if (!find_icu_suffix(s_libicuuc_so, suffix, sizeof(suffix)))\n        goto bail;\n\n    load_functions(suffix);\n    return 0;\n\nbail:\n    if (s_libicuuc_so)\n        dlclose(s_libicuuc_so);\n    if (s_libicui18n_so)\n        dlclose(s_libicui18n_so);\n    s_libicuuc_so = NULL;\n    s_libicui18n_so = NULL;\n    return -1;\n}\n\nvoid destroy_icucompat()\n{\n    if (s_libicuuc_so)\n        dlclose(s_libicuuc_so);\n    if (s_libicui18n_so)\n        dlclose(s_libicui18n_so);\n    s_libicuuc_so = NULL;\n    s_libicui18n_so = NULL;\n}\n\n#endif // defined(__ANDROID__) && !defined(WCDB_ICU_DIRECT_LINKING)\n"
  },
  {
    "path": "deprecated/android/addons/icucompat/icucompat.h",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#ifndef __ICU_COMPAT_H__\n#define __ICU_COMPAT_H__\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/* Disable ICU export renaming. It will be replaced with icucompat macros. */\n#define U_DISABLE_RENAMING 1\n#include <unicode/ubrk.h>\n#include <unicode/ucnv.h>\n#include <unicode/ucol.h>\n#include <unicode/uiter.h>\n#include <unicode/umachine.h>\n#include <unicode/unorm.h>\n#include <unicode/ustring.h>\n#include <unicode/utypes.h>\n#include <unicode/uversion.h>\n\ntypedef struct icu_compat_t {\n#define ICUCOMPAT_UC_FUNC(ret_type, func_name, arg_list)                       \\\n    ret_type(U_EXPORT2 *func_name##_) arg_list;\n#define ICUCOMPAT_I18N_FUNC(ret_type, func_name, arg_list)                     \\\n    ret_type(U_EXPORT2 *func_name##_) arg_list;\n\n#include \"icuprototype.h\"\n\n#undef ICUCOMPAT_UC_FUNC\n#undef ICUCOMPAT_I18N_FUNC\n} icu_compat_t;\nextern icu_compat_t __g_icucompat_iface__;\n\nint init_icucompat();\nvoid destroy_icucompat();\n\n#ifndef ICUCOMPAT_IMPL\n#define ICUCOMPAT_DEFINE_SYMBOL(symbol) (__g_icucompat_iface__.symbol##_)\n#include \"icuprototype.h\"\n#endif\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif\n"
  },
  {
    "path": "deprecated/android/addons/icucompat/icuprototype.h",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#ifndef ICUCOMPAT_UC_FUNC\n#define ICUCOMPAT_UC_FUNC(ret_type, func_name, arg_list)\n#endif\n\n#ifndef ICUCOMPAT_I18N_FUNC\n#define ICUCOMPAT_I18N_FUNC(ret_type, func_name, arg_list)\n#endif\n\n\n#ifdef ICUCOMPAT_DEFINE_SYMBOL\n\n/* uversion functions */\n#define u_getVersion ICUCOMPAT_DEFINE_SYMBOL(u_getVersion)\n\n/* uchar functions */\n#define u_isspace ICUCOMPAT_DEFINE_SYMBOL(u_isspace)\n\n/* ustring functions */\n#define u_strFoldCase ICUCOMPAT_DEFINE_SYMBOL(u_strFoldCase)\n#define u_strToUTF8 ICUCOMPAT_DEFINE_SYMBOL(u_strToUTF8)\n#define u_strtok_r ICUCOMPAT_DEFINE_SYMBOL(u_strtok_r)\n\n/* utf8 functions */\n#define utf8_nextCharSafeBody ICUCOMPAT_DEFINE_SYMBOL(utf8_nextCharSafeBody)\n\n/* ubrk functions */\n#define ubrk_open  ICUCOMPAT_DEFINE_SYMBOL(ubrk_open)\n#define ubrk_close ICUCOMPAT_DEFINE_SYMBOL(ubrk_close)\n#define ubrk_setText ICUCOMPAT_DEFINE_SYMBOL(ubrk_setText)\n#define ubrk_current ICUCOMPAT_DEFINE_SYMBOL(ubrk_current)\n#define ubrk_next ICUCOMPAT_DEFINE_SYMBOL(ubrk_next)\n#define ubrk_previous ICUCOMPAT_DEFINE_SYMBOL(ubrk_previous)\n#define ubrk_first ICUCOMPAT_DEFINE_SYMBOL(ubrk_first)\n#define ubrk_isBoundary ICUCOMPAT_DEFINE_SYMBOL(ubrk_isBoundary)\n#define ubrk_getRuleStatus ICUCOMPAT_DEFINE_SYMBOL(ubrk_getRuleStatus)\n\n/* unorm functions */\n#define unorm_normalize ICUCOMPAT_DEFINE_SYMBOL(unorm_normalize)\n\n/* ucnv functions */\n#define ucnv_fromUChars ICUCOMPAT_DEFINE_SYMBOL(ucnv_fromUChars)\n#define ucnv_toUChars ICUCOMPAT_DEFINE_SYMBOL(ucnv_toUChars)\n#define ucnv_openCCSID ICUCOMPAT_DEFINE_SYMBOL(ucnv_openCCSID)\n#define ucnv_close ICUCOMPAT_DEFINE_SYMBOL(ucnv_close)\n\n/* uiter functions */\n#define uiter_setUTF8 ICUCOMPAT_DEFINE_SYMBOL(uiter_setUTF8)\n\n/* ucol functions */\n#define ucol_strcoll ICUCOMPAT_DEFINE_SYMBOL(ucol_strcoll)\n#define ucol_strcollIter ICUCOMPAT_DEFINE_SYMBOL(ucol_strcollIter)\n#define ucol_getSortKey ICUCOMPAT_DEFINE_SYMBOL(ucol_getSortKey)\n#define ucol_open ICUCOMPAT_DEFINE_SYMBOL(ucol_open)\n#define ucol_setAttribute ICUCOMPAT_DEFINE_SYMBOL(ucol_setAttribute)\n#define ucol_getShortDefinitionString ICUCOMPAT_DEFINE_SYMBOL(ucol_getShortDefinitionString)\n\n#else\n\n/* uversion functions */\nICUCOMPAT_UC_FUNC(void, u_getVersion, (UVersionInfo versionArray))\n\n/* uchar functions */\nICUCOMPAT_UC_FUNC(UBool, u_isspace, (UChar32 c))\n\n/* ustring functions */\nICUCOMPAT_UC_FUNC(int32_t, u_strFoldCase, (UChar *dest, int32_t destCapacity, const UChar *src, int32_t srcLength, uint32_t options, UErrorCode *pErrorCode))\nICUCOMPAT_UC_FUNC(char *, u_strToUTF8, (char *dest, int32_t destCapacity, int32_t *pDestLength, const UChar *src, int32_t srcLength, UErrorCode *pErrorCode))\nICUCOMPAT_UC_FUNC(UChar *, u_strtok_r, (UChar *src, const UChar *delim, UChar **saveState))\n\n/* utf8 functions */\nICUCOMPAT_UC_FUNC(UChar32, utf8_nextCharSafeBody, (const uint8_t *s, int32_t *pi, int32_t length, UChar32 c, UBool strict))\n\n/* ubrk functions */\nICUCOMPAT_UC_FUNC(UBreakIterator *, ubrk_open, (UBreakIteratorType type, const char *locale, const UChar *text, int32_t textLength, UErrorCode *status))\nICUCOMPAT_UC_FUNC(void, ubrk_close, (UBreakIterator *bi))\nICUCOMPAT_UC_FUNC(void, ubrk_setText, (UBreakIterator* bi, const UChar* text, int32_t textLength, UErrorCode *status))\nICUCOMPAT_UC_FUNC(int32_t, ubrk_current, (const UBreakIterator *bi))\nICUCOMPAT_UC_FUNC(int32_t, ubrk_next, (UBreakIterator *bi))\nICUCOMPAT_UC_FUNC(int32_t, ubrk_previous, (UBreakIterator *bi))\nICUCOMPAT_UC_FUNC(int32_t, ubrk_first, (UBreakIterator *bi))\nICUCOMPAT_UC_FUNC(UBool, ubrk_isBoundary, (UBreakIterator *bi, int32_t offset))\nICUCOMPAT_UC_FUNC(int32_t, ubrk_getRuleStatus, (UBreakIterator *bi))\n\n/* unorm functions */\nICUCOMPAT_UC_FUNC(int32_t, unorm_normalize, (const UChar *source, int32_t sourceLength, UNormalizationMode mode, int32_t options, UChar *result, int32_t resultLength, UErrorCode *status))\n\n/* ucnv functions */\nICUCOMPAT_UC_FUNC(int32_t, ucnv_fromUChars, (UConverter *cnv, char *dest, int32_t destCapacity, const UChar *src, int32_t srcLength, UErrorCode *pErrorCode))\nICUCOMPAT_UC_FUNC(int32_t, ucnv_toUChars, (UConverter *cnv, UChar *dest, int32_t destCapacity, const char *src, int32_t srcLength, UErrorCode *pErrorCode))\nICUCOMPAT_UC_FUNC(UConverter *, ucnv_openCCSID, (int32_t codepage, UConverterPlatform platform, UErrorCode *err))\nICUCOMPAT_UC_FUNC(void, ucnv_close, (UConverter *converter))\n\n/* uiter functions */\nICUCOMPAT_UC_FUNC(void, uiter_setUTF8, (UCharIterator *iter, const char *s, int32_t length))\n\n/* ucol functions */\nICUCOMPAT_I18N_FUNC(UCollationResult, ucol_strcoll, (const UCollator *coll, const UChar *source, int32_t sourceLength, const UChar *target, int32_t targetLength))\nICUCOMPAT_I18N_FUNC(UCollationResult, ucol_strcollIter, (const UCollator *coll, UCharIterator *sIter, UCharIterator *tIter, UErrorCode *status))\nICUCOMPAT_I18N_FUNC(int32_t, ucol_getSortKey, (const UCollator *coll, const UChar *source, int32_t sourceLength, uint8_t *result, int32_t resultLength))\nICUCOMPAT_I18N_FUNC(UCollator*, ucol_open, (const char *loc, UErrorCode *status))\nICUCOMPAT_I18N_FUNC(void, ucol_setAttribute, (UCollator *coll, UColAttribute attr, UColAttributeValue value, UErrorCode *status))\nICUCOMPAT_I18N_FUNC(int32_t, ucol_getShortDefinitionString, (const UCollator *coll, const char *locale, char *buffer, int32_t capacity, UErrorCode *status))\n\n#endif"
  },
  {
    "path": "deprecated/android/addons/icucompat/unicode/alphaindex.h",
    "content": "/*\n*******************************************************************************\n*\n*   Copyright (C) 2011-2013 International Business Machines\n*   Corporation and others.  All Rights Reserved.\n*\n*******************************************************************************\n*/\n\n#ifndef INDEXCHARS_H\n#define INDEXCHARS_H\n\n#include \"unicode/utypes.h\"\n#include \"unicode/uobject.h\"\n#include \"unicode/locid.h\"\n\n\n#if !UCONFIG_NO_COLLATION && !UCONFIG_NO_NORMALIZATION\n\n/**\n * \\file\n * \\brief C++ API: Index Characters\n */\n\nU_CDECL_BEGIN\n\n/**\n * Constants for Alphabetic Index Label Types.\n * The form of these enum constants anticipates having a plain C API\n * for Alphabetic Indexes that will also use them.\n * @stable ICU 4.8\n */\ntypedef enum UAlphabeticIndexLabelType {\n    /**\n     *  Normal Label, typically the starting letter of the names\n     *  in the bucket with this label.\n     * @stable ICU 4.8\n     */\n    U_ALPHAINDEX_NORMAL    = 0,\n\n    /**\n     * Undeflow Label.  The bucket with this label contains names\n     * in scripts that sort before any of the bucket labels in this index.\n     * @stable ICU 4.8\n     */\n    U_ALPHAINDEX_UNDERFLOW = 1,\n\n    /**\n     * Inflow Label.  The bucket with this label contains names\n     * in scripts that sort between two of the bucket labels in this index.\n     * Inflow labels are created when an index contains normal labels for\n     * multiple scripts, and skips other scripts that sort between some of the\n     * included scripts.\n     * @stable ICU 4.8\n     */\n    U_ALPHAINDEX_INFLOW    = 2,\n\n    /**\n     * Overflow Label. Te bucket with this label contains names in scripts\n     * that sort after all of the bucket labels in this index.\n     * @stable ICU 4.8\n     */\n    U_ALPHAINDEX_OVERFLOW  = 3\n} UAlphabeticIndexLabelType;\n\n\nstruct UHashtable;\nU_CDECL_END\n\nU_NAMESPACE_BEGIN\n\n// Forward Declarations\n\nclass BucketList;\nclass Collator;\nclass RuleBasedCollator;\nclass StringEnumeration;\nclass UnicodeSet;\nclass UVector;\n\n/**\n * AlphabeticIndex supports the creation of a UI index appropriate for a given language.\n * It can support either direct use, or use with a client that doesn't support localized collation.\n * The following is an example of what an index might look like in a UI:\n * \n * <pre>\n *  <b>... A B C D E F G H I J K L M N O P Q R S T U V W X Y Z  ...</b>\n *\n *  <b>A</b>\n *     Addison\n *     Albertson\n *     Azensky\n *  <b>B</b>\n *     Baker\n *  ...\n * </pre>\n *\n * The class can generate a list of labels for use as a UI \"index\", that is, a list of\n * clickable characters (or character sequences) that allow the user to see a segment\n * (bucket) of a larger \"target\" list. That is, each label corresponds to a bucket in\n * the target list, where everything in the bucket is greater than or equal to the character\n * (according to the locale's collation). Strings can be added to the index;\n * they will be in sorted order in the right bucket.\n * <p>\n * The class also supports having buckets for strings before the first (underflow),\n * after the last (overflow), and between scripts (inflow). For example, if the index\n * is constructed with labels for Russian and English, Greek characters would fall\n * into an inflow bucket between the other two scripts.\n * <p>\n * The AlphabeticIndex class is not intended for public subclassing.\n *\n * <p><em>Note:</em> If you expect to have a lot of ASCII or Latin characters\n * as well as characters from the user's language,\n * then it is a good idea to call addLabels(Locale::getEnglish(), status).</p>\n *\n * <h2>Direct Use</h2>\n * <p>The following shows an example of building an index directly.\n *  The \"show...\" methods below are just to illustrate usage.\n *\n * <pre>\n * // Create a simple index.  \"Item\" is assumed to be an application\n * // defined type that the application's UI and other processing knows about,\n * //  and that has a name.\n *\n * UErrorCode status = U_ZERO_ERROR;\n * AlphabeticIndex index = new AlphabeticIndex(desiredLocale, status);\n * index->addLabels(additionalLocale, status);\n * for (Item *item in some source of Items ) {\n *     index->addRecord(item->name(), item, status);\n * }\n * ...\n * // Show index at top. We could skip or gray out empty buckets\n *\n * while (index->nextBucket(status)) {\n *     if (showAll || index->getBucketRecordCount() != 0) {\n *         showLabelAtTop(UI, index->getBucketLabel());\n *     }\n * }\n *  ...\n * // Show the buckets with their contents, skipping empty buckets\n *\n * index->resetBucketIterator(status);\n * while (index->nextBucket(status)) {\n *    if (index->getBucketRecordCount() != 0) {\n *        showLabelInList(UI, index->getBucketLabel());\n *        while (index->nextRecord(status)) {\n *            showIndexedItem(UI, static_cast<Item *>(index->getRecordData()))\n * </pre>\n *\n * The caller can build different UIs using this class.\n * For example, an index character could be omitted or grayed-out\n * if its bucket is empty. Small buckets could also be combined based on size, such as:\n *\n * <pre>\n * <b>... A-F G-N O-Z ...</b>\n * </pre>\n *\n * <h2>Client Support</h2>\n * <p>Callers can also use the AlphabeticIndex::ImmutableIndex, or the AlphabeticIndex itself,\n * to support sorting on a client that doesn't support AlphabeticIndex functionality.\n *\n * <p>The ImmutableIndex is both immutable and thread-safe.\n * The corresponding AlphabeticIndex methods are not thread-safe because\n * they \"lazily\" build the index buckets.\n * <ul>\n * <li>ImmutableIndex.getBucket(index) provides random access to all\n *     buckets and their labels and label types.\n * <li>The AlphabeticIndex bucket iterator or ImmutableIndex.getBucket(0..getBucketCount-1)\n *     can be used to get a list of the labels,\n *     such as \"...\", \"A\", \"B\",..., and send that list to the client.\n * <li>When the client has a new name, it sends that name to the server.\n * The server needs to call the following methods,\n * and communicate the bucketIndex and collationKey back to the client.\n *\n * <pre>\n * int32_t bucketIndex = index.getBucketIndex(name, status);\n * const UnicodeString &label = immutableIndex.getBucket(bucketIndex)->getLabel();  // optional\n * int32_t skLength = collator.getSortKey(name, sk, skCapacity);\n * </pre>\n *\n * <li>The client would put the name (and associated information) into its bucket for bucketIndex. The sort key sk is a\n * sequence of bytes that can be compared with a binary compare, and produce the right localized result.</li>\n * </ul>\n *\n * @stable ICU 4.8\n */\nclass U_I18N_API AlphabeticIndex: public UObject {\npublic:\n#ifdef U_HIDE_DRAFT_API\n    class Bucket;\n#else\n     /**\n      * An index \"bucket\" with a label string and type.\n      * It is referenced by getBucketIndex(),\n      * and returned by ImmutableIndex.getBucket().\n      *\n      * The Bucket class is not intended for public subclassing.\n      * @draft ICU 51\n      */\n     class U_I18N_API Bucket : public UObject {\n     public:\n        /**\n         * Destructor.\n         * @draft ICU 51\n         */\n        virtual ~Bucket();\n\n        /**\n         * Returns the label string.\n         *\n         * @return the label string for the bucket\n         * @draft ICU 51\n         */\n        const UnicodeString &getLabel() const { return label_; }\n        /**\n         * Returns whether this bucket is a normal, underflow, overflow, or inflow bucket.\n         *\n         * @return the bucket label type\n         * @draft ICU 51\n         */\n        UAlphabeticIndexLabelType getLabelType() const { return labelType_; }\n\n     private:\n        friend class AlphabeticIndex;\n        friend class BucketList;\n\n        UnicodeString label_;\n        UnicodeString lowerBoundary_;\n        UAlphabeticIndexLabelType labelType_;\n        Bucket *displayBucket_;\n        int32_t displayIndex_;\n        UVector *records_;  // Records are owned by the inputList_ vector.\n\n        Bucket(const UnicodeString &label,   // Parameter strings are copied.\n               const UnicodeString &lowerBoundary,\n               UAlphabeticIndexLabelType type);\n     };\n\n    /**\n     * Immutable, thread-safe version of AlphabeticIndex.\n     * This class provides thread-safe methods for bucketing,\n     * and random access to buckets and their properties,\n     * but does not offer adding records to the index.\n     *\n     * The ImmutableIndex class is not intended for public subclassing.\n     *\n     * @draft ICU 51\n     */\n    class U_I18N_API ImmutableIndex : public UObject {\n    public:\n        /**\n         * Destructor.\n         * @draft ICU 51\n         */\n        virtual ~ImmutableIndex();\n\n        /**\n         * Returns the number of index buckets and labels, including underflow/inflow/overflow.\n         *\n         * @return the number of index buckets\n         * @draft ICU 51\n         */\n        int32_t getBucketCount() const;\n\n        /**\n         * Finds the index bucket for the given name and returns the number of that bucket.\n         * Use getBucket() to get the bucket's properties.\n         *\n         * @param name the string to be sorted into an index bucket\n         * @return the bucket number for the name\n         * @draft ICU 51\n         */\n        int32_t getBucketIndex(const UnicodeString &name, UErrorCode &errorCode) const;\n\n        /**\n         * Returns the index-th bucket. Returns NULL if the index is out of range.\n         *\n         * @param index bucket number\n         * @return the index-th bucket\n         * @draft ICU 51\n         */\n        const Bucket *getBucket(int32_t index) const;\n\n    private:\n        friend class AlphabeticIndex;\n\n        ImmutableIndex(BucketList *bucketList, Collator *collatorPrimaryOnly)\n                : buckets_(bucketList), collatorPrimaryOnly_(collatorPrimaryOnly) {}\n\n        BucketList *buckets_;\n        Collator *collatorPrimaryOnly_;\n    };\n#endif  /* U_HIDE_DRAFT_API */\n\n    /**\n     * Construct an AlphabeticIndex object for the specified locale.  If the locale's\n     * data does not include index characters, a set of them will be\n     * synthesized based on the locale's exemplar characters.  The locale\n     * determines the sorting order for both the index characters and the\n     * user item names appearing under each Index character.\n     *\n     * @param locale the desired locale.\n     * @param status Error code, will be set with the reason if the construction\n     *               of the AlphabeticIndex object fails.\n     * @stable ICU 4.8\n     */\n     AlphabeticIndex(const Locale &locale, UErrorCode &status);\n\n#ifndef U_HIDE_DRAFT_API\n   /** \n     * Construct an AlphabeticIndex that uses a specific collator.\n     * \n     * The index will be created with no labels; the addLabels() function must be called\n     * after creation to add the desired labels to the index.\n     * \n     * The index adopts the collator, and is responsible for deleting it. \n     * The caller should make no further use of the collator after creating the index.\n     * \n     * @param collator The collator to use to order the contents of this index.\n     * @param status Error code, will be set with the reason if the \n     *               operation fails.\n     * @draft ICU 51\n     */\n    AlphabeticIndex(RuleBasedCollator *collator, UErrorCode &status);\n#endif  /* U_HIDE_DRAFT_API */\n\n    /**\n     * Add Labels to this Index.  The labels are additions to those\n     * that are already in the index; they do not replace the existing\n     * ones.\n     * @param additions The additional characters to add to the index, such as A-Z.\n     * @param status Error code, will be set with the reason if the \n     *               operation fails.\n     * @return this, for chaining\n     * @stable ICU 4.8\n     */\n    virtual AlphabeticIndex &addLabels(const UnicodeSet &additions, UErrorCode &status);\n\n    /**\n     * Add the index characters from a Locale to the index.  The labels\n     * are added to those that are already in the index; they do not replace the\n     * existing index characters.  The collation order for this index is not\n     * changed; it remains that of the locale that was originally specified\n     * when creating this Index.\n     *\n     * @param locale The locale whose index characters are to be added.\n     * @param status Error code, will be set with the reason if the \n     *               operation fails.\n     * @return this, for chaining\n     * @stable ICU 4.8\n     */\n    virtual AlphabeticIndex &addLabels(const Locale &locale, UErrorCode &status);\n\n     /**\n      * Destructor\n      * @stable ICU 4.8\n      */\n    virtual ~AlphabeticIndex();\n\n#ifndef U_HIDE_DRAFT_API\n    /**\n     * Builds an immutable, thread-safe version of this instance, without data records.\n     *\n     * @return an immutable index instance\n     * @draft ICU 51\n     */\n    ImmutableIndex *buildImmutableIndex(UErrorCode &errorCode);\n#endif  /* U_HIDE_DRAFT_API */\n\n    /**\n     * Get the Collator that establishes the ordering of the items in this index.\n     * Ownership of the collator remains with the AlphabeticIndex instance.\n     *\n     * The returned collator is a reference to the internal collator used by this\n     * index.  It may be safely used to compare the names of items or to get\n     * sort keys for names.  However if any settings need to be changed,\n     * or other non-const methods called, a cloned copy must be made first.\n     *\n     * @return The collator\n     * @stable ICU 4.8\n     */\n    virtual const RuleBasedCollator &getCollator() const;\n\n\n   /**\n     * Get the default label used for abbreviated buckets <i>between</i> other index characters.\n     * For example, consider the labels when Latin and Greek are used:\n     *     X Y Z ... &#x0391; &#x0392; &#x0393;.\n     *\n     * @return inflow label\n     * @stable ICU 4.8\n     */\n    virtual const UnicodeString &getInflowLabel() const;\n\n   /**\n     * Set the default label used for abbreviated buckets <i>between</i> other index characters.\n     * An inflow label will be automatically inserted if two otherwise-adjacent label characters\n     * are from different scripts, e.g. Latin and Cyrillic, and a third script, e.g. Greek,\n     * sorts between the two.  The default inflow character is an ellipsis (...)\n     *\n     * @param inflowLabel the new Inflow label.\n     * @param status Error code, will be set with the reason if the operation fails.\n     * @return this\n     * @stable ICU 4.8\n     */\n    virtual AlphabeticIndex &setInflowLabel(const UnicodeString &inflowLabel, UErrorCode &status);\n\n\n   /**\n     * Get the special label used for items that sort after the last normal label,\n     * and that would not otherwise have an appropriate label.\n     *\n     * @return the overflow label\n     * @stable ICU 4.8\n     */\n    virtual const UnicodeString &getOverflowLabel() const;\n\n\n   /**\n     * Set the label used for items that sort after the last normal label,\n     * and that would not otherwise have an appropriate label.\n     *\n     * @param overflowLabel the new overflow label.\n     * @param status Error code, will be set with the reason if the operation fails.\n     * @return this\n     * @stable ICU 4.8\n     */\n    virtual AlphabeticIndex &setOverflowLabel(const UnicodeString &overflowLabel, UErrorCode &status);\n\n   /**\n     * Get the special label used for items that sort before the first normal label,\n     * and that would not otherwise have an appropriate label.\n     *\n     * @return underflow label\n     * @stable ICU 4.8\n     */\n    virtual const UnicodeString &getUnderflowLabel() const;\n\n   /**\n     * Set the label used for items that sort before the first normal label,\n     * and that would not otherwise have an appropriate label.\n     *\n     * @param underflowLabel the new underflow label.\n     * @param status Error code, will be set with the reason if the operation fails.\n     * @return this\n     * @stable ICU 4.8\n     */\n    virtual AlphabeticIndex &setUnderflowLabel(const UnicodeString &underflowLabel, UErrorCode &status);\n\n\n    /**\n     * Get the limit on the number of labels permitted in the index.\n     * The number does not include over, under and inflow labels.\n     *\n     * @return maxLabelCount maximum number of labels.\n     * @stable ICU 4.8\n     */\n    virtual int32_t getMaxLabelCount() const;\n\n    /**\n     * Set a limit on the number of labels permitted in the index.\n     * The number does not include over, under and inflow labels.\n     * Currently, if the number is exceeded, then every\n     * nth item is removed to bring the count down.\n     * A more sophisticated mechanism may be available in the future.\n     *\n     * @param maxLabelCount the maximum number of labels.\n     * @param status error code\n     * @return This, for chaining\n     * @stable ICU 4.8\n     */\n    virtual AlphabeticIndex &setMaxLabelCount(int32_t maxLabelCount, UErrorCode &status);\n\n\n    /**\n     * Add a record to the index.  Each record will be associated with an index Bucket\n     *  based on the record's name.  The list of records for each bucket will be sorted\n     *  based on the collation ordering of the names in the index's locale.\n     *  Records with duplicate names are permitted; they will be kept in the order\n     *  that they were added.\n     *\n     * @param name The display name for the Record.  The Record will be placed in\n     *             a bucket based on this name.\n     * @param data An optional pointer to user data associated with this\n     *             item.  When iterating the contents of a bucket, both the\n     *             data pointer the name will be available for each Record.\n     * @param status  Error code, will be set with the reason if the operation fails.\n     * @return        This, for chaining.\n     * @stable ICU 4.8\n     */\n    virtual AlphabeticIndex &addRecord(const UnicodeString &name, const void *data, UErrorCode &status);\n\n    /**\n     * Remove all Records from the Index.  The set of Buckets, which define the headings under\n     * which records are classified, is not altered.\n     *\n     * @param status  Error code, will be set with the reason if the operation fails.\n     * @return        This, for chaining.\n     * @stable ICU 4.8\n     */\n    virtual AlphabeticIndex &clearRecords(UErrorCode &status);\n\n\n    /**  Get the number of labels in this index.\n     *      Note: may trigger lazy index construction.\n     *\n     * @param status  Error code, will be set with the reason if the operation fails.\n     * @return        The number of labels in this index, including any under, over or\n     *                in-flow labels.\n     * @stable ICU 4.8\n     */\n    virtual int32_t  getBucketCount(UErrorCode &status);\n\n\n    /**  Get the total number of Records in this index, that is, the number\n     *   of <name, data> pairs added.\n     *\n     * @param status  Error code, will be set with the reason if the operation fails.\n     * @return        The number of records in this index, that is, the total number\n     *                of (name, data) items added with addRecord().\n     * @stable ICU 4.8\n     */\n    virtual int32_t  getRecordCount(UErrorCode &status);\n\n\n\n    /**\n     *   Given the name of a record, return the zero-based index of the Bucket\n     *   in which the item should appear.  The name need not be in the index.\n     *   A Record will not be added to the index by this function.\n     *   Bucket numbers are zero-based, in Bucket iteration order.\n     *\n     * @param itemName  The name whose bucket position in the index is to be determined.\n     * @param status  Error code, will be set with the reason if the operation fails.\n     * @return The bucket number for this name.\n     * @stable ICU 4.8\n     *\n     */\n    virtual int32_t  getBucketIndex(const UnicodeString &itemName, UErrorCode &status);\n\n\n    /**\n     *   Get the zero based index of the current Bucket from an iteration\n     *   over the Buckets of this index.  Return -1 if no iteration is in process.\n     *   @return  the index of the current Bucket\n     *   @stable ICU 4.8\n     */\n    virtual int32_t  getBucketIndex() const;\n\n\n    /**\n     *   Advance the iteration over the Buckets of this index.  Return FALSE if\n     *   there are no more Buckets.\n     *\n     *   @param status  Error code, will be set with the reason if the operation fails.\n     *   U_ENUM_OUT_OF_SYNC_ERROR will be reported if the index is modified while\n     *   an enumeration of its contents are in process.\n     *\n     *   @return TRUE if success, FALSE if at end of iteration\n     *   @stable ICU 4.8\n     */\n    virtual UBool nextBucket(UErrorCode &status);\n\n    /**\n     *   Return the name of the Label of the current bucket from an iteration over the buckets.\n     *   If the iteration is before the first Bucket (nextBucket() has not been called),\n     *   or after the last, return an empty string.\n     *\n     *   @return the bucket label.\n     *   @stable ICU 4.8\n     */\n    virtual const UnicodeString &getBucketLabel() const;\n\n    /**\n     *  Return the type of the label for the current Bucket (selected by the\n     *  iteration over Buckets.)\n     *\n     * @return the label type.\n     * @stable ICU 4.8\n     */\n    virtual UAlphabeticIndexLabelType getBucketLabelType() const;\n\n    /**\n      * Get the number of <name, data> Records in the current Bucket.\n      * If the current bucket iteration position is before the first label or after the\n      * last, return 0.\n      *\n      *  @return the number of Records.\n      *  @stable ICU 4.8\n      */\n    virtual int32_t getBucketRecordCount() const;\n\n\n    /**\n     *  Reset the Bucket iteration for this index.  The next call to nextBucket()\n     *  will restart the iteration at the first label.\n     *\n     * @param status  Error code, will be set with the reason if the operation fails.\n     * @return        this, for chaining.\n     * @stable ICU 4.8\n     */\n    virtual AlphabeticIndex &resetBucketIterator(UErrorCode &status);\n\n    /**\n     * Advance to the next record in the current Bucket.\n     * When nextBucket() is called, Record iteration is reset to just before the\n     * first Record in the new Bucket.\n     *\n     *   @param status  Error code, will be set with the reason if the operation fails.\n     *   U_ENUM_OUT_OF_SYNC_ERROR will be reported if the index is modified while\n     *   an enumeration of its contents are in process.\n     *   @return TRUE if successful, FALSE when the iteration advances past the last item.\n     *   @stable ICU 4.8\n     */\n    virtual UBool nextRecord(UErrorCode &status);\n\n    /**\n     * Get the name of the current Record.\n     * Return an empty string if the Record iteration position is before first\n     * or after the last.\n     *\n     *  @return The name of the current index item.\n     *  @stable ICU 4.8\n     */\n    virtual const UnicodeString &getRecordName() const;\n\n\n    /**\n     * Return the data pointer of the Record currently being iterated over.\n     * Return NULL if the current iteration position before the first item in this Bucket,\n     * or after the last.\n     *\n     *  @return The current Record's data pointer.\n     *  @stable ICU 4.8\n     */\n    virtual const void *getRecordData() const;\n\n\n    /**\n     * Reset the Record iterator position to before the first Record in the current Bucket.\n     *\n     *  @return This, for chaining.\n     *  @stable ICU 4.8\n     */\n    virtual AlphabeticIndex &resetRecordIterator();\n\nprivate:\n     /**\n      * No Copy constructor.\n      * @internal\n      */\n     AlphabeticIndex(const AlphabeticIndex &other);\n\n     /**\n      *   No assignment.\n      */\n     AlphabeticIndex &operator =(const AlphabeticIndex & /*other*/) { return *this;};\n\n    /**\n     * No Equality operators.\n     * @internal\n     */\n     virtual UBool operator==(const AlphabeticIndex& other) const;\n\n    /**\n     * Inequality operator.\n     * @internal\n     */\n     virtual UBool operator!=(const AlphabeticIndex& other) const;\n\n     // Common initialization, for use from all constructors.\n     void init(const Locale *locale, UErrorCode &status);\n\n    /**\n     * This method is called to get the index exemplars. Normally these come from the locale directly,\n     * but if they aren't available, we have to synthesize them.\n     */\n    void addIndexExemplars(const Locale &locale, UErrorCode &status);\n    /**\n     * Add Chinese index characters from the tailoring.\n     */\n    UBool addChineseIndexCharacters(UErrorCode &errorCode);\n\n    UVector *firstStringsInScript(UErrorCode &status);\n\n    static UnicodeString separated(const UnicodeString &item);\n\n    /**\n     * Determine the best labels to use.\n     * This is based on the exemplars, but we also process to make sure that they are unique,\n     * and sort differently, and that the overall list is small enough.\n     */\n    void initLabels(UVector &indexCharacters, UErrorCode &errorCode) const;\n    BucketList *createBucketList(UErrorCode &errorCode) const;\n    void initBuckets(UErrorCode &errorCode);\n    void clearBuckets();\n    void internalResetBucketIterator();\n\npublic:\n\n    //  The Record is declared public only to allow access from\n    //  implementation code written in plain C.\n    //  It is not intended for public use.\n\n#ifndef U_HIDE_INTERNAL_API\n    /**\n     * A (name, data) pair, to be sorted by name into one of the index buckets.\n     * The user data is not used by the index implementation.\n     * @internal\n     */\n    struct Record: public UMemory {\n        const UnicodeString  name_;\n        const void           *data_;\n        Record(const UnicodeString &name, const void *data);\n        ~Record();\n    };\n#endif  /* U_HIDE_INTERNAL_API */\n\nprivate:\n\n    /**\n     * Holds all user records before they are distributed into buckets.\n     * Type of contents is (Record *)\n     * @internal\n     */\n    UVector  *inputList_;\n\n    int32_t  labelsIterIndex_;        // Index of next item to return.\n    int32_t  itemsIterIndex_;\n    Bucket   *currentBucket_;         // While an iteration of the index in underway,\n                                      //   point to the bucket for the current label.\n                                      // NULL when no iteration underway.\n\n    int32_t    maxLabelCount_;        // Limit on # of labels permitted in the index.\n\n    UnicodeSet *initialLabels_;       // Initial (unprocessed) set of Labels.  Union\n                                      //   of those explicitly set by the user plus\n                                      //   those from locales.  Raw values, before\n                                      //   crunching into bucket labels.\n\n    UVector *firstCharsInScripts_;    // The first character from each script,\n                                      //   in collation order.\n\n    RuleBasedCollator *collator_;\n    RuleBasedCollator *collatorPrimaryOnly_;\n\n    // Lazy evaluated: null means that we have not built yet.\n    BucketList *buckets_;\n\n    UnicodeString  inflowLabel_;\n    UnicodeString  overflowLabel_;\n    UnicodeString  underflowLabel_;\n    UnicodeString  overflowComparisonString_;\n\n    UnicodeString emptyString_;\n};\n\nU_NAMESPACE_END\n\n#endif /* UCONFIG_NO_COLLATION / UCONFIG_NO_NORMALIZATION */\n#endif\n"
  },
  {
    "path": "deprecated/android/addons/icucompat/unicode/appendable.h",
    "content": "/*\n*******************************************************************************\n*   Copyright (C) 2011-2012, International Business Machines\n*   Corporation and others.  All Rights Reserved.\n*******************************************************************************\n*   file name:  appendable.h\n*   encoding:   US-ASCII\n*   tab size:   8 (not used)\n*   indentation:4\n*\n*   created on: 2010dec07\n*   created by: Markus W. Scherer\n*/\n\n#ifndef __APPENDABLE_H__\n#define __APPENDABLE_H__\n\n/**\n * \\file\n * \\brief C++ API: Appendable class: Sink for Unicode code points and 16-bit code units (UChars).\n */\n\n#include \"unicode/utypes.h\"\n#include \"unicode/uobject.h\"\n\nU_NAMESPACE_BEGIN\n\nclass UnicodeString;\n\n/**\n * Base class for objects to which Unicode characters and strings can be appended.\n * Combines elements of Java Appendable and ICU4C ByteSink.\n *\n * This class can be used in APIs where it does not matter whether the actual destination is\n * a UnicodeString, a UChar[] array, a UnicodeSet, or any other object\n * that receives and processes characters and/or strings.\n *\n * Implementation classes must implement at least appendCodeUnit(UChar).\n * The base class provides default implementations for the other methods.\n *\n * The methods do not take UErrorCode parameters.\n * If an error occurs (e.g., out-of-memory),\n * in addition to returning FALSE from failing operations,\n * the implementation must prevent unexpected behavior (e.g., crashes)\n * from further calls and should make the error condition available separately\n * (e.g., store a UErrorCode, make/keep a UnicodeString bogus).\n * @stable ICU 4.8\n */\nclass U_COMMON_API Appendable : public UObject {\npublic:\n    /**\n     * Destructor.\n     * @stable ICU 4.8\n     */\n    ~Appendable();\n\n    /**\n     * Appends a 16-bit code unit.\n     * @param c code unit\n     * @return TRUE if the operation succeeded\n     * @stable ICU 4.8\n     */\n    virtual UBool appendCodeUnit(UChar c) = 0;\n\n    /**\n     * Appends a code point.\n     * The default implementation calls appendCodeUnit(UChar) once or twice.\n     * @param c code point 0..0x10ffff\n     * @return TRUE if the operation succeeded\n     * @stable ICU 4.8\n     */\n    virtual UBool appendCodePoint(UChar32 c);\n\n    /**\n     * Appends a string.\n     * The default implementation calls appendCodeUnit(UChar) for each code unit.\n     * @param s string, must not be NULL if length!=0\n     * @param length string length, or -1 if NUL-terminated\n     * @return TRUE if the operation succeeded\n     * @stable ICU 4.8\n     */\n    virtual UBool appendString(const UChar *s, int32_t length);\n\n    /**\n     * Tells the object that the caller is going to append roughly\n     * appendCapacity UChars. A subclass might use this to pre-allocate\n     * a larger buffer if necessary.\n     * The default implementation does nothing. (It always returns TRUE.)\n     * @param appendCapacity estimated number of UChars that will be appended\n     * @return TRUE if the operation succeeded\n     * @stable ICU 4.8\n     */\n    virtual UBool reserveAppendCapacity(int32_t appendCapacity);\n\n    /**\n     * Returns a writable buffer for appending and writes the buffer's capacity to\n     * *resultCapacity. Guarantees *resultCapacity>=minCapacity.\n     * May return a pointer to the caller-owned scratch buffer which must have\n     * scratchCapacity>=minCapacity.\n     * The returned buffer is only valid until the next operation\n     * on this Appendable.\n     *\n     * After writing at most *resultCapacity UChars, call appendString() with the\n     * pointer returned from this function and the number of UChars written.\n     * Many appendString() implementations will avoid copying UChars if this function\n     * returned an internal buffer.\n     *\n     * Partial usage example:\n     * \\code\n     *  int32_t capacity;\n     *  UChar* buffer = app.getAppendBuffer(..., &capacity);\n     *  ... Write n UChars into buffer, with n <= capacity.\n     *  app.appendString(buffer, n);\n     * \\endcode\n     * In many implementations, that call to append will avoid copying UChars.\n     *\n     * If the Appendable allocates or reallocates an internal buffer, it should use\n     * the desiredCapacityHint if appropriate.\n     * If a caller cannot provide a reasonable guess at the desired capacity,\n     * it should pass desiredCapacityHint=0.\n     *\n     * If a non-scratch buffer is returned, the caller may only pass\n     * a prefix to it to appendString().\n     * That is, it is not correct to pass an interior pointer to appendString().\n     *\n     * The default implementation always returns the scratch buffer.\n     *\n     * @param minCapacity required minimum capacity of the returned buffer;\n     *                    must be non-negative\n     * @param desiredCapacityHint desired capacity of the returned buffer;\n     *                            must be non-negative\n     * @param scratch default caller-owned buffer\n     * @param scratchCapacity capacity of the scratch buffer\n     * @param resultCapacity pointer to an integer which will be set to the\n     *                       capacity of the returned buffer\n     * @return a buffer with *resultCapacity>=minCapacity\n     * @stable ICU 4.8\n     */\n    virtual UChar *getAppendBuffer(int32_t minCapacity,\n                                   int32_t desiredCapacityHint,\n                                   UChar *scratch, int32_t scratchCapacity,\n                                   int32_t *resultCapacity);\n\nprivate:\n    // No ICU \"poor man's RTTI\" for this class nor its subclasses.\n    virtual UClassID getDynamicClassID() const;\n};\n\n/**\n * An Appendable implementation which writes to a UnicodeString.\n *\n * This class is not intended for public subclassing.\n * @stable ICU 4.8\n */\nclass U_COMMON_API UnicodeStringAppendable : public Appendable {\npublic:\n    /**\n     * Aliases the UnicodeString (keeps its reference) for writing.\n     * @param s The UnicodeString to which this Appendable will write.\n     * @stable ICU 4.8\n     */\n    explicit UnicodeStringAppendable(UnicodeString &s) : str(s) {}\n\n    /**\n     * Destructor.\n     * @stable ICU 4.8\n     */\n    ~UnicodeStringAppendable();\n\n    /**\n     * Appends a 16-bit code unit to the string.\n     * @param c code unit\n     * @return TRUE if the operation succeeded\n     * @stable ICU 4.8\n     */\n    virtual UBool appendCodeUnit(UChar c);\n\n    /**\n     * Appends a code point to the string.\n     * @param c code point 0..0x10ffff\n     * @return TRUE if the operation succeeded\n     * @stable ICU 4.8\n     */\n    virtual UBool appendCodePoint(UChar32 c);\n\n    /**\n     * Appends a string to the UnicodeString.\n     * @param s string, must not be NULL if length!=0\n     * @param length string length, or -1 if NUL-terminated\n     * @return TRUE if the operation succeeded\n     * @stable ICU 4.8\n     */\n    virtual UBool appendString(const UChar *s, int32_t length);\n\n    /**\n     * Tells the UnicodeString that the caller is going to append roughly\n     * appendCapacity UChars.\n     * @param appendCapacity estimated number of UChars that will be appended\n     * @return TRUE if the operation succeeded\n     * @stable ICU 4.8\n     */\n    virtual UBool reserveAppendCapacity(int32_t appendCapacity);\n\n    /**\n     * Returns a writable buffer for appending and writes the buffer's capacity to\n     * *resultCapacity. Guarantees *resultCapacity>=minCapacity.\n     * May return a pointer to the caller-owned scratch buffer which must have\n     * scratchCapacity>=minCapacity.\n     * The returned buffer is only valid until the next write operation\n     * on the UnicodeString.\n     *\n     * For details see Appendable::getAppendBuffer().\n     *\n     * @param minCapacity required minimum capacity of the returned buffer;\n     *                    must be non-negative\n     * @param desiredCapacityHint desired capacity of the returned buffer;\n     *                            must be non-negative\n     * @param scratch default caller-owned buffer\n     * @param scratchCapacity capacity of the scratch buffer\n     * @param resultCapacity pointer to an integer which will be set to the\n     *                       capacity of the returned buffer\n     * @return a buffer with *resultCapacity>=minCapacity\n     * @stable ICU 4.8\n     */\n    virtual UChar *getAppendBuffer(int32_t minCapacity,\n                                   int32_t desiredCapacityHint,\n                                   UChar *scratch, int32_t scratchCapacity,\n                                   int32_t *resultCapacity);\n\nprivate:\n    UnicodeString &str;\n};\n\nU_NAMESPACE_END\n\n#endif  // __APPENDABLE_H__\n"
  },
  {
    "path": "deprecated/android/addons/icucompat/unicode/basictz.h",
    "content": "/*\n*******************************************************************************\n* Copyright (C) 2007-2011, International Business Machines Corporation and\n* others. All Rights Reserved.\n*******************************************************************************\n*/\n#ifndef BASICTZ_H\n#define BASICTZ_H\n\n/**\n * \\file \n * \\brief C++ API: ICU TimeZone base class\n */\n\n#include \"unicode/utypes.h\"\n\n#if !UCONFIG_NO_FORMATTING\n\n#include \"unicode/timezone.h\"\n#include \"unicode/tzrule.h\"\n#include \"unicode/tztrans.h\"\n\nU_NAMESPACE_BEGIN\n\n// forward declarations\nclass UVector;\n\n/**\n * <code>BasicTimeZone</code> is an abstract class extending <code>TimeZone</code>.\n * This class provides some additional methods to access time zone transitions and rules.\n * All ICU <code>TimeZone</code> concrete subclasses extend this class.\n * @stable ICU 3.8\n */\nclass U_I18N_API BasicTimeZone: public TimeZone {\npublic:\n    /**\n     * Destructor.\n     * @stable ICU 3.8\n     */\n    virtual ~BasicTimeZone();\n\n    /**\n     * Gets the first time zone transition after the base time.\n     * @param base      The base time.\n     * @param inclusive Whether the base time is inclusive or not.\n     * @param result    Receives the first transition after the base time.\n     * @return  TRUE if the transition is found.\n     * @stable ICU 3.8\n     */\n    virtual UBool getNextTransition(UDate base, UBool inclusive, TimeZoneTransition& result) /*const*/ = 0;\n\n    /**\n     * Gets the most recent time zone transition before the base time.\n     * @param base      The base time.\n     * @param inclusive Whether the base time is inclusive or not.\n     * @param result    Receives the most recent transition before the base time.\n     * @return  TRUE if the transition is found.\n     * @stable ICU 3.8\n     */\n    virtual UBool getPreviousTransition(UDate base, UBool inclusive, TimeZoneTransition& result) /*const*/ = 0;\n\n    /**\n     * Checks if the time zone has equivalent transitions in the time range.\n     * This method returns true when all of transition times, from/to standard\n     * offsets and DST savings used by this time zone match the other in the\n     * time range.\n     * @param tz    The <code>BasicTimeZone</code> object to be compared with.\n     * @param start The start time of the evaluated time range (inclusive)\n     * @param end   The end time of the evaluated time range (inclusive)\n     * @param ignoreDstAmount\n     *              When true, any transitions with only daylight saving amount\n     *              changes will be ignored, except either of them is zero.\n     *              For example, a transition from rawoffset 3:00/dstsavings 1:00\n     *              to rawoffset 2:00/dstsavings 2:00 is excluded from the comparison,\n     *              but a transtion from rawoffset 2:00/dstsavings 1:00 to\n     *              rawoffset 3:00/dstsavings 0:00 is included.\n     * @param ec    Output param to filled in with a success or an error.\n     * @return      true if the other time zone has the equivalent transitions in the\n     *              time range.\n     * @stable ICU 3.8\n     */\n    virtual UBool hasEquivalentTransitions(/*const*/ BasicTimeZone& tz, UDate start, UDate end,\n        UBool ignoreDstAmount, UErrorCode& ec) /*const*/;\n\n    /**\n     * Returns the number of <code>TimeZoneRule</code>s which represents time transitions,\n     * for this time zone, that is, all <code>TimeZoneRule</code>s for this time zone except\n     * <code>InitialTimeZoneRule</code>.  The return value range is 0 or any positive value.\n     * @param status    Receives error status code.\n     * @return The number of <code>TimeZoneRule</code>s representing time transitions.\n     * @stable ICU 3.8\n     */\n    virtual int32_t countTransitionRules(UErrorCode& status) /*const*/ = 0;\n\n    /**\n     * Gets the <code>InitialTimeZoneRule</code> and the set of <code>TimeZoneRule</code>\n     * which represent time transitions for this time zone.  On successful return,\n     * the argument initial points to non-NULL <code>InitialTimeZoneRule</code> and\n     * the array trsrules is filled with 0 or multiple <code>TimeZoneRule</code>\n     * instances up to the size specified by trscount.  The results are referencing the\n     * rule instance held by this time zone instance.  Therefore, after this time zone\n     * is destructed, they are no longer available.\n     * @param initial       Receives the initial timezone rule\n     * @param trsrules      Receives the timezone transition rules\n     * @param trscount      On input, specify the size of the array 'transitions' receiving\n     *                      the timezone transition rules.  On output, actual number of\n     *                      rules filled in the array will be set.\n     * @param status        Receives error status code.\n     * @stable ICU 3.8\n     */\n    virtual void getTimeZoneRules(const InitialTimeZoneRule*& initial,\n        const TimeZoneRule* trsrules[], int32_t& trscount, UErrorCode& status) /*const*/ = 0;\n\n    /**\n     * Gets the set of time zone rules valid at the specified time.  Some known external time zone\n     * implementations are not capable to handle historic time zone rule changes.  Also some\n     * implementations can only handle certain type of rule definitions.\n     * If this time zone does not use any daylight saving time within about 1 year from the specified\n     * time, only the <code>InitialTimeZone</code> is returned.  Otherwise, the rule for standard\n     * time and daylight saving time transitions are returned in addition to the\n     * <code>InitialTimeZoneRule</code>.  The standard and daylight saving time transition rules are\n     * represented by <code>AnnualTimeZoneRule</code> with <code>DateTimeRule::DOW</code> for its date\n     * rule and <code>DateTimeRule::WALL_TIME</code> for its time rule.  Because daylight saving time\n     * rule is changing time to time in many time zones and also mapping a transition time rule to\n     * different type is lossy transformation, the set of rules returned by this method may be valid\n     * for short period of time.\n     * The time zone rule objects returned by this method is owned by the caller, so the caller is\n     * responsible for deleting them after use.\n     * @param date      The date used for extracting time zone rules.\n     * @param initial   Receives the <code>InitialTimeZone</code>, always not NULL.\n     * @param std       Receives the <code>AnnualTimeZoneRule</code> for standard time transitions.\n     *                  When this time time zone does not observe daylight saving times around the\n     *                  specified date, NULL is set.\n     * @param dst       Receives the <code>AnnualTimeZoneRule</code> for daylight saving time\n     *                  transitions.  When this time zone does not observer daylight saving times\n     *                  around the specified date, NULL is set.\n     * @param status    Receives error status code.\n     * @stable ICU 3.8\n     */\n    virtual void getSimpleRulesNear(UDate date, InitialTimeZoneRule*& initial,\n        AnnualTimeZoneRule*& std, AnnualTimeZoneRule*& dst, UErrorCode& status) /*const*/;\n\n\n#ifndef U_HIDE_INTERNAL_API\n    /**\n     * The time type option bit flags used by getOffsetFromLocal\n     * @internal\n     */\n    enum {\n        kStandard = 0x01,\n        kDaylight = 0x03,\n        kFormer = 0x04,\n        kLatter = 0x0C\n    };\n#endif  /* U_HIDE_INTERNAL_API */\n\n    /**\n     * Get time zone offsets from local wall time.\n     * @internal\n     */\n    virtual void getOffsetFromLocal(UDate date, int32_t nonExistingTimeOpt, int32_t duplicatedTimeOpt,\n        int32_t& rawOffset, int32_t& dstOffset, UErrorCode& status) /*const*/;\n\nprotected:\n\n#ifndef U_HIDE_INTERNAL_API\n    /**\n     * The time type option bit masks used by getOffsetFromLocal\n     * @internal\n     */\n    enum {\n        kStdDstMask = kDaylight,\n        kFormerLatterMask = kLatter\n    };\n#endif  /* U_HIDE_INTERNAL_API */\n\n    /**\n     * Default constructor.\n     * @stable ICU 3.8\n     */\n    BasicTimeZone();\n\n    /**\n     * Construct a timezone with a given ID.\n     * @param id a system time zone ID\n     * @stable ICU 3.8\n     */\n    BasicTimeZone(const UnicodeString &id);\n\n    /**\n     * Copy constructor.\n     * @param source the object to be copied.\n     * @stable ICU 3.8\n     */\n    BasicTimeZone(const BasicTimeZone& source);\n\n    /**\n     * Gets the set of TimeZoneRule instances applicable to the specified time and after.\n     * @param start     The start date used for extracting time zone rules\n     * @param initial   Receives the InitialTimeZone, always not NULL\n     * @param transitionRules   Receives the transition rules, could be NULL\n     * @param status    Receives error status code\n     */\n    void getTimeZoneRulesAfter(UDate start, InitialTimeZoneRule*& initial, UVector*& transitionRules,\n        UErrorCode& status) /*const*/;\n};\n\nU_NAMESPACE_END\n\n#endif /* #if !UCONFIG_NO_FORMATTING */\n\n#endif // BASICTZ_H\n\n//eof\n"
  },
  {
    "path": "deprecated/android/addons/icucompat/unicode/bms.h",
    "content": "/*\n * Copyright (C) 1996-2012, International Business Machines Corporation and Others.\n * All rights reserved.\n */\n\n/**\n * \\file \n * \\brief C API: Boyer-Moore StringSearch prototype.\n * \\internal\n */\n\n#ifndef _BMS_H\n#define _BMS_H\n\n#include \"unicode/utypes.h\"\n\n#if !UCONFIG_NO_COLLATION && !UCONFIG_NO_BREAK_ITERATION\n\n#include \"unicode/ucol.h\"\n\n#ifndef U_HIDE_INTERNAL_API\n\n/**\n * A <code>UCD</code> object holds the Collator-specific data needed to\n * compute the length of the shortest string that can\n * generate a partcular list of CEs.\n *\n * <code>UCD</code> objects are quite expensive to compute. Because\n * of this, they are cached. When you call <code>ucd_open</code> it\n * returns a reference counted cached object. When you call <code>ucd_close</code>\n * the reference count on the object is decremented but the object is not deleted.\n *\n * If you do not need to reuse any unreferenced objects in the cache, you can call\n * <code>ucd_flushCCache</code>. If you no longer need any <code>UCD</code>\n * objects, you can call <code>ucd_freeCache</code>\n *\n * @internal ICU 4.0.1 technology preview\n */\ntypedef void UCD;\n\n/**\n * Open a <code>UCD</code> object.\n *\n * @param coll - the collator\n * @param status - will be set if any errors occur. \n *\n * @return the <code>UCD</code> object. You must call\n *         <code>ucd_close</code> when you are done using the object.\n *\n * Note: if on return status is set to an error, the only safe\n * thing to do with the returned object is to call <code>ucd_close</code>.\n *\n * @internal ICU 4.0.1 technology preview\n */\nU_INTERNAL UCD * U_EXPORT2\nucd_open(UCollator *coll, UErrorCode *status);\n\n/**\n * Release a <code>UCD</code> object.\n *\n * @param ucd - the object\n *\n * @internal ICU 4.0.1 technology preview\n */\nU_INTERNAL void U_EXPORT2\nucd_close(UCD *ucd);\n\n/**\n * Get the <code>UCollator</code> object used to create a <code>UCD</code> object.\n * The <code>UCollator</code> object returned may not be the exact\n * object that was used to create this object, but it will have the\n * same behavior.\n *\n * @param ucd - the <code>UCD</code> object\n *\n * @return the <code>UCollator</code> used to create the given\n *         <code>UCD</code> object.\n *\n * @internal ICU 4.0.1 technology preview\n */\nU_INTERNAL UCollator * U_EXPORT2\nucd_getCollator(UCD *ucd);\n\n/**\n * <code>UCD</code> objects are expensive to compute, and so\n * may be cached. This routine will free the cached objects and delete\n * the cache.\n *\n * WARNING: Don't call this until you are have called <code>close</code>\n * for each <code>UCD</code> object that you have used. also,\n * DO NOT call this if another thread may be calling <code>ucd_flushCache</code>\n * at the same time.\n *\n * @internal ICU 4.0.1 technology preview\n */\nU_INTERNAL void U_EXPORT2\nucd_freeCache();\n\n/**\n * <code>UCD</code> objects are expensive to compute, and so\n * may be cached. This routine will remove any unused <code>UCD</code>\n * objects from the cache.\n *\n * @internal 4.0.1 technology preview\n */\nU_INTERNAL void U_EXPORT2\nucd_flushCache();\n\n/**\n * BMS\n *\n * This object holds the information needed to do a Collation sensitive Boyer-Moore search. It encapulates\n * the pattern, the \"bad character\" and \"good suffix\" tables, the Collator-based data needed to compute them,\n * and a reference to the text being searched.\n *\n * To do a search, you first need to get a <code>UCD</code> object by calling <code>ucd_open</code>.\n * Then you construct a <code>BMS</code> object from the <code>UCD</code> object, the pattern\n * string and the target string. Then you call the <code>search</code> method. Here's a code sample:\n *\n * <pre>\n * void boyerMooreExample(UCollator *collator, UChar *pattern, int32_t patternLen, UChar *target, int32_t targetLength)\n * {\n *     UErrorCode status = U_ZERO_ERROR;\n *     int32_t offset = 0, start = -1, end = -1;\n *     UCD *ucd = NULL);\n *     BMS *bms = NULL;\n *\n *     ucd = ucd_open(collator, &status);\n *     if (U_FAILURE(status)) {\n *         // could not create a UCD object\n *         return;\n *     }\n *\n *     BMS *bms = bms_open(ucd, pattern, patternLength, target, targetlength, &status);\n *     if (U_FAILURE(status)) {\n *         // could not create a BMS object\n *         ucd_close(ucd);\n *         return;\n *     }\n *\n *\n *     // Find all matches\n *     while (bms_search(bms, offset, &start, &end)) {\n *         // process the match between start and end\n *         ...\n *\n *         // advance past the match\n *         offset = end; \n *     }\n *\n *     // at this point, if offset == 0, there were no matches\n *     if (offset == 0) {\n *         // handle the case of no matches\n *     }\n *\n *     bms_close(bms);\n *     ucd_close(ucd);\n *\n *     // UCD objects are cached, so the call to\n *     // ucd_close doesn't delete the object.\n *     // Call this if you don't need the object any more.\n *     ucd_flushCache();\n * }\n * </pre>\n *\n * NOTE: This is a technology preview. The final version of this API may not bear any resenblence to this API.\n *\n * Knows linitations:\n *   1) Backwards searching has not been implemented.\n *\n *   2) For Han and Hangul characters, this code ignores any Collation tailorings. In general,\n *      this isn't a problem, but in Korean locals, at strength 1, Hangul characters are tailored\n *      to be equal to Han characters with the same pronounciation. Because this code ignroes\n *      tailorings, searching for a Hangul character will not find a Han character and visa-versa.\n *\n *   3) In some cases, searching for a pattern that needs to be normalized and ends\n *      in a discontiguous contraction may fail. The only known cases of this are with\n *      the Tibetan script. For example searching for the pattern\n *      \"\\u0F7F\\u0F80\\u0F81\\u0F82\\u0F83\\u0F84\\u0F85\" will fail. (This case is artificial. We've\n *      been unable to find a pratical, real-world example of this failure.)  \n *\n * NOTE: This is a technology preview. The final version of this API may not bear any resenblence to this API.\n *\n * @internal ICU 4.0.1 technology preview\n */\nstruct BMS;\ntypedef struct BMS BMS; /**< @see BMS */\n\n/**\n * Construct a <code>MBS</code> object.\n *\n * @param ucd - A <code>UCD</code> object holding the Collator-sensitive data\n * @param pattern - the string for which to search\n * @param patternLength - the length of the string for which to search\n * @param target - the string in which to search\n * @param targetLength - the length of the string in which to search\n * @param status - will be set if any errors occur. \n *\n * @return the <code>BMS</code> object.\n *\n * Note: if on return status is set to an error, the only safe\n * thing to do with the returned object is to call\n * <code>bms_close</code>.\n *\n * @internal ICU 4.0.1 technology preview\n */\nU_INTERNAL BMS * U_EXPORT2\nbms_open(UCD *ucd,\n         const UChar *pattern, int32_t patternLength,\n         const UChar *target,  int32_t targetLength,\n         UErrorCode  *status);\n\n/**\n * Close a <code>BMS</code> object and release all the\n * storage associated with it.\n *\n * @param bms - the <code>BMS</code> object to close.\n * @internal ICU 4.0.1 technology preview\n */\nU_INTERNAL void U_EXPORT2\nbms_close(BMS *bms);\n\n/**\n * Test the pattern to see if it generates any CEs.\n *\n * @param bms - the <code>BMS</code> object\n * @return <code>TRUE</code> if the pattern string did not generate any CEs\n *\n * @internal ICU 4.0.1 technology preview\n */\nU_INTERNAL UBool U_EXPORT2\nbms_empty(BMS *bms);\n\n/**\n * Get the <code>UCD</code> object used to create\n * a given <code>BMS</code> object.\n *\n * @param bms - the <code>BMS</code> object\n *\n * @return - the <code>UCD</code> object used to create\n *           the given <code>BMS</code> object.\n *\n * @internal ICU 4.0.1 technology preview\n */\nU_INTERNAL UCD * U_EXPORT2\nbms_getData(BMS *bms);\n\n/**\n * Search for the pattern string in the target string.\n *\n * @param bms - the <code>BMS</code> object\n * @param offset - the offset in the target string at which to begin the search\n * @param start - will be set to the starting offset of the match, or -1 if there's no match\n * @param end - will be set to the ending offset of the match, or -1 if there's no match\n *\n * @return <code>TRUE</code> if the match succeeds, <code>FALSE</code> otherwise.\n *\n * @internal ICU 4.0.1 technology preview\n */\nU_INTERNAL UBool U_EXPORT2\nbms_search(BMS *bms, int32_t offset, int32_t *start, int32_t *end);\n\n/**\n * Set the target string for the match.\n *\n * @param bms - the <code>BMS</code> object\n * @param target - the new target string\n * @param targetLength - the length of the new target string\n * @param status - will be set if any errors occur. \n *\n * @internal ICU 4.0.1 technology preview\n */\nU_INTERNAL void U_EXPORT2\nbms_setTargetString(BMS *bms, const UChar *target, int32_t targetLength, UErrorCode *status);\n\n#endif  /* U_HIDE_INTERNAL_API */\n\n#endif\n\n#endif /* _BMS_H */\n"
  },
  {
    "path": "deprecated/android/addons/icucompat/unicode/bmsearch.h",
    "content": "/*\n ******************************************************************************\n *   Copyright (C) 1996-2011, International Business Machines                 *\n *   Corporation and others.  All Rights Reserved.                            *\n ******************************************************************************\n */\n\n/**\n * \\file \n * \\brief C++ API: Boyer-Moore StringSearch technology preview\n * \\internal ICU 4.0.1 technology preview\n */\n \n#ifndef B_M_SEARCH_H\n#define B_M_SEARCH_H\n\n#include \"unicode/utypes.h\"\n\n#if !UCONFIG_NO_COLLATION && !UCONFIG_NO_BREAK_ITERATION\n\n#include \"unicode/uobject.h\"\n#include \"unicode/ucol.h\"\n\n#include \"unicode/colldata.h\"\n\nU_NAMESPACE_BEGIN\n\nclass BadCharacterTable;\nclass GoodSuffixTable;\nclass Target;\n\n#ifndef U_HIDE_INTERNAL_API\n/**\n * BoyerMooreSearch\n *\n * This object holds the information needed to do a Collation sensitive Boyer-Moore search. It encapulates\n * the pattern, the \"bad character\" and \"good suffix\" tables, the Collator-based data needed to compute them,\n * and a reference to the text being searched.\n *\n * To do a search, you fist need to get a <code>CollData</code> object by calling <code>CollData::open</code>.\n * Then you construct a <code>BoyerMooreSearch</code> object from the <code>CollData</code> object, the pattern\n * string and the target string. Then you call the <code>search</code> method. Here's a code sample:\n *\n * <pre>\n * void boyerMooreExample(UCollator *collator, UnicodeString *pattern, UnicodeString *target)\n * {\n *     UErrorCode status = U_ZERO_ERROR;\n *     CollData *collData = CollData::open(collator, status);\n *\n *     if (U_FAILURE(status)) {\n *         // could not create a CollData object\n *         return;\n *     }\n *\n *     BoyerMooreSearch *search = new BoyerMooreSearch(collData, *patternString, target, status);\n *\n *     if (U_FAILURE(status)) {\n *         // could not create a BoyerMooreSearch object\n *         CollData::close(collData);\n *         return;\n *     }\n *\n *     int32_t offset = 0, start = -1, end = -1;\n *\n *     // Find all matches\n *     while (search->search(offset, start, end)) {\n *         // process the match between start and end\n *         ...\n *         // advance past the match\n *         offset = end; \n *     }\n *\n *     // at this point, if offset == 0, there were no matches\n *     if (offset == 0) {\n *         // handle the case of no matches\n *     }\n *\n *     delete search;\n *     CollData::close(collData);\n *\n *     // CollData objects are cached, so the call to\n *     // CollData::close doesn't delete the object.\n *     // Call this if you don't need the object any more.\n *     CollData::flushCollDataCache();\n * }\n * </pre>\n *\n * NOTE: This is a technology preview. The final version of this API may not bear any resenblence to this API.\n *\n * Knows linitations:\n *   1) Backwards searching has not been implemented.\n *\n *   2) For Han and Hangul characters, this code ignores any Collation tailorings. In general,\n *      this isn't a problem, but in Korean locals, at strength 1, Hangul characters are tailored\n *      to be equal to Han characters with the same pronounciation. Because this code ignroes\n *      tailorings, searching for a Hangul character will not find a Han character and visa-versa.\n *\n *   3) In some cases, searching for a pattern that needs to be normalized and ends\n *      in a discontiguous contraction may fail. The only known cases of this are with\n *      the Tibetan script. For example searching for the pattern\n *      \"\\u0F7F\\u0F80\\u0F81\\u0F82\\u0F83\\u0F84\\u0F85\" will fail. (This case is artificial. We've\n *      been unable to find a pratical, real-world example of this failure.)  \n *\n * @internal ICU 4.0.1 technology preview\n *\n * @see CollData\n */\nclass U_I18N_API BoyerMooreSearch : public UObject\n{\npublic:\n    /**\n     * Construct a <code>BoyerMooreSearch</code> object.\n     *\n     * @param theData - A <code>CollData</code> object holding the Collator-sensitive data\n     * @param patternString - the string for which to search\n     * @param targetString - the string in which to search or <code>NULL</code> if youu will\n     *                       set it later by calling <code>setTargetString</code>.\n     * @param status - will be set if any errors occur. \n     *\n     * Note: if on return, status is set to an error code,\n     * the only safe thing to do with this object is to call\n     * the destructor.\n     *\n     * @internal ICU 4.0.1 technology preview\n     */\n    BoyerMooreSearch(CollData *theData, const UnicodeString &patternString, const UnicodeString *targetString, UErrorCode &status);\n\n    /**\n     * The desstructor\n     *\n     * @internal ICU 4.0.1 technology preview\n     */\n    ~BoyerMooreSearch();\n\n    /**\n     * Test the pattern to see if it generates any CEs.\n     *\n     * @return <code>TRUE</code> if the pattern string did not generate any CEs\n     *\n     * @internal ICU 4.0.1 technology preview\n     */\n    UBool empty();\n\n    /**\n     * Search for the pattern string in the target string.\n     *\n     * @param offset - the offset in the target string at which to begin the search\n     * @param start - will be set to the starting offset of the match, or -1 if there's no match\n     * @param end - will be set to the ending offset of the match, or -1 if there's no match\n     *\n     * @return <code>TRUE</code> if the match succeeds, <code>FALSE</code> otherwise.\n     *\n     * @internal ICU 4.0.1 technology preview\n     */\n    UBool search(int32_t offset, int32_t &start, int32_t &end);\n\n    /**\n     * Set the target string for the match.\n     *\n     * @param targetString - the new target string\n     * @param status - will be set if any errors occur. \n     *\n     * @internal ICU 4.0.1 technology preview\n     */\n    void setTargetString(const UnicodeString *targetString, UErrorCode &status);\n\n    // **** no longer need these? ****\n    /**\n     * Return the <code>CollData</code> object used for searching\n     *\n     * @return the <code>CollData</code> object used for searching\n     *\n     * @internal ICU 4.0.1 technology preview\n     */\n    CollData *getData();\n\n    /**\n     * Return the CEs generated by the pattern string.\n     *\n     * @return a <code>CEList</code> object holding the CEs generated by the pattern string.\n     *\n     * @internal ICU 4.0.1 technology preview\n     */\n    CEList   *getPatternCEs();\n\n    /**\n     * Return the <code>BadCharacterTable</code> object computed for the pattern string.\n     *\n     * @return the <code>BadCharacterTable</code> object.\n     *\n     * @internal ICU 4.0.1 technology preview\n     */\n    BadCharacterTable *getBadCharacterTable();\n\n    /**\n     * Return the <code>GoodSuffixTable</code> object computed for the pattern string.\n     *\n     * @return the <code>GoodSuffixTable</code> object computed for the pattern string.\n     *\n     * @internal ICU 4.0.1 technology preview\n     */\n    GoodSuffixTable   *getGoodSuffixTable();\n\n    /**\n     * UObject glue...\n     * @internal ICU 4.0.1 technology preview\n     */\n    virtual UClassID getDynamicClassID() const;\n    /**\n     * UObject glue...\n     * @internal ICU 4.0.1 technology preview\n     */\n    static UClassID getStaticClassID();\n    \nprivate:\n    CollData *data;\n    CEList *patCEs;\n    BadCharacterTable *badCharacterTable;\n    GoodSuffixTable   *goodSuffixTable;\n    UnicodeString pattern;\n    Target *target;\n};\n#endif  /* U_HIDE_INTERNAL_API */\n\nU_NAMESPACE_END\n\n#endif // #if !UCONFIG_NO_COLLATION\n#endif // #ifndef B_M_SEARCH_H\n"
  },
  {
    "path": "deprecated/android/addons/icucompat/unicode/brkiter.h",
    "content": "/*\n********************************************************************************\n*   Copyright (C) 1997-2012, International Business Machines\n*   Corporation and others.  All Rights Reserved.\n********************************************************************************\n*\n* File brkiter.h\n*\n* Modification History:\n*\n*   Date        Name        Description\n*   02/18/97    aliu        Added typedef for TextCount.  Made DONE const.\n*   05/07/97    aliu        Fixed DLL declaration.\n*   07/09/97    jfitz       Renamed BreakIterator and interface synced with JDK\n*   08/11/98    helena      Sync-up JDK1.2.\n*   01/13/2000  helena      Added UErrorCode parameter to createXXXInstance methods.\n********************************************************************************\n*/\n\n#ifndef BRKITER_H\n#define BRKITER_H\n\n#include \"unicode/utypes.h\"\n\n/**\n * \\file\n * \\brief C++ API: Break Iterator.\n */\n\n#if UCONFIG_NO_BREAK_ITERATION\n\nU_NAMESPACE_BEGIN\n\n/*\n * Allow the declaration of APIs with pointers to BreakIterator\n * even when break iteration is removed from the build.\n */\nclass BreakIterator;\n\nU_NAMESPACE_END\n\n#else\n\n#include \"unicode/uobject.h\"\n#include \"unicode/unistr.h\"\n#include \"unicode/chariter.h\"\n#include \"unicode/locid.h\"\n#include \"unicode/ubrk.h\"\n#include \"unicode/strenum.h\"\n#include \"unicode/utext.h\"\n#include \"unicode/umisc.h\"\n\nU_NAMESPACE_BEGIN\n\n/**\n * The BreakIterator class implements methods for finding the location\n * of boundaries in text. BreakIterator is an abstract base class.\n * Instances of BreakIterator maintain a current position and scan over\n * text returning the index of characters where boundaries occur.\n * <p>\n * Line boundary analysis determines where a text string can be broken\n * when line-wrapping. The mechanism correctly handles punctuation and\n * hyphenated words.\n * <p>\n * Sentence boundary analysis allows selection with correct\n * interpretation of periods within numbers and abbreviations, and\n * trailing punctuation marks such as quotation marks and parentheses.\n * <p>\n * Word boundary analysis is used by search and replace functions, as\n * well as within text editing applications that allow the user to\n * select words with a double click. Word selection provides correct\n * interpretation of punctuation marks within and following\n * words. Characters that are not part of a word, such as symbols or\n * punctuation marks, have word-breaks on both sides.\n * <p>\n * Character boundary analysis allows users to interact with\n * characters as they expect to, for example, when moving the cursor\n * through a text string. Character boundary analysis provides correct\n * navigation of through character strings, regardless of how the\n * character is stored.  For example, an accented character might be\n * stored as a base character and a diacritical mark. What users\n * consider to be a character can differ between languages.\n * <p>\n * The text boundary positions are found according to the rules\n * described in Unicode Standard Annex #29, Text Boundaries, and\n * Unicode Standard Annex #14, Line Breaking Properties.  These\n * are available at http://www.unicode.org/reports/tr14/ and\n * http://www.unicode.org/reports/tr29/.\n * <p>\n * In addition to the C++ API defined in this header file, a\n * plain C API with equivalent functionality is defined in the\n * file ubrk.h\n * <p>\n * Code snippets illustrating the use of the Break Iterator APIs\n * are available in the ICU User Guide,\n * http://icu-project.org/userguide/boundaryAnalysis.html\n * and in the sample program icu/source/samples/break/break.cpp\n *\n */\nclass U_COMMON_API BreakIterator : public UObject {\npublic:\n    /**\n     *  destructor\n     *  @stable ICU 2.0\n     */\n    virtual ~BreakIterator();\n\n    /**\n     * Return true if another object is semantically equal to this\n     * one. The other object should be an instance of the same subclass of\n     * BreakIterator. Objects of different subclasses are considered\n     * unequal.\n     * <P>\n     * Return true if this BreakIterator is at the same position in the\n     * same text, and is the same class and type (word, line, etc.) of\n     * BreakIterator, as the argument.  Text is considered the same if\n     * it contains the same characters, it need not be the same\n     * object, and styles are not considered.\n     * @stable ICU 2.0\n     */\n    virtual UBool operator==(const BreakIterator&) const = 0;\n\n    /**\n     * Returns the complement of the result of operator==\n     * @param rhs The BreakIterator to be compared for inequality\n     * @return the complement of the result of operator==\n     * @stable ICU 2.0\n     */\n    UBool operator!=(const BreakIterator& rhs) const { return !operator==(rhs); }\n\n    /**\n     * Return a polymorphic copy of this object.  This is an abstract\n     * method which subclasses implement.\n     * @stable ICU 2.0\n     */\n    virtual BreakIterator* clone(void) const = 0;\n\n    /**\n     * Return a polymorphic class ID for this object. Different subclasses\n     * will return distinct unequal values.\n     * @stable ICU 2.0\n     */\n    virtual UClassID getDynamicClassID(void) const = 0;\n\n    /**\n     * Return a CharacterIterator over the text being analyzed.\n     * @stable ICU 2.0\n     */\n    virtual CharacterIterator& getText(void) const = 0;\n\n\n    /**\n      *  Get a UText for the text being analyzed.\n      *  The returned UText is a shallow clone of the UText used internally\n      *  by the break iterator implementation.  It can safely be used to\n      *  access the text without impacting any break iterator operations,\n      *  but the underlying text itself must not be altered.\n      *\n      * @param fillIn A UText to be filled in.  If NULL, a new UText will be\n      *           allocated to hold the result.\n      * @param status receives any error codes.\n      * @return   The current UText for this break iterator.  If an input\n      *           UText was provided, it will always be returned.\n      * @stable ICU 3.4\n      */\n     virtual UText *getUText(UText *fillIn, UErrorCode &status) const = 0;\n\n    /**\n     * Change the text over which this operates. The text boundary is\n     * reset to the start.\n     * @param text The UnicodeString used to change the text.\n     * @stable ICU 2.0\n     */\n    virtual void  setText(const UnicodeString &text) = 0;\n\n    /**\n     * Reset the break iterator to operate over the text represented by\n     * the UText.  The iterator position is reset to the start.\n     *\n     * This function makes a shallow clone of the supplied UText.  This means\n     * that the caller is free to immediately close or otherwise reuse the\n     * Utext that was passed as a parameter, but that the underlying text itself\n     * must not be altered while being referenced by the break iterator.\n     *\n     * @param text The UText used to change the text.\n     * @param status receives any error codes.\n     * @stable ICU 3.4\n     */\n    virtual void  setText(UText *text, UErrorCode &status) = 0;\n\n    /**\n     * Change the text over which this operates. The text boundary is\n     * reset to the start.\n     * Note that setText(UText *) provides similar functionality to this function,\n     * and is more efficient.\n     * @param it The CharacterIterator used to change the text.\n     * @stable ICU 2.0\n     */\n    virtual void  adoptText(CharacterIterator* it) = 0;\n\n    enum {\n        /**\n         * DONE is returned by previous() and next() after all valid\n         * boundaries have been returned.\n         * @stable ICU 2.0\n         */\n        DONE = (int32_t)-1\n    };\n\n    /**\n     * Set the iterator position to the index of the first character in the text being scanned.\n     * @return The index of the first character in the text being scanned.\n     * @stable ICU 2.0\n     */\n    virtual int32_t first(void) = 0;\n\n    /**\n     * Set the iterator position to the index immediately BEYOND the last character in the text being scanned.\n     * @return The index immediately BEYOND the last character in the text being scanned.\n     * @stable ICU 2.0\n     */\n    virtual int32_t last(void) = 0;\n\n    /**\n     * Set the iterator position to the boundary preceding the current boundary.\n     * @return The character index of the previous text boundary or DONE if all\n     * boundaries have been returned.\n     * @stable ICU 2.0\n     */\n    virtual int32_t previous(void) = 0;\n\n    /**\n     * Advance the iterator to the boundary following the current boundary.\n     * @return The character index of the next text boundary or DONE if all\n     * boundaries have been returned.\n     * @stable ICU 2.0\n     */\n    virtual int32_t next(void) = 0;\n\n    /**\n     * Return character index of the current interator position within the text.\n     * @return The boundary most recently returned.\n     * @stable ICU 2.0\n     */\n    virtual int32_t current(void) const = 0;\n\n    /**\n     * Advance the iterator to the first boundary following the specified offset.\n     * The value returned is always greater than the offset or\n     * the value BreakIterator.DONE\n     * @param offset the offset to begin scanning.\n     * @return The first boundary after the specified offset.\n     * @stable ICU 2.0\n     */\n    virtual int32_t following(int32_t offset) = 0;\n\n    /**\n     * Set the iterator position to the first boundary preceding the specified offset.\n     * The value returned is always smaller than the offset or\n     * the value BreakIterator.DONE\n     * @param offset the offset to begin scanning.\n     * @return The first boundary before the specified offset.\n     * @stable ICU 2.0\n     */\n    virtual int32_t preceding(int32_t offset) = 0;\n\n    /**\n     * Return true if the specfied position is a boundary position.\n     * As a side effect, the current position of the iterator is set\n     * to the first boundary position at or following the specified offset.\n     * @param offset the offset to check.\n     * @return True if \"offset\" is a boundary position.\n     * @stable ICU 2.0\n     */\n    virtual UBool isBoundary(int32_t offset) = 0;\n\n    /**\n     * Set the iterator position to the nth boundary from the current boundary\n     * @param n the number of boundaries to move by.  A value of 0\n     * does nothing.  Negative values move to previous boundaries\n     * and positive values move to later boundaries.\n     * @return The new iterator position, or\n     * DONE if there are fewer than |n| boundaries in the specfied direction.\n     * @stable ICU 2.0\n     */\n    virtual int32_t next(int32_t n) = 0;\n\n    /**\n     * Create BreakIterator for word-breaks using the given locale.\n     * Returns an instance of a BreakIterator implementing word breaks.\n     * WordBreak is useful for word selection (ex. double click)\n     * @param where the locale.\n     * @param status the error code\n     * @return A BreakIterator for word-breaks.  The UErrorCode& status\n     * parameter is used to return status information to the user.\n     * To check whether the construction succeeded or not, you should check\n     * the value of U_SUCCESS(err).  If you wish more detailed information, you\n     * can check for informational error results which still indicate success.\n     * U_USING_FALLBACK_WARNING indicates that a fall back locale was used.  For\n     * example, 'de_CH' was requested, but nothing was found there, so 'de' was\n     * used.  U_USING_DEFAULT_WARNING indicates that the default locale data was\n     * used; neither the requested locale nor any of its fall back locales\n     * could be found.\n     * The caller owns the returned object and is responsible for deleting it.\n     * @stable ICU 2.0\n     */\n    static BreakIterator* U_EXPORT2\n    createWordInstance(const Locale& where, UErrorCode& status);\n\n    /**\n     * Create BreakIterator for line-breaks using specified locale.\n     * Returns an instance of a BreakIterator implementing line breaks. Line\n     * breaks are logically possible line breaks, actual line breaks are\n     * usually determined based on display width.\n     * LineBreak is useful for word wrapping text.\n     * @param where the locale.\n     * @param status The error code.\n     * @return A BreakIterator for line-breaks.  The UErrorCode& status\n     * parameter is used to return status information to the user.\n     * To check whether the construction succeeded or not, you should check\n     * the value of U_SUCCESS(err).  If you wish more detailed information, you\n     * can check for informational error results which still indicate success.\n     * U_USING_FALLBACK_WARNING indicates that a fall back locale was used.  For\n     * example, 'de_CH' was requested, but nothing was found there, so 'de' was\n     * used.  U_USING_DEFAULT_WARNING indicates that the default locale data was\n     * used; neither the requested locale nor any of its fall back locales\n     * could be found.\n     * The caller owns the returned object and is responsible for deleting it.\n     * @stable ICU 2.0\n     */\n    static BreakIterator* U_EXPORT2\n    createLineInstance(const Locale& where, UErrorCode& status);\n\n    /**\n     * Create BreakIterator for character-breaks using specified locale\n     * Returns an instance of a BreakIterator implementing character breaks.\n     * Character breaks are boundaries of combining character sequences.\n     * @param where the locale.\n     * @param status The error code.\n     * @return A BreakIterator for character-breaks.  The UErrorCode& status\n     * parameter is used to return status information to the user.\n     * To check whether the construction succeeded or not, you should check\n     * the value of U_SUCCESS(err).  If you wish more detailed information, you\n     * can check for informational error results which still indicate success.\n     * U_USING_FALLBACK_WARNING indicates that a fall back locale was used.  For\n     * example, 'de_CH' was requested, but nothing was found there, so 'de' was\n     * used.  U_USING_DEFAULT_WARNING indicates that the default locale data was\n     * used; neither the requested locale nor any of its fall back locales\n     * could be found.\n     * The caller owns the returned object and is responsible for deleting it.\n     * @stable ICU 2.0\n     */\n    static BreakIterator* U_EXPORT2\n    createCharacterInstance(const Locale& where, UErrorCode& status);\n\n    /**\n     * Create BreakIterator for sentence-breaks using specified locale\n     * Returns an instance of a BreakIterator implementing sentence breaks.\n     * @param where the locale.\n     * @param status The error code.\n     * @return A BreakIterator for sentence-breaks.  The UErrorCode& status\n     * parameter is used to return status information to the user.\n     * To check whether the construction succeeded or not, you should check\n     * the value of U_SUCCESS(err).  If you wish more detailed information, you\n     * can check for informational error results which still indicate success.\n     * U_USING_FALLBACK_WARNING indicates that a fall back locale was used.  For\n     * example, 'de_CH' was requested, but nothing was found there, so 'de' was\n     * used.  U_USING_DEFAULT_WARNING indicates that the default locale data was\n     * used; neither the requested locale nor any of its fall back locales\n     * could be found.\n     * The caller owns the returned object and is responsible for deleting it.\n     * @stable ICU 2.0\n     */\n    static BreakIterator* U_EXPORT2\n    createSentenceInstance(const Locale& where, UErrorCode& status);\n\n    /**\n     * Create BreakIterator for title-casing breaks using the specified locale\n     * Returns an instance of a BreakIterator implementing title breaks.\n     * The iterator returned locates title boundaries as described for\n     * Unicode 3.2 only. For Unicode 4.0 and above title boundary iteration,\n     * please use Word Boundary iterator.{@link #createWordInstance }\n     *\n     * @param where the locale.\n     * @param status The error code.\n     * @return A BreakIterator for title-breaks.  The UErrorCode& status\n     * parameter is used to return status information to the user.\n     * To check whether the construction succeeded or not, you should check\n     * the value of U_SUCCESS(err).  If you wish more detailed information, you\n     * can check for informational error results which still indicate success.\n     * U_USING_FALLBACK_WARNING indicates that a fall back locale was used.  For\n     * example, 'de_CH' was requested, but nothing was found there, so 'de' was\n     * used.  U_USING_DEFAULT_WARNING indicates that the default locale data was\n     * used; neither the requested locale nor any of its fall back locales\n     * could be found.\n     * The caller owns the returned object and is responsible for deleting it.\n     * @stable ICU 2.1\n     */\n    static BreakIterator* U_EXPORT2\n    createTitleInstance(const Locale& where, UErrorCode& status);\n\n    /**\n     * Get the set of Locales for which TextBoundaries are installed.\n     * <p><b>Note:</b> this will not return locales added through the register\n     * call. To see the registered locales too, use the getAvailableLocales\n     * function that returns a StringEnumeration object </p>\n     * @param count the output parameter of number of elements in the locale list\n     * @return available locales\n     * @stable ICU 2.0\n     */\n    static const Locale* U_EXPORT2 getAvailableLocales(int32_t& count);\n\n    /**\n     * Get name of the object for the desired Locale, in the desired langauge.\n     * @param objectLocale must be from getAvailableLocales.\n     * @param displayLocale specifies the desired locale for output.\n     * @param name the fill-in parameter of the return value\n     * Uses best match.\n     * @return user-displayable name\n     * @stable ICU 2.0\n     */\n    static UnicodeString& U_EXPORT2 getDisplayName(const Locale& objectLocale,\n                                         const Locale& displayLocale,\n                                         UnicodeString& name);\n\n    /**\n     * Get name of the object for the desired Locale, in the langauge of the\n     * default locale.\n     * @param objectLocale must be from getMatchingLocales\n     * @param name the fill-in parameter of the return value\n     * @return user-displayable name\n     * @stable ICU 2.0\n     */\n    static UnicodeString& U_EXPORT2 getDisplayName(const Locale& objectLocale,\n                                         UnicodeString& name);\n\n    /**\n     * Thread safe client-buffer-based cloning operation\n     *    Do NOT call delete on a safeclone, since 'new' is not used to create it.\n     * @param stackBuffer user allocated space for the new clone. If NULL new memory will be allocated.\n     * If buffer is not large enough, new memory will be allocated.\n     * @param BufferSize reference to size of allocated space.\n     * If BufferSize == 0, a sufficient size for use in cloning will\n     * be returned ('pre-flighting')\n     * If BufferSize is not enough for a stack-based safe clone,\n     * new memory will be allocated.\n     * @param status to indicate whether the operation went on smoothly or there were errors\n     *  An informational status value, U_SAFECLONE_ALLOCATED_ERROR, is used if any allocations were\n     *  necessary.\n     * @return pointer to the new clone\n     *\n     * @stable ICU 2.0\n     */\n    virtual BreakIterator *  createBufferClone(void *stackBuffer,\n                                               int32_t &BufferSize,\n                                               UErrorCode &status) = 0;\n\n    /**\n     *   Determine whether the BreakIterator was created in user memory by\n     *   createBufferClone(), and thus should not be deleted.  Such objects\n     *   must be closed by an explicit call to the destructor (not delete).\n     *  @stable ICU 2.0\n     */\n    inline UBool isBufferClone(void);\n\n#if !UCONFIG_NO_SERVICE\n    /**\n     * Register a new break iterator of the indicated kind, to use in the given locale.\n     * The break iterator will be adopted.  Clones of the iterator will be returned\n     * if a request for a break iterator of the given kind matches or falls back to\n     * this locale.\n     * @param toAdopt the BreakIterator instance to be adopted\n     * @param locale the Locale for which this instance is to be registered\n     * @param kind the type of iterator for which this instance is to be registered\n     * @param status the in/out status code, no special meanings are assigned\n     * @return a registry key that can be used to unregister this instance\n     * @stable ICU 2.4\n     */\n    static URegistryKey U_EXPORT2 registerInstance(BreakIterator* toAdopt,\n                                        const Locale& locale,\n                                        UBreakIteratorType kind,\n                                        UErrorCode& status);\n\n    /**\n     * Unregister a previously-registered BreakIterator using the key returned from the\n     * register call.  Key becomes invalid after a successful call and should not be used again.\n     * The BreakIterator corresponding to the key will be deleted.\n     * @param key the registry key returned by a previous call to registerInstance\n     * @param status the in/out status code, no special meanings are assigned\n     * @return TRUE if the iterator for the key was successfully unregistered\n     * @stable ICU 2.4\n     */\n    static UBool U_EXPORT2 unregister(URegistryKey key, UErrorCode& status);\n\n    /**\n     * Return a StringEnumeration over the locales available at the time of the call,\n     * including registered locales.\n     * @return a StringEnumeration over the locales available at the time of the call\n     * @stable ICU 2.4\n     */\n    static StringEnumeration* U_EXPORT2 getAvailableLocales(void);\n#endif\n\n    /**\n     * Returns the locale for this break iterator. Two flavors are available: valid and\n     * actual locale.\n     * @stable ICU 2.8\n     */\n    Locale getLocale(ULocDataLocaleType type, UErrorCode& status) const;\n\n#ifndef U_HIDE_INTERNAL_API\n    /** Get the locale for this break iterator object. You can choose between valid and actual locale.\n     *  @param type type of the locale we're looking for (valid or actual)\n     *  @param status error code for the operation\n     *  @return the locale\n     *  @internal\n     */\n    const char *getLocaleID(ULocDataLocaleType type, UErrorCode& status) const;\n#endif  /* U_HIDE_INTERNAL_API */\n\n    /**\n     *  Set the subject text string upon which the break iterator is operating\n     *  without changing any other aspect of the matching state.\n     *  The new and previous text strings must have the same content.\n     *\n     *  This function is intended for use in environments where ICU is operating on\n     *  strings that may move around in memory.  It provides a mechanism for notifying\n     *  ICU that the string has been relocated, and providing a new UText to access the\n     *  string in its new position.\n     *\n     *  Note that the break iterator implementation never copies the underlying text\n     *  of a string being processed, but always operates directly on the original text\n     *  provided by the user. Refreshing simply drops the references to the old text\n     *  and replaces them with references to the new.\n     *\n     *  Caution:  this function is normally used only by very specialized,\n     *  system-level code.  One example use case is with garbage collection that moves\n     *  the text in memory.\n     *\n     * @param input      The new (moved) text string.\n     * @param status     Receives errors detected by this function.\n     * @return           *this\n     *\n     * @draft ICU 49\n     */\n    virtual BreakIterator &refreshInputText(UText *input, UErrorCode &status) = 0;\n\n private:\n    static BreakIterator* buildInstance(const Locale& loc, const char *type, int32_t kind, UErrorCode& status);\n    static BreakIterator* createInstance(const Locale& loc, int32_t kind, UErrorCode& status);\n    static BreakIterator* makeInstance(const Locale& loc, int32_t kind, UErrorCode& status);\n\n    friend class ICUBreakIteratorFactory;\n    friend class ICUBreakIteratorService;\n\nprotected:\n    // Do not enclose protected default/copy constructors with #ifndef U_HIDE_INTERNAL_API\n    // or else the compiler will create a public ones.\n    /** @internal */\n    BreakIterator();\n    /** @internal */\n    UBool fBufferClone;\n    /** @internal */\n    BreakIterator (const BreakIterator &other) : UObject(other), fBufferClone(FALSE) {}\n\nprivate:\n\n    /** @internal */\n    char actualLocale[ULOC_FULLNAME_CAPACITY];\n    char validLocale[ULOC_FULLNAME_CAPACITY];\n\n    /**\n     * The assignment operator has no real implementation.\n     * It's provided to make the compiler happy. Do not call.\n     */\n    BreakIterator& operator=(const BreakIterator&);\n};\n\ninline UBool BreakIterator::isBufferClone()\n{\n    return fBufferClone;\n}\n\nU_NAMESPACE_END\n\n#endif /* #if !UCONFIG_NO_BREAK_ITERATION */\n\n#endif // _BRKITER\n//eof\n\n"
  },
  {
    "path": "deprecated/android/addons/icucompat/unicode/bytestream.h",
    "content": "// Copyright (C) 2009-2012, International Business Machines\n// Corporation and others. All Rights Reserved.\n//\n// Copyright 2007 Google Inc. All Rights Reserved.\n// Author: sanjay@google.com (Sanjay Ghemawat)\n//\n// Abstract interface that consumes a sequence of bytes (ByteSink).\n//\n// Used so that we can write a single piece of code that can operate\n// on a variety of output string types.\n//\n// Various implementations of this interface are provided:\n//   ByteSink:\n//      CheckedArrayByteSink    Write to a flat array, with bounds checking\n//      StringByteSink          Write to an STL string\n\n// This code is a contribution of Google code, and the style used here is\n// a compromise between the original Google code and the ICU coding guidelines.\n// For example, data types are ICU-ified (size_t,int->int32_t),\n// and API comments doxygen-ified, but function names and behavior are\n// as in the original, if possible.\n// Assertion-style error handling, not available in ICU, was changed to\n// parameter \"pinning\" similar to UnicodeString.\n//\n// In addition, this is only a partial port of the original Google code,\n// limited to what was needed so far. The (nearly) complete original code\n// is in the ICU svn repository at icuhtml/trunk/design/strings/contrib\n// (see ICU ticket 6765, r25517).\n\n#ifndef __BYTESTREAM_H__\n#define __BYTESTREAM_H__\n\n/**\n * \\file\n * \\brief C++ API: Interface for writing bytes, and implementation classes.\n */\n\n#include \"unicode/utypes.h\"\n#include \"unicode/uobject.h\"\n#include \"unicode/std_string.h\"\n\nU_NAMESPACE_BEGIN\n\n/**\n * A ByteSink can be filled with bytes.\n * @stable ICU 4.2\n */\nclass U_COMMON_API ByteSink : public UMemory {\npublic:\n  /**\n   * Default constructor.\n   * @stable ICU 4.2\n   */\n  ByteSink() { }\n  /**\n   * Virtual destructor.\n   * @stable ICU 4.2\n   */\n  virtual ~ByteSink();\n\n  /**\n   * Append \"bytes[0,n-1]\" to this.\n   * @param bytes the pointer to the bytes\n   * @param n the number of bytes; must be non-negative\n   * @stable ICU 4.2\n   */\n  virtual void Append(const char* bytes, int32_t n) = 0;\n\n  /**\n   * Returns a writable buffer for appending and writes the buffer's capacity to\n   * *result_capacity. Guarantees *result_capacity>=min_capacity.\n   * May return a pointer to the caller-owned scratch buffer which must have\n   * scratch_capacity>=min_capacity.\n   * The returned buffer is only valid until the next operation\n   * on this ByteSink.\n   *\n   * After writing at most *result_capacity bytes, call Append() with the\n   * pointer returned from this function and the number of bytes written.\n   * Many Append() implementations will avoid copying bytes if this function\n   * returned an internal buffer.\n   *\n   * Partial usage example:\n   *  int32_t capacity;\n   *  char* buffer = sink->GetAppendBuffer(..., &capacity);\n   *  ... Write n bytes into buffer, with n <= capacity.\n   *  sink->Append(buffer, n);\n   * In many implementations, that call to Append will avoid copying bytes.\n   *\n   * If the ByteSink allocates or reallocates an internal buffer, it should use\n   * the desired_capacity_hint if appropriate.\n   * If a caller cannot provide a reasonable guess at the desired capacity,\n   * it should pass desired_capacity_hint=0.\n   *\n   * If a non-scratch buffer is returned, the caller may only pass\n   * a prefix to it to Append().\n   * That is, it is not correct to pass an interior pointer to Append().\n   *\n   * The default implementation always returns the scratch buffer.\n   *\n   * @param min_capacity required minimum capacity of the returned buffer;\n   *                     must be non-negative\n   * @param desired_capacity_hint desired capacity of the returned buffer;\n   *                              must be non-negative\n   * @param scratch default caller-owned buffer\n   * @param scratch_capacity capacity of the scratch buffer\n   * @param result_capacity pointer to an integer which will be set to the\n   *                        capacity of the returned buffer\n   * @return a buffer with *result_capacity>=min_capacity\n   * @stable ICU 4.2\n   */\n  virtual char* GetAppendBuffer(int32_t min_capacity,\n                                int32_t desired_capacity_hint,\n                                char* scratch, int32_t scratch_capacity,\n                                int32_t* result_capacity);\n\n  /**\n   * Flush internal buffers.\n   * Some byte sinks use internal buffers or provide buffering\n   * and require calling Flush() at the end of the stream.\n   * The ByteSink should be ready for further Append() calls after Flush().\n   * The default implementation of Flush() does nothing.\n   * @stable ICU 4.2\n   */\n  virtual void Flush();\n\nprivate:\n  ByteSink(const ByteSink &); // copy constructor not implemented\n  ByteSink &operator=(const ByteSink &); // assignment operator not implemented\n};\n\n// -------------------------------------------------------------\n// Some standard implementations\n\n/** \n * Implementation of ByteSink that writes to a flat byte array,\n * with bounds-checking:\n * This sink will not write more than capacity bytes to outbuf.\n * If more than capacity bytes are Append()ed, then excess bytes are ignored,\n * and Overflowed() will return true.\n * Overflow does not cause a runtime error.\n * @stable ICU 4.2\n */\nclass U_COMMON_API CheckedArrayByteSink : public ByteSink {\npublic:\n  /**\n   * Constructs a ByteSink that will write to outbuf[0..capacity-1].\n   * @param outbuf buffer to write to\n   * @param capacity size of the buffer\n   * @stable ICU 4.2\n   */\n  CheckedArrayByteSink(char* outbuf, int32_t capacity);\n  /**\n   * Destructor.\n   * @stable ICU 4.2\n   */\n  virtual ~CheckedArrayByteSink();\n  /**\n   * Returns the sink to its original state, without modifying the buffer.\n   * Useful for reusing both the buffer and the sink for multiple streams.\n   * Resets the state to NumberOfBytesWritten()=NumberOfBytesAppended()=0\n   * and Overflowed()=FALSE.\n   * @return *this\n   * @stable ICU 4.6\n   */\n  virtual CheckedArrayByteSink& Reset();\n  /**\n   * Append \"bytes[0,n-1]\" to this.\n   * @param bytes the pointer to the bytes\n   * @param n the number of bytes; must be non-negative\n   * @stable ICU 4.2\n   */\n  virtual void Append(const char* bytes, int32_t n);\n  /**\n   * Returns a writable buffer for appending and writes the buffer's capacity to\n   * *result_capacity. For details see the base class documentation.\n   * @param min_capacity required minimum capacity of the returned buffer;\n   *                     must be non-negative\n   * @param desired_capacity_hint desired capacity of the returned buffer;\n   *                              must be non-negative\n   * @param scratch default caller-owned buffer\n   * @param scratch_capacity capacity of the scratch buffer\n   * @param result_capacity pointer to an integer which will be set to the\n   *                        capacity of the returned buffer\n   * @return a buffer with *result_capacity>=min_capacity\n   * @stable ICU 4.2\n   */\n  virtual char* GetAppendBuffer(int32_t min_capacity,\n                                int32_t desired_capacity_hint,\n                                char* scratch, int32_t scratch_capacity,\n                                int32_t* result_capacity);\n  /**\n   * Returns the number of bytes actually written to the sink.\n   * @return number of bytes written to the buffer\n   * @stable ICU 4.2\n   */\n  int32_t NumberOfBytesWritten() const { return size_; }\n  /**\n   * Returns true if any bytes were discarded, i.e., if there was an\n   * attempt to write more than 'capacity' bytes.\n   * @return TRUE if more than 'capacity' bytes were Append()ed\n   * @stable ICU 4.2\n   */\n  UBool Overflowed() const { return overflowed_; }\n  /**\n   * Returns the number of bytes appended to the sink.\n   * If Overflowed() then NumberOfBytesAppended()>NumberOfBytesWritten()\n   * else they return the same number.\n   * @return number of bytes written to the buffer\n   * @stable ICU 4.6\n   */\n  int32_t NumberOfBytesAppended() const { return appended_; }\nprivate:\n  char* outbuf_;\n  const int32_t capacity_;\n  int32_t size_;\n  int32_t appended_;\n  UBool overflowed_;\n  CheckedArrayByteSink(); ///< default constructor not implemented \n  CheckedArrayByteSink(const CheckedArrayByteSink &); ///< copy constructor not implemented\n  CheckedArrayByteSink &operator=(const CheckedArrayByteSink &); ///< assignment operator not implemented\n};\n\n#if U_HAVE_STD_STRING\n\n/** \n * Implementation of ByteSink that writes to a \"string\".\n * The StringClass is usually instantiated with a std::string.\n * @stable ICU 4.2\n */\ntemplate<typename StringClass>\nclass StringByteSink : public ByteSink {\n public:\n  /**\n   * Constructs a ByteSink that will append bytes to the dest string.\n   * @param dest pointer to string object to append to\n   * @stable ICU 4.2\n   */\n  StringByteSink(StringClass* dest) : dest_(dest) { }\n  /**\n   * Append \"bytes[0,n-1]\" to this.\n   * @param data the pointer to the bytes\n   * @param n the number of bytes; must be non-negative\n   * @stable ICU 4.2\n   */\n  virtual void Append(const char* data, int32_t n) { dest_->append(data, n); }\n private:\n  StringClass* dest_;\n  StringByteSink(); ///< default constructor not implemented \n  StringByteSink(const StringByteSink &); ///< copy constructor not implemented\n  StringByteSink &operator=(const StringByteSink &); ///< assignment operator not implemented\n};\n\n#endif\n\nU_NAMESPACE_END\n\n#endif  // __BYTESTREAM_H__\n"
  },
  {
    "path": "deprecated/android/addons/icucompat/unicode/bytestrie.h",
    "content": "/*\n*******************************************************************************\n*   Copyright (C) 2010-2012, International Business Machines\n*   Corporation and others.  All Rights Reserved.\n*******************************************************************************\n*   file name:  bytestrie.h\n*   encoding:   US-ASCII\n*   tab size:   8 (not used)\n*   indentation:4\n*\n*   created on: 2010sep25\n*   created by: Markus W. Scherer\n*/\n\n#ifndef __BYTESTRIE_H__\n#define __BYTESTRIE_H__\n\n/**\n * \\file\n * \\brief C++ API: Trie for mapping byte sequences to integer values.\n */\n\n#include \"unicode/utypes.h\"\n#include \"unicode/stringpiece.h\"\n#include \"unicode/uobject.h\"\n#include \"unicode/ustringtrie.h\"\n\nU_NAMESPACE_BEGIN\n\nclass ByteSink;\nclass BytesTrieBuilder;\nclass CharString;\nclass UVector32;\n\n/**\n * Light-weight, non-const reader class for a BytesTrie.\n * Traverses a byte-serialized data structure with minimal state,\n * for mapping byte sequences to non-negative integer values.\n *\n * This class owns the serialized trie data only if it was constructed by\n * the builder's build() method.\n * The public constructor and the copy constructor only alias the data (only copy the pointer).\n * There is no assignment operator.\n *\n * This class is not intended for public subclassing.\n * @stable ICU 4.8\n */\nclass U_COMMON_API BytesTrie : public UMemory {\npublic:\n    /**\n     * Constructs a BytesTrie reader instance.\n     *\n     * The trieBytes must contain a copy of a byte sequence from the BytesTrieBuilder,\n     * starting with the first byte of that sequence.\n     * The BytesTrie object will not read more bytes than\n     * the BytesTrieBuilder generated in the corresponding build() call.\n     *\n     * The array is not copied/cloned and must not be modified while\n     * the BytesTrie object is in use.\n     *\n     * @param trieBytes The byte array that contains the serialized trie.\n     * @stable ICU 4.8\n     */\n    BytesTrie(const void *trieBytes)\n            : ownedArray_(NULL), bytes_(static_cast<const uint8_t *>(trieBytes)),\n              pos_(bytes_), remainingMatchLength_(-1) {}\n\n    /**\n     * Destructor.\n     * @stable ICU 4.8\n     */\n    ~BytesTrie();\n\n    /**\n     * Copy constructor, copies the other trie reader object and its state,\n     * but not the byte array which will be shared. (Shallow copy.)\n     * @param other Another BytesTrie object.\n     * @stable ICU 4.8\n     */\n    BytesTrie(const BytesTrie &other)\n            : ownedArray_(NULL), bytes_(other.bytes_),\n              pos_(other.pos_), remainingMatchLength_(other.remainingMatchLength_) {}\n\n    /**\n     * Resets this trie to its initial state.\n     * @return *this\n     * @stable ICU 4.8\n     */\n    BytesTrie &reset() {\n        pos_=bytes_;\n        remainingMatchLength_=-1;\n        return *this;\n    }\n\n    /**\n     * BytesTrie state object, for saving a trie's current state\n     * and resetting the trie back to this state later.\n     * @stable ICU 4.8\n     */\n    class State : public UMemory {\n    public:\n        /**\n         * Constructs an empty State.\n         * @stable ICU 4.8\n         */\n        State() { bytes=NULL; }\n    private:\n        friend class BytesTrie;\n\n        const uint8_t *bytes;\n        const uint8_t *pos;\n        int32_t remainingMatchLength;\n    };\n\n    /**\n     * Saves the state of this trie.\n     * @param state The State object to hold the trie's state.\n     * @return *this\n     * @see resetToState\n     * @stable ICU 4.8\n     */\n    const BytesTrie &saveState(State &state) const {\n        state.bytes=bytes_;\n        state.pos=pos_;\n        state.remainingMatchLength=remainingMatchLength_;\n        return *this;\n    }\n\n    /**\n     * Resets this trie to the saved state.\n     * If the state object contains no state, or the state of a different trie,\n     * then this trie remains unchanged.\n     * @param state The State object which holds a saved trie state.\n     * @return *this\n     * @see saveState\n     * @see reset\n     * @stable ICU 4.8\n     */\n    BytesTrie &resetToState(const State &state) {\n        if(bytes_==state.bytes && bytes_!=NULL) {\n            pos_=state.pos;\n            remainingMatchLength_=state.remainingMatchLength;\n        }\n        return *this;\n    }\n\n    /**\n     * Determines whether the byte sequence so far matches, whether it has a value,\n     * and whether another input byte can continue a matching byte sequence.\n     * @return The match/value Result.\n     * @stable ICU 4.8\n     */\n    UStringTrieResult current() const;\n\n    /**\n     * Traverses the trie from the initial state for this input byte.\n     * Equivalent to reset().next(inByte).\n     * @param inByte Input byte value. Values -0x100..-1 are treated like 0..0xff.\n     *               Values below -0x100 and above 0xff will never match.\n     * @return The match/value Result.\n     * @stable ICU 4.8\n     */\n    inline UStringTrieResult first(int32_t inByte) {\n        remainingMatchLength_=-1;\n        if(inByte<0) {\n            inByte+=0x100;\n        }\n        return nextImpl(bytes_, inByte);\n    }\n\n    /**\n     * Traverses the trie from the current state for this input byte.\n     * @param inByte Input byte value. Values -0x100..-1 are treated like 0..0xff.\n     *               Values below -0x100 and above 0xff will never match.\n     * @return The match/value Result.\n     * @stable ICU 4.8\n     */\n    UStringTrieResult next(int32_t inByte);\n\n    /**\n     * Traverses the trie from the current state for this byte sequence.\n     * Equivalent to\n     * \\code\n     * Result result=current();\n     * for(each c in s)\n     *   if(!USTRINGTRIE_HAS_NEXT(result)) return USTRINGTRIE_NO_MATCH;\n     *   result=next(c);\n     * return result;\n     * \\endcode\n     * @param s A string or byte sequence. Can be NULL if length is 0.\n     * @param length The length of the byte sequence. Can be -1 if NUL-terminated.\n     * @return The match/value Result.\n     * @stable ICU 4.8\n     */\n    UStringTrieResult next(const char *s, int32_t length);\n\n    /**\n     * Returns a matching byte sequence's value if called immediately after\n     * current()/first()/next() returned USTRINGTRIE_INTERMEDIATE_VALUE or USTRINGTRIE_FINAL_VALUE.\n     * getValue() can be called multiple times.\n     *\n     * Do not call getValue() after USTRINGTRIE_NO_MATCH or USTRINGTRIE_NO_VALUE!\n     * @return The value for the byte sequence so far.\n     * @stable ICU 4.8\n     */\n    inline int32_t getValue() const {\n        const uint8_t *pos=pos_;\n        int32_t leadByte=*pos++;\n        // U_ASSERT(leadByte>=kMinValueLead);\n        return readValue(pos, leadByte>>1);\n    }\n\n    /**\n     * Determines whether all byte sequences reachable from the current state\n     * map to the same value.\n     * @param uniqueValue Receives the unique value, if this function returns TRUE.\n     *                    (output-only)\n     * @return TRUE if all byte sequences reachable from the current state\n     *         map to the same value.\n     * @stable ICU 4.8\n     */\n    inline UBool hasUniqueValue(int32_t &uniqueValue) const {\n        const uint8_t *pos=pos_;\n        // Skip the rest of a pending linear-match node.\n        return pos!=NULL && findUniqueValue(pos+remainingMatchLength_+1, FALSE, uniqueValue);\n    }\n\n    /**\n     * Finds each byte which continues the byte sequence from the current state.\n     * That is, each byte b for which it would be next(b)!=USTRINGTRIE_NO_MATCH now.\n     * @param out Each next byte is appended to this object.\n     *            (Only uses the out.Append(s, length) method.)\n     * @return the number of bytes which continue the byte sequence from here\n     * @stable ICU 4.8\n     */\n    int32_t getNextBytes(ByteSink &out) const;\n\n    /**\n     * Iterator for all of the (byte sequence, value) pairs in a BytesTrie.\n     * @stable ICU 4.8\n     */\n    class U_COMMON_API Iterator : public UMemory {\n    public:\n        /**\n         * Iterates from the root of a byte-serialized BytesTrie.\n         * @param trieBytes The trie bytes.\n         * @param maxStringLength If 0, the iterator returns full strings/byte sequences.\n         *                        Otherwise, the iterator returns strings with this maximum length.\n         * @param errorCode Standard ICU error code. Its input value must\n         *                  pass the U_SUCCESS() test, or else the function returns\n         *                  immediately. Check for U_FAILURE() on output or use with\n         *                  function chaining. (See User Guide for details.)\n         * @stable ICU 4.8\n         */\n        Iterator(const void *trieBytes, int32_t maxStringLength, UErrorCode &errorCode);\n\n        /**\n         * Iterates from the current state of the specified BytesTrie.\n         * @param trie The trie whose state will be copied for iteration.\n         * @param maxStringLength If 0, the iterator returns full strings/byte sequences.\n         *                        Otherwise, the iterator returns strings with this maximum length.\n         * @param errorCode Standard ICU error code. Its input value must\n         *                  pass the U_SUCCESS() test, or else the function returns\n         *                  immediately. Check for U_FAILURE() on output or use with\n         *                  function chaining. (See User Guide for details.)\n         * @stable ICU 4.8\n         */\n        Iterator(const BytesTrie &trie, int32_t maxStringLength, UErrorCode &errorCode);\n\n        /**\n         * Destructor.\n         * @stable ICU 4.8\n         */\n        ~Iterator();\n\n        /**\n         * Resets this iterator to its initial state.\n         * @return *this\n         * @stable ICU 4.8\n         */\n        Iterator &reset();\n\n        /**\n         * @return TRUE if there are more elements.\n         * @stable ICU 4.8\n         */\n        UBool hasNext() const;\n\n        /**\n         * Finds the next (byte sequence, value) pair if there is one.\n         *\n         * If the byte sequence is truncated to the maximum length and does not\n         * have a real value, then the value is set to -1.\n         * In this case, this \"not a real value\" is indistinguishable from\n         * a real value of -1.\n         * @param errorCode Standard ICU error code. Its input value must\n         *                  pass the U_SUCCESS() test, or else the function returns\n         *                  immediately. Check for U_FAILURE() on output or use with\n         *                  function chaining. (See User Guide for details.)\n         * @return TRUE if there is another element.\n         * @stable ICU 4.8\n         */\n        UBool next(UErrorCode &errorCode);\n\n        /**\n         * @return The NUL-terminated byte sequence for the last successful next().\n         * @stable ICU 4.8\n         */\n        const StringPiece &getString() const { return sp_; }\n        /**\n         * @return The value for the last successful next().\n         * @stable ICU 4.8\n         */\n        int32_t getValue() const { return value_; }\n\n    private:\n        UBool truncateAndStop();\n\n        const uint8_t *branchNext(const uint8_t *pos, int32_t length, UErrorCode &errorCode);\n\n        const uint8_t *bytes_;\n        const uint8_t *pos_;\n        const uint8_t *initialPos_;\n        int32_t remainingMatchLength_;\n        int32_t initialRemainingMatchLength_;\n\n        CharString *str_;\n        StringPiece sp_;\n        int32_t maxLength_;\n        int32_t value_;\n\n        // The stack stores pairs of integers for backtracking to another\n        // outbound edge of a branch node.\n        // The first integer is an offset from bytes_.\n        // The second integer has the str_->length() from before the node in bits 15..0,\n        // and the remaining branch length in bits 24..16. (Bits 31..25 are unused.)\n        // (We could store the remaining branch length minus 1 in bits 23..16 and not use bits 31..24,\n        // but the code looks more confusing that way.)\n        UVector32 *stack_;\n    };\n\nprivate:\n    friend class BytesTrieBuilder;\n\n    /**\n     * Constructs a BytesTrie reader instance.\n     * Unlike the public constructor which just aliases an array,\n     * this constructor adopts the builder's array.\n     * This constructor is only called by the builder.\n     */\n    BytesTrie(void *adoptBytes, const void *trieBytes)\n            : ownedArray_(static_cast<uint8_t *>(adoptBytes)),\n              bytes_(static_cast<const uint8_t *>(trieBytes)),\n              pos_(bytes_), remainingMatchLength_(-1) {}\n\n    // No assignment operator.\n    BytesTrie &operator=(const BytesTrie &other);\n\n    inline void stop() {\n        pos_=NULL;\n    }\n\n    // Reads a compact 32-bit integer.\n    // pos is already after the leadByte, and the lead byte is already shifted right by 1.\n    static int32_t readValue(const uint8_t *pos, int32_t leadByte);\n    static inline const uint8_t *skipValue(const uint8_t *pos, int32_t leadByte) {\n        // U_ASSERT(leadByte>=kMinValueLead);\n        if(leadByte>=(kMinTwoByteValueLead<<1)) {\n            if(leadByte<(kMinThreeByteValueLead<<1)) {\n                ++pos;\n            } else if(leadByte<(kFourByteValueLead<<1)) {\n                pos+=2;\n            } else {\n                pos+=3+((leadByte>>1)&1);\n            }\n        }\n        return pos;\n    }\n    static inline const uint8_t *skipValue(const uint8_t *pos) {\n        int32_t leadByte=*pos++;\n        return skipValue(pos, leadByte);\n    }\n\n    // Reads a jump delta and jumps.\n    static const uint8_t *jumpByDelta(const uint8_t *pos);\n\n    static inline const uint8_t *skipDelta(const uint8_t *pos) {\n        int32_t delta=*pos++;\n        if(delta>=kMinTwoByteDeltaLead) {\n            if(delta<kMinThreeByteDeltaLead) {\n                ++pos;\n            } else if(delta<kFourByteDeltaLead) {\n                pos+=2;\n            } else {\n                pos+=3+(delta&1);\n            }\n        }\n        return pos;\n    }\n\n    static inline UStringTrieResult valueResult(int32_t node) {\n        return (UStringTrieResult)(USTRINGTRIE_INTERMEDIATE_VALUE-(node&kValueIsFinal));\n    }\n\n    // Handles a branch node for both next(byte) and next(string).\n    UStringTrieResult branchNext(const uint8_t *pos, int32_t length, int32_t inByte);\n\n    // Requires remainingLength_<0.\n    UStringTrieResult nextImpl(const uint8_t *pos, int32_t inByte);\n\n    // Helper functions for hasUniqueValue().\n    // Recursively finds a unique value (or whether there is not a unique one)\n    // from a branch.\n    static const uint8_t *findUniqueValueFromBranch(const uint8_t *pos, int32_t length,\n                                                    UBool haveUniqueValue, int32_t &uniqueValue);\n    // Recursively finds a unique value (or whether there is not a unique one)\n    // starting from a position on a node lead byte.\n    static UBool findUniqueValue(const uint8_t *pos, UBool haveUniqueValue, int32_t &uniqueValue);\n\n    // Helper functions for getNextBytes().\n    // getNextBytes() when pos is on a branch node.\n    static void getNextBranchBytes(const uint8_t *pos, int32_t length, ByteSink &out);\n    static void append(ByteSink &out, int c);\n\n    // BytesTrie data structure\n    //\n    // The trie consists of a series of byte-serialized nodes for incremental\n    // string/byte sequence matching. The root node is at the beginning of the trie data.\n    //\n    // Types of nodes are distinguished by their node lead byte ranges.\n    // After each node, except a final-value node, another node follows to\n    // encode match values or continue matching further bytes.\n    //\n    // Node types:\n    //  - Value node: Stores a 32-bit integer in a compact, variable-length format.\n    //    The value is for the string/byte sequence so far.\n    //    One node bit indicates whether the value is final or whether\n    //    matching continues with the next node.\n    //  - Linear-match node: Matches a number of bytes.\n    //  - Branch node: Branches to other nodes according to the current input byte.\n    //    The node byte is the length of the branch (number of bytes to select from)\n    //    minus 1. It is followed by a sub-node:\n    //    - If the length is at most kMaxBranchLinearSubNodeLength, then\n    //      there are length-1 (key, value) pairs and then one more comparison byte.\n    //      If one of the key bytes matches, then the value is either a final value for\n    //      the string/byte sequence so far, or a \"jump\" delta to the next node.\n    //      If the last byte matches, then matching continues with the next node.\n    //      (Values have the same encoding as value nodes.)\n    //    - If the length is greater than kMaxBranchLinearSubNodeLength, then\n    //      there is one byte and one \"jump\" delta.\n    //      If the input byte is less than the sub-node byte, then \"jump\" by delta to\n    //      the next sub-node which will have a length of length/2.\n    //      (The delta has its own compact encoding.)\n    //      Otherwise, skip the \"jump\" delta to the next sub-node\n    //      which will have a length of length-length/2.\n\n    // Node lead byte values.\n\n    // 00..0f: Branch node. If node!=0 then the length is node+1, otherwise\n    // the length is one more than the next byte.\n\n    // For a branch sub-node with at most this many entries, we drop down\n    // to a linear search.\n    static const int32_t kMaxBranchLinearSubNodeLength=5;\n\n    // 10..1f: Linear-match node, match 1..16 bytes and continue reading the next node.\n    static const int32_t kMinLinearMatch=0x10;\n    static const int32_t kMaxLinearMatchLength=0x10;\n\n    // 20..ff: Variable-length value node.\n    // If odd, the value is final. (Otherwise, intermediate value or jump delta.)\n    // Then shift-right by 1 bit.\n    // The remaining lead byte value indicates the number of following bytes (0..4)\n    // and contains the value's top bits.\n    static const int32_t kMinValueLead=kMinLinearMatch+kMaxLinearMatchLength;  // 0x20\n    // It is a final value if bit 0 is set.\n    static const int32_t kValueIsFinal=1;\n\n    // Compact value: After testing bit 0, shift right by 1 and then use the following thresholds.\n    static const int32_t kMinOneByteValueLead=kMinValueLead/2;  // 0x10\n    static const int32_t kMaxOneByteValue=0x40;  // At least 6 bits in the first byte.\n\n    static const int32_t kMinTwoByteValueLead=kMinOneByteValueLead+kMaxOneByteValue+1;  // 0x51\n    static const int32_t kMaxTwoByteValue=0x1aff;\n\n    static const int32_t kMinThreeByteValueLead=kMinTwoByteValueLead+(kMaxTwoByteValue>>8)+1;  // 0x6c\n    static const int32_t kFourByteValueLead=0x7e;\n\n    // A little more than Unicode code points. (0x11ffff)\n    static const int32_t kMaxThreeByteValue=((kFourByteValueLead-kMinThreeByteValueLead)<<16)-1;\n\n    static const int32_t kFiveByteValueLead=0x7f;\n\n    // Compact delta integers.\n    static const int32_t kMaxOneByteDelta=0xbf;\n    static const int32_t kMinTwoByteDeltaLead=kMaxOneByteDelta+1;  // 0xc0\n    static const int32_t kMinThreeByteDeltaLead=0xf0;\n    static const int32_t kFourByteDeltaLead=0xfe;\n    static const int32_t kFiveByteDeltaLead=0xff;\n\n    static const int32_t kMaxTwoByteDelta=((kMinThreeByteDeltaLead-kMinTwoByteDeltaLead)<<8)-1;  // 0x2fff\n    static const int32_t kMaxThreeByteDelta=((kFourByteDeltaLead-kMinThreeByteDeltaLead)<<16)-1;  // 0xdffff\n\n    uint8_t *ownedArray_;\n\n    // Fixed value referencing the BytesTrie bytes.\n    const uint8_t *bytes_;\n\n    // Iterator variables.\n\n    // Pointer to next trie byte to read. NULL if no more matches.\n    const uint8_t *pos_;\n    // Remaining length of a linear-match node, minus 1. Negative if not in such a node.\n    int32_t remainingMatchLength_;\n};\n\nU_NAMESPACE_END\n\n#endif  // __BYTESTRIE_H__\n"
  },
  {
    "path": "deprecated/android/addons/icucompat/unicode/bytestriebuilder.h",
    "content": "/*\n*******************************************************************************\n*   Copyright (C) 2010-2012, International Business Machines\n*   Corporation and others.  All Rights Reserved.\n*******************************************************************************\n*   file name:  bytestriebuilder.h\n*   encoding:   US-ASCII\n*   tab size:   8 (not used)\n*   indentation:4\n*\n*   created on: 2010sep25\n*   created by: Markus W. Scherer\n*/\n\n/**\n * \\file\n * \\brief C++ API: Builder for icu::BytesTrie\n */\n\n#ifndef __BYTESTRIEBUILDER_H__\n#define __BYTESTRIEBUILDER_H__\n\n#include \"unicode/utypes.h\"\n#include \"unicode/bytestrie.h\"\n#include \"unicode/stringpiece.h\"\n#include \"unicode/stringtriebuilder.h\"\n\nU_NAMESPACE_BEGIN\n\nclass BytesTrieElement;\nclass CharString;\n\n/**\n * Builder class for BytesTrie.\n *\n * This class is not intended for public subclassing.\n * @stable ICU 4.8\n */\nclass U_COMMON_API BytesTrieBuilder : public StringTrieBuilder {\npublic:\n    /**\n     * Constructs an empty builder.\n     * @param errorCode Standard ICU error code.\n     * @stable ICU 4.8\n     */\n    BytesTrieBuilder(UErrorCode &errorCode);\n\n    /**\n     * Destructor.\n     * @stable ICU 4.8\n     */\n    virtual ~BytesTrieBuilder();\n\n    /**\n     * Adds a (byte sequence, value) pair.\n     * The byte sequence must be unique.\n     * The bytes will be copied; the builder does not keep\n     * a reference to the input StringPiece or its data().\n     * @param s The input byte sequence.\n     * @param value The value associated with this byte sequence.\n     * @param errorCode Standard ICU error code. Its input value must\n     *                  pass the U_SUCCESS() test, or else the function returns\n     *                  immediately. Check for U_FAILURE() on output or use with\n     *                  function chaining. (See User Guide for details.)\n     * @return *this\n     * @stable ICU 4.8\n     */\n    BytesTrieBuilder &add(const StringPiece &s, int32_t value, UErrorCode &errorCode);\n\n    /**\n     * Builds a BytesTrie for the add()ed data.\n     * Once built, no further data can be add()ed until clear() is called.\n     *\n     * This method passes ownership of the builder's internal result array to the new trie object.\n     * Another call to any build() variant will re-serialize the trie.\n     * After clear() has been called, a new array will be used as well.\n     * @param buildOption Build option, see UStringTrieBuildOption.\n     * @param errorCode Standard ICU error code. Its input value must\n     *                  pass the U_SUCCESS() test, or else the function returns\n     *                  immediately. Check for U_FAILURE() on output or use with\n     *                  function chaining. (See User Guide for details.)\n     * @return A new BytesTrie for the add()ed data.\n     * @stable ICU 4.8\n     */\n    BytesTrie *build(UStringTrieBuildOption buildOption, UErrorCode &errorCode);\n\n    /**\n     * Builds a BytesTrie for the add()ed data and byte-serializes it.\n     * Once built, no further data can be add()ed until clear() is called.\n     *\n     * Multiple calls to buildStringPiece() return StringPieces referring to the\n     * builder's same byte array, without rebuilding.\n     * If buildStringPiece() is called after build(), the trie will be\n     * re-serialized into a new array.\n     * If build() is called after buildStringPiece(), the trie object will become\n     * the owner of the previously returned array.\n     * After clear() has been called, a new array will be used as well.\n     * @param buildOption Build option, see UStringTrieBuildOption.\n     * @param errorCode Standard ICU error code. Its input value must\n     *                  pass the U_SUCCESS() test, or else the function returns\n     *                  immediately. Check for U_FAILURE() on output or use with\n     *                  function chaining. (See User Guide for details.)\n     * @return A StringPiece which refers to the byte-serialized BytesTrie for the add()ed data.\n     * @stable ICU 4.8\n     */\n    StringPiece buildStringPiece(UStringTrieBuildOption buildOption, UErrorCode &errorCode);\n\n    /**\n     * Removes all (byte sequence, value) pairs.\n     * New data can then be add()ed and a new trie can be built.\n     * @return *this\n     * @stable ICU 4.8\n     */\n    BytesTrieBuilder &clear();\n\nprivate:\n    BytesTrieBuilder(const BytesTrieBuilder &other);  // no copy constructor\n    BytesTrieBuilder &operator=(const BytesTrieBuilder &other);  // no assignment operator\n\n    void buildBytes(UStringTrieBuildOption buildOption, UErrorCode &errorCode);\n\n    virtual int32_t getElementStringLength(int32_t i) const;\n    virtual UChar getElementUnit(int32_t i, int32_t byteIndex) const;\n    virtual int32_t getElementValue(int32_t i) const;\n\n    virtual int32_t getLimitOfLinearMatch(int32_t first, int32_t last, int32_t byteIndex) const;\n\n    virtual int32_t countElementUnits(int32_t start, int32_t limit, int32_t byteIndex) const;\n    virtual int32_t skipElementsBySomeUnits(int32_t i, int32_t byteIndex, int32_t count) const;\n    virtual int32_t indexOfElementWithNextUnit(int32_t i, int32_t byteIndex, UChar byte) const;\n\n    virtual UBool matchNodesCanHaveValues() const { return FALSE; }\n\n    virtual int32_t getMaxBranchLinearSubNodeLength() const { return BytesTrie::kMaxBranchLinearSubNodeLength; }\n    virtual int32_t getMinLinearMatch() const { return BytesTrie::kMinLinearMatch; }\n    virtual int32_t getMaxLinearMatchLength() const { return BytesTrie::kMaxLinearMatchLength; }\n\n#ifndef U_HIDE_INTERNAL_API\n    /**\n     * @internal\n     */\n    class BTLinearMatchNode : public LinearMatchNode {\n    public:\n        BTLinearMatchNode(const char *units, int32_t len, Node *nextNode);\n        virtual UBool operator==(const Node &other) const;\n        virtual void write(StringTrieBuilder &builder);\n    private:\n        const char *s;\n    };\n#endif  /* U_HIDE_INTERNAL_API */\n\n    virtual Node *createLinearMatchNode(int32_t i, int32_t byteIndex, int32_t length,\n                                        Node *nextNode) const;\n\n    UBool ensureCapacity(int32_t length);\n    virtual int32_t write(int32_t byte);\n    int32_t write(const char *b, int32_t length);\n    virtual int32_t writeElementUnits(int32_t i, int32_t byteIndex, int32_t length);\n    virtual int32_t writeValueAndFinal(int32_t i, UBool isFinal);\n    virtual int32_t writeValueAndType(UBool hasValue, int32_t value, int32_t node);\n    virtual int32_t writeDeltaTo(int32_t jumpTarget);\n\n    CharString *strings;  // Pointer not object so we need not #include internal charstr.h.\n    BytesTrieElement *elements;\n    int32_t elementsCapacity;\n    int32_t elementsLength;\n\n    // Byte serialization of the trie.\n    // Grows from the back: bytesLength measures from the end of the buffer!\n    char *bytes;\n    int32_t bytesCapacity;\n    int32_t bytesLength;\n};\n\nU_NAMESPACE_END\n\n#endif  // __BYTESTRIEBUILDER_H__\n"
  },
  {
    "path": "deprecated/android/addons/icucompat/unicode/calendar.h",
    "content": "/*\n********************************************************************************\n*   Copyright (C) 1997-2012, International Business Machines\n*   Corporation and others.  All Rights Reserved.\n********************************************************************************\n*\n* File CALENDAR.H\n*\n* Modification History:\n*\n*   Date        Name        Description\n*   04/22/97    aliu        Expanded and corrected comments and other header\n*                           contents.\n*   05/01/97    aliu        Made equals(), before(), after() arguments const.\n*   05/20/97    aliu        Replaced fAreFieldsSet with fAreFieldsInSync and\n*                           fAreAllFieldsSet.\n*   07/27/98    stephen     Sync up with JDK 1.2\n*   11/15/99    weiv        added YEAR_WOY and DOW_LOCAL\n*                           to EDateFields\n*    8/19/2002  srl         Removed Javaisms\n*   11/07/2003  srl         Update, clean up documentation.\n********************************************************************************\n*/\n\n#ifndef CALENDAR_H\n#define CALENDAR_H\n\n#include \"unicode/utypes.h\"\n\n/**\n * \\file \n * \\brief C++ API: Calendar object\n */\n#if !UCONFIG_NO_FORMATTING\n\n#include \"unicode/uobject.h\"\n#include \"unicode/locid.h\"\n#include \"unicode/timezone.h\"\n#include \"unicode/ucal.h\"\n#include \"unicode/umisc.h\"\n\nU_NAMESPACE_BEGIN\n\nclass ICUServiceFactory;\n\n/**\n * @internal\n */\ntypedef int32_t UFieldResolutionTable[12][8];\n\nclass BasicTimeZone;\n/**\n * <code>Calendar</code> is an abstract base class for converting between\n * a <code>UDate</code> object and a set of integer fields such as\n * <code>YEAR</code>, <code>MONTH</code>, <code>DAY</code>, <code>HOUR</code>,\n * and so on. (A <code>UDate</code> object represents a specific instant in\n * time with millisecond precision. See UDate\n * for information about the <code>UDate</code> class.)\n *\n * <p>\n * Subclasses of <code>Calendar</code> interpret a <code>UDate</code>\n * according to the rules of a specific calendar system.\n * The most commonly used subclass of <code>Calendar</code> is\n * <code>GregorianCalendar</code>. Other subclasses could represent\n * the various types of lunar calendars in use in many parts of the world.\n *\n * <p>\n * <b>NOTE</b>: (ICU 2.6) The subclass interface should be considered unstable\n * - it WILL change.\n *\n * <p>\n * Like other locale-sensitive classes, <code>Calendar</code> provides a\n * static method, <code>createInstance</code>, for getting a generally useful\n * object of this type. <code>Calendar</code>'s <code>createInstance</code> method\n * returns the appropriate <code>Calendar</code> subclass whose\n * time fields have been initialized with the current date and time:\n * \\htmlonly<blockquote>\\endhtmlonly\n * <pre>\n * Calendar *rightNow = Calendar::createInstance(errCode);\n * </pre>\n * \\htmlonly</blockquote>\\endhtmlonly\n *\n * <p>\n * A <code>Calendar</code> object can produce all the time field values\n * needed to implement the date-time formatting for a particular language\n * and calendar style (for example, Japanese-Gregorian, Japanese-Traditional).\n *\n * <p>\n * When computing a <code>UDate</code> from time fields, some special circumstances\n * may arise: there may be insufficient information to compute the\n * <code>UDate</code> (such as only year and month but no day in the month),\n * there may be inconsistent information (such as \"Tuesday, July 15, 1996\"\n * -- July 15, 1996 is actually a Monday), or the input time might be ambiguous\n * because of time zone transition.\n *\n * <p>\n * <strong>Insufficient information.</strong> The calendar will use default\n * information to specify the missing fields. This may vary by calendar; for\n * the Gregorian calendar, the default for a field is the same as that of the\n * start of the epoch: i.e., YEAR = 1970, MONTH = JANUARY, DATE = 1, etc.\n *\n * <p>\n * <strong>Inconsistent information.</strong> If fields conflict, the calendar\n * will give preference to fields set more recently. For example, when\n * determining the day, the calendar will look for one of the following\n * combinations of fields.  The most recent combination, as determined by the\n * most recently set single field, will be used.\n *\n * \\htmlonly<blockquote>\\endhtmlonly\n * <pre>\n * MONTH + DAY_OF_MONTH\n * MONTH + WEEK_OF_MONTH + DAY_OF_WEEK\n * MONTH + DAY_OF_WEEK_IN_MONTH + DAY_OF_WEEK\n * DAY_OF_YEAR\n * DAY_OF_WEEK + WEEK_OF_YEAR\n * </pre>\n * \\htmlonly</blockquote>\\endhtmlonly\n *\n * For the time of day:\n *\n * \\htmlonly<blockquote>\\endhtmlonly\n * <pre>\n * HOUR_OF_DAY\n * AM_PM + HOUR\n * </pre>\n * \\htmlonly</blockquote>\\endhtmlonly\n *\n * <p>\n * <strong>Ambiguous Wall Clock Time.</strong> When time offset from UTC has\n * changed, it produces ambiguous time slot around the transition. For example,\n * many US locations observe daylight saving time. On the date switching to daylight\n * saving time in US, wall clock time jumps from 1:00 AM (standard) to 2:00 AM\n * (daylight). Therefore, wall clock time from 1:00 AM to 1:59 AM do not exist on\n * the date. When the input wall time fall into this missing time slot, the ICU\n * Calendar resolves the time using the UTC offset before the transition by default.\n * In this example, 1:30 AM is interpreted as 1:30 AM standard time (non-exist),\n * so the final result will be 2:30 AM daylight time.\n * \n * <p>On the date switching back to standard time, wall clock time is moved back one\n * hour at 2:00 AM. So wall clock time from 1:00 AM to 1:59 AM occur twice. In this\n * case, the ICU Calendar resolves the time using the UTC offset after the transition\n * by default. For example, 1:30 AM on the date is resolved as 1:30 AM standard time.\n *\n * <p>Ambiguous wall clock time resolution behaviors can be customized by Calendar APIs\n * {@link #setRepeatedWallTimeOption} and {@link #setSkippedWallTimeOption}.\n * These methods are available in ICU 49 or later versions.\n *\n * <p>\n * <strong>Note:</strong> for some non-Gregorian calendars, different\n * fields may be necessary for complete disambiguation. For example, a full\n * specification of the historial Arabic astronomical calendar requires year,\n * month, day-of-month <em>and</em> day-of-week in some cases.\n *\n * <p>\n * <strong>Note:</strong> There are certain possible ambiguities in\n * interpretation of certain singular times, which are resolved in the\n * following ways:\n * <ol>\n *     <li> 24:00:00 \"belongs\" to the following day. That is,\n *          23:59 on Dec 31, 1969 &lt; 24:00 on Jan 1, 1970 &lt; 24:01:00 on Jan 1, 1970\n *\n *     <li> Although historically not precise, midnight also belongs to \"am\",\n *          and noon belongs to \"pm\", so on the same day,\n *          12:00 am (midnight) &lt; 12:01 am, and 12:00 pm (noon) &lt; 12:01 pm\n * </ol>\n *\n * <p>\n * The date or time format strings are not part of the definition of a\n * calendar, as those must be modifiable or overridable by the user at\n * runtime. Use {@link DateFormat}\n * to format dates.\n *\n * <p>\n * <code>Calendar</code> provides an API for field \"rolling\", where fields\n * can be incremented or decremented, but wrap around. For example, rolling the\n * month up in the date <code>December 12, <b>1996</b></code> results in\n * <code>January 12, <b>1996</b></code>.\n *\n * <p>\n * <code>Calendar</code> also provides a date arithmetic function for\n * adding the specified (signed) amount of time to a particular time field.\n * For example, subtracting 5 days from the date <code>September 12, 1996</code>\n * results in <code>September 7, 1996</code>.\n *\n * <p><big><b>Supported range</b></big>\n *\n * <p>The allowable range of <code>Calendar</code> has been\n * narrowed. <code>GregorianCalendar</code> used to attempt to support\n * the range of dates with millisecond values from\n * <code>Long.MIN_VALUE</code> to <code>Long.MAX_VALUE</code>.\n * The new <code>Calendar</code> protocol specifies the\n * maximum range of supportable dates as those having Julian day numbers\n * of <code>-0x7F000000</code> to <code>+0x7F000000</code>. This\n * corresponds to years from ~5,800,000 BCE to ~5,800,000 CE. Programmers\n * should use the protected constants in <code>Calendar</code> to\n * specify an extremely early or extremely late date.</p>\n *\n * @stable ICU 2.0\n */\nclass U_I18N_API Calendar : public UObject {\npublic:\n\n    /**\n     * Field IDs for date and time. Used to specify date/time fields. ERA is calendar\n     * specific. Example ranges given are for illustration only; see specific Calendar\n     * subclasses for actual ranges.\n     * @deprecated ICU 2.6. Use C enum UCalendarDateFields defined in ucal.h\n     */\n    enum EDateFields {\n#ifndef U_HIDE_DEPRECATED_API\n/*\n * ERA may be defined on other platforms. To avoid any potential problems undefined it here.\n */\n#ifdef ERA\n#undef ERA\n#endif\n        ERA,                  // Example: 0..1\n        YEAR,                 // Example: 1..big number\n        MONTH,                // Example: 0..11\n        WEEK_OF_YEAR,         // Example: 1..53\n        WEEK_OF_MONTH,        // Example: 1..4\n        DATE,                 // Example: 1..31\n        DAY_OF_YEAR,          // Example: 1..365\n        DAY_OF_WEEK,          // Example: 1..7\n        DAY_OF_WEEK_IN_MONTH, // Example: 1..4, may be specified as -1\n        AM_PM,                // Example: 0..1\n        HOUR,                 // Example: 0..11\n        HOUR_OF_DAY,          // Example: 0..23\n        MINUTE,               // Example: 0..59\n        SECOND,               // Example: 0..59\n        MILLISECOND,          // Example: 0..999\n        ZONE_OFFSET,          // Example: -12*U_MILLIS_PER_HOUR..12*U_MILLIS_PER_HOUR\n        DST_OFFSET,           // Example: 0 or U_MILLIS_PER_HOUR\n        YEAR_WOY,             // 'Y' Example: 1..big number - Year of Week of Year\n        DOW_LOCAL,            // 'e' Example: 1..7 - Day of Week / Localized\n        \n        EXTENDED_YEAR,\n        JULIAN_DAY,\n        MILLISECONDS_IN_DAY,\n        IS_LEAP_MONTH,\n\n        FIELD_COUNT = UCAL_FIELD_COUNT // See ucal.h for other fields.\n#endif /* U_HIDE_DEPRECATED_API */\n    };\n\n#ifndef U_HIDE_DEPRECATED_API\n    /**\n     * Useful constant for days of week. Note: Calendar day-of-week is 1-based. Clients\n     * who create locale resources for the field of first-day-of-week should be aware of\n     * this. For instance, in US locale, first-day-of-week is set to 1, i.e., SUNDAY.\n     * @deprecated ICU 2.6. Use C enum UCalendarDaysOfWeek defined in ucal.h\n     */\n    enum EDaysOfWeek {\n        SUNDAY = 1,\n        MONDAY,\n        TUESDAY,\n        WEDNESDAY,\n        THURSDAY,\n        FRIDAY,\n        SATURDAY\n    };\n\n    /**\n     * Useful constants for month. Note: Calendar month is 0-based.\n     * @deprecated ICU 2.6. Use C enum UCalendarMonths defined in ucal.h\n     */\n    enum EMonths {\n        JANUARY,\n        FEBRUARY,\n        MARCH,\n        APRIL,\n        MAY,\n        JUNE,\n        JULY,\n        AUGUST,\n        SEPTEMBER,\n        OCTOBER,\n        NOVEMBER,\n        DECEMBER,\n        UNDECIMBER\n    };\n\n    /**\n     * Useful constants for hour in 12-hour clock. Used in GregorianCalendar.\n     * @deprecated ICU 2.6. Use C enum UCalendarAMPMs defined in ucal.h\n     */\n    enum EAmpm {\n        AM,\n        PM\n    };\n#endif  /* U_HIDE_DEPRECATED_API */\n\n    /**\n     * destructor\n     * @stable ICU 2.0\n     */\n    virtual ~Calendar();\n\n    /**\n     * Create and return a polymorphic copy of this calendar.\n     *\n     * @return    a polymorphic copy of this calendar.\n     * @stable ICU 2.0\n     */\n    virtual Calendar* clone(void) const = 0;\n\n    /**\n     * Creates a Calendar using the default timezone and locale. Clients are responsible\n     * for deleting the object returned.\n     *\n     * @param success  Indicates the success/failure of Calendar creation. Filled in\n     *                 with U_ZERO_ERROR if created successfully, set to a failure result\n     *                 otherwise. U_MISSING_RESOURCE_ERROR will be returned if the resource data\n     *                 requests a calendar type which has not been installed.\n     * @return         A Calendar if created successfully. NULL otherwise.\n     * @stable ICU 2.0\n     */\n    static Calendar* U_EXPORT2 createInstance(UErrorCode& success);\n\n    /**\n     * Creates a Calendar using the given timezone and the default locale.\n     * The Calendar takes ownership of zoneToAdopt; the\n     * client must not delete it.\n     *\n     * @param zoneToAdopt  The given timezone to be adopted.\n     * @param success      Indicates the success/failure of Calendar creation. Filled in\n     *                     with U_ZERO_ERROR if created successfully, set to a failure result\n     *                     otherwise.\n     * @return             A Calendar if created successfully. NULL otherwise.\n     * @stable ICU 2.0\n     */\n    static Calendar* U_EXPORT2 createInstance(TimeZone* zoneToAdopt, UErrorCode& success);\n\n    /**\n     * Creates a Calendar using the given timezone and the default locale.  The TimeZone\n     * is _not_ adopted; the client is still responsible for deleting it.\n     *\n     * @param zone  The timezone.\n     * @param success      Indicates the success/failure of Calendar creation. Filled in\n     *                     with U_ZERO_ERROR if created successfully, set to a failure result\n     *                     otherwise.\n     * @return             A Calendar if created successfully. NULL otherwise.\n     * @stable ICU 2.0\n     */\n    static Calendar* U_EXPORT2 createInstance(const TimeZone& zone, UErrorCode& success);\n\n    /**\n     * Creates a Calendar using the default timezone and the given locale.\n     *\n     * @param aLocale  The given locale.\n     * @param success  Indicates the success/failure of Calendar creation. Filled in\n     *                 with U_ZERO_ERROR if created successfully, set to a failure result\n     *                 otherwise.\n     * @return         A Calendar if created successfully. NULL otherwise.\n     * @stable ICU 2.0\n     */\n    static Calendar* U_EXPORT2 createInstance(const Locale& aLocale, UErrorCode& success);\n\n    /**\n     * Creates a Calendar using the given timezone and given locale.\n     * The Calendar takes ownership of zoneToAdopt; the\n     * client must not delete it.\n     *\n     * @param zoneToAdopt  The given timezone to be adopted.\n     * @param aLocale      The given locale.\n     * @param success      Indicates the success/failure of Calendar creation. Filled in\n     *                     with U_ZERO_ERROR if created successfully, set to a failure result\n     *                     otherwise.\n     * @return             A Calendar if created successfully. NULL otherwise.\n     * @stable ICU 2.0\n     */\n    static Calendar* U_EXPORT2 createInstance(TimeZone* zoneToAdopt, const Locale& aLocale, UErrorCode& success);\n\n    /**\n     * Gets a Calendar using the given timezone and given locale.  The TimeZone\n     * is _not_ adopted; the client is still responsible for deleting it.\n     *\n     * @param zone         The given timezone.\n     * @param aLocale      The given locale.\n     * @param success      Indicates the success/failure of Calendar creation. Filled in\n     *                     with U_ZERO_ERROR if created successfully, set to a failure result\n     *                     otherwise.\n     * @return             A Calendar if created successfully. NULL otherwise.\n     * @stable ICU 2.0\n     */\n    static Calendar* U_EXPORT2 createInstance(const TimeZone& zone, const Locale& aLocale, UErrorCode& success);\n\n    /**\n     * Returns a list of the locales for which Calendars are installed.\n     *\n     * @param count  Number of locales returned.\n     * @return       An array of Locale objects representing the set of locales for which\n     *               Calendars are installed.  The system retains ownership of this list;\n     *               the caller must NOT delete it. Does not include user-registered Calendars.\n     * @stable ICU 2.0\n     */\n    static const Locale* U_EXPORT2 getAvailableLocales(int32_t& count);\n\n\n    /**\n     * Given a key and a locale, returns an array of string values in a preferred\n     * order that would make a difference. These are all and only those values where\n     * the open (creation) of the service with the locale formed from the input locale\n     * plus input keyword and that value has different behavior than creation with the\n     * input locale alone.\n     * @param key           one of the keys supported by this service.  For now, only\n     *                      \"calendar\" is supported.\n     * @param locale        the locale\n     * @param commonlyUsed  if set to true it will return only commonly used values\n     *                      with the given locale in preferred order.  Otherwise,\n     *                      it will return all the available values for the locale.\n     * @param status        ICU Error Code\n     * @return a string enumeration over keyword values for the given key and the locale.\n     * @stable ICU 4.2\n     */\n    static StringEnumeration* U_EXPORT2 getKeywordValuesForLocale(const char* key,\n                    const Locale& locale, UBool commonlyUsed, UErrorCode& status);\n\n    /**\n     * Returns the current UTC (GMT) time measured in milliseconds since 0:00:00 on 1/1/70\n     * (derived from the system time).\n     *\n     * @return   The current UTC time in milliseconds.\n     * @stable ICU 2.0\n     */\n    static UDate U_EXPORT2 getNow(void);\n\n    /**\n     * Gets this Calendar's time as milliseconds. May involve recalculation of time due\n     * to previous calls to set time field values. The time specified is non-local UTC\n     * (GMT) time. Although this method is const, this object may actually be changed\n     * (semantically const).\n     *\n     * @param status  Output param set to success/failure code on exit. If any value\n     *                previously set in the time field is invalid or restricted by\n     *                leniency, this will be set to an error status.\n     * @return        The current time in UTC (GMT) time, or zero if the operation\n     *                failed.\n     * @stable ICU 2.0\n     */\n    inline UDate getTime(UErrorCode& status) const { return getTimeInMillis(status); }\n\n    /**\n     * Sets this Calendar's current time with the given UDate. The time specified should\n     * be in non-local UTC (GMT) time.\n     *\n     * @param date  The given UDate in UTC (GMT) time.\n     * @param status  Output param set to success/failure code on exit. If any value\n     *                set in the time field is invalid or restricted by\n     *                leniency, this will be set to an error status.\n     * @stable ICU 2.0\n     */\n    inline void setTime(UDate date, UErrorCode& status) { setTimeInMillis(date, status); }\n\n    /**\n     * Compares the equality of two Calendar objects. Objects of different subclasses\n     * are considered unequal. This comparison is very exacting; two Calendar objects\n     * must be in exactly the same state to be considered equal. To compare based on the\n     * represented time, use equals() instead.\n     *\n     * @param that  The Calendar object to be compared with.\n     * @return      True if the given Calendar is the same as this Calendar; false\n     *              otherwise.\n     * @stable ICU 2.0\n     */\n    virtual UBool operator==(const Calendar& that) const;\n\n    /**\n     * Compares the inequality of two Calendar objects.\n     *\n     * @param that  The Calendar object to be compared with.\n     * @return      True if the given Calendar is not the same as this Calendar; false\n     *              otherwise.\n     * @stable ICU 2.0\n     */\n    UBool operator!=(const Calendar& that) const {return !operator==(that);}\n\n    /**\n     * Returns TRUE if the given Calendar object is equivalent to this\n     * one.  An equivalent Calendar will behave exactly as this one\n     * does, but it may be set to a different time.  By contrast, for\n     * the operator==() method to return TRUE, the other Calendar must\n     * be set to the same time.\n     *\n     * @param other the Calendar to be compared with this Calendar\n     * @stable ICU 2.4\n     */\n    virtual UBool isEquivalentTo(const Calendar& other) const;\n\n    /**\n     * Compares the Calendar time, whereas Calendar::operator== compares the equality of\n     * Calendar objects.\n     *\n     * @param when    The Calendar to be compared with this Calendar. Although this is a\n     *                const parameter, the object may be modified physically\n     *                (semantically const).\n     * @param status  Output param set to success/failure code on exit. If any value\n     *                previously set in the time field is invalid or restricted by\n     *                leniency, this will be set to an error status.\n     * @return        True if the current time of this Calendar is equal to the time of\n     *                Calendar when; false otherwise.\n     * @stable ICU 2.0\n     */\n    UBool equals(const Calendar& when, UErrorCode& status) const;\n\n    /**\n     * Returns true if this Calendar's current time is before \"when\"'s current time.\n     *\n     * @param when    The Calendar to be compared with this Calendar. Although this is a\n     *                const parameter, the object may be modified physically\n     *                (semantically const).\n     * @param status  Output param set to success/failure code on exit. If any value\n     *                previously set in the time field is invalid or restricted by\n     *                leniency, this will be set to an error status.\n     * @return        True if the current time of this Calendar is before the time of\n     *                Calendar when; false otherwise.\n     * @stable ICU 2.0\n     */\n    UBool before(const Calendar& when, UErrorCode& status) const;\n\n    /**\n     * Returns true if this Calendar's current time is after \"when\"'s current time.\n     *\n     * @param when    The Calendar to be compared with this Calendar. Although this is a\n     *                const parameter, the object may be modified physically\n     *                (semantically const).\n     * @param status  Output param set to success/failure code on exit. If any value\n     *                previously set in the time field is invalid or restricted by\n     *                leniency, this will be set to an error status.\n     * @return        True if the current time of this Calendar is after the time of\n     *                Calendar when; false otherwise.\n     * @stable ICU 2.0\n     */\n    UBool after(const Calendar& when, UErrorCode& status) const;\n\n    /**\n     * UDate Arithmetic function. Adds the specified (signed) amount of time to the given\n     * time field, based on the calendar's rules. For example, to subtract 5 days from\n     * the current time of the calendar, call add(Calendar::DATE, -5). When adding on\n     * the month or Calendar::MONTH field, other fields like date might conflict and\n     * need to be changed. For instance, adding 1 month on the date 01/31/96 will result\n     * in 02/29/96.\n     * Adding a positive value always means moving forward in time, so for the Gregorian calendar,\n     * starting with 100 BC and adding +1 to year results in 99 BC (even though this actually reduces\n     * the numeric value of the field itself).\n     *\n     * @param field   Specifies which date field to modify.\n     * @param amount  The amount of time to be added to the field, in the natural unit\n     *                for that field (e.g., days for the day fields, hours for the hour\n     *                field.)\n     * @param status  Output param set to success/failure code on exit. If any value\n     *                previously set in the time field is invalid or restricted by\n     *                leniency, this will be set to an error status.\n     * @deprecated ICU 2.6. use add(UCalendarDateFields field, int32_t amount, UErrorCode& status) instead.\n     */\n    virtual void add(EDateFields field, int32_t amount, UErrorCode& status);\n\n    /**\n     * UDate Arithmetic function. Adds the specified (signed) amount of time to the given\n     * time field, based on the calendar's rules. For example, to subtract 5 days from\n     * the current time of the calendar, call add(Calendar::DATE, -5). When adding on\n     * the month or Calendar::MONTH field, other fields like date might conflict and\n     * need to be changed. For instance, adding 1 month on the date 01/31/96 will result\n     * in 02/29/96.\n     * Adding a positive value always means moving forward in time, so for the Gregorian calendar,\n     * starting with 100 BC and adding +1 to year results in 99 BC (even though this actually reduces\n     * the numeric value of the field itself).\n     *\n     * @param field   Specifies which date field to modify.\n     * @param amount  The amount of time to be added to the field, in the natural unit\n     *                for that field (e.g., days for the day fields, hours for the hour\n     *                field.)\n     * @param status  Output param set to success/failure code on exit. If any value\n     *                previously set in the time field is invalid or restricted by\n     *                leniency, this will be set to an error status.\n     * @stable ICU 2.6.\n     */\n    virtual void add(UCalendarDateFields field, int32_t amount, UErrorCode& status);\n\n#ifndef U_HIDE_DEPRECATED_API\n    /**\n     * Time Field Rolling function. Rolls (up/down) a single unit of time on the given\n     * time field. For example, to roll the current date up by one day, call\n     * roll(Calendar::DATE, true). When rolling on the year or Calendar::YEAR field, it\n     * will roll the year value in the range between getMinimum(Calendar::YEAR) and the\n     * value returned by getMaximum(Calendar::YEAR). When rolling on the month or\n     * Calendar::MONTH field, other fields like date might conflict and, need to be\n     * changed. For instance, rolling the month up on the date 01/31/96 will result in\n     * 02/29/96. Rolling up always means rolling forward in time (unless the limit of the\n     * field is reached, in which case it may pin or wrap), so for Gregorian calendar,\n     * starting with 100 BC and rolling the year up results in 99 BC.\n     * When eras have a definite beginning and end (as in the Chinese calendar, or as in\n     * most eras in the Japanese calendar) then rolling the year past either limit of the\n     * era will cause the year to wrap around. When eras only have a limit at one end,\n     * then attempting to roll the year past that limit will result in pinning the year\n     * at that limit. Note that for most calendars in which era 0 years move forward in\n     * time (such as Buddhist, Hebrew, or Islamic), it is possible for add or roll to\n     * result in negative years for era 0 (that is the only way to represent years before\n     * the calendar epoch).\n     * When rolling on the hour-in-day or Calendar::HOUR_OF_DAY field, it will roll the\n     * hour value in the range between 0 and 23, which is zero-based.\n     * <P>\n     * NOTE: Do not use this method -- use roll(EDateFields, int, UErrorCode&) instead.\n     *\n     * @param field   The time field.\n     * @param up      Indicates if the value of the specified time field is to be rolled\n     *                up or rolled down. Use true if rolling up, false otherwise.\n     * @param status  Output param set to success/failure code on exit. If any value\n     *                previously set in the time field is invalid or restricted by\n     *                leniency, this will be set to an error status.\n     * @deprecated ICU 2.6. Use roll(UCalendarDateFields field, UBool up, UErrorCode& status) instead.\n     */\n    inline void roll(EDateFields field, UBool up, UErrorCode& status);\n#endif  /* U_HIDE_DEPRECATED_API */\n\n    /**\n     * Time Field Rolling function. Rolls (up/down) a single unit of time on the given\n     * time field. For example, to roll the current date up by one day, call\n     * roll(Calendar::DATE, true). When rolling on the year or Calendar::YEAR field, it\n     * will roll the year value in the range between getMinimum(Calendar::YEAR) and the\n     * value returned by getMaximum(Calendar::YEAR). When rolling on the month or\n     * Calendar::MONTH field, other fields like date might conflict and, need to be\n     * changed. For instance, rolling the month up on the date 01/31/96 will result in\n     * 02/29/96. Rolling up always means rolling forward in time (unless the limit of the\n     * field is reached, in which case it may pin or wrap), so for Gregorian calendar,\n     * starting with 100 BC and rolling the year up results in 99 BC.\n     * When eras have a definite beginning and end (as in the Chinese calendar, or as in\n     * most eras in the Japanese calendar) then rolling the year past either limit of the\n     * era will cause the year to wrap around. When eras only have a limit at one end,\n     * then attempting to roll the year past that limit will result in pinning the year\n     * at that limit. Note that for most calendars in which era 0 years move forward in\n     * time (such as Buddhist, Hebrew, or Islamic), it is possible for add or roll to\n     * result in negative years for era 0 (that is the only way to represent years before\n     * the calendar epoch).\n     * When rolling on the hour-in-day or Calendar::HOUR_OF_DAY field, it will roll the\n     * hour value in the range between 0 and 23, which is zero-based.\n     * <P>\n     * NOTE: Do not use this method -- use roll(UCalendarDateFields, int, UErrorCode&) instead.\n     *\n     * @param field   The time field.\n     * @param up      Indicates if the value of the specified time field is to be rolled\n     *                up or rolled down. Use true if rolling up, false otherwise.\n     * @param status  Output param set to success/failure code on exit. If any value\n     *                previously set in the time field is invalid or restricted by\n     *                leniency, this will be set to an error status.\n     * @stable ICU 2.6.\n     */\n    inline void roll(UCalendarDateFields field, UBool up, UErrorCode& status);\n\n    /**\n     * Time Field Rolling function. Rolls by the given amount on the given\n     * time field. For example, to roll the current date up by one day, call\n     * roll(Calendar::DATE, +1, status). When rolling on the month or\n     * Calendar::MONTH field, other fields like date might conflict and, need to be\n     * changed. For instance, rolling the month up on the date 01/31/96 will result in\n     * 02/29/96. Rolling by a positive value always means rolling forward in time (unless\n     * the limit of the field is reached, in which case it may pin or wrap), so for\n     * Gregorian calendar, starting with 100 BC and rolling the year by + 1 results in 99 BC.\n     * When eras have a definite beginning and end (as in the Chinese calendar, or as in\n     * most eras in the Japanese calendar) then rolling the year past either limit of the\n     * era will cause the year to wrap around. When eras only have a limit at one end,\n     * then attempting to roll the year past that limit will result in pinning the year\n     * at that limit. Note that for most calendars in which era 0 years move forward in\n     * time (such as Buddhist, Hebrew, or Islamic), it is possible for add or roll to\n     * result in negative years for era 0 (that is the only way to represent years before\n     * the calendar epoch).\n     * When rolling on the hour-in-day or Calendar::HOUR_OF_DAY field, it will roll the\n     * hour value in the range between 0 and 23, which is zero-based.\n     * <P>\n     * The only difference between roll() and add() is that roll() does not change\n     * the value of more significant fields when it reaches the minimum or maximum\n     * of its range, whereas add() does.\n     *\n     * @param field   The time field.\n     * @param amount  Indicates amount to roll.\n     * @param status  Output param set to success/failure code on exit. If any value\n     *                previously set in the time field is invalid, this will be set to\n     *                an error status.\n     * @deprecated ICU 2.6. Use roll(UCalendarDateFields field, int32_t amount, UErrorCode& status) instead.\n     */\n    virtual void roll(EDateFields field, int32_t amount, UErrorCode& status);\n\n    /**\n     * Time Field Rolling function. Rolls by the given amount on the given\n     * time field. For example, to roll the current date up by one day, call\n     * roll(Calendar::DATE, +1, status). When rolling on the month or\n     * Calendar::MONTH field, other fields like date might conflict and, need to be\n     * changed. For instance, rolling the month up on the date 01/31/96 will result in\n     * 02/29/96. Rolling by a positive value always means rolling forward in time (unless\n     * the limit of the field is reached, in which case it may pin or wrap), so for\n     * Gregorian calendar, starting with 100 BC and rolling the year by + 1 results in 99 BC.\n     * When eras have a definite beginning and end (as in the Chinese calendar, or as in\n     * most eras in the Japanese calendar) then rolling the year past either limit of the\n     * era will cause the year to wrap around. When eras only have a limit at one end,\n     * then attempting to roll the year past that limit will result in pinning the year\n     * at that limit. Note that for most calendars in which era 0 years move forward in\n     * time (such as Buddhist, Hebrew, or Islamic), it is possible for add or roll to\n     * result in negative years for era 0 (that is the only way to represent years before\n     * the calendar epoch).\n     * When rolling on the hour-in-day or Calendar::HOUR_OF_DAY field, it will roll the\n     * hour value in the range between 0 and 23, which is zero-based.\n     * <P>\n     * The only difference between roll() and add() is that roll() does not change\n     * the value of more significant fields when it reaches the minimum or maximum\n     * of its range, whereas add() does.\n     *\n     * @param field   The time field.\n     * @param amount  Indicates amount to roll.\n     * @param status  Output param set to success/failure code on exit. If any value\n     *                previously set in the time field is invalid, this will be set to\n     *                an error status.\n     * @stable ICU 2.6.\n     */\n    virtual void roll(UCalendarDateFields field, int32_t amount, UErrorCode& status);\n\n    /**\n     * Return the difference between the given time and the time this\n     * calendar object is set to.  If this calendar is set\n     * <em>before</em> the given time, the returned value will be\n     * positive.  If this calendar is set <em>after</em> the given\n     * time, the returned value will be negative.  The\n     * <code>field</code> parameter specifies the units of the return\n     * value.  For example, if <code>fieldDifference(when,\n     * Calendar::MONTH)</code> returns 3, then this calendar is set to\n     * 3 months before <code>when</code>, and possibly some addition\n     * time less than one month.\n     *\n     * <p>As a side effect of this call, this calendar is advanced\n     * toward <code>when</code> by the given amount.  That is, calling\n     * this method has the side effect of calling <code>add(field,\n     * n)</code>, where <code>n</code> is the return value.\n     *\n     * <p>Usage: To use this method, call it first with the largest\n     * field of interest, then with progressively smaller fields.  For\n     * example:\n     *\n     * <pre>\n     * int y = cal->fieldDifference(when, Calendar::YEAR, err);\n     * int m = cal->fieldDifference(when, Calendar::MONTH, err);\n     * int d = cal->fieldDifference(when, Calendar::DATE, err);</pre>\n     *\n     * computes the difference between <code>cal</code> and\n     * <code>when</code> in years, months, and days.\n     *\n     * <p>Note: <code>fieldDifference()</code> is\n     * <em>asymmetrical</em>.  That is, in the following code:\n     *\n     * <pre>\n     * cal->setTime(date1, err);\n     * int m1 = cal->fieldDifference(date2, Calendar::MONTH, err);\n     * int d1 = cal->fieldDifference(date2, Calendar::DATE, err);\n     * cal->setTime(date2, err);\n     * int m2 = cal->fieldDifference(date1, Calendar::MONTH, err);\n     * int d2 = cal->fieldDifference(date1, Calendar::DATE, err);</pre>\n     *\n     * one might expect that <code>m1 == -m2 && d1 == -d2</code>.\n     * However, this is not generally the case, because of\n     * irregularities in the underlying calendar system (e.g., the\n     * Gregorian calendar has a varying number of days per month).\n     *\n     * @param when the date to compare this calendar's time to\n     * @param field the field in which to compute the result\n     * @param status  Output param set to success/failure code on exit. If any value\n     *                previously set in the time field is invalid, this will be set to\n     *                an error status.\n     * @return the difference, either positive or negative, between\n     * this calendar's time and <code>when</code>, in terms of\n     * <code>field</code>.\n     * @deprecated ICU 2.6. Use fieldDifference(UDate when, UCalendarDateFields field, UErrorCode& status).\n     */\n    virtual int32_t fieldDifference(UDate when, EDateFields field, UErrorCode& status);\n\n    /**\n     * Return the difference between the given time and the time this\n     * calendar object is set to.  If this calendar is set\n     * <em>before</em> the given time, the returned value will be\n     * positive.  If this calendar is set <em>after</em> the given\n     * time, the returned value will be negative.  The\n     * <code>field</code> parameter specifies the units of the return\n     * value.  For example, if <code>fieldDifference(when,\n     * Calendar::MONTH)</code> returns 3, then this calendar is set to\n     * 3 months before <code>when</code>, and possibly some addition\n     * time less than one month.\n     *\n     * <p>As a side effect of this call, this calendar is advanced\n     * toward <code>when</code> by the given amount.  That is, calling\n     * this method has the side effect of calling <code>add(field,\n     * n)</code>, where <code>n</code> is the return value.\n     *\n     * <p>Usage: To use this method, call it first with the largest\n     * field of interest, then with progressively smaller fields.  For\n     * example:\n     *\n     * <pre>\n     * int y = cal->fieldDifference(when, Calendar::YEAR, err);\n     * int m = cal->fieldDifference(when, Calendar::MONTH, err);\n     * int d = cal->fieldDifference(when, Calendar::DATE, err);</pre>\n     *\n     * computes the difference between <code>cal</code> and\n     * <code>when</code> in years, months, and days.\n     *\n     * <p>Note: <code>fieldDifference()</code> is\n     * <em>asymmetrical</em>.  That is, in the following code:\n     *\n     * <pre>\n     * cal->setTime(date1, err);\n     * int m1 = cal->fieldDifference(date2, Calendar::MONTH, err);\n     * int d1 = cal->fieldDifference(date2, Calendar::DATE, err);\n     * cal->setTime(date2, err);\n     * int m2 = cal->fieldDifference(date1, Calendar::MONTH, err);\n     * int d2 = cal->fieldDifference(date1, Calendar::DATE, err);</pre>\n     *\n     * one might expect that <code>m1 == -m2 && d1 == -d2</code>.\n     * However, this is not generally the case, because of\n     * irregularities in the underlying calendar system (e.g., the\n     * Gregorian calendar has a varying number of days per month).\n     *\n     * @param when the date to compare this calendar's time to\n     * @param field the field in which to compute the result\n     * @param status  Output param set to success/failure code on exit. If any value\n     *                previously set in the time field is invalid, this will be set to\n     *                an error status.\n     * @return the difference, either positive or negative, between\n     * this calendar's time and <code>when</code>, in terms of\n     * <code>field</code>.\n     * @stable ICU 2.6.\n     */\n    virtual int32_t fieldDifference(UDate when, UCalendarDateFields field, UErrorCode& status);\n\n    /**\n     * Sets the calendar's time zone to be the one passed in. The Calendar takes ownership\n     * of the TimeZone; the caller is no longer responsible for deleting it.  If the\n     * given time zone is NULL, this function has no effect.\n     *\n     * @param value  The given time zone.\n     * @stable ICU 2.0\n     */\n    void adoptTimeZone(TimeZone* value);\n\n    /**\n     * Sets the calendar's time zone to be the same as the one passed in. The TimeZone\n     * passed in is _not_ adopted; the client is still responsible for deleting it.\n     *\n     * @param zone  The given time zone.\n     * @stable ICU 2.0\n     */\n    void setTimeZone(const TimeZone& zone);\n\n    /**\n     * Returns a reference to the time zone owned by this calendar. The returned reference\n     * is only valid until clients make another call to adoptTimeZone or setTimeZone,\n     * or this Calendar is destroyed.\n     *\n     * @return   The time zone object associated with this calendar.\n     * @stable ICU 2.0\n     */\n    const TimeZone& getTimeZone(void) const;\n\n    /**\n     * Returns the time zone owned by this calendar. The caller owns the returned object\n     * and must delete it when done.  After this call, the new time zone associated\n     * with this Calendar is the default TimeZone as returned by TimeZone::createDefault().\n     *\n     * @return   The time zone object which was associated with this calendar.\n     * @stable ICU 2.0\n     */\n    TimeZone* orphanTimeZone(void);\n\n    /**\n     * Queries if the current date for this Calendar is in Daylight Savings Time.\n     *\n     * @param status Fill-in parameter which receives the status of this operation.\n     * @return   True if the current date for this Calendar is in Daylight Savings Time,\n     *           false, otherwise.\n     * @stable ICU 2.0\n     */\n    virtual UBool inDaylightTime(UErrorCode& status) const = 0;\n\n    /**\n     * Specifies whether or not date/time interpretation is to be lenient. With lenient\n     * interpretation, a date such as \"February 942, 1996\" will be treated as being\n     * equivalent to the 941st day after February 1, 1996. With strict interpretation,\n     * such dates will cause an error when computing time from the time field values\n     * representing the dates.\n     *\n     * @param lenient  True specifies date/time interpretation to be lenient.\n     *\n     * @see            DateFormat#setLenient\n     * @stable ICU 2.0\n     */\n    void setLenient(UBool lenient);\n\n    /**\n     * Tells whether date/time interpretation is to be lenient.\n     *\n     * @return   True tells that date/time interpretation is to be lenient.\n     * @stable ICU 2.0\n     */\n    UBool isLenient(void) const;\n\n#ifndef U_HIDE_DRAFT_API\n    /**\n     * Sets the behavior for handling wall time repeating multiple times\n     * at negative time zone offset transitions. For example, 1:30 AM on\n     * November 6, 2011 in US Eastern time (Ameirca/New_York) occurs twice;\n     * 1:30 AM EDT, then 1:30 AM EST one hour later. When <code>UCAL_WALLTIME_FIRST</code>\n     * is used, the wall time 1:30AM in this example will be interpreted as 1:30 AM EDT\n     * (first occurrence). When <code>UCAL_WALLTIME_LAST</code> is used, it will be\n     * interpreted as 1:30 AM EST (last occurrence). The default value is\n     * <code>UCAL_WALLTIME_LAST</code>.\n     * <p>\n     * <b>Note:</b>When <code>UCAL_WALLTIME_NEXT_VALID</code> is not a valid\n     * option for this. When the argument is neither <code>UCAL_WALLTIME_FIRST</code>\n     * nor <code>UCAL_WALLTIME_LAST</code>, this method has no effect and will keep\n     * the current setting.\n     * \n     * @param option the behavior for handling repeating wall time, either\n     * <code>UCAL_WALLTIME_FIRST</code> or <code>UCAL_WALLTIME_LAST</code>.\n     * @see #getRepeatedWallTimeOption\n     * @draft ICU 49\n     */\n    void setRepeatedWallTimeOption(UCalendarWallTimeOption option);\n\n    /**\n     * Gets the behavior for handling wall time repeating multiple times\n     * at negative time zone offset transitions.\n     * \n     * @return the behavior for handling repeating wall time, either\n     * <code>UCAL_WALLTIME_FIRST</code> or <code>UCAL_WALLTIME_LAST</code>.\n     * @see #setRepeatedWallTimeOption\n     * @draft ICU 49\n     */\n    UCalendarWallTimeOption getRepeatedWallTimeOption(void) const;\n\n    /**\n     * Sets the behavior for handling skipped wall time at positive time zone offset\n     * transitions. For example, 2:30 AM on March 13, 2011 in US Eastern time (America/New_York)\n     * does not exist because the wall time jump from 1:59 AM EST to 3:00 AM EDT. When\n     * <code>UCAL_WALLTIME_FIRST</code> is used, 2:30 AM is interpreted as 30 minutes before 3:00 AM\n     * EDT, therefore, it will be resolved as 1:30 AM EST. When <code>UCAL_WALLTIME_LAST</code>\n     * is used, 2:30 AM is interpreted as 31 minutes after 1:59 AM EST, therefore, it will be\n     * resolved as 3:30 AM EDT. When <code>UCAL_WALLTIME_NEXT_VALID</code> is used, 2:30 AM will\n     * be resolved as next valid wall time, that is 3:00 AM EDT. The default value is\n     * <code>UCAL_WALLTIME_LAST</code>.\n     * <p>\n     * <b>Note:</b>This option is effective only when this calendar is lenient.\n     * When the calendar is strict, such non-existing wall time will cause an error.\n     * \n     * @param option the behavior for handling skipped wall time at positive time zone\n     * offset transitions, one of <code>UCAL_WALLTIME_FIRST</code>, <code>UCAL_WALLTIME_LAST</code> and\n     * <code>UCAL_WALLTIME_NEXT_VALID</code>.\n     * @see #getSkippedWallTimeOption\n     * \n     * @draft ICU 49\n     */\n    void setSkippedWallTimeOption(UCalendarWallTimeOption option);\n\n    /**\n     * Gets the behavior for handling skipped wall time at positive time zone offset\n     * transitions.\n     * \n     * @return the behavior for handling skipped wall time, one of\n     * <code>UCAL_WALLTIME_FIRST</code>, <code>UCAL_WALLTIME_LAST</code>\n     * and <code>UCAL_WALLTIME_NEXT_VALID</code>.\n     * @see #setSkippedWallTimeOption\n     * @draft ICU 49\n     */\n    UCalendarWallTimeOption getSkippedWallTimeOption(void) const;\n#endif  /* U_HIDE_DRAFT_API */\n\n#ifndef U_HIDE_DEPRECATED_API\n    /**\n     * Sets what the first day of the week is; e.g., Sunday in US, Monday in France.\n     *\n     * @param value  The given first day of the week.\n     * @deprecated ICU 2.6. Use setFirstDayOfWeek(UCalendarDaysOfWeek value) instead.\n     */\n    void setFirstDayOfWeek(EDaysOfWeek value);\n#endif  /* U_HIDE_DEPRECATED_API */\n\n    /**\n     * Sets what the first day of the week is; e.g., Sunday in US, Monday in France.\n     *\n     * @param value  The given first day of the week.\n     * @stable ICU 2.6.\n     */\n    void setFirstDayOfWeek(UCalendarDaysOfWeek value);\n\n#ifndef U_HIDE_DEPRECATED_API\n    /**\n     * Gets what the first day of the week is; e.g., Sunday in US, Monday in France.\n     *\n     * @return   The first day of the week.\n     * @deprecated ICU 2.6 use the overload with error code\n     */\n    EDaysOfWeek getFirstDayOfWeek(void) const;\n#endif  /* U_HIDE_DEPRECATED_API */\n\n    /**\n     * Gets what the first day of the week is; e.g., Sunday in US, Monday in France.\n     *\n     * @param status error code\n     * @return   The first day of the week.\n     * @stable ICU 2.6\n     */\n    UCalendarDaysOfWeek getFirstDayOfWeek(UErrorCode &status) const;\n\n    /**\n     * Sets what the minimal days required in the first week of the year are; For\n     * example, if the first week is defined as one that contains the first day of the\n     * first month of a year, call the method with value 1. If it must be a full week,\n     * use value 7.\n     *\n     * @param value  The given minimal days required in the first week of the year.\n     * @stable ICU 2.0\n     */\n    void setMinimalDaysInFirstWeek(uint8_t value);\n\n    /**\n     * Gets what the minimal days required in the first week of the year are; e.g., if\n     * the first week is defined as one that contains the first day of the first month\n     * of a year, getMinimalDaysInFirstWeek returns 1. If the minimal days required must\n     * be a full week, getMinimalDaysInFirstWeek returns 7.\n     *\n     * @return   The minimal days required in the first week of the year.\n     * @stable ICU 2.0\n     */\n    uint8_t getMinimalDaysInFirstWeek(void) const;\n\n    /**\n     * Gets the minimum value for the given time field. e.g., for Gregorian\n     * DAY_OF_MONTH, 1.\n     *\n     * @param field  The given time field.\n     * @return       The minimum value for the given time field.\n     * @deprecated ICU 2.6. Use getMinimum(UCalendarDateFields field) instead.\n     */\n    virtual int32_t getMinimum(EDateFields field) const;\n\n    /**\n     * Gets the minimum value for the given time field. e.g., for Gregorian\n     * DAY_OF_MONTH, 1.\n     *\n     * @param field  The given time field.\n     * @return       The minimum value for the given time field.\n     * @stable ICU 2.6.\n     */\n    virtual int32_t getMinimum(UCalendarDateFields field) const;\n\n    /**\n     * Gets the maximum value for the given time field. e.g. for Gregorian DAY_OF_MONTH,\n     * 31.\n     *\n     * @param field  The given time field.\n     * @return       The maximum value for the given time field.\n     * @deprecated ICU 2.6. Use getMaximum(UCalendarDateFields field) instead.\n     */\n    virtual int32_t getMaximum(EDateFields field) const;\n\n    /**\n     * Gets the maximum value for the given time field. e.g. for Gregorian DAY_OF_MONTH,\n     * 31.\n     *\n     * @param field  The given time field.\n     * @return       The maximum value for the given time field.\n     * @stable ICU 2.6.\n     */\n    virtual int32_t getMaximum(UCalendarDateFields field) const;\n\n    /**\n     * Gets the highest minimum value for the given field if varies. Otherwise same as\n     * getMinimum(). For Gregorian, no difference.\n     *\n     * @param field  The given time field.\n     * @return       The highest minimum value for the given time field.\n     * @deprecated ICU 2.6. Use getGreatestMinimum(UCalendarDateFields field) instead.\n     */\n    virtual int32_t getGreatestMinimum(EDateFields field) const;\n\n    /**\n     * Gets the highest minimum value for the given field if varies. Otherwise same as\n     * getMinimum(). For Gregorian, no difference.\n     *\n     * @param field  The given time field.\n     * @return       The highest minimum value for the given time field.\n     * @stable ICU 2.6.\n     */\n    virtual int32_t getGreatestMinimum(UCalendarDateFields field) const;\n\n    /**\n     * Gets the lowest maximum value for the given field if varies. Otherwise same as\n     * getMaximum(). e.g., for Gregorian DAY_OF_MONTH, 28.\n     *\n     * @param field  The given time field.\n     * @return       The lowest maximum value for the given time field.\n     * @deprecated ICU 2.6. Use getLeastMaximum(UCalendarDateFields field) instead.\n     */\n    virtual int32_t getLeastMaximum(EDateFields field) const;\n\n    /**\n     * Gets the lowest maximum value for the given field if varies. Otherwise same as\n     * getMaximum(). e.g., for Gregorian DAY_OF_MONTH, 28.\n     *\n     * @param field  The given time field.\n     * @return       The lowest maximum value for the given time field.\n     * @stable ICU 2.6.\n     */\n    virtual int32_t getLeastMaximum(UCalendarDateFields field) const;\n\n#ifndef U_HIDE_DEPRECATED_API\n    /**\n     * Return the minimum value that this field could have, given the current date.\n     * For the Gregorian calendar, this is the same as getMinimum() and getGreatestMinimum().\n     *\n     * The version of this function on Calendar uses an iterative algorithm to determine the\n     * actual minimum value for the field.  There is almost always a more efficient way to\n     * accomplish this (in most cases, you can simply return getMinimum()).  GregorianCalendar\n     * overrides this function with a more efficient implementation.\n     *\n     * @param field    the field to determine the minimum of\n     * @param status   Fill-in parameter which receives the status of this operation.\n     * @return         the minimum of the given field for the current date of this Calendar\n     * @deprecated ICU 2.6. Use getActualMinimum(UCalendarDateFields field, UErrorCode& status) instead.\n     */\n    int32_t getActualMinimum(EDateFields field, UErrorCode& status) const;\n#endif  /* U_HIDE_DEPRECATED_API */\n\n    /**\n     * Return the minimum value that this field could have, given the current date.\n     * For the Gregorian calendar, this is the same as getMinimum() and getGreatestMinimum().\n     *\n     * The version of this function on Calendar uses an iterative algorithm to determine the\n     * actual minimum value for the field.  There is almost always a more efficient way to\n     * accomplish this (in most cases, you can simply return getMinimum()).  GregorianCalendar\n     * overrides this function with a more efficient implementation.\n     *\n     * @param field    the field to determine the minimum of\n     * @param status   Fill-in parameter which receives the status of this operation.\n     * @return         the minimum of the given field for the current date of this Calendar\n     * @stable ICU 2.6.\n     */\n    virtual int32_t getActualMinimum(UCalendarDateFields field, UErrorCode& status) const;\n\n#ifndef U_HIDE_DEPRECATED_API\n    /**\n     * Return the maximum value that this field could have, given the current date.\n     * For example, with the date \"Feb 3, 1997\" and the DAY_OF_MONTH field, the actual\n     * maximum would be 28; for \"Feb 3, 1996\" it s 29.  Similarly for a Hebrew calendar,\n     * for some years the actual maximum for MONTH is 12, and for others 13.\n     *\n     * The version of this function on Calendar uses an iterative algorithm to determine the\n     * actual maximum value for the field.  There is almost always a more efficient way to\n     * accomplish this (in most cases, you can simply return getMaximum()).  GregorianCalendar\n     * overrides this function with a more efficient implementation.\n     *\n     * @param field    the field to determine the maximum of\n     * @param status   Fill-in parameter which receives the status of this operation.\n     * @return         the maximum of the given field for the current date of this Calendar\n     * @deprecated ICU 2.6. Use getActualMaximum(UCalendarDateFields field, UErrorCode& status) instead.\n     */\n    int32_t getActualMaximum(EDateFields field, UErrorCode& status) const;\n#endif  /* U_HIDE_DEPRECATED_API */\n\n    /**\n     * Return the maximum value that this field could have, given the current date.\n     * For example, with the date \"Feb 3, 1997\" and the DAY_OF_MONTH field, the actual\n     * maximum would be 28; for \"Feb 3, 1996\" it s 29.  Similarly for a Hebrew calendar,\n     * for some years the actual maximum for MONTH is 12, and for others 13.\n     *\n     * The version of this function on Calendar uses an iterative algorithm to determine the\n     * actual maximum value for the field.  There is almost always a more efficient way to\n     * accomplish this (in most cases, you can simply return getMaximum()).  GregorianCalendar\n     * overrides this function with a more efficient implementation.\n     *\n     * @param field    the field to determine the maximum of\n     * @param status   Fill-in parameter which receives the status of this operation.\n     * @return         the maximum of the given field for the current date of this Calendar\n     * @stable ICU 2.6.\n     */\n    virtual int32_t getActualMaximum(UCalendarDateFields field, UErrorCode& status) const;\n\n#ifndef U_HIDE_DEPRECATED_API\n    /**\n     * Gets the value for a given time field. Recalculate the current time field values\n     * if the time value has been changed by a call to setTime(). Return zero for unset\n     * fields if any fields have been explicitly set by a call to set(). To force a\n     * recomputation of all fields regardless of the previous state, call complete().\n     * This method is semantically const, but may alter the object in memory.\n     *\n     * @param field  The given time field.\n     * @param status Fill-in parameter which receives the status of the operation.\n     * @return       The value for the given time field, or zero if the field is unset,\n     *               and set() has been called for any other field.\n     * @deprecated ICU 2.6. Use get(UCalendarDateFields field, UErrorCode& status) instead.\n     */\n    int32_t get(EDateFields field, UErrorCode& status) const;\n#endif  /* U_HIDE_DEPRECATED_API */\n\n    /**\n     * Gets the value for a given time field. Recalculate the current time field values\n     * if the time value has been changed by a call to setTime(). Return zero for unset\n     * fields if any fields have been explicitly set by a call to set(). To force a\n     * recomputation of all fields regardless of the previous state, call complete().\n     * This method is semantically const, but may alter the object in memory.\n     *\n     * @param field  The given time field.\n     * @param status Fill-in parameter which receives the status of the operation.\n     * @return       The value for the given time field, or zero if the field is unset,\n     *               and set() has been called for any other field.\n     * @stable ICU 2.6.\n     */\n    int32_t get(UCalendarDateFields field, UErrorCode& status) const;\n\n#ifndef U_HIDE_DEPRECATED_API\n    /**\n     * Determines if the given time field has a value set. This can affect in the\n     * resolving of time in Calendar. Unset fields have a value of zero, by definition.\n     *\n     * @param field  The given time field.\n     * @return   True if the given time field has a value set; false otherwise.\n     * @deprecated ICU 2.6. Use isSet(UCalendarDateFields field) instead.\n     */\n    UBool isSet(EDateFields field) const;\n#endif  /* U_HIDE_DEPRECATED_API */\n\n    /**\n     * Determines if the given time field has a value set. This can affect in the\n     * resolving of time in Calendar. Unset fields have a value of zero, by definition.\n     *\n     * @param field  The given time field.\n     * @return   True if the given time field has a value set; false otherwise.\n     * @stable ICU 2.6.\n     */\n    UBool isSet(UCalendarDateFields field) const;\n\n#ifndef U_HIDE_DEPRECATED_API\n    /**\n     * Sets the given time field with the given value.\n     *\n     * @param field  The given time field.\n     * @param value  The value to be set for the given time field.\n     * @deprecated ICU 2.6. Use set(UCalendarDateFields field, int32_t value) instead.\n     */\n    void set(EDateFields field, int32_t value);\n#endif  /* U_HIDE_DEPRECATED_API */\n\n    /**\n     * Sets the given time field with the given value.\n     *\n     * @param field  The given time field.\n     * @param value  The value to be set for the given time field.\n     * @stable ICU 2.6.\n     */\n    void set(UCalendarDateFields field, int32_t value);\n\n    /**\n     * Sets the values for the fields YEAR, MONTH, and DATE. Other field values are\n     * retained; call clear() first if this is not desired.\n     *\n     * @param year   The value used to set the YEAR time field.\n     * @param month  The value used to set the MONTH time field. Month value is 0-based.\n     *               e.g., 0 for January.\n     * @param date   The value used to set the DATE time field.\n     * @stable ICU 2.0\n     */\n    void set(int32_t year, int32_t month, int32_t date);\n\n    /**\n     * Sets the values for the fields YEAR, MONTH, DATE, HOUR_OF_DAY, and MINUTE. Other\n     * field values are retained; call clear() first if this is not desired.\n     *\n     * @param year    The value used to set the YEAR time field.\n     * @param month   The value used to set the MONTH time field. Month value is\n     *                0-based. E.g., 0 for January.\n     * @param date    The value used to set the DATE time field.\n     * @param hour    The value used to set the HOUR_OF_DAY time field.\n     * @param minute  The value used to set the MINUTE time field.\n     * @stable ICU 2.0\n     */\n    void set(int32_t year, int32_t month, int32_t date, int32_t hour, int32_t minute);\n\n    /**\n     * Sets the values for the fields YEAR, MONTH, DATE, HOUR_OF_DAY, MINUTE, and SECOND.\n     * Other field values are retained; call clear() first if this is not desired.\n     *\n     * @param year    The value used to set the YEAR time field.\n     * @param month   The value used to set the MONTH time field. Month value is\n     *                0-based. E.g., 0 for January.\n     * @param date    The value used to set the DATE time field.\n     * @param hour    The value used to set the HOUR_OF_DAY time field.\n     * @param minute  The value used to set the MINUTE time field.\n     * @param second  The value used to set the SECOND time field.\n     * @stable ICU 2.0\n     */\n    void set(int32_t year, int32_t month, int32_t date, int32_t hour, int32_t minute, int32_t second);\n\n    /**\n     * Clears the values of all the time fields, making them both unset and assigning\n     * them a value of zero. The field values will be determined during the next\n     * resolving of time into time fields.\n     * @stable ICU 2.0\n     */\n    void clear(void);\n\n#ifndef U_HIDE_DEPRECATED_API\n    /**\n     * Clears the value in the given time field, both making it unset and assigning it a\n     * value of zero. This field value will be determined during the next resolving of\n     * time into time fields.\n     *\n     * @param field  The time field to be cleared.\n     * @deprecated ICU 2.6. Use clear(UCalendarDateFields field) instead.\n     */\n    void clear(EDateFields field);\n#endif  /* U_HIDE_DEPRECATED_API */\n\n    /**\n     * Clears the value in the given time field, both making it unset and assigning it a\n     * value of zero. This field value will be determined during the next resolving of\n     * time into time fields.\n     *\n     * @param field  The time field to be cleared.\n     * @stable ICU 2.6.\n     */\n    void clear(UCalendarDateFields field);\n\n    /**\n     * Returns a unique class ID POLYMORPHICALLY. Pure virtual method. This method is to\n     * implement a simple version of RTTI, since not all C++ compilers support genuine\n     * RTTI. Polymorphic operator==() and clone() methods call this method.\n     * <P>\n     * Concrete subclasses of Calendar must implement getDynamicClassID() and also a\n     * static method and data member:\n     *\n     *      static UClassID getStaticClassID() { return (UClassID)&amp;fgClassID; }\n     *      static char fgClassID;\n     *\n     * @return   The class ID for this object. All objects of a given class have the\n     *           same class ID. Objects of other classes have different class IDs.\n     * @stable ICU 2.0\n     */\n    virtual UClassID getDynamicClassID(void) const = 0;\n\n    /**\n     * Returns the calendar type name string for this Calendar object.\n     * The returned string is the legacy ICU calendar attribute value,\n     * for example, \"gregorian\" or \"japanese\".\n     *\n     * See type=\"old type name\" for the calendar attribute of locale IDs\n     * at http://www.unicode.org/reports/tr35/#Key_Type_Definitions\n     *\n     * Sample code for getting the LDML/BCP 47 calendar key value:\n     * \\code\n     * const char *calType = cal->getType();\n     * if (0 == strcmp(calType, \"unknown\")) {\n     *     // deal with unknown calendar type\n     * } else {\n     *     string localeID(\"root@calendar=\");\n     *     localeID.append(calType);\n     *     char langTag[100];\n     *     UErrorCode errorCode = U_ZERO_ERROR;\n     *     int32_t length = uloc_toLanguageTag(localeID.c_str(), langTag, (int32_t)sizeof(langTag), TRUE, &errorCode);\n     *     if (U_FAILURE(errorCode)) {\n     *         // deal with errors & overflow\n     *     }\n     *     string lang(langTag, length);\n     *     size_t caPos = lang.find(\"-ca-\");\n     *     lang.erase(0, caPos + 4);\n     *     // lang now contains the LDML calendar type\n     * }\n     * \\endcode\n     *\n     * @return legacy calendar type name string\n     * @draft ICU 49\n     */\n    virtual const char * getType() const = 0;\n\n    /**\n     * Returns whether the given day of the week is a weekday, a\n     * weekend day, or a day that transitions from one to the other,\n     * in this calendar system. If a transition occurs at midnight,\n     * then the days before and after the transition will have the\n     * type UCAL_WEEKDAY or UCAL_WEEKEND. If a transition occurs at a time\n     * other than midnight, then the day of the transition will have\n     * the type UCAL_WEEKEND_ONSET or UCAL_WEEKEND_CEASE. In this case, the\n     * method getWeekendTransition() will return the point of\n     * transition.\n     * @param dayOfWeek The day of the week whose type is desired (UCAL_SUNDAY..UCAL_SATURDAY).\n     * @param status The error code for the operation.\n     * @return The UCalendarWeekdayType for the day of the week.\n     * @stable ICU 4.4\n     */\n    virtual UCalendarWeekdayType getDayOfWeekType(UCalendarDaysOfWeek dayOfWeek, UErrorCode &status) const;\n\n    /**\n     * Returns the time during the day at which the weekend begins or ends in\n     * this calendar system.  If getDayOfWeekType() rerturns UCAL_WEEKEND_ONSET\n     * for the specified dayOfWeek, return the time at which the weekend begins.\n     * If getDayOfWeekType() returns UCAL_WEEKEND_CEASE for the specified dayOfWeek,\n     * return the time at which the weekend ends. If getDayOfWeekType() returns\n     * some other UCalendarWeekdayType for the specified dayOfWeek, is it an error condition\n     * (U_ILLEGAL_ARGUMENT_ERROR).\n     * @param dayOfWeek The day of the week for which the weekend transition time is\n     * desired (UCAL_SUNDAY..UCAL_SATURDAY).\n     * @param status The error code for the operation.\n     * @return The milliseconds after midnight at which the weekend begins or ends.\n     * @stable ICU 4.4\n     */\n    virtual int32_t getWeekendTransition(UCalendarDaysOfWeek dayOfWeek, UErrorCode &status) const;\n\n    /**\n     * Returns TRUE if the given UDate is in the weekend in\n     * this calendar system.\n     * @param date The UDate in question.\n     * @param status The error code for the operation.\n     * @return TRUE if the given UDate is in the weekend in\n     * this calendar system, FALSE otherwise.\n     * @stable ICU 4.4\n     */\n    virtual UBool isWeekend(UDate date, UErrorCode &status) const;\n\n    /**\n     * Returns TRUE if this Calendar's current date-time is in the weekend in\n     * this calendar system.\n     * @return TRUE if this Calendar's current date-time is in the weekend in\n     * this calendar system, FALSE otherwise.\n     * @stable ICU 4.4\n     */\n    virtual UBool isWeekend(void) const;\n\nprotected:\n\n     /**\n      * Constructs a Calendar with the default time zone as returned by\n      * TimeZone::createInstance(), and the default locale.\n      *\n      * @param success  Indicates the status of Calendar object construction. Returns\n      *                 U_ZERO_ERROR if constructed successfully.\n     * @stable ICU 2.0\n      */\n    Calendar(UErrorCode& success);\n\n    /**\n     * Copy constructor\n     *\n     * @param source    Calendar object to be copied from\n     * @stable ICU 2.0\n     */\n    Calendar(const Calendar& source);\n\n    /**\n     * Default assignment operator\n     *\n     * @param right    Calendar object to be copied\n     * @stable ICU 2.0\n     */\n    Calendar& operator=(const Calendar& right);\n\n    /**\n     * Constructs a Calendar with the given time zone and locale. Clients are no longer\n     * responsible for deleting the given time zone object after it's adopted.\n     *\n     * @param zone     The given time zone.\n     * @param aLocale  The given locale.\n     * @param success  Indicates the status of Calendar object construction. Returns\n     *                 U_ZERO_ERROR if constructed successfully.\n     * @stable ICU 2.0\n     */\n    Calendar(TimeZone* zone, const Locale& aLocale, UErrorCode& success);\n\n    /**\n     * Constructs a Calendar with the given time zone and locale.\n     *\n     * @param zone     The given time zone.\n     * @param aLocale  The given locale.\n     * @param success  Indicates the status of Calendar object construction. Returns\n     *                 U_ZERO_ERROR if constructed successfully.\n     * @stable ICU 2.0\n     */\n    Calendar(const TimeZone& zone, const Locale& aLocale, UErrorCode& success);\n\n    /**\n     * Converts Calendar's time field values to GMT as milliseconds.\n     *\n     * @param status  Output param set to success/failure code on exit. If any value\n     *                previously set in the time field is invalid or restricted by\n     *                leniency, this will be set to an error status.\n     * @stable ICU 2.0\n     */\n    virtual void computeTime(UErrorCode& status);\n\n    /**\n     * Converts GMT as milliseconds to time field values. This allows you to sync up the\n     * time field values with a new time that is set for the calendar.  This method\n     * does NOT recompute the time first; to recompute the time, then the fields, use\n     * the method complete().\n     *\n     * @param status  Output param set to success/failure code on exit. If any value\n     *                previously set in the time field is invalid or restricted by\n     *                leniency, this will be set to an error status.\n     * @stable ICU 2.0\n     */\n    virtual void computeFields(UErrorCode& status);\n\n    /**\n     * Gets this Calendar's current time as a long.\n     *\n     * @param status  Output param set to success/failure code on exit. If any value\n     *                previously set in the time field is invalid or restricted by\n     *                leniency, this will be set to an error status.\n     * @return the current time as UTC milliseconds from the epoch.\n     * @stable ICU 2.0\n     */\n    double getTimeInMillis(UErrorCode& status) const;\n\n    /**\n     * Sets this Calendar's current time from the given long value.\n     * @param millis  the new time in UTC milliseconds from the epoch.\n     * @param status  Output param set to success/failure code on exit. If any value\n     *                previously set in the time field is invalid or restricted by\n     *                leniency, this will be set to an error status.\n     * @stable ICU 2.0\n     */\n    void setTimeInMillis( double millis, UErrorCode& status );\n\n    /**\n     * Recomputes the current time from currently set fields, and then fills in any\n     * unset fields in the time field list.\n     *\n     * @param status  Output param set to success/failure code on exit. If any value\n     *                previously set in the time field is invalid or restricted by\n     *                leniency, this will be set to an error status.\n     * @stable ICU 2.0\n     */\n    void complete(UErrorCode& status);\n\n#ifndef U_HIDE_DEPRECATED_API\n    /**\n     * Gets the value for a given time field. Subclasses can use this function to get\n     * field values without forcing recomputation of time.\n     *\n     * @param field  The given time field.\n     * @return       The value for the given time field.\n     * @deprecated ICU 2.6. Use internalGet(UCalendarDateFields field) instead.\n     */\n    inline int32_t internalGet(EDateFields field) const {return fFields[field];}\n#endif  /* U_HIDE_DEPRECATED_API */\n\n#ifndef U_HIDE_INTERNAL_API\n    /**\n     * Gets the value for a given time field. Subclasses can use this function to get\n     * field values without forcing recomputation of time. If the field's stamp is UNSET,\n     * the defaultValue is used.\n     *\n     * @param field  The given time field.\n     * @param defaultValue a default value used if the field is unset.\n     * @return       The value for the given time field.\n     * @internal\n     */\n    inline int32_t internalGet(UCalendarDateFields field, int32_t defaultValue) const {return fStamp[field]>kUnset ? fFields[field] : defaultValue;}\n\n    /**\n     * Gets the value for a given time field. Subclasses can use this function to get\n     * field values without forcing recomputation of time.\n     *\n     * @param field  The given time field.\n     * @return       The value for the given time field.\n     * @internal\n     */\n    inline int32_t internalGet(UCalendarDateFields field) const {return fFields[field];}\n#endif  /* U_HIDE_INTERNAL_API */\n\n#ifndef U_HIDE_DEPRECATED_API\n    /**\n     * Sets the value for a given time field.  This is a fast internal method for\n     * subclasses.  It does not affect the areFieldsInSync, isTimeSet, or areAllFieldsSet\n     * flags.\n     *\n     * @param field    The given time field.\n     * @param value    The value for the given time field.\n     * @deprecated ICU 2.6. Use internalSet(UCalendarDateFields field, int32_t value) instead.\n     */\n    void internalSet(EDateFields field, int32_t value);\n#endif  /* U_HIDE_DEPRECATED_API */\n\n    /**\n     * Sets the value for a given time field.  This is a fast internal method for\n     * subclasses.  It does not affect the areFieldsInSync, isTimeSet, or areAllFieldsSet\n     * flags.\n     *\n     * @param field    The given time field.\n     * @param value    The value for the given time field.\n     * @stable ICU 2.6.\n     */\n    inline void internalSet(UCalendarDateFields field, int32_t value);\n\n    /**\n     * Prepare this calendar for computing the actual minimum or maximum.\n     * This method modifies this calendar's fields; it is called on a\n     * temporary calendar.\n     * @internal\n     */\n    virtual void prepareGetActual(UCalendarDateFields field, UBool isMinimum, UErrorCode &status);\n\n    /**\n     * Limit enums. Not in sync with UCalendarLimitType (refers to internal fields).\n     * @internal\n     */\n    enum ELimitType {\n      UCAL_LIMIT_MINIMUM = 0,\n      UCAL_LIMIT_GREATEST_MINIMUM,\n      UCAL_LIMIT_LEAST_MAXIMUM,\n      UCAL_LIMIT_MAXIMUM,\n      UCAL_LIMIT_COUNT\n    };\n\n    /**\n     * Subclass API for defining limits of different types.\n     * Subclasses must implement this method to return limits for the\n     * following fields:\n     *\n     * <pre>UCAL_ERA\n     * UCAL_YEAR\n     * UCAL_MONTH\n     * UCAL_WEEK_OF_YEAR\n     * UCAL_WEEK_OF_MONTH\n     * UCAL_DATE (DAY_OF_MONTH on Java)\n     * UCAL_DAY_OF_YEAR\n     * UCAL_DAY_OF_WEEK_IN_MONTH\n     * UCAL_YEAR_WOY\n     * UCAL_EXTENDED_YEAR</pre>\n     *\n     * @param field one of the above field numbers\n     * @param limitType one of <code>MINIMUM</code>, <code>GREATEST_MINIMUM</code>,\n     * <code>LEAST_MAXIMUM</code>, or <code>MAXIMUM</code>\n     * @internal\n     */\n    virtual int32_t handleGetLimit(UCalendarDateFields field, ELimitType limitType) const = 0;\n\n    /**\n     * Return a limit for a field.\n     * @param field the field, from <code>0..UCAL_MAX_FIELD</code>\n     * @param limitType the type specifier for the limit\n     * @see #ELimitType\n     * @internal\n     */\n    virtual int32_t getLimit(UCalendarDateFields field, ELimitType limitType) const;\n\n\n    /**\n     * Return the Julian day number of day before the first day of the\n     * given month in the given extended year.  Subclasses should override\n     * this method to implement their calendar system.\n     * @param eyear the extended year\n     * @param month the zero-based month, or 0 if useMonth is false\n     * @param useMonth if false, compute the day before the first day of\n     * the given year, otherwise, compute the day before the first day of\n     * the given month\n     * @return the Julian day number of the day before the first\n     * day of the given month and year\n     * @internal\n     */\n    virtual int32_t handleComputeMonthStart(int32_t eyear, int32_t month,\n                                                   UBool useMonth) const  = 0;\n\n    /**\n     * Return the number of days in the given month of the given extended\n     * year of this calendar system.  Subclasses should override this\n     * method if they can provide a more correct or more efficient\n     * implementation than the default implementation in Calendar.\n     * @internal\n     */\n    virtual int32_t handleGetMonthLength(int32_t extendedYear, int32_t month) const ;\n\n    /**\n     * Return the number of days in the given extended year of this\n     * calendar system.  Subclasses should override this method if they can\n     * provide a more correct or more efficient implementation than the\n     * default implementation in Calendar.\n     * @stable ICU 2.0\n     */\n    virtual int32_t handleGetYearLength(int32_t eyear) const;\n\n\n    /**\n     * Return the extended year defined by the current fields.  This will\n     * use the UCAL_EXTENDED_YEAR field or the UCAL_YEAR and supra-year fields (such\n     * as UCAL_ERA) specific to the calendar system, depending on which set of\n     * fields is newer.\n     * @return the extended year\n     * @internal\n     */\n    virtual int32_t handleGetExtendedYear() = 0;\n\n    /**\n     * Subclasses may override this.  This method calls\n     * handleGetMonthLength() to obtain the calendar-specific month\n     * length.\n     * @param bestField which field to use to calculate the date\n     * @return julian day specified by calendar fields.\n     * @internal\n     */\n    virtual int32_t handleComputeJulianDay(UCalendarDateFields bestField);\n\n    /**\n     * Subclasses must override this to convert from week fields\n     * (YEAR_WOY and WEEK_OF_YEAR) to an extended year in the case\n     * where YEAR, EXTENDED_YEAR are not set.\n     * The Calendar implementation assumes yearWoy is in extended gregorian form\n     * @internal\n     * @return the extended year, UCAL_EXTENDED_YEAR\n     */\n    virtual int32_t handleGetExtendedYearFromWeekFields(int32_t yearWoy, int32_t woy);\n\n#ifndef U_HIDE_INTERNAL_API\n    /**\n     * Compute the Julian day from fields.  Will determine whether to use\n     * the JULIAN_DAY field directly, or other fields.\n     * @return the julian day\n     * @internal\n     */\n    int32_t computeJulianDay();\n\n    /**\n     * Compute the milliseconds in the day from the fields.  This is a\n     * value from 0 to 23:59:59.999 inclusive, unless fields are out of\n     * range, in which case it can be an arbitrary value.  This value\n     * reflects local zone wall time.\n     * @internal\n     */\n    int32_t computeMillisInDay();\n\n    /**\n     * This method can assume EXTENDED_YEAR has been set.\n     * @param millis milliseconds of the date fields\n     * @param millisInDay milliseconds of the time fields; may be out\n     * or range.\n     * @param ec Output param set to failure code on function return\n     *          when this function fails.\n     * @internal\n     */\n    int32_t computeZoneOffset(double millis, int32_t millisInDay, UErrorCode &ec);\n\n\n    /**\n     * Determine the best stamp in a range.\n     * @param start first enum to look at\n     * @param end last enum to look at\n     * @param bestSoFar stamp prior to function call\n     * @return the stamp value of the best stamp\n     * @internal\n     */\n    int32_t newestStamp(UCalendarDateFields start, UCalendarDateFields end, int32_t bestSoFar) const;\n\n    /**\n     * Values for field resolution tables\n     * @see #resolveFields\n     * @internal\n     */\n    enum {\n      /** Marker for end of resolve set (row or group). */\n      kResolveSTOP = -1,\n      /** Value to be bitwised \"ORed\" against resolve table field values for remapping.  Example: (UCAL_DATE | kResolveRemap) in 1st column will cause 'UCAL_DATE' to be returned, but will not examine the value of UCAL_DATE.  */\n      kResolveRemap = 32\n    };\n\n    /**\n     * Precedence table for Dates\n     * @see #resolveFields\n     * @internal\n     */\n    static const UFieldResolutionTable kDatePrecedence[];\n\n    /**\n     * Precedence table for Year\n     * @see #resolveFields\n     * @internal\n     */\n    static const UFieldResolutionTable kYearPrecedence[];\n\n    /**\n     * Precedence table for Day of Week\n     * @see #resolveFields\n     * @internal\n     */\n    static const UFieldResolutionTable kDOWPrecedence[];\n\n    /**\n     * Given a precedence table, return the newest field combination in\n     * the table, or UCAL_FIELD_COUNT if none is found.\n     *\n     * <p>The precedence table is a 3-dimensional array of integers.  It\n     * may be thought of as an array of groups.  Each group is an array of\n     * lines.  Each line is an array of field numbers.  Within a line, if\n     * all fields are set, then the time stamp of the line is taken to be\n     * the stamp of the most recently set field.  If any field of a line is\n     * unset, then the line fails to match.  Within a group, the line with\n     * the newest time stamp is selected.  The first field of the line is\n     * returned to indicate which line matched.\n     *\n     * <p>In some cases, it may be desirable to map a line to field that\n     * whose stamp is NOT examined.  For example, if the best field is\n     * DAY_OF_WEEK then the DAY_OF_WEEK_IN_MONTH algorithm may be used.  In\n     * order to do this, insert the value <code>kResolveRemap | F</code> at\n     * the start of the line, where <code>F</code> is the desired return\n     * field value.  This field will NOT be examined; it only determines\n     * the return value if the other fields in the line are the newest.\n     *\n     * <p>If all lines of a group contain at least one unset field, then no\n     * line will match, and the group as a whole will fail to match.  In\n     * that case, the next group will be processed.  If all groups fail to\n     * match, then UCAL_FIELD_COUNT is returned.\n     * @internal\n     */\n    UCalendarDateFields resolveFields(const UFieldResolutionTable *precedenceTable);\n#endif  /* U_HIDE_INTERNAL_API */\n\n\n    /**\n     * @internal\n     */\n    virtual const UFieldResolutionTable* getFieldResolutionTable() const;\n\n#ifndef U_HIDE_INTERNAL_API\n    /**\n     * Return the field that is newer, either defaultField, or\n     * alternateField.  If neither is newer or neither is set, return defaultField.\n     * @internal\n     */\n    UCalendarDateFields newerField(UCalendarDateFields defaultField, UCalendarDateFields alternateField) const;\n#endif  /* U_HIDE_INTERNAL_API */\n\n\nprivate:\n    /**\n     * Helper function for calculating limits by trial and error\n     * @param field The field being investigated\n     * @param startValue starting (least max) value of field\n     * @param endValue ending (greatest max) value of field\n     * @param status return type\n     * @internal\n     */\n    int32_t getActualHelper(UCalendarDateFields field, int32_t startValue, int32_t endValue, UErrorCode &status) const;\n\n\nprotected:\n    /**\n     * The flag which indicates if the current time is set in the calendar.\n     * @stable ICU 2.0\n     */\n    UBool      fIsTimeSet;\n\n    /**\n     * True if the fields are in sync with the currently set time of this Calendar.\n     * If false, then the next attempt to get the value of a field will\n     * force a recomputation of all fields from the current value of the time\n     * field.\n     * <P>\n     * This should really be named areFieldsInSync, but the old name is retained\n     * for backward compatibility.\n     * @stable ICU 2.0\n     */\n    UBool      fAreFieldsSet;\n\n    /**\n     * True if all of the fields have been set.  This is initially false, and set to\n     * true by computeFields().\n     * @stable ICU 2.0\n     */\n    UBool      fAreAllFieldsSet;\n\n    /**\n     * True if all fields have been virtually set, but have not yet been\n     * computed.  This occurs only in setTimeInMillis().  A calendar set\n     * to this state will compute all fields from the time if it becomes\n     * necessary, but otherwise will delay such computation.\n     * @stable ICU 3.0\n     */\n    UBool fAreFieldsVirtuallySet;\n\n    /**\n     * Get the current time without recomputing.\n     *\n     * @return     the current time without recomputing.\n     * @stable ICU 2.0\n     */\n    UDate        internalGetTime(void) const     { return fTime; }\n\n    /**\n     * Set the current time without affecting flags or fields.\n     *\n     * @param time    The time to be set\n     * @return        the current time without recomputing.\n     * @stable ICU 2.0\n     */\n    void        internalSetTime(UDate time)     { fTime = time; }\n\n    /**\n     * The time fields containing values into which the millis is computed.\n     * @stable ICU 2.0\n     */\n    int32_t     fFields[UCAL_FIELD_COUNT];\n\n    /**\n     * The flags which tell if a specified time field for the calendar is set.\n     * @deprecated ICU 2.8 use (fStamp[n]!=kUnset)\n     */\n    UBool      fIsSet[UCAL_FIELD_COUNT];\n\n    /** Special values of stamp[]\n     * @stable ICU 2.0\n     */\n    enum {\n        kUnset                 = 0,\n        kInternallySet,\n        kMinimumUserStamp\n    };\n\n    /**\n     * Pseudo-time-stamps which specify when each field was set. There\n     * are two special values, UNSET and INTERNALLY_SET. Values from\n     * MINIMUM_USER_SET to Integer.MAX_VALUE are legal user set values.\n     * @stable ICU 2.0\n     */\n    int32_t        fStamp[UCAL_FIELD_COUNT];\n\n    /**\n     * Subclasses may override this method to compute several fields\n     * specific to each calendar system.  These are:\n     *\n     * <ul><li>ERA\n     * <li>YEAR\n     * <li>MONTH\n     * <li>DAY_OF_MONTH\n     * <li>DAY_OF_YEAR\n     * <li>EXTENDED_YEAR</ul>\n     *\n     * Subclasses can refer to the DAY_OF_WEEK and DOW_LOCAL fields, which\n     * will be set when this method is called.  Subclasses can also call\n     * the getGregorianXxx() methods to obtain Gregorian calendar\n     * equivalents for the given Julian day.\n     *\n     * <p>In addition, subclasses should compute any subclass-specific\n     * fields, that is, fields from BASE_FIELD_COUNT to\n     * getFieldCount() - 1.\n     *\n     * <p>The default implementation in <code>Calendar</code> implements\n     * a pure proleptic Gregorian calendar.\n     * @internal\n     */\n    virtual void handleComputeFields(int32_t julianDay, UErrorCode &status);\n\n#ifndef U_HIDE_INTERNAL_API\n    /**\n     * Return the extended year on the Gregorian calendar as computed by\n     * <code>computeGregorianFields()</code>.\n     * @internal\n     */\n    int32_t getGregorianYear() const {\n        return fGregorianYear;\n    }\n\n    /**\n     * Return the month (0-based) on the Gregorian calendar as computed by\n     * <code>computeGregorianFields()</code>.\n     * @internal\n     */\n    int32_t getGregorianMonth() const {\n        return fGregorianMonth;\n    }\n\n    /**\n     * Return the day of year (1-based) on the Gregorian calendar as\n     * computed by <code>computeGregorianFields()</code>.\n     * @internal\n     */\n    int32_t getGregorianDayOfYear() const {\n        return fGregorianDayOfYear;\n    }\n\n    /**\n     * Return the day of month (1-based) on the Gregorian calendar as\n     * computed by <code>computeGregorianFields()</code>.\n     * @internal\n     */\n    int32_t getGregorianDayOfMonth() const {\n      return fGregorianDayOfMonth;\n    }\n#endif  /* U_HIDE_INTERNAL_API */\n\n    /**\n     * Called by computeJulianDay.  Returns the default month (0-based) for the year,\n     * taking year and era into account.  Defaults to 0 for Gregorian, which doesn't care.\n     * @param eyear The extended year\n     * @internal\n     */\n    virtual int32_t getDefaultMonthInYear(int32_t eyear) ;\n\n\n    /**\n     * Called by computeJulianDay.  Returns the default day (1-based) for the month,\n     * taking currently-set year and era into account.  Defaults to 1 for Gregorian.\n     * @param eyear the extended year\n     * @param month the month in the year\n     * @internal\n     */\n    virtual int32_t getDefaultDayInMonth(int32_t eyear, int32_t month);\n\n    //-------------------------------------------------------------------------\n    // Protected utility methods for use by subclasses.  These are very handy\n    // for implementing add, roll, and computeFields.\n    //-------------------------------------------------------------------------\n\n    /**\n     * Adjust the specified field so that it is within\n     * the allowable range for the date to which this calendar is set.\n     * For example, in a Gregorian calendar pinning the {@link #UCalendarDateFields DAY_OF_MONTH}\n     * field for a calendar set to April 31 would cause it to be set\n     * to April 30.\n     * <p>\n     * <b>Subclassing:</b>\n     * <br>\n     * This utility method is intended for use by subclasses that need to implement\n     * their own overrides of {@link #roll roll} and {@link #add add}.\n     * <p>\n     * <b>Note:</b>\n     * <code>pinField</code> is implemented in terms of\n     * {@link #getActualMinimum getActualMinimum}\n     * and {@link #getActualMaximum getActualMaximum}.  If either of those methods uses\n     * a slow, iterative algorithm for a particular field, it would be\n     * unwise to attempt to call <code>pinField</code> for that field.  If you\n     * really do need to do so, you should override this method to do\n     * something more efficient for that field.\n     * <p>\n     * @param field The calendar field whose value should be pinned.\n     * @param status Output param set to failure code on function return\n     *          when this function fails.\n     *\n     * @see #getActualMinimum\n     * @see #getActualMaximum\n     * @stable ICU 2.0\n     */\n    virtual void pinField(UCalendarDateFields field, UErrorCode& status);\n\n    /**\n     * Return the week number of a day, within a period. This may be the week number in\n     * a year or the week number in a month. Usually this will be a value >= 1, but if\n     * some initial days of the period are excluded from week 1, because\n     * {@link #getMinimalDaysInFirstWeek getMinimalDaysInFirstWeek} is > 1, then\n     * the week number will be zero for those\n     * initial days. This method requires the day number and day of week for some\n     * known date in the period in order to determine the day of week\n     * on the desired day.\n     * <p>\n     * <b>Subclassing:</b>\n     * <br>\n     * This method is intended for use by subclasses in implementing their\n     * {@link #computeTime computeTime} and/or {@link #computeFields computeFields} methods.\n     * It is often useful in {@link #getActualMinimum getActualMinimum} and\n     * {@link #getActualMaximum getActualMaximum} as well.\n     * <p>\n     * This variant is handy for computing the week number of some other\n     * day of a period (often the first or last day of the period) when its day\n     * of the week is not known but the day number and day of week for some other\n     * day in the period (e.g. the current date) <em>is</em> known.\n     * <p>\n     * @param desiredDay    The {@link #UCalendarDateFields DAY_OF_YEAR} or\n     *              {@link #UCalendarDateFields DAY_OF_MONTH} whose week number is desired.\n     *              Should be 1 for the first day of the period.\n     *\n     * @param dayOfPeriod   The {@link #UCalendarDateFields DAY_OF_YEAR}\n     *              or {@link #UCalendarDateFields DAY_OF_MONTH} for a day in the period whose\n     *              {@link #UCalendarDateFields DAY_OF_WEEK} is specified by the\n     *              <code>knownDayOfWeek</code> parameter.\n     *              Should be 1 for first day of period.\n     *\n     * @param dayOfWeek  The {@link #UCalendarDateFields DAY_OF_WEEK} for the day\n     *              corresponding to the <code>knownDayOfPeriod</code> parameter.\n     *              1-based with 1=Sunday.\n     *\n     * @return      The week number (one-based), or zero if the day falls before\n     *              the first week because\n     *              {@link #getMinimalDaysInFirstWeek getMinimalDaysInFirstWeek}\n     *              is more than one.\n     *\n     * @stable ICU 2.8\n     */\n    int32_t weekNumber(int32_t desiredDay, int32_t dayOfPeriod, int32_t dayOfWeek);\n\n\n#ifndef U_HIDE_INTERNAL_API\n    /**\n     * Return the week number of a day, within a period. This may be the week number in\n     * a year, or the week number in a month. Usually this will be a value >= 1, but if\n     * some initial days of the period are excluded from week 1, because\n     * {@link #getMinimalDaysInFirstWeek getMinimalDaysInFirstWeek} is > 1,\n     * then the week number will be zero for those\n     * initial days. This method requires the day of week for the given date in order to\n     * determine the result.\n     * <p>\n     * <b>Subclassing:</b>\n     * <br>\n     * This method is intended for use by subclasses in implementing their\n     * {@link #computeTime computeTime} and/or {@link #computeFields computeFields} methods.\n     * It is often useful in {@link #getActualMinimum getActualMinimum} and\n     * {@link #getActualMaximum getActualMaximum} as well.\n     * <p>\n     * @param dayOfPeriod   The {@link #UCalendarDateFields DAY_OF_YEAR} or\n     *                      {@link #UCalendarDateFields DAY_OF_MONTH} whose week number is desired.\n     *                      Should be 1 for the first day of the period.\n     *\n     * @param dayOfWeek     The {@link #UCalendarDateFields DAY_OF_WEEK} for the day\n     *                      corresponding to the <code>dayOfPeriod</code> parameter.\n     *                      1-based with 1=Sunday.\n     *\n     * @return      The week number (one-based), or zero if the day falls before\n     *              the first week because\n     *              {@link #getMinimalDaysInFirstWeek getMinimalDaysInFirstWeek}\n     *              is more than one.\n     * @internal\n     */\n    inline int32_t weekNumber(int32_t dayOfPeriod, int32_t dayOfWeek);\n\n    /**\n     * returns the local DOW, valid range 0..6\n     * @internal\n     */\n    int32_t getLocalDOW();\n#endif  /* U_HIDE_INTERNAL_API */\n\nprivate:\n\n    /**\n     * The next available value for fStamp[]\n     */\n    int32_t fNextStamp;// = MINIMUM_USER_STAMP;\n\n    /**\n     * Recalculates the time stamp array (fStamp).\n     * Resets fNextStamp to lowest next stamp value.\n     */\n    void recalculateStamp();\n\n    /**\n     * The current time set for the calendar.\n     */\n    UDate        fTime;\n\n    /**\n     * @see   #setLenient\n     */\n    UBool      fLenient;\n\n    /**\n     * Time zone affects the time calculation done by Calendar. Calendar subclasses use\n     * the time zone data to produce the local time.\n     */\n    TimeZone*   fZone;\n\n    /**\n     * Option for rpeated wall time\n     * @see #setRepeatedWallTimeOption\n     */\n    UCalendarWallTimeOption fRepeatedWallTime;\n\n    /**\n     * Option for skipped wall time\n     * @see #setSkippedWallTimeOption\n     */\n    UCalendarWallTimeOption fSkippedWallTime;\n\n    /**\n     * Both firstDayOfWeek and minimalDaysInFirstWeek are locale-dependent. They are\n     * used to figure out the week count for a specific date for a given locale. These\n     * must be set when a Calendar is constructed. For example, in US locale,\n     * firstDayOfWeek is SUNDAY; minimalDaysInFirstWeek is 1. They are used to figure\n     * out the week count for a specific date for a given locale. These must be set when\n     * a Calendar is constructed.\n     */\n    UCalendarDaysOfWeek fFirstDayOfWeek;\n    uint8_t     fMinimalDaysInFirstWeek;\n    UCalendarDaysOfWeek fWeekendOnset;\n    int32_t fWeekendOnsetMillis;\n    UCalendarDaysOfWeek fWeekendCease;\n    int32_t fWeekendCeaseMillis;\n\n    /**\n     * Sets firstDayOfWeek and minimalDaysInFirstWeek. Called at Calendar construction\n     * time.\n     *\n     * @param desiredLocale  The given locale.\n     * @param type           The calendar type identifier, e.g: gregorian, buddhist, etc.\n     * @param success        Indicates the status of setting the week count data from\n     *                       the resource for the given locale. Returns U_ZERO_ERROR if\n     *                       constructed successfully.\n     */\n    void        setWeekData(const Locale& desiredLocale, const char *type, UErrorCode& success);\n\n    /**\n     * Recompute the time and update the status fields isTimeSet\n     * and areFieldsSet.  Callers should check isTimeSet and only\n     * call this method if isTimeSet is false.\n     *\n     * @param status  Output param set to success/failure code on exit. If any value\n     *                previously set in the time field is invalid or restricted by\n     *                leniency, this will be set to an error status.\n     */\n    void updateTime(UErrorCode& status);\n\n    /**\n     * The Gregorian year, as computed by computeGregorianFields() and\n     * returned by getGregorianYear().\n     * @see #computeGregorianFields\n     */\n    int32_t fGregorianYear;\n\n    /**\n     * The Gregorian month, as computed by computeGregorianFields() and\n     * returned by getGregorianMonth().\n     * @see #computeGregorianFields\n     */\n    int32_t fGregorianMonth;\n\n    /**\n     * The Gregorian day of the year, as computed by\n     * computeGregorianFields() and returned by getGregorianDayOfYear().\n     * @see #computeGregorianFields\n     */\n    int32_t fGregorianDayOfYear;\n\n    /**\n     * The Gregorian day of the month, as computed by\n     * computeGregorianFields() and returned by getGregorianDayOfMonth().\n     * @see #computeGregorianFields\n     */\n    int32_t fGregorianDayOfMonth;\n\n    /* calculations */\n\n    /**\n     * Compute the Gregorian calendar year, month, and day of month from\n     * the given Julian day.  These values are not stored in fields, but in\n     * member variables gregorianXxx.  Also compute the DAY_OF_WEEK and\n     * DOW_LOCAL fields.\n     */\n    void computeGregorianAndDOWFields(int32_t julianDay, UErrorCode &ec);\n\nprotected:\n\n    /**\n     * Compute the Gregorian calendar year, month, and day of month from the\n     * Julian day.  These values are not stored in fields, but in member\n     * variables gregorianXxx.  They are used for time zone computations and by\n     * subclasses that are Gregorian derivatives.  Subclasses may call this\n     * method to perform a Gregorian calendar millis->fields computation.\n     */\n    void computeGregorianFields(int32_t julianDay, UErrorCode &ec);\n\nprivate:\n\n    /**\n     * Compute the fields WEEK_OF_YEAR, YEAR_WOY, WEEK_OF_MONTH,\n     * DAY_OF_WEEK_IN_MONTH, and DOW_LOCAL from EXTENDED_YEAR, YEAR,\n     * DAY_OF_WEEK, and DAY_OF_YEAR.  The latter fields are computed by the\n     * subclass based on the calendar system.\n     *\n     * <p>The YEAR_WOY field is computed simplistically.  It is equal to YEAR\n     * most of the time, but at the year boundary it may be adjusted to YEAR-1\n     * or YEAR+1 to reflect the overlap of a week into an adjacent year.  In\n     * this case, a simple increment or decrement is performed on YEAR, even\n     * though this may yield an invalid YEAR value.  For instance, if the YEAR\n     * is part of a calendar system with an N-year cycle field CYCLE, then\n     * incrementing the YEAR may involve incrementing CYCLE and setting YEAR\n     * back to 0 or 1.  This is not handled by this code, and in fact cannot be\n     * simply handled without having subclasses define an entire parallel set of\n     * fields for fields larger than or equal to a year.  This additional\n     * complexity is not warranted, since the intention of the YEAR_WOY field is\n     * to support ISO 8601 notation, so it will typically be used with a\n     * proleptic Gregorian calendar, which has no field larger than a year.\n     */\n    void computeWeekFields(UErrorCode &ec);\n\n\n    /**\n     * Ensure that each field is within its valid range by calling {@link\n     * #validateField(int, int&)} on each field that has been set.  This method\n     * should only be called if this calendar is not lenient.\n     * @see #isLenient\n     * @see #validateField(int, int&)\n     * @internal\n     */\n    void validateFields(UErrorCode &status);\n\n    /**\n     * Validate a single field of this calendar.  Subclasses should\n     * override this method to validate any calendar-specific fields.\n     * Generic fields can be handled by\n     * <code>Calendar::validateField()</code>.\n     * @see #validateField(int, int, int, int&)\n     * @internal\n     */\n    virtual void validateField(UCalendarDateFields field, UErrorCode &status);\n\n    /**\n     * Validate a single field of this calendar given its minimum and\n     * maximum allowed value.  If the field is out of range,\n     * <code>U_ILLEGAL_ARGUMENT_ERROR</code> will be set.  Subclasses may\n     * use this method in their implementation of {@link\n     * #validateField(int, int&)}.\n     * @internal\n     */\n    void validateField(UCalendarDateFields field, int32_t min, int32_t max, UErrorCode& status);\n\n protected:\n#ifndef U_HIDE_INTERNAL_API\n    /**\n     * Convert a quasi Julian date to the day of the week. The Julian date used here is\n     * not a true Julian date, since it is measured from midnight, not noon. Return\n     * value is one-based.\n     *\n     * @param julian  The given Julian date number.\n     * @return   Day number from 1..7 (SUN..SAT).\n     * @internal\n     */\n    static uint8_t julianDayToDayOfWeek(double julian);\n#endif  /* U_HIDE_INTERNAL_API */\n\n private:\n    char validLocale[ULOC_FULLNAME_CAPACITY];\n    char actualLocale[ULOC_FULLNAME_CAPACITY];\n\n public:\n#if !UCONFIG_NO_SERVICE\n    /**\n     * INTERNAL FOR 2.6 --  Registration.\n     */\n\n#ifndef U_HIDE_INTERNAL_API\n    /**\n     * Return a StringEnumeration over the locales available at the time of the call,\n     * including registered locales.\n     * @return a StringEnumeration over the locales available at the time of the call\n     * @internal\n     */\n    static StringEnumeration* getAvailableLocales(void);\n\n    /**\n     * Register a new Calendar factory.  The factory will be adopted.\n     * INTERNAL in 2.6\n     * @param toAdopt the factory instance to be adopted\n     * @param status the in/out status code, no special meanings are assigned\n     * @return a registry key that can be used to unregister this factory\n     * @internal\n     */\n    static URegistryKey registerFactory(ICUServiceFactory* toAdopt, UErrorCode& status);\n\n    /**\n     * Unregister a previously-registered CalendarFactory using the key returned from the\n     * register call.  Key becomes invalid after a successful call and should not be used again.\n     * The CalendarFactory corresponding to the key will be deleted.\n     * INTERNAL in 2.6\n     * @param key the registry key returned by a previous call to registerFactory\n     * @param status the in/out status code, no special meanings are assigned\n     * @return TRUE if the factory for the key was successfully unregistered\n     * @internal\n     */\n    static UBool unregister(URegistryKey key, UErrorCode& status);\n#endif  /* U_HIDE_INTERNAL_API */\n\n    /**\n     * Multiple Calendar Implementation\n     * @internal\n     */\n    friend class CalendarFactory;\n\n    /**\n     * Multiple Calendar Implementation\n     * @internal\n     */\n    friend class CalendarService;\n\n    /**\n     * Multiple Calendar Implementation\n     * @internal\n     */\n    friend class DefaultCalendarFactory;\n#endif /* !UCONFIG_NO_SERVICE */\n\n    /**\n     * @internal\n     * @return TRUE if this calendar has a default century (i.e. 03 -> 2003)\n     */\n    virtual UBool haveDefaultCentury() const = 0;\n\n    /**\n     * @internal\n     * @return the start of the default century, as a UDate\n     */\n    virtual UDate defaultCenturyStart() const = 0;\n    /**\n     * @internal\n     * @return the beginning year of the default century, as a year\n     */\n    virtual int32_t defaultCenturyStartYear() const = 0;\n\n    /** Get the locale for this calendar object. You can choose between valid and actual locale.\n     *  @param type type of the locale we're looking for (valid or actual)\n     *  @param status error code for the operation\n     *  @return the locale\n     *  @stable ICU 2.8\n     */\n    Locale getLocale(ULocDataLocaleType type, UErrorCode &status) const;\n\n#ifndef U_HIDE_INTERNAL_API\n    /** Get the locale for this calendar object. You can choose between valid and actual locale.\n     *  @param type type of the locale we're looking for (valid or actual)\n     *  @param status error code for the operation\n     *  @return the locale\n     *  @internal\n     */\n    const char* getLocaleID(ULocDataLocaleType type, UErrorCode &status) const;\n#endif  /* U_HIDE_INTERNAL_API */\n\nprivate:\n    /**\n     * Cast TimeZone used by this object to BasicTimeZone, or NULL if the TimeZone\n     * is not an instance of BasicTimeZone.\n     */\n    BasicTimeZone* getBasicTimeZone() const;\n};\n\n// -------------------------------------\n\ninline Calendar*\nCalendar::createInstance(TimeZone* zone, UErrorCode& errorCode)\n{\n    // since the Locale isn't specified, use the default locale\n    return createInstance(zone, Locale::getDefault(), errorCode);\n}\n\n// -------------------------------------\n\ninline void\nCalendar::roll(UCalendarDateFields field, UBool up, UErrorCode& status)\n{\n    roll(field, (int32_t)(up ? +1 : -1), status);\n}\n\n#ifndef U_HIDE_DEPRECATED_API\ninline void\nCalendar::roll(EDateFields field, UBool up, UErrorCode& status)\n{\n    roll((UCalendarDateFields) field, up, status);\n}\n#endif\n\n\n// -------------------------------------\n\n/**\n * Fast method for subclasses.  The caller must maintain fUserSetDSTOffset and\n * fUserSetZoneOffset, as well as the isSet[] array.\n */\n\ninline void\nCalendar::internalSet(UCalendarDateFields field, int32_t value)\n{\n    fFields[field] = value;\n    fStamp[field] = kInternallySet;\n    fIsSet[field]     = TRUE; // Remove later\n}\n\n\n#ifndef U_HIDE_INTERNAL_API\ninline int32_t  Calendar::weekNumber(int32_t dayOfPeriod, int32_t dayOfWeek)\n{\n  return weekNumber(dayOfPeriod, dayOfPeriod, dayOfWeek);\n}\n#endif\n\nU_NAMESPACE_END\n\n#endif /* #if !UCONFIG_NO_FORMATTING */\n\n#endif // _CALENDAR\n"
  },
  {
    "path": "deprecated/android/addons/icucompat/unicode/caniter.h",
    "content": "/*\n *******************************************************************************\n * Copyright (C) 1996-2011, International Business Machines Corporation and\n * others. All Rights Reserved.\n *******************************************************************************\n */\n\n#ifndef CANITER_H\n#define CANITER_H\n\n#include \"unicode/utypes.h\"\n\n#if !UCONFIG_NO_NORMALIZATION\n\n#include \"unicode/uobject.h\"\n#include \"unicode/unistr.h\"\n\n/**\n * \\file\n * \\brief C++ API: Canonical Iterator\n */\n \n/** Should permutation skip characters with combining class zero\n *  Should be either TRUE or FALSE. This is a compile time option\n *  @stable ICU 2.4\n */\n#ifndef CANITER_SKIP_ZEROES\n#define CANITER_SKIP_ZEROES TRUE\n#endif\n\nU_NAMESPACE_BEGIN\n\nclass Hashtable;\nclass Normalizer2;\nclass Normalizer2Impl;\n\n/**\n * This class allows one to iterate through all the strings that are canonically equivalent to a given\n * string. For example, here are some sample results:\nResults for: {LATIN CAPITAL LETTER A WITH RING ABOVE}{LATIN SMALL LETTER D}{COMBINING DOT ABOVE}{COMBINING CEDILLA}\n1: \\\\u0041\\\\u030A\\\\u0064\\\\u0307\\\\u0327\n = {LATIN CAPITAL LETTER A}{COMBINING RING ABOVE}{LATIN SMALL LETTER D}{COMBINING DOT ABOVE}{COMBINING CEDILLA}\n2: \\\\u0041\\\\u030A\\\\u0064\\\\u0327\\\\u0307\n = {LATIN CAPITAL LETTER A}{COMBINING RING ABOVE}{LATIN SMALL LETTER D}{COMBINING CEDILLA}{COMBINING DOT ABOVE}\n3: \\\\u0041\\\\u030A\\\\u1E0B\\\\u0327\n = {LATIN CAPITAL LETTER A}{COMBINING RING ABOVE}{LATIN SMALL LETTER D WITH DOT ABOVE}{COMBINING CEDILLA}\n4: \\\\u0041\\\\u030A\\\\u1E11\\\\u0307\n = {LATIN CAPITAL LETTER A}{COMBINING RING ABOVE}{LATIN SMALL LETTER D WITH CEDILLA}{COMBINING DOT ABOVE}\n5: \\\\u00C5\\\\u0064\\\\u0307\\\\u0327\n = {LATIN CAPITAL LETTER A WITH RING ABOVE}{LATIN SMALL LETTER D}{COMBINING DOT ABOVE}{COMBINING CEDILLA}\n6: \\\\u00C5\\\\u0064\\\\u0327\\\\u0307\n = {LATIN CAPITAL LETTER A WITH RING ABOVE}{LATIN SMALL LETTER D}{COMBINING CEDILLA}{COMBINING DOT ABOVE}\n7: \\\\u00C5\\\\u1E0B\\\\u0327\n = {LATIN CAPITAL LETTER A WITH RING ABOVE}{LATIN SMALL LETTER D WITH DOT ABOVE}{COMBINING CEDILLA}\n8: \\\\u00C5\\\\u1E11\\\\u0307\n = {LATIN CAPITAL LETTER A WITH RING ABOVE}{LATIN SMALL LETTER D WITH CEDILLA}{COMBINING DOT ABOVE}\n9: \\\\u212B\\\\u0064\\\\u0307\\\\u0327\n = {ANGSTROM SIGN}{LATIN SMALL LETTER D}{COMBINING DOT ABOVE}{COMBINING CEDILLA}\n10: \\\\u212B\\\\u0064\\\\u0327\\\\u0307\n = {ANGSTROM SIGN}{LATIN SMALL LETTER D}{COMBINING CEDILLA}{COMBINING DOT ABOVE}\n11: \\\\u212B\\\\u1E0B\\\\u0327\n = {ANGSTROM SIGN}{LATIN SMALL LETTER D WITH DOT ABOVE}{COMBINING CEDILLA}\n12: \\\\u212B\\\\u1E11\\\\u0307\n = {ANGSTROM SIGN}{LATIN SMALL LETTER D WITH CEDILLA}{COMBINING DOT ABOVE}\n *<br>Note: the code is intended for use with small strings, and is not suitable for larger ones,\n * since it has not been optimized for that situation.\n * Note, CanonicalIterator is not intended to be subclassed.\n * @author M. Davis\n * @author C++ port by V. Weinstein\n * @stable ICU 2.4\n */\nclass U_COMMON_API CanonicalIterator : public UObject {\npublic:\n    /**\n     * Construct a CanonicalIterator object\n     * @param source    string to get results for\n     * @param status    Fill-in parameter which receives the status of this operation.\n     * @stable ICU 2.4\n     */\n    CanonicalIterator(const UnicodeString &source, UErrorCode &status);\n\n    /** Destructor\n     *  Cleans pieces\n     * @stable ICU 2.4\n     */\n    virtual ~CanonicalIterator();\n\n    /**\n     * Gets the NFD form of the current source we are iterating over.\n     * @return gets the source: NOTE: it is the NFD form of source\n     * @stable ICU 2.4\n     */\n    UnicodeString getSource();\n\n    /**\n     * Resets the iterator so that one can start again from the beginning.\n     * @stable ICU 2.4\n     */\n    void reset();\n\n    /**\n     * Get the next canonically equivalent string.\n     * <br><b>Warning: The strings are not guaranteed to be in any particular order.</b>\n     * @return the next string that is canonically equivalent. A bogus string is returned when\n     * the iteration is done.\n     * @stable ICU 2.4\n     */\n    UnicodeString next();\n\n    /**\n     * Set a new source for this iterator. Allows object reuse.\n     * @param newSource     the source string to iterate against. This allows the same iterator to be used\n     *                     while changing the source string, saving object creation.\n     * @param status        Fill-in parameter which receives the status of this operation.\n     * @stable ICU 2.4\n     */\n    void setSource(const UnicodeString &newSource, UErrorCode &status);\n\n#ifndef U_HIDE_INTERNAL_API\n    /**\n     * Dumb recursive implementation of permutation.\n     * TODO: optimize\n     * @param source     the string to find permutations for\n     * @param skipZeros  determine if skip zeros\n     * @param result     the results in a set.\n     * @param status       Fill-in parameter which receives the status of this operation.\n     * @internal\n     */\n    static void U_EXPORT2 permute(UnicodeString &source, UBool skipZeros, Hashtable *result, UErrorCode &status);\n#endif  /* U_HIDE_INTERNAL_API */\n\n    /**\n     * ICU \"poor man's RTTI\", returns a UClassID for this class.\n     *\n     * @stable ICU 2.2\n     */\n    static UClassID U_EXPORT2 getStaticClassID();\n\n    /**\n     * ICU \"poor man's RTTI\", returns a UClassID for the actual class.\n     *\n     * @stable ICU 2.2\n     */\n    virtual UClassID getDynamicClassID() const;\n\nprivate:\n    // ===================== PRIVATES ==============================\n    // private default constructor\n    CanonicalIterator();\n\n\n    /**\n     * Copy constructor. Private for now.\n     * @internal\n     */\n    CanonicalIterator(const CanonicalIterator& other);\n\n    /**\n     * Assignment operator. Private for now.\n     * @internal\n     */\n    CanonicalIterator& operator=(const CanonicalIterator& other);\n\n    // fields\n    UnicodeString source;\n    UBool done;\n\n    // 2 dimensional array holds the pieces of the string with\n    // their different canonically equivalent representations\n    UnicodeString **pieces;\n    int32_t pieces_length;\n    int32_t *pieces_lengths;\n\n    // current is used in iterating to combine pieces\n    int32_t *current;\n    int32_t current_length;\n\n    // transient fields\n    UnicodeString buffer;\n\n    const Normalizer2 &nfd;\n    const Normalizer2Impl &nfcImpl;\n\n    // we have a segment, in NFD. Find all the strings that are canonically equivalent to it.\n    UnicodeString *getEquivalents(const UnicodeString &segment, int32_t &result_len, UErrorCode &status); //private String[] getEquivalents(String segment)\n\n    //Set getEquivalents2(String segment);\n    Hashtable *getEquivalents2(Hashtable *fillinResult, const UChar *segment, int32_t segLen, UErrorCode &status);\n    //Hashtable *getEquivalents2(const UnicodeString &segment, int32_t segLen, UErrorCode &status);\n\n    /**\n     * See if the decomposition of cp2 is at segment starting at segmentPos\n     * (with canonical rearrangment!)\n     * If so, take the remainder, and return the equivalents\n     */\n    //Set extract(int comp, String segment, int segmentPos, StringBuffer buffer);\n    Hashtable *extract(Hashtable *fillinResult, UChar32 comp, const UChar *segment, int32_t segLen, int32_t segmentPos, UErrorCode &status);\n    //Hashtable *extract(UChar32 comp, const UnicodeString &segment, int32_t segLen, int32_t segmentPos, UErrorCode &status);\n\n    void cleanPieces();\n\n};\n\nU_NAMESPACE_END\n\n#endif /* #if !UCONFIG_NO_NORMALIZATION */\n\n#endif\n"
  },
  {
    "path": "deprecated/android/addons/icucompat/unicode/chariter.h",
    "content": "/*\n********************************************************************\n*\n*   Copyright (C) 1997-2011, International Business Machines\n*   Corporation and others.  All Rights Reserved.\n*\n********************************************************************\n*/\n\n#ifndef CHARITER_H\n#define CHARITER_H\n\n#include \"unicode/utypes.h\"\n#include \"unicode/uobject.h\"\n#include \"unicode/unistr.h\"\n/**\n * \\file\n * \\brief C++ API: Character Iterator\n */\n \nU_NAMESPACE_BEGIN\n/**\n * Abstract class that defines an API for forward-only iteration\n * on text objects.\n * This is a minimal interface for iteration without random access\n * or backwards iteration. It is especially useful for wrapping\n * streams with converters into an object for collation or\n * normalization.\n *\n * <p>Characters can be accessed in two ways: as code units or as\n * code points.\n * Unicode code points are 21-bit integers and are the scalar values\n * of Unicode characters. ICU uses the type UChar32 for them.\n * Unicode code units are the storage units of a given\n * Unicode/UCS Transformation Format (a character encoding scheme).\n * With UTF-16, all code points can be represented with either one\n * or two code units (\"surrogates\").\n * String storage is typically based on code units, while properties\n * of characters are typically determined using code point values.\n * Some processes may be designed to work with sequences of code units,\n * or it may be known that all characters that are important to an\n * algorithm can be represented with single code units.\n * Other processes will need to use the code point access functions.</p>\n *\n * <p>ForwardCharacterIterator provides nextPostInc() to access\n * a code unit and advance an internal position into the text object,\n * similar to a <code>return text[position++]</code>.<br>\n * It provides next32PostInc() to access a code point and advance an internal\n * position.</p>\n *\n * <p>next32PostInc() assumes that the current position is that of\n * the beginning of a code point, i.e., of its first code unit.\n * After next32PostInc(), this will be true again.\n * In general, access to code units and code points in the same\n * iteration loop should not be mixed. In UTF-16, if the current position\n * is on a second code unit (Low Surrogate), then only that code unit\n * is returned even by next32PostInc().</p>\n *\n * <p>For iteration with either function, there are two ways to\n * check for the end of the iteration. When there are no more\n * characters in the text object:\n * <ul>\n * <li>The hasNext() function returns FALSE.</li>\n * <li>nextPostInc() and next32PostInc() return DONE\n *     when one attempts to read beyond the end of the text object.</li>\n * </ul>\n *\n * Example:\n * \\code \n * void function1(ForwardCharacterIterator &it) {\n *     UChar32 c;\n *     while(it.hasNext()) {\n *         c=it.next32PostInc();\n *         // use c\n *     }\n * }\n *\n * void function1(ForwardCharacterIterator &it) {\n *     UChar c;\n *     while((c=it.nextPostInc())!=ForwardCharacterIterator::DONE) {\n *         // use c\n *      }\n *  }\n * \\endcode\n * </p>\n *\n * @stable ICU 2.0\n */\nclass U_COMMON_API ForwardCharacterIterator : public UObject {\npublic:\n    /**\n     * Value returned by most of ForwardCharacterIterator's functions\n     * when the iterator has reached the limits of its iteration.\n     * @stable ICU 2.0\n     */\n    enum { DONE = 0xffff };\n    \n    /**\n     * Destructor.  \n     * @stable ICU 2.0\n     */\n    virtual ~ForwardCharacterIterator();\n    \n    /**\n     * Returns true when both iterators refer to the same\n     * character in the same character-storage object.  \n     * @param that The ForwardCharacterIterator to be compared for equality\n     * @return true when both iterators refer to the same\n     * character in the same character-storage object\n     * @stable ICU 2.0\n     */\n    virtual UBool operator==(const ForwardCharacterIterator& that) const = 0;\n    \n    /**\n     * Returns true when the iterators refer to different\n     * text-storage objects, or to different characters in the\n     * same text-storage object.  \n     * @param that The ForwardCharacterIterator to be compared for inequality\n     * @return true when the iterators refer to different\n     * text-storage objects, or to different characters in the\n     * same text-storage object\n     * @stable ICU 2.0\n     */\n    inline UBool operator!=(const ForwardCharacterIterator& that) const;\n    \n    /**\n     * Generates a hash code for this iterator.  \n     * @return the hash code.\n     * @stable ICU 2.0\n     */\n    virtual int32_t hashCode(void) const = 0;\n    \n    /**\n     * Returns a UClassID for this ForwardCharacterIterator (\"poor man's\n     * RTTI\").<P> Despite the fact that this function is public,\n     * DO NOT CONSIDER IT PART OF CHARACTERITERATOR'S API! \n     * @return a UClassID for this ForwardCharacterIterator \n     * @stable ICU 2.0\n     */\n    virtual UClassID getDynamicClassID(void) const = 0;\n    \n    /**\n     * Gets the current code unit for returning and advances to the next code unit\n     * in the iteration range\n     * (toward endIndex()).  If there are\n     * no more code units to return, returns DONE.\n     * @return the current code unit.\n     * @stable ICU 2.0\n     */\n    virtual UChar         nextPostInc(void) = 0;\n    \n    /**\n     * Gets the current code point for returning and advances to the next code point\n     * in the iteration range\n     * (toward endIndex()).  If there are\n     * no more code points to return, returns DONE.\n     * @return the current code point.\n     * @stable ICU 2.0\n     */\n    virtual UChar32       next32PostInc(void) = 0;\n    \n    /**\n     * Returns FALSE if there are no more code units or code points\n     * at or after the current position in the iteration range.\n     * This is used with nextPostInc() or next32PostInc() in forward\n     * iteration.\n     * @returns FALSE if there are no more code units or code points\n     * at or after the current position in the iteration range.\n     * @stable ICU 2.0\n     */\n    virtual UBool        hasNext() = 0;\n    \nprotected:\n    /** Default constructor to be overridden in the implementing class. @stable ICU 2.0*/\n    ForwardCharacterIterator();\n    \n    /** Copy constructor to be overridden in the implementing class. @stable ICU 2.0*/\n    ForwardCharacterIterator(const ForwardCharacterIterator &other);\n    \n    /**\n     * Assignment operator to be overridden in the implementing class.\n     * @stable ICU 2.0\n     */\n    ForwardCharacterIterator &operator=(const ForwardCharacterIterator&) { return *this; }\n};\n\n/**\n * Abstract class that defines an API for iteration\n * on text objects.\n * This is an interface for forward and backward iteration\n * and random access into a text object.\n *\n * <p>The API provides backward compatibility to the Java and older ICU\n * CharacterIterator classes but extends them significantly:\n * <ol>\n * <li>CharacterIterator is now a subclass of ForwardCharacterIterator.</li>\n * <li>While the old API functions provided forward iteration with\n *     \"pre-increment\" semantics, the new one also provides functions\n *     with \"post-increment\" semantics. They are more efficient and should\n *     be the preferred iterator functions for new implementations.\n *     The backward iteration always had \"pre-decrement\" semantics, which\n *     are efficient.</li>\n * <li>Just like ForwardCharacterIterator, it provides access to\n *     both code units and code points. Code point access versions are available\n *     for the old and the new iteration semantics.</li>\n * <li>There are new functions for setting and moving the current position\n *     without returning a character, for efficiency.</li>\n * </ol>\n *\n * See ForwardCharacterIterator for examples for using the new forward iteration\n * functions. For backward iteration, there is also a hasPrevious() function\n * that can be used analogously to hasNext().\n * The old functions work as before and are shown below.</p>\n *\n * <p>Examples for some of the new functions:</p>\n *\n * Forward iteration with hasNext():\n * \\code\n * void forward1(CharacterIterator &it) {\n *     UChar32 c;\n *     for(it.setToStart(); it.hasNext();) {\n *         c=it.next32PostInc();\n *         // use c\n *     }\n *  }\n * \\endcode\n * Forward iteration more similar to loops with the old forward iteration,\n * showing a way to convert simple for() loops:\n * \\code\n * void forward2(CharacterIterator &it) {\n *     UChar c;\n *     for(c=it.firstPostInc(); c!=CharacterIterator::DONE; c=it.nextPostInc()) {\n *          // use c\n *      }\n * }\n * \\endcode\n * Backward iteration with setToEnd() and hasPrevious():\n * \\code\n *  void backward1(CharacterIterator &it) {\n *      UChar32 c;\n *      for(it.setToEnd(); it.hasPrevious();) {\n *         c=it.previous32();\n *          // use c\n *      }\n *  }\n * \\endcode\n * Backward iteration with a more traditional for() loop:\n * \\code\n * void backward2(CharacterIterator &it) {\n *     UChar c;\n *     for(c=it.last(); c!=CharacterIterator::DONE; c=it.previous()) {\n *         // use c\n *      }\n *  }\n * \\endcode\n *\n * Example for random access:\n * \\code\n *  void random(CharacterIterator &it) {\n *      // set to the third code point from the beginning\n *      it.move32(3, CharacterIterator::kStart);\n *      // get a code point from here without moving the position\n *      UChar32 c=it.current32();\n *      // get the position\n *      int32_t pos=it.getIndex();\n *      // get the previous code unit\n *      UChar u=it.previous();\n *      // move back one more code unit\n *      it.move(-1, CharacterIterator::kCurrent);\n *      // set the position back to where it was\n *      // and read the same code point c and move beyond it\n *      it.setIndex(pos);\n *      if(c!=it.next32PostInc()) {\n *          exit(1); // CharacterIterator inconsistent\n *      }\n *  }\n * \\endcode\n *\n * <p>Examples, especially for the old API:</p>\n *\n * Function processing characters, in this example simple output\n * <pre>\n * \\code\n *  void processChar( UChar c )\n *  {\n *      cout << \" \" << c;\n *  }\n * \\endcode\n * </pre>\n * Traverse the text from start to finish\n * <pre> \n * \\code\n *  void traverseForward(CharacterIterator& iter)\n *  {\n *      for(UChar c = iter.first(); c != CharacterIterator.DONE; c = iter.next()) {\n *          processChar(c);\n *      }\n *  }\n * \\endcode\n * </pre>\n * Traverse the text backwards, from end to start\n * <pre>\n * \\code\n *  void traverseBackward(CharacterIterator& iter)\n *  {\n *      for(UChar c = iter.last(); c != CharacterIterator.DONE; c = iter.previous()) {\n *          processChar(c);\n *      }\n *  }\n * \\endcode\n * </pre>\n * Traverse both forward and backward from a given position in the text. \n * Calls to notBoundary() in this example represents some additional stopping criteria.\n * <pre>\n * \\code\n * void traverseOut(CharacterIterator& iter, int32_t pos)\n * {\n *      UChar c;\n *      for (c = iter.setIndex(pos);\n *      c != CharacterIterator.DONE && (Unicode::isLetter(c) || Unicode::isDigit(c));\n *          c = iter.next()) {}\n *      int32_t end = iter.getIndex();\n *      for (c = iter.setIndex(pos);\n *          c != CharacterIterator.DONE && (Unicode::isLetter(c) || Unicode::isDigit(c));\n *          c = iter.previous()) {}\n *      int32_t start = iter.getIndex() + 1;\n *  \n *      cout << \"start: \" << start << \" end: \" << end << endl;\n *      for (c = iter.setIndex(start); iter.getIndex() < end; c = iter.next() ) {\n *          processChar(c);\n *     }\n *  }\n * \\endcode\n * </pre>\n * Creating a StringCharacterIterator and calling the test functions\n * <pre>\n * \\code\n *  void CharacterIterator_Example( void )\n *   {\n *       cout << endl << \"===== CharacterIterator_Example: =====\" << endl;\n *       UnicodeString text(\"Ein kleiner Satz.\");\n *       StringCharacterIterator iterator(text);\n *       cout << \"----- traverseForward: -----------\" << endl;\n *       traverseForward( iterator );\n *       cout << endl << endl << \"----- traverseBackward: ----------\" << endl;\n *       traverseBackward( iterator );\n *       cout << endl << endl << \"----- traverseOut: ---------------\" << endl;\n *       traverseOut( iterator, 7 );\n *       cout << endl << endl << \"-----\" << endl;\n *   }\n * \\endcode\n * </pre>\n *\n * @stable ICU 2.0\n */\nclass U_COMMON_API CharacterIterator : public ForwardCharacterIterator {\npublic:\n    /**\n     * Origin enumeration for the move() and move32() functions.\n     * @stable ICU 2.0\n     */\n    enum EOrigin { kStart, kCurrent, kEnd };\n\n    /**\n     * Destructor.\n     * @stable ICU 2.0\n     */\n    virtual ~CharacterIterator();\n\n    /**\n     * Returns a pointer to a new CharacterIterator of the same\n     * concrete class as this one, and referring to the same\n     * character in the same text-storage object as this one.  The\n     * caller is responsible for deleting the new clone.  \n     * @return a pointer to a new CharacterIterator\n     * @stable ICU 2.0\n     */\n    virtual CharacterIterator* clone(void) const = 0;\n\n    /**\n     * Sets the iterator to refer to the first code unit in its\n     * iteration range, and returns that code unit.\n     * This can be used to begin an iteration with next().\n     * @return the first code unit in its iteration range.\n     * @stable ICU 2.0\n     */\n    virtual UChar         first(void) = 0;\n\n    /**\n     * Sets the iterator to refer to the first code unit in its\n     * iteration range, returns that code unit, and moves the position\n     * to the second code unit. This is an alternative to setToStart()\n     * for forward iteration with nextPostInc().\n     * @return the first code unit in its iteration range.\n     * @stable ICU 2.0\n     */\n    virtual UChar         firstPostInc(void);\n\n    /**\n     * Sets the iterator to refer to the first code point in its\n     * iteration range, and returns that code unit,\n     * This can be used to begin an iteration with next32().\n     * Note that an iteration with next32PostInc(), beginning with,\n     * e.g., setToStart() or firstPostInc(), is more efficient.\n     * @return the first code point in its iteration range.\n     * @stable ICU 2.0\n     */\n    virtual UChar32       first32(void) = 0;\n\n    /**\n     * Sets the iterator to refer to the first code point in its\n     * iteration range, returns that code point, and moves the position\n     * to the second code point. This is an alternative to setToStart()\n     * for forward iteration with next32PostInc().\n     * @return the first code point in its iteration range.\n     * @stable ICU 2.0\n     */\n    virtual UChar32       first32PostInc(void);\n\n    /**\n     * Sets the iterator to refer to the first code unit or code point in its\n     * iteration range. This can be used to begin a forward\n     * iteration with nextPostInc() or next32PostInc().\n     * @return the start position of the iteration range\n     * @stable ICU 2.0\n     */\n    inline int32_t    setToStart();\n\n    /**\n     * Sets the iterator to refer to the last code unit in its\n     * iteration range, and returns that code unit.\n     * This can be used to begin an iteration with previous().\n     * @return the last code unit.\n     * @stable ICU 2.0\n     */\n    virtual UChar         last(void) = 0;\n        \n    /**\n     * Sets the iterator to refer to the last code point in its\n     * iteration range, and returns that code unit.\n     * This can be used to begin an iteration with previous32().\n     * @return the last code point.\n     * @stable ICU 2.0\n     */\n    virtual UChar32       last32(void) = 0;\n\n    /**\n     * Sets the iterator to the end of its iteration range, just behind\n     * the last code unit or code point. This can be used to begin a backward\n     * iteration with previous() or previous32().\n     * @return the end position of the iteration range\n     * @stable ICU 2.0\n     */\n    inline int32_t    setToEnd();\n\n    /**\n     * Sets the iterator to refer to the \"position\"-th code unit\n     * in the text-storage object the iterator refers to, and\n     * returns that code unit.  \n     * @param position the \"position\"-th code unit in the text-storage object\n     * @return the \"position\"-th code unit.\n     * @stable ICU 2.0\n     */\n    virtual UChar         setIndex(int32_t position) = 0;\n\n    /**\n     * Sets the iterator to refer to the beginning of the code point\n     * that contains the \"position\"-th code unit\n     * in the text-storage object the iterator refers to, and\n     * returns that code point.\n     * The current position is adjusted to the beginning of the code point\n     * (its first code unit).\n     * @param position the \"position\"-th code unit in the text-storage object\n     * @return the \"position\"-th code point.\n     * @stable ICU 2.0\n     */\n    virtual UChar32       setIndex32(int32_t position) = 0;\n\n    /**\n     * Returns the code unit the iterator currently refers to. \n     * @return the current code unit. \n     * @stable ICU 2.0\n     */\n    virtual UChar         current(void) const = 0;\n        \n    /**\n     * Returns the code point the iterator currently refers to.  \n     * @return the current code point.\n     * @stable ICU 2.0\n     */\n    virtual UChar32       current32(void) const = 0;\n        \n    /**\n     * Advances to the next code unit in the iteration range\n     * (toward endIndex()), and returns that code unit.  If there are\n     * no more code units to return, returns DONE.\n     * @return the next code unit.\n     * @stable ICU 2.0\n     */\n    virtual UChar         next(void) = 0;\n        \n    /**\n     * Advances to the next code point in the iteration range\n     * (toward endIndex()), and returns that code point.  If there are\n     * no more code points to return, returns DONE.\n     * Note that iteration with \"pre-increment\" semantics is less\n     * efficient than iteration with \"post-increment\" semantics\n     * that is provided by next32PostInc().\n     * @return the next code point.\n     * @stable ICU 2.0\n     */\n    virtual UChar32       next32(void) = 0;\n        \n    /**\n     * Advances to the previous code unit in the iteration range\n     * (toward startIndex()), and returns that code unit.  If there are\n     * no more code units to return, returns DONE.  \n     * @return the previous code unit.\n     * @stable ICU 2.0\n     */\n    virtual UChar         previous(void) = 0;\n\n    /**\n     * Advances to the previous code point in the iteration range\n     * (toward startIndex()), and returns that code point.  If there are\n     * no more code points to return, returns DONE. \n     * @return the previous code point. \n     * @stable ICU 2.0\n     */\n    virtual UChar32       previous32(void) = 0;\n\n    /**\n     * Returns FALSE if there are no more code units or code points\n     * before the current position in the iteration range.\n     * This is used with previous() or previous32() in backward\n     * iteration.\n     * @return FALSE if there are no more code units or code points\n     * before the current position in the iteration range, return TRUE otherwise.\n     * @stable ICU 2.0\n     */\n    virtual UBool        hasPrevious() = 0;\n\n    /**\n     * Returns the numeric index in the underlying text-storage\n     * object of the character returned by first().  Since it's\n     * possible to create an iterator that iterates across only\n     * part of a text-storage object, this number isn't\n     * necessarily 0.  \n     * @returns the numeric index in the underlying text-storage\n     * object of the character returned by first().\n     * @stable ICU 2.0\n     */\n    inline int32_t       startIndex(void) const;\n        \n    /**\n     * Returns the numeric index in the underlying text-storage\n     * object of the position immediately BEYOND the character\n     * returned by last().  \n     * @return the numeric index in the underlying text-storage\n     * object of the position immediately BEYOND the character\n     * returned by last().\n     * @stable ICU 2.0\n     */\n    inline int32_t       endIndex(void) const;\n        \n    /**\n     * Returns the numeric index in the underlying text-storage\n     * object of the character the iterator currently refers to\n     * (i.e., the character returned by current()).  \n     * @return the numberic index in the text-storage object of \n     * the character the iterator currently refers to\n     * @stable ICU 2.0\n     */\n    inline int32_t       getIndex(void) const;\n\n    /**\n     * Returns the length of the entire text in the underlying\n     * text-storage object.\n     * @return the length of the entire text in the text-storage object\n     * @stable ICU 2.0\n     */\n    inline int32_t           getLength() const;\n\n    /**\n     * Moves the current position relative to the start or end of the\n     * iteration range, or relative to the current position itself.\n     * The movement is expressed in numbers of code units forward\n     * or backward by specifying a positive or negative delta.\n     * @param delta the position relative to origin. A positive delta means forward;\n     * a negative delta means backward.\n     * @param origin Origin enumeration {kStart, kCurrent, kEnd}\n     * @return the new position\n     * @stable ICU 2.0\n     */\n    virtual int32_t      move(int32_t delta, EOrigin origin) = 0;\n\n    /**\n     * Moves the current position relative to the start or end of the\n     * iteration range, or relative to the current position itself.\n     * The movement is expressed in numbers of code points forward\n     * or backward by specifying a positive or negative delta.\n     * @param delta the position relative to origin. A positive delta means forward;\n     * a negative delta means backward.\n     * @param origin Origin enumeration {kStart, kCurrent, kEnd}\n     * @return the new position\n     * @stable ICU 2.0\n     */\n    virtual int32_t      move32(int32_t delta, EOrigin origin) = 0;\n\n    /**\n     * Copies the text under iteration into the UnicodeString\n     * referred to by \"result\".  \n     * @param result Receives a copy of the text under iteration.  \n     * @stable ICU 2.0\n     */\n    virtual void            getText(UnicodeString&  result) = 0;\n\nprotected:\n    /**\n     * Empty constructor.\n     * @stable ICU 2.0\n     */\n    CharacterIterator();\n\n    /**\n     * Constructor, just setting the length field in this base class.\n     * @stable ICU 2.0\n     */\n    CharacterIterator(int32_t length);\n\n    /**\n     * Constructor, just setting the length and position fields in this base class.\n     * @stable ICU 2.0\n     */\n    CharacterIterator(int32_t length, int32_t position);\n\n    /**\n     * Constructor, just setting the length, start, end, and position fields in this base class.\n     * @stable ICU 2.0\n     */\n    CharacterIterator(int32_t length, int32_t textBegin, int32_t textEnd, int32_t position);\n  \n    /**\n     * Copy constructor.\n     *\n     * @param that The CharacterIterator to be copied\n     * @stable ICU 2.0\n     */\n    CharacterIterator(const CharacterIterator &that);\n\n    /**\n     * Assignment operator.  Sets this CharacterIterator to have the same behavior,\n     * as the one passed in.\n     * @param that The CharacterIterator passed in.\n     * @return the newly set CharacterIterator.\n     * @stable ICU 2.0\n     */\n    CharacterIterator &operator=(const CharacterIterator &that);\n\n    /**\n     * Base class text length field.\n     * Necessary this for correct getText() and hashCode().\n     * @stable ICU 2.0\n     */\n    int32_t textLength;\n\n    /**\n     * Base class field for the current position.\n     * @stable ICU 2.0\n     */\n    int32_t  pos;\n\n    /**\n     * Base class field for the start of the iteration range.\n     * @stable ICU 2.0\n     */\n    int32_t  begin;\n\n    /**\n     * Base class field for the end of the iteration range.\n     * @stable ICU 2.0\n     */\n    int32_t  end;\n};\n\ninline UBool\nForwardCharacterIterator::operator!=(const ForwardCharacterIterator& that) const {\n    return !operator==(that);\n}\n\ninline int32_t\nCharacterIterator::setToStart() {\n    return move(0, kStart);\n}\n\ninline int32_t\nCharacterIterator::setToEnd() {\n    return move(0, kEnd);\n}\n\ninline int32_t\nCharacterIterator::startIndex(void) const {\n    return begin;\n}\n\ninline int32_t\nCharacterIterator::endIndex(void) const {\n    return end;\n}\n\ninline int32_t\nCharacterIterator::getIndex(void) const {\n    return pos;\n}\n\ninline int32_t\nCharacterIterator::getLength(void) const {\n    return textLength;\n}\n\nU_NAMESPACE_END\n#endif\n"
  },
  {
    "path": "deprecated/android/addons/icucompat/unicode/choicfmt.h",
    "content": "/*\n********************************************************************************\n*   Copyright (C) 1997-2011, International Business Machines\n*   Corporation and others.  All Rights Reserved.\n********************************************************************************\n*\n* File CHOICFMT.H\n*\n* Modification History:\n*\n*   Date        Name        Description\n*   02/19/97    aliu        Converted from java.\n*   03/20/97    helena      Finished first cut of implementation and got rid\n*                           of nextDouble/previousDouble and replaced with\n*                           boolean array.\n*   4/10/97     aliu        Clean up.  Modified to work on AIX.\n*   8/6/97      nos         Removed overloaded constructor, member var 'buffer'.\n*   07/22/98    stephen     Removed operator!= (implemented in Format)\n********************************************************************************\n*/\n\n#ifndef CHOICFMT_H\n#define CHOICFMT_H\n\n#include \"unicode/utypes.h\"\n\n/**\n * \\file\n * \\brief C++ API: Choice Format.\n */\n\n#if !UCONFIG_NO_FORMATTING\n#ifndef U_HIDE_DEPRECATED_API\n\n#include \"unicode/fieldpos.h\"\n#include \"unicode/format.h\"\n#include \"unicode/messagepattern.h\"\n#include \"unicode/numfmt.h\"\n#include \"unicode/unistr.h\"\n\nU_NAMESPACE_BEGIN\n\nclass MessageFormat;\n\n/**\n * ChoiceFormat converts between ranges of numeric values and strings for those ranges.\n * The strings must conform to the MessageFormat pattern syntax.\n *\n * <p><em><code>ChoiceFormat</code> is probably not what you need.\n * Please use <code>MessageFormat</code>\n * with <code>plural</code> arguments for proper plural selection,\n * and <code>select</code> arguments for simple selection among a fixed set of choices!</em></p>\n *\n * <p>A <code>ChoiceFormat</code> splits\n * the real number line \\htmlonly<code>-&#x221E;</code> to\n * <code>+&#x221E;</code>\\endhtmlonly into two\n * or more contiguous ranges. Each range is mapped to a\n * string.</p>\n *\n * <p><code>ChoiceFormat</code> was originally intended\n * for displaying grammatically correct\n * plurals such as &quot;There is one file.&quot; vs. &quot;There are 2 files.&quot;\n * <em>However,</em> plural rules for many languages\n * are too complex for the capabilities of ChoiceFormat,\n * and its requirement of specifying the precise rules for each message\n * is unmanageable for translators.</p>\n *\n * <p>There are two methods of defining a <code>ChoiceFormat</code>; both\n * are equivalent.  The first is by using a string pattern. This is the\n * preferred method in most cases.  The second method is through direct\n * specification of the arrays that logically make up the\n * <code>ChoiceFormat</code>.</p>\n *\n * <p>Note: Typically, choice formatting is done (if done at all) via <code>MessageFormat</code>\n * with a <code>choice</code> argument type,\n * rather than using a stand-alone <code>ChoiceFormat</code>.</p>\n *\n * <h5>Patterns and Their Interpretation</h5>\n *\n * <p>The pattern string defines the range boundaries and the strings for each number range.\n * Syntax:\n * <pre>\n * choiceStyle = number separator message ('|' number separator message)*\n * number = normal_number | ['-'] \\htmlonly&#x221E;\\endhtmlonly (U+221E, infinity)\n * normal_number = double value (unlocalized ASCII string)\n * separator = less_than | less_than_or_equal\n * less_than = '<'\n * less_than_or_equal = '#' | \\htmlonly&#x2264;\\endhtmlonly (U+2264)\n * message: see {@link MessageFormat}\n * </pre>\n * Pattern_White_Space between syntax elements is ignored, except\n * around each range's sub-message.</p>\n *\n * <p>Each numeric sub-range extends from the current range's number\n * to the next range's number.\n * The number itself is included in its range if a <code>less_than_or_equal</code> sign is used,\n * and excluded from its range (and instead included in the previous range)\n * if a <code>less_than</code> sign is used.</p>\n *\n * <p>When a <code>ChoiceFormat</code> is constructed from\n * arrays of numbers, closure flags and strings,\n * they are interpreted just like\n * the sequence of <code>(number separator string)</code> in an equivalent pattern string.\n * <code>closure[i]==TRUE</code> corresponds to a <code>less_than</code> separator sign.\n * The equivalent pattern string will be constructed automatically.</p>\n *\n * <p>During formatting, a number is mapped to the first range\n * where the number is not greater than the range's upper limit.\n * That range's message string is returned. A NaN maps to the very first range.</p>\n *\n * <p>During parsing, a range is selected for the longest match of\n * any range's message. That range's number is returned, ignoring the separator/closure.\n * Only a simple string match is performed, without parsing of arguments that\n * might be specified in the message strings.</p>\n *\n * <p>Note that the first range's number is ignored in formatting\n * but may be returned from parsing.</p>\n *\n * <h5>Examples</h5>\n *\n * <p>Here is an example of two arrays that map the number\n * <code>1..7</code> to the English day of the week abbreviations\n * <code>Sun..Sat</code>. No closures array is given; this is the same as\n * specifying all closures to be <code>FALSE</code>.</p>\n *\n * <pre>    {1,2,3,4,5,6,7},\n *     {&quot;Sun&quot;,&quot;Mon&quot;,&quot;Tue&quot;,&quot;Wed&quot;,&quot;Thur&quot;,&quot;Fri&quot;,&quot;Sat&quot;}</pre>\n *\n * <p>Here is an example that maps the ranges [-Inf, 1), [1, 1], and (1,\n * +Inf] to three strings. That is, the number line is split into three\n * ranges: x &lt; 1.0, x = 1.0, and x &gt; 1.0.\n * (The round parentheses in the notation above indicate an exclusive boundary,\n * like the turned bracket in European notation: [-Inf, 1) == [-Inf, 1[  )</p>\n *\n * <pre>    {0, 1, 1},\n *     {FALSE, FALSE, TRUE},\n *     {&quot;no files&quot;, &quot;one file&quot;, &quot;many files&quot;}</pre>\n *\n * <p>Here is an example that shows formatting and parsing: </p>\n *\n * \\code\n *   #include <unicode/choicfmt.h>\n *   #include <unicode/unistr.h>\n *   #include <iostream.h>\n *\n *   int main(int argc, char *argv[]) {\n *       double limits[] = {1,2,3,4,5,6,7};\n *       UnicodeString monthNames[] = {\n *           \"Sun\",\"Mon\",\"Tue\",\"Wed\",\"Thu\",\"Fri\",\"Sat\"};\n *       ChoiceFormat fmt(limits, monthNames, 7);\n *       UnicodeString str;\n *       char buf[256];\n *       for (double x = 1.0; x <= 8.0; x += 1.0) {\n *           fmt.format(x, str);\n *           str.extract(0, str.length(), buf, 256, \"\");\n *           str.truncate(0);\n *           cout << x << \" -> \"\n *                << buf << endl;\n *       }\n *       cout << endl;\n *       return 0;\n *   }\n * \\endcode\n *\n * <p><em>User subclasses are not supported.</em> While clients may write\n * subclasses, such code will not necessarily work and will not be\n * guaranteed to work stably from release to release.\n *\n * @deprecated ICU 49 Use MessageFormat instead, with plural and select arguments.\n */\nclass U_I18N_API ChoiceFormat: public NumberFormat {\npublic:\n    /**\n     * Constructs a new ChoiceFormat from the pattern string.\n     *\n     * @param pattern   Pattern used to construct object.\n     * @param status    Output param to receive success code.  If the\n     *                  pattern cannot be parsed, set to failure code.\n     * @deprecated ICU 49 Use MessageFormat instead, with plural and select arguments.\n     */\n    ChoiceFormat(const UnicodeString& pattern,\n                 UErrorCode& status);\n\n\n    /**\n     * Constructs a new ChoiceFormat with the given limits and message strings.\n     * All closure flags default to <code>FALSE</code>,\n     * equivalent to <code>less_than_or_equal</code> separators.\n     *\n     * Copies the limits and formats instead of adopting them.\n     *\n     * @param limits    Array of limit values.\n     * @param formats   Array of formats.\n     * @param count     Size of 'limits' and 'formats' arrays.\n     * @deprecated ICU 49 Use MessageFormat instead, with plural and select arguments.\n     */\n    ChoiceFormat(const double* limits,\n                 const UnicodeString* formats,\n                 int32_t count );\n\n    /**\n     * Constructs a new ChoiceFormat with the given limits, closure flags and message strings.\n     *\n     * Copies the limits and formats instead of adopting them.\n     *\n     * @param limits Array of limit values\n     * @param closures Array of booleans specifying whether each\n     * element of 'limits' is open or closed.  If FALSE, then the\n     * corresponding limit number is a member of its range.\n     * If TRUE, then the limit number belongs to the previous range it.\n     * @param formats Array of formats\n     * @param count Size of 'limits', 'closures', and 'formats' arrays\n     * @deprecated ICU 49 Use MessageFormat instead, with plural and select arguments.\n     */\n    ChoiceFormat(const double* limits,\n                 const UBool* closures,\n                 const UnicodeString* formats,\n                 int32_t count);\n\n    /**\n     * Copy constructor.\n     *\n     * @param that   ChoiceFormat object to be copied from\n     * @deprecated ICU 49 Use MessageFormat instead, with plural and select arguments.\n     */\n    ChoiceFormat(const ChoiceFormat& that);\n\n    /**\n     * Assignment operator.\n     *\n     * @param that   ChoiceFormat object to be copied\n     * @deprecated ICU 49 Use MessageFormat instead, with plural and select arguments.\n     */\n    const ChoiceFormat& operator=(const ChoiceFormat& that);\n\n    /**\n     * Destructor.\n     * @deprecated ICU 49 Use MessageFormat instead, with plural and select arguments.\n     */\n    virtual ~ChoiceFormat();\n\n    /**\n     * Clones this Format object. The caller owns the\n     * result and must delete it when done.\n     *\n     * @return a copy of this object\n     * @deprecated ICU 49 Use MessageFormat instead, with plural and select arguments.\n     */\n    virtual Format* clone(void) const;\n\n    /**\n     * Returns true if the given Format objects are semantically equal.\n     * Objects of different subclasses are considered unequal.\n     *\n     * @param other    ChoiceFormat object to be compared\n     * @return         true if other is the same as this.\n     * @deprecated ICU 49 Use MessageFormat instead, with plural and select arguments.\n     */\n    virtual UBool operator==(const Format& other) const;\n\n    /**\n     * Sets the pattern.\n     * @param pattern   The pattern to be applied.\n     * @param status    Output param set to success/failure code on\n     *                  exit. If the pattern is invalid, this will be\n     *                  set to a failure result.\n     * @deprecated ICU 49 Use MessageFormat instead, with plural and select arguments.\n     */\n    virtual void applyPattern(const UnicodeString& pattern,\n                              UErrorCode& status);\n\n    /**\n     * Sets the pattern.\n     * @param pattern    The pattern to be applied.\n     * @param parseError Struct to receive information on position\n     *                   of error if an error is encountered\n     * @param status     Output param set to success/failure code on\n     *                   exit. If the pattern is invalid, this will be\n     *                   set to a failure result.\n     * @deprecated ICU 49 Use MessageFormat instead, with plural and select arguments.\n     */\n    virtual void applyPattern(const UnicodeString& pattern,\n                             UParseError& parseError,\n                             UErrorCode& status);\n    /**\n     * Gets the pattern.\n     *\n     * @param pattern    Output param which will receive the pattern\n     *                   Previous contents are deleted.\n     * @return    A reference to 'pattern'\n     * @deprecated ICU 49 Use MessageFormat instead, with plural and select arguments.\n     */\n    virtual UnicodeString& toPattern(UnicodeString &pattern) const;\n\n    /**\n     * Sets the choices to be used in formatting.\n     * For details see the constructor with the same parameter list.\n     *\n     * @param limitsToCopy      Contains the top value that you want\n     *                          parsed with that format,and should be in\n     *                          ascending sorted order. When formatting X,\n     *                          the choice will be the i, where limit[i]\n     *                          &lt;= X &lt; limit[i+1].\n     * @param formatsToCopy     The format strings you want to use for each limit.\n     * @param count             The size of the above arrays.\n     * @deprecated ICU 49 Use MessageFormat instead, with plural and select arguments.\n     */\n    virtual void setChoices(const double* limitsToCopy,\n                            const UnicodeString* formatsToCopy,\n                            int32_t count );\n\n    /**\n     * Sets the choices to be used in formatting.\n     * For details see the constructor with the same parameter list.\n     *\n     * @param limits Array of limits\n     * @param closures Array of limit booleans\n     * @param formats Array of format string\n     * @param count The size of the above arrays\n     * @deprecated ICU 49 Use MessageFormat instead, with plural and select arguments.\n     */\n    virtual void setChoices(const double* limits,\n                            const UBool* closures,\n                            const UnicodeString* formats,\n                            int32_t count);\n\n    /**\n     * Returns NULL and 0.\n     * Before ICU 4.8, this used to return the choice limits array.\n     *\n     * @param count Will be set to 0.\n     * @return NULL\n     * @deprecated ICU 4.8 Use the MessagePattern class to analyze a ChoiceFormat pattern.\n     */\n    virtual const double* getLimits(int32_t& count) const;\n\n    /**\n     * Returns NULL and 0.\n     * Before ICU 4.8, this used to return the limit booleans array.\n     *\n     * @param count Will be set to 0.\n     * @return NULL\n     * @deprecated ICU 4.8 Use the MessagePattern class to analyze a ChoiceFormat pattern.\n     */\n    virtual const UBool* getClosures(int32_t& count) const;\n\n    /**\n     * Returns NULL and 0.\n     * Before ICU 4.8, this used to return the array of choice strings.\n     *\n     * @param count Will be set to 0.\n     * @return NULL\n     * @deprecated ICU 4.8 Use the MessagePattern class to analyze a ChoiceFormat pattern.\n     */\n    virtual const UnicodeString* getFormats(int32_t& count) const;\n\n\n    using NumberFormat::format;\n\n    /**\n     * Formats a double number using this object's choices.\n     *\n     * @param number    The value to be formatted.\n     * @param appendTo  Output parameter to receive result.\n     *                  Result is appended to existing contents.\n     * @param pos       On input: an alignment field, if desired.\n     *                  On output: the offsets of the alignment field.\n     * @return          Reference to 'appendTo' parameter.\n     * @deprecated ICU 49 Use MessageFormat instead, with plural and select arguments.\n     */\n    virtual UnicodeString& format(double number,\n                                  UnicodeString& appendTo,\n                                  FieldPosition& pos) const;\n    /**\n     * Formats an int32_t number using this object's choices.\n     *\n     * @param number    The value to be formatted.\n     * @param appendTo  Output parameter to receive result.\n     *                  Result is appended to existing contents.\n     * @param pos       On input: an alignment field, if desired.\n     *                  On output: the offsets of the alignment field.\n     * @return          Reference to 'appendTo' parameter.\n     * @deprecated ICU 49 Use MessageFormat instead, with plural and select arguments.\n     */\n    virtual UnicodeString& format(int32_t number,\n                                  UnicodeString& appendTo,\n                                  FieldPosition& pos) const;\n\n    /**\n     * Formats an int64_t number using this object's choices.\n     *\n     * @param number    The value to be formatted.\n     * @param appendTo  Output parameter to receive result.\n     *                  Result is appended to existing contents.\n     * @param pos       On input: an alignment field, if desired.\n     *                  On output: the offsets of the alignment field.\n     * @return          Reference to 'appendTo' parameter.\n     * @deprecated ICU 49 Use MessageFormat instead, with plural and select arguments.\n     */\n    virtual UnicodeString& format(int64_t number,\n                                  UnicodeString& appendTo,\n                                  FieldPosition& pos) const;\n\n    /**\n     * Formats an array of objects using this object's choices.\n     *\n     * @param objs      The array of objects to be formatted.\n     * @param cnt       The size of objs.\n     * @param appendTo  Output parameter to receive result.\n     *                  Result is appended to existing contents.\n     * @param pos       On input: an alignment field, if desired.\n     *                  On output: the offsets of the alignment field.\n     * @param success   Output param set to success/failure code on\n     *                  exit.\n     * @return          Reference to 'appendTo' parameter.\n     * @deprecated ICU 49 Use MessageFormat instead, with plural and select arguments.\n     */\n    virtual UnicodeString& format(const Formattable* objs,\n                                  int32_t cnt,\n                                  UnicodeString& appendTo,\n                                  FieldPosition& pos,\n                                  UErrorCode& success) const;\n    /**\n     * Formats an object using this object's choices.\n     *\n     *\n     * @param obj       The object to be formatted.\n     * @param appendTo  Output parameter to receive result.\n     *                  Result is appended to existing contents.\n     * @param pos       On input: an alignment field, if desired.\n     *                  On output: the offsets of the alignment field.\n     * @param status    Output param set to success/failure code on\n     *                  exit.\n     * @return          Reference to 'appendTo' parameter.\n     * @deprecated ICU 49 Use MessageFormat instead, with plural and select arguments.\n     */\n    virtual UnicodeString& format(const Formattable& obj,\n                                  UnicodeString& appendTo,\n                                  FieldPosition& pos,\n                                  UErrorCode& status) const;\n\n    /**\n     * Redeclared NumberFormat method.\n     *\n     * @param obj       The object to be formatted.\n     * @param appendTo  Output parameter to receive result.\n     *                  Result is appended to existing contents.\n     * @param status    Output param set to success/failure code on\n     *                  exit.\n     * @return          Reference to 'appendTo' parameter.\n     * @deprecated ICU 49 Use MessageFormat instead, with plural and select arguments.\n     */\n    UnicodeString& format(const Formattable& obj,\n                          UnicodeString& appendTo,\n                          UErrorCode& status) const;\n\n    /**\n     * Redeclared NumberFormat method.\n     * Formats a double number. These methods call the NumberFormat\n     * pure virtual format() methods with the default FieldPosition.\n     *\n     * @param number    The value to be formatted.\n     * @param appendTo  Output parameter to receive result.\n     *                  Result is appended to existing contents.\n     * @return          Reference to 'appendTo' parameter.\n     * @deprecated ICU 49 Use MessageFormat instead, with plural and select arguments.\n     */\n    UnicodeString& format(  double number,\n                            UnicodeString& appendTo) const;\n\n    /**\n     * Redeclared NumberFormat method.\n     * Formats an int32_t number. These methods call the NumberFormat\n     * pure virtual format() methods with the default FieldPosition.\n     *\n     * @param number    The value to be formatted.\n     * @param appendTo  Output parameter to receive result.\n     *                  Result is appended to existing contents.\n     * @return          Reference to 'appendTo' parameter.\n     * @deprecated ICU 49 Use MessageFormat instead, with plural and select arguments.\n     */\n    UnicodeString& format(  int32_t number,\n                            UnicodeString& appendTo) const;\n\n   /**\n    * Looks for the longest match of any message string on the input text and,\n    * if there is a match, sets the result object to the corresponding range's number.\n    *\n    * If no string matches, then the parsePosition is unchanged.\n    *\n    * @param text           The text to be parsed.\n    * @param result         Formattable to be set to the parse result.\n    *                       If parse fails, return contents are undefined.\n    * @param parsePosition  The position to start parsing at on input.\n    *                       On output, moved to after the last successfully\n    *                       parse character. On parse failure, does not change.\n     * @deprecated ICU 49 Use MessageFormat instead, with plural and select arguments.\n    */\n    virtual void parse(const UnicodeString& text,\n                       Formattable& result,\n                       ParsePosition& parsePosition) const;\n\n    /**\n     * Looks for the longest match of any message string on the input text and,\n     * if there is a match, sets the result object to the corresponding range's number.\n     *\n     * If no string matches, then the UErrorCode is set to U_INVALID_FORMAT_ERROR.\n     *\n     * @param text           The text to be parsed.\n     * @param result         Formattable to be set to the parse result.\n     *                       If parse fails, return contents are undefined.\n     * @param status         Output param with the formatted string.\n     * @deprecated ICU 49 Use MessageFormat instead, with plural and select arguments.\n     */\n    virtual void parse(const UnicodeString& text,\n                       Formattable& result,\n                       UErrorCode& status) const;\n\n    /**\n     * Returns a unique class ID POLYMORPHICALLY. Part of ICU's \"poor man's RTTI\".\n     *\n     * @return          The class ID for this object. All objects of a\n     *                  given class have the same class ID.  Objects of\n     *                  other classes have different class IDs.\n     * @deprecated ICU 49 Use MessageFormat instead, with plural and select arguments.\n     */\n    virtual UClassID getDynamicClassID(void) const;\n\n    /**\n     * Returns the class ID for this class.  This is useful only for\n     * comparing to a return value from getDynamicClassID().  For example:\n     * <pre>\n     * .       Base* polymorphic_pointer = createPolymorphicObject();\n     * .       if (polymorphic_pointer->getDynamicClassID() ==\n     * .           Derived::getStaticClassID()) ...\n     * </pre>\n     * @return          The class ID for all objects of this class.\n     * @deprecated ICU 49 Use MessageFormat instead, with plural and select arguments.\n     */\n    static UClassID U_EXPORT2 getStaticClassID(void);\n\nprivate:\n    /**\n     * Converts a double value to a string.\n     * @param value the double number to be converted.\n     * @param string the result string.\n     * @return the converted string.\n     */\n    static UnicodeString& dtos(double value, UnicodeString& string);\n\n    ChoiceFormat(); // default constructor not implemented\n\n    /**\n     * Construct a new ChoiceFormat with the limits and the corresponding formats\n     * based on the pattern.\n     *\n     * @param newPattern   Pattern used to construct object.\n     * @param parseError   Struct to receive information on position\n     *                     of error if an error is encountered.\n     * @param status       Output param to receive success code.  If the\n     *                     pattern cannot be parsed, set to failure code.\n     */\n    ChoiceFormat(const UnicodeString& newPattern,\n                 UParseError& parseError,\n                 UErrorCode& status);\n\n    friend class MessageFormat;\n\n    virtual void setChoices(const double* limits,\n                            const UBool* closures,\n                            const UnicodeString* formats,\n                            int32_t count,\n                            UErrorCode &errorCode);\n\n    /**\n     * Finds the ChoiceFormat sub-message for the given number.\n     * @param pattern A MessagePattern.\n     * @param partIndex the index of the first ChoiceFormat argument style part.\n     * @param number a number to be mapped to one of the ChoiceFormat argument's intervals\n     * @return the sub-message start part index.\n     */\n    static int32_t findSubMessage(const MessagePattern &pattern, int32_t partIndex, double number);\n\n    static double parseArgument(\n            const MessagePattern &pattern, int32_t partIndex,\n            const UnicodeString &source, ParsePosition &pos);\n\n    /**\n     * Matches the pattern string from the end of the partIndex to\n     * the beginning of the limitPartIndex,\n     * including all syntax except SKIP_SYNTAX,\n     * against the source string starting at sourceOffset.\n     * If they match, returns the length of the source string match.\n     * Otherwise returns -1.\n     */\n    static int32_t matchStringUntilLimitPart(\n            const MessagePattern &pattern, int32_t partIndex, int32_t limitPartIndex,\n            const UnicodeString &source, int32_t sourceOffset);\n\n    /**\n     * Some of the ChoiceFormat constructors do not have a UErrorCode paramater.\n     * We need _some_ way to provide one for the MessagePattern constructor.\n     * Alternatively, the MessagePattern could be a pointer field, but that is\n     * not nice either.\n     */\n    UErrorCode constructorErrorCode;\n\n    /**\n     * The MessagePattern which contains the parsed structure of the pattern string.\n     *\n     * Starting with ICU 4.8, the MessagePattern contains a sequence of\n     * numeric/selector/message parts corresponding to the parsed pattern.\n     * For details see the MessagePattern class API docs.\n     */\n    MessagePattern msgPattern;\n\n    /**\n     * Docs & fields from before ICU 4.8, before MessagePattern was used.\n     * Commented out, and left only for explanation of semantics.\n     * --------\n     * Each ChoiceFormat divides the range -Inf..+Inf into fCount\n     * intervals.  The intervals are:\n     *\n     *         0: fChoiceLimits[0]..fChoiceLimits[1]\n     *         1: fChoiceLimits[1]..fChoiceLimits[2]\n     *        ...\n     *  fCount-2: fChoiceLimits[fCount-2]..fChoiceLimits[fCount-1]\n     *  fCount-1: fChoiceLimits[fCount-1]..+Inf\n     *\n     * Interval 0 is special; during formatting (mapping numbers to\n     * strings), it also contains all numbers less than\n     * fChoiceLimits[0], as well as NaN values.\n     *\n     * Interval i maps to and from string fChoiceFormats[i].  When\n     * parsing (mapping strings to numbers), then intervals map to\n     * their lower limit, that is, interval i maps to fChoiceLimit[i].\n     *\n     * The intervals may be closed, half open, or open.  This affects\n     * formatting but does not affect parsing.  Interval i is affected\n     * by fClosures[i] and fClosures[i+1].  If fClosures[i]\n     * is FALSE, then the value fChoiceLimits[i] is in interval i.\n     * That is, intervals i and i are:\n     *\n     *  i-1:                 ... x < fChoiceLimits[i]\n     *    i: fChoiceLimits[i] <= x ...\n     *\n     * If fClosures[i] is TRUE, then the value fChoiceLimits[i] is\n     * in interval i-1.  That is, intervals i-1 and i are:\n     *\n     *  i-1:                ... x <= fChoiceLimits[i]\n     *    i: fChoiceLimits[i] < x ...\n     *\n     * Because of the nature of interval 0, fClosures[0] has no\n     * effect.\n     */\n    // double*         fChoiceLimits;\n    // UBool*          fClosures;\n    // UnicodeString*  fChoiceFormats;\n    // int32_t         fCount;\n};\n\ninline UnicodeString&\nChoiceFormat::format(const Formattable& obj,\n                     UnicodeString& appendTo,\n                     UErrorCode& status) const {\n    // Don't use Format:: - use immediate base class only,\n    // in case immediate base modifies behavior later.\n    return NumberFormat::format(obj, appendTo, status);\n}\n\ninline UnicodeString&\nChoiceFormat::format(double number,\n                     UnicodeString& appendTo) const {\n    return NumberFormat::format(number, appendTo);\n}\n\ninline UnicodeString&\nChoiceFormat::format(int32_t number,\n                     UnicodeString& appendTo) const {\n    return NumberFormat::format(number, appendTo);\n}\nU_NAMESPACE_END\n\n#endif  // U_HIDE_DEPRECATED_API\n#endif /* #if !UCONFIG_NO_FORMATTING */\n\n#endif // CHOICFMT_H\n//eof\n"
  },
  {
    "path": "deprecated/android/addons/icucompat/unicode/coleitr.h",
    "content": "/*\n ******************************************************************************\n *   Copyright (C) 1997-2008, International Business Machines\n *   Corporation and others.  All Rights Reserved.\n ******************************************************************************\n */\n\n/**\n * \\file \n * \\brief C++ API: Collation Element Iterator.\n */\n\n/**\n* File coleitr.h\n*\n* \n*\n* Created by: Helena Shih\n*\n* Modification History:\n*\n*  Date       Name        Description\n*\n*  8/18/97    helena      Added internal API documentation.\n* 08/03/98    erm         Synched with 1.2 version CollationElementIterator.java\n* 12/10/99    aliu        Ported Thai collation support from Java.\n* 01/25/01    swquek      Modified into a C++ wrapper calling C APIs (ucoliter.h)\n* 02/19/01    swquek      Removed CollationElementsIterator() since it is \n*                         private constructor and no calls are made to it\n*/\n\n#ifndef COLEITR_H\n#define COLEITR_H\n\n#include \"unicode/utypes.h\"\n\n \n#if !UCONFIG_NO_COLLATION\n\n#include \"unicode/uobject.h\"\n#include \"unicode/tblcoll.h\"\n#include \"unicode/ucoleitr.h\"\n\n/** \n * The UCollationElements struct.\n * For usage in C programs.\n * @stable ICU 2.0\n */\ntypedef struct UCollationElements UCollationElements;\n\nU_NAMESPACE_BEGIN\n\n/**\n* The CollationElementIterator class is used as an iterator to walk through     \n* each character of an international string. Use the iterator to return the\n* ordering priority of the positioned character. The ordering priority of a \n* character, which we refer to as a key, defines how a character is collated in \n* the given collation object.\n* For example, consider the following in Spanish:\n* <pre>\n*        \"ca\" -> the first key is key('c') and second key is key('a').\n*        \"cha\" -> the first key is key('ch') and second key is key('a').</pre>\n* And in German,\n* <pre> \\htmlonly       \"&#x00E6;b\"-> the first key is key('a'), the second key is key('e'), and\n*        the third key is key('b'). \\endhtmlonly </pre>\n* The key of a character, is an integer composed of primary order(short),\n* secondary order(char), and tertiary order(char). Java strictly defines the \n* size and signedness of its primitive data types. Therefore, the static\n* functions primaryOrder(), secondaryOrder(), and tertiaryOrder() return \n* int32_t to ensure the correctness of the key value.\n* <p>Example of the iterator usage: (without error checking)\n* <pre>\n* \\code\n*   void CollationElementIterator_Example()\n*   {\n*       UnicodeString str = \"This is a test\";\n*       UErrorCode success = U_ZERO_ERROR;\n*       RuleBasedCollator* rbc =\n*           (RuleBasedCollator*) RuleBasedCollator::createInstance(success);\n*       CollationElementIterator* c =\n*           rbc->createCollationElementIterator( str );\n*       int32_t order = c->next(success);\n*       c->reset();\n*       order = c->previous(success);\n*       delete c;\n*       delete rbc;\n*   }\n* \\endcode\n* </pre>\n* <p>\n* CollationElementIterator::next returns the collation order of the next\n* character based on the comparison level of the collator. \n* CollationElementIterator::previous returns the collation order of the \n* previous character based on the comparison level of the collator. \n* The Collation Element Iterator moves only in one direction between calls to\n* CollationElementIterator::reset. That is, CollationElementIterator::next() \n* and CollationElementIterator::previous can not be inter-used. Whenever \n* CollationElementIterator::previous is to be called after \n* CollationElementIterator::next() or vice versa, \n* CollationElementIterator::reset has to be called first to reset the status, \n* shifting pointers to either the end or the start of the string. Hence at the \n* next call of CollationElementIterator::previous or \n* CollationElementIterator::next(), the first or last collation order will be \n* returned. \n* If a change of direction is done without a CollationElementIterator::reset(), \n* the result is undefined.\n* The result of a forward iterate (CollationElementIterator::next) and \n* reversed result of the backward iterate (CollationElementIterator::previous) \n* on the same string are equivalent, if collation orders with the value \n* UCOL_IGNORABLE are ignored.\n* Character based on the comparison level of the collator.  A collation order \n* consists of primary order, secondary order and tertiary order.  The data \n* type of the collation order is <strong>t_int32</strong>. \n*\n* Note, CollationElementIterator should not be subclassed.\n* @see     Collator\n* @see     RuleBasedCollator\n* @version 1.8 Jan 16 2001\n*/\nclass U_I18N_API CollationElementIterator : public UObject {\npublic: \n\n    // CollationElementIterator public data member ------------------------------\n\n    enum {\n        /**\n         * NULLORDER indicates that an error has occured while processing\n         * @stable ICU 2.0\n         */\n        NULLORDER = (int32_t)0xffffffff\n    };\n\n    // CollationElementIterator public constructor/destructor -------------------\n\n    /**\n    * Copy constructor.\n    *\n    * @param other    the object to be copied from\n    * @stable ICU 2.0\n    */\n    CollationElementIterator(const CollationElementIterator& other);\n\n    /** \n    * Destructor\n    * @stable ICU 2.0\n    */\n    virtual ~CollationElementIterator();\n\n    // CollationElementIterator public methods ----------------------------------\n\n    /**\n    * Returns true if \"other\" is the same as \"this\"\n    *\n    * @param other    the object to be compared\n    * @return         true if \"other\" is the same as \"this\"\n    * @stable ICU 2.0\n    */\n    UBool operator==(const CollationElementIterator& other) const;\n\n    /**\n    * Returns true if \"other\" is not the same as \"this\".\n    *\n    * @param other    the object to be compared\n    * @return         true if \"other\" is not the same as \"this\"\n    * @stable ICU 2.0\n    */\n    UBool operator!=(const CollationElementIterator& other) const;\n\n    /**\n    * Resets the cursor to the beginning of the string.\n    * @stable ICU 2.0\n    */\n    void reset(void);\n\n    /**\n    * Gets the ordering priority of the next character in the string.\n    * @param status the error code status.\n    * @return the next character's ordering. otherwise returns NULLORDER if an \n    *         error has occured or if the end of string has been reached\n    * @stable ICU 2.0\n    */\n    int32_t next(UErrorCode& status);\n\n    /**\n    * Get the ordering priority of the previous collation element in the string.\n    * @param status the error code status.\n    * @return the previous element's ordering. otherwise returns NULLORDER if an \n    *         error has occured or if the start of string has been reached\n    * @stable ICU 2.0\n    */\n    int32_t previous(UErrorCode& status);\n\n    /**\n    * Gets the primary order of a collation order.\n    * @param order the collation order\n    * @return the primary order of a collation order.\n    * @stable ICU 2.0\n    */\n    static inline int32_t primaryOrder(int32_t order);\n\n    /**\n    * Gets the secondary order of a collation order.\n    * @param order the collation order\n    * @return the secondary order of a collation order.\n    * @stable ICU 2.0\n    */\n    static inline int32_t secondaryOrder(int32_t order);\n\n    /**\n    * Gets the tertiary order of a collation order.\n    * @param order the collation order\n    * @return the tertiary order of a collation order.\n    * @stable ICU 2.0\n    */\n    static inline int32_t tertiaryOrder(int32_t order);\n\n    /**\n    * Return the maximum length of any expansion sequences that end with the \n    * specified comparison order.\n    * @param order a collation order returned by previous or next.\n    * @return maximum size of the expansion sequences ending with the collation \n    *         element or 1 if collation element does not occur at the end of any \n    *         expansion sequence\n    * @stable ICU 2.0\n    */\n    int32_t getMaxExpansion(int32_t order) const;\n\n    /**\n    * Gets the comparison order in the desired strength. Ignore the other\n    * differences.\n    * @param order The order value\n    * @stable ICU 2.0\n    */\n    int32_t strengthOrder(int32_t order) const;\n\n    /**\n    * Sets the source string.\n    * @param str the source string.\n    * @param status the error code status.\n    * @stable ICU 2.0\n    */\n    void setText(const UnicodeString& str, UErrorCode& status);\n\n    /**\n    * Sets the source string.\n    * @param str the source character iterator.\n    * @param status the error code status.\n    * @stable ICU 2.0\n    */\n    void setText(CharacterIterator& str, UErrorCode& status);\n\n    /**\n    * Checks if a comparison order is ignorable.\n    * @param order the collation order.\n    * @return TRUE if a character is ignorable, FALSE otherwise.\n    * @stable ICU 2.0\n    */\n    static inline UBool isIgnorable(int32_t order);\n\n    /**\n    * Gets the offset of the currently processed character in the source string.\n    * @return the offset of the character.\n    * @stable ICU 2.0\n    */\n    int32_t getOffset(void) const;\n\n    /**\n    * Sets the offset of the currently processed character in the source string.\n    * @param newOffset the new offset.\n    * @param status the error code status.\n    * @return the offset of the character.\n    * @stable ICU 2.0\n    */\n    void setOffset(int32_t newOffset, UErrorCode& status);\n\n    /**\n    * ICU \"poor man's RTTI\", returns a UClassID for the actual class.\n    *\n    * @stable ICU 2.2\n    */\n    virtual UClassID getDynamicClassID() const;\n\n    /**\n    * ICU \"poor man's RTTI\", returns a UClassID for this class.\n    *\n    * @stable ICU 2.2\n    */\n    static UClassID U_EXPORT2 getStaticClassID();\n\nprotected:\n  \n    // CollationElementIterator protected constructors --------------------------\n    /**\n    * @stable ICU 2.0\n    */\n    friend class RuleBasedCollator;\n\n    /**\n    * CollationElementIterator constructor. This takes the source string and the \n    * collation object. The cursor will walk thru the source string based on the \n    * predefined collation rules. If the source string is empty, NULLORDER will \n    * be returned on the calls to next().\n    * @param sourceText    the source string.\n    * @param order         the collation object.\n    * @param status        the error code status.\n    * @stable ICU 2.0\n    */\n    CollationElementIterator(const UnicodeString& sourceText,\n        const RuleBasedCollator* order, UErrorCode& status);\n\n    /**\n    * CollationElementIterator constructor. This takes the source string and the \n    * collation object.  The cursor will walk thru the source string based on the \n    * predefined collation rules.  If the source string is empty, NULLORDER will \n    * be returned on the calls to next().\n    * @param sourceText    the source string.\n    * @param order         the collation object.\n    * @param status        the error code status.\n    * @stable ICU 2.0\n    */\n    CollationElementIterator(const CharacterIterator& sourceText,\n        const RuleBasedCollator* order, UErrorCode& status);\n\n    // CollationElementIterator protected methods -------------------------------\n\n    /**\n    * Assignment operator\n    *\n    * @param other    the object to be copied\n    * @stable ICU 2.0\n    */\n    const CollationElementIterator&\n        operator=(const CollationElementIterator& other);\n\nprivate:\n    CollationElementIterator(); // default constructor not implemented\n\n    // CollationElementIterator private data members ----------------------------\n\n    /**\n    * Data wrapper for collation elements\n    */\n    UCollationElements *m_data_;\n\n    /**\n    * Indicates if m_data_ belongs to this object.\n    */\n    UBool isDataOwned_;\n\n};\n\n// CollationElementIterator inline method defination --------------------------\n\n/**\n* Get the primary order of a collation order.\n* @param order the collation order\n* @return the primary order of a collation order.\n*/\ninline int32_t CollationElementIterator::primaryOrder(int32_t order)\n{\n    order &= RuleBasedCollator::PRIMARYORDERMASK;\n    return (order >> RuleBasedCollator::PRIMARYORDERSHIFT);\n}\n\n/**\n* Get the secondary order of a collation order.\n* @param order the collation order\n* @return the secondary order of a collation order.\n*/\ninline int32_t CollationElementIterator::secondaryOrder(int32_t order)\n{\n    order = order & RuleBasedCollator::SECONDARYORDERMASK;\n    return (order >> RuleBasedCollator::SECONDARYORDERSHIFT);\n}\n\n/**\n* Get the tertiary order of a collation order.\n* @param order the collation order\n* @return the tertiary order of a collation order.\n*/\ninline int32_t CollationElementIterator::tertiaryOrder(int32_t order)\n{\n    return (order &= RuleBasedCollator::TERTIARYORDERMASK);\n}\n\ninline int32_t CollationElementIterator::getMaxExpansion(int32_t order) const\n{\n    return ucol_getMaxExpansion(m_data_, (uint32_t)order);\n}\n\ninline UBool CollationElementIterator::isIgnorable(int32_t order)\n{\n    return (primaryOrder(order) == RuleBasedCollator::PRIMIGNORABLE);\n}\n\nU_NAMESPACE_END\n\n#endif /* #if !UCONFIG_NO_COLLATION */\n\n#endif\n"
  },
  {
    "path": "deprecated/android/addons/icucompat/unicode/coll.h",
    "content": "/*\n******************************************************************************\n*   Copyright (C) 1996-2012, International Business Machines                 *\n*   Corporation and others.  All Rights Reserved.                            *\n******************************************************************************\n*/\n\n/**\n * \\file \n * \\brief C++ API: Collation Service.\n */\n \n/**\n* File coll.h\n*\n* Created by: Helena Shih\n*\n* Modification History:\n*\n*  Date        Name        Description\n* 02/5/97      aliu        Modified createDefault to load collation data from\n*                          binary files when possible.  Added related methods\n*                          createCollationFromFile, chopLocale, createPathName.\n* 02/11/97     aliu        Added members addToCache, findInCache, and fgCache.\n* 02/12/97     aliu        Modified to create objects from RuleBasedCollator cache.\n*                          Moved cache out of Collation class.\n* 02/13/97     aliu        Moved several methods out of this class and into\n*                          RuleBasedCollator, with modifications.  Modified\n*                          createDefault() to call new RuleBasedCollator(Locale&)\n*                          constructor.  General clean up and documentation.\n* 02/20/97     helena      Added clone, operator==, operator!=, operator=, copy\n*                          constructor and getDynamicClassID.\n* 03/25/97     helena      Updated with platform independent data types.\n* 05/06/97     helena      Added memory allocation error detection.\n* 06/20/97     helena      Java class name change.\n* 09/03/97     helena      Added createCollationKeyValues().\n* 02/10/98     damiba      Added compare() with length as parameter.\n* 04/23/99     stephen     Removed EDecompositionMode, merged with\n*                          Normalizer::EMode.\n* 11/02/99     helena      Collator performance enhancements.  Eliminates the\n*                          UnicodeString construction and special case for NO_OP.\n* 11/23/99     srl         More performance enhancements. Inlining of\n*                          critical accessors.\n* 05/15/00     helena      Added version information API.\n* 01/29/01     synwee      Modified into a C++ wrapper which calls C apis\n*                          (ucoll.h).\n*/\n\n#ifndef COLL_H\n#define COLL_H\n\n#include \"unicode/utypes.h\"\n\n#if !UCONFIG_NO_COLLATION\n\n#include \"unicode/uobject.h\"\n#include \"unicode/ucol.h\"\n#include \"unicode/normlzr.h\"\n#include \"unicode/locid.h\"\n#include \"unicode/uniset.h\"\n#include \"unicode/umisc.h\"\n#include \"unicode/uiter.h\"\n#include \"unicode/stringpiece.h\"\n\nU_NAMESPACE_BEGIN\n\nclass StringEnumeration;\n\n#if !UCONFIG_NO_SERVICE\n/**\n * @stable ICU 2.6\n */\nclass CollatorFactory;\n#endif\n\n/**\n* @stable ICU 2.0\n*/\nclass CollationKey;\n\n/**\n* The <code>Collator</code> class performs locale-sensitive string\n* comparison.<br>\n* You use this class to build searching and sorting routines for natural\n* language text.<br>\n* <em>Important: </em>The ICU collation service has been reimplemented\n* in order to achieve better performance and UCA compliance.\n* For details, see the\n* <a href=\"http://source.icu-project.org/repos/icu/icuhtml/trunk/design/collation/ICU_collation_design.htm\">\n* collation design document</a>.\n* <p>\n* <code>Collator</code> is an abstract base class. Subclasses implement\n* specific collation strategies. One subclass,\n* <code>RuleBasedCollator</code>, is currently provided and is applicable\n* to a wide set of languages. Other subclasses may be created to handle more\n* specialized needs.\n* <p>\n* Like other locale-sensitive classes, you can use the static factory method,\n* <code>createInstance</code>, to obtain the appropriate\n* <code>Collator</code> object for a given locale. You will only need to\n* look at the subclasses of <code>Collator</code> if you need to\n* understand the details of a particular collation strategy or if you need to\n* modify that strategy.\n* <p>\n* The following example shows how to compare two strings using the\n* <code>Collator</code> for the default locale.\n* \\htmlonly<blockquote>\\endhtmlonly\n* <pre>\n* \\code\n* // Compare two strings in the default locale\n* UErrorCode success = U_ZERO_ERROR;\n* Collator* myCollator = Collator::createInstance(success);\n* if (myCollator->compare(\"abc\", \"ABC\") < 0)\n*   cout << \"abc is less than ABC\" << endl;\n* else\n*   cout << \"abc is greater than or equal to ABC\" << endl;\n* \\endcode\n* </pre>\n* \\htmlonly</blockquote>\\endhtmlonly\n* <p>\n* You can set a <code>Collator</code>'s <em>strength</em> property to\n* determine the level of difference considered significant in comparisons.\n* Five strengths are provided: <code>PRIMARY</code>, <code>SECONDARY</code>,\n* <code>TERTIARY</code>, <code>QUATERNARY</code> and <code>IDENTICAL</code>.\n* The exact assignment of strengths to language features is locale dependant.\n* For example, in Czech, \"e\" and \"f\" are considered primary differences,\n* while \"e\" and \"\\u00EA\" are secondary differences, \"e\" and \"E\" are tertiary\n* differences and \"e\" and \"e\" are identical. The following shows how both case\n* and accents could be ignored for US English.\n* \\htmlonly<blockquote>\\endhtmlonly\n* <pre>\n* \\code\n* //Get the Collator for US English and set its strength to PRIMARY\n* UErrorCode success = U_ZERO_ERROR;\n* Collator* usCollator = Collator::createInstance(Locale::US, success);\n* usCollator->setStrength(Collator::PRIMARY);\n* if (usCollator->compare(\"abc\", \"ABC\") == 0)\n*     cout << \"'abc' and 'ABC' strings are equivalent with strength PRIMARY\" << endl;\n* \\endcode\n* </pre>\n* \\htmlonly</blockquote>\\endhtmlonly\n* <p>\n* For comparing strings exactly once, the <code>compare</code> method\n* provides the best performance. When sorting a list of strings however, it\n* is generally necessary to compare each string multiple times. In this case,\n* sort keys provide better performance. The <code>getSortKey</code> methods\n* convert a string to a series of bytes that can be compared bitwise against\n* other sort keys using <code>strcmp()</code>. Sort keys are written as\n* zero-terminated byte strings. They consist of several substrings, one for\n* each collation strength level, that are delimited by 0x01 bytes.\n* If the string code points are appended for UCOL_IDENTICAL, then they are\n* processed for correct code point order comparison and may contain 0x01\n* bytes but not zero bytes.\n* </p>\n* <p>\n* An older set of APIs returns a <code>CollationKey</code> object that wraps\n* the sort key bytes instead of returning the bytes themselves.\n* Its use is deprecated, but it is still available for compatibility with\n* Java.\n* </p>\n* <p>\n* <strong>Note:</strong> <code>Collator</code>s with different Locale,\n* and CollationStrength settings will return different sort\n* orders for the same set of strings. Locales have specific collation rules,\n* and the way in which secondary and tertiary differences are taken into\n* account, for example, will result in a different sorting order for same\n* strings.\n* </p>\n* @see         RuleBasedCollator\n* @see         CollationKey\n* @see         CollationElementIterator\n* @see         Locale\n* @see         Normalizer\n* @version     2.0 11/15/01\n*/\n\nclass U_I18N_API Collator : public UObject {\npublic:\n\n    // Collator public enums -----------------------------------------------\n\n    /**\n     * Base letter represents a primary difference. Set comparison level to\n     * PRIMARY to ignore secondary and tertiary differences.<br>\n     * Use this to set the strength of a Collator object.<br>\n     * Example of primary difference, \"abc\" &lt; \"abd\"\n     *\n     * Diacritical differences on the same base letter represent a secondary\n     * difference. Set comparison level to SECONDARY to ignore tertiary\n     * differences. Use this to set the strength of a Collator object.<br>\n     * Example of secondary difference, \"&auml;\" >> \"a\".\n     *\n     * Uppercase and lowercase versions of the same character represents a\n     * tertiary difference.  Set comparison level to TERTIARY to include all\n     * comparison differences. Use this to set the strength of a Collator\n     * object.<br>\n     * Example of tertiary difference, \"abc\" &lt;&lt;&lt; \"ABC\".\n     *\n     * Two characters are considered \"identical\" when they have the same unicode\n     * spellings.<br>\n     * For example, \"&auml;\" == \"&auml;\".\n     *\n     * UCollationStrength is also used to determine the strength of sort keys\n     * generated from Collator objects.\n     * @stable ICU 2.0\n     */\n    enum ECollationStrength\n    {\n        PRIMARY    = UCOL_PRIMARY,  // 0\n        SECONDARY  = UCOL_SECONDARY,  // 1\n        TERTIARY   = UCOL_TERTIARY,  // 2\n        QUATERNARY = UCOL_QUATERNARY,  // 3\n        IDENTICAL  = UCOL_IDENTICAL  // 15\n    };\n\n    /**\n     * LESS is returned if source string is compared to be less than target\n     * string in the compare() method.\n     * EQUAL is returned if source string is compared to be equal to target\n     * string in the compare() method.\n     * GREATER is returned if source string is compared to be greater than\n     * target string in the compare() method.\n     * @see Collator#compare\n     * @deprecated ICU 2.6. Use C enum UCollationResult defined in ucol.h\n     */\n    enum EComparisonResult\n    {\n        LESS = UCOL_LESS,  // -1\n        EQUAL = UCOL_EQUAL,  // 0\n        GREATER = UCOL_GREATER  // 1\n    };\n\n    // Collator public destructor -----------------------------------------\n\n    /**\n     * Destructor\n     * @stable ICU 2.0\n     */\n    virtual ~Collator();\n\n    // Collator public methods --------------------------------------------\n\n    /**\n     * Returns TRUE if \"other\" is the same as \"this\".\n     *\n     * The base class implementation returns TRUE if \"other\" has the same type/class as \"this\":\n     * <code>typeid(*this) == typeid(other)</code>.\n     *\n     * Subclass implementations should do something like the following:\n     * <pre>\n     *   if (this == &other) { return TRUE; }\n     *   if (!Collator::operator==(other)) { return FALSE; }  // not the same class\n     *\n     *   const MyCollator &o = (const MyCollator&)other;\n     *   (compare this vs. o's subclass fields)\n     * </pre>\n     * @param other Collator object to be compared\n     * @return TRUE if other is the same as this.\n     * @stable ICU 2.0\n     */\n    virtual UBool operator==(const Collator& other) const;\n\n    /**\n     * Returns true if \"other\" is not the same as \"this\".\n     * Calls ! operator==(const Collator&) const which works for all subclasses.\n     * @param other Collator object to be compared\n     * @return TRUE if other is not the same as this.\n     * @stable ICU 2.0\n     */\n    virtual UBool operator!=(const Collator& other) const;\n\n    /**\n     * Makes a copy of this object.\n     * @return a copy of this object, owned by the caller\n     * @stable ICU 2.0\n     */\n    virtual Collator* clone(void) const = 0;\n\n    /**\n     * Creates the Collator object for the current default locale.\n     * The default locale is determined by Locale::getDefault.\n     * The UErrorCode& err parameter is used to return status information to the user.\n     * To check whether the construction succeeded or not, you should check the\n     * value of U_SUCCESS(err).  If you wish more detailed information, you can\n     * check for informational error results which still indicate success.\n     * U_USING_FALLBACK_ERROR indicates that a fall back locale was used. For\n     * example, 'de_CH' was requested, but nothing was found there, so 'de' was\n     * used. U_USING_DEFAULT_ERROR indicates that the default locale data was\n     * used; neither the requested locale nor any of its fall back locales\n     * could be found.\n     * The caller owns the returned object and is responsible for deleting it.\n     *\n     * @param err    the error code status.\n     * @return       the collation object of the default locale.(for example, en_US)\n     * @see Locale#getDefault\n     * @stable ICU 2.0\n     */\n    static Collator* U_EXPORT2 createInstance(UErrorCode&  err);\n\n    /**\n     * Gets the table-based collation object for the desired locale. The\n     * resource of the desired locale will be loaded by ResourceLoader.\n     * Locale::ENGLISH is the base collation table and all other languages are\n     * built on top of it with additional language-specific modifications.\n     * The UErrorCode& err parameter is used to return status information to the user.\n     * To check whether the construction succeeded or not, you should check\n     * the value of U_SUCCESS(err).  If you wish more detailed information, you\n     * can check for informational error results which still indicate success.\n     * U_USING_FALLBACK_ERROR indicates that a fall back locale was used.  For\n     * example, 'de_CH' was requested, but nothing was found there, so 'de' was\n     * used.  U_USING_DEFAULT_ERROR indicates that the default locale data was\n     * used; neither the requested locale nor any of its fall back locales\n     * could be found.\n     * The caller owns the returned object and is responsible for deleting it.\n     * @param loc    The locale ID for which to open a collator.\n     * @param err    the error code status.\n     * @return       the created table-based collation object based on the desired\n     *               locale.\n     * @see Locale\n     * @see ResourceLoader\n     * @stable ICU 2.2\n     */\n    static Collator* U_EXPORT2 createInstance(const Locale& loc, UErrorCode& err);\n\n#ifdef U_USE_COLLATION_OBSOLETE_2_6\n    /**\n     * Create a Collator with a specific version.\n     * This is the same as createInstance(loc, err) except that getVersion() of\n     * the returned object is guaranteed to be the same as the version\n     * parameter.\n     * This is designed to be used to open the same collator for a given\n     * locale even when ICU is updated.\n     * The same locale and version guarantees the same sort keys and\n     * comparison results.\n     * <p>\n     * Note: this API will be removed in a future release.  Use\n     * <tt>createInstance(const Locale&, UErrorCode&) instead.</tt></p>\n     *\n     * @param loc The locale ID for which to open a collator.\n     * @param version The requested collator version.\n     * @param err A reference to a UErrorCode,\n     *            must not indicate a failure before calling this function.\n     * @return A pointer to a Collator, or 0 if an error occurred\n     *         or a collator with the requested version is not available.\n     *\n     * @see getVersion\n     * @obsolete ICU 2.6\n     */\n    static Collator *createInstance(const Locale &loc, UVersionInfo version, UErrorCode &err);\n#endif\n\n    /**\n     * The comparison function compares the character data stored in two\n     * different strings. Returns information about whether a string is less\n     * than, greater than or equal to another string.\n     * @param source the source string to be compared with.\n     * @param target the string that is to be compared with the source string.\n     * @return Returns a byte value. GREATER if source is greater\n     * than target; EQUAL if source is equal to target; LESS if source is less\n     * than target\n     * @deprecated ICU 2.6 use the overload with UErrorCode &\n     */\n    virtual EComparisonResult compare(const UnicodeString& source,\n                                      const UnicodeString& target) const;\n\n    /**\n     * The comparison function compares the character data stored in two\n     * different strings. Returns information about whether a string is less\n     * than, greater than or equal to another string.\n     * @param source the source string to be compared with.\n     * @param target the string that is to be compared with the source string.\n     * @param status possible error code\n     * @return Returns an enum value. UCOL_GREATER if source is greater\n     * than target; UCOL_EQUAL if source is equal to target; UCOL_LESS if source is less\n     * than target\n     * @stable ICU 2.6\n     */\n    virtual UCollationResult compare(const UnicodeString& source,\n                                      const UnicodeString& target,\n                                      UErrorCode &status) const = 0;\n\n    /**\n     * Does the same thing as compare but limits the comparison to a specified\n     * length\n     * @param source the source string to be compared with.\n     * @param target the string that is to be compared with the source string.\n     * @param length the length the comparison is limited to\n     * @return Returns a byte value. GREATER if source (up to the specified\n     *         length) is greater than target; EQUAL if source (up to specified\n     *         length) is equal to target; LESS if source (up to the specified\n     *         length) is less  than target.\n     * @deprecated ICU 2.6 use the overload with UErrorCode &\n     */\n    virtual EComparisonResult compare(const UnicodeString& source,\n                                      const UnicodeString& target,\n                                      int32_t length) const;\n\n    /**\n     * Does the same thing as compare but limits the comparison to a specified\n     * length\n     * @param source the source string to be compared with.\n     * @param target the string that is to be compared with the source string.\n     * @param length the length the comparison is limited to\n     * @param status possible error code\n     * @return Returns an enum value. UCOL_GREATER if source (up to the specified\n     *         length) is greater than target; UCOL_EQUAL if source (up to specified\n     *         length) is equal to target; UCOL_LESS if source (up to the specified\n     *         length) is less  than target.\n     * @stable ICU 2.6\n     */\n    virtual UCollationResult compare(const UnicodeString& source,\n                                      const UnicodeString& target,\n                                      int32_t length,\n                                      UErrorCode &status) const = 0;\n\n    /**\n     * The comparison function compares the character data stored in two\n     * different string arrays. Returns information about whether a string array\n     * is less than, greater than or equal to another string array.\n     * <p>Example of use:\n     * <pre>\n     * .       UChar ABC[] = {0x41, 0x42, 0x43, 0};  // = \"ABC\"\n     * .       UChar abc[] = {0x61, 0x62, 0x63, 0};  // = \"abc\"\n     * .       UErrorCode status = U_ZERO_ERROR;\n     * .       Collator *myCollation =\n     * .                         Collator::createInstance(Locale::US, status);\n     * .       if (U_FAILURE(status)) return;\n     * .       myCollation->setStrength(Collator::PRIMARY);\n     * .       // result would be Collator::EQUAL (\"abc\" == \"ABC\")\n     * .       // (no primary difference between \"abc\" and \"ABC\")\n     * .       Collator::EComparisonResult result =\n     * .                             myCollation->compare(abc, 3, ABC, 3);\n     * .       myCollation->setStrength(Collator::TERTIARY);\n     * .       // result would be Collator::LESS (\"abc\" &lt;&lt;&lt; \"ABC\")\n     * .       // (with tertiary difference between \"abc\" and \"ABC\")\n     * .       result = myCollation->compare(abc, 3, ABC, 3);\n     * </pre>\n     * @param source the source string array to be compared with.\n     * @param sourceLength the length of the source string array.  If this value\n     *        is equal to -1, the string array is null-terminated.\n     * @param target the string that is to be compared with the source string.\n     * @param targetLength the length of the target string array.  If this value\n     *        is equal to -1, the string array is null-terminated.\n     * @return Returns a byte value. GREATER if source is greater than target;\n     *         EQUAL if source is equal to target; LESS if source is less than\n     *         target\n     * @deprecated ICU 2.6 use the overload with UErrorCode &\n     */\n    virtual EComparisonResult compare(const UChar* source, int32_t sourceLength,\n                                      const UChar* target, int32_t targetLength)\n                                      const;\n\n    /**\n     * The comparison function compares the character data stored in two\n     * different string arrays. Returns information about whether a string array\n     * is less than, greater than or equal to another string array.\n     * @param source the source string array to be compared with.\n     * @param sourceLength the length of the source string array.  If this value\n     *        is equal to -1, the string array is null-terminated.\n     * @param target the string that is to be compared with the source string.\n     * @param targetLength the length of the target string array.  If this value\n     *        is equal to -1, the string array is null-terminated.\n     * @param status possible error code\n     * @return Returns an enum value. UCOL_GREATER if source is greater\n     * than target; UCOL_EQUAL if source is equal to target; UCOL_LESS if source is less\n     * than target\n     * @stable ICU 2.6\n     */\n    virtual UCollationResult compare(const UChar* source, int32_t sourceLength,\n                                      const UChar* target, int32_t targetLength,\n                                      UErrorCode &status) const = 0;\n\n    /**\n     * Compares two strings using the Collator.\n     * Returns whether the first one compares less than/equal to/greater than\n     * the second one.\n     * This version takes UCharIterator input.\n     * @param sIter the first (\"source\") string iterator\n     * @param tIter the second (\"target\") string iterator\n     * @param status ICU status\n     * @return UCOL_LESS, UCOL_EQUAL or UCOL_GREATER\n     * @stable ICU 4.2\n     */\n    virtual UCollationResult compare(UCharIterator &sIter,\n                                     UCharIterator &tIter,\n                                     UErrorCode &status) const;\n\n    /**\n     * Compares two UTF-8 strings using the Collator.\n     * Returns whether the first one compares less than/equal to/greater than\n     * the second one.\n     * This version takes UTF-8 input.\n     * Note that a StringPiece can be implicitly constructed\n     * from a std::string or a NUL-terminated const char * string.\n     * @param source the first UTF-8 string\n     * @param target the second UTF-8 string\n     * @param status ICU status\n     * @return UCOL_LESS, UCOL_EQUAL or UCOL_GREATER\n     * @stable ICU 4.2\n     */\n    virtual UCollationResult compareUTF8(const StringPiece &source,\n                                         const StringPiece &target,\n                                         UErrorCode &status) const;\n\n    /**\n     * Transforms the string into a series of characters that can be compared\n     * with CollationKey::compareTo. It is not possible to restore the original\n     * string from the chars in the sort key.  The generated sort key handles\n     * only a limited number of ignorable characters.\n     * <p>Use CollationKey::equals or CollationKey::compare to compare the\n     * generated sort keys.\n     * If the source string is null, a null collation key will be returned.\n     * @param source the source string to be transformed into a sort key.\n     * @param key the collation key to be filled in\n     * @param status the error code status.\n     * @return the collation key of the string based on the collation rules.\n     * @see CollationKey#compare\n     * @stable ICU 2.0\n     */\n    virtual CollationKey& getCollationKey(const UnicodeString&  source,\n                                          CollationKey& key,\n                                          UErrorCode& status) const = 0;\n\n    /**\n     * Transforms the string into a series of characters that can be compared\n     * with CollationKey::compareTo. It is not possible to restore the original\n     * string from the chars in the sort key.  The generated sort key handles\n     * only a limited number of ignorable characters.\n     * <p>Use CollationKey::equals or CollationKey::compare to compare the\n     * generated sort keys.\n     * <p>If the source string is null, a null collation key will be returned.\n     * @param source the source string to be transformed into a sort key.\n     * @param sourceLength length of the collation key\n     * @param key the collation key to be filled in\n     * @param status the error code status.\n     * @return the collation key of the string based on the collation rules.\n     * @see CollationKey#compare\n     * @stable ICU 2.0\n     */\n    virtual CollationKey& getCollationKey(const UChar*source,\n                                          int32_t sourceLength,\n                                          CollationKey& key,\n                                          UErrorCode& status) const = 0;\n    /**\n     * Generates the hash code for the collation object\n     * @stable ICU 2.0\n     */\n    virtual int32_t hashCode(void) const = 0;\n\n    /**\n     * Gets the locale of the Collator\n     *\n     * @param type can be either requested, valid or actual locale. For more\n     *             information see the definition of ULocDataLocaleType in\n     *             uloc.h\n     * @param status the error code status.\n     * @return locale where the collation data lives. If the collator\n     *         was instantiated from rules, locale is empty.\n     * @deprecated ICU 2.8 This API is under consideration for revision\n     * in ICU 3.0.\n     */\n    virtual Locale getLocale(ULocDataLocaleType type, UErrorCode& status) const = 0;\n\n    /**\n     * Convenience method for comparing two strings based on the collation rules.\n     * @param source the source string to be compared with.\n     * @param target the target string to be compared with.\n     * @return true if the first string is greater than the second one,\n     *         according to the collation rules. false, otherwise.\n     * @see Collator#compare\n     * @stable ICU 2.0\n     */\n    UBool greater(const UnicodeString& source, const UnicodeString& target)\n                  const;\n\n    /**\n     * Convenience method for comparing two strings based on the collation rules.\n     * @param source the source string to be compared with.\n     * @param target the target string to be compared with.\n     * @return true if the first string is greater than or equal to the second\n     *         one, according to the collation rules. false, otherwise.\n     * @see Collator#compare\n     * @stable ICU 2.0\n     */\n    UBool greaterOrEqual(const UnicodeString& source,\n                         const UnicodeString& target) const;\n\n    /**\n     * Convenience method for comparing two strings based on the collation rules.\n     * @param source the source string to be compared with.\n     * @param target the target string to be compared with.\n     * @return true if the strings are equal according to the collation rules.\n     *         false, otherwise.\n     * @see Collator#compare\n     * @stable ICU 2.0\n     */\n    UBool equals(const UnicodeString& source, const UnicodeString& target) const;\n\n    /**\n     * Determines the minimum strength that will be used in comparison or\n     * transformation.\n     * <p>E.g. with strength == SECONDARY, the tertiary difference is ignored\n     * <p>E.g. with strength == PRIMARY, the secondary and tertiary difference\n     * are ignored.\n     * @return the current comparison level.\n     * @see Collator#setStrength\n     * @deprecated ICU 2.6 Use getAttribute(UCOL_STRENGTH...) instead\n     */\n    virtual ECollationStrength getStrength(void) const;\n\n    /**\n     * Sets the minimum strength to be used in comparison or transformation.\n     * <p>Example of use:\n     * <pre>\n     *  \\code\n     *  UErrorCode status = U_ZERO_ERROR;\n     *  Collator*myCollation = Collator::createInstance(Locale::US, status);\n     *  if (U_FAILURE(status)) return;\n     *  myCollation->setStrength(Collator::PRIMARY);\n     *  // result will be \"abc\" == \"ABC\"\n     *  // tertiary differences will be ignored\n     *  Collator::ComparisonResult result = myCollation->compare(\"abc\", \"ABC\");\n     * \\endcode\n     * </pre>\n     * @see Collator#getStrength\n     * @param newStrength the new comparison level.\n     * @deprecated ICU 2.6 Use setAttribute(UCOL_STRENGTH...) instead\n     */\n    virtual void setStrength(ECollationStrength newStrength);\n\n    /**\n     * Retrieves the reordering codes for this collator.\n     * @param dest The array to fill with the script ordering.\n     * @param destCapacity The length of dest. If it is 0, then dest may be NULL and the function\n     *  will only return the length of the result without writing any of the result string (pre-flighting).\n     * @param status A reference to an error code value, which must not indicate\n     * a failure before the function call.\n     * @return The length of the script ordering array.\n     * @see ucol_setReorderCodes\n     * @see Collator#getEquivalentReorderCodes\n     * @see Collator#setReorderCodes\n     * @see UScriptCode\n     * @see UColReorderCode\n     * @stable ICU 4.8 \n     */\n     virtual int32_t getReorderCodes(int32_t *dest,\n                                     int32_t destCapacity,\n                                     UErrorCode& status) const;\n\n    /**\n     * Sets the ordering of scripts for this collator.\n     *\n     * <p>The reordering codes are a combination of script codes and reorder codes.\n     * @param reorderCodes An array of script codes in the new order. This can be NULL if the \n     * length is also set to 0. An empty array will clear any reordering codes on the collator.\n     * @param reorderCodesLength The length of reorderCodes.\n     * @param status error code\n     * @see Collator#getReorderCodes\n     * @see Collator#getEquivalentReorderCodes\n     * @see UScriptCode\n     * @see UColReorderCode\n     * @stable ICU 4.8 \n     */\n     virtual void setReorderCodes(const int32_t* reorderCodes,\n                                  int32_t reorderCodesLength,\n                                  UErrorCode& status) ;\n\n    /**\n     * Retrieves the reorder codes that are grouped with the given reorder code. Some reorder\n     * codes will be grouped and must reorder together.\n     * @param reorderCode The reorder code to determine equivalence for. \n     * @param dest The array to fill with the script equivalene reordering codes.\n     * @param destCapacity The length of dest. If it is 0, then dest may be NULL and the \n     * function will only return the length of the result without writing any of the result \n     * string (pre-flighting).\n     * @param status A reference to an error code value, which must not indicate \n     * a failure before the function call.\n     * @return The length of the of the reordering code equivalence array.\n     * @see ucol_setReorderCodes\n     * @see Collator#getReorderCodes\n     * @see Collator#setReorderCodes\n     * @see UScriptCode\n     * @see UColReorderCode\n     * @stable ICU 4.8 \n     */\n    static int32_t U_EXPORT2 getEquivalentReorderCodes(int32_t reorderCode,\n                                int32_t* dest,\n                                int32_t destCapacity,\n                                UErrorCode& status);\n\n    /**\n     * Get name of the object for the desired Locale, in the desired langauge\n     * @param objectLocale must be from getAvailableLocales\n     * @param displayLocale specifies the desired locale for output\n     * @param name the fill-in parameter of the return value\n     * @return display-able name of the object for the object locale in the\n     *         desired language\n     * @stable ICU 2.0\n     */\n    static UnicodeString& U_EXPORT2 getDisplayName(const Locale& objectLocale,\n                                         const Locale& displayLocale,\n                                         UnicodeString& name);\n\n    /**\n    * Get name of the object for the desired Locale, in the langauge of the\n    * default locale.\n    * @param objectLocale must be from getAvailableLocales\n    * @param name the fill-in parameter of the return value\n    * @return name of the object for the desired locale in the default language\n    * @stable ICU 2.0\n    */\n    static UnicodeString& U_EXPORT2 getDisplayName(const Locale& objectLocale,\n                                         UnicodeString& name);\n\n    /**\n     * Get the set of Locales for which Collations are installed.\n     *\n     * <p>Note this does not include locales supported by registered collators.\n     * If collators might have been registered, use the overload of getAvailableLocales\n     * that returns a StringEnumeration.</p>\n     *\n     * @param count the output parameter of number of elements in the locale list\n     * @return the list of available locales for which collations are installed\n     * @stable ICU 2.0\n     */\n    static const Locale* U_EXPORT2 getAvailableLocales(int32_t& count);\n\n    /**\n     * Return a StringEnumeration over the locales available at the time of the call,\n     * including registered locales.  If a severe error occurs (such as out of memory\n     * condition) this will return null. If there is no locale data, an empty enumeration\n     * will be returned.\n     * @return a StringEnumeration over the locales available at the time of the call\n     * @stable ICU 2.6\n     */\n    static StringEnumeration* U_EXPORT2 getAvailableLocales(void);\n\n    /**\n     * Create a string enumerator of all possible keywords that are relevant to\n     * collation. At this point, the only recognized keyword for this\n     * service is \"collation\".\n     * @param status input-output error code\n     * @return a string enumeration over locale strings. The caller is\n     * responsible for closing the result.\n     * @stable ICU 3.0\n     */\n    static StringEnumeration* U_EXPORT2 getKeywords(UErrorCode& status);\n\n    /**\n     * Given a keyword, create a string enumeration of all values\n     * for that keyword that are currently in use.\n     * @param keyword a particular keyword as enumerated by\n     * ucol_getKeywords. If any other keyword is passed in, status is set\n     * to U_ILLEGAL_ARGUMENT_ERROR.\n     * @param status input-output error code\n     * @return a string enumeration over collation keyword values, or NULL\n     * upon error. The caller is responsible for deleting the result.\n     * @stable ICU 3.0\n     */\n    static StringEnumeration* U_EXPORT2 getKeywordValues(const char *keyword, UErrorCode& status);\n\n    /**\n     * Given a key and a locale, returns an array of string values in a preferred\n     * order that would make a difference. These are all and only those values where\n     * the open (creation) of the service with the locale formed from the input locale\n     * plus input keyword and that value has different behavior than creation with the\n     * input locale alone.\n     * @param keyword        one of the keys supported by this service.  For now, only\n     *                      \"collation\" is supported.\n     * @param locale        the locale\n     * @param commonlyUsed  if set to true it will return only commonly used values\n     *                      with the given locale in preferred order.  Otherwise,\n     *                      it will return all the available values for the locale.\n     * @param status ICU status\n     * @return a string enumeration over keyword values for the given key and the locale.\n     * @stable ICU 4.2\n     */\n    static StringEnumeration* U_EXPORT2 getKeywordValuesForLocale(const char* keyword, const Locale& locale,\n                                                                    UBool commonlyUsed, UErrorCode& status);\n\n    /**\n     * Return the functionally equivalent locale for the given\n     * requested locale, with respect to given keyword, for the\n     * collation service.  If two locales return the same result, then\n     * collators instantiated for these locales will behave\n     * equivalently.  The converse is not always true; two collators\n     * may in fact be equivalent, but return different results, due to\n     * internal details.  The return result has no other meaning than\n     * that stated above, and implies nothing as to the relationship\n     * between the two locales.  This is intended for use by\n     * applications who wish to cache collators, or otherwise reuse\n     * collators when possible.  The functional equivalent may change\n     * over time.  For more information, please see the <a\n     * href=\"http://icu-project.org/userguide/locale.html#services\">\n     * Locales and Services</a> section of the ICU User Guide.\n     * @param keyword a particular keyword as enumerated by\n     * ucol_getKeywords.\n     * @param locale the requested locale\n     * @param isAvailable reference to a fillin parameter that\n     * indicates whether the requested locale was 'available' to the\n     * collation service. A locale is defined as 'available' if it\n     * physically exists within the collation locale data.\n     * @param status reference to input-output error code\n     * @return the functionally equivalent collation locale, or the root\n     * locale upon error.\n     * @stable ICU 3.0\n     */\n    static Locale U_EXPORT2 getFunctionalEquivalent(const char* keyword, const Locale& locale,\n                                          UBool& isAvailable, UErrorCode& status);\n\n#if !UCONFIG_NO_SERVICE\n    /**\n     * Register a new Collator.  The collator will be adopted.\n     * @param toAdopt the Collator instance to be adopted\n     * @param locale the locale with which the collator will be associated\n     * @param status the in/out status code, no special meanings are assigned\n     * @return a registry key that can be used to unregister this collator\n     * @stable ICU 2.6\n     */\n    static URegistryKey U_EXPORT2 registerInstance(Collator* toAdopt, const Locale& locale, UErrorCode& status);\n\n    /**\n     * Register a new CollatorFactory.  The factory will be adopted.\n     * @param toAdopt the CollatorFactory instance to be adopted\n     * @param status the in/out status code, no special meanings are assigned\n     * @return a registry key that can be used to unregister this collator\n     * @stable ICU 2.6\n     */\n    static URegistryKey U_EXPORT2 registerFactory(CollatorFactory* toAdopt, UErrorCode& status);\n\n    /**\n     * Unregister a previously-registered Collator or CollatorFactory\n     * using the key returned from the register call.  Key becomes\n     * invalid after a successful call and should not be used again.\n     * The object corresponding to the key will be deleted.\n     * @param key the registry key returned by a previous call to registerInstance\n     * @param status the in/out status code, no special meanings are assigned\n     * @return TRUE if the collator for the key was successfully unregistered\n     * @stable ICU 2.6\n     */\n    static UBool U_EXPORT2 unregister(URegistryKey key, UErrorCode& status);\n#endif /* UCONFIG_NO_SERVICE */\n\n    /**\n     * Gets the version information for a Collator.\n     * @param info the version # information, the result will be filled in\n     * @stable ICU 2.0\n     */\n    virtual void getVersion(UVersionInfo info) const = 0;\n\n    /**\n     * Returns a unique class ID POLYMORPHICALLY. Pure virtual method.\n     * This method is to implement a simple version of RTTI, since not all C++\n     * compilers support genuine RTTI. Polymorphic operator==() and clone()\n     * methods call this method.\n     * @return The class ID for this object. All objects of a given class have\n     *         the same class ID.  Objects of other classes have different class\n     *         IDs.\n     * @stable ICU 2.0\n     */\n    virtual UClassID getDynamicClassID(void) const = 0;\n\n    /**\n     * Universal attribute setter\n     * @param attr attribute type\n     * @param value attribute value\n     * @param status to indicate whether the operation went on smoothly or\n     *        there were errors\n     * @stable ICU 2.2\n     */\n    virtual void setAttribute(UColAttribute attr, UColAttributeValue value,\n                              UErrorCode &status) = 0;\n\n    /**\n     * Universal attribute getter\n     * @param attr attribute type\n     * @param status to indicate whether the operation went on smoothly or\n     *        there were errors\n     * @return attribute value\n     * @stable ICU 2.2\n     */\n    virtual UColAttributeValue getAttribute(UColAttribute attr,\n                                            UErrorCode &status) const = 0;\n\n    /**\n     * Sets the variable top to a collation element value of a string supplied.\n     * @param varTop one or more (if contraction) UChars to which the variable top should be set\n     * @param len length of variable top string. If -1 it is considered to be zero terminated.\n     * @param status error code. If error code is set, the return value is undefined. Errors set by this function are: <br>\n     *    U_CE_NOT_FOUND_ERROR if more than one character was passed and there is no such a contraction<br>\n     *    U_PRIMARY_TOO_LONG_ERROR if the primary for the variable top has more than two bytes\n     * @return a 32 bit value containing the value of the variable top in upper 16 bits. Lower 16 bits are undefined\n     * @stable ICU 2.0\n     */\n    virtual uint32_t setVariableTop(const UChar *varTop, int32_t len, UErrorCode &status) = 0;\n\n    /**\n     * Sets the variable top to a collation element value of a string supplied.\n     * @param varTop an UnicodeString size 1 or more (if contraction) of UChars to which the variable top should be set\n     * @param status error code. If error code is set, the return value is undefined. Errors set by this function are: <br>\n     *    U_CE_NOT_FOUND_ERROR if more than one character was passed and there is no such a contraction<br>\n     *    U_PRIMARY_TOO_LONG_ERROR if the primary for the variable top has more than two bytes\n     * @return a 32 bit value containing the value of the variable top in upper 16 bits. Lower 16 bits are undefined\n     * @stable ICU 2.0\n     */\n    virtual uint32_t setVariableTop(const UnicodeString &varTop, UErrorCode &status) = 0;\n\n    /**\n     * Sets the variable top to a collation element value supplied. Variable top is set to the upper 16 bits.\n     * Lower 16 bits are ignored.\n     * @param varTop CE value, as returned by setVariableTop or ucol)getVariableTop\n     * @param status error code (not changed by function)\n     * @stable ICU 2.0\n     */\n    virtual void setVariableTop(uint32_t varTop, UErrorCode &status) = 0;\n\n    /**\n     * Gets the variable top value of a Collator.\n     * Lower 16 bits are undefined and should be ignored.\n     * @param status error code (not changed by function). If error code is set, the return value is undefined.\n     * @stable ICU 2.0\n     */\n    virtual uint32_t getVariableTop(UErrorCode &status) const = 0;\n\n    /**\n     * Get an UnicodeSet that contains all the characters and sequences\n     * tailored in this collator.\n     * @param status      error code of the operation\n     * @return a pointer to a UnicodeSet object containing all the\n     *         code points and sequences that may sort differently than\n     *         in the UCA. The object must be disposed of by using delete\n     * @stable ICU 2.4\n     */\n    virtual UnicodeSet *getTailoredSet(UErrorCode &status) const;\n\n    /**\n     * Same as clone().\n     * The base class implementation simply calls clone().\n     * @return a copy of this object, owned by the caller\n     * @see clone()\n     * @deprecated ICU 50 no need to have two methods for cloning\n     */\n    virtual Collator* safeClone(void) const;\n\n    /**\n     * Get the sort key as an array of bytes from an UnicodeString.\n     * Sort key byte arrays are zero-terminated and can be compared using\n     * strcmp().\n     * @param source string to be processed.\n     * @param result buffer to store result in. If NULL, number of bytes needed\n     *        will be returned.\n     * @param resultLength length of the result buffer. If if not enough the\n     *        buffer will be filled to capacity.\n     * @return Number of bytes needed for storing the sort key\n     * @stable ICU 2.2\n     */\n    virtual int32_t getSortKey(const UnicodeString& source,\n                              uint8_t* result,\n                              int32_t resultLength) const = 0;\n\n    /**\n     * Get the sort key as an array of bytes from an UChar buffer.\n     * Sort key byte arrays are zero-terminated and can be compared using\n     * strcmp().\n     * @param source string to be processed.\n     * @param sourceLength length of string to be processed.\n     *        If -1, the string is 0 terminated and length will be decided by the\n     *        function.\n     * @param result buffer to store result in. If NULL, number of bytes needed\n     *        will be returned.\n     * @param resultLength length of the result buffer. If if not enough the\n     *        buffer will be filled to capacity.\n     * @return Number of bytes needed for storing the sort key\n     * @stable ICU 2.2\n     */\n    virtual int32_t getSortKey(const UChar*source, int32_t sourceLength,\n                               uint8_t*result, int32_t resultLength) const = 0;\n\n    /**\n     * Produce a bound for a given sortkey and a number of levels.\n     * Return value is always the number of bytes needed, regardless of\n     * whether the result buffer was big enough or even valid.<br>\n     * Resulting bounds can be used to produce a range of strings that are\n     * between upper and lower bounds. For example, if bounds are produced\n     * for a sortkey of string \"smith\", strings between upper and lower\n     * bounds with one level would include \"Smith\", \"SMITH\", \"sMiTh\".<br>\n     * There are two upper bounds that can be produced. If UCOL_BOUND_UPPER\n     * is produced, strings matched would be as above. However, if bound\n     * produced using UCOL_BOUND_UPPER_LONG is used, the above example will\n     * also match \"Smithsonian\" and similar.<br>\n     * For more on usage, see example in cintltst/capitst.c in procedure\n     * TestBounds.\n     * Sort keys may be compared using <TT>strcmp</TT>.\n     * @param source The source sortkey.\n     * @param sourceLength The length of source, or -1 if null-terminated.\n     *                     (If an unmodified sortkey is passed, it is always null\n     *                      terminated).\n     * @param boundType Type of bound required. It can be UCOL_BOUND_LOWER, which\n     *                  produces a lower inclusive bound, UCOL_BOUND_UPPER, that\n     *                  produces upper bound that matches strings of the same length\n     *                  or UCOL_BOUND_UPPER_LONG that matches strings that have the\n     *                  same starting substring as the source string.\n     * @param noOfLevels  Number of levels required in the resulting bound (for most\n     *                    uses, the recommended value is 1). See users guide for\n     *                    explanation on number of levels a sortkey can have.\n     * @param result A pointer to a buffer to receive the resulting sortkey.\n     * @param resultLength The maximum size of result.\n     * @param status Used for returning error code if something went wrong. If the\n     *               number of levels requested is higher than the number of levels\n     *               in the source key, a warning (U_SORT_KEY_TOO_SHORT_WARNING) is\n     *               issued.\n     * @return The size needed to fully store the bound.\n     * @see ucol_keyHashCode\n     * @stable ICU 2.1\n     */\n    static int32_t U_EXPORT2 getBound(const uint8_t       *source,\n            int32_t             sourceLength,\n            UColBoundMode       boundType,\n            uint32_t            noOfLevels,\n            uint8_t             *result,\n            int32_t             resultLength,\n            UErrorCode          &status);\n\n\nprotected:\n\n    // Collator protected constructors -------------------------------------\n\n    /**\n    * Default constructor.\n    * Constructor is different from the old default Collator constructor.\n    * The task for determing the default collation strength and normalization\n    * mode is left to the child class.\n    * @stable ICU 2.0\n    */\n    Collator();\n\n#ifndef U_HIDE_DEPRECATED_API\n    /**\n    * Constructor.\n    * Empty constructor, does not handle the arguments.\n    * This constructor is done for backward compatibility with 1.7 and 1.8.\n    * The task for handling the argument collation strength and normalization\n    * mode is left to the child class.\n    * @param collationStrength collation strength\n    * @param decompositionMode\n    * @deprecated ICU 2.4. Subclasses should use the default constructor\n    * instead and handle the strength and normalization mode themselves.\n    */\n    Collator(UCollationStrength collationStrength,\n             UNormalizationMode decompositionMode);\n#endif  /* U_HIDE_DEPRECATED_API */\n\n    /**\n    * Copy constructor.\n    * @param other Collator object to be copied from\n    * @stable ICU 2.0\n    */\n    Collator(const Collator& other);\n\n    // Collator protected methods -----------------------------------------\n\n\n   /**\n    * Used internally by registraton to define the requested and valid locales.\n    * @param requestedLocale the requested locale\n    * @param validLocale the valid locale\n    * @param actualLocale the actual locale\n    * @internal\n    */\n    virtual void setLocales(const Locale& requestedLocale, const Locale& validLocale, const Locale& actualLocale);\n\npublic:\n#if !UCONFIG_NO_SERVICE\n#ifndef U_HIDE_INTERNAL_API\n    /**\n     * used only by ucol_open, not for public use\n     * @internal\n     */\n    static UCollator* createUCollator(const char* loc, UErrorCode* status);\n#endif  /* U_HIDE_INTERNAL_API */\n#endif\n\n    /** Get the short definition string for a collator. This internal API harvests the collator's\n     *  locale and the attribute set and produces a string that can be used for opening \n     *  a collator with the same properties using the ucol_openFromShortString API.\n     *  This string will be normalized.\n     *  The structure and the syntax of the string is defined in the \"Naming collators\"\n     *  section of the users guide: \n     *  http://icu-project.org/userguide/Collate_Concepts.html#Naming_Collators\n     *  This function supports preflighting.\n     * \n     *  This is internal, and intended to be used with delegate converters.\n     *\n     *  @param locale a locale that will appear as a collators locale in the resulting\n     *                short string definition. If NULL, the locale will be harvested \n     *                from the collator.\n     *  @param buffer space to hold the resulting string\n     *  @param capacity capacity of the buffer\n     *  @param status for returning errors. All the preflighting errors are featured\n     *  @return length of the resulting string\n     *  @see ucol_openFromShortString\n     *  @see ucol_normalizeShortDefinitionString\n     *  @see ucol_getShortDefinitionString\n     *  @internal\n     */\n    virtual int32_t internalGetShortDefinitionString(const char *locale,\n                                                     char *buffer,\n                                                     int32_t capacity,\n                                                     UErrorCode &status) const;\nprivate:\n    /**\n     * Assignment operator. Private for now.\n     * @internal\n     */\n    Collator& operator=(const Collator& other);\n\n    friend class CFactory;\n    friend class SimpleCFactory;\n    friend class ICUCollatorFactory;\n    friend class ICUCollatorService;\n    static Collator* makeInstance(const Locale& desiredLocale,\n                                  UErrorCode& status);\n\n    // Collator private data members ---------------------------------------\n\n    /*\n    synwee : removed as attributes to be handled by child class\n    UCollationStrength  strength;\n    Normalizer::EMode  decmp;\n    */\n    /* This is useless information */\n/*  static const UVersionInfo fVersion;*/\n};\n\n#if !UCONFIG_NO_SERVICE\n/**\n * A factory, used with registerFactory, the creates multiple collators and provides\n * display names for them.  A factory supports some number of locales-- these are the\n * locales for which it can create collators.  The factory can be visible, in which\n * case the supported locales will be enumerated by getAvailableLocales, or invisible,\n * in which they are not.  Invisible locales are still supported, they are just not\n * listed by getAvailableLocales.\n * <p>\n * If standard locale display names are sufficient, Collator instances can\n * be registered using registerInstance instead.</p>\n * <p>\n * Note: if the collators are to be used from C APIs, they must be instances\n * of RuleBasedCollator.</p>\n *\n * @stable ICU 2.6\n */\nclass U_I18N_API CollatorFactory : public UObject {\npublic:\n\n    /**\n     * Destructor\n     * @stable ICU 3.0\n     */\n    virtual ~CollatorFactory();\n\n    /**\n     * Return true if this factory is visible.  Default is true.\n     * If not visible, the locales supported by this factory will not\n     * be listed by getAvailableLocales.\n     * @return true if the factory is visible.\n     * @stable ICU 2.6\n     */\n    virtual UBool visible(void) const;\n\n    /**\n     * Return a collator for the provided locale.  If the locale\n     * is not supported, return NULL.\n     * @param loc the locale identifying the collator to be created.\n     * @return a new collator if the locale is supported, otherwise NULL.\n     * @stable ICU 2.6\n     */\n    virtual Collator* createCollator(const Locale& loc) = 0;\n\n    /**\n     * Return the name of the collator for the objectLocale, localized for the displayLocale.\n     * If objectLocale is not supported, or the factory is not visible, set the result string\n     * to bogus.\n     * @param objectLocale the locale identifying the collator\n     * @param displayLocale the locale for which the display name of the collator should be localized\n     * @param result an output parameter for the display name, set to bogus if not supported.\n     * @return the display name\n     * @stable ICU 2.6\n     */\n    virtual  UnicodeString& getDisplayName(const Locale& objectLocale,\n                                           const Locale& displayLocale,\n                                           UnicodeString& result);\n\n    /**\n     * Return an array of all the locale names directly supported by this factory.\n     * The number of names is returned in count.  This array is owned by the factory.\n     * Its contents must never change.\n     * @param count output parameter for the number of locales supported by the factory\n     * @param status the in/out error code\n     * @return a pointer to an array of count UnicodeStrings.\n     * @stable ICU 2.6\n     */\n    virtual const UnicodeString * getSupportedIDs(int32_t &count, UErrorCode& status) = 0;\n};\n#endif /* UCONFIG_NO_SERVICE */\n\n// Collator inline methods -----------------------------------------------\n\nU_NAMESPACE_END\n\n#endif /* #if !UCONFIG_NO_COLLATION */\n\n#endif\n"
  },
  {
    "path": "deprecated/android/addons/icucompat/unicode/colldata.h",
    "content": "/*\n ******************************************************************************\n *   Copyright (C) 1996-2012, International Business Machines                 *\n *   Corporation and others.  All Rights Reserved.                            *\n ******************************************************************************\n */\n\n/**\n * \\file \n * \\brief C++ API: Collation data used to compute minLengthInChars.\n * \\internal\n */\n \n#ifndef COLL_DATA_H\n#define COLL_DATA_H\n\n#include \"unicode/utypes.h\"\n\n#if !UCONFIG_NO_COLLATION\n\n#include \"unicode/uobject.h\"\n#include \"unicode/ucol.h\"\n\nU_NAMESPACE_BEGIN\n\n#ifndef U_HIDE_INTERNAL_API\n/**\n * The size of the internal buffer for the Collator's short description string.\n * @internal ICU 4.0.1 technology preview\n */\n#define KEY_BUFFER_SIZE 64\n\n /**\n  * The size of the internal CE buffer in a <code>CEList</code> object\n  * @internal ICU 4.0.1 technology preview\n  */\n#define CELIST_BUFFER_SIZE 4\n\n/**\n * \\def INSTRUMENT_CELIST\n * Define this to enable the <code>CEList</code> objects to collect\n * statistics.\n * @internal ICU 4.0.1 technology preview\n */\n//#define INSTRUMENT_CELIST\n\n /**\n  * The size of the initial list in a <code>StringList</code> object.\n  * @internal ICU 4.0.1 technology preview\n  */\n#define STRING_LIST_BUFFER_SIZE 16\n\n/**\n * \\def INSTRUMENT_STRING_LIST\n * Define this to enable the <code>StringList</code> objects to\n * collect statistics.\n * @internal ICU 4.0.1 technology preview\n */\n//#define INSTRUMENT_STRING_LIST\n\n /**\n  * This object holds a list of CEs generated from a particular\n  * <code>UnicodeString</code>\n  *\n  * @internal ICU 4.0.1 technology preview\n  */\nclass U_I18N_API CEList : public UObject\n{\npublic:\n    /**\n     * Construct a <code>CEList</code> object.\n     *\n     * @param coll - the Collator used to collect the CEs.\n     * @param string - the string for which to collect the CEs.\n     * @param status - will be set if any errors occur. \n     *\n     * Note: if on return, status is set to an error code,\n     * the only safe thing to do with this object is to call\n     * the destructor.\n     *\n     * @internal ICU 4.0.1 technology preview\n     */\n    CEList(UCollator *coll, const UnicodeString &string, UErrorCode &status);\n\n    /**\n     * The destructor.\n     * @internal ICU 4.0.1 technology preview\n     */\n    ~CEList();\n\n    /**\n     * Return the number of CEs in the list.\n     *\n     * @return the number of CEs in the list.\n     *\n     * @internal ICU 4.0.1 technology preview\n     */\n    int32_t size() const;\n\n    /**\n     * Get a particular CE from the list.\n     *\n     * @param index - the index of the CE to return\n     *\n     * @return the CE, or <code>0</code> if <code>index</code> is out of range\n     *\n     * @internal ICU 4.0.1 technology preview\n     */\n    uint32_t get(int32_t index) const;\n\n    /**\n     * Check if the CEs in another <code>CEList</code> match the\n     * suffix of this list starting at a give offset.\n     *\n     * @param offset - the offset of the suffix\n     * @param other - the other <code>CEList</code>\n     *\n     * @return <code>TRUE</code> if the CEs match, <code>FALSE</code> otherwise.\n     *\n     * @internal ICU 4.0.1 technology preview\n     */\n    UBool matchesAt(int32_t offset, const CEList *other) const; \n\n    /**\n     * The index operator.\n     *\n     * @param index - the index\n     *\n     * @return a reference to the given CE in the list\n     *\n     * @internal ICU 4.0.1 technology preview\n     */\n    uint32_t &operator[](int32_t index) const;\n\n    /**\n     * UObject glue...\n     * @internal ICU 4.0.1 technology preview\n     */\n    virtual UClassID getDynamicClassID() const;\n    /**\n     * UObject glue...\n     * @internal ICU 4.0.1 technology preview\n     */\n    static UClassID getStaticClassID();\n\nprivate:\n    void add(uint32_t ce, UErrorCode &status);\n\n    uint32_t ceBuffer[CELIST_BUFFER_SIZE];\n    uint32_t *ces;\n    int32_t listMax;\n    int32_t listSize;\n\n#ifdef INSTRUMENT_CELIST\n    static int32_t _active;\n    static int32_t _histogram[10];\n#endif\n};\n\n/**\n * StringList\n *\n * This object holds a list of <code>UnicodeString</code> objects.\n *\n * @internal ICU 4.0.1 technology preview\n */\nclass U_I18N_API StringList : public UObject\n{\npublic:\n    /**\n     * Construct an empty <code>StringList</code>\n     *\n     * @param status - will be set if any errors occur. \n     *\n     * Note: if on return, status is set to an error code,\n     * the only safe thing to do with this object is to call\n     * the destructor.\n     *\n     * @internal ICU 4.0.1 technology preview\n     */\n    StringList(UErrorCode &status);\n\n    /**\n     * The destructor.\n     *\n     * @internal ICU 4.0.1 technology preview\n     */\n    ~StringList();\n\n    /**\n     * Add a string to the list.\n     *\n     * @param string - the string to add\n     * @param status - will be set if any errors occur. \n     *\n     * @internal ICU 4.0.1 technology preview\n     */\n    void add(const UnicodeString *string, UErrorCode &status);\n\n    /**\n     * Add an array of Unicode code points to the list.\n     *\n     * @param chars - the address of the array of code points\n     * @param count - the number of code points in the array\n     * @param status - will be set if any errors occur. \n     *\n     * @internal ICU 4.0.1 technology preview\n     */\n    void add(const UChar *chars, int32_t count, UErrorCode &status);\n\n    /**\n     * Get a particular string from the list.\n     *\n     * @param index - the index of the string\n     *\n     * @return a pointer to the <code>UnicodeString</code> or <code>NULL</code> \n     *         if <code>index</code> is out of bounds.\n     *\n     * @internal ICU 4.0.1 technology preview\n     */\n    const UnicodeString *get(int32_t index) const;\n\n    /**\n     * Get the number of stings in the list.\n     *\n     * @return the number of strings in the list.\n     *\n     * @internal ICU 4.0.1 technology preview\n     */\n    int32_t size() const;\n\n    /**\n     * the UObject glue...\n     * @internal ICU 4.0.1 technology preview\n     */\n    virtual UClassID getDynamicClassID() const;\n    /**\n     * the UObject glue...\n     * @internal ICU 4.0.1 technology preview\n     */\n    static UClassID getStaticClassID();\n\nprivate:\n    UnicodeString *strings;\n    int32_t listMax;\n    int32_t listSize;\n\n#ifdef INSTRUMENT_STRING_LIST\n    static int32_t _lists;\n    static int32_t _strings;\n    static int32_t _histogram[101];\n#endif\n};\n#endif  /* U_HIDE_INTERNAL_API */\n\n/*\n * Forward references to internal classes.\n */\nclass StringToCEsMap;\nclass CEToStringsMap;\nclass CollDataCache;\n\n#ifndef U_HIDE_INTERNAL_API\n/**\n * CollData\n *\n * This class holds the Collator-specific data needed to\n * compute the length of the shortest string that can\n * generate a partcular list of CEs.\n *\n * <code>CollData</code> objects are quite expensive to compute. Because\n * of this, they are cached. When you call <code>CollData::open</code> it\n * returns a reference counted cached object. When you call <code>CollData::close</code>\n * the reference count on the object is decremented but the object is not deleted.\n *\n * If you do not need to reuse any unreferenced objects in the cache, you can call\n * <code>CollData::flushCollDataCache</code>. If you no longer need any <code>CollData</code>\n * objects, you can call <code>CollData::freeCollDataCache</code>\n *\n * @internal ICU 4.0.1 technology preview\n */\nclass U_I18N_API CollData : public UObject\n{\npublic:\n    /**\n     * Construct a <code>CollData</code> object.\n     *\n     * @param collator - the collator\n     * @param status - will be set if any errors occur. \n     *\n     * @return the <code>CollData</code> object. You must call\n     *         <code>close</code> when you are done using the object.\n     *\n     * Note: if on return, status is set to an error code,\n     * the only safe thing to do with this object is to call\n     * <code>CollData::close</code>.\n     *\n     * @internal ICU 4.0.1 technology preview\n     */\n    static CollData *open(UCollator *collator, UErrorCode &status);\n\n    /**\n     * Release a <code>CollData</code> object.\n     *\n     * @param collData - the object\n     *\n     * @internal ICU 4.0.1 technology preview\n     */\n    static void close(CollData *collData);\n\n    /**\n     * Get the <code>UCollator</code> object used to create this object.\n     * The object returned may not be the exact object that was used to\n     * create this object, but it will have the same behavior.\n     * @internal ICU 4.0.1 technology preview\n     */\n    UCollator *getCollator() const;\n\n    /**\n     * Get a list of all the strings which generate a list\n     * of CEs starting with a given CE.\n     *\n     * @param ce - the CE\n     *\n     * return a <code>StringList</code> object containing all\n     *        the stirngs, or <code>NULL</code> if there are\n     *        no such strings.\n     *\n     * @internal ICU 4.0.1 technology preview.\n     */\n    const StringList *getStringList(int32_t ce) const;\n\n    /**\n     * Get a list of the CEs generated by a partcular stirng.\n     *\n     * @param string - the string\n     *\n     * @return a <code>CEList</code> object containt the CEs. You\n     *         must call <code>freeCEList</code> when you are finished\n     *         using the <code>CEList</code>/\n     *\n     * @internal ICU 4.0.1 technology preview.\n     */\n    const CEList *getCEList(const UnicodeString *string) const;\n\n    /**\n     * Release a <code>CEList</code> returned by <code>getCEList</code>.\n     *\n     * @param list - the <code>CEList</code> to free.\n     *\n     * @internal ICU 4.0.1 technology preview\n     */\n    void freeCEList(const CEList *list);\n\n    /**\n     * Return the length of the shortest string that will generate\n     * the given list of CEs.\n     *\n     * @param ces - the CEs\n     * @param offset - the offset of the first CE in the list to use.\n     *\n     * @return the length of the shortest string.\n     *\n     * @internal ICU 4.0.1 technology preview\n     */\n    int32_t minLengthInChars(const CEList *ces, int32_t offset) const;\n\n \n    /**\n     * Return the length of the shortest string that will generate\n     * the given list of CEs.\n     *\n     * Note: the algorithm used to do this computation is recursive. To\n     * limit the amount of recursion, a \"history\" list is used to record\n     * the best answer starting at a particular offset in the list of CEs.\n     * If the same offset is visited again during the recursion, the answer\n     * in the history list is used.\n     *\n     * @param ces - the CEs\n     * @param offset - the offset of the first CE in the list to use.\n     * @param history - the history list. Must be at least as long as\n     *                 the number of cEs in the <code>CEList</code>\n     *\n     * @return the length of the shortest string.\n     *\n     * @internal ICU 4.0.1 technology preview\n     */\n   int32_t minLengthInChars(const CEList *ces, int32_t offset, int32_t *history) const;\n\n   /**\n    * UObject glue...\n    * @internal ICU 4.0.1 technology preview\n    */\n    virtual UClassID getDynamicClassID() const;\n   /**\n    * UObject glue...\n    * @internal ICU 4.0.1 technology preview\n    */\n    static UClassID getStaticClassID();\n\n    /**\n     * <code>CollData</code> objects are expensive to compute, and so\n     * may be cached. This routine will free the cached objects and delete\n     * the cache.\n     *\n     * WARNING: Don't call this until you are have called <code>close</code>\n     * for each <code>CollData</code> object that you have used. also,\n     * DO NOT call this if another thread may be calling <code>flushCollDataCache</code>\n     * at the same time.\n     *\n     * @internal 4.0.1 technology preview\n     */\n    static void freeCollDataCache();\n\n    /**\n     * <code>CollData</code> objects are expensive to compute, and so\n     * may be cached. This routine will remove any unused <code>CollData</code>\n     * objects from the cache.\n     *\n     * @internal 4.0.1 technology preview\n     */\n    static void flushCollDataCache();\n\nprivate:\n    friend class CollDataCache;\n    friend class CollDataCacheEntry;\n\n    CollData(UCollator *collator, char *cacheKey, int32_t cachekeyLength, UErrorCode &status);\n    ~CollData();\n\n    CollData();\n\n    static char *getCollatorKey(UCollator *collator, char *buffer, int32_t bufferLength);\n\n    static CollDataCache *getCollDataCache();\n\n    UCollator      *coll;\n    StringToCEsMap *charsToCEList;\n    CEToStringsMap *ceToCharsStartingWith;\n\n    char keyBuffer[KEY_BUFFER_SIZE];\n    char *key;\n\n    static CollDataCache *collDataCache;\n\n    uint32_t minHan;\n    uint32_t maxHan;\n\n    uint32_t jamoLimits[4];\n};\n#endif  /* U_HIDE_INTERNAL_API */\n\nU_NAMESPACE_END\n\n#endif // #if !UCONFIG_NO_COLLATION\n#endif // #ifndef COLL_DATA_H\n"
  },
  {
    "path": "deprecated/android/addons/icucompat/unicode/curramt.h",
    "content": "/*\n**********************************************************************\n* Copyright (c) 2004-2006, International Business Machines\n* Corporation and others.  All Rights Reserved.\n**********************************************************************\n* Author: Alan Liu\n* Created: April 26, 2004\n* Since: ICU 3.0\n**********************************************************************\n*/\n#ifndef __CURRENCYAMOUNT_H__\n#define __CURRENCYAMOUNT_H__\n\n#include \"unicode/utypes.h\"\n\n#if !UCONFIG_NO_FORMATTING\n\n#include \"unicode/measure.h\"\n#include \"unicode/currunit.h\"\n\n/**\n * \\file \n * \\brief C++ API: Currency Amount Object.\n */\n \nU_NAMESPACE_BEGIN\n\n/**\n *\n * A currency together with a numeric amount, such as 200 USD.\n *\n * @author Alan Liu\n * @stable ICU 3.0\n */\nclass U_I18N_API CurrencyAmount: public Measure {\n public:\n    /**\n     * Construct an object with the given numeric amount and the given\n     * ISO currency code.\n     * @param amount a numeric object; amount.isNumeric() must be TRUE\n     * @param isoCode the 3-letter ISO 4217 currency code; must not be\n     * NULL and must have length 3\n     * @param ec input-output error code. If the amount or the isoCode\n     * is invalid, then this will be set to a failing value.\n     * @stable ICU 3.0\n     */\n    CurrencyAmount(const Formattable& amount, const UChar* isoCode,\n                   UErrorCode &ec);\n\n    /**\n     * Construct an object with the given numeric amount and the given\n     * ISO currency code.\n     * @param amount the amount of the given currency\n     * @param isoCode the 3-letter ISO 4217 currency code; must not be\n     * NULL and must have length 3\n     * @param ec input-output error code. If the isoCode is invalid,\n     * then this will be set to a failing value.\n     * @stable ICU 3.0\n     */\n    CurrencyAmount(double amount, const UChar* isoCode,\n                   UErrorCode &ec);\n\n    /**\n     * Copy constructor\n     * @stable ICU 3.0\n     */\n    CurrencyAmount(const CurrencyAmount& other);\n \n    /**\n     * Assignment operator\n     * @stable ICU 3.0\n     */\n    CurrencyAmount& operator=(const CurrencyAmount& other);\n\n    /**\n     * Return a polymorphic clone of this object.  The result will\n     * have the same class as returned by getDynamicClassID().\n     * @stable ICU 3.0\n     */\n    virtual UObject* clone() const;\n\n    /**\n     * Destructor\n     * @stable ICU 3.0\n     */\n    virtual ~CurrencyAmount();\n    \n    /**\n     * Returns a unique class ID for this object POLYMORPHICALLY.\n     * This method implements a simple form of RTTI used by ICU.\n     * @return The class ID for this object. All objects of a given\n     * class have the same class ID.  Objects of other classes have\n     * different class IDs.\n     * @stable ICU 3.0\n     */\n    virtual UClassID getDynamicClassID() const;\n\n    /**\n     * Returns the class ID for this class. This is used to compare to\n     * the return value of getDynamicClassID().\n     * @return The class ID for all objects of this class.\n     * @stable ICU 3.0\n     */\n    static UClassID U_EXPORT2 getStaticClassID();\n\n    /**\n     * Return the currency unit object of this object.\n     * @stable ICU 3.0\n     */\n    inline const CurrencyUnit& getCurrency() const;\n\n    /**\n     * Return the ISO currency code of this object.\n     * @stable ICU 3.0\n     */\n    inline const UChar* getISOCurrency() const;\n};\n\ninline const CurrencyUnit& CurrencyAmount::getCurrency() const {\n    return (const CurrencyUnit&) getUnit();\n}\n\ninline const UChar* CurrencyAmount::getISOCurrency() const {\n    return getCurrency().getISOCurrency();\n}\n\nU_NAMESPACE_END\n\n#endif // !UCONFIG_NO_FORMATTING\n#endif // __CURRENCYAMOUNT_H__\n"
  },
  {
    "path": "deprecated/android/addons/icucompat/unicode/currpinf.h",
    "content": "/*\n *******************************************************************************\n * Copyright (C) 2009-2011, International Business Machines Corporation and         *\n * others. All Rights Reserved.                                                *\n *******************************************************************************\n */\n#ifndef CURRPINF_H\n#define CURRPINF_H\n\n#include \"unicode/utypes.h\"\n\n/**\n * \\file\n * \\brief C++ API: Currency Plural Information used by Decimal Format\n */\n\n#if !UCONFIG_NO_FORMATTING\n\n#include \"unicode/unistr.h\"\n\nU_NAMESPACE_BEGIN\n\nclass Locale;\nclass PluralRules;\nclass Hashtable;\n\n/**\n * This class represents the information needed by \n * DecimalFormat to format currency plural, \n * such as \"3.00 US dollars\" or \"1.00 US dollar\". \n * DecimalFormat creates for itself an instance of\n * CurrencyPluralInfo from its locale data.  \n * If you need to change any of these symbols, you can get the\n * CurrencyPluralInfo object from your \n * DecimalFormat and modify it.\n *\n * Following are the information needed for currency plural format and parse:\n * locale information,\n * plural rule of the locale,\n * currency plural pattern of the locale.\n *\n * @stable ICU 4.2\n */\nclass  U_I18N_API CurrencyPluralInfo : public UObject {\npublic:\n\n    /**\n     * Create a CurrencyPluralInfo object for the default locale.\n     * @param status output param set to success/failure code on exit\n     * @stable ICU 4.2\n     */\n    CurrencyPluralInfo(UErrorCode& status);\n\n    /**\n     * Create a CurrencyPluralInfo object for the given locale.\n     * @param locale the locale\n     * @param status output param set to success/failure code on exit\n     * @stable ICU 4.2\n     */\n    CurrencyPluralInfo(const Locale& locale, UErrorCode& status); \n\n    /**\n     * Copy constructor\n     *\n     * @stable ICU 4.2\n     */\n    CurrencyPluralInfo(const CurrencyPluralInfo& info);\n\n\n    /**\n     * Assignment operator\n     *\n     * @stable ICU 4.2\n     */\n    CurrencyPluralInfo& operator=(const CurrencyPluralInfo& info);\n\n\n    /**\n     * Destructor\n     *\n     * @stable ICU 4.2\n     */\n    virtual ~CurrencyPluralInfo();\n\n\n    /**\n     * Equal operator.\n     *\n     * @stable ICU 4.2\n     */\n    UBool operator==(const CurrencyPluralInfo& info) const;\n\n\n    /**\n     * Not equal operator\n     *\n     * @stable ICU 4.2\n     */\n    UBool operator!=(const CurrencyPluralInfo& info) const;\n\n\n    /**\n     * Clone\n     *\n     * @stable ICU 4.2\n     */\n    CurrencyPluralInfo* clone() const;\n\n\n    /**\n     * Gets plural rules of this locale, used for currency plural format\n     *\n     * @return plural rule\n     * @stable ICU 4.2\n     */\n    const PluralRules* getPluralRules() const;\n\n    /**\n     * Given a plural count, gets currency plural pattern of this locale, \n     * used for currency plural format\n     *\n     * @param  pluralCount currency plural count\n     * @param  result      output param to receive the pattern\n     * @return a currency plural pattern based on plural count\n     * @stable ICU 4.2\n     */\n    UnicodeString& getCurrencyPluralPattern(const UnicodeString& pluralCount,\n                                            UnicodeString& result) const; \n\n    /**\n     * Get locale \n     *\n     * @return locale\n     * @stable ICU 4.2\n     */\n    const Locale& getLocale() const;\n\n    /**\n     * Set plural rules.\n     * The plural rule is set when CurrencyPluralInfo\n     * instance is created.\n     * You can call this method to reset plural rules only if you want\n     * to modify the default plural rule of the locale.\n     *\n     * @param ruleDescription new plural rule description\n     * @param status output param set to success/failure code on exit\n     * @stable ICU 4.2\n     */\n    void setPluralRules(const UnicodeString& ruleDescription,\n                        UErrorCode& status);\n\n    /**\n     * Set currency plural pattern.\n     * The currency plural pattern is set when CurrencyPluralInfo\n     * instance is created.\n     * You can call this method to reset currency plural pattern only if \n     * you want to modify the default currency plural pattern of the locale.\n     *\n     * @param pluralCount the plural count for which the currency pattern will \n     *                    be overridden.\n     * @param pattern     the new currency plural pattern\n     * @param status      output param set to success/failure code on exit\n     * @stable ICU 4.2\n     */\n    void setCurrencyPluralPattern(const UnicodeString& pluralCount, \n                                  const UnicodeString& pattern,\n                                  UErrorCode& status);\n\n    /**\n     * Set locale\n     *\n     * @param loc     the new locale to set\n     * @param status  output param set to success/failure code on exit\n     * @stable ICU 4.2\n     */\n    void setLocale(const Locale& loc, UErrorCode& status);\n\n    /**\n     * ICU \"poor man's RTTI\", returns a UClassID for the actual class.\n     *\n     * @stable ICU 4.2\n     */\n    virtual UClassID getDynamicClassID() const;\n\n    /**\n     * ICU \"poor man's RTTI\", returns a UClassID for this class.\n     *\n     * @stable ICU 4.2\n     */\n    static UClassID U_EXPORT2 getStaticClassID();\n\nprivate:\n    friend class DecimalFormat;\n\n    void initialize(const Locale& loc, UErrorCode& status);\n   \n    void setupCurrencyPluralPattern(const Locale& loc, UErrorCode& status);\n\n    /*\n     * delete hash table\n     *\n     * @param hTable  hash table to be deleted\n     */\n    void deleteHash(Hashtable* hTable);\n\n\n    /*\n     * initialize hash table\n     *\n     * @param status   output param set to success/failure code on exit\n     * @return         hash table initialized\n     */\n    Hashtable* initHash(UErrorCode& status);\n\n\n\n    /**\n     * copy hash table\n     *\n     * @param source   the source to copy from\n     * @param target   the target to copy to\n     * @param status   error code\n     */\n    void copyHash(const Hashtable* source, Hashtable* target, UErrorCode& status);\n\n    //-------------------- private data member ---------------------\n    // map from plural count to currency plural pattern, for example\n    // a plural pattern defined in \"CurrencyUnitPatterns\" is\n    // \"one{{0} {1}}\", in which \"one\" is a plural count\n    // and \"{0} {1}\" is a currency plural pattern\".\n    // The currency plural pattern saved in this mapping is the pattern\n    // defined in \"CurrencyUnitPattern\" by replacing\n    // {0} with the number format pattern,\n    // and {1} with 3 currency sign.\n    Hashtable* fPluralCountToCurrencyUnitPattern;\n\n    /*\n     * The plural rule is used to format currency plural name,\n     * for example: \"3.00 US Dollars\".\n     * If there are 3 currency signs in the currency patttern,\n     * the 3 currency signs will be replaced by currency plural name.\n     */\n    PluralRules* fPluralRules;\n\n    // locale\n    Locale* fLocale;\n};\n\n\ninline UBool\nCurrencyPluralInfo::operator!=(const CurrencyPluralInfo& info) const {              return !operator==(info);                                                   }  \n\nU_NAMESPACE_END\n\n#endif /* #if !UCONFIG_NO_FORMATTING */\n\n#endif // _CURRPINFO\n//eof\n"
  },
  {
    "path": "deprecated/android/addons/icucompat/unicode/currunit.h",
    "content": "/*\n**********************************************************************\n* Copyright (c) 2004-2006, International Business Machines\n* Corporation and others.  All Rights Reserved.\n**********************************************************************\n* Author: Alan Liu\n* Created: April 26, 2004\n* Since: ICU 3.0\n**********************************************************************\n*/\n#ifndef __CURRENCYUNIT_H__\n#define __CURRENCYUNIT_H__\n\n#include \"unicode/utypes.h\"\n\n#if !UCONFIG_NO_FORMATTING\n\n#include \"unicode/measunit.h\"\n\n/**\n * \\file \n * \\brief C++ API: Currency Unit Information.\n */\n \nU_NAMESPACE_BEGIN\n\n/**\n * A unit of currency, such as USD (U.S. dollars) or JPY (Japanese\n * yen).  This class is a thin wrapper over a UChar string that\n * subclasses MeasureUnit, for use with Measure and MeasureFormat.\n *\n * @author Alan Liu\n * @stable ICU 3.0\n */\nclass U_I18N_API CurrencyUnit: public MeasureUnit {\n public:\n    /**\n     * Construct an object with the given ISO currency code.\n     * @param isoCode the 3-letter ISO 4217 currency code; must not be\n     * NULL and must have length 3\n     * @param ec input-output error code. If the isoCode is invalid,\n     * then this will be set to a failing value.\n     * @stable ICU 3.0\n     */\n    CurrencyUnit(const UChar* isoCode, UErrorCode &ec);\n\n    /**\n     * Copy constructor\n     * @stable ICU 3.0\n     */\n    CurrencyUnit(const CurrencyUnit& other);\n\n    /**\n     * Assignment operator\n     * @stable ICU 3.0\n     */\n    CurrencyUnit& operator=(const CurrencyUnit& other);\n\n    /**\n     * Return a polymorphic clone of this object.  The result will\n     * have the same class as returned by getDynamicClassID().\n     * @stable ICU 3.0\n     */\n    virtual UObject* clone() const;\n\n    /**\n     * Destructor\n     * @stable ICU 3.0\n     */\n    virtual ~CurrencyUnit();\n\n    /**\n     * Equality operator.  Return true if this object is equal\n     * to the given object.\n     * @stable ICU 3.0\n     */\n    UBool operator==(const UObject& other) const;\n\n    /**\n     * Returns a unique class ID for this object POLYMORPHICALLY.\n     * This method implements a simple form of RTTI used by ICU.\n     * @return The class ID for this object. All objects of a given\n     * class have the same class ID.  Objects of other classes have\n     * different class IDs.\n     * @stable ICU 3.0\n     */\n    virtual UClassID getDynamicClassID() const;\n\n    /**\n     * Returns the class ID for this class. This is used to compare to\n     * the return value of getDynamicClassID().\n     * @return The class ID for all objects of this class.\n     * @stable ICU 3.0\n     */\n    static UClassID U_EXPORT2 getStaticClassID();\n\n    /**\n     * Return the ISO currency code of this object.\n     * @stable ICU 3.0\n     */\n    inline const UChar* getISOCurrency() const;\n\n private:\n    /**\n     * The ISO 4217 code of this object.\n     */\n    UChar isoCode[4];\n};\n\ninline const UChar* CurrencyUnit::getISOCurrency() const {\n    return isoCode;\n}\n\nU_NAMESPACE_END\n\n#endif // !UCONFIG_NO_FORMATTING\n#endif // __CURRENCYUNIT_H__\n"
  },
  {
    "path": "deprecated/android/addons/icucompat/unicode/datefmt.h",
    "content": "/*\n ********************************************************************************\n *   Copyright (C) 1997-2012, International Business Machines\n *   Corporation and others.  All Rights Reserved.\n ********************************************************************************\n *\n * File DATEFMT.H\n *\n * Modification History:\n *\n *   Date        Name        Description\n *   02/19/97    aliu        Converted from java.\n *   04/01/97    aliu        Added support for centuries.\n *   07/23/98    stephen     JDK 1.2 sync\n *   11/15/99    weiv        Added support for week of year/day of week formatting\n ********************************************************************************\n */\n\n#ifndef DATEFMT_H\n#define DATEFMT_H\n\n#include \"unicode/utypes.h\"\n\n#if !UCONFIG_NO_FORMATTING\n\n#include \"unicode/udat.h\"\n#include \"unicode/calendar.h\"\n#include \"unicode/numfmt.h\"\n#include \"unicode/format.h\"\n#include \"unicode/locid.h\"\n\n/**\n * \\file\n * \\brief C++ API: Abstract class for converting dates.\n */\n\nU_NAMESPACE_BEGIN\n\nclass TimeZone;\nclass DateTimePatternGenerator;\n\n/**\n * DateFormat is an abstract class for a family of classes that convert dates and\n * times from their internal representations to textual form and back again in a\n * language-independent manner. Converting from the internal representation (milliseconds\n * since midnight, January 1, 1970) to text is known as \"formatting,\" and converting\n * from text to millis is known as \"parsing.\"  We currently define only one concrete\n * subclass of DateFormat: SimpleDateFormat, which can handle pretty much all normal\n * date formatting and parsing actions.\n * <P>\n * DateFormat helps you to format and parse dates for any locale. Your code can\n * be completely independent of the locale conventions for months, days of the\n * week, or even the calendar format: lunar vs. solar.\n * <P>\n * To format a date for the current Locale, use one of the static factory\n * methods:\n * <pre>\n * \\code\n *      DateFormat* dfmt = DateFormat::createDateInstance();\n *      UDate myDate = Calendar::getNow();\n *      UnicodeString myString;\n *      myString = dfmt->format( myDate, myString );\n * \\endcode\n * </pre>\n * If you are formatting multiple numbers, it is more efficient to get the\n * format and use it multiple times so that the system doesn't have to fetch the\n * information about the local language and country conventions multiple times.\n * <pre>\n * \\code\n *      DateFormat* df = DateFormat::createDateInstance();\n *      UnicodeString myString;\n *      UDate myDateArr[] = { 0.0, 100000000.0, 2000000000.0 }; // test values\n *      for (int32_t i = 0; i < 3; ++i) {\n *          myString.remove();\n *          cout << df->format( myDateArr[i], myString ) << endl;\n *      }\n * \\endcode\n * </pre>\n * To get specific fields of a date, you can use UFieldPosition to\n * get specific fields.\n * <pre>\n * \\code\n *      DateFormat* dfmt = DateFormat::createDateInstance();\n *      FieldPosition pos(DateFormat::YEAR_FIELD);\n *      UnicodeString myString;\n *      myString = dfmt->format( myDate, myString );\n *      cout << myString << endl;\n *      cout << pos.getBeginIndex() << \",\" << pos. getEndIndex() << endl;\n * \\endcode\n * </pre>\n * To format a date for a different Locale, specify it in the call to\n * createDateInstance().\n * <pre>\n * \\code\n *       DateFormat* df =\n *           DateFormat::createDateInstance( DateFormat::SHORT, Locale::getFrance());\n * \\endcode\n * </pre>\n * You can use a DateFormat to parse also.\n * <pre>\n * \\code\n *       UErrorCode status = U_ZERO_ERROR;\n *       UDate myDate = df->parse(myString, status);\n * \\endcode\n * </pre>\n * Use createDateInstance() to produce the normal date format for that country.\n * There are other static factory methods available. Use createTimeInstance()\n * to produce the normal time format for that country. Use createDateTimeInstance()\n * to produce a DateFormat that formats both date and time. You can pass in\n * different options to these factory methods to control the length of the\n * result; from SHORT to MEDIUM to LONG to FULL. The exact result depends on the\n * locale, but generally:\n * <ul type=round>\n *   <li>   SHORT is completely numeric, such as 12/13/52 or 3:30pm\n *   <li>   MEDIUM is longer, such as Jan 12, 1952\n *   <li>   LONG is longer, such as January 12, 1952 or 3:30:32pm\n *   <li>   FULL is pretty completely specified, such as\n *          Tuesday, April 12, 1952 AD or 3:30:42pm PST.\n * </ul>\n * You can also set the time zone on the format if you wish. If you want even\n * more control over the format or parsing, (or want to give your users more\n * control), you can try casting the DateFormat you get from the factory methods\n * to a SimpleDateFormat. This will work for the majority of countries; just\n * remember to chck getDynamicClassID() before carrying out the cast.\n * <P>\n * You can also use forms of the parse and format methods with ParsePosition and\n * FieldPosition to allow you to\n * <ul type=round>\n *   <li>   Progressively parse through pieces of a string.\n *   <li>   Align any particular field, or find out where it is for selection\n *          on the screen.\n * </ul>\n *\n * <p><em>User subclasses are not supported.</em> While clients may write\n * subclasses, such code will not necessarily work and will not be\n * guaranteed to work stably from release to release.\n */\nclass U_I18N_API DateFormat : public Format {\npublic:\n\n    /**\n     * Constants for various style patterns. These reflect the order of items in\n     * the DateTimePatterns resource. There are 4 time patterns, 4 date patterns,\n     * the default date-time pattern, and 4 date-time patterns. Each block of 4 values\n     * in the resource occurs in the order full, long, medium, short.\n     * @stable ICU 2.4\n     */\n    enum EStyle\n    {\n        kNone   = -1,\n\n        kFull   = 0,\n        kLong   = 1,\n        kMedium = 2,\n        kShort  = 3,\n\n        kDateOffset   = kShort + 1,\n     // kFull   + kDateOffset = 4\n     // kLong   + kDateOffset = 5\n     // kMedium + kDateOffset = 6\n     // kShort  + kDateOffset = 7\n\n        kDateTime             = 8,\n     // Default DateTime\n\n        kDateTimeOffset = kDateTime + 1,\n     // kFull   + kDateTimeOffset = 9\n     // kLong   + kDateTimeOffset = 10\n     // kMedium + kDateTimeOffset = 11\n     // kShort  + kDateTimeOffset = 12\n\n        // relative dates\n        kRelative = (1 << 7),\n\n        kFullRelative = (kFull | kRelative),\n\n        kLongRelative = kLong | kRelative,\n\n        kMediumRelative = kMedium | kRelative,\n\n        kShortRelative = kShort | kRelative,\n\n\n        kDefault      = kMedium,\n\n\n\n    /**\n     * These constants are provided for backwards compatibility only.\n     * Please use the C++ style constants defined above.\n     */\n        FULL        = kFull,\n        LONG        = kLong,\n        MEDIUM        = kMedium,\n        SHORT        = kShort,\n        DEFAULT        = kDefault,\n        DATE_OFFSET    = kDateOffset,\n        NONE        = kNone,\n        DATE_TIME    = kDateTime\n    };\n\n    /**\n     * Destructor.\n     * @stable ICU 2.0\n     */\n    virtual ~DateFormat();\n\n    /**\n     * Equality operator.  Returns true if the two formats have the same behavior.\n     * @stable ICU 2.0\n     */\n    virtual UBool operator==(const Format&) const;\n\n\n    using Format::format;\n\n    /**\n     * Format an object to produce a string. This method handles Formattable\n     * objects with a UDate type. If a the Formattable object type is not a Date,\n     * then it returns a failing UErrorCode.\n     *\n     * @param obj       The object to format. Must be a Date.\n     * @param appendTo  Output parameter to receive result.\n     *                  Result is appended to existing contents.\n     * @param pos       On input: an alignment field, if desired.\n     *                  On output: the offsets of the alignment field.\n     * @param status    Output param filled with success/failure status.\n     * @return          Reference to 'appendTo' parameter.\n     * @stable ICU 2.0\n     */\n    virtual UnicodeString& format(const Formattable& obj,\n                                  UnicodeString& appendTo,\n                                  FieldPosition& pos,\n                                  UErrorCode& status) const;\n\n    /**\n     * Format an object to produce a string. This method handles Formattable\n     * objects with a UDate type. If a the Formattable object type is not a Date,\n     * then it returns a failing UErrorCode.\n     *\n     * @param obj       The object to format. Must be a Date.\n     * @param appendTo  Output parameter to receive result.\n     *                  Result is appended to existing contents.\n     * @param posIter   On return, can be used to iterate over positions\n     *                  of fields generated by this format call.  Field values\n     *                  are defined in UDateFormatField.  Can be NULL.\n     * @param status    Output param filled with success/failure status.\n     * @return          Reference to 'appendTo' parameter.\n     * @stable ICU 4.4\n     */\n    virtual UnicodeString& format(const Formattable& obj,\n                                  UnicodeString& appendTo,\n                                  FieldPositionIterator* posIter,\n                                  UErrorCode& status) const;\n    /**\n     * Formats a date into a date/time string. This is an abstract method which\n     * concrete subclasses must implement.\n     * <P>\n     * On input, the FieldPosition parameter may have its \"field\" member filled with\n     * an enum value specifying a field.  On output, the FieldPosition will be filled\n     * in with the text offsets for that field.\n     * <P> For example, given a time text\n     * \"1996.07.10 AD at 15:08:56 PDT\", if the given fieldPosition.field is\n     * UDAT_YEAR_FIELD, the offsets fieldPosition.beginIndex and\n     * statfieldPositionus.getEndIndex will be set to 0 and 4, respectively.\n     * <P> Notice\n     * that if the same time field appears more than once in a pattern, the status will\n     * be set for the first occurence of that time field. For instance,\n     * formatting a UDate to the time string \"1 PM PDT (Pacific Daylight Time)\"\n     * using the pattern \"h a z (zzzz)\" and the alignment field\n     * DateFormat::TIMEZONE_FIELD, the offsets fieldPosition.beginIndex and\n     * fieldPosition.getEndIndex will be set to 5 and 8, respectively, for the first\n     * occurence of the timezone pattern character 'z'.\n     *\n     * @param cal           Calendar set to the date and time to be formatted\n     *                      into a date/time string.  When the calendar type is\n     *                      different from the internal calendar held by this\n     *                      DateFormat instance, the date and the time zone will\n     *                      be inherited from the input calendar, but other calendar\n     *                      field values will be calculated by the internal calendar.\n     * @param appendTo      Output parameter to receive result.\n     *                      Result is appended to existing contents.\n     * @param fieldPosition On input: an alignment field, if desired (see examples above)\n     *                      On output: the offsets of the alignment field (see examples above)\n     * @return              Reference to 'appendTo' parameter.\n     * @stable ICU 2.1\n     */\n    virtual UnicodeString& format(  Calendar& cal,\n                                    UnicodeString& appendTo,\n                                    FieldPosition& fieldPosition) const = 0;\n\n    /**\n     * Formats a date into a date/time string. Subclasses should implement this method.\n     *\n     * @param cal       Calendar set to the date and time to be formatted\n     *                  into a date/time string.  When the calendar type is\n     *                  different from the internal calendar held by this\n     *                  DateFormat instance, the date and the time zone will\n     *                  be inherited from the input calendar, but other calendar\n     *                  field values will be calculated by the internal calendar.\n     * @param appendTo  Output parameter to receive result.\n     *                  Result is appended to existing contents.\n     * @param posIter   On return, can be used to iterate over positions\n     *                  of fields generated by this format call.  Field values\n     *                  are defined in UDateFormatField.  Can be NULL.\n     * @param status    error status.\n     * @return          Reference to 'appendTo' parameter.\n     * @stable ICU 4.4\n     */\n    virtual UnicodeString& format(Calendar& cal,\n                                  UnicodeString& appendTo,\n                                  FieldPositionIterator* posIter,\n                                  UErrorCode& status) const;\n    /**\n     * Formats a UDate into a date/time string.\n     * <P>\n     * On input, the FieldPosition parameter may have its \"field\" member filled with\n     * an enum value specifying a field.  On output, the FieldPosition will be filled\n     * in with the text offsets for that field.\n     * <P> For example, given a time text\n     * \"1996.07.10 AD at 15:08:56 PDT\", if the given fieldPosition.field is\n     * UDAT_YEAR_FIELD, the offsets fieldPosition.beginIndex and\n     * statfieldPositionus.getEndIndex will be set to 0 and 4, respectively.\n     * <P> Notice\n     * that if the same time field appears more than once in a pattern, the status will\n     * be set for the first occurence of that time field. For instance,\n     * formatting a UDate to the time string \"1 PM PDT (Pacific Daylight Time)\"\n     * using the pattern \"h a z (zzzz)\" and the alignment field\n     * DateFormat::TIMEZONE_FIELD, the offsets fieldPosition.beginIndex and\n     * fieldPosition.getEndIndex will be set to 5 and 8, respectively, for the first\n     * occurence of the timezone pattern character 'z'.\n     *\n     * @param date          UDate to be formatted into a date/time string.\n     * @param appendTo      Output parameter to receive result.\n     *                      Result is appended to existing contents.\n     * @param fieldPosition On input: an alignment field, if desired (see examples above)\n     *                      On output: the offsets of the alignment field (see examples above)\n     * @return              Reference to 'appendTo' parameter.\n     * @stable ICU 2.0\n     */\n    UnicodeString& format(  UDate date,\n                            UnicodeString& appendTo,\n                            FieldPosition& fieldPosition) const;\n\n    /**\n     * Formats a UDate into a date/time string.\n     *\n     * @param date      UDate to be formatted into a date/time string.\n     * @param appendTo  Output parameter to receive result.\n     *                  Result is appended to existing contents.\n     * @param posIter   On return, can be used to iterate over positions\n     *                  of fields generated by this format call.  Field values\n     *                  are defined in UDateFormatField.  Can be NULL.\n     * @param status    error status.\n     * @return          Reference to 'appendTo' parameter.\n     * @stable ICU 4.4\n     */\n    UnicodeString& format(UDate date,\n                          UnicodeString& appendTo,\n                          FieldPositionIterator* posIter,\n                          UErrorCode& status) const;\n    /**\n     * Formats a UDate into a date/time string. If there is a problem, you won't\n     * know, using this method. Use the overloaded format() method which takes a\n     * FieldPosition& to detect formatting problems.\n     *\n     * @param date      The UDate value to be formatted into a string.\n     * @param appendTo  Output parameter to receive result.\n     *                  Result is appended to existing contents.\n     * @return          Reference to 'appendTo' parameter.\n     * @stable ICU 2.0\n     */\n    UnicodeString& format(UDate date, UnicodeString& appendTo) const;\n\n    /**\n     * Redeclared Format method.\n     *\n     * @param obj       The object to be formatted into a string.\n     * @param appendTo  Output parameter to receive result.\n     *                  Result is appended to existing contents.\n     * @param status    Output param filled with success/failure status.\n     * @return          Reference to 'appendTo' parameter.\n     * @stable ICU 2.0\n     */\n    UnicodeString& format(const Formattable& obj,\n                          UnicodeString& appendTo,\n                          UErrorCode& status) const;\n\n    /**\n     * Parse a date/time string. For example, a time text \"07/10/96 4:5 PM, PDT\"\n     * will be parsed into a UDate that is equivalent to Date(837039928046).\n     * Parsing begins at the beginning of the string and proceeds as far as\n     * possible.  Assuming no parse errors were encountered, this function\n     * doesn't return any information about how much of the string was consumed\n     * by the parsing.  If you need that information, use the version of\n     * parse() that takes a ParsePosition.\n     * <P>\n     * By default, parsing is lenient: If the input is not in the form used by\n     * this object's format method but can still be parsed as a date, then the\n     * parse succeeds. Clients may insist on strict adherence to the format by\n     * calling setLenient(false).\n     * @see DateFormat::setLenient(boolean)\n     * <P>\n     * Note that the normal date formats associated with some calendars - such\n     * as the Chinese lunar calendar - do not specify enough fields to enable\n     * dates to be parsed unambiguously. In the case of the Chinese lunar\n     * calendar, while the year within the current 60-year cycle is specified,\n     * the number of such cycles since the start date of the calendar (in the\n     * ERA field of the Calendar object) is not normally part of the format,\n     * and parsing may assume the wrong era. For cases such as this it is\n     * recommended that clients parse using the method\n     * parse(const UnicodeString&, Calendar& cal, ParsePosition&)\n     * with the Calendar passed in set to the current date, or to a date\n     * within the era/cycle that should be assumed if absent in the format.\n     *\n     * @param text      The date/time string to be parsed into a UDate value.\n     * @param status    Output param to be set to success/failure code. If\n     *                  'text' cannot be parsed, it will be set to a failure\n     *                  code.\n     * @return          The parsed UDate value, if successful.\n     * @stable ICU 2.0\n     */\n    virtual UDate parse( const UnicodeString& text,\n                        UErrorCode& status) const;\n\n    /**\n     * Parse a date/time string beginning at the given parse position. For\n     * example, a time text \"07/10/96 4:5 PM, PDT\" will be parsed into a Date\n     * that is equivalent to Date(837039928046).\n     * <P>\n     * By default, parsing is lenient: If the input is not in the form used by\n     * this object's format method but can still be parsed as a date, then the\n     * parse succeeds. Clients may insist on strict adherence to the format by\n     * calling setLenient(false).\n     * @see DateFormat::setLenient(boolean)\n     *\n     * @param text  The date/time string to be parsed.\n     * @param cal   A Calendar set on input to the date and time to be used for\n     *              missing values in the date/time string being parsed, and set\n     *              on output to the parsed date/time. When the calendar type is\n     *              different from the internal calendar held by this DateFormat\n     *              instance, the internal calendar will be cloned to a work\n     *              calendar set to the same milliseconds and time zone as the\n     *              cal parameter, field values will be parsed based on the work\n     *              calendar, then the result (milliseconds and time zone) will\n     *              be set in this calendar.\n     * @param pos   On input, the position at which to start parsing; on\n     *              output, the position at which parsing terminated, or the\n     *              start position if the parse failed.\n     * @stable ICU 2.1\n     */\n    virtual void parse( const UnicodeString& text,\n                        Calendar& cal,\n                        ParsePosition& pos) const = 0;\n\n    /**\n     * Parse a date/time string beginning at the given parse position. For\n     * example, a time text \"07/10/96 4:5 PM, PDT\" will be parsed into a Date\n     * that is equivalent to Date(837039928046).\n     * <P>\n     * By default, parsing is lenient: If the input is not in the form used by\n     * this object's format method but can still be parsed as a date, then the\n     * parse succeeds. Clients may insist on strict adherence to the format by\n     * calling setLenient(false).\n     * @see DateFormat::setLenient(boolean)\n     * <P>\n     * Note that the normal date formats associated with some calendars - such\n     * as the Chinese lunar calendar - do not specify enough fields to enable\n     * dates to be parsed unambiguously. In the case of the Chinese lunar\n     * calendar, while the year within the current 60-year cycle is specified,\n     * the number of such cycles since the start date of the calendar (in the\n     * ERA field of the Calendar object) is not normally part of the format,\n     * and parsing may assume the wrong era. For cases such as this it is\n     * recommended that clients parse using the method\n     * parse(const UnicodeString&, Calendar& cal, ParsePosition&)\n     * with the Calendar passed in set to the current date, or to a date\n     * within the era/cycle that should be assumed if absent in the format.\n     *\n     * @param text  The date/time string to be parsed into a UDate value.\n     * @param pos   On input, the position at which to start parsing; on\n     *              output, the position at which parsing terminated, or the\n     *              start position if the parse failed.\n     * @return      A valid UDate if the input could be parsed.\n     * @stable ICU 2.0\n     */\n    UDate parse( const UnicodeString& text,\n                 ParsePosition& pos) const;\n\n    /**\n     * Parse a string to produce an object. This methods handles parsing of\n     * date/time strings into Formattable objects with UDate types.\n     * <P>\n     * Before calling, set parse_pos.index to the offset you want to start\n     * parsing at in the source. After calling, parse_pos.index is the end of\n     * the text you parsed. If error occurs, index is unchanged.\n     * <P>\n     * When parsing, leading whitespace is discarded (with a successful parse),\n     * while trailing whitespace is left as is.\n     * <P>\n     * See Format::parseObject() for more.\n     *\n     * @param source    The string to be parsed into an object.\n     * @param result    Formattable to be set to the parse result.\n     *                  If parse fails, return contents are undefined.\n     * @param parse_pos The position to start parsing at. Upon return\n     *                  this param is set to the position after the\n     *                  last character successfully parsed. If the\n     *                  source is not parsed successfully, this param\n     *                  will remain unchanged.\n     * @stable ICU 2.0\n     */\n    virtual void parseObject(const UnicodeString& source,\n                             Formattable& result,\n                             ParsePosition& parse_pos) const;\n\n    /**\n     * Create a default date/time formatter that uses the SHORT style for both\n     * the date and the time.\n     *\n     * @return A date/time formatter which the caller owns.\n     * @stable ICU 2.0\n     */\n    static DateFormat* U_EXPORT2 createInstance(void);\n\n    /**\n     * Creates a time formatter with the given formatting style for the given\n     * locale.\n     *\n     * @param style     The given formatting style. For example,\n     *                  SHORT for \"h:mm a\" in the US locale. Relative\n     *                  time styles are not currently supported.\n     * @param aLocale   The given locale.\n     * @return          A time formatter which the caller owns.\n     * @stable ICU 2.0\n     */\n    static DateFormat* U_EXPORT2 createTimeInstance(EStyle style = kDefault,\n                                          const Locale& aLocale = Locale::getDefault());\n\n    /**\n     * Creates a date formatter with the given formatting style for the given\n     * const locale.\n     *\n     * @param style     The given formatting style. For example, SHORT for \"M/d/yy\" in the\n     *                  US locale. As currently implemented, relative date formatting only\n     *                  affects a limited range of calendar days before or after the\n     *                  current date, based on the CLDR &lt;field type=\"day\"&gt;/&lt;relative&gt; data:\n     *                  For example, in English, \"Yesterday\", \"Today\", and \"Tomorrow\".\n     *                  Outside of this range, dates are formatted using the corresponding\n     *                  non-relative style.\n     * @param aLocale   The given locale.\n     * @return          A date formatter which the caller owns.\n     * @stable ICU 2.0\n     */\n    static DateFormat* U_EXPORT2 createDateInstance(EStyle style = kDefault,\n                                          const Locale& aLocale = Locale::getDefault());\n\n    /**\n     * Creates a date/time formatter with the given formatting styles for the\n     * given locale.\n     *\n     * @param dateStyle The given formatting style for the date portion of the result.\n     *                  For example, SHORT for \"M/d/yy\" in the US locale. As currently\n     *                  implemented, relative date formatting only affects a limited range\n     *                  of calendar days before or after the current date, based on the\n     *                  CLDR &lt;field type=\"day\"&gt;/&lt;relative&gt; data: For example, in English,\n     *                  \"Yesterday\", \"Today\", and \"Tomorrow\". Outside of this range, dates\n     *                  are formatted using the corresponding non-relative style.\n     * @param timeStyle The given formatting style for the time portion of the result.\n     *                  For example, SHORT for \"h:mm a\" in the US locale. Relative\n     *                  time styles are not currently supported.\n     * @param aLocale   The given locale.\n     * @return          A date/time formatter which the caller owns.\n     * @stable ICU 2.0\n     */\n    static DateFormat* U_EXPORT2 createDateTimeInstance(EStyle dateStyle = kDefault,\n                                              EStyle timeStyle = kDefault,\n                                              const Locale& aLocale = Locale::getDefault());\n\n    /**\n     * Gets the set of locales for which DateFormats are installed.\n     * @param count Filled in with the number of locales in the list that is returned.\n     * @return the set of locales for which DateFormats are installed.  The caller\n     *  does NOT own this list and must not delete it.\n     * @stable ICU 2.0\n     */\n    static const Locale* U_EXPORT2 getAvailableLocales(int32_t& count);\n\n    /**\n     * Returns true if the formatter is set for lenient parsing.\n     * @stable ICU 2.0\n     */\n    virtual UBool isLenient(void) const;\n\n    /**\n     * Specify whether or not date/time parsing is to be lenient. With lenient\n     * parsing, the parser may use heuristics to interpret inputs that do not\n     * precisely match this object's format. With strict parsing, inputs must\n     * match this object's format.\n     *\n     * @param lenient  True specifies date/time interpretation to be lenient.\n     * @see Calendar::setLenient\n     * @stable ICU 2.0\n     */\n    virtual void setLenient(UBool lenient);\n\n    /**\n     * Gets the calendar associated with this date/time formatter.\n     * @return the calendar associated with this date/time formatter.\n     * @stable ICU 2.0\n     */\n    virtual const Calendar* getCalendar(void) const;\n\n    /**\n     * Set the calendar to be used by this date format. Initially, the default\n     * calendar for the specified or default locale is used.  The caller should\n     * not delete the Calendar object after it is adopted by this call.\n     * Adopting a new calendar will change to the default symbols.\n     *\n     * @param calendarToAdopt    Calendar object to be adopted.\n     * @stable ICU 2.0\n     */\n    virtual void adoptCalendar(Calendar* calendarToAdopt);\n\n    /**\n     * Set the calendar to be used by this date format. Initially, the default\n     * calendar for the specified or default locale is used.\n     *\n     * @param newCalendar Calendar object to be set.\n     * @stable ICU 2.0\n     */\n    virtual void setCalendar(const Calendar& newCalendar);\n\n\n    /**\n     * Gets the number formatter which this date/time formatter uses to format\n     * and parse the numeric portions of the pattern.\n     * @return the number formatter which this date/time formatter uses.\n     * @stable ICU 2.0\n     */\n    virtual const NumberFormat* getNumberFormat(void) const;\n\n    /**\n     * Allows you to set the number formatter.  The caller should\n     * not delete the NumberFormat object after it is adopted by this call.\n     * @param formatToAdopt     NumberFormat object to be adopted.\n     * @stable ICU 2.0\n     */\n    virtual void adoptNumberFormat(NumberFormat* formatToAdopt);\n\n    /**\n     * Allows you to set the number formatter.\n     * @param newNumberFormat  NumberFormat object to be set.\n     * @stable ICU 2.0\n     */\n    virtual void setNumberFormat(const NumberFormat& newNumberFormat);\n\n    /**\n     * Returns a reference to the TimeZone used by this DateFormat's calendar.\n     * @return the time zone associated with the calendar of DateFormat.\n     * @stable ICU 2.0\n     */\n    virtual const TimeZone& getTimeZone(void) const;\n\n    /**\n     * Sets the time zone for the calendar of this DateFormat object. The caller\n     * no longer owns the TimeZone object and should not delete it after this call.\n     * @param zoneToAdopt the TimeZone to be adopted.\n     * @stable ICU 2.0\n     */\n    virtual void adoptTimeZone(TimeZone* zoneToAdopt);\n\n    /**\n     * Sets the time zone for the calendar of this DateFormat object.\n     * @param zone the new time zone.\n     * @stable ICU 2.0\n     */\n    virtual void setTimeZone(const TimeZone& zone);\n\nprotected:\n    /**\n     * Default constructor.  Creates a DateFormat with no Calendar or NumberFormat\n     * associated with it.  This constructor depends on the subclasses to fill in\n     * the calendar and numberFormat fields.\n     * @stable ICU 2.0\n     */\n    DateFormat();\n\n    /**\n     * Copy constructor.\n     * @stable ICU 2.0\n     */\n    DateFormat(const DateFormat&);\n\n    /**\n     * Default assignment operator.\n     * @stable ICU 2.0\n     */\n    DateFormat& operator=(const DateFormat&);\n\n    /**\n     * The calendar that DateFormat uses to produce the time field values needed\n     * to implement date/time formatting. Subclasses should generally initialize\n     * this to the default calendar for the locale associated with this DateFormat.\n     * @stable ICU 2.4\n     */\n    Calendar* fCalendar;\n\n    /**\n     * The number formatter that DateFormat uses to format numbers in dates and\n     * times. Subclasses should generally initialize this to the default number\n     * format for the locale associated with this DateFormat.\n     * @stable ICU 2.4\n     */\n    NumberFormat* fNumberFormat;\n\nprivate:\n    /**\n     * Gets the date/time formatter with the given formatting styles for the\n     * given locale.\n     * @param dateStyle the given date formatting style.\n     * @param timeStyle the given time formatting style.\n     * @param inLocale the given locale.\n     * @return a date/time formatter, or 0 on failure.\n     */\n    static DateFormat* U_EXPORT2 create(EStyle timeStyle, EStyle dateStyle, const Locale& inLocale);\n\npublic:\n#ifndef U_HIDE_OBSOLETE_API\n    /**\n     * Field selector for FieldPosition for DateFormat fields.\n     * @obsolete ICU 3.4 use UDateFormatField instead, since this API will be\n     * removed in that release\n     */\n    enum EField\n    {\n        // Obsolete; use UDateFormatField instead\n        kEraField = UDAT_ERA_FIELD,\n        kYearField = UDAT_YEAR_FIELD,\n        kMonthField = UDAT_MONTH_FIELD,\n        kDateField = UDAT_DATE_FIELD,\n        kHourOfDay1Field = UDAT_HOUR_OF_DAY1_FIELD,\n        kHourOfDay0Field = UDAT_HOUR_OF_DAY0_FIELD,\n        kMinuteField = UDAT_MINUTE_FIELD,\n        kSecondField = UDAT_SECOND_FIELD,\n        kMillisecondField = UDAT_FRACTIONAL_SECOND_FIELD,\n        kDayOfWeekField = UDAT_DAY_OF_WEEK_FIELD,\n        kDayOfYearField = UDAT_DAY_OF_YEAR_FIELD,\n        kDayOfWeekInMonthField = UDAT_DAY_OF_WEEK_IN_MONTH_FIELD,\n        kWeekOfYearField = UDAT_WEEK_OF_YEAR_FIELD,\n        kWeekOfMonthField = UDAT_WEEK_OF_MONTH_FIELD,\n        kAmPmField = UDAT_AM_PM_FIELD,\n        kHour1Field = UDAT_HOUR1_FIELD,\n        kHour0Field = UDAT_HOUR0_FIELD,\n        kTimezoneField = UDAT_TIMEZONE_FIELD,\n        kYearWOYField = UDAT_YEAR_WOY_FIELD,\n        kDOWLocalField = UDAT_DOW_LOCAL_FIELD,\n        kExtendedYearField = UDAT_EXTENDED_YEAR_FIELD,\n        kJulianDayField = UDAT_JULIAN_DAY_FIELD,\n        kMillisecondsInDayField = UDAT_MILLISECONDS_IN_DAY_FIELD,\n\n        // Obsolete; use UDateFormatField instead\n        ERA_FIELD = UDAT_ERA_FIELD,\n        YEAR_FIELD = UDAT_YEAR_FIELD,\n        MONTH_FIELD = UDAT_MONTH_FIELD,\n        DATE_FIELD = UDAT_DATE_FIELD,\n        HOUR_OF_DAY1_FIELD = UDAT_HOUR_OF_DAY1_FIELD,\n        HOUR_OF_DAY0_FIELD = UDAT_HOUR_OF_DAY0_FIELD,\n        MINUTE_FIELD = UDAT_MINUTE_FIELD,\n        SECOND_FIELD = UDAT_SECOND_FIELD,\n        MILLISECOND_FIELD = UDAT_FRACTIONAL_SECOND_FIELD,\n        DAY_OF_WEEK_FIELD = UDAT_DAY_OF_WEEK_FIELD,\n        DAY_OF_YEAR_FIELD = UDAT_DAY_OF_YEAR_FIELD,\n        DAY_OF_WEEK_IN_MONTH_FIELD = UDAT_DAY_OF_WEEK_IN_MONTH_FIELD,\n        WEEK_OF_YEAR_FIELD = UDAT_WEEK_OF_YEAR_FIELD,\n        WEEK_OF_MONTH_FIELD = UDAT_WEEK_OF_MONTH_FIELD,\n        AM_PM_FIELD = UDAT_AM_PM_FIELD,\n        HOUR1_FIELD = UDAT_HOUR1_FIELD,\n        HOUR0_FIELD = UDAT_HOUR0_FIELD,\n        TIMEZONE_FIELD = UDAT_TIMEZONE_FIELD\n    };\n#endif  /* U_HIDE_OBSOLETE_API */\n};\n\ninline UnicodeString&\nDateFormat::format(const Formattable& obj,\n                   UnicodeString& appendTo,\n                   UErrorCode& status) const {\n    return Format::format(obj, appendTo, status);\n}\nU_NAMESPACE_END\n\n#endif /* #if !UCONFIG_NO_FORMATTING */\n\n#endif // _DATEFMT\n//eof\n"
  },
  {
    "path": "deprecated/android/addons/icucompat/unicode/dbbi.h",
    "content": "/*\n**********************************************************************\n*   Copyright (C) 1999-2006 IBM Corp. All rights reserved.\n**********************************************************************\n*   Date        Name        Description\n*   12/1/99    rgillam     Complete port from Java.\n*   01/13/2000 helena      Added UErrorCode to ctors.\n**********************************************************************\n*/\n\n#ifndef DBBI_H\n#define DBBI_H\n\n#include \"unicode/rbbi.h\"\n\n#if !UCONFIG_NO_BREAK_ITERATION\n\n/**\n * \\file\n * \\brief C++ API: Dictionary Based Break Iterator\n */\n \nU_NAMESPACE_BEGIN\n\n/**\n * An obsolete subclass of RuleBasedBreakIterator. Handling of dictionary-\n * based break iteration has been folded into the base class. This class\n * is deprecated as of ICU 3.6.\n */\n \n#ifndef U_HIDE_DEPRECATED_API\n\ntypedef RuleBasedBreakIterator DictionaryBasedBreakIterator;\n\n#endif\n\nU_NAMESPACE_END\n\n#endif /* #if !UCONFIG_NO_BREAK_ITERATION */\n\n#endif\n"
  },
  {
    "path": "deprecated/android/addons/icucompat/unicode/dcfmtsym.h",
    "content": "/*\n********************************************************************************\n*   Copyright (C) 1997-2012, International Business Machines\n*   Corporation and others.  All Rights Reserved.\n********************************************************************************\n*\n* File DCFMTSYM.H\n*\n* Modification History:\n*\n*   Date        Name        Description\n*   02/19/97    aliu        Converted from java.\n*   03/18/97    clhuang     Updated per C++ implementation.\n*   03/27/97    helena      Updated to pass the simple test after code review.\n*   08/26/97    aliu        Added currency/intl currency symbol support.\n*   07/22/98    stephen     Changed to match C++ style\n*                            currencySymbol -> fCurrencySymbol\n*                            Constants changed from CAPS to kCaps\n*   06/24/99    helena      Integrated Alan's NF enhancements and Java2 bug fixes\n*   09/22/00    grhoten     Marked deprecation tags with a pointer to replacement\n*                            functions.\n********************************************************************************\n*/\n\n#ifndef DCFMTSYM_H\n#define DCFMTSYM_H\n\n#include \"unicode/utypes.h\"\n#include \"unicode/uchar.h\"\n\n#if !UCONFIG_NO_FORMATTING\n\n#include \"unicode/uobject.h\"\n#include \"unicode/locid.h\"\n#include \"unicode/unum.h\"\n\n/**\n * \\file\n * \\brief C++ API: Symbols for formatting numbers.\n */\n\n\nU_NAMESPACE_BEGIN\n\n/**\n * This class represents the set of symbols needed by DecimalFormat\n * to format numbers. DecimalFormat creates for itself an instance of\n * DecimalFormatSymbols from its locale data.  If you need to change any\n * of these symbols, you can get the DecimalFormatSymbols object from\n * your DecimalFormat and modify it.\n * <P>\n * Here are the special characters used in the parts of the\n * subpattern, with notes on their usage.\n * <pre>\n * \\code\n *        Symbol   Meaning\n *          0      a digit\n *          #      a digit, zero shows as absent\n *          .      placeholder for decimal separator\n *          ,      placeholder for grouping separator.\n *          ;      separates formats.\n *          -      default negative prefix.\n *          %      divide by 100 and show as percentage\n *          X      any other characters can be used in the prefix or suffix\n *          '      used to quote special characters in a prefix or suffix.\n * \\endcode\n *  </pre>\n * [Notes]\n * <P>\n * If there is no explicit negative subpattern, - is prefixed to the\n * positive form. That is, \"0.00\" alone is equivalent to \"0.00;-0.00\".\n * <P>\n * The grouping separator is commonly used for thousands, but in some\n * countries for ten-thousands. The interval is a constant number of\n * digits between the grouping characters, such as 100,000,000 or 1,0000,0000.\n * If you supply a pattern with multiple grouping characters, the interval\n * between the last one and the end of the integer is the one that is\n * used. So \"#,##,###,####\" == \"######,####\" == \"##,####,####\".\n * <P>\n * This class only handles localized digits where the 10 digits are\n * contiguous in Unicode, from 0 to 9. Other digits sets (such as\n * superscripts) would need a different subclass.\n */\nclass U_I18N_API DecimalFormatSymbols : public UObject {\npublic:\n    /**\n     * Constants for specifying a number format symbol.\n     * @stable ICU 2.0\n     */\n    enum ENumberFormatSymbol {\n        /** The decimal separator */\n        kDecimalSeparatorSymbol,\n        /** The grouping separator */\n        kGroupingSeparatorSymbol,\n        /** The pattern separator */\n        kPatternSeparatorSymbol,\n        /** The percent sign */\n        kPercentSymbol,\n        /** Zero*/\n        kZeroDigitSymbol,\n        /** Character representing a digit in the pattern */\n        kDigitSymbol,\n        /** The minus sign */\n        kMinusSignSymbol,\n        /** The plus sign */\n        kPlusSignSymbol,\n        /** The currency symbol */\n        kCurrencySymbol,\n        /** The international currency symbol */\n        kIntlCurrencySymbol,\n        /** The monetary separator */\n        kMonetarySeparatorSymbol,\n        /** The exponential symbol */\n        kExponentialSymbol,\n        /** Per mill symbol - replaces kPermillSymbol */\n        kPerMillSymbol,\n        /** Escape padding character */\n        kPadEscapeSymbol,\n        /** Infinity symbol */\n        kInfinitySymbol,\n        /** Nan symbol */\n        kNaNSymbol,\n        /** Significant digit symbol\n         * @stable ICU 3.0 */\n        kSignificantDigitSymbol,\n        /** The monetary grouping separator\n         * @stable ICU 3.6\n         */\n        kMonetaryGroupingSeparatorSymbol,\n        /** One\n         * @stable ICU 4.6\n         */\n        kOneDigitSymbol,\n        /** Two\n         * @stable ICU 4.6\n         */\n        kTwoDigitSymbol,\n        /** Three\n         * @stable ICU 4.6\n         */\n        kThreeDigitSymbol,\n        /** Four\n         * @stable ICU 4.6\n         */\n        kFourDigitSymbol,\n        /** Five\n         * @stable ICU 4.6\n         */\n        kFiveDigitSymbol,\n        /** Six\n         * @stable ICU 4.6\n         */\n        kSixDigitSymbol,\n        /** Seven\n         * @stable ICU 4.6\n         */\n        kSevenDigitSymbol,\n        /** Eight\n         * @stable ICU 4.6\n         */\n        kEightDigitSymbol,\n        /** Nine\n         * @stable ICU 4.6\n         */\n        kNineDigitSymbol,\n        /** count symbol constants */\n        kFormatSymbolCount\n    };\n\n    /**\n     * Create a DecimalFormatSymbols object for the given locale.\n     *\n     * @param locale    The locale to get symbols for.\n     * @param status    Input/output parameter, set to success or\n     *                  failure code upon return.\n     * @stable ICU 2.0\n     */\n    DecimalFormatSymbols(const Locale& locale, UErrorCode& status);\n\n    /**\n     * Create a DecimalFormatSymbols object for the default locale.\n     * This constructor will not fail.  If the resource file data is\n     * not available, it will use hard-coded last-resort data and\n     * set status to U_USING_FALLBACK_ERROR.\n     *\n     * @param status    Input/output parameter, set to success or\n     *                  failure code upon return.\n     * @stable ICU 2.0\n     */\n    DecimalFormatSymbols( UErrorCode& status);\n\n    // BEGIN android-added: we need a default constructor for performance.\n    // Proposed for ICU 4.8: http://icu-project.org/trac/ticket/7392\n    DecimalFormatSymbols();\n    // END android-added\n\n    /**\n     * Copy constructor.\n     * @stable ICU 2.0\n     */\n    DecimalFormatSymbols(const DecimalFormatSymbols&);\n\n    /**\n     * Assignment operator.\n     * @stable ICU 2.0\n     */\n    DecimalFormatSymbols& operator=(const DecimalFormatSymbols&);\n\n    /**\n     * Destructor.\n     * @stable ICU 2.0\n     */\n    virtual ~DecimalFormatSymbols();\n\n    /**\n     * Return true if another object is semantically equal to this one.\n     *\n     * @param other    the object to be compared with.\n     * @return         true if another object is semantically equal to this one.\n     * @stable ICU 2.0\n     */\n    UBool operator==(const DecimalFormatSymbols& other) const;\n\n    /**\n     * Return true if another object is semantically unequal to this one.\n     *\n     * @param other    the object to be compared with.\n     * @return         true if another object is semantically unequal to this one.\n     * @stable ICU 2.0\n     */\n    UBool operator!=(const DecimalFormatSymbols& other) const { return !operator==(other); }\n\n    /**\n     * Get one of the format symbols by its enum constant.\n     * Each symbol is stored as a string so that graphemes\n     * (characters with modifier letters) can be used.\n     *\n     * @param symbol    Constant to indicate a number format symbol.\n     * @return    the format symbols by the param 'symbol'\n     * @stable ICU 2.0\n     */\n    inline UnicodeString getSymbol(ENumberFormatSymbol symbol) const;\n\n    /**\n     * Set one of the format symbols by its enum constant.\n     * Each symbol is stored as a string so that graphemes\n     * (characters with modifier letters) can be used.\n     *\n     * @param symbol    Constant to indicate a number format symbol.\n     * @param value     value of the format symbol\n     * @param propogateDigits If false, setting the zero digit will not automatically set 1-9.\n     *     The default behavior is to automatically set 1-9 if zero is being set and the value\n     *     it is being set to corresponds to a known Unicode zero digit.\n     * @stable ICU 2.0\n     */\n    void setSymbol(ENumberFormatSymbol symbol, const UnicodeString &value, const UBool propogateDigits);\n\n    /**\n     * Returns the locale for which this object was constructed.\n     * @stable ICU 2.6\n     */\n    inline Locale getLocale() const;\n\n    /**\n     * Returns the locale for this object. Two flavors are available:\n     * valid and actual locale.\n     * @stable ICU 2.8\n     */\n    Locale getLocale(ULocDataLocaleType type, UErrorCode& status) const;\n\n    /**\n      * Get pattern string for 'CurrencySpacing' that can be applied to\n      * currency format.\n      * This API gets the CurrencySpacing data from ResourceBundle. The pattern can\n      * be empty if there is no data from current locale and its parent locales.\n      *\n      * @param type :  UNUM_CURRENCY_MATCH, UNUM_CURRENCY_SURROUNDING_MATCH or UNUM_CURRENCY_INSERT.\n      * @param beforeCurrency : true if the pattern is for before currency symbol.\n      *                         false if the pattern is for after currency symbol.\n      * @param status: Input/output parameter, set to success or\n      *                  failure code upon return.\n      * @return pattern string for currencyMatch, surroundingMatch or spaceInsert.\n      *     Return empty string if there is no data for this locale and its parent\n      *     locales.\n      * @stable ICU 4.8\n      */\n     const UnicodeString& getPatternForCurrencySpacing(UCurrencySpacing type,\n                                                 UBool beforeCurrency,\n                                                 UErrorCode& status) const;\n     /**\n       * Set pattern string for 'CurrencySpacing' that can be applied to\n       * currency format.\n       *\n       * @param type : UNUM_CURRENCY_MATCH, UNUM_CURRENCY_SURROUNDING_MATCH or UNUM_CURRENCY_INSERT.\n       * @param beforeCurrency : true if the pattern is for before currency symbol.\n       *                         false if the pattern is for after currency symbol.\n       * @param pattern : pattern string to override current setting.\n       * @stable ICU 4.8\n       */\n     void setPatternForCurrencySpacing(UCurrencySpacing type,\n                                       UBool beforeCurrency,\n                                       const UnicodeString& pattern);\n\n    /**\n     * ICU \"poor man's RTTI\", returns a UClassID for the actual class.\n     *\n     * @stable ICU 2.2\n     */\n    virtual UClassID getDynamicClassID() const;\n\n    /**\n     * ICU \"poor man's RTTI\", returns a UClassID for this class.\n     *\n     * @stable ICU 2.2\n     */\n    static UClassID U_EXPORT2 getStaticClassID();\n\nprivate:\n    // BEGIN android-removed: we need a default constructor for performance.\n    // DecimalFormatSymbols(); // default constructor not implemented\n    // END android-removed\n\n    /**\n     * Initializes the symbols from the LocaleElements resource bundle.\n     * Note: The organization of LocaleElements badly needs to be\n     * cleaned up.\n     *\n     * @param locale               The locale to get symbols for.\n     * @param success              Input/output parameter, set to success or\n     *                             failure code upon return.\n     * @param useLastResortData    determine if use last resort data\n     */\n    void initialize(const Locale& locale, UErrorCode& success, UBool useLastResortData = FALSE);\n\n    /**\n     * Initialize the symbols with default values.\n     */\n    void initialize();\n\n    void setCurrencyForSymbols();\n\npublic:\n#ifndef U_HIDE_INTERNAL_API\n    /**\n     * _Internal_ function - more efficient version of getSymbol,\n     * returning a const reference to one of the symbol strings.\n     * The returned reference becomes invalid when the symbol is changed\n     * or when the DecimalFormatSymbols are destroyed.\n     * ### TODO markus 2002oct11: Consider proposing getConstSymbol() to be really public.\n     *\n     * @param symbol Constant to indicate a number format symbol.\n     * @return the format symbol by the param 'symbol'\n     * @internal\n     */\n    inline const UnicodeString &getConstSymbol(ENumberFormatSymbol symbol) const;\n\n    /**\n     * Returns that pattern stored in currecy info. Internal API for use by NumberFormat API.\n     * @internal\n     */\n    inline const UChar* getCurrencyPattern(void) const;\n#endif  /* U_HIDE_INTERNAL_API */\n\nprivate:\n    /**\n     * Private symbol strings.\n     * They are either loaded from a resource bundle or otherwise owned.\n     * setSymbol() clones the symbol string.\n     * Readonly aliases can only come from a resource bundle, so that we can always\n     * use fastCopyFrom() with them.\n     *\n     * If DecimalFormatSymbols becomes subclassable and the status of fSymbols changes\n     * from private to protected,\n     * or when fSymbols can be set any other way that allows them to be readonly aliases\n     * to non-resource bundle strings,\n     * then regular UnicodeString copies must be used instead of fastCopyFrom().\n     *\n     * @internal\n     */\n    UnicodeString fSymbols[kFormatSymbolCount];\n\n    /**\n     * Non-symbol variable for getConstSymbol(). Always empty.\n     * @internal\n     */\n    UnicodeString fNoSymbol;\n\n    Locale locale;\n\n    char actualLocale[ULOC_FULLNAME_CAPACITY];\n    char validLocale[ULOC_FULLNAME_CAPACITY];\n    const UChar* currPattern;\n\n    UnicodeString currencySpcBeforeSym[UNUM_CURRENCY_SPACING_COUNT];\n    UnicodeString currencySpcAfterSym[UNUM_CURRENCY_SPACING_COUNT];\n};\n\n// -------------------------------------\n\ninline UnicodeString\nDecimalFormatSymbols::getSymbol(ENumberFormatSymbol symbol) const {\n    const UnicodeString *strPtr;\n    if(symbol < kFormatSymbolCount) {\n        strPtr = &fSymbols[symbol];\n    } else {\n        strPtr = &fNoSymbol;\n    }\n    return *strPtr;\n}\n\n#ifndef U_HIDE_INTERNAL_API\ninline const UnicodeString &\nDecimalFormatSymbols::getConstSymbol(ENumberFormatSymbol symbol) const {\n    const UnicodeString *strPtr;\n    if(symbol < kFormatSymbolCount) {\n        strPtr = &fSymbols[symbol];\n    } else {\n        strPtr = &fNoSymbol;\n    }\n    return *strPtr;\n}\n#endif\n\n\n// -------------------------------------\n\ninline void\nDecimalFormatSymbols::setSymbol(ENumberFormatSymbol symbol, const UnicodeString &value, const UBool propogateDigits = TRUE) {\n    if(symbol<kFormatSymbolCount) {\n        fSymbols[symbol]=value;\n    }\n\n    // If the zero digit is being set to a known zero digit according to Unicode,\n    // then we automatically set the corresponding 1-9 digits\n    if ( propogateDigits && symbol == kZeroDigitSymbol && value.countChar32() == 1 ) {\n        UChar32 sym = value.char32At(0);\n        if ( u_charDigitValue(sym) == 0 ) {\n            for ( int8_t i = 1 ; i<= 9 ; i++ ) {\n                sym++;\n                fSymbols[(int)kOneDigitSymbol+i-1] = UnicodeString(sym);\n            }\n        }\n    }\n}\n\n// -------------------------------------\n\ninline Locale\nDecimalFormatSymbols::getLocale() const {\n    return locale;\n}\n\n#ifndef U_HIDE_INTERNAL_API\ninline const UChar*\nDecimalFormatSymbols::getCurrencyPattern() const {\n    return currPattern;\n}\n#endif\n\nU_NAMESPACE_END\n\n#endif /* #if !UCONFIG_NO_FORMATTING */\n\n#endif // _DCFMTSYM\n//eof\n"
  },
  {
    "path": "deprecated/android/addons/icucompat/unicode/decimfmt.h",
    "content": "/*\n********************************************************************************\n*   Copyright (C) 1997-2012, International Business Machines\n*   Corporation and others.  All Rights Reserved.\n********************************************************************************\n*\n* File DECIMFMT.H\n*\n* Modification History:\n*\n*   Date        Name        Description\n*   02/19/97    aliu        Converted from java.\n*   03/20/97    clhuang     Updated per C++ implementation.\n*   04/03/97    aliu        Rewrote parsing and formatting completely, and\n*                           cleaned up and debugged.  Actually works now.\n*   04/17/97    aliu        Changed DigitCount to int per code review.\n*   07/10/97    helena      Made ParsePosition a class and get rid of the function\n*                           hiding problems.\n*   09/09/97    aliu        Ported over support for exponential formats.\n*    07/20/98    stephen        Changed documentation\n********************************************************************************\n*/\n\n#ifndef DECIMFMT_H\n#define DECIMFMT_H\n\n#include \"unicode/utypes.h\"\n/**\n * \\file\n * \\brief C++ API: Formats decimal numbers.\n */\n\n#if !UCONFIG_NO_FORMATTING\n\n#include \"unicode/dcfmtsym.h\"\n#include \"unicode/numfmt.h\"\n#include \"unicode/locid.h\"\n#include \"unicode/fpositer.h\"\n#include \"unicode/stringpiece.h\"\n#include \"unicode/curramt.h\"\n#include \"unicode/enumset.h\"\n\n/**\n * \\def UNUM_DECIMALFORMAT_INTERNAL_SIZE\n * @internal\n */\n#if UCONFIG_FORMAT_FASTPATHS_49\n#define UNUM_DECIMALFORMAT_INTERNAL_SIZE 16\n#endif\n\nU_NAMESPACE_BEGIN\n\nclass DigitList;\nclass ChoiceFormat;\nclass CurrencyPluralInfo;\nclass Hashtable;\nclass UnicodeSet;\nclass FieldPositionHandler;\n\n// explicit template instantiation. see digitlst.h\n#if defined (_MSC_VER)\ntemplate class U_I18N_API    EnumSet<UNumberFormatAttribute,\n            UNUM_MAX_NONBOOLEAN_ATTRIBUTE+1, \n            UNUM_LIMIT_BOOLEAN_ATTRIBUTE>;\n#endif\n\n/**\n * DecimalFormat is a concrete subclass of NumberFormat that formats decimal\n * numbers. It has a variety of features designed to make it possible to parse\n * and format numbers in any locale, including support for Western, Arabic, or\n * Indic digits.  It also supports different flavors of numbers, including\n * integers (\"123\"), fixed-point numbers (\"123.4\"), scientific notation\n * (\"1.23E4\"), percentages (\"12%\"), and currency amounts (\"$123\", \"USD123\",\n * \"123 US dollars\").  All of these flavors can be easily localized.\n *\n * <p>To obtain a NumberFormat for a specific locale (including the default\n * locale) call one of NumberFormat's factory methods such as\n * createInstance(). Do not call the DecimalFormat constructors directly, unless\n * you know what you are doing, since the NumberFormat factory methods may\n * return subclasses other than DecimalFormat.\n *\n * <p><strong>Example Usage</strong>\n *\n * \\code\n *     // Normally we would have a GUI with a menu for this\n *     int32_t locCount;\n *     const Locale* locales = NumberFormat::getAvailableLocales(locCount);\n *\n *     double myNumber = -1234.56;\n *     UErrorCode success = U_ZERO_ERROR;\n *     NumberFormat* form;\n *\n *     // Print out a number with the localized number, currency and percent\n *     // format for each locale.\n *     UnicodeString countryName;\n *     UnicodeString displayName;\n *     UnicodeString str;\n *     UnicodeString pattern;\n *     Formattable fmtable;\n *     for (int32_t j = 0; j < 3; ++j) {\n *         cout << endl << \"FORMAT \" << j << endl;\n *         for (int32_t i = 0; i < locCount; ++i) {\n *             if (locales[i].getCountry(countryName).size() == 0) {\n *                 // skip language-only\n *                 continue;\n *             }\n *             switch (j) {\n *             case 0:\n *                 form = NumberFormat::createInstance(locales[i], success ); break;\n *             case 1:\n *                 form = NumberFormat::createCurrencyInstance(locales[i], success ); break;\n *             default:\n *                 form = NumberFormat::createPercentInstance(locales[i], success ); break;\n *             }\n *             if (form) {\n *                 str.remove();\n *                 pattern = ((DecimalFormat*)form)->toPattern(pattern);\n *                 cout << locales[i].getDisplayName(displayName) << \": \" << pattern;\n *                 cout << \"  ->  \" << form->format(myNumber,str) << endl;\n *                 form->parse(form->format(myNumber,str), fmtable, success);\n *                 delete form;\n *             }\n *         }\n *     }\n * \\endcode\n * <P>\n * Another example use createInstance(style)\n * <P>\n * <pre>\n * <strong>// Print out a number using the localized number, currency,\n * // percent, scientific, integer, iso currency, and plural currency\n * // format for each locale</strong>\n * Locale* locale = new Locale(\"en\", \"US\");\n * double myNumber = 1234.56;\n * UErrorCode success = U_ZERO_ERROR;\n * UnicodeString str;\n * Formattable fmtable;\n * for (int j=NumberFormat::kNumberStyle;\n *      j<=NumberFormat::kPluralCurrencyStyle;\n *      ++j) {\n *     NumberFormat* format = NumberFormat::createInstance(locale, j, success);\n *     str.remove();\n *     cout << \"format result \" << form->format(myNumber, str) << endl;\n *     format->parse(form->format(myNumber, str), fmtable, success);\n * }</pre>\n *\n *\n * <p><strong>Patterns</strong>\n *\n * <p>A DecimalFormat consists of a <em>pattern</em> and a set of\n * <em>symbols</em>.  The pattern may be set directly using\n * applyPattern(), or indirectly using other API methods which\n * manipulate aspects of the pattern, such as the minimum number of integer\n * digits.  The symbols are stored in a DecimalFormatSymbols\n * object.  When using the NumberFormat factory methods, the\n * pattern and symbols are read from ICU's locale data.\n *\n * <p><strong>Special Pattern Characters</strong>\n *\n * <p>Many characters in a pattern are taken literally; they are matched during\n * parsing and output unchanged during formatting.  Special characters, on the\n * other hand, stand for other characters, strings, or classes of characters.\n * For example, the '#' character is replaced by a localized digit.  Often the\n * replacement character is the same as the pattern character; in the U.S. locale,\n * the ',' grouping character is replaced by ','.  However, the replacement is\n * still happening, and if the symbols are modified, the grouping character\n * changes.  Some special characters affect the behavior of the formatter by\n * their presence; for example, if the percent character is seen, then the\n * value is multiplied by 100 before being displayed.\n *\n * <p>To insert a special character in a pattern as a literal, that is, without\n * any special meaning, the character must be quoted.  There are some exceptions to\n * this which are noted below.\n *\n * <p>The characters listed here are used in non-localized patterns.  Localized\n * patterns use the corresponding characters taken from this formatter's\n * DecimalFormatSymbols object instead, and these characters lose\n * their special status.  Two exceptions are the currency sign and quote, which\n * are not localized.\n *\n * <table border=0 cellspacing=3 cellpadding=0>\n *   <tr bgcolor=\"#ccccff\">\n *     <td align=left><strong>Symbol</strong>\n *     <td align=left><strong>Location</strong>\n *     <td align=left><strong>Localized?</strong>\n *     <td align=left><strong>Meaning</strong>\n *   <tr valign=top>\n *     <td><code>0</code>\n *     <td>Number\n *     <td>Yes\n *     <td>Digit\n *   <tr valign=top bgcolor=\"#eeeeff\">\n *     <td><code>1-9</code>\n *     <td>Number\n *     <td>Yes\n *     <td>'1' through '9' indicate rounding.\n *   <tr valign=top>\n *     <td><code>\\htmlonly&#x40;\\endhtmlonly</code> <!--doxygen doesn't like @-->\n *     <td>Number\n *     <td>No\n *     <td>Significant digit\n *   <tr valign=top bgcolor=\"#eeeeff\">\n *     <td><code>#</code>\n *     <td>Number\n *     <td>Yes\n *     <td>Digit, zero shows as absent\n *   <tr valign=top>\n *     <td><code>.</code>\n *     <td>Number\n *     <td>Yes\n *     <td>Decimal separator or monetary decimal separator\n *   <tr valign=top bgcolor=\"#eeeeff\">\n *     <td><code>-</code>\n *     <td>Number\n *     <td>Yes\n *     <td>Minus sign\n *   <tr valign=top>\n *     <td><code>,</code>\n *     <td>Number\n *     <td>Yes\n *     <td>Grouping separator\n *   <tr valign=top bgcolor=\"#eeeeff\">\n *     <td><code>E</code>\n *     <td>Number\n *     <td>Yes\n *     <td>Separates mantissa and exponent in scientific notation.\n *         <em>Need not be quoted in prefix or suffix.</em>\n *   <tr valign=top>\n *     <td><code>+</code>\n *     <td>Exponent\n *     <td>Yes\n *     <td>Prefix positive exponents with localized plus sign.\n *         <em>Need not be quoted in prefix or suffix.</em>\n *   <tr valign=top bgcolor=\"#eeeeff\">\n *     <td><code>;</code>\n *     <td>Subpattern boundary\n *     <td>Yes\n *     <td>Separates positive and negative subpatterns\n *   <tr valign=top>\n *     <td><code>\\%</code>\n *     <td>Prefix or suffix\n *     <td>Yes\n *     <td>Multiply by 100 and show as percentage\n *   <tr valign=top bgcolor=\"#eeeeff\">\n *     <td><code>\\\\u2030</code>\n *     <td>Prefix or suffix\n *     <td>Yes\n *     <td>Multiply by 1000 and show as per mille\n *   <tr valign=top>\n *     <td><code>\\htmlonly&curren;\\endhtmlonly</code> (<code>\\\\u00A4</code>)\n *     <td>Prefix or suffix\n *     <td>No\n *     <td>Currency sign, replaced by currency symbol.  If\n *         doubled, replaced by international currency symbol.\n *         If tripled, replaced by currency plural names, for example,\n *         \"US dollar\" or \"US dollars\" for America.\n *         If present in a pattern, the monetary decimal separator\n *         is used instead of the decimal separator.\n *   <tr valign=top bgcolor=\"#eeeeff\">\n *     <td><code>'</code>\n *     <td>Prefix or suffix\n *     <td>No\n *     <td>Used to quote special characters in a prefix or suffix,\n *         for example, <code>\"'#'#\"</code> formats 123 to\n *         <code>\"#123\"</code>.  To create a single quote\n *         itself, use two in a row: <code>\"# o''clock\"</code>.\n *   <tr valign=top>\n *     <td><code>*</code>\n *     <td>Prefix or suffix boundary\n *     <td>Yes\n *     <td>Pad escape, precedes pad character\n * </table>\n *\n * <p>A DecimalFormat pattern contains a postive and negative\n * subpattern, for example, \"#,##0.00;(#,##0.00)\".  Each subpattern has a\n * prefix, a numeric part, and a suffix.  If there is no explicit negative\n * subpattern, the negative subpattern is the localized minus sign prefixed to the\n * positive subpattern. That is, \"0.00\" alone is equivalent to \"0.00;-0.00\".  If there\n * is an explicit negative subpattern, it serves only to specify the negative\n * prefix and suffix; the number of digits, minimal digits, and other\n * characteristics are ignored in the negative subpattern. That means that\n * \"#,##0.0#;(#)\" has precisely the same result as \"#,##0.0#;(#,##0.0#)\".\n *\n * <p>The prefixes, suffixes, and various symbols used for infinity, digits,\n * thousands separators, decimal separators, etc. may be set to arbitrary\n * values, and they will appear properly during formatting.  However, care must\n * be taken that the symbols and strings do not conflict, or parsing will be\n * unreliable.  For example, either the positive and negative prefixes or the\n * suffixes must be distinct for parse() to be able\n * to distinguish positive from negative values.  Another example is that the\n * decimal separator and thousands separator should be distinct characters, or\n * parsing will be impossible.\n *\n * <p>The <em>grouping separator</em> is a character that separates clusters of\n * integer digits to make large numbers more legible.  It commonly used for\n * thousands, but in some locales it separates ten-thousands.  The <em>grouping\n * size</em> is the number of digits between the grouping separators, such as 3\n * for \"100,000,000\" or 4 for \"1 0000 0000\". There are actually two different\n * grouping sizes: One used for the least significant integer digits, the\n * <em>primary grouping size</em>, and one used for all others, the\n * <em>secondary grouping size</em>.  In most locales these are the same, but\n * sometimes they are different. For example, if the primary grouping interval\n * is 3, and the secondary is 2, then this corresponds to the pattern\n * \"#,##,##0\", and the number 123456789 is formatted as \"12,34,56,789\".  If a\n * pattern contains multiple grouping separators, the interval between the last\n * one and the end of the integer defines the primary grouping size, and the\n * interval between the last two defines the secondary grouping size. All others\n * are ignored, so \"#,##,###,####\" == \"###,###,####\" == \"##,#,###,####\".\n *\n * <p>Illegal patterns, such as \"#.#.#\" or \"#.###,###\", will cause\n * DecimalFormat to set a failing UErrorCode.\n *\n * <p><strong>Pattern BNF</strong>\n *\n * <pre>\n * pattern    := subpattern (';' subpattern)?\n * subpattern := prefix? number exponent? suffix?\n * number     := (integer ('.' fraction)?) | sigDigits\n * prefix     := '\\\\u0000'..'\\\\uFFFD' - specialCharacters\n * suffix     := '\\\\u0000'..'\\\\uFFFD' - specialCharacters\n * integer    := '#'* '0'* '0'\n * fraction   := '0'* '#'*\n * sigDigits  := '#'* '@' '@'* '#'*\n * exponent   := 'E' '+'? '0'* '0'\n * padSpec    := '*' padChar\n * padChar    := '\\\\u0000'..'\\\\uFFFD' - quote\n * &nbsp;\n * Notation:\n *   X*       0 or more instances of X\n *   X?       0 or 1 instances of X\n *   X|Y      either X or Y\n *   C..D     any character from C up to D, inclusive\n *   S-T      characters in S, except those in T\n * </pre>\n * The first subpattern is for positive numbers. The second (optional)\n * subpattern is for negative numbers.\n *\n * <p>Not indicated in the BNF syntax above:\n *\n * <ul><li>The grouping separator ',' can occur inside the integer and\n * sigDigits elements, between any two pattern characters of that\n * element, as long as the integer or sigDigits element is not\n * followed by the exponent element.\n *\n * <li>Two grouping intervals are recognized: That between the\n *     decimal point and the first grouping symbol, and that\n *     between the first and second grouping symbols. These\n *     intervals are identical in most locales, but in some\n *     locales they differ. For example, the pattern\n *     &quot;#,##,###&quot; formats the number 123456789 as\n *     &quot;12,34,56,789&quot;.</li>\n *\n * <li>The pad specifier <code>padSpec</code> may appear before the prefix,\n * after the prefix, before the suffix, after the suffix, or not at all.\n *\n * <li>In place of '0', the digits '1' through '9' may be used to\n * indicate a rounding increment.\n * </ul>\n *\n * <p><strong>Parsing</strong>\n *\n * <p>DecimalFormat parses all Unicode characters that represent\n * decimal digits, as defined by u_charDigitValue().  In addition,\n * DecimalFormat also recognizes as digits the ten consecutive\n * characters starting with the localized zero digit defined in the\n * DecimalFormatSymbols object.  During formatting, the\n * DecimalFormatSymbols-based digits are output.\n *\n * <p>During parsing, grouping separators are ignored if in lenient mode;\n * otherwise, if present, they must be in appropriate positions.\n *\n * <p>For currency parsing, the formatter is able to parse every currency\n * style formats no matter which style the formatter is constructed with.\n * For example, a formatter instance gotten from\n * NumberFormat.getInstance(ULocale, NumberFormat.CURRENCYSTYLE) can parse\n * formats such as \"USD1.00\" and \"3.00 US dollars\".\n *\n * <p>If parse(UnicodeString&,Formattable&,ParsePosition&)\n * fails to parse a string, it leaves the parse position unchanged.\n * The convenience method parse(UnicodeString&,Formattable&,UErrorCode&)\n * indicates parse failure by setting a failing\n * UErrorCode.\n *\n * <p><strong>Formatting</strong>\n *\n * <p>Formatting is guided by several parameters, all of which can be\n * specified either using a pattern or using the API.  The following\n * description applies to formats that do not use <a href=\"#sci\">scientific\n * notation</a> or <a href=\"#sigdig\">significant digits</a>.\n *\n * <ul><li>If the number of actual integer digits exceeds the\n * <em>maximum integer digits</em>, then only the least significant\n * digits are shown.  For example, 1997 is formatted as \"97\" if the\n * maximum integer digits is set to 2.\n *\n * <li>If the number of actual integer digits is less than the\n * <em>minimum integer digits</em>, then leading zeros are added.  For\n * example, 1997 is formatted as \"01997\" if the minimum integer digits\n * is set to 5.\n *\n * <li>If the number of actual fraction digits exceeds the <em>maximum\n * fraction digits</em>, then rounding is performed to the\n * maximum fraction digits.  For example, 0.125 is formatted as \"0.12\"\n * if the maximum fraction digits is 2.  This behavior can be changed\n * by specifying a rounding increment and/or a rounding mode.\n *\n * <li>If the number of actual fraction digits is less than the\n * <em>minimum fraction digits</em>, then trailing zeros are added.\n * For example, 0.125 is formatted as \"0.1250\" if the mimimum fraction\n * digits is set to 4.\n *\n * <li>Trailing fractional zeros are not displayed if they occur\n * <em>j</em> positions after the decimal, where <em>j</em> is less\n * than the maximum fraction digits. For example, 0.10004 is\n * formatted as \"0.1\" if the maximum fraction digits is four or less.\n * </ul>\n *\n * <p><strong>Special Values</strong>\n *\n * <p><code>NaN</code> is represented as a single character, typically\n * <code>\\\\uFFFD</code>.  This character is determined by the\n * DecimalFormatSymbols object.  This is the only value for which\n * the prefixes and suffixes are not used.\n *\n * <p>Infinity is represented as a single character, typically\n * <code>\\\\u221E</code>, with the positive or negative prefixes and suffixes\n * applied.  The infinity character is determined by the\n * DecimalFormatSymbols object.\n *\n * <a name=\"sci\"><strong>Scientific Notation</strong></a>\n *\n * <p>Numbers in scientific notation are expressed as the product of a mantissa\n * and a power of ten, for example, 1234 can be expressed as 1.234 x 10<sup>3</sup>. The\n * mantissa is typically in the half-open interval [1.0, 10.0) or sometimes [0.0, 1.0),\n * but it need not be.  DecimalFormat supports arbitrary mantissas.\n * DecimalFormat can be instructed to use scientific\n * notation through the API or through the pattern.  In a pattern, the exponent\n * character immediately followed by one or more digit characters indicates\n * scientific notation.  Example: \"0.###E0\" formats the number 1234 as\n * \"1.234E3\".\n *\n * <ul>\n * <li>The number of digit characters after the exponent character gives the\n * minimum exponent digit count.  There is no maximum.  Negative exponents are\n * formatted using the localized minus sign, <em>not</em> the prefix and suffix\n * from the pattern.  This allows patterns such as \"0.###E0 m/s\".  To prefix\n * positive exponents with a localized plus sign, specify '+' between the\n * exponent and the digits: \"0.###E+0\" will produce formats \"1E+1\", \"1E+0\",\n * \"1E-1\", etc.  (In localized patterns, use the localized plus sign rather than\n * '+'.)\n *\n * <li>The minimum number of integer digits is achieved by adjusting the\n * exponent.  Example: 0.00123 formatted with \"00.###E0\" yields \"12.3E-4\".  This\n * only happens if there is no maximum number of integer digits.  If there is a\n * maximum, then the minimum number of integer digits is fixed at one.\n *\n * <li>The maximum number of integer digits, if present, specifies the exponent\n * grouping.  The most common use of this is to generate <em>engineering\n * notation</em>, in which the exponent is a multiple of three, e.g.,\n * \"##0.###E0\".  The number 12345 is formatted using \"##0.####E0\" as \"12.345E3\".\n *\n * <li>When using scientific notation, the formatter controls the\n * digit counts using significant digits logic.  The maximum number of\n * significant digits limits the total number of integer and fraction\n * digits that will be shown in the mantissa; it does not affect\n * parsing.  For example, 12345 formatted with \"##0.##E0\" is \"12.3E3\".\n * See the section on significant digits for more details.\n *\n * <li>The number of significant digits shown is determined as\n * follows: If areSignificantDigitsUsed() returns false, then the\n * minimum number of significant digits shown is one, and the maximum\n * number of significant digits shown is the sum of the <em>minimum\n * integer</em> and <em>maximum fraction</em> digits, and is\n * unaffected by the maximum integer digits.  If this sum is zero,\n * then all significant digits are shown.  If\n * areSignificantDigitsUsed() returns true, then the significant digit\n * counts are specified by getMinimumSignificantDigits() and\n * getMaximumSignificantDigits().  In this case, the number of\n * integer digits is fixed at one, and there is no exponent grouping.\n *\n * <li>Exponential patterns may not contain grouping separators.\n * </ul>\n *\n * <a name=\"sigdig\"><strong>Significant Digits</strong></a>\n *\n * <code>DecimalFormat</code> has two ways of controlling how many\n * digits are shows: (a) significant digits counts, or (b) integer and\n * fraction digit counts.  Integer and fraction digit counts are\n * described above.  When a formatter is using significant digits\n * counts, the number of integer and fraction digits is not specified\n * directly, and the formatter settings for these counts are ignored.\n * Instead, the formatter uses however many integer and fraction\n * digits are required to display the specified number of significant\n * digits.  Examples:\n *\n * <table border=0 cellspacing=3 cellpadding=0>\n *   <tr bgcolor=\"#ccccff\">\n *     <td align=left>Pattern\n *     <td align=left>Minimum significant digits\n *     <td align=left>Maximum significant digits\n *     <td align=left>Number\n *     <td align=left>Output of format()\n *   <tr valign=top>\n *     <td><code>\\@\\@\\@</code>\n *     <td>3\n *     <td>3\n *     <td>12345\n *     <td><code>12300</code>\n *   <tr valign=top bgcolor=\"#eeeeff\">\n *     <td><code>\\@\\@\\@</code>\n *     <td>3\n *     <td>3\n *     <td>0.12345\n *     <td><code>0.123</code>\n *   <tr valign=top>\n *     <td><code>\\@\\@##</code>\n *     <td>2\n *     <td>4\n *     <td>3.14159\n *     <td><code>3.142</code>\n *   <tr valign=top bgcolor=\"#eeeeff\">\n *     <td><code>\\@\\@##</code>\n *     <td>2\n *     <td>4\n *     <td>1.23004\n *     <td><code>1.23</code>\n * </table>\n *\n * <ul>\n * <li>Significant digit counts may be expressed using patterns that\n * specify a minimum and maximum number of significant digits.  These\n * are indicated by the <code>'@'</code> and <code>'#'</code>\n * characters.  The minimum number of significant digits is the number\n * of <code>'@'</code> characters.  The maximum number of significant\n * digits is the number of <code>'@'</code> characters plus the number\n * of <code>'#'</code> characters following on the right.  For\n * example, the pattern <code>\"@@@\"</code> indicates exactly 3\n * significant digits.  The pattern <code>\"@##\"</code> indicates from\n * 1 to 3 significant digits.  Trailing zero digits to the right of\n * the decimal separator are suppressed after the minimum number of\n * significant digits have been shown.  For example, the pattern\n * <code>\"@##\"</code> formats the number 0.1203 as\n * <code>\"0.12\"</code>.\n *\n * <li>If a pattern uses significant digits, it may not contain a\n * decimal separator, nor the <code>'0'</code> pattern character.\n * Patterns such as <code>\"@00\"</code> or <code>\"@.###\"</code> are\n * disallowed.\n *\n * <li>Any number of <code>'#'</code> characters may be prepended to\n * the left of the leftmost <code>'@'</code> character.  These have no\n * effect on the minimum and maximum significant digits counts, but\n * may be used to position grouping separators.  For example,\n * <code>\"#,#@#\"</code> indicates a minimum of one significant digits,\n * a maximum of two significant digits, and a grouping size of three.\n *\n * <li>In order to enable significant digits formatting, use a pattern\n * containing the <code>'@'</code> pattern character.  Alternatively,\n * call setSignificantDigitsUsed(TRUE).\n *\n * <li>In order to disable significant digits formatting, use a\n * pattern that does not contain the <code>'@'</code> pattern\n * character. Alternatively, call setSignificantDigitsUsed(FALSE).\n *\n * <li>The number of significant digits has no effect on parsing.\n *\n * <li>Significant digits may be used together with exponential notation. Such\n * patterns are equivalent to a normal exponential pattern with a minimum and\n * maximum integer digit count of one, a minimum fraction digit count of\n * <code>getMinimumSignificantDigits() - 1</code>, and a maximum fraction digit\n * count of <code>getMaximumSignificantDigits() - 1</code>. For example, the\n * pattern <code>\"@@###E0\"</code> is equivalent to <code>\"0.0###E0\"</code>.\n *\n * <li>If signficant digits are in use, then the integer and fraction\n * digit counts, as set via the API, are ignored.  If significant\n * digits are not in use, then the signficant digit counts, as set via\n * the API, are ignored.\n *\n * </ul>\n *\n * <p><strong>Padding</strong>\n *\n * <p>DecimalFormat supports padding the result of\n * format() to a specific width.  Padding may be specified either\n * through the API or through the pattern syntax.  In a pattern the pad escape\n * character, followed by a single pad character, causes padding to be parsed\n * and formatted.  The pad escape character is '*' in unlocalized patterns, and\n * can be localized using DecimalFormatSymbols::setSymbol() with a\n * DecimalFormatSymbols::kPadEscapeSymbol\n * selector.  For example, <code>\"$*x#,##0.00\"</code> formats 123 to\n * <code>\"$xx123.00\"</code>, and 1234 to <code>\"$1,234.00\"</code>.\n *\n * <ul>\n * <li>When padding is in effect, the width of the positive subpattern,\n * including prefix and suffix, determines the format width.  For example, in\n * the pattern <code>\"* #0 o''clock\"</code>, the format width is 10.\n *\n * <li>The width is counted in 16-bit code units (UChars).\n *\n * <li>Some parameters which usually do not matter have meaning when padding is\n * used, because the pattern width is significant with padding.  In the pattern\n * \"* ##,##,#,##0.##\", the format width is 14.  The initial characters \"##,##,\"\n * do not affect the grouping size or maximum integer digits, but they do affect\n * the format width.\n *\n * <li>Padding may be inserted at one of four locations: before the prefix,\n * after the prefix, before the suffix, or after the suffix.  If padding is\n * specified in any other location, applyPattern()\n * sets a failing UErrorCode.  If there is no prefix,\n * before the prefix and after the prefix are equivalent, likewise for the\n * suffix.\n *\n * <li>When specified in a pattern, the 32-bit code point immediately\n * following the pad escape is the pad character. This may be any character,\n * including a special pattern character. That is, the pad escape\n * <em>escapes</em> the following character. If there is no character after\n * the pad escape, then the pattern is illegal.\n *\n * </ul>\n *\n * <p><strong>Rounding</strong>\n *\n * <p>DecimalFormat supports rounding to a specific increment.  For\n * example, 1230 rounded to the nearest 50 is 1250.  1.234 rounded to the\n * nearest 0.65 is 1.3.  The rounding increment may be specified through the API\n * or in a pattern.  To specify a rounding increment in a pattern, include the\n * increment in the pattern itself.  \"#,#50\" specifies a rounding increment of\n * 50.  \"#,##0.05\" specifies a rounding increment of 0.05.\n *\n * <p>In the absense of an explicit rounding increment numbers are\n * rounded to their formatted width.\n *\n * <ul>\n * <li>Rounding only affects the string produced by formatting.  It does\n * not affect parsing or change any numerical values.\n *\n * <li>A <em>rounding mode</em> determines how values are rounded; see\n * DecimalFormat::ERoundingMode.  The default rounding mode is\n * DecimalFormat::kRoundHalfEven.  The rounding mode can only be set\n * through the API; it can not be set with a pattern.\n *\n * <li>Some locales use rounding in their currency formats to reflect the\n * smallest currency denomination.\n *\n * <li>In a pattern, digits '1' through '9' specify rounding, but otherwise\n * behave identically to digit '0'.\n * </ul>\n *\n * <p><strong>Synchronization</strong>\n *\n * <p>DecimalFormat objects are not synchronized.  Multiple\n * threads should not access one formatter concurrently.\n *\n * <p><strong>Subclassing</strong>\n *\n * <p><em>User subclasses are not supported.</em> While clients may write\n * subclasses, such code will not necessarily work and will not be\n * guaranteed to work stably from release to release.\n */\nclass U_I18N_API DecimalFormat: public NumberFormat {\npublic:\n    /**\n     * Rounding mode.\n     * @stable ICU 2.4\n     */\n    enum ERoundingMode {\n        kRoundCeiling,  /**< Round towards positive infinity */\n        kRoundFloor,    /**< Round towards negative infinity */\n        kRoundDown,     /**< Round towards zero */\n        kRoundUp,       /**< Round away from zero */\n        kRoundHalfEven, /**< Round towards the nearest integer, or\n                             towards the nearest even integer if equidistant */\n        kRoundHalfDown, /**< Round towards the nearest integer, or\n                             towards zero if equidistant */\n        kRoundHalfUp,   /**< Round towards the nearest integer, or\n                             away from zero if equidistant */\n        /**\n          *  Return U_FORMAT_INEXACT_ERROR if number does not format exactly. \n          *  @stable ICU 4.8 \n          */\n        kRoundUnnecessary\n    };\n\n    /**\n     * Pad position.\n     * @stable ICU 2.4\n     */\n    enum EPadPosition {\n        kPadBeforePrefix,\n        kPadAfterPrefix,\n        kPadBeforeSuffix,\n        kPadAfterSuffix\n    };\n\n    /**\n     * Create a DecimalFormat using the default pattern and symbols\n     * for the default locale. This is a convenient way to obtain a\n     * DecimalFormat when internationalization is not the main concern.\n     * <P>\n     * To obtain standard formats for a given locale, use the factory methods\n     * on NumberFormat such as createInstance. These factories will\n     * return the most appropriate sub-class of NumberFormat for a given\n     * locale.\n     * @param status    Output param set to success/failure code. If the\n     *                  pattern is invalid this will be set to a failure code.\n     * @stable ICU 2.0\n     */\n    DecimalFormat(UErrorCode& status);\n\n    /**\n     * Create a DecimalFormat from the given pattern and the symbols\n     * for the default locale. This is a convenient way to obtain a\n     * DecimalFormat when internationalization is not the main concern.\n     * <P>\n     * To obtain standard formats for a given locale, use the factory methods\n     * on NumberFormat such as createInstance. These factories will\n     * return the most appropriate sub-class of NumberFormat for a given\n     * locale.\n     * @param pattern   A non-localized pattern string.\n     * @param status    Output param set to success/failure code. If the\n     *                  pattern is invalid this will be set to a failure code.\n     * @stable ICU 2.0\n     */\n    DecimalFormat(const UnicodeString& pattern,\n                  UErrorCode& status);\n\n    /**\n     * Create a DecimalFormat from the given pattern and symbols.\n     * Use this constructor when you need to completely customize the\n     * behavior of the format.\n     * <P>\n     * To obtain standard formats for a given\n     * locale, use the factory methods on NumberFormat such as\n     * createInstance or createCurrencyInstance. If you need only minor adjustments\n     * to a standard format, you can modify the format returned by\n     * a NumberFormat factory method.\n     *\n     * @param pattern           a non-localized pattern string\n     * @param symbolsToAdopt    the set of symbols to be used.  The caller should not\n     *                          delete this object after making this call.\n     * @param status            Output param set to success/failure code. If the\n     *                          pattern is invalid this will be set to a failure code.\n     * @stable ICU 2.0\n     */\n    DecimalFormat(  const UnicodeString& pattern,\n                    DecimalFormatSymbols* symbolsToAdopt,\n                    UErrorCode& status);\n\n#ifndef U_HIDE_INTERNAL_API\n    /**\n     * This API is for ICU use only.\n     * Create a DecimalFormat from the given pattern, symbols, and style.\n     *\n     * @param pattern           a non-localized pattern string\n     * @param symbolsToAdopt    the set of symbols to be used.  The caller should not\n     *                          delete this object after making this call.\n     * @param style             style of decimal format\n     * @param status            Output param set to success/failure code. If the\n     *                          pattern is invalid this will be set to a failure code.\n     * @internal ICU 4.2\n     */\n    DecimalFormat(  const UnicodeString& pattern,\n                    DecimalFormatSymbols* symbolsToAdopt,\n                    UNumberFormatStyle style,\n                    UErrorCode& status);\n\n\n    /**\n     * Set an integer attribute on this DecimalFormat.\n     * May return U_UNSUPPORTED_ERROR if this instance does not support\n     * the specified attribute.\n     * @param attr the attribute to set\n     * @param newvalue new value\n     * @param status the error type\n     * @return *this - for chaining\n     * @internal ICU 50\n     */\n    virtual DecimalFormat& setAttribute( UNumberFormatAttribute attr,\n                                       int32_t newvalue,\n                                       UErrorCode &status);\n\n    /**\n     * Get an integer\n     * May return U_UNSUPPORTED_ERROR if this instance does not support\n     * the specified attribute.\n     * @param attr the attribute to set\n     * @param status the error type\n     * @return the attribute value. Undefined if there is an error.\n     * @internal ICU 50\n     */\n    virtual int32_t getAttribute( UNumberFormatAttribute attr,\n                                  UErrorCode &status) const;\n\n#if UCONFIG_HAVE_PARSEALLINPUT\n    /**\n     * @internal \n     */\n    void setParseAllInput(UNumberFormatAttributeValue value);\n#endif\n\n#endif  /* U_HIDE_INTERNAL_API */\n\n    /**\n     * Create a DecimalFormat from the given pattern and symbols.\n     * Use this constructor when you need to completely customize the\n     * behavior of the format.\n     * <P>\n     * To obtain standard formats for a given\n     * locale, use the factory methods on NumberFormat such as\n     * createInstance or createCurrencyInstance. If you need only minor adjustments\n     * to a standard format, you can modify the format returned by\n     * a NumberFormat factory method.\n     *\n     * @param pattern           a non-localized pattern string\n     * @param symbolsToAdopt    the set of symbols to be used.  The caller should not\n     *                          delete this object after making this call.\n     * @param parseError        Output param to receive errors occured during parsing\n     * @param status            Output param set to success/failure code. If the\n     *                          pattern is invalid this will be set to a failure code.\n     * @stable ICU 2.0\n     */\n    DecimalFormat(  const UnicodeString& pattern,\n                    DecimalFormatSymbols* symbolsToAdopt,\n                    UParseError& parseError,\n                    UErrorCode& status);\n    /**\n     * Create a DecimalFormat from the given pattern and symbols.\n     * Use this constructor when you need to completely customize the\n     * behavior of the format.\n     * <P>\n     * To obtain standard formats for a given\n     * locale, use the factory methods on NumberFormat such as\n     * createInstance or createCurrencyInstance. If you need only minor adjustments\n     * to a standard format, you can modify the format returned by\n     * a NumberFormat factory method.\n     *\n     * @param pattern           a non-localized pattern string\n     * @param symbols   the set of symbols to be used\n     * @param status            Output param set to success/failure code. If the\n     *                          pattern is invalid this will be set to a failure code.\n     * @stable ICU 2.0\n     */\n    DecimalFormat(  const UnicodeString& pattern,\n                    const DecimalFormatSymbols& symbols,\n                    UErrorCode& status);\n\n    /**\n     * Copy constructor.\n     *\n     * @param source    the DecimalFormat object to be copied from.\n     * @stable ICU 2.0\n     */\n    DecimalFormat(const DecimalFormat& source);\n\n    /**\n     * Assignment operator.\n     *\n     * @param rhs    the DecimalFormat object to be copied.\n     * @stable ICU 2.0\n     */\n    DecimalFormat& operator=(const DecimalFormat& rhs);\n\n    /**\n     * Destructor.\n     * @stable ICU 2.0\n     */\n    virtual ~DecimalFormat();\n\n    /**\n     * Clone this Format object polymorphically. The caller owns the\n     * result and should delete it when done.\n     *\n     * @return    a polymorphic copy of this DecimalFormat.\n     * @stable ICU 2.0\n     */\n    virtual Format* clone(void) const;\n\n    /**\n     * Return true if the given Format objects are semantically equal.\n     * Objects of different subclasses are considered unequal.\n     *\n     * @param other    the object to be compared with.\n     * @return         true if the given Format objects are semantically equal.\n     * @stable ICU 2.0\n     */\n    virtual UBool operator==(const Format& other) const;\n\n\n    using NumberFormat::format;\n\n    /**\n     * Format a double or long number using base-10 representation.\n     *\n     * @param number    The value to be formatted.\n     * @param appendTo  Output parameter to receive result.\n     *                  Result is appended to existing contents.\n     * @param pos       On input: an alignment field, if desired.\n     *                  On output: the offsets of the alignment field.\n     * @return          Reference to 'appendTo' parameter.\n     * @stable ICU 2.0\n     */\n    virtual UnicodeString& format(double number,\n                                  UnicodeString& appendTo,\n                                  FieldPosition& pos) const;\n\n\n    /**\n     * Format a double or long number using base-10 representation.\n     *\n     * @param number    The value to be formatted.\n     * @param appendTo  Output parameter to receive result.\n     *                  Result is appended to existing contents.\n     * @param pos       On input: an alignment field, if desired.\n     *                  On output: the offsets of the alignment field.\n     * @param status\n     * @return          Reference to 'appendTo' parameter.\n     * @internal\n     */\n    virtual UnicodeString& format(double number,\n                                  UnicodeString& appendTo,\n                                  FieldPosition& pos,\n                                  UErrorCode &status) const;\n\n    /**\n     * Format a double or long number using base-10 representation.\n     *\n     * @param number    The value to be formatted.\n     * @param appendTo  Output parameter to receive result.\n     *                  Result is appended to existing contents.\n     * @param posIter   On return, can be used to iterate over positions\n     *                  of fields generated by this format call.\n     *                  Can be NULL.\n     * @param status    Output param filled with success/failure status.\n     * @return          Reference to 'appendTo' parameter.\n     * @stable 4.4\n     */\n    virtual UnicodeString& format(double number,\n                                  UnicodeString& appendTo,\n                                  FieldPositionIterator* posIter,\n                                  UErrorCode& status) const;\n\n    /**\n     * Format a long number using base-10 representation.\n     *\n     * @param number    The value to be formatted.\n     * @param appendTo  Output parameter to receive result.\n     *                  Result is appended to existing contents.\n     * @param pos       On input: an alignment field, if desired.\n     *                  On output: the offsets of the alignment field.\n     * @return          Reference to 'appendTo' parameter.\n     * @stable ICU 2.0\n     */\n    virtual UnicodeString& format(int32_t number,\n                                  UnicodeString& appendTo,\n                                  FieldPosition& pos) const;\n\n    /**\n     * Format a long number using base-10 representation.\n     *\n     * @param number    The value to be formatted.\n     * @param appendTo  Output parameter to receive result.\n     *                  Result is appended to existing contents.\n     * @param pos       On input: an alignment field, if desired.\n     *                  On output: the offsets of the alignment field.\n     * @return          Reference to 'appendTo' parameter.\n     * @internal\n     */\n    virtual UnicodeString& format(int32_t number,\n                                  UnicodeString& appendTo,\n                                  FieldPosition& pos,\n                                  UErrorCode &status) const;\n\n    /**\n     * Format a long number using base-10 representation.\n     *\n     * @param number    The value to be formatted.\n     * @param appendTo  Output parameter to receive result.\n     *                  Result is appended to existing contents.\n     * @param posIter   On return, can be used to iterate over positions\n     *                  of fields generated by this format call.\n     *                  Can be NULL.\n     * @param status    Output param filled with success/failure status.\n     * @return          Reference to 'appendTo' parameter.\n     * @stable 4.4\n     */\n    virtual UnicodeString& format(int32_t number,\n                                  UnicodeString& appendTo,\n                                  FieldPositionIterator* posIter,\n                                  UErrorCode& status) const;\n\n    /**\n     * Format an int64 number using base-10 representation.\n     *\n     * @param number    The value to be formatted.\n     * @param appendTo  Output parameter to receive result.\n     *                  Result is appended to existing contents.\n     * @param pos       On input: an alignment field, if desired.\n     *                  On output: the offsets of the alignment field.\n     * @return          Reference to 'appendTo' parameter.\n     * @stable ICU 2.8\n     */\n    virtual UnicodeString& format(int64_t number,\n                                  UnicodeString& appendTo,\n                                  FieldPosition& pos) const;\n\n    /**\n     * Format an int64 number using base-10 representation.\n     *\n     * @param number    The value to be formatted.\n     * @param appendTo  Output parameter to receive result.\n     *                  Result is appended to existing contents.\n     * @param pos       On input: an alignment field, if desired.\n     *                  On output: the offsets of the alignment field.\n     * @return          Reference to 'appendTo' parameter.\n     * @internal\n     */\n    virtual UnicodeString& format(int64_t number,\n                                  UnicodeString& appendTo,\n                                  FieldPosition& pos,\n                                  UErrorCode &status) const;\n\n    /**\n     * Format an int64 number using base-10 representation.\n     *\n     * @param number    The value to be formatted.\n     * @param appendTo  Output parameter to receive result.\n     *                  Result is appended to existing contents.\n     * @param posIter   On return, can be used to iterate over positions\n     *                  of fields generated by this format call.\n     *                  Can be NULL.\n     * @param status    Output param filled with success/failure status.\n     * @return          Reference to 'appendTo' parameter.\n     * @stable 4.4\n     */\n    virtual UnicodeString& format(int64_t number,\n                                  UnicodeString& appendTo,\n                                  FieldPositionIterator* posIter,\n                                  UErrorCode& status) const;\n\n    /**\n     * Format a decimal number.\n     * The syntax of the unformatted number is a \"numeric string\"\n     * as defined in the Decimal Arithmetic Specification, available at\n     * http://speleotrove.com/decimal\n     *\n     * @param number    The unformatted number, as a string.\n     * @param appendTo  Output parameter to receive result.\n     *                  Result is appended to existing contents.\n     * @param posIter   On return, can be used to iterate over positions\n     *                  of fields generated by this format call.\n     *                  Can be NULL.\n     * @param status    Output param filled with success/failure status.\n     * @return          Reference to 'appendTo' parameter.\n     * @stable 4.4\n     */\n    virtual UnicodeString& format(const StringPiece &number,\n                                  UnicodeString& appendTo,\n                                  FieldPositionIterator* posIter,\n                                  UErrorCode& status) const;\n\n\n    /**\n     * Format a decimal number. \n     * The number is a DigitList wrapper onto a floating point decimal number.\n     * The default implementation in NumberFormat converts the decimal number\n     * to a double and formats that.\n     *\n     * @param number    The number, a DigitList format Decimal Floating Point.\n     * @param appendTo  Output parameter to receive result.\n     *                  Result is appended to existing contents.\n     * @param posIter   On return, can be used to iterate over positions\n     *                  of fields generated by this format call.\n     * @param status    Output param filled with success/failure status.\n     * @return          Reference to 'appendTo' parameter.\n     * @internal\n     */\n    virtual UnicodeString& format(const DigitList &number,\n                                  UnicodeString& appendTo,\n                                  FieldPositionIterator* posIter,\n                                  UErrorCode& status) const;\n\n    /**\n     * Format a decimal number. \n     * The number is a DigitList wrapper onto a floating point decimal number.\n     * The default implementation in NumberFormat converts the decimal number\n     * to a double and formats that.  \n     *\n     * @param number    The number, a DigitList format Decimal Floating Point.\n     * @param appendTo  Output parameter to receive result.\n     *                  Result is appended to existing contents.\n     * @param pos       On input: an alignment field, if desired.\n     *                  On output: the offsets of the alignment field.\n     * @param status    Output param filled with success/failure status.\n     * @return          Reference to 'appendTo' parameter.\n     * @internal\n     */\n    virtual UnicodeString& format(const DigitList &number,\n                                  UnicodeString& appendTo,\n                                  FieldPosition& pos,\n                                  UErrorCode& status) const;\n\n\n    /**\n     * Format a Formattable using base-10 representation.\n     *\n     * @param obj       The value to be formatted.\n     * @param appendTo  Output parameter to receive result.\n     *                  Result is appended to existing contents.\n     * @param pos       On input: an alignment field, if desired.\n     *                  On output: the offsets of the alignment field.\n     * @param status    Error code indicating success or failure.\n     * @return          Reference to 'appendTo' parameter.\n     * @stable ICU 2.0\n     */\n    virtual UnicodeString& format(const Formattable& obj,\n                                  UnicodeString& appendTo,\n                                  FieldPosition& pos,\n                                  UErrorCode& status) const;\n\n    /**\n     * Redeclared NumberFormat method.\n     * Formats an object to produce a string.\n     *\n     * @param obj       The object to format.\n     * @param appendTo  Output parameter to receive result.\n     *                  Result is appended to existing contents.\n     * @param status    Output parameter filled in with success or failure status.\n     * @return          Reference to 'appendTo' parameter.\n     * @stable ICU 2.0\n     */\n    UnicodeString& format(const Formattable& obj,\n                          UnicodeString& appendTo,\n                          UErrorCode& status) const;\n\n    /**\n     * Redeclared NumberFormat method.\n     * Format a double number.\n     *\n     * @param number    The value to be formatted.\n     * @param appendTo  Output parameter to receive result.\n     *                  Result is appended to existing contents.\n     * @return          Reference to 'appendTo' parameter.\n     * @stable ICU 2.0\n     */\n    UnicodeString& format(double number,\n                          UnicodeString& appendTo) const;\n\n    /**\n     * Redeclared NumberFormat method.\n     * Format a long number. These methods call the NumberFormat\n     * pure virtual format() methods with the default FieldPosition.\n     *\n     * @param number    The value to be formatted.\n     * @param appendTo  Output parameter to receive result.\n     *                  Result is appended to existing contents.\n     * @return          Reference to 'appendTo' parameter.\n     * @stable ICU 2.0\n     */\n    UnicodeString& format(int32_t number,\n                          UnicodeString& appendTo) const;\n\n    /**\n     * Redeclared NumberFormat method.\n     * Format an int64 number. These methods call the NumberFormat\n     * pure virtual format() methods with the default FieldPosition.\n     *\n     * @param number    The value to be formatted.\n     * @param appendTo  Output parameter to receive result.\n     *                  Result is appended to existing contents.\n     * @return          Reference to 'appendTo' parameter.\n     * @stable ICU 2.8\n     */\n    UnicodeString& format(int64_t number,\n                          UnicodeString& appendTo) const;\n   /**\n    * Parse the given string using this object's choices. The method\n    * does string comparisons to try to find an optimal match.\n    * If no object can be parsed, index is unchanged, and NULL is\n    * returned.  The result is returned as the most parsimonious\n    * type of Formattable that will accomodate all of the\n    * necessary precision.  For example, if the result is exactly 12,\n    * it will be returned as a long.  However, if it is 1.5, it will\n    * be returned as a double.\n    *\n    * @param text           The text to be parsed.\n    * @param result         Formattable to be set to the parse result.\n    *                       If parse fails, return contents are undefined.\n    * @param parsePosition  The position to start parsing at on input.\n    *                       On output, moved to after the last successfully\n    *                       parse character. On parse failure, does not change.\n    * @see Formattable\n    * @stable ICU 2.0\n    */\n    virtual void parse(const UnicodeString& text,\n                       Formattable& result,\n                       ParsePosition& parsePosition) const;\n\n    // Declare here again to get rid of function hiding problems.\n    /**\n     * Parse the given string using this object's choices.\n     *\n     * @param text           The text to be parsed.\n     * @param result         Formattable to be set to the parse result.\n     * @param status    Output parameter filled in with success or failure status.\n     * @stable ICU 2.0\n     */\n    virtual void parse(const UnicodeString& text,\n                       Formattable& result,\n                       UErrorCode& status) const;\n\n/* Cannot use #ifndef U_HIDE_DRAFT_API for the following draft method since it is virtual */\n    /**\n     * Parses text from the given string as a currency amount.  Unlike\n     * the parse() method, this method will attempt to parse a generic\n     * currency name, searching for a match of this object's locale's\n     * currency display names, or for a 3-letter ISO currency code.\n     * This method will fail if this format is not a currency format,\n     * that is, if it does not contain the currency pattern symbol\n     * (U+00A4) in its prefix or suffix.\n     *\n     * @param text the string to parse\n     * @param pos  input-output position; on input, the position within text\n     *             to match; must have 0 <= pos.getIndex() < text.length();\n     *             on output, the position after the last matched character.\n     *             If the parse fails, the position in unchanged upon output.\n     * @return     if parse succeeds, a pointer to a newly-created CurrencyAmount\n     *             object (owned by the caller) containing information about\n     *             the parsed currency; if parse fails, this is NULL.\n     * @draft ICU 49\n     */\n    virtual CurrencyAmount* parseCurrency(const UnicodeString& text,\n                                          ParsePosition& pos) const;\n\n    /**\n     * Returns the decimal format symbols, which is generally not changed\n     * by the programmer or user.\n     * @return desired DecimalFormatSymbols\n     * @see DecimalFormatSymbols\n     * @stable ICU 2.0\n     */\n    virtual const DecimalFormatSymbols* getDecimalFormatSymbols(void) const;\n\n    /**\n     * Sets the decimal format symbols, which is generally not changed\n     * by the programmer or user.\n     * @param symbolsToAdopt DecimalFormatSymbols to be adopted.\n     * @stable ICU 2.0\n     */\n    virtual void adoptDecimalFormatSymbols(DecimalFormatSymbols* symbolsToAdopt);\n\n    /**\n     * Sets the decimal format symbols, which is generally not changed\n     * by the programmer or user.\n     * @param symbols DecimalFormatSymbols.\n     * @stable ICU 2.0\n     */\n    virtual void setDecimalFormatSymbols(const DecimalFormatSymbols& symbols);\n\n\n    /**\n     * Returns the currency plural format information,\n     * which is generally not changed by the programmer or user.\n     * @return desired CurrencyPluralInfo\n     * @stable ICU 4.2\n     */\n    virtual const CurrencyPluralInfo* getCurrencyPluralInfo(void) const;\n\n    /**\n     * Sets the currency plural format information,\n     * which is generally not changed by the programmer or user.\n     * @param toAdopt CurrencyPluralInfo to be adopted.\n     * @stable ICU 4.2\n     */\n    virtual void adoptCurrencyPluralInfo(CurrencyPluralInfo* toAdopt);\n\n    /**\n     * Sets the currency plural format information,\n     * which is generally not changed by the programmer or user.\n     * @param info Currency Plural Info.\n     * @stable ICU 4.2\n     */\n    virtual void setCurrencyPluralInfo(const CurrencyPluralInfo& info);\n\n\n    /**\n     * Get the positive prefix.\n     *\n     * @param result    Output param which will receive the positive prefix.\n     * @return          A reference to 'result'.\n     * Examples: +123, $123, sFr123\n     * @stable ICU 2.0\n     */\n    UnicodeString& getPositivePrefix(UnicodeString& result) const;\n\n    /**\n     * Set the positive prefix.\n     *\n     * @param newValue    the new value of the the positive prefix to be set.\n     * Examples: +123, $123, sFr123\n     * @stable ICU 2.0\n     */\n    virtual void setPositivePrefix(const UnicodeString& newValue);\n\n    /**\n     * Get the negative prefix.\n     *\n     * @param result    Output param which will receive the negative prefix.\n     * @return          A reference to 'result'.\n     * Examples: -123, ($123) (with negative suffix), sFr-123\n     * @stable ICU 2.0\n     */\n    UnicodeString& getNegativePrefix(UnicodeString& result) const;\n\n    /**\n     * Set the negative prefix.\n     *\n     * @param newValue    the new value of the the negative prefix to be set.\n     * Examples: -123, ($123) (with negative suffix), sFr-123\n     * @stable ICU 2.0\n     */\n    virtual void setNegativePrefix(const UnicodeString& newValue);\n\n    /**\n     * Get the positive suffix.\n     *\n     * @param result    Output param which will receive the positive suffix.\n     * @return          A reference to 'result'.\n     * Example: 123%\n     * @stable ICU 2.0\n     */\n    UnicodeString& getPositiveSuffix(UnicodeString& result) const;\n\n    /**\n     * Set the positive suffix.\n     *\n     * @param newValue    the new value of the positive suffix to be set.\n     * Example: 123%\n     * @stable ICU 2.0\n     */\n    virtual void setPositiveSuffix(const UnicodeString& newValue);\n\n    /**\n     * Get the negative suffix.\n     *\n     * @param result    Output param which will receive the negative suffix.\n     * @return          A reference to 'result'.\n     * Examples: -123%, ($123) (with positive suffixes)\n     * @stable ICU 2.0\n     */\n    UnicodeString& getNegativeSuffix(UnicodeString& result) const;\n\n    /**\n     * Set the negative suffix.\n     *\n     * @param newValue    the new value of the negative suffix to be set.\n     * Examples: 123%\n     * @stable ICU 2.0\n     */\n    virtual void setNegativeSuffix(const UnicodeString& newValue);\n\n    /**\n     * Get the multiplier for use in percent, permill, etc.\n     * For a percentage, set the suffixes to have \"%\" and the multiplier to be 100.\n     * (For Arabic, use arabic percent symbol).\n     * For a permill, set the suffixes to have \"\\\\u2031\" and the multiplier to be 1000.\n     *\n     * @return    the multiplier for use in percent, permill, etc.\n     * Examples: with 100, 1.23 -> \"123\", and \"123\" -> 1.23\n     * @stable ICU 2.0\n     */\n    int32_t getMultiplier(void) const;\n\n    /**\n     * Set the multiplier for use in percent, permill, etc.\n     * For a percentage, set the suffixes to have \"%\" and the multiplier to be 100.\n     * (For Arabic, use arabic percent symbol).\n     * For a permill, set the suffixes to have \"\\\\u2031\" and the multiplier to be 1000.\n     *\n     * @param newValue    the new value of the multiplier for use in percent, permill, etc.\n     * Examples: with 100, 1.23 -> \"123\", and \"123\" -> 1.23\n     * @stable ICU 2.0\n     */\n    virtual void setMultiplier(int32_t newValue);\n\n    /**\n     * Get the rounding increment.\n     * @return A positive rounding increment, or 0.0 if a rounding\n     * increment is not in effect.\n     * @see #setRoundingIncrement\n     * @see #getRoundingMode\n     * @see #setRoundingMode\n     * @stable ICU 2.0\n     */\n    virtual double getRoundingIncrement(void) const;\n\n    /**\n     * Set the rounding increment.  In the absence of a rounding increment,\n     *    numbers will be rounded to the number of digits displayed.\n     * @param newValue A positive rounding increment.\n     * Negative increments are equivalent to 0.0.\n     * @see #getRoundingIncrement\n     * @see #getRoundingMode\n     * @see #setRoundingMode\n     * @stable ICU 2.0\n     */\n    virtual void setRoundingIncrement(double newValue);\n\n    /**\n     * Get the rounding mode.\n     * @return A rounding mode\n     * @see #setRoundingIncrement\n     * @see #getRoundingIncrement\n     * @see #setRoundingMode\n     * @stable ICU 2.0\n     */\n    virtual ERoundingMode getRoundingMode(void) const;\n\n    /**\n     * Set the rounding mode.  \n     * @param roundingMode A rounding mode\n     * @see #setRoundingIncrement\n     * @see #getRoundingIncrement\n     * @see #getRoundingMode\n     * @stable ICU 2.0\n     */\n    virtual void setRoundingMode(ERoundingMode roundingMode);\n\n    /**\n     * Get the width to which the output of format() is padded.\n     * The width is counted in 16-bit code units.\n     * @return the format width, or zero if no padding is in effect\n     * @see #setFormatWidth\n     * @see #getPadCharacterString\n     * @see #setPadCharacter\n     * @see #getPadPosition\n     * @see #setPadPosition\n     * @stable ICU 2.0\n     */\n    virtual int32_t getFormatWidth(void) const;\n\n    /**\n     * Set the width to which the output of format() is padded.\n     * The width is counted in 16-bit code units.\n     * This method also controls whether padding is enabled.\n     * @param width the width to which to pad the result of\n     * format(), or zero to disable padding.  A negative\n     * width is equivalent to 0.\n     * @see #getFormatWidth\n     * @see #getPadCharacterString\n     * @see #setPadCharacter\n     * @see #getPadPosition\n     * @see #setPadPosition\n     * @stable ICU 2.0\n     */\n    virtual void setFormatWidth(int32_t width);\n\n    /**\n     * Get the pad character used to pad to the format width.  The\n     * default is ' '.\n     * @return a string containing the pad character. This will always\n     * have a length of one 32-bit code point.\n     * @see #setFormatWidth\n     * @see #getFormatWidth\n     * @see #setPadCharacter\n     * @see #getPadPosition\n     * @see #setPadPosition\n     * @stable ICU 2.0\n     */\n    virtual UnicodeString getPadCharacterString() const;\n\n    /**\n     * Set the character used to pad to the format width.  If padding\n     * is not enabled, then this will take effect if padding is later\n     * enabled.\n     * @param padChar a string containing the pad charcter. If the string\n     * has length 0, then the pad characer is set to ' '.  Otherwise\n     * padChar.char32At(0) will be used as the pad character.\n     * @see #setFormatWidth\n     * @see #getFormatWidth\n     * @see #getPadCharacterString\n     * @see #getPadPosition\n     * @see #setPadPosition\n     * @stable ICU 2.0\n     */\n    virtual void setPadCharacter(const UnicodeString &padChar);\n\n    /**\n     * Get the position at which padding will take place.  This is the location\n     * at which padding will be inserted if the result of format()\n     * is shorter than the format width.\n     * @return the pad position, one of kPadBeforePrefix,\n     * kPadAfterPrefix, kPadBeforeSuffix, or\n     * kPadAfterSuffix.\n     * @see #setFormatWidth\n     * @see #getFormatWidth\n     * @see #setPadCharacter\n     * @see #getPadCharacterString\n     * @see #setPadPosition\n     * @see #EPadPosition\n     * @stable ICU 2.0\n     */\n    virtual EPadPosition getPadPosition(void) const;\n\n    /**\n     * Set the position at which padding will take place.  This is the location\n     * at which padding will be inserted if the result of format()\n     * is shorter than the format width.  This has no effect unless padding is\n     * enabled.\n     * @param padPos the pad position, one of kPadBeforePrefix,\n     * kPadAfterPrefix, kPadBeforeSuffix, or\n     * kPadAfterSuffix.\n     * @see #setFormatWidth\n     * @see #getFormatWidth\n     * @see #setPadCharacter\n     * @see #getPadCharacterString\n     * @see #getPadPosition\n     * @see #EPadPosition\n     * @stable ICU 2.0\n     */\n    virtual void setPadPosition(EPadPosition padPos);\n\n    /**\n     * Return whether or not scientific notation is used.\n     * @return TRUE if this object formats and parses scientific notation\n     * @see #setScientificNotation\n     * @see #getMinimumExponentDigits\n     * @see #setMinimumExponentDigits\n     * @see #isExponentSignAlwaysShown\n     * @see #setExponentSignAlwaysShown\n     * @stable ICU 2.0\n     */\n    virtual UBool isScientificNotation(void);\n\n    /**\n     * Set whether or not scientific notation is used. When scientific notation\n     * is used, the effective maximum number of integer digits is <= 8.  If the\n     * maximum number of integer digits is set to more than 8, the effective\n     * maximum will be 1.  This allows this call to generate a 'default' scientific\n     * number format without additional changes.\n     * @param useScientific TRUE if this object formats and parses scientific\n     * notation\n     * @see #isScientificNotation\n     * @see #getMinimumExponentDigits\n     * @see #setMinimumExponentDigits\n     * @see #isExponentSignAlwaysShown\n     * @see #setExponentSignAlwaysShown\n     * @stable ICU 2.0\n     */\n    virtual void setScientificNotation(UBool useScientific);\n\n    /**\n     * Return the minimum exponent digits that will be shown.\n     * @return the minimum exponent digits that will be shown\n     * @see #setScientificNotation\n     * @see #isScientificNotation\n     * @see #setMinimumExponentDigits\n     * @see #isExponentSignAlwaysShown\n     * @see #setExponentSignAlwaysShown\n     * @stable ICU 2.0\n     */\n    virtual int8_t getMinimumExponentDigits(void) const;\n\n    /**\n     * Set the minimum exponent digits that will be shown.  This has no\n     * effect unless scientific notation is in use.\n     * @param minExpDig a value >= 1 indicating the fewest exponent digits\n     * that will be shown.  Values less than 1 will be treated as 1.\n     * @see #setScientificNotation\n     * @see #isScientificNotation\n     * @see #getMinimumExponentDigits\n     * @see #isExponentSignAlwaysShown\n     * @see #setExponentSignAlwaysShown\n     * @stable ICU 2.0\n     */\n    virtual void setMinimumExponentDigits(int8_t minExpDig);\n\n    /**\n     * Return whether the exponent sign is always shown.\n     * @return TRUE if the exponent is always prefixed with either the\n     * localized minus sign or the localized plus sign, false if only negative\n     * exponents are prefixed with the localized minus sign.\n     * @see #setScientificNotation\n     * @see #isScientificNotation\n     * @see #setMinimumExponentDigits\n     * @see #getMinimumExponentDigits\n     * @see #setExponentSignAlwaysShown\n     * @stable ICU 2.0\n     */\n    virtual UBool isExponentSignAlwaysShown(void);\n\n    /**\n     * Set whether the exponent sign is always shown.  This has no effect\n     * unless scientific notation is in use.\n     * @param expSignAlways TRUE if the exponent is always prefixed with either\n     * the localized minus sign or the localized plus sign, false if only\n     * negative exponents are prefixed with the localized minus sign.\n     * @see #setScientificNotation\n     * @see #isScientificNotation\n     * @see #setMinimumExponentDigits\n     * @see #getMinimumExponentDigits\n     * @see #isExponentSignAlwaysShown\n     * @stable ICU 2.0\n     */\n    virtual void setExponentSignAlwaysShown(UBool expSignAlways);\n\n    /**\n     * Return the grouping size. Grouping size is the number of digits between\n     * grouping separators in the integer portion of a number.  For example,\n     * in the number \"123,456.78\", the grouping size is 3.\n     *\n     * @return    the grouping size.\n     * @see setGroupingSize\n     * @see NumberFormat::isGroupingUsed\n     * @see DecimalFormatSymbols::getGroupingSeparator\n     * @stable ICU 2.0\n     */\n    int32_t getGroupingSize(void) const;\n\n    /**\n     * Set the grouping size. Grouping size is the number of digits between\n     * grouping separators in the integer portion of a number.  For example,\n     * in the number \"123,456.78\", the grouping size is 3.\n     *\n     * @param newValue    the new value of the grouping size.\n     * @see getGroupingSize\n     * @see NumberFormat::setGroupingUsed\n     * @see DecimalFormatSymbols::setGroupingSeparator\n     * @stable ICU 2.0\n     */\n    virtual void setGroupingSize(int32_t newValue);\n\n    /**\n     * Return the secondary grouping size. In some locales one\n     * grouping interval is used for the least significant integer\n     * digits (the primary grouping size), and another is used for all\n     * others (the secondary grouping size).  A formatter supporting a\n     * secondary grouping size will return a positive integer unequal\n     * to the primary grouping size returned by\n     * getGroupingSize().  For example, if the primary\n     * grouping size is 4, and the secondary grouping size is 2, then\n     * the number 123456789 formats as \"1,23,45,6789\", and the pattern\n     * appears as \"#,##,###0\".\n     * @return the secondary grouping size, or a value less than\n     * one if there is none\n     * @see setSecondaryGroupingSize\n     * @see NumberFormat::isGroupingUsed\n     * @see DecimalFormatSymbols::getGroupingSeparator\n     * @stable ICU 2.4\n     */\n    int32_t getSecondaryGroupingSize(void) const;\n\n    /**\n     * Set the secondary grouping size. If set to a value less than 1,\n     * then secondary grouping is turned off, and the primary grouping\n     * size is used for all intervals, not just the least significant.\n     *\n     * @param newValue    the new value of the secondary grouping size.\n     * @see getSecondaryGroupingSize\n     * @see NumberFormat#setGroupingUsed\n     * @see DecimalFormatSymbols::setGroupingSeparator\n     * @stable ICU 2.4\n     */\n    virtual void setSecondaryGroupingSize(int32_t newValue);\n\n    /**\n     * Allows you to get the behavior of the decimal separator with integers.\n     * (The decimal separator will always appear with decimals.)\n     *\n     * @return    TRUE if the decimal separator always appear with decimals.\n     * Example: Decimal ON: 12345 -> 12345.; OFF: 12345 -> 12345\n     * @stable ICU 2.0\n     */\n    UBool isDecimalSeparatorAlwaysShown(void) const;\n\n    /**\n     * Allows you to set the behavior of the decimal separator with integers.\n     * (The decimal separator will always appear with decimals.)\n     *\n     * @param newValue    set TRUE if the decimal separator will always appear with decimals.\n     * Example: Decimal ON: 12345 -> 12345.; OFF: 12345 -> 12345\n     * @stable ICU 2.0\n     */\n    virtual void setDecimalSeparatorAlwaysShown(UBool newValue);\n\n    /**\n     * Synthesizes a pattern string that represents the current state\n     * of this Format object.\n     *\n     * @param result    Output param which will receive the pattern.\n     *                  Previous contents are deleted.\n     * @return          A reference to 'result'.\n     * @see applyPattern\n     * @stable ICU 2.0\n     */\n    virtual UnicodeString& toPattern(UnicodeString& result) const;\n\n    /**\n     * Synthesizes a localized pattern string that represents the current\n     * state of this Format object.\n     *\n     * @param result    Output param which will receive the localized pattern.\n     *                  Previous contents are deleted.\n     * @return          A reference to 'result'.\n     * @see applyPattern\n     * @stable ICU 2.0\n     */\n    virtual UnicodeString& toLocalizedPattern(UnicodeString& result) const;\n\n    /**\n     * Apply the given pattern to this Format object.  A pattern is a\n     * short-hand specification for the various formatting properties.\n     * These properties can also be changed individually through the\n     * various setter methods.\n     * <P>\n     * There is no limit to integer digits are set\n     * by this routine, since that is the typical end-user desire;\n     * use setMaximumInteger if you want to set a real value.\n     * For negative numbers, use a second pattern, separated by a semicolon\n     * <pre>\n     * .      Example \"#,#00.0#\" -> 1,234.56\n     * </pre>\n     * This means a minimum of 2 integer digits, 1 fraction digit, and\n     * a maximum of 2 fraction digits.\n     * <pre>\n     * .      Example: \"#,#00.0#;(#,#00.0#)\" for negatives in parantheses.\n     * </pre>\n     * In negative patterns, the minimum and maximum counts are ignored;\n     * these are presumed to be set in the positive pattern.\n     *\n     * @param pattern    The pattern to be applied.\n     * @param parseError Struct to recieve information on position\n     *                   of error if an error is encountered\n     * @param status     Output param set to success/failure code on\n     *                   exit. If the pattern is invalid, this will be\n     *                   set to a failure result.\n     * @stable ICU 2.0\n     */\n    virtual void applyPattern(const UnicodeString& pattern,\n                             UParseError& parseError,\n                             UErrorCode& status);\n    /**\n     * Sets the pattern.\n     * @param pattern   The pattern to be applied.\n     * @param status    Output param set to success/failure code on\n     *                  exit. If the pattern is invalid, this will be\n     *                  set to a failure result.\n     * @stable ICU 2.0\n     */\n    virtual void applyPattern(const UnicodeString& pattern,\n                             UErrorCode& status);\n\n    /**\n     * Apply the given pattern to this Format object.  The pattern\n     * is assumed to be in a localized notation. A pattern is a\n     * short-hand specification for the various formatting properties.\n     * These properties can also be changed individually through the\n     * various setter methods.\n     * <P>\n     * There is no limit to integer digits are set\n     * by this routine, since that is the typical end-user desire;\n     * use setMaximumInteger if you want to set a real value.\n     * For negative numbers, use a second pattern, separated by a semicolon\n     * <pre>\n     * .      Example \"#,#00.0#\" -> 1,234.56\n     * </pre>\n     * This means a minimum of 2 integer digits, 1 fraction digit, and\n     * a maximum of 2 fraction digits.\n     *\n     * Example: \"#,#00.0#;(#,#00.0#)\" for negatives in parantheses.\n     *\n     * In negative patterns, the minimum and maximum counts are ignored;\n     * these are presumed to be set in the positive pattern.\n     *\n     * @param pattern   The localized pattern to be applied.\n     * @param parseError Struct to recieve information on position\n     *                   of error if an error is encountered\n     * @param status    Output param set to success/failure code on\n     *                  exit. If the pattern is invalid, this will be\n     *                  set to a failure result.\n     * @stable ICU 2.0\n     */\n    virtual void applyLocalizedPattern(const UnicodeString& pattern,\n                                       UParseError& parseError,\n                                       UErrorCode& status);\n\n    /**\n     * Apply the given pattern to this Format object.\n     *\n     * @param pattern   The localized pattern to be applied.\n     * @param status    Output param set to success/failure code on\n     *                  exit. If the pattern is invalid, this will be\n     *                  set to a failure result.\n     * @stable ICU 2.0\n     */\n    virtual void applyLocalizedPattern(const UnicodeString& pattern,\n                                       UErrorCode& status);\n\n\n    /**\n     * Sets the maximum number of digits allowed in the integer portion of a\n     * number. This override limits the integer digit count to 309.\n     *\n     * @param newValue    the new value of the maximum number of digits\n     *                      allowed in the integer portion of a number.\n     * @see NumberFormat#setMaximumIntegerDigits\n     * @stable ICU 2.0\n     */\n    virtual void setMaximumIntegerDigits(int32_t newValue);\n\n    /**\n     * Sets the minimum number of digits allowed in the integer portion of a\n     * number. This override limits the integer digit count to 309.\n     *\n     * @param newValue    the new value of the minimum number of digits\n     *                      allowed in the integer portion of a number.\n     * @see NumberFormat#setMinimumIntegerDigits\n     * @stable ICU 2.0\n     */\n    virtual void setMinimumIntegerDigits(int32_t newValue);\n\n    /**\n     * Sets the maximum number of digits allowed in the fraction portion of a\n     * number. This override limits the fraction digit count to 340.\n     *\n     * @param newValue    the new value of the maximum number of digits\n     *                    allowed in the fraction portion of a number.\n     * @see NumberFormat#setMaximumFractionDigits\n     * @stable ICU 2.0\n     */\n    virtual void setMaximumFractionDigits(int32_t newValue);\n\n    /**\n     * Sets the minimum number of digits allowed in the fraction portion of a\n     * number. This override limits the fraction digit count to 340.\n     *\n     * @param newValue    the new value of the minimum number of digits\n     *                    allowed in the fraction portion of a number.\n     * @see NumberFormat#setMinimumFractionDigits\n     * @stable ICU 2.0\n     */\n    virtual void setMinimumFractionDigits(int32_t newValue);\n\n    /**\n     * Returns the minimum number of significant digits that will be\n     * displayed. This value has no effect unless areSignificantDigitsUsed()\n     * returns true.\n     * @return the fewest significant digits that will be shown\n     * @stable ICU 3.0\n     */\n    int32_t getMinimumSignificantDigits() const;\n\n    /**\n     * Returns the maximum number of significant digits that will be\n     * displayed. This value has no effect unless areSignificantDigitsUsed()\n     * returns true.\n     * @return the most significant digits that will be shown\n     * @stable ICU 3.0\n     */\n    int32_t getMaximumSignificantDigits() const;\n\n    /**\n     * Sets the minimum number of significant digits that will be\n     * displayed.  If <code>min</code> is less than one then it is set\n     * to one.  If the maximum significant digits count is less than\n     * <code>min</code>, then it is set to <code>min</code>. This\n     * value has no effect unless areSignificantDigits() returns true.\n     * @param min the fewest significant digits to be shown\n     * @stable ICU 3.0\n     */\n    void setMinimumSignificantDigits(int32_t min);\n\n    /**\n     * Sets the maximum number of significant digits that will be\n     * displayed.  If <code>max</code> is less than one then it is set\n     * to one.  If the minimum significant digits count is greater\n     * than <code>max</code>, then it is set to <code>max</code>.\n     * This value has no effect unless areSignificantDigits() returns\n     * true.\n     * @param max the most significant digits to be shown\n     * @stable ICU 3.0\n     */\n    void setMaximumSignificantDigits(int32_t max);\n\n    /**\n     * Returns true if significant digits are in use, or false if\n     * integer and fraction digit counts are in use.\n     * @return true if significant digits are in use\n     * @stable ICU 3.0\n     */\n    UBool areSignificantDigitsUsed() const;\n\n    /**\n     * Sets whether significant digits are in use, or integer and\n     * fraction digit counts are in use.\n     * @param useSignificantDigits true to use significant digits, or\n     * false to use integer and fraction digit counts\n     * @stable ICU 3.0\n     */\n    void setSignificantDigitsUsed(UBool useSignificantDigits);\n\n public:\n    /**\n     * Sets the currency used to display currency\n     * amounts.  This takes effect immediately, if this format is a\n     * currency format.  If this format is not a currency format, then\n     * the currency is used if and when this object becomes a\n     * currency format through the application of a new pattern.\n     * @param theCurrency a 3-letter ISO code indicating new currency\n     * to use.  It need not be null-terminated.  May be the empty\n     * string or NULL to indicate no currency.\n     * @param ec input-output error code\n     * @stable ICU 3.0\n     */\n    virtual void setCurrency(const UChar* theCurrency, UErrorCode& ec);\n\n    /**\n     * Sets the currency used to display currency amounts.  See\n     * setCurrency(const UChar*, UErrorCode&).\n     * @deprecated ICU 3.0. Use setCurrency(const UChar*, UErrorCode&).\n     */\n    virtual void setCurrency(const UChar* theCurrency);\n\n    /**\n     * The resource tags we use to retrieve decimal format data from\n     * locale resource bundles.\n     * @deprecated ICU 3.4. This string has no public purpose. Please don't use it.\n     */\n    static const char fgNumberPatterns[];\n\npublic:\n\n    /**\n     * Return the class ID for this class.  This is useful only for\n     * comparing to a return value from getDynamicClassID().  For example:\n     * <pre>\n     * .      Base* polymorphic_pointer = createPolymorphicObject();\n     * .      if (polymorphic_pointer->getDynamicClassID() ==\n     * .          Derived::getStaticClassID()) ...\n     * </pre>\n     * @return          The class ID for all objects of this class.\n     * @stable ICU 2.0\n     */\n    static UClassID U_EXPORT2 getStaticClassID(void);\n\n    /**\n     * Returns a unique class ID POLYMORPHICALLY.  Pure virtual override.\n     * This method is to implement a simple version of RTTI, since not all\n     * C++ compilers support genuine RTTI.  Polymorphic operator==() and\n     * clone() methods call this method.\n     *\n     * @return          The class ID for this object. All objects of a\n     *                  given class have the same class ID.  Objects of\n     *                  other classes have different class IDs.\n     * @stable ICU 2.0\n     */\n    virtual UClassID getDynamicClassID(void) const;\n\nprivate:\n\n    DecimalFormat(); // default constructor not implemented\n\n    int32_t precision() const;\n\n    /**\n     *   Initialize all fields of a new DecimalFormatter.\n     *      Common code for use by constructors.\n     */\n    void init(UErrorCode& status);\n\n    /**\n     * Do real work of constructing a new DecimalFormat.\n     */\n    void construct(UErrorCode&               status,\n                   UParseError&             parseErr,\n                   const UnicodeString*     pattern = 0,\n                   DecimalFormatSymbols*    symbolsToAdopt = 0\n                   );\n\n    /**\n     * Does the real work of generating a pattern.\n     *\n     * @param result     Output param which will receive the pattern.\n     *                   Previous contents are deleted.\n     * @param localized  TRUE return localized pattern.\n     * @return           A reference to 'result'.\n     */\n    UnicodeString& toPattern(UnicodeString& result, UBool localized) const;\n\n    /**\n     * Does the real work of applying a pattern.\n     * @param pattern    The pattern to be applied.\n     * @param localized  If true, the pattern is localized; else false.\n     * @param parseError Struct to recieve information on position\n     *                   of error if an error is encountered\n     * @param status     Output param set to success/failure code on\n     *                   exit. If the pattern is invalid, this will be\n     *                   set to a failure result.\n     */\n    void applyPattern(const UnicodeString& pattern,\n                            UBool localized,\n                            UParseError& parseError,\n                            UErrorCode& status);\n\n    /*\n     * similar to applyPattern, but without re-gen affix for currency\n     */\n    void applyPatternInternally(const UnicodeString& pluralCount,\n                                const UnicodeString& pattern,\n                                UBool localized,\n                                UParseError& parseError,\n                                UErrorCode& status);\n\n    /*\n     * only apply pattern without expand affixes\n     */\n    void applyPatternWithoutExpandAffix(const UnicodeString& pattern,\n                                        UBool localized,\n                                        UParseError& parseError,\n                                        UErrorCode& status);\n\n\n    /*\n     * expand affixes (after apply patter) and re-compute fFormatWidth\n     */\n    void expandAffixAdjustWidth(const UnicodeString* pluralCount);\n\n\n    /**\n     * Do the work of formatting a number, either a double or a long.\n     *\n     * @param appendTo       Output parameter to receive result.\n     *                       Result is appended to existing contents.\n     * @param handler        Records information about field positions.\n     * @param digits         the digits to be formatted.\n     * @param isInteger      if TRUE format the digits as Integer.\n     * @return               Reference to 'appendTo' parameter.\n     */\n    UnicodeString& subformat(UnicodeString& appendTo,\n                             FieldPositionHandler& handler,\n                             DigitList&     digits,\n                             UBool          isInteger, \n                             UErrorCode &status) const;\n\n\n    void parse(const UnicodeString& text,\n               Formattable& result,\n               ParsePosition& pos,\n               UChar* currency) const;\n\n    enum {\n        fgStatusInfinite,\n        fgStatusLength      // Leave last in list.\n    } StatusFlags;\n\n    UBool subparse(const UnicodeString& text,\n                   const UnicodeString* negPrefix,\n                   const UnicodeString* negSuffix,\n                   const UnicodeString* posPrefix,\n                   const UnicodeString* posSuffix,\n                   UBool currencyParsing,\n                   int8_t type,\n                   ParsePosition& parsePosition,\n                   DigitList& digits, UBool* status,\n                   UChar* currency) const;\n\n    // Mixed style parsing for currency.\n    // It parses against the current currency pattern\n    // using complex affix comparison\n    // parses against the currency plural patterns using complex affix comparison,\n    // and parses against the current pattern using simple affix comparison.\n    UBool parseForCurrency(const UnicodeString& text,\n                           ParsePosition& parsePosition,\n                           DigitList& digits,\n                           UBool* status,\n                           UChar* currency) const;\n\n    int32_t skipPadding(const UnicodeString& text, int32_t position) const;\n\n    int32_t compareAffix(const UnicodeString& input,\n                         int32_t pos,\n                         UBool isNegative,\n                         UBool isPrefix,\n                         const UnicodeString* affixPat,\n                         UBool currencyParsing,\n                         int8_t type,\n                         UChar* currency) const;\n\n    static int32_t compareSimpleAffix(const UnicodeString& affix,\n                                      const UnicodeString& input,\n                                      int32_t pos,\n                                      UBool lenient);\n\n    static int32_t skipPatternWhiteSpace(const UnicodeString& text, int32_t pos);\n\n    static int32_t skipUWhiteSpace(const UnicodeString& text, int32_t pos);\n\n    int32_t compareComplexAffix(const UnicodeString& affixPat,\n                                const UnicodeString& input,\n                                int32_t pos,\n                                int8_t type,\n                                UChar* currency) const;\n\n    static int32_t match(const UnicodeString& text, int32_t pos, UChar32 ch);\n\n    static int32_t match(const UnicodeString& text, int32_t pos, const UnicodeString& str);\n\n    static UBool matchSymbol(const UnicodeString &text, int32_t position, int32_t length, const UnicodeString &symbol,\n                             UnicodeSet *sset, UChar32 schar);\n\n    static UBool matchDecimal(UChar32 symbolChar,\n                            UBool sawDecimal,  UChar32 sawDecimalChar,\n                             const UnicodeSet *sset, UChar32 schar);\n\n    static UBool matchGrouping(UChar32 groupingChar,\n                            UBool sawGrouping, UChar32 sawGroupingChar,\n                             const UnicodeSet *sset,\n                             UChar32 decimalChar, const UnicodeSet *decimalSet,\n                             UChar32 schar);\n\n    /**\n     * Get a decimal format symbol.\n     * Returns a const reference to the symbol string.\n     * @internal\n     */\n    inline const UnicodeString &getConstSymbol(DecimalFormatSymbols::ENumberFormatSymbol symbol) const;\n\n    int32_t appendAffix(UnicodeString& buf,\n                        double number,\n                        FieldPositionHandler& handler,\n                        UBool isNegative,\n                        UBool isPrefix) const;\n\n    /**\n     * Append an affix to the given UnicodeString, using quotes if\n     * there are special characters.  Single quotes themselves must be\n     * escaped in either case.\n     */\n    void appendAffixPattern(UnicodeString& appendTo, const UnicodeString& affix,\n                            UBool localized) const;\n\n    void appendAffixPattern(UnicodeString& appendTo,\n                            const UnicodeString* affixPattern,\n                            const UnicodeString& expAffix, UBool localized) const;\n\n    void expandAffix(const UnicodeString& pattern,\n                     UnicodeString& affix,\n                     double number,\n                     FieldPositionHandler& handler,\n                     UBool doFormat,\n                     const UnicodeString* pluralCount) const;\n\n    void expandAffixes(const UnicodeString* pluralCount);\n\n    void addPadding(UnicodeString& appendTo,\n                    FieldPositionHandler& handler,\n                    int32_t prefixLen, int32_t suffixLen) const;\n\n    UBool isGroupingPosition(int32_t pos) const;\n\n    void setCurrencyForSymbols();\n\n    // similar to setCurrency without re-compute the affixes for currency.\n    // If currency changes, the affix pattern for currency is not changed,\n    // but the affix will be changed. So, affixes need to be\n    // re-computed in setCurrency(), but not in setCurrencyInternally().\n    virtual void setCurrencyInternally(const UChar* theCurrency, UErrorCode& ec);\n\n    // set up currency affix patterns for mix parsing.\n    // The patterns saved here are the affix patterns of default currency\n    // pattern and the unique affix patterns of the plural currency patterns.\n    // Those patterns are used by parseForCurrency().\n    void setupCurrencyAffixPatterns(UErrorCode& status);\n\n    // set up the currency affixes used in currency plural formatting.\n    // It sets up both fAffixesForCurrency for currency pattern if the current\n    // pattern contains 3 currency signs,\n    // and it sets up fPluralAffixesForCurrency for currency plural patterns.\n    void setupCurrencyAffixes(const UnicodeString& pattern,\n                              UBool setupForCurrentPattern,\n                              UBool setupForPluralPattern,\n                              UErrorCode& status);\n\n    // hashtable operations\n    Hashtable* initHashForAffixPattern(UErrorCode& status);\n    Hashtable* initHashForAffix(UErrorCode& status);\n\n    void deleteHashForAffixPattern();\n    void deleteHashForAffix(Hashtable*& table);\n\n    void copyHashForAffixPattern(const Hashtable* source,\n                                 Hashtable* target, UErrorCode& status);\n    void copyHashForAffix(const Hashtable* source,\n                          Hashtable* target, UErrorCode& status);\n\n    UnicodeString& _format(int64_t number,\n                           UnicodeString& appendTo,\n                           FieldPositionHandler& handler,\n                           UErrorCode &status) const;\n    UnicodeString& _format(double number,\n                           UnicodeString& appendTo,\n                           FieldPositionHandler& handler,\n                           UErrorCode &status) const;\n    UnicodeString& _format(const DigitList &number,\n                           UnicodeString& appendTo,\n                           FieldPositionHandler& handler,\n                           UErrorCode &status) const;\n\n    // currency sign count\n    enum {\n        fgCurrencySignCountZero,\n        fgCurrencySignCountInSymbolFormat,\n        fgCurrencySignCountInISOFormat,\n        fgCurrencySignCountInPluralFormat\n    } CurrencySignCount;\n\n    /**\n     * Constants.\n     */\n\n    UnicodeString           fPositivePrefix;\n    UnicodeString           fPositiveSuffix;\n    UnicodeString           fNegativePrefix;\n    UnicodeString           fNegativeSuffix;\n    UnicodeString*          fPosPrefixPattern;\n    UnicodeString*          fPosSuffixPattern;\n    UnicodeString*          fNegPrefixPattern;\n    UnicodeString*          fNegSuffixPattern;\n\n    /**\n     * Formatter for ChoiceFormat-based currency names.  If this field\n     * is not null, then delegate to it to format currency symbols.\n     * @since ICU 2.6\n     */\n    ChoiceFormat*           fCurrencyChoice;\n\n    DigitList *             fMultiplier;   // NULL for multiplier of one\n    int32_t                 fGroupingSize;\n    int32_t                 fGroupingSize2;\n    UBool                   fDecimalSeparatorAlwaysShown;\n    DecimalFormatSymbols*   fSymbols;\n\n    UBool                   fUseSignificantDigits;\n    int32_t                 fMinSignificantDigits;\n    int32_t                 fMaxSignificantDigits;\n\n    UBool                   fUseExponentialNotation;\n    int8_t                  fMinExponentDigits;\n    UBool                   fExponentSignAlwaysShown;\n\n    EnumSet<UNumberFormatAttribute,\n            UNUM_MAX_NONBOOLEAN_ATTRIBUTE+1, \n            UNUM_LIMIT_BOOLEAN_ATTRIBUTE>  \n                            fBoolFlags;\n\n    DigitList*              fRoundingIncrement;  // NULL if no rounding increment specified.\n    ERoundingMode           fRoundingMode;\n\n    UChar32                 fPad;\n    int32_t                 fFormatWidth;\n    EPadPosition            fPadPosition;\n\n    /*\n     * Following are used for currency format\n     */\n    // pattern used in this formatter\n    UnicodeString fFormatPattern;\n    // style is only valid when decimal formatter is constructed by\n    // DecimalFormat(pattern, decimalFormatSymbol, style)\n    int fStyle;\n    /*\n     * Represents whether this is a currency format, and which\n     * currency format style.\n     * 0: not currency format type;\n     * 1: currency style -- symbol name, such as \"$\" for US dollar.\n     * 2: currency style -- ISO name, such as USD for US dollar.\n     * 3: currency style -- plural long name, such as \"US Dollar\" for\n     *                      \"1.00 US Dollar\", or \"US Dollars\" for\n     *                      \"3.00 US Dollars\".\n     */\n    int fCurrencySignCount;\n\n\n    /* For currency parsing purose,\n     * Need to remember all prefix patterns and suffix patterns of\n     * every currency format pattern,\n     * including the pattern of default currecny style\n     * and plural currency style. And the patterns are set through applyPattern.\n     */\n    // TODO: innerclass?\n    /* This is not needed in the class declaration, so it is moved into decimfmp.cpp\n    struct AffixPatternsForCurrency : public UMemory {\n        // negative prefix pattern\n        UnicodeString negPrefixPatternForCurrency;\n        // negative suffix pattern\n        UnicodeString negSuffixPatternForCurrency;\n        // positive prefix pattern\n        UnicodeString posPrefixPatternForCurrency;\n        // positive suffix pattern\n        UnicodeString posSuffixPatternForCurrency;\n        int8_t patternType;\n\n        AffixPatternsForCurrency(const UnicodeString& negPrefix,\n                                 const UnicodeString& negSuffix,\n                                 const UnicodeString& posPrefix,\n                                 const UnicodeString& posSuffix,\n                                 int8_t type) {\n            negPrefixPatternForCurrency = negPrefix;\n            negSuffixPatternForCurrency = negSuffix;\n            posPrefixPatternForCurrency = posPrefix;\n            posSuffixPatternForCurrency = posSuffix;\n            patternType = type;\n        }\n    };\n    */\n\n    /* affix for currency formatting when the currency sign in the pattern\n     * equals to 3, such as the pattern contains 3 currency sign or\n     * the formatter style is currency plural format style.\n     */\n    /* This is not needed in the class declaration, so it is moved into decimfmp.cpp\n    struct AffixesForCurrency : public UMemory {\n        // negative prefix\n        UnicodeString negPrefixForCurrency;\n        // negative suffix\n        UnicodeString negSuffixForCurrency;\n        // positive prefix\n        UnicodeString posPrefixForCurrency;\n        // positive suffix\n        UnicodeString posSuffixForCurrency;\n\n        int32_t formatWidth;\n\n        AffixesForCurrency(const UnicodeString& negPrefix,\n                           const UnicodeString& negSuffix,\n                           const UnicodeString& posPrefix,\n                           const UnicodeString& posSuffix) {\n            negPrefixForCurrency = negPrefix;\n            negSuffixForCurrency = negSuffix;\n            posPrefixForCurrency = posPrefix;\n            posSuffixForCurrency = posSuffix;\n        }\n    };\n    */\n\n    // Affix pattern set for currency.\n    // It is a set of AffixPatternsForCurrency,\n    // each element of the set saves the negative prefix pattern,\n    // negative suffix pattern, positive prefix pattern,\n    // and positive suffix  pattern of a pattern.\n    // It is used for currency mixed style parsing.\n    // It is actually is a set.\n    // The set contains the default currency pattern from the locale,\n    // and the currency plural patterns.\n    // Since it is a set, it does not contain duplicated items.\n    // For example, if 2 currency plural patterns are the same, only one pattern\n    // is included in the set. When parsing, we do not check whether the plural\n    // count match or not.\n    Hashtable* fAffixPatternsForCurrency;\n\n    // Following 2 are affixes for currency.\n    // It is a hash map from plural count to AffixesForCurrency.\n    // AffixesForCurrency saves the negative prefix,\n    // negative suffix, positive prefix, and positive suffix of a pattern.\n    // It is used during currency formatting only when the currency sign count\n    // is 3. In which case, the affixes are getting from here, not\n    // from the fNegativePrefix etc.\n    Hashtable* fAffixesForCurrency;  // for current pattern\n    Hashtable* fPluralAffixesForCurrency;  // for plural pattern\n\n    // Information needed for DecimalFormat to format/parse currency plural.\n    CurrencyPluralInfo* fCurrencyPluralInfo;\n\n#if UCONFIG_HAVE_PARSEALLINPUT\n    UNumberFormatAttributeValue fParseAllInput;\n#endif\n\n\nprotected:\n\n    /**\n     * Returns the currency in effect for this formatter.  Subclasses\n     * should override this method as needed.  Unlike getCurrency(),\n     * this method should never return \"\".\n     * @result output parameter for null-terminated result, which must\n     * have a capacity of at least 4\n     * @internal\n     */\n    virtual void getEffectiveCurrency(UChar* result, UErrorCode& ec) const;\n\n  /** number of integer digits\n   * @stable ICU 2.4\n   */\n    static const int32_t  kDoubleIntegerDigits;\n  /** number of fraction digits\n   * @stable ICU 2.4\n   */\n    static const int32_t  kDoubleFractionDigits;\n\n    /**\n     * When someone turns on scientific mode, we assume that more than this\n     * number of digits is due to flipping from some other mode that didn't\n     * restrict the maximum, and so we force 1 integer digit.  We don't bother\n     * to track and see if someone is using exponential notation with more than\n     * this number, it wouldn't make sense anyway, and this is just to make sure\n     * that someone turning on scientific mode with default settings doesn't\n     * end up with lots of zeroes.\n     * @stable ICU 2.8\n     */\n    static const int32_t  kMaxScientificIntegerDigits;\n\n#if UCONFIG_FORMAT_FASTPATHS_49\n private:\n    /**\n     * Internal state. \n     * @internal\n     */\n    uint8_t fReserved[UNUM_DECIMALFORMAT_INTERNAL_SIZE];\n\n\n    /**\n     * Called whenever any state changes. Recomputes whether fastpath is OK to use.\n     */\n    void handleChanged();\n#endif\n};\n\ninline UnicodeString&\nDecimalFormat::format(const Formattable& obj,\n                      UnicodeString& appendTo,\n                      UErrorCode& status) const {\n    // Don't use Format:: - use immediate base class only,\n    // in case immediate base modifies behavior later.\n    return NumberFormat::format(obj, appendTo, status);\n}\n\ninline UnicodeString&\nDecimalFormat::format(double number,\n                      UnicodeString& appendTo) const {\n    FieldPosition pos(0);\n    return format(number, appendTo, pos);\n}\n\ninline UnicodeString&\nDecimalFormat::format(int32_t number,\n                      UnicodeString& appendTo) const {\n    FieldPosition pos(0);\n    return format((int64_t)number, appendTo, pos);\n}\n\n#ifndef U_HIDE_INTERNAL_API\ninline const UnicodeString &\nDecimalFormat::getConstSymbol(DecimalFormatSymbols::ENumberFormatSymbol symbol) const {\n    return fSymbols->getConstSymbol(symbol);\n}\n\n#endif\n\nU_NAMESPACE_END\n\n#endif /* #if !UCONFIG_NO_FORMATTING */\n\n#endif // _DECIMFMT\n//eof\n"
  },
  {
    "path": "deprecated/android/addons/icucompat/unicode/docmain.h",
    "content": "/********************************************************************\n * COPYRIGHT: \n * Copyright (c) 1997-2012, International Business Machines Corporation and\n * others. All Rights Reserved.\n *\n *  FILE NAME: DOCMAIN.h\n *\n *   Date          Name        Description\n *   12/11/2000    Ram        Creation.\n */\n\n/**\n * \\file\n * \\brief (Non API- contains Doxygen definitions)\n *\n * This file contains documentation for Doxygen and doesnot have\n * any significance with respect to C or C++ API\n */\n\n/*! \\mainpage\n *\n * \\section API API Reference Usage\n * \n * <h3>C++ Programmers:</h3>\n * <p>Use <a href=\"hierarchy.html\">Class Hierarchy</a> or <a href=\"classes.html\"> Alphabetical List </a>\n * or <a href=\"annotated.html\"> Compound List</a>\n * to find the class you are interested in. For example, to find BreakIterator,\n * you can go to the <a href=\"classes.html\"> Alphabetical List</a>, then click on\n * \"BreakIterator\". Once you are at the class, you will find an inheritance\n * chart, a list of the public members, a detailed description of the class,\n * then detailed member descriptions.</p>\n * \n * <h3>C Programmers:</h3>\n * <p>Use <a href=\"#Module\">Module List</a> or <a href=\"globals.html\">File Members</a>\n * to find a list of all the functions and constants.\n * For example, to find BreakIterator functions you would click on\n * <a href=\"files.html\"> File List</a>,\n * then find \"ubrk.h\" and click on it. You will find descriptions of Defines,\n * Typedefs, Enumerations, and Functions, with detailed descriptions below.\n * If you want to find a specific function, such as ubrk_next(), then click\n * first on <a href=\"globals.html\"> File Members</a>, then use your browser\n * Find dialog to search for \"ubrk_next()\".</p>\n *\n *\n * <h3>API References for Previous Releases</h3>\n * <p>The API References for each release of ICU are also available as\n * a zip file from the ICU \n * <a href=\"http://site.icu-project.org/download\">download page</a>.</p>\n *\n * <hr>\n *\n * <h2>Architecture (User's Guide)</h2>\n * <ul>\n *   <li><a href=\"http://userguide.icu-project.org/\">Introduction</a></li>\n *   <li><a href=\"http://userguide.icu-project.org/i18n\">Internationalization</a></li>\n *   <li><a href=\"http://userguide.icu-project.org/design\">Locale Model, Multithreading, Error Handling, etc.</a></li>\n *   <li><a href=\"http://userguide.icu-project.org/conversion\">Conversion</a></li>\n * </ul>\n *\n * <hr>\n *\\htmlonly <h2><a NAME=\"Module\">Module List</a></h2> \\endhtmlonly\n * <table border=\"1\" cols=\"3\" align=\"center\">\n *   <tr>\n *     <td><strong>Module Name</strong></td>\n *     <td><strong>C</strong></td>\n *     <td><strong>C++</strong></td>\n *   </tr>\n *   <tr>\n *     <td>Basic Types and Constants</td>\n *     <td>utypes.h</td>\n *     <td>utypes.h</td>\n *   </tr>\n *   <tr>\n *     <td>Strings and Character Iteration</td>\n *     <td>ustring.h, utf8.h, utf16.h, UText, UCharIterator</td>\n *     <td>icu::UnicodeString, icu::CharacterIterator, icu::Appendable, icu::StringPiece,icu::ByteSink</td>\n *   </tr>\n *   <tr>\n *     <td>Unicode Character<br/>Properties and Names</td>\n *     <td>uchar.h, uscript.h</td>\n *     <td>C API</td>\n *   </tr>\n *   <tr>\n *     <td>Sets of Unicode Code Points and Strings</td>\n *     <td>uset.h</td>\n *     <td>icu::UnicodeSet</td>\n *   </tr>\n *   <tr>\n *     <td>Maps from Strings to Integer Values</td>\n *     <td>(no C API)</td>\n *     <td>icu::BytesTrie, icu::UCharsTrie</td>\n *   </tr>\n *   <tr>\n *     <td>Codepage Conversion</td>\n *     <td>ucnv.h, ucnvsel.hb</td>\n *     <td>C API</td>\n *   </tr>\n *   <tr>\n *     <td>Unicode Text Compression</td>\n *     <td>ucnv.h<br/>(encoding name \"SCSU\" or \"BOCU-1\")</td>\n *     <td>C API</td>\n *   </tr>\n *   <tr>\n *     <td>Locales </td>\n *     <td>uloc.h</a></td>\n *     <td>icu::Locale</td>\n *   </tr>\n *   <tr>\n *     <td>Resource Bundles</td>\n *     <td>ures.h</td>\n *     <td>icu::ResourceBundle</td>\n *   </tr>\n *   <tr>\n *     <td>Normalization</td>\n *     <td>unorm2.h</td>\n *     <td>icu::Normalizer2</td>\n *   </tr>\n *   <tr>\n *     <td>Calendars</td>\n *     <td>ucal.h</td>\n *     <td>icu::Calendar</td>\n *   </tr>\n *   <tr>\n *     <td>Date and Time Formatting</td>\n *     <td>udat.h</td>\n *     <td>icu::DateFormat</td>\n *   </tr>\n *   <tr>\n *     <td>Message Formatting</td>\n *     <td>umsg.h</td>\n *     <td>icu::MessageFormat</td>\n *   </tr>\n *   <tr>\n *     <td>Number Formatting</td>\n *     <td>unum.h</td>\n *     <td>icu::NumberFormat</td>\n *   </tr>\n *   <tr>\n *     <td>Number Spellout<br/>(Rule Based Number Formatting)</td>\n *     <td>unum.h<br/>(use UNUM_SPELLOUT)</td>\n *     <td>icu::RuleBasedNumberFormat</td>\n *   </tr>\n *   <tr>\n *     <td>Text Transformation<br/>(Transliteration)</td>\n *     <td>utrans.h</td>\n *     <td>icu::Transliterator</td>\n *   </tr>\n *   <tr>\n *     <td>Bidirectional Algorithm</td>\n *     <td>ubidi.h</td>\n *     <td>C API</td>\n *   </tr>\n *   <tr>\n *     <td>Arabic Shaping</td>\n *     <td>ushape.h</td>\n *     <td>C API</td>\n *   </tr>\n *   <tr>\n *     <td>Collation</td>\n *     <td>ucol.h</td>\n *     <td>icu::Collator</td>\n *   </tr>\n *   <tr>\n *     <td>String Searching</td>\n *     <td>usearch.h</td>\n *     <td>icu::StringSearch</td>\n *   </tr>\n *   <tr>\n *     <td>Index Characters/<br/>Bucketing for Sorted Lists</td>\n *     <td>(no C API)</td>\n *     <td>icu::AlphabeticIndex</td>\n *   </tr>\n *   <tr>\n *     <td>Text Boundary Analysis<br/>(Break Iteration)</td>\n *     <td>ubrk.h</td>\n *     <td>icu::BreakIterator</td>\n *   </tr>\n *   <tr>\n *     <td>Regular Expressions</td>\n *     <td>uregex.h</td>\n *     <td>icu::RegexPattern, icu::RegexMatcher</td>\n *   </tr>\n *   <tr>\n *     <td>StringPrep</td>\n *     <td>usprep.h</td>\n *     <td>C API</td>\n *   </tr>\n *   <tr>\n *     <td>International Domain Names in Applications:<br/>\n *         UTS #46 in C/C++, IDNA2003 only via C API</td>\n *     <td>uidna.h</td>\n *     <td>idna.h</td>\n *   </tr>\n *   <tr>\n *     <td>Identifier Spoofing & Confusability</td>\n *     <td>uspoof.h</td>\n *     <td>C API</td>\n *   <tr>\n *     <td>Universal Time Scale</td>\n *     <td>utmscale.h</td>\n *     <td>C API</td>\n *   </tr>\n *   <tr>\n *     <td>Layout Engine/Complex Text Layout</td>\n *     <td>loengine.h</td>\n *     <td>icu::LayoutEngine,icu::ParagraphLayout</td>\n *   </tr>\n *   <tr>\n *     <td>ICU I/O</td>\n *     <td>ustdio.h</td>\n *     <td>ustream.h</td>\n *   </tr>\n * </table>\n * <i>This main page is generated from docmain.h</i>\n */\n"
  },
  {
    "path": "deprecated/android/addons/icucompat/unicode/dtfmtsym.h",
    "content": "/*  \n********************************************************************************\n*   Copyright (C) 1997-2012, International Business Machines\n*   Corporation and others.  All Rights Reserved.\n********************************************************************************\n*\n* File DTFMTSYM.H\n*\n* Modification History:\n*\n*   Date        Name        Description\n*   02/19/97    aliu        Converted from java.\n*    07/21/98    stephen        Added getZoneIndex()\n*                            Changed to match C++ conventions\n********************************************************************************\n*/\n     \n#ifndef DTFMTSYM_H\n#define DTFMTSYM_H\n \n#include \"unicode/utypes.h\"\n\n#if !UCONFIG_NO_FORMATTING\n\n#include \"unicode/calendar.h\"\n#include \"unicode/uobject.h\"\n#include \"unicode/locid.h\"\n#include \"unicode/udat.h\"\n#include \"unicode/ures.h\"\n\n/**\n * \\file \n * \\brief C++ API: Symbols for formatting dates.\n */\n\nU_NAMESPACE_BEGIN\n\n/* forward declaration */\nclass SimpleDateFormat;\nclass Hashtable;\n\n/**\n * DateFormatSymbols is a public class for encapsulating localizable date-time\n * formatting data -- including timezone data. DateFormatSymbols is used by\n * DateFormat and SimpleDateFormat.\n * <P>\n * Rather than first creating a DateFormatSymbols to get a date-time formatter\n * by using a SimpleDateFormat constructor, clients are encouraged to create a\n * date-time formatter using the getTimeInstance(), getDateInstance(), or\n * getDateTimeInstance() method in DateFormat. Each of these methods can return a\n * date/time formatter initialized with a default format pattern along with the\n * date-time formatting data for a given or default locale. After a formatter is\n * created, clients may modify the format pattern using the setPattern function\n * as so desired. For more information on using these formatter factory\n * functions, see DateFormat.\n * <P>\n * If clients decide to create a date-time formatter with a particular format\n * pattern and locale, they can do so with new SimpleDateFormat(aPattern,\n * new DateFormatSymbols(aLocale)).  This will load the appropriate date-time\n * formatting data from the locale.\n * <P>\n * DateFormatSymbols objects are clonable. When clients obtain a\n * DateFormatSymbols object, they can feel free to modify the date-time\n * formatting data as necessary. For instance, clients can\n * replace the localized date-time format pattern characters with the ones that\n * they feel easy to remember. Or they can change the representative cities\n * originally picked by default to using their favorite ones.\n * <P>\n * DateFormatSymbols are not expected to be subclassed. Data for a calendar is\n * loaded out of resource bundles.  The 'type' parameter indicates the type of\n * calendar, for example, \"gregorian\" or \"japanese\".  If the type is not gregorian\n * (or NULL, or an empty string) then the type is appended to the resource name,\n * for example,  'Eras_japanese' instead of 'Eras'.   If the resource 'Eras_japanese' did\n * not exist (even in root), then this class will fall back to just 'Eras', that is,\n * Gregorian data.  Therefore, the calendar implementor MUST ensure that the root\n * locale at least contains any resources that are to be particularized for the\n * calendar type.\n */\nclass U_I18N_API DateFormatSymbols : public UObject {\npublic:\n    /**\n     * Construct a DateFormatSymbols object by loading format data from\n     * resources for the default locale, in the default calendar (Gregorian).\n     * <P>\n     * NOTE: This constructor will never fail; if it cannot get resource\n     * data for the default locale, it will return a last-resort object\n     * based on hard-coded strings.\n     *\n     * @param status    Status code.  Failure\n     *                  results if the resources for the default cannot be\n     *                  found or cannot be loaded\n     * @stable ICU 2.0\n     */\n    DateFormatSymbols(UErrorCode& status);\n\n    /**\n     * Construct a DateFormatSymbols object by loading format data from\n     * resources for the given locale, in the default calendar (Gregorian).\n     *\n     * @param locale    Locale to load format data from.\n     * @param status    Status code.  Failure\n     *                  results if the resources for the locale cannot be\n     *                  found or cannot be loaded\n     * @stable ICU 2.0\n     */\n    DateFormatSymbols(const Locale& locale,\n                      UErrorCode& status);\n\n#ifndef U_HIDE_INTERNAL_API\n    /**\n     * Construct a DateFormatSymbols object by loading format data from\n     * resources for the default locale, in the default calendar (Gregorian).\n     * <P>\n     * NOTE: This constructor will never fail; if it cannot get resource\n     * data for the default locale, it will return a last-resort object\n     * based on hard-coded strings.\n     *\n     * @param type      Type of calendar (as returned by Calendar::getType). \n     *                  Will be used to access the correct set of strings.\n     *                  (NULL or empty string defaults to \"gregorian\".)\n     * @param status    Status code.  Failure\n     *                  results if the resources for the default cannot be\n     *                  found or cannot be loaded\n     * @internal\n     */\n    DateFormatSymbols(const char *type, UErrorCode& status);\n\n    /**\n     * Construct a DateFormatSymbols object by loading format data from\n     * resources for the given locale, in the default calendar (Gregorian).\n     *\n     * @param locale    Locale to load format data from.\n     * @param type      Type of calendar (as returned by Calendar::getType). \n     *                  Will be used to access the correct set of strings.\n     *                  (NULL or empty string defaults to \"gregorian\".)\n     * @param status    Status code.  Failure\n     *                  results if the resources for the locale cannot be\n     *                  found or cannot be loaded\n     * @internal\n     */\n    DateFormatSymbols(const Locale& locale,\n                      const char *type,\n                      UErrorCode& status);\n#endif  /* U_HIDE_INTERNAL_API */\n\n    /**\n     * Copy constructor.\n     * @stable ICU 2.0\n     */\n    DateFormatSymbols(const DateFormatSymbols&);\n\n    /**\n     * Assignment operator.\n     * @stable ICU 2.0\n     */\n    DateFormatSymbols& operator=(const DateFormatSymbols&);\n\n    /**\n     * Destructor. This is nonvirtual because this class is not designed to be\n     * subclassed.\n     * @stable ICU 2.0\n     */\n    virtual ~DateFormatSymbols();\n\n    /**\n     * Return true if another object is semantically equal to this one.\n     *\n     * @param other    the DateFormatSymbols object to be compared with.\n     * @return         true if other is semantically equal to this.\n     * @stable ICU 2.0\n     */\n    UBool operator==(const DateFormatSymbols& other) const;\n\n    /**\n     * Return true if another object is semantically unequal to this one.\n     *\n     * @param other    the DateFormatSymbols object to be compared with.\n     * @return         true if other is semantically unequal to this.\n     * @stable ICU 2.0\n     */\n    UBool operator!=(const DateFormatSymbols& other) const { return !operator==(other); }\n\n    /**\n     * Gets abbreviated era strings. For example: \"AD\" and \"BC\".\n     *\n     * @param count    Filled in with length of the array.\n     * @return         the era strings.\n     * @stable ICU 2.0\n     */\n    const UnicodeString* getEras(int32_t& count) const;\n\n    /**\n     * Sets abbreviated era strings. For example: \"AD\" and \"BC\".\n     * @param eras  Array of era strings (DateFormatSymbols retains ownership.)\n     * @param count Filled in with length of the array.\n     * @stable ICU 2.0\n     */\n    void setEras(const UnicodeString* eras, int32_t count);\n\n    /**\n     * Gets era name strings. For example: \"Anno Domini\" and \"Before Christ\".\n     *\n     * @param count    Filled in with length of the array.\n     * @return         the era name strings.\n     * @stable ICU 3.4\n     */\n    const UnicodeString* getEraNames(int32_t& count) const;\n\n    /**\n     * Sets era name strings. For example: \"Anno Domini\" and \"Before Christ\".\n     * @param eraNames  Array of era name strings (DateFormatSymbols retains ownership.)\n     * @param count Filled in with length of the array.\n     * @stable ICU 3.6\n     */\n    void setEraNames(const UnicodeString* eraNames, int32_t count);\n\n    /**\n     * Gets narrow era strings. For example: \"A\" and \"B\".\n     *\n     * @param count    Filled in with length of the array.\n     * @return         the narrow era strings.\n     * @stable ICU 4.2\n     */\n    const UnicodeString* getNarrowEras(int32_t& count) const;\n\n    /**\n     * Sets narrow era strings. For example: \"A\" and \"B\".\n     * @param narrowEras  Array of narrow era strings (DateFormatSymbols retains ownership.)\n     * @param count Filled in with length of the array.\n     * @stable ICU 4.2\n     */\n    void setNarrowEras(const UnicodeString* narrowEras, int32_t count);\n\n    /**\n     * Gets month strings. For example: \"January\", \"February\", etc.\n     * @param count Filled in with length of the array.\n     * @return the month strings. (DateFormatSymbols retains ownership.)\n     * @stable ICU 2.0\n     */\n    const UnicodeString* getMonths(int32_t& count) const;\n\n    /**\n     * Sets month strings. For example: \"January\", \"February\", etc.\n     *\n     * @param months    the new month strings. (not adopted; caller retains ownership)\n     * @param count     Filled in with length of the array.\n     * @stable ICU 2.0\n     */\n    void setMonths(const UnicodeString* months, int32_t count);\n\n    /**\n     * Gets short month strings. For example: \"Jan\", \"Feb\", etc.\n     *\n     * @param count Filled in with length of the array.\n     * @return the short month strings. (DateFormatSymbols retains ownership.)\n     * @stable ICU 2.0\n     */\n    const UnicodeString* getShortMonths(int32_t& count) const;\n\n    /**\n     * Sets short month strings. For example: \"Jan\", \"Feb\", etc.\n     * @param count        Filled in with length of the array.\n     * @param shortMonths  the new short month strings. (not adopted; caller retains ownership)\n     * @stable ICU 2.0\n     */\n    void setShortMonths(const UnicodeString* shortMonths, int32_t count);\n\n    /**\n     * Selector for date formatting context\n     * @stable ICU 3.6\n     */\n    enum DtContextType {\n         FORMAT,\n         STANDALONE,\n         DT_CONTEXT_COUNT\n    };\n\n    /**\n     * Selector for date formatting width\n     * @stable ICU 3.6\n     */\n    enum DtWidthType {\n         ABBREVIATED,\n         WIDE,\n         NARROW,\n         DT_WIDTH_COUNT\n    };\n\n    /**\n     * Gets month strings by width and context. For example: \"January\", \"February\", etc.\n     * @param count Filled in with length of the array.\n     * @param context The formatting context, either FORMAT or STANDALONE\n     * @param width   The width of returned strings, either WIDE, ABBREVIATED, or NARROW.\n     * @return the month strings. (DateFormatSymbols retains ownership.)\n     * @stable ICU 3.4\n     */\n    const UnicodeString* getMonths(int32_t& count, DtContextType context, DtWidthType width) const;\n\n    /**\n     * Sets month strings by width and context. For example: \"January\", \"February\", etc.\n     *\n     * @param months  The new month strings. (not adopted; caller retains ownership)\n     * @param count   Filled in with length of the array.\n     * @param context The formatting context, either FORMAT or STANDALONE\n     * @param width   The width of returned strings, either WIDE, ABBREVIATED, or NARROW.\n     * @stable ICU 3.6\n     */\n    void setMonths(const UnicodeString* months, int32_t count, DtContextType context, DtWidthType width);\n\n    /**\n     * Gets weekday strings. For example: \"Sunday\", \"Monday\", etc.\n     * @param count        Filled in with length of the array.\n     * @return the weekday strings. (DateFormatSymbols retains ownership.)\n     * @stable ICU 2.0\n     */\n    const UnicodeString* getWeekdays(int32_t& count) const;\n\n\n    /**\n     * Sets weekday strings. For example: \"Sunday\", \"Monday\", etc.\n     * @param weekdays     the new weekday strings. (not adopted; caller retains ownership)\n     * @param count        Filled in with length of the array.\n     * @stable ICU 2.0\n     */\n    void setWeekdays(const UnicodeString* weekdays, int32_t count);\n\n    /**\n     * Gets short weekday strings. For example: \"Sun\", \"Mon\", etc.\n     * @param count        Filled in with length of the array.\n     * @return             the short weekday strings. (DateFormatSymbols retains ownership.)\n     * @stable ICU 2.0\n     */\n    const UnicodeString* getShortWeekdays(int32_t& count) const;\n\n    /**\n     * Sets short weekday strings. For example: \"Sun\", \"Mon\", etc.\n     * @param shortWeekdays  the new short weekday strings. (not adopted; caller retains ownership)\n     * @param count          Filled in with length of the array.\n     * @stable ICU 2.0\n     */\n    void setShortWeekdays(const UnicodeString* shortWeekdays, int32_t count);\n\n    /**\n     * Gets weekday strings by width and context. For example: \"Sunday\", \"Monday\", etc.\n     * @param count   Filled in with length of the array.\n     * @param context The formatting context, either FORMAT or STANDALONE\n     * @param width   The width of returned strings, either WIDE, ABBREVIATED, or NARROW\n     * @return the month strings. (DateFormatSymbols retains ownership.)\n     * @stable ICU 3.4\n     */\n    const UnicodeString* getWeekdays(int32_t& count, DtContextType context, DtWidthType width) const;\n\n    /**\n     * Sets weekday strings by width and context. For example: \"Sunday\", \"Monday\", etc.\n     * @param weekdays  The new weekday strings. (not adopted; caller retains ownership)\n     * @param count     Filled in with length of the array.\n     * @param context   The formatting context, either FORMAT or STANDALONE\n     * @param width     The width of returned strings, either WIDE, ABBREVIATED, or NARROW\n     * @stable ICU 3.6\n     */\n    void setWeekdays(const UnicodeString* weekdays, int32_t count, DtContextType context, DtWidthType width);\n\n    /**\n     * Gets quarter strings by width and context. For example: \"1st Quarter\", \"2nd Quarter\", etc.\n     * @param count Filled in with length of the array.\n     * @param context The formatting context, either FORMAT or STANDALONE\n     * @param width   The width of returned strings, either WIDE or ABBREVIATED. There\n     *                are no NARROW quarters.\n     * @return the quarter strings. (DateFormatSymbols retains ownership.)\n     * @stable ICU 3.6\n     */\n    const UnicodeString* getQuarters(int32_t& count, DtContextType context, DtWidthType width) const;\n\n    /**\n     * Sets quarter strings by width and context. For example: \"1st Quarter\", \"2nd Quarter\", etc.\n     *\n     * @param quarters  The new quarter strings. (not adopted; caller retains ownership)\n     * @param count   Filled in with length of the array.\n     * @param context The formatting context, either FORMAT or STANDALONE\n     * @param width   The width of returned strings, either WIDE or ABBREVIATED. There\n     *                are no NARROW quarters.\n     * @stable ICU 3.6\n     */\n    void setQuarters(const UnicodeString* quarters, int32_t count, DtContextType context, DtWidthType width);\n\n    /**\n     * Gets AM/PM strings. For example: \"AM\" and \"PM\".\n     * @param count        Filled in with length of the array.\n     * @return             the weekday strings. (DateFormatSymbols retains ownership.)\n     * @stable ICU 2.0\n     */\n    const UnicodeString* getAmPmStrings(int32_t& count) const;\n\n    /**\n     * Sets ampm strings. For example: \"AM\" and \"PM\".\n     * @param ampms        the new ampm strings. (not adopted; caller retains ownership)\n     * @param count        Filled in with length of the array.\n     * @stable ICU 2.0\n     */\n    void setAmPmStrings(const UnicodeString* ampms, int32_t count);\n\n#ifndef U_HIDE_INTERNAL_API\n    /**\n     * Somewhat temporary constants for leap month pattern types, adequate for supporting\n     * just leap month patterns as needed for Chinese lunar calendar.\n     * Eventually we will add full support for different month pattern types (needed for\n     * other calendars such as Hindu) at which point this approach will be replaced by a\n     * more complete approach.\n     * @internal\n     */\n    enum EMonthPatternType\n    {\n        kLeapMonthPatternFormatWide,\n        kLeapMonthPatternFormatAbbrev,\n        kLeapMonthPatternFormatNarrow,\n        kLeapMonthPatternStandaloneWide,\n        kLeapMonthPatternStandaloneAbbrev,\n        kLeapMonthPatternStandaloneNarrow,\n        kLeapMonthPatternNumeric,\n        kMonthPatternsCount\n    };\n\n    /**\n     * Somewhat temporary function for getting complete set of leap month patterns for all\n     * contexts & widths, indexed by EMonthPatternType values. Returns NULL if calendar\n     * does not have leap month patterns. Note, there is currently no setter for this.\n     * Eventually we will add full support for different month pattern types (needed for\n     * other calendars such as Hindu) at which point this approach will be replaced by a\n     * more complete approach.\n     * @param count        Filled in with length of the array (may be 0).\n     * @return             The leap month patterns (DateFormatSymbols retains ownership).\n     *                     May be NULL if there are no leap month patterns for this calendar.\n     * @internal\n     */\n    const UnicodeString* getLeapMonthPatterns(int32_t& count) const;\n\n#endif  /* U_HIDE_INTERNAL_API */\n\n#ifndef U_HIDE_DEPRECATED_API\n    /**\n     * Gets timezone strings. These strings are stored in a 2-dimensional array.\n     * @param rowCount      Output param to receive number of rows.\n     * @param columnCount   Output param to receive number of columns.\n     * @return              The timezone strings as a 2-d array. (DateFormatSymbols retains ownership.)\n     * @deprecated ICU 3.6\n     */\n    const UnicodeString** getZoneStrings(int32_t& rowCount, int32_t& columnCount) const;\n#endif  /* U_HIDE_DEPRECATED_API */\n\n    /**\n     * Sets timezone strings. These strings are stored in a 2-dimensional array.\n     * <p><b>Note:</b> SimpleDateFormat no longer use the zone strings stored in\n     * a DateFormatSymbols. Therefore, the time zone strings set by this mthod\n     * have no effects in an instance of SimpleDateFormat for formatting time\n     * zones.\n     * @param strings       The timezone strings as a 2-d array to be copied. (not adopted; caller retains ownership)\n     * @param rowCount      The number of rows (count of first index).\n     * @param columnCount   The number of columns (count of second index).\n     * @stable ICU 2.0\n     */\n    void setZoneStrings(const UnicodeString* const* strings, int32_t rowCount, int32_t columnCount);\n\n    /**\n     * Get the non-localized date-time pattern characters.\n     * @return    the non-localized date-time pattern characters\n     * @stable ICU 2.0\n     */\n    static const UChar * U_EXPORT2 getPatternUChars(void);\n\n    /**\n     * Gets localized date-time pattern characters. For example: 'u', 't', etc.\n     * <p>\n     * Note: ICU no longer provides localized date-time pattern characters for a locale\n     * starting ICU 3.8.  This method returns the non-localized date-time pattern\n     * characters unless user defined localized data is set by setLocalPatternChars.\n     * @param result    Output param which will receive the localized date-time pattern characters.\n     * @return          A reference to 'result'.\n     * @stable ICU 2.0\n     */\n    UnicodeString& getLocalPatternChars(UnicodeString& result) const;\n\n    /**\n     * Sets localized date-time pattern characters. For example: 'u', 't', etc.\n     * @param newLocalPatternChars the new localized date-time\n     * pattern characters.\n     * @stable ICU 2.0\n     */\n    void setLocalPatternChars(const UnicodeString& newLocalPatternChars);\n\n    /**\n     * Returns the locale for this object. Two flavors are available:\n     * valid and actual locale.\n     * @stable ICU 2.8\n     */\n    Locale getLocale(ULocDataLocaleType type, UErrorCode& status) const;\n\n#ifndef U_HIDE_INTERNAL_API\n    /**\n     * Constants for capitalization context usage types.\n     * @internal\n     */\n    enum ECapitalizationContextUsageType\n    {\n        kCapContextUsageOther,\n        kCapContextUsageMonthFormat,     /* except narrow */\n        kCapContextUsageMonthStandalone, /* except narrow */\n        kCapContextUsageMonthNarrow,\n        kCapContextUsageDayFormat,     /* except narrow */\n        kCapContextUsageDayStandalone, /* except narrow */\n        kCapContextUsageDayNarrow,\n        kCapContextUsageEraWide,\n        kCapContextUsageEraAbbrev,\n        kCapContextUsageEraNarrow,\n        kCapContextUsageZoneLong,\n        kCapContextUsageZoneShort,\n        kCapContextUsageMetazoneLong,\n        kCapContextUsageMetazoneShort,\n        kCapContextUsageTypeCount\n    };\n#endif  /* U_HIDE_INTERNAL_API */\n\n    /**\n     * ICU \"poor man's RTTI\", returns a UClassID for the actual class.\n     *\n     * @stable ICU 2.2\n     */\n    virtual UClassID getDynamicClassID() const;\n\n    /**\n     * ICU \"poor man's RTTI\", returns a UClassID for this class.\n     *\n     * @stable ICU 2.2\n     */\n    static UClassID U_EXPORT2 getStaticClassID();\n\nprivate:\n\n    friend class SimpleDateFormat;\n    friend class DateFormatSymbolsSingleSetter; // see udat.cpp\n\n    /**\n     * Abbreviated era strings. For example: \"AD\" and \"BC\".\n     */\n    UnicodeString*  fEras;\n    int32_t         fErasCount;\n\n    /**\n     * Era name strings. For example: \"Anno Domini\" and \"Before Christ\".\n     */\n    UnicodeString*  fEraNames;\n    int32_t         fEraNamesCount;\n\n    /**\n     * Narrow era strings. For example: \"A\" and \"B\".\n     */\n    UnicodeString*  fNarrowEras;\n    int32_t         fNarrowErasCount;\n\n    /**\n     * Month strings. For example: \"January\", \"February\", etc.\n     */\n    UnicodeString*  fMonths;\n    int32_t         fMonthsCount;\n\n    /**\n     * Short month strings. For example: \"Jan\", \"Feb\", etc.\n     */\n    UnicodeString*  fShortMonths;\n    int32_t         fShortMonthsCount;\n\n    /**\n     * Narrow month strings. For example: \"J\", \"F\", etc.\n     */\n    UnicodeString*  fNarrowMonths;\n    int32_t         fNarrowMonthsCount;\n\n    /**\n     * Standalone Month strings. For example: \"January\", \"February\", etc.\n     */\n    UnicodeString*  fStandaloneMonths;\n    int32_t         fStandaloneMonthsCount;\n\n    /**\n     * Standalone Short month strings. For example: \"Jan\", \"Feb\", etc.\n     */\n    UnicodeString*  fStandaloneShortMonths;\n    int32_t         fStandaloneShortMonthsCount;\n\n    /**\n     * Standalone Narrow month strings. For example: \"J\", \"F\", etc.\n     */\n    UnicodeString*  fStandaloneNarrowMonths;\n    int32_t         fStandaloneNarrowMonthsCount;\n\n    /**\n     * Weekday strings. For example: \"Sunday\", \"Monday\", etc.\n     */\n    UnicodeString*  fWeekdays;\n    int32_t         fWeekdaysCount;\n\n    /**\n     * Short weekday strings. For example: \"Sun\", \"Mon\", etc.\n     */\n    UnicodeString*  fShortWeekdays;\n    int32_t         fShortWeekdaysCount;\n\n    /**\n     * Narrow weekday strings. For example: \"Sun\", \"Mon\", etc.\n     */\n    UnicodeString*  fNarrowWeekdays;\n    int32_t         fNarrowWeekdaysCount;\n\n    /**\n     * Standalone Weekday strings. For example: \"Sunday\", \"Monday\", etc.\n     */\n    UnicodeString*  fStandaloneWeekdays;\n    int32_t         fStandaloneWeekdaysCount;\n\n    /**\n     * Standalone Short weekday strings. For example: \"Sun\", \"Mon\", etc.\n     */\n    UnicodeString*  fStandaloneShortWeekdays;\n    int32_t         fStandaloneShortWeekdaysCount;\n\n    /**\n     * Standalone Narrow weekday strings. For example: \"Sun\", \"Mon\", etc.\n     */\n    UnicodeString*  fStandaloneNarrowWeekdays;\n    int32_t         fStandaloneNarrowWeekdaysCount;\n\n    /**\n     * Ampm strings. For example: \"AM\" and \"PM\".\n     */\n    UnicodeString*  fAmPms;\n    int32_t         fAmPmsCount;\n\n    /**\n     * Quarter strings. For example: \"1st quarter\", \"2nd quarter\", etc.\n     */\n    UnicodeString  *fQuarters;\n    int32_t         fQuartersCount;\n\n    /**\n     * Short quarters. For example: \"Q1\", \"Q2\", etc.\n     */\n    UnicodeString  *fShortQuarters;\n    int32_t         fShortQuartersCount;\n\n    /**\n     * Standalone quarter strings. For example: \"1st quarter\", \"2nd quarter\", etc.\n     */\n    UnicodeString  *fStandaloneQuarters;\n    int32_t         fStandaloneQuartersCount;\n\n    /**\n     * Standalone short quarter strings. For example: \"Q1\", \"Q2\", etc.\n     */\n    UnicodeString  *fStandaloneShortQuarters;\n    int32_t         fStandaloneShortQuartersCount;\n\n    /**\n     * All leap month patterns, for example \"{0}bis\".\n     */\n    UnicodeString  *fLeapMonthPatterns;\n    int32_t         fLeapMonthPatternsCount;\n\n    /**\n     * (Format) Short cyclic year names, for example: \"jia-zi\", \"yi-chou\", ... \"gui-hai\"\n     */\n    UnicodeString*  fShortYearNames;\n    int32_t         fShortYearNamesCount;\n\n    /**\n     * Localized names of time zones in this locale.  This is a\n     * two-dimensional array of strings of size n by m,\n     * where m is at least 5 and up to 7.  Each of the n rows is an\n     * entry containing the localized names for a single TimeZone.\n     *\n     * Each such row contains (with i ranging from 0..n-1):\n     * \n     * zoneStrings[i][0] - time zone ID\n     *  example: America/Los_Angeles\n     * zoneStrings[i][1] - long name of zone in standard time\n     *  example: Pacific Standard Time\n     * zoneStrings[i][2] - short name of zone in standard time\n     *  example: PST\n     * zoneStrings[i][3] - long name of zone in daylight savings time\n     *  example: Pacific Daylight Time\n     * zoneStrings[i][4] - short name of zone in daylight savings time\n     *  example: PDT\n     * zoneStrings[i][5] - location name of zone\n     *  example: United States (Los Angeles)\n     * zoneStrings[i][6] - long generic name of zone\n     *  example: Pacific Time\n     * zoneStrings[i][7] - short generic of zone\n     *  example: PT\n     *\n     * The zone ID is not localized; it corresponds to the ID\n     * value associated with a system time zone object.  All other entries\n     * are localized names.  If a zone does not implement daylight savings\n     * time, the daylight savings time names are ignored.\n     *\n     * Note:CLDR 1.5 introduced metazone and its historical mappings.\n     * This simple two-dimensional array is no longer sufficient to represent\n     * localized names and its historic changes.  Since ICU 3.8.1, localized\n     * zone names extracted from ICU locale data is stored in a ZoneStringFormat\n     * instance.  But we still need to support the old way of customizing\n     * localized zone names, so we keep this field for the purpose.\n     */\n    UnicodeString   **fZoneStrings;         // Zone string array set by setZoneStrings\n    UnicodeString   **fLocaleZoneStrings;   // Zone string array created by the locale\n    int32_t         fZoneStringsRowCount;\n    int32_t         fZoneStringsColCount;\n\n    Locale                  fZSFLocale;         // Locale used for getting ZoneStringFormat\n\n    /**\n     * Localized date-time pattern characters. For example: use 'u' as 'y'.\n     */\n    UnicodeString   fLocalPatternChars;\n\n#ifndef U_HIDE_INTERNAL_API\n    /**\n     * Capitalization transforms. For each usage type, the first array element indicates\n     * whether to titlecase for uiListOrMenu context, the second indicates whether to\n     * titlecase for stand-alone context.\n     */\n     UBool fCapitalization[kCapContextUsageTypeCount][2];\n#endif\n\n\nprivate:\n    /** valid/actual locale information \n     *  these are always ICU locales, so the length should not be a problem\n     */\n    char validLocale[ULOC_FULLNAME_CAPACITY];\n    char actualLocale[ULOC_FULLNAME_CAPACITY];\n\n    DateFormatSymbols(); // default constructor not implemented\n\n    /**\n     * Called by the constructors to actually load data from the resources\n     *\n     * @param locale               The locale to get symbols for.\n     * @param type                 Calendar Type (as from Calendar::getType())\n     * @param status               Input/output parameter, set to success or\n     *                             failure code upon return.\n     * @param useLastResortData    determine if use last resort data\n     */\n    void initializeData(const Locale& locale, const char *type, UErrorCode& status, UBool useLastResortData = FALSE);\n\n    /**\n     * Copy or alias an array in another object, as appropriate.\n     *\n     * @param dstArray    the copy destination array.\n     * @param dstCount    fill in with the lenth of 'dstArray'.\n     * @param srcArray    the source array to be copied.\n     * @param srcCount    the length of items to be copied from the 'srcArray'.\n     */\n    static void assignArray(UnicodeString*& dstArray,\n                            int32_t& dstCount,\n                            const UnicodeString* srcArray,\n                            int32_t srcCount);\n\n    /**\n     * Return true if the given arrays' contents are equal, or if the arrays are\n     * identical (pointers are equal).\n     *\n     * @param array1   one array to be compared with.\n     * @param array2   another array to be compared with.\n     * @param count    the length of items to be copied.\n     * @return         true if the given arrays' contents are equal, or if the arrays are\n     *                 identical (pointers are equal).\n     */\n    static UBool arrayCompare(const UnicodeString* array1,\n                             const UnicodeString* array2,\n                             int32_t count);\n\n    /**\n     * Create a copy, in fZoneStrings, of the given zone strings array. The\n     * member variables fZoneStringsRowCount and fZoneStringsColCount should be\n     * set already by the caller.\n     */\n    void createZoneStrings(const UnicodeString *const * otherStrings);\n\n    /**\n     * Delete all the storage owned by this object.\n     */\n    void dispose(void);\n\n    /**\n     * Copy all of the other's data to this.\n     * @param other the object to be copied.\n     */\n    void copyData(const DateFormatSymbols& other);\n\n    /**\n     * Create zone strings array by locale if not yet available\n     */\n    void initZoneStringsArray(void);\n\n    /**\n     * Delete just the zone strings.\n     */\n    void disposeZoneStrings(void);\n\n    /**\n     * Returns the date format field index of the pattern character c,\n     * or UDAT_FIELD_COUNT if c is not a pattern character.\n     */\n    static UDateFormatField U_EXPORT2 getPatternCharIndex(UChar c);\n\n    /**\n     * Returns TRUE if f (with its pattern character repeated count times) is a numeric field.\n     */\n    static UBool U_EXPORT2 isNumericField(UDateFormatField f, int32_t count);\n\n    /**\n     * Returns TRUE if c (repeated count times) is the pattern character for a numeric field.\n     */\n    static UBool U_EXPORT2 isNumericPatternChar(UChar c, int32_t count);\n};\n\nU_NAMESPACE_END\n\n#endif /* #if !UCONFIG_NO_FORMATTING */\n\n#endif // _DTFMTSYM\n//eof\n"
  },
  {
    "path": "deprecated/android/addons/icucompat/unicode/dtintrv.h",
    "content": "/*\n*******************************************************************************\n* Copyright (C) 2008-2009, International Business Machines Corporation and\n* others. All Rights Reserved.\n*******************************************************************************\n*\n* File DTINTRV.H \n*\n*******************************************************************************\n*/\n\n#ifndef __DTINTRV_H__\n#define __DTINTRV_H__\n\n#include \"unicode/utypes.h\"\n#include \"unicode/uobject.h\"\n\n/**\n * \\file\n * \\brief C++ API: Date Interval data type\n */\n\n\nU_NAMESPACE_BEGIN\n\n\n/**\n * This class represents a date interval.\n * It is a pair of UDate representing from UDate 1 to UDate 2.\n * @stable ICU 4.0\n**/\nclass U_COMMON_API DateInterval : public UObject {\npublic:\n\n    /** \n     * Construct a DateInterval given a from date and a to date.\n     * @param fromDate  The from date in date interval.\n     * @param toDate    The to date in date interval.\n     * @stable ICU 4.0\n     */\n    DateInterval(UDate fromDate, UDate toDate);\n\n    /**\n     * destructor\n     * @stable ICU 4.0\n     */\n    virtual ~DateInterval();\n \n    /** \n     * Get the from date.\n     * @return  the from date in dateInterval.\n     * @stable ICU 4.0\n     */\n    UDate getFromDate() const;\n\n    /** \n     * Get the to date.\n     * @return  the to date in dateInterval.\n     * @stable ICU 4.0\n     */\n    UDate getToDate() const;\n\n\n    /**\n     * Return the class ID for this class. This is useful only for comparing to\n     * a return value from getDynamicClassID(). For example:\n     * <pre>\n     * .   Base* polymorphic_pointer = createPolymorphicObject();\n     * .   if (polymorphic_pointer->getDynamicClassID() ==\n     * .       erived::getStaticClassID()) ...\n     * </pre>\n     * @return          The class ID for all objects of this class.\n     * @stable ICU 4.0\n     */\n    static UClassID U_EXPORT2 getStaticClassID(void);\n\n    /**\n     * Returns a unique class ID POLYMORPHICALLY. Pure virtual override. This\n     * method is to implement a simple version of RTTI, since not all C++\n     * compilers support genuine RTTI. Polymorphic operator==() and clone()\n     * methods call this method.\n     *\n     * @return          The class ID for this object. All objects of a\n     *                  given class have the same class ID.  Objects of\n     *                  other classes have different class IDs.\n     * @stable ICU 4.0\n     */\n    virtual UClassID getDynamicClassID(void) const;\n\n    \n    /**\n     * Copy constructor.\n     * @stable ICU 4.0\n     */\n    DateInterval(const DateInterval& other);\n\n    /**\n     * Default assignment operator\n     * @stable ICU 4.0\n     */\n    DateInterval& operator=(const DateInterval&);\n\n    /**\n     * Equality operator.\n     * @return TRUE if the two DateIntervals are the same\n     * @stable ICU 4.0\n     */\n    virtual UBool operator==(const DateInterval& other) const;\n\n    /**\n     * Non-equality operator\n     * @return TRUE if the two DateIntervals are not the same\n     * @stable ICU 4.0\n     */\n    UBool operator!=(const DateInterval& other) const;\n\n\n    /**\n     * clone this object. \n     * The caller owns the result and should delete it when done.\n     * @return a cloned DateInterval\n     * @stable ICU 4.0\n     */\n     virtual DateInterval* clone() const;\n\nprivate:\n    /** \n     * Default constructor, not implemented.\n     */\n    DateInterval();\n\n    UDate fromDate;\n    UDate toDate;\n\n} ;// end class DateInterval\n\n\ninline UDate \nDateInterval::getFromDate() const { \n    return fromDate; \n}\n\n\ninline UDate \nDateInterval::getToDate() const { \n    return toDate; \n}\n\n\ninline UBool \nDateInterval::operator!=(const DateInterval& other) const { \n    return ( !operator==(other) );\n}\n\n\nU_NAMESPACE_END\n\n#endif\n"
  },
  {
    "path": "deprecated/android/addons/icucompat/unicode/dtitvfmt.h",
    "content": "/********************************************************************************\n* Copyright (C) 2008-2012, International Business Machines Corporation and\n* others. All Rights Reserved.\n*******************************************************************************\n*\n* File DTITVFMT.H\n*\n*******************************************************************************\n*/\n\n#ifndef __DTITVFMT_H__\n#define __DTITVFMT_H__\n\n\n#include \"unicode/utypes.h\"\n\n/**\n * \\file\n * \\brief C++ API: Format and parse date interval in a language-independent manner.\n */\n\n#if !UCONFIG_NO_FORMATTING\n\n#include \"unicode/ucal.h\"\n#include \"unicode/smpdtfmt.h\"\n#include \"unicode/dtintrv.h\"\n#include \"unicode/dtitvinf.h\"\n#include \"unicode/dtptngen.h\"\n\nU_NAMESPACE_BEGIN\n\n\n\n/**\n * DateIntervalFormat is a class for formatting and parsing date\n * intervals in a language-independent manner.\n * Only formatting is supported, parsing is not supported.\n *\n * <P>\n * Date interval means from one date to another date,\n * for example, from \"Jan 11, 2008\" to \"Jan 18, 2008\".\n * We introduced class DateInterval to represent it.\n * DateInterval is a pair of UDate, which is\n * the standard milliseconds since 24:00 GMT, Jan 1, 1970.\n *\n * <P>\n * DateIntervalFormat formats a DateInterval into\n * text as compactly as possible.\n * For example, the date interval format from \"Jan 11, 2008\" to \"Jan 18,. 2008\"\n * is \"Jan 11-18, 2008\" for English.\n * And it parses text into DateInterval,\n * although initially, parsing is not supported.\n *\n * <P>\n * There is no structural information in date time patterns.\n * For any punctuations and string literals inside a date time pattern,\n * we do not know whether it is just a separator, or a prefix, or a suffix.\n * Without such information, so, it is difficult to generate a sub-pattern\n * (or super-pattern) by algorithm.\n * So, formatting a DateInterval is pattern-driven. It is very\n * similar to formatting in SimpleDateFormat.\n * We introduce class DateIntervalInfo to save date interval\n * patterns, similar to date time pattern in SimpleDateFormat.\n *\n * <P>\n * Logically, the interval patterns are mappings\n * from (skeleton, the_largest_different_calendar_field)\n * to (date_interval_pattern).\n *\n * <P>\n * A skeleton\n * <ol>\n * <li>\n * only keeps the field pattern letter and ignores all other parts\n * in a pattern, such as space, punctuations, and string literals.\n * </li>\n * <li>\n * hides the order of fields.\n * </li>\n * <li>\n * might hide a field's pattern letter length.\n * </li>\n * </ol>\n *\n * For those non-digit calendar fields, the pattern letter length is\n * important, such as MMM, MMMM, and MMMMM; EEE and EEEE,\n * and the field's pattern letter length is honored.\n *\n * For the digit calendar fields,  such as M or MM, d or dd, yy or yyyy,\n * the field pattern length is ignored and the best match, which is defined\n * in date time patterns, will be returned without honor the field pattern\n * letter length in skeleton.\n *\n * <P>\n * The calendar fields we support for interval formatting are:\n * year, month, date, day-of-week, am-pm, hour, hour-of-day, and minute.\n * Those calendar fields can be defined in the following order:\n * year >  month > date > hour (in day) >  minute\n *\n * The largest different calendar fields between 2 calendars is the\n * first different calendar field in above order.\n *\n * For example: the largest different calendar fields between \"Jan 10, 2007\"\n * and \"Feb 20, 2008\" is year.\n *\n * <P>\n * For other calendar fields, the compact interval formatting is not\n * supported. And the interval format will be fall back to fall-back\n * patterns, which is mostly \"{date0} - {date1}\".\n *\n * <P>\n * There is a set of pre-defined static skeleton strings.\n * There are pre-defined interval patterns for those pre-defined skeletons\n * in locales' resource files.\n * For example, for a skeleton UDAT_YEAR_ABBR_MONTH_DAY, which is  &quot;yMMMd&quot;,\n * in  en_US, if the largest different calendar field between date1 and date2\n * is &quot;year&quot;, the date interval pattern  is &quot;MMM d, yyyy - MMM d, yyyy&quot;,\n * such as &quot;Jan 10, 2007 - Jan 10, 2008&quot;.\n * If the largest different calendar field between date1 and date2 is &quot;month&quot;,\n * the date interval pattern is &quot;MMM d - MMM d, yyyy&quot;,\n * such as &quot;Jan 10 - Feb 10, 2007&quot;.\n * If the largest different calendar field between date1 and date2 is &quot;day&quot;,\n * the date interval pattern is &quot;MMM d-d, yyyy&quot;, such as &quot;Jan 10-20, 2007&quot;.\n *\n * For date skeleton, the interval patterns when year, or month, or date is\n * different are defined in resource files.\n * For time skeleton, the interval patterns when am/pm, or hour, or minute is\n * different are defined in resource files.\n *\n * <P>\n * If a skeleton is not found in a locale's DateIntervalInfo, which means\n * the interval patterns for the skeleton is not defined in resource file,\n * the interval pattern will falls back to the interval \"fallback\" pattern\n * defined in resource file.\n * If the interval \"fallback\" pattern is not defined, the default fall-back\n * is \"{date0} - {data1}\".\n *\n * <P>\n * For the combination of date and time,\n * The rule to generate interval patterns are:\n * <ol>\n * <li>\n *    when the year, month, or day differs, falls back to fall-back\n *    interval pattern, which mostly is the concatenate the two original\n *    expressions with a separator between,\n *    For example, interval pattern from \"Jan 10, 2007 10:10 am\"\n *    to \"Jan 11, 2007 10:10am\" is\n *    \"Jan 10, 2007 10:10 am - Jan 11, 2007 10:10am\"\n * </li>\n * <li>\n *    otherwise, present the date followed by the range expression\n *    for the time.\n *    For example, interval pattern from \"Jan 10, 2007 10:10 am\"\n *    to \"Jan 10, 2007 11:10am\" is \"Jan 10, 2007 10:10 am - 11:10am\"\n * </li>\n * </ol>\n *\n *\n * <P>\n * If two dates are the same, the interval pattern is the single date pattern.\n * For example, interval pattern from \"Jan 10, 2007\" to \"Jan 10, 2007\" is\n * \"Jan 10, 2007\".\n *\n * Or if the presenting fields between 2 dates have the exact same values,\n * the interval pattern is the  single date pattern.\n * For example, if user only requests year and month,\n * the interval pattern from \"Jan 10, 2007\" to \"Jan 20, 2007\" is \"Jan 2007\".\n *\n * <P>\n * DateIntervalFormat needs the following information for correct\n * formatting: time zone, calendar type, pattern, date format symbols,\n * and date interval patterns.\n * It can be instantiated in 2 ways:\n * <ol>\n * <li>\n *    create an instance using default or given locale plus given skeleton.\n *    Users are encouraged to created date interval formatter this way and\n *    to use the pre-defined skeleton macros, such as\n *    UDAT_YEAR_NUM_MONTH, which consists the calendar fields and\n *    the format style.\n * </li>\n * <li>\n *    create an instance using default or given locale plus given skeleton\n *    plus a given DateIntervalInfo.\n *    This factory method is for powerful users who want to provide their own\n *    interval patterns.\n *    Locale provides the timezone, calendar, and format symbols information.\n *    Local plus skeleton provides full pattern information.\n *    DateIntervalInfo provides the date interval patterns.\n * </li>\n * </ol>\n *\n * <P>\n * For the calendar field pattern letter, such as G, y, M, d, a, h, H, m, s etc.\n * DateIntervalFormat uses the same syntax as that of\n * DateTime format.\n *\n * <P>\n * Code Sample: general usage\n * <pre>\n * \\code\n *   // the date interval object which the DateIntervalFormat formats on\n *   // and parses into\n *   DateInterval*  dtInterval = new DateInterval(1000*3600*24, 1000*3600*24*2);\n *   UErrorCode status = U_ZERO_ERROR;\n *   DateIntervalFormat* dtIntervalFmt = DateIntervalFormat::createInstance(\n *                           UDAT_YEAR_MONTH_DAY,\n *                           Locale(\"en\", \"GB\", \"\"), status);\n *   UnicodeUnicodeString dateIntervalString;\n *   FieldPosition pos = 0;\n *   // formatting\n *   dtIntervalFmt->format(dtInterval, dateIntervalUnicodeString, pos, status);\n *   delete dtIntervalFmt;\n * \\endcode\n * </pre>\n */\n\nclass U_I18N_API DateIntervalFormat : public Format {\npublic:\n\n    /**\n     * Construct a DateIntervalFormat from skeleton and  the default locale.\n     *\n     * This is a convenient override of\n     * createInstance(const UnicodeString& skeleton, const Locale& locale,\n     *                UErrorCode&)\n     * with the value of locale as default locale.\n     *\n     * @param skeleton  the skeleton on which interval format based.\n     * @param status    output param set to success/failure code on exit\n     * @return          a date time interval formatter which the caller owns.\n     * @stable ICU 4.0\n     */\n    static DateIntervalFormat* U_EXPORT2 createInstance(\n                                               const UnicodeString& skeleton,\n                                               UErrorCode& status);\n\n    /**\n     * Construct a DateIntervalFormat from skeleton and a given locale.\n     * <P>\n     * In this factory method,\n     * the date interval pattern information is load from resource files.\n     * Users are encouraged to created date interval formatter this way and\n     * to use the pre-defined skeleton macros.\n     *\n     * <P>\n     * There are pre-defined skeletons (defined in udate.h) having predefined\n     * interval patterns in resource files.\n     * Users are encouraged to use those macros.\n     * For example:\n     * DateIntervalFormat::createInstance(UDAT_MONTH_DAY, status)\n     *\n     * The given Locale provides the interval patterns.\n     * For example, for en_GB, if skeleton is UDAT_YEAR_ABBR_MONTH_WEEKDAY_DAY,\n     * which is \"yMMMEEEd\",\n     * the interval patterns defined in resource file to above skeleton are:\n     * \"EEE, d MMM, yyyy - EEE, d MMM, yyyy\" for year differs,\n     * \"EEE, d MMM - EEE, d MMM, yyyy\" for month differs,\n     * \"EEE, d - EEE, d MMM, yyyy\" for day differs,\n     * @param skeleton  the skeleton on which the interval format is based.\n     * @param locale    the given locale\n     * @param status    output param set to success/failure code on exit\n     * @return          a date time interval formatter which the caller owns.\n     * @stable ICU 4.0\n     */\n\n    static DateIntervalFormat* U_EXPORT2 createInstance(\n                                               const UnicodeString& skeleton,\n                                               const Locale& locale,\n                                               UErrorCode& status);\n\n    /**\n     * Construct a DateIntervalFormat from skeleton\n     *  DateIntervalInfo, and default locale.\n     *\n     * This is a convenient override of\n     * createInstance(const UnicodeString& skeleton, const Locale& locale,\n     *                const DateIntervalInfo& dtitvinf, UErrorCode&)\n     * with the locale value as default locale.\n     *\n     * @param skeleton  the skeleton on which interval format based.\n     * @param dtitvinf  the DateIntervalInfo object.\n     * @param status    output param set to success/failure code on exit\n     * @return          a date time interval formatter which the caller owns.\n     * @stable ICU 4.0\n     */\n    static DateIntervalFormat* U_EXPORT2 createInstance(\n                                              const UnicodeString& skeleton,\n                                              const DateIntervalInfo& dtitvinf,\n                                              UErrorCode& status);\n\n    /**\n     * Construct a DateIntervalFormat from skeleton\n     * a DateIntervalInfo, and the given locale.\n     *\n     * <P>\n     * In this factory method, user provides its own date interval pattern\n     * information, instead of using those pre-defined data in resource file.\n     * This factory method is for powerful users who want to provide their own\n     * interval patterns.\n     * <P>\n     * There are pre-defined skeletons (defined in udate.h) having predefined\n     * interval patterns in resource files.\n     * Users are encouraged to use those macros.\n     * For example:\n     * DateIntervalFormat::createInstance(UDAT_MONTH_DAY, status)\n     *\n     * The DateIntervalInfo provides the interval patterns.\n     * and the DateIntervalInfo ownership remains to the caller.\n     *\n     * User are encouraged to set default interval pattern in DateIntervalInfo\n     * as well, if they want to set other interval patterns ( instead of\n     * reading the interval patterns from resource files).\n     * When the corresponding interval pattern for a largest calendar different\n     * field is not found ( if user not set it ), interval format fallback to\n     * the default interval pattern.\n     * If user does not provide default interval pattern, it fallback to\n     * \"{date0} - {date1}\"\n     *\n     * @param skeleton  the skeleton on which interval format based.\n     * @param locale    the given locale\n     * @param dtitvinf  the DateIntervalInfo object.\n     * @param status    output param set to success/failure code on exit\n     * @return          a date time interval formatter which the caller owns.\n     * @stable ICU 4.0\n     */\n    static DateIntervalFormat* U_EXPORT2 createInstance(\n                                              const UnicodeString& skeleton,\n                                              const Locale& locale,\n                                              const DateIntervalInfo& dtitvinf,\n                                              UErrorCode& status);\n\n    /**\n     * Destructor.\n     * @stable ICU 4.0\n     */\n    virtual ~DateIntervalFormat();\n\n    /**\n     * Clone this Format object polymorphically. The caller owns the result and\n     * should delete it when done.\n     * @return    A copy of the object.\n     * @stable ICU 4.0\n     */\n    virtual Format* clone(void) const;\n\n    /**\n     * Return true if the given Format objects are semantically equal. Objects\n     * of different subclasses are considered unequal.\n     * @param other    the object to be compared with.\n     * @return         true if the given Format objects are semantically equal.\n     * @stable ICU 4.0\n     */\n    virtual UBool operator==(const Format& other) const;\n\n    /**\n     * Return true if the given Format objects are not semantically equal.\n     * Objects of different subclasses are considered unequal.\n     * @param other the object to be compared with.\n     * @return      true if the given Format objects are not semantically equal.\n     * @stable ICU 4.0\n     */\n    UBool operator!=(const Format& other) const;\n\n\n    using Format::format;\n\n    /**\n     * Format an object to produce a string. This method handles Formattable\n     * objects with a DateInterval type.\n     * If a the Formattable object type is not a DateInterval,\n     * then it returns a failing UErrorCode.\n     *\n     * @param obj               The object to format.\n     *                          Must be a DateInterval.\n     * @param appendTo          Output parameter to receive result.\n     *                          Result is appended to existing contents.\n     * @param fieldPosition     On input: an alignment field, if desired.\n     *                          On output: the offsets of the alignment field.\n     * @param status            Output param filled with success/failure status.\n     * @return                  Reference to 'appendTo' parameter.\n     * @stable ICU 4.0\n     */\n    virtual UnicodeString& format(const Formattable& obj,\n                                  UnicodeString& appendTo,\n                                  FieldPosition& fieldPosition,\n                                  UErrorCode& status) const ;\n\n\n\n    /**\n     * Format a DateInterval to produce a string.\n     *\n     * @param dtInterval        DateInterval to be formatted.\n     * @param appendTo          Output parameter to receive result.\n     *                          Result is appended to existing contents.\n     * @param fieldPosition     On input: an alignment field, if desired.\n     *                          On output: the offsets of the alignment field.\n     * @param status            Output param filled with success/failure status.\n     * @return                  Reference to 'appendTo' parameter.\n     * @stable ICU 4.0\n     */\n    UnicodeString& format(const DateInterval* dtInterval,\n                          UnicodeString& appendTo,\n                          FieldPosition& fieldPosition,\n                          UErrorCode& status) const ;\n\n\n    /**\n     * Format 2 Calendars to produce a string.\n     *\n     * Note: \"fromCalendar\" and \"toCalendar\" are not const,\n     * since calendar is not const in  SimpleDateFormat::format(Calendar&),\n     *\n     * @param fromCalendar      calendar set to the from date in date interval\n     *                          to be formatted into date interval string\n     * @param toCalendar        calendar set to the to date in date interval\n     *                          to be formatted into date interval string\n     * @param appendTo          Output parameter to receive result.\n     *                          Result is appended to existing contents.\n     * @param fieldPosition     On input: an alignment field, if desired.\n     *                          On output: the offsets of the alignment field.\n     * @param status            Output param filled with success/failure status.\n     *                          Caller needs to make sure it is SUCCESS\n     *                          at the function entrance\n     * @return                  Reference to 'appendTo' parameter.\n     * @stable ICU 4.0\n     */\n    UnicodeString& format(Calendar& fromCalendar,\n                          Calendar& toCalendar,\n                          UnicodeString& appendTo,\n                          FieldPosition& fieldPosition,\n                          UErrorCode& status) const ;\n\n    /**\n     * Date interval parsing is not supported. Please do not use.\n     * <P>\n     * This method should handle parsing of\n     * date time interval strings into Formattable objects with\n     * DateInterval type, which is a pair of UDate.\n     * <P>\n     * Before calling, set parse_pos.index to the offset you want to start\n     * parsing at in the source. After calling, parse_pos.index is the end of\n     * the text you parsed. If error occurs, index is unchanged.\n     * <P>\n     * When parsing, leading whitespace is discarded (with a successful parse),\n     * while trailing whitespace is left as is.\n     * <P>\n     * See Format::parseObject() for more.\n     *\n     * @param source    The string to be parsed into an object.\n     * @param result    Formattable to be set to the parse result.\n     *                  If parse fails, return contents are undefined.\n     * @param parse_pos The position to start parsing at. Since no parsing\n     *                  is supported, upon return this param is unchanged.\n     * @return          A newly created Formattable* object, or NULL\n     *                  on failure.  The caller owns this and should\n     *                  delete it when done.\n     * @internal ICU 4.0\n     */\n    virtual void parseObject(const UnicodeString& source,\n                             Formattable& result,\n                             ParsePosition& parse_pos) const;\n\n\n    /**\n     * Gets the date time interval patterns.\n     * @return the date time interval patterns associated with\n     * this date interval formatter.\n     * @stable ICU 4.0\n     */\n    const DateIntervalInfo* getDateIntervalInfo(void) const;\n\n\n    /**\n     * Set the date time interval patterns.\n     * @param newIntervalPatterns   the given interval patterns to copy.\n     * @param status          output param set to success/failure code on exit\n     * @stable ICU 4.0\n     */\n    void setDateIntervalInfo(const DateIntervalInfo& newIntervalPatterns,\n                             UErrorCode& status);\n\n\n    /**\n     * Gets the date formatter\n     * @return the date formatter associated with this date interval formatter.\n     * @stable ICU 4.0\n     */\n    const DateFormat* getDateFormat(void) const;\n\n    /**\n     * Returns a reference to the TimeZone used by this DateIntervalFormat's calendar.\n     * @return the time zone associated with the calendar of DateIntervalFormat.\n     * @stable ICU 4.8\n     */\n    virtual const TimeZone& getTimeZone(void) const;\n\n    /**\n     * Sets the time zone for the calendar used by this DateIntervalFormat object. The\n     * caller no longer owns the TimeZone object and should not delete it after this call.\n     * @param zoneToAdopt the TimeZone to be adopted.\n     * @stable ICU 4.8\n     */\n    virtual void adoptTimeZone(TimeZone* zoneToAdopt);\n\n    /**\n     * Sets the time zone for the calendar used by this DateIntervalFormat object.\n     * @param zone the new time zone.\n     * @stable ICU 4.8\n     */\n    virtual void setTimeZone(const TimeZone& zone);\n\n    /**\n     * Return the class ID for this class. This is useful only for comparing to\n     * a return value from getDynamicClassID(). For example:\n     * <pre>\n     * .   Base* polymorphic_pointer = createPolymorphicObject();\n     * .   if (polymorphic_pointer->getDynamicClassID() ==\n     * .       erived::getStaticClassID()) ...\n     * </pre>\n     * @return          The class ID for all objects of this class.\n     * @stable ICU 4.0\n     */\n    static UClassID U_EXPORT2 getStaticClassID(void);\n\n    /**\n     * Returns a unique class ID POLYMORPHICALLY. Pure virtual override. This\n     * method is to implement a simple version of RTTI, since not all C++\n     * compilers support genuine RTTI. Polymorphic operator==() and clone()\n     * methods call this method.\n     *\n     * @return          The class ID for this object. All objects of a\n     *                  given class have the same class ID.  Objects of\n     *                  other classes have different class IDs.\n     * @stable ICU 4.0\n     */\n    virtual UClassID getDynamicClassID(void) const;\n\nprotected:\n\n    /**\n     * Copy constructor.\n     * @stable ICU 4.0\n     */\n    DateIntervalFormat(const DateIntervalFormat&);\n\n    /**\n     * Assignment operator.\n     * @stable ICU 4.0\n     */\n    DateIntervalFormat& operator=(const DateIntervalFormat&);\n\nprivate:\n\n    /*\n     * This is for ICU internal use only. Please do not use.\n     * Save the interval pattern information.\n     * Interval pattern consists of 2 single date patterns and the separator.\n     * For example, interval pattern \"MMM d - MMM d, yyyy\" consists\n     * a single date pattern \"MMM d\", another single date pattern \"MMM d, yyyy\",\n     * and a separator \"-\".\n     * The pattern is divided into 2 parts. For above example,\n     * the first part is \"MMM d - \", and the second part is \"MMM d, yyyy\".\n     * Also, the first date appears in an interval pattern could be\n     * the earlier date or the later date.\n     * And such information is saved in the interval pattern as well.\n     * @internal ICU 4.0\n     */\n    struct PatternInfo {\n        UnicodeString firstPart;\n        UnicodeString secondPart;\n        /**\n         * Whether the first date in interval pattern is later date or not.\n         * Fallback format set the default ordering.\n         * And for a particular interval pattern, the order can be\n         * overriden by prefixing the interval pattern with \"latestFirst:\" or\n         * \"earliestFirst:\"\n         * For example, given 2 date, Jan 10, 2007 to Feb 10, 2007.\n         * if the fallback format is \"{0} - {1}\",\n         * and the pattern is \"d MMM - d MMM yyyy\", the interval format is\n         * \"10 Jan - 10 Feb, 2007\".\n         * If the pattern is \"latestFirst:d MMM - d MMM yyyy\",\n         * the interval format is \"10 Feb - 10 Jan, 2007\"\n         */\n        UBool         laterDateFirst;\n    };\n\n\n    /**\n     * default constructor\n     * @internal ICU 4.0\n     */\n    DateIntervalFormat();\n\n    /**\n     * Construct a DateIntervalFormat from DateFormat,\n     * a DateIntervalInfo, and skeleton.\n     * DateFormat provides the timezone, calendar,\n     * full pattern, and date format symbols information.\n     * It should be a SimpleDateFormat object which\n     * has a pattern in it.\n     * the DateIntervalInfo provides the interval patterns.\n     *\n     * Note: the DateIntervalFormat takes ownership of both\n     * DateFormat and DateIntervalInfo objects.\n     * Caller should not delete them.\n     *\n     * @param locale    the locale of this date interval formatter.\n     * @param dtItvInfo the DateIntervalInfo object to be adopted.\n     * @param skeleton  the skeleton of the date formatter\n     * @param status    output param set to success/failure code on exit\n     * @internal ICU 4.0\n     */\n    DateIntervalFormat(const Locale& locale, DateIntervalInfo* dtItvInfo,\n                       const UnicodeString* skeleton, UErrorCode& status);\n\n\n    /**\n     * Construct a DateIntervalFormat from DateFormat\n     * and a DateIntervalInfo.\n     *\n     * It is a wrapper of the constructor.\n     *\n     * @param locale    the locale of this date interval formatter.\n     * @param dtitvinf  the DateIntervalInfo object to be adopted.\n     * @param skeleton  the skeleton of this formatter.\n     * @param status    Output param set to success/failure code.\n     * @return          a date time interval formatter which the caller owns.\n     * @internal ICU 4.0\n     */\n    static DateIntervalFormat* U_EXPORT2 create(const Locale& locale,\n                                                DateIntervalInfo* dtitvinf,\n                                                const UnicodeString* skeleton,\n                                                UErrorCode& status);\n\n    /**\n     * Create a simple date/time formatter from skeleton, given locale,\n     * and date time pattern generator.\n     *\n     * @param skeleton  the skeleton on which date format based.\n     * @param locale    the given locale.\n     * @param dtpng     the date time pattern generator.\n     * @param status    Output param to be set to success/failure code.\n     *                  If it is failure, the returned date formatter will\n     *                  be NULL.\n     * @return          a simple date formatter which the caller owns.\n     * @internal ICU 4.0\n     */\n    static SimpleDateFormat* U_EXPORT2 createSDFPatternInstance(\n                                        const UnicodeString& skeleton,\n                                        const Locale& locale,\n                                        DateTimePatternGenerator* dtpng,\n                                        UErrorCode& status);\n\n\n    /**\n     *  Below are for generating interval patterns local to the formatter\n     */\n\n\n    /**\n     * Format 2 Calendars using fall-back interval pattern\n     *\n     * The full pattern used in this fall-back format is the\n     * full pattern of the date formatter.\n     *\n     * @param fromCalendar      calendar set to the from date in date interval\n     *                          to be formatted into date interval string\n     * @param toCalendar        calendar set to the to date in date interval\n     *                          to be formatted into date interval string\n     * @param appendTo          Output parameter to receive result.\n     *                          Result is appended to existing contents.\n     * @param pos               On input: an alignment field, if desired.\n     *                          On output: the offsets of the alignment field.\n     * @param status            output param set to success/failure code on exit\n     * @return                  Reference to 'appendTo' parameter.\n     * @internal ICU 4.0\n     */\n    UnicodeString& fallbackFormat(Calendar& fromCalendar,\n                                  Calendar& toCalendar,\n                                  UnicodeString& appendTo,\n                                  FieldPosition& pos,\n                                  UErrorCode& status) const;\n\n\n\n    /**\n     * Initialize interval patterns locale to this formatter\n     *\n     * This code is a bit complicated since\n     * 1. the interval patterns saved in resource bundle files are interval\n     *    patterns based on date or time only.\n     *    It does not have interval patterns based on both date and time.\n     *    Interval patterns on both date and time are algorithm generated.\n     *\n     *    For example, it has interval patterns on skeleton \"dMy\" and \"hm\",\n     *    but it does not have interval patterns on skeleton \"dMyhm\".\n     *\n     *    The rule to generate interval patterns for both date and time skeleton are\n     *    1) when the year, month, or day differs, concatenate the two original\n     *    expressions with a separator between,\n     *    For example, interval pattern from \"Jan 10, 2007 10:10 am\"\n     *    to \"Jan 11, 2007 10:10am\" is\n     *    \"Jan 10, 2007 10:10 am - Jan 11, 2007 10:10am\"\n     *\n     *    2) otherwise, present the date followed by the range expression\n     *    for the time.\n     *    For example, interval pattern from \"Jan 10, 2007 10:10 am\"\n     *    to \"Jan 10, 2007 11:10am\" is\n     *    \"Jan 10, 2007 10:10 am - 11:10am\"\n     *\n     * 2. even a pattern does not request a certain calendar field,\n     *    the interval pattern needs to include such field if such fields are\n     *    different between 2 dates.\n     *    For example, a pattern/skeleton is \"hm\", but the interval pattern\n     *    includes year, month, and date when year, month, and date differs.\n     *\n     *\n     * @param status    output param set to success/failure code on exit\n     * @internal ICU 4.0\n     */\n    void initializePattern(UErrorCode& status);\n\n\n\n    /**\n     * Set fall back interval pattern given a calendar field,\n     * a skeleton, and a date time pattern generator.\n     * @param field      the largest different calendar field\n     * @param skeleton   a skeleton\n     * @param status     output param set to success/failure code on exit\n     * @internal ICU 4.0\n     */\n    void setFallbackPattern(UCalendarDateFields field,\n                            const UnicodeString& skeleton,\n                            UErrorCode& status);\n\n\n\n    /**\n     * get separated date and time skeleton from a combined skeleton.\n     *\n     * The difference between date skeleton and normalizedDateSkeleton are:\n     * 1. both 'y' and 'd' are appeared only once in normalizeDateSkeleton\n     * 2. 'E' and 'EE' are normalized into 'EEE'\n     * 3. 'MM' is normalized into 'M'\n     *\n     ** the difference between time skeleton and normalizedTimeSkeleton are:\n     * 1. both 'H' and 'h' are normalized as 'h' in normalized time skeleton,\n     * 2. 'a' is omitted in normalized time skeleton.\n     * 3. there is only one appearance for 'h', 'm','v', 'z' in normalized time\n     *    skeleton\n     *\n     *\n     *  @param skeleton               given combined skeleton.\n     *  @param date                   Output parameter for date only skeleton.\n     *  @param normalizedDate         Output parameter for normalized date only\n     *\n     *  @param time                   Output parameter for time only skeleton.\n     *  @param normalizedTime         Output parameter for normalized time only\n     *                                skeleton.\n     *\n     * @internal ICU 4.0\n     */\n    static void  U_EXPORT2 getDateTimeSkeleton(const UnicodeString& skeleton,\n                                    UnicodeString& date,\n                                    UnicodeString& normalizedDate,\n                                    UnicodeString& time,\n                                    UnicodeString& normalizedTime);\n\n\n\n    /**\n     * Generate date or time interval pattern from resource,\n     * and set them into the interval pattern locale to this formatter.\n     *\n     * It needs to handle the following:\n     * 1. need to adjust field width.\n     *    For example, the interval patterns saved in DateIntervalInfo\n     *    includes \"dMMMy\", but not \"dMMMMy\".\n     *    Need to get interval patterns for dMMMMy from dMMMy.\n     *    Another example, the interval patterns saved in DateIntervalInfo\n     *    includes \"hmv\", but not \"hmz\".\n     *    Need to get interval patterns for \"hmz' from 'hmv'\n     *\n     * 2. there might be no pattern for 'y' differ for skeleton \"Md\",\n     *    in order to get interval patterns for 'y' differ,\n     *    need to look for it from skeleton 'yMd'\n     *\n     * @param dateSkeleton   normalized date skeleton\n     * @param timeSkeleton   normalized time skeleton\n     * @return               whether the resource is found for the skeleton.\n     *                       TRUE if interval pattern found for the skeleton,\n     *                       FALSE otherwise.\n     * @internal ICU 4.0\n     */\n    UBool setSeparateDateTimePtn(const UnicodeString& dateSkeleton,\n                                 const UnicodeString& timeSkeleton);\n\n\n\n\n    /**\n     * Generate interval pattern from existing resource\n     *\n     * It not only save the interval patterns,\n     * but also return the extended skeleton and its best match skeleton.\n     *\n     * @param field           largest different calendar field\n     * @param skeleton        skeleton\n     * @param bestSkeleton    the best match skeleton which has interval pattern\n     *                        defined in resource\n     * @param differenceInfo  the difference between skeleton and best skeleton\n     *         0 means the best matched skeleton is the same as input skeleton\n     *         1 means the fields are the same, but field width are different\n     *         2 means the only difference between fields are v/z,\n     *        -1 means there are other fields difference\n     *\n     * @param extendedSkeleton      extended skeleton\n     * @param extendedBestSkeleton  extended best match skeleton\n     * @return                      whether the interval pattern is found\n     *                              through extending skeleton or not.\n     *                              TRUE if interval pattern is found by\n     *                              extending skeleton, FALSE otherwise.\n     * @internal ICU 4.0\n     */\n    UBool setIntervalPattern(UCalendarDateFields field,\n                             const UnicodeString* skeleton,\n                             const UnicodeString* bestSkeleton,\n                             int8_t differenceInfo,\n                             UnicodeString* extendedSkeleton = NULL,\n                             UnicodeString* extendedBestSkeleton = NULL);\n\n    /**\n     * Adjust field width in best match interval pattern to match\n     * the field width in input skeleton.\n     *\n     * TODO (xji) make a general solution\n     * The adjusting rule can be:\n     * 1. always adjust\n     * 2. never adjust\n     * 3. default adjust, which means adjust according to the following rules\n     * 3.1 always adjust string, such as MMM and MMMM\n     * 3.2 never adjust between string and numeric, such as MM and MMM\n     * 3.3 always adjust year\n     * 3.4 do not adjust 'd', 'h', or 'm' if h presents\n     * 3.5 do not adjust 'M' if it is numeric(?)\n     *\n     * Since date interval format is well-formed format,\n     * date and time skeletons are normalized previously,\n     * till this stage, the adjust here is only \"adjust strings, such as MMM\n     * and MMMM, EEE and EEEE.\n     *\n     * @param inputSkeleton            the input skeleton\n     * @param bestMatchSkeleton        the best match skeleton\n     * @param bestMatchIntervalPattern the best match interval pattern\n     * @param differenceInfo           the difference between 2 skeletons\n     *                                 1 means only field width differs\n     *                                 2 means v/z exchange\n     * @param adjustedIntervalPattern  adjusted interval pattern\n     * @internal ICU 4.0\n     */\n    static void U_EXPORT2 adjustFieldWidth(\n                            const UnicodeString& inputSkeleton,\n                            const UnicodeString& bestMatchSkeleton,\n                            const UnicodeString& bestMatchIntervalPattern,\n                            int8_t differenceInfo,\n                            UnicodeString& adjustedIntervalPattern);\n\n    /**\n     * Concat a single date pattern with a time interval pattern,\n     * set it into the intervalPatterns, while field is time field.\n     * This is used to handle time interval patterns on skeleton with\n     * both time and date. Present the date followed by\n     * the range expression for the time.\n     * @param format         date and time format\n     * @param formatLen      format string length\n     * @param datePattern    date pattern\n     * @param field          time calendar field: AM_PM, HOUR, MINUTE\n     * @param status         output param set to success/failure code on exit\n     * @internal ICU 4.0\n     */\n    void concatSingleDate2TimeInterval(const UChar* format,\n                                       int32_t formatLen,\n                                       const UnicodeString& datePattern,\n                                       UCalendarDateFields field,\n                                       UErrorCode& status);\n\n    /**\n     * check whether a calendar field present in a skeleton.\n     * @param field      calendar field need to check\n     * @param skeleton   given skeleton on which to check the calendar field\n     * @return           true if field present in a skeleton.\n     * @internal ICU 4.0\n     */\n    static UBool U_EXPORT2 fieldExistsInSkeleton(UCalendarDateFields field,\n                                                 const UnicodeString& skeleton);\n\n\n    /**\n     * Split interval patterns into 2 part.\n     * @param intervalPattern  interval pattern\n     * @return the index in interval pattern which split the pattern into 2 part\n     * @internal ICU 4.0\n     */\n    static int32_t  U_EXPORT2 splitPatternInto2Part(const UnicodeString& intervalPattern);\n\n\n    /**\n     * Break interval patterns as 2 part and save them into pattern info.\n     * @param field            calendar field\n     * @param intervalPattern  interval pattern\n     * @internal ICU 4.0\n     */\n    void setIntervalPattern(UCalendarDateFields field,\n                            const UnicodeString& intervalPattern);\n\n\n    /**\n     * Break interval patterns as 2 part and save them into pattern info.\n     * @param field            calendar field\n     * @param intervalPattern  interval pattern\n     * @param laterDateFirst   whether later date appear first in interval pattern\n     * @internal ICU 4.0\n     */\n    void setIntervalPattern(UCalendarDateFields field,\n                            const UnicodeString& intervalPattern,\n                            UBool laterDateFirst);\n\n\n    /**\n     * Set pattern information.\n     *\n     * @param field            calendar field\n     * @param firstPart        the first part in interval pattern\n     * @param secondPart       the second part in interval pattern\n     * @param laterDateFirst   whether the first date in intervalPattern\n     *                         is earlier date or later date\n     * @internal ICU 4.0\n     */\n    void setPatternInfo(UCalendarDateFields field,\n                        const UnicodeString* firstPart,\n                        const UnicodeString* secondPart,\n                        UBool laterDateFirst);\n\n\n    // from calendar field to pattern letter\n    static const UChar fgCalendarFieldToPatternLetter[];\n\n\n    /**\n     * The interval patterns for this locale.\n     */\n    DateIntervalInfo*     fInfo;\n\n    /**\n     * The DateFormat object used to format single pattern\n     */\n    SimpleDateFormat*     fDateFormat;\n\n    /**\n     * The 2 calendars with the from and to date.\n     * could re-use the calendar in fDateFormat,\n     * but keeping 2 calendars make it clear and clean.\n     */\n    Calendar* fFromCalendar;\n    Calendar* fToCalendar;\n\n    /**\n     * Date time pattern generator\n     */\n    DateTimePatternGenerator* fDtpng;\n\n    /**\n     * Following are interval information relavent (locale) to this formatter.\n     */\n    UnicodeString fSkeleton;\n    PatternInfo fIntervalPatterns[DateIntervalInfo::kIPI_MAX_INDEX];\n};\n\ninline UBool\nDateIntervalFormat::operator!=(const Format& other) const  {\n    return !operator==(other);\n}\n\nU_NAMESPACE_END\n\n#endif /* #if !UCONFIG_NO_FORMATTING */\n\n#endif // _DTITVFMT_H__\n//eof\n"
  },
  {
    "path": "deprecated/android/addons/icucompat/unicode/dtitvinf.h",
    "content": "/*\n *******************************************************************************\n * Copyright (C) 2008-2011, International Business Machines Corporation and\n * others. All Rights Reserved.\n *******************************************************************************\n *\n * File DTITVINF.H\n *\n *******************************************************************************\n */\n\n#ifndef __DTITVINF_H__\n#define __DTITVINF_H__\n\n#include \"unicode/utypes.h\"\n\n/**\n * \\file\n * \\brief C++ API: Date/Time interval patterns for formatting date/time interval\n */\n\n#if !UCONFIG_NO_FORMATTING\n\n#include \"unicode/udat.h\"\n#include \"unicode/locid.h\"\n#include \"unicode/ucal.h\"\n#include \"unicode/dtptngen.h\"\n\nU_NAMESPACE_BEGIN\n\n/**\n * DateIntervalInfo is a public class for encapsulating localizable\n * date time interval patterns. It is used by DateIntervalFormat.\n *\n * <P>\n * For most users, ordinary use of DateIntervalFormat does not need to create\n * DateIntervalInfo object directly.\n * DateIntervalFormat will take care of it when creating a date interval\n * formatter when user pass in skeleton and locale.\n *\n * <P>\n * For power users, who want to create their own date interval patterns,\n * or want to re-set date interval patterns, they could do so by\n * directly creating DateIntervalInfo and manupulating it.\n *\n * <P>\n * Logically, the interval patterns are mappings\n * from (skeleton, the_largest_different_calendar_field)\n * to (date_interval_pattern).\n *\n * <P>\n * A skeleton \n * <ol>\n * <li>\n * only keeps the field pattern letter and ignores all other parts \n * in a pattern, such as space, punctuations, and string literals.\n * <li>\n * hides the order of fields. \n * <li>\n * might hide a field's pattern letter length.\n *\n * For those non-digit calendar fields, the pattern letter length is \n * important, such as MMM, MMMM, and MMMMM; EEE and EEEE, \n * and the field's pattern letter length is honored.\n *    \n * For the digit calendar fields,  such as M or MM, d or dd, yy or yyyy, \n * the field pattern length is ignored and the best match, which is defined \n * in date time patterns, will be returned without honor the field pattern\n * letter length in skeleton.\n * </ol>\n *\n * <P>\n * The calendar fields we support for interval formatting are:\n * year, month, date, day-of-week, am-pm, hour, hour-of-day, and minute.\n * Those calendar fields can be defined in the following order:\n * year >  month > date > am-pm > hour >  minute \n *  \n * The largest different calendar fields between 2 calendars is the\n * first different calendar field in above order.\n *\n * For example: the largest different calendar fields between &quot;Jan 10, 2007&quot; \n * and &quot;Feb 20, 2008&quot; is year.\n *   \n * <P>\n * There is a set of pre-defined static skeleton strings.\n * There are pre-defined interval patterns for those pre-defined skeletons\n * in locales' resource files.\n * For example, for a skeleton UDAT_YEAR_ABBR_MONTH_DAY, which is  &quot;yMMMd&quot;,\n * in  en_US, if the largest different calendar field between date1 and date2 \n * is &quot;year&quot;, the date interval pattern  is &quot;MMM d, yyyy - MMM d, yyyy&quot;, \n * such as &quot;Jan 10, 2007 - Jan 10, 2008&quot;.\n * If the largest different calendar field between date1 and date2 is &quot;month&quot;,\n * the date interval pattern is &quot;MMM d - MMM d, yyyy&quot;,\n * such as &quot;Jan 10 - Feb 10, 2007&quot;.\n * If the largest different calendar field between date1 and date2 is &quot;day&quot;,\n * the date interval pattern is &quot;MMM d-d, yyyy&quot;, such as &quot;Jan 10-20, 2007&quot;.\n *\n * For date skeleton, the interval patterns when year, or month, or date is \n * different are defined in resource files.\n * For time skeleton, the interval patterns when am/pm, or hour, or minute is\n * different are defined in resource files.\n *\n *\n * <P>\n * There are 2 dates in interval pattern. For most locales, the first date\n * in an interval pattern is the earlier date. There might be a locale in which\n * the first date in an interval pattern is the later date.\n * We use fallback format for the default order for the locale.\n * For example, if the fallback format is &quot;{0} - {1}&quot;, it means\n * the first date in the interval pattern for this locale is earlier date.\n * If the fallback format is &quot;{1} - {0}&quot;, it means the first date is the \n * later date.\n * For a particular interval pattern, the default order can be overriden\n * by prefixing &quot;latestFirst:&quot; or &quot;earliestFirst:&quot; to the interval pattern.\n * For example, if the fallback format is &quot;{0}-{1}&quot;,\n * but for skeleton &quot;yMMMd&quot;, the interval pattern when day is different is \n * &quot;latestFirst:d-d MMM yy&quot;, it means by default, the first date in interval\n * pattern is the earlier date. But for skeleton &quot;yMMMd&quot;, when day is different,\n * the first date in &quot;d-d MMM yy&quot; is the later date.\n * \n * <P>\n * The recommended way to create a DateIntervalFormat object is to pass in \n * the locale. \n * By using a Locale parameter, the DateIntervalFormat object is \n * initialized with the pre-defined interval patterns for a given or \n * default locale.\n * <P>\n * Users can also create DateIntervalFormat object \n * by supplying their own interval patterns.\n * It provides flexibility for power users.\n *\n * <P>\n * After a DateIntervalInfo object is created, clients may modify\n * the interval patterns using setIntervalPattern function as so desired.\n * Currently, users can only set interval patterns when the following \n * calendar fields are different: ERA, YEAR, MONTH, DATE,  DAY_OF_MONTH, \n * DAY_OF_WEEK, AM_PM,  HOUR, HOUR_OF_DAY, and MINUTE.\n * Interval patterns when other calendar fields are different is not supported.\n * <P>\n * DateIntervalInfo objects are cloneable. \n * When clients obtain a DateIntervalInfo object, \n * they can feel free to modify it as necessary.\n * <P>\n * DateIntervalInfo are not expected to be subclassed. \n * Data for a calendar is loaded out of resource bundles. \n * Through ICU 4.4, date interval patterns are only supported in the Gregorian\n * calendar; non-Gregorian calendars are supported from ICU 4.4.1. \n * @stable ICU 4.0\n**/\n\nclass U_I18N_API DateIntervalInfo : public UObject {\npublic:\n#ifndef U_HIDE_INTERNAL_API\n    /**\n     * Default constructor.\n     * It does not initialize any interval patterns except\n     * that it initialize default fall-back pattern as \"{0} - {1}\",\n     * which can be reset by setFallbackIntervalPattern().\n     * It should be followed by setFallbackIntervalPattern() and \n     * setIntervalPattern(), \n     * and is recommended to be used only for power users who\n     * wants to create their own interval patterns and use them to create\n     * date interval formatter.\n     * @param status   output param set to success/failure code on exit\n     * @internal ICU 4.0\n     */\n    DateIntervalInfo(UErrorCode& status);\n#endif  /* U_HIDE_INTERNAL_API */\n\n\n    /** \n     * Construct DateIntervalInfo for the given locale,\n     * @param locale  the interval patterns are loaded from the appropriate calendar\n     *                data (specified calendar or default calendar) in this locale.\n     * @param status  output param set to success/failure code on exit\n     * @stable ICU 4.0\n     */\n    DateIntervalInfo(const Locale& locale, UErrorCode& status);\n\n\n    /**\n     * Copy constructor.\n     * @stable ICU 4.0\n     */\n    DateIntervalInfo(const DateIntervalInfo&);\n\n    /**\n     * Assignment operator\n     * @stable ICU 4.0\n     */\n    DateIntervalInfo& operator=(const DateIntervalInfo&);\n\n    /**\n     * Clone this object polymorphically.\n     * The caller owns the result and should delete it when done.\n     * @return   a copy of the object\n     * @stable ICU 4.0\n     */\n    virtual DateIntervalInfo* clone(void) const;\n\n    /**\n     * Destructor.\n     * It is virtual to be safe, but it is not designed to be subclassed.\n     * @stable ICU 4.0\n     */\n    virtual ~DateIntervalInfo();\n\n\n    /**\n     * Return true if another object is semantically equal to this one.\n     *\n     * @param other    the DateIntervalInfo object to be compared with.\n     * @return         true if other is semantically equal to this.\n     * @stable ICU 4.0\n     */\n    virtual UBool operator==(const DateIntervalInfo& other) const;\n\n    /**\n     * Return true if another object is semantically unequal to this one.\n     *\n     * @param other    the DateIntervalInfo object to be compared with.\n     * @return         true if other is semantically unequal to this.\n     * @stable ICU 4.0\n     */\n    UBool operator!=(const DateIntervalInfo& other) const;\n\n\n\n    /** \n     * Provides a way for client to build interval patterns.\n     * User could construct DateIntervalInfo by providing a list of skeletons\n     * and their patterns.\n     * <P>\n     * For example:\n     * <pre>\n     * UErrorCode status = U_ZERO_ERROR;\n     * DateIntervalInfo dIntervalInfo = new DateIntervalInfo();\n     * dIntervalInfo->setFallbackIntervalPattern(\"{0} ~ {1}\");\n     * dIntervalInfo->setIntervalPattern(\"yMd\", UCAL_YEAR, \"'from' yyyy-M-d 'to' yyyy-M-d\", status); \n     * dIntervalInfo->setIntervalPattern(\"yMMMd\", UCAL_MONTH, \"'from' yyyy MMM d 'to' MMM d\", status);\n     * dIntervalInfo->setIntervalPattern(\"yMMMd\", UCAL_DAY, \"yyyy MMM d-d\", status, status);\n     * </pre>\n     *\n     * Restriction: \n     * Currently, users can only set interval patterns when the following \n     * calendar fields are different: ERA, YEAR, MONTH, DATE,  DAY_OF_MONTH, \n     * DAY_OF_WEEK, AM_PM,  HOUR, HOUR_OF_DAY, and MINUTE.\n     * Interval patterns when other calendar fields are different are \n     * not supported.\n     *\n     * @param skeleton         the skeleton on which interval pattern based\n     * @param lrgDiffCalUnit   the largest different calendar unit.\n     * @param intervalPattern  the interval pattern on the largest different\n     *                         calendar unit.\n     *                         For example, if lrgDiffCalUnit is \n     *                         \"year\", the interval pattern for en_US when year\n     *                         is different could be \"'from' yyyy 'to' yyyy\".\n     * @param status           output param set to success/failure code on exit\n     * @stable ICU 4.0\n     */\n    void setIntervalPattern(const UnicodeString& skeleton, \n                            UCalendarDateFields lrgDiffCalUnit, \n                            const UnicodeString& intervalPattern,\n                            UErrorCode& status);\n\n    /**\n     * Get the interval pattern given skeleton and \n     * the largest different calendar field.\n     * @param skeleton   the skeleton\n     * @param field      the largest different calendar field\n     * @param result     output param to receive the pattern\n     * @param status     output param set to success/failure code on exit\n     * @return a reference to 'result'\n     * @stable ICU 4.0 \n     */\n    UnicodeString& getIntervalPattern(const UnicodeString& skeleton,\n                                      UCalendarDateFields field,\n                                      UnicodeString& result,\n                                      UErrorCode& status) const; \n\n    /**\n     * Get the fallback interval pattern.\n     * @param  result   output param to receive the pattern\n     * @return a reference to 'result'\n     * @stable ICU 4.0 \n     */\n    UnicodeString& getFallbackIntervalPattern(UnicodeString& result) const;\n\n\n    /**\n     * Re-set the fallback interval pattern.\n     *\n     * In construction, default fallback pattern is set as \"{0} - {1}\".\n     * And constructor taking locale as parameter will set the\n     * fallback pattern as what defined in the locale resource file.\n     *\n     * This method provides a way for user to replace the fallback pattern.\n     *\n     * @param fallbackPattern  fall-back interval pattern.\n     * @param status           output param set to success/failure code on exit\n     * @stable ICU 4.0 \n     */\n    void setFallbackIntervalPattern(const UnicodeString& fallbackPattern,\n                                    UErrorCode& status);\n\n\n    /** Get default order -- whether the first date in pattern is later date\n                             or not.\n     * return default date ordering in interval pattern. TRUE if the first date\n     *        in pattern is later date, FALSE otherwise.\n     * @stable ICU 4.0 \n     */\n    UBool getDefaultOrder() const;\n\n\n    /**\n     * ICU \"poor man's RTTI\", returns a UClassID for the actual class.\n     *\n     * @stable ICU 4.0\n     */\n    virtual UClassID getDynamicClassID() const;\n\n    /**\n     * ICU \"poor man's RTTI\", returns a UClassID for this class.\n     *\n     * @stable ICU 4.0\n     */\n    static UClassID U_EXPORT2 getStaticClassID();\n\n\nprivate:\n    /**\n     * DateIntervalFormat will need access to\n     * getBestSkeleton(), parseSkeleton(), enum IntervalPatternIndex,\n     * and calendarFieldToPatternIndex().\n     *\n     * Instead of making above public,\n     * make DateIntervalFormat a friend of DateIntervalInfo.\n     */\n    friend class DateIntervalFormat;\n\n    /**\n     * Following is for saving the interval patterns.\n     * We only support interval patterns on\n     * ERA, YEAR, MONTH, DAY, AM_PM, HOUR, and MINUTE\n     */\n    enum IntervalPatternIndex\n    {\n        kIPI_ERA,\n        kIPI_YEAR,\n        kIPI_MONTH,\n        kIPI_DATE,\n        kIPI_AM_PM,\n        kIPI_HOUR,\n        kIPI_MINUTE,\n        kIPI_MAX_INDEX\n    };\npublic:\n#ifndef U_HIDE_INTERNAL_API\n    /**\n     * Max index for stored interval patterns\n     * @internal ICU 4.4 \n     */\n     enum {\n         kMaxIntervalPatternIndex = kIPI_MAX_INDEX\n     };\n#endif  /* U_HIDE_INTERNAL_API */\nprivate:\n\n\n    /** \n     * Initialize the DateIntervalInfo from locale\n     * @param locale   the given locale.\n     * @param status   output param set to success/failure code on exit\n     * @internal ICU 4.0 \n     */\n    void initializeData(const Locale& locale, UErrorCode& status);\n\n\n    /* Set Interval pattern.\n     *\n     * It sets interval pattern into the hash map.\n     *\n     * @param skeleton         skeleton on which the interval pattern based\n     * @param lrgDiffCalUnit   the largest different calendar unit.\n     * @param intervalPattern  the interval pattern on the largest different\n     *                         calendar unit.\n     * @param status           output param set to success/failure code on exit\n     * @internal ICU 4.0\n     */\n    void setIntervalPatternInternally(const UnicodeString& skeleton,\n                                      UCalendarDateFields lrgDiffCalUnit,\n                                      const UnicodeString& intervalPattern,\n                                      UErrorCode& status); \n\n\n    /**given an input skeleton, get the best match skeleton \n     * which has pre-defined interval pattern in resource file.\n     * Also return the difference between the input skeleton\n     * and the best match skeleton.\n     *\n     * TODO (xji): set field weight or\n     *             isolate the funtionality in DateTimePatternGenerator\n     * @param  skeleton               input skeleton\n     * @param  bestMatchDistanceInfo  the difference between input skeleton\n     *                                and best match skeleton.\n     *         0, if there is exact match for input skeleton\n     *         1, if there is only field width difference between \n     *            the best match and the input skeleton\n     *         2, the only field difference is 'v' and 'z'\n     *        -1, if there is calendar field difference between\n     *            the best match and the input skeleton\n     * @return                        best match skeleton\n     * @internal ICU 4.0\n     */\n    const UnicodeString* getBestSkeleton(const UnicodeString& skeleton,\n                                         int8_t& bestMatchDistanceInfo) const;\n\n\n    /**\n     * Parse skeleton, save each field's width.\n     * It is used for looking for best match skeleton,\n     * and adjust pattern field width.\n     * @param skeleton            skeleton to be parsed\n     * @param skeletonFieldWidth  parsed skeleton field width\n     * @internal ICU 4.0\n     */\n    static void U_EXPORT2 parseSkeleton(const UnicodeString& skeleton, \n                                        int32_t* skeletonFieldWidth);\n\n\n    /**\n     * Check whether one field width is numeric while the other is string.\n     *\n     * TODO (xji): make it general\n     *\n     * @param fieldWidth          one field width\n     * @param anotherFieldWidth   another field width\n     * @param patternLetter       pattern letter char\n     * @return true if one field width is numeric and the other is string,\n     *         false otherwise.\n     * @internal ICU 4.0\n     */\n    static UBool U_EXPORT2 stringNumeric(int32_t fieldWidth,\n                                         int32_t anotherFieldWidth,\n                                         char patternLetter);\n\n\n    /** \n     * Convert calendar field to the interval pattern index in \n     * hash table.\n     *\n     * Since we only support the following calendar fields: \n     * ERA, YEAR, MONTH, DATE,  DAY_OF_MONTH, DAY_OF_WEEK, \n     * AM_PM,  HOUR, HOUR_OF_DAY, and MINUTE,\n     * We reserve only 4 interval patterns for a skeleton.\n     *\n     * @param field    calendar field\n     * @param status   output param set to success/failure code on exit\n     * @return  interval pattern index in hash table\n     * @internal ICU 4.0\n     */\n    static IntervalPatternIndex U_EXPORT2 calendarFieldToIntervalIndex(\n                                                      UCalendarDateFields field,\n                                                      UErrorCode& status);\n\n\n    /**\n     * delete hash table (of type fIntervalPatterns).\n     *\n     * @param hTable  hash table to be deleted\n     * @internal ICU 4.0\n     */\n    void deleteHash(Hashtable* hTable);\n\n\n    /**\n     * initialize hash table (of type fIntervalPatterns).\n     *\n     * @param status   output param set to success/failure code on exit\n     * @return         hash table initialized\n     * @internal ICU 4.0\n     */\n    Hashtable* initHash(UErrorCode& status);\n\n\n\n    /**\n     * copy hash table (of type fIntervalPatterns).\n     *\n     * @param source   the source to copy from\n     * @param target   the target to copy to\n     * @param status   output param set to success/failure code on exit\n     * @internal ICU 4.0\n     */\n    void copyHash(const Hashtable* source, Hashtable* target, UErrorCode& status);\n\n\n    // data members\n    // fallback interval pattern \n    UnicodeString fFallbackIntervalPattern;\n    // default order\n    UBool fFirstDateInPtnIsLaterDate;\n\n    // HashMap<UnicodeString, UnicodeString[kIPI_MAX_INDEX]>\n    // HashMap( skeleton, pattern[largest_different_field] )\n    Hashtable* fIntervalPatterns;\n\n};// end class DateIntervalInfo\n\n\ninline UBool\nDateIntervalInfo::operator!=(const DateIntervalInfo& other) const {\n    return !operator==(other);\n}\n\n\nU_NAMESPACE_END\n\n#endif\n\n#endif\n\n"
  },
  {
    "path": "deprecated/android/addons/icucompat/unicode/dtptngen.h",
    "content": "/*\n*******************************************************************************\n* Copyright (C) 2007-2011, International Business Machines Corporation and\n* others. All Rights Reserved.\n*******************************************************************************\n*\n* File DTPTNGEN.H\n*\n*******************************************************************************\n*/\n\n#ifndef __DTPTNGEN_H__\n#define __DTPTNGEN_H__\n\n#include \"unicode/datefmt.h\"\n#include \"unicode/locid.h\"\n#include \"unicode/udat.h\"\n#include \"unicode/udatpg.h\"\n\nU_NAMESPACE_BEGIN\n\n/**\n * \\file\n * \\brief C++ API: Date/Time Pattern Generator\n */\n\n\nclass Hashtable;\nclass FormatParser;\nclass DateTimeMatcher;\nclass DistanceInfo;\nclass PatternMap;\nclass PtnSkeleton;\n\n/**\n * This class provides flexible generation of date format patterns, like \"yy-MM-dd\". \n * The user can build up the generator by adding successive patterns. Once that \n * is done, a query can be made using a \"skeleton\", which is a pattern which just\n * includes the desired fields and lengths. The generator will return the \"best fit\" \n * pattern corresponding to that skeleton.\n * <p>The main method people will use is getBestPattern(String skeleton),\n * since normally this class is pre-built with data from a particular locale. \n * However, generators can be built directly from other data as well.\n * <p><i>Issue: may be useful to also have a function that returns the list of \n * fields in a pattern, in order, since we have that internally.\n * That would be useful for getting the UI order of field elements.</i>\n * @stable ICU 3.8\n**/\nclass U_I18N_API DateTimePatternGenerator : public UObject {\npublic:\n    /**\n     * Construct a flexible generator according to default locale.\n     * @param status  Output param set to success/failure code on exit,\n     *               which must not indicate a failure before the function call.\n     * @stable ICU 3.8\n     */\n    static DateTimePatternGenerator* U_EXPORT2 createInstance(UErrorCode& status);\n\n    /**\n     * Construct a flexible generator according to data for a given locale.\n     * @param uLocale\n     * @param status  Output param set to success/failure code on exit,\n     *               which must not indicate a failure before the function call.\n     * @stable ICU 3.8\n     */\n    static DateTimePatternGenerator* U_EXPORT2 createInstance(const Locale& uLocale, UErrorCode& status);\n\n    /**\n     * Create an empty generator, to be constructed with addPattern(...) etc.\n     * @param status  Output param set to success/failure code on exit,\n     *               which must not indicate a failure before the function call.\n     * @stable ICU 3.8\n     */\n     static DateTimePatternGenerator* U_EXPORT2 createEmptyInstance(UErrorCode& status);\n     \n    /**\n     * Destructor.\n     * @stable ICU 3.8\n     */\n    virtual ~DateTimePatternGenerator();\n\n    /**\n     * Clone DateTimePatternGenerator object. Clients are responsible for \n     * deleting the DateTimePatternGenerator object cloned.\n     * @stable ICU 3.8\n     */\n    DateTimePatternGenerator* clone() const;\n\n     /**\n      * Return true if another object is semantically equal to this one.\n      *\n      * @param other    the DateTimePatternGenerator object to be compared with.\n      * @return         true if other is semantically equal to this.\n      * @stable ICU 3.8\n      */\n    UBool operator==(const DateTimePatternGenerator& other) const;\n    \n    /**\n     * Return true if another object is semantically unequal to this one.\n     *\n     * @param other    the DateTimePatternGenerator object to be compared with.\n     * @return         true if other is semantically unequal to this.\n     * @stable ICU 3.8\n     */\n    UBool operator!=(const DateTimePatternGenerator& other) const;\n\n    /**\n     * Utility to return a unique skeleton from a given pattern. For example,\n     * both \"MMM-dd\" and \"dd/MMM\" produce the skeleton \"MMMdd\".\n     *\n     * @param pattern   Input pattern, such as \"dd/MMM\"\n     * @param status  Output param set to success/failure code on exit,\n     *                  which must not indicate a failure before the function call.\n     * @return skeleton such as \"MMMdd\"\n     * @stable ICU 3.8\n     */\n    UnicodeString getSkeleton(const UnicodeString& pattern, UErrorCode& status);\n\n    /**\n     * Utility to return a unique base skeleton from a given pattern. This is\n     * the same as the skeleton, except that differences in length are minimized\n     * so as to only preserve the difference between string and numeric form. So\n     * for example, both \"MMM-dd\" and \"d/MMM\" produce the skeleton \"MMMd\"\n     * (notice the single d).\n     *\n     * @param pattern  Input pattern, such as \"dd/MMM\"\n     * @param status  Output param set to success/failure code on exit,\n     *               which must not indicate a failure before the function call.\n     * @return base skeleton, such as \"Md\"\n     * @stable ICU 3.8\n     */\n    UnicodeString getBaseSkeleton(const UnicodeString& pattern, UErrorCode& status);\n\n    /**\n     * Adds a pattern to the generator. If the pattern has the same skeleton as\n     * an existing pattern, and the override parameter is set, then the previous\n     * value is overriden. Otherwise, the previous value is retained. In either\n     * case, the conflicting status is set and previous vale is stored in \n     * conflicting pattern.\n     * <p>\n     * Note that single-field patterns (like \"MMM\") are automatically added, and\n     * don't need to be added explicitly!\n     *\n     * @param pattern   Input pattern, such as \"dd/MMM\"\n     * @param override  When existing values are to be overridden use true, \n     *                   otherwise use false.\n     * @param conflictingPattern  Previous pattern with the same skeleton.\n     * @param status  Output param set to success/failure code on exit,\n     *               which must not indicate a failure before the function call.\n     * @return conflicting status.  The value could be UDATPG_NO_CONFLICT, \n     *                             UDATPG_BASE_CONFLICT or UDATPG_CONFLICT.\n     * @stable ICU 3.8\n     */\n    UDateTimePatternConflict addPattern(const UnicodeString& pattern, \n                                        UBool override, \n                                        UnicodeString& conflictingPattern,\n                                        UErrorCode& status);\n\n    /**\n     * An AppendItem format is a pattern used to append a field if there is no\n     * good match. For example, suppose that the input skeleton is \"GyyyyMMMd\",\n     * and there is no matching pattern internally, but there is a pattern\n     * matching \"yyyyMMMd\", say \"d-MM-yyyy\". Then that pattern is used, plus the\n     * G. The way these two are conjoined is by using the AppendItemFormat for G\n     * (era). So if that value is, say \"{0}, {1}\" then the final resulting\n     * pattern is \"d-MM-yyyy, G\".\n     * <p>\n     * There are actually three available variables: {0} is the pattern so far,\n     * {1} is the element we are adding, and {2} is the name of the element.\n     * <p>\n     * This reflects the way that the CLDR data is organized.\n     *\n     * @param field  such as UDATPG_ERA_FIELD.\n     * @param value  pattern, such as \"{0}, {1}\"\n     * @stable ICU 3.8\n     */\n    void setAppendItemFormat(UDateTimePatternField field, const UnicodeString& value);\n\n    /**\n     * Getter corresponding to setAppendItemFormat. Values below 0 or at or\n     * above UDATPG_FIELD_COUNT are illegal arguments.\n     *\n     * @param  field  such as UDATPG_ERA_FIELD.\n     * @return append pattern for field\n     * @stable ICU 3.8\n     */\n    const UnicodeString& getAppendItemFormat(UDateTimePatternField field) const;\n\n    /**\n     * Sets the names of field, eg \"era\" in English for ERA. These are only\n     * used if the corresponding AppendItemFormat is used, and if it contains a\n     * {2} variable.\n     * <p>\n     * This reflects the way that the CLDR data is organized.\n     *\n     * @param field   such as UDATPG_ERA_FIELD.\n     * @param value   name of the field\n     * @stable ICU 3.8\n     */\n    void setAppendItemName(UDateTimePatternField field, const UnicodeString& value);\n\n    /**\n     * Getter corresponding to setAppendItemNames. Values below 0 or at or above\n     * UDATPG_FIELD_COUNT are illegal arguments.\n     *\n     * @param field  such as UDATPG_ERA_FIELD.\n     * @return name for field\n     * @stable ICU 3.8\n     */\n    const UnicodeString& getAppendItemName(UDateTimePatternField field) const;\n\n    /**\n     * The date time format is a message format pattern used to compose date and\n     * time patterns. The default value is \"{0} {1}\", where {0} will be replaced\n     * by the date pattern and {1} will be replaced by the time pattern.\n     * <p>\n     * This is used when the input skeleton contains both date and time fields,\n     * but there is not a close match among the added patterns. For example,\n     * suppose that this object was created by adding \"dd-MMM\" and \"hh:mm\", and\n     * its datetimeFormat is the default \"{0} {1}\". Then if the input skeleton\n     * is \"MMMdhmm\", there is not an exact match, so the input skeleton is\n     * broken up into two components \"MMMd\" and \"hmm\". There are close matches\n     * for those two skeletons, so the result is put together with this pattern,\n     * resulting in \"d-MMM h:mm\".\n     *\n     * @param dateTimeFormat\n     *            message format pattern, here {0} will be replaced by the date\n     *            pattern and {1} will be replaced by the time pattern.\n     * @stable ICU 3.8\n     */\n    void setDateTimeFormat(const UnicodeString& dateTimeFormat);\n\n    /**\n     * Getter corresponding to setDateTimeFormat.\n     * @return DateTimeFormat.\n     * @stable ICU 3.8\n     */\n    const UnicodeString& getDateTimeFormat() const;\n\n    /**\n     * Return the best pattern matching the input skeleton. It is guaranteed to\n     * have all of the fields in the skeleton.\n     *\n     * @param skeleton\n     *            The skeleton is a pattern containing only the variable fields.\n     *            For example, \"MMMdd\" and \"mmhh\" are skeletons.\n     * @param status  Output param set to success/failure code on exit,\n     *               which must not indicate a failure before the function call.\n     * @return bestPattern\n     *            The best pattern found from the given skeleton.\n     * @stable ICU 3.8\n     */\n     UnicodeString getBestPattern(const UnicodeString& skeleton, UErrorCode& status);\n\n\n    /**\n     * Return the best pattern matching the input skeleton. It is guaranteed to\n     * have all of the fields in the skeleton.\n     *\n     * @param skeleton\n     *            The skeleton is a pattern containing only the variable fields.\n     *            For example, \"MMMdd\" and \"mmhh\" are skeletons.\n     * @param options\n     *            Options for forcing the length of specified fields in the\n     *            returned pattern to match those in the skeleton (when this\n     *            would not happen otherwise). For default behavior, use\n     *            UDATPG_MATCH_NO_OPTIONS.\n     * @param status\n     *            Output param set to success/failure code on exit,\n     *            which must not indicate a failure before the function call.\n     * @return bestPattern\n     *            The best pattern found from the given skeleton.\n     * @stable ICU 4.4\n     */\n     UnicodeString getBestPattern(const UnicodeString& skeleton,\n                                  UDateTimePatternMatchOptions options,\n                                  UErrorCode& status);\n\n\n    /**\n     * Adjusts the field types (width and subtype) of a pattern to match what is\n     * in a skeleton. That is, if you supply a pattern like \"d-M H:m\", and a\n     * skeleton of \"MMMMddhhmm\", then the input pattern is adjusted to be\n     * \"dd-MMMM hh:mm\". This is used internally to get the best match for the\n     * input skeleton, but can also be used externally.\n     *\n     * @param pattern Input pattern\n     * @param skeleton\n     *            The skeleton is a pattern containing only the variable fields.\n     *            For example, \"MMMdd\" and \"mmhh\" are skeletons.\n     * @param status  Output param set to success/failure code on exit,\n     *               which must not indicate a failure before the function call.\n     * @return pattern adjusted to match the skeleton fields widths and subtypes.\n     * @stable ICU 3.8\n     */\n     UnicodeString replaceFieldTypes(const UnicodeString& pattern, \n                                     const UnicodeString& skeleton, \n                                     UErrorCode& status);\n\n    /**\n     * Adjusts the field types (width and subtype) of a pattern to match what is\n     * in a skeleton. That is, if you supply a pattern like \"d-M H:m\", and a\n     * skeleton of \"MMMMddhhmm\", then the input pattern is adjusted to be\n     * \"dd-MMMM hh:mm\". This is used internally to get the best match for the\n     * input skeleton, but can also be used externally.\n     *\n     * @param pattern Input pattern\n     * @param skeleton\n     *            The skeleton is a pattern containing only the variable fields.\n     *            For example, \"MMMdd\" and \"mmhh\" are skeletons.\n     * @param options\n     *            Options controlling whether the length of specified fields in the\n     *            pattern are adjusted to match those in the skeleton (when this\n     *            would not happen otherwise). For default behavior, use\n     *            UDATPG_MATCH_NO_OPTIONS.\n     * @param status\n     *            Output param set to success/failure code on exit,\n     *            which must not indicate a failure before the function call.\n     * @return pattern adjusted to match the skeleton fields widths and subtypes.\n     * @stable ICU 4.4\n     */\n     UnicodeString replaceFieldTypes(const UnicodeString& pattern, \n                                     const UnicodeString& skeleton, \n                                     UDateTimePatternMatchOptions options,\n                                     UErrorCode& status);\n\n    /**\n     * Return a list of all the skeletons (in canonical form) from this class.\n     *\n     * Call getPatternForSkeleton() to get the corresponding pattern.\n     *\n     * @param status  Output param set to success/failure code on exit,\n     *               which must not indicate a failure before the function call.\n     * @return StringEnumeration with the skeletons.\n     *         The caller must delete the object.\n     * @stable ICU 3.8\n     */\n     StringEnumeration* getSkeletons(UErrorCode& status) const;\n\n     /**\n      * Get the pattern corresponding to a given skeleton.\n      * @param skeleton \n      * @return pattern corresponding to a given skeleton.\n      * @stable ICU 3.8\n      */\n     const UnicodeString& getPatternForSkeleton(const UnicodeString& skeleton) const;\n     \n    /**\n     * Return a list of all the base skeletons (in canonical form) from this class.\n     *\n     * @param status  Output param set to success/failure code on exit,\n     *               which must not indicate a failure before the function call.\n     * @return a StringEnumeration with the base skeletons.\n     *         The caller must delete the object.\n     * @stable ICU 3.8\n     */\n     StringEnumeration* getBaseSkeletons(UErrorCode& status) const;\n\n#ifndef U_HIDE_INTERNAL_API\n     /**\n      * Return a list of redundant patterns are those which if removed, make no \n      * difference in the resulting getBestPattern values. This method returns a \n      * list of them, to help check the consistency of the patterns used to build \n      * this generator.\n      * \n      * @param status  Output param set to success/failure code on exit,\n      *               which must not indicate a failure before the function call.\n      * @return a StringEnumeration with the redundant pattern.\n      *         The caller must delete the object.\n      * @internal ICU 3.8\n      */\n     StringEnumeration* getRedundants(UErrorCode& status);\n#endif  /* U_HIDE_INTERNAL_API */\n\n    /**\n     * The decimal value is used in formatting fractions of seconds. If the\n     * skeleton contains fractional seconds, then this is used with the\n     * fractional seconds. For example, suppose that the input pattern is\n     * \"hhmmssSSSS\", and the best matching pattern internally is \"H:mm:ss\", and\n     * the decimal string is \",\". Then the resulting pattern is modified to be\n     * \"H:mm:ss,SSSS\"\n     *\n     * @param decimal \n     * @stable ICU 3.8\n     */\n    void setDecimal(const UnicodeString& decimal);\n\n    /**\n     * Getter corresponding to setDecimal.\n     * @return UnicodeString corresponding to the decimal point\n     * @stable ICU 3.8\n     */\n    const UnicodeString& getDecimal() const;\n\n    /**\n     * ICU \"poor man's RTTI\", returns a UClassID for the actual class.\n     *\n     * @stable ICU 3.8\n     */\n    virtual UClassID getDynamicClassID() const;\n\n    /**\n     * ICU \"poor man's RTTI\", returns a UClassID for this class.\n     *\n     * @stable ICU 3.8\n     */\n    static UClassID U_EXPORT2 getStaticClassID(void);\n\nprivate:\n    /**\n     * Constructor.\n     * @stable ICU 3.8\n     */\n    DateTimePatternGenerator(UErrorCode & status);\n\n    /**\n     * Constructor.\n     * @stable ICU 3.8\n     */\n    DateTimePatternGenerator(const Locale& locale, UErrorCode & status);\n\n    /**\n     * Copy constructor.\n     * @param other DateTimePatternGenerator to copy\n     * @stable ICU 3.8\n     */\n    DateTimePatternGenerator(const DateTimePatternGenerator& other);\n\n    /**\n     * Default assignment operator.\n     * @param other DateTimePatternGenerator to copy\n     * @stable ICU 3.8\n     */\n    DateTimePatternGenerator& operator=(const DateTimePatternGenerator& other);\n\n    Locale pLocale;  // pattern locale\n    FormatParser *fp;\n    DateTimeMatcher* dtMatcher;\n    DistanceInfo *distanceInfo;\n    PatternMap *patternMap;\n    UnicodeString appendItemFormats[UDATPG_FIELD_COUNT];\n    UnicodeString appendItemNames[UDATPG_FIELD_COUNT];\n    UnicodeString dateTimeFormat;\n    UnicodeString decimal;\n    DateTimeMatcher *skipMatcher;\n    Hashtable *fAvailableFormatKeyHash;\n    UnicodeString hackPattern;\n    UnicodeString emptyString;\n    UChar fDefaultHourFormatChar;\n\n    void initData(const Locale &locale, UErrorCode &status);\n    void addCanonicalItems();\n    void addICUPatterns(const Locale& locale, UErrorCode& status);\n    void hackTimes(const UnicodeString& hackPattern, UErrorCode& status);\n    void addCLDRData(const Locale& locale, UErrorCode& status);\n    UDateTimePatternConflict addPatternWithSkeleton(const UnicodeString& pattern, const UnicodeString * skeletonToUse, UBool override, UnicodeString& conflictingPattern, UErrorCode& status);\n    void initHashtable(UErrorCode& status);\n    void setDateTimeFromCalendar(const Locale& locale, UErrorCode& status);\n    void setDecimalSymbols(const Locale& locale, UErrorCode& status);\n    UDateTimePatternField getAppendFormatNumber(const char* field) const;\n    UDateTimePatternField getAppendNameNumber(const char* field) const;\n    void getAppendName(UDateTimePatternField field, UnicodeString& value);\n    int32_t getCanonicalIndex(const UnicodeString& field);\n    const UnicodeString* getBestRaw(DateTimeMatcher& source, int32_t includeMask, DistanceInfo* missingFields, const PtnSkeleton** specifiedSkeletonPtr = 0);\n    UnicodeString adjustFieldTypes(const UnicodeString& pattern, const PtnSkeleton* specifiedSkeleton, UBool fixFractionalSeconds, UDateTimePatternMatchOptions options = UDATPG_MATCH_NO_OPTIONS);\n    UnicodeString getBestAppending(int32_t missingFields, UDateTimePatternMatchOptions options = UDATPG_MATCH_NO_OPTIONS);\n    int32_t getTopBitNumber(int32_t foundMask);\n    void setAvailableFormat(const UnicodeString &key, UErrorCode& status);\n    UBool isAvailableFormatSet(const UnicodeString &key) const;\n    void copyHashtable(Hashtable *other, UErrorCode &status);\n    UBool isCanonicalItem(const UnicodeString& item) const;\n} ;// end class DateTimePatternGenerator\n\nU_NAMESPACE_END\n\n#endif\n"
  },
  {
    "path": "deprecated/android/addons/icucompat/unicode/dtrule.h",
    "content": "/*\n*******************************************************************************\n* Copyright (C) 2007-2008, International Business Machines Corporation and         *\n* others. All Rights Reserved.                                                *\n*******************************************************************************\n*/\n#ifndef DTRULE_H\n#define DTRULE_H\n\n#include \"unicode/utypes.h\"\n\n/**\n * \\file \n * \\brief C++ API: Rule for specifying date and time in an year\n */\n\n#if !UCONFIG_NO_FORMATTING\n\n#include \"unicode/uobject.h\"\n\nU_NAMESPACE_BEGIN\n/**\n * <code>DateTimeRule</code> is a class representing a time in a year by\n * a rule specified by month, day of month, day of week and\n * time in the day.\n * \n * @stable ICU 3.8\n */\nclass U_I18N_API DateTimeRule : public UObject {\npublic:\n\n    /**\n     * Date rule type constants.\n     * @stable ICU 3.8\n     */\n    enum DateRuleType {\n        DOM = 0,        /**< The exact day of month,\n                             for example, March 11. */\n        DOW,            /**< The Nth occurence of the day of week,\n                             for example, 2nd Sunday in March. */\n        DOW_GEQ_DOM,    /**< The first occurence of the day of week on or after the day of monnth,\n                             for example, first Sunday on or after March 8. */\n        DOW_LEQ_DOM     /**< The last occurence of the day of week on or before the day of month,\n                             for example, first Sunday on or before March 14. */\n    };\n\n    /**\n     * Time rule type constants.\n     * @stable ICU 3.8\n     */\n    enum TimeRuleType {\n        WALL_TIME = 0,  /**< The local wall clock time */\n        STANDARD_TIME,  /**< The local standard time */\n        UTC_TIME        /**< The UTC time */\n    };\n\n    /**\n     * Constructs a <code>DateTimeRule</code> by the day of month and\n     * the time rule.  The date rule type for an instance created by\n     * this constructor is <code>DOM</code>.\n     * \n     * @param month         The rule month, for example, <code>Calendar::JANUARY</code>\n     * @param dayOfMonth    The day of month, 1-based.\n     * @param millisInDay   The milliseconds in the rule date.\n     * @param timeType      The time type, <code>WALL_TIME</code> or <code>STANDARD_TIME</code>\n     *                      or <code>UTC_TIME</code>.\n     * @stable ICU 3.8\n     */\n    DateTimeRule(int32_t month, int32_t dayOfMonth,\n        int32_t millisInDay, TimeRuleType timeType);\n\n    /**\n     * Constructs a <code>DateTimeRule</code> by the day of week and its oridinal\n     * number and the time rule.  The date rule type for an instance created\n     * by this constructor is <code>DOW</code>.\n     * \n     * @param month         The rule month, for example, <code>Calendar::JANUARY</code>.\n     * @param weekInMonth   The ordinal number of the day of week.  Negative number\n     *                      may be used for specifying a rule date counted from the\n     *                      end of the rule month.\n     * @param dayOfWeek     The day of week, for example, <code>Calendar::SUNDAY</code>.\n     * @param millisInDay   The milliseconds in the rule date.\n     * @param timeType      The time type, <code>WALL_TIME</code> or <code>STANDARD_TIME</code>\n     *                      or <code>UTC_TIME</code>.\n     * @stable ICU 3.8\n     */\n    DateTimeRule(int32_t month, int32_t weekInMonth, int32_t dayOfWeek,\n        int32_t millisInDay, TimeRuleType timeType);\n\n    /**\n     * Constructs a <code>DateTimeRule</code> by the first/last day of week\n     * on or after/before the day of month and the time rule.  The date rule\n     * type for an instance created by this constructor is either\n     * <code>DOM_GEQ_DOM</code> or <code>DOM_LEQ_DOM</code>.\n     * \n     * @param month         The rule month, for example, <code>Calendar::JANUARY</code>\n     * @param dayOfMonth    The day of month, 1-based.\n     * @param dayOfWeek     The day of week, for example, <code>Calendar::SUNDAY</code>.\n     * @param after         true if the rule date is on or after the day of month.\n     * @param millisInDay   The milliseconds in the rule date.\n     * @param timeType      The time type, <code>WALL_TIME</code> or <code>STANDARD_TIME</code>\n     *                      or <code>UTC_TIME</code>.\n     * @stable ICU 3.8\n     */\n    DateTimeRule(int32_t month, int32_t dayOfMonth, int32_t dayOfWeek, UBool after,\n        int32_t millisInDay, TimeRuleType timeType);\n\n    /**\n     * Copy constructor.\n     * @param source    The DateTimeRule object to be copied.\n     * @stable ICU 3.8\n     */\n    DateTimeRule(const DateTimeRule& source);\n\n    /**\n     * Destructor.\n     * @stable ICU 3.8\n     */\n    ~DateTimeRule();\n\n    /**\n     * Clone this DateTimeRule object polymorphically. The caller owns the result and\n     * should delete it when done.\n     * @return    A copy of the object.\n     * @stable ICU 3.8\n     */\n    DateTimeRule* clone(void) const;\n\n    /**\n     * Assignment operator.\n     * @param right The object to be copied.\n     * @stable ICU 3.8\n     */\n    DateTimeRule& operator=(const DateTimeRule& right);\n\n    /**\n     * Return true if the given DateTimeRule objects are semantically equal. Objects\n     * of different subclasses are considered unequal.\n     * @param that  The object to be compared with.\n     * @return  true if the given DateTimeRule objects are semantically equal.\n     * @stable ICU 3.8\n     */\n    UBool operator==(const DateTimeRule& that) const;\n\n    /**\n     * Return true if the given DateTimeRule objects are semantically unequal. Objects\n     * of different subclasses are considered unequal.\n     * @param that  The object to be compared with.\n     * @return  true if the given DateTimeRule objects are semantically unequal.\n     * @stable ICU 3.8\n     */\n    UBool operator!=(const DateTimeRule& that) const;\n\n    /**\n     * Gets the date rule type, such as <code>DOM</code>\n     * @return The date rule type.\n     * @stable ICU 3.8\n     */\n    DateRuleType getDateRuleType(void) const;\n\n    /**\n     * Gets the time rule type\n     * @return The time rule type, either <code>WALL_TIME</code> or <code>STANDARD_TIME</code>\n     *         or <code>UTC_TIME</code>.\n     * @stable ICU 3.8\n     */\n    TimeRuleType getTimeRuleType(void) const;\n\n    /**\n     * Gets the rule month.\n     * @return The rule month.\n     * @stable ICU 3.8\n     */\n    int32_t getRuleMonth(void) const;\n\n    /**\n     * Gets the rule day of month.  When the date rule type\n     * is <code>DOW</code>, the value is always 0.\n     * @return The rule day of month\n     * @stable ICU 3.8\n     */\n    int32_t getRuleDayOfMonth(void) const;\n\n    /**\n     * Gets the rule day of week.  When the date rule type\n     * is <code>DOM</code>, the value is always 0.\n     * @return The rule day of week.\n     * @stable ICU 3.8\n     */\n    int32_t getRuleDayOfWeek(void) const;\n\n    /**\n     * Gets the ordinal number of the occurence of the day of week\n     * in the month.  When the date rule type is not <code>DOW</code>,\n     * the value is always 0.\n     * @return The rule day of week ordinal number in the month.\n     * @stable ICU 3.8\n     */\n    int32_t getRuleWeekInMonth(void) const;\n\n    /**\n     * Gets the rule time in the rule day.\n     * @return The time in the rule day in milliseconds.\n     * @stable ICU 3.8\n     */\n    int32_t getRuleMillisInDay(void) const;\n\nprivate:\n    int32_t fMonth;\n    int32_t fDayOfMonth;\n    int32_t fDayOfWeek;\n    int32_t fWeekInMonth;\n    int32_t fMillisInDay;\n    DateRuleType fDateRuleType;\n    TimeRuleType fTimeRuleType;\n\npublic:\n    /**\n     * Return the class ID for this class. This is useful only for comparing to\n     * a return value from getDynamicClassID(). For example:\n     * <pre>\n     * .   Base* polymorphic_pointer = createPolymorphicObject();\n     * .   if (polymorphic_pointer->getDynamicClassID() ==\n     * .       erived::getStaticClassID()) ...\n     * </pre>\n     * @return          The class ID for all objects of this class.\n     * @stable ICU 3.8\n     */\n    static UClassID U_EXPORT2 getStaticClassID(void);\n\n    /**\n     * Returns a unique class ID POLYMORPHICALLY. Pure virtual override. This\n     * method is to implement a simple version of RTTI, since not all C++\n     * compilers support genuine RTTI. Polymorphic operator==() and clone()\n     * methods call this method.\n     *\n     * @return          The class ID for this object. All objects of a\n     *                  given class have the same class ID.  Objects of\n     *                  other classes have different class IDs.\n     * @stable ICU 3.8\n     */\n    virtual UClassID getDynamicClassID(void) const;\n};\n\nU_NAMESPACE_END\n\n#endif /* #if !UCONFIG_NO_FORMATTING */\n\n#endif // DTRULE_H\n//eof\n"
  },
  {
    "path": "deprecated/android/addons/icucompat/unicode/enumset.h",
    "content": "/*\n******************************************************************************\n*\n*   Copyright (C) 2012, International Business Machines\n*   Corporation and others.  All Rights Reserved.\n*\n******************************************************************************\n*/\n\n/**\n * \\file\n * \\brief C++: internal template EnumSet<>\n */\n\n#ifndef ENUMSET_H\n#define ENUMSET_H\n\n#include \"unicode/utypes.h\"\n\n#if U_SHOW_CPLUSPLUS_API\n\nU_NAMESPACE_BEGIN\n\n/**\n * enum bitset for boolean fields. Similar to Java EnumSet<>. \n * Needs to range check.\n * @internal\n */\ntemplate<typename T, uint32_t minValue, uint32_t limitValue>\nclass EnumSet {\npublic:\n    inline EnumSet() : fBools(0) {}\n    inline EnumSet(const EnumSet<T,minValue,limitValue>& other) : fBools(other.fBools) {}\n    inline ~EnumSet() {}\n    inline void clear() { fBools=0; }\n    inline void add(T toAdd) { set(toAdd, 1); }\n    inline void remove(T toRemove) { set(toRemove, 0); }\n    inline int32_t contains(T toCheck) const { return get(toCheck); }\n    inline void set(T toSet, int32_t v) { fBools=(fBools&(~flag(toSet)))|(v?(flag(toSet)):0); }\n    inline int32_t get(T toCheck) const { return (fBools & flag(toCheck))?1:0; }\n    inline UBool isValidEnum(T toCheck) const {  return (toCheck>=minValue&&toCheck<limitValue); }\n    inline UBool isValidValue(int32_t v) const { return (v==0||v==1); }\n    inline const EnumSet<T,minValue,limitValue>& operator=(const EnumSet<T,minValue,limitValue>& other) {\n        fBools = other.fBools;\n        return *this;\n    }\n  \n    inline uint32_t getAll() const {\n        return fBools; \n    }\n\nprivate:\n    inline uint32_t flag(T toCheck) const { return (1<<(toCheck-minValue)); }\nprivate:\n    uint32_t fBools;\n};\n\nU_NAMESPACE_END\n\n#endif /* U_SHOW_CPLUSPLUS_API */\n#endif /* ENUMSET_H */\n"
  },
  {
    "path": "deprecated/android/addons/icucompat/unicode/errorcode.h",
    "content": "/*\n*******************************************************************************\n*\n*   Copyright (C) 2009-2011, International Business Machines\n*   Corporation and others.  All Rights Reserved.\n*\n*******************************************************************************\n*   file name:  errorcode.h\n*   encoding:   US-ASCII\n*   tab size:   8 (not used)\n*   indentation:4\n*\n*   created on: 2009mar10\n*   created by: Markus W. Scherer\n*/\n\n#ifndef __ERRORCODE_H__\n#define __ERRORCODE_H__\n\n/**\n * \\file \n * \\brief C++ API: ErrorCode class intended to make it easier to use\n *                 ICU C and C++ APIs from C++ user code.\n */\n\n#include \"unicode/utypes.h\"\n#include \"unicode/uobject.h\"\n\nU_NAMESPACE_BEGIN\n\n/**\n * Wrapper class for UErrorCode, with conversion operators for direct use\n * in ICU C and C++ APIs.\n * Intended to be used as a base class, where a subclass overrides\n * the handleFailure() function so that it throws an exception,\n * does an assert(), logs an error, etc.\n * This is not an abstract base class. This class can be used and instantiated\n * by itself, although it will be more useful when subclassed.\n *\n * Features:\n * - The constructor initializes the internal UErrorCode to U_ZERO_ERROR,\n *   removing one common source of errors.\n * - Same use in C APIs taking a UErrorCode * (pointer)\n *   and C++ taking UErrorCode & (reference) via conversion operators.\n * - Possible automatic checking for success when it goes out of scope.\n *\n * Note: For automatic checking for success in the destructor, a subclass\n * must implement such logic in its own destructor because the base class\n * destructor cannot call a subclass function (like handleFailure()).\n * The ErrorCode base class destructor does nothing.\n *\n * Note also: While it is possible for a destructor to throw an exception,\n * it is generally unsafe to do so. This means that in a subclass the destructor\n * and the handleFailure() function may need to take different actions.\n *\n * Sample code:\n * \\code\n *   class IcuErrorCode: public icu::ErrorCode {\n *   public:\n *     virtual ~IcuErrorCode() {  // should be defined in .cpp as \"key function\"\n *       // Safe because our handleFailure() does not throw exceptions.\n *       if(isFailure()) { handleFailure(); }\n *     }\n *   protected:\n *     virtual void handleFailure() const {\n *       log_failure(u_errorName(errorCode));\n *       exit(errorCode);\n *     }\n *   };\n *   IcuErrorCode error_code;\n *   UConverter *cnv = ucnv_open(\"Shift-JIS\", error_code);\n *   length = ucnv_fromUChars(dest, capacity, src, length, error_code);\n *   ucnv_close(cnv);\n *   // IcuErrorCode destructor checks for success.\n * \\endcode\n *\n * @stable ICU 4.2\n */\nclass U_COMMON_API ErrorCode: public UMemory {\npublic:\n    /**\n     * Default constructor. Initializes its UErrorCode to U_ZERO_ERROR.\n     * @stable ICU 4.2\n     */\n    ErrorCode() : errorCode(U_ZERO_ERROR) {}\n    /** Destructor, does nothing. See class documentation for details. @stable ICU 4.2 */\n    virtual ~ErrorCode();\n    /** Conversion operator, returns a reference. @stable ICU 4.2 */\n    operator UErrorCode & () { return errorCode; }\n    /** Conversion operator, returns a pointer. @stable ICU 4.2 */\n    operator UErrorCode * () { return &errorCode; }\n    /** Tests for U_SUCCESS(). @stable ICU 4.2 */\n    UBool isSuccess() const { return U_SUCCESS(errorCode); }\n    /** Tests for U_FAILURE(). @stable ICU 4.2 */\n    UBool isFailure() const { return U_FAILURE(errorCode); }\n    /** Returns the UErrorCode value. @stable ICU 4.2 */\n    UErrorCode get() const { return errorCode; }\n    /** Sets the UErrorCode value. @stable ICU 4.2 */\n    void set(UErrorCode value) { errorCode=value; }\n    /** Returns the UErrorCode value and resets it to U_ZERO_ERROR. @stable ICU 4.2 */\n    UErrorCode reset();\n    /**\n     * Asserts isSuccess().\n     * In other words, this method checks for a failure code,\n     * and the base class handles it like this:\n     * \\code\n     *   if(isFailure()) { handleFailure(); }\n     * \\endcode\n     * @stable ICU 4.4\n     */\n    void assertSuccess() const;\n    /**\n     * Return a string for the UErrorCode value.\n     * The string will be the same as the name of the error code constant\n     * in the UErrorCode enum.\n     * @stable ICU 4.4\n     */\n    const char* errorName() const;\n\nprotected:\n    /**\n     * Internal UErrorCode, accessible to subclasses.\n     * @stable ICU 4.2\n     */\n    UErrorCode errorCode;\n    /**\n     * Called by assertSuccess() if isFailure() is true.\n     * A subclass should override this function to deal with a failure code:\n     * Throw an exception, log an error, terminate the program, or similar.\n     * @stable ICU 4.2\n     */\n    virtual void handleFailure() const {}\n};\n\nU_NAMESPACE_END\n\n#endif  // __ERRORCODE_H__\n"
  },
  {
    "path": "deprecated/android/addons/icucompat/unicode/fieldpos.h",
    "content": "/*\n ********************************************************************************\n *   Copyright (C) 1997-2006, International Business Machines\n *   Corporation and others.  All Rights Reserved.\n ********************************************************************************\n *\n * File FIELDPOS.H\n *\n * Modification History:\n *\n *   Date        Name        Description\n *   02/25/97    aliu        Converted from java.\n *   03/17/97    clhuang     Updated per Format implementation.\n *    07/17/98    stephen        Added default/copy ctors, and operators =, ==, !=\n ********************************************************************************\n */\n\n// *****************************************************************************\n// This file was generated from the java source file FieldPosition.java\n// *****************************************************************************\n \n#ifndef FIELDPOS_H\n#define FIELDPOS_H\n\n#include \"unicode/utypes.h\"\n\n/**\n * \\file \n * \\brief C++ API: FieldPosition identifies the fields in a formatted output.\n */\n\n#if !UCONFIG_NO_FORMATTING\n\n#include \"unicode/uobject.h\"\n\nU_NAMESPACE_BEGIN\n\n/**\n * <code>FieldPosition</code> is a simple class used by <code>Format</code>\n * and its subclasses to identify fields in formatted output. Fields are\n * identified by constants, whose names typically end with <code>_FIELD</code>,\n * defined in the various subclasses of <code>Format</code>. See\n * <code>ERA_FIELD</code> and its friends in <code>DateFormat</code> for\n * an example.\n *\n * <p>\n * <code>FieldPosition</code> keeps track of the position of the\n * field within the formatted output with two indices: the index\n * of the first character of the field and the index of the last\n * character of the field.\n *\n * <p>\n * One version of the <code>format</code> method in the various\n * <code>Format</code> classes requires a <code>FieldPosition</code>\n * object as an argument. You use this <code>format</code> method\n * to perform partial formatting or to get information about the\n * formatted output (such as the position of a field).\n *\n * The FieldPosition class is not suitable for subclassing.\n *\n * <p>\n * Below is an example of using <code>FieldPosition</code> to aid\n * alignment of an array of formatted floating-point numbers on\n * their decimal points:\n * <pre>\n * \\code\n *       double doubleNum[] = {123456789.0, -12345678.9, 1234567.89, -123456.789,\n *                  12345.6789, -1234.56789, 123.456789, -12.3456789, 1.23456789};\n *       int dNumSize = (int)(sizeof(doubleNum)/sizeof(double));\n *       \n *       UErrorCode status = U_ZERO_ERROR;\n *       DecimalFormat* fmt = (DecimalFormat*) NumberFormat::createInstance(status);\n *       fmt->setDecimalSeparatorAlwaysShown(true);\n *       \n *       const int tempLen = 20;\n *       char temp[tempLen];\n *       \n *       for (int i=0; i<dNumSize; i++) {\n *           FieldPosition pos(NumberFormat::INTEGER_FIELD);\n *           UnicodeString buf;\n *           char fmtText[tempLen];\n *           ToCharString(fmt->format(doubleNum[i], buf, pos), fmtText);\n *           for (int j=0; j<tempLen; j++) temp[j] = ' '; // clear with spaces\n *           temp[__min(tempLen, tempLen-pos.getEndIndex())] = '\\0';\n *           cout << temp << fmtText   << endl;\n *       }\n *       delete fmt;\n * \\endcode\n * </pre>\n * <p>\n * The code will generate the following output:\n * <pre>\n * \\code\n *           123,456,789.000\n *           -12,345,678.900\n *             1,234,567.880\n *              -123,456.789\n *                12,345.678\n *                -1,234.567\n *                   123.456\n *                   -12.345\n *                     1.234\n *  \\endcode\n * </pre>\n */\nclass U_I18N_API FieldPosition : public UObject {\npublic:\n    /**\n     * DONT_CARE may be specified as the field to indicate that the\n     * caller doesn't need to specify a field.  Do not subclass.\n     */\n    enum { DONT_CARE = -1 };\n\n    /**\n     * Creates a FieldPosition object with a non-specified field.\n     * @stable ICU 2.0\n     */\n    FieldPosition() \n        : UObject(), fField(DONT_CARE), fBeginIndex(0), fEndIndex(0) {}\n\n    /**\n     * Creates a FieldPosition object for the given field.  Fields are\n     * identified by constants, whose names typically end with _FIELD,\n     * in the various subclasses of Format.\n     *\n     * @see NumberFormat#INTEGER_FIELD\n     * @see NumberFormat#FRACTION_FIELD\n     * @see DateFormat#YEAR_FIELD\n     * @see DateFormat#MONTH_FIELD\n     * @stable ICU 2.0\n     */\n    FieldPosition(int32_t field) \n        : UObject(), fField(field), fBeginIndex(0), fEndIndex(0) {}\n\n    /**\n     * Copy constructor\n     * @param copy the object to be copied from.\n     * @stable ICU 2.0\n     */\n    FieldPosition(const FieldPosition& copy) \n        : UObject(copy), fField(copy.fField), fBeginIndex(copy.fBeginIndex), fEndIndex(copy.fEndIndex) {}\n\n    /**\n     * Destructor\n     * @stable ICU 2.0\n     */\n    virtual ~FieldPosition();\n\n    /**\n     * Assignment operator\n     * @param copy the object to be copied from.\n     * @stable ICU 2.0\n     */\n    FieldPosition&      operator=(const FieldPosition& copy);\n\n    /** \n     * Equality operator.\n     * @param that    the object to be compared with.\n     * @return        TRUE if the two field positions are equal, FALSE otherwise.\n     * @stable ICU 2.0\n     */\n    UBool              operator==(const FieldPosition& that) const;\n\n    /** \n     * Equality operator.\n     * @param that    the object to be compared with.\n     * @return        TRUE if the two field positions are not equal, FALSE otherwise.\n     * @stable ICU 2.0\n     */\n    UBool              operator!=(const FieldPosition& that) const;\n\n    /**\n     * Clone this object.\n     * Clones can be used concurrently in multiple threads.\n     * If an error occurs, then NULL is returned.\n     * The caller must delete the clone.\n     *\n     * @return a clone of this object\n     *\n     * @see getDynamicClassID\n     * @stable ICU 2.8\n     */\n    FieldPosition *clone() const;\n\n    /**\n     * Retrieve the field identifier.\n     * @return    the field identifier.\n     * @stable ICU 2.0\n     */\n    int32_t getField(void) const { return fField; }\n\n    /**\n     * Retrieve the index of the first character in the requested field.\n     * @return    the index of the first character in the requested field.\n     * @stable ICU 2.0\n     */\n    int32_t getBeginIndex(void) const { return fBeginIndex; }\n\n    /**\n     * Retrieve the index of the character following the last character in the\n     * requested field.\n     * @return    the index of the character following the last character in the\n     *            requested field.\n     * @stable ICU 2.0\n     */\n    int32_t getEndIndex(void) const { return fEndIndex; }\n \n    /**\n     * Set the field.\n     * @param f    the new value of the field.\n     * @stable ICU 2.0\n     */\n    void setField(int32_t f) { fField = f; }\n\n    /**\n     * Set the begin index.  For use by subclasses of Format.\n     * @param bi    the new value of the begin index\n     * @stable ICU 2.0\n     */\n    void setBeginIndex(int32_t bi) { fBeginIndex = bi; }\n\n    /**\n     * Set the end index.  For use by subclasses of Format.\n     * @param ei    the new value of the end index\n     * @stable ICU 2.0\n     */\n    void setEndIndex(int32_t ei) { fEndIndex = ei; }\n    \n    /**\n     * ICU \"poor man's RTTI\", returns a UClassID for the actual class.\n     *\n     * @stable ICU 2.2\n     */\n    virtual UClassID getDynamicClassID() const;\n\n    /**\n     * ICU \"poor man's RTTI\", returns a UClassID for this class.\n     *\n     * @stable ICU 2.2\n     */\n    static UClassID U_EXPORT2 getStaticClassID();\n\nprivate:\n    /**\n     * Input: Desired field to determine start and end offsets for.\n     * The meaning depends on the subclass of Format.\n     */\n    int32_t fField;\n\n    /**\n     * Output: Start offset of field in text.\n     * If the field does not occur in the text, 0 is returned.\n     */\n    int32_t fBeginIndex;\n\n    /**\n     * Output: End offset of field in text.\n     * If the field does not occur in the text, 0 is returned.\n     */\n    int32_t fEndIndex;\n};\n\ninline FieldPosition&\nFieldPosition::operator=(const FieldPosition& copy)\n{\n    fField         = copy.fField;\n    fEndIndex     = copy.fEndIndex;\n    fBeginIndex = copy.fBeginIndex;\n    return *this;\n}\n\ninline UBool\nFieldPosition::operator==(const FieldPosition& copy) const\n{\n    return (fField == copy.fField &&\n        fEndIndex == copy.fEndIndex &&\n        fBeginIndex == copy.fBeginIndex);\n}\n\ninline UBool\nFieldPosition::operator!=(const FieldPosition& copy) const\n{\n    return !operator==(copy);\n}\n\nU_NAMESPACE_END\n\n#endif /* #if !UCONFIG_NO_FORMATTING */\n\n#endif // _FIELDPOS\n//eof\n"
  },
  {
    "path": "deprecated/android/addons/icucompat/unicode/fmtable.h",
    "content": "/*\n********************************************************************************\n*   Copyright (C) 1997-2012, International Business Machines\n*   Corporation and others.  All Rights Reserved.\n********************************************************************************\n*\n* File FMTABLE.H\n*\n* Modification History:\n*\n*   Date        Name        Description\n*   02/29/97    aliu        Creation.\n********************************************************************************\n*/\n#ifndef FMTABLE_H\n#define FMTABLE_H\n\n#include \"unicode/utypes.h\"\n#include \"unicode/unistr.h\"\n#include \"unicode/stringpiece.h\"\n\n/**\n * \\file \n * \\brief C++ API: Formattable is a thin wrapper for primitive numeric types.\n */\n\n#if !UCONFIG_NO_FORMATTING\n\nU_NAMESPACE_BEGIN\n\nclass CharString;\nclass DigitList;\n\n/**\n * \\def UNUM_INTERNAL_STACKARRAY_SIZE\n * @internal\n */\n#if U_PLATFORM == U_PF_OS400\n#define UNUM_INTERNAL_STACKARRAY_SIZE 144\n#else\n#define UNUM_INTERNAL_STACKARRAY_SIZE 128\n#endif\n\n/**\n * Formattable objects can be passed to the Format class or\n * its subclasses for formatting.  Formattable is a thin wrapper\n * class which interconverts between the primitive numeric types\n * (double, long, etc.) as well as UDate and UnicodeString.\n *\n * <p>Internally, a Formattable object is a union of primitive types.\n * As such, it can only store one flavor of data at a time.  To\n * determine what flavor of data it contains, use the getType method.\n *\n * <p>As of ICU 3.0, Formattable may also wrap a UObject pointer,\n * which it owns.  This allows an instance of any ICU class to be\n * encapsulated in a Formattable.  For legacy reasons and for\n * efficiency, primitive numeric types are still stored directly\n * within a Formattable.\n *\n * <p>The Formattable class is not suitable for subclassing.\n */\nclass U_I18N_API Formattable : public UObject {\npublic:\n    /**\n     * This enum is only used to let callers distinguish between\n     * the Formattable(UDate) constructor and the Formattable(double)\n     * constructor; the compiler cannot distinguish the signatures,\n     * since UDate is currently typedefed to be either double or long.\n     * If UDate is changed later to be a bonafide class\n     * or struct, then we no longer need this enum.\n     * @stable ICU 2.4\n     */\n    enum ISDATE { kIsDate };\n\n    /**\n     * Default constructor\n     * @stable ICU 2.4\n     */\n    Formattable(); // Type kLong, value 0\n\n    /**\n     * Creates a Formattable object with a UDate instance.\n     * @param d the UDate instance.\n     * @param flag the flag to indicate this is a date. Always set it to kIsDate\n     * @stable ICU 2.0  \n     */\n    Formattable(UDate d, ISDATE flag);\n\n    /**\n     * Creates a Formattable object with a double number.\n     * @param d the double number.\n     * @stable ICU 2.0\n     */\n    Formattable(double d);\n\n    /**\n     * Creates a Formattable object with a long number.\n     * @param l the long number.\n     * @stable ICU 2.0\n     */\n    Formattable(int32_t l);\n\n    /**\n     * Creates a Formattable object with an int64_t number\n     * @param ll the int64_t number.\n     * @stable ICU 2.8\n     */\n    Formattable(int64_t ll);\n\n#if !UCONFIG_NO_CONVERSION\n    /**\n     * Creates a Formattable object with a char string pointer.\n     * Assumes that the char string is null terminated.\n     * @param strToCopy the char string.\n     * @stable ICU 2.0\n     */\n    Formattable(const char* strToCopy);\n#endif\n\n    /**\n     * Creates a Formattable object of an appropriate numeric type from a\n     * a decimal number in string form.  The Formattable will retain the\n     * full precision of the input in decimal format, even when it exceeds\n     * what can be represented by a double of int64_t.\n     *\n     * @param number  the unformatted (not localized) string representation\n     *                     of the Decimal number.\n     * @param status  the error code.  Possible errors include U_INVALID_FORMAT_ERROR\n     *                if the format of the string does not conform to that of a\n     *                decimal number.\n     * @stable ICU 4.4\n     */\n    Formattable(const StringPiece &number, UErrorCode &status);\n\n    /**\n     * Creates a Formattable object with a UnicodeString object to copy from.\n     * @param strToCopy the UnicodeString string.\n     * @stable ICU 2.0\n     */\n    Formattable(const UnicodeString& strToCopy);\n\n    /**\n     * Creates a Formattable object with a UnicodeString object to adopt from.\n     * @param strToAdopt the UnicodeString string.\n     * @stable ICU 2.0\n     */\n    Formattable(UnicodeString* strToAdopt);\n\n    /**\n     * Creates a Formattable object with an array of Formattable objects.\n     * @param arrayToCopy the Formattable object array.\n     * @param count the array count.\n     * @stable ICU 2.0\n     */\n    Formattable(const Formattable* arrayToCopy, int32_t count);\n\n    /**\n     * Creates a Formattable object that adopts the given UObject.\n     * @param objectToAdopt the UObject to set this object to\n     * @stable ICU 3.0\n     */\n    Formattable(UObject* objectToAdopt);\n\n    /**\n     * Copy constructor.\n     * @stable ICU 2.0\n     */\n    Formattable(const Formattable&);\n\n    /**\n     * Assignment operator.\n     * @param rhs   The Formattable object to copy into this object.\n     * @stable ICU 2.0\n     */\n    Formattable&    operator=(const Formattable &rhs);\n\n    /**\n     * Equality comparison.\n     * @param other    the object to be compared with.\n     * @return        TRUE if other are equal to this, FALSE otherwise.\n     * @stable ICU 2.0\n     */\n    UBool          operator==(const Formattable &other) const;\n    \n    /** \n     * Equality operator.\n     * @param other    the object to be compared with.\n     * @return        TRUE if other are unequal to this, FALSE otherwise.\n     * @stable ICU 2.0\n     */\n    UBool          operator!=(const Formattable& other) const\n      { return !operator==(other); }\n\n    /** \n     * Destructor.\n     * @stable ICU 2.0\n     */\n    virtual         ~Formattable();\n\n    /**\n     * Clone this object.\n     * Clones can be used concurrently in multiple threads.\n     * If an error occurs, then NULL is returned.\n     * The caller must delete the clone.\n     *\n     * @return a clone of this object\n     *\n     * @see getDynamicClassID\n     * @stable ICU 2.8\n     */\n    Formattable *clone() const;\n\n    /** \n     * Selector for flavor of data type contained within a\n     * Formattable object.  Formattable is a union of several\n     * different types, and at any time contains exactly one type.\n     * @stable ICU 2.4\n     */\n    enum Type {\n        /**\n         * Selector indicating a UDate value.  Use getDate to retrieve\n         * the value.\n         * @stable ICU 2.4\n         */\n        kDate,\n\n        /**\n         * Selector indicating a double value.  Use getDouble to\n         * retrieve the value.\n         * @stable ICU 2.4\n         */\n        kDouble,\n\n        /**\n         * Selector indicating a 32-bit integer value.  Use getLong to\n         * retrieve the value.\n         * @stable ICU 2.4\n         */\n        kLong,\n\n        /**\n         * Selector indicating a UnicodeString value.  Use getString\n         * to retrieve the value.\n         * @stable ICU 2.4\n         */\n        kString,\n\n        /**\n         * Selector indicating an array of Formattables.  Use getArray\n         * to retrieve the value.\n         * @stable ICU 2.4\n         */\n        kArray,\n\n        /**\n         * Selector indicating a 64-bit integer value.  Use getInt64\n         * to retrieve the value.\n         * @stable ICU 2.8\n         */\n        kInt64,\n\n        /**\n         * Selector indicating a UObject value.  Use getObject to\n         * retrieve the value.\n         * @stable ICU 3.0\n         */\n        kObject\n   };\n\n    /**\n     * Gets the data type of this Formattable object.\n     * @return    the data type of this Formattable object.\n     * @stable ICU 2.0\n     */\n    Type            getType(void) const;\n    \n    /**\n     * Returns TRUE if the data type of this Formattable object\n     * is kDouble, kLong, kInt64 or kDecimalNumber.\n     * @return TRUE if this is a pure numeric object\n     * @stable ICU 3.0\n     */\n    UBool           isNumeric() const;\n    \n    /**\n     * Gets the double value of this object. If this object is not of type\n     * kDouble then the result is undefined.\n     * @return    the double value of this object.\n     * @stable ICU 2.0\n     */ \n    double          getDouble(void) const { return fValue.fDouble; }\n\n    /**\n     * Gets the double value of this object. If this object is of type\n     * long, int64 or Decimal Number then a conversion is peformed, with\n     * possible loss of precision.  If the type is kObject and the\n     * object is a Measure, then the result of\n     * getNumber().getDouble(status) is returned.  If this object is\n     * neither a numeric type nor a Measure, then 0 is returned and\n     * the status is set to U_INVALID_FORMAT_ERROR.\n     * @param status the error code\n     * @return the double value of this object.\n     * @stable ICU 3.0\n     */ \n    double          getDouble(UErrorCode& status) const;\n\n    /**\n     * Gets the long value of this object. If this object is not of type\n     * kLong then the result is undefined.\n     * @return    the long value of this object.\n     * @stable ICU 2.0\n     */ \n    int32_t         getLong(void) const { return (int32_t)fValue.fInt64; }\n\n    /**\n     * Gets the long value of this object. If the magnitude is too\n     * large to fit in a long, then the maximum or minimum long value,\n     * as appropriate, is returned and the status is set to\n     * U_INVALID_FORMAT_ERROR.  If this object is of type kInt64 and\n     * it fits within a long, then no precision is lost.  If it is of\n     * type kDouble or kDecimalNumber, then a conversion is peformed, with\n     * truncation of any fractional part.  If the type is kObject and\n     * the object is a Measure, then the result of\n     * getNumber().getLong(status) is returned.  If this object is\n     * neither a numeric type nor a Measure, then 0 is returned and\n     * the status is set to U_INVALID_FORMAT_ERROR.\n     * @param status the error code\n     * @return    the long value of this object.\n     * @stable ICU 3.0\n     */ \n    int32_t         getLong(UErrorCode& status) const;\n\n    /**\n     * Gets the int64 value of this object. If this object is not of type\n     * kInt64 then the result is undefined.\n     * @return    the int64 value of this object.\n     * @stable ICU 2.8\n     */ \n    int64_t         getInt64(void) const { return fValue.fInt64; }\n\n    /**\n     * Gets the int64 value of this object. If this object is of a numeric\n     * type and the magnitude is too large to fit in an int64, then\n     * the maximum or minimum int64 value, as appropriate, is returned\n     * and the status is set to U_INVALID_FORMAT_ERROR.  If the\n     * magnitude fits in an int64, then a casting conversion is\n     * peformed, with truncation of any fractional part.  If the type\n     * is kObject and the object is a Measure, then the result of\n     * getNumber().getDouble(status) is returned.  If this object is\n     * neither a numeric type nor a Measure, then 0 is returned and\n     * the status is set to U_INVALID_FORMAT_ERROR.\n     * @param status the error code\n     * @return    the int64 value of this object.\n     * @stable ICU 3.0\n     */ \n    int64_t         getInt64(UErrorCode& status) const;\n\n    /**\n     * Gets the Date value of this object. If this object is not of type\n     * kDate then the result is undefined.\n     * @return    the Date value of this object.\n     * @stable ICU 2.0\n     */ \n    UDate           getDate() const { return fValue.fDate; }\n\n    /**\n     * Gets the Date value of this object.  If the type is not a date,\n     * status is set to U_INVALID_FORMAT_ERROR and the return value is\n     * undefined.\n     * @param status the error code.\n     * @return    the Date value of this object.\n     * @stable ICU 3.0\n     */ \n     UDate          getDate(UErrorCode& status) const;\n\n    /**\n     * Gets the string value of this object. If this object is not of type\n     * kString then the result is undefined.\n     * @param result    Output param to receive the Date value of this object.\n     * @return          A reference to 'result'.\n     * @stable ICU 2.0\n     */ \n    UnicodeString&  getString(UnicodeString& result) const\n      { result=*fValue.fString; return result; }\n\n    /**\n     * Gets the string value of this object. If the type is not a\n     * string, status is set to U_INVALID_FORMAT_ERROR and a bogus\n     * string is returned.\n     * @param result    Output param to receive the Date value of this object.\n     * @param status    the error code. \n     * @return          A reference to 'result'.\n     * @stable ICU 3.0\n     */ \n    UnicodeString&  getString(UnicodeString& result, UErrorCode& status) const;\n\n    /**\n     * Gets a const reference to the string value of this object. If\n     * this object is not of type kString then the result is\n     * undefined.\n     * @return   a const reference to the string value of this object.\n     * @stable ICU 2.0\n     */\n    inline const UnicodeString& getString(void) const;\n\n    /**\n     * Gets a const reference to the string value of this object.  If\n     * the type is not a string, status is set to\n     * U_INVALID_FORMAT_ERROR and the result is a bogus string.\n     * @param status    the error code.\n     * @return   a const reference to the string value of this object.\n     * @stable ICU 3.0\n     */\n    const UnicodeString& getString(UErrorCode& status) const;\n\n    /**\n     * Gets a reference to the string value of this object. If this\n     * object is not of type kString then the result is undefined.\n     * @return   a reference to the string value of this object.\n     * @stable ICU 2.0\n     */\n    inline UnicodeString& getString(void);\n\n    /**\n     * Gets a reference to the string value of this object. If the\n     * type is not a string, status is set to U_INVALID_FORMAT_ERROR\n     * and the result is a bogus string.\n     * @param status    the error code. \n     * @return   a reference to the string value of this object.\n     * @stable ICU 3.0\n     */\n    UnicodeString& getString(UErrorCode& status);\n\n    /**\n     * Gets the array value and count of this object. If this object\n     * is not of type kArray then the result is undefined.\n     * @param count    fill-in with the count of this object.\n     * @return         the array value of this object.\n     * @stable ICU 2.0\n     */ \n    const Formattable* getArray(int32_t& count) const\n      { count=fValue.fArrayAndCount.fCount; return fValue.fArrayAndCount.fArray; }\n\n    /**\n     * Gets the array value and count of this object. If the type is\n     * not an array, status is set to U_INVALID_FORMAT_ERROR, count is\n     * set to 0, and the result is NULL.\n     * @param count    fill-in with the count of this object.\n     * @param status the error code. \n     * @return         the array value of this object.\n     * @stable ICU 3.0\n     */ \n    const Formattable* getArray(int32_t& count, UErrorCode& status) const;\n\n    /**\n     * Accesses the specified element in the array value of this\n     * Formattable object. If this object is not of type kArray then\n     * the result is undefined.\n     * @param index the specified index.\n     * @return the accessed element in the array.\n     * @stable ICU 2.0\n     */\n    Formattable&    operator[](int32_t index) { return fValue.fArrayAndCount.fArray[index]; }\n       \n    /**\n     * Returns a pointer to the UObject contained within this\n     * formattable, or NULL if this object does not contain a UObject.\n     * @return a UObject pointer, or NULL\n     * @stable ICU 3.0\n     */\n    const UObject*  getObject() const;\n\n    /**\n     * Returns a numeric string representation of the number contained within this\n     * formattable, or NULL if this object does not contain numeric type.\n     * For values obtained by parsing, the returned decimal number retains\n     * the full precision and range of the original input, unconstrained by\n     * the limits of a double floating point or a 64 bit int.\n     * \n     * This function is not thread safe, and therfore is not declared const,\n     * even though it is logically const.\n     *\n     * Possible errors include U_MEMORY_ALLOCATION_ERROR, and\n     * U_INVALID_STATE if the formattable object has not been set to\n     * a numeric type.\n     *\n     * @param status the error code.\n     * @return the unformatted string representation of a number.\n     * @stable ICU 4.4\n     */\n    StringPiece getDecimalNumber(UErrorCode &status);\n\n     /**\n     * Sets the double value of this object and changes the type to\n     * kDouble.\n     * @param d    the new double value to be set.\n     * @stable ICU 2.0\n     */ \n    void            setDouble(double d);\n\n    /**\n     * Sets the long value of this object and changes the type to\n     * kLong.\n     * @param l    the new long value to be set.\n     * @stable ICU 2.0\n     */ \n    void            setLong(int32_t l);\n\n    /**\n     * Sets the int64 value of this object and changes the type to\n     * kInt64.\n     * @param ll    the new int64 value to be set.\n     * @stable ICU 2.8\n     */ \n    void            setInt64(int64_t ll);\n\n    /**\n     * Sets the Date value of this object and changes the type to\n     * kDate.\n     * @param d    the new Date value to be set.\n     * @stable ICU 2.0\n     */ \n    void            setDate(UDate d);\n\n    /**\n     * Sets the string value of this object and changes the type to\n     * kString.\n     * @param stringToCopy    the new string value to be set.\n     * @stable ICU 2.0\n     */ \n    void            setString(const UnicodeString& stringToCopy);\n\n    /**\n     * Sets the array value and count of this object and changes the\n     * type to kArray.\n     * @param array    the array value.\n     * @param count    the number of array elements to be copied.\n     * @stable ICU 2.0\n     */ \n    void            setArray(const Formattable* array, int32_t count);\n\n    /**\n     * Sets and adopts the string value and count of this object and\n     * changes the type to kArray.\n     * @param stringToAdopt    the new string value to be adopted.\n     * @stable ICU 2.0\n     */ \n    void            adoptString(UnicodeString* stringToAdopt);\n\n    /**\n     * Sets and adopts the array value and count of this object and\n     * changes the type to kArray.\n     * @stable ICU 2.0\n     */ \n    void            adoptArray(Formattable* array, int32_t count);\n       \n    /**\n     * Sets and adopts the UObject value of this object and changes\n     * the type to kObject.  After this call, the caller must not\n     * delete the given object.\n     * @param objectToAdopt the UObject value to be adopted\n     * @stable ICU 3.0\n     */\n    void            adoptObject(UObject* objectToAdopt);\n\n    /**\n     * Sets the the numeric value from a decimal number string, and changes\n     * the type to to a numeric type appropriate for the number.  \n     * The syntax of the number is a \"numeric string\"\n     * as defined in the Decimal Arithmetic Specification, available at\n     * http://speleotrove.com/decimal\n     * The full precision and range of the input number will be retained,\n     * even when it exceeds what can be represented by a double or an int64.\n     *\n     * @param numberString  a string representation of the unformatted decimal number.\n     * @param status        the error code.  Set to U_INVALID_FORMAT_ERROR if the\n     *                      incoming string is not a valid decimal number.\n     * @stable ICU 4.4\n     */\n    void             setDecimalNumber(const StringPiece &numberString,\n                                      UErrorCode &status);\n\n    /**\n     * ICU \"poor man's RTTI\", returns a UClassID for the actual class.\n     *\n     * @stable ICU 2.2\n     */\n    virtual UClassID getDynamicClassID() const;\n\n    /**\n     * ICU \"poor man's RTTI\", returns a UClassID for this class.\n     *\n     * @stable ICU 2.2\n     */\n    static UClassID U_EXPORT2 getStaticClassID();\n\n#ifndef U_HIDE_DEPRECATED_API\n    /**\n     * Deprecated variant of getLong(UErrorCode&).\n     * @param status the error code\n     * @return the long value of this object.\n     * @deprecated ICU 3.0 use getLong(UErrorCode&) instead\n     */ \n    inline int32_t getLong(UErrorCode* status) const;\n#endif  /* U_HIDE_DEPRECATED_API */\n\n#ifndef U_HIDE_INTERNAL_API\n    /**\n     * Internal function, do not use.\n     * TODO:  figure out how to make this be non-public.\n     *        NumberFormat::format(Formattable, ...\n     *        needs to get at the DigitList, if it exists, for\n     *        big decimal formatting.\n     *  @internal\n     */\n    DigitList *getDigitList() const { return fDecimalNum;}\n\n    /**\n     *  @internal\n     */\n    DigitList *getInternalDigitList();\n\n    /**\n     *  Adopt, and set value from, a DigitList\n     *     Internal Function, do not use.\n     *  @param dl the Digit List to be adopted\n     *  @internal\n     */\n    void adoptDigitList(DigitList *dl);\n#endif  /* U_HIDE_INTERNAL_API */\n\nprivate:\n    /**\n     * Cleans up the memory for unwanted values.  For example, the adopted\n     * string or array objects.\n     */\n    void            dispose(void);\n\n    /**\n     * Common initialization, for use by constructors.\n     */\n    void            init();\n\n    UnicodeString* getBogus() const;\n\n    union {\n        UObject*        fObject;\n        UnicodeString*  fString;\n        double          fDouble;\n        int64_t         fInt64;\n        UDate           fDate;\n        struct {\n          Formattable*  fArray;\n          int32_t       fCount;\n        }               fArrayAndCount;\n    } fValue;\n\n    CharString           *fDecimalStr;\n\n    DigitList            *fDecimalNum;\n\n    char                fStackData[UNUM_INTERNAL_STACKARRAY_SIZE]; // must be big enough for DigitList\n\n    Type                fType;\n    UnicodeString       fBogus; // Bogus string when it's needed.\n};\n\ninline UDate Formattable::getDate(UErrorCode& status) const {\n    if (fType != kDate) {\n        if (U_SUCCESS(status)) {\n            status = U_INVALID_FORMAT_ERROR;\n        }\n        return 0;\n    }\n    return fValue.fDate;\n}\n\ninline const UnicodeString& Formattable::getString(void) const {\n    return *fValue.fString;\n}\n\ninline UnicodeString& Formattable::getString(void) {\n    return *fValue.fString;\n}\n\n#ifndef U_HIDE_DEPRECATED_API\ninline int32_t Formattable::getLong(UErrorCode* status) const {\n    return getLong(*status);\n}\n#endif\n\n\nU_NAMESPACE_END\n\n#endif /* #if !UCONFIG_NO_FORMATTING */\n\n#endif //_FMTABLE\n//eof\n"
  },
  {
    "path": "deprecated/android/addons/icucompat/unicode/format.h",
    "content": "/*\n********************************************************************************\n* Copyright (C) 1997-2011, International Business Machines Corporation and others.\n* All Rights Reserved.\n********************************************************************************\n*\n* File FORMAT.H\n*\n* Modification History:\n*\n*   Date        Name        Description\n*   02/19/97    aliu        Converted from java.\n*   03/17/97    clhuang     Updated per C++ implementation.\n*   03/27/97    helena      Updated to pass the simple test after code review.\n********************************************************************************\n*/\n// *****************************************************************************\n// This file was generated from the java source file Format.java\n// *****************************************************************************\n\n#ifndef FORMAT_H\n#define FORMAT_H\n\n\n#include \"unicode/utypes.h\"\n\n/**\n * \\file \n * \\brief C++ API: Base class for all formats. \n */\n\n#if !UCONFIG_NO_FORMATTING\n\n#include \"unicode/unistr.h\"\n#include \"unicode/fmtable.h\"\n#include \"unicode/fieldpos.h\"\n#include \"unicode/fpositer.h\"\n#include \"unicode/parsepos.h\"\n#include \"unicode/parseerr.h\" \n#include \"unicode/locid.h\"\n\nU_NAMESPACE_BEGIN\n\n/**\n * Base class for all formats.  This is an abstract base class which\n * specifies the protocol for classes which convert other objects or\n * values, such as numeric values and dates, and their string\n * representations.  In some cases these representations may be\n * localized or contain localized characters or strings.  For example,\n * a numeric formatter such as DecimalFormat may convert a numeric\n * value such as 12345 to the string \"$12,345\".  It may also parse\n * the string back into a numeric value.  A date and time formatter\n * like SimpleDateFormat may represent a specific date, encoded\n * numerically, as a string such as \"Wednesday, February 26, 1997 AD\".\n * <P>\n * Many of the concrete subclasses of Format employ the notion of\n * a pattern.  A pattern is a string representation of the rules which\n * govern the interconversion between values and strings.  For example,\n * a DecimalFormat object may be associated with the pattern\n * \"$#,##0.00;($#,##0.00)\", which is a common US English format for\n * currency values, yielding strings such as \"$1,234.45\" for 1234.45,\n * and \"($987.65)\" for 987.6543.  The specific syntax of a pattern\n * is defined by each subclass.\n * <P>\n * Even though many subclasses use patterns, the notion of a pattern\n * is not inherent to Format classes in general, and is not part of\n * the explicit base class protocol.\n * <P>\n * Two complex formatting classes bear mentioning.  These are\n * MessageFormat and ChoiceFormat.  ChoiceFormat is a subclass of\n * NumberFormat which allows the user to format different number ranges\n * as strings.  For instance, 0 may be represented as \"no files\", 1 as\n * \"one file\", and any number greater than 1 as \"many files\".\n * MessageFormat is a formatter which utilizes other Format objects to\n * format a string containing with multiple values.  For instance,\n * A MessageFormat object might produce the string \"There are no files\n * on the disk MyDisk on February 27, 1997.\" given the arguments 0,\n * \"MyDisk\", and the date value of 2/27/97.  See the ChoiceFormat\n * and MessageFormat headers for further information.\n * <P>\n * If formatting is unsuccessful, a failing UErrorCode is returned when\n * the Format cannot format the type of object, otherwise if there is\n * something illformed about the the Unicode replacement character\n * 0xFFFD is returned.\n * <P>\n * If there is no match when parsing, a parse failure UErrorCode is\n * retured for methods which take no ParsePosition.  For the method\n * that takes a ParsePosition, the index parameter is left unchanged.\n * <P>\n * <em>User subclasses are not supported.</em> While clients may write\n * subclasses, such code will not necessarily work and will not be\n * guaranteed to work stably from release to release.\n */\nclass U_I18N_API Format : public UObject {\npublic:\n\n    /** Destructor\n     * @stable ICU 2.4\n     */\n    virtual ~Format();\n\n    /**\n     * Return true if the given Format objects are semantically equal.\n     * Objects of different subclasses are considered unequal.\n     * @param other    the object to be compared with.\n     * @return         Return true if the given Format objects are semantically equal.\n     *                 Objects of different subclasses are considered unequal.\n     * @stable ICU 2.0\n     */\n    virtual UBool operator==(const Format& other) const = 0;\n\n    /**\n     * Return true if the given Format objects are not semantically\n     * equal.\n     * @param other    the object to be compared with.\n     * @return         Return true if the given Format objects are not semantically.\n     * @stable ICU 2.0\n     */\n    UBool operator!=(const Format& other) const { return !operator==(other); }\n\n    /**\n     * Clone this object polymorphically.  The caller is responsible\n     * for deleting the result when done.\n     * @return    A copy of the object\n     * @stable ICU 2.0\n     */\n    virtual Format* clone() const = 0;\n\n    /**\n     * Formats an object to produce a string.\n     *\n     * @param obj       The object to format.\n     * @param appendTo  Output parameter to receive result.\n     *                  Result is appended to existing contents.\n     * @param status    Output parameter filled in with success or failure status.\n     * @return          Reference to 'appendTo' parameter.\n     * @stable ICU 2.0\n     */\n    UnicodeString& format(const Formattable& obj,\n                          UnicodeString& appendTo,\n                          UErrorCode& status) const;\n\n    /**\n     * Format an object to produce a string.  This is a pure virtual method which\n     * subclasses must implement. This method allows polymorphic formatting\n     * of Formattable objects. If a subclass of Format receives a Formattable\n     * object type it doesn't handle (e.g., if a numeric Formattable is passed\n     * to a DateFormat object) then it returns a failing UErrorCode.\n     *\n     * @param obj       The object to format.\n     * @param appendTo  Output parameter to receive result.\n     *                  Result is appended to existing contents.\n     * @param pos       On input: an alignment field, if desired.\n     *                  On output: the offsets of the alignment field.\n     * @param status    Output param filled with success/failure status.\n     * @return          Reference to 'appendTo' parameter.\n     * @stable ICU 2.0\n     */\n    virtual UnicodeString& format(const Formattable& obj,\n                                  UnicodeString& appendTo,\n                                  FieldPosition& pos,\n                                  UErrorCode& status) const = 0;\n    /**\n     * Format an object to produce a string.  Subclasses should override this\n     * method. This method allows polymorphic formatting of Formattable objects.\n     * If a subclass of Format receives a Formattable object type it doesn't\n     * handle (e.g., if a numeric Formattable is passed to a DateFormat object)\n     * then it returns a failing UErrorCode.\n     *\n     * @param obj       The object to format.\n     * @param appendTo  Output parameter to receive result.\n     *                  Result is appended to existing contents.\n     * @param posIter   On return, can be used to iterate over positions\n     *                  of fields generated by this format call.\n     * @param status    Output param filled with success/failure status.\n     * @return          Reference to 'appendTo' parameter.\n     * @stable ICU 4.4\n     */\n    virtual UnicodeString& format(const Formattable& obj,\n                                  UnicodeString& appendTo,\n                                  FieldPositionIterator* posIter,\n                                  UErrorCode& status) const;\n\n    /**\n     * Parse a string to produce an object.  This is a pure virtual\n     * method which subclasses must implement.  This method allows\n     * polymorphic parsing of strings into Formattable objects.\n     * <P>\n     * Before calling, set parse_pos.index to the offset you want to\n     * start parsing at in the source.  After calling, parse_pos.index\n     * is the end of the text you parsed.  If error occurs, index is\n     * unchanged.\n     * <P>\n     * When parsing, leading whitespace is discarded (with successful\n     * parse), while trailing whitespace is left as is.\n     * <P>\n     * Example:\n     * <P>\n     * Parsing \"_12_xy\" (where _ represents a space) for a number,\n     * with index == 0 will result in the number 12, with\n     * parse_pos.index updated to 3 (just before the second space).\n     * Parsing a second time will result in a failing UErrorCode since\n     * \"xy\" is not a number, and leave index at 3.\n     * <P>\n     * Subclasses will typically supply specific parse methods that\n     * return different types of values. Since methods can't overload\n     * on return types, these will typically be named \"parse\", while\n     * this polymorphic method will always be called parseObject.  Any\n     * parse method that does not take a parse_pos should set status\n     * to an error value when no text in the required format is at the\n     * start position.\n     *\n     * @param source    The string to be parsed into an object.\n     * @param result    Formattable to be set to the parse result.\n     *                  If parse fails, return contents are undefined.\n     * @param parse_pos The position to start parsing at. Upon return\n     *                  this param is set to the position after the\n     *                  last character successfully parsed. If the\n     *                  source is not parsed successfully, this param\n     *                  will remain unchanged.\n     * @stable ICU 2.0\n     */\n    virtual void parseObject(const UnicodeString& source,\n                             Formattable& result,\n                             ParsePosition& parse_pos) const = 0;\n\n    /**\n     * Parses a string to produce an object. This is a convenience method\n     * which calls the pure virtual parseObject() method, and returns a\n     * failure UErrorCode if the ParsePosition indicates failure.\n     *\n     * @param source    The string to be parsed into an object.\n     * @param result    Formattable to be set to the parse result.\n     *                  If parse fails, return contents are undefined.\n     * @param status    Output param to be filled with success/failure\n     *                  result code.\n     * @stable ICU 2.0\n     */\n    void parseObject(const UnicodeString& source,\n                     Formattable& result,\n                     UErrorCode& status) const;\n\n    /** Get the locale for this format object. You can choose between valid and actual locale.\n     *  @param type type of the locale we're looking for (valid or actual) \n     *  @param status error code for the operation\n     *  @return the locale\n     *  @stable ICU 2.8\n     */\n    Locale getLocale(ULocDataLocaleType type, UErrorCode& status) const;\n\n#ifndef U_HIDE_INTERNAL_API\n    /** Get the locale for this format object. You can choose between valid and actual locale.\n     *  @param type type of the locale we're looking for (valid or actual) \n     *  @param status error code for the operation\n     *  @return the locale\n     *  @internal\n     */\n    const char* getLocaleID(ULocDataLocaleType type, UErrorCode &status) const;\n#endif  /* U_HIDE_INTERNAL_API */\n\n protected:\n    /** @stable ICU 2.8 */\n    void setLocaleIDs(const char* valid, const char* actual);\n\nprotected:\n    /**\n     * Default constructor for subclass use only.  Does nothing.\n     * @stable ICU 2.0\n     */\n    Format();\n\n    /**\n     * @stable ICU 2.0\n     */\n    Format(const Format&); // Does nothing; for subclasses only\n\n    /**\n     * @stable ICU 2.0\n     */\n    Format& operator=(const Format&); // Does nothing; for subclasses\n\n       \n    /**\n     * Simple function for initializing a UParseError from a UnicodeString.\n     *\n     * @param pattern The pattern to copy into the parseError\n     * @param pos The position in pattern where the error occured\n     * @param parseError The UParseError object to fill in\n     * @stable ICU 2.4\n     */\n    static void syntaxError(const UnicodeString& pattern,\n                            int32_t pos,\n                            UParseError& parseError);\n\n private:\n    char actualLocale[ULOC_FULLNAME_CAPACITY];\n    char validLocale[ULOC_FULLNAME_CAPACITY];\n};\n\nU_NAMESPACE_END\n\n#endif /* #if !UCONFIG_NO_FORMATTING */\n\n#endif // _FORMAT\n//eof\n"
  },
  {
    "path": "deprecated/android/addons/icucompat/unicode/fpositer.h",
    "content": "/*\n********************************************************************************\n*   Copyright (C) 2010, International Business Machines\n*   Corporation and others.  All Rights Reserved.\n********************************************************************************\n*\n* File attiter.h\n*\n* Modification History:\n*\n*   Date        Name        Description\n*   12/15/2009  dougfelt    Created\n********************************************************************************\n*/\n\n#ifndef FPOSITER_H\n#define FPOSITER_H\n\n#include \"unicode/utypes.h\"\n#include \"unicode/uobject.h\"\n\n/**\n * \\file\n * \\brief C++ API: FieldPosition Iterator.\n */\n\n#if UCONFIG_NO_FORMATTING\n\nU_NAMESPACE_BEGIN\n\n/*\n * Allow the declaration of APIs with pointers to FieldPositionIterator\n * even when formatting is removed from the build.\n */\nclass FieldPositionIterator;\n\nU_NAMESPACE_END\n\n#else\n\n#include \"unicode/fieldpos.h\"\n#include \"unicode/umisc.h\"\n\nU_NAMESPACE_BEGIN\n\nclass UVector32;\n\n/**\n * FieldPositionIterator returns the field ids and their start/limit positions generated\n * by a call to Format::format.  See Format, NumberFormat, DecimalFormat.\n * @stable ICU 4.4\n */\nclass U_I18N_API FieldPositionIterator : public UObject {\npublic:\n    /**\n     * Destructor.\n     * @stable ICU 4.4\n     */\n    ~FieldPositionIterator();\n\n    /**\n     * Constructs a new, empty iterator.\n     * @stable ICU 4.4\n     */\n    FieldPositionIterator(void);\n\n    /**\n     * Copy constructor.  If the copy failed for some reason, the new iterator will\n     * be empty.\n     * @stable ICU 4.4\n     */\n    FieldPositionIterator(const FieldPositionIterator&);\n\n    /**\n     * Return true if another object is semantically equal to this\n     * one.\n     * <p>\n     * Return true if this FieldPositionIterator is at the same position in an\n     * equal array of run values.\n     * @stable ICU 4.4\n     */\n    UBool operator==(const FieldPositionIterator&) const;\n\n    /**\n     * Returns the complement of the result of operator==\n     * @param rhs The FieldPositionIterator to be compared for inequality\n     * @return the complement of the result of operator==\n     * @stable ICU 4.4\n     */\n    UBool operator!=(const FieldPositionIterator& rhs) const { return !operator==(rhs); }\n\n    /**\n     * If the current position is valid, updates the FieldPosition values, advances the iterator,\n     * and returns TRUE, otherwise returns FALSE.\n     * @stable ICU 4.4\n     */\n    UBool next(FieldPosition& fp);\n\n    // BEGIN android-added\n    /**\n     * Returns the data.  If dest is null, returns the length of the data.\n     * Otherwise, if capacity is insufficient, returns the negative of the\n     * length of the data.  Otherwise, copies data into dest and returns\n     * the length of the data.\n     * @internal\n     */\n    int32_t getData(int32_t *dest, int32_t capacity) const;\n   // END android-added\n\nprivate:\n    friend class FieldPositionIteratorHandler;\n\n    /**\n     * Sets the data used by the iterator, and resets the position.\n     * Returns U_ILLEGAL_ARGUMENT_ERROR in status if the data is not valid \n     * (length is not a multiple of 3, or start >= limit for any run).\n     */\n    void setData(UVector32 *adopt, UErrorCode& status);\n\n    UVector32 *data;\n    int32_t pos;\n\n    // No ICU \"poor man's RTTI\" for this class nor its subclasses.\n    virtual UClassID getDynamicClassID() const;\n};\n\nU_NAMESPACE_END\n\n#endif /* #if !UCONFIG_NO_FORMATTING */\n\n#endif // FPOSITER_H\n"
  },
  {
    "path": "deprecated/android/addons/icucompat/unicode/gender.h",
    "content": "/*\n*******************************************************************************\n* Copyright (C) 2008-2012, International Business Machines Corporation and\n* others. All Rights Reserved.\n*******************************************************************************\n*\n*\n* File GENDER.H\n*\n* Modification History:*\n*   Date        Name        Description\n*\n********************************************************************************\n*/\n\n#ifndef _GENDER\n#define _GENDER\n\n#include \"unicode/utypes.h\"\n\n#if !UCONFIG_NO_FORMATTING\n\n#include \"unicode/locid.h\"\n#include \"unicode/ugender.h\"\n#include \"unicode/uobject.h\"\n\nclass GenderInfoTest;\n\nU_NAMESPACE_BEGIN\n\n/**\n * GenderInfo computes the gender of a list as a whole given the gender of\n * each element.\n * @draft ICU 50\n */\nclass U_I18N_API GenderInfo : public UObject {\npublic:\n\n    /**\n     * Provides access to the predefined GenderInfo object for a given\n     * locale.\n     *\n     * @param locale  The locale for which a <code>GenderInfo</code> object is\n     *                returned.\n     * @param status  Output param set to success/failure code on exit, which\n     *                must not indicate a failure before the function call.\n     * @return        The predefined <code>GenderInfo</code> object pointer for\n     *                this locale. The returned object is immutable, so it is\n     *                declared as const. Caller does not own the returned\n     *                pointer, so it must not attempt to free it.\n     * @draft ICU 50\n     */\n    static const GenderInfo* U_EXPORT2 getInstance(const Locale& locale, UErrorCode& status);\n\n    /**\n     * Determines the gender of a list as a whole given the gender of each\n     * of the elements.\n     * \n     * @param genders the gender of each element in the list.\n     * @param length the length of gender array.\n     * @param status  Output param set to success/failure code on exit, which\n     *                must not indicate a failure before the function call.\n     * @return        the gender of the whole list.\n     * @draft ICU 50\n     */\n    UGender getListGender(const UGender* genders, int32_t length, UErrorCode& status) const;\n\n    /**\n     * Destructor.\n     *\n     * @draft ICU 50\n     * @internal\n     */\n    virtual ~GenderInfo();\n\nprivate:\n    int32_t _style;\n\n\n    /**\n     * No \"poor man's RTTI\"\n     */\n    virtual UClassID getDynamicClassID() const;\n\n    /**\n     * Copy constructor. One object per locale invariant. Clients\n     * must never copy GenderInfo objects.\n     */\n    GenderInfo(const GenderInfo& other);\n\n    /**\n      * Assignment operator. Not applicable to immutable objects.\n      */\n    GenderInfo& operator=(const GenderInfo&);\n\n    GenderInfo();\n\n    static const GenderInfo* getNeutralInstance();\n\n    static const GenderInfo* getMixedNeutralInstance();\n\n    static const GenderInfo* getMaleTaintsInstance();\n\n    static const GenderInfo* loadInstance(const Locale& locale, UErrorCode& status);\n    friend class ::GenderInfoTest;\n};\n\nU_NAMESPACE_END\n\n#endif /* #if !UCONFIG_NO_FORMATTING */\n\n#endif // _GENDER\n//eof\n"
  },
  {
    "path": "deprecated/android/addons/icucompat/unicode/gregocal.h",
    "content": "/*\n* Copyright (C) 1997-2012, International Business Machines Corporation and others.\n* All Rights Reserved.\n********************************************************************************\n*\n* File GREGOCAL.H\n*\n* Modification History:\n*\n*   Date        Name        Description\n*   04/22/97    aliu        Overhauled header.\n*    07/28/98    stephen        Sync with JDK 1.2\n*    09/04/98    stephen        Re-sync with JDK 8/31 putback\n*    09/14/98    stephen        Changed type of kOneDay, kOneWeek to double.\n*                            Fixed bug in roll()\n*   10/15/99    aliu        Fixed j31, incorrect WEEK_OF_YEAR computation.\n*                           Added documentation of WEEK_OF_YEAR computation.\n*   10/15/99    aliu        Fixed j32, cannot set date to Feb 29 2000 AD.\n*                           {JDK bug 4210209 4209272}\n*   11/07/2003  srl         Update, clean up documentation.\n********************************************************************************\n*/\n\n#ifndef GREGOCAL_H\n#define GREGOCAL_H\n\n#include \"unicode/utypes.h\"\n\n#if !UCONFIG_NO_FORMATTING\n\n#include \"unicode/calendar.h\"\n\n/**\n * \\file \n * \\brief C++ API: Concrete class which provides the standard calendar.\n */\n\nU_NAMESPACE_BEGIN\n\n/** \n * Concrete class which provides the standard calendar used by most of the world.\n * <P>\n * The standard (Gregorian) calendar has 2 eras, BC and AD.\n * <P>\n * This implementation handles a single discontinuity, which corresponds by default to\n * the date the Gregorian calendar was originally instituted (October 15, 1582). Not all\n * countries adopted the Gregorian calendar then, so this cutover date may be changed by\n * the caller.\n * <P>\n * Prior to the institution of the Gregorian Calendar, New Year's Day was March 25. To\n * avoid confusion, this Calendar always uses January 1. A manual adjustment may be made\n * if desired for dates that are prior to the Gregorian changeover and which fall\n * between January 1 and March 24.\n *\n * <p>Values calculated for the <code>WEEK_OF_YEAR</code> field range from 1 to\n * 53.  Week 1 for a year is the first week that contains at least\n * <code>getMinimalDaysInFirstWeek()</code> days from that year.  It thus\n * depends on the values of <code>getMinimalDaysInFirstWeek()</code>,\n * <code>getFirstDayOfWeek()</code>, and the day of the week of January 1.\n * Weeks between week 1 of one year and week 1 of the following year are\n * numbered sequentially from 2 to 52 or 53 (as needed).\n *\n * <p>For example, January 1, 1998 was a Thursday.  If\n * <code>getFirstDayOfWeek()</code> is <code>MONDAY</code> and\n * <code>getMinimalDaysInFirstWeek()</code> is 4 (these are the values\n * reflecting ISO 8601 and many national standards), then week 1 of 1998 starts\n * on December 29, 1997, and ends on January 4, 1998.  If, however,\n * <code>getFirstDayOfWeek()</code> is <code>SUNDAY</code>, then week 1 of 1998\n * starts on January 4, 1998, and ends on January 10, 1998; the first three days\n * of 1998 then are part of week 53 of 1997.\n *\n * <p>Example for using GregorianCalendar:\n * <pre>\n * \\code\n *     // get the supported ids for GMT-08:00 (Pacific Standard Time)\n *     UErrorCode success = U_ZERO_ERROR;\n *     const StringEnumeration *ids = TimeZone::createEnumeration(-8 * 60 * 60 * 1000);\n *     // if no ids were returned, something is wrong. get out.\n *     if (ids == 0 || ids->count(success) == 0) {\n *         return;\n *     }\n *\n *     // begin output\n *     cout << \"Current Time\" << endl;\n *\n *     // create a Pacific Standard Time time zone\n *     SimpleTimeZone* pdt = new SimpleTimeZone(-8 * 60 * 60 * 1000, ids->unext(NULL, success)));\n *\n *     // set up rules for daylight savings time\n *     pdt->setStartRule(UCAL_MARCH, 1, UCAL_SUNDAY, 2 * 60 * 60 * 1000);\n *     pdt->setEndRule(UCAL_NOVEMBER, 2, UCAL_SUNDAY, 2 * 60 * 60 * 1000);\n *\n *     // create a GregorianCalendar with the Pacific Daylight time zone\n *     // and the current date and time\n *     Calendar* calendar = new GregorianCalendar( pdt, success );\n *\n *     // print out a bunch of interesting things\n *     cout << \"ERA: \" << calendar->get( UCAL_ERA, success ) << endl;\n *     cout << \"YEAR: \" << calendar->get( UCAL_YEAR, success ) << endl;\n *     cout << \"MONTH: \" << calendar->get( UCAL_MONTH, success ) << endl;\n *     cout << \"WEEK_OF_YEAR: \" << calendar->get( UCAL_WEEK_OF_YEAR, success ) << endl;\n *     cout << \"WEEK_OF_MONTH: \" << calendar->get( UCAL_WEEK_OF_MONTH, success ) << endl;\n *     cout << \"DATE: \" << calendar->get( UCAL_DATE, success ) << endl;\n *     cout << \"DAY_OF_MONTH: \" << calendar->get( UCAL_DAY_OF_MONTH, success ) << endl;\n *     cout << \"DAY_OF_YEAR: \" << calendar->get( UCAL_DAY_OF_YEAR, success ) << endl;\n *     cout << \"DAY_OF_WEEK: \" << calendar->get( UCAL_DAY_OF_WEEK, success ) << endl;\n *     cout << \"DAY_OF_WEEK_IN_MONTH: \" << calendar->get( UCAL_DAY_OF_WEEK_IN_MONTH, success ) << endl;\n *     cout << \"AM_PM: \" << calendar->get( UCAL_AM_PM, success ) << endl;\n *     cout << \"HOUR: \" << calendar->get( UCAL_HOUR, success ) << endl;\n *     cout << \"HOUR_OF_DAY: \" << calendar->get( UCAL_HOUR_OF_DAY, success ) << endl;\n *     cout << \"MINUTE: \" << calendar->get( UCAL_MINUTE, success ) << endl;\n *     cout << \"SECOND: \" << calendar->get( UCAL_SECOND, success ) << endl;\n *     cout << \"MILLISECOND: \" << calendar->get( UCAL_MILLISECOND, success ) << endl;\n *     cout << \"ZONE_OFFSET: \" << (calendar->get( UCAL_ZONE_OFFSET, success )/(60*60*1000)) << endl;\n *     cout << \"DST_OFFSET: \" << (calendar->get( UCAL_DST_OFFSET, success )/(60*60*1000)) << endl;\n *\n *     cout << \"Current Time, with hour reset to 3\" << endl;\n *     calendar->clear(UCAL_HOUR_OF_DAY); // so doesn't override\n *     calendar->set(UCAL_HOUR, 3);\n *     cout << \"ERA: \" << calendar->get( UCAL_ERA, success ) << endl;\n *     cout << \"YEAR: \" << calendar->get( UCAL_YEAR, success ) << endl;\n *     cout << \"MONTH: \" << calendar->get( UCAL_MONTH, success ) << endl;\n *     cout << \"WEEK_OF_YEAR: \" << calendar->get( UCAL_WEEK_OF_YEAR, success ) << endl;\n *     cout << \"WEEK_OF_MONTH: \" << calendar->get( UCAL_WEEK_OF_MONTH, success ) << endl;\n *     cout << \"DATE: \" << calendar->get( UCAL_DATE, success ) << endl;\n *     cout << \"DAY_OF_MONTH: \" << calendar->get( UCAL_DAY_OF_MONTH, success ) << endl;\n *     cout << \"DAY_OF_YEAR: \" << calendar->get( UCAL_DAY_OF_YEAR, success ) << endl;\n *     cout << \"DAY_OF_WEEK: \" << calendar->get( UCAL_DAY_OF_WEEK, success ) << endl;\n *     cout << \"DAY_OF_WEEK_IN_MONTH: \" << calendar->get( UCAL_DAY_OF_WEEK_IN_MONTH, success ) << endl;\n *     cout << \"AM_PM: \" << calendar->get( UCAL_AM_PM, success ) << endl;\n *     cout << \"HOUR: \" << calendar->get( UCAL_HOUR, success ) << endl;\n *     cout << \"HOUR_OF_DAY: \" << calendar->get( UCAL_HOUR_OF_DAY, success ) << endl;\n *     cout << \"MINUTE: \" << calendar->get( UCAL_MINUTE, success ) << endl;\n *     cout << \"SECOND: \" << calendar->get( UCAL_SECOND, success ) << endl;\n *     cout << \"MILLISECOND: \" << calendar->get( UCAL_MILLISECOND, success ) << endl;\n *     cout << \"ZONE_OFFSET: \" << (calendar->get( UCAL_ZONE_OFFSET, success )/(60*60*1000)) << endl; // in hours\n *     cout << \"DST_OFFSET: \" << (calendar->get( UCAL_DST_OFFSET, success )/(60*60*1000)) << endl; // in hours\n *\n *     if (U_FAILURE(success)) {\n *         cout << \"An error occured. success=\" << u_errorName(success) << endl;\n *     }\n *\n *     delete ids;\n *     delete calendar; // also deletes pdt\n * \\endcode\n * </pre>\n * @stable ICU 2.0\n */\nclass U_I18N_API GregorianCalendar: public Calendar {\npublic:\n\n    /**\n     * Useful constants for GregorianCalendar and TimeZone.\n     * @stable ICU 2.0\n     */\n    enum EEras {\n        BC,\n        AD\n    };\n\n    /**\n     * Constructs a default GregorianCalendar using the current time in the default time\n     * zone with the default locale.\n     *\n     * @param success  Indicates the status of GregorianCalendar object construction.\n     *                 Returns U_ZERO_ERROR if constructed successfully.\n     * @stable ICU 2.0\n     */\n    GregorianCalendar(UErrorCode& success);\n\n    /**\n     * Constructs a GregorianCalendar based on the current time in the given time zone\n     * with the default locale. Clients are no longer responsible for deleting the given\n     * time zone object after it's adopted.\n     *\n     * @param zoneToAdopt     The given timezone.\n     * @param success  Indicates the status of GregorianCalendar object construction.\n     *                 Returns U_ZERO_ERROR if constructed successfully.\n     * @stable ICU 2.0\n     */\n    GregorianCalendar(TimeZone* zoneToAdopt, UErrorCode& success);\n\n    /**\n     * Constructs a GregorianCalendar based on the current time in the given time zone\n     * with the default locale.\n     *\n     * @param zone     The given timezone.\n     * @param success  Indicates the status of GregorianCalendar object construction.\n     *                 Returns U_ZERO_ERROR if constructed successfully.\n     * @stable ICU 2.0\n     */\n    GregorianCalendar(const TimeZone& zone, UErrorCode& success);\n\n    /**\n     * Constructs a GregorianCalendar based on the current time in the default time zone\n     * with the given locale.\n     *\n     * @param aLocale  The given locale.\n     * @param success  Indicates the status of GregorianCalendar object construction.\n     *                 Returns U_ZERO_ERROR if constructed successfully.\n     * @stable ICU 2.0\n     */\n    GregorianCalendar(const Locale& aLocale, UErrorCode& success);\n\n    /**\n     * Constructs a GregorianCalendar based on the current time in the given time zone\n     * with the given locale. Clients are no longer responsible for deleting the given\n     * time zone object after it's adopted.\n     *\n     * @param zoneToAdopt     The given timezone.\n     * @param aLocale  The given locale.\n     * @param success  Indicates the status of GregorianCalendar object construction.\n     *                 Returns U_ZERO_ERROR if constructed successfully.\n     * @stable ICU 2.0\n     */\n    GregorianCalendar(TimeZone* zoneToAdopt, const Locale& aLocale, UErrorCode& success);\n\n    /**\n     * Constructs a GregorianCalendar based on the current time in the given time zone\n     * with the given locale.\n     *\n     * @param zone     The given timezone.\n     * @param aLocale  The given locale.\n     * @param success  Indicates the status of GregorianCalendar object construction.\n     *                 Returns U_ZERO_ERROR if constructed successfully.\n     * @stable ICU 2.0\n     */\n    GregorianCalendar(const TimeZone& zone, const Locale& aLocale, UErrorCode& success);\n\n    /**\n     * Constructs a GregorianCalendar with the given AD date set in the default time\n     * zone with the default locale.\n     *\n     * @param year     The value used to set the YEAR time field in the calendar.\n     * @param month    The value used to set the MONTH time field in the calendar. Month\n     *                 value is 0-based. e.g., 0 for January.\n     * @param date     The value used to set the DATE time field in the calendar.\n     * @param success  Indicates the status of GregorianCalendar object construction.\n     *                 Returns U_ZERO_ERROR if constructed successfully.\n     * @stable ICU 2.0\n     */\n    GregorianCalendar(int32_t year, int32_t month, int32_t date, UErrorCode& success);\n\n    /**\n     * Constructs a GregorianCalendar with the given AD date and time set for the\n     * default time zone with the default locale.\n     *\n     * @param year     The value used to set the YEAR time field in the calendar.\n     * @param month    The value used to set the MONTH time field in the calendar. Month\n     *                 value is 0-based. e.g., 0 for January.\n     * @param date     The value used to set the DATE time field in the calendar.\n     * @param hour     The value used to set the HOUR_OF_DAY time field in the calendar.\n     * @param minute   The value used to set the MINUTE time field in the calendar.\n     * @param success  Indicates the status of GregorianCalendar object construction.\n     *                 Returns U_ZERO_ERROR if constructed successfully.\n     * @stable ICU 2.0\n     */\n    GregorianCalendar(int32_t year, int32_t month, int32_t date, int32_t hour, int32_t minute, UErrorCode& success);\n\n    /**\n     * Constructs a GregorianCalendar with the given AD date and time set for the\n     * default time zone with the default locale.\n     *\n     * @param year     The value used to set the YEAR time field in the calendar.\n     * @param month    The value used to set the MONTH time field in the calendar. Month\n     *                 value is 0-based. e.g., 0 for January.\n     * @param date     The value used to set the DATE time field in the calendar.\n     * @param hour     The value used to set the HOUR_OF_DAY time field in the calendar.\n     * @param minute   The value used to set the MINUTE time field in the calendar.\n     * @param second   The value used to set the SECOND time field in the calendar.\n     * @param success  Indicates the status of GregorianCalendar object construction.\n     *                 Returns U_ZERO_ERROR if constructed successfully.\n     * @stable ICU 2.0\n     */\n    GregorianCalendar(int32_t year, int32_t month, int32_t date, int32_t hour, int32_t minute, int32_t second, UErrorCode& success);\n\n    /**\n     * Destructor\n     * @stable ICU 2.0\n     */\n    virtual ~GregorianCalendar();\n\n    /**\n     * Copy constructor\n     * @param source    the object to be copied.\n     * @stable ICU 2.0\n     */\n    GregorianCalendar(const GregorianCalendar& source);\n\n    /**\n     * Default assignment operator\n     * @param right    the object to be copied.\n     * @stable ICU 2.0\n     */\n    GregorianCalendar& operator=(const GregorianCalendar& right);\n\n    /**\n     * Create and return a polymorphic copy of this calendar.\n     * @return    return a polymorphic copy of this calendar.\n     * @stable ICU 2.0\n     */\n    virtual Calendar* clone(void) const;\n\n    /**\n     * Sets the GregorianCalendar change date. This is the point when the switch from\n     * Julian dates to Gregorian dates occurred. Default is 00:00:00 local time, October\n     * 15, 1582. Previous to this time and date will be Julian dates.\n     *\n     * @param date     The given Gregorian cutover date.\n     * @param success  Output param set to success/failure code on exit.\n     * @stable ICU 2.0\n     */\n    void setGregorianChange(UDate date, UErrorCode& success);\n\n    /**\n     * Gets the Gregorian Calendar change date. This is the point when the switch from\n     * Julian dates to Gregorian dates occurred. Default is 00:00:00 local time, October\n     * 15, 1582. Previous to this time and date will be Julian dates.\n     *\n     * @return   The Gregorian cutover time for this calendar.\n     * @stable ICU 2.0\n     */\n    UDate getGregorianChange(void) const;\n\n    /**\n     * Return true if the given year is a leap year. Determination of whether a year is\n     * a leap year is actually very complicated. We do something crude and mostly\n     * correct here, but for a real determination you need a lot of contextual\n     * information. For example, in Sweden, the change from Julian to Gregorian happened\n     * in a complex way resulting in missed leap years and double leap years between\n     * 1700 and 1753. Another example is that after the start of the Julian calendar in\n     * 45 B.C., the leap years did not regularize until 8 A.D. This method ignores these\n     * quirks, and pays attention only to the Julian onset date and the Gregorian\n     * cutover (which can be changed).\n     *\n     * @param year  The given year.\n     * @return      True if the given year is a leap year; false otherwise.\n     * @stable ICU 2.0\n     */\n    UBool isLeapYear(int32_t year) const;\n\n    /**\n     * Returns TRUE if the given Calendar object is equivalent to this\n     * one.  Calendar override.\n     *\n     * @param other the Calendar to be compared with this Calendar   \n     * @stable ICU 2.4\n     */\n    virtual UBool isEquivalentTo(const Calendar& other) const;\n\n    /**\n     * (Overrides Calendar) Rolls up or down by the given amount in the specified field.\n     * For more information, see the documentation for Calendar::roll().\n     *\n     * @param field   The time field.\n     * @param amount  Indicates amount to roll.\n     * @param status  Output param set to success/failure code on exit. If any value\n     *                previously set in the time field is invalid, this will be set to\n     *                an error status.\n     * @deprecated ICU 2.6. Use roll(UCalendarDateFields field, int32_t amount, UErrorCode& status) instead.\n     */\n    virtual void roll(EDateFields field, int32_t amount, UErrorCode& status);\n\n    /**\n     * (Overrides Calendar) Rolls up or down by the given amount in the specified field.\n     * For more information, see the documentation for Calendar::roll().\n     *\n     * @param field   The time field.\n     * @param amount  Indicates amount to roll.\n     * @param status  Output param set to success/failure code on exit. If any value\n     *                previously set in the time field is invalid, this will be set to\n     *                an error status.\n     * @stable ICU 2.6.\n     */\n    virtual void roll(UCalendarDateFields field, int32_t amount, UErrorCode& status);\n\n#ifndef U_HIDE_DEPRECATED_API\n    /**\n     * Return the minimum value that this field could have, given the current date.\n     * For the Gregorian calendar, this is the same as getMinimum() and getGreatestMinimum().\n     * @param field    the time field.\n     * @return         the minimum value that this field could have, given the current date.\n     * @deprecated ICU 2.6. Use getActualMinimum(UCalendarDateFields field) instead.\n     */\n    int32_t getActualMinimum(EDateFields field) const;\n\n    /**\n     * Return the minimum value that this field could have, given the current date.\n     * For the Gregorian calendar, this is the same as getMinimum() and getGreatestMinimum().\n     * @param field    the time field.\n     * @param status\n     * @return         the minimum value that this field could have, given the current date.\n     * @deprecated ICU 2.6. Use getActualMinimum(UCalendarDateFields field) instead. (Added to ICU 3.0 for signature consistency)\n     */\n    int32_t getActualMinimum(EDateFields field, UErrorCode& status) const;\n#endif  /* U_HIDE_DEPRECATED_API */\n\n    /**\n     * Return the minimum value that this field could have, given the current date.\n     * For the Gregorian calendar, this is the same as getMinimum() and getGreatestMinimum().\n     * @param field    the time field.\n     * @param status   error result.\n     * @return         the minimum value that this field could have, given the current date.\n     * @stable ICU 3.0\n     */\n    int32_t getActualMinimum(UCalendarDateFields field, UErrorCode &status) const;\n\n#ifndef U_HIDE_DEPRECATED_API\n    /**\n     * Return the maximum value that this field could have, given the current date.\n     * For example, with the date \"Feb 3, 1997\" and the DAY_OF_MONTH field, the actual\n     * maximum would be 28; for \"Feb 3, 1996\" it s 29.  Similarly for a Hebrew calendar,\n     * for some years the actual maximum for MONTH is 12, and for others 13.\n     * @param field    the time field.\n     * @return         the maximum value that this field could have, given the current date.\n     * @deprecated ICU 2.6. Use getActualMaximum(UCalendarDateFields field) instead.\n     */\n    int32_t getActualMaximum(EDateFields field) const;\n#endif  /* U_HIDE_DEPRECATED_API */\n\n    /**\n     * Return the maximum value that this field could have, given the current date.\n     * For example, with the date \"Feb 3, 1997\" and the DAY_OF_MONTH field, the actual\n     * maximum would be 28; for \"Feb 3, 1996\" it s 29.  Similarly for a Hebrew calendar,\n     * for some years the actual maximum for MONTH is 12, and for others 13.\n     * @param field    the time field.\n     * @param status   returns any errors that may result from this function call.\n     * @return         the maximum value that this field could have, given the current date.\n     * @stable ICU 2.6\n     */\n    virtual int32_t getActualMaximum(UCalendarDateFields field, UErrorCode& status) const;\n\n    /**\n     * (Overrides Calendar) Return true if the current date for this Calendar is in\n     * Daylight Savings Time. Recognizes DST_OFFSET, if it is set.\n     *\n     * @param status Fill-in parameter which receives the status of this operation.\n     * @return   True if the current date for this Calendar is in Daylight Savings Time,\n     *           false, otherwise.\n     * @stable ICU 2.0\n     */\n    virtual UBool inDaylightTime(UErrorCode& status) const;\n\npublic:\n\n    /**\n     * Override Calendar Returns a unique class ID POLYMORPHICALLY. Pure virtual\n     * override. This method is to implement a simple version of RTTI, since not all C++\n     * compilers support genuine RTTI. Polymorphic operator==() and clone() methods call\n     * this method.\n     *\n     * @return   The class ID for this object. All objects of a given class have the\n     *           same class ID. Objects of other classes have different class IDs.\n     * @stable ICU 2.0\n     */\n    virtual UClassID getDynamicClassID(void) const;\n\n    /**\n     * Return the class ID for this class. This is useful only for comparing to a return\n     * value from getDynamicClassID(). For example:\n     *\n     *      Base* polymorphic_pointer = createPolymorphicObject();\n     *      if (polymorphic_pointer->getDynamicClassID() ==\n     *          Derived::getStaticClassID()) ...\n     *\n     * @return   The class ID for all objects of this class.\n     * @stable ICU 2.0\n     */\n    static UClassID U_EXPORT2 getStaticClassID(void);\n\n/* Cannot use #ifndef U_HIDE_DRAFT_API for the following draft method since it is virtual */\n    /**\n     * Returns the calendar type name string for this Calendar object.\n     * The returned string is the legacy ICU calendar attribute value,\n     * for example, \"gregorian\" or \"japanese\".\n     *\n     * For more details see the Calendar::getType() documentation.\n     *\n     * @return legacy calendar type name string\n     * @draft ICU 49\n     */\n    virtual const char * getType() const;\n\n private:\n    GregorianCalendar(); // default constructor not implemented\n\n protected:\n    /**\n     * Return the ERA.  We need a special method for this because the\n     * default ERA is AD, but a zero (unset) ERA is BC.\n     * @return    the ERA.\n     * @internal\n     */\n    virtual int32_t internalGetEra() const;\n\n    /**\n     * Return the Julian day number of day before the first day of the\n     * given month in the given extended year.  Subclasses should override\n     * this method to implement their calendar system.\n     * @param eyear the extended year\n     * @param month the zero-based month, or 0 if useMonth is false\n     * @param useMonth if false, compute the day before the first day of\n     * the given year, otherwise, compute the day before the first day of\n     * the given month\n     * @return the Julian day number of the day before the first\n     * day of the given month and year\n     * @internal\n     */\n    virtual int32_t handleComputeMonthStart(int32_t eyear, int32_t month,\n                                                   UBool useMonth) const;\n\n    /**\n     * Subclasses may override this.  This method calls\n     * handleGetMonthLength() to obtain the calendar-specific month\n     * length.\n     * @param bestField which field to use to calculate the date \n     * @return julian day specified by calendar fields.\n     * @internal\n     */\n    virtual int32_t handleComputeJulianDay(UCalendarDateFields bestField)  ;\n\n    /**\n     * Return the number of days in the given month of the given extended\n     * year of this calendar system.  Subclasses should override this\n     * method if they can provide a more correct or more efficient\n     * implementation than the default implementation in Calendar.\n     * @internal\n     */\n    virtual int32_t handleGetMonthLength(int32_t extendedYear, int32_t month) const;\n\n    /**\n     * Return the number of days in the given extended year of this\n     * calendar system.  Subclasses should override this method if they can\n     * provide a more correct or more efficient implementation than the\n     * default implementation in Calendar.\n     * @stable ICU 2.0\n     */\n    virtual int32_t handleGetYearLength(int32_t eyear) const;\n\n    /**\n     * return the length of the given month.\n     * @param month    the given month.\n     * @return    the length of the given month.\n     * @internal\n     */\n    virtual int32_t monthLength(int32_t month) const;\n\n    /**\n     * return the length of the month according to the given year.\n     * @param month    the given month.\n     * @param year     the given year.\n     * @return         the length of the month\n     * @internal\n     */\n    virtual int32_t monthLength(int32_t month, int32_t year) const;\n\n#ifndef U_HIDE_INTERNAL_API\n    /**\n     * return the length of the given year.\n     * @param year    the given year.\n     * @return        the length of the given year.\n     * @internal\n     */\n    int32_t yearLength(int32_t year) const;\n    \n    /**\n     * return the length of the year field.\n     * @return    the length of the year field\n     * @internal\n     */\n    int32_t yearLength(void) const;\n\n    /**\n     * After adjustments such as add(MONTH), add(YEAR), we don't want the\n     * month to jump around.  E.g., we don't want Jan 31 + 1 month to go to Mar\n     * 3, we want it to go to Feb 28.  Adjustments which might run into this\n     * problem call this method to retain the proper month.\n     * @internal\n     */\n    void pinDayOfMonth(void);\n#endif  /* U_HIDE_INTERNAL_API */\n\n    /**\n     * Return the day number with respect to the epoch.  January 1, 1970 (Gregorian)\n     * is day zero.\n     * @param status Fill-in parameter which receives the status of this operation.\n     * @return       the day number with respect to the epoch.  \n     * @internal\n     */\n    virtual UDate getEpochDay(UErrorCode& status);\n\n    /**\n     * Subclass API for defining limits of different types.\n     * Subclasses must implement this method to return limits for the\n     * following fields:\n     *\n     * <pre>UCAL_ERA\n     * UCAL_YEAR\n     * UCAL_MONTH\n     * UCAL_WEEK_OF_YEAR\n     * UCAL_WEEK_OF_MONTH\n     * UCAL_DATE (DAY_OF_MONTH on Java)\n     * UCAL_DAY_OF_YEAR\n     * UCAL_DAY_OF_WEEK_IN_MONTH\n     * UCAL_YEAR_WOY\n     * UCAL_EXTENDED_YEAR</pre>\n     *\n     * @param field one of the above field numbers\n     * @param limitType one of <code>MINIMUM</code>, <code>GREATEST_MINIMUM</code>,\n     * <code>LEAST_MAXIMUM</code>, or <code>MAXIMUM</code>\n     * @internal\n     */\n    virtual int32_t handleGetLimit(UCalendarDateFields field, ELimitType limitType) const;\n\n    /**\n     * Return the extended year defined by the current fields.  This will\n     * use the UCAL_EXTENDED_YEAR field or the UCAL_YEAR and supra-year fields (such\n     * as UCAL_ERA) specific to the calendar system, depending on which set of\n     * fields is newer.\n     * @return the extended year\n     * @internal\n     */\n    virtual int32_t handleGetExtendedYear();\n\n    /** \n     * Subclasses may override this to convert from week fields \n     * (YEAR_WOY and WEEK_OF_YEAR) to an extended year in the case\n     * where YEAR, EXTENDED_YEAR are not set.\n     * The Gregorian implementation assumes a yearWoy in gregorian format, according to the current era.\n     * @return the extended year, UCAL_EXTENDED_YEAR\n     * @internal\n     */\n    virtual int32_t handleGetExtendedYearFromWeekFields(int32_t yearWoy, int32_t woy);\n\n\n    /**\n     * Subclasses may override this method to compute several fields\n     * specific to each calendar system.  These are:\n     *\n     * <ul><li>ERA\n     * <li>YEAR\n     * <li>MONTH\n     * <li>DAY_OF_MONTH\n     * <li>DAY_OF_YEAR\n     * <li>EXTENDED_YEAR</ul>\n     *\n     * <p>The GregorianCalendar implementation implements\n     * a calendar with the specified Julian/Gregorian cutover date.\n     * @internal\n     */\n    virtual void handleComputeFields(int32_t julianDay, UErrorCode &status);\n\n private:\n    /**\n     * Compute the julian day number of the given year.\n     * @param isGregorian    if true, using Gregorian calendar, otherwise using Julian calendar\n     * @param year           the given year.\n     * @param isLeap         true if the year is a leap year.       \n     * @return \n     */\n    static double computeJulianDayOfYear(UBool isGregorian, int32_t year,\n                                         UBool& isLeap);\n    \n    /**\n     * Validates the values of the set time fields.  True if they're all valid.\n     * @return    True if the set time fields are all valid.\n     */\n    UBool validateFields(void) const;\n\n    /**\n     * Validates the value of the given time field.  True if it's valid.\n     */\n    UBool boundsCheck(int32_t value, UCalendarDateFields field) const;\n\n    /**\n     * Return the pseudo-time-stamp for two fields, given their\n     * individual pseudo-time-stamps.  If either of the fields\n     * is unset, then the aggregate is unset.  Otherwise, the\n     * aggregate is the later of the two stamps.\n     * @param stamp_a    One given field.\n     * @param stamp_b    Another given field.\n     * @return the pseudo-time-stamp for two fields\n     */\n    int32_t aggregateStamp(int32_t stamp_a, int32_t stamp_b);\n\n    /**\n     * The point at which the Gregorian calendar rules are used, measured in\n     * milliseconds from the standard epoch.  Default is October 15, 1582\n     * (Gregorian) 00:00:00 UTC, that is, October 4, 1582 (Julian) is followed\n     * by October 15, 1582 (Gregorian).  This corresponds to Julian day number\n     * 2299161. This is measured from the standard epoch, not in Julian Days.\n     * @internal\n     */\n    UDate                fGregorianCutover;\n\n    /**\n     * Julian day number of the Gregorian cutover\n     */\n    int32_t             fCutoverJulianDay;\n\n    /**\n     * Midnight, local time (using this Calendar's TimeZone) at or before the\n     * gregorianCutover. This is a pure date value with no time of day or\n     * timezone component.\n     */\n    UDate                 fNormalizedGregorianCutover;// = gregorianCutover;\n\n    /**\n     * The year of the gregorianCutover, with 0 representing\n     * 1 BC, -1 representing 2 BC, etc.\n     */\n    int32_t fGregorianCutoverYear;// = 1582;\n\n    /**\n     * The year of the gregorianCutover, with 0 representing\n     * 1 BC, -1 representing 2 BC, etc.\n     */\n    int32_t fGregorianCutoverJulianDay;// = 2299161;\n\n    /**\n     * Converts time as milliseconds to Julian date. The Julian date used here is not a\n     * true Julian date, since it is measured from midnight, not noon.\n     *\n     * @param millis  The given milliseconds.\n     * @return        The Julian date number.\n     */\n    static double millisToJulianDay(UDate millis);\n\n    /**\n     * Converts Julian date to time as milliseconds. The Julian date used here is not a\n     * true Julian date, since it is measured from midnight, not noon.\n     *\n     * @param julian  The given Julian date number.\n     * @return        Time as milliseconds.\n     */\n    static UDate julianDayToMillis(double julian);\n\n    /**\n     * Used by handleComputeJulianDay() and handleComputeMonthStart().\n     * Temporary field indicating whether the calendar is currently Gregorian as opposed to Julian.\n     */\n    UBool fIsGregorian;\n\n    /**\n     * Used by handleComputeJulianDay() and handleComputeMonthStart().\n     * Temporary field indicating that the sense of the gregorian cutover should be inverted\n     * to handle certain calculations on and around the cutover date.\n     */\n    UBool fInvertGregorian;\n\n\n public: // internal implementation\n\n    /**\n     * @internal \n     * @return TRUE if this calendar has the notion of a default century\n     */\n    virtual UBool haveDefaultCentury() const;\n\n    /**\n     * @internal\n     * @return the start of the default century\n     */\n    virtual UDate defaultCenturyStart() const;\n\n    /**\n     * @internal \n     * @return the beginning year of the default century\n     */\n    virtual int32_t defaultCenturyStartYear() const;\n\n private:\n    /**\n     * The system maintains a static default century start date.  This is initialized\n     * the first time it is used.  Before then, it is set to SYSTEM_DEFAULT_CENTURY to\n     * indicate an uninitialized state.  Once the system default century date and year\n     * are set, they do not change.\n     */\n    static UDate         fgSystemDefaultCenturyStart;\n\n    /**\n     * See documentation for systemDefaultCenturyStart.\n     */\n    static int32_t          fgSystemDefaultCenturyStartYear;\n\n    /**\n     * Default value that indicates the defaultCenturyStartYear is unitialized\n     */\n    static const int32_t    fgSystemDefaultCenturyYear;\n\n    /**\n     * Default value that indicates the UDate of the beginning of the system default century\n     */\n    static const UDate        fgSystemDefaultCentury;\n\n    /**\n     * Returns the beginning date of the 100-year window that dates with 2-digit years\n     * are considered to fall within.\n     * @return    the beginning date of the 100-year window that dates with 2-digit years\n     *            are considered to fall within.\n     */\n    UDate         internalGetDefaultCenturyStart(void) const;\n\n    /**\n     * Returns the first year of the 100-year window that dates with 2-digit years\n     * are considered to fall within.\n     * @return    the first year of the 100-year window that dates with 2-digit years\n     *            are considered to fall within.\n     */\n    int32_t          internalGetDefaultCenturyStartYear(void) const;\n\n    /**\n     * Initializes the 100-year window that dates with 2-digit years are considered\n     * to fall within so that its start date is 80 years before the current time.\n     */\n    static void  initializeSystemDefaultCentury(void);\n\n};\n\nU_NAMESPACE_END\n\n#endif /* #if !UCONFIG_NO_FORMATTING */\n\n#endif // _GREGOCAL\n//eof\n\n"
  },
  {
    "path": "deprecated/android/addons/icucompat/unicode/icudataver.h",
    "content": "/*\n******************************************************************************\n*\n*   Copyright (C) 2009-2012, International Business Machines\n*   Corporation and others.  All Rights Reserved.\n*\n******************************************************************************\n*/\n\n\n/**\n * \\file\n * \\brief C API: access to ICU Data Version number\n */\n\n#ifndef __ICU_DATA_VER_H__\n#define __ICU_DATA_VER_H__\n\n#include \"unicode/utypes.h\"\n\n#ifndef U_HIDE_DRAFT_API\n/**\n * @draft ICU 49\n */\n#define U_ICU_VERSION_BUNDLE \"icuver\"\n\n/**\n * @draft ICU 49\n */\n#define U_ICU_DATA_KEY \"DataVersion\"\n\n/**\n * Retrieves the data version from icuver and stores it in dataVersionFillin.\n * \n * @param dataVersionFillin icuver data version information to be filled in if not-null\n * @param status stores the error code from the calls to resource bundle\n * \n * @draft ICU 49\n */\nU_DRAFT void U_EXPORT2 u_getDataVersion(UVersionInfo dataVersionFillin, UErrorCode *status);\n#endif  /* U_HIDE_DRAFT_API */\n\n#endif\n"
  },
  {
    "path": "deprecated/android/addons/icucompat/unicode/icuplug.h",
    "content": "/*\n******************************************************************************\n*\n*   Copyright (C) 2009-2012, International Business Machines\n*   Corporation and others.  All Rights Reserved.\n*\n******************************************************************************\n*\n*  FILE NAME : icuplug.h\n*\n*   Date         Name        Description\n*   10/29/2009   sl          New.\n******************************************************************************\n*/\n\n/**\n * \\file\n * \\brief C API: ICU Plugin API \n *\n * <h2>C API: ICU Plugin API</h2>\n *\n * <p>C API allowing run-time loadable modules that extend or modify ICU functionality.</p>\n *\n * <h3>Loading and Configuration</h3>\n *\n * <p>At ICU startup time, the environment variable \"ICU_PLUGINS\" will be \n * queried for a directory name.  If it is not set, the preprocessor symbol \n * \"DEFAULT_ICU_PLUGINS\" will be checked for a default value.</p>\n *\n * <p>Within the above-named directory, the file  \"icuplugins##.txt\" will be \n * opened, if present, where ## is the major+minor number of the currently \n * running ICU (such as, 44 for ICU 4.4, thus icuplugins44.txt)</p>\n *\n * <p>The configuration file has this format:</p>\n *\n * <ul>\n * <li>Hash (#) begins a comment line</li>\n * \n * <li>Non-comment lines have two or three components:\n * LIBRARYNAME     ENTRYPOINT     [ CONFIGURATION .. ]</li>\n *\n * <li>Tabs or spaces separate the three items.</li>\n *\n * <li>LIBRARYNAME is the name of a shared library, either a short name if \n * it is on the loader path,  or a full pathname.</li>\n *\n * <li>ENTRYPOINT is the short (undecorated) symbol name of the plugin's \n * entrypoint, as above.</li>\n *\n * <li>CONFIGURATION is the entire rest of the line . It's passed as-is to \n * the plugin.</li>\n * </ul>\n *\n * <p>An example configuration file is, in its entirety:</p>\n *\n * \\code\n * # this is icuplugins44.txt\n * testplug.dll    myPlugin        hello=world\n * \\endcode\n * <p>Plugins are categorized as \"high\" or \"low\" level.  Low level are those \n * which must be run BEFORE high level plugins, and before any operations \n * which cause ICU to be 'initialized'.  If a plugin is low level but \n * causes ICU to allocate memory or become initialized, that plugin is said \n * to cause a 'level change'. </p>\n *\n * <p>At load time, ICU first queries all plugins to determine their level, \n * then loads all 'low' plugins first, and then loads all 'high' plugins.  \n * Plugins are otherwise loaded in the order listed in the configuration file.</p>\n * \n * <h3>Implementing a Plugin</h3>\n * \\code\n * U_CAPI UPlugTokenReturn U_EXPORT2 \n * myPlugin (UPlugData *plug, UPlugReason reason, UErrorCode *status) {\n *   if(reason==UPLUG_REASON_QUERY) {\n *      uplug_setPlugName(plug, \"Simple Plugin\");\n *      uplug_setPlugLevel(plug, UPLUG_LEVEL_HIGH);\n *    } else if(reason==UPLUG_REASON_LOAD) {\n *       ... Set up some ICU things here.... \n *    } else if(reason==UPLUG_REASON_UNLOAD) {\n *       ... unload, clean up ...\n *    }\n *   return UPLUG_TOKEN;\n *  }\n * \\endcode\n *\n * <p>The UPlugData*  is an opaque pointer to the plugin-specific data, and is \n * used in all other API calls.</p>\n *\n * <p>The API contract is:</p>\n * <ol><li>The plugin MUST always return UPLUG_TOKEN as a return value- to \n * indicate that it is a valid plugin.</li>\n *\n * <li>When the 'reason' parameter is set to UPLUG_REASON_QUERY,  the \n * plugin MUST call uplug_setPlugLevel() to indicate whether it is a high \n * level or low level plugin.</li>\n *\n * <li>When the 'reason' parameter is UPLUG_REASON_QUERY, the plugin \n * SHOULD call uplug_setPlugName to indicate a human readable plugin name.</li></ol>\n * \n *\n * \\internal ICU 4.4 Technology Preview\n */\n\n\n#ifndef ICUPLUG_H\n#define ICUPLUG_H\n\n#include \"unicode/utypes.h\"\n\n\n/* === Basic types === */\n\n#ifndef U_HIDE_INTERNAL_API\n/**\n * @{\n * Opaque structure passed to/from a plugin. \n * use the APIs to access it.\n * @internal ICU 4.4 Technology Preview\n */\n\nstruct UPlugData;\ntypedef struct UPlugData UPlugData;\n\n/** @} */\n\n/**\n * Random Token to identify a valid ICU plugin. Plugins must return this \n * from the entrypoint.\n * @internal ICU 4.4 Technology Preview\n */\n#define UPLUG_TOKEN 0x54762486\n\n/**\n * Max width of names, symbols, and configuration strings\n * @internal ICU 4.4 Technology Preview\n */\n#define UPLUG_NAME_MAX              100\n\n\n/**\n * Return value from a plugin entrypoint. \n * Must always be set to UPLUG_TOKEN\n * @see UPLUG_TOKEN\n * @internal ICU 4.4 Technology Preview\n */\ntypedef uint32_t UPlugTokenReturn;\n\n/**\n * Reason code for the entrypoint's call\n * @internal ICU 4.4 Technology Preview\n */\ntypedef enum {\n    UPLUG_REASON_QUERY = 0,     /**< The plugin is being queried for info. **/\n    UPLUG_REASON_LOAD = 1,     /**< The plugin is being loaded. **/\n    UPLUG_REASON_UNLOAD = 2,   /**< The plugin is being unloaded. **/\n    UPLUG_REASON_COUNT         /**< count of known reasons **/\n} UPlugReason;\n\n\n/**\n * Level of plugin loading\n *     INITIAL:  UNKNOWN\n *       QUERY:   INVALID ->  { LOW | HIGH }\n *     ERR -> INVALID\n * @internal ICU 4.4 Technology Preview\n */\ntypedef enum {\n    UPLUG_LEVEL_INVALID = 0,     /**< The plugin is invalid, hasn't called uplug_setLevel, or can't load. **/\n    UPLUG_LEVEL_UNKNOWN = 1,     /**< The plugin is waiting to be installed. **/\n    UPLUG_LEVEL_LOW     = 2,     /**< The plugin must be called before u_init completes **/\n    UPLUG_LEVEL_HIGH    = 3,     /**< The plugin can run at any time. **/\n    UPLUG_LEVEL_COUNT         /**< count of known reasons **/\n} UPlugLevel;\n\n/**\n * Entrypoint for an ICU plugin.\n * @param plug the UPlugData handle. \n * @param status the plugin's extended status code.\n * @return A valid plugin must return UPLUG_TOKEN\n * @internal ICU 4.4 Technology Preview\n */\ntypedef UPlugTokenReturn (U_EXPORT2 UPlugEntrypoint) (\n                  UPlugData *plug,\n                  UPlugReason reason,\n                  UErrorCode *status);\n\n/* === Needed for Implementing === */\n\n/**\n * Request that this plugin not be unloaded at cleanup time.\n * This is appropriate for plugins which cannot be cleaned up.\n * @see u_cleanup()\n * @param plug plugin\n * @param dontUnload  set true if this plugin can't be unloaded\n * @internal ICU 4.4 Technology Preview\n */\nU_INTERNAL void U_EXPORT2 \nuplug_setPlugNoUnload(UPlugData *plug, UBool dontUnload);\n\n/**\n * Set the level of this plugin.\n * @param plug plugin data handle\n * @param level the level of this plugin\n * @internal ICU 4.4 Technology Preview\n */\nU_INTERNAL void U_EXPORT2\nuplug_setPlugLevel(UPlugData *plug, UPlugLevel level);\n\n/**\n * Get the level of this plugin.\n * @param plug plugin data handle\n * @return the level of this plugin\n * @internal ICU 4.4 Technology Preview\n */\nU_INTERNAL UPlugLevel U_EXPORT2\nuplug_getPlugLevel(UPlugData *plug);\n\n/**\n * Get the lowest level of plug which can currently load.\n * For example, if UPLUG_LEVEL_LOW is returned, then low level plugins may load\n * if UPLUG_LEVEL_HIGH is returned, then only high level plugins may load.\n * @return the lowest level of plug which can currently load\n * @internal ICU 4.4 Technology Preview\n */\nU_INTERNAL UPlugLevel U_EXPORT2\nuplug_getCurrentLevel(void);\n\n\n/**\n * Get plug load status\n * @return The error code of this plugin's load attempt.\n * @internal ICU 4.4 Technology Preview\n */\nU_INTERNAL UErrorCode U_EXPORT2\nuplug_getPlugLoadStatus(UPlugData *plug); \n\n/**\n * Set the human-readable name of this plugin.\n * @param plug plugin data handle\n * @param name the name of this plugin. The first UPLUG_NAME_MAX characters willi be copied into a new buffer.\n * @internal ICU 4.4 Technology Preview\n */\nU_INTERNAL void U_EXPORT2\nuplug_setPlugName(UPlugData *plug, const char *name);\n\n/**\n * Get the human-readable name of this plugin.\n * @param plug plugin data handle\n * @return the name of this plugin\n * @internal ICU 4.4 Technology Preview\n */\nU_INTERNAL const char * U_EXPORT2\nuplug_getPlugName(UPlugData *plug);\n\n/**\n * Return the symbol name for this plugin, if known.\n * @param plug plugin data handle\n * @return the symbol name, or NULL\n * @internal ICU 4.4 Technology Preview\n */\nU_INTERNAL const char * U_EXPORT2\nuplug_getSymbolName(UPlugData *plug);\n\n/**\n * Return the library name for this plugin, if known.\n * @param plug plugin data handle\n * @param status error code\n * @return the library name, or NULL\n * @internal ICU 4.4 Technology Preview\n */\nU_INTERNAL const char * U_EXPORT2\nuplug_getLibraryName(UPlugData *plug, UErrorCode *status);\n\n/**\n * Return the library used for this plugin, if known.\n * Plugins could use this to load data out of their \n * @param plug plugin data handle\n * @return the library, or NULL\n * @internal ICU 4.4 Technology Preview\n */\nU_INTERNAL void * U_EXPORT2\nuplug_getLibrary(UPlugData *plug);\n\n/**\n * Return the plugin-specific context data.\n * @param plug plugin data handle\n * @return the context, or NULL if not set\n * @internal ICU 4.4 Technology Preview\n */\nU_INTERNAL void * U_EXPORT2\nuplug_getContext(UPlugData *plug);\n\n/**\n * Set the plugin-specific context data.\n * @param plug plugin data handle\n * @param context new context to set\n * @internal ICU 4.4 Technology Preview\n */\nU_INTERNAL void U_EXPORT2\nuplug_setContext(UPlugData *plug, void *context);\n\n\n/**\n * Get the configuration string, if available.\n * The string is in the platform default codepage.\n * @param plug plugin data handle\n * @return configuration string, or else null.\n * @internal ICU 4.4 Technology Preview\n */\nU_INTERNAL const char * U_EXPORT2\nuplug_getConfiguration(UPlugData *plug);\n\n/**\n * Return all currently installed plugins, from newest to oldest\n * Usage Example:\n * \\code\n *    UPlugData *plug = NULL;\n *    while(plug=uplug_nextPlug(plug)) {\n *        ... do something with 'plug' ...\n *    }\n * \\endcode\n * Not thread safe- do not call while plugs are added or removed.\n * @param prior pass in 'NULL' to get the first (most recent) plug, \n *  otherwise pass the value returned on a prior call to uplug_nextPlug\n * @return the next oldest plugin, or NULL if no more.\n * @internal ICU 4.4 Technology Preview\n */\nU_INTERNAL UPlugData* U_EXPORT2\nuplug_nextPlug(UPlugData *prior);\n\n/**\n * Inject a plugin as if it were loaded from a library.\n * This is useful for testing plugins. \n * Note that it will have a 'NULL' library pointer associated\n * with it, and therefore no llibrary will be closed at cleanup time.\n * Low level plugins may not be able to load, as ordering can't be enforced.\n * @param entrypoint entrypoint to install\n * @param config user specified configuration string, if available, or NULL.\n * @param status error result\n * @return the new UPlugData associated with this plugin, or NULL if error.\n * @internal ICU 4.4 Technology Preview\n */\nU_INTERNAL UPlugData* U_EXPORT2\nuplug_loadPlugFromEntrypoint(UPlugEntrypoint *entrypoint, const char *config, UErrorCode *status);\n\n\n/**\n * Inject a plugin from a library, as if the information came from a config file.\n * Low level plugins may not be able to load, and ordering can't be enforced.\n * @param libName DLL name to load\n * @param sym symbol of plugin (UPlugEntrypoint function)\n * @param config configuration string, or NULL\n * @param status error result\n * @return the new UPlugData associated with this plugin, or NULL if error.\n * @internal ICU 4.4 Technology Preview\n */\nU_INTERNAL UPlugData* U_EXPORT2\nuplug_loadPlugFromLibrary(const char *libName, const char *sym, const char *config, UErrorCode *status);\n\n/**\n * Remove a plugin. \n * Will request the plugin to be unloaded, and close the library if needed\n * @param plug plugin handle to close\n * @param status error result\n * @internal ICU 4.4 Technology Preview\n */\nU_INTERNAL void U_EXPORT2\nuplug_removePlug(UPlugData *plug, UErrorCode *status);\n#endif  /* U_HIDE_INTERNAL_API */\n\n#endif\n"
  },
  {
    "path": "deprecated/android/addons/icucompat/unicode/idna.h",
    "content": "/*\n*******************************************************************************\n*   Copyright (C) 2010-2012, International Business Machines\n*   Corporation and others.  All Rights Reserved.\n*******************************************************************************\n*   file name:  idna.h\n*   encoding:   US-ASCII\n*   tab size:   8 (not used)\n*   indentation:4\n*\n*   created on: 2010mar05\n*   created by: Markus W. Scherer\n*/\n\n#ifndef __IDNA_H__\n#define __IDNA_H__\n\n/**\n * \\file\n * \\brief C++ API: Internationalizing Domain Names in Applications (IDNA)\n */\n\n#include \"unicode/utypes.h\"\n\n#if !UCONFIG_NO_IDNA\n\n#include \"unicode/bytestream.h\"\n#include \"unicode/stringpiece.h\"\n#include \"unicode/uidna.h\"\n#include \"unicode/unistr.h\"\n\nU_NAMESPACE_BEGIN\n\nclass IDNAInfo;\n\n/**\n * Abstract base class for IDNA processing.\n * See http://www.unicode.org/reports/tr46/\n * and http://www.ietf.org/rfc/rfc3490.txt\n *\n * The IDNA class is not intended for public subclassing.\n *\n * This C++ API currently only implements UTS #46.\n * The uidna.h C API implements both UTS #46 (functions using UIDNA service object)\n * and IDNA2003 (functions that do not use a service object).\n * @stable ICU 4.6\n */\nclass U_COMMON_API IDNA : public UObject {\npublic:\n    /**\n     * Destructor.\n     * @stable ICU 4.6\n     */\n    ~IDNA();\n\n    /**\n     * Returns an IDNA instance which implements UTS #46.\n     * Returns an unmodifiable instance, owned by the caller.\n     * Cache it for multiple operations, and delete it when done.\n     * The instance is thread-safe, that is, it can be used concurrently.\n     *\n     * UTS #46 defines Unicode IDNA Compatibility Processing,\n     * updated to the latest version of Unicode and compatible with both\n     * IDNA2003 and IDNA2008.\n     *\n     * The worker functions use transitional processing, including deviation mappings,\n     * unless UIDNA_NONTRANSITIONAL_TO_ASCII or UIDNA_NONTRANSITIONAL_TO_UNICODE\n     * is used in which case the deviation characters are passed through without change.\n     *\n     * Disallowed characters are mapped to U+FFFD.\n     *\n     * For available options see the uidna.h header.\n     * Operations with the UTS #46 instance do not support the\n     * UIDNA_ALLOW_UNASSIGNED option.\n     *\n     * By default, the UTS #46 implementation allows all ASCII characters (as valid or mapped).\n     * When the UIDNA_USE_STD3_RULES option is used, ASCII characters other than\n     * letters, digits, hyphen (LDH) and dot/full stop are disallowed and mapped to U+FFFD.\n     *\n     * @param options Bit set to modify the processing and error checking.\n     *                See option bit set values in uidna.h.\n     * @param errorCode Standard ICU error code. Its input value must\n     *                  pass the U_SUCCESS() test, or else the function returns\n     *                  immediately. Check for U_FAILURE() on output or use with\n     *                  function chaining. (See User Guide for details.)\n     * @return the UTS #46 IDNA instance, if successful\n     * @stable ICU 4.6\n     */\n    static IDNA *\n    createUTS46Instance(uint32_t options, UErrorCode &errorCode);\n\n    /**\n     * Converts a single domain name label into its ASCII form for DNS lookup.\n     * If any processing step fails, then info.hasErrors() will be TRUE and\n     * the result might not be an ASCII string.\n     * The label might be modified according to the types of errors.\n     * Labels with severe errors will be left in (or turned into) their Unicode form.\n     *\n     * The UErrorCode indicates an error only in exceptional cases,\n     * such as a U_MEMORY_ALLOCATION_ERROR.\n     *\n     * @param label Input domain name label\n     * @param dest Destination string object\n     * @param info Output container of IDNA processing details.\n     * @param errorCode Standard ICU error code. Its input value must\n     *                  pass the U_SUCCESS() test, or else the function returns\n     *                  immediately. Check for U_FAILURE() on output or use with\n     *                  function chaining. (See User Guide for details.)\n     * @return dest\n     * @stable ICU 4.6\n     */\n    virtual UnicodeString &\n    labelToASCII(const UnicodeString &label, UnicodeString &dest,\n                 IDNAInfo &info, UErrorCode &errorCode) const = 0;\n\n    /**\n     * Converts a single domain name label into its Unicode form for human-readable display.\n     * If any processing step fails, then info.hasErrors() will be TRUE.\n     * The label might be modified according to the types of errors.\n     *\n     * The UErrorCode indicates an error only in exceptional cases,\n     * such as a U_MEMORY_ALLOCATION_ERROR.\n     *\n     * @param label Input domain name label\n     * @param dest Destination string object\n     * @param info Output container of IDNA processing details.\n     * @param errorCode Standard ICU error code. Its input value must\n     *                  pass the U_SUCCESS() test, or else the function returns\n     *                  immediately. Check for U_FAILURE() on output or use with\n     *                  function chaining. (See User Guide for details.)\n     * @return dest\n     * @stable ICU 4.6\n     */\n    virtual UnicodeString &\n    labelToUnicode(const UnicodeString &label, UnicodeString &dest,\n                   IDNAInfo &info, UErrorCode &errorCode) const = 0;\n\n    /**\n     * Converts a whole domain name into its ASCII form for DNS lookup.\n     * If any processing step fails, then info.hasErrors() will be TRUE and\n     * the result might not be an ASCII string.\n     * The domain name might be modified according to the types of errors.\n     * Labels with severe errors will be left in (or turned into) their Unicode form.\n     *\n     * The UErrorCode indicates an error only in exceptional cases,\n     * such as a U_MEMORY_ALLOCATION_ERROR.\n     *\n     * @param name Input domain name\n     * @param dest Destination string object\n     * @param info Output container of IDNA processing details.\n     * @param errorCode Standard ICU error code. Its input value must\n     *                  pass the U_SUCCESS() test, or else the function returns\n     *                  immediately. Check for U_FAILURE() on output or use with\n     *                  function chaining. (See User Guide for details.)\n     * @return dest\n     * @stable ICU 4.6\n     */\n    virtual UnicodeString &\n    nameToASCII(const UnicodeString &name, UnicodeString &dest,\n                IDNAInfo &info, UErrorCode &errorCode) const = 0;\n\n    /**\n     * Converts a whole domain name into its Unicode form for human-readable display.\n     * If any processing step fails, then info.hasErrors() will be TRUE.\n     * The domain name might be modified according to the types of errors.\n     *\n     * The UErrorCode indicates an error only in exceptional cases,\n     * such as a U_MEMORY_ALLOCATION_ERROR.\n     *\n     * @param name Input domain name\n     * @param dest Destination string object\n     * @param info Output container of IDNA processing details.\n     * @param errorCode Standard ICU error code. Its input value must\n     *                  pass the U_SUCCESS() test, or else the function returns\n     *                  immediately. Check for U_FAILURE() on output or use with\n     *                  function chaining. (See User Guide for details.)\n     * @return dest\n     * @stable ICU 4.6\n     */\n    virtual UnicodeString &\n    nameToUnicode(const UnicodeString &name, UnicodeString &dest,\n                  IDNAInfo &info, UErrorCode &errorCode) const = 0;\n\n    // UTF-8 versions of the processing methods ---------------------------- ***\n\n    /**\n     * Converts a single domain name label into its ASCII form for DNS lookup.\n     * UTF-8 version of labelToASCII(), same behavior.\n     *\n     * @param label Input domain name label\n     * @param dest Destination byte sink; Flush()ed if successful\n     * @param info Output container of IDNA processing details.\n     * @param errorCode Standard ICU error code. Its input value must\n     *                  pass the U_SUCCESS() test, or else the function returns\n     *                  immediately. Check for U_FAILURE() on output or use with\n     *                  function chaining. (See User Guide for details.)\n     * @return dest\n     * @stable ICU 4.6\n     */\n    virtual void\n    labelToASCII_UTF8(const StringPiece &label, ByteSink &dest,\n                      IDNAInfo &info, UErrorCode &errorCode) const;\n\n    /**\n     * Converts a single domain name label into its Unicode form for human-readable display.\n     * UTF-8 version of labelToUnicode(), same behavior.\n     *\n     * @param label Input domain name label\n     * @param dest Destination byte sink; Flush()ed if successful\n     * @param info Output container of IDNA processing details.\n     * @param errorCode Standard ICU error code. Its input value must\n     *                  pass the U_SUCCESS() test, or else the function returns\n     *                  immediately. Check for U_FAILURE() on output or use with\n     *                  function chaining. (See User Guide for details.)\n     * @return dest\n     * @stable ICU 4.6\n     */\n    virtual void\n    labelToUnicodeUTF8(const StringPiece &label, ByteSink &dest,\n                       IDNAInfo &info, UErrorCode &errorCode) const;\n\n    /**\n     * Converts a whole domain name into its ASCII form for DNS lookup.\n     * UTF-8 version of nameToASCII(), same behavior.\n     *\n     * @param name Input domain name\n     * @param dest Destination byte sink; Flush()ed if successful\n     * @param info Output container of IDNA processing details.\n     * @param errorCode Standard ICU error code. Its input value must\n     *                  pass the U_SUCCESS() test, or else the function returns\n     *                  immediately. Check for U_FAILURE() on output or use with\n     *                  function chaining. (See User Guide for details.)\n     * @return dest\n     * @stable ICU 4.6\n     */\n    virtual void\n    nameToASCII_UTF8(const StringPiece &name, ByteSink &dest,\n                     IDNAInfo &info, UErrorCode &errorCode) const;\n\n    /**\n     * Converts a whole domain name into its Unicode form for human-readable display.\n     * UTF-8 version of nameToUnicode(), same behavior.\n     *\n     * @param name Input domain name\n     * @param dest Destination byte sink; Flush()ed if successful\n     * @param info Output container of IDNA processing details.\n     * @param errorCode Standard ICU error code. Its input value must\n     *                  pass the U_SUCCESS() test, or else the function returns\n     *                  immediately. Check for U_FAILURE() on output or use with\n     *                  function chaining. (See User Guide for details.)\n     * @return dest\n     * @stable ICU 4.6\n     */\n    virtual void\n    nameToUnicodeUTF8(const StringPiece &name, ByteSink &dest,\n                      IDNAInfo &info, UErrorCode &errorCode) const;\n\nprivate:\n    // No ICU \"poor man's RTTI\" for this class nor its subclasses.\n    virtual UClassID getDynamicClassID() const;\n};\n\nclass UTS46;\n\n/**\n * Output container for IDNA processing errors.\n * The IDNAInfo class is not suitable for subclassing.\n * @stable ICU 4.6\n */\nclass U_COMMON_API IDNAInfo : public UMemory {\npublic:\n    /**\n     * Constructor for stack allocation.\n     * @stable ICU 4.6\n     */\n    IDNAInfo() : errors(0), labelErrors(0), isTransDiff(FALSE), isBiDi(FALSE), isOkBiDi(TRUE) {}\n    /**\n     * Were there IDNA processing errors?\n     * @return TRUE if there were processing errors\n     * @stable ICU 4.6\n     */\n    UBool hasErrors() const { return errors!=0; }\n    /**\n     * Returns a bit set indicating IDNA processing errors.\n     * See UIDNA_ERROR_... constants in uidna.h.\n     * @return bit set of processing errors\n     * @stable ICU 4.6\n     */\n    uint32_t getErrors() const { return errors; }\n    /**\n     * Returns TRUE if transitional and nontransitional processing produce different results.\n     * This is the case when the input label or domain name contains\n     * one or more deviation characters outside a Punycode label (see UTS #46).\n     * <ul>\n     * <li>With nontransitional processing, such characters are\n     * copied to the destination string.\n     * <li>With transitional processing, such characters are\n     * mapped (sharp s/sigma) or removed (joiner/nonjoiner).\n     * </ul>\n     * @return TRUE if transitional and nontransitional processing produce different results\n     * @stable ICU 4.6\n     */\n    UBool isTransitionalDifferent() const { return isTransDiff; }\n\nprivate:\n    friend class UTS46;\n\n    IDNAInfo(const IDNAInfo &other);  // no copying\n    IDNAInfo &operator=(const IDNAInfo &other);  // no copying\n\n    void reset() {\n        errors=labelErrors=0;\n        isTransDiff=FALSE;\n        isBiDi=FALSE;\n        isOkBiDi=TRUE;\n    }\n\n    uint32_t errors, labelErrors;\n    UBool isTransDiff;\n    UBool isBiDi;\n    UBool isOkBiDi;\n};\n\nU_NAMESPACE_END\n\n#endif  // UCONFIG_NO_IDNA\n#endif  // __IDNA_H__\n"
  },
  {
    "path": "deprecated/android/addons/icucompat/unicode/listformatter.h",
    "content": "/*\n*******************************************************************************\n*\n*   Copyright (C) 2012, International Business Machines\n*   Corporation and others.  All Rights Reserved.\n*\n*******************************************************************************\n*   file name:  listformatter.h\n*   encoding:   US-ASCII\n*   tab size:   8 (not used)\n*   indentation:4\n*\n*   created on: 20120426\n*   created by: Umesh P. Nair\n*/\n\n#ifndef __LISTFORMATTER_H__\n#define __LISTFORMATTER_H__\n\n#include \"unicode/unistr.h\"\n#include \"unicode/locid.h\"\n\n\nU_NAMESPACE_BEGIN\n\n/** @internal */\nclass Hashtable;\n\n/** @internal */\nstruct ListFormatData : public UMemory {\n    UnicodeString twoPattern;\n    UnicodeString startPattern;\n    UnicodeString middlePattern;\n    UnicodeString endPattern;\n\n  ListFormatData(const UnicodeString& two, const UnicodeString& start, const UnicodeString& middle, const UnicodeString& end) :\n      twoPattern(two), startPattern(start), middlePattern(middle), endPattern(end) {}\n};\n\n\n/**\n * \\file\n * \\brief C++ API: API for formatting a list.\n */\n\n\n/**\n * An immutable class for formatting a list, using data from CLDR (or supplied\n * separately).\n *\n * Example: Input data [\"Alice\", \"Bob\", \"Charlie\", \"Delta\"] will be formatted\n * as \"Alice, Bob, Charlie and Delta\" in English.\n *\n * The ListFormatter class is not intended for public subclassing.\n */\nclass U_COMMON_API ListFormatter : public UObject{\n\n  public:\n    /**\n     * Creates a ListFormatter appropriate for the default locale.\n     *\n     * @param errorCode ICU error code, set if no data available for default locale.\n     * @return Pointer to a ListFormatter object for the default locale,\n     *     created from internal data derived from CLDR data.\n     * @draft ICU 50\n     */\n    static ListFormatter* createInstance(UErrorCode& errorCode);\n\n    /**\n     * Creates a ListFormatter appropriate for a locale.\n     *\n     * @param locale The locale.\n     * @param errorCode ICU error code, set if no data available for the given locale.\n     * @return A ListFormatter object created from internal data derived from\n     *     CLDR data.\n     * @draft ICU 50\n     */\n    static ListFormatter* createInstance(const Locale& locale, UErrorCode& errorCode);\n\n\n    /**\n     * Destructor.\n     *\n     * @draft ICU 50\n     */\n    virtual ~ListFormatter();\n\n\n    /**\n     * Formats a list of strings.\n     *\n     * @param items An array of strings to be combined and formatted.\n     * @param n_items Length of the array items.\n     * @param appendTo The string to which the result should be appended to.\n     * @param errorCode ICU error code, set if there is an error.\n     * @return Formatted string combining the elements of items, appended to appendTo.\n     * @draft ICU 50\n     */\n    UnicodeString& format(const UnicodeString items[], int32_t n_items,\n        UnicodeString& appendTo, UErrorCode& errorCode) const;\n\n    /**\n     * Gets the fallback locale for a given locale.\n     * TODO: Consider moving this to the Locale class.\n     * @param in The input locale.\n     * @param out The output locale after fallback.\n     * @internal For testing.\n     */\n    static void getFallbackLocale(const Locale& in, Locale& out, UErrorCode& errorCode);\n\n    /**\n     * @internal constructor made public for testing.\n     */\n    ListFormatter(const ListFormatData& listFormatterData);\n\n  private:\n    static void initializeHash(UErrorCode& errorCode);\n    static void addDataToHash(const char* locale, const char* two, const char* start, const char* middle, const char* end, UErrorCode& errorCode);\n    static const ListFormatData* getListFormatData(const Locale& locale, UErrorCode& errorCode);\n\n    ListFormatter();\n    ListFormatter(const ListFormatter&);\n\n    ListFormatter& operator = (const ListFormatter&);\n    void addNewString(const UnicodeString& pattern, UnicodeString& originalString,\n                      const UnicodeString& newString, UErrorCode& errorCode) const;\n    virtual UClassID getDynamicClassID() const;\n\n    const ListFormatData& data;\n};\n\nU_NAMESPACE_END\n\n#endif\n"
  },
  {
    "path": "deprecated/android/addons/icucompat/unicode/localpointer.h",
    "content": "/*\n*******************************************************************************\n*\n*   Copyright (C) 2009-2012, International Business Machines\n*   Corporation and others.  All Rights Reserved.\n*\n*******************************************************************************\n*   file name:  localpointer.h\n*   encoding:   US-ASCII\n*   tab size:   8 (not used)\n*   indentation:4\n*\n*   created on: 2009nov13\n*   created by: Markus W. Scherer\n*/\n\n#ifndef __LOCALPOINTER_H__\n#define __LOCALPOINTER_H__\n\n/**\n * \\file \n * \\brief C++ API: \"Smart pointers\" for use with and in ICU4C C++ code.\n *\n * These classes are inspired by\n * - std::auto_ptr\n * - boost::scoped_ptr & boost::scoped_array\n * - Taligent Safe Pointers (TOnlyPointerTo)\n *\n * but none of those provide for all of the goals for ICU smart pointers:\n * - Smart pointer owns the object and releases it when it goes out of scope.\n * - No transfer of ownership via copy/assignment to reduce misuse. Simpler & more robust.\n * - ICU-compatible: No exceptions.\n * - Need to be able to orphan/release the pointer and its ownership.\n * - Need variants for normal C++ object pointers, C++ arrays, and ICU C service objects.\n *\n * For details see http://site.icu-project.org/design/cpp/scoped_ptr\n */\n\n#include \"unicode/utypes.h\"\n\n#if U_SHOW_CPLUSPLUS_API\n\nU_NAMESPACE_BEGIN\n\n/**\n * \"Smart pointer\" base class; do not use directly: use LocalPointer etc.\n *\n * Base class for smart pointer classes that do not throw exceptions.\n *\n * Do not use this base class directly, since it does not delete its pointer.\n * A subclass must implement methods that delete the pointer:\n * Destructor and adoptInstead().\n *\n * There is no operator T *() provided because the programmer must decide\n * whether to use getAlias() (without transfer of ownership) or orpan()\n * (with transfer of ownership and NULLing of the pointer).\n *\n * @see LocalPointer\n * @see LocalArray\n * @see U_DEFINE_LOCAL_OPEN_POINTER\n * @stable ICU 4.4\n */\ntemplate<typename T>\nclass LocalPointerBase {\npublic:\n    /**\n     * Constructor takes ownership.\n     * @param p simple pointer to an object that is adopted\n     * @stable ICU 4.4\n     */\n    explicit LocalPointerBase(T *p=NULL) : ptr(p) {}\n    /**\n     * Destructor deletes the object it owns.\n     * Subclass must override: Base class does nothing.\n     * @stable ICU 4.4\n     */\n    ~LocalPointerBase() { /* delete ptr; */ }\n    /**\n     * NULL check.\n     * @return TRUE if ==NULL\n     * @stable ICU 4.4\n     */\n    UBool isNull() const { return ptr==NULL; }\n    /**\n     * NULL check.\n     * @return TRUE if !=NULL\n     * @stable ICU 4.4\n     */\n    UBool isValid() const { return ptr!=NULL; }\n    /**\n     * Comparison with a simple pointer, so that existing code\n     * with ==NULL need not be changed.\n     * @param other simple pointer for comparison\n     * @return true if this pointer value equals other\n     * @stable ICU 4.4\n     */\n    bool operator==(const T *other) const { return ptr==other; }\n    /**\n     * Comparison with a simple pointer, so that existing code\n     * with !=NULL need not be changed.\n     * @param other simple pointer for comparison\n     * @return true if this pointer value differs from other\n     * @stable ICU 4.4\n     */\n    bool operator!=(const T *other) const { return ptr!=other; }\n    /**\n     * Access without ownership change.\n     * @return the pointer value\n     * @stable ICU 4.4\n     */\n    T *getAlias() const { return ptr; }\n    /**\n     * Access without ownership change.\n     * @return the pointer value as a reference\n     * @stable ICU 4.4\n     */\n    T &operator*() const { return *ptr; }\n    /**\n     * Access without ownership change.\n     * @return the pointer value\n     * @stable ICU 4.4\n     */\n    T *operator->() const { return ptr; }\n    /**\n     * Gives up ownership; the internal pointer becomes NULL.\n     * @return the pointer value;\n     *         caller becomes responsible for deleting the object\n     * @stable ICU 4.4\n     */\n    T *orphan() {\n        T *p=ptr;\n        ptr=NULL;\n        return p;\n    }\n    /**\n     * Deletes the object it owns,\n     * and adopts (takes ownership of) the one passed in.\n     * Subclass must override: Base class does not delete the object.\n     * @param p simple pointer to an object that is adopted\n     * @stable ICU 4.4\n     */\n    void adoptInstead(T *p) {\n        // delete ptr;\n        ptr=p;\n    }\nprotected:\n    /**\n     * Actual pointer.\n     * @internal\n     */\n    T *ptr;\nprivate:\n    // No comparison operators with other LocalPointerBases.\n    bool operator==(const LocalPointerBase &other);\n    bool operator!=(const LocalPointerBase &other);\n    // No ownership transfer: No copy constructor, no assignment operator.\n    LocalPointerBase(const LocalPointerBase &other);\n    void operator=(const LocalPointerBase &other);\n    // No heap allocation. Use only on the stack.\n    static void * U_EXPORT2 operator new(size_t size);\n    static void * U_EXPORT2 operator new[](size_t size);\n#if U_HAVE_PLACEMENT_NEW\n    static void * U_EXPORT2 operator new(size_t, void *ptr);\n#endif\n};\n\n/**\n * \"Smart pointer\" class, deletes objects via the standard C++ delete operator.\n * For most methods see the LocalPointerBase base class.\n *\n * Usage example:\n * \\code\n * LocalPointer<UnicodeString> s(new UnicodeString((UChar32)0x50005));\n * int32_t length=s->length();  // 2\n * UChar lead=s->charAt(0);  // 0xd900\n * if(some condition) { return; }  // no need to explicitly delete the pointer\n * s.adoptInstead(new UnicodeString((UChar)0xfffc));\n * length=s->length();  // 1\n * // no need to explicitly delete the pointer\n * \\endcode\n *\n * @see LocalPointerBase\n * @stable ICU 4.4\n */\ntemplate<typename T>\nclass LocalPointer : public LocalPointerBase<T> {\npublic:\n    /**\n     * Constructor takes ownership.\n     * @param p simple pointer to an object that is adopted\n     * @stable ICU 4.4\n     */\n    explicit LocalPointer(T *p=NULL) : LocalPointerBase<T>(p) {}\n    /**\n     * Destructor deletes the object it owns.\n     * @stable ICU 4.4\n     */\n    ~LocalPointer() {\n        delete LocalPointerBase<T>::ptr;\n    }\n    /**\n     * Deletes the object it owns,\n     * and adopts (takes ownership of) the one passed in.\n     * @param p simple pointer to an object that is adopted\n     * @stable ICU 4.4\n     */\n    void adoptInstead(T *p) {\n        delete LocalPointerBase<T>::ptr;\n        LocalPointerBase<T>::ptr=p;\n    }\n};\n\n/**\n * \"Smart pointer\" class, deletes objects via the C++ array delete[] operator.\n * For most methods see the LocalPointerBase base class.\n * Adds operator[] for array item access.\n *\n * Usage example:\n * \\code\n * LocalArray<UnicodeString> a(new UnicodeString[2]);\n * a[0].append((UChar)0x61);\n * if(some condition) { return; }  // no need to explicitly delete the array\n * a.adoptInstead(new UnicodeString[4]);\n * a[3].append((UChar)0x62).append((UChar)0x63).reverse();\n * // no need to explicitly delete the array\n * \\endcode\n *\n * @see LocalPointerBase\n * @stable ICU 4.4\n */\ntemplate<typename T>\nclass LocalArray : public LocalPointerBase<T> {\npublic:\n    /**\n     * Constructor takes ownership.\n     * @param p simple pointer to an array of T objects that is adopted\n     * @stable ICU 4.4\n     */\n    explicit LocalArray(T *p=NULL) : LocalPointerBase<T>(p) {}\n    /**\n     * Destructor deletes the array it owns.\n     * @stable ICU 4.4\n     */\n    ~LocalArray() {\n        delete[] LocalPointerBase<T>::ptr;\n    }\n    /**\n     * Deletes the array it owns,\n     * and adopts (takes ownership of) the one passed in.\n     * @param p simple pointer to an array of T objects that is adopted\n     * @stable ICU 4.4\n     */\n    void adoptInstead(T *p) {\n        delete[] LocalPointerBase<T>::ptr;\n        LocalPointerBase<T>::ptr=p;\n    }\n    /**\n     * Array item access (writable).\n     * No index bounds check.\n     * @param i array index\n     * @return reference to the array item\n     * @stable ICU 4.4\n     */\n    T &operator[](ptrdiff_t i) const { return LocalPointerBase<T>::ptr[i]; }\n};\n\n/**\n * \\def U_DEFINE_LOCAL_OPEN_POINTER\n * \"Smart pointer\" definition macro, deletes objects via the closeFunction.\n * Defines a subclass of LocalPointerBase which works just\n * like LocalPointer<Type> except that this subclass will use the closeFunction\n * rather than the C++ delete operator.\n *\n * Requirement: The closeFunction must tolerate a NULL pointer.\n * (We could add a NULL check here but it is normally redundant.)\n *\n * Usage example:\n * \\code\n * LocalUCaseMapPointer csm(ucasemap_open(localeID, options, &errorCode));\n * utf8OutLength=ucasemap_utf8ToLower(csm.getAlias(),\n *     utf8Out, (int32_t)sizeof(utf8Out),\n *     utf8In, utf8InLength, &errorCode);\n * if(U_FAILURE(errorCode)) { return; }  // no need to explicitly delete the UCaseMap\n * \\endcode\n *\n * @see LocalPointerBase\n * @see LocalPointer\n * @stable ICU 4.4\n */\n#define U_DEFINE_LOCAL_OPEN_POINTER(LocalPointerClassName, Type, closeFunction) \\\n    class LocalPointerClassName : public LocalPointerBase<Type> { \\\n    public: \\\n        explicit LocalPointerClassName(Type *p=NULL) : LocalPointerBase<Type>(p) {} \\\n        ~LocalPointerClassName() { closeFunction(ptr); } \\\n        void adoptInstead(Type *p) { \\\n            closeFunction(ptr); \\\n            ptr=p; \\\n        } \\\n    }\n\nU_NAMESPACE_END\n\n#endif  /* U_SHOW_CPLUSPLUS_API */\n#endif  /* __LOCALPOINTER_H__ */\n"
  },
  {
    "path": "deprecated/android/addons/icucompat/unicode/locdspnm.h",
    "content": "/*\n******************************************************************************\n* Copyright (C) 2010-2012, International Business Machines Corporation and\n* others. All Rights Reserved.\n******************************************************************************\n*/\n\n#ifndef LOCDSPNM_H\n#define LOCDSPNM_H\n\n#include \"unicode/utypes.h\"\n\n/**\n * \\file\n * \\brief C++ API: Provides display names of Locale and its components.\n */\n\n#if !UCONFIG_NO_FORMATTING\n\n#include \"unicode/locid.h\"\n#include \"unicode/uscript.h\"\n#include \"unicode/uldnames.h\"\n#include \"unicode/udisplaycontext.h\"\n\nU_NAMESPACE_BEGIN\n\n/**\n * Returns display names of Locales and components of Locales. For\n * more information on language, script, region, variant, key, and\n * values, see Locale.\n * @stable ICU 4.4\n */\nclass U_I18N_API LocaleDisplayNames : public UObject {\npublic:\n    /**\n     * Destructor.\n     * @stable ICU 4.4\n     */\n    virtual ~LocaleDisplayNames();\n\n    /**\n     * Convenience overload of\n     * {@link #createInstance(const Locale& locale, UDialectHandling dialectHandling)}\n     * that specifies STANDARD dialect handling.\n     * @param locale the display locale\n     * @return a LocaleDisplayNames instance\n     * @stable ICU 4.4\n     */\n    static LocaleDisplayNames* U_EXPORT2 createInstance(const Locale& locale);\n\n    /**\n     * Returns an instance of LocaleDisplayNames that returns names\n     * formatted for the provided locale, using the provided\n     * dialectHandling.\n     *\n     * @param locale the display locale\n     * @param dialectHandling how to select names for locales\n     * @return a LocaleDisplayNames instance\n     * @stable ICU 4.4\n     */\n    static LocaleDisplayNames* U_EXPORT2 createInstance(const Locale& locale,\n                            UDialectHandling dialectHandling);\n\n#ifndef U_HIDE_INTERNAL_API\n    /**\n     * Returns an instance of LocaleDisplayNames that returns names formatted\n     * for the provided locale, using the provided UDisplayContext settings.\n     *\n     * @param locale the display locale\n     * @param contexts List of one or more context settings (e.g. for dialect\n     *               handling, capitalization, etc.\n     * @param length Number of items in the contexts list\n     * @return a LocaleDisplayNames instance\n     * @internal ICU 50 technology preview\n     */\n    static LocaleDisplayNames* U_EXPORT2 createInstance(const Locale& locale,\n                            UDisplayContext *contexts, int32_t length);\n#endif  /* U_HIDE_INTERNAL_API */\n\n    // getters for state\n    /**\n     * Returns the locale used to determine the display names. This is\n     * not necessarily the same locale passed to {@link #createInstance}.\n     * @return the display locale\n     * @stable ICU 4.4\n     */\n    virtual const Locale& getLocale() const = 0;\n\n    /**\n     * Returns the dialect handling used in the display names.\n     * @return the dialect handling enum\n     * @stable ICU 4.4\n     */\n    virtual UDialectHandling getDialectHandling() const = 0;\n\n    /**\n     * Returns the UDisplayContext value for the specified UDisplayContextType.\n     * @param type the UDisplayContextType whose value to return\n     * @return the UDisplayContext for the specified type.\n     * @internal ICU 50 technology preview\n     */\n    virtual UDisplayContext getContext(UDisplayContextType type) const = 0;\n\n    // names for entire locales\n    /**\n     * Returns the display name of the provided locale.\n     * @param locale the locale whose display name to return\n     * @param result receives the locale's display name\n     * @return the display name of the provided locale\n     * @stable ICU 4.4\n     */\n    virtual UnicodeString& localeDisplayName(const Locale& locale,\n                         UnicodeString& result) const = 0;\n\n    /**\n     * Returns the display name of the provided locale id.\n     * @param localeId the id of the locale whose display name to return\n     * @param result receives the locale's display name\n     * @return the display name of the provided locale\n     * @stable ICU 4.4\n     */\n    virtual UnicodeString& localeDisplayName(const char* localeId,\n                         UnicodeString& result) const = 0;\n\n    // names for components of a locale id\n    /**\n     * Returns the display name of the provided language code.\n     * @param lang the language code\n     * @param result receives the language code's display name\n     * @return the display name of the provided language code\n     * @stable ICU 4.4\n     */\n    virtual UnicodeString& languageDisplayName(const char* lang,\n                           UnicodeString& result) const = 0;\n\n    /**\n     * Returns the display name of the provided script code.\n     * @param script the script code\n     * @param result receives the script code's display name\n     * @return the display name of the provided script code\n     * @stable ICU 4.4\n     */\n    virtual UnicodeString& scriptDisplayName(const char* script,\n                         UnicodeString& result) const = 0;\n\n    /**\n     * Returns the display name of the provided script code.\n     * @param scriptCode the script code number\n     * @param result receives the script code's display name\n     * @return the display name of the provided script code\n     * @stable ICU 4.4\n     */\n    virtual UnicodeString& scriptDisplayName(UScriptCode scriptCode,\n                         UnicodeString& result) const = 0;\n\n    /**\n     * Returns the display name of the provided region code.\n     * @param region the region code\n     * @param result receives the region code's display name\n     * @return the display name of the provided region code\n     * @stable ICU 4.4\n     */\n    virtual UnicodeString& regionDisplayName(const char* region,\n                         UnicodeString& result) const = 0;\n\n    /**\n     * Returns the display name of the provided variant.\n     * @param variant the variant string\n     * @param result receives the variant's display name\n     * @return the display name of the provided variant\n     * @stable ICU 4.4\n     */\n    virtual UnicodeString& variantDisplayName(const char* variant,\n                          UnicodeString& result) const = 0;\n\n    /**\n     * Returns the display name of the provided locale key.\n     * @param key the locale key name\n     * @param result receives the locale key's display name\n     * @return the display name of the provided locale key\n     * @stable ICU 4.4\n     */\n    virtual UnicodeString& keyDisplayName(const char* key,\n                      UnicodeString& result) const = 0;\n\n    /**\n     * Returns the display name of the provided value (used with the provided key).\n     * @param key the locale key name\n     * @param value the locale key's value\n     * @param result receives the value's display name\n     * @return the display name of the provided value\n     * @stable ICU 4.4\n     */\n    virtual UnicodeString& keyValueDisplayName(const char* key, const char* value,\n                           UnicodeString& result) const = 0;\n\nprivate:\n    // No ICU \"poor man's RTTI\" for this class nor its subclasses.\n    virtual UClassID getDynamicClassID() const;\n};\n\ninline LocaleDisplayNames* LocaleDisplayNames::createInstance(const Locale& locale) {\n  return LocaleDisplayNames::createInstance(locale, ULDN_STANDARD_NAMES);\n}\n\nU_NAMESPACE_END\n\n#endif\n\n#endif\n"
  },
  {
    "path": "deprecated/android/addons/icucompat/unicode/locid.h",
    "content": "/*\n******************************************************************************\n*\n*   Copyright (C) 1996-2012, International Business Machines\n*   Corporation and others.  All Rights Reserved.\n*\n******************************************************************************\n*\n* File locid.h\n*\n* Created by: Helena Shih\n*\n* Modification History:\n*\n*   Date        Name        Description\n*   02/11/97    aliu        Changed gLocPath to fgLocPath and added methods to\n*                           get and set it.\n*   04/02/97    aliu        Made operator!= inline; fixed return value of getName().\n*   04/15/97    aliu        Cleanup for AIX/Win32.\n*   04/24/97    aliu        Numerous changes per code review.\n*   08/18/98    stephen     Added tokenizeString(),changed getDisplayName()\n*   09/08/98    stephen     Moved definition of kEmptyString for Mac Port\n*   11/09/99    weiv        Added const char * getName() const;\n*   04/12/00    srl         removing unicodestring api's and cached hash code\n*   08/10/01    grhoten     Change the static Locales to accessor functions\n******************************************************************************\n*/\n\n#ifndef LOCID_H\n#define LOCID_H\n\n#include \"unicode/utypes.h\"\n#include \"unicode/uobject.h\"\n#include \"unicode/unistr.h\"\n#include \"unicode/putil.h\"\n#include \"unicode/uloc.h\"\n#include \"unicode/strenum.h\"\n\n/**\n * \\file\n * \\brief C++ API: Locale ID object.\n */\n\nU_NAMESPACE_BEGIN\n\n/**\n * A <code>Locale</code> object represents a specific geographical, political,\n * or cultural region. An operation that requires a <code>Locale</code> to perform\n * its task is called <em>locale-sensitive</em> and uses the <code>Locale</code>\n * to tailor information for the user. For example, displaying a number\n * is a locale-sensitive operation--the number should be formatted\n * according to the customs/conventions of the user's native country,\n * region, or culture.\n *\n * The Locale class is not suitable for subclassing.\n *\n * <P>\n * You can create a <code>Locale</code> object using the constructor in\n * this class:\n * \\htmlonly<blockquote>\\endhtmlonly\n * <pre>\n *       Locale( const   char*  language,\n *               const   char*  country,\n *               const   char*  variant);\n * </pre>\n * \\htmlonly</blockquote>\\endhtmlonly\n * The first argument to the constructors is a valid <STRONG>ISO\n * Language Code.</STRONG> These codes are the lower-case two-letter\n * codes as defined by ISO-639.\n * You can find a full list of these codes at:\n * <BR><a href =\"http://www.loc.gov/standards/iso639-2/\">\n * http://www.loc.gov/standards/iso639-2/</a>\n *\n * <P>\n * The second argument to the constructors is a valid <STRONG>ISO Country\n * Code.</STRONG> These codes are the upper-case two-letter codes\n * as defined by ISO-3166.\n * You can find a full list of these codes at a number of sites, such as:\n * <BR><a href=\"http://www.iso.org/iso/en/prods-services/iso3166ma/index.html\">\n * http://www.iso.org/iso/en/prods-services/iso3166ma/index.html</a>\n *\n * <P>\n * The third constructor requires a third argument--the <STRONG>Variant.</STRONG>\n * The Variant codes are vendor and browser-specific.\n * For example, use REVISED for a langauge's revised script orthography, and POSIX for POSIX.\n * Where there are two variants, separate them with an underscore, and\n * put the most important one first. For\n * example, a Traditional Spanish collation might be referenced, with\n * \"ES\", \"ES\", \"Traditional_POSIX\".\n *\n * <P>\n * Because a <code>Locale</code> object is just an identifier for a region,\n * no validity check is performed when you construct a <code>Locale</code>.\n * If you want to see whether particular resources are available for the\n * <code>Locale</code> you construct, you must query those resources. For\n * example, ask the <code>NumberFormat</code> for the locales it supports\n * using its <code>getAvailableLocales</code> method.\n * <BR><STRONG>Note:</STRONG> When you ask for a resource for a particular\n * locale, you get back the best available match, not necessarily\n * precisely what you asked for. For more information, look at\n * <code>ResourceBundle</code>.\n *\n * <P>\n * The <code>Locale</code> class provides a number of convenient constants\n * that you can use to create <code>Locale</code> objects for commonly used\n * locales. For example, the following refers to a <code>Locale</code> object\n * for the United States:\n * \\htmlonly<blockquote>\\endhtmlonly\n * <pre>\n *       Locale::getUS()\n * </pre>\n * \\htmlonly</blockquote>\\endhtmlonly\n *\n * <P>\n * Once you've created a <code>Locale</code> you can query it for information about\n * itself. Use <code>getCountry</code> to get the ISO Country Code and\n * <code>getLanguage</code> to get the ISO Language Code. You can\n * use <code>getDisplayCountry</code> to get the\n * name of the country suitable for displaying to the user. Similarly,\n * you can use <code>getDisplayLanguage</code> to get the name of\n * the language suitable for displaying to the user. Interestingly,\n * the <code>getDisplayXXX</code> methods are themselves locale-sensitive\n * and have two versions: one that uses the default locale and one\n * that takes a locale as an argument and displays the name or country in\n * a language appropriate to that locale.\n *\n * <P>\n * ICU provides a number of classes that perform locale-sensitive\n * operations. For example, the <code>NumberFormat</code> class formats\n * numbers, currency, or percentages in a locale-sensitive manner. Classes\n * such as <code>NumberFormat</code> have a number of convenience methods\n * for creating a default object of that type. For example, the\n * <code>NumberFormat</code> class provides these three convenience methods\n * for creating a default <code>NumberFormat</code> object:\n * \\htmlonly<blockquote>\\endhtmlonly\n * <pre>\n *     UErrorCode success = U_ZERO_ERROR;\n *     Locale myLocale;\n *     NumberFormat *nf;\n *\n *     nf = NumberFormat::createInstance( success );          delete nf;\n *     nf = NumberFormat::createCurrencyInstance( success );  delete nf;\n *     nf = NumberFormat::createPercentInstance( success );   delete nf;\n * </pre>\n * \\htmlonly</blockquote>\\endhtmlonly\n * Each of these methods has two variants; one with an explicit locale\n * and one without; the latter using the default locale.\n * \\htmlonly<blockquote>\\endhtmlonly\n * <pre>\n *     nf = NumberFormat::createInstance( myLocale, success );          delete nf;\n *     nf = NumberFormat::createCurrencyInstance( myLocale, success );  delete nf;\n *     nf = NumberFormat::createPercentInstance( myLocale, success );   delete nf;\n * </pre>\n * \\htmlonly</blockquote>\\endhtmlonly\n * A <code>Locale</code> is the mechanism for identifying the kind of object\n * (<code>NumberFormat</code>) that you would like to get. The locale is\n * <STRONG>just</STRONG> a mechanism for identifying objects,\n * <STRONG>not</STRONG> a container for the objects themselves.\n *\n * <P>\n * Each class that performs locale-sensitive operations allows you\n * to get all the available objects of that type. You can sift\n * through these objects by language, country, or variant,\n * and use the display names to present a menu to the user.\n * For example, you can create a menu of all the collation objects\n * suitable for a given language. Such classes implement these\n * three class methods:\n * \\htmlonly<blockquote>\\endhtmlonly\n * <pre>\n *       static Locale* getAvailableLocales(int32_t& numLocales)\n *       static UnicodeString& getDisplayName(const Locale&  objectLocale,\n *                                            const Locale&  displayLocale,\n *                                            UnicodeString& displayName)\n *       static UnicodeString& getDisplayName(const Locale&  objectLocale,\n *                                            UnicodeString& displayName)\n * </pre>\n * \\htmlonly</blockquote>\\endhtmlonly\n *\n * @stable ICU 2.0\n * @see ResourceBundle\n */\nclass U_COMMON_API Locale : public UObject {\npublic:\n    /** Useful constant for the Root locale. @stable ICU 4.4 */\n    static const Locale &U_EXPORT2 getRoot(void);\n    /** Useful constant for this language. @stable ICU 2.0 */\n    static const Locale &U_EXPORT2 getEnglish(void);\n    /** Useful constant for this language. @stable ICU 2.0 */\n    static const Locale &U_EXPORT2 getFrench(void);\n    /** Useful constant for this language. @stable ICU 2.0 */\n    static const Locale &U_EXPORT2 getGerman(void);\n    /** Useful constant for this language. @stable ICU 2.0 */\n    static const Locale &U_EXPORT2 getItalian(void);\n    /** Useful constant for this language. @stable ICU 2.0 */\n    static const Locale &U_EXPORT2 getJapanese(void);\n    /** Useful constant for this language. @stable ICU 2.0 */\n    static const Locale &U_EXPORT2 getKorean(void);\n    /** Useful constant for this language. @stable ICU 2.0 */\n    static const Locale &U_EXPORT2 getChinese(void);\n    /** Useful constant for this language. @stable ICU 2.0 */\n    static const Locale &U_EXPORT2 getSimplifiedChinese(void);\n    /** Useful constant for this language. @stable ICU 2.0 */\n    static const Locale &U_EXPORT2 getTraditionalChinese(void);\n\n    /** Useful constant for this country/region. @stable ICU 2.0 */\n    static const Locale &U_EXPORT2 getFrance(void);\n    /** Useful constant for this country/region. @stable ICU 2.0 */\n    static const Locale &U_EXPORT2 getGermany(void);\n    /** Useful constant for this country/region. @stable ICU 2.0 */\n    static const Locale &U_EXPORT2 getItaly(void);\n    /** Useful constant for this country/region. @stable ICU 2.0 */\n    static const Locale &U_EXPORT2 getJapan(void);\n    /** Useful constant for this country/region. @stable ICU 2.0 */\n    static const Locale &U_EXPORT2 getKorea(void);\n    /** Useful constant for this country/region. @stable ICU 2.0 */\n    static const Locale &U_EXPORT2 getChina(void);\n    /** Useful constant for this country/region. @stable ICU 2.0 */\n    static const Locale &U_EXPORT2 getPRC(void);\n    /** Useful constant for this country/region. @stable ICU 2.0 */\n    static const Locale &U_EXPORT2 getTaiwan(void);\n    /** Useful constant for this country/region. @stable ICU 2.0 */\n    static const Locale &U_EXPORT2 getUK(void);\n    /** Useful constant for this country/region. @stable ICU 2.0 */\n    static const Locale &U_EXPORT2 getUS(void);\n    /** Useful constant for this country/region. @stable ICU 2.0 */\n    static const Locale &U_EXPORT2 getCanada(void);\n    /** Useful constant for this country/region. @stable ICU 2.0 */\n    static const Locale &U_EXPORT2 getCanadaFrench(void);\n\n\n    /**\n     * Construct a default locale object, a Locale for the default locale ID.\n     *\n     * @see getDefault\n     * @see uloc_getDefault\n     * @stable ICU 2.0\n     */\n    Locale();\n\n    /**\n     * Construct a locale from language, country, variant.\n     * If an error occurs, then the constructed object will be \"bogus\"\n     * (isBogus() will return TRUE).\n     *\n     * @param language Lowercase two-letter or three-letter ISO-639 code.\n     *  This parameter can instead be an ICU style C locale (e.g. \"en_US\"),\n     *  but the other parameters must not be used.\n     *  This parameter can be NULL; if so,\n     *  the locale is initialized to match the current default locale.\n     *  (This is the same as using the default constructor.)\n     *  Please note: The Java Locale class does NOT accept the form\n     *  'new Locale(\"en_US\")' but only 'new Locale(\"en\",\"US\")'\n     *\n     * @param country  Uppercase two-letter ISO-3166 code. (optional)\n     * @param variant  Uppercase vendor and browser specific code. See class\n     *                 description. (optional)\n     * @param keywordsAndValues A string consisting of keyword/values pairs, such as\n     *                 \"collation=phonebook;currency=euro\"\n     *\n     * @see getDefault\n     * @see uloc_getDefault\n     * @stable ICU 2.0\n     */\n    Locale( const   char * language,\n            const   char * country  = 0,\n            const   char * variant  = 0,\n            const   char * keywordsAndValues = 0);\n\n    /**\n     * Initializes a Locale object from another Locale object.\n     *\n     * @param other The Locale object being copied in.\n     * @stable ICU 2.0\n     */\n    Locale(const    Locale& other);\n\n\n    /**\n     * Destructor\n     * @stable ICU 2.0\n     */\n    virtual ~Locale() ;\n\n    /**\n     * Replaces the entire contents of *this with the specified value.\n     *\n     * @param other The Locale object being copied in.\n     * @return      *this\n     * @stable ICU 2.0\n     */\n    Locale& operator=(const Locale& other);\n\n    /**\n     * Checks if two locale keys are the same.\n     *\n     * @param other The locale key object to be compared with this.\n     * @return      True if the two locale keys are the same, false otherwise.\n     * @stable ICU 2.0\n     */\n    UBool   operator==(const    Locale&     other) const;\n\n    /**\n     * Checks if two locale keys are not the same.\n     *\n     * @param other The locale key object to be compared with this.\n     * @return      True if the two locale keys are not the same, false\n     *              otherwise.\n     * @stable ICU 2.0\n     */\n    UBool   operator!=(const    Locale&     other) const;\n\n    /**\n     * Clone this object.\n     * Clones can be used concurrently in multiple threads.\n     * If an error occurs, then NULL is returned.\n     * The caller must delete the clone.\n     *\n     * @return a clone of this object\n     *\n     * @see getDynamicClassID\n     * @stable ICU 2.8\n     */\n    Locale *clone() const;\n\n#ifndef U_HIDE_SYSTEM_API\n    /**\n     * Common methods of getting the current default Locale. Used for the\n     * presentation: menus, dialogs, etc. Generally set once when your applet or\n     * application is initialized, then never reset. (If you do reset the\n     * default locale, you probably want to reload your GUI, so that the change\n     * is reflected in your interface.)\n     *\n     * More advanced programs will allow users to use different locales for\n     * different fields, e.g. in a spreadsheet.\n     *\n     * Note that the initial setting will match the host system.\n     * @return a reference to the Locale object for the default locale ID\n     * @system\n     * @stable ICU 2.0\n     */\n    static const Locale& U_EXPORT2 getDefault(void);\n\n    /**\n     * Sets the default. Normally set once at the beginning of a process,\n     * then never reset.\n     * setDefault() only changes ICU's default locale ID, <strong>not</strong>\n     * the default locale ID of the runtime environment.\n     *\n     * @param newLocale Locale to set to.  If NULL, set to the value obtained\n     *                  from the runtime environement.\n     * @param success The error code.\n     * @system\n     * @stable ICU 2.0\n     */\n    static void U_EXPORT2 setDefault(const Locale& newLocale,\n                                     UErrorCode&   success);\n#endif  /* U_HIDE_SYSTEM_API */\n\n    /**\n     * Creates a locale which has had minimal canonicalization\n     * as per uloc_getName().\n     * @param name The name to create from.  If name is null,\n     *  the default Locale is used.\n     * @return new locale object\n     * @stable ICU 2.0\n     * @see uloc_getName\n     */\n    static Locale U_EXPORT2 createFromName(const char *name);\n\n    /**\n     * Creates a locale from the given string after canonicalizing\n     * the string by calling uloc_canonicalize().\n     * @param name the locale ID to create from.  Must not be NULL.\n     * @return a new locale object corresponding to the given name\n     * @stable ICU 3.0\n     * @see uloc_canonicalize\n     */\n    static Locale U_EXPORT2 createCanonical(const char* name);\n\n    /**\n     * Returns the locale's ISO-639 language code.\n     * @return      An alias to the code\n     * @stable ICU 2.0\n     */\n    inline const char *  getLanguage( ) const;\n\n    /**\n     * Returns the locale's ISO-15924 abbreviation script code.\n     * @return      An alias to the code\n     * @see uscript_getShortName\n     * @see uscript_getCode\n     * @stable ICU 2.8\n     */\n    inline const char *  getScript( ) const;\n\n    /**\n     * Returns the locale's ISO-3166 country code.\n     * @return      An alias to the code\n     * @stable ICU 2.0\n     */\n    inline const char *  getCountry( ) const;\n\n    /**\n     * Returns the locale's variant code.\n     * @return      An alias to the code\n     * @stable ICU 2.0\n     */\n    inline const char *  getVariant( ) const;\n\n    /**\n     * Returns the programmatic name of the entire locale, with the language,\n     * country and variant separated by underbars. If a field is missing, up\n     * to two leading underbars will occur. Example: \"en\", \"de_DE\", \"en_US_WIN\",\n     * \"de__POSIX\", \"fr__MAC\", \"__MAC\", \"_MT\", \"_FR_EURO\"\n     * @return      A pointer to \"name\".\n     * @stable ICU 2.0\n     */\n    inline const char * getName() const;\n\n    /**\n     * Returns the programmatic name of the entire locale as getName would return,\n     * but without keywords.\n     * @return      A pointer to \"name\".\n     * @see getName\n     * @stable ICU 2.8\n     */\n    const char * getBaseName() const;\n\n\n    /**\n     * Gets the list of keywords for the specified locale.\n     *\n     * @param status the status code\n     * @return pointer to StringEnumeration class, or NULL if there are no keywords. \n     * Client must dispose of it by calling delete.\n     * @stable ICU 2.8\n     */\n    StringEnumeration * createKeywords(UErrorCode &status) const;\n\n    /**\n     * Gets the value for a keyword.\n     *\n     * @param keywordName name of the keyword for which we want the value. Case insensitive.\n     * @param buffer The buffer to receive the keyword value.\n     * @param bufferCapacity The capacity of receiving buffer\n     * @param status Returns any error information while performing this operation.\n     * @return the length of the keyword value\n     *\n     * @stable ICU 2.8\n     */\n    int32_t getKeywordValue(const char* keywordName, char *buffer, int32_t bufferCapacity, UErrorCode &status) const;\n\n#ifndef U_HIDE_DRAFT_API\n    /**\n     * Sets the value for a keyword.\n     *\n     * @param keywordName name of the keyword to be set. Case insensitive.\n     * @param keywordValue value of the keyword to be set. If 0-length or\n     *  NULL, will result in the keyword being removed. No error is given if\n     *  that keyword does not exist.\n     * @param status Returns any error information while performing this operation.\n     *\n     * @draft ICU 49\n     */\n    void setKeywordValue(const char* keywordName, const char* keywordValue, UErrorCode &status);\n#endif  /* U_HIDE_DRAFT_API */\n\n    /**\n     * returns the locale's three-letter language code, as specified\n     * in ISO draft standard ISO-639-2.\n     * @return      An alias to the code, or an empty string\n     * @stable ICU 2.0\n     */\n    const char * getISO3Language() const;\n\n    /**\n     * Fills in \"name\" with the locale's three-letter ISO-3166 country code.\n     * @return      An alias to the code, or an empty string\n     * @stable ICU 2.0\n     */\n    const char * getISO3Country() const;\n\n    /**\n     * Returns the Windows LCID value corresponding to this locale.\n     * This value is stored in the resource data for the locale as a one-to-four-digit\n     * hexadecimal number.  If the resource is missing, in the wrong format, or\n     * there is no Windows LCID value that corresponds to this locale, returns 0.\n     * @stable ICU 2.0\n     */\n    uint32_t        getLCID(void) const;\n\n    /**\n     * Fills in \"dispLang\" with the name of this locale's language in a format suitable for\n     * user display in the default locale.  For example, if the locale's language code is\n     * \"fr\" and the default locale's language code is \"en\", this function would set\n     * dispLang to \"French\".\n     * @param dispLang  Receives the language's display name.\n     * @return          A reference to \"dispLang\".\n     * @stable ICU 2.0\n     */\n    UnicodeString&  getDisplayLanguage(UnicodeString&   dispLang) const;\n\n    /**\n     * Fills in \"dispLang\" with the name of this locale's language in a format suitable for\n     * user display in the locale specified by \"displayLocale\".  For example, if the locale's\n     * language code is \"en\" and displayLocale's language code is \"fr\", this function would set\n     * dispLang to \"Anglais\".\n     * @param displayLocale  Specifies the locale to be used to display the name.  In other words,\n     *                  if the locale's language code is \"en\", passing Locale::getFrench() for\n     *                  displayLocale would result in \"Anglais\", while passing Locale::getGerman()\n     *                  for displayLocale would result in \"Englisch\".\n     * @param dispLang  Receives the language's display name.\n     * @return          A reference to \"dispLang\".\n     * @stable ICU 2.0\n     */\n    UnicodeString&  getDisplayLanguage( const   Locale&         displayLocale,\n                                                UnicodeString&  dispLang) const;\n\n    /**\n     * Fills in \"dispScript\" with the name of this locale's script in a format suitable\n     * for user display in the default locale.  For example, if the locale's script code\n     * is \"LATN\" and the default locale's language code is \"en\", this function would set\n     * dispScript to \"Latin\".\n     * @param dispScript    Receives the scripts's display name.\n     * @return              A reference to \"dispScript\".\n     * @stable ICU 2.8\n     */\n    UnicodeString&  getDisplayScript(          UnicodeString& dispScript) const;\n\n    /**\n     * Fills in \"dispScript\" with the name of this locale's country in a format suitable\n     * for user display in the locale specified by \"displayLocale\".  For example, if the locale's\n     * script code is \"LATN\" and displayLocale's language code is \"en\", this function would set\n     * dispScript to \"Latin\".\n     * @param displayLocale      Specifies the locale to be used to display the name.  In other\n     *                      words, if the locale's script code is \"LATN\", passing\n     *                      Locale::getFrench() for displayLocale would result in \"\", while\n     *                      passing Locale::getGerman() for displayLocale would result in\n     *                      \"\".\n     * @param dispScript    Receives the scripts's display name.\n     * @return              A reference to \"dispScript\".\n     * @stable ICU 2.8\n     */\n    UnicodeString&  getDisplayScript(  const   Locale&         displayLocale,\n                                               UnicodeString&  dispScript) const;\n\n    /**\n     * Fills in \"dispCountry\" with the name of this locale's country in a format suitable\n     * for user display in the default locale.  For example, if the locale's country code\n     * is \"FR\" and the default locale's language code is \"en\", this function would set\n     * dispCountry to \"France\".\n     * @param dispCountry   Receives the country's display name.\n     * @return              A reference to \"dispCountry\".\n     * @stable ICU 2.0\n     */\n    UnicodeString&  getDisplayCountry(          UnicodeString& dispCountry) const;\n\n    /**\n     * Fills in \"dispCountry\" with the name of this locale's country in a format suitable\n     * for user display in the locale specified by \"displayLocale\".  For example, if the locale's\n     * country code is \"US\" and displayLocale's language code is \"fr\", this function would set\n     * dispCountry to \"&Eacute;tats-Unis\".\n     * @param displayLocale      Specifies the locale to be used to display the name.  In other\n     *                      words, if the locale's country code is \"US\", passing\n     *                      Locale::getFrench() for displayLocale would result in \"&Eacute;tats-Unis\", while\n     *                      passing Locale::getGerman() for displayLocale would result in\n     *                      \"Vereinigte Staaten\".\n     * @param dispCountry   Receives the country's display name.\n     * @return              A reference to \"dispCountry\".\n     * @stable ICU 2.0\n     */\n    UnicodeString&  getDisplayCountry(  const   Locale&         displayLocale,\n                                                UnicodeString&  dispCountry) const;\n\n    /**\n     * Fills in \"dispVar\" with the name of this locale's variant code in a format suitable\n     * for user display in the default locale.\n     * @param dispVar   Receives the variant's name.\n     * @return          A reference to \"dispVar\".\n     * @stable ICU 2.0\n     */\n    UnicodeString&  getDisplayVariant(      UnicodeString& dispVar) const;\n\n    /**\n     * Fills in \"dispVar\" with the name of this locale's variant code in a format\n     * suitable for user display in the locale specified by \"displayLocale\".\n     * @param displayLocale  Specifies the locale to be used to display the name.\n     * @param dispVar   Receives the variant's display name.\n     * @return          A reference to \"dispVar\".\n     * @stable ICU 2.0\n     */\n    UnicodeString&  getDisplayVariant(  const   Locale&         displayLocale,\n                                                UnicodeString&  dispVar) const;\n\n    /**\n     * Fills in \"name\" with the name of this locale in a format suitable for user display\n     * in the default locale.  This function uses getDisplayLanguage(), getDisplayCountry(),\n     * and getDisplayVariant() to do its work, and outputs the display name in the format\n     * \"language (country[,variant])\".  For example, if the default locale is en_US, then\n     * fr_FR's display name would be \"French (France)\", and es_MX_Traditional's display name\n     * would be \"Spanish (Mexico,Traditional)\".\n     * @param name  Receives the locale's display name.\n     * @return      A reference to \"name\".\n     * @stable ICU 2.0\n     */\n    UnicodeString&  getDisplayName(         UnicodeString&  name) const;\n\n    /**\n     * Fills in \"name\" with the name of this locale in a format suitable for user display\n     * in the locale specfied by \"displayLocale\".  This function uses getDisplayLanguage(),\n     * getDisplayCountry(), and getDisplayVariant() to do its work, and outputs the display\n     * name in the format \"language (country[,variant])\".  For example, if displayLocale is\n     * fr_FR, then en_US's display name would be \"Anglais (&Eacute;tats-Unis)\", and no_NO_NY's\n     * display name would be \"norv&eacute;gien (Norv&egrave;ge,NY)\".\n     * @param displayLocale  Specifies the locale to be used to display the name.\n     * @param name      Receives the locale's display name.\n     * @return          A reference to \"name\".\n     * @stable ICU 2.0\n     */\n    UnicodeString&  getDisplayName( const   Locale&         displayLocale,\n                                            UnicodeString&  name) const;\n\n    /**\n     * Generates a hash code for the locale.\n     * @stable ICU 2.0\n     */\n    int32_t         hashCode(void) const;\n\n    /**\n     * Sets the locale to bogus\n     * A bogus locale represents a non-existing locale associated\n     * with services that can be instantiated from non-locale data\n     * in addition to locale (for example, collation can be\n     * instantiated from a locale and from a rule set).\n     * @stable ICU 2.1\n     */\n    void setToBogus();\n\n    /**\n     * Gets the bogus state. Locale object can be bogus if it doesn't exist\n     * @return FALSE if it is a real locale, TRUE if it is a bogus locale\n     * @stable ICU 2.1\n     */\n    UBool isBogus(void) const;\n\n    /**\n     * Returns a list of all installed locales.\n     * @param count Receives the number of locales in the list.\n     * @return      A pointer to an array of Locale objects.  This array is the list\n     *              of all locales with installed resource files.  The called does NOT\n     *              get ownership of this list, and must NOT delete it.\n     * @stable ICU 2.0\n     */\n    static const Locale* U_EXPORT2 getAvailableLocales(int32_t& count);\n\n    /**\n     * Gets a list of all available 2-letter country codes defined in ISO 3166.  This is a\n     * pointer to an array of pointers to arrays of char.  All of these pointers are\n     * owned by ICU-- do not delete them, and do not write through them.  The array is\n     * terminated with a null pointer.\n     * @return a list of all available country codes\n     * @stable ICU 2.0\n     */\n    static const char* const* U_EXPORT2 getISOCountries();\n\n    /**\n     * Gets a list of all available language codes defined in ISO 639.  This is a pointer\n     * to an array of pointers to arrays of char.  All of these pointers are owned\n     * by ICU-- do not delete them, and do not write through them.  The array is\n     * terminated with a null pointer.\n     * @return a list of all available language codes\n     * @stable ICU 2.0\n     */\n    static const char* const* U_EXPORT2 getISOLanguages();\n\n    /**\n     * ICU \"poor man's RTTI\", returns a UClassID for this class.\n     *\n     * @stable ICU 2.2\n     */\n    static UClassID U_EXPORT2 getStaticClassID();\n\n    /**\n     * ICU \"poor man's RTTI\", returns a UClassID for the actual class.\n     *\n     * @stable ICU 2.2\n     */\n    virtual UClassID getDynamicClassID() const;\n\nprotected: /* only protected for testing purposes. DO NOT USE. */\n#ifndef U_HIDE_INTERNAL_API\n    /**\n     * Set this from a single POSIX style locale string.\n     * @internal\n     */\n    void setFromPOSIXID(const char *posixID);\n#endif  /* U_HIDE_INTERNAL_API */\n\nprivate:\n    /**\n     * Initialize the locale object with a new name.\n     * Was deprecated - used in implementation - moved internal\n     *\n     * @param cLocaleID The new locale name.\n     * @param canonicalize whether to call uloc_canonicalize on cLocaleID\n     */\n    Locale& init(const char* cLocaleID, UBool canonicalize);\n\n    /*\n     * Internal constructor to allow construction of a locale object with\n     *   NO side effects.   (Default constructor tries to get\n     *   the default locale.)\n     */\n    enum ELocaleType {\n        eBOGUS\n    };\n    Locale(ELocaleType);\n\n    /**\n     * Initialize the locale cache for commonly used locales\n     */\n    static Locale *getLocaleCache(void);\n\n    char language[ULOC_LANG_CAPACITY];\n    char script[ULOC_SCRIPT_CAPACITY];\n    char country[ULOC_COUNTRY_CAPACITY];\n    int32_t variantBegin;\n    char* fullName;\n    char fullNameBuffer[ULOC_FULLNAME_CAPACITY];\n    // name without keywords\n    char* baseName;\n    char baseNameBuffer[ULOC_FULLNAME_CAPACITY];\n\n    UBool fIsBogus;\n\n    static const Locale &getLocale(int locid);\n\n    /**\n     * A friend to allow the default locale to be set by either the C or C++ API.\n     * @internal\n     */\n    friend Locale *locale_set_default_internal(const char *, UErrorCode& status);\n};\n\ninline UBool\nLocale::operator!=(const    Locale&     other) const\n{\n    return !operator==(other);\n}\n\ninline const char *\nLocale::getCountry() const\n{\n    return country;\n}\n\ninline const char *\nLocale::getLanguage() const\n{\n    return language;\n}\n\ninline const char *\nLocale::getScript() const\n{\n    return script;\n}\n\ninline const char *\nLocale::getVariant() const\n{\n    getBaseName(); // lazy init\n    return &baseName[variantBegin];\n}\n\ninline const char *\nLocale::getName() const\n{\n    return fullName;\n}\n\ninline UBool\nLocale::isBogus(void) const {\n    return fIsBogus;\n}\n\nU_NAMESPACE_END\n\n#endif\n"
  },
  {
    "path": "deprecated/android/addons/icucompat/unicode/measfmt.h",
    "content": "/*\n**********************************************************************\n* Copyright (c) 2004-2011, International Business Machines\n* Corporation and others.  All Rights Reserved.\n**********************************************************************\n* Author: Alan Liu\n* Created: April 20, 2004\n* Since: ICU 3.0\n**********************************************************************\n*/\n#ifndef MEASUREFORMAT_H\n#define MEASUREFORMAT_H\n\n#include \"unicode/utypes.h\"\n\n#if !UCONFIG_NO_FORMATTING\n\n#include \"unicode/format.h\"\n\n/**\n * \\file \n * \\brief C++ API: Formatter for measure objects.\n */\n\nU_NAMESPACE_BEGIN\n\n/**\n * \n * A formatter for measure objects.  This is an abstract base class.\n *\n * <p>To format or parse a measure object, first create a formatter\n * object using a MeasureFormat factory method.  Then use that\n * object's format and parse methods.\n *\n * <p>This is an abstract class.\n *\n * @see Format\n * @author Alan Liu\n * @stable ICU 3.0\n */\nclass U_I18N_API MeasureFormat : public Format {\n public:\n    /**\n     * Destructor.\n     * @stable ICU 3.0\n     */\n    virtual ~MeasureFormat();\n\n    /**\n     * Return a formatter for CurrencyAmount objects in the given\n     * locale.\n     * @param locale desired locale\n     * @param ec input-output error code\n     * @return a formatter object, or NULL upon error\n     * @stable ICU 3.0\n     */\n    static MeasureFormat* U_EXPORT2 createCurrencyFormat(const Locale& locale,\n                                               UErrorCode& ec);\n\n    /**\n     * Return a formatter for CurrencyAmount objects in the default\n     * locale.\n     * @param ec input-output error code\n     * @return a formatter object, or NULL upon error\n     * @stable ICU 3.0\n     */\n    static MeasureFormat* U_EXPORT2 createCurrencyFormat(UErrorCode& ec);\n\n protected:\n\n    /**\n     * Default constructor.\n     * @stable ICU 3.0\n     */\n    MeasureFormat();\n};\n\nU_NAMESPACE_END\n\n#endif // #if !UCONFIG_NO_FORMATTING\n#endif // #ifndef MEASUREFORMAT_H\n"
  },
  {
    "path": "deprecated/android/addons/icucompat/unicode/measunit.h",
    "content": "/*\n**********************************************************************\n* Copyright (c) 2004-2006, International Business Machines\n* Corporation and others.  All Rights Reserved.\n**********************************************************************\n* Author: Alan Liu\n* Created: April 26, 2004\n* Since: ICU 3.0\n**********************************************************************\n*/\n#ifndef __MEASUREUNIT_H__\n#define __MEASUREUNIT_H__\n\n#include \"unicode/utypes.h\"\n\n#if !UCONFIG_NO_FORMATTING\n\n#include \"unicode/fmtable.h\"\n\n/**\n * \\file \n * \\brief C++ API: A unit for measuring a quantity.\n */\n \nU_NAMESPACE_BEGIN\n\n/**\n * A unit such as length, mass, volume, currency, etc.  A unit is\n * coupled with a numeric amount to produce a Measure.\n *\n * <p>This is an abstract class.\n *\n * @author Alan Liu\n * @stable ICU 3.0\n */\nclass U_I18N_API MeasureUnit: public UObject {\n public:\n    /**\n     * Return a polymorphic clone of this object.  The result will\n     * have the same class as returned by getDynamicClassID().\n     * @stable ICU 3.0\n     */\n    virtual UObject* clone() const = 0;\n\n    /**\n     * Destructor\n     * @stable ICU 3.0\n     */\n    virtual ~MeasureUnit();\n    \n    /**\n     * Equality operator.  Return true if this object is equal\n     * to the given object.\n     * @stable ICU 3.0\n     */\n    virtual UBool operator==(const UObject& other) const = 0;\n\n protected:\n    /**\n     * Default constructor.\n     * @stable ICU 3.0\n     */\n    MeasureUnit();\n};\n\nU_NAMESPACE_END\n\n// NOTE: There is no measunit.cpp. For implementation, see measure.cpp. [alan]\n\n#endif // !UCONFIG_NO_FORMATTING\n#endif // __MEASUREUNIT_H__\n"
  },
  {
    "path": "deprecated/android/addons/icucompat/unicode/measure.h",
    "content": "/*\n**********************************************************************\n* Copyright (c) 2004-2006, International Business Machines\n* Corporation and others.  All Rights Reserved.\n**********************************************************************\n* Author: Alan Liu\n* Created: April 26, 2004\n* Since: ICU 3.0\n**********************************************************************\n*/\n#ifndef __MEASURE_H__\n#define __MEASURE_H__\n\n#include \"unicode/utypes.h\"\n\n/**\n * \\file \n * \\brief C++ API: MeasureUnit object.\n */\n \n#if !UCONFIG_NO_FORMATTING\n\n#include \"unicode/fmtable.h\"\n\nU_NAMESPACE_BEGIN\n\nclass MeasureUnit;\n\n/**\n * An amount of a specified unit, consisting of a number and a Unit.\n * For example, a length measure consists of a number and a length\n * unit, such as feet or meters.  This is an abstract class.\n * Subclasses specify a concrete Unit type.\n *\n * <p>Measure objects are parsed and formatted by subclasses of\n * MeasureFormat.\n *\n * <p>Measure objects are immutable.\n *\n * <p>This is an abstract class.\n *\n * @author Alan Liu\n * @stable ICU 3.0\n */\nclass U_I18N_API Measure: public UObject {\n public:\n    /**\n     * Construct an object with the given numeric amount and the given\n     * unit.  After this call, the caller must not delete the given\n     * unit object.\n     * @param number a numeric object; amount.isNumeric() must be TRUE\n     * @param adoptedUnit the unit object, which must not be NULL\n     * @param ec input-output error code. If the amount or the unit\n     * is invalid, then this will be set to a failing value.\n     * @stable ICU 3.0\n     */\n    Measure(const Formattable& number, MeasureUnit* adoptedUnit,\n            UErrorCode& ec);\n\n    /**\n     * Copy constructor\n     * @stable ICU 3.0\n     */\n    Measure(const Measure& other);\n\n    /**\n     * Assignment operator\n     * @stable ICU 3.0\n     */\n    Measure& operator=(const Measure& other);\n\n    /**\n     * Return a polymorphic clone of this object.  The result will\n     * have the same class as returned by getDynamicClassID().\n     * @stable ICU 3.0\n     */\n    virtual UObject* clone() const = 0;\n\n    /**\n     * Destructor\n     * @stable ICU 3.0\n     */\n    virtual ~Measure();\n    \n    /**\n     * Equality operator.  Return true if this object is equal\n     * to the given object.\n     * @stable ICU 3.0\n     */\n    UBool operator==(const UObject& other) const;\n\n    /**\n     * Return a reference to the numeric value of this object.  The\n     * numeric value may be of any numeric type supported by\n     * Formattable.\n     * @stable ICU 3.0\n     */\n    inline const Formattable& getNumber() const;\n\n    /**\n     * Return a reference to the unit of this object.\n     * @stable ICU 3.0\n     */\n    inline const MeasureUnit& getUnit() const;\n\n protected:\n    /**\n     * Default constructor.\n     * @stable ICU 3.0\n     */\n    Measure();\n\n private:\n    /**\n     * The numeric value of this object, e.g. 2.54 or 100.\n     */\n    Formattable number;\n\n    /**\n     * The unit of this object, e.g., \"millimeter\" or \"JPY\".  This is\n     * owned by this object.\n     */\n    MeasureUnit* unit;\n};\n\ninline const Formattable& Measure::getNumber() const {\n    return number;\n}\n\ninline const MeasureUnit& Measure::getUnit() const {\n    return *unit;\n}\n\nU_NAMESPACE_END\n\n#endif // !UCONFIG_NO_FORMATTING\n#endif // __MEASURE_H__\n"
  },
  {
    "path": "deprecated/android/addons/icucompat/unicode/messagepattern.h",
    "content": "/*\n*******************************************************************************\n*   Copyright (C) 2011-2012, International Business Machines\n*   Corporation and others.  All Rights Reserved.\n*******************************************************************************\n*   file name:  messagepattern.h\n*   encoding:   US-ASCII\n*   tab size:   8 (not used)\n*   indentation:4\n*\n*   created on: 2011mar14\n*   created by: Markus W. Scherer\n*/\n\n#ifndef __MESSAGEPATTERN_H__\n#define __MESSAGEPATTERN_H__\n\n/**\n * \\file\n * \\brief C++ API: MessagePattern class: Parses and represents ICU MessageFormat patterns.\n */\n\n#include \"unicode/utypes.h\"\n\n#if !UCONFIG_NO_FORMATTING\n\n#include \"unicode/parseerr.h\"\n#include \"unicode/unistr.h\"\n\n/**\n * Mode for when an apostrophe starts quoted literal text for MessageFormat output.\n * The default is DOUBLE_OPTIONAL unless overridden via uconfig.h\n * (UCONFIG_MSGPAT_DEFAULT_APOSTROPHE_MODE).\n * <p>\n * A pair of adjacent apostrophes always results in a single apostrophe in the output,\n * even when the pair is between two single, text-quoting apostrophes.\n * <p>\n * The following table shows examples of desired MessageFormat.format() output\n * with the pattern strings that yield that output.\n * <p>\n * <table>\n *   <tr>\n *     <th>Desired output</th>\n *     <th>DOUBLE_OPTIONAL</th>\n *     <th>DOUBLE_REQUIRED</th>\n *   </tr>\n *   <tr>\n *     <td>I see {many}</td>\n *     <td>I see '{many}'</td>\n *     <td>(same)</td>\n *   </tr>\n *   <tr>\n *     <td>I said {'Wow!'}</td>\n *     <td>I said '{''Wow!''}'</td>\n *     <td>(same)</td>\n *   </tr>\n *   <tr>\n *     <td>I don't know</td>\n *     <td>I don't know OR<br> I don''t know</td>\n *     <td>I don''t know</td>\n *   </tr>\n * </table>\n * @stable ICU 4.8\n * @see UCONFIG_MSGPAT_DEFAULT_APOSTROPHE_MODE\n */\nenum UMessagePatternApostropheMode {\n    /**\n     * A literal apostrophe is represented by\n     * either a single or a double apostrophe pattern character.\n     * Within a MessageFormat pattern, a single apostrophe only starts quoted literal text\n     * if it immediately precedes a curly brace {},\n     * or a pipe symbol | if inside a choice format,\n     * or a pound symbol # if inside a plural format.\n     * <p>\n     * This is the default behavior starting with ICU 4.8.\n     * @stable ICU 4.8\n     */\n    UMSGPAT_APOS_DOUBLE_OPTIONAL,\n    /**\n     * A literal apostrophe must be represented by\n     * a double apostrophe pattern character.\n     * A single apostrophe always starts quoted literal text.\n     * <p>\n     * This is the behavior of ICU 4.6 and earlier, and of the JDK.\n     * @stable ICU 4.8\n     */\n    UMSGPAT_APOS_DOUBLE_REQUIRED\n};\n/**\n * @stable ICU 4.8\n */\ntypedef enum UMessagePatternApostropheMode UMessagePatternApostropheMode;\n\n/**\n * MessagePattern::Part type constants.\n * @stable ICU 4.8\n */\nenum UMessagePatternPartType {\n    /**\n     * Start of a message pattern (main or nested).\n     * The length is 0 for the top-level message\n     * and for a choice argument sub-message, otherwise 1 for the '{'.\n     * The value indicates the nesting level, starting with 0 for the main message.\n     * <p>\n     * There is always a later MSG_LIMIT part.\n     * @stable ICU 4.8\n     */\n    UMSGPAT_PART_TYPE_MSG_START,\n    /**\n     * End of a message pattern (main or nested).\n     * The length is 0 for the top-level message and\n     * the last sub-message of a choice argument,\n     * otherwise 1 for the '}' or (in a choice argument style) the '|'.\n     * The value indicates the nesting level, starting with 0 for the main message.\n     * @stable ICU 4.8\n     */\n    UMSGPAT_PART_TYPE_MSG_LIMIT,\n    /**\n     * Indicates a substring of the pattern string which is to be skipped when formatting.\n     * For example, an apostrophe that begins or ends quoted text\n     * would be indicated with such a part.\n     * The value is undefined and currently always 0.\n     * @stable ICU 4.8\n     */\n    UMSGPAT_PART_TYPE_SKIP_SYNTAX,\n    /**\n     * Indicates that a syntax character needs to be inserted for auto-quoting.\n     * The length is 0.\n     * The value is the character code of the insertion character. (U+0027=APOSTROPHE)\n     * @stable ICU 4.8\n     */\n    UMSGPAT_PART_TYPE_INSERT_CHAR,\n    /**\n     * Indicates a syntactic (non-escaped) # symbol in a plural variant.\n     * When formatting, replace this part's substring with the\n     * (value-offset) for the plural argument value.\n     * The value is undefined and currently always 0.\n     * @stable ICU 4.8\n     */\n    UMSGPAT_PART_TYPE_REPLACE_NUMBER,\n    /**\n     * Start of an argument.\n     * The length is 1 for the '{'.\n     * The value is the ordinal value of the ArgType. Use getArgType().\n     * <p>\n     * This part is followed by either an ARG_NUMBER or ARG_NAME,\n     * followed by optional argument sub-parts (see UMessagePatternArgType constants)\n     * and finally an ARG_LIMIT part.\n     * @stable ICU 4.8\n     */\n    UMSGPAT_PART_TYPE_ARG_START,\n    /**\n     * End of an argument.\n     * The length is 1 for the '}'.\n     * The value is the ordinal value of the ArgType. Use getArgType().\n     * @stable ICU 4.8\n     */\n    UMSGPAT_PART_TYPE_ARG_LIMIT,\n    /**\n     * The argument number, provided by the value.\n     * @stable ICU 4.8\n     */\n    UMSGPAT_PART_TYPE_ARG_NUMBER,\n    /**\n     * The argument name.\n     * The value is undefined and currently always 0.\n     * @stable ICU 4.8\n     */\n    UMSGPAT_PART_TYPE_ARG_NAME,\n    /**\n     * The argument type.\n     * The value is undefined and currently always 0.\n     * @stable ICU 4.8\n     */\n    UMSGPAT_PART_TYPE_ARG_TYPE,\n    /**\n     * The argument style text.\n     * The value is undefined and currently always 0.\n     * @stable ICU 4.8\n     */\n    UMSGPAT_PART_TYPE_ARG_STYLE,\n    /**\n     * A selector substring in a \"complex\" argument style.\n     * The value is undefined and currently always 0.\n     * @stable ICU 4.8\n     */\n    UMSGPAT_PART_TYPE_ARG_SELECTOR,\n    /**\n     * An integer value, for example the offset or an explicit selector value\n     * in a PluralFormat style.\n     * The part value is the integer value.\n     * @stable ICU 4.8\n     */\n    UMSGPAT_PART_TYPE_ARG_INT,\n    /**\n     * A numeric value, for example the offset or an explicit selector value\n     * in a PluralFormat style.\n     * The part value is an index into an internal array of numeric values;\n     * use getNumericValue().\n     * @stable ICU 4.8\n     */\n    UMSGPAT_PART_TYPE_ARG_DOUBLE\n};\n/**\n * @stable ICU 4.8\n */\ntypedef enum UMessagePatternPartType UMessagePatternPartType;\n\n/**\n * Argument type constants.\n * Returned by Part.getArgType() for ARG_START and ARG_LIMIT parts.\n *\n * Messages nested inside an argument are each delimited by MSG_START and MSG_LIMIT,\n * with a nesting level one greater than the surrounding message.\n * @stable ICU 4.8\n */\nenum UMessagePatternArgType {\n    /**\n     * The argument has no specified type.\n     * @stable ICU 4.8\n     */\n    UMSGPAT_ARG_TYPE_NONE,\n    /**\n     * The argument has a \"simple\" type which is provided by the ARG_TYPE part.\n     * An ARG_STYLE part might follow that.\n     * @stable ICU 4.8\n     */\n    UMSGPAT_ARG_TYPE_SIMPLE,\n    /**\n     * The argument is a ChoiceFormat with one or more\n     * ((ARG_INT | ARG_DOUBLE), ARG_SELECTOR, message) tuples.\n     * @stable ICU 4.8\n     */\n    UMSGPAT_ARG_TYPE_CHOICE,\n    /**\n     * The argument is a cardinal-number PluralFormat with an optional ARG_INT or ARG_DOUBLE offset\n     * (e.g., offset:1)\n     * and one or more (ARG_SELECTOR [explicit-value] message) tuples.\n     * If the selector has an explicit value (e.g., =2), then\n     * that value is provided by the ARG_INT or ARG_DOUBLE part preceding the message.\n     * Otherwise the message immediately follows the ARG_SELECTOR.\n     * @stable ICU 4.8\n     */\n    UMSGPAT_ARG_TYPE_PLURAL,\n    /**\n     * The argument is a SelectFormat with one or more (ARG_SELECTOR, message) pairs.\n     * @stable ICU 4.8\n     */\n    UMSGPAT_ARG_TYPE_SELECT,\n    /**\n     * The argument is an ordinal-number PluralFormat\n     * with the same style parts sequence and semantics as UMSGPAT_ARG_TYPE_PLURAL.\n     * @draft ICU 50\n     */\n    UMSGPAT_ARG_TYPE_SELECTORDINAL\n};\n/**\n * @stable ICU 4.8\n */\ntypedef enum UMessagePatternArgType UMessagePatternArgType;\n\n/**\n * Returns TRUE if the argument type has a plural style part sequence and semantics,\n * for example UMSGPAT_ARG_TYPE_PLURAL and UMSGPAT_ARG_TYPE_SELECTORDINAL.\n * @draft ICU 50\n */\n#define UMSGPAT_ARG_TYPE_HAS_PLURAL_STYLE(argType) \\\n    ((argType)==UMSGPAT_ARG_TYPE_PLURAL || (argType)==UMSGPAT_ARG_TYPE_SELECTORDINAL)\n\nenum {\n    /**\n     * Return value from MessagePattern.validateArgumentName() for when\n     * the string is a valid \"pattern identifier\" but not a number.\n     * @stable ICU 4.8\n     */\n    UMSGPAT_ARG_NAME_NOT_NUMBER=-1,\n\n    /**\n     * Return value from MessagePattern.validateArgumentName() for when\n     * the string is invalid.\n     * It might not be a valid \"pattern identifier\",\n     * or it have only ASCII digits but there is a leading zero or the number is too large.\n     * @stable ICU 4.8\n     */\n    UMSGPAT_ARG_NAME_NOT_VALID=-2\n};\n\n/**\n * Special value that is returned by getNumericValue(Part) when no\n * numeric value is defined for a part.\n * @see MessagePattern.getNumericValue()\n * @stable ICU 4.8\n */\n#define UMSGPAT_NO_NUMERIC_VALUE ((double)(-123456789))\n\nU_NAMESPACE_BEGIN\n\nclass MessagePatternDoubleList;\nclass MessagePatternPartsList;\n\n/**\n * Parses and represents ICU MessageFormat patterns.\n * Also handles patterns for ChoiceFormat, PluralFormat and SelectFormat.\n * Used in the implementations of those classes as well as in tools\n * for message validation, translation and format conversion.\n * <p>\n * The parser handles all syntax relevant for identifying message arguments.\n * This includes \"complex\" arguments whose style strings contain\n * nested MessageFormat pattern substrings.\n * For \"simple\" arguments (with no nested MessageFormat pattern substrings),\n * the argument style is not parsed any further.\n * <p>\n * The parser handles named and numbered message arguments and allows both in one message.\n * <p>\n * Once a pattern has been parsed successfully, iterate through the parsed data\n * with countParts(), getPart() and related methods.\n * <p>\n * The data logically represents a parse tree, but is stored and accessed\n * as a list of \"parts\" for fast and simple parsing and to minimize object allocations.\n * Arguments and nested messages are best handled via recursion.\n * For every _START \"part\", MessagePattern.getLimitPartIndex() efficiently returns\n * the index of the corresponding _LIMIT \"part\".\n * <p>\n * List of \"parts\":\n * <pre>\n * message = MSG_START (SKIP_SYNTAX | INSERT_CHAR | REPLACE_NUMBER | argument)* MSG_LIMIT\n * argument = noneArg | simpleArg | complexArg\n * complexArg = choiceArg | pluralArg | selectArg\n *\n * noneArg = ARG_START.NONE (ARG_NAME | ARG_NUMBER) ARG_LIMIT.NONE\n * simpleArg = ARG_START.SIMPLE (ARG_NAME | ARG_NUMBER) ARG_TYPE [ARG_STYLE] ARG_LIMIT.SIMPLE\n * choiceArg = ARG_START.CHOICE (ARG_NAME | ARG_NUMBER) choiceStyle ARG_LIMIT.CHOICE\n * pluralArg = ARG_START.PLURAL (ARG_NAME | ARG_NUMBER) pluralStyle ARG_LIMIT.PLURAL\n * selectArg = ARG_START.SELECT (ARG_NAME | ARG_NUMBER) selectStyle ARG_LIMIT.SELECT\n *\n * choiceStyle = ((ARG_INT | ARG_DOUBLE) ARG_SELECTOR message)+\n * pluralStyle = [ARG_INT | ARG_DOUBLE] (ARG_SELECTOR [ARG_INT | ARG_DOUBLE] message)+\n * selectStyle = (ARG_SELECTOR message)+\n * </pre>\n * <ul>\n *   <li>Literal output text is not represented directly by \"parts\" but accessed\n *       between parts of a message, from one part's getLimit() to the next part's getIndex().\n *   <li><code>ARG_START.CHOICE</code> stands for an ARG_START Part with ArgType CHOICE.\n *   <li>In the choiceStyle, the ARG_SELECTOR has the '<', the '#' or\n *       the less-than-or-equal-to sign (U+2264).\n *   <li>In the pluralStyle, the first, optional numeric Part has the \"offset:\" value.\n *       The optional numeric Part between each (ARG_SELECTOR, message) pair\n *       is the value of an explicit-number selector like \"=2\",\n *       otherwise the selector is a non-numeric identifier.\n *   <li>The REPLACE_NUMBER Part can occur only in an immediate sub-message of the pluralStyle.\n * </ul>\n * <p>\n * This class is not intended for public subclassing.\n *\n * @stable ICU 4.8\n */\nclass U_COMMON_API MessagePattern : public UObject {\npublic:\n    /**\n     * Constructs an empty MessagePattern with default UMessagePatternApostropheMode.\n     * @param errorCode Standard ICU error code. Its input value must\n     *                  pass the U_SUCCESS() test, or else the function returns\n     *                  immediately. Check for U_FAILURE() on output or use with\n     *                  function chaining. (See User Guide for details.)\n     * @stable ICU 4.8\n     */\n    MessagePattern(UErrorCode &errorCode);\n\n    /**\n     * Constructs an empty MessagePattern.\n     * @param mode Explicit UMessagePatternApostropheMode.\n     * @param errorCode Standard ICU error code. Its input value must\n     *                  pass the U_SUCCESS() test, or else the function returns\n     *                  immediately. Check for U_FAILURE() on output or use with\n     *                  function chaining. (See User Guide for details.)\n     * @stable ICU 4.8\n     */\n    MessagePattern(UMessagePatternApostropheMode mode, UErrorCode &errorCode);\n\n    /**\n     * Constructs a MessagePattern with default UMessagePatternApostropheMode and\n     * parses the MessageFormat pattern string.\n     * @param pattern a MessageFormat pattern string\n     * @param parseError Struct to receive information on the position\n     *                   of an error within the pattern.\n     *                   Can be NULL.\n     * @param errorCode Standard ICU error code. Its input value must\n     *                  pass the U_SUCCESS() test, or else the function returns\n     *                  immediately. Check for U_FAILURE() on output or use with\n     *                  function chaining. (See User Guide for details.)\n     * TODO: turn @throws into UErrorCode specifics?\n     * @throws IllegalArgumentException for syntax errors in the pattern string\n     * @throws IndexOutOfBoundsException if certain limits are exceeded\n     *         (e.g., argument number too high, argument name too long, etc.)\n     * @throws NumberFormatException if a number could not be parsed\n     * @stable ICU 4.8\n     */\n    MessagePattern(const UnicodeString &pattern, UParseError *parseError, UErrorCode &errorCode);\n\n    /**\n     * Copy constructor.\n     * @param other Object to copy.\n     * @stable ICU 4.8\n     */\n    MessagePattern(const MessagePattern &other);\n\n    /**\n     * Assignment operator.\n     * @param other Object to copy.\n     * @return *this=other\n     * @stable ICU 4.8\n     */\n    MessagePattern &operator=(const MessagePattern &other);\n\n    /**\n     * Destructor.\n     * @stable ICU 4.8\n     */\n    virtual ~MessagePattern();\n\n    /**\n     * Parses a MessageFormat pattern string.\n     * @param pattern a MessageFormat pattern string\n     * @param parseError Struct to receive information on the position\n     *                   of an error within the pattern.\n     *                   Can be NULL.\n     * @param errorCode Standard ICU error code. Its input value must\n     *                  pass the U_SUCCESS() test, or else the function returns\n     *                  immediately. Check for U_FAILURE() on output or use with\n     *                  function chaining. (See User Guide for details.)\n     * @return *this\n     * @throws IllegalArgumentException for syntax errors in the pattern string\n     * @throws IndexOutOfBoundsException if certain limits are exceeded\n     *         (e.g., argument number too high, argument name too long, etc.)\n     * @throws NumberFormatException if a number could not be parsed\n     * @stable ICU 4.8\n     */\n    MessagePattern &parse(const UnicodeString &pattern,\n                          UParseError *parseError, UErrorCode &errorCode);\n\n    /**\n     * Parses a ChoiceFormat pattern string.\n     * @param pattern a ChoiceFormat pattern string\n     * @param parseError Struct to receive information on the position\n     *                   of an error within the pattern.\n     *                   Can be NULL.\n     * @param errorCode Standard ICU error code. Its input value must\n     *                  pass the U_SUCCESS() test, or else the function returns\n     *                  immediately. Check for U_FAILURE() on output or use with\n     *                  function chaining. (See User Guide for details.)\n     * @return *this\n     * @throws IllegalArgumentException for syntax errors in the pattern string\n     * @throws IndexOutOfBoundsException if certain limits are exceeded\n     *         (e.g., argument number too high, argument name too long, etc.)\n     * @throws NumberFormatException if a number could not be parsed\n     * @stable ICU 4.8\n     */\n    MessagePattern &parseChoiceStyle(const UnicodeString &pattern,\n                                     UParseError *parseError, UErrorCode &errorCode);\n\n    /**\n     * Parses a PluralFormat pattern string.\n     * @param pattern a PluralFormat pattern string\n     * @param parseError Struct to receive information on the position\n     *                   of an error within the pattern.\n     *                   Can be NULL.\n     * @param errorCode Standard ICU error code. Its input value must\n     *                  pass the U_SUCCESS() test, or else the function returns\n     *                  immediately. Check for U_FAILURE() on output or use with\n     *                  function chaining. (See User Guide for details.)\n     * @return *this\n     * @throws IllegalArgumentException for syntax errors in the pattern string\n     * @throws IndexOutOfBoundsException if certain limits are exceeded\n     *         (e.g., argument number too high, argument name too long, etc.)\n     * @throws NumberFormatException if a number could not be parsed\n     * @stable ICU 4.8\n     */\n    MessagePattern &parsePluralStyle(const UnicodeString &pattern,\n                                     UParseError *parseError, UErrorCode &errorCode);\n\n    /**\n     * Parses a SelectFormat pattern string.\n     * @param pattern a SelectFormat pattern string\n     * @param parseError Struct to receive information on the position\n     *                   of an error within the pattern.\n     *                   Can be NULL.\n     * @param errorCode Standard ICU error code. Its input value must\n     *                  pass the U_SUCCESS() test, or else the function returns\n     *                  immediately. Check for U_FAILURE() on output or use with\n     *                  function chaining. (See User Guide for details.)\n     * @return *this\n     * @throws IllegalArgumentException for syntax errors in the pattern string\n     * @throws IndexOutOfBoundsException if certain limits are exceeded\n     *         (e.g., argument number too high, argument name too long, etc.)\n     * @throws NumberFormatException if a number could not be parsed\n     * @stable ICU 4.8\n     */\n    MessagePattern &parseSelectStyle(const UnicodeString &pattern,\n                                     UParseError *parseError, UErrorCode &errorCode);\n\n    /**\n     * Clears this MessagePattern.\n     * countParts() will return 0.\n     * @stable ICU 4.8\n     */\n    void clear();\n\n    /**\n     * Clears this MessagePattern and sets the UMessagePatternApostropheMode.\n     * countParts() will return 0.\n     * @param mode The new UMessagePatternApostropheMode.\n     * @stable ICU 4.8\n     */\n    void clearPatternAndSetApostropheMode(UMessagePatternApostropheMode mode) {\n        clear();\n        aposMode=mode;\n    }\n\n    /**\n     * @param other another object to compare with.\n     * @return TRUE if this object is equivalent to the other one.\n     * @stable ICU 4.8\n     */\n    UBool operator==(const MessagePattern &other) const;\n\n    /**\n     * @param other another object to compare with.\n     * @return FALSE if this object is equivalent to the other one.\n     * @stable ICU 4.8\n     */\n    inline UBool operator!=(const MessagePattern &other) const {\n        return !operator==(other);\n    }\n\n    /**\n     * @return A hash code for this object.\n     * @stable ICU 4.8\n     */\n    int32_t hashCode() const;\n\n    /**\n     * @return this instance's UMessagePatternApostropheMode.\n     * @stable ICU 4.8\n     */\n    UMessagePatternApostropheMode getApostropheMode() const {\n        return aposMode;\n    }\n\n    // Java has package-private jdkAposMode() here.\n    // In C++, this is declared in the MessageImpl class.\n\n    /**\n     * @return the parsed pattern string (null if none was parsed).\n     * @stable ICU 4.8\n     */\n    const UnicodeString &getPatternString() const {\n        return msg;\n    }\n\n    /**\n     * Does the parsed pattern have named arguments like {first_name}?\n     * @return TRUE if the parsed pattern has at least one named argument.\n     * @stable ICU 4.8\n     */\n    UBool hasNamedArguments() const {\n        return hasArgNames;\n    }\n\n    /**\n     * Does the parsed pattern have numbered arguments like {2}?\n     * @return TRUE if the parsed pattern has at least one numbered argument.\n     * @stable ICU 4.8\n     */\n    UBool hasNumberedArguments() const {\n        return hasArgNumbers;\n    }\n\n    /**\n     * Validates and parses an argument name or argument number string.\n     * An argument name must be a \"pattern identifier\", that is, it must contain\n     * no Unicode Pattern_Syntax or Pattern_White_Space characters.\n     * If it only contains ASCII digits, then it must be a small integer with no leading zero.\n     * @param name Input string.\n     * @return &gt;=0 if the name is a valid number,\n     *         ARG_NAME_NOT_NUMBER (-1) if it is a \"pattern identifier\" but not all ASCII digits,\n     *         ARG_NAME_NOT_VALID (-2) if it is neither.\n     * @stable ICU 4.8\n     */\n    static int32_t validateArgumentName(const UnicodeString &name);\n\n    /**\n     * Returns a version of the parsed pattern string where each ASCII apostrophe\n     * is doubled (escaped) if it is not already, and if it is not interpreted as quoting syntax.\n     * <p>\n     * For example, this turns \"I don't '{know}' {gender,select,female{h''er}other{h'im}}.\"\n     * into \"I don''t '{know}' {gender,select,female{h''er}other{h''im}}.\"\n     * @return the deep-auto-quoted version of the parsed pattern string.\n     * @see MessageFormat.autoQuoteApostrophe()\n     * @stable ICU 4.8\n     */\n    UnicodeString autoQuoteApostropheDeep() const;\n\n    class Part;\n\n    /**\n     * Returns the number of \"parts\" created by parsing the pattern string.\n     * Returns 0 if no pattern has been parsed or clear() was called.\n     * @return the number of pattern parts.\n     * @stable ICU 4.8\n     */\n    int32_t countParts() const {\n        return partsLength;\n    }\n\n    /**\n     * Gets the i-th pattern \"part\".\n     * @param i The index of the Part data. (0..countParts()-1)\n     * @return the i-th pattern \"part\".\n     * @stable ICU 4.8\n     */\n    const Part &getPart(int32_t i) const {\n        return parts[i];\n    }\n\n    /**\n     * Returns the UMessagePatternPartType of the i-th pattern \"part\".\n     * Convenience method for getPart(i).getType().\n     * @param i The index of the Part data. (0..countParts()-1)\n     * @return The UMessagePatternPartType of the i-th Part.\n     * @stable ICU 4.8\n     */\n    UMessagePatternPartType getPartType(int32_t i) const {\n        return getPart(i).type;\n    }\n\n    /**\n     * Returns the pattern index of the specified pattern \"part\".\n     * Convenience method for getPart(partIndex).getIndex().\n     * @param partIndex The index of the Part data. (0..countParts()-1)\n     * @return The pattern index of this Part.\n     * @stable ICU 4.8\n     */\n    int32_t getPatternIndex(int32_t partIndex) const {\n        return getPart(partIndex).index;\n    }\n\n    /**\n     * Returns the substring of the pattern string indicated by the Part.\n     * Convenience method for getPatternString().substring(part.getIndex(), part.getLimit()).\n     * @param part a part of this MessagePattern.\n     * @return the substring associated with part.\n     * @stable ICU 4.8\n     */\n    UnicodeString getSubstring(const Part &part) const {\n        return msg.tempSubString(part.index, part.length);\n    }\n\n    /**\n     * Compares the part's substring with the input string s.\n     * @param part a part of this MessagePattern.\n     * @param s a string.\n     * @return TRUE if getSubstring(part).equals(s).\n     * @stable ICU 4.8\n     */\n    UBool partSubstringMatches(const Part &part, const UnicodeString &s) const {\n        return 0==msg.compare(part.index, part.length, s);\n    }\n\n    /**\n     * Returns the numeric value associated with an ARG_INT or ARG_DOUBLE.\n     * @param part a part of this MessagePattern.\n     * @return the part's numeric value, or UMSGPAT_NO_NUMERIC_VALUE if this is not a numeric part.\n     * @stable ICU 4.8\n     */\n    double getNumericValue(const Part &part) const;\n\n    /**\n     * Returns the \"offset:\" value of a PluralFormat argument, or 0 if none is specified.\n     * @param pluralStart the index of the first PluralFormat argument style part. (0..countParts()-1)\n     * @return the \"offset:\" value.\n     * @stable ICU 4.8\n     */\n    double getPluralOffset(int32_t pluralStart) const;\n\n    /**\n     * Returns the index of the ARG|MSG_LIMIT part corresponding to the ARG|MSG_START at start.\n     * @param start The index of some Part data (0..countParts()-1);\n     *        this Part should be of Type ARG_START or MSG_START.\n     * @return The first i>start where getPart(i).getType()==ARG|MSG_LIMIT at the same nesting level,\n     *         or start itself if getPartType(msgStart)!=ARG|MSG_START.\n     * @stable ICU 4.8\n     */\n    int32_t getLimitPartIndex(int32_t start) const {\n        int32_t limit=getPart(start).limitPartIndex;\n        if(limit<start) {\n            return start;\n        }\n        return limit;\n    }\n\n    /**\n     * A message pattern \"part\", representing a pattern parsing event.\n     * There is a part for the start and end of a message or argument,\n     * for quoting and escaping of and with ASCII apostrophes,\n     * and for syntax elements of \"complex\" arguments.\n     * @stable ICU 4.8\n     */\n    class Part : public UMemory {\n    public:\n        /**\n         * Default constructor, do not use.\n         * @internal\n         */\n        Part() {}\n\n        /**\n         * Returns the type of this part.\n         * @return the part type.\n         * @stable ICU 4.8\n         */\n        UMessagePatternPartType getType() const {\n            return type;\n        }\n\n        /**\n         * Returns the pattern string index associated with this Part.\n         * @return this part's pattern string index.\n         * @stable ICU 4.8\n         */\n        int32_t getIndex() const {\n            return index;\n        }\n\n        /**\n         * Returns the length of the pattern substring associated with this Part.\n         * This is 0 for some parts.\n         * @return this part's pattern substring length.\n         * @stable ICU 4.8\n         */\n        int32_t getLength() const {\n            return length;\n        }\n\n        /**\n         * Returns the pattern string limit (exclusive-end) index associated with this Part.\n         * Convenience method for getIndex()+getLength().\n         * @return this part's pattern string limit index, same as getIndex()+getLength().\n         * @stable ICU 4.8\n         */\n        int32_t getLimit() const {\n            return index+length;\n        }\n\n        /**\n         * Returns a value associated with this part.\n         * See the documentation of each part type for details.\n         * @return the part value.\n         * @stable ICU 4.8\n         */\n        int32_t getValue() const {\n            return value;\n        }\n\n        /**\n         * Returns the argument type if this part is of type ARG_START or ARG_LIMIT,\n         * otherwise UMSGPAT_ARG_TYPE_NONE.\n         * @return the argument type for this part.\n         * @stable ICU 4.8\n         */\n        UMessagePatternArgType getArgType() const {\n            UMessagePatternPartType type=getType();\n            if(type==UMSGPAT_PART_TYPE_ARG_START || type==UMSGPAT_PART_TYPE_ARG_LIMIT) {\n                return (UMessagePatternArgType)value;\n            } else {\n                return UMSGPAT_ARG_TYPE_NONE;\n            }\n        }\n\n        /**\n         * Indicates whether the Part type has a numeric value.\n         * If so, then that numeric value can be retrieved via MessagePattern.getNumericValue().\n         * @param type The Part type to be tested.\n         * @return TRUE if the Part type has a numeric value.\n         * @stable ICU 4.8\n         */\n        static UBool hasNumericValue(UMessagePatternPartType type) {\n            return type==UMSGPAT_PART_TYPE_ARG_INT || type==UMSGPAT_PART_TYPE_ARG_DOUBLE;\n        }\n\n        /**\n         * @param other another object to compare with.\n         * @return TRUE if this object is equivalent to the other one.\n         * @stable ICU 4.8\n         */\n        UBool operator==(const Part &other) const;\n\n        /**\n         * @param other another object to compare with.\n         * @return FALSE if this object is equivalent to the other one.\n         * @stable ICU 4.8\n         */\n        inline UBool operator!=(const Part &other) const {\n            return !operator==(other);\n        }\n\n        /**\n         * @return A hash code for this object.\n         * @stable ICU 4.8\n         */\n        int32_t hashCode() const {\n            return ((type*37+index)*37+length)*37+value;\n        }\n\n    private:\n        friend class MessagePattern;\n\n        static const int32_t MAX_LENGTH=0xffff;\n        static const int32_t MAX_VALUE=0x7fff;\n\n        // Some fields are not final because they are modified during pattern parsing.\n        // After pattern parsing, the parts are effectively immutable.\n        UMessagePatternPartType type;\n        int32_t index;\n        uint16_t length;\n        int16_t value;\n        int32_t limitPartIndex;\n    };\n\nprivate:\n    void preParse(const UnicodeString &pattern, UParseError *parseError, UErrorCode &errorCode);\n\n    void postParse();\n\n    int32_t parseMessage(int32_t index, int32_t msgStartLength,\n                         int32_t nestingLevel, UMessagePatternArgType parentType,\n                         UParseError *parseError, UErrorCode &errorCode);\n\n    int32_t parseArg(int32_t index, int32_t argStartLength, int32_t nestingLevel,\n                     UParseError *parseError, UErrorCode &errorCode);\n\n    int32_t parseSimpleStyle(int32_t index, UParseError *parseError, UErrorCode &errorCode);\n\n    int32_t parseChoiceStyle(int32_t index, int32_t nestingLevel,\n                             UParseError *parseError, UErrorCode &errorCode);\n\n    int32_t parsePluralOrSelectStyle(UMessagePatternArgType argType, int32_t index, int32_t nestingLevel,\n                                     UParseError *parseError, UErrorCode &errorCode);\n\n    /**\n     * Validates and parses an argument name or argument number string.\n     * This internal method assumes that the input substring is a \"pattern identifier\".\n     * @return &gt;=0 if the name is a valid number,\n     *         ARG_NAME_NOT_NUMBER (-1) if it is a \"pattern identifier\" but not all ASCII digits,\n     *         ARG_NAME_NOT_VALID (-2) if it is neither.\n     * @see #validateArgumentName(String)\n     */\n    static int32_t parseArgNumber(const UnicodeString &s, int32_t start, int32_t limit);\n\n    int32_t parseArgNumber(int32_t start, int32_t limit) {\n        return parseArgNumber(msg, start, limit);\n    }\n\n    /**\n     * Parses a number from the specified message substring.\n     * @param start start index into the message string\n     * @param limit limit index into the message string, must be start<limit\n     * @param allowInfinity TRUE if U+221E is allowed (for ChoiceFormat)\n     * @param parseError\n     * @param errorCode\n     */\n    void parseDouble(int32_t start, int32_t limit, UBool allowInfinity,\n                     UParseError *parseError, UErrorCode &errorCode);\n\n    // Java has package-private appendReducedApostrophes() here.\n    // In C++, this is declared in the MessageImpl class.\n\n    int32_t skipWhiteSpace(int32_t index);\n\n    int32_t skipIdentifier(int32_t index);\n\n    /**\n     * Skips a sequence of characters that could occur in a double value.\n     * Does not fully parse or validate the value.\n     */\n    int32_t skipDouble(int32_t index);\n\n    static UBool isArgTypeChar(UChar32 c);\n\n    UBool isChoice(int32_t index);\n\n    UBool isPlural(int32_t index);\n\n    UBool isSelect(int32_t index);\n\n    UBool isOrdinal(int32_t index);\n\n    /**\n     * @return TRUE if we are inside a MessageFormat (sub-)pattern,\n     *         as opposed to inside a top-level choice/plural/select pattern.\n     */\n    UBool inMessageFormatPattern(int32_t nestingLevel);\n\n    /**\n     * @return TRUE if we are in a MessageFormat sub-pattern\n     *         of a top-level ChoiceFormat pattern.\n     */\n    UBool inTopLevelChoiceMessage(int32_t nestingLevel, UMessagePatternArgType parentType);\n\n    void addPart(UMessagePatternPartType type, int32_t index, int32_t length,\n                 int32_t value, UErrorCode &errorCode);\n\n    void addLimitPart(int32_t start,\n                      UMessagePatternPartType type, int32_t index, int32_t length,\n                      int32_t value, UErrorCode &errorCode);\n\n    void addArgDoublePart(double numericValue, int32_t start, int32_t length, UErrorCode &errorCode);\n\n    void setParseError(UParseError *parseError, int32_t index);\n\n    // No ICU \"poor man's RTTI\" for this class nor its subclasses.\n    virtual UClassID getDynamicClassID() const;\n\n    UBool init(UErrorCode &errorCode);\n    UBool copyStorage(const MessagePattern &other, UErrorCode &errorCode);\n\n    UMessagePatternApostropheMode aposMode;\n    UnicodeString msg;\n    // ArrayList<Part> parts=new ArrayList<Part>();\n    MessagePatternPartsList *partsList;\n    Part *parts;\n    int32_t partsLength;\n    // ArrayList<Double> numericValues;\n    MessagePatternDoubleList *numericValuesList;\n    double *numericValues;\n    int32_t numericValuesLength;\n    UBool hasArgNames;\n    UBool hasArgNumbers;\n    UBool needsAutoQuoting;\n};\n\nU_NAMESPACE_END\n\n#endif  // !UCONFIG_NO_FORMATTING\n\n#endif  // __MESSAGEPATTERN_H__\n"
  },
  {
    "path": "deprecated/android/addons/icucompat/unicode/msgfmt.h",
    "content": "/*\n* Copyright (C) 2007-2012, International Business Machines Corporation and\n* others. All Rights Reserved.\n********************************************************************************\n*\n* File MSGFMT.H\n*\n* Modification History:\n*\n*   Date        Name        Description\n*   02/19/97    aliu        Converted from java.\n*   03/20/97    helena      Finished first cut of implementation.\n*   07/22/98    stephen     Removed operator!= (defined in Format)\n*   08/19/2002  srl         Removing Javaisms\n*******************************************************************************/\n\n#ifndef MSGFMT_H\n#define MSGFMT_H\n\n#include \"unicode/utypes.h\"\n\n/**\n * \\file\n * \\brief C++ API: Formats messages in a language-neutral way.\n */\n\n#if !UCONFIG_NO_FORMATTING\n\n#include \"unicode/format.h\"\n#include \"unicode/locid.h\"\n#include \"unicode/messagepattern.h\"\n#include \"unicode/parseerr.h\"\n#include \"unicode/plurfmt.h\"\n#include \"unicode/plurrule.h\"\n\nU_CDECL_BEGIN\n// Forward declaration.\nstruct UHashtable;\ntypedef struct UHashtable UHashtable;\nU_CDECL_END\n\nU_NAMESPACE_BEGIN\n\nclass AppendableWrapper;\nclass DateFormat;\nclass NumberFormat;\n\n/**\n * <p>MessageFormat prepares strings for display to users,\n * with optional arguments (variables/placeholders).\n * The arguments can occur in any order, which is necessary for translation\n * into languages with different grammars.\n *\n * <p>A MessageFormat is constructed from a <em>pattern</em> string\n * with arguments in {curly braces} which will be replaced by formatted values.\n *\n * <p><code>MessageFormat</code> differs from the other <code>Format</code>\n * classes in that you create a <code>MessageFormat</code> object with one\n * of its constructors (not with a <code>createInstance</code> style factory\n * method). Factory methods aren't necessary because <code>MessageFormat</code>\n * itself doesn't implement locale-specific behavior. Any locale-specific\n * behavior is defined by the pattern that you provide and the\n * subformats used for inserted arguments.\n *\n * <p>Arguments can be named (using identifiers) or numbered (using small ASCII-digit integers).\n * Some of the API methods work only with argument numbers and throw an exception\n * if the pattern has named arguments (see {@link #usesNamedArguments()}).\n *\n * <p>An argument might not specify any format type. In this case,\n * a Number value is formatted with a default (for the locale) NumberFormat,\n * a Date value is formatted with a default (for the locale) DateFormat,\n * and for any other value its toString() value is used.\n *\n * <p>An argument might specify a \"simple\" type for which the specified\n * Format object is created, cached and used.\n *\n * <p>An argument might have a \"complex\" type with nested MessageFormat sub-patterns.\n * During formatting, one of these sub-messages is selected according to the argument value\n * and recursively formatted.\n *\n * <p>After construction, a custom Format object can be set for\n * a top-level argument, overriding the default formatting and parsing behavior\n * for that argument.\n * However, custom formatting can be achieved more simply by writing\n * a typeless argument in the pattern string\n * and supplying it with a preformatted string value.\n *\n * <p>When formatting, MessageFormat takes a collection of argument values\n * and writes an output string.\n * The argument values may be passed as an array\n * (when the pattern contains only numbered arguments)\n * or as an array of names and and an array of arguments (which works for both named\n * and numbered arguments).\n *\n * <p>Each argument is matched with one of the input values by array index or argument name\n * and formatted according to its pattern specification\n * (or using a custom Format object if one was set).\n * A numbered pattern argument is matched with an argument name that contains that number\n * as an ASCII-decimal-digit string (without leading zero).\n *\n * <h4><a name=\"patterns\">Patterns and Their Interpretation</a></h4>\n *\n * <code>MessageFormat</code> uses patterns of the following form:\n * <pre>\n * message = messageText (argument messageText)*\n * argument = noneArg | simpleArg | complexArg\n * complexArg = choiceArg | pluralArg | selectArg | selectordinalArg\n *\n * noneArg = '{' argNameOrNumber '}'\n * simpleArg = '{' argNameOrNumber ',' argType [',' argStyle] '}'\n * choiceArg = '{' argNameOrNumber ',' \"choice\" ',' choiceStyle '}'\n * pluralArg = '{' argNameOrNumber ',' \"plural\" ',' pluralStyle '}'\n * selectArg = '{' argNameOrNumber ',' \"select\" ',' selectStyle '}'\n * selectordinalArg = '{' argNameOrNumber ',' \"selectordinal\" ',' pluralStyle '}'\n *\n * choiceStyle: see {@link ChoiceFormat}\n * pluralStyle: see {@link PluralFormat}\n * selectStyle: see {@link SelectFormat}\n *\n * argNameOrNumber = argName | argNumber\n * argName = [^[[:Pattern_Syntax:][:Pattern_White_Space:]]]+\n * argNumber = '0' | ('1'..'9' ('0'..'9')*)\n *\n * argType = \"number\" | \"date\" | \"time\" | \"spellout\" | \"ordinal\" | \"duration\"\n * argStyle = \"short\" | \"medium\" | \"long\" | \"full\" | \"integer\" | \"currency\" | \"percent\" | argStyleText\n * </pre>\n *\n * <ul>\n *   <li>messageText can contain quoted literal strings including syntax characters.\n *       A quoted literal string begins with an ASCII apostrophe and a syntax character\n *       (usually a {curly brace}) and continues until the next single apostrophe.\n *       A double ASCII apostrohpe inside or outside of a quoted string represents\n *       one literal apostrophe.\n *   <li>Quotable syntax characters are the {curly braces} in all messageText parts,\n *       plus the '#' sign in a messageText immediately inside a pluralStyle,\n *       and the '|' symbol in a messageText immediately inside a choiceStyle.\n *   <li>See also {@link #UMessagePatternApostropheMode}\n *   <li>In argStyleText, every single ASCII apostrophe begins and ends quoted literal text,\n *       and unquoted {curly braces} must occur in matched pairs.\n * </ul>\n *\n * <p>Recommendation: Use the real apostrophe (single quote) character\n * \\htmlonly&#x2019;\\endhtmlonly (U+2019) for\n * human-readable text, and use the ASCII apostrophe ' (U+0027)\n * only in program syntax, like quoting in MessageFormat.\n * See the annotations for U+0027 Apostrophe in The Unicode Standard.\n *\n * <p>The <code>choice</code> argument type is deprecated.\n * Use <code>plural</code> arguments for proper plural selection,\n * and <code>select</code> arguments for simple selection among a fixed set of choices.\n *\n * <p>The <code>argType</code> and <code>argStyle</code> values are used to create\n * a <code>Format</code> instance for the format element. The following\n * table shows how the values map to Format instances. Combinations not\n * shown in the table are illegal. Any <code>argStyleText</code> must\n * be a valid pattern string for the Format subclass used.\n *\n * <p><table border=1>\n *    <tr>\n *       <th>argType\n *       <th>argStyle\n *       <th>resulting Format object\n *    <tr>\n *       <td colspan=2><i>(none)</i>\n *       <td><code>null</code>\n *    <tr>\n *       <td rowspan=5><code>number</code>\n *       <td><i>(none)</i>\n *       <td><code>NumberFormat.createInstance(getLocale(), status)</code>\n *    <tr>\n *       <td><code>integer</code>\n *       <td><code>NumberFormat.createInstance(getLocale(), kNumberStyle, status)</code>\n *    <tr>\n *       <td><code>currency</code>\n *       <td><code>NumberFormat.createCurrencyInstance(getLocale(), status)</code>\n *    <tr>\n *       <td><code>percent</code>\n *       <td><code>NumberFormat.createPercentInstance(getLocale(), status)</code>\n *    <tr>\n *       <td><i>argStyleText</i>\n *       <td><code>new DecimalFormat(argStyleText, new DecimalFormatSymbols(getLocale(), status), status)</code>\n *    <tr>\n *       <td rowspan=6><code>date</code>\n *       <td><i>(none)</i>\n *       <td><code>DateFormat.createDateInstance(kDefault, getLocale(), status)</code>\n *    <tr>\n *       <td><code>short</code>\n *       <td><code>DateFormat.createDateInstance(kShort, getLocale(), status)</code>\n *    <tr>\n *       <td><code>medium</code>\n *       <td><code>DateFormat.createDateInstance(kDefault, getLocale(), status)</code>\n *    <tr>\n *       <td><code>long</code>\n *       <td><code>DateFormat.createDateInstance(kLong, getLocale(), status)</code>\n *    <tr>\n *       <td><code>full</code>\n *       <td><code>DateFormat.createDateInstance(kFull, getLocale(), status)</code>\n *    <tr>\n *       <td><i>argStyleText</i>\n *       <td><code>new SimpleDateFormat(argStyleText, getLocale(), status)\n *    <tr>\n *       <td rowspan=6><code>time</code>\n *       <td><i>(none)</i>\n *       <td><code>DateFormat.createTimeInstance(kDefault, getLocale(), status)</code>\n *    <tr>\n *       <td><code>short</code>\n *       <td><code>DateFormat.createTimeInstance(kShort, getLocale(), status)</code>\n *    <tr>\n *       <td><code>medium</code>\n *       <td><code>DateFormat.createTimeInstance(kDefault, getLocale(), status)</code>\n *    <tr>\n *       <td><code>long</code>\n *       <td><code>DateFormat.createTimeInstance(kLong, getLocale(), status)</code>\n *    <tr>\n *       <td><code>full</code>\n *       <td><code>DateFormat.createTimeInstance(kFull, getLocale(), status)</code>\n *    <tr>\n *       <td><i>argStyleText</i>\n *       <td><code>new SimpleDateFormat(argStyleText, getLocale(), status)\n *    <tr>\n *       <td><code>spellout</code>\n *       <td><i>argStyleText (optional)</i>\n *       <td><code>new RuleBasedNumberFormat(URBNF_SPELLOUT, getLocale(), status)\n *           <br/>&nbsp;&nbsp;&nbsp;&nbsp;.setDefaultRuleset(argStyleText, status);</code>\n *    <tr>\n *       <td><code>ordinal</code>\n *       <td><i>argStyleText (optional)</i>\n *       <td><code>new RuleBasedNumberFormat(URBNF_ORDINAL, getLocale(), status)\n *           <br/>&nbsp;&nbsp;&nbsp;&nbsp;.setDefaultRuleset(argStyleText, status);</code>\n *    <tr>\n *       <td><code>duration</code>\n *       <td><i>argStyleText (optional)</i>\n *       <td><code>new RuleBasedNumberFormat(URBNF_DURATION, getLocale(), status)\n *           <br/>&nbsp;&nbsp;&nbsp;&nbsp;.setDefaultRuleset(argStyleText, status);</code>\n * </table>\n * <p>\n *\n * <h4>Usage Information</h4>\n *\n * <p>Here are some examples of usage:\n * Example 1:\n *\n * <pre>\n * \\code\n *     UErrorCode success = U_ZERO_ERROR;\n *     GregorianCalendar cal(success);\n *     Formattable arguments[] = {\n *         7L,\n *         Formattable( (Date) cal.getTime(success), Formattable::kIsDate),\n *         \"a disturbance in the Force\"\n *     };\n *\n *     UnicodeString result;\n *     MessageFormat::format(\n *          \"At {1,time} on {1,date}, there was {2} on planet {0,number}.\",\n *          arguments, 3, result, success );\n *\n *     cout << \"result: \" << result << endl;\n *     //<output>: At 4:34:20 PM on 23-Mar-98, there was a disturbance\n *     //             in the Force on planet 7.\n * \\endcode\n * </pre>\n *\n * Typically, the message format will come from resources, and the\n * arguments will be dynamically set at runtime.\n *\n * <p>Example 2:\n *\n * <pre>\n *  \\code\n *     success = U_ZERO_ERROR;\n *     Formattable testArgs[] = {3L, \"MyDisk\"};\n *\n *     MessageFormat form(\n *         \"The disk \\\"{1}\\\" contains {0} file(s).\", success );\n *\n *     UnicodeString string;\n *     FieldPosition fpos = 0;\n *     cout << \"format: \" << form.format(testArgs, 2, string, fpos, success ) << endl;\n *\n *     // output, with different testArgs:\n *     // output: The disk \"MyDisk\" contains 0 file(s).\n *     // output: The disk \"MyDisk\" contains 1 file(s).\n *     // output: The disk \"MyDisk\" contains 1,273 file(s).\n *  \\endcode\n *  </pre>\n *\n *\n * <p>For messages that include plural forms, you can use a plural argument:\n * <pre>\n * \\code\n *  success = U_ZERO_ERROR;\n *  MessageFormat msgFmt(\n *       \"{num_files, plural, \"\n *       \"=0{There are no files on disk \\\"{disk_name}\\\".}\"\n *       \"=1{There is one file on disk \\\"{disk_name}\\\".}\"\n *       \"other{There are # files on disk \\\"{disk_name}\\\".}}\",\n *      Locale(\"en\"),\n *      success);\n *  FieldPosition fpos = 0;\n *  Formattable testArgs[] = {0L, \"MyDisk\"};\n *  UnicodeString testArgsNames[] = {\"num_files\", \"disk_name\"};\n *  UnicodeString result;\n *  cout << msgFmt.format(testArgs, testArgsNames, 2, result, fpos, 0, success);\n *  testArgs[0] = 3L;\n *  cout << msgFmt.format(testArgs, testArgsNames, 2, result, fpos, 0, success);\n * \\endcode\n * <em>output</em>:\n * There are no files on disk \"MyDisk\".\n * There are 3 files on \"MyDisk\".\n * </pre>\n * See {@link PluralFormat} and {@link PluralRules} for details.\n *\n * <h4><a name=\"synchronization\">Synchronization</a></h4>\n *\n * <p>MessageFormats are not synchronized.\n * It is recommended to create separate format instances for each thread.\n * If multiple threads access a format concurrently, it must be synchronized\n * externally.\n *\n * @stable ICU 2.0\n */\nclass U_I18N_API MessageFormat : public Format {\npublic:\n#ifndef U_HIDE_OBSOLETE_API\n    /**\n     * Enum type for kMaxFormat.\n     * @obsolete ICU 3.0.  The 10-argument limit was removed as of ICU 2.6,\n     * rendering this enum type obsolete.\n     */\n    enum EFormatNumber {\n        /**\n         * The maximum number of arguments.\n         * @obsolete ICU 3.0.  The 10-argument limit was removed as of ICU 2.6,\n         * rendering this constant obsolete.\n         */\n        kMaxFormat = 10\n    };\n#endif  /* U_HIDE_OBSOLETE_API */\n\n    /**\n     * Constructs a new MessageFormat using the given pattern and the\n     * default locale.\n     *\n     * @param pattern   Pattern used to construct object.\n     * @param status    Input/output error code.  If the\n     *                  pattern cannot be parsed, set to failure code.\n     * @stable ICU 2.0\n     */\n    MessageFormat(const UnicodeString& pattern,\n                  UErrorCode &status);\n\n    /**\n     * Constructs a new MessageFormat using the given pattern and locale.\n     * @param pattern   Pattern used to construct object.\n     * @param newLocale The locale to use for formatting dates and numbers.\n     * @param status    Input/output error code.  If the\n     *                  pattern cannot be parsed, set to failure code.\n     * @stable ICU 2.0\n     */\n    MessageFormat(const UnicodeString& pattern,\n                  const Locale& newLocale,\n                        UErrorCode& status);\n    /**\n     * Constructs a new MessageFormat using the given pattern and locale.\n     * @param pattern   Pattern used to construct object.\n     * @param newLocale The locale to use for formatting dates and numbers.\n     * @param parseError Struct to receive information on the position\n     *                   of an error within the pattern.\n     * @param status    Input/output error code.  If the\n     *                  pattern cannot be parsed, set to failure code.\n     * @stable ICU 2.0\n     */\n    MessageFormat(const UnicodeString& pattern,\n                  const Locale& newLocale,\n                  UParseError& parseError,\n                  UErrorCode& status);\n    /**\n     * Constructs a new MessageFormat from an existing one.\n     * @stable ICU 2.0\n     */\n    MessageFormat(const MessageFormat&);\n\n    /**\n     * Assignment operator.\n     * @stable ICU 2.0\n     */\n    const MessageFormat& operator=(const MessageFormat&);\n\n    /**\n     * Destructor.\n     * @stable ICU 2.0\n     */\n    virtual ~MessageFormat();\n\n    /**\n     * Clones this Format object polymorphically.  The caller owns the\n     * result and should delete it when done.\n     * @stable ICU 2.0\n     */\n    virtual Format* clone(void) const;\n\n    /**\n     * Returns true if the given Format objects are semantically equal.\n     * Objects of different subclasses are considered unequal.\n     * @param other  the object to be compared with.\n     * @return       true if the given Format objects are semantically equal.\n     * @stable ICU 2.0\n     */\n    virtual UBool operator==(const Format& other) const;\n\n    /**\n     * Sets the locale to be used for creating argument Format objects.\n     * @param theLocale    the new locale value to be set.\n     * @stable ICU 2.0\n     */\n    virtual void setLocale(const Locale& theLocale);\n\n    /**\n     * Gets the locale used for creating argument Format objects.\n     * format information.\n     * @return    the locale of the object.\n     * @stable ICU 2.0\n     */\n    virtual const Locale& getLocale(void) const;\n\n    /**\n     * Applies the given pattern string to this message format.\n     *\n     * @param pattern   The pattern to be applied.\n     * @param status    Input/output error code.  If the\n     *                  pattern cannot be parsed, set to failure code.\n     * @stable ICU 2.0\n     */\n    virtual void applyPattern(const UnicodeString& pattern,\n                              UErrorCode& status);\n    /**\n     * Applies the given pattern string to this message format.\n     *\n     * @param pattern    The pattern to be applied.\n     * @param parseError Struct to receive information on the position\n     *                   of an error within the pattern.\n     * @param status    Input/output error code.  If the\n     *                  pattern cannot be parsed, set to failure code.\n     * @stable ICU 2.0\n     */\n    virtual void applyPattern(const UnicodeString& pattern,\n                             UParseError& parseError,\n                             UErrorCode& status);\n\n    /**\n     * Sets the UMessagePatternApostropheMode and the pattern used by this message format.\n     * Parses the pattern and caches Format objects for simple argument types.\n     * Patterns and their interpretation are specified in the\n     * <a href=\"#patterns\">class description</a>.\n     * <p>\n     * This method is best used only once on a given object to avoid confusion about the mode,\n     * and after constructing the object with an empty pattern string to minimize overhead.\n     *\n     * @param pattern    The pattern to be applied.\n     * @param aposMode   The new apostrophe mode.\n     * @param parseError Struct to receive information on the position\n     *                   of an error within the pattern.\n     *                   Can be NULL.\n     * @param status    Input/output error code.  If the\n     *                  pattern cannot be parsed, set to failure code.\n     * @stable ICU 4.8\n     */\n    virtual void applyPattern(const UnicodeString& pattern,\n                              UMessagePatternApostropheMode aposMode,\n                              UParseError* parseError,\n                              UErrorCode& status);\n\n    /**\n     * @return this instance's UMessagePatternApostropheMode.\n     * @stable ICU 4.8\n     */\n    UMessagePatternApostropheMode getApostropheMode() const {\n        return msgPattern.getApostropheMode();\n    }\n\n    /**\n     * Returns a pattern that can be used to recreate this object.\n     *\n     * @param appendTo  Output parameter to receive the pattern.\n     *                  Result is appended to existing contents.\n     * @return          Reference to 'appendTo' parameter.\n     * @stable ICU 2.0\n     */\n    virtual UnicodeString& toPattern(UnicodeString& appendTo) const;\n\n    /**\n     * Sets subformats.\n     * See the class description about format numbering.\n     * The caller should not delete the Format objects after this call.\n     * <EM>The array formatsToAdopt is not itself adopted.</EM> Its\n     * ownership is retained by the caller. If the call fails because\n     * memory cannot be allocated, then the formats will be deleted\n     * by this method, and this object will remain unchanged.\n     *\n     * <p>If this format uses named arguments, the new formats are discarded\n     * and this format remains unchanged.\n     *\n     * @stable ICU 2.0\n     * @param formatsToAdopt    the format to be adopted.\n     * @param count             the size of the array.\n     */\n    virtual void adoptFormats(Format** formatsToAdopt, int32_t count);\n\n    /**\n     * Sets subformats.\n     * See the class description about format numbering.\n     * Each item in the array is cloned into the internal array.\n     * If the call fails because memory cannot be allocated, then this\n     * object will remain unchanged.\n     *\n     * <p>If this format uses named arguments, the new formats are discarded\n     * and this format remains unchanged.\n     *\n     * @stable ICU 2.0\n     * @param newFormats the new format to be set.\n     * @param cnt        the size of the array.\n     */\n    virtual void setFormats(const Format** newFormats, int32_t cnt);\n\n\n    /**\n     * Sets one subformat.\n     * See the class description about format numbering.\n     * The caller should not delete the Format object after this call.\n     * If the number is over the number of formats already set,\n     * the item will be deleted and ignored.\n     *\n     * <p>If this format uses named arguments, the new format is discarded\n     * and this format remains unchanged.\n     *\n     * @stable ICU 2.0\n     * @param formatNumber     index of the subformat.\n     * @param formatToAdopt    the format to be adopted.\n     */\n    virtual void adoptFormat(int32_t formatNumber, Format* formatToAdopt);\n\n    /**\n     * Sets one subformat.\n     * See the class description about format numbering.\n     * If the number is over the number of formats already set,\n     * the item will be ignored.\n     * @param formatNumber     index of the subformat.\n     * @param format    the format to be set.\n     * @stable ICU 2.0\n     */\n    virtual void setFormat(int32_t formatNumber, const Format& format);\n\n    /**\n     * Gets format names. This function returns formatNames in StringEnumerations\n     * which can be used with getFormat() and setFormat() to export formattable\n     * array from current MessageFormat to another.  It is the caller's responsibility\n     * to delete the returned formatNames.\n     * @param status  output param set to success/failure code.\n     * @stable ICU 4.0\n     */\n    virtual StringEnumeration* getFormatNames(UErrorCode& status);\n\n    /**\n     * Gets subformat pointer for given format name.\n     * This function supports both named and numbered\n     * arguments. If numbered, the formatName is the\n     * corresponding UnicodeStrings (e.g. \"0\", \"1\", \"2\"...).\n     * The returned Format object should not be deleted by the caller,\n     * nor should the ponter of other object .  The pointer and its\n     * contents remain valid only until the next call to any method\n     * of this class is made with this object.\n     * @param formatName the name or number specifying a format\n     * @param status  output param set to success/failure code.\n     * @stable ICU 4.0\n     */\n    virtual Format* getFormat(const UnicodeString& formatName, UErrorCode& status);\n\n    /**\n     * Sets one subformat for given format name.\n     * See the class description about format name.\n     * This function supports both named and numbered\n     * arguments-- if numbered, the formatName is the\n     * corresponding UnicodeStrings (e.g. \"0\", \"1\", \"2\"...).\n     * If there is no matched formatName or wrong type,\n     * the item will be ignored.\n     * @param formatName  Name of the subformat.\n     * @param format      the format to be set.\n     * @param status  output param set to success/failure code.\n     * @stable ICU 4.0\n     */\n    virtual void setFormat(const UnicodeString& formatName, const Format& format, UErrorCode& status);\n\n    /**\n     * Sets one subformat for given format name.\n     * See the class description about format name.\n     * This function supports both named and numbered\n     * arguments-- if numbered, the formatName is the\n     * corresponding UnicodeStrings (e.g. \"0\", \"1\", \"2\"...).\n     * If there is no matched formatName or wrong type,\n     * the item will be ignored.\n     * The caller should not delete the Format object after this call.\n     * @param formatName  Name of the subformat.\n     * @param formatToAdopt  Format to be adopted.\n     * @param status      output param set to success/failure code.\n     * @stable ICU 4.0\n     */\n    virtual void adoptFormat(const UnicodeString& formatName, Format* formatToAdopt, UErrorCode& status);\n\n    /**\n     * Gets an array of subformats of this object.  The returned array\n     * should not be deleted by the caller, nor should the pointers\n     * within the array.  The array and its contents remain valid only\n     * until the next call to this format. See the class description\n     * about format numbering.\n     *\n     * @param count output parameter to receive the size of the array\n     * @return an array of count Format* objects, or NULL if out of\n     * memory.  Any or all of the array elements may be NULL.\n     * @stable ICU 2.0\n     */\n    virtual const Format** getFormats(int32_t& count) const;\n\n\n    using Format::format;\n\n    /**\n     * Formats the given array of arguments into a user-readable string.\n     * Does not take ownership of the Formattable* array or its contents.\n     *\n     * <p>If this format uses named arguments, appendTo is unchanged and\n     * status is set to U_ILLEGAL_ARGUMENT_ERROR.\n     *\n     * @param source    An array of objects to be formatted.\n     * @param count     The number of elements of 'source'.\n     * @param appendTo  Output parameter to receive result.\n     *                  Result is appended to existing contents.\n     * @param ignore    Not used; inherited from base class API.\n     * @param status    Input/output error code.  If the\n     *                  pattern cannot be parsed, set to failure code.\n     * @return          Reference to 'appendTo' parameter.\n     * @stable ICU 2.0\n     */\n    UnicodeString& format(const Formattable* source,\n                          int32_t count,\n                          UnicodeString& appendTo,\n                          FieldPosition& ignore,\n                          UErrorCode& status) const;\n\n    /**\n     * Formats the given array of arguments into a user-readable string\n     * using the given pattern.\n     *\n     * <p>If this format uses named arguments, appendTo is unchanged and\n     * status is set to U_ILLEGAL_ARGUMENT_ERROR.\n     *\n     * @param pattern   The pattern.\n     * @param arguments An array of objects to be formatted.\n     * @param count     The number of elements of 'source'.\n     * @param appendTo  Output parameter to receive result.\n     *                  Result is appended to existing contents.\n     * @param status    Input/output error code.  If the\n     *                  pattern cannot be parsed, set to failure code.\n     * @return          Reference to 'appendTo' parameter.\n     * @stable ICU 2.0\n     */\n    static UnicodeString& format(const UnicodeString& pattern,\n                                 const Formattable* arguments,\n                                 int32_t count,\n                                 UnicodeString& appendTo,\n                                 UErrorCode& status);\n\n    /**\n     * Formats the given array of arguments into a user-readable\n     * string.  The array must be stored within a single Formattable\n     * object of type kArray. If the Formattable object type is not of\n     * type kArray, then returns a failing UErrorCode.\n     *\n     * <p>If this format uses named arguments, appendTo is unchanged and\n     * status is set to U_ILLEGAL_ARGUMENT_ERROR.\n     *\n     * @param obj       A Formattable of type kArray containing\n     *                  arguments to be formatted.\n     * @param appendTo  Output parameter to receive result.\n     *                  Result is appended to existing contents.\n     * @param pos       On input: an alignment field, if desired.\n     *                  On output: the offsets of the alignment field.\n     * @param status    Input/output error code.  If the\n     *                  pattern cannot be parsed, set to failure code.\n     * @return          Reference to 'appendTo' parameter.\n     * @stable ICU 2.0\n     */\n    virtual UnicodeString& format(const Formattable& obj,\n                                  UnicodeString& appendTo,\n                                  FieldPosition& pos,\n                                  UErrorCode& status) const;\n\n    /**\n     * Formats the given array of arguments into a user-readable\n     * string.  The array must be stored within a single Formattable\n     * object of type kArray. If the Formattable object type is not of\n     * type kArray, then returns a failing UErrorCode.\n     *\n     * @param obj       The object to format\n     * @param appendTo  Output parameter to receive result.\n     *                  Result is appended to existing contents.\n     * @param status    Input/output error code.  If the\n     *                  pattern cannot be parsed, set to failure code.\n     * @return          Reference to 'appendTo' parameter.\n     * @stable ICU 2.0\n     */\n    UnicodeString& format(const Formattable& obj,\n                          UnicodeString& appendTo,\n                          UErrorCode& status) const;\n\n\n    /**\n     * Formats the given array of arguments into a user-defined argument name\n     * array. This function supports both named and numbered\n     * arguments-- if numbered, the formatName is the\n     * corresponding UnicodeStrings (e.g. \"0\", \"1\", \"2\"...).\n     *\n     * @param argumentNames argument name array\n     * @param arguments An array of objects to be formatted.\n     * @param count     The number of elements of 'argumentNames' and\n     *                  arguments.  The number of argumentNames and arguments\n     *                  must be the same.\n     * @param appendTo  Output parameter to receive result.\n     *                  Result is appended to existing contents.\n     * @param status    Input/output error code.  If the\n     *                  pattern cannot be parsed, set to failure code.\n     * @return          Reference to 'appendTo' parameter.\n     * @stable ICU 4.0\n     */\n    UnicodeString& format(const UnicodeString* argumentNames,\n                          const Formattable* arguments,\n                          int32_t count,\n                          UnicodeString& appendTo,\n                          UErrorCode& status) const;\n    /**\n     * Parses the given string into an array of output arguments.\n     *\n     * @param source    String to be parsed.\n     * @param pos       On input, starting position for parse. On output,\n     *                  final position after parse.  Unchanged if parse\n     *                  fails.\n     * @param count     Output parameter to receive the number of arguments\n     *                  parsed.\n     * @return an array of parsed arguments.  The caller owns both\n     * the array and its contents.\n     * @stable ICU 2.0\n     */\n    virtual Formattable* parse(const UnicodeString& source,\n                               ParsePosition& pos,\n                               int32_t& count) const;\n\n    /**\n     * Parses the given string into an array of output arguments.\n     *\n     * <p>If this format uses named arguments, status is set to\n     * U_ARGUMENT_TYPE_MISMATCH.\n     *\n     * @param source    String to be parsed.\n     * @param count     Output param to receive size of returned array.\n     * @param status    Input/output error code.  If the\n     *                  pattern cannot be parsed, set to failure code.\n     * @return an array of parsed arguments.  The caller owns both\n     * the array and its contents. Returns NULL if status is not U_ZERO_ERROR.\n     *\n     * @stable ICU 2.0\n     */\n    virtual Formattable* parse(const UnicodeString& source,\n                               int32_t& count,\n                               UErrorCode& status) const;\n\n    /**\n     * Parses the given string into an array of output arguments\n     * stored within a single Formattable of type kArray.\n     *\n     * @param source    The string to be parsed into an object.\n     * @param result    Formattable to be set to the parse result.\n     *                  If parse fails, return contents are undefined.\n     * @param pos       On input, starting position for parse. On output,\n     *                  final position after parse.  Unchanged if parse\n     *                  fails.\n     * @stable ICU 2.0\n     */\n    virtual void parseObject(const UnicodeString& source,\n                             Formattable& result,\n                             ParsePosition& pos) const;\n\n    /**\n     * Convert an 'apostrophe-friendly' pattern into a standard\n     * pattern.  Standard patterns treat all apostrophes as\n     * quotes, which is problematic in some languages, e.g.\n     * French, where apostrophe is commonly used.  This utility\n     * assumes that only an unpaired apostrophe immediately before\n     * a brace is a true quote.  Other unpaired apostrophes are paired,\n     * and the resulting standard pattern string is returned.\n     *\n     * <p><b>Note</b> it is not guaranteed that the returned pattern\n     * is indeed a valid pattern.  The only effect is to convert\n     * between patterns having different quoting semantics.\n     *\n     * @param pattern the 'apostrophe-friendly' patttern to convert\n     * @param status    Input/output error code.  If the pattern\n     *                  cannot be parsed, the failure code is set.\n     * @return the standard equivalent of the original pattern\n     * @stable ICU 3.4\n     */\n    static UnicodeString autoQuoteApostrophe(const UnicodeString& pattern,\n        UErrorCode& status);\n\n\n    /**\n     * Returns true if this MessageFormat uses named arguments,\n     * and false otherwise.  See class description.\n     *\n     * @return true if named arguments are used.\n     * @stable ICU 4.0\n     */\n    UBool usesNamedArguments() const;\n\n\n#ifndef U_HIDE_INTERNAL_API\n    /**\n     * This API is for ICU internal use only.\n     * Please do not use it.\n     *\n     * Returns argument types count in the parsed pattern.\n     * Used to distinguish pattern \"{0} d\" and \"d\".\n     *\n     * @return           The number of formattable types in the pattern\n     * @internal\n     */\n    int32_t getArgTypeCount() const;\n#endif  /* U_HIDE_INTERNAL_API */\n\n    /**\n     * Returns a unique class ID POLYMORPHICALLY.  Pure virtual override.\n     * This method is to implement a simple version of RTTI, since not all\n     * C++ compilers support genuine RTTI.  Polymorphic operator==() and\n     * clone() methods call this method.\n     *\n     * @return          The class ID for this object. All objects of a\n     *                  given class have the same class ID.  Objects of\n     *                  other classes have different class IDs.\n     * @stable ICU 2.0\n     */\n    virtual UClassID getDynamicClassID(void) const;\n\n    /**\n     * Return the class ID for this class.  This is useful only for\n     * comparing to a return value from getDynamicClassID().  For example:\n     * <pre>\n     * .   Base* polymorphic_pointer = createPolymorphicObject();\n     * .   if (polymorphic_pointer->getDynamicClassID() ==\n     * .      Derived::getStaticClassID()) ...\n     * </pre>\n     * @return          The class ID for all objects of this class.\n     * @stable ICU 2.0\n     */\n    static UClassID U_EXPORT2 getStaticClassID(void);\n\n#ifndef U_HIDE_INTERNAL_API\n    /**\n     * Compares two Format objects. This is used for constructing the hash\n     * tables.\n     *\n     * @param left pointer to a Format object. Must not be NULL.\n     * @param right pointer to a Format object. Must not be NULL.\n     *\n     * @return whether the two objects are the same\n     * @internal\n     */\n    static UBool equalFormats(const void* left, const void* right);\n#endif  /* U_HIDE_INTERNAL_API */\n\nprivate:\n\n    Locale              fLocale;\n    MessagePattern      msgPattern;\n    Format**            formatAliases; // see getFormats\n    int32_t             formatAliasesCapacity;\n\n    MessageFormat(); // default constructor not implemented\n\n     /**\n      * This provider helps defer instantiation of a PluralRules object\n      * until we actually need to select a keyword.\n      * For example, if the number matches an explicit-value selector like \"=1\"\n      * we do not need any PluralRules.\n      */\n    class U_I18N_API PluralSelectorProvider : public PluralFormat::PluralSelector {\n    public:\n        PluralSelectorProvider(const Locale* loc, UPluralType type);\n        virtual ~PluralSelectorProvider();\n        virtual UnicodeString select(double number, UErrorCode& ec) const;\n\n        void reset(const Locale* loc);\n    private:\n        const Locale* locale;\n        PluralRules* rules;\n        UPluralType type;\n    };\n\n    /**\n     * A MessageFormat formats an array of arguments.  Each argument\n     * has an expected type, based on the pattern.  For example, if\n     * the pattern contains the subformat \"{3,number,integer}\", then\n     * we expect argument 3 to have type Formattable::kLong.  This\n     * array needs to grow dynamically if the MessageFormat is\n     * modified.\n     */\n    Formattable::Type* argTypes;\n    int32_t            argTypeCount;\n    int32_t            argTypeCapacity;\n\n    /**\n     * TRUE if there are different argTypes for the same argument.\n     * This only matters when the MessageFormat is used in the plain C (umsg_xxx) API\n     * where the pattern argTypes determine how the va_arg list is read.\n     */\n    UBool hasArgTypeConflicts;\n\n    // Variable-size array management\n    UBool allocateArgTypes(int32_t capacity, UErrorCode& status);\n\n    /**\n     * Default Format objects used when no format is specified and a\n     * numeric or date argument is formatted.  These are volatile\n     * cache objects maintained only for performance.  They do not\n     * participate in operator=(), copy constructor(), nor\n     * operator==().\n     */\n    NumberFormat* defaultNumberFormat;\n    DateFormat*   defaultDateFormat;\n\n    UHashtable* cachedFormatters;\n    UHashtable* customFormatArgStarts;\n\n    PluralSelectorProvider pluralProvider;\n    PluralSelectorProvider ordinalProvider;\n\n    /**\n     * Method to retrieve default formats (or NULL on failure).\n     * These are semantically const, but may modify *this.\n     */\n    const NumberFormat* getDefaultNumberFormat(UErrorCode&) const;\n    const DateFormat*   getDefaultDateFormat(UErrorCode&) const;\n\n    /**\n     * Finds the word s, in the keyword list and returns the located index.\n     * @param s the keyword to be searched for.\n     * @param list the list of keywords to be searched with.\n     * @return the index of the list which matches the keyword s.\n     */\n    static int32_t findKeyword( const UnicodeString& s,\n                                const UChar * const *list);\n\n    /**\n     * Thin wrapper around the format(... AppendableWrapper ...) variant.\n     * Wraps the destination UnicodeString into an AppendableWrapper and\n     * supplies default values for some other parameters.\n     */\n    UnicodeString& format(const Formattable* arguments,\n                          const UnicodeString *argumentNames,\n                          int32_t cnt,\n                          UnicodeString& appendTo,\n                          FieldPosition* pos,\n                          UErrorCode& status) const;\n\n    /**\n     * Formats the arguments and writes the result into the\n     * AppendableWrapper, updates the field position.\n     *\n     * @param msgStart      Index to msgPattern part to start formatting from.\n     * @param pluralNumber  Zero except when formatting a plural argument sub-message\n     *                      where a '#' is replaced by the format string for this number.\n     * @param arguments     The formattable objects array. (Must not be NULL.)\n     * @param argumentNames NULL if numbered values are used. Otherwise the same\n     *                      length as \"arguments\", and each entry is the name of the\n     *                      corresponding argument in \"arguments\".\n     * @param cnt           The length of arguments (and of argumentNames if that is not NULL).\n     * @param appendTo      Output parameter to receive the result.\n     *                      The result string is appended to existing contents.\n     * @param pos           Field position status.\n     * @param success       The error code status.\n     */\n    void format(int32_t msgStart,\n                double pluralNumber,\n                const Formattable* arguments,\n                const UnicodeString *argumentNames,\n                int32_t cnt,\n                AppendableWrapper& appendTo,\n                FieldPosition* pos,\n                UErrorCode& success) const;\n\n    UnicodeString getArgName(int32_t partIndex);\n\n    void setArgStartFormat(int32_t argStart, Format* formatter, UErrorCode& status);\n\n    void setCustomArgStartFormat(int32_t argStart, Format* formatter, UErrorCode& status);\n\n    int32_t nextTopLevelArgStart(int32_t partIndex) const;\n\n    UBool argNameMatches(int32_t partIndex, const UnicodeString& argName, int32_t argNumber);\n\n    void cacheExplicitFormats(UErrorCode& status);\n\n    Format* createAppropriateFormat(UnicodeString& type,\n                                    UnicodeString& style,\n                                    Formattable::Type& formattableType,\n                                    UParseError& parseError,\n                                    UErrorCode& ec);\n\n    const Formattable* getArgFromListByName(const Formattable* arguments,\n                                            const UnicodeString *argumentNames,\n                                            int32_t cnt, UnicodeString& name) const;\n\n    Formattable* parse(int32_t msgStart,\n                       const UnicodeString& source,\n                       ParsePosition& pos,\n                       int32_t& count,\n                       UErrorCode& ec) const;\n\n    FieldPosition* updateMetaData(AppendableWrapper& dest, int32_t prevLength,\n                                  FieldPosition* fp, const Formattable* argId) const;\n\n    Format* getCachedFormatter(int32_t argumentNumber) const;\n\n    UnicodeString getLiteralStringUntilNextArgument(int32_t from) const;\n\n    void copyObjects(const MessageFormat& that, UErrorCode& ec);\n\n    void formatComplexSubMessage(int32_t msgStart,\n                                 double pluralNumber,\n                                 const Formattable* arguments,\n                                 const UnicodeString *argumentNames,\n                                 int32_t cnt,\n                                 AppendableWrapper& appendTo,\n                                 UErrorCode& success) const;\n\n    /**\n     * Convenience method that ought to be in NumberFormat\n     */\n    NumberFormat* createIntegerFormat(const Locale& locale, UErrorCode& status) const;\n\n    /**\n     * Returns array of argument types in the parsed pattern\n     * for use in C API.  Only for the use of umsg_vformat().  Not\n     * for public consumption.\n     * @param listCount  Output parameter to receive the size of array\n     * @return           The array of formattable types in the pattern\n     * @internal\n     */\n    const Formattable::Type* getArgTypeList(int32_t& listCount) const {\n        listCount = argTypeCount;\n        return argTypes;\n    }\n\n    /**\n     * Resets the internal MessagePattern, and other associated caches.\n     */\n    void resetPattern();\n\n    /**\n     * A DummyFormatter that we use solely to store a NULL value. UHash does\n     * not support storing NULL values.\n     * @internal\n     */\n    class U_I18N_API DummyFormat : public Format {\n    public:\n        virtual UBool operator==(const Format&) const;\n        virtual Format* clone() const;\n        virtual UnicodeString& format(const Formattable& obj,\n                              UnicodeString& appendTo,\n                              UErrorCode& status) const;\n        virtual UnicodeString& format(const Formattable&,\n                                      UnicodeString& appendTo,\n                                      FieldPosition&,\n                                      UErrorCode& status) const;\n        virtual UnicodeString& format(const Formattable& obj,\n                                      UnicodeString& appendTo,\n                                      FieldPositionIterator* posIter,\n                                      UErrorCode& status) const;\n        virtual void parseObject(const UnicodeString&,\n                                 Formattable&,\n                                 ParsePosition&) const;\n        virtual UClassID getDynamicClassID() const;\n    };\n\n    friend class MessageFormatAdapter; // getFormatTypeList() access\n};\n\ninline UnicodeString&\nMessageFormat::format(const Formattable& obj,\n                      UnicodeString& appendTo,\n                      UErrorCode& status) const {\n    return Format::format(obj, appendTo, status);\n}\n\n\nU_NAMESPACE_END\n\n#endif /* #if !UCONFIG_NO_FORMATTING */\n\n#endif // _MSGFMT\n//eof\n"
  },
  {
    "path": "deprecated/android/addons/icucompat/unicode/normalizer2.h",
    "content": "/*\n*******************************************************************************\n*\n*   Copyright (C) 2009-2012, International Business Machines\n*   Corporation and others.  All Rights Reserved.\n*\n*******************************************************************************\n*   file name:  normalizer2.h\n*   encoding:   US-ASCII\n*   tab size:   8 (not used)\n*   indentation:4\n*\n*   created on: 2009nov22\n*   created by: Markus W. Scherer\n*/\n\n#ifndef __NORMALIZER2_H__\n#define __NORMALIZER2_H__\n\n/**\n * \\file\n * \\brief C++ API: New API for Unicode Normalization.\n */\n\n#include \"unicode/utypes.h\"\n\n#if !UCONFIG_NO_NORMALIZATION\n\n#include \"unicode/uniset.h\"\n#include \"unicode/unistr.h\"\n#include \"unicode/unorm2.h\"\n\nU_NAMESPACE_BEGIN\n\n/**\n * Unicode normalization functionality for standard Unicode normalization or\n * for using custom mapping tables.\n * All instances of this class are unmodifiable/immutable.\n * Instances returned by getInstance() are singletons that must not be deleted by the caller.\n * The Normalizer2 class is not intended for public subclassing.\n *\n * The primary functions are to produce a normalized string and to detect whether\n * a string is already normalized.\n * The most commonly used normalization forms are those defined in\n * http://www.unicode.org/unicode/reports/tr15/\n * However, this API supports additional normalization forms for specialized purposes.\n * For example, NFKC_Casefold is provided via getInstance(\"nfkc_cf\", COMPOSE)\n * and can be used in implementations of UTS #46.\n *\n * Not only are the standard compose and decompose modes supplied,\n * but additional modes are provided as documented in the Mode enum.\n *\n * Some of the functions in this class identify normalization boundaries.\n * At a normalization boundary, the portions of the string\n * before it and starting from it do not interact and can be handled independently.\n *\n * The spanQuickCheckYes() stops at a normalization boundary.\n * When the goal is a normalized string, then the text before the boundary\n * can be copied, and the remainder can be processed with normalizeSecondAndAppend().\n *\n * The hasBoundaryBefore(), hasBoundaryAfter() and isInert() functions test whether\n * a character is guaranteed to be at a normalization boundary,\n * regardless of context.\n * This is used for moving from one normalization boundary to the next\n * or preceding boundary, and for performing iterative normalization.\n *\n * Iterative normalization is useful when only a small portion of a\n * longer string needs to be processed.\n * For example, in ICU, iterative normalization is used by the NormalizationTransliterator\n * (to avoid replacing already-normalized text) and ucol_nextSortKeyPart()\n * (to process only the substring for which sort key bytes are computed).\n *\n * The set of normalization boundaries returned by these functions may not be\n * complete: There may be more boundaries that could be returned.\n * Different functions may return different boundaries.\n * @stable ICU 4.4\n */\nclass U_COMMON_API Normalizer2 : public UObject {\npublic:\n    /**\n     * Destructor.\n     * @stable ICU 4.4\n     */\n    ~Normalizer2();\n\n#ifndef U_HIDE_DRAFT_API\n    /**\n     * Returns a Normalizer2 instance for Unicode NFC normalization.\n     * Same as getInstance(NULL, \"nfc\", UNORM2_COMPOSE, errorCode).\n     * Returns an unmodifiable singleton instance. Do not delete it.\n     * @param errorCode Standard ICU error code. Its input value must\n     *                  pass the U_SUCCESS() test, or else the function returns\n     *                  immediately. Check for U_FAILURE() on output or use with\n     *                  function chaining. (See User Guide for details.)\n     * @return the requested Normalizer2, if successful\n     * @draft ICU 49\n     */\n    static const Normalizer2 *\n    getNFCInstance(UErrorCode &errorCode);\n\n    /**\n     * Returns a Normalizer2 instance for Unicode NFD normalization.\n     * Same as getInstance(NULL, \"nfc\", UNORM2_DECOMPOSE, errorCode).\n     * Returns an unmodifiable singleton instance. Do not delete it.\n     * @param errorCode Standard ICU error code. Its input value must\n     *                  pass the U_SUCCESS() test, or else the function returns\n     *                  immediately. Check for U_FAILURE() on output or use with\n     *                  function chaining. (See User Guide for details.)\n     * @return the requested Normalizer2, if successful\n     * @draft ICU 49\n     */\n    static const Normalizer2 *\n    getNFDInstance(UErrorCode &errorCode);\n\n    /**\n     * Returns a Normalizer2 instance for Unicode NFKC normalization.\n     * Same as getInstance(NULL, \"nfkc\", UNORM2_COMPOSE, errorCode).\n     * Returns an unmodifiable singleton instance. Do not delete it.\n     * @param errorCode Standard ICU error code. Its input value must\n     *                  pass the U_SUCCESS() test, or else the function returns\n     *                  immediately. Check for U_FAILURE() on output or use with\n     *                  function chaining. (See User Guide for details.)\n     * @return the requested Normalizer2, if successful\n     * @draft ICU 49\n     */\n    static const Normalizer2 *\n    getNFKCInstance(UErrorCode &errorCode);\n\n    /**\n     * Returns a Normalizer2 instance for Unicode NFKD normalization.\n     * Same as getInstance(NULL, \"nfkc\", UNORM2_DECOMPOSE, errorCode).\n     * Returns an unmodifiable singleton instance. Do not delete it.\n     * @param errorCode Standard ICU error code. Its input value must\n     *                  pass the U_SUCCESS() test, or else the function returns\n     *                  immediately. Check for U_FAILURE() on output or use with\n     *                  function chaining. (See User Guide for details.)\n     * @return the requested Normalizer2, if successful\n     * @draft ICU 49\n     */\n    static const Normalizer2 *\n    getNFKDInstance(UErrorCode &errorCode);\n\n    /**\n     * Returns a Normalizer2 instance for Unicode NFKC_Casefold normalization.\n     * Same as getInstance(NULL, \"nfkc_cf\", UNORM2_COMPOSE, errorCode).\n     * Returns an unmodifiable singleton instance. Do not delete it.\n     * @param errorCode Standard ICU error code. Its input value must\n     *                  pass the U_SUCCESS() test, or else the function returns\n     *                  immediately. Check for U_FAILURE() on output or use with\n     *                  function chaining. (See User Guide for details.)\n     * @return the requested Normalizer2, if successful\n     * @draft ICU 49\n     */\n    static const Normalizer2 *\n    getNFKCCasefoldInstance(UErrorCode &errorCode);\n#endif  /* U_HIDE_DRAFT_API */\n\n    /**\n     * Returns a Normalizer2 instance which uses the specified data file\n     * (packageName/name similar to ucnv_openPackage() and ures_open()/ResourceBundle)\n     * and which composes or decomposes text according to the specified mode.\n     * Returns an unmodifiable singleton instance. Do not delete it.\n     *\n     * Use packageName=NULL for data files that are part of ICU's own data.\n     * Use name=\"nfc\" and UNORM2_COMPOSE/UNORM2_DECOMPOSE for Unicode standard NFC/NFD.\n     * Use name=\"nfkc\" and UNORM2_COMPOSE/UNORM2_DECOMPOSE for Unicode standard NFKC/NFKD.\n     * Use name=\"nfkc_cf\" and UNORM2_COMPOSE for Unicode standard NFKC_CF=NFKC_Casefold.\n     *\n     * @param packageName NULL for ICU built-in data, otherwise application data package name\n     * @param name \"nfc\" or \"nfkc\" or \"nfkc_cf\" or name of custom data file\n     * @param mode normalization mode (compose or decompose etc.)\n     * @param errorCode Standard ICU error code. Its input value must\n     *                  pass the U_SUCCESS() test, or else the function returns\n     *                  immediately. Check for U_FAILURE() on output or use with\n     *                  function chaining. (See User Guide for details.)\n     * @return the requested Normalizer2, if successful\n     * @stable ICU 4.4\n     */\n    static const Normalizer2 *\n    getInstance(const char *packageName,\n                const char *name,\n                UNormalization2Mode mode,\n                UErrorCode &errorCode);\n\n    /**\n     * Returns the normalized form of the source string.\n     * @param src source string\n     * @param errorCode Standard ICU error code. Its input value must\n     *                  pass the U_SUCCESS() test, or else the function returns\n     *                  immediately. Check for U_FAILURE() on output or use with\n     *                  function chaining. (See User Guide for details.)\n     * @return normalized src\n     * @stable ICU 4.4\n     */\n    UnicodeString\n    normalize(const UnicodeString &src, UErrorCode &errorCode) const {\n        UnicodeString result;\n        normalize(src, result, errorCode);\n        return result;\n    }\n    /**\n     * Writes the normalized form of the source string to the destination string\n     * (replacing its contents) and returns the destination string.\n     * The source and destination strings must be different objects.\n     * @param src source string\n     * @param dest destination string; its contents is replaced with normalized src\n     * @param errorCode Standard ICU error code. Its input value must\n     *                  pass the U_SUCCESS() test, or else the function returns\n     *                  immediately. Check for U_FAILURE() on output or use with\n     *                  function chaining. (See User Guide for details.)\n     * @return dest\n     * @stable ICU 4.4\n     */\n    virtual UnicodeString &\n    normalize(const UnicodeString &src,\n              UnicodeString &dest,\n              UErrorCode &errorCode) const = 0;\n    /**\n     * Appends the normalized form of the second string to the first string\n     * (merging them at the boundary) and returns the first string.\n     * The result is normalized if the first string was normalized.\n     * The first and second strings must be different objects.\n     * @param first string, should be normalized\n     * @param second string, will be normalized\n     * @param errorCode Standard ICU error code. Its input value must\n     *                  pass the U_SUCCESS() test, or else the function returns\n     *                  immediately. Check for U_FAILURE() on output or use with\n     *                  function chaining. (See User Guide for details.)\n     * @return first\n     * @stable ICU 4.4\n     */\n    virtual UnicodeString &\n    normalizeSecondAndAppend(UnicodeString &first,\n                             const UnicodeString &second,\n                             UErrorCode &errorCode) const = 0;\n    /**\n     * Appends the second string to the first string\n     * (merging them at the boundary) and returns the first string.\n     * The result is normalized if both the strings were normalized.\n     * The first and second strings must be different objects.\n     * @param first string, should be normalized\n     * @param second string, should be normalized\n     * @param errorCode Standard ICU error code. Its input value must\n     *                  pass the U_SUCCESS() test, or else the function returns\n     *                  immediately. Check for U_FAILURE() on output or use with\n     *                  function chaining. (See User Guide for details.)\n     * @return first\n     * @stable ICU 4.4\n     */\n    virtual UnicodeString &\n    append(UnicodeString &first,\n           const UnicodeString &second,\n           UErrorCode &errorCode) const = 0;\n\n    /**\n     * Gets the decomposition mapping of c.\n     * Roughly equivalent to normalizing the String form of c\n     * on a UNORM2_DECOMPOSE Normalizer2 instance, but much faster, and except that this function\n     * returns FALSE and does not write a string\n     * if c does not have a decomposition mapping in this instance's data.\n     * This function is independent of the mode of the Normalizer2.\n     * @param c code point\n     * @param decomposition String object which will be set to c's\n     *                      decomposition mapping, if there is one.\n     * @return TRUE if c has a decomposition, otherwise FALSE\n     * @stable ICU 4.6\n     */\n    virtual UBool\n    getDecomposition(UChar32 c, UnicodeString &decomposition) const = 0;\n\n    /**\n     * Gets the raw decomposition mapping of c.\n     *\n     * This is similar to the getDecomposition() method but returns the\n     * raw decomposition mapping as specified in UnicodeData.txt or\n     * (for custom data) in the mapping files processed by the gennorm2 tool.\n     * By contrast, getDecomposition() returns the processed,\n     * recursively-decomposed version of this mapping.\n     *\n     * When used on a standard NFKC Normalizer2 instance,\n     * getRawDecomposition() returns the Unicode Decomposition_Mapping (dm) property.\n     *\n     * When used on a standard NFC Normalizer2 instance,\n     * it returns the Decomposition_Mapping only if the Decomposition_Type (dt) is Canonical (Can);\n     * in this case, the result contains either one or two code points (=1..4 UChars).\n     *\n     * This function is independent of the mode of the Normalizer2.\n     * The default implementation returns FALSE.\n     * @param c code point\n     * @param decomposition String object which will be set to c's\n     *                      raw decomposition mapping, if there is one.\n     * @return TRUE if c has a decomposition, otherwise FALSE\n     * @draft ICU 49\n     */\n    virtual UBool\n    getRawDecomposition(UChar32 c, UnicodeString &decomposition) const;\n\n    /**\n     * Performs pairwise composition of a & b and returns the composite if there is one.\n     *\n     * Returns a composite code point c only if c has a two-way mapping to a+b.\n     * In standard Unicode normalization, this means that\n     * c has a canonical decomposition to a+b\n     * and c does not have the Full_Composition_Exclusion property.\n     *\n     * This function is independent of the mode of the Normalizer2.\n     * The default implementation returns a negative value.\n     * @param a A (normalization starter) code point.\n     * @param b Another code point.\n     * @return The non-negative composite code point if there is one; otherwise a negative value.\n     * @draft ICU 49\n     */\n    virtual UChar32\n    composePair(UChar32 a, UChar32 b) const;\n\n    /**\n     * Gets the combining class of c.\n     * The default implementation returns 0\n     * but all standard implementations return the Unicode Canonical_Combining_Class value.\n     * @param c code point\n     * @return c's combining class\n     * @draft ICU 49\n     */\n    virtual uint8_t\n    getCombiningClass(UChar32 c) const;\n\n    /**\n     * Tests if the string is normalized.\n     * Internally, in cases where the quickCheck() method would return \"maybe\"\n     * (which is only possible for the two COMPOSE modes) this method\n     * resolves to \"yes\" or \"no\" to provide a definitive result,\n     * at the cost of doing more work in those cases.\n     * @param s input string\n     * @param errorCode Standard ICU error code. Its input value must\n     *                  pass the U_SUCCESS() test, or else the function returns\n     *                  immediately. Check for U_FAILURE() on output or use with\n     *                  function chaining. (See User Guide for details.)\n     * @return TRUE if s is normalized\n     * @stable ICU 4.4\n     */\n    virtual UBool\n    isNormalized(const UnicodeString &s, UErrorCode &errorCode) const = 0;\n\n    /**\n     * Tests if the string is normalized.\n     * For the two COMPOSE modes, the result could be \"maybe\" in cases that\n     * would take a little more work to resolve definitively.\n     * Use spanQuickCheckYes() and normalizeSecondAndAppend() for a faster\n     * combination of quick check + normalization, to avoid\n     * re-checking the \"yes\" prefix.\n     * @param s input string\n     * @param errorCode Standard ICU error code. Its input value must\n     *                  pass the U_SUCCESS() test, or else the function returns\n     *                  immediately. Check for U_FAILURE() on output or use with\n     *                  function chaining. (See User Guide for details.)\n     * @return UNormalizationCheckResult\n     * @stable ICU 4.4\n     */\n    virtual UNormalizationCheckResult\n    quickCheck(const UnicodeString &s, UErrorCode &errorCode) const = 0;\n\n    /**\n     * Returns the end of the normalized substring of the input string.\n     * In other words, with <code>end=spanQuickCheckYes(s, ec);</code>\n     * the substring <code>UnicodeString(s, 0, end)</code>\n     * will pass the quick check with a \"yes\" result.\n     *\n     * The returned end index is usually one or more characters before the\n     * \"no\" or \"maybe\" character: The end index is at a normalization boundary.\n     * (See the class documentation for more about normalization boundaries.)\n     *\n     * When the goal is a normalized string and most input strings are expected\n     * to be normalized already, then call this method,\n     * and if it returns a prefix shorter than the input string,\n     * copy that prefix and use normalizeSecondAndAppend() for the remainder.\n     * @param s input string\n     * @param errorCode Standard ICU error code. Its input value must\n     *                  pass the U_SUCCESS() test, or else the function returns\n     *                  immediately. Check for U_FAILURE() on output or use with\n     *                  function chaining. (See User Guide for details.)\n     * @return \"yes\" span end index\n     * @stable ICU 4.4\n     */\n    virtual int32_t\n    spanQuickCheckYes(const UnicodeString &s, UErrorCode &errorCode) const = 0;\n\n    /**\n     * Tests if the character always has a normalization boundary before it,\n     * regardless of context.\n     * If true, then the character does not normalization-interact with\n     * preceding characters.\n     * In other words, a string containing this character can be normalized\n     * by processing portions before this character and starting from this\n     * character independently.\n     * This is used for iterative normalization. See the class documentation for details.\n     * @param c character to test\n     * @return TRUE if c has a normalization boundary before it\n     * @stable ICU 4.4\n     */\n    virtual UBool hasBoundaryBefore(UChar32 c) const = 0;\n\n    /**\n     * Tests if the character always has a normalization boundary after it,\n     * regardless of context.\n     * If true, then the character does not normalization-interact with\n     * following characters.\n     * In other words, a string containing this character can be normalized\n     * by processing portions up to this character and after this\n     * character independently.\n     * This is used for iterative normalization. See the class documentation for details.\n     * Note that this operation may be significantly slower than hasBoundaryBefore().\n     * @param c character to test\n     * @return TRUE if c has a normalization boundary after it\n     * @stable ICU 4.4\n     */\n    virtual UBool hasBoundaryAfter(UChar32 c) const = 0;\n\n    /**\n     * Tests if the character is normalization-inert.\n     * If true, then the character does not change, nor normalization-interact with\n     * preceding or following characters.\n     * In other words, a string containing this character can be normalized\n     * by processing portions before this character and after this\n     * character independently.\n     * This is used for iterative normalization. See the class documentation for details.\n     * Note that this operation may be significantly slower than hasBoundaryBefore().\n     * @param c character to test\n     * @return TRUE if c is normalization-inert\n     * @stable ICU 4.4\n     */\n    virtual UBool isInert(UChar32 c) const = 0;\n\nprivate:\n    // No ICU \"poor man's RTTI\" for this class nor its subclasses.\n    virtual UClassID getDynamicClassID() const;\n};\n\n/**\n * Normalization filtered by a UnicodeSet.\n * Normalizes portions of the text contained in the filter set and leaves\n * portions not contained in the filter set unchanged.\n * Filtering is done via UnicodeSet::span(..., USET_SPAN_SIMPLE).\n * Not-in-the-filter text is treated as \"is normalized\" and \"quick check yes\".\n * This class implements all of (and only) the Normalizer2 API.\n * An instance of this class is unmodifiable/immutable but is constructed and\n * must be destructed by the owner.\n * @stable ICU 4.4\n */\nclass U_COMMON_API FilteredNormalizer2 : public Normalizer2 {\npublic:\n    /**\n     * Constructs a filtered normalizer wrapping any Normalizer2 instance\n     * and a filter set.\n     * Both are aliased and must not be modified or deleted while this object\n     * is used.\n     * The filter set should be frozen; otherwise the performance will suffer greatly.\n     * @param n2 wrapped Normalizer2 instance\n     * @param filterSet UnicodeSet which determines the characters to be normalized\n     * @stable ICU 4.4\n     */\n    FilteredNormalizer2(const Normalizer2 &n2, const UnicodeSet &filterSet) :\n            norm2(n2), set(filterSet) {}\n\n    /**\n     * Destructor.\n     * @stable ICU 4.4\n     */\n    ~FilteredNormalizer2();\n\n    /**\n     * Writes the normalized form of the source string to the destination string\n     * (replacing its contents) and returns the destination string.\n     * The source and destination strings must be different objects.\n     * @param src source string\n     * @param dest destination string; its contents is replaced with normalized src\n     * @param errorCode Standard ICU error code. Its input value must\n     *                  pass the U_SUCCESS() test, or else the function returns\n     *                  immediately. Check for U_FAILURE() on output or use with\n     *                  function chaining. (See User Guide for details.)\n     * @return dest\n     * @stable ICU 4.4\n     */\n    virtual UnicodeString &\n    normalize(const UnicodeString &src,\n              UnicodeString &dest,\n              UErrorCode &errorCode) const;\n    /**\n     * Appends the normalized form of the second string to the first string\n     * (merging them at the boundary) and returns the first string.\n     * The result is normalized if the first string was normalized.\n     * The first and second strings must be different objects.\n     * @param first string, should be normalized\n     * @param second string, will be normalized\n     * @param errorCode Standard ICU error code. Its input value must\n     *                  pass the U_SUCCESS() test, or else the function returns\n     *                  immediately. Check for U_FAILURE() on output or use with\n     *                  function chaining. (See User Guide for details.)\n     * @return first\n     * @stable ICU 4.4\n     */\n    virtual UnicodeString &\n    normalizeSecondAndAppend(UnicodeString &first,\n                             const UnicodeString &second,\n                             UErrorCode &errorCode) const;\n    /**\n     * Appends the second string to the first string\n     * (merging them at the boundary) and returns the first string.\n     * The result is normalized if both the strings were normalized.\n     * The first and second strings must be different objects.\n     * @param first string, should be normalized\n     * @param second string, should be normalized\n     * @param errorCode Standard ICU error code. Its input value must\n     *                  pass the U_SUCCESS() test, or else the function returns\n     *                  immediately. Check for U_FAILURE() on output or use with\n     *                  function chaining. (See User Guide for details.)\n     * @return first\n     * @stable ICU 4.4\n     */\n    virtual UnicodeString &\n    append(UnicodeString &first,\n           const UnicodeString &second,\n           UErrorCode &errorCode) const;\n\n    /**\n     * Gets the decomposition mapping of c.\n     * For details see the base class documentation.\n     *\n     * This function is independent of the mode of the Normalizer2.\n     * @param c code point\n     * @param decomposition String object which will be set to c's\n     *                      decomposition mapping, if there is one.\n     * @return TRUE if c has a decomposition, otherwise FALSE\n     * @stable ICU 4.6\n     */\n    virtual UBool\n    getDecomposition(UChar32 c, UnicodeString &decomposition) const;\n\n    /**\n     * Gets the raw decomposition mapping of c.\n     * For details see the base class documentation.\n     *\n     * This function is independent of the mode of the Normalizer2.\n     * @param c code point\n     * @param decomposition String object which will be set to c's\n     *                      raw decomposition mapping, if there is one.\n     * @return TRUE if c has a decomposition, otherwise FALSE\n     * @draft ICU 49\n     */\n    virtual UBool\n    getRawDecomposition(UChar32 c, UnicodeString &decomposition) const;\n\n    /**\n     * Performs pairwise composition of a & b and returns the composite if there is one.\n     * For details see the base class documentation.\n     *\n     * This function is independent of the mode of the Normalizer2.\n     * @param a A (normalization starter) code point.\n     * @param b Another code point.\n     * @return The non-negative composite code point if there is one; otherwise a negative value.\n     * @draft ICU 49\n     */\n    virtual UChar32\n    composePair(UChar32 a, UChar32 b) const;\n\n    /**\n     * Gets the combining class of c.\n     * The default implementation returns 0\n     * but all standard implementations return the Unicode Canonical_Combining_Class value.\n     * @param c code point\n     * @return c's combining class\n     * @draft ICU 49\n     */\n    virtual uint8_t\n    getCombiningClass(UChar32 c) const;\n\n    /**\n     * Tests if the string is normalized.\n     * For details see the Normalizer2 base class documentation.\n     * @param s input string\n     * @param errorCode Standard ICU error code. Its input value must\n     *                  pass the U_SUCCESS() test, or else the function returns\n     *                  immediately. Check for U_FAILURE() on output or use with\n     *                  function chaining. (See User Guide for details.)\n     * @return TRUE if s is normalized\n     * @stable ICU 4.4\n     */\n    virtual UBool\n    isNormalized(const UnicodeString &s, UErrorCode &errorCode) const;\n    /**\n     * Tests if the string is normalized.\n     * For details see the Normalizer2 base class documentation.\n     * @param s input string\n     * @param errorCode Standard ICU error code. Its input value must\n     *                  pass the U_SUCCESS() test, or else the function returns\n     *                  immediately. Check for U_FAILURE() on output or use with\n     *                  function chaining. (See User Guide for details.)\n     * @return UNormalizationCheckResult\n     * @stable ICU 4.4\n     */\n    virtual UNormalizationCheckResult\n    quickCheck(const UnicodeString &s, UErrorCode &errorCode) const;\n    /**\n     * Returns the end of the normalized substring of the input string.\n     * For details see the Normalizer2 base class documentation.\n     * @param s input string\n     * @param errorCode Standard ICU error code. Its input value must\n     *                  pass the U_SUCCESS() test, or else the function returns\n     *                  immediately. Check for U_FAILURE() on output or use with\n     *                  function chaining. (See User Guide for details.)\n     * @return \"yes\" span end index\n     * @stable ICU 4.4\n     */\n    virtual int32_t\n    spanQuickCheckYes(const UnicodeString &s, UErrorCode &errorCode) const;\n\n    /**\n     * Tests if the character always has a normalization boundary before it,\n     * regardless of context.\n     * For details see the Normalizer2 base class documentation.\n     * @param c character to test\n     * @return TRUE if c has a normalization boundary before it\n     * @stable ICU 4.4\n     */\n    virtual UBool hasBoundaryBefore(UChar32 c) const;\n\n    /**\n     * Tests if the character always has a normalization boundary after it,\n     * regardless of context.\n     * For details see the Normalizer2 base class documentation.\n     * @param c character to test\n     * @return TRUE if c has a normalization boundary after it\n     * @stable ICU 4.4\n     */\n    virtual UBool hasBoundaryAfter(UChar32 c) const;\n\n    /**\n     * Tests if the character is normalization-inert.\n     * For details see the Normalizer2 base class documentation.\n     * @param c character to test\n     * @return TRUE if c is normalization-inert\n     * @stable ICU 4.4\n     */\n    virtual UBool isInert(UChar32 c) const;\nprivate:\n    UnicodeString &\n    normalize(const UnicodeString &src,\n              UnicodeString &dest,\n              USetSpanCondition spanCondition,\n              UErrorCode &errorCode) const;\n\n    UnicodeString &\n    normalizeSecondAndAppend(UnicodeString &first,\n                             const UnicodeString &second,\n                             UBool doNormalize,\n                             UErrorCode &errorCode) const;\n\n    const Normalizer2 &norm2;\n    const UnicodeSet &set;\n};\n\nU_NAMESPACE_END\n\n#endif  // !UCONFIG_NO_NORMALIZATION\n#endif  // __NORMALIZER2_H__\n"
  },
  {
    "path": "deprecated/android/addons/icucompat/unicode/normlzr.h",
    "content": "/*\n ********************************************************************\n * COPYRIGHT:\n * Copyright (c) 1996-2011, International Business Machines Corporation and\n * others. All Rights Reserved.\n ********************************************************************\n */\n\n#ifndef NORMLZR_H\n#define NORMLZR_H\n\n#include \"unicode/utypes.h\"\n\n/**\n * \\file \n * \\brief C++ API: Unicode Normalization\n */\n \n#if !UCONFIG_NO_NORMALIZATION\n\n#include \"unicode/chariter.h\"\n#include \"unicode/normalizer2.h\"\n#include \"unicode/unistr.h\"\n#include \"unicode/unorm.h\"\n#include \"unicode/uobject.h\"\n\nU_NAMESPACE_BEGIN\n/**\n * The Normalizer class supports the standard normalization forms described in\n * <a href=\"http://www.unicode.org/unicode/reports/tr15/\" target=\"unicode\">\n * Unicode Standard Annex #15: Unicode Normalization Forms</a>.\n *\n * Note: This API has been replaced by the Normalizer2 class and is only available\n * for backward compatibility. This class simply delegates to the Normalizer2 class.\n * There is one exception: The new API does not provide a replacement for Normalizer::compare().\n *\n * The Normalizer class consists of two parts:\n * - static functions that normalize strings or test if strings are normalized\n * - a Normalizer object is an iterator that takes any kind of text and\n *   provides iteration over its normalized form\n *\n * The Normalizer class is not suitable for subclassing.\n *\n * For basic information about normalization forms and details about the C API\n * please see the documentation in unorm.h.\n *\n * The iterator API with the Normalizer constructors and the non-static functions\n * use a CharacterIterator as input. It is possible to pass a string which\n * is then internally wrapped in a CharacterIterator.\n * The input text is not normalized all at once, but incrementally where needed\n * (providing efficient random access).\n * This allows to pass in a large text but spend only a small amount of time\n * normalizing a small part of that text.\n * However, if the entire text is normalized, then the iterator will be\n * slower than normalizing the entire text at once and iterating over the result.\n * A possible use of the Normalizer iterator is also to report an index into the\n * original text that is close to where the normalized characters come from.\n *\n * <em>Important:</em> The iterator API was cleaned up significantly for ICU 2.0.\n * The earlier implementation reported the getIndex() inconsistently,\n * and previous() could not be used after setIndex(), next(), first(), and current().\n *\n * Normalizer allows to start normalizing from anywhere in the input text by\n * calling setIndexOnly(), first(), or last().\n * Without calling any of these, the iterator will start at the beginning of the text.\n *\n * At any time, next() returns the next normalized code point (UChar32),\n * with post-increment semantics (like CharacterIterator::next32PostInc()).\n * previous() returns the previous normalized code point (UChar32),\n * with pre-decrement semantics (like CharacterIterator::previous32()).\n *\n * current() returns the current code point\n * (respectively the one at the newly set index) without moving\n * the getIndex(). Note that if the text at the current position\n * needs to be normalized, then these functions will do that.\n * (This is why current() is not const.)\n * It is more efficient to call setIndexOnly() instead, which does not\n * normalize.\n *\n * getIndex() always refers to the position in the input text where the normalized\n * code points are returned from. It does not always change with each returned\n * code point.\n * The code point that is returned from any of the functions\n * corresponds to text at or after getIndex(), according to the\n * function's iteration semantics (post-increment or pre-decrement).\n *\n * next() returns a code point from at or after the getIndex()\n * from before the next() call. After the next() call, the getIndex()\n * might have moved to where the next code point will be returned from\n * (from a next() or current() call).\n * This is semantically equivalent to array access with array[index++]\n * (post-increment semantics).\n *\n * previous() returns a code point from at or after the getIndex()\n * from after the previous() call.\n * This is semantically equivalent to array access with array[--index]\n * (pre-decrement semantics).\n *\n * Internally, the Normalizer iterator normalizes a small piece of text\n * starting at the getIndex() and ending at a following \"safe\" index.\n * The normalized results is stored in an internal string buffer, and\n * the code points are iterated from there.\n * With multiple iteration calls, this is repeated until the next piece\n * of text needs to be normalized, and the getIndex() needs to be moved.\n *\n * The following \"safe\" index, the internal buffer, and the secondary\n * iteration index into that buffer are not exposed on the API.\n * This also means that it is currently not practical to return to\n * a particular, arbitrary position in the text because one would need to\n * know, and be able to set, in addition to the getIndex(), at least also the\n * current index into the internal buffer.\n * It is currently only possible to observe when getIndex() changes\n * (with careful consideration of the iteration semantics),\n * at which time the internal index will be 0.\n * For example, if getIndex() is different after next() than before it,\n * then the internal index is 0 and one can return to this getIndex()\n * later with setIndexOnly().\n *\n * Note: While the setIndex() and getIndex() refer to indices in the\n * underlying Unicode input text, the next() and previous() methods\n * iterate through characters in the normalized output.\n * This means that there is not necessarily a one-to-one correspondence\n * between characters returned by next() and previous() and the indices\n * passed to and returned from setIndex() and getIndex().\n * It is for this reason that Normalizer does not implement the CharacterIterator interface.\n *\n * @author Laura Werner, Mark Davis, Markus Scherer\n * @stable ICU 2.0\n */\nclass U_COMMON_API Normalizer : public UObject {\npublic:\n  /**\n   * If DONE is returned from an iteration function that returns a code point,\n   * then there are no more normalization results available.\n   * @stable ICU 2.0\n   */\n  enum {\n      DONE=0xffff\n  };\n\n  // Constructors\n\n  /**\n   * Creates a new <code>Normalizer</code> object for iterating over the\n   * normalized form of a given string.\n   * <p>\n   * @param str   The string to be normalized.  The normalization\n   *              will start at the beginning of the string.\n   *\n   * @param mode  The normalization mode.\n   * @stable ICU 2.0\n   */\n  Normalizer(const UnicodeString& str, UNormalizationMode mode);\n\n  /**\n   * Creates a new <code>Normalizer</code> object for iterating over the\n   * normalized form of a given string.\n   * <p>\n   * @param str   The string to be normalized.  The normalization\n   *              will start at the beginning of the string.\n   *\n   * @param length Length of the string, or -1 if NUL-terminated.\n   * @param mode  The normalization mode.\n   * @stable ICU 2.0\n   */\n  Normalizer(const UChar* str, int32_t length, UNormalizationMode mode);\n\n  /**\n   * Creates a new <code>Normalizer</code> object for iterating over the\n   * normalized form of the given text.\n   * <p>\n   * @param iter  The input text to be normalized.  The normalization\n   *              will start at the beginning of the string.\n   *\n   * @param mode  The normalization mode.\n   * @stable ICU 2.0\n   */\n  Normalizer(const CharacterIterator& iter, UNormalizationMode mode);\n\n  /**\n   * Copy constructor.\n   * @param copy The object to be copied.\n   * @stable ICU 2.0\n   */\n  Normalizer(const Normalizer& copy);\n\n  /**\n   * Destructor\n   * @stable ICU 2.0\n   */\n  virtual ~Normalizer();\n\n\n  //-------------------------------------------------------------------------\n  // Static utility methods\n  //-------------------------------------------------------------------------\n\n  /**\n   * Normalizes a <code>UnicodeString</code> according to the specified normalization mode.\n   * This is a wrapper for unorm_normalize(), using UnicodeString's.\n   *\n   * The <code>options</code> parameter specifies which optional\n   * <code>Normalizer</code> features are to be enabled for this operation.\n   *\n   * @param source    the input string to be normalized.\n   * @param mode      the normalization mode\n   * @param options   the optional features to be enabled (0 for no options)\n   * @param result    The normalized string (on output).\n   * @param status    The error code.\n   * @stable ICU 2.0\n   */\n  static void U_EXPORT2 normalize(const UnicodeString& source,\n                        UNormalizationMode mode, int32_t options,\n                        UnicodeString& result,\n                        UErrorCode &status);\n\n  /**\n   * Compose a <code>UnicodeString</code>.\n   * This is equivalent to normalize() with mode UNORM_NFC or UNORM_NFKC.\n   * This is a wrapper for unorm_normalize(), using UnicodeString's.\n   *\n   * The <code>options</code> parameter specifies which optional\n   * <code>Normalizer</code> features are to be enabled for this operation.\n   *\n   * @param source    the string to be composed.\n   * @param compat    Perform compatibility decomposition before composition.\n   *                  If this argument is <code>FALSE</code>, only canonical\n   *                  decomposition will be performed.\n   * @param options   the optional features to be enabled (0 for no options)\n   * @param result    The composed string (on output).\n   * @param status    The error code.\n   * @stable ICU 2.0\n   */\n  static void U_EXPORT2 compose(const UnicodeString& source,\n                      UBool compat, int32_t options,\n                      UnicodeString& result,\n                      UErrorCode &status);\n\n  /**\n   * Static method to decompose a <code>UnicodeString</code>.\n   * This is equivalent to normalize() with mode UNORM_NFD or UNORM_NFKD.\n   * This is a wrapper for unorm_normalize(), using UnicodeString's.\n   *\n   * The <code>options</code> parameter specifies which optional\n   * <code>Normalizer</code> features are to be enabled for this operation.\n   *\n   * @param source    the string to be decomposed.\n   * @param compat    Perform compatibility decomposition.\n   *                  If this argument is <code>FALSE</code>, only canonical\n   *                  decomposition will be performed.\n   * @param options   the optional features to be enabled (0 for no options)\n   * @param result    The decomposed string (on output).\n   * @param status    The error code.\n   * @stable ICU 2.0\n   */\n  static void U_EXPORT2 decompose(const UnicodeString& source,\n                        UBool compat, int32_t options,\n                        UnicodeString& result,\n                        UErrorCode &status);\n\n  /**\n   * Performing quick check on a string, to quickly determine if the string is\n   * in a particular normalization format.\n   * This is a wrapper for unorm_quickCheck(), using a UnicodeString.\n   *\n   * Three types of result can be returned UNORM_YES, UNORM_NO or\n   * UNORM_MAYBE. Result UNORM_YES indicates that the argument\n   * string is in the desired normalized format, UNORM_NO determines that\n   * argument string is not in the desired normalized format. A\n   * UNORM_MAYBE result indicates that a more thorough check is required,\n   * the user may have to put the string in its normalized form and compare the\n   * results.\n   * @param source       string for determining if it is in a normalized format\n   * @param mode         normalization format\n   * @param status A reference to a UErrorCode to receive any errors\n   * @return UNORM_YES, UNORM_NO or UNORM_MAYBE\n   *\n   * @see isNormalized\n   * @stable ICU 2.0\n   */\n  static inline UNormalizationCheckResult\n  quickCheck(const UnicodeString &source, UNormalizationMode mode, UErrorCode &status);\n\n  /**\n   * Performing quick check on a string; same as the other version of quickCheck\n   * but takes an extra options parameter like most normalization functions.\n   *\n   * @param source       string for determining if it is in a normalized format\n   * @param mode         normalization format\n   * @param options      the optional features to be enabled (0 for no options)\n   * @param status A reference to a UErrorCode to receive any errors\n   * @return UNORM_YES, UNORM_NO or UNORM_MAYBE\n   *\n   * @see isNormalized\n   * @stable ICU 2.6\n   */\n  static UNormalizationCheckResult\n  quickCheck(const UnicodeString &source, UNormalizationMode mode, int32_t options, UErrorCode &status);\n\n  /**\n   * Test if a string is in a given normalization form.\n   * This is semantically equivalent to source.equals(normalize(source, mode)) .\n   *\n   * Unlike unorm_quickCheck(), this function returns a definitive result,\n   * never a \"maybe\".\n   * For NFD, NFKD, and FCD, both functions work exactly the same.\n   * For NFC and NFKC where quickCheck may return \"maybe\", this function will\n   * perform further tests to arrive at a TRUE/FALSE result.\n   *\n   * @param src        String that is to be tested if it is in a normalization format.\n   * @param mode       Which normalization form to test for.\n   * @param errorCode  ICU error code in/out parameter.\n   *                   Must fulfill U_SUCCESS before the function call.\n   * @return Boolean value indicating whether the source string is in the\n   *         \"mode\" normalization form.\n   *\n   * @see quickCheck\n   * @stable ICU 2.2\n   */\n  static inline UBool\n  isNormalized(const UnicodeString &src, UNormalizationMode mode, UErrorCode &errorCode);\n\n  /**\n   * Test if a string is in a given normalization form; same as the other version of isNormalized\n   * but takes an extra options parameter like most normalization functions.\n   *\n   * @param src        String that is to be tested if it is in a normalization format.\n   * @param mode       Which normalization form to test for.\n   * @param options      the optional features to be enabled (0 for no options)\n   * @param errorCode  ICU error code in/out parameter.\n   *                   Must fulfill U_SUCCESS before the function call.\n   * @return Boolean value indicating whether the source string is in the\n   *         \"mode\" normalization form.\n   *\n   * @see quickCheck\n   * @stable ICU 2.6\n   */\n  static UBool\n  isNormalized(const UnicodeString &src, UNormalizationMode mode, int32_t options, UErrorCode &errorCode);\n\n  /**\n   * Concatenate normalized strings, making sure that the result is normalized as well.\n   *\n   * If both the left and the right strings are in\n   * the normalization form according to \"mode/options\",\n   * then the result will be\n   *\n   * \\code\n   *     dest=normalize(left+right, mode, options)\n   * \\endcode\n   *\n   * For details see unorm_concatenate in unorm.h.\n   *\n   * @param left Left source string.\n   * @param right Right source string.\n   * @param result The output string.\n   * @param mode The normalization mode.\n   * @param options A bit set of normalization options.\n   * @param errorCode ICU error code in/out parameter.\n   *                   Must fulfill U_SUCCESS before the function call.\n   * @return result\n   *\n   * @see unorm_concatenate\n   * @see normalize\n   * @see unorm_next\n   * @see unorm_previous\n   *\n   * @stable ICU 2.1\n   */\n  static UnicodeString &\n  U_EXPORT2 concatenate(const UnicodeString &left, const UnicodeString &right,\n              UnicodeString &result,\n              UNormalizationMode mode, int32_t options,\n              UErrorCode &errorCode);\n\n  /**\n   * Compare two strings for canonical equivalence.\n   * Further options include case-insensitive comparison and\n   * code point order (as opposed to code unit order).\n   *\n   * Canonical equivalence between two strings is defined as their normalized\n   * forms (NFD or NFC) being identical.\n   * This function compares strings incrementally instead of normalizing\n   * (and optionally case-folding) both strings entirely,\n   * improving performance significantly.\n   *\n   * Bulk normalization is only necessary if the strings do not fulfill the FCD\n   * conditions. Only in this case, and only if the strings are relatively long,\n   * is memory allocated temporarily.\n   * For FCD strings and short non-FCD strings there is no memory allocation.\n   *\n   * Semantically, this is equivalent to\n   *   strcmp[CodePointOrder](NFD(foldCase(s1)), NFD(foldCase(s2)))\n   * where code point order and foldCase are all optional.\n   *\n   * UAX 21 2.5 Caseless Matching specifies that for a canonical caseless match\n   * the case folding must be performed first, then the normalization.\n   *\n   * @param s1 First source string.\n   * @param s2 Second source string.\n   *\n   * @param options A bit set of options:\n   *   - U_FOLD_CASE_DEFAULT or 0 is used for default options:\n   *     Case-sensitive comparison in code unit order, and the input strings\n   *     are quick-checked for FCD.\n   *\n   *   - UNORM_INPUT_IS_FCD\n   *     Set if the caller knows that both s1 and s2 fulfill the FCD conditions.\n   *     If not set, the function will quickCheck for FCD\n   *     and normalize if necessary.\n   *\n   *   - U_COMPARE_CODE_POINT_ORDER\n   *     Set to choose code point order instead of code unit order\n   *     (see u_strCompare for details).\n   *\n   *   - U_COMPARE_IGNORE_CASE\n   *     Set to compare strings case-insensitively using case folding,\n   *     instead of case-sensitively.\n   *     If set, then the following case folding options are used.\n   *\n   *   - Options as used with case-insensitive comparisons, currently:\n   *\n   *   - U_FOLD_CASE_EXCLUDE_SPECIAL_I\n   *    (see u_strCaseCompare for details)\n   *\n   *   - regular normalization options shifted left by UNORM_COMPARE_NORM_OPTIONS_SHIFT\n   *\n   * @param errorCode ICU error code in/out parameter.\n   *                  Must fulfill U_SUCCESS before the function call.\n   * @return <0 or 0 or >0 as usual for string comparisons\n   *\n   * @see unorm_compare\n   * @see normalize\n   * @see UNORM_FCD\n   * @see u_strCompare\n   * @see u_strCaseCompare\n   *\n   * @stable ICU 2.2\n   */\n  static inline int32_t\n  compare(const UnicodeString &s1, const UnicodeString &s2,\n          uint32_t options,\n          UErrorCode &errorCode);\n\n  //-------------------------------------------------------------------------\n  // Iteration API\n  //-------------------------------------------------------------------------\n\n  /**\n   * Return the current character in the normalized text.\n   * current() may need to normalize some text at getIndex().\n   * The getIndex() is not changed.\n   *\n   * @return the current normalized code point\n   * @stable ICU 2.0\n   */\n  UChar32              current(void);\n\n  /**\n   * Return the first character in the normalized text.\n   * This is equivalent to setIndexOnly(startIndex()) followed by next().\n   * (Post-increment semantics.)\n   *\n   * @return the first normalized code point\n   * @stable ICU 2.0\n   */\n  UChar32              first(void);\n\n  /**\n   * Return the last character in the normalized text.\n   * This is equivalent to setIndexOnly(endIndex()) followed by previous().\n   * (Pre-decrement semantics.)\n   *\n   * @return the last normalized code point\n   * @stable ICU 2.0\n   */\n  UChar32              last(void);\n\n  /**\n   * Return the next character in the normalized text.\n   * (Post-increment semantics.)\n   * If the end of the text has already been reached, DONE is returned.\n   * The DONE value could be confused with a U+FFFF non-character code point\n   * in the text. If this is possible, you can test getIndex()<endIndex()\n   * before calling next(), or (getIndex()<endIndex() || last()!=DONE)\n   * after calling next(). (Calling last() will change the iterator state!)\n   *\n   * The C API unorm_next() is more efficient and does not have this ambiguity.\n   *\n   * @return the next normalized code point\n   * @stable ICU 2.0\n   */\n  UChar32              next(void);\n\n  /**\n   * Return the previous character in the normalized text and decrement.\n   * (Pre-decrement semantics.)\n   * If the beginning of the text has already been reached, DONE is returned.\n   * The DONE value could be confused with a U+FFFF non-character code point\n   * in the text. If this is possible, you can test\n   * (getIndex()>startIndex() || first()!=DONE). (Calling first() will change\n   * the iterator state!)\n   *\n   * The C API unorm_previous() is more efficient and does not have this ambiguity.\n   *\n   * @return the previous normalized code point\n   * @stable ICU 2.0\n   */\n  UChar32              previous(void);\n\n  /**\n   * Set the iteration position in the input text that is being normalized,\n   * without any immediate normalization.\n   * After setIndexOnly(), getIndex() will return the same index that is\n   * specified here.\n   *\n   * @param index the desired index in the input text.\n   * @stable ICU 2.0\n   */\n  void                 setIndexOnly(int32_t index);\n\n  /**\n   * Reset the index to the beginning of the text.\n   * This is equivalent to setIndexOnly(startIndex)).\n   * @stable ICU 2.0\n   */\n  void                reset(void);\n\n  /**\n   * Retrieve the current iteration position in the input text that is\n   * being normalized.\n   *\n   * A following call to next() will return a normalized code point from\n   * the input text at or after this index.\n   *\n   * After a call to previous(), getIndex() will point at or before the\n   * position in the input text where the normalized code point\n   * was returned from with previous().\n   *\n   * @return the current index in the input text\n   * @stable ICU 2.0\n   */\n  int32_t            getIndex(void) const;\n\n  /**\n   * Retrieve the index of the start of the input text. This is the begin index\n   * of the <code>CharacterIterator</code> or the start (i.e. index 0) of the string\n   * over which this <code>Normalizer</code> is iterating.\n   *\n   * @return the smallest index in the input text where the Normalizer operates\n   * @stable ICU 2.0\n   */\n  int32_t            startIndex(void) const;\n\n  /**\n   * Retrieve the index of the end of the input text. This is the end index\n   * of the <code>CharacterIterator</code> or the length of the string\n   * over which this <code>Normalizer</code> is iterating.\n   * This end index is exclusive, i.e., the Normalizer operates only on characters\n   * before this index.\n   *\n   * @return the first index in the input text where the Normalizer does not operate\n   * @stable ICU 2.0\n   */\n  int32_t            endIndex(void) const;\n\n  /**\n   * Returns TRUE when both iterators refer to the same character in the same\n   * input text.\n   *\n   * @param that a Normalizer object to compare this one to\n   * @return comparison result\n   * @stable ICU 2.0\n   */\n  UBool        operator==(const Normalizer& that) const;\n\n  /**\n   * Returns FALSE when both iterators refer to the same character in the same\n   * input text.\n   *\n   * @param that a Normalizer object to compare this one to\n   * @return comparison result\n   * @stable ICU 2.0\n   */\n  inline UBool        operator!=(const Normalizer& that) const;\n\n  /**\n   * Returns a pointer to a new Normalizer that is a clone of this one.\n   * The caller is responsible for deleting the new clone.\n   * @return a pointer to a new Normalizer\n   * @stable ICU 2.0\n   */\n  Normalizer*        clone(void) const;\n\n  /**\n   * Generates a hash code for this iterator.\n   *\n   * @return the hash code\n   * @stable ICU 2.0\n   */\n  int32_t                hashCode(void) const;\n\n  //-------------------------------------------------------------------------\n  // Property access methods\n  //-------------------------------------------------------------------------\n\n  /**\n   * Set the normalization mode for this object.\n   * <p>\n   * <b>Note:</b>If the normalization mode is changed while iterating\n   * over a string, calls to {@link #next() } and {@link #previous() } may\n   * return previously buffers characters in the old normalization mode\n   * until the iteration is able to re-sync at the next base character.\n   * It is safest to call {@link #setIndexOnly }, {@link #reset() },\n   * {@link #setText }, {@link #first() },\n   * {@link #last() }, etc. after calling <code>setMode</code>.\n   * <p>\n   * @param newMode the new mode for this <code>Normalizer</code>.\n   * @see #getUMode\n   * @stable ICU 2.0\n   */\n  void setMode(UNormalizationMode newMode);\n\n  /**\n   * Return the normalization mode for this object.\n   *\n   * This is an unusual name because there used to be a getMode() that\n   * returned a different type.\n   *\n   * @return the mode for this <code>Normalizer</code>\n   * @see #setMode\n   * @stable ICU 2.0\n   */\n  UNormalizationMode getUMode(void) const;\n\n  /**\n   * Set options that affect this <code>Normalizer</code>'s operation.\n   * Options do not change the basic composition or decomposition operation\n   * that is being performed, but they control whether\n   * certain optional portions of the operation are done.\n   * Currently the only available option is obsolete.\n   *\n   * It is possible to specify multiple options that are all turned on or off.\n   *\n   * @param   option  the option(s) whose value is/are to be set.\n   * @param   value   the new setting for the option.  Use <code>TRUE</code> to\n   *                  turn the option(s) on and <code>FALSE</code> to turn it/them off.\n   *\n   * @see #getOption\n   * @stable ICU 2.0\n   */\n  void setOption(int32_t option,\n         UBool value);\n\n  /**\n   * Determine whether an option is turned on or off.\n   * If multiple options are specified, then the result is TRUE if any\n   * of them are set.\n   * <p>\n   * @param option the option(s) that are to be checked\n   * @return TRUE if any of the option(s) are set\n   * @see #setOption\n   * @stable ICU 2.0\n   */\n  UBool getOption(int32_t option) const;\n\n  /**\n   * Set the input text over which this <code>Normalizer</code> will iterate.\n   * The iteration position is set to the beginning.\n   *\n   * @param newText a string that replaces the current input text\n   * @param status a UErrorCode\n   * @stable ICU 2.0\n   */\n  void setText(const UnicodeString& newText,\n           UErrorCode &status);\n\n  /**\n   * Set the input text over which this <code>Normalizer</code> will iterate.\n   * The iteration position is set to the beginning.\n   *\n   * @param newText a CharacterIterator object that replaces the current input text\n   * @param status a UErrorCode\n   * @stable ICU 2.0\n   */\n  void setText(const CharacterIterator& newText,\n           UErrorCode &status);\n\n  /**\n   * Set the input text over which this <code>Normalizer</code> will iterate.\n   * The iteration position is set to the beginning.\n   *\n   * @param newText a string that replaces the current input text\n   * @param length the length of the string, or -1 if NUL-terminated\n   * @param status a UErrorCode\n   * @stable ICU 2.0\n   */\n  void setText(const UChar* newText,\n                    int32_t length,\n            UErrorCode &status);\n  /**\n   * Copies the input text into the UnicodeString argument.\n   *\n   * @param result Receives a copy of the text under iteration.\n   * @stable ICU 2.0\n   */\n  void            getText(UnicodeString&  result);\n\n  /**\n   * ICU \"poor man's RTTI\", returns a UClassID for this class.\n   * @returns a UClassID for this class.\n   * @stable ICU 2.2\n   */\n  static UClassID U_EXPORT2 getStaticClassID();\n\n  /**\n   * ICU \"poor man's RTTI\", returns a UClassID for the actual class.\n   * @return a UClassID for the actual class.\n   * @stable ICU 2.2\n   */\n  virtual UClassID getDynamicClassID() const;\n\nprivate:\n  //-------------------------------------------------------------------------\n  // Private functions\n  //-------------------------------------------------------------------------\n\n  Normalizer(); // default constructor not implemented\n  Normalizer &operator=(const Normalizer &that); // assignment operator not implemented\n\n  // Private utility methods for iteration\n  // For documentation, see the source code\n  UBool nextNormalize();\n  UBool previousNormalize();\n\n  void    init();\n  void    clearBuffer(void);\n\n  //-------------------------------------------------------------------------\n  // Private data\n  //-------------------------------------------------------------------------\n\n  FilteredNormalizer2*fFilteredNorm2;  // owned if not NULL\n  const Normalizer2  *fNorm2;  // not owned; may be equal to fFilteredNorm2\n  UNormalizationMode  fUMode;\n  int32_t             fOptions;\n\n  // The input text and our position in it\n  CharacterIterator  *text;\n\n  // The normalization buffer is the result of normalization\n  // of the source in [currentIndex..nextIndex[ .\n  int32_t         currentIndex, nextIndex;\n\n  // A buffer for holding intermediate results\n  UnicodeString       buffer;\n  int32_t         bufferPos;\n};\n\n//-------------------------------------------------------------------------\n// Inline implementations\n//-------------------------------------------------------------------------\n\ninline UBool\nNormalizer::operator!= (const Normalizer& other) const\n{ return ! operator==(other); }\n\ninline UNormalizationCheckResult\nNormalizer::quickCheck(const UnicodeString& source,\n                       UNormalizationMode mode,\n                       UErrorCode &status) {\n    return quickCheck(source, mode, 0, status);\n}\n\ninline UBool\nNormalizer::isNormalized(const UnicodeString& source,\n                         UNormalizationMode mode,\n                         UErrorCode &status) {\n    return isNormalized(source, mode, 0, status);\n}\n\ninline int32_t\nNormalizer::compare(const UnicodeString &s1, const UnicodeString &s2,\n                    uint32_t options,\n                    UErrorCode &errorCode) {\n  // all argument checking is done in unorm_compare\n  return unorm_compare(s1.getBuffer(), s1.length(),\n                       s2.getBuffer(), s2.length(),\n                       options,\n                       &errorCode);\n}\n\nU_NAMESPACE_END\n\n#endif /* #if !UCONFIG_NO_NORMALIZATION */\n\n#endif // NORMLZR_H\n"
  },
  {
    "path": "deprecated/android/addons/icucompat/unicode/numfmt.h",
    "content": "/*\n********************************************************************************\n* Copyright (C) 1997-2012, International Business Machines Corporation and others.\n* All Rights Reserved.\n********************************************************************************\n*\n* File NUMFMT.H\n*\n* Modification History:\n*\n*   Date        Name        Description\n*   02/19/97    aliu        Converted from java.\n*   03/18/97    clhuang     Updated per C++ implementation.\n*   04/17/97    aliu        Changed DigitCount to int per code review.\n*    07/20/98    stephen        JDK 1.2 sync up. Added scientific support.\n*                            Changed naming conventions to match C++ guidelines\n*                            Derecated Java style constants (eg, INTEGER_FIELD)\n********************************************************************************\n*/\n\n#ifndef NUMFMT_H\n#define NUMFMT_H\n\n\n#include \"unicode/utypes.h\"\n\n/**\n * \\file\n * \\brief C++ API: Abstract base class for all number formats.\n */\n\n#if !UCONFIG_NO_FORMATTING\n\n#include \"unicode/unistr.h\"\n#include \"unicode/format.h\"\n#include \"unicode/unum.h\" // UNumberFormatStyle\n#include \"unicode/locid.h\"\n#include \"unicode/stringpiece.h\"\n#include \"unicode/curramt.h\"\n\nclass NumberFormatTest;\n\nU_NAMESPACE_BEGIN\n\n#if !UCONFIG_NO_SERVICE\nclass NumberFormatFactory;\nclass StringEnumeration;\n#endif\n\n/**\n *\n * Abstract base class for all number formats.  Provides interface for\n * formatting and parsing a number.  Also provides methods for\n * determining which locales have number formats, and what their names\n * are.\n * <P>\n * NumberFormat helps you to format and parse numbers for any locale.\n * Your code can be completely independent of the locale conventions\n * for decimal points, thousands-separators, or even the particular\n * decimal digits used, or whether the number format is even decimal.\n * <P>\n * To format a number for the current Locale, use one of the static\n * factory methods:\n * <pre>\n * \\code\n *    double myNumber = 7.0;\n *    UnicodeString myString;\n *    UErrorCode success = U_ZERO_ERROR;\n *    NumberFormat* nf = NumberFormat::createInstance(success)\n *    nf->format(myNumber, myString);\n *    cout << \" Example 1: \" << myString << endl;\n * \\endcode\n * </pre>\n * If you are formatting multiple numbers, it is more efficient to get\n * the format and use it multiple times so that the system doesn't\n * have to fetch the information about the local language and country\n * conventions multiple times.\n * <pre>\n * \\code\n *     UnicodeString myString;\n *     UErrorCode success = U_ZERO_ERROR;\n *     nf = NumberFormat::createInstance( success );\n *     int32_t a[] = { 123, 3333, -1234567 };\n *     const int32_t a_len = sizeof(a) / sizeof(a[0]);\n *     myString.remove();\n *     for (int32_t i = 0; i < a_len; i++) {\n *         nf->format(a[i], myString);\n *         myString += \" ; \";\n *     }\n *     cout << \" Example 2: \" << myString << endl;\n * \\endcode\n * </pre>\n * To format a number for a different Locale, specify it in the\n * call to createInstance().\n * <pre>\n * \\code\n *     nf = NumberFormat::createInstance( Locale::FRENCH, success );\n * \\endcode\n * </pre>\n * You can use a NumberFormat to parse also.\n * <pre>\n * \\code\n *    UErrorCode success;\n *    Formattable result(-999);  // initialized with error code\n *    nf->parse(myString, result, success);\n * \\endcode\n * </pre>\n * Use createInstance to get the normal number format for that country.\n * There are other static factory methods available.  Use getCurrency\n * to get the currency number format for that country.  Use getPercent\n * to get a format for displaying percentages. With this format, a\n * fraction from 0.53 is displayed as 53%.\n * <P>\n * Starting from ICU 4.2, you can use createInstance() by passing in a 'style'\n * as parameter to get the correct instance.\n * For example,\n * use createInstance(...kNumberStyle...) to get the normal number format,\n * createInstance(...kPercentStyle...) to get a format for displaying\n * percentage,\n * createInstance(...kScientificStyle...) to get a format for displaying\n * scientific number,\n * createInstance(...kCurrencyStyle...) to get the currency number format,\n * in which the currency is represented by its symbol, for example, \"$3.00\".\n * createInstance(...kIsoCurrencyStyle...)  to get the currency number format,\n * in which the currency is represented by its ISO code, for example \"USD3.00\".\n * createInstance(...kPluralCurrencyStyle...) to get the currency number format,\n * in which the currency is represented by its full name in plural format,\n * for example, \"3.00 US dollars\" or \"1.00 US dollar\".\n * <P>\n * You can also control the display of numbers with such methods as\n * getMinimumFractionDigits.  If you want even more control over the\n * format or parsing, or want to give your users more control, you can\n * try casting the NumberFormat you get from the factory methods to a\n * DecimalNumberFormat. This will work for the vast majority of\n * countries; just remember to put it in a try block in case you\n * encounter an unusual one.\n * <P>\n * You can also use forms of the parse and format methods with\n * ParsePosition and FieldPosition to allow you to:\n * <ul type=round>\n *   <li>(a) progressively parse through pieces of a string.\n *   <li>(b) align the decimal point and other areas.\n * </ul>\n * For example, you can align numbers in two ways.\n * <P>\n * If you are using a monospaced font with spacing for alignment, you\n * can pass the FieldPosition in your format call, with field =\n * INTEGER_FIELD. On output, getEndIndex will be set to the offset\n * between the last character of the integer and the decimal. Add\n * (desiredSpaceCount - getEndIndex) spaces at the front of the\n * string.\n * <P>\n * If you are using proportional fonts, instead of padding with\n * spaces, measure the width of the string in pixels from the start to\n * getEndIndex.  Then move the pen by (desiredPixelWidth -\n * widthToAlignmentPoint) before drawing the text.  It also works\n * where there is no decimal, but possibly additional characters at\n * the end, e.g. with parentheses in negative numbers: \"(12)\" for -12.\n * <p>\n * <em>User subclasses are not supported.</em> While clients may write\n * subclasses, such code will not necessarily work and will not be\n * guaranteed to work stably from release to release.\n *\n * @stable ICU 2.0\n */\nclass U_I18N_API NumberFormat : public Format {\npublic:\n    /**\n     * Alignment Field constants used to construct a FieldPosition object.\n     * Signifies that the position of the integer part or fraction part of\n     * a formatted number should be returned.\n     *\n     * Note: as of ICU 4.4, the values in this enum have been extended to\n     * support identification of all number format fields, not just those\n     * pertaining to alignment.\n     *\n     * These constants are provided for backwards compatibility only.\n     * Please use the C style constants defined in the header file unum.h.\n     *\n     * @see FieldPosition\n     * @stable ICU 2.0\n     */\n    enum EAlignmentFields {\n        /** @stable ICU 2.0 */\n        kIntegerField = UNUM_INTEGER_FIELD,\n        /** @stable ICU 2.0 */\n        kFractionField = UNUM_FRACTION_FIELD,\n        /** @stable ICU 2.0 */\n        kDecimalSeparatorField = UNUM_DECIMAL_SEPARATOR_FIELD,\n        /** @stable ICU 2.0 */\n        kExponentSymbolField = UNUM_EXPONENT_SYMBOL_FIELD,\n        /** @stable ICU 2.0 */\n        kExponentSignField = UNUM_EXPONENT_SIGN_FIELD,\n        /** @stable ICU 2.0 */\n        kExponentField = UNUM_EXPONENT_FIELD,\n        /** @stable ICU 2.0 */\n        kGroupingSeparatorField = UNUM_GROUPING_SEPARATOR_FIELD,\n        /** @stable ICU 2.0 */\n        kCurrencyField = UNUM_CURRENCY_FIELD,\n        /** @stable ICU 2.0 */\n        kPercentField = UNUM_PERCENT_FIELD,\n        /** @stable ICU 2.0 */\n        kPermillField = UNUM_PERMILL_FIELD,\n        /** @stable ICU 2.0 */\n        kSignField = UNUM_SIGN_FIELD,\n\n    /**\n     * These constants are provided for backwards compatibility only.\n     * Please use the constants defined in the header file unum.h.\n     */\n        /** @stable ICU 2.0 */\n        INTEGER_FIELD        = UNUM_INTEGER_FIELD,\n        /** @stable ICU 2.0 */\n        FRACTION_FIELD       = UNUM_FRACTION_FIELD\n    };\n\n    /**\n     * Destructor.\n     * @stable ICU 2.0\n     */\n    virtual ~NumberFormat();\n\n    /**\n     * Return true if the given Format objects are semantically equal.\n     * Objects of different subclasses are considered unequal.\n     * @return    true if the given Format objects are semantically equal.\n     * @stable ICU 2.0\n     */\n    virtual UBool operator==(const Format& other) const;\n\n\n    using Format::format;\n\n    /**\n     * Format an object to produce a string.  This method handles\n     * Formattable objects with numeric types. If the Formattable\n     * object type is not a numeric type, then it returns a failing\n     * UErrorCode.\n     *\n     * @param obj       The object to format.\n     * @param appendTo  Output parameter to receive result.\n     *                  Result is appended to existing contents.\n     * @param pos       On input: an alignment field, if desired.\n     *                  On output: the offsets of the alignment field.\n     * @param status    Output param filled with success/failure status.\n     * @return          Reference to 'appendTo' parameter.\n     * @stable ICU 2.0\n     */\n    virtual UnicodeString& format(const Formattable& obj,\n                                  UnicodeString& appendTo,\n                                  FieldPosition& pos,\n                                  UErrorCode& status) const;\n\n    /**\n     * Format an object to produce a string.  This method handles\n     * Formattable objects with numeric types. If the Formattable\n     * object type is not a numeric type, then it returns a failing\n     * UErrorCode.\n     *\n     * @param obj       The object to format.\n     * @param appendTo  Output parameter to receive result.\n     *                  Result is appended to existing contents.\n     * @param posIter   On return, can be used to iterate over positions\n     *                  of fields generated by this format call.  Can be\n     *                  NULL.\n     * @param status    Output param filled with success/failure status.\n     * @return          Reference to 'appendTo' parameter.\n     * @stable 4.4\n     */\n    virtual UnicodeString& format(const Formattable& obj,\n                                  UnicodeString& appendTo,\n                                  FieldPositionIterator* posIter,\n                                  UErrorCode& status) const;\n\n    /**\n     * Parse a string to produce an object.  This methods handles\n     * parsing of numeric strings into Formattable objects with numeric\n     * types.\n     * <P>\n     * Before calling, set parse_pos.index to the offset you want to\n     * start parsing at in the source. After calling, parse_pos.index\n     * indicates the position after the successfully parsed text.  If\n     * an error occurs, parse_pos.index is unchanged.\n     * <P>\n     * When parsing, leading whitespace is discarded (with successful\n     * parse), while trailing whitespace is left as is.\n     * <P>\n     * See Format::parseObject() for more.\n     *\n     * @param source    The string to be parsed into an object.\n     * @param result    Formattable to be set to the parse result.\n     *                  If parse fails, return contents are undefined.\n     * @param parse_pos The position to start parsing at. Upon return\n     *                  this param is set to the position after the\n     *                  last character successfully parsed. If the\n     *                  source is not parsed successfully, this param\n     *                  will remain unchanged.\n     * @return          A newly created Formattable* object, or NULL\n     *                  on failure.  The caller owns this and should\n     *                  delete it when done.\n     * @stable ICU 2.0\n     */\n    virtual void parseObject(const UnicodeString& source,\n                             Formattable& result,\n                             ParsePosition& parse_pos) const;\n\n    /**\n     * Format a double number. These methods call the NumberFormat\n     * pure virtual format() methods with the default FieldPosition.\n     *\n     * @param number    The value to be formatted.\n     * @param appendTo  Output parameter to receive result.\n     *                  Result is appended to existing contents.\n     * @return          Reference to 'appendTo' parameter.\n     * @stable ICU 2.0\n     */\n    UnicodeString& format(  double number,\n                            UnicodeString& appendTo) const;\n\n    /**\n     * Format a long number. These methods call the NumberFormat\n     * pure virtual format() methods with the default FieldPosition.\n     *\n     * @param number    The value to be formatted.\n     * @param appendTo  Output parameter to receive result.\n     *                  Result is appended to existing contents.\n     * @return          Reference to 'appendTo' parameter.\n     * @stable ICU 2.0\n     */\n    UnicodeString& format(  int32_t number,\n                            UnicodeString& appendTo) const;\n\n    /**\n     * Format an int64 number. These methods call the NumberFormat\n     * pure virtual format() methods with the default FieldPosition.\n     *\n     * @param number    The value to be formatted.\n     * @param appendTo  Output parameter to receive result.\n     *                  Result is appended to existing contents.\n     * @return          Reference to 'appendTo' parameter.\n     * @stable ICU 2.8\n     */\n    UnicodeString& format(  int64_t number,\n                            UnicodeString& appendTo) const;\n\n    /**\n     * Format a double number. Concrete subclasses must implement\n     * these pure virtual methods.\n     *\n     * @param number    The value to be formatted.\n     * @param appendTo  Output parameter to receive result.\n     *                  Result is appended to existing contents.\n     * @param pos       On input: an alignment field, if desired.\n     *                  On output: the offsets of the alignment field.\n     * @return          Reference to 'appendTo' parameter.\n     * @stable ICU 2.0\n     */\n    virtual UnicodeString& format(double number,\n                                  UnicodeString& appendTo,\n                                  FieldPosition& pos) const = 0;\n    /**\n     * Format a double number. By default, the parent function simply\n     * calls the base class and does not return an error status.\n     * Therefore, the status may be ignored in some subclasses.\n     *\n     * @param number    The value to be formatted.\n     * @param appendTo  Output parameter to receive result.\n     *                  Result is appended to existing contents.\n     * @param pos       On input: an alignment field, if desired.\n     *                  On output: the offsets of the alignment field.\n     * @param status    error status\n     * @return          Reference to 'appendTo' parameter.\n     * @internal\n     */\n    virtual UnicodeString& format(double number,\n                                  UnicodeString& appendTo,\n                                  FieldPosition& pos,\n                                  UErrorCode &status) const;\n    /**\n     * Format a double number. Subclasses must implement\n     * this method.\n     *\n     * @param number    The value to be formatted.\n     * @param appendTo  Output parameter to receive result.\n     *                  Result is appended to existing contents.\n     * @param posIter   On return, can be used to iterate over positions\n     *                  of fields generated by this format call.\n     *                  Can be NULL.\n     * @param status    Output param filled with success/failure status.\n     * @return          Reference to 'appendTo' parameter.\n     * @stable 4.4\n     */\n    virtual UnicodeString& format(double number,\n                                  UnicodeString& appendTo,\n                                  FieldPositionIterator* posIter,\n                                  UErrorCode& status) const;\n    /**\n     * Format a long number. Concrete subclasses must implement\n     * these pure virtual methods.\n     *\n     * @param number    The value to be formatted.\n     * @param appendTo  Output parameter to receive result.\n     *                  Result is appended to existing contents.\n     * @param pos       On input: an alignment field, if desired.\n     *                  On output: the offsets of the alignment field.\n     * @return          Reference to 'appendTo' parameter.\n     * @stable ICU 2.0\n    */\n    virtual UnicodeString& format(int32_t number,\n                                  UnicodeString& appendTo,\n                                  FieldPosition& pos) const = 0;\n\n    /**\n     * Format a long number. Concrete subclasses may override\n     * this function to provide status return.\n     *\n     * @param number    The value to be formatted.\n     * @param appendTo  Output parameter to receive result.\n     *                  Result is appended to existing contents.\n     * @param pos       On input: an alignment field, if desired.\n     *                  On output: the offsets of the alignment field.\n     * @param status the output status.\n     * @return          Reference to 'appendTo' parameter.\n     * @internal\n    */\n    virtual UnicodeString& format(int32_t number,\n                                  UnicodeString& appendTo,\n                                  FieldPosition& pos,\n                                  UErrorCode &status) const;\n\n    /**\n     * Format an int32 number. Subclasses must implement\n     * this method.\n     *\n     * @param number    The value to be formatted.\n     * @param appendTo  Output parameter to receive result.\n     *                  Result is appended to existing contents.\n     * @param posIter   On return, can be used to iterate over positions\n     *                  of fields generated by this format call.\n     *                  Can be NULL.\n     * @param status    Output param filled with success/failure status.\n     * @return          Reference to 'appendTo' parameter.\n     * @stable 4.4\n     */\n    virtual UnicodeString& format(int32_t number,\n                                  UnicodeString& appendTo,\n                                  FieldPositionIterator* posIter,\n                                  UErrorCode& status) const;\n    /**\n     * Format an int64 number. (Not abstract to retain compatibility\n     * with earlier releases, however subclasses should override this\n     * method as it just delegates to format(int32_t number...);\n     *\n     * @param number    The value to be formatted.\n     * @param appendTo  Output parameter to receive result.\n     *                  Result is appended to existing contents.\n     * @param pos       On input: an alignment field, if desired.\n     *                  On output: the offsets of the alignment field.\n     * @return          Reference to 'appendTo' parameter.\n     * @stable ICU 2.8\n    */\n    virtual UnicodeString& format(int64_t number,\n                                  UnicodeString& appendTo,\n                                  FieldPosition& pos) const;\n\n    /**\n     * Format an int64 number. (Not abstract to retain compatibility\n     * with earlier releases, however subclasses should override this\n     * method as it just delegates to format(int32_t number...);\n     *\n     * @param number    The value to be formatted.\n     * @param appendTo  Output parameter to receive result.\n     *                  Result is appended to existing contents.\n     * @param pos       On input: an alignment field, if desired.\n     *                  On output: the offsets of the alignment field.\n     * @return          Reference to 'appendTo' parameter.\n     * @internal\n    */\n    virtual UnicodeString& format(int64_t number,\n                                  UnicodeString& appendTo,\n                                  FieldPosition& pos,\n                                  UErrorCode& status) const;\n    /**\n     * Format an int64 number. Subclasses must implement\n     * this method.\n     *\n     * @param number    The value to be formatted.\n     * @param appendTo  Output parameter to receive result.\n     *                  Result is appended to existing contents.\n     * @param posIter   On return, can be used to iterate over positions\n     *                  of fields generated by this format call.\n     *                  Can be NULL.\n     * @param status    Output param filled with success/failure status.\n     * @return          Reference to 'appendTo' parameter.\n     * @stable 4.4\n     */\n    virtual UnicodeString& format(int64_t number,\n                                  UnicodeString& appendTo,\n                                  FieldPositionIterator* posIter,\n                                  UErrorCode& status) const;\n\n    /**\n     * Format a decimal number. Subclasses must implement\n     * this method.  The syntax of the unformatted number is a \"numeric string\"\n     * as defined in the Decimal Arithmetic Specification, available at\n     * http://speleotrove.com/decimal\n     *\n     * @param number    The unformatted number, as a string, to be formatted.\n     * @param appendTo  Output parameter to receive result.\n     *                  Result is appended to existing contents.\n     * @param posIter   On return, can be used to iterate over positions\n     *                  of fields generated by this format call.\n     *                  Can be NULL.\n     * @param status    Output param filled with success/failure status.\n     * @return          Reference to 'appendTo' parameter.\n     * @stable 4.4\n     */\n    virtual UnicodeString& format(const StringPiece &number,\n                                  UnicodeString& appendTo,\n                                  FieldPositionIterator* posIter,\n                                  UErrorCode& status) const;\npublic:\n    /**\n     * Format a decimal number. \n     * The number is a DigitList wrapper onto a floating point decimal number.\n     * The default implementation in NumberFormat converts the decimal number\n     * to a double and formats that.  Subclasses of NumberFormat that want\n     * to specifically handle big decimal numbers must override this method.\n     * class DecimalFormat does so.\n     *\n     * @param number    The number, a DigitList format Decimal Floating Point.\n     * @param appendTo  Output parameter to receive result.\n     *                  Result is appended to existing contents.\n     * @param posIter   On return, can be used to iterate over positions\n     *                  of fields generated by this format call.\n     * @param status    Output param filled with success/failure status.\n     * @return          Reference to 'appendTo' parameter.\n     * @internal\n     */\n    virtual UnicodeString& format(const DigitList &number,\n                                  UnicodeString& appendTo,\n                                  FieldPositionIterator* posIter,\n                                  UErrorCode& status) const;\n\n    /**\n     * Format a decimal number. \n     * The number is a DigitList wrapper onto a floating point decimal number.\n     * The default implementation in NumberFormat converts the decimal number\n     * to a double and formats that.  Subclasses of NumberFormat that want\n     * to specifically handle big decimal numbers must override this method.\n     * class DecimalFormat does so.\n     *\n     * @param number    The number, a DigitList format Decimal Floating Point.\n     * @param appendTo  Output parameter to receive result.\n     *                  Result is appended to existing contents.\n     * @param pos       On input: an alignment field, if desired.\n     *                  On output: the offsets of the alignment field.\n     * @param status    Output param filled with success/failure status.\n     * @return          Reference to 'appendTo' parameter.\n     * @internal\n     */\n    virtual UnicodeString& format(const DigitList &number,\n                                  UnicodeString& appendTo,\n                                  FieldPosition& pos,\n                                  UErrorCode& status) const;\n\npublic:\n\n    /**\n     * Redeclared Format method.\n     * @param obj       The object to be formatted.\n     * @param appendTo  Output parameter to receive result.\n     *                  Result is appended to existing contents.\n     * @param status    Output parameter set to a failure error code\n     *                  when a failure occurs.\n     * @return          Reference to 'appendTo' parameter.\n     * @stable ICU 2.0\n     */\n    UnicodeString& format(const Formattable& obj,\n                          UnicodeString& appendTo,\n                          UErrorCode& status) const;\n\n   /**\n    * Return a long if possible (e.g. within range LONG_MAX,\n    * LONG_MAX], and with no decimals), otherwise a double.  If\n    * IntegerOnly is set, will stop at a decimal point (or equivalent;\n    * e.g. for rational numbers \"1 2/3\", will stop after the 1).\n    * <P>\n    * If no object can be parsed, index is unchanged, and NULL is\n    * returned.\n    * <P>\n    * This is a pure virtual which concrete subclasses must implement.\n    *\n    * @param text           The text to be parsed.\n    * @param result         Formattable to be set to the parse result.\n    *                       If parse fails, return contents are undefined.\n    * @param parsePosition  The position to start parsing at on input.\n    *                       On output, moved to after the last successfully\n    *                       parse character. On parse failure, does not change.\n    * @stable ICU 2.0\n    */\n    virtual void parse(const UnicodeString& text,\n                       Formattable& result,\n                       ParsePosition& parsePosition) const = 0;\n\n    /**\n     * Parse a string as a numeric value, and return a Formattable\n     * numeric object. This method parses integers only if IntegerOnly\n     * is set.\n     *\n     * @param text          The text to be parsed.\n     * @param result        Formattable to be set to the parse result.\n     *                      If parse fails, return contents are undefined.\n     * @param status        Output parameter set to a failure error code\n     *                      when a failure occurs.\n     * @see                 NumberFormat::isParseIntegerOnly\n     * @stable ICU 2.0\n     */\n    virtual void parse(const UnicodeString& text,\n                       Formattable& result,\n                       UErrorCode& status) const;\n\n/* Cannot use #ifndef U_HIDE_DRAFT_API for the following draft method since it is virtual */\n    /**\n     * Parses text from the given string as a currency amount.  Unlike\n     * the parse() method, this method will attempt to parse a generic\n     * currency name, searching for a match of this object's locale's\n     * currency display names, or for a 3-letter ISO currency code.\n     * This method will fail if this format is not a currency format,\n     * that is, if it does not contain the currency pattern symbol\n     * (U+00A4) in its prefix or suffix.\n     *\n     * @param text the string to parse\n     * @param pos  input-output position; on input, the position within text\n     *             to match; must have 0 <= pos.getIndex() < text.length();\n     *             on output, the position after the last matched character.\n     *             If the parse fails, the position in unchanged upon output.\n     * @return     if parse succeeds, a pointer to a newly-created CurrencyAmount\n     *             object (owned by the caller) containing information about\n     *             the parsed currency; if parse fails, this is NULL.\n     * @draft ICU 49\n     */\n    virtual CurrencyAmount* parseCurrency(const UnicodeString& text,\n                                          ParsePosition& pos) const;\n\n    /**\n     * Return true if this format will parse numbers as integers\n     * only.  For example in the English locale, with ParseIntegerOnly\n     * true, the string \"1234.\" would be parsed as the integer value\n     * 1234 and parsing would stop at the \".\" character.  Of course,\n     * the exact format accepted by the parse operation is locale\n     * dependant and determined by sub-classes of NumberFormat.\n     * @return    true if this format will parse numbers as integers\n     *            only.\n     * @stable ICU 2.0\n     */\n    UBool isParseIntegerOnly(void) const;\n\n    /**\n     * Sets whether or not numbers should be parsed as integers only.\n     * @param value    set True, this format will parse numbers as integers\n     *                 only.\n     * @see isParseIntegerOnly\n     * @stable ICU 2.0\n     */\n    virtual void setParseIntegerOnly(UBool value);\n\n    /**\n     * Sets whether lenient parsing should be enabled (it is off by default).\n     *\n     * @param enable <code>TRUE</code> if lenient parsing should be used,\n     *               <code>FALSE</code> otherwise.\n     * @stable ICU 4.8\n     */\n    virtual void setLenient(UBool enable);\n\n    /**\n     * Returns whether lenient parsing is enabled (it is off by default).\n     *\n     * @return <code>TRUE</code> if lenient parsing is enabled,\n     *         <code>FALSE</code> otherwise.\n     * @see #setLenient\n     * @stable ICU 4.8\n     */\n    virtual UBool isLenient(void) const;\n\n    /**\n     * Returns the default number format for the current default\n     * locale.  The default format is one of the styles provided by\n     * the other factory methods: getNumberInstance,\n     * getCurrencyInstance or getPercentInstance.  Exactly which one\n     * is locale dependant.\n     * @stable ICU 2.0\n     */\n    static NumberFormat* U_EXPORT2 createInstance(UErrorCode&);\n\n    /**\n     * Returns the default number format for the specified locale.\n     * The default format is one of the styles provided by the other\n     * factory methods: getNumberInstance, getCurrencyInstance or\n     * getPercentInstance.  Exactly which one is locale dependant.\n     * @param inLocale    the given locale.\n     * @stable ICU 2.0\n     */\n    static NumberFormat* U_EXPORT2 createInstance(const Locale& inLocale,\n                                        UErrorCode&);\n\n    /**\n     * Creates the specified decimal format style of the desired locale.\n     * @param desiredLocale    the given locale.\n     * @param style            the given style.\n     * @param errorCode        Output param filled with success/failure status.\n     * @return                 A new NumberFormat instance.\n     * @stable ICU 4.8\n     */\n    static NumberFormat* U_EXPORT2 createInstance(const Locale& desiredLocale,\n                                                  UNumberFormatStyle style,\n                                                  UErrorCode& errorCode);\n\n    /**\n     * Returns a currency format for the current default locale.\n     * @stable ICU 2.0\n     */\n    static NumberFormat* U_EXPORT2 createCurrencyInstance(UErrorCode&);\n\n    /**\n     * Returns a currency format for the specified locale.\n     * @param inLocale    the given locale.\n     * @stable ICU 2.0\n     */\n    static NumberFormat* U_EXPORT2 createCurrencyInstance(const Locale& inLocale,\n                                                UErrorCode&);\n\n    /**\n     * Returns a percentage format for the current default locale.\n     * @stable ICU 2.0\n     */\n    static NumberFormat* U_EXPORT2 createPercentInstance(UErrorCode&);\n\n    /**\n     * Returns a percentage format for the specified locale.\n     * @param inLocale    the given locale.\n     * @stable ICU 2.0\n     */\n    static NumberFormat* U_EXPORT2 createPercentInstance(const Locale& inLocale,\n                                               UErrorCode&);\n\n    /**\n     * Returns a scientific format for the current default locale.\n     * @stable ICU 2.0\n     */\n    static NumberFormat* U_EXPORT2 createScientificInstance(UErrorCode&);\n\n    /**\n     * Returns a scientific format for the specified locale.\n     * @param inLocale    the given locale.\n     * @stable ICU 2.0\n     */\n    static NumberFormat* U_EXPORT2 createScientificInstance(const Locale& inLocale,\n                                                UErrorCode&);\n\n    /**\n     * Get the set of Locales for which NumberFormats are installed.\n     * @param count    Output param to receive the size of the locales\n     * @stable ICU 2.0\n     */\n    static const Locale* U_EXPORT2 getAvailableLocales(int32_t& count);\n\n#if !UCONFIG_NO_SERVICE\n    /**\n     * Register a new NumberFormatFactory.  The factory will be adopted.\n     * @param toAdopt the NumberFormatFactory instance to be adopted\n     * @param status the in/out status code, no special meanings are assigned\n     * @return a registry key that can be used to unregister this factory\n     * @stable ICU 2.6\n     */\n    static URegistryKey U_EXPORT2 registerFactory(NumberFormatFactory* toAdopt, UErrorCode& status);\n\n    /**\n     * Unregister a previously-registered NumberFormatFactory using the key returned from the\n     * register call.  Key becomes invalid after a successful call and should not be used again.\n     * The NumberFormatFactory corresponding to the key will be deleted.\n     * @param key the registry key returned by a previous call to registerFactory\n     * @param status the in/out status code, no special meanings are assigned\n     * @return TRUE if the factory for the key was successfully unregistered\n     * @stable ICU 2.6\n     */\n    static UBool U_EXPORT2 unregister(URegistryKey key, UErrorCode& status);\n\n    /**\n     * Return a StringEnumeration over the locales available at the time of the call,\n     * including registered locales.\n     * @return a StringEnumeration over the locales available at the time of the call\n     * @stable ICU 2.6\n     */\n    static StringEnumeration* U_EXPORT2 getAvailableLocales(void);\n#endif /* UCONFIG_NO_SERVICE */\n\n    /**\n     * Returns true if grouping is used in this format. For example,\n     * in the English locale, with grouping on, the number 1234567\n     * might be formatted as \"1,234,567\". The grouping separator as\n     * well as the size of each group is locale dependant and is\n     * determined by sub-classes of NumberFormat.\n     * @see setGroupingUsed\n     * @stable ICU 2.0\n     */\n    UBool isGroupingUsed(void) const;\n\n    /**\n     * Set whether or not grouping will be used in this format.\n     * @param newValue    True, grouping will be used in this format.\n     * @see getGroupingUsed\n     * @stable ICU 2.0\n     */\n    virtual void setGroupingUsed(UBool newValue);\n\n    /**\n     * Returns the maximum number of digits allowed in the integer portion of a\n     * number.\n     * @return     the maximum number of digits allowed in the integer portion of a\n     *             number.\n     * @see setMaximumIntegerDigits\n     * @stable ICU 2.0\n     */\n    int32_t getMaximumIntegerDigits(void) const;\n\n    /**\n     * Sets the maximum number of digits allowed in the integer portion of a\n     * number. maximumIntegerDigits must be >= minimumIntegerDigits.  If the\n     * new value for maximumIntegerDigits is less than the current value\n     * of minimumIntegerDigits, then minimumIntegerDigits will also be set to\n     * the new value.\n     *\n     * @param newValue    the new value for the maximum number of digits\n     *                    allowed in the integer portion of a number.\n     * @see getMaximumIntegerDigits\n     * @stable ICU 2.0\n     */\n    virtual void setMaximumIntegerDigits(int32_t newValue);\n\n    /**\n     * Returns the minimum number of digits allowed in the integer portion of a\n     * number.\n     * @return    the minimum number of digits allowed in the integer portion of a\n     *            number.\n     * @see setMinimumIntegerDigits\n     * @stable ICU 2.0\n     */\n    int32_t getMinimumIntegerDigits(void) const;\n\n    /**\n     * Sets the minimum number of digits allowed in the integer portion of a\n     * number. minimumIntegerDigits must be &lt;= maximumIntegerDigits.  If the\n     * new value for minimumIntegerDigits exceeds the current value\n     * of maximumIntegerDigits, then maximumIntegerDigits will also be set to\n     * the new value.\n     * @param newValue    the new value to be set.\n     * @see getMinimumIntegerDigits\n     * @stable ICU 2.0\n     */\n    virtual void setMinimumIntegerDigits(int32_t newValue);\n\n    /**\n     * Returns the maximum number of digits allowed in the fraction portion of a\n     * number.\n     * @return    the maximum number of digits allowed in the fraction portion of a\n     *            number.\n     * @see setMaximumFractionDigits\n     * @stable ICU 2.0\n     */\n    int32_t getMaximumFractionDigits(void) const;\n\n    /**\n     * Sets the maximum number of digits allowed in the fraction portion of a\n     * number. maximumFractionDigits must be >= minimumFractionDigits.  If the\n     * new value for maximumFractionDigits is less than the current value\n     * of minimumFractionDigits, then minimumFractionDigits will also be set to\n     * the new value.\n     * @param newValue    the new value to be set.\n     * @see getMaximumFractionDigits\n     * @stable ICU 2.0\n     */\n    virtual void setMaximumFractionDigits(int32_t newValue);\n\n    /**\n     * Returns the minimum number of digits allowed in the fraction portion of a\n     * number.\n     * @return    the minimum number of digits allowed in the fraction portion of a\n     *            number.\n     * @see setMinimumFractionDigits\n     * @stable ICU 2.0\n     */\n    int32_t getMinimumFractionDigits(void) const;\n\n    /**\n     * Sets the minimum number of digits allowed in the fraction portion of a\n     * number. minimumFractionDigits must be &lt;= maximumFractionDigits.   If the\n     * new value for minimumFractionDigits exceeds the current value\n     * of maximumFractionDigits, then maximumIntegerDigits will also be set to\n     * the new value\n     * @param newValue    the new value to be set.\n     * @see getMinimumFractionDigits\n     * @stable ICU 2.0\n     */\n    virtual void setMinimumFractionDigits(int32_t newValue);\n\n    /**\n     * Sets the currency used to display currency\n     * amounts.  This takes effect immediately, if this format is a\n     * currency format.  If this format is not a currency format, then\n     * the currency is used if and when this object becomes a\n     * currency format.\n     * @param theCurrency a 3-letter ISO code indicating new currency\n     * to use.  It need not be null-terminated.  May be the empty\n     * string or NULL to indicate no currency.\n     * @param ec input-output error code\n     * @stable ICU 3.0\n     */\n    virtual void setCurrency(const UChar* theCurrency, UErrorCode& ec);\n\n    /**\n     * Gets the currency used to display currency\n     * amounts.  This may be an empty string for some subclasses.\n     * @return a 3-letter null-terminated ISO code indicating\n     * the currency in use, or a pointer to the empty string.\n     * @stable ICU 2.6\n     */\n    const UChar* getCurrency() const;\n\npublic:\n\n    /**\n     * Return the class ID for this class.  This is useful for\n     * comparing to a return value from getDynamicClassID(). Note that,\n     * because NumberFormat is an abstract base class, no fully constructed object\n     * will have the class ID returned by NumberFormat::getStaticClassID().\n     * @return The class ID for all objects of this class.\n     * @stable ICU 2.0\n     */\n    static UClassID U_EXPORT2 getStaticClassID(void);\n\n    /**\n     * Returns a unique class ID POLYMORPHICALLY.  Pure virtual override.\n     * This method is to implement a simple version of RTTI, since not all\n     * C++ compilers support genuine RTTI.  Polymorphic operator==() and\n     * clone() methods call this method.\n     * <P>\n     * @return The class ID for this object. All objects of a\n     * given class have the same class ID.  Objects of\n     * other classes have different class IDs.\n     * @stable ICU 2.0\n     */\n    virtual UClassID getDynamicClassID(void) const = 0;\n\nprotected:\n\n    /**\n     * Default constructor for subclass use only.\n     * @stable ICU 2.0\n     */\n    NumberFormat();\n\n    /**\n     * Copy constructor.\n     * @stable ICU 2.0\n     */\n    NumberFormat(const NumberFormat&);\n\n    /**\n     * Assignment operator.\n     * @stable ICU 2.0\n     */\n    NumberFormat& operator=(const NumberFormat&);\n\n    /**\n     * Returns the currency in effect for this formatter.  Subclasses\n     * should override this method as needed.  Unlike getCurrency(),\n     * this method should never return \"\".\n     * @result output parameter for null-terminated result, which must\n     * have a capacity of at least 4\n     * @internal\n     */\n    virtual void getEffectiveCurrency(UChar* result, UErrorCode& ec) const;\n\nprivate:\n\n    static UBool isStyleSupported(UNumberFormatStyle style);\n\n    /**\n     * Creates the specified decimal format style of the desired locale.\n     * @param desiredLocale    the given locale.\n     * @param style            the given style.\n     * @param errorCode        Output param filled with success/failure status.\n     * @return                 A new NumberFormat instance.\n     */\n    static NumberFormat* makeInstance(const Locale& desiredLocale,\n                                      UNumberFormatStyle style,\n                                      UErrorCode& errorCode);\n\n    UBool      fGroupingUsed;\n    int32_t     fMaxIntegerDigits;\n    int32_t     fMinIntegerDigits;\n    int32_t     fMaxFractionDigits;\n    int32_t     fMinFractionDigits;\n    UBool      fParseIntegerOnly;\n    UBool      fLenient; // TRUE => lenient parse is enabled\n\n    // ISO currency code\n    UChar      fCurrency[4];\n\n    friend class ICUNumberFormatFactory; // access to makeInstance\n    friend class ICUNumberFormatService;\n    friend class ::NumberFormatTest;  // access to isStyleSupported()\n};\n\n#if !UCONFIG_NO_SERVICE\n/**\n * A NumberFormatFactory is used to register new number formats.  The factory\n * should be able to create any of the predefined formats for each locale it\n * supports.  When registered, the locales it supports extend or override the\n * locale already supported by ICU.\n *\n * @stable ICU 2.6\n */\nclass U_I18N_API NumberFormatFactory : public UObject {\npublic:\n\n    /**\n     * Destructor\n     * @stable ICU 3.0\n     */\n    virtual ~NumberFormatFactory();\n\n    /**\n     * Return true if this factory will be visible.  Default is true.\n     * If not visible, the locales supported by this factory will not\n     * be listed by getAvailableLocales.\n     * @stable ICU 2.6\n     */\n    virtual UBool visible(void) const = 0;\n\n    /**\n     * Return the locale names directly supported by this factory.  The number of names\n     * is returned in count;\n     * @stable ICU 2.6\n     */\n    virtual const UnicodeString * getSupportedIDs(int32_t &count, UErrorCode& status) const = 0;\n\n    /**\n     * Return a number format of the appropriate type.  If the locale\n     * is not supported, return null.  If the locale is supported, but\n     * the type is not provided by this service, return null.  Otherwise\n     * return an appropriate instance of NumberFormat.\n     * @stable ICU 2.6\n     */\n    virtual NumberFormat* createFormat(const Locale& loc, UNumberFormatStyle formatType) = 0;\n};\n\n/**\n * A NumberFormatFactory that supports a single locale.  It can be visible or invisible.\n * @stable ICU 2.6\n */\nclass U_I18N_API SimpleNumberFormatFactory : public NumberFormatFactory {\nprotected:\n    /**\n     * True if the locale supported by this factory is visible.\n     * @stable ICU 2.6\n     */\n    const UBool _visible;\n\n    /**\n     * The locale supported by this factory, as a UnicodeString.\n     * @stable ICU 2.6\n     */\n    UnicodeString _id;\n\npublic:\n    /**\n     * @stable ICU 2.6\n     */\n    SimpleNumberFormatFactory(const Locale& locale, UBool visible = TRUE);\n\n    /**\n     * @stable ICU 3.0\n     */\n    virtual ~SimpleNumberFormatFactory();\n\n    /**\n     * @stable ICU 2.6\n     */\n    virtual UBool visible(void) const;\n\n    /**\n     * @stable ICU 2.6\n     */\n    virtual const UnicodeString * getSupportedIDs(int32_t &count, UErrorCode& status) const;\n};\n#endif /* #if !UCONFIG_NO_SERVICE */\n\n// -------------------------------------\n\ninline UBool\nNumberFormat::isParseIntegerOnly() const\n{\n    return fParseIntegerOnly;\n}\n\ninline UBool\nNumberFormat::isLenient() const\n{\n    return fLenient;\n}\n\ninline UnicodeString&\nNumberFormat::format(const Formattable& obj,\n                     UnicodeString& appendTo,\n                     UErrorCode& status) const {\n    return Format::format(obj, appendTo, status);\n}\n\nU_NAMESPACE_END\n\n#endif /* #if !UCONFIG_NO_FORMATTING */\n\n#endif // _NUMFMT\n//eof\n"
  },
  {
    "path": "deprecated/android/addons/icucompat/unicode/numsys.h",
    "content": "/*\n*******************************************************************************\n* Copyright (C) 2010-2011, International Business Machines Corporation and\n* others. All Rights Reserved.\n*******************************************************************************\n*\n*\n* File NUMSYS.H\n*\n* Modification History:*\n*   Date        Name        Description\n*\n********************************************************************************\n*/\n\n#ifndef NUMSYS\n#define NUMSYS\n\n/**\n * \\def NUMSYS_NAME_CAPACITY\n * Size of a numbering system name.\n * @internal\n */\n#define NUMSYS_NAME_CAPACITY 8\n\n#include \"unicode/utypes.h\"\n\n/**\n * \\file\n * \\brief C++ API: NumberingSystem object\n */\n\n#if !UCONFIG_NO_FORMATTING\n\n\n#include \"unicode/format.h\"\n#include \"unicode/uobject.h\"\n\nU_NAMESPACE_BEGIN\n\n/**\n * Defines numbering systems. A numbering system describes the scheme by which \n * numbers are to be presented to the end user.  In its simplest form, a numbering\n * system describes the set of digit characters that are to be used to display\n * numbers, such as Western digits, Thai digits, Arabic-Indic digits, etc. \n * More complicated numbering systems are algorithmic in nature, and require use\n * of an RBNF formatter ( rule based number formatter ), in order to calculate\n * the characters to be displayed for a given number.  Examples of algorithmic\n * numbering systems include Roman numerals, Chinese numerals, and Hebrew numerals.\n * Formatting rules for many commonly used numbering systems are included in\n * the ICU package, based on the numbering system rules defined in CLDR.\n * Alternate numbering systems can be specified to a locale by using the\n * numbers locale keyword.\n */\n\nclass U_I18N_API NumberingSystem : public UObject {\npublic:\n\n    /**\n     * Default Constructor.\n     *\n     * @stable ICU 4.2\n     */\n    NumberingSystem();\n\n    /**\n     * Copy constructor.\n     * @stable ICU 4.2\n     */\n    NumberingSystem(const NumberingSystem& other);\n\n    /**\n     * Destructor.\n     * @stable ICU 4.2\n     */\n    virtual ~NumberingSystem();\n\n    /**\n     * Create the default numbering system associated with the specified locale.\n     * @param inLocale The given locale.\n     * @param status ICU status\n     * @stable ICU 4.2\n     */\n    static NumberingSystem* U_EXPORT2 createInstance(const Locale & inLocale, UErrorCode& status);\n\n    /**\n     * Create the default numbering system associated with the default locale.\n     * @stable ICU 4.2\n     */\n    static NumberingSystem* U_EXPORT2 createInstance(UErrorCode& status);\n\n    /**\n     * Create a numbering system using the specified radix, type, and description. \n     * @param radix         The radix (base) for this numbering system.\n     * @param isAlgorithmic TRUE if the numbering system is algorithmic rather than numeric.\n     * @param description   The string representing the set of digits used in a numeric system, or the name of the RBNF\n     *                      ruleset to be used in an algorithmic system.\n     * @param status ICU status\n     * @stable ICU 4.2\n     */\n    static NumberingSystem* U_EXPORT2 createInstance(int32_t radix, UBool isAlgorithmic, const UnicodeString& description, UErrorCode& status );\n\n    /**\n     * Return a StringEnumeration over all the names of numbering systems known to ICU.\n     * @stable ICU 4.2\n     */\n\n     static StringEnumeration * U_EXPORT2 getAvailableNames(UErrorCode& status);\n\n    /**\n     * Create a numbering system from one of the predefined numbering systems known to ICU.\n     * @param name   The name of the numbering system.\n     * @param status ICU status\n     * @stable ICU 4.2\n     */\n    static NumberingSystem* U_EXPORT2 createInstanceByName(const char* name, UErrorCode& status);\n\n\n    /**\n     * Returns the radix of this numbering system.\n     * @stable ICU 4.2\n     */\n    int32_t getRadix();\n\n#ifndef U_HIDE_DRAFT_API\n    /**\n     * Returns the name of this numbering system if it was created using one of the predefined names\n     * known to ICU.  Otherwise, returns NULL.\n     * @draft ICU 4.6\n     */\n    const char * getName();\n#endif  /* U_HIDE_DRAFT_API */\n\n    /**\n     * Returns the description string of this numbering system, which is either\n     * the string of digits in the case of simple systems, or the ruleset name\n     * in the case of algorithmic systems.\n     * @stable ICU 4.2\n     */\n    virtual UnicodeString getDescription();\n\n\n\n    /**\n     * Returns TRUE if the given numbering system is algorithmic\n     *\n     * @return         TRUE if the numbering system is algorithmic.\n     *                 Otherwise, return FALSE.\n     * @stable ICU 4.2\n     */\n    UBool isAlgorithmic() const;\n\n    /**\n     * ICU \"poor man's RTTI\", returns a UClassID for this class.\n     *\n     * @stable ICU 4.2\n     *\n    */\n    static UClassID U_EXPORT2 getStaticClassID(void);\n\n    /**\n     * ICU \"poor man's RTTI\", returns a UClassID for the actual class.\n     *\n     * @stable ICU 4.2\n     */\n    virtual UClassID getDynamicClassID() const;\n\n\nprivate:\n    UnicodeString   desc;\n    int32_t         radix;\n    UBool           algorithmic;\n    char            name[NUMSYS_NAME_CAPACITY+1];\n\n    void setRadix(int32_t radix);\n\n    void setAlgorithmic(UBool algorithmic);\n\n    void setDesc(UnicodeString desc);\n\n    void setName(const char* name);\n\n    static UBool isValidDigitString(const UnicodeString &str);\n\n    UBool hasContiguousDecimalDigits() const;\n};\n\nU_NAMESPACE_END\n\n#endif /* #if !UCONFIG_NO_FORMATTING */\n\n#endif // _NUMSYS\n//eof\n"
  },
  {
    "path": "deprecated/android/addons/icucompat/unicode/parseerr.h",
    "content": "/*\n**********************************************************************\n*   Copyright (C) 1999-2005, International Business Machines\n*   Corporation and others.  All Rights Reserved.\n**********************************************************************\n*   Date        Name        Description\n*   03/14/00    aliu        Creation.\n*   06/27/00    aliu        Change from C++ class to C struct\n**********************************************************************\n*/\n#ifndef PARSEERR_H\n#define PARSEERR_H\n\n#include \"unicode/utypes.h\"\n\n\n/**\n * \\file\n * \\brief C API: Parse Error Information\n */\n/**\n * The capacity of the context strings in UParseError.\n * @stable ICU 2.0\n */ \nenum { U_PARSE_CONTEXT_LEN = 16 };\n\n/**\n * A UParseError struct is used to returned detailed information about\n * parsing errors.  It is used by ICU parsing engines that parse long\n * rules, patterns, or programs, where the text being parsed is long\n * enough that more information than a UErrorCode is needed to\n * localize the error.\n *\n * <p>The line, offset, and context fields are optional; parsing\n * engines may choose not to use to use them.\n *\n * <p>The preContext and postContext strings include some part of the\n * context surrounding the error.  If the source text is \"let for=7\"\n * and \"for\" is the error (e.g., because it is a reserved word), then\n * some examples of what a parser might produce are the following:\n *\n * <pre>\n * preContext   postContext\n * \"\"           \"\"            The parser does not support context\n * \"let \"       \"=7\"          Pre- and post-context only\n * \"let \"       \"for=7\"       Pre- and post-context and error text\n * \"\"           \"for\"         Error text only\n * </pre>\n *\n * <p>Examples of engines which use UParseError (or may use it in the\n * future) are Transliterator, RuleBasedBreakIterator, and\n * RegexPattern.\n * \n * @stable ICU 2.0\n */\ntypedef struct UParseError {\n\n    /**\n     * The line on which the error occured.  If the parser uses this\n     * field, it sets it to the line number of the source text line on\n     * which the error appears, which will be be a value >= 1.  If the\n     * parse does not support line numbers, the value will be <= 0.\n     * @stable ICU 2.0\n     */\n    int32_t        line;\n\n    /**\n     * The character offset to the error.  If the line field is >= 1,\n     * then this is the offset from the start of the line.  Otherwise,\n     * this is the offset from the start of the text.  If the parser\n     * does not support this field, it will have a value < 0.\n     * @stable ICU 2.0\n     */\n    int32_t        offset;\n\n    /**\n     * Textual context before the error.  Null-terminated.  The empty\n     * string if not supported by parser.\n     * @stable ICU 2.0   \n     */\n    UChar          preContext[U_PARSE_CONTEXT_LEN];\n\n    /**\n     * The error itself and/or textual context after the error.\n     * Null-terminated.  The empty string if not supported by parser.\n     * @stable ICU 2.0   \n     */\n    UChar          postContext[U_PARSE_CONTEXT_LEN];\n\n} UParseError;\n\n#endif\n"
  },
  {
    "path": "deprecated/android/addons/icucompat/unicode/parsepos.h",
    "content": "/*\n* Copyright (C) 1997-2005, International Business Machines Corporation and others. All Rights Reserved.\n*******************************************************************************\n*\n* File PARSEPOS.H\n*\n* Modification History:\n*\n*   Date        Name        Description\n*   07/09/97    helena      Converted from java.\n*   07/17/98    stephen     Added errorIndex support.\n*   05/11/99    stephen     Cleaned up.\n*******************************************************************************\n*/\n\n#ifndef PARSEPOS_H\n#define PARSEPOS_H\n\n#include \"unicode/utypes.h\"\n#include \"unicode/uobject.h\"\n\n \nU_NAMESPACE_BEGIN\n\n/**\n * \\file\n * \\brief C++ API: Canonical Iterator\n */\n/** \n * <code>ParsePosition</code> is a simple class used by <code>Format</code>\n * and its subclasses to keep track of the current position during parsing.\n * The <code>parseObject</code> method in the various <code>Format</code>\n * classes requires a <code>ParsePosition</code> object as an argument.\n *\n * <p>\n * By design, as you parse through a string with different formats,\n * you can use the same <code>ParsePosition</code>, since the index parameter\n * records the current position.\n *\n * The ParsePosition class is not suitable for subclassing.\n *\n * @version     1.3 10/30/97\n * @author      Mark Davis, Helena Shih\n * @see         java.text.Format\n */\n\nclass U_COMMON_API ParsePosition : public UObject {\npublic:\n    /**\n     * Default constructor, the index starts with 0 as default.\n     * @stable ICU 2.0\n     */\n    ParsePosition()\n        : UObject(),\n        index(0),\n        errorIndex(-1)\n      {}\n\n    /**\n     * Create a new ParsePosition with the given initial index.\n     * @param newIndex the new text offset.\n     * @stable ICU 2.0\n     */\n    ParsePosition(int32_t newIndex)\n        : UObject(),\n        index(newIndex),\n        errorIndex(-1)\n      {}\n\n    /**\n     * Copy constructor\n     * @param copy the object to be copied from.\n     * @stable ICU 2.0\n     */\n    ParsePosition(const ParsePosition& copy)\n        : UObject(copy),\n        index(copy.index),\n        errorIndex(copy.errorIndex)\n      {}\n\n    /**\n     * Destructor\n     * @stable ICU 2.0\n     */\n    virtual ~ParsePosition();\n\n    /**\n     * Assignment operator\n     * @stable ICU 2.0\n     */\n    ParsePosition&      operator=(const ParsePosition& copy);\n\n    /**\n     * Equality operator.\n     * @return TRUE if the two parse positions are equal, FALSE otherwise.\n     * @stable ICU 2.0\n     */\n    UBool              operator==(const ParsePosition& that) const;\n\n    /**\n     * Equality operator.\n     * @return TRUE if the two parse positions are not equal, FALSE otherwise.\n     * @stable ICU 2.0\n     */\n    UBool              operator!=(const ParsePosition& that) const;\n\n    /**\n     * Clone this object.\n     * Clones can be used concurrently in multiple threads.\n     * If an error occurs, then NULL is returned.\n     * The caller must delete the clone.\n     *\n     * @return a clone of this object\n     *\n     * @see getDynamicClassID\n     * @stable ICU 2.8\n     */\n    ParsePosition *clone() const;\n\n    /**\n     * Retrieve the current parse position.  On input to a parse method, this\n     * is the index of the character at which parsing will begin; on output, it\n     * is the index of the character following the last character parsed.\n     * @return the current index.\n     * @stable ICU 2.0\n     */\n    int32_t getIndex(void) const;\n\n    /**\n     * Set the current parse position.\n     * @param index the new index.\n     * @stable ICU 2.0\n     */\n    void setIndex(int32_t index);\n\n    /**\n     * Set the index at which a parse error occurred.  Formatters\n     * should set this before returning an error code from their\n     * parseObject method.  The default value is -1 if this is not\n     * set.\n     * @stable ICU 2.0\n     */\n    void setErrorIndex(int32_t ei);\n\n    /**\n     * Retrieve the index at which an error occurred, or -1 if the\n     * error index has not been set.\n     * @stable ICU 2.0\n     */\n    int32_t getErrorIndex(void) const;\n\n    /**\n     * ICU \"poor man's RTTI\", returns a UClassID for this class.\n     *\n     * @stable ICU 2.2\n     */\n    static UClassID U_EXPORT2 getStaticClassID();\n\n    /**\n     * ICU \"poor man's RTTI\", returns a UClassID for the actual class.\n     *\n     * @stable ICU 2.2\n     */\n    virtual UClassID getDynamicClassID() const;\n\nprivate:\n    /**\n     * Input: the place you start parsing.\n     * <br>Output: position where the parse stopped.\n     * This is designed to be used serially,\n     * with each call setting index up for the next one.\n     */\n    int32_t index;\n\n    /**\n     * The index at which a parse error occurred.\n     */\n    int32_t errorIndex;\n\n};\n\ninline ParsePosition&\nParsePosition::operator=(const ParsePosition& copy)\n{\n  index = copy.index;\n  errorIndex = copy.errorIndex;\n  return *this;\n}\n\ninline UBool\nParsePosition::operator==(const ParsePosition& copy) const\n{\n  if(index != copy.index || errorIndex != copy.errorIndex)\n  return FALSE;\n  else\n  return TRUE;\n}\n\ninline UBool\nParsePosition::operator!=(const ParsePosition& copy) const\n{\n  return !operator==(copy);\n}\n\ninline int32_t\nParsePosition::getIndex() const\n{\n  return index;\n}\n\ninline void\nParsePosition::setIndex(int32_t offset)\n{\n  this->index = offset;\n}\n\ninline int32_t\nParsePosition::getErrorIndex() const\n{\n  return errorIndex;\n}\n\ninline void\nParsePosition::setErrorIndex(int32_t ei)\n{\n  this->errorIndex = ei;\n}\nU_NAMESPACE_END\n\n#endif\n"
  },
  {
    "path": "deprecated/android/addons/icucompat/unicode/platform.h",
    "content": "/*\n******************************************************************************\n*\n*   Copyright (C) 1997-2012, International Business Machines\n*   Corporation and others.  All Rights Reserved.\n*\n******************************************************************************\n*\n*  FILE NAME : platform.h\n*\n*   Date        Name        Description\n*   05/13/98    nos         Creation (content moved here from ptypes.h).\n*   03/02/99    stephen     Added AS400 support.\n*   03/30/99    stephen     Added Linux support.\n*   04/13/99    stephen     Reworked for autoconf.\n******************************************************************************\n*/\n\n#ifndef _PLATFORM_H\n#define _PLATFORM_H\n\n#include \"unicode/uconfig.h\"\n#include \"unicode/uvernum.h\"\n\n/**\n * \\file\n * \\brief Basic types for the platform.\n *\n * This file used to be generated by autoconf/configure.\n * Starting with ICU 49, platform.h is a normal source file,\n * to simplify cross-compiling and working with non-autoconf/make build systems.\n *\n * When a value in this file does not work on a platform, then please\n * try to derive it from the U_PLATFORM value\n * (for which we might need a new value constant in rare cases)\n * and/or from other macros that are predefined by the compiler\n * or defined in standard (POSIX or platform or compiler) headers.\n *\n * As a temporary workaround, you can add an explicit <code>#define</code> for some macros\n * before it is first tested, or add an equivalent -D macro definition\n * to the compiler's command line.\n *\n * Note: Some compilers provide ways to show the predefined macros.\n * For example, with gcc you can compile an empty .c file and have the compiler\n * print the predefined macros with\n * \\code\n * gcc -E -dM -x c /dev/null | sort\n * \\endcode\n * (You can provide an actual empty .c file rather than /dev/null.\n * <code>-x c++</code> is for C++.)\n */\n\n/**\n * Define some things so that they can be documented.\n * @internal\n */\n#ifdef U_IN_DOXYGEN\n/*\n * Problem: \"platform.h:335: warning: documentation for unknown define U_HAVE_STD_STRING found.\" means that U_HAVE_STD_STRING is not documented.\n * Solution: #define any defines for non @internal API here, so that they are visible in the docs.  If you just set PREDEFINED in Doxyfile.in,  they won't be documented.\n */\n\n/* None for now. */\n#endif\n\n/**\n * \\def U_PLATFORM\n * The U_PLATFORM macro defines the platform we're on.\n *\n * We used to define one different, value-less macro per platform.\n * That made it hard to know the set of relevant platforms and macros,\n * and hard to deal with variants of platforms.\n *\n * Starting with ICU 49, we define platforms as numeric macros,\n * with ranges of values for related platforms and their variants.\n * The U_PLATFORM macro is set to one of these values.\n *\n * Historical note from the Solaris Wikipedia article:\n * AT&T and Sun collaborated on a project to merge the most popular Unix variants\n * on the market at that time: BSD, System V, and Xenix.\n * This became Unix System V Release 4 (SVR4).\n *\n * @internal\n */\n\n/** Unknown platform. @internal */\n#define U_PF_UNKNOWN 0\n/** Windows @internal */\n#define U_PF_WINDOWS 1000\n/** MinGW. Windows, calls to Win32 API, but using GNU gcc and binutils. @internal */\n#define U_PF_MINGW 1800\n/**\n * Cygwin. Windows, calls to cygwin1.dll for Posix functions,\n * using MSVC or GNU gcc and binutils.\n * @internal\n */\n#define U_PF_CYGWIN 1900\n/* Reserve 2000 for U_PF_UNIX? */\n/** HP-UX is based on UNIX System V. @internal */\n#define U_PF_HPUX 2100\n/** Solaris is a Unix operating system based on SVR4. @internal */\n#define U_PF_SOLARIS 2600\n/** BSD is a UNIX operating system derivative. @internal */\n#define U_PF_BSD 3000\n/** AIX is based on UNIX System V Releases and 4.3 BSD. @internal */\n#define U_PF_AIX 3100\n/** IRIX is based on UNIX System V with BSD extensions. @internal */\n#define U_PF_IRIX 3200\n/**\n * Darwin is a POSIX-compliant operating system, composed of code developed by Apple,\n * as well as code derived from NeXTSTEP, BSD, and other projects,\n * built around the Mach kernel.\n * Darwin forms the core set of components upon which Mac OS X, Apple TV, and iOS are based.\n * (Original description modified from WikiPedia.)\n * @internal\n */\n#define U_PF_DARWIN 3500\n/** iPhone OS (iOS) is a derivative of Mac OS X. @internal */\n#define U_PF_IPHONE 3550\n/** QNX is a commercial Unix-like real-time operating system related to BSD. @internal */\n#define U_PF_QNX 3700\n/** Linux is a Unix-like operating system. @internal */\n#define U_PF_LINUX 4000\n/** Android is based on Linux. @internal */\n#define U_PF_ANDROID 4050\n/** \"Classic\" Mac OS (1984-2001) @internal */\n#define U_PF_CLASSIC_MACOS 8000\n/** z/OS is the successor to OS/390 which was the successor to MVS. @internal */\n#define U_PF_OS390 9000\n/** \"IBM i\" is the current name of what used to be i5/OS and earlier OS/400. @internal */\n#define U_PF_OS400 9400\n\n#ifdef U_PLATFORM\n    /* Use the predefined value. */\n#elif defined(__MINGW32__)\n#   define U_PLATFORM U_PF_MINGW\n#elif defined(__CYGWIN__)\n#   define U_PLATFORM U_PF_CYGWIN\n#elif defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64)\n#   define U_PLATFORM U_PF_WINDOWS\n#elif defined(__ANDROID__)\n#   define U_PLATFORM U_PF_ANDROID\n    /* Android wchar_t support depends on the API level. */\n#   include <android/api-level.h>\n#elif defined(linux) || defined(__linux__) || defined(__linux)\n#   define U_PLATFORM U_PF_LINUX\n#elif defined(BSD) || defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__MirBSD__)\n#   define U_PLATFORM U_PF_BSD\n#elif defined(sun) || defined(__sun)\n    /* Check defined(__SVR4) || defined(__svr4__) to distinguish Solaris from SunOS? */\n#   define U_PLATFORM U_PF_SOLARIS\n#   if defined(__GNUC__)\n        /* Solaris/GCC needs this header file to get the proper endianness. Normally, this\n         * header file is included with stddef.h but on Solairs/GCC, the GCC version of stddef.h\n         *  is included which does not include this header file.\n         */\n#       include <sys/isa_defs.h>\n#   endif\n#elif defined(_AIX) || defined(__TOS_AIX__)\n#   define U_PLATFORM U_PF_AIX\n#elif defined(_hpux) || defined(hpux) || defined(__hpux)\n#   define U_PLATFORM U_PF_HPUX\n#elif defined(sgi) || defined(__sgi)\n#   define U_PLATFORM U_PF_IRIX\n#elif defined(__APPLE__) && defined(__MACH__)\n#   include <TargetConditionals.h>\n#   if defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE  /* variant of TARGET_OS_MAC */\n#       define U_PLATFORM U_PF_IPHONE\n#   else\n#       define U_PLATFORM U_PF_DARWIN\n#   endif\n#elif defined(macintosh)\n#   define U_PLATFORM U_PF_CLASSIC_MACOS\n#elif defined(__QNX__) || defined(__QNXNTO__)\n#   define U_PLATFORM U_PF_QNX\n#elif defined(__TOS_MVS__)\n#   define U_PLATFORM U_PF_OS390\n#elif defined(__OS400__) || defined(__TOS_OS400__)\n#   define U_PLATFORM U_PF_OS400\n#else\n#   define U_PLATFORM U_PF_UNKNOWN\n#endif\n\n/**\n * \\def CYGWINMSVC\n * Defined if this is Windows with Cygwin, but using MSVC rather than gcc.\n * Otherwise undefined.\n * @internal\n */\n/* Commented out because this is already set in mh-cygwin-msvc\n#if U_PLATFORM == U_PF_CYGWIN && defined(_MSC_VER)\n#   define CYGWINMSVC\n#endif\n*/\n\n/**\n * \\def U_PLATFORM_USES_ONLY_WIN32_API\n * Defines whether the platform uses only the Win32 API.\n * Set to 1 for Windows/MSVC and MinGW but not Cygwin.\n * @internal\n */\n#ifdef U_PLATFORM_USES_ONLY_WIN32_API\n    /* Use the predefined value. */\n#elif (U_PF_WINDOWS <= U_PLATFORM && U_PLATFORM <= U_PF_MINGW) || defined(CYGWINMSVC)\n#   define U_PLATFORM_USES_ONLY_WIN32_API 1\n#else\n    /* Cygwin implements POSIX. */\n#   define U_PLATFORM_USES_ONLY_WIN32_API 0\n#endif\n\n/**\n * \\def U_PLATFORM_HAS_WIN32_API\n * Defines whether the Win32 API is available on the platform.\n * Set to 1 for Windows/MSVC, MinGW and Cygwin.\n * @internal\n */\n#ifdef U_PLATFORM_HAS_WIN32_API\n    /* Use the predefined value. */\n#elif U_PF_WINDOWS <= U_PLATFORM && U_PLATFORM <= U_PF_CYGWIN\n#   define U_PLATFORM_HAS_WIN32_API 1\n#else\n#   define U_PLATFORM_HAS_WIN32_API 0\n#endif\n\n/**\n * \\def U_PLATFORM_IMPLEMENTS_POSIX\n * Defines whether the platform implements (most of) the POSIX API.\n * Set to 1 for Cygwin and most other platforms.\n * @internal\n */\n#ifdef U_PLATFORM_IMPLEMENTS_POSIX\n    /* Use the predefined value. */\n#elif U_PLATFORM_USES_ONLY_WIN32_API || U_PLATFORM == U_PF_CLASSIC_MACOS\n#   define U_PLATFORM_IMPLEMENTS_POSIX 0\n#else\n#   define U_PLATFORM_IMPLEMENTS_POSIX 1\n#endif\n\n/**\n * \\def U_PLATFORM_IS_LINUX_BASED\n * Defines whether the platform is Linux or one of its derivatives.\n * @internal\n */\n#ifdef U_PLATFORM_IS_LINUX_BASED\n    /* Use the predefined value. */\n#elif U_PF_LINUX <= U_PLATFORM && U_PLATFORM <= U_PF_ANDROID\n#   define U_PLATFORM_IS_LINUX_BASED 1\n#else\n#   define U_PLATFORM_IS_LINUX_BASED 0\n#endif\n\n/**\n * \\def U_PLATFORM_IS_DARWIN_BASED\n * Defines whether the platform is Darwin or one of its derivatives.\n * @internal\n */\n#ifdef U_PLATFORM_IS_DARWIN_BASED\n    /* Use the predefined value. */\n#elif U_PF_DARWIN <= U_PLATFORM && U_PLATFORM <= U_PF_IPHONE\n#   define U_PLATFORM_IS_DARWIN_BASED 1\n#else\n#   define U_PLATFORM_IS_DARWIN_BASED 0\n#endif\n\n/**\n * \\def U_HAVE_STDINT_H\n * Defines whether stdint.h is available. It is a C99 standard header.\n * We used to include inttypes.h which includes stdint.h but we usually do not need\n * the additional definitions from inttypes.h.\n * @internal\n */\n#ifdef U_HAVE_STDINT_H\n    /* Use the predefined value. */\n#elif U_PLATFORM_USES_ONLY_WIN32_API\n#   if defined(__BORLANDC__) || (defined(_MSC_VER) && _MSC_VER>=1600)\n        /* Windows Visual Studio 9 and below do not have stdint.h & inttypes.h, but VS 2010 adds them. */\n#       define U_HAVE_STDINT_H 1\n#   else\n#       define U_HAVE_STDINT_H 0\n#   endif\n#elif U_PLATFORM == U_PF_SOLARIS\n    /* Solaris has inttypes.h but not stdint.h. */\n#   define U_HAVE_STDINT_H 0\n#elif U_PLATFORM == U_PF_AIX && !defined(_AIX51) && defined(_POWER)\n    /* PPC AIX <= 4.3 has inttypes.h but not stdint.h. */\n#   define U_HAVE_STDINT_H 0\n#else\n#   define U_HAVE_STDINT_H 1\n#endif\n\n/**\n * \\def U_HAVE_INTTYPES_H\n * Defines whether inttypes.h is available. It is a C99 standard header.\n * We include inttypes.h where it is available but stdint.h is not.\n * @internal\n */\n#ifdef U_HAVE_INTTYPES_H\n    /* Use the predefined value. */\n#elif U_PLATFORM == U_PF_SOLARIS\n    /* Solaris has inttypes.h but not stdint.h. */\n#   define U_HAVE_INTTYPES_H 1\n#elif U_PLATFORM == U_PF_AIX && !defined(_AIX51) && defined(_POWER)\n    /* PPC AIX <= 4.3 has inttypes.h but not stdint.h. */\n#   define U_HAVE_INTTYPES_H 1\n#else\n    /* Most platforms have both inttypes.h and stdint.h, or neither. */\n#   define U_HAVE_INTTYPES_H U_HAVE_STDINT_H\n#endif\n\n/**\n * \\def U_IOSTREAM_SOURCE\n * Defines what support for C++ streams is available.\n *\n * If U_IOSTREAM_SOURCE is set to 199711, then &lt;iostream&gt; is available\n * (the ISO/IEC C++ FDIS was published in November 1997), and then\n * one should qualify streams using the std namespace in ICU header\n * files.\n * Starting with ICU 49, this is the only supported version.\n *\n * If U_IOSTREAM_SOURCE is set to 198506, then &lt;iostream.h&gt; is\n * available instead (in June 1985 Stroustrup published\n * \"An Extensible I/O Facility for C++\" at the summer USENIX conference).\n * Starting with ICU 49, this version is not supported any more.\n *\n * If U_IOSTREAM_SOURCE is 0 (or any value less than 199711),\n * then C++ streams are not available and\n * support for them will be silently suppressed in ICU.\n *\n * @internal\n */\n#ifndef U_IOSTREAM_SOURCE\n#define U_IOSTREAM_SOURCE 199711\n#endif\n\n/**\n * \\def U_HAVE_STD_STRING\n * Defines whether the standard C++ (STL) &lt;string&gt; header is available.\n * @internal\n */\n#ifdef U_HAVE_STD_STRING\n    /* Use the predefined value. */\n#elif U_PLATFORM == U_PF_ANDROID\n#   define U_HAVE_STD_STRING 0\n#else\n#   define U_HAVE_STD_STRING 1\n#endif\n\n/*===========================================================================*/\n/** @{ Compiler and environment features                                     */\n/*===========================================================================*/\n\n/**\n * \\def U_GCC_MAJOR_MINOR\n * Indicates whether the compiler is gcc (test for != 0),\n * and if so, contains its major (times 100) and minor version numbers.\n * If the compiler is not gcc, then U_GCC_MAJOR_MINOR == 0.\n *\n * For example, for testing for whether we have gcc, and whether it's 4.6 or higher,\n * use \"#if U_GCC_MAJOR_MINOR >= 406\".\n * @internal\n */\n#ifdef __GNUC__\n#   define U_GCC_MAJOR_MINOR (__GNUC__ * 100 + __GNUC_MINOR__)\n#else\n#   define U_GCC_MAJOR_MINOR 0\n#endif\n\n/**\n * \\def U_IS_BIG_ENDIAN\n * Determines the endianness of the platform.\n * @internal\n */\n#ifdef U_IS_BIG_ENDIAN\n    /* Use the predefined value. */\n#elif defined(BYTE_ORDER) && defined(BIG_ENDIAN)\n#   define U_IS_BIG_ENDIAN (BYTE_ORDER == BIG_ENDIAN)\n#elif defined(__BYTE_ORDER__) && defined(__ORDER_BIG_ENDIAN__)\n    /* gcc */\n#   define U_IS_BIG_ENDIAN (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__)\n#elif defined(__BIG_ENDIAN__) || defined(_BIG_ENDIAN)\n#   define U_IS_BIG_ENDIAN 1\n#elif defined(__LITTLE_ENDIAN__) || defined(_LITTLE_ENDIAN)\n#   define U_IS_BIG_ENDIAN 0\n#elif U_PLATFORM == U_PF_OS390 || U_PLATFORM == U_PF_OS400 || defined(__s390__) || defined(__s390x__)\n    /* These platforms do not appear to predefine any endianness macros. */\n#   define U_IS_BIG_ENDIAN 1\n#elif defined(_PA_RISC1_0) || defined(_PA_RISC1_1) || defined(_PA_RISC2_0)\n    /* HPPA do not appear to predefine any endianness macros. */\n#   define U_IS_BIG_ENDIAN 1\n#elif defined(sparc) || defined(__sparc) || defined(__sparc__)\n    /* Some sparc based systems (e.g. Linux) do not predefine any endianness macros. */\n#   define U_IS_BIG_ENDIAN 1\n#else\n#   define U_IS_BIG_ENDIAN 0\n#endif\n\n/**\n * \\def U_HAVE_PLACEMENT_NEW\n * Determines whether to override placement new and delete for STL.\n * @stable ICU 2.6\n */\n#ifdef U_HAVE_PLACEMENT_NEW\n    /* Use the predefined value. */\n#elif defined(__BORLANDC__)\n#   define U_HAVE_PLACEMENT_NEW 0\n#else\n#   define U_HAVE_PLACEMENT_NEW 1\n#endif\n\n/**\n * \\def U_HAVE_DEBUG_LOCATION_NEW \n * Define this to define the MFC debug version of the operator new.\n *\n * @stable ICU 3.4\n */\n#ifdef U_HAVE_DEBUG_LOCATION_NEW\n    /* Use the predefined value. */\n#elif defined(_MSC_VER)\n#   define U_HAVE_DEBUG_LOCATION_NEW 1\n#else\n#   define U_HAVE_DEBUG_LOCATION_NEW 0\n#endif\n\n/* Compatibility with non clang compilers */\n#ifndef __has_attribute\n#    define __has_attribute(x) 0\n#endif\n\n/**\n * \\def U_MALLOC_ATTR\n * Attribute to mark functions as malloc-like\n * @internal\n */\n#if defined(__GNUC__) && __GNUC__>=3\n#    define U_MALLOC_ATTR __attribute__ ((__malloc__))\n#else\n#    define U_MALLOC_ATTR\n#endif\n\n/**\n * \\def U_ALLOC_SIZE_ATTR\n * Attribute to specify the size of the allocated buffer for malloc-like functions\n * @internal\n */\n#if (defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))) || __has_attribute(alloc_size)\n#   define U_ALLOC_SIZE_ATTR(X) __attribute__ ((alloc_size(X)))\n#   define U_ALLOC_SIZE_ATTR2(X,Y) __attribute__ ((alloc_size(X,Y)))\n#else\n#   define U_ALLOC_SIZE_ATTR(X)\n#   define U_ALLOC_SIZE_ATTR2(X,Y)\n#endif\n\n/** @} */\n\n/*===========================================================================*/\n/** @{ Character data types                                                  */\n/*===========================================================================*/\n\n/**\n * U_CHARSET_FAMILY is equal to this value when the platform is an ASCII based platform.\n * @stable ICU 2.0\n */\n#define U_ASCII_FAMILY 0\n\n/**\n * U_CHARSET_FAMILY is equal to this value when the platform is an EBCDIC based platform.\n * @stable ICU 2.0\n */\n#define U_EBCDIC_FAMILY 1\n\n/**\n * \\def U_CHARSET_FAMILY\n *\n * <p>These definitions allow to specify the encoding of text\n * in the char data type as defined by the platform and the compiler.\n * It is enough to determine the code point values of \"invariant characters\",\n * which are the ones shared by all encodings that are in use\n * on a given platform.</p>\n *\n * <p>Those \"invariant characters\" should be all the uppercase and lowercase\n * latin letters, the digits, the space, and \"basic punctuation\".\n * Also, '\\\\n', '\\\\r', '\\\\t' should be available.</p>\n *\n * <p>The list of \"invariant characters\" is:<br>\n * \\code\n *    A-Z  a-z  0-9  SPACE  \"  %  &amp;  '  (  )  *  +  ,  -  .  /  :  ;  <  =  >  ?  _\n * \\endcode\n * <br>\n * (52 letters + 10 numbers + 20 punc/sym/space = 82 total)</p>\n *\n * <p>This matches the IBM Syntactic Character Set (CS 640).</p>\n *\n * <p>In other words, all the graphic characters in 7-bit ASCII should\n * be safely accessible except the following:</p>\n *\n * \\code\n *    '\\' <backslash>\n *    '[' <left bracket>\n *    ']' <right bracket>\n *    '{' <left brace>\n *    '}' <right brace>\n *    '^' <circumflex>\n *    '~' <tilde>\n *    '!' <exclamation mark>\n *    '#' <number sign>\n *    '|' <vertical line>\n *    '$' <dollar sign>\n *    '@' <commercial at>\n *    '`' <grave accent>\n * \\endcode\n * @stable ICU 2.0\n */\n#ifdef U_CHARSET_FAMILY\n    /* Use the predefined value. */\n#elif U_PLATFORM == U_PF_OS390 && (!defined(__CHARSET_LIB) || !__CHARSET_LIB)\n#   define U_CHARSET_FAMILY U_EBCDIC_FAMILY\n#elif U_PLATFORM == U_PF_OS400 && !defined(__UTF32__)\n#   define U_CHARSET_FAMILY U_EBCDIC_FAMILY\n#else\n#   define U_CHARSET_FAMILY U_ASCII_FAMILY\n#endif\n\n/**\n * \\def U_CHARSET_IS_UTF8\n *\n * Hardcode the default charset to UTF-8.\n *\n * If this is set to 1, then\n * - ICU will assume that all non-invariant char*, StringPiece, std::string etc.\n *   contain UTF-8 text, regardless of what the system API uses\n * - some ICU code will use fast functions like u_strFromUTF8()\n *   rather than the more general and more heavy-weight conversion API (ucnv.h)\n * - ucnv_getDefaultName() always returns \"UTF-8\"\n * - ucnv_setDefaultName() is disabled and will not change the default charset\n * - static builds of ICU are smaller\n * - more functionality is available with the UCONFIG_NO_CONVERSION build-time\n *   configuration option (see unicode/uconfig.h)\n * - the UCONFIG_NO_CONVERSION build option in uconfig.h is more usable\n *\n * @stable ICU 4.2\n * @see UCONFIG_NO_CONVERSION\n */\n#ifdef U_CHARSET_IS_UTF8\n    /* Use the predefined value. */\n#elif U_PLATFORM == U_PF_ANDROID || U_PLATFORM_IS_DARWIN_BASED\n#   define U_CHARSET_IS_UTF8 1\n#else\n#   define U_CHARSET_IS_UTF8 0\n#endif\n\n/** @} */\n\n/*===========================================================================*/\n/** @{ Information about wchar support                                       */\n/*===========================================================================*/\n\n/**\n * \\def U_HAVE_WCHAR_H\n * Indicates whether <wchar.h> is available (1) or not (0). Set to 1 by default.\n *\n * @stable ICU 2.0\n */\n#ifdef U_HAVE_WCHAR_H\n    /* Use the predefined value. */\n#elif U_PLATFORM == U_PF_ANDROID && __ANDROID_API__ < 9\n    /*\n     * Android before Gingerbread (Android 2.3, API level 9) did not support wchar_t.\n     * The type and header existed, but the library functions did not work as expected.\n     * The size of wchar_t was 1 but L\"xyz\" string literals had 32-bit units anyway.\n     */\n#   define U_HAVE_WCHAR_H 0\n#else\n#   define U_HAVE_WCHAR_H 1\n#endif\n\n/**\n * \\def U_SIZEOF_WCHAR_T\n * U_SIZEOF_WCHAR_T==sizeof(wchar_t)\n *\n * @stable ICU 2.0\n */\n#ifdef U_SIZEOF_WCHAR_T\n    /* Use the predefined value. */\n#elif (U_PLATFORM == U_PF_ANDROID && __ANDROID_API__ < 9) || U_PLATFORM == U_PF_CLASSIC_MACOS\n    /*\n     * Classic Mac OS and Mac OS X before 10.3 (Panther) did not support wchar_t or wstring.\n     * Newer Mac OS X has size 4.\n     */\n#   define U_SIZEOF_WCHAR_T 1\n#elif U_PLATFORM_HAS_WIN32_API || U_PLATFORM == U_PF_CYGWIN\n#   define U_SIZEOF_WCHAR_T 2\n#elif U_PLATFORM == U_PF_AIX\n    /*\n     * AIX 6.1 information, section \"Wide character data representation\":\n     * \"... the wchar_t datatype is 32-bit in the 64-bit environment and\n     * 16-bit in the 32-bit environment.\"\n     * and\n     * \"All locales use Unicode for their wide character code values (process code),\n     * except the IBM-eucTW codeset.\"\n     */\n#   ifdef __64BIT__\n#       define U_SIZEOF_WCHAR_T 4\n#   else\n#       define U_SIZEOF_WCHAR_T 2\n#   endif\n#elif U_PLATFORM == U_PF_OS390\n    /*\n     * z/OS V1R11 information center, section \"LP64 | ILP32\":\n     * \"In 31-bit mode, the size of long and pointers is 4 bytes and the size of wchar_t is 2 bytes.\n     * Under LP64, the size of long and pointer is 8 bytes and the size of wchar_t is 4 bytes.\"\n     */\n#   ifdef _LP64\n#       define U_SIZEOF_WCHAR_T 4\n#   else\n#       define U_SIZEOF_WCHAR_T 2\n#   endif\n#elif U_PLATFORM == U_PF_OS400\n#   if defined(__UTF32__)\n        /*\n         * LOCALETYPE(*LOCALEUTF) is specified.\n         * Wide-character strings are in UTF-32,\n         * narrow-character strings are in UTF-8.\n         */\n#       define U_SIZEOF_WCHAR_T 4\n#   elif defined(__UCS2__)\n        /*\n         * LOCALETYPE(*LOCALEUCS2) is specified.\n         * Wide-character strings are in UCS-2,\n         * narrow-character strings are in EBCDIC.\n         */\n#       define U_SIZEOF_WCHAR_T 2\n#else\n        /*\n         * LOCALETYPE(*CLD) or LOCALETYPE(*LOCALE) is specified.\n         * Wide-character strings are in 16-bit EBCDIC,\n         * narrow-character strings are in EBCDIC.\n         */\n#       define U_SIZEOF_WCHAR_T 2\n#   endif\n#else\n#   define U_SIZEOF_WCHAR_T 4\n#endif\n\n#ifndef U_HAVE_WCSCPY\n#define U_HAVE_WCSCPY U_HAVE_WCHAR_H\n#endif\n\n/** @} */\n\n/**\n * \\def U_HAVE_CHAR16_T\n * Defines whether the char16_t type is available for UTF-16\n * and u\"abc\" UTF-16 string literals are supported.\n * This is a new standard type and standard string literal syntax in C++0x\n * but has been available in some compilers before.\n * @internal\n */\n#ifdef U_HAVE_CHAR16_T\n    /* Use the predefined value. */\n#else\n    /*\n     * Notes:\n     * Visual Studio 10 (_MSC_VER>=1600) defines char16_t but\n     * does not support u\"abc\" string literals.\n     * gcc 4.4 defines the __CHAR16_TYPE__ macro to a usable type but\n     * does not support u\"abc\" string literals.\n     * C++11 and C11 require support for UTF-16 literals\n     */\n#   if (defined(__cplusplus) && __cplusplus >= 201103L) || (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L)\n#       define U_HAVE_CHAR16_T 1\n#   else\n#       define U_HAVE_CHAR16_T 0\n#   endif\n#endif\n\n/**\n * @{\n * \\def U_DECLARE_UTF16\n * Do not use this macro because it is not defined on all platforms.\n * Use the UNICODE_STRING or U_STRING_DECL macros instead.\n * @internal\n */\n#ifdef U_DECLARE_UTF16\n    /* Use the predefined value. */\n#elif U_HAVE_CHAR16_T \\\n    || (defined(__xlC__) && defined(__IBM_UTF_LITERAL) && U_SIZEOF_WCHAR_T != 2) \\\n    || (defined(__HP_aCC) && __HP_aCC >= 035000) \\\n    || (defined(__HP_cc) && __HP_cc >= 111106)\n#   define U_DECLARE_UTF16(string) u ## string\n#elif U_SIZEOF_WCHAR_T == 2 \\\n    && (U_CHARSET_FAMILY == 0 || (U_PF_OS390 <= U_PLATFORM && U_PLATFORM <= U_PF_OS400 && defined(__UCS2__)))\n#   define U_DECLARE_UTF16(string) L ## string\n#else\n    /* Leave U_DECLARE_UTF16 undefined. See unistr.h. */\n#endif\n\n/** @} */\n\n/*===========================================================================*/\n/** @{ Symbol import-export control                                          */\n/*===========================================================================*/\n\n#ifdef U_EXPORT\n    /* Use the predefined value. */\n#elif defined(U_STATIC_IMPLEMENTATION)\n#   define U_EXPORT\n#elif defined(__GNUC__)\n#   define U_EXPORT __attribute__((visibility(\"default\")))\n#elif (defined(__SUNPRO_CC) && __SUNPRO_CC >= 0x550) \\\n   || (defined(__SUNPRO_C) && __SUNPRO_C >= 0x550) \n#   define U_EXPORT __global\n/*#elif defined(__HP_aCC) || defined(__HP_cc)\n#   define U_EXPORT __declspec(dllexport)*/\n#elif defined(_MSC_VER)\n#   define U_EXPORT __declspec(dllexport)\n#else\n#   define U_EXPORT\n#endif\n\n/* U_CALLCONV is releated to U_EXPORT2 */\n#ifdef U_EXPORT2\n    /* Use the predefined value. */\n#elif defined(_MSC_VER)\n#   define U_EXPORT2 __cdecl\n#else\n#   define U_EXPORT2\n#endif\n\n#ifdef U_IMPORT\n    /* Use the predefined value. */\n#elif defined(_MSC_VER)\n    /* Windows needs to export/import data. */\n#   define U_IMPORT __declspec(dllimport)\n#else\n#   define U_IMPORT \n#endif\n\n/**\n * \\def U_CALLCONV\n * Similar to U_CDECL_BEGIN/U_CDECL_END, this qualifier is necessary\n * in callback function typedefs to make sure that the calling convention\n * is compatible.\n *\n * This is only used for non-ICU-API functions.\n * When a function is a public ICU API,\n * you must use the U_CAPI and U_EXPORT2 qualifiers.\n * @stable ICU 2.0\n */\n#if U_PLATFORM == U_PF_OS390 && defined(__cplusplus)\n#    define U_CALLCONV __cdecl\n#else\n#    define U_CALLCONV U_EXPORT2\n#endif\n\n/* @} */\n\n#endif\n"
  },
  {
    "path": "deprecated/android/addons/icucompat/unicode/plurfmt.h",
    "content": "/*\n*******************************************************************************\n* Copyright (C) 2007-2012, International Business Machines Corporation and\n* others. All Rights Reserved.\n*******************************************************************************\n*\n\n* File PLURFMT.H\n*\n* Modification History:*\n*   Date        Name        Description\n*\n********************************************************************************\n*/\n\n#ifndef PLURFMT\n#define PLURFMT\n\n#include \"unicode/utypes.h\"\n\n/**\n * \\file\n * \\brief C++ API: PluralFormat object\n */\n\n#if !UCONFIG_NO_FORMATTING\n\n#include \"unicode/messagepattern.h\"\n#include \"unicode/numfmt.h\"\n#include \"unicode/plurrule.h\"\n\nU_NAMESPACE_BEGIN\n\nclass Hashtable;\n\n/**\n * <p>\n * <code>PluralFormat</code> supports the creation of internationalized\n * messages with plural inflection. It is based on <i>plural\n * selection</i>, i.e. the caller specifies messages for each\n * plural case that can appear in the user's language and the\n * <code>PluralFormat</code> selects the appropriate message based on\n * the number.\n * </p>\n * <h4>The Problem of Plural Forms in Internationalized Messages</h4>\n * <p>\n * Different languages have different ways to inflect\n * plurals. Creating internationalized messages that include plural\n * forms is only feasible when the framework is able to handle plural\n * forms of <i>all</i> languages correctly. <code>ChoiceFormat</code>\n * doesn't handle this well, because it attaches a number interval to\n * each message and selects the message whose interval contains a\n * given number. This can only handle a finite number of\n * intervals. But in some languages, like Polish, one plural case\n * applies to infinitely many intervals (e.g., the plural case applies to\n * numbers ending with 2, 3, or 4 except those ending with 12, 13, or\n * 14). Thus <code>ChoiceFormat</code> is not adequate.\n * </p><p>\n * <code>PluralFormat</code> deals with this by breaking the problem\n * into two parts:\n * <ul>\n * <li>It uses <code>PluralRules</code> that can define more complex\n *     conditions for a plural case than just a single interval. These plural\n *     rules define both what plural cases exist in a language, and to\n *     which numbers these cases apply.\n * <li>It provides predefined plural rules for many languages. Thus, the programmer\n *     need not worry about the plural cases of a language and\n *     does not have to define the plural cases; they can simply\n *     use the predefined keywords. The whole plural formatting of messages can\n *     be done using localized patterns from resource bundles. For predefined plural\n *     rules, see the CLDR <i>Language Plural Rules</i> page at\n *    http://unicode.org/repos/cldr-tmp/trunk/diff/supplemental/language_plural_rules.html\n * </ul>\n * </p>\n * <h4>Usage of <code>PluralFormat</code></h4>\n * <p>Note: Typically, plural formatting is done via <code>MessageFormat</code>\n * with a <code>plural</code> argument type,\n * rather than using a stand-alone <code>PluralFormat</code>.\n * </p><p>\n * This discussion assumes that you use <code>PluralFormat</code> with\n * a predefined set of plural rules. You can create one using one of\n * the constructors that takes a <code>locale</code> object. To\n * specify the message pattern, you can either pass it to the\n * constructor or set it explicitly using the\n * <code>applyPattern()</code> method. The <code>format()</code>\n * method takes a number object and selects the message of the\n * matching plural case. This message will be returned.\n * </p>\n * <h5>Patterns and Their Interpretation</h5>\n * <p>\n * The pattern text defines the message output for each plural case of the\n * specified locale. Syntax:\n * <pre>\n * pluralStyle = [offsetValue] (selector '{' message '}')+\n * offsetValue = \"offset:\" number\n * selector = explicitValue | keyword\n * explicitValue = '=' number  // adjacent, no white space in between\n * keyword = [^[[:Pattern_Syntax:][:Pattern_White_Space:]]]+\n * message: see {@link MessageFormat}\n * </pre>\n * Pattern_White_Space between syntax elements is ignored, except\n * between the {curly braces} and their sub-message,\n * and between the '=' and the number of an explicitValue.\n *\n * </p><p>\n * There are 6 predefined casekeyword in CLDR/ICU - 'zero', 'one', 'two', 'few', 'many' and\n * 'other'. You always have to define a message text for the default plural case\n * <code>other</code> which is contained in every rule set.\n * If you do not specify a message text for a particular plural case, the\n * message text of the plural case <code>other</code> gets assigned to this\n * plural case.\n * </p><p>\n * When formatting, the input number is first matched against the explicitValue clauses.\n * If there is no exact-number match, then a keyword is selected by calling\n * the <code>PluralRules</code> with the input number <em>minus the offset</em>.\n * (The offset defaults to 0 if it is omitted from the pattern string.)\n * If there is no clause with that keyword, then the \"other\" clauses is returned.\n * </p><p>\n * An unquoted pound sign (<code>#</code>) in the selected sub-message\n * itself (i.e., outside of arguments nested in the sub-message)\n * is replaced by the input number minus the offset.\n * The number-minus-offset value is formatted using a\n * <code>NumberFormat</code> for the <code>PluralFormat</code>'s locale. If you\n * need special number formatting, you have to use a <code>MessageFormat</code>\n * and explicitly specify a <code>NumberFormat</code> argument.\n * <strong>Note:</strong> That argument is formatting without subtracting the offset!\n * If you need a custom format and have a non-zero offset, then you need to pass the\n * number-minus-offset value as a separate parameter.\n * </p>\n * For a usage example, see the {@link MessageFormat} class documentation.\n *\n * <h4>Defining Custom Plural Rules</h4>\n * <p>If you need to use <code>PluralFormat</code> with custom rules, you can\n * create a <code>PluralRules</code> object and pass it to\n * <code>PluralFormat</code>'s constructor. If you also specify a locale in this\n * constructor, this locale will be used to format the number in the message\n * texts.\n * </p><p>\n * For more information about <code>PluralRules</code>, see\n * {@link PluralRules}.\n * </p>\n *\n * ported from Java\n * @stable ICU 4.0\n */\n\nclass U_I18N_API PluralFormat : public Format {\npublic:\n\n    /**\n     * Creates a new cardinal-number <code>PluralFormat</code> for the default locale.\n     * This locale will be used to get the set of plural rules and for standard\n     * number formatting.\n     * @param status  output param set to success/failure code on exit, which\n     *                must not indicate a failure before the function call.\n     * @stable ICU 4.0\n     */\n    PluralFormat(UErrorCode& status);\n\n    /**\n     * Creates a new cardinal-number <code>PluralFormat</code> for a given locale.\n     * @param locale the <code>PluralFormat</code> will be configured with\n     *               rules for this locale. This locale will also be used for\n     *               standard number formatting.\n     * @param status output param set to success/failure code on exit, which\n     *               must not indicate a failure before the function call.\n     * @stable ICU 4.0\n     */\n    PluralFormat(const Locale& locale, UErrorCode& status);\n\n    /**\n     * Creates a new <code>PluralFormat</code> for a given set of rules.\n     * The standard number formatting will be done using the default locale.\n     * @param rules   defines the behavior of the <code>PluralFormat</code>\n     *                object.\n     * @param status  output param set to success/failure code on exit, which\n     *                must not indicate a failure before the function call.\n     * @stable ICU 4.0\n     */\n    PluralFormat(const PluralRules& rules, UErrorCode& status);\n\n    /**\n     * Creates a new <code>PluralFormat</code> for a given set of rules.\n     * The standard number formatting will be done using the given locale.\n     * @param locale  the default number formatting will be done using this\n     *                locale.\n     * @param rules   defines the behavior of the <code>PluralFormat</code>\n     *                object.\n     * @param status  output param set to success/failure code on exit, which\n     *                must not indicate a failure before the function call.\n     * @stable ICU 4.0\n     */\n    PluralFormat(const Locale& locale, const PluralRules& rules, UErrorCode& status);\n\n    /**\n     * Creates a new <code>PluralFormat</code> for the plural type.\n     * The standard number formatting will be done using the given locale.\n     * @param locale  the default number formatting will be done using this\n     *                locale.\n     * @param type    The plural type (e.g., cardinal or ordinal).\n     * @param status  output param set to success/failure code on exit, which\n     *                must not indicate a failure before the function call.\n     * @draft ICU 50\n     */\n    PluralFormat(const Locale& locale, UPluralType type, UErrorCode& status);\n\n    /**\n     * Creates a new cardinal-number <code>PluralFormat</code> for a given pattern string.\n     * The default locale will be used to get the set of plural rules and for\n     * standard number formatting.\n     * @param  pattern the pattern for this <code>PluralFormat</code>.\n     *                 errors are returned to status if the pattern is invalid.\n     * @param status   output param set to success/failure code on exit, which\n     *                 must not indicate a failure before the function call.\n     * @stable ICU 4.0\n     */\n    PluralFormat(const UnicodeString& pattern, UErrorCode& status);\n\n    /**\n     * Creates a new cardinal-number <code>PluralFormat</code> for a given pattern string and\n     * locale.\n     * The locale will be used to get the set of plural rules and for\n     * standard number formatting.\n     * @param locale   the <code>PluralFormat</code> will be configured with\n     *                 rules for this locale. This locale will also be used for\n     *                 standard number formatting.\n     * @param pattern  the pattern for this <code>PluralFormat</code>.\n     *                 errors are returned to status if the pattern is invalid.\n     * @param status   output param set to success/failure code on exit, which\n     *                 must not indicate a failure before the function call.\n     * @stable ICU 4.0\n     */\n    PluralFormat(const Locale& locale, const UnicodeString& pattern, UErrorCode& status);\n\n    /**\n     * Creates a new <code>PluralFormat</code> for a given set of rules, a\n     * pattern and a locale.\n     * @param rules    defines the behavior of the <code>PluralFormat</code>\n     *                 object.\n     * @param pattern  the pattern for this <code>PluralFormat</code>.\n     *                 errors are returned to status if the pattern is invalid.\n     * @param status   output param set to success/failure code on exit, which\n     *                 must not indicate a failure before the function call.\n     * @stable ICU 4.0\n     */\n    PluralFormat(const PluralRules& rules,\n                 const UnicodeString& pattern,\n                 UErrorCode& status);\n\n    /**\n     * Creates a new <code>PluralFormat</code> for a given set of rules, a\n     * pattern and a locale.\n     * @param locale  the <code>PluralFormat</code> will be configured with\n     *                rules for this locale. This locale will also be used for\n     *                standard number formatting.\n     * @param rules   defines the behavior of the <code>PluralFormat</code>\n     *                object.\n     * @param pattern the pattern for this <code>PluralFormat</code>.\n     *                errors are returned to status if the pattern is invalid.\n     * @param status  output param set to success/failure code on exit, which\n     *                must not indicate a failure before the function call.\n     * @stable ICU 4.0\n     */\n    PluralFormat(const Locale& locale,\n                 const PluralRules& rules,\n                 const UnicodeString& pattern,\n                 UErrorCode& status);\n\n    /**\n     * Creates a new <code>PluralFormat</code> for a plural type, a\n     * pattern and a locale.\n     * @param locale  the <code>PluralFormat</code> will be configured with\n     *                rules for this locale. This locale will also be used for\n     *                standard number formatting.\n     * @param type    The plural type (e.g., cardinal or ordinal).\n     * @param pattern the pattern for this <code>PluralFormat</code>.\n     *                errors are returned to status if the pattern is invalid.\n     * @param status  output param set to success/failure code on exit, which\n     *                must not indicate a failure before the function call.\n     * @draft ICU 50\n     */\n    PluralFormat(const Locale& locale,\n                 UPluralType type,\n                 const UnicodeString& pattern,\n                 UErrorCode& status);\n\n    /**\n      * copy constructor.\n      * @stable ICU 4.0\n      */\n    PluralFormat(const PluralFormat& other);\n\n    /**\n     * Destructor.\n     * @stable ICU 4.0\n     */\n    virtual ~PluralFormat();\n\n    /**\n     * Sets the pattern used by this plural format.\n     * The method parses the pattern and creates a map of format strings\n     * for the plural rules.\n     * Patterns and their interpretation are specified in the class description.\n     *\n     * @param pattern the pattern for this plural format\n     *                errors are returned to status if the pattern is invalid.\n     * @param status  output param set to success/failure code on exit, which\n     *                must not indicate a failure before the function call.\n     * @stable ICU 4.0\n     */\n    void applyPattern(const UnicodeString& pattern, UErrorCode& status);\n\n\n    using Format::format;\n\n    /**\n     * Formats a plural message for a given number.\n     *\n     * @param number  a number for which the plural message should be formatted\n     *                for. If no pattern has been applied to this\n     *                <code>PluralFormat</code> object yet, the formatted number\n     *                will be returned.\n     * @param status  output param set to success/failure code on exit, which\n     *                must not indicate a failure before the function call.\n     * @return        the string containing the formatted plural message.\n     * @stable ICU 4.0\n     */\n    UnicodeString format(int32_t number, UErrorCode& status) const;\n\n    /**\n     * Formats a plural message for a given number.\n     *\n     * @param number  a number for which the plural message should be formatted\n     *                for. If no pattern has been applied to this\n     *                PluralFormat object yet, the formatted number\n     *                will be returned.\n     * @param status  output param set to success or failure code on exit, which\n     *                must not indicate a failure before the function call.\n     * @return        the string containing the formatted plural message.\n     * @stable ICU 4.0\n     */\n    UnicodeString format(double number, UErrorCode& status) const;\n\n    /**\n     * Formats a plural message for a given number.\n     *\n     * @param number   a number for which the plural message should be formatted\n     *                 for. If no pattern has been applied to this\n     *                 <code>PluralFormat</code> object yet, the formatted number\n     *                 will be returned.\n     * @param appendTo output parameter to receive result.\n     *                 result is appended to existing contents.\n     * @param pos      On input: an alignment field, if desired.\n     *                 On output: the offsets of the alignment field.\n     * @param status   output param set to success/failure code on exit, which\n     *                 must not indicate a failure before the function call.\n     * @return         the string containing the formatted plural message.\n     * @stable ICU 4.0\n     */\n    UnicodeString& format(int32_t number,\n                          UnicodeString& appendTo,\n                          FieldPosition& pos,\n                          UErrorCode& status) const;\n\n    /**\n     * Formats a plural message for a given number.\n     *\n     * @param number   a number for which the plural message should be formatted\n     *                 for. If no pattern has been applied to this\n     *                 PluralFormat object yet, the formatted number\n     *                 will be returned.\n     * @param appendTo output parameter to receive result.\n     *                 result is appended to existing contents.\n     * @param pos      On input: an alignment field, if desired.\n     *                 On output: the offsets of the alignment field.\n     * @param status   output param set to success/failure code on exit, which\n     *                 must not indicate a failure before the function call.\n     * @return         the string containing the formatted plural message.\n     * @stable ICU 4.0\n     */\n    UnicodeString& format(double number,\n                          UnicodeString& appendTo,\n                          FieldPosition& pos,\n                          UErrorCode& status) const;\n\n    /**\n     * Sets the locale used by this <code>PluraFormat</code> object.\n     * Note: Calling this method resets this <code>PluraFormat</code> object,\n     *     i.e., a pattern that was applied previously will be removed,\n     *     and the NumberFormat is set to the default number format for\n     *     the locale.  The resulting format behaves the same as one\n     *     constructed from {@link #PluralFormat(const Locale& locale, UPluralType type, UErrorCode& status)}\n     *     with UPLURAL_TYPE_CARDINAL.\n     * @param locale  the <code>locale</code> to use to configure the formatter.\n     * @param status  output param set to success/failure code on exit, which\n     *                must not indicate a failure before the function call.\n     * @deprecated ICU 50 This method clears the pattern and might create\n     *             a different kind of PluralRules instance;\n     *             use one of the constructors to create a new instance instead.\n     */\n    void setLocale(const Locale& locale, UErrorCode& status);\n\n    /**\n      * Sets the number format used by this formatter.  You only need to\n      * call this if you want a different number format than the default\n      * formatter for the locale.\n      * @param format  the number format to use.\n      * @param status  output param set to success/failure code on exit, which\n      *                must not indicate a failure before the function call.\n      * @stable ICU 4.0\n      */\n    void setNumberFormat(const NumberFormat* format, UErrorCode& status);\n\n    /**\n       * Assignment operator\n       *\n       * @param other    the PluralFormat object to copy from.\n       * @stable ICU 4.0\n       */\n    PluralFormat& operator=(const PluralFormat& other);\n\n    /**\n      * Return true if another object is semantically equal to this one.\n      *\n      * @param other    the PluralFormat object to be compared with.\n      * @return         true if other is semantically equal to this.\n      * @stable ICU 4.0\n      */\n    virtual UBool operator==(const Format& other) const;\n\n    /**\n     * Return true if another object is semantically unequal to this one.\n     *\n     * @param other    the PluralFormat object to be compared with.\n     * @return         true if other is semantically unequal to this.\n     * @stable ICU 4.0\n     */\n    virtual UBool operator!=(const Format& other) const;\n\n    /**\n     * Clones this Format object polymorphically.  The caller owns the\n     * result and should delete it when done.\n     * @stable ICU 4.0\n     */\n    virtual Format* clone(void) const;\n\n    /**\n    * Redeclared Format method.\n    *\n    * @param obj       The object to be formatted into a string.\n    * @param appendTo  output parameter to receive result.\n    *                  Result is appended to existing contents.\n    * @param pos       On input: an alignment field, if desired.\n    *                  On output: the offsets of the alignment field.\n    * @param status    output param filled with success/failure status.\n    * @return          Reference to 'appendTo' parameter.\n    * @stable ICU 4.0\n    */\n   UnicodeString& format(const Formattable& obj,\n                         UnicodeString& appendTo,\n                         FieldPosition& pos,\n                         UErrorCode& status) const;\n\n   /**\n    * Returns the pattern from applyPattern() or constructor().\n    *\n    * @param  appendTo  output parameter to receive result.\n     *                  Result is appended to existing contents.\n    * @return the UnicodeString with inserted pattern.\n    * @stable ICU 4.0\n    */\n   UnicodeString& toPattern(UnicodeString& appendTo);\n\n   /**\n    * This method is not yet supported by <code>PluralFormat</code>.\n    * <P>\n    * Before calling, set parse_pos.index to the offset you want to start\n    * parsing at in the source. After calling, parse_pos.index is the end of\n    * the text you parsed. If error occurs, index is unchanged.\n    * <P>\n    * When parsing, leading whitespace is discarded (with a successful parse),\n    * while trailing whitespace is left as is.\n    * <P>\n    * See Format::parseObject() for more.\n    *\n    * @param source    The string to be parsed into an object.\n    * @param result    Formattable to be set to the parse result.\n    *                  If parse fails, return contents are undefined.\n    * @param parse_pos The position to start parsing at. Upon return\n    *                  this param is set to the position after the\n    *                  last character successfully parsed. If the\n    *                  source is not parsed successfully, this param\n    *                  will remain unchanged.\n    * @stable ICU 4.0\n    */\n   virtual void parseObject(const UnicodeString& source,\n                            Formattable& result,\n                            ParsePosition& parse_pos) const;\n\n    /**\n     * ICU \"poor man's RTTI\", returns a UClassID for this class.\n     *\n     * @stable ICU 4.0\n     *\n     */\n    static UClassID U_EXPORT2 getStaticClassID(void);\n\n    /**\n     * ICU \"poor man's RTTI\", returns a UClassID for the actual class.\n     *\n     * @stable ICU 4.0\n     */\n     virtual UClassID getDynamicClassID() const;\n\n#if (defined(__xlC__) && (__xlC__ < 0x0C00)) || (U_PLATFORM == U_PF_OS390) || (U_PLATFORM ==U_PF_OS400)\n// Work around a compiler bug on xlC 11.1 on AIX 7.1 that would\n// prevent PluralSelectorAdapter from implementing private PluralSelector.\n// xlC error message:\n// 1540-0300 (S) The \"private\" member \"class icu_49::PluralFormat::PluralSelector\" cannot be accessed.\npublic:\n#else\nprivate:\n#endif\n     /**\n      * @internal \n      */\n    class U_I18N_API PluralSelector : public UMemory {\n      public:\n        virtual ~PluralSelector();\n        /**\n         * Given a number, returns the appropriate PluralFormat keyword.\n         *\n         * @param number The number to be plural-formatted.\n         * @param ec Error code.\n         * @return The selected PluralFormat keyword.\n         */\n        virtual UnicodeString select(double number, UErrorCode& ec) const = 0;\n    };\n\n    /**\n     * @internal\n     */\n    class U_I18N_API PluralSelectorAdapter : public PluralSelector {\n      public:\n        PluralSelectorAdapter() : pluralRules(NULL) {\n        }\n\n        virtual ~PluralSelectorAdapter();\n\n        virtual UnicodeString select(double number, UErrorCode& /*ec*/) const;\n\n        void reset();\n\n        PluralRules* pluralRules;\n    };\n\n#if defined(__xlC__)\n// End of xlC bug workaround, keep remaining definitions private.\nprivate:\n#endif\n    Locale  locale;\n    MessagePattern msgPattern;\n    NumberFormat*  numberFormat;\n    double offset;\n    PluralSelectorAdapter pluralRulesWrapper;\n\n    PluralFormat();   // default constructor not implemented\n    void init(const PluralRules* rules, UPluralType type, UErrorCode& status);\n    /**\n     * Copies dynamically allocated values (pointer fields).\n     * Others are copied using their copy constructors and assignment operators.\n     */\n    void copyObjects(const PluralFormat& other);\n\n    /**\n     * Finds the PluralFormat sub-message for the given number, or the \"other\" sub-message.\n     * @param pattern A MessagePattern.\n     * @param partIndex the index of the first PluralFormat argument style part.\n     * @param selector the PluralSelector for mapping the number (minus offset) to a keyword.\n     * @param number a number to be matched to one of the PluralFormat argument's explicit values,\n     *        or mapped via the PluralSelector.\n     * @param ec ICU error code.\n     * @return the sub-message start part index.\n     */\n    static int32_t findSubMessage(\n         const MessagePattern& pattern, int32_t partIndex,\n         const PluralSelector& selector, double number, UErrorCode& ec);\n\n    friend class MessageFormat;\n};\n\nU_NAMESPACE_END\n\n#endif /* #if !UCONFIG_NO_FORMATTING */\n\n#endif // _PLURFMT\n//eof\n"
  },
  {
    "path": "deprecated/android/addons/icucompat/unicode/plurrule.h",
    "content": "/*\n*******************************************************************************\n* Copyright (C) 2008-2012, International Business Machines Corporation and\n* others. All Rights Reserved.\n*******************************************************************************\n*\n*\n* File PLURRULE.H\n*\n* Modification History:*\n*   Date        Name        Description\n*\n********************************************************************************\n*/\n\n#ifndef PLURRULE\n#define PLURRULE\n\n#include \"unicode/utypes.h\"\n\n/**\n * \\file\n * \\brief C++ API: PluralRules object\n */\n\n#if !UCONFIG_NO_FORMATTING\n\n#include \"unicode/format.h\"\n#include \"unicode/upluralrules.h\"\n\n/**\n * Value returned by PluralRules::getUniqueKeywordValue() when there is no\n * unique value to return.\n * @stable ICU 4.8\n */\n#define UPLRULES_NO_UNIQUE_VALUE ((double)-0.00123456777)\n\nU_NAMESPACE_BEGIN\n\nclass Hashtable;\nclass RuleChain;\nclass RuleParser;\nclass PluralKeywordEnumeration;\n\n/**\n * Defines rules for mapping non-negative numeric values onto a small set of\n * keywords. Rules are constructed from a text description, consisting\n * of a series of keywords and conditions.  The {@link #select} method\n * examines each condition in order and returns the keyword for the\n * first condition that matches the number.  If none match,\n * default rule(other) is returned.\n *\n * For more information, details, and tips for writing rules, see the\n * LDML spec, C.11 Language Plural Rules:\n * http://www.unicode.org/draft/reports/tr35/tr35.html#Language_Plural_Rules\n *\n * Examples:<pre>\n *   \"one: n is 1; few: n in 2..4\"</pre>\n *  This defines two rules, for 'one' and 'few'.  The condition for\n *  'one' is \"n is 1\" which means that the number must be equal to\n *  1 for this condition to pass.  The condition for 'few' is\n *  \"n in 2..4\" which means that the number must be between 2 and\n *  4 inclusive for this condition to pass.  All other numbers\n *  are assigned the keyword \"other\" by the default rule.\n *  </p><pre>\n *    \"zero: n is 0; one: n is 1; zero: n mod 100 in 1..19\"</pre>\n *  This illustrates that the same keyword can be defined multiple times.\n *  Each rule is examined in order, and the first keyword whose condition\n *  passes is the one returned.  Also notes that a modulus is applied\n *  to n in the last rule.  Thus its condition holds for 119, 219, 319...\n *  </p><pre>\n *    \"one: n is 1; few: n mod 10 in 2..4 and n mod 100 not in 12..14\"</pre>\n *  This illustrates conjunction and negation.  The condition for 'few'\n *  has two parts, both of which must be met: \"n mod 10 in 2..4\" and\n *  \"n mod 100 not in 12..14\".  The first part applies a modulus to n\n *  before the test as in the previous example.  The second part applies\n *  a different modulus and also uses negation, thus it matches all\n *  numbers _not_ in 12, 13, 14, 112, 113, 114, 212, 213, 214...\n *  </p>\n *  <p>\n * Syntax:<pre>\n * \\code\n * rules         = rule (';' rule)*\n * rule          = keyword ':' condition\n * keyword       = <identifier>\n * condition     = and_condition ('or' and_condition)*\n * and_condition = relation ('and' relation)*\n * relation      = is_relation | in_relation | within_relation | 'n' <EOL>\n * is_relation   = expr 'is' ('not')? value\n * in_relation   = expr ('not')? 'in' range_list\n * within_relation = expr ('not')? 'within' range\n * expr          = 'n' ('mod' value)?\n * range_list    = (range | value) (',' range_list)*\n * value         = digit+\n * digit         = 0|1|2|3|4|5|6|7|8|9\n * range         = value'..'value\n * \\endcode\n * </pre></p>\n * <p>\n * An \"identifier\" is a sequence of characters that do not have the\n * Unicode Pattern_Syntax or Pattern_White_Space properties.\n * <p>\n * The difference between 'in' and 'within' is that 'in' only includes\n * integers in the specified range, while 'within' includes all values.</p>\n * <p>\n * Keywords\n * could be defined by users or from ICU locale data. There are 6\n * predefined values in ICU - 'zero', 'one', 'two', 'few', 'many' and\n * 'other'. Callers need to check the value of keyword returned by\n * {@link #select} method.\n * </p>\n *\n * Examples:<pre>\n * UnicodeString keyword = pl->select(number);\n * if (keyword== UnicodeString(\"one\") {\n *     ...\n * }\n * else if ( ... )\n * </pre>\n * <strong>Note:</strong><br>\n *  <p>\n *   ICU defines plural rules for many locales based on CLDR <i>Language Plural Rules</i>.\n *   For these predefined rules, see CLDR page at\n *    http://unicode.org/repos/cldr-tmp/trunk/diff/supplemental/language_plural_rules.html\n * </p>\n */\nclass U_I18N_API PluralRules : public UObject {\npublic:\n\n    /**\n     * Constructor.\n     * @param status  Output param set to success/failure code on exit, which\n     *                must not indicate a failure before the function call.\n     *\n     * @stable ICU 4.0\n     */\n    PluralRules(UErrorCode& status);\n\n    /**\n     * Copy constructor.\n     * @stable ICU 4.0\n     */\n    PluralRules(const PluralRules& other);\n\n    /**\n     * Destructor.\n     * @stable ICU 4.0\n     */\n    virtual ~PluralRules();\n\n    /**\n     * Clone\n     * @stable ICU 4.0\n     */\n    PluralRules* clone() const;\n\n    /**\n      * Assignment operator.\n      * @stable ICU 4.0\n      */\n    PluralRules& operator=(const PluralRules&);\n\n    /**\n     * Creates a PluralRules from a description if it is parsable, otherwise\n     * returns NULL.\n     *\n     * @param description rule description\n     * @param status      Output param set to success/failure code on exit, which\n     *                    must not indicate a failure before the function call.\n     * @return            new PluralRules pointer. NULL if there is an error.\n     * @stable ICU 4.0\n     */\n    static PluralRules* U_EXPORT2 createRules(const UnicodeString& description,\n                                              UErrorCode& status);\n\n    /**\n     * The default rules that accept any number.\n     *\n     * @param status  Output param set to success/failure code on exit, which\n     *                must not indicate a failure before the function call.\n     * @return        new PluralRules pointer. NULL if there is an error.\n     * @stable ICU 4.0\n     */\n    static PluralRules* U_EXPORT2 createDefaultRules(UErrorCode& status);\n\n    /**\n     * Provides access to the predefined cardinal-number <code>PluralRules</code> for a given\n     * locale.\n     * Same as forLocale(locale, UPLURAL_TYPE_CARDINAL, status).\n     *\n     * @param locale  The locale for which a <code>PluralRules</code> object is\n     *                returned.\n     * @param status  Output param set to success/failure code on exit, which\n     *                must not indicate a failure before the function call.\n     * @return        The predefined <code>PluralRules</code> object pointer for\n     *                this locale. If there's no predefined rules for this locale,\n     *                the rules for the closest parent in the locale hierarchy\n     *                that has one will  be returned.  The final fallback always\n     *                returns the default 'other' rules.\n     * @stable ICU 4.0\n     */\n    static PluralRules* U_EXPORT2 forLocale(const Locale& locale, UErrorCode& status);\n\n    /**\n     * Provides access to the predefined <code>PluralRules</code> for a given\n     * locale and the plural type.\n     *\n     * @param locale  The locale for which a <code>PluralRules</code> object is\n     *                returned.\n     * @param type    The plural type (e.g., cardinal or ordinal).\n     * @param status  Output param set to success/failure code on exit, which\n     *                must not indicate a failure before the function call.\n     * @return        The predefined <code>PluralRules</code> object pointer for\n     *                this locale. If there's no predefined rules for this locale,\n     *                the rules for the closest parent in the locale hierarchy\n     *                that has one will  be returned.  The final fallback always\n     *                returns the default 'other' rules.\n     * @draft ICU 50\n     */\n    static PluralRules* U_EXPORT2 forLocale(const Locale& locale, UPluralType type, UErrorCode& status);\n\n    /**\n     * Given a number, returns the keyword of the first rule that applies to\n     * the number.  This function can be used with isKeyword* functions to\n     * determine the keyword for default plural rules.\n     *\n     * @param number  The number for which the rule has to be determined.\n     * @return        The keyword of the selected rule.\n     * @stable ICU 4.0\n     */\n    UnicodeString select(int32_t number) const;\n\n    /**\n     * Given a number, returns the keyword of the first rule that applies to\n     * the number.  This function can be used with isKeyword* functions to\n     * determine the keyword for default plural rules.\n     *\n     * @param number  The number for which the rule has to be determined.\n     * @return        The keyword of the selected rule.\n     * @stable ICU 4.0\n     */\n    UnicodeString select(double number) const;\n\n    /**\n     * Returns a list of all rule keywords used in this <code>PluralRules</code>\n     * object.  The rule 'other' is always present by default.\n     *\n     * @param status Output param set to success/failure code on exit, which\n     *               must not indicate a failure before the function call.\n     * @return       StringEnumeration with the keywords.\n     *               The caller must delete the object.\n     * @stable ICU 4.0\n     */\n    StringEnumeration* getKeywords(UErrorCode& status) const;\n\n    /**\n     * Returns a unique value for this keyword if it exists, else the constant\n     * UPLRULES_NO_UNIQUE_VALUE.\n     *\n     * @param keyword The keyword.\n     * @return        The unique value that generates the keyword, or\n     *                UPLRULES_NO_UNIQUE_VALUE if the keyword is undefined or there is no\n     *                unique value that generates this keyword.\n     * @stable ICU 4.8\n     */\n    double getUniqueKeywordValue(const UnicodeString& keyword);\n\n    /**\n     * Returns all the values for which select() would return the keyword.  If\n     * the keyword is unknown, returns no values, but this is not an error.  If\n     * the number of values is unlimited, returns no values and -1 as the\n     * count.\n     *\n     * The number of returned values is typically small.\n     *\n     * @param keyword      The keyword.\n     * @param dest         Array into which to put the returned values.  May\n     *                     be NULL if destCapacity is 0.\n     * @param destCapacity The capacity of the array, must be at least 0.\n     * @param status       The error code.\n     * @return             The count of values available, or -1.  This count\n     *                     can be larger than destCapacity, but no more than\n     *                     destCapacity values will be written.\n     * @stable ICU 4.8\n     */\n    int32_t getAllKeywordValues(const UnicodeString &keyword,\n                                double *dest, int32_t destCapacity,\n                                UErrorCode& status);\n\n    /**\n     * Returns sample values for which select() would return the keyword.  If\n     * the keyword is unknown, returns no values, but this is not an error.\n     *\n     * The number of returned values is typically small.\n     *\n     * @param keyword      The keyword.\n     * @param dest         Array into which to put the returned values.  May\n     *                     be NULL if destCapacity is 0.\n     * @param destCapacity The capacity of the array, must be at least 0.\n     * @param status       The error code.\n     * @return             The count of values written.\n     *                     If more than destCapacity samples are available, then\n     *                     only destCapacity are written, and destCapacity is returned as the count,\n     *                     rather than setting a U_BUFFER_OVERFLOW_ERROR.\n     *                     (The actual number of keyword values could be unlimited.)\n     * @stable ICU 4.8\n     */\n    int32_t getSamples(const UnicodeString &keyword,\n                       double *dest, int32_t destCapacity,\n                       UErrorCode& status);\n\n    /**\n     * Returns TRUE if the given keyword is defined in this\n     * <code>PluralRules</code> object.\n     *\n     * @param keyword  the input keyword.\n     * @return         TRUE if the input keyword is defined.\n     *                 Otherwise, return FALSE.\n     * @stable ICU 4.0\n     */\n    UBool isKeyword(const UnicodeString& keyword) const;\n\n\n    /**\n     * Returns keyword for default plural form.\n     *\n     * @return         keyword for default plural form.\n     * @stable ICU 4.0\n     */\n    UnicodeString getKeywordOther() const;\n\n    /**\n     * Compares the equality of two PluralRules objects.\n     *\n     * @param other The other PluralRules object to be compared with.\n     * @return      True if the given PluralRules is the same as this\n     *              PluralRules; false otherwise.\n     * @stable ICU 4.0\n     */\n    virtual UBool operator==(const PluralRules& other) const;\n\n    /**\n     * Compares the inequality of two PluralRules objects.\n     *\n     * @param other The PluralRules object to be compared with.\n     * @return      True if the given PluralRules is not the same as this\n     *              PluralRules; false otherwise.\n     * @stable ICU 4.0\n     */\n    UBool operator!=(const PluralRules& other) const  {return !operator==(other);}\n\n\n    /**\n     * ICU \"poor man's RTTI\", returns a UClassID for this class.\n     *\n     * @stable ICU 4.0\n     *\n    */\n    static UClassID U_EXPORT2 getStaticClassID(void);\n\n    /**\n     * ICU \"poor man's RTTI\", returns a UClassID for the actual class.\n     *\n     * @stable ICU 4.0\n     */\n    virtual UClassID getDynamicClassID() const;\n\n\nprivate:\n    RuleChain  *mRules;\n    RuleParser *mParser;\n    double     *mSamples;\n    int32_t    *mSampleInfo;\n    int32_t    mSampleInfoCount;\n\n    PluralRules();   // default constructor not implemented\n    int32_t getRepeatLimit() const;\n    void parseDescription(UnicodeString& ruleData, RuleChain& rules, UErrorCode &status);\n    void getNextLocale(const UnicodeString& localeData, int32_t* curIndex, UnicodeString& localeName);\n    void addRules(RuleChain& rules);\n    int32_t getNumberValue(const UnicodeString& token) const;\n    UnicodeString getRuleFromResource(const Locale& locale, UPluralType type, UErrorCode& status);\n\n    static const int32_t MAX_SAMPLES = 3;\n\n    int32_t getSamplesInternal(const UnicodeString &keyword, double *dest,\n                               int32_t destCapacity, UBool includeUnlimited,\n                               UErrorCode& status);\n    int32_t getKeywordIndex(const UnicodeString& keyword,\n                            UErrorCode& status) const;\n    void initSamples(UErrorCode& status);\n\n};\n\nU_NAMESPACE_END\n\n#endif /* #if !UCONFIG_NO_FORMATTING */\n\n#endif // _PLURRULE\n//eof\n"
  },
  {
    "path": "deprecated/android/addons/icucompat/unicode/ptypes.h",
    "content": "/*\n******************************************************************************\n*\n*   Copyright (C) 1997-2012, International Business Machines\n*   Corporation and others.  All Rights Reserved.\n*\n******************************************************************************\n*\n*  FILE NAME : ptypes.h\n*\n*   Date        Name        Description\n*   05/13/98    nos         Creation (content moved here from ptypes.h).\n*   03/02/99    stephen     Added AS400 support.\n*   03/30/99    stephen     Added Linux support.\n*   04/13/99    stephen     Reworked for autoconf.\n*   09/18/08    srl         Moved basic types back to ptypes.h from platform.h\n******************************************************************************\n*/\n\n/**\n * \\file\n * \\brief C API: Definitions of integer types of various widths\n */\n\n#ifndef _PTYPES_H\n#define _PTYPES_H\n\n/**\n * \\def __STDC_LIMIT_MACROS\n * According to the Linux stdint.h, the ISO C99 standard specifies that in C++ implementations\n * macros like INT32_MIN and UINTPTR_MAX should only be defined if explicitly requested.\n * We need to define __STDC_LIMIT_MACROS before including stdint.h in C++ code\n * that uses such limit macros.\n * @internal\n */\n#ifndef __STDC_LIMIT_MACROS\n#define __STDC_LIMIT_MACROS\n#endif\n\n/* NULL, size_t, wchar_t */\n#include <stddef.h>\n\n/*\n * If all compilers provided all of the C99 headers and types,\n * we would just unconditionally #include <stdint.h> here\n * and not need any of the stuff after including platform.h.\n */\n\n/* Find out if we have stdint.h etc. */\n#include \"unicode/platform.h\"\n\n/*===========================================================================*/\n/* Generic data types                                                        */\n/*===========================================================================*/\n\n/* If your platform does not have the <stdint.h> header, you may\n   need to edit the typedefs in the #else section below.\n   Use #if...#else...#endif with predefined compiler macros if possible. */\n#if U_HAVE_STDINT_H\n\n/*\n * We mostly need <stdint.h> (which defines the standard integer types) but not <inttypes.h>.\n * <inttypes.h> includes <stdint.h> and adds the printf/scanf helpers PRId32, SCNx16 etc.\n * which we almost never use, plus stuff like imaxabs() which we never use.\n */\n#include <stdint.h>\n\n#if U_PLATFORM == U_PF_OS390\n/* The features header is needed to get (u)int64_t sometimes. */\n#include <features.h>\n/* z/OS has <stdint.h>, but some versions are missing uint8_t (APAR PK62248). */\n#if !defined(__uint8_t)\n#define __uint8_t 1\ntypedef unsigned char uint8_t;\n#endif\n#endif /* U_PLATFORM == U_PF_OS390 */\n\n#elif U_HAVE_INTTYPES_H\n\n#   include <inttypes.h>\n\n#else /* neither U_HAVE_STDINT_H nor U_HAVE_INTTYPES_H */\n\n#if ! U_HAVE_INT8_T\ntypedef signed char int8_t;\n#endif\n\n#if ! U_HAVE_UINT8_T\ntypedef unsigned char uint8_t;\n#endif\n\n#if ! U_HAVE_INT16_T\ntypedef signed short int16_t;\n#endif\n\n#if ! U_HAVE_UINT16_T\ntypedef unsigned short uint16_t;\n#endif\n\n#if ! U_HAVE_INT32_T\ntypedef signed int int32_t;\n#endif\n\n#if ! U_HAVE_UINT32_T\ntypedef unsigned int uint32_t;\n#endif\n\n#if ! U_HAVE_INT64_T\n#ifdef _MSC_VER\n    typedef signed __int64 int64_t;\n#else\n    typedef signed long long int64_t;\n#endif\n#endif\n\n#if ! U_HAVE_UINT64_T\n#ifdef _MSC_VER\n    typedef unsigned __int64 uint64_t;\n#else\n    typedef unsigned long long uint64_t;\n#endif\n#endif\n\n#endif /* U_HAVE_STDINT_H / U_HAVE_INTTYPES_H */\n\n#endif /* _PTYPES_H */\n"
  },
  {
    "path": "deprecated/android/addons/icucompat/unicode/putil.h",
    "content": "/*\n******************************************************************************\n*\n*   Copyright (C) 1997-2011, International Business Machines\n*   Corporation and others.  All Rights Reserved.\n*\n******************************************************************************\n*\n*  FILE NAME : putil.h\n*\n*   Date        Name        Description\n*   05/14/98    nos         Creation (content moved here from utypes.h).\n*   06/17/99    erm         Added IEEE_754\n*   07/22/98    stephen     Added IEEEremainder, max, min, trunc\n*   08/13/98    stephen     Added isNegativeInfinity, isPositiveInfinity\n*   08/24/98    stephen     Added longBitsFromDouble\n*   03/02/99    stephen     Removed openFile().  Added AS400 support.\n*   04/15/99    stephen     Converted to C\n*   11/15/99    helena      Integrated S/390 changes for IEEE support.\n*   01/11/00    helena      Added u_getVersion.\n******************************************************************************\n*/\n\n#ifndef PUTIL_H\n#define PUTIL_H\n\n#include \"unicode/utypes.h\"\n /**\n  * \\file\n  * \\brief C API: Platform Utilities\n  */\n\n/*==========================================================================*/\n/* Platform utilities                                                       */\n/*==========================================================================*/\n\n/**\n * Platform utilities isolates the platform dependencies of the\n * libarary.  For each platform which this code is ported to, these\n * functions may have to be re-implemented.\n */\n\n/**\n * Return the ICU data directory. \n * The data directory is where common format ICU data files (.dat files)\n *   are loaded from.  Note that normal use of the built-in ICU\n *   facilities does not require loading of an external data file;\n *   unless you are adding custom data to ICU, the data directory\n *   does not need to be set.\n *\n * The data directory is determined as follows:\n *    If u_setDataDirectory() has been called, that is it, otherwise\n *    if the ICU_DATA environment variable is set, use that, otherwise\n *    If a data directory was specifed at ICU build time\n *      <code>\n * \\code\n *        #define ICU_DATA_DIR \"path\" \n * \\endcode\n * </code> use that,\n *    otherwise no data directory is available.\n *\n * @return the data directory, or an empty string (\"\") if no data directory has\n *         been specified.\n *   \n * @stable ICU 2.0\n */\nU_STABLE const char* U_EXPORT2 u_getDataDirectory(void);\n\n/** \n * Set the ICU data directory. \n * The data directory is where common format ICU data files (.dat files)\n *   are loaded from.  Note that normal use of the built-in ICU\n *   facilities does not require loading of an external data file;\n *   unless you are adding custom data to ICU, the data directory\n *   does not need to be set.\n *\n * This function should be called at most once in a process, before the\n * first ICU operation (e.g., u_init()) that will require the loading of an\n * ICU data file.\n * This function is not thread-safe. Use it before calling ICU APIs from\n * multiple threads.\n *\n * @param directory The directory to be set.\n *\n * @see u_init\n * @stable ICU 2.0\n */\nU_STABLE void U_EXPORT2 u_setDataDirectory(const char *directory);\n\n/**\n * @{\n * Filesystem file and path separator characters.\n * Example: '/' and ':' on Unix, '\\\\' and ';' on Windows.\n * @stable ICU 2.0\n */\n#if U_PLATFORM == U_PF_CLASSIC_MACOS\n#   define U_FILE_SEP_CHAR ':'\n#   define U_FILE_ALT_SEP_CHAR ':'\n#   define U_PATH_SEP_CHAR ';'\n#   define U_FILE_SEP_STRING \":\"\n#   define U_FILE_ALT_SEP_STRING \":\"\n#   define U_PATH_SEP_STRING \";\"\n#elif U_PLATFORM_USES_ONLY_WIN32_API\n#   define U_FILE_SEP_CHAR '\\\\'\n#   define U_FILE_ALT_SEP_CHAR '/'\n#   define U_PATH_SEP_CHAR ';'\n#   define U_FILE_SEP_STRING \"\\\\\"\n#   define U_FILE_ALT_SEP_STRING \"/\"\n#   define U_PATH_SEP_STRING \";\"\n#else\n#   define U_FILE_SEP_CHAR '/'\n#   define U_FILE_ALT_SEP_CHAR '/'\n#   define U_PATH_SEP_CHAR ':'\n#   define U_FILE_SEP_STRING \"/\"\n#   define U_FILE_ALT_SEP_STRING \"/\"\n#   define U_PATH_SEP_STRING \":\"\n#endif\n\n/** @} */\n\n/**\n * Convert char characters to UChar characters.\n * This utility function is useful only for \"invariant characters\"\n * that are encoded in the platform default encoding.\n * They are a small, constant subset of the encoding and include\n * just the latin letters, digits, and some punctuation.\n * For details, see U_CHARSET_FAMILY.\n *\n * @param cs Input string, points to <code>length</code>\n *           character bytes from a subset of the platform encoding.\n * @param us Output string, points to memory for <code>length</code>\n *           Unicode characters.\n * @param length The number of characters to convert; this may\n *               include the terminating <code>NUL</code>.\n *\n * @see U_CHARSET_FAMILY\n * @stable ICU 2.0\n */\nU_STABLE void U_EXPORT2\nu_charsToUChars(const char *cs, UChar *us, int32_t length);\n\n/**\n * Convert UChar characters to char characters.\n * This utility function is useful only for \"invariant characters\"\n * that can be encoded in the platform default encoding.\n * They are a small, constant subset of the encoding and include\n * just the latin letters, digits, and some punctuation.\n * For details, see U_CHARSET_FAMILY.\n *\n * @param us Input string, points to <code>length</code>\n *           Unicode characters that can be encoded with the\n *           codepage-invariant subset of the platform encoding.\n * @param cs Output string, points to memory for <code>length</code>\n *           character bytes.\n * @param length The number of characters to convert; this may\n *               include the terminating <code>NUL</code>.\n *\n * @see U_CHARSET_FAMILY\n * @stable ICU 2.0\n */\nU_STABLE void U_EXPORT2\nu_UCharsToChars(const UChar *us, char *cs, int32_t length);\n\n#endif\n"
  },
  {
    "path": "deprecated/android/addons/icucompat/unicode/rbbi.h",
    "content": "/*\n***************************************************************************\n*   Copyright (C) 1999-2012 International Business Machines Corporation   *\n*   and others. All rights reserved.                                      *\n***************************************************************************\n\n**********************************************************************\n*   Date        Name        Description\n*   10/22/99    alan        Creation.\n*   11/11/99    rgillam     Complete port from Java.\n**********************************************************************\n*/\n\n#ifndef RBBI_H\n#define RBBI_H\n\n#include \"unicode/utypes.h\"\n\n/**\n * \\file\n * \\brief C++ API: Rule Based Break Iterator\n */\n\n#if !UCONFIG_NO_BREAK_ITERATION\n\n#include \"unicode/brkiter.h\"\n#include \"unicode/udata.h\"\n#include \"unicode/parseerr.h\"\n#include \"unicode/schriter.h\"\n#include \"unicode/uchriter.h\"\n\n\nstruct UTrie;\n\nU_NAMESPACE_BEGIN\n\n/** @internal */\nstruct RBBIDataHeader;\nclass  RuleBasedBreakIteratorTables;\nclass  BreakIterator;\nclass  RBBIDataWrapper;\nclass  UStack;\nclass  LanguageBreakEngine;\nclass  UnhandledEngine;\nstruct RBBIStateTable;\n\n\n\n\n/**\n *\n * A subclass of BreakIterator whose behavior is specified using a list of rules.\n * <p>Instances of this class are most commonly created by the factory methods of\n *  BreakIterator::createWordInstance(), BreakIterator::createLineInstance(), etc.,\n *  and then used via the abstract API in class BreakIterator</p>\n *\n * <p>See the ICU User Guide for information on Break Iterator Rules.</p>\n *\n * <p>This class is not intended to be subclassed.  (Class DictionaryBasedBreakIterator\n *    is a subclass, but that relationship is effectively internal to the ICU\n *    implementation.  The subclassing interface to RulesBasedBreakIterator is\n *    not part of the ICU API, and may not remain stable.</p>\n *\n */\nclass U_COMMON_API RuleBasedBreakIterator : public BreakIterator {\n\nprotected:\n    /**\n     * The UText through which this BreakIterator accesses the text\n     * @internal\n     */\n    UText  *fText;\n\n    /**\n     *   A character iterator that refers to the same text as the UText, above.\n     *   Only included for compatibility with old API, which was based on CharacterIterators.\n     *   Value may be adopted from outside, or one of fSCharIter or fDCharIter, below.\n     */\n    CharacterIterator  *fCharIter;\n\n    /**\n     *   When the input text is provided by a UnicodeString, this will point to\n     *    a characterIterator that wraps that data.  Needed only for the\n     *    implementation of getText(), a backwards compatibility issue.\n     */\n    StringCharacterIterator *fSCharIter;\n\n    /**\n     *  When the input text is provided by a UText, this\n     *    dummy CharacterIterator over an empty string will\n     *    be returned from getText()\n     */\n    UCharCharacterIterator *fDCharIter;\n\n    /**\n     * The rule data for this BreakIterator instance\n     * @internal\n     */\n    RBBIDataWrapper    *fData;\n\n    /** Index of the Rule {tag} values for the most recent match.\n     *  @internal\n    */\n    int32_t             fLastRuleStatusIndex;\n\n    /**\n     * Rule tag value valid flag.\n     * Some iterator operations don't intrinsically set the correct tag value.\n     * This flag lets us lazily compute the value if we are ever asked for it.\n     * @internal\n     */\n    UBool               fLastStatusIndexValid;\n\n    /**\n     * Counter for the number of characters encountered with the \"dictionary\"\n     *   flag set.\n     * @internal\n     */\n    uint32_t            fDictionaryCharCount;\n\n    /**\n     * When a range of characters is divided up using the dictionary, the break\n     * positions that are discovered are stored here, preventing us from having\n     * to use either the dictionary or the state table again until the iterator\n     * leaves this range of text. Has the most impact for line breaking.\n     * @internal\n     */\n    int32_t*            fCachedBreakPositions;\n\n    /**\n     * The number of elements in fCachedBreakPositions\n     * @internal\n     */\n    int32_t             fNumCachedBreakPositions;\n\n    /**\n     * if fCachedBreakPositions is not null, this indicates which item in the\n     * cache the current iteration position refers to\n     * @internal\n     */\n    int32_t             fPositionInCache;\n    \n    /**\n     *\n     * If present, UStack of LanguageBreakEngine objects that might handle\n     * dictionary characters. Searched from top to bottom to find an object to\n     * handle a given character.\n     * @internal\n     */\n    UStack              *fLanguageBreakEngines;\n    \n    /**\n     *\n     * If present, the special LanguageBreakEngine used for handling\n     * characters that are in the dictionary set, but not handled by any\n     * LangugageBreakEngine.\n     * @internal\n     */\n    UnhandledEngine     *fUnhandledBreakEngine;\n    \n    /**\n     *\n     * The type of the break iterator, or -1 if it has not been set.\n     * @internal\n     */\n    int32_t             fBreakType;\n    \nprotected:\n    //=======================================================================\n    // constructors\n    //=======================================================================\n\n#ifndef U_HIDE_INTERNAL_API\n    /**\n     * Constant to be used in the constructor\n     * RuleBasedBreakIterator(RBBIDataHeader*, EDontAdopt, UErrorCode &);\n     * which does not adopt the memory indicated by the RBBIDataHeader*\n     * parameter.\n     *\n     * @internal\n     */\n    enum EDontAdopt {\n        kDontAdopt\n    };\n\n    /**\n     * Constructor from a flattened set of RBBI data in malloced memory.\n     *             RulesBasedBreakIterators built from a custom set of rules\n     *             are created via this constructor; the rules are compiled\n     *             into memory, then the break iterator is constructed here.\n     *\n     *             The break iterator adopts the memory, and will\n     *             free it when done.\n     * @internal\n     */\n    RuleBasedBreakIterator(RBBIDataHeader* data, UErrorCode &status);\n\n    /**\n     * Constructor from a flattened set of RBBI data in memory which need not\n     *             be malloced (e.g. it may be a memory-mapped file, etc.).\n     *\n     *             This version does not adopt the memory, and does not\n     *             free it when done.\n     * @internal\n     */\n    RuleBasedBreakIterator(const RBBIDataHeader* data, enum EDontAdopt dontAdopt, UErrorCode &status);\n#endif  /* U_HIDE_INTERNAL_API */\n\n\n    friend class RBBIRuleBuilder;\n    /** @internal */\n    friend class BreakIterator;\n\n\n\npublic:\n\n    /** Default constructor.  Creates an empty shell of an iterator, with no\n     *  rules or text to iterate over.   Object can subsequently be assigned to.\n     *  @stable ICU 2.2\n     */\n    RuleBasedBreakIterator();\n\n    /**\n     * Copy constructor.  Will produce a break iterator with the same behavior,\n     * and which iterates over the same text, as the one passed in.\n     * @param that The RuleBasedBreakIterator passed to be copied\n     * @stable ICU 2.0\n     */\n    RuleBasedBreakIterator(const RuleBasedBreakIterator& that);\n\n    /**\n     * Construct a RuleBasedBreakIterator from a set of rules supplied as a string.\n     * @param rules The break rules to be used.\n     * @param parseError  In the event of a syntax error in the rules, provides the location\n     *                    within the rules of the problem.\n     * @param status Information on any errors encountered.\n     * @stable ICU 2.2\n     */\n    RuleBasedBreakIterator( const UnicodeString    &rules,\n                             UParseError           &parseError,\n                             UErrorCode            &status);\n\n    /**\n     * Contruct a RuleBasedBreakIterator from a set of precompiled binary rules.\n     * Binary rules are obtained from RulesBasedBreakIterator::getBinaryRules().\n     * Construction of a break iterator in this way is substantially faster than\n     * constuction from source rules.\n     *\n     * Ownership of the storage containing the compiled rules remains with the\n     * caller of this function.  The compiled rules must not be  modified or \n     * deleted during the life of the break iterator.\n     *\n     * The compiled rules are not compatible across different major versions of ICU.\n     * The compiled rules are comaptible only between machines with the same\n     * byte ordering (little or big endian) and the same base character set family\n     * (ASCII or EBCDIC).\n     *\n     * @see #getBinaryRules\n     * @param compiledRules A pointer to the compiled break rules to be used.\n     * @param ruleLength The length of the compiled break rules, in bytes.  This\n     *   corresponds to the length value produced by getBinaryRules().\n     * @param status Information on any errors encountered, including invalid\n     *   binary rules.\n     * @stable ICU 4.8\n     */\n    RuleBasedBreakIterator(const uint8_t *compiledRules,\n                           uint32_t       ruleLength,\n                           UErrorCode    &status);\n\n    /**\n     * This constructor uses the udata interface to create a BreakIterator\n     * whose internal tables live in a memory-mapped file.  \"image\" is an\n     * ICU UDataMemory handle for the pre-compiled break iterator tables.\n     * @param image handle to the memory image for the break iterator data.\n     *        Ownership of the UDataMemory handle passes to the Break Iterator,\n     *        which will be responsible for closing it when it is no longer needed.\n     * @param status Information on any errors encountered.\n     * @see udata_open\n     * @see #getBinaryRules\n     * @stable ICU 2.8\n     */\n    RuleBasedBreakIterator(UDataMemory* image, UErrorCode &status);\n\n    /**\n     * Destructor\n     *  @stable ICU 2.0\n     */\n    virtual ~RuleBasedBreakIterator();\n\n    /**\n     * Assignment operator.  Sets this iterator to have the same behavior,\n     * and iterate over the same text, as the one passed in.\n     * @param that The RuleBasedBreakItertor passed in\n     * @return the newly created RuleBasedBreakIterator\n     *  @stable ICU 2.0\n     */\n    RuleBasedBreakIterator& operator=(const RuleBasedBreakIterator& that);\n\n    /**\n     * Equality operator.  Returns TRUE if both BreakIterators are of the\n     * same class, have the same behavior, and iterate over the same text.\n     * @param that The BreakIterator to be compared for equality\n     * @return TRUE if both BreakIterators are of the\n     * same class, have the same behavior, and iterate over the same text.\n     *  @stable ICU 2.0\n     */\n    virtual UBool operator==(const BreakIterator& that) const;\n\n    /**\n     * Not-equal operator.  If operator== returns TRUE, this returns FALSE,\n     * and vice versa.\n     * @param that The BreakIterator to be compared for inequality\n     * @return TRUE if both BreakIterators are not same.\n     *  @stable ICU 2.0\n     */\n    UBool operator!=(const BreakIterator& that) const;\n\n    /**\n     * Returns a newly-constructed RuleBasedBreakIterator with the same\n     * behavior, and iterating over the same text, as this one.\n     * Differs from the copy constructor in that it is polymorphic, and\n     * will correctly clone (copy) a derived class.\n     * clone() is thread safe.  Multiple threads may simultaeneously\n     * clone the same source break iterator.\n     * @return a newly-constructed RuleBasedBreakIterator\n     * @stable ICU 2.0\n     */\n    virtual BreakIterator* clone() const;\n\n    /**\n     * Compute a hash code for this BreakIterator\n     * @return A hash code\n     *  @stable ICU 2.0\n     */\n    virtual int32_t hashCode(void) const;\n\n    /**\n     * Returns the description used to create this iterator\n     * @return the description used to create this iterator\n     *  @stable ICU 2.0\n     */\n    virtual const UnicodeString& getRules(void) const;\n\n    //=======================================================================\n    // BreakIterator overrides\n    //=======================================================================\n\n    /**\n     * <p>\n     * Return a CharacterIterator over the text being analyzed.\n     * The returned character iterator is owned by the break iterator, and must\n     * not be deleted by the caller.  Repeated calls to this function may\n     * return the same CharacterIterator.\n     * </p>\n     * <p>\n     * The returned character iterator must not be used concurrently with\n     * the break iterator.  If concurrent operation is needed, clone the\n     * returned character iterator first and operate on the clone.\n     * </p>\n     * <p>\n     * When the break iterator is operating on text supplied via a UText,\n     * this function will fail.  Lacking any way to signal failures, it\n     * returns an CharacterIterator containing no text.\n     * The function getUText() provides similar functionality,\n     * is reliable, and is more efficient.\n     * </p>\n     *\n     * TODO:  deprecate this function?\n     *\n     * @return An iterator over the text being analyzed.\n     * @stable ICU 2.0\n     */\n    virtual  CharacterIterator& getText(void) const;\n\n\n    /**\n      *  Get a UText for the text being analyzed.\n      *  The returned UText is a shallow clone of the UText used internally\n      *  by the break iterator implementation.  It can safely be used to\n      *  access the text without impacting any break iterator operations,\n      *  but the underlying text itself must not be altered.\n      *\n      * @param fillIn A UText to be filled in.  If NULL, a new UText will be\n      *           allocated to hold the result.\n      * @param status receives any error codes.\n      * @return   The current UText for this break iterator.  If an input\n      *           UText was provided, it will always be returned.\n      * @stable ICU 3.4\n      */\n     virtual UText *getUText(UText *fillIn, UErrorCode &status) const;\n\n    /**\n     * Set the iterator to analyze a new piece of text.  This function resets\n     * the current iteration position to the beginning of the text.\n     * @param newText An iterator over the text to analyze.  The BreakIterator\n     * takes ownership of the character iterator.  The caller MUST NOT delete it!\n     *  @stable ICU 2.0\n     */\n    virtual void adoptText(CharacterIterator* newText);\n\n    /**\n     * Set the iterator to analyze a new piece of text.  This function resets\n     * the current iteration position to the beginning of the text.\n     * @param newText The text to analyze.\n     *  @stable ICU 2.0\n     */\n    virtual void setText(const UnicodeString& newText);\n\n    /**\n     * Reset the break iterator to operate over the text represented by\n     * the UText.  The iterator position is reset to the start.\n     *\n     * This function makes a shallow clone of the supplied UText.  This means\n     * that the caller is free to immediately close or otherwise reuse the\n     * Utext that was passed as a parameter, but that the underlying text itself\n     * must not be altered while being referenced by the break iterator.\n     *\n     * @param text    The UText used to change the text.\n     * @param status  Receives any error codes.\n     * @stable ICU 3.4\n     */\n    virtual void  setText(UText *text, UErrorCode &status);\n\n    /**\n     * Sets the current iteration position to the beginning of the text.\n     * @return The offset of the beginning of the text.\n     *  @stable ICU 2.0\n     */\n    virtual int32_t first(void);\n\n    /**\n     * Sets the current iteration position to the end of the text.\n     * @return The text's past-the-end offset.\n     *  @stable ICU 2.0\n     */\n    virtual int32_t last(void);\n\n    /**\n     * Advances the iterator either forward or backward the specified number of steps.\n     * Negative values move backward, and positive values move forward.  This is\n     * equivalent to repeatedly calling next() or previous().\n     * @param n The number of steps to move.  The sign indicates the direction\n     * (negative is backwards, and positive is forwards).\n     * @return The character offset of the boundary position n boundaries away from\n     * the current one.\n     *  @stable ICU 2.0\n     */\n    virtual int32_t next(int32_t n);\n\n    /**\n     * Advances the iterator to the next boundary position.\n     * @return The position of the first boundary after this one.\n     *  @stable ICU 2.0\n     */\n    virtual int32_t next(void);\n\n    /**\n     * Moves the iterator backwards, to the last boundary preceding this one.\n     * @return The position of the last boundary position preceding this one.\n     *  @stable ICU 2.0\n     */\n    virtual int32_t previous(void);\n\n    /**\n     * Sets the iterator to refer to the first boundary position following\n     * the specified position.\n     * @param offset The position from which to begin searching for a break position.\n     * @return The position of the first break after the current position.\n     *  @stable ICU 2.0\n     */\n    virtual int32_t following(int32_t offset);\n\n    /**\n     * Sets the iterator to refer to the last boundary position before the\n     * specified position.\n     * @param offset The position to begin searching for a break from.\n     * @return The position of the last boundary before the starting position.\n     *  @stable ICU 2.0\n     */\n    virtual int32_t preceding(int32_t offset);\n\n    /**\n     * Returns true if the specfied position is a boundary position.  As a side\n     * effect, leaves the iterator pointing to the first boundary position at\n     * or after \"offset\".\n     * @param offset the offset to check.\n     * @return True if \"offset\" is a boundary position.\n     *  @stable ICU 2.0\n     */\n    virtual UBool isBoundary(int32_t offset);\n\n    /**\n     * Returns the current iteration position.\n     * @return The current iteration position.\n     * @stable ICU 2.0\n     */\n    virtual int32_t current(void) const;\n\n\n    /**\n     * Return the status tag from the break rule that determined the most recently\n     * returned break position.  For break rules that do not specify a\n     * status, a default value of 0 is returned.  If more than one break rule\n     * would cause a boundary to be located at some position in the text,\n     * the numerically largest of the applicable status values is returned.\n     * <p>\n     * Of the standard types of ICU break iterators, only word break and\n     * line break provide status values.  The values are defined in\n     * the header file ubrk.h.  For Word breaks, the status allows distinguishing between words\n     * that contain alphabetic letters, \"words\" that appear to be numbers,\n     * punctuation and spaces, words containing ideographic characters, and\n     * more.  For Line Break, the status distinguishes between hard (mandatory) breaks\n     * and soft (potential) break positions.\n     * <p>\n     * <code>getRuleStatus()</code> can be called after obtaining a boundary\n     * position from <code>next()</code>, <code>previous()</code>, or\n     * any other break iterator functions that returns a boundary position.\n     * <p>\n     * When creating custom break rules, one is free to define whatever\n     * status values may be convenient for the application.\n     * <p>\n     * Note: this function is not thread safe.  It should not have been\n     *       declared const, and the const remains only for compatibility\n     *       reasons.  (The function is logically const, but not bit-wise const).\n     * <p>\n     * @return the status from the break rule that determined the most recently\n     * returned break position.\n     *\n     * @see UWordBreak\n     * @stable ICU 2.2\n     */\n    virtual int32_t getRuleStatus() const;\n\n   /**\n    * Get the status (tag) values from the break rule(s) that determined the most\n    * recently returned break position.\n    * <p>\n    * The returned status value(s) are stored into an array provided by the caller.\n    * The values are stored in sorted (ascending) order.\n    * If the capacity of the output array is insufficient to hold the data,\n    *  the output will be truncated to the available length, and a\n    *  U_BUFFER_OVERFLOW_ERROR will be signaled.\n    *\n    * @param fillInVec an array to be filled in with the status values.\n    * @param capacity  the length of the supplied vector.  A length of zero causes\n    *                  the function to return the number of status values, in the\n    *                  normal way, without attemtping to store any values.\n    * @param status    receives error codes.\n    * @return          The number of rule status values from rules that determined\n    *                  the most recent boundary returned by the break iterator.\n    *                  In the event of a U_BUFFER_OVERFLOW_ERROR, the return value\n    *                  is the total number of status values that were available,\n    *                  not the reduced number that were actually returned.\n    * @see getRuleStatus\n    * @stable ICU 3.0\n    */\n    virtual int32_t getRuleStatusVec(int32_t *fillInVec, int32_t capacity, UErrorCode &status);\n\n    /**\n     * Returns a unique class ID POLYMORPHICALLY.  Pure virtual override.\n     * This method is to implement a simple version of RTTI, since not all\n     * C++ compilers support genuine RTTI.  Polymorphic operator==() and\n     * clone() methods call this method.\n     *\n     * @return          The class ID for this object. All objects of a\n     *                  given class have the same class ID.  Objects of\n     *                  other classes have different class IDs.\n     * @stable ICU 2.0\n     */\n    virtual UClassID getDynamicClassID(void) const;\n\n    /**\n     * Returns the class ID for this class.  This is useful only for\n     * comparing to a return value from getDynamicClassID().  For example:\n     *\n     *      Base* polymorphic_pointer = createPolymorphicObject();\n     *      if (polymorphic_pointer->getDynamicClassID() ==\n     *          Derived::getStaticClassID()) ...\n     *\n     * @return          The class ID for all objects of this class.\n     * @stable ICU 2.0\n     */\n    static UClassID U_EXPORT2 getStaticClassID(void);\n\n    /*\n     * Create a clone (copy) of this break iterator in memory provided\n     *  by the caller.  The idea is to increase performance by avoiding\n     *  a storage allocation.  Use of this functoin is NOT RECOMMENDED.\n     *  Performance gains are minimal, and correct buffer management is\n     *  tricky.  Use clone() instead.\n     *\n     * @param stackBuffer  The pointer to the memory into which the cloned object\n     *                     should be placed.  If NULL,  allocate heap memory\n     *                     for the cloned object.\n     * @param BufferSize   The size of the buffer.  If zero, return the required\n     *                     buffer size, but do not clone the object.  If the\n     *                     size was too small (but not zero), allocate heap\n     *                     storage for the cloned object.\n     *\n     * @param status       Error status.  U_SAFECLONE_ALLOCATED_WARNING will be\n     *                     returned if the the provided buffer was too small, and\n     *                     the clone was therefore put on the heap.\n     *\n     * @return  Pointer to the clone object.  This may differ from the stackBuffer\n     *          address if the byte alignment of the stack buffer was not suitable\n     *          or if the stackBuffer was too small to hold the clone.\n     * @stable ICU 2.0\n     */\n    virtual BreakIterator *  createBufferClone(void *stackBuffer,\n                                               int32_t &BufferSize,\n                                               UErrorCode &status);\n\n\n    /**\n     * Return the binary form of compiled break rules,\n     * which can then be used to create a new break iterator at some\n     * time in the future.  Creating a break iterator from pre-compiled rules\n     * is much faster than building one from the source form of the\n     * break rules.\n     *\n     * The binary data can only be used with the same version of ICU\n     *  and on the same platform type (processor endian-ness)\n     *\n     * @param length Returns the length of the binary data.  (Out paramter.)\n     *\n     * @return   A pointer to the binary (compiled) rule data.  The storage\n     *           belongs to the RulesBasedBreakIterator object, not the\n     *           caller, and must not be modified or deleted.\n     * @stable ICU 4.8\n     */\n    virtual const uint8_t *getBinaryRules(uint32_t &length);\n\n    /**\n     *  Set the subject text string upon which the break iterator is operating\n     *  without changing any other aspect of the matching state.\n     *  The new and previous text strings must have the same content.\n     *\n     *  This function is intended for use in environments where ICU is operating on\n     *  strings that may move around in memory.  It provides a mechanism for notifying\n     *  ICU that the string has been relocated, and providing a new UText to access the\n     *  string in its new position.\n     *\n     *  Note that the break iterator implementation never copies the underlying text\n     *  of a string being processed, but always operates directly on the original text\n     *  provided by the user. Refreshing simply drops the references to the old text\n     *  and replaces them with references to the new.\n     *\n     *  Caution:  this function is normally used only by very specialized,\n     *  system-level code.  One example use case is with garbage collection that moves\n     *  the text in memory.\n     *\n     * @param input      The new (moved) text string.\n     * @param status     Receives errors detected by this function.\n     * @return           *this\n     *\n     * @draft ICU 49\n     */\n    virtual RuleBasedBreakIterator &refreshInputText(UText *input, UErrorCode &status);\n\n\nprotected:\n    //=======================================================================\n    // implementation\n    //=======================================================================\n    /**\n     * Dumps caches and performs other actions associated with a complete change\n     * in text or iteration position.\n     * @internal\n     */\n    virtual void reset(void);\n\n#if 0\n    /**\n      * Return true if the category lookup for this char\n      * indicates that it is in the set of dictionary lookup chars.\n      * This function is intended for use by dictionary based break iterators.\n      * @return true if the category lookup for this char\n      * indicates that it is in the set of dictionary lookup chars.\n      * @internal\n      */\n    virtual UBool isDictionaryChar(UChar32);\n\n    /**\n      * Get the type of the break iterator.\n      * @internal\n      */\n    virtual int32_t getBreakType() const;\n#endif\n\n    /**\n      * Set the type of the break iterator.\n      * @internal\n      */\n    virtual void setBreakType(int32_t type);\n\n#ifndef U_HIDE_INTERNAL_API\n    /**\n      * Common initialization function, used by constructors and bufferClone.\n      *   (Also used by DictionaryBasedBreakIterator::createBufferClone().)\n      * @internal\n      */\n    void init();\n#endif  /* U_HIDE_INTERNAL_API */\n\nprivate:\n\n    /**\n     * This method backs the iterator back up to a \"safe position\" in the text.\n     * This is a position that we know, without any context, must be a break position.\n     * The various calling methods then iterate forward from this safe position to\n     * the appropriate position to return.  (For more information, see the description\n     * of buildBackwardsStateTable() in RuleBasedBreakIterator.Builder.)\n     * @param statetable state table used of moving backwards\n     * @internal\n     */\n    int32_t handlePrevious(const RBBIStateTable *statetable);\n\n    /**\n     * This method is the actual implementation of the next() method.  All iteration\n     * vectors through here.  This method initializes the state machine to state 1\n     * and advances through the text character by character until we reach the end\n     * of the text or the state machine transitions to state 0.  We update our return\n     * value every time the state machine passes through a possible end state.\n     * @param statetable state table used of moving forwards\n     * @internal\n     */\n    int32_t handleNext(const RBBIStateTable *statetable);\n\nprotected:\n\n#ifndef U_HIDE_INTERNAL_API\n    /**\n     * This is the function that actually implements dictionary-based\n     * breaking.  Covering at least the range from startPos to endPos,\n     * it checks for dictionary characters, and if it finds them determines\n     * the appropriate object to deal with them. It may cache found breaks in\n     * fCachedBreakPositions as it goes. It may well also look at text outside\n     * the range startPos to endPos.\n     * If going forward, endPos is the normal Unicode break result, and\n     * if goind in reverse, startPos is the normal Unicode break result\n     * @param startPos  The start position of a range of text\n     * @param endPos    The end position of a range of text\n     * @param reverse   The call is for the reverse direction\n     * @internal\n     */\n    int32_t checkDictionary(int32_t startPos, int32_t endPos, UBool reverse);\n#endif  /* U_HIDE_INTERNAL_API */\n\nprivate:\n\n    /**\n     * This function returns the appropriate LanguageBreakEngine for a\n     * given character c.\n     * @param c         A character in the dictionary set\n     * @internal\n     */\n    const LanguageBreakEngine *getLanguageBreakEngine(UChar32 c);\n\n    /**\n     *  @internal\n     */\n    void makeRuleStatusValid();\n\n};\n\n//------------------------------------------------------------------------------\n//\n//   Inline Functions Definitions ...\n//\n//------------------------------------------------------------------------------\n\ninline UBool RuleBasedBreakIterator::operator!=(const BreakIterator& that) const {\n    return !operator==(that);\n}\n\nU_NAMESPACE_END\n\n#endif /* #if !UCONFIG_NO_BREAK_ITERATION */\n\n#endif\n"
  },
  {
    "path": "deprecated/android/addons/icucompat/unicode/rbnf.h",
    "content": "/*\n*******************************************************************************\n* Copyright (C) 1997-2012, International Business Machines Corporation and others.\n* All Rights Reserved.\n*******************************************************************************\n*/\n\n#ifndef RBNF_H\n#define RBNF_H\n\n#include \"unicode/utypes.h\"\n\n/**\n * \\file\n * \\brief C++ API: Rule Based Number Format\n */\n\n/**\n * \\def U_HAVE_RBNF\n * This will be 0 if RBNF support is not included in ICU\n * and 1 if it is.\n *\n * @stable ICU 2.4\n */\n#if UCONFIG_NO_FORMATTING\n#define U_HAVE_RBNF 0\n#else\n#define U_HAVE_RBNF 1\n\n#include \"unicode/coll.h\"\n#include \"unicode/dcfmtsym.h\"\n#include \"unicode/fmtable.h\"\n#include \"unicode/locid.h\"\n#include \"unicode/numfmt.h\"\n#include \"unicode/unistr.h\"\n#include \"unicode/strenum.h\"\n\nU_NAMESPACE_BEGIN\n\nclass NFRuleSet;\nclass LocalizationInfo;\n\n/**\n * Tags for the predefined rulesets.\n *\n * @stable ICU 2.2\n */\nenum URBNFRuleSetTag {\n    URBNF_SPELLOUT,\n    URBNF_ORDINAL,\n    URBNF_DURATION,\n    URBNF_NUMBERING_SYSTEM,\n    URBNF_COUNT\n};\n\n#if UCONFIG_NO_COLLATION\nclass Collator;\n#endif\n\n/**\n * The RuleBasedNumberFormat class formats numbers according to a set of rules. This number formatter is\n * typically used for spelling out numeric values in words (e.g., 25,3476 as\n * &quot;twenty-five thousand three hundred seventy-six&quot; or &quot;vingt-cinq mille trois\n * cents soixante-seize&quot; or\n * &quot;f&uuml;nfundzwanzigtausenddreihundertsechsundsiebzig&quot;), but can also be used for\n * other complicated formatting tasks, such as formatting a number of seconds as hours,\n * minutes and seconds (e.g., 3,730 as &quot;1:02:10&quot;).\n *\n * <p>The resources contain three predefined formatters for each locale: spellout, which\n * spells out a value in words (123 is &quot;one hundred twenty-three&quot;); ordinal, which\n * appends an ordinal suffix to the end of a numeral (123 is &quot;123rd&quot;); and\n * duration, which shows a duration in seconds as hours, minutes, and seconds (123 is\n * &quot;2:03&quot;).&nbsp; The client can also define more specialized <tt>RuleBasedNumberFormat</tt>s\n * by supplying programmer-defined rule sets.</p>\n *\n * <p>The behavior of a <tt>RuleBasedNumberFormat</tt> is specified by a textual description\n * that is either passed to the constructor as a <tt>String</tt> or loaded from a resource\n * bundle. In its simplest form, the description consists of a semicolon-delimited list of <em>rules.</em>\n * Each rule has a string of output text and a value or range of values it is applicable to.\n * In a typical spellout rule set, the first twenty rules are the words for the numbers from\n * 0 to 19:</p>\n *\n * <pre>zero; one; two; three; four; five; six; seven; eight; nine;\n * ten; eleven; twelve; thirteen; fourteen; fifteen; sixteen; seventeen; eighteen; nineteen;</pre>\n *\n * <p>For larger numbers, we can use the preceding set of rules to format the ones place, and\n * we only have to supply the words for the multiples of 10:</p>\n *\n * <pre> 20: twenty[-&gt;&gt;];\n * 30: thirty[-&gt;&gt;];\n * 40: forty[-&gt;&gt;];\n * 50: fifty[-&gt;&gt;];\n * 60: sixty[-&gt;&gt;];\n * 70: seventy[-&gt;&gt;];\n * 80: eighty[-&gt;&gt;];\n * 90: ninety[-&gt;&gt;];</pre>\n *\n * <p>In these rules, the <em>base value</em> is spelled out explicitly and set off from the\n * rule's output text with a colon. The rules are in a sorted list, and a rule is applicable\n * to all numbers from its own base value to one less than the next rule's base value. The\n * &quot;&gt;&gt;&quot; token is called a <em>substitution</em> and tells the fomatter to\n * isolate the number's ones digit, format it using this same set of rules, and place the\n * result at the position of the &quot;&gt;&gt;&quot; token. Text in brackets is omitted if\n * the number being formatted is an even multiple of 10 (the hyphen is a literal hyphen; 24\n * is &quot;twenty-four,&quot; not &quot;twenty four&quot;).</p>\n *\n * <p>For even larger numbers, we can actually look up several parts of the number in the\n * list:</p>\n *\n * <pre>100: &lt;&lt; hundred[ &gt;&gt;];</pre>\n *\n * <p>The &quot;&lt;&lt;&quot; represents a new kind of substitution. The &lt;&lt; isolates\n * the hundreds digit (and any digits to its left), formats it using this same rule set, and\n * places the result where the &quot;&lt;&lt;&quot; was. Notice also that the meaning of\n * &gt;&gt; has changed: it now refers to both the tens and the ones digits. The meaning of\n * both substitutions depends on the rule's base value. The base value determines the rule's <em>divisor,</em>\n * which is the highest power of 10 that is less than or equal to the base value (the user\n * can change this). To fill in the substitutions, the formatter divides the number being\n * formatted by the divisor. The integral quotient is used to fill in the &lt;&lt;\n * substitution, and the remainder is used to fill in the &gt;&gt; substitution. The meaning\n * of the brackets changes similarly: text in brackets is omitted if the value being\n * formatted is an even multiple of the rule's divisor. The rules are applied recursively, so\n * if a substitution is filled in with text that includes another substitution, that\n * substitution is also filled in.</p>\n *\n * <p>This rule covers values up to 999, at which point we add another rule:</p>\n *\n * <pre>1000: &lt;&lt; thousand[ &gt;&gt;];</pre>\n *\n * <p>Again, the meanings of the brackets and substitution tokens shift because the rule's\n * base value is a higher power of 10, changing the rule's divisor. This rule can actually be\n * used all the way up to 999,999. This allows us to finish out the rules as follows:</p>\n *\n * <pre> 1,000,000: &lt;&lt; million[ &gt;&gt;];\n * 1,000,000,000: &lt;&lt; billion[ &gt;&gt;];\n * 1,000,000,000,000: &lt;&lt; trillion[ &gt;&gt;];\n * 1,000,000,000,000,000: OUT OF RANGE!;</pre>\n *\n * <p>Commas, periods, and spaces can be used in the base values to improve legibility and\n * are ignored by the rule parser. The last rule in the list is customarily treated as an\n * &quot;overflow rule,&quot; applying to everything from its base value on up, and often (as\n * in this example) being used to print out an error message or default representation.\n * Notice also that the size of the major groupings in large numbers is controlled by the\n * spacing of the rules: because in English we group numbers by thousand, the higher rules\n * are separated from each other by a factor of 1,000.</p>\n *\n * <p>To see how these rules actually work in practice, consider the following example:\n * Formatting 25,430 with this rule set would work like this:</p>\n *\n * <table border=\"0\" width=\"100%\">\n *   <tr>\n *     <td><strong>&lt;&lt; thousand &gt;&gt;</strong></td>\n *     <td>[the rule whose base value is 1,000 is applicable to 25,340]</td>\n *   </tr>\n *   <tr>\n *     <td><strong>twenty-&gt;&gt;</strong> thousand &gt;&gt;</td>\n *     <td>[25,340 over 1,000 is 25. The rule for 20 applies.]</td>\n *   </tr>\n *   <tr>\n *     <td>twenty-<strong>five</strong> thousand &gt;&gt;</td>\n *     <td>[25 mod 10 is 5. The rule for 5 is &quot;five.&quot;</td>\n *   </tr>\n *   <tr>\n *     <td>twenty-five thousand <strong>&lt;&lt; hundred &gt;&gt;</strong></td>\n *     <td>[25,340 mod 1,000 is 340. The rule for 100 applies.]</td>\n *   </tr>\n *   <tr>\n *     <td>twenty-five thousand <strong>three</strong> hundred &gt;&gt;</td>\n *     <td>[340 over 100 is 3. The rule for 3 is &quot;three.&quot;]</td>\n *   </tr>\n *   <tr>\n *     <td>twenty-five thousand three hundred <strong>forty</strong></td>\n *     <td>[340 mod 100 is 40. The rule for 40 applies. Since 40 divides\n *     evenly by 10, the hyphen and substitution in the brackets are omitted.]</td>\n *   </tr>\n * </table>\n *\n * <p>The above syntax suffices only to format positive integers. To format negative numbers,\n * we add a special rule:</p>\n *\n * <pre>-x: minus &gt;&gt;;</pre>\n *\n * <p>This is called a <em>negative-number rule,</em> and is identified by &quot;-x&quot;\n * where the base value would be. This rule is used to format all negative numbers. the\n * &gt;&gt; token here means &quot;find the number's absolute value, format it with these\n * rules, and put the result here.&quot;</p>\n *\n * <p>We also add a special rule called a <em>fraction rule </em>for numbers with fractional\n * parts:</p>\n *\n * <pre>x.x: &lt;&lt; point &gt;&gt;;</pre>\n *\n * <p>This rule is used for all positive non-integers (negative non-integers pass through the\n * negative-number rule first and then through this rule). Here, the &lt;&lt; token refers to\n * the number's integral part, and the &gt;&gt; to the number's fractional part. The\n * fractional part is formatted as a series of single-digit numbers (e.g., 123.456 would be\n * formatted as &quot;one hundred twenty-three point four five six&quot;).</p>\n *\n * <p>To see how this rule syntax is applied to various languages, examine the resource data.</p>\n *\n * <p>There is actually much more flexibility built into the rule language than the\n * description above shows. A formatter may own multiple rule sets, which can be selected by\n * the caller, and which can use each other to fill in their substitutions. Substitutions can\n * also be filled in with digits, using a DecimalFormat object. There is syntax that can be\n * used to alter a rule's divisor in various ways. And there is provision for much more\n * flexible fraction handling. A complete description of the rule syntax follows:</p>\n *\n * <hr>\n *\n * <p>The description of a <tt>RuleBasedNumberFormat</tt>'s behavior consists of one or more <em>rule\n * sets.</em> Each rule set consists of a name, a colon, and a list of <em>rules.</em> A rule\n * set name must begin with a % sign. Rule sets with names that begin with a single % sign\n * are <em>public:</em> the caller can specify that they be used to format and parse numbers.\n * Rule sets with names that begin with %% are <em>private:</em> they exist only for the use\n * of other rule sets. If a formatter only has one rule set, the name may be omitted.</p>\n *\n * <p>The user can also specify a special &quot;rule set&quot; named <tt>%%lenient-parse</tt>.\n * The body of <tt>%%lenient-parse</tt> isn't a set of number-formatting rules, but a <tt>RuleBasedCollator</tt>\n * description which is used to define equivalences for lenient parsing. For more information\n * on the syntax, see <tt>RuleBasedCollator</tt>. For more information on lenient parsing,\n * see <tt>setLenientParse()</tt>.  <em>Note:</em> symbols that have syntactic meaning\n * in collation rules, such as '&amp;', have no particular meaning when appearing outside\n * of the <tt>lenient-parse</tt> rule set.</p>\n *\n * <p>The body of a rule set consists of an ordered, semicolon-delimited list of <em>rules.</em>\n * Internally, every rule has a base value, a divisor, rule text, and zero, one, or two <em>substitutions.</em>\n * These parameters are controlled by the description syntax, which consists of a <em>rule\n * descriptor,</em> a colon, and a <em>rule body.</em></p>\n *\n * <p>A rule descriptor can take one of the following forms (text in <em>italics</em> is the\n * name of a token):</p>\n *\n * <table border=\"0\" width=\"100%\">\n *   <tr>\n *     <td><em>bv</em>:</td>\n *     <td><em>bv</em> specifies the rule's base value. <em>bv</em> is a decimal\n *     number expressed using ASCII digits. <em>bv</em> may contain spaces, period, and commas,\n *     which are ignored. The rule's divisor is the highest power of 10 less than or equal to\n *     the base value.</td>\n *   </tr>\n *   <tr>\n *     <td><em>bv</em>/<em>rad</em>:</td>\n *     <td><em>bv</em> specifies the rule's base value. The rule's divisor is the\n *     highest power of <em>rad</em> less than or equal to the base value.</td>\n *   </tr>\n *   <tr>\n *     <td><em>bv</em>&gt;:</td>\n *     <td><em>bv</em> specifies the rule's base value. To calculate the divisor,\n *     let the radix be 10, and the exponent be the highest exponent of the radix that yields a\n *     result less than or equal to the base value. Every &gt; character after the base value\n *     decreases the exponent by 1. If the exponent is positive or 0, the divisor is the radix\n *     raised to the power of the exponent; otherwise, the divisor is 1.</td>\n *   </tr>\n *   <tr>\n *     <td><em>bv</em>/<em>rad</em>&gt;:</td>\n *     <td><em>bv</em> specifies the rule's base value. To calculate the divisor,\n *     let the radix be <em>rad</em>, and the exponent be the highest exponent of the radix that\n *     yields a result less than or equal to the base value. Every &gt; character after the radix\n *     decreases the exponent by 1. If the exponent is positive or 0, the divisor is the radix\n *     raised to the power of the exponent; otherwise, the divisor is 1.</td>\n *   </tr>\n *   <tr>\n *     <td>-x:</td>\n *     <td>The rule is a negative-number rule.</td>\n *   </tr>\n *   <tr>\n *     <td>x.x:</td>\n *     <td>The rule is an <em>improper fraction rule.</em></td>\n *   </tr>\n *   <tr>\n *     <td>0.x:</td>\n *     <td>The rule is a <em>proper fraction rule.</em></td>\n *   </tr>\n *   <tr>\n *     <td>x.0:</td>\n *     <td>The rule is a <em>master rule.</em></td>\n *   </tr>\n *   <tr>\n *     <td><em>nothing</em></td>\n *     <td>If the rule's rule descriptor is left out, the base value is one plus the\n *     preceding rule's base value (or zero if this is the first rule in the list) in a normal\n *     rule set.&nbsp; In a fraction rule set, the base value is the same as the preceding rule's\n *     base value.</td>\n *   </tr>\n * </table>\n *\n * <p>A rule set may be either a regular rule set or a <em>fraction rule set,</em> depending\n * on whether it is used to format a number's integral part (or the whole number) or a\n * number's fractional part. Using a rule set to format a rule's fractional part makes it a\n * fraction rule set.</p>\n *\n * <p>Which rule is used to format a number is defined according to one of the following\n * algorithms: If the rule set is a regular rule set, do the following:\n *\n * <ul>\n *   <li>If the rule set includes a master rule (and the number was passed in as a <tt>double</tt>),\n *     use the master rule.&nbsp; (If the number being formatted was passed in as a <tt>long</tt>,\n *     the master rule is ignored.)</li>\n *   <li>If the number is negative, use the negative-number rule.</li>\n *   <li>If the number has a fractional part and is greater than 1, use the improper fraction\n *     rule.</li>\n *   <li>If the number has a fractional part and is between 0 and 1, use the proper fraction\n *     rule.</li>\n *   <li>Binary-search the rule list for the rule with the highest base value less than or equal\n *     to the number. If that rule has two substitutions, its base value is not an even multiple\n *     of its divisor, and the number <em>is</em> an even multiple of the rule's divisor, use the\n *     rule that precedes it in the rule list. Otherwise, use the rule itself.</li>\n * </ul>\n *\n * <p>If the rule set is a fraction rule set, do the following:\n *\n * <ul>\n *   <li>Ignore negative-number and fraction rules.</li>\n *   <li>For each rule in the list, multiply the number being formatted (which will always be\n *     between 0 and 1) by the rule's base value. Keep track of the distance between the result\n *     the nearest integer.</li>\n *   <li>Use the rule that produced the result closest to zero in the above calculation. In the\n *     event of a tie or a direct hit, use the first matching rule encountered. (The idea here is\n *     to try each rule's base value as a possible denominator of a fraction. Whichever\n *     denominator produces the fraction closest in value to the number being formatted wins.) If\n *     the rule following the matching rule has the same base value, use it if the numerator of\n *     the fraction is anything other than 1; if the numerator is 1, use the original matching\n *     rule. (This is to allow singular and plural forms of the rule text without a lot of extra\n *     hassle.)</li>\n * </ul>\n *\n * <p>A rule's body consists of a string of characters terminated by a semicolon. The rule\n * may include zero, one, or two <em>substitution tokens,</em> and a range of text in\n * brackets. The brackets denote optional text (and may also include one or both\n * substitutions). The exact meanings of the substitution tokens, and under what conditions\n * optional text is omitted, depend on the syntax of the substitution token and the context.\n * The rest of the text in a rule body is literal text that is output when the rule matches\n * the number being formatted.</p>\n *\n * <p>A substitution token begins and ends with a <em>token character.</em> The token\n * character and the context together specify a mathematical operation to be performed on the\n * number being formatted. An optional <em>substitution descriptor </em>specifies how the\n * value resulting from that operation is used to fill in the substitution. The position of\n * the substitution token in the rule body specifies the location of the resultant text in\n * the original rule text.</p>\n *\n * <p>The meanings of the substitution token characters are as follows:</p>\n *\n * <table border=\"0\" width=\"100%\">\n *   <tr>\n *     <td>&gt;&gt;</td>\n *     <td>in normal rule</td>\n *     <td>Divide the number by the rule's divisor and format the remainder</td>\n *   </tr>\n *   <tr>\n *     <td></td>\n *     <td>in negative-number rule</td>\n *     <td>Find the absolute value of the number and format the result</td>\n *   </tr>\n *   <tr>\n *     <td></td>\n *     <td>in fraction or master rule</td>\n *     <td>Isolate the number's fractional part and format it.</td>\n *   </tr>\n *   <tr>\n *     <td></td>\n *     <td>in rule in fraction rule set</td>\n *     <td>Not allowed.</td>\n *   </tr>\n *   <tr>\n *     <td>&gt;&gt;&gt;</td>\n *     <td>in normal rule</td>\n *     <td>Divide the number by the rule's divisor and format the remainder,\n *       but bypass the normal rule-selection process and just use the\n *       rule that precedes this one in this rule list.</td>\n *   </tr>\n *   <tr>\n *     <td></td>\n *     <td>in all other rules</td>\n *     <td>Not allowed.</td>\n *   </tr>\n *   <tr>\n *     <td>&lt;&lt;</td>\n *     <td>in normal rule</td>\n *     <td>Divide the number by the rule's divisor and format the quotient</td>\n *   </tr>\n *   <tr>\n *     <td></td>\n *     <td>in negative-number rule</td>\n *     <td>Not allowed.</td>\n *   </tr>\n *   <tr>\n *     <td></td>\n *     <td>in fraction or master rule</td>\n *     <td>Isolate the number's integral part and format it.</td>\n *   </tr>\n *   <tr>\n *     <td></td>\n *     <td>in rule in fraction rule set</td>\n *     <td>Multiply the number by the rule's base value and format the result.</td>\n *   </tr>\n *   <tr>\n *     <td>==</td>\n *     <td>in all rule sets</td>\n *     <td>Format the number unchanged</td>\n *   </tr>\n *   <tr>\n *     <td>[]</td>\n *     <td>in normal rule</td>\n *     <td>Omit the optional text if the number is an even multiple of the rule's divisor</td>\n *   </tr>\n *   <tr>\n *     <td></td>\n *     <td>in negative-number rule</td>\n *     <td>Not allowed.</td>\n *   </tr>\n *   <tr>\n *     <td></td>\n *     <td>in improper-fraction rule</td>\n *     <td>Omit the optional text if the number is between 0 and 1 (same as specifying both an\n *     x.x rule and a 0.x rule)</td>\n *   </tr>\n *   <tr>\n *     <td></td>\n *     <td>in master rule</td>\n *     <td>Omit the optional text if the number is an integer (same as specifying both an x.x\n *     rule and an x.0 rule)</td>\n *   </tr>\n *   <tr>\n *     <td></td>\n *     <td>in proper-fraction rule</td>\n *     <td>Not allowed.</td>\n *   </tr>\n *   <tr>\n *     <td></td>\n *     <td>in rule in fraction rule set</td>\n *     <td>Omit the optional text if multiplying the number by the rule's base value yields 1.</td>\n *   </tr>\n * </table>\n *\n * <p>The substitution descriptor (i.e., the text between the token characters) may take one\n * of three forms:</p>\n *\n * <table border=\"0\" width=\"100%\">\n *   <tr>\n *     <td>a rule set name</td>\n *     <td>Perform the mathematical operation on the number, and format the result using the\n *     named rule set.</td>\n *   </tr>\n *   <tr>\n *     <td>a DecimalFormat pattern</td>\n *     <td>Perform the mathematical operation on the number, and format the result using a\n *     DecimalFormat with the specified pattern.&nbsp; The pattern must begin with 0 or #.</td>\n *   </tr>\n *   <tr>\n *     <td>nothing</td>\n *     <td>Perform the mathematical operation on the number, and format the result using the rule\n *     set containing the current rule, except:\n *     <ul>\n *       <li>You can't have an empty substitution descriptor with a == substitution.</li>\n *       <li>If you omit the substitution descriptor in a &gt;&gt; substitution in a fraction rule,\n *         format the result one digit at a time using the rule set containing the current rule.</li>\n *       <li>If you omit the substitution descriptor in a &lt;&lt; substitution in a rule in a\n *         fraction rule set, format the result using the default rule set for this formatter.</li>\n *     </ul>\n *     </td>\n *   </tr>\n * </table>\n *\n * <p>Whitespace is ignored between a rule set name and a rule set body, between a rule\n * descriptor and a rule body, or between rules. If a rule body begins with an apostrophe,\n * the apostrophe is ignored, but all text after it becomes significant (this is how you can\n * have a rule's rule text begin with whitespace). There is no escape function: the semicolon\n * is not allowed in rule set names or in rule text, and the colon is not allowed in rule set\n * names. The characters beginning a substitution token are always treated as the beginning\n * of a substitution token.</p>\n *\n * <p>See the resource data and the demo program for annotated examples of real rule sets\n * using these features.</p>\n *\n * <p><em>User subclasses are not supported.</em> While clients may write\n * subclasses, such code will not necessarily work and will not be\n * guaranteed to work stably from release to release.\n *\n * <p><b>Localizations</b></p>\n * <p>Constructors are available that allow the specification of localizations for the\n * public rule sets (and also allow more control over what public rule sets are available).\n * Localization data is represented as a textual description.  The description represents\n * an array of arrays of string.  The first element is an array of the public rule set names,\n * each of these must be one of the public rule set names that appear in the rules.  Only\n * names in this array will be treated as public rule set names by the API.  Each subsequent\n * element is an array of localizations of these names.  The first element of one of these\n * subarrays is the locale name, and the remaining elements are localizations of the\n * public rule set names, in the same order as they were listed in the first arrray.</p>\n * <p>In the syntax, angle brackets '<', '>' are used to delimit the arrays, and comma ',' is used\n * to separate elements of an array.  Whitespace is ignored, unless quoted.</p>\n * <p>For example:<pre>\n * < < %foo, %bar, %baz >,\n *   < en, Foo, Bar, Baz >,\n *   < fr, 'le Foo', 'le Bar', 'le Baz' >\n *   < zh, \\\\u7532, \\\\u4e59, \\\\u4e19 > >\n * </pre></p>\n * @author Richard Gillam\n * @see NumberFormat\n * @see DecimalFormat\n * @stable ICU 2.0\n */\nclass U_I18N_API RuleBasedNumberFormat : public NumberFormat {\npublic:\n\n  //-----------------------------------------------------------------------\n  // constructors\n  //-----------------------------------------------------------------------\n\n    /**\n     * Creates a RuleBasedNumberFormat that behaves according to the description\n     * passed in.  The formatter uses the default locale.\n     * @param rules A description of the formatter's desired behavior.\n     * See the class documentation for a complete explanation of the description\n     * syntax.\n     * @param perror The parse error if an error was encountered.\n     * @param status The status indicating whether the constructor succeeded.\n     * @stable ICU 3.2\n     */\n    RuleBasedNumberFormat(const UnicodeString& rules, UParseError& perror, UErrorCode& status);\n\n    /**\n     * Creates a RuleBasedNumberFormat that behaves according to the description\n     * passed in.  The formatter uses the default locale.\n     * <p>\n     * The localizations data provides information about the public\n     * rule sets and their localized display names for different\n     * locales. The first element in the list is an array of the names\n     * of the public rule sets.  The first element in this array is\n     * the initial default ruleset.  The remaining elements in the\n     * list are arrays of localizations of the names of the public\n     * rule sets.  Each of these is one longer than the initial array,\n     * with the first String being the ULocale ID, and the remaining\n     * Strings being the localizations of the rule set names, in the\n     * same order as the initial array.  Arrays are NULL-terminated.\n     * @param rules A description of the formatter's desired behavior.\n     * See the class documentation for a complete explanation of the description\n     * syntax.\n     * @param localizations the localization information.\n     * names in the description.  These will be copied by the constructor.\n     * @param perror The parse error if an error was encountered.\n     * @param status The status indicating whether the constructor succeeded.\n     * @stable ICU 3.2\n     */\n    RuleBasedNumberFormat(const UnicodeString& rules, const UnicodeString& localizations,\n                        UParseError& perror, UErrorCode& status);\n\n  /**\n   * Creates a RuleBasedNumberFormat that behaves according to the rules\n   * passed in.  The formatter uses the specified locale to determine the\n   * characters to use when formatting numerals, and to define equivalences\n   * for lenient parsing.\n   * @param rules The formatter rules.\n   * See the class documentation for a complete explanation of the rule\n   * syntax.\n   * @param locale A locale that governs which characters are used for\n   * formatting values in numerals and which characters are equivalent in\n   * lenient parsing.\n   * @param perror The parse error if an error was encountered.\n   * @param status The status indicating whether the constructor succeeded.\n   * @stable ICU 2.0\n   */\n  RuleBasedNumberFormat(const UnicodeString& rules, const Locale& locale,\n                        UParseError& perror, UErrorCode& status);\n\n    /**\n     * Creates a RuleBasedNumberFormat that behaves according to the description\n     * passed in.  The formatter uses the default locale.\n     * <p>\n     * The localizations data provides information about the public\n     * rule sets and their localized display names for different\n     * locales. The first element in the list is an array of the names\n     * of the public rule sets.  The first element in this array is\n     * the initial default ruleset.  The remaining elements in the\n     * list are arrays of localizations of the names of the public\n     * rule sets.  Each of these is one longer than the initial array,\n     * with the first String being the ULocale ID, and the remaining\n     * Strings being the localizations of the rule set names, in the\n     * same order as the initial array.  Arrays are NULL-terminated.\n     * @param rules A description of the formatter's desired behavior.\n     * See the class documentation for a complete explanation of the description\n     * syntax.\n     * @param localizations a list of localizations for the rule set\n     * names in the description.  These will be copied by the constructor.\n     * @param locale A locale that governs which characters are used for\n     * formatting values in numerals and which characters are equivalent in\n     * lenient parsing.\n     * @param perror The parse error if an error was encountered.\n     * @param status The status indicating whether the constructor succeeded.\n     * @stable ICU 3.2\n     */\n    RuleBasedNumberFormat(const UnicodeString& rules, const UnicodeString& localizations,\n                        const Locale& locale, UParseError& perror, UErrorCode& status);\n\n  /**\n   * Creates a RuleBasedNumberFormat from a predefined ruleset.  The selector\n   * code choosed among three possible predefined formats: spellout, ordinal,\n   * and duration.\n   * @param tag A selector code specifying which kind of formatter to create for that\n   * locale.  There are four legal values: URBNF_SPELLOUT, which creates a formatter that\n   * spells out a value in words in the desired language, URBNF_ORDINAL, which attaches\n   * an ordinal suffix from the desired language to the end of a number (e.g. \"123rd\"),\n   * URBNF_DURATION, which formats a duration in seconds as hours, minutes, and seconds,\n   * and URBNF_NUMBERING_SYSTEM, which is used to invoke rules for alternate numbering\n   * systems such as the Hebrew numbering system, or for Roman Numerals, etc.\n   * @param locale The locale for the formatter.\n   * @param status The status indicating whether the constructor succeeded.\n   * @stable ICU 2.0\n   */\n  RuleBasedNumberFormat(URBNFRuleSetTag tag, const Locale& locale, UErrorCode& status);\n\n  //-----------------------------------------------------------------------\n  // boilerplate\n  //-----------------------------------------------------------------------\n\n  /**\n   * Copy constructor\n   * @param rhs    the object to be copied from.\n   * @stable ICU 2.6\n   */\n  RuleBasedNumberFormat(const RuleBasedNumberFormat& rhs);\n\n  /**\n   * Assignment operator\n   * @param rhs    the object to be copied from.\n   * @stable ICU 2.6\n   */\n  RuleBasedNumberFormat& operator=(const RuleBasedNumberFormat& rhs);\n\n  /**\n   * Release memory allocated for a RuleBasedNumberFormat when you are finished with it.\n   * @stable ICU 2.6\n   */\n  virtual ~RuleBasedNumberFormat();\n\n  /**\n   * Clone this object polymorphically.  The caller is responsible\n   * for deleting the result when done.\n   * @return  A copy of the object.\n   * @stable ICU 2.6\n   */\n  virtual Format* clone(void) const;\n\n  /**\n   * Return true if the given Format objects are semantically equal.\n   * Objects of different subclasses are considered unequal.\n   * @param other    the object to be compared with.\n   * @return        true if the given Format objects are semantically equal.\n   * @stable ICU 2.6\n   */\n  virtual UBool operator==(const Format& other) const;\n\n//-----------------------------------------------------------------------\n// public API functions\n//-----------------------------------------------------------------------\n\n  /**\n   * return the rules that were provided to the RuleBasedNumberFormat.\n   * @return the result String that was passed in\n   * @stable ICU 2.0\n   */\n  virtual UnicodeString getRules() const;\n\n  /**\n   * Return the number of public rule set names.\n   * @return the number of public rule set names.\n   * @stable ICU 2.0\n   */\n  virtual int32_t getNumberOfRuleSetNames() const;\n\n  /**\n   * Return the name of the index'th public ruleSet.  If index is not valid,\n   * the function returns null.\n   * @param index the index of the ruleset\n   * @return the name of the index'th public ruleSet.\n   * @stable ICU 2.0\n   */\n  virtual UnicodeString getRuleSetName(int32_t index) const;\n\n  /**\n   * Return the number of locales for which we have localized rule set display names.\n   * @return the number of locales for which we have localized rule set display names.\n   * @stable ICU 3.2\n   */\n  virtual int32_t getNumberOfRuleSetDisplayNameLocales(void) const;\n\n  /**\n   * Return the index'th display name locale.\n   * @param index the index of the locale\n   * @param status set to a failure code when this function fails\n   * @return the locale\n   * @see #getNumberOfRuleSetDisplayNameLocales\n   * @stable ICU 3.2\n   */\n  virtual Locale getRuleSetDisplayNameLocale(int32_t index, UErrorCode& status) const;\n\n    /**\n     * Return the rule set display names for the provided locale.  These are in the same order\n     * as those returned by getRuleSetName.  The locale is matched against the locales for\n     * which there is display name data, using normal fallback rules.  If no locale matches,\n     * the default display names are returned.  (These are the internal rule set names minus\n     * the leading '%'.)\n     * @param index the index of the rule set\n     * @param locale the locale (returned by getRuleSetDisplayNameLocales) for which the localized\n     * display name is desired\n     * @return the display name for the given index, which might be bogus if there is an error\n     * @see #getRuleSetName\n     * @stable ICU 3.2\n     */\n  virtual UnicodeString getRuleSetDisplayName(int32_t index,\n                          const Locale& locale = Locale::getDefault());\n\n    /**\n     * Return the rule set display name for the provided rule set and locale.\n     * The locale is matched against the locales for which there is display name data, using\n     * normal fallback rules.  If no locale matches, the default display name is returned.\n     * @return the display name for the rule set\n     * @stable ICU 3.2\n     * @see #getRuleSetDisplayName\n     */\n  virtual UnicodeString getRuleSetDisplayName(const UnicodeString& ruleSetName,\n                          const Locale& locale = Locale::getDefault());\n\n\n  using NumberFormat::format;\n\n  /**\n   * Formats the specified 32-bit number using the default ruleset.\n   * @param number The number to format.\n   * @param toAppendTo the string that will hold the (appended) result\n   * @param pos the fieldposition\n   * @return A textual representation of the number.\n   * @stable ICU 2.0\n   */\n  virtual UnicodeString& format(int32_t number,\n                                UnicodeString& toAppendTo,\n                                FieldPosition& pos) const;\n\n  /**\n   * Formats the specified 64-bit number using the default ruleset.\n   * @param number The number to format.\n   * @param toAppendTo the string that will hold the (appended) result\n   * @param pos the fieldposition\n   * @return A textual representation of the number.\n   * @stable ICU 2.1\n   */\n  virtual UnicodeString& format(int64_t number,\n                                UnicodeString& toAppendTo,\n                                FieldPosition& pos) const;\n  /**\n   * Formats the specified number using the default ruleset.\n   * @param number The number to format.\n   * @param toAppendTo the string that will hold the (appended) result\n   * @param pos the fieldposition\n   * @return A textual representation of the number.\n   * @stable ICU 2.0\n   */\n  virtual UnicodeString& format(double number,\n                                UnicodeString& toAppendTo,\n                                FieldPosition& pos) const;\n\n  /**\n   * Formats the specified number using the named ruleset.\n   * @param number The number to format.\n   * @param ruleSetName The name of the rule set to format the number with.\n   * This must be the name of a valid public rule set for this formatter.\n   * @param toAppendTo the string that will hold the (appended) result\n   * @param pos the fieldposition\n   * @param status the status\n   * @return A textual representation of the number.\n   * @stable ICU 2.0\n   */\n  virtual UnicodeString& format(int32_t number,\n                                const UnicodeString& ruleSetName,\n                                UnicodeString& toAppendTo,\n                                FieldPosition& pos,\n                                UErrorCode& status) const;\n  /**\n   * Formats the specified 64-bit number using the named ruleset.\n   * @param number The number to format.\n   * @param ruleSetName The name of the rule set to format the number with.\n   * This must be the name of a valid public rule set for this formatter.\n   * @param toAppendTo the string that will hold the (appended) result\n   * @param pos the fieldposition\n   * @param status the status\n   * @return A textual representation of the number.\n   * @stable ICU 2.1\n   */\n  virtual UnicodeString& format(int64_t number,\n                                const UnicodeString& ruleSetName,\n                                UnicodeString& toAppendTo,\n                                FieldPosition& pos,\n                                UErrorCode& status) const;\n  /**\n   * Formats the specified number using the named ruleset.\n   * @param number The number to format.\n   * @param ruleSetName The name of the rule set to format the number with.\n   * This must be the name of a valid public rule set for this formatter.\n   * @param toAppendTo the string that will hold the (appended) result\n   * @param pos the fieldposition\n   * @param status the status\n   * @return A textual representation of the number.\n   * @stable ICU 2.0\n   */\n  virtual UnicodeString& format(double number,\n                                const UnicodeString& ruleSetName,\n                                UnicodeString& toAppendTo,\n                                FieldPosition& pos,\n                                UErrorCode& status) const;\n\n  /**\n   * Formats the specified number using the default ruleset.\n   * @param obj The number to format.\n   * @param toAppendTo the string that will hold the (appended) result\n   * @param pos the fieldposition\n   * @param status the status\n   * @return A textual representation of the number.\n   * @stable ICU 2.0\n   */\n  virtual UnicodeString& format(const Formattable& obj,\n                                UnicodeString& toAppendTo,\n                                FieldPosition& pos,\n                                UErrorCode& status) const;\n  /**\n   * Redeclared Format method.\n   * @param obj    the object to be formatted.\n   * @param result Output param which will receive the formatted string.\n   * @param status Output param set to success/failure code\n   * @return       A reference to 'result'.\n   * @stable ICU 2.0\n   */\n  UnicodeString& format(const Formattable& obj,\n                        UnicodeString& result,\n                        UErrorCode& status) const;\n\n  /**\n   * Redeclared NumberFormat method.\n   * @param number    the double value to be formatted.\n   * @param output    Output param which will receive the formatted string.\n   * @return          A reference to 'output'.\n   * @stable ICU 2.0\n   */\n   UnicodeString& format(double number,\n                         UnicodeString& output) const;\n\n  /**\n   * Redeclared NumberFormat method.\n   * @param number    the long value to be formatted.\n   * @param output    Output param which will receive the formatted string.\n   * @return          A reference to 'output'.\n   * @stable ICU 2.0\n   */\n   UnicodeString& format(int32_t number,\n                         UnicodeString& output) const;\n\n  /**\n   * Parses the specfied string, beginning at the specified position, according\n   * to this formatter's rules.  This will match the string against all of the\n   * formatter's public rule sets and return the value corresponding to the longest\n   * parseable substring.  This function's behavior is affected by the lenient\n   * parse mode.\n   * @param text The string to parse\n   * @param result the result of the parse, either a double or a long.\n   * @param parsePosition On entry, contains the position of the first character\n   * in \"text\" to examine.  On exit, has been updated to contain the position\n   * of the first character in \"text\" that wasn't consumed by the parse.\n   * @see #setLenient\n   * @stable ICU 2.0\n   */\n  virtual void parse(const UnicodeString& text,\n                     Formattable& result,\n                     ParsePosition& parsePosition) const;\n\n\n  /**\n   * Redeclared Format method.\n   * @param text   The string to parse\n   * @param result the result of the parse, either a double or a long.\n   * @param status Output param set to failure code when a problem occurs.\n   * @stable ICU 2.0\n   */\n  virtual inline void parse(const UnicodeString& text,\n                      Formattable& result,\n                      UErrorCode& status) const;\n\n#if !UCONFIG_NO_COLLATION\n\n  /**\n   * Turns lenient parse mode on and off.\n   *\n   * When in lenient parse mode, the formatter uses a Collator for parsing the text.\n   * Only primary differences are treated as significant.  This means that case\n   * differences, accent differences, alternate spellings of the same letter\n   * (e.g., ae and a-umlaut in German), ignorable characters, etc. are ignored in\n   * matching the text.  In many cases, numerals will be accepted in place of words\n   * or phrases as well.\n   *\n   * For example, all of the following will correctly parse as 255 in English in\n   * lenient-parse mode:\n   * <br>\"two hundred fifty-five\"\n   * <br>\"two hundred fifty five\"\n   * <br>\"TWO HUNDRED FIFTY-FIVE\"\n   * <br>\"twohundredfiftyfive\"\n   * <br>\"2 hundred fifty-5\"\n   *\n   * The Collator used is determined by the locale that was\n   * passed to this object on construction.  The description passed to this object\n   * on construction may supply additional collation rules that are appended to the\n   * end of the default collator for the locale, enabling additional equivalences\n   * (such as adding more ignorable characters or permitting spelled-out version of\n   * symbols; see the demo program for examples).\n   *\n   * It's important to emphasize that even strict parsing is relatively lenient: it\n   * will accept some text that it won't produce as output.  In English, for example,\n   * it will correctly parse \"two hundred zero\" and \"fifteen hundred\".\n   *\n   * @param enabled If true, turns lenient-parse mode on; if false, turns it off.\n   * @see RuleBasedCollator\n   * @stable ICU 2.0\n   */\n  virtual void setLenient(UBool enabled);\n\n  /**\n   * Returns true if lenient-parse mode is turned on.  Lenient parsing is off\n   * by default.\n   * @return true if lenient-parse mode is turned on.\n   * @see #setLenient\n   * @stable ICU 2.0\n   */\n  virtual inline UBool isLenient(void) const;\n\n#endif\n\n  /**\n   * Override the default rule set to use.  If ruleSetName is null, reset\n   * to the initial default rule set.  If the rule set is not a public rule set name,\n   * U_ILLEGAL_ARGUMENT_ERROR is returned in status.\n   * @param ruleSetName the name of the rule set, or null to reset the initial default.\n   * @param status set to failure code when a problem occurs.\n   * @stable ICU 2.6\n   */\n  virtual void setDefaultRuleSet(const UnicodeString& ruleSetName, UErrorCode& status);\n\n  /**\n   * Return the name of the current default rule set.  If the current rule set is\n   * not public, returns a bogus (and empty) UnicodeString.\n   * @return the name of the current default rule set\n   * @stable ICU 3.0\n   */\n  virtual UnicodeString getDefaultRuleSetName() const;\n\npublic:\n    /**\n     * ICU \"poor man's RTTI\", returns a UClassID for this class.\n     *\n     * @stable ICU 2.8\n     */\n    static UClassID U_EXPORT2 getStaticClassID(void);\n\n    /**\n     * ICU \"poor man's RTTI\", returns a UClassID for the actual class.\n     *\n     * @stable ICU 2.8\n     */\n    virtual UClassID getDynamicClassID(void) const;\n\n    /**\n     * Sets the decimal format symbols, which is generally not changed\n     * by the programmer or user. The formatter takes ownership of\n     * symbolsToAdopt; the client must not delete it.\n     *\n     * @param symbolsToAdopt DecimalFormatSymbols to be adopted.\n     * @draft ICU 49\n     */\n    virtual void adoptDecimalFormatSymbols(DecimalFormatSymbols* symbolsToAdopt);\n\n    /**\n     * Sets the decimal format symbols, which is generally not changed\n     * by the programmer or user. A clone of the symbols is created and\n     * the symbols is _not_ adopted; the client is still responsible for\n     * deleting it.\n     *\n     * @param symbols DecimalFormatSymbols.\n     * @draft ICU 49\n     */\n    virtual void setDecimalFormatSymbols(const DecimalFormatSymbols& symbols);\n\nprivate:\n    RuleBasedNumberFormat(); // default constructor not implemented\n\n    // this will ref the localizations if they are not NULL\n    // caller must deref to get adoption\n    RuleBasedNumberFormat(const UnicodeString& description, LocalizationInfo* localizations,\n              const Locale& locale, UParseError& perror, UErrorCode& status);\n\n    void init(const UnicodeString& rules, LocalizationInfo* localizations, UParseError& perror, UErrorCode& status);\n    void dispose();\n    void stripWhitespace(UnicodeString& src);\n    void initDefaultRuleSet();\n    void format(double number, NFRuleSet& ruleSet);\n    NFRuleSet* findRuleSet(const UnicodeString& name, UErrorCode& status) const;\n\n    /* friend access */\n    friend class NFSubstitution;\n    friend class NFRule;\n    friend class FractionalPartSubstitution;\n\n    inline NFRuleSet * getDefaultRuleSet() const;\n    Collator * getCollator() const;\n    DecimalFormatSymbols * getDecimalFormatSymbols() const;\n\nprivate:\n    NFRuleSet **ruleSets;\n    UnicodeString* ruleSetDescriptions;\n    int32_t numRuleSets;\n    NFRuleSet *defaultRuleSet;\n    Locale locale;\n    Collator* collator;\n    DecimalFormatSymbols* decimalFormatSymbols;\n    UBool lenient;\n    UnicodeString* lenientParseRules;\n    LocalizationInfo* localizations;\n};\n\n// ---------------\n\ninline UnicodeString&\nRuleBasedNumberFormat::format(const Formattable& obj,\n                              UnicodeString& result,\n                              UErrorCode& status) const\n{\n    // Don't use Format:: - use immediate base class only,\n    // in case immediate base modifies behavior later.\n    // dlf - the above comment is bogus, if there were a reason to modify\n    // it, it would be virtual, and there's no reason because it is\n    // a one-line macro in NumberFormat anyway, just like this one.\n    return NumberFormat::format(obj, result, status);\n}\n\ninline UnicodeString&\nRuleBasedNumberFormat::format(double number, UnicodeString& output) const {\n    FieldPosition pos(0);\n    return format(number, output, pos);\n}\n\ninline UnicodeString&\nRuleBasedNumberFormat::format(int32_t number, UnicodeString& output) const {\n    FieldPosition pos(0);\n    return format(number, output, pos);\n}\n\ninline void\nRuleBasedNumberFormat::parse(const UnicodeString& text, Formattable& result, UErrorCode& status) const\n{\n    NumberFormat::parse(text, result, status);\n}\n\n#if !UCONFIG_NO_COLLATION\n\ninline UBool\nRuleBasedNumberFormat::isLenient(void) const {\n    return lenient;\n}\n\n#endif\n\ninline NFRuleSet*\nRuleBasedNumberFormat::getDefaultRuleSet() const {\n    return defaultRuleSet;\n}\n\nU_NAMESPACE_END\n\n/* U_HAVE_RBNF */\n#endif\n\n/* RBNF_H */\n#endif\n"
  },
  {
    "path": "deprecated/android/addons/icucompat/unicode/rbtz.h",
    "content": "/*\n*******************************************************************************\n* Copyright (C) 2007-2008, International Business Machines Corporation and    *\n* others. All Rights Reserved.                                                *\n*******************************************************************************\n*/\n#ifndef RBTZ_H\n#define RBTZ_H\n\n#include \"unicode/utypes.h\"\n\n/**\n * \\file \n * \\brief C++ API: Rule based customizable time zone\n */\n\n#if !UCONFIG_NO_FORMATTING\n\n#include \"unicode/basictz.h\"\n#include \"unicode/unistr.h\"\n\nU_NAMESPACE_BEGIN\n\n// forward declaration\nclass UVector;\nstruct Transition;\n\n/**\n * a BasicTimeZone subclass implemented in terms of InitialTimeZoneRule and TimeZoneRule instances\n * @see BasicTimeZone\n * @see InitialTimeZoneRule\n * @see TimeZoneRule\n */\nclass U_I18N_API RuleBasedTimeZone : public BasicTimeZone {\npublic:\n    /**\n     * Constructs a <code>RuleBasedTimeZone</code> object with the ID and the\n     * <code>InitialTimeZoneRule</code>.  The input <code>InitialTimeZoneRule</code>\n     * is adopted by this <code>RuleBasedTimeZone</code>, thus the caller must not\n     * delete it.\n     * @param id                The time zone ID.\n     * @param initialRule       The initial time zone rule.\n     * @stable ICU 3.8\n     */\n    RuleBasedTimeZone(const UnicodeString& id, InitialTimeZoneRule* initialRule);\n\n    /**\n     * Copy constructor.\n     * @param source    The RuleBasedTimeZone object to be copied.\n     * @stable ICU 3.8\n     */\n    RuleBasedTimeZone(const RuleBasedTimeZone& source);\n\n    /**\n     * Destructor.\n     * @stable ICU 3.8\n     */\n    virtual ~RuleBasedTimeZone();\n\n    /**\n     * Assignment operator.\n     * @param right The object to be copied.\n     * @stable ICU 3.8\n     */\n    RuleBasedTimeZone& operator=(const RuleBasedTimeZone& right);\n\n    /**\n     * Return true if the given <code>TimeZone</code> objects are\n     * semantically equal. Objects of different subclasses are considered unequal.\n     * @param that  The object to be compared with.\n     * @return  true if the given <code>TimeZone</code> objects are\n      *semantically equal.\n     * @stable ICU 3.8\n     */\n    virtual UBool operator==(const TimeZone& that) const;\n\n    /**\n     * Return true if the given <code>TimeZone</code> objects are\n     * semantically unequal. Objects of different subclasses are considered unequal.\n     * @param that  The object to be compared with.\n     * @return  true if the given <code>TimeZone</code> objects are\n     * semantically unequal.\n     * @stable ICU 3.8\n     */\n    virtual UBool operator!=(const TimeZone& that) const;\n\n    /**\n     * Adds the <code>TimeZoneRule</code> which represents time transitions.\n     * The <code>TimeZoneRule</code> must have start times, that is, the result\n     * of isTransitionRule() must be true. Otherwise, U_ILLEGAL_ARGUMENT_ERROR\n     * is set to the error code.\n     * The input <code>TimeZoneRule</code> is adopted by this\n     * <code>RuleBasedTimeZone</code> on successful completion of this method,\n     * thus, the caller must not delete it when no error is returned.\n     * After all rules are added, the caller must call complete() method to\n     * make this <code>RuleBasedTimeZone</code> ready to handle common time\n     * zone functions.\n     * @param rule The <code>TimeZoneRule</code>.\n     * @param status Output param to filled in with a success or an error.\n     * @stable ICU 3.8\n     */\n    void addTransitionRule(TimeZoneRule* rule, UErrorCode& status);\n\n    /**\n     * Makes the <code>TimeZoneRule</code> ready to handle actual timezone\n     * calcuation APIs.  This method collects time zone rules specified\n     * by the caller via the constructor and addTransitionRule() and\n     * builds internal structure for making the object ready to support\n     * time zone APIs such as getOffset(), getNextTransition() and others.\n     * @param status Output param to filled in with a success or an error.\n     * @stable ICU 3.8\n     */\n    void complete(UErrorCode& status);\n\n    /**\n     * Clones TimeZone objects polymorphically. Clients are responsible for deleting\n     * the TimeZone object cloned.\n     *\n     * @return   A new copy of this TimeZone object.\n     * @stable ICU 3.8\n     */\n    virtual TimeZone* clone(void) const;\n\n    /**\n     * Returns the TimeZone's adjusted GMT offset (i.e., the number of milliseconds to add\n     * to GMT to get local time in this time zone, taking daylight savings time into\n     * account) as of a particular reference date.  The reference date is used to determine\n     * whether daylight savings time is in effect and needs to be figured into the offset\n     * that is returned (in other words, what is the adjusted GMT offset in this time zone\n     * at this particular date and time?).  For the time zones produced by createTimeZone(),\n     * the reference data is specified according to the Gregorian calendar, and the date\n     * and time fields are local standard time.\n     *\n     * <p>Note: Don't call this method. Instead, call the getOffset(UDate...) overload,\n     * which returns both the raw and the DST offset for a given time. This method\n     * is retained only for backward compatibility.\n     *\n     * @param era        The reference date's era\n     * @param year       The reference date's year\n     * @param month      The reference date's month (0-based; 0 is January)\n     * @param day        The reference date's day-in-month (1-based)\n     * @param dayOfWeek  The reference date's day-of-week (1-based; 1 is Sunday)\n     * @param millis     The reference date's milliseconds in day, local standard time\n     * @param status     Output param to filled in with a success or an error.\n     * @return           The offset in milliseconds to add to GMT to get local time.\n     * @stable ICU 3.8\n     */\n    virtual int32_t getOffset(uint8_t era, int32_t year, int32_t month, int32_t day,\n                              uint8_t dayOfWeek, int32_t millis, UErrorCode& status) const;\n\n    /**\n     * Gets the time zone offset, for current date, modified in case of\n     * daylight savings. This is the offset to add *to* UTC to get local time.\n     *\n     * <p>Note: Don't call this method. Instead, call the getOffset(UDate...) overload,\n     * which returns both the raw and the DST offset for a given time. This method\n     * is retained only for backward compatibility.\n     *\n     * @param era        The reference date's era\n     * @param year       The reference date's year\n     * @param month      The reference date's month (0-based; 0 is January)\n     * @param day        The reference date's day-in-month (1-based)\n     * @param dayOfWeek  The reference date's day-of-week (1-based; 1 is Sunday)\n     * @param millis     The reference date's milliseconds in day, local standard time\n     * @param monthLength The length of the given month in days.\n     * @param status     Output param to filled in with a success or an error.\n     * @return           The offset in milliseconds to add to GMT to get local time.\n     * @stable ICU 3.8\n     */\n    virtual int32_t getOffset(uint8_t era, int32_t year, int32_t month, int32_t day,\n                           uint8_t dayOfWeek, int32_t millis,\n                           int32_t monthLength, UErrorCode& status) const;\n\n    /**\n     * Returns the time zone raw and GMT offset for the given moment\n     * in time.  Upon return, local-millis = GMT-millis + rawOffset +\n     * dstOffset.  All computations are performed in the proleptic\n     * Gregorian calendar.  The default implementation in the TimeZone\n     * class delegates to the 8-argument getOffset().\n     *\n     * @param date moment in time for which to return offsets, in\n     * units of milliseconds from January 1, 1970 0:00 GMT, either GMT\n     * time or local wall time, depending on `local'.\n     * @param local if true, `date' is local wall time; otherwise it\n     * is in GMT time.\n     * @param rawOffset output parameter to receive the raw offset, that\n     * is, the offset not including DST adjustments\n     * @param dstOffset output parameter to receive the DST offset,\n     * that is, the offset to be added to `rawOffset' to obtain the\n     * total offset between local and GMT time. If DST is not in\n     * effect, this value is zero; otherwise it is a positive value,\n     * typically one hour.\n     * @param ec input-output error code\n     * @stable ICU 3.8\n     */\n    virtual void getOffset(UDate date, UBool local, int32_t& rawOffset,\n                           int32_t& dstOffset, UErrorCode& ec) const;\n\n    /**\n     * Sets the TimeZone's raw GMT offset (i.e., the number of milliseconds to add\n     * to GMT to get local time, before taking daylight savings time into account).\n     *\n     * @param offsetMillis  The new raw GMT offset for this time zone.\n     * @stable ICU 3.8\n     */\n    virtual void setRawOffset(int32_t offsetMillis);\n\n    /**\n     * Returns the TimeZone's raw GMT offset (i.e., the number of milliseconds to add\n     * to GMT to get local time, before taking daylight savings time into account).\n     *\n     * @return   The TimeZone's raw GMT offset.\n     * @stable ICU 3.8\n     */\n    virtual int32_t getRawOffset(void) const;\n\n    /**\n     * Queries if this time zone uses daylight savings time.\n     * @return true if this time zone uses daylight savings time,\n     * false, otherwise.\n     * @stable ICU 3.8\n     */\n    virtual UBool useDaylightTime(void) const;\n\n    /**\n     * Queries if the given date is in daylight savings time in\n     * this time zone.\n     * This method is wasteful since it creates a new GregorianCalendar and\n     * deletes it each time it is called. This is a deprecated method\n     * and provided only for Java compatibility.\n     *\n     * @param date the given UDate.\n     * @param status Output param filled in with success/error code.\n     * @return true if the given date is in daylight savings time,\n     * false, otherwise.\n     * @deprecated ICU 2.4. Use Calendar::inDaylightTime() instead.\n     */\n    virtual UBool inDaylightTime(UDate date, UErrorCode& status) const;\n\n    /**\n     * Returns true if this zone has the same rule and offset as another zone.\n     * That is, if this zone differs only in ID, if at all.\n     * @param other the <code>TimeZone</code> object to be compared with\n     * @return true if the given zone is the same as this one,\n     * with the possible exception of the ID\n     * @stable ICU 3.8\n     */\n    virtual UBool hasSameRules(const TimeZone& other) const;\n\n    /**\n     * Gets the first time zone transition after the base time.\n     * @param base      The base time.\n     * @param inclusive Whether the base time is inclusive or not.\n     * @param result    Receives the first transition after the base time.\n     * @return  TRUE if the transition is found.\n     * @stable ICU 3.8\n     */\n    virtual UBool getNextTransition(UDate base, UBool inclusive, TimeZoneTransition& result) /*const*/;\n\n    /**\n     * Gets the most recent time zone transition before the base time.\n     * @param base      The base time.\n     * @param inclusive Whether the base time is inclusive or not.\n     * @param result    Receives the most recent transition before the base time.\n     * @return  TRUE if the transition is found.\n     * @stable ICU 3.8\n     */\n    virtual UBool getPreviousTransition(UDate base, UBool inclusive, TimeZoneTransition& result) /*const*/;\n\n    /**\n     * Returns the number of <code>TimeZoneRule</code>s which represents time transitions,\n     * for this time zone, that is, all <code>TimeZoneRule</code>s for this time zone except\n     * <code>InitialTimeZoneRule</code>.  The return value range is 0 or any positive value.\n     * @param status    Receives error status code.\n     * @return The number of <code>TimeZoneRule</code>s representing time transitions.\n     * @stable ICU 3.8\n     */\n    virtual int32_t countTransitionRules(UErrorCode& status) /*const*/;\n\n    /**\n     * Gets the <code>InitialTimeZoneRule</code> and the set of <code>TimeZoneRule</code>\n     * which represent time transitions for this time zone.  On successful return,\n     * the argument initial points to non-NULL <code>InitialTimeZoneRule</code> and\n     * the array trsrules is filled with 0 or multiple <code>TimeZoneRule</code>\n     * instances up to the size specified by trscount.  The results are referencing the\n     * rule instance held by this time zone instance.  Therefore, after this time zone\n     * is destructed, they are no longer available.\n     * @param initial       Receives the initial timezone rule\n     * @param trsrules      Receives the timezone transition rules\n     * @param trscount      On input, specify the size of the array 'transitions' receiving\n     *                      the timezone transition rules.  On output, actual number of\n     *                      rules filled in the array will be set.\n     * @param status        Receives error status code.\n     * @stable ICU 3.8\n     */\n    virtual void getTimeZoneRules(const InitialTimeZoneRule*& initial,\n        const TimeZoneRule* trsrules[], int32_t& trscount, UErrorCode& status) /*const*/;\n\n    /**\n     * Get time zone offsets from local wall time.\n     * @internal\n     */\n    virtual void getOffsetFromLocal(UDate date, int32_t nonExistingTimeOpt, int32_t duplicatedTimeOpt,\n        int32_t& rawOffset, int32_t& dstOffset, UErrorCode& status) /*const*/;\n\nprivate:\n    void deleteRules(void);\n    void deleteTransitions(void);\n    UVector* copyRules(UVector* source);\n    TimeZoneRule* findRuleInFinal(UDate date, UBool local,\n        int32_t NonExistingTimeOpt, int32_t DuplicatedTimeOpt) const;\n    UBool findNext(UDate base, UBool inclusive, UDate& time, TimeZoneRule*& from, TimeZoneRule*& to) const;\n    UBool findPrev(UDate base, UBool inclusive, UDate& time, TimeZoneRule*& from, TimeZoneRule*& to) const;\n    int32_t getLocalDelta(int32_t rawBefore, int32_t dstBefore, int32_t rawAfter, int32_t dstAfter,\n        int32_t NonExistingTimeOpt, int32_t DuplicatedTimeOpt) const;\n    UDate getTransitionTime(Transition* transition, UBool local,\n        int32_t NonExistingTimeOpt, int32_t DuplicatedTimeOpt) const;\n    void getOffsetInternal(UDate date, UBool local, int32_t NonExistingTimeOpt, int32_t DuplicatedTimeOpt,\n        int32_t& rawOffset, int32_t& dstOffset, UErrorCode& ec) const;\n\n    InitialTimeZoneRule *fInitialRule;\n    UVector             *fHistoricRules;\n    UVector             *fFinalRules;\n    UVector             *fHistoricTransitions;\n    UBool               fUpToDate;\n\npublic:\n    /**\n     * Return the class ID for this class. This is useful only for comparing to\n     * a return value from getDynamicClassID(). For example:\n     * <pre>\n     * .   Base* polymorphic_pointer = createPolymorphicObject();\n     * .   if (polymorphic_pointer->getDynamicClassID() ==\n     * .       erived::getStaticClassID()) ...\n     * </pre>\n     * @return          The class ID for all objects of this class.\n     * @stable ICU 3.8\n     */\n    static UClassID U_EXPORT2 getStaticClassID(void);\n\n    /**\n     * Returns a unique class ID POLYMORPHICALLY. Pure virtual override. This\n     * method is to implement a simple version of RTTI, since not all C++\n     * compilers support genuine RTTI. Polymorphic operator==() and clone()\n     * methods call this method.\n     *\n     * @return          The class ID for this object. All objects of a\n     *                  given class have the same class ID.  Objects of\n     *                  other classes have different class IDs.\n     * @stable ICU 3.8\n     */\n    virtual UClassID getDynamicClassID(void) const;\n};\n\nU_NAMESPACE_END\n\n#endif /* #if !UCONFIG_NO_FORMATTING */\n\n#endif // RBTZ_H\n\n//eof\n"
  },
  {
    "path": "deprecated/android/addons/icucompat/unicode/regex.h",
    "content": "/*\n**********************************************************************\n*   Copyright (C) 2002-2012, International Business Machines\n*   Corporation and others.  All Rights Reserved.\n**********************************************************************\n*   file name:  regex.h\n*   encoding:   US-ASCII\n*   indentation:4\n*\n*   created on: 2002oct22\n*   created by: Andy Heninger\n*\n*   ICU Regular Expressions, API for C++\n*/\n\n#ifndef REGEX_H\n#define REGEX_H\n\n//#define REGEX_DEBUG\n\n/**\n * \\file\n * \\brief  C++ API:  Regular Expressions\n *\n * <h2>Regular Expression API</h2>\n *\n * <p>The ICU API for processing regular expressions consists of two classes,\n *  <code>RegexPattern</code> and <code>RegexMatcher</code>.\n *  <code>RegexPattern</code> objects represent a pre-processed, or compiled\n *  regular expression.  They are created from a regular expression pattern string,\n *  and can be used to create <code>RegexMatcher</code> objects for the pattern.</p>\n *\n * <p>Class <code>RegexMatcher</code> bundles together a regular expression\n *  pattern and a target string to which the search pattern will be applied.\n *  <code>RegexMatcher</code> includes API for doing plain find or search\n *  operations, for search and replace operations, and for obtaining detailed\n *  information about bounds of a match. </p>\n *\n * <p>Note that by constructing <code>RegexMatcher</code> objects directly from regular\n * expression pattern strings application code can be simplified and the explicit\n * need for <code>RegexPattern</code> objects can usually be eliminated.\n * </p>\n */\n\n#include \"unicode/utypes.h\"\n\n#if !UCONFIG_NO_REGULAR_EXPRESSIONS\n\n#include \"unicode/uobject.h\"\n#include \"unicode/unistr.h\"\n#include \"unicode/utext.h\"\n#include \"unicode/parseerr.h\"\n\n#include \"unicode/uregex.h\"\n\n// Forward Declarations\n\nU_NAMESPACE_BEGIN\n\nstruct Regex8BitSet;\nclass  RegexCImpl;\nclass  RegexMatcher;\nclass  RegexPattern;\nstruct REStackFrame;\nclass  RuleBasedBreakIterator;\nclass  UnicodeSet;\nclass  UVector;\nclass  UVector32;\nclass  UVector64;\n\n/**\n *   RBBIPatternDump   Debug function, displays the compiled form of a pattern.\n *   @internal\n */\n#ifdef REGEX_DEBUG\nU_INTERNAL void U_EXPORT2\n    RegexPatternDump(const RegexPattern *pat);\n#else\n    #undef RegexPatternDump\n    #define RegexPatternDump(pat)\n#endif\n\n\n\n/**\n  * Class <code>RegexPattern</code> represents a compiled regular expression.  It includes\n  * factory methods for creating a RegexPattern object from the source (string) form\n  * of a regular expression, methods for creating RegexMatchers that allow the pattern\n  * to be applied to input text, and a few convenience methods for simple common\n  * uses of regular expressions.\n  *\n  * <p>Class RegexPattern is not intended to be subclassed.</p>\n  *\n  * @stable ICU 2.4\n  */\nclass U_I18N_API RegexPattern: public UObject {\npublic:\n\n    /**\n     * default constructor.  Create a RegexPattern object that refers to no actual\n     *   pattern.  Not normally needed; RegexPattern objects are usually\n     *   created using the factory method <code>compile()</code>.\n     *\n     * @stable ICU 2.4\n     */\n    RegexPattern();\n\n    /**\n     * Copy Constructor.  Create a new RegexPattern object that is equivalent\n     *                    to the source object.\n     * @param source the pattern object to be copied.\n     * @stable ICU 2.4\n     */\n    RegexPattern(const RegexPattern &source);\n\n    /**\n     * Destructor.  Note that a RegexPattern object must persist so long as any\n     *  RegexMatcher objects that were created from the RegexPattern are active.\n     * @stable ICU 2.4\n     */\n    virtual ~RegexPattern();\n\n    /**\n     * Comparison operator.  Two RegexPattern objects are considered equal if they\n     * were constructed from identical source patterns using the same match flag\n     * settings.\n     * @param that a RegexPattern object to compare with \"this\".\n     * @return TRUE if the objects are equivalent.\n     * @stable ICU 2.4\n     */\n    UBool           operator==(const RegexPattern& that) const;\n\n    /**\n     * Comparison operator.  Two RegexPattern objects are considered equal if they\n     * were constructed from identical source patterns using the same match flag\n     * settings.\n     * @param that a RegexPattern object to compare with \"this\".\n     * @return TRUE if the objects are different.\n     * @stable ICU 2.4\n     */\n    inline UBool    operator!=(const RegexPattern& that) const {return ! operator ==(that);}\n\n    /**\n     * Assignment operator.  After assignment, this RegexPattern will behave identically\n     *     to the source object.\n     * @stable ICU 2.4\n     */\n    RegexPattern  &operator =(const RegexPattern &source);\n\n    /**\n     * Create an exact copy of this RegexPattern object.  Since RegexPattern is not\n     * intended to be subclasses, <code>clone()</code> and the copy construction are\n     * equivalent operations.\n     * @return the copy of this RegexPattern\n     * @stable ICU 2.4\n     */\n    virtual RegexPattern  *clone() const;\n\n\n   /**\n    * Compiles the regular expression in string form into a RegexPattern\n    * object.  These compile methods, rather than the constructors, are the usual\n    * way that RegexPattern objects are created.\n    *\n    * <p>Note that RegexPattern objects must not be deleted while RegexMatcher\n    * objects created from the pattern are active.  RegexMatchers keep a pointer\n    * back to their pattern, so premature deletion of the pattern is a\n    * catastrophic error.</p>\n    *\n    * <p>All pattern match mode flags are set to their default values.</p>\n    *\n    * <p>Note that it is often more convenient to construct a RegexMatcher directly\n    *    from a pattern string rather than separately compiling the pattern and\n    *    then creating a RegexMatcher object from the pattern.</p>\n    *\n    * @param regex The regular expression to be compiled.\n    * @param pe    Receives the position (line and column nubers) of any error\n    *              within the regular expression.)\n    * @param status A reference to a UErrorCode to receive any errors.\n    * @return      A regexPattern object for the compiled pattern.\n    *\n    * @stable ICU 2.4\n    */\n    static RegexPattern * U_EXPORT2 compile( const UnicodeString &regex,\n        UParseError          &pe,\n        UErrorCode           &status);\n\n   /**\n    * Compiles the regular expression in string form into a RegexPattern\n    * object.  These compile methods, rather than the constructors, are the usual\n    * way that RegexPattern objects are created.\n    *\n    * <p>Note that RegexPattern objects must not be deleted while RegexMatcher\n    * objects created from the pattern are active.  RegexMatchers keep a pointer\n    * back to their pattern, so premature deletion of the pattern is a\n    * catastrophic error.</p>\n    *\n    * <p>All pattern match mode flags are set to their default values.</p>\n    *\n    * <p>Note that it is often more convenient to construct a RegexMatcher directly\n    *    from a pattern string rather than separately compiling the pattern and\n    *    then creating a RegexMatcher object from the pattern.</p>\n    *\n    * @param regex The regular expression to be compiled. Note, the text referred\n    *              to by this UText must not be deleted during the lifetime of the\n    *              RegexPattern object or any RegexMatcher object created from it.\n    * @param pe    Receives the position (line and column nubers) of any error\n    *              within the regular expression.)\n    * @param status A reference to a UErrorCode to receive any errors.\n    * @return      A regexPattern object for the compiled pattern.\n    *\n    * @stable ICU 4.6\n    */\n    static RegexPattern * U_EXPORT2 compile( UText *regex,\n        UParseError          &pe,\n        UErrorCode           &status);\n\n   /**\n    * Compiles the regular expression in string form into a RegexPattern\n    * object using the specified match mode flags.  These compile methods,\n    * rather than the constructors, are the usual way that RegexPattern objects\n    * are created.\n    *\n    * <p>Note that RegexPattern objects must not be deleted while RegexMatcher\n    * objects created from the pattern are active.  RegexMatchers keep a pointer\n    * back to their pattern, so premature deletion of the pattern is a\n    * catastrophic error.</p>\n    *\n    * <p>Note that it is often more convenient to construct a RegexMatcher directly\n    *    from a pattern string instead of than separately compiling the pattern and\n    *    then creating a RegexMatcher object from the pattern.</p>\n    *\n    * @param regex The regular expression to be compiled.\n    * @param flags The match mode flags to be used.\n    * @param pe    Receives the position (line and column numbers) of any error\n    *              within the regular expression.)\n    * @param status   A reference to a UErrorCode to receive any errors.\n    * @return      A regexPattern object for the compiled pattern.\n    *\n    * @stable ICU 2.4\n    */\n    static RegexPattern * U_EXPORT2 compile( const UnicodeString &regex,\n        uint32_t             flags,\n        UParseError          &pe,\n        UErrorCode           &status);\n\n   /**\n    * Compiles the regular expression in string form into a RegexPattern\n    * object using the specified match mode flags.  These compile methods,\n    * rather than the constructors, are the usual way that RegexPattern objects\n    * are created.\n    *\n    * <p>Note that RegexPattern objects must not be deleted while RegexMatcher\n    * objects created from the pattern are active.  RegexMatchers keep a pointer\n    * back to their pattern, so premature deletion of the pattern is a\n    * catastrophic error.</p>\n    *\n    * <p>Note that it is often more convenient to construct a RegexMatcher directly\n    *    from a pattern string instead of than separately compiling the pattern and\n    *    then creating a RegexMatcher object from the pattern.</p>\n    *\n    * @param regex The regular expression to be compiled. Note, the text referred\n    *              to by this UText must not be deleted during the lifetime of the\n    *              RegexPattern object or any RegexMatcher object created from it.\n    * @param flags The match mode flags to be used.\n    * @param pe    Receives the position (line and column numbers) of any error\n    *              within the regular expression.)\n    * @param status   A reference to a UErrorCode to receive any errors.\n    * @return      A regexPattern object for the compiled pattern.\n    *\n    * @stable ICU 4.6\n    */\n    static RegexPattern * U_EXPORT2 compile( UText *regex,\n        uint32_t             flags,\n        UParseError          &pe,\n        UErrorCode           &status);\n\n   /**\n    * Compiles the regular expression in string form into a RegexPattern\n    * object using the specified match mode flags.  These compile methods,\n    * rather than the constructors, are the usual way that RegexPattern objects\n    * are created.\n    *\n    * <p>Note that RegexPattern objects must not be deleted while RegexMatcher\n    * objects created from the pattern are active.  RegexMatchers keep a pointer\n    * back to their pattern, so premature deletion of the pattern is a\n    * catastrophic error.</p>\n    *\n    * <p>Note that it is often more convenient to construct a RegexMatcher directly\n    *    from a pattern string instead of than separately compiling the pattern and\n    *    then creating a RegexMatcher object from the pattern.</p>\n    *\n    * @param regex The regular expression to be compiled.\n    * @param flags The match mode flags to be used.\n    * @param status   A reference to a UErrorCode to receive any errors.\n    * @return      A regexPattern object for the compiled pattern.\n    *\n    * @stable ICU 2.6\n    */\n    static RegexPattern * U_EXPORT2 compile( const UnicodeString &regex,\n        uint32_t             flags,\n        UErrorCode           &status);\n\n   /**\n    * Compiles the regular expression in string form into a RegexPattern\n    * object using the specified match mode flags.  These compile methods,\n    * rather than the constructors, are the usual way that RegexPattern objects\n    * are created.\n    *\n    * <p>Note that RegexPattern objects must not be deleted while RegexMatcher\n    * objects created from the pattern are active.  RegexMatchers keep a pointer\n    * back to their pattern, so premature deletion of the pattern is a\n    * catastrophic error.</p>\n    *\n    * <p>Note that it is often more convenient to construct a RegexMatcher directly\n    *    from a pattern string instead of than separately compiling the pattern and\n    *    then creating a RegexMatcher object from the pattern.</p>\n    *\n    * @param regex The regular expression to be compiled. Note, the text referred\n    *              to by this UText must not be deleted during the lifetime of the\n    *              RegexPattern object or any RegexMatcher object created from it.\n    * @param flags The match mode flags to be used.\n    * @param status   A reference to a UErrorCode to receive any errors.\n    * @return      A regexPattern object for the compiled pattern.\n    *\n    * @stable ICU 4.6\n    */\n    static RegexPattern * U_EXPORT2 compile( UText *regex,\n        uint32_t             flags,\n        UErrorCode           &status);\n\n   /**\n    * Get the match mode flags that were used when compiling this pattern.\n    * @return  the match mode flags\n    * @stable ICU 2.4\n    */\n    virtual uint32_t flags() const;\n\n   /**\n    * Creates a RegexMatcher that will match the given input against this pattern.  The\n    * RegexMatcher can then be used to perform match, find or replace operations\n    * on the input.  Note that a RegexPattern object must not be deleted while\n    * RegexMatchers created from it still exist and might possibly be used again.\n    * <p>\n    * The matcher will retain a reference to the supplied input string, and all regexp\n    * pattern matching operations happen directly on this original string.  It is\n    * critical that the string not be altered or deleted before use by the regular\n    * expression operations is complete.\n    *\n    * @param input    The input string to which the regular expression will be applied.\n    * @param status   A reference to a UErrorCode to receive any errors.\n    * @return         A RegexMatcher object for this pattern and input.\n    *\n    * @stable ICU 2.4\n    */\n    virtual RegexMatcher *matcher(const UnicodeString &input,\n        UErrorCode          &status) const;\n        \nprivate:\n    /**\n     * Cause a compilation error if an application accidentally attempts to\n     *   create a matcher with a (UChar *) string as input rather than\n     *   a UnicodeString.  Avoids a dangling reference to a temporary string.\n     * <p>\n     * To efficiently work with UChar *strings, wrap the data in a UnicodeString\n     * using one of the aliasing constructors, such as\n     * <code>UnicodeString(UBool isTerminated, const UChar *text, int32_t textLength);</code>\n     * or in a UText, using\n     * <code>utext_openUChars(UText *ut, const UChar *text, int64_t textLength, UErrorCode *status);</code>\n     *\n     * @internal\n     */\n    RegexMatcher *matcher(const UChar *input,\n        UErrorCode          &status) const;\npublic:\n\n\n   /**\n    * Creates a RegexMatcher that will match against this pattern.  The\n    * RegexMatcher can be used to perform match, find or replace operations.\n    * Note that a RegexPattern object must not be deleted while\n    * RegexMatchers created from it still exist and might possibly be used again.\n    *\n    * @param status   A reference to a UErrorCode to receive any errors.\n    * @return      A RegexMatcher object for this pattern and input.\n    *\n    * @stable ICU 2.6\n    */\n    virtual RegexMatcher *matcher(UErrorCode  &status) const;\n\n\n   /**\n    * Test whether a string matches a regular expression.  This convenience function\n    * both compiles the regular expression and applies it in a single operation.\n    * Note that if the same pattern needs to be applied repeatedly, this method will be\n    * less efficient than creating and reusing a RegexMatcher object.\n    *\n    * @param regex The regular expression\n    * @param input The string data to be matched\n    * @param pe Receives the position of any syntax errors within the regular expression\n    * @param status A reference to a UErrorCode to receive any errors.\n    * @return True if the regular expression exactly matches the full input string.\n    *\n    * @stable ICU 2.4\n    */\n    static UBool U_EXPORT2 matches(const UnicodeString   &regex,\n        const UnicodeString   &input,\n              UParseError     &pe,\n              UErrorCode      &status);\n\n   /**\n    * Test whether a string matches a regular expression.  This convenience function\n    * both compiles the regular expression and applies it in a single operation.\n    * Note that if the same pattern needs to be applied repeatedly, this method will be\n    * less efficient than creating and reusing a RegexMatcher object.\n    *\n    * @param regex The regular expression\n    * @param input The string data to be matched\n    * @param pe Receives the position of any syntax errors within the regular expression\n    * @param status A reference to a UErrorCode to receive any errors.\n    * @return True if the regular expression exactly matches the full input string.\n    *\n    * @stable ICU 4.6\n    */\n    static UBool U_EXPORT2 matches(UText *regex,\n        UText           *input,\n        UParseError     &pe,\n        UErrorCode      &status);\n\n   /**\n    * Returns the regular expression from which this pattern was compiled. This method will work\n    * even if the pattern was compiled from a UText.\n    *\n    * Note: If the pattern was originally compiled from a UText, and that UText was modified,\n    * the returned string may no longer reflect the RegexPattern object.\n    * @stable ICU 2.4\n    */\n    virtual UnicodeString pattern() const;\n    \n    \n   /**\n    * Returns the regular expression from which this pattern was compiled. This method will work\n    * even if the pattern was compiled from a UnicodeString.\n    *\n    * Note: This is the original input, not a clone. If the pattern was originally compiled from a\n    * UText, and that UText was modified, the returned UText may no longer reflect the RegexPattern\n    * object.\n    *\n    * @stable ICU 4.6\n    */\n    virtual UText *patternText(UErrorCode      &status) const;\n\n\n    /**\n     * Split a string into fields.  Somewhat like split() from Perl or Java.\n     * Pattern matches identify delimiters that separate the input\n     * into fields.  The input data between the delimiters becomes the\n     * fields themselves.\n     *\n     * If the delimiter pattern includes capture groups, the captured text will\n     * also appear in the destination array of output strings, interspersed\n     * with the fields.  This is similar to Perl, but differs from Java, \n     * which ignores the presence of capture groups in the pattern.\n     * \n     * Trailing empty fields will always be returned, assuming sufficient\n     * destination capacity.  This differs from the default behavior for Java\n     * and Perl where trailing empty fields are not returned.\n     *\n     * The number of strings produced by the split operation is returned.\n     * This count includes the strings from capture groups in the delimiter pattern.\n     * This behavior differs from Java, which ignores capture groups.\n     *\n     * For the best performance on split() operations,\n     * <code>RegexMatcher::split</code> is preferable to this function\n     *\n     * @param input   The string to be split into fields.  The field delimiters\n     *                match the pattern (in the \"this\" object)\n     * @param dest    An array of UnicodeStrings to receive the results of the split.\n     *                This is an array of actual UnicodeString objects, not an\n     *                array of pointers to strings.  Local (stack based) arrays can\n     *                work well here.\n     * @param destCapacity  The number of elements in the destination array.\n     *                If the number of fields found is less than destCapacity, the\n     *                extra strings in the destination array are not altered.\n     *                If the number of destination strings is less than the number\n     *                of fields, the trailing part of the input string, including any\n     *                field delimiters, is placed in the last destination string.\n     * @param status  A reference to a UErrorCode to receive any errors.\n     * @return        The number of fields into which the input string was split.\n     * @stable ICU 2.4\n     */\n    virtual int32_t  split(const UnicodeString &input,\n        UnicodeString    dest[],\n        int32_t          destCapacity,\n        UErrorCode       &status) const;\n\n\n    /**\n     * Split a string into fields.  Somewhat like split() from Perl or Java.\n     * Pattern matches identify delimiters that separate the input\n     * into fields.  The input data between the delimiters becomes the\n     * fields themselves.\n     *\n     * If the delimiter pattern includes capture groups, the captured text will\n     * also appear in the destination array of output strings, interspersed\n     * with the fields.  This is similar to Perl, but differs from Java, \n     * which ignores the presence of capture groups in the pattern.\n     * \n     * Trailing empty fields will always be returned, assuming sufficient\n     * destination capacity.  This differs from the default behavior for Java\n     * and Perl where trailing empty fields are not returned.\n     *\n     * The number of strings produced by the split operation is returned.\n     * This count includes the strings from capture groups in the delimiter pattern.\n     * This behavior differs from Java, which ignores capture groups.\n     *\n     *  For the best performance on split() operations,\n     *  <code>RegexMatcher::split</code> is preferable to this function\n     *\n     * @param input   The string to be split into fields.  The field delimiters\n     *                match the pattern (in the \"this\" object)\n     * @param dest    An array of mutable UText structs to receive the results of the split.\n     *                If a field is NULL, a new UText is allocated to contain the results for\n     *                that field. This new UText is not guaranteed to be mutable.\n     * @param destCapacity  The number of elements in the destination array.\n     *                If the number of fields found is less than destCapacity, the\n     *                extra strings in the destination array are not altered.\n     *                If the number of destination strings is less than the number\n     *                of fields, the trailing part of the input string, including any\n     *                field delimiters, is placed in the last destination string.\n     * @param status  A reference to a UErrorCode to receive any errors.\n     * @return        The number of destination strings used.  \n     *\n     * @stable ICU 4.6\n     */\n    virtual int32_t  split(UText *input,\n        UText            *dest[],\n        int32_t          destCapacity,\n        UErrorCode       &status) const;\n\n\n    /**\n     * ICU \"poor man's RTTI\", returns a UClassID for the actual class.\n     *\n     * @stable ICU 2.4\n     */\n    virtual UClassID getDynamicClassID() const;\n\n    /**\n     * ICU \"poor man's RTTI\", returns a UClassID for this class.\n     *\n     * @stable ICU 2.4\n     */\n    static UClassID U_EXPORT2 getStaticClassID();\n\nprivate:\n    //\n    //  Implementation Data\n    //\n    UText          *fPattern;      // The original pattern string.\n    UnicodeString  *fPatternString; // The original pattern UncodeString if relevant\n    uint32_t        fFlags;        // The flags used when compiling the pattern.\n                                   //\n    UVector64       *fCompiledPat; // The compiled pattern p-code.\n    UnicodeString   fLiteralText;  // Any literal string data from the pattern,\n                                   //   after un-escaping, for use during the match.\n\n    UVector         *fSets;        // Any UnicodeSets referenced from the pattern.\n    Regex8BitSet    *fSets8;       //      (and fast sets for latin-1 range.)\n\n\n    UErrorCode      fDeferredStatus; // status if some prior error has left this\n                                   //  RegexPattern in an unusable state.\n\n    int32_t         fMinMatchLen;  // Minimum Match Length.  All matches will have length\n                                   //   >= this value.  For some patterns, this calculated\n                                   //   value may be less than the true shortest\n                                   //   possible match.\n    \n    int32_t         fFrameSize;    // Size of a state stack frame in the\n                                   //   execution engine.\n\n    int32_t         fDataSize;     // The size of the data needed by the pattern that\n                                   //   does not go on the state stack, but has just\n                                   //   a single copy per matcher.\n\n    UVector32       *fGroupMap;    // Map from capture group number to position of\n                                   //   the group's variables in the matcher stack frame.\n\n    int32_t         fMaxCaptureDigits;\n\n    UnicodeSet     **fStaticSets;  // Ptr to static (shared) sets for predefined\n                                   //   regex character classes, e.g. Word.\n\n    Regex8BitSet   *fStaticSets8;  // Ptr to the static (shared) latin-1 only\n                                   //  sets for predefined regex classes.\n\n    int32_t         fStartType;    // Info on how a match must start.\n    int32_t         fInitialStringIdx;     //\n    int32_t         fInitialStringLen;\n    UnicodeSet     *fInitialChars;\n    UChar32         fInitialChar;\n    Regex8BitSet   *fInitialChars8;\n    UBool           fNeedsAltInput;\n\n    friend class RegexCompile;\n    friend class RegexMatcher;\n    friend class RegexCImpl;\n\n    //\n    //  Implementation Methods\n    //\n    void        init();            // Common initialization, for use by constructors.\n    void        zap();             // Common cleanup\n#ifdef REGEX_DEBUG\n    void        dumpOp(int32_t index) const;\n    friend     void U_EXPORT2 RegexPatternDump(const RegexPattern *);\n#endif\n\n};\n\n\n\n/**\n *  class RegexMatcher bundles together a regular expression pattern and\n *  input text to which the expression can be applied.  It includes methods\n *  for testing for matches, and for find and replace operations.\n *\n * <p>Class RegexMatcher is not intended to be subclassed.</p>\n *\n * @stable ICU 2.4\n */\nclass U_I18N_API RegexMatcher: public UObject {\npublic:\n\n    /**\n      * Construct a RegexMatcher for a regular expression.\n      * This is a convenience method that avoids the need to explicitly create\n      * a RegexPattern object.  Note that if several RegexMatchers need to be\n      * created for the same expression, it will be more efficient to\n      * separately create and cache a RegexPattern object, and use\n      * its matcher() method to create the RegexMatcher objects.\n      *\n      *  @param regexp The Regular Expression to be compiled.\n      *  @param flags  Regular expression options, such as case insensitive matching.\n      *                @see UREGEX_CASE_INSENSITIVE\n      *  @param status Any errors are reported by setting this UErrorCode variable.\n      *  @stable ICU 2.6\n      */\n    RegexMatcher(const UnicodeString &regexp, uint32_t flags, UErrorCode &status);\n\n    /**\n      * Construct a RegexMatcher for a regular expression.\n      * This is a convenience method that avoids the need to explicitly create\n      * a RegexPattern object.  Note that if several RegexMatchers need to be\n      * created for the same expression, it will be more efficient to\n      * separately create and cache a RegexPattern object, and use\n      * its matcher() method to create the RegexMatcher objects.\n      *\n      *  @param regexp The regular expression to be compiled.\n      *  @param flags  Regular expression options, such as case insensitive matching.\n      *                @see UREGEX_CASE_INSENSITIVE\n      *  @param status Any errors are reported by setting this UErrorCode variable.\n      *\n      *  @stable ICU 4.6\n      */\n    RegexMatcher(UText *regexp, uint32_t flags, UErrorCode &status);\n\n    /**\n      * Construct a RegexMatcher for a regular expression.\n      * This is a convenience method that avoids the need to explicitly create\n      * a RegexPattern object.  Note that if several RegexMatchers need to be\n      * created for the same expression, it will be more efficient to\n      * separately create and cache a RegexPattern object, and use\n      * its matcher() method to create the RegexMatcher objects.\n      * <p>\n      * The matcher will retain a reference to the supplied input string, and all regexp\n      * pattern matching operations happen directly on the original string.  It is\n      * critical that the string not be altered or deleted before use by the regular\n      * expression operations is complete.\n      *\n      *  @param regexp The Regular Expression to be compiled.\n      *  @param input  The string to match.  The matcher retains a reference to the\n      *                caller's string; mo copy is made.\n      *  @param flags  Regular expression options, such as case insensitive matching.\n      *                @see UREGEX_CASE_INSENSITIVE\n      *  @param status Any errors are reported by setting this UErrorCode variable.\n      *  @stable ICU 2.6\n      */\n    RegexMatcher(const UnicodeString &regexp, const UnicodeString &input,\n        uint32_t flags, UErrorCode &status);\n\n    /**\n      * Construct a RegexMatcher for a regular expression.\n      * This is a convenience method that avoids the need to explicitly create\n      * a RegexPattern object.  Note that if several RegexMatchers need to be\n      * created for the same expression, it will be more efficient to\n      * separately create and cache a RegexPattern object, and use\n      * its matcher() method to create the RegexMatcher objects.\n      * <p>\n      * The matcher will make a shallow clone of the supplied input text, and all regexp\n      * pattern matching operations happen on this clone.  While read-only operations on\n      * the supplied text are permitted, it is critical that the underlying string not be\n      * altered or deleted before use by the regular expression operations is complete.\n      *\n      *  @param regexp The Regular Expression to be compiled.\n      *  @param input  The string to match.  The matcher retains a shallow clone of the text.\n      *  @param flags  Regular expression options, such as case insensitive matching.\n      *                @see UREGEX_CASE_INSENSITIVE\n      *  @param status Any errors are reported by setting this UErrorCode variable.\n      *\n      *  @stable ICU 4.6\n      */\n    RegexMatcher(UText *regexp, UText *input,\n        uint32_t flags, UErrorCode &status);\n\nprivate:\n    /**\n     * Cause a compilation error if an application accidentally attempts to\n     *   create a matcher with a (UChar *) string as input rather than\n     *   a UnicodeString.    Avoids a dangling reference to a temporary string.\n     * <p>\n     * To efficiently work with UChar *strings, wrap the data in a UnicodeString\n     * using one of the aliasing constructors, such as\n     * <code>UnicodeString(UBool isTerminated, const UChar *text, int32_t textLength);</code>\n     * or in a UText, using\n     * <code>utext_openUChars(UText *ut, const UChar *text, int64_t textLength, UErrorCode *status);</code>\n     *\n     * @internal\n     */\n    RegexMatcher(const UnicodeString &regexp, const UChar *input,\n        uint32_t flags, UErrorCode &status);\npublic:\n\n\n   /**\n    *   Destructor.\n    *\n    *  @stable ICU 2.4\n    */\n    virtual ~RegexMatcher();\n\n\n   /**\n    *   Attempts to match the entire input region against the pattern.\n    *    @param   status     A reference to a UErrorCode to receive any errors.\n    *    @return TRUE if there is a match\n    *    @stable ICU 2.4\n    */\n    virtual UBool matches(UErrorCode &status);\n\n\n   /**\n    *   Resets the matcher, then attempts to match the input beginning \n    *   at the specified startIndex, and extending to the end of the input.\n    *   The input region is reset to include the entire input string.\n    *   A successful match must extend to the end of the input.\n    *    @param   startIndex The input string (native) index at which to begin matching.\n    *    @param   status     A reference to a UErrorCode to receive any errors.\n    *    @return TRUE if there is a match\n    *    @stable ICU 2.8\n    */\n    virtual UBool matches(int64_t startIndex, UErrorCode &status);\n\n\n   /**\n    *   Attempts to match the input string, starting from the beginning of the region,\n    *   against the pattern.  Like the matches() method, this function \n    *   always starts at the beginning of the input region;\n    *   unlike that function, it does not require that the entire region be matched.\n    *\n    *   <p>If the match succeeds then more information can be obtained via the <code>start()</code>,\n    *     <code>end()</code>, and <code>group()</code> functions.</p>\n    *\n    *    @param   status     A reference to a UErrorCode to receive any errors.\n    *    @return  TRUE if there is a match at the start of the input string.\n    *    @stable ICU 2.4\n    */\n    virtual UBool lookingAt(UErrorCode &status);\n\n\n  /**\n    *   Attempts to match the input string, starting from the specified index, against the pattern.\n    *   The match may be of any length, and is not required to extend to the end\n    *   of the input string.  Contrast with match().\n    *\n    *   <p>If the match succeeds then more information can be obtained via the <code>start()</code>,\n    *     <code>end()</code>, and <code>group()</code> functions.</p>\n    *\n    *    @param   startIndex The input string (native) index at which to begin matching.\n    *    @param   status     A reference to a UErrorCode to receive any errors.\n    *    @return  TRUE if there is a match.\n    *    @stable ICU 2.8\n    */\n    virtual UBool lookingAt(int64_t startIndex, UErrorCode &status);\n\n\n   /**\n    *  Find the next pattern match in the input string.\n    *  The find begins searching the input at the location following the end of\n    *  the previous match, or at the start of the string if there is no previous match.\n    *  If a match is found, <code>start(), end()</code> and <code>group()</code>\n    *  will provide more information regarding the match.\n    *  <p>Note that if the input string is changed by the application,\n    *     use find(startPos, status) instead of find(), because the saved starting\n    *     position may not be valid with the altered input string.</p>\n    *  @return  TRUE if a match is found.\n    *  @stable ICU 2.4\n    */\n    virtual UBool find();\n\n\n   /**\n    *   Resets this RegexMatcher and then attempts to find the next substring of the\n    *   input string that matches the pattern, starting at the specified index.\n    *\n    *   @param   start     The (native) index in the input string to begin the search.\n    *   @param   status    A reference to a UErrorCode to receive any errors.\n    *   @return  TRUE if a match is found.\n    *   @stable ICU 2.4\n    */\n    virtual UBool find(int64_t start, UErrorCode &status);\n\n\n   /**\n    *   Returns a string containing the text matched by the previous match.\n    *   If the pattern can match an empty string, an empty string may be returned.\n    *   @param   status      A reference to a UErrorCode to receive any errors.\n    *                        Possible errors are  U_REGEX_INVALID_STATE if no match\n    *                        has been attempted or the last match failed.\n    *   @return  a string containing the matched input text.\n    *   @stable ICU 2.4\n    */\n    virtual UnicodeString group(UErrorCode &status) const;\n\n\n   /**\n    *    Returns a string containing the text captured by the given group\n    *    during the previous match operation.  Group(0) is the entire match.\n    *\n    *    @param groupNum the capture group number\n    *    @param   status     A reference to a UErrorCode to receive any errors.\n    *                        Possible errors are  U_REGEX_INVALID_STATE if no match\n    *                        has been attempted or the last match failed and\n    *                        U_INDEX_OUTOFBOUNDS_ERROR for a bad capture group number.\n    *    @return the captured text\n    *    @stable ICU 2.4\n    */\n    virtual UnicodeString group(int32_t groupNum, UErrorCode &status) const;\n\n\n   /**\n    *   Returns the number of capturing groups in this matcher's pattern.\n    *   @return the number of capture groups\n    *   @stable ICU 2.4\n    */\n    virtual int32_t groupCount() const;\n\n\n   /**\n    *   Returns a shallow clone of the entire live input string with the UText current native index\n    *   set to the beginning of the requested group.\n    *\n    *   @param   dest        The UText into which the input should be cloned, or NULL to create a new UText\n    *   @param   group_len   A reference to receive the length of the desired capture group\n    *   @param   status      A reference to a UErrorCode to receive any errors.\n    *                        Possible errors are  U_REGEX_INVALID_STATE if no match\n    *                        has been attempted or the last match failed and\n    *                        U_INDEX_OUTOFBOUNDS_ERROR for a bad capture group number.\n    *   @return dest if non-NULL, a shallow copy of the input text otherwise\n    *\n    *   @stable ICU 4.6\n    */\n    virtual UText *group(UText *dest, int64_t &group_len, UErrorCode &status) const; \n\n   /**\n    *   Returns a shallow clone of the entire live input string with the UText current native index\n    *   set to the beginning of the requested group.\n    *\n    *   @param   groupNum   The capture group number.\n    *   @param   dest        The UText into which the input should be cloned, or NULL to create a new UText.\n    *   @param   group_len   A reference to receive the length of the desired capture group\n    *   @param   status      A reference to a UErrorCode to receive any errors.\n    *                        Possible errors are  U_REGEX_INVALID_STATE if no match\n    *                        has been attempted or the last match failed and\n    *                        U_INDEX_OUTOFBOUNDS_ERROR for a bad capture group number.\n    *   @return dest if non-NULL, a shallow copy of the input text otherwise\n    *\n    *   @stable ICU 4.6\n    */\n    virtual UText *group(int32_t groupNum, UText *dest, int64_t &group_len, UErrorCode &status) const;\n\n   /**\n    *   Returns a string containing the text captured by the given group\n    *   during the previous match operation.  Group(0) is the entire match.\n    *\n    *   @param   groupNum    the capture group number\n    *   @param   dest        A mutable UText in which the matching text is placed.\n    *                        If NULL, a new UText will be created (which may not be mutable).\n    *   @param   status      A reference to a UErrorCode to receive any errors.\n    *                        Possible errors are  U_REGEX_INVALID_STATE if no match\n    *                        has been attempted or the last match failed.\n    *   @return  A string containing the matched input text. If a pre-allocated UText\n    *            was provided, it will always be used and returned.\n    *\n    *   @internal ICU 4.4 technology preview\n    */\n    virtual UText *group(int32_t groupNum, UText *dest, UErrorCode &status) const;\n\n\n   /**\n    *   Returns the index in the input string of the start of the text matched\n    *   during the previous match operation.\n    *    @param   status      a reference to a UErrorCode to receive any errors.\n    *    @return              The (native) position in the input string of the start of the last match.\n    *    @stable ICU 2.4\n    */\n    virtual int32_t start(UErrorCode &status) const;\n\n   /**\n    *   Returns the index in the input string of the start of the text matched\n    *   during the previous match operation.\n    *    @param   status      a reference to a UErrorCode to receive any errors.\n    *    @return              The (native) position in the input string of the start of the last match.\n    *   @stable ICU 4.6\n    */\n    virtual int64_t start64(UErrorCode &status) const;\n\n\n   /**\n    *   Returns the index in the input string of the start of the text matched by the\n    *    specified capture group during the previous match operation.  Return -1 if\n    *    the capture group exists in the pattern, but was not part of the last match.\n    *\n    *    @param  group       the capture group number\n    *    @param  status      A reference to a UErrorCode to receive any errors.  Possible\n    *                        errors are  U_REGEX_INVALID_STATE if no match has been\n    *                        attempted or the last match failed, and\n    *                        U_INDEX_OUTOFBOUNDS_ERROR for a bad capture group number\n    *    @return the (native) start position of substring matched by the specified group.\n    *    @stable ICU 2.4\n    */\n    virtual int32_t start(int32_t group, UErrorCode &status) const;\n\n   /**\n    *   Returns the index in the input string of the start of the text matched by the\n    *    specified capture group during the previous match operation.  Return -1 if\n    *    the capture group exists in the pattern, but was not part of the last match.\n    *\n    *    @param  group       the capture group number.\n    *    @param  status      A reference to a UErrorCode to receive any errors.  Possible\n    *                        errors are  U_REGEX_INVALID_STATE if no match has been\n    *                        attempted or the last match failed, and\n    *                        U_INDEX_OUTOFBOUNDS_ERROR for a bad capture group number.\n    *    @return the (native) start position of substring matched by the specified group.\n    *    @stable ICU 4.6\n    */\n    virtual int64_t start64(int32_t group, UErrorCode &status) const;\n\n\n   /**\n    *    Returns the index in the input string of the first character following the\n    *    text matched during the previous match operation.\n    *\n    *   @param   status      A reference to a UErrorCode to receive any errors.  Possible\n    *                        errors are  U_REGEX_INVALID_STATE if no match has been\n    *                        attempted or the last match failed.\n    *    @return the index of the last character matched, plus one.\n    *                        The index value returned is a native index, corresponding to\n    *                        code units for the underlying encoding type, for example,\n    *                        a byte index for UTF-8.\n    *   @stable ICU 2.4\n    */\n    virtual int32_t end(UErrorCode &status) const;\n\n   /**\n    *    Returns the index in the input string of the first character following the\n    *    text matched during the previous match operation.\n    *\n    *   @param   status      A reference to a UErrorCode to receive any errors.  Possible\n    *                        errors are  U_REGEX_INVALID_STATE if no match has been\n    *                        attempted or the last match failed.\n    *    @return the index of the last character matched, plus one.\n    *                        The index value returned is a native index, corresponding to\n    *                        code units for the underlying encoding type, for example,\n    *                        a byte index for UTF-8.\n    *   @stable ICU 4.6\n    */\n    virtual int64_t end64(UErrorCode &status) const;\n\n\n   /**\n    *    Returns the index in the input string of the character following the\n    *    text matched by the specified capture group during the previous match operation.\n    *\n    *    @param group  the capture group number\n    *    @param   status      A reference to a UErrorCode to receive any errors.  Possible\n    *                        errors are  U_REGEX_INVALID_STATE if no match has been\n    *                        attempted or the last match failed and\n    *                        U_INDEX_OUTOFBOUNDS_ERROR for a bad capture group number\n    *    @return  the index of the first character following the text\n    *              captured by the specified group during the previous match operation.\n    *              Return -1 if the capture group exists in the pattern but was not part of the match.\n    *              The index value returned is a native index, corresponding to\n    *              code units for the underlying encoding type, for example,\n    *              a byte index for UTF8.\n    *    @stable ICU 2.4\n    */\n    virtual int32_t end(int32_t group, UErrorCode &status) const;\n\n   /**\n    *    Returns the index in the input string of the character following the\n    *    text matched by the specified capture group during the previous match operation.\n    *\n    *    @param group  the capture group number\n    *    @param   status      A reference to a UErrorCode to receive any errors.  Possible\n    *                        errors are  U_REGEX_INVALID_STATE if no match has been\n    *                        attempted or the last match failed and\n    *                        U_INDEX_OUTOFBOUNDS_ERROR for a bad capture group number\n    *    @return  the index of the first character following the text\n    *              captured by the specified group during the previous match operation.\n    *              Return -1 if the capture group exists in the pattern but was not part of the match.\n    *              The index value returned is a native index, corresponding to\n    *              code units for the underlying encoding type, for example,\n    *              a byte index for UTF8.\n    *   @stable ICU 4.6\n    */\n    virtual int64_t end64(int32_t group, UErrorCode &status) const;\n\n\n   /**\n    *   Resets this matcher.  The effect is to remove any memory of previous matches,\n    *       and to cause subsequent find() operations to begin at the beginning of\n    *       the input string.\n    *\n    *   @return this RegexMatcher.\n    *   @stable ICU 2.4\n    */\n    virtual RegexMatcher &reset();\n\n\n   /**\n    *   Resets this matcher, and set the current input position.\n    *   The effect is to remove any memory of previous matches,\n    *       and to cause subsequent find() operations to begin at\n    *       the specified (native) position in the input string.\n    * <p>\n    *   The matcher's region is reset to its default, which is the entire\n    *   input string.\n    * <p>\n    *   An alternative to this function is to set a match region\n    *   beginning at the desired index.\n    *\n    *   @return this RegexMatcher.\n    *   @stable ICU 2.8\n    */\n    virtual RegexMatcher &reset(int64_t index, UErrorCode &status);\n\n\n   /**\n    *   Resets this matcher with a new input string.  This allows instances of RegexMatcher\n    *     to be reused, which is more efficient than creating a new RegexMatcher for\n    *     each input string to be processed.\n    *   @param input The new string on which subsequent pattern matches will operate.\n    *                The matcher retains a reference to the callers string, and operates\n    *                directly on that.  Ownership of the string remains with the caller.\n    *                Because no copy of the string is made, it is essential that the\n    *                caller not delete the string until after regexp operations on it\n    *                are done.\n    *                Note that while a reset on the matcher with an input string that is then\n    *                modified across/during matcher operations may be supported currently for UnicodeString,\n    *                this was not originally intended behavior, and support for this is not guaranteed\n    *                in upcoming versions of ICU.\n    *   @return this RegexMatcher.\n    *   @stable ICU 2.4\n    */\n    virtual RegexMatcher &reset(const UnicodeString &input);\n\n\n   /**\n    *   Resets this matcher with a new input string.  This allows instances of RegexMatcher\n    *     to be reused, which is more efficient than creating a new RegexMatcher for\n    *     each input string to be processed.\n    *   @param input The new string on which subsequent pattern matches will operate.\n    *                The matcher makes a shallow clone of the given text; ownership of the\n    *                original string remains with the caller. Because no deep copy of the\n    *                text is made, it is essential that the caller not modify the string\n    *                until after regexp operations on it are done.\n    *   @return this RegexMatcher.\n    *\n    *   @stable ICU 4.6\n    */\n    virtual RegexMatcher &reset(UText *input);\n\n\n  /**\n    *  Set the subject text string upon which the regular expression is looking for matches\n    *  without changing any other aspect of the matching state.\n    *  The new and previous text strings must have the same content.\n    *\n    *  This function is intended for use in environments where ICU is operating on \n    *  strings that may move around in memory.  It provides a mechanism for notifying\n    *  ICU that the string has been relocated, and providing a new UText to access the\n    *  string in its new position.\n    *\n    *  Note that the regular expression implementation never copies the underlying text\n    *  of a string being matched, but always operates directly on the original text \n    *  provided by the user. Refreshing simply drops the references to the old text \n    *  and replaces them with references to the new.\n    *\n    *  Caution:  this function is normally used only by very specialized,\n    *  system-level code.  One example use case is with garbage collection that moves\n    *  the text in memory.\n    *\n    * @param input      The new (moved) text string.\n    * @param status     Receives errors detected by this function.\n    *\n    * @stable ICU 4.8 \n    */\n    virtual RegexMatcher &refreshInputText(UText *input, UErrorCode &status);\n\nprivate:\n    /**\n     * Cause a compilation error if an application accidentally attempts to\n     *   reset a matcher with a (UChar *) string as input rather than\n     *   a UnicodeString.    Avoids a dangling reference to a temporary string.\n     * <p>\n     * To efficiently work with UChar *strings, wrap the data in a UnicodeString\n     * using one of the aliasing constructors, such as\n     * <code>UnicodeString(UBool isTerminated, const UChar *text, int32_t textLength);</code>\n     * or in a UText, using\n     * <code>utext_openUChars(UText *ut, const UChar *text, int64_t textLength, UErrorCode *status);</code>\n     *\n     * @internal\n     */\n    RegexMatcher &reset(const UChar *input);\npublic:\n\n   /**\n    *   Returns the input string being matched.  Ownership of the string belongs to\n    *   the matcher; it should not be altered or deleted. This method will work even if the input\n    *   was originally supplied as a UText.\n    *   @return the input string\n    *   @stable ICU 2.4\n    */\n    virtual const UnicodeString &input() const;\n    \n   /**\n    *   Returns the input string being matched.  This is the live input text; it should not be\n    *   altered or deleted. This method will work even if the input was originally supplied as\n    *   a UnicodeString.\n    *   @return the input text\n    *\n    *   @stable ICU 4.6\n    */\n    virtual UText *inputText() const;\n    \n   /**\n    *   Returns the input string being matched, either by copying it into the provided\n    *   UText parameter or by returning a shallow clone of the live input. Note that copying\n    *   the entire input may cause significant performance and memory issues.\n    *   @param dest The UText into which the input should be copied, or NULL to create a new UText\n    *   @param status error code\n    *   @return dest if non-NULL, a shallow copy of the input text otherwise\n    *\n    *   @stable ICU 4.6\n    */\n    virtual UText *getInput(UText *dest, UErrorCode &status) const;\n    \n\n   /** Sets the limits of this matcher's region.\n     * The region is the part of the input string that will be searched to find a match.\n     * Invoking this method resets the matcher, and then sets the region to start\n     * at the index specified by the start parameter and end at the index specified\n     * by the end parameter.\n     *\n     * Depending on the transparency and anchoring being used (see useTransparentBounds\n     * and useAnchoringBounds), certain constructs such as anchors may behave differently\n     * at or around the boundaries of the region\n     *\n     * The function will fail if start is greater than limit, or if either index\n     *  is less than zero or greater than the length of the string being matched.\n     *\n     * @param start  The (native) index to begin searches at.\n     * @param limit  The index to end searches at (exclusive).\n     * @param status A reference to a UErrorCode to receive any errors.\n     * @stable ICU 4.0\n     */\n     virtual RegexMatcher &region(int64_t start, int64_t limit, UErrorCode &status);\n\n   /** \n     * Identical to region(start, limit, status) but also allows a start position without\n     *  resetting the region state.\n     * @param regionStart The region start\n     * @param regionLimit the limit of the region\n     * @param startIndex  The (native) index within the region bounds at which to begin searches.\n     * @param status A reference to a UErrorCode to receive any errors.\n     *                If startIndex is not within the specified region bounds, \n     *                U_INDEX_OUTOFBOUNDS_ERROR is returned.\n     * @stable ICU 4.6\n     */\n     virtual RegexMatcher &region(int64_t regionStart, int64_t regionLimit, int64_t startIndex, UErrorCode &status);\n\n   /**\n     * Reports the start index of this matcher's region. The searches this matcher\n     * conducts are limited to finding matches within regionStart (inclusive) and\n     * regionEnd (exclusive).\n     *\n     * @return The starting (native) index of this matcher's region.\n     * @stable ICU 4.0\n     */\n     virtual int32_t regionStart() const;\n\n   /**\n     * Reports the start index of this matcher's region. The searches this matcher\n     * conducts are limited to finding matches within regionStart (inclusive) and\n     * regionEnd (exclusive).\n     *\n     * @return The starting (native) index of this matcher's region.\n     * @stable ICU 4.6\n     */\n     virtual int64_t regionStart64() const;\n\n\n    /**\n      * Reports the end (limit) index (exclusive) of this matcher's region. The searches\n      * this matcher conducts are limited to finding matches within regionStart\n      * (inclusive) and regionEnd (exclusive).\n      *\n      * @return The ending point (native) of this matcher's region.\n      * @stable ICU 4.0\n      */\n      virtual int32_t regionEnd() const;\n\n   /**\n     * Reports the end (limit) index (exclusive) of this matcher's region. The searches\n     * this matcher conducts are limited to finding matches within regionStart\n     * (inclusive) and regionEnd (exclusive).\n     *\n     * @return The ending point (native) of this matcher's region.\n     * @stable ICU 4.6\n     */\n      virtual int64_t regionEnd64() const;\n\n    /**\n      * Queries the transparency of region bounds for this matcher.\n      * See useTransparentBounds for a description of transparent and opaque bounds.\n      * By default, a matcher uses opaque region boundaries.\n      *\n      * @return TRUE if this matcher is using opaque bounds, false if it is not.\n      * @stable ICU 4.0\n      */\n      virtual UBool hasTransparentBounds() const;\n\n    /**\n      * Sets the transparency of region bounds for this matcher.\n      * Invoking this function with an argument of true will set this matcher to use transparent bounds.\n      * If the boolean argument is false, then opaque bounds will be used.\n      *\n      * Using transparent bounds, the boundaries of this matcher's region are transparent\n      * to lookahead, lookbehind, and boundary matching constructs. Those constructs can\n      * see text beyond the boundaries of the region while checking for a match.\n      *\n      * With opaque bounds, no text outside of the matcher's region is visible to lookahead,\n      * lookbehind, and boundary matching constructs.\n      *\n      * By default, a matcher uses opaque bounds.\n      *\n      * @param   b TRUE for transparent bounds; FALSE for opaque bounds\n      * @return  This Matcher;\n      * @stable ICU 4.0\n      **/\n      virtual RegexMatcher &useTransparentBounds(UBool b);\n\n     \n    /**\n      * Return true if this matcher is using anchoring bounds.\n      * By default, matchers use anchoring region bounds.\n      *\n      * @return TRUE if this matcher is using anchoring bounds.\n      * @stable ICU 4.0\n      */    \n      virtual UBool hasAnchoringBounds() const;\n\n\n    /**\n      * Set whether this matcher is using Anchoring Bounds for its region.\n      * With anchoring bounds, pattern anchors such as ^ and $ will match at the start\n      * and end of the region.  Without Anchoring Bounds, anchors will only match at\n      * the positions they would in the complete text.\n      *\n      * Anchoring Bounds are the default for regions.\n      *\n      * @param b TRUE if to enable anchoring bounds; FALSE to disable them.\n      * @return  This Matcher\n      * @stable ICU 4.0\n      */\n      virtual RegexMatcher &useAnchoringBounds(UBool b);\n\n\n    /**\n      * Return TRUE if the most recent matching operation attempted to access\n      *  additional input beyond the available input text.\n      *  In this case, additional input text could change the results of the match.\n      *\n      *  hitEnd() is defined for both successful and unsuccessful matches.\n      *  In either case hitEnd() will return TRUE if if the end of the text was\n      *  reached at any point during the matching process.\n      *\n      *  @return  TRUE if the most recent match hit the end of input\n      *  @stable ICU 4.0\n      */\n      virtual UBool hitEnd() const;\n\n    /**\n      * Return TRUE the most recent match succeeded and additional input could cause\n      * it to fail. If this method returns false and a match was found, then more input\n      * might change the match but the match won't be lost. If a match was not found,\n      * then requireEnd has no meaning.\n      *\n      * @return TRUE if more input could cause the most recent match to no longer match.\n      * @stable ICU 4.0\n      */\n      virtual UBool requireEnd() const;\n\n\n   /**\n    *    Returns the pattern that is interpreted by this matcher.\n    *    @return  the RegexPattern for this RegexMatcher\n    *    @stable ICU 2.4\n    */\n    virtual const RegexPattern &pattern() const;\n\n\n   /**\n    *    Replaces every substring of the input that matches the pattern\n    *    with the given replacement string.  This is a convenience function that\n    *    provides a complete find-and-replace-all operation.\n    *\n    *    This method first resets this matcher. It then scans the input string\n    *    looking for matches of the pattern. Input that is not part of any\n    *    match is left unchanged; each match is replaced in the result by the\n    *    replacement string. The replacement string may contain references to\n    *    capture groups.\n    *\n    *    @param   replacement a string containing the replacement text.\n    *    @param   status      a reference to a UErrorCode to receive any errors.\n    *    @return              a string containing the results of the find and replace.\n    *    @stable ICU 2.4\n    */\n    virtual UnicodeString replaceAll(const UnicodeString &replacement, UErrorCode &status);\n\n\n   /**\n    *    Replaces every substring of the input that matches the pattern\n    *    with the given replacement string.  This is a convenience function that\n    *    provides a complete find-and-replace-all operation.\n    *\n    *    This method first resets this matcher. It then scans the input string\n    *    looking for matches of the pattern. Input that is not part of any\n    *    match is left unchanged; each match is replaced in the result by the\n    *    replacement string. The replacement string may contain references to\n    *    capture groups.\n    *\n    *    @param   replacement a string containing the replacement text.\n    *    @param   dest        a mutable UText in which the results are placed.\n    *                          If NULL, a new UText will be created (which may not be mutable).\n    *    @param   status      a reference to a UErrorCode to receive any errors.\n    *    @return              a string containing the results of the find and replace.\n    *                          If a pre-allocated UText was provided, it will always be used and returned.\n    *\n    *    @stable ICU 4.6\n    */\n    virtual UText *replaceAll(UText *replacement, UText *dest, UErrorCode &status);\n    \n\n   /**\n    * Replaces the first substring of the input that matches\n    * the pattern with the replacement string.   This is a convenience\n    * function that provides a complete find-and-replace operation.\n    *\n    * <p>This function first resets this RegexMatcher. It then scans the input string\n    * looking for a match of the pattern. Input that is not part\n    * of the match is appended directly to the result string; the match is replaced\n    * in the result by the replacement string. The replacement string may contain\n    * references to captured groups.</p>\n    *\n    * <p>The state of the matcher (the position at which a subsequent find()\n    *    would begin) after completing a replaceFirst() is not specified.  The\n    *    RegexMatcher should be reset before doing additional find() operations.</p>\n    *\n    *    @param   replacement a string containing the replacement text.\n    *    @param   status      a reference to a UErrorCode to receive any errors.\n    *    @return              a string containing the results of the find and replace.\n    *    @stable ICU 2.4\n    */\n    virtual UnicodeString replaceFirst(const UnicodeString &replacement, UErrorCode &status);\n    \n\n   /**\n    * Replaces the first substring of the input that matches\n    * the pattern with the replacement string.   This is a convenience\n    * function that provides a complete find-and-replace operation.\n    *\n    * <p>This function first resets this RegexMatcher. It then scans the input string\n    * looking for a match of the pattern. Input that is not part\n    * of the match is appended directly to the result string; the match is replaced\n    * in the result by the replacement string. The replacement string may contain\n    * references to captured groups.</p>\n    *\n    * <p>The state of the matcher (the position at which a subsequent find()\n    *    would begin) after completing a replaceFirst() is not specified.  The\n    *    RegexMatcher should be reset before doing additional find() operations.</p>\n    *\n    *    @param   replacement a string containing the replacement text.\n    *    @param   dest        a mutable UText in which the results are placed.\n    *                          If NULL, a new UText will be created (which may not be mutable).\n    *    @param   status      a reference to a UErrorCode to receive any errors.\n    *    @return              a string containing the results of the find and replace.\n    *                          If a pre-allocated UText was provided, it will always be used and returned.\n    *\n    *    @stable ICU 4.6\n    */\n    virtual UText *replaceFirst(UText *replacement, UText *dest, UErrorCode &status);\n    \n    \n   /**\n    *   Implements a replace operation intended to be used as part of an\n    *   incremental find-and-replace.\n    *\n    *   <p>The input string, starting from the end of the previous replacement and ending at\n    *   the start of the current match, is appended to the destination string.  Then the\n    *   replacement string is appended to the output string,\n    *   including handling any substitutions of captured text.</p>\n    *\n    *   <p>For simple, prepackaged, non-incremental find-and-replace\n    *   operations, see replaceFirst() or replaceAll().</p>\n    *\n    *   @param   dest        A UnicodeString to which the results of the find-and-replace are appended.\n    *   @param   replacement A UnicodeString that provides the text to be substituted for\n    *                        the input text that matched the regexp pattern.  The replacement\n    *                        text may contain references to captured text from the\n    *                        input.\n    *   @param   status      A reference to a UErrorCode to receive any errors.  Possible\n    *                        errors are  U_REGEX_INVALID_STATE if no match has been\n    *                        attempted or the last match failed, and U_INDEX_OUTOFBOUNDS_ERROR\n    *                        if the replacement text specifies a capture group that\n    *                        does not exist in the pattern.\n    *\n    *   @return  this  RegexMatcher\n    *   @stable ICU 2.4\n    *\n    */\n    virtual RegexMatcher &appendReplacement(UnicodeString &dest,\n        const UnicodeString &replacement, UErrorCode &status);\n    \n    \n   /**\n    *   Implements a replace operation intended to be used as part of an\n    *   incremental find-and-replace.\n    *\n    *   <p>The input string, starting from the end of the previous replacement and ending at\n    *   the start of the current match, is appended to the destination string.  Then the\n    *   replacement string is appended to the output string,\n    *   including handling any substitutions of captured text.</p>\n    *\n    *   <p>For simple, prepackaged, non-incremental find-and-replace\n    *   operations, see replaceFirst() or replaceAll().</p>\n    *\n    *   @param   dest        A mutable UText to which the results of the find-and-replace are appended.\n    *                         Must not be NULL.\n    *   @param   replacement A UText that provides the text to be substituted for\n    *                        the input text that matched the regexp pattern.  The replacement\n    *                        text may contain references to captured text from the input.\n    *   @param   status      A reference to a UErrorCode to receive any errors.  Possible\n    *                        errors are  U_REGEX_INVALID_STATE if no match has been\n    *                        attempted or the last match failed, and U_INDEX_OUTOFBOUNDS_ERROR\n    *                        if the replacement text specifies a capture group that\n    *                        does not exist in the pattern.\n    *\n    *   @return  this  RegexMatcher\n    *\n    *   @stable ICU 4.6\n    */\n    virtual RegexMatcher &appendReplacement(UText *dest,\n        UText *replacement, UErrorCode &status);\n\n\n   /**\n    * As the final step in a find-and-replace operation, append the remainder\n    * of the input string, starting at the position following the last appendReplacement(),\n    * to the destination string. <code>appendTail()</code> is intended to be invoked after one\n    * or more invocations of the <code>RegexMatcher::appendReplacement()</code>.\n    *\n    *  @param dest A UnicodeString to which the results of the find-and-replace are appended.\n    *  @return  the destination string.\n    *  @stable ICU 2.4\n    */\n    virtual UnicodeString &appendTail(UnicodeString &dest);\n\n\n   /**\n    * As the final step in a find-and-replace operation, append the remainder\n    * of the input string, starting at the position following the last appendReplacement(),\n    * to the destination string. <code>appendTail()</code> is intended to be invoked after one\n    * or more invocations of the <code>RegexMatcher::appendReplacement()</code>.\n    *\n    *  @param dest A mutable UText to which the results of the find-and-replace are appended.\n    *               Must not be NULL.\n    *  @param status error cod\n    *  @return  the destination string.\n    *\n    *  @stable ICU 4.6\n    */\n    virtual UText *appendTail(UText *dest, UErrorCode &status);\n\n\n    /**\n     * Split a string into fields.  Somewhat like split() from Perl.\n     * The pattern matches identify delimiters that separate the input\n     *  into fields.  The input data between the matches becomes the\n     *  fields themselves.\n     *\n     * @param input   The string to be split into fields.  The field delimiters\n     *                match the pattern (in the \"this\" object).  This matcher\n     *                will be reset to this input string.\n     * @param dest    An array of UnicodeStrings to receive the results of the split.\n     *                This is an array of actual UnicodeString objects, not an\n     *                array of pointers to strings.  Local (stack based) arrays can\n     *                work well here.\n     * @param destCapacity  The number of elements in the destination array.\n     *                If the number of fields found is less than destCapacity, the\n     *                extra strings in the destination array are not altered.\n     *                If the number of destination strings is less than the number\n     *                of fields, the trailing part of the input string, including any\n     *                field delimiters, is placed in the last destination string.\n     * @param status  A reference to a UErrorCode to receive any errors.\n     * @return        The number of fields into which the input string was split.\n     * @stable ICU 2.6\n     */\n    virtual int32_t  split(const UnicodeString &input,\n        UnicodeString    dest[],\n        int32_t          destCapacity,\n        UErrorCode       &status);\n\n\n    /**\n     * Split a string into fields.  Somewhat like split() from Perl.\n     * The pattern matches identify delimiters that separate the input\n     *  into fields.  The input data between the matches becomes the\n     *  fields themselves.\n     *\n     * @param input   The string to be split into fields.  The field delimiters\n     *                match the pattern (in the \"this\" object).  This matcher\n     *                will be reset to this input string.\n     * @param dest    An array of mutable UText structs to receive the results of the split.\n     *                If a field is NULL, a new UText is allocated to contain the results for\n     *                that field. This new UText is not guaranteed to be mutable.\n     * @param destCapacity  The number of elements in the destination array.\n     *                If the number of fields found is less than destCapacity, the\n     *                extra strings in the destination array are not altered.\n     *                If the number of destination strings is less than the number\n     *                of fields, the trailing part of the input string, including any\n     *                field delimiters, is placed in the last destination string.\n     * @param status  A reference to a UErrorCode to receive any errors.\n     * @return        The number of fields into which the input string was split.\n     *\n     * @stable ICU 4.6\n     */\n    virtual int32_t  split(UText *input,\n        UText           *dest[],\n        int32_t          destCapacity,\n        UErrorCode       &status);\n    \n  /**\n    *   Set a processing time limit for match operations with this Matcher.\n    *  \n    *   Some patterns, when matching certain strings, can run in exponential time.\n    *   For practical purposes, the match operation may appear to be in an\n    *   infinite loop.\n    *   When a limit is set a match operation will fail with an error if the\n    *   limit is exceeded.\n    *   <p>\n    *   The units of the limit are steps of the match engine.\n    *   Correspondence with actual processor time will depend on the speed\n    *   of the processor and the details of the specific pattern, but will\n    *   typically be on the order of milliseconds.\n    *   <p>\n    *   By default, the matching time is not limited.\n    *   <p>\n    *\n    *   @param   limit       The limit value, or 0 for no limit.\n    *   @param   status      A reference to a UErrorCode to receive any errors.\n    *   @stable ICU 4.0\n    */\n    virtual void setTimeLimit(int32_t limit, UErrorCode &status);\n\n  /**\n    * Get the time limit, if any, for match operations made with this Matcher.\n    *\n    *   @return the maximum allowed time for a match, in units of processing steps.\n    *   @stable ICU 4.0\n    */\n    virtual int32_t getTimeLimit() const;\n\n  /**\n    *  Set the amount of heap storage available for use by the match backtracking stack.\n    *  The matcher is also reset, discarding any results from previous matches.\n    *  <p>\n    *  ICU uses a backtracking regular expression engine, with the backtrack stack\n    *  maintained on the heap.  This function sets the limit to the amount of memory\n    *  that can be used  for this purpose.  A backtracking stack overflow will\n    *  result in an error from the match operation that caused it.\n    *  <p>\n    *  A limit is desirable because a malicious or poorly designed pattern can use\n    *  excessive memory, potentially crashing the process.  A limit is enabled\n    *  by default.\n    *  <p>\n    *  @param limit  The maximum size, in bytes, of the matching backtrack stack.\n    *                A value of zero means no limit.\n    *                The limit must be greater or equal to zero.\n    *\n    *  @param status   A reference to a UErrorCode to receive any errors.\n    *\n    *  @stable ICU 4.0\n    */\n    virtual void setStackLimit(int32_t  limit, UErrorCode &status);\n    \n  /**\n    *  Get the size of the heap storage available for use by the back tracking stack.\n    *\n    *  @return  the maximum backtracking stack size, in bytes, or zero if the\n    *           stack size is unlimited.\n    *  @stable ICU 4.0\n    */\n    virtual int32_t  getStackLimit() const;\n\n\n  /**\n    * Set a callback function for use with this Matcher.\n    * During matching operations the function will be called periodically,\n    * giving the application the opportunity to terminate a long-running\n    * match.\n    *\n    *    @param   callback    A pointer to the user-supplied callback function.\n    *    @param   context     User context pointer.  The value supplied at the\n    *                         time the callback function is set will be saved\n    *                         and passed to the callback each time that it is called.\n    *    @param   status      A reference to a UErrorCode to receive any errors.\n    *  @stable ICU 4.0\n    */\n    virtual void setMatchCallback(URegexMatchCallback     *callback,\n                                  const void              *context,\n                                  UErrorCode              &status);\n\n\n  /**\n    *  Get the callback function for this URegularExpression.\n    *\n    *    @param   callback    Out parameter, receives a pointer to the user-supplied \n    *                         callback function.\n    *    @param   context     Out parameter, receives the user context pointer that\n    *                         was set when uregex_setMatchCallback() was called.\n    *    @param   status      A reference to a UErrorCode to receive any errors.\n    *    @stable ICU 4.0\n    */\n    virtual void getMatchCallback(URegexMatchCallback     *&callback,\n                                  const void              *&context,\n                                  UErrorCode              &status);\n\n\n  /**\n    * Set a progress callback function for use with find operations on this Matcher.\n    * During find operations, the callback will be invoked after each return from a\n    * match attempt, giving the application the opportunity to terminate a long-running\n    * find operation.\n    *\n    *    @param   callback    A pointer to the user-supplied callback function.\n    *    @param   context     User context pointer.  The value supplied at the\n    *                         time the callback function is set will be saved\n    *                         and passed to the callback each time that it is called.\n    *    @param   status      A reference to a UErrorCode to receive any errors.\n    *    @stable ICU 4.6\n    */\n    virtual void setFindProgressCallback(URegexFindProgressCallback      *callback,\n                                              const void                              *context,\n                                              UErrorCode                              &status);\n\n\n  /**\n    *  Get the find progress callback function for this URegularExpression.\n    *\n    *    @param   callback    Out parameter, receives a pointer to the user-supplied \n    *                         callback function.\n    *    @param   context     Out parameter, receives the user context pointer that\n    *                         was set when uregex_setFindProgressCallback() was called.\n    *    @param   status      A reference to a UErrorCode to receive any errors.\n    *    @stable ICU 4.6\n    */\n    virtual void getFindProgressCallback(URegexFindProgressCallback      *&callback,\n                                              const void                      *&context,\n                                              UErrorCode                      &status);\n\n#ifndef U_HIDE_INTERNAL_API\n   /**\n     *   setTrace   Debug function, enable/disable tracing of the matching engine.\n     *              For internal ICU development use only.  DO NO USE!!!!\n     *   @internal\n     */\n    void setTrace(UBool state);\n#endif  /* U_HIDE_INTERNAL_API */\n\n    /**\n    * ICU \"poor man's RTTI\", returns a UClassID for this class.\n    *\n    * @stable ICU 2.2\n    */\n    static UClassID U_EXPORT2 getStaticClassID();\n\n    /**\n     * ICU \"poor man's RTTI\", returns a UClassID for the actual class.\n     *\n     * @stable ICU 2.2\n     */\n    virtual UClassID getDynamicClassID() const;\n\nprivate:\n    // Constructors and other object boilerplate are private.\n    // Instances of RegexMatcher can not be assigned, copied, cloned, etc.\n    RegexMatcher();                  // default constructor not implemented\n    RegexMatcher(const RegexPattern *pat);\n    RegexMatcher(const RegexMatcher &other);\n    RegexMatcher &operator =(const RegexMatcher &rhs);\n    void init(UErrorCode &status);                      // Common initialization\n    void init2(UText *t, UErrorCode &e);  // Common initialization, part 2.\n\n    friend class RegexPattern;\n    friend class RegexCImpl;\npublic:\n#ifndef U_HIDE_INTERNAL_API\n    /** @internal  */\n    void resetPreserveRegion();  // Reset matcher state, but preserve any region.\n#endif  /* U_HIDE_INTERNAL_API */\nprivate:\n\n    //\n    //  MatchAt   This is the internal interface to the match engine itself.\n    //            Match status comes back in matcher member variables.\n    //\n    void                 MatchAt(int64_t startIdx, UBool toEnd, UErrorCode &status);\n    inline void          backTrack(int64_t &inputIdx, int32_t &patIdx);\n    UBool                isWordBoundary(int64_t pos);         // perform Perl-like  \\b test\n    UBool                isUWordBoundary(int64_t pos);        // perform RBBI based \\b test\n    REStackFrame        *resetStack();\n    inline REStackFrame *StateSave(REStackFrame *fp, int64_t savePatIdx, UErrorCode &status);\n    void                 IncrementTime(UErrorCode &status);\n    UBool                ReportFindProgress(int64_t matchIndex, UErrorCode &status);\n    \n    int64_t              appendGroup(int32_t groupNum, UText *dest, UErrorCode &status) const;\n    \n    UBool                findUsingChunk();\n    void                 MatchChunkAt(int32_t startIdx, UBool toEnd, UErrorCode &status);\n    UBool                isChunkWordBoundary(int32_t pos);\n\n    const RegexPattern  *fPattern;\n    RegexPattern        *fPatternOwned;    // Non-NULL if this matcher owns the pattern, and\n                                           //   should delete it when through.\n\n    const UnicodeString *fInput;           // The string being matched. Only used for input()\n    UText               *fInputText;       // The text being matched. Is never NULL.\n    UText               *fAltInputText;    // A shallow copy of the text being matched.\n                                           //   Only created if the pattern contains backreferences.\n    int64_t              fInputLength;     // Full length of the input text.\n    int32_t              fFrameSize;       // The size of a frame in the backtrack stack.\n    \n    int64_t              fRegionStart;     // Start of the input region, default = 0.\n    int64_t              fRegionLimit;     // End of input region, default to input.length.\n    \n    int64_t              fAnchorStart;     // Region bounds for anchoring operations (^ or $).\n    int64_t              fAnchorLimit;     //   See useAnchoringBounds\n    \n    int64_t              fLookStart;       // Region bounds for look-ahead/behind and\n    int64_t              fLookLimit;       //   and other boundary tests.  See\n                                           //   useTransparentBounds\n\n    int64_t              fActiveStart;     // Currently active bounds for matching.\n    int64_t              fActiveLimit;     //   Usually is the same as region, but\n                                           //   is changed to fLookStart/Limit when\n                                           //   entering look around regions.\n\n    UBool                fTransparentBounds;  // True if using transparent bounds.\n    UBool                fAnchoringBounds; // True if using anchoring bounds.\n\n    UBool                fMatch;           // True if the last attempted match was successful.\n    int64_t              fMatchStart;      // Position of the start of the most recent match\n    int64_t              fMatchEnd;        // First position after the end of the most recent match\n                                           //   Zero if no previous match, even when a region\n                                           //   is active.\n    int64_t              fLastMatchEnd;    // First position after the end of the previous match,\n                                           //   or -1 if there was no previous match.\n    int64_t              fAppendPosition;  // First position after the end of the previous\n                                           //   appendReplacement().  As described by the\n                                           //   JavaDoc for Java Matcher, where it is called \n                                           //   \"append position\"\n    UBool                fHitEnd;          // True if the last match touched the end of input.\n    UBool                fRequireEnd;      // True if the last match required end-of-input\n                                           //    (matched $ or Z)\n\n    UVector64           *fStack;\n    REStackFrame        *fFrame;           // After finding a match, the last active stack frame,\n                                           //   which will contain the capture group results.\n                                           //   NOT valid while match engine is running.\n\n    int64_t             *fData;            // Data area for use by the compiled pattern.\n    int64_t             fSmallData[8];     //   Use this for data if it's enough.\n\n    int32_t             fTimeLimit;        // Max time (in arbitrary steps) to let the\n                                           //   match engine run.  Zero for unlimited.\n    \n    int32_t             fTime;             // Match time, accumulates while matching.\n    int32_t             fTickCounter;      // Low bits counter for time.  Counts down StateSaves.\n                                           //   Kept separately from fTime to keep as much\n                                           //   code as possible out of the inline\n                                           //   StateSave function.\n\n    int32_t             fStackLimit;       // Maximum memory size to use for the backtrack\n                                           //   stack, in bytes.  Zero for unlimited.\n\n    URegexMatchCallback *fCallbackFn;       // Pointer to match progress callback funct.\n                                           //   NULL if there is no callback.\n    const void         *fCallbackContext;  // User Context ptr for callback function.\n\n    URegexFindProgressCallback  *fFindProgressCallbackFn;  // Pointer to match progress callback funct.\n                                                           //   NULL if there is no callback.\n    const void         *fFindProgressCallbackContext;      // User Context ptr for callback function.\n\n\n    UBool               fInputUniStrMaybeMutable;  // Set when fInputText wraps a UnicodeString that may be mutable - compatibility.\n\n    UBool               fTraceDebug;       // Set true for debug tracing of match engine.\n\n    UErrorCode          fDeferredStatus;   // Save error state that cannot be immediately\n                                           //   reported, or that permanently disables this matcher.\n\n    RuleBasedBreakIterator  *fWordBreakItr;\n};\n\nU_NAMESPACE_END\n#endif  // UCONFIG_NO_REGULAR_EXPRESSIONS\n#endif\n"
  },
  {
    "path": "deprecated/android/addons/icucompat/unicode/rep.h",
    "content": "/*\n**************************************************************************\n* Copyright (C) 1999-2005, International Business Machines Corporation and\n* others. All Rights Reserved.\n**************************************************************************\n*   Date        Name        Description\n*   11/17/99    aliu        Creation.  Ported from java.  Modified to\n*                           match current UnicodeString API.  Forced\n*                           to use name \"handleReplaceBetween\" because\n*                           of existing methods in UnicodeString.\n**************************************************************************\n*/\n\n#ifndef REP_H\n#define REP_H\n\n#include \"unicode/uobject.h\"\n\n/**\n * \\file \n * \\brief C++ API: Replaceable String\n */\n \nU_NAMESPACE_BEGIN\n\nclass UnicodeString;\n\n/**\n * <code>Replaceable</code> is an abstract base class representing a\n * string of characters that supports the replacement of a range of\n * itself with a new string of characters.  It is used by APIs that\n * change a piece of text while retaining metadata.  Metadata is data\n * other than the Unicode characters returned by char32At().  One\n * example of metadata is style attributes; another is an edit\n * history, marking each character with an author and revision number.\n *\n * <p>An implicit aspect of the <code>Replaceable</code> API is that\n * during a replace operation, new characters take on the metadata of\n * the old characters.  For example, if the string \"the <b>bold</b>\n * font\" has range (4, 8) replaced with \"strong\", then it becomes \"the\n * <b>strong</b> font\".\n *\n * <p><code>Replaceable</code> specifies ranges using a start\n * offset and a limit offset.  The range of characters thus specified\n * includes the characters at offset start..limit-1.  That is, the\n * start offset is inclusive, and the limit offset is exclusive.\n *\n * <p><code>Replaceable</code> also includes API to access characters\n * in the string: <code>length()</code>, <code>charAt()</code>,\n * <code>char32At()</code>, and <code>extractBetween()</code>.\n *\n * <p>For a subclass to support metadata, typical behavior of\n * <code>replace()</code> is the following:\n * <ul>\n *   <li>Set the metadata of the new text to the metadata of the first\n *   character replaced</li>\n *   <li>If no characters are replaced, use the metadata of the\n *   previous character</li>\n *   <li>If there is no previous character (i.e. start == 0), use the\n *   following character</li>\n *   <li>If there is no following character (i.e. the replaceable was\n *   empty), use default metadata.<br>\n *   <li>If the code point U+FFFF is seen, it should be interpreted as\n *   a special marker having no metadata<li>\n *   </li>\n * </ul>\n * If this is not the behavior, the subclass should document any differences.\n * @author Alan Liu\n * @stable ICU 2.0\n */\nclass U_COMMON_API Replaceable : public UObject {\n\npublic:\n    /**\n     * Destructor.\n     * @stable ICU 2.0\n     */\n    virtual ~Replaceable();\n\n    /**\n     * Returns the number of 16-bit code units in the text.\n     * @return number of 16-bit code units in text\n     * @stable ICU 1.8\n     */ \n    inline int32_t length() const;\n\n    /**\n     * Returns the 16-bit code unit at the given offset into the text.\n     * @param offset an integer between 0 and <code>length()</code>-1\n     * inclusive\n     * @return 16-bit code unit of text at given offset\n     * @stable ICU 1.8\n     */\n    inline UChar charAt(int32_t offset) const;\n\n    /**\n     * Returns the 32-bit code point at the given 16-bit offset into\n     * the text.  This assumes the text is stored as 16-bit code units\n     * with surrogate pairs intermixed.  If the offset of a leading or\n     * trailing code unit of a surrogate pair is given, return the\n     * code point of the surrogate pair.\n     *\n     * @param offset an integer between 0 and <code>length()</code>-1\n     * inclusive\n     * @return 32-bit code point of text at given offset\n     * @stable ICU 1.8\n     */\n    inline UChar32 char32At(int32_t offset) const;\n\n    /**\n     * Copies characters in the range [<tt>start</tt>, <tt>limit</tt>) \n     * into the UnicodeString <tt>target</tt>.\n     * @param start offset of first character which will be copied\n     * @param limit offset immediately following the last character to\n     * be copied\n     * @param target UnicodeString into which to copy characters.\n     * @return A reference to <TT>target</TT>\n     * @stable ICU 2.1\n     */\n    virtual void extractBetween(int32_t start,\n                                int32_t limit,\n                                UnicodeString& target) const = 0;\n\n    /**\n     * Replaces a substring of this object with the given text.  If the\n     * characters being replaced have metadata, the new characters\n     * that replace them should be given the same metadata.\n     *\n     * <p>Subclasses must ensure that if the text between start and\n     * limit is equal to the replacement text, that replace has no\n     * effect. That is, any metadata\n     * should be unaffected. In addition, subclasses are encouraged to\n     * check for initial and trailing identical characters, and make a\n     * smaller replacement if possible. This will preserve as much\n     * metadata as possible.\n     * @param start the beginning index, inclusive; <code>0 <= start\n     * <= limit</code>.\n     * @param limit the ending index, exclusive; <code>start <= limit\n     * <= length()</code>.\n     * @param text the text to replace characters <code>start</code>\n     * to <code>limit - 1</code> \n     * @stable ICU 2.0\n     */\n    virtual void handleReplaceBetween(int32_t start,\n                                      int32_t limit,\n                                      const UnicodeString& text) = 0;\n    // Note: All other methods in this class take the names of\n    // existing UnicodeString methods.  This method is the exception.\n    // It is named differently because all replace methods of\n    // UnicodeString return a UnicodeString&.  The 'between' is\n    // required in order to conform to the UnicodeString naming\n    // convention; API taking start/length are named <operation>, and\n    // those taking start/limit are named <operationBetween>.  The\n    // 'handle' is added because 'replaceBetween' and\n    // 'doReplaceBetween' are already taken.\n\n    /**\n     * Copies a substring of this object, retaining metadata.\n     * This method is used to duplicate or reorder substrings.\n     * The destination index must not overlap the source range.\n     * \n     * @param start the beginning index, inclusive; <code>0 <= start <=\n     * limit</code>.\n     * @param limit the ending index, exclusive; <code>start <= limit <=\n     * length()</code>.\n     * @param dest the destination index.  The characters from\n     * <code>start..limit-1</code> will be copied to <code>dest</code>.\n     * Implementations of this method may assume that <code>dest <= start ||\n     * dest >= limit</code>.\n     * @stable ICU 2.0\n     */\n    virtual void copy(int32_t start, int32_t limit, int32_t dest) = 0;\n\n    /**\n     * Returns true if this object contains metadata.  If a\n     * Replaceable object has metadata, calls to the Replaceable API\n     * must be made so as to preserve metadata.  If it does not, calls\n     * to the Replaceable API may be optimized to improve performance.\n     * The default implementation returns true.\n     * @return true if this object contains metadata\n     * @stable ICU 2.2\n     */\n    virtual UBool hasMetaData() const;\n\n    /**\n     * Clone this object, an instance of a subclass of Replaceable.\n     * Clones can be used concurrently in multiple threads.\n     * If a subclass does not implement clone(), or if an error occurs,\n     * then NULL is returned.\n     * The clone functions in all subclasses return a pointer to a Replaceable\n     * because some compilers do not support covariant (same-as-this)\n     * return types; cast to the appropriate subclass if necessary.\n     * The caller must delete the clone.\n     *\n     * @return a clone of this object\n     *\n     * @see getDynamicClassID\n     * @stable ICU 2.6\n     */\n    virtual Replaceable *clone() const;\n\nprotected:\n\n    /**\n     * Default constructor.\n     * @stable ICU 2.4\n     */\n    Replaceable();\n\n    /*\n     * Assignment operator not declared. The compiler will provide one\n     * which does nothing since this class does not contain any data members.\n     * API/code coverage may show the assignment operator as present and\n     * untested - ignore.\n     * Subclasses need this assignment operator if they use compiler-provided\n     * assignment operators of their own. An alternative to not declaring one\n     * here would be to declare and empty-implement a protected or public one.\n    Replaceable &Replaceable::operator=(const Replaceable &);\n     */\n\n    /**\n     * Virtual version of length().\n     * @stable ICU 2.4\n     */ \n    virtual int32_t getLength() const = 0;\n\n    /**\n     * Virtual version of charAt().\n     * @stable ICU 2.4\n     */\n    virtual UChar getCharAt(int32_t offset) const = 0;\n\n    /**\n     * Virtual version of char32At().\n     * @stable ICU 2.4\n     */\n    virtual UChar32 getChar32At(int32_t offset) const = 0;\n};\n\ninline int32_t\nReplaceable::length() const {\n    return getLength();\n}\n\ninline UChar\nReplaceable::charAt(int32_t offset) const {\n    return getCharAt(offset);\n}\n\ninline UChar32\nReplaceable::char32At(int32_t offset) const {\n    return getChar32At(offset);\n}\n\n// There is no rep.cpp, see unistr.cpp for Replaceable function implementations.\n\nU_NAMESPACE_END\n\n#endif\n"
  },
  {
    "path": "deprecated/android/addons/icucompat/unicode/resbund.h",
    "content": "/*\n******************************************************************************\n*\n*   Copyright (C) 1996-2011, International Business Machines Corporation\n*   and others.  All Rights Reserved.\n*\n******************************************************************************\n*\n* File resbund.h\n*\n*   CREATED BY\n*       Richard Gillam\n*\n* Modification History:\n*\n*   Date        Name        Description\n*   2/5/97      aliu        Added scanForLocaleInFile.  Added\n*                           constructor which attempts to read resource bundle\n*                           from a specific file, without searching other files.\n*   2/11/97     aliu        Added UErrorCode return values to constructors.  Fixed\n*                           infinite loops in scanForFile and scanForLocale.\n*                           Modified getRawResourceData to not delete storage\n*                           in localeData and resourceData which it doesn't own.\n*                           Added Mac compatibility #ifdefs for tellp() and\n*                           ios::nocreate.\n*   2/18/97     helena      Updated with 100% documentation coverage.\n*   3/13/97     aliu        Rewrote to load in entire resource bundle and store\n*                           it as a Hashtable of ResourceBundleData objects.\n*                           Added state table to govern parsing of files.\n*                           Modified to load locale index out of new file\n*                           distinct from default.txt.\n*   3/25/97     aliu        Modified to support 2-d arrays, needed for timezone\n*                           data. Added support for custom file suffixes.  Again,\n*                           needed to support timezone data.\n*   4/7/97      aliu        Cleaned up.\n* 03/02/99      stephen     Removed dependency on FILE*.\n* 03/29/99      helena      Merged Bertrand and Stephen's changes.\n* 06/11/99      stephen     Removed parsing of .txt files.\n*                           Reworked to use new binary format.\n*                           Cleaned up.\n* 06/14/99      stephen     Removed methods taking a filename suffix.\n* 11/09/99      weiv        Added getLocale(), fRealLocale, removed fRealLocaleID\n******************************************************************************\n*/\n\n#ifndef RESBUND_H\n#define RESBUND_H\n\n#include \"unicode/utypes.h\"\n#include \"unicode/uobject.h\"\n#include \"unicode/ures.h\"\n#include \"unicode/unistr.h\"\n#include \"unicode/locid.h\"\n\n/**\n * \\file \n * \\brief C++ API: Resource Bundle\n */\n \nU_NAMESPACE_BEGIN\n\n/**\n * A class representing a collection of resource information pertaining to a given\n * locale. A resource bundle provides a way of accessing locale- specfic information in\n * a data file. You create a resource bundle that manages the resources for a given\n * locale and then ask it for individual resources.\n * <P>\n * Resource bundles in ICU4C are currently defined using text files which conform to the following\n * <a href=\"http://source.icu-project.org/repos/icu/icuhtml/trunk/design/bnf_rb.txt\">BNF definition</a>.\n * More on resource bundle concepts and syntax can be found in the\n * <a href=\"http://icu-project.org/userguide/ResourceManagement.html\">Users Guide</a>.\n * <P>\n *\n * The ResourceBundle class is not suitable for subclassing.\n *\n * @stable ICU 2.0\n */\nclass U_COMMON_API ResourceBundle : public UObject {\npublic:\n    /**\n     * Constructor\n     *\n     * @param packageName   The packageName and locale together point to an ICU udata object, \n     *                      as defined by <code> udata_open( packageName, \"res\", locale, err) </code> \n     *                      or equivalent.  Typically, packageName will refer to a (.dat) file, or to\n     *                      a package registered with udata_setAppData(). Using a full file or directory\n     *                      pathname for packageName is deprecated.\n     * @param locale  This is the locale this resource bundle is for. To get resources\n     *                for the French locale, for example, you would create a\n     *                ResourceBundle passing Locale::FRENCH for the \"locale\" parameter,\n     *                and all subsequent calls to that resource bundle will return\n     *                resources that pertain to the French locale. If the caller doesn't\n     *                pass a locale parameter, the default locale for the system (as\n     *                returned by Locale::getDefault()) will be used.\n     * @param err     The Error Code.\n     * The UErrorCode& err parameter is used to return status information to the user. To\n     * check whether the construction succeeded or not, you should check the value of\n     * U_SUCCESS(err). If you wish more detailed information, you can check for\n     * informational error results which still indicate success. U_USING_FALLBACK_WARNING\n     * indicates that a fall back locale was used. For example, 'de_CH' was requested,\n     * but nothing was found there, so 'de' was used. U_USING_DEFAULT_WARNING indicates that\n     * the default locale data was used; neither the requested locale nor any of its\n     * fall back locales could be found.\n     * @stable ICU 2.0\n     */\n    ResourceBundle(const UnicodeString&    packageName,\n                   const Locale&           locale,\n                   UErrorCode&              err);\n\n    /**\n     * Construct a resource bundle for the default bundle in the specified package.\n     *\n     * @param packageName   The packageName and locale together point to an ICU udata object, \n     *                      as defined by <code> udata_open( packageName, \"res\", locale, err) </code> \n     *                      or equivalent.  Typically, packageName will refer to a (.dat) file, or to\n     *                      a package registered with udata_setAppData(). Using a full file or directory\n     *                      pathname for packageName is deprecated.\n     * @param err A UErrorCode value\n     * @stable ICU 2.0\n     */\n    ResourceBundle(const UnicodeString&    packageName,\n                   UErrorCode&              err);\n\n    /**\n     * Construct a resource bundle for the ICU default bundle.\n     *\n     * @param err A UErrorCode value\n     * @stable ICU 2.0\n     */\n    ResourceBundle(UErrorCode &err);\n\n    /**\n     * Standard constructor, onstructs a resource bundle for the locale-specific\n     * bundle in the specified package.\n     *\n     * @param packageName   The packageName and locale together point to an ICU udata object, \n     *                      as defined by <code> udata_open( packageName, \"res\", locale, err) </code> \n     *                      or equivalent.  Typically, packageName will refer to a (.dat) file, or to\n     *                      a package registered with udata_setAppData(). Using a full file or directory\n     *                      pathname for packageName is deprecated.\n     *                      NULL is used to refer to ICU data.\n     * @param locale The locale for which to open a resource bundle.\n     * @param err A UErrorCode value\n     * @stable ICU 2.0\n     */\n    ResourceBundle(const char* packageName,\n                   const Locale& locale,\n                   UErrorCode& err);\n\n    /**\n     * Copy constructor.\n     *\n     * @param original The resource bundle to copy.\n     * @stable ICU 2.0\n     */\n    ResourceBundle(const ResourceBundle &original);\n\n    /**\n     * Constructor from a C UResourceBundle. The resource bundle is\n     * copied and not adopted. ures_close will still need to be used on the\n     * original resource bundle.\n     *\n     * @param res A pointer to the C resource bundle.\n     * @param status A UErrorCode value.\n     * @stable ICU 2.0\n     */\n    ResourceBundle(UResourceBundle *res,\n                   UErrorCode &status);\n\n    /**\n     * Assignment operator.\n     *\n     * @param other The resource bundle to copy.\n     * @stable ICU 2.0\n     */\n    ResourceBundle&\n      operator=(const ResourceBundle& other);\n\n    /** Destructor.\n     * @stable ICU 2.0\n     */\n    virtual ~ResourceBundle();\n\n    /**\n     * Clone this object.\n     * Clones can be used concurrently in multiple threads.\n     * If an error occurs, then NULL is returned.\n     * The caller must delete the clone.\n     *\n     * @return a clone of this object\n     *\n     * @see getDynamicClassID\n     * @stable ICU 2.8\n     */\n    ResourceBundle *clone() const;\n\n    /**\n     * Returns the size of a resource. Size for scalar types is always 1, and for vector/table types is\n     * the number of child resources.\n     * @warning Integer array is treated as a scalar type. There are no\n     *          APIs to access individual members of an integer array. It\n     *          is always returned as a whole.\n     *\n     * @return number of resources in a given resource.\n     * @stable ICU 2.0\n     */\n    int32_t\n      getSize(void) const;\n\n    /**\n     * returns a string from a string resource type\n     *\n     * @param status  fills in the outgoing error code\n     *                could be <TT>U_MISSING_RESOURCE_ERROR</TT> if the key is not found\n     *                could be a warning\n     *                e.g.: <TT>U_USING_FALLBACK_WARNING</TT>,<TT>U_USING_DEFAULT_WARNING </TT>\n     * @return a pointer to a zero-terminated UChar array which lives in a memory mapped/DLL file.\n     * @stable ICU 2.0\n     */\n    UnicodeString\n      getString(UErrorCode& status) const;\n\n    /**\n     * returns a binary data from a resource. Can be used at most primitive resource types (binaries,\n     * strings, ints)\n     *\n     * @param len     fills in the length of resulting byte chunk\n     * @param status  fills in the outgoing error code\n     *                could be <TT>U_MISSING_RESOURCE_ERROR</TT> if the key is not found\n     *                could be a warning\n     *                e.g.: <TT>U_USING_FALLBACK_WARNING</TT>,<TT>U_USING_DEFAULT_WARNING </TT>\n     * @return a pointer to a chunk of unsigned bytes which live in a memory mapped/DLL file.\n     * @stable ICU 2.0\n     */\n    const uint8_t*\n      getBinary(int32_t& len, UErrorCode& status) const;\n\n\n    /**\n     * returns an integer vector from a resource.\n     *\n     * @param len     fills in the length of resulting integer vector\n     * @param status  fills in the outgoing error code\n     *                could be <TT>U_MISSING_RESOURCE_ERROR</TT> if the key is not found\n     *                could be a warning\n     *                e.g.: <TT>U_USING_FALLBACK_WARNING</TT>,<TT>U_USING_DEFAULT_WARNING </TT>\n     * @return a pointer to a vector of integers that lives in a memory mapped/DLL file.\n     * @stable ICU 2.0\n     */\n    const int32_t*\n      getIntVector(int32_t& len, UErrorCode& status) const;\n\n    /**\n     * returns an unsigned integer from a resource.\n     * This integer is originally 28 bits.\n     *\n     * @param status  fills in the outgoing error code\n     *                could be <TT>U_MISSING_RESOURCE_ERROR</TT> if the key is not found\n     *                could be a warning\n     *                e.g.: <TT>U_USING_FALLBACK_WARNING</TT>,<TT>U_USING_DEFAULT_WARNING </TT>\n     * @return an unsigned integer value\n     * @stable ICU 2.0\n     */\n    uint32_t\n      getUInt(UErrorCode& status) const;\n\n    /**\n     * returns a signed integer from a resource.\n     * This integer is originally 28 bit and the sign gets propagated.\n     *\n     * @param status  fills in the outgoing error code\n     *                could be <TT>U_MISSING_RESOURCE_ERROR</TT> if the key is not found\n     *                could be a warning\n     *                e.g.: <TT>U_USING_FALLBACK_WARNING</TT>,<TT>U_USING_DEFAULT_WARNING </TT>\n     * @return a signed integer value\n     * @stable ICU 2.0\n     */\n    int32_t\n      getInt(UErrorCode& status) const;\n\n    /**\n     * Checks whether the resource has another element to iterate over.\n     *\n     * @return TRUE if there are more elements, FALSE if there is no more elements\n     * @stable ICU 2.0\n     */\n    UBool\n      hasNext(void) const;\n\n    /**\n     * Resets the internal context of a resource so that iteration starts from the first element.\n     *\n     * @stable ICU 2.0\n     */\n    void\n      resetIterator(void);\n\n    /**\n     * Returns the key associated with this resource. Not all the resources have a key - only\n     * those that are members of a table.\n     *\n     * @return a key associated to this resource, or NULL if it doesn't have a key\n     * @stable ICU 2.0\n     */\n    const char*\n      getKey(void) const;\n\n    /**\n     * Gets the locale ID of the resource bundle as a string.\n     * Same as getLocale().getName() .\n     *\n     * @return the locale ID of the resource bundle as a string\n     * @stable ICU 2.0\n     */\n    const char*\n      getName(void) const;\n\n\n    /**\n     * Returns the type of a resource. Available types are defined in enum UResType\n     *\n     * @return type of the given resource.\n     * @stable ICU 2.0\n     */\n    UResType\n      getType(void) const;\n\n    /**\n     * Returns the next resource in a given resource or NULL if there are no more resources\n     *\n     * @param status            fills in the outgoing error code\n     * @return                  ResourceBundle object.\n     * @stable ICU 2.0\n     */\n    ResourceBundle\n      getNext(UErrorCode& status);\n\n    /**\n     * Returns the next string in a resource or NULL if there are no more resources\n     * to iterate over.\n     *\n     * @param status            fills in the outgoing error code\n     * @return an UnicodeString object.\n     * @stable ICU 2.0\n     */\n    UnicodeString\n      getNextString(UErrorCode& status);\n\n    /**\n     * Returns the next string in a resource or NULL if there are no more resources\n     * to iterate over.\n     *\n     * @param key               fill in for key associated with this string\n     * @param status            fills in the outgoing error code\n     * @return an UnicodeString object.\n     * @stable ICU 2.0\n     */\n    UnicodeString\n      getNextString(const char ** key,\n                    UErrorCode& status);\n\n    /**\n     * Returns the resource in a resource at the specified index.\n     *\n     * @param index             an index to the wanted resource.\n     * @param status            fills in the outgoing error code\n     * @return                  ResourceBundle object. If there is an error, resource is invalid.\n     * @stable ICU 2.0\n     */\n    ResourceBundle\n      get(int32_t index,\n          UErrorCode& status) const;\n\n    /**\n     * Returns the string in a given resource at the specified index.\n     *\n     * @param index             an index to the wanted string.\n     * @param status            fills in the outgoing error code\n     * @return                  an UnicodeString object. If there is an error, string is bogus\n     * @stable ICU 2.0\n     */\n    UnicodeString\n      getStringEx(int32_t index,\n                  UErrorCode& status) const;\n\n    /**\n     * Returns a resource in a resource that has a given key. This procedure works only with table\n     * resources.\n     *\n     * @param key               a key associated with the wanted resource\n     * @param status            fills in the outgoing error code.\n     * @return                  ResourceBundle object. If there is an error, resource is invalid.\n     * @stable ICU 2.0\n     */\n    ResourceBundle\n      get(const char* key,\n          UErrorCode& status) const;\n\n    /**\n     * Returns a string in a resource that has a given key. This procedure works only with table\n     * resources.\n     *\n     * @param key               a key associated with the wanted string\n     * @param status            fills in the outgoing error code\n     * @return                  an UnicodeString object. If there is an error, string is bogus\n     * @stable ICU 2.0\n     */\n    UnicodeString\n      getStringEx(const char* key,\n                  UErrorCode& status) const;\n\n#ifndef U_HIDE_DEPRECATED_API\n    /**\n     * Return the version number associated with this ResourceBundle as a string. Please\n     * use getVersion, as this method is going to be deprecated.\n     *\n     * @return  A version number string as specified in the resource bundle or its parent.\n     *          The caller does not own this string.\n     * @see getVersion\n     * @deprecated ICU 2.8 Use getVersion instead.\n     */\n    const char*\n      getVersionNumber(void) const;\n#endif  /* U_HIDE_DEPRECATED_API */\n\n    /**\n     * Return the version number associated with this ResourceBundle as a UVersionInfo array.\n     *\n     * @param versionInfo A UVersionInfo array that is filled with the version number\n     *                    as specified in the resource bundle or its parent.\n     * @stable ICU 2.0\n     */\n    void\n      getVersion(UVersionInfo versionInfo) const;\n\n#ifndef U_HIDE_DEPRECATED_API\n    /**\n     * Return the Locale associated with this ResourceBundle.\n     *\n     * @return a Locale object\n     * @deprecated ICU 2.8 Use getLocale(ULocDataLocaleType type, UErrorCode &status) overload instead.\n     */\n    const Locale&\n      getLocale(void) const;\n#endif  /* U_HIDE_DEPRECATED_API */\n\n    /**\n     * Return the Locale associated with this ResourceBundle.\n     * @param type You can choose between requested, valid and actual\n     *             locale. For description see the definition of\n     *             ULocDataLocaleType in uloc.h\n     * @param status just for catching illegal arguments\n     *\n     * @return a Locale object\n     * @stable ICU 2.8\n     */\n    const Locale\n      getLocale(ULocDataLocaleType type, UErrorCode &status) const;\n#ifndef U_HIDE_INTERNAL_API\n    /**\n     * This API implements multilevel fallback\n     * @internal\n     */\n    ResourceBundle\n        getWithFallback(const char* key, UErrorCode& status);\n#endif  /* U_HIDE_INTERNAL_API */\n    /**\n     * ICU \"poor man's RTTI\", returns a UClassID for the actual class.\n     *\n     * @stable ICU 2.2\n     */\n    virtual UClassID getDynamicClassID() const;\n\n    /**\n     * ICU \"poor man's RTTI\", returns a UClassID for this class.\n     *\n     * @stable ICU 2.2\n     */\n    static UClassID U_EXPORT2 getStaticClassID();\n\nprivate:\n    ResourceBundle(); // default constructor not implemented\n\n    UResourceBundle *fResource;\n    void constructForLocale(const UnicodeString& path, const Locale& locale, UErrorCode& error);\n    Locale *fLocale;\n\n};\n\nU_NAMESPACE_END\n#endif\n"
  },
  {
    "path": "deprecated/android/addons/icucompat/unicode/schriter.h",
    "content": "/*\n******************************************************************************\n*\n*   Copyright (C) 1998-2005, International Business Machines\n*   Corporation and others.  All Rights Reserved.\n*\n******************************************************************************\n*\n* File schriter.h\n*\n* Modification History:\n*\n*   Date        Name        Description\n*  05/05/99     stephen     Cleaned up.\n******************************************************************************\n*/\n\n#ifndef SCHRITER_H\n#define SCHRITER_H\n\n#include \"unicode/utypes.h\"\n#include \"unicode/chariter.h\"\n#include \"unicode/uchriter.h\"\n\n/**\n * \\file \n * \\brief C++ API: String Character Iterator\n */\n \nU_NAMESPACE_BEGIN\n/**\n * A concrete subclass of CharacterIterator that iterates over the\n * characters (code units or code points) in a UnicodeString.\n * It's possible not only to create an\n * iterator that iterates over an entire UnicodeString, but also to\n * create one that iterates over only a subrange of a UnicodeString\n * (iterators over different subranges of the same UnicodeString don't\n * compare equal).\n * @see CharacterIterator\n * @see ForwardCharacterIterator\n * @stable ICU 2.0\n */\nclass U_COMMON_API StringCharacterIterator : public UCharCharacterIterator {\npublic:\n  /**\n   * Create an iterator over the UnicodeString referred to by \"textStr\".\n   * The UnicodeString object is copied.\n   * The iteration range is the whole string, and the starting position is 0.\n   * @param textStr The unicode string used to create an iterator\n   * @stable ICU 2.0\n   */\n  StringCharacterIterator(const UnicodeString& textStr);\n\n  /**\n   * Create an iterator over the UnicodeString referred to by \"textStr\".\n   * The iteration range is the whole string, and the starting\n   * position is specified by \"textPos\".  If \"textPos\" is outside the valid\n   * iteration range, the behavior of this object is undefined.\n   * @param textStr The unicode string used to create an iterator\n   * @param textPos The starting position of the iteration\n   * @stable ICU 2.0\n   */\n  StringCharacterIterator(const UnicodeString&    textStr,\n              int32_t              textPos);\n\n  /**\n   * Create an iterator over the UnicodeString referred to by \"textStr\".\n   * The UnicodeString object is copied.\n   * The iteration range begins with the code unit specified by\n   * \"textBegin\" and ends with the code unit BEFORE the code unit specfied\n   * by \"textEnd\".  The starting position is specified by \"textPos\".  If\n   * \"textBegin\" and \"textEnd\" don't form a valid range on \"text\" (i.e.,\n   * textBegin >= textEnd or either is negative or greater than text.size()),\n   * or \"textPos\" is outside the range defined by \"textBegin\" and \"textEnd\",\n   * the behavior of this iterator is undefined.\n   * @param textStr    The unicode string used to create the StringCharacterIterator\n   * @param textBegin  The begin position of the iteration range\n   * @param textEnd    The end position of the iteration range\n   * @param textPos    The starting position of the iteration\n   * @stable ICU 2.0\n   */\n  StringCharacterIterator(const UnicodeString&    textStr,\n              int32_t              textBegin,\n              int32_t              textEnd,\n              int32_t              textPos);\n\n  /**\n   * Copy constructor.  The new iterator iterates over the same range\n   * of the same string as \"that\", and its initial position is the\n   * same as \"that\"'s current position.\n   * The UnicodeString object in \"that\" is copied.\n   * @param that The StringCharacterIterator to be copied\n   * @stable ICU 2.0\n   */\n  StringCharacterIterator(const StringCharacterIterator&  that);\n\n  /**\n   * Destructor.\n   * @stable ICU 2.0\n   */\n  virtual ~StringCharacterIterator();\n\n  /**\n   * Assignment operator.  *this is altered to iterate over the same\n   * range of the same string as \"that\", and refers to the same\n   * character within that string as \"that\" does.\n   * @param that The object to be copied.\n   * @return the newly created object.\n   * @stable ICU 2.0\n   */\n  StringCharacterIterator&\n  operator=(const StringCharacterIterator&    that);\n\n  /**\n   * Returns true if the iterators iterate over the same range of the\n   * same string and are pointing at the same character.\n   * @param that The ForwardCharacterIterator to be compared for equality\n   * @return true if the iterators iterate over the same range of the\n   * same string and are pointing at the same character.\n   * @stable ICU 2.0\n   */\n  virtual UBool          operator==(const ForwardCharacterIterator& that) const;\n\n  /**\n   * Returns a new StringCharacterIterator referring to the same\n   * character in the same range of the same string as this one.  The\n   * caller must delete the new iterator.\n   * @return the newly cloned object.\n   * @stable ICU 2.0\n   */\n  virtual CharacterIterator* clone(void) const;\n\n  /**\n   * Sets the iterator to iterate over the provided string.\n   * @param newText The string to be iterated over\n   * @stable ICU 2.0\n   */\n  void setText(const UnicodeString& newText);\n\n  /**\n   * Copies the UnicodeString under iteration into the UnicodeString\n   * referred to by \"result\".  Even if this iterator iterates across\n   * only a part of this string, the whole string is copied.\n   * @param result Receives a copy of the text under iteration.\n   * @stable ICU 2.0\n   */\n  virtual void            getText(UnicodeString& result);\n\n  /**\n   * Return a class ID for this object (not really public)\n   * @return a class ID for this object.\n   * @stable ICU 2.0\n   */\n  virtual UClassID         getDynamicClassID(void) const;\n\n  /**\n   * Return a class ID for this class (not really public)\n   * @return a class ID for this class\n   * @stable ICU 2.0\n   */\n  static UClassID   U_EXPORT2 getStaticClassID(void);\n\nprotected:\n  /**\n   * Default constructor, iteration over empty string.\n   * @stable ICU 2.0\n   */\n  StringCharacterIterator();\n\n  /**\n   * Sets the iterator to iterate over the provided string.\n   * @param newText The string to be iterated over\n   * @param newTextLength The length of the String\n   * @stable ICU 2.0\n   */\n  void setText(const UChar* newText, int32_t newTextLength);\n\n  /**\n   * Copy of the iterated string object.\n   * @stable ICU 2.0\n   */\n  UnicodeString            text;\n\n};\n\nU_NAMESPACE_END\n#endif\n"
  },
  {
    "path": "deprecated/android/addons/icucompat/unicode/search.h",
    "content": "/*\n**********************************************************************\n*   Copyright (C) 2001-2011 IBM and others. All rights reserved.\n**********************************************************************\n*   Date        Name        Description\n*  03/22/2000   helena      Creation.\n**********************************************************************\n*/\n\n#ifndef SEARCH_H\n#define SEARCH_H\n\n#include \"unicode/utypes.h\"\n\n/**\n * \\file \n * \\brief C++ API: SearchIterator object.\n */\n \n#if !UCONFIG_NO_COLLATION && !UCONFIG_NO_BREAK_ITERATION\n\n#include \"unicode/uobject.h\"\n#include \"unicode/unistr.h\"\n#include \"unicode/chariter.h\"\n#include \"unicode/brkiter.h\"\n#include \"unicode/usearch.h\"\n\n/**\n* @stable ICU 2.0\n*/\nstruct USearch;\n/**\n* @stable ICU 2.0\n*/\ntypedef struct USearch USearch;\n\nU_NAMESPACE_BEGIN\n\n/**\n *\n * <tt>SearchIterator</tt> is an abstract base class that provides \n * methods to search for a pattern within a text string. Instances of\n * <tt>SearchIterator</tt> maintain a current position and scans over the \n * target text, returning the indices the pattern is matched and the length \n * of each match.\n * <p>\n * <tt>SearchIterator</tt> defines a protocol for text searching. \n * Subclasses provide concrete implementations of various search algorithms. \n * For example, <tt>StringSearch</tt> implements language-sensitive pattern \n * matching based on the comparison rules defined in a \n * <tt>RuleBasedCollator</tt> object. \n * <p> \n * Other options for searching includes using a BreakIterator to restrict \n * the points at which matches are detected.\n * <p>\n * <tt>SearchIterator</tt> provides an API that is similar to that of\n * other text iteration classes such as <tt>BreakIterator</tt>. Using \n * this class, it is easy to scan through text looking for all occurances of \n * a given pattern. The following example uses a <tt>StringSearch</tt> \n * object to find all instances of \"fox\" in the target string. Any other \n * subclass of <tt>SearchIterator</tt> can be used in an identical \n * manner.\n * <pre><code>\n * UnicodeString target(\"The quick brown fox jumped over the lazy fox\");\n * UnicodeString pattern(\"fox\");\n *\n * SearchIterator *iter  = new StringSearch(pattern, target);\n * UErrorCode      error = U_ZERO_ERROR;\n * for (int pos = iter->first(error); pos != USEARCH_DONE; \n *                               pos = iter->next(error)) {\n *     printf(\"Found match at %d pos, length is %d\\n\", pos, \n *                                             iter.getMatchLength());\n * }\n * </code></pre>\n *\n * @see StringSearch\n * @see RuleBasedCollator\n */\nclass U_I18N_API SearchIterator : public UObject {\n\npublic:\n\n    // public constructors and destructors -------------------------------\n\n    /** \n    * Copy constructor that creates a SearchIterator instance with the same \n    * behavior, and iterating over the same text. \n    * @param other the SearchIterator instance to be copied.\n    * @stable ICU 2.0\n    */\n    SearchIterator(const SearchIterator &other);\n\n    /**\n     * Destructor. Cleans up the search iterator data struct.\n     * @stable ICU 2.0\n     */\n    virtual ~SearchIterator();\n\n    // public get and set methods ----------------------------------------\n\n    /**\n     * Sets the index to point to the given position, and clears any state \n     * that's affected.\n     * <p>\n     * This method takes the argument index and sets the position in the text \n     * string accordingly without checking if the index is pointing to a \n     * valid starting point to begin searching. \n     * @param position within the text to be set. If position is less\n     *             than or greater than the text range for searching, \n     *          an U_INDEX_OUTOFBOUNDS_ERROR will be returned\n     * @param status for errors if it occurs\n     * @stable ICU 2.0\n     */\n    virtual void setOffset(int32_t position, UErrorCode &status) = 0;\n\n    /**\n     * Return the current index in the text being searched.\n     * If the iteration has gone past the end of the text\n     * (or past the beginning for a backwards search), USEARCH_DONE\n     * is returned.\n     * @return current index in the text being searched.\n     * @stable ICU 2.0\n     */\n    virtual int32_t getOffset(void) const = 0;\n\n    /**\n    * Sets the text searching attributes located in the enum \n    * USearchAttribute with values from the enum USearchAttributeValue.\n    * USEARCH_DEFAULT can be used for all attributes for resetting.\n    * @param attribute text attribute (enum USearchAttribute) to be set\n    * @param value text attribute value\n    * @param status for errors if it occurs\n    * @stable ICU 2.0\n    */\n    void setAttribute(USearchAttribute       attribute,\n                      USearchAttributeValue  value,\n                      UErrorCode            &status);\n\n    /**    \n    * Gets the text searching attributes\n    * @param attribute text attribute (enum USearchAttribute) to be retrieve\n    * @return text attribute value\n    * @stable ICU 2.0\n    */\n    USearchAttributeValue getAttribute(USearchAttribute  attribute) const;\n    \n    /**\n    * Returns the index to the match in the text string that was searched.\n    * This call returns a valid result only after a successful call to \n    * <tt>first</tt>, <tt>next</tt>, <tt>previous</tt>, or <tt>last</tt>.\n    * Just after construction, or after a searching method returns \n    * <tt>USEARCH_DONE</tt>, this method will return <tt>USEARCH_DONE</tt>.\n    * <p>\n    * Use getMatchedLength to get the matched string length.\n    * @return index of a substring within the text string that is being \n    *         searched.\n    * @see #first\n    * @see #next\n    * @see #previous\n    * @see #last\n    * @stable ICU 2.0\n    */\n    int32_t getMatchedStart(void) const;\n\n    /**\n     * Returns the length of text in the string which matches the search \n     * pattern. This call returns a valid result only after a successful call \n     * to <tt>first</tt>, <tt>next</tt>, <tt>previous</tt>, or <tt>last</tt>.\n     * Just after construction, or after a searching method returns \n     * <tt>USEARCH_DONE</tt>, this method will return 0.\n     * @return The length of the match in the target text, or 0 if there\n     *         is no match currently.\n     * @see #first\n     * @see #next\n     * @see #previous\n     * @see #last\n     * @stable ICU 2.0\n     */\n    int32_t getMatchedLength(void) const;\n    \n    /**\n     * Returns the text that was matched by the most recent call to \n     * <tt>first</tt>, <tt>next</tt>, <tt>previous</tt>, or <tt>last</tt>.\n     * If the iterator is not pointing at a valid match (e.g. just after \n     * construction or after <tt>USEARCH_DONE</tt> has been returned, \n     * returns an empty string. \n     * @param result stores the matched string or an empty string if a match\n     *        is not found.\n     * @see #first\n     * @see #next\n     * @see #previous\n     * @see #last\n     * @stable ICU 2.0\n     */\n    void getMatchedText(UnicodeString &result) const;\n    \n    /**\n     * Set the BreakIterator that will be used to restrict the points\n     * at which matches are detected. The user is responsible for deleting \n     * the breakiterator.\n     * @param breakiter A BreakIterator that will be used to restrict the \n     *                points at which matches are detected. If a match is \n     *                found, but the match's start or end index is not a \n     *                boundary as determined by the <tt>BreakIterator</tt>, \n     *                the match will be rejected and another will be searched \n     *                for. If this parameter is <tt>NULL</tt>, no break\n     *                detection is attempted.\n     * @param status for errors if it occurs\n     * @see BreakIterator\n     * @stable ICU 2.0\n     */\n    void setBreakIterator(BreakIterator *breakiter, UErrorCode &status);\n    \n    /**\n     * Returns the BreakIterator that is used to restrict the points at \n     * which matches are detected.  This will be the same object that was \n     * passed to the constructor or to <tt>setBreakIterator</tt>.\n     * Note that <tt>NULL</tt> is a legal value; it means that break\n     * detection should not be attempted.\n     * @return BreakIterator used to restrict matchings.\n     * @see #setBreakIterator\n     * @stable ICU 2.0\n     */\n    const BreakIterator * getBreakIterator(void) const;\n\n    /**\n     * Set the string text to be searched. Text iteration will hence begin at \n     * the start of the text string. This method is useful if you want to \n     * re-use an iterator to search for the same pattern within a different \n     * body of text. The user is responsible for deleting the text.\n     * @param text string to be searched.\n     * @param status for errors. If the text length is 0, \n     *        an U_ILLEGAL_ARGUMENT_ERROR is returned.\n     * @stable ICU 2.0\n     */\n    virtual void setText(const UnicodeString &text, UErrorCode &status);    \n\n    /**\n     * Set the string text to be searched. Text iteration will hence begin at \n     * the start of the text string. This method is useful if you want to \n     * re-use an iterator to search for the same pattern within a different \n     * body of text.\n     * <p>\n     * Note: No parsing of the text within the <tt>CharacterIterator</tt> \n     * will be done during searching for this version. The block of text \n     * in <tt>CharacterIterator</tt> will be used as it is.\n     * The user is responsible for deleting the text.\n     * @param text string iterator to be searched.\n     * @param status for errors if any. If the text length is 0 then an \n     *        U_ILLEGAL_ARGUMENT_ERROR is returned.\n     * @stable ICU 2.0\n     */\n    virtual void setText(CharacterIterator &text, UErrorCode &status);\n    \n    /**\n     * Return the string text to be searched.\n     * @return text string to be searched.\n     * @stable ICU 2.0\n     */\n    const UnicodeString & getText(void) const;\n\n    // operator overloading ----------------------------------------------\n\n    /**\n     * Equality operator. \n     * @param that SearchIterator instance to be compared.\n     * @return TRUE if both BreakIterators are of the same class, have the \n     *         same behavior, terates over the same text and have the same\n     *         attributes. FALSE otherwise.\n     * @stable ICU 2.0\n     */\n    virtual UBool operator==(const SearchIterator &that) const;\n\n    /**\n     * Not-equal operator. \n     * @param that SearchIterator instance to be compared.\n     * @return FALSE if operator== returns TRUE, and vice versa.\n     * @stable ICU 2.0\n     */\n    UBool operator!=(const SearchIterator &that) const;\n\n    // public methods ----------------------------------------------------\n\n    /**\n     * Returns a copy of SearchIterator with the same behavior, and \n     * iterating over the same text, as this one. Note that all data will be\n     * replicated, except for the text string to be searched.\n     * @return cloned object\n     * @stable ICU 2.0\n     */\n    virtual SearchIterator* safeClone(void) const = 0;\n\n    /**\n     * Returns the first index at which the string text matches the search \n     * pattern. The iterator is adjusted so that its current index (as \n     * returned by <tt>getOffset</tt>) is the match position if one \n     * was found.\n     * If a match is not found, <tt>USEARCH_DONE</tt> will be returned and\n     * the iterator will be adjusted to the index USEARCH_DONE\n     * @param  status for errors if it occurs\n     * @return The character index of the first match, or \n     *         <tt>USEARCH_DONE</tt> if there are no matches.\n     * @see #getOffset\n     * @stable ICU 2.0\n     */\n    int32_t first(UErrorCode &status);\n\n    /**\n     * Returns the first index equal or greater than <tt>position</tt> at which the \n     * string text matches the search pattern. The iterator is adjusted so \n     * that its current index (as returned by <tt>getOffset</tt>) is the \n     * match position if one was found.\n     * If a match is not found, <tt>USEARCH_DONE</tt> will be returned and the\n     * iterator will be adjusted to the index <tt>USEARCH_DONE</tt>.\n     * @param  position where search if to start from. If position is less\n     *             than or greater than the text range for searching, \n     *          an U_INDEX_OUTOFBOUNDS_ERROR will be returned\n     * @param  status for errors if it occurs\n     * @return The character index of the first match following \n     *         <tt>position</tt>, or <tt>USEARCH_DONE</tt> if there are no \n     *         matches.\n     * @see #getOffset\n     * @stable ICU 2.0\n     */\n    int32_t following(int32_t position, UErrorCode &status);\n    \n    /**\n     * Returns the last index in the target text at which it matches the \n     * search pattern. The iterator is adjusted so that its current index \n     * (as returned by <tt>getOffset</tt>) is the match position if one was \n     * found.\n     * If a match is not found, <tt>USEARCH_DONE</tt> will be returned and\n     * the iterator will be adjusted to the index USEARCH_DONE.\n     * @param  status for errors if it occurs\n     * @return The index of the first match, or <tt>USEARCH_DONE</tt> if \n     *         there are no matches.\n     * @see #getOffset\n     * @stable ICU 2.0\n     */\n    int32_t last(UErrorCode &status);\n\n    /**\n     * Returns the first index less than <tt>position</tt> at which the string \n     * text matches the search pattern. The iterator is adjusted so that its \n     * current index (as returned by <tt>getOffset</tt>) is the match \n     * position if one was found. If a match is not found, \n     * <tt>USEARCH_DONE</tt> will be returned and the iterator will be \n     * adjusted to the index USEARCH_DONE\n     * <p>\n     * When <tt>USEARCH_OVERLAP</tt> option is off, the last index of the\n     * result match is always less than <tt>position</tt>.\n     * When <tt>USERARCH_OVERLAP</tt> is on, the result match may span across\n     * <tt>position</tt>.\n     *\n     * @param  position where search is to start from. If position is less\n     *             than or greater than the text range for searching, \n     *          an U_INDEX_OUTOFBOUNDS_ERROR will be returned\n     * @param  status for errors if it occurs\n     * @return The character index of the first match preceding \n     *         <tt>position</tt>, or <tt>USEARCH_DONE</tt> if there are \n     *         no matches.\n     * @see #getOffset\n     * @stable ICU 2.0\n     */\n    int32_t preceding(int32_t position, UErrorCode &status);\n\n    /**\n     * Returns the index of the next point at which the text matches the\n     * search pattern, starting from the current position\n     * The iterator is adjusted so that its current index (as returned by \n     * <tt>getOffset</tt>) is the match position if one was found.\n     * If a match is not found, <tt>USEARCH_DONE</tt> will be returned and\n     * the iterator will be adjusted to a position after the end of the text \n     * string.\n     * @param  status for errors if it occurs\n     * @return The index of the next match after the current position,\n     *          or <tt>USEARCH_DONE</tt> if there are no more matches.\n     * @see #getOffset\n     * @stable ICU 2.0\n     */\n     int32_t next(UErrorCode &status);\n\n    /**\n     * Returns the index of the previous point at which the string text \n     * matches the search pattern, starting at the current position.\n     * The iterator is adjusted so that its current index (as returned by \n     * <tt>getOffset</tt>) is the match position if one was found.\n     * If a match is not found, <tt>USEARCH_DONE</tt> will be returned and\n     * the iterator will be adjusted to the index USEARCH_DONE\n     * @param  status for errors if it occurs\n     * @return The index of the previous match before the current position,\n     *          or <tt>USEARCH_DONE</tt> if there are no more matches.\n     * @see #getOffset\n     * @stable ICU 2.0\n     */\n    int32_t previous(UErrorCode &status);\n\n    /** \n    * Resets the iteration.\n    * Search will begin at the start of the text string if a forward \n    * iteration is initiated before a backwards iteration. Otherwise if a \n    * backwards iteration is initiated before a forwards iteration, the \n    * search will begin at the end of the text string.    \n    * @stable ICU 2.0\n    */\n    virtual void reset();\n\nprotected:\n    // protected data members ---------------------------------------------\n\n    /**\n    * C search data struct\n    * @stable ICU 2.0\n    */\n    USearch *m_search_;\n\n    /**\n    * Break iterator.\n    * Currently the C++ breakiterator does not have getRules etc to reproduce\n    * another in C. Hence we keep the original around and do the verification\n    * at the end of the match. The user is responsible for deleting this\n    * break iterator.\n    * @stable ICU 2.0\n    */\n    BreakIterator *m_breakiterator_;\n    \n    /**\n    * Unicode string version of the search text\n    * @stable ICU 2.0\n    */\n    UnicodeString  m_text_;\n\n    // protected constructors and destructors -----------------------------\n\n    /**\n    * Default constructor.\n    * Initializes data to the default values.\n    * @stable ICU 2.0\n    */\n    SearchIterator();\n\n    /**\n     * Constructor for use by subclasses.\n     * @param text The target text to be searched.\n     * @param breakiter A {@link BreakIterator} that is used to restrict the \n     *                points at which matches are detected. If \n     *                <tt>handleNext</tt> or <tt>handlePrev</tt> finds a \n     *                match, but the match's start or end index is not a \n     *                boundary as determined by the <tt>BreakIterator</tt>, \n     *                the match is rejected and <tt>handleNext</tt> or \n     *                <tt>handlePrev</tt> is called again. If this parameter \n     *                is <tt>NULL</tt>, no break detection is attempted.  \n     * @see #handleNext\n     * @see #handlePrev\n     * @stable ICU 2.0\n     */\n    SearchIterator(const UnicodeString &text, \n                         BreakIterator *breakiter = NULL);\n\n    /**\n     * Constructor for use by subclasses.\n     * <p>\n     * Note: No parsing of the text within the <tt>CharacterIterator</tt> \n     * will be done during searching for this version. The block of text \n     * in <tt>CharacterIterator</tt> will be used as it is.\n     * @param text The target text to be searched.\n     * @param breakiter A {@link BreakIterator} that is used to restrict the \n     *                points at which matches are detected. If \n     *                <tt>handleNext</tt> or <tt>handlePrev</tt> finds a \n     *                match, but the match's start or end index is not a \n     *                boundary as determined by the <tt>BreakIterator</tt>, \n     *                the match is rejected and <tt>handleNext</tt> or \n     *                <tt>handlePrev</tt> is called again. If this parameter \n     *                is <tt>NULL</tt>, no break detection is attempted.\n     * @see #handleNext\n     * @see #handlePrev\n     * @stable ICU 2.0\n     */\n    SearchIterator(CharacterIterator &text, BreakIterator *breakiter = NULL);\n\n    // protected methods --------------------------------------------------\n\n    /**\n     * Assignment operator. Sets this iterator to have the same behavior,\n     * and iterate over the same text, as the one passed in.\n     * @param that instance to be copied.\n     * @stable ICU 2.0\n     */\n    SearchIterator & operator=(const SearchIterator &that);\n\n    /**\n     * Abstract method which subclasses override to provide the mechanism\n     * for finding the next match in the target text. This allows different\n     * subclasses to provide different search algorithms.\n     * <p>\n     * If a match is found, the implementation should return the index at\n     * which the match starts and should call \n     * <tt>setMatchLength</tt> with the number of characters \n     * in the target text that make up the match. If no match is found, the \n     * method should return USEARCH_DONE.\n     * <p>\n     * @param position The index in the target text at which the search \n     *                 should start.\n     * @param status for error codes if it occurs.\n     * @return index at which the match starts, else if match is not found \n     *         USEARCH_DONE is returned\n     * @see #setMatchLength\n     * @stable ICU 2.0\n     */\n    virtual int32_t handleNext(int32_t position, UErrorCode &status) \n                                                                         = 0;\n\n    /**\n     * Abstract method which subclasses override to provide the mechanism for\n     * finding the previous match in the target text. This allows different\n     * subclasses to provide different search algorithms.\n     * <p>\n     * If a match is found, the implementation should return the index at\n     * which the match starts and should call \n     * <tt>setMatchLength</tt> with the number of characters \n     * in the target text that make up the match. If no match is found, the \n     * method should return USEARCH_DONE.\n     * <p>\n     * @param position The index in the target text at which the search \n     *                 should start.\n     * @param status for error codes if it occurs.\n     * @return index at which the match starts, else if match is not found \n     *         USEARCH_DONE is returned\n     * @see #setMatchLength\n     * @stable ICU 2.0\n     */\n     virtual int32_t handlePrev(int32_t position, UErrorCode &status) \n                                                                         = 0;\n\n    /**\n     * Sets the length of the currently matched string in the text string to\n     * be searched.\n     * Subclasses' <tt>handleNext</tt> and <tt>handlePrev</tt>\n     * methods should call this when they find a match in the target text.\n     * @param length length of the matched text.\n     * @see #handleNext\n     * @see #handlePrev\n     * @stable ICU 2.0\n     */\n    virtual void setMatchLength(int32_t length);\n\n    /**\n     * Sets the offset of the currently matched string in the text string to\n     * be searched.\n     * Subclasses' <tt>handleNext</tt> and <tt>handlePrev</tt>\n     * methods should call this when they find a match in the target text.\n     * @param position start offset of the matched text.\n     * @see #handleNext\n     * @see #handlePrev\n     * @stable ICU 2.0\n     */\n    virtual void setMatchStart(int32_t position);\n\n    /**\n    * sets match not found \n    * @stable ICU 2.0\n    */\n    void setMatchNotFound();\n};\n\ninline UBool SearchIterator::operator!=(const SearchIterator &that) const\n{\n   return !operator==(that); \n}\nU_NAMESPACE_END\n\n#endif /* #if !UCONFIG_NO_COLLATION */\n\n#endif\n\n"
  },
  {
    "path": "deprecated/android/addons/icucompat/unicode/selfmt.h",
    "content": "/********************************************************************\n * COPYRIGHT:\n * Copyright (c) 1997-2011, International Business Machines Corporation and\n * others. All Rights Reserved.\n * Copyright (C) 2010 , Yahoo! Inc.\n ********************************************************************\n *\n * File SELFMT.H\n *\n * Modification History:\n *\n *   Date        Name        Description\n *   11/11/09    kirtig      Finished first cut of implementation.\n ********************************************************************/\n\n#ifndef SELFMT\n#define SELFMT\n\n#include \"unicode/messagepattern.h\"\n#include \"unicode/numfmt.h\"\n#include \"unicode/utypes.h\"\n\n/**\n * \\file\n * \\brief C++ API: SelectFormat object\n */\n\n#if !UCONFIG_NO_FORMATTING\n\nU_NAMESPACE_BEGIN\n\nclass MessageFormat;\n\n/**\n  * <p><code>SelectFormat</code> supports the creation of  internationalized\n  * messages by selecting phrases based on keywords. The pattern  specifies\n  * how to map keywords to phrases and provides a default phrase. The\n  * object provided to the format method is a string that's matched\n  * against the keywords. If there is a match, the corresponding phrase\n  * is selected; otherwise, the default phrase is used.</p>\n  *\n  * <h4>Using <code>SelectFormat</code> for Gender Agreement</h4>\n  *\n  * <p>Note: Typically, select formatting is done via <code>MessageFormat</code>\n  * with a <code>select</code> argument type,\n  * rather than using a stand-alone <code>SelectFormat</code>.</p>\n  *\n  * <p>The main use case for the select format is gender based  inflection.\n  * When names or nouns are inserted into sentences, their gender can  affect pronouns,\n  * verb forms, articles, and adjectives. Special care needs to be\n  * taken for the case where the gender cannot be determined.\n  * The impact varies between languages:</p>\n  * \\htmlonly\n  * <ul>\n  * <li>English has three genders, and unknown gender is handled as a  special\n  * case. Names use the gender of the named person (if known), nouns  referring\n  * to people use natural gender, and inanimate objects are usually  neutral.\n  * The gender only affects pronouns: \"he\", \"she\", \"it\", \"they\".\n  *\n  * <li>German differs from English in that the gender of nouns is  rather\n  * arbitrary, even for nouns referring to people (\"M&#x00E4;dchen\", girl, is  neutral).\n  * The gender affects pronouns (\"er\", \"sie\", \"es\"), articles (\"der\",  \"die\",\n  * \"das\"), and adjective forms (\"guter Mann\", \"gute Frau\", \"gutes  M&#x00E4;dchen\").\n  *\n  * <li>French has only two genders; as in German the gender of nouns\n  * is rather arbitrary - for sun and moon, the genders\n  * are the opposite of those in German. The gender affects\n  * pronouns (\"il\", \"elle\"), articles (\"le\", \"la\"),\n  * adjective forms (\"bon\", \"bonne\"), and sometimes\n  * verb forms (\"all&#x00E9;\", \"all&#x00E9;e\").\n  *\n  * <li>Polish distinguishes five genders (or noun classes),\n  * human masculine, animate non-human masculine, inanimate masculine,\n  * feminine, and neuter.\n  * </ul>\n  * \\endhtmlonly\n  * <p>Some other languages have noun classes that are not related to  gender,\n  * but similar in grammatical use.\n  * Some African languages have around 20 noun classes.</p>\n  *\n  * <p><b>Note:</b>For the gender of a <i>person</i> in a given sentence,\n  * we usually need to distinguish only between female, male and other/unknown.</p>\n  *\n  * <p>To enable localizers to create sentence patterns that take their\n  * language's gender dependencies into consideration, software has to  provide\n  * information about the gender associated with a noun or name to\n  * <code>MessageFormat</code>.\n  * Two main cases can be distinguished:</p>\n  *\n  * <ul>\n  * <li>For people, natural gender information should be maintained  for each person.\n  * Keywords like \"male\", \"female\", \"mixed\" (for groups of people)\n  * and \"unknown\" could be used.\n  *\n  * <li>For nouns, grammatical gender information should be maintained  for\n  * each noun and per language, e.g., in resource bundles.\n  * The keywords \"masculine\", \"feminine\", and \"neuter\" are commonly  used,\n  * but some languages may require other keywords.\n  * </ul>\n  *\n  * <p>The resulting keyword is provided to <code>MessageFormat</code>  as a\n  * parameter separate from the name or noun it's associated with. For  example,\n  * to generate a message such as \"Jean went to Paris\", three separate  arguments\n  * would be provided: The name of the person as argument 0, the  gender of\n  * the person as argument 1, and the name of the city as argument 2.\n  * The sentence pattern for English, where the gender of the person has\n  * no impact on this simple sentence, would not refer to argument 1  at all:</p>\n  *\n  * <pre>{0} went to {2}.</pre>\n  *\n  * <p><b>Note:</b> The entire sentence should be included (and partially repeated)\n  * inside each phrase. Otherwise translators would have to be trained on how to\n  * move bits of the sentence in and out of the select argument of a message.\n  * (The examples below do not follow this recommendation!)</p>\n  *\n  * <p>The sentence pattern for French, where the gender of the person affects\n  * the form of the participle, uses a select format based on argument 1:</p>\n  *\n  * \\htmlonly<pre>{0} est {1, select, female {all&#x00E9;e} other {all&#x00E9;}} &#x00E0; {2}.</pre>\\endhtmlonly\n  *\n  * <p>Patterns can be nested, so that it's possible to handle  interactions of\n  * number and gender where necessary. For example, if the above  sentence should\n  * allow for the names of several people to be inserted, the  following sentence\n  * pattern can be used (with argument 0 the list of people's names,\n  * argument 1 the number of people, argument 2 their combined gender, and\n  * argument 3 the city name):</p>\n  *\n  * \\htmlonly\n  * <pre>{0} {1, plural,\n  *                 one {est {2, select, female {all&#x00E9;e} other  {all&#x00E9;}}}\n  *                 other {sont {2, select, female {all&#x00E9;es} other {all&#x00E9;s}}}\n  *          }&#x00E0; {3}.</pre>\n  * \\endhtmlonly\n  *\n  * <h4>Patterns and Their Interpretation</h4>\n  *\n  * <p>The <code>SelectFormat</code> pattern string defines the phrase output\n  * for each user-defined keyword.\n  * The pattern is a sequence of (keyword, message) pairs.\n  * A keyword is a \"pattern identifier\": [^[[:Pattern_Syntax:][:Pattern_White_Space:]]]+</p>\n  *\n  * <p>Each message is a MessageFormat pattern string enclosed in {curly braces}.</p>\n  *\n  * <p>You always have to define a phrase for the default keyword\n  * <code>other</code>; this phrase is returned when the keyword\n  * provided to\n  * the <code>format</code> method matches no other keyword.\n  * If a pattern does not provide a phrase for <code>other</code>, the  method\n  * it's provided to returns the error  <code>U_DEFAULT_KEYWORD_MISSING</code>.\n  * <br>\n  * Pattern_White_Space between keywords and messages is ignored.\n  * Pattern_White_Space within a message is preserved and output.</p>\n  *\n  * <p><pre>Example:\n  * \\htmlonly\n  *\n  * UErrorCode status = U_ZERO_ERROR;\n  * MessageFormat *msgFmt = new MessageFormat(UnicodeString(\"{0} est  {1, select, female {all&#x00E9;e} other {all&#x00E9;}} &#x00E0; Paris.\"), Locale(\"fr\"),  status);\n  * if (U_FAILURE(status)) {\n  *       return;\n  * }\n  * FieldPosition ignore(FieldPosition::DONT_CARE);\n  * UnicodeString result;\n  *\n  * char* str1= \"Kirti,female\";\n  * Formattable args1[] = {\"Kirti\",\"female\"};\n  * msgFmt->format(args1, 2, result, ignore, status);\n  * cout << \"Input is \" << str1 << \" and result is: \" << result << endl;\n  * delete msgFmt;\n  *\n  * \\endhtmlonly\n  * </pre>\n  * </p>\n  *\n  * Produces the output:<br>\n  * \\htmlonly\n  * <code>Kirti est all&#x00E9;e &#x00E0; Paris.</code>\n  * \\endhtmlonly\n  *\n  * @stable ICU 4.4\n  */\n\nclass U_I18N_API SelectFormat : public Format {\npublic:\n\n    /**\n     * Creates a new <code>SelectFormat</code> for a given pattern string.\n     * @param  pattern the pattern for this <code>SelectFormat</code>.\n     *                 errors are returned to status if the pattern is invalid.\n     * @param status   output param set to success/failure code on exit, which\n     *                 must not indicate a failure before the function call.\n     * @stable ICU 4.4\n     */\n    SelectFormat(const UnicodeString& pattern, UErrorCode& status);\n\n    /**\n     * copy constructor.\n     * @stable ICU 4.4\n     */\n    SelectFormat(const SelectFormat& other);\n\n    /**\n     * Destructor.\n     * @stable ICU 4.4\n     */\n    virtual ~SelectFormat();\n\n    /**\n     * Sets the pattern used by this select format.\n     * for the keyword rules.\n     * Patterns and their interpretation are specified in the class description.\n     *\n     * @param pattern the pattern for this select format\n     *                errors are returned to status if the pattern is invalid.\n     * @param status  output param set to success/failure code on exit, which\n     *                must not indicate a failure before the function call.\n     * @stable ICU 4.4\n     */\n    void applyPattern(const UnicodeString& pattern, UErrorCode& status);\n\n\n    using Format::format;\n\n    /**\n     * Selects the phrase for  the given keyword\n     *\n     * @param keyword  The keyword that is used to select an alternative.\n     * @param appendTo output parameter to receive result.\n     *                 result is appended to existing contents.\n     * @param pos      On input: an alignment field, if desired.\n     *                 On output: the offsets of the alignment field.\n     * @param status  output param set to success/failure code on exit, which\n     *                 must not indicate a failure before the function call.\n     * @return         Reference to 'appendTo' parameter.\n     * @stable ICU 4.4\n     */\n    UnicodeString& format(const UnicodeString& keyword,\n                            UnicodeString& appendTo,\n                            FieldPosition& pos,\n                            UErrorCode& status) const;\n\n    /**\n     * Assignment operator\n     *\n     * @param other    the SelectFormat object to copy from.\n     * @stable ICU 4.4\n     */\n    SelectFormat& operator=(const SelectFormat& other);\n\n    /**\n     * Return true if another object is semantically equal to this one.\n     *\n     * @param other    the SelectFormat object to be compared with.\n     * @return         true if other is semantically equal to this.\n     * @stable ICU 4.4\n     */\n    virtual UBool operator==(const Format& other) const;\n\n    /**\n     * Return true if another object is semantically unequal to this one.\n     *\n     * @param other    the SelectFormat object to be compared with.\n     * @return         true if other is semantically unequal to this.\n     * @stable ICU 4.4\n     */\n    virtual UBool operator!=(const Format& other) const;\n\n    /**\n     * Clones this Format object polymorphically.  The caller owns the\n     * result and should delete it when done.\n     * @stable ICU 4.4\n     */\n    virtual Format* clone(void) const;\n\n    /**\n     * Format an object to produce a string.\n     * This method handles keyword strings.\n     * If the Formattable object is not a <code>UnicodeString</code>,\n     * then it returns a failing UErrorCode.\n     *\n     * @param obj       A keyword string that is used to select an alternative.\n     * @param appendTo  output parameter to receive result.\n     *                  Result is appended to existing contents.\n     * @param pos       On input: an alignment field, if desired.\n     *                  On output: the offsets of the alignment field.\n     * @param status    output param filled with success/failure status.\n     * @return          Reference to 'appendTo' parameter.\n     * @stable ICU 4.4\n     */\n    UnicodeString& format(const Formattable& obj,\n                         UnicodeString& appendTo,\n                         FieldPosition& pos,\n                         UErrorCode& status) const;\n\n    /**\n     * Returns the pattern from applyPattern() or constructor.\n     *\n     * @param  appendTo  output parameter to receive result.\n     *                  Result is appended to existing contents.\n     * @return the UnicodeString with inserted pattern.\n     * @stable ICU 4.4\n     */\n    UnicodeString& toPattern(UnicodeString& appendTo);\n\n    /**\n     * This method is not yet supported by <code>SelectFormat</code>.\n     * <P>\n     * Before calling, set parse_pos.index to the offset you want to start\n     * parsing at in the source. After calling, parse_pos.index is the end of\n     * the text you parsed. If error occurs, index is unchanged.\n     * <P>\n     * When parsing, leading whitespace is discarded (with a successful parse),\n     * while trailing whitespace is left as is.\n     * <P>\n     * See Format::parseObject() for more.\n     *\n     * @param source     The string to be parsed into an object.\n     * @param result     Formattable to be set to the parse result.\n     *     If parse fails, return contents are undefined.\n     * @param parse_pos The position to start parsing at. Upon return\n     *     this param is set to the position after the\n     *     last character successfully parsed. If the\n     *     source is not parsed successfully, this param\n     *     will remain unchanged.\n     * @stable ICU 4.4\n     */\n    virtual void parseObject(const UnicodeString& source,\n                            Formattable& result,\n                            ParsePosition& parse_pos) const;\n\n    /**\n     * ICU \"poor man's RTTI\", returns a UClassID for this class.\n     * @stable ICU 4.4\n     */\n    static UClassID U_EXPORT2 getStaticClassID(void);\n\n    /**\n     * ICU \"poor man's RTTI\", returns a UClassID for the actual class.\n     * @stable ICU 4.4\n     */\n    virtual UClassID getDynamicClassID() const;\n\nprivate:\n    friend class MessageFormat;\n\n    SelectFormat();   // default constructor not implemented.\n\n    /**\n     * Finds the SelectFormat sub-message for the given keyword, or the \"other\" sub-message.\n     * @param pattern A MessagePattern.\n     * @param partIndex the index of the first SelectFormat argument style part.\n     * @param keyword a keyword to be matched to one of the SelectFormat argument's keywords.\n     * @param ec Error code.\n     * @return the sub-message start part index.\n     */\n    static int32_t findSubMessage(const MessagePattern& pattern, int32_t partIndex,\n                                  const UnicodeString& keyword, UErrorCode& ec);\n\n    MessagePattern msgPattern;\n};\n\nU_NAMESPACE_END\n\n#endif /* #if !UCONFIG_NO_FORMATTING */\n\n#endif // _SELFMT\n//eof\n"
  },
  {
    "path": "deprecated/android/addons/icucompat/unicode/simpletz.h",
    "content": "/*\n ********************************************************************************\n * Copyright (C) 1997-2011, International Business Machines                     *\n * Corporation and others. All Rights Reserved.                                 *\n ********************************************************************************\n *\n * File SIMPLETZ.H\n *\n * Modification History:\n *\n *   Date        Name        Description\n *   04/21/97    aliu        Overhauled header.\n *   08/10/98    stephen     JDK 1.2 sync\n *                           Added setStartRule() / setEndRule() overloads\n *                           Added hasSameRules()\n *   09/02/98    stephen     Added getOffset(monthLen)\n *                           Changed getOffset() to take UErrorCode\n *   07/09/99    stephen     Removed millisPerHour (unused, for HP compiler)\n *   12/02/99    aliu        Added TimeMode and constructor and setStart/EndRule\n *                           methods that take TimeMode. Added to docs.\n ********************************************************************************\n */\n\n#ifndef SIMPLETZ_H\n#define SIMPLETZ_H\n\n#include \"unicode/utypes.h\"\n\n/**\n * \\file \n * \\brief C++ API: SimpleTimeZone is a concrete subclass of TimeZone.\n */\n \n#if !UCONFIG_NO_FORMATTING\n\n#include \"unicode/basictz.h\"\n\nU_NAMESPACE_BEGIN\n\n// forward declaration\nclass InitialTimeZoneRule;\nclass TimeZoneTransition;\nclass AnnualTimeZoneRule;\n\n/**\n * <code>SimpleTimeZone</code> is a concrete subclass of <code>TimeZone</code>\n * that represents a time zone for use with a Gregorian calendar. This\n * class does not handle historical changes.\n * <P>\n * When specifying daylight-savings-time begin and end dates, use a negative value for\n * <code>dayOfWeekInMonth</code> to indicate that <code>SimpleTimeZone</code> should\n * count from the end of the month backwards. For example, if Daylight Savings\n * Time starts or ends at the last Sunday a month, use <code>dayOfWeekInMonth = -1</code>\n * along with <code>dayOfWeek = UCAL_SUNDAY</code> to specify the rule.\n *\n * @see      Calendar\n * @see      GregorianCalendar\n * @see      TimeZone\n * @author   D. Goldsmith, Mark Davis, Chen-Lieh Huang, Alan Liu\n */\nclass U_I18N_API SimpleTimeZone: public BasicTimeZone {\npublic:\n\n    /**\n     * TimeMode is used, together with a millisecond offset after\n     * midnight, to specify a rule transition time.  Most rules\n     * transition at a local wall time, that is, according to the\n     * current time in effect, either standard, or DST.  However, some\n     * rules transition at local standard time, and some at a specific\n     * UTC time.  Although it might seem that all times could be\n     * converted to wall time, thus eliminating the need for this\n     * parameter, this is not the case.\n     * @stable ICU 2.0\n     */\n    enum TimeMode {\n        WALL_TIME = 0,\n        STANDARD_TIME,\n        UTC_TIME\n    };\n\n    /**\n     * Copy constructor\n     * @param source the object to be copied.\n     * @stable ICU 2.0\n     */\n    SimpleTimeZone(const SimpleTimeZone& source);\n\n    /**\n     * Default assignment operator\n     * @param right    the object to be copied.\n     * @stable ICU 2.0\n     */\n    SimpleTimeZone& operator=(const SimpleTimeZone& right);\n\n    /**\n     * Destructor\n     * @stable ICU 2.0\n     */\n    virtual ~SimpleTimeZone();\n\n    /**\n     * Returns true if the two TimeZone objects are equal; that is, they have\n     * the same ID, raw GMT offset, and DST rules.\n     *\n     * @param that  The SimpleTimeZone object to be compared with.\n     * @return      True if the given time zone is equal to this time zone; false\n     *              otherwise.\n     * @stable ICU 2.0\n     */\n    virtual UBool operator==(const TimeZone& that) const;\n\n    /**\n     * Constructs a SimpleTimeZone with the given raw GMT offset and time zone ID,\n     * and which doesn't observe daylight savings time.  Normally you should use\n     * TimeZone::createInstance() to create a TimeZone instead of creating a\n     * SimpleTimeZone directly with this constructor.\n     *\n     * @param rawOffsetGMT  The given base time zone offset to GMT.\n     * @param ID         The timezone ID which is obtained from\n     *                   TimeZone.getAvailableIDs.\n     * @stable ICU 2.0\n     */\n    SimpleTimeZone(int32_t rawOffsetGMT, const UnicodeString& ID);\n\n    /**\n     * Construct a SimpleTimeZone with the given raw GMT offset, time zone ID,\n     * and times to start and end daylight savings time. To create a TimeZone that\n     * doesn't observe daylight savings time, don't use this constructor; use\n     * SimpleTimeZone(rawOffset, ID) instead. Normally, you should use\n     * TimeZone.createInstance() to create a TimeZone instead of creating a\n     * SimpleTimeZone directly with this constructor.\n     * <P>\n     * Various types of daylight-savings time rules can be specfied by using different\n     * values for startDay and startDayOfWeek and endDay and endDayOfWeek.  For a\n     * complete explanation of how these parameters work, see the documentation for\n     * setStartRule().\n     *\n     * @param rawOffsetGMT      The new SimpleTimeZone's raw GMT offset\n     * @param ID                The new SimpleTimeZone's time zone ID.\n     * @param savingsStartMonth The daylight savings starting month. Month is\n     *                          0-based. eg, 0 for January.\n     * @param savingsStartDayOfWeekInMonth   The daylight savings starting\n     *                          day-of-week-in-month. See setStartRule() for a\n     *                          complete explanation.\n     * @param savingsStartDayOfWeek The daylight savings starting day-of-week.\n     *                          See setStartRule() for a complete explanation.\n     * @param savingsStartTime  The daylight savings starting time, expressed as the\n     *                          number of milliseconds after midnight.\n     * @param savingsEndMonth   The daylight savings ending month. Month is\n     *                          0-based. eg, 0 for January.\n     * @param savingsEndDayOfWeekInMonth     The daylight savings ending day-of-week-in-month.\n     *                          See setStartRule() for a complete explanation.\n     * @param savingsEndDayOfWeek The daylight savings ending day-of-week.\n     *                          See setStartRule() for a complete explanation.\n     * @param savingsEndTime    The daylight savings ending time, expressed as the\n     *                          number of milliseconds after midnight.\n     * @param status            An UErrorCode to receive the status.\n     * @stable ICU 2.0\n     */\n    SimpleTimeZone(int32_t rawOffsetGMT, const UnicodeString& ID,\n        int8_t savingsStartMonth, int8_t savingsStartDayOfWeekInMonth,\n        int8_t savingsStartDayOfWeek, int32_t savingsStartTime,\n        int8_t savingsEndMonth, int8_t savingsEndDayOfWeekInMonth,\n        int8_t savingsEndDayOfWeek, int32_t savingsEndTime,\n        UErrorCode& status);\n    /**\n     * Construct a SimpleTimeZone with the given raw GMT offset, time zone ID,\n     * and times to start and end daylight savings time. To create a TimeZone that\n     * doesn't observe daylight savings time, don't use this constructor; use\n     * SimpleTimeZone(rawOffset, ID) instead. Normally, you should use\n     * TimeZone.createInstance() to create a TimeZone instead of creating a\n     * SimpleTimeZone directly with this constructor.\n     * <P>\n     * Various types of daylight-savings time rules can be specfied by using different\n     * values for startDay and startDayOfWeek and endDay and endDayOfWeek.  For a\n     * complete explanation of how these parameters work, see the documentation for\n     * setStartRule().\n     *\n     * @param rawOffsetGMT      The new SimpleTimeZone's raw GMT offset\n     * @param ID                The new SimpleTimeZone's time zone ID.\n     * @param savingsStartMonth The daylight savings starting month. Month is\n     *                          0-based. eg, 0 for January.\n     * @param savingsStartDayOfWeekInMonth   The daylight savings starting\n     *                          day-of-week-in-month. See setStartRule() for a\n     *                          complete explanation.\n     * @param savingsStartDayOfWeek The daylight savings starting day-of-week.\n     *                          See setStartRule() for a complete explanation.\n     * @param savingsStartTime  The daylight savings starting time, expressed as the\n     *                          number of milliseconds after midnight.\n     * @param savingsEndMonth   The daylight savings ending month. Month is\n     *                          0-based. eg, 0 for January.\n     * @param savingsEndDayOfWeekInMonth     The daylight savings ending day-of-week-in-month.\n     *                          See setStartRule() for a complete explanation.\n     * @param savingsEndDayOfWeek The daylight savings ending day-of-week.\n     *                          See setStartRule() for a complete explanation.\n     * @param savingsEndTime    The daylight savings ending time, expressed as the\n     *                          number of milliseconds after midnight.\n     * @param savingsDST        The number of milliseconds added to standard time\n     *                          to get DST time. Default is one hour.\n     * @param status            An UErrorCode to receive the status.\n     * @stable ICU 2.0\n     */\n    SimpleTimeZone(int32_t rawOffsetGMT, const UnicodeString& ID,\n        int8_t savingsStartMonth, int8_t savingsStartDayOfWeekInMonth,\n        int8_t savingsStartDayOfWeek, int32_t savingsStartTime,\n        int8_t savingsEndMonth, int8_t savingsEndDayOfWeekInMonth,\n        int8_t savingsEndDayOfWeek, int32_t savingsEndTime,\n        int32_t savingsDST, UErrorCode& status);\n\n    /**\n     * Construct a SimpleTimeZone with the given raw GMT offset, time zone ID,\n     * and times to start and end daylight savings time. To create a TimeZone that\n     * doesn't observe daylight savings time, don't use this constructor; use\n     * SimpleTimeZone(rawOffset, ID) instead. Normally, you should use\n     * TimeZone.createInstance() to create a TimeZone instead of creating a\n     * SimpleTimeZone directly with this constructor.\n     * <P>\n     * Various types of daylight-savings time rules can be specfied by using different\n     * values for startDay and startDayOfWeek and endDay and endDayOfWeek.  For a\n     * complete explanation of how these parameters work, see the documentation for\n     * setStartRule().\n     *\n     * @param rawOffsetGMT      The new SimpleTimeZone's raw GMT offset\n     * @param ID                The new SimpleTimeZone's time zone ID.\n     * @param savingsStartMonth The daylight savings starting month. Month is\n     *                          0-based. eg, 0 for January.\n     * @param savingsStartDayOfWeekInMonth   The daylight savings starting\n     *                          day-of-week-in-month. See setStartRule() for a\n     *                          complete explanation.\n     * @param savingsStartDayOfWeek The daylight savings starting day-of-week.\n     *                          See setStartRule() for a complete explanation.\n     * @param savingsStartTime  The daylight savings starting time, expressed as the\n     *                          number of milliseconds after midnight.\n     * @param savingsStartTimeMode Whether the start time is local wall time, local\n     *                          standard time, or UTC time. Default is local wall time.\n     * @param savingsEndMonth   The daylight savings ending month. Month is\n     *                          0-based. eg, 0 for January.\n     * @param savingsEndDayOfWeekInMonth     The daylight savings ending day-of-week-in-month.\n     *                          See setStartRule() for a complete explanation.\n     * @param savingsEndDayOfWeek The daylight savings ending day-of-week.\n     *                          See setStartRule() for a complete explanation.\n     * @param savingsEndTime    The daylight savings ending time, expressed as the\n     *                          number of milliseconds after midnight.\n     * @param savingsEndTimeMode Whether the end time is local wall time, local\n     *                          standard time, or UTC time. Default is local wall time.\n     * @param savingsDST        The number of milliseconds added to standard time\n     *                          to get DST time. Default is one hour.\n     * @param status            An UErrorCode to receive the status.\n     * @stable ICU 2.0\n     */\n    SimpleTimeZone(int32_t rawOffsetGMT, const UnicodeString& ID,\n        int8_t savingsStartMonth, int8_t savingsStartDayOfWeekInMonth,\n        int8_t savingsStartDayOfWeek, int32_t savingsStartTime,\n        TimeMode savingsStartTimeMode,\n        int8_t savingsEndMonth, int8_t savingsEndDayOfWeekInMonth,\n        int8_t savingsEndDayOfWeek, int32_t savingsEndTime, TimeMode savingsEndTimeMode,\n        int32_t savingsDST, UErrorCode& status);\n\n    /**\n     * Sets the daylight savings starting year, that is, the year this time zone began\n     * observing its specified daylight savings time rules.  The time zone is considered\n     * not to observe daylight savings time prior to that year; SimpleTimeZone doesn't\n     * support historical daylight-savings-time rules.\n     * @param year the daylight savings starting year.\n     * @stable ICU 2.0\n     */\n    void setStartYear(int32_t year);\n\n    /**\n     * Sets the daylight savings starting rule. For example, in the U.S., Daylight Savings\n     * Time starts at the second Sunday in March, at 2 AM in standard time.\n     * Therefore, you can set the start rule by calling:\n     * setStartRule(UCAL_MARCH, 2, UCAL_SUNDAY, 2*60*60*1000);\n     * The dayOfWeekInMonth and dayOfWeek parameters together specify how to calculate\n     * the exact starting date.  Their exact meaning depend on their respective signs,\n     * allowing various types of rules to be constructed, as follows:\n     * <ul>\n     *   <li>If both dayOfWeekInMonth and dayOfWeek are positive, they specify the\n     *       day of week in the month (e.g., (2, WEDNESDAY) is the second Wednesday\n     *       of the month).</li>\n     *   <li>If dayOfWeek is positive and dayOfWeekInMonth is negative, they specify\n     *       the day of week in the month counting backward from the end of the month.\n     *       (e.g., (-1, MONDAY) is the last Monday in the month)</li>\n     *   <li>If dayOfWeek is zero and dayOfWeekInMonth is positive, dayOfWeekInMonth\n     *       specifies the day of the month, regardless of what day of the week it is.\n     *       (e.g., (10, 0) is the tenth day of the month)</li>\n     *   <li>If dayOfWeek is zero and dayOfWeekInMonth is negative, dayOfWeekInMonth\n     *       specifies the day of the month counting backward from the end of the\n     *       month, regardless of what day of the week it is (e.g., (-2, 0) is the\n     *       next-to-last day of the month).</li>\n     *   <li>If dayOfWeek is negative and dayOfWeekInMonth is positive, they specify the\n     *       first specified day of the week on or after the specfied day of the month.\n     *       (e.g., (15, -SUNDAY) is the first Sunday after the 15th of the month\n     *       [or the 15th itself if the 15th is a Sunday].)</li>\n     *   <li>If dayOfWeek and DayOfWeekInMonth are both negative, they specify the\n     *       last specified day of the week on or before the specified day of the month.\n     *       (e.g., (-20, -TUESDAY) is the last Tuesday before the 20th of the month\n     *       [or the 20th itself if the 20th is a Tuesday].)</li>\n     * </ul>\n     * @param month the daylight savings starting month. Month is 0-based.\n     * eg, 0 for January.\n     * @param dayOfWeekInMonth the daylight savings starting\n     * day-of-week-in-month. Please see the member description for an example.\n     * @param dayOfWeek the daylight savings starting day-of-week. Please see\n     * the member description for an example.\n     * @param time the daylight savings starting time. Please see the member\n     * description for an example.\n     * @param status An UErrorCode\n     * @stable ICU 2.0\n     */\n    void setStartRule(int32_t month, int32_t dayOfWeekInMonth, int32_t dayOfWeek,\n                      int32_t time, UErrorCode& status);\n    /**\n     * Sets the daylight savings starting rule. For example, in the U.S., Daylight Savings\n     * Time starts at the second Sunday in March, at 2 AM in standard time.\n     * Therefore, you can set the start rule by calling:\n     * setStartRule(UCAL_MARCH, 2, UCAL_SUNDAY, 2*60*60*1000);\n     * The dayOfWeekInMonth and dayOfWeek parameters together specify how to calculate\n     * the exact starting date.  Their exact meaning depend on their respective signs,\n     * allowing various types of rules to be constructed, as follows:\n     * <ul>\n     *   <li>If both dayOfWeekInMonth and dayOfWeek are positive, they specify the\n     *       day of week in the month (e.g., (2, WEDNESDAY) is the second Wednesday\n     *       of the month).</li>\n     *   <li>If dayOfWeek is positive and dayOfWeekInMonth is negative, they specify\n     *       the day of week in the month counting backward from the end of the month.\n     *       (e.g., (-1, MONDAY) is the last Monday in the month)</li>\n     *   <li>If dayOfWeek is zero and dayOfWeekInMonth is positive, dayOfWeekInMonth\n     *       specifies the day of the month, regardless of what day of the week it is.\n     *       (e.g., (10, 0) is the tenth day of the month)</li>\n     *   <li>If dayOfWeek is zero and dayOfWeekInMonth is negative, dayOfWeekInMonth\n     *       specifies the day of the month counting backward from the end of the\n     *       month, regardless of what day of the week it is (e.g., (-2, 0) is the\n     *       next-to-last day of the month).</li>\n     *   <li>If dayOfWeek is negative and dayOfWeekInMonth is positive, they specify the\n     *       first specified day of the week on or after the specfied day of the month.\n     *       (e.g., (15, -SUNDAY) is the first Sunday after the 15th of the month\n     *       [or the 15th itself if the 15th is a Sunday].)</li>\n     *   <li>If dayOfWeek and DayOfWeekInMonth are both negative, they specify the\n     *       last specified day of the week on or before the specified day of the month.\n     *       (e.g., (-20, -TUESDAY) is the last Tuesday before the 20th of the month\n     *       [or the 20th itself if the 20th is a Tuesday].)</li>\n     * </ul>\n     * @param month the daylight savings starting month. Month is 0-based.\n     * eg, 0 for January.\n     * @param dayOfWeekInMonth the daylight savings starting\n     * day-of-week-in-month. Please see the member description for an example.\n     * @param dayOfWeek the daylight savings starting day-of-week. Please see\n     * the member description for an example.\n     * @param time the daylight savings starting time. Please see the member\n     * description for an example.\n     * @param mode whether the time is local wall time, local standard time,\n     * or UTC time. Default is local wall time.\n     * @param status An UErrorCode\n     * @stable ICU 2.0\n     */\n    void setStartRule(int32_t month, int32_t dayOfWeekInMonth, int32_t dayOfWeek,\n                      int32_t time, TimeMode mode, UErrorCode& status);\n\n    /**\n     * Sets the DST start rule to a fixed date within a month.\n     *\n     * @param month         The month in which this rule occurs (0-based).\n     * @param dayOfMonth    The date in that month (1-based).\n     * @param time          The time of that day (number of millis after midnight)\n     *                      when DST takes effect in local wall time, which is\n     *                      standard time in this case.\n     * @param status An UErrorCode\n     * @stable ICU 2.0\n     */\n    void setStartRule(int32_t month, int32_t dayOfMonth, int32_t time,\n                      UErrorCode& status);\n    /**\n     * Sets the DST start rule to a fixed date within a month.\n     *\n     * @param month         The month in which this rule occurs (0-based).\n     * @param dayOfMonth    The date in that month (1-based).\n     * @param time          The time of that day (number of millis after midnight)\n     *                      when DST takes effect in local wall time, which is\n     *                      standard time in this case.\n     * @param mode whether the time is local wall time, local standard time,\n     * or UTC time. Default is local wall time.\n     * @param status An UErrorCode\n     * @stable ICU 2.0\n     */\n    void setStartRule(int32_t month, int32_t dayOfMonth, int32_t time,\n                      TimeMode mode, UErrorCode& status);\n\n    /**\n     * Sets the DST start rule to a weekday before or after a give date within\n     * a month, e.g., the first Monday on or after the 8th.\n     *\n     * @param month         The month in which this rule occurs (0-based).\n     * @param dayOfMonth    A date within that month (1-based).\n     * @param dayOfWeek     The day of the week on which this rule occurs.\n     * @param time          The time of that day (number of millis after midnight)\n     *                      when DST takes effect in local wall time, which is\n     *                      standard time in this case.\n     * @param after         If true, this rule selects the first dayOfWeek on\n     *                      or after dayOfMonth.  If false, this rule selects\n     *                      the last dayOfWeek on or before dayOfMonth.\n     * @param status An UErrorCode\n     * @stable ICU 2.0\n     */\n    void setStartRule(int32_t month, int32_t dayOfMonth, int32_t dayOfWeek,\n                      int32_t time, UBool after, UErrorCode& status);\n    /**\n     * Sets the DST start rule to a weekday before or after a give date within\n     * a month, e.g., the first Monday on or after the 8th.\n     *\n     * @param month         The month in which this rule occurs (0-based).\n     * @param dayOfMonth    A date within that month (1-based).\n     * @param dayOfWeek     The day of the week on which this rule occurs.\n     * @param time          The time of that day (number of millis after midnight)\n     *                      when DST takes effect in local wall time, which is\n     *                      standard time in this case.\n     * @param mode whether the time is local wall time, local standard time,\n     * or UTC time. Default is local wall time.\n     * @param after         If true, this rule selects the first dayOfWeek on\n     *                      or after dayOfMonth.  If false, this rule selects\n     *                      the last dayOfWeek on or before dayOfMonth.\n     * @param status An UErrorCode\n     * @stable ICU 2.0\n     */\n    void setStartRule(int32_t month, int32_t dayOfMonth, int32_t dayOfWeek,\n                      int32_t time, TimeMode mode, UBool after, UErrorCode& status);\n\n    /**\n     * Sets the daylight savings ending rule. For example, if Daylight\n     * Savings Time ends at the last (-1) Sunday in October, at 2 AM in standard time.\n     * Therefore, you can set the end rule by calling:\n     * <pre>\n     *    setEndRule(UCAL_OCTOBER, -1, UCAL_SUNDAY, 2*60*60*1000);\n     * </pre>\n     * Various other types of rules can be specified by manipulating the dayOfWeek\n     * and dayOfWeekInMonth parameters.  For complete details, see the documentation\n     * for setStartRule().\n     *\n     * @param month the daylight savings ending month. Month is 0-based.\n     * eg, 0 for January.\n     * @param dayOfWeekInMonth the daylight savings ending\n     * day-of-week-in-month. See setStartRule() for a complete explanation.\n     * @param dayOfWeek the daylight savings ending day-of-week. See setStartRule()\n     * for a complete explanation.\n     * @param time the daylight savings ending time. Please see the member\n     * description for an example.\n     * @param status An UErrorCode\n     * @stable ICU 2.0\n     */\n    void setEndRule(int32_t month, int32_t dayOfWeekInMonth, int32_t dayOfWeek,\n                    int32_t time, UErrorCode& status);\n\n    /**\n     * Sets the daylight savings ending rule. For example, if Daylight\n     * Savings Time ends at the last (-1) Sunday in October, at 2 AM in standard time.\n     * Therefore, you can set the end rule by calling:\n     * <pre>\n     *    setEndRule(UCAL_OCTOBER, -1, UCAL_SUNDAY, 2*60*60*1000);\n     * </pre>\n     * Various other types of rules can be specified by manipulating the dayOfWeek\n     * and dayOfWeekInMonth parameters.  For complete details, see the documentation\n     * for setStartRule().\n     *\n     * @param month the daylight savings ending month. Month is 0-based.\n     * eg, 0 for January.\n     * @param dayOfWeekInMonth the daylight savings ending\n     * day-of-week-in-month. See setStartRule() for a complete explanation.\n     * @param dayOfWeek the daylight savings ending day-of-week. See setStartRule()\n     * for a complete explanation.\n     * @param time the daylight savings ending time. Please see the member\n     * description for an example.\n     * @param mode whether the time is local wall time, local standard time,\n     * or UTC time. Default is local wall time.\n     * @param status An UErrorCode\n     * @stable ICU 2.0\n     */\n    void setEndRule(int32_t month, int32_t dayOfWeekInMonth, int32_t dayOfWeek,\n                    int32_t time, TimeMode mode, UErrorCode& status);\n\n    /**\n     * Sets the DST end rule to a fixed date within a month.\n     *\n     * @param month         The month in which this rule occurs (0-based).\n     * @param dayOfMonth    The date in that month (1-based).\n     * @param time          The time of that day (number of millis after midnight)\n     *                      when DST ends in local wall time, which is daylight\n     *                      time in this case.\n     * @param status An UErrorCode\n     * @stable ICU 2.0\n     */\n    void setEndRule(int32_t month, int32_t dayOfMonth, int32_t time, UErrorCode& status);\n\n    /**\n     * Sets the DST end rule to a fixed date within a month.\n     *\n     * @param month         The month in which this rule occurs (0-based).\n     * @param dayOfMonth    The date in that month (1-based).\n     * @param time          The time of that day (number of millis after midnight)\n     *                      when DST ends in local wall time, which is daylight\n     *                      time in this case.\n     * @param mode whether the time is local wall time, local standard time,\n     * or UTC time. Default is local wall time.\n     * @param status An UErrorCode\n     * @stable ICU 2.0\n     */\n    void setEndRule(int32_t month, int32_t dayOfMonth, int32_t time,\n                    TimeMode mode, UErrorCode& status);\n\n    /**\n     * Sets the DST end rule to a weekday before or after a give date within\n     * a month, e.g., the first Monday on or after the 8th.\n     *\n     * @param month         The month in which this rule occurs (0-based).\n     * @param dayOfMonth    A date within that month (1-based).\n     * @param dayOfWeek     The day of the week on which this rule occurs.\n     * @param time          The time of that day (number of millis after midnight)\n     *                      when DST ends in local wall time, which is daylight\n     *                      time in this case.\n     * @param after         If true, this rule selects the first dayOfWeek on\n     *                      or after dayOfMonth.  If false, this rule selects\n     *                      the last dayOfWeek on or before dayOfMonth.\n     * @param status An UErrorCode\n     * @stable ICU 2.0\n     */\n    void setEndRule(int32_t month, int32_t dayOfMonth, int32_t dayOfWeek,\n                    int32_t time, UBool after, UErrorCode& status);\n\n    /**\n     * Sets the DST end rule to a weekday before or after a give date within\n     * a month, e.g., the first Monday on or after the 8th.\n     *\n     * @param month         The month in which this rule occurs (0-based).\n     * @param dayOfMonth    A date within that month (1-based).\n     * @param dayOfWeek     The day of the week on which this rule occurs.\n     * @param time          The time of that day (number of millis after midnight)\n     *                      when DST ends in local wall time, which is daylight\n     *                      time in this case.\n     * @param mode whether the time is local wall time, local standard time,\n     * or UTC time. Default is local wall time.\n     * @param after         If true, this rule selects the first dayOfWeek on\n     *                      or after dayOfMonth.  If false, this rule selects\n     *                      the last dayOfWeek on or before dayOfMonth.\n     * @param status An UErrorCode\n     * @stable ICU 2.0\n     */\n    void setEndRule(int32_t month, int32_t dayOfMonth, int32_t dayOfWeek,\n                    int32_t time, TimeMode mode, UBool after, UErrorCode& status);\n\n    /**\n     * Returns the TimeZone's adjusted GMT offset (i.e., the number of milliseconds to add\n     * to GMT to get local time in this time zone, taking daylight savings time into\n     * account) as of a particular reference date.  The reference date is used to determine\n     * whether daylight savings time is in effect and needs to be figured into the offset\n     * that is returned (in other words, what is the adjusted GMT offset in this time zone\n     * at this particular date and time?).  For the time zones produced by createTimeZone(),\n     * the reference data is specified according to the Gregorian calendar, and the date\n     * and time fields are in GMT, NOT local time.\n     *\n     * @param era        The reference date's era\n     * @param year       The reference date's year\n     * @param month      The reference date's month (0-based; 0 is January)\n     * @param day        The reference date's day-in-month (1-based)\n     * @param dayOfWeek  The reference date's day-of-week (1-based; 1 is Sunday)\n     * @param millis     The reference date's milliseconds in day, UTT (NOT local time).\n     * @param status     An UErrorCode to receive the status.\n     * @return           The offset in milliseconds to add to GMT to get local time.\n     * @stable ICU 2.0\n     */\n    virtual int32_t getOffset(uint8_t era, int32_t year, int32_t month, int32_t day,\n                              uint8_t dayOfWeek, int32_t millis, UErrorCode& status) const;\n\n    /**\n     * Gets the time zone offset, for current date, modified in case of\n     * daylight savings. This is the offset to add *to* UTC to get local time.\n     * @param era the era of the given date.\n     * @param year the year in the given date.\n     * @param month the month in the given date.\n     * Month is 0-based. e.g., 0 for January.\n     * @param day the day-in-month of the given date.\n     * @param dayOfWeek the day-of-week of the given date.\n     * @param milliseconds the millis in day in <em>standard</em> local time.\n     * @param monthLength the length of the given month in days.\n     * @param status     An UErrorCode to receive the status.\n     * @return the offset to add *to* GMT to get local time.\n     * @stable ICU 2.0\n     */\n    virtual int32_t getOffset(uint8_t era, int32_t year, int32_t month, int32_t day,\n                           uint8_t dayOfWeek, int32_t milliseconds,\n                           int32_t monthLength, UErrorCode& status) const;\n    /**\n     * Gets the time zone offset, for current date, modified in case of\n     * daylight savings. This is the offset to add *to* UTC to get local time.\n     * @param era the era of the given date.\n     * @param year the year in the given date.\n     * @param month the month in the given date.\n     * Month is 0-based. e.g., 0 for January.\n     * @param day the day-in-month of the given date.\n     * @param dayOfWeek the day-of-week of the given date.\n     * @param milliseconds the millis in day in <em>standard</em> local time.\n     * @param monthLength the length of the given month in days.\n     * @param prevMonthLength length of the previous month in days.\n     * @param status     An UErrorCode to receive the status.\n     * @return the offset to add *to* GMT to get local time.\n     * @stable ICU 2.0\n     */\n    virtual int32_t getOffset(uint8_t era, int32_t year, int32_t month, int32_t day,\n                              uint8_t dayOfWeek, int32_t milliseconds,\n                              int32_t monthLength, int32_t prevMonthLength,\n                              UErrorCode& status) const;\n\n    /**\n     * Redeclared TimeZone method.  This implementation simply calls\n     * the base class method, which otherwise would be hidden.\n     * @stable ICU 2.8\n     */\n    virtual void getOffset(UDate date, UBool local, int32_t& rawOffset,\n                           int32_t& dstOffset, UErrorCode& ec) const;\n\n    /**\n     * Get time zone offsets from local wall time.\n     * @internal\n     */\n    virtual void getOffsetFromLocal(UDate date, int32_t nonExistingTimeOpt, int32_t duplicatedTimeOpt,\n        int32_t& rawOffset, int32_t& dstOffset, UErrorCode& status) /*const*/;\n\n    /**\n     * Returns the TimeZone's raw GMT offset (i.e., the number of milliseconds to add\n     * to GMT to get local time, before taking daylight savings time into account).\n     *\n     * @return   The TimeZone's raw GMT offset.\n     * @stable ICU 2.0\n     */\n    virtual int32_t getRawOffset(void) const;\n\n    /**\n     * Sets the TimeZone's raw GMT offset (i.e., the number of milliseconds to add\n     * to GMT to get local time, before taking daylight savings time into account).\n     *\n     * @param offsetMillis  The new raw GMT offset for this time zone.\n     * @stable ICU 2.0\n     */\n    virtual void setRawOffset(int32_t offsetMillis);\n\n    /**\n     * Sets the amount of time in ms that the clock is advanced during DST.\n     * @param millisSavedDuringDST the number of milliseconds the time is\n     * advanced with respect to standard time when the daylight savings rules\n     * are in effect. A positive number, typically one hour (3600000).\n     * @param status  An UErrorCode to receive the status.\n     * @stable ICU 2.0\n     */\n    void setDSTSavings(int32_t millisSavedDuringDST, UErrorCode& status);\n\n    /**\n     * Returns the amount of time in ms that the clock is advanced during DST.\n     * @return the number of milliseconds the time is\n     * advanced with respect to standard time when the daylight savings rules\n     * are in effect. A positive number, typically one hour (3600000).\n     * @stable ICU 2.0\n     */\n    virtual int32_t getDSTSavings(void) const;\n\n    /**\n     * Queries if this TimeZone uses Daylight Savings Time.\n     *\n     * @return   True if this TimeZone uses Daylight Savings Time; false otherwise.\n     * @stable ICU 2.0\n     */\n    virtual UBool useDaylightTime(void) const;\n\n    /**\n     * Returns true if the given date is within the period when daylight savings time\n     * is in effect; false otherwise.  If the TimeZone doesn't observe daylight savings\n     * time, this functions always returns false.\n     * This method is wasteful since it creates a new GregorianCalendar and\n     * deletes it each time it is called. This is a deprecated method\n     * and provided only for Java compatibility.\n     *\n     * @param date The date to test.\n     * @param status  An UErrorCode to receive the status.\n     * @return true if the given date is in Daylight Savings Time;\n     * false otherwise.\n     * @deprecated ICU 2.4. Use Calendar::inDaylightTime() instead.\n     */\n    virtual UBool inDaylightTime(UDate date, UErrorCode& status) const;\n\n    /**\n     * Return true if this zone has the same rules and offset as another zone.\n     * @param other the TimeZone object to be compared with\n     * @return true if the given zone has the same rules and offset as this one\n     * @stable ICU 2.0\n     */\n    UBool hasSameRules(const TimeZone& other) const;\n\n    /**\n     * Clones TimeZone objects polymorphically. Clients are responsible for deleting\n     * the TimeZone object cloned.\n     *\n     * @return   A new copy of this TimeZone object.\n     * @stable ICU 2.0\n     */\n    virtual TimeZone* clone(void) const;\n\n    /**\n     * Gets the first time zone transition after the base time.\n     * @param base      The base time.\n     * @param inclusive Whether the base time is inclusive or not.\n     * @param result    Receives the first transition after the base time.\n     * @return  TRUE if the transition is found.\n     * @stable ICU 3.8\n     */\n    virtual UBool getNextTransition(UDate base, UBool inclusive, TimeZoneTransition& result) /*const*/;\n\n    /**\n     * Gets the most recent time zone transition before the base time.\n     * @param base      The base time.\n     * @param inclusive Whether the base time is inclusive or not.\n     * @param result    Receives the most recent transition before the base time.\n     * @return  TRUE if the transition is found.\n     * @stable ICU 3.8\n     */\n    virtual UBool getPreviousTransition(UDate base, UBool inclusive, TimeZoneTransition& result) /*const*/;\n\n    /**\n     * Returns the number of <code>TimeZoneRule</code>s which represents time transitions,\n     * for this time zone, that is, all <code>TimeZoneRule</code>s for this time zone except\n     * <code>InitialTimeZoneRule</code>.  The return value range is 0 or any positive value.\n     * @param status    Receives error status code.\n     * @return The number of <code>TimeZoneRule</code>s representing time transitions.\n     * @stable ICU 3.8\n     */\n    virtual int32_t countTransitionRules(UErrorCode& status) /*const*/;\n\n    /**\n     * Gets the <code>InitialTimeZoneRule</code> and the set of <code>TimeZoneRule</code>\n     * which represent time transitions for this time zone.  On successful return,\n     * the argument initial points to non-NULL <code>InitialTimeZoneRule</code> and\n     * the array trsrules is filled with 0 or multiple <code>TimeZoneRule</code>\n     * instances up to the size specified by trscount.  The results are referencing the\n     * rule instance held by this time zone instance.  Therefore, after this time zone\n     * is destructed, they are no longer available.\n     * @param initial       Receives the initial timezone rule\n     * @param trsrules      Receives the timezone transition rules\n     * @param trscount      On input, specify the size of the array 'transitions' receiving\n     *                      the timezone transition rules.  On output, actual number of\n     *                      rules filled in the array will be set.\n     * @param status        Receives error status code.\n     * @stable ICU 3.8\n     */\n    virtual void getTimeZoneRules(const InitialTimeZoneRule*& initial,\n        const TimeZoneRule* trsrules[], int32_t& trscount, UErrorCode& status) /*const*/;\n\n\npublic:\n\n    /**\n     * Override TimeZone Returns a unique class ID POLYMORPHICALLY. Pure virtual\n     * override. This method is to implement a simple version of RTTI, since not all C++\n     * compilers support genuine RTTI. Polymorphic operator==() and clone() methods call\n     * this method.\n     *\n     * @return   The class ID for this object. All objects of a given class have the\n     *           same class ID. Objects of other classes have different class IDs.\n     * @stable ICU 2.0\n     */\n    virtual UClassID getDynamicClassID(void) const;\n\n    /**\n     * Return the class ID for this class. This is useful only for comparing to a return\n     * value from getDynamicClassID(). For example:\n     * <pre>\n     * .   Base* polymorphic_pointer = createPolymorphicObject();\n     * .   if (polymorphic_pointer->getDynamicClassID() ==\n     * .       Derived::getStaticClassID()) ...\n     * </pre>\n     * @return   The class ID for all objects of this class.\n     * @stable ICU 2.0\n     */\n    static UClassID U_EXPORT2 getStaticClassID(void);\n\nprivate:\n    /**\n     * Constants specifying values of startMode and endMode.\n     */\n    enum EMode\n    {\n        DOM_MODE = 1,\n        DOW_IN_MONTH_MODE,\n        DOW_GE_DOM_MODE,\n        DOW_LE_DOM_MODE\n    };\n\n    SimpleTimeZone(); // default constructor not implemented\n\n    /**\n     * Internal construction method.\n     * @param rawOffsetGMT    The new SimpleTimeZone's raw GMT offset\n     * @param startMonth      the month DST starts\n     * @param startDay        the day DST starts\n     * @param startDayOfWeek  the DOW DST starts\n     * @param startTime       the time DST starts\n     * @param startTimeMode   Whether the start time is local wall time, local\n     *                        standard time, or UTC time. Default is local wall time.\n     * @param endMonth        the month DST ends\n     * @param endDay          the day DST ends\n     * @param endDayOfWeek    the DOW DST ends\n     * @param endTime         the time DST ends\n     * @param endTimeMode     Whether the end time is local wall time, local\n     *                        standard time, or UTC time. Default is local wall time.\n     * @param dstSavings      The number of milliseconds added to standard time\n     *                        to get DST time. Default is one hour.\n     * @param status          An UErrorCode to receive the status.\n     */\n    void construct(int32_t rawOffsetGMT,\n                   int8_t startMonth, int8_t startDay, int8_t startDayOfWeek,\n                   int32_t startTime, TimeMode startTimeMode,\n                   int8_t endMonth, int8_t endDay, int8_t endDayOfWeek,\n                   int32_t endTime, TimeMode endTimeMode,\n                   int32_t dstSavings, UErrorCode& status);\n\n    /**\n     * Compare a given date in the year to a rule. Return 1, 0, or -1, depending\n     * on whether the date is after, equal to, or before the rule date. The\n     * millis are compared directly against the ruleMillis, so any\n     * standard-daylight adjustments must be handled by the caller.\n     *\n     * @return  1 if the date is after the rule date, -1 if the date is before\n     *          the rule date, or 0 if the date is equal to the rule date.\n     */\n    static int32_t compareToRule(int8_t month, int8_t monthLen, int8_t prevMonthLen,\n                                 int8_t dayOfMonth,\n                                 int8_t dayOfWeek, int32_t millis, int32_t millisDelta,\n                                 EMode ruleMode, int8_t ruleMonth, int8_t ruleDayOfWeek,\n                                 int8_t ruleDay, int32_t ruleMillis);\n\n    /**\n     * Given a set of encoded rules in startDay and startDayOfMonth, decode\n     * them and set the startMode appropriately.  Do the same for endDay and\n     * endDayOfMonth.\n     * <P>\n     * Upon entry, the day of week variables may be zero or\n     * negative, in order to indicate special modes.  The day of month\n     * variables may also be negative.\n     * <P>\n     * Upon exit, the mode variables will be\n     * set, and the day of week and day of month variables will be positive.\n     * <P>\n     * This method also recognizes a startDay or endDay of zero as indicating\n     * no DST.\n     */\n    void decodeRules(UErrorCode& status);\n    void decodeStartRule(UErrorCode& status);\n    void decodeEndRule(UErrorCode& status);\n\n    int8_t startMonth, startDay, startDayOfWeek;   // the month, day, DOW, and time DST starts\n    int32_t startTime;\n    TimeMode startTimeMode, endTimeMode; // Mode for startTime, endTime; see TimeMode\n    int8_t endMonth, endDay, endDayOfWeek; // the month, day, DOW, and time DST ends\n    int32_t endTime;\n    int32_t startYear;  // the year these DST rules took effect\n    int32_t rawOffset;  // the TimeZone's raw GMT offset\n    UBool useDaylight; // flag indicating whether this TimeZone uses DST\n    static const int8_t STATICMONTHLENGTH[12]; // lengths of the months\n    EMode startMode, endMode;   // flags indicating what kind of rules the DST rules are\n\n    /**\n     * A positive value indicating the amount of time saved during DST in ms.\n     * Typically one hour; sometimes 30 minutes.\n     */\n    int32_t dstSavings;\n\n    /* Private for BasicTimeZone implementation */\n    void initTransitionRules(UErrorCode& status);\n    void clearTransitionRules(void);\n    void deleteTransitionRules(void);\n    UBool   transitionRulesInitialized;\n    InitialTimeZoneRule*    initialRule;\n    TimeZoneTransition*     firstTransition;\n    AnnualTimeZoneRule*     stdRule;\n    AnnualTimeZoneRule*     dstRule;\n};\n\ninline void SimpleTimeZone::setStartRule(int32_t month, int32_t dayOfWeekInMonth,\n                                         int32_t dayOfWeek,\n                                         int32_t time, UErrorCode& status) {\n    setStartRule(month, dayOfWeekInMonth, dayOfWeek, time, WALL_TIME, status);\n}\n\ninline void SimpleTimeZone::setStartRule(int32_t month, int32_t dayOfMonth,\n                                         int32_t time,\n                                         UErrorCode& status) {\n    setStartRule(month, dayOfMonth, time, WALL_TIME, status);\n}\n\ninline void SimpleTimeZone::setStartRule(int32_t month, int32_t dayOfMonth,\n                                         int32_t dayOfWeek,\n                                         int32_t time, UBool after, UErrorCode& status) {\n    setStartRule(month, dayOfMonth, dayOfWeek, time, WALL_TIME, after, status);\n}\n\ninline void SimpleTimeZone::setEndRule(int32_t month, int32_t dayOfWeekInMonth,\n                                       int32_t dayOfWeek,\n                                       int32_t time, UErrorCode& status) {\n    setEndRule(month, dayOfWeekInMonth, dayOfWeek, time, WALL_TIME, status);\n}\n\ninline void SimpleTimeZone::setEndRule(int32_t month, int32_t dayOfMonth,\n                                       int32_t time, UErrorCode& status) {\n    setEndRule(month, dayOfMonth, time, WALL_TIME, status);\n}\n\ninline void SimpleTimeZone::setEndRule(int32_t month, int32_t dayOfMonth, int32_t dayOfWeek,\n                                       int32_t time, UBool after, UErrorCode& status) {\n    setEndRule(month, dayOfMonth, dayOfWeek, time, WALL_TIME, after, status);\n}\n\ninline void\nSimpleTimeZone::getOffset(UDate date, UBool local, int32_t& rawOffsetRef,\n                          int32_t& dstOffsetRef, UErrorCode& ec) const {\n    TimeZone::getOffset(date, local, rawOffsetRef, dstOffsetRef, ec);\n}\n\nU_NAMESPACE_END\n\n#endif /* #if !UCONFIG_NO_FORMATTING */\n\n#endif // _SIMPLETZ\n"
  },
  {
    "path": "deprecated/android/addons/icucompat/unicode/smpdtfmt.h",
    "content": "/*\n* Copyright (C) 1997-2012, International Business Machines Corporation and\n* others. All Rights Reserved.\n*******************************************************************************\n*\n* File SMPDTFMT.H\n*\n* Modification History:\n*\n*   Date        Name        Description\n*   02/19/97    aliu        Converted from java.\n*   07/09/97    helena      Make ParsePosition into a class.\n*   07/21/98    stephen     Added GMT_PLUS, GMT_MINUS\n*                            Changed setTwoDigitStartDate to set2DigitYearStart\n*                            Changed getTwoDigitStartDate to get2DigitYearStart\n*                            Removed subParseLong\n*                            Removed getZoneIndex (added in DateFormatSymbols)\n*   06/14/99    stephen     Removed fgTimeZoneDataSuffix\n*   10/14/99    aliu        Updated class doc to describe 2-digit year parsing\n*                           {j28 4182066}.\n*******************************************************************************\n*/\n\n#ifndef SMPDTFMT_H\n#define SMPDTFMT_H\n\n#include \"unicode/utypes.h\"\n\n/**\n * \\file\n * \\brief C++ API: Format and parse dates in a language-independent manner.\n */\n\n#if !UCONFIG_NO_FORMATTING\n\n#include \"unicode/datefmt.h\"\n#include \"unicode/udisplaycontext.h\"\n\nU_NAMESPACE_BEGIN\n\nclass DateFormatSymbols;\nclass DateFormat;\nclass MessageFormat;\nclass FieldPositionHandler;\nclass TimeZoneFormat;\n\n/**\n *\n * SimpleDateFormat is a concrete class for formatting and parsing dates in a\n * language-independent manner. It allows for formatting (millis -> text),\n * parsing (text -> millis), and normalization. Formats/Parses a date or time,\n * which is the standard milliseconds since 24:00 GMT, Jan 1, 1970.\n * <P>\n * Clients are encouraged to create a date-time formatter using DateFormat::getInstance(),\n * getDateInstance(), getDateInstance(), or getDateTimeInstance() rather than\n * explicitly constructing an instance of SimpleDateFormat.  This way, the client\n * is guaranteed to get an appropriate formatting pattern for whatever locale the\n * program is running in.  However, if the client needs something more unusual than\n * the default patterns in the locales, he can construct a SimpleDateFormat directly\n * and give it an appropriate pattern (or use one of the factory methods on DateFormat\n * and modify the pattern after the fact with toPattern() and applyPattern().\n * <P>\n * Date/Time format syntax:\n * <P>\n * The date/time format is specified by means of a string time pattern. In this\n * pattern, all ASCII letters are reserved as pattern letters, which are defined\n * as the following:\n * <pre>\n * \\code\n * Symbol   Meaning                 Presentation        Example\n * ------   -------                 ------------        -------\n * G        era designator          (Text)              AD\n * y        year                    (Number)            1996\n * Y        year (week of year)     (Number)            1997\n * u        extended year           (Number)            4601\n * U        cyclic year name        (Text,NumFallback)  ren-chen (29)\n * Q        Quarter                 (Text & Number)     Q2 & 02\n * M        month in year           (Text & Number)     July & 07\n * d        day in month            (Number)            10\n * h        hour in am/pm (1~12)    (Number)            12\n * H        hour in day (0~23)      (Number)            0\n * m        minute in hour          (Number)            30\n * s        second in minute        (Number)            55\n * S        fractional second       (Number)            978\n *          (maximum resolution of SSS; truncated if shorter, zero-padded if longer)\n * E        day of week             (Text)              Tuesday\n * e        day of week (local 1~7) (Text & Number)     Tues & 2\n * D        day in year             (Number)            189\n * F        day of week in month    (Number)            2 (2nd Wed in July)\n * w        week in year            (Number)            27\n * W        week in month           (Number)            2\n * a        am/pm marker            (Text)              PM\n * k        hour in day (1~24)      (Number)            24\n * K        hour in am/pm (0~11)    (Number)            0\n * z        time zone               (Text)              PST\n * zzzz     time zone               (Text)              Pacific Standard Time\n * Z        time zone (RFC 822)     (Number)            -0800\n * ZZZZ     time zone (RFC 822)     (Text & Number)     GMT-08:00\n * ZZZZZ    time zone (ISO 8601)    (Text & Number)     -08:00 & Z\n * v        time zone (generic)     (Text)              PT\n * vvvv     time zone (generic)     (Text)              Pacific Time\n * V        time zone (abreviation) (Text)              PST\n * VVVV     time zone (location)    (Text)              United States Time (Los Angeles)\n * g        Julian day              (Number)            2451334\n * A        milliseconds in day     (Number)            69540000\n * q        stand alone quarter     (Text & Number)     Q2 & 02\n * L        stand alone month       (Text & Number)     July & 07\n * c        stand alone day of week (Text & Number)     Tuesday & 2\n * '        escape for text         (Delimiter)         'Date='\n * ''       single quote            (Literal)           'o''clock'\n * \\endcode\n * </pre>\n * The count of pattern letters determine the format.\n * <P>\n * (Text): 4 or more, use full form, &lt;4, use short or abbreviated form if it\n * exists. (e.g., \"EEEE\" produces \"Monday\", \"EEE\" produces \"Mon\")\n * <P>\n * (Number): the minimum number of digits. Shorter numbers are zero-padded to\n * this amount (e.g. if \"m\" produces \"6\", \"mm\" produces \"06\"). Year is handled\n * specially; that is, if the count of 'y' is 2, the Year will be truncated to 2 digits.\n * (e.g., if \"yyyy\" produces \"1997\", \"yy\" produces \"97\".)\n * Unlike other fields, fractional seconds are padded on the right with zero.\n * <P>\n * (Text & Number): 3 or over, use text, otherwise use number.  (e.g., \"M\" produces \"1\",\n * \"MM\" produces \"01\", \"MMM\" produces \"Jan\", and \"MMMM\" produces \"January\".)\n * <P>\n * (Text,NumFallback): Behaves like Text if there is supporting data, like\n * Number otherwise.\n * <P>\n * Any characters in the pattern that are not in the ranges of ['a'..'z'] and\n * ['A'..'Z'] will be treated as quoted text. For instance, characters\n * like ':', '.', ' ', '#' and '@' will appear in the resulting time text\n * even they are not embraced within single quotes.\n * <P>\n * A pattern containing any invalid pattern letter will result in a failing\n * UErrorCode result during formatting or parsing.\n * <P>\n * Examples using the US locale:\n * <pre>\n * \\code\n *    Format Pattern                         Result\n *    --------------                         -------\n *    \"yyyy.MM.dd G 'at' HH:mm:ss vvvv\" ->>  1996.07.10 AD at 15:08:56 Pacific Time\n *    \"EEE, MMM d, ''yy\"                ->>  Wed, July 10, '96\n *    \"h:mm a\"                          ->>  12:08 PM\n *    \"hh 'o''clock' a, zzzz\"           ->>  12 o'clock PM, Pacific Daylight Time\n *    \"K:mm a, vvv\"                     ->>  0:00 PM, PT\n *    \"yyyyy.MMMMM.dd GGG hh:mm aaa\"    ->>  1996.July.10 AD 12:08 PM\n * \\endcode\n * </pre>\n * Code Sample:\n * <pre>\n * \\code\n *     UErrorCode success = U_ZERO_ERROR;\n *     SimpleTimeZone* pdt = new SimpleTimeZone(-8 * 60 * 60 * 1000, \"PST\");\n *     pdt->setStartRule( Calendar::APRIL, 1, Calendar::SUNDAY, 2*60*60*1000);\n *     pdt->setEndRule( Calendar::OCTOBER, -1, Calendar::SUNDAY, 2*60*60*1000);\n *\n *     // Format the current time.\n *     SimpleDateFormat* formatter\n *         = new SimpleDateFormat (\"yyyy.MM.dd G 'at' hh:mm:ss a zzz\", success );\n *     GregorianCalendar cal(success);\n *     UDate currentTime_1 = cal.getTime(success);\n *     FieldPosition fp(0);\n *     UnicodeString dateString;\n *     formatter->format( currentTime_1, dateString, fp );\n *     cout << \"result: \" << dateString << endl;\n *\n *     // Parse the previous string back into a Date.\n *     ParsePosition pp(0);\n *     UDate currentTime_2 = formatter->parse(dateString, pp );\n * \\endcode\n * </pre>\n * In the above example, the time value \"currentTime_2\" obtained from parsing\n * will be equal to currentTime_1. However, they may not be equal if the am/pm\n * marker 'a' is left out from the format pattern while the \"hour in am/pm\"\n * pattern symbol is used. This information loss can happen when formatting the\n * time in PM.\n *\n * <p>\n * When parsing a date string using the abbreviated year pattern (\"y\" or \"yy\"),\n * SimpleDateFormat must interpret the abbreviated year\n * relative to some century.  It does this by adjusting dates to be\n * within 80 years before and 20 years after the time the SimpleDateFormat\n * instance is created. For example, using a pattern of \"MM/dd/yy\" and a\n * SimpleDateFormat instance created on Jan 1, 1997,  the string\n * \"01/11/12\" would be interpreted as Jan 11, 2012 while the string \"05/04/64\"\n * would be interpreted as May 4, 1964.\n * During parsing, only strings consisting of exactly two digits, as defined by\n * <code>Unicode::isDigit()</code>, will be parsed into the default century.\n * Any other numeric string, such as a one digit string, a three or more digit\n * string, or a two digit string that isn't all digits (for example, \"-1\"), is\n * interpreted literally.  So \"01/02/3\" or \"01/02/003\" are parsed (for the\n * Gregorian calendar), using the same pattern, as Jan 2, 3 AD.  Likewise (but\n * only in lenient parse mode, the default) \"01/02/-3\" is parsed as Jan 2, 4 BC.\n *\n * <p>\n * If the year pattern has more than two 'y' characters, the year is\n * interpreted literally, regardless of the number of digits.  So using the\n * pattern \"MM/dd/yyyy\", \"01/11/12\" parses to Jan 11, 12 A.D.\n *\n * <p>\n * When numeric fields abut one another directly, with no intervening delimiter\n * characters, they constitute a run of abutting numeric fields.  Such runs are\n * parsed specially.  For example, the format \"HHmmss\" parses the input text\n * \"123456\" to 12:34:56, parses the input text \"12345\" to 1:23:45, and fails to\n * parse \"1234\".  In other words, the leftmost field of the run is flexible,\n * while the others keep a fixed width.  If the parse fails anywhere in the run,\n * then the leftmost field is shortened by one character, and the entire run is\n * parsed again. This is repeated until either the parse succeeds or the\n * leftmost field is one character in length.  If the parse still fails at that\n * point, the parse of the run fails.\n *\n * <P>\n * For time zones that have no names, SimpleDateFormat uses strings GMT+hours:minutes or\n * GMT-hours:minutes.\n * <P>\n * The calendar defines what is the first day of the week, the first week of the\n * year, whether hours are zero based or not (0 vs 12 or 24), and the timezone.\n * There is one common number format to handle all the numbers; the digit count\n * is handled programmatically according to the pattern.\n *\n * <p><em>User subclasses are not supported.</em> While clients may write\n * subclasses, such code will not necessarily work and will not be\n * guaranteed to work stably from release to release.\n */\nclass U_I18N_API SimpleDateFormat: public DateFormat {\npublic:\n    /**\n     * Construct a SimpleDateFormat using the default pattern for the default\n     * locale.\n     * <P>\n     * [Note:] Not all locales support SimpleDateFormat; for full generality,\n     * use the factory methods in the DateFormat class.\n     * @param status    Output param set to success/failure code.\n     * @stable ICU 2.0\n     */\n    SimpleDateFormat(UErrorCode& status);\n\n    /**\n     * Construct a SimpleDateFormat using the given pattern and the default locale.\n     * The locale is used to obtain the symbols used in formatting (e.g., the\n     * names of the months), but not to provide the pattern.\n     * <P>\n     * [Note:] Not all locales support SimpleDateFormat; for full generality,\n     * use the factory methods in the DateFormat class.\n     * @param pattern    the pattern for the format.\n     * @param status     Output param set to success/failure code.\n     * @stable ICU 2.0\n     */\n    SimpleDateFormat(const UnicodeString& pattern,\n                     UErrorCode& status);\n\n    /**\n     * Construct a SimpleDateFormat using the given pattern, numbering system override, and the default locale.\n     * The locale is used to obtain the symbols used in formatting (e.g., the\n     * names of the months), but not to provide the pattern.\n     * <P>\n     * A numbering system override is a string containing either the name of a known numbering system,\n     * or a set of field and numbering system pairs that specify which fields are to be formattied with\n     * the alternate numbering system.  For example, to specify that all numeric fields in the specified\n     * date or time pattern are to be rendered using Thai digits, simply specify the numbering system override\n     * as \"thai\".  To specify that just the year portion of the date be formatted using Hebrew numbering,\n     * use the override string \"y=hebrew\".  Numbering system overrides can be combined using a semi-colon\n     * character in the override string, such as \"d=decimal;M=arabic;y=hebrew\", etc.\n     *\n     * <P>\n     * [Note:] Not all locales support SimpleDateFormat; for full generality,\n     * use the factory methods in the DateFormat class.\n     * @param pattern    the pattern for the format.\n     * @param override   the override string.\n     * @param status     Output param set to success/failure code.\n     * @stable ICU 4.2\n     */\n    SimpleDateFormat(const UnicodeString& pattern,\n                     const UnicodeString& override,\n                     UErrorCode& status);\n\n    /**\n     * Construct a SimpleDateFormat using the given pattern and locale.\n     * The locale is used to obtain the symbols used in formatting (e.g., the\n     * names of the months), but not to provide the pattern.\n     * <P>\n     * [Note:] Not all locales support SimpleDateFormat; for full generality,\n     * use the factory methods in the DateFormat class.\n     * @param pattern    the pattern for the format.\n     * @param locale     the given locale.\n     * @param status     Output param set to success/failure code.\n     * @stable ICU 2.0\n     */\n    SimpleDateFormat(const UnicodeString& pattern,\n                     const Locale& locale,\n                     UErrorCode& status);\n\n    /**\n     * Construct a SimpleDateFormat using the given pattern, numbering system override, and locale.\n     * The locale is used to obtain the symbols used in formatting (e.g., the\n     * names of the months), but not to provide the pattern.\n     * <P>\n     * A numbering system override is a string containing either the name of a known numbering system,\n     * or a set of field and numbering system pairs that specify which fields are to be formattied with\n     * the alternate numbering system.  For example, to specify that all numeric fields in the specified\n     * date or time pattern are to be rendered using Thai digits, simply specify the numbering system override\n     * as \"thai\".  To specify that just the year portion of the date be formatted using Hebrew numbering,\n     * use the override string \"y=hebrew\".  Numbering system overrides can be combined using a semi-colon\n     * character in the override string, such as \"d=decimal;M=arabic;y=hebrew\", etc.\n     * <P>\n     * [Note:] Not all locales support SimpleDateFormat; for full generality,\n     * use the factory methods in the DateFormat class.\n     * @param pattern    the pattern for the format.\n     * @param override   the numbering system override.\n     * @param locale     the given locale.\n     * @param status     Output param set to success/failure code.\n     * @stable ICU 4.2\n     */\n    SimpleDateFormat(const UnicodeString& pattern,\n                     const UnicodeString& override,\n                     const Locale& locale,\n                     UErrorCode& status);\n\n    /**\n     * Construct a SimpleDateFormat using the given pattern and locale-specific\n     * symbol data.  The formatter takes ownership of the DateFormatSymbols object;\n     * the caller is no longer responsible for deleting it.\n     * @param pattern           the given pattern for the format.\n     * @param formatDataToAdopt the symbols to be adopted.\n     * @param status            Output param set to success/faulure code.\n     * @stable ICU 2.0\n     */\n    SimpleDateFormat(const UnicodeString& pattern,\n                     DateFormatSymbols* formatDataToAdopt,\n                     UErrorCode& status);\n\n    /**\n     * Construct a SimpleDateFormat using the given pattern and locale-specific\n     * symbol data.  The DateFormatSymbols object is NOT adopted; the caller\n     * remains responsible for deleting it.\n     * @param pattern           the given pattern for the format.\n     * @param formatData        the formatting symbols to be use.\n     * @param status            Output param set to success/faulure code.\n     * @stable ICU 2.0\n     */\n    SimpleDateFormat(const UnicodeString& pattern,\n                     const DateFormatSymbols& formatData,\n                     UErrorCode& status);\n\n    /**\n     * Copy constructor.\n     * @stable ICU 2.0\n     */\n    SimpleDateFormat(const SimpleDateFormat&);\n\n    /**\n     * Assignment operator.\n     * @stable ICU 2.0\n     */\n    SimpleDateFormat& operator=(const SimpleDateFormat&);\n\n    /**\n     * Destructor.\n     * @stable ICU 2.0\n     */\n    virtual ~SimpleDateFormat();\n\n    /**\n     * Clone this Format object polymorphically. The caller owns the result and\n     * should delete it when done.\n     * @return    A copy of the object.\n     * @stable ICU 2.0\n     */\n    virtual Format* clone(void) const;\n\n    /**\n     * Return true if the given Format objects are semantically equal. Objects\n     * of different subclasses are considered unequal.\n     * @param other    the object to be compared with.\n     * @return         true if the given Format objects are semantically equal.\n     * @stable ICU 2.0\n     */\n    virtual UBool operator==(const Format& other) const;\n\n\n    using DateFormat::format;\n\n    /**\n     * Format a date or time, which is the standard millis since 24:00 GMT, Jan\n     * 1, 1970. Overrides DateFormat pure virtual method.\n     * <P>\n     * Example: using the US locale: \"yyyy.MM.dd e 'at' HH:mm:ss zzz\" ->>\n     * 1996.07.10 AD at 15:08:56 PDT\n     *\n     * @param cal       Calendar set to the date and time to be formatted\n     *                  into a date/time string.\n     * @param appendTo  Output parameter to receive result.\n     *                  Result is appended to existing contents.\n     * @param pos       The formatting position. On input: an alignment field,\n     *                  if desired. On output: the offsets of the alignment field.\n     * @return          Reference to 'appendTo' parameter.\n     * @stable ICU 2.1\n     */\n    virtual UnicodeString& format(  Calendar& cal,\n                                    UnicodeString& appendTo,\n                                    FieldPosition& pos) const;\n\n    /**\n     * Format a date or time, which is the standard millis since 24:00 GMT, Jan\n     * 1, 1970. Overrides DateFormat pure virtual method.\n     * <P>\n     * Example: using the US locale: \"yyyy.MM.dd e 'at' HH:mm:ss zzz\" ->>\n     * 1996.07.10 AD at 15:08:56 PDT\n     *\n     * @param cal       Calendar set to the date and time to be formatted\n     *                  into a date/time string.\n     * @param appendTo  Output parameter to receive result.\n     *                  Result is appended to existing contents.\n     * @param posIter   On return, can be used to iterate over positions\n     *                  of fields generated by this format call.  Field values\n     *                  are defined in UDateFormatField.\n     * @param status    Input/output param set to success/failure code.\n     * @return          Reference to 'appendTo' parameter.\n     * @stable ICU 4.4\n     */\n    virtual UnicodeString& format(  Calendar& cal,\n                                    UnicodeString& appendTo,\n                                    FieldPositionIterator* posIter,\n                                    UErrorCode& status) const;\n\n    /**\n     * Format a date or time, which is the standard millis since 24:00 GMT, Jan\n     * 1, 1970. Overrides DateFormat pure virtual method.\n     * <P>\n     * Example: using the US locale: \"yyyy.MM.dd e 'at' HH:mm:ss zzz\" ->>\n     * 1996.07.10 AD at 15:08:56 PDT\n     *\n     * @param obj       A Formattable containing the date-time value to be formatted\n     *                  into a date-time string.  If the type of the Formattable\n     *                  is a numeric type, it is treated as if it were an\n     *                  instance of Date.\n     * @param appendTo  Output parameter to receive result.\n     *                  Result is appended to existing contents.\n     * @param pos       The formatting position. On input: an alignment field,\n     *                  if desired. On output: the offsets of the alignment field.\n     * @param status    Input/output param set to success/failure code.\n     * @return          Reference to 'appendTo' parameter.\n     * @stable ICU 2.0\n     */\n    virtual UnicodeString& format(  const Formattable& obj,\n                                    UnicodeString& appendTo,\n                                    FieldPosition& pos,\n                                    UErrorCode& status) const;\n\n    /**\n     * Format a date or time, which is the standard millis since 24:00 GMT, Jan\n     * 1, 1970. Overrides DateFormat pure virtual method.\n     * <P>\n     * Example: using the US locale: \"yyyy.MM.dd e 'at' HH:mm:ss zzz\" ->>\n     * 1996.07.10 AD at 15:08:56 PDT\n     *\n     * @param obj       A Formattable containing the date-time value to be formatted\n     *                  into a date-time string.  If the type of the Formattable\n     *                  is a numeric type, it is treated as if it were an\n     *                  instance of Date.\n     * @param appendTo  Output parameter to receive result.\n     *                  Result is appended to existing contents.\n     * @param posIter   On return, can be used to iterate over positions\n     *                  of fields generated by this format call.  Field values\n     *                  are defined in UDateFormatField.\n     * @param status    Input/output param set to success/failure code.\n     * @return          Reference to 'appendTo' parameter.\n     * @stable ICU 4.4\n     */\n    virtual UnicodeString& format(  const Formattable& obj,\n                                    UnicodeString& appendTo,\n                                    FieldPositionIterator* posIter,\n                                    UErrorCode& status) const;\n\n    /**\n     * Redeclared DateFormat method.\n     * @param date          the Date value to be formatted.\n     * @param appendTo      Output parameter to receive result.\n     *                      Result is appended to existing contents.\n     * @param fieldPosition The formatting position. On input: an alignment field,\n     *                      if desired. On output: the offsets of the alignment field.\n     * @return              Reference to 'appendTo' parameter.\n     * @stable ICU 2.1\n     */\n    UnicodeString& format(UDate date,\n                          UnicodeString& appendTo,\n                          FieldPosition& fieldPosition) const;\n\n    /**\n     * Redeclared DateFormat method.\n     * @param date          the Date value to be formatted.\n     * @param appendTo      Output parameter to receive result.\n     *                      Result is appended to existing contents.\n     * @param posIter       On return, can be used to iterate over positions\n     *                      of fields generated by this format call.  Field values\n     *                      are defined in UDateFormatField.\n     * @param status        Input/output param set to success/failure code.\n     * @return              Reference to 'appendTo' parameter.\n     * @stable ICU 4.4\n     */\n    UnicodeString& format(UDate date,\n                          UnicodeString& appendTo,\n                          FieldPositionIterator* posIter,\n                          UErrorCode& status) const;\n\n    /**\n     * Redeclared DateFormat method.\n     * @param obj       Object to be formatted.\n     * @param appendTo  Output parameter to receive result.\n     *                  Result is appended to existing contents.\n     * @param status    Input/output success/failure code.\n     * @return          Reference to 'appendTo' parameter.\n     * @stable ICU 2.0\n     */\n    UnicodeString& format(const Formattable& obj,\n                          UnicodeString& appendTo,\n                          UErrorCode& status) const;\n\n    /**\n     * Redeclared DateFormat method.\n     * @param date      Date value to be formatted.\n     * @param appendTo  Output parameter to receive result.\n     *                  Result is appended to existing contents.\n     * @return          Reference to 'appendTo' parameter.\n     * @stable ICU 2.0\n     */\n    UnicodeString& format(UDate date, UnicodeString& appendTo) const;\n\n    /**\n     * Parse a date/time string beginning at the given parse position. For\n     * example, a time text \"07/10/96 4:5 PM, PDT\" will be parsed into a Date\n     * that is equivalent to Date(837039928046).\n     * <P>\n     * By default, parsing is lenient: If the input is not in the form used by\n     * this object's format method but can still be parsed as a date, then the\n     * parse succeeds. Clients may insist on strict adherence to the format by\n     * calling setLenient(false).\n     * @see DateFormat::setLenient(boolean)\n     *\n     * @param text  The date/time string to be parsed\n     * @param cal   A Calendar set on input to the date and time to be used for\n     *              missing values in the date/time string being parsed, and set\n     *              on output to the parsed date/time. When the calendar type is\n     *              different from the internal calendar held by this SimpleDateFormat\n     *              instance, the internal calendar will be cloned to a work\n     *              calendar set to the same milliseconds and time zone as the\n     *              cal parameter, field values will be parsed based on the work\n     *              calendar, then the result (milliseconds and time zone) will\n     *              be set in this calendar.\n     * @param pos   On input, the position at which to start parsing; on\n     *              output, the position at which parsing terminated, or the\n     *              start position if the parse failed.\n     * @stable ICU 2.1\n     */\n    virtual void parse( const UnicodeString& text,\n                        Calendar& cal,\n                        ParsePosition& pos) const;\n\n    /**\n     * Parse a date/time string starting at the given parse position. For\n     * example, a time text \"07/10/96 4:5 PM, PDT\" will be parsed into a Date\n     * that is equivalent to Date(837039928046).\n     * <P>\n     * By default, parsing is lenient: If the input is not in the form used by\n     * this object's format method but can still be parsed as a date, then the\n     * parse succeeds. Clients may insist on strict adherence to the format by\n     * calling setLenient(false).\n     * @see DateFormat::setLenient(boolean)\n     * <P>\n     * Note that the normal date formats associated with some calendars - such\n     * as the Chinese lunar calendar - do not specify enough fields to enable\n     * dates to be parsed unambiguously. In the case of the Chinese lunar\n     * calendar, while the year within the current 60-year cycle is specified,\n     * the number of such cycles since the start date of the calendar (in the\n     * ERA field of the Calendar object) is not normally part of the format,\n     * and parsing may assume the wrong era. For cases such as this it is\n     * recommended that clients parse using the method\n     * parse(const UnicodeString&, Calendar& cal, ParsePosition&)\n     * with the Calendar passed in set to the current date, or to a date\n     * within the era/cycle that should be assumed if absent in the format.\n     *\n     * @param text  The date/time string to be parsed\n     * @param pos   On input, the position at which to start parsing; on\n     *              output, the position at which parsing terminated, or the\n     *              start position if the parse failed.\n     * @return      A valid UDate if the input could be parsed.\n     * @stable ICU 2.0\n     */\n    UDate parse( const UnicodeString& text,\n                 ParsePosition& pos) const;\n\n\n    /**\n     * Parse a date/time string. For example, a time text \"07/10/96 4:5 PM, PDT\"\n     * will be parsed into a UDate that is equivalent to Date(837039928046).\n     * Parsing begins at the beginning of the string and proceeds as far as\n     * possible.  Assuming no parse errors were encountered, this function\n     * doesn't return any information about how much of the string was consumed\n     * by the parsing.  If you need that information, use the version of\n     * parse() that takes a ParsePosition.\n     * <P>\n     * By default, parsing is lenient: If the input is not in the form used by\n     * this object's format method but can still be parsed as a date, then the\n     * parse succeeds. Clients may insist on strict adherence to the format by\n     * calling setLenient(false).\n     * @see DateFormat::setLenient(boolean)\n     * <P>\n     * Note that the normal date formats associated with some calendars - such\n     * as the Chinese lunar calendar - do not specify enough fields to enable\n     * dates to be parsed unambiguously. In the case of the Chinese lunar\n     * calendar, while the year within the current 60-year cycle is specified,\n     * the number of such cycles since the start date of the calendar (in the\n     * ERA field of the Calendar object) is not normally part of the format,\n     * and parsing may assume the wrong era. For cases such as this it is\n     * recommended that clients parse using the method\n     * parse(const UnicodeString&, Calendar& cal, ParsePosition&)\n     * with the Calendar passed in set to the current date, or to a date\n     * within the era/cycle that should be assumed if absent in the format.\n     *\n     * @param text  The date/time string to be parsed into a UDate value.\n     * @param status Filled in with U_ZERO_ERROR if the parse was successful, and with\n     *              an error value if there was a parse error.\n     * @return      A valid UDate if the input could be parsed.\n     * @stable ICU 2.0\n     */\n    virtual UDate parse( const UnicodeString& text,\n                        UErrorCode& status) const;\n\n    /**\n     * Set the start UDate used to interpret two-digit year strings.\n     * When dates are parsed having 2-digit year strings, they are placed within\n     * a assumed range of 100 years starting on the two digit start date.  For\n     * example, the string \"24-Jan-17\" may be in the year 1817, 1917, 2017, or\n     * some other year.  SimpleDateFormat chooses a year so that the resultant\n     * date is on or after the two digit start date and within 100 years of the\n     * two digit start date.\n     * <P>\n     * By default, the two digit start date is set to 80 years before the current\n     * time at which a SimpleDateFormat object is created.\n     * @param d      start UDate used to interpret two-digit year strings.\n     * @param status Filled in with U_ZERO_ERROR if the parse was successful, and with\n     *               an error value if there was a parse error.\n     * @stable ICU 2.0\n     */\n    virtual void set2DigitYearStart(UDate d, UErrorCode& status);\n\n    /**\n     * Get the start UDate used to interpret two-digit year strings.\n     * When dates are parsed having 2-digit year strings, they are placed within\n     * a assumed range of 100 years starting on the two digit start date.  For\n     * example, the string \"24-Jan-17\" may be in the year 1817, 1917, 2017, or\n     * some other year.  SimpleDateFormat chooses a year so that the resultant\n     * date is on or after the two digit start date and within 100 years of the\n     * two digit start date.\n     * <P>\n     * By default, the two digit start date is set to 80 years before the current\n     * time at which a SimpleDateFormat object is created.\n     * @param status Filled in with U_ZERO_ERROR if the parse was successful, and with\n     *               an error value if there was a parse error.\n     * @stable ICU 2.0\n     */\n    UDate get2DigitYearStart(UErrorCode& status) const;\n\n    /**\n     * Return a pattern string describing this date format.\n     * @param result Output param to receive the pattern.\n     * @return       A reference to 'result'.\n     * @stable ICU 2.0\n     */\n    virtual UnicodeString& toPattern(UnicodeString& result) const;\n\n    /**\n     * Return a localized pattern string describing this date format.\n     * In most cases, this will return the same thing as toPattern(),\n     * but a locale can specify characters to use in pattern descriptions\n     * in place of the ones described in this class's class documentation.\n     * (Presumably, letters that would be more mnemonic in that locale's\n     * language.)  This function would produce a pattern using those\n     * letters.\n     *\n     * @param result    Receives the localized pattern.\n     * @param status    Output param set to success/failure code on\n     *                  exit. If the pattern is invalid, this will be\n     *                  set to a failure result.\n     * @return          A reference to 'result'.\n     * @stable ICU 2.0\n     */\n    virtual UnicodeString& toLocalizedPattern(UnicodeString& result,\n                                              UErrorCode& status) const;\n\n    /**\n     * Apply the given unlocalized pattern string to this date format.\n     * (i.e., after this call, this formatter will format dates according to\n     * the new pattern)\n     *\n     * @param pattern   The pattern to be applied.\n     * @stable ICU 2.0\n     */\n    virtual void applyPattern(const UnicodeString& pattern);\n\n    /**\n     * Apply the given localized pattern string to this date format.\n     * (see toLocalizedPattern() for more information on localized patterns.)\n     *\n     * @param pattern   The localized pattern to be applied.\n     * @param status    Output param set to success/failure code on\n     *                  exit. If the pattern is invalid, this will be\n     *                  set to a failure result.\n     * @stable ICU 2.0\n     */\n    virtual void applyLocalizedPattern(const UnicodeString& pattern,\n                                       UErrorCode& status);\n\n    /**\n     * Gets the date/time formatting symbols (this is an object carrying\n     * the various strings and other symbols used in formatting: e.g., month\n     * names and abbreviations, time zone names, AM/PM strings, etc.)\n     * @return a copy of the date-time formatting data associated\n     * with this date-time formatter.\n     * @stable ICU 2.0\n     */\n    virtual const DateFormatSymbols* getDateFormatSymbols(void) const;\n\n    /**\n     * Set the date/time formatting symbols.  The caller no longer owns the\n     * DateFormatSymbols object and should not delete it after making this call.\n     * @param newFormatSymbols the given date-time formatting symbols to copy.\n     * @stable ICU 2.0\n     */\n    virtual void adoptDateFormatSymbols(DateFormatSymbols* newFormatSymbols);\n\n    /**\n     * Set the date/time formatting data.\n     * @param newFormatSymbols the given date-time formatting symbols to copy.\n     * @stable ICU 2.0\n     */\n    virtual void setDateFormatSymbols(const DateFormatSymbols& newFormatSymbols);\n\n    /**\n     * Return the class ID for this class. This is useful only for comparing to\n     * a return value from getDynamicClassID(). For example:\n     * <pre>\n     * .   Base* polymorphic_pointer = createPolymorphicObject();\n     * .   if (polymorphic_pointer->getDynamicClassID() ==\n     * .       erived::getStaticClassID()) ...\n     * </pre>\n     * @return          The class ID for all objects of this class.\n     * @stable ICU 2.0\n     */\n    static UClassID U_EXPORT2 getStaticClassID(void);\n\n    /**\n     * Returns a unique class ID POLYMORPHICALLY. Pure virtual override. This\n     * method is to implement a simple version of RTTI, since not all C++\n     * compilers support genuine RTTI. Polymorphic operator==() and clone()\n     * methods call this method.\n     *\n     * @return          The class ID for this object. All objects of a\n     *                  given class have the same class ID.  Objects of\n     *                  other classes have different class IDs.\n     * @stable ICU 2.0\n     */\n    virtual UClassID getDynamicClassID(void) const;\n\n    /**\n     * Set the calendar to be used by this date format. Initially, the default\n     * calendar for the specified or default locale is used.  The caller should\n     * not delete the Calendar object after it is adopted by this call.\n     * Adopting a new calendar will change to the default symbols.\n     *\n     * @param calendarToAdopt    Calendar object to be adopted.\n     * @stable ICU 2.0\n     */\n    virtual void adoptCalendar(Calendar* calendarToAdopt);\n\n    /* Cannot use #ifndef U_HIDE_INTERNAL_API for the following draft method since it is virtual */\n    /**\n     * Set a particular UDisplayContext value in the formatter, such as\n     * UDISPCTX_CAPITALIZATION_FOR_STANDALONE.\n     * @param value The UDisplayContext value to set.\n     * @param status Input/output status. If at entry this indicates a failure\n     *               status, the function will do nothing; otherwise this will be\n     *               updated with any new status from the function. \n     * @internal ICU 50 technology preview\n     */\n    virtual void setContext(UDisplayContext value, UErrorCode& status);\n\n    /* Cannot use #ifndef U_HIDE_INTERNAL_API for the following draft method since it is virtual */\n    /**\n     * Get the formatter's UDisplayContext value for the specified UDisplayContextType,\n     * such as UDISPCTX_TYPE_CAPITALIZATION.\n     * @param type The UDisplayContextType whose value to return\n     * @param status Input/output status. If at entry this indicates a failure\n     *               status, the function will do nothing; otherwise this will be\n     *               updated with any new status from the function. \n     * @return The UDisplayContextValue for the specified type.\n     * @internal ICU 50 technology preview\n     */\n    virtual UDisplayContext getContext(UDisplayContextType type, UErrorCode& status) const;\n\n    /* Cannot use #ifndef U_HIDE_INTERNAL_API for the following methods since they are virtual */\n    /**\n     * Sets the TimeZoneFormat to be used by this date/time formatter.\n     * The caller should not delete the TimeZoneFormat object after\n     * it is adopted by this call.\n     * @param timeZoneFormatToAdopt The TimeZoneFormat object to be adopted.\n     * @internal ICU 49 technology preview\n     */\n    virtual void adoptTimeZoneFormat(TimeZoneFormat* timeZoneFormatToAdopt);\n\n    /**\n     * Sets the TimeZoneFormat to be used by this date/time formatter.\n     * @param newTimeZoneFormat The TimeZoneFormat object to copy.\n     * @internal ICU 49 technology preview\n     */\n    virtual void setTimeZoneFormat(const TimeZoneFormat& newTimeZoneFormat);\n\n    /**\n     * Gets the time zone format object associated with this date/time formatter.\n     * @return the time zone format associated with this date/time formatter.\n     * @internal ICU 49 technology preview\n     */\n    virtual const TimeZoneFormat* getTimeZoneFormat(void) const;\n\n#ifndef U_HIDE_INTERNAL_API\n    /**\n     * This is for ICU internal use only. Please do not use.\n     * Check whether the 'field' is smaller than all the fields covered in\n     * pattern, return TRUE if it is. The sequence of calendar field,\n     * from large to small is: ERA, YEAR, MONTH, DATE, AM_PM, HOUR, MINUTE,...\n     * @param field    the calendar field need to check against\n     * @return         TRUE if the 'field' is smaller than all the fields\n     *                 covered in pattern. FALSE otherwise.\n     * @internal ICU 4.0\n     */\n    UBool isFieldUnitIgnored(UCalendarDateFields field) const;\n\n\n    /**\n     * This is for ICU internal use only. Please do not use.\n     * Check whether the 'field' is smaller than all the fields covered in\n     * pattern, return TRUE if it is. The sequence of calendar field,\n     * from large to small is: ERA, YEAR, MONTH, DATE, AM_PM, HOUR, MINUTE,...\n     * @param pattern  the pattern to check against\n     * @param field    the calendar field need to check against\n     * @return         TRUE if the 'field' is smaller than all the fields\n     *                 covered in pattern. FALSE otherwise.\n     * @internal ICU 4.0\n     */\n    static UBool isFieldUnitIgnored(const UnicodeString& pattern,\n                                    UCalendarDateFields field);\n\n    /**\n     * This is for ICU internal use only. Please do not use.\n     * Get the locale of this simple date formatter.\n     * It is used in DateIntervalFormat.\n     *\n     * @return   locale in this simple date formatter\n     * @internal ICU 4.0\n     */\n    const Locale& getSmpFmtLocale(void) const;\n#endif  /* U_HIDE_INTERNAL_API */\n\nprivate:\n    friend class DateFormat;\n\n    void initializeDefaultCentury(void);\n\n    SimpleDateFormat(); // default constructor not implemented\n\n    /**\n     * Used by the DateFormat factory methods to construct a SimpleDateFormat.\n     * @param timeStyle the time style.\n     * @param dateStyle the date style.\n     * @param locale    the given locale.\n     * @param status    Output param set to success/failure code on\n     *                  exit.\n     */\n    SimpleDateFormat(EStyle timeStyle, EStyle dateStyle, const Locale& locale, UErrorCode& status);\n\n    /**\n     * Construct a SimpleDateFormat for the given locale.  If no resource data\n     * is available, create an object of last resort, using hard-coded strings.\n     * This is an internal method, called by DateFormat.  It should never fail.\n     * @param locale    the given locale.\n     * @param status    Output param set to success/failure code on\n     *                  exit.\n     */\n    SimpleDateFormat(const Locale& locale, UErrorCode& status); // Use default pattern\n\n    /**\n     * Hook called by format(... FieldPosition& ...) and format(...FieldPositionIterator&...)\n     */\n    UnicodeString& _format(Calendar& cal, UnicodeString& appendTo, FieldPositionHandler& handler, UErrorCode& status) const;\n\n    /**\n     * Called by format() to format a single field.\n     *\n     * @param appendTo  Output parameter to receive result.\n     *                  Result is appended to existing contents.\n     * @param ch        The format character we encountered in the pattern.\n     * @param count     Number of characters in the current pattern symbol (e.g.,\n     *                  \"yyyy\" in the pattern would result in a call to this function\n     *                  with ch equal to 'y' and count equal to 4)\n     * @param capitalizationContext Capitalization context for this date format.\n     * @param fieldNum  Zero-based numbering of current field within the overall format.\n     * @param handler   Records information about field positions.\n     * @param cal       Calendar to use\n     * @param status    Receives a status code, which will be U_ZERO_ERROR if the operation\n     *                  succeeds.\n     */\n    void subFormat(UnicodeString &appendTo,\n                   UChar ch,\n                   int32_t count,\n                   UDisplayContext capitalizationContext,\n                   int32_t fieldNum,\n                   FieldPositionHandler& handler,\n                   Calendar& cal,\n                   UErrorCode& status) const; // in case of illegal argument\n\n    /**\n     * Used by subFormat() to format a numeric value.\n     * Appends to toAppendTo a string representation of \"value\"\n     * having a number of digits between \"minDigits\" and\n     * \"maxDigits\".  Uses the DateFormat's NumberFormat.\n     *\n     * @param currentNumberFormat \n     * @param appendTo  Output parameter to receive result.\n     *                  Formatted number is appended to existing contents.\n     * @param value     Value to format.\n     * @param minDigits Minimum number of digits the result should have\n     * @param maxDigits Maximum number of digits the result should have\n     */\n    void zeroPaddingNumber(NumberFormat *currentNumberFormat,\n                           UnicodeString &appendTo,\n                           int32_t value,\n                           int32_t minDigits,\n                           int32_t maxDigits) const;\n\n    /**\n     * Return true if the given format character, occuring count\n     * times, represents a numeric field.\n     */\n    static UBool isNumeric(UChar formatChar, int32_t count);\n\n    /**\n     * Returns TRUE if the patternOffset is at the start of a numeric field.\n     */\n    static UBool isAtNumericField(const UnicodeString &pattern, int32_t patternOffset);\n\n    /**\n     * Returns TRUE if the patternOffset is right after a non-numeric field.\n     */\n    static UBool isAfterNonNumericField(const UnicodeString &pattern, int32_t patternOffset);\n\n    /**\n     * initializes fCalendar from parameters.  Returns fCalendar as a convenience.\n     * @param adoptZone  Zone to be adopted, or NULL for TimeZone::createDefault().\n     * @param locale Locale of the calendar\n     * @param status Error code\n     * @return the newly constructed fCalendar\n     */\n    Calendar *initializeCalendar(TimeZone* adoptZone, const Locale& locale, UErrorCode& status);\n\n    /**\n     * initializes fSymbols from parameters.\n     * @param locale Locale of the symbols\n     * @param calendar Alias to Calendar that will be used.\n     * @param status Error code\n     */\n    void initializeSymbols(const Locale& locale, Calendar* calendar, UErrorCode& status);\n\n    /**\n     * Called by several of the constructors to load pattern data and formatting symbols\n     * out of a resource bundle and initialize the locale based on it.\n     * @param timeStyle     The time style, as passed to DateFormat::createDateInstance().\n     * @param dateStyle     The date style, as passed to DateFormat::createTimeInstance().\n     * @param locale        The locale to load the patterns from.\n     * @param status        Filled in with an error code if loading the data from the\n     *                      resources fails.\n     */\n    void construct(EStyle timeStyle, EStyle dateStyle, const Locale& locale, UErrorCode& status);\n\n    /**\n     * Called by construct() and the various constructors to set up the SimpleDateFormat's\n     * Calendar and NumberFormat objects.\n     * @param locale    The locale for which we want a Calendar and a NumberFormat.\n     * @param status    Filled in with an error code if creating either subobject fails.\n     */\n    void initialize(const Locale& locale, UErrorCode& status);\n\n    /**\n     * Private code-size reduction function used by subParse.\n     * @param text the time text being parsed.\n     * @param start where to start parsing.\n     * @param field the date field being parsed.\n     * @param stringArray the string array to parsed.\n     * @param stringArrayCount the size of the array.\n     * @param monthPattern pointer to leap month pattern, or NULL if none.\n     * @param cal a Calendar set to the date and time to be formatted\n     *            into a date/time string.\n     * @return the new start position if matching succeeded; a negative number\n     * indicating matching failure, otherwise.\n     */\n    int32_t matchString(const UnicodeString& text, int32_t start, UCalendarDateFields field,\n                        const UnicodeString* stringArray, int32_t stringArrayCount,\n                        const UnicodeString* monthPattern, Calendar& cal) const;\n\n    /**\n     * Private code-size reduction function used by subParse.\n     * @param text the time text being parsed.\n     * @param start where to start parsing.\n     * @param field the date field being parsed.\n     * @param stringArray the string array to parsed.\n     * @param stringArrayCount the size of the array.\n     * @param cal a Calendar set to the date and time to be formatted\n     *            into a date/time string.\n     * @return the new start position if matching succeeded; a negative number\n     * indicating matching failure, otherwise.\n     */\n    int32_t matchQuarterString(const UnicodeString& text, int32_t start, UCalendarDateFields field,\n                               const UnicodeString* stringArray, int32_t stringArrayCount, Calendar& cal) const;\n    \n    /**\n     * Private function used by subParse to match literal pattern text.\n     *\n     * @param pattern the pattern string\n     * @param patternOffset the starting offset into the pattern text. On\n     *        outupt will be set the offset of the first non-literal character in the pattern\n     * @param text the text being parsed\n     * @param textOffset the starting offset into the text. On output\n     *                   will be set to the offset of the character after the match\n     * @param lenient <code>TRUE</code> if the parse is lenient, <code>FALSE</code> otherwise.\n     *\n     * @return <code>TRUE</code> if the literal text could be matched, <code>FALSE</code> otherwise.\n     */\n    static UBool matchLiterals(const UnicodeString &pattern, int32_t &patternOffset,\n                               const UnicodeString &text, int32_t &textOffset, UBool lenient);\n    \n    /**\n     * Private member function that converts the parsed date strings into\n     * timeFields. Returns -start (for ParsePosition) if failed.\n     * @param text the time text to be parsed.\n     * @param start where to start parsing.\n     * @param ch the pattern character for the date field text to be parsed.\n     * @param count the count of a pattern character.\n     * @param obeyCount if true then the count is strictly obeyed.\n     * @param allowNegative\n     * @param ambiguousYear If true then the two-digit year == the default start year.\n     * @param saveHebrewMonth Used to hang onto month until year is known.\n     * @param cal a Calendar set to the date and time to be formatted\n     *            into a date/time string.\n     * @param patLoc\n     * @param numericLeapMonthFormatter If non-null, used to parse numeric leap months.\n     * @return the new start position if matching succeeded; a negative number\n     * indicating matching failure, otherwise.\n     */\n    int32_t subParse(const UnicodeString& text, int32_t& start, UChar ch, int32_t count,\n                     UBool obeyCount, UBool allowNegative, UBool ambiguousYear[], int32_t& saveHebrewMonth, Calendar& cal,\n                     int32_t patLoc, MessageFormat * numericLeapMonthFormatter) const;\n\n    void parseInt(const UnicodeString& text,\n                  Formattable& number,\n                  ParsePosition& pos,\n                  UBool allowNegative,\n                  NumberFormat *fmt) const;\n\n    void parseInt(const UnicodeString& text,\n                  Formattable& number,\n                  int32_t maxDigits,\n                  ParsePosition& pos,\n                  UBool allowNegative,\n                  NumberFormat *fmt) const;\n\n    int32_t checkIntSuffix(const UnicodeString& text, int32_t start,\n                           int32_t patLoc, UBool isNegative) const;\n\n    /**\n     * Translate a pattern, mapping each character in the from string to the\n     * corresponding character in the to string. Return an error if the original\n     * pattern contains an unmapped character, or if a quote is unmatched.\n     * Quoted (single quotes only) material is not translated.\n     * @param originalPattern   the original pattern.\n     * @param translatedPattern Output param to receive the translited pattern.\n     * @param from              the characters to be translited from.\n     * @param to                the characters to be translited to.\n     * @param status            Receives a status code, which will be U_ZERO_ERROR\n     *                          if the operation succeeds.\n     */\n    static void translatePattern(const UnicodeString& originalPattern,\n                                UnicodeString& translatedPattern,\n                                const UnicodeString& from,\n                                const UnicodeString& to,\n                                UErrorCode& status);\n\n    /**\n     * Sets the starting date of the 100-year window that dates with 2-digit years\n     * are considered to fall within.\n     * @param startDate the start date\n     * @param status    Receives a status code, which will be U_ZERO_ERROR\n     *                  if the operation succeeds.\n     */\n    void         parseAmbiguousDatesAsAfter(UDate startDate, UErrorCode& status);\n\n    /**\n     * Return the length matched by the given affix, or -1 if none.\n     * Runs of white space in the affix, match runs of white space in\n     * the input.\n     * @param affix pattern string, taken as a literal\n     * @param input input text\n     * @param pos offset into input at which to begin matching\n     * @return length of input that matches, or -1 if match failure\n     */\n    int32_t compareSimpleAffix(const UnicodeString& affix,\n                   const UnicodeString& input,\n                   int32_t pos) const;\n\n    /**\n     * Skip over a run of zero or more Pattern_White_Space characters at\n     * pos in text.\n     */\n    int32_t skipPatternWhiteSpace(const UnicodeString& text, int32_t pos) const;\n\n    /**\n     * Skip over a run of zero or more isUWhiteSpace() characters at pos\n     * in text.\n     */\n    int32_t skipUWhiteSpace(const UnicodeString& text, int32_t pos) const;\n\n    /**\n     * Initialize NumberFormat instances used for numbering system overrides.\n     */\n    void initNumberFormatters(const Locale &locale,UErrorCode &status);\n\n    /**\n     * Get the numbering system to be used for a particular field.\n     */\n     NumberFormat * getNumberFormatByIndex(UDateFormatField index) const;\n\n    /**\n     * Parse the given override string and set up structures for number formats\n     */\n    void processOverrideString(const Locale &locale, const UnicodeString &str, int8_t type, UErrorCode &status);\n\n    /**\n     * Used to map pattern characters to Calendar field identifiers.\n     */\n    static const UCalendarDateFields fgPatternIndexToCalendarField[];\n\n    /**\n     * Map index into pattern character string to DateFormat field number\n     */\n    static const UDateFormatField fgPatternIndexToDateFormatField[];\n\n    /**\n     * Lazy TimeZoneFormat instantiation, semantically const\n     */\n    TimeZoneFormat *tzFormat() const;\n\n    /**\n     * Used to map Calendar field to field level.\n     * The larger the level, the smaller the field unit.\n     * For example, UCAL_ERA level is 0, UCAL_YEAR level is 10,\n     * UCAL_MONTH level is 20.\n     */\n    static const int32_t fgCalendarFieldToLevel[];\n    static const int32_t fgPatternCharToLevel[];\n\n    /**\n     * The formatting pattern for this formatter.\n     */\n    UnicodeString       fPattern;\n\n    /**\n     * The numbering system override for dates.\n     */\n    UnicodeString       fDateOverride;\n\n    /**\n     * The numbering system override for times.\n     */\n    UnicodeString       fTimeOverride;\n\n\n    /**\n     * The original locale used (for reloading symbols)\n     */\n    Locale              fLocale;\n\n    /**\n     * A pointer to an object containing the strings to use in formatting (e.g.,\n     * month and day names, AM and PM strings, time zone names, etc.)\n     */\n    DateFormatSymbols*  fSymbols;   // Owned\n\n    /**\n     * The time zone formatter\n     */\n    TimeZoneFormat* fTimeZoneFormat;\n\n    /**\n     * If dates have ambiguous years, we map them into the century starting\n     * at defaultCenturyStart, which may be any date.  If defaultCenturyStart is\n     * set to SYSTEM_DEFAULT_CENTURY, which it is by default, then the system\n     * values are used.  The instance values defaultCenturyStart and\n     * defaultCenturyStartYear are only used if explicitly set by the user\n     * through the API method parseAmbiguousDatesAsAfter().\n     */\n    UDate                fDefaultCenturyStart;\n\n    /**\n     * See documentation for defaultCenturyStart.\n     */\n    /*transient*/ int32_t   fDefaultCenturyStartYear;\n\n    int32_t tztype; // here to avoid api change\n\n    typedef struct NSOverride {\n        NumberFormat *nf;\n        int32_t hash;\n        NSOverride *next;\n    } NSOverride;\n\n    NumberFormat    **fNumberFormatters;\n\n    NSOverride      *fOverrideList;\n\n    UBool fHaveDefaultCentury;\n\n    UDisplayContext fCapitalizationContext;\n};\n\ninline UDate\nSimpleDateFormat::get2DigitYearStart(UErrorCode& /*status*/) const\n{\n    return fDefaultCenturyStart;\n}\n\ninline UnicodeString&\nSimpleDateFormat::format(const Formattable& obj,\n                         UnicodeString& appendTo,\n                         UErrorCode& status) const {\n    // Don't use Format:: - use immediate base class only,\n    // in case immediate base modifies behavior later.\n    return DateFormat::format(obj, appendTo, status);\n}\n\ninline UnicodeString&\nSimpleDateFormat::format(const Formattable& obj,\n                         UnicodeString& appendTo,\n                         FieldPosition& pos,\n                         UErrorCode& status) const\n{\n    // Don't use Format:: - use immediate base class only,\n    // in case immediate base modifies behavior later.\n    return DateFormat::format(obj, appendTo, pos, status);\n}\n\ninline UnicodeString&\nSimpleDateFormat::format(const Formattable& obj,\n                         UnicodeString& appendTo,\n                         FieldPositionIterator* posIter,\n                         UErrorCode& status) const\n{\n    // Don't use Format:: - use immediate base class only,\n    // in case immediate base modifies behavior later.\n    return DateFormat::format(obj, appendTo, posIter, status);\n}\n\ninline UnicodeString&\nSimpleDateFormat::format(UDate date,\n                         UnicodeString& appendTo,\n                         FieldPosition& fieldPosition) const {\n    // Don't use Format:: - use immediate base class only,\n    // in case immediate base modifies behavior later.\n    return DateFormat::format(date, appendTo, fieldPosition);\n}\n\ninline UnicodeString&\nSimpleDateFormat::format(UDate date,\n                         UnicodeString& appendTo,\n                         FieldPositionIterator* posIter,\n                         UErrorCode& status) const {\n    // Don't use Format:: - use immediate base class only,\n    // in case immediate base modifies behavior later.\n    return DateFormat::format(date, appendTo, posIter, status);\n}\n\ninline UnicodeString&\nSimpleDateFormat::format(UDate date, UnicodeString& appendTo) const {\n    return DateFormat::format(date, appendTo);\n}\n\nU_NAMESPACE_END\n\n#endif /* #if !UCONFIG_NO_FORMATTING */\n\n#endif // _SMPDTFMT\n//eof\n"
  },
  {
    "path": "deprecated/android/addons/icucompat/unicode/sortkey.h",
    "content": "/*\n *****************************************************************************\n * Copyright (C) 1996-2012, International Business Machines Corporation and others.\n * All Rights Reserved.\n *****************************************************************************\n *\n * File sortkey.h\n *\n * Created by: Helena Shih\n *\n * Modification History:\n *\n *  Date         Name          Description\n *\n *  6/20/97     helena      Java class name change.\n *  8/18/97     helena      Added internal API documentation.\n *  6/26/98     erm         Changed to use byte arrays and memcmp.\n *****************************************************************************\n */\n\n#ifndef SORTKEY_H\n#define SORTKEY_H\n\n#include \"unicode/utypes.h\"\n\n/**\n * \\file \n * \\brief C++ API: Keys for comparing strings multiple times. \n */\n \n#if !UCONFIG_NO_COLLATION\n#ifndef U_HIDE_DEPRECATED_API\n\n#include \"unicode/uobject.h\"\n#include \"unicode/unistr.h\"\n#include \"unicode/coll.h\"\n\nU_NAMESPACE_BEGIN\n\n/* forward declaration */\nclass RuleBasedCollator;\n\n/**\n *\n * Collation keys are generated by the Collator class.  Use the CollationKey objects\n * instead of Collator to compare strings multiple times.  A CollationKey\n * preprocesses the comparison information from the Collator object to\n * make the comparison faster.  If you are not going to comparing strings\n * multiple times, then using the Collator object is generally faster,\n * since it only processes as much of the string as needed to make a\n * comparison.\n * <p> For example (with strength == tertiary)\n * <p>When comparing \"Abernathy\" to \"Baggins-Smythworthy\", Collator\n * only needs to process a couple of characters, while a comparison\n * with CollationKeys will process all of the characters.  On the other hand,\n * if you are doing a sort of a number of fields, it is much faster to use\n * CollationKeys, since you will be comparing strings multiple times.\n * <p>Typical use of CollationKeys are in databases, where you store a CollationKey\n * in a hidden field, and use it for sorting or indexing.\n *\n * <p>Example of use:\n * <pre>\n * \\code\n *     UErrorCode success = U_ZERO_ERROR;\n *     Collator* myCollator = Collator::createInstance(success);\n *     CollationKey* keys = new CollationKey [3];\n *     myCollator->getCollationKey(\"Tom\", keys[0], success );\n *     myCollator->getCollationKey(\"Dick\", keys[1], success );\n *     myCollator->getCollationKey(\"Harry\", keys[2], success );\n *\n *     // Inside body of sort routine, compare keys this way:\n *     CollationKey tmp;\n *     if(keys[0].compareTo( keys[1] ) > 0 ) {\n *         tmp = keys[0]; keys[0] = keys[1]; keys[1] = tmp;\n *     }\n *     //...\n * \\endcode\n * </pre>\n * <p>Because Collator::compare()'s algorithm is complex, it is faster to sort\n * long lists of words by retrieving collation keys with Collator::getCollationKey().\n * You can then cache the collation keys and compare them using CollationKey::compareTo().\n * <p>\n * <strong>Note:</strong> <code>Collator</code>s with different Locale,\n * CollationStrength and DecompositionMode settings will return different\n * CollationKeys for the same set of strings. Locales have specific\n * collation rules, and the way in which secondary and tertiary differences\n * are taken into account, for example, will result in different CollationKeys\n * for same strings.\n * <p>\n\n * @see          Collator\n * @see          RuleBasedCollator\n * @version      1.3 12/18/96\n * @author       Helena Shih\n * @stable ICU 2.0\n */\nclass U_I18N_API CollationKey : public UObject {\npublic:\n    /**\n    * This creates an empty collation key based on the null string.  An empty\n    * collation key contains no sorting information.  When comparing two empty\n    * collation keys, the result is Collator::EQUAL.  Comparing empty collation key\n    * with non-empty collation key is always Collator::LESS.\n    * @stable ICU 2.0\n    */\n    CollationKey();\n\n\n    /**\n    * Creates a collation key based on the collation key values.\n    * @param values the collation key values\n    * @param count number of collation key values, including trailing nulls.\n    * @stable ICU 2.0\n    */\n    CollationKey(const  uint8_t*    values,\n                int32_t     count);\n\n    /**\n    * Copy constructor.\n    * @param other    the object to be copied.\n    * @stable ICU 2.0\n    */\n    CollationKey(const CollationKey& other);\n\n    /**\n    * Sort key destructor.\n    * @stable ICU 2.0\n    */\n    virtual ~CollationKey();\n\n    /**\n    * Assignment operator\n    * @param other    the object to be copied.\n    * @stable ICU 2.0\n    */\n    const   CollationKey&   operator=(const CollationKey& other);\n\n    /**\n    * Compare if two collation keys are the same.\n    * @param source the collation key to compare to.\n    * @return Returns true if two collation keys are equal, false otherwise.\n    * @stable ICU 2.0\n    */\n    UBool                   operator==(const CollationKey& source) const;\n\n    /**\n    * Compare if two collation keys are not the same.\n    * @param source the collation key to compare to.\n    * @return Returns TRUE if two collation keys are different, FALSE otherwise.\n    * @stable ICU 2.0\n    */\n    UBool                   operator!=(const CollationKey& source) const;\n\n\n    /**\n    * Test to see if the key is in an invalid state. The key will be in an\n    * invalid state if it couldn't allocate memory for some operation.\n    * @return Returns TRUE if the key is in an invalid, FALSE otherwise.\n    * @stable ICU 2.0\n    */\n    UBool                   isBogus(void) const;\n\n    /**\n    * Returns a pointer to the collation key values. The storage is owned\n    * by the collation key and the pointer will become invalid if the key\n    * is deleted.\n    * @param count the output parameter of number of collation key values,\n    * including any trailing nulls.\n    * @return a pointer to the collation key values.\n    * @stable ICU 2.0\n    */\n    const    uint8_t*       getByteArray(int32_t& count) const;\n\n#ifdef U_USE_COLLATION_KEY_DEPRECATES\n    /**\n    * Extracts the collation key values into a new array. The caller owns\n    * this storage and should free it.\n    * @param count the output parameter of number of collation key values,\n    * including any trailing nulls.\n    * @obsolete ICU 2.6. Use getByteArray instead since this API will be removed in that release.\n    */\n    uint8_t*                toByteArray(int32_t& count) const;\n#endif\n\n    /**\n    * Convenience method which does a string(bit-wise) comparison of the\n    * two collation keys.\n    * @param target target collation key to be compared with\n    * @return Returns Collator::LESS if sourceKey &lt; targetKey,\n    * Collator::GREATER if sourceKey > targetKey and Collator::EQUAL\n    * otherwise.\n    * @deprecated ICU 2.6 use the overload with error code\n    */\n    Collator::EComparisonResult compareTo(const CollationKey& target) const;\n\n    /**\n    * Convenience method which does a string(bit-wise) comparison of the\n    * two collation keys.\n    * @param target target collation key to be compared with\n    * @param status error code\n    * @return Returns UCOL_LESS if sourceKey &lt; targetKey,\n    * UCOL_GREATER if sourceKey > targetKey and UCOL_EQUAL\n    * otherwise.\n    * @stable ICU 2.6\n    */\n    UCollationResult compareTo(const CollationKey& target, UErrorCode &status) const;\n\n    /**\n    * Creates an integer that is unique to the collation key.  NOTE: this\n    * is not the same as String.hashCode.\n    * <p>Example of use:\n    * <pre>\n    * .    UErrorCode status = U_ZERO_ERROR;\n    * .    Collator *myCollation = Collator::createInstance(Locale::US, status);\n    * .    if (U_FAILURE(status)) return;\n    * .    CollationKey key1, key2;\n    * .    UErrorCode status1 = U_ZERO_ERROR, status2 = U_ZERO_ERROR;\n    * .    myCollation->getCollationKey(\"abc\", key1, status1);\n    * .    if (U_FAILURE(status1)) { delete myCollation; return; }\n    * .    myCollation->getCollationKey(\"ABC\", key2, status2);\n    * .    if (U_FAILURE(status2)) { delete myCollation; return; }\n    * .    // key1.hashCode() != key2.hashCode()\n    * </pre>\n    * @return the hash value based on the string's collation order.\n    * @see UnicodeString#hashCode\n    * @stable ICU 2.0\n    */\n    int32_t                 hashCode(void) const;\n\n    /**\n     * ICU \"poor man's RTTI\", returns a UClassID for the actual class.\n     * @stable ICU 2.2\n     */\n    virtual UClassID getDynamicClassID() const;\n\n    /**\n     * ICU \"poor man's RTTI\", returns a UClassID for this class.\n     * @stable ICU 2.2\n     */\n    static UClassID U_EXPORT2 getStaticClassID();\n\nprivate:\n    /**\n     * Replaces the current bytes buffer with a new one of newCapacity\n     * and copies length bytes from the old buffer to the new one.\n     * @return the new buffer, or NULL if the allocation failed\n     */\n    uint8_t *reallocate(int32_t newCapacity, int32_t length);\n    /**\n     * Set a new length for a new sort key in the existing fBytes.\n     */\n    void setLength(int32_t newLength);\n\n    uint8_t *getBytes() {\n        return (fFlagAndLength >= 0) ? fUnion.fStackBuffer : fUnion.fFields.fBytes;\n    }\n    const uint8_t *getBytes() const {\n        return (fFlagAndLength >= 0) ? fUnion.fStackBuffer : fUnion.fFields.fBytes;\n    }\n    int32_t getCapacity() const {\n        return (fFlagAndLength >= 0) ? (int32_t)sizeof(fUnion) : fUnion.fFields.fCapacity;\n    }\n    int32_t getLength() const { return fFlagAndLength & 0x7fffffff; }\n\n    /**\n    * Set the CollationKey to a \"bogus\" or invalid state\n    * @return this CollationKey\n    */\n    CollationKey&           setToBogus(void);\n    /**\n    * Resets this CollationKey to an empty state\n    * @return this CollationKey\n    */\n    CollationKey&           reset(void);\n\n    /**\n    * Allow private access to RuleBasedCollator\n    */\n    friend  class           RuleBasedCollator;\n    friend  class           CollationKeyByteSink;\n\n    // Class fields. sizeof(CollationKey) is intended to be 48 bytes\n    // on a machine with 64-bit pointers.\n    // We use a union to maximize the size of the internal buffer,\n    // similar to UnicodeString but not as tight and complex.\n\n    // (implicit) *vtable;\n    /**\n     * Sort key length and flag.\n     * Bit 31 is set if the buffer is heap-allocated.\n     * Bits 30..0 contain the sort key length.\n     */\n    int32_t fFlagAndLength;\n    /**\n    * Unique hash value of this CollationKey.\n    * Special value 2 if the key is bogus.\n    */\n    mutable int32_t fHashCode;\n    /**\n     * fUnion provides 32 bytes for the internal buffer or for\n     * pointer+capacity.\n     */\n    union StackBufferOrFields {\n        /** fStackBuffer is used iff fFlagAndLength>=0, else fFields is used */\n        uint8_t fStackBuffer[32];\n        struct {\n            uint8_t *fBytes;\n            int32_t fCapacity;\n        } fFields;\n    } fUnion;\n};\n\ninline UBool\nCollationKey::operator!=(const CollationKey& other) const\n{\n    return !(*this == other);\n}\n\ninline UBool\nCollationKey::isBogus() const\n{\n    return fHashCode == 2;  // kBogusHashCode\n}\n\ninline const uint8_t*\nCollationKey::getByteArray(int32_t &count) const\n{\n    count = getLength();\n    return getBytes();\n}\n\nU_NAMESPACE_END\n\n#endif  /* U_HIDE_DEPRECATED_API */\n#endif /* #if !UCONFIG_NO_COLLATION */\n\n#endif\n"
  },
  {
    "path": "deprecated/android/addons/icucompat/unicode/std_string.h",
    "content": "/*\n*******************************************************************************\n*\n*   Copyright (C) 2009-2011, International Business Machines\n*   Corporation and others.  All Rights Reserved.\n*\n*******************************************************************************\n*   file name:  std_string.h\n*   encoding:   US-ASCII\n*   tab size:   8 (not used)\n*   indentation:4\n*\n*   created on: 2009feb19\n*   created by: Markus W. Scherer\n*/\n\n#ifndef __STD_STRING_H__\n#define __STD_STRING_H__\n\n/**\n * \\file \n * \\brief C++ API: Central ICU header for including the C++ standard &lt;string&gt;\n *                 header and for related definitions.\n */\n\n#include \"unicode/utypes.h\"\n\n#if U_HAVE_STD_STRING\n\n#include <string>\n\n#endif  // U_HAVE_STD_STRING\n\n#endif  // __STD_STRING_H__\n"
  },
  {
    "path": "deprecated/android/addons/icucompat/unicode/strenum.h",
    "content": "/*\n*******************************************************************************\n*\n*   Copyright (C) 2002-2012, International Business Machines\n*   Corporation and others.  All Rights Reserved.\n*\n*******************************************************************************\n*/\n\n#ifndef STRENUM_H\n#define STRENUM_H\n\n#include \"unicode/uobject.h\"\n#include \"unicode/unistr.h\"\n\n/**\n * \\file \n * \\brief C++ API: String Enumeration\n */\n \nU_NAMESPACE_BEGIN\n\n/**\n * Base class for 'pure' C++ implementations of uenum api.  Adds a\n * method that returns the next UnicodeString since in C++ this can\n * be a common storage format for strings.\n *\n * <p>The model is that the enumeration is over strings maintained by\n * a 'service.'  At any point, the service might change, invalidating\n * the enumerator (though this is expected to be rare).  The iterator\n * returns an error if this has occurred.  Lack of the error is no\n * guarantee that the service didn't change immediately after the\n * call, so the returned string still might not be 'valid' on\n * subsequent use.</p>\n *\n * <p>Strings may take the form of const char*, const UChar*, or const\n * UnicodeString*.  The type you get is determine by the variant of\n * 'next' that you call.  In general the StringEnumeration is\n * optimized for one of these types, but all StringEnumerations can\n * return all types.  Returned strings are each terminated with a NUL.\n * Depending on the service data, they might also include embedded NUL\n * characters, so API is provided to optionally return the true\n * length, counting the embedded NULs but not counting the terminating\n * NUL.</p>\n *\n * <p>The pointers returned by next, unext, and snext become invalid\n * upon any subsequent call to the enumeration's destructor, next,\n * unext, snext, or reset.</p>\n *\n * ICU 2.8 adds some default implementations and helper functions\n * for subclasses.\n *\n * @stable ICU 2.4 \n */\nclass U_COMMON_API StringEnumeration : public UObject { \npublic:\n    /**\n     * Destructor.\n     * @stable ICU 2.4\n     */\n    virtual ~StringEnumeration();\n\n    /**\n     * Clone this object, an instance of a subclass of StringEnumeration.\n     * Clones can be used concurrently in multiple threads.\n     * If a subclass does not implement clone(), or if an error occurs,\n     * then NULL is returned.\n     * The clone functions in all subclasses return a base class pointer\n     * because some compilers do not support covariant (same-as-this)\n     * return types; cast to the appropriate subclass if necessary.\n     * The caller must delete the clone.\n     *\n     * @return a clone of this object\n     *\n     * @see getDynamicClassID\n     * @stable ICU 2.8\n     */\n    virtual StringEnumeration *clone() const;\n\n    /**\n     * <p>Return the number of elements that the iterator traverses.  If\n     * the iterator is out of sync with its service, status is set to\n     * U_ENUM_OUT_OF_SYNC_ERROR, and the return value is zero.</p>\n     *\n     * <p>The return value will not change except possibly as a result of\n     * a subsequent call to reset, or if the iterator becomes out of sync.</p>\n     *\n     * <p>This is a convenience function. It can end up being very\n     * expensive as all the items might have to be pre-fetched\n     * (depending on the storage format of the data being\n     * traversed).</p>\n     *\n     * @param status the error code.\n     * @return number of elements in the iterator.\n     *\n     * @stable ICU 2.4 */\n    virtual int32_t count(UErrorCode& status) const = 0;\n\n    /**\n     * <p>Returns the next element as a NUL-terminated char*.  If there\n     * are no more elements, returns NULL.  If the resultLength pointer\n     * is not NULL, the length of the string (not counting the\n     * terminating NUL) is returned at that address.  If an error\n     * status is returned, the value at resultLength is undefined.</p>\n     *\n     * <p>The returned pointer is owned by this iterator and must not be\n     * deleted by the caller.  The pointer is valid until the next call\n     * to next, unext, snext, reset, or the enumerator's destructor.</p>\n     *\n     * <p>If the iterator is out of sync with its service, status is set\n     * to U_ENUM_OUT_OF_SYNC_ERROR and NULL is returned.</p>\n     *\n     * <p>If the native service string is a UChar* string, it is\n     * converted to char* with the invariant converter.  If the\n     * conversion fails (because a character cannot be converted) then\n     * status is set to U_INVARIANT_CONVERSION_ERROR and the return\n     * value is undefined (though not NULL).</p>\n     *\n     * Starting with ICU 2.8, the default implementation calls snext()\n     * and handles the conversion.\n     * Either next() or snext() must be implemented differently by a subclass.\n     *\n     * @param status the error code.\n     * @param resultLength a pointer to receive the length, can be NULL.\n     * @return a pointer to the string, or NULL.\n     *\n     * @stable ICU 2.4 \n     */\n    virtual const char* next(int32_t *resultLength, UErrorCode& status);\n\n    /**\n     * <p>Returns the next element as a NUL-terminated UChar*.  If there\n     * are no more elements, returns NULL.  If the resultLength pointer\n     * is not NULL, the length of the string (not counting the\n     * terminating NUL) is returned at that address.  If an error\n     * status is returned, the value at resultLength is undefined.</p>\n     *\n     * <p>The returned pointer is owned by this iterator and must not be\n     * deleted by the caller.  The pointer is valid until the next call\n     * to next, unext, snext, reset, or the enumerator's destructor.</p>\n     *\n     * <p>If the iterator is out of sync with its service, status is set\n     * to U_ENUM_OUT_OF_SYNC_ERROR and NULL is returned.</p>\n     *\n     * Starting with ICU 2.8, the default implementation calls snext()\n     * and handles the conversion.\n     *\n     * @param status the error code.\n     * @param resultLength a ponter to receive the length, can be NULL.\n     * @return a pointer to the string, or NULL.\n     *\n     * @stable ICU 2.4 \n     */\n    virtual const UChar* unext(int32_t *resultLength, UErrorCode& status);\n\n    /**\n     * <p>Returns the next element a UnicodeString*.  If there are no\n     * more elements, returns NULL.</p>\n     *\n     * <p>The returned pointer is owned by this iterator and must not be\n     * deleted by the caller.  The pointer is valid until the next call\n     * to next, unext, snext, reset, or the enumerator's destructor.</p>\n     *\n     * <p>If the iterator is out of sync with its service, status is set\n     * to U_ENUM_OUT_OF_SYNC_ERROR and NULL is returned.</p>\n     *\n     * Starting with ICU 2.8, the default implementation calls next()\n     * and handles the conversion.\n     * Either next() or snext() must be implemented differently by a subclass.\n     *\n     * @param status the error code.\n     * @return a pointer to the string, or NULL.\n     *\n     * @stable ICU 2.4 \n     */\n    virtual const UnicodeString* snext(UErrorCode& status);\n\n    /**\n     * <p>Resets the iterator.  This re-establishes sync with the\n     * service and rewinds the iterator to start at the first\n     * element.</p>\n     *\n     * <p>Previous pointers returned by next, unext, or snext become\n     * invalid, and the value returned by count might change.</p>\n     *\n     * @param status the error code.\n     *\n     * @stable ICU 2.4 \n     */\n    virtual void reset(UErrorCode& status) = 0;\n\n    /**\n     * Compares this enumeration to other to check if both are equal\n     *\n     * @param that The other string enumeration to compare this object to\n     * @return TRUE if the enumerations are equal. FALSE if not.\n     * @stable ICU 3.6 \n     */\n    virtual UBool operator==(const StringEnumeration& that)const;\n    /**\n     * Compares this enumeration to other to check if both are not equal\n     *\n     * @param that The other string enumeration to compare this object to\n     * @return TRUE if the enumerations are equal. FALSE if not.\n     * @stable ICU 3.6 \n     */\n    virtual UBool operator!=(const StringEnumeration& that)const;\n\nprotected:\n    /**\n     * UnicodeString field for use with default implementations and subclasses.\n     * @stable ICU 2.8\n     */\n    UnicodeString unistr;\n    /**\n     * char * default buffer for use with default implementations and subclasses.\n     * @stable ICU 2.8\n     */\n    char charsBuffer[32];\n    /**\n     * char * buffer for use with default implementations and subclasses.\n     * Allocated in constructor and in ensureCharsCapacity().\n     * @stable ICU 2.8\n     */\n    char *chars;\n    /**\n     * Capacity of chars, for use with default implementations and subclasses.\n     * @stable ICU 2.8\n     */\n    int32_t charsCapacity;\n\n    /**\n     * Default constructor for use with default implementations and subclasses.\n     * @stable ICU 2.8\n     */\n    StringEnumeration();\n\n    /**\n     * Ensures that chars is at least as large as the requested capacity.\n     * For use with default implementations and subclasses.\n     *\n     * @param capacity Requested capacity.\n     * @param status ICU in/out error code.\n     * @stable ICU 2.8\n     */\n    void ensureCharsCapacity(int32_t capacity, UErrorCode &status);\n\n    /**\n     * Converts s to Unicode and sets unistr to the result.\n     * For use with default implementations and subclasses,\n     * especially for implementations of snext() in terms of next().\n     * This is provided with a helper function instead of a default implementation\n     * of snext() to avoid potential infinite loops between next() and snext().\n     *\n     * For example:\n     * \\code\n     * const UnicodeString* snext(UErrorCode& status) {\n     *   int32_t resultLength=0;\n     *   const char *s=next(&resultLength, status);\n     *   return setChars(s, resultLength, status);\n     * }\n     * \\endcode\n     *\n     * @param s String to be converted to Unicode.\n     * @param length Length of the string.\n     * @param status ICU in/out error code.\n     * @return A pointer to unistr.\n     * @stable ICU 2.8\n     */\n    UnicodeString *setChars(const char *s, int32_t length, UErrorCode &status);\n};\n\nU_NAMESPACE_END\n\n/* STRENUM_H */\n#endif\n"
  },
  {
    "path": "deprecated/android/addons/icucompat/unicode/stringpiece.h",
    "content": "// Copyright (C) 2009-2012, International Business Machines\n// Corporation and others. All Rights Reserved.\n//\n// Copyright 2001 and onwards Google Inc.\n// Author: Sanjay Ghemawat\n\n// This code is a contribution of Google code, and the style used here is\n// a compromise between the original Google code and the ICU coding guidelines.\n// For example, data types are ICU-ified (size_t,int->int32_t),\n// and API comments doxygen-ified, but function names and behavior are\n// as in the original, if possible.\n// Assertion-style error handling, not available in ICU, was changed to\n// parameter \"pinning\" similar to UnicodeString.\n//\n// In addition, this is only a partial port of the original Google code,\n// limited to what was needed so far. The (nearly) complete original code\n// is in the ICU svn repository at icuhtml/trunk/design/strings/contrib\n// (see ICU ticket 6765, r25517).\n\n#ifndef __STRINGPIECE_H__\n#define __STRINGPIECE_H__\n\n/**\n * \\file \n * \\brief C++ API: StringPiece: Read-only byte string wrapper class.\n */\n\n#include \"unicode/utypes.h\"\n#include \"unicode/uobject.h\"\n#include \"unicode/std_string.h\"\n\n// Arghh!  I wish C++ literals were \"string\".\n\nU_NAMESPACE_BEGIN\n\n/**\n * A string-like object that points to a sized piece of memory.\n *\n * We provide non-explicit singleton constructors so users can pass\n * in a \"const char*\" or a \"string\" wherever a \"StringPiece\" is\n * expected.\n *\n * Functions or methods may use const StringPiece& parameters to accept either\n * a \"const char*\" or a \"string\" value that will be implicitly converted to\n * a StringPiece.\n *\n * Systematic usage of StringPiece is encouraged as it will reduce unnecessary\n * conversions from \"const char*\" to \"string\" and back again.\n *\n * @stable ICU 4.2\n */\nclass U_COMMON_API StringPiece : public UMemory {\n private:\n  const char*   ptr_;\n  int32_t       length_;\n\n public:\n  /**\n   * Default constructor, creates an empty StringPiece.\n   * @stable ICU 4.2\n   */\n  StringPiece() : ptr_(NULL), length_(0) { }\n  /**\n   * Constructs from a NUL-terminated const char * pointer.\n   * @param str a NUL-terminated const char * pointer\n   * @stable ICU 4.2\n   */\n  StringPiece(const char* str);\n#if U_HAVE_STD_STRING\n  /**\n   * Constructs from a std::string.\n   * @stable ICU 4.2\n   */\n  StringPiece(const std::string& str)\n    : ptr_(str.data()), length_(static_cast<int32_t>(str.size())) { }\n#endif\n  /**\n   * Constructs from a const char * pointer and a specified length.\n   * @param offset a const char * pointer (need not be terminated)\n   * @param len the length of the string; must be non-negative\n   * @stable ICU 4.2\n   */\n  StringPiece(const char* offset, int32_t len) : ptr_(offset), length_(len) { }\n  /**\n   * Substring of another StringPiece.\n   * @param x the other StringPiece\n   * @param pos start position in x; must be non-negative and <= x.length().\n   * @stable ICU 4.2\n   */\n  StringPiece(const StringPiece& x, int32_t pos);\n  /**\n   * Substring of another StringPiece.\n   * @param x the other StringPiece\n   * @param pos start position in x; must be non-negative and <= x.length().\n   * @param len length of the substring;\n   *            must be non-negative and will be pinned to at most x.length() - pos.\n   * @stable ICU 4.2\n   */\n  StringPiece(const StringPiece& x, int32_t pos, int32_t len);\n\n  /**\n   * Returns the string pointer. May be NULL if it is empty.\n   *\n   * data() may return a pointer to a buffer with embedded NULs, and the\n   * returned buffer may or may not be null terminated.  Therefore it is\n   * typically a mistake to pass data() to a routine that expects a NUL\n   * terminated string.\n   * @return the string pointer\n   * @stable ICU 4.2\n   */\n  const char* data() const { return ptr_; }\n  /**\n   * Returns the string length. Same as length().\n   * @return the string length\n   * @stable ICU 4.2\n   */\n  int32_t size() const { return length_; }\n  /**\n   * Returns the string length. Same as size().\n   * @return the string length\n   * @stable ICU 4.2\n   */\n  int32_t length() const { return length_; }\n  /**\n   * Returns whether the string is empty.\n   * @return TRUE if the string is empty\n   * @stable ICU 4.2\n   */\n  UBool empty() const { return length_ == 0; }\n\n  /**\n   * Sets to an empty string.\n   * @stable ICU 4.2\n   */\n  void clear() { ptr_ = NULL; length_ = 0; }\n\n  /**\n   * Reset the stringpiece to refer to new data.\n   * @param xdata pointer the new string data.  Need not be nul terminated.\n   * @param len the length of the new data\n   * @stable ICU 4.8\n   */\n  void set(const char* xdata, int32_t len) { ptr_ = xdata; length_ = len; }\n\n  /**\n   * Reset the stringpiece to refer to new data.\n   * @param str a pointer to a NUL-terminated string. \n   * @stable ICU 4.8\n   */\n  void set(const char* str);\n\n  /**\n   * Removes the first n string units.\n   * @param n prefix length, must be non-negative and <=length()\n   * @stable ICU 4.2\n   */\n  void remove_prefix(int32_t n) {\n    if (n >= 0) {\n      if (n > length_) {\n        n = length_;\n      }\n      ptr_ += n;\n      length_ -= n;\n    }\n  }\n\n  /**\n   * Removes the last n string units.\n   * @param n suffix length, must be non-negative and <=length()\n   * @stable ICU 4.2\n   */\n  void remove_suffix(int32_t n) {\n    if (n >= 0) {\n      if (n <= length_) {\n        length_ -= n;\n      } else {\n        length_ = 0;\n      }\n    }\n  }\n\n  /**\n   * Maximum integer, used as a default value for substring methods.\n   * @stable ICU 4.2\n   */\n  static const int32_t npos = 0x7fffffff;\n\n  /**\n   * Returns a substring of this StringPiece.\n   * @param pos start position; must be non-negative and <= length().\n   * @param len length of the substring;\n   *            must be non-negative and will be pinned to at most length() - pos.\n   * @return the substring StringPiece\n   * @stable ICU 4.2\n   */\n  StringPiece substr(int32_t pos, int32_t len = npos) const {\n    return StringPiece(*this, pos, len);\n  }\n};\n\n/**\n * Global operator == for StringPiece\n * @param x The first StringPiece to compare.\n * @param y The second StringPiece to compare.\n * @return TRUE if the string data is equal\n * @stable ICU 4.8\n */\nU_EXPORT UBool U_EXPORT2 \noperator==(const StringPiece& x, const StringPiece& y);\n\n/**\n * Global operator != for StringPiece\n * @param x The first StringPiece to compare.\n * @param y The second StringPiece to compare.\n * @return TRUE if the string data is not equal\n * @stable ICU 4.8\n */\ninline UBool operator!=(const StringPiece& x, const StringPiece& y) {\n  return !(x == y);\n}\n\nU_NAMESPACE_END\n\n#endif  // __STRINGPIECE_H__\n"
  },
  {
    "path": "deprecated/android/addons/icucompat/unicode/stringtriebuilder.h",
    "content": "/*\n*******************************************************************************\n*   Copyright (C) 2010-2012, International Business Machines\n*   Corporation and others.  All Rights Reserved.\n*******************************************************************************\n*   file name:  stringtriebuilder.h\n*   encoding:   US-ASCII\n*   tab size:   8 (not used)\n*   indentation:4\n*\n*   created on: 2010dec24\n*   created by: Markus W. Scherer\n*/\n\n#ifndef __STRINGTRIEBUILDER_H__\n#define __STRINGTRIEBUILDER_H__\n\n#include \"unicode/utypes.h\"\n#include \"unicode/uobject.h\"\n\n/**\n * \\file\n * \\brief C++ API: Builder API for trie builders\n */\n\n// Forward declaration.\nstruct UHashtable;\ntypedef struct UHashtable UHashtable;\n\n/**\n * Build options for BytesTrieBuilder and CharsTrieBuilder.\n * @stable ICU 4.8\n */\nenum UStringTrieBuildOption {\n    /**\n     * Builds a trie quickly.\n     * @stable ICU 4.8\n     */\n    USTRINGTRIE_BUILD_FAST,\n    /**\n     * Builds a trie more slowly, attempting to generate\n     * a shorter but equivalent serialization.\n     * This build option also uses more memory.\n     *\n     * This option can be effective when many integer values are the same\n     * and string/byte sequence suffixes can be shared.\n     * Runtime speed is not expected to improve.\n     * @stable ICU 4.8\n     */\n    USTRINGTRIE_BUILD_SMALL\n};\n\nU_NAMESPACE_BEGIN\n\n/**\n * Base class for string trie builder classes.\n *\n * This class is not intended for public subclassing.\n * @stable ICU 4.8\n */\nclass U_COMMON_API StringTrieBuilder : public UObject {\npublic:\n#ifndef U_HIDE_INTERNAL_API\n    /** @internal */\n    static UBool hashNode(const void *node);\n    /** @internal */\n    static UBool equalNodes(const void *left, const void *right);\n#endif  /* U_HIDE_INTERNAL_API */\n\nprotected:\n    // Do not enclose the protected default constructor with #ifndef U_HIDE_INTERNAL_API\n    // or else the compiler will create a public default constructor.\n    /** @internal */\n    StringTrieBuilder();\n    /** @internal */\n    virtual ~StringTrieBuilder();\n\n#ifndef U_HIDE_INTERNAL_API\n    /** @internal */\n    void createCompactBuilder(int32_t sizeGuess, UErrorCode &errorCode);\n    /** @internal */\n    void deleteCompactBuilder();\n\n    /** @internal */\n    void build(UStringTrieBuildOption buildOption, int32_t elementsLength, UErrorCode &errorCode);\n\n    /** @internal */\n    int32_t writeNode(int32_t start, int32_t limit, int32_t unitIndex);\n    /** @internal */\n    int32_t writeBranchSubNode(int32_t start, int32_t limit, int32_t unitIndex, int32_t length);\n#endif  /* U_HIDE_INTERNAL_API */\n\n    class Node;\n\n#ifndef U_HIDE_INTERNAL_API\n    /** @internal */\n    Node *makeNode(int32_t start, int32_t limit, int32_t unitIndex, UErrorCode &errorCode);\n    /** @internal */\n    Node *makeBranchSubNode(int32_t start, int32_t limit, int32_t unitIndex,\n                            int32_t length, UErrorCode &errorCode);\n#endif  /* U_HIDE_INTERNAL_API */\n\n    /** @internal */\n    virtual int32_t getElementStringLength(int32_t i) const = 0;\n    /** @internal */\n    virtual UChar getElementUnit(int32_t i, int32_t unitIndex) const = 0;\n    /** @internal */\n    virtual int32_t getElementValue(int32_t i) const = 0;\n\n    // Finds the first unit index after this one where\n    // the first and last element have different units again.\n    /** @internal */\n    virtual int32_t getLimitOfLinearMatch(int32_t first, int32_t last, int32_t unitIndex) const = 0;\n\n    // Number of different units at unitIndex.\n    /** @internal */\n    virtual int32_t countElementUnits(int32_t start, int32_t limit, int32_t unitIndex) const = 0;\n    /** @internal */\n    virtual int32_t skipElementsBySomeUnits(int32_t i, int32_t unitIndex, int32_t count) const = 0;\n    /** @internal */\n    virtual int32_t indexOfElementWithNextUnit(int32_t i, int32_t unitIndex, UChar unit) const = 0;\n\n    /** @internal */\n    virtual UBool matchNodesCanHaveValues() const = 0;\n\n    /** @internal */\n    virtual int32_t getMaxBranchLinearSubNodeLength() const = 0;\n    /** @internal */\n    virtual int32_t getMinLinearMatch() const = 0;\n    /** @internal */\n    virtual int32_t getMaxLinearMatchLength() const = 0;\n\n#ifndef U_HIDE_INTERNAL_API\n    // max(BytesTrie::kMaxBranchLinearSubNodeLength, UCharsTrie::kMaxBranchLinearSubNodeLength).\n    /** @internal */\n    static const int32_t kMaxBranchLinearSubNodeLength=5;\n\n    // Maximum number of nested split-branch levels for a branch on all 2^16 possible UChar units.\n    // log2(2^16/kMaxBranchLinearSubNodeLength) rounded up.\n    /** @internal */\n    static const int32_t kMaxSplitBranchLevels=14;\n\n    /**\n     * Makes sure that there is only one unique node registered that is\n     * equivalent to newNode.\n     * @param newNode Input node. The builder takes ownership.\n     * @param errorCode ICU in/out UErrorCode.\n                        Set to U_MEMORY_ALLOCATION_ERROR if it was success but newNode==NULL.\n     * @return newNode if it is the first of its kind, or\n     *         an equivalent node if newNode is a duplicate.\n     * @internal\n     */\n    Node *registerNode(Node *newNode, UErrorCode &errorCode);\n    /**\n     * Makes sure that there is only one unique FinalValueNode registered\n     * with this value.\n     * Avoids creating a node if the value is a duplicate.\n     * @param value A final value.\n     * @param errorCode ICU in/out UErrorCode.\n                        Set to U_MEMORY_ALLOCATION_ERROR if it was success but newNode==NULL.\n     * @return A FinalValueNode with the given value.\n     * @internal\n     */\n    Node *registerFinalValue(int32_t value, UErrorCode &errorCode);\n\n    /*\n     * C++ note:\n     * registerNode() and registerFinalValue() take ownership of their input nodes,\n     * and only return owned nodes.\n     * If they see a failure UErrorCode, they will delete the input node.\n     * If they get a NULL pointer, they will record a U_MEMORY_ALLOCATION_ERROR.\n     * If there is a failure, they return NULL.\n     *\n     * NULL Node pointers can be safely passed into other Nodes because\n     * they call the static Node::hashCode() which checks for a NULL pointer first.\n     *\n     * Therefore, as long as builder functions register a new node,\n     * they need to check for failures only before explicitly dereferencing\n     * a Node pointer, or before setting a new UErrorCode.\n     */\n\n    // Hash set of nodes, maps from nodes to integer 1.\n    /** @internal */\n    UHashtable *nodes;\n\n    /** @internal */\n    class Node : public UObject {\n    public:\n        Node(int32_t initialHash) : hash(initialHash), offset(0) {}\n        inline int32_t hashCode() const { return hash; }\n        // Handles node==NULL.\n        static inline int32_t hashCode(const Node *node) { return node==NULL ? 0 : node->hashCode(); }\n        // Base class operator==() compares the actual class types.\n        virtual UBool operator==(const Node &other) const;\n        inline UBool operator!=(const Node &other) const { return !operator==(other); }\n        /**\n         * Traverses the Node graph and numbers branch edges, with rightmost edges first.\n         * This is to avoid writing a duplicate node twice.\n         *\n         * Branch nodes in this trie data structure are not symmetric.\n         * Most branch edges \"jump\" to other nodes but the rightmost branch edges\n         * just continue without a jump.\n         * Therefore, write() must write the rightmost branch edge last\n         * (trie units are written backwards), and must write it at that point even if\n         * it is a duplicate of a node previously written elsewhere.\n         *\n         * This function visits and marks right branch edges first.\n         * Edges are numbered with increasingly negative values because we share the\n         * offset field which gets positive values when nodes are written.\n         * A branch edge also remembers the first number for any of its edges.\n         *\n         * When a further-left branch edge has a number in the range of the rightmost\n         * edge's numbers, then it will be written as part of the required right edge\n         * and we can avoid writing it first.\n         *\n         * After root.markRightEdgesFirst(-1) the offsets of all nodes are negative\n         * edge numbers.\n         *\n         * @param edgeNumber The first edge number for this node and its sub-nodes.\n         * @return An edge number that is at least the maximum-negative\n         *         of the input edge number and the numbers of this node and all of its sub-nodes.\n         */\n        virtual int32_t markRightEdgesFirst(int32_t edgeNumber);\n        // write() must set the offset to a positive value.\n        virtual void write(StringTrieBuilder &builder) = 0;\n        // See markRightEdgesFirst.\n        inline void writeUnlessInsideRightEdge(int32_t firstRight, int32_t lastRight,\n                                               StringTrieBuilder &builder) {\n            // Note: Edge numbers are negative, lastRight<=firstRight.\n            // If offset>0 then this node and its sub-nodes have been written already\n            // and we need not write them again.\n            // If this node is part of the unwritten right branch edge,\n            // then we wait until that is written.\n            if(offset<0 && (offset<lastRight || firstRight<offset)) {\n                write(builder);\n            }\n        }\n        inline int32_t getOffset() const { return offset; }\n    protected:\n        int32_t hash;\n        int32_t offset;\n    private:\n        // No ICU \"poor man's RTTI\" for this class nor its subclasses.\n        virtual UClassID getDynamicClassID() const;\n    };\n\n    // This class should not be overridden because\n    // registerFinalValue() compares a stack-allocated FinalValueNode\n    // (stack-allocated so that we don't unnecessarily create lots of duplicate nodes)\n    // with the input node, and the\n    // !Node::operator==(other) used inside FinalValueNode::operator==(other)\n    // will be false if the typeid's are different.\n    /** @internal */\n    class FinalValueNode : public Node {\n    public:\n        FinalValueNode(int32_t v) : Node(0x111111*37+v), value(v) {}\n        virtual UBool operator==(const Node &other) const;\n        virtual void write(StringTrieBuilder &builder);\n    protected:\n        int32_t value;\n    };\n\n    /**\n     * @internal \n     */\n    class ValueNode : public Node {\n    public:\n        ValueNode(int32_t initialHash) : Node(initialHash), hasValue(FALSE), value(0) {}\n        virtual UBool operator==(const Node &other) const;\n        void setValue(int32_t v) {\n            hasValue=TRUE;\n            value=v;\n            hash=hash*37+v;\n        }\n    protected:\n        UBool hasValue;\n        int32_t value;\n    };\n\n    /** \n     * @internal \n     */\n    class IntermediateValueNode : public ValueNode {\n    public:\n        IntermediateValueNode(int32_t v, Node *nextNode)\n                : ValueNode(0x222222*37+hashCode(nextNode)), next(nextNode) { setValue(v); }\n        virtual UBool operator==(const Node &other) const;\n        virtual int32_t markRightEdgesFirst(int32_t edgeNumber);\n        virtual void write(StringTrieBuilder &builder);\n    protected:\n        Node *next;\n    };\n\n    /**\n     * @internal \n     */\n    class LinearMatchNode : public ValueNode {\n    public:\n        LinearMatchNode(int32_t len, Node *nextNode)\n                : ValueNode((0x333333*37+len)*37+hashCode(nextNode)),\n                  length(len), next(nextNode) {}\n        virtual UBool operator==(const Node &other) const;\n        virtual int32_t markRightEdgesFirst(int32_t edgeNumber);\n    protected:\n        int32_t length;\n        Node *next;\n    };\n\n    /**\n     * @internal \n     */\n    class BranchNode : public Node {\n    public:\n        BranchNode(int32_t initialHash) : Node(initialHash) {}\n    protected:\n        int32_t firstEdgeNumber;\n    };\n\n    /**\n     * @internal \n     */\n    class ListBranchNode : public BranchNode {\n    public:\n        ListBranchNode() : BranchNode(0x444444), length(0) {}\n        virtual UBool operator==(const Node &other) const;\n        virtual int32_t markRightEdgesFirst(int32_t edgeNumber);\n        virtual void write(StringTrieBuilder &builder);\n        // Adds a unit with a final value.\n        void add(int32_t c, int32_t value) {\n            units[length]=(UChar)c;\n            equal[length]=NULL;\n            values[length]=value;\n            ++length;\n            hash=(hash*37+c)*37+value;\n        }\n        // Adds a unit which leads to another match node.\n        void add(int32_t c, Node *node) {\n            units[length]=(UChar)c;\n            equal[length]=node;\n            values[length]=0;\n            ++length;\n            hash=(hash*37+c)*37+hashCode(node);\n        }\n    protected:\n        Node *equal[kMaxBranchLinearSubNodeLength];  // NULL means \"has final value\".\n        int32_t length;\n        int32_t values[kMaxBranchLinearSubNodeLength];\n        UChar units[kMaxBranchLinearSubNodeLength];\n    };\n\n    /**\n     * @internal \n     */\n    class SplitBranchNode : public BranchNode {\n    public:\n        SplitBranchNode(UChar middleUnit, Node *lessThanNode, Node *greaterOrEqualNode)\n                : BranchNode(((0x555555*37+middleUnit)*37+\n                              hashCode(lessThanNode))*37+hashCode(greaterOrEqualNode)),\n                  unit(middleUnit), lessThan(lessThanNode), greaterOrEqual(greaterOrEqualNode) {}\n        virtual UBool operator==(const Node &other) const;\n        virtual int32_t markRightEdgesFirst(int32_t edgeNumber);\n        virtual void write(StringTrieBuilder &builder);\n    protected:\n        UChar unit;\n        Node *lessThan;\n        Node *greaterOrEqual;\n    };\n\n    // Branch head node, for writing the actual node lead unit.\n    /** @internal */\n    class BranchHeadNode : public ValueNode {\n    public:\n        BranchHeadNode(int32_t len, Node *subNode)\n                : ValueNode((0x666666*37+len)*37+hashCode(subNode)),\n                  length(len), next(subNode) {}\n        virtual UBool operator==(const Node &other) const;\n        virtual int32_t markRightEdgesFirst(int32_t edgeNumber);\n        virtual void write(StringTrieBuilder &builder);\n    protected:\n        int32_t length;\n        Node *next;  // A branch sub-node.\n    };\n#endif  /* U_HIDE_INTERNAL_API */\n\n    /** @internal */\n    virtual Node *createLinearMatchNode(int32_t i, int32_t unitIndex, int32_t length,\n                                        Node *nextNode) const = 0;\n\n    /** @internal */\n    virtual int32_t write(int32_t unit) = 0;\n    /** @internal */\n    virtual int32_t writeElementUnits(int32_t i, int32_t unitIndex, int32_t length) = 0;\n    /** @internal */\n    virtual int32_t writeValueAndFinal(int32_t i, UBool isFinal) = 0;\n    /** @internal */\n    virtual int32_t writeValueAndType(UBool hasValue, int32_t value, int32_t node) = 0;\n    /** @internal */\n    virtual int32_t writeDeltaTo(int32_t jumpTarget) = 0;\n\nprivate:\n    // No ICU \"poor man's RTTI\" for this class nor its subclasses.\n    virtual UClassID getDynamicClassID() const;\n};\n\nU_NAMESPACE_END\n\n#endif  // __STRINGTRIEBUILDER_H__\n"
  },
  {
    "path": "deprecated/android/addons/icucompat/unicode/stsearch.h",
    "content": "/*\n**********************************************************************\n*   Copyright (C) 2001-2008 IBM and others. All rights reserved.\n**********************************************************************\n*   Date        Name        Description\n*  03/22/2000   helena      Creation.\n**********************************************************************\n*/\n\n#ifndef STSEARCH_H\n#define STSEARCH_H\n\n#include \"unicode/utypes.h\"\n\n/**\n * \\file \n * \\brief C++ API: Service for searching text based on RuleBasedCollator.\n */\n \n#if !UCONFIG_NO_COLLATION && !UCONFIG_NO_BREAK_ITERATION\n\n#include \"unicode/tblcoll.h\"\n#include \"unicode/coleitr.h\"\n#include \"unicode/search.h\"\n\nU_NAMESPACE_BEGIN\n\n/** \n *\n * <tt>StringSearch</tt> is a <tt>SearchIterator</tt> that provides\n * language-sensitive text searching based on the comparison rules defined\n * in a {@link RuleBasedCollator} object.\n * StringSearch ensures that language eccentricity can be \n * handled, e.g. for the German collator, characters &szlig; and SS will be matched \n * if case is chosen to be ignored.\n * See the <a href=\"http://source.icu-project.org/repos/icu/icuhtml/trunk/design/collation/ICU_collation_design.htm\">\n * \"ICU Collation Design Document\"</a> for more information.\n * <p> \n * The algorithm implemented is a modified form of the Boyer Moore's search.\n * For more information  see \n * <a href=\"http://icu-project.org/docs/papers/efficient_text_searching_in_java.html\">\n * \"Efficient Text Searching in Java\"</a>, published in <i>Java Report</i> \n * in February, 1999, for further information on the algorithm.\n * <p>\n * There are 2 match options for selection:<br>\n * Let S' be the sub-string of a text string S between the offsets start and \n * end <start, end>.\n * <br>\n * A pattern string P matches a text string S at the offsets <start, end> \n * if\n * <pre> \n * option 1. Some canonical equivalent of P matches some canonical equivalent \n *           of S'\n * option 2. P matches S' and if P starts or ends with a combining mark, \n *           there exists no non-ignorable combining mark before or after S? \n *           in S respectively. \n * </pre>\n * Option 2. will be the default.\n * <p>\n * This search has APIs similar to that of other text iteration mechanisms \n * such as the break iterators in <tt>BreakIterator</tt>. Using these \n * APIs, it is easy to scan through text looking for all occurances of \n * a given pattern. This search iterator allows changing of direction by \n * calling a <tt>reset</tt> followed by a <tt>next</tt> or <tt>previous</tt>. \n * Though a direction change can occur without calling <tt>reset</tt> first,  \n * this operation comes with some speed penalty.\n * Match results in the forward direction will match the result matches in \n * the backwards direction in the reverse order\n * <p>\n * <tt>SearchIterator</tt> provides APIs to specify the starting position \n * within the text string to be searched, e.g. <tt>setOffset</tt>,\n * <tt>preceding</tt> and <tt>following</tt>. Since the \n * starting position will be set as it is specified, please take note that \n * there are some danger points which the search may render incorrect \n * results:\n * <ul>\n * <li> The midst of a substring that requires normalization.\n * <li> If the following match is to be found, the position should not be the\n *      second character which requires to be swapped with the preceding \n *      character. Vice versa, if the preceding match is to be found, \n *      position to search from should not be the first character which \n *      requires to be swapped with the next character. E.g certain Thai and\n *      Lao characters require swapping.\n * <li> If a following pattern match is to be found, any position within a \n *      contracting sequence except the first will fail. Vice versa if a \n *      preceding pattern match is to be found, a invalid starting point \n *      would be any character within a contracting sequence except the last.\n * </ul>\n * <p>\n * A breakiterator can be used if only matches at logical breaks are desired.\n * Using a breakiterator will only give you results that exactly matches the\n * boundaries given by the breakiterator. For instance the pattern \"e\" will\n * not be found in the string \"\\u00e9\" if a character break iterator is used.\n * <p>\n * Options are provided to handle overlapping matches. \n * E.g. In English, overlapping matches produces the result 0 and 2 \n * for the pattern \"abab\" in the text \"ababab\", where else mutually \n * exclusive matches only produce the result of 0.\n * <p>\n * Though collator attributes will be taken into consideration while \n * performing matches, there are no APIs here for setting and getting the \n * attributes. These attributes can be set by getting the collator\n * from <tt>getCollator</tt> and using the APIs in <tt>coll.h</tt>.\n * Lastly to update StringSearch to the new collator attributes, \n * reset() has to be called.\n * <p> \n * Restriction: <br>\n * Currently there are no composite characters that consists of a\n * character with combining class > 0 before a character with combining \n * class == 0. However, if such a character exists in the future,  \n * StringSearch does not guarantee the results for option 1.\n * <p>\n * Consult the <tt>SearchIterator</tt> documentation for information on\n * and examples of how to use instances of this class to implement text\n * searching.\n * <pre><code>\n * UnicodeString target(\"The quick brown fox jumps over the lazy dog.\");\n * UnicodeString pattern(\"fox\");\n *\n * UErrorCode      error = U_ZERO_ERROR;\n * StringSearch iter(pattern, target, Locale::getUS(), NULL, status);\n * for (int pos = iter.first(error);\n *      pos != USEARCH_DONE; \n *      pos = iter.next(error))\n * {\n *     printf(\"Found match at %d pos, length is %d\\n\", pos, \n *                                             iter.getMatchLength());\n * }\n * </code></pre>\n * <p>\n * Note, StringSearch is not to be subclassed.\n * </p>\n * @see SearchIterator\n * @see RuleBasedCollator\n * @since ICU 2.0\n */\n\nclass U_I18N_API StringSearch : public SearchIterator\n{\npublic:\n\n    // public constructors and destructors --------------------------------\n\n    /**\n     * Creating a <tt>StringSearch</tt> instance using the argument locale \n     * language rule set. A collator will be created in the process, which \n     * will be owned by this instance and will be deleted during \n     * destruction\n     * @param pattern The text for which this object will search.\n     * @param text    The text in which to search for the pattern.\n     * @param locale  A locale which defines the language-sensitive \n     *                comparison rules used to determine whether text in the \n     *                pattern and target matches. \n     * @param breakiter A <tt>BreakIterator</tt> object used to constrain \n     *                the matches that are found. Matches whose start and end \n     *                indices in the target text are not boundaries as \n     *                determined by the <tt>BreakIterator</tt> are \n     *                ignored. If this behavior is not desired, \n     *                <tt>NULL</tt> can be passed in instead.\n     * @param status  for errors if any. If pattern or text is NULL, or if\n     *               either the length of pattern or text is 0 then an \n     *               U_ILLEGAL_ARGUMENT_ERROR is returned.\n     * @stable ICU 2.0\n     */\n    StringSearch(const UnicodeString &pattern, const UnicodeString &text,\n                 const Locale        &locale,       \n                       BreakIterator *breakiter,\n                       UErrorCode    &status);\n\n    /**\n     * Creating a <tt>StringSearch</tt> instance using the argument collator \n     * language rule set. Note, user retains the ownership of this collator, \n     * it does not get destroyed during this instance's destruction.\n     * @param pattern The text for which this object will search.\n     * @param text    The text in which to search for the pattern.\n     * @param coll    A <tt>RuleBasedCollator</tt> object which defines \n     *                the language-sensitive comparison rules used to \n     *                determine whether text in the pattern and target \n     *                matches. User is responsible for the clearing of this\n     *                object.\n     * @param breakiter A <tt>BreakIterator</tt> object used to constrain \n     *                the matches that are found. Matches whose start and end \n     *                indices in the target text are not boundaries as \n     *                determined by the <tt>BreakIterator</tt> are \n     *                ignored. If this behavior is not desired, \n     *                <tt>NULL</tt> can be passed in instead.\n     * @param status for errors if any. If either the length of pattern or \n     *               text is 0 then an U_ILLEGAL_ARGUMENT_ERROR is returned.\n     * @stable ICU 2.0\n     */\n    StringSearch(const UnicodeString     &pattern, \n                 const UnicodeString     &text,\n                       RuleBasedCollator *coll,       \n                       BreakIterator     *breakiter,\n                       UErrorCode        &status);\n\n    /**\n     * Creating a <tt>StringSearch</tt> instance using the argument locale \n     * language rule set. A collator will be created in the process, which \n     * will be owned by this instance and will be deleted during \n     * destruction\n     * <p>\n     * Note: No parsing of the text within the <tt>CharacterIterator</tt> \n     * will be done during searching for this version. The block of text \n     * in <tt>CharacterIterator</tt> will be used as it is.\n     * @param pattern The text for which this object will search.\n     * @param text    The text iterator in which to search for the pattern.\n     * @param locale  A locale which defines the language-sensitive \n     *                comparison rules used to determine whether text in the \n     *                pattern and target matches. User is responsible for \n     *                the clearing of this object.\n     * @param breakiter A <tt>BreakIterator</tt> object used to constrain \n     *                the matches that are found. Matches whose start and end \n     *                indices in the target text are not boundaries as \n     *                determined by the <tt>BreakIterator</tt> are \n     *                ignored. If this behavior is not desired, \n     *                <tt>NULL</tt> can be passed in instead.\n     * @param status for errors if any. If either the length of pattern or \n     *               text is 0 then an U_ILLEGAL_ARGUMENT_ERROR is returned.\n     * @stable ICU 2.0\n     */\n    StringSearch(const UnicodeString &pattern, CharacterIterator &text,\n                 const Locale        &locale, \n                       BreakIterator *breakiter,\n                       UErrorCode    &status);\n\n    /**\n     * Creating a <tt>StringSearch</tt> instance using the argument collator \n     * language rule set. Note, user retains the ownership of this collator, \n     * it does not get destroyed during this instance's destruction.\n     * <p>\n     * Note: No parsing of the text within the <tt>CharacterIterator</tt> \n     * will be done during searching for this version. The block of text \n     * in <tt>CharacterIterator</tt> will be used as it is.\n     * @param pattern The text for which this object will search.\n     * @param text    The text in which to search for the pattern.\n     * @param coll    A <tt>RuleBasedCollator</tt> object which defines \n     *                the language-sensitive comparison rules used to \n     *                determine whether text in the pattern and target \n     *                matches. User is responsible for the clearing of this\n     *                object.\n     * @param breakiter A <tt>BreakIterator</tt> object used to constrain \n     *                the matches that are found. Matches whose start and end \n     *                indices in the target text are not boundaries as \n     *                determined by the <tt>BreakIterator</tt> are \n     *                ignored. If this behavior is not desired, \n     *                <tt>NULL</tt> can be passed in instead.\n     * @param status for errors if any. If either the length of pattern or \n     *               text is 0 then an U_ILLEGAL_ARGUMENT_ERROR is returned.\n     * @stable ICU 2.0\n     */\n    StringSearch(const UnicodeString     &pattern, CharacterIterator &text,\n                       RuleBasedCollator *coll, \n                       BreakIterator     *breakiter,\n                       UErrorCode        &status);\n\n    /**\n     * Copy constructor that creates a StringSearch instance with the same \n     * behavior, and iterating over the same text.\n     * @param that StringSearch instance to be copied.\n     * @stable ICU 2.0\n     */\n    StringSearch(const StringSearch &that);\n\n    /**\n    * Destructor. Cleans up the search iterator data struct.\n    * If a collator is created in the constructor, it will be destroyed here.\n    * @stable ICU 2.0\n    */\n    virtual ~StringSearch(void);\n\n    /**\n     * Clone this object.\n     * Clones can be used concurrently in multiple threads.\n     * If an error occurs, then NULL is returned.\n     * The caller must delete the clone.\n     *\n     * @return a clone of this object\n     *\n     * @see getDynamicClassID\n     * @stable ICU 2.8\n     */\n    StringSearch *clone() const;\n\n    // operator overloading ---------------------------------------------\n\n    /**\n     * Assignment operator. Sets this iterator to have the same behavior,\n     * and iterate over the same text, as the one passed in.\n     * @param that instance to be copied.\n     * @stable ICU 2.0\n     */\n    StringSearch & operator=(const StringSearch &that);\n\n    /**\n     * Equality operator. \n     * @param that instance to be compared.\n     * @return TRUE if both instances have the same attributes, \n     *         breakiterators, collators and iterate over the same text \n     *         while looking for the same pattern.\n     * @stable ICU 2.0\n     */\n    virtual UBool operator==(const SearchIterator &that) const;\n\n    // public get and set methods ----------------------------------------\n\n    /**\n     * Sets the index to point to the given position, and clears any state \n     * that's affected.\n     * <p>\n     * This method takes the argument index and sets the position in the text \n     * string accordingly without checking if the index is pointing to a \n     * valid starting point to begin searching. \n     * @param position within the text to be set. If position is less\n     *          than or greater than the text range for searching, \n     *          an U_INDEX_OUTOFBOUNDS_ERROR will be returned\n     * @param status for errors if it occurs\n     * @stable ICU 2.0\n     */\n    virtual void setOffset(int32_t position, UErrorCode &status);\n\n    /**\n     * Return the current index in the text being searched.\n     * If the iteration has gone past the end of the text\n     * (or past the beginning for a backwards search), USEARCH_DONE\n     * is returned.\n     * @return current index in the text being searched.\n     * @stable ICU 2.0\n     */\n    virtual int32_t getOffset(void) const;\n\n    /**\n     * Set the target text to be searched.\n     * Text iteration will hence begin at the start of the text string. \n     * This method is \n     * useful if you want to re-use an iterator to search for the same \n     * pattern within a different body of text.\n     * @param text text string to be searched\n     * @param status for errors if any. If the text length is 0 then an \n     *        U_ILLEGAL_ARGUMENT_ERROR is returned.\n     * @stable ICU 2.0\n     */\n    virtual void setText(const UnicodeString &text, UErrorCode &status);\n    \n    /**\n     * Set the target text to be searched.\n     * Text iteration will hence begin at the start of the text string. \n     * This method is \n     * useful if you want to re-use an iterator to search for the same \n     * pattern within a different body of text.\n     * Note: No parsing of the text within the <tt>CharacterIterator</tt> \n     * will be done during searching for this version. The block of text \n     * in <tt>CharacterIterator</tt> will be used as it is.\n     * @param text text string to be searched\n     * @param status for errors if any. If the text length is 0 then an \n     *        U_ILLEGAL_ARGUMENT_ERROR is returned.\n     * @stable ICU 2.0\n     */\n    virtual void setText(CharacterIterator &text, UErrorCode &status);\n\n    /**\n     * Gets the collator used for the language rules.\n     * <p>\n     * Caller may modify but <b>must not</b> delete the <tt>RuleBasedCollator</tt>!\n     * Modifications to this collator will affect the original collator passed in to \n     * the <tt>StringSearch></tt> constructor or to setCollator, if any.\n     * @return collator used for string search\n     * @stable ICU 2.0\n     */\n    RuleBasedCollator * getCollator() const;\n    \n    /**\n     * Sets the collator used for the language rules. User retains the \n     * ownership of this collator, thus the responsibility of deletion lies \n     * with the user. This method causes internal data such as Boyer-Moore \n     * shift tables to be recalculated, but the iterator's position is \n     * unchanged.\n     * @param coll    collator \n     * @param status  for errors if any\n     * @stable ICU 2.0\n     */\n    void setCollator(RuleBasedCollator *coll, UErrorCode &status);\n    \n    /**\n     * Sets the pattern used for matching.\n     * Internal data like the Boyer Moore table will be recalculated, but \n     * the iterator's position is unchanged.\n     * @param pattern search pattern to be found\n     * @param status for errors if any. If the pattern length is 0 then an \n     *               U_ILLEGAL_ARGUMENT_ERROR is returned.\n     * @stable ICU 2.0\n     */\n    void setPattern(const UnicodeString &pattern, UErrorCode &status);\n    \n    /**\n     * Gets the search pattern.\n     * @return pattern used for matching\n     * @stable ICU 2.0\n     */\n    const UnicodeString & getPattern() const;\n\n    // public methods ----------------------------------------------------\n\n    /** \n     * Reset the iteration.\n     * Search will begin at the start of the text string if a forward \n     * iteration is initiated before a backwards iteration. Otherwise if \n     * a backwards iteration is initiated before a forwards iteration, the \n     * search will begin at the end of the text string.\n     * @stable ICU 2.0\n     */\n    virtual void reset();\n\n    /**\n     * Returns a copy of StringSearch with the same behavior, and \n     * iterating over the same text, as this one. Note that all data will be\n     * replicated, except for the user-specified collator and the\n     * breakiterator.\n     * @return cloned object\n     * @stable ICU 2.0\n     */\n    virtual SearchIterator * safeClone(void) const;\n    \n    /**\n     * ICU \"poor man's RTTI\", returns a UClassID for the actual class.\n     *\n     * @stable ICU 2.2\n     */\n    virtual UClassID getDynamicClassID() const;\n\n    /**\n     * ICU \"poor man's RTTI\", returns a UClassID for this class.\n     *\n     * @stable ICU 2.2\n     */\n    static UClassID U_EXPORT2 getStaticClassID();\n\nprotected:\n\n    // protected method -------------------------------------------------\n\n    /**\n     * Search forward for matching text, starting at a given location.\n     * Clients should not call this method directly; instead they should \n     * call {@link SearchIterator#next }.\n     * <p>\n     * If a match is found, this method returns the index at which the match\n     * starts and calls {@link SearchIterator#setMatchLength } with the number \n     * of characters in the target text that make up the match. If no match \n     * is found, the method returns <tt>USEARCH_DONE</tt>.\n     * <p>\n     * The <tt>StringSearch</tt> is adjusted so that its current index \n     * (as returned by {@link #getOffset }) is the match position if one was \n     * found.\n     * If a match is not found, <tt>USEARCH_DONE</tt> will be returned and\n     * the <tt>StringSearch</tt> will be adjusted to the index USEARCH_DONE.\n     * @param position The index in the target text at which the search \n     *                 starts\n     * @param status for errors if any occurs\n     * @return The index at which the matched text in the target starts, or \n     *         USEARCH_DONE if no match was found.\n     * @stable ICU 2.0\n     */\n    virtual int32_t handleNext(int32_t position, UErrorCode &status);\n\n    /**\n     * Search backward for matching text, starting at a given location.\n     * Clients should not call this method directly; instead they should call\n     * <tt>SearchIterator.previous()</tt>, which this method overrides.\n     * <p>\n     * If a match is found, this method returns the index at which the match\n     * starts and calls {@link SearchIterator#setMatchLength } with the number \n     * of characters in the target text that make up the match. If no match \n     * is found, the method returns <tt>USEARCH_DONE</tt>.\n     * <p>\n     * The <tt>StringSearch</tt> is adjusted so that its current index \n     * (as returned by {@link #getOffset }) is the match position if one was \n     * found.\n     * If a match is not found, <tt>USEARCH_DONE</tt> will be returned and\n     * the <tt>StringSearch</tt> will be adjusted to the index USEARCH_DONE.\n     * @param position The index in the target text at which the search \n     *                 starts.\n     * @param status for errors if any occurs\n     * @return The index at which the matched text in the target starts, or \n     *         USEARCH_DONE if no match was found.\n     * @stable ICU 2.0\n     */\n    virtual int32_t handlePrev(int32_t position, UErrorCode &status);\n    \nprivate :\n    StringSearch(); // default constructor not implemented\n\n    // private data members ----------------------------------------------\n\n    /**\n    * RuleBasedCollator, contains exactly the same UCollator * in m_strsrch_\n    * @stable ICU 2.0\n    */\n    RuleBasedCollator  m_collator_;\n    /**\n    * Pattern text\n    * @stable ICU 2.0\n    */\n    UnicodeString      m_pattern_;\n    /**\n    * String search struct data\n    * @stable ICU 2.0\n    */\n    UStringSearch     *m_strsrch_;\n\n};\n\nU_NAMESPACE_END\n\n#endif /* #if !UCONFIG_NO_COLLATION */\n\n#endif\n\n"
  },
  {
    "path": "deprecated/android/addons/icucompat/unicode/symtable.h",
    "content": "/*\n**********************************************************************\n*   Copyright (c) 2000-2005, International Business Machines\n*   Corporation and others.  All Rights Reserved.\n**********************************************************************\n*   Date        Name        Description\n*   02/04/00    aliu        Creation.\n**********************************************************************\n*/\n#ifndef SYMTABLE_H\n#define SYMTABLE_H\n\n#include \"unicode/utypes.h\"\n#include \"unicode/uobject.h\"\n\n/**\n * \\file \n * \\brief C++ API: An interface that defines both lookup protocol and parsing of\n * symbolic names.\n */\n \nU_NAMESPACE_BEGIN\n\nclass ParsePosition;\nclass UnicodeFunctor;\nclass UnicodeSet;\nclass UnicodeString;\n\n/**\n * An interface that defines both lookup protocol and parsing of\n * symbolic names.\n *\n * <p>A symbol table maintains two kinds of mappings.  The first is\n * between symbolic names and their values.  For example, if the\n * variable with the name \"start\" is set to the value \"alpha\"\n * (perhaps, though not necessarily, through an expression such as\n * \"$start=alpha\"), then the call lookup(\"start\") will return the\n * char[] array ['a', 'l', 'p', 'h', 'a'].\n *\n * <p>The second kind of mapping is between character values and\n * UnicodeMatcher objects.  This is used by RuleBasedTransliterator,\n * which uses characters in the private use area to represent objects\n * such as UnicodeSets.  If U+E015 is mapped to the UnicodeSet [a-z],\n * then lookupMatcher(0xE015) will return the UnicodeSet [a-z].\n *\n * <p>Finally, a symbol table defines parsing behavior for symbolic\n * names.  All symbolic names start with the SYMBOL_REF character.\n * When a parser encounters this character, it calls parseReference()\n * with the position immediately following the SYMBOL_REF.  The symbol\n * table parses the name, if there is one, and returns it.\n *\n * @stable ICU 2.8\n */\nclass U_COMMON_API SymbolTable /* not : public UObject because this is an interface/mixin class */ {\npublic:\n\n    /**\n     * The character preceding a symbol reference name.\n     * @stable ICU 2.8\n     */\n    enum { SYMBOL_REF = 0x0024 /*$*/ };\n\n    /**\n     * Destructor.\n     * @stable ICU 2.8\n     */\n    virtual ~SymbolTable();\n\n    /**\n     * Lookup the characters associated with this string and return it.\n     * Return <tt>NULL</tt> if no such name exists.  The resultant\n     * string may have length zero.\n     * @param s the symbolic name to lookup\n     * @return a string containing the name's value, or <tt>NULL</tt> if\n     * there is no mapping for s.\n     * @stable ICU 2.8\n     */\n    virtual const UnicodeString* lookup(const UnicodeString& s) const = 0;\n\n    /**\n     * Lookup the UnicodeMatcher associated with the given character, and\n     * return it.  Return <tt>NULL</tt> if not found.\n     * @param ch a 32-bit code point from 0 to 0x10FFFF inclusive.\n     * @return the UnicodeMatcher object represented by the given\n     * character, or NULL if there is no mapping for ch.\n     * @stable ICU 2.8\n     */\n    virtual const UnicodeFunctor* lookupMatcher(UChar32 ch) const = 0;\n\n    /**\n     * Parse a symbol reference name from the given string, starting\n     * at the given position.  If no valid symbol reference name is\n     * found, return the empty string and leave pos unchanged.  That is, if the\n     * character at pos cannot start a name, or if pos is at or after\n     * text.length(), then return an empty string.  This indicates an\n     * isolated SYMBOL_REF character.\n     * @param text the text to parse for the name\n     * @param pos on entry, the index of the first character to parse.\n     * This is the character following the SYMBOL_REF character.  On\n     * exit, the index after the last parsed character.  If the parse\n     * failed, pos is unchanged on exit.\n     * @param limit the index after the last character to be parsed.\n     * @return the parsed name, or an empty string if there is no\n     * valid symbolic name at the given position.\n     * @stable ICU 2.8\n     */\n    virtual UnicodeString parseReference(const UnicodeString& text,\n                                         ParsePosition& pos, int32_t limit) const = 0;\n};\nU_NAMESPACE_END\n\n#endif\n"
  },
  {
    "path": "deprecated/android/addons/icucompat/unicode/tblcoll.h",
    "content": "/*\n******************************************************************************\n* Copyright (C) 1996-2012, International Business Machines Corporation and\n* others. All Rights Reserved.\n******************************************************************************\n*/\n\n/**\n * \\file \n * \\brief C++ API: RuleBasedCollator class provides the simple implementation of Collator.\n */\n\n/**\n* File tblcoll.h\n*\n* Created by: Helena Shih\n*\n* Modification History:\n*\n*  Date        Name        Description\n*  2/5/97      aliu        Added streamIn and streamOut methods.  Added\n*                          constructor which reads RuleBasedCollator object from\n*                          a binary file.  Added writeToFile method which streams\n*                          RuleBasedCollator out to a binary file.  The streamIn\n*                          and streamOut methods use istream and ostream objects\n*                          in binary mode.\n*  2/12/97     aliu        Modified to use TableCollationData sub-object to\n*                          hold invariant data.\n*  2/13/97     aliu        Moved several methods into this class from Collation.\n*                          Added a private RuleBasedCollator(Locale&) constructor,\n*                          to be used by Collator::createDefault().  General\n*                          clean up.\n*  2/20/97     helena      Added clone, operator==, operator!=, operator=, and copy\n*                          constructor and getDynamicClassID.\n*  3/5/97      aliu        Modified constructFromFile() to add parameter\n*                          specifying whether or not binary loading is to be\n*                          attempted.  This is required for dynamic rule loading.\n* 05/07/97     helena      Added memory allocation error detection.\n*  6/17/97     helena      Added IDENTICAL strength for compare, changed getRules to\n*                          use MergeCollation::getPattern.\n*  6/20/97     helena      Java class name change.\n*  8/18/97     helena      Added internal API documentation.\n* 09/03/97     helena      Added createCollationKeyValues().\n* 02/10/98     damiba      Added compare with \"length\" parameter\n* 08/05/98     erm         Synched with 1.2 version of RuleBasedCollator.java\n* 04/23/99     stephen     Removed EDecompositionMode, merged with\n*                          Normalizer::EMode\n* 06/14/99     stephen     Removed kResourceBundleSuffix\n* 11/02/99     helena      Collator performance enhancements.  Eliminates the\n*                          UnicodeString construction and special case for NO_OP.\n* 11/23/99     srl         More performance enhancements. Updates to NormalizerIterator\n*                          internal state management.\n* 12/15/99     aliu        Update to support Thai collation.  Move NormalizerIterator\n*                          to implementation file.\n* 01/29/01     synwee      Modified into a C++ wrapper which calls C API\n*                          (ucol.h)\n*/\n\n#ifndef TBLCOLL_H\n#define TBLCOLL_H\n\n#include \"unicode/utypes.h\"\n\n \n#if !UCONFIG_NO_COLLATION\n\n#include \"unicode/coll.h\"\n#include \"unicode/ucol.h\"\n#include \"unicode/sortkey.h\"\n#include \"unicode/normlzr.h\"\n\nU_NAMESPACE_BEGIN\n\n/**\n* @stable ICU 2.0\n*/\nclass StringSearch;\n/**\n* @stable ICU 2.0\n*/\nclass CollationElementIterator;\n\n/**\n * The RuleBasedCollator class provides the simple implementation of\n * Collator, using data-driven tables. The user can create a customized\n * table-based collation.\n * <P>\n * <em>Important: </em>The ICU collation service has been reimplemented \n * in order to achieve better performance and UCA compliance. \n * For details, see the \n * <a href=\"http://source.icu-project.org/repos/icu/icuhtml/trunk/design/collation/ICU_collation_design.htm\">\n * collation design document</a>.\n * <p>\n * RuleBasedCollator is a thin C++ wrapper over the C implementation.\n * <p>\n * For more information about the collation service see \n * <a href=\"http://icu-project.org/userguide/Collate_Intro.html\">the users guide</a>.\n * <p>\n * Collation service provides correct sorting orders for most locales supported in ICU. \n * If specific data for a locale is not available, the orders eventually falls back\n * to the <a href=\"http://www.unicode.org/unicode/reports/tr10/\">UCA sort order</a>. \n * <p>\n * Sort ordering may be customized by providing your own set of rules. For more on\n * this subject see the <a href=\"http://icu-project.org/userguide/Collate_Customization.html\">\n * Collation customization</a> section of the users guide.\n * <p>\n * Note, RuleBasedCollator is not to be subclassed.\n * @see        Collator\n * @version    2.0 11/15/2001\n */\nclass U_I18N_API RuleBasedCollator : public Collator\n{\npublic:\n\n  // constructor -------------------------------------------------------------\n\n    /**\n     * RuleBasedCollator constructor. This takes the table rules and builds a\n     * collation table out of them. Please see RuleBasedCollator class\n     * description for more details on the collation rule syntax.\n     * @param rules the collation rules to build the collation table from.\n     * @param status reporting a success or an error.\n     * @see Locale\n     * @stable ICU 2.0\n     */\n    RuleBasedCollator(const UnicodeString& rules, UErrorCode& status);\n\n    /**\n     * RuleBasedCollator constructor. This takes the table rules and builds a\n     * collation table out of them. Please see RuleBasedCollator class\n     * description for more details on the collation rule syntax.\n     * @param rules the collation rules to build the collation table from.\n     * @param collationStrength default strength for comparison\n     * @param status reporting a success or an error.\n     * @see Locale\n     * @stable ICU 2.0\n     */\n    RuleBasedCollator(const UnicodeString& rules,\n                       ECollationStrength collationStrength,\n                       UErrorCode& status);\n\n    /**\n     * RuleBasedCollator constructor. This takes the table rules and builds a\n     * collation table out of them. Please see RuleBasedCollator class\n     * description for more details on the collation rule syntax.\n     * @param rules the collation rules to build the collation table from.\n     * @param decompositionMode the normalisation mode\n     * @param status reporting a success or an error.\n     * @see Locale\n     * @stable ICU 2.0\n     */\n    RuleBasedCollator(const UnicodeString& rules,\n                    UColAttributeValue decompositionMode,\n                    UErrorCode& status);\n\n    /**\n     * RuleBasedCollator constructor. This takes the table rules and builds a\n     * collation table out of them. Please see RuleBasedCollator class\n     * description for more details on the collation rule syntax.\n     * @param rules the collation rules to build the collation table from.\n     * @param collationStrength default strength for comparison\n     * @param decompositionMode the normalisation mode\n     * @param status reporting a success or an error.\n     * @see Locale\n     * @stable ICU 2.0\n     */\n    RuleBasedCollator(const UnicodeString& rules,\n                    ECollationStrength collationStrength,\n                    UColAttributeValue decompositionMode,\n                    UErrorCode& status);\n\n    /**\n     * Copy constructor.\n     * @param other the RuleBasedCollator object to be copied\n     * @see Locale\n     * @stable ICU 2.0\n     */\n    RuleBasedCollator(const RuleBasedCollator& other);\n\n\n    /** Opens a collator from a collator binary image created using\n    *  cloneBinary. Binary image used in instantiation of the \n    *  collator remains owned by the user and should stay around for \n    *  the lifetime of the collator. The API also takes a base collator\n    *  which usualy should be UCA.\n    *  @param bin binary image owned by the user and required through the\n    *             lifetime of the collator\n    *  @param length size of the image. If negative, the API will try to\n    *                figure out the length of the image\n    *  @param base fallback collator, usually UCA. Base is required to be\n    *              present through the lifetime of the collator. Currently \n    *              it cannot be NULL.\n    *  @param status for catching errors\n    *  @return newly created collator\n    *  @see cloneBinary\n    *  @stable ICU 3.4\n    */\n    RuleBasedCollator(const uint8_t *bin, int32_t length, \n                    const RuleBasedCollator *base, \n                    UErrorCode &status);\n    // destructor --------------------------------------------------------------\n\n    /**\n     * Destructor.\n     * @stable ICU 2.0\n     */\n    virtual ~RuleBasedCollator();\n\n    // public methods ----------------------------------------------------------\n\n    /**\n     * Assignment operator.\n     * @param other other RuleBasedCollator object to compare with.\n     * @stable ICU 2.0\n     */\n    RuleBasedCollator& operator=(const RuleBasedCollator& other);\n\n    /**\n     * Returns true if argument is the same as this object.\n     * @param other Collator object to be compared.\n     * @return true if arguments is the same as this object.\n     * @stable ICU 2.0\n     */\n    virtual UBool operator==(const Collator& other) const;\n\n    /**\n     * Makes a copy of this object.\n     * @return a copy of this object, owned by the caller\n     * @stable ICU 2.0\n     */\n    virtual Collator* clone(void) const;\n\n    /**\n     * Creates a collation element iterator for the source string. The caller of\n     * this method is responsible for the memory management of the return\n     * pointer.\n     * @param source the string over which the CollationElementIterator will\n     *        iterate.\n     * @return the collation element iterator of the source string using this as\n     *         the based Collator.\n     * @stable ICU 2.2\n     */\n    virtual CollationElementIterator* createCollationElementIterator(\n                                           const UnicodeString& source) const;\n\n    /**\n     * Creates a collation element iterator for the source. The caller of this\n     * method is responsible for the memory management of the returned pointer.\n     * @param source the CharacterIterator which produces the characters over\n     *        which the CollationElementItgerator will iterate.\n     * @return the collation element iterator of the source using this as the\n     *         based Collator.\n     * @stable ICU 2.2\n     */\n    virtual CollationElementIterator* createCollationElementIterator(\n                                         const CharacterIterator& source) const;\n\n    // Make deprecated versions of Collator::compare() visible.\n    using Collator::compare;\n\n    /**\n    * The comparison function compares the character data stored in two\n    * different strings. Returns information about whether a string is less \n    * than, greater than or equal to another string.\n    * @param source the source string to be compared with.\n    * @param target the string that is to be compared with the source string.\n    * @param status possible error code\n    * @return Returns an enum value. UCOL_GREATER if source is greater\n    * than target; UCOL_EQUAL if source is equal to target; UCOL_LESS if source is less\n    * than target\n    * @stable ICU 2.6\n    **/\n    virtual UCollationResult compare(const UnicodeString& source,\n                                      const UnicodeString& target,\n                                      UErrorCode &status) const;\n\n    /**\n    * Does the same thing as compare but limits the comparison to a specified \n    * length\n    * @param source the source string to be compared with.\n    * @param target the string that is to be compared with the source string.\n    * @param length the length the comparison is limited to\n    * @param status possible error code\n    * @return Returns an enum value. UCOL_GREATER if source (up to the specified \n    *         length) is greater than target; UCOL_EQUAL if source (up to specified \n    *         length) is equal to target; UCOL_LESS if source (up to the specified \n    *         length) is less  than target.\n    * @stable ICU 2.6\n    */\n    virtual UCollationResult compare(const UnicodeString& source,\n                                      const UnicodeString& target,\n                                      int32_t length,\n                                      UErrorCode &status) const;\n\n    /**\n    * The comparison function compares the character data stored in two\n    * different string arrays. Returns information about whether a string array \n    * is less than, greater than or equal to another string array.\n    * @param source the source string array to be compared with.\n    * @param sourceLength the length of the source string array.  If this value\n    *        is equal to -1, the string array is null-terminated.\n    * @param target the string that is to be compared with the source string.\n    * @param targetLength the length of the target string array.  If this value\n    *        is equal to -1, the string array is null-terminated.\n    * @param status possible error code\n    * @return Returns an enum value. UCOL_GREATER if source is greater\n    * than target; UCOL_EQUAL if source is equal to target; UCOL_LESS if source is less\n    * than target\n    * @stable ICU 2.6\n    */\n    virtual UCollationResult compare(const UChar* source, int32_t sourceLength,\n                                      const UChar* target, int32_t targetLength,\n                                      UErrorCode &status) const;\n\n    /**\n     * Compares two strings using the Collator.\n     * Returns whether the first one compares less than/equal to/greater than\n     * the second one.\n     * This version takes UCharIterator input.\n     * @param sIter the first (\"source\") string iterator\n     * @param tIter the second (\"target\") string iterator\n     * @param status ICU status\n     * @return UCOL_LESS, UCOL_EQUAL or UCOL_GREATER\n     * @stable ICU 4.2\n     */\n    virtual UCollationResult compare(UCharIterator &sIter,\n                                     UCharIterator &tIter,\n                                     UErrorCode &status) const;\n\n    /**\n    * Transforms a specified region of the string into a series of characters\n    * that can be compared with CollationKey.compare. Use a CollationKey when\n    * you need to do repeated comparisions on the same string. For a single\n    * comparison the compare method will be faster.\n    * @param source the source string.\n    * @param key the transformed key of the source string.\n    * @param status the error code status.\n    * @return the transformed key.\n    * @see CollationKey\n    * @stable ICU 2.0\n    */\n    virtual CollationKey& getCollationKey(const UnicodeString& source,\n                                          CollationKey& key,\n                                          UErrorCode& status) const;\n\n    /**\n    * Transforms a specified region of the string into a series of characters\n    * that can be compared with CollationKey.compare. Use a CollationKey when\n    * you need to do repeated comparisions on the same string. For a single\n    * comparison the compare method will be faster.\n    * @param source the source string.\n    * @param sourceLength the length of the source string.\n    * @param key the transformed key of the source string.\n    * @param status the error code status.\n    * @return the transformed key.\n    * @see CollationKey\n    * @stable ICU 2.0\n    */\n    virtual CollationKey& getCollationKey(const UChar *source,\n                                          int32_t sourceLength,\n                                          CollationKey& key,\n                                          UErrorCode& status) const;\n\n    /**\n     * Generates the hash code for the rule-based collation object.\n     * @return the hash code.\n     * @stable ICU 2.0\n     */\n    virtual int32_t hashCode(void) const;\n\n    /**\n    * Gets the locale of the Collator\n    * @param type can be either requested, valid or actual locale. For more\n    *             information see the definition of ULocDataLocaleType in\n    *             uloc.h\n    * @param status the error code status.\n    * @return locale where the collation data lives. If the collator\n    *         was instantiated from rules, locale is empty.\n    * @deprecated ICU 2.8 likely to change in ICU 3.0, based on feedback\n    */\n    virtual Locale getLocale(ULocDataLocaleType type, UErrorCode& status) const;\n\n    /**\n     * Gets the tailoring rules for this collator.\n     * @return the collation tailoring from which this collator was created\n     * @stable ICU 2.0\n     */\n    const UnicodeString& getRules(void) const;\n\n    /**\n     * Gets the version information for a Collator.\n     * @param info the version # information, the result will be filled in\n     * @stable ICU 2.0\n     */\n    virtual void getVersion(UVersionInfo info) const;\n\n    /**\n     * Return the maximum length of any expansion sequences that end with the\n     * specified comparison order.\n     * @param order a collation order returned by previous or next.\n     * @return maximum size of the expansion sequences ending with the collation\n     *         element or 1 if collation element does not occur at the end of\n     *         any expansion sequence\n     * @see CollationElementIterator#getMaxExpansion\n     * @stable ICU 2.0\n     */\n    int32_t getMaxExpansion(int32_t order) const;\n\n    /**\n     * Returns a unique class ID POLYMORPHICALLY. Pure virtual override. This\n     * method is to implement a simple version of RTTI, since not all C++\n     * compilers support genuine RTTI. Polymorphic operator==() and clone()\n     * methods call this method.\n     * @return The class ID for this object. All objects of a given class have\n     *         the same class ID. Objects of other classes have different class\n     *         IDs.\n     * @stable ICU 2.0\n     */\n    virtual UClassID getDynamicClassID(void) const;\n\n    /**\n     * Returns the class ID for this class. This is useful only for comparing to\n     * a return value from getDynamicClassID(). For example:\n     * <pre>\n     * Base* polymorphic_pointer = createPolymorphicObject();\n     * if (polymorphic_pointer->getDynamicClassID() ==\n     *                                          Derived::getStaticClassID()) ...\n     * </pre>\n     * @return The class ID for all objects of this class.\n     * @stable ICU 2.0\n     */\n    static UClassID U_EXPORT2 getStaticClassID(void);\n\n    /**\n     * Returns the binary format of the class's rules. The format is that of\n     * .col files.\n     * @param length Returns the length of the data, in bytes\n     * @param status the error code status.\n     * @return memory, owned by the caller, of size 'length' bytes.\n     * @stable ICU 2.2\n     */\n    uint8_t *cloneRuleData(int32_t &length, UErrorCode &status);\n\n\n    /** Creates a binary image of a collator. This binary image can be stored and \n    *  later used to instantiate a collator using ucol_openBinary.\n    *  This API supports preflighting.\n    *  @param buffer a fill-in buffer to receive the binary image\n    *  @param capacity capacity of the destination buffer\n    *  @param status for catching errors\n    *  @return size of the image\n    *  @see ucol_openBinary\n    *  @stable ICU 3.4\n    */\n    int32_t cloneBinary(uint8_t *buffer, int32_t capacity, UErrorCode &status);\n\n    /**\n     * Returns current rules. Delta defines whether full rules are returned or\n     * just the tailoring.\n     *\n     * getRules(void) should normally be used instead.\n     * See http://userguide.icu-project.org/collation/customization#TOC-Building-on-Existing-Locales\n     * @param delta one of UCOL_TAILORING_ONLY, UCOL_FULL_RULES.\n     * @param buffer UnicodeString to store the result rules\n     * @stable ICU 2.2\n     * @see UCOL_FULL_RULES\n     */\n    void getRules(UColRuleOption delta, UnicodeString &buffer);\n\n    /**\n     * Universal attribute setter\n     * @param attr attribute type\n     * @param value attribute value\n     * @param status to indicate whether the operation went on smoothly or there were errors\n     * @stable ICU 2.2\n     */\n    virtual void setAttribute(UColAttribute attr, UColAttributeValue value,\n                              UErrorCode &status);\n\n    /**\n     * Universal attribute getter.\n     * @param attr attribute type\n     * @param status to indicate whether the operation went on smoothly or there were errors\n     * @return attribute value\n     * @stable ICU 2.2\n     */\n    virtual UColAttributeValue getAttribute(UColAttribute attr,\n                                            UErrorCode &status) const;\n\n    /**\n     * Sets the variable top to a collation element value of a string supplied.\n     * @param varTop one or more (if contraction) UChars to which the variable top should be set\n     * @param len length of variable top string. If -1 it is considered to be zero terminated.\n     * @param status error code. If error code is set, the return value is undefined. Errors set by this function are: <br>\n     *    U_CE_NOT_FOUND_ERROR if more than one character was passed and there is no such a contraction<br>\n     *    U_PRIMARY_TOO_LONG_ERROR if the primary for the variable top has more than two bytes\n     * @return a 32 bit value containing the value of the variable top in upper 16 bits. Lower 16 bits are undefined\n     * @stable ICU 2.0\n     */\n    virtual uint32_t setVariableTop(const UChar *varTop, int32_t len, UErrorCode &status);\n\n    /**\n     * Sets the variable top to a collation element value of a string supplied.\n     * @param varTop an UnicodeString size 1 or more (if contraction) of UChars to which the variable top should be set\n     * @param status error code. If error code is set, the return value is undefined. Errors set by this function are: <br>\n     *    U_CE_NOT_FOUND_ERROR if more than one character was passed and there is no such a contraction<br>\n     *    U_PRIMARY_TOO_LONG_ERROR if the primary for the variable top has more than two bytes\n     * @return a 32 bit value containing the value of the variable top in upper 16 bits. Lower 16 bits are undefined\n     * @stable ICU 2.0\n     */\n    virtual uint32_t setVariableTop(const UnicodeString &varTop, UErrorCode &status);\n\n    /**\n     * Sets the variable top to a collation element value supplied. Variable top is set to the upper 16 bits.\n     * Lower 16 bits are ignored.\n     * @param varTop CE value, as returned by setVariableTop or ucol)getVariableTop\n     * @param status error code (not changed by function)\n     * @stable ICU 2.0\n     */\n    virtual void setVariableTop(uint32_t varTop, UErrorCode &status);\n\n    /**\n     * Gets the variable top value of a Collator.\n     * Lower 16 bits are undefined and should be ignored.\n     * @param status error code (not changed by function). If error code is set, the return value is undefined.\n     * @stable ICU 2.0\n     */\n    virtual uint32_t getVariableTop(UErrorCode &status) const;\n\n    /**\n     * Get an UnicodeSet that contains all the characters and sequences tailored in \n     * this collator.\n     * @param status      error code of the operation\n     * @return a pointer to a UnicodeSet object containing all the \n     *         code points and sequences that may sort differently than\n     *         in the UCA. The object must be disposed of by using delete\n     * @stable ICU 2.4\n     */\n    virtual UnicodeSet *getTailoredSet(UErrorCode &status) const;\n\n    /**\n     * Get the sort key as an array of bytes from an UnicodeString.\n     * @param source string to be processed.\n     * @param result buffer to store result in. If NULL, number of bytes needed\n     *        will be returned.\n     * @param resultLength length of the result buffer. If if not enough the\n     *        buffer will be filled to capacity.\n     * @return Number of bytes needed for storing the sort key\n     * @stable ICU 2.0\n     */\n    virtual int32_t getSortKey(const UnicodeString& source, uint8_t *result,\n                               int32_t resultLength) const;\n\n    /**\n     * Get the sort key as an array of bytes from an UChar buffer.\n     * @param source string to be processed.\n     * @param sourceLength length of string to be processed. If -1, the string\n     *        is 0 terminated and length will be decided by the function.\n     * @param result buffer to store result in. If NULL, number of bytes needed\n     *        will be returned.\n     * @param resultLength length of the result buffer. If if not enough the\n     *        buffer will be filled to capacity.\n     * @return Number of bytes needed for storing the sort key\n     * @stable ICU 2.2\n     */\n    virtual int32_t getSortKey(const UChar *source, int32_t sourceLength,\n                               uint8_t *result, int32_t resultLength) const;\n\n    /**\n     * Retrieves the reordering codes for this collator.\n     * @param dest The array to fill with the script ordering.\n     * @param destCapacity The length of dest. If it is 0, then dest may be NULL and the function\n     *  will only return the length of the result without writing any of the result string (pre-flighting).\n     * @param status A reference to an error code value, which must not indicate\n     * a failure before the function call.\n     * @return The length of the script ordering array.\n     * @see ucol_setReorderCodes\n     * @see Collator#getEquivalentReorderCodes\n     * @see Collator#setReorderCodes\n     * @stable ICU 4.8 \n     */\n     virtual int32_t getReorderCodes(int32_t *dest,\n                                     int32_t destCapacity,\n                                     UErrorCode& status) const;\n\n    /**\n     * Sets the ordering of scripts for this collator.\n     * @param reorderCodes An array of script codes in the new order. This can be NULL if the \n     * length is also set to 0. An empty array will clear any reordering codes on the collator.\n     * @param reorderCodesLength The length of reorderCodes.\n     * @param status error code\n     * @see Collator#getReorderCodes\n     * @see Collator#getEquivalentReorderCodes\n     * @stable ICU 4.8 \n     */\n     virtual void setReorderCodes(const int32_t* reorderCodes,\n                                  int32_t reorderCodesLength,\n                                  UErrorCode& status) ;\n\n    /**\n     * Retrieves the reorder codes that are grouped with the given reorder code. Some reorder\n     * codes will be grouped and must reorder together.\n     * @param reorderCode The reorder code to determine equivalence for. \n     * @param dest The array to fill with the script equivalene reordering codes.\n     * @param destCapacity The length of dest. If it is 0, then dest may be NULL and the \n     * function will only return the length of the result without writing any of the result \n     * string (pre-flighting).\n     * @param status A reference to an error code value, which must not indicate \n     * a failure before the function call.\n     * @return The length of the of the reordering code equivalence array.\n     * @see ucol_setReorderCodes\n     * @see Collator#getReorderCodes\n     * @see Collator#setReorderCodes\n     * @stable ICU 4.8 \n     */\n    static int32_t U_EXPORT2 getEquivalentReorderCodes(int32_t reorderCode,\n                                int32_t* dest,\n                                int32_t destCapacity,\n                                UErrorCode& status);\n\nprivate:\n\n    // private static constants -----------------------------------------------\n\n    enum {\n        /* need look up in .commit() */\n        CHARINDEX = 0x70000000,\n        /* Expand index follows */\n        EXPANDCHARINDEX = 0x7E000000,\n        /* contract indexes follows */\n        CONTRACTCHARINDEX = 0x7F000000,\n        /* unmapped character values */\n        UNMAPPED = 0xFFFFFFFF,\n        /* primary strength increment */\n        PRIMARYORDERINCREMENT = 0x00010000,\n        /* secondary strength increment */\n        SECONDARYORDERINCREMENT = 0x00000100,\n        /* tertiary strength increment */\n        TERTIARYORDERINCREMENT = 0x00000001,\n        /* mask off anything but primary order */\n        PRIMARYORDERMASK = 0xffff0000,\n        /* mask off anything but secondary order */\n        SECONDARYORDERMASK = 0x0000ff00,\n        /* mask off anything but tertiary order */\n        TERTIARYORDERMASK = 0x000000ff,\n        /* mask off ignorable char order */\n        IGNORABLEMASK = 0x0000ffff,\n        /* use only the primary difference */\n        PRIMARYDIFFERENCEONLY = 0xffff0000,\n        /* use only the primary and secondary difference */\n        SECONDARYDIFFERENCEONLY = 0xffffff00,\n        /* primary order shift */\n        PRIMARYORDERSHIFT = 16,\n        /* secondary order shift */\n        SECONDARYORDERSHIFT = 8,\n        /* starting value for collation elements */\n        COLELEMENTSTART = 0x02020202,\n        /* testing mask for primary low element */\n        PRIMARYLOWZEROMASK = 0x00FF0000,\n        /* reseting value for secondaries and tertiaries */\n        RESETSECONDARYTERTIARY = 0x00000202,\n        /* reseting value for tertiaries */\n        RESETTERTIARY = 0x00000002,\n\n        PRIMIGNORABLE = 0x0202\n    };\n\n    // private data members ---------------------------------------------------\n\n    UBool dataIsOwned;\n\n    UBool isWriteThroughAlias;\n\n    /**\n    * c struct for collation. All initialisation for it has to be done through\n    * setUCollator().\n    */\n    UCollator *ucollator;\n\n    /**\n    * Rule UnicodeString\n    */\n    UnicodeString urulestring;\n\n    // friend classes --------------------------------------------------------\n\n    /**\n    * Used to iterate over collation elements in a character source.\n    */\n    friend class CollationElementIterator;\n\n    /**\n    * Collator ONLY needs access to RuleBasedCollator(const Locale&,\n    *                                                       UErrorCode&)\n    */\n    friend class Collator;\n\n    /**\n    * Searching over collation elements in a character source\n    */\n    friend class StringSearch;\n\n    // private constructors --------------------------------------------------\n\n    /**\n     * Default constructor\n     */\n    RuleBasedCollator();\n\n    /**\n     * RuleBasedCollator constructor. This constructor takes a locale. The\n     * only caller of this class should be Collator::createInstance(). If\n     * createInstance() happens to know that the requested locale's collation is\n     * implemented as a RuleBasedCollator, it can then call this constructor.\n     * OTHERWISE IT SHOULDN'T, since this constructor ALWAYS RETURNS A VALID\n     * COLLATION TABLE. It does this by falling back to defaults.\n     * @param desiredLocale locale used\n     * @param status error code status\n     */\n    RuleBasedCollator(const Locale& desiredLocale, UErrorCode& status);\n\n    /**\n     * common constructor implementation\n     *\n     * @param rules the collation rules to build the collation table from.\n     * @param collationStrength default strength for comparison\n     * @param decompositionMode the normalisation mode\n     * @param status reporting a success or an error.\n     */\n    void\n    construct(const UnicodeString& rules,\n              UColAttributeValue collationStrength,\n              UColAttributeValue decompositionMode,\n              UErrorCode& status);\n\n    // private methods -------------------------------------------------------\n\n    /**\n    * Creates the c struct for ucollator\n    * @param locale desired locale\n    * @param status error status\n    */\n    void setUCollator(const Locale& locale, UErrorCode& status);\n\n    /**\n    * Creates the c struct for ucollator\n    * @param locale desired locale name\n    * @param status error status\n    */\n    void setUCollator(const char* locale, UErrorCode& status);\n\n    /**\n    * Creates the c struct for ucollator. This used internally by StringSearch.\n    * Hence the responsibility of cleaning up the ucollator is not done by\n    * this RuleBasedCollator. The isDataOwned flag is set to FALSE.\n    * @param collator new ucollator data\n    */\n    void setUCollator(UCollator *collator);\n\npublic:\n#ifndef U_HIDE_INTERNAL_API\n    /**\n    * Get UCollator data struct. Used only by StringSearch & intltest.\n    * @return UCollator data struct\n    * @internal\n    */\n    const UCollator * getUCollator();\n#endif  /* U_HIDE_INTERNAL_API */\n\nprotected:\n   /**\n    * Used internally by registraton to define the requested and valid locales.\n    * @param requestedLocale the requsted locale\n    * @param validLocale the valid locale\n    * @param actualLocale the actual locale\n    * @internal\n    */\n    virtual void setLocales(const Locale& requestedLocale, const Locale& validLocale, const Locale& actualLocale);\n\nprivate:\n    // if not owned and not a write through alias, copy the ucollator\n    void checkOwned(void);\n\n    // utility to init rule string used by checkOwned and construct\n    void setRuleStringFromCollator();\n\npublic:\n    /** Get the short definition string for a collator. This internal API harvests the collator's\n     *  locale and the attribute set and produces a string that can be used for opening \n     *  a collator with the same properties using the ucol_openFromShortString API.\n     *  This string will be normalized.\n     *  The structure and the syntax of the string is defined in the \"Naming collators\"\n     *  section of the users guide: \n     *  http://icu-project.org/userguide/Collate_Concepts.html#Naming_Collators\n     *  This function supports preflighting.\n     * \n     *  This is internal, and intended to be used with delegate converters.\n     *\n     *  @param locale a locale that will appear as a collators locale in the resulting\n     *                short string definition. If NULL, the locale will be harvested \n     *                from the collator.\n     *  @param buffer space to hold the resulting string\n     *  @param capacity capacity of the buffer\n     *  @param status for returning errors. All the preflighting errors are featured\n     *  @return length of the resulting string\n     *  @see ucol_openFromShortString\n     *  @see ucol_normalizeShortDefinitionString\n     *  @see ucol_getShortDefinitionString\n     *  @internal\n     */\n    virtual int32_t internalGetShortDefinitionString(const char *locale,\n                                                     char *buffer,\n                                                     int32_t capacity,\n                                                     UErrorCode &status) const;\n};\n\n// inline method implementation ---------------------------------------------\n\ninline void RuleBasedCollator::setUCollator(const Locale &locale,\n                                               UErrorCode &status)\n{\n    setUCollator(locale.getName(), status);\n}\n\n\ninline void RuleBasedCollator::setUCollator(UCollator     *collator)\n{\n\n    if (ucollator && dataIsOwned) {\n        ucol_close(ucollator);\n    }\n    ucollator   = collator;\n    dataIsOwned = FALSE;\n    isWriteThroughAlias = TRUE;\n    setRuleStringFromCollator();\n}\n\n#ifndef U_HIDE_INTERNAL_API\ninline const UCollator * RuleBasedCollator::getUCollator()\n{\n    return ucollator;\n}\n#endif\n\nU_NAMESPACE_END\n\n#endif /* #if !UCONFIG_NO_COLLATION */\n\n#endif\n"
  },
  {
    "path": "deprecated/android/addons/icucompat/unicode/timezone.h",
    "content": "/*************************************************************************\n* Copyright (c) 1997-2012, International Business Machines Corporation\n* and others. All Rights Reserved.\n**************************************************************************\n*\n* File TIMEZONE.H\n*\n* Modification History:\n*\n*   Date        Name        Description\n*   04/21/97    aliu        Overhauled header.\n*   07/09/97    helena      Changed createInstance to createDefault.\n*   08/06/97    aliu        Removed dependency on internal header for Hashtable.\n*   08/10/98    stephen        Changed getDisplayName() API conventions to match\n*   08/19/98    stephen        Changed createTimeZone() to never return 0\n*   09/02/98    stephen        Sync to JDK 1.2 8/31\n*                            - Added getOffset(... monthlen ...)\n*                            - Added hasSameRules()\n*   09/15/98    stephen        Added getStaticClassID\n*   12/03/99    aliu        Moved data out of static table into icudata.dll.\n*                           Hashtable replaced by new static data structures.\n*   12/14/99    aliu        Made GMT public.\n*   08/15/01    grhoten     Made GMT private and added the getGMT() function\n**************************************************************************\n*/\n\n#ifndef TIMEZONE_H\n#define TIMEZONE_H\n\n#include \"unicode/utypes.h\"\n\n/**\n * \\file \n * \\brief C++ API: TimeZone object\n */\n\n#if !UCONFIG_NO_FORMATTING\n\n#include \"unicode/uobject.h\"\n#include \"unicode/unistr.h\"\n#include \"unicode/ures.h\"\n#include \"unicode/ucal.h\"\n\nU_NAMESPACE_BEGIN\n\nclass StringEnumeration;\n\n/**\n *\n * <code>TimeZone</code> represents a time zone offset, and also figures out daylight\n * savings.\n *\n * <p>\n * Typically, you get a <code>TimeZone</code> using <code>createDefault</code>\n * which creates a <code>TimeZone</code> based on the time zone where the program\n * is running. For example, for a program running in Japan, <code>createDefault</code>\n * creates a <code>TimeZone</code> object based on Japanese Standard Time.\n *\n * <p>\n * You can also get a <code>TimeZone</code> using <code>createTimeZone</code> along\n * with a time zone ID. For instance, the time zone ID for the US Pacific\n * Time zone is \"America/Los_Angeles\". So, you can get a Pacific Time <code>TimeZone</code> object\n * with:\n * \\htmlonly<blockquote>\\endhtmlonly\n * <pre>\n * TimeZone *tz = TimeZone::createTimeZone(\"America/Los_Angeles\");\n * </pre>\n * \\htmlonly</blockquote>\\endhtmlonly\n * You can use <code>getAvailableIDs</code> method to iterate through\n * all the supported time zone IDs, or getCanonicalID method to check\n * if a time zone ID is supported or not.  You can then choose a\n * supported ID to get a <code>TimeZone</code>.\n * If the time zone you want is not represented by one of the\n * supported IDs, then you can create a custom time zone ID with\n * the following syntax:\n *\n * \\htmlonly<blockquote>\\endhtmlonly\n * <pre>\n * GMT[+|-]hh[[:]mm]\n * </pre>\n * \\htmlonly</blockquote>\\endhtmlonly\n *\n * For example, you might specify GMT+14:00 as a custom\n * time zone ID.  The <code>TimeZone</code> that is returned\n * when you specify a custom time zone ID uses the specified\n * offset from GMT(=UTC) and does not observe daylight saving\n * time. For example, you might specify GMT+14:00 as a custom\n * time zone ID to create a TimeZone representing 14 hours ahead\n * of GMT (with no daylight saving time). In addition,\n * <code>getCanonicalID</code> can also be used to\n * normalize a custom time zone ID.\n *\n * TimeZone is an abstract class representing a time zone.  A TimeZone is needed for\n * Calendar to produce local time for a particular time zone.  A TimeZone comprises\n * three basic pieces of information:\n * <ul>\n *    <li>A time zone offset; that, is the number of milliseconds to add or subtract\n *      from a time expressed in terms of GMT to convert it to the same time in that\n *      time zone (without taking daylight savings time into account).</li>\n *    <li>Logic necessary to take daylight savings time into account if daylight savings\n *      time is observed in that time zone (e.g., the days and hours on which daylight\n *      savings time begins and ends).</li>\n *    <li>An ID.  This is a text string that uniquely identifies the time zone.</li>\n * </ul>\n *\n * (Only the ID is actually implemented in TimeZone; subclasses of TimeZone may handle\n * daylight savings time and GMT offset in different ways.  Currently we have the following\n * TimeZone subclasses: RuleBasedTimeZone, SimpleTimeZone, and VTimeZone.)\n * <P>\n * The TimeZone class contains a static list containing a TimeZone object for every\n * combination of GMT offset and daylight-savings time rules currently in use in the\n * world, each with a unique ID.  Each ID consists of a region (usually a continent or\n * ocean) and a city in that region, separated by a slash, (for example, US Pacific\n * Time is \"America/Los_Angeles.\")  Because older versions of this class used\n * three- or four-letter abbreviations instead, there is also a table that maps the older\n * abbreviations to the newer ones (for example, \"PST\" maps to \"America/Los_Angeles\").\n * Anywhere the API requires an ID, you can use either form.\n * <P>\n * To create a new TimeZone, you call the factory function TimeZone::createTimeZone()\n * and pass it a time zone ID.  You can use the createEnumeration() function to\n * obtain a list of all the time zone IDs recognized by createTimeZone().\n * <P>\n * You can also use TimeZone::createDefault() to create a TimeZone.  This function uses\n * platform-specific APIs to produce a TimeZone for the time zone corresponding to\n * the client's computer's physical location.  For example, if you're in Japan (assuming\n * your machine is set up correctly), TimeZone::createDefault() will return a TimeZone\n * for Japanese Standard Time (\"Asia/Tokyo\").\n */\nclass U_I18N_API TimeZone : public UObject {\npublic:\n    /**\n     * @stable ICU 2.0\n     */\n    virtual ~TimeZone();\n\n#ifndef U_HIDE_DRAFT_API\n    /**\n     * Returns the \"unknown\" time zone.\n     * It behaves like the GMT/UTC time zone but has the\n     * <code>UCAL_UNKNOWN_ZONE_ID</code> = \"Etc/Unknown\".\n     * createTimeZone() returns a mutable clone of this time zone if the input ID is not recognized.\n     *\n     * @return the \"unknown\" time zone.\n     * @see UCAL_UNKNOWN_ZONE_ID\n     * @see createTimeZone\n     * @see getGMT\n     * @draft ICU 49\n     */\n    static const TimeZone& U_EXPORT2 getUnknown();\n#endif  /* U_HIDE_DRAFT_API */\n\n    /**\n     * The GMT (=UTC) time zone has a raw offset of zero and does not use daylight\n     * savings time. This is a commonly used time zone.\n     *\n     * <p>Note: For backward compatibility reason, the ID used by the time\n     * zone returned by this method is \"GMT\", although the ICU's canonical\n     * ID for the GMT time zone is \"Etc/GMT\".\n     *\n     * @return the GMT/UTC time zone.\n     * @see getUnknown\n     * @stable ICU 2.0\n     */\n    static const TimeZone* U_EXPORT2 getGMT(void);\n\n    /**\n     * Creates a <code>TimeZone</code> for the given ID.\n     * @param ID the ID for a <code>TimeZone</code>, such as \"America/Los_Angeles\",\n     * or a custom ID such as \"GMT-8:00\".\n     * @return the specified <code>TimeZone</code>, or a mutable clone of getUnknown()\n     * if the given ID cannot be understood or if the given ID is \"Etc/Unknown\".\n     * The return result is guaranteed to be non-NULL.\n     * If you require that the specific zone asked for be returned,\n     * compare the result with getUnknown() or check the ID of the return result.\n     * @stable ICU 2.0\n     */\n    static TimeZone* U_EXPORT2 createTimeZone(const UnicodeString& ID);\n\n    /**\n     * Returns an enumeration over system time zone IDs with the given\n     * filter conditions.\n     * @param zoneType      The system time zone type.\n     * @param region        The ISO 3166 two-letter country code or UN M.49\n     *                      three-digit area code. When NULL, no filtering\n     *                      done by region. \n     * @param rawOffset     An offset from GMT in milliseconds, ignoring\n     *                      the effect of daylight savings time, if any.\n     *                      When NULL, no filtering done by zone offset. \n     * @param ec            Output param to filled in with a success or\n     *                      an error.\n     * @return an enumeration object, owned by the caller.\n     * @stable ICU 4.8\n     */\n    static StringEnumeration* U_EXPORT2 createTimeZoneIDEnumeration(\n        USystemTimeZoneType zoneType,\n        const char* region,\n        const int32_t* rawOffset,\n        UErrorCode& ec);\n\n    /**\n     * Returns an enumeration over all recognized time zone IDs. (i.e.,\n     * all strings that createTimeZone() accepts)\n     *\n     * @return an enumeration object, owned by the caller.\n     * @stable ICU 2.4\n     */\n    static StringEnumeration* U_EXPORT2 createEnumeration();\n\n    /**\n     * Returns an enumeration over time zone IDs with a given raw\n     * offset from GMT.  There may be several times zones with the\n     * same GMT offset that differ in the way they handle daylight\n     * savings time.  For example, the state of Arizona doesn't\n     * observe daylight savings time.  If you ask for the time zone\n     * IDs corresponding to GMT-7:00, you'll get back an enumeration\n     * over two time zone IDs: \"America/Denver,\" which corresponds to\n     * Mountain Standard Time in the winter and Mountain Daylight Time\n     * in the summer, and \"America/Phoenix\", which corresponds to\n     * Mountain Standard Time year-round, even in the summer.\n     *\n     * @param rawOffset an offset from GMT in milliseconds, ignoring\n     * the effect of daylight savings time, if any\n     * @return an enumeration object, owned by the caller\n     * @stable ICU 2.4\n     */\n    static StringEnumeration* U_EXPORT2 createEnumeration(int32_t rawOffset);\n\n    /**\n     * Returns an enumeration over time zone IDs associated with the\n     * given country.  Some zones are affiliated with no country\n     * (e.g., \"UTC\"); these may also be retrieved, as a group.\n     *\n     * @param country The ISO 3166 two-letter country code, or NULL to\n     * retrieve zones not affiliated with any country.\n     * @return an enumeration object, owned by the caller\n     * @stable ICU 2.4\n     */\n    static StringEnumeration* U_EXPORT2 createEnumeration(const char* country);\n\n    /**\n     * Returns the number of IDs in the equivalency group that\n     * includes the given ID.  An equivalency group contains zones\n     * that have the same GMT offset and rules.\n     *\n     * <p>The returned count includes the given ID; it is always >= 1.\n     * The given ID must be a system time zone.  If it is not, returns\n     * zero.\n     * @param id a system time zone ID\n     * @return the number of zones in the equivalency group containing\n     * 'id', or zero if 'id' is not a valid system ID\n     * @see #getEquivalentID\n     * @stable ICU 2.0\n     */\n    static int32_t U_EXPORT2 countEquivalentIDs(const UnicodeString& id);\n\n    /**\n     * Returns an ID in the equivalency group that\n     * includes the given ID.  An equivalency group contains zones\n     * that have the same GMT offset and rules.\n     *\n     * <p>The given index must be in the range 0..n-1, where n is the\n     * value returned by <code>countEquivalentIDs(id)</code>.  For\n     * some value of 'index', the returned value will be equal to the\n     * given id.  If the given id is not a valid system time zone, or\n     * if 'index' is out of range, then returns an empty string.\n     * @param id a system time zone ID\n     * @param index a value from 0 to n-1, where n is the value\n     * returned by <code>countEquivalentIDs(id)</code>\n     * @return the ID of the index-th zone in the equivalency group\n     * containing 'id', or an empty string if 'id' is not a valid\n     * system ID or 'index' is out of range\n     * @see #countEquivalentIDs\n     * @stable ICU 2.0\n     */\n    static const UnicodeString U_EXPORT2 getEquivalentID(const UnicodeString& id,\n                                               int32_t index);\n\n    /**\n     * Creates a new copy of the default TimeZone for this host. Unless the default time\n     * zone has already been set using adoptDefault() or setDefault(), the default is\n     * determined by querying the system using methods in TPlatformUtilities. If the\n     * system routines fail, or if they specify a TimeZone or TimeZone offset which is not\n     * recognized, the TimeZone indicated by the ID kLastResortID is instantiated\n     * and made the default.\n     *\n     * @return   A default TimeZone. Clients are responsible for deleting the time zone\n     *           object returned.\n     * @stable ICU 2.0\n     */\n    static TimeZone* U_EXPORT2 createDefault(void);\n\n    /**\n     * Sets the default time zone (i.e., what's returned by createDefault()) to be the\n     * specified time zone.  If NULL is specified for the time zone, the default time\n     * zone is set to the default host time zone.  This call adopts the TimeZone object\n     * passed in; the clent is no longer responsible for deleting it.\n     *\n     * @param zone  A pointer to the new TimeZone object to use as the default.\n     * @stable ICU 2.0\n     */\n    static void U_EXPORT2 adoptDefault(TimeZone* zone);\n\n#ifndef U_HIDE_SYSTEM_API\n    /**\n     * Same as adoptDefault(), except that the TimeZone object passed in is NOT adopted;\n     * the caller remains responsible for deleting it.\n     *\n     * @param zone  The given timezone.\n     * @system\n     * @stable ICU 2.0\n     */\n    static void U_EXPORT2 setDefault(const TimeZone& zone);\n#endif  /* U_HIDE_SYSTEM_API */\n\n    /**\n     * Returns the timezone data version currently used by ICU.\n     * @param status Output param to filled in with a success or an error.\n     * @return the version string, such as \"2007f\"\n     * @stable ICU 3.8\n     */\n    static const char* U_EXPORT2 getTZDataVersion(UErrorCode& status);\n\n    /**\n     * Returns the canonical system timezone ID or the normalized\n     * custom time zone ID for the given time zone ID.\n     * @param id            The input time zone ID to be canonicalized.\n     * @param canonicalID   Receives the canonical system time zone ID\n     *                      or the custom time zone ID in normalized format.\n     * @param status        Recevies the status.  When the given time zone ID\n     *                      is neither a known system time zone ID nor a\n     *                      valid custom time zone ID, U_ILLEGAL_ARGUMENT_ERROR\n     *                      is set.\n     * @return A reference to the result.\n     * @stable ICU 4.0\n     */\n    static UnicodeString& U_EXPORT2 getCanonicalID(const UnicodeString& id,\n        UnicodeString& canonicalID, UErrorCode& status);\n\n    /**\n     * Returns the canonical system time zone ID or the normalized\n     * custom time zone ID for the given time zone ID.\n     * @param id            The input time zone ID to be canonicalized.\n     * @param canonicalID   Receives the canonical system time zone ID\n     *                      or the custom time zone ID in normalized format.\n     * @param isSystemID    Receives if the given ID is a known system\n     *                      time zone ID.\n     * @param status        Recevies the status.  When the given time zone ID\n     *                      is neither a known system time zone ID nor a\n     *                      valid custom time zone ID, U_ILLEGAL_ARGUMENT_ERROR\n     *                      is set.\n     * @return A reference to the result.\n     * @stable ICU 4.0\n     */\n    static UnicodeString& U_EXPORT2 getCanonicalID(const UnicodeString& id,\n        UnicodeString& canonicalID, UBool& isSystemID, UErrorCode& status);\n\n    /**\n     * Returns true if the two TimeZones are equal.  (The TimeZone version only compares\n     * IDs, but subclasses are expected to also compare the fields they add.)\n     *\n     * @param that  The TimeZone object to be compared with.\n     * @return      True if the given TimeZone is equal to this TimeZone; false\n     *              otherwise.\n     * @stable ICU 2.0\n     */\n    virtual UBool operator==(const TimeZone& that) const;\n\n    /**\n     * Returns true if the two TimeZones are NOT equal; that is, if operator==() returns\n     * false.\n     *\n     * @param that  The TimeZone object to be compared with.\n     * @return      True if the given TimeZone is not equal to this TimeZone; false\n     *              otherwise.\n     * @stable ICU 2.0\n     */\n    UBool operator!=(const TimeZone& that) const {return !operator==(that);}\n\n    /**\n     * Returns the TimeZone's adjusted GMT offset (i.e., the number of milliseconds to add\n     * to GMT to get local time in this time zone, taking daylight savings time into\n     * account) as of a particular reference date.  The reference date is used to determine\n     * whether daylight savings time is in effect and needs to be figured into the offset\n     * that is returned (in other words, what is the adjusted GMT offset in this time zone\n     * at this particular date and time?).  For the time zones produced by createTimeZone(),\n     * the reference data is specified according to the Gregorian calendar, and the date\n     * and time fields are local standard time.\n     *\n     * <p>Note: Don't call this method. Instead, call the getOffset(UDate...) overload,\n     * which returns both the raw and the DST offset for a given time. This method\n     * is retained only for backward compatibility.\n     *\n     * @param era        The reference date's era\n     * @param year       The reference date's year\n     * @param month      The reference date's month (0-based; 0 is January)\n     * @param day        The reference date's day-in-month (1-based)\n     * @param dayOfWeek  The reference date's day-of-week (1-based; 1 is Sunday)\n     * @param millis     The reference date's milliseconds in day, local standard time\n     * @param status     Output param to filled in with a success or an error.\n     * @return           The offset in milliseconds to add to GMT to get local time.\n     * @stable ICU 2.0\n     */\n    virtual int32_t getOffset(uint8_t era, int32_t year, int32_t month, int32_t day,\n                              uint8_t dayOfWeek, int32_t millis, UErrorCode& status) const = 0;\n\n    /**\n     * Gets the time zone offset, for current date, modified in case of\n     * daylight savings. This is the offset to add *to* UTC to get local time.\n     *\n     * <p>Note: Don't call this method. Instead, call the getOffset(UDate...) overload,\n     * which returns both the raw and the DST offset for a given time. This method\n     * is retained only for backward compatibility.\n     *\n     * @param era the era of the given date.\n     * @param year the year in the given date.\n     * @param month the month in the given date.\n     * Month is 0-based. e.g., 0 for January.\n     * @param day the day-in-month of the given date.\n     * @param dayOfWeek the day-of-week of the given date.\n     * @param milliseconds the millis in day in <em>standard</em> local time.\n     * @param monthLength the length of the given month in days.\n     * @param status     Output param to filled in with a success or an error.\n     * @return the offset to add *to* GMT to get local time.\n     * @stable ICU 2.0\n     */\n    virtual int32_t getOffset(uint8_t era, int32_t year, int32_t month, int32_t day,\n                           uint8_t dayOfWeek, int32_t milliseconds,\n                           int32_t monthLength, UErrorCode& status) const = 0;\n\n    /**\n     * Returns the time zone raw and GMT offset for the given moment\n     * in time.  Upon return, local-millis = GMT-millis + rawOffset +\n     * dstOffset.  All computations are performed in the proleptic\n     * Gregorian calendar.  The default implementation in the TimeZone\n     * class delegates to the 8-argument getOffset().\n     *\n     * @param date moment in time for which to return offsets, in\n     * units of milliseconds from January 1, 1970 0:00 GMT, either GMT\n     * time or local wall time, depending on `local'.\n     * @param local if true, `date' is local wall time; otherwise it\n     * is in GMT time.\n     * @param rawOffset output parameter to receive the raw offset, that\n     * is, the offset not including DST adjustments\n     * @param dstOffset output parameter to receive the DST offset,\n     * that is, the offset to be added to `rawOffset' to obtain the\n     * total offset between local and GMT time. If DST is not in\n     * effect, this value is zero; otherwise it is a positive value,\n     * typically one hour.\n     * @param ec input-output error code\n     *\n     * @stable ICU 2.8\n     */\n    virtual void getOffset(UDate date, UBool local, int32_t& rawOffset,\n                           int32_t& dstOffset, UErrorCode& ec) const;\n\n    /**\n     * Sets the TimeZone's raw GMT offset (i.e., the number of milliseconds to add\n     * to GMT to get local time, before taking daylight savings time into account).\n     *\n     * @param offsetMillis  The new raw GMT offset for this time zone.\n     * @stable ICU 2.0\n     */\n    virtual void setRawOffset(int32_t offsetMillis) = 0;\n\n    /**\n     * Returns the TimeZone's raw GMT offset (i.e., the number of milliseconds to add\n     * to GMT to get local time, before taking daylight savings time into account).\n     *\n     * @return   The TimeZone's raw GMT offset.\n     * @stable ICU 2.0\n     */\n    virtual int32_t getRawOffset(void) const = 0;\n\n    /**\n     * Fills in \"ID\" with the TimeZone's ID.\n     *\n     * @param ID  Receives this TimeZone's ID.\n     * @return    A reference to 'ID'\n     * @stable ICU 2.0\n     */\n    UnicodeString& getID(UnicodeString& ID) const;\n\n    /**\n     * Sets the TimeZone's ID to the specified value.  This doesn't affect any other\n     * fields (for example, if you say<\n     * blockquote><pre>\n     * .     TimeZone* foo = TimeZone::createTimeZone(\"America/New_York\");\n     * .     foo.setID(\"America/Los_Angeles\");\n     * </pre>\\htmlonly</blockquote>\\endhtmlonly\n     * the time zone's GMT offset and daylight-savings rules don't change to those for\n     * Los Angeles.  They're still those for New York.  Only the ID has changed.)\n     *\n     * @param ID  The new time zone ID.\n     * @stable ICU 2.0\n     */\n    void setID(const UnicodeString& ID);\n\n    /**\n     * Enum for use with getDisplayName\n     * @stable ICU 2.4\n     */\n    enum EDisplayType {\n        /**\n         * Selector for short display name\n         * @stable ICU 2.4\n         */\n        SHORT = 1,\n        /**\n         * Selector for long display name\n         * @stable ICU 2.4\n         */\n        LONG,\n        /**\n         * Selector for short generic display name\n         * @stable ICU 4.4\n         */\n        SHORT_GENERIC,\n        /**\n         * Selector for long generic display name\n         * @stable ICU 4.4\n         */\n        LONG_GENERIC,\n        /**\n         * Selector for short display name derived\n         * from time zone offset\n         * @stable ICU 4.4\n         */\n        SHORT_GMT,\n        /**\n         * Selector for long display name derived\n         * from time zone offset\n         * @stable ICU 4.4\n         */\n        LONG_GMT,\n        /**\n         * Selector for short display name derived\n         * from the time zone's fallback name\n         * @stable ICU 4.4\n         */\n        SHORT_COMMONLY_USED,\n        /**\n         * Selector for long display name derived\n         * from the time zone's fallback name\n         * @stable ICU 4.4\n         */\n        GENERIC_LOCATION\n    };\n\n    /**\n     * Returns a name of this time zone suitable for presentation to the user\n     * in the default locale.\n     * This method returns the long name, not including daylight savings.\n     * If the display name is not available for the locale,\n     * then this method returns a string in the format\n     * <code>GMT[+-]hh:mm</code>.\n     * @param result the human-readable name of this time zone in the default locale.\n     * @return       A reference to 'result'.\n     * @stable ICU 2.0\n     */\n    UnicodeString& getDisplayName(UnicodeString& result) const;\n\n    /**\n     * Returns a name of this time zone suitable for presentation to the user\n     * in the specified locale.\n     * This method returns the long name, not including daylight savings.\n     * If the display name is not available for the locale,\n     * then this method returns a string in the format\n     * <code>GMT[+-]hh:mm</code>.\n     * @param locale the locale in which to supply the display name.\n     * @param result the human-readable name of this time zone in the given locale\n     *               or in the default locale if the given locale is not recognized.\n     * @return       A reference to 'result'.\n     * @stable ICU 2.0\n     */\n    UnicodeString& getDisplayName(const Locale& locale, UnicodeString& result) const;\n\n    /**\n     * Returns a name of this time zone suitable for presentation to the user\n     * in the default locale.\n     * If the display name is not available for the locale,\n     * then this method returns a string in the format\n     * <code>GMT[+-]hh:mm</code>.\n     * @param daylight if true, return the daylight savings name.\n     * @param style\n     * @param result the human-readable name of this time zone in the default locale.\n     * @return       A reference to 'result'.\n     * @stable ICU 2.0\n     */\n    UnicodeString& getDisplayName(UBool daylight, EDisplayType style, UnicodeString& result) const;\n\n    /**\n     * Returns a name of this time zone suitable for presentation to the user\n     * in the specified locale.\n     * If the display name is not available for the locale,\n     * then this method returns a string in the format\n     * <code>GMT[+-]hh:mm</code>.\n     * @param daylight if true, return the daylight savings name.\n     * @param style\n     * @param locale the locale in which to supply the display name.\n     * @param result the human-readable name of this time zone in the given locale\n     *               or in the default locale if the given locale is not recognized.\n     * @return       A refence to 'result'.\n     * @stable ICU 2.0\n     */\n    UnicodeString& getDisplayName(UBool daylight, EDisplayType style, const Locale& locale, UnicodeString& result) const;\n    \n    /**\n     * Queries if this time zone uses daylight savings time.\n     * @return true if this time zone uses daylight savings time,\n     * false, otherwise.\n     * <p><strong>Note:</strong>The default implementation of\n     * ICU TimeZone uses the tz database, which supports historic\n     * rule changes, for system time zones. With the implementation,\n     * there are time zones that used daylight savings time in the\n     * past, but no longer used currently. For example, Asia/Tokyo has\n     * never used daylight savings time since 1951. Most clients would\n     * expect that this method to return <code>FALSE</code> for such case.\n     * The default implementation of this method returns <code>TRUE</code>\n     * when the time zone uses daylight savings time in the current\n     * (Gregorian) calendar year.\n     * <p>In Java 7, <code>observesDaylightTime()</code> was added in\n     * addition to <code>useDaylightTime()</code>. In Java, <code>useDaylightTime()</code>\n     * only checks if daylight saving time is observed by the last known\n     * rule. This specification might not be what most users would expect\n     * if daylight saving time is currently observed, but not scheduled\n     * in future. In this case, Java's <code>userDaylightTime()</code> returns\n     * <code>false</code>. To resolve the issue, Java 7 added <code>observesDaylightTime()</code>,\n     * which takes the current rule into account. The method <code>observesDaylightTime()</code>\n     * was added in ICU4J for supporting API signature compatibility with JDK.\n     * In general, ICU4C also provides JDK compatible methods, but the current\n     * implementation <code>userDaylightTime()</code> serves the purpose\n     * (takes the current rule into account), <code>observesDaylightTime()</code>\n     * is not added in ICU4C. In addition to <code>useDaylightTime()</code>, ICU4C\n     * <code>BasicTimeZone</code> class (Note that <code>TimeZone::createTimeZone(const UnicodeString &ID)</code>\n     * always returns a <code>BasicTimeZone</code>) provides a series of methods allowing\n     * historic and future time zone rule iteration, so you can check if daylight saving\n     * time is observed or not within a given period.\n     * \n     * @stable ICU 2.0\n     */\n    virtual UBool useDaylightTime(void) const = 0;\n\n    /**\n     * Queries if the given date is in daylight savings time in\n     * this time zone.\n     * This method is wasteful since it creates a new GregorianCalendar and\n     * deletes it each time it is called. This is a deprecated method\n     * and provided only for Java compatibility.\n     *\n     * @param date the given UDate.\n     * @param status Output param filled in with success/error code.\n     * @return true if the given date is in daylight savings time,\n     * false, otherwise.\n     * @deprecated ICU 2.4. Use Calendar::inDaylightTime() instead.\n     */\n    virtual UBool inDaylightTime(UDate date, UErrorCode& status) const = 0;\n\n    /**\n     * Returns true if this zone has the same rule and offset as another zone.\n     * That is, if this zone differs only in ID, if at all.\n     * @param other the <code>TimeZone</code> object to be compared with\n     * @return true if the given zone is the same as this one,\n     * with the possible exception of the ID\n     * @stable ICU 2.0\n     */\n    virtual UBool hasSameRules(const TimeZone& other) const;\n\n    /**\n     * Clones TimeZone objects polymorphically. Clients are responsible for deleting\n     * the TimeZone object cloned.\n     *\n     * @return   A new copy of this TimeZone object.\n     * @stable ICU 2.0\n     */\n    virtual TimeZone* clone(void) const = 0;\n\n    /**\n     * Return the class ID for this class.  This is useful only for\n     * comparing to a return value from getDynamicClassID().\n     * @return The class ID for all objects of this class.\n     * @stable ICU 2.0\n     */\n    static UClassID U_EXPORT2 getStaticClassID(void);\n\n    /**\n     * Returns a unique class ID POLYMORPHICALLY. This method is to\n     * implement a simple version of RTTI, since not all C++ compilers support genuine\n     * RTTI. Polymorphic operator==() and clone() methods call this method.\n     * <P>\n     * Concrete subclasses of TimeZone must use the UOBJECT_DEFINE_RTTI_IMPLEMENTATION\n     *  macro from uobject.h in their implementation to provide correct RTTI information.\n     * @return   The class ID for this object. All objects of a given class have the\n     *           same class ID. Objects of other classes have different class IDs.\n     * @stable ICU 2.0\n     */\n    virtual UClassID getDynamicClassID(void) const = 0;\n    \n    /**\n     * Returns the amount of time to be added to local standard time\n     * to get local wall clock time.\n     * <p>\n     * The default implementation always returns 3600000 milliseconds\n     * (i.e., one hour) if this time zone observes Daylight Saving\n     * Time. Otherwise, 0 (zero) is returned.\n     * <p>\n     * If an underlying TimeZone implementation subclass supports\n     * historical Daylight Saving Time changes, this method returns\n     * the known latest daylight saving value.\n     *\n     * @return the amount of saving time in milliseconds\n     * @stable ICU 3.6\n     */\n    virtual int32_t getDSTSavings() const;\n\n    /**\n     * Gets the region code associated with the given\n     * system time zone ID. The region code is either ISO 3166\n     * 2-letter country code or UN M.49 3-digit area code.\n     * When the time zone is not associated with a specific location,\n     * for example - \"Etc/UTC\", \"EST5EDT\", then this method returns\n     * \"001\" (UN M.49 area code for World).\n     * \n     * @param id            The system time zone ID.\n     * @param region        Output buffer for receiving the region code.\n     * @param capacity      The size of the output buffer.\n     * @param status        Receives the status.  When the given time zone ID\n     *                      is not a known system time zone ID,\n     *                      U_ILLEGAL_ARGUMENT_ERROR is set.\n     * @return The length of the output region code.\n     * @stable ICU 4.8 \n     */ \n    static int32_t U_EXPORT2 getRegion(const UnicodeString& id, \n        char *region, int32_t capacity, UErrorCode& status); \n\nprotected:\n\n    /**\n     * Default constructor.  ID is initialized to the empty string.\n     * @stable ICU 2.0\n     */\n    TimeZone();\n\n    /**\n     * Construct a TimeZone with a given ID.\n     * @param id a system time zone ID\n     * @stable ICU 2.0\n     */\n    TimeZone(const UnicodeString &id);\n\n    /**\n     * Copy constructor.\n     * @param source the object to be copied.\n     * @stable ICU 2.0\n     */\n    TimeZone(const TimeZone& source);\n\n    /**\n     * Default assignment operator.\n     * @param right the object to be copied.\n     * @stable ICU 2.0\n     */\n    TimeZone& operator=(const TimeZone& right);\n\n#ifndef U_HIDE_INTERNAL_API\n    /**\n     * Utility function. For internally loading rule data.\n     * @param top Top resource bundle for tz data\n     * @param ruleid ID of rule to load\n     * @param oldbundle Old bundle to reuse or NULL\n     * @param status Status parameter\n     * @return either a new bundle or *oldbundle\n     * @internal\n     */\n    static UResourceBundle* loadRule(const UResourceBundle* top, const UnicodeString& ruleid, UResourceBundle* oldbundle, UErrorCode&status);\n#endif  /* U_HIDE_INTERNAL_API */\n\nprivate:\n    friend class ZoneMeta;\n\n\n    static TimeZone*        createCustomTimeZone(const UnicodeString&); // Creates a time zone based on the string.\n\n    /**\n     * Finds the given ID in the Olson tzdata. If the given ID is found in the tzdata,\n     * returns the pointer to the ID resource. This method is exposed through ZoneMeta class\n     * for ICU internal implementation and useful for building hashtable using a time zone\n     * ID as a key.\n     * @param id zone id string\n     * @return the pointer of the ID resource, or NULL.\n     */\n    static const UChar* findID(const UnicodeString& id);\n\n    /**\n     * Resolve a link in Olson tzdata.  When the given id is known and it's not a link,\n     * the id itself is returned.  When the given id is known and it is a link, then\n     * dereferenced zone id is returned.  When the given id is unknown, then it returns\n     * NULL.\n     * @param id zone id string\n     * @return the dereferenced zone or NULL\n     */\n    static const UChar* dereferOlsonLink(const UnicodeString& id);\n\n    /**\n     * Returns the region code associated with the given zone,\n     * or NULL if the zone is not known.\n     * @param id zone id string\n     * @return the region associated with the given zone\n     */\n    static const UChar* getRegion(const UnicodeString& id);\n\n    /**\n     * Returns the region code associated with the given zone,\n     * or NULL if the zone is not known.\n     * @param id zone id string\n     * @param status Status parameter\n     * @return the region associated with the given zone\n     */\n    static const UChar* getRegion(const UnicodeString& id, UErrorCode& status);\n\n    /**\n     * Parses the given custom time zone identifier\n     * @param id id A string of the form GMT[+-]hh:mm, GMT[+-]hhmm, or\n     * GMT[+-]hh.\n     * @param sign Receves parsed sign, 1 for positive, -1 for negative.\n     * @param hour Receives parsed hour field\n     * @param minute Receives parsed minute field\n     * @param second Receives parsed second field\n     * @return Returns TRUE when the given custom id is valid.\n     */\n    static UBool parseCustomID(const UnicodeString& id, int32_t& sign, int32_t& hour,\n        int32_t& minute, int32_t& second);\n\n    /**\n     * Parse a custom time zone identifier and return the normalized\n     * custom time zone identifier for the given custom id string.\n     * @param id a string of the form GMT[+-]hh:mm, GMT[+-]hhmm, or\n     * GMT[+-]hh.\n     * @param normalized Receives the normalized custom ID\n     * @param status Receives the status.  When the input ID string is invalid,\n     * U_ILLEGAL_ARGUMENT_ERROR is set.\n     * @return The normalized custom id string.\n    */\n    static UnicodeString& getCustomID(const UnicodeString& id, UnicodeString& normalized,\n        UErrorCode& status);\n\n    /**\n     * Returns the normalized custome time zone ID for the given offset fields.\n     * @param hour offset hours\n     * @param min offset minutes\n     * @param sec offset seconds\n     * @param negative sign of the offset, TRUE for negative offset.\n     * @param id Receves the format result (normalized custom ID)\n     * @return The reference to id\n     */\n    static UnicodeString& formatCustomID(int32_t hour, int32_t min, int32_t sec,\n        UBool negative, UnicodeString& id);\n\n    /**\n     * Responsible for setting up DEFAULT_ZONE.  Uses routines in TPlatformUtilities\n     * (i.e., platform-specific calls) to get the current system time zone.  Failing\n     * that, uses the platform-specific default time zone.  Failing that, uses GMT.\n     */\n    static void             initDefault(void);\n\n    // See source file for documentation\n    /**\n     * Lookup the given name in our system zone table.  If found,\n     * instantiate a new zone of that name and return it.  If not\n     * found, return 0.\n     * @param name tthe given name of a system time zone.\n     * @return the TimeZone indicated by the 'name'.\n     */\n    static TimeZone*        createSystemTimeZone(const UnicodeString& name);\n    static TimeZone*        createSystemTimeZone(const UnicodeString& name, UErrorCode& ec);\n\n    UnicodeString           fID;    // this time zone's ID\n\n    friend class TZEnumeration;\n};\n\n\n// -------------------------------------\n\ninline UnicodeString&\nTimeZone::getID(UnicodeString& ID) const\n{\n    ID = fID;\n    return ID;\n}\n\n// -------------------------------------\n\ninline void\nTimeZone::setID(const UnicodeString& ID)\n{\n    fID = ID;\n}\nU_NAMESPACE_END\n\n#endif /* #if !UCONFIG_NO_FORMATTING */\n\n#endif //_TIMEZONE\n//eof\n"
  },
  {
    "path": "deprecated/android/addons/icucompat/unicode/tmunit.h",
    "content": "/*\n *******************************************************************************\n * Copyright (C) 2009-2010, Google, International Business Machines Corporation and *\n * others. All Rights Reserved.                                                *\n *******************************************************************************\n */\n\n#ifndef __TMUNIT_H__\n#define __TMUNIT_H__\n\n\n/**\n * \\file\n * \\brief C++ API: time unit object\n */\n\n\n#include \"unicode/measunit.h\"\n\n#if !UCONFIG_NO_FORMATTING\n\nU_NAMESPACE_BEGIN\n\n/**\n * Measurement unit for time units.\n * @see TimeUnitAmount\n * @see TimeUnit\n * @stable ICU 4.2\n */\nclass U_I18N_API TimeUnit: public MeasureUnit {\npublic:\n    /**\n     * Constants for all the time units we supported.\n     * @stable ICU 4.2\n     */\n    enum UTimeUnitFields {\n        UTIMEUNIT_YEAR,\n        UTIMEUNIT_MONTH,\n        UTIMEUNIT_DAY,\n        UTIMEUNIT_WEEK,\n        UTIMEUNIT_HOUR,\n        UTIMEUNIT_MINUTE,\n        UTIMEUNIT_SECOND,\n        UTIMEUNIT_FIELD_COUNT\n    };\n\n    /**\n     * Create Instance.\n     * @param timeUnitField  time unit field based on which the instance \n     *                       is created.\n     * @param status         input-output error code. \n     *                       If the timeUnitField is invalid,\n     *                       then this will be set to U_ILLEGAL_ARGUMENT_ERROR.\n     * @return               a TimeUnit instance\n     * @stable ICU 4.2 \n     */\n    static TimeUnit* U_EXPORT2 createInstance(UTimeUnitFields timeUnitField,\n                                              UErrorCode& status);\n\n\n    /**\n     * Override clone.\n     * @stable ICU 4.2 \n     */\n    virtual UObject* clone() const;\n\n    /**\n     * Copy operator.\n     * @stable ICU 4.2 \n     */\n    TimeUnit(const TimeUnit& other);\n\n    /**\n     * Assignment operator.\n     * @stable ICU 4.2 \n     */\n    TimeUnit& operator=(const TimeUnit& other);\n\n    /**\n     * Equality operator. \n     * @return true if 2 objects are the same.\n     * @stable ICU 4.2 \n     */\n    virtual UBool operator==(const UObject& other) const;\n\n    /**\n     * Non-Equality operator. \n     * @return true if 2 objects are not the same.\n     * @stable ICU 4.2 \n     */\n    UBool operator!=(const UObject& other) const;\n\n    /**\n     * Returns a unique class ID for this object POLYMORPHICALLY.\n     * This method implements a simple form of RTTI used by ICU.\n     * @return The class ID for this object. All objects of a given\n     * class have the same class ID.  Objects of other classes have\n     * different class IDs.\n     * @stable ICU 4.2 \n     */\n    virtual UClassID getDynamicClassID() const;\n\n    /**\n     * Returns the class ID for this class. This is used to compare to\n     * the return value of getDynamicClassID().\n     * @return The class ID for all objects of this class.\n     * @stable ICU 4.2 \n     */\n    static UClassID U_EXPORT2 getStaticClassID();\n\n\n    /**\n     * Get time unit field.\n     * @return time unit field.\n     * @stable ICU 4.2 \n     */\n    UTimeUnitFields getTimeUnitField() const;\n\n    /**\n     * Destructor.\n     * @stable ICU 4.2 \n     */\n    virtual ~TimeUnit();\n\nprivate:\n    UTimeUnitFields fTimeUnitField;\n\n    /**\n     * Constructor\n     * @internal ICU 4.2 \n     */\n    TimeUnit(UTimeUnitFields timeUnitField);\n\n};\n\n\ninline UBool \nTimeUnit::operator!=(const UObject& other) const {\n    return !operator==(other);\n}\n\n\nU_NAMESPACE_END\n\n#endif /* #if !UCONFIG_NO_FORMATTING */\n\n#endif // __TMUNIT_H__\n//eof\n//\n"
  },
  {
    "path": "deprecated/android/addons/icucompat/unicode/tmutamt.h",
    "content": "/*\n *******************************************************************************\n * Copyright (C) 2009-2010, Google, International Business Machines Corporation and *\n * others. All Rights Reserved.                                                *\n *******************************************************************************\n */ \n\n#ifndef __TMUTAMT_H__\n#define __TMUTAMT_H__\n\n\n/**\n * \\file\n * \\brief C++ API: time unit amount object.\n */\n\n#include \"unicode/measure.h\"\n#include \"unicode/tmunit.h\"\n\n#if !UCONFIG_NO_FORMATTING\n\nU_NAMESPACE_BEGIN\n\n\n/**\n * Express a duration as a time unit and number. Patterned after Currency.\n * @see TimeUnitAmount\n * @see TimeUnitFormat\n * @stable ICU 4.2\n */\nclass U_I18N_API TimeUnitAmount: public Measure {\npublic:\n    /**\n     * Construct TimeUnitAmount object with the given number and the\n     * given time unit. \n     * @param number        a numeric object; number.isNumeric() must be TRUE\n     * @param timeUnitField the time unit field of a time unit\n     * @param status        the input-output error code. \n     *                      If the number is not numeric or the timeUnitField\n     *                      is not valid,\n     *                      then this will be set to a failing value:\n     *                      U_ILLEGAL_ARGUMENT_ERROR.\n     * @stable ICU 4.2\n     */\n    TimeUnitAmount(const Formattable& number, \n                   TimeUnit::UTimeUnitFields timeUnitField,\n                   UErrorCode& status);\n\n    /**\n     * Construct TimeUnitAmount object with the given numeric amount and the\n     * given time unit. \n     * @param amount        a numeric amount.\n     * @param timeUnitField the time unit field on which a time unit amount\n     *                      object will be created.\n     * @param status        the input-output error code. \n     *                      If the timeUnitField is not valid,\n     *                      then this will be set to a failing value:\n     *                      U_ILLEGAL_ARGUMENT_ERROR.\n     * @stable ICU 4.2\n     */\n    TimeUnitAmount(double amount, TimeUnit::UTimeUnitFields timeUnitField,\n                   UErrorCode& status);\n\n\n    /**\n     * Copy constructor \n     * @stable ICU 4.2\n     */\n    TimeUnitAmount(const TimeUnitAmount& other);\n\n\n    /**\n     * Assignment operator\n     * @stable ICU 4.2\n     */\n    TimeUnitAmount& operator=(const TimeUnitAmount& other);\n\n\n    /**\n     * Clone. \n     * @return a polymorphic clone of this object. The result will have the same               class as returned by getDynamicClassID().\n     * @stable ICU 4.2\n     */\n    virtual UObject* clone() const;\n\n    \n    /**\n     * Destructor\n     * @stable ICU 4.2\n     */\n    virtual ~TimeUnitAmount();\n\n    \n    /** \n     * Equality operator.  \n     * @param other  the object to compare to.\n     * @return       true if this object is equal to the given object.\n     * @stable ICU 4.2\n     */\n    virtual UBool operator==(const UObject& other) const;\n\n\n    /** \n     * Not-equality operator.  \n     * @param other  the object to compare to.\n     * @return       true if this object is not equal to the given object.\n     * @stable ICU 4.2\n     */\n    UBool operator!=(const UObject& other) const;\n\n\n    /**\n     * Return the class ID for this class. This is useful only for comparing to\n     * a return value from getDynamicClassID(). For example:\n     * <pre>\n     * .   Base* polymorphic_pointer = createPolymorphicObject();\n     * .   if (polymorphic_pointer->getDynamicClassID() ==\n     * .       erived::getStaticClassID()) ...\n     * </pre>\n     * @return          The class ID for all objects of this class.\n     * @stable ICU 4.2\n     */\n    static UClassID U_EXPORT2 getStaticClassID(void);\n\n\n    /**\n     * Returns a unique class ID POLYMORPHICALLY. Pure virtual override. This\n     * method is to implement a simple version of RTTI, since not all C++\n     * compilers support genuine RTTI. Polymorphic operator==() and clone()\n     * methods call this method.\n     *\n     * @return          The class ID for this object. All objects of a\n     *                  given class have the same class ID.  Objects of\n     *                  other classes have different class IDs.\n     * @stable ICU 4.2\n     */\n    virtual UClassID getDynamicClassID(void) const;\n\n\n    /**\n     * Get the time unit.\n     * @return time unit object.\n     * @stable ICU 4.2\n     */\n    const TimeUnit& getTimeUnit() const;\n\n    /**\n     * Get the time unit field value.\n     * @return time unit field value.\n     * @stable ICU 4.2\n     */\n    TimeUnit::UTimeUnitFields getTimeUnitField() const;\n};\n\n\n\ninline UBool \nTimeUnitAmount::operator!=(const UObject& other) const {\n    return !operator==(other);\n}\n\nU_NAMESPACE_END\n\n#endif /* #if !UCONFIG_NO_FORMATTING */\n\n#endif // __TMUTAMT_H__\n//eof\n//\n"
  },
  {
    "path": "deprecated/android/addons/icucompat/unicode/tmutfmt.h",
    "content": "/*\n *******************************************************************************\n * Copyright (C) 2008-2012, Google, International Business Machines Corporation\n * and others. All Rights Reserved.\n *******************************************************************************\n */\n\n#ifndef __TMUTFMT_H__\n#define __TMUTFMT_H__\n\n#include \"unicode/utypes.h\"\n\n/**\n * \\file\n * \\brief C++ API: Format and parse duration in single time unit\n */\n\n\n#if !UCONFIG_NO_FORMATTING\n\n#include \"unicode/unistr.h\"\n#include \"unicode/tmunit.h\"\n#include \"unicode/tmutamt.h\"\n#include \"unicode/measfmt.h\"\n#include \"unicode/numfmt.h\"\n#include \"unicode/plurrule.h\"\n\n/**\n * Constants for various styles.\n * There are 2 styles: full name and abbreviated name.\n * For example, for English, the full name for hour duration is \"3 hours\",\n * and the abbreviated name is \"3 hrs\".\n * @stable ICU 4.8\n */\nenum UTimeUnitFormatStyle {\n    /** @stable ICU 4.8 */\n    UTMUTFMT_FULL_STYLE,\n    /** @stable ICU 4.8 */\n    UTMUTFMT_ABBREVIATED_STYLE,\n    /** @stable ICU 4.8 */\n    UTMUTFMT_FORMAT_STYLE_COUNT\n};\ntypedef enum UTimeUnitFormatStyle UTimeUnitFormatStyle; /**< @stable ICU 4.8 */\n\nU_NAMESPACE_BEGIN\n\nclass Hashtable;\nclass UVector;\n\n/**\n * Format or parse a TimeUnitAmount, using plural rules for the units where available.\n *\n * <P>\n * Code Sample:\n * <pre>\n *   // create time unit amount instance - a combination of Number and time unit\n *   UErrorCode status = U_ZERO_ERROR;\n *   TimeUnitAmount* source = new TimeUnitAmount(2, TimeUnit::UTIMEUNIT_YEAR, status);\n *   // create time unit format instance\n *   TimeUnitFormat* format = new TimeUnitFormat(Locale(\"en\"), status);\n *   // format a time unit amount\n *   UnicodeString formatted;\n *   Formattable formattable;\n *   if (U_SUCCESS(status)) {\n *       formattable.adoptObject(source);\n *       formatted = ((Format*)format)->format(formattable, formatted, status);\n *       Formattable result;\n *       ((Format*)format)->parseObject(formatted, result, status);\n *       if (U_SUCCESS(status)) {\n *           assert (result == formattable);\n *       }\n *   }\n * </pre>\n *\n * <P>\n * @see TimeUnitAmount\n * @see TimeUnitFormat\n * @stable ICU 4.2\n */\nclass U_I18N_API TimeUnitFormat: public MeasureFormat {\npublic:\n\n    /**\n     * Create TimeUnitFormat with default locale, and full name style.\n     * Use setLocale and/or setFormat to modify.\n     * @stable ICU 4.2\n     */\n    TimeUnitFormat(UErrorCode& status);\n\n    /**\n     * Create TimeUnitFormat given locale, and full name style.\n     * @stable ICU 4.2\n     */\n    TimeUnitFormat(const Locale& locale, UErrorCode& status);\n\n    /**\n     * Create TimeUnitFormat given locale and style.\n     * @stable ICU 4.8\n     */\n    TimeUnitFormat(const Locale& locale, UTimeUnitFormatStyle style, UErrorCode& status);\n\n    /**\n     * Copy constructor.\n     * @stable ICU 4.2\n     */\n    TimeUnitFormat(const TimeUnitFormat&);\n\n    /**\n     * deconstructor\n     * @stable ICU 4.2\n     */\n    virtual ~TimeUnitFormat();\n\n    /**\n     * Clone this Format object polymorphically. The caller owns the result and\n     * should delete it when done.\n     * @return    A copy of the object.\n     * @stable ICU 4.2\n     */\n    virtual Format* clone(void) const;\n\n    /**\n     * Assignment operator\n     * @stable ICU 4.2\n     */\n    TimeUnitFormat& operator=(const TimeUnitFormat& other);\n\n\n    /**\n     * Return true if the given Format objects are semantically equal. Objects\n     * of different subclasses are considered unequal.\n     * @param other    the object to be compared with.\n     * @return         true if the given Format objects are semantically equal.\n     * @stable ICU 4.2\n     */\n    virtual UBool operator==(const Format& other) const;\n\n    /**\n     * Return true if the given Format objects are not semantically equal.\n     * Objects of different subclasses are considered unequal.\n     * @param other the object to be compared with.\n     * @return      true if the given Format objects are not semantically equal.\n     * @stable ICU 4.2\n     */\n    UBool operator!=(const Format& other) const;\n\n    /**\n     * Set the locale used for formatting or parsing.\n     * @param locale  the locale to be set\n     * @param status  output param set to success/failure code on exit\n     * @stable ICU 4.2\n     */\n    void setLocale(const Locale& locale, UErrorCode& status);\n\n\n    /**\n     * Set the number format used for formatting or parsing.\n     * @param format  the number formatter to be set\n     * @param status  output param set to success/failure code on exit\n     * @stable ICU 4.2\n     */\n    void setNumberFormat(const NumberFormat& format, UErrorCode& status);\n\n\n    using MeasureFormat::format;\n\n    /**\n     * Format a TimeUnitAmount.\n     * If the formattable object is not a time unit amount object,\n     * or the number in time unit amount is not a double type or long type\n     * numeric, it returns a failing status: U_ILLEGAL_ARGUMENT_ERROR.\n     * @see Format#format(const Formattable&, UnicodeString&, FieldPosition&,  UErrorCode&) const\n     * @stable ICU 4.2\n     */\n    virtual UnicodeString& format(const Formattable& obj,\n                                  UnicodeString& toAppendTo,\n                                  FieldPosition& pos,\n                                  UErrorCode& status) const;\n\n    /**\n     * Parse a TimeUnitAmount.\n     * @see Format#parseObject(const UnicodeString&, Formattable&, ParsePosition&) const;\n     * @stable ICU 4.2\n     */\n    virtual void parseObject(const UnicodeString& source,\n                             Formattable& result,\n                             ParsePosition& pos) const;\n\n    /**\n     * Return the class ID for this class. This is useful only for comparing to\n     * a return value from getDynamicClassID(). For example:\n     * <pre>\n     * .   Base* polymorphic_pointer = createPolymorphicObject();\n     * .   if (polymorphic_pointer->getDynamicClassID() ==\n     * .       erived::getStaticClassID()) ...\n     * </pre>\n     * @return          The class ID for all objects of this class.\n     * @stable ICU 4.2\n     */\n    static UClassID U_EXPORT2 getStaticClassID(void);\n\n    /**\n     * Returns a unique class ID POLYMORPHICALLY. Pure virtual override. This\n     * method is to implement a simple version of RTTI, since not all C++\n     * compilers support genuine RTTI. Polymorphic operator==() and clone()\n     * methods call this method.\n     *\n     * @return          The class ID for this object. All objects of a\n     *                  given class have the same class ID.  Objects of\n     *                  other classes have different class IDs.\n     * @stable ICU 4.2\n     */\n    virtual UClassID getDynamicClassID(void) const;\n\nprivate:\n    NumberFormat* fNumberFormat;\n    Locale        fLocale;\n    Hashtable*    fTimeUnitToCountToPatterns[TimeUnit::UTIMEUNIT_FIELD_COUNT];\n    PluralRules*  fPluralRules;\n    UTimeUnitFormatStyle fStyle;\n\n    void create(const Locale& locale, UTimeUnitFormatStyle style, UErrorCode& status);\n\n    // it might actually be simpler to make them Decimal Formats later.\n    // initialize all private data members\n    void setup(UErrorCode& status);\n\n    // initialize data member without fill in data for fTimeUnitToCountToPattern\n    void initDataMembers(UErrorCode& status);\n\n    // initialize fTimeUnitToCountToPatterns from current locale's resource.\n    void readFromCurrentLocale(UTimeUnitFormatStyle style, const char* key, const UVector& pluralCounts,\n                               UErrorCode& status);\n\n    // check completeness of fTimeUnitToCountToPatterns against all time units,\n    // and all plural rules, fill in fallback as necessary.\n    void checkConsistency(UTimeUnitFormatStyle style, const char* key, UErrorCode& status);\n\n    // fill in fTimeUnitToCountToPatterns from locale fall-back chain\n    void searchInLocaleChain(UTimeUnitFormatStyle style, const char* key, const char* localeName,\n                             TimeUnit::UTimeUnitFields field, const UnicodeString&,\n                             const char*, Hashtable*, UErrorCode&);\n\n    // initialize hash table\n    Hashtable* initHash(UErrorCode& status);\n\n    // delete hash table\n    void deleteHash(Hashtable* htable);\n\n    // copy hash table\n    void copyHash(const Hashtable* source, Hashtable* target, UErrorCode& status);\n    // get time unit name, such as \"year\", from time unit field enum, such as\n    // UTIMEUNIT_YEAR.\n    static const char* getTimeUnitName(TimeUnit::UTimeUnitFields field, UErrorCode& status);\n};\n\n\n\ninline UBool\nTimeUnitFormat::operator!=(const Format& other) const  {\n    return !operator==(other);\n}\n\n\n\nU_NAMESPACE_END\n\n#endif /* #if !UCONFIG_NO_FORMATTING */\n\n#endif // __TMUTFMT_H__\n//eof\n"
  },
  {
    "path": "deprecated/android/addons/icucompat/unicode/translit.h",
    "content": "/*\n**********************************************************************\n* Copyright (C) 1999-2012, International Business Machines\n* Corporation and others. All Rights Reserved.\n**********************************************************************\n*   Date        Name        Description\n*   11/17/99    aliu        Creation.\n**********************************************************************\n*/\n#ifndef TRANSLIT_H\n#define TRANSLIT_H\n\n#include \"unicode/utypes.h\"\n\n/**\n * \\file \n * \\brief C++ API: Tranforms text from one format to another.\n */\n \n#if !UCONFIG_NO_TRANSLITERATION\n\n#include \"unicode/uobject.h\"\n#include \"unicode/unistr.h\"\n#include \"unicode/parseerr.h\"\n#include \"unicode/utrans.h\" // UTransPosition, UTransDirection\n#include \"unicode/strenum.h\"\n\nU_NAMESPACE_BEGIN\n\nclass UnicodeFilter;\nclass UnicodeSet;\nclass CompoundTransliterator;\nclass TransliteratorParser;\nclass NormalizationTransliterator;\nclass TransliteratorIDParser;\n\n/**\n *\n * <code>Transliterator</code> is an abstract class that\n * transliterates text from one format to another.  The most common\n * kind of transliterator is a script, or alphabet, transliterator.\n * For example, a Russian to Latin transliterator changes Russian text\n * written in Cyrillic characters to phonetically equivalent Latin\n * characters.  It does not <em>translate</em> Russian to English!\n * Transliteration, unlike translation, operates on characters, without\n * reference to the meanings of words and sentences.\n *\n * <p>Although script conversion is its most common use, a\n * transliterator can actually perform a more general class of tasks.\n * In fact, <code>Transliterator</code> defines a very general API\n * which specifies only that a segment of the input text is replaced\n * by new text.  The particulars of this conversion are determined\n * entirely by subclasses of <code>Transliterator</code>.\n *\n * <p><b>Transliterators are stateless</b>\n *\n * <p><code>Transliterator</code> objects are <em>stateless</em>; they\n * retain no information between calls to\n * <code>transliterate()</code>.  (However, this does <em>not</em>\n * mean that threads may share transliterators without synchronizing\n * them.  Transliterators are not immutable, so they must be\n * synchronized when shared between threads.)  This might seem to\n * limit the complexity of the transliteration operation.  In\n * practice, subclasses perform complex transliterations by delaying\n * the replacement of text until it is known that no other\n * replacements are possible.  In other words, although the\n * <code>Transliterator</code> objects are stateless, the source text\n * itself embodies all the needed information, and delayed operation\n * allows arbitrary complexity.\n *\n * <p><b>Batch transliteration</b>\n *\n * <p>The simplest way to perform transliteration is all at once, on a\n * string of existing text.  This is referred to as <em>batch</em>\n * transliteration.  For example, given a string <code>input</code>\n * and a transliterator <code>t</code>, the call\n *\n * \\htmlonly<blockquote>\\endhtmlonly<code>String result = t.transliterate(input);\n * </code>\\htmlonly</blockquote>\\endhtmlonly\n *\n * will transliterate it and return the result.  Other methods allow\n * the client to specify a substring to be transliterated and to use\n * {@link Replaceable } objects instead of strings, in order to\n * preserve out-of-band information (such as text styles).\n *\n * <p><b>Keyboard transliteration</b>\n *\n * <p>Somewhat more involved is <em>keyboard</em>, or incremental\n * transliteration.  This is the transliteration of text that is\n * arriving from some source (typically the user's keyboard) one\n * character at a time, or in some other piecemeal fashion.\n *\n * <p>In keyboard transliteration, a <code>Replaceable</code> buffer\n * stores the text.  As text is inserted, as much as possible is\n * transliterated on the fly.  This means a GUI that displays the\n * contents of the buffer may show text being modified as each new\n * character arrives.\n *\n * <p>Consider the simple <code>RuleBasedTransliterator</code>:\n *\n * \\htmlonly<blockquote>\\endhtmlonly<code>\n * th&gt;{theta}<br>\n * t&gt;{tau}\n * </code>\\htmlonly</blockquote>\\endhtmlonly\n *\n * When the user types 't', nothing will happen, since the\n * transliterator is waiting to see if the next character is 'h'.  To\n * remedy this, we introduce the notion of a cursor, marked by a '|'\n * in the output string:\n *\n * \\htmlonly<blockquote>\\endhtmlonly<code>\n * t&gt;|{tau}<br>\n * {tau}h&gt;{theta}\n * </code>\\htmlonly</blockquote>\\endhtmlonly\n *\n * Now when the user types 't', tau appears, and if the next character\n * is 'h', the tau changes to a theta.  This is accomplished by\n * maintaining a cursor position (independent of the insertion point,\n * and invisible in the GUI) across calls to\n * <code>transliterate()</code>.  Typically, the cursor will\n * be coincident with the insertion point, but in a case like the one\n * above, it will precede the insertion point.\n *\n * <p>Keyboard transliteration methods maintain a set of three indices\n * that are updated with each call to\n * <code>transliterate()</code>, including the cursor, start,\n * and limit.  Since these indices are changed by the method, they are\n * passed in an <code>int[]</code> array. The <code>START</code> index\n * marks the beginning of the substring that the transliterator will\n * look at.  It is advanced as text becomes committed (but it is not\n * the committed index; that's the <code>CURSOR</code>).  The\n * <code>CURSOR</code> index, described above, marks the point at\n * which the transliterator last stopped, either because it reached\n * the end, or because it required more characters to disambiguate\n * between possible inputs.  The <code>CURSOR</code> can also be\n * explicitly set by rules in a <code>RuleBasedTransliterator</code>.\n * Any characters before the <code>CURSOR</code> index are frozen;\n * future keyboard transliteration calls within this input sequence\n * will not change them.  New text is inserted at the\n * <code>LIMIT</code> index, which marks the end of the substring that\n * the transliterator looks at.\n *\n * <p>Because keyboard transliteration assumes that more characters\n * are to arrive, it is conservative in its operation.  It only\n * transliterates when it can do so unambiguously.  Otherwise it waits\n * for more characters to arrive.  When the client code knows that no\n * more characters are forthcoming, perhaps because the user has\n * performed some input termination operation, then it should call\n * <code>finishTransliteration()</code> to complete any\n * pending transliterations.\n *\n * <p><b>Inverses</b>\n *\n * <p>Pairs of transliterators may be inverses of one another.  For\n * example, if transliterator <b>A</b> transliterates characters by\n * incrementing their Unicode value (so \"abc\" -> \"def\"), and\n * transliterator <b>B</b> decrements character values, then <b>A</b>\n * is an inverse of <b>B</b> and vice versa.  If we compose <b>A</b>\n * with <b>B</b> in a compound transliterator, the result is the\n * indentity transliterator, that is, a transliterator that does not\n * change its input text.\n *\n * The <code>Transliterator</code> method <code>getInverse()</code>\n * returns a transliterator's inverse, if one exists, or\n * <code>null</code> otherwise.  However, the result of\n * <code>getInverse()</code> usually will <em>not</em> be a true\n * mathematical inverse.  This is because true inverse transliterators\n * are difficult to formulate.  For example, consider two\n * transliterators: <b>AB</b>, which transliterates the character 'A'\n * to 'B', and <b>BA</b>, which transliterates 'B' to 'A'.  It might\n * seem that these are exact inverses, since\n *\n * \\htmlonly<blockquote>\\endhtmlonly\"A\" x <b>AB</b> -> \"B\"<br>\n * \"B\" x <b>BA</b> -> \"A\"\\htmlonly</blockquote>\\endhtmlonly\n *\n * where 'x' represents transliteration.  However,\n *\n * \\htmlonly<blockquote>\\endhtmlonly\"ABCD\" x <b>AB</b> -> \"BBCD\"<br>\n * \"BBCD\" x <b>BA</b> -> \"AACD\"\\htmlonly</blockquote>\\endhtmlonly\n *\n * so <b>AB</b> composed with <b>BA</b> is not the\n * identity. Nonetheless, <b>BA</b> may be usefully considered to be\n * <b>AB</b>'s inverse, and it is on this basis that\n * <b>AB</b><code>.getInverse()</code> could legitimately return\n * <b>BA</b>.\n *\n * <p><b>IDs and display names</b>\n *\n * <p>A transliterator is designated by a short identifier string or\n * <em>ID</em>.  IDs follow the format <em>source-destination</em>,\n * where <em>source</em> describes the entity being replaced, and\n * <em>destination</em> describes the entity replacing\n * <em>source</em>.  The entities may be the names of scripts,\n * particular sequences of characters, or whatever else it is that the\n * transliterator converts to or from.  For example, a transliterator\n * from Russian to Latin might be named \"Russian-Latin\".  A\n * transliterator from keyboard escape sequences to Latin-1 characters\n * might be named \"KeyboardEscape-Latin1\".  By convention, system\n * entity names are in English, with the initial letters of words\n * capitalized; user entity names may follow any format so long as\n * they do not contain dashes.\n *\n * <p>In addition to programmatic IDs, transliterator objects have\n * display names for presentation in user interfaces, returned by\n * {@link #getDisplayName }.\n *\n * <p><b>Factory methods and registration</b>\n *\n * <p>In general, client code should use the factory method\n * {@link #createInstance } to obtain an instance of a\n * transliterator given its ID.  Valid IDs may be enumerated using\n * <code>getAvailableIDs()</code>.  Since transliterators are mutable,\n * multiple calls to {@link #createInstance } with the same ID will\n * return distinct objects.\n *\n * <p>In addition to the system transliterators registered at startup,\n * user transliterators may be registered by calling\n * <code>registerInstance()</code> at run time.  A registered instance\n * acts a template; future calls to {@link #createInstance } with the ID\n * of the registered object return clones of that object.  Thus any\n * object passed to <tt>registerInstance()</tt> must implement\n * <tt>clone()</tt> propertly.  To register a transliterator subclass\n * without instantiating it (until it is needed), users may call\n * {@link #registerFactory }.  In this case, the objects are\n * instantiated by invoking the zero-argument public constructor of\n * the class.\n *\n * <p><b>Subclassing</b>\n *\n * Subclasses must implement the abstract method\n * <code>handleTransliterate()</code>.  <p>Subclasses should override\n * the <code>transliterate()</code> method taking a\n * <code>Replaceable</code> and the <code>transliterate()</code>\n * method taking a <code>String</code> and <code>StringBuffer</code>\n * if the performance of these methods can be improved over the\n * performance obtained by the default implementations in this class.\n *\n * @author Alan Liu\n * @stable ICU 2.0\n */\nclass U_I18N_API Transliterator : public UObject {\n\nprivate:\n\n    /**\n     * Programmatic name, e.g., \"Latin-Arabic\".\n     */\n    UnicodeString ID;\n\n    /**\n     * This transliterator's filter.  Any character for which\n     * <tt>filter.contains()</tt> returns <tt>false</tt> will not be\n     * altered by this transliterator.  If <tt>filter</tt> is\n     * <tt>null</tt> then no filtering is applied.\n     */\n    UnicodeFilter* filter;\n\n    int32_t maximumContextLength;\n\n public:\n\n    /**\n     * A context integer or pointer for a factory function, passed by\n     * value.\n     * @stable ICU 2.4\n     */\n    union Token {\n        /**\n         * This token, interpreted as a 32-bit integer.\n         * @stable ICU 2.4\n         */\n        int32_t integer;\n        /**\n         * This token, interpreted as a native pointer.\n         * @stable ICU 2.4\n         */\n        void*   pointer;\n    };\n\n#ifndef U_HIDE_INTERNAL_API\n    /**\n     * Return a token containing an integer.\n     * @return a token containing an integer.\n     * @internal\n     */\n    inline static Token integerToken(int32_t);\n\n    /**\n     * Return a token containing a pointer.\n     * @return a token containing a pointer.\n     * @internal\n     */\n    inline static Token pointerToken(void*);\n#endif  /* U_HIDE_INTERNAL_API */\n\n    /**\n     * A function that creates and returns a Transliterator.  When\n     * invoked, it will be passed the ID string that is being\n     * instantiated, together with the context pointer that was passed\n     * in when the factory function was first registered.  Many\n     * factory functions will ignore both parameters, however,\n     * functions that are registered to more than one ID may use the\n     * ID or the context parameter to parameterize the transliterator\n     * they create.\n     * @param ID      the string identifier for this transliterator\n     * @param context a context pointer that will be stored and\n     *                later passed to the factory function when an ID matching\n     *                the registration ID is being instantiated with this factory.\n     * @stable ICU 2.4\n     */\n    typedef Transliterator* (U_EXPORT2 *Factory)(const UnicodeString& ID, Token context);\n\nprotected:\n\n    /**\n     * Default constructor.\n     * @param ID the string identifier for this transliterator\n     * @param adoptedFilter the filter.  Any character for which\n     * <tt>filter.contains()</tt> returns <tt>false</tt> will not be\n     * altered by this transliterator.  If <tt>filter</tt> is\n     * <tt>null</tt> then no filtering is applied.\n     * @stable ICU 2.4\n     */\n    Transliterator(const UnicodeString& ID, UnicodeFilter* adoptedFilter);\n\n    /**\n     * Copy constructor.\n     * @stable ICU 2.4\n     */\n    Transliterator(const Transliterator&);\n\n    /**\n     * Assignment operator.\n     * @stable ICU 2.4\n     */\n    Transliterator& operator=(const Transliterator&);\n\n    /**\n     * Create a transliterator from a basic ID.  This is an ID\n     * containing only the forward direction source, target, and\n     * variant.\n     * @param id a basic ID of the form S-T or S-T/V.\n     * @param canon canonical ID to assign to the object, or\n     * NULL to leave the ID unchanged\n     * @return a newly created Transliterator or null if the ID is\n     * invalid.\n     * @stable ICU 2.4\n     */\n    static Transliterator* createBasicInstance(const UnicodeString& id,\n                                               const UnicodeString* canon);\n\n    friend class TransliteratorParser; // for parseID()\n    friend class TransliteratorIDParser; // for createBasicInstance()\n    friend class TransliteratorAlias; // for setID()\n\npublic:\n\n    /**\n     * Destructor.\n     * @stable ICU 2.0\n     */\n    virtual ~Transliterator();\n\n    /**\n     * Implements Cloneable.\n     * All subclasses are encouraged to implement this method if it is\n     * possible and reasonable to do so.  Subclasses that are to be\n     * registered with the system using <tt>registerInstance()</tt>\n     * are required to implement this method.  If a subclass does not\n     * implement clone() properly and is registered with the system\n     * using registerInstance(), then the default clone() implementation\n     * will return null, and calls to createInstance() will fail.\n     *\n     * @return a copy of the object.\n     * @see #registerInstance\n     * @stable ICU 2.0\n     */\n    virtual Transliterator* clone() const;\n\n    /**\n     * Transliterates a segment of a string, with optional filtering.\n     *\n     * @param text the string to be transliterated\n     * @param start the beginning index, inclusive; <code>0 <= start\n     * <= limit</code>.\n     * @param limit the ending index, exclusive; <code>start <= limit\n     * <= text.length()</code>.\n     * @return The new limit index.  The text previously occupying <code>[start,\n     * limit)</code> has been transliterated, possibly to a string of a different\n     * length, at <code>[start, </code><em>new-limit</em><code>)</code>, where\n     * <em>new-limit</em> is the return value. If the input offsets are out of bounds,\n     * the returned value is -1 and the input string remains unchanged.\n     * @stable ICU 2.0\n     */\n    virtual int32_t transliterate(Replaceable& text,\n                                  int32_t start, int32_t limit) const;\n\n    /**\n     * Transliterates an entire string in place. Convenience method.\n     * @param text the string to be transliterated\n     * @stable ICU 2.0\n     */\n    virtual void transliterate(Replaceable& text) const;\n\n    /**\n     * Transliterates the portion of the text buffer that can be\n     * transliterated unambiguosly after new text has been inserted,\n     * typically as a result of a keyboard event.  The new text in\n     * <code>insertion</code> will be inserted into <code>text</code>\n     * at <code>index.limit</code>, advancing\n     * <code>index.limit</code> by <code>insertion.length()</code>.\n     * Then the transliterator will try to transliterate characters of\n     * <code>text</code> between <code>index.cursor</code> and\n     * <code>index.limit</code>.  Characters before\n     * <code>index.cursor</code> will not be changed.\n     *\n     * <p>Upon return, values in <code>index</code> will be updated.\n     * <code>index.start</code> will be advanced to the first\n     * character that future calls to this method will read.\n     * <code>index.cursor</code> and <code>index.limit</code> will\n     * be adjusted to delimit the range of text that future calls to\n     * this method may change.\n     *\n     * <p>Typical usage of this method begins with an initial call\n     * with <code>index.start</code> and <code>index.limit</code>\n     * set to indicate the portion of <code>text</code> to be\n     * transliterated, and <code>index.cursor == index.start</code>.\n     * Thereafter, <code>index</code> can be used without\n     * modification in future calls, provided that all changes to\n     * <code>text</code> are made via this method.\n     *\n     * <p>This method assumes that future calls may be made that will\n     * insert new text into the buffer.  As a result, it only performs\n     * unambiguous transliterations.  After the last call to this\n     * method, there may be untransliterated text that is waiting for\n     * more input to resolve an ambiguity.  In order to perform these\n     * pending transliterations, clients should call {@link\n     * #finishTransliteration } after the last call to this\n     * method has been made.\n     *\n     * @param text the buffer holding transliterated and untransliterated text\n     * @param index an array of three integers.\n     *\n     * <ul><li><code>index.start</code>: the beginning index,\n     * inclusive; <code>0 <= index.start <= index.limit</code>.\n     *\n     * <li><code>index.limit</code>: the ending index, exclusive;\n     * <code>index.start <= index.limit <= text.length()</code>.\n     * <code>insertion</code> is inserted at\n     * <code>index.limit</code>.\n     *\n     * <li><code>index.cursor</code>: the next character to be\n     * considered for transliteration; <code>index.start <=\n     * index.cursor <= index.limit</code>.  Characters before\n     * <code>index.cursor</code> will not be changed by future calls\n     * to this method.</ul>\n     *\n     * @param insertion text to be inserted and possibly\n     * transliterated into the translation buffer at\n     * <code>index.limit</code>.  If <code>null</code> then no text\n     * is inserted.\n     * @param status    Output param to filled in with a success or an error.\n     * @see #handleTransliterate\n     * @exception IllegalArgumentException if <code>index</code>\n     * is invalid\n     * @see UTransPosition\n     * @stable ICU 2.0\n     */\n    virtual void transliterate(Replaceable& text, UTransPosition& index,\n                               const UnicodeString& insertion,\n                               UErrorCode& status) const;\n\n    /**\n     * Transliterates the portion of the text buffer that can be\n     * transliterated unambiguosly after a new character has been\n     * inserted, typically as a result of a keyboard event.  This is a\n     * convenience method.\n     * @param text the buffer holding transliterated and\n     * untransliterated text\n     * @param index an array of three integers.\n     * @param insertion text to be inserted and possibly\n     * transliterated into the translation buffer at\n     * <code>index.limit</code>.\n     * @param status    Output param to filled in with a success or an error.\n     * @see #transliterate(Replaceable&, UTransPosition&, const UnicodeString&, UErrorCode&) const\n     * @stable ICU 2.0\n     */\n    virtual void transliterate(Replaceable& text, UTransPosition& index,\n                               UChar32 insertion,\n                               UErrorCode& status) const;\n\n    /**\n     * Transliterates the portion of the text buffer that can be\n     * transliterated unambiguosly.  This is a convenience method; see\n     * {@link\n     * #transliterate(Replaceable&, UTransPosition&, const UnicodeString&, UErrorCode&) const }\n     * for details.\n     * @param text the buffer holding transliterated and\n     * untransliterated text\n     * @param index an array of three integers.  See {@link #transliterate(Replaceable&, UTransPosition&, const UnicodeString*, UErrorCode&) const }.\n     * @param status    Output param to filled in with a success or an error.\n     * @see #transliterate(Replaceable, int[], String)\n     * @stable ICU 2.0\n     */\n    virtual void transliterate(Replaceable& text, UTransPosition& index,\n                               UErrorCode& status) const;\n\n    /**\n     * Finishes any pending transliterations that were waiting for\n     * more characters.  Clients should call this method as the last\n     * call after a sequence of one or more calls to\n     * <code>transliterate()</code>.\n     * @param text the buffer holding transliterated and\n     * untransliterated text.\n     * @param index the array of indices previously passed to {@link\n     * #transliterate }\n     * @stable ICU 2.0\n     */\n    virtual void finishTransliteration(Replaceable& text,\n                                       UTransPosition& index) const;\n\nprivate:\n\n    /**\n     * This internal method does incremental transliteration.  If the\n     * 'insertion' is non-null then we append it to 'text' before\n     * proceeding.  This method calls through to the pure virtual\n     * framework method handleTransliterate() to do the actual\n     * work.\n     * @param text the buffer holding transliterated and\n     * untransliterated text\n     * @param index an array of three integers.  See {@link\n     * #transliterate(Replaceable, int[], String)}.\n     * @param insertion text to be inserted and possibly\n     * transliterated into the translation buffer at\n     * <code>index.limit</code>.\n     * @param status    Output param to filled in with a success or an error.\n     */\n    void _transliterate(Replaceable& text,\n                        UTransPosition& index,\n                        const UnicodeString* insertion,\n                        UErrorCode &status) const;\n\nprotected:\n\n    /**\n     * Abstract method that concrete subclasses define to implement\n     * their transliteration algorithm.  This method handles both\n     * incremental and non-incremental transliteration.  Let\n     * <code>originalStart</code> refer to the value of\n     * <code>pos.start</code> upon entry.\n     *\n     * <ul>\n     *  <li>If <code>incremental</code> is false, then this method\n     *  should transliterate all characters between\n     *  <code>pos.start</code> and <code>pos.limit</code>. Upon return\n     *  <code>pos.start</code> must == <code> pos.limit</code>.</li>\n     *\n     *  <li>If <code>incremental</code> is true, then this method\n     *  should transliterate all characters between\n     *  <code>pos.start</code> and <code>pos.limit</code> that can be\n     *  unambiguously transliterated, regardless of future insertions\n     *  of text at <code>pos.limit</code>.  Upon return,\n     *  <code>pos.start</code> should be in the range\n     *  [<code>originalStart</code>, <code>pos.limit</code>).\n     *  <code>pos.start</code> should be positioned such that\n     *  characters [<code>originalStart</code>, <code>\n     *  pos.start</code>) will not be changed in the future by this\n     *  transliterator and characters [<code>pos.start</code>,\n     *  <code>pos.limit</code>) are unchanged.</li>\n     * </ul>\n     *\n     * <p>Implementations of this method should also obey the\n     * following invariants:</p>\n     *\n     * <ul>\n     *  <li> <code>pos.limit</code> and <code>pos.contextLimit</code>\n     *  should be updated to reflect changes in length of the text\n     *  between <code>pos.start</code> and <code>pos.limit</code>. The\n     *  difference <code> pos.contextLimit - pos.limit</code> should\n     *  not change.</li>\n     *\n     *  <li><code>pos.contextStart</code> should not change.</li>\n     *\n     *  <li>Upon return, neither <code>pos.start</code> nor\n     *  <code>pos.limit</code> should be less than\n     *  <code>originalStart</code>.</li>\n     *\n     *  <li>Text before <code>originalStart</code> and text after\n     *  <code>pos.limit</code> should not change.</li>\n     *\n     *  <li>Text before <code>pos.contextStart</code> and text after\n     *  <code> pos.contextLimit</code> should be ignored.</li>\n     * </ul>\n     *\n     * <p>Subclasses may safely assume that all characters in\n     * [<code>pos.start</code>, <code>pos.limit</code>) are filtered.\n     * In other words, the filter has already been applied by the time\n     * this method is called.  See\n     * <code>filteredTransliterate()</code>.\n     *\n     * <p>This method is <b>not</b> for public consumption.  Calling\n     * this method directly will transliterate\n     * [<code>pos.start</code>, <code>pos.limit</code>) without\n     * applying the filter. End user code should call <code>\n     * transliterate()</code> instead of this method. Subclass code\n     * and wrapping transliterators should call\n     * <code>filteredTransliterate()</code> instead of this method.<p>\n     *\n     * @param text the buffer holding transliterated and\n     * untransliterated text\n     *\n     * @param pos the indices indicating the start, limit, context\n     * start, and context limit of the text.\n     *\n     * @param incremental if true, assume more text may be inserted at\n     * <code>pos.limit</code> and act accordingly.  Otherwise,\n     * transliterate all text between <code>pos.start</code> and\n     * <code>pos.limit</code> and move <code>pos.start</code> up to\n     * <code>pos.limit</code>.\n     *\n     * @see #transliterate\n     * @stable ICU 2.4\n     */\n    virtual void handleTransliterate(Replaceable& text,\n                                     UTransPosition& pos,\n                                     UBool incremental) const = 0;\n\npublic:\n    /**\n     * Transliterate a substring of text, as specified by index, taking filters\n     * into account.  This method is for subclasses that need to delegate to\n     * another transliterator, such as CompoundTransliterator.\n     * @param text the text to be transliterated\n     * @param index the position indices\n     * @param incremental if TRUE, then assume more characters may be inserted\n     * at index.limit, and postpone processing to accomodate future incoming\n     * characters\n     * @stable ICU 2.4\n     */\n    virtual void filteredTransliterate(Replaceable& text,\n                                       UTransPosition& index,\n                                       UBool incremental) const;\n\nprivate:\n\n    /**\n     * Top-level transliteration method, handling filtering, incremental and\n     * non-incremental transliteration, and rollback.  All transliteration\n     * public API methods eventually call this method with a rollback argument\n     * of TRUE.  Other entities may call this method but rollback should be\n     * FALSE.\n     *\n     * <p>If this transliterator has a filter, break up the input text into runs\n     * of unfiltered characters.  Pass each run to\n     * subclass.handleTransliterate().\n     *\n     * <p>In incremental mode, if rollback is TRUE, perform a special\n     * incremental procedure in which several passes are made over the input\n     * text, adding one character at a time, and committing successful\n     * transliterations as they occur.  Unsuccessful transliterations are rolled\n     * back and retried with additional characters to give correct results.\n     *\n     * @param text the text to be transliterated\n     * @param index the position indices\n     * @param incremental if TRUE, then assume more characters may be inserted\n     * at index.limit, and postpone processing to accomodate future incoming\n     * characters\n     * @param rollback if TRUE and if incremental is TRUE, then perform special\n     * incremental processing, as described above, and undo partial\n     * transliterations where necessary.  If incremental is FALSE then this\n     * parameter is ignored.\n     */\n    virtual void filteredTransliterate(Replaceable& text,\n                                       UTransPosition& index,\n                                       UBool incremental,\n                                       UBool rollback) const;\n\npublic:\n\n    /**\n     * Returns the length of the longest context required by this transliterator.\n     * This is <em>preceding</em> context.  The default implementation supplied\n     * by <code>Transliterator</code> returns zero; subclasses\n     * that use preceding context should override this method to return the\n     * correct value.  For example, if a transliterator translates \"ddd\" (where\n     * d is any digit) to \"555\" when preceded by \"(ddd)\", then the preceding\n     * context length is 5, the length of \"(ddd)\".\n     *\n     * @return The maximum number of preceding context characters this\n     * transliterator needs to examine\n     * @stable ICU 2.0\n     */\n    int32_t getMaximumContextLength(void) const;\n\nprotected:\n\n    /**\n     * Method for subclasses to use to set the maximum context length.\n     * @param maxContextLength the new value to be set.\n     * @see #getMaximumContextLength\n     * @stable ICU 2.4\n     */\n    void setMaximumContextLength(int32_t maxContextLength);\n\npublic:\n\n    /**\n     * Returns a programmatic identifier for this transliterator.\n     * If this identifier is passed to <code>createInstance()</code>, it\n     * will return this object, if it has been registered.\n     * @return a programmatic identifier for this transliterator.\n     * @see #registerInstance\n     * @see #registerFactory\n     * @see #getAvailableIDs\n     * @stable ICU 2.0\n     */\n    virtual const UnicodeString& getID(void) const;\n\n    /**\n     * Returns a name for this transliterator that is appropriate for\n     * display to the user in the default locale.  See {@link\n     * #getDisplayName } for details.\n     * @param ID     the string identifier for this transliterator\n     * @param result Output param to receive the display name\n     * @return       A reference to 'result'.\n     * @stable ICU 2.0\n     */\n    static UnicodeString& U_EXPORT2 getDisplayName(const UnicodeString& ID,\n                                         UnicodeString& result);\n\n    /**\n     * Returns a name for this transliterator that is appropriate for\n     * display to the user in the given locale.  This name is taken\n     * from the locale resource data in the standard manner of the\n     * <code>java.text</code> package.\n     *\n     * <p>If no localized names exist in the system resource bundles,\n     * a name is synthesized using a localized\n     * <code>MessageFormat</code> pattern from the resource data.  The\n     * arguments to this pattern are an integer followed by one or two\n     * strings.  The integer is the number of strings, either 1 or 2.\n     * The strings are formed by splitting the ID for this\n     * transliterator at the first '-'.  If there is no '-', then the\n     * entire ID forms the only string.\n     * @param ID       the string identifier for this transliterator\n     * @param inLocale the Locale in which the display name should be\n     *                 localized.\n     * @param result   Output param to receive the display name\n     * @return         A reference to 'result'.\n     * @stable ICU 2.0\n     */\n    static UnicodeString& U_EXPORT2 getDisplayName(const UnicodeString& ID,\n                                         const Locale& inLocale,\n                                         UnicodeString& result);\n\n    /**\n     * Returns the filter used by this transliterator, or <tt>NULL</tt>\n     * if this transliterator uses no filter.\n     * @return the filter used by this transliterator, or <tt>NULL</tt>\n     *         if this transliterator uses no filter.\n     * @stable ICU 2.0\n     */\n    const UnicodeFilter* getFilter(void) const;\n\n    /**\n     * Returns the filter used by this transliterator, or <tt>NULL</tt> if this\n     * transliterator uses no filter.  The caller must eventually delete the\n     * result.  After this call, this transliterator's filter is set to\n     * <tt>NULL</tt>.\n     * @return the filter used by this transliterator, or <tt>NULL</tt> if this\n     *         transliterator uses no filter.\n     * @stable ICU 2.4\n     */\n    UnicodeFilter* orphanFilter(void);\n\n    /**\n     * Changes the filter used by this transliterator.  If the filter\n     * is set to <tt>null</tt> then no filtering will occur.\n     *\n     * <p>Callers must take care if a transliterator is in use by\n     * multiple threads.  The filter should not be changed by one\n     * thread while another thread may be transliterating.\n     * @param adoptedFilter the new filter to be adopted.\n     * @stable ICU 2.0\n     */\n    void adoptFilter(UnicodeFilter* adoptedFilter);\n\n    /**\n     * Returns this transliterator's inverse.  See the class\n     * documentation for details.  This implementation simply inverts\n     * the two entities in the ID and attempts to retrieve the\n     * resulting transliterator.  That is, if <code>getID()</code>\n     * returns \"A-B\", then this method will return the result of\n     * <code>createInstance(\"B-A\")</code>, or <code>null</code> if that\n     * call fails.\n     *\n     * <p>Subclasses with knowledge of their inverse may wish to\n     * override this method.\n     *\n     * @param status Output param to filled in with a success or an error.\n     * @return a transliterator that is an inverse, not necessarily\n     * exact, of this transliterator, or <code>null</code> if no such\n     * transliterator is registered.\n     * @see #registerInstance\n     * @stable ICU 2.0\n     */\n    Transliterator* createInverse(UErrorCode& status) const;\n\n    /**\n     * Returns a <code>Transliterator</code> object given its ID.\n     * The ID must be either a system transliterator ID or a ID registered\n     * using <code>registerInstance()</code>.\n     *\n     * @param ID a valid ID, as enumerated by <code>getAvailableIDs()</code>\n     * @param dir        either FORWARD or REVERSE.\n     * @param parseError Struct to recieve information on position\n     *                   of error if an error is encountered\n     * @param status     Output param to filled in with a success or an error.\n     * @return A <code>Transliterator</code> object with the given ID\n     * @see #registerInstance\n     * @see #getAvailableIDs\n     * @see #getID\n     * @stable ICU 2.0\n     */\n    static Transliterator* U_EXPORT2 createInstance(const UnicodeString& ID,\n                                          UTransDirection dir,\n                                          UParseError& parseError,\n                                          UErrorCode& status);\n\n    /**\n     * Returns a <code>Transliterator</code> object given its ID.\n     * The ID must be either a system transliterator ID or a ID registered\n     * using <code>registerInstance()</code>.\n     * @param ID a valid ID, as enumerated by <code>getAvailableIDs()</code>\n     * @param dir        either FORWARD or REVERSE.\n     * @param status     Output param to filled in with a success or an error.\n     * @return A <code>Transliterator</code> object with the given ID\n     * @stable ICU 2.0\n     */\n    static Transliterator* U_EXPORT2 createInstance(const UnicodeString& ID,\n                                          UTransDirection dir,\n                                          UErrorCode& status);\n\n    /**\n     * Returns a <code>Transliterator</code> object constructed from\n     * the given rule string.  This will be a RuleBasedTransliterator,\n     * if the rule string contains only rules, or a\n     * CompoundTransliterator, if it contains ID blocks, or a\n     * NullTransliterator, if it contains ID blocks which parse as\n     * empty for the given direction.\n     * @param ID            the id for the transliterator.\n     * @param rules         rules, separated by ';'\n     * @param dir           either FORWARD or REVERSE.\n     * @param parseError    Struct to recieve information on position\n     *                      of error if an error is encountered\n     * @param status        Output param set to success/failure code.\n     * @stable ICU 2.0\n     */\n    static Transliterator* U_EXPORT2 createFromRules(const UnicodeString& ID,\n                                           const UnicodeString& rules,\n                                           UTransDirection dir,\n                                           UParseError& parseError,\n                                           UErrorCode& status);\n\n    /**\n     * Create a rule string that can be passed to createFromRules()\n     * to recreate this transliterator.\n     * @param result the string to receive the rules.  Previous\n     * contents will be deleted.\n     * @param escapeUnprintable if TRUE then convert unprintable\n     * character to their hex escape representations, \\\\uxxxx or\n     * \\\\Uxxxxxxxx.  Unprintable characters are those other than\n     * U+000A, U+0020..U+007E.\n     * @stable ICU 2.0\n     */\n    virtual UnicodeString& toRules(UnicodeString& result,\n                                   UBool escapeUnprintable) const;\n\n    /**\n     * Return the number of elements that make up this transliterator.\n     * For example, if the transliterator \"NFD;Jamo-Latin;Latin-Greek\"\n     * were created, the return value of this method would be 3.\n     *\n     * <p>If this transliterator is not composed of other\n     * transliterators, then this method returns 1.\n     * @return the number of transliterators that compose this\n     * transliterator, or 1 if this transliterator is not composed of\n     * multiple transliterators\n     * @stable ICU 3.0\n     */\n    int32_t countElements() const;\n\n    /**\n     * Return an element that makes up this transliterator.  For\n     * example, if the transliterator \"NFD;Jamo-Latin;Latin-Greek\"\n     * were created, the return value of this method would be one\n     * of the three transliterator objects that make up that\n     * transliterator: [NFD, Jamo-Latin, Latin-Greek].\n     *\n     * <p>If this transliterator is not composed of other\n     * transliterators, then this method will return a reference to\n     * this transliterator when given the index 0.\n     * @param index a value from 0..countElements()-1 indicating the\n     * transliterator to return\n     * @param ec input-output error code\n     * @return one of the transliterators that makes up this\n     * transliterator, if this transliterator is made up of multiple\n     * transliterators, otherwise a reference to this object if given\n     * an index of 0\n     * @stable ICU 3.0\n     */\n    const Transliterator& getElement(int32_t index, UErrorCode& ec) const;\n\n    /**\n     * Returns the set of all characters that may be modified in the\n     * input text by this Transliterator.  This incorporates this\n     * object's current filter; if the filter is changed, the return\n     * value of this function will change.  The default implementation\n     * returns an empty set.  Some subclasses may override {@link\n     * #handleGetSourceSet } to return a more precise result.  The\n     * return result is approximate in any case and is intended for\n     * use by tests, tools, or utilities.\n     * @param result receives result set; previous contents lost\n     * @return a reference to result\n     * @see #getTargetSet\n     * @see #handleGetSourceSet\n     * @stable ICU 2.4\n     */\n    UnicodeSet& getSourceSet(UnicodeSet& result) const;\n\n    /**\n     * Framework method that returns the set of all characters that\n     * may be modified in the input text by this Transliterator,\n     * ignoring the effect of this object's filter.  The base class\n     * implementation returns the empty set.  Subclasses that wish to\n     * implement this should override this method.\n     * @return the set of characters that this transliterator may\n     * modify.  The set may be modified, so subclasses should return a\n     * newly-created object.\n     * @param result receives result set; previous contents lost\n     * @see #getSourceSet\n     * @see #getTargetSet\n     * @stable ICU 2.4\n     */\n    virtual void handleGetSourceSet(UnicodeSet& result) const;\n\n    /**\n     * Returns the set of all characters that may be generated as\n     * replacement text by this transliterator.  The default\n     * implementation returns the empty set.  Some subclasses may\n     * override this method to return a more precise result.  The\n     * return result is approximate in any case and is intended for\n     * use by tests, tools, or utilities requiring such\n     * meta-information.\n     * @param result receives result set; previous contents lost\n     * @return a reference to result\n     * @see #getTargetSet\n     * @stable ICU 2.4\n     */\n    virtual UnicodeSet& getTargetSet(UnicodeSet& result) const;\n\npublic:\n\n    /**\n     * Registers a factory function that creates transliterators of\n     * a given ID.\n     * @param id the ID being registered\n     * @param factory a function pointer that will be copied and\n     * called later when the given ID is passed to createInstance()\n     * @param context a context pointer that will be stored and\n     * later passed to the factory function when an ID matching\n     * the registration ID is being instantiated with this factory.\n     * @stable ICU 2.0\n     */\n    static void U_EXPORT2 registerFactory(const UnicodeString& id,\n                                Factory factory,\n                                Token context);\n\n    /**\n     * Registers an instance <tt>obj</tt> of a subclass of\n     * <code>Transliterator</code> with the system.  When\n     * <tt>createInstance()</tt> is called with an ID string that is\n     * equal to <tt>obj->getID()</tt>, then <tt>obj->clone()</tt> is\n     * returned.\n     *\n     * After this call the Transliterator class owns the adoptedObj\n     * and will delete it.\n     *\n     * @param adoptedObj an instance of subclass of\n     * <code>Transliterator</code> that defines <tt>clone()</tt>\n     * @see #createInstance\n     * @see #registerFactory\n     * @see #unregister\n     * @stable ICU 2.0\n     */\n    static void U_EXPORT2 registerInstance(Transliterator* adoptedObj);\n\n    /**\n     * Registers an ID string as an alias of another ID string.\n     * That is, after calling this function, <tt>createInstance(aliasID)</tt>\n     * will return the same thing as <tt>createInstance(realID)</tt>.\n     * This is generally used to create shorter, more mnemonic aliases\n     * for long compound IDs.\n     *\n     * @param aliasID The new ID being registered.\n     * @param realID The ID that the new ID is to be an alias for.\n     * This can be a compound ID and can include filters and should\n     * refer to transliterators that have already been registered with\n     * the framework, although this isn't checked.\n     * @stable ICU 3.6\n     */\n     static void U_EXPORT2 registerAlias(const UnicodeString& aliasID,\n                                         const UnicodeString& realID);\n\nprotected:\n\n#ifndef U_HIDE_INTERNAL_API\n    /**\n     * @internal\n     * @param id the ID being registered\n     * @param factory a function pointer that will be copied and\n     * called later when the given ID is passed to createInstance()\n     * @param context a context pointer that will be stored and\n     * later passed to the factory function when an ID matching\n     * the registration ID is being instantiated with this factory.\n     */\n    static void _registerFactory(const UnicodeString& id,\n                                 Factory factory,\n                                 Token context);\n\n    /**\n     * @internal\n     */\n    static void _registerInstance(Transliterator* adoptedObj);\n\n    /**\n     * @internal\n     */\n    static void _registerAlias(const UnicodeString& aliasID, const UnicodeString& realID);\n\n    /**\n     * Register two targets as being inverses of one another.  For\n     * example, calling registerSpecialInverse(\"NFC\", \"NFD\", true) causes\n     * Transliterator to form the following inverse relationships:\n     *\n     * <pre>NFC => NFD\n     * Any-NFC => Any-NFD\n     * NFD => NFC\n     * Any-NFD => Any-NFC</pre>\n     *\n     * (Without the special inverse registration, the inverse of NFC\n     * would be NFC-Any.)  Note that NFD is shorthand for Any-NFD, but\n     * that the presence or absence of \"Any-\" is preserved.\n     *\n     * <p>The relationship is symmetrical; registering (a, b) is\n     * equivalent to registering (b, a).\n     *\n     * <p>The relevant IDs must still be registered separately as\n     * factories or classes.\n     *\n     * <p>Only the targets are specified.  Special inverses always\n     * have the form Any-Target1 <=> Any-Target2.  The target should\n     * have canonical casing (the casing desired to be produced when\n     * an inverse is formed) and should contain no whitespace or other\n     * extraneous characters.\n     *\n     * @param target the target against which to register the inverse\n     * @param inverseTarget the inverse of target, that is\n     * Any-target.getInverse() => Any-inverseTarget\n     * @param bidirectional if true, register the reverse relation\n     * as well, that is, Any-inverseTarget.getInverse() => Any-target\n     * @internal\n     */\n    static void _registerSpecialInverse(const UnicodeString& target,\n                                        const UnicodeString& inverseTarget,\n                                        UBool bidirectional);\n#endif  /* U_HIDE_INTERNAL_API */\n\npublic:\n\n    /**\n     * Unregisters a transliterator or class.  This may be either\n     * a system transliterator or a user transliterator or class.\n     * Any attempt to construct an unregistered transliterator based\n     * on its ID will fail.\n     *\n     * @param ID the ID of the transliterator or class\n     * @return the <code>Object</code> that was registered with\n     * <code>ID</code>, or <code>null</code> if none was\n     * @see #registerInstance\n     * @see #registerFactory\n     * @stable ICU 2.0\n     */\n    static void U_EXPORT2 unregister(const UnicodeString& ID);\n\npublic:\n\n    /**\n     * Return a StringEnumeration over the IDs available at the time of the\n     * call, including user-registered IDs.\n     * @param ec input-output error code\n     * @return a newly-created StringEnumeration over the transliterators\n     * available at the time of the call. The caller should delete this object\n     * when done using it.\n     * @stable ICU 3.0\n     */\n    static StringEnumeration* U_EXPORT2 getAvailableIDs(UErrorCode& ec);\n\n    /**\n     * Return the number of registered source specifiers.\n     * @return the number of registered source specifiers.\n     * @stable ICU 2.0\n     */\n    static int32_t U_EXPORT2 countAvailableSources(void);\n\n    /**\n     * Return a registered source specifier.\n     * @param index which specifier to return, from 0 to n-1, where\n     * n = countAvailableSources()\n     * @param result fill-in paramter to receive the source specifier.\n     * If index is out of range, result will be empty.\n     * @return reference to result\n     * @stable ICU 2.0\n     */\n    static UnicodeString& U_EXPORT2 getAvailableSource(int32_t index,\n                                             UnicodeString& result);\n\n    /**\n     * Return the number of registered target specifiers for a given\n     * source specifier.\n     * @param source the given source specifier.\n     * @return the number of registered target specifiers for a given\n     *         source specifier.\n     * @stable ICU 2.0\n     */\n    static int32_t U_EXPORT2 countAvailableTargets(const UnicodeString& source);\n\n    /**\n     * Return a registered target specifier for a given source.\n     * @param index which specifier to return, from 0 to n-1, where\n     * n = countAvailableTargets(source)\n     * @param source the source specifier\n     * @param result fill-in paramter to receive the target specifier.\n     * If source is invalid or if index is out of range, result will\n     * be empty.\n     * @return reference to result\n     * @stable ICU 2.0\n     */\n    static UnicodeString& U_EXPORT2 getAvailableTarget(int32_t index,\n                                             const UnicodeString& source,\n                                             UnicodeString& result);\n\n    /**\n     * Return the number of registered variant specifiers for a given\n     * source-target pair.\n     * @param source    the source specifiers.\n     * @param target    the target specifiers.\n     * @stable ICU 2.0\n     */\n    static int32_t U_EXPORT2 countAvailableVariants(const UnicodeString& source,\n                                          const UnicodeString& target);\n\n    /**\n     * Return a registered variant specifier for a given source-target\n     * pair.\n     * @param index which specifier to return, from 0 to n-1, where\n     * n = countAvailableVariants(source, target)\n     * @param source the source specifier\n     * @param target the target specifier\n     * @param result fill-in paramter to receive the variant\n     * specifier.  If source is invalid or if target is invalid or if\n     * index is out of range, result will be empty.\n     * @return reference to result\n     * @stable ICU 2.0\n     */\n    static UnicodeString& U_EXPORT2 getAvailableVariant(int32_t index,\n                                              const UnicodeString& source,\n                                              const UnicodeString& target,\n                                              UnicodeString& result);\n\nprotected:\n\n#ifndef U_HIDE_INTERNAL_API\n    /**\n     * Non-mutexed internal method\n     * @internal\n     */\n    static int32_t _countAvailableSources(void);\n\n    /**\n     * Non-mutexed internal method\n     * @internal\n     */\n    static UnicodeString& _getAvailableSource(int32_t index,\n                                              UnicodeString& result);\n\n    /**\n     * Non-mutexed internal method\n     * @internal\n     */\n    static int32_t _countAvailableTargets(const UnicodeString& source);\n\n    /**\n     * Non-mutexed internal method\n     * @internal\n     */\n    static UnicodeString& _getAvailableTarget(int32_t index,\n                                              const UnicodeString& source,\n                                              UnicodeString& result);\n\n    /**\n     * Non-mutexed internal method\n     * @internal\n     */\n    static int32_t _countAvailableVariants(const UnicodeString& source,\n                                           const UnicodeString& target);\n\n    /**\n     * Non-mutexed internal method\n     * @internal\n     */\n    static UnicodeString& _getAvailableVariant(int32_t index,\n                                               const UnicodeString& source,\n                                               const UnicodeString& target,\n                                               UnicodeString& result);\n#endif  /* U_HIDE_INTERNAL_API */\n\nprotected:\n\n    /**\n     * Set the ID of this transliterators.  Subclasses shouldn't do\n     * this, unless the underlying script behavior has changed.\n     * @param id the new id t to be set.\n     * @stable ICU 2.4\n     */\n    void setID(const UnicodeString& id);\n\npublic:\n\n    /**\n     * Return the class ID for this class.  This is useful only for\n     * comparing to a return value from getDynamicClassID().\n     * Note that Transliterator is an abstract base class, and therefor\n     * no fully constructed object will  have a dynamic\n     * UCLassID that equals the UClassID returned from\n     * TRansliterator::getStaticClassID().\n     * @return       The class ID for class Transliterator.\n     * @stable ICU 2.0\n     */\n    static UClassID U_EXPORT2 getStaticClassID(void);\n\n    /**\n     * Returns a unique class ID <b>polymorphically</b>.  This method\n     * is to implement a simple version of RTTI, since not all C++\n     * compilers support genuine RTTI.  Polymorphic operator==() and\n     * clone() methods call this method.\n     *\n     * <p>Concrete subclasses of Transliterator must use the\n     *    UOBJECT_DEFINE_RTTI_IMPLEMENTATION macro from\n     *    uobject.h to provide the RTTI functions.\n     *\n     * @return The class ID for this object. All objects of a given\n     * class have the same class ID.  Objects of other classes have\n     * different class IDs.\n     * @stable ICU 2.0\n     */\n    virtual UClassID getDynamicClassID(void) const = 0;\n\nprivate:\n    static UBool initializeRegistry(UErrorCode &status);\n\npublic:\n#ifndef U_HIDE_OBSOLETE_API\n    /**\n     * Return the number of IDs currently registered with the system.\n     * To retrieve the actual IDs, call getAvailableID(i) with\n     * i from 0 to countAvailableIDs() - 1.\n     * @return the number of IDs currently registered with the system.\n     * @obsolete ICU 3.4 use getAvailableIDs() instead\n     */\n    static int32_t U_EXPORT2 countAvailableIDs(void);\n\n    /**\n     * Return the index-th available ID.  index must be between 0\n     * and countAvailableIDs() - 1, inclusive.  If index is out of\n     * range, the result of getAvailableID(0) is returned.\n     * @param index the given ID index.\n     * @return      the index-th available ID.  index must be between 0\n     *              and countAvailableIDs() - 1, inclusive.  If index is out of\n     *              range, the result of getAvailableID(0) is returned.\n     * @obsolete ICU 3.4 use getAvailableIDs() instead; this function\n     * is not thread safe, since it returns a reference to storage that\n     * may become invalid if another thread calls unregister\n     */\n    static const UnicodeString& U_EXPORT2 getAvailableID(int32_t index);\n#endif  /* U_HIDE_OBSOLETE_API */\n};\n\ninline int32_t Transliterator::getMaximumContextLength(void) const {\n    return maximumContextLength;\n}\n\ninline void Transliterator::setID(const UnicodeString& id) {\n    ID = id;\n    // NUL-terminate the ID string, which is a non-aliased copy.\n    ID.append((UChar)0);\n    ID.truncate(ID.length()-1);\n}\n\n#ifndef U_HIDE_INTERNAL_API\ninline Transliterator::Token Transliterator::integerToken(int32_t i) {\n    Token t;\n    t.integer = i;\n    return t;\n}\n\ninline Transliterator::Token Transliterator::pointerToken(void* p) {\n    Token t;\n    t.pointer = p;\n    return t;\n}\n#endif\n\nU_NAMESPACE_END\n\n#endif /* #if !UCONFIG_NO_TRANSLITERATION */\n\n#endif\n"
  },
  {
    "path": "deprecated/android/addons/icucompat/unicode/tzfmt.h",
    "content": "/*\n*******************************************************************************\n* Copyright (C) 2011-2012, International Business Machines Corporation and    *\n* others. All Rights Reserved.                                                *\n*******************************************************************************\n*/\n#ifndef __TZFMT_H\n#define __TZFMT_H\n\n/**\n * \\file \n * \\brief C++ API: TimeZoneFormat\n */\n\n#include \"unicode/utypes.h\"\n\n#if !UCONFIG_NO_FORMATTING\n#ifndef U_HIDE_INTERNAL_API\n\n#include \"unicode/format.h\"\n#include \"unicode/timezone.h\"\n#include \"unicode/tznames.h\"\n\nU_CDECL_BEGIN\n/**\n * Constants for time zone display format style used by format/parse APIs\n * in TimeZoneFormat.\n * @draft ICU 50\n */\ntypedef enum UTimeZoneFormatStyle {\n    /**\n     * Generic location format, such as \"United States Time (New York)\", \"Italy Time\"\n     * @draft ICU 50\n     */\n    UTZFMT_STYLE_GENERIC_LOCATION,\n    /**\n     * Generic long non-location format, such as \"Eastern Time\".\n     * @draft ICU 50\n     */\n    UTZFMT_STYLE_GENERIC_LONG,\n    /**\n     * Generic short non-location format, such as \"ET\".\n     * @draft ICU 50\n     */\n    UTZFMT_STYLE_GENERIC_SHORT,\n    /**\n     * Specific long format, such as \"Eastern Standard Time\".\n     * @draft ICU 50\n     */\n    UTZFMT_STYLE_SPECIFIC_LONG,\n    /**\n     * Specific short format, such as \"EST\", \"PDT\".\n     * @draft ICU 50\n     */\n    UTZFMT_STYLE_SPECIFIC_SHORT,\n    /**\n     * RFC822 format, such as \"-0500\"\n     * @draft ICU 50\n     */\n    UTZFMT_STYLE_RFC822,\n    /**\n     * Localized GMT offset format, such as \"GMT-05:00\", \"UTC+0100\"\n     * @draft ICU 50\n     */\n    UTZFMT_STYLE_LOCALIZED_GMT,\n    /**\n     * ISO 8601 format (extended), such as \"-05:00\", \"Z\"(UTC)\n     * @draft ICU 50\n     */\n    UTZFMT_STYLE_ISO8601\n} UTimeZoneFormatStyle;\n\n/**\n * Constants for GMT offset pattern types.\n * @draft ICU 50\n */\ntypedef enum UTimeZoneFormatGMTOffsetPatternType {\n    /**\n     * Positive offset with hour and minute fields\n     * @draft ICU 50\n     */\n    UTZFMT_PAT_POSITIVE_HM,\n    /**\n     * Positive offset with hour, minute and second fields\n     * @draft ICU 50\n     */\n    UTZFMT_PAT_POSITIVE_HMS,\n    /**\n     * Negative offset with hour and minute fields\n     * @draft ICU 50\n     */\n    UTZFMT_PAT_NEGATIVE_HM,\n    /**\n     * Negative offset with hour, minute and second fields\n     * @draft ICU 50\n     */\n    UTZFMT_PAT_NEGATIVE_HMS\n} UTimeZoneFormatGMTOffsetPatternType;\n\n/**\n * Constants for time types used by TimeZoneFormat APIs for\n * receiving time type (standard time, daylight time or unknown).\n * @draft ICU 50\n */\ntypedef enum UTimeZoneFormatTimeType {\n    /**\n     * Unknown\n     * @draft ICU 50\n     */\n    UTZFMT_TIME_TYPE_UNKNOWN,\n    /**\n     * Standard time\n     * @draft ICU 50\n     */\n    UTZFMT_TIME_TYPE_STANDARD,\n    /**\n     * Daylight saving time\n     * @draft ICU 50\n     */\n    UTZFMT_TIME_TYPE_DAYLIGHT\n} UTimeZoneFormatTimeType;\n\n/**\n * Constants for parse option flags, used for specifying optional parse behavior.\n * @draft ICU 50\n */\ntypedef enum UTimeZoneFormatParseOption {\n    /**\n     * No option.\n     * @draft ICU 50\n     */\n    UTZFMT_PARSE_OPTION_NONE        = 0x00,\n    /**\n     * When a time zone display name is not found within a set of display names\n     * used for the specified style, look for the name from display names used\n     * by other styles.\n     * @draft ICU 50\n     */\n    UTZFMT_PARSE_OPTION_ALL_STYLES  = 0x01\n} UTimeZoneFormatParseOption;\n\nU_CDECL_END\n\nU_NAMESPACE_BEGIN\n\nclass TimeZoneGenericNames;\nclass UVector;\n\n/**\n * <code>TimeZoneFormat</code> supports time zone display name formatting and parsing.\n * An instance of TimeZoneFormat works as a subformatter of {@link SimpleDateFormat},\n * but you can also directly get a new instance of <code>TimeZoneFormat</code> and\n * formatting/parsing time zone display names.\n * <p>\n * ICU implements the time zone display names defined by <a href=\"http://www.unicode.org/reports/tr35/\">UTS#35\n * Unicode Locale Data Markup Language (LDML)</a>. {@link TimeZoneNames} represents the\n * time zone display name data model and this class implements the algorithm for actual\n * formatting and parsing.\n * \n * @see SimpleDateFormat\n * @see TimeZoneNames\n * @draft ICU 50\n */\nclass U_I18N_API TimeZoneFormat : public Format {\npublic:\n    /**\n     * Copy constructor.\n     * @draft ICU 50\n     */\n    TimeZoneFormat(const TimeZoneFormat& other);\n\n    /**\n     * Destructor.\n     * @draft ICU 50\n     */\n    virtual ~TimeZoneFormat();\n\n    /**\n     * Assignment operator.\n     * @draft ICU 50\n     */\n    TimeZoneFormat& operator=(const TimeZoneFormat& other);\n\n    /**\n     * Return true if the given Format objects are semantically equal.\n     * Objects of different subclasses are considered unequal.\n     * @param other The object to be compared with.\n     * @return Return TRUE if the given Format objects are semantically equal.\n     *                Objects of different subclasses are considered unequal.\n     * @draft ICU 50\n     */\n    virtual UBool operator==(const Format& other) const;\n\n    /**\n     * Clone this object polymorphically. The caller is responsible\n     * for deleting the result when done.\n     * @return A copy of the object\n     * @draft ICU 50\n     */\n    virtual Format* clone() const;\n\n    /**\n     * Creates an instance of <code>TimeZoneFormat</code> for the given locale.\n     * @param locale The locale.\n     * @param status Recevies the status.\n     * @return An instance of <code>TimeZoneFormat</code> for the given locale,\n     *          owned by the caller.\n     * @draft ICU 50\n     */\n    static TimeZoneFormat* U_EXPORT2 createInstance(const Locale& locale, UErrorCode& status);\n\n    /**\n     * Returns the time zone display name data used by this instance.\n     * @return The time zone display name data.\n     * @draft ICU 50\n     */\n    const TimeZoneNames* getTimeZoneNames() const;\n\n    /**\n     * Sets the time zone display name data to this format instnace.\n     * The caller should not delete the TimeZoenNames object after it is adopted\n     * by this call.\n     * @param tznames TimeZoneNames object to be adopted.\n     * @draft ICU 50\n     */\n    void adoptTimeZoneNames(TimeZoneNames *tznames);\n\n    /**\n     * Sets the time zone display name data to this format instnace.\n     * @param tznames TimeZoneNames object to be set.\n     * @draft ICU 50\n     */\n    void setTimeZoneNames(const TimeZoneNames &tznames);\n\n    /**\n     * Returns the localized GMT format pattern.\n     * @param pattern Receives the localized GMT format pattern.\n     * @return A reference to the result pattern.\n     * @see #setGMTPattern\n     * @draft ICU 50\n     */\n    UnicodeString& getGMTPattern(UnicodeString& pattern) const;\n\n    /**\n     * Sets the localized GMT format pattern. The pattern must contain\n     * a single argument {0}, for example \"GMT {0}\".\n     * @param pattern The localized GMT format pattern to be used by this object.\n     * @param status Recieves the status.\n     * @see #getGMTPattern\n     * @draft ICU 50\n     */\n    void setGMTPattern(const UnicodeString& pattern, UErrorCode& status);\n\n    /**\n     * Returns the offset pattern used for localized GMT format.\n     * @param type The offset pattern type enum.\n     * @param pattern Receives the offset pattern.\n     * @return A reference to the result pattern.\n     * @see #setGMTOffsetPattern\n     * @draft ICU 50\n     */\n    UnicodeString& getGMTOffsetPattern(UTimeZoneFormatGMTOffsetPatternType type, UnicodeString& pattern) const;\n\n    /**\n     * Sets the offset pattern for the given offset type.\n     * @param type The offset pattern type enum.\n     * @param pattern The offset pattern used for localized GMT format for the type.\n     * @param status Receives the status.\n     * @see #getGMTOffsetPattern\n     * @draft ICU 50\n     */\n    void setGMTOffsetPattern(UTimeZoneFormatGMTOffsetPatternType type, const UnicodeString& pattern, UErrorCode& status);\n\n    /**\n     * Returns the decimal digit characters used for localized GMT format.\n     * The return string contains exactly 10 code points (may include Unicode\n     * supplementary character) representing digit 0 to digit 9 in the ascending\n     * order.\n     * @param digits Receives the decimal digits used for localized GMT format.\n     * @see #setGMTOffsetDigits\n     * @draft ICU 50\n     */\n    UnicodeString& getGMTOffsetDigits(UnicodeString& digits) const;\n\n    /**\n     * Sets the decimal digit characters used for localized GMT format.\n     * The input <code>digits</code> must contain exactly 10 code points\n     * (Unicode supplementary characters are also allowed) representing\n     * digit 0 to digit 9 in the ascending order. When the input <code>digits</code>\n     * does not satisfy the condition, <code>U_ILLEGAL_ARGUMENT_ERROR</code>\n     * will be set to the return status.\n     * @param digits The decimal digits used for localized GMT format.\n     * @param status Receives the status.\n     * @see #getGMTOffsetDigits\n     * @draft ICU 50\n     */\n    void setGMTOffsetDigits(const UnicodeString& digits, UErrorCode& status);\n\n    /**\n     * Returns the localized GMT format string for GMT(UTC) itself (GMT offset is 0).\n     * @param gmtZeroFormat Receives the localized GMT string string for GMT(UTC) itself.\n     * @return A reference to the result GMT string.\n     * @see #setGMTZeroFormat\n     * @draft ICU 50\n     */\n    UnicodeString& getGMTZeroFormat(UnicodeString& gmtZeroFormat) const;\n\n    /**\n     * Sets the localized GMT format string for GMT(UTC) itself (GMT offset is 0).\n     * @param gmtZeroFormat The localized GMT format string for GMT(UTC).\n     * @param status Receives the status.\n     * @see #getGMTZeroFormat\n     * @draft ICU 50\n     */\n    void setGMTZeroFormat(const UnicodeString& gmtZeroFormat, UErrorCode& status);\n\n    /**\n     * Returns the bitwise flags of UTimeZoneFormatParseOption representing the default parse\n     * options used by this object.\n     * @return the default parse options.\n     * @see ParseOption\n     * @draft ICU 50\n     */\n    uint32_t getDefaultParseOptions(void) const;\n\n    /**\n     * Sets the default parse options.\n     * <p><b>Note</b>: By default, an instance of <code>TimeZoneFormat</code>\n     * created by {@link #createInstance} has no parse options set (UTZFMT_PARSE_OPTION_NONE).\n     * To specify multipe options, use bitwise flags of UTimeZoneFormatParseOption.\n     * @see #UTimeZoneFormatParseOption\n     * @draft ICU 50\n     */\n    void setDefaultParseOptions(uint32_t flags);\n\n    /**\n     * Returns the RFC822 style time zone string for the given offset.\n     * For example, \"-0800\".\n     * @param offset The offset from GMT(UTC) in milliseconds.\n     * @param result Recevies the RFC822 style GMT(UTC) offset format.\n     * @return A reference to the result.\n     * @param status Receives the status\n     * @see #parseOffsetRFC822\n     * @draft ICU 50\n     */\n    UnicodeString& formatOffsetRFC822(int32_t offset, UnicodeString& result, UErrorCode& status) const;\n\n    /**\n     * Returns the ISO 8601 style time zone string for the given offset.\n     * For example, \"-08:00\" and \"Z\".\n     * @param offset The offset from GMT(UTC) in milliseconds.\n     * @param result Receives the ISO 8601 style GMT(UTC) offset format.\n     * @param status Receives the status\n     * @return A reference to the result.\n     * @see #parseOffsetISO8601\n     * @draft ICU 50\n     */\n    UnicodeString& formatOffsetISO8601(int32_t offset, UnicodeString& result, UErrorCode& status) const;\n\n    /**\n     * Returns the localized GMT(UTC) offset format for the given offset.\n     * The localized GMT offset is defined by;\n     * <ul>\n     * <li>GMT format pattern (e.g. \"GMT {0}\" - see {@link #getGMTPattern})\n     * <li>Offset time pattern (e.g. \"+HH:mm\" - see {@link #getGMTOffsetPattern})\n     * <li>Offset digits (e.g. \"0123456789\" - see {@link #getGMTOffsetDigits})\n     * <li>GMT zero format (e.g. \"GMT\" - see {@link #getGMTZeroFormat})\n     * </ul>\n     * @param offset the offset from GMT(UTC) in milliseconds.\n     * @param status Receives the status\n     * @param result Receives the localized GMT format string.\n     * @return A reference to the result.\n     * @see #parseOffsetLocalizedGMT\n     * @draft ICU 50\n     */\n    UnicodeString& formatOffsetLocalizedGMT(int32_t offset, UnicodeString& result, UErrorCode& status) const;\n\n    using Format::format;\n\n    /**\n     * Returns the display name of the time zone at the given date for the style.\n     * @param style The style (e.g. <code>UTZFMT_STYLE_GENERIC_LONG</code>, <code>UTZFMT_STYLE_LOCALIZED_GMT</code>...)\n     * @param tz The time zone.\n     * @param date The date.\n     * @param name Receives the display name.\n     * @param timeType the output argument for receiving the time type (standard/daylight/unknown)\n     * used for the display name, or NULL if the information is not necessary.\n     * @return A reference to the result\n     * @see #UTimeZoneFormatStyle\n     * @see #UTimeZoneFormatTimeType\n     * @draft ICU 50\n     */\n    virtual UnicodeString& format(UTimeZoneFormatStyle style, const TimeZone& tz, UDate date,\n        UnicodeString& name, UTimeZoneFormatTimeType* timeType = NULL) const;\n\n    /**\n     * Returns offset from GMT(UTC) in milliseconds for the given RFC822\n     * style time zone string. When the given string is not an RFC822 time zone\n     * string, this method sets the current position as the error index\n     * to <code>ParsePosition pos</code> and returns 0.\n     * @param text The text contains RFC822 style time zone string (e.g. \"-0800\")\n     *              at the position.\n     * @param pos The ParsePosition object.\n     * @return The offset from GMT(UTC) in milliseconds for the given RFC822 style\n     *              time zone string.\n     * @see #formatOffsetRFC822\n     * @draft ICU 50\n     */\n    int32_t parseOffsetRFC822(const UnicodeString& text, ParsePosition& pos) const;\n\n    /**\n     * Returns offset from GMT(UTC) in milliseconds for the given ISO 8601\n     * style time zone string. When the given string is not an ISO 8601 time zone\n     * string, this method sets the current position as the error index\n     * to <code>ParsePosition pos</code> and returns 0.\n     * @param text The text contains ISO8601 style time zone string (e.g. \"-08:00\", \"Z\")\n     *              at the position.\n     * @param pos The ParsePosition object.\n     * @return The offset from GMT(UTC) in milliseconds for the given ISO 8601 style\n     *              time zone string.\n     * @see #formatOffsetISO8601\n     * @draft ICU 50\n     */\n    int32_t parseOffsetISO8601(const UnicodeString& text, ParsePosition& pos) const;\n\n    /**\n     * Returns offset from GMT(UTC) in milliseconds for the given localized GMT\n     * offset format string. When the given string cannot be parsed, this method\n     * sets the current position as the error index to <code>ParsePosition pos</code>\n     * and returns 0.\n     * @param text The text contains a localized GMT offset string at the position.\n     * @param pos The ParsePosition object.\n     * @return The offset from GMT(UTC) in milliseconds for the given localized GMT\n     *          offset format string.\n     * @see #formatOffsetLocalizedGMT\n     * @draft ICU 50\n     */\n    int32_t parseOffsetLocalizedGMT(const UnicodeString& text, ParsePosition& pos) const;\n\n    /**\n     * Returns a <code>TimeZone</code> by parsing the time zone string according to\n     * the given parse position, the specified format style and parse options.\n     * \n     * @param text The text contains a time zone string at the position.\n     * @param style The format style\n     * @param pos The position.\n     * @param parseOptions The parse options repesented by bitwise flags of UTimeZoneFormatParseOption.\n     * @param timeType The output argument for receiving the time type (standard/daylight/unknown),\n     * or NULL if the information is not necessary.\n     * @return A <code>TimeZone</code>, or null if the input could not be parsed.\n     * @see UTimeZoneFormatStyle\n     * @see UTimeZoneFormatParseOption\n     * @see UTimeZoneFormatTimeType\n     * @draft ICU 50\n     */\n    virtual TimeZone* parse(UTimeZoneFormatStyle style, const UnicodeString& text, ParsePosition& pos,\n        int32_t parseOptions, UTimeZoneFormatTimeType* timeType = NULL) const;\n\n    /**\n     * Returns a <code>TimeZone</code> by parsing the time zone string according to\n     * the given parse position, the specified format style and the default parse options.\n     * \n     * @param text The text contains a time zone string at the position.\n     * @param style The format style\n     * @param pos The position.\n     * @param timeType The output argument for receiving the time type (standard/daylight/unknown),\n     * or NULL if the information is not necessary.\n     * @return A <code>TimeZone</code>, or null if the input could not be parsed.\n     * @see UTimeZoneFormatStyle\n     * @see UTimeZoneFormatParseOption\n     * @see UTimeZoneFormatTimeType\n     * @draft ICU 50\n     */\n    TimeZone* parse(UTimeZoneFormatStyle style, const UnicodeString& text, ParsePosition& pos,\n        UTimeZoneFormatTimeType* timeType = NULL) const;\n\n    /* ----------------------------------------------\n     * Format APIs\n     * ---------------------------------------------- */\n\n    /**\n     * Format an object to produce a time zone display string using localized GMT offset format.\n     * This method handles Formattable objects with a <code>TimeZone</code>. If a the Formattable\n     * object type is not a <code>TimeZone</code>, then it returns a failing UErrorCode.\n     * @param obj The object to format. Must be a <code>TimeZone</code>.\n     * @param appendTo Output parameter to receive result. Result is appended to existing contents.\n     * @param pos On input: an alignment field, if desired. On output: the offsets of the alignment field.\n     * @param status Output param filled with success/failure status.\n     * @return Reference to 'appendTo' parameter.\n     * @draft ICU 50\n     */\n    virtual UnicodeString& format(const Formattable& obj, UnicodeString& appendTo,\n        FieldPosition& pos, UErrorCode& status) const;\n\n    /**\n     * Parse a string to produce an object. This methods handles parsing of\n     * time zone display strings into Formattable objects with <code>TimeZone</code>.\n     * @param source The string to be parsed into an object.\n     * @param result Formattable to be set to the parse result. If parse fails, return contents are undefined.\n     * @param parse_pos The position to start parsing at. Upon return this param is set to the position after the\n     *                  last character successfully parsed. If the source is not parsed successfully, this param\n     *                  will remain unchanged.\n     * @return A newly created Formattable* object, or NULL on failure.  The caller owns this and should\n     *                 delete it when done.\n     * @draft ICU 50\n     */\n    virtual void parseObject(const UnicodeString& source, Formattable& result, ParsePosition& parse_pos) const;\n\n    /**\n     * ICU \"poor man's RTTI\", returns a UClassID for this class.\n     * @draft ICU 50\n     */\n    static UClassID U_EXPORT2 getStaticClassID(void);\n\n    /**\n     * ICU \"poor man's RTTI\", returns a UClassID for the actual class.\n     * @draft ICU 50\n     */\n    virtual UClassID getDynamicClassID() const;\n\nprotected:\n    /**\n     * Constructs a TimeZoneFormat object for the specified locale.\n     * @param locale the locale\n     * @param status receives the status.\n     * @draft ICU 50\n     */\n    TimeZoneFormat(const Locale& locale, UErrorCode& status);\n\nprivate:\n    /* Locale of this object */\n    Locale fLocale;\n\n    /* Stores the region (could be implicit default) */ \n    char fTargetRegion[ULOC_COUNTRY_CAPACITY];\n\n    /* TimeZoneNames object used by this formatter */\n    TimeZoneNames* fTimeZoneNames;\n\n    /* TimeZoneGenericNames object used by this formatter - lazily instantiated */\n    TimeZoneGenericNames* fTimeZoneGenericNames;\n\n    /* Localized GMT format pattern - e.g. \"GMT{0}\" */\n    UnicodeString fGMTPattern;\n\n    /* Array of offset patterns used by Localized GMT format - e.g. \"+HH:mm\" */\n    UnicodeString fGMTOffsetPatterns[UTZFMT_PAT_NEGATIVE_HMS + 1];\n\n    /* Localized decimal digits used by Localized GMT format */\n    UChar32 fGMTOffsetDigits[10];\n\n    /* Localized GMT zero format - e.g. \"GMT\" */\n    UnicodeString fGMTZeroFormat;\n\n    /* Bit flags representing parse options */\n    uint32_t fDefParseOptionFlags;\n\n    /* Constant parts of GMT format pattern, populated from localized GMT format pattern*/\n    UnicodeString fGMTPatternPrefix;    /* Substring before {0} */\n    UnicodeString fGMTPatternSuffix;    /* Substring after {0} */\n\n    /* Compiled offset patterns generated from fGMTOffsetPatterns[] */\n    UVector* fGMTOffsetPatternItems[UTZFMT_PAT_NEGATIVE_HMS + 1];\n\n    /**\n     * Returns the time zone's specific format string.\n     * @param tz the time zone\n     * @param stdType the name type used for standard time\n     * @param dstType the name type used for daylight time\n     * @param date the date\n     * @param name receives the time zone's specific format name string\n     * @param timeType when null, actual time type is set\n     * @return a reference to name.\n     */\n    UnicodeString& formatSpecific(const TimeZone& tz, UTimeZoneNameType stdType, UTimeZoneNameType dstType,\n        UDate date, UnicodeString& name, UTimeZoneFormatTimeType *timeType) const;\n\n    /**\n     * Returns the time zone's generic format string.\n     * @param tz the time zone\n     * @param genType the generic name type\n     * @param date the date\n     * @param name receives the time zone's generic format name string\n     * @return a reference to name.\n     */\n    UnicodeString& formatGeneric(const TimeZone& tz, int32_t genType, UDate date, UnicodeString& name) const;\n\n    /**\n     * Lazily create a TimeZoneGenericNames instance\n     * @param status receives the status\n     * @return the cached TimeZoneGenericNames.\n     */\n    const TimeZoneGenericNames* getTimeZoneGenericNames(UErrorCode& status) const;\n\n    /**\n     * Private enum specifying a combination of offset fields\n     */\n    enum OffsetFields {\n        FIELDS_H,\n        FIELDS_HM,\n        FIELDS_HMS\n    };\n\n    /**\n     * Parses the localized GMT pattern string and initialize\n     * localized gmt pattern fields.\n     * @param gmtPattern the localized GMT pattern string such as \"GMT {0}\"\n     * @param status U_ILLEGAL_ARGUMENT_ERROR is set when the specified pattern does not\n     *               contain an argument \"{0}\".\n     */\n    void initGMTPattern(const UnicodeString& gmtPattern, UErrorCode& status);\n\n    /**\n     * Parse the GMT offset pattern into runtime optimized format.\n     * @param pattern the offset pattern string\n     * @param required the required set of fields, such as FIELDS_HM\n     * @param status U_ILLEGAL_ARGUMENT is set when the specified pattern does not contain\n     *               pattern letters for the required fields.\n     * @return A list of GMTOffsetField objects, or NULL on error.\n     */\n    static UVector* parseOffsetPattern(const UnicodeString& pattern, OffsetFields required, UErrorCode& status);\n\n    /**\n     * Appends second field to the offset pattern with hour/minute\n     * Note: This code will be obsoleted once we add hour-minute-second pattern data in CLDR.\n     * @param offsetHM the offset pattern including hour and minute fields\n     * @param result the output offset pattern including hour, minute and second fields\n     * @return a reference to result\n     */\n    static UnicodeString& expandOffsetPattern(const UnicodeString& offsetHM, UnicodeString& result);\n\n    /**\n     * Break input string into UChar32[]. Each array element represents\n     * a code point. This method is used for parsing localized digit\n     * characters and support characters in Unicode supplemental planes.\n     * @param str the string\n     * @param codeArray receives the result\n     * @param capacity the capacity of codeArray\n     * @return TRUE when the specified code array is fully filled with code points\n     *         (no under/overflow).\n     */\n    static UBool toCodePoints(const UnicodeString& str, UChar32* codeArray, int32_t capacity);\n\n    /**\n     * Returns offset from GMT(UTC) in milliseconds for the given ISO 8601 style\n     * (extended format) time zone string. When the given string is not an ISO 8601 time\n     * zone string, this method sets the current position as the error index\n     * to <code>ParsePosition pos</code> and returns 0.\n     * @param text the text contains ISO 8601 style time zone string (e.g. \"-08:00\", \"Z\")\n     *      at the position.\n     * @param pos the position, non-negative error index will be set on failure.\n     * @param extendedOnly TRUE if parsing the text as ISO 8601 extended offset format (e.g. \"-08:00\"),\n     *      or FALSE to evaluate the text as basic format.\n     * @param hasDigitOffset receiving if the parsed zone string contains offset digits.\n     * @return the offset from GMT(UTC) in milliseconds for the given ISO 8601 style\n     *      time zone string.\n     */\n    int32_t parseOffsetISO8601(const UnicodeString& text, ParsePosition& pos, UBool extendedOnly,\n        UBool* hasDigitOffset = NULL) const;\n\n    /**\n     * Appends localized digits to the buffer.\n     * This code assumes that the input number is 0 - 59\n     * @param buf the target buffer\n     * @param n the integer number\n     * @param minDigits the minimum digits width\n     */\n    void appendOffsetDigits(UnicodeString& buf, int32_t n, uint8_t minDigits) const;\n\n    /**\n     * Returns offset from GMT(UTC) in milliseconds for the given localized GMT\n     * offset format string. When the given string cannot be parsed, this method\n     * sets the current position as the error index to <code>ParsePosition pos</code>\n     * and returns 0.\n     * @param text the text contains a localized GMT offset string at the position.\n     * @param pos the position, non-negative error index will be set on failure.\n     * @param hasDigitOffset receiving if the parsed zone string contains offset digits.\n     * @return the offset from GMT(UTC) in milliseconds for the given localized GMT\n     *      offset format string.\n     */\n    int32_t parseOffsetLocalizedGMT(const UnicodeString& text, ParsePosition& pos,\n        UBool* hasDigitOffset) const;\n\n    /**\n     * Parses localized GMT offset fields into offset.\n     * @param text the input text\n     * @param start the start index\n     * @param minimumHourWidth true if the parser allows hour field width to be 1\n     * @param parsedLen the parsed length, or 0 on failure.\n     * @return the parsed offset in milliseconds.\n     */\n    int32_t parseOffsetFields(const UnicodeString& text, int32_t start, UBool minimumHourWidth,\n        int32_t& parsedLen) const;\n\n    /**\n     * Parses abutting localized GMT offset fields (such as 0800) into offset.\n     * @param text the input text\n     * @param start the start index\n     * @param parsedLen the parsed length, or 0 on failure\n     * @return the parsed offset in milliseconds.\n     */\n    int32_t parseAbuttingOffsetFields(const UnicodeString& text, int32_t start, int32_t& parsedLen) const;\n\n    /**\n     * Parses the input text using the default format patterns (e.g. \"UTC{0}\").\n     * @param text the input text\n     * @param start the start index\n     * @param parsedLen the parsed length, or 0 on failure\n     * @return the parsed offset in milliseconds.\n     */\n    int32_t parseOffsetDefaultLocalizedGMT(const UnicodeString& text, int start, int32_t& parsedLen) const;\n\n    /**\n     * Parses the input GMT offset fields with the default offset pattern.\n     * @param text the input text\n     * @param start the start index\n     * @param separator the separator character, e.g. ':'\n     * @param parsedLen the parsed length, or 0 on failure.\n     * @return the parsed offset in milliseconds.\n     */\n    int32_t parseDefaultOffsetFields(const UnicodeString& text, int32_t start, UChar separator,\n        int32_t& parsedLen) const;\n\n    /**\n     * Reads an offset field value. This method will stop parsing when\n     * 1) number of digits reaches <code>maxDigits</code>\n     * 2) just before already parsed number exceeds <code>maxVal</code>\n     * \n     * @param text the text\n     * @param start the start offset\n     * @param minDigits the minimum number of required digits\n     * @param maxDigits the maximum number of digits\n     * @param minVal the minimum value\n     * @param maxVal the maximum value\n     * @param parsedLen the actual parsed length.\n     * @return the integer value parsed\n     */\n    int32_t parseOffsetFieldWithLocalizedDigits(const UnicodeString& text, int32_t start,\n        uint8_t minDigits, uint8_t maxDigits, uint16_t minVal, uint16_t maxVal, int32_t& parsedLen) const;\n\n    /**\n     * Reads a single decimal digit, either localized digits used by this object\n     * or any Unicode numeric character.\n     * @param text the text\n     * @param start the start index\n     * @param len the actual length read from the text\n     * the start index is not a decimal number.\n     * @return the integer value of the parsed digit, or -1 on failure.\n     */\n    int32_t parseSingleLocalizedDigit(const UnicodeString& text, int32_t start, int32_t& len) const;\n\n    /**\n     * Formats offset using ASCII digits. The input offset range must be\n     * within +/-24 hours (exclusive).\n     * @param offset The offset\n     * @param sep The field separator character or 0 if not required\n     * @param minFields The minimum fields\n     * @param maxFields The maximum fields\n     * @return The offset string\n     */\n    static UnicodeString& formatOffsetWithAsciiDigits(int32_t offset, UChar sep,\n        OffsetFields minFields, OffsetFields maxFields, UnicodeString& result);\n\n    /**\n     * Parses offset represented by contiguous ASCII digits.\n     * <p>\n     * Note: This method expects the input position is already at the start of\n     * ASCII digits and does not parse sign (+/-).\n     * @param text The text contains a sequence of ASCII digits\n     * @param pos The parse position\n     * @param minFields The minimum Fields to be parsed\n     * @param maxFields The maximum Fields to be parsed\n     * @param fixedHourWidth true if hour field must be width of 2\n     * @return Parsed offset, 0 or positive number.\n     */\n    static int32_t parseAbuttingAsciiOffsetFields(const UnicodeString& text, ParsePosition& pos,\n        OffsetFields minFields, OffsetFields maxFields, UBool fixedHourWidth);\n\n    /**\n     * Parses offset represented by ASCII digits and separators.\n     * <p>\n     * Note: This method expects the input position is already at the start of\n     * ASCII digits and does not parse sign (+/-).\n     * @param text The text\n     * @param pos The parse position\n     * @param sep The separator character\n     * @param minFields The minimum Fields to be parsed\n     * @param maxFields The maximum Fields to be parsed\n     * @param fixedHourWidth true if hour field must be width of 2\n     * @return Parsed offset, 0 or positive number.\n     */\n    static int32_t parseAsciiOffsetFields(const UnicodeString& text, ParsePosition& pos, UChar sep,\n        OffsetFields minFields, OffsetFields maxFields, UBool fixedHourWidth);\n\n    /**\n     * Unquotes the message format style pattern.\n     * @param pattern the pattern\n     * @param result receive the unquoted pattern.\n     * @return A reference to result.\n     */\n    static UnicodeString& unquote(const UnicodeString& pattern, UnicodeString& result);\n\n    /**\n     * Initialize localized GMT format offset hour/min/sec patterns.\n     * This method parses patterns into optimized run-time format.\n     * @param status receives the status.\n     */\n    void initGMTOffsetPatterns(UErrorCode& status);\n\n    /**\n     * Creates an instance of TimeZone for the given offset\n     * @param offset the offset\n     * @return A TimeZone with the given offset\n     */\n    TimeZone* createTimeZoneForOffset(int32_t offset) const;\n\n    /**\n     * Returns the time type for the given name type\n     * @param nameType the name type\n     * @return the time type (unknown/standard/daylight)\n     */\n    static UTimeZoneFormatTimeType getTimeType(UTimeZoneNameType nameType);\n\n    /*\n     * Returns the time zone ID of a match at the specified index within\n     * the MatchInfoCollection.\n     * @param matches the collection of matches\n     * @param idx the index withing matches\n     * @param tzID receives the resolved time zone ID\n     * @return a reference to tzID.\n     */\n    UnicodeString& getTimeZoneID(const TimeZoneNames::MatchInfoCollection* matches, int32_t idx, UnicodeString& tzID) const;\n};\n\nU_NAMESPACE_END\n\n#endif  /* U_HIDE_INTERNAL_API */\n#endif\n#endif\n\n"
  },
  {
    "path": "deprecated/android/addons/icucompat/unicode/tznames.h",
    "content": "/*\n*******************************************************************************\n* Copyright (C) 2011-2012, International Business Machines Corporation and    *\n* others. All Rights Reserved.                                                *\n*******************************************************************************\n*/\n#ifndef __TZNAMES_H\n#define __TZNAMES_H\n\n/**\n * \\file \n * \\brief C++ API: TimeZoneNames\n */\n#include \"unicode/utypes.h\"\n\n#if !UCONFIG_NO_FORMATTING\n#ifndef U_HIDE_INTERNAL_API\n\n#include \"unicode/uloc.h\"\n#include \"unicode/unistr.h\"\n\nU_CDECL_BEGIN\n\n/**\n * Constants for time zone display name types.\n * @draft ICU 50\n */\ntypedef enum UTimeZoneNameType {\n    /**\n     * Unknown display name type.\n     * @draft ICU 50\n     */\n    UTZNM_UNKNOWN           = 0x00,\n    /**\n     * Long display name, such as \"Eastern Time\".\n     * @draft ICU 50\n     */\n    UTZNM_LONG_GENERIC      = 0x01,\n    /**\n     * Long display name for standard time, such as \"Eastern Standard Time\".\n     * @draft ICU 50\n     */\n    UTZNM_LONG_STANDARD     = 0x02,\n    /**\n     * Long display name for daylight saving time, such as \"Eastern Daylight Time\".\n     * @draft ICU 50\n     */\n    UTZNM_LONG_DAYLIGHT     = 0x04,\n    /**\n     * Short display name, such as \"ET\".\n     * @draft ICU 50\n     */\n    UTZNM_SHORT_GENERIC     = 0x08,\n    /**\n     * Short display name for standard time, such as \"EST\".\n     * @draft ICU 50\n     */\n    UTZNM_SHORT_STANDARD    = 0x10,\n    /**\n     * Short display name for daylight saving time, such as \"EDT\".\n     * @draft ICU 50\n     */\n    UTZNM_SHORT_DAYLIGHT    = 0x20\n} UTimeZoneNameType;\n\nU_CDECL_END\n\nU_NAMESPACE_BEGIN\n\nclass UVector;\nstruct MatchInfo;\n\n/**\n * <code>TimeZoneNames</code> is an abstract class representing the time zone display name data model defined\n * by <a href=\"http://www.unicode.org/reports/tr35/\">UTS#35 Unicode Locale Data Markup Language (LDML)</a>.\n * The model defines meta zone, which is used for storing a set of display names. A meta zone can be shared\n * by multiple time zones. Also a time zone may have multiple meta zone historic mappings.\n * <p>\n * For example, people in the United States refer the zone used by the east part of North America as \"Eastern Time\".\n * The tz database contains multiple time zones \"America/New_York\", \"America/Detroit\", \"America/Montreal\" and some\n * others that belong to \"Eastern Time\". However, assigning different display names to these time zones does not make\n * much sense for most of people.\n * <p>\n * In <a href=\"http://cldr.unicode.org/\">CLDR</a> (which uses LDML for representing locale data), the display name\n * \"Eastern Time\" is stored as long generic display name of a meta zone identified by the ID \"America_Eastern\".\n * Then, there is another table maintaining the historic mapping to meta zones for each time zone. The time zones in\n * the above example (\"America/New_York\", \"America/Detroit\"...) are mapped to the meta zone \"America_Eastern\".\n * <p>\n * Sometimes, a time zone is mapped to a different time zone in the past. For example, \"America/Indiana/Knox\"\n * had been moving \"Eastern Time\" and \"Central Time\" back and forth. Therefore, it is necessary that time zone\n * to meta zones mapping data are stored by date range.\n * \n * <p><b>Note:</b>\n * The methods in this class assume that time zone IDs are already canonicalized. For example, you may not get proper\n * result returned by a method with time zone ID \"America/Indiana/Indianapolis\", because it's not a canonical time zone\n * ID (the canonical time zone ID for the time zone is \"America/Indianapolis\". See\n * {@link TimeZone#getCanonicalID(const UnicodeString& id, UnicodeString& canonicalID, UErrorCode& status)} about ICU\n * canonical time zone IDs.\n * \n * <p>\n * In CLDR, most of time zone display names except location names are provided through meta zones. But a time zone may\n * have a specific name that is not shared with other time zones.\n *\n * For example, time zone \"Europe/London\" has English long name for standard time \"Greenwich Mean Time\", which is also\n * shared with other time zones. However, the long name for daylight saving time is \"British Summer Time\", which is only\n * used for \"Europe/London\".\n * \n * <p>\n * {@link #getTimeZoneDisplayName} is designed for accessing a name only used by a single time zone.\n * But is not necessarily mean that a subclass implementation use the same model with CLDR. A subclass implementation\n * may provide time zone names only through {@link #getTimeZoneDisplayName}, or only through {@link #getMetaZoneDisplayName},\n * or both.\n * \n * @draft ICU 50\n */\nclass U_I18N_API TimeZoneNames : public UObject {\npublic:\n    /**\n     * Destructor.\n     * @draft ICU 50\n     */\n    virtual ~TimeZoneNames();\n\n    /**\n     * Return true if the given TimeZoneNames objects are emantically equal.\n     * @param other the object to be compared with.\n     * @return Return TRUE if the given Format objects are semantically equal.\n     * @draft ICU 50\n     */\n    virtual UBool operator==(const TimeZoneNames& other) const = 0;\n\n    /**\n     * Return true if the given TimeZoneNames objects are not semantically\n     * equal.\n     * @param other the object to be compared with.\n     * @return Return TRUE if the given Format objects are not semantically equal.\n     * @draft ICU 50\n     */\n    UBool operator!=(const TimeZoneNames& other) const { return !operator==(other); }\n\n    /**\n     * Clone this object polymorphically.  The caller is responsible\n     * for deleting the result when done.\n     * @return A copy of the object\n     * @draft ICU 50\n     */\n    virtual TimeZoneNames* clone() const = 0;\n\n    /**\n     * Returns an instance of <code>TimeZoneDisplayNames</code> for the specified locale.\n     * \n     * @param locale The locale.\n     * @param status Recevies the status.\n     * @return An instance of <code>TimeZoneDisplayNames</code>\n     * @draft ICU 50\n     */\n    static TimeZoneNames* U_EXPORT2 createInstance(const Locale& locale, UErrorCode& status);\n\n    /**\n     * Returns an enumeration of all available meta zone IDs.\n     * @param status Recevies the status.\n     * @return an enumeration object, owned by the caller.\n     * @draft ICU 50\n     */\n    virtual StringEnumeration* getAvailableMetaZoneIDs(UErrorCode& status) const = 0;\n\n    /**\n     * Returns an enumeration of all available meta zone IDs used by the given time zone.\n     * @param tzID The canoical tiem zone ID.\n     * @param status Recevies the status.\n     * @return an enumeration object, owned by the caller.\n     * @draft ICU 50\n     */\n    virtual StringEnumeration* getAvailableMetaZoneIDs(const UnicodeString& tzID, UErrorCode& status) const = 0;\n\n    /**\n     * Returns the meta zone ID for the given canonical time zone ID at the given date.\n     * @param tzID The canonical time zone ID.\n     * @param date The date.\n     * @param mzID Receives the meta zone ID for the given time zone ID at the given date. If the time zone does not have a\n     *          corresponding meta zone at the given date or the implementation does not support meta zones, \"bogus\" state\n     *          is set.\n     * @return A reference to the result.\n     * @draft ICU 50\n     */\n    virtual UnicodeString& getMetaZoneID(const UnicodeString& tzID, UDate date, UnicodeString& mzID) const = 0;\n\n    /**\n     * Returns the reference zone ID for the given meta zone ID for the region.\n     * @param mzID The meta zone ID.\n     * @param region The region.\n     * @param tzID Receives the reference zone ID (\"golden zone\" in the LDML specification) for the given time zone ID for the\n     *          region. If the meta zone is unknown or the implementation does not support meta zones, \"bogus\" state\n     *          is set.\n     * @return A reference to the result.\n     * @draft ICU 50\n     */\n    virtual UnicodeString& getReferenceZoneID(const UnicodeString& mzID, const char* region, UnicodeString& tzID) const = 0;\n\n    /**\n     * Returns the display name of the meta zone.\n     * @param mzID The meta zone ID.\n     * @param type The display name type. See {@link #UTimeZoneNameType}.\n     * @param name Receives the display name of the meta zone. When this object does not have a localized display name for the given\n     *         meta zone with the specified type or the implementation does not provide any display names associated\n     *         with meta zones, \"bogus\" state is set.\n     * @return A reference to the result.\n     * @draft ICU 50\n     */\n    virtual UnicodeString& getMetaZoneDisplayName(const UnicodeString& mzID, UTimeZoneNameType type, UnicodeString& name) const = 0;\n\n    /**\n     * Returns the display name of the time zone. Unlike {@link #getDisplayName},\n     * this method does not get a name from a meta zone used by the time zone.\n     * @param tzID The canonical time zone ID.\n     * @param type The display name type. See {@link #UTimeZoneNameType}.\n     * @param name Receives the display name for the time zone. When this object does not have a localized display name for the given\n     *         time zone with the specified type, \"bogus\" state is set.\n     * @return A reference to the result.\n     * @draft ICU 50\n     */\n    virtual UnicodeString& getTimeZoneDisplayName(const UnicodeString& tzID, UTimeZoneNameType type, UnicodeString& name) const = 0;\n\n    /**\n     * Returns the exemplar location name for the given time zone. When this object does not have a localized location\n     * name, the default implementation may still returns a programmatically generated name with the logic described\n     * below.\n     * <ol>\n     * <li>Check if the ID contains \"/\". If not, return null.\n     * <li>Check if the ID does not start with \"Etc/\" or \"SystemV/\". If it does, return null.\n     * <li>Extract a substring after the last occurrence of \"/\".\n     * <li>Replace \"_\" with \" \".\n     * </ol>\n     * For example, \"New York\" is returned for the time zone ID \"America/New_York\" when this object does not have the\n     * localized location name.\n     * \n     * @param tzID The canonical time zone ID\n     * @param name Receives the exemplar location name for the given time zone, or \"bogus\" state is set when a localized\n     *          location name is not available and the fallback logic described above cannot extract location from the ID.\n     * @return A reference to the result.\n     * @draft ICU 50\n     */\n    virtual UnicodeString& getExemplarLocationName(const UnicodeString& tzID, UnicodeString& name) const;\n\n    /**\n     * Returns the display name of the time zone at the given date.\n     * <p>\n     * <b>Note:</b> This method calls the subclass's {@link #getTimeZoneDisplayName} first. When the\n     * result is bogus, this method calls {@link #getMetaZoneID} to get the meta zone ID mapped from the\n     * time zone, then calls {@link #getMetaZoneDisplayName}.\n     * \n     * @param tzID The canonical time zone ID.\n     * @param type The display name type. See {@link #UTimeZoneNameType}.\n     * @param date The date.\n     * @param name Receives the display name for the time zone at the given date. When this object does not have a localized display\n     *          name for the time zone with the specified type and date, \"bogus\" state is set.\n     * @return A reference to the result.\n     * @draft ICU 50\n     */\n    virtual UnicodeString& getDisplayName(const UnicodeString& tzID, UTimeZoneNameType type, UDate date, UnicodeString& name) const;\n\n    /**\n     * <code>MatchInfoCollection</code> represents a collection of time zone name matches used by\n     * {@link TimeZoneNames#find}.\n     * @internal\n     */\n    class U_I18N_API MatchInfoCollection : public UMemory {\n    public:\n        /**\n         * Constructor.\n         * @internal\n         */\n        MatchInfoCollection();\n        /**\n         * Destructor.\n         * @internal\n         */\n        virtual ~MatchInfoCollection();\n\n        /**\n         * Adds a zone match.\n         * @param nameType The name type.\n         * @param matchLength The match length.\n         * @param tzID The time zone ID.\n         * @param status Receives the status\n         * @internal\n         */\n        void addZone(UTimeZoneNameType nameType, int32_t matchLength,\n            const UnicodeString& tzID, UErrorCode& status);\n\n        /**\n         * Adds a meata zone match.\n         * @param nameType The name type.\n         * @param matchLength The match length.\n         * @param mzID The metazone ID.\n         * @param status Receives the status\n         * @internal\n         */\n        void addMetaZone(UTimeZoneNameType nameType, int32_t matchLength,\n            const UnicodeString& mzID, UErrorCode& status);\n\n        /**\n         * Returns the number of entries available in this object.\n         * @return The number of entries.\n         * @internal\n         */\n        int32_t size() const;\n\n        /**\n         * Returns the time zone name type of a match at the specified index.\n         * @param idx The index\n         * @return The time zone name type. If the specified idx is out of range,\n         *      it returns UTZNM_UNKNOWN.\n         * @see UTimeZoneNameType\n         * @internal\n         */\n        UTimeZoneNameType getNameTypeAt(int32_t idx) const;\n\n        /**\n         * Returns the match length of a match at the specified index.\n         * @param idx The index\n         * @return The match length. If the specified idx is out of range,\n         *      it returns 0.\n         * @internal\n         */\n        int32_t getMatchLengthAt(int32_t idx) const;\n\n        /**\n         * Gets the zone ID of a match at the specified index.\n         * @param idx The index\n         * @param tzID Receives the zone ID.\n         * @return TRUE if the zone ID was set to tzID.\n         * @internal\n         */\n        UBool getTimeZoneIDAt(int32_t idx, UnicodeString& tzID) const;\n\n        /**\n         * Gets the metazone ID of a match at the specified index.\n         * @param idx The index\n         * @param mzID Receives the metazone ID\n         * @return TRUE if the meta zone ID was set to mzID.\n         * @internal\n         */\n        UBool getMetaZoneIDAt(int32_t idx, UnicodeString& mzID) const;\n\n    private:\n        UVector* fMatches;  // vector of MatchEntry\n\n        UVector* matches(UErrorCode& status);\n    };\n\n    /**\n     * Finds time zone name prefix matches for the input text at the\n     * given offset and returns a collection of the matches.\n     * @param text The text.\n     * @param start The starting offset within the text.\n     * @param types The set of name types represented by bitwise flags of UTimeZoneNameType enums,\n     *              or UTZNM_UNKNOWN for all name types.\n     * @param status Receives the status.\n     * @return A collection of matches (owned by the caller), or NULL if no matches are found.\n     * @see UTimeZoneNameType\n     * @see MatchInfoCollection\n     * @internal\n     */\n    virtual MatchInfoCollection* find(const UnicodeString& text, int32_t start, uint32_t types, UErrorCode& status) const = 0;\n\nprivate:\n    // No ICU \"poor man's RTTI\" for this class nor its subclasses.\n    virtual UClassID getDynamicClassID() const;\n};\n\nU_NAMESPACE_END\n\n#endif  /* U_HIDE_INTERNAL_API */\n#endif\n#endif\n"
  },
  {
    "path": "deprecated/android/addons/icucompat/unicode/tzrule.h",
    "content": "/*\n*******************************************************************************\n* Copyright (C) 2007-2008, International Business Machines Corporation and    *\n* others. All Rights Reserved.                                                *\n*******************************************************************************\n*/\n#ifndef TZRULE_H\n#define TZRULE_H\n\n/**\n * \\file \n * \\brief C++ API: Time zone rule classes\n */\n\n#include \"unicode/utypes.h\"\n\n#if !UCONFIG_NO_FORMATTING\n\n#include \"unicode/uobject.h\"\n#include \"unicode/unistr.h\"\n#include \"unicode/dtrule.h\"\n\nU_NAMESPACE_BEGIN\n\n/**\n * <code>TimeZoneRule</code> is a class representing a rule for time zone.\n * <code>TimeZoneRule</code> has a set of time zone attributes, such as zone name,\n * raw offset (UTC offset for standard time) and daylight saving time offset.\n * \n * @stable ICU 3.8\n */\nclass U_I18N_API TimeZoneRule : public UObject {\npublic:\n    /**\n     * Destructor.\n     * @stable ICU 3.8\n     */\n    virtual ~TimeZoneRule();\n\n    /**\n     * Clone this TimeZoneRule object polymorphically. The caller owns the result and\n     * should delete it when done.\n     * @return  A copy of the object.\n     * @stable ICU 3.8\n     */\n    virtual TimeZoneRule* clone(void) const = 0;\n\n    /**\n     * Return true if the given <code>TimeZoneRule</code> objects are semantically equal. Objects\n     * of different subclasses are considered unequal.\n     * @param that  The object to be compared with.\n     * @return  true if the given <code>TimeZoneRule</code> objects are semantically equal.\n     * @stable ICU 3.8\n     */\n    virtual UBool operator==(const TimeZoneRule& that) const;\n\n    /**\n     * Return true if the given <code>TimeZoneRule</code> objects are semantically unequal. Objects\n     * of different subclasses are considered unequal.\n     * @param that  The object to be compared with.\n     * @return  true if the given <code>TimeZoneRule</code> objects are semantically unequal.\n     * @stable ICU 3.8\n     */\n    virtual UBool operator!=(const TimeZoneRule& that) const;\n\n    /**\n     * Fills in \"name\" with the name of this time zone.\n     * @param name  Receives the name of this time zone.\n     * @return  A reference to \"name\"\n     * @stable ICU 3.8\n     */\n    UnicodeString& getName(UnicodeString& name) const;\n\n    /**\n     * Gets the standard time offset.\n     * @return  The standard time offset from UTC in milliseconds.\n     * @stable ICU 3.8\n     */\n    int32_t getRawOffset(void) const;\n\n    /**\n     * Gets the amount of daylight saving delta time from the standard time.\n     * @return  The amount of daylight saving offset used by this rule\n     *          in milliseconds.\n     * @stable ICU 3.8\n     */\n    int32_t getDSTSavings(void) const;\n\n    /**\n     * Returns if this rule represents the same rule and offsets as another.\n     * When two <code>TimeZoneRule</code> objects differ only its names, this method\n     * returns true.\n     * @param other The <code>TimeZoneRule</code> object to be compared with.\n     * @return  true if the other <code>TimeZoneRule</code> is the same as this one.\n     * @stable ICU 3.8\n     */\n    virtual UBool isEquivalentTo(const TimeZoneRule& other) const;\n\n    /**\n     * Gets the very first time when this rule takes effect.\n     * @param prevRawOffset     The standard time offset from UTC before this rule\n     *                          takes effect in milliseconds.\n     * @param prevDSTSavings    The amount of daylight saving offset from the\n     *                          standard time.\n     * @param result            Receives the very first time when this rule takes effect.\n     * @return  true if the start time is available.  When false is returned, output parameter\n     *          \"result\" is unchanged.\n     * @stable ICU 3.8\n     */\n    virtual UBool getFirstStart(int32_t prevRawOffset, int32_t prevDSTSavings, UDate& result) const = 0;\n\n    /**\n     * Gets the final time when this rule takes effect.\n     * @param prevRawOffset     The standard time offset from UTC before this rule\n     *                          takes effect in milliseconds.\n     * @param prevDSTSavings    The amount of daylight saving offset from the\n     *                          standard time.\n     * @param result            Receives the final time when this rule takes effect.\n     * @return  true if the start time is available.  When false is returned, output parameter\n     *          \"result\" is unchanged.\n     * @stable ICU 3.8\n     */\n    virtual UBool getFinalStart(int32_t prevRawOffset, int32_t prevDSTSavings, UDate& result) const = 0;\n\n    /**\n     * Gets the first time when this rule takes effect after the specified time.\n     * @param base              The first start time after this base time will be returned.\n     * @param prevRawOffset     The standard time offset from UTC before this rule\n     *                          takes effect in milliseconds.\n     * @param prevDSTSavings    The amount of daylight saving offset from the\n     *                          standard time.\n     * @param inclusive         Whether the base time is inclusive or not.\n     * @param result            Receives The first time when this rule takes effect after\n     *                          the specified base time.\n     * @return  true if the start time is available.  When false is returned, output parameter\n     *          \"result\" is unchanged.\n     * @stable ICU 3.8\n     */\n    virtual UBool getNextStart(UDate base, int32_t prevRawOffset, int32_t prevDSTSavings,\n        UBool inclusive, UDate& result) const = 0;\n\n    /**\n     * Gets the most recent time when this rule takes effect before the specified time.\n     * @param base              The most recent time before this base time will be returned.\n     * @param prevRawOffset     The standard time offset from UTC before this rule\n     *                          takes effect in milliseconds.\n     * @param prevDSTSavings    The amount of daylight saving offset from the\n     *                          standard time.\n     * @param inclusive         Whether the base time is inclusive or not.\n     * @param result            Receives The most recent time when this rule takes effect before\n     *                          the specified base time.\n     * @return  true if the start time is available.  When false is returned, output parameter\n     *          \"result\" is unchanged.\n     * @stable ICU 3.8\n     */\n    virtual UBool getPreviousStart(UDate base, int32_t prevRawOffset, int32_t prevDSTSavings,\n        UBool inclusive, UDate& result) const = 0;\n\nprotected:\n\n    /**\n     * Constructs a <code>TimeZoneRule</code> with the name, the GMT offset of its\n     * standard time and the amount of daylight saving offset adjustment.\n     * @param name          The time zone name.\n     * @param rawOffset     The UTC offset of its standard time in milliseconds.\n     * @param dstSavings    The amount of daylight saving offset adjustment in milliseconds.\n     *                      If this ia a rule for standard time, the value of this argument is 0.\n     * @stable ICU 3.8\n     */\n    TimeZoneRule(const UnicodeString& name, int32_t rawOffset, int32_t dstSavings);\n\n    /**\n     * Copy constructor.\n     * @param source    The TimeZoneRule object to be copied.\n     * @stable ICU 3.8\n     */\n    TimeZoneRule(const TimeZoneRule& source);\n\n    /**\n     * Assignment operator.\n     * @param right The object to be copied.\n     * @stable ICU 3.8\n     */\n    TimeZoneRule& operator=(const TimeZoneRule& right);\n\nprivate:\n    UnicodeString fName; // time name\n    int32_t fRawOffset;  // UTC offset of the standard time in milliseconds\n    int32_t fDSTSavings; // DST saving amount in milliseconds\n};\n\n/**\n * <code>InitialTimeZoneRule</code> represents a time zone rule\n * representing a time zone effective from the beginning and\n * has no actual start times.\n * @stable ICU 3.8\n */\nclass U_I18N_API InitialTimeZoneRule : public TimeZoneRule {\npublic:\n    /**\n     * Constructs an <code>InitialTimeZoneRule</code> with the name, the GMT offset of its\n     * standard time and the amount of daylight saving offset adjustment.\n     * @param name          The time zone name.\n     * @param rawOffset     The UTC offset of its standard time in milliseconds.\n     * @param dstSavings    The amount of daylight saving offset adjustment in milliseconds.\n     *                      If this ia a rule for standard time, the value of this argument is 0.\n     * @stable ICU 3.8\n     */\n    InitialTimeZoneRule(const UnicodeString& name, int32_t rawOffset, int32_t dstSavings);\n\n    /**\n     * Copy constructor.\n     * @param source    The InitialTimeZoneRule object to be copied.\n     * @stable ICU 3.8\n     */\n    InitialTimeZoneRule(const InitialTimeZoneRule& source);\n\n    /**\n     * Destructor.\n     * @stable ICU 3.8\n     */\n    virtual ~InitialTimeZoneRule();\n\n    /**\n     * Clone this InitialTimeZoneRule object polymorphically. The caller owns the result and\n     * should delete it when done.\n     * @return    A copy of the object.\n     * @stable ICU 3.8\n     */\n    virtual InitialTimeZoneRule* clone(void) const;\n\n    /**\n     * Assignment operator.\n     * @param right The object to be copied.\n     * @stable ICU 3.8\n     */\n    InitialTimeZoneRule& operator=(const InitialTimeZoneRule& right);\n\n    /**\n     * Return true if the given <code>TimeZoneRule</code> objects are semantically equal. Objects\n     * of different subclasses are considered unequal.\n     * @param that  The object to be compared with.\n     * @return  true if the given <code>TimeZoneRule</code> objects are semantically equal.\n     * @stable ICU 3.8\n     */\n    virtual UBool operator==(const TimeZoneRule& that) const;\n\n    /**\n     * Return true if the given <code>TimeZoneRule</code> objects are semantically unequal. Objects\n     * of different subclasses are considered unequal.\n     * @param that  The object to be compared with.\n     * @return  true if the given <code>TimeZoneRule</code> objects are semantically unequal.\n     * @stable ICU 3.8\n     */\n    virtual UBool operator!=(const TimeZoneRule& that) const;\n\n    /**\n     * Gets the time when this rule takes effect in the given year.\n     * @param year              The Gregorian year, with 0 == 1 BCE, -1 == 2 BCE, etc.\n     * @param prevRawOffset     The standard time offset from UTC before this rule\n     *                          takes effect in milliseconds.\n     * @param prevDSTSavings    The amount of daylight saving offset from the\n     *                          standard time.\n     * @param result            Receives the start time in the year.\n     * @return  true if this rule takes effect in the year and the result is set to\n     *          \"result\".\n     * @stable ICU 3.8\n     */\n    UBool getStartInYear(int32_t year, int32_t prevRawOffset, int32_t prevDSTSavings, UDate& result) const;\n\n    /**\n     * Returns if this rule represents the same rule and offsets as another.\n     * When two <code>TimeZoneRule</code> objects differ only its names, this method\n     * returns true.\n     * @param that  The <code>TimeZoneRule</code> object to be compared with.\n     * @return  true if the other <code>TimeZoneRule</code> is equivalent to this one.\n     * @stable ICU 3.8\n     */\n    virtual UBool isEquivalentTo(const TimeZoneRule& that) const;\n\n    /**\n     * Gets the very first time when this rule takes effect.\n     * @param prevRawOffset     The standard time offset from UTC before this rule\n     *                          takes effect in milliseconds.\n     * @param prevDSTSavings    The amount of daylight saving offset from the\n     *                          standard time.\n     * @param result            Receives the very first time when this rule takes effect.\n     * @return  true if the start time is available.  When false is returned, output parameter\n     *          \"result\" is unchanged.\n     * @stable ICU 3.8\n     */\n    virtual UBool getFirstStart(int32_t prevRawOffset, int32_t prevDSTSavings, UDate& result) const;\n\n    /**\n     * Gets the final time when this rule takes effect.\n     * @param prevRawOffset     The standard time offset from UTC before this rule\n     *                          takes effect in milliseconds.\n     * @param prevDSTSavings    The amount of daylight saving offset from the\n     *                          standard time.\n     * @param result            Receives the final time when this rule takes effect.\n     * @return  true if the start time is available.  When false is returned, output parameter\n     *          \"result\" is unchanged.\n     * @stable ICU 3.8\n     */\n    virtual UBool getFinalStart(int32_t prevRawOffset, int32_t prevDSTSavings, UDate& result) const;\n\n    /**\n     * Gets the first time when this rule takes effect after the specified time.\n     * @param base              The first start time after this base time will be returned.\n     * @param prevRawOffset     The standard time offset from UTC before this rule\n     *                          takes effect in milliseconds.\n     * @param prevDSTSavings    The amount of daylight saving offset from the\n     *                          standard time.\n     * @param inclusive         Whether the base time is inclusive or not.\n     * @param result            Receives The first time when this rule takes effect after\n     *                          the specified base time.\n     * @return  true if the start time is available.  When false is returned, output parameter\n     *          \"result\" is unchanged.\n     * @stable ICU 3.8\n     */\n    virtual UBool getNextStart(UDate base, int32_t prevRawOffset, int32_t prevDSTSavings,\n        UBool inclusive, UDate& result) const;\n\n    /**\n     * Gets the most recent time when this rule takes effect before the specified time.\n     * @param base              The most recent time before this base time will be returned.\n     * @param prevRawOffset     The standard time offset from UTC before this rule\n     *                          takes effect in milliseconds.\n     * @param prevDSTSavings    The amount of daylight saving offset from the\n     *                          standard time.\n     * @param inclusive         Whether the base time is inclusive or not.\n     * @param result            Receives The most recent time when this rule takes effect before\n     *                          the specified base time.\n     * @return  true if the start time is available.  When false is returned, output parameter\n     *          \"result\" is unchanged.\n     * @stable ICU 3.8\n     */\n    virtual UBool getPreviousStart(UDate base, int32_t prevRawOffset, int32_t prevDSTSavings,\n        UBool inclusive, UDate& result) const;\n\npublic:\n    /**\n     * Return the class ID for this class. This is useful only for comparing to\n     * a return value from getDynamicClassID(). For example:\n     * <pre>\n     * .   Base* polymorphic_pointer = createPolymorphicObject();\n     * .   if (polymorphic_pointer->getDynamicClassID() ==\n     * .       erived::getStaticClassID()) ...\n     * </pre>\n     * @return          The class ID for all objects of this class.\n     * @stable ICU 3.8\n     */\n    static UClassID U_EXPORT2 getStaticClassID(void);\n\n    /**\n     * Returns a unique class ID POLYMORPHICALLY. Pure virtual override. This\n     * method is to implement a simple version of RTTI, since not all C++\n     * compilers support genuine RTTI. Polymorphic operator==() and clone()\n     * methods call this method.\n     *\n     * @return          The class ID for this object. All objects of a\n     *                  given class have the same class ID.  Objects of\n     *                  other classes have different class IDs.\n     * @stable ICU 3.8\n     */\n    virtual UClassID getDynamicClassID(void) const;\n};\n\n/**\n * <code>AnnualTimeZoneRule</code> is a class used for representing a time zone\n * rule which takes effect annually.  The calenday system used for the rule is\n * is based on Gregorian calendar\n * \n * @stable ICU 3.8\n */\nclass U_I18N_API AnnualTimeZoneRule : public TimeZoneRule {\npublic:\n    /**\n     * The constant representing the maximum year used for designating\n     * a rule is permanent.\n     */\n    static const int32_t MAX_YEAR;\n\n    /**\n     * Constructs a <code>AnnualTimeZoneRule</code> with the name, the GMT offset of its\n     * standard time, the amount of daylight saving offset adjustment, the annual start\n     * time rule and the start/until years.  The input DateTimeRule is copied by this\n     * constructor, so the caller remains responsible for deleting the object.\n     * @param name          The time zone name.\n     * @param rawOffset     The GMT offset of its standard time in milliseconds.\n     * @param dstSavings    The amount of daylight saving offset adjustment in\n     *                      milliseconds.  If this ia a rule for standard time,\n     *                      the value of this argument is 0.\n     * @param dateTimeRule  The start date/time rule repeated annually.\n     * @param startYear     The first year when this rule takes effect.\n     * @param endYear       The last year when this rule takes effect.  If this\n     *                      rule is effective forever in future, specify MAX_YEAR.\n     * @stable ICU 3.8\n     */\n    AnnualTimeZoneRule(const UnicodeString& name, int32_t rawOffset, int32_t dstSavings,\n            const DateTimeRule& dateTimeRule, int32_t startYear, int32_t endYear);\n\n    /**\n     * Constructs a <code>AnnualTimeZoneRule</code> with the name, the GMT offset of its\n     * standard time, the amount of daylight saving offset adjustment, the annual start\n     * time rule and the start/until years.  The input DateTimeRule object is adopted\n     * by this object, therefore, the caller must not delete the object.\n     * @param name          The time zone name.\n     * @param rawOffset     The GMT offset of its standard time in milliseconds.\n     * @param dstSavings    The amount of daylight saving offset adjustment in\n     *                      milliseconds.  If this ia a rule for standard time,\n     *                      the value of this argument is 0.\n     * @param dateTimeRule  The start date/time rule repeated annually.\n     * @param startYear     The first year when this rule takes effect.\n     * @param endYear       The last year when this rule takes effect.  If this\n     *                      rule is effective forever in future, specify MAX_YEAR.\n     * @stable ICU 3.8\n     */\n    AnnualTimeZoneRule(const UnicodeString& name, int32_t rawOffset, int32_t dstSavings,\n            DateTimeRule* dateTimeRule, int32_t startYear, int32_t endYear);\n\n    /**\n     * Copy constructor.\n     * @param source    The AnnualTimeZoneRule object to be copied.\n     * @stable ICU 3.8\n     */\n    AnnualTimeZoneRule(const AnnualTimeZoneRule& source);\n\n    /**\n     * Destructor.\n     * @stable ICU 3.8\n     */\n    virtual ~AnnualTimeZoneRule();\n\n    /**\n     * Clone this AnnualTimeZoneRule object polymorphically. The caller owns the result and\n     * should delete it when done.\n     * @return    A copy of the object.\n     * @stable ICU 3.8\n     */\n    virtual AnnualTimeZoneRule* clone(void) const;\n\n    /**\n     * Assignment operator.\n     * @param right The object to be copied.\n     * @stable ICU 3.8\n     */\n    AnnualTimeZoneRule& operator=(const AnnualTimeZoneRule& right);\n\n    /**\n     * Return true if the given <code>TimeZoneRule</code> objects are semantically equal. Objects\n     * of different subclasses are considered unequal.\n     * @param that  The object to be compared with.\n     * @return  true if the given <code>TimeZoneRule</code> objects are semantically equal.\n     * @stable ICU 3.8\n     */\n    virtual UBool operator==(const TimeZoneRule& that) const;\n\n    /**\n     * Return true if the given <code>TimeZoneRule</code> objects are semantically unequal. Objects\n     * of different subclasses are considered unequal.\n     * @param that  The object to be compared with.\n     * @return  true if the given <code>TimeZoneRule</code> objects are semantically unequal.\n     * @stable ICU 3.8\n     */\n    virtual UBool operator!=(const TimeZoneRule& that) const;\n\n    /**\n     * Gets the start date/time rule used by this rule.\n     * @return  The <code>AnnualDateTimeRule</code> which represents the start date/time\n     *          rule used by this time zone rule.\n     * @stable ICU 3.8\n     */\n    const DateTimeRule* getRule(void) const;\n\n    /**\n     * Gets the first year when this rule takes effect.\n     * @return  The start year of this rule.  The year is in Gregorian calendar\n     *          with 0 == 1 BCE, -1 == 2 BCE, etc.\n     * @stable ICU 3.8\n     */\n    int32_t getStartYear(void) const;\n\n    /**\n     * Gets the end year when this rule takes effect.\n     * @return  The end year of this rule (inclusive). The year is in Gregorian calendar\n     *          with 0 == 1 BCE, -1 == 2 BCE, etc.\n     * @stable ICU 3.8\n     */\n    int32_t getEndYear(void) const;\n\n    /**\n     * Gets the time when this rule takes effect in the given year.\n     * @param year              The Gregorian year, with 0 == 1 BCE, -1 == 2 BCE, etc.\n     * @param prevRawOffset     The standard time offset from UTC before this rule\n     *                          takes effect in milliseconds.\n     * @param prevDSTSavings    The amount of daylight saving offset from the\n     *                          standard time.\n     * @param result            Receives the start time in the year.\n     * @return  true if this rule takes effect in the year and the result is set to\n     *          \"result\".\n     * @stable ICU 3.8\n     */\n    UBool getStartInYear(int32_t year, int32_t prevRawOffset, int32_t prevDSTSavings, UDate& result) const;\n\n    /**\n     * Returns if this rule represents the same rule and offsets as another.\n     * When two <code>TimeZoneRule</code> objects differ only its names, this method\n     * returns true.\n     * @param that  The <code>TimeZoneRule</code> object to be compared with.\n     * @return  true if the other <code>TimeZoneRule</code> is equivalent to this one.\n     * @stable ICU 3.8\n     */\n    virtual UBool isEquivalentTo(const TimeZoneRule& that) const;\n\n    /**\n     * Gets the very first time when this rule takes effect.\n     * @param prevRawOffset     The standard time offset from UTC before this rule\n     *                          takes effect in milliseconds.\n     * @param prevDSTSavings    The amount of daylight saving offset from the\n     *                          standard time.\n     * @param result            Receives the very first time when this rule takes effect.\n     * @return  true if the start time is available.  When false is returned, output parameter\n     *          \"result\" is unchanged.\n     * @stable ICU 3.8\n     */\n    virtual UBool getFirstStart(int32_t prevRawOffset, int32_t prevDSTSavings, UDate& result) const;\n\n    /**\n     * Gets the final time when this rule takes effect.\n     * @param prevRawOffset     The standard time offset from UTC before this rule\n     *                          takes effect in milliseconds.\n     * @param prevDSTSavings    The amount of daylight saving offset from the\n     *                          standard time.\n     * @param result            Receives the final time when this rule takes effect.\n     * @return  true if the start time is available.  When false is returned, output parameter\n     *          \"result\" is unchanged.\n     * @stable ICU 3.8\n     */\n    virtual UBool getFinalStart(int32_t prevRawOffset, int32_t prevDSTSavings, UDate& result) const;\n\n    /**\n     * Gets the first time when this rule takes effect after the specified time.\n     * @param base              The first start time after this base time will be returned.\n     * @param prevRawOffset     The standard time offset from UTC before this rule\n     *                          takes effect in milliseconds.\n     * @param prevDSTSavings    The amount of daylight saving offset from the\n     *                          standard time.\n     * @param inclusive         Whether the base time is inclusive or not.\n     * @param result            Receives The first time when this rule takes effect after\n     *                          the specified base time.\n     * @return  true if the start time is available.  When false is returned, output parameter\n     *          \"result\" is unchanged.\n     * @stable ICU 3.8\n     */\n    virtual UBool getNextStart(UDate base, int32_t prevRawOffset, int32_t prevDSTSavings,\n        UBool inclusive, UDate& result) const;\n\n    /**\n     * Gets the most recent time when this rule takes effect before the specified time.\n     * @param base              The most recent time before this base time will be returned.\n     * @param prevRawOffset     The standard time offset from UTC before this rule\n     *                          takes effect in milliseconds.\n     * @param prevDSTSavings    The amount of daylight saving offset from the\n     *                          standard time.\n     * @param inclusive         Whether the base time is inclusive or not.\n     * @param result            Receives The most recent time when this rule takes effect before\n     *                          the specified base time.\n     * @return  true if the start time is available.  When false is returned, output parameter\n     *          \"result\" is unchanged.\n     * @stable ICU 3.8\n     */\n    virtual UBool getPreviousStart(UDate base, int32_t prevRawOffset, int32_t prevDSTSavings,\n        UBool inclusive, UDate& result) const;\n\n\nprivate:\n    DateTimeRule* fDateTimeRule;\n    int32_t fStartYear;\n    int32_t fEndYear;\n\npublic:\n    /**\n     * Return the class ID for this class. This is useful only for comparing to\n     * a return value from getDynamicClassID(). For example:\n     * <pre>\n     * .   Base* polymorphic_pointer = createPolymorphicObject();\n     * .   if (polymorphic_pointer->getDynamicClassID() ==\n     * .       erived::getStaticClassID()) ...\n     * </pre>\n     * @return          The class ID for all objects of this class.\n     * @stable ICU 3.8\n     */\n    static UClassID U_EXPORT2 getStaticClassID(void);\n\n    /**\n     * Returns a unique class ID POLYMORPHICALLY. Pure virtual override. This\n     * method is to implement a simple version of RTTI, since not all C++\n     * compilers support genuine RTTI. Polymorphic operator==() and clone()\n     * methods call this method.\n     *\n     * @return          The class ID for this object. All objects of a\n     *                  given class have the same class ID.  Objects of\n     *                  other classes have different class IDs.\n     * @stable ICU 3.8\n     */\n    virtual UClassID getDynamicClassID(void) const;\n};\n\n/**\n * <code>TimeArrayTimeZoneRule</code> represents a time zone rule whose start times are\n * defined by an array of milliseconds since the standard base time.\n * \n * @stable ICU 3.8\n */\nclass U_I18N_API TimeArrayTimeZoneRule : public TimeZoneRule {\npublic:\n    /**\n     * Constructs a <code>TimeArrayTimeZoneRule</code> with the name, the GMT offset of its\n     * standard time, the amount of daylight saving offset adjustment and\n     * the array of times when this rule takes effect.\n     * @param name          The time zone name.\n     * @param rawOffset     The UTC offset of its standard time in milliseconds.\n     * @param dstSavings    The amount of daylight saving offset adjustment in\n     *                      milliseconds.  If this ia a rule for standard time,\n     *                      the value of this argument is 0.\n     * @param startTimes    The array start times in milliseconds since the base time\n     *                      (January 1, 1970, 00:00:00).\n     * @param numStartTimes The number of elements in the parameter \"startTimes\"\n     * @param timeRuleType  The time type of the start times, which is one of\n     *                      <code>DataTimeRule::WALL_TIME</code>, <code>STANDARD_TIME</code>\n     *                      and <code>UTC_TIME</code>.\n     * @stable ICU 3.8\n     */\n    TimeArrayTimeZoneRule(const UnicodeString& name, int32_t rawOffset, int32_t dstSavings,\n        const UDate* startTimes, int32_t numStartTimes, DateTimeRule::TimeRuleType timeRuleType);\n\n    /**\n     * Copy constructor.\n     * @param source    The TimeArrayTimeZoneRule object to be copied.\n     * @stable ICU 3.8\n     */\n    TimeArrayTimeZoneRule(const TimeArrayTimeZoneRule& source);\n\n    /**\n     * Destructor.\n     * @stable ICU 3.8\n     */\n    virtual ~TimeArrayTimeZoneRule();\n\n    /**\n     * Clone this TimeArrayTimeZoneRule object polymorphically. The caller owns the result and\n     * should delete it when done.\n     * @return    A copy of the object.\n     * @stable ICU 3.8\n     */\n    virtual TimeArrayTimeZoneRule* clone(void) const;\n\n    /**\n     * Assignment operator.\n     * @param right The object to be copied.\n     * @stable ICU 3.8\n     */\n    TimeArrayTimeZoneRule& operator=(const TimeArrayTimeZoneRule& right);\n\n    /**\n     * Return true if the given <code>TimeZoneRule</code> objects are semantically equal. Objects\n     * of different subclasses are considered unequal.\n     * @param that  The object to be compared with.\n     * @return  true if the given <code>TimeZoneRule</code> objects are semantically equal.\n     * @stable ICU 3.8\n     */\n    virtual UBool operator==(const TimeZoneRule& that) const;\n\n    /**\n     * Return true if the given <code>TimeZoneRule</code> objects are semantically unequal. Objects\n     * of different subclasses are considered unequal.\n     * @param that  The object to be compared with.\n     * @return  true if the given <code>TimeZoneRule</code> objects are semantically unequal.\n     * @stable ICU 3.8\n     */\n    virtual UBool operator!=(const TimeZoneRule& that) const;\n\n    /**\n     * Gets the time type of the start times used by this rule.  The return value\n     * is either <code>DateTimeRule::WALL_TIME</code> or <code>STANDARD_TIME</code>\n     * or <code>UTC_TIME</code>.\n     * \n     * @return The time type used of the start times used by this rule.\n     * @stable ICU 3.8\n     */\n    DateTimeRule::TimeRuleType getTimeType(void) const;\n\n    /**\n     * Gets a start time at the index stored in this rule.\n     * @param index     The index of start times\n     * @param result    Receives the start time at the index\n     * @return  true if the index is within the valid range and\n     *          and the result is set.  When false, the output\n     *          parameger \"result\" is unchanged.\n     * @stable ICU 3.8\n     */\n    UBool getStartTimeAt(int32_t index, UDate& result) const;\n\n    /**\n     * Returns the number of start times stored in this rule\n     * @return The number of start times.\n     * @stable ICU 3.8\n     */\n    int32_t countStartTimes(void) const;\n\n    /**\n     * Returns if this rule represents the same rule and offsets as another.\n     * When two <code>TimeZoneRule</code> objects differ only its names, this method\n     * returns true.\n     * @param that  The <code>TimeZoneRule</code> object to be compared with.\n     * @return  true if the other <code>TimeZoneRule</code> is equivalent to this one.\n     * @stable ICU 3.8\n     */\n    virtual UBool isEquivalentTo(const TimeZoneRule& that) const;\n\n    /**\n     * Gets the very first time when this rule takes effect.\n     * @param prevRawOffset     The standard time offset from UTC before this rule\n     *                          takes effect in milliseconds.\n     * @param prevDSTSavings    The amount of daylight saving offset from the\n     *                          standard time.\n     * @param result            Receives the very first time when this rule takes effect.\n     * @return  true if the start time is available.  When false is returned, output parameter\n     *          \"result\" is unchanged.\n     * @stable ICU 3.8\n     */\n    virtual UBool getFirstStart(int32_t prevRawOffset, int32_t prevDSTSavings, UDate& result) const;\n\n    /**\n     * Gets the final time when this rule takes effect.\n     * @param prevRawOffset     The standard time offset from UTC before this rule\n     *                          takes effect in milliseconds.\n     * @param prevDSTSavings    The amount of daylight saving offset from the\n     *                          standard time.\n     * @param result            Receives the final time when this rule takes effect.\n     * @return  true if the start time is available.  When false is returned, output parameter\n     *          \"result\" is unchanged.\n     * @stable ICU 3.8\n     */\n    virtual UBool getFinalStart(int32_t prevRawOffset, int32_t prevDSTSavings, UDate& result) const;\n\n    /**\n     * Gets the first time when this rule takes effect after the specified time.\n     * @param base              The first start time after this base time will be returned.\n     * @param prevRawOffset     The standard time offset from UTC before this rule\n     *                          takes effect in milliseconds.\n     * @param prevDSTSavings    The amount of daylight saving offset from the\n     *                          standard time.\n     * @param inclusive         Whether the base time is inclusive or not.\n     * @param result            Receives The first time when this rule takes effect after\n     *                          the specified base time.\n     * @return  true if the start time is available.  When false is returned, output parameter\n     *          \"result\" is unchanged.\n     * @stable ICU 3.8\n     */\n    virtual UBool getNextStart(UDate base, int32_t prevRawOffset, int32_t prevDSTSavings,\n        UBool inclusive, UDate& result) const;\n\n    /**\n     * Gets the most recent time when this rule takes effect before the specified time.\n     * @param base              The most recent time before this base time will be returned.\n     * @param prevRawOffset     The standard time offset from UTC before this rule\n     *                          takes effect in milliseconds.\n     * @param prevDSTSavings    The amount of daylight saving offset from the\n     *                          standard time.\n     * @param inclusive         Whether the base time is inclusive or not.\n     * @param result            Receives The most recent time when this rule takes effect before\n     *                          the specified base time.\n     * @return  true if the start time is available.  When false is returned, output parameter\n     *          \"result\" is unchanged.\n     * @stable ICU 3.8\n     */\n    virtual UBool getPreviousStart(UDate base, int32_t prevRawOffset, int32_t prevDSTSavings,\n        UBool inclusive, UDate& result) const;\n\n\nprivate:\n    enum { TIMEARRAY_STACK_BUFFER_SIZE = 32 };\n    UBool initStartTimes(const UDate source[], int32_t size, UErrorCode& ec);\n    UDate getUTC(UDate time, int32_t raw, int32_t dst) const;\n\n    DateTimeRule::TimeRuleType  fTimeRuleType;\n    int32_t fNumStartTimes;\n    UDate*  fStartTimes;\n    UDate   fLocalStartTimes[TIMEARRAY_STACK_BUFFER_SIZE];\n\npublic:\n    /**\n     * Return the class ID for this class. This is useful only for comparing to\n     * a return value from getDynamicClassID(). For example:\n     * <pre>\n     * .   Base* polymorphic_pointer = createPolymorphicObject();\n     * .   if (polymorphic_pointer->getDynamicClassID() ==\n     * .       erived::getStaticClassID()) ...\n     * </pre>\n     * @return          The class ID for all objects of this class.\n     * @stable ICU 3.8\n     */\n    static UClassID U_EXPORT2 getStaticClassID(void);\n\n    /**\n     * Returns a unique class ID POLYMORPHICALLY. Pure virtual override. This\n     * method is to implement a simple version of RTTI, since not all C++\n     * compilers support genuine RTTI. Polymorphic operator==() and clone()\n     * methods call this method.\n     *\n     * @return          The class ID for this object. All objects of a\n     *                  given class have the same class ID.  Objects of\n     *                  other classes have different class IDs.\n     * @stable ICU 3.8\n     */\n    virtual UClassID getDynamicClassID(void) const;\n};\n\n\nU_NAMESPACE_END\n\n#endif /* #if !UCONFIG_NO_FORMATTING */\n\n#endif // TZRULE_H\n\n//eof\n"
  },
  {
    "path": "deprecated/android/addons/icucompat/unicode/tztrans.h",
    "content": "/*\n*******************************************************************************\n* Copyright (C) 2007-2008, International Business Machines Corporation and         *\n* others. All Rights Reserved.                                                *\n*******************************************************************************\n*/\n#ifndef TZTRANS_H\n#define TZTRANS_H\n\n/**\n * \\file \n * \\brief C++ API: Time zone transition\n */\n\n#include \"unicode/utypes.h\"\n\n#if !UCONFIG_NO_FORMATTING\n\n#include \"unicode/uobject.h\"\n\nU_NAMESPACE_BEGIN\n\n// Forward declaration\nclass TimeZoneRule;\n\n/**\n * <code>TimeZoneTransition</code> is a class representing a time zone transition.\n * An instance has a time of transition and rules for both before and after the transition.\n * @stable ICU 3.8\n */\nclass U_I18N_API TimeZoneTransition : public UObject {\npublic:\n    /**\n     * Constructs a <code>TimeZoneTransition</code> with the time and the rules before/after\n     * the transition.\n     * \n     * @param time  The time of transition in milliseconds since the base time.\n     * @param from  The time zone rule used before the transition.\n     * @param to    The time zone rule used after the transition.\n     * @stable ICU 3.8\n     */\n    TimeZoneTransition(UDate time, const TimeZoneRule& from, const TimeZoneRule& to);\n\n    /**\n     * Constructs an empty <code>TimeZoneTransition</code>\n     * @stable ICU 3.8\n     */\n    TimeZoneTransition();\n\n    /**\n     * Copy constructor.\n     * @param source    The TimeZoneTransition object to be copied.\n     * @stable ICU 3.8\n     */\n    TimeZoneTransition(const TimeZoneTransition& source);\n\n    /**\n     * Destructor.\n     * @stable ICU 3.8\n     */\n    ~TimeZoneTransition();\n\n    /**\n     * Clone this TimeZoneTransition object polymorphically. The caller owns the result and\n     * should delete it when done.\n     * @return  A copy of the object.\n     * @stable ICU 3.8\n     */\n    TimeZoneTransition* clone(void) const;\n\n    /**\n     * Assignment operator.\n     * @param right The object to be copied.\n     * @stable ICU 3.8\n     */\n    TimeZoneTransition& operator=(const TimeZoneTransition& right);\n\n    /**\n     * Return true if the given TimeZoneTransition objects are semantically equal. Objects\n     * of different subclasses are considered unequal.\n     * @param that  The object to be compared with.\n     * @return  true if the given TimeZoneTransition objects are semantically equal.\n     * @stable ICU 3.8\n     */\n    UBool operator==(const TimeZoneTransition& that) const;\n\n    /**\n     * Return true if the given TimeZoneTransition objects are semantically unequal. Objects\n     * of different subclasses are considered unequal.\n     * @param that  The object to be compared with.\n     * @return  true if the given TimeZoneTransition objects are semantically unequal.\n     * @stable ICU 3.8\n     */\n    UBool operator!=(const TimeZoneTransition& that) const;\n\n    /**\n     * Returns the time of transition in milliseconds.\n     * @return The time of the transition in milliseconds since the 1970 Jan 1 epoch time.\n     * @stable ICU 3.8\n     */\n    UDate getTime(void) const;\n\n    /**\n     * Sets the time of transition in milliseconds.\n     * @param time The time of the transition in milliseconds since the 1970 Jan 1 epoch time.\n     * @stable ICU 3.8\n     */\n    void setTime(UDate time);\n\n    /**\n     * Returns the rule used before the transition.\n     * @return The time zone rule used after the transition.\n     * @stable ICU 3.8\n     */\n    const TimeZoneRule* getFrom(void) const;\n\n    /**\n     * Sets the rule used before the transition.  The caller remains\n     * responsible for deleting the <code>TimeZoneRule</code> object.\n     * @param from The time zone rule used before the transition.\n     * @stable ICU 3.8\n     */\n    void setFrom(const TimeZoneRule& from);\n\n    /**\n     * Adopts the rule used before the transition.  The caller must\n     * not delete the <code>TimeZoneRule</code> object passed in.\n     * @param from The time zone rule used before the transition.\n     * @stable ICU 3.8\n     */\n    void adoptFrom(TimeZoneRule* from);\n\n    /**\n     * Sets the rule used after the transition.  The caller remains\n     * responsible for deleting the <code>TimeZoneRule</code> object.\n     * @param to The time zone rule used after the transition.\n     * @stable ICU 3.8\n     */\n    void setTo(const TimeZoneRule& to);\n\n    /**\n     * Adopts the rule used after the transition.  The caller must\n     * not delete the <code>TimeZoneRule</code> object passed in.\n     * @param to The time zone rule used after the transition.\n     * @stable ICU 3.8\n     */\n    void adoptTo(TimeZoneRule* to);\n\n    /**\n     * Returns the rule used after the transition.\n     * @return The time zone rule used after the transition.\n     * @stable ICU 3.8\n     */\n    const TimeZoneRule* getTo(void) const;\n\nprivate:\n    UDate   fTime;\n    TimeZoneRule*   fFrom;\n    TimeZoneRule*   fTo;\n\npublic:\n    /**\n     * Return the class ID for this class. This is useful only for comparing to\n     * a return value from getDynamicClassID(). For example:\n     * <pre>\n     * .   Base* polymorphic_pointer = createPolymorphicObject();\n     * .   if (polymorphic_pointer->getDynamicClassID() ==\n     * .       erived::getStaticClassID()) ...\n     * </pre>\n     * @return          The class ID for all objects of this class.\n     * @stable ICU 3.8\n     */\n    static UClassID U_EXPORT2 getStaticClassID(void);\n\n    /**\n     * Returns a unique class ID POLYMORPHICALLY. Pure virtual override. This\n     * method is to implement a simple version of RTTI, since not all C++\n     * compilers support genuine RTTI. Polymorphic operator==() and clone()\n     * methods call this method.\n     *\n     * @return          The class ID for this object. All objects of a\n     *                  given class have the same class ID.  Objects of\n     *                  other classes have different class IDs.\n     * @stable ICU 3.8\n     */\n    virtual UClassID getDynamicClassID(void) const;\n};\n\nU_NAMESPACE_END\n\n#endif /* #if !UCONFIG_NO_FORMATTING */\n\n#endif // TZTRANS_H\n\n//eof\n"
  },
  {
    "path": "deprecated/android/addons/icucompat/unicode/ubidi.h",
    "content": "/*\n******************************************************************************\n*\n*   Copyright (C) 1999-2012, International Business Machines\n*   Corporation and others.  All Rights Reserved.\n*\n******************************************************************************\n*   file name:  ubidi.h\n*   encoding:   US-ASCII\n*   tab size:   8 (not used)\n*   indentation:4\n*\n*   created on: 1999jul27\n*   created by: Markus W. Scherer, updated by Matitiahu Allouche\n*/\n\n#ifndef UBIDI_H\n#define UBIDI_H\n\n#include \"unicode/utypes.h\"\n#include \"unicode/uchar.h\"\n#include \"unicode/localpointer.h\"\n\n/**\n *\\file\n * \\brief C API: Bidi algorithm\n *\n * <h2>Bidi algorithm for ICU</h2>\n *\n * This is an implementation of the Unicode Bidirectional Algorithm.\n * The algorithm is defined in the\n * <a href=\"http://www.unicode.org/unicode/reports/tr9/\">Unicode Standard Annex #9</a>.<p>\n *\n * Note: Libraries that perform a bidirectional algorithm and\n * reorder strings accordingly are sometimes called \"Storage Layout Engines\".\n * ICU's Bidi and shaping (u_shapeArabic()) APIs can be used at the core of such\n * \"Storage Layout Engines\".\n *\n * <h3>General remarks about the API:</h3>\n *\n * In functions with an error code parameter,\n * the <code>pErrorCode</code> pointer must be valid\n * and the value that it points to must not indicate a failure before\n * the function call. Otherwise, the function returns immediately.\n * After the function call, the value indicates success or failure.<p>\n *\n * The &quot;limit&quot; of a sequence of characters is the position just after their\n * last character, i.e., one more than that position.<p>\n *\n * Some of the API functions provide access to &quot;runs&quot;.\n * Such a &quot;run&quot; is defined as a sequence of characters\n * that are at the same embedding level\n * after performing the Bidi algorithm.<p>\n *\n * @author Markus W. Scherer\n * @version 1.0\n *\n *\n * <h4> Sample code for the ICU Bidi API </h4>\n *\n * <h5>Rendering a paragraph with the ICU Bidi API</h5>\n *\n * This is (hypothetical) sample code that illustrates\n * how the ICU Bidi API could be used to render a paragraph of text.\n * Rendering code depends highly on the graphics system,\n * therefore this sample code must make a lot of assumptions,\n * which may or may not match any existing graphics system's properties.\n *\n * <p>The basic assumptions are:</p>\n * <ul>\n * <li>Rendering is done from left to right on a horizontal line.</li>\n * <li>A run of single-style, unidirectional text can be rendered at once.</li>\n * <li>Such a run of text is passed to the graphics system with\n *     characters (code units) in logical order.</li>\n * <li>The line-breaking algorithm is very complicated\n *     and Locale-dependent -\n *     and therefore its implementation omitted from this sample code.</li>\n * </ul>\n *\n * <pre>\n * \\code\n *#include \"unicode/ubidi.h\"\n *\n *typedef enum {\n *     styleNormal=0, styleSelected=1,\n *     styleBold=2, styleItalics=4,\n *     styleSuper=8, styleSub=16\n *} Style;\n *\n *typedef struct { int32_t limit; Style style; } StyleRun;\n *\n *int getTextWidth(const UChar *text, int32_t start, int32_t limit,\n *                  const StyleRun *styleRuns, int styleRunCount);\n *\n * // set *pLimit and *pStyleRunLimit for a line\n * // from text[start] and from styleRuns[styleRunStart]\n * // using ubidi_getLogicalRun(para, ...)\n *void getLineBreak(const UChar *text, int32_t start, int32_t *pLimit,\n *                  UBiDi *para,\n *                  const StyleRun *styleRuns, int styleRunStart, int *pStyleRunLimit,\n *                  int *pLineWidth);\n *\n * // render runs on a line sequentially, always from left to right\n *\n * // prepare rendering a new line\n * void startLine(UBiDiDirection textDirection, int lineWidth);\n *\n * // render a run of text and advance to the right by the run width\n * // the text[start..limit-1] is always in logical order\n * void renderRun(const UChar *text, int32_t start, int32_t limit,\n *               UBiDiDirection textDirection, Style style);\n *\n * // We could compute a cross-product\n * // from the style runs with the directional runs\n * // and then reorder it.\n * // Instead, here we iterate over each run type\n * // and render the intersections -\n * // with shortcuts in simple (and common) cases.\n * // renderParagraph() is the main function.\n *\n * // render a directional run with\n * // (possibly) multiple style runs intersecting with it\n * void renderDirectionalRun(const UChar *text,\n *                           int32_t start, int32_t limit,\n *                           UBiDiDirection direction,\n *                           const StyleRun *styleRuns, int styleRunCount) {\n *     int i;\n *\n *     // iterate over style runs\n *     if(direction==UBIDI_LTR) {\n *         int styleLimit;\n *\n *         for(i=0; i<styleRunCount; ++i) {\n *             styleLimit=styleRun[i].limit;\n *             if(start<styleLimit) {\n *                 if(styleLimit>limit) { styleLimit=limit; }\n *                 renderRun(text, start, styleLimit,\n *                           direction, styleRun[i].style);\n *                 if(styleLimit==limit) { break; }\n *                 start=styleLimit;\n *             }\n *         }\n *     } else {\n *         int styleStart;\n *\n *         for(i=styleRunCount-1; i>=0; --i) {\n *             if(i>0) {\n *                 styleStart=styleRun[i-1].limit;\n *             } else {\n *                 styleStart=0;\n *             }\n *             if(limit>=styleStart) {\n *                 if(styleStart<start) { styleStart=start; }\n *                 renderRun(text, styleStart, limit,\n *                           direction, styleRun[i].style);\n *                 if(styleStart==start) { break; }\n *                 limit=styleStart;\n *             }\n *         }\n *     }\n * }\n *\n * // the line object represents text[start..limit-1]\n * void renderLine(UBiDi *line, const UChar *text,\n *                 int32_t start, int32_t limit,\n *                 const StyleRun *styleRuns, int styleRunCount) {\n *     UBiDiDirection direction=ubidi_getDirection(line);\n *     if(direction!=UBIDI_MIXED) {\n *         // unidirectional\n *         if(styleRunCount<=1) {\n *             renderRun(text, start, limit, direction, styleRuns[0].style);\n *         } else {\n *             renderDirectionalRun(text, start, limit,\n *                                  direction, styleRuns, styleRunCount);\n *         }\n *     } else {\n *         // mixed-directional\n *         int32_t count, i, length;\n *         UBiDiLevel level;\n *\n *         count=ubidi_countRuns(para, pErrorCode);\n *         if(U_SUCCESS(*pErrorCode)) {\n *             if(styleRunCount<=1) {\n *                 Style style=styleRuns[0].style;\n *\n *                 // iterate over directional runs\n *                for(i=0; i<count; ++i) {\n *                    direction=ubidi_getVisualRun(para, i, &start, &length);\n *                     renderRun(text, start, start+length, direction, style);\n *                }\n *             } else {\n *                 int32_t j;\n *\n *                 // iterate over both directional and style runs\n *                 for(i=0; i<count; ++i) {\n *                     direction=ubidi_getVisualRun(line, i, &start, &length);\n *                     renderDirectionalRun(text, start, start+length,\n *                                          direction, styleRuns, styleRunCount);\n *                 }\n *             }\n *         }\n *     }\n * }\n *\n *void renderParagraph(const UChar *text, int32_t length,\n *                     UBiDiDirection textDirection,\n *                      const StyleRun *styleRuns, int styleRunCount,\n *                      int lineWidth,\n *                      UErrorCode *pErrorCode) {\n *     UBiDi *para;\n *\n *     if(pErrorCode==NULL || U_FAILURE(*pErrorCode) || length<=0) {\n *         return;\n *     }\n *\n *     para=ubidi_openSized(length, 0, pErrorCode);\n *     if(para==NULL) { return; }\n *\n *     ubidi_setPara(para, text, length,\n *                   textDirection ? UBIDI_DEFAULT_RTL : UBIDI_DEFAULT_LTR,\n *                   NULL, pErrorCode);\n *     if(U_SUCCESS(*pErrorCode)) {\n *         UBiDiLevel paraLevel=1&ubidi_getParaLevel(para);\n *         StyleRun styleRun={ length, styleNormal };\n *         int width;\n *\n *         if(styleRuns==NULL || styleRunCount<=0) {\n *            styleRunCount=1;\n *             styleRuns=&styleRun;\n *         }\n *\n *        // assume styleRuns[styleRunCount-1].limit>=length\n *\n *         width=getTextWidth(text, 0, length, styleRuns, styleRunCount);\n *         if(width<=lineWidth) {\n *             // everything fits onto one line\n *\n *            // prepare rendering a new line from either left or right\n *             startLine(paraLevel, width);\n *\n *             renderLine(para, text, 0, length,\n *                        styleRuns, styleRunCount);\n *         } else {\n *             UBiDi *line;\n *\n *             // we need to render several lines\n *             line=ubidi_openSized(length, 0, pErrorCode);\n *             if(line!=NULL) {\n *                 int32_t start=0, limit;\n *                 int styleRunStart=0, styleRunLimit;\n *\n *                 for(;;) {\n *                     limit=length;\n *                     styleRunLimit=styleRunCount;\n *                     getLineBreak(text, start, &limit, para,\n *                                  styleRuns, styleRunStart, &styleRunLimit,\n *                                 &width);\n *                     ubidi_setLine(para, start, limit, line, pErrorCode);\n *                     if(U_SUCCESS(*pErrorCode)) {\n *                         // prepare rendering a new line\n *                         // from either left or right\n *                         startLine(paraLevel, width);\n *\n *                         renderLine(line, text, start, limit,\n *                                    styleRuns+styleRunStart,\n *                                    styleRunLimit-styleRunStart);\n *                     }\n *                     if(limit==length) { break; }\n *                     start=limit;\n *                     styleRunStart=styleRunLimit-1;\n *                     if(start>=styleRuns[styleRunStart].limit) {\n *                         ++styleRunStart;\n *                     }\n *                 }\n *\n *                 ubidi_close(line);\n *             }\n *        }\n *    }\n *\n *     ubidi_close(para);\n *}\n *\\endcode\n * </pre>\n */\n\n/*DOCXX_TAG*/\n/*@{*/\n\n/**\n * UBiDiLevel is the type of the level values in this\n * Bidi implementation.\n * It holds an embedding level and indicates the visual direction\n * by its bit&nbsp;0 (even/odd value).<p>\n *\n * It can also hold non-level values for the\n * <code>paraLevel</code> and <code>embeddingLevels</code>\n * arguments of <code>ubidi_setPara()</code>; there:\n * <ul>\n * <li>bit&nbsp;7 of an <code>embeddingLevels[]</code>\n * value indicates whether the using application is\n * specifying the level of a character to <i>override</i> whatever the\n * Bidi implementation would resolve it to.</li>\n * <li><code>paraLevel</code> can be set to the\n * pseudo-level values <code>UBIDI_DEFAULT_LTR</code>\n * and <code>UBIDI_DEFAULT_RTL</code>.</li>\n * </ul>\n *\n * @see ubidi_setPara\n *\n * <p>The related constants are not real, valid level values.\n * <code>UBIDI_DEFAULT_XXX</code> can be used to specify\n * a default for the paragraph level for\n * when the <code>ubidi_setPara()</code> function\n * shall determine it but there is no\n * strongly typed character in the input.<p>\n *\n * Note that the value for <code>UBIDI_DEFAULT_LTR</code> is even\n * and the one for <code>UBIDI_DEFAULT_RTL</code> is odd,\n * just like with normal LTR and RTL level values -\n * these special values are designed that way. Also, the implementation\n * assumes that UBIDI_MAX_EXPLICIT_LEVEL is odd.\n *\n * @see UBIDI_DEFAULT_LTR\n * @see UBIDI_DEFAULT_RTL\n * @see UBIDI_LEVEL_OVERRIDE\n * @see UBIDI_MAX_EXPLICIT_LEVEL\n * @stable ICU 2.0\n */\ntypedef uint8_t UBiDiLevel;\n\n/** Paragraph level setting.<p>\n *\n * Constant indicating that the base direction depends on the first strong\n * directional character in the text according to the Unicode Bidirectional\n * Algorithm. If no strong directional character is present,\n * then set the paragraph level to 0 (left-to-right).<p>\n *\n * If this value is used in conjunction with reordering modes\n * <code>UBIDI_REORDER_INVERSE_LIKE_DIRECT</code> or\n * <code>UBIDI_REORDER_INVERSE_FOR_NUMBERS_SPECIAL</code>, the text to reorder\n * is assumed to be visual LTR, and the text after reordering is required\n * to be the corresponding logical string with appropriate contextual\n * direction. The direction of the result string will be RTL if either\n * the righmost or leftmost strong character of the source text is RTL\n * or Arabic Letter, the direction will be LTR otherwise.<p>\n *\n * If reordering option <code>UBIDI_OPTION_INSERT_MARKS</code> is set, an RLM may\n * be added at the beginning of the result string to ensure round trip\n * (that the result string, when reordered back to visual, will produce\n * the original source text).\n * @see UBIDI_REORDER_INVERSE_LIKE_DIRECT\n * @see UBIDI_REORDER_INVERSE_FOR_NUMBERS_SPECIAL\n * @stable ICU 2.0\n */\n#define UBIDI_DEFAULT_LTR 0xfe\n\n/** Paragraph level setting.<p>\n *\n * Constant indicating that the base direction depends on the first strong\n * directional character in the text according to the Unicode Bidirectional\n * Algorithm. If no strong directional character is present,\n * then set the paragraph level to 1 (right-to-left).<p>\n *\n * If this value is used in conjunction with reordering modes\n * <code>UBIDI_REORDER_INVERSE_LIKE_DIRECT</code> or\n * <code>UBIDI_REORDER_INVERSE_FOR_NUMBERS_SPECIAL</code>, the text to reorder\n * is assumed to be visual LTR, and the text after reordering is required\n * to be the corresponding logical string with appropriate contextual\n * direction. The direction of the result string will be RTL if either\n * the righmost or leftmost strong character of the source text is RTL\n * or Arabic Letter, or if the text contains no strong character;\n * the direction will be LTR otherwise.<p>\n *\n * If reordering option <code>UBIDI_OPTION_INSERT_MARKS</code> is set, an RLM may\n * be added at the beginning of the result string to ensure round trip\n * (that the result string, when reordered back to visual, will produce\n * the original source text).\n * @see UBIDI_REORDER_INVERSE_LIKE_DIRECT\n * @see UBIDI_REORDER_INVERSE_FOR_NUMBERS_SPECIAL\n * @stable ICU 2.0\n */\n#define UBIDI_DEFAULT_RTL 0xff\n\n/**\n * Maximum explicit embedding level.\n * (The maximum resolved level can be up to <code>UBIDI_MAX_EXPLICIT_LEVEL+1</code>).\n * @stable ICU 2.0\n */\n#define UBIDI_MAX_EXPLICIT_LEVEL 61\n\n/** Bit flag for level input.\n *  Overrides directional properties.\n * @stable ICU 2.0\n */\n#define UBIDI_LEVEL_OVERRIDE 0x80\n\n/**\n * Special value which can be returned by the mapping functions when a logical\n * index has no corresponding visual index or vice-versa. This may happen\n * for the logical-to-visual mapping of a Bidi control when option\n * <code>#UBIDI_OPTION_REMOVE_CONTROLS</code> is specified. This can also happen\n * for the visual-to-logical mapping of a Bidi mark (LRM or RLM) inserted\n * by option <code>#UBIDI_OPTION_INSERT_MARKS</code>.\n * @see ubidi_getVisualIndex\n * @see ubidi_getVisualMap\n * @see ubidi_getLogicalIndex\n * @see ubidi_getLogicalMap\n * @stable ICU 3.6\n */\n#define UBIDI_MAP_NOWHERE   (-1)\n\n/**\n * <code>UBiDiDirection</code> values indicate the text direction.\n * @stable ICU 2.0\n */\nenum UBiDiDirection {\n  /** Left-to-right text. This is a 0 value.\n   * <ul>\n   * <li>As return value for <code>ubidi_getDirection()</code>, it means\n   *     that the source string contains no right-to-left characters, or\n   *     that the source string is empty and the paragraph level is even.\n   * <li> As return value for <code>ubidi_getBaseDirection()</code>, it\n   *      means that the first strong character of the source string has\n   *      a left-to-right direction.\n   * </ul>\n   * @stable ICU 2.0\n   */\n  UBIDI_LTR,\n  /** Right-to-left text. This is a 1 value.\n   * <ul>\n   * <li>As return value for <code>ubidi_getDirection()</code>, it means\n   *     that the source string contains no left-to-right characters, or\n   *     that the source string is empty and the paragraph level is odd.\n   * <li> As return value for <code>ubidi_getBaseDirection()</code>, it\n   *      means that the first strong character of the source string has\n   *      a right-to-left direction.\n   * </ul>\n   * @stable ICU 2.0\n   */\n  UBIDI_RTL,\n  /** Mixed-directional text.\n   * <p>As return value for <code>ubidi_getDirection()</code>, it means\n   *    that the source string contains both left-to-right and\n   *    right-to-left characters.\n   * @stable ICU 2.0\n   */\n  UBIDI_MIXED,\n  /** No strongly directional text.\n   * <p>As return value for <code>ubidi_getBaseDirection()</code>, it means\n   *    that the source string is missing or empty, or contains neither left-to-right\n   *    nor right-to-left characters.\n   * @stable ICU 4.6\n   */\n  UBIDI_NEUTRAL\n};\n\n/** @stable ICU 2.0 */\ntypedef enum UBiDiDirection UBiDiDirection;\n\n/**\n * Forward declaration of the <code>UBiDi</code> structure for the declaration of\n * the API functions. Its fields are implementation-specific.<p>\n * This structure holds information about a paragraph (or multiple paragraphs)\n * of text with Bidi-algorithm-related details, or about one line of\n * such a paragraph.<p>\n * Reordering can be done on a line, or on one or more paragraphs which are\n * then interpreted each as one single line.\n * @stable ICU 2.0\n */\nstruct UBiDi;\n\n/** @stable ICU 2.0 */\ntypedef struct UBiDi UBiDi;\n\n/**\n * Allocate a <code>UBiDi</code> structure.\n * Such an object is initially empty. It is assigned\n * the Bidi properties of a piece of text containing one or more paragraphs\n * by <code>ubidi_setPara()</code>\n * or the Bidi properties of a line within a paragraph by\n * <code>ubidi_setLine()</code>.<p>\n * This object can be reused for as long as it is not deallocated\n * by calling <code>ubidi_close()</code>.<p>\n * <code>ubidi_setPara()</code> and <code>ubidi_setLine()</code> will allocate\n * additional memory for internal structures as necessary.\n *\n * @return An empty <code>UBiDi</code> object.\n * @stable ICU 2.0\n */\nU_STABLE UBiDi * U_EXPORT2\nubidi_open(void);\n\n/**\n * Allocate a <code>UBiDi</code> structure with preallocated memory\n * for internal structures.\n * This function provides a <code>UBiDi</code> object like <code>ubidi_open()</code>\n * with no arguments, but it also preallocates memory for internal structures\n * according to the sizings supplied by the caller.<p>\n * Subsequent functions will not allocate any more memory, and are thus\n * guaranteed not to fail because of lack of memory.<p>\n * The preallocation can be limited to some of the internal memory\n * by setting some values to 0 here. That means that if, e.g.,\n * <code>maxRunCount</code> cannot be reasonably predetermined and should not\n * be set to <code>maxLength</code> (the only failproof value) to avoid\n * wasting memory, then <code>maxRunCount</code> could be set to 0 here\n * and the internal structures that are associated with it will be allocated\n * on demand, just like with <code>ubidi_open()</code>.\n *\n * @param maxLength is the maximum text or line length that internal memory\n *        will be preallocated for. An attempt to associate this object with a\n *        longer text will fail, unless this value is 0, which leaves the allocation\n *        up to the implementation.\n *\n * @param maxRunCount is the maximum anticipated number of same-level runs\n *        that internal memory will be preallocated for. An attempt to access\n *        visual runs on an object that was not preallocated for as many runs\n *        as the text was actually resolved to will fail,\n *        unless this value is 0, which leaves the allocation up to the implementation.<br><br>\n *        The number of runs depends on the actual text and maybe anywhere between\n *        1 and <code>maxLength</code>. It is typically small.\n *\n * @param pErrorCode must be a valid pointer to an error code value.\n *\n * @return An empty <code>UBiDi</code> object with preallocated memory.\n * @stable ICU 2.0\n */\nU_STABLE UBiDi * U_EXPORT2\nubidi_openSized(int32_t maxLength, int32_t maxRunCount, UErrorCode *pErrorCode);\n\n/**\n * <code>ubidi_close()</code> must be called to free the memory\n * associated with a UBiDi object.<p>\n *\n * <strong>Important: </strong>\n * A parent <code>UBiDi</code> object must not be destroyed or reused if\n * it still has children.\n * If a <code>UBiDi</code> object has become the <i>child</i>\n * of another one (its <i>parent</i>) by calling\n * <code>ubidi_setLine()</code>, then the child object must\n * be destroyed (closed) or reused (by calling\n * <code>ubidi_setPara()</code> or <code>ubidi_setLine()</code>)\n * before the parent object.\n *\n * @param pBiDi is a <code>UBiDi</code> object.\n *\n * @see ubidi_setPara\n * @see ubidi_setLine\n * @stable ICU 2.0\n */\nU_STABLE void U_EXPORT2\nubidi_close(UBiDi *pBiDi);\n\n#if U_SHOW_CPLUSPLUS_API\n\nU_NAMESPACE_BEGIN\n\n/**\n * \\class LocalUBiDiPointer\n * \"Smart pointer\" class, closes a UBiDi via ubidi_close().\n * For most methods see the LocalPointerBase base class.\n *\n * @see LocalPointerBase\n * @see LocalPointer\n * @stable ICU 4.4\n */\nU_DEFINE_LOCAL_OPEN_POINTER(LocalUBiDiPointer, UBiDi, ubidi_close);\n\nU_NAMESPACE_END\n\n#endif\n\n/**\n * Modify the operation of the Bidi algorithm such that it\n * approximates an \"inverse Bidi\" algorithm. This function\n * must be called before <code>ubidi_setPara()</code>.\n *\n * <p>The normal operation of the Bidi algorithm as described\n * in the Unicode Technical Report is to take text stored in logical\n * (keyboard, typing) order and to determine the reordering of it for visual\n * rendering.\n * Some legacy systems store text in visual order, and for operations\n * with standard, Unicode-based algorithms, the text needs to be transformed\n * to logical order. This is effectively the inverse algorithm of the\n * described Bidi algorithm. Note that there is no standard algorithm for\n * this \"inverse Bidi\" and that the current implementation provides only an\n * approximation of \"inverse Bidi\".</p>\n *\n * <p>With <code>isInverse</code> set to <code>TRUE</code>,\n * this function changes the behavior of some of the subsequent functions\n * in a way that they can be used for the inverse Bidi algorithm.\n * Specifically, runs of text with numeric characters will be treated in a\n * special way and may need to be surrounded with LRM characters when they are\n * written in reordered sequence.</p>\n *\n * <p>Output runs should be retrieved using <code>ubidi_getVisualRun()</code>.\n * Since the actual input for \"inverse Bidi\" is visually ordered text and\n * <code>ubidi_getVisualRun()</code> gets the reordered runs, these are actually\n * the runs of the logically ordered output.</p>\n *\n * <p>Calling this function with argument <code>isInverse</code> set to\n * <code>TRUE</code> is equivalent to calling\n * <code>ubidi_setReorderingMode</code> with argument\n * <code>reorderingMode</code>\n * set to <code>#UBIDI_REORDER_INVERSE_NUMBERS_AS_L</code>.<br>\n * Calling this function with argument <code>isInverse</code> set to\n * <code>FALSE</code> is equivalent to calling\n * <code>ubidi_setReorderingMode</code> with argument\n * <code>reorderingMode</code>\n * set to <code>#UBIDI_REORDER_DEFAULT</code>.\n *\n * @param pBiDi is a <code>UBiDi</code> object.\n *\n * @param isInverse specifies \"forward\" or \"inverse\" Bidi operation.\n *\n * @see ubidi_setPara\n * @see ubidi_writeReordered\n * @see ubidi_setReorderingMode\n * @stable ICU 2.0\n */\nU_STABLE void U_EXPORT2\nubidi_setInverse(UBiDi *pBiDi, UBool isInverse);\n\n/**\n * Is this Bidi object set to perform the inverse Bidi algorithm?\n * <p>Note: calling this function after setting the reordering mode with\n * <code>ubidi_setReorderingMode</code> will return <code>TRUE</code> if the\n * reordering mode was set to <code>#UBIDI_REORDER_INVERSE_NUMBERS_AS_L</code>,\n * <code>FALSE</code> for all other values.</p>\n *\n * @param pBiDi is a <code>UBiDi</code> object.\n * @return TRUE if the Bidi object is set to perform the inverse Bidi algorithm\n * by handling numbers as L.\n *\n * @see ubidi_setInverse\n * @see ubidi_setReorderingMode\n * @stable ICU 2.0\n */\n\nU_STABLE UBool U_EXPORT2\nubidi_isInverse(UBiDi *pBiDi);\n\n/**\n * Specify whether block separators must be allocated level zero,\n * so that successive paragraphs will progress from left to right.\n * This function must be called before <code>ubidi_setPara()</code>.\n * Paragraph separators (B) may appear in the text.  Setting them to level zero\n * means that all paragraph separators (including one possibly appearing\n * in the last text position) are kept in the reordered text after the text\n * that they follow in the source text.\n * When this feature is not enabled, a paragraph separator at the last\n * position of the text before reordering will go to the first position\n * of the reordered text when the paragraph level is odd.\n *\n * @param pBiDi is a <code>UBiDi</code> object.\n *\n * @param orderParagraphsLTR specifies whether paragraph separators (B) must\n * receive level 0, so that successive paragraphs progress from left to right.\n *\n * @see ubidi_setPara\n * @stable ICU 3.4\n */\nU_STABLE void U_EXPORT2\nubidi_orderParagraphsLTR(UBiDi *pBiDi, UBool orderParagraphsLTR);\n\n/**\n * Is this Bidi object set to allocate level 0 to block separators so that\n * successive paragraphs progress from left to right?\n *\n * @param pBiDi is a <code>UBiDi</code> object.\n * @return TRUE if the Bidi object is set to allocate level 0 to block\n *         separators.\n *\n * @see ubidi_orderParagraphsLTR\n * @stable ICU 3.4\n */\nU_STABLE UBool U_EXPORT2\nubidi_isOrderParagraphsLTR(UBiDi *pBiDi);\n\n/**\n * <code>UBiDiReorderingMode</code> values indicate which variant of the Bidi\n * algorithm to use.\n *\n * @see ubidi_setReorderingMode\n * @stable ICU 3.6\n */\ntypedef enum UBiDiReorderingMode {\n    /** Regular Logical to Visual Bidi algorithm according to Unicode.\n      * This is a 0 value.\n      * @stable ICU 3.6 */\n    UBIDI_REORDER_DEFAULT = 0,\n    /** Logical to Visual algorithm which handles numbers in a way which\n      * mimicks the behavior of Windows XP.\n      * @stable ICU 3.6 */\n    UBIDI_REORDER_NUMBERS_SPECIAL,\n    /** Logical to Visual algorithm grouping numbers with adjacent R characters\n      * (reversible algorithm).\n      * @stable ICU 3.6 */\n    UBIDI_REORDER_GROUP_NUMBERS_WITH_R,\n    /** Reorder runs only to transform a Logical LTR string to the Logical RTL\n      * string with the same display, or vice-versa.<br>\n      * If this mode is set together with option\n      * <code>#UBIDI_OPTION_INSERT_MARKS</code>, some Bidi controls in the source\n      * text may be removed and other controls may be added to produce the\n      * minimum combination which has the required display.\n      * @stable ICU 3.6 */\n    UBIDI_REORDER_RUNS_ONLY,\n    /** Visual to Logical algorithm which handles numbers like L\n      * (same algorithm as selected by <code>ubidi_setInverse(TRUE)</code>.\n      * @see ubidi_setInverse\n      * @stable ICU 3.6 */\n    UBIDI_REORDER_INVERSE_NUMBERS_AS_L,\n    /** Visual to Logical algorithm equivalent to the regular Logical to Visual\n      * algorithm.\n      * @stable ICU 3.6 */\n    UBIDI_REORDER_INVERSE_LIKE_DIRECT,\n    /** Inverse Bidi (Visual to Logical) algorithm for the\n      * <code>UBIDI_REORDER_NUMBERS_SPECIAL</code> Bidi algorithm.\n      * @stable ICU 3.6 */\n    UBIDI_REORDER_INVERSE_FOR_NUMBERS_SPECIAL,\n    /** Number of values for reordering mode.\n      * @stable ICU 3.6 */\n    UBIDI_REORDER_COUNT\n} UBiDiReorderingMode;\n\n/**\n * Modify the operation of the Bidi algorithm such that it implements some\n * variant to the basic Bidi algorithm or approximates an \"inverse Bidi\"\n * algorithm, depending on different values of the \"reordering mode\".\n * This function must be called before <code>ubidi_setPara()</code>, and stays\n * in effect until called again with a different argument.\n *\n * <p>The normal operation of the Bidi algorithm as described\n * in the Unicode Standard Annex #9 is to take text stored in logical\n * (keyboard, typing) order and to determine how to reorder it for visual\n * rendering.</p>\n *\n * <p>With the reordering mode set to a value other than\n * <code>#UBIDI_REORDER_DEFAULT</code>, this function changes the behavior of\n * some of the subsequent functions in a way such that they implement an\n * inverse Bidi algorithm or some other algorithm variants.</p>\n *\n * <p>Some legacy systems store text in visual order, and for operations\n * with standard, Unicode-based algorithms, the text needs to be transformed\n * into logical order. This is effectively the inverse algorithm of the\n * described Bidi algorithm. Note that there is no standard algorithm for\n * this \"inverse Bidi\", so a number of variants are implemented here.</p>\n *\n * <p>In other cases, it may be desirable to emulate some variant of the\n * Logical to Visual algorithm (e.g. one used in MS Windows), or perform a\n * Logical to Logical transformation.</p>\n *\n * <ul>\n * <li>When the reordering mode is set to <code>#UBIDI_REORDER_DEFAULT</code>,\n * the standard Bidi Logical to Visual algorithm is applied.</li>\n *\n * <li>When the reordering mode is set to\n * <code>#UBIDI_REORDER_NUMBERS_SPECIAL</code>,\n * the algorithm used to perform Bidi transformations when calling\n * <code>ubidi_setPara</code> should approximate the algorithm used in\n * Microsoft Windows XP rather than strictly conform to the Unicode Bidi\n * algorithm.\n * <br>\n * The differences between the basic algorithm and the algorithm addressed\n * by this option are as follows:\n * <ul>\n *   <li>Within text at an even embedding level, the sequence \"123AB\"\n *   (where AB represent R or AL letters) is transformed to \"123BA\" by the\n *   Unicode algorithm and to \"BA123\" by the Windows algorithm.</li>\n *   <li>Arabic-Indic numbers (AN) are handled by the Windows algorithm just\n *   like regular numbers (EN).</li>\n * </ul></li>\n *\n * <li>When the reordering mode is set to\n * <code>#UBIDI_REORDER_GROUP_NUMBERS_WITH_R</code>,\n * numbers located between LTR text and RTL text are associated with the RTL\n * text. For instance, an LTR paragraph with content \"abc 123 DEF\" (where\n * upper case letters represent RTL characters) will be transformed to\n * \"abc FED 123\" (and not \"abc 123 FED\"), \"DEF 123 abc\" will be transformed\n * to \"123 FED abc\" and \"123 FED abc\" will be transformed to \"DEF 123 abc\".\n * This makes the algorithm reversible and makes it useful when round trip\n * (from visual to logical and back to visual) must be achieved without\n * adding LRM characters. However, this is a variation from the standard\n * Unicode Bidi algorithm.<br>\n * The source text should not contain Bidi control characters other than LRM\n * or RLM.</li>\n *\n * <li>When the reordering mode is set to\n * <code>#UBIDI_REORDER_RUNS_ONLY</code>,\n * a \"Logical to Logical\" transformation must be performed:\n * <ul>\n * <li>If the default text level of the source text (argument <code>paraLevel</code>\n * in <code>ubidi_setPara</code>) is even, the source text will be handled as\n * LTR logical text and will be transformed to the RTL logical text which has\n * the same LTR visual display.</li>\n * <li>If the default level of the source text is odd, the source text\n * will be handled as RTL logical text and will be transformed to the\n * LTR logical text which has the same LTR visual display.</li>\n * </ul>\n * This mode may be needed when logical text which is basically Arabic or\n * Hebrew, with possible included numbers or phrases in English, has to be\n * displayed as if it had an even embedding level (this can happen if the\n * displaying application treats all text as if it was basically LTR).\n * <br>\n * This mode may also be needed in the reverse case, when logical text which is\n * basically English, with possible included phrases in Arabic or Hebrew, has to\n * be displayed as if it had an odd embedding level.\n * <br>\n * Both cases could be handled by adding LRE or RLE at the head of the text,\n * if the display subsystem supports these formatting controls. If it does not,\n * the problem may be handled by transforming the source text in this mode\n * before displaying it, so that it will be displayed properly.<br>\n * The source text should not contain Bidi control characters other than LRM\n * or RLM.</li>\n *\n * <li>When the reordering mode is set to\n * <code>#UBIDI_REORDER_INVERSE_NUMBERS_AS_L</code>, an \"inverse Bidi\" algorithm\n * is applied.\n * Runs of text with numeric characters will be treated like LTR letters and\n * may need to be surrounded with LRM characters when they are written in\n * reordered sequence (the option <code>#UBIDI_INSERT_LRM_FOR_NUMERIC</code> can\n * be used with function <code>ubidi_writeReordered</code> to this end. This\n * mode is equivalent to calling <code>ubidi_setInverse()</code> with\n * argument <code>isInverse</code> set to <code>TRUE</code>.</li>\n *\n * <li>When the reordering mode is set to\n * <code>#UBIDI_REORDER_INVERSE_LIKE_DIRECT</code>, the \"direct\" Logical to Visual\n * Bidi algorithm is used as an approximation of an \"inverse Bidi\" algorithm.\n * This mode is similar to mode <code>#UBIDI_REORDER_INVERSE_NUMBERS_AS_L</code>\n * but is closer to the regular Bidi algorithm.\n * <br>\n * For example, an LTR paragraph with the content \"FED 123 456 CBA\" (where\n * upper case represents RTL characters) will be transformed to\n * \"ABC 456 123 DEF\", as opposed to \"DEF 123 456 ABC\"\n * with mode <code>UBIDI_REORDER_INVERSE_NUMBERS_AS_L</code>.<br>\n * When used in conjunction with option\n * <code>#UBIDI_OPTION_INSERT_MARKS</code>, this mode generally\n * adds Bidi marks to the output significantly more sparingly than mode\n * <code>#UBIDI_REORDER_INVERSE_NUMBERS_AS_L</code> with option\n * <code>#UBIDI_INSERT_LRM_FOR_NUMERIC</code> in calls to\n * <code>ubidi_writeReordered</code>.</li>\n *\n * <li>When the reordering mode is set to\n * <code>#UBIDI_REORDER_INVERSE_FOR_NUMBERS_SPECIAL</code>, the Logical to Visual\n * Bidi algorithm used in Windows XP is used as an approximation of an \"inverse Bidi\" algorithm.\n * <br>\n * For example, an LTR paragraph with the content \"abc FED123\" (where\n * upper case represents RTL characters) will be transformed to \"abc 123DEF.\"</li>\n * </ul>\n *\n * <p>In all the reordering modes specifying an \"inverse Bidi\" algorithm\n * (i.e. those with a name starting with <code>UBIDI_REORDER_INVERSE</code>),\n * output runs should be retrieved using\n * <code>ubidi_getVisualRun()</code>, and the output text with\n * <code>ubidi_writeReordered()</code>. The caller should keep in mind that in\n * \"inverse Bidi\" modes the input is actually visually ordered text and\n * reordered output returned by <code>ubidi_getVisualRun()</code> or\n * <code>ubidi_writeReordered()</code> are actually runs or character string\n * of logically ordered output.<br>\n * For all the \"inverse Bidi\" modes, the source text should not contain\n * Bidi control characters other than LRM or RLM.</p>\n *\n * <p>Note that option <code>#UBIDI_OUTPUT_REVERSE</code> of\n * <code>ubidi_writeReordered</code> has no useful meaning and should not be\n * used in conjunction with any value of the reordering mode specifying\n * \"inverse Bidi\" or with value <code>UBIDI_REORDER_RUNS_ONLY</code>.\n *\n * @param pBiDi is a <code>UBiDi</code> object.\n * @param reorderingMode specifies the required variant of the Bidi algorithm.\n *\n * @see UBiDiReorderingMode\n * @see ubidi_setInverse\n * @see ubidi_setPara\n * @see ubidi_writeReordered\n * @stable ICU 3.6\n */\nU_STABLE void U_EXPORT2\nubidi_setReorderingMode(UBiDi *pBiDi, UBiDiReorderingMode reorderingMode);\n\n/**\n * What is the requested reordering mode for a given Bidi object?\n *\n * @param pBiDi is a <code>UBiDi</code> object.\n * @return the current reordering mode of the Bidi object\n * @see ubidi_setReorderingMode\n * @stable ICU 3.6\n */\nU_STABLE UBiDiReorderingMode U_EXPORT2\nubidi_getReorderingMode(UBiDi *pBiDi);\n\n/**\n * <code>UBiDiReorderingOption</code> values indicate which options are\n * specified to affect the Bidi algorithm.\n *\n * @see ubidi_setReorderingOptions\n * @stable ICU 3.6\n */\ntypedef enum UBiDiReorderingOption {\n    /**\n     * option value for <code>ubidi_setReorderingOptions</code>:\n     * disable all the options which can be set with this function\n     * @see ubidi_setReorderingOptions\n     * @stable ICU 3.6\n     */\n    UBIDI_OPTION_DEFAULT = 0,\n\n    /**\n     * option bit for <code>ubidi_setReorderingOptions</code>:\n     * insert Bidi marks (LRM or RLM) when needed to ensure correct result of\n     * a reordering to a Logical order\n     *\n     * <p>This option must be set or reset before calling\n     * <code>ubidi_setPara</code>.</p>\n     *\n     * <p>This option is significant only with reordering modes which generate\n     * a result with Logical order, specifically:</p>\n     * <ul>\n     *   <li><code>#UBIDI_REORDER_RUNS_ONLY</code></li>\n     *   <li><code>#UBIDI_REORDER_INVERSE_NUMBERS_AS_L</code></li>\n     *   <li><code>#UBIDI_REORDER_INVERSE_LIKE_DIRECT</code></li>\n     *   <li><code>#UBIDI_REORDER_INVERSE_FOR_NUMBERS_SPECIAL</code></li>\n     * </ul>\n     *\n     * <p>If this option is set in conjunction with reordering mode\n     * <code>#UBIDI_REORDER_INVERSE_NUMBERS_AS_L</code> or with calling\n     * <code>ubidi_setInverse(TRUE)</code>, it implies\n     * option <code>#UBIDI_INSERT_LRM_FOR_NUMERIC</code>\n     * in calls to function <code>ubidi_writeReordered()</code>.</p>\n     *\n     * <p>For other reordering modes, a minimum number of LRM or RLM characters\n     * will be added to the source text after reordering it so as to ensure\n     * round trip, i.e. when applying the inverse reordering mode on the\n     * resulting logical text with removal of Bidi marks\n     * (option <code>#UBIDI_OPTION_REMOVE_CONTROLS</code> set before calling\n     * <code>ubidi_setPara()</code> or option <code>#UBIDI_REMOVE_BIDI_CONTROLS</code>\n     * in <code>ubidi_writeReordered</code>), the result will be identical to the\n     * source text in the first transformation.\n     *\n     * <p>This option will be ignored if specified together with option\n     * <code>#UBIDI_OPTION_REMOVE_CONTROLS</code>. It inhibits option\n     * <code>UBIDI_REMOVE_BIDI_CONTROLS</code> in calls to function\n     * <code>ubidi_writeReordered()</code> and it implies option\n     * <code>#UBIDI_INSERT_LRM_FOR_NUMERIC</code> in calls to function\n     * <code>ubidi_writeReordered()</code> if the reordering mode is\n     * <code>#UBIDI_REORDER_INVERSE_NUMBERS_AS_L</code>.</p>\n     *\n     * @see ubidi_setReorderingMode\n     * @see ubidi_setReorderingOptions\n     * @stable ICU 3.6\n     */\n    UBIDI_OPTION_INSERT_MARKS = 1,\n\n    /**\n     * option bit for <code>ubidi_setReorderingOptions</code>:\n     * remove Bidi control characters\n     *\n     * <p>This option must be set or reset before calling\n     * <code>ubidi_setPara</code>.</p>\n     *\n     * <p>This option nullifies option <code>#UBIDI_OPTION_INSERT_MARKS</code>.\n     * It inhibits option <code>#UBIDI_INSERT_LRM_FOR_NUMERIC</code> in calls\n     * to function <code>ubidi_writeReordered()</code> and it implies option\n     * <code>#UBIDI_REMOVE_BIDI_CONTROLS</code> in calls to that function.</p>\n     *\n     * @see ubidi_setReorderingMode\n     * @see ubidi_setReorderingOptions\n     * @stable ICU 3.6\n     */\n    UBIDI_OPTION_REMOVE_CONTROLS = 2,\n\n    /**\n     * option bit for <code>ubidi_setReorderingOptions</code>:\n     * process the output as part of a stream to be continued\n     *\n     * <p>This option must be set or reset before calling\n     * <code>ubidi_setPara</code>.</p>\n     *\n     * <p>This option specifies that the caller is interested in processing large\n     * text object in parts.\n     * The results of the successive calls are expected to be concatenated by the\n     * caller. Only the call for the last part will have this option bit off.</p>\n     *\n     * <p>When this option bit is on, <code>ubidi_setPara()</code> may process\n     * less than the full source text in order to truncate the text at a meaningful\n     * boundary. The caller should call <code>ubidi_getProcessedLength()</code>\n     * immediately after calling <code>ubidi_setPara()</code> in order to\n     * determine how much of the source text has been processed.\n     * Source text beyond that length should be resubmitted in following calls to\n     * <code>ubidi_setPara</code>. The processed length may be less than\n     * the length of the source text if a character preceding the last character of\n     * the source text constitutes a reasonable boundary (like a block separator)\n     * for text to be continued.<br>\n     * If the last character of the source text constitutes a reasonable\n     * boundary, the whole text will be processed at once.<br>\n     * If nowhere in the source text there exists\n     * such a reasonable boundary, the processed length will be zero.<br>\n     * The caller should check for such an occurrence and do one of the following:\n     * <ul><li>submit a larger amount of text with a better chance to include\n     *         a reasonable boundary.</li>\n     *     <li>resubmit the same text after turning off option\n     *         <code>UBIDI_OPTION_STREAMING</code>.</li></ul>\n     * In all cases, this option should be turned off before processing the last\n     * part of the text.</p>\n     *\n     * <p>When the <code>UBIDI_OPTION_STREAMING</code> option is used,\n     * it is recommended to call <code>ubidi_orderParagraphsLTR()</code> with\n     * argument <code>orderParagraphsLTR</code> set to <code>TRUE</code> before\n     * calling <code>ubidi_setPara</code> so that later paragraphs may be\n     * concatenated to previous paragraphs on the right.</p>\n     *\n     * @see ubidi_setReorderingMode\n     * @see ubidi_setReorderingOptions\n     * @see ubidi_getProcessedLength\n     * @see ubidi_orderParagraphsLTR\n     * @stable ICU 3.6\n     */\n    UBIDI_OPTION_STREAMING = 4\n} UBiDiReorderingOption;\n\n/**\n * Specify which of the reordering options\n * should be applied during Bidi transformations.\n *\n * @param pBiDi is a <code>UBiDi</code> object.\n * @param reorderingOptions is a combination of zero or more of the following\n * options:\n * <code>#UBIDI_OPTION_DEFAULT</code>, <code>#UBIDI_OPTION_INSERT_MARKS</code>,\n * <code>#UBIDI_OPTION_REMOVE_CONTROLS</code>, <code>#UBIDI_OPTION_STREAMING</code>.\n *\n * @see ubidi_getReorderingOptions\n * @stable ICU 3.6\n */\nU_STABLE void U_EXPORT2\nubidi_setReorderingOptions(UBiDi *pBiDi, uint32_t reorderingOptions);\n\n/**\n * What are the reordering options applied to a given Bidi object?\n *\n * @param pBiDi is a <code>UBiDi</code> object.\n * @return the current reordering options of the Bidi object\n * @see ubidi_setReorderingOptions\n * @stable ICU 3.6\n */\nU_STABLE uint32_t U_EXPORT2\nubidi_getReorderingOptions(UBiDi *pBiDi);\n\n/**\n * Set the context before a call to ubidi_setPara().<p>\n *\n * ubidi_setPara() computes the left-right directionality for a given piece\n * of text which is supplied as one of its arguments. Sometimes this piece\n * of text (the \"main text\") should be considered in context, because text\n * appearing before (\"prologue\") and/or after (\"epilogue\") the main text\n * may affect the result of this computation.<p>\n *\n * This function specifies the prologue and/or the epilogue for the next\n * call to ubidi_setPara(). The characters specified as prologue and\n * epilogue should not be modified by the calling program until the call\n * to ubidi_setPara() has returned. If successive calls to ubidi_setPara()\n * all need specification of a context, ubidi_setContext() must be called\n * before each call to ubidi_setPara(). In other words, a context is not\n * \"remembered\" after the following successful call to ubidi_setPara().<p>\n *\n * If a call to ubidi_setPara() specifies UBIDI_DEFAULT_LTR or\n * UBIDI_DEFAULT_RTL as paraLevel and is preceded by a call to\n * ubidi_setContext() which specifies a prologue, the paragraph level will\n * be computed taking in consideration the text in the prologue.<p>\n *\n * When ubidi_setPara() is called without a previous call to\n * ubidi_setContext, the main text is handled as if preceded and followed\n * by strong directional characters at the current paragraph level.\n * Calling ubidi_setContext() with specification of a prologue will change\n * this behavior by handling the main text as if preceded by the last\n * strong character appearing in the prologue, if any.\n * Calling ubidi_setContext() with specification of an epilogue will change\n * the behavior of ubidi_setPara() by handling the main text as if followed\n * by the first strong character or digit appearing in the epilogue, if any.<p>\n *\n * Note 1: if <code>ubidi_setContext</code> is called repeatedly without\n *         calling <code>ubidi_setPara</code>, the earlier calls have no effect,\n *         only the last call will be remembered for the next call to\n *         <code>ubidi_setPara</code>.<p>\n *\n * Note 2: calling <code>ubidi_setContext(pBiDi, NULL, 0, NULL, 0, &errorCode)</code>\n *         cancels any previous setting of non-empty prologue or epilogue.\n *         The next call to <code>ubidi_setPara()</code> will process no\n *         prologue or epilogue.<p>\n *\n * Note 3: users must be aware that even after setting the context\n *         before a call to ubidi_setPara() to perform e.g. a logical to visual\n *         transformation, the resulting string may not be identical to what it\n *         would have been if all the text, including prologue and epilogue, had\n *         been processed together.<br>\n * Example (upper case letters represent RTL characters):<br>\n * &nbsp;&nbsp;prologue = \"<code>abc DE</code>\"<br>\n * &nbsp;&nbsp;epilogue = none<br>\n * &nbsp;&nbsp;main text = \"<code>FGH xyz</code>\"<br>\n * &nbsp;&nbsp;paraLevel = UBIDI_LTR<br>\n * &nbsp;&nbsp;display without prologue = \"<code>HGF xyz</code>\"\n *             (\"HGF\" is adjacent to \"xyz\")<br>\n * &nbsp;&nbsp;display with prologue = \"<code>abc HGFED xyz</code>\"\n *             (\"HGF\" is not adjacent to \"xyz\")<br>\n *\n * @param pBiDi is a paragraph <code>UBiDi</code> object.\n *\n * @param prologue is a pointer to the text which precedes the text that\n *        will be specified in a coming call to ubidi_setPara().\n *        If there is no prologue to consider, then <code>proLength</code>\n *        must be zero and this pointer can be NULL.\n *\n * @param proLength is the length of the prologue; if <code>proLength==-1</code>\n *        then the prologue must be zero-terminated.\n *        Otherwise proLength must be >= 0. If <code>proLength==0</code>, it means\n *        that there is no prologue to consider.\n *\n * @param epilogue is a pointer to the text which follows the text that\n *        will be specified in a coming call to ubidi_setPara().\n *        If there is no epilogue to consider, then <code>epiLength</code>\n *        must be zero and this pointer can be NULL.\n *\n * @param epiLength is the length of the epilogue; if <code>epiLength==-1</code>\n *        then the epilogue must be zero-terminated.\n *        Otherwise epiLength must be >= 0. If <code>epiLength==0</code>, it means\n *        that there is no epilogue to consider.\n *\n * @param pErrorCode must be a valid pointer to an error code value.\n *\n * @see ubidi_setPara\n * @stable ICU 4.8\n */\nU_STABLE void U_EXPORT2\nubidi_setContext(UBiDi *pBiDi,\n                 const UChar *prologue, int32_t proLength,\n                 const UChar *epilogue, int32_t epiLength,\n                 UErrorCode *pErrorCode);\n\n/**\n * Perform the Unicode Bidi algorithm. It is defined in the\n * <a href=\"http://www.unicode.org/unicode/reports/tr9/\">Unicode Standard Anned #9</a>,\n * version 13,\n * also described in The Unicode Standard, Version 4.0 .<p>\n *\n * This function takes a piece of plain text containing one or more paragraphs,\n * with or without externally specified embedding levels from <i>styled</i>\n * text and computes the left-right-directionality of each character.<p>\n *\n * If the entire text is all of the same directionality, then\n * the function may not perform all the steps described by the algorithm,\n * i.e., some levels may not be the same as if all steps were performed.\n * This is not relevant for unidirectional text.<br>\n * For example, in pure LTR text with numbers the numbers would get\n * a resolved level of 2 higher than the surrounding text according to\n * the algorithm. This implementation may set all resolved levels to\n * the same value in such a case.<p>\n *\n * The text can be composed of multiple paragraphs. Occurrence of a block\n * separator in the text terminates a paragraph, and whatever comes next starts\n * a new paragraph. The exception to this rule is when a Carriage Return (CR)\n * is followed by a Line Feed (LF). Both CR and LF are block separators, but\n * in that case, the pair of characters is considered as terminating the\n * preceding paragraph, and a new paragraph will be started by a character\n * coming after the LF.\n *\n * @param pBiDi A <code>UBiDi</code> object allocated with <code>ubidi_open()</code>\n *        which will be set to contain the reordering information,\n *        especially the resolved levels for all the characters in <code>text</code>.\n *\n * @param text is a pointer to the text that the Bidi algorithm will be performed on.\n *        This pointer is stored in the UBiDi object and can be retrieved\n *        with <code>ubidi_getText()</code>.<br>\n *        <strong>Note:</strong> the text must be (at least) <code>length</code> long.\n *\n * @param length is the length of the text; if <code>length==-1</code> then\n *        the text must be zero-terminated.\n *\n * @param paraLevel specifies the default level for the text;\n *        it is typically 0 (LTR) or 1 (RTL).\n *        If the function shall determine the paragraph level from the text,\n *        then <code>paraLevel</code> can be set to\n *        either <code>#UBIDI_DEFAULT_LTR</code>\n *        or <code>#UBIDI_DEFAULT_RTL</code>; if the text contains multiple\n *        paragraphs, the paragraph level shall be determined separately for\n *        each paragraph; if a paragraph does not include any strongly typed\n *        character, then the desired default is used (0 for LTR or 1 for RTL).\n *        Any other value between 0 and <code>#UBIDI_MAX_EXPLICIT_LEVEL</code>\n *        is also valid, with odd levels indicating RTL.\n *\n * @param embeddingLevels (in) may be used to preset the embedding and override levels,\n *        ignoring characters like LRE and PDF in the text.\n *        A level overrides the directional property of its corresponding\n *        (same index) character if the level has the\n *        <code>#UBIDI_LEVEL_OVERRIDE</code> bit set.<br><br>\n *        Except for that bit, it must be\n *        <code>paraLevel<=embeddingLevels[]<=UBIDI_MAX_EXPLICIT_LEVEL</code>,\n *        with one exception: a level of zero may be specified for a paragraph\n *        separator even if <code>paraLevel>0</code> when multiple paragraphs\n *        are submitted in the same call to <code>ubidi_setPara()</code>.<br><br>\n *        <strong>Caution: </strong>A copy of this pointer, not of the levels,\n *        will be stored in the <code>UBiDi</code> object;\n *        the <code>embeddingLevels</code> array must not be\n *        deallocated before the <code>UBiDi</code> structure is destroyed or reused,\n *        and the <code>embeddingLevels</code>\n *        should not be modified to avoid unexpected results on subsequent Bidi operations.\n *        However, the <code>ubidi_setPara()</code> and\n *        <code>ubidi_setLine()</code> functions may modify some or all of the levels.<br><br>\n *        After the <code>UBiDi</code> object is reused or destroyed, the caller\n *        must take care of the deallocation of the <code>embeddingLevels</code> array.<br><br>\n *        <strong>Note:</strong> the <code>embeddingLevels</code> array must be\n *        at least <code>length</code> long.\n *        This pointer can be <code>NULL</code> if this\n *        value is not necessary.\n *\n * @param pErrorCode must be a valid pointer to an error code value.\n * @stable ICU 2.0\n */\nU_STABLE void U_EXPORT2\nubidi_setPara(UBiDi *pBiDi, const UChar *text, int32_t length,\n              UBiDiLevel paraLevel, UBiDiLevel *embeddingLevels,\n              UErrorCode *pErrorCode);\n\n/**\n * <code>ubidi_setLine()</code> sets a <code>UBiDi</code> to\n * contain the reordering information, especially the resolved levels,\n * for all the characters in a line of text. This line of text is\n * specified by referring to a <code>UBiDi</code> object representing\n * this information for a piece of text containing one or more paragraphs,\n * and by specifying a range of indexes in this text.<p>\n * In the new line object, the indexes will range from 0 to <code>limit-start-1</code>.<p>\n *\n * This is used after calling <code>ubidi_setPara()</code>\n * for a piece of text, and after line-breaking on that text.\n * It is not necessary if each paragraph is treated as a single line.<p>\n *\n * After line-breaking, rules (L1) and (L2) for the treatment of\n * trailing WS and for reordering are performed on\n * a <code>UBiDi</code> object that represents a line.<p>\n *\n * <strong>Important: </strong><code>pLineBiDi</code> shares data with\n * <code>pParaBiDi</code>.\n * You must destroy or reuse <code>pLineBiDi</code> before <code>pParaBiDi</code>.\n * In other words, you must destroy or reuse the <code>UBiDi</code> object for a line\n * before the object for its parent paragraph.<p>\n *\n * The text pointer that was stored in <code>pParaBiDi</code> is also copied,\n * and <code>start</code> is added to it so that it points to the beginning of the\n * line for this object.\n *\n * @param pParaBiDi is the parent paragraph object. It must have been set\n * by a successful call to ubidi_setPara.\n *\n * @param start is the line's first index into the text.\n *\n * @param limit is just behind the line's last index into the text\n *        (its last index +1).<br>\n *        It must be <code>0<=start<limit<=</code>containing paragraph limit.\n *        If the specified line crosses a paragraph boundary, the function\n *        will terminate with error code U_ILLEGAL_ARGUMENT_ERROR.\n *\n * @param pLineBiDi is the object that will now represent a line of the text.\n *\n * @param pErrorCode must be a valid pointer to an error code value.\n *\n * @see ubidi_setPara\n * @see ubidi_getProcessedLength\n * @stable ICU 2.0\n */\nU_STABLE void U_EXPORT2\nubidi_setLine(const UBiDi *pParaBiDi,\n              int32_t start, int32_t limit,\n              UBiDi *pLineBiDi,\n              UErrorCode *pErrorCode);\n\n/**\n * Get the directionality of the text.\n *\n * @param pBiDi is the paragraph or line <code>UBiDi</code> object.\n *\n * @return a value of <code>UBIDI_LTR</code>, <code>UBIDI_RTL</code>\n *         or <code>UBIDI_MIXED</code>\n *         that indicates if the entire text\n *         represented by this object is unidirectional,\n *         and which direction, or if it is mixed-directional.\n * Note -  The value <code>UBIDI_NEUTRAL</code> is never returned from this method.\n *\n * @see UBiDiDirection\n * @stable ICU 2.0\n */\nU_STABLE UBiDiDirection U_EXPORT2\nubidi_getDirection(const UBiDi *pBiDi);\n\n/**\n * Gets the base direction of the text provided according\n * to the Unicode Bidirectional Algorithm. The base direction\n * is derived from the first character in the string with bidirectional\n * character type L, R, or AL. If the first such character has type L,\n * <code>UBIDI_LTR</code> is returned. If the first such character has\n * type R or AL, <code>UBIDI_RTL</code> is returned. If the string does\n * not contain any character of these types, then\n * <code>UBIDI_NEUTRAL</code> is returned.\n *\n * This is a lightweight function for use when only the base direction\n * is needed and no further bidi processing of the text is needed.\n *\n * @param text is a pointer to the text whose base\n *             direction is needed.\n * Note: the text must be (at least) @c length long.\n *\n * @param length is the length of the text;\n *               if <code>length==-1</code> then the text\n *               must be zero-terminated.\n *\n * @return  <code>UBIDI_LTR</code>, <code>UBIDI_RTL</code>,\n *          <code>UBIDI_NEUTRAL</code>\n *\n * @see UBiDiDirection\n * @stable ICU 4.6\n */\nU_STABLE UBiDiDirection U_EXPORT2\nubidi_getBaseDirection(const UChar *text,  int32_t length );\n\n/**\n * Get the pointer to the text.\n *\n * @param pBiDi is the paragraph or line <code>UBiDi</code> object.\n *\n * @return The pointer to the text that the UBiDi object was created for.\n *\n * @see ubidi_setPara\n * @see ubidi_setLine\n * @stable ICU 2.0\n */\nU_STABLE const UChar * U_EXPORT2\nubidi_getText(const UBiDi *pBiDi);\n\n/**\n * Get the length of the text.\n *\n * @param pBiDi is the paragraph or line <code>UBiDi</code> object.\n *\n * @return The length of the text that the UBiDi object was created for.\n * @stable ICU 2.0\n */\nU_STABLE int32_t U_EXPORT2\nubidi_getLength(const UBiDi *pBiDi);\n\n/**\n * Get the paragraph level of the text.\n *\n * @param pBiDi is the paragraph or line <code>UBiDi</code> object.\n *\n * @return The paragraph level. If there are multiple paragraphs, their\n *         level may vary if the required paraLevel is UBIDI_DEFAULT_LTR or\n *         UBIDI_DEFAULT_RTL.  In that case, the level of the first paragraph\n *         is returned.\n *\n * @see UBiDiLevel\n * @see ubidi_getParagraph\n * @see ubidi_getParagraphByIndex\n * @stable ICU 2.0\n */\nU_STABLE UBiDiLevel U_EXPORT2\nubidi_getParaLevel(const UBiDi *pBiDi);\n\n/**\n * Get the number of paragraphs.\n *\n * @param pBiDi is the paragraph or line <code>UBiDi</code> object.\n *\n * @return The number of paragraphs.\n * @stable ICU 3.4\n */\nU_STABLE int32_t U_EXPORT2\nubidi_countParagraphs(UBiDi *pBiDi);\n\n/**\n * Get a paragraph, given a position within the text.\n * This function returns information about a paragraph.<br>\n * Note: if the paragraph index is known, it is more efficient to\n * retrieve the paragraph information using ubidi_getParagraphByIndex().<p>\n *\n * @param pBiDi is the paragraph or line <code>UBiDi</code> object.\n *\n * @param charIndex is the index of a character within the text, in the\n *        range <code>[0..ubidi_getProcessedLength(pBiDi)-1]</code>.\n *\n * @param pParaStart will receive the index of the first character of the\n *        paragraph in the text.\n *        This pointer can be <code>NULL</code> if this\n *        value is not necessary.\n *\n * @param pParaLimit will receive the limit of the paragraph.\n *        The l-value that you point to here may be the\n *        same expression (variable) as the one for\n *        <code>charIndex</code>.\n *        This pointer can be <code>NULL</code> if this\n *        value is not necessary.\n *\n * @param pParaLevel will receive the level of the paragraph.\n *        This pointer can be <code>NULL</code> if this\n *        value is not necessary.\n *\n * @param pErrorCode must be a valid pointer to an error code value.\n *\n * @return The index of the paragraph containing the specified position.\n *\n * @see ubidi_getProcessedLength\n * @stable ICU 3.4\n */\nU_STABLE int32_t U_EXPORT2\nubidi_getParagraph(const UBiDi *pBiDi, int32_t charIndex, int32_t *pParaStart,\n                   int32_t *pParaLimit, UBiDiLevel *pParaLevel,\n                   UErrorCode *pErrorCode);\n\n/**\n * Get a paragraph, given the index of this paragraph.\n *\n * This function returns information about a paragraph.<p>\n *\n * @param pBiDi is the paragraph <code>UBiDi</code> object.\n *\n * @param paraIndex is the number of the paragraph, in the\n *        range <code>[0..ubidi_countParagraphs(pBiDi)-1]</code>.\n *\n * @param pParaStart will receive the index of the first character of the\n *        paragraph in the text.\n *        This pointer can be <code>NULL</code> if this\n *        value is not necessary.\n *\n * @param pParaLimit will receive the limit of the paragraph.\n *        This pointer can be <code>NULL</code> if this\n *        value is not necessary.\n *\n * @param pParaLevel will receive the level of the paragraph.\n *        This pointer can be <code>NULL</code> if this\n *        value is not necessary.\n *\n * @param pErrorCode must be a valid pointer to an error code value.\n *\n * @stable ICU 3.4\n */\nU_STABLE void U_EXPORT2\nubidi_getParagraphByIndex(const UBiDi *pBiDi, int32_t paraIndex,\n                          int32_t *pParaStart, int32_t *pParaLimit,\n                          UBiDiLevel *pParaLevel, UErrorCode *pErrorCode);\n\n/**\n * Get the level for one character.\n *\n * @param pBiDi is the paragraph or line <code>UBiDi</code> object.\n *\n * @param charIndex the index of a character. It must be in the range\n *         [0..ubidi_getProcessedLength(pBiDi)].\n *\n * @return The level for the character at charIndex (0 if charIndex is not\n *         in the valid range).\n *\n * @see UBiDiLevel\n * @see ubidi_getProcessedLength\n * @stable ICU 2.0\n */\nU_STABLE UBiDiLevel U_EXPORT2\nubidi_getLevelAt(const UBiDi *pBiDi, int32_t charIndex);\n\n/**\n * Get an array of levels for each character.<p>\n *\n * Note that this function may allocate memory under some\n * circumstances, unlike <code>ubidi_getLevelAt()</code>.\n *\n * @param pBiDi is the paragraph or line <code>UBiDi</code> object, whose\n *        text length must be strictly positive.\n *\n * @param pErrorCode must be a valid pointer to an error code value.\n *\n * @return The levels array for the text,\n *         or <code>NULL</code> if an error occurs.\n *\n * @see UBiDiLevel\n * @see ubidi_getProcessedLength\n * @stable ICU 2.0\n */\nU_STABLE const UBiDiLevel * U_EXPORT2\nubidi_getLevels(UBiDi *pBiDi, UErrorCode *pErrorCode);\n\n/**\n * Get a logical run.\n * This function returns information about a run and is used\n * to retrieve runs in logical order.<p>\n * This is especially useful for line-breaking on a paragraph.\n *\n * @param pBiDi is the paragraph or line <code>UBiDi</code> object.\n *\n * @param logicalPosition is a logical position within the source text.\n *\n * @param pLogicalLimit will receive the limit of the corresponding run.\n *        The l-value that you point to here may be the\n *        same expression (variable) as the one for\n *        <code>logicalPosition</code>.\n *        This pointer can be <code>NULL</code> if this\n *        value is not necessary.\n *\n * @param pLevel will receive the level of the corresponding run.\n *        This pointer can be <code>NULL</code> if this\n *        value is not necessary.\n *\n * @see ubidi_getProcessedLength\n * @stable ICU 2.0\n */\nU_STABLE void U_EXPORT2\nubidi_getLogicalRun(const UBiDi *pBiDi, int32_t logicalPosition,\n                    int32_t *pLogicalLimit, UBiDiLevel *pLevel);\n\n/**\n * Get the number of runs.\n * This function may invoke the actual reordering on the\n * <code>UBiDi</code> object, after <code>ubidi_setPara()</code>\n * may have resolved only the levels of the text. Therefore,\n * <code>ubidi_countRuns()</code> may have to allocate memory,\n * and may fail doing so.\n *\n * @param pBiDi is the paragraph or line <code>UBiDi</code> object.\n *\n * @param pErrorCode must be a valid pointer to an error code value.\n *\n * @return The number of runs.\n * @stable ICU 2.0\n */\nU_STABLE int32_t U_EXPORT2\nubidi_countRuns(UBiDi *pBiDi, UErrorCode *pErrorCode);\n\n/**\n * Get one run's logical start, length, and directionality,\n * which can be 0 for LTR or 1 for RTL.\n * In an RTL run, the character at the logical start is\n * visually on the right of the displayed run.\n * The length is the number of characters in the run.<p>\n * <code>ubidi_countRuns()</code> should be called\n * before the runs are retrieved.\n *\n * @param pBiDi is the paragraph or line <code>UBiDi</code> object.\n *\n * @param runIndex is the number of the run in visual order, in the\n *        range <code>[0..ubidi_countRuns(pBiDi)-1]</code>.\n *\n * @param pLogicalStart is the first logical character index in the text.\n *        The pointer may be <code>NULL</code> if this index is not needed.\n *\n * @param pLength is the number of characters (at least one) in the run.\n *        The pointer may be <code>NULL</code> if this is not needed.\n *\n * @return the directionality of the run,\n *         <code>UBIDI_LTR==0</code> or <code>UBIDI_RTL==1</code>,\n *         never <code>UBIDI_MIXED</code>,\n *         never <code>UBIDI_NEUTRAL</code>.\n *\n * @see ubidi_countRuns\n *\n * Example:\n * <pre>\n * \\code\n * int32_t i, count=ubidi_countRuns(pBiDi),\n *         logicalStart, visualIndex=0, length;\n * for(i=0; i<count; ++i) {\n *    if(UBIDI_LTR==ubidi_getVisualRun(pBiDi, i, &logicalStart, &length)) {\n *         do { // LTR\n *             show_char(text[logicalStart++], visualIndex++);\n *         } while(--length>0);\n *     } else {\n *         logicalStart+=length;  // logicalLimit\n *         do { // RTL\n *             show_char(text[--logicalStart], visualIndex++);\n *         } while(--length>0);\n *     }\n * }\n *\\endcode\n * </pre>\n *\n * Note that in right-to-left runs, code like this places\n * second surrogates before first ones (which is generally a bad idea)\n * and combining characters before base characters.\n * <p>\n * Use of <code>ubidi_writeReordered()</code>, optionally with the\n * <code>#UBIDI_KEEP_BASE_COMBINING</code> option, can be considered in order\n * to avoid these issues.\n * @stable ICU 2.0\n */\nU_STABLE UBiDiDirection U_EXPORT2\nubidi_getVisualRun(UBiDi *pBiDi, int32_t runIndex,\n                   int32_t *pLogicalStart, int32_t *pLength);\n\n/**\n * Get the visual position from a logical text position.\n * If such a mapping is used many times on the same\n * <code>UBiDi</code> object, then calling\n * <code>ubidi_getLogicalMap()</code> is more efficient.<p>\n *\n * The value returned may be <code>#UBIDI_MAP_NOWHERE</code> if there is no\n * visual position because the corresponding text character is a Bidi control\n * removed from output by the option <code>#UBIDI_OPTION_REMOVE_CONTROLS</code>.\n * <p>\n * When the visual output is altered by using options of\n * <code>ubidi_writeReordered()</code> such as <code>UBIDI_INSERT_LRM_FOR_NUMERIC</code>,\n * <code>UBIDI_KEEP_BASE_COMBINING</code>, <code>UBIDI_OUTPUT_REVERSE</code>,\n * <code>UBIDI_REMOVE_BIDI_CONTROLS</code>, the visual position returned may not\n * be correct. It is advised to use, when possible, reordering options\n * such as <code>UBIDI_OPTION_INSERT_MARKS</code> and <code>UBIDI_OPTION_REMOVE_CONTROLS</code>.\n * <p>\n * Note that in right-to-left runs, this mapping places\n * second surrogates before first ones (which is generally a bad idea)\n * and combining characters before base characters.\n * Use of <code>ubidi_writeReordered()</code>, optionally with the\n * <code>#UBIDI_KEEP_BASE_COMBINING</code> option can be considered instead\n * of using the mapping, in order to avoid these issues.\n *\n * @param pBiDi is the paragraph or line <code>UBiDi</code> object.\n *\n * @param logicalIndex is the index of a character in the text.\n *\n * @param pErrorCode must be a valid pointer to an error code value.\n *\n * @return The visual position of this character.\n *\n * @see ubidi_getLogicalMap\n * @see ubidi_getLogicalIndex\n * @see ubidi_getProcessedLength\n * @stable ICU 2.0\n */\nU_STABLE int32_t U_EXPORT2\nubidi_getVisualIndex(UBiDi *pBiDi, int32_t logicalIndex, UErrorCode *pErrorCode);\n\n/**\n * Get the logical text position from a visual position.\n * If such a mapping is used many times on the same\n * <code>UBiDi</code> object, then calling\n * <code>ubidi_getVisualMap()</code> is more efficient.<p>\n *\n * The value returned may be <code>#UBIDI_MAP_NOWHERE</code> if there is no\n * logical position because the corresponding text character is a Bidi mark\n * inserted in the output by option <code>#UBIDI_OPTION_INSERT_MARKS</code>.\n * <p>\n * This is the inverse function to <code>ubidi_getVisualIndex()</code>.\n * <p>\n * When the visual output is altered by using options of\n * <code>ubidi_writeReordered()</code> such as <code>UBIDI_INSERT_LRM_FOR_NUMERIC</code>,\n * <code>UBIDI_KEEP_BASE_COMBINING</code>, <code>UBIDI_OUTPUT_REVERSE</code>,\n * <code>UBIDI_REMOVE_BIDI_CONTROLS</code>, the logical position returned may not\n * be correct. It is advised to use, when possible, reordering options\n * such as <code>UBIDI_OPTION_INSERT_MARKS</code> and <code>UBIDI_OPTION_REMOVE_CONTROLS</code>.\n *\n * @param pBiDi is the paragraph or line <code>UBiDi</code> object.\n *\n * @param visualIndex is the visual position of a character.\n *\n * @param pErrorCode must be a valid pointer to an error code value.\n *\n * @return The index of this character in the text.\n *\n * @see ubidi_getVisualMap\n * @see ubidi_getVisualIndex\n * @see ubidi_getResultLength\n * @stable ICU 2.0\n */\nU_STABLE int32_t U_EXPORT2\nubidi_getLogicalIndex(UBiDi *pBiDi, int32_t visualIndex, UErrorCode *pErrorCode);\n\n/**\n * Get a logical-to-visual index map (array) for the characters in the UBiDi\n * (paragraph or line) object.\n * <p>\n * Some values in the map may be <code>#UBIDI_MAP_NOWHERE</code> if the\n * corresponding text characters are Bidi controls removed from the visual\n * output by the option <code>#UBIDI_OPTION_REMOVE_CONTROLS</code>.\n * <p>\n * When the visual output is altered by using options of\n * <code>ubidi_writeReordered()</code> such as <code>UBIDI_INSERT_LRM_FOR_NUMERIC</code>,\n * <code>UBIDI_KEEP_BASE_COMBINING</code>, <code>UBIDI_OUTPUT_REVERSE</code>,\n * <code>UBIDI_REMOVE_BIDI_CONTROLS</code>, the visual positions returned may not\n * be correct. It is advised to use, when possible, reordering options\n * such as <code>UBIDI_OPTION_INSERT_MARKS</code> and <code>UBIDI_OPTION_REMOVE_CONTROLS</code>.\n * <p>\n * Note that in right-to-left runs, this mapping places\n * second surrogates before first ones (which is generally a bad idea)\n * and combining characters before base characters.\n * Use of <code>ubidi_writeReordered()</code>, optionally with the\n * <code>#UBIDI_KEEP_BASE_COMBINING</code> option can be considered instead\n * of using the mapping, in order to avoid these issues.\n *\n * @param pBiDi is the paragraph or line <code>UBiDi</code> object.\n *\n * @param indexMap is a pointer to an array of <code>ubidi_getProcessedLength()</code>\n *        indexes which will reflect the reordering of the characters.\n *        If option <code>#UBIDI_OPTION_INSERT_MARKS</code> is set, the number\n *        of elements allocated in <code>indexMap</code> must be no less than\n *        <code>ubidi_getResultLength()</code>.\n *        The array does not need to be initialized.<br><br>\n *        The index map will result in <code>indexMap[logicalIndex]==visualIndex</code>.\n *\n * @param pErrorCode must be a valid pointer to an error code value.\n *\n * @see ubidi_getVisualMap\n * @see ubidi_getVisualIndex\n * @see ubidi_getProcessedLength\n * @see ubidi_getResultLength\n * @stable ICU 2.0\n */\nU_STABLE void U_EXPORT2\nubidi_getLogicalMap(UBiDi *pBiDi, int32_t *indexMap, UErrorCode *pErrorCode);\n\n/**\n * Get a visual-to-logical index map (array) for the characters in the UBiDi\n * (paragraph or line) object.\n * <p>\n * Some values in the map may be <code>#UBIDI_MAP_NOWHERE</code> if the\n * corresponding text characters are Bidi marks inserted in the visual output\n * by the option <code>#UBIDI_OPTION_INSERT_MARKS</code>.\n * <p>\n * When the visual output is altered by using options of\n * <code>ubidi_writeReordered()</code> such as <code>UBIDI_INSERT_LRM_FOR_NUMERIC</code>,\n * <code>UBIDI_KEEP_BASE_COMBINING</code>, <code>UBIDI_OUTPUT_REVERSE</code>,\n * <code>UBIDI_REMOVE_BIDI_CONTROLS</code>, the logical positions returned may not\n * be correct. It is advised to use, when possible, reordering options\n * such as <code>UBIDI_OPTION_INSERT_MARKS</code> and <code>UBIDI_OPTION_REMOVE_CONTROLS</code>.\n *\n * @param pBiDi is the paragraph or line <code>UBiDi</code> object.\n *\n * @param indexMap is a pointer to an array of <code>ubidi_getResultLength()</code>\n *        indexes which will reflect the reordering of the characters.\n *        If option <code>#UBIDI_OPTION_REMOVE_CONTROLS</code> is set, the number\n *        of elements allocated in <code>indexMap</code> must be no less than\n *        <code>ubidi_getProcessedLength()</code>.\n *        The array does not need to be initialized.<br><br>\n *        The index map will result in <code>indexMap[visualIndex]==logicalIndex</code>.\n *\n * @param pErrorCode must be a valid pointer to an error code value.\n *\n * @see ubidi_getLogicalMap\n * @see ubidi_getLogicalIndex\n * @see ubidi_getProcessedLength\n * @see ubidi_getResultLength\n * @stable ICU 2.0\n */\nU_STABLE void U_EXPORT2\nubidi_getVisualMap(UBiDi *pBiDi, int32_t *indexMap, UErrorCode *pErrorCode);\n\n/**\n * This is a convenience function that does not use a UBiDi object.\n * It is intended to be used for when an application has determined the levels\n * of objects (character sequences) and just needs to have them reordered (L2).\n * This is equivalent to using <code>ubidi_getLogicalMap()</code> on a\n * <code>UBiDi</code> object.\n *\n * @param levels is an array with <code>length</code> levels that have been determined by\n *        the application.\n *\n * @param length is the number of levels in the array, or, semantically,\n *        the number of objects to be reordered.\n *        It must be <code>length>0</code>.\n *\n * @param indexMap is a pointer to an array of <code>length</code>\n *        indexes which will reflect the reordering of the characters.\n *        The array does not need to be initialized.<p>\n *        The index map will result in <code>indexMap[logicalIndex]==visualIndex</code>.\n * @stable ICU 2.0\n */\nU_STABLE void U_EXPORT2\nubidi_reorderLogical(const UBiDiLevel *levels, int32_t length, int32_t *indexMap);\n\n/**\n * This is a convenience function that does not use a UBiDi object.\n * It is intended to be used for when an application has determined the levels\n * of objects (character sequences) and just needs to have them reordered (L2).\n * This is equivalent to using <code>ubidi_getVisualMap()</code> on a\n * <code>UBiDi</code> object.\n *\n * @param levels is an array with <code>length</code> levels that have been determined by\n *        the application.\n *\n * @param length is the number of levels in the array, or, semantically,\n *        the number of objects to be reordered.\n *        It must be <code>length>0</code>.\n *\n * @param indexMap is a pointer to an array of <code>length</code>\n *        indexes which will reflect the reordering of the characters.\n *        The array does not need to be initialized.<p>\n *        The index map will result in <code>indexMap[visualIndex]==logicalIndex</code>.\n * @stable ICU 2.0\n */\nU_STABLE void U_EXPORT2\nubidi_reorderVisual(const UBiDiLevel *levels, int32_t length, int32_t *indexMap);\n\n/**\n * Invert an index map.\n * The index mapping of the first map is inverted and written to\n * the second one.\n *\n * @param srcMap is an array with <code>length</code> elements\n *        which defines the original mapping from a source array containing\n *        <code>length</code> elements to a destination array.\n *        Some elements of the source array may have no mapping in the\n *        destination array. In that case, their value will be\n *        the special value <code>UBIDI_MAP_NOWHERE</code>.\n *        All elements must be >=0 or equal to <code>UBIDI_MAP_NOWHERE</code>.\n *        Some elements may have a value >= <code>length</code>, if the\n *        destination array has more elements than the source array.\n *        There must be no duplicate indexes (two or more elements with the\n *        same value except <code>UBIDI_MAP_NOWHERE</code>).\n *\n * @param destMap is an array with a number of elements equal to 1 + the highest\n *        value in <code>srcMap</code>.\n *        <code>destMap</code> will be filled with the inverse mapping.\n *        If element with index i in <code>srcMap</code> has a value k different\n *        from <code>UBIDI_MAP_NOWHERE</code>, this means that element i of\n *        the source array maps to element k in the destination array.\n *        The inverse map will have value i in its k-th element.\n *        For all elements of the destination array which do not map to\n *        an element in the source array, the corresponding element in the\n *        inverse map will have a value equal to <code>UBIDI_MAP_NOWHERE</code>.\n *\n * @param length is the length of each array.\n * @see UBIDI_MAP_NOWHERE\n * @stable ICU 2.0\n */\nU_STABLE void U_EXPORT2\nubidi_invertMap(const int32_t *srcMap, int32_t *destMap, int32_t length);\n\n/** option flags for ubidi_writeReordered() */\n\n/**\n * option bit for ubidi_writeReordered():\n * keep combining characters after their base characters in RTL runs\n *\n * @see ubidi_writeReordered\n * @stable ICU 2.0\n */\n#define UBIDI_KEEP_BASE_COMBINING       1\n\n/**\n * option bit for ubidi_writeReordered():\n * replace characters with the \"mirrored\" property in RTL runs\n * by their mirror-image mappings\n *\n * @see ubidi_writeReordered\n * @stable ICU 2.0\n */\n#define UBIDI_DO_MIRRORING              2\n\n/**\n * option bit for ubidi_writeReordered():\n * surround the run with LRMs if necessary;\n * this is part of the approximate \"inverse Bidi\" algorithm\n *\n * <p>This option does not imply corresponding adjustment of the index\n * mappings.</p>\n *\n * @see ubidi_setInverse\n * @see ubidi_writeReordered\n * @stable ICU 2.0\n */\n#define UBIDI_INSERT_LRM_FOR_NUMERIC    4\n\n/**\n * option bit for ubidi_writeReordered():\n * remove Bidi control characters\n * (this does not affect #UBIDI_INSERT_LRM_FOR_NUMERIC)\n *\n * <p>This option does not imply corresponding adjustment of the index\n * mappings.</p>\n *\n * @see ubidi_writeReordered\n * @stable ICU 2.0\n */\n#define UBIDI_REMOVE_BIDI_CONTROLS      8\n\n/**\n * option bit for ubidi_writeReordered():\n * write the output in reverse order\n *\n * <p>This has the same effect as calling <code>ubidi_writeReordered()</code>\n * first without this option, and then calling\n * <code>ubidi_writeReverse()</code> without mirroring.\n * Doing this in the same step is faster and avoids a temporary buffer.\n * An example for using this option is output to a character terminal that\n * is designed for RTL scripts and stores text in reverse order.</p>\n *\n * @see ubidi_writeReordered\n * @stable ICU 2.0\n */\n#define UBIDI_OUTPUT_REVERSE            16\n\n/**\n * Get the length of the source text processed by the last call to\n * <code>ubidi_setPara()</code>. This length may be different from the length\n * of the source text if option <code>#UBIDI_OPTION_STREAMING</code>\n * has been set.\n * <br>\n * Note that whenever the length of the text affects the execution or the\n * result of a function, it is the processed length which must be considered,\n * except for <code>ubidi_setPara</code> (which receives unprocessed source\n * text) and <code>ubidi_getLength</code> (which returns the original length\n * of the source text).<br>\n * In particular, the processed length is the one to consider in the following\n * cases:\n * <ul>\n * <li>maximum value of the <code>limit</code> argument of\n * <code>ubidi_setLine</code></li>\n * <li>maximum value of the <code>charIndex</code> argument of\n * <code>ubidi_getParagraph</code></li>\n * <li>maximum value of the <code>charIndex</code> argument of\n * <code>ubidi_getLevelAt</code></li>\n * <li>number of elements in the array returned by <code>ubidi_getLevels</code></li>\n * <li>maximum value of the <code>logicalStart</code> argument of\n * <code>ubidi_getLogicalRun</code></li>\n * <li>maximum value of the <code>logicalIndex</code> argument of\n * <code>ubidi_getVisualIndex</code></li>\n * <li>number of elements filled in the <code>*indexMap</code> argument of\n * <code>ubidi_getLogicalMap</code></li>\n * <li>length of text processed by <code>ubidi_writeReordered</code></li>\n * </ul>\n *\n * @param pBiDi is the paragraph <code>UBiDi</code> object.\n *\n * @return The length of the part of the source text processed by\n *         the last call to <code>ubidi_setPara</code>.\n * @see ubidi_setPara\n * @see UBIDI_OPTION_STREAMING\n * @stable ICU 3.6\n */\nU_STABLE int32_t U_EXPORT2\nubidi_getProcessedLength(const UBiDi *pBiDi);\n\n/**\n * Get the length of the reordered text resulting from the last call to\n * <code>ubidi_setPara()</code>. This length may be different from the length\n * of the source text if option <code>#UBIDI_OPTION_INSERT_MARKS</code>\n * or option <code>#UBIDI_OPTION_REMOVE_CONTROLS</code> has been set.\n * <br>\n * This resulting length is the one to consider in the following cases:\n * <ul>\n * <li>maximum value of the <code>visualIndex</code> argument of\n * <code>ubidi_getLogicalIndex</code></li>\n * <li>number of elements of the <code>*indexMap</code> argument of\n * <code>ubidi_getVisualMap</code></li>\n * </ul>\n * Note that this length stays identical to the source text length if\n * Bidi marks are inserted or removed using option bits of\n * <code>ubidi_writeReordered</code>, or if option\n * <code>#UBIDI_REORDER_INVERSE_NUMBERS_AS_L</code> has been set.\n *\n * @param pBiDi is the paragraph <code>UBiDi</code> object.\n *\n * @return The length of the reordered text resulting from\n *         the last call to <code>ubidi_setPara</code>.\n * @see ubidi_setPara\n * @see UBIDI_OPTION_INSERT_MARKS\n * @see UBIDI_OPTION_REMOVE_CONTROLS\n * @stable ICU 3.6\n */\nU_STABLE int32_t U_EXPORT2\nubidi_getResultLength(const UBiDi *pBiDi);\n\nU_CDECL_BEGIN\n/**\n * value returned by <code>UBiDiClassCallback</code> callbacks when\n * there is no need to override the standard Bidi class for a given code point.\n * @see UBiDiClassCallback\n * @stable ICU 3.6\n */\n#define U_BIDI_CLASS_DEFAULT  U_CHAR_DIRECTION_COUNT\n\n/**\n * Callback type declaration for overriding default Bidi class values with\n * custom ones.\n * <p>Usually, the function pointer will be propagated to a <code>UBiDi</code>\n * object by calling the <code>ubidi_setClassCallback()</code> function;\n * then the callback will be invoked by the UBA implementation any time the\n * class of a character is to be determined.</p>\n *\n * @param context is a pointer to the callback private data.\n *\n * @param c       is the code point to get a Bidi class for.\n *\n * @return The directional property / Bidi class for the given code point\n *         <code>c</code> if the default class has been overridden, or\n *         <code>#U_BIDI_CLASS_DEFAULT</code> if the standard Bidi class value\n *         for <code>c</code> is to be used.\n * @see ubidi_setClassCallback\n * @see ubidi_getClassCallback\n * @stable ICU 3.6\n */\ntypedef UCharDirection U_CALLCONV\nUBiDiClassCallback(const void *context, UChar32 c);\n\nU_CDECL_END\n\n/**\n * Retrieve the Bidi class for a given code point.\n * <p>If a <code>#UBiDiClassCallback</code> callback is defined and returns a\n * value other than <code>#U_BIDI_CLASS_DEFAULT</code>, that value is used;\n * otherwise the default class determination mechanism is invoked.</p>\n *\n * @param pBiDi is the paragraph <code>UBiDi</code> object.\n *\n * @param c     is the code point whose Bidi class must be retrieved.\n *\n * @return The Bidi class for character <code>c</code> based\n *         on the given <code>pBiDi</code> instance.\n * @see UBiDiClassCallback\n * @stable ICU 3.6\n */\nU_STABLE UCharDirection U_EXPORT2\nubidi_getCustomizedClass(UBiDi *pBiDi, UChar32 c);\n\n/**\n * Set the callback function and callback data used by the UBA\n * implementation for Bidi class determination.\n * <p>This may be useful for assigning Bidi classes to PUA characters, or\n * for special application needs. For instance, an application may want to\n * handle all spaces like L or R characters (according to the base direction)\n * when creating the visual ordering of logical lines which are part of a report\n * organized in columns: there should not be interaction between adjacent\n * cells.<p>\n *\n * @param pBiDi is the paragraph <code>UBiDi</code> object.\n *\n * @param newFn is the new callback function pointer.\n *\n * @param newContext is the new callback context pointer. This can be NULL.\n *\n * @param oldFn fillin: Returns the old callback function pointer. This can be\n *                      NULL.\n *\n * @param oldContext fillin: Returns the old callback's context. This can be\n *                           NULL.\n *\n * @param pErrorCode must be a valid pointer to an error code value.\n *\n * @see ubidi_getClassCallback\n * @stable ICU 3.6\n */\nU_STABLE void U_EXPORT2\nubidi_setClassCallback(UBiDi *pBiDi, UBiDiClassCallback *newFn,\n                       const void *newContext, UBiDiClassCallback **oldFn,\n                       const void **oldContext, UErrorCode *pErrorCode);\n\n/**\n * Get the current callback function used for Bidi class determination.\n *\n * @param pBiDi is the paragraph <code>UBiDi</code> object.\n *\n * @param fn fillin: Returns the callback function pointer.\n *\n * @param context fillin: Returns the callback's private context.\n *\n * @see ubidi_setClassCallback\n * @stable ICU 3.6\n */\nU_STABLE void U_EXPORT2\nubidi_getClassCallback(UBiDi *pBiDi, UBiDiClassCallback **fn, const void **context);\n\n/**\n * Take a <code>UBiDi</code> object containing the reordering\n * information for a piece of text (one or more paragraphs) set by\n * <code>ubidi_setPara()</code> or for a line of text set by\n * <code>ubidi_setLine()</code> and write a reordered string to the\n * destination buffer.\n *\n * This function preserves the integrity of characters with multiple\n * code units and (optionally) combining characters.\n * Characters in RTL runs can be replaced by mirror-image characters\n * in the destination buffer. Note that \"real\" mirroring has\n * to be done in a rendering engine by glyph selection\n * and that for many \"mirrored\" characters there are no\n * Unicode characters as mirror-image equivalents.\n * There are also options to insert or remove Bidi control\n * characters; see the description of the <code>destSize</code>\n * and <code>options</code> parameters and of the option bit flags.\n *\n * @param pBiDi A pointer to a <code>UBiDi</code> object that\n *              is set by <code>ubidi_setPara()</code> or\n *              <code>ubidi_setLine()</code> and contains the reordering\n *              information for the text that it was defined for,\n *              as well as a pointer to that text.<br><br>\n *              The text was aliased (only the pointer was stored\n *              without copying the contents) and must not have been modified\n *              since the <code>ubidi_setPara()</code> call.\n *\n * @param dest A pointer to where the reordered text is to be copied.\n *             The source text and <code>dest[destSize]</code>\n *             must not overlap.\n *\n * @param destSize The size of the <code>dest</code> buffer,\n *                 in number of UChars.\n *                 If the <code>UBIDI_INSERT_LRM_FOR_NUMERIC</code>\n *                 option is set, then the destination length could be\n *                 as large as\n *                 <code>ubidi_getLength(pBiDi)+2*ubidi_countRuns(pBiDi)</code>.\n *                 If the <code>UBIDI_REMOVE_BIDI_CONTROLS</code> option\n *                 is set, then the destination length may be less than\n *                 <code>ubidi_getLength(pBiDi)</code>.\n *                 If none of these options is set, then the destination length\n *                 will be exactly <code>ubidi_getProcessedLength(pBiDi)</code>.\n *\n * @param options A bit set of options for the reordering that control\n *                how the reordered text is written.\n *                The options include mirroring the characters on a code\n *                point basis and inserting LRM characters, which is used\n *                especially for transforming visually stored text\n *                to logically stored text (although this is still an\n *                imperfect implementation of an \"inverse Bidi\" algorithm\n *                because it uses the \"forward Bidi\" algorithm at its core).\n *                The available options are:\n *                <code>#UBIDI_DO_MIRRORING</code>,\n *                <code>#UBIDI_INSERT_LRM_FOR_NUMERIC</code>,\n *                <code>#UBIDI_KEEP_BASE_COMBINING</code>,\n *                <code>#UBIDI_OUTPUT_REVERSE</code>,\n *                <code>#UBIDI_REMOVE_BIDI_CONTROLS</code>\n *\n * @param pErrorCode must be a valid pointer to an error code value.\n *\n * @return The length of the output string.\n *\n * @see ubidi_getProcessedLength\n * @stable ICU 2.0\n */\nU_STABLE int32_t U_EXPORT2\nubidi_writeReordered(UBiDi *pBiDi,\n                     UChar *dest, int32_t destSize,\n                     uint16_t options,\n                     UErrorCode *pErrorCode);\n\n/**\n * Reverse a Right-To-Left run of Unicode text.\n *\n * This function preserves the integrity of characters with multiple\n * code units and (optionally) combining characters.\n * Characters can be replaced by mirror-image characters\n * in the destination buffer. Note that \"real\" mirroring has\n * to be done in a rendering engine by glyph selection\n * and that for many \"mirrored\" characters there are no\n * Unicode characters as mirror-image equivalents.\n * There are also options to insert or remove Bidi control\n * characters.\n *\n * This function is the implementation for reversing RTL runs as part\n * of <code>ubidi_writeReordered()</code>. For detailed descriptions\n * of the parameters, see there.\n * Since no Bidi controls are inserted here, the output string length\n * will never exceed <code>srcLength</code>.\n *\n * @see ubidi_writeReordered\n *\n * @param src A pointer to the RTL run text.\n *\n * @param srcLength The length of the RTL run.\n *\n * @param dest A pointer to where the reordered text is to be copied.\n *             <code>src[srcLength]</code> and <code>dest[destSize]</code>\n *             must not overlap.\n *\n * @param destSize The size of the <code>dest</code> buffer,\n *                 in number of UChars.\n *                 If the <code>UBIDI_REMOVE_BIDI_CONTROLS</code> option\n *                 is set, then the destination length may be less than\n *                 <code>srcLength</code>.\n *                 If this option is not set, then the destination length\n *                 will be exactly <code>srcLength</code>.\n *\n * @param options A bit set of options for the reordering that control\n *                how the reordered text is written.\n *                See the <code>options</code> parameter in <code>ubidi_writeReordered()</code>.\n *\n * @param pErrorCode must be a valid pointer to an error code value.\n *\n * @return The length of the output string.\n * @stable ICU 2.0\n */\nU_STABLE int32_t U_EXPORT2\nubidi_writeReverse(const UChar *src, int32_t srcLength,\n                   UChar *dest, int32_t destSize,\n                   uint16_t options,\n                   UErrorCode *pErrorCode);\n\n/*#define BIDI_SAMPLE_CODE*/\n/*@}*/\n\n#endif\n"
  },
  {
    "path": "deprecated/android/addons/icucompat/unicode/ubrk.h",
    "content": "/*\n******************************************************************************\n* Copyright (C) 1996-2012, International Business Machines Corporation and others.\n* All Rights Reserved.\n******************************************************************************\n*/\n\n#ifndef UBRK_H\n#define UBRK_H\n\n#include \"unicode/utypes.h\"\n#include \"unicode/uloc.h\"\n#include \"unicode/utext.h\"\n#include \"unicode/localpointer.h\"\n\n/**\n * A text-break iterator.\n *  For usage in C programs.\n */\n#ifndef UBRK_TYPEDEF_UBREAK_ITERATOR\n#   define UBRK_TYPEDEF_UBREAK_ITERATOR\n    /**\n     *  Opaque type representing an ICU Break iterator object.\n     *  @stable ICU 2.0\n     */\n    typedef struct UBreakIterator UBreakIterator;\n#endif\n\n#if !UCONFIG_NO_BREAK_ITERATION\n\n#include \"unicode/parseerr.h\"\n\n/**\n * \\file\n * \\brief C API: BreakIterator\n *\n * <h2> BreakIterator C API </h2>\n *\n * The BreakIterator C API defines  methods for finding the location\n * of boundaries in text. Pointer to a UBreakIterator maintain a\n * current position and scan over text returning the index of characters\n * where boundaries occur.\n * <p>\n * Line boundary analysis determines where a text string can be broken\n * when line-wrapping. The mechanism correctly handles punctuation and\n * hyphenated words.\n * <p>\n * Sentence boundary analysis allows selection with correct\n * interpretation of periods within numbers and abbreviations, and\n * trailing punctuation marks such as quotation marks and parentheses.\n * <p>\n * Word boundary analysis is used by search and replace functions, as\n * well as within text editing applications that allow the user to\n * select words with a double click. Word selection provides correct\n * interpretation of punctuation marks within and following\n * words. Characters that are not part of a word, such as symbols or\n * punctuation marks, have word-breaks on both sides.\n * <p>\n * Character boundary analysis identifies the boundaries of\n * \"Extended Grapheme Clusters\", which are groupings of codepoints\n * that should be treated as character-like units for many text operations.\n * Please see Unicode Standard Annex #29, Unicode Text Segmentation,\n * http://www.unicode.org/reports/tr29/ for additional information \n * on grapheme clusters and guidelines on their use.\n * <p>\n * Title boundary analysis locates all positions,\n * typically starts of words, that should be set to Title Case\n * when title casing the text.\n * <p>\n * The text boundary positions are found according to the rules\n * described in Unicode Standard Annex #29, Text Boundaries, and\n * Unicode Standard Annex #14, Line Breaking Properties.  These\n * are available at http://www.unicode.org/reports/tr14/ and\n * http://www.unicode.org/reports/tr29/.\n * <p>\n * In addition to the plain C API defined in this header file, an\n * object oriented C++ API with equivalent functionality is defined in the\n * file brkiter.h.\n * <p>\n * Code snippets illustrating the use of the Break Iterator APIs\n * are available in the ICU User Guide,\n * http://icu-project.org/userguide/boundaryAnalysis.html\n * and in the sample program icu/source/samples/break/break.cpp\n */\n\n/** The possible types of text boundaries.  @stable ICU 2.0 */\ntypedef enum UBreakIteratorType {\n  /** Character breaks  @stable ICU 2.0 */\n  UBRK_CHARACTER = 0,\n  /** Word breaks @stable ICU 2.0 */\n  UBRK_WORD = 1,\n  /** Line breaks @stable ICU 2.0 */\n  UBRK_LINE = 2,\n  /** Sentence breaks @stable ICU 2.0 */\n  UBRK_SENTENCE = 3,\n\n#ifndef U_HIDE_DEPRECATED_API\n  /**\n   * Title Case breaks\n   * The iterator created using this type locates title boundaries as described for\n   * Unicode 3.2 only. For Unicode 4.0 and above title boundary iteration,\n   * please use Word Boundary iterator.\n   *\n   * @deprecated ICU 2.8 Use the word break iterator for titlecasing for Unicode 4 and later.\n   */\n  UBRK_TITLE = 4,\n#endif /* U_HIDE_DEPRECATED_API */\n  UBRK_COUNT = 5\n} UBreakIteratorType;\n\n/** Value indicating all text boundaries have been returned.\n *  @stable ICU 2.0\n */\n#define UBRK_DONE ((int32_t) -1)\n\n\n/**\n *  Enum constants for the word break tags returned by\n *  getRuleStatus().  A range of values is defined for each category of\n *  word, to allow for further subdivisions of a category in future releases.\n *  Applications should check for tag values falling within the range, rather\n *  than for single individual values.\n *  @stable ICU 2.2\n*/\ntypedef enum UWordBreak {\n    /** Tag value for \"words\" that do not fit into any of other categories.\n     *  Includes spaces and most punctuation. */\n    UBRK_WORD_NONE           = 0,\n    /** Upper bound for tags for uncategorized words. */\n    UBRK_WORD_NONE_LIMIT     = 100,\n    /** Tag value for words that appear to be numbers, lower limit.    */\n    UBRK_WORD_NUMBER         = 100,\n    /** Tag value for words that appear to be numbers, upper limit.    */\n    UBRK_WORD_NUMBER_LIMIT   = 200,\n    /** Tag value for words that contain letters, excluding\n     *  hiragana, katakana or ideographic characters, lower limit.    */\n    UBRK_WORD_LETTER         = 200,\n    /** Tag value for words containing letters, upper limit  */\n    UBRK_WORD_LETTER_LIMIT   = 300,\n    /** Tag value for words containing kana characters, lower limit */\n    UBRK_WORD_KANA           = 300,\n    /** Tag value for words containing kana characters, upper limit */\n    UBRK_WORD_KANA_LIMIT     = 400,\n    /** Tag value for words containing ideographic characters, lower limit */\n    UBRK_WORD_IDEO           = 400,\n    /** Tag value for words containing ideographic characters, upper limit */\n    UBRK_WORD_IDEO_LIMIT     = 500\n} UWordBreak;\n\n/**\n *  Enum constants for the line break tags returned by getRuleStatus().\n *  A range of values is defined for each category of\n *  word, to allow for further subdivisions of a category in future releases.\n *  Applications should check for tag values falling within the range, rather\n *  than for single individual values.\n *  @stable ICU 2.8\n*/\ntypedef enum ULineBreakTag {\n    /** Tag value for soft line breaks, positions at which a line break\n      *  is acceptable but not required                */\n    UBRK_LINE_SOFT            = 0,\n    /** Upper bound for soft line breaks.              */\n    UBRK_LINE_SOFT_LIMIT      = 100,\n    /** Tag value for a hard, or mandatory line break  */\n    UBRK_LINE_HARD            = 100,\n    /** Upper bound for hard line breaks.              */\n    UBRK_LINE_HARD_LIMIT      = 200\n} ULineBreakTag;\n\n\n\n/**\n *  Enum constants for the sentence break tags returned by getRuleStatus().\n *  A range of values is defined for each category of\n *  sentence, to allow for further subdivisions of a category in future releases.\n *  Applications should check for tag values falling within the range, rather\n *  than for single individual values.\n *  @stable ICU 2.8\n*/\ntypedef enum USentenceBreakTag {\n    /** Tag value for for sentences  ending with a sentence terminator\n      * ('.', '?', '!', etc.) character, possibly followed by a\n      * hard separator (CR, LF, PS, etc.)\n      */\n    UBRK_SENTENCE_TERM       = 0,\n    /** Upper bound for tags for sentences ended by sentence terminators.    */\n    UBRK_SENTENCE_TERM_LIMIT = 100,\n    /** Tag value for for sentences that do not contain an ending\n      * sentence terminator ('.', '?', '!', etc.) character, but\n      * are ended only by a hard separator (CR, LF, PS, etc.) or end of input.\n      */\n    UBRK_SENTENCE_SEP        = 100,\n    /** Upper bound for tags for sentences ended by a separator.              */\n    UBRK_SENTENCE_SEP_LIMIT  = 200\n    /** Tag value for a hard, or mandatory line break  */\n} USentenceBreakTag;\n\n\n/**\n * Open a new UBreakIterator for locating text boundaries for a specified locale.\n * A UBreakIterator may be used for detecting character, line, word,\n * and sentence breaks in text.\n * @param type The type of UBreakIterator to open: one of UBRK_CHARACTER, UBRK_WORD,\n * UBRK_LINE, UBRK_SENTENCE\n * @param locale The locale specifying the text-breaking conventions.\n * @param text The text to be iterated over.\n * @param textLength The number of characters in text, or -1 if null-terminated.\n * @param status A UErrorCode to receive any errors.\n * @return A UBreakIterator for the specified locale.\n * @see ubrk_openRules\n * @stable ICU 2.0\n */\nU_STABLE UBreakIterator* U_EXPORT2\nubrk_open(UBreakIteratorType type,\n      const char *locale,\n      const UChar *text,\n      int32_t textLength,\n      UErrorCode *status);\n\n/**\n * Open a new UBreakIterator for locating text boundaries using specified breaking rules.\n * The rule syntax is ... (TBD)\n * @param rules A set of rules specifying the text breaking conventions.\n * @param rulesLength The number of characters in rules, or -1 if null-terminated.\n * @param text The text to be iterated over.  May be null, in which case ubrk_setText() is\n *        used to specify the text to be iterated.\n * @param textLength The number of characters in text, or -1 if null-terminated.\n * @param parseErr   Receives position and context information for any syntax errors\n *                   detected while parsing the rules.\n * @param status A UErrorCode to receive any errors.\n * @return A UBreakIterator for the specified rules.\n * @see ubrk_open\n * @stable ICU 2.2\n */\nU_STABLE UBreakIterator* U_EXPORT2\nubrk_openRules(const UChar     *rules,\n               int32_t         rulesLength,\n               const UChar     *text,\n               int32_t          textLength,\n               UParseError     *parseErr,\n               UErrorCode      *status);\n\n/**\n * Thread safe cloning operation\n * @param bi iterator to be cloned\n * @param stackBuffer user allocated space for the new clone. If NULL new memory will be allocated.\n *  If buffer is not large enough, new memory will be allocated.\n *  Clients can use the U_BRK_SAFECLONE_BUFFERSIZE. This will probably be enough to avoid memory allocations.\n * @param pBufferSize pointer to size of allocated space.\n *  If *pBufferSize == 0, a sufficient size for use in cloning will\n *  be returned ('pre-flighting')\n *  If *pBufferSize is not enough for a stack-based safe clone,\n *  new memory will be allocated.\n * @param status to indicate whether the operation went on smoothly or there were errors\n *  An informational status value, U_SAFECLONE_ALLOCATED_ERROR, is used if any allocations were necessary.\n * @return pointer to the new clone\n * @stable ICU 2.0\n */\nU_STABLE UBreakIterator * U_EXPORT2\nubrk_safeClone(\n          const UBreakIterator *bi,\n          void *stackBuffer,\n          int32_t *pBufferSize,\n          UErrorCode *status);\n\n/**\n  * A recommended size (in bytes) for the memory buffer to be passed to ubrk_saveClone().\n  * @stable ICU 2.0\n  */\n#define U_BRK_SAFECLONE_BUFFERSIZE 528\n\n/**\n* Close a UBreakIterator.\n* Once closed, a UBreakIterator may no longer be used.\n* @param bi The break iterator to close.\n * @stable ICU 2.0\n*/\nU_STABLE void U_EXPORT2\nubrk_close(UBreakIterator *bi);\n\n#if U_SHOW_CPLUSPLUS_API\n\nU_NAMESPACE_BEGIN\n\n/**\n * \\class LocalUBreakIteratorPointer\n * \"Smart pointer\" class, closes a UBreakIterator via ubrk_close().\n * For most methods see the LocalPointerBase base class.\n *\n * @see LocalPointerBase\n * @see LocalPointer\n * @stable ICU 4.4\n */\nU_DEFINE_LOCAL_OPEN_POINTER(LocalUBreakIteratorPointer, UBreakIterator, ubrk_close);\n\nU_NAMESPACE_END\n\n#endif\n\n/**\n * Sets an existing iterator to point to a new piece of text\n * @param bi The iterator to use\n * @param text The text to be set\n * @param textLength The length of the text\n * @param status The error code\n * @stable ICU 2.0\n */\nU_STABLE void U_EXPORT2\nubrk_setText(UBreakIterator* bi,\n             const UChar*    text,\n             int32_t         textLength,\n             UErrorCode*     status);\n\n\n/**\n * Sets an existing iterator to point to a new piece of text\n * @param bi The iterator to use\n * @param text The text to be set.\n *             This function makes a shallow clone of the supplied UText.  This means\n *             that the caller is free to immediately close or otherwise reuse the\n *             UText that was passed as a parameter, but that the underlying text itself\n *             must not be altered while being referenced by the break iterator.\n * @param status The error code\n * @stable ICU 3.4\n */\nU_STABLE void U_EXPORT2\nubrk_setUText(UBreakIterator* bi,\n             UText*          text,\n             UErrorCode*     status);\n\n\n\n/**\n * Determine the most recently-returned text boundary.\n *\n * @param bi The break iterator to use.\n * @return The character index most recently returned by \\ref ubrk_next, \\ref ubrk_previous,\n * \\ref ubrk_first, or \\ref ubrk_last.\n * @stable ICU 2.0\n */\nU_STABLE int32_t U_EXPORT2\nubrk_current(const UBreakIterator *bi);\n\n/**\n * Advance the iterator to the boundary following the current boundary.\n *\n * @param bi The break iterator to use.\n * @return The character index of the next text boundary, or UBRK_DONE\n * if all text boundaries have been returned.\n * @see ubrk_previous\n * @stable ICU 2.0\n */\nU_STABLE int32_t U_EXPORT2\nubrk_next(UBreakIterator *bi);\n\n/**\n * Set the iterator position to the boundary preceding the current boundary.\n *\n * @param bi The break iterator to use.\n * @return The character index of the preceding text boundary, or UBRK_DONE\n * if all text boundaries have been returned.\n * @see ubrk_next\n * @stable ICU 2.0\n */\nU_STABLE int32_t U_EXPORT2\nubrk_previous(UBreakIterator *bi);\n\n/**\n * Set the iterator position to the index of the first character in the text being scanned.\n * This is not always the same as index 0 of the text.\n * @param bi The break iterator to use.\n * @return The character index of the first character in the text being scanned.\n * @see ubrk_last\n * @stable ICU 2.0\n */\nU_STABLE int32_t U_EXPORT2\nubrk_first(UBreakIterator *bi);\n\n/**\n * Set the iterator position to the index immediately <EM>beyond</EM> the last character in the text being scanned.\n * This is not the same as the last character.\n * @param bi The break iterator to use.\n * @return The character offset immediately <EM>beyond</EM> the last character in the\n * text being scanned.\n * @see ubrk_first\n * @stable ICU 2.0\n */\nU_STABLE int32_t U_EXPORT2\nubrk_last(UBreakIterator *bi);\n\n/**\n * Set the iterator position to the first boundary preceding the specified offset.\n * The new position is always smaller than offset, or UBRK_DONE.\n * @param bi The break iterator to use.\n * @param offset The offset to begin scanning.\n * @return The text boundary preceding offset, or UBRK_DONE.\n * @see ubrk_following\n * @stable ICU 2.0\n */\nU_STABLE int32_t U_EXPORT2\nubrk_preceding(UBreakIterator *bi,\n           int32_t offset);\n\n/**\n * Advance the iterator to the first boundary following the specified offset.\n * The value returned is always greater than offset, or UBRK_DONE.\n * @param bi The break iterator to use.\n * @param offset The offset to begin scanning.\n * @return The text boundary following offset, or UBRK_DONE.\n * @see ubrk_preceding\n * @stable ICU 2.0\n */\nU_STABLE int32_t U_EXPORT2\nubrk_following(UBreakIterator *bi,\n           int32_t offset);\n\n/**\n* Get a locale for which text breaking information is available.\n* A UBreakIterator in a locale returned by this function will perform the correct\n* text breaking for the locale.\n* @param index The index of the desired locale.\n* @return A locale for which number text breaking information is available, or 0 if none.\n* @see ubrk_countAvailable\n* @stable ICU 2.0\n*/\nU_STABLE const char* U_EXPORT2\nubrk_getAvailable(int32_t index);\n\n/**\n* Determine how many locales have text breaking information available.\n* This function is most useful as determining the loop ending condition for\n* calls to \\ref ubrk_getAvailable.\n* @return The number of locales for which text breaking information is available.\n* @see ubrk_getAvailable\n* @stable ICU 2.0\n*/\nU_STABLE int32_t U_EXPORT2\nubrk_countAvailable(void);\n\n\n/**\n* Returns true if the specfied position is a boundary position.  As a side\n* effect, leaves the iterator pointing to the first boundary position at\n* or after \"offset\".\n* @param bi The break iterator to use.\n* @param offset the offset to check.\n* @return True if \"offset\" is a boundary position.\n* @stable ICU 2.0\n*/\nU_STABLE  UBool U_EXPORT2\nubrk_isBoundary(UBreakIterator *bi, int32_t offset);\n\n/**\n * Return the status from the break rule that determined the most recently\n * returned break position.  The values appear in the rule source\n * within brackets, {123}, for example.  For rules that do not specify a\n * status, a default value of 0 is returned.\n * <p>\n * For word break iterators, the possible values are defined in enum UWordBreak.\n * @stable ICU 2.2\n */\nU_STABLE  int32_t U_EXPORT2\nubrk_getRuleStatus(UBreakIterator *bi);\n\n/**\n * Get the statuses from the break rules that determined the most recently\n * returned break position.  The values appear in the rule source\n * within brackets, {123}, for example.  The default status value for rules\n * that do not explicitly provide one is zero.\n * <p>\n * For word break iterators, the possible values are defined in enum UWordBreak.\n * @param bi        The break iterator to use\n * @param fillInVec an array to be filled in with the status values.\n * @param capacity  the length of the supplied vector.  A length of zero causes\n *                  the function to return the number of status values, in the\n *                  normal way, without attemtping to store any values.\n * @param status    receives error codes.\n * @return          The number of rule status values from rules that determined\n *                  the most recent boundary returned by the break iterator.\n * @stable ICU 3.0\n */\nU_STABLE  int32_t U_EXPORT2\nubrk_getRuleStatusVec(UBreakIterator *bi, int32_t *fillInVec, int32_t capacity, UErrorCode *status);\n\n/**\n * Return the locale of the break iterator. You can choose between the valid and\n * the actual locale.\n * @param bi break iterator\n * @param type locale type (valid or actual)\n * @param status error code\n * @return locale string\n * @stable ICU 2.8\n */\nU_STABLE const char* U_EXPORT2\nubrk_getLocaleByType(const UBreakIterator *bi, ULocDataLocaleType type, UErrorCode* status);\n\n#ifndef U_HIDE_DRAFT_API\n/**\n  *  Set the subject text string upon which the break iterator is operating\n  *  without changing any other aspect of the state.\n  *  The new and previous text strings must have the same content.\n  *\n  *  This function is intended for use in environments where ICU is operating on\n  *  strings that may move around in memory.  It provides a mechanism for notifying\n  *  ICU that the string has been relocated, and providing a new UText to access the\n  *  string in its new position.\n  *\n  *  Note that the break iterator never copies the underlying text\n  *  of a string being processed, but always operates directly on the original text\n  *  provided by the user. Refreshing simply drops the references to the old text\n  *  and replaces them with references to the new.\n  *\n  *  Caution:  this function is normally used only by very specialized\n  *            system-level code.   One example use case is with garbage collection\n  *            that moves the text in memory.\n  *\n  * @param bi         The break iterator.\n  * @param text       The new (moved) text string.\n  * @param status     Receives errors detected by this function.\n  *\n  * @draft ICU 49\n  */\nU_DRAFT void U_EXPORT2\nubrk_refreshUText(UBreakIterator *bi,\n                       UText          *text,\n                       UErrorCode     *status);\n#endif  /* U_HIDE_DRAFT_API */\n\n#endif /* #if !UCONFIG_NO_BREAK_ITERATION */\n\n#endif\n"
  },
  {
    "path": "deprecated/android/addons/icucompat/unicode/ucal.h",
    "content": "/*\n *******************************************************************************\n * Copyright (C) 1996-2012, International Business Machines Corporation and\n * others. All Rights Reserved.\n *******************************************************************************\n */\n\n#ifndef UCAL_H\n#define UCAL_H\n\n#include \"unicode/utypes.h\"\n#include \"unicode/uenum.h\"\n#include \"unicode/uloc.h\"\n#include \"unicode/localpointer.h\"\n\n#if !UCONFIG_NO_FORMATTING\n\n/**\n * \\file\n * \\brief C API: Calendar\n *\n * <h2>Calendar C API</h2>\n *\n * UCalendar C API is used  for converting between a <code>UDate</code> object\n * and a set of integer fields such as <code>UCAL_YEAR</code>, <code>UCAL_MONTH</code>,\n * <code>UCAL_DAY</code>, <code>UCAL_HOUR</code>, and so on.\n * (A <code>UDate</code> object represents a specific instant in\n * time with millisecond precision. See UDate\n * for information about the <code>UDate</code> .)\n *\n * <p>\n * Types of <code>UCalendar</code> interpret a <code>UDate</code>\n * according to the rules of a specific calendar system. The U_STABLE\n * provides the enum UCalendarType with UCAL_TRADITIONAL and\n * UCAL_GREGORIAN.\n * <p>\n * Like other locale-sensitive C API, calendar API  provides a\n * function, <code>ucal_open()</code>, which returns a pointer to\n * <code>UCalendar</code> whose time fields have been initialized\n * with the current date and time. We need to specify the type of\n * calendar to be opened and the  timezoneId.\n * \\htmlonly<blockquote>\\endhtmlonly\n * <pre>\n * \\code\n * UCalendar *caldef;\n * UChar *tzId;\n * UErrorCode status;\n * tzId=(UChar*)malloc(sizeof(UChar) * (strlen(\"PST\") +1) );\n * u_uastrcpy(tzId, \"PST\");\n * caldef=ucal_open(tzID, u_strlen(tzID), NULL, UCAL_TRADITIONAL, &status);\n * \\endcode\n * </pre>\n * \\htmlonly</blockquote>\\endhtmlonly\n *\n * <p>\n * A <code>UCalendar</code> object can produce all the time field values\n * needed to implement the date-time formatting for a particular language\n * and calendar style (for example, Japanese-Gregorian, Japanese-Traditional).\n *\n * <p>\n * When computing a <code>UDate</code> from time fields, two special circumstances\n * may arise: there may be insufficient information to compute the\n * <code>UDate</code> (such as only year and month but no day in the month),\n * or there may be inconsistent information (such as \"Tuesday, July 15, 1996\"\n * -- July 15, 1996 is actually a Monday).\n *\n * <p>\n * <strong>Insufficient information.</strong> The calendar will use default\n * information to specify the missing fields. This may vary by calendar; for\n * the Gregorian calendar, the default for a field is the same as that of the\n * start of the epoch: i.e., UCAL_YEAR = 1970, UCAL_MONTH = JANUARY, UCAL_DATE = 1, etc.\n *\n * <p>\n * <strong>Inconsistent information.</strong> If fields conflict, the calendar\n * will give preference to fields set more recently. For example, when\n * determining the day, the calendar will look for one of the following\n * combinations of fields.  The most recent combination, as determined by the\n * most recently set single field, will be used.\n *\n * \\htmlonly<blockquote>\\endhtmlonly\n * <pre>\n * \\code\n * UCAL_MONTH + UCAL_DAY_OF_MONTH\n * UCAL_MONTH + UCAL_WEEK_OF_MONTH + UCAL_DAY_OF_WEEK\n * UCAL_MONTH + UCAL_DAY_OF_WEEK_IN_MONTH + UCAL_DAY_OF_WEEK\n * UCAL_DAY_OF_YEAR\n * UCAL_DAY_OF_WEEK + UCAL_WEEK_OF_YEAR\n * \\endcode\n * </pre>\n * \\htmlonly</blockquote>\\endhtmlonly\n *\n * For the time of day:\n *\n * \\htmlonly<blockquote>\\endhtmlonly\n * <pre>\n * \\code\n * UCAL_HOUR_OF_DAY\n * UCAL_AM_PM + UCAL_HOUR\n * \\endcode\n * </pre>\n * \\htmlonly</blockquote>\\endhtmlonly\n *\n * <p>\n * <strong>Note:</strong> for some non-Gregorian calendars, different\n * fields may be necessary for complete disambiguation. For example, a full\n * specification of the historial Arabic astronomical calendar requires year,\n * month, day-of-month <em>and</em> day-of-week in some cases.\n *\n * <p>\n * <strong>Note:</strong> There are certain possible ambiguities in\n * interpretation of certain singular times, which are resolved in the\n * following ways:\n * <ol>\n *     <li> 24:00:00 \"belongs\" to the following day. That is,\n *          23:59 on Dec 31, 1969 &lt; 24:00 on Jan 1, 1970 &lt; 24:01:00 on Jan 1, 1970\n *\n *     <li> Although historically not precise, midnight also belongs to \"am\",\n *          and noon belongs to \"pm\", so on the same day,\n *          12:00 am (midnight) &lt; 12:01 am, and 12:00 pm (noon) &lt; 12:01 pm\n * </ol>\n *\n * <p>\n * The date or time format strings are not part of the definition of a\n * calendar, as those must be modifiable or overridable by the user at\n * runtime. Use {@link icu::DateFormat}\n * to format dates.\n *\n * <p>\n * <code>Calendar</code> provides an API for field \"rolling\", where fields\n * can be incremented or decremented, but wrap around. For example, rolling the\n * month up in the date <code>December 12, <b>1996</b></code> results in\n * <code>January 12, <b>1996</b></code>.\n *\n * <p>\n * <code>Calendar</code> also provides a date arithmetic function for\n * adding the specified (signed) amount of time to a particular time field.\n * For example, subtracting 5 days from the date <code>September 12, 1996</code>\n * results in <code>September 7, 1996</code>.\n *\n * @stable ICU 2.0\n */\n\n/**\n * The time zone ID reserved for unknown time zone.\n * @stable ICU 4.8\n */\n#define UCAL_UNKNOWN_ZONE_ID \"Etc/Unknown\"\n\n/** A calendar.\n *  For usage in C programs.\n * @stable ICU 2.0\n */\ntypedef void* UCalendar;\n\n/** Possible types of UCalendars \n * @stable ICU 2.0\n */\nenum UCalendarType {\n  /**\n   * Despite the name, UCAL_TRADITIONAL designates the locale's default calendar,\n   * which may be the Gregorian calendar or some other calendar.\n   * @stable ICU 2.0\n   */\n  UCAL_TRADITIONAL,\n  /**\n   * A better name for UCAL_TRADITIONAL.\n   * @stable ICU 4.2\n   */\n  UCAL_DEFAULT = UCAL_TRADITIONAL,\n  /**\n   * Unambiguously designates the Gregorian calendar for the locale.\n   * @stable ICU 2.0\n   */\n  UCAL_GREGORIAN\n};\n\n/** @stable ICU 2.0 */\ntypedef enum UCalendarType UCalendarType;\n\n/** Possible fields in a UCalendar \n * @stable ICU 2.0\n */\nenum UCalendarDateFields {\n  /** \n   * Field number indicating the era, e.g., AD or BC in the Gregorian (Julian) calendar. \n   * This is a calendar-specific value.\n   * @stable ICU 2.6 \n   */\n  UCAL_ERA,\n\n  /**\n   * Field number indicating the year. This is a calendar-specific value.\n   * @stable ICU 2.6 \n   */\n  UCAL_YEAR,\n\n  /**\n   * Field number indicating the month. This is a calendar-specific value. \n   * The first month of the year is\n   * <code>JANUARY</code>; the last depends on the number of months in a year.\n   * @see #UCAL_JANUARY\n   * @see #UCAL_FEBRUARY\n   * @see #UCAL_MARCH\n   * @see #UCAL_APRIL\n   * @see #UCAL_MAY\n   * @see #UCAL_JUNE\n   * @see #UCAL_JULY\n   * @see #UCAL_AUGUST\n   * @see #UCAL_SEPTEMBER\n   * @see #UCAL_OCTOBER\n   * @see #UCAL_NOVEMBER\n   * @see #UCAL_DECEMBER\n   * @see #UCAL_UNDECIMBER\n   * @stable ICU 2.6 \n   */\n  UCAL_MONTH,\n\n  /**\n   * Field number indicating the\n   * week number within the current year.  The first week of the year, as\n   * defined by <code>UCAL_FIRST_DAY_OF_WEEK</code> and <code>UCAL_MINIMAL_DAYS_IN_FIRST_WEEK</code>\n   * attributes, has value 1.  Subclasses define\n   * the value of <code>UCAL_WEEK_OF_YEAR</code> for days before the first week of\n   * the year.\n   * @see ucal_getAttribute\n   * @see ucal_setAttribute\n   * @stable ICU 2.6 \n   */\n  UCAL_WEEK_OF_YEAR,\n\n /**\n   * Field number indicating the\n   * week number within the current month.  The first week of the month, as\n   * defined by <code>UCAL_FIRST_DAY_OF_WEEK</code> and <code>UCAL_MINIMAL_DAYS_IN_FIRST_WEEK</code>\n   * attributes, has value 1.  Subclasses define\n   * the value of <code>WEEK_OF_MONTH</code> for days before the first week of\n   * the month.\n   * @see ucal_getAttribute\n   * @see ucal_setAttribute\n   * @see #UCAL_FIRST_DAY_OF_WEEK\n   * @see #UCAL_MINIMAL_DAYS_IN_FIRST_WEEK\n   * @stable ICU 2.6 \n   */\n  UCAL_WEEK_OF_MONTH,\n\n /**\n   * Field number indicating the\n   * day of the month. This is a synonym for <code>DAY_OF_MONTH</code>.\n   * The first day of the month has value 1.\n   * @see #UCAL_DAY_OF_MONTH\n   * @stable ICU 2.6 \n   */\n  UCAL_DATE,\n\n /**\n   * Field number indicating the day\n   * number within the current year.  The first day of the year has value 1.\n   * @stable ICU 2.6 \n   */\n  UCAL_DAY_OF_YEAR,\n\n /**\n   * Field number indicating the day\n   * of the week.  This field takes values <code>SUNDAY</code>,\n   * <code>MONDAY</code>, <code>TUESDAY</code>, <code>WEDNESDAY</code>,\n   * <code>THURSDAY</code>, <code>FRIDAY</code>, and <code>SATURDAY</code>.\n   * @see #UCAL_SUNDAY\n   * @see #UCAL_MONDAY\n   * @see #UCAL_TUESDAY\n   * @see #UCAL_WEDNESDAY\n   * @see #UCAL_THURSDAY\n   * @see #UCAL_FRIDAY\n   * @see #UCAL_SATURDAY\n   * @stable ICU 2.6 \n   */\n  UCAL_DAY_OF_WEEK,\n\n /**\n   * Field number indicating the\n   * ordinal number of the day of the week within the current month. Together\n   * with the <code>DAY_OF_WEEK</code> field, this uniquely specifies a day\n   * within a month.  Unlike <code>WEEK_OF_MONTH</code> and\n   * <code>WEEK_OF_YEAR</code>, this field's value does <em>not</em> depend on\n   * <code>getFirstDayOfWeek()</code> or\n   * <code>getMinimalDaysInFirstWeek()</code>.  <code>DAY_OF_MONTH 1</code>\n   * through <code>7</code> always correspond to <code>DAY_OF_WEEK_IN_MONTH\n   * 1</code>; <code>8</code> through <code>15</code> correspond to\n   * <code>DAY_OF_WEEK_IN_MONTH 2</code>, and so on.\n   * <code>DAY_OF_WEEK_IN_MONTH 0</code> indicates the week before\n   * <code>DAY_OF_WEEK_IN_MONTH 1</code>.  Negative values count back from the\n   * end of the month, so the last Sunday of a month is specified as\n   * <code>DAY_OF_WEEK = SUNDAY, DAY_OF_WEEK_IN_MONTH = -1</code>.  Because\n   * negative values count backward they will usually be aligned differently\n   * within the month than positive values.  For example, if a month has 31\n   * days, <code>DAY_OF_WEEK_IN_MONTH -1</code> will overlap\n   * <code>DAY_OF_WEEK_IN_MONTH 5</code> and the end of <code>4</code>.\n   * @see #UCAL_DAY_OF_WEEK\n   * @see #UCAL_WEEK_OF_MONTH\n   * @stable ICU 2.6 \n   */\n  UCAL_DAY_OF_WEEK_IN_MONTH,\n\n /**\n   * Field number indicating\n   * whether the <code>HOUR</code> is before or after noon.\n   * E.g., at 10:04:15.250 PM the <code>AM_PM</code> is <code>PM</code>.\n   * @see #UCAL_AM\n   * @see #UCAL_PM\n   * @see #UCAL_HOUR\n   * @stable ICU 2.6 \n   */\n  UCAL_AM_PM,\n\n /**\n   * Field number indicating the\n   * hour of the morning or afternoon. <code>HOUR</code> is used for the 12-hour\n   * clock.\n   * E.g., at 10:04:15.250 PM the <code>HOUR</code> is 10.\n   * @see #UCAL_AM_PM\n   * @see #UCAL_HOUR_OF_DAY\n   * @stable ICU 2.6 \n   */\n  UCAL_HOUR,\n\n /**\n   * Field number indicating the\n   * hour of the day. <code>HOUR_OF_DAY</code> is used for the 24-hour clock.\n   * E.g., at 10:04:15.250 PM the <code>HOUR_OF_DAY</code> is 22.\n   * @see #UCAL_HOUR\n   * @stable ICU 2.6 \n   */\n  UCAL_HOUR_OF_DAY,\n\n /**\n   * Field number indicating the\n   * minute within the hour.\n   * E.g., at 10:04:15.250 PM the <code>UCAL_MINUTE</code> is 4.\n   * @stable ICU 2.6 \n   */\n  UCAL_MINUTE,\n\n /**\n   * Field number indicating the\n   * second within the minute.\n   * E.g., at 10:04:15.250 PM the <code>UCAL_SECOND</code> is 15.\n   * @stable ICU 2.6 \n   */\n  UCAL_SECOND,\n\n /**\n   * Field number indicating the\n   * millisecond within the second.\n   * E.g., at 10:04:15.250 PM the <code>UCAL_MILLISECOND</code> is 250.\n   * @stable ICU 2.6 \n   */\n  UCAL_MILLISECOND,\n\n /**\n   * Field number indicating the\n   * raw offset from GMT in milliseconds.\n   * @stable ICU 2.6 \n   */\n  UCAL_ZONE_OFFSET,\n\n /**\n   * Field number indicating the\n   * daylight savings offset in milliseconds.\n   * @stable ICU 2.6 \n   */\n  UCAL_DST_OFFSET,\n  \n /**\n   * Field number \n   * indicating the extended year corresponding to the\n   * <code>UCAL_WEEK_OF_YEAR</code> field.  This may be one greater or less\n   * than the value of <code>UCAL_EXTENDED_YEAR</code>.\n   * @stable ICU 2.6\n   */\n  UCAL_YEAR_WOY,\n\n /**\n   * Field number \n   * indicating the localized day of week.  This will be a value from 1\n   * to 7 inclusive, with 1 being the localized first day of the week.\n   * @stable ICU 2.6\n   */\n  UCAL_DOW_LOCAL,\n\n  /**\n   * Year of this calendar system, encompassing all supra-year fields. For example, \n   * in Gregorian/Julian calendars, positive Extended Year values indicate years AD,\n   *  1 BC = 0 extended, 2 BC = -1 extended, and so on. \n   * @stable ICU 2.8 \n   */\n  UCAL_EXTENDED_YEAR,\n\n /**\n   * Field number \n   * indicating the modified Julian day number.  This is different from\n   * the conventional Julian day number in two regards.  First, it\n   * demarcates days at local zone midnight, rather than noon GMT.\n   * Second, it is a local number; that is, it depends on the local time\n   * zone.  It can be thought of as a single number that encompasses all\n   * the date-related fields.\n   * @stable ICU 2.8\n   */\n  UCAL_JULIAN_DAY, \n\n  /**\n   * Ranges from 0 to 23:59:59.999 (regardless of DST).  This field behaves <em>exactly</em> \n   * like a composite of all time-related fields, not including the zone fields.  As such, \n   * it also reflects discontinuities of those fields on DST transition days.  On a day\n   * of DST onset, it will jump forward.  On a day of DST cessation, it will jump \n   * backward.  This reflects the fact that it must be combined with the DST_OFFSET field\n   * to obtain a unique local time value.\n   * @stable ICU 2.8\n   */\n  UCAL_MILLISECONDS_IN_DAY,\n\n  /**\n   * Whether or not the current month is a leap month (0 or 1). See the Chinese calendar for\n   * an example of this.\n   */\n  UCAL_IS_LEAP_MONTH,\n  \n  /**\n   * Field count\n   * @stable ICU 2.6\n   */\n  UCAL_FIELD_COUNT,\n\n /**\n   * Field number indicating the\n   * day of the month. This is a synonym for <code>UCAL_DATE</code>.\n   * The first day of the month has value 1.\n   * @see #UCAL_DATE\n   * Synonym for UCAL_DATE\n   * @stable ICU 2.8\n   **/\n  UCAL_DAY_OF_MONTH=UCAL_DATE\n};\n\n/** @stable ICU 2.0 */\ntypedef enum UCalendarDateFields UCalendarDateFields;\n    /**\n     * Useful constant for days of week. Note: Calendar day-of-week is 1-based. Clients\n     * who create locale resources for the field of first-day-of-week should be aware of\n     * this. For instance, in US locale, first-day-of-week is set to 1, i.e., UCAL_SUNDAY.\n     */\n/** Possible days of the week in a UCalendar \n * @stable ICU 2.0\n */\nenum UCalendarDaysOfWeek {\n  /** Sunday */\n  UCAL_SUNDAY = 1,\n  /** Monday */\n  UCAL_MONDAY,\n  /** Tuesday */\n  UCAL_TUESDAY,\n  /** Wednesday */\n  UCAL_WEDNESDAY,\n  /** Thursday */\n  UCAL_THURSDAY,\n  /** Friday */\n  UCAL_FRIDAY,\n  /** Saturday */\n  UCAL_SATURDAY\n};\n\n/** @stable ICU 2.0 */\ntypedef enum UCalendarDaysOfWeek UCalendarDaysOfWeek;\n\n/** Possible months in a UCalendar. Note: Calendar month is 0-based.\n * @stable ICU 2.0\n */\nenum UCalendarMonths {\n  /** January */\n  UCAL_JANUARY,\n  /** February */\n  UCAL_FEBRUARY,\n  /** March */\n  UCAL_MARCH,\n  /** April */\n  UCAL_APRIL,\n  /** May */\n  UCAL_MAY,\n  /** June */\n  UCAL_JUNE,\n  /** July */\n  UCAL_JULY,\n  /** August */\n  UCAL_AUGUST,\n  /** September */\n  UCAL_SEPTEMBER,\n  /** October */\n  UCAL_OCTOBER,\n  /** November */\n  UCAL_NOVEMBER,\n  /** December */\n  UCAL_DECEMBER,\n  /** Value of the <code>UCAL_MONTH</code> field indicating the\n    * thirteenth month of the year. Although the Gregorian calendar\n    * does not use this value, lunar calendars do.\n    */\n  UCAL_UNDECIMBER\n};\n\n/** @stable ICU 2.0 */\ntypedef enum UCalendarMonths UCalendarMonths;\n\n/** Possible AM/PM values in a UCalendar \n * @stable ICU 2.0\n */\nenum UCalendarAMPMs {\n    /** AM */\n  UCAL_AM,\n  /** PM */\n  UCAL_PM\n};\n\n/** @stable ICU 2.0 */\ntypedef enum UCalendarAMPMs UCalendarAMPMs;\n\n/**\n * System time zone type constants used by filtering zones\n * in ucal_openTimeZoneIDEnumeration.\n * @see ucal_openTimeZoneIDEnumeration\n * @stable ICU 4.8\n */\nenum USystemTimeZoneType {\n    /**\n     * Any system zones.\n     * @stable ICU 4.8\n     */\n    UCAL_ZONE_TYPE_ANY,\n    /**\n     * Canonical system zones.\n     * @stable ICU 4.8\n     */\n    UCAL_ZONE_TYPE_CANONICAL,\n    /**\n     * Canonical system zones associated with actual locations.\n     * @stable ICU 4.8\n     */\n    UCAL_ZONE_TYPE_CANONICAL_LOCATION\n};\n\n/** @stable ICU 4.8 */\ntypedef enum USystemTimeZoneType USystemTimeZoneType;\n\n/** \n * Create an enumeration over system time zone IDs with the given\n * filter conditions. \n * @param zoneType  The system time zone type.\n * @param region    The ISO 3166 two-letter country code or UN M.49\n *                  three-digit area code.  When NULL, no filtering\n *                  done by region. \n * @param rawOffset An offset from GMT in milliseconds, ignoring the\n *                  effect of daylight savings time, if any. When NULL,\n *                  no filtering done by zone offset.\n * @param ec        A pointer to an UErrorCode to receive any errors\n * @return  an enumeration object that the caller must dispose of\n *          using enum_close(), or NULL upon failure. In case of failure,\n *          *ec will indicate the error.\n * @stable ICU 4.8\n */ \nU_STABLE UEnumeration* U_EXPORT2\nucal_openTimeZoneIDEnumeration(USystemTimeZoneType zoneType, const char* region,\n                                const int32_t* rawOffset, UErrorCode* ec);\n\n/**\n * Create an enumeration over all time zones.\n *\n * @param ec input/output error code\n *\n * @return an enumeration object that the caller must dispose of using\n * uenum_close(), or NULL upon failure. In case of failure *ec will\n * indicate the error.\n *\n * @stable ICU 2.6\n */\nU_STABLE UEnumeration* U_EXPORT2\nucal_openTimeZones(UErrorCode* ec);\n\n/**\n * Create an enumeration over all time zones associated with the given\n * country. Some zones are affiliated with no country (e.g., \"UTC\");\n * these may also be retrieved, as a group.\n *\n * @param country the ISO 3166 two-letter country code, or NULL to\n * retrieve zones not affiliated with any country\n *\n * @param ec input/output error code\n *\n * @return an enumeration object that the caller must dispose of using\n * uenum_close(), or NULL upon failure. In case of failure *ec will\n * indicate the error.\n *\n * @stable ICU 2.6\n */\nU_STABLE UEnumeration* U_EXPORT2\nucal_openCountryTimeZones(const char* country, UErrorCode* ec);\n\n/**\n * Return the default time zone. The default is determined initially\n * by querying the host operating system. It may be changed with\n * ucal_setDefaultTimeZone() or with the C++ TimeZone API.\n *\n * @param result A buffer to receive the result, or NULL\n *\n * @param resultCapacity The capacity of the result buffer\n *\n * @param ec input/output error code\n *\n * @return The result string length, not including the terminating\n * null\n *\n * @stable ICU 2.6\n */\nU_STABLE int32_t U_EXPORT2\nucal_getDefaultTimeZone(UChar* result, int32_t resultCapacity, UErrorCode* ec);\n\n/**\n * Set the default time zone.\n *\n * @param zoneID null-terminated time zone ID\n *\n * @param ec input/output error code\n *\n * @stable ICU 2.6\n */\nU_STABLE void U_EXPORT2\nucal_setDefaultTimeZone(const UChar* zoneID, UErrorCode* ec);\n\n/**\n * Return the amount of time in milliseconds that the clock is\n * advanced during daylight savings time for the given time zone, or\n * zero if the time zone does not observe daylight savings time.\n *\n * @param zoneID null-terminated time zone ID\n *\n * @param ec input/output error code\n *\n * @return the number of milliseconds the time is advanced with\n * respect to standard time when the daylight savings rules are in\n * effect. This is always a non-negative number, most commonly either\n * 3,600,000 (one hour) or zero.\n *\n * @stable ICU 2.6\n */\nU_STABLE int32_t U_EXPORT2\nucal_getDSTSavings(const UChar* zoneID, UErrorCode* ec);\n\n/**\n * Get the current date and time.\n * The value returned is represented as milliseconds from the epoch.\n * @return The current date and time.\n * @stable ICU 2.0\n */\nU_STABLE UDate U_EXPORT2 \nucal_getNow(void);\n\n/**\n * Open a UCalendar.\n * A UCalendar may be used to convert a millisecond value to a year,\n * month, and day.\n * <p>\n * Note: When unknown TimeZone ID is specified or if the TimeZone ID specified is \"Etc/Unknown\",\n * the UCalendar returned by the function is initialized with GMT zone with TimeZone ID\n * <code>UCAL_UNKNOWN_ZONE_ID</code> (\"Etc/Unknown\") without any errors/warnings.  If you want\n * to check if a TimeZone ID is valid prior to this function, use <code>ucal_getCanonicalTimeZoneID</code>.\n * \n * @param zoneID The desired TimeZone ID.  If 0, use the default time zone.\n * @param len The length of zoneID, or -1 if null-terminated.\n * @param locale The desired locale\n * @param type The type of UCalendar to open. This can be UCAL_GREGORIAN to open the Gregorian\n * calendar for the locale, or UCAL_DEFAULT to open the default calendar for the locale (the\n * default calendar may also be Gregorian). To open a specific non-Gregorian calendar for the\n * locale, use uloc_setKeywordValue to set the value of the calendar keyword for the locale\n * and then pass the locale to ucal_open with UCAL_DEFAULT as the type.\n * @param status A pointer to an UErrorCode to receive any errors\n * @return A pointer to a UCalendar, or 0 if an error occurred.\n * @see #UCAL_UNKNOWN_ZONE_ID\n * @stable ICU 2.0\n */\nU_STABLE UCalendar* U_EXPORT2 \nucal_open(const UChar*   zoneID,\n          int32_t        len,\n          const char*    locale,\n          UCalendarType  type,\n          UErrorCode*    status);\n\n/**\n * Close a UCalendar.\n * Once closed, a UCalendar may no longer be used.\n * @param cal The UCalendar to close.\n * @stable ICU 2.0\n */\nU_STABLE void U_EXPORT2 \nucal_close(UCalendar *cal);\n\n#if U_SHOW_CPLUSPLUS_API\n\nU_NAMESPACE_BEGIN\n\n/**\n * \\class LocalUCalendarPointer\n * \"Smart pointer\" class, closes a UCalendar via ucal_close().\n * For most methods see the LocalPointerBase base class.\n *\n * @see LocalPointerBase\n * @see LocalPointer\n * @stable ICU 4.4\n */\nU_DEFINE_LOCAL_OPEN_POINTER(LocalUCalendarPointer, UCalendar, ucal_close);\n\nU_NAMESPACE_END\n\n#endif\n\n/**\n * Open a copy of a UCalendar.\n * This function performs a deep copy.\n * @param cal The calendar to copy\n * @param status A pointer to an UErrorCode to receive any errors.\n * @return A pointer to a UCalendar identical to cal.\n * @stable ICU 4.0\n */\nU_STABLE UCalendar* U_EXPORT2 \nucal_clone(const UCalendar* cal,\n           UErrorCode*      status);\n\n/**\n * Set the TimeZone used by a UCalendar.\n * A UCalendar uses a timezone for converting from Greenwich time to local time.\n * @param cal The UCalendar to set.\n * @param zoneID The desired TimeZone ID.  If 0, use the default time zone.\n * @param len The length of zoneID, or -1 if null-terminated.\n * @param status A pointer to an UErrorCode to receive any errors.\n * @stable ICU 2.0\n */\nU_STABLE void U_EXPORT2 \nucal_setTimeZone(UCalendar*    cal,\n                 const UChar*  zoneID,\n                 int32_t       len,\n                 UErrorCode*   status);\n\n/**\n * Possible formats for a UCalendar's display name \n * @stable ICU 2.0\n */\nenum UCalendarDisplayNameType {\n  /** Standard display name */\n  UCAL_STANDARD,\n  /** Short standard display name */\n  UCAL_SHORT_STANDARD,\n  /** Daylight savings display name */\n  UCAL_DST,\n  /** Short daylight savings display name */\n  UCAL_SHORT_DST\n};\n\n/** @stable ICU 2.0 */\ntypedef enum UCalendarDisplayNameType UCalendarDisplayNameType;\n\n/**\n * Get the display name for a UCalendar's TimeZone.\n * A display name is suitable for presentation to a user.\n * @param cal          The UCalendar to query.\n * @param type         The desired display name format; one of UCAL_STANDARD, UCAL_SHORT_STANDARD,\n *                     UCAL_DST, UCAL_SHORT_DST\n * @param locale       The desired locale for the display name.\n * @param result       A pointer to a buffer to receive the formatted number.\n * @param resultLength The maximum size of result.\n * @param status       A pointer to an UErrorCode to receive any errors\n * @return             The total buffer size needed; if greater than resultLength, the output was truncated.\n * @stable ICU 2.0\n */\nU_STABLE int32_t U_EXPORT2 \nucal_getTimeZoneDisplayName(const UCalendar*          cal,\n                            UCalendarDisplayNameType  type,\n                            const char*               locale,\n                            UChar*                    result,\n                            int32_t                   resultLength,\n                            UErrorCode*               status);\n\n/**\n * Determine if a UCalendar is currently in daylight savings time.\n * Daylight savings time is not used in all parts of the world.\n * @param cal The UCalendar to query.\n * @param status A pointer to an UErrorCode to receive any errors\n * @return TRUE if cal is currently in daylight savings time, FALSE otherwise\n * @stable ICU 2.0\n */\nU_STABLE UBool U_EXPORT2 \nucal_inDaylightTime(const UCalendar*  cal,\n                    UErrorCode*       status );\n\n/**\n * Sets the GregorianCalendar change date. This is the point when the switch from\n * Julian dates to Gregorian dates occurred. Default is 00:00:00 local time, October\n * 15, 1582. Previous to this time and date will be Julian dates.\n *\n * This function works only for Gregorian calendars. If the UCalendar is not\n * an instance of a Gregorian calendar, then a U_UNSUPPORTED_ERROR\n * error code is set.\n *\n * @param cal        The calendar object.\n * @param date       The given Gregorian cutover date.\n * @param pErrorCode Pointer to a standard ICU error code. Its input value must\n *                   pass the U_SUCCESS() test, or else the function returns\n *                   immediately. Check for U_FAILURE() on output or use with\n *                   function chaining. (See User Guide for details.)\n *\n * @see GregorianCalendar::setGregorianChange\n * @see ucal_getGregorianChange\n * @stable ICU 3.6\n */\nU_STABLE void U_EXPORT2\nucal_setGregorianChange(UCalendar *cal, UDate date, UErrorCode *pErrorCode);\n\n/**\n * Gets the Gregorian Calendar change date. This is the point when the switch from\n * Julian dates to Gregorian dates occurred. Default is 00:00:00 local time, October\n * 15, 1582. Previous to this time and date will be Julian dates.\n *\n * This function works only for Gregorian calendars. If the UCalendar is not\n * an instance of a Gregorian calendar, then a U_UNSUPPORTED_ERROR\n * error code is set.\n *\n * @param cal        The calendar object.\n * @param pErrorCode Pointer to a standard ICU error code. Its input value must\n *                   pass the U_SUCCESS() test, or else the function returns\n *                   immediately. Check for U_FAILURE() on output or use with\n *                   function chaining. (See User Guide for details.)\n * @return   The Gregorian cutover time for this calendar.\n *\n * @see GregorianCalendar::getGregorianChange\n * @see ucal_setGregorianChange\n * @stable ICU 3.6\n */\nU_STABLE UDate U_EXPORT2\nucal_getGregorianChange(const UCalendar *cal, UErrorCode *pErrorCode);\n\n/**\n * Types of UCalendar attributes \n * @stable ICU 2.0\n */\nenum UCalendarAttribute {\n  /**\n   * Lenient parsing\n   * @stable ICU 2.0\n   */\n  UCAL_LENIENT,\n  /**\n   * First day of week\n   * @stable ICU 2.0\n   */\n  UCAL_FIRST_DAY_OF_WEEK,\n  /**\n   * Minimum number of days in first week\n   * @stable ICU 2.0\n   */\n  UCAL_MINIMAL_DAYS_IN_FIRST_WEEK\n#ifndef U_HIDE_DRAFT_API\n  ,\n  /**\n   * The behavior for handling wall time repeating multiple times\n   * at negative time zone offset transitions\n   * @draft ICU 49\n   */\n  UCAL_REPEATED_WALL_TIME,\n  /**\n   * The behavior for handling skipped wall time at positive time\n   * zone offset transitions.\n   * @draft ICU 49\n   */\n  UCAL_SKIPPED_WALL_TIME\n#endif  /* U_HIDE_DRAFT_API */\n};\n\n/** @stable ICU 2.0 */\ntypedef enum UCalendarAttribute UCalendarAttribute;\n\n/**\n * Options for handling ambiguous wall time at time zone\n * offset transitions.\n * @draft ICU 49\n */\nenum UCalendarWallTimeOption {\n    /**\n     * An ambiguous wall time to be interpreted as the latest.\n     * This option is valid for UCAL_REPEATED_WALL_TIME and\n     * UCAL_SKIPPED_WALL_TIME.\n     * @draft ICU 49\n     */\n    UCAL_WALLTIME_LAST\n#ifndef U_HIDE_DRAFT_API\n    ,\n    /**\n     * An ambiguous wall time to be interpreted as the earliest.\n     * This option is valid for UCAL_REPEATED_WALL_TIME and\n     * UCAL_SKIPPED_WALL_TIME.\n     * @draft ICU 49\n     */\n    UCAL_WALLTIME_FIRST,\n    /**\n     * An ambiguous wall time to be interpreted as the next valid\n     * wall time. This option is valid for UCAL_SKIPPED_WALL_TIME.\n     * @draft ICU 49\n     */\n    UCAL_WALLTIME_NEXT_VALID\n#endif  /* U_HIDE_DRAFT_API */\n};\n/** @draft ICU 49 */\ntypedef enum UCalendarWallTimeOption UCalendarWallTimeOption;\n\n/**\n * Get a numeric attribute associated with a UCalendar.\n * Numeric attributes include the first day of the week, or the minimal numbers\n * of days in the first week of the month.\n * @param cal The UCalendar to query.\n * @param attr The desired attribute; one of UCAL_LENIENT, UCAL_FIRST_DAY_OF_WEEK,\n * UCAL_MINIMAL_DAYS_IN_FIRST_WEEK, UCAL_REPEATED_WALL_TIME or UCAL_SKIPPED_WALL_TIME\n * @return The value of attr.\n * @see ucal_setAttribute\n * @stable ICU 2.0\n */\nU_STABLE int32_t U_EXPORT2 \nucal_getAttribute(const UCalendar*    cal,\n                  UCalendarAttribute  attr);\n\n/**\n * Set a numeric attribute associated with a UCalendar.\n * Numeric attributes include the first day of the week, or the minimal numbers\n * of days in the first week of the month.\n * @param cal The UCalendar to set.\n * @param attr The desired attribute; one of UCAL_LENIENT, UCAL_FIRST_DAY_OF_WEEK,\n * UCAL_MINIMAL_DAYS_IN_FIRST_WEEK, UCAL_REPEATED_WALL_TIME or UCAL_SKIPPED_WALL_TIME\n * @param newValue The new value of attr.\n * @see ucal_getAttribute\n * @stable ICU 2.0\n */\nU_STABLE void U_EXPORT2 \nucal_setAttribute(UCalendar*          cal,\n                  UCalendarAttribute  attr,\n                  int32_t             newValue);\n\n/**\n * Get a locale for which calendars are available.\n * A UCalendar in a locale returned by this function will contain the correct\n * day and month names for the locale.\n * @param localeIndex The index of the desired locale.\n * @return A locale for which calendars are available, or 0 if none.\n * @see ucal_countAvailable\n * @stable ICU 2.0\n */\nU_STABLE const char* U_EXPORT2 \nucal_getAvailable(int32_t localeIndex);\n\n/**\n * Determine how many locales have calendars available.\n * This function is most useful as determining the loop ending condition for\n * calls to \\ref ucal_getAvailable.\n * @return The number of locales for which calendars are available.\n * @see ucal_getAvailable\n * @stable ICU 2.0\n */\nU_STABLE int32_t U_EXPORT2 \nucal_countAvailable(void);\n\n/**\n * Get a UCalendar's current time in millis.\n * The time is represented as milliseconds from the epoch.\n * @param cal The UCalendar to query.\n * @param status A pointer to an UErrorCode to receive any errors\n * @return The calendar's current time in millis.\n * @see ucal_setMillis\n * @see ucal_setDate\n * @see ucal_setDateTime\n * @stable ICU 2.0\n */\nU_STABLE UDate U_EXPORT2 \nucal_getMillis(const UCalendar*  cal,\n               UErrorCode*       status);\n\n/**\n * Set a UCalendar's current time in millis.\n * The time is represented as milliseconds from the epoch.\n * @param cal The UCalendar to set.\n * @param dateTime The desired date and time.\n * @param status A pointer to an UErrorCode to receive any errors\n * @see ucal_getMillis\n * @see ucal_setDate\n * @see ucal_setDateTime\n * @stable ICU 2.0\n */\nU_STABLE void U_EXPORT2 \nucal_setMillis(UCalendar*   cal,\n               UDate        dateTime,\n               UErrorCode*  status );\n\n/**\n * Set a UCalendar's current date.\n * The date is represented as a series of 32-bit integers.\n * @param cal The UCalendar to set.\n * @param year The desired year.\n * @param month The desired month; one of UCAL_JANUARY, UCAL_FEBRUARY, UCAL_MARCH, UCAL_APRIL, UCAL_MAY,\n * UCAL_JUNE, UCAL_JULY, UCAL_AUGUST, UCAL_SEPTEMBER, UCAL_OCTOBER, UCAL_NOVEMBER, UCAL_DECEMBER, UCAL_UNDECIMBER\n * @param date The desired day of the month.\n * @param status A pointer to an UErrorCode to receive any errors\n * @see ucal_getMillis\n * @see ucal_setMillis\n * @see ucal_setDateTime\n * @stable ICU 2.0\n */\nU_STABLE void U_EXPORT2 \nucal_setDate(UCalendar*   cal,\n             int32_t      year,\n             int32_t      month,\n             int32_t      date,\n             UErrorCode*  status);\n\n/**\n * Set a UCalendar's current date.\n * The date is represented as a series of 32-bit integers.\n * @param cal The UCalendar to set.\n * @param year The desired year.\n * @param month The desired month; one of UCAL_JANUARY, UCAL_FEBRUARY, UCAL_MARCH, UCAL_APRIL, UCAL_MAY,\n * UCAL_JUNE, UCAL_JULY, UCAL_AUGUST, UCAL_SEPTEMBER, UCAL_OCTOBER, UCAL_NOVEMBER, UCAL_DECEMBER, UCAL_UNDECIMBER\n * @param date The desired day of the month.\n * @param hour The desired hour of day.\n * @param minute The desired minute.\n * @param second The desirec second.\n * @param status A pointer to an UErrorCode to receive any errors\n * @see ucal_getMillis\n * @see ucal_setMillis\n * @see ucal_setDate\n * @stable ICU 2.0\n */\nU_STABLE void U_EXPORT2 \nucal_setDateTime(UCalendar*   cal,\n                 int32_t      year,\n                 int32_t      month,\n                 int32_t      date,\n                 int32_t      hour,\n                 int32_t      minute,\n                 int32_t      second,\n                 UErrorCode*  status);\n\n/**\n * Returns TRUE if two UCalendars are equivalent.  Equivalent\n * UCalendars will behave identically, but they may be set to\n * different times.\n * @param cal1 The first of the UCalendars to compare.\n * @param cal2 The second of the UCalendars to compare.\n * @return TRUE if cal1 and cal2 are equivalent, FALSE otherwise.\n * @stable ICU 2.0\n */\nU_STABLE UBool U_EXPORT2 \nucal_equivalentTo(const UCalendar*  cal1,\n                  const UCalendar*  cal2);\n\n/**\n * Add a specified signed amount to a particular field in a UCalendar.\n * This can modify more significant fields in the calendar.\n * Adding a positive value always means moving forward in time, so for the Gregorian calendar,\n * starting with 100 BC and adding +1 to year results in 99 BC (even though this actually reduces\n * the numeric value of the field itself).\n * @param cal The UCalendar to which to add.\n * @param field The field to which to add the signed value; one of UCAL_ERA, UCAL_YEAR, UCAL_MONTH,\n * UCAL_WEEK_OF_YEAR, UCAL_WEEK_OF_MONTH, UCAL_DATE, UCAL_DAY_OF_YEAR, UCAL_DAY_OF_WEEK,\n * UCAL_DAY_OF_WEEK_IN_MONTH, UCAL_AM_PM, UCAL_HOUR, UCAL_HOUR_OF_DAY, UCAL_MINUTE, UCAL_SECOND,\n * UCAL_MILLISECOND, UCAL_ZONE_OFFSET, UCAL_DST_OFFSET.\n * @param amount The signed amount to add to field. If the amount causes the value\n * to exceed to maximum or minimum values for that field, other fields are modified\n * to preserve the magnitude of the change.\n * @param status A pointer to an UErrorCode to receive any errors\n * @see ucal_roll\n * @stable ICU 2.0\n */\nU_STABLE void U_EXPORT2 \nucal_add(UCalendar*           cal,\n         UCalendarDateFields  field,\n         int32_t              amount,\n         UErrorCode*          status);\n\n/**\n * Add a specified signed amount to a particular field in a UCalendar.\n * This will not modify more significant fields in the calendar.\n * Rolling by a positive value always means moving forward in time (unless the limit of the\n * field is reached, in which case it may pin or wrap), so for Gregorian calendar,\n * starting with 100 BC and rolling the year by +1 results in 99 BC.\n * When eras have a definite beginning and end (as in the Chinese calendar, or as in most eras in the\n * Japanese calendar) then rolling the year past either limit of the era will cause the year to wrap around.\n * When eras only have a limit at one end, then attempting to roll the year past that limit will result in\n * pinning the year at that limit. Note that for most calendars in which era 0 years move forward in time\n * (such as Buddhist, Hebrew, or Islamic), it is possible for add or roll to result in negative years for\n * era 0 (that is the only way to represent years before the calendar epoch).\n * @param cal The UCalendar to which to add.\n * @param field The field to which to add the signed value; one of UCAL_ERA, UCAL_YEAR, UCAL_MONTH,\n * UCAL_WEEK_OF_YEAR, UCAL_WEEK_OF_MONTH, UCAL_DATE, UCAL_DAY_OF_YEAR, UCAL_DAY_OF_WEEK,\n * UCAL_DAY_OF_WEEK_IN_MONTH, UCAL_AM_PM, UCAL_HOUR, UCAL_HOUR_OF_DAY, UCAL_MINUTE, UCAL_SECOND,\n * UCAL_MILLISECOND, UCAL_ZONE_OFFSET, UCAL_DST_OFFSET.\n * @param amount The signed amount to add to field. If the amount causes the value\n * to exceed to maximum or minimum values for that field, the field is pinned to a permissible\n * value.\n * @param status A pointer to an UErrorCode to receive any errors\n * @see ucal_add\n * @stable ICU 2.0\n */\nU_STABLE void U_EXPORT2 \nucal_roll(UCalendar*           cal,\n          UCalendarDateFields  field,\n          int32_t              amount,\n          UErrorCode*          status);\n\n/**\n * Get the current value of a field from a UCalendar.\n * All fields are represented as 32-bit integers.\n * @param cal The UCalendar to query.\n * @param field The desired field; one of UCAL_ERA, UCAL_YEAR, UCAL_MONTH,\n * UCAL_WEEK_OF_YEAR, UCAL_WEEK_OF_MONTH, UCAL_DATE, UCAL_DAY_OF_YEAR, UCAL_DAY_OF_WEEK,\n * UCAL_DAY_OF_WEEK_IN_MONTH, UCAL_AM_PM, UCAL_HOUR, UCAL_HOUR_OF_DAY, UCAL_MINUTE, UCAL_SECOND,\n * UCAL_MILLISECOND, UCAL_ZONE_OFFSET, UCAL_DST_OFFSET.\n * @param status A pointer to an UErrorCode to receive any errors\n * @return The value of the desired field.\n * @see ucal_set\n * @see ucal_isSet\n * @see ucal_clearField\n * @see ucal_clear\n * @stable ICU 2.0\n */\nU_STABLE int32_t U_EXPORT2 \nucal_get(const UCalendar*     cal,\n         UCalendarDateFields  field,\n         UErrorCode*          status );\n\n/**\n * Set the value of a field in a UCalendar.\n * All fields are represented as 32-bit integers.\n * @param cal The UCalendar to set.\n * @param field The field to set; one of UCAL_ERA, UCAL_YEAR, UCAL_MONTH,\n * UCAL_WEEK_OF_YEAR, UCAL_WEEK_OF_MONTH, UCAL_DATE, UCAL_DAY_OF_YEAR, UCAL_DAY_OF_WEEK,\n * UCAL_DAY_OF_WEEK_IN_MONTH, UCAL_AM_PM, UCAL_HOUR, UCAL_HOUR_OF_DAY, UCAL_MINUTE, UCAL_SECOND,\n * UCAL_MILLISECOND, UCAL_ZONE_OFFSET, UCAL_DST_OFFSET.\n * @param value The desired value of field.\n * @see ucal_get\n * @see ucal_isSet\n * @see ucal_clearField\n * @see ucal_clear\n * @stable ICU 2.0\n */\nU_STABLE void U_EXPORT2 \nucal_set(UCalendar*           cal,\n         UCalendarDateFields  field,\n         int32_t              value);\n\n/**\n * Determine if a field in a UCalendar is set.\n * All fields are represented as 32-bit integers.\n * @param cal The UCalendar to query.\n * @param field The desired field; one of UCAL_ERA, UCAL_YEAR, UCAL_MONTH,\n * UCAL_WEEK_OF_YEAR, UCAL_WEEK_OF_MONTH, UCAL_DATE, UCAL_DAY_OF_YEAR, UCAL_DAY_OF_WEEK,\n * UCAL_DAY_OF_WEEK_IN_MONTH, UCAL_AM_PM, UCAL_HOUR, UCAL_HOUR_OF_DAY, UCAL_MINUTE, UCAL_SECOND,\n * UCAL_MILLISECOND, UCAL_ZONE_OFFSET, UCAL_DST_OFFSET.\n * @return TRUE if field is set, FALSE otherwise.\n * @see ucal_get\n * @see ucal_set\n * @see ucal_clearField\n * @see ucal_clear\n * @stable ICU 2.0\n */\nU_STABLE UBool U_EXPORT2 \nucal_isSet(const UCalendar*     cal,\n           UCalendarDateFields  field);\n\n/**\n * Clear a field in a UCalendar.\n * All fields are represented as 32-bit integers.\n * @param cal The UCalendar containing the field to clear.\n * @param field The field to clear; one of UCAL_ERA, UCAL_YEAR, UCAL_MONTH,\n * UCAL_WEEK_OF_YEAR, UCAL_WEEK_OF_MONTH, UCAL_DATE, UCAL_DAY_OF_YEAR, UCAL_DAY_OF_WEEK,\n * UCAL_DAY_OF_WEEK_IN_MONTH, UCAL_AM_PM, UCAL_HOUR, UCAL_HOUR_OF_DAY, UCAL_MINUTE, UCAL_SECOND,\n * UCAL_MILLISECOND, UCAL_ZONE_OFFSET, UCAL_DST_OFFSET.\n * @see ucal_get\n * @see ucal_set\n * @see ucal_isSet\n * @see ucal_clear\n * @stable ICU 2.0\n */\nU_STABLE void U_EXPORT2 \nucal_clearField(UCalendar*           cal,\n                UCalendarDateFields  field);\n\n/**\n * Clear all fields in a UCalendar.\n * All fields are represented as 32-bit integers.\n * @param calendar The UCalendar to clear.\n * @see ucal_get\n * @see ucal_set\n * @see ucal_isSet\n * @see ucal_clearField\n * @stable ICU 2.0\n */\nU_STABLE void U_EXPORT2 \nucal_clear(UCalendar* calendar);\n\n/**\n * Possible limit values for a UCalendar \n * @stable ICU 2.0\n */\nenum UCalendarLimitType {\n  /** Minimum value */\n  UCAL_MINIMUM,\n  /** Maximum value */\n  UCAL_MAXIMUM,\n  /** Greatest minimum value */\n  UCAL_GREATEST_MINIMUM,\n  /** Leaest maximum value */\n  UCAL_LEAST_MAXIMUM,\n  /** Actual minimum value */\n  UCAL_ACTUAL_MINIMUM,\n  /** Actual maximum value */\n  UCAL_ACTUAL_MAXIMUM\n};\n\n/** @stable ICU 2.0 */\ntypedef enum UCalendarLimitType UCalendarLimitType;\n\n/**\n * Determine a limit for a field in a UCalendar.\n * A limit is a maximum or minimum value for a field.\n * @param cal The UCalendar to query.\n * @param field The desired field; one of UCAL_ERA, UCAL_YEAR, UCAL_MONTH,\n * UCAL_WEEK_OF_YEAR, UCAL_WEEK_OF_MONTH, UCAL_DATE, UCAL_DAY_OF_YEAR, UCAL_DAY_OF_WEEK,\n * UCAL_DAY_OF_WEEK_IN_MONTH, UCAL_AM_PM, UCAL_HOUR, UCAL_HOUR_OF_DAY, UCAL_MINUTE, UCAL_SECOND,\n * UCAL_MILLISECOND, UCAL_ZONE_OFFSET, UCAL_DST_OFFSET.\n * @param type The desired critical point; one of UCAL_MINIMUM, UCAL_MAXIMUM, UCAL_GREATEST_MINIMUM,\n * UCAL_LEAST_MAXIMUM, UCAL_ACTUAL_MINIMUM, UCAL_ACTUAL_MAXIMUM\n * @param status A pointer to an UErrorCode to receive any errors.\n * @return The requested value.\n * @stable ICU 2.0\n */\nU_STABLE int32_t U_EXPORT2 \nucal_getLimit(const UCalendar*     cal,\n              UCalendarDateFields  field,\n              UCalendarLimitType   type,\n              UErrorCode*          status);\n\n/** Get the locale for this calendar object. You can choose between valid and actual locale.\n *  @param cal The calendar object\n *  @param type type of the locale we're looking for (valid or actual) \n *  @param status error code for the operation\n *  @return the locale name\n *  @stable ICU 2.8\n */\nU_STABLE const char * U_EXPORT2\nucal_getLocaleByType(const UCalendar *cal, ULocDataLocaleType type, UErrorCode* status);\n\n/**\n * Returns the timezone data version currently used by ICU.\n * @param status error code for the operation\n * @return the version string, such as \"2007f\"\n * @stable ICU 3.8\n */\nU_STABLE const char * U_EXPORT2\nucal_getTZDataVersion(UErrorCode* status);\n\n/**\n * Returns the canonical system timezone ID or the normalized\n * custom time zone ID for the given time zone ID.\n * @param id        The input timezone ID to be canonicalized.\n * @param len       The length of id, or -1 if null-terminated.\n * @param result    The buffer receives the canonical system timezone ID\n *                  or the custom timezone ID in normalized format.\n * @param resultCapacity    The capacity of the result buffer.\n * @param isSystemID        Receives if the given ID is a known system\n     *                      timezone ID.\n * @param status    Recevies the status.  When the given timezone ID\n *                  is neither a known system time zone ID nor a\n *                  valid custom timezone ID, U_ILLEGAL_ARGUMENT_ERROR\n *                  is set.\n * @return          The result string length, not including the terminating\n *                  null.\n * @stable ICU 4.0\n */\nU_STABLE int32_t U_EXPORT2\nucal_getCanonicalTimeZoneID(const UChar* id, int32_t len,\n                            UChar* result, int32_t resultCapacity, UBool *isSystemID, UErrorCode* status);\n/**\n * Get the resource keyword value string designating the calendar type for the UCalendar.\n * @param cal The UCalendar to query.\n * @param status The error code for the operation.\n * @return The resource keyword value string.\n * @stable ICU 4.2\n */\nU_STABLE const char * U_EXPORT2\nucal_getType(const UCalendar *cal, UErrorCode* status);\n\n/**\n * Given a key and a locale, returns an array of string values in a preferred\n * order that would make a difference. These are all and only those values where\n * the open (creation) of the service with the locale formed from the input locale\n * plus input keyword and that value has different behavior than creation with the\n * input locale alone.\n * @param key           one of the keys supported by this service.  For now, only\n *                      \"calendar\" is supported.\n * @param locale        the locale\n * @param commonlyUsed  if set to true it will return only commonly used values\n *                      with the given locale in preferred order.  Otherwise,\n *                      it will return all the available values for the locale.\n * @param status error status\n * @return a string enumeration over keyword values for the given key and the locale.\n * @stable ICU 4.2\n */\nU_STABLE UEnumeration* U_EXPORT2\nucal_getKeywordValuesForLocale(const char* key,\n                               const char* locale,\n                               UBool commonlyUsed,\n                               UErrorCode* status);\n\n\n/** Weekday types, as returned by ucal_getDayOfWeekType().\n * @stable ICU 4.4\n */\nenum UCalendarWeekdayType {\n  /**\n   * Designates a full weekday (no part of the day is included in the weekend).\n   * @stable ICU 4.4 \n   */\n  UCAL_WEEKDAY,\n  /**\n   * Designates a full weekend day (the entire day is included in the weekend).\n   * @stable ICU 4.4 \n   */\n  UCAL_WEEKEND,\n  /**\n   * Designates a day that starts as a weekday and transitions to the weekend.\n   * Call ucal_getWeekendTransition() to get the time of transition.\n   * @stable ICU 4.4 \n   */\n  UCAL_WEEKEND_ONSET,\n  /**\n   * Designates a day that starts as the weekend and transitions to a weekday.\n   * Call ucal_getWeekendTransition() to get the time of transition.\n   * @stable ICU 4.4 \n   */\n  UCAL_WEEKEND_CEASE\n};\n\n/** @stable ICU 4.4 */\ntypedef enum UCalendarWeekdayType UCalendarWeekdayType;\n\n/**\n * Returns whether the given day of the week is a weekday, a\n * weekend day, or a day that transitions from one to the other,\n * in this calendar system. If a transition occurs at midnight,\n * then the days before and after the transition will have the\n * type UCAL_WEEKDAY or UCAL_WEEKEND. If a transition occurs at a time\n * other than midnight, then the day of the transition will have\n * the type UCAL_WEEKEND_ONSET or UCAL_WEEKEND_CEASE. In this case, the\n * method getWeekendTransition() will return the point of\n * transition.\n * @param cal The UCalendar to query.\n * @param dayOfWeek The day of the week whose type is desired (UCAL_SUNDAY..UCAL_SATURDAY).\n * @param status The error code for the operation.\n * @return The UCalendarWeekdayType for the day of the week.\n * @stable ICU 4.4\n */\nU_STABLE UCalendarWeekdayType U_EXPORT2\nucal_getDayOfWeekType(const UCalendar *cal, UCalendarDaysOfWeek dayOfWeek, UErrorCode* status);\n\n/**\n * Returns the time during the day at which the weekend begins or ends in\n * this calendar system.  If ucal_getDayOfWeekType() rerturns UCAL_WEEKEND_ONSET\n * for the specified dayOfWeek, return the time at which the weekend begins.\n * If ucal_getDayOfWeekType() returns UCAL_WEEKEND_CEASE for the specified dayOfWeek,\n * return the time at which the weekend ends. If ucal_getDayOfWeekType() returns\n * some other UCalendarWeekdayType for the specified dayOfWeek, is it an error condition\n * (U_ILLEGAL_ARGUMENT_ERROR).\n * @param cal The UCalendar to query.\n * @param dayOfWeek The day of the week for which the weekend transition time is\n * desired (UCAL_SUNDAY..UCAL_SATURDAY).\n * @param status The error code for the operation.\n * @return The milliseconds after midnight at which the weekend begins or ends.\n * @stable ICU 4.4\n */\nU_STABLE int32_t U_EXPORT2\nucal_getWeekendTransition(const UCalendar *cal, UCalendarDaysOfWeek dayOfWeek, UErrorCode *status);\n\n/**\n * Returns TRUE if the given UDate is in the weekend in\n * this calendar system.\n * @param cal The UCalendar to query.\n * @param date The UDate in question.\n * @param status The error code for the operation.\n * @return TRUE if the given UDate is in the weekend in\n * this calendar system, FALSE otherwise.\n * @stable ICU 4.4\n */\nU_STABLE UBool U_EXPORT2\nucal_isWeekend(const UCalendar *cal, UDate date, UErrorCode *status);\n\n/**\n * Return the difference between the target time and the time this calendar object is currently set to.\n * If the target time is after the current calendar setting, the the returned value will be positive.\n * The field parameter specifies the units of the return value. For example, if field is UCAL_MONTH\n * and ucal_getFieldDifference returns 3, then the target time is 3 to less than 4 months after the\n * current calendar setting.\n *\n * As a side effect of this call, this calendar is advanced toward target by the given amount. That is,\n * calling this function has the side effect of calling ucal_add on this calendar with the specified\n * field and an amount equal to the return value from this function.\n *\n * A typical way of using this function is to call it first with the largest field of interest, then\n * with progressively smaller fields.\n * \n * @param cal The UCalendar to compare and update.\n * @param target The target date to compare to the current calendar setting.\n * @param field The field to compare; one of UCAL_ERA, UCAL_YEAR, UCAL_MONTH,\n * UCAL_WEEK_OF_YEAR, UCAL_WEEK_OF_MONTH, UCAL_DATE, UCAL_DAY_OF_YEAR, UCAL_DAY_OF_WEEK,\n * UCAL_DAY_OF_WEEK_IN_MONTH, UCAL_AM_PM, UCAL_HOUR, UCAL_HOUR_OF_DAY, UCAL_MINUTE, UCAL_SECOND,\n * UCAL_MILLISECOND, UCAL_ZONE_OFFSET, UCAL_DST_OFFSET.\n * @param status A pointer to an UErrorCode to receive any errors\n * @return The date difference for the specified field.\n * @stable ICU 4.8\n */\nU_STABLE int32_t U_EXPORT2 \nucal_getFieldDifference(UCalendar* cal,\n                        UDate target,\n                        UCalendarDateFields field,\n                        UErrorCode* status);\n\n#ifndef U_HIDE_DRAFT_API\n/**\n * Time zone transition types for ucal_getTimeZoneTransitionDate\n * @draft ICU 50\n */\nenum UTimeZoneTransitionType {\n    /**\n     * Get the next transition after the current date,\n     * i.e. excludes the current date\n     * @draft ICU 50\n     */\n    UCAL_TZ_TRANSITION_NEXT,\n    /**\n     * Get the next transition on or after the current date,\n     * i.e. may include the current date\n     * @draft ICU 50\n     */\n    UCAL_TZ_TRANSITION_NEXT_INCLUSIVE,\n    /**\n     * Get the previous transition before the current date,\n     * i.e. excludes the current date\n     * @draft ICU 50\n     */\n    UCAL_TZ_TRANSITION_PREVIOUS,\n    /**\n     * Get the previous transition on or before the current date,\n     * i.e. may include the current date\n     * @draft ICU 50\n     */\n    UCAL_TZ_TRANSITION_PREVIOUS_INCLUSIVE\n};\n\n/** @draft ICU 50 */\ntypedef enum UTimeZoneTransitionType UTimeZoneTransitionType;\n\n/**\n* Get the UDate for the next/previous time zone transition relative to\n* the calendar's current date, in the time zone to which the calendar\n* is currently set. If there is no known time zone transition of the\n* requested type relative to the calendar's date, the function returns\n* FALSE.\n* @param cal The UCalendar to query.\n* @param type The type of transition desired.\n* @param transition A pointer to a UDate to be set to the transition time.\n*         If the function returns FALSE, the value set is unspecified.\n* @param status A pointer to a UErrorCode to receive any errors.\n* @return TRUE if a valid transition time is set in *transition, FALSE\n*         otherwise.\n* @draft ICU 50\n*/\nU_DRAFT UBool U_EXPORT2 \nucal_getTimeZoneTransitionDate(const UCalendar* cal, UTimeZoneTransitionType type,\n                               UDate* transition, UErrorCode* status);\n\n#endif  /* U_HIDE_DRAFT_API */\n\n#endif /* #if !UCONFIG_NO_FORMATTING */\n\n#endif\n"
  },
  {
    "path": "deprecated/android/addons/icucompat/unicode/ucasemap.h",
    "content": "/*\n*******************************************************************************\n*\n*   Copyright (C) 2005-2012, International Business Machines\n*   Corporation and others.  All Rights Reserved.\n*\n*******************************************************************************\n*   file name:  ucasemap.h\n*   encoding:   US-ASCII\n*   tab size:   8 (not used)\n*   indentation:4\n*\n*   created on: 2005may06\n*   created by: Markus W. Scherer\n*\n*   Case mapping service object and functions using it.\n*/\n\n#ifndef __UCASEMAP_H__\n#define __UCASEMAP_H__\n\n#include \"unicode/utypes.h\"\n#include \"unicode/ustring.h\"\n#include \"unicode/localpointer.h\"\n\n/**\n * \\file\n * \\brief C API: Unicode case mapping functions using a UCaseMap service object.\n *\n * The service object takes care of memory allocations, data loading, and setup\n * for the attributes, as usual.\n *\n * Currently, the functionality provided here does not overlap with uchar.h\n * and ustring.h, except for ucasemap_toTitle().\n *\n * ucasemap_utf8XYZ() functions operate directly on UTF-8 strings.\n */\n\n/**\n * UCaseMap is an opaque service object for newer ICU case mapping functions.\n * Older functions did not use a service object.\n * @stable ICU 3.4\n */\nstruct UCaseMap;\ntypedef struct UCaseMap UCaseMap; /**< C typedef for struct UCaseMap. @stable ICU 3.4 */\n\n/**\n * Open a UCaseMap service object for a locale and a set of options.\n * The locale ID and options are preprocessed so that functions using the\n * service object need not process them in each call.\n *\n * @param locale ICU locale ID, used for language-dependent\n *               upper-/lower-/title-casing according to the Unicode standard.\n *               Usual semantics: \"\"=root, NULL=default locale, etc.\n * @param options Options bit set, used for case folding and string comparisons.\n *                Same flags as for u_foldCase(), u_strFoldCase(),\n *                u_strCaseCompare(), etc.\n *                Use 0 or U_FOLD_CASE_DEFAULT for default behavior.\n * @param pErrorCode Must be a valid pointer to an error code value,\n *                   which must not indicate a failure before the function call.\n * @return Pointer to a UCaseMap service object, if successful.\n *\n * @see U_FOLD_CASE_DEFAULT\n * @see U_FOLD_CASE_EXCLUDE_SPECIAL_I\n * @see U_TITLECASE_NO_LOWERCASE\n * @see U_TITLECASE_NO_BREAK_ADJUSTMENT\n * @stable ICU 3.4\n */\nU_STABLE UCaseMap * U_EXPORT2\nucasemap_open(const char *locale, uint32_t options, UErrorCode *pErrorCode);\n\n/**\n * Close a UCaseMap service object.\n * @param csm Object to be closed.\n * @stable ICU 3.4\n */\nU_STABLE void U_EXPORT2\nucasemap_close(UCaseMap *csm);\n\n#if U_SHOW_CPLUSPLUS_API\n\nU_NAMESPACE_BEGIN\n\n/**\n * \\class LocalUCaseMapPointer\n * \"Smart pointer\" class, closes a UCaseMap via ucasemap_close().\n * For most methods see the LocalPointerBase base class.\n *\n * @see LocalPointerBase\n * @see LocalPointer\n * @stable ICU 4.4\n */\nU_DEFINE_LOCAL_OPEN_POINTER(LocalUCaseMapPointer, UCaseMap, ucasemap_close);\n\nU_NAMESPACE_END\n\n#endif\n\n/**\n * Get the locale ID that is used for language-dependent case mappings.\n * @param csm UCaseMap service object.\n * @return locale ID\n * @stable ICU 3.4\n */\nU_STABLE const char * U_EXPORT2\nucasemap_getLocale(const UCaseMap *csm);\n\n/**\n * Get the options bit set that is used for case folding and string comparisons.\n * @param csm UCaseMap service object.\n * @return options bit set\n * @stable ICU 3.4\n */\nU_STABLE uint32_t U_EXPORT2\nucasemap_getOptions(const UCaseMap *csm);\n\n/**\n * Set the locale ID that is used for language-dependent case mappings.\n *\n * @param csm UCaseMap service object.\n * @param locale Locale ID, see ucasemap_open().\n * @param pErrorCode Must be a valid pointer to an error code value,\n *                   which must not indicate a failure before the function call.\n *\n * @see ucasemap_open\n * @stable ICU 3.4\n */\nU_STABLE void U_EXPORT2\nucasemap_setLocale(UCaseMap *csm, const char *locale, UErrorCode *pErrorCode);\n\n/**\n * Set the options bit set that is used for case folding and string comparisons.\n *\n * @param csm UCaseMap service object.\n * @param options Options bit set, see ucasemap_open().\n * @param pErrorCode Must be a valid pointer to an error code value,\n *                   which must not indicate a failure before the function call.\n *\n * @see ucasemap_open\n * @stable ICU 3.4\n */\nU_STABLE void U_EXPORT2\nucasemap_setOptions(UCaseMap *csm, uint32_t options, UErrorCode *pErrorCode);\n\n/**\n * Do not lowercase non-initial parts of words when titlecasing.\n * Option bit for titlecasing APIs that take an options bit set.\n *\n * By default, titlecasing will titlecase the first cased character\n * of a word and lowercase all other characters.\n * With this option, the other characters will not be modified.\n *\n * @see ucasemap_setOptions\n * @see ucasemap_toTitle\n * @see ucasemap_utf8ToTitle\n * @see UnicodeString::toTitle\n * @stable ICU 3.8\n */\n#define U_TITLECASE_NO_LOWERCASE 0x100\n\n/**\n * Do not adjust the titlecasing indexes from BreakIterator::next() indexes;\n * titlecase exactly the characters at breaks from the iterator.\n * Option bit for titlecasing APIs that take an options bit set.\n *\n * By default, titlecasing will take each break iterator index,\n * adjust it by looking for the next cased character, and titlecase that one.\n * Other characters are lowercased.\n *\n * This follows Unicode 4 & 5 section 3.13 Default Case Operations:\n *\n * R3  toTitlecase(X): Find the word boundaries based on Unicode Standard Annex\n * #29, \"Text Boundaries.\" Between each pair of word boundaries, find the first\n * cased character F. If F exists, map F to default_title(F); then map each\n * subsequent character C to default_lower(C).\n *\n * @see ucasemap_setOptions\n * @see ucasemap_toTitle\n * @see ucasemap_utf8ToTitle\n * @see UnicodeString::toTitle\n * @see U_TITLECASE_NO_LOWERCASE\n * @stable ICU 3.8\n */\n#define U_TITLECASE_NO_BREAK_ADJUSTMENT 0x200\n\n#if !UCONFIG_NO_BREAK_ITERATION\n\n/**\n * Get the break iterator that is used for titlecasing.\n * Do not modify the returned break iterator.\n * @param csm UCaseMap service object.\n * @return titlecasing break iterator\n * @stable ICU 3.8\n */\nU_STABLE const UBreakIterator * U_EXPORT2\nucasemap_getBreakIterator(const UCaseMap *csm);\n\n/**\n * Set the break iterator that is used for titlecasing.\n * The UCaseMap service object releases a previously set break iterator\n * and \"adopts\" this new one, taking ownership of it.\n * It will be released in a subsequent call to ucasemap_setBreakIterator()\n * or ucasemap_close().\n *\n * Break iterator operations are not thread-safe. Therefore, titlecasing\n * functions use non-const UCaseMap objects. It is not possible to titlecase\n * strings concurrently using the same UCaseMap.\n *\n * @param csm UCaseMap service object.\n * @param iterToAdopt Break iterator to be adopted for titlecasing.\n * @param pErrorCode Must be a valid pointer to an error code value,\n *                   which must not indicate a failure before the function call.\n *\n * @see ucasemap_toTitle\n * @see ucasemap_utf8ToTitle\n * @stable ICU 3.8\n */\nU_STABLE void U_EXPORT2\nucasemap_setBreakIterator(UCaseMap *csm, UBreakIterator *iterToAdopt, UErrorCode *pErrorCode);\n\n/**\n * Titlecase a UTF-16 string. This function is almost a duplicate of u_strToTitle(),\n * except that it takes ucasemap_setOptions() into account and has performance\n * advantages from being able to use a UCaseMap object for multiple case mapping\n * operations, saving setup time.\n *\n * Casing is locale-dependent and context-sensitive.\n * Titlecasing uses a break iterator to find the first characters of words\n * that are to be titlecased. It titlecases those characters and lowercases\n * all others. (This can be modified with ucasemap_setOptions().)\n *\n * Note: This function takes a non-const UCaseMap pointer because it will\n * open a default break iterator if no break iterator was set yet,\n * and effectively call ucasemap_setBreakIterator();\n * also because the break iterator is stateful and will be modified during\n * the iteration.\n *\n * The titlecase break iterator can be provided to customize for arbitrary\n * styles, using rules and dictionaries beyond the standard iterators.\n * The standard titlecase iterator for the root locale implements the\n * algorithm of Unicode TR 21.\n *\n * This function uses only the setUText(), first(), next() and close() methods of the\n * provided break iterator.\n *\n * The result may be longer or shorter than the original.\n * The source string and the destination buffer must not overlap.\n *\n * @param csm       UCaseMap service object. This pointer is non-const!\n *                  See the note above for details.\n * @param dest      A buffer for the result string. The result will be NUL-terminated if\n *                  the buffer is large enough.\n *                  The contents is undefined in case of failure.\n * @param destCapacity The size of the buffer (number of bytes). If it is 0, then\n *                  dest may be NULL and the function will only return the length of the result\n *                  without writing any of the result string.\n * @param src       The original string.\n * @param srcLength The length of the original string. If -1, then src must be NUL-terminated.\n * @param pErrorCode Must be a valid pointer to an error code value,\n *                  which must not indicate a failure before the function call.\n * @return The length of the result string, if successful - or in case of a buffer overflow,\n *         in which case it will be greater than destCapacity.\n *\n * @see u_strToTitle\n * @stable ICU 3.8\n */\nU_STABLE int32_t U_EXPORT2\nucasemap_toTitle(UCaseMap *csm,\n                 UChar *dest, int32_t destCapacity,\n                 const UChar *src, int32_t srcLength,\n                 UErrorCode *pErrorCode);\n\n#endif\n\n/**\n * Lowercase the characters in a UTF-8 string.\n * Casing is locale-dependent and context-sensitive.\n * The result may be longer or shorter than the original.\n * The source string and the destination buffer must not overlap.\n *\n * @param csm       UCaseMap service object.\n * @param dest      A buffer for the result string. The result will be NUL-terminated if\n *                  the buffer is large enough.\n *                  The contents is undefined in case of failure.\n * @param destCapacity The size of the buffer (number of bytes). If it is 0, then\n *                  dest may be NULL and the function will only return the length of the result\n *                  without writing any of the result string.\n * @param src       The original string.\n * @param srcLength The length of the original string. If -1, then src must be NUL-terminated.\n * @param pErrorCode Must be a valid pointer to an error code value,\n *                  which must not indicate a failure before the function call.\n * @return The length of the result string, if successful - or in case of a buffer overflow,\n *         in which case it will be greater than destCapacity.\n *\n * @see u_strToLower\n * @stable ICU 3.4\n */\nU_STABLE int32_t U_EXPORT2\nucasemap_utf8ToLower(const UCaseMap *csm,\n                     char *dest, int32_t destCapacity,\n                     const char *src, int32_t srcLength,\n                     UErrorCode *pErrorCode);\n\n/**\n * Uppercase the characters in a UTF-8 string.\n * Casing is locale-dependent and context-sensitive.\n * The result may be longer or shorter than the original.\n * The source string and the destination buffer must not overlap.\n *\n * @param csm       UCaseMap service object.\n * @param dest      A buffer for the result string. The result will be NUL-terminated if\n *                  the buffer is large enough.\n *                  The contents is undefined in case of failure.\n * @param destCapacity The size of the buffer (number of bytes). If it is 0, then\n *                  dest may be NULL and the function will only return the length of the result\n *                  without writing any of the result string.\n * @param src       The original string.\n * @param srcLength The length of the original string. If -1, then src must be NUL-terminated.\n * @param pErrorCode Must be a valid pointer to an error code value,\n *                  which must not indicate a failure before the function call.\n * @return The length of the result string, if successful - or in case of a buffer overflow,\n *         in which case it will be greater than destCapacity.\n *\n * @see u_strToUpper\n * @stable ICU 3.4\n */\nU_STABLE int32_t U_EXPORT2\nucasemap_utf8ToUpper(const UCaseMap *csm,\n                     char *dest, int32_t destCapacity,\n                     const char *src, int32_t srcLength,\n                     UErrorCode *pErrorCode);\n\n#if !UCONFIG_NO_BREAK_ITERATION\n\n/**\n * Titlecase a UTF-8 string.\n * Casing is locale-dependent and context-sensitive.\n * Titlecasing uses a break iterator to find the first characters of words\n * that are to be titlecased. It titlecases those characters and lowercases\n * all others. (This can be modified with ucasemap_setOptions().)\n *\n * Note: This function takes a non-const UCaseMap pointer because it will\n * open a default break iterator if no break iterator was set yet,\n * and effectively call ucasemap_setBreakIterator();\n * also because the break iterator is stateful and will be modified during\n * the iteration.\n *\n * The titlecase break iterator can be provided to customize for arbitrary\n * styles, using rules and dictionaries beyond the standard iterators.\n * The standard titlecase iterator for the root locale implements the\n * algorithm of Unicode TR 21.\n *\n * This function uses only the setUText(), first(), next() and close() methods of the\n * provided break iterator.\n *\n * The result may be longer or shorter than the original.\n * The source string and the destination buffer must not overlap.\n *\n * @param csm       UCaseMap service object. This pointer is non-const!\n *                  See the note above for details.\n * @param dest      A buffer for the result string. The result will be NUL-terminated if\n *                  the buffer is large enough.\n *                  The contents is undefined in case of failure.\n * @param destCapacity The size of the buffer (number of bytes). If it is 0, then\n *                  dest may be NULL and the function will only return the length of the result\n *                  without writing any of the result string.\n * @param src       The original string.\n * @param srcLength The length of the original string. If -1, then src must be NUL-terminated.\n * @param pErrorCode Must be a valid pointer to an error code value,\n *                  which must not indicate a failure before the function call.\n * @return The length of the result string, if successful - or in case of a buffer overflow,\n *         in which case it will be greater than destCapacity.\n *\n * @see u_strToTitle\n * @see U_TITLECASE_NO_LOWERCASE\n * @see U_TITLECASE_NO_BREAK_ADJUSTMENT\n * @stable ICU 3.8\n */\nU_STABLE int32_t U_EXPORT2\nucasemap_utf8ToTitle(UCaseMap *csm,\n                    char *dest, int32_t destCapacity,\n                    const char *src, int32_t srcLength,\n                    UErrorCode *pErrorCode);\n\n#endif\n\n/**\n * Case-folds the characters in a UTF-8 string.\n *\n * Case-folding is locale-independent and not context-sensitive,\n * but there is an option for whether to include or exclude mappings for dotted I\n * and dotless i that are marked with 'T' in CaseFolding.txt.\n *\n * The result may be longer or shorter than the original.\n * The source string and the destination buffer must not overlap.\n *\n * @param csm       UCaseMap service object.\n * @param dest      A buffer for the result string. The result will be NUL-terminated if\n *                  the buffer is large enough.\n *                  The contents is undefined in case of failure.\n * @param destCapacity The size of the buffer (number of bytes). If it is 0, then\n *                  dest may be NULL and the function will only return the length of the result\n *                  without writing any of the result string.\n * @param src       The original string.\n * @param srcLength The length of the original string. If -1, then src must be NUL-terminated.\n * @param pErrorCode Must be a valid pointer to an error code value,\n *                  which must not indicate a failure before the function call.\n * @return The length of the result string, if successful - or in case of a buffer overflow,\n *         in which case it will be greater than destCapacity.\n *\n * @see u_strFoldCase\n * @see ucasemap_setOptions\n * @see U_FOLD_CASE_DEFAULT\n * @see U_FOLD_CASE_EXCLUDE_SPECIAL_I\n * @stable ICU 3.8\n */\nU_STABLE int32_t U_EXPORT2\nucasemap_utf8FoldCase(const UCaseMap *csm,\n                      char *dest, int32_t destCapacity,\n                      const char *src, int32_t srcLength,\n                      UErrorCode *pErrorCode);\n\n#endif\n"
  },
  {
    "path": "deprecated/android/addons/icucompat/unicode/ucat.h",
    "content": "/*\n**********************************************************************\n* Copyright (c) 2003-2004, International Business Machines\n* Corporation and others.  All Rights Reserved.\n**********************************************************************\n* Author: Alan Liu\n* Created: March 19 2003\n* Since: ICU 2.6\n**********************************************************************\n*/\n#ifndef UCAT_H\n#define UCAT_H\n\n#include \"unicode/utypes.h\"\n#include \"unicode/ures.h\"\n\n/**\n * \\file\n * \\brief C API: Message Catalog Wrappers\n *\n * This C API provides look-alike functions that deliberately resemble\n * the POSIX catopen, catclose, and catgets functions.  The underlying\n * implementation is in terms of ICU resource bundles, rather than\n * POSIX message catalogs.\n *\n * The ICU resource bundles obey standard ICU inheritance policies.\n * To facilitate this, sets and messages are flattened into one tier.\n * This is done by creating resource bundle keys of the form\n * &lt;set_num&gt;%&lt;msg_num&gt; where set_num is the set number and msg_num is\n * the message number, formatted as decimal strings.\n *\n * Example:  Consider a message catalog containing two sets:\n *\n * Set 1: Message 4  = \"Good morning.\"\n *        Message 5  = \"Good afternoon.\"\n *        Message 7  = \"Good evening.\"\n *        Message 8  = \"Good night.\"\n * Set 4: Message 14 = \"Please \"\n *        Message 19 = \"Thank you.\"\n *        Message 20 = \"Sincerely,\"\n *\n * The ICU resource bundle source file would, assuming it is named\n * \"greet.txt\", would look like this:\n *\n * greet\n * {\n *     1%4  { \"Good morning.\" }\n *     1%5  { \"Good afternoon.\" }\n *     1%7  { \"Good evening.\" }\n *     1%8  { \"Good night.\" }\n * \n *     4%14 { \"Please \" }\n *     4%19 { \"Thank you.\" }\n *     4%20 { \"Sincerely,\" }\n * }\n *\n * The catgets function is commonly used in combination with functions\n * like printf and strftime.  ICU components like message format can\n * be used instead, although they use a different format syntax.\n * There is an ICU package, icuio, that provides some of\n * the POSIX-style formatting API.\n */\n\nU_CDECL_BEGIN\n\n/**\n * An ICU message catalog descriptor, analogous to nl_catd.\n * \n * @stable ICU 2.6\n */\ntypedef UResourceBundle* u_nl_catd;\n\n/**\n * Open and return an ICU message catalog descriptor. The descriptor\n * may be passed to u_catgets() to retrieve localized strings.\n *\n * @param name string containing the full path pointing to the\n * directory where the resources reside followed by the package name\n * e.g. \"/usr/resource/my_app/resources/guimessages\" on a Unix system.\n * If NULL, ICU default data files will be used.\n *\n * Unlike POSIX, environment variables are not interpolated within the\n * name.\n *\n * @param locale the locale for which we want to open the resource. If\n * NULL, the default ICU locale will be used (see uloc_getDefault). If\n * strlen(locale) == 0, the root locale will be used.\n *\n * @param ec input/output error code. Upon output,\n * U_USING_FALLBACK_WARNING indicates that a fallback locale was\n * used. For example, 'de_CH' was requested, but nothing was found\n * there, so 'de' was used. U_USING_DEFAULT_WARNING indicates that the\n * default locale data or root locale data was used; neither the\n * requested locale nor any of its fallback locales were found.\n *\n * @return a message catalog descriptor that may be passed to\n * u_catgets(). If the ec parameter indicates success, then the caller\n * is responsible for calling u_catclose() to close the message\n * catalog. If the ec parameter indicates failure, then NULL will be\n * returned.\n * \n * @stable ICU 2.6\n */\nU_STABLE u_nl_catd U_EXPORT2\nu_catopen(const char* name, const char* locale, UErrorCode* ec);\n\n/**\n * Close an ICU message catalog, given its descriptor.\n *\n * @param catd a message catalog descriptor to be closed. May be NULL,\n * in which case no action is taken.\n * \n * @stable ICU 2.6\n */\nU_STABLE void U_EXPORT2\nu_catclose(u_nl_catd catd);\n\n/**\n * Retrieve a localized string from an ICU message catalog.\n *\n * @param catd a message catalog descriptor returned by u_catopen.\n *\n * @param set_num the message catalog set number. Sets need not be\n * numbered consecutively.\n *\n * @param msg_num the message catalog message number within the\n * set. Messages need not be numbered consecutively.\n *\n * @param s the default string. This is returned if the string\n * specified by the set_num and msg_num is not found. It must be\n * zero-terminated.\n *\n * @param len fill-in parameter to receive the length of the result.\n * May be NULL, in which case it is ignored.\n *\n * @param ec input/output error code. May be U_USING_FALLBACK_WARNING\n * or U_USING_DEFAULT_WARNING. U_MISSING_RESOURCE_ERROR indicates that\n * the set_num/msg_num tuple does not specify a valid message string\n * in this catalog.\n *\n * @return a pointer to a zero-terminated UChar array which lives in\n * an internal buffer area, typically a memory mapped/DLL file. The\n * caller must NOT delete this pointer. If the call is unsuccessful\n * for any reason, then s is returned.  This includes the situation in\n * which ec indicates a failing error code upon entry to this\n * function.\n * \n * @stable ICU 2.6\n */\nU_STABLE const UChar* U_EXPORT2\nu_catgets(u_nl_catd catd, int32_t set_num, int32_t msg_num,\n          const UChar* s,\n          int32_t* len, UErrorCode* ec);\n\nU_CDECL_END\n\n#endif /*UCAT_H*/\n/*eof*/\n"
  },
  {
    "path": "deprecated/android/addons/icucompat/unicode/uchar.h",
    "content": "/*\n**********************************************************************\n*   Copyright (C) 1997-2012, International Business Machines\n*   Corporation and others.  All Rights Reserved.\n**********************************************************************\n*\n* File UCHAR.H\n*\n* Modification History:\n*\n*   Date        Name        Description\n*   04/02/97    aliu        Creation.\n*   03/29/99    helena      Updated for C APIs.\n*   4/15/99     Madhu       Updated for C Implementation and Javadoc\n*   5/20/99     Madhu       Added the function u_getVersion()\n*   8/19/1999   srl         Upgraded scripts to Unicode 3.0\n*   8/27/1999   schererm    UCharDirection constants: U_...\n*   11/11/1999  weiv        added u_isalnum(), cleaned comments\n*   01/11/2000  helena      Renamed u_getVersion to u_getUnicodeVersion().\n******************************************************************************\n*/\n\n#ifndef UCHAR_H\n#define UCHAR_H\n\n#include \"unicode/utypes.h\"\n\nU_CDECL_BEGIN\n\n/*==========================================================================*/\n/* Unicode version number                                                   */\n/*==========================================================================*/\n/**\n * Unicode version number, default for the current ICU version.\n * The actual Unicode Character Database (UCD) data is stored in uprops.dat\n * and may be generated from UCD files from a different Unicode version.\n * Call u_getUnicodeVersion to get the actual Unicode version of the data.\n *\n * @see u_getUnicodeVersion\n * @stable ICU 2.0\n */\n#define U_UNICODE_VERSION \"6.2\"\n\n/**\n * \\file\n * \\brief C API: Unicode Properties\n *\n * This C API provides low-level access to the Unicode Character Database.\n * In addition to raw property values, some convenience functions calculate\n * derived properties, for example for Java-style programming.\n *\n * Unicode assigns each code point (not just assigned character) values for\n * many properties.\n * Most of them are simple boolean flags, or constants from a small enumerated list.\n * For some properties, values are strings or other relatively more complex types.\n *\n * For more information see\n * \"About the Unicode Character Database\" (http://www.unicode.org/ucd/)\n * and the ICU User Guide chapter on Properties (http://icu-project.org/userguide/properties.html).\n *\n * Many functions are designed to match java.lang.Character functions.\n * See the individual function documentation,\n * and see the JDK 1.4 java.lang.Character documentation\n * at http://java.sun.com/j2se/1.4/docs/api/java/lang/Character.html\n *\n * There are also functions that provide easy migration from C/POSIX functions\n * like isblank(). Their use is generally discouraged because the C/POSIX\n * standards do not define their semantics beyond the ASCII range, which means\n * that different implementations exhibit very different behavior.\n * Instead, Unicode properties should be used directly.\n *\n * There are also only a few, broad C/POSIX character classes, and they tend\n * to be used for conflicting purposes. For example, the \"isalpha()\" class\n * is sometimes used to determine word boundaries, while a more sophisticated\n * approach would at least distinguish initial letters from continuation\n * characters (the latter including combining marks).\n * (In ICU, BreakIterator is the most sophisticated API for word boundaries.)\n * Another example: There is no \"istitle()\" class for titlecase characters.\n *\n * ICU 3.4 and later provides API access for all twelve C/POSIX character classes.\n * ICU implements them according to the Standard Recommendations in\n * Annex C: Compatibility Properties of UTS #18 Unicode Regular Expressions\n * (http://www.unicode.org/reports/tr18/#Compatibility_Properties).\n *\n * API access for C/POSIX character classes is as follows:\n * - alpha:     u_isUAlphabetic(c) or u_hasBinaryProperty(c, UCHAR_ALPHABETIC)\n * - lower:     u_isULowercase(c) or u_hasBinaryProperty(c, UCHAR_LOWERCASE)\n * - upper:     u_isUUppercase(c) or u_hasBinaryProperty(c, UCHAR_UPPERCASE)\n * - punct:     u_ispunct(c)\n * - digit:     u_isdigit(c) or u_charType(c)==U_DECIMAL_DIGIT_NUMBER\n * - xdigit:    u_isxdigit(c) or u_hasBinaryProperty(c, UCHAR_POSIX_XDIGIT)\n * - alnum:     u_hasBinaryProperty(c, UCHAR_POSIX_ALNUM)\n * - space:     u_isUWhiteSpace(c) or u_hasBinaryProperty(c, UCHAR_WHITE_SPACE)\n * - blank:     u_isblank(c) or u_hasBinaryProperty(c, UCHAR_POSIX_BLANK)\n * - cntrl:     u_charType(c)==U_CONTROL_CHAR\n * - graph:     u_hasBinaryProperty(c, UCHAR_POSIX_GRAPH)\n * - print:     u_hasBinaryProperty(c, UCHAR_POSIX_PRINT)\n *\n * Note: Some of the u_isxyz() functions in uchar.h predate, and do not match,\n * the Standard Recommendations in UTS #18. Instead, they match Java\n * functions according to their API documentation.\n *\n * \\htmlonly\n * The C/POSIX character classes are also available in UnicodeSet patterns,\n * using patterns like [:graph:] or \\p{graph}.\n * \\endhtmlonly\n *\n * Note: There are several ICU whitespace functions.\n * Comparison:\n * - u_isUWhiteSpace=UCHAR_WHITE_SPACE: Unicode White_Space property;\n *       most of general categories \"Z\" (separators) + most whitespace ISO controls\n *       (including no-break spaces, but excluding IS1..IS4 and ZWSP)\n * - u_isWhitespace: Java isWhitespace; Z + whitespace ISO controls but excluding no-break spaces\n * - u_isJavaSpaceChar: Java isSpaceChar; just Z (including no-break spaces)\n * - u_isspace: Z + whitespace ISO controls (including no-break spaces)\n * - u_isblank: \"horizontal spaces\" = TAB + Zs - ZWSP\n */\n\n/**\n * Constants.\n */\n\n/** The lowest Unicode code point value. Code points are non-negative. @stable ICU 2.0 */\n#define UCHAR_MIN_VALUE 0\n\n/**\n * The highest Unicode code point value (scalar value) according to\n * The Unicode Standard. This is a 21-bit value (20.1 bits, rounded up).\n * For a single character, UChar32 is a simple type that can hold any code point value.\n *\n * @see UChar32\n * @stable ICU 2.0\n */\n#define UCHAR_MAX_VALUE 0x10ffff\n\n/**\n * Get a single-bit bit set (a flag) from a bit number 0..31.\n * @stable ICU 2.1\n */\n#define U_MASK(x) ((uint32_t)1<<(x))\n\n/**\n * Selection constants for Unicode properties.\n * These constants are used in functions like u_hasBinaryProperty to select\n * one of the Unicode properties.\n *\n * The properties APIs are intended to reflect Unicode properties as defined\n * in the Unicode Character Database (UCD) and Unicode Technical Reports (UTR).\n * For details about the properties see http://www.unicode.org/ucd/ .\n * For names of Unicode properties see the UCD file PropertyAliases.txt.\n *\n * Important: If ICU is built with UCD files from Unicode versions below, e.g., 3.2,\n * then properties marked with \"new in Unicode 3.2\" are not or not fully available.\n * Check u_getUnicodeVersion to be sure.\n *\n * @see u_hasBinaryProperty\n * @see u_getIntPropertyValue\n * @see u_getUnicodeVersion\n * @stable ICU 2.1\n */\ntypedef enum UProperty {\n    /*\n     * Note: UProperty constants are parsed by preparseucd.py.\n     * It matches lines like\n     *     UCHAR_<Unicode property name>=<integer>,\n     */\n\n    /*  Note: Place UCHAR_ALPHABETIC before UCHAR_BINARY_START so that\n    debuggers display UCHAR_ALPHABETIC as the symbolic name for 0,\n    rather than UCHAR_BINARY_START.  Likewise for other *_START\n    identifiers. */\n\n    /** Binary property Alphabetic. Same as u_isUAlphabetic, different from u_isalpha.\n        Lu+Ll+Lt+Lm+Lo+Nl+Other_Alphabetic @stable ICU 2.1 */\n    UCHAR_ALPHABETIC=0,\n    /** First constant for binary Unicode properties. @stable ICU 2.1 */\n    UCHAR_BINARY_START=UCHAR_ALPHABETIC,\n    /** Binary property ASCII_Hex_Digit. 0-9 A-F a-f @stable ICU 2.1 */\n    UCHAR_ASCII_HEX_DIGIT=1,\n    /** Binary property Bidi_Control.\n        Format controls which have specific functions\n        in the Bidi Algorithm. @stable ICU 2.1 */\n    UCHAR_BIDI_CONTROL=2,\n    /** Binary property Bidi_Mirrored.\n        Characters that may change display in RTL text.\n        Same as u_isMirrored.\n        See Bidi Algorithm, UTR 9. @stable ICU 2.1 */\n    UCHAR_BIDI_MIRRORED=3,\n    /** Binary property Dash. Variations of dashes. @stable ICU 2.1 */\n    UCHAR_DASH=4,\n    /** Binary property Default_Ignorable_Code_Point (new in Unicode 3.2).\n        Ignorable in most processing.\n        <2060..206F, FFF0..FFFB, E0000..E0FFF>+Other_Default_Ignorable_Code_Point+(Cf+Cc+Cs-White_Space) @stable ICU 2.1 */\n    UCHAR_DEFAULT_IGNORABLE_CODE_POINT=5,\n    /** Binary property Deprecated (new in Unicode 3.2).\n        The usage of deprecated characters is strongly discouraged. @stable ICU 2.1 */\n    UCHAR_DEPRECATED=6,\n    /** Binary property Diacritic. Characters that linguistically modify\n        the meaning of another character to which they apply. @stable ICU 2.1 */\n    UCHAR_DIACRITIC=7,\n    /** Binary property Extender.\n        Extend the value or shape of a preceding alphabetic character,\n        e.g., length and iteration marks. @stable ICU 2.1 */\n    UCHAR_EXTENDER=8,\n    /** Binary property Full_Composition_Exclusion.\n        CompositionExclusions.txt+Singleton Decompositions+\n        Non-Starter Decompositions. @stable ICU 2.1 */\n    UCHAR_FULL_COMPOSITION_EXCLUSION=9,\n    /** Binary property Grapheme_Base (new in Unicode 3.2).\n        For programmatic determination of grapheme cluster boundaries.\n        [0..10FFFF]-Cc-Cf-Cs-Co-Cn-Zl-Zp-Grapheme_Link-Grapheme_Extend-CGJ @stable ICU 2.1 */\n    UCHAR_GRAPHEME_BASE=10,\n    /** Binary property Grapheme_Extend (new in Unicode 3.2).\n        For programmatic determination of grapheme cluster boundaries.\n        Me+Mn+Mc+Other_Grapheme_Extend-Grapheme_Link-CGJ @stable ICU 2.1 */\n    UCHAR_GRAPHEME_EXTEND=11,\n    /** Binary property Grapheme_Link (new in Unicode 3.2).\n        For programmatic determination of grapheme cluster boundaries. @stable ICU 2.1 */\n    UCHAR_GRAPHEME_LINK=12,\n    /** Binary property Hex_Digit.\n        Characters commonly used for hexadecimal numbers. @stable ICU 2.1 */\n    UCHAR_HEX_DIGIT=13,\n    /** Binary property Hyphen. Dashes used to mark connections\n        between pieces of words, plus the Katakana middle dot. @stable ICU 2.1 */\n    UCHAR_HYPHEN=14,\n    /** Binary property ID_Continue.\n        Characters that can continue an identifier.\n        DerivedCoreProperties.txt also says \"NOTE: Cf characters should be filtered out.\"\n        ID_Start+Mn+Mc+Nd+Pc @stable ICU 2.1 */\n    UCHAR_ID_CONTINUE=15,\n    /** Binary property ID_Start.\n        Characters that can start an identifier.\n        Lu+Ll+Lt+Lm+Lo+Nl @stable ICU 2.1 */\n    UCHAR_ID_START=16,\n    /** Binary property Ideographic.\n        CJKV ideographs. @stable ICU 2.1 */\n    UCHAR_IDEOGRAPHIC=17,\n    /** Binary property IDS_Binary_Operator (new in Unicode 3.2).\n        For programmatic determination of\n        Ideographic Description Sequences. @stable ICU 2.1 */\n    UCHAR_IDS_BINARY_OPERATOR=18,\n    /** Binary property IDS_Trinary_Operator (new in Unicode 3.2).\n        For programmatic determination of\n        Ideographic Description Sequences. @stable ICU 2.1 */\n    UCHAR_IDS_TRINARY_OPERATOR=19,\n    /** Binary property Join_Control.\n        Format controls for cursive joining and ligation. @stable ICU 2.1 */\n    UCHAR_JOIN_CONTROL=20,\n    /** Binary property Logical_Order_Exception (new in Unicode 3.2).\n        Characters that do not use logical order and\n        require special handling in most processing. @stable ICU 2.1 */\n    UCHAR_LOGICAL_ORDER_EXCEPTION=21,\n    /** Binary property Lowercase. Same as u_isULowercase, different from u_islower.\n        Ll+Other_Lowercase @stable ICU 2.1 */\n    UCHAR_LOWERCASE=22,\n    /** Binary property Math. Sm+Other_Math @stable ICU 2.1 */\n    UCHAR_MATH=23,\n    /** Binary property Noncharacter_Code_Point.\n        Code points that are explicitly defined as illegal\n        for the encoding of characters. @stable ICU 2.1 */\n    UCHAR_NONCHARACTER_CODE_POINT=24,\n    /** Binary property Quotation_Mark. @stable ICU 2.1 */\n    UCHAR_QUOTATION_MARK=25,\n    /** Binary property Radical (new in Unicode 3.2).\n        For programmatic determination of\n        Ideographic Description Sequences. @stable ICU 2.1 */\n    UCHAR_RADICAL=26,\n    /** Binary property Soft_Dotted (new in Unicode 3.2).\n        Characters with a \"soft dot\", like i or j.\n        An accent placed on these characters causes\n        the dot to disappear. @stable ICU 2.1 */\n    UCHAR_SOFT_DOTTED=27,\n    /** Binary property Terminal_Punctuation.\n        Punctuation characters that generally mark\n        the end of textual units. @stable ICU 2.1 */\n    UCHAR_TERMINAL_PUNCTUATION=28,\n    /** Binary property Unified_Ideograph (new in Unicode 3.2).\n        For programmatic determination of\n        Ideographic Description Sequences. @stable ICU 2.1 */\n    UCHAR_UNIFIED_IDEOGRAPH=29,\n    /** Binary property Uppercase. Same as u_isUUppercase, different from u_isupper.\n        Lu+Other_Uppercase @stable ICU 2.1 */\n    UCHAR_UPPERCASE=30,\n    /** Binary property White_Space.\n        Same as u_isUWhiteSpace, different from u_isspace and u_isWhitespace.\n        Space characters+TAB+CR+LF-ZWSP-ZWNBSP @stable ICU 2.1 */\n    UCHAR_WHITE_SPACE=31,\n    /** Binary property XID_Continue.\n        ID_Continue modified to allow closure under\n        normalization forms NFKC and NFKD. @stable ICU 2.1 */\n    UCHAR_XID_CONTINUE=32,\n    /** Binary property XID_Start. ID_Start modified to allow\n        closure under normalization forms NFKC and NFKD. @stable ICU 2.1 */\n    UCHAR_XID_START=33,\n    /** Binary property Case_Sensitive. Either the source of a case\n        mapping or _in_ the target of a case mapping. Not the same as\n        the general category Cased_Letter. @stable ICU 2.6 */\n   UCHAR_CASE_SENSITIVE=34,\n    /** Binary property STerm (new in Unicode 4.0.1).\n        Sentence Terminal. Used in UAX #29: Text Boundaries\n        (http://www.unicode.org/reports/tr29/)\n        @stable ICU 3.0 */\n    UCHAR_S_TERM=35,\n    /** Binary property Variation_Selector (new in Unicode 4.0.1).\n        Indicates all those characters that qualify as Variation Selectors.\n        For details on the behavior of these characters,\n        see StandardizedVariants.html and 15.6 Variation Selectors.\n        @stable ICU 3.0 */\n    UCHAR_VARIATION_SELECTOR=36,\n    /** Binary property NFD_Inert.\n        ICU-specific property for characters that are inert under NFD,\n        i.e., they do not interact with adjacent characters.\n        See the documentation for the Normalizer2 class and the\n        Normalizer2::isInert() method.\n        @stable ICU 3.0 */\n    UCHAR_NFD_INERT=37,\n    /** Binary property NFKD_Inert.\n        ICU-specific property for characters that are inert under NFKD,\n        i.e., they do not interact with adjacent characters.\n        See the documentation for the Normalizer2 class and the\n        Normalizer2::isInert() method.\n        @stable ICU 3.0 */\n    UCHAR_NFKD_INERT=38,\n    /** Binary property NFC_Inert.\n        ICU-specific property for characters that are inert under NFC,\n        i.e., they do not interact with adjacent characters.\n        See the documentation for the Normalizer2 class and the\n        Normalizer2::isInert() method.\n        @stable ICU 3.0 */\n    UCHAR_NFC_INERT=39,\n    /** Binary property NFKC_Inert.\n        ICU-specific property for characters that are inert under NFKC,\n        i.e., they do not interact with adjacent characters.\n        See the documentation for the Normalizer2 class and the\n        Normalizer2::isInert() method.\n        @stable ICU 3.0 */\n    UCHAR_NFKC_INERT=40,\n    /** Binary Property Segment_Starter.\n        ICU-specific property for characters that are starters in terms of\n        Unicode normalization and combining character sequences.\n        They have ccc=0 and do not occur in non-initial position of the\n        canonical decomposition of any character\n        (like a-umlaut in NFD and a Jamo T in an NFD(Hangul LVT)).\n        ICU uses this property for segmenting a string for generating a set of\n        canonically equivalent strings, e.g. for canonical closure while\n        processing collation tailoring rules.\n        @stable ICU 3.0 */\n    UCHAR_SEGMENT_STARTER=41,\n    /** Binary property Pattern_Syntax (new in Unicode 4.1).\n        See UAX #31 Identifier and Pattern Syntax\n        (http://www.unicode.org/reports/tr31/)\n        @stable ICU 3.4 */\n    UCHAR_PATTERN_SYNTAX=42,\n    /** Binary property Pattern_White_Space (new in Unicode 4.1).\n        See UAX #31 Identifier and Pattern Syntax\n        (http://www.unicode.org/reports/tr31/)\n        @stable ICU 3.4 */\n    UCHAR_PATTERN_WHITE_SPACE=43,\n    /** Binary property alnum (a C/POSIX character class).\n        Implemented according to the UTS #18 Annex C Standard Recommendation.\n        See the uchar.h file documentation.\n        @stable ICU 3.4 */\n    UCHAR_POSIX_ALNUM=44,\n    /** Binary property blank (a C/POSIX character class).\n        Implemented according to the UTS #18 Annex C Standard Recommendation.\n        See the uchar.h file documentation.\n        @stable ICU 3.4 */\n    UCHAR_POSIX_BLANK=45,\n    /** Binary property graph (a C/POSIX character class).\n        Implemented according to the UTS #18 Annex C Standard Recommendation.\n        See the uchar.h file documentation.\n        @stable ICU 3.4 */\n    UCHAR_POSIX_GRAPH=46,\n    /** Binary property print (a C/POSIX character class).\n        Implemented according to the UTS #18 Annex C Standard Recommendation.\n        See the uchar.h file documentation.\n        @stable ICU 3.4 */\n    UCHAR_POSIX_PRINT=47,\n    /** Binary property xdigit (a C/POSIX character class).\n        Implemented according to the UTS #18 Annex C Standard Recommendation.\n        See the uchar.h file documentation.\n        @stable ICU 3.4 */\n    UCHAR_POSIX_XDIGIT=48,\n    /** Binary property Cased. For Lowercase, Uppercase and Titlecase characters. @stable ICU 4.4 */\n    UCHAR_CASED=49,\n    /** Binary property Case_Ignorable. Used in context-sensitive case mappings. @stable ICU 4.4 */\n    UCHAR_CASE_IGNORABLE=50,\n    /** Binary property Changes_When_Lowercased. @stable ICU 4.4 */\n    UCHAR_CHANGES_WHEN_LOWERCASED=51,\n    /** Binary property Changes_When_Uppercased. @stable ICU 4.4 */\n    UCHAR_CHANGES_WHEN_UPPERCASED=52,\n    /** Binary property Changes_When_Titlecased. @stable ICU 4.4 */\n    UCHAR_CHANGES_WHEN_TITLECASED=53,\n    /** Binary property Changes_When_Casefolded. @stable ICU 4.4 */\n    UCHAR_CHANGES_WHEN_CASEFOLDED=54,\n    /** Binary property Changes_When_Casemapped. @stable ICU 4.4 */\n    UCHAR_CHANGES_WHEN_CASEMAPPED=55,\n    /** Binary property Changes_When_NFKC_Casefolded. @stable ICU 4.4 */\n    UCHAR_CHANGES_WHEN_NFKC_CASEFOLDED=56,\n    /** One more than the last constant for binary Unicode properties. @stable ICU 2.1 */\n    UCHAR_BINARY_LIMIT=57,\n\n    /** Enumerated property Bidi_Class.\n        Same as u_charDirection, returns UCharDirection values. @stable ICU 2.2 */\n    UCHAR_BIDI_CLASS=0x1000,\n    /** First constant for enumerated/integer Unicode properties. @stable ICU 2.2 */\n    UCHAR_INT_START=UCHAR_BIDI_CLASS,\n    /** Enumerated property Block.\n        Same as ublock_getCode, returns UBlockCode values. @stable ICU 2.2 */\n    UCHAR_BLOCK=0x1001,\n    /** Enumerated property Canonical_Combining_Class.\n        Same as u_getCombiningClass, returns 8-bit numeric values. @stable ICU 2.2 */\n    UCHAR_CANONICAL_COMBINING_CLASS=0x1002,\n    /** Enumerated property Decomposition_Type.\n        Returns UDecompositionType values. @stable ICU 2.2 */\n    UCHAR_DECOMPOSITION_TYPE=0x1003,\n    /** Enumerated property East_Asian_Width.\n        See http://www.unicode.org/reports/tr11/\n        Returns UEastAsianWidth values. @stable ICU 2.2 */\n    UCHAR_EAST_ASIAN_WIDTH=0x1004,\n    /** Enumerated property General_Category.\n        Same as u_charType, returns UCharCategory values. @stable ICU 2.2 */\n    UCHAR_GENERAL_CATEGORY=0x1005,\n    /** Enumerated property Joining_Group.\n        Returns UJoiningGroup values. @stable ICU 2.2 */\n    UCHAR_JOINING_GROUP=0x1006,\n    /** Enumerated property Joining_Type.\n        Returns UJoiningType values. @stable ICU 2.2 */\n    UCHAR_JOINING_TYPE=0x1007,\n    /** Enumerated property Line_Break.\n        Returns ULineBreak values. @stable ICU 2.2 */\n    UCHAR_LINE_BREAK=0x1008,\n    /** Enumerated property Numeric_Type.\n        Returns UNumericType values. @stable ICU 2.2 */\n    UCHAR_NUMERIC_TYPE=0x1009,\n    /** Enumerated property Script.\n        Same as uscript_getScript, returns UScriptCode values. @stable ICU 2.2 */\n    UCHAR_SCRIPT=0x100A,\n    /** Enumerated property Hangul_Syllable_Type, new in Unicode 4.\n        Returns UHangulSyllableType values. @stable ICU 2.6 */\n    UCHAR_HANGUL_SYLLABLE_TYPE=0x100B,\n    /** Enumerated property NFD_Quick_Check.\n        Returns UNormalizationCheckResult values. @stable ICU 3.0 */\n    UCHAR_NFD_QUICK_CHECK=0x100C,\n    /** Enumerated property NFKD_Quick_Check.\n        Returns UNormalizationCheckResult values. @stable ICU 3.0 */\n    UCHAR_NFKD_QUICK_CHECK=0x100D,\n    /** Enumerated property NFC_Quick_Check.\n        Returns UNormalizationCheckResult values. @stable ICU 3.0 */\n    UCHAR_NFC_QUICK_CHECK=0x100E,\n    /** Enumerated property NFKC_Quick_Check.\n        Returns UNormalizationCheckResult values. @stable ICU 3.0 */\n    UCHAR_NFKC_QUICK_CHECK=0x100F,\n    /** Enumerated property Lead_Canonical_Combining_Class.\n        ICU-specific property for the ccc of the first code point\n        of the decomposition, or lccc(c)=ccc(NFD(c)[0]).\n        Useful for checking for canonically ordered text;\n        see UNORM_FCD and http://www.unicode.org/notes/tn5/#FCD .\n        Returns 8-bit numeric values like UCHAR_CANONICAL_COMBINING_CLASS. @stable ICU 3.0 */\n    UCHAR_LEAD_CANONICAL_COMBINING_CLASS=0x1010,\n    /** Enumerated property Trail_Canonical_Combining_Class.\n        ICU-specific property for the ccc of the last code point\n        of the decomposition, or tccc(c)=ccc(NFD(c)[last]).\n        Useful for checking for canonically ordered text;\n        see UNORM_FCD and http://www.unicode.org/notes/tn5/#FCD .\n        Returns 8-bit numeric values like UCHAR_CANONICAL_COMBINING_CLASS. @stable ICU 3.0 */\n    UCHAR_TRAIL_CANONICAL_COMBINING_CLASS=0x1011,\n    /** Enumerated property Grapheme_Cluster_Break (new in Unicode 4.1).\n        Used in UAX #29: Text Boundaries\n        (http://www.unicode.org/reports/tr29/)\n        Returns UGraphemeClusterBreak values. @stable ICU 3.4 */\n    UCHAR_GRAPHEME_CLUSTER_BREAK=0x1012,\n    /** Enumerated property Sentence_Break (new in Unicode 4.1).\n        Used in UAX #29: Text Boundaries\n        (http://www.unicode.org/reports/tr29/)\n        Returns USentenceBreak values. @stable ICU 3.4 */\n    UCHAR_SENTENCE_BREAK=0x1013,\n    /** Enumerated property Word_Break (new in Unicode 4.1).\n        Used in UAX #29: Text Boundaries\n        (http://www.unicode.org/reports/tr29/)\n        Returns UWordBreakValues values. @stable ICU 3.4 */\n    UCHAR_WORD_BREAK=0x1014,\n    /** One more than the last constant for enumerated/integer Unicode properties. @stable ICU 2.2 */\n    UCHAR_INT_LIMIT=0x1015,\n\n    /** Bitmask property General_Category_Mask.\n        This is the General_Category property returned as a bit mask.\n        When used in u_getIntPropertyValue(c), same as U_MASK(u_charType(c)),\n        returns bit masks for UCharCategory values where exactly one bit is set.\n        When used with u_getPropertyValueName() and u_getPropertyValueEnum(),\n        a multi-bit mask is used for sets of categories like \"Letters\".\n        Mask values should be cast to uint32_t.\n        @stable ICU 2.4 */\n    UCHAR_GENERAL_CATEGORY_MASK=0x2000,\n    /** First constant for bit-mask Unicode properties. @stable ICU 2.4 */\n    UCHAR_MASK_START=UCHAR_GENERAL_CATEGORY_MASK,\n    /** One more than the last constant for bit-mask Unicode properties. @stable ICU 2.4 */\n    UCHAR_MASK_LIMIT=0x2001,\n\n    /** Double property Numeric_Value.\n        Corresponds to u_getNumericValue. @stable ICU 2.4 */\n    UCHAR_NUMERIC_VALUE=0x3000,\n    /** First constant for double Unicode properties. @stable ICU 2.4 */\n    UCHAR_DOUBLE_START=UCHAR_NUMERIC_VALUE,\n    /** One more than the last constant for double Unicode properties. @stable ICU 2.4 */\n    UCHAR_DOUBLE_LIMIT=0x3001,\n\n    /** String property Age.\n        Corresponds to u_charAge. @stable ICU 2.4 */\n    UCHAR_AGE=0x4000,\n    /** First constant for string Unicode properties. @stable ICU 2.4 */\n    UCHAR_STRING_START=UCHAR_AGE,\n    /** String property Bidi_Mirroring_Glyph.\n        Corresponds to u_charMirror. @stable ICU 2.4 */\n    UCHAR_BIDI_MIRRORING_GLYPH=0x4001,\n    /** String property Case_Folding.\n        Corresponds to u_strFoldCase in ustring.h. @stable ICU 2.4 */\n    UCHAR_CASE_FOLDING=0x4002,\n    /** Deprecated string property ISO_Comment.\n        Corresponds to u_getISOComment. @deprecated ICU 49 */\n    UCHAR_ISO_COMMENT=0x4003,\n    /** String property Lowercase_Mapping.\n        Corresponds to u_strToLower in ustring.h. @stable ICU 2.4 */\n    UCHAR_LOWERCASE_MAPPING=0x4004,\n    /** String property Name.\n        Corresponds to u_charName. @stable ICU 2.4 */\n    UCHAR_NAME=0x4005,\n    /** String property Simple_Case_Folding.\n        Corresponds to u_foldCase. @stable ICU 2.4 */\n    UCHAR_SIMPLE_CASE_FOLDING=0x4006,\n    /** String property Simple_Lowercase_Mapping.\n        Corresponds to u_tolower. @stable ICU 2.4 */\n    UCHAR_SIMPLE_LOWERCASE_MAPPING=0x4007,\n    /** String property Simple_Titlecase_Mapping.\n        Corresponds to u_totitle. @stable ICU 2.4 */\n    UCHAR_SIMPLE_TITLECASE_MAPPING=0x4008,\n    /** String property Simple_Uppercase_Mapping.\n        Corresponds to u_toupper. @stable ICU 2.4 */\n    UCHAR_SIMPLE_UPPERCASE_MAPPING=0x4009,\n    /** String property Titlecase_Mapping.\n        Corresponds to u_strToTitle in ustring.h. @stable ICU 2.4 */\n    UCHAR_TITLECASE_MAPPING=0x400A,\n    /** String property Unicode_1_Name.\n        This property is of little practical value.\n        Beginning with ICU 49, ICU APIs return an empty string for this property.\n        Corresponds to u_charName(U_UNICODE_10_CHAR_NAME). @deprecated ICU 49 */\n    UCHAR_UNICODE_1_NAME=0x400B,\n    /** String property Uppercase_Mapping.\n        Corresponds to u_strToUpper in ustring.h. @stable ICU 2.4 */\n    UCHAR_UPPERCASE_MAPPING=0x400C,\n    /** One more than the last constant for string Unicode properties. @stable ICU 2.4 */\n    UCHAR_STRING_LIMIT=0x400D,\n    /** Provisional property Script_Extensions (new in Unicode 6.0).\n        As a provisional property, it may be modified or removed\n        in future versions of the Unicode Standard, and thus in ICU.\n        Some characters are commonly used in multiple scripts.\n        For more information, see UAX #24: http://www.unicode.org/reports/tr24/.\n        Corresponds to uscript_hasScript and uscript_getScriptExtensions in uscript.h.\n        @stable ICU 4.6 */\n    UCHAR_SCRIPT_EXTENSIONS=0x7000,\n    /** First constant for Unicode properties with unusual value types. @stable ICU 4.6 */\n    UCHAR_OTHER_PROPERTY_START=UCHAR_SCRIPT_EXTENSIONS,\n    /** One more than the last constant for Unicode properties with unusual value types.\n     * @stable ICU 4.6 */\n    UCHAR_OTHER_PROPERTY_LIMIT=0x7001,\n    /** Represents a nonexistent or invalid property or property value. @stable ICU 2.4 */\n    UCHAR_INVALID_CODE = -1\n} UProperty;\n\n/**\n * Data for enumerated Unicode general category types.\n * See http://www.unicode.org/Public/UNIDATA/UnicodeData.html .\n * @stable ICU 2.0\n */\ntypedef enum UCharCategory\n{\n    /*\n     * Note: UCharCategory constants and their API comments are parsed by preparseucd.py.\n     * It matches pairs of lines like\n     *     / ** <Unicode 2-letter General_Category value> comment... * /\n     *     U_<[A-Z_]+> = <integer>,\n     */\n\n    /** Non-category for unassigned and non-character code points. @stable ICU 2.0 */\n    U_UNASSIGNED              = 0,\n    /** Cn \"Other, Not Assigned (no characters in [UnicodeData.txt] have this property)\" (same as U_UNASSIGNED!) @stable ICU 2.0 */\n    U_GENERAL_OTHER_TYPES     = 0,\n    /** Lu @stable ICU 2.0 */\n    U_UPPERCASE_LETTER        = 1,\n    /** Ll @stable ICU 2.0 */\n    U_LOWERCASE_LETTER        = 2,\n    /** Lt @stable ICU 2.0 */\n    U_TITLECASE_LETTER        = 3,\n    /** Lm @stable ICU 2.0 */\n    U_MODIFIER_LETTER         = 4,\n    /** Lo @stable ICU 2.0 */\n    U_OTHER_LETTER            = 5,\n    /** Mn @stable ICU 2.0 */\n    U_NON_SPACING_MARK        = 6,\n    /** Me @stable ICU 2.0 */\n    U_ENCLOSING_MARK          = 7,\n    /** Mc @stable ICU 2.0 */\n    U_COMBINING_SPACING_MARK  = 8,\n    /** Nd @stable ICU 2.0 */\n    U_DECIMAL_DIGIT_NUMBER    = 9,\n    /** Nl @stable ICU 2.0 */\n    U_LETTER_NUMBER           = 10,\n    /** No @stable ICU 2.0 */\n    U_OTHER_NUMBER            = 11,\n    /** Zs @stable ICU 2.0 */\n    U_SPACE_SEPARATOR         = 12,\n    /** Zl @stable ICU 2.0 */\n    U_LINE_SEPARATOR          = 13,\n    /** Zp @stable ICU 2.0 */\n    U_PARAGRAPH_SEPARATOR     = 14,\n    /** Cc @stable ICU 2.0 */\n    U_CONTROL_CHAR            = 15,\n    /** Cf @stable ICU 2.0 */\n    U_FORMAT_CHAR             = 16,\n    /** Co @stable ICU 2.0 */\n    U_PRIVATE_USE_CHAR        = 17,\n    /** Cs @stable ICU 2.0 */\n    U_SURROGATE               = 18,\n    /** Pd @stable ICU 2.0 */\n    U_DASH_PUNCTUATION        = 19,\n    /** Ps @stable ICU 2.0 */\n    U_START_PUNCTUATION       = 20,\n    /** Pe @stable ICU 2.0 */\n    U_END_PUNCTUATION         = 21,\n    /** Pc @stable ICU 2.0 */\n    U_CONNECTOR_PUNCTUATION   = 22,\n    /** Po @stable ICU 2.0 */\n    U_OTHER_PUNCTUATION       = 23,\n    /** Sm @stable ICU 2.0 */\n    U_MATH_SYMBOL             = 24,\n    /** Sc @stable ICU 2.0 */\n    U_CURRENCY_SYMBOL         = 25,\n    /** Sk @stable ICU 2.0 */\n    U_MODIFIER_SYMBOL         = 26,\n    /** So @stable ICU 2.0 */\n    U_OTHER_SYMBOL            = 27,\n    /** Pi @stable ICU 2.0 */\n    U_INITIAL_PUNCTUATION     = 28,\n    /** Pf @stable ICU 2.0 */\n    U_FINAL_PUNCTUATION       = 29,\n    /** One higher than the last enum UCharCategory constant. @stable ICU 2.0 */\n    U_CHAR_CATEGORY_COUNT\n} UCharCategory;\n\n/**\n * U_GC_XX_MASK constants are bit flags corresponding to Unicode\n * general category values.\n * For each category, the nth bit is set if the numeric value of the\n * corresponding UCharCategory constant is n.\n *\n * There are also some U_GC_Y_MASK constants for groups of general categories\n * like L for all letter categories.\n *\n * @see u_charType\n * @see U_GET_GC_MASK\n * @see UCharCategory\n * @stable ICU 2.1\n */\n#define U_GC_CN_MASK    U_MASK(U_GENERAL_OTHER_TYPES)\n\n/** Mask constant for a UCharCategory. @stable ICU 2.1 */\n#define U_GC_LU_MASK    U_MASK(U_UPPERCASE_LETTER)\n/** Mask constant for a UCharCategory. @stable ICU 2.1 */\n#define U_GC_LL_MASK    U_MASK(U_LOWERCASE_LETTER)\n/** Mask constant for a UCharCategory. @stable ICU 2.1 */\n#define U_GC_LT_MASK    U_MASK(U_TITLECASE_LETTER)\n/** Mask constant for a UCharCategory. @stable ICU 2.1 */\n#define U_GC_LM_MASK    U_MASK(U_MODIFIER_LETTER)\n/** Mask constant for a UCharCategory. @stable ICU 2.1 */\n#define U_GC_LO_MASK    U_MASK(U_OTHER_LETTER)\n\n/** Mask constant for a UCharCategory. @stable ICU 2.1 */\n#define U_GC_MN_MASK    U_MASK(U_NON_SPACING_MARK)\n/** Mask constant for a UCharCategory. @stable ICU 2.1 */\n#define U_GC_ME_MASK    U_MASK(U_ENCLOSING_MARK)\n/** Mask constant for a UCharCategory. @stable ICU 2.1 */\n#define U_GC_MC_MASK    U_MASK(U_COMBINING_SPACING_MARK)\n\n/** Mask constant for a UCharCategory. @stable ICU 2.1 */\n#define U_GC_ND_MASK    U_MASK(U_DECIMAL_DIGIT_NUMBER)\n/** Mask constant for a UCharCategory. @stable ICU 2.1 */\n#define U_GC_NL_MASK    U_MASK(U_LETTER_NUMBER)\n/** Mask constant for a UCharCategory. @stable ICU 2.1 */\n#define U_GC_NO_MASK    U_MASK(U_OTHER_NUMBER)\n\n/** Mask constant for a UCharCategory. @stable ICU 2.1 */\n#define U_GC_ZS_MASK    U_MASK(U_SPACE_SEPARATOR)\n/** Mask constant for a UCharCategory. @stable ICU 2.1 */\n#define U_GC_ZL_MASK    U_MASK(U_LINE_SEPARATOR)\n/** Mask constant for a UCharCategory. @stable ICU 2.1 */\n#define U_GC_ZP_MASK    U_MASK(U_PARAGRAPH_SEPARATOR)\n\n/** Mask constant for a UCharCategory. @stable ICU 2.1 */\n#define U_GC_CC_MASK    U_MASK(U_CONTROL_CHAR)\n/** Mask constant for a UCharCategory. @stable ICU 2.1 */\n#define U_GC_CF_MASK    U_MASK(U_FORMAT_CHAR)\n/** Mask constant for a UCharCategory. @stable ICU 2.1 */\n#define U_GC_CO_MASK    U_MASK(U_PRIVATE_USE_CHAR)\n/** Mask constant for a UCharCategory. @stable ICU 2.1 */\n#define U_GC_CS_MASK    U_MASK(U_SURROGATE)\n\n/** Mask constant for a UCharCategory. @stable ICU 2.1 */\n#define U_GC_PD_MASK    U_MASK(U_DASH_PUNCTUATION)\n/** Mask constant for a UCharCategory. @stable ICU 2.1 */\n#define U_GC_PS_MASK    U_MASK(U_START_PUNCTUATION)\n/** Mask constant for a UCharCategory. @stable ICU 2.1 */\n#define U_GC_PE_MASK    U_MASK(U_END_PUNCTUATION)\n/** Mask constant for a UCharCategory. @stable ICU 2.1 */\n#define U_GC_PC_MASK    U_MASK(U_CONNECTOR_PUNCTUATION)\n/** Mask constant for a UCharCategory. @stable ICU 2.1 */\n#define U_GC_PO_MASK    U_MASK(U_OTHER_PUNCTUATION)\n\n/** Mask constant for a UCharCategory. @stable ICU 2.1 */\n#define U_GC_SM_MASK    U_MASK(U_MATH_SYMBOL)\n/** Mask constant for a UCharCategory. @stable ICU 2.1 */\n#define U_GC_SC_MASK    U_MASK(U_CURRENCY_SYMBOL)\n/** Mask constant for a UCharCategory. @stable ICU 2.1 */\n#define U_GC_SK_MASK    U_MASK(U_MODIFIER_SYMBOL)\n/** Mask constant for a UCharCategory. @stable ICU 2.1 */\n#define U_GC_SO_MASK    U_MASK(U_OTHER_SYMBOL)\n\n/** Mask constant for a UCharCategory. @stable ICU 2.1 */\n#define U_GC_PI_MASK    U_MASK(U_INITIAL_PUNCTUATION)\n/** Mask constant for a UCharCategory. @stable ICU 2.1 */\n#define U_GC_PF_MASK    U_MASK(U_FINAL_PUNCTUATION)\n\n\n/** Mask constant for multiple UCharCategory bits (L Letters). @stable ICU 2.1 */\n#define U_GC_L_MASK \\\n            (U_GC_LU_MASK|U_GC_LL_MASK|U_GC_LT_MASK|U_GC_LM_MASK|U_GC_LO_MASK)\n\n/** Mask constant for multiple UCharCategory bits (LC Cased Letters). @stable ICU 2.1 */\n#define U_GC_LC_MASK \\\n            (U_GC_LU_MASK|U_GC_LL_MASK|U_GC_LT_MASK)\n\n/** Mask constant for multiple UCharCategory bits (M Marks). @stable ICU 2.1 */\n#define U_GC_M_MASK (U_GC_MN_MASK|U_GC_ME_MASK|U_GC_MC_MASK)\n\n/** Mask constant for multiple UCharCategory bits (N Numbers). @stable ICU 2.1 */\n#define U_GC_N_MASK (U_GC_ND_MASK|U_GC_NL_MASK|U_GC_NO_MASK)\n\n/** Mask constant for multiple UCharCategory bits (Z Separators). @stable ICU 2.1 */\n#define U_GC_Z_MASK (U_GC_ZS_MASK|U_GC_ZL_MASK|U_GC_ZP_MASK)\n\n/** Mask constant for multiple UCharCategory bits (C Others). @stable ICU 2.1 */\n#define U_GC_C_MASK \\\n            (U_GC_CN_MASK|U_GC_CC_MASK|U_GC_CF_MASK|U_GC_CO_MASK|U_GC_CS_MASK)\n\n/** Mask constant for multiple UCharCategory bits (P Punctuation). @stable ICU 2.1 */\n#define U_GC_P_MASK \\\n            (U_GC_PD_MASK|U_GC_PS_MASK|U_GC_PE_MASK|U_GC_PC_MASK|U_GC_PO_MASK| \\\n             U_GC_PI_MASK|U_GC_PF_MASK)\n\n/** Mask constant for multiple UCharCategory bits (S Symbols). @stable ICU 2.1 */\n#define U_GC_S_MASK (U_GC_SM_MASK|U_GC_SC_MASK|U_GC_SK_MASK|U_GC_SO_MASK)\n\n/**\n * This specifies the language directional property of a character set.\n * @stable ICU 2.0\n */\ntypedef enum UCharDirection {\n    /*\n     * Note: UCharDirection constants and their API comments are parsed by preparseucd.py.\n     * It matches pairs of lines like\n     *     / ** <Unicode 1..3-letter Bidi_Class value> comment... * /\n     *     U_<[A-Z_]+> = <integer>,\n     */\n\n    /** L @stable ICU 2.0 */\n    U_LEFT_TO_RIGHT               = 0,\n    /** R @stable ICU 2.0 */\n    U_RIGHT_TO_LEFT               = 1,\n    /** EN @stable ICU 2.0 */\n    U_EUROPEAN_NUMBER             = 2,\n    /** ES @stable ICU 2.0 */\n    U_EUROPEAN_NUMBER_SEPARATOR   = 3,\n    /** ET @stable ICU 2.0 */\n    U_EUROPEAN_NUMBER_TERMINATOR  = 4,\n    /** AN @stable ICU 2.0 */\n    U_ARABIC_NUMBER               = 5,\n    /** CS @stable ICU 2.0 */\n    U_COMMON_NUMBER_SEPARATOR     = 6,\n    /** B @stable ICU 2.0 */\n    U_BLOCK_SEPARATOR             = 7,\n    /** S @stable ICU 2.0 */\n    U_SEGMENT_SEPARATOR           = 8,\n    /** WS @stable ICU 2.0 */\n    U_WHITE_SPACE_NEUTRAL         = 9,\n    /** ON @stable ICU 2.0 */\n    U_OTHER_NEUTRAL               = 10,\n    /** LRE @stable ICU 2.0 */\n    U_LEFT_TO_RIGHT_EMBEDDING     = 11,\n    /** LRO @stable ICU 2.0 */\n    U_LEFT_TO_RIGHT_OVERRIDE      = 12,\n    /** AL @stable ICU 2.0 */\n    U_RIGHT_TO_LEFT_ARABIC        = 13,\n    /** RLE @stable ICU 2.0 */\n    U_RIGHT_TO_LEFT_EMBEDDING     = 14,\n    /** RLO @stable ICU 2.0 */\n    U_RIGHT_TO_LEFT_OVERRIDE      = 15,\n    /** PDF @stable ICU 2.0 */\n    U_POP_DIRECTIONAL_FORMAT      = 16,\n    /** NSM @stable ICU 2.0 */\n    U_DIR_NON_SPACING_MARK        = 17,\n    /** BN @stable ICU 2.0 */\n    U_BOUNDARY_NEUTRAL            = 18,\n    /** @stable ICU 2.0 */\n    U_CHAR_DIRECTION_COUNT\n} UCharDirection;\n\n/**\n * Constants for Unicode blocks, see the Unicode Data file Blocks.txt\n * @stable ICU 2.0\n */\nenum UBlockCode {\n    /*\n     * Note: UBlockCode constants are parsed by preparseucd.py.\n     * It matches lines like\n     *     UBLOCK_<Unicode Block value name> = <integer>,\n     */\n\n    /** New No_Block value in Unicode 4. @stable ICU 2.6 */\n    UBLOCK_NO_BLOCK = 0, /*[none]*/ /* Special range indicating No_Block */\n\n    /** @stable ICU 2.0 */\n    UBLOCK_BASIC_LATIN = 1, /*[0000]*/\n\n    /** @stable ICU 2.0 */\n    UBLOCK_LATIN_1_SUPPLEMENT=2, /*[0080]*/\n\n    /** @stable ICU 2.0 */\n    UBLOCK_LATIN_EXTENDED_A =3, /*[0100]*/\n\n    /** @stable ICU 2.0 */\n    UBLOCK_LATIN_EXTENDED_B =4, /*[0180]*/\n\n    /** @stable ICU 2.0 */\n    UBLOCK_IPA_EXTENSIONS =5, /*[0250]*/\n\n    /** @stable ICU 2.0 */\n    UBLOCK_SPACING_MODIFIER_LETTERS =6, /*[02B0]*/\n\n    /** @stable ICU 2.0 */\n    UBLOCK_COMBINING_DIACRITICAL_MARKS =7, /*[0300]*/\n\n    /**\n     * Unicode 3.2 renames this block to \"Greek and Coptic\".\n     * @stable ICU 2.0\n     */\n    UBLOCK_GREEK =8, /*[0370]*/\n\n    /** @stable ICU 2.0 */\n    UBLOCK_CYRILLIC =9, /*[0400]*/\n\n    /** @stable ICU 2.0 */\n    UBLOCK_ARMENIAN =10, /*[0530]*/\n\n    /** @stable ICU 2.0 */\n    UBLOCK_HEBREW =11, /*[0590]*/\n\n    /** @stable ICU 2.0 */\n    UBLOCK_ARABIC =12, /*[0600]*/\n\n    /** @stable ICU 2.0 */\n    UBLOCK_SYRIAC =13, /*[0700]*/\n\n    /** @stable ICU 2.0 */\n    UBLOCK_THAANA =14, /*[0780]*/\n\n    /** @stable ICU 2.0 */\n    UBLOCK_DEVANAGARI =15, /*[0900]*/\n\n    /** @stable ICU 2.0 */\n    UBLOCK_BENGALI =16, /*[0980]*/\n\n    /** @stable ICU 2.0 */\n    UBLOCK_GURMUKHI =17, /*[0A00]*/\n\n    /** @stable ICU 2.0 */\n    UBLOCK_GUJARATI =18, /*[0A80]*/\n\n    /** @stable ICU 2.0 */\n    UBLOCK_ORIYA =19, /*[0B00]*/\n\n    /** @stable ICU 2.0 */\n    UBLOCK_TAMIL =20, /*[0B80]*/\n\n    /** @stable ICU 2.0 */\n    UBLOCK_TELUGU =21, /*[0C00]*/\n\n    /** @stable ICU 2.0 */\n    UBLOCK_KANNADA =22, /*[0C80]*/\n\n    /** @stable ICU 2.0 */\n    UBLOCK_MALAYALAM =23, /*[0D00]*/\n\n    /** @stable ICU 2.0 */\n    UBLOCK_SINHALA =24, /*[0D80]*/\n\n    /** @stable ICU 2.0 */\n    UBLOCK_THAI =25, /*[0E00]*/\n\n    /** @stable ICU 2.0 */\n    UBLOCK_LAO =26, /*[0E80]*/\n\n    /** @stable ICU 2.0 */\n    UBLOCK_TIBETAN =27, /*[0F00]*/\n\n    /** @stable ICU 2.0 */\n    UBLOCK_MYANMAR =28, /*[1000]*/\n\n    /** @stable ICU 2.0 */\n    UBLOCK_GEORGIAN =29, /*[10A0]*/\n\n    /** @stable ICU 2.0 */\n    UBLOCK_HANGUL_JAMO =30, /*[1100]*/\n\n    /** @stable ICU 2.0 */\n    UBLOCK_ETHIOPIC =31, /*[1200]*/\n\n    /** @stable ICU 2.0 */\n    UBLOCK_CHEROKEE =32, /*[13A0]*/\n\n    /** @stable ICU 2.0 */\n    UBLOCK_UNIFIED_CANADIAN_ABORIGINAL_SYLLABICS =33, /*[1400]*/\n\n    /** @stable ICU 2.0 */\n    UBLOCK_OGHAM =34, /*[1680]*/\n\n    /** @stable ICU 2.0 */\n    UBLOCK_RUNIC =35, /*[16A0]*/\n\n    /** @stable ICU 2.0 */\n    UBLOCK_KHMER =36, /*[1780]*/\n\n    /** @stable ICU 2.0 */\n    UBLOCK_MONGOLIAN =37, /*[1800]*/\n\n    /** @stable ICU 2.0 */\n    UBLOCK_LATIN_EXTENDED_ADDITIONAL =38, /*[1E00]*/\n\n    /** @stable ICU 2.0 */\n    UBLOCK_GREEK_EXTENDED =39, /*[1F00]*/\n\n    /** @stable ICU 2.0 */\n    UBLOCK_GENERAL_PUNCTUATION =40, /*[2000]*/\n\n    /** @stable ICU 2.0 */\n    UBLOCK_SUPERSCRIPTS_AND_SUBSCRIPTS =41, /*[2070]*/\n\n    /** @stable ICU 2.0 */\n    UBLOCK_CURRENCY_SYMBOLS =42, /*[20A0]*/\n\n    /**\n     * Unicode 3.2 renames this block to \"Combining Diacritical Marks for Symbols\".\n     * @stable ICU 2.0\n     */\n    UBLOCK_COMBINING_MARKS_FOR_SYMBOLS =43, /*[20D0]*/\n\n    /** @stable ICU 2.0 */\n    UBLOCK_LETTERLIKE_SYMBOLS =44, /*[2100]*/\n\n    /** @stable ICU 2.0 */\n    UBLOCK_NUMBER_FORMS =45, /*[2150]*/\n\n    /** @stable ICU 2.0 */\n    UBLOCK_ARROWS =46, /*[2190]*/\n\n    /** @stable ICU 2.0 */\n    UBLOCK_MATHEMATICAL_OPERATORS =47, /*[2200]*/\n\n    /** @stable ICU 2.0 */\n    UBLOCK_MISCELLANEOUS_TECHNICAL =48, /*[2300]*/\n\n    /** @stable ICU 2.0 */\n    UBLOCK_CONTROL_PICTURES =49, /*[2400]*/\n\n    /** @stable ICU 2.0 */\n    UBLOCK_OPTICAL_CHARACTER_RECOGNITION =50, /*[2440]*/\n\n    /** @stable ICU 2.0 */\n    UBLOCK_ENCLOSED_ALPHANUMERICS =51, /*[2460]*/\n\n    /** @stable ICU 2.0 */\n    UBLOCK_BOX_DRAWING =52, /*[2500]*/\n\n    /** @stable ICU 2.0 */\n    UBLOCK_BLOCK_ELEMENTS =53, /*[2580]*/\n\n    /** @stable ICU 2.0 */\n    UBLOCK_GEOMETRIC_SHAPES =54, /*[25A0]*/\n\n    /** @stable ICU 2.0 */\n    UBLOCK_MISCELLANEOUS_SYMBOLS =55, /*[2600]*/\n\n    /** @stable ICU 2.0 */\n    UBLOCK_DINGBATS =56, /*[2700]*/\n\n    /** @stable ICU 2.0 */\n    UBLOCK_BRAILLE_PATTERNS =57, /*[2800]*/\n\n    /** @stable ICU 2.0 */\n    UBLOCK_CJK_RADICALS_SUPPLEMENT =58, /*[2E80]*/\n\n    /** @stable ICU 2.0 */\n    UBLOCK_KANGXI_RADICALS =59, /*[2F00]*/\n\n    /** @stable ICU 2.0 */\n    UBLOCK_IDEOGRAPHIC_DESCRIPTION_CHARACTERS =60, /*[2FF0]*/\n\n    /** @stable ICU 2.0 */\n    UBLOCK_CJK_SYMBOLS_AND_PUNCTUATION =61, /*[3000]*/\n\n    /** @stable ICU 2.0 */\n    UBLOCK_HIRAGANA =62, /*[3040]*/\n\n    /** @stable ICU 2.0 */\n    UBLOCK_KATAKANA =63, /*[30A0]*/\n\n    /** @stable ICU 2.0 */\n    UBLOCK_BOPOMOFO =64, /*[3100]*/\n\n    /** @stable ICU 2.0 */\n    UBLOCK_HANGUL_COMPATIBILITY_JAMO =65, /*[3130]*/\n\n    /** @stable ICU 2.0 */\n    UBLOCK_KANBUN =66, /*[3190]*/\n\n    /** @stable ICU 2.0 */\n    UBLOCK_BOPOMOFO_EXTENDED =67, /*[31A0]*/\n\n    /** @stable ICU 2.0 */\n    UBLOCK_ENCLOSED_CJK_LETTERS_AND_MONTHS =68, /*[3200]*/\n\n    /** @stable ICU 2.0 */\n    UBLOCK_CJK_COMPATIBILITY =69, /*[3300]*/\n\n    /** @stable ICU 2.0 */\n    UBLOCK_CJK_UNIFIED_IDEOGRAPHS_EXTENSION_A =70, /*[3400]*/\n\n    /** @stable ICU 2.0 */\n    UBLOCK_CJK_UNIFIED_IDEOGRAPHS =71, /*[4E00]*/\n\n    /** @stable ICU 2.0 */\n    UBLOCK_YI_SYLLABLES =72, /*[A000]*/\n\n    /** @stable ICU 2.0 */\n    UBLOCK_YI_RADICALS =73, /*[A490]*/\n\n    /** @stable ICU 2.0 */\n    UBLOCK_HANGUL_SYLLABLES =74, /*[AC00]*/\n\n    /** @stable ICU 2.0 */\n    UBLOCK_HIGH_SURROGATES =75, /*[D800]*/\n\n    /** @stable ICU 2.0 */\n    UBLOCK_HIGH_PRIVATE_USE_SURROGATES =76, /*[DB80]*/\n\n    /** @stable ICU 2.0 */\n    UBLOCK_LOW_SURROGATES =77, /*[DC00]*/\n\n    /**\n     * Same as UBLOCK_PRIVATE_USE.\n     * Until Unicode 3.1.1, the corresponding block name was \"Private Use\",\n     * and multiple code point ranges had this block.\n     * Unicode 3.2 renames the block for the BMP PUA to \"Private Use Area\" and\n     * adds separate blocks for the supplementary PUAs.\n     *\n     * @stable ICU 2.0\n     */\n    UBLOCK_PRIVATE_USE_AREA =78, /*[E000]*/\n    /**\n     * Same as UBLOCK_PRIVATE_USE_AREA.\n     * Until Unicode 3.1.1, the corresponding block name was \"Private Use\",\n     * and multiple code point ranges had this block.\n     * Unicode 3.2 renames the block for the BMP PUA to \"Private Use Area\" and\n     * adds separate blocks for the supplementary PUAs.\n     *\n     * @stable ICU 2.0\n     */\n    UBLOCK_PRIVATE_USE = UBLOCK_PRIVATE_USE_AREA,\n\n    /** @stable ICU 2.0 */\n    UBLOCK_CJK_COMPATIBILITY_IDEOGRAPHS =79, /*[F900]*/\n\n    /** @stable ICU 2.0 */\n    UBLOCK_ALPHABETIC_PRESENTATION_FORMS =80, /*[FB00]*/\n\n    /** @stable ICU 2.0 */\n    UBLOCK_ARABIC_PRESENTATION_FORMS_A =81, /*[FB50]*/\n\n    /** @stable ICU 2.0 */\n    UBLOCK_COMBINING_HALF_MARKS =82, /*[FE20]*/\n\n    /** @stable ICU 2.0 */\n    UBLOCK_CJK_COMPATIBILITY_FORMS =83, /*[FE30]*/\n\n    /** @stable ICU 2.0 */\n    UBLOCK_SMALL_FORM_VARIANTS =84, /*[FE50]*/\n\n    /** @stable ICU 2.0 */\n    UBLOCK_ARABIC_PRESENTATION_FORMS_B =85, /*[FE70]*/\n\n    /** @stable ICU 2.0 */\n    UBLOCK_SPECIALS =86, /*[FFF0]*/\n\n    /** @stable ICU 2.0 */\n    UBLOCK_HALFWIDTH_AND_FULLWIDTH_FORMS =87, /*[FF00]*/\n\n    /* New blocks in Unicode 3.1 */\n\n    /** @stable ICU 2.0 */\n    UBLOCK_OLD_ITALIC = 88, /*[10300]*/\n    /** @stable ICU 2.0 */\n    UBLOCK_GOTHIC = 89, /*[10330]*/\n    /** @stable ICU 2.0 */\n    UBLOCK_DESERET = 90, /*[10400]*/\n    /** @stable ICU 2.0 */\n    UBLOCK_BYZANTINE_MUSICAL_SYMBOLS = 91, /*[1D000]*/\n    /** @stable ICU 2.0 */\n    UBLOCK_MUSICAL_SYMBOLS = 92, /*[1D100]*/\n    /** @stable ICU 2.0 */\n    UBLOCK_MATHEMATICAL_ALPHANUMERIC_SYMBOLS = 93, /*[1D400]*/\n    /** @stable ICU 2.0 */\n    UBLOCK_CJK_UNIFIED_IDEOGRAPHS_EXTENSION_B  = 94, /*[20000]*/\n    /** @stable ICU 2.0 */\n    UBLOCK_CJK_COMPATIBILITY_IDEOGRAPHS_SUPPLEMENT = 95, /*[2F800]*/\n    /** @stable ICU 2.0 */\n    UBLOCK_TAGS = 96, /*[E0000]*/\n\n    /* New blocks in Unicode 3.2 */\n\n    /** @stable ICU 3.0  */\n    UBLOCK_CYRILLIC_SUPPLEMENT = 97, /*[0500]*/\n    /**\n     * Unicode 4.0.1 renames the \"Cyrillic Supplementary\" block to \"Cyrillic Supplement\".\n     * @stable ICU 2.2\n     */\n    UBLOCK_CYRILLIC_SUPPLEMENTARY = UBLOCK_CYRILLIC_SUPPLEMENT, \n    /** @stable ICU 2.2 */\n    UBLOCK_TAGALOG = 98, /*[1700]*/\n    /** @stable ICU 2.2 */\n    UBLOCK_HANUNOO = 99, /*[1720]*/\n    /** @stable ICU 2.2 */\n    UBLOCK_BUHID = 100, /*[1740]*/\n    /** @stable ICU 2.2 */\n    UBLOCK_TAGBANWA = 101, /*[1760]*/\n    /** @stable ICU 2.2 */\n    UBLOCK_MISCELLANEOUS_MATHEMATICAL_SYMBOLS_A = 102, /*[27C0]*/\n    /** @stable ICU 2.2 */\n    UBLOCK_SUPPLEMENTAL_ARROWS_A = 103, /*[27F0]*/\n    /** @stable ICU 2.2 */\n    UBLOCK_SUPPLEMENTAL_ARROWS_B = 104, /*[2900]*/\n    /** @stable ICU 2.2 */\n    UBLOCK_MISCELLANEOUS_MATHEMATICAL_SYMBOLS_B = 105, /*[2980]*/\n    /** @stable ICU 2.2 */\n    UBLOCK_SUPPLEMENTAL_MATHEMATICAL_OPERATORS = 106, /*[2A00]*/\n    /** @stable ICU 2.2 */\n    UBLOCK_KATAKANA_PHONETIC_EXTENSIONS = 107, /*[31F0]*/\n    /** @stable ICU 2.2 */\n    UBLOCK_VARIATION_SELECTORS = 108, /*[FE00]*/\n    /** @stable ICU 2.2 */\n    UBLOCK_SUPPLEMENTARY_PRIVATE_USE_AREA_A = 109, /*[F0000]*/\n    /** @stable ICU 2.2 */\n    UBLOCK_SUPPLEMENTARY_PRIVATE_USE_AREA_B = 110, /*[100000]*/\n\n    /* New blocks in Unicode 4 */\n\n    /** @stable ICU 2.6 */\n    UBLOCK_LIMBU = 111, /*[1900]*/\n    /** @stable ICU 2.6 */\n    UBLOCK_TAI_LE = 112, /*[1950]*/\n    /** @stable ICU 2.6 */\n    UBLOCK_KHMER_SYMBOLS = 113, /*[19E0]*/\n    /** @stable ICU 2.6 */\n    UBLOCK_PHONETIC_EXTENSIONS = 114, /*[1D00]*/\n    /** @stable ICU 2.6 */\n    UBLOCK_MISCELLANEOUS_SYMBOLS_AND_ARROWS = 115, /*[2B00]*/\n    /** @stable ICU 2.6 */\n    UBLOCK_YIJING_HEXAGRAM_SYMBOLS = 116, /*[4DC0]*/\n    /** @stable ICU 2.6 */\n    UBLOCK_LINEAR_B_SYLLABARY = 117, /*[10000]*/\n    /** @stable ICU 2.6 */\n    UBLOCK_LINEAR_B_IDEOGRAMS = 118, /*[10080]*/\n    /** @stable ICU 2.6 */\n    UBLOCK_AEGEAN_NUMBERS = 119, /*[10100]*/\n    /** @stable ICU 2.6 */\n    UBLOCK_UGARITIC = 120, /*[10380]*/\n    /** @stable ICU 2.6 */\n    UBLOCK_SHAVIAN = 121, /*[10450]*/\n    /** @stable ICU 2.6 */\n    UBLOCK_OSMANYA = 122, /*[10480]*/\n    /** @stable ICU 2.6 */\n    UBLOCK_CYPRIOT_SYLLABARY = 123, /*[10800]*/\n    /** @stable ICU 2.6 */\n    UBLOCK_TAI_XUAN_JING_SYMBOLS = 124, /*[1D300]*/\n    /** @stable ICU 2.6 */\n    UBLOCK_VARIATION_SELECTORS_SUPPLEMENT = 125, /*[E0100]*/\n\n    /* New blocks in Unicode 4.1 */\n\n    /** @stable ICU 3.4 */\n    UBLOCK_ANCIENT_GREEK_MUSICAL_NOTATION = 126, /*[1D200]*/\n    /** @stable ICU 3.4 */\n    UBLOCK_ANCIENT_GREEK_NUMBERS = 127, /*[10140]*/\n    /** @stable ICU 3.4 */\n    UBLOCK_ARABIC_SUPPLEMENT = 128, /*[0750]*/\n    /** @stable ICU 3.4 */\n    UBLOCK_BUGINESE = 129, /*[1A00]*/\n    /** @stable ICU 3.4 */\n    UBLOCK_CJK_STROKES = 130, /*[31C0]*/\n    /** @stable ICU 3.4 */\n    UBLOCK_COMBINING_DIACRITICAL_MARKS_SUPPLEMENT = 131, /*[1DC0]*/\n    /** @stable ICU 3.4 */\n    UBLOCK_COPTIC = 132, /*[2C80]*/\n    /** @stable ICU 3.4 */\n    UBLOCK_ETHIOPIC_EXTENDED = 133, /*[2D80]*/\n    /** @stable ICU 3.4 */\n    UBLOCK_ETHIOPIC_SUPPLEMENT = 134, /*[1380]*/\n    /** @stable ICU 3.4 */\n    UBLOCK_GEORGIAN_SUPPLEMENT = 135, /*[2D00]*/\n    /** @stable ICU 3.4 */\n    UBLOCK_GLAGOLITIC = 136, /*[2C00]*/\n    /** @stable ICU 3.4 */\n    UBLOCK_KHAROSHTHI = 137, /*[10A00]*/\n    /** @stable ICU 3.4 */\n    UBLOCK_MODIFIER_TONE_LETTERS = 138, /*[A700]*/\n    /** @stable ICU 3.4 */\n    UBLOCK_NEW_TAI_LUE = 139, /*[1980]*/\n    /** @stable ICU 3.4 */\n    UBLOCK_OLD_PERSIAN = 140, /*[103A0]*/\n    /** @stable ICU 3.4 */\n    UBLOCK_PHONETIC_EXTENSIONS_SUPPLEMENT = 141, /*[1D80]*/\n    /** @stable ICU 3.4 */\n    UBLOCK_SUPPLEMENTAL_PUNCTUATION = 142, /*[2E00]*/\n    /** @stable ICU 3.4 */\n    UBLOCK_SYLOTI_NAGRI = 143, /*[A800]*/\n    /** @stable ICU 3.4 */\n    UBLOCK_TIFINAGH = 144, /*[2D30]*/\n    /** @stable ICU 3.4 */\n    UBLOCK_VERTICAL_FORMS = 145, /*[FE10]*/\n\n    /* New blocks in Unicode 5.0 */\n\n    /** @stable ICU 3.6 */\n    UBLOCK_NKO = 146, /*[07C0]*/\n    /** @stable ICU 3.6 */\n    UBLOCK_BALINESE = 147, /*[1B00]*/\n    /** @stable ICU 3.6 */\n    UBLOCK_LATIN_EXTENDED_C = 148, /*[2C60]*/\n    /** @stable ICU 3.6 */\n    UBLOCK_LATIN_EXTENDED_D = 149, /*[A720]*/\n    /** @stable ICU 3.6 */\n    UBLOCK_PHAGS_PA = 150, /*[A840]*/\n    /** @stable ICU 3.6 */\n    UBLOCK_PHOENICIAN = 151, /*[10900]*/\n    /** @stable ICU 3.6 */\n    UBLOCK_CUNEIFORM = 152, /*[12000]*/\n    /** @stable ICU 3.6 */\n    UBLOCK_CUNEIFORM_NUMBERS_AND_PUNCTUATION = 153, /*[12400]*/\n    /** @stable ICU 3.6 */\n    UBLOCK_COUNTING_ROD_NUMERALS = 154, /*[1D360]*/\n\n    /* New blocks in Unicode 5.1 */\n\n    /** @stable ICU 4.0 */\n    UBLOCK_SUNDANESE = 155, /*[1B80]*/\n    /** @stable ICU 4.0 */\n    UBLOCK_LEPCHA = 156, /*[1C00]*/\n    /** @stable ICU 4.0 */\n    UBLOCK_OL_CHIKI = 157, /*[1C50]*/\n    /** @stable ICU 4.0 */\n    UBLOCK_CYRILLIC_EXTENDED_A = 158, /*[2DE0]*/\n    /** @stable ICU 4.0 */\n    UBLOCK_VAI = 159, /*[A500]*/\n    /** @stable ICU 4.0 */\n    UBLOCK_CYRILLIC_EXTENDED_B = 160, /*[A640]*/\n    /** @stable ICU 4.0 */\n    UBLOCK_SAURASHTRA = 161, /*[A880]*/\n    /** @stable ICU 4.0 */\n    UBLOCK_KAYAH_LI = 162, /*[A900]*/\n    /** @stable ICU 4.0 */\n    UBLOCK_REJANG = 163, /*[A930]*/\n    /** @stable ICU 4.0 */\n    UBLOCK_CHAM = 164, /*[AA00]*/\n    /** @stable ICU 4.0 */\n    UBLOCK_ANCIENT_SYMBOLS = 165, /*[10190]*/\n    /** @stable ICU 4.0 */\n    UBLOCK_PHAISTOS_DISC = 166, /*[101D0]*/\n    /** @stable ICU 4.0 */\n    UBLOCK_LYCIAN = 167, /*[10280]*/\n    /** @stable ICU 4.0 */\n    UBLOCK_CARIAN = 168, /*[102A0]*/\n    /** @stable ICU 4.0 */\n    UBLOCK_LYDIAN = 169, /*[10920]*/\n    /** @stable ICU 4.0 */\n    UBLOCK_MAHJONG_TILES = 170, /*[1F000]*/\n    /** @stable ICU 4.0 */\n    UBLOCK_DOMINO_TILES = 171, /*[1F030]*/\n\n    /* New blocks in Unicode 5.2 */\n\n    /** @stable ICU 4.4 */\n    UBLOCK_SAMARITAN = 172, /*[0800]*/\n    /** @stable ICU 4.4 */\n    UBLOCK_UNIFIED_CANADIAN_ABORIGINAL_SYLLABICS_EXTENDED = 173, /*[18B0]*/\n    /** @stable ICU 4.4 */\n    UBLOCK_TAI_THAM = 174, /*[1A20]*/\n    /** @stable ICU 4.4 */\n    UBLOCK_VEDIC_EXTENSIONS = 175, /*[1CD0]*/\n    /** @stable ICU 4.4 */\n    UBLOCK_LISU = 176, /*[A4D0]*/\n    /** @stable ICU 4.4 */\n    UBLOCK_BAMUM = 177, /*[A6A0]*/\n    /** @stable ICU 4.4 */\n    UBLOCK_COMMON_INDIC_NUMBER_FORMS = 178, /*[A830]*/\n    /** @stable ICU 4.4 */\n    UBLOCK_DEVANAGARI_EXTENDED = 179, /*[A8E0]*/\n    /** @stable ICU 4.4 */\n    UBLOCK_HANGUL_JAMO_EXTENDED_A = 180, /*[A960]*/\n    /** @stable ICU 4.4 */\n    UBLOCK_JAVANESE = 181, /*[A980]*/\n    /** @stable ICU 4.4 */\n    UBLOCK_MYANMAR_EXTENDED_A = 182, /*[AA60]*/\n    /** @stable ICU 4.4 */\n    UBLOCK_TAI_VIET = 183, /*[AA80]*/\n    /** @stable ICU 4.4 */\n    UBLOCK_MEETEI_MAYEK = 184, /*[ABC0]*/\n    /** @stable ICU 4.4 */\n    UBLOCK_HANGUL_JAMO_EXTENDED_B = 185, /*[D7B0]*/\n    /** @stable ICU 4.4 */\n    UBLOCK_IMPERIAL_ARAMAIC = 186, /*[10840]*/\n    /** @stable ICU 4.4 */\n    UBLOCK_OLD_SOUTH_ARABIAN = 187, /*[10A60]*/\n    /** @stable ICU 4.4 */\n    UBLOCK_AVESTAN = 188, /*[10B00]*/\n    /** @stable ICU 4.4 */\n    UBLOCK_INSCRIPTIONAL_PARTHIAN = 189, /*[10B40]*/\n    /** @stable ICU 4.4 */\n    UBLOCK_INSCRIPTIONAL_PAHLAVI = 190, /*[10B60]*/\n    /** @stable ICU 4.4 */\n    UBLOCK_OLD_TURKIC = 191, /*[10C00]*/\n    /** @stable ICU 4.4 */\n    UBLOCK_RUMI_NUMERAL_SYMBOLS = 192, /*[10E60]*/\n    /** @stable ICU 4.4 */\n    UBLOCK_KAITHI = 193, /*[11080]*/\n    /** @stable ICU 4.4 */\n    UBLOCK_EGYPTIAN_HIEROGLYPHS = 194, /*[13000]*/\n    /** @stable ICU 4.4 */\n    UBLOCK_ENCLOSED_ALPHANUMERIC_SUPPLEMENT = 195, /*[1F100]*/\n    /** @stable ICU 4.4 */\n    UBLOCK_ENCLOSED_IDEOGRAPHIC_SUPPLEMENT = 196, /*[1F200]*/\n    /** @stable ICU 4.4 */\n    UBLOCK_CJK_UNIFIED_IDEOGRAPHS_EXTENSION_C = 197, /*[2A700]*/\n\n    /* New blocks in Unicode 6.0 */\n\n    /** @stable ICU 4.6 */\n    UBLOCK_MANDAIC = 198, /*[0840]*/\n    /** @stable ICU 4.6 */\n    UBLOCK_BATAK = 199, /*[1BC0]*/\n    /** @stable ICU 4.6 */\n    UBLOCK_ETHIOPIC_EXTENDED_A = 200, /*[AB00]*/\n    /** @stable ICU 4.6 */\n    UBLOCK_BRAHMI = 201, /*[11000]*/\n    /** @stable ICU 4.6 */\n    UBLOCK_BAMUM_SUPPLEMENT = 202, /*[16800]*/\n    /** @stable ICU 4.6 */\n    UBLOCK_KANA_SUPPLEMENT = 203, /*[1B000]*/\n    /** @stable ICU 4.6 */\n    UBLOCK_PLAYING_CARDS = 204, /*[1F0A0]*/\n    /** @stable ICU 4.6 */\n    UBLOCK_MISCELLANEOUS_SYMBOLS_AND_PICTOGRAPHS = 205, /*[1F300]*/\n    /** @stable ICU 4.6 */\n    UBLOCK_EMOTICONS = 206, /*[1F600]*/\n    /** @stable ICU 4.6 */\n    UBLOCK_TRANSPORT_AND_MAP_SYMBOLS = 207, /*[1F680]*/\n    /** @stable ICU 4.6 */\n    UBLOCK_ALCHEMICAL_SYMBOLS = 208, /*[1F700]*/\n    /** @stable ICU 4.6 */\n    UBLOCK_CJK_UNIFIED_IDEOGRAPHS_EXTENSION_D = 209, /*[2B740]*/\n\n    /* New blocks in Unicode 6.1 */\n\n    /** @stable ICU 49 */\n    UBLOCK_ARABIC_EXTENDED_A = 210, /*[08A0]*/\n    /** @stable ICU 49 */\n    UBLOCK_ARABIC_MATHEMATICAL_ALPHABETIC_SYMBOLS = 211, /*[1EE00]*/\n    /** @stable ICU 49 */\n    UBLOCK_CHAKMA = 212, /*[11100]*/\n    /** @stable ICU 49 */\n    UBLOCK_MEETEI_MAYEK_EXTENSIONS = 213, /*[AAE0]*/\n    /** @stable ICU 49 */\n    UBLOCK_MEROITIC_CURSIVE = 214, /*[109A0]*/\n    /** @stable ICU 49 */\n    UBLOCK_MEROITIC_HIEROGLYPHS = 215, /*[10980]*/\n    /** @stable ICU 49 */\n    UBLOCK_MIAO = 216, /*[16F00]*/\n    /** @stable ICU 49 */\n    UBLOCK_SHARADA = 217, /*[11180]*/\n    /** @stable ICU 49 */\n    UBLOCK_SORA_SOMPENG = 218, /*[110D0]*/\n    /** @stable ICU 49 */\n    UBLOCK_SUNDANESE_SUPPLEMENT = 219, /*[1CC0]*/\n    /** @stable ICU 49 */\n    UBLOCK_TAKRI = 220, /*[11680]*/\n\n    /** @stable ICU 2.0 */\n    UBLOCK_COUNT = 221,\n\n    /** @stable ICU 2.0 */\n    UBLOCK_INVALID_CODE=-1\n};\n\n/** @stable ICU 2.0 */\ntypedef enum UBlockCode UBlockCode;\n\n/**\n * East Asian Width constants.\n *\n * @see UCHAR_EAST_ASIAN_WIDTH\n * @see u_getIntPropertyValue\n * @stable ICU 2.2\n */\ntypedef enum UEastAsianWidth {\n    /*\n     * Note: UEastAsianWidth constants are parsed by preparseucd.py.\n     * It matches lines like\n     *     U_EA_<Unicode East_Asian_Width value name>\n     */\n\n    U_EA_NEUTRAL,   /*[N]*/\n    U_EA_AMBIGUOUS, /*[A]*/\n    U_EA_HALFWIDTH, /*[H]*/\n    U_EA_FULLWIDTH, /*[F]*/\n    U_EA_NARROW,    /*[Na]*/\n    U_EA_WIDE,      /*[W]*/\n    U_EA_COUNT\n} UEastAsianWidth;\n\n/**\n * Selector constants for u_charName().\n * u_charName() returns the \"modern\" name of a\n * Unicode character; or the name that was defined in\n * Unicode version 1.0, before the Unicode standard merged\n * with ISO-10646; or an \"extended\" name that gives each\n * Unicode code point a unique name.\n *\n * @see u_charName\n * @stable ICU 2.0\n */\ntypedef enum UCharNameChoice {\n    /** Unicode character name (Name property). @stable ICU 2.0 */\n    U_UNICODE_CHAR_NAME,\n    /**\n     * The Unicode_1_Name property value which is of little practical value.\n     * Beginning with ICU 49, ICU APIs return an empty string for this name choice.\n     * @deprecated ICU 49\n     */\n    U_UNICODE_10_CHAR_NAME,\n    /** Standard or synthetic character name. @stable ICU 2.0 */\n    U_EXTENDED_CHAR_NAME,\n    /** Corrected name from NameAliases.txt. @stable ICU 4.4 */\n    U_CHAR_NAME_ALIAS,\n    /** @stable ICU 2.0 */\n    U_CHAR_NAME_CHOICE_COUNT\n} UCharNameChoice;\n\n/**\n * Selector constants for u_getPropertyName() and\n * u_getPropertyValueName().  These selectors are used to choose which\n * name is returned for a given property or value.  All properties and\n * values have a long name.  Most have a short name, but some do not.\n * Unicode allows for additional names, beyond the long and short\n * name, which would be indicated by U_LONG_PROPERTY_NAME + i, where\n * i=1, 2,...\n *\n * @see u_getPropertyName()\n * @see u_getPropertyValueName()\n * @stable ICU 2.4\n */\ntypedef enum UPropertyNameChoice {\n    U_SHORT_PROPERTY_NAME,\n    U_LONG_PROPERTY_NAME,\n    U_PROPERTY_NAME_CHOICE_COUNT\n} UPropertyNameChoice;\n\n/**\n * Decomposition Type constants.\n *\n * @see UCHAR_DECOMPOSITION_TYPE\n * @stable ICU 2.2\n */\ntypedef enum UDecompositionType {\n    /*\n     * Note: UDecompositionType constants are parsed by preparseucd.py.\n     * It matches lines like\n     *     U_DT_<Unicode Decomposition_Type value name>\n     */\n\n    U_DT_NONE,              /*[none]*/\n    U_DT_CANONICAL,         /*[can]*/\n    U_DT_COMPAT,            /*[com]*/\n    U_DT_CIRCLE,            /*[enc]*/\n    U_DT_FINAL,             /*[fin]*/\n    U_DT_FONT,              /*[font]*/\n    U_DT_FRACTION,          /*[fra]*/\n    U_DT_INITIAL,           /*[init]*/\n    U_DT_ISOLATED,          /*[iso]*/\n    U_DT_MEDIAL,            /*[med]*/\n    U_DT_NARROW,            /*[nar]*/\n    U_DT_NOBREAK,           /*[nb]*/\n    U_DT_SMALL,             /*[sml]*/\n    U_DT_SQUARE,            /*[sqr]*/\n    U_DT_SUB,               /*[sub]*/\n    U_DT_SUPER,             /*[sup]*/\n    U_DT_VERTICAL,          /*[vert]*/\n    U_DT_WIDE,              /*[wide]*/\n    U_DT_COUNT /* 18 */\n} UDecompositionType;\n\n/**\n * Joining Type constants.\n *\n * @see UCHAR_JOINING_TYPE\n * @stable ICU 2.2\n */\ntypedef enum UJoiningType {\n    /*\n     * Note: UJoiningType constants are parsed by preparseucd.py.\n     * It matches lines like\n     *     U_JT_<Unicode Joining_Type value name>\n     */\n\n    U_JT_NON_JOINING,       /*[U]*/\n    U_JT_JOIN_CAUSING,      /*[C]*/\n    U_JT_DUAL_JOINING,      /*[D]*/\n    U_JT_LEFT_JOINING,      /*[L]*/\n    U_JT_RIGHT_JOINING,     /*[R]*/\n    U_JT_TRANSPARENT,       /*[T]*/\n    U_JT_COUNT /* 6 */\n} UJoiningType;\n\n/**\n * Joining Group constants.\n *\n * @see UCHAR_JOINING_GROUP\n * @stable ICU 2.2\n */\ntypedef enum UJoiningGroup {\n    /*\n     * Note: UJoiningGroup constants are parsed by preparseucd.py.\n     * It matches lines like\n     *     U_JG_<Unicode Joining_Group value name>\n     */\n\n    U_JG_NO_JOINING_GROUP,\n    U_JG_AIN,\n    U_JG_ALAPH,\n    U_JG_ALEF,\n    U_JG_BEH,\n    U_JG_BETH,\n    U_JG_DAL,\n    U_JG_DALATH_RISH,\n    U_JG_E,\n    U_JG_FEH,\n    U_JG_FINAL_SEMKATH,\n    U_JG_GAF,\n    U_JG_GAMAL,\n    U_JG_HAH,\n    U_JG_TEH_MARBUTA_GOAL,  /**< @stable ICU 4.6 */\n    U_JG_HAMZA_ON_HEH_GOAL=U_JG_TEH_MARBUTA_GOAL,\n    U_JG_HE,\n    U_JG_HEH,\n    U_JG_HEH_GOAL,\n    U_JG_HETH,\n    U_JG_KAF,\n    U_JG_KAPH,\n    U_JG_KNOTTED_HEH,\n    U_JG_LAM,\n    U_JG_LAMADH,\n    U_JG_MEEM,\n    U_JG_MIM,\n    U_JG_NOON,\n    U_JG_NUN,\n    U_JG_PE,\n    U_JG_QAF,\n    U_JG_QAPH,\n    U_JG_REH,\n    U_JG_REVERSED_PE,\n    U_JG_SAD,\n    U_JG_SADHE,\n    U_JG_SEEN,\n    U_JG_SEMKATH,\n    U_JG_SHIN,\n    U_JG_SWASH_KAF,\n    U_JG_SYRIAC_WAW,\n    U_JG_TAH,\n    U_JG_TAW,\n    U_JG_TEH_MARBUTA,\n    U_JG_TETH,\n    U_JG_WAW,\n    U_JG_YEH,\n    U_JG_YEH_BARREE,\n    U_JG_YEH_WITH_TAIL,\n    U_JG_YUDH,\n    U_JG_YUDH_HE,\n    U_JG_ZAIN,\n    U_JG_FE,        /**< @stable ICU 2.6 */\n    U_JG_KHAPH,     /**< @stable ICU 2.6 */\n    U_JG_ZHAIN,     /**< @stable ICU 2.6 */\n    U_JG_BURUSHASKI_YEH_BARREE, /**< @stable ICU 4.0 */\n    U_JG_FARSI_YEH, /**< @stable ICU 4.4 */\n    U_JG_NYA,       /**< @stable ICU 4.4 */\n    U_JG_ROHINGYA_YEH,  /**< @stable ICU 49 */\n    U_JG_COUNT\n} UJoiningGroup;\n\n/**\n * Grapheme Cluster Break constants.\n *\n * @see UCHAR_GRAPHEME_CLUSTER_BREAK\n * @stable ICU 3.4\n */\ntypedef enum UGraphemeClusterBreak {\n    /*\n     * Note: UGraphemeClusterBreak constants are parsed by preparseucd.py.\n     * It matches lines like\n     *     U_GCB_<Unicode Grapheme_Cluster_Break value name>\n     */\n\n    U_GCB_OTHER = 0,            /*[XX]*/\n    U_GCB_CONTROL = 1,          /*[CN]*/\n    U_GCB_CR = 2,               /*[CR]*/\n    U_GCB_EXTEND = 3,           /*[EX]*/\n    U_GCB_L = 4,                /*[L]*/\n    U_GCB_LF = 5,               /*[LF]*/\n    U_GCB_LV = 6,               /*[LV]*/\n    U_GCB_LVT = 7,              /*[LVT]*/\n    U_GCB_T = 8,                /*[T]*/\n    U_GCB_V = 9,                /*[V]*/\n    U_GCB_SPACING_MARK = 10,    /*[SM]*/ /* from here on: new in Unicode 5.1/ICU 4.0 */\n    U_GCB_PREPEND = 11,         /*[PP]*/\n    U_GCB_REGIONAL_INDICATOR = 12,  /*[RI]*/ /* new in Unicode 6.2/ICU 50 */\n    U_GCB_COUNT = 13\n} UGraphemeClusterBreak;\n\n/**\n * Word Break constants.\n * (UWordBreak is a pre-existing enum type in ubrk.h for word break status tags.)\n *\n * @see UCHAR_WORD_BREAK\n * @stable ICU 3.4\n */\ntypedef enum UWordBreakValues {\n    /*\n     * Note: UWordBreakValues constants are parsed by preparseucd.py.\n     * It matches lines like\n     *     U_WB_<Unicode Word_Break value name>\n     */\n\n    U_WB_OTHER = 0,             /*[XX]*/\n    U_WB_ALETTER = 1,           /*[LE]*/\n    U_WB_FORMAT = 2,            /*[FO]*/\n    U_WB_KATAKANA = 3,          /*[KA]*/\n    U_WB_MIDLETTER = 4,         /*[ML]*/\n    U_WB_MIDNUM = 5,            /*[MN]*/\n    U_WB_NUMERIC = 6,           /*[NU]*/\n    U_WB_EXTENDNUMLET = 7,      /*[EX]*/\n    U_WB_CR = 8,                /*[CR]*/ /* from here on: new in Unicode 5.1/ICU 4.0 */\n    U_WB_EXTEND = 9,            /*[Extend]*/\n    U_WB_LF = 10,               /*[LF]*/\n    U_WB_MIDNUMLET =11,         /*[MB]*/\n    U_WB_NEWLINE =12,           /*[NL]*/\n    U_WB_REGIONAL_INDICATOR = 13,   /*[RI]*/ /* new in Unicode 6.2/ICU 50 */\n    U_WB_COUNT = 14\n} UWordBreakValues;\n\n/**\n * Sentence Break constants.\n *\n * @see UCHAR_SENTENCE_BREAK\n * @stable ICU 3.4\n */\ntypedef enum USentenceBreak {\n    /*\n     * Note: USentenceBreak constants are parsed by preparseucd.py.\n     * It matches lines like\n     *     U_SB_<Unicode Sentence_Break value name>\n     */\n\n    U_SB_OTHER = 0,             /*[XX]*/\n    U_SB_ATERM = 1,             /*[AT]*/\n    U_SB_CLOSE = 2,             /*[CL]*/\n    U_SB_FORMAT = 3,            /*[FO]*/\n    U_SB_LOWER = 4,             /*[LO]*/\n    U_SB_NUMERIC = 5,           /*[NU]*/\n    U_SB_OLETTER = 6,           /*[LE]*/\n    U_SB_SEP = 7,               /*[SE]*/\n    U_SB_SP = 8,                /*[SP]*/\n    U_SB_STERM = 9,             /*[ST]*/\n    U_SB_UPPER = 10,            /*[UP]*/\n    U_SB_CR = 11,               /*[CR]*/ /* from here on: new in Unicode 5.1/ICU 4.0 */\n    U_SB_EXTEND = 12,           /*[EX]*/\n    U_SB_LF = 13,               /*[LF]*/\n    U_SB_SCONTINUE = 14,        /*[SC]*/\n    U_SB_COUNT = 15\n} USentenceBreak;\n\n/**\n * Line Break constants.\n *\n * @see UCHAR_LINE_BREAK\n * @stable ICU 2.2\n */\ntypedef enum ULineBreak {\n    /*\n     * Note: ULineBreak constants are parsed by preparseucd.py.\n     * It matches lines like\n     *     U_LB_<Unicode Line_Break value name>\n     */\n\n    U_LB_UNKNOWN = 0,           /*[XX]*/\n    U_LB_AMBIGUOUS = 1,         /*[AI]*/\n    U_LB_ALPHABETIC = 2,        /*[AL]*/\n    U_LB_BREAK_BOTH = 3,        /*[B2]*/\n    U_LB_BREAK_AFTER = 4,       /*[BA]*/\n    U_LB_BREAK_BEFORE = 5,      /*[BB]*/\n    U_LB_MANDATORY_BREAK = 6,   /*[BK]*/\n    U_LB_CONTINGENT_BREAK = 7,  /*[CB]*/\n    U_LB_CLOSE_PUNCTUATION = 8, /*[CL]*/\n    U_LB_COMBINING_MARK = 9,    /*[CM]*/\n    U_LB_CARRIAGE_RETURN = 10,   /*[CR]*/\n    U_LB_EXCLAMATION = 11,       /*[EX]*/\n    U_LB_GLUE = 12,              /*[GL]*/\n    U_LB_HYPHEN = 13,            /*[HY]*/\n    U_LB_IDEOGRAPHIC = 14,       /*[ID]*/\n    /** Renamed from the misspelled \"inseperable\" in Unicode 4.0.1/ICU 3.0 @stable ICU 3.0 */\n    U_LB_INSEPARABLE = 15,       /*[IN]*/\n    U_LB_INSEPERABLE = U_LB_INSEPARABLE,\n    U_LB_INFIX_NUMERIC = 16,     /*[IS]*/\n    U_LB_LINE_FEED = 17,         /*[LF]*/\n    U_LB_NONSTARTER = 18,        /*[NS]*/\n    U_LB_NUMERIC = 19,           /*[NU]*/\n    U_LB_OPEN_PUNCTUATION = 20,  /*[OP]*/\n    U_LB_POSTFIX_NUMERIC = 21,   /*[PO]*/\n    U_LB_PREFIX_NUMERIC = 22,    /*[PR]*/\n    U_LB_QUOTATION = 23,         /*[QU]*/\n    U_LB_COMPLEX_CONTEXT = 24,   /*[SA]*/\n    U_LB_SURROGATE = 25,         /*[SG]*/\n    U_LB_SPACE = 26,             /*[SP]*/\n    U_LB_BREAK_SYMBOLS = 27,     /*[SY]*/\n    U_LB_ZWSPACE = 28,           /*[ZW]*/\n    U_LB_NEXT_LINE = 29,         /*[NL]*/ /* from here on: new in Unicode 4/ICU 2.6 */\n    U_LB_WORD_JOINER = 30,       /*[WJ]*/\n    U_LB_H2 = 31,                /*[H2]*/ /* from here on: new in Unicode 4.1/ICU 3.4 */\n    U_LB_H3 = 32,                /*[H3]*/\n    U_LB_JL = 33,                /*[JL]*/\n    U_LB_JT = 34,                /*[JT]*/\n    U_LB_JV = 35,                /*[JV]*/\n    U_LB_CLOSE_PARENTHESIS = 36, /*[CP]*/ /* new in Unicode 5.2/ICU 4.4 */\n    U_LB_CONDITIONAL_JAPANESE_STARTER = 37,/*[CJ]*/ /* new in Unicode 6.1/ICU 49 */\n    U_LB_HEBREW_LETTER = 38,     /*[HL]*/ /* new in Unicode 6.1/ICU 49 */\n    U_LB_REGIONAL_INDICATOR = 39,/*[RI]*/ /* new in Unicode 6.2/ICU 50 */\n    U_LB_COUNT = 40\n} ULineBreak;\n\n/**\n * Numeric Type constants.\n *\n * @see UCHAR_NUMERIC_TYPE\n * @stable ICU 2.2\n */\ntypedef enum UNumericType {\n    /*\n     * Note: UNumericType constants are parsed by preparseucd.py.\n     * It matches lines like\n     *     U_NT_<Unicode Numeric_Type value name>\n     */\n\n    U_NT_NONE,              /*[None]*/\n    U_NT_DECIMAL,           /*[de]*/\n    U_NT_DIGIT,             /*[di]*/\n    U_NT_NUMERIC,           /*[nu]*/\n    U_NT_COUNT\n} UNumericType;\n\n/**\n * Hangul Syllable Type constants.\n *\n * @see UCHAR_HANGUL_SYLLABLE_TYPE\n * @stable ICU 2.6\n */\ntypedef enum UHangulSyllableType {\n    /*\n     * Note: UHangulSyllableType constants are parsed by preparseucd.py.\n     * It matches lines like\n     *     U_HST_<Unicode Hangul_Syllable_Type value name>\n     */\n\n    U_HST_NOT_APPLICABLE,   /*[NA]*/\n    U_HST_LEADING_JAMO,     /*[L]*/\n    U_HST_VOWEL_JAMO,       /*[V]*/\n    U_HST_TRAILING_JAMO,    /*[T]*/\n    U_HST_LV_SYLLABLE,      /*[LV]*/\n    U_HST_LVT_SYLLABLE,     /*[LVT]*/\n    U_HST_COUNT\n} UHangulSyllableType;\n\n/**\n * Check a binary Unicode property for a code point.\n *\n * Unicode, especially in version 3.2, defines many more properties than the\n * original set in UnicodeData.txt.\n *\n * The properties APIs are intended to reflect Unicode properties as defined\n * in the Unicode Character Database (UCD) and Unicode Technical Reports (UTR).\n * For details about the properties see http://www.unicode.org/ucd/ .\n * For names of Unicode properties see the UCD file PropertyAliases.txt.\n *\n * Important: If ICU is built with UCD files from Unicode versions below 3.2,\n * then properties marked with \"new in Unicode 3.2\" are not or not fully available.\n *\n * @param c Code point to test.\n * @param which UProperty selector constant, identifies which binary property to check.\n *        Must be UCHAR_BINARY_START<=which<UCHAR_BINARY_LIMIT.\n * @return TRUE or FALSE according to the binary Unicode property value for c.\n *         Also FALSE if 'which' is out of bounds or if the Unicode version\n *         does not have data for the property at all, or not for this code point.\n *\n * @see UProperty\n * @see u_getIntPropertyValue\n * @see u_getUnicodeVersion\n * @stable ICU 2.1\n */\nU_STABLE UBool U_EXPORT2\nu_hasBinaryProperty(UChar32 c, UProperty which);\n\n/**\n * Check if a code point has the Alphabetic Unicode property.\n * Same as u_hasBinaryProperty(c, UCHAR_ALPHABETIC).\n * This is different from u_isalpha!\n * @param c Code point to test\n * @return true if the code point has the Alphabetic Unicode property, false otherwise\n *\n * @see UCHAR_ALPHABETIC\n * @see u_isalpha\n * @see u_hasBinaryProperty\n * @stable ICU 2.1\n */\nU_STABLE UBool U_EXPORT2\nu_isUAlphabetic(UChar32 c);\n\n/**\n * Check if a code point has the Lowercase Unicode property.\n * Same as u_hasBinaryProperty(c, UCHAR_LOWERCASE).\n * This is different from u_islower!\n * @param c Code point to test\n * @return true if the code point has the Lowercase Unicode property, false otherwise\n *\n * @see UCHAR_LOWERCASE\n * @see u_islower\n * @see u_hasBinaryProperty\n * @stable ICU 2.1\n */\nU_STABLE UBool U_EXPORT2\nu_isULowercase(UChar32 c);\n\n/**\n * Check if a code point has the Uppercase Unicode property.\n * Same as u_hasBinaryProperty(c, UCHAR_UPPERCASE).\n * This is different from u_isupper!\n * @param c Code point to test\n * @return true if the code point has the Uppercase Unicode property, false otherwise\n *\n * @see UCHAR_UPPERCASE\n * @see u_isupper\n * @see u_hasBinaryProperty\n * @stable ICU 2.1\n */\nU_STABLE UBool U_EXPORT2\nu_isUUppercase(UChar32 c);\n\n/**\n * Check if a code point has the White_Space Unicode property.\n * Same as u_hasBinaryProperty(c, UCHAR_WHITE_SPACE).\n * This is different from both u_isspace and u_isWhitespace!\n *\n * Note: There are several ICU whitespace functions; please see the uchar.h\n * file documentation for a detailed comparison.\n *\n * @param c Code point to test\n * @return true if the code point has the White_Space Unicode property, false otherwise.\n *\n * @see UCHAR_WHITE_SPACE\n * @see u_isWhitespace\n * @see u_isspace\n * @see u_isJavaSpaceChar\n * @see u_hasBinaryProperty\n * @stable ICU 2.1\n */\nU_STABLE UBool U_EXPORT2\nu_isUWhiteSpace(UChar32 c);\n\n/**\n * Get the property value for an enumerated or integer Unicode property for a code point.\n * Also returns binary and mask property values.\n *\n * Unicode, especially in version 3.2, defines many more properties than the\n * original set in UnicodeData.txt.\n *\n * The properties APIs are intended to reflect Unicode properties as defined\n * in the Unicode Character Database (UCD) and Unicode Technical Reports (UTR).\n * For details about the properties see http://www.unicode.org/ .\n * For names of Unicode properties see the UCD file PropertyAliases.txt.\n *\n * Sample usage:\n * UEastAsianWidth ea=(UEastAsianWidth)u_getIntPropertyValue(c, UCHAR_EAST_ASIAN_WIDTH);\n * UBool b=(UBool)u_getIntPropertyValue(c, UCHAR_IDEOGRAPHIC);\n *\n * @param c Code point to test.\n * @param which UProperty selector constant, identifies which property to check.\n *        Must be UCHAR_BINARY_START<=which<UCHAR_BINARY_LIMIT\n *        or UCHAR_INT_START<=which<UCHAR_INT_LIMIT\n *        or UCHAR_MASK_START<=which<UCHAR_MASK_LIMIT.\n * @return Numeric value that is directly the property value or,\n *         for enumerated properties, corresponds to the numeric value of the enumerated\n *         constant of the respective property value enumeration type\n *         (cast to enum type if necessary).\n *         Returns 0 or 1 (for FALSE/TRUE) for binary Unicode properties.\n *         Returns a bit-mask for mask properties.\n *         Returns 0 if 'which' is out of bounds or if the Unicode version\n *         does not have data for the property at all, or not for this code point.\n *\n * @see UProperty\n * @see u_hasBinaryProperty\n * @see u_getIntPropertyMinValue\n * @see u_getIntPropertyMaxValue\n * @see u_getUnicodeVersion\n * @stable ICU 2.2\n */\nU_STABLE int32_t U_EXPORT2\nu_getIntPropertyValue(UChar32 c, UProperty which);\n\n/**\n * Get the minimum value for an enumerated/integer/binary Unicode property.\n * Can be used together with u_getIntPropertyMaxValue\n * to allocate arrays of UnicodeSet or similar.\n *\n * @param which UProperty selector constant, identifies which binary property to check.\n *        Must be UCHAR_BINARY_START<=which<UCHAR_BINARY_LIMIT\n *        or UCHAR_INT_START<=which<UCHAR_INT_LIMIT.\n * @return Minimum value returned by u_getIntPropertyValue for a Unicode property.\n *         0 if the property selector is out of range.\n *\n * @see UProperty\n * @see u_hasBinaryProperty\n * @see u_getUnicodeVersion\n * @see u_getIntPropertyMaxValue\n * @see u_getIntPropertyValue\n * @stable ICU 2.2\n */\nU_STABLE int32_t U_EXPORT2\nu_getIntPropertyMinValue(UProperty which);\n\n/**\n * Get the maximum value for an enumerated/integer/binary Unicode property.\n * Can be used together with u_getIntPropertyMinValue\n * to allocate arrays of UnicodeSet or similar.\n *\n * Examples for min/max values (for Unicode 3.2):\n *\n * - UCHAR_BIDI_CLASS:    0/18 (U_LEFT_TO_RIGHT/U_BOUNDARY_NEUTRAL)\n * - UCHAR_SCRIPT:        0/45 (USCRIPT_COMMON/USCRIPT_TAGBANWA)\n * - UCHAR_IDEOGRAPHIC:   0/1  (FALSE/TRUE)\n *\n * For undefined UProperty constant values, min/max values will be 0/-1.\n *\n * @param which UProperty selector constant, identifies which binary property to check.\n *        Must be UCHAR_BINARY_START<=which<UCHAR_BINARY_LIMIT\n *        or UCHAR_INT_START<=which<UCHAR_INT_LIMIT.\n * @return Maximum value returned by u_getIntPropertyValue for a Unicode property.\n *         <=0 if the property selector is out of range.\n *\n * @see UProperty\n * @see u_hasBinaryProperty\n * @see u_getUnicodeVersion\n * @see u_getIntPropertyMaxValue\n * @see u_getIntPropertyValue\n * @stable ICU 2.2\n */\nU_STABLE int32_t U_EXPORT2\nu_getIntPropertyMaxValue(UProperty which);\n\n/**\n * Get the numeric value for a Unicode code point as defined in the\n * Unicode Character Database.\n *\n * A \"double\" return type is necessary because\n * some numeric values are fractions, negative, or too large for int32_t.\n *\n * For characters without any numeric values in the Unicode Character Database,\n * this function will return U_NO_NUMERIC_VALUE.\n * Note: This is different from the Unicode Standard which specifies NaN as the default value.\n * (NaN is not available on all platforms.)\n *\n * Similar to java.lang.Character.getNumericValue(), but u_getNumericValue()\n * also supports negative values, large values, and fractions,\n * while Java's getNumericValue() returns values 10..35 for ASCII letters.\n *\n * @param c Code point to get the numeric value for.\n * @return Numeric value of c, or U_NO_NUMERIC_VALUE if none is defined.\n *\n * @see U_NO_NUMERIC_VALUE\n * @stable ICU 2.2\n */\nU_STABLE double U_EXPORT2\nu_getNumericValue(UChar32 c);\n\n/**\n * Special value that is returned by u_getNumericValue when\n * no numeric value is defined for a code point.\n *\n * @see u_getNumericValue\n * @stable ICU 2.2\n */\n#define U_NO_NUMERIC_VALUE ((double)-123456789.)\n\n/**\n * Determines whether the specified code point has the general category \"Ll\"\n * (lowercase letter).\n *\n * Same as java.lang.Character.isLowerCase().\n *\n * This misses some characters that are also lowercase but\n * have a different general category value.\n * In order to include those, use UCHAR_LOWERCASE.\n *\n * In addition to being equivalent to a Java function, this also serves\n * as a C/POSIX migration function.\n * See the comments about C/POSIX character classification functions in the\n * documentation at the top of this header file.\n *\n * @param c the code point to be tested\n * @return TRUE if the code point is an Ll lowercase letter\n *\n * @see UCHAR_LOWERCASE\n * @see u_isupper\n * @see u_istitle\n * @stable ICU 2.0\n */\nU_STABLE UBool U_EXPORT2\nu_islower(UChar32 c);\n\n/**\n * Determines whether the specified code point has the general category \"Lu\"\n * (uppercase letter).\n *\n * Same as java.lang.Character.isUpperCase().\n *\n * This misses some characters that are also uppercase but\n * have a different general category value.\n * In order to include those, use UCHAR_UPPERCASE.\n *\n * In addition to being equivalent to a Java function, this also serves\n * as a C/POSIX migration function.\n * See the comments about C/POSIX character classification functions in the\n * documentation at the top of this header file.\n *\n * @param c the code point to be tested\n * @return TRUE if the code point is an Lu uppercase letter\n *\n * @see UCHAR_UPPERCASE\n * @see u_islower\n * @see u_istitle\n * @see u_tolower\n * @stable ICU 2.0\n */\nU_STABLE UBool U_EXPORT2\nu_isupper(UChar32 c);\n\n/**\n * Determines whether the specified code point is a titlecase letter.\n * True for general category \"Lt\" (titlecase letter).\n *\n * Same as java.lang.Character.isTitleCase().\n *\n * @param c the code point to be tested\n * @return TRUE if the code point is an Lt titlecase letter\n *\n * @see u_isupper\n * @see u_islower\n * @see u_totitle\n * @stable ICU 2.0\n */\nU_STABLE UBool U_EXPORT2\nu_istitle(UChar32 c);\n\n/**\n * Determines whether the specified code point is a digit character according to Java.\n * True for characters with general category \"Nd\" (decimal digit numbers).\n * Beginning with Unicode 4, this is the same as\n * testing for the Numeric_Type of Decimal.\n *\n * Same as java.lang.Character.isDigit().\n *\n * In addition to being equivalent to a Java function, this also serves\n * as a C/POSIX migration function.\n * See the comments about C/POSIX character classification functions in the\n * documentation at the top of this header file.\n *\n * @param c the code point to be tested\n * @return TRUE if the code point is a digit character according to Character.isDigit()\n *\n * @stable ICU 2.0\n */\nU_STABLE UBool U_EXPORT2\nu_isdigit(UChar32 c);\n\n/**\n * Determines whether the specified code point is a letter character.\n * True for general categories \"L\" (letters).\n *\n * Same as java.lang.Character.isLetter().\n *\n * In addition to being equivalent to a Java function, this also serves\n * as a C/POSIX migration function.\n * See the comments about C/POSIX character classification functions in the\n * documentation at the top of this header file.\n *\n * @param c the code point to be tested\n * @return TRUE if the code point is a letter character\n *\n * @see u_isdigit\n * @see u_isalnum\n * @stable ICU 2.0\n */\nU_STABLE UBool U_EXPORT2\nu_isalpha(UChar32 c);\n\n/**\n * Determines whether the specified code point is an alphanumeric character\n * (letter or digit) according to Java.\n * True for characters with general categories\n * \"L\" (letters) and \"Nd\" (decimal digit numbers).\n *\n * Same as java.lang.Character.isLetterOrDigit().\n *\n * In addition to being equivalent to a Java function, this also serves\n * as a C/POSIX migration function.\n * See the comments about C/POSIX character classification functions in the\n * documentation at the top of this header file.\n *\n * @param c the code point to be tested\n * @return TRUE if the code point is an alphanumeric character according to Character.isLetterOrDigit()\n *\n * @stable ICU 2.0\n */\nU_STABLE UBool U_EXPORT2\nu_isalnum(UChar32 c);\n\n/**\n * Determines whether the specified code point is a hexadecimal digit.\n * This is equivalent to u_digit(c, 16)>=0.\n * True for characters with general category \"Nd\" (decimal digit numbers)\n * as well as Latin letters a-f and A-F in both ASCII and Fullwidth ASCII.\n * (That is, for letters with code points\n * 0041..0046, 0061..0066, FF21..FF26, FF41..FF46.)\n *\n * In order to narrow the definition of hexadecimal digits to only ASCII\n * characters, use (c<=0x7f && u_isxdigit(c)).\n *\n * This is a C/POSIX migration function.\n * See the comments about C/POSIX character classification functions in the\n * documentation at the top of this header file.\n *\n * @param c the code point to be tested\n * @return TRUE if the code point is a hexadecimal digit\n *\n * @stable ICU 2.6\n */\nU_STABLE UBool U_EXPORT2\nu_isxdigit(UChar32 c);\n\n/**\n * Determines whether the specified code point is a punctuation character.\n * True for characters with general categories \"P\" (punctuation).\n *\n * This is a C/POSIX migration function.\n * See the comments about C/POSIX character classification functions in the\n * documentation at the top of this header file.\n *\n * @param c the code point to be tested\n * @return TRUE if the code point is a punctuation character\n *\n * @stable ICU 2.6\n */\nU_STABLE UBool U_EXPORT2\nu_ispunct(UChar32 c);\n\n/**\n * Determines whether the specified code point is a \"graphic\" character\n * (printable, excluding spaces).\n * TRUE for all characters except those with general categories\n * \"Cc\" (control codes), \"Cf\" (format controls), \"Cs\" (surrogates),\n * \"Cn\" (unassigned), and \"Z\" (separators).\n *\n * This is a C/POSIX migration function.\n * See the comments about C/POSIX character classification functions in the\n * documentation at the top of this header file.\n *\n * @param c the code point to be tested\n * @return TRUE if the code point is a \"graphic\" character\n *\n * @stable ICU 2.6\n */\nU_STABLE UBool U_EXPORT2\nu_isgraph(UChar32 c);\n\n/**\n * Determines whether the specified code point is a \"blank\" or \"horizontal space\",\n * a character that visibly separates words on a line.\n * The following are equivalent definitions:\n *\n * TRUE for Unicode White_Space characters except for \"vertical space controls\"\n * where \"vertical space controls\" are the following characters:\n * U+000A (LF) U+000B (VT) U+000C (FF) U+000D (CR) U+0085 (NEL) U+2028 (LS) U+2029 (PS)\n *\n * same as\n *\n * TRUE for U+0009 (TAB) and characters with general category \"Zs\" (space separators)\n * except Zero Width Space (ZWSP, U+200B).\n *\n * Note: There are several ICU whitespace functions; please see the uchar.h\n * file documentation for a detailed comparison.\n *\n * This is a C/POSIX migration function.\n * See the comments about C/POSIX character classification functions in the\n * documentation at the top of this header file.\n *\n * @param c the code point to be tested\n * @return TRUE if the code point is a \"blank\"\n *\n * @stable ICU 2.6\n */\nU_STABLE UBool U_EXPORT2\nu_isblank(UChar32 c);\n\n/**\n * Determines whether the specified code point is \"defined\",\n * which usually means that it is assigned a character.\n * True for general categories other than \"Cn\" (other, not assigned),\n * i.e., true for all code points mentioned in UnicodeData.txt.\n *\n * Note that non-character code points (e.g., U+FDD0) are not \"defined\"\n * (they are Cn), but surrogate code points are \"defined\" (Cs).\n *\n * Same as java.lang.Character.isDefined().\n *\n * @param c the code point to be tested\n * @return TRUE if the code point is assigned a character\n *\n * @see u_isdigit\n * @see u_isalpha\n * @see u_isalnum\n * @see u_isupper\n * @see u_islower\n * @see u_istitle\n * @stable ICU 2.0\n */\nU_STABLE UBool U_EXPORT2\nu_isdefined(UChar32 c);\n\n/**\n * Determines if the specified character is a space character or not.\n *\n * Note: There are several ICU whitespace functions; please see the uchar.h\n * file documentation for a detailed comparison.\n *\n * This is a C/POSIX migration function.\n * See the comments about C/POSIX character classification functions in the\n * documentation at the top of this header file.\n *\n * @param c    the character to be tested\n * @return  true if the character is a space character; false otherwise.\n *\n * @see u_isJavaSpaceChar\n * @see u_isWhitespace\n * @see u_isUWhiteSpace\n * @stable ICU 2.0\n */\nU_STABLE UBool U_EXPORT2\nu_isspace(UChar32 c);\n\n/**\n * Determine if the specified code point is a space character according to Java.\n * True for characters with general categories \"Z\" (separators),\n * which does not include control codes (e.g., TAB or Line Feed).\n *\n * Same as java.lang.Character.isSpaceChar().\n *\n * Note: There are several ICU whitespace functions; please see the uchar.h\n * file documentation for a detailed comparison.\n *\n * @param c the code point to be tested\n * @return TRUE if the code point is a space character according to Character.isSpaceChar()\n *\n * @see u_isspace\n * @see u_isWhitespace\n * @see u_isUWhiteSpace\n * @stable ICU 2.6\n */\nU_STABLE UBool U_EXPORT2\nu_isJavaSpaceChar(UChar32 c);\n\n/**\n * Determines if the specified code point is a whitespace character according to Java/ICU.\n * A character is considered to be a Java whitespace character if and only\n * if it satisfies one of the following criteria:\n *\n * - It is a Unicode Separator character (categories \"Z\" = \"Zs\" or \"Zl\" or \"Zp\"), but is not\n *      also a non-breaking space (U+00A0 NBSP or U+2007 Figure Space or U+202F Narrow NBSP).\n * - It is U+0009 HORIZONTAL TABULATION.\n * - It is U+000A LINE FEED.\n * - It is U+000B VERTICAL TABULATION.\n * - It is U+000C FORM FEED.\n * - It is U+000D CARRIAGE RETURN.\n * - It is U+001C FILE SEPARATOR.\n * - It is U+001D GROUP SEPARATOR.\n * - It is U+001E RECORD SEPARATOR.\n * - It is U+001F UNIT SEPARATOR.\n *\n * This API tries to sync with the semantics of Java's\n * java.lang.Character.isWhitespace(), but it may not return\n * the exact same results because of the Unicode version\n * difference.\n *\n * Note: Unicode 4.0.1 changed U+200B ZERO WIDTH SPACE from a Space Separator (Zs)\n * to a Format Control (Cf). Since then, isWhitespace(0x200b) returns false.\n * See http://www.unicode.org/versions/Unicode4.0.1/\n *\n * Note: There are several ICU whitespace functions; please see the uchar.h\n * file documentation for a detailed comparison.\n *\n * @param c the code point to be tested\n * @return TRUE if the code point is a whitespace character according to Java/ICU\n *\n * @see u_isspace\n * @see u_isJavaSpaceChar\n * @see u_isUWhiteSpace\n * @stable ICU 2.0\n */\nU_STABLE UBool U_EXPORT2\nu_isWhitespace(UChar32 c);\n\n/**\n * Determines whether the specified code point is a control character\n * (as defined by this function).\n * A control character is one of the following:\n * - ISO 8-bit control character (U+0000..U+001f and U+007f..U+009f)\n * - U_CONTROL_CHAR (Cc)\n * - U_FORMAT_CHAR (Cf)\n * - U_LINE_SEPARATOR (Zl)\n * - U_PARAGRAPH_SEPARATOR (Zp)\n *\n * This is a C/POSIX migration function.\n * See the comments about C/POSIX character classification functions in the\n * documentation at the top of this header file.\n *\n * @param c the code point to be tested\n * @return TRUE if the code point is a control character\n *\n * @see UCHAR_DEFAULT_IGNORABLE_CODE_POINT\n * @see u_isprint\n * @stable ICU 2.0\n */\nU_STABLE UBool U_EXPORT2\nu_iscntrl(UChar32 c);\n\n/**\n * Determines whether the specified code point is an ISO control code.\n * True for U+0000..U+001f and U+007f..U+009f (general category \"Cc\").\n *\n * Same as java.lang.Character.isISOControl().\n *\n * @param c the code point to be tested\n * @return TRUE if the code point is an ISO control code\n *\n * @see u_iscntrl\n * @stable ICU 2.6\n */\nU_STABLE UBool U_EXPORT2\nu_isISOControl(UChar32 c);\n\n/**\n * Determines whether the specified code point is a printable character.\n * True for general categories <em>other</em> than \"C\" (controls).\n *\n * This is a C/POSIX migration function.\n * See the comments about C/POSIX character classification functions in the\n * documentation at the top of this header file.\n *\n * @param c the code point to be tested\n * @return TRUE if the code point is a printable character\n *\n * @see UCHAR_DEFAULT_IGNORABLE_CODE_POINT\n * @see u_iscntrl\n * @stable ICU 2.0\n */\nU_STABLE UBool U_EXPORT2\nu_isprint(UChar32 c);\n\n/**\n * Determines whether the specified code point is a base character.\n * True for general categories \"L\" (letters), \"N\" (numbers),\n * \"Mc\" (spacing combining marks), and \"Me\" (enclosing marks).\n *\n * Note that this is different from the Unicode definition in\n * chapter 3.5, conformance clause D13,\n * which defines base characters to be all characters (not Cn)\n * that do not graphically combine with preceding characters (M)\n * and that are neither control (Cc) or format (Cf) characters.\n *\n * @param c the code point to be tested\n * @return TRUE if the code point is a base character according to this function\n *\n * @see u_isalpha\n * @see u_isdigit\n * @stable ICU 2.0\n */\nU_STABLE UBool U_EXPORT2\nu_isbase(UChar32 c);\n\n/**\n * Returns the bidirectional category value for the code point,\n * which is used in the Unicode bidirectional algorithm\n * (UAX #9 http://www.unicode.org/reports/tr9/).\n * Note that some <em>unassigned</em> code points have bidi values\n * of R or AL because they are in blocks that are reserved\n * for Right-To-Left scripts.\n *\n * Same as java.lang.Character.getDirectionality()\n *\n * @param c the code point to be tested\n * @return the bidirectional category (UCharDirection) value\n *\n * @see UCharDirection\n * @stable ICU 2.0\n */\nU_STABLE UCharDirection U_EXPORT2\nu_charDirection(UChar32 c);\n\n/**\n * Determines whether the code point has the Bidi_Mirrored property.\n * This property is set for characters that are commonly used in\n * Right-To-Left contexts and need to be displayed with a \"mirrored\"\n * glyph.\n *\n * Same as java.lang.Character.isMirrored().\n * Same as UCHAR_BIDI_MIRRORED\n *\n * @param c the code point to be tested\n * @return TRUE if the character has the Bidi_Mirrored property\n *\n * @see UCHAR_BIDI_MIRRORED\n * @stable ICU 2.0\n */\nU_STABLE UBool U_EXPORT2\nu_isMirrored(UChar32 c);\n\n/**\n * Maps the specified character to a \"mirror-image\" character.\n * For characters with the Bidi_Mirrored property, implementations\n * sometimes need a \"poor man's\" mapping to another Unicode\n * character (code point) such that the default glyph may serve\n * as the mirror-image of the default glyph of the specified\n * character. This is useful for text conversion to and from\n * codepages with visual order, and for displays without glyph\n * selecetion capabilities.\n *\n * @param c the code point to be mapped\n * @return another Unicode code point that may serve as a mirror-image\n *         substitute, or c itself if there is no such mapping or c\n *         does not have the Bidi_Mirrored property\n *\n * @see UCHAR_BIDI_MIRRORED\n * @see u_isMirrored\n * @stable ICU 2.0\n */\nU_STABLE UChar32 U_EXPORT2\nu_charMirror(UChar32 c);\n\n/**\n * Returns the general category value for the code point.\n *\n * Same as java.lang.Character.getType().\n *\n * @param c the code point to be tested\n * @return the general category (UCharCategory) value\n *\n * @see UCharCategory\n * @stable ICU 2.0\n */\nU_STABLE int8_t U_EXPORT2\nu_charType(UChar32 c);\n\n/**\n * Get a single-bit bit set for the general category of a character.\n * This bit set can be compared bitwise with U_GC_SM_MASK, U_GC_L_MASK, etc.\n * Same as U_MASK(u_charType(c)).\n *\n * @param c the code point to be tested\n * @return a single-bit mask corresponding to the general category (UCharCategory) value\n *\n * @see u_charType\n * @see UCharCategory\n * @see U_GC_CN_MASK\n * @stable ICU 2.1\n */\n#define U_GET_GC_MASK(c) U_MASK(u_charType(c))\n\n/**\n * Callback from u_enumCharTypes(), is called for each contiguous range\n * of code points c (where start<=c<limit)\n * with the same Unicode general category (\"character type\").\n *\n * The callback function can stop the enumeration by returning FALSE.\n *\n * @param context an opaque pointer, as passed into utrie_enum()\n * @param start the first code point in a contiguous range with value\n * @param limit one past the last code point in a contiguous range with value\n * @param type the general category for all code points in [start..limit[\n * @return FALSE to stop the enumeration\n *\n * @stable ICU 2.1\n * @see UCharCategory\n * @see u_enumCharTypes\n */\ntypedef UBool U_CALLCONV\nUCharEnumTypeRange(const void *context, UChar32 start, UChar32 limit, UCharCategory type);\n\n/**\n * Enumerate efficiently all code points with their Unicode general categories.\n *\n * This is useful for building data structures (e.g., UnicodeSet's),\n * for enumerating all assigned code points (type!=U_UNASSIGNED), etc.\n *\n * For each contiguous range of code points with a given general category (\"character type\"),\n * the UCharEnumTypeRange function is called.\n * Adjacent ranges have different types.\n * The Unicode Standard guarantees that the numeric value of the type is 0..31.\n *\n * @param enumRange a pointer to a function that is called for each contiguous range\n *                  of code points with the same general category\n * @param context an opaque pointer that is passed on to the callback function\n *\n * @stable ICU 2.1\n * @see UCharCategory\n * @see UCharEnumTypeRange\n */\nU_STABLE void U_EXPORT2\nu_enumCharTypes(UCharEnumTypeRange *enumRange, const void *context);\n\n#if !UCONFIG_NO_NORMALIZATION\n\n/**\n * Returns the combining class of the code point as specified in UnicodeData.txt.\n *\n * @param c the code point of the character\n * @return the combining class of the character\n * @stable ICU 2.0\n */\nU_STABLE uint8_t U_EXPORT2\nu_getCombiningClass(UChar32 c);\n\n#endif\n\n/**\n * Returns the decimal digit value of a decimal digit character.\n * Such characters have the general category \"Nd\" (decimal digit numbers)\n * and a Numeric_Type of Decimal.\n *\n * Unlike ICU releases before 2.6, no digit values are returned for any\n * Han characters because Han number characters are often used with a special\n * Chinese-style number format (with characters for powers of 10 in between)\n * instead of in decimal-positional notation.\n * Unicode 4 explicitly assigns Han number characters the Numeric_Type\n * Numeric instead of Decimal.\n * See Jitterbug 1483 for more details.\n *\n * Use u_getIntPropertyValue(c, UCHAR_NUMERIC_TYPE) and u_getNumericValue()\n * for complete numeric Unicode properties.\n *\n * @param c the code point for which to get the decimal digit value\n * @return the decimal digit value of c,\n *         or -1 if c is not a decimal digit character\n *\n * @see u_getNumericValue\n * @stable ICU 2.0\n */\nU_STABLE int32_t U_EXPORT2\nu_charDigitValue(UChar32 c);\n\n/**\n * Returns the Unicode allocation block that contains the character.\n *\n * @param c the code point to be tested\n * @return the block value (UBlockCode) for c\n *\n * @see UBlockCode\n * @stable ICU 2.0\n */\nU_STABLE UBlockCode U_EXPORT2\nublock_getCode(UChar32 c);\n\n/**\n * Retrieve the name of a Unicode character.\n * Depending on <code>nameChoice</code>, the character name written\n * into the buffer is the \"modern\" name or the name that was defined\n * in Unicode version 1.0.\n * The name contains only \"invariant\" characters\n * like A-Z, 0-9, space, and '-'.\n * Unicode 1.0 names are only retrieved if they are different from the modern\n * names and if the data file contains the data for them. gennames may or may\n * not be called with a command line option to include 1.0 names in unames.dat.\n *\n * @param code The character (code point) for which to get the name.\n *             It must be <code>0<=code<=0x10ffff</code>.\n * @param nameChoice Selector for which name to get.\n * @param buffer Destination address for copying the name.\n *               The name will always be zero-terminated.\n *               If there is no name, then the buffer will be set to the empty string.\n * @param bufferLength <code>==sizeof(buffer)</code>\n * @param pErrorCode Pointer to a UErrorCode variable;\n *        check for <code>U_SUCCESS()</code> after <code>u_charName()</code>\n *        returns.\n * @return The length of the name, or 0 if there is no name for this character.\n *         If the bufferLength is less than or equal to the length, then the buffer\n *         contains the truncated name and the returned length indicates the full\n *         length of the name.\n *         The length does not include the zero-termination.\n *\n * @see UCharNameChoice\n * @see u_charFromName\n * @see u_enumCharNames\n * @stable ICU 2.0\n */\nU_STABLE int32_t U_EXPORT2\nu_charName(UChar32 code, UCharNameChoice nameChoice,\n           char *buffer, int32_t bufferLength,\n           UErrorCode *pErrorCode);\n\n/**\n * Returns an empty string.\n * Used to return the ISO 10646 comment for a character.\n * The Unicode ISO_Comment property is deprecated and has no values.\n *\n * @param c The character (code point) for which to get the ISO comment.\n *             It must be <code>0<=c<=0x10ffff</code>.\n * @param dest Destination address for copying the comment.\n *             The comment will be zero-terminated if possible.\n *             If there is no comment, then the buffer will be set to the empty string.\n * @param destCapacity <code>==sizeof(dest)</code>\n * @param pErrorCode Pointer to a UErrorCode variable;\n *        check for <code>U_SUCCESS()</code> after <code>u_getISOComment()</code>\n *        returns.\n * @return 0\n *\n * @deprecated ICU 49\n */\nU_STABLE int32_t U_EXPORT2\nu_getISOComment(UChar32 c,\n                char *dest, int32_t destCapacity,\n                UErrorCode *pErrorCode);\n\n/**\n * Find a Unicode character by its name and return its code point value.\n * The name is matched exactly and completely.\n * If the name does not correspond to a code point, <i>pErrorCode</i>\n * is set to <code>U_INVALID_CHAR_FOUND</code>.\n * A Unicode 1.0 name is matched only if it differs from the modern name.\n * Unicode names are all uppercase. Extended names are lowercase followed\n * by an uppercase hexadecimal number, and within angle brackets.\n *\n * @param nameChoice Selector for which name to match.\n * @param name The name to match.\n * @param pErrorCode Pointer to a UErrorCode variable\n * @return The Unicode value of the code point with the given name,\n *         or an undefined value if there is no such code point.\n *\n * @see UCharNameChoice\n * @see u_charName\n * @see u_enumCharNames\n * @stable ICU 1.7\n */\nU_STABLE UChar32 U_EXPORT2\nu_charFromName(UCharNameChoice nameChoice,\n               const char *name,\n               UErrorCode *pErrorCode);\n\n/**\n * Type of a callback function for u_enumCharNames() that gets called\n * for each Unicode character with the code point value and\n * the character name.\n * If such a function returns FALSE, then the enumeration is stopped.\n *\n * @param context The context pointer that was passed to u_enumCharNames().\n * @param code The Unicode code point for the character with this name.\n * @param nameChoice Selector for which kind of names is enumerated.\n * @param name The character's name, zero-terminated.\n * @param length The length of the name.\n * @return TRUE if the enumeration should continue, FALSE to stop it.\n *\n * @see UCharNameChoice\n * @see u_enumCharNames\n * @stable ICU 1.7\n */\ntypedef UBool U_CALLCONV UEnumCharNamesFn(void *context,\n                               UChar32 code,\n                               UCharNameChoice nameChoice,\n                               const char *name,\n                               int32_t length);\n\n/**\n * Enumerate all assigned Unicode characters between the start and limit\n * code points (start inclusive, limit exclusive) and call a function\n * for each, passing the code point value and the character name.\n * For Unicode 1.0 names, only those are enumerated that differ from the\n * modern names.\n *\n * @param start The first code point in the enumeration range.\n * @param limit One more than the last code point in the enumeration range\n *              (the first one after the range).\n * @param fn The function that is to be called for each character name.\n * @param context An arbitrary pointer that is passed to the function.\n * @param nameChoice Selector for which kind of names to enumerate.\n * @param pErrorCode Pointer to a UErrorCode variable\n *\n * @see UCharNameChoice\n * @see UEnumCharNamesFn\n * @see u_charName\n * @see u_charFromName\n * @stable ICU 1.7\n */\nU_STABLE void U_EXPORT2\nu_enumCharNames(UChar32 start, UChar32 limit,\n                UEnumCharNamesFn *fn,\n                void *context,\n                UCharNameChoice nameChoice,\n                UErrorCode *pErrorCode);\n\n/**\n * Return the Unicode name for a given property, as given in the\n * Unicode database file PropertyAliases.txt.\n *\n * In addition, this function maps the property\n * UCHAR_GENERAL_CATEGORY_MASK to the synthetic names \"gcm\" /\n * \"General_Category_Mask\".  These names are not in\n * PropertyAliases.txt.\n *\n * @param property UProperty selector other than UCHAR_INVALID_CODE.\n *         If out of range, NULL is returned.\n *\n * @param nameChoice selector for which name to get.  If out of range,\n *         NULL is returned.  All properties have a long name.  Most\n *         have a short name, but some do not.  Unicode allows for\n *         additional names; if present these will be returned by\n *         U_LONG_PROPERTY_NAME + i, where i=1, 2,...\n *\n * @return a pointer to the name, or NULL if either the\n *         property or the nameChoice is out of range.  If a given\n *         nameChoice returns NULL, then all larger values of\n *         nameChoice will return NULL, with one exception: if NULL is\n *         returned for U_SHORT_PROPERTY_NAME, then\n *         U_LONG_PROPERTY_NAME (and higher) may still return a\n *         non-NULL value.  The returned pointer is valid until\n *         u_cleanup() is called.\n *\n * @see UProperty\n * @see UPropertyNameChoice\n * @stable ICU 2.4\n */\nU_STABLE const char* U_EXPORT2\nu_getPropertyName(UProperty property,\n                  UPropertyNameChoice nameChoice);\n\n/**\n * Return the UProperty enum for a given property name, as specified\n * in the Unicode database file PropertyAliases.txt.  Short, long, and\n * any other variants are recognized.\n *\n * In addition, this function maps the synthetic names \"gcm\" /\n * \"General_Category_Mask\" to the property\n * UCHAR_GENERAL_CATEGORY_MASK.  These names are not in\n * PropertyAliases.txt.\n *\n * @param alias the property name to be matched.  The name is compared\n *         using \"loose matching\" as described in PropertyAliases.txt.\n *\n * @return a UProperty enum, or UCHAR_INVALID_CODE if the given name\n *         does not match any property.\n *\n * @see UProperty\n * @stable ICU 2.4\n */\nU_STABLE UProperty U_EXPORT2\nu_getPropertyEnum(const char* alias);\n\n/**\n * Return the Unicode name for a given property value, as given in the\n * Unicode database file PropertyValueAliases.txt.\n *\n * Note: Some of the names in PropertyValueAliases.txt can only be\n * retrieved using UCHAR_GENERAL_CATEGORY_MASK, not\n * UCHAR_GENERAL_CATEGORY.  These include: \"C\" / \"Other\", \"L\" /\n * \"Letter\", \"LC\" / \"Cased_Letter\", \"M\" / \"Mark\", \"N\" / \"Number\", \"P\"\n * / \"Punctuation\", \"S\" / \"Symbol\", and \"Z\" / \"Separator\".\n *\n * @param property UProperty selector constant.\n *        Must be UCHAR_BINARY_START<=which<UCHAR_BINARY_LIMIT\n *        or UCHAR_INT_START<=which<UCHAR_INT_LIMIT\n *        or UCHAR_MASK_START<=which<UCHAR_MASK_LIMIT.\n *        If out of range, NULL is returned.\n *\n * @param value selector for a value for the given property.  If out\n *         of range, NULL is returned.  In general, valid values range\n *         from 0 up to some maximum.  There are a few exceptions:\n *         (1.) UCHAR_BLOCK values begin at the non-zero value\n *         UBLOCK_BASIC_LATIN.  (2.)  UCHAR_CANONICAL_COMBINING_CLASS\n *         values are not contiguous and range from 0..240.  (3.)\n *         UCHAR_GENERAL_CATEGORY_MASK values are not values of\n *         UCharCategory, but rather mask values produced by\n *         U_GET_GC_MASK().  This allows grouped categories such as\n *         [:L:] to be represented.  Mask values range\n *         non-contiguously from 1..U_GC_P_MASK.\n *\n * @param nameChoice selector for which name to get.  If out of range,\n *         NULL is returned.  All values have a long name.  Most have\n *         a short name, but some do not.  Unicode allows for\n *         additional names; if present these will be returned by\n *         U_LONG_PROPERTY_NAME + i, where i=1, 2,...\n\n * @return a pointer to the name, or NULL if either the\n *         property or the nameChoice is out of range.  If a given\n *         nameChoice returns NULL, then all larger values of\n *         nameChoice will return NULL, with one exception: if NULL is\n *         returned for U_SHORT_PROPERTY_NAME, then\n *         U_LONG_PROPERTY_NAME (and higher) may still return a\n *         non-NULL value.  The returned pointer is valid until\n *         u_cleanup() is called.\n *\n * @see UProperty\n * @see UPropertyNameChoice\n * @stable ICU 2.4\n */\nU_STABLE const char* U_EXPORT2\nu_getPropertyValueName(UProperty property,\n                       int32_t value,\n                       UPropertyNameChoice nameChoice);\n\n/**\n * Return the property value integer for a given value name, as\n * specified in the Unicode database file PropertyValueAliases.txt.\n * Short, long, and any other variants are recognized.\n *\n * Note: Some of the names in PropertyValueAliases.txt will only be\n * recognized with UCHAR_GENERAL_CATEGORY_MASK, not\n * UCHAR_GENERAL_CATEGORY.  These include: \"C\" / \"Other\", \"L\" /\n * \"Letter\", \"LC\" / \"Cased_Letter\", \"M\" / \"Mark\", \"N\" / \"Number\", \"P\"\n * / \"Punctuation\", \"S\" / \"Symbol\", and \"Z\" / \"Separator\".\n *\n * @param property UProperty selector constant.\n *        Must be UCHAR_BINARY_START<=which<UCHAR_BINARY_LIMIT\n *        or UCHAR_INT_START<=which<UCHAR_INT_LIMIT\n *        or UCHAR_MASK_START<=which<UCHAR_MASK_LIMIT.\n *        If out of range, UCHAR_INVALID_CODE is returned.\n *\n * @param alias the value name to be matched.  The name is compared\n *         using \"loose matching\" as described in\n *         PropertyValueAliases.txt.\n *\n * @return a value integer or UCHAR_INVALID_CODE if the given name\n *         does not match any value of the given property, or if the\n *         property is invalid.  Note: UCHAR_GENERAL_CATEGORY_MASK values\n *         are not values of UCharCategory, but rather mask values\n *         produced by U_GET_GC_MASK().  This allows grouped\n *         categories such as [:L:] to be represented.\n *\n * @see UProperty\n * @stable ICU 2.4\n */\nU_STABLE int32_t U_EXPORT2\nu_getPropertyValueEnum(UProperty property,\n                       const char* alias);\n\n/**\n * Determines if the specified character is permissible as the\n * first character in an identifier according to Unicode\n * (The Unicode Standard, Version 3.0, chapter 5.16 Identifiers).\n * True for characters with general categories \"L\" (letters) and \"Nl\" (letter numbers).\n *\n * Same as java.lang.Character.isUnicodeIdentifierStart().\n * Same as UCHAR_ID_START\n *\n * @param c the code point to be tested\n * @return TRUE if the code point may start an identifier\n *\n * @see UCHAR_ID_START\n * @see u_isalpha\n * @see u_isIDPart\n * @stable ICU 2.0\n */\nU_STABLE UBool U_EXPORT2\nu_isIDStart(UChar32 c);\n\n/**\n * Determines if the specified character is permissible\n * in an identifier according to Java.\n * True for characters with general categories \"L\" (letters),\n * \"Nl\" (letter numbers), \"Nd\" (decimal digits),\n * \"Mc\" and \"Mn\" (combining marks), \"Pc\" (connecting punctuation), and\n * u_isIDIgnorable(c).\n *\n * Same as java.lang.Character.isUnicodeIdentifierPart().\n * Almost the same as Unicode's ID_Continue (UCHAR_ID_CONTINUE)\n * except that Unicode recommends to ignore Cf which is less than\n * u_isIDIgnorable(c).\n *\n * @param c the code point to be tested\n * @return TRUE if the code point may occur in an identifier according to Java\n *\n * @see UCHAR_ID_CONTINUE\n * @see u_isIDStart\n * @see u_isIDIgnorable\n * @stable ICU 2.0\n */\nU_STABLE UBool U_EXPORT2\nu_isIDPart(UChar32 c);\n\n/**\n * Determines if the specified character should be regarded\n * as an ignorable character in an identifier,\n * according to Java.\n * True for characters with general category \"Cf\" (format controls) as well as\n * non-whitespace ISO controls\n * (U+0000..U+0008, U+000E..U+001B, U+007F..U+009F).\n *\n * Same as java.lang.Character.isIdentifierIgnorable().\n *\n * Note that Unicode just recommends to ignore Cf (format controls).\n *\n * @param c the code point to be tested\n * @return TRUE if the code point is ignorable in identifiers according to Java\n *\n * @see UCHAR_DEFAULT_IGNORABLE_CODE_POINT\n * @see u_isIDStart\n * @see u_isIDPart\n * @stable ICU 2.0\n */\nU_STABLE UBool U_EXPORT2\nu_isIDIgnorable(UChar32 c);\n\n/**\n * Determines if the specified character is permissible as the\n * first character in a Java identifier.\n * In addition to u_isIDStart(c), true for characters with\n * general categories \"Sc\" (currency symbols) and \"Pc\" (connecting punctuation).\n *\n * Same as java.lang.Character.isJavaIdentifierStart().\n *\n * @param c the code point to be tested\n * @return TRUE if the code point may start a Java identifier\n *\n * @see     u_isJavaIDPart\n * @see     u_isalpha\n * @see     u_isIDStart\n * @stable ICU 2.0\n */\nU_STABLE UBool U_EXPORT2\nu_isJavaIDStart(UChar32 c);\n\n/**\n * Determines if the specified character is permissible\n * in a Java identifier.\n * In addition to u_isIDPart(c), true for characters with\n * general category \"Sc\" (currency symbols).\n *\n * Same as java.lang.Character.isJavaIdentifierPart().\n *\n * @param c the code point to be tested\n * @return TRUE if the code point may occur in a Java identifier\n *\n * @see     u_isIDIgnorable\n * @see     u_isJavaIDStart\n * @see     u_isalpha\n * @see     u_isdigit\n * @see     u_isIDPart\n * @stable ICU 2.0\n */\nU_STABLE UBool U_EXPORT2\nu_isJavaIDPart(UChar32 c);\n\n/**\n * The given character is mapped to its lowercase equivalent according to\n * UnicodeData.txt; if the character has no lowercase equivalent, the character\n * itself is returned.\n *\n * Same as java.lang.Character.toLowerCase().\n *\n * This function only returns the simple, single-code point case mapping.\n * Full case mappings should be used whenever possible because they produce\n * better results by working on whole strings.\n * They take into account the string context and the language and can map\n * to a result string with a different length as appropriate.\n * Full case mappings are applied by the string case mapping functions,\n * see ustring.h and the UnicodeString class.\n * See also the User Guide chapter on C/POSIX migration:\n * http://icu-project.org/userguide/posix.html#case_mappings\n *\n * @param c the code point to be mapped\n * @return the Simple_Lowercase_Mapping of the code point, if any;\n *         otherwise the code point itself.\n * @stable ICU 2.0\n */\nU_STABLE UChar32 U_EXPORT2\nu_tolower(UChar32 c);\n\n/**\n * The given character is mapped to its uppercase equivalent according to UnicodeData.txt;\n * if the character has no uppercase equivalent, the character itself is\n * returned.\n *\n * Same as java.lang.Character.toUpperCase().\n *\n * This function only returns the simple, single-code point case mapping.\n * Full case mappings should be used whenever possible because they produce\n * better results by working on whole strings.\n * They take into account the string context and the language and can map\n * to a result string with a different length as appropriate.\n * Full case mappings are applied by the string case mapping functions,\n * see ustring.h and the UnicodeString class.\n * See also the User Guide chapter on C/POSIX migration:\n * http://icu-project.org/userguide/posix.html#case_mappings\n *\n * @param c the code point to be mapped\n * @return the Simple_Uppercase_Mapping of the code point, if any;\n *         otherwise the code point itself.\n * @stable ICU 2.0\n */\nU_STABLE UChar32 U_EXPORT2\nu_toupper(UChar32 c);\n\n/**\n * The given character is mapped to its titlecase equivalent\n * according to UnicodeData.txt;\n * if none is defined, the character itself is returned.\n *\n * Same as java.lang.Character.toTitleCase().\n *\n * This function only returns the simple, single-code point case mapping.\n * Full case mappings should be used whenever possible because they produce\n * better results by working on whole strings.\n * They take into account the string context and the language and can map\n * to a result string with a different length as appropriate.\n * Full case mappings are applied by the string case mapping functions,\n * see ustring.h and the UnicodeString class.\n * See also the User Guide chapter on C/POSIX migration:\n * http://icu-project.org/userguide/posix.html#case_mappings\n *\n * @param c the code point to be mapped\n * @return the Simple_Titlecase_Mapping of the code point, if any;\n *         otherwise the code point itself.\n * @stable ICU 2.0\n */\nU_STABLE UChar32 U_EXPORT2\nu_totitle(UChar32 c);\n\n/** Option value for case folding: use default mappings defined in CaseFolding.txt. @stable ICU 2.0 */\n#define U_FOLD_CASE_DEFAULT 0\n\n/**\n * Option value for case folding:\n *\n * Use the modified set of mappings provided in CaseFolding.txt to handle dotted I\n * and dotless i appropriately for Turkic languages (tr, az).\n *\n * Before Unicode 3.2, CaseFolding.txt contains mappings marked with 'I' that\n * are to be included for default mappings and\n * excluded for the Turkic-specific mappings.\n *\n * Unicode 3.2 CaseFolding.txt instead contains mappings marked with 'T' that\n * are to be excluded for default mappings and\n * included for the Turkic-specific mappings.\n *\n * @stable ICU 2.0\n */\n#define U_FOLD_CASE_EXCLUDE_SPECIAL_I 1\n\n/**\n * The given character is mapped to its case folding equivalent according to\n * UnicodeData.txt and CaseFolding.txt;\n * if the character has no case folding equivalent, the character\n * itself is returned.\n *\n * This function only returns the simple, single-code point case mapping.\n * Full case mappings should be used whenever possible because they produce\n * better results by working on whole strings.\n * They take into account the string context and the language and can map\n * to a result string with a different length as appropriate.\n * Full case mappings are applied by the string case mapping functions,\n * see ustring.h and the UnicodeString class.\n * See also the User Guide chapter on C/POSIX migration:\n * http://icu-project.org/userguide/posix.html#case_mappings\n *\n * @param c the code point to be mapped\n * @param options Either U_FOLD_CASE_DEFAULT or U_FOLD_CASE_EXCLUDE_SPECIAL_I\n * @return the Simple_Case_Folding of the code point, if any;\n *         otherwise the code point itself.\n * @stable ICU 2.0\n */\nU_STABLE UChar32 U_EXPORT2\nu_foldCase(UChar32 c, uint32_t options);\n\n/**\n * Returns the decimal digit value of the code point in the\n * specified radix.\n *\n * If the radix is not in the range <code>2<=radix<=36</code> or if the\n * value of <code>c</code> is not a valid digit in the specified\n * radix, <code>-1</code> is returned. A character is a valid digit\n * if at least one of the following is true:\n * <ul>\n * <li>The character has a decimal digit value.\n *     Such characters have the general category \"Nd\" (decimal digit numbers)\n *     and a Numeric_Type of Decimal.\n *     In this case the value is the character's decimal digit value.</li>\n * <li>The character is one of the uppercase Latin letters\n *     <code>'A'</code> through <code>'Z'</code>.\n *     In this case the value is <code>c-'A'+10</code>.</li>\n * <li>The character is one of the lowercase Latin letters\n *     <code>'a'</code> through <code>'z'</code>.\n *     In this case the value is <code>ch-'a'+10</code>.</li>\n * <li>Latin letters from both the ASCII range (0061..007A, 0041..005A)\n *     as well as from the Fullwidth ASCII range (FF41..FF5A, FF21..FF3A)\n *     are recognized.</li>\n * </ul>\n *\n * Same as java.lang.Character.digit().\n *\n * @param   ch      the code point to be tested.\n * @param   radix   the radix.\n * @return  the numeric value represented by the character in the\n *          specified radix,\n *          or -1 if there is no value or if the value exceeds the radix.\n *\n * @see     UCHAR_NUMERIC_TYPE\n * @see     u_forDigit\n * @see     u_charDigitValue\n * @see     u_isdigit\n * @stable ICU 2.0\n */\nU_STABLE int32_t U_EXPORT2\nu_digit(UChar32 ch, int8_t radix);\n\n/**\n * Determines the character representation for a specific digit in\n * the specified radix. If the value of <code>radix</code> is not a\n * valid radix, or the value of <code>digit</code> is not a valid\n * digit in the specified radix, the null character\n * (<code>U+0000</code>) is returned.\n * <p>\n * The <code>radix</code> argument is valid if it is greater than or\n * equal to 2 and less than or equal to 36.\n * The <code>digit</code> argument is valid if\n * <code>0 <= digit < radix</code>.\n * <p>\n * If the digit is less than 10, then\n * <code>'0' + digit</code> is returned. Otherwise, the value\n * <code>'a' + digit - 10</code> is returned.\n *\n * Same as java.lang.Character.forDigit().\n *\n * @param   digit   the number to convert to a character.\n * @param   radix   the radix.\n * @return  the <code>char</code> representation of the specified digit\n *          in the specified radix.\n *\n * @see     u_digit\n * @see     u_charDigitValue\n * @see     u_isdigit\n * @stable ICU 2.0\n */\nU_STABLE UChar32 U_EXPORT2\nu_forDigit(int32_t digit, int8_t radix);\n\n/**\n * Get the \"age\" of the code point.\n * The \"age\" is the Unicode version when the code point was first\n * designated (as a non-character or for Private Use)\n * or assigned a character.\n * This can be useful to avoid emitting code points to receiving\n * processes that do not accept newer characters.\n * The data is from the UCD file DerivedAge.txt.\n *\n * @param c The code point.\n * @param versionArray The Unicode version number array, to be filled in.\n *\n * @stable ICU 2.1\n */\nU_STABLE void U_EXPORT2\nu_charAge(UChar32 c, UVersionInfo versionArray);\n\n/**\n * Gets the Unicode version information.\n * The version array is filled in with the version information\n * for the Unicode standard that is currently used by ICU.\n * For example, Unicode version 3.1.1 is represented as an array with\n * the values { 3, 1, 1, 0 }.\n *\n * @param versionArray an output array that will be filled in with\n *                     the Unicode version number\n * @stable ICU 2.0\n */\nU_STABLE void U_EXPORT2\nu_getUnicodeVersion(UVersionInfo versionArray);\n\n#if !UCONFIG_NO_NORMALIZATION\n/**\n * Get the FC_NFKC_Closure property string for a character.\n * See Unicode Standard Annex #15 for details, search for \"FC_NFKC_Closure\"\n * or for \"FNC\": http://www.unicode.org/reports/tr15/\n *\n * @param c The character (code point) for which to get the FC_NFKC_Closure string.\n *             It must be <code>0<=c<=0x10ffff</code>.\n * @param dest Destination address for copying the string.\n *             The string will be zero-terminated if possible.\n *             If there is no FC_NFKC_Closure string,\n *             then the buffer will be set to the empty string.\n * @param destCapacity <code>==sizeof(dest)</code>\n * @param pErrorCode Pointer to a UErrorCode variable.\n * @return The length of the string, or 0 if there is no FC_NFKC_Closure string for this character.\n *         If the destCapacity is less than or equal to the length, then the buffer\n *         contains the truncated name and the returned length indicates the full\n *         length of the name.\n *         The length does not include the zero-termination.\n *\n * @stable ICU 2.2\n */\nU_STABLE int32_t U_EXPORT2\nu_getFC_NFKC_Closure(UChar32 c, UChar *dest, int32_t destCapacity, UErrorCode *pErrorCode);\n\n#endif\n\n\nU_CDECL_END\n\n#endif /*_UCHAR*/\n/*eof*/\n"
  },
  {
    "path": "deprecated/android/addons/icucompat/unicode/ucharstrie.h",
    "content": "/*\n*******************************************************************************\n*   Copyright (C) 2010-2012, International Business Machines\n*   Corporation and others.  All Rights Reserved.\n*******************************************************************************\n*   file name:  ucharstrie.h\n*   encoding:   US-ASCII\n*   tab size:   8 (not used)\n*   indentation:4\n*\n*   created on: 2010nov14\n*   created by: Markus W. Scherer\n*/\n\n#ifndef __UCHARSTRIE_H__\n#define __UCHARSTRIE_H__\n\n/**\n * \\file\n * \\brief C++ API: Trie for mapping Unicode strings (or 16-bit-unit sequences)\n *                 to integer values.\n */\n\n#include \"unicode/utypes.h\"\n#include \"unicode/unistr.h\"\n#include \"unicode/uobject.h\"\n#include \"unicode/ustringtrie.h\"\n\nU_NAMESPACE_BEGIN\n\nclass Appendable;\nclass UCharsTrieBuilder;\nclass UVector32;\n\n/**\n * Light-weight, non-const reader class for a UCharsTrie.\n * Traverses a UChar-serialized data structure with minimal state,\n * for mapping strings (16-bit-unit sequences) to non-negative integer values.\n *\n * This class owns the serialized trie data only if it was constructed by\n * the builder's build() method.\n * The public constructor and the copy constructor only alias the data (only copy the pointer).\n * There is no assignment operator.\n *\n * This class is not intended for public subclassing.\n * @stable ICU 4.8\n */\nclass U_COMMON_API UCharsTrie : public UMemory {\npublic:\n    /**\n     * Constructs a UCharsTrie reader instance.\n     *\n     * The trieUChars must contain a copy of a UChar sequence from the UCharsTrieBuilder,\n     * starting with the first UChar of that sequence.\n     * The UCharsTrie object will not read more UChars than\n     * the UCharsTrieBuilder generated in the corresponding build() call.\n     *\n     * The array is not copied/cloned and must not be modified while\n     * the UCharsTrie object is in use.\n     *\n     * @param trieUChars The UChar array that contains the serialized trie.\n     * @stable ICU 4.8\n     */\n    UCharsTrie(const UChar *trieUChars)\n            : ownedArray_(NULL), uchars_(trieUChars),\n              pos_(uchars_), remainingMatchLength_(-1) {}\n\n    /**\n     * Destructor.\n     * @stable ICU 4.8\n     */\n    ~UCharsTrie();\n\n    /**\n     * Copy constructor, copies the other trie reader object and its state,\n     * but not the UChar array which will be shared. (Shallow copy.)\n     * @param other Another UCharsTrie object.\n     * @stable ICU 4.8\n     */\n    UCharsTrie(const UCharsTrie &other)\n            : ownedArray_(NULL), uchars_(other.uchars_),\n              pos_(other.pos_), remainingMatchLength_(other.remainingMatchLength_) {}\n\n    /**\n     * Resets this trie to its initial state.\n     * @return *this\n     * @stable ICU 4.8\n     */\n    UCharsTrie &reset() {\n        pos_=uchars_;\n        remainingMatchLength_=-1;\n        return *this;\n    }\n\n    /**\n     * UCharsTrie state object, for saving a trie's current state\n     * and resetting the trie back to this state later.\n     * @stable ICU 4.8\n     */\n    class State : public UMemory {\n    public:\n        /**\n         * Constructs an empty State.\n         * @stable ICU 4.8\n         */\n        State() { uchars=NULL; }\n    private:\n        friend class UCharsTrie;\n\n        const UChar *uchars;\n        const UChar *pos;\n        int32_t remainingMatchLength;\n    };\n\n    /**\n     * Saves the state of this trie.\n     * @param state The State object to hold the trie's state.\n     * @return *this\n     * @see resetToState\n     * @stable ICU 4.8\n     */\n    const UCharsTrie &saveState(State &state) const {\n        state.uchars=uchars_;\n        state.pos=pos_;\n        state.remainingMatchLength=remainingMatchLength_;\n        return *this;\n    }\n\n    /**\n     * Resets this trie to the saved state.\n     * If the state object contains no state, or the state of a different trie,\n     * then this trie remains unchanged.\n     * @param state The State object which holds a saved trie state.\n     * @return *this\n     * @see saveState\n     * @see reset\n     * @stable ICU 4.8\n     */\n    UCharsTrie &resetToState(const State &state) {\n        if(uchars_==state.uchars && uchars_!=NULL) {\n            pos_=state.pos;\n            remainingMatchLength_=state.remainingMatchLength;\n        }\n        return *this;\n    }\n\n    /**\n     * Determines whether the string so far matches, whether it has a value,\n     * and whether another input UChar can continue a matching string.\n     * @return The match/value Result.\n     * @stable ICU 4.8\n     */\n    UStringTrieResult current() const;\n\n    /**\n     * Traverses the trie from the initial state for this input UChar.\n     * Equivalent to reset().next(uchar).\n     * @param uchar Input char value. Values below 0 and above 0xffff will never match.\n     * @return The match/value Result.\n     * @stable ICU 4.8\n     */\n    inline UStringTrieResult first(int32_t uchar) {\n        remainingMatchLength_=-1;\n        return nextImpl(uchars_, uchar);\n    }\n\n    /**\n     * Traverses the trie from the initial state for the\n     * one or two UTF-16 code units for this input code point.\n     * Equivalent to reset().nextForCodePoint(cp).\n     * @param cp A Unicode code point 0..0x10ffff.\n     * @return The match/value Result.\n     * @stable ICU 4.8\n     */\n    UStringTrieResult firstForCodePoint(UChar32 cp);\n\n    /**\n     * Traverses the trie from the current state for this input UChar.\n     * @param uchar Input char value. Values below 0 and above 0xffff will never match.\n     * @return The match/value Result.\n     * @stable ICU 4.8\n     */\n    UStringTrieResult next(int32_t uchar);\n\n    /**\n     * Traverses the trie from the current state for the\n     * one or two UTF-16 code units for this input code point.\n     * @param cp A Unicode code point 0..0x10ffff.\n     * @return The match/value Result.\n     * @stable ICU 4.8\n     */\n    UStringTrieResult nextForCodePoint(UChar32 cp);\n\n    /**\n     * Traverses the trie from the current state for this string.\n     * Equivalent to\n     * \\code\n     * Result result=current();\n     * for(each c in s)\n     *   if(!USTRINGTRIE_HAS_NEXT(result)) return USTRINGTRIE_NO_MATCH;\n     *   result=next(c);\n     * return result;\n     * \\endcode\n     * @param s A string. Can be NULL if length is 0.\n     * @param length The length of the string. Can be -1 if NUL-terminated.\n     * @return The match/value Result.\n     * @stable ICU 4.8\n     */\n    UStringTrieResult next(const UChar *s, int32_t length);\n\n    /**\n     * Returns a matching string's value if called immediately after\n     * current()/first()/next() returned USTRINGTRIE_INTERMEDIATE_VALUE or USTRINGTRIE_FINAL_VALUE.\n     * getValue() can be called multiple times.\n     *\n     * Do not call getValue() after USTRINGTRIE_NO_MATCH or USTRINGTRIE_NO_VALUE!\n     * @return The value for the string so far.\n     * @stable ICU 4.8\n     */\n    inline int32_t getValue() const {\n        const UChar *pos=pos_;\n        int32_t leadUnit=*pos++;\n        // U_ASSERT(leadUnit>=kMinValueLead);\n        return leadUnit&kValueIsFinal ?\n            readValue(pos, leadUnit&0x7fff) : readNodeValue(pos, leadUnit);\n    }\n\n    /**\n     * Determines whether all strings reachable from the current state\n     * map to the same value.\n     * @param uniqueValue Receives the unique value, if this function returns TRUE.\n     *                    (output-only)\n     * @return TRUE if all strings reachable from the current state\n     *         map to the same value.\n     * @stable ICU 4.8\n     */\n    inline UBool hasUniqueValue(int32_t &uniqueValue) const {\n        const UChar *pos=pos_;\n        // Skip the rest of a pending linear-match node.\n        return pos!=NULL && findUniqueValue(pos+remainingMatchLength_+1, FALSE, uniqueValue);\n    }\n\n    /**\n     * Finds each UChar which continues the string from the current state.\n     * That is, each UChar c for which it would be next(c)!=USTRINGTRIE_NO_MATCH now.\n     * @param out Each next UChar is appended to this object.\n     * @return the number of UChars which continue the string from here\n     * @stable ICU 4.8\n     */\n    int32_t getNextUChars(Appendable &out) const;\n\n    /**\n     * Iterator for all of the (string, value) pairs in a UCharsTrie.\n     * @stable ICU 4.8\n     */\n    class U_COMMON_API Iterator : public UMemory {\n    public:\n        /**\n         * Iterates from the root of a UChar-serialized UCharsTrie.\n         * @param trieUChars The trie UChars.\n         * @param maxStringLength If 0, the iterator returns full strings.\n         *                        Otherwise, the iterator returns strings with this maximum length.\n         * @param errorCode Standard ICU error code. Its input value must\n         *                  pass the U_SUCCESS() test, or else the function returns\n         *                  immediately. Check for U_FAILURE() on output or use with\n         *                  function chaining. (See User Guide for details.)\n         * @stable ICU 4.8\n         */\n        Iterator(const UChar *trieUChars, int32_t maxStringLength, UErrorCode &errorCode);\n\n        /**\n         * Iterates from the current state of the specified UCharsTrie.\n         * @param trie The trie whose state will be copied for iteration.\n         * @param maxStringLength If 0, the iterator returns full strings.\n         *                        Otherwise, the iterator returns strings with this maximum length.\n         * @param errorCode Standard ICU error code. Its input value must\n         *                  pass the U_SUCCESS() test, or else the function returns\n         *                  immediately. Check for U_FAILURE() on output or use with\n         *                  function chaining. (See User Guide for details.)\n         * @stable ICU 4.8\n         */\n        Iterator(const UCharsTrie &trie, int32_t maxStringLength, UErrorCode &errorCode);\n\n        /**\n         * Destructor.\n         * @stable ICU 4.8\n         */\n        ~Iterator();\n\n        /**\n         * Resets this iterator to its initial state.\n         * @return *this\n         * @stable ICU 4.8\n         */\n        Iterator &reset();\n\n        /**\n         * @return TRUE if there are more elements.\n         * @stable ICU 4.8\n         */\n        UBool hasNext() const;\n\n        /**\n         * Finds the next (string, value) pair if there is one.\n         *\n         * If the string is truncated to the maximum length and does not\n         * have a real value, then the value is set to -1.\n         * In this case, this \"not a real value\" is indistinguishable from\n         * a real value of -1.\n         * @param errorCode Standard ICU error code. Its input value must\n         *                  pass the U_SUCCESS() test, or else the function returns\n         *                  immediately. Check for U_FAILURE() on output or use with\n         *                  function chaining. (See User Guide for details.)\n         * @return TRUE if there is another element.\n         * @stable ICU 4.8\n         */\n        UBool next(UErrorCode &errorCode);\n\n        /**\n         * @return The string for the last successful next().\n         * @stable ICU 4.8\n         */\n        const UnicodeString &getString() const { return str_; }\n        /**\n         * @return The value for the last successful next().\n         * @stable ICU 4.8\n         */\n        int32_t getValue() const { return value_; }\n\n    private:\n        UBool truncateAndStop() {\n            pos_=NULL;\n            value_=-1;  // no real value for str\n            return TRUE;\n        }\n\n        const UChar *branchNext(const UChar *pos, int32_t length, UErrorCode &errorCode);\n\n        const UChar *uchars_;\n        const UChar *pos_;\n        const UChar *initialPos_;\n        int32_t remainingMatchLength_;\n        int32_t initialRemainingMatchLength_;\n        UBool skipValue_;  // Skip intermediate value which was already delivered.\n\n        UnicodeString str_;\n        int32_t maxLength_;\n        int32_t value_;\n\n        // The stack stores pairs of integers for backtracking to another\n        // outbound edge of a branch node.\n        // The first integer is an offset from uchars_.\n        // The second integer has the str_.length() from before the node in bits 15..0,\n        // and the remaining branch length in bits 31..16.\n        // (We could store the remaining branch length minus 1 in bits 30..16 and not use the sign bit,\n        // but the code looks more confusing that way.)\n        UVector32 *stack_;\n    };\n\nprivate:\n    friend class UCharsTrieBuilder;\n\n    /**\n     * Constructs a UCharsTrie reader instance.\n     * Unlike the public constructor which just aliases an array,\n     * this constructor adopts the builder's array.\n     * This constructor is only called by the builder.\n     */\n    UCharsTrie(UChar *adoptUChars, const UChar *trieUChars)\n            : ownedArray_(adoptUChars), uchars_(trieUChars),\n              pos_(uchars_), remainingMatchLength_(-1) {}\n\n    // No assignment operator.\n    UCharsTrie &operator=(const UCharsTrie &other);\n\n    inline void stop() {\n        pos_=NULL;\n    }\n\n    // Reads a compact 32-bit integer.\n    // pos is already after the leadUnit, and the lead unit has bit 15 reset.\n    static inline int32_t readValue(const UChar *pos, int32_t leadUnit) {\n        int32_t value;\n        if(leadUnit<kMinTwoUnitValueLead) {\n            value=leadUnit;\n        } else if(leadUnit<kThreeUnitValueLead) {\n            value=((leadUnit-kMinTwoUnitValueLead)<<16)|*pos;\n        } else {\n            value=(pos[0]<<16)|pos[1];\n        }\n        return value;\n    }\n    static inline const UChar *skipValue(const UChar *pos, int32_t leadUnit) {\n        if(leadUnit>=kMinTwoUnitValueLead) {\n            if(leadUnit<kThreeUnitValueLead) {\n                ++pos;\n            } else {\n                pos+=2;\n            }\n        }\n        return pos;\n    }\n    static inline const UChar *skipValue(const UChar *pos) {\n        int32_t leadUnit=*pos++;\n        return skipValue(pos, leadUnit&0x7fff);\n    }\n\n    static inline int32_t readNodeValue(const UChar *pos, int32_t leadUnit) {\n        // U_ASSERT(kMinValueLead<=leadUnit && leadUnit<kValueIsFinal);\n        int32_t value;\n        if(leadUnit<kMinTwoUnitNodeValueLead) {\n            value=(leadUnit>>6)-1;\n        } else if(leadUnit<kThreeUnitNodeValueLead) {\n            value=(((leadUnit&0x7fc0)-kMinTwoUnitNodeValueLead)<<10)|*pos;\n        } else {\n            value=(pos[0]<<16)|pos[1];\n        }\n        return value;\n    }\n    static inline const UChar *skipNodeValue(const UChar *pos, int32_t leadUnit) {\n        // U_ASSERT(kMinValueLead<=leadUnit && leadUnit<kValueIsFinal);\n        if(leadUnit>=kMinTwoUnitNodeValueLead) {\n            if(leadUnit<kThreeUnitNodeValueLead) {\n                ++pos;\n            } else {\n                pos+=2;\n            }\n        }\n        return pos;\n    }\n\n    static inline const UChar *jumpByDelta(const UChar *pos) {\n        int32_t delta=*pos++;\n        if(delta>=kMinTwoUnitDeltaLead) {\n            if(delta==kThreeUnitDeltaLead) {\n                delta=(pos[0]<<16)|pos[1];\n                pos+=2;\n            } else {\n                delta=((delta-kMinTwoUnitDeltaLead)<<16)|*pos++;\n            }\n        }\n        return pos+delta;\n    }\n\n    static const UChar *skipDelta(const UChar *pos) {\n        int32_t delta=*pos++;\n        if(delta>=kMinTwoUnitDeltaLead) {\n            if(delta==kThreeUnitDeltaLead) {\n                pos+=2;\n            } else {\n                ++pos;\n            }\n        }\n        return pos;\n    }\n\n    static inline UStringTrieResult valueResult(int32_t node) {\n        return (UStringTrieResult)(USTRINGTRIE_INTERMEDIATE_VALUE-(node>>15));\n    }\n\n    // Handles a branch node for both next(uchar) and next(string).\n    UStringTrieResult branchNext(const UChar *pos, int32_t length, int32_t uchar);\n\n    // Requires remainingLength_<0.\n    UStringTrieResult nextImpl(const UChar *pos, int32_t uchar);\n\n    // Helper functions for hasUniqueValue().\n    // Recursively finds a unique value (or whether there is not a unique one)\n    // from a branch.\n    static const UChar *findUniqueValueFromBranch(const UChar *pos, int32_t length,\n                                                  UBool haveUniqueValue, int32_t &uniqueValue);\n    // Recursively finds a unique value (or whether there is not a unique one)\n    // starting from a position on a node lead unit.\n    static UBool findUniqueValue(const UChar *pos, UBool haveUniqueValue, int32_t &uniqueValue);\n\n    // Helper functions for getNextUChars().\n    // getNextUChars() when pos is on a branch node.\n    static void getNextBranchUChars(const UChar *pos, int32_t length, Appendable &out);\n\n    // UCharsTrie data structure\n    //\n    // The trie consists of a series of UChar-serialized nodes for incremental\n    // Unicode string/UChar sequence matching. (UChar=16-bit unsigned integer)\n    // The root node is at the beginning of the trie data.\n    //\n    // Types of nodes are distinguished by their node lead unit ranges.\n    // After each node, except a final-value node, another node follows to\n    // encode match values or continue matching further units.\n    //\n    // Node types:\n    //  - Final-value node: Stores a 32-bit integer in a compact, variable-length format.\n    //    The value is for the string/UChar sequence so far.\n    //  - Match node, optionally with an intermediate value in a different compact format.\n    //    The value, if present, is for the string/UChar sequence so far.\n    //\n    //  Aside from the value, which uses the node lead unit's high bits:\n    //\n    //  - Linear-match node: Matches a number of units.\n    //  - Branch node: Branches to other nodes according to the current input unit.\n    //    The node unit is the length of the branch (number of units to select from)\n    //    minus 1. It is followed by a sub-node:\n    //    - If the length is at most kMaxBranchLinearSubNodeLength, then\n    //      there are length-1 (key, value) pairs and then one more comparison unit.\n    //      If one of the key units matches, then the value is either a final value for\n    //      the string so far, or a \"jump\" delta to the next node.\n    //      If the last unit matches, then matching continues with the next node.\n    //      (Values have the same encoding as final-value nodes.)\n    //    - If the length is greater than kMaxBranchLinearSubNodeLength, then\n    //      there is one unit and one \"jump\" delta.\n    //      If the input unit is less than the sub-node unit, then \"jump\" by delta to\n    //      the next sub-node which will have a length of length/2.\n    //      (The delta has its own compact encoding.)\n    //      Otherwise, skip the \"jump\" delta to the next sub-node\n    //      which will have a length of length-length/2.\n\n    // Match-node lead unit values, after masking off intermediate-value bits:\n\n    // 0000..002f: Branch node. If node!=0 then the length is node+1, otherwise\n    // the length is one more than the next unit.\n\n    // For a branch sub-node with at most this many entries, we drop down\n    // to a linear search.\n    static const int32_t kMaxBranchLinearSubNodeLength=5;\n\n    // 0030..003f: Linear-match node, match 1..16 units and continue reading the next node.\n    static const int32_t kMinLinearMatch=0x30;\n    static const int32_t kMaxLinearMatchLength=0x10;\n\n    // Match-node lead unit bits 14..6 for the optional intermediate value.\n    // If these bits are 0, then there is no intermediate value.\n    // Otherwise, see the *NodeValue* constants below.\n    static const int32_t kMinValueLead=kMinLinearMatch+kMaxLinearMatchLength;  // 0x0040\n    static const int32_t kNodeTypeMask=kMinValueLead-1;  // 0x003f\n\n    // A final-value node has bit 15 set.\n    static const int32_t kValueIsFinal=0x8000;\n\n    // Compact value: After testing and masking off bit 15, use the following thresholds.\n    static const int32_t kMaxOneUnitValue=0x3fff;\n\n    static const int32_t kMinTwoUnitValueLead=kMaxOneUnitValue+1;  // 0x4000\n    static const int32_t kThreeUnitValueLead=0x7fff;\n\n    static const int32_t kMaxTwoUnitValue=((kThreeUnitValueLead-kMinTwoUnitValueLead)<<16)-1;  // 0x3ffeffff\n\n    // Compact intermediate-value integer, lead unit shared with a branch or linear-match node.\n    static const int32_t kMaxOneUnitNodeValue=0xff;\n    static const int32_t kMinTwoUnitNodeValueLead=kMinValueLead+((kMaxOneUnitNodeValue+1)<<6);  // 0x4040\n    static const int32_t kThreeUnitNodeValueLead=0x7fc0;\n\n    static const int32_t kMaxTwoUnitNodeValue=\n        ((kThreeUnitNodeValueLead-kMinTwoUnitNodeValueLead)<<10)-1;  // 0xfdffff\n\n    // Compact delta integers.\n    static const int32_t kMaxOneUnitDelta=0xfbff;\n    static const int32_t kMinTwoUnitDeltaLead=kMaxOneUnitDelta+1;  // 0xfc00\n    static const int32_t kThreeUnitDeltaLead=0xffff;\n\n    static const int32_t kMaxTwoUnitDelta=((kThreeUnitDeltaLead-kMinTwoUnitDeltaLead)<<16)-1;  // 0x03feffff\n\n    UChar *ownedArray_;\n\n    // Fixed value referencing the UCharsTrie words.\n    const UChar *uchars_;\n\n    // Iterator variables.\n\n    // Pointer to next trie unit to read. NULL if no more matches.\n    const UChar *pos_;\n    // Remaining length of a linear-match node, minus 1. Negative if not in such a node.\n    int32_t remainingMatchLength_;\n};\n\nU_NAMESPACE_END\n\n#endif  // __UCHARSTRIE_H__\n"
  },
  {
    "path": "deprecated/android/addons/icucompat/unicode/ucharstriebuilder.h",
    "content": "/*\n*******************************************************************************\n*   Copyright (C) 2010-2012, International Business Machines\n*   Corporation and others.  All Rights Reserved.\n*******************************************************************************\n*   file name:  ucharstriebuilder.h\n*   encoding:   US-ASCII\n*   tab size:   8 (not used)\n*   indentation:4\n*\n*   created on: 2010nov14\n*   created by: Markus W. Scherer\n*/\n\n#ifndef __UCHARSTRIEBUILDER_H__\n#define __UCHARSTRIEBUILDER_H__\n\n#include \"unicode/utypes.h\"\n#include \"unicode/stringtriebuilder.h\"\n#include \"unicode/ucharstrie.h\"\n#include \"unicode/unistr.h\"\n\n/**\n * \\file\n * \\brief C++ API: Builder for icu::UCharsTrie\n */\n\nU_NAMESPACE_BEGIN\n\nclass UCharsTrieElement;\n\n/**\n * Builder class for UCharsTrie.\n *\n * This class is not intended for public subclassing.\n * @stable ICU 4.8\n */\nclass U_COMMON_API UCharsTrieBuilder : public StringTrieBuilder {\npublic:\n    /**\n     * Constructs an empty builder.\n     * @param errorCode Standard ICU error code.\n     * @stable ICU 4.8\n     */\n    UCharsTrieBuilder(UErrorCode &errorCode);\n\n    /**\n     * Destructor.\n     * @stable ICU 4.8\n     */\n    virtual ~UCharsTrieBuilder();\n\n    /**\n     * Adds a (string, value) pair.\n     * The string must be unique.\n     * The string contents will be copied; the builder does not keep\n     * a reference to the input UnicodeString or its buffer.\n     * @param s The input string.\n     * @param value The value associated with this string.\n     * @param errorCode Standard ICU error code. Its input value must\n     *                  pass the U_SUCCESS() test, or else the function returns\n     *                  immediately. Check for U_FAILURE() on output or use with\n     *                  function chaining. (See User Guide for details.)\n     * @return *this\n     * @stable ICU 4.8\n     */\n    UCharsTrieBuilder &add(const UnicodeString &s, int32_t value, UErrorCode &errorCode);\n\n    /**\n     * Builds a UCharsTrie for the add()ed data.\n     * Once built, no further data can be add()ed until clear() is called.\n     *\n     * This method passes ownership of the builder's internal result array to the new trie object.\n     * Another call to any build() variant will re-serialize the trie.\n     * After clear() has been called, a new array will be used as well.\n     * @param buildOption Build option, see UStringTrieBuildOption.\n     * @param errorCode Standard ICU error code. Its input value must\n     *                  pass the U_SUCCESS() test, or else the function returns\n     *                  immediately. Check for U_FAILURE() on output or use with\n     *                  function chaining. (See User Guide for details.)\n     * @return A new UCharsTrie for the add()ed data.\n     * @stable ICU 4.8\n     */\n    UCharsTrie *build(UStringTrieBuildOption buildOption, UErrorCode &errorCode);\n\n    /**\n     * Builds a UCharsTrie for the add()ed data and UChar-serializes it.\n     * Once built, no further data can be add()ed until clear() is called.\n     *\n     * Multiple calls to buildUnicodeString() set the UnicodeStrings to the\n     * builder's same UChar array, without rebuilding.\n     * If buildUnicodeString() is called after build(), the trie will be\n     * re-serialized into a new array.\n     * If build() is called after buildUnicodeString(), the trie object will become\n     * the owner of the previously returned array.\n     * After clear() has been called, a new array will be used as well.\n     * @param buildOption Build option, see UStringTrieBuildOption.\n     * @param result A UnicodeString which will be set to the UChar-serialized\n     *               UCharsTrie for the add()ed data.\n     * @param errorCode Standard ICU error code. Its input value must\n     *                  pass the U_SUCCESS() test, or else the function returns\n     *                  immediately. Check for U_FAILURE() on output or use with\n     *                  function chaining. (See User Guide for details.)\n     * @return result\n     * @stable ICU 4.8\n     */\n    UnicodeString &buildUnicodeString(UStringTrieBuildOption buildOption, UnicodeString &result,\n                                      UErrorCode &errorCode);\n\n    /**\n     * Removes all (string, value) pairs.\n     * New data can then be add()ed and a new trie can be built.\n     * @return *this\n     * @stable ICU 4.8\n     */\n    UCharsTrieBuilder &clear() {\n        strings.remove();\n        elementsLength=0;\n        ucharsLength=0;\n        return *this;\n    }\n\nprivate:\n    UCharsTrieBuilder(const UCharsTrieBuilder &other);  // no copy constructor\n    UCharsTrieBuilder &operator=(const UCharsTrieBuilder &other);  // no assignment operator\n\n    void buildUChars(UStringTrieBuildOption buildOption, UErrorCode &errorCode);\n\n    virtual int32_t getElementStringLength(int32_t i) const;\n    virtual UChar getElementUnit(int32_t i, int32_t unitIndex) const;\n    virtual int32_t getElementValue(int32_t i) const;\n\n    virtual int32_t getLimitOfLinearMatch(int32_t first, int32_t last, int32_t unitIndex) const;\n\n    virtual int32_t countElementUnits(int32_t start, int32_t limit, int32_t unitIndex) const;\n    virtual int32_t skipElementsBySomeUnits(int32_t i, int32_t unitIndex, int32_t count) const;\n    virtual int32_t indexOfElementWithNextUnit(int32_t i, int32_t unitIndex, UChar unit) const;\n\n    virtual UBool matchNodesCanHaveValues() const { return TRUE; }\n\n    virtual int32_t getMaxBranchLinearSubNodeLength() const { return UCharsTrie::kMaxBranchLinearSubNodeLength; }\n    virtual int32_t getMinLinearMatch() const { return UCharsTrie::kMinLinearMatch; }\n    virtual int32_t getMaxLinearMatchLength() const { return UCharsTrie::kMaxLinearMatchLength; }\n\n#ifndef U_HIDE_INTERNAL_API\n    class UCTLinearMatchNode : public LinearMatchNode {\n    public:\n        UCTLinearMatchNode(const UChar *units, int32_t len, Node *nextNode);\n        virtual UBool operator==(const Node &other) const;\n        virtual void write(StringTrieBuilder &builder);\n    private:\n        const UChar *s;\n    };\n#endif\n\n    virtual Node *createLinearMatchNode(int32_t i, int32_t unitIndex, int32_t length,\n                                        Node *nextNode) const;\n\n    UBool ensureCapacity(int32_t length);\n    virtual int32_t write(int32_t unit);\n    int32_t write(const UChar *s, int32_t length);\n    virtual int32_t writeElementUnits(int32_t i, int32_t unitIndex, int32_t length);\n    virtual int32_t writeValueAndFinal(int32_t i, UBool isFinal);\n    virtual int32_t writeValueAndType(UBool hasValue, int32_t value, int32_t node);\n    virtual int32_t writeDeltaTo(int32_t jumpTarget);\n\n    UnicodeString strings;\n    UCharsTrieElement *elements;\n    int32_t elementsCapacity;\n    int32_t elementsLength;\n\n    // UChar serialization of the trie.\n    // Grows from the back: ucharsLength measures from the end of the buffer!\n    UChar *uchars;\n    int32_t ucharsCapacity;\n    int32_t ucharsLength;\n};\n\nU_NAMESPACE_END\n\n#endif  // __UCHARSTRIEBUILDER_H__\n"
  },
  {
    "path": "deprecated/android/addons/icucompat/unicode/uchriter.h",
    "content": "/*\n**********************************************************************\n*   Copyright (C) 1998-2005, International Business Machines\n*   Corporation and others.  All Rights Reserved.\n**********************************************************************\n*/\n\n#ifndef UCHRITER_H\n#define UCHRITER_H\n\n#include \"unicode/utypes.h\"\n#include \"unicode/chariter.h\"\n\n/**\n * \\file \n * \\brief C++ API: UChar Character Iterator\n */\n \nU_NAMESPACE_BEGIN\n\n/**\n * A concrete subclass of CharacterIterator that iterates over the\n * characters (code units or code points) in a UChar array.\n * It's possible not only to create an\n * iterator that iterates over an entire UChar array, but also to\n * create one that iterates over only a subrange of a UChar array\n * (iterators over different subranges of the same UChar array don't\n * compare equal).\n * @see CharacterIterator\n * @see ForwardCharacterIterator\n * @stable ICU 2.0\n */\nclass U_COMMON_API UCharCharacterIterator : public CharacterIterator {\npublic:\n  /**\n   * Create an iterator over the UChar array referred to by \"textPtr\".\n   * The iteration range is 0 to <code>length-1</code>.\n   * text is only aliased, not adopted (the\n   * destructor will not delete it).\n   * @param textPtr The UChar array to be iterated over\n   * @param length The length of the UChar array\n   * @stable ICU 2.0\n   */\n  UCharCharacterIterator(const UChar* textPtr, int32_t length);\n\n  /**\n   * Create an iterator over the UChar array referred to by \"textPtr\".\n   * The iteration range is 0 to <code>length-1</code>.\n   * text is only aliased, not adopted (the\n   * destructor will not delete it).\n   * The starting\n   * position is specified by \"position\". If \"position\" is outside the valid\n   * iteration range, the behavior of this object is undefined.\n   * @param textPtr The UChar array to be iteratd over\n   * @param length The length of the UChar array\n   * @param position The starting position of the iteration\n   * @stable ICU 2.0\n   */\n  UCharCharacterIterator(const UChar* textPtr, int32_t length,\n                         int32_t position);\n\n  /**\n   * Create an iterator over the UChar array referred to by \"textPtr\".\n   * The iteration range is 0 to <code>end-1</code>.\n   * text is only aliased, not adopted (the\n   * destructor will not delete it).\n   * The starting\n   * position is specified by \"position\". If begin and end do not\n   * form a valid iteration range or \"position\" is outside the valid\n   * iteration range, the behavior of this object is undefined.\n   * @param textPtr The UChar array to be iterated over\n   * @param length The length of the UChar array\n   * @param textBegin  The begin position of the iteration range\n   * @param textEnd    The end position of the iteration range\n   * @param position    The starting position of the iteration\n   * @stable ICU 2.0\n   */\n  UCharCharacterIterator(const UChar* textPtr, int32_t length,\n                         int32_t textBegin,\n                         int32_t textEnd,\n                         int32_t position);\n\n  /**\n   * Copy constructor.  The new iterator iterates over the same range\n   * of the same string as \"that\", and its initial position is the\n   * same as \"that\"'s current position.\n   * @param that The UCharCharacterIterator to be copied\n   * @stable ICU 2.0\n   */\n  UCharCharacterIterator(const UCharCharacterIterator&  that);\n\n  /**\n   * Destructor.\n   * @stable ICU 2.0\n   */\n  virtual ~UCharCharacterIterator();\n\n  /**\n   * Assignment operator.  *this is altered to iterate over the sane\n   * range of the same string as \"that\", and refers to the same\n   * character within that string as \"that\" does.\n   * @param that The object to be copied\n   * @return the newly created object\n   * @stable ICU 2.0\n   */\n  UCharCharacterIterator&\n  operator=(const UCharCharacterIterator&    that);\n\n  /**\n   * Returns true if the iterators iterate over the same range of the\n   * same string and are pointing at the same character.\n   * @param that The ForwardCharacterIterator used to be compared for equality\n   * @return true if the iterators iterate over the same range of the\n   * same string and are pointing at the same character.\n   * @stable ICU 2.0\n   */\n  virtual UBool          operator==(const ForwardCharacterIterator& that) const;\n\n  /**\n   * Generates a hash code for this iterator.\n   * @return the hash code.\n   * @stable ICU 2.0\n   */\n  virtual int32_t         hashCode(void) const;\n\n  /**\n   * Returns a new UCharCharacterIterator referring to the same\n   * character in the same range of the same string as this one.  The\n   * caller must delete the new iterator.\n   * @return the CharacterIterator newly created\n   * @stable ICU 2.0\n   */\n  virtual CharacterIterator* clone(void) const;\n\n  /**\n   * Sets the iterator to refer to the first code unit in its\n   * iteration range, and returns that code unit.\n   * This can be used to begin an iteration with next().\n   * @return the first code unit in its iteration range.\n   * @stable ICU 2.0\n   */\n  virtual UChar         first(void);\n\n  /**\n   * Sets the iterator to refer to the first code unit in its\n   * iteration range, returns that code unit, and moves the position\n   * to the second code unit. This is an alternative to setToStart()\n   * for forward iteration with nextPostInc().\n   * @return the first code unit in its iteration range\n   * @stable ICU 2.0\n   */\n  virtual UChar         firstPostInc(void);\n\n  /**\n   * Sets the iterator to refer to the first code point in its\n   * iteration range, and returns that code unit,\n   * This can be used to begin an iteration with next32().\n   * Note that an iteration with next32PostInc(), beginning with,\n   * e.g., setToStart() or firstPostInc(), is more efficient.\n   * @return the first code point in its iteration range\n   * @stable ICU 2.0\n   */\n  virtual UChar32       first32(void);\n\n  /**\n   * Sets the iterator to refer to the first code point in its\n   * iteration range, returns that code point, and moves the position\n   * to the second code point. This is an alternative to setToStart()\n   * for forward iteration with next32PostInc().\n   * @return the first code point in its iteration range.\n   * @stable ICU 2.0\n   */\n  virtual UChar32       first32PostInc(void);\n\n  /**\n   * Sets the iterator to refer to the last code unit in its\n   * iteration range, and returns that code unit.\n   * This can be used to begin an iteration with previous().\n   * @return the last code unit in its iteration range.\n   * @stable ICU 2.0\n   */\n  virtual UChar         last(void);\n\n  /**\n   * Sets the iterator to refer to the last code point in its\n   * iteration range, and returns that code unit.\n   * This can be used to begin an iteration with previous32().\n   * @return the last code point in its iteration range.\n   * @stable ICU 2.0\n   */\n  virtual UChar32       last32(void);\n\n  /**\n   * Sets the iterator to refer to the \"position\"-th code unit\n   * in the text-storage object the iterator refers to, and\n   * returns that code unit.\n   * @param position the position within the text-storage object\n   * @return the code unit\n   * @stable ICU 2.0\n   */\n  virtual UChar         setIndex(int32_t position);\n\n  /**\n   * Sets the iterator to refer to the beginning of the code point\n   * that contains the \"position\"-th code unit\n   * in the text-storage object the iterator refers to, and\n   * returns that code point.\n   * The current position is adjusted to the beginning of the code point\n   * (its first code unit).\n   * @param position the position within the text-storage object\n   * @return the code unit\n   * @stable ICU 2.0\n   */\n  virtual UChar32       setIndex32(int32_t position);\n\n  /**\n   * Returns the code unit the iterator currently refers to.\n   * @return the code unit the iterator currently refers to.\n   * @stable ICU 2.0\n   */\n  virtual UChar         current(void) const;\n\n  /**\n   * Returns the code point the iterator currently refers to.\n   * @return the code point the iterator currently refers to.\n   * @stable ICU 2.0\n   */\n  virtual UChar32       current32(void) const;\n\n  /**\n   * Advances to the next code unit in the iteration range (toward\n   * endIndex()), and returns that code unit.  If there are no more\n   * code units to return, returns DONE.\n   * @return the next code unit in the iteration range.\n   * @stable ICU 2.0\n   */\n  virtual UChar         next(void);\n\n  /**\n   * Gets the current code unit for returning and advances to the next code unit\n   * in the iteration range\n   * (toward endIndex()).  If there are\n   * no more code units to return, returns DONE.\n   * @return the current code unit.\n   * @stable ICU 2.0\n   */\n  virtual UChar         nextPostInc(void);\n\n  /**\n   * Advances to the next code point in the iteration range (toward\n   * endIndex()), and returns that code point.  If there are no more\n   * code points to return, returns DONE.\n   * Note that iteration with \"pre-increment\" semantics is less\n   * efficient than iteration with \"post-increment\" semantics\n   * that is provided by next32PostInc().\n   * @return the next code point in the iteration range.\n   * @stable ICU 2.0\n   */\n  virtual UChar32       next32(void);\n\n  /**\n   * Gets the current code point for returning and advances to the next code point\n   * in the iteration range\n   * (toward endIndex()).  If there are\n   * no more code points to return, returns DONE.\n   * @return the current point.\n   * @stable ICU 2.0\n   */\n  virtual UChar32       next32PostInc(void);\n\n  /**\n   * Returns FALSE if there are no more code units or code points\n   * at or after the current position in the iteration range.\n   * This is used with nextPostInc() or next32PostInc() in forward\n   * iteration.\n   * @return FALSE if there are no more code units or code points\n   * at or after the current position in the iteration range.\n   * @stable ICU 2.0\n   */\n  virtual UBool        hasNext();\n\n  /**\n   * Advances to the previous code unit in the iteration range (toward\n   * startIndex()), and returns that code unit.  If there are no more\n   * code units to return, returns DONE.\n   * @return the previous code unit in the iteration range.\n   * @stable ICU 2.0\n   */\n  virtual UChar         previous(void);\n\n  /**\n   * Advances to the previous code point in the iteration range (toward\n   * startIndex()), and returns that code point.  If there are no more\n   * code points to return, returns DONE.\n   * @return the previous code point in the iteration range.\n   * @stable ICU 2.0\n   */\n  virtual UChar32       previous32(void);\n\n  /**\n   * Returns FALSE if there are no more code units or code points\n   * before the current position in the iteration range.\n   * This is used with previous() or previous32() in backward\n   * iteration.\n   * @return FALSE if there are no more code units or code points\n   * before the current position in the iteration range.\n   * @stable ICU 2.0\n   */\n  virtual UBool        hasPrevious();\n\n  /**\n   * Moves the current position relative to the start or end of the\n   * iteration range, or relative to the current position itself.\n   * The movement is expressed in numbers of code units forward\n   * or backward by specifying a positive or negative delta.\n   * @param delta the position relative to origin. A positive delta means forward;\n   * a negative delta means backward.\n   * @param origin Origin enumeration {kStart, kCurrent, kEnd}\n   * @return the new position\n   * @stable ICU 2.0\n   */\n  virtual int32_t      move(int32_t delta, EOrigin origin);\n\n  /**\n   * Moves the current position relative to the start or end of the\n   * iteration range, or relative to the current position itself.\n   * The movement is expressed in numbers of code points forward\n   * or backward by specifying a positive or negative delta.\n   * @param delta the position relative to origin. A positive delta means forward;\n   * a negative delta means backward.\n   * @param origin Origin enumeration {kStart, kCurrent, kEnd}\n   * @return the new position\n   * @stable ICU 2.0\n   */\n  virtual int32_t      move32(int32_t delta, EOrigin origin);\n\n  /**\n   * Sets the iterator to iterate over a new range of text\n   * @stable ICU 2.0\n   */\n  void setText(const UChar* newText, int32_t newTextLength);\n\n  /**\n   * Copies the UChar array under iteration into the UnicodeString\n   * referred to by \"result\".  Even if this iterator iterates across\n   * only a part of this string, the whole string is copied.\n   * @param result Receives a copy of the text under iteration.\n   * @stable ICU 2.0\n   */\n  virtual void            getText(UnicodeString& result);\n\n  /**\n   * Return a class ID for this class (not really public)\n   * @return a class ID for this class\n   * @stable ICU 2.0\n   */\n  static UClassID         U_EXPORT2 getStaticClassID(void);\n\n  /**\n   * Return a class ID for this object (not really public)\n   * @return a class ID for this object.\n   * @stable ICU 2.0\n   */\n  virtual UClassID        getDynamicClassID(void) const;\n\nprotected:\n  /**\n   * Protected constructor\n   * @stable ICU 2.0\n   */\n  UCharCharacterIterator();\n  /**\n   * Protected member text\n   * @stable ICU 2.0\n   */\n  const UChar*            text;\n\n};\n\nU_NAMESPACE_END\n#endif\n"
  },
  {
    "path": "deprecated/android/addons/icucompat/unicode/uclean.h",
    "content": "/*\n******************************************************************************\n* Copyright (C) 2001-2012, International Business Machines\n*                Corporation and others. All Rights Reserved.\n******************************************************************************\n*   file name:  uclean.h\n*   encoding:   US-ASCII\n*   tab size:   8 (not used)\n*   indentation:4\n*\n*   created on: 2001July05\n*   created by: George Rhoten\n*/\n\n#ifndef __UCLEAN_H__\n#define __UCLEAN_H__\n\n#include \"unicode/utypes.h\"\n/**\n * \\file\n * \\brief C API: Initialize and clean up ICU\n */\n \n/**\n *  Initialize ICU.\n *\n *  Use of this function is optional.  It is OK to simply use ICU\n *  services and functions without first having initialized\n *  ICU by calling u_init().\n *\n *  u_init() will attempt to load some part of ICU's data, and is\n *  useful as a test for configuration or installation problems that\n *  leave the ICU data inaccessible.  A successful invocation of u_init()\n *  does not, however, guarantee that all ICU data is accessible.\n *\n *  Multiple calls to u_init() cause no harm, aside from the small amount\n *  of time required.\n *\n *  In old versions of ICU, u_init() was required in multi-threaded applications\n *  to ensure the thread safety of ICU.  u_init() is no longer needed for this purpose.\n *\n * @param status An ICU UErrorCode parameter. It must not be <code>NULL</code>.\n *    An Error will be returned if some required part of ICU data can not\n *    be loaded or initialized.\n *    The function returns immediately if the input error code indicates a\n *    failure, as usual.\n *\n * @stable ICU 2.6\n */  \nU_STABLE void U_EXPORT2 \nu_init(UErrorCode *status);\n\n#ifndef U_HIDE_SYSTEM_API\n/**\n * Clean up the system resources, such as allocated memory or open files,\n * used in all ICU libraries. This will free/delete all memory owned by the\n * ICU libraries, and return them to their original load state. All open ICU\n * items (collators, resource bundles, converters, etc.) must be closed before\n * calling this function, otherwise ICU may not free its allocated memory\n * (e.g. close your converters and resource bundles before calling this\n * function). Generally, this function should be called once just before\n * an application exits. For applications that dynamically load and unload\n * the ICU libraries (relatively uncommon), u_cleanup() should be called\n * just before the library unload.\n * <p>\n * u_cleanup() also clears any ICU heap functions, mutex functions or\n * trace functions that may have been set for the process.  \n * This has the effect of restoring ICU to its initial condition, before\n * any of these override functions were installed.  Refer to\n * u_setMemoryFunctions(), u_setMutexFunctions and \n * utrace_setFunctions().  If ICU is to be reinitialized after after\n * calling u_cleanup(), these runtime override functions will need to\n * be set up again if they are still required.\n * <p>\n * u_cleanup() is not thread safe.  All other threads should stop using ICU\n * before calling this function.\n * <p>\n * Any open ICU items will be left in an undefined state by u_cleanup(),\n * and any subsequent attempt to use such an item will give unpredictable\n * results.\n * <p>\n * After calling u_cleanup(), an application may continue to use ICU by\n * calling u_init().  An application must invoke u_init() first from one single\n * thread before allowing other threads call u_init().  All threads existing\n * at the time of the first thread's call to u_init() must also call\n * u_init() themselves before continuing with other ICU operations.  \n * <p>\n * The use of u_cleanup() just before an application terminates is optional,\n * but it should be called only once for performance reasons. The primary\n * benefit is to eliminate reports of memory or resource leaks originating\n * in ICU code from the results generated by heap analysis tools.\n * <p>\n * <strong>Use this function with great care!</strong>\n * </p>\n *\n * @stable ICU 2.0\n * @system\n */\nU_STABLE void U_EXPORT2 \nu_cleanup(void);\n\n\n\n\n/**\n  * An opaque pointer type that represents an ICU mutex.\n  * For user-implemented mutexes, the value will typically point to a\n  *  struct or object that implements the mutex.\n  * @stable ICU 2.8\n  * @system\n  */\ntypedef void *UMTX;\n\n/**\n  *  Function Pointer type for a user supplied mutex initialization function.\n  *  The user-supplied function will be called by ICU whenever ICU needs to create a\n  *  new mutex.  The function implementation should create a mutex, and store a pointer\n  *  to something that uniquely identifies the mutex into the UMTX that is supplied\n  *  as a paramter.\n  *  @param context user supplied value, obtained from from u_setMutexFunctions().\n  *  @param mutex   Receives a pointer that identifies the new mutex.\n  *                 The mutex init function must set the UMTX to a non-null value.   \n  *                 Subsequent calls by ICU to lock, unlock, or destroy a mutex will \n  *                 identify the mutex by the UMTX value.\n  *  @param status  Error status.  Report errors back to ICU by setting this variable\n  *                 with an error code.\n  *  @stable ICU 2.8\n  *  @system\n  */\ntypedef void U_CALLCONV UMtxInitFn (const void *context, UMTX  *mutex, UErrorCode* status);\n\n\n/**\n  *  Function Pointer type for a user supplied mutex functions.\n  *  One of the  user-supplied functions with this signature will be called by ICU\n  *  whenever ICU needs to lock, unlock, or destroy a mutex.\n  *  @param context user supplied value, obtained from from u_setMutexFunctions().\n  *  @param mutex   specify the mutex on which to operate.\n  *  @stable ICU 2.8\n  *  @system\n  */\ntypedef void U_CALLCONV UMtxFn   (const void *context, UMTX  *mutex);\n\n\n/**\n  *  Set the functions that ICU will use for mutex operations\n  *  Use of this function is optional; by default (without this function), ICU will\n  *  directly access system functions for mutex operations\n  *  This function can only be used when ICU is in an initial, unused state, before\n  *  u_init() has been called.\n  *  @param context This pointer value will be saved, and then (later) passed as\n  *                 a parameter to the user-supplied mutex functions each time they\n  *                 are called. \n  *  @param init    Pointer to a mutex initialization function.  Must be non-null.\n  *  @param destroy Pointer to the mutex destroy function.  Must be non-null.\n  *  @param lock    pointer to the mutex lock function.  Must be non-null.\n  *  @param unlock  Pointer to the mutex unlock function.  Must be non-null.\n  *  @param status  Receives error values.\n  *  @stable ICU 2.8\n  *  @system\n  */  \nU_STABLE void U_EXPORT2 \nu_setMutexFunctions(const void *context, UMtxInitFn *init, UMtxFn *destroy, UMtxFn *lock, UMtxFn *unlock,\n                    UErrorCode *status);\n\n\n/**\n  *  Pointer type for a user supplied atomic increment or decrement function.\n  *  @param context user supplied value, obtained from from u_setAtomicIncDecFunctions().\n  *  @param p   Pointer to a 32 bit int to be incremented or decremented\n  *  @return    The value of the variable after the inc or dec operation.\n  *  @stable ICU 2.8\n  *  @system\n  */\ntypedef int32_t U_CALLCONV UMtxAtomicFn(const void *context, int32_t *p);\n\n/**\n *  Set the functions that ICU will use for atomic increment and decrement of int32_t values.\n *  Use of this function is optional; by default (without this function), ICU will\n *  use its own internal implementation of atomic increment/decrement.\n *  This function can only be used when ICU is in an initial, unused state, before\n *  u_init() has been called.\n *  @param context This pointer value will be saved, and then (later) passed as\n *                 a parameter to the increment and decrement functions each time they\n *                 are called.  This function can only be called \n *  @param inc     Pointer to a function to do an atomic increment operation.  Must be non-null.\n *  @param dec     Pointer to a function to do an atomic decrement operation.  Must be non-null.\n *  @param status  Receives error values.\n *  @stable ICU 2.8\n *  @system\n */  \nU_STABLE void U_EXPORT2 \nu_setAtomicIncDecFunctions(const void *context, UMtxAtomicFn *inc, UMtxAtomicFn *dec,\n                    UErrorCode *status);\n\n\n\n/**\n  *  Pointer type for a user supplied memory allocation function.\n  *  @param context user supplied value, obtained from from u_setMemoryFunctions().\n  *  @param size    The number of bytes to be allocated\n  *  @return        Pointer to the newly allocated memory, or NULL if the allocation failed.\n  *  @stable ICU 2.8\n  *  @system\n  */\ntypedef void *U_CALLCONV UMemAllocFn(const void *context, size_t size);\n/**\n  *  Pointer type for a user supplied memory re-allocation function.\n  *  @param context user supplied value, obtained from from u_setMemoryFunctions().\n  *  @param size    The number of bytes to be allocated\n  *  @return        Pointer to the newly allocated memory, or NULL if the allocation failed.\n  *  @stable ICU 2.8\n  *  @system\n  */\ntypedef void *U_CALLCONV UMemReallocFn(const void *context, void *mem, size_t size);\n/**\n  *  Pointer type for a user supplied memory free  function.  Behavior should be\n  *  similar the standard C library free().\n  *  @param context user supplied value, obtained from from u_setMemoryFunctions().\n  *  @param mem     Pointer to the memory block to be resized\n  *  @param size    The new size for the block\n  *  @return        Pointer to the resized memory block, or NULL if the resizing failed.\n  *  @stable ICU 2.8\n  *  @system\n  */\ntypedef void  U_CALLCONV UMemFreeFn (const void *context, void *mem);\n\n/**\n *  Set the functions that ICU will use for memory allocation.\n *  Use of this function is optional; by default (without this function), ICU will\n *  use the standard C library malloc() and free() functions.\n *  This function can only be used when ICU is in an initial, unused state, before\n *  u_init() has been called.\n *  @param context This pointer value will be saved, and then (later) passed as\n *                 a parameter to the memory functions each time they\n *                 are called.\n *  @param a       Pointer to a user-supplied malloc function.\n *  @param r       Pointer to a user-supplied realloc function.\n *  @param f       Pointer to a user-supplied free function.\n *  @param status  Receives error values.\n *  @stable ICU 2.8\n *  @system\n */  \nU_STABLE void U_EXPORT2 \nu_setMemoryFunctions(const void *context, UMemAllocFn *a, UMemReallocFn *r, UMemFreeFn *f, \n                    UErrorCode *status);\n#endif  /* U_HIDE_SYSTEM_API */\n\n#endif\n"
  },
  {
    "path": "deprecated/android/addons/icucompat/unicode/ucnv.h",
    "content": "/*\n**********************************************************************\n*   Copyright (C) 1999-2012, International Business Machines\n*   Corporation and others.  All Rights Reserved.\n**********************************************************************\n *  ucnv.h:\n *  External APIs for the ICU's codeset conversion library\n *  Bertrand A. Damiba\n *\n * Modification History:\n *\n *   Date        Name        Description\n *   04/04/99    helena      Fixed internal header inclusion.\n *   05/11/00    helena      Added setFallback and usesFallback APIs.\n *   06/29/2000  helena      Major rewrite of the callback APIs.\n *   12/07/2000  srl         Update of documentation\n */\n\n/**\n * \\file\n * \\brief C API: Character conversion \n *\n * <h2>Character Conversion C API</h2>\n *\n * <p>This API is used to convert codepage or character encoded data to and\n * from UTF-16. You can open a converter with {@link ucnv_open() }. With that\n * converter, you can get its properties, set options, convert your data and\n * close the converter.</p>\n *\n * <p>Since many software programs recogize different converter names for\n * different types of converters, there are other functions in this API to\n * iterate over the converter aliases. The functions {@link ucnv_getAvailableName() },\n * {@link ucnv_getAlias() } and {@link ucnv_getStandardName() } are some of the\n * more frequently used alias functions to get this information.</p>\n *\n * <p>When a converter encounters an illegal, irregular, invalid or unmappable character\n * its default behavior is to use a substitution character to replace the\n * bad byte sequence. This behavior can be changed by using {@link ucnv_setFromUCallBack() }\n * or {@link ucnv_setToUCallBack() } on the converter. The header ucnv_err.h defines\n * many other callback actions that can be used instead of a character substitution.</p>\n *\n * <p>More information about this API can be found in our \n * <a href=\"http://icu-project.org/userguide/conversion.html\">User's\n * Guide</a>.</p>\n */\n\n#ifndef UCNV_H\n#define UCNV_H\n\n#include \"unicode/ucnv_err.h\"\n#include \"unicode/uenum.h\"\n#include \"unicode/localpointer.h\"\n\n#ifndef __USET_H__\n\n/**\n * USet is the C API type for Unicode sets.\n * It is forward-declared here to avoid including the header file if related\n * conversion APIs are not used.\n * See unicode/uset.h\n *\n * @see ucnv_getUnicodeSet\n * @stable ICU 2.6\n */\nstruct USet;\n/** @stable ICU 2.6 */\ntypedef struct USet USet;\n\n#endif\n\n#if !UCONFIG_NO_CONVERSION\n\nU_CDECL_BEGIN\n\n/** Maximum length of a converter name including the terminating NULL @stable ICU 2.0 */\n#define UCNV_MAX_CONVERTER_NAME_LENGTH 60\n/** Maximum length of a converter name including path and terminating NULL @stable ICU 2.0 */\n#define UCNV_MAX_FULL_FILE_NAME_LENGTH (600+UCNV_MAX_CONVERTER_NAME_LENGTH)\n\n/** Shift in for EBDCDIC_STATEFUL and iso2022 states @stable ICU 2.0 */\n#define  UCNV_SI 0x0F\n/** Shift out for EBDCDIC_STATEFUL and iso2022 states @stable ICU 2.0 */\n#define  UCNV_SO 0x0E\n\n/**\n * Enum for specifying basic types of converters\n * @see ucnv_getType\n * @stable ICU 2.0\n */\ntypedef enum {\n    /** @stable ICU 2.0 */\n    UCNV_UNSUPPORTED_CONVERTER = -1,\n    /** @stable ICU 2.0 */\n    UCNV_SBCS = 0,\n    /** @stable ICU 2.0 */\n    UCNV_DBCS = 1,\n    /** @stable ICU 2.0 */\n    UCNV_MBCS = 2,\n    /** @stable ICU 2.0 */\n    UCNV_LATIN_1 = 3,\n    /** @stable ICU 2.0 */\n    UCNV_UTF8 = 4,\n    /** @stable ICU 2.0 */\n    UCNV_UTF16_BigEndian = 5,\n    /** @stable ICU 2.0 */\n    UCNV_UTF16_LittleEndian = 6,\n    /** @stable ICU 2.0 */\n    UCNV_UTF32_BigEndian = 7,\n    /** @stable ICU 2.0 */\n    UCNV_UTF32_LittleEndian = 8,\n    /** @stable ICU 2.0 */\n    UCNV_EBCDIC_STATEFUL = 9,\n    /** @stable ICU 2.0 */\n    UCNV_ISO_2022 = 10,\n\n    /** @stable ICU 2.0 */\n    UCNV_LMBCS_1 = 11,\n    /** @stable ICU 2.0 */\n    UCNV_LMBCS_2, \n    /** @stable ICU 2.0 */\n    UCNV_LMBCS_3,\n    /** @stable ICU 2.0 */\n    UCNV_LMBCS_4,\n    /** @stable ICU 2.0 */\n    UCNV_LMBCS_5,\n    /** @stable ICU 2.0 */\n    UCNV_LMBCS_6,\n    /** @stable ICU 2.0 */\n    UCNV_LMBCS_8,\n    /** @stable ICU 2.0 */\n    UCNV_LMBCS_11,\n    /** @stable ICU 2.0 */\n    UCNV_LMBCS_16,\n    /** @stable ICU 2.0 */\n    UCNV_LMBCS_17,\n    /** @stable ICU 2.0 */\n    UCNV_LMBCS_18,\n    /** @stable ICU 2.0 */\n    UCNV_LMBCS_19,\n    /** @stable ICU 2.0 */\n    UCNV_LMBCS_LAST = UCNV_LMBCS_19,\n    /** @stable ICU 2.0 */\n    UCNV_HZ,\n    /** @stable ICU 2.0 */\n    UCNV_SCSU,\n    /** @stable ICU 2.0 */\n    UCNV_ISCII,\n    /** @stable ICU 2.0 */\n    UCNV_US_ASCII,\n    /** @stable ICU 2.0 */\n    UCNV_UTF7,\n    /** @stable ICU 2.2 */\n    UCNV_BOCU1,\n    /** @stable ICU 2.2 */\n    UCNV_UTF16,\n    /** @stable ICU 2.2 */\n    UCNV_UTF32,\n    /** @stable ICU 2.2 */\n    UCNV_CESU8,\n    /** @stable ICU 2.4 */\n    UCNV_IMAP_MAILBOX,\n    /** @stable ICU 4.8 */\n    UCNV_COMPOUND_TEXT,\n\n    /* Number of converter types for which we have conversion routines. */\n    UCNV_NUMBER_OF_SUPPORTED_CONVERTER_TYPES\n} UConverterType;\n\n/**\n * Enum for specifying which platform a converter ID refers to.\n * The use of platform/CCSID is not recommended. See ucnv_openCCSID().\n *\n * @see ucnv_getPlatform\n * @see ucnv_openCCSID\n * @see ucnv_getCCSID\n * @stable ICU 2.0\n */\ntypedef enum {\n    UCNV_UNKNOWN = -1,\n    UCNV_IBM = 0\n} UConverterPlatform;\n\n/**\n * Function pointer for error callback in the codepage to unicode direction.\n * Called when an error has occured in conversion to unicode, or on open/close of the callback (see reason).\n * @param context Pointer to the callback's private data\n * @param args Information about the conversion in progress\n * @param codeUnits Points to 'length' bytes of the concerned codepage sequence\n * @param length Size (in bytes) of the concerned codepage sequence\n * @param reason Defines the reason the callback was invoked\n * @param pErrorCode    ICU error code in/out parameter.\n *                      For converter callback functions, set to a conversion error\n *                      before the call, and the callback may reset it to U_ZERO_ERROR.\n * @see ucnv_setToUCallBack\n * @see UConverterToUnicodeArgs\n * @stable ICU 2.0\n */\ntypedef void (U_EXPORT2 *UConverterToUCallback) (\n                  const void* context,\n                  UConverterToUnicodeArgs *args,\n                  const char *codeUnits,\n                  int32_t length,\n                  UConverterCallbackReason reason,\n                  UErrorCode *pErrorCode);\n\n/**\n * Function pointer for error callback in the unicode to codepage direction.\n * Called when an error has occured in conversion from unicode, or on open/close of the callback (see reason).\n * @param context Pointer to the callback's private data\n * @param args Information about the conversion in progress\n * @param codeUnits Points to 'length' UChars of the concerned Unicode sequence\n * @param length Size (in bytes) of the concerned codepage sequence\n * @param codePoint Single UChar32 (UTF-32) containing the concerend Unicode codepoint.\n * @param reason Defines the reason the callback was invoked\n * @param pErrorCode    ICU error code in/out parameter.\n *                      For converter callback functions, set to a conversion error\n *                      before the call, and the callback may reset it to U_ZERO_ERROR.\n * @see ucnv_setFromUCallBack\n * @stable ICU 2.0\n */\ntypedef void (U_EXPORT2 *UConverterFromUCallback) (\n                    const void* context,\n                    UConverterFromUnicodeArgs *args,\n                    const UChar* codeUnits,\n                    int32_t length,\n                    UChar32 codePoint,\n                    UConverterCallbackReason reason,\n                    UErrorCode *pErrorCode);\n\nU_CDECL_END\n\n/**\n * Character that separates converter names from options and options from each other.\n * @see ucnv_open\n * @stable ICU 2.0\n */\n#define UCNV_OPTION_SEP_CHAR ','\n\n/**\n * String version of UCNV_OPTION_SEP_CHAR. \n * @see ucnv_open\n * @stable ICU 2.0\n */\n#define UCNV_OPTION_SEP_STRING \",\"\n\n/**\n * Character that separates a converter option from its value.\n * @see ucnv_open\n * @stable ICU 2.0\n */\n#define UCNV_VALUE_SEP_CHAR '='\n\n/**\n * String version of UCNV_VALUE_SEP_CHAR. \n * @see ucnv_open\n * @stable ICU 2.0\n */\n#define UCNV_VALUE_SEP_STRING \"=\"\n\n/**\n * Converter option for specifying a locale.\n * For example, ucnv_open(\"SCSU,locale=ja\", &errorCode);\n * See convrtrs.txt.\n *\n * @see ucnv_open\n * @stable ICU 2.0\n */\n#define UCNV_LOCALE_OPTION_STRING \",locale=\"\n\n/**\n * Converter option for specifying a version selector (0..9) for some converters.\n * For example, \n * \\code\n *   ucnv_open(\"UTF-7,version=1\", &errorCode);\n * \\endcode\n * See convrtrs.txt.\n *\n * @see ucnv_open\n * @stable ICU 2.4\n */\n#define UCNV_VERSION_OPTION_STRING \",version=\"\n\n/**\n * Converter option for EBCDIC SBCS or mixed-SBCS/DBCS (stateful) codepages.\n * Swaps Unicode mappings for EBCDIC LF and NL codes, as used on\n * S/390 (z/OS) Unix System Services (Open Edition).\n * For example, ucnv_open(\"ibm-1047,swaplfnl\", &errorCode);\n * See convrtrs.txt.\n *\n * @see ucnv_open\n * @stable ICU 2.4\n */\n#define UCNV_SWAP_LFNL_OPTION_STRING \",swaplfnl\"\n\n/**\n * Do a fuzzy compare of two converter/alias names.\n * The comparison is case-insensitive, ignores leading zeroes if they are not\n * followed by further digits, and ignores all but letters and digits.\n * Thus the strings \"UTF-8\", \"utf_8\", \"u*T@f08\" and \"Utf 8\" are exactly equivalent.\n * See section 1.4, Charset Alias Matching in Unicode Technical Standard #22\n * at http://www.unicode.org/reports/tr22/\n *\n * @param name1 a converter name or alias, zero-terminated\n * @param name2 a converter name or alias, zero-terminated\n * @return 0 if the names match, or a negative value if the name1\n * lexically precedes name2, or a positive value if the name1\n * lexically follows name2.\n * @stable ICU 2.0\n */\nU_STABLE int U_EXPORT2\nucnv_compareNames(const char *name1, const char *name2);\n\n\n/**\n * Creates a UConverter object with the name of a coded character set specified as a C string.\n * The actual name will be resolved with the alias file\n * using a case-insensitive string comparison that ignores\n * leading zeroes and all non-alphanumeric characters.\n * E.g., the names \"UTF8\", \"utf-8\", \"u*T@f08\" and \"Utf 8\" are all equivalent.\n * (See also ucnv_compareNames().)\n * If <code>NULL</code> is passed for the converter name, it will create one with the\n * getDefaultName return value.\n *\n * <p>A converter name for ICU 1.5 and above may contain options\n * like a locale specification to control the specific behavior of\n * the newly instantiated converter.\n * The meaning of the options depends on the particular converter.\n * If an option is not defined for or recognized by a given converter, then it is ignored.</p>\n *\n * <p>Options are appended to the converter name string, with a\n * <code>UCNV_OPTION_SEP_CHAR</code> between the name and the first option and\n * also between adjacent options.</p>\n *\n * <p>If the alias is ambiguous, then the preferred converter is used\n * and the status is set to U_AMBIGUOUS_ALIAS_WARNING.</p>\n *\n * <p>The conversion behavior and names can vary between platforms. ICU may\n * convert some characters differently from other platforms. Details on this topic\n * are in the <a href=\"http://icu-project.org/userguide/conversion.html\">User's\n * Guide</a>. Aliases starting with a \"cp\" prefix have no specific meaning\n * other than its an alias starting with the letters \"cp\". Please do not\n * associate any meaning to these aliases.</p>\n *\n * \\snippet samples/ucnv/convsamp.cpp ucnv_open\n *\n * @param converterName Name of the coded character set table.\n *          This may have options appended to the string.\n *          IANA alias character set names, IBM CCSIDs starting with \"ibm-\",\n *          Windows codepage numbers starting with \"windows-\" are frequently\n *          used for this parameter. See ucnv_getAvailableName and\n *          ucnv_getAlias for a complete list that is available.\n *          If this parameter is NULL, the default converter will be used.\n * @param err outgoing error status <TT>U_MEMORY_ALLOCATION_ERROR, U_FILE_ACCESS_ERROR</TT>\n * @return the created Unicode converter object, or <TT>NULL</TT> if an error occured\n * @see ucnv_openU\n * @see ucnv_openCCSID\n * @see ucnv_getAvailableName\n * @see ucnv_getAlias\n * @see ucnv_getDefaultName\n * @see ucnv_close\n * @see ucnv_compareNames\n * @stable ICU 2.0\n */\nU_STABLE UConverter* U_EXPORT2 \nucnv_open(const char *converterName, UErrorCode *err);\n\n\n/**\n * Creates a Unicode converter with the names specified as unicode string. \n * The name should be limited to the ASCII-7 alphanumerics range.\n * The actual name will be resolved with the alias file\n * using a case-insensitive string comparison that ignores\n * leading zeroes and all non-alphanumeric characters.\n * E.g., the names \"UTF8\", \"utf-8\", \"u*T@f08\" and \"Utf 8\" are all equivalent.\n * (See also ucnv_compareNames().)\n * If <TT>NULL</TT> is passed for the converter name, it will create \n * one with the ucnv_getDefaultName() return value.\n * If the alias is ambiguous, then the preferred converter is used\n * and the status is set to U_AMBIGUOUS_ALIAS_WARNING.\n *\n * <p>See ucnv_open for the complete details</p>\n * @param name Name of the UConverter table in a zero terminated \n *        Unicode string\n * @param err outgoing error status <TT>U_MEMORY_ALLOCATION_ERROR, \n *        U_FILE_ACCESS_ERROR</TT>\n * @return the created Unicode converter object, or <TT>NULL</TT> if an \n *        error occured\n * @see ucnv_open\n * @see ucnv_openCCSID\n * @see ucnv_close\n * @see ucnv_compareNames\n * @stable ICU 2.0\n */\nU_STABLE UConverter* U_EXPORT2 \nucnv_openU(const UChar *name,\n           UErrorCode *err);\n\n/**\n * Creates a UConverter object from a CCSID number and platform pair.\n * Note that the usefulness of this function is limited to platforms with numeric\n * encoding IDs. Only IBM and Microsoft platforms use numeric (16-bit) identifiers for\n * encodings.\n *\n * In addition, IBM CCSIDs and Unicode conversion tables are not 1:1 related.\n * For many IBM CCSIDs there are multiple (up to six) Unicode conversion tables, and\n * for some Unicode conversion tables there are multiple CCSIDs.\n * Some \"alternate\" Unicode conversion tables are provided by the\n * IBM CDRA conversion table registry.\n * The most prominent example of a systematic modification of conversion tables that is\n * not provided in the form of conversion table files in the repository is\n * that S/390 Unix System Services swaps the codes for Line Feed and New Line in all\n * EBCDIC codepages, which requires such a swap in the Unicode conversion tables as well.\n *\n * Only IBM default conversion tables are accessible with ucnv_openCCSID().\n * ucnv_getCCSID() will return the same CCSID for all conversion tables that are associated\n * with that CCSID.\n *\n * Currently, the only \"platform\" supported in the ICU converter API is UCNV_IBM.\n *\n * In summary, the use of CCSIDs and the associated API functions is not recommended.\n *\n * In order to open a converter with the default IBM CDRA Unicode conversion table,\n * you can use this function or use the prefix \"ibm-\":\n * \\code\n *     char name[20];\n *     sprintf(name, \"ibm-%hu\", ccsid);\n *     cnv=ucnv_open(name, &errorCode);\n * \\endcode\n *\n * In order to open a converter with the IBM S/390 Unix System Services variant\n * of a Unicode/EBCDIC conversion table,\n * you can use the prefix \"ibm-\" together with the option string UCNV_SWAP_LFNL_OPTION_STRING:\n * \\code\n *     char name[20];\n *     sprintf(name, \"ibm-%hu\" UCNV_SWAP_LFNL_OPTION_STRING, ccsid);\n *     cnv=ucnv_open(name, &errorCode);\n * \\endcode\n *\n * In order to open a converter from a Microsoft codepage number, use the prefix \"cp\":\n * \\code\n *     char name[20];\n *     sprintf(name, \"cp%hu\", codepageID);\n *     cnv=ucnv_open(name, &errorCode);\n * \\endcode\n *\n * If the alias is ambiguous, then the preferred converter is used\n * and the status is set to U_AMBIGUOUS_ALIAS_WARNING.\n *\n * @param codepage codepage number to create\n * @param platform the platform in which the codepage number exists\n * @param err error status <TT>U_MEMORY_ALLOCATION_ERROR, U_FILE_ACCESS_ERROR</TT>\n * @return the created Unicode converter object, or <TT>NULL</TT> if an error\n *   occured.\n * @see ucnv_open\n * @see ucnv_openU\n * @see ucnv_close\n * @see ucnv_getCCSID\n * @see ucnv_getPlatform\n * @see UConverterPlatform\n * @stable ICU 2.0\n */\nU_STABLE UConverter* U_EXPORT2\nucnv_openCCSID(int32_t codepage,\n               UConverterPlatform platform,\n               UErrorCode * err);\n\n/**\n * <p>Creates a UConverter object specified from a packageName and a converterName.</p>\n * \n * <p>The packageName and converterName must point to an ICU udata object, as defined by\n *   <code> udata_open( packageName, \"cnv\", converterName, err) </code> or equivalent.\n * Typically, packageName will refer to a (.dat) file, or to a package registered with\n * udata_setAppData(). Using a full file or directory pathname for packageName is deprecated.</p>\n * \n * <p>The name will NOT be looked up in the alias mechanism, nor will the converter be\n * stored in the converter cache or the alias table. The only way to open further converters\n * is call this function multiple times, or use the ucnv_safeClone() function to clone a \n * 'master' converter.</p>\n *\n * <p>A future version of ICU may add alias table lookups and/or caching\n * to this function.</p>\n * \n * <p>Example Use:\n *      <code>cnv = ucnv_openPackage(\"myapp\", \"myconverter\", &err);</code>\n * </p>\n *\n * @param packageName name of the package (equivalent to 'path' in udata_open() call)\n * @param converterName name of the data item to be used, without suffix.\n * @param err outgoing error status <TT>U_MEMORY_ALLOCATION_ERROR, U_FILE_ACCESS_ERROR</TT>\n * @return the created Unicode converter object, or <TT>NULL</TT> if an error occured\n * @see udata_open\n * @see ucnv_open\n * @see ucnv_safeClone\n * @see ucnv_close\n * @stable ICU 2.2\n */\nU_STABLE UConverter* U_EXPORT2 \nucnv_openPackage(const char *packageName, const char *converterName, UErrorCode *err);\n\n/**\n * Thread safe converter cloning operation.\n * For most efficient operation, pass in a stackBuffer (and a *pBufferSize)\n * with at least U_CNV_SAFECLONE_BUFFERSIZE bytes of space.\n * If the buffer size is sufficient, then the clone will use the stack buffer;\n * otherwise, it will be allocated, and *pBufferSize will indicate\n * the actual size. (This should not occur with U_CNV_SAFECLONE_BUFFERSIZE.)\n *\n * You must ucnv_close() the clone in any case.\n *\n * If *pBufferSize==0, (regardless of whether stackBuffer==NULL or not)\n * then *pBufferSize will be changed to a sufficient size\n * for cloning this converter,\n * without actually cloning the converter (\"pure pre-flighting\").\n *\n * If *pBufferSize is greater than zero but not large enough for a stack-based\n * clone, then the converter is cloned using newly allocated memory\n * and *pBufferSize is changed to the necessary size.\n *\n * If the converter clone fits into the stack buffer but the stack buffer is not\n * sufficiently aligned for the clone, then the clone will use an\n * adjusted pointer and use an accordingly smaller buffer size.\n *\n * @param cnv converter to be cloned\n * @param stackBuffer user allocated space for the new clone. If NULL new memory will be allocated. \n *  If buffer is not large enough, new memory will be allocated.\n *  Clients can use the U_CNV_SAFECLONE_BUFFERSIZE. This will probably be enough to avoid memory allocations.\n * @param pBufferSize pointer to size of allocated space. pBufferSize must not be NULL.\n * @param status to indicate whether the operation went on smoothly or there were errors\n *  An informational status value, U_SAFECLONE_ALLOCATED_WARNING,\n *  is used if any allocations were necessary.\n *  However, it is better to check if *pBufferSize grew for checking for\n *  allocations because warning codes can be overridden by subsequent\n *  function calls.\n * @return pointer to the new clone\n * @stable ICU 2.0\n */\nU_STABLE UConverter * U_EXPORT2 \nucnv_safeClone(const UConverter *cnv, \n               void             *stackBuffer,\n               int32_t          *pBufferSize, \n               UErrorCode       *status);\n\n/**\n * \\def U_CNV_SAFECLONE_BUFFERSIZE\n * Definition of a buffer size that is designed to be large enough for\n * converters to be cloned with ucnv_safeClone().\n * @stable ICU 2.0\n */\n#define U_CNV_SAFECLONE_BUFFERSIZE  1024\n\n/**\n * Deletes the unicode converter and releases resources associated\n * with just this instance.\n * Does not free up shared converter tables.\n *\n * @param converter the converter object to be deleted\n * @see ucnv_open\n * @see ucnv_openU\n * @see ucnv_openCCSID\n * @stable ICU 2.0\n */\nU_STABLE void  U_EXPORT2\nucnv_close(UConverter * converter);\n\n#if U_SHOW_CPLUSPLUS_API\n\nU_NAMESPACE_BEGIN\n\n/**\n * \\class LocalUConverterPointer\n * \"Smart pointer\" class, closes a UConverter via ucnv_close().\n * For most methods see the LocalPointerBase base class.\n *\n * @see LocalPointerBase\n * @see LocalPointer\n * @stable ICU 4.4\n */\nU_DEFINE_LOCAL_OPEN_POINTER(LocalUConverterPointer, UConverter, ucnv_close);\n\nU_NAMESPACE_END\n\n#endif\n\n/**\n * Fills in the output parameter, subChars, with the substitution characters\n * as multiple bytes.\n * If ucnv_setSubstString() set a Unicode string because the converter is\n * stateful, then subChars will be an empty string.\n *\n * @param converter the Unicode converter\n * @param subChars the subsitution characters\n * @param len on input the capacity of subChars, on output the number \n * of bytes copied to it\n * @param  err the outgoing error status code.\n * If the substitution character array is too small, an\n * <TT>U_INDEX_OUTOFBOUNDS_ERROR</TT> will be returned.\n * @see ucnv_setSubstString\n * @see ucnv_setSubstChars\n * @stable ICU 2.0\n */\nU_STABLE void U_EXPORT2\nucnv_getSubstChars(const UConverter *converter,\n                   char *subChars,\n                   int8_t *len,\n                   UErrorCode *err);\n\n/**\n * Sets the substitution chars when converting from unicode to a codepage. The\n * substitution is specified as a string of 1-4 bytes, and may contain\n * <TT>NULL</TT> bytes.\n * The subChars must represent a single character. The caller needs to know the\n * byte sequence of a valid character in the converter's charset.\n * For some converters, for example some ISO 2022 variants, only single-byte\n * substitution characters may be supported.\n * The newer ucnv_setSubstString() function relaxes these limitations.\n *\n * @param converter the Unicode converter\n * @param subChars the substitution character byte sequence we want set\n * @param len the number of bytes in subChars\n * @param err the error status code.  <TT>U_INDEX_OUTOFBOUNDS_ERROR </TT> if\n * len is bigger than the maximum number of bytes allowed in subchars\n * @see ucnv_setSubstString\n * @see ucnv_getSubstChars\n * @stable ICU 2.0\n */\nU_STABLE void U_EXPORT2\nucnv_setSubstChars(UConverter *converter,\n                   const char *subChars,\n                   int8_t len,\n                   UErrorCode *err);\n\n/**\n * Set a substitution string for converting from Unicode to a charset.\n * The caller need not know the charset byte sequence for each charset.\n *\n * Unlike ucnv_setSubstChars() which is designed to set a charset byte sequence\n * for a single character, this function takes a Unicode string with\n * zero, one or more characters, and immediately verifies that the string can be\n * converted to the charset.\n * If not, or if the result is too long (more than 32 bytes as of ICU 3.6),\n * then the function returns with an error accordingly.\n *\n * Also unlike ucnv_setSubstChars(), this function works for stateful charsets\n * by converting on the fly at the point of substitution rather than setting\n * a fixed byte sequence.\n *\n * @param cnv The UConverter object.\n * @param s The Unicode string.\n * @param length The number of UChars in s, or -1 for a NUL-terminated string.\n * @param err Pointer to a standard ICU error code. Its input value must\n *            pass the U_SUCCESS() test, or else the function returns\n *            immediately. Check for U_FAILURE() on output or use with\n *            function chaining. (See User Guide for details.)\n *\n * @see ucnv_setSubstChars\n * @see ucnv_getSubstChars\n * @stable ICU 3.6\n */\nU_STABLE void U_EXPORT2\nucnv_setSubstString(UConverter *cnv,\n                    const UChar *s,\n                    int32_t length,\n                    UErrorCode *err);\n\n/**\n * Fills in the output parameter, errBytes, with the error characters from the\n * last failing conversion.\n *\n * @param converter the Unicode converter\n * @param errBytes the codepage bytes which were in error\n * @param len on input the capacity of errBytes, on output the number of\n *  bytes which were copied to it\n * @param err the error status code.\n * If the substitution character array is too small, an\n * <TT>U_INDEX_OUTOFBOUNDS_ERROR</TT> will be returned.\n * @stable ICU 2.0\n */\nU_STABLE void U_EXPORT2\nucnv_getInvalidChars(const UConverter *converter,\n                     char *errBytes,\n                     int8_t *len,\n                     UErrorCode *err);\n\n/**\n * Fills in the output parameter, errChars, with the error characters from the\n * last failing conversion.\n *\n * @param converter the Unicode converter\n * @param errUChars the UChars which were in error\n * @param len on input the capacity of errUChars, on output the number of \n *  UChars which were copied to it\n * @param err the error status code.\n * If the substitution character array is too small, an\n * <TT>U_INDEX_OUTOFBOUNDS_ERROR</TT> will be returned.\n * @stable ICU 2.0\n */\nU_STABLE void U_EXPORT2\nucnv_getInvalidUChars(const UConverter *converter,\n                      UChar *errUChars,\n                      int8_t *len,\n                      UErrorCode *err);\n\n/**\n * Resets the state of a converter to the default state. This is used\n * in the case of an error, to restart a conversion from a known default state.\n * It will also empty the internal output buffers.\n * @param converter the Unicode converter\n * @stable ICU 2.0\n */\nU_STABLE void U_EXPORT2\nucnv_reset(UConverter *converter);\n\n/**\n * Resets the to-Unicode part of a converter state to the default state.\n * This is used in the case of an error to restart a conversion to\n * Unicode to a known default state. It will also empty the internal\n * output buffers used for the conversion to Unicode codepoints.\n * @param converter the Unicode converter\n * @stable ICU 2.0\n */\nU_STABLE void U_EXPORT2 \nucnv_resetToUnicode(UConverter *converter);\n\n/**\n * Resets the from-Unicode part of a converter state to the default state.\n * This is used in the case of an error to restart a conversion from\n * Unicode to a known default state. It will also empty the internal output\n * buffers used for the conversion from Unicode codepoints.\n * @param converter the Unicode converter\n * @stable ICU 2.0\n */\nU_STABLE void U_EXPORT2 \nucnv_resetFromUnicode(UConverter *converter);\n\n/**\n * Returns the maximum number of bytes that are output per UChar in conversion\n * from Unicode using this converter.\n * The returned number can be used with UCNV_GET_MAX_BYTES_FOR_STRING\n * to calculate the size of a target buffer for conversion from Unicode.\n *\n * Note: Before ICU 2.8, this function did not return reliable numbers for\n * some stateful converters (EBCDIC_STATEFUL, ISO-2022) and LMBCS.\n *\n * This number may not be the same as the maximum number of bytes per\n * \"conversion unit\". In other words, it may not be the intuitively expected\n * number of bytes per character that would be published for a charset,\n * and may not fulfill any other purpose than the allocation of an output\n * buffer of guaranteed sufficient size for a given input length and converter.\n *\n * Examples for special cases that are taken into account:\n * - Supplementary code points may convert to more bytes than BMP code points.\n *   This function returns bytes per UChar (UTF-16 code unit), not per\n *   Unicode code point, for efficient buffer allocation.\n * - State-shifting output (SI/SO, escapes, etc.) from stateful converters.\n * - When m input UChars are converted to n output bytes, then the maximum m/n\n *   is taken into account.\n *\n * The number returned here does not take into account\n * (see UCNV_GET_MAX_BYTES_FOR_STRING):\n * - callbacks which output more than one charset character sequence per call,\n *   like escape callbacks\n * - initial and final non-character bytes that are output by some converters\n *   (automatic BOMs, initial escape sequence, final SI, etc.)\n *\n * Examples for returned values:\n * - SBCS charsets: 1\n * - Shift-JIS: 2\n * - UTF-16: 2 (2 per BMP, 4 per surrogate _pair_, BOM not counted)\n * - UTF-8: 3 (3 per BMP, 4 per surrogate _pair_)\n * - EBCDIC_STATEFUL (EBCDIC mixed SBCS/DBCS): 3 (SO + DBCS)\n * - ISO-2022: 3 (always outputs UTF-8)\n * - ISO-2022-JP: 6 (4-byte escape sequences + DBCS)\n * - ISO-2022-CN: 8 (4-byte designator sequences + 2-byte SS2/SS3 + DBCS)\n *\n * @param converter The Unicode converter.\n * @return The maximum number of bytes per UChar that are output by ucnv_fromUnicode(),\n *         to be used together with UCNV_GET_MAX_BYTES_FOR_STRING for buffer allocation.\n *\n * @see UCNV_GET_MAX_BYTES_FOR_STRING\n * @see ucnv_getMinCharSize\n * @stable ICU 2.0\n */\nU_STABLE int8_t U_EXPORT2\nucnv_getMaxCharSize(const UConverter *converter);\n\n/**\n * Calculates the size of a buffer for conversion from Unicode to a charset.\n * The calculated size is guaranteed to be sufficient for this conversion.\n *\n * It takes into account initial and final non-character bytes that are output\n * by some converters.\n * It does not take into account callbacks which output more than one charset\n * character sequence per call, like escape callbacks.\n * The default (substitution) callback only outputs one charset character sequence.\n *\n * @param length Number of UChars to be converted.\n * @param maxCharSize Return value from ucnv_getMaxCharSize() for the converter\n *                    that will be used.\n * @return Size of a buffer that will be large enough to hold the output bytes of\n *         converting length UChars with the converter that returned the maxCharSize.\n *\n * @see ucnv_getMaxCharSize\n * @stable ICU 2.8\n */\n#define UCNV_GET_MAX_BYTES_FOR_STRING(length, maxCharSize) \\\n     (((int32_t)(length)+10)*(int32_t)(maxCharSize))\n\n/**\n * Returns the minimum byte length for characters in this codepage. \n * This is usually either 1 or 2.\n * @param converter the Unicode converter\n * @return the minimum number of bytes allowed by this particular converter\n * @see ucnv_getMaxCharSize\n * @stable ICU 2.0\n */\nU_STABLE int8_t U_EXPORT2\nucnv_getMinCharSize(const UConverter *converter);\n\n/**\n * Returns the display name of the converter passed in based on the Locale \n * passed in. If the locale contains no display name, the internal ASCII\n * name will be filled in.\n *\n * @param converter the Unicode converter.\n * @param displayLocale is the specific Locale we want to localised for\n * @param displayName user provided buffer to be filled in\n * @param displayNameCapacity size of displayName Buffer\n * @param err error status code\n * @return displayNameLength number of UChar needed in displayName\n * @see ucnv_getName\n * @stable ICU 2.0\n */\nU_STABLE int32_t U_EXPORT2\nucnv_getDisplayName(const UConverter *converter,\n                    const char *displayLocale,\n                    UChar *displayName,\n                    int32_t displayNameCapacity,\n                    UErrorCode *err);\n\n/**\n * Gets the internal, canonical name of the converter (zero-terminated).\n * The lifetime of the returned string will be that of the converter \n * passed to this function.\n * @param converter the Unicode converter\n * @param err UErrorCode status\n * @return the internal name of the converter\n * @see ucnv_getDisplayName\n * @stable ICU 2.0\n */\nU_STABLE const char * U_EXPORT2 \nucnv_getName(const UConverter *converter, UErrorCode *err);\n\n/**\n * Gets a codepage number associated with the converter. This is not guaranteed\n * to be the one used to create the converter. Some converters do not represent\n * platform registered codepages and return zero for the codepage number.\n * The error code fill-in parameter indicates if the codepage number\n * is available.\n * Does not check if the converter is <TT>NULL</TT> or if converter's data\n * table is <TT>NULL</TT>.\n *\n * Important: The use of CCSIDs is not recommended because it is limited\n * to only two platforms in principle and only one (UCNV_IBM) in the current\n * ICU converter API.\n * Also, CCSIDs are insufficient to identify IBM Unicode conversion tables precisely.\n * For more details see ucnv_openCCSID().\n *\n * @param converter the Unicode converter\n * @param err the error status code.\n * @return If any error occurrs, -1 will be returned otherwise, the codepage number\n * will be returned\n * @see ucnv_openCCSID\n * @see ucnv_getPlatform\n * @stable ICU 2.0\n */\nU_STABLE int32_t U_EXPORT2\nucnv_getCCSID(const UConverter *converter,\n              UErrorCode *err);\n\n/**\n * Gets a codepage platform associated with the converter. Currently, \n * only <TT>UCNV_IBM</TT> will be returned.\n * Does not test if the converter is <TT>NULL</TT> or if converter's data \n * table is <TT>NULL</TT>. \n * @param converter the Unicode converter\n * @param err the error status code.\n * @return The codepage platform\n * @stable ICU 2.0\n */\nU_STABLE UConverterPlatform U_EXPORT2\nucnv_getPlatform(const UConverter *converter,\n                 UErrorCode *err);\n\n/**\n * Gets the type of the converter\n * e.g. SBCS, MBCS, DBCS, UTF8, UTF16_BE, UTF16_LE, ISO_2022, \n * EBCDIC_STATEFUL, LATIN_1\n * @param converter a valid, opened converter\n * @return the type of the converter\n * @stable ICU 2.0\n */\nU_STABLE UConverterType U_EXPORT2\nucnv_getType(const UConverter * converter);\n\n/**\n * Gets the \"starter\" (lead) bytes for converters of type MBCS.\n * Will fill in an <TT>U_ILLEGAL_ARGUMENT_ERROR</TT> if converter passed in\n * is not MBCS. Fills in an array of type UBool, with the value of the byte \n * as offset to the array. For example, if (starters[0x20] == TRUE) at return,\n * it means that the byte 0x20 is a starter byte in this converter.\n * Context pointers are always owned by the caller.\n * \n * @param converter a valid, opened converter of type MBCS\n * @param starters an array of size 256 to be filled in\n * @param err error status, <TT>U_ILLEGAL_ARGUMENT_ERROR</TT> if the \n * converter is not a type which can return starters.\n * @see ucnv_getType\n * @stable ICU 2.0\n */\nU_STABLE void U_EXPORT2\nucnv_getStarters(const UConverter* converter, \n                 UBool starters[256],\n                 UErrorCode* err);\n\n\n/**\n * Selectors for Unicode sets that can be returned by ucnv_getUnicodeSet().\n * @see ucnv_getUnicodeSet\n * @stable ICU 2.6\n */\ntypedef enum UConverterUnicodeSet {\n    /** Select the set of roundtrippable Unicode code points. @stable ICU 2.6 */\n    UCNV_ROUNDTRIP_SET,\n    /** Select the set of Unicode code points with roundtrip or fallback mappings. @stable ICU 4.0 */\n    UCNV_ROUNDTRIP_AND_FALLBACK_SET,\n    /** Number of UConverterUnicodeSet selectors. @stable ICU 2.6 */\n    UCNV_SET_COUNT\n} UConverterUnicodeSet;\n\n\n/**\n * Returns the set of Unicode code points that can be converted by an ICU converter.\n *\n * Returns one of several kinds of set:\n *\n * 1. UCNV_ROUNDTRIP_SET\n *\n * The set of all Unicode code points that can be roundtrip-converted\n * (converted without any data loss) with the converter (ucnv_fromUnicode()).\n * This set will not include code points that have fallback mappings\n * or are only the result of reverse fallback mappings.\n * This set will also not include PUA code points with fallbacks, although\n * ucnv_fromUnicode() will always uses those mappings despite ucnv_setFallback().\n * See UTR #22 \"Character Mapping Markup Language\"\n * at http://www.unicode.org/reports/tr22/\n *\n * This is useful for example for\n * - checking that a string or document can be roundtrip-converted with a converter,\n *   without/before actually performing the conversion\n * - testing if a converter can be used for text for typical text for a certain locale,\n *   by comparing its roundtrip set with the set of ExemplarCharacters from\n *   ICU's locale data or other sources\n *\n * 2. UCNV_ROUNDTRIP_AND_FALLBACK_SET\n *\n * The set of all Unicode code points that can be converted with the converter (ucnv_fromUnicode())\n * when fallbacks are turned on (see ucnv_setFallback()).\n * This set includes all code points with roundtrips and fallbacks (but not reverse fallbacks).\n *\n * In the future, there may be more UConverterUnicodeSet choices to select\n * sets with different properties.\n *\n * @param cnv The converter for which a set is requested.\n * @param setFillIn A valid USet *. It will be cleared by this function before\n *            the converter's specific set is filled into the USet.\n * @param whichSet A UConverterUnicodeSet selector;\n *              currently UCNV_ROUNDTRIP_SET is the only supported value.\n * @param pErrorCode ICU error code in/out parameter.\n *                   Must fulfill U_SUCCESS before the function call.\n *\n * @see UConverterUnicodeSet\n * @see uset_open\n * @see uset_close\n * @stable ICU 2.6\n */\nU_STABLE void U_EXPORT2\nucnv_getUnicodeSet(const UConverter *cnv,\n                   USet *setFillIn,\n                   UConverterUnicodeSet whichSet,\n                   UErrorCode *pErrorCode);\n\n/**\n * Gets the current calback function used by the converter when an illegal\n *  or invalid codepage sequence is found. \n * Context pointers are always owned by the caller.\n *\n * @param converter the unicode converter\n * @param action fillin: returns the callback function pointer\n * @param context fillin: returns the callback's private void* context\n * @see ucnv_setToUCallBack\n * @stable ICU 2.0\n */\nU_STABLE void U_EXPORT2\nucnv_getToUCallBack (const UConverter * converter,\n                     UConverterToUCallback *action,\n                     const void **context);\n\n/**\n * Gets the current callback function used by the converter when illegal \n * or invalid Unicode sequence is found.\n * Context pointers are always owned by the caller.\n *\n * @param converter the unicode converter\n * @param action fillin: returns the callback function pointer\n * @param context fillin: returns the callback's private void* context\n * @see ucnv_setFromUCallBack\n * @stable ICU 2.0\n */\nU_STABLE void U_EXPORT2\nucnv_getFromUCallBack (const UConverter * converter,\n                       UConverterFromUCallback *action,\n                       const void **context);\n\n/**\n * Changes the callback function used by the converter when\n * an illegal or invalid sequence is found.\n * Context pointers are always owned by the caller.\n * Predefined actions and contexts can be found in the ucnv_err.h header.\n *\n * @param converter the unicode converter\n * @param newAction the new callback function\n * @param newContext the new toUnicode callback context pointer. This can be NULL.\n * @param oldAction fillin: returns the old callback function pointer. This can be NULL.\n * @param oldContext fillin: returns the old callback's private void* context. This can be NULL.\n * @param err The error code status\n * @see ucnv_getToUCallBack\n * @stable ICU 2.0\n */\nU_STABLE void U_EXPORT2\nucnv_setToUCallBack (UConverter * converter,\n                     UConverterToUCallback newAction,\n                     const void* newContext,\n                     UConverterToUCallback *oldAction,\n                     const void** oldContext,\n                     UErrorCode * err);\n\n/**\n * Changes the current callback function used by the converter when\n * an illegal or invalid sequence is found.\n * Context pointers are always owned by the caller.\n * Predefined actions and contexts can be found in the ucnv_err.h header.\n *\n * @param converter the unicode converter\n * @param newAction the new callback function\n * @param newContext the new fromUnicode callback context pointer. This can be NULL.\n * @param oldAction fillin: returns the old callback function pointer. This can be NULL.\n * @param oldContext fillin: returns the old callback's private void* context. This can be NULL.\n * @param err The error code status\n * @see ucnv_getFromUCallBack\n * @stable ICU 2.0\n */\nU_STABLE void U_EXPORT2\nucnv_setFromUCallBack (UConverter * converter,\n                       UConverterFromUCallback newAction,\n                       const void *newContext,\n                       UConverterFromUCallback *oldAction,\n                       const void **oldContext,\n                       UErrorCode * err);\n\n/**\n * Converts an array of unicode characters to an array of codepage\n * characters. This function is optimized for converting a continuous\n * stream of data in buffer-sized chunks, where the entire source and\n * target does not fit in available buffers.\n * \n * The source pointer is an in/out parameter. It starts out pointing where the \n * conversion is to begin, and ends up pointing after the last UChar consumed. \n * \n * Target similarly starts out pointer at the first available byte in the output\n * buffer, and ends up pointing after the last byte written to the output.\n * \n * The converter always attempts to consume the entire source buffer, unless \n * (1.) the target buffer is full, or (2.) a failing error is returned from the\n * current callback function.  When a successful error status has been\n * returned, it means that all of the source buffer has been\n *  consumed. At that point, the caller should reset the source and\n *  sourceLimit pointers to point to the next chunk.\n * \n * At the end of the stream (flush==TRUE), the input is completely consumed\n * when *source==sourceLimit and no error code is set.\n * The converter object is then automatically reset by this function.\n * (This means that a converter need not be reset explicitly between data\n * streams if it finishes the previous stream without errors.)\n * \n * This is a <I>stateful</I> conversion. Additionally, even when all source data has\n * been consumed, some data may be in the converters' internal state.\n * Call this function repeatedly, updating the target pointers with\n * the next empty chunk of target in case of a\n * <TT>U_BUFFER_OVERFLOW_ERROR</TT>, and updating the source  pointers\n *  with the next chunk of source when a successful error status is\n * returned, until there are no more chunks of source data.\n * @param converter the Unicode converter\n * @param target I/O parameter. Input : Points to the beginning of the buffer to copy\n *  codepage characters to. Output : points to after the last codepage character copied\n *  to <TT>target</TT>.\n * @param targetLimit the pointer just after last of the <TT>target</TT> buffer\n * @param source I/O parameter, pointer to pointer to the source Unicode character buffer. \n * @param sourceLimit the pointer just after the last of the source buffer\n * @param offsets if NULL is passed, nothing will happen to it, otherwise it needs to have the same number\n * of allocated cells as <TT>target</TT>. Will fill in offsets from target to source pointer\n * e.g: <TT>offsets[3]</TT> is equal to 6, it means that the <TT>target[3]</TT> was a result of transcoding <TT>source[6]</TT>\n * For output data carried across calls, and other data without a specific source character\n * (such as from escape sequences or callbacks)  -1 will be placed for offsets. \n * @param flush set to <TT>TRUE</TT> if the current source buffer is the last available\n * chunk of the source, <TT>FALSE</TT> otherwise. Note that if a failing status is returned,\n * this function may have to be called multiple times with flush set to <TT>TRUE</TT> until\n * the source buffer is consumed.\n * @param err the error status.  <TT>U_ILLEGAL_ARGUMENT_ERROR</TT> will be set if the\n * converter is <TT>NULL</TT>.\n * <code>U_BUFFER_OVERFLOW_ERROR</code> will be set if the target is full and there is \n * still data to be written to the target.\n * @see ucnv_fromUChars\n * @see ucnv_convert\n * @see ucnv_getMinCharSize\n * @see ucnv_setToUCallBack\n * @stable ICU 2.0\n */\nU_STABLE void U_EXPORT2 \nucnv_fromUnicode (UConverter * converter,\n                  char **target,\n                  const char *targetLimit,\n                  const UChar ** source,\n                  const UChar * sourceLimit,\n                  int32_t* offsets,\n                  UBool flush,\n                  UErrorCode * err);\n\n/**\n * Converts a buffer of codepage bytes into an array of unicode UChars\n * characters. This function is optimized for converting a continuous\n * stream of data in buffer-sized chunks, where the entire source and\n * target does not fit in available buffers.\n * \n * The source pointer is an in/out parameter. It starts out pointing where the \n * conversion is to begin, and ends up pointing after the last byte of source consumed. \n * \n * Target similarly starts out pointer at the first available UChar in the output\n * buffer, and ends up pointing after the last UChar written to the output. \n * It does NOT necessarily keep UChar sequences together.\n * \n * The converter always attempts to consume the entire source buffer, unless \n * (1.) the target buffer is full, or (2.) a failing error is returned from the\n * current callback function.  When a successful error status has been\n * returned, it means that all of the source buffer has been\n *  consumed. At that point, the caller should reset the source and\n *  sourceLimit pointers to point to the next chunk.\n *\n * At the end of the stream (flush==TRUE), the input is completely consumed\n * when *source==sourceLimit and no error code is set\n * The converter object is then automatically reset by this function.\n * (This means that a converter need not be reset explicitly between data\n * streams if it finishes the previous stream without errors.)\n * \n * This is a <I>stateful</I> conversion. Additionally, even when all source data has\n * been consumed, some data may be in the converters' internal state.\n * Call this function repeatedly, updating the target pointers with\n * the next empty chunk of target in case of a\n * <TT>U_BUFFER_OVERFLOW_ERROR</TT>, and updating the source  pointers\n *  with the next chunk of source when a successful error status is\n * returned, until there are no more chunks of source data.\n * @param converter the Unicode converter\n * @param target I/O parameter. Input : Points to the beginning of the buffer to copy\n *  UChars into. Output : points to after the last UChar copied.\n * @param targetLimit the pointer just after the end of the <TT>target</TT> buffer\n * @param source I/O parameter, pointer to pointer to the source codepage buffer. \n * @param sourceLimit the pointer to the byte after the end of the source buffer\n * @param offsets if NULL is passed, nothing will happen to it, otherwise it needs to have the same number\n * of allocated cells as <TT>target</TT>. Will fill in offsets from target to source pointer\n * e.g: <TT>offsets[3]</TT> is equal to 6, it means that the <TT>target[3]</TT> was a result of transcoding <TT>source[6]</TT>\n * For output data carried across calls, and other data without a specific source character\n * (such as from escape sequences or callbacks)  -1 will be placed for offsets. \n * @param flush set to <TT>TRUE</TT> if the current source buffer is the last available\n * chunk of the source, <TT>FALSE</TT> otherwise. Note that if a failing status is returned,\n * this function may have to be called multiple times with flush set to <TT>TRUE</TT> until\n * the source buffer is consumed.\n * @param err the error status.  <TT>U_ILLEGAL_ARGUMENT_ERROR</TT> will be set if the\n * converter is <TT>NULL</TT>.\n * <code>U_BUFFER_OVERFLOW_ERROR</code> will be set if the target is full and there is \n * still data to be written to the target. \n * @see ucnv_fromUChars\n * @see ucnv_convert\n * @see ucnv_getMinCharSize\n * @see ucnv_setFromUCallBack\n * @see ucnv_getNextUChar\n * @stable ICU 2.0\n */\nU_STABLE void U_EXPORT2 \nucnv_toUnicode(UConverter *converter,\n               UChar **target,\n               const UChar *targetLimit,\n               const char **source,\n               const char *sourceLimit,\n               int32_t *offsets,\n               UBool flush,\n               UErrorCode *err);\n\n/**\n * Convert the Unicode string into a codepage string using an existing UConverter.\n * The output string is NUL-terminated if possible.\n *\n * This function is a more convenient but less powerful version of ucnv_fromUnicode().\n * It is only useful for whole strings, not for streaming conversion.\n *\n * The maximum output buffer capacity required (barring output from callbacks) will be\n * UCNV_GET_MAX_BYTES_FOR_STRING(srcLength, ucnv_getMaxCharSize(cnv)).\n *\n * @param cnv the converter object to be used (ucnv_resetFromUnicode() will be called)\n * @param src the input Unicode string\n * @param srcLength the input string length, or -1 if NUL-terminated\n * @param dest destination string buffer, can be NULL if destCapacity==0\n * @param destCapacity the number of chars available at dest\n * @param pErrorCode normal ICU error code;\n *                  common error codes that may be set by this function include\n *                  U_BUFFER_OVERFLOW_ERROR, U_STRING_NOT_TERMINATED_WARNING,\n *                  U_ILLEGAL_ARGUMENT_ERROR, and conversion errors\n * @return the length of the output string, not counting the terminating NUL;\n *         if the length is greater than destCapacity, then the string will not fit\n *         and a buffer of the indicated length would need to be passed in\n * @see ucnv_fromUnicode\n * @see ucnv_convert\n * @see UCNV_GET_MAX_BYTES_FOR_STRING\n * @stable ICU 2.0\n */\nU_STABLE int32_t U_EXPORT2\nucnv_fromUChars(UConverter *cnv,\n                char *dest, int32_t destCapacity,\n                const UChar *src, int32_t srcLength,\n                UErrorCode *pErrorCode);\n\n/**\n * Convert the codepage string into a Unicode string using an existing UConverter.\n * The output string is NUL-terminated if possible.\n *\n * This function is a more convenient but less powerful version of ucnv_toUnicode().\n * It is only useful for whole strings, not for streaming conversion.\n *\n * The maximum output buffer capacity required (barring output from callbacks) will be\n * 2*srcLength (each char may be converted into a surrogate pair).\n *\n * @param cnv the converter object to be used (ucnv_resetToUnicode() will be called)\n * @param src the input codepage string\n * @param srcLength the input string length, or -1 if NUL-terminated\n * @param dest destination string buffer, can be NULL if destCapacity==0\n * @param destCapacity the number of UChars available at dest\n * @param pErrorCode normal ICU error code;\n *                  common error codes that may be set by this function include\n *                  U_BUFFER_OVERFLOW_ERROR, U_STRING_NOT_TERMINATED_WARNING,\n *                  U_ILLEGAL_ARGUMENT_ERROR, and conversion errors\n * @return the length of the output string, not counting the terminating NUL;\n *         if the length is greater than destCapacity, then the string will not fit\n *         and a buffer of the indicated length would need to be passed in\n * @see ucnv_toUnicode\n * @see ucnv_convert\n * @stable ICU 2.0\n */\nU_STABLE int32_t U_EXPORT2\nucnv_toUChars(UConverter *cnv,\n              UChar *dest, int32_t destCapacity,\n              const char *src, int32_t srcLength,\n              UErrorCode *pErrorCode);\n\n/**\n * Convert a codepage buffer into Unicode one character at a time.\n * The input is completely consumed when the U_INDEX_OUTOFBOUNDS_ERROR is set.\n *\n * Advantage compared to ucnv_toUnicode() or ucnv_toUChars():\n * - Faster for small amounts of data, for most converters, e.g.,\n *   US-ASCII, ISO-8859-1, UTF-8/16/32, and most \"normal\" charsets.\n *   (For complex converters, e.g., SCSU, UTF-7 and ISO 2022 variants,\n *    it uses ucnv_toUnicode() internally.)\n * - Convenient.\n *\n * Limitations compared to ucnv_toUnicode():\n * - Always assumes flush=TRUE.\n *   This makes ucnv_getNextUChar() unsuitable for \"streaming\" conversion,\n *   that is, for where the input is supplied in multiple buffers,\n *   because ucnv_getNextUChar() will assume the end of the input at the end\n *   of the first buffer.\n * - Does not provide offset output.\n *\n * It is possible to \"mix\" ucnv_getNextUChar() and ucnv_toUnicode() because\n * ucnv_getNextUChar() uses the current state of the converter\n * (unlike ucnv_toUChars() which always resets first).\n * However, if ucnv_getNextUChar() is called after ucnv_toUnicode()\n * stopped in the middle of a character sequence (with flush=FALSE),\n * then ucnv_getNextUChar() will always use the slower ucnv_toUnicode()\n * internally until the next character boundary.\n * (This is new in ICU 2.6. In earlier releases, ucnv_getNextUChar() had to\n * start at a character boundary.)\n *\n * Instead of using ucnv_getNextUChar(), it is recommended\n * to convert using ucnv_toUnicode() or ucnv_toUChars()\n * and then iterate over the text using U16_NEXT() or a UCharIterator (uiter.h)\n * or a C++ CharacterIterator or similar.\n * This allows streaming conversion and offset output, for example.\n *\n * <p>Handling of surrogate pairs and supplementary-plane code points:<br>\n * There are two different kinds of codepages that provide mappings for surrogate characters:\n * <ul>\n *   <li>Codepages like UTF-8, UTF-32, and GB 18030 provide direct representations for Unicode\n *       code points U+10000-U+10ffff as well as for single surrogates U+d800-U+dfff.\n *       Each valid sequence will result in exactly one returned code point.\n *       If a sequence results in a single surrogate, then that will be returned\n *       by itself, even if a neighboring sequence encodes the matching surrogate.</li>\n *   <li>Codepages like SCSU and LMBCS (and UTF-16) provide direct representations only for BMP code points\n *       including surrogates. Code points in supplementary planes are represented with\n *       two sequences, each encoding a surrogate.\n *       For these codepages, matching pairs of surrogates will be combined into single\n *       code points for returning from this function.\n *       (Note that SCSU is actually a mix of these codepage types.)</li>\n * </ul></p>\n *\n * @param converter an open UConverter\n * @param source the address of a pointer to the codepage buffer, will be\n *  updated to point after the bytes consumed in the conversion call.\n * @param sourceLimit points to the end of the input buffer\n * @param err fills in error status (see ucnv_toUnicode)\n * <code>U_INDEX_OUTOFBOUNDS_ERROR</code> will be set if the input \n * is empty or does not convert to any output (e.g.: pure state-change \n * codes SI/SO, escape sequences for ISO 2022,\n * or if the callback did not output anything, ...).\n * This function will not set a <code>U_BUFFER_OVERFLOW_ERROR</code> because\n *  the \"buffer\" is the return code. However, there might be subsequent output\n *  stored in the converter object\n * that will be returned in following calls to this function.\n * @return a UChar32 resulting from the partial conversion of source\n * @see ucnv_toUnicode\n * @see ucnv_toUChars\n * @see ucnv_convert\n * @stable ICU 2.0\n */\nU_STABLE UChar32 U_EXPORT2\nucnv_getNextUChar(UConverter * converter,\n                  const char **source,\n                  const char * sourceLimit,\n                  UErrorCode * err);\n\n/**\n * Convert from one external charset to another using two existing UConverters.\n * Internally, two conversions - ucnv_toUnicode() and ucnv_fromUnicode() -\n * are used, \"pivoting\" through 16-bit Unicode.\n *\n * Important: For streaming conversion (multiple function calls for successive\n * parts of a text stream), the caller must provide a pivot buffer explicitly,\n * and must preserve the pivot buffer and associated pointers from one\n * call to another. (The buffer may be moved if its contents and the relative\n * pointer positions are preserved.)\n *\n * There is a similar function, ucnv_convert(),\n * which has the following limitations:\n * - it takes charset names, not converter objects, so that\n *   - two converters are opened for each call\n *   - only single-string conversion is possible, not streaming operation\n * - it does not provide enough information to find out,\n *   in case of failure, whether the toUnicode or\n *   the fromUnicode conversion failed\n *\n * By contrast, ucnv_convertEx()\n * - takes UConverter parameters instead of charset names\n * - fully exposes the pivot buffer for streaming conversion and complete error handling\n *\n * ucnv_convertEx() also provides further convenience:\n * - an option to reset the converters at the beginning\n *   (if reset==TRUE, see parameters;\n *    also sets *pivotTarget=*pivotSource=pivotStart)\n * - allow NUL-terminated input\n *   (only a single NUL byte, will not work for charsets with multi-byte NULs)\n *   (if sourceLimit==NULL, see parameters)\n * - terminate with a NUL on output\n *   (only a single NUL byte, not useful for charsets with multi-byte NULs),\n *   or set U_STRING_NOT_TERMINATED_WARNING if the output exactly fills\n *   the target buffer\n * - the pivot buffer can be provided internally;\n *   possible only for whole-string conversion, not streaming conversion;\n *   in this case, the caller will not be able to get details about where an\n *   error occurred\n *   (if pivotStart==NULL, see below)\n *\n * The function returns when one of the following is true:\n * - the entire source text has been converted successfully to the target buffer\n * - a target buffer overflow occurred (U_BUFFER_OVERFLOW_ERROR)\n * - a conversion error occurred\n *   (other U_FAILURE(), see description of pErrorCode)\n *\n * Limitation compared to the direct use of\n * ucnv_fromUnicode() and ucnv_toUnicode():\n * ucnv_convertEx() does not provide offset information.\n *\n * Limitation compared to ucnv_fromUChars() and ucnv_toUChars():\n * ucnv_convertEx() does not support preflighting directly.\n *\n * Sample code for converting a single string from\n * one external charset to UTF-8, ignoring the location of errors:\n *\n * \\code\n * int32_t\n * myToUTF8(UConverter *cnv,\n *          const char *s, int32_t length,\n *          char *u8, int32_t capacity,\n *          UErrorCode *pErrorCode) {\n *     UConverter *utf8Cnv;\n *     char *target;\n *\n *     if(U_FAILURE(*pErrorCode)) {\n *         return 0;\n *     }\n *\n *     utf8Cnv=myGetCachedUTF8Converter(pErrorCode);\n *     if(U_FAILURE(*pErrorCode)) {\n *         return 0;\n *     }\n *\n *     if(length<0) {\n *         length=strlen(s);\n *     }\n *     target=u8;\n *     ucnv_convertEx(utf8Cnv, cnv,\n *                    &target, u8+capacity,\n *                    &s, s+length,\n *                    NULL, NULL, NULL, NULL,\n *                    TRUE, TRUE,\n *                    pErrorCode);\n * \n *     myReleaseCachedUTF8Converter(utf8Cnv);\n *\n *     // return the output string length, but without preflighting\n *     return (int32_t)(target-u8);\n * }\n * \\endcode\n *\n * @param targetCnv     Output converter, used to convert from the UTF-16 pivot\n *                      to the target using ucnv_fromUnicode().\n * @param sourceCnv     Input converter, used to convert from the source to\n *                      the UTF-16 pivot using ucnv_toUnicode().\n * @param target        I/O parameter, same as for ucnv_fromUChars().\n *                      Input: *target points to the beginning of the target buffer.\n *                      Output: *target points to the first unit after the last char written.\n * @param targetLimit   Pointer to the first unit after the target buffer.\n * @param source        I/O parameter, same as for ucnv_toUChars().\n *                      Input: *source points to the beginning of the source buffer.\n *                      Output: *source points to the first unit after the last char read.\n * @param sourceLimit   Pointer to the first unit after the source buffer.\n * @param pivotStart    Pointer to the UTF-16 pivot buffer. If pivotStart==NULL,\n *                      then an internal buffer is used and the other pivot\n *                      arguments are ignored and can be NULL as well.\n * @param pivotSource   I/O parameter, same as source in ucnv_fromUChars() for\n *                      conversion from the pivot buffer to the target buffer.\n * @param pivotTarget   I/O parameter, same as target in ucnv_toUChars() for\n *                      conversion from the source buffer to the pivot buffer.\n *                      It must be pivotStart<=*pivotSource<=*pivotTarget<=pivotLimit\n *                      and pivotStart<pivotLimit (unless pivotStart==NULL).\n * @param pivotLimit    Pointer to the first unit after the pivot buffer.\n * @param reset         If TRUE, then ucnv_resetToUnicode(sourceCnv) and\n *                      ucnv_resetFromUnicode(targetCnv) are called, and the\n *                      pivot pointers are reset (*pivotTarget=*pivotSource=pivotStart).\n * @param flush         If true, indicates the end of the input.\n *                      Passed directly to ucnv_toUnicode(), and carried over to\n *                      ucnv_fromUnicode() when the source is empty as well.\n * @param pErrorCode    ICU error code in/out parameter.\n *                      Must fulfill U_SUCCESS before the function call.\n *                      U_BUFFER_OVERFLOW_ERROR always refers to the target buffer\n *                      because overflows into the pivot buffer are handled internally.\n *                      Other conversion errors are from the source-to-pivot\n *                      conversion if *pivotSource==pivotStart, otherwise from\n *                      the pivot-to-target conversion.\n *\n * @see ucnv_convert\n * @see ucnv_fromAlgorithmic\n * @see ucnv_toAlgorithmic\n * @see ucnv_fromUnicode\n * @see ucnv_toUnicode\n * @see ucnv_fromUChars\n * @see ucnv_toUChars\n * @stable ICU 2.6\n */\nU_STABLE void U_EXPORT2\nucnv_convertEx(UConverter *targetCnv, UConverter *sourceCnv,\n               char **target, const char *targetLimit,\n               const char **source, const char *sourceLimit,\n               UChar *pivotStart, UChar **pivotSource,\n               UChar **pivotTarget, const UChar *pivotLimit,\n               UBool reset, UBool flush,\n               UErrorCode *pErrorCode);\n\n/**\n * Convert from one external charset to another.\n * Internally, two converters are opened according to the name arguments,\n * then the text is converted to and from the 16-bit Unicode \"pivot\"\n * using ucnv_convertEx(), then the converters are closed again.\n *\n * This is a convenience function, not an efficient way to convert a lot of text:\n * ucnv_convert()\n * - takes charset names, not converter objects, so that\n *   - two converters are opened for each call\n *   - only single-string conversion is possible, not streaming operation\n * - does not provide enough information to find out,\n *   in case of failure, whether the toUnicode or\n *   the fromUnicode conversion failed\n * - allows NUL-terminated input\n *   (only a single NUL byte, will not work for charsets with multi-byte NULs)\n *   (if sourceLength==-1, see parameters)\n * - terminate with a NUL on output\n *   (only a single NUL byte, not useful for charsets with multi-byte NULs),\n *   or set U_STRING_NOT_TERMINATED_WARNING if the output exactly fills\n *   the target buffer\n * - a pivot buffer is provided internally\n *\n * The function returns when one of the following is true:\n * - the entire source text has been converted successfully to the target buffer\n *   and either the target buffer is terminated with a single NUL byte\n *   or the error code is set to U_STRING_NOT_TERMINATED_WARNING\n * - a target buffer overflow occurred (U_BUFFER_OVERFLOW_ERROR)\n *   and the full output string length is returned (\"preflighting\")\n * - a conversion error occurred\n *   (other U_FAILURE(), see description of pErrorCode)\n *\n * @param toConverterName   The name of the converter that is used to convert\n *                          from the UTF-16 pivot buffer to the target.\n * @param fromConverterName The name of the converter that is used to convert\n *                          from the source to the UTF-16 pivot buffer.\n * @param target            Pointer to the output buffer.\n * @param targetCapacity    Capacity of the target, in bytes.\n * @param source            Pointer to the input buffer.\n * @param sourceLength      Length of the input text, in bytes, or -1 for NUL-terminated input.\n * @param pErrorCode        ICU error code in/out parameter.\n *                          Must fulfill U_SUCCESS before the function call.\n * @return Length of the complete output text in bytes, even if it exceeds the targetCapacity\n *         and a U_BUFFER_OVERFLOW_ERROR is set.\n *\n * @see ucnv_convertEx\n * @see ucnv_fromAlgorithmic\n * @see ucnv_toAlgorithmic\n * @see ucnv_fromUnicode\n * @see ucnv_toUnicode\n * @see ucnv_fromUChars\n * @see ucnv_toUChars\n * @see ucnv_getNextUChar\n * @stable ICU 2.0\n */\nU_STABLE int32_t U_EXPORT2\nucnv_convert(const char *toConverterName,\n             const char *fromConverterName,\n             char *target,\n             int32_t targetCapacity,\n             const char *source,\n             int32_t sourceLength,\n             UErrorCode *pErrorCode);\n\n/**\n * Convert from one external charset to another.\n * Internally, the text is converted to and from the 16-bit Unicode \"pivot\"\n * using ucnv_convertEx(). ucnv_toAlgorithmic() works exactly like ucnv_convert()\n * except that the two converters need not be looked up and opened completely.\n *\n * The source-to-pivot conversion uses the cnv converter parameter.\n * The pivot-to-target conversion uses a purely algorithmic converter\n * according to the specified type, e.g., UCNV_UTF8 for a UTF-8 converter.\n *\n * Internally, the algorithmic converter is opened and closed for each\n * function call, which is more efficient than using the public ucnv_open()\n * but somewhat less efficient than only resetting an existing converter\n * and using ucnv_convertEx().\n *\n * This function is more convenient than ucnv_convertEx() for single-string\n * conversions, especially when \"preflighting\" is desired (returning the length\n * of the complete output even if it does not fit into the target buffer;\n * see the User Guide Strings chapter). See ucnv_convert() for details.\n *\n * @param algorithmicType   UConverterType constant identifying the desired target\n *                          charset as a purely algorithmic converter.\n *                          Those are converters for Unicode charsets like\n *                          UTF-8, BOCU-1, SCSU, UTF-7, IMAP-mailbox-name, etc.,\n *                          as well as US-ASCII and ISO-8859-1.\n * @param cnv               The converter that is used to convert\n *                          from the source to the UTF-16 pivot buffer.\n * @param target            Pointer to the output buffer.\n * @param targetCapacity    Capacity of the target, in bytes.\n * @param source            Pointer to the input buffer.\n * @param sourceLength      Length of the input text, in bytes\n * @param pErrorCode        ICU error code in/out parameter.\n *                          Must fulfill U_SUCCESS before the function call.\n * @return Length of the complete output text in bytes, even if it exceeds the targetCapacity\n *         and a U_BUFFER_OVERFLOW_ERROR is set.\n *\n * @see ucnv_fromAlgorithmic\n * @see ucnv_convert\n * @see ucnv_convertEx\n * @see ucnv_fromUnicode\n * @see ucnv_toUnicode\n * @see ucnv_fromUChars\n * @see ucnv_toUChars\n * @stable ICU 2.6\n */\nU_STABLE int32_t U_EXPORT2\nucnv_toAlgorithmic(UConverterType algorithmicType,\n                   UConverter *cnv,\n                   char *target, int32_t targetCapacity,\n                   const char *source, int32_t sourceLength,\n                   UErrorCode *pErrorCode);\n\n/**\n * Convert from one external charset to another.\n * Internally, the text is converted to and from the 16-bit Unicode \"pivot\"\n * using ucnv_convertEx(). ucnv_fromAlgorithmic() works exactly like ucnv_convert()\n * except that the two converters need not be looked up and opened completely.\n *\n * The source-to-pivot conversion uses a purely algorithmic converter\n * according to the specified type, e.g., UCNV_UTF8 for a UTF-8 converter.\n * The pivot-to-target conversion uses the cnv converter parameter.\n *\n * Internally, the algorithmic converter is opened and closed for each\n * function call, which is more efficient than using the public ucnv_open()\n * but somewhat less efficient than only resetting an existing converter\n * and using ucnv_convertEx().\n *\n * This function is more convenient than ucnv_convertEx() for single-string\n * conversions, especially when \"preflighting\" is desired (returning the length\n * of the complete output even if it does not fit into the target buffer;\n * see the User Guide Strings chapter). See ucnv_convert() for details.\n *\n * @param cnv               The converter that is used to convert\n *                          from the UTF-16 pivot buffer to the target.\n * @param algorithmicType   UConverterType constant identifying the desired source\n *                          charset as a purely algorithmic converter.\n *                          Those are converters for Unicode charsets like\n *                          UTF-8, BOCU-1, SCSU, UTF-7, IMAP-mailbox-name, etc.,\n *                          as well as US-ASCII and ISO-8859-1.\n * @param target            Pointer to the output buffer.\n * @param targetCapacity    Capacity of the target, in bytes.\n * @param source            Pointer to the input buffer.\n * @param sourceLength      Length of the input text, in bytes\n * @param pErrorCode        ICU error code in/out parameter.\n *                          Must fulfill U_SUCCESS before the function call.\n * @return Length of the complete output text in bytes, even if it exceeds the targetCapacity\n *         and a U_BUFFER_OVERFLOW_ERROR is set.\n *\n * @see ucnv_fromAlgorithmic\n * @see ucnv_convert\n * @see ucnv_convertEx\n * @see ucnv_fromUnicode\n * @see ucnv_toUnicode\n * @see ucnv_fromUChars\n * @see ucnv_toUChars\n * @stable ICU 2.6\n */\nU_STABLE int32_t U_EXPORT2\nucnv_fromAlgorithmic(UConverter *cnv,\n                     UConverterType algorithmicType,\n                     char *target, int32_t targetCapacity,\n                     const char *source, int32_t sourceLength,\n                     UErrorCode *pErrorCode);\n\n/**\n * Frees up memory occupied by unused, cached converter shared data.\n *\n * @return the number of cached converters successfully deleted\n * @see ucnv_close\n * @stable ICU 2.0\n */\nU_STABLE int32_t U_EXPORT2\nucnv_flushCache(void);\n\n/**\n * Returns the number of available converters, as per the alias file.\n *\n * @return the number of available converters\n * @see ucnv_getAvailableName\n * @stable ICU 2.0\n */\nU_STABLE int32_t U_EXPORT2\nucnv_countAvailable(void);\n\n/**\n * Gets the canonical converter name of the specified converter from a list of\n * all available converters contaied in the alias file. All converters\n * in this list can be opened.\n *\n * @param n the index to a converter available on the system (in the range <TT>[0..ucnv_countAvaiable()]</TT>)\n * @return a pointer a string (library owned), or <TT>NULL</TT> if the index is out of bounds.\n * @see ucnv_countAvailable\n * @stable ICU 2.0\n */\nU_STABLE const char* U_EXPORT2\nucnv_getAvailableName(int32_t n);\n\n/**\n * Returns a UEnumeration to enumerate all of the canonical converter\n * names, as per the alias file, regardless of the ability to open each\n * converter.\n *\n * @return A UEnumeration object for getting all the recognized canonical\n *   converter names.\n * @see ucnv_getAvailableName\n * @see uenum_close\n * @see uenum_next\n * @stable ICU 2.4\n */\nU_STABLE UEnumeration * U_EXPORT2\nucnv_openAllNames(UErrorCode *pErrorCode);\n\n/**\n * Gives the number of aliases for a given converter or alias name.\n * If the alias is ambiguous, then the preferred converter is used\n * and the status is set to U_AMBIGUOUS_ALIAS_WARNING.\n * This method only enumerates the listed entries in the alias file.\n * @param alias alias name\n * @param pErrorCode error status\n * @return number of names on alias list for given alias\n * @stable ICU 2.0\n */\nU_STABLE uint16_t U_EXPORT2 \nucnv_countAliases(const char *alias, UErrorCode *pErrorCode);\n\n/**\n * Gives the name of the alias at given index of alias list.\n * This method only enumerates the listed entries in the alias file.\n * If the alias is ambiguous, then the preferred converter is used\n * and the status is set to U_AMBIGUOUS_ALIAS_WARNING.\n * @param alias alias name\n * @param n index in alias list\n * @param pErrorCode result of operation\n * @return returns the name of the alias at given index\n * @see ucnv_countAliases\n * @stable ICU 2.0\n */\nU_STABLE const char * U_EXPORT2 \nucnv_getAlias(const char *alias, uint16_t n, UErrorCode *pErrorCode);\n\n/**\n * Fill-up the list of alias names for the given alias.\n * This method only enumerates the listed entries in the alias file.\n * If the alias is ambiguous, then the preferred converter is used\n * and the status is set to U_AMBIGUOUS_ALIAS_WARNING.\n * @param alias alias name\n * @param aliases fill-in list, aliases is a pointer to an array of\n *        <code>ucnv_countAliases()</code> string-pointers\n *        (<code>const char *</code>) that will be filled in.\n *        The strings themselves are owned by the library.\n * @param pErrorCode result of operation\n * @stable ICU 2.0\n */\nU_STABLE void U_EXPORT2 \nucnv_getAliases(const char *alias, const char **aliases, UErrorCode *pErrorCode);\n\n/**\n * Return a new UEnumeration object for enumerating all the\n * alias names for a given converter that are recognized by a standard.\n * This method only enumerates the listed entries in the alias file.\n * The convrtrs.txt file can be modified to change the results of\n * this function.\n * The first result in this list is the same result given by\n * <code>ucnv_getStandardName</code>, which is the default alias for\n * the specified standard name. The returned object must be closed with\n * <code>uenum_close</code> when you are done with the object.\n *\n * @param convName original converter name\n * @param standard name of the standard governing the names; MIME and IANA\n *      are such standards\n * @param pErrorCode The error code\n * @return A UEnumeration object for getting all aliases that are recognized\n *      by a standard. If any of the parameters are invalid, NULL\n *      is returned.\n * @see ucnv_getStandardName\n * @see uenum_close\n * @see uenum_next\n * @stable ICU 2.2\n */\nU_STABLE UEnumeration * U_EXPORT2\nucnv_openStandardNames(const char *convName,\n                       const char *standard,\n                       UErrorCode *pErrorCode);\n\n/**\n * Gives the number of standards associated to converter names.\n * @return number of standards\n * @stable ICU 2.0\n */\nU_STABLE uint16_t U_EXPORT2\nucnv_countStandards(void);\n\n/**\n * Gives the name of the standard at given index of standard list.\n * @param n index in standard list\n * @param pErrorCode result of operation\n * @return returns the name of the standard at given index. Owned by the library.\n * @stable ICU 2.0\n */\nU_STABLE const char * U_EXPORT2\nucnv_getStandard(uint16_t n, UErrorCode *pErrorCode);\n\n/**\n * Returns a standard name for a given converter name.\n * <p>\n * Example alias table:<br>\n * conv alias1 { STANDARD1 } alias2 { STANDARD1* }\n * <p>\n * Result of ucnv_getStandardName(\"conv\", \"STANDARD1\") from example\n * alias table:<br>\n * <b>\"alias2\"</b>\n *\n * @param name original converter name\n * @param standard name of the standard governing the names; MIME and IANA\n *        are such standards\n * @param pErrorCode result of operation\n * @return returns the standard converter name;\n *         if a standard converter name cannot be determined,\n *         then <code>NULL</code> is returned. Owned by the library.\n * @stable ICU 2.0\n */\nU_STABLE const char * U_EXPORT2\nucnv_getStandardName(const char *name, const char *standard, UErrorCode *pErrorCode);\n\n/**\n * This function will return the internal canonical converter name of the\n * tagged alias. This is the opposite of ucnv_openStandardNames, which\n * returns the tagged alias given the canonical name.\n * <p>\n * Example alias table:<br>\n * conv alias1 { STANDARD1 } alias2 { STANDARD1* }\n * <p>\n * Result of ucnv_getStandardName(\"alias1\", \"STANDARD1\") from example\n * alias table:<br>\n * <b>\"conv\"</b>\n *\n * @return returns the canonical converter name;\n *         if a standard or alias name cannot be determined,\n *         then <code>NULL</code> is returned. The returned string is\n *         owned by the library.\n * @see ucnv_getStandardName\n * @stable ICU 2.4\n */\nU_STABLE const char * U_EXPORT2\nucnv_getCanonicalName(const char *alias, const char *standard, UErrorCode *pErrorCode);\n\n/**\n * Returns the current default converter name. If you want to open\n * a default converter, you do not need to use this function.\n * It is faster if you pass a NULL argument to ucnv_open the\n * default converter.\n *\n * If U_CHARSET_IS_UTF8 is defined to 1 in utypes.h then this function\n * always returns \"UTF-8\".\n *\n * @return returns the current default converter name.\n *         Storage owned by the library\n * @see ucnv_setDefaultName\n * @stable ICU 2.0\n */\nU_STABLE const char * U_EXPORT2\nucnv_getDefaultName(void);\n\n#ifndef U_HIDE_SYSTEM_API\n/**\n * This function is not thread safe. DO NOT call this function when ANY ICU\n * function is being used from more than one thread! This function sets the\n * current default converter name. If this function needs to be called, it\n * should be called during application initialization. Most of the time, the\n * results from ucnv_getDefaultName() or ucnv_open with a NULL string argument\n * is sufficient for your application.\n *\n * If U_CHARSET_IS_UTF8 is defined to 1 in utypes.h then this function\n * does nothing.\n *\n * @param name the converter name to be the default (must be known by ICU).\n * @see ucnv_getDefaultName\n * @system\n * @stable ICU 2.0\n */\nU_STABLE void U_EXPORT2\nucnv_setDefaultName(const char *name);\n#endif  /* U_HIDE_SYSTEM_API */\n\n/**\n * Fixes the backslash character mismapping.  For example, in SJIS, the backslash \n * character in the ASCII portion is also used to represent the yen currency sign.  \n * When mapping from Unicode character 0x005C, it's unclear whether to map the \n * character back to yen or backslash in SJIS.  This function will take the input\n * buffer and replace all the yen sign characters with backslash.  This is necessary\n * when the user tries to open a file with the input buffer on Windows.\n * This function will test the converter to see whether such mapping is\n * required.  You can sometimes avoid using this function by using the correct version\n * of Shift-JIS.\n *\n * @param cnv The converter representing the target codepage.\n * @param source the input buffer to be fixed\n * @param sourceLen the length of the input buffer\n * @see ucnv_isAmbiguous\n * @stable ICU 2.0\n */\nU_STABLE void U_EXPORT2\nucnv_fixFileSeparator(const UConverter *cnv, UChar *source, int32_t sourceLen);\n\n/**\n * Determines if the converter contains ambiguous mappings of the same\n * character or not.\n * @param cnv the converter to be tested\n * @return TRUE if the converter contains ambiguous mapping of the same \n * character, FALSE otherwise.\n * @stable ICU 2.0\n */\nU_STABLE UBool U_EXPORT2\nucnv_isAmbiguous(const UConverter *cnv);\n\n/**\n * Sets the converter to use fallback mappings or not.\n * Regardless of this flag, the converter will always use\n * fallbacks from Unicode Private Use code points, as well as\n * reverse fallbacks (to Unicode).\n * For details see \".ucm File Format\"\n * in the Conversion Data chapter of the ICU User Guide:\n * http://www.icu-project.org/userguide/conversion-data.html#ucmformat\n *\n * @param cnv The converter to set the fallback mapping usage on.\n * @param usesFallback TRUE if the user wants the converter to take advantage of the fallback \n * mapping, FALSE otherwise.\n * @stable ICU 2.0\n * @see ucnv_usesFallback\n */\nU_STABLE void U_EXPORT2 \nucnv_setFallback(UConverter *cnv, UBool usesFallback);\n\n/**\n * Determines if the converter uses fallback mappings or not.\n * This flag has restrictions, see ucnv_setFallback().\n *\n * @param cnv The converter to be tested\n * @return TRUE if the converter uses fallback, FALSE otherwise.\n * @stable ICU 2.0\n * @see ucnv_setFallback\n */\nU_STABLE UBool U_EXPORT2 \nucnv_usesFallback(const UConverter *cnv);\n\n/**\n * Detects Unicode signature byte sequences at the start of the byte stream\n * and returns the charset name of the indicated Unicode charset.\n * NULL is returned when no Unicode signature is recognized.\n * The number of bytes in the signature is output as well.\n *\n * The caller can ucnv_open() a converter using the charset name.\n * The first code unit (UChar) from the start of the stream will be U+FEFF\n * (the Unicode BOM/signature character) and can usually be ignored.\n *\n * For most Unicode charsets it is also possible to ignore the indicated\n * number of initial stream bytes and start converting after them.\n * However, there are stateful Unicode charsets (UTF-7 and BOCU-1) for which\n * this will not work. Therefore, it is best to ignore the first output UChar\n * instead of the input signature bytes.\n * <p>\n * Usage:\n * \\snippet samples/ucnv/convsamp.cpp ucnv_detectUnicodeSignature\n *\n * @param source            The source string in which the signature should be detected.\n * @param sourceLength      Length of the input string, or -1 if terminated with a NUL byte.\n * @param signatureLength   A pointer to int32_t to receive the number of bytes that make up the signature \n *                          of the detected UTF. 0 if not detected.\n *                          Can be a NULL pointer.\n * @param pErrorCode        ICU error code in/out parameter.\n *                          Must fulfill U_SUCCESS before the function call.\n * @return The name of the encoding detected. NULL if encoding is not detected. \n * @stable ICU 2.4\n */\nU_STABLE const char* U_EXPORT2\nucnv_detectUnicodeSignature(const char* source,\n                            int32_t sourceLength,\n                            int32_t *signatureLength,\n                            UErrorCode *pErrorCode);\n\n/**\n * Returns the number of UChars held in the converter's internal state \n * because more input is needed for completing the conversion. This function is \n * useful for mapping semantics of ICU's converter interface to those of iconv,\n * and this information is not needed for normal conversion.\n * @param cnv       The converter in which the input is held\n * @param status    ICU error code in/out parameter.\n *                  Must fulfill U_SUCCESS before the function call.\n * @return The number of UChars in the state. -1 if an error is encountered.\n * @stable ICU 3.4\n */\nU_STABLE int32_t U_EXPORT2\nucnv_fromUCountPending(const UConverter* cnv, UErrorCode* status);\n\n/**\n * Returns the number of chars held in the converter's internal state\n * because more input is needed for completing the conversion. This function is \n * useful for mapping semantics of ICU's converter interface to those of iconv,\n * and this information is not needed for normal conversion.\n * @param cnv       The converter in which the input is held as internal state\n * @param status    ICU error code in/out parameter.\n *                  Must fulfill U_SUCCESS before the function call.\n * @return The number of chars in the state. -1 if an error is encountered.\n * @stable ICU 3.4\n */\nU_STABLE int32_t U_EXPORT2\nucnv_toUCountPending(const UConverter* cnv, UErrorCode* status);\n\n/**\n * Returns whether or not the charset of the converter has a fixed number of bytes\n * per charset character.\n * An example of this are converters that are of the type UCNV_SBCS or UCNV_DBCS.\n * Another example is UTF-32 which is always 4 bytes per character.\n * A Unicode code point may be represented by more than one UTF-8 or UTF-16 code unit\n * but a UTF-32 converter encodes each code point with 4 bytes.\n * Note: This method is not intended to be used to determine whether the charset has a\n * fixed ratio of bytes to Unicode codes <i>units</i> for any particular Unicode encoding form.\n * FALSE is returned with the UErrorCode if error occurs or cnv is NULL.\n * @param cnv       The converter to be tested\n * @param status    ICU error code in/out paramter\n * @return TRUE if the converter is fixed-width\n * @stable ICU 4.8\n */\nU_STABLE UBool U_EXPORT2\nucnv_isFixedWidth(UConverter *cnv, UErrorCode *status);\n\n#endif\n\n#endif\n/*_UCNV*/\n"
  },
  {
    "path": "deprecated/android/addons/icucompat/unicode/ucnv_cb.h",
    "content": "/*\n**********************************************************************\n*   Copyright (C) 2000-2004, International Business Machines\n*   Corporation and others.  All Rights Reserved.\n**********************************************************************\n *  ucnv_cb.h:\n *  External APIs for the ICU's codeset conversion library\n *  Helena Shih\n * \n * Modification History:\n *\n *   Date        Name        Description\n */\n\n/**\n * \\file \n * \\brief C UConverter functions to aid the writers of callbacks\n *\n * <h2> Callback API for UConverter </h2>\n * \n * These functions are provided here for the convenience of the callback\n * writer. If you are just looking for callback functions to use, please\n * see ucnv_err.h.  DO NOT call these functions directly when you are \n * working with converters, unless your code has been called as a callback\n * via ucnv_setFromUCallback or ucnv_setToUCallback !!\n * \n * A note about error codes and overflow.  Unlike other ICU functions,\n * these functions do not expect the error status to be U_ZERO_ERROR.\n * Callbacks must be much more careful about their error codes.\n * The error codes used here are in/out parameters, which should be passed\n * back in the callback's error parameter.\n * \n * For example, if you call ucnv_cbfromUWriteBytes to write data out \n * to the output codepage, it may return U_BUFFER_OVERFLOW_ERROR if \n * the data did not fit in the target. But this isn't a failing error, \n * in fact, ucnv_cbfromUWriteBytes may be called AGAIN with the error\n * status still U_BUFFER_OVERFLOW_ERROR to attempt to write further bytes,\n * which will also go into the internal overflow buffers.\n * \n * Concerning offsets, the 'offset' parameters here are relative to the start\n * of SOURCE.  For example, Suppose the string \"ABCD\" was being converted \n * from Unicode into a codepage which doesn't have a mapping for 'B'.\n * 'A' will be written out correctly, but\n * The FromU Callback will be called on an unassigned character for 'B'.\n * At this point, this is the state of the world:\n *    Target:    A [..]     [points after A]\n *    Source:  A B [C] D    [points to C - B has been consumed]\n *             0 1  2  3 \n *    codePoint = \"B\"       [the unassigned codepoint] \n * \n * Now, suppose a callback wants to write the substitution character '?' to\n * the target. It calls ucnv_cbFromUWriteBytes() to write the ?. \n * It should pass ZERO as the offset, because the offset as far as the \n * callback is concerned is relative to the SOURCE pointer [which points \n * before 'C'.]  If the callback goes into the args and consumes 'C' also,\n * it would call FromUWriteBytes with an offset of 1 (and advance the source\n * pointer).\n *\n */\n\n#ifndef UCNV_CB_H\n#define UCNV_CB_H\n\n#include \"unicode/utypes.h\"\n\n#if !UCONFIG_NO_CONVERSION\n\n#include \"unicode/ucnv.h\"\n#include \"unicode/ucnv_err.h\"\n\n/**\n * ONLY used by FromU callback functions.\n * Writes out the specified byte output bytes to the target byte buffer or to converter internal buffers.\n *\n * @param args callback fromUnicode arguments\n * @param source source bytes to write\n * @param length length of bytes to write\n * @param offsetIndex the relative offset index from callback.\n * @param err error status. If <TT>U_BUFFER_OVERFLOW</TT> is returned, then U_BUFFER_OVERFLOW <STRONG>must</STRONG> \n * be returned to the user, because it means that not all data could be written into the target buffer, and some is \n * in the converter error buffer.\n * @see ucnv_cbFromUWriteSub\n * @stable ICU 2.0\n */\nU_STABLE void U_EXPORT2\nucnv_cbFromUWriteBytes (UConverterFromUnicodeArgs *args,\n                        const char* source,\n                        int32_t length,\n                        int32_t offsetIndex,\n                        UErrorCode * err);\n\n/**\n * ONLY used by FromU callback functions.  \n * This function will write out the correct substitution character sequence \n * to the target.\n *\n * @param args callback fromUnicode arguments\n * @param offsetIndex the relative offset index from the current source pointer to be used\n * @param err error status. If <TT>U_BUFFER_OVERFLOW</TT> is returned, then U_BUFFER_OVERFLOW <STRONG>must</STRONG> \n * be returned to the user, because it means that not all data could be written into the target buffer, and some is \n * in the converter error buffer.\n * @see ucnv_cbFromUWriteBytes\n * @stable ICU 2.0\n */\nU_STABLE void U_EXPORT2 \nucnv_cbFromUWriteSub (UConverterFromUnicodeArgs *args,\n                      int32_t offsetIndex,\n                      UErrorCode * err);\n\n/**\n * ONLY used by fromU callback functions.  \n * This function will write out the error character(s) to the target UChar buffer.\n *\n * @param args callback fromUnicode arguments\n * @param source pointer to pointer to first UChar to write [on exit: 1 after last UChar processed]\n * @param sourceLimit pointer after last UChar to write\n * @param offsetIndex the relative offset index from callback which will be set\n * @param err error status <TT>U_BUFFER_OVERFLOW</TT>\n * @see ucnv_cbToUWriteSub\n * @stable ICU 2.0\n */\nU_STABLE void U_EXPORT2 ucnv_cbFromUWriteUChars(UConverterFromUnicodeArgs *args,\n                             const UChar** source,\n                             const UChar*  sourceLimit,\n                             int32_t offsetIndex,\n                             UErrorCode * err);\n\n/**\n * ONLY used by ToU callback functions.\n *  This function will write out the specified characters to the target \n * UChar buffer.\n *\n * @param args callback toUnicode arguments\n * @param source source string to write\n * @param length the length of source string\n * @param offsetIndex the relative offset index which will be written.\n * @param err error status <TT>U_BUFFER_OVERFLOW</TT>\n * @see ucnv_cbToUWriteSub\n * @stable ICU 2.0\n */\nU_STABLE void U_EXPORT2 ucnv_cbToUWriteUChars (UConverterToUnicodeArgs *args,\n                                             const UChar* source,\n                                             int32_t length,\n                                             int32_t offsetIndex,\n                                             UErrorCode * err);\n\n/**\n * ONLY used by ToU  callback functions.  \n * This function will write out the Unicode substitution character (U+FFFD).\n *\n * @param args callback fromUnicode arguments\n * @param offsetIndex the relative offset index from callback.\n * @param err error status <TT>U_BUFFER_OVERFLOW</TT>\n * @see ucnv_cbToUWriteUChars\n * @stable ICU 2.0\n */\nU_STABLE void U_EXPORT2 ucnv_cbToUWriteSub (UConverterToUnicodeArgs *args,\n                       int32_t offsetIndex,\n                       UErrorCode * err);\n#endif\n\n#endif\n"
  },
  {
    "path": "deprecated/android/addons/icucompat/unicode/ucnv_err.h",
    "content": "/*\n**********************************************************************\n*   Copyright (C) 1999-2009, International Business Machines\n*   Corporation and others.  All Rights Reserved.\n**********************************************************************\n *\n *\n *   ucnv_err.h:\n */\n\n/**\n * \\file\n * \\brief C UConverter predefined error callbacks\n *\n *  <h2>Error Behaviour Functions</h2>\n *  Defines some error behaviour functions called by ucnv_{from,to}Unicode\n *  These are provided as part of ICU and many are stable, but they\n *  can also be considered only as an example of what can be done with\n *  callbacks.  You may of course write your own.\n *\n *  If you want to write your own, you may also find the functions from\n *  ucnv_cb.h useful when writing your own callbacks.\n *\n *  These functions, although public, should NEVER be called directly.\n *  They should be used as parameters to the ucnv_setFromUCallback\n *  and ucnv_setToUCallback functions, to set the behaviour of a converter\n *  when it encounters ILLEGAL/UNMAPPED/INVALID sequences.\n *\n *  usage example:  'STOP' doesn't need any context, but newContext\n *    could be set to something other than 'NULL' if needed. The available\n *    contexts in this header can modify the default behavior of the callback.\n *\n *  \\code\n *  UErrorCode err = U_ZERO_ERROR;\n *  UConverter *myConverter = ucnv_open(\"ibm-949\", &err);\n *  const void *oldContext;\n *  UConverterFromUCallback oldAction;\n *\n *\n *  if (U_SUCCESS(err))\n *  {\n *      ucnv_setFromUCallBack(myConverter,\n *                       UCNV_FROM_U_CALLBACK_STOP,\n *                       NULL,\n *                       &oldAction,\n *                       &oldContext,\n *                       &status);\n *  }\n *  \\endcode\n *\n *  The code above tells \"myConverter\" to stop when it encounters an\n *  ILLEGAL/TRUNCATED/INVALID sequences when it is used to convert from\n *  Unicode -> Codepage. The behavior from Codepage to Unicode is not changed,\n *  and ucnv_setToUCallBack would need to be called in order to change\n *  that behavior too.\n *\n *  Here is an example with a context:\n *\n *  \\code\n *  UErrorCode err = U_ZERO_ERROR;\n *  UConverter *myConverter = ucnv_open(\"ibm-949\", &err);\n *  const void *oldContext;\n *  UConverterFromUCallback oldAction;\n *\n *\n *  if (U_SUCCESS(err))\n *  {\n *      ucnv_setToUCallBack(myConverter,\n *                       UCNV_TO_U_CALLBACK_SUBSTITUTE,\n *                       UCNV_SUB_STOP_ON_ILLEGAL,\n *                       &oldAction,\n *                       &oldContext,\n *                       &status);\n *  }\n *  \\endcode\n *\n *  The code above tells \"myConverter\" to stop when it encounters an\n *  ILLEGAL/TRUNCATED/INVALID sequences when it is used to convert from\n *  Codepage -> Unicode. Any unmapped and legal characters will be\n *  substituted to be the default substitution character.\n */\n\n#ifndef UCNV_ERR_H\n#define UCNV_ERR_H\n\n#include \"unicode/utypes.h\"\n\n#if !UCONFIG_NO_CONVERSION\n\n/** Forward declaring the UConverter structure. @stable ICU 2.0 */\nstruct UConverter;\n\n/** @stable ICU 2.0 */\ntypedef struct UConverter UConverter;\n\n/**\n * FROM_U, TO_U context options for sub callback\n * @stable ICU 2.0\n */\n#define UCNV_SUB_STOP_ON_ILLEGAL \"i\"\n\n/**\n * FROM_U, TO_U context options for skip callback\n * @stable ICU 2.0\n */\n#define UCNV_SKIP_STOP_ON_ILLEGAL \"i\"\n\n/**\n * FROM_U_CALLBACK_ESCAPE context option to escape the code unit according to ICU (%UXXXX) \n * @stable ICU 2.0\n */\n#define UCNV_ESCAPE_ICU       NULL\n/**\n * FROM_U_CALLBACK_ESCAPE context option to escape the code unit according to JAVA (\\\\uXXXX)\n * @stable ICU 2.0\n */\n#define UCNV_ESCAPE_JAVA      \"J\"\n/**\n * FROM_U_CALLBACK_ESCAPE context option to escape the code unit according to C (\\\\uXXXX \\\\UXXXXXXXX)\n * TO_U_CALLBACK_ESCAPE option to escape the character value accoding to C (\\\\xXXXX)\n * @stable ICU 2.0\n */\n#define UCNV_ESCAPE_C         \"C\"\n/**\n * FROM_U_CALLBACK_ESCAPE context option to escape the code unit according to XML Decimal escape \\htmlonly(&amp;#DDDD;)\\endhtmlonly\n * TO_U_CALLBACK_ESCAPE context option to escape the character value accoding to XML Decimal escape \\htmlonly(&amp;#DDDD;)\\endhtmlonly\n * @stable ICU 2.0\n */\n#define UCNV_ESCAPE_XML_DEC   \"D\"\n/**\n * FROM_U_CALLBACK_ESCAPE context option to escape the code unit according to XML Hex escape \\htmlonly(&amp;#xXXXX;)\\endhtmlonly\n * TO_U_CALLBACK_ESCAPE context option to escape the character value accoding to XML Hex escape \\htmlonly(&amp;#xXXXX;)\\endhtmlonly\n * @stable ICU 2.0\n */\n#define UCNV_ESCAPE_XML_HEX   \"X\"\n/**\n * FROM_U_CALLBACK_ESCAPE context option to escape the code unit according to Unicode (U+XXXXX)\n * @stable ICU 2.0\n */\n#define UCNV_ESCAPE_UNICODE   \"U\"\n\n/**\n * FROM_U_CALLBACK_ESCAPE context option to escape the code unit according to CSS2 conventions (\\\\HH..H<space>, that is,\n * a backslash, 1..6 hex digits, and a space)\n * @stable ICU 4.0\n */\n#define UCNV_ESCAPE_CSS2   \"S\"\n\n/** \n * The process condition code to be used with the callbacks.  \n * Codes which are greater than UCNV_IRREGULAR should be \n * passed on to any chained callbacks.\n * @stable ICU 2.0\n */\ntypedef enum {\n    UCNV_UNASSIGNED = 0,  /**< The code point is unassigned.\n                             The error code U_INVALID_CHAR_FOUND will be set. */\n    UCNV_ILLEGAL = 1,     /**< The code point is illegal. For example, \n                             \\\\x81\\\\x2E is illegal in SJIS because \\\\x2E\n                             is not a valid trail byte for the \\\\x81 \n                             lead byte.\n                             Also, starting with Unicode 3.0.1, non-shortest byte sequences\n                             in UTF-8 (like \\\\xC1\\\\xA1 instead of \\\\x61 for U+0061)\n                             are also illegal, not just irregular.\n                             The error code U_ILLEGAL_CHAR_FOUND will be set. */\n    UCNV_IRREGULAR = 2,   /**< The codepoint is not a regular sequence in \n                             the encoding. For example, \\\\xED\\\\xA0\\\\x80..\\\\xED\\\\xBF\\\\xBF\n                             are irregular UTF-8 byte sequences for single surrogate\n                             code points.\n                             The error code U_INVALID_CHAR_FOUND will be set. */\n    UCNV_RESET = 3,       /**< The callback is called with this reason when a\n                             'reset' has occured. Callback should reset all\n                             state. */\n    UCNV_CLOSE = 4,        /**< Called when the converter is closed. The\n                             callback should release any allocated memory.*/\n    UCNV_CLONE = 5         /**< Called when ucnv_safeClone() is called on the\n                              converter. the pointer available as the\n                              'context' is an alias to the original converters'\n                              context pointer. If the context must be owned\n                              by the new converter, the callback must clone \n                              the data and call ucnv_setFromUCallback \n                              (or setToUCallback) with the correct pointer.\n                              @stable ICU 2.2\n                           */\n} UConverterCallbackReason;\n\n\n/**\n * The structure for the fromUnicode callback function parameter.\n * @stable ICU 2.0\n */\ntypedef struct {\n    uint16_t size;              /**< The size of this struct. @stable ICU 2.0 */\n    UBool flush;                /**< The internal state of converter will be reset and data flushed if set to TRUE. @stable ICU 2.0    */\n    UConverter *converter;      /**< Pointer to the converter that is opened and to which this struct is passed as an argument. @stable ICU 2.0  */\n    const UChar *source;        /**< Pointer to the source source buffer. @stable ICU 2.0    */\n    const UChar *sourceLimit;   /**< Pointer to the limit (end + 1) of source buffer. @stable ICU 2.0    */\n    char *target;               /**< Pointer to the target buffer. @stable ICU 2.0    */\n    const char *targetLimit;    /**< Pointer to the limit (end + 1) of target buffer. @stable ICU 2.0     */\n    int32_t *offsets;           /**< Pointer to the buffer that recieves the offsets. *offset = blah ; offset++;. @stable ICU 2.0  */\n} UConverterFromUnicodeArgs;\n\n\n/**\n * The structure for the toUnicode callback function parameter.\n * @stable ICU 2.0\n */\ntypedef struct {\n    uint16_t size;              /**< The size of this struct   @stable ICU 2.0 */\n    UBool flush;                /**< The internal state of converter will be reset and data flushed if set to TRUE. @stable ICU 2.0   */\n    UConverter *converter;      /**< Pointer to the converter that is opened and to which this struct is passed as an argument. @stable ICU 2.0 */\n    const char *source;         /**< Pointer to the source source buffer. @stable ICU 2.0    */\n    const char *sourceLimit;    /**< Pointer to the limit (end + 1) of source buffer. @stable ICU 2.0    */\n    UChar *target;              /**< Pointer to the target buffer. @stable ICU 2.0    */\n    const UChar *targetLimit;   /**< Pointer to the limit (end + 1) of target buffer. @stable ICU 2.0     */\n    int32_t *offsets;           /**< Pointer to the buffer that recieves the offsets. *offset = blah ; offset++;. @stable ICU 2.0  */\n} UConverterToUnicodeArgs;\n\n\n/**\n * DO NOT CALL THIS FUNCTION DIRECTLY!\n * This From Unicode callback STOPS at the ILLEGAL_SEQUENCE,\n * returning the error code back to the caller immediately.\n *\n * @param context Pointer to the callback's private data\n * @param fromUArgs Information about the conversion in progress\n * @param codeUnits Points to 'length' UChars of the concerned Unicode sequence\n * @param length Size (in bytes) of the concerned codepage sequence\n * @param codePoint Single UChar32 (UTF-32) containing the concerend Unicode codepoint.\n * @param reason Defines the reason the callback was invoked\n * @param err This should always be set to a failure status prior to calling.\n * @stable ICU 2.0\n */\nU_STABLE void U_EXPORT2 UCNV_FROM_U_CALLBACK_STOP (\n                  const void *context,\n                  UConverterFromUnicodeArgs *fromUArgs,\n                  const UChar* codeUnits,\n                  int32_t length,\n                  UChar32 codePoint,\n                  UConverterCallbackReason reason,\n                  UErrorCode * err);\n\n\n\n/**\n * DO NOT CALL THIS FUNCTION DIRECTLY!\n * This To Unicode callback STOPS at the ILLEGAL_SEQUENCE,\n * returning the error code back to the caller immediately.\n *\n * @param context Pointer to the callback's private data\n * @param toUArgs Information about the conversion in progress\n * @param codeUnits Points to 'length' bytes of the concerned codepage sequence\n * @param length Size (in bytes) of the concerned codepage sequence\n * @param reason Defines the reason the callback was invoked\n * @param err This should always be set to a failure status prior to calling.\n * @stable ICU 2.0\n */\nU_STABLE void U_EXPORT2 UCNV_TO_U_CALLBACK_STOP (\n                  const void *context,\n                  UConverterToUnicodeArgs *toUArgs,\n                  const char* codeUnits,\n                  int32_t length,\n                  UConverterCallbackReason reason,\n                  UErrorCode * err);\n\n/**\n * DO NOT CALL THIS FUNCTION DIRECTLY!\n * This From Unicode callback skips any ILLEGAL_SEQUENCE, or\n * skips only UNASSINGED_SEQUENCE depending on the context parameter\n * simply ignoring those characters. \n *\n * @param context  The function currently recognizes the callback options:\n *                 UCNV_SKIP_STOP_ON_ILLEGAL: STOPS at the ILLEGAL_SEQUENCE,\n *                      returning the error code back to the caller immediately.\n *                 NULL: Skips any ILLEGAL_SEQUENCE\n * @param fromUArgs Information about the conversion in progress\n * @param codeUnits Points to 'length' UChars of the concerned Unicode sequence\n * @param length Size (in bytes) of the concerned codepage sequence\n * @param codePoint Single UChar32 (UTF-32) containing the concerend Unicode codepoint.\n * @param reason Defines the reason the callback was invoked\n * @param err Return value will be set to success if the callback was handled,\n *      otherwise this value will be set to a failure status.\n * @stable ICU 2.0\n */\nU_STABLE void U_EXPORT2 UCNV_FROM_U_CALLBACK_SKIP (\n                  const void *context,\n                  UConverterFromUnicodeArgs *fromUArgs,\n                  const UChar* codeUnits,\n                  int32_t length,\n                  UChar32 codePoint,\n                  UConverterCallbackReason reason,\n                  UErrorCode * err);\n\n/**\n * DO NOT CALL THIS FUNCTION DIRECTLY!\n * This From Unicode callback will Substitute the ILLEGAL SEQUENCE, or \n * UNASSIGNED_SEQUENCE depending on context parameter, with the\n * current substitution string for the converter. This is the default\n * callback.\n *\n * @param context The function currently recognizes the callback options:\n *                 UCNV_SUB_STOP_ON_ILLEGAL: STOPS at the ILLEGAL_SEQUENCE,\n *                      returning the error code back to the caller immediately.\n *                 NULL: Substitutes any ILLEGAL_SEQUENCE\n * @param fromUArgs Information about the conversion in progress\n * @param codeUnits Points to 'length' UChars of the concerned Unicode sequence\n * @param length Size (in bytes) of the concerned codepage sequence\n * @param codePoint Single UChar32 (UTF-32) containing the concerend Unicode codepoint.\n * @param reason Defines the reason the callback was invoked\n * @param err Return value will be set to success if the callback was handled,\n *      otherwise this value will be set to a failure status.\n * @see ucnv_setSubstChars\n * @stable ICU 2.0\n */\nU_STABLE void U_EXPORT2 UCNV_FROM_U_CALLBACK_SUBSTITUTE (\n                  const void *context,\n                  UConverterFromUnicodeArgs *fromUArgs,\n                  const UChar* codeUnits,\n                  int32_t length,\n                  UChar32 codePoint,\n                  UConverterCallbackReason reason,\n                  UErrorCode * err);\n\n/**\n * DO NOT CALL THIS FUNCTION DIRECTLY!\n * This From Unicode callback will Substitute the ILLEGAL SEQUENCE with the\n * hexadecimal representation of the illegal codepoints\n *\n * @param context The function currently recognizes the callback options:\n *        <ul>\n *        <li>UCNV_ESCAPE_ICU: Substitues the  ILLEGAL SEQUENCE with the hexadecimal \n *          representation in the format  %UXXXX, e.g. \"%uFFFE%u00AC%uC8FE\"). \n *          In the Event the converter doesn't support the characters {%,U}[A-F][0-9], \n *          it will  substitute  the illegal sequence with the substitution characters.\n *          Note that  codeUnit(32bit int eg: unit of a surrogate pair) is represented as\n *          %UD84D%UDC56</li>\n *        <li>UCNV_ESCAPE_JAVA: Substitues the  ILLEGAL SEQUENCE with the hexadecimal \n *          representation in the format  \\\\uXXXX, e.g. \"\\\\uFFFE\\\\u00AC\\\\uC8FE\"). \n *          In the Event the converter doesn't support the characters {\\,u}[A-F][0-9], \n *          it will  substitute  the illegal sequence with the substitution characters.\n *          Note that  codeUnit(32bit int eg: unit of a surrogate pair) is represented as\n *          \\\\uD84D\\\\uDC56</li>\n *        <li>UCNV_ESCAPE_C: Substitues the  ILLEGAL SEQUENCE with the hexadecimal \n *          representation in the format  \\\\uXXXX, e.g. \"\\\\uFFFE\\\\u00AC\\\\uC8FE\"). \n *          In the Event the converter doesn't support the characters {\\,u,U}[A-F][0-9], \n *          it will  substitute  the illegal sequence with the substitution characters.\n *          Note that  codeUnit(32bit int eg: unit of a surrogate pair) is represented as\n *          \\\\U00023456</li>\n *        <li>UCNV_ESCAPE_XML_DEC: Substitues the  ILLEGAL SEQUENCE with the decimal \n *          representation in the format \\htmlonly&amp;#DDDDDDDD;, e.g. \"&amp;#65534;&amp;#172;&amp;#51454;\")\\endhtmlonly. \n *          In the Event the converter doesn't support the characters {&amp;,#}[0-9], \n *          it will  substitute  the illegal sequence with the substitution characters.\n *          Note that  codeUnit(32bit int eg: unit of a surrogate pair) is represented as\n *          &amp;#144470; and Zero padding is ignored.</li>\n *        <li>UCNV_ESCAPE_XML_HEX:Substitues the  ILLEGAL SEQUENCE with the decimal \n *          representation in the format \\htmlonly&amp;#xXXXX; e.g. \"&amp;#xFFFE;&amp;#x00AC;&amp;#xC8FE;\")\\endhtmlonly. \n *          In the Event the converter doesn't support the characters {&,#,x}[0-9], \n *          it will  substitute  the illegal sequence with the substitution characters.\n *          Note that  codeUnit(32bit int eg: unit of a surrogate pair) is represented as\n *          \\htmlonly&amp;#x23456;\\endhtmlonly</li>\n *        </ul>\n * @param fromUArgs Information about the conversion in progress\n * @param codeUnits Points to 'length' UChars of the concerned Unicode sequence\n * @param length Size (in bytes) of the concerned codepage sequence\n * @param codePoint Single UChar32 (UTF-32) containing the concerend Unicode codepoint.\n * @param reason Defines the reason the callback was invoked\n * @param err Return value will be set to success if the callback was handled,\n *      otherwise this value will be set to a failure status.\n * @stable ICU 2.0\n */\nU_STABLE void U_EXPORT2 UCNV_FROM_U_CALLBACK_ESCAPE (\n                  const void *context,\n                  UConverterFromUnicodeArgs *fromUArgs,\n                  const UChar* codeUnits,\n                  int32_t length,\n                  UChar32 codePoint,\n                  UConverterCallbackReason reason,\n                  UErrorCode * err);\n\n\n/**\n * DO NOT CALL THIS FUNCTION DIRECTLY!\n * This To Unicode callback skips any ILLEGAL_SEQUENCE, or\n * skips only UNASSINGED_SEQUENCE depending on the context parameter\n * simply ignoring those characters. \n *\n * @param context  The function currently recognizes the callback options:\n *                 UCNV_SKIP_STOP_ON_ILLEGAL: STOPS at the ILLEGAL_SEQUENCE,\n *                      returning the error code back to the caller immediately.\n *                 NULL: Skips any ILLEGAL_SEQUENCE\n * @param toUArgs Information about the conversion in progress\n * @param codeUnits Points to 'length' bytes of the concerned codepage sequence\n * @param length Size (in bytes) of the concerned codepage sequence\n * @param reason Defines the reason the callback was invoked\n * @param err Return value will be set to success if the callback was handled,\n *      otherwise this value will be set to a failure status.\n * @stable ICU 2.0\n */\nU_STABLE void U_EXPORT2 UCNV_TO_U_CALLBACK_SKIP (\n                  const void *context,\n                  UConverterToUnicodeArgs *toUArgs,\n                  const char* codeUnits,\n                  int32_t length,\n                  UConverterCallbackReason reason,\n                  UErrorCode * err);\n\n/**\n * DO NOT CALL THIS FUNCTION DIRECTLY!\n * This To Unicode callback will Substitute the ILLEGAL SEQUENCE,or \n * UNASSIGNED_SEQUENCE depending on context parameter,  with the\n * Unicode substitution character, U+FFFD.\n *\n * @param context  The function currently recognizes the callback options:\n *                 UCNV_SUB_STOP_ON_ILLEGAL: STOPS at the ILLEGAL_SEQUENCE,\n *                      returning the error code back to the caller immediately.\n *                 NULL: Substitutes any ILLEGAL_SEQUENCE\n * @param toUArgs Information about the conversion in progress\n * @param codeUnits Points to 'length' bytes of the concerned codepage sequence\n * @param length Size (in bytes) of the concerned codepage sequence\n * @param reason Defines the reason the callback was invoked\n * @param err Return value will be set to success if the callback was handled,\n *      otherwise this value will be set to a failure status.\n * @stable ICU 2.0\n */\nU_STABLE void U_EXPORT2 UCNV_TO_U_CALLBACK_SUBSTITUTE (\n                  const void *context,\n                  UConverterToUnicodeArgs *toUArgs,\n                  const char* codeUnits,\n                  int32_t length,\n                  UConverterCallbackReason reason,\n                  UErrorCode * err);\n\n/**\n * DO NOT CALL THIS FUNCTION DIRECTLY!\n * This To Unicode callback will Substitute the ILLEGAL SEQUENCE with the\n * hexadecimal representation of the illegal bytes\n *  (in the format  %XNN, e.g. \"%XFF%X0A%XC8%X03\").\n *\n * @param context This function currently recognizes the callback options:\n *      UCNV_ESCAPE_ICU, UCNV_ESCAPE_JAVA, UCNV_ESCAPE_C, UCNV_ESCAPE_XML_DEC,\n *      UCNV_ESCAPE_XML_HEX and UCNV_ESCAPE_UNICODE.\n * @param toUArgs Information about the conversion in progress\n * @param codeUnits Points to 'length' bytes of the concerned codepage sequence\n * @param length Size (in bytes) of the concerned codepage sequence\n * @param reason Defines the reason the callback was invoked\n * @param err Return value will be set to success if the callback was handled,\n *      otherwise this value will be set to a failure status.\n * @stable ICU 2.0\n */\n\nU_STABLE void U_EXPORT2 UCNV_TO_U_CALLBACK_ESCAPE (\n                  const void *context,\n                  UConverterToUnicodeArgs *toUArgs,\n                  const char* codeUnits,\n                  int32_t length,\n                  UConverterCallbackReason reason,\n                  UErrorCode * err);\n\n#endif\n\n#endif\n\n/*UCNV_ERR_H*/ \n"
  },
  {
    "path": "deprecated/android/addons/icucompat/unicode/ucnvsel.h",
    "content": "/*\n*******************************************************************************\n*\n*   Copyright (C) 2008-2011, International Business Machines\n*   Corporation, Google and others.  All Rights Reserved.\n*\n*******************************************************************************\n*/\n/*\n * Author : eldawy@google.com (Mohamed Eldawy)\n * ucnvsel.h\n *\n * Purpose: To generate a list of encodings capable of handling\n * a given Unicode text\n *\n * Started 09-April-2008\n */\n\n#ifndef __ICU_UCNV_SEL_H__\n#define __ICU_UCNV_SEL_H__\n\n#include \"unicode/utypes.h\"\n\n#if !UCONFIG_NO_CONVERSION\n\n#include \"unicode/uset.h\"\n#include \"unicode/utf16.h\"\n#include \"unicode/uenum.h\"\n#include \"unicode/ucnv.h\"\n#include \"unicode/localpointer.h\"\n\n/**\n * \\file\n *\n * A converter selector is built with a set of encoding/charset names\n * and given an input string returns the set of names of the\n * corresponding converters which can convert the string.\n *\n * A converter selector can be serialized into a buffer and reopened\n * from the serialized form.\n */\n\n/**\n * @{\n * The selector data structure\n */\nstruct UConverterSelector;\ntypedef struct UConverterSelector UConverterSelector;\n/** @} */\n\n/**\n * Open a selector.\n * If converterListSize is 0, build for all available converters.\n * If excludedCodePoints is NULL, don't exclude any code points.\n *\n * @param converterList a pointer to encoding names needed to be involved. \n *                      Can be NULL if converterListSize==0.\n *                      The list and the names will be cloned, and the caller\n *                      retains ownership of the original.\n * @param converterListSize number of encodings in above list.\n *                          If 0, builds a selector for all available converters.\n * @param excludedCodePoints a set of code points to be excluded from consideration.\n *                           That is, excluded code points in a string do not change\n *                           the selection result. (They might be handled by a callback.)\n *                           Use NULL to exclude nothing.\n * @param whichSet what converter set to use? Use this to determine whether\n *                 to consider only roundtrip mappings or also fallbacks.\n * @param status an in/out ICU UErrorCode\n * @return the new selector\n *\n * @stable ICU 4.2\n */\nU_STABLE UConverterSelector* U_EXPORT2\nucnvsel_open(const char* const*  converterList, int32_t converterListSize,\n             const USet* excludedCodePoints,\n             const UConverterUnicodeSet whichSet, UErrorCode* status);\n\n/**\n * Closes a selector.\n * If any Enumerations were returned by ucnv_select*, they become invalid.\n * They can be closed before or after calling ucnv_closeSelector,\n * but should never be used after the selector is closed.\n *\n * @see ucnv_selectForString\n * @see ucnv_selectForUTF8\n *\n * @param sel selector to close\n *\n * @stable ICU 4.2\n */\nU_STABLE void U_EXPORT2\nucnvsel_close(UConverterSelector *sel);\n\n#if U_SHOW_CPLUSPLUS_API\n\nU_NAMESPACE_BEGIN\n\n/**\n * \\class LocalUConverterSelectorPointer\n * \"Smart pointer\" class, closes a UConverterSelector via ucnvsel_close().\n * For most methods see the LocalPointerBase base class.\n *\n * @see LocalPointerBase\n * @see LocalPointer\n * @stable ICU 4.4\n */\nU_DEFINE_LOCAL_OPEN_POINTER(LocalUConverterSelectorPointer, UConverterSelector, ucnvsel_close);\n\nU_NAMESPACE_END\n\n#endif\n\n/**\n * Open a selector from its serialized form.\n * The buffer must remain valid and unchanged for the lifetime of the selector.\n * This is much faster than creating a selector from scratch.\n * Using a serialized form from a different machine (endianness/charset) is supported.\n *\n * @param buffer pointer to the serialized form of a converter selector;\n *               must be 32-bit-aligned\n * @param length the capacity of this buffer (can be equal to or larger than\n *               the actual data length)\n * @param status an in/out ICU UErrorCode\n * @return the new selector\n *\n * @stable ICU 4.2\n */\nU_STABLE UConverterSelector* U_EXPORT2\nucnvsel_openFromSerialized(const void* buffer, int32_t length, UErrorCode* status);\n\n/**\n * Serialize a selector into a linear buffer.\n * The serialized form is portable to different machines.\n *\n * @param sel selector to consider\n * @param buffer pointer to 32-bit-aligned memory to be filled with the\n *               serialized form of this converter selector\n * @param bufferCapacity the capacity of this buffer\n * @param status an in/out ICU UErrorCode\n * @return the required buffer capacity to hold serialize data (even if the call fails\n *         with a U_BUFFER_OVERFLOW_ERROR, it will return the required capacity)\n *\n * @stable ICU 4.2\n */\nU_STABLE int32_t U_EXPORT2\nucnvsel_serialize(const UConverterSelector* sel,\n                  void* buffer, int32_t bufferCapacity, UErrorCode* status);\n\n/**\n * Select converters that can map all characters in a UTF-16 string,\n * ignoring the excluded code points.\n *\n * @param sel a selector\n * @param s UTF-16 string\n * @param length length of the string, or -1 if NUL-terminated\n * @param status an in/out ICU UErrorCode\n * @return an enumeration containing encoding names.\n *         The returned encoding names and their order will be the same as\n *         supplied when building the selector.\n *\n * @stable ICU 4.2\n */\nU_STABLE UEnumeration * U_EXPORT2\nucnvsel_selectForString(const UConverterSelector* sel,\n                        const UChar *s, int32_t length, UErrorCode *status);\n\n/**\n * Select converters that can map all characters in a UTF-8 string,\n * ignoring the excluded code points.\n *\n * @param sel a selector\n * @param s UTF-8 string\n * @param length length of the string, or -1 if NUL-terminated\n * @param status an in/out ICU UErrorCode\n * @return an enumeration containing encoding names.\n *         The returned encoding names and their order will be the same as\n *         supplied when building the selector.\n *\n * @stable ICU 4.2\n */\nU_STABLE UEnumeration * U_EXPORT2\nucnvsel_selectForUTF8(const UConverterSelector* sel,\n                      const char *s, int32_t length, UErrorCode *status);\n\n#endif  /* !UCONFIG_NO_CONVERSION */\n\n#endif  /* __ICU_UCNV_SEL_H__ */\n"
  },
  {
    "path": "deprecated/android/addons/icucompat/unicode/ucol.h",
    "content": "/*\n*******************************************************************************\n* Copyright (c) 1996-2012, International Business Machines Corporation and others.\n* All Rights Reserved.\n*******************************************************************************\n*/\n\n#ifndef UCOL_H\n#define UCOL_H\n\n#include \"unicode/utypes.h\"\n\n#if !UCONFIG_NO_COLLATION\n\n#include \"unicode/unorm.h\"\n#include \"unicode/localpointer.h\"\n#include \"unicode/parseerr.h\"\n#include \"unicode/uloc.h\"\n#include \"unicode/uset.h\"\n#include \"unicode/uscript.h\"\n\n/**\n * \\file\n * \\brief C API: Collator \n *\n * <h2> Collator C API </h2>\n *\n * The C API for Collator performs locale-sensitive\n * string comparison. You use this service to build\n * searching and sorting routines for natural language text.\n * <em>Important: </em>The ICU collation service has been reimplemented \n * in order to achieve better performance and UCA compliance. \n * For details, see the \n * <a href=\"http://source.icu-project.org/repos/icu/icuhtml/trunk/design/collation/ICU_collation_design.htm\">\n * collation design document</a>.\n * <p>\n * For more information about the collation service see \n * <a href=\"http://icu-project.org/userguide/Collate_Intro.html\">the users guide</a>.\n * <p>\n * Collation service provides correct sorting orders for most locales supported in ICU. \n * If specific data for a locale is not available, the orders eventually falls back\n * to the <a href=\"http://www.unicode.org/unicode/reports/tr10/\">UCA sort order</a>. \n * <p>\n * Sort ordering may be customized by providing your own set of rules. For more on\n * this subject see the \n * <a href=\"http://icu-project.org/userguide/Collate_Customization.html\">\n * Collation customization</a> section of the users guide.\n * <p>\n * @see         UCollationResult\n * @see         UNormalizationMode\n * @see         UCollationStrength\n * @see         UCollationElements\n */\n\n/** A collator.\n*  For usage in C programs.\n*/\nstruct UCollator;\n/** structure representing a collator object instance \n * @stable ICU 2.0\n */\ntypedef struct UCollator UCollator;\n\n\n/**\n * UCOL_LESS is returned if source string is compared to be less than target\n * string in the u_strcoll() method.\n * UCOL_EQUAL is returned if source string is compared to be equal to target\n * string in the u_strcoll() method.\n * UCOL_GREATER is returned if source string is compared to be greater than\n * target string in the u_strcoll() method.\n * @see u_strcoll()\n * <p>\n * Possible values for a comparison result \n * @stable ICU 2.0\n */\ntypedef enum {\n  /** string a == string b */\n  UCOL_EQUAL    = 0,\n  /** string a > string b */\n  UCOL_GREATER    = 1,\n  /** string a < string b */\n  UCOL_LESS    = -1\n} UCollationResult ;\n\n\n/** Enum containing attribute values for controling collation behavior.\n * Here are all the allowable values. Not every attribute can take every value. The only\n * universal value is UCOL_DEFAULT, which resets the attribute value to the predefined  \n * value for that locale \n * @stable ICU 2.0\n */\ntypedef enum {\n  /** accepted by most attributes */\n  UCOL_DEFAULT = -1,\n\n  /** Primary collation strength */\n  UCOL_PRIMARY = 0,\n  /** Secondary collation strength */\n  UCOL_SECONDARY = 1,\n  /** Tertiary collation strength */\n  UCOL_TERTIARY = 2,\n  /** Default collation strength */\n  UCOL_DEFAULT_STRENGTH = UCOL_TERTIARY,\n  UCOL_CE_STRENGTH_LIMIT,\n  /** Quaternary collation strength */\n  UCOL_QUATERNARY=3,\n  /** Identical collation strength */\n  UCOL_IDENTICAL=15,\n  UCOL_STRENGTH_LIMIT,\n\n  /** Turn the feature off - works for UCOL_FRENCH_COLLATION, \n      UCOL_CASE_LEVEL, UCOL_HIRAGANA_QUATERNARY_MODE\n      & UCOL_DECOMPOSITION_MODE*/\n  UCOL_OFF = 16,\n  /** Turn the feature on - works for UCOL_FRENCH_COLLATION, \n      UCOL_CASE_LEVEL, UCOL_HIRAGANA_QUATERNARY_MODE\n      & UCOL_DECOMPOSITION_MODE*/\n  UCOL_ON = 17,\n  \n  /** Valid for UCOL_ALTERNATE_HANDLING. Alternate handling will be shifted */\n  UCOL_SHIFTED = 20,\n  /** Valid for UCOL_ALTERNATE_HANDLING. Alternate handling will be non ignorable */\n  UCOL_NON_IGNORABLE = 21,\n\n  /** Valid for UCOL_CASE_FIRST - \n      lower case sorts before upper case */\n  UCOL_LOWER_FIRST = 24,\n  /** upper case sorts before lower case */\n  UCOL_UPPER_FIRST = 25,\n\n  UCOL_ATTRIBUTE_VALUE_COUNT\n\n} UColAttributeValue;\n\n/**\n * Enum containing the codes for reordering segments of the collation table that are not script\n * codes. These reordering codes are to be used in conjunction with the script codes.\n * @see ucol_getReorderCodes\n * @see ucol_setReorderCodes\n * @see ucol_getEquivalentReorderCodes\n * @see UScriptCode\n * @stable ICU 4.8\n */\n typedef enum {\n   /**\n    * A special reordering code that is used to specify the default\n    * reordering codes for a locale.\n    * @stable ICU 4.8\n    */   \n    UCOL_REORDER_CODE_DEFAULT       = -1,\n   /**\n    * A special reordering code that is used to specify no reordering codes.\n    * @stable ICU 4.8\n    */   \n    UCOL_REORDER_CODE_NONE          = USCRIPT_UNKNOWN,\n   /**\n    * A special reordering code that is used to specify all other codes used for\n    * reordering except for the codes lised as UColReorderCode values and those\n    * listed explicitly in a reordering.\n    * @stable ICU 4.8\n    */   \n    UCOL_REORDER_CODE_OTHERS        = USCRIPT_UNKNOWN,\n   /**\n    * Characters with the space property.\n    * This is equivalent to the rule value \"space\".\n    * @stable ICU 4.8\n    */    \n    UCOL_REORDER_CODE_SPACE         = 0x1000,\n   /**\n    * The first entry in the enumeration of reordering groups. This is intended for use in\n    * range checking and enumeration of the reorder codes.\n    * @stable ICU 4.8\n    */    \n    UCOL_REORDER_CODE_FIRST         = UCOL_REORDER_CODE_SPACE,\n   /**\n    * Characters with the punctuation property.\n    * This is equivalent to the rule value \"punct\".\n    * @stable ICU 4.8\n    */    \n    UCOL_REORDER_CODE_PUNCTUATION   = 0x1001,\n   /**\n    * Characters with the symbol property.\n    * This is equivalent to the rule value \"symbol\".\n    * @stable ICU 4.8\n    */    \n    UCOL_REORDER_CODE_SYMBOL        = 0x1002,\n   /**\n    * Characters with the currency property.\n    * This is equivalent to the rule value \"currency\".\n    * @stable ICU 4.8\n    */    \n    UCOL_REORDER_CODE_CURRENCY      = 0x1003,\n   /**\n    * Characters with the digit property.\n    * This is equivalent to the rule value \"digit\".\n    * @stable ICU 4.8\n    */    \n    UCOL_REORDER_CODE_DIGIT         = 0x1004,\n   /**\n    * The limit of the reorder codes. This is intended for use in range checking \n    * and enumeration of the reorder codes.\n    * @stable ICU 4.8\n    */    \n    UCOL_REORDER_CODE_LIMIT         = 0x1005\n} UColReorderCode;\n\n/**\n * Base letter represents a primary difference.  Set comparison\n * level to UCOL_PRIMARY to ignore secondary and tertiary differences.\n * Use this to set the strength of a Collator object.\n * Example of primary difference, \"abc\" &lt; \"abd\"\n * \n * Diacritical differences on the same base letter represent a secondary\n * difference.  Set comparison level to UCOL_SECONDARY to ignore tertiary\n * differences. Use this to set the strength of a Collator object.\n * Example of secondary difference, \"&auml;\" >> \"a\".\n *\n * Uppercase and lowercase versions of the same character represents a\n * tertiary difference.  Set comparison level to UCOL_TERTIARY to include\n * all comparison differences. Use this to set the strength of a Collator\n * object.\n * Example of tertiary difference, \"abc\" &lt;&lt;&lt; \"ABC\".\n *\n * Two characters are considered \"identical\" when they have the same\n * unicode spellings.  UCOL_IDENTICAL.\n * For example, \"&auml;\" == \"&auml;\".\n *\n * UCollationStrength is also used to determine the strength of sort keys \n * generated from UCollator objects\n * These values can be now found in the UColAttributeValue enum.\n * @stable ICU 2.0\n **/\ntypedef UColAttributeValue UCollationStrength;\n\n/** Attributes that collation service understands. All the attributes can take UCOL_DEFAULT\n * value, as well as the values specific to each one. \n * @stable ICU 2.0\n */\ntypedef enum {\n     /** Attribute for direction of secondary weights - used in Canadian French.\n      * Acceptable values are UCOL_ON, which results in secondary weights\n      * being considered backwards and UCOL_OFF which treats secondary\n      * weights in the order they appear.\n      * @stable ICU 2.0\n      */\n     UCOL_FRENCH_COLLATION, \n     /** Attribute for handling variable elements.\n      * Acceptable values are UCOL_NON_IGNORABLE (default)\n      * which treats all the codepoints with non-ignorable \n      * primary weights in the same way,\n      * and UCOL_SHIFTED which causes codepoints with primary \n      * weights that are equal or below the variable top value\n      * to be ignored on primary level and moved to the quaternary \n      * level.\n      * @stable ICU 2.0\n      */\n     UCOL_ALTERNATE_HANDLING, \n     /** Controls the ordering of upper and lower case letters.\n      * Acceptable values are UCOL_OFF (default), which orders\n      * upper and lower case letters in accordance to their tertiary\n      * weights, UCOL_UPPER_FIRST which forces upper case letters to \n      * sort before lower case letters, and UCOL_LOWER_FIRST which does \n      * the opposite.\n      * @stable ICU 2.0\n      */\n     UCOL_CASE_FIRST, \n     /** Controls whether an extra case level (positioned before the third\n      * level) is generated or not. Acceptable values are UCOL_OFF (default), \n      * when case level is not generated, and UCOL_ON which causes the case\n      * level to be generated. Contents of the case level are affected by\n      * the value of UCOL_CASE_FIRST attribute. A simple way to ignore \n      * accent differences in a string is to set the strength to UCOL_PRIMARY\n      * and enable case level.\n      * @stable ICU 2.0\n      */\n     UCOL_CASE_LEVEL,\n     /** Controls whether the normalization check and necessary normalizations\n      * are performed. When set to UCOL_OFF (default) no normalization check\n      * is performed. The correctness of the result is guaranteed only if the \n      * input data is in so-called FCD form (see users manual for more info).\n      * When set to UCOL_ON, an incremental check is performed to see whether\n      * the input data is in the FCD form. If the data is not in the FCD form,\n      * incremental NFD normalization is performed.\n      * @stable ICU 2.0\n      */\n     UCOL_NORMALIZATION_MODE, \n     /** An alias for UCOL_NORMALIZATION_MODE attribute.\n      * @stable ICU 2.0\n      */\n     UCOL_DECOMPOSITION_MODE = UCOL_NORMALIZATION_MODE,\n     /** The strength attribute. Can be either UCOL_PRIMARY, UCOL_SECONDARY,\n      * UCOL_TERTIARY, UCOL_QUATERNARY or UCOL_IDENTICAL. The usual strength\n      * for most locales (except Japanese) is tertiary. Quaternary strength \n      * is useful when combined with shifted setting for alternate handling\n      * attribute and for JIS x 4061 collation, when it is used to distinguish\n      * between Katakana  and Hiragana (this is achieved by setting the \n      * UCOL_HIRAGANA_QUATERNARY mode to on. Otherwise, quaternary level\n      * is affected only by the number of non ignorable code points in\n      * the string. Identical strength is rarely useful, as it amounts \n      * to codepoints of the NFD form of the string.\n      * @stable ICU 2.0\n      */\n     UCOL_STRENGTH,  \n     /** When turned on, this attribute positions Hiragana before all  \n      * non-ignorables on quaternary level This is a sneaky way to produce JIS\n      * sort order.\n      *\n      * This attribute is an implementation detail of the CLDR Japanese tailoring.\n      * The implementation might change to use a different mechanism\n      * to achieve the same Japanese sort order.\n      * Since ICU 50, this attribute is not settable any more via API functions.\n      * @deprecated ICU 50 Implementation detail, cannot be set via API, might be removed from implementation.\n      */\n     UCOL_HIRAGANA_QUATERNARY_MODE,\n     /** When turned on, this attribute generates a collation key\n      * for the numeric value of substrings of digits.\n      * This is a way to get '100' to sort AFTER '2'. Note that the longest\n      * digit substring that can be treated as a single collation element is\n      * 254 digits (not counting leading zeros). If a digit substring is\n      * longer than that, the digits beyond the limit will be treated as a\n      * separate digit substring associated with a separate collation element.\n      * @stable ICU 2.8\n      */\n     UCOL_NUMERIC_COLLATION, \n     /**\n      * The number of UColAttribute constants.\n      * @stable ICU 2.0\n      */\n     UCOL_ATTRIBUTE_COUNT\n} UColAttribute;\n\n/** Options for retrieving the rule string \n *  @stable ICU 2.0\n */\ntypedef enum {\n  /**\n   * Retrieves the tailoring rules only.\n   * Same as calling the version of getRules() without UColRuleOption.\n   * @stable ICU 2.0\n   */\n  UCOL_TAILORING_ONLY, \n  /**\n   * Retrieves the \"UCA rules\" concatenated with the tailoring rules.\n   * The \"UCA rules\" are an <i>approximation</i> of the root collator's sort order.\n   * They are almost never used or useful at runtime and can be removed from the data.\n   * See http://userguide.icu-project.org/collation/customization#TOC-Building-on-Existing-Locales\n   * @stable ICU 2.0\n   */\n  UCOL_FULL_RULES \n} UColRuleOption ;\n\n/**\n * Open a UCollator for comparing strings.\n * The UCollator pointer is used in all the calls to the Collation \n * service. After finished, collator must be disposed of by calling\n * {@link #ucol_close }.\n * @param loc The locale containing the required collation rules. \n *            Special values for locales can be passed in - \n *            if NULL is passed for the locale, the default locale\n *            collation rules will be used. If empty string (\"\") or\n *            \"root\" are passed, UCA rules will be used.\n * @param status A pointer to an UErrorCode to receive any errors\n * @return A pointer to a UCollator, or 0 if an error occurred.\n * @see ucol_openRules\n * @see ucol_safeClone\n * @see ucol_close\n * @stable ICU 2.0\n */\nU_STABLE UCollator* U_EXPORT2 \nucol_open(const char *loc, UErrorCode *status);\n\n/**\n * Produce an UCollator instance according to the rules supplied.\n * The rules are used to change the default ordering, defined in the\n * UCA in a process called tailoring. The resulting UCollator pointer\n * can be used in the same way as the one obtained by {@link #ucol_strcoll }.\n * @param rules A string describing the collation rules. For the syntax\n *              of the rules please see users guide.\n * @param rulesLength The length of rules, or -1 if null-terminated.\n * @param normalizationMode The normalization mode: One of\n *             UCOL_OFF     (expect the text to not need normalization),\n *             UCOL_ON      (normalize), or\n *             UCOL_DEFAULT (set the mode according to the rules)\n * @param strength The default collation strength; one of UCOL_PRIMARY, UCOL_SECONDARY,\n * UCOL_TERTIARY, UCOL_IDENTICAL,UCOL_DEFAULT_STRENGTH - can be also set in the rules.\n * @param parseError  A pointer to UParseError to recieve information about errors\n *                    occurred during parsing. This argument can currently be set\n *                    to NULL, but at users own risk. Please provide a real structure.\n * @param status A pointer to an UErrorCode to receive any errors\n * @return A pointer to a UCollator. It is not guaranteed that NULL be returned in case\n *         of error - please use status argument to check for errors.\n * @see ucol_open\n * @see ucol_safeClone\n * @see ucol_close\n * @stable ICU 2.0\n */\nU_STABLE UCollator* U_EXPORT2 \nucol_openRules( const UChar        *rules,\n                int32_t            rulesLength,\n                UColAttributeValue normalizationMode,\n                UCollationStrength strength,\n                UParseError        *parseError,\n                UErrorCode         *status);\n\n/** \n * Open a collator defined by a short form string.\n * The structure and the syntax of the string is defined in the \"Naming collators\"\n * section of the users guide: \n * http://icu-project.org/userguide/Collate_Concepts.html#Naming_Collators\n * Attributes are overriden by the subsequent attributes. So, for \"S2_S3\", final\n * strength will be 3. 3066bis locale overrides individual locale parts.\n * The call to this function is equivalent to a call to ucol_open, followed by a \n * series of calls to ucol_setAttribute and ucol_setVariableTop.\n * @param definition A short string containing a locale and a set of attributes. \n *                   Attributes not explicitly mentioned are left at the default\n *                   state for a locale.\n * @param parseError if not NULL, structure that will get filled with error's pre\n *                   and post context in case of error.\n * @param forceDefaults if FALSE, the settings that are the same as the collator \n *                   default settings will not be applied (for example, setting\n *                   French secondary on a French collator would not be executed). \n *                   If TRUE, all the settings will be applied regardless of the \n *                   collator default value. If the definition\n *                   strings are to be cached, should be set to FALSE.\n * @param status     Error code. Apart from regular error conditions connected to \n *                   instantiating collators (like out of memory or similar), this\n *                   API will return an error if an invalid attribute or attribute/value\n *                   combination is specified.\n * @return           A pointer to a UCollator or 0 if an error occured (including an \n *                   invalid attribute).\n * @see ucol_open\n * @see ucol_setAttribute\n * @see ucol_setVariableTop\n * @see ucol_getShortDefinitionString\n * @see ucol_normalizeShortDefinitionString\n * @stable ICU 3.0\n *\n */\nU_STABLE UCollator* U_EXPORT2\nucol_openFromShortString( const char *definition,\n                          UBool forceDefaults,\n                          UParseError *parseError,\n                          UErrorCode *status);\n\n#ifndef U_HIDE_DEPRECATED_API\n/**\n * Get a set containing the contractions defined by the collator. The set includes\n * both the UCA contractions and the contractions defined by the collator. This set\n * will contain only strings. If a tailoring explicitly suppresses contractions from \n * the UCA (like Russian), removed contractions will not be in the resulting set.\n * @param coll collator \n * @param conts the set to hold the result. It gets emptied before\n *              contractions are added. \n * @param status to hold the error code\n * @return the size of the contraction set\n *\n * @deprecated ICU 3.4, use ucol_getContractionsAndExpansions instead\n */\nU_DEPRECATED int32_t U_EXPORT2\nucol_getContractions( const UCollator *coll,\n                  USet *conts,\n                  UErrorCode *status);\n#endif  /* U_HIDE_DEPRECATED_API */\n\n/**\n * Get a set containing the expansions defined by the collator. The set includes\n * both the UCA expansions and the expansions defined by the tailoring\n * @param coll collator\n * @param contractions if not NULL, the set to hold the contractions\n * @param expansions if not NULL, the set to hold the expansions\n * @param addPrefixes add the prefix contextual elements to contractions\n * @param status to hold the error code\n *\n * @stable ICU 3.4\n */\nU_STABLE void U_EXPORT2\nucol_getContractionsAndExpansions( const UCollator *coll,\n                  USet *contractions, USet *expansions,\n                  UBool addPrefixes, UErrorCode *status);\n\n/** \n * Close a UCollator.\n * Once closed, a UCollator should not be used. Every open collator should\n * be closed. Otherwise, a memory leak will result.\n * @param coll The UCollator to close.\n * @see ucol_open\n * @see ucol_openRules\n * @see ucol_safeClone\n * @stable ICU 2.0\n */\nU_STABLE void U_EXPORT2 \nucol_close(UCollator *coll);\n\n#if U_SHOW_CPLUSPLUS_API\n\nU_NAMESPACE_BEGIN\n\n/**\n * \\class LocalUCollatorPointer\n * \"Smart pointer\" class, closes a UCollator via ucol_close().\n * For most methods see the LocalPointerBase base class.\n *\n * @see LocalPointerBase\n * @see LocalPointer\n * @stable ICU 4.4\n */\nU_DEFINE_LOCAL_OPEN_POINTER(LocalUCollatorPointer, UCollator, ucol_close);\n\nU_NAMESPACE_END\n\n#endif\n\n/**\n * Compare two strings.\n * The strings will be compared using the options already specified.\n * @param coll The UCollator containing the comparison rules.\n * @param source The source string.\n * @param sourceLength The length of source, or -1 if null-terminated.\n * @param target The target string.\n * @param targetLength The length of target, or -1 if null-terminated.\n * @return The result of comparing the strings; one of UCOL_EQUAL,\n * UCOL_GREATER, UCOL_LESS\n * @see ucol_greater\n * @see ucol_greaterOrEqual\n * @see ucol_equal\n * @stable ICU 2.0\n */\nU_STABLE UCollationResult U_EXPORT2 \nucol_strcoll(    const    UCollator    *coll,\n        const    UChar        *source,\n        int32_t            sourceLength,\n        const    UChar        *target,\n        int32_t            targetLength);\n\n/** \n* Compare two strings in UTF-8. \n* The strings will be compared using the options already specified. \n* Note: When input string contains malformed a UTF-8 byte sequence, \n* this function treats these bytes as REPLACEMENT CHARACTER (U+FFFD).\n* @param coll The UCollator containing the comparison rules. \n* @param source The source UTF-8 string. \n* @param sourceLength The length of source, or -1 if null-terminated. \n* @param target The target UTF-8 string. \n* @param targetLength The length of target, or -1 if null-terminated. \n* @param status A pointer to an UErrorCode to receive any errors \n* @return The result of comparing the strings; one of UCOL_EQUAL, \n* UCOL_GREATER, UCOL_LESS \n* @see ucol_greater \n* @see ucol_greaterOrEqual \n* @see ucol_equal \n* @draft ICU 50 \n*/ \nU_DRAFT UCollationResult U_EXPORT2\nucol_strcollUTF8(\n        const UCollator *coll,\n        const char      *source,\n        int32_t         sourceLength,\n        const char      *target,\n        int32_t         targetLength,\n        UErrorCode      *status);\n\n/**\n * Determine if one string is greater than another.\n * This function is equivalent to {@link #ucol_strcoll } == UCOL_GREATER\n * @param coll The UCollator containing the comparison rules.\n * @param source The source string.\n * @param sourceLength The length of source, or -1 if null-terminated.\n * @param target The target string.\n * @param targetLength The length of target, or -1 if null-terminated.\n * @return TRUE if source is greater than target, FALSE otherwise.\n * @see ucol_strcoll\n * @see ucol_greaterOrEqual\n * @see ucol_equal\n * @stable ICU 2.0\n */\nU_STABLE UBool U_EXPORT2 \nucol_greater(const UCollator *coll,\n             const UChar     *source, int32_t sourceLength,\n             const UChar     *target, int32_t targetLength);\n\n/**\n * Determine if one string is greater than or equal to another.\n * This function is equivalent to {@link #ucol_strcoll } != UCOL_LESS\n * @param coll The UCollator containing the comparison rules.\n * @param source The source string.\n * @param sourceLength The length of source, or -1 if null-terminated.\n * @param target The target string.\n * @param targetLength The length of target, or -1 if null-terminated.\n * @return TRUE if source is greater than or equal to target, FALSE otherwise.\n * @see ucol_strcoll\n * @see ucol_greater\n * @see ucol_equal\n * @stable ICU 2.0\n */\nU_STABLE UBool U_EXPORT2 \nucol_greaterOrEqual(const UCollator *coll,\n                    const UChar     *source, int32_t sourceLength,\n                    const UChar     *target, int32_t targetLength);\n\n/**\n * Compare two strings for equality.\n * This function is equivalent to {@link #ucol_strcoll } == UCOL_EQUAL\n * @param coll The UCollator containing the comparison rules.\n * @param source The source string.\n * @param sourceLength The length of source, or -1 if null-terminated.\n * @param target The target string.\n * @param targetLength The length of target, or -1 if null-terminated.\n * @return TRUE if source is equal to target, FALSE otherwise\n * @see ucol_strcoll\n * @see ucol_greater\n * @see ucol_greaterOrEqual\n * @stable ICU 2.0\n */\nU_STABLE UBool U_EXPORT2 \nucol_equal(const UCollator *coll,\n           const UChar     *source, int32_t sourceLength,\n           const UChar     *target, int32_t targetLength);\n\n/**\n * Compare two UTF-8 encoded trings.\n * The strings will be compared using the options already specified.\n * @param coll The UCollator containing the comparison rules.\n * @param sIter The source string iterator.\n * @param tIter The target string iterator.\n * @return The result of comparing the strings; one of UCOL_EQUAL,\n * UCOL_GREATER, UCOL_LESS\n * @param status A pointer to an UErrorCode to receive any errors\n * @see ucol_strcoll\n * @stable ICU 2.6\n */\nU_STABLE UCollationResult U_EXPORT2 \nucol_strcollIter(  const    UCollator    *coll,\n                  UCharIterator *sIter,\n                  UCharIterator *tIter,\n                  UErrorCode *status);\n\n/**\n * Get the collation strength used in a UCollator.\n * The strength influences how strings are compared.\n * @param coll The UCollator to query.\n * @return The collation strength; one of UCOL_PRIMARY, UCOL_SECONDARY,\n * UCOL_TERTIARY, UCOL_QUATERNARY, UCOL_IDENTICAL\n * @see ucol_setStrength\n * @stable ICU 2.0\n */\nU_STABLE UCollationStrength U_EXPORT2 \nucol_getStrength(const UCollator *coll);\n\n/**\n * Set the collation strength used in a UCollator.\n * The strength influences how strings are compared.\n * @param coll The UCollator to set.\n * @param strength The desired collation strength; one of UCOL_PRIMARY, \n * UCOL_SECONDARY, UCOL_TERTIARY, UCOL_QUATERNARY, UCOL_IDENTICAL, UCOL_DEFAULT\n * @see ucol_getStrength\n * @stable ICU 2.0\n */\nU_STABLE void U_EXPORT2 \nucol_setStrength(UCollator *coll,\n                 UCollationStrength strength);\n\n/**\n * Retrieves the reordering codes for this collator.\n * These reordering codes are a combination of UScript codes and UColReorderCode entries.\n * @param coll The UCollator to query.\n * @param dest The array to fill with the script ordering.\n * @param destCapacity The length of dest. If it is 0, then dest may be NULL and the function \n * will only return the length of the result without writing any of the result string (pre-flighting).\n * @param pErrorCode Must be a valid pointer to an error code value, which must not indicate a \n * failure before the function call.\n * @return The number of reordering codes written to the dest array.\n * @see ucol_setReorderCodes\n * @see ucol_getEquivalentReorderCodes\n * @see UScriptCode\n * @see UColReorderCode\n * @stable ICU 4.8\n */\nU_STABLE int32_t U_EXPORT2 \nucol_getReorderCodes(const UCollator* coll,\n                    int32_t* dest,\n                    int32_t destCapacity,\n                    UErrorCode *pErrorCode);\n/** \n * Sets the reordering codes for this collator.\n * Collation reordering allows scripts and some other defined blocks of characters \n * to be moved relative to each other as a block. This reordering is done on top of \n * the DUCET/CLDR standard collation order. Reordering can specify groups to be placed \n * at the start and/or the end of the collation order. These groups are specified using\n * UScript codes and UColReorderCode entries.\n * <p>By default, reordering codes specified for the start of the order are placed in the \n * order given after a group of \"special\" non-script blocks. These special groups of characters \n * are space, punctuation, symbol, currency, and digit. These special groups are represented with\n * UColReorderCode entries. Script groups can be intermingled with \n * these special non-script blocks if those special blocks are explicitly specified in the reordering.\n * <p>The special code OTHERS stands for any script that is not explicitly \n * mentioned in the list of reordering codes given. Anything that is after OTHERS\n * will go at the very end of the reordering in the order given.\n * <p>The special reorder code DEFAULT will reset the reordering for this collator\n * to the default for this collator. The default reordering may be the DUCET/CLDR order or may be a reordering that\n * was specified when this collator was created from resource data or from rules. The \n * DEFAULT code <b>must</b> be the sole code supplied when it used. If not\n * that will result in an U_ILLEGAL_ARGUMENT_ERROR being set.\n * <p>The special reorder code NONE will remove any reordering for this collator.\n * The result of setting no reordering will be to have the DUCET/CLDR ordering used. The \n * NONE code <b>must</b> be the sole code supplied when it used.\n * @param coll The UCollator to set.\n * @param reorderCodes An array of script codes in the new order. This can be NULL if the \n * length is also set to 0. An empty array will clear any reordering codes on the collator.\n * @param reorderCodesLength The length of reorderCodes.\n * @param pErrorCode Must be a valid pointer to an error code value, which must not indicate a\n * failure before the function call.\n * @see ucol_getReorderCodes\n * @see ucol_getEquivalentReorderCodes\n * @see UScriptCode\n * @see UColReorderCode\n * @stable ICU 4.8\n */ \nU_STABLE void U_EXPORT2 \nucol_setReorderCodes(UCollator* coll,\n                    const int32_t* reorderCodes,\n                    int32_t reorderCodesLength,\n                    UErrorCode *pErrorCode);\n\n/**\n * Retrieves the reorder codes that are grouped with the given reorder code. Some reorder\n * codes will be grouped and must reorder together.\n * @param reorderCode The reorder code to determine equivalence for.\n * @param dest The array to fill with the script ordering.\n * @param destCapacity The length of dest. If it is 0, then dest may be NULL and the function\n * will only return the length of the result without writing any of the result string (pre-flighting).\n * @param pErrorCode Must be a valid pointer to an error code value, which must not indicate \n * a failure before the function call.\n * @return The number of reordering codes written to the dest array.\n * @see ucol_setReorderCodes\n * @see ucol_getReorderCodes\n * @see UScriptCode\n * @see UColReorderCode\n * @stable ICU 4.8\n */\nU_STABLE int32_t U_EXPORT2 \nucol_getEquivalentReorderCodes(int32_t reorderCode,\n                    int32_t* dest,\n                    int32_t destCapacity,\n                    UErrorCode *pErrorCode);\n\n/**\n * Get the display name for a UCollator.\n * The display name is suitable for presentation to a user.\n * @param objLoc The locale of the collator in question.\n * @param dispLoc The locale for display.\n * @param result A pointer to a buffer to receive the attribute.\n * @param resultLength The maximum size of result.\n * @param status A pointer to an UErrorCode to receive any errors\n * @return The total buffer size needed; if greater than resultLength,\n * the output was truncated.\n * @stable ICU 2.0\n */\nU_STABLE int32_t U_EXPORT2 \nucol_getDisplayName(    const    char        *objLoc,\n            const    char        *dispLoc,\n            UChar             *result,\n            int32_t         resultLength,\n            UErrorCode        *status);\n\n/**\n * Get a locale for which collation rules are available.\n * A UCollator in a locale returned by this function will perform the correct\n * collation for the locale.\n * @param localeIndex The index of the desired locale.\n * @return A locale for which collation rules are available, or 0 if none.\n * @see ucol_countAvailable\n * @stable ICU 2.0\n */\nU_STABLE const char* U_EXPORT2 \nucol_getAvailable(int32_t localeIndex);\n\n/**\n * Determine how many locales have collation rules available.\n * This function is most useful as determining the loop ending condition for\n * calls to {@link #ucol_getAvailable }.\n * @return The number of locales for which collation rules are available.\n * @see ucol_getAvailable\n * @stable ICU 2.0\n */\nU_STABLE int32_t U_EXPORT2 \nucol_countAvailable(void);\n\n#if !UCONFIG_NO_SERVICE\n/**\n * Create a string enumerator of all locales for which a valid\n * collator may be opened.\n * @param status input-output error code\n * @return a string enumeration over locale strings. The caller is\n * responsible for closing the result.\n * @stable ICU 3.0\n */\nU_STABLE UEnumeration* U_EXPORT2\nucol_openAvailableLocales(UErrorCode *status);\n#endif\n\n/**\n * Create a string enumerator of all possible keywords that are relevant to\n * collation. At this point, the only recognized keyword for this\n * service is \"collation\".\n * @param status input-output error code\n * @return a string enumeration over locale strings. The caller is\n * responsible for closing the result.\n * @stable ICU 3.0\n */\nU_STABLE UEnumeration* U_EXPORT2\nucol_getKeywords(UErrorCode *status);\n\n/**\n * Given a keyword, create a string enumeration of all values\n * for that keyword that are currently in use.\n * @param keyword a particular keyword as enumerated by\n * ucol_getKeywords. If any other keyword is passed in, *status is set\n * to U_ILLEGAL_ARGUMENT_ERROR.\n * @param status input-output error code\n * @return a string enumeration over collation keyword values, or NULL\n * upon error. The caller is responsible for closing the result.\n * @stable ICU 3.0\n */\nU_STABLE UEnumeration* U_EXPORT2\nucol_getKeywordValues(const char *keyword, UErrorCode *status);\n\n/**\n * Given a key and a locale, returns an array of string values in a preferred\n * order that would make a difference. These are all and only those values where\n * the open (creation) of the service with the locale formed from the input locale\n * plus input keyword and that value has different behavior than creation with the\n * input locale alone.\n * @param key           one of the keys supported by this service.  For now, only\n *                      \"collation\" is supported.\n * @param locale        the locale\n * @param commonlyUsed  if set to true it will return only commonly used values\n *                      with the given locale in preferred order.  Otherwise,\n *                      it will return all the available values for the locale.\n * @param status error status\n * @return a string enumeration over keyword values for the given key and the locale.\n * @stable ICU 4.2\n */\nU_STABLE UEnumeration* U_EXPORT2\nucol_getKeywordValuesForLocale(const char* key,\n                               const char* locale,\n                               UBool commonlyUsed,\n                               UErrorCode* status);\n\n/**\n * Return the functionally equivalent locale for the given\n * requested locale, with respect to given keyword, for the\n * collation service.  If two locales return the same result, then\n * collators instantiated for these locales will behave\n * equivalently.  The converse is not always true; two collators\n * may in fact be equivalent, but return different results, due to\n * internal details.  The return result has no other meaning than\n * that stated above, and implies nothing as to the relationship\n * between the two locales.  This is intended for use by\n * applications who wish to cache collators, or otherwise reuse\n * collators when possible.  The functional equivalent may change\n * over time.  For more information, please see the <a\n * href=\"http://icu-project.org/userguide/locale.html#services\">\n * Locales and Services</a> section of the ICU User Guide.\n * @param result fillin for the functionally equivalent locale\n * @param resultCapacity capacity of the fillin buffer\n * @param keyword a particular keyword as enumerated by\n * ucol_getKeywords.\n * @param locale the requested locale\n * @param isAvailable if non-NULL, pointer to a fillin parameter that\n * indicates whether the requested locale was 'available' to the\n * collation service. A locale is defined as 'available' if it\n * physically exists within the collation locale data.\n * @param status pointer to input-output error code\n * @return the actual buffer size needed for the locale.  If greater\n * than resultCapacity, the returned full name will be truncated and\n * an error code will be returned.\n * @stable ICU 3.0\n */\nU_STABLE int32_t U_EXPORT2\nucol_getFunctionalEquivalent(char* result, int32_t resultCapacity,\n                             const char* keyword, const char* locale,\n                             UBool* isAvailable, UErrorCode* status);\n\n/**\n * Get the collation tailoring rules from a UCollator.\n * The rules will follow the rule syntax.\n * @param coll The UCollator to query.\n * @param length \n * @return The collation tailoring rules.\n * @stable ICU 2.0\n */\nU_STABLE const UChar* U_EXPORT2 \nucol_getRules(    const    UCollator    *coll, \n        int32_t            *length);\n\n/** Get the short definition string for a collator. This API harvests the collator's\n *  locale and the attribute set and produces a string that can be used for opening \n *  a collator with the same properties using the ucol_openFromShortString API.\n *  This string will be normalized.\n *  The structure and the syntax of the string is defined in the \"Naming collators\"\n *  section of the users guide: \n *  http://icu-project.org/userguide/Collate_Concepts.html#Naming_Collators\n *  This API supports preflighting.\n *  @param coll a collator\n *  @param locale a locale that will appear as a collators locale in the resulting\n *                short string definition. If NULL, the locale will be harvested \n *                from the collator.\n *  @param buffer space to hold the resulting string\n *  @param capacity capacity of the buffer\n *  @param status for returning errors. All the preflighting errors are featured\n *  @return length of the resulting string\n *  @see ucol_openFromShortString\n *  @see ucol_normalizeShortDefinitionString\n *  @stable ICU 3.0\n */\nU_STABLE int32_t U_EXPORT2\nucol_getShortDefinitionString(const UCollator *coll,\n                              const char *locale,\n                              char *buffer,\n                              int32_t capacity,\n                              UErrorCode *status);\n\n/** Verifies and normalizes short definition string.\n *  Normalized short definition string has all the option sorted by the argument name,\n *  so that equivalent definition strings are the same. \n *  This API supports preflighting.\n *  @param source definition string\n *  @param destination space to hold the resulting string\n *  @param capacity capacity of the buffer\n *  @param parseError if not NULL, structure that will get filled with error's pre\n *                   and post context in case of error.\n *  @param status     Error code. This API will return an error if an invalid attribute \n *                    or attribute/value combination is specified. All the preflighting \n *                    errors are also featured\n *  @return length of the resulting normalized string.\n *\n *  @see ucol_openFromShortString\n *  @see ucol_getShortDefinitionString\n * \n *  @stable ICU 3.0\n */\n\nU_STABLE int32_t U_EXPORT2\nucol_normalizeShortDefinitionString(const char *source,\n                                    char *destination,\n                                    int32_t capacity,\n                                    UParseError *parseError,\n                                    UErrorCode *status);\n\n\n/**\n * Get a sort key for a string from a UCollator.\n * Sort keys may be compared using <TT>strcmp</TT>.\n *\n * Like ICU functions that write to an output buffer, the buffer contents\n * is undefined if the buffer capacity (resultLength parameter) is too small.\n * Unlike ICU functions that write a string to an output buffer,\n * the terminating zero byte is counted in the sort key length.\n * @param coll The UCollator containing the collation rules.\n * @param source The string to transform.\n * @param sourceLength The length of source, or -1 if null-terminated.\n * @param result A pointer to a buffer to receive the attribute.\n * @param resultLength The maximum size of result.\n * @return The size needed to fully store the sort key.\n *      If there was an internal error generating the sort key,\n *      a zero value is returned.\n * @see ucol_keyHashCode\n * @stable ICU 2.0\n */\nU_STABLE int32_t U_EXPORT2 \nucol_getSortKey(const    UCollator    *coll,\n        const    UChar        *source,\n        int32_t        sourceLength,\n        uint8_t        *result,\n        int32_t        resultLength);\n\n\n/** Gets the next count bytes of a sort key. Caller needs\n *  to preserve state array between calls and to provide\n *  the same type of UCharIterator set with the same string.\n *  The destination buffer provided must be big enough to store\n *  the number of requested bytes.\n *\n *  The generated sort key may or may not be compatible with\n *  sort keys generated using ucol_getSortKey().\n *  @param coll The UCollator containing the collation rules.\n *  @param iter UCharIterator containing the string we need \n *              the sort key to be calculated for.\n *  @param state Opaque state of sortkey iteration.\n *  @param dest Buffer to hold the resulting sortkey part\n *  @param count number of sort key bytes required.\n *  @param status error code indicator.\n *  @return the actual number of bytes of a sortkey. It can be\n *          smaller than count if we have reached the end of \n *          the sort key.\n *  @stable ICU 2.6\n */\nU_STABLE int32_t U_EXPORT2 \nucol_nextSortKeyPart(const UCollator *coll,\n                     UCharIterator *iter,\n                     uint32_t state[2],\n                     uint8_t *dest, int32_t count,\n                     UErrorCode *status);\n\n/** enum that is taken by ucol_getBound API \n * See below for explanation                \n * do not change the values assigned to the \n * members of this enum. Underlying code    \n * depends on them having these numbers     \n * @stable ICU 2.0\n */\ntypedef enum {\n  /** lower bound */\n  UCOL_BOUND_LOWER = 0,\n  /** upper bound that will match strings of exact size */\n  UCOL_BOUND_UPPER = 1,\n  /** upper bound that will match all the strings that have the same initial substring as the given string */\n  UCOL_BOUND_UPPER_LONG = 2,\n  UCOL_BOUND_VALUE_COUNT\n} UColBoundMode;\n\n/**\n * Produce a bound for a given sortkey and a number of levels.\n * Return value is always the number of bytes needed, regardless of \n * whether the result buffer was big enough or even valid.<br>\n * Resulting bounds can be used to produce a range of strings that are\n * between upper and lower bounds. For example, if bounds are produced\n * for a sortkey of string \"smith\", strings between upper and lower \n * bounds with one level would include \"Smith\", \"SMITH\", \"sMiTh\".<br>\n * There are two upper bounds that can be produced. If UCOL_BOUND_UPPER\n * is produced, strings matched would be as above. However, if bound\n * produced using UCOL_BOUND_UPPER_LONG is used, the above example will\n * also match \"Smithsonian\" and similar.<br>\n * For more on usage, see example in cintltst/capitst.c in procedure\n * TestBounds.\n * Sort keys may be compared using <TT>strcmp</TT>.\n * @param source The source sortkey.\n * @param sourceLength The length of source, or -1 if null-terminated. \n *                     (If an unmodified sortkey is passed, it is always null \n *                      terminated).\n * @param boundType Type of bound required. It can be UCOL_BOUND_LOWER, which \n *                  produces a lower inclusive bound, UCOL_BOUND_UPPER, that \n *                  produces upper bound that matches strings of the same length \n *                  or UCOL_BOUND_UPPER_LONG that matches strings that have the \n *                  same starting substring as the source string.\n * @param noOfLevels  Number of levels required in the resulting bound (for most \n *                    uses, the recommended value is 1). See users guide for \n *                    explanation on number of levels a sortkey can have.\n * @param result A pointer to a buffer to receive the resulting sortkey.\n * @param resultLength The maximum size of result.\n * @param status Used for returning error code if something went wrong. If the \n *               number of levels requested is higher than the number of levels\n *               in the source key, a warning (U_SORT_KEY_TOO_SHORT_WARNING) is \n *               issued.\n * @return The size needed to fully store the bound. \n * @see ucol_keyHashCode\n * @stable ICU 2.1\n */\nU_STABLE int32_t U_EXPORT2 \nucol_getBound(const uint8_t       *source,\n        int32_t             sourceLength,\n        UColBoundMode       boundType,\n        uint32_t            noOfLevels,\n        uint8_t             *result,\n        int32_t             resultLength,\n        UErrorCode          *status);\n        \n/**\n * Gets the version information for a Collator. Version is currently\n * an opaque 32-bit number which depends, among other things, on major\n * versions of the collator tailoring and UCA.\n * @param coll The UCollator to query.\n * @param info the version # information, the result will be filled in\n * @stable ICU 2.0\n */\nU_STABLE void U_EXPORT2\nucol_getVersion(const UCollator* coll, UVersionInfo info);\n\n/**\n * Gets the UCA version information for a Collator. Version is the\n * UCA version number (3.1.1, 4.0).\n * @param coll The UCollator to query.\n * @param info the version # information, the result will be filled in\n * @stable ICU 2.8\n */\nU_STABLE void U_EXPORT2\nucol_getUCAVersion(const UCollator* coll, UVersionInfo info);\n\n/** \n * Merge two sort keys. The levels are merged with their corresponding counterparts\n * (primaries with primaries, secondaries with secondaries etc.). Between the values\n * from the same level a separator is inserted.\n * example (uncompressed): \n * 191B1D 01 050505 01 910505 00 and 1F2123 01 050505 01 910505 00\n * will be merged as \n * 191B1D 02 1F212301 050505 02 050505 01 910505 02 910505 00\n * This allows for concatenating of first and last names for sorting, among other things.\n * If the destination buffer is not big enough, the results are undefined.\n * If any of source lengths are zero or any of source pointers are NULL/undefined, \n * result is of size zero.\n * @param src1 pointer to the first sortkey\n * @param src1Length length of the first sortkey\n * @param src2 pointer to the second sortkey\n * @param src2Length length of the second sortkey\n * @param dest buffer to hold the result\n * @param destCapacity size of the buffer for the result\n * @return size of the result. If the buffer is big enough size is always\n *         src1Length+src2Length-1\n * @stable ICU 2.0\n */\nU_STABLE int32_t U_EXPORT2 \nucol_mergeSortkeys(const uint8_t *src1, int32_t src1Length,\n                   const uint8_t *src2, int32_t src2Length,\n                   uint8_t *dest, int32_t destCapacity);\n\n/**\n * Universal attribute setter\n * @param coll collator which attributes are to be changed\n * @param attr attribute type \n * @param value attribute value\n * @param status to indicate whether the operation went on smoothly or there were errors\n * @see UColAttribute\n * @see UColAttributeValue\n * @see ucol_getAttribute\n * @stable ICU 2.0\n */\nU_STABLE void U_EXPORT2 \nucol_setAttribute(UCollator *coll, UColAttribute attr, UColAttributeValue value, UErrorCode *status);\n\n/**\n * Universal attribute getter\n * @param coll collator which attributes are to be changed\n * @param attr attribute type\n * @return attribute value\n * @param status to indicate whether the operation went on smoothly or there were errors\n * @see UColAttribute\n * @see UColAttributeValue\n * @see ucol_setAttribute\n * @stable ICU 2.0\n */\nU_STABLE UColAttributeValue  U_EXPORT2 \nucol_getAttribute(const UCollator *coll, UColAttribute attr, UErrorCode *status);\n\n/** Variable top\n * is a two byte primary value which causes all the codepoints with primary values that\n * are less or equal than the variable top to be shifted when alternate handling is set\n * to UCOL_SHIFTED.\n * Sets the variable top to a collation element value of a string supplied. \n * @param coll collator which variable top needs to be changed\n * @param varTop one or more (if contraction) UChars to which the variable top should be set\n * @param len length of variable top string. If -1 it is considered to be zero terminated.\n * @param status error code. If error code is set, the return value is undefined. \n *               Errors set by this function are: <br>\n *    U_CE_NOT_FOUND_ERROR if more than one character was passed and there is no such \n *    a contraction<br>\n *    U_PRIMARY_TOO_LONG_ERROR if the primary for the variable top has more than two bytes\n * @return a 32 bit value containing the value of the variable top in upper 16 bits. \n *         Lower 16 bits are undefined\n * @see ucol_getVariableTop\n * @see ucol_restoreVariableTop\n * @stable ICU 2.0\n */\nU_STABLE uint32_t U_EXPORT2 \nucol_setVariableTop(UCollator *coll, \n                    const UChar *varTop, int32_t len, \n                    UErrorCode *status);\n\n/** \n * Gets the variable top value of a Collator. \n * Lower 16 bits are undefined and should be ignored.\n * @param coll collator which variable top needs to be retrieved\n * @param status error code (not changed by function). If error code is set, \n *               the return value is undefined.\n * @return the variable top value of a Collator.\n * @see ucol_setVariableTop\n * @see ucol_restoreVariableTop\n * @stable ICU 2.0\n */\nU_STABLE uint32_t U_EXPORT2 ucol_getVariableTop(const UCollator *coll, UErrorCode *status);\n\n/** \n * Sets the variable top to a collation element value supplied. Variable top is \n * set to the upper 16 bits. \n * Lower 16 bits are ignored.\n * @param coll collator which variable top needs to be changed\n * @param varTop CE value, as returned by ucol_setVariableTop or ucol)getVariableTop\n * @param status error code (not changed by function)\n * @see ucol_getVariableTop\n * @see ucol_setVariableTop\n * @stable ICU 2.0\n */\nU_STABLE void U_EXPORT2 \nucol_restoreVariableTop(UCollator *coll, const uint32_t varTop, UErrorCode *status);\n\n/**\n * Thread safe cloning operation. The result is a clone of a given collator.\n * @param coll collator to be cloned\n * @param stackBuffer user allocated space for the new clone. \n * If NULL new memory will be allocated. \n *  If buffer is not large enough, new memory will be allocated.\n *  Clients can use the U_COL_SAFECLONE_BUFFERSIZE. \n *  This will probably be enough to avoid memory allocations.\n * @param pBufferSize pointer to size of allocated space. \n *  If *pBufferSize == 0, a sufficient size for use in cloning will \n *  be returned ('pre-flighting')\n *  If *pBufferSize is not enough for a stack-based safe clone, \n *  new memory will be allocated.\n * @param status to indicate whether the operation went on smoothly or there were errors\n *    An informational status value, U_SAFECLONE_ALLOCATED_ERROR, is used if any\n * allocations were necessary.\n * @return pointer to the new clone\n * @see ucol_open\n * @see ucol_openRules\n * @see ucol_close\n * @stable ICU 2.0\n */\nU_STABLE UCollator* U_EXPORT2 \nucol_safeClone(const UCollator *coll,\n               void            *stackBuffer,\n               int32_t         *pBufferSize,\n               UErrorCode      *status);\n\n/** default memory size for the new clone. It needs to be this large for os/400 large pointers \n * @stable ICU 2.0\n */\n#define U_COL_SAFECLONE_BUFFERSIZE 528\n\n/**\n * Returns current rules. Delta defines whether full rules are returned or just the tailoring. \n * Returns number of UChars needed to store rules. If buffer is NULL or bufferLen is not enough \n * to store rules, will store up to available space.\n *\n * ucol_getRules() should normally be used instead.\n * See http://userguide.icu-project.org/collation/customization#TOC-Building-on-Existing-Locales\n * @param coll collator to get the rules from\n * @param delta one of UCOL_TAILORING_ONLY, UCOL_FULL_RULES. \n * @param buffer buffer to store the result in. If NULL, you'll get no rules.\n * @param bufferLen length of buffer to store rules in. If less than needed you'll get only the part that fits in.\n * @return current rules\n * @stable ICU 2.0\n * @see UCOL_FULL_RULES\n */\nU_STABLE int32_t U_EXPORT2 \nucol_getRulesEx(const UCollator *coll, UColRuleOption delta, UChar *buffer, int32_t bufferLen);\n\n#ifndef U_HIDE_DEPRECATED_API\n/**\n * gets the locale name of the collator. If the collator\n * is instantiated from the rules, then this function returns\n * NULL.\n * @param coll The UCollator for which the locale is needed\n * @param type You can choose between requested, valid and actual\n *             locale. For description see the definition of\n *             ULocDataLocaleType in uloc.h\n * @param status error code of the operation\n * @return real locale name from which the collation data comes. \n *         If the collator was instantiated from rules, returns\n *         NULL.\n * @deprecated ICU 2.8 Use ucol_getLocaleByType instead\n */\nU_DEPRECATED const char * U_EXPORT2\nucol_getLocale(const UCollator *coll, ULocDataLocaleType type, UErrorCode *status);\n#endif  /* U_HIDE_DEPRECATED_API */\n\n/**\n * gets the locale name of the collator. If the collator\n * is instantiated from the rules, then this function returns\n * NULL.\n * @param coll The UCollator for which the locale is needed\n * @param type You can choose between requested, valid and actual\n *             locale. For description see the definition of\n *             ULocDataLocaleType in uloc.h\n * @param status error code of the operation\n * @return real locale name from which the collation data comes. \n *         If the collator was instantiated from rules, returns\n *         NULL.\n * @stable ICU 2.8\n */\nU_STABLE const char * U_EXPORT2\nucol_getLocaleByType(const UCollator *coll, ULocDataLocaleType type, UErrorCode *status);\n\n/**\n * Get an Unicode set that contains all the characters and sequences tailored in \n * this collator. The result must be disposed of by using uset_close.\n * @param coll        The UCollator for which we want to get tailored chars\n * @param status      error code of the operation\n * @return a pointer to newly created USet. Must be be disposed by using uset_close\n * @see ucol_openRules\n * @see uset_close\n * @stable ICU 2.4\n */\nU_STABLE USet * U_EXPORT2\nucol_getTailoredSet(const UCollator *coll, UErrorCode *status);\n\n#ifndef U_HIDE_INTERNAL_API\n/**\n * Universal attribute getter that returns UCOL_DEFAULT if the value is default\n * @param coll collator which attributes are to be changed\n * @param attr attribute type\n * @return attribute value or UCOL_DEFAULT if the value is default\n * @param status to indicate whether the operation went on smoothly or there were errors\n * @see UColAttribute\n * @see UColAttributeValue\n * @see ucol_setAttribute\n * @internal ICU 3.0\n */\nU_INTERNAL UColAttributeValue  U_EXPORT2\nucol_getAttributeOrDefault(const UCollator *coll, UColAttribute attr, UErrorCode *status);\n\n/** Check whether two collators are equal. Collators are considered equal if they\n *  will sort strings the same. This means that both the current attributes and the\n *  rules must be equivalent. Currently used for RuleBasedCollator::operator==.\n *  @param source first collator\n *  @param target second collator\n *  @return TRUE or FALSE\n *  @internal ICU 3.0\n */\nU_INTERNAL UBool U_EXPORT2\nucol_equals(const UCollator *source, const UCollator *target);\n\n/** Calculates the set of unsafe code points, given a collator.\n *   A character is unsafe if you could append any character and cause the ordering to alter significantly.\n *   Collation sorts in normalized order, so anything that rearranges in normalization can cause this.\n *   Thus if you have a character like a_umlaut, and you add a lower_dot to it,\n *   then it normalizes to a_lower_dot + umlaut, and sorts differently.\n *  @param coll Collator\n *  @param unsafe a fill-in set to receive the unsafe points\n *  @param status for catching errors\n *  @return number of elements in the set\n *  @internal ICU 3.0\n */\nU_INTERNAL int32_t U_EXPORT2\nucol_getUnsafeSet( const UCollator *coll,\n                  USet *unsafe,\n                  UErrorCode *status);\n\n/** Reset UCA's static pointers. You don't want to use this, unless your static memory can go away.\n * @internal ICU 3.2.1\n */\nU_INTERNAL void U_EXPORT2\nucol_forgetUCA(void);\n\n/** Touches all resources needed for instantiating a collator from a short string definition,\n *  thus filling up the cache.\n * @param definition A short string containing a locale and a set of attributes. \n *                   Attributes not explicitly mentioned are left at the default\n *                   state for a locale.\n * @param parseError if not NULL, structure that will get filled with error's pre\n *                   and post context in case of error.\n * @param forceDefaults if FALSE, the settings that are the same as the collator \n *                   default settings will not be applied (for example, setting\n *                   French secondary on a French collator would not be executed). \n *                   If TRUE, all the settings will be applied regardless of the \n *                   collator default value. If the definition\n *                   strings are to be cached, should be set to FALSE.\n * @param status     Error code. Apart from regular error conditions connected to \n *                   instantiating collators (like out of memory or similar), this\n *                   API will return an error if an invalid attribute or attribute/value\n *                   combination is specified.\n * @see ucol_openFromShortString\n * @internal ICU 3.2.1\n */\nU_INTERNAL void U_EXPORT2\nucol_prepareShortStringOpen( const char *definition,\n                          UBool forceDefaults,\n                          UParseError *parseError,\n                          UErrorCode *status);\n#endif  /* U_HIDE_INTERNAL_API */\n\n/** Creates a binary image of a collator. This binary image can be stored and \n *  later used to instantiate a collator using ucol_openBinary.\n *  This API supports preflighting.\n *  @param coll Collator\n *  @param buffer a fill-in buffer to receive the binary image\n *  @param capacity capacity of the destination buffer\n *  @param status for catching errors\n *  @return size of the image\n *  @see ucol_openBinary\n *  @stable ICU 3.2\n */\nU_STABLE int32_t U_EXPORT2\nucol_cloneBinary(const UCollator *coll,\n                 uint8_t *buffer, int32_t capacity,\n                 UErrorCode *status);\n\n/** Opens a collator from a collator binary image created using\n *  ucol_cloneBinary. Binary image used in instantiation of the \n *  collator remains owned by the user and should stay around for \n *  the lifetime of the collator. The API also takes a base collator\n *  which usualy should be UCA.\n *  @param bin binary image owned by the user and required through the\n *             lifetime of the collator\n *  @param length size of the image. If negative, the API will try to\n *                figure out the length of the image\n *  @param base fallback collator, usually UCA. Base is required to be\n *              present through the lifetime of the collator. Currently \n *              it cannot be NULL.\n *  @param status for catching errors\n *  @return newly created collator\n *  @see ucol_cloneBinary\n *  @stable ICU 3.2\n */\nU_STABLE UCollator* U_EXPORT2\nucol_openBinary(const uint8_t *bin, int32_t length, \n                const UCollator *base, \n                UErrorCode *status);\n\n\n#endif /* #if !UCONFIG_NO_COLLATION */\n\n#endif\n"
  },
  {
    "path": "deprecated/android/addons/icucompat/unicode/ucoleitr.h",
    "content": "/*\n*******************************************************************************\n*   Copyright (C) 2001-2011, International Business Machines\n*   Corporation and others.  All Rights Reserved.\n*******************************************************************************\n*\n* File ucoleitr.cpp\n*\n* Modification History:\n*\n* Date        Name        Description\n* 02/15/2001  synwee      Modified all methods to process its own function \n*                         instead of calling the equivalent c++ api (coleitr.h)\n*******************************************************************************/\n\n#ifndef UCOLEITR_H\n#define UCOLEITR_H\n\n#include \"unicode/utypes.h\"\n\n#if !UCONFIG_NO_COLLATION\n\n/**  \n * This indicates an error has occured during processing or if no more CEs is \n * to be returned.\n * @stable ICU 2.0\n */\n#define UCOL_NULLORDER        ((int32_t)0xFFFFFFFF)\n\n#ifndef U_HIDE_INTERNAL_API\n/**\n * This indicates an error has occured during processing or there are no more CEs \n * to be returned.\n *\n * @internal\n */\n#define UCOL_PROCESSED_NULLORDER        ((int64_t)U_INT64_MAX)\n#endif  /* U_HIDE_INTERNAL_API */\n\n#include \"unicode/ucol.h\"\n\n/** \n * The UCollationElements struct.\n * For usage in C programs.\n * @stable ICU 2.0\n */\ntypedef struct UCollationElements UCollationElements;\n\n/**\n * \\file\n * \\brief C API: UCollationElements\n *\n * The UCollationElements API is used as an iterator to walk through each \n * character of an international string. Use the iterator to return the\n * ordering priority of the positioned character. The ordering priority of a \n * character, which we refer to as a key, defines how a character is collated \n * in the given collation object.\n * For example, consider the following in Spanish:\n * <pre>\n * .       \"ca\" -> the first key is key('c') and second key is key('a').\n * .       \"cha\" -> the first key is key('ch') and second key is key('a').\n * </pre>\n * And in German,\n * <pre>\n * .       \"<ae ligature>b\"-> the first key is key('a'), the second key is key('e'), and\n * .       the third key is key('b').\n * </pre>\n * <p>Example of the iterator usage: (without error checking)\n * <pre>\n * .  void CollationElementIterator_Example()\n * .  {\n * .      UChar *s;\n * .      t_int32 order, primaryOrder;\n * .      UCollationElements *c;\n * .      UCollatorOld *coll;\n * .      UErrorCode success = U_ZERO_ERROR;\n * .      s=(UChar*)malloc(sizeof(UChar) * (strlen(\"This is a test\")+1) );\n * .      u_uastrcpy(s, \"This is a test\");\n * .      coll = ucol_open(NULL, &success);\n * .      c = ucol_openElements(coll, str, u_strlen(str), &status);\n * .      order = ucol_next(c, &success);\n * .      ucol_reset(c);\n * .      order = ucol_prev(c, &success);\n * .      free(s);\n * .      ucol_close(coll);\n * .      ucol_closeElements(c);\n * .  }\n * </pre>\n * <p>\n * ucol_next() returns the collation order of the next.\n * ucol_prev() returns the collation order of the previous character.\n * The Collation Element Iterator moves only in one direction between calls to\n * ucol_reset. That is, ucol_next() and ucol_prev can not be inter-used. \n * Whenever ucol_prev is to be called after ucol_next() or vice versa, \n * ucol_reset has to be called first to reset the status, shifting pointers to \n * either the end or the start of the string. Hence at the next call of \n * ucol_prev or ucol_next, the first or last collation order will be returned. \n * If a change of direction is done without a ucol_reset, the result is \n * undefined.\n * The result of a forward iterate (ucol_next) and reversed result of the  \n * backward iterate (ucol_prev) on the same string are equivalent, if \n * collation orders with the value UCOL_IGNORABLE are ignored.\n * Character based on the comparison level of the collator.  A collation order \n * consists of primary order, secondary order and tertiary order.  The data \n * type of the collation order is <strong>t_int32</strong>. \n *\n * @see UCollator\n */\n\n/**\n * Open the collation elements for a string.\n *\n * @param coll The collator containing the desired collation rules.\n * @param text The text to iterate over.\n * @param textLength The number of characters in text, or -1 if null-terminated\n * @param status A pointer to an UErrorCode to receive any errors.\n * @return a struct containing collation element information\n * @stable ICU 2.0\n */\nU_STABLE UCollationElements* U_EXPORT2 \nucol_openElements(const UCollator  *coll,\n                  const UChar      *text,\n                        int32_t    textLength,\n                        UErrorCode *status);\n\n\n/**\n * get a hash code for a key... Not very useful!\n * @param key    the given key.\n * @param length the size of the key array.\n * @return       the hash code.\n * @stable ICU 2.0\n */\nU_STABLE int32_t U_EXPORT2 \nucol_keyHashCode(const uint8_t* key, int32_t length);\n\n/**\n * Close a UCollationElements.\n * Once closed, a UCollationElements may no longer be used.\n * @param elems The UCollationElements to close.\n * @stable ICU 2.0\n */\nU_STABLE void U_EXPORT2 \nucol_closeElements(UCollationElements *elems);\n\n/**\n * Reset the collation elements to their initial state.\n * This will move the 'cursor' to the beginning of the text.\n * Property settings for collation will be reset to the current status.\n * @param elems The UCollationElements to reset.\n * @see ucol_next\n * @see ucol_previous\n * @stable ICU 2.0\n */\nU_STABLE void U_EXPORT2 \nucol_reset(UCollationElements *elems);\n\n#ifndef U_HIDE_INTERNAL_API\n/**\n * Set the collation elements to use implicit ordering for Han\n * even if they've been tailored. This will also force Hangul\n * syllables to be ordered by decomposing them to their component\n * Jamo.\n *\n * @param elems The UCollationElements containing the text.\n * @param status A pointer to a UErrorCode to reveive any errors.\n *\n * @internal\n */\nU_INTERNAL void U_EXPORT2\nucol_forceHanImplicit(UCollationElements *elems, UErrorCode *status);\n#endif  /* U_HIDE_INTERNAL_API */\n\n/**\n * Get the ordering priority of the next collation element in the text.\n * A single character may contain more than one collation element.\n * @param elems The UCollationElements containing the text.\n * @param status A pointer to an UErrorCode to receive any errors.\n * @return The next collation elements ordering, otherwise returns NULLORDER \n *         if an error has occured or if the end of string has been reached\n * @stable ICU 2.0\n */\nU_STABLE int32_t U_EXPORT2 \nucol_next(UCollationElements *elems, UErrorCode *status);\n\n/**\n * Get the ordering priority of the previous collation element in the text.\n * A single character may contain more than one collation element.\n * Note that internally a stack is used to store buffered collation elements. \n * It is very rare that the stack will overflow, however if such a case is \n * encountered, the problem can be solved by increasing the size \n * UCOL_EXPAND_CE_BUFFER_SIZE in ucol_imp.h.\n * @param elems The UCollationElements containing the text.\n * @param status A pointer to an UErrorCode to receive any errors. Noteably \n *               a U_BUFFER_OVERFLOW_ERROR is returned if the internal stack\n *               buffer has been exhausted.\n * @return The previous collation elements ordering, otherwise returns \n *         NULLORDER if an error has occured or if the start of string has \n *         been reached.\n * @stable ICU 2.0\n */\nU_STABLE int32_t U_EXPORT2 \nucol_previous(UCollationElements *elems, UErrorCode *status);\n\n#ifndef U_HIDE_INTERNAL_API\n/**\n * Get the processed ordering priority of the next collation element in the text.\n * A single character may contain more than one collation element.\n *\n * @param elems The UCollationElements containing the text.\n * @param ixLow a pointer to an int32_t to receive the iterator index before fetching the CE.\n * @param ixHigh a pointer to an int32_t to receive the iterator index after fetching the CE.\n * @param status A pointer to an UErrorCode to receive any errors.\n * @return The next collation elements ordering, otherwise returns UCOL_PROCESSED_NULLORDER \n *         if an error has occured or if the end of string has been reached\n *\n * @internal\n */\nU_INTERNAL int64_t U_EXPORT2\nucol_nextProcessed(UCollationElements *elems, int32_t *ixLow, int32_t *ixHigh, UErrorCode *status);\n\n/**\n * Get the processed ordering priority of the previous collation element in the text.\n * A single character may contain more than one collation element.\n * Note that internally a stack is used to store buffered collation elements. \n * It is very rare that the stack will overflow, however if such a case is \n * encountered, the problem can be solved by increasing the size \n * UCOL_EXPAND_CE_BUFFER_SIZE in ucol_imp.h.\n *\n * @param elems The UCollationElements containing the text.\n * @param ixLow A pointer to an int32_t to receive the iterator index after fetching the CE\n * @param ixHigh A pointer to an int32_t to receiver the iterator index before fetching the CE\n * @param status A pointer to an UErrorCode to receive any errors. Noteably \n *               a U_BUFFER_OVERFLOW_ERROR is returned if the internal stack\n *               buffer has been exhausted.\n * @return The previous collation elements ordering, otherwise returns \n *         UCOL_PROCESSED_NULLORDER if an error has occured or if the start of\n *         string has been reached.\n *\n * @internal\n */\nU_INTERNAL int64_t U_EXPORT2\nucol_previousProcessed(UCollationElements *elems, int32_t *ixLow, int32_t *ixHigh, UErrorCode *status);\n#endif  /* U_HIDE_INTERNAL_API */\n\n/**\n * Get the maximum length of any expansion sequences that end with the \n * specified comparison order.\n * This is useful for .... ?\n * @param elems The UCollationElements containing the text.\n * @param order A collation order returned by previous or next.\n * @return maximum size of the expansion sequences ending with the collation \n *         element or 1 if collation element does not occur at the end of any \n *         expansion sequence\n * @stable ICU 2.0\n */\nU_STABLE int32_t U_EXPORT2 \nucol_getMaxExpansion(const UCollationElements *elems, int32_t order);\n\n/**\n * Set the text containing the collation elements.\n * Property settings for collation will remain the same.\n * In order to reset the iterator to the current collation property settings,\n * the API reset() has to be called.\n * @param elems The UCollationElements to set.\n * @param text The source text containing the collation elements.\n * @param textLength The length of text, or -1 if null-terminated.\n * @param status A pointer to an UErrorCode to receive any errors.\n * @see ucol_getText\n * @stable ICU 2.0\n */\nU_STABLE void U_EXPORT2 \nucol_setText(      UCollationElements *elems, \n             const UChar              *text,\n                   int32_t            textLength,\n                   UErrorCode         *status);\n\n/**\n * Get the offset of the current source character.\n * This is an offset into the text of the character containing the current\n * collation elements.\n * @param elems The UCollationElements to query.\n * @return The offset of the current source character.\n * @see ucol_setOffset\n * @stable ICU 2.0\n */\nU_STABLE int32_t U_EXPORT2 \nucol_getOffset(const UCollationElements *elems);\n\n/**\n * Set the offset of the current source character.\n * This is an offset into the text of the character to be processed.\n * Property settings for collation will remain the same.\n * In order to reset the iterator to the current collation property settings,\n * the API reset() has to be called.\n * @param elems The UCollationElements to set.\n * @param offset The desired character offset.\n * @param status A pointer to an UErrorCode to receive any errors.\n * @see ucol_getOffset\n * @stable ICU 2.0\n */\nU_STABLE void U_EXPORT2 \nucol_setOffset(UCollationElements *elems,\n               int32_t        offset,\n               UErrorCode         *status);\n\n/**\n* Get the primary order of a collation order.\n* @param order the collation order\n* @return the primary order of a collation order.\n* @stable ICU 2.6\n*/\nU_STABLE int32_t U_EXPORT2\nucol_primaryOrder (int32_t order); \n\n/**\n* Get the secondary order of a collation order.\n* @param order the collation order\n* @return the secondary order of a collation order.\n* @stable ICU 2.6\n*/\nU_STABLE int32_t U_EXPORT2\nucol_secondaryOrder (int32_t order); \n\n/**\n* Get the tertiary order of a collation order.\n* @param order the collation order\n* @return the tertiary order of a collation order.\n* @stable ICU 2.6\n*/\nU_STABLE int32_t U_EXPORT2\nucol_tertiaryOrder (int32_t order); \n\n#endif /* #if !UCONFIG_NO_COLLATION */\n\n#endif\n"
  },
  {
    "path": "deprecated/android/addons/icucompat/unicode/uconfig.h",
    "content": "/*  \n**********************************************************************\n*   Copyright (C) 2002-2012, International Business Machines\n*   Corporation and others.  All Rights Reserved.\n**********************************************************************\n*   file name:  uconfig.h\n*   encoding:   US-ASCII\n*   tab size:   8 (not used)\n*   indentation:4\n*\n*   created on: 2002sep19\n*   created by: Markus W. Scherer\n*/\n\n#ifndef __UCONFIG_H__\n#define __UCONFIG_H__\n\n\n/*!\n * \\file\n * \\brief User-configurable settings\n *\n * Miscellaneous switches:\n *\n * A number of macros affect a variety of minor aspects of ICU.\n * Most of them used to be defined elsewhere (e.g., in utypes.h or platform.h)\n * and moved here to make them easier to find.\n *\n * Switches for excluding parts of ICU library code modules:\n *\n * Changing these macros allows building partial, smaller libraries for special purposes.\n * By default, all modules are built.\n * The switches are fairly coarse, controlling large modules.\n * Basic services cannot be turned off.\n *\n * Building with any of these options does not guarantee that the\n * ICU build process will completely work. It is recommended that\n * the ICU libraries and data be built using the normal build.\n * At that time you should remove the data used by those services.\n * After building the ICU data library, you should rebuild the ICU\n * libraries with these switches customized to your needs.\n *\n * @stable ICU 2.4\n */\n\n/**\n * If this switch is defined, ICU will attempt to load a header file named \"uconfig_local.h\"\n * prior to determining default settings for uconfig variables.\n *\n * @internal ICU 4.0\n */\n#if defined(UCONFIG_USE_LOCAL)\n#include \"uconfig_local.h\"\n#endif\n\n/**\n * \\def U_DEBUG\n * Determines whether to include debugging code.\n * Automatically set on Windows, but most compilers do not have\n * related predefined macros.\n * @internal\n */\n#ifdef U_DEBUG\n    /* Use the predefined value. */\n#elif defined(_DEBUG)\n    /*\n     * _DEBUG is defined by Visual Studio debug compilation.\n     * Do *not* test for its NDEBUG macro: It is an orthogonal macro\n     * which disables assert().\n     */\n#   define U_DEBUG 1\n# else\n#   define U_DEBUG 0\n#endif\n\n/**\n * Determines wheter to enable auto cleanup of libraries. \n * @internal\n */\n#ifndef UCLN_NO_AUTO_CLEANUP\n#define UCLN_NO_AUTO_CLEANUP 1\n#endif\n\n/**\n * \\def U_DISABLE_RENAMING\n * Determines whether to disable renaming or not.\n * @internal\n */\n#ifndef U_DISABLE_RENAMING\n#define U_DISABLE_RENAMING 0\n#endif\n\n/**\n * \\def U_NO_DEFAULT_INCLUDE_UTF_HEADERS\n * Determines whether utypes.h includes utf.h, utf8.h, utf16.h and utf_old.h.\n * utypes.h includes those headers if this macro is defined to 0.\n * Otherwise, each those headers must be included explicitly when using one of their macros.\n * Defaults to 0 for backward compatibility, except inside ICU.\n * @draft ICU 49\n */\n#ifdef U_NO_DEFAULT_INCLUDE_UTF_HEADERS\n    /* Use the predefined value. */\n#elif defined(U_COMBINED_IMPLEMENTATION) || defined(U_COMMON_IMPLEMENTATION) || defined(U_I18N_IMPLEMENTATION) || \\\n      defined(U_IO_IMPLEMENTATION) || defined(U_LAYOUT_IMPLEMENTATION) || defined(U_LAYOUTEX_IMPLEMENTATION) || \\\n      defined(U_TOOLUTIL_IMPLEMENTATION)\n#   define U_NO_DEFAULT_INCLUDE_UTF_HEADERS 1\n#else\n#   define U_NO_DEFAULT_INCLUDE_UTF_HEADERS 0\n#endif\n\n/**\n * \\def U_OVERRIDE_CXX_ALLOCATION\n * Determines whether to override new and delete.\n * ICU is normally built such that all of its C++ classes, via their UMemory base,\n * override operators new and delete to use its internal, customizable,\n * non-exception-throwing memory allocation functions. (Default value 1 for this macro.)\n *\n * This is especially important when the application and its libraries use multiple heaps.\n * For example, on Windows, this allows the ICU DLL to be used by\n * applications that statically link the C Runtime library.\n *\n * @stable ICU 2.2\n */\n#ifndef U_OVERRIDE_CXX_ALLOCATION\n#define U_OVERRIDE_CXX_ALLOCATION 1\n#endif\n\n/**\n * \\def U_ENABLE_TRACING\n * Determines whether to enable tracing.\n * @internal\n */\n#ifndef U_ENABLE_TRACING\n#define U_ENABLE_TRACING 0\n#endif\n\n/**\n * \\def U_ENABLE_DYLOAD\n * Whether to enable Dynamic loading in ICU.\n * @internal\n */\n#ifndef U_ENABLE_DYLOAD\n#define U_ENABLE_DYLOAD 1\n#endif\n\n/**\n * \\def U_CHECK_DYLOAD\n * Whether to test Dynamic loading as an OS capability.\n * @internal\n */\n#ifndef U_CHECK_DYLOAD\n#define U_CHECK_DYLOAD 1\n#endif\n\n\n/**\n * \\def U_DEFAULT_SHOW_DRAFT\n * Do we allow ICU users to use the draft APIs by default?\n * @internal\n */\n#ifndef U_DEFAULT_SHOW_DRAFT\n#define U_DEFAULT_SHOW_DRAFT 1\n#endif\n\n/*===========================================================================*/\n/* Custom icu entry point renaming                                           */\n/*===========================================================================*/\n\n/**\n * \\def U_HAVE_LIB_SUFFIX\n * 1 if a custom library suffix is set.\n * @internal\n */\n#ifdef U_HAVE_LIB_SUFFIX\n    /* Use the predefined value. */\n#elif defined(U_LIB_SUFFIX_C_NAME)\n#   define U_HAVE_LIB_SUFFIX 1\n#endif\n\n/**\n * \\def U_LIB_SUFFIX_C_NAME_STRING\n * Defines the library suffix as a string with C syntax.\n * @internal\n */\n#ifdef U_LIB_SUFFIX_C_NAME_STRING\n    /* Use the predefined value. */\n#elif defined(U_LIB_SUFFIX_C_NAME)\n#   define U_LIB_SUFFIX_C_NAME_STRING #U_LIB_SUFFIX_C_NAME\n#else\n#   define U_LIB_SUFFIX_C_NAME_STRING \"\"\n#endif\n\n/* common/i18n library switches --------------------------------------------- */\n\n/**\n * \\def UCONFIG_ONLY_COLLATION\n * This switch turns off modules that are not needed for collation.\n *\n * It does not turn off legacy conversion because that is necessary\n * for ICU to work on EBCDIC platforms (for the default converter).\n * If you want \"only collation\" and do not build for EBCDIC,\n * then you can define UCONFIG_NO_LEGACY_CONVERSION 1 as well.\n *\n * @stable ICU 2.4\n */\n#ifndef UCONFIG_ONLY_COLLATION\n#   define UCONFIG_ONLY_COLLATION 0\n#endif\n\n#if UCONFIG_ONLY_COLLATION\n    /* common library */\n#   define UCONFIG_NO_BREAK_ITERATION 1\n#   define UCONFIG_NO_IDNA 1\n\n    /* i18n library */\n#   if UCONFIG_NO_COLLATION\n#       error Contradictory collation switches in uconfig.h.\n#   endif\n#   define UCONFIG_NO_FORMATTING 1\n#   define UCONFIG_NO_TRANSLITERATION 1\n#   define UCONFIG_NO_REGULAR_EXPRESSIONS 1\n#endif\n\n/* common library switches -------------------------------------------------- */\n\n/**\n * \\def UCONFIG_NO_FILE_IO\n * This switch turns off all file access in the common library\n * where file access is only used for data loading.\n * ICU data must then be provided in the form of a data DLL (or with an\n * equivalent way to link to the data residing in an executable,\n * as in building a combined library with both the common library's code and\n * the data), or via udata_setCommonData().\n * Application data must be provided via udata_setAppData() or by using\n * \"open\" functions that take pointers to data, for example ucol_openBinary().\n *\n * File access is not used at all in the i18n library.\n *\n * File access cannot be turned off for the icuio library or for the ICU\n * test suites and ICU tools.\n *\n * @stable ICU 3.6\n */\n#ifndef UCONFIG_NO_FILE_IO\n#   define UCONFIG_NO_FILE_IO 0\n#endif\n\n/**\n * \\def UCONFIG_NO_CONVERSION\n * ICU will not completely build with this switch turned on.\n * This switch turns off all converters.\n *\n * You may want to use this together with U_CHARSET_IS_UTF8 defined to 1\n * in utypes.h if char* strings in your environment are always in UTF-8.\n *\n * @stable ICU 3.2\n * @see U_CHARSET_IS_UTF8\n */\n#ifndef UCONFIG_NO_CONVERSION\n#   define UCONFIG_NO_CONVERSION 0\n#endif\n\n#if UCONFIG_NO_CONVERSION\n#   define UCONFIG_NO_LEGACY_CONVERSION 1\n#endif\n\n/**\n * \\def UCONFIG_NO_LEGACY_CONVERSION\n * This switch turns off all converters except for\n * - Unicode charsets (UTF-7/8/16/32, CESU-8, SCSU, BOCU-1)\n * - US-ASCII\n * - ISO-8859-1\n *\n * Turning off legacy conversion is not possible on EBCDIC platforms\n * because they need ibm-37 or ibm-1047 default converters.\n *\n * @stable ICU 2.4\n */\n#ifndef UCONFIG_NO_LEGACY_CONVERSION\n#   define UCONFIG_NO_LEGACY_CONVERSION 0\n#endif\n\n/**\n * \\def UCONFIG_NO_NORMALIZATION\n * This switch turns off normalization.\n * It implies turning off several other services as well, for example\n * collation and IDNA.\n *\n * @stable ICU 2.6\n */\n#ifndef UCONFIG_NO_NORMALIZATION\n#   define UCONFIG_NO_NORMALIZATION 0\n#elif UCONFIG_NO_NORMALIZATION\n    /* common library */\n    /* ICU 50 CJK dictionary BreakIterator uses normalization */\n#   define UCONFIG_NO_BREAK_ITERATION 1\n    /* IDNA (UTS #46) is implemented via normalization */\n#   define UCONFIG_NO_IDNA 1\n\n    /* i18n library */\n#   if UCONFIG_ONLY_COLLATION\n#       error Contradictory collation switches in uconfig.h.\n#   endif\n#   define UCONFIG_NO_COLLATION 1\n#   define UCONFIG_NO_TRANSLITERATION 1\n#endif\n\n/**\n * \\def UCONFIG_NO_BREAK_ITERATION\n * This switch turns off break iteration.\n *\n * @stable ICU 2.4\n */\n#ifndef UCONFIG_NO_BREAK_ITERATION\n#   define UCONFIG_NO_BREAK_ITERATION 0\n#endif\n\n/**\n * \\def UCONFIG_NO_IDNA\n * This switch turns off IDNA.\n *\n * @stable ICU 2.6\n */\n#ifndef UCONFIG_NO_IDNA\n#   define UCONFIG_NO_IDNA 0\n#endif\n\n/**\n * \\def UCONFIG_MSGPAT_DEFAULT_APOSTROPHE_MODE\n * Determines the default UMessagePatternApostropheMode.\n * See the documentation for that enum.\n *\n * @stable ICU 4.8\n */\n#ifndef UCONFIG_MSGPAT_DEFAULT_APOSTROPHE_MODE\n#   define UCONFIG_MSGPAT_DEFAULT_APOSTROPHE_MODE UMSGPAT_APOS_DOUBLE_OPTIONAL\n#endif\n\n/* i18n library switches ---------------------------------------------------- */\n\n/**\n * \\def UCONFIG_NO_COLLATION\n * This switch turns off collation and collation-based string search.\n *\n * @stable ICU 2.4\n */\n#ifndef UCONFIG_NO_COLLATION\n#   define UCONFIG_NO_COLLATION 0\n#endif\n\n/**\n * \\def UCONFIG_NO_FORMATTING\n * This switch turns off formatting and calendar/timezone services.\n *\n * @stable ICU 2.4\n */\n#ifndef UCONFIG_NO_FORMATTING\n#   define UCONFIG_NO_FORMATTING 0\n#endif\n\n/**\n * \\def UCONFIG_NO_TRANSLITERATION\n * This switch turns off transliteration.\n *\n * @stable ICU 2.4\n */\n#ifndef UCONFIG_NO_TRANSLITERATION\n#   define UCONFIG_NO_TRANSLITERATION 0\n#endif\n\n/**\n * \\def UCONFIG_NO_REGULAR_EXPRESSIONS\n * This switch turns off regular expressions.\n *\n * @stable ICU 2.4\n */\n#ifndef UCONFIG_NO_REGULAR_EXPRESSIONS\n#   define UCONFIG_NO_REGULAR_EXPRESSIONS 0\n#endif\n\n/**\n * \\def UCONFIG_NO_SERVICE\n * This switch turns off service registration.\n *\n * @stable ICU 3.2\n */\n#ifndef UCONFIG_NO_SERVICE\n#   define UCONFIG_NO_SERVICE 0\n#endif\n\n/**\n * \\def UCONFIG_HAVE_PARSEALLINPUT\n * This switch turns on the \"parse all input\" attribute. Binary incompatible.\n *\n * @internal\n */\n#ifndef UCONFIG_HAVE_PARSEALLINPUT\n#   define UCONFIG_HAVE_PARSEALLINPUT 1\n#endif\n\n\n/**\n * \\def UCONFIG_FORMAT_FASTPATHS_49\n * This switch turns on other formatting fastpaths. Binary incompatible in object DecimalFormat and DecimalFormatSymbols\n *\n * @internal\n */\n#ifndef UCONFIG_FORMAT_FASTPATHS_49\n#   define UCONFIG_FORMAT_FASTPATHS_49 1\n#endif\n\n#endif\n"
  },
  {
    "path": "deprecated/android/addons/icucompat/unicode/ucsdet.h",
    "content": "/*\n **********************************************************************\n *   Copyright (C) 2005-2010, International Business Machines\n *   Corporation and others.  All Rights Reserved.\n **********************************************************************\n *   file name:  ucsdet.h\n *   encoding:   US-ASCII\n *   indentation:4\n *\n *   created on: 2005Aug04\n *   created by: Andy Heninger\n *\n *   ICU Character Set Detection, API for C\n *\n *   Draft version 18 Oct 2005\n *\n */\n\n#ifndef __UCSDET_H\n#define __UCSDET_H\n\n#include \"unicode/utypes.h\"\n\n#if !UCONFIG_NO_CONVERSION\n\n#include \"unicode/localpointer.h\"\n#include \"unicode/uenum.h\"\n\n/**\n * \\file \n * \\brief C API: Charset Detection API\n *\n * This API provides a facility for detecting the\n * charset or encoding of character data in an unknown text format.\n * The input data can be from an array of bytes.\n * <p>\n * Character set detection is at best an imprecise operation.  The detection\n * process will attempt to identify the charset that best matches the characteristics\n * of the byte data, but the process is partly statistical in nature, and\n * the results can not be guaranteed to always be correct.\n * <p>\n * For best accuracy in charset detection, the input data should be primarily\n * in a single language, and a minimum of a few hundred bytes worth of plain text\n * in the language are needed.  The detection process will attempt to\n * ignore html or xml style markup that could otherwise obscure the content.\n */\n \n\nstruct UCharsetDetector;\n/**\n  * Structure representing a charset detector\n  * @stable ICU 3.6\n  */\ntypedef struct UCharsetDetector UCharsetDetector;\n\nstruct UCharsetMatch;\n/**\n  *  Opaque structure representing a match that was identified\n  *  from a charset detection operation.\n  *  @stable ICU 3.6\n  */\ntypedef struct UCharsetMatch UCharsetMatch;\n\n/**\n  *  Open a charset detector.\n  *\n  *  @param status Any error conditions occurring during the open\n  *                operation are reported back in this variable.\n  *  @return the newly opened charset detector.\n  *  @stable ICU 3.6\n  */\nU_STABLE UCharsetDetector * U_EXPORT2\nucsdet_open(UErrorCode   *status);\n\n/**\n  * Close a charset detector.  All storage and any other resources\n  *   owned by this charset detector will be released.  Failure to\n  *   close a charset detector when finished with it can result in\n  *   memory leaks in the application.\n  *\n  *  @param ucsd  The charset detector to be closed.\n  *  @stable ICU 3.6\n  */\nU_STABLE void U_EXPORT2\nucsdet_close(UCharsetDetector *ucsd);\n\n#if U_SHOW_CPLUSPLUS_API\n\nU_NAMESPACE_BEGIN\n\n/**\n * \\class LocalUCharsetDetectorPointer\n * \"Smart pointer\" class, closes a UCharsetDetector via ucsdet_close().\n * For most methods see the LocalPointerBase base class.\n *\n * @see LocalPointerBase\n * @see LocalPointer\n * @stable ICU 4.4\n */\nU_DEFINE_LOCAL_OPEN_POINTER(LocalUCharsetDetectorPointer, UCharsetDetector, ucsdet_close);\n\nU_NAMESPACE_END\n\n#endif\n\n/**\n  * Set the input byte data whose charset is to detected.\n  *\n  * Ownership of the input  text byte array remains with the caller.\n  * The input string must not be altered or deleted until the charset\n  * detector is either closed or reset to refer to different input text.\n  *\n  * @param ucsd   the charset detector to be used.\n  * @param textIn the input text of unknown encoding.   .\n  * @param len    the length of the input text, or -1 if the text\n  *               is NUL terminated.\n  * @param status any error conditions are reported back in this variable.\n  *\n  * @stable ICU 3.6\n  */\nU_STABLE void U_EXPORT2\nucsdet_setText(UCharsetDetector *ucsd, const char *textIn, int32_t len, UErrorCode *status);\n\n\n/** Set the declared encoding for charset detection.\n *  The declared encoding of an input text is an encoding obtained\n *  by the user from an http header or xml declaration or similar source that\n *  can be provided as an additional hint to the charset detector.\n *\n *  How and whether the declared encoding will be used during the\n *  detection process is TBD.\n *\n * @param ucsd      the charset detector to be used.\n * @param encoding  an encoding for the current data obtained from\n *                  a header or declaration or other source outside\n *                  of the byte data itself.\n * @param length    the length of the encoding name, or -1 if the name string\n *                  is NUL terminated.\n * @param status    any error conditions are reported back in this variable.\n *\n * @stable ICU 3.6\n */\nU_STABLE void U_EXPORT2\nucsdet_setDeclaredEncoding(UCharsetDetector *ucsd, const char *encoding, int32_t length, UErrorCode *status);\n\n\n/**\n * Return the charset that best matches the supplied input data.\n * \n * Note though, that because the detection \n * only looks at the start of the input data,\n * there is a possibility that the returned charset will fail to handle\n * the full set of input data.\n * <p>\n * The returned UCharsetMatch object is owned by the UCharsetDetector.\n * It will remain valid until the detector input is reset, or until\n * the detector is closed.\n * <p>\n * The function will fail if\n *  <ul>\n *    <li>no charset appears to match the data.</li>\n *    <li>no input text has been provided</li>\n *  </ul>\n *\n * @param ucsd      the charset detector to be used.\n * @param status    any error conditions are reported back in this variable.\n * @return          a UCharsetMatch  representing the best matching charset,\n *                  or NULL if no charset matches the byte data.\n *\n * @stable ICU 3.6\n */\nU_STABLE const UCharsetMatch * U_EXPORT2\nucsdet_detect(UCharsetDetector *ucsd, UErrorCode *status);\n    \n\n/**\n *  Find all charset matches that appear to be consistent with the input,\n *  returning an array of results.  The results are ordered with the\n *  best quality match first.\n *\n *  Because the detection only looks at a limited amount of the\n *  input byte data, some of the returned charsets may fail to handle\n *  the all of input data.\n *  <p>\n *  The returned UCharsetMatch objects are owned by the UCharsetDetector.\n *  They will remain valid until the detector is closed or modified\n *  \n * <p>\n * Return an error if \n *  <ul>\n *    <li>no charsets appear to match the input data.</li>\n *    <li>no input text has been provided</li>\n *  </ul>\n * \n * @param ucsd          the charset detector to be used.\n * @param matchesFound  pointer to a variable that will be set to the\n *                      number of charsets identified that are consistent with\n *                      the input data.  Output only.\n * @param status        any error conditions are reported back in this variable.\n * @return              A pointer to an array of pointers to UCharSetMatch objects.\n *                      This array, and the UCharSetMatch instances to which it refers,\n *                      are owned by the UCharsetDetector, and will remain valid until\n *                      the detector is closed or modified.\n * @stable ICU 3.6\n */\nU_STABLE const UCharsetMatch ** U_EXPORT2\nucsdet_detectAll(UCharsetDetector *ucsd, int32_t *matchesFound, UErrorCode *status);\n\n\n\n/**\n *  Get the name of the charset represented by a UCharsetMatch.\n *\n *  The storage for the returned name string is owned by the\n *  UCharsetMatch, and will remain valid while the UCharsetMatch\n *  is valid.\n *\n *  The name returned is suitable for use with the ICU conversion APIs.\n *\n *  @param ucsm    The charset match object.\n *  @param status  Any error conditions are reported back in this variable.\n *  @return        The name of the matching charset.\n *\n *  @stable ICU 3.6\n */\nU_STABLE const char * U_EXPORT2\nucsdet_getName(const UCharsetMatch *ucsm, UErrorCode *status);\n\n/**\n *  Get a confidence number for the quality of the match of the byte\n *  data with the charset.  Confidence numbers range from zero to 100,\n *  with 100 representing complete confidence and zero representing\n *  no confidence.\n *\n *  The confidence values are somewhat arbitrary.  They define an\n *  an ordering within the results for any single detection operation\n *  but are not generally comparable between the results for different input.\n *\n *  A confidence value of ten does have a general meaning - it is used\n *  for charsets that can represent the input data, but for which there\n *  is no other indication that suggests that the charset is the correct one.\n *  Pure 7 bit ASCII data, for example, is compatible with a\n *  great many charsets, most of which will appear as possible matches\n *  with a confidence of 10.\n *\n *  @param ucsm    The charset match object.\n *  @param status  Any error conditions are reported back in this variable.\n *  @return        A confidence number for the charset match.\n *\n *  @stable ICU 3.6\n */\nU_STABLE int32_t U_EXPORT2\nucsdet_getConfidence(const UCharsetMatch *ucsm, UErrorCode *status);\n\n/**\n *  Get the RFC 3066 code for the language of the input data.\n *\n *  The Charset Detection service is intended primarily for detecting\n *  charsets, not language.  For some, but not all, charsets, a language is\n *  identified as a byproduct of the detection process, and that is what\n *  is returned by this function.\n *\n *  CAUTION:\n *    1.  Language information is not available for input data encoded in\n *        all charsets. In particular, no language is identified\n *        for UTF-8 input data.\n *\n *    2.  Closely related languages may sometimes be confused.\n *\n *  If more accurate language detection is required, a linguistic\n *  analysis package should be used.\n *\n *  The storage for the returned name string is owned by the\n *  UCharsetMatch, and will remain valid while the UCharsetMatch\n *  is valid.\n *\n *  @param ucsm    The charset match object.\n *  @param status  Any error conditions are reported back in this variable.\n *  @return        The RFC 3066 code for the language of the input data, or\n *                 an empty string if the language could not be determined.\n *\n *  @stable ICU 3.6\n */\nU_STABLE const char * U_EXPORT2\nucsdet_getLanguage(const UCharsetMatch *ucsm, UErrorCode *status);\n\n\n/**\n  *  Get the entire input text as a UChar string, placing it into\n  *  a caller-supplied buffer.  A terminating\n  *  NUL character will be appended to the buffer if space is available.\n  *\n  *  The number of UChars in the output string, not including the terminating\n  *  NUL, is returned. \n  *\n  *  If the supplied buffer is smaller than required to hold the output,\n  *  the contents of the buffer are undefined.  The full output string length\n  *  (in UChars) is returned as always, and can be used to allocate a buffer\n  *  of the correct size.\n  *\n  *\n  * @param ucsm    The charset match object.\n  * @param buf     A UChar buffer to be filled with the converted text data.\n  * @param cap     The capacity of the buffer in UChars.\n  * @param status  Any error conditions are reported back in this variable.\n  * @return        The number of UChars in the output string.\n  *\n  * @stable ICU 3.6\n  */\nU_STABLE  int32_t U_EXPORT2\nucsdet_getUChars(const UCharsetMatch *ucsm,\n                 UChar *buf, int32_t cap, UErrorCode *status);\n\n\n\n/**\n  *  Get an iterator over the set of all detectable charsets - \n  *  over the charsets that are known to the charset detection\n  *  service.\n  *\n  *  The returned UEnumeration provides access to the names of\n  *  the charsets.\n  *\n  *  The state of the Charset detector that is passed in does not\n  *  affect the result of this function, but requiring a valid, open\n  *  charset detector as a parameter insures that the charset detection\n  *  service has been safely initialized and that the required detection\n  *  data is available.\n  *\n  *  @param ucsd a Charset detector.\n  *  @param status  Any error conditions are reported back in this variable.\n  *  @return an iterator providing access to the detectable charset names.\n  *  @stable ICU 3.6\n  */\nU_STABLE  UEnumeration * U_EXPORT2\nucsdet_getAllDetectableCharsets(const UCharsetDetector *ucsd,  UErrorCode *status);\n\n\n/**\n  *  Test whether input filtering is enabled for this charset detector.\n  *  Input filtering removes text that appears to be HTML or xml\n  *  markup from the input before applying the code page detection\n  *  heuristics.\n  *\n  *  @param ucsd  The charset detector to check.\n  *  @return TRUE if filtering is enabled.\n  *  @stable ICU 3.6\n  */\nU_STABLE  UBool U_EXPORT2\nucsdet_isInputFilterEnabled(const UCharsetDetector *ucsd);\n\n\n/**\n * Enable filtering of input text. If filtering is enabled,\n * text within angle brackets (\"<\" and \">\") will be removed\n * before detection, which will remove most HTML or xml markup.\n *\n * @param ucsd   the charset detector to be modified.\n * @param filter <code>true</code> to enable input text filtering.\n * @return The previous setting.\n *\n * @stable ICU 3.6\n */\nU_STABLE  UBool U_EXPORT2\nucsdet_enableInputFilter(UCharsetDetector *ucsd, UBool filter);\n\n#endif\n#endif   /* __UCSDET_H */\n\n\n"
  },
  {
    "path": "deprecated/android/addons/icucompat/unicode/ucurr.h",
    "content": "/*\n**********************************************************************\n* Copyright (c) 2002-2012, International Business Machines\n* Corporation and others.  All Rights Reserved.\n**********************************************************************\n*/\n#ifndef _UCURR_H_\n#define _UCURR_H_\n\n#include \"unicode/utypes.h\"\n#include \"unicode/uenum.h\"\n\n/**\n * \\file \n * \\brief C API: Encapsulates information about a currency.\n */\n\n#if !UCONFIG_NO_FORMATTING\n\n/**\n * The ucurr API encapsulates information about a currency, as defined by\n * ISO 4217.  A currency is represented by a 3-character string\n * containing its ISO 4217 code.  This API can return various data\n * necessary the proper display of a currency:\n *\n * <ul><li>A display symbol, for a specific locale\n * <li>The number of fraction digits to display\n * <li>A rounding increment\n * </ul>\n *\n * The <tt>DecimalFormat</tt> class uses these data to display\n * currencies.\n * @author Alan Liu\n * @since ICU 2.2\n */\n\n/**\n * Finds a currency code for the given locale.\n * @param locale the locale for which to retrieve a currency code. \n *               Currency can be specified by the \"currency\" keyword\n *               in which case it overrides the default currency code\n * @param buff   fill in buffer. Can be NULL for preflighting.\n * @param buffCapacity capacity of the fill in buffer. Can be 0 for\n *               preflighting. If it is non-zero, the buff parameter\n *               must not be NULL.\n * @param ec error code\n * @return length of the currency string. It should always be 3. If 0,\n *                currency couldn't be found or the input values are \n *                invalid. \n * @stable ICU 2.8\n */\nU_STABLE int32_t U_EXPORT2\nucurr_forLocale(const char* locale,\n                UChar* buff,\n                int32_t buffCapacity,\n                UErrorCode* ec);\n\n/**\n * Selector constants for ucurr_getName().\n *\n * @see ucurr_getName\n * @stable ICU 2.6\n */\ntypedef enum UCurrNameStyle {\n    /**\n     * Selector for ucurr_getName indicating a symbolic name for a\n     * currency, such as \"$\" for USD.\n     * @stable ICU 2.6\n     */\n    UCURR_SYMBOL_NAME,\n\n    /**\n     * Selector for ucurr_getName indicating the long name for a\n     * currency, such as \"US Dollar\" for USD.\n     * @stable ICU 2.6\n     */\n    UCURR_LONG_NAME\n} UCurrNameStyle;\n\n#if !UCONFIG_NO_SERVICE\n/**\n * @stable ICU 2.6\n */\ntypedef const void* UCurrRegistryKey;\n\n/**\n * Register an (existing) ISO 4217 currency code for the given locale.\n * Only the country code and the two variants EURO and PRE_EURO are\n * recognized.\n * @param isoCode the three-letter ISO 4217 currency code\n * @param locale  the locale for which to register this currency code\n * @param status the in/out status code\n * @return a registry key that can be used to unregister this currency code, or NULL\n * if there was an error.\n * @stable ICU 2.6\n */\nU_STABLE UCurrRegistryKey U_EXPORT2\nucurr_register(const UChar* isoCode, \n                   const char* locale,  \n                   UErrorCode* status);\n/**\n * Unregister the previously-registered currency definitions using the\n * URegistryKey returned from ucurr_register.  Key becomes invalid after\n * a successful call and should not be used again.  Any currency \n * that might have been hidden by the original ucurr_register call is \n * restored.\n * @param key the registry key returned by a previous call to ucurr_register\n * @param status the in/out status code, no special meanings are assigned\n * @return TRUE if the currency for this key was successfully unregistered\n * @stable ICU 2.6\n */\nU_STABLE UBool U_EXPORT2\nucurr_unregister(UCurrRegistryKey key, UErrorCode* status);\n#endif /* UCONFIG_NO_SERVICE */\n\n/**\n * Returns the display name for the given currency in the\n * given locale.  For example, the display name for the USD\n * currency object in the en_US locale is \"$\".\n * @param currency null-terminated 3-letter ISO 4217 code\n * @param locale locale in which to display currency\n * @param nameStyle selector for which kind of name to return\n * @param isChoiceFormat fill-in set to TRUE if the returned value\n * is a ChoiceFormat pattern; otherwise it is a static string\n * @param len fill-in parameter to receive length of result\n * @param ec error code\n * @return pointer to display string of 'len' UChars.  If the resource\n * data contains no entry for 'currency', then 'currency' itself is\n * returned.  If *isChoiceFormat is TRUE, then the result is a\n * ChoiceFormat pattern.  Otherwise it is a static string.\n * @stable ICU 2.6\n */\nU_STABLE const UChar* U_EXPORT2\nucurr_getName(const UChar* currency,\n              const char* locale,\n              UCurrNameStyle nameStyle,\n              UBool* isChoiceFormat,\n              int32_t* len,\n              UErrorCode* ec);\n\n/**\n * Returns the plural name for the given currency in the\n * given locale.  For example, the plural name for the USD\n * currency object in the en_US locale is \"US dollar\" or \"US dollars\".\n * @param currency null-terminated 3-letter ISO 4217 code\n * @param locale locale in which to display currency\n * @param isChoiceFormat fill-in set to TRUE if the returned value\n * is a ChoiceFormat pattern; otherwise it is a static string\n * @param pluralCount plural count\n * @param len fill-in parameter to receive length of result\n * @param ec error code\n * @return pointer to display string of 'len' UChars.  If the resource\n * data contains no entry for 'currency', then 'currency' itself is\n * returned.  \n * @stable ICU 4.2\n */\nU_STABLE const UChar* U_EXPORT2\nucurr_getPluralName(const UChar* currency,\n                    const char* locale,\n                    UBool* isChoiceFormat,\n                    const char* pluralCount,\n                    int32_t* len,\n                    UErrorCode* ec);\n\n/**\n * Returns the number of the number of fraction digits that should\n * be displayed for the given currency.\n * @param currency null-terminated 3-letter ISO 4217 code\n * @param ec input-output error code\n * @return a non-negative number of fraction digits to be\n * displayed, or 0 if there is an error\n * @stable ICU 3.0\n */\nU_STABLE int32_t U_EXPORT2\nucurr_getDefaultFractionDigits(const UChar* currency,\n                               UErrorCode* ec);\n\n/**\n * Returns the rounding increment for the given currency, or 0.0 if no\n * rounding is done by the currency.\n * @param currency null-terminated 3-letter ISO 4217 code\n * @param ec input-output error code\n * @return the non-negative rounding increment, or 0.0 if none,\n * or 0.0 if there is an error\n * @stable ICU 3.0\n */\nU_STABLE double U_EXPORT2\nucurr_getRoundingIncrement(const UChar* currency,\n                           UErrorCode* ec);\n\n/**\n * Selector constants for ucurr_openCurrencies().\n *\n * @see ucurr_openCurrencies\n * @stable ICU 3.2\n */\ntypedef enum UCurrCurrencyType {\n    /**\n     * Select all ISO-4217 currency codes.\n     * @stable ICU 3.2\n     */\n    UCURR_ALL = INT32_MAX,\n    /**\n     * Select only ISO-4217 commonly used currency codes.\n     * These currencies can be found in common use, and they usually have\n     * bank notes or coins associated with the currency code.\n     * This does not include fund codes, precious metals and other\n     * various ISO-4217 codes limited to special financial products.\n     * @stable ICU 3.2\n     */\n    UCURR_COMMON = 1,\n    /**\n     * Select ISO-4217 uncommon currency codes.\n     * These codes respresent fund codes, precious metals and other\n     * various ISO-4217 codes limited to special financial products.\n     * A fund code is a monetary resource associated with a currency.\n     * @stable ICU 3.2\n     */\n    UCURR_UNCOMMON = 2,\n    /**\n     * Select only deprecated ISO-4217 codes.\n     * These codes are no longer in general public use.\n     * @stable ICU 3.2\n     */\n    UCURR_DEPRECATED = 4,\n    /**\n     * Select only non-deprecated ISO-4217 codes.\n     * These codes are in general public use.\n     * @stable ICU 3.2\n     */\n    UCURR_NON_DEPRECATED = 8\n} UCurrCurrencyType;\n\n/**\n * Provides a UEnumeration object for listing ISO-4217 codes.\n * @param currType You can use one of several UCurrCurrencyType values for this\n *      variable. You can also | (or) them together to get a specific list of\n *      currencies. Most people will want to use the (UCURR_CURRENCY|UCURR_NON_DEPRECATED) value to\n *      get a list of current currencies.\n * @param pErrorCode Error code\n * @stable ICU 3.2\n */\nU_STABLE UEnumeration * U_EXPORT2\nucurr_openISOCurrencies(uint32_t currType, UErrorCode *pErrorCode);\n\n/**\n  * Queries if the given ISO 4217 3-letter code is available on the specified date range. \n  * \n  * Note: For checking availability of a currency on a specific date, specify the date on both 'from' and 'to' \n  * \n  * When 'from' is U_DATE_MIN and 'to' is U_DATE_MAX, this method checks if the specified currency is available any time. \n  * If 'from' and 'to' are same UDate value, this method checks if the specified currency is available on that date.\n  * \n  * @param isoCode \n  *            The ISO 4217 3-letter code. \n  * \n  * @param from \n  *            The lower bound of the date range, inclusive. When 'from' is U_DATE_MIN, check the availability \n  *            of the currency any date before 'to' \n  * \n  * @param to \n  *            The upper bound of the date range, inclusive. When 'to' is U_DATE_MAX, check the availability of \n  *            the currency any date after 'from' \n  * \n  * @param errorCode \n  *            ICU error code \n   * \n  * @return TRUE if the given ISO 4217 3-letter code is supported on the specified date range. \n  * \n  * @stable ICU 4.8 \n  */ \nU_STABLE UBool U_EXPORT2\nucurr_isAvailable(const UChar* isoCode, \n             UDate from, \n             UDate to, \n             UErrorCode* errorCode);\n\n/** \n * Finds the number of valid currency codes for the\n * given locale and date.\n * @param locale the locale for which to retrieve the\n *               currency count.\n * @param date   the date for which to retrieve the\n *               currency count for the given locale.\n * @param ec     error code\n * @return       the number of currency codes for the\n *               given locale and date.  If 0, currency\n *               codes couldn't be found for the input\n *               values are invalid.\n * @stable ICU 4.0\n */\nU_STABLE int32_t U_EXPORT2\nucurr_countCurrencies(const char* locale, \n                 UDate date, \n                 UErrorCode* ec); \n\n/** \n * Finds a currency code for the given locale and date \n * @param locale the locale for which to retrieve a currency code.  \n *               Currency can be specified by the \"currency\" keyword \n *               in which case it overrides the default currency code \n * @param date   the date for which to retrieve a currency code for \n *               the given locale. \n * @param index  the index within the available list of currency codes\n *               for the given locale on the given date.\n * @param buff   fill in buffer. Can be NULL for preflighting. \n * @param buffCapacity capacity of the fill in buffer. Can be 0 for \n *               preflighting. If it is non-zero, the buff parameter \n *               must not be NULL. \n * @param ec     error code \n * @return       length of the currency string. It should always be 3. \n *               If 0, currency couldn't be found or the input values are  \n *               invalid.  \n * @stable ICU 4.0 \n */ \nU_STABLE int32_t U_EXPORT2 \nucurr_forLocaleAndDate(const char* locale, \n                UDate date, \n                int32_t index,\n                UChar* buff, \n                int32_t buffCapacity, \n                UErrorCode* ec); \n\n/**\n * Given a key and a locale, returns an array of string values in a preferred\n * order that would make a difference. These are all and only those values where\n * the open (creation) of the service with the locale formed from the input locale\n * plus input keyword and that value has different behavior than creation with the\n * input locale alone.\n * @param key           one of the keys supported by this service.  For now, only\n *                      \"currency\" is supported.\n * @param locale        the locale\n * @param commonlyUsed  if set to true it will return only commonly used values\n *                      with the given locale in preferred order.  Otherwise,\n *                      it will return all the available values for the locale.\n * @param status error status\n * @return a string enumeration over keyword values for the given key and the locale.\n * @stable ICU 4.2\n */\nU_STABLE UEnumeration* U_EXPORT2\nucurr_getKeywordValuesForLocale(const char* key,\n                                const char* locale,\n                                UBool commonlyUsed,\n                                UErrorCode* status);\n\n#ifndef U_HIDE_DRAFT_API\n/**\n * Returns the ISO 4217 numeric code for the currency.\n * <p>Note: If the ISO 4217 numeric code is not assigned for the currency or\n * the currency is unknown, this function returns 0.\n *\n * @param currency null-terminated 3-letter ISO 4217 code\n * @return The ISO 4217 numeric code of the currency\n * @draft ICU 49\n */\nU_DRAFT int32_t U_EXPORT2\nucurr_getNumericCode(const UChar* currency);\n#endif  /* U_HIDE_DRAFT_API */\n\n#endif /* #if !UCONFIG_NO_FORMATTING */\n\n#endif\n"
  },
  {
    "path": "deprecated/android/addons/icucompat/unicode/udat.h",
    "content": "/*\n *******************************************************************************\n * Copyright (C) 1996-2012, International Business Machines\n * Corporation and others. All Rights Reserved.\n *******************************************************************************\n*/\n\n#ifndef UDAT_H\n#define UDAT_H\n\n#include \"unicode/utypes.h\"\n\n#if !UCONFIG_NO_FORMATTING\n\n#include \"unicode/localpointer.h\"\n#include \"unicode/ucal.h\"\n#include \"unicode/unum.h\"\n#include \"unicode/udisplaycontext.h\"\n/**\n * \\file\n * \\brief C API: DateFormat\n *\n * <h2> Date Format C API</h2>\n *\n * Date Format C API  consists of functions that convert dates and\n * times from their internal representations to textual form and back again in a\n * language-independent manner. Converting from the internal representation (milliseconds\n * since midnight, January 1, 1970) to text is known as \"formatting,\" and converting\n * from text to millis is known as \"parsing.\"  We currently define only one concrete\n * structure UDateFormat, which can handle pretty much all normal\n * date formatting and parsing actions.\n * <P>\n * Date Format helps you to format and parse dates for any locale. Your code can\n * be completely independent of the locale conventions for months, days of the\n * week, or even the calendar format: lunar vs. solar.\n * <P>\n * To format a date for the current Locale with default time and date style,\n * use one of the static factory methods:\n * <pre>\n * \\code\n *  UErrorCode status = U_ZERO_ERROR;\n *  UChar *myString;\n *  int32_t myStrlen = 0;\n *  UDateFormat* dfmt = udat_open(UDAT_DEFAULT, UDAT_DEFAULT, NULL, NULL, -1, NULL, -1, &status);\n *  myStrlen = udat_format(dfmt, myDate, NULL, myStrlen, NULL, &status);\n *  if (status==U_BUFFER_OVERFLOW_ERROR){\n *      status=U_ZERO_ERROR;\n *      myString=(UChar*)malloc(sizeof(UChar) * (myStrlen+1) );\n *      udat_format(dfmt, myDate, myString, myStrlen+1, NULL, &status);\n *  }\n * \\endcode\n * </pre>\n * If you are formatting multiple numbers, it is more efficient to get the\n * format and use it multiple times so that the system doesn't have to fetch the\n * information about the local language and country conventions multiple times.\n * <pre>\n * \\code\n *  UErrorCode status = U_ZERO_ERROR;\n *  int32_t i, myStrlen = 0;\n *  UChar* myString;\n *  char buffer[1024];\n *  UDate myDateArr[] = { 0.0, 100000000.0, 2000000000.0 }; // test values\n *  UDateFormat* df = udat_open(UDAT_DEFAULT, UDAT_DEFAULT, NULL, NULL, -1, NULL, 0, &status);\n *  for (i = 0; i < 3; i++) {\n *      myStrlen = udat_format(df, myDateArr[i], NULL, myStrlen, NULL, &status);\n *      if(status == U_BUFFER_OVERFLOW_ERROR){\n *          status = U_ZERO_ERROR;\n *          myString = (UChar*)malloc(sizeof(UChar) * (myStrlen+1) );\n *          udat_format(df, myDateArr[i], myString, myStrlen+1, NULL, &status);\n *          printf(\"%s\\n\", u_austrcpy(buffer, myString) );\n *          free(myString);\n *      }\n *  }\n * \\endcode\n * </pre>\n * To get specific fields of a date, you can use UFieldPosition to\n * get specific fields.\n * <pre>\n * \\code\n *  UErrorCode status = U_ZERO_ERROR;\n *  UFieldPosition pos;\n *  UChar *myString;\n *  int32_t myStrlen = 0;\n *  char buffer[1024];\n *\n *  pos.field = 1;  // Same as the DateFormat::EField enum\n *  UDateFormat* dfmt = udat_open(UDAT_DEFAULT, UDAT_DEFAULT, NULL, -1, NULL, 0, &status);\n *  myStrlen = udat_format(dfmt, myDate, NULL, myStrlen, &pos, &status);\n *  if (status==U_BUFFER_OVERFLOW_ERROR){\n *      status=U_ZERO_ERROR;\n *      myString=(UChar*)malloc(sizeof(UChar) * (myStrlen+1) );\n *      udat_format(dfmt, myDate, myString, myStrlen+1, &pos, &status);\n *  }\n *  printf(\"date format: %s\\n\", u_austrcpy(buffer, myString));\n *  buffer[pos.endIndex] = 0;   // NULL terminate the string.\n *  printf(\"UFieldPosition position equals %s\\n\", &buffer[pos.beginIndex]);\n * \\endcode\n * </pre>\n * To format a date for a different Locale, specify it in the call to\n * udat_open()\n * <pre>\n * \\code\n *        UDateFormat* df = udat_open(UDAT_SHORT, UDAT_SHORT, \"fr_FR\", NULL, -1, NULL, 0, &status);\n * \\endcode\n * </pre>\n * You can use a DateFormat API udat_parse() to parse.\n * <pre>\n * \\code\n *  UErrorCode status = U_ZERO_ERROR;\n *  int32_t parsepos=0;\n *  UDate myDate = udat_parse(df, myString, u_strlen(myString), &parsepos, &status);\n * \\endcode\n * </pre>\n *  You can pass in different options for the arguments for date and time style\n *  to control the length of the result; from SHORT to MEDIUM to LONG to FULL.\n *  The exact result depends on the locale, but generally:\n *  see UDateFormatStyle for more details\n * <ul type=round>\n *   <li>   UDAT_SHORT is completely numeric, such as 12/13/52 or 3:30pm\n *   <li>   UDAT_MEDIUM is longer, such as Jan 12, 1952\n *   <li>   UDAT_LONG is longer, such as January 12, 1952 or 3:30:32pm\n *   <li>   UDAT_FULL is pretty completely specified, such as\n *          Tuesday, April 12, 1952 AD or 3:30:42pm PST.\n * </ul>\n * You can also set the time zone on the format if you wish.\n * <P>\n * You can also use forms of the parse and format methods with Parse Position and\n * UFieldPosition to allow you to\n * <ul type=round>\n *   <li>   Progressively parse through pieces of a string.\n *   <li>   Align any particular field, or find out where it is for selection\n *          on the screen.\n * </ul>\n */\n\n/** A date formatter.\n *  For usage in C programs.\n *  @stable ICU 2.6\n */\ntypedef void* UDateFormat;\n\n/** The possible date/time format styles \n *  @stable ICU 2.6\n */\ntypedef enum UDateFormatStyle {\n    /** Full style */\n    UDAT_FULL,\n    /** Long style */\n    UDAT_LONG,\n    /** Medium style */\n    UDAT_MEDIUM,\n    /** Short style */\n    UDAT_SHORT,\n    /** Default style */\n    UDAT_DEFAULT = UDAT_MEDIUM,\n\n    /** Bitfield for relative date */\n    UDAT_RELATIVE = (1 << 7),\n    \n    UDAT_FULL_RELATIVE = UDAT_FULL | UDAT_RELATIVE,\n        \n    UDAT_LONG_RELATIVE = UDAT_LONG | UDAT_RELATIVE,\n    \n    UDAT_MEDIUM_RELATIVE = UDAT_MEDIUM | UDAT_RELATIVE,\n    \n    UDAT_SHORT_RELATIVE = UDAT_SHORT | UDAT_RELATIVE,\n    \n    \n    /** No style */\n    UDAT_NONE = -1,\n\n    /**\n     * Use the pattern given in the parameter to udat_open\n     * @see udat_open\n     * @draft ICU 50\n     */\n    UDAT_PATTERN = -2,\n\n    /** @internal alias to UDAT_PATTERN */\n    UDAT_IGNORE = UDAT_PATTERN\n} UDateFormatStyle;\n\n// Skeletons for dates.\n\n/**\n * Constant for date skeleton with year.\n * @stable ICU 4.0\n */\n#define UDAT_YEAR                       \"y\"\n/**\n * Constant for date skeleton with quarter.\n * @internal ICU 50 technology preview\n */\n#define UDAT_QUARTER                    \"QQQQ\"\n/**\n * Constant for date skeleton with abbreviated quarter.\n * @internal ICU 50 technology preview\n */\n#define UDAT_ABBR_QUARTER               \"QQQ\"\n/**\n * Constant for date skeleton with year and quarter.\n * @stable ICU 4.0\n */\n#define UDAT_YEAR_QUARTER               \"yQQQQ\"\n/**\n * Constant for date skeleton with year and abbreviated quarter.\n * @stable ICU 4.0\n */\n#define UDAT_YEAR_ABBR_QUARTER          \"yQQQ\"\n/**\n * Constant for date skeleton with month.\n * @stable ICU 4.0\n */\n#define UDAT_MONTH                      \"MMMM\"\n/**\n * Constant for date skeleton with abbreviated month.\n * @stable ICU 4.0\n */\n#define UDAT_ABBR_MONTH                 \"MMM\"\n/**\n * Constant for date skeleton with numeric month.\n * @stable ICU 4.0\n */\n#define UDAT_NUM_MONTH                  \"M\"\n/**\n * Constant for date skeleton with year and month.\n * @stable ICU 4.0\n */\n#define UDAT_YEAR_MONTH                 \"yMMMM\"\n/**\n * Constant for date skeleton with year and abbreviated month.\n * @stable ICU 4.0\n */\n#define UDAT_YEAR_ABBR_MONTH            \"yMMM\"\n/**\n * Constant for date skeleton with year and numeric month.\n * @stable ICU 4.0\n */\n#define UDAT_YEAR_NUM_MONTH             \"yM\"\n/**\n * Constant for date skeleton with day.\n * @stable ICU 4.0\n */\n#define UDAT_DAY                        \"d\"\n/**\n * Constant for date skeleton with year, month, and day.\n * Used in combinations date + time, date + time + zone, or time + zone.\n * @stable ICU 4.0\n */\n#define UDAT_YEAR_MONTH_DAY             \"yMMMMd\"\n/**\n * Constant for date skeleton with year, abbreviated month, and day.\n * Used in combinations date + time, date + time + zone, or time + zone.\n * @stable ICU 4.0\n */\n#define UDAT_YEAR_ABBR_MONTH_DAY        \"yMMMd\"\n/**\n * Constant for date skeleton with year, numeric month, and day.\n * Used in combinations date + time, date + time + zone, or time + zone.\n * @stable ICU 4.0\n */\n#define UDAT_YEAR_NUM_MONTH_DAY         \"yMd\"\n/**\n * Constant for date skeleton with weekday.\n * @internal ICU 50 technology preview\n */\n#define UDAT_WEEKDAY                    \"EEEE\"\n/**\n * Constant for date skeleton with abbreviated weekday.\n * @internal ICU 50 technology preview\n */\n#define UDAT_ABBR_WEEKDAY               \"E\"\n/**\n * Constant for date skeleton with year, month, weekday, and day.\n * Used in combinations date + time, date + time + zone, or time + zone.\n * @stable ICU 4.0\n */\n#define UDAT_YEAR_MONTH_WEEKDAY_DAY     \"yMMMMEEEEd\"\n/**\n * Constant for date skeleton with year, abbreviated month, weekday, and day.\n * Used in combinations date + time, date + time + zone, or time + zone.\n * @stable ICU 4.0\n */\n#define UDAT_YEAR_ABBR_MONTH_WEEKDAY_DAY \"yMMMEd\" \n/**\n * Constant for date skeleton with year, numeric month, weekday, and day.\n * Used in combinations date + time, date + time + zone, or time + zone.\n * @stable ICU 4.0\n */\n#define UDAT_YEAR_NUM_MONTH_WEEKDAY_DAY \"yMEd\"\n/**\n * Constant for date skeleton with long month and day.\n * Used in combinations date + time, date + time + zone, or time + zone.\n * @stable ICU 4.0\n */\n#define UDAT_MONTH_DAY                  \"MMMMd\"\n/**\n * Constant for date skeleton with abbreviated month and day.\n * Used in combinations date + time, date + time + zone, or time + zone.\n * @stable ICU 4.0\n */\n#define UDAT_ABBR_MONTH_DAY             \"MMMd\"\n/**\n * Constant for date skeleton with numeric month and day.\n * Used in combinations date + time, date + time + zone, or time + zone.\n * @stable ICU 4.0\n */\n#define UDAT_NUM_MONTH_DAY              \"Md\"\n/**\n * Constant for date skeleton with month, weekday, and day.\n * Used in combinations date + time, date + time + zone, or time + zone.\n * @stable ICU 4.0\n */\n#define UDAT_MONTH_WEEKDAY_DAY          \"MMMMEEEEd\"\n/**\n * Constant for date skeleton with abbreviated month, weekday, and day.\n * Used in combinations date + time, date + time + zone, or time + zone.\n * @stable ICU 4.0\n */\n#define UDAT_ABBR_MONTH_WEEKDAY_DAY     \"MMMEd\"\n/**\n * Constant for date skeleton with numeric month, weekday, and day.\n * Used in combinations date + time, date + time + zone, or time + zone.\n * @stable ICU 4.0\n */\n#define UDAT_NUM_MONTH_WEEKDAY_DAY      \"MEd\"\n\n// Skeletons for times.\n\n/**\n * Constant for date skeleton with hour, with the locale's preferred hour format (12 or 24).\n * @stable ICU 4.0\n */\n#define UDAT_HOUR                       \"j\"\n/**\n * Constant for date skeleton with hour in 24-hour presentation.\n * @internal ICU 50 technology preview\n */\n#define UDAT_HOUR24                     \"H\"\n/**\n * Constant for date skeleton with minute.\n * @internal ICU 50 technology preview\n */\n#define UDAT_MINUTE                     \"m\"\n/**\n * Constant for date skeleton with hour and minute, with the locale's preferred hour format (12 or 24).\n * Used in combinations date + time, date + time + zone, or time + zone.\n * @stable ICU 4.0\n */\n#define UDAT_HOUR_MINUTE                \"jm\"\n/**\n * Constant for date skeleton with hour and minute in 24-hour presentation.\n * Used in combinations date + time, date + time + zone, or time + zone.\n * @stable ICU 4.0\n */\n#define UDAT_HOUR24_MINUTE              \"Hm\"\n/**\n * Constant for date skeleton with second.\n * @internal ICU 50 technology preview\n */\n#define UDAT_SECOND                     \"s\"\n/**\n * Constant for date skeleton with hour, minute, and second,\n * with the locale's preferred hour format (12 or 24).\n * Used in combinations date + time, date + time + zone, or time + zone.\n * @stable ICU 4.0\n */\n#define UDAT_HOUR_MINUTE_SECOND         \"jms\"\n/**\n * Constant for date skeleton with hour, minute, and second in\n * 24-hour presentation.\n * Used in combinations date + time, date + time + zone, or time + zone.\n * @stable ICU 4.0\n */\n#define UDAT_HOUR24_MINUTE_SECOND       \"Hms\"\n/**\n * Constant for date skeleton with minute and second.\n * Used in combinations date + time, date + time + zone, or time + zone.\n * @stable ICU 4.0\n */\n#define UDAT_MINUTE_SECOND              \"ms\"\n\n// Skeletons for time zones.\n\n/**\n * Constant for <i>generic location format</i>, such as Los Angeles Time;\n * used in combinations date + time + zone, or time + zone.\n * @see <a href=\"http://unicode.org/reports/tr35/#Date_Format_Patterns\">LDML Date Format Patterns</a>\n * @see <a href=\"http://unicode.org/reports/tr35/#Time_Zone_Fallback\">LDML Time Zone Fallback</a>\n * @internal ICU 50 technology preview\n */\n#define UDAT_LOCATION_TZ \"VVVV\"\n/**\n * Constant for <i>generic non-location format</i>, such as Pacific Time;\n * used in combinations date + time + zone, or time + zone.\n * @see <a href=\"http://unicode.org/reports/tr35/#Date_Format_Patterns\">LDML Date Format Patterns</a>\n * @see <a href=\"http://unicode.org/reports/tr35/#Time_Zone_Fallback\">LDML Time Zone Fallback</a>\n * @internal ICU 50 technology preview\n */\n#define UDAT_GENERIC_TZ \"vvvv\"\n/**\n * Constant for <i>generic non-location format</i>, abbreviated if possible, such as PT;\n * used in combinations date + time + zone, or time + zone.\n * @see <a href=\"http://unicode.org/reports/tr35/#Date_Format_Patterns\">LDML Date Format Patterns</a>\n * @see <a href=\"http://unicode.org/reports/tr35/#Time_Zone_Fallback\">LDML Time Zone Fallback</a>\n * @internal ICU 50 technology preview\n */\n#define UDAT_ABBR_GENERIC_TZ \"v\"\n/**\n * Constant for <i>specific non-location format</i>, such as Pacific Daylight Time;\n * used in combinations date + time + zone, or time + zone.\n * @see <a href=\"http://unicode.org/reports/tr35/#Date_Format_Patterns\">LDML Date Format Patterns</a>\n * @see <a href=\"http://unicode.org/reports/tr35/#Time_Zone_Fallback\">LDML Time Zone Fallback</a>\n * @internal ICU 50 technology preview\n */\n#define UDAT_SPECIFIC_TZ \"zzzz\"\n/**\n * Constant for <i>specific non-location format</i>, abbreviated if possible, such as PDT;\n * used in combinations date + time + zone, or time + zone.\n * @see <a href=\"http://unicode.org/reports/tr35/#Date_Format_Patterns\">LDML Date Format Patterns</a>\n * @see <a href=\"http://unicode.org/reports/tr35/#Time_Zone_Fallback\">LDML Time Zone Fallback</a>\n * @internal ICU 50 technology preview\n */\n#define UDAT_ABBR_SPECIFIC_TZ \"z\"\n/**\n * Constant for <i>localized GMT/UTC format</i>, such as GMT+8:00 or HPG-8:00;\n * used in combinations date + time + zone, or time + zone.\n * @see <a href=\"http://unicode.org/reports/tr35/#Date_Format_Patterns\">LDML Date Format Patterns</a>\n * @see <a href=\"http://unicode.org/reports/tr35/#Time_Zone_Fallback\">LDML Time Zone Fallback</a>\n * @internal ICU 50 technology preview\n */\n#define UDAT_ABBR_UTC_TZ \"ZZZZ\"\n\n// deprecated skeleton constants\n\n/**\n * Constant for date skeleton with standalone month.\n * @deprecated ICU 50 Use UDAT_MONTH instead.\n */\n#define UDAT_STANDALONE_MONTH           \"LLLL\"\n/**\n * Constant for date skeleton with standalone abbreviated month.\n * @deprecated ICU 50 Use UDAT_ABBR_MONTH instead.\n */\n#define UDAT_ABBR_STANDALONE_MONTH      \"LLL\"\n\n/**\n * Constant for date skeleton with hour, minute, and generic timezone.\n * @deprecated ICU 50 Use instead UDAT_HOUR_MINUTE UDAT_ABBR_GENERIC_TZ or some other timezone presentation.\n */\n#define UDAT_HOUR_MINUTE_GENERIC_TZ     \"jmv\"\n/**\n * Constant for date skeleton with hour, minute, and timezone.\n * @deprecated ICU 50 Use instead UDAT_HOUR_MINUTE UDAT_ABBR_SPECIFIC_TZ or some other timezone presentation.\n */\n#define UDAT_HOUR_MINUTE_TZ             \"jmz\"\n/**\n * Constant for date skeleton with hour and generic timezone.\n * @deprecated ICU 50 Use instead UDAT_HOUR UDAT_ABBR_GENERIC_TZ or some other timezone presentation.\n */\n#define UDAT_HOUR_GENERIC_TZ            \"jv\"\n/**\n * Constant for date skeleton with hour and timezone.\n * @deprecated ICU 50 Use instead UDAT_HOUR UDAT_ABBR_SPECIFIC_TZ or some other timezone presentation.\n */\n#define UDAT_HOUR_TZ                    \"jz\"\n\n/**\n * FieldPosition and UFieldPosition selectors for format fields\n * defined by DateFormat and UDateFormat.\n * @stable ICU 3.0\n */\ntypedef enum UDateFormatField {\n    /**\n     * FieldPosition and UFieldPosition selector for 'G' field alignment,\n     * corresponding to the UCAL_ERA field.\n     * @stable ICU 3.0\n     */\n    UDAT_ERA_FIELD = 0,\n\n    /**\n     * FieldPosition and UFieldPosition selector for 'y' field alignment,\n     * corresponding to the UCAL_YEAR field.\n     * @stable ICU 3.0\n     */\n    UDAT_YEAR_FIELD = 1,\n\n    /**\n     * FieldPosition and UFieldPosition selector for 'M' field alignment,\n     * corresponding to the UCAL_MONTH field.\n     * @stable ICU 3.0\n     */\n    UDAT_MONTH_FIELD = 2,\n\n    /**\n     * FieldPosition and UFieldPosition selector for 'd' field alignment,\n     * corresponding to the UCAL_DATE field.\n     * @stable ICU 3.0\n     */\n    UDAT_DATE_FIELD = 3,\n\n    /**\n     * FieldPosition and UFieldPosition selector for 'k' field alignment,\n     * corresponding to the UCAL_HOUR_OF_DAY field.\n     * UDAT_HOUR_OF_DAY1_FIELD is used for the one-based 24-hour clock.\n     * For example, 23:59 + 01:00 results in 24:59.\n     * @stable ICU 3.0\n     */\n    UDAT_HOUR_OF_DAY1_FIELD = 4,\n\n    /**\n     * FieldPosition and UFieldPosition selector for 'H' field alignment,\n     * corresponding to the UCAL_HOUR_OF_DAY field.\n     * UDAT_HOUR_OF_DAY0_FIELD is used for the zero-based 24-hour clock.\n     * For example, 23:59 + 01:00 results in 00:59.\n     * @stable ICU 3.0\n     */\n    UDAT_HOUR_OF_DAY0_FIELD = 5,\n\n    /**\n     * FieldPosition and UFieldPosition selector for 'm' field alignment,\n     * corresponding to the UCAL_MINUTE field.\n     * @stable ICU 3.0\n     */\n    UDAT_MINUTE_FIELD = 6,\n\n    /**\n     * FieldPosition and UFieldPosition selector for 's' field alignment,\n     * corresponding to the UCAL_SECOND field.\n     * @stable ICU 3.0\n     */\n    UDAT_SECOND_FIELD = 7,\n\n    /**\n     * FieldPosition and UFieldPosition selector for 'S' field alignment,\n     * corresponding to the UCAL_MILLISECOND field.\n     *\n     * Note: Time formats that use 'S' can display a maximum of three\n     * significant digits for fractional seconds, corresponding to millisecond\n     * resolution and a fractional seconds sub-pattern of SSS. If the\n     * sub-pattern is S or SS, the fractional seconds value will be truncated\n     * (not rounded) to the number of display places specified. If the\n     * fractional seconds sub-pattern is longer than SSS, the additional\n     * display places will be filled with zeros.\n     * @stable ICU 3.0\n     */\n    UDAT_FRACTIONAL_SECOND_FIELD = 8,\n\n    /**\n     * FieldPosition and UFieldPosition selector for 'E' field alignment,\n     * corresponding to the UCAL_DAY_OF_WEEK field.\n     * @stable ICU 3.0\n     */\n    UDAT_DAY_OF_WEEK_FIELD = 9,\n\n    /**\n     * FieldPosition and UFieldPosition selector for 'D' field alignment,\n     * corresponding to the UCAL_DAY_OF_YEAR field.\n     * @stable ICU 3.0\n     */\n    UDAT_DAY_OF_YEAR_FIELD = 10,\n\n    /**\n     * FieldPosition and UFieldPosition selector for 'F' field alignment,\n     * corresponding to the UCAL_DAY_OF_WEEK_IN_MONTH field.\n     * @stable ICU 3.0\n     */\n    UDAT_DAY_OF_WEEK_IN_MONTH_FIELD = 11,\n\n    /**\n     * FieldPosition and UFieldPosition selector for 'w' field alignment,\n     * corresponding to the UCAL_WEEK_OF_YEAR field.\n     * @stable ICU 3.0\n     */\n    UDAT_WEEK_OF_YEAR_FIELD = 12,\n\n    /**\n     * FieldPosition and UFieldPosition selector for 'W' field alignment,\n     * corresponding to the UCAL_WEEK_OF_MONTH field.\n     * @stable ICU 3.0\n     */\n    UDAT_WEEK_OF_MONTH_FIELD = 13,\n\n    /**\n     * FieldPosition and UFieldPosition selector for 'a' field alignment,\n     * corresponding to the UCAL_AM_PM field.\n     * @stable ICU 3.0\n     */\n    UDAT_AM_PM_FIELD = 14,\n\n    /**\n     * FieldPosition and UFieldPosition selector for 'h' field alignment,\n     * corresponding to the UCAL_HOUR field.\n     * UDAT_HOUR1_FIELD is used for the one-based 12-hour clock.\n     * For example, 11:30 PM + 1 hour results in 12:30 AM.\n     * @stable ICU 3.0\n     */\n    UDAT_HOUR1_FIELD = 15,\n\n    /**\n     * FieldPosition and UFieldPosition selector for 'K' field alignment,\n     * corresponding to the UCAL_HOUR field.\n     * UDAT_HOUR0_FIELD is used for the zero-based 12-hour clock.\n     * For example, 11:30 PM + 1 hour results in 00:30 AM.\n     * @stable ICU 3.0\n     */\n    UDAT_HOUR0_FIELD = 16,\n\n    /**\n     * FieldPosition and UFieldPosition selector for 'z' field alignment,\n     * corresponding to the UCAL_ZONE_OFFSET and\n     * UCAL_DST_OFFSET fields.\n     * @stable ICU 3.0\n     */\n    UDAT_TIMEZONE_FIELD = 17,\n\n    /**\n     * FieldPosition and UFieldPosition selector for 'Y' field alignment,\n     * corresponding to the UCAL_YEAR_WOY field.\n     * @stable ICU 3.0\n     */\n    UDAT_YEAR_WOY_FIELD = 18,\n\n    /**\n     * FieldPosition and UFieldPosition selector for 'e' field alignment,\n     * corresponding to the UCAL_DOW_LOCAL field.\n     * @stable ICU 3.0\n     */\n    UDAT_DOW_LOCAL_FIELD = 19,\n\n    /**\n     * FieldPosition and UFieldPosition selector for 'u' field alignment,\n     * corresponding to the UCAL_EXTENDED_YEAR field.\n     * @stable ICU 3.0\n     */\n    UDAT_EXTENDED_YEAR_FIELD = 20,\n\n    /**\n     * FieldPosition and UFieldPosition selector for 'g' field alignment,\n     * corresponding to the UCAL_JULIAN_DAY field.\n     * @stable ICU 3.0\n     */\n    UDAT_JULIAN_DAY_FIELD = 21,\n\n    /**\n     * FieldPosition and UFieldPosition selector for 'A' field alignment,\n     * corresponding to the UCAL_MILLISECONDS_IN_DAY field.\n     * @stable ICU 3.0\n     */\n    UDAT_MILLISECONDS_IN_DAY_FIELD = 22,\n\n    /**\n     * FieldPosition and UFieldPosition selector for 'Z' field alignment,\n     * corresponding to the UCAL_ZONE_OFFSET and\n     * UCAL_DST_OFFSET fields.\n     * @stable ICU 3.0\n     */\n    UDAT_TIMEZONE_RFC_FIELD = 23,\n\n    /**\n     * FieldPosition and UFieldPosition selector for 'v' field alignment,\n     * corresponding to the UCAL_ZONE_OFFSET field.\n     * @stable ICU 3.4\n     */\n    UDAT_TIMEZONE_GENERIC_FIELD = 24,\n    /**\n     * FieldPosition selector for 'c' field alignment,\n     * corresponding to the {@link #UCAL_DOW_LOCAL} field.\n     * This displays the stand alone day name, if available.\n     * @stable ICU 3.4\n     */\n    UDAT_STANDALONE_DAY_FIELD = 25,\n\n    /**\n     * FieldPosition selector for 'L' field alignment,\n     * corresponding to the {@link #UCAL_MONTH} field.\n     * This displays the stand alone month name, if available.\n     * @stable ICU 3.4\n     */\n    UDAT_STANDALONE_MONTH_FIELD = 26,\n\n    /**\n     * FieldPosition selector for \"Q\" field alignment,\n     * corresponding to quarters. This is implemented\n     * using the {@link #UCAL_MONTH} field. This\n     * displays the quarter.\n     * @stable ICU 3.6\n     */\n    UDAT_QUARTER_FIELD = 27,\n\n    /**\n     * FieldPosition selector for the \"q\" field alignment,\n     * corresponding to stand-alone quarters. This is\n     * implemented using the {@link #UCAL_MONTH} field.\n     * This displays the stand-alone quarter.\n     * @stable ICU 3.6\n     */\n    UDAT_STANDALONE_QUARTER_FIELD = 28,\n\n    /**\n     * FieldPosition and UFieldPosition selector for 'V' field alignment,\n     * corresponding to the UCAL_ZONE_OFFSET field.\n     * @stable ICU 3.8\n     */\n    UDAT_TIMEZONE_SPECIAL_FIELD = 29,\n\n    /**\n     * FieldPosition selector for \"U\" field alignment,\n     * corresponding to cyclic year names. This is implemented\n     * using the {@link #UCAL_YEAR} field. This displays\n     * the cyclic year name, if available.\n     * @draft ICU 49\n     */\n    UDAT_YEAR_NAME_FIELD = 30,\n\n   /**\n     * Number of FieldPosition and UFieldPosition selectors for\n     * DateFormat and UDateFormat.\n     * Valid selectors range from 0 to UDAT_FIELD_COUNT-1.\n     * This value is subject to change if new fields are defined\n     * in the future.\n     * @stable ICU 3.0\n     */\n    UDAT_FIELD_COUNT = 31\n\n} UDateFormatField;\n\n\n/**\n * Maps from a UDateFormatField to the corresponding UCalendarDateFields.\n * Note: since the mapping is many-to-one, there is no inverse mapping.\n * @param field the UDateFormatField.\n * @return the UCalendarDateField.  This will be UCAL_FIELD_COUNT in case\n * of error (e.g., the input field is UDAT_FIELD_COUNT).\n * @stable ICU 4.4\n */\nU_STABLE UCalendarDateFields U_EXPORT2\nudat_toCalendarDateField(UDateFormatField field);\n\n\n/**\n * Open a new UDateFormat for formatting and parsing dates and times.\n * A UDateFormat may be used to format dates in calls to {@link #udat_format },\n * and to parse dates in calls to {@link #udat_parse }.\n * @param timeStyle The style used to format times; one of UDAT_FULL, UDAT_LONG,\n * UDAT_MEDIUM, UDAT_SHORT, UDAT_DEFAULT, or UDAT_NONE (relative time styles\n * are not currently supported).\n * When the pattern parameter is used, pass in UDAT_PATTERN for both timeStyle and dateStyle.\n * @param dateStyle The style used to format dates; one of UDAT_FULL, UDAT_LONG,\n * UDAT_MEDIUM, UDAT_SHORT, UDAT_DEFAULT, UDAT_FULL_RELATIVE, UDAT_LONG_RELATIVE,\n * UDAT_MEDIUM_RELATIVE, UDAT_SHORT_RELATIVE, or UDAT_NONE.\n * When the pattern parameter is used, pass in UDAT_PATTERN for both timeStyle and dateStyle.\n * As currently implemented,\n * relative date formatting only affects a limited range of calendar days before or\n * after the current date, based on the CLDR &lt;field type=\"day\"&gt;/&lt;relative&gt; data: For\n * example, in English, \"Yesterday\", \"Today\", and \"Tomorrow\". Outside of this range,\n * dates are formatted using the corresponding non-relative style.\n * @param locale The locale specifying the formatting conventions\n * @param tzID A timezone ID specifying the timezone to use.  If 0, use\n * the default timezone.\n * @param tzIDLength The length of tzID, or -1 if null-terminated.\n * @param pattern A pattern specifying the format to use.\n * @param patternLength The number of characters in the pattern, or -1 if null-terminated.\n * @param status A pointer to an UErrorCode to receive any errors\n * @return A pointer to a UDateFormat to use for formatting dates and times, or 0 if\n * an error occurred.\n * @stable ICU 2.0\n */\nU_STABLE UDateFormat* U_EXPORT2 \nudat_open(UDateFormatStyle  timeStyle,\n          UDateFormatStyle  dateStyle,\n          const char        *locale,\n          const UChar       *tzID,\n          int32_t           tzIDLength,\n          const UChar       *pattern,\n          int32_t           patternLength,\n          UErrorCode        *status);\n\n\n/**\n* Close a UDateFormat.\n* Once closed, a UDateFormat may no longer be used.\n* @param format The formatter to close.\n* @stable ICU 2.0\n*/\nU_STABLE void U_EXPORT2 \nudat_close(UDateFormat* format);\n\n#if U_SHOW_CPLUSPLUS_API\n\nU_NAMESPACE_BEGIN\n\n/**\n * \\class LocalUDateFormatPointer\n * \"Smart pointer\" class, closes a UDateFormat via udat_close().\n * For most methods see the LocalPointerBase base class.\n *\n * @see LocalPointerBase\n * @see LocalPointer\n * @stable ICU 4.4\n */\nU_DEFINE_LOCAL_OPEN_POINTER(LocalUDateFormatPointer, UDateFormat, udat_close);\n\nU_NAMESPACE_END\n\n#endif\n\n/**\n * Open a copy of a UDateFormat.\n * This function performs a deep copy.\n * @param fmt The format to copy\n * @param status A pointer to an UErrorCode to receive any errors.\n * @return A pointer to a UDateFormat identical to fmt.\n * @stable ICU 2.0\n */\nU_STABLE UDateFormat* U_EXPORT2 \nudat_clone(const UDateFormat *fmt,\n       UErrorCode *status);\n\n/**\n* Format a date using an UDateFormat.\n* The date will be formatted using the conventions specified in {@link #udat_open }\n* @param format The formatter to use\n* @param dateToFormat The date to format\n* @param result A pointer to a buffer to receive the formatted number.\n* @param resultLength The maximum size of result.\n* @param position A pointer to a UFieldPosition.  On input, position->field\n* is read.  On output, position->beginIndex and position->endIndex indicate\n* the beginning and ending indices of field number position->field, if such\n* a field exists.  This parameter may be NULL, in which case no field\n* position data is returned.\n* @param status A pointer to an UErrorCode to receive any errors\n* @return The total buffer size needed; if greater than resultLength, the output was truncated.\n* @see udat_parse\n* @see UFieldPosition\n* @stable ICU 2.0\n*/\nU_STABLE int32_t U_EXPORT2 \nudat_format(    const    UDateFormat*    format,\n                        UDate           dateToFormat,\n                        UChar*          result,\n                        int32_t         resultLength,\n                        UFieldPosition* position,\n                        UErrorCode*     status);\n\n/**\n* Parse a string into an date/time using a UDateFormat.\n* The date will be parsed using the conventions specified in {@link #udat_open }.\n* <P>\n* Note that the normal date formats associated with some calendars - such\n* as the Chinese lunar calendar - do not specify enough fields to enable\n* dates to be parsed unambiguously. In the case of the Chinese lunar\n* calendar, while the year within the current 60-year cycle is specified,\n* the number of such cycles since the start date of the calendar (in the\n* UCAL_ERA field of the UCalendar object) is not normally part of the format,\n* and parsing may assume the wrong era. For cases such as this it is\n* recommended that clients parse using udat_parseCalendar with the UCalendar\n* passed in set to the current date, or to a date within the era/cycle that\n* should be assumed if absent in the format.\n*\n* @param format The formatter to use.\n* @param text The text to parse.\n* @param textLength The length of text, or -1 if null-terminated.\n* @param parsePos If not 0, on input a pointer to an integer specifying the offset at which\n* to begin parsing.  If not 0, on output the offset at which parsing ended.\n* @param status A pointer to an UErrorCode to receive any errors\n* @return The value of the parsed date/time\n* @see udat_format\n* @stable ICU 2.0\n*/\nU_STABLE UDate U_EXPORT2 \nudat_parse(const    UDateFormat*    format,\n           const    UChar*          text,\n                    int32_t         textLength,\n                    int32_t         *parsePos,\n                    UErrorCode      *status);\n\n/**\n* Parse a string into an date/time using a UDateFormat.\n* The date will be parsed using the conventions specified in {@link #udat_open }.\n* @param format The formatter to use.\n* @param calendar A calendar set on input to the date and time to be used for\n*                 missing values in the date/time string being parsed, and set\n*                 on output to the parsed date/time. When the calendar type is\n*                 different from the internal calendar held by the UDateFormat\n*                 instance, the internal calendar will be cloned to a work\n*                 calendar set to the same milliseconds and time zone as this\n*                 calendar parameter, field values will be parsed based on the\n*                 work calendar, then the result (milliseconds and time zone)\n*                 will be set in this calendar.\n* @param text The text to parse.\n* @param textLength The length of text, or -1 if null-terminated.\n* @param parsePos If not 0, on input a pointer to an integer specifying the offset at which\n* to begin parsing.  If not 0, on output the offset at which parsing ended.\n* @param status A pointer to an UErrorCode to receive any errors\n* @see udat_format\n* @stable ICU 2.0\n*/\nU_STABLE void U_EXPORT2 \nudat_parseCalendar(const    UDateFormat*    format,\n                            UCalendar*      calendar,\n                   const    UChar*          text,\n                            int32_t         textLength,\n                            int32_t         *parsePos,\n                            UErrorCode      *status);\n\n/**\n* Determine if an UDateFormat will perform lenient parsing.\n* With lenient parsing, the parser may use heuristics to interpret inputs that do not\n* precisely match the pattern. With strict parsing, inputs must match the pattern.\n* @param fmt The formatter to query\n* @return TRUE if fmt is set to perform lenient parsing, FALSE otherwise.\n* @see udat_setLenient\n* @stable ICU 2.0\n*/\nU_STABLE UBool U_EXPORT2 \nudat_isLenient(const UDateFormat* fmt);\n\n/**\n* Specify whether an UDateFormat will perform lenient parsing.\n* With lenient parsing, the parser may use heuristics to interpret inputs that do not\n* precisely match the pattern. With strict parsing, inputs must match the pattern.\n* @param fmt The formatter to set\n* @param isLenient TRUE if fmt should perform lenient parsing, FALSE otherwise.\n* @see dat_isLenient\n* @stable ICU 2.0\n*/\nU_STABLE void U_EXPORT2 \nudat_setLenient(    UDateFormat*    fmt,\n                    UBool          isLenient);\n\n/**\n* Get the UCalendar associated with an UDateFormat.\n* A UDateFormat uses a UCalendar to convert a raw value to, for example,\n* the day of the week.\n* @param fmt The formatter to query.\n* @return A pointer to the UCalendar used by fmt.\n* @see udat_setCalendar\n* @stable ICU 2.0\n*/\nU_STABLE const UCalendar* U_EXPORT2 \nudat_getCalendar(const UDateFormat* fmt);\n\n/**\n* Set the UCalendar associated with an UDateFormat.\n* A UDateFormat uses a UCalendar to convert a raw value to, for example,\n* the day of the week.\n* @param fmt The formatter to set.\n* @param calendarToSet A pointer to an UCalendar to be used by fmt.\n* @see udat_setCalendar\n* @stable ICU 2.0\n*/\nU_STABLE void U_EXPORT2 \nudat_setCalendar(            UDateFormat*    fmt,\n                    const   UCalendar*      calendarToSet);\n\n/**\n* Get the UNumberFormat associated with an UDateFormat.\n* A UDateFormat uses a UNumberFormat to format numbers within a date,\n* for example the day number.\n* @param fmt The formatter to query.\n* @return A pointer to the UNumberFormat used by fmt to format numbers.\n* @see udat_setNumberFormat\n* @stable ICU 2.0\n*/\nU_STABLE const UNumberFormat* U_EXPORT2 \nudat_getNumberFormat(const UDateFormat* fmt);\n\n/**\n* Set the UNumberFormat associated with an UDateFormat.\n* A UDateFormat uses a UNumberFormat to format numbers within a date,\n* for example the day number.\n* @param fmt The formatter to set.\n* @param numberFormatToSet A pointer to the UNumberFormat to be used by fmt to format numbers.\n* @see udat_getNumberFormat\n* @stable ICU 2.0\n*/\nU_STABLE void U_EXPORT2 \nudat_setNumberFormat(            UDateFormat*    fmt,\n                        const   UNumberFormat*  numberFormatToSet);\n\n/**\n* Get a locale for which date/time formatting patterns are available.\n* A UDateFormat in a locale returned by this function will perform the correct\n* formatting and parsing for the locale.\n* @param localeIndex The index of the desired locale.\n* @return A locale for which date/time formatting patterns are available, or 0 if none.\n* @see udat_countAvailable\n* @stable ICU 2.0\n*/\nU_STABLE const char* U_EXPORT2 \nudat_getAvailable(int32_t localeIndex);\n\n/**\n* Determine how many locales have date/time  formatting patterns available.\n* This function is most useful as determining the loop ending condition for\n* calls to {@link #udat_getAvailable }.\n* @return The number of locales for which date/time formatting patterns are available.\n* @see udat_getAvailable\n* @stable ICU 2.0\n*/\nU_STABLE int32_t U_EXPORT2 \nudat_countAvailable(void);\n\n/**\n* Get the year relative to which all 2-digit years are interpreted.\n* For example, if the 2-digit start year is 2100, the year 99 will be\n* interpreted as 2199.\n* @param fmt The formatter to query.\n* @param status A pointer to an UErrorCode to receive any errors\n* @return The year relative to which all 2-digit years are interpreted.\n* @see udat_Set2DigitYearStart\n* @stable ICU 2.0\n*/\nU_STABLE UDate U_EXPORT2 \nudat_get2DigitYearStart(    const   UDateFormat     *fmt,\n                                    UErrorCode      *status);\n\n/**\n* Set the year relative to which all 2-digit years will be interpreted.\n* For example, if the 2-digit start year is 2100, the year 99 will be\n* interpreted as 2199.\n* @param fmt The formatter to set.\n* @param d The year relative to which all 2-digit years will be interpreted.\n* @param status A pointer to an UErrorCode to receive any errors\n* @see udat_Set2DigitYearStart\n* @stable ICU 2.0\n*/\nU_STABLE void U_EXPORT2 \nudat_set2DigitYearStart(    UDateFormat     *fmt,\n                            UDate           d,\n                            UErrorCode      *status);\n\n/**\n* Extract the pattern from a UDateFormat.\n* The pattern will follow the pattern syntax rules.\n* @param fmt The formatter to query.\n* @param localized TRUE if the pattern should be localized, FALSE otherwise.\n* @param result A pointer to a buffer to receive the pattern.\n* @param resultLength The maximum size of result.\n* @param status A pointer to an UErrorCode to receive any errors\n* @return The total buffer size needed; if greater than resultLength, the output was truncated.\n* @see udat_applyPattern\n* @stable ICU 2.0\n*/\nU_STABLE int32_t U_EXPORT2 \nudat_toPattern(    const   UDateFormat     *fmt,\n                        UBool          localized,\n                        UChar           *result,\n                        int32_t         resultLength,\n                        UErrorCode      *status);\n\n/**\n* Set the pattern used by an UDateFormat.\n* The pattern should follow the pattern syntax rules.\n* @param format The formatter to set.\n* @param localized TRUE if the pattern is localized, FALSE otherwise.\n* @param pattern The new pattern\n* @param patternLength The length of pattern, or -1 if null-terminated.\n* @see udat_toPattern\n* @stable ICU 2.0\n*/\nU_STABLE void U_EXPORT2 \nudat_applyPattern(            UDateFormat     *format,\n                            UBool          localized,\n                    const   UChar           *pattern,\n                            int32_t         patternLength);\n\n/** \n * The possible types of date format symbols \n * @stable ICU 2.6\n */\ntypedef enum UDateFormatSymbolType {\n    /** The era names, for example AD */\n    UDAT_ERAS,\n    /** The month names, for example February */\n    UDAT_MONTHS,\n    /** The short month names, for example Feb. */\n    UDAT_SHORT_MONTHS,\n    /** The weekday names, for example Monday */\n    UDAT_WEEKDAYS,\n    /** The short weekday names, for example Mon. */\n    UDAT_SHORT_WEEKDAYS,\n    /** The AM/PM names, for example AM */\n    UDAT_AM_PMS,\n    /** The localized characters */\n    UDAT_LOCALIZED_CHARS,\n    /** The long era names, for example Anno Domini */\n    UDAT_ERA_NAMES,\n    /** The narrow month names, for example F */\n    UDAT_NARROW_MONTHS,\n    /** The narrow weekday names, for example N */\n    UDAT_NARROW_WEEKDAYS,\n    /** Standalone context versions of months */\n    UDAT_STANDALONE_MONTHS,\n    UDAT_STANDALONE_SHORT_MONTHS,\n    UDAT_STANDALONE_NARROW_MONTHS,\n    /** Standalone context versions of weekdays */\n    UDAT_STANDALONE_WEEKDAYS,\n    UDAT_STANDALONE_SHORT_WEEKDAYS,\n    UDAT_STANDALONE_NARROW_WEEKDAYS,\n    /** The quarters, for example 1st Quarter */\n    UDAT_QUARTERS,\n    /** The short quarter names, for example Q1 */\n    UDAT_SHORT_QUARTERS,\n    /** Standalone context versions of quarters */\n    UDAT_STANDALONE_QUARTERS,\n    UDAT_STANDALONE_SHORT_QUARTERS\n\n} UDateFormatSymbolType;\n\nstruct UDateFormatSymbols;\n/** Date format symbols.\n *  For usage in C programs.\n *  @stable ICU 2.6\n */\ntypedef struct UDateFormatSymbols UDateFormatSymbols;\n\n/**\n* Get the symbols associated with an UDateFormat.\n* The symbols are what a UDateFormat uses to represent locale-specific data,\n* for example month or day names.\n* @param fmt The formatter to query.\n* @param type The type of symbols to get.  One of UDAT_ERAS, UDAT_MONTHS, UDAT_SHORT_MONTHS,\n* UDAT_WEEKDAYS, UDAT_SHORT_WEEKDAYS, UDAT_AM_PMS, or UDAT_LOCALIZED_CHARS\n* @param symbolIndex The desired symbol of type type.\n* @param result A pointer to a buffer to receive the pattern.\n* @param resultLength The maximum size of result.\n* @param status A pointer to an UErrorCode to receive any errors\n* @return The total buffer size needed; if greater than resultLength, the output was truncated.\n* @see udat_countSymbols\n* @see udat_setSymbols\n* @stable ICU 2.0\n*/\nU_STABLE int32_t U_EXPORT2 \nudat_getSymbols(const   UDateFormat             *fmt,\n                        UDateFormatSymbolType   type,\n                        int32_t                 symbolIndex,\n                        UChar                   *result,\n                        int32_t                 resultLength,\n                        UErrorCode              *status);\n\n/**\n* Count the number of particular symbols for an UDateFormat.\n* This function is most useful as for detemining the loop termination condition\n* for calls to {@link #udat_getSymbols }.\n* @param fmt The formatter to query.\n* @param type The type of symbols to count.  One of UDAT_ERAS, UDAT_MONTHS, UDAT_SHORT_MONTHS,\n* UDAT_WEEKDAYS, UDAT_SHORT_WEEKDAYS, UDAT_AM_PMS, or UDAT_LOCALIZED_CHARS\n* @return The number of symbols of type type.\n* @see udat_getSymbols\n* @see udat_setSymbols\n* @stable ICU 2.0\n*/\nU_STABLE int32_t U_EXPORT2 \nudat_countSymbols(    const    UDateFormat                *fmt,\n                            UDateFormatSymbolType    type);\n\n/**\n* Set the symbols associated with an UDateFormat.\n* The symbols are what a UDateFormat uses to represent locale-specific data,\n* for example month or day names.\n* @param format The formatter to set\n* @param type The type of symbols to set.  One of UDAT_ERAS, UDAT_MONTHS, UDAT_SHORT_MONTHS,\n* UDAT_WEEKDAYS, UDAT_SHORT_WEEKDAYS, UDAT_AM_PMS, or UDAT_LOCALIZED_CHARS\n* @param symbolIndex The index of the symbol to set of type type.\n* @param value The new value\n* @param valueLength The length of value, or -1 if null-terminated\n* @param status A pointer to an UErrorCode to receive any errors\n* @see udat_getSymbols\n* @see udat_countSymbols\n* @stable ICU 2.0\n*/\nU_STABLE void U_EXPORT2 \nudat_setSymbols(    UDateFormat             *format,\n                    UDateFormatSymbolType   type,\n                    int32_t                 symbolIndex,\n                    UChar                   *value,\n                    int32_t                 valueLength,\n                    UErrorCode              *status);\n\n/**\n * Get the locale for this date format object.\n * You can choose between valid and actual locale.\n * @param fmt The formatter to get the locale from\n * @param type type of the locale we're looking for (valid or actual) \n * @param status error code for the operation\n * @return the locale name\n * @stable ICU 2.8\n */\nU_STABLE const char* U_EXPORT2\nudat_getLocaleByType(const UDateFormat *fmt,\n                     ULocDataLocaleType type,\n                     UErrorCode* status); \n\n#ifndef U_HIDE_INTERNAL_API\n/**\n * Set a particular UDisplayContext value in the formatter, such as\n * UDISPCTX_CAPITALIZATION_FOR_STANDALONE.\n * @param fmt The formatter for which to set a UDisplayContext value.\n * @param value The UDisplayContext value to set.\n * @param status A pointer to an UErrorCode to receive any errors\n * @internal ICU 50 technology preview\n */\nU_INTERNAL void U_EXPORT2\nudat_setContext(UDateFormat* fmt, UDisplayContext value, UErrorCode* status);\n\n/**\n * Get the formatter's UDisplayContext value for the specified UDisplayContextType,\n * such as UDISPCTX_TYPE_CAPITALIZATION.\n * @param fmt The formatter to query.\n * @param type The UDisplayContextType whose value to return\n * @param status A pointer to an UErrorCode to receive any errors\n * @return The UDisplayContextValue for the specified type.\n * @internal ICU 50 technology preview\n */\nU_INTERNAL UDisplayContext U_EXPORT2\nudat_getContext(UDateFormat* fmt, UDisplayContextType type, UErrorCode* status);\n\n#endif  /* U_HIDE_INTERNAL_API */\n\n#ifndef U_HIDE_INTERNAL_API\n/**\n* Extract the date pattern from a UDateFormat set for relative date formatting.\n* The pattern will follow the pattern syntax rules.\n* @param fmt The formatter to query.\n* @param result A pointer to a buffer to receive the pattern.\n* @param resultLength The maximum size of result.\n* @param status A pointer to a UErrorCode to receive any errors\n* @return The total buffer size needed; if greater than resultLength, the output was truncated.\n* @see udat_applyPatternRelative\n* @internal ICU 4.2 technology preview\n*/\nU_INTERNAL int32_t U_EXPORT2 \nudat_toPatternRelativeDate(const UDateFormat *fmt,\n                           UChar             *result,\n                           int32_t           resultLength,\n                           UErrorCode        *status);\n\n/**\n* Extract the time pattern from a UDateFormat set for relative date formatting.\n* The pattern will follow the pattern syntax rules.\n* @param fmt The formatter to query.\n* @param result A pointer to a buffer to receive the pattern.\n* @param resultLength The maximum size of result.\n* @param status A pointer to a UErrorCode to receive any errors\n* @return The total buffer size needed; if greater than resultLength, the output was truncated.\n* @see udat_applyPatternRelative\n* @internal ICU 4.2 technology preview\n*/\nU_INTERNAL int32_t U_EXPORT2 \nudat_toPatternRelativeTime(const UDateFormat *fmt,\n                           UChar             *result,\n                           int32_t           resultLength,\n                           UErrorCode        *status);\n\n/**\n* Set the date & time patterns used by a UDateFormat set for relative date formatting.\n* The patterns should follow the pattern syntax rules.\n* @param format The formatter to set.\n* @param datePattern The new date pattern\n* @param datePatternLength The length of datePattern, or -1 if null-terminated.\n* @param timePattern The new time pattern\n* @param timePatternLength The length of timePattern, or -1 if null-terminated.\n* @param status A pointer to a UErrorCode to receive any errors\n* @see udat_toPatternRelativeDate, udat_toPatternRelativeTime\n* @internal ICU 4.2 technology preview\n*/\nU_INTERNAL void U_EXPORT2 \nudat_applyPatternRelative(UDateFormat *format,\n                          const UChar *datePattern,\n                          int32_t     datePatternLength,\n                          const UChar *timePattern,\n                          int32_t     timePatternLength,\n                          UErrorCode  *status);\n#endif  /* U_HIDE_INTERNAL_API */\n\n/**\n * @internal\n * @see udat_open\n */\ntypedef UDateFormat* (U_EXPORT2 *UDateFormatOpener) (UDateFormatStyle  timeStyle,\n                                                    UDateFormatStyle  dateStyle,\n                                                    const char        *locale,\n                                                    const UChar       *tzID,\n                                                    int32_t           tzIDLength,\n                                                    const UChar       *pattern,\n                                                    int32_t           patternLength,\n                                                    UErrorCode        *status);\n\n/**\n * Register a provider factory\n * @internal ICU 49\n */\nU_INTERNAL void U_EXPORT2\nudat_registerOpener(UDateFormatOpener opener, UErrorCode *status);\n\n/**\n * Un-Register a provider factory\n * @internal ICU 49\n */\nU_INTERNAL UDateFormatOpener U_EXPORT2\nudat_unregisterOpener(UDateFormatOpener opener, UErrorCode *status);\n\n\n#endif /* #if !UCONFIG_NO_FORMATTING */\n\n#endif\n"
  },
  {
    "path": "deprecated/android/addons/icucompat/unicode/udata.h",
    "content": "/*\n******************************************************************************\n*\n*   Copyright (C) 1999-2012, International Business Machines\n*   Corporation and others.  All Rights Reserved.\n*\n******************************************************************************\n*   file name:  udata.h\n*   encoding:   US-ASCII\n*   tab size:   8 (not used)\n*   indentation:4\n*\n*   created on: 1999oct25\n*   created by: Markus W. Scherer\n*/\n\n#ifndef __UDATA_H__\n#define __UDATA_H__\n\n#include \"unicode/utypes.h\"\n#include \"unicode/localpointer.h\"\n\nU_CDECL_BEGIN\n\n/**\n * \\file\n * \\brief C API: Data loading interface\n *\n * <h2>Information about data loading interface</h2>\n *\n * This API is used to find and efficiently load data for ICU and applications\n * using ICU. It provides an abstract interface that specifies a data type and\n * name to find and load the data. Normally this API is used by other ICU APIs\n * to load required data out of the ICU data library, but it can be used to\n * load data out of other places.\n *\n * See the User Guide Data Management chapter.\n */\n \n#ifndef U_HIDE_INTERNAL_API\n/**\n * Character used to separate package names from tree names \n * @internal ICU 3.0\n */\n#define U_TREE_SEPARATOR '-'\n\n/**\n * String used to separate package names from tree names \n * @internal ICU 3.0\n */\n#define U_TREE_SEPARATOR_STRING \"-\"\n\n/**\n * Character used to separate parts of entry names\n * @internal ICU 3.0\n */\n#define U_TREE_ENTRY_SEP_CHAR '/'\n\n/**\n * String used to separate parts of entry names\n * @internal ICU 3.0\n */\n#define U_TREE_ENTRY_SEP_STRING \"/\"\n\n/**\n * Alias for standard ICU data \n * @internal ICU 3.0\n */\n#define U_ICUDATA_ALIAS \"ICUDATA\"\n\n#endif /* U_HIDE_INTERNAL_API */\n\n/**\n * UDataInfo contains the properties about the requested data.\n * This is meta data.\n *\n * <p>This structure may grow in the future, indicated by the\n * <code>size</code> field.</p>\n *\n * <p>The platform data property fields help determine if a data\n * file can be efficiently used on a given machine.\n * The particular fields are of importance only if the data\n * is affected by the properties - if there is integer data\n * with word sizes > 1 byte, char* text, or UChar* text.</p>\n *\n * <p>The implementation for the <code>udata_open[Choice]()</code>\n * functions may reject data based on the value in <code>isBigEndian</code>.\n * No other field is used by the <code>udata</code> API implementation.</p>\n *\n * <p>The <code>dataFormat</code> may be used to identify\n * the kind of data, e.g. a converter table.</p>\n *\n * <p>The <code>formatVersion</code> field should be used to\n * make sure that the format can be interpreted.\n * I may be a good idea to check only for the one or two highest\n * of the version elements to allow the data memory to\n * get more or somewhat rearranged contents, for as long\n * as the using code can still interpret the older contents.</p>\n *\n * <p>The <code>dataVersion</code> field is intended to be a\n * common place to store the source version of the data;\n * for data from the Unicode character database, this could\n * reflect the Unicode version.</p>\n * @stable ICU 2.0\n */\ntypedef struct {\n    /** sizeof(UDataInfo)\n     *  @stable ICU 2.0 */\n    uint16_t size;\n\n    /** unused, set to 0 \n     *  @stable ICU 2.0*/\n    uint16_t reservedWord;\n\n    /* platform data properties */\n    /** 0 for little-endian machine, 1 for big-endian\n     *  @stable ICU 2.0 */\n    uint8_t isBigEndian;\n\n    /** see U_CHARSET_FAMILY values in utypes.h \n     *  @stable ICU 2.0*/\n    uint8_t charsetFamily;\n\n    /** sizeof(UChar), one of { 1, 2, 4 } \n     *  @stable ICU 2.0*/\n    uint8_t sizeofUChar;\n\n    /** unused, set to 0 \n     *  @stable ICU 2.0*/\n    uint8_t reservedByte;\n\n    /** data format identifier \n     *  @stable ICU 2.0*/\n    uint8_t dataFormat[4];\n\n    /** versions: [0] major [1] minor [2] milli [3] micro \n     *  @stable ICU 2.0*/\n    uint8_t formatVersion[4];\n\n    /** versions: [0] major [1] minor [2] milli [3] micro \n     *  @stable ICU 2.0*/\n    uint8_t dataVersion[4];\n} UDataInfo;\n\n/* API for reading data -----------------------------------------------------*/\n\n/**\n * Forward declaration of the data memory type.\n * @stable ICU 2.0\n */\ntypedef struct UDataMemory UDataMemory;\n\n/**\n * Callback function for udata_openChoice().\n * @param context parameter passed into <code>udata_openChoice()</code>.\n * @param type The type of the data as passed into <code>udata_openChoice()</code>.\n *             It may be <code>NULL</code>.\n * @param name The name of the data as passed into <code>udata_openChoice()</code>.\n * @param pInfo A pointer to the <code>UDataInfo</code> structure\n *              of data that has been loaded and will be returned\n *              by <code>udata_openChoice()</code> if this function\n *              returns <code>TRUE</code>.\n * @return TRUE if the current data memory is acceptable\n * @stable ICU 2.0\n */\ntypedef UBool U_CALLCONV\nUDataMemoryIsAcceptable(void *context,\n                        const char *type, const char *name,\n                        const UDataInfo *pInfo);\n\n\n/**\n * Convenience function.\n * This function works the same as <code>udata_openChoice</code>\n * except that any data that matches the type and name\n * is assumed to be acceptable.\n * @param path Specifies an absolute path and/or a basename for the\n *             finding of the data in the file system.\n *             <code>NULL</code> for ICU data.\n * @param type A string that specifies the type of data to be loaded.\n *             For example, resource bundles are loaded with type \"res\",\n *             conversion tables with type \"cnv\".\n *             This may be <code>NULL</code> or empty.\n * @param name A string that specifies the name of the data.\n * @param pErrorCode An ICU UErrorCode parameter. It must not be <code>NULL</code>.\n * @return A pointer (handle) to a data memory object, or <code>NULL</code>\n *         if an error occurs. Call <code>udata_getMemory()</code>\n *         to get a pointer to the actual data.\n *\n * @see udata_openChoice\n * @stable ICU 2.0\n */\nU_STABLE UDataMemory * U_EXPORT2\nudata_open(const char *path, const char *type, const char *name,\n           UErrorCode *pErrorCode);\n\n/**\n * Data loading function.\n * This function is used to find and load efficiently data for\n * ICU and applications using ICU.\n * It provides an abstract interface that allows to specify a data\n * type and name to find and load the data.\n *\n * <p>The implementation depends on platform properties and user preferences\n * and may involve loading shared libraries (DLLs), mapping\n * files into memory, or fopen()/fread() files.\n * It may also involve using static memory or database queries etc.\n * Several or all data items may be combined into one entity\n * (DLL, memory-mappable file).</p>\n *\n * <p>The data is always preceded by a header that includes\n * a <code>UDataInfo</code> structure.\n * The caller's <code>isAcceptable()</code> function is called to make\n * sure that the data is useful. It may be called several times if it\n * rejects the data and there is more than one location with data\n * matching the type and name.</p>\n *\n * <p>If <code>path==NULL</code>, then ICU data is loaded.\n * Otherwise, it is separated into a basename and a basename-less directory string.\n * The basename is used as the data package name, and the directory is\n * logically prepended to the ICU data directory string.</p>\n *\n * <p>For details about ICU data loading see the User Guide\n * Data Management chapter. (http://icu-project.org/userguide/icudata.html)</p>\n *\n * @param path Specifies an absolute path and/or a basename for the\n *             finding of the data in the file system.\n *             <code>NULL</code> for ICU data.\n * @param type A string that specifies the type of data to be loaded.\n *             For example, resource bundles are loaded with type \"res\",\n *             conversion tables with type \"cnv\".\n *             This may be <code>NULL</code> or empty.\n * @param name A string that specifies the name of the data.\n * @param isAcceptable This function is called to verify that loaded data\n *                     is useful for the client code. If it returns FALSE\n *                     for all data items, then <code>udata_openChoice()</code>\n *                     will return with an error.\n * @param context Arbitrary parameter to be passed into isAcceptable.\n * @param pErrorCode An ICU UErrorCode parameter. It must not be <code>NULL</code>.\n * @return A pointer (handle) to a data memory object, or <code>NULL</code>\n *         if an error occurs. Call <code>udata_getMemory()</code>\n *         to get a pointer to the actual data.\n * @stable ICU 2.0\n */\nU_STABLE UDataMemory * U_EXPORT2\nudata_openChoice(const char *path, const char *type, const char *name,\n                 UDataMemoryIsAcceptable *isAcceptable, void *context,\n                 UErrorCode *pErrorCode);\n\n/**\n * Close the data memory.\n * This function must be called to allow the system to\n * release resources associated with this data memory.\n * @param pData The pointer to data memory object\n * @stable ICU 2.0\n */\nU_STABLE void U_EXPORT2\nudata_close(UDataMemory *pData);\n\n#if U_SHOW_CPLUSPLUS_API\n\nU_NAMESPACE_BEGIN\n\n/**\n * \\class LocalUDataMemoryPointer\n * \"Smart pointer\" class, closes a UDataMemory via udata_close().\n * For most methods see the LocalPointerBase base class.\n *\n * @see LocalPointerBase\n * @see LocalPointer\n * @stable ICU 4.4\n */\nU_DEFINE_LOCAL_OPEN_POINTER(LocalUDataMemoryPointer, UDataMemory, udata_close);\n\nU_NAMESPACE_END\n\n#endif\n\n/**\n * Get the pointer to the actual data inside the data memory.\n * The data is read-only.\n * @param pData The pointer to data memory object\n * @stable ICU 2.0\n */\nU_STABLE const void * U_EXPORT2\nudata_getMemory(UDataMemory *pData);\n\n/**\n * Get the information from the data memory header.\n * This allows to get access to the header containing\n * platform data properties etc. which is not part of\n * the data itself and can therefore not be accessed\n * via the pointer that <code>udata_getMemory()</code> returns.\n *\n * @param pData pointer to the data memory object\n * @param pInfo pointer to a UDataInfo object;\n *              its <code>size</code> field must be set correctly,\n *              typically to <code>sizeof(UDataInfo)</code>.\n *\n * <code>*pInfo</code> will be filled with the UDataInfo structure\n * in the data memory object. If this structure is smaller than\n * <code>pInfo->size</code>, then the <code>size</code> will be\n * adjusted and only part of the structure will be filled.\n * @stable ICU 2.0\n */\nU_STABLE void U_EXPORT2\nudata_getInfo(UDataMemory *pData, UDataInfo *pInfo);\n\n/**\n * This function bypasses the normal ICU data loading process and\n * allows you to force ICU's system data to come out of a user-specified\n * area in memory.\n *\n * The format of this data is that of the icu common data file, as is\n * generated by the pkgdata tool with mode=common or mode=dll.\n * You can read in a whole common mode file and pass the address to the start of the\n * data, or (with the appropriate link options) pass in the pointer to\n * the data that has been loaded from a dll by the operating system,\n * as shown in this code:\n *\n *       extern const char U_IMPORT U_ICUDATA_ENTRY_POINT [];\n *        // U_ICUDATA_ENTRY_POINT is same as entry point specified to pkgdata tool\n *       UErrorCode  status = U_ZERO_ERROR;\n *\n *       udata_setCommonData(&U_ICUDATA_ENTRY_POINT, &status);\n *\n * It is important that the declaration be as above. The entry point\n * must not be declared as an extern void*.\n *\n * Starting with ICU 4.4, it is possible to set several data packages,\n * one per call to this function.\n * udata_open() will look for data in the multiple data packages in the order\n * in which they were set.\n * The position of the linked-in or default-name ICU .data package in the\n * search list depends on when the first data item is loaded that is not contained\n * in the already explicitly set packages.\n * If data was loaded implicitly before the first call to this function\n * (for example, via opening a converter, constructing a UnicodeString\n * from default-codepage data, using formatting or collation APIs, etc.),\n * then the default data will be first in the list.\n *\n * This function has no effect on application (non ICU) data.  See udata_setAppData()\n * for similar functionality for application data.\n *\n * @param data pointer to ICU common data\n * @param err outgoing error status <code>U_USING_DEFAULT_WARNING, U_UNSUPPORTED_ERROR</code>\n * @stable ICU 2.0\n */\nU_STABLE void U_EXPORT2\nudata_setCommonData(const void *data, UErrorCode *err);\n\n\n/**\n * This function bypasses the normal ICU data loading process for application-specific\n * data and allows you to force the it to come out of a user-specified\n * pointer.\n *\n * The format of this data is that of the icu common data file, like 'icudt26l.dat'\n * or the corresponding shared library (DLL) file.\n * The application must read in or otherwise construct an image of the data and then\n * pass the address of it to this function.\n *\n *\n * Warning:  setAppData will set a U_USING_DEFAULT_WARNING code if\n *           data with the specifed path that has already been opened, or\n *           if setAppData with the same path has already been called.\n *           Any such calls to setAppData will have no effect.\n *\n *\n * @param packageName the package name by which the application will refer\n *             to (open) this data\n * @param data pointer to the data\n * @param err outgoing error status <code>U_USING_DEFAULT_WARNING, U_UNSUPPORTED_ERROR</code>\n * @see udata_setCommonData\n * @stable ICU 2.0\n */\nU_STABLE void U_EXPORT2\nudata_setAppData(const char *packageName, const void *data, UErrorCode *err);\n\n/**\n * Possible settings for udata_setFileAccess()\n * @see udata_setFileAccess\n * @stable ICU 3.4\n */\ntypedef enum UDataFileAccess {\n    /** ICU looks for data in single files first, then in packages. (default) @stable ICU 3.4 */\n    UDATA_FILES_FIRST,\n    /** An alias for the default access mode. @stable ICU 3.4 */\n    UDATA_DEFAULT_ACCESS = UDATA_FILES_FIRST,\n    /** ICU only loads data from packages, not from single files. @stable ICU 3.4 */\n    UDATA_ONLY_PACKAGES,\n    /** ICU loads data from packages first, and only from single files\n        if the data cannot be found in a package. @stable ICU 3.4 */\n    UDATA_PACKAGES_FIRST,\n    /** ICU does not access the file system for data loading. @stable ICU 3.4 */\n    UDATA_NO_FILES,\n    /** Number of real UDataFileAccess values. @stable ICU 3.4 */\n    UDATA_FILE_ACCESS_COUNT\n} UDataFileAccess;\n\n/**\n * This function may be called to control how ICU loads data. It must be called\n * before any ICU data is loaded, including application data loaded with \n * ures/ResourceBundle or udata APIs. This function is not multithread safe.  \n * The results of calling it while other threads are loading data are undefined.\n * @param access The type of file access to be used\n * @param status Error code.\n * @see UDataFileAccess\n * @stable ICU 3.4 \n */\nU_STABLE void U_EXPORT2\nudata_setFileAccess(UDataFileAccess access, UErrorCode *status);\n\nU_CDECL_END\n\n#endif\n"
  },
  {
    "path": "deprecated/android/addons/icucompat/unicode/udateintervalformat.h",
    "content": "/*\n*****************************************************************************************\n* Copyright (C) 2010-2012, International Business Machines\n* Corporation and others. All Rights Reserved.\n*****************************************************************************************\n*/\n\n#ifndef UDATEINTERVALFORMAT_H\n#define UDATEINTERVALFORMAT_H\n\n#include \"unicode/utypes.h\"\n\n#if !UCONFIG_NO_FORMATTING\n\n#include \"unicode/umisc.h\"\n#include \"unicode/localpointer.h\"\n\n/**\n * \\file\n * \\brief C API: Format a date interval.\n *\n * A UDateIntervalFormat is used to format the range between two UDate values\n * in a locale-sensitive way, using a skeleton that specifies the precision and\n * completeness of the information to show. If the range smaller than the resolution\n * specified by the skeleton, a single date format will be produced. If the range\n * is larger than the format specified by the skeleton, a locale-specific fallback\n * will be used to format the items missing from the skeleton.\n *\n * For example, if the range is 2010-03-04 07:56 - 2010-03-04 19:56 (12 hours)\n * - The skeleton jm will produce\n *   for en_US, \"7:56 AM - 7:56 PM\"\n *   for en_GB, \"7:56 - 19:56\"\n * - The skeleton MMMd will produce\n *   for en_US, \"Mar 4\"\n *   for en_GB, \"4 Mar\"\n * If the range is 2010-03-04 07:56 - 2010-03-08 16:11 (4 days, 8 hours, 15 minutes)\n * - The skeleton jm will produce\n *   for en_US, \"3/4/2010 7:56 AM - 3/8/2010 4:11 PM\"\n *   for en_GB, \"4/3/2010 7:56 - 8/3/2010 16:11\"\n * - The skeleton MMMd will produce\n *   for en_US, \"Mar 4-8\"\n *   for en_GB, \"4-8 Mar\"\n * \n * Note:  the \"-\" characters in the above sample output will actually be\n * Unicode 2013, EN_DASH, in all but the last example.\n *\n * Note, in ICU 4.4 the standard skeletons for which date interval format data\n * is usually available are as follows; best results will be obtained by using\n * skeletons from this set, or those formed by combining these standard skeletons\n * (note that for these skeletons, the length of digit field such as d, y, or\n * M vs MM is irrelevant (but for non-digit fields such as MMM vs MMMM it is\n * relevant). Note that a skeleton involving h or H generally explicitly requests\n * that time style (12- or 24-hour time respectively). For a skeleton that\n * requests the locale's default time style (h or H), use 'j' instead of h or H.\n *   h, H, hm, Hm,\n *   hv, Hv, hmv, Hmv,\n *   d,\n *   M, MMM, MMMM,\n *   Md, MMMd,\n *   MEd, MMMEd,\n *   y,\n *   yM, yMMM, yMMMM,\n *   yMd, yMMMd,\n *   yMEd, yMMMEd\n *\n * Locales for which ICU 4.4 seems to have a reasonable amount of this data\n * include:\n *   af, am, ar, be, bg, bn, ca, cs, da, de (_AT), el, en (_AU,_CA,_GB,_IE,_IN...),\n *   eo, es (_AR,_CL,_CO,...,_US) et, fa, fi, fo, fr (_BE,_CH,_CA), fur, gsw, he,\n *   hr, hu, hy, is, it (_CH), ja, kk, km, ko, lt, lv, mk, ml, mt, nb, nl )_BE),\n *   nn, pl, pt (_PT), rm, ro, ru (_UA), sk, sl, so, sq, sr, sr_Latn, sv, th, to,\n *   tr, uk, ur, vi, zh (_SG), zh_Hant (_HK,_MO)\n */\n\n/**\n * Opaque UDateIntervalFormat object for use in C programs.\n * @stable ICU 4.8\n */\nstruct UDateIntervalFormat;\ntypedef struct UDateIntervalFormat UDateIntervalFormat;  /**< C typedef for struct UDateIntervalFormat. @stable ICU 4.8 */\n\n/**\n * Open a new UDateIntervalFormat object using the predefined rules for a\n * given locale plus a specified skeleton.\n * @param locale\n *            The locale for whose rules should be used; may be NULL for\n *            default locale.\n * @param skeleton\n *            A pattern containing only the fields desired for the interval\n *            format, for example \"Hm\", \"yMMMd\", or \"yMMMEdHm\".\n * @param skeletonLength\n *            The length of skeleton; may be -1 if the skeleton is zero-terminated.\n * @param tzID\n *            A timezone ID specifying the timezone to use. If 0, use the default\n *            timezone.\n * @param tzIDLength\n *            The length of tzID, or -1 if null-terminated. If 0, use the default\n *            timezone.\n * @param status\n *            A pointer to a UErrorCode to receive any errors.\n * @return\n *            A pointer to a UDateIntervalFormat object for the specified locale,\n *            or NULL if an error occurred.\n * @stable ICU 4.8\n */\nU_STABLE UDateIntervalFormat* U_EXPORT2\nudtitvfmt_open(const char*  locale,\n              const UChar* skeleton,\n              int32_t      skeletonLength,\n              const UChar* tzID,\n              int32_t      tzIDLength,\n              UErrorCode*  status);\n\n/**\n * Close a UDateIntervalFormat object. Once closed it may no longer be used.\n * @param formatter\n *            The UDateIntervalFormat object to close.\n * @stable ICU 4.8\n */\nU_STABLE void U_EXPORT2\nudtitvfmt_close(UDateIntervalFormat *formatter);\n\n\n#if U_SHOW_CPLUSPLUS_API\n\nU_NAMESPACE_BEGIN\n\n/**\n * \\class LocalUDateIntervalFormatPointer\n * \"Smart pointer\" class, closes a UDateIntervalFormat via udtitvfmt_close().\n * For most methods see the LocalPointerBase base class.\n *\n * @see LocalPointerBase\n * @see LocalPointer\n * @stable ICU 4.8\n */\nU_DEFINE_LOCAL_OPEN_POINTER(LocalUDateIntervalFormatPointer, UDateIntervalFormat, udtitvfmt_close);\n\nU_NAMESPACE_END\n\n#endif\n\n\n/**\n * Formats a date/time range using the conventions established for the\n * UDateIntervalFormat object.\n * @param formatter\n *            The UDateIntervalFormat object specifying the format conventions.\n * @param fromDate\n *            The starting point of the range.\n * @param toDate\n *            The ending point of the range.\n * @param result\n *            A pointer to a buffer to receive the formatted range.\n * @param resultCapacity\n *            The maximum size of result.\n * @param position\n *            A pointer to a UFieldPosition. On input, position->field is read.\n *            On output, position->beginIndex and position->endIndex indicate\n *            the beginning and ending indices of field number position->field,\n *            if such a field exists. This parameter may be NULL, in which case\n *            no field position data is returned.\n * @param status\n *            A pointer to a UErrorCode to receive any errors.\n * @return\n *            The total buffer size needed; if greater than resultLength, the\n *            output was truncated.\n * @stable ICU 4.8\n */\nU_STABLE int32_t U_EXPORT2\nudtitvfmt_format(const UDateIntervalFormat* formatter,\n                UDate           fromDate,\n                UDate           toDate,\n                UChar*          result,\n                int32_t         resultCapacity,\n                UFieldPosition* position,\n                UErrorCode*     status);\n\n#endif /* #if !UCONFIG_NO_FORMATTING */\n\n#endif\n"
  },
  {
    "path": "deprecated/android/addons/icucompat/unicode/udatpg.h",
    "content": "/*\n*******************************************************************************\n*\n*   Copyright (C) 2007-2012, International Business Machines\n*   Corporation and others.  All Rights Reserved.\n*\n*******************************************************************************\n*   file name:  udatpg.h\n*   encoding:   US-ASCII\n*   tab size:   8 (not used)\n*   indentation:4\n*\n*   created on: 2007jul30\n*   created by: Markus W. Scherer\n*/\n\n#ifndef __UDATPG_H__\n#define __UDATPG_H__\n\n#include \"unicode/utypes.h\"\n#include \"unicode/uenum.h\"\n#include \"unicode/localpointer.h\"\n\n/**\n * \\file\n * \\brief C API: Wrapper for icu::DateTimePatternGenerator (unicode/dtptngen.h).\n *\n * UDateTimePatternGenerator provides flexible generation of date format patterns, \n * like \"yy-MM-dd\". The user can build up the generator by adding successive \n * patterns. Once that is done, a query can be made using a \"skeleton\", which is \n * a pattern which just includes the desired fields and lengths. The generator \n * will return the \"best fit\" pattern corresponding to that skeleton.\n * <p>The main method people will use is udatpg_getBestPattern, since normally\n * UDateTimePatternGenerator is pre-built with data from a particular locale. \n * However, generators can be built directly from other data as well.\n * <p><i>Issue: may be useful to also have a function that returns the list of \n * fields in a pattern, in order, since we have that internally.\n * That would be useful for getting the UI order of field elements.</i>\n */\n\n/**\n * Opaque type for a date/time pattern generator object.\n * @stable ICU 3.8\n */\ntypedef void *UDateTimePatternGenerator;\n\n/**\n * Field number constants for udatpg_getAppendItemFormats() and similar functions.\n * These constants are separate from UDateFormatField despite semantic overlap\n * because some fields are merged for the date/time pattern generator.\n * @stable ICU 3.8\n */\ntypedef enum UDateTimePatternField {\n    /** @stable ICU 3.8 */\n    UDATPG_ERA_FIELD,\n    /** @stable ICU 3.8 */\n    UDATPG_YEAR_FIELD,\n    /** @stable ICU 3.8 */\n    UDATPG_QUARTER_FIELD,\n    /** @stable ICU 3.8 */\n    UDATPG_MONTH_FIELD,\n    /** @stable ICU 3.8 */\n    UDATPG_WEEK_OF_YEAR_FIELD,\n    /** @stable ICU 3.8 */\n    UDATPG_WEEK_OF_MONTH_FIELD,\n    /** @stable ICU 3.8 */\n    UDATPG_WEEKDAY_FIELD,\n    /** @stable ICU 3.8 */\n    UDATPG_DAY_OF_YEAR_FIELD,\n    /** @stable ICU 3.8 */\n    UDATPG_DAY_OF_WEEK_IN_MONTH_FIELD,\n    /** @stable ICU 3.8 */\n    UDATPG_DAY_FIELD,\n    /** @stable ICU 3.8 */\n    UDATPG_DAYPERIOD_FIELD,\n    /** @stable ICU 3.8 */\n    UDATPG_HOUR_FIELD,\n    /** @stable ICU 3.8 */\n    UDATPG_MINUTE_FIELD,\n    /** @stable ICU 3.8 */\n    UDATPG_SECOND_FIELD,\n    /** @stable ICU 3.8 */\n    UDATPG_FRACTIONAL_SECOND_FIELD,\n    /** @stable ICU 3.8 */\n    UDATPG_ZONE_FIELD,\n    /** @stable ICU 3.8 */\n    UDATPG_FIELD_COUNT\n} UDateTimePatternField;\n\n/**\n * Masks to control forcing the length of specified fields in the returned\n * pattern to match those in the skeleton (when this would not happen\n * otherwise). These may be combined to force the length of multiple fields.\n * Used with udatpg_getBestPatternWithOptions, udatpg_replaceFieldTypesWithOptions.\n * @stable ICU 4.4\n */\ntypedef enum UDateTimePatternMatchOptions {\n    /** @stable ICU 4.4 */\n    UDATPG_MATCH_NO_OPTIONS = 0,\n    /** @stable ICU 4.4 */\n    UDATPG_MATCH_HOUR_FIELD_LENGTH = 1 << UDATPG_HOUR_FIELD,\n#ifndef U_HIDE_INTERNAL_API\n    /** @internal ICU 4.4 */\n    UDATPG_MATCH_MINUTE_FIELD_LENGTH = 1 << UDATPG_MINUTE_FIELD,\n    /** @internal ICU 4.4 */\n    UDATPG_MATCH_SECOND_FIELD_LENGTH = 1 << UDATPG_SECOND_FIELD,\n#endif  /* U_HIDE_INTERNAL_API */\n    /** @stable ICU 4.4 */\n    UDATPG_MATCH_ALL_FIELDS_LENGTH = (1 << UDATPG_FIELD_COUNT) - 1\n} UDateTimePatternMatchOptions;\n\n/**\n * Status return values from udatpg_addPattern().\n * @stable ICU 3.8\n */\ntypedef enum UDateTimePatternConflict {\n    /** @stable ICU 3.8 */\n    UDATPG_NO_CONFLICT,\n    /** @stable ICU 3.8 */\n    UDATPG_BASE_CONFLICT,\n    /** @stable ICU 3.8 */\n    UDATPG_CONFLICT,\n    /** @stable ICU 3.8 */\n    UDATPG_CONFLICT_COUNT\n} UDateTimePatternConflict;\n\n/**\n  * Open a generator according to a given locale.\n  * @param locale\n  * @param pErrorCode a pointer to the UErrorCode which must not indicate a\n  *                   failure before the function call.\n  * @return a pointer to UDateTimePatternGenerator.\n  * @stable ICU 3.8\n  */\nU_STABLE UDateTimePatternGenerator * U_EXPORT2\nudatpg_open(const char *locale, UErrorCode *pErrorCode);\n\n/**\n  * Open an empty generator, to be constructed with udatpg_addPattern(...) etc.\n  * @param pErrorCode a pointer to the UErrorCode which must not indicate a\n  *                   failure before the function call.\n  * @return a pointer to UDateTimePatternGenerator.\n  * @stable ICU 3.8\n  */\nU_STABLE UDateTimePatternGenerator * U_EXPORT2\nudatpg_openEmpty(UErrorCode *pErrorCode);\n\n/**\n  * Close a generator.\n  * @param dtpg a pointer to UDateTimePatternGenerator.\n  * @stable ICU 3.8\n  */\nU_STABLE void U_EXPORT2\nudatpg_close(UDateTimePatternGenerator *dtpg);\n\n#if U_SHOW_CPLUSPLUS_API\n\nU_NAMESPACE_BEGIN\n\n/**\n * \\class LocalUDateTimePatternGeneratorPointer\n * \"Smart pointer\" class, closes a UDateTimePatternGenerator via udatpg_close().\n * For most methods see the LocalPointerBase base class.\n *\n * @see LocalPointerBase\n * @see LocalPointer\n * @stable ICU 4.4\n */\nU_DEFINE_LOCAL_OPEN_POINTER(LocalUDateTimePatternGeneratorPointer, UDateTimePatternGenerator, udatpg_close);\n\nU_NAMESPACE_END\n\n#endif\n\n/**\n  * Create a copy pf a generator.\n  * @param dtpg a pointer to UDateTimePatternGenerator to be copied.\n  * @param pErrorCode a pointer to the UErrorCode which must not indicate a\n  *                   failure before the function call.\n  * @return a pointer to a new UDateTimePatternGenerator.\n  * @stable ICU 3.8\n */\nU_STABLE UDateTimePatternGenerator * U_EXPORT2\nudatpg_clone(const UDateTimePatternGenerator *dtpg, UErrorCode *pErrorCode);\n\n/**\n * Get the best pattern matching the input skeleton. It is guaranteed to\n * have all of the fields in the skeleton.\n * \n * Note that this function uses a non-const UDateTimePatternGenerator:\n * It uses a stateful pattern parser which is set up for each generator object,\n * rather than creating one for each function call.\n * Consecutive calls to this function do not affect each other,\n * but this function cannot be used concurrently on a single generator object.\n * \n * @param dtpg a pointer to UDateTimePatternGenerator.\n * @param skeleton\n *            The skeleton is a pattern containing only the variable fields.\n *            For example, \"MMMdd\" and \"mmhh\" are skeletons.\n * @param length the length of skeleton\n * @param bestPattern\n *            The best pattern found from the given skeleton.\n * @param capacity the capacity of bestPattern.\n * @param pErrorCode a pointer to the UErrorCode which must not indicate a\n *                   failure before the function call.\n * @return the length of bestPattern.\n * @stable ICU 3.8\n */\nU_STABLE int32_t U_EXPORT2\nudatpg_getBestPattern(UDateTimePatternGenerator *dtpg,\n                      const UChar *skeleton, int32_t length,\n                      UChar *bestPattern, int32_t capacity,\n                      UErrorCode *pErrorCode);\n\n/**\n * Get the best pattern matching the input skeleton. It is guaranteed to\n * have all of the fields in the skeleton.\n * \n * Note that this function uses a non-const UDateTimePatternGenerator:\n * It uses a stateful pattern parser which is set up for each generator object,\n * rather than creating one for each function call.\n * Consecutive calls to this function do not affect each other,\n * but this function cannot be used concurrently on a single generator object.\n * \n * @param dtpg a pointer to UDateTimePatternGenerator.\n * @param skeleton\n *            The skeleton is a pattern containing only the variable fields.\n *            For example, \"MMMdd\" and \"mmhh\" are skeletons.\n * @param length the length of skeleton\n * @param options\n *            Options for forcing the length of specified fields in the\n *            returned pattern to match those in the skeleton (when this\n *            would not happen otherwise). For default behavior, use\n *            UDATPG_MATCH_NO_OPTIONS.\n * @param bestPattern\n *            The best pattern found from the given skeleton.\n * @param capacity\n *            the capacity of bestPattern.\n * @param pErrorCode\n *            a pointer to the UErrorCode which must not indicate a\n *            failure before the function call.\n * @return the length of bestPattern.\n * @stable ICU 4.4\n */\nU_STABLE int32_t U_EXPORT2\nudatpg_getBestPatternWithOptions(UDateTimePatternGenerator *dtpg,\n                                 const UChar *skeleton, int32_t length,\n                                 UDateTimePatternMatchOptions options,\n                                 UChar *bestPattern, int32_t capacity,\n                                 UErrorCode *pErrorCode);\n\n/**\n  * Get a unique skeleton from a given pattern. For example,\n  * both \"MMM-dd\" and \"dd/MMM\" produce the skeleton \"MMMdd\".\n  * \n  * Note that this function uses a non-const UDateTimePatternGenerator:\n  * It uses a stateful pattern parser which is set up for each generator object,\n  * rather than creating one for each function call.\n  * Consecutive calls to this function do not affect each other,\n  * but this function cannot be used concurrently on a single generator object.\n  *\n  * @param dtpg     a pointer to UDateTimePatternGenerator.\n  * @param pattern  input pattern, such as \"dd/MMM\".\n  * @param length   the length of pattern.\n  * @param skeleton such as \"MMMdd\"\n  * @param capacity the capacity of skeleton.\n  * @param pErrorCode a pointer to the UErrorCode which must not indicate a\n  *                  failure before the function call.\n  * @return the length of skeleton.\n  * @stable ICU 3.8\n  */\nU_STABLE int32_t U_EXPORT2\nudatpg_getSkeleton(UDateTimePatternGenerator *dtpg,\n                   const UChar *pattern, int32_t length,\n                   UChar *skeleton, int32_t capacity,\n                   UErrorCode *pErrorCode);\n\n/**\n * Get a unique base skeleton from a given pattern. This is the same\n * as the skeleton, except that differences in length are minimized so\n * as to only preserve the difference between string and numeric form. So\n * for example, both \"MMM-dd\" and \"d/MMM\" produce the skeleton \"MMMd\"\n * (notice the single d).\n *\n * Note that this function uses a non-const UDateTimePatternGenerator:\n * It uses a stateful pattern parser which is set up for each generator object,\n * rather than creating one for each function call.\n * Consecutive calls to this function do not affect each other,\n * but this function cannot be used concurrently on a single generator object.\n *\n * @param dtpg     a pointer to UDateTimePatternGenerator.\n * @param pattern  input pattern, such as \"dd/MMM\".\n * @param length   the length of pattern.\n * @param baseSkeleton such as \"Md\"\n * @param capacity the capacity of base skeleton.\n * @param pErrorCode a pointer to the UErrorCode which must not indicate a\n *                  failure before the function call.\n * @return the length of baseSkeleton.\n * @stable ICU 3.8\n */\nU_STABLE int32_t U_EXPORT2\nudatpg_getBaseSkeleton(UDateTimePatternGenerator *dtpg,\n                       const UChar *pattern, int32_t length,\n                       UChar *baseSkeleton, int32_t capacity,\n                       UErrorCode *pErrorCode);\n\n/**\n * Adds a pattern to the generator. If the pattern has the same skeleton as\n * an existing pattern, and the override parameter is set, then the previous\n * value is overriden. Otherwise, the previous value is retained. In either\n * case, the conflicting status is set and previous vale is stored in \n * conflicting pattern.\n * <p>\n * Note that single-field patterns (like \"MMM\") are automatically added, and\n * don't need to be added explicitly!\n *\n * @param dtpg     a pointer to UDateTimePatternGenerator.\n * @param pattern  input pattern, such as \"dd/MMM\"\n * @param patternLength the length of pattern.\n * @param override  When existing values are to be overridden use true, \n *                  otherwise use false.\n * @param conflictingPattern  Previous pattern with the same skeleton.\n * @param capacity the capacity of conflictingPattern.\n * @param pLength a pointer to the length of conflictingPattern.\n * @param pErrorCode a pointer to the UErrorCode which must not indicate a\n *                  failure before the function call.\n * @return conflicting status. The value could be UDATPG_NO_CONFLICT, \n *                  UDATPG_BASE_CONFLICT or UDATPG_CONFLICT.\n * @stable ICU 3.8\n */\nU_STABLE UDateTimePatternConflict U_EXPORT2\nudatpg_addPattern(UDateTimePatternGenerator *dtpg,\n                  const UChar *pattern, int32_t patternLength,\n                  UBool override,\n                  UChar *conflictingPattern, int32_t capacity, int32_t *pLength,\n                  UErrorCode *pErrorCode);\n\n/**\n  * An AppendItem format is a pattern used to append a field if there is no\n  * good match. For example, suppose that the input skeleton is \"GyyyyMMMd\",\n  * and there is no matching pattern internally, but there is a pattern\n  * matching \"yyyyMMMd\", say \"d-MM-yyyy\". Then that pattern is used, plus the\n  * G. The way these two are conjoined is by using the AppendItemFormat for G\n  * (era). So if that value is, say \"{0}, {1}\" then the final resulting\n  * pattern is \"d-MM-yyyy, G\".\n  * <p>\n  * There are actually three available variables: {0} is the pattern so far,\n  * {1} is the element we are adding, and {2} is the name of the element.\n  * <p>\n  * This reflects the way that the CLDR data is organized.\n  *\n  * @param dtpg   a pointer to UDateTimePatternGenerator.\n  * @param field  UDateTimePatternField, such as UDATPG_ERA_FIELD\n  * @param value  pattern, such as \"{0}, {1}\"\n  * @param length the length of value.\n  * @stable ICU 3.8\n  */\nU_STABLE void U_EXPORT2\nudatpg_setAppendItemFormat(UDateTimePatternGenerator *dtpg,\n                           UDateTimePatternField field,\n                           const UChar *value, int32_t length);\n\n/**\n * Getter corresponding to setAppendItemFormat. Values below 0 or at or\n * above UDATPG_FIELD_COUNT are illegal arguments.\n *\n * @param dtpg   A pointer to UDateTimePatternGenerator.\n * @param field  UDateTimePatternField, such as UDATPG_ERA_FIELD\n * @param pLength A pointer that will receive the length of appendItemFormat.\n * @return appendItemFormat for field.\n * @stable ICU 3.8\n */\nU_STABLE const UChar * U_EXPORT2\nudatpg_getAppendItemFormat(const UDateTimePatternGenerator *dtpg,\n                           UDateTimePatternField field,\n                           int32_t *pLength);\n\n/**\n   * Set the name of field, eg \"era\" in English for ERA. These are only\n   * used if the corresponding AppendItemFormat is used, and if it contains a\n   * {2} variable.\n   * <p>\n   * This reflects the way that the CLDR data is organized.\n   *\n   * @param dtpg   a pointer to UDateTimePatternGenerator.\n   * @param field  UDateTimePatternField\n   * @param value  name for the field.\n   * @param length the length of value.\n   * @stable ICU 3.8\n   */\nU_STABLE void U_EXPORT2\nudatpg_setAppendItemName(UDateTimePatternGenerator *dtpg,\n                         UDateTimePatternField field,\n                         const UChar *value, int32_t length);\n\n/**\n * Getter corresponding to setAppendItemNames. Values below 0 or at or above\n * UDATPG_FIELD_COUNT are illegal arguments.\n *\n * @param dtpg   a pointer to UDateTimePatternGenerator.\n * @param field  UDateTimePatternField, such as UDATPG_ERA_FIELD\n * @param pLength A pointer that will receive the length of the name for field.\n * @return name for field\n * @stable ICU 3.8\n */\nU_STABLE const UChar * U_EXPORT2\nudatpg_getAppendItemName(const UDateTimePatternGenerator *dtpg,\n                         UDateTimePatternField field,\n                         int32_t *pLength);\n\n/**\n * The date time format is a message format pattern used to compose date and\n * time patterns. The default value is \"{0} {1}\", where {0} will be replaced\n * by the date pattern and {1} will be replaced by the time pattern.\n * <p>\n * This is used when the input skeleton contains both date and time fields,\n * but there is not a close match among the added patterns. For example,\n * suppose that this object was created by adding \"dd-MMM\" and \"hh:mm\", and\n * its datetimeFormat is the default \"{0} {1}\". Then if the input skeleton\n * is \"MMMdhmm\", there is not an exact match, so the input skeleton is\n * broken up into two components \"MMMd\" and \"hmm\". There are close matches\n * for those two skeletons, so the result is put together with this pattern,\n * resulting in \"d-MMM h:mm\".\n *\n * @param dtpg a pointer to UDateTimePatternGenerator.\n * @param dtFormat\n *            message format pattern, here {0} will be replaced by the date\n *            pattern and {1} will be replaced by the time pattern.\n * @param length the length of dtFormat.\n * @stable ICU 3.8\n */\nU_STABLE void U_EXPORT2\nudatpg_setDateTimeFormat(const UDateTimePatternGenerator *dtpg,\n                         const UChar *dtFormat, int32_t length);\n\n/**\n * Getter corresponding to setDateTimeFormat.\n * @param dtpg   a pointer to UDateTimePatternGenerator.\n * @param pLength A pointer that will receive the length of the format\n * @return dateTimeFormat.\n * @stable ICU 3.8\n */\nU_STABLE const UChar * U_EXPORT2\nudatpg_getDateTimeFormat(const UDateTimePatternGenerator *dtpg,\n                         int32_t *pLength);\n\n/**\n * The decimal value is used in formatting fractions of seconds. If the\n * skeleton contains fractional seconds, then this is used with the\n * fractional seconds. For example, suppose that the input pattern is\n * \"hhmmssSSSS\", and the best matching pattern internally is \"H:mm:ss\", and\n * the decimal string is \",\". Then the resulting pattern is modified to be\n * \"H:mm:ss,SSSS\"\n *\n * @param dtpg a pointer to UDateTimePatternGenerator.\n * @param decimal\n * @param length the length of decimal.\n * @stable ICU 3.8\n */\nU_STABLE void U_EXPORT2\nudatpg_setDecimal(UDateTimePatternGenerator *dtpg,\n                  const UChar *decimal, int32_t length);\n\n/**\n * Getter corresponding to setDecimal.\n * \n * @param dtpg a pointer to UDateTimePatternGenerator.\n * @param pLength A pointer that will receive the length of the decimal string.\n * @return corresponding to the decimal point.\n * @stable ICU 3.8\n */\nU_STABLE const UChar * U_EXPORT2\nudatpg_getDecimal(const UDateTimePatternGenerator *dtpg,\n                  int32_t *pLength);\n\n/**\n * Adjusts the field types (width and subtype) of a pattern to match what is\n * in a skeleton. That is, if you supply a pattern like \"d-M H:m\", and a\n * skeleton of \"MMMMddhhmm\", then the input pattern is adjusted to be\n * \"dd-MMMM hh:mm\". This is used internally to get the best match for the\n * input skeleton, but can also be used externally.\n *\n * Note that this function uses a non-const UDateTimePatternGenerator:\n * It uses a stateful pattern parser which is set up for each generator object,\n * rather than creating one for each function call.\n * Consecutive calls to this function do not affect each other,\n * but this function cannot be used concurrently on a single generator object.\n *\n * @param dtpg a pointer to UDateTimePatternGenerator.\n * @param pattern Input pattern\n * @param patternLength the length of input pattern.\n * @param skeleton\n * @param skeletonLength the length of input skeleton.\n * @param dest  pattern adjusted to match the skeleton fields widths and subtypes.\n * @param destCapacity the capacity of dest.\n * @param pErrorCode a pointer to the UErrorCode which must not indicate a\n *                  failure before the function call.\n * @return the length of dest.\n * @stable ICU 3.8\n */\nU_STABLE int32_t U_EXPORT2\nudatpg_replaceFieldTypes(UDateTimePatternGenerator *dtpg,\n                         const UChar *pattern, int32_t patternLength,\n                         const UChar *skeleton, int32_t skeletonLength,\n                         UChar *dest, int32_t destCapacity,\n                         UErrorCode *pErrorCode);\n\n/**\n * Adjusts the field types (width and subtype) of a pattern to match what is\n * in a skeleton. That is, if you supply a pattern like \"d-M H:m\", and a\n * skeleton of \"MMMMddhhmm\", then the input pattern is adjusted to be\n * \"dd-MMMM hh:mm\". This is used internally to get the best match for the\n * input skeleton, but can also be used externally.\n *\n * Note that this function uses a non-const UDateTimePatternGenerator:\n * It uses a stateful pattern parser which is set up for each generator object,\n * rather than creating one for each function call.\n * Consecutive calls to this function do not affect each other,\n * but this function cannot be used concurrently on a single generator object.\n *\n * @param dtpg a pointer to UDateTimePatternGenerator.\n * @param pattern Input pattern\n * @param patternLength the length of input pattern.\n * @param skeleton\n * @param skeletonLength the length of input skeleton.\n * @param options\n *            Options controlling whether the length of specified fields in the\n *            pattern are adjusted to match those in the skeleton (when this\n *            would not happen otherwise). For default behavior, use\n *            UDATPG_MATCH_NO_OPTIONS.\n * @param dest  pattern adjusted to match the skeleton fields widths and subtypes.\n * @param destCapacity the capacity of dest.\n * @param pErrorCode a pointer to the UErrorCode which must not indicate a\n *                  failure before the function call.\n * @return the length of dest.\n * @stable ICU 4.4\n */\nU_STABLE int32_t U_EXPORT2\nudatpg_replaceFieldTypesWithOptions(UDateTimePatternGenerator *dtpg,\n                                    const UChar *pattern, int32_t patternLength,\n                                    const UChar *skeleton, int32_t skeletonLength,\n                                    UDateTimePatternMatchOptions options,\n                                    UChar *dest, int32_t destCapacity,\n                                    UErrorCode *pErrorCode);\n\n/**\n * Return a UEnumeration list of all the skeletons in canonical form.\n * Call udatpg_getPatternForSkeleton() to get the corresponding pattern.\n * \n * @param dtpg a pointer to UDateTimePatternGenerator.\n * @param pErrorCode a pointer to the UErrorCode which must not indicate a\n *                  failure before the function call\n * @return a UEnumeration list of all the skeletons\n *         The caller must close the object.\n * @stable ICU 3.8\n */\nU_STABLE UEnumeration * U_EXPORT2\nudatpg_openSkeletons(const UDateTimePatternGenerator *dtpg, UErrorCode *pErrorCode);\n\n/**\n * Return a UEnumeration list of all the base skeletons in canonical form.\n *\n * @param dtpg a pointer to UDateTimePatternGenerator.\n * @param pErrorCode a pointer to the UErrorCode which must not indicate a\n *             failure before the function call.\n * @return a UEnumeration list of all the base skeletons\n *             The caller must close the object.\n * @stable ICU 3.8\n */\nU_STABLE UEnumeration * U_EXPORT2\nudatpg_openBaseSkeletons(const UDateTimePatternGenerator *dtpg, UErrorCode *pErrorCode);\n\n/**\n * Get the pattern corresponding to a given skeleton.\n * \n * @param dtpg a pointer to UDateTimePatternGenerator.\n * @param skeleton \n * @param skeletonLength pointer to the length of skeleton.\n * @param pLength pointer to the length of return pattern.\n * @return pattern corresponding to a given skeleton.\n * @stable ICU 3.8\n */\nU_STABLE const UChar * U_EXPORT2\nudatpg_getPatternForSkeleton(const UDateTimePatternGenerator *dtpg,\n                             const UChar *skeleton, int32_t skeletonLength,\n                             int32_t *pLength);\n\n#endif\n"
  },
  {
    "path": "deprecated/android/addons/icucompat/unicode/udisplaycontext.h",
    "content": "/*\n*****************************************************************************************\n* Copyright (C) 2012, International Business Machines\n* Corporation and others. All Rights Reserved.\n*****************************************************************************************\n*/\n\n#ifndef UDISPLAYCONTEXT_H\n#define UDISPLAYCONTEXT_H\n\n#include \"unicode/utypes.h\"\n\n#if !UCONFIG_NO_FORMATTING\n\n/* Dont hide with #ifndef U_HIDE_INTERNAL_API, needed by virtual methods */\n/**\n * Display context types, for getting values of a particular setting.\n * Note, the specific numeric values are internal and may change.\n * @internal ICU 50 technology preview\n */\nenum UDisplayContextType {\n    /**\n     * Type to retrieve the dialect handling setting, e.g.\n     * UDISPCTX_STANDARD_NAMES or UDISPCTX_DIALECT_NAMES.\n     * @internal ICU 50 technology preview\n     */\n    UDISPCTX_TYPE_DIALECT_HANDLING = 0,\n    /**\n     * Type to retrieve the capitalization context setting, e.g.\n     * UDISPCTX_CAPITALIZATION_NONE, UDISPCTX_CAPITALIZATION_FOR_MIDDLE_OF_SENTENCE,\n     * UDISPCTX_CAPITALIZATION_FOR_BEGINNING_OF_SENTENCE, etc.\n     * @internal ICU 50 technology preview\n     */\n    UDISPCTX_TYPE_CAPITALIZATION = 1\n};\n/**\n*  @internal ICU 50 technology preview\n*/\ntypedef enum UDisplayContextType UDisplayContextType;\n\n/* Dont hide with #ifndef U_HIDE_INTERNAL_API, needed by virtual methods */\n/**\n * Display context settings.\n * Note, the specific numeric values are internal and may change.\n * @internal ICU 50 technology preview\n */\nenum UDisplayContext {\n    /**\n     * ================================\n     * DIALECT_HANDLING can be set to one of UDISPCTX_STANDARD_NAMES or\n     * UDISPCTX_DIALECT_NAMES. Use UDisplayContextType UDISPCTX_TYPE_DIALECT_HANDLING\n     * to get the value.\n     */\n    /**\n     * A possible setting for DIALECT_HANDLING:\n     * use standard names when generating a locale name,\n     * e.g. en_GB displays as 'English (United Kingdom)'.\n     * @internal ICU 50 technology preview\n     */\n    UDISPCTX_STANDARD_NAMES = (UDISPCTX_TYPE_DIALECT_HANDLING<<8) + 0,\n    /**\n     * A possible setting for DIALECT_HANDLING:\n     * use dialect names, when generating a locale name,\n     * e.g. en_GB displays as 'British English'.\n     * @internal ICU 50 technology preview\n     */\n    UDISPCTX_DIALECT_NAMES = (UDISPCTX_TYPE_DIALECT_HANDLING<<8) + 1,\n    /**\n     * ================================\n     * CAPITALIZATION can be set to one of UDISPCTX_CAPITALIZATION_NONE,\n     * UDISPCTX_CAPITALIZATION_FOR_MIDDLE_OF_SENTENCE,\n     * UDISPCTX_CAPITALIZATION_FOR_BEGINNING_OF_SENTENCE,\n     * UDISPCTX_CAPITALIZATION_FOR_UI_LIST_OR_MENU, or\n     * UDISPCTX_CAPITALIZATION_FOR_STANDALONE.\n     * Use UDisplayContextType UDISPCTX_TYPE_CAPITALIZATION to get the value.\n     */\n    /**\n     * The capitalization context to be used is unknown (this is the default value).\n     * @internal ICU 50 technology preview\n     */\n    UDISPCTX_CAPITALIZATION_NONE = (UDISPCTX_TYPE_CAPITALIZATION<<8) + 0,\n    /**\n     * The capitalization context if a date, date symbol or display name is to be\n     * formatted with capitalization appropriate for the middle of a sentence.\n     * @internal ICU 50 technology preview\n     */\n    UDISPCTX_CAPITALIZATION_FOR_MIDDLE_OF_SENTENCE = (UDISPCTX_TYPE_CAPITALIZATION<<8) + 1,\n    /**\n     * The capitalization context if a date, date symbol or display name is to be\n     * formatted with capitalization appropriate for the beginning of a sentence.\n     * @internal ICU 50 technology preview\n     */\n    UDISPCTX_CAPITALIZATION_FOR_BEGINNING_OF_SENTENCE = (UDISPCTX_TYPE_CAPITALIZATION<<8) + 2,\n    /**\n     * The capitalization context if a date, date symbol or display name is to be\n     * formatted with capitalization appropriate for a user-interface list or menu item.\n     * @internal ICU 50 technology preview\n     */\n    UDISPCTX_CAPITALIZATION_FOR_UI_LIST_OR_MENU = (UDISPCTX_TYPE_CAPITALIZATION<<8) + 3,\n    /**\n     * The capitalization context if a date, date symbol or display name is to be\n     * formatted with capitalization appropriate for stand-alone usage such as an\n     * isolated name on a calendar page.\n     * @internal ICU 50 technology preview\n     */\n    UDISPCTX_CAPITALIZATION_FOR_STANDALONE = (UDISPCTX_TYPE_CAPITALIZATION<<8) + 4\n};\n/**\n*  @internal ICU 50 technology preview\n*/\ntypedef enum UDisplayContext UDisplayContext;\n\n#endif /* #if !UCONFIG_NO_FORMATTING */\n\n#endif\n"
  },
  {
    "path": "deprecated/android/addons/icucompat/unicode/uenum.h",
    "content": "/*\n*******************************************************************************\n*\n*   Copyright (C) 2002-2012, International Business Machines\n*   Corporation and others.  All Rights Reserved.\n*\n*******************************************************************************\n*   file name:  uenum.h\n*   encoding:   US-ASCII\n*   tab size:   8 (not used)\n*   indentation:2\n*\n*   created on: 2002jul08\n*   created by: Vladimir Weinstein\n*/\n\n#ifndef __UENUM_H\n#define __UENUM_H\n\n#include \"unicode/utypes.h\"\n#include \"unicode/localpointer.h\"\n\n#if U_SHOW_CPLUSPLUS_API\n#include \"unicode/strenum.h\"\n#endif\n\n/**\n * \\file\n * \\brief C API: String Enumeration \n */\n \n/**\n * An enumeration object.\n * For usage in C programs.\n * @stable ICU 2.2\n */\nstruct UEnumeration;\n/** structure representing an enumeration object instance @stable ICU 2.2 */\ntypedef struct UEnumeration UEnumeration;\n\n/**\n * Disposes of resources in use by the iterator.  If en is NULL,\n * does nothing.  After this call, any char* or UChar* pointer\n * returned by uenum_unext() or uenum_next() is invalid.\n * @param en UEnumeration structure pointer\n * @stable ICU 2.2\n */\nU_STABLE void U_EXPORT2\nuenum_close(UEnumeration* en);\n\n#if U_SHOW_CPLUSPLUS_API\n\nU_NAMESPACE_BEGIN\n\n/**\n * \\class LocalUEnumerationPointer\n * \"Smart pointer\" class, closes a UEnumeration via uenum_close().\n * For most methods see the LocalPointerBase base class.\n *\n * @see LocalPointerBase\n * @see LocalPointer\n * @stable ICU 4.4\n */\nU_DEFINE_LOCAL_OPEN_POINTER(LocalUEnumerationPointer, UEnumeration, uenum_close);\n\nU_NAMESPACE_END\n\n#endif\n\n/**\n * Returns the number of elements that the iterator traverses.  If\n * the iterator is out-of-sync with its service, status is set to\n * U_ENUM_OUT_OF_SYNC_ERROR.\n * This is a convenience function. It can end up being very\n * expensive as all the items might have to be pre-fetched (depending\n * on the type of data being traversed). Use with caution and only \n * when necessary.\n * @param en UEnumeration structure pointer\n * @param status error code, can be U_ENUM_OUT_OF_SYNC_ERROR if the\n *               iterator is out of sync.\n * @return number of elements in the iterator\n * @stable ICU 2.2\n */\nU_STABLE int32_t U_EXPORT2\nuenum_count(UEnumeration* en, UErrorCode* status);\n\n/**\n * Returns the next element in the iterator's list.  If there are\n * no more elements, returns NULL.  If the iterator is out-of-sync\n * with its service, status is set to U_ENUM_OUT_OF_SYNC_ERROR and\n * NULL is returned.  If the native service string is a char* string,\n * it is converted to UChar* with the invariant converter.\n * The result is terminated by (UChar)0.\n * @param en the iterator object\n * @param resultLength pointer to receive the length of the result\n *                     (not including the terminating \\\\0).\n *                     If the pointer is NULL it is ignored.\n * @param status the error code, set to U_ENUM_OUT_OF_SYNC_ERROR if\n *               the iterator is out of sync with its service.\n * @return a pointer to the string.  The string will be\n *         zero-terminated.  The return pointer is owned by this iterator\n *         and must not be deleted by the caller.  The pointer is valid\n *         until the next call to any uenum_... method, including\n *         uenum_next() or uenum_unext().  When all strings have been\n *         traversed, returns NULL.\n * @stable ICU 2.2\n */\nU_STABLE const UChar* U_EXPORT2\nuenum_unext(UEnumeration* en,\n            int32_t* resultLength,\n            UErrorCode* status);\n\n/**\n * Returns the next element in the iterator's list.  If there are\n * no more elements, returns NULL.  If the iterator is out-of-sync\n * with its service, status is set to U_ENUM_OUT_OF_SYNC_ERROR and\n * NULL is returned.  If the native service string is a UChar*\n * string, it is converted to char* with the invariant converter.\n * The result is terminated by (char)0.  If the conversion fails\n * (because a character cannot be converted) then status is set to\n * U_INVARIANT_CONVERSION_ERROR and the return value is undefined\n * (but non-NULL).\n * @param en the iterator object\n * @param resultLength pointer to receive the length of the result\n *                     (not including the terminating \\\\0).\n *                     If the pointer is NULL it is ignored.\n * @param status the error code, set to U_ENUM_OUT_OF_SYNC_ERROR if\n *               the iterator is out of sync with its service.  Set to\n *               U_INVARIANT_CONVERSION_ERROR if the underlying native string is\n *               UChar* and conversion to char* with the invariant converter\n *               fails. This error pertains only to current string, so iteration\n *               might be able to continue successfully.\n * @return a pointer to the string.  The string will be\n *         zero-terminated.  The return pointer is owned by this iterator\n *         and must not be deleted by the caller.  The pointer is valid\n *         until the next call to any uenum_... method, including\n *         uenum_next() or uenum_unext().  When all strings have been\n *         traversed, returns NULL.\n * @stable ICU 2.2\n */\nU_STABLE const char* U_EXPORT2\nuenum_next(UEnumeration* en,\n           int32_t* resultLength,\n           UErrorCode* status);\n\n/**\n * Resets the iterator to the current list of service IDs.  This\n * re-establishes sync with the service and rewinds the iterator\n * to start at the first element.\n * @param en the iterator object\n * @param status the error code, set to U_ENUM_OUT_OF_SYNC_ERROR if\n *               the iterator is out of sync with its service.  \n * @stable ICU 2.2\n */\nU_STABLE void U_EXPORT2\nuenum_reset(UEnumeration* en, UErrorCode* status);\n\n#if U_SHOW_CPLUSPLUS_API\n\n/**\n * Given a StringEnumeration, wrap it in a UEnumeration.  The\n * StringEnumeration is adopted; after this call, the caller must not\n * delete it (regardless of error status).\n * @param adopted the C++ StringEnumeration to be wrapped in a UEnumeration.\n * @param ec the error code.\n * @return a UEnumeration wrapping the adopted StringEnumeration.\n * @stable ICU 4.2\n */\nU_STABLE UEnumeration* U_EXPORT2\nuenum_openFromStringEnumeration(icu::StringEnumeration* adopted, UErrorCode* ec);\n\n#endif\n\n#ifndef U_HIDE_DRAFT_API\n/**\n * Given an array of const UChar* strings, return a UEnumeration.  String pointers from 0..count-1 must not be null.\n * Do not free or modify either the string array or the characters it points to until this object has been destroyed with uenum_close.\n * \\snippet test/cintltst/uenumtst.c uenum_openUCharStringsEnumeration\n * @param strings array of const UChar* strings (each null terminated). All storage is owned by the caller.\n * @param count length of the array\n * @param ec error code\n * @return the new UEnumeration object. Caller is responsible for calling uenum_close to free memory.\n * @see uenum_close\n * @draft ICU 50\n */\nU_DRAFT UEnumeration* U_EXPORT2\nuenum_openUCharStringsEnumeration(const UChar* const strings[], int32_t count,\n                                 UErrorCode* ec);\n#endif\n\n/* Note:  next function is not hidden as draft, as it is used internally (it was formerly an internal function). */\n\n/**\n * Given an array of const char* strings (invariant chars only), return a UEnumeration.  String pointers from 0..count-1 must not be null.\n * Do not free or modify either the string array or the characters it points to until this object has been destroyed with uenum_close.\n * \\snippet test/cintltst/uenumtst.c uenum_openCharStringsEnumeration\n * @param strings array of char* strings (each null terminated).  All storage is owned by the caller.\n * @param count length of the array\n * @param ec error code\n * @return the new UEnumeration object. Caller is responsible for calling uenum_close to free memory\n * @see uenum_close\n * @draft ICU 50\n */\nU_DRAFT UEnumeration* U_EXPORT2\nuenum_openCharStringsEnumeration(const char* const strings[], int32_t count,\n                                 UErrorCode* ec);\n\n\n#endif\n"
  },
  {
    "path": "deprecated/android/addons/icucompat/unicode/ugender.h",
    "content": "/*\n*****************************************************************************************\n* Copyright (C) 2010-2012, International Business Machines\n* Corporation and others. All Rights Reserved.\n*****************************************************************************************\n*/\n\n#ifndef UGENDER_H\n#define UGENDER_H\n\n#include \"unicode/utypes.h\"\n\n#if !UCONFIG_NO_FORMATTING\n\n#include \"unicode/localpointer.h\"\n\n/**\n * \\file\n * \\brief C API: The purpose of this API is to compute the gender of a list as a\n * whole given the gender of each element.\n *\n */\n\n/**\n * Genders\n * @draft ICU 50\n */\nenum UGender {\n    /**\n     * Male gender.\n     * @draft ICU 50\n     */\n    UGENDER_MALE,\n    /**\n     * Female gender.\n     * @draft ICU 50\n     */\n    UGENDER_FEMALE,\n    /**\n     * Neutral gender.\n     * @draft ICU 50\n     */\n    UGENDER_OTHER\n};\n/**\n * @draft ICU 50\n */\ntypedef enum UGender UGender;\n\n/**\n * Opaque UGenderInfo object for use in C programs.\n * @draft ICU 50\n */\nstruct UGenderInfo;\ntypedef struct UGenderInfo UGenderInfo;\n\n/**\n * Opens a new UGenderInfo object given locale.\n * @param locale The locale for which the rules are desired.\n * @return A UGenderInfo for the specified locale, or NULL if an error occurred.\n * @draft ICU 50\n */\nU_STABLE const UGenderInfo* U_EXPORT2\nugender_getInstance(const char *locale, UErrorCode *status);\n\n\n/**\n * Given a list, returns the gender of the list as a whole.\n * @param genderInfo pointer that ugender_getInstance returns.\n * @param genders the gender of each element in the list.\n * @param size the size of the list.\n * @param status A pointer to a UErrorCode to receive any errors.\n * @return The gender of the list.\n * @draft ICU 50\n */\nU_DRAFT UGender U_EXPORT2\nugender_getListGender(const UGenderInfo* genderinfo, const UGender *genders, int32_t size, UErrorCode *status);\n\n#endif /* #if !UCONFIG_NO_FORMATTING */\n\n#endif\n"
  },
  {
    "path": "deprecated/android/addons/icucompat/unicode/uidna.h",
    "content": "/*\n *******************************************************************************\n *\n *   Copyright (C) 2003-2012, International Business Machines\n *   Corporation and others.  All Rights Reserved.\n *\n *******************************************************************************\n *   file name:  uidna.h\n *   encoding:   US-ASCII\n *   tab size:   8 (not used)\n *   indentation:4\n *\n *   created on: 2003feb1\n *   created by: Ram Viswanadha\n */\n\n#ifndef __UIDNA_H__\n#define __UIDNA_H__\n\n#include \"unicode/utypes.h\"\n\n#if !UCONFIG_NO_IDNA\n\n#include \"unicode/localpointer.h\"\n#include \"unicode/parseerr.h\"\n\n/**\n * \\file\n * \\brief C API: Internationalizing Domain Names in Applications (IDNA)\n *\n * IDNA2008 is implemented according to UTS #46, see the IDNA C++ class in idna.h.\n *\n * The C API functions which do take a UIDNA * service object pointer\n * implement UTS #46 and IDNA2008.\n * The C API functions which do not take a service object pointer\n * implement IDNA2003.\n */\n\n/*\n * IDNA option bit set values.\n */\nenum {\n    /**\n     * Default options value: None of the other options are set.\n     * For use in static worker and factory methods.\n     * @stable ICU 2.6\n     */\n    UIDNA_DEFAULT=0,\n    /**\n     * Option to allow unassigned code points in domain names and labels.\n     * For use in static worker and factory methods.\n     * <p>This option is ignored by the UTS46 implementation.\n     * (UTS #46 disallows unassigned code points.)\n     * @stable ICU 2.6\n     */\n    UIDNA_ALLOW_UNASSIGNED=1,\n    /**\n     * Option to check whether the input conforms to the STD3 ASCII rules,\n     * for example the restriction of labels to LDH characters\n     * (ASCII Letters, Digits and Hyphen-Minus).\n     * For use in static worker and factory methods.\n     * @stable ICU 2.6\n     */\n    UIDNA_USE_STD3_RULES=2,\n    /**\n     * IDNA option to check for whether the input conforms to the BiDi rules.\n     * For use in static worker and factory methods.\n     * <p>This option is ignored by the IDNA2003 implementation.\n     * (IDNA2003 always performs a BiDi check.)\n     * @stable ICU 4.6\n     */\n    UIDNA_CHECK_BIDI=4,\n    /**\n     * IDNA option to check for whether the input conforms to the CONTEXTJ rules.\n     * For use in static worker and factory methods.\n     * <p>This option is ignored by the IDNA2003 implementation.\n     * (The CONTEXTJ check is new in IDNA2008.)\n     * @stable ICU 4.6\n     */\n    UIDNA_CHECK_CONTEXTJ=8,\n    /**\n     * IDNA option for nontransitional processing in ToASCII().\n     * For use in static worker and factory methods.\n     * <p>By default, ToASCII() uses transitional processing.\n     * <p>This option is ignored by the IDNA2003 implementation.\n     * (This is only relevant for compatibility of newer IDNA implementations with IDNA2003.)\n     * @stable ICU 4.6\n     */\n    UIDNA_NONTRANSITIONAL_TO_ASCII=0x10,\n    /**\n     * IDNA option for nontransitional processing in ToUnicode().\n     * For use in static worker and factory methods.\n     * <p>By default, ToUnicode() uses transitional processing.\n     * <p>This option is ignored by the IDNA2003 implementation.\n     * (This is only relevant for compatibility of newer IDNA implementations with IDNA2003.)\n     * @stable ICU 4.6\n     */\n    UIDNA_NONTRANSITIONAL_TO_UNICODE=0x20,\n#ifndef U_HIDE_DRAFT_API\n    /**\n     * IDNA option to check for whether the input conforms to the CONTEXTO rules.\n     * For use in static worker and factory methods.\n     * <p>This option is ignored by the IDNA2003 implementation.\n     * (The CONTEXTO check is new in IDNA2008.)\n     * <p>This is for use by registries for IDNA2008 conformance.\n     * UTS #46 does not require the CONTEXTO check.\n     * @draft ICU 49\n     */\n    UIDNA_CHECK_CONTEXTO=0x40\n#endif  /* U_HIDE_DRAFT_API */\n};\n\n/**\n * Opaque C service object type for the new IDNA API.\n * @stable ICU 4.6\n */\nstruct UIDNA;\ntypedef struct UIDNA UIDNA;  /**< C typedef for struct UIDNA. @stable ICU 4.6 */\n\n/**\n * Returns a UIDNA instance which implements UTS #46.\n * Returns an unmodifiable instance, owned by the caller.\n * Cache it for multiple operations, and uidna_close() it when done.\n * The instance is thread-safe, that is, it can be used concurrently.\n *\n * For details about the UTS #46 implementation see the IDNA C++ class in idna.h.\n *\n * @param options Bit set to modify the processing and error checking.\n *                See option bit set values in uidna.h.\n * @param pErrorCode Standard ICU error code. Its input value must\n *                  pass the U_SUCCESS() test, or else the function returns\n *                  immediately. Check for U_FAILURE() on output or use with\n *                  function chaining. (See User Guide for details.)\n * @return the UTS #46 UIDNA instance, if successful\n * @stable ICU 4.6\n */\nU_STABLE UIDNA * U_EXPORT2\nuidna_openUTS46(uint32_t options, UErrorCode *pErrorCode);\n\n/**\n * Closes a UIDNA instance.\n * @param idna UIDNA instance to be closed\n * @stable ICU 4.6\n */\nU_STABLE void U_EXPORT2\nuidna_close(UIDNA *idna);\n\n#if U_SHOW_CPLUSPLUS_API\n\nU_NAMESPACE_BEGIN\n\n/**\n * \\class LocalUIDNAPointer\n * \"Smart pointer\" class, closes a UIDNA via uidna_close().\n * For most methods see the LocalPointerBase base class.\n *\n * @see LocalPointerBase\n * @see LocalPointer\n * @stable ICU 4.6\n */\nU_DEFINE_LOCAL_OPEN_POINTER(LocalUIDNAPointer, UIDNA, uidna_close);\n\nU_NAMESPACE_END\n\n#endif\n\n/**\n * Output container for IDNA processing errors.\n * Initialize with UIDNA_INFO_INITIALIZER:\n * \\code\n * UIDNAInfo info = UIDNA_INFO_INITIALIZER;\n * int32_t length = uidna_nameToASCII(..., &info, &errorCode);\n * if(U_SUCCESS(errorCode) && info.errors!=0) { ... }\n * \\endcode\n * @stable ICU 4.6\n */\ntypedef struct UIDNAInfo {\n    /** sizeof(UIDNAInfo) @stable ICU 4.6 */\n    int16_t size;\n    /**\n     * Set to TRUE if transitional and nontransitional processing produce different results.\n     * For details see C++ IDNAInfo::isTransitionalDifferent().\n     * @stable ICU 4.6\n     */\n    UBool isTransitionalDifferent;\n    UBool reservedB3;  /**< Reserved field, do not use. @internal */\n    /**\n     * Bit set indicating IDNA processing errors. 0 if no errors.\n     * See UIDNA_ERROR_... constants.\n     * @stable ICU 4.6\n     */\n    uint32_t errors;\n    int32_t reservedI2;  /**< Reserved field, do not use. @internal */\n    int32_t reservedI3;  /**< Reserved field, do not use. @internal */\n} UIDNAInfo;\n\n/**\n * Static initializer for a UIDNAInfo struct.\n * @stable ICU 4.6\n */\n#define UIDNA_INFO_INITIALIZER { \\\n    (int16_t)sizeof(UIDNAInfo), \\\n    FALSE, FALSE, \\\n    0, 0, 0 }\n\n/**\n * Converts a single domain name label into its ASCII form for DNS lookup.\n * If any processing step fails, then pInfo->errors will be non-zero and\n * the result might not be an ASCII string.\n * The label might be modified according to the types of errors.\n * Labels with severe errors will be left in (or turned into) their Unicode form.\n *\n * The UErrorCode indicates an error only in exceptional cases,\n * such as a U_MEMORY_ALLOCATION_ERROR.\n *\n * @param idna UIDNA instance\n * @param label Input domain name label\n * @param length Label length, or -1 if NUL-terminated\n * @param dest Destination string buffer\n * @param capacity Destination buffer capacity\n * @param pInfo Output container of IDNA processing details.\n * @param pErrorCode Standard ICU error code. Its input value must\n *                  pass the U_SUCCESS() test, or else the function returns\n *                  immediately. Check for U_FAILURE() on output or use with\n *                  function chaining. (See User Guide for details.)\n * @return destination string length\n * @stable ICU 4.6\n */\nU_STABLE int32_t U_EXPORT2\nuidna_labelToASCII(const UIDNA *idna,\n                   const UChar *label, int32_t length,\n                   UChar *dest, int32_t capacity,\n                   UIDNAInfo *pInfo, UErrorCode *pErrorCode);\n\n/**\n * Converts a single domain name label into its Unicode form for human-readable display.\n * If any processing step fails, then pInfo->errors will be non-zero.\n * The label might be modified according to the types of errors.\n *\n * The UErrorCode indicates an error only in exceptional cases,\n * such as a U_MEMORY_ALLOCATION_ERROR.\n *\n * @param idna UIDNA instance\n * @param label Input domain name label\n * @param length Label length, or -1 if NUL-terminated\n * @param dest Destination string buffer\n * @param capacity Destination buffer capacity\n * @param pInfo Output container of IDNA processing details.\n * @param pErrorCode Standard ICU error code. Its input value must\n *                  pass the U_SUCCESS() test, or else the function returns\n *                  immediately. Check for U_FAILURE() on output or use with\n *                  function chaining. (See User Guide for details.)\n * @return destination string length\n * @stable ICU 4.6\n */\nU_STABLE int32_t U_EXPORT2\nuidna_labelToUnicode(const UIDNA *idna,\n                     const UChar *label, int32_t length,\n                     UChar *dest, int32_t capacity,\n                     UIDNAInfo *pInfo, UErrorCode *pErrorCode);\n\n/**\n * Converts a whole domain name into its ASCII form for DNS lookup.\n * If any processing step fails, then pInfo->errors will be non-zero and\n * the result might not be an ASCII string.\n * The domain name might be modified according to the types of errors.\n * Labels with severe errors will be left in (or turned into) their Unicode form.\n *\n * The UErrorCode indicates an error only in exceptional cases,\n * such as a U_MEMORY_ALLOCATION_ERROR.\n *\n * @param idna UIDNA instance\n * @param name Input domain name\n * @param length Domain name length, or -1 if NUL-terminated\n * @param dest Destination string buffer\n * @param capacity Destination buffer capacity\n * @param pInfo Output container of IDNA processing details.\n * @param pErrorCode Standard ICU error code. Its input value must\n *                  pass the U_SUCCESS() test, or else the function returns\n *                  immediately. Check for U_FAILURE() on output or use with\n *                  function chaining. (See User Guide for details.)\n * @return destination string length\n * @stable ICU 4.6\n */\nU_STABLE int32_t U_EXPORT2\nuidna_nameToASCII(const UIDNA *idna,\n                  const UChar *name, int32_t length,\n                  UChar *dest, int32_t capacity,\n                  UIDNAInfo *pInfo, UErrorCode *pErrorCode);\n\n/**\n * Converts a whole domain name into its Unicode form for human-readable display.\n * If any processing step fails, then pInfo->errors will be non-zero.\n * The domain name might be modified according to the types of errors.\n *\n * The UErrorCode indicates an error only in exceptional cases,\n * such as a U_MEMORY_ALLOCATION_ERROR.\n *\n * @param idna UIDNA instance\n * @param name Input domain name\n * @param length Domain name length, or -1 if NUL-terminated\n * @param dest Destination string buffer\n * @param capacity Destination buffer capacity\n * @param pInfo Output container of IDNA processing details.\n * @param pErrorCode Standard ICU error code. Its input value must\n *                  pass the U_SUCCESS() test, or else the function returns\n *                  immediately. Check for U_FAILURE() on output or use with\n *                  function chaining. (See User Guide for details.)\n * @return destination string length\n * @stable ICU 4.6\n */\nU_STABLE int32_t U_EXPORT2\nuidna_nameToUnicode(const UIDNA *idna,\n                    const UChar *name, int32_t length,\n                    UChar *dest, int32_t capacity,\n                    UIDNAInfo *pInfo, UErrorCode *pErrorCode);\n\n/* UTF-8 versions of the processing methods --------------------------------- */\n\n/**\n * Converts a single domain name label into its ASCII form for DNS lookup.\n * UTF-8 version of uidna_labelToASCII(), same behavior.\n *\n * @param idna UIDNA instance\n * @param label Input domain name label\n * @param length Label length, or -1 if NUL-terminated\n * @param dest Destination string buffer\n * @param capacity Destination buffer capacity\n * @param pInfo Output container of IDNA processing details.\n * @param pErrorCode Standard ICU error code. Its input value must\n *                  pass the U_SUCCESS() test, or else the function returns\n *                  immediately. Check for U_FAILURE() on output or use with\n *                  function chaining. (See User Guide for details.)\n * @return destination string length\n * @stable ICU 4.6\n */\nU_STABLE int32_t U_EXPORT2\nuidna_labelToASCII_UTF8(const UIDNA *idna,\n                        const char *label, int32_t length,\n                        char *dest, int32_t capacity,\n                        UIDNAInfo *pInfo, UErrorCode *pErrorCode);\n\n/**\n * Converts a single domain name label into its Unicode form for human-readable display.\n * UTF-8 version of uidna_labelToUnicode(), same behavior.\n *\n * @param idna UIDNA instance\n * @param label Input domain name label\n * @param length Label length, or -1 if NUL-terminated\n * @param dest Destination string buffer\n * @param capacity Destination buffer capacity\n * @param pInfo Output container of IDNA processing details.\n * @param pErrorCode Standard ICU error code. Its input value must\n *                  pass the U_SUCCESS() test, or else the function returns\n *                  immediately. Check for U_FAILURE() on output or use with\n *                  function chaining. (See User Guide for details.)\n * @return destination string length\n * @stable ICU 4.6\n */\nU_STABLE int32_t U_EXPORT2\nuidna_labelToUnicodeUTF8(const UIDNA *idna,\n                         const char *label, int32_t length,\n                         char *dest, int32_t capacity,\n                         UIDNAInfo *pInfo, UErrorCode *pErrorCode);\n\n/**\n * Converts a whole domain name into its ASCII form for DNS lookup.\n * UTF-8 version of uidna_nameToASCII(), same behavior.\n *\n * @param idna UIDNA instance\n * @param name Input domain name\n * @param length Domain name length, or -1 if NUL-terminated\n * @param dest Destination string buffer\n * @param capacity Destination buffer capacity\n * @param pInfo Output container of IDNA processing details.\n * @param pErrorCode Standard ICU error code. Its input value must\n *                  pass the U_SUCCESS() test, or else the function returns\n *                  immediately. Check for U_FAILURE() on output or use with\n *                  function chaining. (See User Guide for details.)\n * @return destination string length\n * @stable ICU 4.6\n */\nU_STABLE int32_t U_EXPORT2\nuidna_nameToASCII_UTF8(const UIDNA *idna,\n                       const char *name, int32_t length,\n                       char *dest, int32_t capacity,\n                       UIDNAInfo *pInfo, UErrorCode *pErrorCode);\n\n/**\n * Converts a whole domain name into its Unicode form for human-readable display.\n * UTF-8 version of uidna_nameToUnicode(), same behavior.\n *\n * @param idna UIDNA instance\n * @param name Input domain name\n * @param length Domain name length, or -1 if NUL-terminated\n * @param dest Destination string buffer\n * @param capacity Destination buffer capacity\n * @param pInfo Output container of IDNA processing details.\n * @param pErrorCode Standard ICU error code. Its input value must\n *                  pass the U_SUCCESS() test, or else the function returns\n *                  immediately. Check for U_FAILURE() on output or use with\n *                  function chaining. (See User Guide for details.)\n * @return destination string length\n * @stable ICU 4.6\n */\nU_STABLE int32_t U_EXPORT2\nuidna_nameToUnicodeUTF8(const UIDNA *idna,\n                        const char *name, int32_t length,\n                        char *dest, int32_t capacity,\n                        UIDNAInfo *pInfo, UErrorCode *pErrorCode);\n\n/*\n * IDNA error bit set values.\n * When a domain name or label fails a processing step or does not meet the\n * validity criteria, then one or more of these error bits are set.\n */\nenum {\n    /**\n     * A non-final domain name label (or the whole domain name) is empty.\n     * @stable ICU 4.6\n     */\n    UIDNA_ERROR_EMPTY_LABEL=1,\n    /**\n     * A domain name label is longer than 63 bytes.\n     * (See STD13/RFC1034 3.1. Name space specifications and terminology.)\n     * This is only checked in ToASCII operations, and only if the output label is all-ASCII.\n     * @stable ICU 4.6\n     */\n    UIDNA_ERROR_LABEL_TOO_LONG=2,\n    /**\n     * A domain name is longer than 255 bytes in its storage form.\n     * (See STD13/RFC1034 3.1. Name space specifications and terminology.)\n     * This is only checked in ToASCII operations, and only if the output domain name is all-ASCII.\n     * @stable ICU 4.6\n     */\n    UIDNA_ERROR_DOMAIN_NAME_TOO_LONG=4,\n    /**\n     * A label starts with a hyphen-minus ('-').\n     * @stable ICU 4.6\n     */\n    UIDNA_ERROR_LEADING_HYPHEN=8,\n    /**\n     * A label ends with a hyphen-minus ('-').\n     * @stable ICU 4.6\n     */\n    UIDNA_ERROR_TRAILING_HYPHEN=0x10,\n    /**\n     * A label contains hyphen-minus ('-') in the third and fourth positions.\n     * @stable ICU 4.6\n     */\n    UIDNA_ERROR_HYPHEN_3_4=0x20,\n    /**\n     * A label starts with a combining mark.\n     * @stable ICU 4.6\n     */\n    UIDNA_ERROR_LEADING_COMBINING_MARK=0x40,\n    /**\n     * A label or domain name contains disallowed characters.\n     * @stable ICU 4.6\n     */\n    UIDNA_ERROR_DISALLOWED=0x80,\n    /**\n     * A label starts with \"xn--\" but does not contain valid Punycode.\n     * That is, an xn-- label failed Punycode decoding.\n     * @stable ICU 4.6\n     */\n    UIDNA_ERROR_PUNYCODE=0x100,\n    /**\n     * A label contains a dot=full stop.\n     * This can occur in an input string for a single-label function.\n     * @stable ICU 4.6\n     */\n    UIDNA_ERROR_LABEL_HAS_DOT=0x200,\n    /**\n     * An ACE label does not contain a valid label string.\n     * The label was successfully ACE (Punycode) decoded but the resulting\n     * string had severe validation errors. For example,\n     * it might contain characters that are not allowed in ACE labels,\n     * or it might not be normalized.\n     * @stable ICU 4.6\n     */\n    UIDNA_ERROR_INVALID_ACE_LABEL=0x400,\n    /**\n     * A label does not meet the IDNA BiDi requirements (for right-to-left characters).\n     * @stable ICU 4.6\n     */\n    UIDNA_ERROR_BIDI=0x800,\n    /**\n     * A label does not meet the IDNA CONTEXTJ requirements.\n     * @stable ICU 4.6\n     */\n    UIDNA_ERROR_CONTEXTJ=0x1000,\n#ifndef U_HIDE_DRAFT_API\n    /**\n     * A label does not meet the IDNA CONTEXTO requirements for punctuation characters.\n     * Some punctuation characters \"Would otherwise have been DISALLOWED\"\n     * but are allowed in certain contexts. (RFC 5892)\n     * @draft ICU 49\n     */\n    UIDNA_ERROR_CONTEXTO_PUNCTUATION=0x2000,\n    /**\n     * A label does not meet the IDNA CONTEXTO requirements for digits.\n     * Arabic-Indic Digits (U+066x) must not be mixed with Extended Arabic-Indic Digits (U+06Fx).\n     * @draft ICU 49\n     */\n    UIDNA_ERROR_CONTEXTO_DIGITS=0x4000\n#endif  /* U_HIDE_DRAFT_API */\n};\n\n/* IDNA2003 API ------------------------------------------------------------- */\n\n/**\n * IDNA2003: This function implements the ToASCII operation as defined in the IDNA RFC.\n * This operation is done on <b>single labels</b> before sending it to something that expects\n * ASCII names. A label is an individual part of a domain name. Labels are usually\n * separated by dots; e.g. \"www.example.com\" is composed of 3 labels \"www\",\"example\", and \"com\".\n *\n * IDNA2003 API Overview:\n *\n * The uidna_ API implements the IDNA protocol as defined in the IDNA RFC\n * (http://www.ietf.org/rfc/rfc3490.txt).\n * The RFC defines 2 operations: ToASCII and ToUnicode. Domain name labels\n * containing non-ASCII code points are processed by the\n * ToASCII operation before passing it to resolver libraries. Domain names\n * that are obtained from resolver libraries are processed by the\n * ToUnicode operation before displaying the domain name to the user.\n * IDNA requires that implementations process input strings with Nameprep\n * (http://www.ietf.org/rfc/rfc3491.txt),\n * which is a profile of Stringprep (http://www.ietf.org/rfc/rfc3454.txt),\n * and then with Punycode (http://www.ietf.org/rfc/rfc3492.txt).\n * Implementations of IDNA MUST fully implement Nameprep and Punycode;\n * neither Nameprep nor Punycode are optional.\n * The input and output of ToASCII and ToUnicode operations are Unicode\n * and are designed to be chainable, i.e., applying ToASCII or ToUnicode operations\n * multiple times to an input string will yield the same result as applying the operation\n * once.\n * ToUnicode(ToUnicode(ToUnicode...(ToUnicode(string)))) == ToUnicode(string) \n * ToASCII(ToASCII(ToASCII...(ToASCII(string))) == ToASCII(string).\n *\n * @param src               Input UChar array containing label in Unicode.\n * @param srcLength         Number of UChars in src, or -1 if NUL-terminated.\n * @param dest              Output UChar array with ASCII (ACE encoded) label.\n * @param destCapacity      Size of dest.\n * @param options           A bit set of options:\n *\n *  - UIDNA_DEFAULT             Use default options, i.e., do not process unassigned code points\n *                              and do not use STD3 ASCII rules\n *                              If unassigned code points are found the operation fails with \n *                              U_UNASSIGNED_ERROR error code.\n *\n *  - UIDNA_ALLOW_UNASSIGNED    Unassigned values can be converted to ASCII for query operations\n *                              If this option is set, the unassigned code points are in the input \n *                              are treated as normal Unicode code points.\n *\n *  - UIDNA_USE_STD3_RULES      Use STD3 ASCII rules for host name syntax restrictions\n *                              If this option is set and the input does not satisfy STD3 rules,  \n *                              the operation will fail with U_IDNA_STD3_ASCII_RULES_ERROR\n *\n * @param parseError        Pointer to UParseError struct to receive information on position \n *                          of error if an error is encountered. Can be NULL.\n * @param status            ICU in/out error code parameter.\n *                          U_INVALID_CHAR_FOUND if src contains\n *                          unmatched single surrogates.\n *                          U_INDEX_OUTOFBOUNDS_ERROR if src contains\n *                          too many code points.\n *                          U_BUFFER_OVERFLOW_ERROR if destCapacity is not enough\n * @return The length of the result string, if successful - or in case of a buffer overflow,\n *         in which case it will be greater than destCapacity.\n * @stable ICU 2.6\n */\nU_STABLE int32_t U_EXPORT2\nuidna_toASCII(const UChar* src, int32_t srcLength, \n              UChar* dest, int32_t destCapacity,\n              int32_t options,\n              UParseError* parseError,\n              UErrorCode* status);\n\n\n/**\n * IDNA2003: This function implements the ToUnicode operation as defined in the IDNA RFC.\n * This operation is done on <b>single labels</b> before sending it to something that expects\n * Unicode names. A label is an individual part of a domain name. Labels are usually\n * separated by dots; for e.g. \"www.example.com\" is composed of 3 labels \"www\",\"example\", and \"com\".\n *\n * @param src               Input UChar array containing ASCII (ACE encoded) label.\n * @param srcLength         Number of UChars in src, or -1 if NUL-terminated.\n * @param dest Output       Converted UChar array containing Unicode equivalent of label.\n * @param destCapacity      Size of dest.\n * @param options           A bit set of options:\n *\n *  - UIDNA_DEFAULT             Use default options, i.e., do not process unassigned code points\n *                              and do not use STD3 ASCII rules\n *                              If unassigned code points are found the operation fails with \n *                              U_UNASSIGNED_ERROR error code.\n *\n *  - UIDNA_ALLOW_UNASSIGNED      Unassigned values can be converted to ASCII for query operations\n *                              If this option is set, the unassigned code points are in the input \n *                              are treated as normal Unicode code points. <b> Note: </b> This option is \n *                              required on toUnicode operation because the RFC mandates \n *                              verification of decoded ACE input by applying toASCII and comparing\n *                              its output with source\n *\n *  - UIDNA_USE_STD3_RULES      Use STD3 ASCII rules for host name syntax restrictions\n *                              If this option is set and the input does not satisfy STD3 rules,  \n *                              the operation will fail with U_IDNA_STD3_ASCII_RULES_ERROR\n *\n * @param parseError        Pointer to UParseError struct to receive information on position \n *                          of error if an error is encountered. Can be NULL.\n * @param status            ICU in/out error code parameter.\n *                          U_INVALID_CHAR_FOUND if src contains\n *                          unmatched single surrogates.\n *                          U_INDEX_OUTOFBOUNDS_ERROR if src contains\n *                          too many code points.\n *                          U_BUFFER_OVERFLOW_ERROR if destCapacity is not enough\n * @return The length of the result string, if successful - or in case of a buffer overflow,\n *         in which case it will be greater than destCapacity.\n * @stable ICU 2.6\n */\nU_STABLE int32_t U_EXPORT2\nuidna_toUnicode(const UChar* src, int32_t srcLength,\n                UChar* dest, int32_t destCapacity,\n                int32_t options,\n                UParseError* parseError,\n                UErrorCode* status);\n\n\n/**\n * IDNA2003: Convenience function that implements the IDNToASCII operation as defined in the IDNA RFC.\n * This operation is done on complete domain names, e.g: \"www.example.com\". \n * It is important to note that this operation can fail. If it fails, then the input \n * domain name cannot be used as an Internationalized Domain Name and the application\n * should have methods defined to deal with the failure.\n *\n * <b>Note:</b> IDNA RFC specifies that a conformant application should divide a domain name\n * into separate labels, decide whether to apply allowUnassigned and useSTD3ASCIIRules on each, \n * and then convert. This function does not offer that level of granularity. The options once  \n * set will apply to all labels in the domain name\n *\n * @param src               Input UChar array containing IDN in Unicode.\n * @param srcLength         Number of UChars in src, or -1 if NUL-terminated.\n * @param dest              Output UChar array with ASCII (ACE encoded) IDN.\n * @param destCapacity      Size of dest.\n * @param options           A bit set of options:\n *\n *  - UIDNA_DEFAULT             Use default options, i.e., do not process unassigned code points\n *                              and do not use STD3 ASCII rules\n *                              If unassigned code points are found the operation fails with \n *                              U_UNASSIGNED_CODE_POINT_FOUND error code.\n *\n *  - UIDNA_ALLOW_UNASSIGNED    Unassigned values can be converted to ASCII for query operations\n *                              If this option is set, the unassigned code points are in the input \n *                              are treated as normal Unicode code points.\n *\n *  - UIDNA_USE_STD3_RULES      Use STD3 ASCII rules for host name syntax restrictions\n *                              If this option is set and the input does not satisfy STD3 rules,  \n *                              the operation will fail with U_IDNA_STD3_ASCII_RULES_ERROR\n *\n * @param parseError        Pointer to UParseError struct to receive information on position \n *                          of error if an error is encountered. Can be NULL.\n * @param status            ICU in/out error code parameter.\n *                          U_INVALID_CHAR_FOUND if src contains\n *                          unmatched single surrogates.\n *                          U_INDEX_OUTOFBOUNDS_ERROR if src contains\n *                          too many code points.\n *                          U_BUFFER_OVERFLOW_ERROR if destCapacity is not enough\n * @return The length of the result string, if successful - or in case of a buffer overflow,\n *         in which case it will be greater than destCapacity.\n * @stable ICU 2.6\n */\nU_STABLE int32_t U_EXPORT2\nuidna_IDNToASCII(  const UChar* src, int32_t srcLength,\n                   UChar* dest, int32_t destCapacity,\n                   int32_t options,\n                   UParseError* parseError,\n                   UErrorCode* status);\n\n/**\n * IDNA2003: Convenience function that implements the IDNToUnicode operation as defined in the IDNA RFC.\n * This operation is done on complete domain names, e.g: \"www.example.com\". \n *\n * <b>Note:</b> IDNA RFC specifies that a conformant application should divide a domain name\n * into separate labels, decide whether to apply allowUnassigned and useSTD3ASCIIRules on each, \n * and then convert. This function does not offer that level of granularity. The options once  \n * set will apply to all labels in the domain name\n *\n * @param src               Input UChar array containing IDN in ASCII (ACE encoded) form.\n * @param srcLength         Number of UChars in src, or -1 if NUL-terminated.\n * @param dest Output       UChar array containing Unicode equivalent of source IDN.\n * @param destCapacity      Size of dest.\n * @param options           A bit set of options:\n *\n *  - UIDNA_DEFAULT             Use default options, i.e., do not process unassigned code points\n *                              and do not use STD3 ASCII rules\n *                              If unassigned code points are found the operation fails with \n *                              U_UNASSIGNED_CODE_POINT_FOUND error code.\n *\n *  - UIDNA_ALLOW_UNASSIGNED    Unassigned values can be converted to ASCII for query operations\n *                              If this option is set, the unassigned code points are in the input \n *                              are treated as normal Unicode code points.\n *\n *  - UIDNA_USE_STD3_RULES      Use STD3 ASCII rules for host name syntax restrictions\n *                              If this option is set and the input does not satisfy STD3 rules,  \n *                              the operation will fail with U_IDNA_STD3_ASCII_RULES_ERROR\n *\n * @param parseError        Pointer to UParseError struct to receive information on position \n *                          of error if an error is encountered. Can be NULL.\n * @param status            ICU in/out error code parameter.\n *                          U_INVALID_CHAR_FOUND if src contains\n *                          unmatched single surrogates.\n *                          U_INDEX_OUTOFBOUNDS_ERROR if src contains\n *                          too many code points.\n *                          U_BUFFER_OVERFLOW_ERROR if destCapacity is not enough\n * @return The length of the result string, if successful - or in case of a buffer overflow,\n *         in which case it will be greater than destCapacity.\n * @stable ICU 2.6\n */\nU_STABLE int32_t U_EXPORT2\nuidna_IDNToUnicode(  const UChar* src, int32_t srcLength,\n                     UChar* dest, int32_t destCapacity,\n                     int32_t options,\n                     UParseError* parseError,\n                     UErrorCode* status);\n\n/**\n * IDNA2003: Compare two IDN strings for equivalence.\n * This function splits the domain names into labels and compares them.\n * According to IDN RFC, whenever two labels are compared, they are \n * considered equal if and only if their ASCII forms (obtained by \n * applying toASCII) match using an case-insensitive ASCII comparison.\n * Two domain names are considered a match if and only if all labels \n * match regardless of whether label separators match.\n *\n * @param s1                First source string.\n * @param length1           Length of first source string, or -1 if NUL-terminated.\n *\n * @param s2                Second source string.\n * @param length2           Length of second source string, or -1 if NUL-terminated.\n * @param options           A bit set of options:\n *\n *  - UIDNA_DEFAULT             Use default options, i.e., do not process unassigned code points\n *                              and do not use STD3 ASCII rules\n *                              If unassigned code points are found the operation fails with \n *                              U_UNASSIGNED_CODE_POINT_FOUND error code.\n *\n *  - UIDNA_ALLOW_UNASSIGNED    Unassigned values can be converted to ASCII for query operations\n *                              If this option is set, the unassigned code points are in the input \n *                              are treated as normal Unicode code points.\n *\n *  - UIDNA_USE_STD3_RULES      Use STD3 ASCII rules for host name syntax restrictions\n *                              If this option is set and the input does not satisfy STD3 rules,  \n *                              the operation will fail with U_IDNA_STD3_ASCII_RULES_ERROR\n *\n * @param status            ICU error code in/out parameter.\n *                          Must fulfill U_SUCCESS before the function call.\n * @return <0 or 0 or >0 as usual for string comparisons\n * @stable ICU 2.6\n */\nU_STABLE int32_t U_EXPORT2\nuidna_compare(  const UChar *s1, int32_t length1,\n                const UChar *s2, int32_t length2,\n                int32_t options,\n                UErrorCode* status);\n\n#endif /* #if !UCONFIG_NO_IDNA */\n\n#endif\n"
  },
  {
    "path": "deprecated/android/addons/icucompat/unicode/uiter.h",
    "content": "/*\n*******************************************************************************\n*\n*   Copyright (C) 2002-2011 International Business Machines\n*   Corporation and others.  All Rights Reserved.\n*\n*******************************************************************************\n*   file name:  uiter.h\n*   encoding:   US-ASCII\n*   tab size:   8 (not used)\n*   indentation:4\n*\n*   created on: 2002jan18\n*   created by: Markus W. Scherer\n*/\n\n#ifndef __UITER_H__\n#define __UITER_H__\n\n/**\n * \\file\n * \\brief C API: Unicode Character Iteration\n *\n * @see UCharIterator\n */\n\n#include \"unicode/utypes.h\"\n\n#if U_SHOW_CPLUSPLUS_API\n    U_NAMESPACE_BEGIN\n\n    class CharacterIterator;\n    class Replaceable;\n\n    U_NAMESPACE_END\n#endif\n\nU_CDECL_BEGIN\n\nstruct UCharIterator;\ntypedef struct UCharIterator UCharIterator; /**< C typedef for struct UCharIterator. @stable ICU 2.1 */\n\n/**\n * Origin constants for UCharIterator.getIndex() and UCharIterator.move().\n * @see UCharIteratorMove\n * @see UCharIterator\n * @stable ICU 2.1\n */\ntypedef enum UCharIteratorOrigin {\n    UITER_START, UITER_CURRENT, UITER_LIMIT, UITER_ZERO, UITER_LENGTH\n} UCharIteratorOrigin;\n\n/** Constants for UCharIterator. @stable ICU 2.6 */\nenum {\n    /**\n     * Constant value that may be returned by UCharIteratorMove\n     * indicating that the final UTF-16 index is not known, but that the move succeeded.\n     * This can occur when moving relative to limit or length, or\n     * when moving relative to the current index after a setState()\n     * when the current UTF-16 index is not known.\n     *\n     * It would be very inefficient to have to count from the beginning of the text\n     * just to get the current/limit/length index after moving relative to it.\n     * The actual index can be determined with getIndex(UITER_CURRENT)\n     * which will count the UChars if necessary.\n     *\n     * @stable ICU 2.6\n     */\n    UITER_UNKNOWN_INDEX=-2\n};\n\n\n/**\n * Constant for UCharIterator getState() indicating an error or\n * an unknown state.\n * Returned by uiter_getState()/UCharIteratorGetState\n * when an error occurs.\n * Also, some UCharIterator implementations may not be able to return\n * a valid state for each position. This will be clearly documented\n * for each such iterator (none of the public ones here).\n *\n * @stable ICU 2.6\n */\n#define UITER_NO_STATE ((uint32_t)0xffffffff)\n\n/**\n * Function type declaration for UCharIterator.getIndex().\n *\n * Gets the current position, or the start or limit of the\n * iteration range.\n *\n * This function may perform slowly for UITER_CURRENT after setState() was called,\n * or for UITER_LENGTH, because an iterator implementation may have to count\n * UChars if the underlying storage is not UTF-16.\n *\n * @param iter the UCharIterator structure (\"this pointer\")\n * @param origin get the 0, start, limit, length, or current index\n * @return the requested index, or U_SENTINEL in an error condition\n *\n * @see UCharIteratorOrigin\n * @see UCharIterator\n * @stable ICU 2.1\n */\ntypedef int32_t U_CALLCONV\nUCharIteratorGetIndex(UCharIterator *iter, UCharIteratorOrigin origin);\n\n/**\n * Function type declaration for UCharIterator.move().\n *\n * Use iter->move(iter, index, UITER_ZERO) like CharacterIterator::setIndex(index).\n *\n * Moves the current position relative to the start or limit of the\n * iteration range, or relative to the current position itself.\n * The movement is expressed in numbers of code units forward\n * or backward by specifying a positive or negative delta.\n * Out of bounds movement will be pinned to the start or limit.\n *\n * This function may perform slowly for moving relative to UITER_LENGTH\n * because an iterator implementation may have to count the rest of the\n * UChars if the native storage is not UTF-16.\n *\n * When moving relative to the limit or length, or\n * relative to the current position after setState() was called,\n * move() may return UITER_UNKNOWN_INDEX (-2) to avoid an inefficient\n * determination of the actual UTF-16 index.\n * The actual index can be determined with getIndex(UITER_CURRENT)\n * which will count the UChars if necessary.\n * See UITER_UNKNOWN_INDEX for details.\n *\n * @param iter the UCharIterator structure (\"this pointer\")\n * @param delta can be positive, zero, or negative\n * @param origin move relative to the 0, start, limit, length, or current index\n * @return the new index, or U_SENTINEL on an error condition,\n *         or UITER_UNKNOWN_INDEX when the index is not known.\n *\n * @see UCharIteratorOrigin\n * @see UCharIterator\n * @see UITER_UNKNOWN_INDEX\n * @stable ICU 2.1\n */\ntypedef int32_t U_CALLCONV\nUCharIteratorMove(UCharIterator *iter, int32_t delta, UCharIteratorOrigin origin);\n\n/**\n * Function type declaration for UCharIterator.hasNext().\n *\n * Check if current() and next() can still\n * return another code unit.\n *\n * @param iter the UCharIterator structure (\"this pointer\")\n * @return boolean value for whether current() and next() can still return another code unit\n *\n * @see UCharIterator\n * @stable ICU 2.1\n */\ntypedef UBool U_CALLCONV\nUCharIteratorHasNext(UCharIterator *iter);\n\n/**\n * Function type declaration for UCharIterator.hasPrevious().\n *\n * Check if previous() can still return another code unit.\n *\n * @param iter the UCharIterator structure (\"this pointer\")\n * @return boolean value for whether previous() can still return another code unit\n *\n * @see UCharIterator\n * @stable ICU 2.1\n */\ntypedef UBool U_CALLCONV\nUCharIteratorHasPrevious(UCharIterator *iter);\n \n/**\n * Function type declaration for UCharIterator.current().\n *\n * Return the code unit at the current position,\n * or U_SENTINEL if there is none (index is at the limit).\n *\n * @param iter the UCharIterator structure (\"this pointer\")\n * @return the current code unit\n *\n * @see UCharIterator\n * @stable ICU 2.1\n */\ntypedef UChar32 U_CALLCONV\nUCharIteratorCurrent(UCharIterator *iter);\n\n/**\n * Function type declaration for UCharIterator.next().\n *\n * Return the code unit at the current index and increment\n * the index (post-increment, like s[i++]),\n * or return U_SENTINEL if there is none (index is at the limit).\n *\n * @param iter the UCharIterator structure (\"this pointer\")\n * @return the current code unit (and post-increment the current index)\n *\n * @see UCharIterator\n * @stable ICU 2.1\n */\ntypedef UChar32 U_CALLCONV\nUCharIteratorNext(UCharIterator *iter);\n\n/**\n * Function type declaration for UCharIterator.previous().\n *\n * Decrement the index and return the code unit from there\n * (pre-decrement, like s[--i]),\n * or return U_SENTINEL if there is none (index is at the start).\n *\n * @param iter the UCharIterator structure (\"this pointer\")\n * @return the previous code unit (after pre-decrementing the current index)\n *\n * @see UCharIterator\n * @stable ICU 2.1\n */\ntypedef UChar32 U_CALLCONV\nUCharIteratorPrevious(UCharIterator *iter);\n\n/**\n * Function type declaration for UCharIterator.reservedFn().\n * Reserved for future use.\n *\n * @param iter the UCharIterator structure (\"this pointer\")\n * @param something some integer argument\n * @return some integer\n *\n * @see UCharIterator\n * @stable ICU 2.1\n */\ntypedef int32_t U_CALLCONV\nUCharIteratorReserved(UCharIterator *iter, int32_t something);\n\n/**\n * Function type declaration for UCharIterator.getState().\n *\n * Get the \"state\" of the iterator in the form of a single 32-bit word.\n * It is recommended that the state value be calculated to be as small as\n * is feasible. For strings with limited lengths, fewer than 32 bits may\n * be sufficient.\n *\n * This is used together with setState()/UCharIteratorSetState\n * to save and restore the iterator position more efficiently than with\n * getIndex()/move().\n *\n * The iterator state is defined as a uint32_t value because it is designed\n * for use in ucol_nextSortKeyPart() which provides 32 bits to store the state\n * of the character iterator.\n *\n * With some UCharIterator implementations (e.g., UTF-8),\n * getting and setting the UTF-16 index with existing functions\n * (getIndex(UITER_CURRENT) followed by move(pos, UITER_ZERO)) is possible but\n * relatively slow because the iterator has to \"walk\" from a known index\n * to the requested one.\n * This takes more time the farther it needs to go.\n *\n * An opaque state value allows an iterator implementation to provide\n * an internal index (UTF-8: the source byte array index) for\n * fast, constant-time restoration.\n *\n * After calling setState(), a getIndex(UITER_CURRENT) may be slow because\n * the UTF-16 index may not be restored as well, but the iterator can deliver\n * the correct text contents and move relative to the current position\n * without performance degradation.\n *\n * Some UCharIterator implementations may not be able to return\n * a valid state for each position, in which case they return UITER_NO_STATE instead.\n * This will be clearly documented for each such iterator (none of the public ones here).\n *\n * @param iter the UCharIterator structure (\"this pointer\")\n * @return the state word\n *\n * @see UCharIterator\n * @see UCharIteratorSetState\n * @see UITER_NO_STATE\n * @stable ICU 2.6\n */\ntypedef uint32_t U_CALLCONV\nUCharIteratorGetState(const UCharIterator *iter);\n\n/**\n * Function type declaration for UCharIterator.setState().\n *\n * Restore the \"state\" of the iterator using a state word from a getState() call.\n * The iterator object need not be the same one as for which getState() was called,\n * but it must be of the same type (set up using the same uiter_setXYZ function)\n * and it must iterate over the same string\n * (binary identical regardless of memory address).\n * For more about the state word see UCharIteratorGetState.\n *\n * After calling setState(), a getIndex(UITER_CURRENT) may be slow because\n * the UTF-16 index may not be restored as well, but the iterator can deliver\n * the correct text contents and move relative to the current position\n * without performance degradation.\n *\n * @param iter the UCharIterator structure (\"this pointer\")\n * @param state the state word from a getState() call\n *              on a same-type, same-string iterator\n * @param pErrorCode Must be a valid pointer to an error code value,\n *                   which must not indicate a failure before the function call.\n *\n * @see UCharIterator\n * @see UCharIteratorGetState\n * @stable ICU 2.6\n */\ntypedef void U_CALLCONV\nUCharIteratorSetState(UCharIterator *iter, uint32_t state, UErrorCode *pErrorCode);\n\n\n/**\n * C API for code unit iteration.\n * This can be used as a C wrapper around\n * CharacterIterator, Replaceable, or implemented using simple strings, etc.\n *\n * There are two roles for using UCharIterator:\n *\n * A \"provider\" sets the necessary function pointers and controls the \"protected\"\n * fields of the UCharIterator structure. A \"provider\" passes a UCharIterator\n * into C APIs that need a UCharIterator as an abstract, flexible string interface.\n *\n * Implementations of such C APIs are \"callers\" of UCharIterator functions;\n * they only use the \"public\" function pointers and never access the \"protected\"\n * fields directly.\n *\n * The current() and next() functions only check the current index against the\n * limit, and previous() only checks the current index against the start,\n * to see if the iterator already reached the end of the iteration range.\n *\n * The assumption - in all iterators - is that the index is moved via the API,\n * which means it won't go out of bounds, or the index is modified by\n * user code that knows enough about the iterator implementation to set valid\n * index values.\n *\n * UCharIterator functions return code unit values 0..0xffff,\n * or U_SENTINEL if the iteration bounds are reached.\n *\n * @stable ICU 2.1\n */\nstruct UCharIterator {\n    /**\n     * (protected) Pointer to string or wrapped object or similar.\n     * Not used by caller.\n     * @stable ICU 2.1\n     */\n    const void *context;\n\n    /**\n     * (protected) Length of string or similar.\n     * Not used by caller.\n     * @stable ICU 2.1\n     */\n    int32_t length;\n\n    /**\n     * (protected) Start index or similar.\n     * Not used by caller.\n     * @stable ICU 2.1\n     */\n    int32_t start;\n\n    /**\n     * (protected) Current index or similar.\n     * Not used by caller.\n     * @stable ICU 2.1\n     */\n    int32_t index;\n\n    /**\n     * (protected) Limit index or similar.\n     * Not used by caller.\n     * @stable ICU 2.1\n     */\n    int32_t limit;\n\n    /**\n     * (protected) Used by UTF-8 iterators and possibly others.\n     * @stable ICU 2.1\n     */\n    int32_t reservedField;\n\n    /**\n     * (public) Returns the current position or the\n     * start or limit index of the iteration range.\n     *\n     * @see UCharIteratorGetIndex\n     * @stable ICU 2.1\n     */\n    UCharIteratorGetIndex *getIndex;\n\n    /**\n     * (public) Moves the current position relative to the start or limit of the\n     * iteration range, or relative to the current position itself.\n     * The movement is expressed in numbers of code units forward\n     * or backward by specifying a positive or negative delta.\n     *\n     * @see UCharIteratorMove\n     * @stable ICU 2.1\n     */\n    UCharIteratorMove *move;\n\n    /**\n     * (public) Check if current() and next() can still\n     * return another code unit.\n     *\n     * @see UCharIteratorHasNext\n     * @stable ICU 2.1\n     */\n    UCharIteratorHasNext *hasNext;\n\n    /**\n     * (public) Check if previous() can still return another code unit.\n     *\n     * @see UCharIteratorHasPrevious\n     * @stable ICU 2.1\n     */\n    UCharIteratorHasPrevious *hasPrevious;\n\n    /**\n     * (public) Return the code unit at the current position,\n     * or U_SENTINEL if there is none (index is at the limit).\n     *\n     * @see UCharIteratorCurrent\n     * @stable ICU 2.1\n     */\n    UCharIteratorCurrent *current;\n\n    /**\n     * (public) Return the code unit at the current index and increment\n     * the index (post-increment, like s[i++]),\n     * or return U_SENTINEL if there is none (index is at the limit).\n     *\n     * @see UCharIteratorNext\n     * @stable ICU 2.1\n     */\n    UCharIteratorNext *next;\n\n    /**\n     * (public) Decrement the index and return the code unit from there\n     * (pre-decrement, like s[--i]),\n     * or return U_SENTINEL if there is none (index is at the start).\n     *\n     * @see UCharIteratorPrevious\n     * @stable ICU 2.1\n     */\n    UCharIteratorPrevious *previous;\n\n    /**\n     * (public) Reserved for future use. Currently NULL.\n     *\n     * @see UCharIteratorReserved\n     * @stable ICU 2.1\n     */\n    UCharIteratorReserved *reservedFn;\n\n    /**\n     * (public) Return the state of the iterator, to be restored later with setState().\n     * This function pointer is NULL if the iterator does not implement it.\n     *\n     * @see UCharIteratorGet\n     * @stable ICU 2.6\n     */\n    UCharIteratorGetState *getState;\n\n    /**\n     * (public) Restore the iterator state from the state word from a call\n     * to getState().\n     * This function pointer is NULL if the iterator does not implement it.\n     *\n     * @see UCharIteratorSet\n     * @stable ICU 2.6\n     */\n    UCharIteratorSetState *setState;\n};\n\n/**\n * Helper function for UCharIterator to get the code point\n * at the current index.\n *\n * Return the code point that includes the code unit at the current position,\n * or U_SENTINEL if there is none (index is at the limit).\n * If the current code unit is a lead or trail surrogate,\n * then the following or preceding surrogate is used to form\n * the code point value.\n *\n * @param iter the UCharIterator structure (\"this pointer\")\n * @return the current code point\n *\n * @see UCharIterator\n * @see U16_GET\n * @see UnicodeString::char32At()\n * @stable ICU 2.1\n */\nU_STABLE UChar32 U_EXPORT2\nuiter_current32(UCharIterator *iter);\n\n/**\n * Helper function for UCharIterator to get the next code point.\n *\n * Return the code point at the current index and increment\n * the index (post-increment, like s[i++]),\n * or return U_SENTINEL if there is none (index is at the limit).\n *\n * @param iter the UCharIterator structure (\"this pointer\")\n * @return the current code point (and post-increment the current index)\n *\n * @see UCharIterator\n * @see U16_NEXT\n * @stable ICU 2.1\n */\nU_STABLE UChar32 U_EXPORT2\nuiter_next32(UCharIterator *iter);\n\n/**\n * Helper function for UCharIterator to get the previous code point.\n *\n * Decrement the index and return the code point from there\n * (pre-decrement, like s[--i]),\n * or return U_SENTINEL if there is none (index is at the start).\n *\n * @param iter the UCharIterator structure (\"this pointer\")\n * @return the previous code point (after pre-decrementing the current index)\n *\n * @see UCharIterator\n * @see U16_PREV\n * @stable ICU 2.1\n */\nU_STABLE UChar32 U_EXPORT2\nuiter_previous32(UCharIterator *iter);\n\n/**\n * Get the \"state\" of the iterator in the form of a single 32-bit word.\n * This is a convenience function that calls iter->getState(iter)\n * if iter->getState is not NULL;\n * if it is NULL or any other error occurs, then UITER_NO_STATE is returned.\n *\n * Some UCharIterator implementations may not be able to return\n * a valid state for each position, in which case they return UITER_NO_STATE instead.\n * This will be clearly documented for each such iterator (none of the public ones here).\n *\n * @param iter the UCharIterator structure (\"this pointer\")\n * @return the state word\n *\n * @see UCharIterator\n * @see UCharIteratorGetState\n * @see UITER_NO_STATE\n * @stable ICU 2.6\n */\nU_STABLE uint32_t U_EXPORT2\nuiter_getState(const UCharIterator *iter);\n\n/**\n * Restore the \"state\" of the iterator using a state word from a getState() call.\n * This is a convenience function that calls iter->setState(iter, state, pErrorCode)\n * if iter->setState is not NULL; if it is NULL, then U_UNSUPPORTED_ERROR is set.\n *\n * @param iter the UCharIterator structure (\"this pointer\")\n * @param state the state word from a getState() call\n *              on a same-type, same-string iterator\n * @param pErrorCode Must be a valid pointer to an error code value,\n *                   which must not indicate a failure before the function call.\n *\n * @see UCharIterator\n * @see UCharIteratorSetState\n * @stable ICU 2.6\n */\nU_STABLE void U_EXPORT2\nuiter_setState(UCharIterator *iter, uint32_t state, UErrorCode *pErrorCode);\n\n/**\n * Set up a UCharIterator to iterate over a string.\n *\n * Sets the UCharIterator function pointers for iteration over the string s\n * with iteration boundaries start=index=0 and length=limit=string length.\n * The \"provider\" may set the start, index, and limit values at any time\n * within the range 0..length.\n * The length field will be ignored.\n *\n * The string pointer s is set into UCharIterator.context without copying\n * or reallocating the string contents.\n *\n * getState() simply returns the current index.\n * move() will always return the final index.\n *\n * @param iter UCharIterator structure to be set for iteration\n * @param s String to iterate over\n * @param length Length of s, or -1 if NUL-terminated\n *\n * @see UCharIterator\n * @stable ICU 2.1\n */\nU_STABLE void U_EXPORT2\nuiter_setString(UCharIterator *iter, const UChar *s, int32_t length);\n\n/**\n * Set up a UCharIterator to iterate over a UTF-16BE string\n * (byte vector with a big-endian pair of bytes per UChar).\n *\n * Everything works just like with a normal UChar iterator (uiter_setString),\n * except that UChars are assembled from byte pairs,\n * and that the length argument here indicates an even number of bytes.\n *\n * getState() simply returns the current index.\n * move() will always return the final index.\n *\n * @param iter UCharIterator structure to be set for iteration\n * @param s UTF-16BE string to iterate over\n * @param length Length of s as an even number of bytes, or -1 if NUL-terminated\n *               (NUL means pair of 0 bytes at even index from s)\n *\n * @see UCharIterator\n * @see uiter_setString\n * @stable ICU 2.6\n */\nU_STABLE void U_EXPORT2\nuiter_setUTF16BE(UCharIterator *iter, const char *s, int32_t length);\n\n/**\n * Set up a UCharIterator to iterate over a UTF-8 string.\n *\n * Sets the UCharIterator function pointers for iteration over the UTF-8 string s\n * with UTF-8 iteration boundaries 0 and length.\n * The implementation counts the UTF-16 index on the fly and\n * lazily evaluates the UTF-16 length of the text.\n *\n * The start field is used as the UTF-8 offset, the limit field as the UTF-8 length.\n * When the reservedField is not 0, then it contains a supplementary code point\n * and the UTF-16 index is between the two corresponding surrogates.\n * At that point, the UTF-8 index is behind that code point.\n *\n * The UTF-8 string pointer s is set into UCharIterator.context without copying\n * or reallocating the string contents.\n *\n * getState() returns a state value consisting of\n * - the current UTF-8 source byte index (bits 31..1)\n * - a flag (bit 0) that indicates whether the UChar position is in the middle\n *   of a surrogate pair\n *   (from a 4-byte UTF-8 sequence for the corresponding supplementary code point)\n *\n * getState() cannot also encode the UTF-16 index in the state value.\n * move(relative to limit or length), or\n * move(relative to current) after setState(), may return UITER_UNKNOWN_INDEX.\n *\n * @param iter UCharIterator structure to be set for iteration\n * @param s UTF-8 string to iterate over\n * @param length Length of s in bytes, or -1 if NUL-terminated\n *\n * @see UCharIterator\n * @stable ICU 2.6\n */\nU_STABLE void U_EXPORT2\nuiter_setUTF8(UCharIterator *iter, const char *s, int32_t length);\n\n#if U_SHOW_CPLUSPLUS_API\n\n/**\n * Set up a UCharIterator to wrap around a C++ CharacterIterator.\n *\n * Sets the UCharIterator function pointers for iteration using the\n * CharacterIterator charIter.\n *\n * The CharacterIterator pointer charIter is set into UCharIterator.context\n * without copying or cloning the CharacterIterator object.\n * The other \"protected\" UCharIterator fields are set to 0 and will be ignored.\n * The iteration index and boundaries are controlled by the CharacterIterator.\n *\n * getState() simply returns the current index.\n * move() will always return the final index.\n *\n * @param iter UCharIterator structure to be set for iteration\n * @param charIter CharacterIterator to wrap\n *\n * @see UCharIterator\n * @stable ICU 2.1\n */\nU_STABLE void U_EXPORT2\nuiter_setCharacterIterator(UCharIterator *iter, icu::CharacterIterator *charIter);\n\n/**\n * Set up a UCharIterator to iterate over a C++ Replaceable.\n *\n * Sets the UCharIterator function pointers for iteration over the\n * Replaceable rep with iteration boundaries start=index=0 and\n * length=limit=rep->length().\n * The \"provider\" may set the start, index, and limit values at any time\n * within the range 0..length=rep->length().\n * The length field will be ignored.\n *\n * The Replaceable pointer rep is set into UCharIterator.context without copying\n * or cloning/reallocating the Replaceable object.\n *\n * getState() simply returns the current index.\n * move() will always return the final index.\n *\n * @param iter UCharIterator structure to be set for iteration\n * @param rep Replaceable to iterate over\n *\n * @see UCharIterator\n * @stable ICU 2.1\n */\nU_STABLE void U_EXPORT2\nuiter_setReplaceable(UCharIterator *iter, const icu::Replaceable *rep);\n\n#endif\n\nU_CDECL_END\n\n#endif\n"
  },
  {
    "path": "deprecated/android/addons/icucompat/unicode/uldnames.h",
    "content": "/*\n*******************************************************************************\n*   Copyright (C) 2010-2012, International Business Machines Corporation and       * \n*   others.  All Rights Reserved.                                             *\n*******************************************************************************\n*/\n\n#ifndef __ULDNAMES_H__\n#define __ULDNAMES_H__\n\n/**\n * \\file\n * \\brief C API: Provides display names of Locale ids and their components.\n */\n\n#include \"unicode/utypes.h\"\n#include \"unicode/localpointer.h\"\n#include \"unicode/uscript.h\"\n#include \"unicode/udisplaycontext.h\"\n\n/**\n * Enum used in LocaleDisplayNames::createInstance.\n * @stable ICU 4.4\n */\ntypedef enum {\n    /**\n     * Use standard names when generating a locale name,\n     * e.g. en_GB displays as 'English (United Kingdom)'.\n     * @stable ICU 4.4\n     */\n    ULDN_STANDARD_NAMES = 0,\n    /**\n     * Use dialect names, when generating a locale name,\n     * e.g. en_GB displays as 'British English'.\n     * @stable ICU 4.4\n     */\n    ULDN_DIALECT_NAMES\n} UDialectHandling;\n\n/**\n * Opaque C service object type for the locale display names API\n * @stable ICU 4.4\n */\nstruct ULocaleDisplayNames;\n\n/** \n * C typedef for struct ULocaleDisplayNames. \n * @stable ICU 4.4 \n */\ntypedef struct ULocaleDisplayNames ULocaleDisplayNames;  \n\n#if !UCONFIG_NO_FORMATTING\n\n/**\n * Returns an instance of LocaleDisplayNames that returns names\n * formatted for the provided locale, using the provided\n * dialectHandling.  The usual value for dialectHandling is\n * ULOC_STANDARD_NAMES.\n *\n * @param locale the display locale \n * @param dialectHandling how to select names for locales \n * @return a ULocaleDisplayNames instance \n * @param pErrorCode the status code\n * @stable ICU 4.4\n */\nU_STABLE ULocaleDisplayNames * U_EXPORT2\nuldn_open(const char * locale,\n          UDialectHandling dialectHandling,\n          UErrorCode *pErrorCode);\n\n/**\n * Closes a ULocaleDisplayNames instance obtained from uldn_open().\n * @param ldn the ULocaleDisplayNames instance to be closed\n * @stable ICU 4.4\n */\nU_STABLE void U_EXPORT2\nuldn_close(ULocaleDisplayNames *ldn);\n\n#if U_SHOW_CPLUSPLUS_API\n\nU_NAMESPACE_BEGIN\n\n/**\n * \\class LocalULocaleDisplayNamesPointer\n * \"Smart pointer\" class, closes a ULocaleDisplayNames via uldn_close().\n * For most methods see the LocalPointerBase base class.\n *\n * @see LocalPointerBase\n * @see LocalPointer\n * @stable ICU 4.4\n */\nU_DEFINE_LOCAL_OPEN_POINTER(LocalULocaleDisplayNamesPointer, ULocaleDisplayNames, uldn_close);\n\nU_NAMESPACE_END\n\n#endif\n\n/* getters for state */\n\n/**\n * Returns the locale used to determine the display names. This is\n * not necessarily the same locale passed to {@link #uldn_open}.\n * @param ldn the LocaleDisplayNames instance\n * @return the display locale \n * @stable ICU 4.4\n */\nU_STABLE const char * U_EXPORT2\nuldn_getLocale(const ULocaleDisplayNames *ldn);\n\n/**\n * Returns the dialect handling used in the display names.\n * @param ldn the LocaleDisplayNames instance\n * @return the dialect handling enum\n * @stable ICU 4.4\n */\nU_STABLE UDialectHandling U_EXPORT2\nuldn_getDialectHandling(const ULocaleDisplayNames *ldn);\n\n/* names for entire locales */\n\n/**\n * Returns the display name of the provided locale.\n * @param ldn the LocaleDisplayNames instance\n * @param locale the locale whose display name to return\n * @param result receives the display name\n * @param maxResultSize the size of the result buffer\n * @param pErrorCode the status code\n * @return the actual buffer size needed for the display name.  If it's\n * greater than maxResultSize, the returned name will be truncated.\n * @stable ICU 4.4\n */\nU_STABLE int32_t U_EXPORT2\nuldn_localeDisplayName(const ULocaleDisplayNames *ldn,\n                       const char *locale,\n                       UChar *result,\n                       int32_t maxResultSize,\n                       UErrorCode *pErrorCode);\n\n/* names for components of a locale */\n\n/**\n * Returns the display name of the provided language code.\n * @param ldn the LocaleDisplayNames instance\n * @param lang the language code whose display name to return\n * @param result receives the display name\n * @param maxResultSize the size of the result buffer\n * @param pErrorCode the status code\n * @return the actual buffer size needed for the display name.  If it's\n * greater than maxResultSize, the returned name will be truncated.\n * @stable ICU 4.4\n */\nU_STABLE int32_t U_EXPORT2\nuldn_languageDisplayName(const ULocaleDisplayNames *ldn,\n                         const char *lang,\n                         UChar *result,\n                         int32_t maxResultSize,\n                         UErrorCode *pErrorCode);\n\n/**\n * Returns the display name of the provided script.\n * @param ldn the LocaleDisplayNames instance\n * @param script the script whose display name to return\n * @param result receives the display name\n * @param maxResultSize the size of the result buffer\n * @param pErrorCode the status code\n * @return the actual buffer size needed for the display name.  If it's\n * greater than maxResultSize, the returned name will be truncated.\n * @stable ICU 4.4\n */\nU_STABLE int32_t U_EXPORT2\nuldn_scriptDisplayName(const ULocaleDisplayNames *ldn,\n                       const char *script,\n                       UChar *result,\n                       int32_t maxResultSize,\n                       UErrorCode *pErrorCode);\n\n/**\n * Returns the display name of the provided script code.\n * @param ldn the LocaleDisplayNames instance\n * @param scriptCode the script code whose display name to return\n * @param result receives the display name\n * @param maxResultSize the size of the result buffer\n * @param pErrorCode the status code\n * @return the actual buffer size needed for the display name.  If it's\n * greater than maxResultSize, the returned name will be truncated.\n * @stable ICU 4.4\n */\nU_STABLE int32_t U_EXPORT2\nuldn_scriptCodeDisplayName(const ULocaleDisplayNames *ldn,\n                           UScriptCode scriptCode,\n                           UChar *result,\n                           int32_t maxResultSize,\n                           UErrorCode *pErrorCode);\n\n/**\n * Returns the display name of the provided region code.\n * @param ldn the LocaleDisplayNames instance\n * @param region the region code whose display name to return\n * @param result receives the display name\n * @param maxResultSize the size of the result buffer\n * @param pErrorCode the status code\n * @return the actual buffer size needed for the display name.  If it's\n * greater than maxResultSize, the returned name will be truncated.\n * @stable ICU 4.4\n */\nU_STABLE int32_t U_EXPORT2\nuldn_regionDisplayName(const ULocaleDisplayNames *ldn,\n                       const char *region,\n                       UChar *result,\n                       int32_t maxResultSize,\n                       UErrorCode *pErrorCode);\n\n/**\n * Returns the display name of the provided variant\n * @param ldn the LocaleDisplayNames instance\n * @param variant the variant whose display name to return\n * @param result receives the display name\n * @param maxResultSize the size of the result buffer\n * @param pErrorCode the status code\n * @return the actual buffer size needed for the display name.  If it's\n * greater than maxResultSize, the returned name will be truncated.\n * @stable ICU 4.4\n */\nU_STABLE int32_t U_EXPORT2\nuldn_variantDisplayName(const ULocaleDisplayNames *ldn,\n                        const char *variant,\n                        UChar *result,\n                        int32_t maxResultSize,\n                        UErrorCode *pErrorCode);\n\n/**\n * Returns the display name of the provided locale key\n * @param ldn the LocaleDisplayNames instance\n * @param key the locale key whose display name to return\n * @param result receives the display name\n * @param maxResultSize the size of the result buffer\n * @param pErrorCode the status code\n * @return the actual buffer size needed for the display name.  If it's\n * greater than maxResultSize, the returned name will be truncated.\n * @stable ICU 4.4\n */\nU_STABLE int32_t U_EXPORT2\nuldn_keyDisplayName(const ULocaleDisplayNames *ldn,\n                    const char *key,\n                    UChar *result,\n                    int32_t maxResultSize,\n                    UErrorCode *pErrorCode);\n\n/**\n * Returns the display name of the provided value (used with the provided key).\n * @param ldn the LocaleDisplayNames instance\n * @param key the locale key\n * @param value the locale key's value\n * @param result receives the display name\n * @param maxResultSize the size of the result buffer\n * @param pErrorCode the status code\n * @return the actual buffer size needed for the display name.  If it's\n * greater than maxResultSize, the returned name will be truncated.\n * @stable ICU 4.4\n */\nU_STABLE int32_t U_EXPORT2\nuldn_keyValueDisplayName(const ULocaleDisplayNames *ldn,\n                         const char *key,\n                         const char *value,\n                         UChar *result,\n                         int32_t maxResultSize,\n                         UErrorCode *pErrorCode);\n\n#ifndef U_HIDE_INTERNAL_API\n/**\n* Returns an instance of LocaleDisplayNames that returns names formatted\n* for the provided locale, using the provided UDisplayContext settings.\n*\n* @param locale The display locale \n* @param contexts List of one or more context settings (e.g. for dialect\n*               handling, capitalization, etc.\n* @param length Number of items in the contexts list\n* @param pErrorCode Pointer to UErrorCode input/output status. If at entry this indicates\n*               a failure status, the function will do nothing; otherwise this will be\n*               updated with any new status from the function. \n* @return a ULocaleDisplayNames instance \n* @internal ICU 50 technology preview\n*/\nU_INTERNAL ULocaleDisplayNames * U_EXPORT2\nuldn_openForContext(const char * locale, UDisplayContext *contexts,\n                    int32_t length, UErrorCode *pErrorCode);\n\n/**\n* Returns the UDisplayContext value for the specified UDisplayContextType.\n* @param ldn the ULocaleDisplayNames instance\n* @param type the UDisplayContextType whose value to return\n* @param pErrorCode Pointer to UErrorCode input/output status. If at entry this indicates\n*               a failure status, the function will do nothing; otherwise this will be\n*               updated with any new status from the function. \n* @return the UDisplayContextValue for the specified type.\n* @internal ICU 50 technology preview\n*/\nU_INTERNAL UDisplayContext U_EXPORT2\nuldn_getContext(const ULocaleDisplayNames *ldn, UDisplayContextType type,\n                UErrorCode *pErrorCode);\n\n#endif  /* U_HIDE_INTERNAL_API */\n\n#endif  /* !UCONFIG_NO_FORMATTING */\n#endif  /* __ULDNAMES_H__ */\n"
  },
  {
    "path": "deprecated/android/addons/icucompat/unicode/uloc.h",
    "content": "/*\n**********************************************************************\n*   Copyright (C) 1997-2012, International Business Machines\n*   Corporation and others.  All Rights Reserved.\n**********************************************************************\n*\n* File ULOC.H\n*\n* Modification History:\n*\n*   Date        Name        Description\n*   04/01/97    aliu        Creation.\n*   08/22/98    stephen     JDK 1.2 sync.\n*   12/08/98    rtg         New C API for Locale\n*   03/30/99    damiba      overhaul\n*   03/31/99    helena      Javadoc for uloc functions.\n*   04/15/99    Madhu       Updated Javadoc\n********************************************************************************\n*/\n\n#ifndef ULOC_H\n#define ULOC_H\n\n#include \"unicode/utypes.h\"\n#include \"unicode/uenum.h\"\n\n/**    \n * \\file\n * \\brief  C API: Locale \n *\n * <h2> ULoc C API for Locale </h2>\n * A <code>Locale</code> represents a specific geographical, political,\n * or cultural region. An operation that requires a <code>Locale</code> to perform\n * its task is called <em>locale-sensitive</em> and uses the <code>Locale</code>\n * to tailor information for the user. For example, displaying a number\n * is a locale-sensitive operation--the number should be formatted\n * according to the customs/conventions of the user's native country,\n * region, or culture.  In the C APIs, a locales is simply a const char string.\n *\n * <P>\n * You create a <code>Locale</code> with one of the three options listed below.\n * Each of the component is separated by '_' in the locale string.\n * \\htmlonly<blockquote>\\endhtmlonly\n * <pre>\n * \\code\n *       newLanguage\n * \n *       newLanguage + newCountry\n * \n *       newLanguage + newCountry + newVariant\n * \\endcode\n * </pre>\n * \\htmlonly</blockquote>\\endhtmlonly\n * The first option is a valid <STRONG>ISO\n * Language Code.</STRONG> These codes are the lower-case two-letter\n * codes as defined by ISO-639.\n * You can find a full list of these codes at a number of sites, such as:\n * <BR><a href =\"http://www.ics.uci.edu/pub/ietf/http/related/iso639.txt\">\n * http://www.ics.uci.edu/pub/ietf/http/related/iso639.txt</a>\n *\n * <P>\n * The second option includes an additonal <STRONG>ISO Country\n * Code.</STRONG> These codes are the upper-case two-letter codes\n * as defined by ISO-3166.\n * You can find a full list of these codes at a number of sites, such as:\n * <BR><a href=\"http://www.chemie.fu-berlin.de/diverse/doc/ISO_3166.html\">\n * http://www.chemie.fu-berlin.de/diverse/doc/ISO_3166.html</a>\n *\n * <P>\n * The third option requires another additonal information--the \n * <STRONG>Variant.</STRONG>\n * The Variant codes are vendor and browser-specific.\n * For example, use WIN for Windows, MAC for Macintosh, and POSIX for POSIX.\n * Where there are two variants, separate them with an underscore, and\n * put the most important one first. For\n * example, a Traditional Spanish collation might be referenced, with\n * \"ES\", \"ES\", \"Traditional_WIN\".\n *\n * <P>\n * Because a <code>Locale</code> is just an identifier for a region,\n * no validity check is performed when you specify a <code>Locale</code>.\n * If you want to see whether particular resources are available for the\n * <code>Locale</code> you asked for, you must query those resources. For\n * example, ask the <code>UNumberFormat</code> for the locales it supports\n * using its <code>getAvailable</code> method.\n * <BR><STRONG>Note:</STRONG> When you ask for a resource for a particular\n * locale, you get back the best available match, not necessarily\n * precisely what you asked for. For more information, look at\n * <code>UResourceBundle</code>.\n *\n * <P>\n * The <code>Locale</code> provides a number of convenient constants\n * that you can use to specify the commonly used\n * locales. For example, the following refers to a locale\n * for the United States:\n * \\htmlonly<blockquote>\\endhtmlonly\n * <pre>\n * \\code\n *       ULOC_US\n * \\endcode\n * </pre>\n * \\htmlonly</blockquote>\\endhtmlonly\n *\n * <P>\n * Once you've specified a locale you can query it for information about\n * itself. Use <code>uloc_getCountry</code> to get the ISO Country Code and\n * <code>uloc_getLanguage</code> to get the ISO Language Code. You can\n * use <code>uloc_getDisplayCountry</code> to get the\n * name of the country suitable for displaying to the user. Similarly,\n * you can use <code>uloc_getDisplayLanguage</code> to get the name of\n * the language suitable for displaying to the user. Interestingly,\n * the <code>uloc_getDisplayXXX</code> methods are themselves locale-sensitive\n * and have two versions: one that uses the default locale and one\n * that takes a locale as an argument and displays the name or country in\n * a language appropriate to that locale.\n *\n * <P>\n * The ICU provides a number of services that perform locale-sensitive\n * operations. For example, the <code>unum_xxx</code> functions format\n * numbers, currency, or percentages in a locale-sensitive manner. \n * </P>\n * \\htmlonly<blockquote>\\endhtmlonly\n * <pre>\n * \\code\n *     UErrorCode success = U_ZERO_ERROR;\n *     UNumberFormat *nf;\n *     const char* myLocale = \"fr_FR\";\n * \n *     nf = unum_open( UNUM_DEFAULT, NULL, success );          \n *     unum_close(nf);\n *     nf = unum_open( UNUM_CURRENCY, NULL, success );\n *     unum_close(nf);\n *     nf = unum_open( UNUM_PERCENT, NULL, success );   \n *     unum_close(nf);\n * \\endcode\n * </pre>\n * \\htmlonly</blockquote>\\endhtmlonly\n * Each of these methods has two variants; one with an explicit locale\n * and one without; the latter using the default locale.\n * \\htmlonly<blockquote>\\endhtmlonly\n * <pre>\n * \\code \n * \n *     nf = unum_open( UNUM_DEFAULT, myLocale, success );          \n *     unum_close(nf);\n *     nf = unum_open( UNUM_CURRENCY, myLocale, success );\n *     unum_close(nf);\n *     nf = unum_open( UNUM_PERCENT, myLocale, success );   \n *     unum_close(nf);\n * \\endcode\n * </pre>\n * \\htmlonly</blockquote>\\endhtmlonly\n * A <code>Locale</code> is the mechanism for identifying the kind of services\n * (<code>UNumberFormat</code>) that you would like to get. The locale is\n * <STRONG>just</STRONG> a mechanism for identifying these services.\n *\n * <P>\n * Each international serivce that performs locale-sensitive operations \n * allows you\n * to get all the available objects of that type. You can sift\n * through these objects by language, country, or variant,\n * and use the display names to present a menu to the user.\n * For example, you can create a menu of all the collation objects\n * suitable for a given language. Such classes implement these\n * three class methods:\n * \\htmlonly<blockquote>\\endhtmlonly\n * <pre>\n * \\code\n *       const char* uloc_getAvailable(int32_t index);\n *       int32_t uloc_countAvailable();\n *       int32_t\n *       uloc_getDisplayName(const char* localeID,\n *                 const char* inLocaleID, \n *                 UChar* result,\n *                 int32_t maxResultSize,\n *                  UErrorCode* err);\n * \n * \\endcode\n * </pre>\n * \\htmlonly</blockquote>\\endhtmlonly\n * <P>\n * Concerning POSIX/RFC1766 Locale IDs, \n *  the getLanguage/getCountry/getVariant/getName functions do understand\n * the POSIX type form of  language_COUNTRY.ENCODING\\@VARIANT\n * and if there is not an ICU-stype variant, uloc_getVariant() for example\n * will return the one listed after the \\@at sign. As well, the hyphen\n * \"-\" is recognized as a country/variant separator similarly to RFC1766.\n * So for example, \"en-us\" will be interpreted as en_US.  \n * As a result, uloc_getName() is far from a no-op, and will have the\n * effect of converting POSIX/RFC1766 IDs into ICU form, although it does\n * NOT map any of the actual codes (i.e. russian->ru) in any way.\n * Applications should call uloc_getName() at the point where a locale ID\n * is coming from an external source (user entry, OS, web browser)\n * and pass the resulting string to other ICU functions.  For example,\n * don't use de-de\\@EURO as an argument to resourcebundle.\n *\n * @see UResourceBundle\n */\n\n/** Useful constant for this language. @stable ICU 2.0 */\n#define ULOC_CHINESE            \"zh\"\n/** Useful constant for this language. @stable ICU 2.0 */\n#define ULOC_ENGLISH            \"en\"\n/** Useful constant for this language. @stable ICU 2.0 */\n#define ULOC_FRENCH             \"fr\"\n/** Useful constant for this language. @stable ICU 2.0 */\n#define ULOC_GERMAN             \"de\"\n/** Useful constant for this language. @stable ICU 2.0 */\n#define ULOC_ITALIAN            \"it\"\n/** Useful constant for this language. @stable ICU 2.0 */\n#define ULOC_JAPANESE           \"ja\"\n/** Useful constant for this language. @stable ICU 2.0 */\n#define ULOC_KOREAN             \"ko\"\n/** Useful constant for this language. @stable ICU 2.0 */\n#define ULOC_SIMPLIFIED_CHINESE \"zh_CN\"\n/** Useful constant for this language. @stable ICU 2.0 */\n#define ULOC_TRADITIONAL_CHINESE \"zh_TW\"\n\n/** Useful constant for this country/region. @stable ICU 2.0 */\n#define ULOC_CANADA         \"en_CA\"\n/** Useful constant for this country/region. @stable ICU 2.0 */\n#define ULOC_CANADA_FRENCH  \"fr_CA\"\n/** Useful constant for this country/region. @stable ICU 2.0 */\n#define ULOC_CHINA          \"zh_CN\"\n/** Useful constant for this country/region. @stable ICU 2.0 */\n#define ULOC_PRC            \"zh_CN\"\n/** Useful constant for this country/region. @stable ICU 2.0 */\n#define ULOC_FRANCE         \"fr_FR\"\n/** Useful constant for this country/region. @stable ICU 2.0 */\n#define ULOC_GERMANY        \"de_DE\"\n/** Useful constant for this country/region. @stable ICU 2.0 */\n#define ULOC_ITALY          \"it_IT\"\n/** Useful constant for this country/region. @stable ICU 2.0 */\n#define ULOC_JAPAN          \"ja_JP\"\n/** Useful constant for this country/region. @stable ICU 2.0 */\n#define ULOC_KOREA          \"ko_KR\"\n/** Useful constant for this country/region. @stable ICU 2.0 */\n#define ULOC_TAIWAN         \"zh_TW\"\n/** Useful constant for this country/region. @stable ICU 2.0 */\n#define ULOC_UK             \"en_GB\"\n/** Useful constant for this country/region. @stable ICU 2.0 */\n#define ULOC_US             \"en_US\"\n\n/**\n * Useful constant for the maximum size of the language part of a locale ID.\n * (including the terminating NULL).\n * @stable ICU 2.0\n */\n#define ULOC_LANG_CAPACITY 12\n\n/**\n * Useful constant for the maximum size of the country part of a locale ID\n * (including the terminating NULL).\n * @stable ICU 2.0\n */\n#define ULOC_COUNTRY_CAPACITY 4\n/**\n * Useful constant for the maximum size of the whole locale ID\n * (including the terminating NULL and all keywords).\n * @stable ICU 2.0\n */\n#define ULOC_FULLNAME_CAPACITY 157\n\n/**\n * Useful constant for the maximum size of the script part of a locale ID\n * (including the terminating NULL).\n * @stable ICU 2.8\n */\n#define ULOC_SCRIPT_CAPACITY 6\n\n/**\n * Useful constant for the maximum size of keywords in a locale\n * @stable ICU 2.8\n */\n#define ULOC_KEYWORDS_CAPACITY 50\n\n/**\n * Useful constant for the maximum total size of keywords and their values in a locale\n * @stable ICU 2.8\n */\n#define ULOC_KEYWORD_AND_VALUES_CAPACITY 100\n\n/**\n * Invariant character separating keywords from the locale string\n * @stable ICU 2.8\n */\n#define ULOC_KEYWORD_SEPARATOR '@'\n\n/**\n  * Unicode code point for '@' separating keywords from the locale string.\n  * @see ULOC_KEYWORD_SEPARATOR\n  * @stable ICU 4.6\n  */\n#define ULOC_KEYWORD_SEPARATOR_UNICODE 0x40\n\n/**\n * Invariant character for assigning value to a keyword\n * @stable ICU 2.8\n */\n#define ULOC_KEYWORD_ASSIGN '='\n\n/**\n  * Unicode code point for '=' for assigning value to a keyword.\n  * @see ULOC_KEYWORD_ASSIGN\n  * @stable ICU 4.6 \n  */\n#define ULOC_KEYWORD_ASSIGN_UNICODE 0x3D\n\n/**\n * Invariant character separating keywords\n * @stable ICU 2.8\n */\n#define ULOC_KEYWORD_ITEM_SEPARATOR ';'\n\n/**\n  * Unicode code point for ';' separating keywords\n  * @see ULOC_KEYWORD_ITEM_SEPARATOR\n  * @stable ICU 4.6\n  */\n#define ULOC_KEYWORD_ITEM_SEPARATOR_UNICODE 0x3B\n\n/**\n * Constants for *_getLocale()\n * Allow user to select whether she wants information on \n * requested, valid or actual locale.\n * For example, a collator for \"en_US_CALIFORNIA\" was\n * requested. In the current state of ICU (2.0), \n * the requested locale is \"en_US_CALIFORNIA\",\n * the valid locale is \"en_US\" (most specific locale supported by ICU)\n * and the actual locale is \"root\" (the collation data comes unmodified \n * from the UCA)\n * The locale is considered supported by ICU if there is a core ICU bundle \n * for that locale (although it may be empty).\n * @stable ICU 2.1\n */\ntypedef enum {\n  /** This is locale the data actually comes from \n   * @stable ICU 2.1\n   */\n  ULOC_ACTUAL_LOCALE    = 0,\n  /** This is the most specific locale supported by ICU \n   * @stable ICU 2.1\n   */\n  ULOC_VALID_LOCALE    = 1,\n\n#ifndef U_HIDE_DEPRECATED_API\n  /** This is the requested locale\n   *  @deprecated ICU 2.8 \n   */\n  ULOC_REQUESTED_LOCALE = 2,\n#endif /* U_HIDE_DEPRECATED_API */\n\n  ULOC_DATA_LOCALE_TYPE_LIMIT = 3\n} ULocDataLocaleType ;\n\n#ifndef U_HIDE_SYSTEM_API\n/**\n * Gets ICU's default locale.  \n * The returned string is a snapshot in time, and will remain valid\n *   and unchanged even when uloc_setDefault() is called.\n *   The returned storage is owned by ICU, and must not be altered or deleted\n *   by the caller.\n *  \n * @return the ICU default locale\n * @system\n * @stable ICU 2.0\n */\nU_STABLE const char* U_EXPORT2\nuloc_getDefault(void);\n\n/**\n * Sets ICU's default locale.  \n *    By default (without calling this function), ICU's default locale will be based\n *    on information obtained from the underlying system environment.\n *    <p>\n *    Changes to ICU's default locale do not propagate back to the\n *    system environment.\n *    <p>\n *    Changes to ICU's default locale to not affect any ICU services that\n *    may already be open based on the previous default locale value.\n *\n * @param localeID the new ICU default locale. A value of NULL will try to get\n *                 the system's default locale.\n * @param status the error information if the setting of default locale fails\n * @system\n * @stable ICU 2.0\n */\nU_STABLE void U_EXPORT2\nuloc_setDefault(const char* localeID,\n        UErrorCode*       status);\n#endif  /* U_HIDE_SYSTEM_API */\n\n/**\n * Gets the language code for the specified locale.\n *\n * @param localeID the locale to get the ISO language code with\n * @param language the language code for localeID\n * @param languageCapacity the size of the language buffer to store the  \n * language code with\n * @param err error information if retrieving the language code failed\n * @return the actual buffer size needed for the language code.  If it's greater \n * than languageCapacity, the returned language code will be truncated.  \n * @stable ICU 2.0\n */\nU_STABLE int32_t U_EXPORT2\nuloc_getLanguage(const char*    localeID,\n         char* language,\n         int32_t languageCapacity,\n         UErrorCode* err);\n\n/**\n * Gets the script code for the specified locale.\n *\n * @param localeID the locale to get the ISO language code with\n * @param script the language code for localeID\n * @param scriptCapacity the size of the language buffer to store the  \n * language code with\n * @param err error information if retrieving the language code failed\n * @return the actual buffer size needed for the language code.  If it's greater \n * than scriptCapacity, the returned language code will be truncated.  \n * @stable ICU 2.8\n */\nU_STABLE int32_t U_EXPORT2\nuloc_getScript(const char*    localeID,\n         char* script,\n         int32_t scriptCapacity,\n         UErrorCode* err);\n\n/**\n * Gets the  country code for the specified locale.\n *\n * @param localeID the locale to get the country code with\n * @param country the country code for localeID\n * @param countryCapacity the size of the country buffer to store the  \n * country code with\n * @param err error information if retrieving the country code failed\n * @return the actual buffer size needed for the country code.  If it's greater \n * than countryCapacity, the returned country code will be truncated.  \n * @stable ICU 2.0\n */\nU_STABLE int32_t U_EXPORT2\nuloc_getCountry(const char*    localeID,\n        char* country,\n        int32_t countryCapacity,\n        UErrorCode* err);\n\n/**\n * Gets the variant code for the specified locale.\n *\n * @param localeID the locale to get the variant code with\n * @param variant the variant code for localeID\n * @param variantCapacity the size of the variant buffer to store the \n * variant code with\n * @param err error information if retrieving the variant code failed\n * @return the actual buffer size needed for the variant code.  If it's greater \n * than variantCapacity, the returned variant code will be truncated.  \n * @stable ICU 2.0\n */\nU_STABLE int32_t U_EXPORT2\nuloc_getVariant(const char*    localeID,\n        char* variant,\n        int32_t variantCapacity,\n        UErrorCode* err);\n\n\n/**\n * Gets the full name for the specified locale.\n * Note: This has the effect of 'canonicalizing' the ICU locale ID to\n * a certain extent. Upper and lower case are set as needed.\n * It does NOT map aliased names in any way.\n * See the top of this header file.\n * This API supports preflighting.\n *\n * @param localeID the locale to get the full name with\n * @param name fill in buffer for the name without keywords.\n * @param nameCapacity capacity of the fill in buffer.\n * @param err error information if retrieving the full name failed\n * @return the actual buffer size needed for the full name.  If it's greater \n * than nameCapacity, the returned full name will be truncated.  \n * @stable ICU 2.0\n */\nU_STABLE int32_t U_EXPORT2\nuloc_getName(const char*    localeID,\n         char* name,\n         int32_t nameCapacity,\n         UErrorCode* err);\n\n/**\n * Gets the full name for the specified locale.\n * Note: This has the effect of 'canonicalizing' the string to\n * a certain extent. Upper and lower case are set as needed,\n * and if the components were in 'POSIX' format they are changed to\n * ICU format.  It does NOT map aliased names in any way.\n * See the top of this header file.\n *\n * @param localeID the locale to get the full name with\n * @param name the full name for localeID\n * @param nameCapacity the size of the name buffer to store the \n * full name with\n * @param err error information if retrieving the full name failed\n * @return the actual buffer size needed for the full name.  If it's greater \n * than nameCapacity, the returned full name will be truncated.  \n * @stable ICU 2.8\n */\nU_STABLE int32_t U_EXPORT2\nuloc_canonicalize(const char*    localeID,\n         char* name,\n         int32_t nameCapacity,\n         UErrorCode* err);\n\n/**\n * Gets the ISO language code for the specified locale.\n *\n * @param localeID the locale to get the ISO language code with\n * @return language the ISO language code for localeID\n * @stable ICU 2.0\n */\nU_STABLE const char* U_EXPORT2\nuloc_getISO3Language(const char* localeID);\n\n\n/**\n * Gets the ISO country code for the specified locale.\n *\n * @param localeID the locale to get the ISO country code with\n * @return country the ISO country code for localeID\n * @stable ICU 2.0\n */\nU_STABLE const char* U_EXPORT2\nuloc_getISO3Country(const char* localeID);\n\n/**\n * Gets the Win32 LCID value for the specified locale.\n * If the ICU locale is not recognized by Windows, 0 will be returned.\n *\n * @param localeID the locale to get the Win32 LCID value with\n * @return country the Win32 LCID for localeID\n * @stable ICU 2.0\n */\nU_STABLE uint32_t U_EXPORT2\nuloc_getLCID(const char* localeID);\n\n/**\n * Gets the language name suitable for display for the specified locale.\n *\n * @param locale the locale to get the ISO language code with\n * @param displayLocale Specifies the locale to be used to display the name.  In other words,\n *                 if the locale's language code is \"en\", passing Locale::getFrench() for\n *                 inLocale would result in \"Anglais\", while passing Locale::getGerman()\n *                 for inLocale would result in \"Englisch\".\n * @param language the displayable language code for localeID\n * @param languageCapacity the size of the language buffer to store the  \n * displayable language code with\n * @param status error information if retrieving the displayable language code failed\n * @return the actual buffer size needed for the displayable language code.  If it's greater \n * than languageCapacity, the returned language code will be truncated.  \n * @stable ICU 2.0\n */\nU_STABLE int32_t U_EXPORT2\nuloc_getDisplayLanguage(const char* locale,\n            const char* displayLocale,\n            UChar* language,\n            int32_t languageCapacity,\n            UErrorCode* status);\n\n/**\n * Gets the script name suitable for display for the specified locale.\n *\n * @param locale the locale to get the displayable script code with. NULL may be used to specify the default.\n * @param displayLocale Specifies the locale to be used to display the name.  In other words,\n *                 if the locale's language code is \"en\", passing Locale::getFrench() for\n *                 inLocale would result in \"\", while passing Locale::getGerman()\n *                 for inLocale would result in \"\". NULL may be used to specify the default.\n * @param script the displayable country code for localeID\n * @param scriptCapacity the size of the script buffer to store the  \n * displayable script code with\n * @param status error information if retrieving the displayable script code failed\n * @return the actual buffer size needed for the displayable script code.  If it's greater \n * than scriptCapacity, the returned displayable script code will be truncated.  \n * @stable ICU 2.8\n */\nU_STABLE int32_t U_EXPORT2\nuloc_getDisplayScript(const char* locale,\n            const char* displayLocale,\n            UChar* script,\n            int32_t scriptCapacity,\n            UErrorCode* status);\n\n/**\n * Gets the country name suitable for display for the specified locale.\n *\n * @param locale the locale to get the displayable country code with. NULL may be used to specify the default.\n * @param displayLocale Specifies the locale to be used to display the name.  In other words,\n *                 if the locale's language code is \"en\", passing Locale::getFrench() for\n *                 inLocale would result in \"Anglais\", while passing Locale::getGerman()\n *                 for inLocale would result in \"Englisch\". NULL may be used to specify the default.\n * @param country the displayable country code for localeID\n * @param countryCapacity the size of the country buffer to store the  \n * displayable country code with\n * @param status error information if retrieving the displayable country code failed\n * @return the actual buffer size needed for the displayable country code.  If it's greater \n * than countryCapacity, the returned displayable country code will be truncated.  \n * @stable ICU 2.0\n */\nU_STABLE int32_t U_EXPORT2\nuloc_getDisplayCountry(const char* locale,\n                       const char* displayLocale,\n                       UChar* country,\n                       int32_t countryCapacity,\n                       UErrorCode* status);\n\n\n/**\n * Gets the variant name suitable for display for the specified locale.\n *\n * @param locale the locale to get the displayable variant code with. NULL may be used to specify the default.\n * @param displayLocale Specifies the locale to be used to display the name.  In other words,\n *                 if the locale's language code is \"en\", passing Locale::getFrench() for\n *                 inLocale would result in \"Anglais\", while passing Locale::getGerman()\n *                 for inLocale would result in \"Englisch\". NULL may be used to specify the default.\n * @param variant the displayable variant code for localeID\n * @param variantCapacity the size of the variant buffer to store the \n * displayable variant code with\n * @param status error information if retrieving the displayable variant code failed\n * @return the actual buffer size needed for the displayable variant code.  If it's greater \n * than variantCapacity, the returned displayable variant code will be truncated.  \n * @stable ICU 2.0\n */\nU_STABLE int32_t U_EXPORT2\nuloc_getDisplayVariant(const char* locale,\n                       const char* displayLocale,\n                       UChar* variant,\n                       int32_t variantCapacity,\n                       UErrorCode* status);\n\n/**\n * Gets the keyword name suitable for display for the specified locale.\n * E.g: for the locale string de_DE\\@collation=PHONEBOOK, this API gets the display \n * string for the keyword collation. \n * Usage:\n * <code>\n *    UErrorCode status = U_ZERO_ERROR;\n *    const char* keyword =NULL;\n *    int32_t keywordLen = 0;\n *    int32_t keywordCount = 0;\n *    UChar displayKeyword[256];\n *    int32_t displayKeywordLen = 0;\n *    UEnumeration* keywordEnum = uloc_openKeywords(\"de_DE@collation=PHONEBOOK;calendar=TRADITIONAL\", &status);\n *    for(keywordCount = uenum_count(keywordEnum, &status); keywordCount > 0 ; keywordCount--){\n *          if(U_FAILURE(status)){\n *              ...something went wrong so handle the error...\n *              break;\n *          }\n *          // the uenum_next returns NUL terminated string\n *          keyword = uenum_next(keywordEnum, &keywordLen, &status);\n *          displayKeywordLen = uloc_getDisplayKeyword(keyword, \"en_US\", displayKeyword, 256);\n *          ... do something interesting .....\n *    }\n *    uenum_close(keywordEnum);\n * </code>\n * @param keyword           The keyword whose display string needs to be returned.\n * @param displayLocale     Specifies the locale to be used to display the name.  In other words,\n *                          if the locale's language code is \"en\", passing Locale::getFrench() for\n *                          inLocale would result in \"Anglais\", while passing Locale::getGerman()\n *                          for inLocale would result in \"Englisch\". NULL may be used to specify the default.\n * @param dest              the buffer to which the displayable keyword should be written.\n * @param destCapacity      The size of the buffer (number of UChars). If it is 0, then\n *                          dest may be NULL and the function will only return the length of the \n *                          result without writing any of the result string (pre-flighting).\n * @param status            error information if retrieving the displayable string failed. \n *                          Should not be NULL and should not indicate failure on entry.\n * @return the actual buffer size needed for the displayable variant code.  \n * @see #uloc_openKeywords\n * @stable ICU 2.8\n */\nU_STABLE int32_t U_EXPORT2\nuloc_getDisplayKeyword(const char* keyword,\n                       const char* displayLocale,\n                       UChar* dest,\n                       int32_t destCapacity,\n                       UErrorCode* status);\n/**\n * Gets the value of the keyword suitable for display for the specified locale.\n * E.g: for the locale string de_DE\\@collation=PHONEBOOK, this API gets the display \n * string for PHONEBOOK, in the display locale, when \"collation\" is specified as the keyword.\n *\n * @param locale            The locale to get the displayable variant code with. NULL may be used to specify the default.\n * @param keyword           The keyword for whose value should be used.\n * @param displayLocale     Specifies the locale to be used to display the name.  In other words,\n *                          if the locale's language code is \"en\", passing Locale::getFrench() for\n *                          inLocale would result in \"Anglais\", while passing Locale::getGerman()\n *                          for inLocale would result in \"Englisch\". NULL may be used to specify the default.\n * @param dest              the buffer to which the displayable keyword should be written.\n * @param destCapacity      The size of the buffer (number of UChars). If it is 0, then\n *                          dest may be NULL and the function will only return the length of the \n *                          result without writing any of the result string (pre-flighting).\n * @param status            error information if retrieving the displayable string failed. \n *                          Should not be NULL and must not indicate failure on entry.\n * @return the actual buffer size needed for the displayable variant code.  \n * @stable ICU 2.8\n */\nU_STABLE int32_t U_EXPORT2\nuloc_getDisplayKeywordValue(   const char* locale,\n                               const char* keyword,\n                               const char* displayLocale,\n                               UChar* dest,\n                               int32_t destCapacity,\n                               UErrorCode* status);\n/**\n * Gets the full name suitable for display for the specified locale.\n *\n * @param localeID the locale to get the displayable name with. NULL may be used to specify the default.\n * @param inLocaleID Specifies the locale to be used to display the name.  In other words,\n *                   if the locale's language code is \"en\", passing Locale::getFrench() for\n *                   inLocale would result in \"Anglais\", while passing Locale::getGerman()\n *                   for inLocale would result in \"Englisch\". NULL may be used to specify the default.\n * @param result the displayable name for localeID\n * @param maxResultSize the size of the name buffer to store the \n * displayable full name with\n * @param err error information if retrieving the displayable name failed\n * @return the actual buffer size needed for the displayable name.  If it's greater \n * than maxResultSize, the returned displayable name will be truncated.  \n * @stable ICU 2.0\n */\nU_STABLE int32_t U_EXPORT2\nuloc_getDisplayName(const char* localeID,\n            const char* inLocaleID,\n            UChar* result,\n            int32_t maxResultSize,\n            UErrorCode* err);\n\n\n/**\n * Gets the specified locale from a list of all available locales.  \n * The return value is a pointer to an item of \n * a locale name array.  Both this array and the pointers\n * it contains are owned by ICU and should not be deleted or written through\n * by the caller.  The locale name is terminated by a null pointer.\n * @param n the specific locale name index of the available locale list\n * @return a specified locale name of all available locales\n * @stable ICU 2.0\n */\nU_STABLE const char* U_EXPORT2\nuloc_getAvailable(int32_t n);\n\n/**\n * Gets the size of the all available locale list.\n *\n * @return the size of the locale list\n * @stable ICU 2.0\n */\nU_STABLE int32_t U_EXPORT2 uloc_countAvailable(void);\n\n/**\n *\n * Gets a list of all available language codes defined in ISO 639.  This is a pointer\n * to an array of pointers to arrays of char.  All of these pointers are owned\n * by ICU-- do not delete them, and do not write through them.  The array is\n * terminated with a null pointer.\n * @return a list of all available language codes\n * @stable ICU 2.0\n */\nU_STABLE const char* const* U_EXPORT2\nuloc_getISOLanguages(void);\n\n/**\n *\n * Gets a list of all available 2-letter country codes defined in ISO 639.  This is a\n * pointer to an array of pointers to arrays of char.  All of these pointers are\n * owned by ICU-- do not delete them, and do not write through them.  The array is\n * terminated with a null pointer.\n * @return a list of all available country codes\n * @stable ICU 2.0\n */\nU_STABLE const char* const* U_EXPORT2\nuloc_getISOCountries(void);\n\n/**\n * Truncate the locale ID string to get the parent locale ID.\n * Copies the part of the string before the last underscore.\n * The parent locale ID will be an empty string if there is no\n * underscore, or if there is only one underscore at localeID[0].\n *\n * @param localeID Input locale ID string.\n * @param parent   Output string buffer for the parent locale ID.\n * @param parentCapacity Size of the output buffer.\n * @param err A UErrorCode value.\n * @return The length of the parent locale ID.\n * @stable ICU 2.0\n */\nU_STABLE int32_t U_EXPORT2\nuloc_getParent(const char*    localeID,\n                 char* parent,\n                 int32_t parentCapacity,\n                 UErrorCode* err);\n\n\n\n\n/**\n * Gets the full name for the specified locale.\n * Note: This has the effect of 'canonicalizing' the string to\n * a certain extent. Upper and lower case are set as needed,\n * and if the components were in 'POSIX' format they are changed to\n * ICU format.  It does NOT map aliased names in any way.\n * See the top of this header file.\n * This API strips off the keyword part, so \"de_DE\\@collation=phonebook\" \n * will become \"de_DE\". \n * This API supports preflighting.\n *\n * @param localeID the locale to get the full name with\n * @param name fill in buffer for the name without keywords.\n * @param nameCapacity capacity of the fill in buffer.\n * @param err error information if retrieving the full name failed\n * @return the actual buffer size needed for the full name.  If it's greater \n * than nameCapacity, the returned full name will be truncated.  \n * @stable ICU 2.8\n */\nU_STABLE int32_t U_EXPORT2\nuloc_getBaseName(const char*    localeID,\n         char* name,\n         int32_t nameCapacity,\n         UErrorCode* err);\n\n/**\n * Gets an enumeration of keywords for the specified locale. Enumeration\n * must get disposed of by the client using uenum_close function.\n *\n * @param localeID the locale to get the variant code with\n * @param status error information if retrieving the keywords failed\n * @return enumeration of keywords or NULL if there are no keywords.\n * @stable ICU 2.8\n */\nU_STABLE UEnumeration* U_EXPORT2\nuloc_openKeywords(const char* localeID,\n                        UErrorCode* status);\n\n/**\n * Get the value for a keyword. Locale name does not need to be normalized.\n * \n * @param localeID locale name containing the keyword (\"de_DE@currency=EURO;collation=PHONEBOOK\")\n * @param keywordName name of the keyword for which we want the value. Case insensitive.\n * @param buffer receiving buffer\n * @param bufferCapacity capacity of receiving buffer\n * @param status containing error code - buffer not big enough.\n * @return the length of keyword value\n * @stable ICU 2.8\n */\nU_STABLE int32_t U_EXPORT2\nuloc_getKeywordValue(const char* localeID,\n                     const char* keywordName,\n                     char* buffer, int32_t bufferCapacity,\n                     UErrorCode* status);\n\n\n/**\n * Set the value of the specified keyword.\n * NOTE: Unlike almost every other ICU function which takes a\n * buffer, this function will NOT truncate the output text. If a\n * BUFFER_OVERFLOW_ERROR is received, it means that the original\n * buffer is untouched. This is done to prevent incorrect or possibly\n * even malformed locales from being generated and used.\n * \n * @param keywordName name of the keyword to be set. Case insensitive.\n * @param keywordValue value of the keyword to be set. If 0-length or\n *  NULL, will result in the keyword being removed. No error is given if \n *  that keyword does not exist.\n * @param buffer input buffer containing locale to be modified.\n * @param bufferCapacity capacity of receiving buffer\n * @param status containing error code - buffer not big enough.\n * @return the length needed for the buffer\n * @see uloc_getKeywordValue\n * @stable ICU 3.2\n */\nU_STABLE int32_t U_EXPORT2\nuloc_setKeywordValue(const char* keywordName,\n                     const char* keywordValue,\n                     char* buffer, int32_t bufferCapacity,\n                     UErrorCode* status);\n\n/**\n * enums for the  return value for the character and line orientation\n * functions.\n * @stable ICU 4.0\n */\ntypedef enum {\n  ULOC_LAYOUT_LTR   = 0,  /* left-to-right. */\n  ULOC_LAYOUT_RTL    = 1,  /* right-to-left. */\n  ULOC_LAYOUT_TTB    = 2,  /* top-to-bottom. */\n  ULOC_LAYOUT_BTT    = 3,   /* bottom-to-top. */\n  ULOC_LAYOUT_UNKNOWN\n} ULayoutType;\n\n/**\n * Get the layout character orientation for the specified locale.\n * \n * @param localeId locale name\n * @param status Error status\n * @return an enum indicating the layout orientation for characters.\n * @stable ICU 4.0\n */\nU_STABLE ULayoutType U_EXPORT2\nuloc_getCharacterOrientation(const char* localeId,\n                             UErrorCode *status);\n\n/**\n * Get the layout line orientation for the specified locale.\n * \n * @param localeId locale name\n * @param status Error status\n * @return an enum indicating the layout orientation for lines.\n * @stable ICU 4.0\n */\nU_STABLE ULayoutType U_EXPORT2\nuloc_getLineOrientation(const char* localeId,\n                        UErrorCode *status);\n\n/**\n * enums for the 'outResult' parameter return value\n * @see uloc_acceptLanguageFromHTTP\n * @see uloc_acceptLanguage\n * @stable ICU 3.2\n */\ntypedef enum {\n  ULOC_ACCEPT_FAILED   = 0,  /* No exact match was found. */\n  ULOC_ACCEPT_VALID    = 1,  /* An exact match was found. */\n  ULOC_ACCEPT_FALLBACK = 2   /* A fallback was found, for example, \n                                Accept list contained 'ja_JP'\n                                which matched available locale 'ja'. */\n} UAcceptResult;\n\n\n/**\n * Based on a HTTP header from a web browser and a list of available locales,\n * determine an acceptable locale for the user.\n * @param result - buffer to accept the result locale\n * @param resultAvailable the size of the result buffer.\n * @param outResult - An out parameter that contains the fallback status\n * @param httpAcceptLanguage - \"Accept-Language:\" header as per HTTP.\n * @param availableLocales - list of available locales to match\n * @param status Error status, may be BUFFER_OVERFLOW_ERROR\n * @return length needed for the locale.\n * @stable ICU 3.2\n */\nU_STABLE int32_t U_EXPORT2\nuloc_acceptLanguageFromHTTP(char *result, int32_t resultAvailable,\n                            UAcceptResult *outResult,\n                            const char *httpAcceptLanguage,\n                            UEnumeration* availableLocales,\n                            UErrorCode *status);\n\n/**\n * Based on a list of available locales,\n * determine an acceptable locale for the user.\n * @param result - buffer to accept the result locale\n * @param resultAvailable the size of the result buffer.\n * @param outResult - An out parameter that contains the fallback status\n * @param acceptList - list of acceptable languages\n * @param acceptListCount - count of acceptList items\n * @param availableLocales - list of available locales to match\n * @param status Error status, may be BUFFER_OVERFLOW_ERROR\n * @return length needed for the locale.\n * @stable ICU 3.2\n */\nU_STABLE int32_t U_EXPORT2\nuloc_acceptLanguage(char *result, int32_t resultAvailable, \n                    UAcceptResult *outResult, const char **acceptList,\n                    int32_t acceptListCount,\n                    UEnumeration* availableLocales,\n                    UErrorCode *status);\n\n\n/**\n * Gets the ICU locale ID for the specified Win32 LCID value.\n *\n * @param hostID the Win32 LCID to translate\n * @param locale the output buffer for the ICU locale ID, which will be NUL-terminated\n *  if there is room.\n * @param localeCapacity the size of the output buffer\n * @param status an error is returned if the LCID is unrecognized or the output buffer\n *  is too small\n * @return actual the actual size of the locale ID, not including NUL-termination \n * @stable ICU 3.8\n */\nU_STABLE int32_t U_EXPORT2\nuloc_getLocaleForLCID(uint32_t hostID, char *locale, int32_t localeCapacity,\n                    UErrorCode *status);\n\n\n/**\n * Add the likely subtags for a provided locale ID, per the algorithm described\n * in the following CLDR technical report:\n *\n *   http://www.unicode.org/reports/tr35/#Likely_Subtags\n *\n * If localeID is already in the maximal form, or there is no data available\n * for maximization, it will be copied to the output buffer.  For example,\n * \"und-Zzzz\" cannot be maximized, since there is no reasonable maximization.\n *\n * Examples:\n *\n * \"en\" maximizes to \"en_Latn_US\"\n *\n * \"de\" maximizes to \"de_Latn_US\"\n *\n * \"sr\" maximizes to \"sr_Cyrl_RS\"\n *\n * \"sh\" maximizes to \"sr_Latn_RS\" (Note this will not reverse.)\n *\n * \"zh_Hani\" maximizes to \"zh_Hans_CN\" (Note this will not reverse.)\n *\n * @param localeID The locale to maximize\n * @param maximizedLocaleID The maximized locale\n * @param maximizedLocaleIDCapacity The capacity of the maximizedLocaleID buffer\n * @param err Error information if maximizing the locale failed.  If the length\n * of the localeID and the null-terminator is greater than the maximum allowed size,\n * or the localeId is not well-formed, the error code is U_ILLEGAL_ARGUMENT_ERROR.\n * @return The actual buffer size needed for the maximized locale.  If it's\n * greater than maximizedLocaleIDCapacity, the returned ID will be truncated.\n * On error, the return value is -1.\n * @stable ICU 4.0\n */\nU_STABLE int32_t U_EXPORT2\nuloc_addLikelySubtags(const char*    localeID,\n         char* maximizedLocaleID,\n         int32_t maximizedLocaleIDCapacity,\n         UErrorCode* err);\n\n\n/**\n * Minimize the subtags for a provided locale ID, per the algorithm described\n * in the following CLDR technical report:\n *\n *   http://www.unicode.org/reports/tr35/#Likely_Subtags\n *\n * If localeID is already in the minimal form, or there is no data available\n * for minimization, it will be copied to the output buffer.  Since the\n * minimization algorithm relies on proper maximization, see the comments\n * for uloc_addLikelySubtags for reasons why there might not be any data.\n *\n * Examples:\n *\n * \"en_Latn_US\" minimizes to \"en\"\n *\n * \"de_Latn_US\" minimizes to \"de\"\n *\n * \"sr_Cyrl_RS\" minimizes to \"sr\"\n *\n * \"zh_Hant_TW\" minimizes to \"zh_TW\" (The region is preferred to the\n * script, and minimizing to \"zh\" would imply \"zh_Hans_CN\".)\n *\n * @param localeID The locale to minimize\n * @param minimizedLocaleID The minimized locale\n * @param minimizedLocaleIDCapacity The capacity of the minimizedLocaleID buffer\n * @param err Error information if minimizing the locale failed.  If the length\n * of the localeID and the null-terminator is greater than the maximum allowed size,\n * or the localeId is not well-formed, the error code is U_ILLEGAL_ARGUMENT_ERROR.\n * @return The actual buffer size needed for the minimized locale.  If it's\n * greater than minimizedLocaleIDCapacity, the returned ID will be truncated.\n * On error, the return value is -1.\n * @stable ICU 4.0\n */\nU_STABLE int32_t U_EXPORT2\nuloc_minimizeSubtags(const char*    localeID,\n         char* minimizedLocaleID,\n         int32_t minimizedLocaleIDCapacity,\n         UErrorCode* err);\n\n/**\n * Returns a locale ID for the specified BCP47 language tag string.\n * If the specified language tag contains any ill-formed subtags,\n * the first such subtag and all following subtags are ignored.\n * <p> \n * This implements the 'Language-Tag' production of BCP47, and so\n * supports grandfathered (regular and irregular) as well as private\n * use language tags.  Private use tags are represented as 'x-whatever',\n * and grandfathered tags are converted to their canonical replacements\n * where they exist.  Note that a few grandfathered tags have no modern\n * replacement, these will be converted using the fallback described in\n * the first paragraph, so some information might be lost.\n * @param langtag   the input BCP47 language tag.\n * @param localeID  the output buffer receiving a locale ID for the\n *                  specified BCP47 language tag.\n * @param localeIDCapacity  the size of the locale ID output buffer.\n * @param parsedLength  if not NULL, successfully parsed length\n *                      for the input language tag is set.\n * @param err       error information if receiving the locald ID\n *                  failed.\n * @return          the length of the locale ID.\n * @stable ICU 4.2\n */\nU_STABLE int32_t U_EXPORT2\nuloc_forLanguageTag(const char* langtag,\n                    char* localeID,\n                    int32_t localeIDCapacity,\n                    int32_t* parsedLength,\n                    UErrorCode* err);\n\n/**\n * Returns a well-formed language tag for this locale ID. \n * <p> \n * <b>Note</b>: When <code>strict</code> is FALSE, any locale\n * fields which do not satisfy the BCP47 syntax requirement will\n * be omitted from the result.  When <code>strict</code> is\n * TRUE, this function sets U_ILLEGAL_ARGUMENT_ERROR to the\n * <code>err</code> if any locale fields do not satisfy the\n * BCP47 syntax requirement.\n * @param localeID  the input locale ID\n * @param langtag   the output buffer receiving BCP47 language\n *                  tag for the locale ID.\n * @param langtagCapacity   the size of the BCP47 language tag\n *                          output buffer.\n * @param strict    boolean value indicating if the function returns\n *                  an error for an ill-formed input locale ID.\n * @param err       error information if receiving the language\n *                  tag failed.\n * @return          The length of the BCP47 language tag.\n * @stable ICU 4.2\n */\nU_STABLE int32_t U_EXPORT2\nuloc_toLanguageTag(const char* localeID,\n                   char* langtag,\n                   int32_t langtagCapacity,\n                   UBool strict,\n                   UErrorCode* err);\n\n#endif /*_ULOC*/\n"
  },
  {
    "path": "deprecated/android/addons/icucompat/unicode/ulocdata.h",
    "content": "/*\n******************************************************************************\n*                                                                            *\n* Copyright (C) 2003-2012, International Business Machines                   *\n*                Corporation and others. All Rights Reserved.                *\n*                                                                            *\n******************************************************************************\n*   file name:  ulocdata.h\n*   encoding:   US-ASCII\n*   tab size:   8 (not used)\n*   indentation:4\n*\n*   created on: 2003Oct21\n*   created by: Ram Viswanadha\n*/\n\n#ifndef __ULOCDATA_H__\n#define __ULOCDATA_H__\n\n#include \"unicode/ures.h\"\n#include \"unicode/uloc.h\"\n#include \"unicode/uset.h\"\n#include \"unicode/localpointer.h\"\n\n/**\n * \\file\n * \\brief C API: Provides access to locale data.\n */\n\n/** Forward declaration of the ULocaleData structure. @stable ICU 3.6 */\nstruct ULocaleData;\n\n/** A locale data object. @stable ICU 3.6 */\ntypedef struct ULocaleData ULocaleData;\n\n\n\n/** The possible types of exemplar character sets.\n  * @stable ICU 3.4\n  */\ntypedef enum ULocaleDataExemplarSetType  {\n    /** Basic set @stable ICU 3.4 */\n    ULOCDATA_ES_STANDARD=0,\n    /** Auxiliary set @stable ICU 3.4 */\n    ULOCDATA_ES_AUXILIARY=1,\n    /** Index Character set @stable ICU 4.8 */\n    ULOCDATA_ES_INDEX=2,\n    /** One higher than the last valid type @stable ICU 3.4 */\n    ULOCDATA_ES_COUNT=3\n} ULocaleDataExemplarSetType;\n\n/** The possible types of delimiters.\n  * @stable ICU 3.4\n  */\ntypedef enum ULocaleDataDelimiterType {\n    /** Quotation start @stable ICU 3.4 */\n    ULOCDATA_QUOTATION_START = 0,\n    /** Quotation end @stable ICU 3.4 */\n    ULOCDATA_QUOTATION_END = 1,\n    /** Alternate quotation start @stable ICU 3.4 */\n    ULOCDATA_ALT_QUOTATION_START = 2,\n    /** Alternate quotation end @stable ICU 3.4 */\n    ULOCDATA_ALT_QUOTATION_END = 3,\n    /** One higher than the last valid type @stable ICU 3.4 */\n    ULOCDATA_DELIMITER_COUNT = 4\n} ULocaleDataDelimiterType;\n\n/**\n * Opens a locale data object for the given locale\n *\n * @param localeID  Specifies the locale associated with this locale\n *                  data object.\n * @param status    Pointer to error status code.\n * @stable ICU 3.4\n */\nU_STABLE ULocaleData* U_EXPORT2\nulocdata_open(const char *localeID, UErrorCode *status);\n\n/**\n * Closes a locale data object.\n *\n * @param uld       The locale data object to close\n * @stable ICU 3.4\n */\nU_STABLE void U_EXPORT2\nulocdata_close(ULocaleData *uld);\n\n#if U_SHOW_CPLUSPLUS_API\n\nU_NAMESPACE_BEGIN\n\n/**\n * \\class LocalULocaleDataPointer\n * \"Smart pointer\" class, closes a ULocaleData via ulocdata_close().\n * For most methods see the LocalPointerBase base class.\n *\n * @see LocalPointerBase\n * @see LocalPointer\n * @stable ICU 4.4\n */\nU_DEFINE_LOCAL_OPEN_POINTER(LocalULocaleDataPointer, ULocaleData, ulocdata_close);\n\nU_NAMESPACE_END\n\n#endif\n\n/**\n * Sets the \"no Substitute\" attribute of the locale data\n * object.  If true, then any methods associated with the\n * locale data object will return null when there is no\n * data available for that method, given the locale ID\n * supplied to ulocdata_open().\n *\n * @param uld       The locale data object to set.\n * @param setting   Value of the \"no substitute\" attribute.\n * @stable ICU 3.4\n */\nU_STABLE void U_EXPORT2\nulocdata_setNoSubstitute(ULocaleData *uld, UBool setting);\n\n/**\n * Retrieves the current \"no Substitute\" value of the locale data\n * object.  If true, then any methods associated with the\n * locale data object will return null when there is no\n * data available for that method, given the locale ID\n * supplied to ulocdata_open().\n *\n * @param uld       Pointer to the The locale data object to set.\n * @return UBool    Value of the \"no substitute\" attribute.\n * @stable ICU 3.4\n */\nU_STABLE UBool U_EXPORT2\nulocdata_getNoSubstitute(ULocaleData *uld);\n\n/**\n * Returns the set of exemplar characters for a locale.\n *\n * @param uld       Pointer to the locale data object from which the\n *                  exemplar character set is to be retrieved.\n * @param fillIn    Pointer to a USet object to receive the\n *                  exemplar character set for the given locale.  Previous\n *                  contents of fillIn are lost.  <em>If fillIn is NULL,\n *                  then a new USet is created and returned.  The caller\n *                  owns the result and must dispose of it by calling\n *                  uset_close.</em>\n * @param options   Bitmask for options to apply to the exemplar pattern.\n *                  Specify zero to retrieve the exemplar set as it is\n *                  defined in the locale data.  Specify\n *                  USET_CASE_INSENSITIVE to retrieve a case-folded\n *                  exemplar set.  See uset_applyPattern for a complete\n *                  list of valid options.  The USET_IGNORE_SPACE bit is\n *                  always set, regardless of the value of 'options'.\n * @param extype    Specifies the type of exemplar set to be retrieved.\n * @param status    Pointer to an input-output error code value;\n *                  must not be NULL.  Will be set to U_MISSING_RESOURCE_ERROR\n *                  if the requested data is not available.\n * @return USet*    Either fillIn, or if fillIn is NULL, a pointer to\n *                  a newly-allocated USet that the user must close.\n *                  In case of error, NULL is returned.\n * @stable ICU 3.4\n */\nU_STABLE USet* U_EXPORT2\nulocdata_getExemplarSet(ULocaleData *uld, USet *fillIn,\n                        uint32_t options, ULocaleDataExemplarSetType extype, UErrorCode *status);\n\n/**\n * Returns one of the delimiter strings associated with a locale.\n *\n * @param uld           Pointer to the locale data object from which the\n *                      delimiter string is to be retrieved.\n * @param type          the type of delimiter to be retrieved.\n * @param result        A pointer to a buffer to receive the result.\n * @param resultLength  The maximum size of result.\n * @param status        Pointer to an error code value\n * @return int32_t      The total buffer size needed; if greater than resultLength,\n *                      the output was truncated.\n * @stable ICU 3.4\n */\nU_STABLE int32_t U_EXPORT2\nulocdata_getDelimiter(ULocaleData *uld, ULocaleDataDelimiterType type, UChar *result, int32_t resultLength, UErrorCode *status);\n\n/**\n * Enumeration for representing the measurement systems.\n * @stable ICU 2.8\n */\ntypedef enum UMeasurementSystem {\n    UMS_SI,     /** Measurement system specified by SI otherwise known as Metric system. */\n    UMS_US,     /** Measurement system followed in the United States of America. */\n    UMS_LIMIT\n} UMeasurementSystem;\n\n/**\n * Returns the measurement system used in the locale specified by the localeID.\n * Please note that this API will change in ICU 3.6 and will use an ulocdata object.\n *\n * @param localeID      The id of the locale for which the measurement system to be retrieved.\n * @param status        Must be a valid pointer to an error code value,\n *                      which must not indicate a failure before the function call.\n * @return UMeasurementSystem the measurement system used in the locale.\n * @stable ICU 2.8\n */\nU_STABLE UMeasurementSystem U_EXPORT2\nulocdata_getMeasurementSystem(const char *localeID, UErrorCode *status);\n\n/**\n * Returns the element gives the normal business letter size, and customary units.\n * The units for the numbers are always in <em>milli-meters</em>.\n * For US since 8.5 and 11 do not yeild an integral value when converted to milli-meters,\n * the values are rounded off.\n * So for A4 size paper the height and width are 297 mm and 210 mm repectively,\n * and for US letter size the height and width are 279 mm and 216 mm respectively.\n * Please note that this API will change in ICU 3.6 and will use an ulocdata object.\n *\n * @param localeID      The id of the locale for which the paper size information to be retrieved.\n * @param height        A pointer to int to recieve the height information.\n * @param width         A pointer to int to recieve the width information.\n * @param status        Must be a valid pointer to an error code value,\n *                      which must not indicate a failure before the function call.\n * @stable ICU 2.8\n */\nU_STABLE void U_EXPORT2\nulocdata_getPaperSize(const char *localeID, int32_t *height, int32_t *width, UErrorCode *status);\n\n/**\n * Return the current CLDR version used by the library.\n * @param versionArray fillin that will recieve the version number\n * @param status error code - could be U_MISSING_RESOURCE_ERROR if the version was not found.\n * @stable ICU 4.2\n */\nU_STABLE void U_EXPORT2\nulocdata_getCLDRVersion(UVersionInfo versionArray, UErrorCode *status);\n\n/**\n * Returns locale display pattern associated with a locale.\n *\n * @param uld       Pointer to the locale data object from which the\n *                  exemplar character set is to be retrieved.\n * @param pattern   locale display pattern for locale.\n * @param patternCapacity the size of the buffer to store the locale display\n *                  pattern with.\n * @param status    Must be a valid pointer to an error code value,\n *                  which must not indicate a failure before the function call.\n * @return the actual buffer size needed for localeDisplayPattern.  If it's greater\n * than patternCapacity, the returned pattern will be truncated.\n *\n * @stable ICU 4.2\n */\nU_STABLE int32_t U_EXPORT2\nulocdata_getLocaleDisplayPattern(ULocaleData *uld,\n                                 UChar *pattern,\n                                 int32_t patternCapacity,\n                                 UErrorCode *status);\n\n\n/**\n * Returns locale separator associated with a locale.\n *\n * @param uld       Pointer to the locale data object from which the\n *                  exemplar character set is to be retrieved.\n * @param separator locale separator for locale.\n * @param separatorCapacity the size of the buffer to store the locale\n *                  separator with.\n * @param status    Must be a valid pointer to an error code value,\n *                  which must not indicate a failure before the function call.\n * @return the actual buffer size needed for localeSeparator.  If it's greater\n * than separatorCapacity, the returned separator will be truncated.\n *\n * @stable ICU 4.2\n */\nU_STABLE int32_t U_EXPORT2\nulocdata_getLocaleSeparator(ULocaleData *uld,\n                            UChar *separator,\n                            int32_t separatorCapacity,\n                            UErrorCode *status);\n#endif\n"
  },
  {
    "path": "deprecated/android/addons/icucompat/unicode/umachine.h",
    "content": "/*\n******************************************************************************\n*\n*   Copyright (C) 1999-2012, International Business Machines\n*   Corporation and others.  All Rights Reserved.\n*\n******************************************************************************\n*   file name:  umachine.h\n*   encoding:   US-ASCII\n*   tab size:   8 (not used)\n*   indentation:4\n*\n*   created on: 1999sep13\n*   created by: Markus W. Scherer\n*\n*   This file defines basic types and constants for utf.h to be\n*   platform-independent. umachine.h and utf.h are included into\n*   utypes.h to provide all the general definitions for ICU.\n*   All of these definitions used to be in utypes.h before\n*   the UTF-handling macros made this unmaintainable.\n*/\n\n#ifndef __UMACHINE_H__\n#define __UMACHINE_H__\n\n\n/**\n * \\file\n * \\brief Basic types and constants for UTF\n *\n * <h2> Basic types and constants for UTF </h2>\n *   This file defines basic types and constants for utf.h to be\n *   platform-independent. umachine.h and utf.h are included into\n *   utypes.h to provide all the general definitions for ICU.\n *   All of these definitions used to be in utypes.h before\n *   the UTF-handling macros made this unmaintainable.\n *\n */\n/*==========================================================================*/\n/* Include platform-dependent definitions                                   */\n/* which are contained in the platform-specific file platform.h             */\n/*==========================================================================*/\n\n#include \"unicode/ptypes.h\" /* platform.h is included in ptypes.h */\n\n/*\n * ANSI C headers:\n * stddef.h defines wchar_t\n */\n#include <stddef.h>\n\n/*==========================================================================*/\n/* For C wrappers, we use the symbol U_STABLE.                                */\n/* This works properly if the includer is C or C++.                         */\n/* Functions are declared   U_STABLE return-type U_EXPORT2 function-name()... */\n/*==========================================================================*/\n\n/**\n * \\def U_CFUNC\n * This is used in a declaration of a library private ICU C function.\n * @stable ICU 2.4\n */\n\n/**\n * \\def U_CDECL_BEGIN\n * This is used to begin a declaration of a library private ICU C API.\n * @stable ICU 2.4\n */\n\n/**\n * \\def U_CDECL_END\n * This is used to end a declaration of a library private ICU C API\n * @stable ICU 2.4\n */\n\n#ifdef __cplusplus\n#   define U_CFUNC extern \"C\"\n#   define U_CDECL_BEGIN extern \"C\" {\n#   define U_CDECL_END   }\n#else\n#   define U_CFUNC extern\n#   define U_CDECL_BEGIN\n#   define U_CDECL_END\n#endif\n\n#ifndef U_ATTRIBUTE_DEPRECATED\n/**\n * \\def U_ATTRIBUTE_DEPRECATED\n *  This is used for GCC specific attributes\n * @internal\n */\n#if U_GCC_MAJOR_MINOR >= 302\n#    define U_ATTRIBUTE_DEPRECATED __attribute__ ((deprecated))\n/**\n * \\def U_ATTRIBUTE_DEPRECATED\n * This is used for Visual C++ specific attributes \n * @internal\n */\n#elif defined(_MSC_VER) && (_MSC_VER >= 1400)\n#    define U_ATTRIBUTE_DEPRECATED __declspec(deprecated)\n#else\n#    define U_ATTRIBUTE_DEPRECATED\n#endif\n#endif\n\n/** This is used to declare a function as a public ICU C API @stable ICU 2.0*/\n#define U_CAPI U_CFUNC U_EXPORT\n/** This is used to declare a function as a stable public ICU C API*/\n#define U_STABLE U_CAPI\n/** This is used to declare a function as a draft public ICU C API  */\n#define U_DRAFT  U_CAPI\n/** This is used to declare a function as a deprecated public ICU C API  */\n#define U_DEPRECATED U_CAPI U_ATTRIBUTE_DEPRECATED\n/** This is used to declare a function as an obsolete public ICU C API  */\n#define U_OBSOLETE U_CAPI\n/** This is used to declare a function as an internal ICU C API  */\n#define U_INTERNAL U_CAPI\n\n/*==========================================================================*/\n/* limits for int32_t etc., like in POSIX inttypes.h                        */\n/*==========================================================================*/\n\n#ifndef INT8_MIN\n/** The smallest value an 8 bit signed integer can hold @stable ICU 2.0 */\n#   define INT8_MIN        ((int8_t)(-128))\n#endif\n#ifndef INT16_MIN\n/** The smallest value a 16 bit signed integer can hold @stable ICU 2.0 */\n#   define INT16_MIN       ((int16_t)(-32767-1))\n#endif\n#ifndef INT32_MIN\n/** The smallest value a 32 bit signed integer can hold @stable ICU 2.0 */\n#   define INT32_MIN       ((int32_t)(-2147483647-1))\n#endif\n\n#ifndef INT8_MAX\n/** The largest value an 8 bit signed integer can hold @stable ICU 2.0 */\n#   define INT8_MAX        ((int8_t)(127))\n#endif\n#ifndef INT16_MAX\n/** The largest value a 16 bit signed integer can hold @stable ICU 2.0 */\n#   define INT16_MAX       ((int16_t)(32767))\n#endif\n#ifndef INT32_MAX\n/** The largest value a 32 bit signed integer can hold @stable ICU 2.0 */\n#   define INT32_MAX       ((int32_t)(2147483647))\n#endif\n\n#ifndef UINT8_MAX\n/** The largest value an 8 bit unsigned integer can hold @stable ICU 2.0 */\n#   define UINT8_MAX       ((uint8_t)(255U))\n#endif\n#ifndef UINT16_MAX\n/** The largest value a 16 bit unsigned integer can hold @stable ICU 2.0 */\n#   define UINT16_MAX      ((uint16_t)(65535U))\n#endif\n#ifndef UINT32_MAX\n/** The largest value a 32 bit unsigned integer can hold @stable ICU 2.0 */\n#   define UINT32_MAX      ((uint32_t)(4294967295U))\n#endif\n\n#if defined(U_INT64_T_UNAVAILABLE)\n# error int64_t is required for decimal format and rule-based number format.\n#else\n# ifndef INT64_C\n/**\n * Provides a platform independent way to specify a signed 64-bit integer constant.\n * note: may be wrong for some 64 bit platforms - ensure your compiler provides INT64_C\n * @stable ICU 2.8\n */\n#   define INT64_C(c) c ## LL\n# endif\n# ifndef UINT64_C\n/**\n * Provides a platform independent way to specify an unsigned 64-bit integer constant.\n * note: may be wrong for some 64 bit platforms - ensure your compiler provides UINT64_C\n * @stable ICU 2.8\n */\n#   define UINT64_C(c) c ## ULL\n# endif\n# ifndef U_INT64_MIN\n/** The smallest value a 64 bit signed integer can hold @stable ICU 2.8 */\n#     define U_INT64_MIN       ((int64_t)(INT64_C(-9223372036854775807)-1))\n# endif\n# ifndef U_INT64_MAX\n/** The largest value a 64 bit signed integer can hold @stable ICU 2.8 */\n#     define U_INT64_MAX       ((int64_t)(INT64_C(9223372036854775807)))\n# endif\n# ifndef U_UINT64_MAX\n/** The largest value a 64 bit unsigned integer can hold @stable ICU 2.8 */\n#     define U_UINT64_MAX      ((uint64_t)(UINT64_C(18446744073709551615)))\n# endif\n#endif\n\n/*==========================================================================*/\n/* Boolean data type                                                        */\n/*==========================================================================*/\n\n/** The ICU boolean type @stable ICU 2.0 */\ntypedef int8_t UBool;\n\n#ifndef TRUE\n/** The TRUE value of a UBool @stable ICU 2.0 */\n#   define TRUE  1\n#endif\n#ifndef FALSE\n/** The FALSE value of a UBool @stable ICU 2.0 */\n#   define FALSE 0\n#endif\n\n\n/*==========================================================================*/\n/* Unicode data types                                                       */\n/*==========================================================================*/\n\n/* wchar_t-related definitions -------------------------------------------- */\n\n/*\n * \\def U_WCHAR_IS_UTF16\n * Defined if wchar_t uses UTF-16.\n *\n * @stable ICU 2.0\n */\n/*\n * \\def U_WCHAR_IS_UTF32\n * Defined if wchar_t uses UTF-32.\n *\n * @stable ICU 2.0\n */\n#if !defined(U_WCHAR_IS_UTF16) && !defined(U_WCHAR_IS_UTF32)\n#   ifdef __STDC_ISO_10646__\n#       if (U_SIZEOF_WCHAR_T==2)\n#           define U_WCHAR_IS_UTF16\n#       elif (U_SIZEOF_WCHAR_T==4)\n#           define  U_WCHAR_IS_UTF32\n#       endif\n#   elif defined __UCS2__\n#       if (U_PF_OS390 <= U_PLATFORM && U_PLATFORM <= U_PF_OS400) && (U_SIZEOF_WCHAR_T==2)\n#           define U_WCHAR_IS_UTF16\n#       endif\n#   elif defined(__UCS4__) || (U_PLATFORM == U_PF_OS400 && defined(__UTF32__))\n#       if (U_SIZEOF_WCHAR_T==4)\n#           define U_WCHAR_IS_UTF32\n#       endif\n#   elif U_PLATFORM_IS_DARWIN_BASED || (U_SIZEOF_WCHAR_T==4 && U_PLATFORM_IS_LINUX_BASED)\n#       define U_WCHAR_IS_UTF32\n#   elif U_PLATFORM_HAS_WIN32_API\n#       define U_WCHAR_IS_UTF16\n#   endif\n#endif\n\n/* UChar and UChar32 definitions -------------------------------------------- */\n\n/** Number of bytes in a UChar. @stable ICU 2.0 */\n#define U_SIZEOF_UCHAR 2\n\n/**\n * \\var UChar\n * Define UChar to be UCHAR_TYPE, if that is #defined (for example, to char16_t),\n * or wchar_t if that is 16 bits wide; always assumed to be unsigned.\n * If neither is available, then define UChar to be uint16_t.\n *\n * This makes the definition of UChar platform-dependent\n * but allows direct string type compatibility with platforms with\n * 16-bit wchar_t types.\n *\n * @stable ICU 4.4\n */\n#if defined(UCHAR_TYPE)\n    typedef UCHAR_TYPE UChar;\n/* Not #elif U_HAVE_CHAR16_T -- because that is type-incompatible with pre-C++11 callers\n    typedef char16_t UChar;  */\n#elif U_SIZEOF_WCHAR_T==2\n    typedef wchar_t UChar;\n#elif defined(__CHAR16_TYPE__)\n    typedef __CHAR16_TYPE__ UChar;\n#else\n    typedef uint16_t UChar;\n#endif\n\n/**\n * Define UChar32 as a type for single Unicode code points.\n * UChar32 is a signed 32-bit integer (same as int32_t).\n *\n * The Unicode code point range is 0..0x10ffff.\n * All other values (negative or >=0x110000) are illegal as Unicode code points.\n * They may be used as sentinel values to indicate \"done\", \"error\"\n * or similar non-code point conditions.\n *\n * Before ICU 2.4 (Jitterbug 2146), UChar32 was defined\n * to be wchar_t if that is 32 bits wide (wchar_t may be signed or unsigned)\n * or else to be uint32_t.\n * That is, the definition of UChar32 was platform-dependent.\n *\n * @see U_SENTINEL\n * @stable ICU 2.4\n */\ntypedef int32_t UChar32;\n\n/**\n * This value is intended for sentinel values for APIs that\n * (take or) return single code points (UChar32).\n * It is outside of the Unicode code point range 0..0x10ffff.\n * \n * For example, a \"done\" or \"error\" value in a new API\n * could be indicated with U_SENTINEL.\n *\n * ICU APIs designed before ICU 2.4 usually define service-specific \"done\"\n * values, mostly 0xffff.\n * Those may need to be distinguished from\n * actual U+ffff text contents by calling functions like\n * CharacterIterator::hasNext() or UnicodeString::length().\n *\n * @return -1\n * @see UChar32\n * @stable ICU 2.4\n */\n#define U_SENTINEL (-1)\n\n#include \"unicode/urename.h\"\n\n#endif\n"
  },
  {
    "path": "deprecated/android/addons/icucompat/unicode/umisc.h",
    "content": "/*\n**********************************************************************\n*   Copyright (C) 1999-2006, International Business Machines\n*   Corporation and others.  All Rights Reserved.\n**********************************************************************\n*   file name:  umisc.h\n*   encoding:   US-ASCII\n*   tab size:   8 (not used)\n*   indentation:4\n*\n*   created on: 1999oct15\n*   created by: Markus W. Scherer\n*/\n\n#ifndef UMISC_H\n#define UMISC_H\n\n#include \"unicode/utypes.h\"\n\n/**\n * \\file\n * \\brief  C API:misc definitions \n *\n *  This file contains miscellaneous definitions for the C APIs. \n */\n\nU_CDECL_BEGIN\n\n/** A struct representing a range of text containing a specific field \n *  @stable ICU 2.0\n */\ntypedef struct UFieldPosition {\n  /**\n   * The field \n   * @stable ICU 2.0\n   */\n  int32_t field;\n  /**\n   * The start of the text range containing field \n   * @stable ICU 2.0\n   */\n  int32_t beginIndex;\n  /** \n   * The limit of the text range containing field \n   * @stable ICU 2.0\n   */\n  int32_t endIndex;\n} UFieldPosition;\n\n#if !UCONFIG_NO_SERVICE\n/**\n * Opaque type returned by registerInstance, registerFactory and unregister for service registration.\n * @stable ICU 2.6\n */\ntypedef const void* URegistryKey;\n#endif\n\nU_CDECL_END\n\n#endif\n"
  },
  {
    "path": "deprecated/android/addons/icucompat/unicode/umsg.h",
    "content": "/********************************************************************\n * COPYRIGHT: \n * Copyright (c) 1997-2011, International Business Machines Corporation and\n * others. All Rights Reserved.\n * Copyright (C) 2010 , Yahoo! Inc. \n ********************************************************************\n *\n *   file name:  umsg.h\n *   encoding:   US-ASCII\n *   tab size:   8 (not used)\n *   indentation:4\n *\n *   Change history:\n *\n *   08/5/2001  Ram         Added C wrappers for C++ API.\n ********************************************************************/\n\n#ifndef UMSG_H\n#define UMSG_H\n\n#include \"unicode/utypes.h\"\n\n#if !UCONFIG_NO_FORMATTING\n\n#include \"unicode/localpointer.h\"\n#include \"unicode/uloc.h\"\n#include \"unicode/parseerr.h\"\n#include <stdarg.h>\n\n/**\n * \\file\n * \\brief C API: MessageFormat\n *\n * <h2>MessageFormat C API </h2>\n *\n * <p>MessageFormat prepares strings for display to users,\n * with optional arguments (variables/placeholders).\n * The arguments can occur in any order, which is necessary for translation\n * into languages with different grammars.\n *\n * <p>The opaque UMessageFormat type is a thin C wrapper around\n * a C++ MessageFormat. It is constructed from a <em>pattern</em> string\n * with arguments in {curly braces} which will be replaced by formatted values.\n *\n * <p>Currently, the C API supports only numbered arguments.\n *\n * <p>For details about the pattern syntax and behavior,\n * especially about the ASCII apostrophe vs. the\n * real apostrophe (single quote) character \\htmlonly&#x2019;\\endhtmlonly (U+2019),\n * see the C++ MessageFormat class documentation.\n *\n * <p>Here are some examples of C API usage:\n * Example 1:\n * <pre>\n * \\code\n *     UChar *result, *tzID, *str;\n *     UChar pattern[100];\n *     int32_t resultLengthOut, resultlength;\n *     UCalendar *cal;\n *     UDate d1;\n *     UDateFormat *def1;\n *     UErrorCode status = U_ZERO_ERROR;\n *\n *     str=(UChar*)malloc(sizeof(UChar) * (strlen(\"disturbance in force\") +1));\n *     u_uastrcpy(str, \"disturbance in force\");\n *     tzID=(UChar*)malloc(sizeof(UChar) * 4);\n *     u_uastrcpy(tzID, \"PST\");\n *     cal=ucal_open(tzID, u_strlen(tzID), \"en_US\", UCAL_TRADITIONAL, &status);\n *     ucal_setDateTime(cal, 1999, UCAL_MARCH, 18, 0, 0, 0, &status);\n *     d1=ucal_getMillis(cal, &status);\n *     u_uastrcpy(pattern, \"On {0, date, long}, there was a {1} on planet {2,number,integer}\");\n *     resultlength=0;\n *     resultLengthOut=u_formatMessage( \"en_US\", pattern, u_strlen(pattern), NULL, resultlength, &status, d1, str, 7);\n *     if(status==U_BUFFER_OVERFLOW_ERROR){\n *         status=U_ZERO_ERROR;\n *         resultlength=resultLengthOut+1;\n *         result=(UChar*)realloc(result, sizeof(UChar) * resultlength);\n *         u_formatMessage( \"en_US\", pattern, u_strlen(pattern), result, resultlength, &status, d1, str, 7);\n *     }\n *     printf(\"%s\\n\", austrdup(result) );//austrdup( a function used to convert UChar* to char*)\n *     //output>: \"On March 18, 1999, there was a disturbance in force on planet 7\n * \\endcode\n * </pre>\n * Typically, the message format will come from resources, and the\n * arguments will be dynamically set at runtime.\n * <P>\n * Example 2:\n * <pre>\n * \\code\n *     UChar* str;\n *     UErrorCode status = U_ZERO_ERROR;\n *     UChar *result;\n *     UChar pattern[100];\n *     int32_t resultlength, resultLengthOut, i;\n *     double testArgs= { 100.0, 1.0, 0.0};\n *\n *     str=(UChar*)malloc(sizeof(UChar) * 10);\n *     u_uastrcpy(str, \"MyDisk\");\n *     u_uastrcpy(pattern, \"The disk {1} contains {0,choice,0#no files|1#one file|1<{0,number,integer} files}\");\n *     for(i=0; i<3; i++){\n *       resultlength=0; \n *       resultLengthOut=u_formatMessage( \"en_US\", pattern, u_strlen(pattern), NULL, resultlength, &status, testArgs[i], str); \n *       if(status==U_BUFFER_OVERFLOW_ERROR){\n *         status=U_ZERO_ERROR;\n *         resultlength=resultLengthOut+1;\n *         result=(UChar*)malloc(sizeof(UChar) * resultlength);\n *         u_formatMessage( \"en_US\", pattern, u_strlen(pattern), result, resultlength, &status, testArgs[i], str);\n *       }\n *       printf(\"%s\\n\", austrdup(result) );  //austrdup( a function used to convert UChar* to char*)\n *       free(result);\n *     }\n *     // output, with different testArgs:\n *     // output: The disk \"MyDisk\" contains 100 files.\n *     // output: The disk \"MyDisk\" contains one file.\n *     // output: The disk \"MyDisk\" contains no files.\n * \\endcode\n *  </pre>\n *\n *\n * Example 3:\n * <pre>\n * \\code\n * UChar* str;\n * UChar* str1;\n * UErrorCode status = U_ZERO_ERROR;\n * UChar *result;\n * UChar pattern[100];\n * UChar expected[100];\n * int32_t resultlength,resultLengthOut;\n\n * str=(UChar*)malloc(sizeof(UChar) * 25);\n * u_uastrcpy(str, \"Kirti\");\n * str1=(UChar*)malloc(sizeof(UChar) * 25);\n * u_uastrcpy(str1, \"female\");\n * log_verbose(\"Testing message format with Select test #1\\n:\");\n * u_uastrcpy(pattern, \"{0} est {1, select, female {all\\\\u00E9e} other {all\\\\u00E9}} \\\\u00E0 Paris.\");\n * u_uastrcpy(expected, \"Kirti est all\\\\u00E9e \\\\u00E0 Paris.\");\n * resultlength=0;\n * resultLengthOut=u_formatMessage( \"fr\", pattern, u_strlen(pattern), NULL, resultlength, &status, str , str1);\n * if(status==U_BUFFER_OVERFLOW_ERROR)\n *  {\n *      status=U_ZERO_ERROR;\n *      resultlength=resultLengthOut+1;\n *      result=(UChar*)malloc(sizeof(UChar) * resultlength);\n *      u_formatMessage( \"fr\", pattern, u_strlen(pattern), result, resultlength, &status, str , str1);\n *      if(u_strcmp(result, expected)==0)\n *          log_verbose(\"PASS: MessagFormat successful on Select test#1\\n\");\n *      else{\n *          log_err(\"FAIL: Error in MessageFormat on Select test#1\\n GOT %s EXPECTED %s\\n\", austrdup(result),\n *          austrdup(expected) );\n *      }\n *      free(result);\n * }\n * \\endcode\n *  </pre>\n */\n\n/**\n * Format a message for a locale.\n * This function may perform re-ordering of the arguments depending on the\n * locale. For all numeric arguments, double is assumed unless the type is\n * explicitly integer.  All choice format arguments must be of type double.\n * @param locale The locale for which the message will be formatted\n * @param pattern The pattern specifying the message's format\n * @param patternLength The length of pattern\n * @param result A pointer to a buffer to receive the formatted message.\n * @param resultLength The maximum size of result.\n * @param status A pointer to an UErrorCode to receive any errors\n * @param ... A variable-length argument list containing the arguments specified\n * in pattern.\n * @return The total buffer size needed; if greater than resultLength, the\n * output was truncated.\n * @see u_parseMessage\n * @stable ICU 2.0\n */\nU_STABLE int32_t U_EXPORT2 \nu_formatMessage(const char  *locale,\n                 const UChar *pattern,\n                int32_t     patternLength,\n                UChar       *result,\n                int32_t     resultLength,\n                UErrorCode  *status,\n                ...);\n\n/**\n * Format a message for a locale.\n * This function may perform re-ordering of the arguments depending on the\n * locale. For all numeric arguments, double is assumed unless the type is\n * explicitly integer.  All choice format arguments must be of type double.\n * @param locale The locale for which the message will be formatted\n * @param pattern The pattern specifying the message's format\n * @param patternLength The length of pattern\n * @param result A pointer to a buffer to receive the formatted message.\n * @param resultLength The maximum size of result.\n * @param ap A variable-length argument list containing the arguments specified\n * @param status A pointer to an UErrorCode to receive any errors\n * in pattern.\n * @return The total buffer size needed; if greater than resultLength, the\n * output was truncated.\n * @see u_parseMessage\n * @stable ICU 2.0\n */\nU_STABLE int32_t U_EXPORT2 \nu_vformatMessage(   const char  *locale,\n                    const UChar *pattern,\n                    int32_t     patternLength,\n                    UChar       *result,\n                    int32_t     resultLength,\n                    va_list     ap,\n                    UErrorCode  *status);\n\n/**\n * Parse a message.\n * For numeric arguments, this function will always use doubles.  Integer types\n * should not be passed.\n * This function is not able to parse all output from {@link #u_formatMessage }.\n * @param locale The locale for which the message is formatted\n * @param pattern The pattern specifying the message's format\n * @param patternLength The length of pattern\n * @param source The text to parse.\n * @param sourceLength The length of source, or -1 if null-terminated.\n * @param status A pointer to an UErrorCode to receive any errors\n * @param ... A variable-length argument list containing the arguments\n * specified in pattern.\n * @see u_formatMessage\n * @stable ICU 2.0\n */\nU_STABLE void U_EXPORT2 \nu_parseMessage( const char   *locale,\n                const UChar  *pattern,\n                int32_t      patternLength,\n                const UChar  *source,\n                int32_t      sourceLength,\n                UErrorCode   *status,\n                ...);\n\n/**\n * Parse a message.\n * For numeric arguments, this function will always use doubles.  Integer types\n * should not be passed.\n * This function is not able to parse all output from {@link #u_formatMessage }.\n * @param locale The locale for which the message is formatted\n * @param pattern The pattern specifying the message's format\n * @param patternLength The length of pattern\n * @param source The text to parse.\n * @param sourceLength The length of source, or -1 if null-terminated.\n * @param ap A variable-length argument list containing the arguments\n * @param status A pointer to an UErrorCode to receive any errors\n * specified in pattern.\n * @see u_formatMessage\n * @stable ICU 2.0\n */\nU_STABLE void U_EXPORT2 \nu_vparseMessage(const char  *locale,\n                const UChar *pattern,\n                int32_t     patternLength,\n                const UChar *source,\n                int32_t     sourceLength,\n                va_list     ap,\n                UErrorCode  *status);\n\n/**\n * Format a message for a locale.\n * This function may perform re-ordering of the arguments depending on the\n * locale. For all numeric arguments, double is assumed unless the type is\n * explicitly integer.  All choice format arguments must be of type double.\n * @param locale The locale for which the message will be formatted\n * @param pattern The pattern specifying the message's format\n * @param patternLength The length of pattern\n * @param result A pointer to a buffer to receive the formatted message.\n * @param resultLength The maximum size of result.\n * @param status A pointer to an UErrorCode to receive any errors\n * @param ... A variable-length argument list containing the arguments specified\n * in pattern.\n * @param parseError  A pointer to UParseError to receive information about errors\n *                     occurred during parsing.\n * @return The total buffer size needed; if greater than resultLength, the\n * output was truncated.\n * @see u_parseMessage\n * @stable ICU 2.0\n */\nU_STABLE int32_t U_EXPORT2 \nu_formatMessageWithError(   const char    *locale,\n                            const UChar   *pattern,\n                            int32_t       patternLength,\n                            UChar         *result,\n                            int32_t       resultLength,\n                            UParseError   *parseError,\n                            UErrorCode    *status,\n                            ...);\n\n/**\n * Format a message for a locale.\n * This function may perform re-ordering of the arguments depending on the\n * locale. For all numeric arguments, double is assumed unless the type is\n * explicitly integer.  All choice format arguments must be of type double.\n * @param locale The locale for which the message will be formatted\n * @param pattern The pattern specifying the message's format\n * @param patternLength The length of pattern\n * @param result A pointer to a buffer to receive the formatted message.\n * @param resultLength The maximum size of result.\n * @param parseError  A pointer to UParseError to receive information about errors\n *                    occurred during parsing.\n * @param ap A variable-length argument list containing the arguments specified\n * @param status A pointer to an UErrorCode to receive any errors\n * in pattern.\n * @return The total buffer size needed; if greater than resultLength, the\n * output was truncated.\n * @stable ICU 2.0\n */\nU_STABLE int32_t U_EXPORT2 \nu_vformatMessageWithError(  const char   *locale,\n                            const UChar  *pattern,\n                            int32_t      patternLength,\n                            UChar        *result,\n                            int32_t      resultLength,\n                            UParseError* parseError,\n                            va_list      ap,\n                            UErrorCode   *status);\n\n/**\n * Parse a message.\n * For numeric arguments, this function will always use doubles.  Integer types\n * should not be passed.\n * This function is not able to parse all output from {@link #u_formatMessage }.\n * @param locale The locale for which the message is formatted\n * @param pattern The pattern specifying the message's format\n * @param patternLength The length of pattern\n * @param source The text to parse.\n * @param sourceLength The length of source, or -1 if null-terminated.\n * @param parseError  A pointer to UParseError to receive information about errors\n *                     occurred during parsing.\n * @param status A pointer to an UErrorCode to receive any errors\n * @param ... A variable-length argument list containing the arguments\n * specified in pattern.\n * @see u_formatMessage\n * @stable ICU 2.0\n */\nU_STABLE void U_EXPORT2 \nu_parseMessageWithError(const char  *locale,\n                        const UChar *pattern,\n                        int32_t     patternLength,\n                        const UChar *source,\n                        int32_t     sourceLength,\n                        UParseError *parseError,\n                        UErrorCode  *status,\n                        ...);\n\n/**\n * Parse a message.\n * For numeric arguments, this function will always use doubles.  Integer types\n * should not be passed.\n * This function is not able to parse all output from {@link #u_formatMessage }.\n * @param locale The locale for which the message is formatted\n * @param pattern The pattern specifying the message's format\n * @param patternLength The length of pattern\n * @param source The text to parse.\n * @param sourceLength The length of source, or -1 if null-terminated.\n * @param ap A variable-length argument list containing the arguments\n * @param parseError  A pointer to UParseError to receive information about errors\n *                     occurred during parsing.\n * @param status A pointer to an UErrorCode to receive any errors\n * specified in pattern.\n * @see u_formatMessage\n * @stable ICU 2.0\n */\nU_STABLE void U_EXPORT2 \nu_vparseMessageWithError(const char  *locale,\n                         const UChar *pattern,\n                         int32_t     patternLength,\n                         const UChar *source,\n                         int32_t     sourceLength,\n                         va_list     ap,\n                         UParseError *parseError,\n                         UErrorCode* status);\n\n/*----------------------- New experimental API --------------------------- */\n/** \n * The message format object\n * @stable ICU 2.0\n */\ntypedef void* UMessageFormat;\n\n\n/**\n * Open a message formatter with given pattern and for the given locale.\n * @param pattern       A pattern specifying the format to use.\n * @param patternLength Length of the pattern to use\n * @param locale        The locale for which the messages are formatted.\n * @param parseError    A pointer to UParseError struct to receive any errors \n *                      occured during parsing. Can be NULL.\n * @param status        A pointer to an UErrorCode to receive any errors.\n * @return              A pointer to a UMessageFormat to use for formatting \n *                      messages, or 0 if an error occurred. \n * @stable ICU 2.0\n */\nU_STABLE UMessageFormat* U_EXPORT2 \numsg_open(  const UChar     *pattern,\n            int32_t         patternLength,\n            const  char     *locale,\n            UParseError     *parseError,\n            UErrorCode      *status);\n\n/**\n * Close a UMessageFormat.\n * Once closed, a UMessageFormat may no longer be used.\n * @param format The formatter to close.\n * @stable ICU 2.0\n */\nU_STABLE void U_EXPORT2 \numsg_close(UMessageFormat* format);\n\n#if U_SHOW_CPLUSPLUS_API\n\nU_NAMESPACE_BEGIN\n\n/**\n * \\class LocalUMessageFormatPointer\n * \"Smart pointer\" class, closes a UMessageFormat via umsg_close().\n * For most methods see the LocalPointerBase base class.\n *\n * @see LocalPointerBase\n * @see LocalPointer\n * @stable ICU 4.4\n */\nU_DEFINE_LOCAL_OPEN_POINTER(LocalUMessageFormatPointer, UMessageFormat, umsg_close);\n\nU_NAMESPACE_END\n\n#endif\n\n/**\n * Open a copy of a UMessageFormat.\n * This function performs a deep copy.\n * @param fmt The formatter to copy\n * @param status A pointer to an UErrorCode to receive any errors.\n * @return A pointer to a UDateFormat identical to fmt.\n * @stable ICU 2.0\n */\nU_STABLE UMessageFormat U_EXPORT2 \numsg_clone(const UMessageFormat *fmt,\n           UErrorCode *status);\n\n/**\n * Sets the locale. This locale is used for fetching default number or date\n * format information.\n * @param fmt The formatter to set\n * @param locale The locale the formatter should use.\n * @stable ICU 2.0\n */\nU_STABLE void  U_EXPORT2 \numsg_setLocale(UMessageFormat *fmt,\n               const char* locale);\n\n/**\n * Gets the locale. This locale is used for fetching default number or date\n * format information.\n * @param fmt The formatter to querry\n * @return the locale.\n * @stable ICU 2.0\n */\nU_STABLE const char*  U_EXPORT2 \numsg_getLocale(const UMessageFormat *fmt);\n\n/**\n * Sets the pattern.\n * @param fmt           The formatter to use\n * @param pattern       The pattern to be applied.\n * @param patternLength Length of the pattern to use\n * @param parseError    Struct to receive information on position \n *                      of error if an error is encountered.Can be NULL.\n * @param status        Output param set to success/failure code on\n *                      exit. If the pattern is invalid, this will be\n *                      set to a failure result.\n * @stable ICU 2.0\n */\nU_STABLE void  U_EXPORT2 \numsg_applyPattern( UMessageFormat *fmt,\n                   const UChar* pattern,\n                   int32_t patternLength,\n                   UParseError* parseError,\n                   UErrorCode* status);\n\n/**\n * Gets the pattern.\n * @param fmt          The formatter to use\n * @param result       A pointer to a buffer to receive the pattern.\n * @param resultLength The maximum size of result.\n * @param status       Output param set to success/failure code on\n *                     exit. If the pattern is invalid, this will be\n *                     set to a failure result.  \n * @return the pattern of the format\n * @stable ICU 2.0\n */\nU_STABLE int32_t  U_EXPORT2 \numsg_toPattern(const UMessageFormat *fmt,\n               UChar* result, \n               int32_t resultLength,\n               UErrorCode* status);\n\n/**\n * Format a message for a locale.\n * This function may perform re-ordering of the arguments depending on the\n * locale. For all numeric arguments, double is assumed unless the type is\n * explicitly integer.  All choice format arguments must be of type double.\n * @param fmt           The formatter to use\n * @param result        A pointer to a buffer to receive the formatted message.\n * @param resultLength  The maximum size of result.\n * @param status        A pointer to an UErrorCode to receive any errors\n * @param ...           A variable-length argument list containing the arguments \n *                      specified in pattern.\n * @return              The total buffer size needed; if greater than resultLength, \n *                      the output was truncated.\n * @stable ICU 2.0\n */\nU_STABLE int32_t U_EXPORT2 \numsg_format(    const UMessageFormat *fmt,\n                UChar          *result,\n                int32_t        resultLength,\n                UErrorCode     *status,\n                ...);\n\n/**\n * Format a message for a locale.\n * This function may perform re-ordering of the arguments depending on the\n * locale. For all numeric arguments, double is assumed unless the type is\n * explicitly integer.  All choice format arguments must be of type double.\n * @param fmt          The formatter to use \n * @param result       A pointer to a buffer to receive the formatted message.\n * @param resultLength The maximum size of result.\n * @param ap           A variable-length argument list containing the arguments \n * @param status       A pointer to an UErrorCode to receive any errors\n *                     specified in pattern.\n * @return             The total buffer size needed; if greater than resultLength, \n *                     the output was truncated.\n * @stable ICU 2.0\n */\nU_STABLE int32_t U_EXPORT2 \numsg_vformat(   const UMessageFormat *fmt,\n                UChar          *result,\n                int32_t        resultLength,\n                va_list        ap,\n                UErrorCode     *status);\n\n/**\n * Parse a message.\n * For numeric arguments, this function will always use doubles.  Integer types\n * should not be passed.\n * This function is not able to parse all output from {@link #umsg_format }.\n * @param fmt           The formatter to use \n * @param source        The text to parse.\n * @param sourceLength  The length of source, or -1 if null-terminated.\n * @param count         Output param to receive number of elements returned.\n * @param status        A pointer to an UErrorCode to receive any errors\n * @param ...           A variable-length argument list containing the arguments\n *                      specified in pattern.\n * @stable ICU 2.0\n */\nU_STABLE void U_EXPORT2 \numsg_parse( const UMessageFormat *fmt,\n            const UChar    *source,\n            int32_t        sourceLength,\n            int32_t        *count,\n            UErrorCode     *status,\n            ...);\n\n/**\n * Parse a message.\n * For numeric arguments, this function will always use doubles.  Integer types\n * should not be passed.\n * This function is not able to parse all output from {@link #umsg_format }.\n * @param fmt           The formatter to use \n * @param source        The text to parse.\n * @param sourceLength  The length of source, or -1 if null-terminated.\n * @param count         Output param to receive number of elements returned.\n * @param ap            A variable-length argument list containing the arguments\n * @param status        A pointer to an UErrorCode to receive any errors\n *                      specified in pattern.\n * @see u_formatMessage\n * @stable ICU 2.0\n */\nU_STABLE void U_EXPORT2 \numsg_vparse(const UMessageFormat *fmt,\n            const UChar    *source,\n            int32_t        sourceLength,\n            int32_t        *count,\n            va_list        ap,\n            UErrorCode     *status);\n\n\n/**\n * Convert an 'apostrophe-friendly' pattern into a standard\n * pattern.  Standard patterns treat all apostrophes as\n * quotes, which is problematic in some languages, e.g. \n * French, where apostrophe is commonly used.  This utility\n * assumes that only an unpaired apostrophe immediately before\n * a brace is a true quote.  Other unpaired apostrophes are paired,\n * and the resulting standard pattern string is returned.\n *\n * <p><b>Note</b> it is not guaranteed that the returned pattern\n * is indeed a valid pattern.  The only effect is to convert\n * between patterns having different quoting semantics.\n *\n * @param pattern the 'apostrophe-friendly' patttern to convert\n * @param patternLength the length of pattern, or -1 if unknown and pattern is null-terminated\n * @param dest the buffer for the result, or NULL if preflight only\n * @param destCapacity the length of the buffer, or 0 if preflighting\n * @param ec the error code\n * @return the length of the resulting text, not including trailing null\n *        if buffer has room for the trailing null, it is provided, otherwise\n *        not\n * @stable ICU 3.4\n */\nU_STABLE int32_t U_EXPORT2 \numsg_autoQuoteApostrophe(const UChar* pattern, \n                         int32_t patternLength,\n                         UChar* dest,\n                         int32_t destCapacity,\n                         UErrorCode* ec);\n\n#endif /* #if !UCONFIG_NO_FORMATTING */\n\n#endif\n"
  },
  {
    "path": "deprecated/android/addons/icucompat/unicode/unifilt.h",
    "content": "/*\n**********************************************************************\n* Copyright (C) 1999-2010, International Business Machines Corporation and others.\n* All Rights Reserved.\n**********************************************************************\n*   Date        Name        Description\n*   11/17/99    aliu        Creation.\n**********************************************************************\n*/\n#ifndef UNIFILT_H\n#define UNIFILT_H\n\n#include \"unicode/unifunct.h\"\n#include \"unicode/unimatch.h\"\n\n/**\n * \\file \n * \\brief C++ API: Unicode Filter\n */\n\nU_NAMESPACE_BEGIN\n\n/**\n * U_ETHER is used to represent character values for positions outside\n * a range.  For example, transliterator uses this to represent\n * characters outside the range contextStart..contextLimit-1.  This\n * allows explicit matching by rules and UnicodeSets of text outside a\n * defined range.\n * @stable ICU 3.0\n */\n#define U_ETHER ((UChar)0xFFFF)\n\n/**\n *\n * <code>UnicodeFilter</code> defines a protocol for selecting a\n * subset of the full range (U+0000 to U+10FFFF) of Unicode characters.\n * Currently, filters are used in conjunction with classes like {@link\n * Transliterator} to only process selected characters through a\n * transformation.\n *\n * <p>Note: UnicodeFilter currently stubs out two pure virtual methods\n * of its base class, UnicodeMatcher.  These methods are toPattern()\n * and matchesIndexValue().  This is done so that filter classes that\n * are not actually used as matchers -- specifically, those in the\n * UnicodeFilterLogic component, and those in tests -- can continue to\n * work without defining these methods.  As long as a filter is not\n * used in an RBT during real transliteration, these methods will not\n * be called.  However, this breaks the UnicodeMatcher base class\n * protocol, and it is not a correct solution.\n *\n * <p>In the future we may revisit the UnicodeMatcher / UnicodeFilter\n * hierarchy and either redesign it, or simply remove the stubs in\n * UnicodeFilter and force subclasses to implement the full\n * UnicodeMatcher protocol.\n *\n * @see UnicodeFilterLogic\n * @stable ICU 2.0\n */\nclass U_COMMON_API UnicodeFilter : public UnicodeFunctor, public UnicodeMatcher {\n\npublic:\n    /**\n     * Destructor\n     * @stable ICU 2.0\n     */\n    virtual ~UnicodeFilter();\n\n    /**\n     * Returns <tt>true</tt> for characters that are in the selected\n     * subset.  In other words, if a character is <b>to be\n     * filtered</b>, then <tt>contains()</tt> returns\n     * <b><tt>false</tt></b>.\n     * @stable ICU 2.0\n     */\n    virtual UBool contains(UChar32 c) const = 0;\n\n    /**\n     * UnicodeFunctor API.  Cast 'this' to a UnicodeMatcher* pointer\n     * and return the pointer.\n     * @stable ICU 2.4\n     */\n    virtual UnicodeMatcher* toMatcher() const;\n\n    /**\n     * Implement UnicodeMatcher API.\n     * @stable ICU 2.4\n     */\n    virtual UMatchDegree matches(const Replaceable& text,\n                                 int32_t& offset,\n                                 int32_t limit,\n                                 UBool incremental);\n\n    /**\n     * UnicodeFunctor API.  Nothing to do.\n     * @stable ICU 2.4\n     */\n    virtual void setData(const TransliterationRuleData*);\n\n    /**\n     * ICU \"poor man's RTTI\", returns a UClassID for this class.\n     *\n     * @stable ICU 2.2\n     */\n    static UClassID U_EXPORT2 getStaticClassID();\n\nprotected:\n\n    /*\n     * Since this class has pure virtual functions,\n     * a constructor can't be used.\n     * @stable ICU 2.0\n     */\n/*    UnicodeFilter();*/\n};\n\n/*inline UnicodeFilter::UnicodeFilter() {}*/\n\nU_NAMESPACE_END\n\n#endif\n"
  },
  {
    "path": "deprecated/android/addons/icucompat/unicode/unifunct.h",
    "content": "/*\n**********************************************************************\n*   Copyright (c) 2002-2005, International Business Machines Corporation\n*   and others.  All Rights Reserved.\n**********************************************************************\n*   Date        Name        Description\n*   01/14/2002  aliu        Creation.\n**********************************************************************\n*/\n#ifndef UNIFUNCT_H\n#define UNIFUNCT_H\n\n#include \"unicode/utypes.h\"\n#include \"unicode/uobject.h\"\n\n/**\n * \\file \n * \\brief C++ API: Unicode Functor\n */\n \nU_NAMESPACE_BEGIN\n\nclass UnicodeMatcher;\nclass UnicodeReplacer;\nclass TransliterationRuleData;\n\n/**\n * <code>UnicodeFunctor</code> is an abstract base class for objects\n * that perform match and/or replace operations on Unicode strings.\n * @author Alan Liu\n * @stable ICU 2.4\n */\nclass U_COMMON_API UnicodeFunctor : public UObject {\n\npublic:\n\n    /**\n     * Destructor\n     * @stable ICU 2.4\n     */\n    virtual ~UnicodeFunctor();\n\n    /**\n     * Return a copy of this object.  All UnicodeFunctor objects\n     * have to support cloning in order to allow classes using\n     * UnicodeFunctor to implement cloning.\n     * @stable ICU 2.4\n     */\n    virtual UnicodeFunctor* clone() const = 0;\n\n    /**\n     * Cast 'this' to a UnicodeMatcher* pointer and return the\n     * pointer, or null if this is not a UnicodeMatcher*.  Subclasses\n     * that mix in UnicodeMatcher as a base class must override this.\n     * This protocol is required because a pointer to a UnicodeFunctor\n     * cannot be cast to a pointer to a UnicodeMatcher, since\n     * UnicodeMatcher is a mixin that does not derive from\n     * UnicodeFunctor.\n     * @stable ICU 2.4\n     */\n    virtual UnicodeMatcher* toMatcher() const;\n\n    /**\n     * Cast 'this' to a UnicodeReplacer* pointer and return the\n     * pointer, or null if this is not a UnicodeReplacer*.  Subclasses\n     * that mix in UnicodeReplacer as a base class must override this.\n     * This protocol is required because a pointer to a UnicodeFunctor\n     * cannot be cast to a pointer to a UnicodeReplacer, since\n     * UnicodeReplacer is a mixin that does not derive from\n     * UnicodeFunctor.\n     * @stable ICU 2.4\n     */\n    virtual UnicodeReplacer* toReplacer() const;\n\n    /**\n     * Return the class ID for this class.  This is useful only for\n     * comparing to a return value from getDynamicClassID().\n     * @return          The class ID for all objects of this class.\n     * @stable ICU 2.0\n     */\n    static UClassID U_EXPORT2 getStaticClassID(void);\n\n    /**\n     * Returns a unique class ID <b>polymorphically</b>.  This method\n     * is to implement a simple version of RTTI, since not all C++\n     * compilers support genuine RTTI.  Polymorphic operator==() and\n     * clone() methods call this method.\n     *\n     * <p>Concrete subclasses of UnicodeFunctor should use the macro\n     *    UOBJECT_DEFINE_RTTI_IMPLEMENTATION from uobject.h to\n     *    provide definitios getStaticClassID and getDynamicClassID.\n     *\n     * @return The class ID for this object. All objects of a given\n     * class have the same class ID.  Objects of other classes have\n     * different class IDs.\n     * @stable ICU 2.4\n     */\n    virtual UClassID getDynamicClassID(void) const = 0;\n\n    /**\n     * Set the data object associated with this functor.  The data\n     * object provides context for functor-to-standin mapping.  This\n     * method is required when assigning a functor to a different data\n     * object.  This function MAY GO AWAY later if the architecture is\n     * changed to pass data object pointers through the API.\n     * @internal ICU 2.1\n     */\n    virtual void setData(const TransliterationRuleData*) = 0;\n\nprotected:\n\n    /**\n     * Since this class has pure virtual functions,\n     * a constructor can't be used.\n     * @stable ICU 2.0\n     */\n    /*UnicodeFunctor();*/\n\n};\n\n/*inline UnicodeFunctor::UnicodeFunctor() {}*/\n\nU_NAMESPACE_END\n\n#endif\n"
  },
  {
    "path": "deprecated/android/addons/icucompat/unicode/unimatch.h",
    "content": "/*\n* Copyright (C) 2001-2005, International Business Machines Corporation and others. All Rights Reserved.\n**********************************************************************\n*   Date        Name        Description\n*   07/18/01    aliu        Creation.\n**********************************************************************\n*/\n#ifndef UNIMATCH_H\n#define UNIMATCH_H\n\n#include \"unicode/utypes.h\"\n\n/**\n * \\file \n * \\brief C++ API: Unicode Matcher\n */\n\n\nU_NAMESPACE_BEGIN\n\nclass Replaceable;\nclass UnicodeString;\nclass UnicodeSet;\n\n/**\n * Constants returned by <code>UnicodeMatcher::matches()</code>\n * indicating the degree of match.\n * @stable ICU 2.4\n */\nenum UMatchDegree {\n    /**\n     * Constant returned by <code>matches()</code> indicating a\n     * mismatch between the text and this matcher.  The text contains\n     * a character which does not match, or the text does not contain\n     * all desired characters for a non-incremental match.\n     * @stable ICU 2.4\n     */\n    U_MISMATCH,\n    \n    /**\n     * Constant returned by <code>matches()</code> indicating a\n     * partial match between the text and this matcher.  This value is\n     * only returned for incremental match operations.  All characters\n     * of the text match, but more characters are required for a\n     * complete match.  Alternatively, for variable-length matchers,\n     * all characters of the text match, and if more characters were\n     * supplied at limit, they might also match.\n     * @stable ICU 2.4\n     */\n    U_PARTIAL_MATCH,\n    \n    /**\n     * Constant returned by <code>matches()</code> indicating a\n     * complete match between the text and this matcher.  For an\n     * incremental variable-length match, this value is returned if\n     * the given text matches, and it is known that additional\n     * characters would not alter the extent of the match.\n     * @stable ICU 2.4\n     */\n    U_MATCH\n};\n\n/**\n * <code>UnicodeMatcher</code> defines a protocol for objects that can\n * match a range of characters in a Replaceable string.\n * @stable ICU 2.4\n */\nclass U_COMMON_API UnicodeMatcher /* not : public UObject because this is an interface/mixin class */ {\n\npublic:\n    /**\n     * Destructor.\n     * @stable ICU 2.4\n     */\n    virtual ~UnicodeMatcher();\n\n    /**\n     * Return a UMatchDegree value indicating the degree of match for\n     * the given text at the given offset.  Zero, one, or more\n     * characters may be matched.\n     *\n     * Matching in the forward direction is indicated by limit >\n     * offset.  Characters from offset forwards to limit-1 will be\n     * considered for matching.\n     * \n     * Matching in the reverse direction is indicated by limit <\n     * offset.  Characters from offset backwards to limit+1 will be\n     * considered for matching.\n     *\n     * If limit == offset then the only match possible is a zero\n     * character match (which subclasses may implement if desired).\n     *\n     * As a side effect, advance the offset parameter to the limit of\n     * the matched substring.  In the forward direction, this will be\n     * the index of the last matched character plus one.  In the\n     * reverse direction, this will be the index of the last matched\n     * character minus one.\n     *\n     * <p>Note:  This method is not const because some classes may\n     * modify their state as the result of a match.\n     *\n     * @param text the text to be matched\n     * @param offset on input, the index into text at which to begin\n     * matching.  On output, the limit of the matched text.  The\n     * number of matched characters is the output value of offset\n     * minus the input value.  Offset should always point to the\n     * HIGH SURROGATE (leading code unit) of a pair of surrogates,\n     * both on entry and upon return.\n     * @param limit the limit index of text to be matched.  Greater\n     * than offset for a forward direction match, less than offset for\n     * a backward direction match.  The last character to be\n     * considered for matching will be text.charAt(limit-1) in the\n     * forward direction or text.charAt(limit+1) in the backward\n     * direction.\n     * @param incremental if TRUE, then assume further characters may\n     * be inserted at limit and check for partial matching.  Otherwise\n     * assume the text as given is complete.\n     * @return a match degree value indicating a full match, a partial\n     * match, or a mismatch.  If incremental is FALSE then\n     * U_PARTIAL_MATCH should never be returned.\n     * @stable ICU 2.4\n     */\n    virtual UMatchDegree matches(const Replaceable& text,\n                                 int32_t& offset,\n                                 int32_t limit,\n                                 UBool incremental) = 0;\n\n    /**\n     * Returns a string representation of this matcher.  If the result of\n     * calling this function is passed to the appropriate parser, it\n     * will produce another matcher that is equal to this one.\n     * @param result the string to receive the pattern.  Previous\n     * contents will be deleted.\n     * @param escapeUnprintable if TRUE then convert unprintable\n     * character to their hex escape representations, \\\\uxxxx or\n     * \\\\Uxxxxxxxx.  Unprintable characters are those other than\n     * U+000A, U+0020..U+007E.\n     * @stable ICU 2.4\n     */\n    virtual UnicodeString& toPattern(UnicodeString& result,\n                                     UBool escapeUnprintable = FALSE) const = 0;\n\n    /**\n     * Returns TRUE if this matcher will match a character c, where c\n     * & 0xFF == v, at offset, in the forward direction (with limit >\n     * offset).  This is used by <tt>RuleBasedTransliterator</tt> for\n     * indexing.\n     * @stable ICU 2.4\n     */\n    virtual UBool matchesIndexValue(uint8_t v) const = 0;\n\n    /**\n     * Union the set of all characters that may be matched by this object\n     * into the given set.\n     * @param toUnionTo the set into which to union the source characters\n     * @stable ICU 2.4\n     */\n    virtual void addMatchSetTo(UnicodeSet& toUnionTo) const = 0;\n};\n\nU_NAMESPACE_END\n\n#endif\n"
  },
  {
    "path": "deprecated/android/addons/icucompat/unicode/unirepl.h",
    "content": "/*\n**********************************************************************\n*   Copyright (c) 2002-2005, International Business Machines Corporation\n*   and others.  All Rights Reserved.\n**********************************************************************\n*   Date        Name        Description\n*   01/14/2002  aliu        Creation.\n**********************************************************************\n*/\n#ifndef UNIREPL_H\n#define UNIREPL_H\n\n#include \"unicode/utypes.h\"\n\n/**\n * \\file \n * \\brief C++ API: UnicodeReplacer\n */\n\nU_NAMESPACE_BEGIN\n\nclass Replaceable;\nclass UnicodeString;\nclass UnicodeSet;\n\n/**\n * <code>UnicodeReplacer</code> defines a protocol for objects that\n * replace a range of characters in a Replaceable string with output\n * text.  The replacement is done via the Replaceable API so as to\n * preserve out-of-band data.\n *\n * <p>This is a mixin class.\n * @author Alan Liu\n * @stable ICU 2.4\n */\nclass U_I18N_API UnicodeReplacer /* not : public UObject because this is an interface/mixin class */ {\n\n public:\n\n    /**\n     * Destructor.\n     * @stable ICU 2.4\n     */\n    virtual ~UnicodeReplacer();\n\n    /**\n     * Replace characters in 'text' from 'start' to 'limit' with the\n     * output text of this object.  Update the 'cursor' parameter to\n     * give the cursor position and return the length of the\n     * replacement text.\n     *\n     * @param text the text to be matched\n     * @param start inclusive start index of text to be replaced\n     * @param limit exclusive end index of text to be replaced;\n     * must be greater than or equal to start\n     * @param cursor output parameter for the cursor position.\n     * Not all replacer objects will update this, but in a complete\n     * tree of replacer objects, representing the entire output side\n     * of a transliteration rule, at least one must update it.\n     * @return the number of 16-bit code units in the text replacing\n     * the characters at offsets start..(limit-1) in text\n     * @stable ICU 2.4\n     */\n    virtual int32_t replace(Replaceable& text,\n                            int32_t start,\n                            int32_t limit,\n                            int32_t& cursor) = 0;\n\n    /**\n     * Returns a string representation of this replacer.  If the\n     * result of calling this function is passed to the appropriate\n     * parser, typically TransliteratorParser, it will produce another\n     * replacer that is equal to this one.\n     * @param result the string to receive the pattern.  Previous\n     * contents will be deleted.\n     * @param escapeUnprintable if TRUE then convert unprintable\n     * character to their hex escape representations, \\\\uxxxx or\n     * \\\\Uxxxxxxxx.  Unprintable characters are defined by\n     * Utility.isUnprintable().\n     * @return a reference to 'result'.\n     * @stable ICU 2.4\n     */\n    virtual UnicodeString& toReplacerPattern(UnicodeString& result,\n                                             UBool escapeUnprintable) const = 0;\n\n    /**\n     * Union the set of all characters that may output by this object\n     * into the given set.\n     * @param toUnionTo the set into which to union the output characters\n     * @stable ICU 2.4\n     */\n    virtual void addReplacementSetTo(UnicodeSet& toUnionTo) const = 0;\n};\n\nU_NAMESPACE_END\n\n#endif\n"
  },
  {
    "path": "deprecated/android/addons/icucompat/unicode/uniset.h",
    "content": "/*\n***************************************************************************\n* Copyright (C) 1999-2011, International Business Machines Corporation\n* and others. All Rights Reserved.\n***************************************************************************\n*   Date        Name        Description\n*   10/20/99    alan        Creation.\n***************************************************************************\n*/\n\n#ifndef UNICODESET_H\n#define UNICODESET_H\n\n#include \"unicode/unifilt.h\"\n#include \"unicode/unistr.h\"\n#include \"unicode/uset.h\"\n\n/**\n * \\file\n * \\brief C++ API: Unicode Set\n */\n\nU_NAMESPACE_BEGIN\n\nclass BMPSet;\nclass ParsePosition;\nclass RBBIRuleScanner;\nclass SymbolTable;\nclass UnicodeSetStringSpan;\nclass UVector;\nclass RuleCharacterIterator;\n\n/**\n * A mutable set of Unicode characters and multicharacter strings.  Objects of this class\n * represent <em>character classes</em> used in regular expressions.\n * A character specifies a subset of Unicode code points.  Legal\n * code points are U+0000 to U+10FFFF, inclusive.\n *\n * <p>The UnicodeSet class is not designed to be subclassed.\n *\n * <p><code>UnicodeSet</code> supports two APIs. The first is the\n * <em>operand</em> API that allows the caller to modify the value of\n * a <code>UnicodeSet</code> object. It conforms to Java 2's\n * <code>java.util.Set</code> interface, although\n * <code>UnicodeSet</code> does not actually implement that\n * interface. All methods of <code>Set</code> are supported, with the\n * modification that they take a character range or single character\n * instead of an <code>Object</code>, and they take a\n * <code>UnicodeSet</code> instead of a <code>Collection</code>.  The\n * operand API may be thought of in terms of boolean logic: a boolean\n * OR is implemented by <code>add</code>, a boolean AND is implemented\n * by <code>retain</code>, a boolean XOR is implemented by\n * <code>complement</code> taking an argument, and a boolean NOT is\n * implemented by <code>complement</code> with no argument.  In terms\n * of traditional set theory function names, <code>add</code> is a\n * union, <code>retain</code> is an intersection, <code>remove</code>\n * is an asymmetric difference, and <code>complement</code> with no\n * argument is a set complement with respect to the superset range\n * <code>MIN_VALUE-MAX_VALUE</code>\n *\n * <p>The second API is the\n * <code>applyPattern()</code>/<code>toPattern()</code> API from the\n * <code>java.text.Format</code>-derived classes.  Unlike the\n * methods that add characters, add categories, and control the logic\n * of the set, the method <code>applyPattern()</code> sets all\n * attributes of a <code>UnicodeSet</code> at once, based on a\n * string pattern.\n *\n * <p><b>Pattern syntax</b></p>\n *\n * Patterns are accepted by the constructors and the\n * <code>applyPattern()</code> methods and returned by the\n * <code>toPattern()</code> method.  These patterns follow a syntax\n * similar to that employed by version 8 regular expression character\n * classes.  Here are some simple examples:\n *\n * \\htmlonly<blockquote>\\endhtmlonly\n *   <table>\n *     <tr align=\"top\">\n *       <td nowrap valign=\"top\" align=\"left\"><code>[]</code></td>\n *       <td valign=\"top\">No characters</td>\n *     </tr><tr align=\"top\">\n *       <td nowrap valign=\"top\" align=\"left\"><code>[a]</code></td>\n *       <td valign=\"top\">The character 'a'</td>\n *     </tr><tr align=\"top\">\n *       <td nowrap valign=\"top\" align=\"left\"><code>[ae]</code></td>\n *       <td valign=\"top\">The characters 'a' and 'e'</td>\n *     </tr>\n *     <tr>\n *       <td nowrap valign=\"top\" align=\"left\"><code>[a-e]</code></td>\n *       <td valign=\"top\">The characters 'a' through 'e' inclusive, in Unicode code\n *       point order</td>\n *     </tr>\n *     <tr>\n *       <td nowrap valign=\"top\" align=\"left\"><code>[\\\\u4E01]</code></td>\n *       <td valign=\"top\">The character U+4E01</td>\n *     </tr>\n *     <tr>\n *       <td nowrap valign=\"top\" align=\"left\"><code>[a{ab}{ac}]</code></td>\n *       <td valign=\"top\">The character 'a' and the multicharacter strings &quot;ab&quot; and\n *       &quot;ac&quot;</td>\n *     </tr>\n *     <tr>\n *       <td nowrap valign=\"top\" align=\"left\"><code>[\\\\p{Lu}]</code></td>\n *       <td valign=\"top\">All characters in the general category Uppercase Letter</td>\n *     </tr>\n *   </table>\n * \\htmlonly</blockquote>\\endhtmlonly\n *\n * Any character may be preceded by a backslash in order to remove any special\n * meaning.  White space characters, as defined by UCharacter.isWhitespace(), are\n * ignored, unless they are escaped.\n *\n * <p>Property patterns specify a set of characters having a certain\n * property as defined by the Unicode standard.  Both the POSIX-like\n * \"[:Lu:]\" and the Perl-like syntax \"\\\\p{Lu}\" are recognized.  For a\n * complete list of supported property patterns, see the User's Guide\n * for UnicodeSet at\n * <a href=\"http://icu-project.org/userguide/unicodeSet.html\">\n * http://icu-project.org/userguide/unicodeSet.html</a>.\n * Actual determination of property data is defined by the underlying\n * Unicode database as implemented by UCharacter.\n *\n * <p>Patterns specify individual characters, ranges of characters, and\n * Unicode property sets.  When elements are concatenated, they\n * specify their union.  To complement a set, place a '^' immediately\n * after the opening '['.  Property patterns are inverted by modifying\n * their delimiters; \"[:^foo]\" and \"\\\\P{foo}\".  In any other location,\n * '^' has no special meaning.\n *\n * <p>Ranges are indicated by placing two a '-' between two\n * characters, as in \"a-z\".  This specifies the range of all\n * characters from the left to the right, in Unicode order.  If the\n * left character is greater than or equal to the\n * right character it is a syntax error.  If a '-' occurs as the first\n * character after the opening '[' or '[^', or if it occurs as the\n * last character before the closing ']', then it is taken as a\n * literal.  Thus \"[a\\-b]\", \"[-ab]\", and \"[ab-]\" all indicate the same\n * set of three characters, 'a', 'b', and '-'.\n *\n * <p>Sets may be intersected using the '&' operator or the asymmetric\n * set difference may be taken using the '-' operator, for example,\n * \"[[:L:]&[\\\\u0000-\\\\u0FFF]]\" indicates the set of all Unicode letters\n * with values less than 4096.  Operators ('&' and '|') have equal\n * precedence and bind left-to-right.  Thus\n * \"[[:L:]-[a-z]-[\\\\u0100-\\\\u01FF]]\" is equivalent to\n * \"[[[:L:]-[a-z]]-[\\\\u0100-\\\\u01FF]]\".  This only really matters for\n * difference; intersection is commutative.\n *\n * <table>\n * <tr valign=top><td nowrap><code>[a]</code><td>The set containing 'a'\n * <tr valign=top><td nowrap><code>[a-z]</code><td>The set containing 'a'\n * through 'z' and all letters in between, in Unicode order\n * <tr valign=top><td nowrap><code>[^a-z]</code><td>The set containing\n * all characters but 'a' through 'z',\n * that is, U+0000 through 'a'-1 and 'z'+1 through U+10FFFF\n * <tr valign=top><td nowrap><code>[[<em>pat1</em>][<em>pat2</em>]]</code>\n * <td>The union of sets specified by <em>pat1</em> and <em>pat2</em>\n * <tr valign=top><td nowrap><code>[[<em>pat1</em>]&[<em>pat2</em>]]</code>\n * <td>The intersection of sets specified by <em>pat1</em> and <em>pat2</em>\n * <tr valign=top><td nowrap><code>[[<em>pat1</em>]-[<em>pat2</em>]]</code>\n * <td>The asymmetric difference of sets specified by <em>pat1</em> and\n * <em>pat2</em>\n * <tr valign=top><td nowrap><code>[:Lu:] or \\\\p{Lu}</code>\n * <td>The set of characters having the specified\n * Unicode property; in\n * this case, Unicode uppercase letters\n * <tr valign=top><td nowrap><code>[:^Lu:] or \\\\P{Lu}</code>\n * <td>The set of characters <em>not</em> having the given\n * Unicode property\n * </table>\n *\n * <p><b>Warning</b>: you cannot add an empty string (\"\") to a UnicodeSet.</p>\n *\n * <p><b>Formal syntax</b></p>\n *\n * \\htmlonly<blockquote>\\endhtmlonly\n *   <table>\n *     <tr align=\"top\">\n *       <td nowrap valign=\"top\" align=\"right\"><code>pattern :=&nbsp; </code></td>\n *       <td valign=\"top\"><code>('[' '^'? item* ']') |\n *       property</code></td>\n *     </tr>\n *     <tr align=\"top\">\n *       <td nowrap valign=\"top\" align=\"right\"><code>item :=&nbsp; </code></td>\n *       <td valign=\"top\"><code>char | (char '-' char) | pattern-expr<br>\n *       </code></td>\n *     </tr>\n *     <tr align=\"top\">\n *       <td nowrap valign=\"top\" align=\"right\"><code>pattern-expr :=&nbsp; </code></td>\n *       <td valign=\"top\"><code>pattern | pattern-expr pattern |\n *       pattern-expr op pattern<br>\n *       </code></td>\n *     </tr>\n *     <tr align=\"top\">\n *       <td nowrap valign=\"top\" align=\"right\"><code>op :=&nbsp; </code></td>\n *       <td valign=\"top\"><code>'&amp;' | '-'<br>\n *       </code></td>\n *     </tr>\n *     <tr align=\"top\">\n *       <td nowrap valign=\"top\" align=\"right\"><code>special :=&nbsp; </code></td>\n *       <td valign=\"top\"><code>'[' | ']' | '-'<br>\n *       </code></td>\n *     </tr>\n *     <tr align=\"top\">\n *       <td nowrap valign=\"top\" align=\"right\"><code>char :=&nbsp; </code></td>\n *       <td valign=\"top\"><em>any character that is not</em><code> special<br>\n *       | ('\\' </code><em>any character</em><code>)<br>\n *       | ('\\\\u' hex hex hex hex)<br>\n *       </code></td>\n *     </tr>\n *     <tr align=\"top\">\n *       <td nowrap valign=\"top\" align=\"right\"><code>hex :=&nbsp; </code></td>\n *       <td valign=\"top\"><em>any character for which\n *       </em><code>Character.digit(c, 16)</code><em>\n *       returns a non-negative result</em></td>\n *     </tr>\n *     <tr>\n *       <td nowrap valign=\"top\" align=\"right\"><code>property :=&nbsp; </code></td>\n *       <td valign=\"top\"><em>a Unicode property set pattern</em></td>\n *     </tr>\n *   </table>\n *   <br>\n *   <table border=\"1\">\n *     <tr>\n *       <td>Legend: <table>\n *         <tr>\n *           <td nowrap valign=\"top\"><code>a := b</code></td>\n *           <td width=\"20\" valign=\"top\">&nbsp; </td>\n *           <td valign=\"top\"><code>a</code> may be replaced by <code>b</code> </td>\n *         </tr>\n *         <tr>\n *           <td nowrap valign=\"top\"><code>a?</code></td>\n *           <td valign=\"top\"></td>\n *           <td valign=\"top\">zero or one instance of <code>a</code><br>\n *           </td>\n *         </tr>\n *         <tr>\n *           <td nowrap valign=\"top\"><code>a*</code></td>\n *           <td valign=\"top\"></td>\n *           <td valign=\"top\">one or more instances of <code>a</code><br>\n *           </td>\n *         </tr>\n *         <tr>\n *           <td nowrap valign=\"top\"><code>a | b</code></td>\n *           <td valign=\"top\"></td>\n *           <td valign=\"top\">either <code>a</code> or <code>b</code><br>\n *           </td>\n *         </tr>\n *         <tr>\n *           <td nowrap valign=\"top\"><code>'a'</code></td>\n *           <td valign=\"top\"></td>\n *           <td valign=\"top\">the literal string between the quotes </td>\n *         </tr>\n *       </table>\n *       </td>\n *     </tr>\n *   </table>\n * \\htmlonly</blockquote>\\endhtmlonly\n * \n * <p>Note:\n *  - Most UnicodeSet methods do not take a UErrorCode parameter because\n *   there are usually very few opportunities for failure other than a shortage\n *   of memory, error codes in low-level C++ string methods would be inconvenient,\n *   and the error code as the last parameter (ICU convention) would prevent\n *   the use of default parameter values.\n *   Instead, such methods set the UnicodeSet into a \"bogus\" state\n *   (see isBogus()) if an error occurs.\n *\n * @author Alan Liu\n * @stable ICU 2.0\n */\nclass U_COMMON_API UnicodeSet : public UnicodeFilter {\n\n    int32_t len; // length of list used; 0 <= len <= capacity\n    int32_t capacity; // capacity of list\n    UChar32* list; // MUST be terminated with HIGH\n    BMPSet *bmpSet; // The set is frozen iff either bmpSet or stringSpan is not NULL.\n    UChar32* buffer; // internal buffer, may be NULL\n    int32_t bufferCapacity; // capacity of buffer\n    int32_t patLen;\n\n    /**\n     * The pattern representation of this set.  This may not be the\n     * most economical pattern.  It is the pattern supplied to\n     * applyPattern(), with variables substituted and whitespace\n     * removed.  For sets constructed without applyPattern(), or\n     * modified using the non-pattern API, this string will be empty,\n     * indicating that toPattern() must generate a pattern\n     * representation from the inversion list.\n     */\n    UChar *pat;\n    UVector* strings; // maintained in sorted order\n    UnicodeSetStringSpan *stringSpan;\n\nprivate:\n    enum { // constants\n        kIsBogus = 1       // This set is bogus (i.e. not valid)\n    };\n    uint8_t fFlags;         // Bit flag (see constants above)\npublic:\n    /**\n     * Determine if this object contains a valid set.\n     * A bogus set has no value. It is different from an empty set.\n     * It can be used to indicate that no set value is available.\n     *\n     * @return TRUE if the set is valid, FALSE otherwise\n     * @see setToBogus()\n     * @stable ICU 4.0\n     */\n    inline UBool isBogus(void) const;\n    \n    /**\n     * Make this UnicodeSet object invalid.\n     * The string will test TRUE with isBogus().\n     *\n     * A bogus set has no value. It is different from an empty set.\n     * It can be used to indicate that no set value is available.\n     *\n     * This utility function is used throughout the UnicodeSet\n     * implementation to indicate that a UnicodeSet operation failed,\n     * and may be used in other functions,\n     * especially but not exclusively when such functions do not\n     * take a UErrorCode for simplicity.\n     *\n     * @see isBogus()\n     * @stable ICU 4.0\n     */\n    void setToBogus();\n\npublic:\n\n    enum {\n        /**\n         * Minimum value that can be stored in a UnicodeSet.\n         * @stable ICU 2.4\n         */\n        MIN_VALUE = 0,\n\n        /**\n         * Maximum value that can be stored in a UnicodeSet.\n         * @stable ICU 2.4\n         */\n        MAX_VALUE = 0x10ffff\n    };\n\n    //----------------------------------------------------------------\n    // Constructors &c\n    //----------------------------------------------------------------\n\npublic:\n\n    /**\n     * Constructs an empty set.\n     * @stable ICU 2.0\n     */\n    UnicodeSet();\n\n    /**\n     * Constructs a set containing the given range. If <code>end >\n     * start</code> then an empty set is created.\n     *\n     * @param start first character, inclusive, of range\n     * @param end last character, inclusive, of range\n     * @stable ICU 2.4\n     */\n    UnicodeSet(UChar32 start, UChar32 end);\n\n    /**\n     * Constructs a set from the given pattern.  See the class\n     * description for the syntax of the pattern language.\n     * @param pattern a string specifying what characters are in the set\n     * @param status returns <code>U_ILLEGAL_ARGUMENT_ERROR</code> if the pattern\n     * contains a syntax error.\n     * @stable ICU 2.0\n     */\n    UnicodeSet(const UnicodeString& pattern,\n               UErrorCode& status);\n\n#ifndef U_HIDE_INTERNAL_API\n    /**\n     * Constructs a set from the given pattern.  See the class\n     * description for the syntax of the pattern language.\n     * @param pattern a string specifying what characters are in the set\n     * @param options bitmask for options to apply to the pattern.\n     * Valid options are USET_IGNORE_SPACE and USET_CASE_INSENSITIVE.\n     * @param symbols a symbol table mapping variable names to values\n     * and stand-in characters to UnicodeSets; may be NULL\n     * @param status returns <code>U_ILLEGAL_ARGUMENT_ERROR</code> if the pattern\n     * contains a syntax error.\n     * @internal\n     */\n    UnicodeSet(const UnicodeString& pattern,\n               uint32_t options,\n               const SymbolTable* symbols,\n               UErrorCode& status);\n#endif  /* U_HIDE_INTERNAL_API */\n\n    /**\n     * Constructs a set from the given pattern.  See the class description\n     * for the syntax of the pattern language.\n     * @param pattern a string specifying what characters are in the set\n     * @param pos on input, the position in pattern at which to start parsing.\n     * On output, the position after the last character parsed.\n     * @param options bitmask for options to apply to the pattern.\n     * Valid options are USET_IGNORE_SPACE and USET_CASE_INSENSITIVE.\n     * @param symbols a symbol table mapping variable names to values\n     * and stand-in characters to UnicodeSets; may be NULL\n     * @param status input-output error code\n     * @stable ICU 2.8\n     */\n    UnicodeSet(const UnicodeString& pattern, ParsePosition& pos,\n               uint32_t options,\n               const SymbolTable* symbols,\n               UErrorCode& status);\n\n    /**\n     * Constructs a set that is identical to the given UnicodeSet.\n     * @stable ICU 2.0\n     */\n    UnicodeSet(const UnicodeSet& o);\n\n    /**\n     * Destructs the set.\n     * @stable ICU 2.0\n     */\n    virtual ~UnicodeSet();\n\n    /**\n     * Assigns this object to be a copy of another.\n     * A frozen set will not be modified.\n     * @stable ICU 2.0\n     */\n    UnicodeSet& operator=(const UnicodeSet& o);\n\n    /**\n     * Compares the specified object with this set for equality.  Returns\n     * <tt>true</tt> if the two sets\n     * have the same size, and every member of the specified set is\n     * contained in this set (or equivalently, every member of this set is\n     * contained in the specified set).\n     *\n     * @param o set to be compared for equality with this set.\n     * @return <tt>true</tt> if the specified set is equal to this set.\n     * @stable ICU 2.0\n     */\n    virtual UBool operator==(const UnicodeSet& o) const;\n\n    /**\n     * Compares the specified object with this set for equality.  Returns\n     * <tt>true</tt> if the specified set is not equal to this set.\n     * @stable ICU 2.0\n     */\n    UBool operator!=(const UnicodeSet& o) const;\n\n    /**\n     * Returns a copy of this object.  All UnicodeFunctor objects have\n     * to support cloning in order to allow classes using\n     * UnicodeFunctors, such as Transliterator, to implement cloning.\n     * If this set is frozen, then the clone will be frozen as well.\n     * Use cloneAsThawed() for a mutable clone of a frozen set.\n     * @see cloneAsThawed\n     * @stable ICU 2.0\n     */\n    virtual UnicodeFunctor* clone() const;\n\n    /**\n     * Returns the hash code value for this set.\n     *\n     * @return the hash code value for this set.\n     * @see Object#hashCode()\n     * @stable ICU 2.0\n     */\n    virtual int32_t hashCode(void) const;\n\n    /**\n     * Get a UnicodeSet pointer from a USet\n     *\n     * @param uset a USet (the ICU plain C type for UnicodeSet)\n     * @return the corresponding UnicodeSet pointer.\n     *\n     * @stable ICU 4.2\n     */\n    inline static UnicodeSet *fromUSet(USet *uset);\n\n    /**\n     * Get a UnicodeSet pointer from a const USet\n     *\n     * @param uset a const USet (the ICU plain C type for UnicodeSet)\n     * @return the corresponding UnicodeSet pointer.\n     *\n     * @stable ICU 4.2\n     */\n    inline static const UnicodeSet *fromUSet(const USet *uset);\n    \n    /**\n     * Produce a USet * pointer for this UnicodeSet.\n     * USet is the plain C type for UnicodeSet\n     *\n     * @return a USet pointer for this UnicodeSet\n     * @stable ICU 4.2\n     */\n    inline USet *toUSet();\n\n\n    /**\n     * Produce a const USet * pointer for this UnicodeSet.\n     * USet is the plain C type for UnicodeSet\n     *\n     * @return a const USet pointer for this UnicodeSet\n     * @stable ICU 4.2\n     */\n    inline const USet * toUSet() const;\n\n\n    //----------------------------------------------------------------\n    // Freezable API\n    //----------------------------------------------------------------\n\n    /**\n     * Determines whether the set has been frozen (made immutable) or not.\n     * See the ICU4J Freezable interface for details.\n     * @return TRUE/FALSE for whether the set has been frozen\n     * @see freeze\n     * @see cloneAsThawed\n     * @stable ICU 3.8\n     */\n    inline UBool isFrozen() const;\n\n    /**\n     * Freeze the set (make it immutable).\n     * Once frozen, it cannot be unfrozen and is therefore thread-safe\n     * until it is deleted.\n     * See the ICU4J Freezable interface for details.\n     * Freezing the set may also make some operations faster, for example\n     * contains() and span().\n     * A frozen set will not be modified. (It remains frozen.)\n     * @return this set.\n     * @see isFrozen\n     * @see cloneAsThawed\n     * @stable ICU 3.8\n     */\n    UnicodeFunctor *freeze();\n\n    /**\n     * Clone the set and make the clone mutable.\n     * See the ICU4J Freezable interface for details.\n     * @return the mutable clone\n     * @see freeze\n     * @see isFrozen\n     * @stable ICU 3.8\n     */\n    UnicodeFunctor *cloneAsThawed() const;\n\n    //----------------------------------------------------------------\n    // Public API\n    //----------------------------------------------------------------\n\n    /**\n     * Make this object represent the range <code>start - end</code>.\n     * If <code>end > start</code> then this object is set to an\n     * an empty range.\n     * A frozen set will not be modified.\n     *\n     * @param start first character in the set, inclusive\n     * @param end last character in the set, inclusive\n     * @stable ICU 2.4\n     */\n    UnicodeSet& set(UChar32 start, UChar32 end);\n\n    /**\n     * Return true if the given position, in the given pattern, appears\n     * to be the start of a UnicodeSet pattern.\n     * @stable ICU 2.4\n     */\n    static UBool resemblesPattern(const UnicodeString& pattern,\n                                  int32_t pos);\n\n    /**\n     * Modifies this set to represent the set specified by the given\n     * pattern, ignoring Unicode Pattern_White_Space characters.\n     * See the class description for the syntax of the pattern language.\n     * A frozen set will not be modified.\n     * @param pattern a string specifying what characters are in the set\n     * @param status returns <code>U_ILLEGAL_ARGUMENT_ERROR</code> if the pattern\n     * contains a syntax error.\n     * <em> Empties the set passed before applying the pattern.</em>\n     * @return a reference to this\n     * @stable ICU 2.0\n     */\n    UnicodeSet& applyPattern(const UnicodeString& pattern,\n                             UErrorCode& status);\n\n#ifndef U_HIDE_INTERNAL_API\n    /**\n     * Modifies this set to represent the set specified by the given\n     * pattern, optionally ignoring Unicode Pattern_White_Space characters.\n     * See the class description for the syntax of the pattern language.\n     * A frozen set will not be modified.\n     * @param pattern a string specifying what characters are in the set\n     * @param options bitmask for options to apply to the pattern.\n     * Valid options are USET_IGNORE_SPACE and USET_CASE_INSENSITIVE.\n     * @param symbols a symbol table mapping variable names to\n     * values and stand-ins to UnicodeSets; may be NULL\n     * @param status returns <code>U_ILLEGAL_ARGUMENT_ERROR</code> if the pattern\n     * contains a syntax error.\n     *<em> Empties the set passed before applying the pattern.</em>\n     * @return a reference to this\n     * @internal\n     */\n    UnicodeSet& applyPattern(const UnicodeString& pattern,\n                             uint32_t options,\n                             const SymbolTable* symbols,\n                             UErrorCode& status);\n#endif  /* U_HIDE_INTERNAL_API */\n\n    /**\n     * Parses the given pattern, starting at the given position.  The\n     * character at pattern.charAt(pos.getIndex()) must be '[', or the\n     * parse fails.  Parsing continues until the corresponding closing\n     * ']'.  If a syntax error is encountered between the opening and\n     * closing brace, the parse fails.  Upon return from a successful\n     * parse, the ParsePosition is updated to point to the character\n     * following the closing ']', and a StringBuffer containing a\n     * pairs list for the parsed pattern is returned.  This method calls\n     * itself recursively to parse embedded subpatterns.\n     *<em> Empties the set passed before applying the pattern.</em>\n     * A frozen set will not be modified.\n     *\n     * @param pattern the string containing the pattern to be parsed.\n     * The portion of the string from pos.getIndex(), which must be a\n     * '[', to the corresponding closing ']', is parsed.\n     * @param pos upon entry, the position at which to being parsing.\n     * The character at pattern.charAt(pos.getIndex()) must be a '['.\n     * Upon return from a successful parse, pos.getIndex() is either\n     * the character after the closing ']' of the parsed pattern, or\n     * pattern.length() if the closing ']' is the last character of\n     * the pattern string.\n     * @param options bitmask for options to apply to the pattern.\n     * Valid options are USET_IGNORE_SPACE and USET_CASE_INSENSITIVE.\n     * @param symbols a symbol table mapping variable names to\n     * values and stand-ins to UnicodeSets; may be NULL\n     * @param status returns <code>U_ILLEGAL_ARGUMENT_ERROR</code> if the pattern\n     * contains a syntax error.\n     * @return a reference to this\n     * @stable ICU 2.8\n     */\n    UnicodeSet& applyPattern(const UnicodeString& pattern,\n                             ParsePosition& pos,\n                             uint32_t options,\n                             const SymbolTable* symbols,\n                             UErrorCode& status);\n\n    /**\n     * Returns a string representation of this set.  If the result of\n     * calling this function is passed to a UnicodeSet constructor, it\n     * will produce another set that is equal to this one.\n     * A frozen set will not be modified.\n     * @param result the string to receive the rules.  Previous\n     * contents will be deleted.\n     * @param escapeUnprintable if TRUE then convert unprintable\n     * character to their hex escape representations, \\\\uxxxx or\n     * \\\\Uxxxxxxxx.  Unprintable characters are those other than\n     * U+000A, U+0020..U+007E.\n     * @stable ICU 2.0\n     */\n    virtual UnicodeString& toPattern(UnicodeString& result,\n                             UBool escapeUnprintable = FALSE) const;\n\n    /**\n     * Modifies this set to contain those code points which have the given value\n     * for the given binary or enumerated property, as returned by\n     * u_getIntPropertyValue.  Prior contents of this set are lost.\n     * A frozen set will not be modified.\n     *\n     * @param prop a property in the range UCHAR_BIN_START..UCHAR_BIN_LIMIT-1\n     * or UCHAR_INT_START..UCHAR_INT_LIMIT-1\n     * or UCHAR_MASK_START..UCHAR_MASK_LIMIT-1.\n     *\n     * @param value a value in the range u_getIntPropertyMinValue(prop)..\n     * u_getIntPropertyMaxValue(prop), with one exception.  If prop is\n     * UCHAR_GENERAL_CATEGORY_MASK, then value should not be a UCharCategory, but\n     * rather a mask value produced by U_GET_GC_MASK().  This allows grouped\n     * categories such as [:L:] to be represented.\n     *\n     * @param ec error code input/output parameter\n     *\n     * @return a reference to this set\n     *\n     * @stable ICU 2.4\n     */\n    UnicodeSet& applyIntPropertyValue(UProperty prop,\n                                      int32_t value,\n                                      UErrorCode& ec);\n\n    /**\n     * Modifies this set to contain those code points which have the\n     * given value for the given property.  Prior contents of this\n     * set are lost.\n     * A frozen set will not be modified.\n     *\n     * @param prop a property alias, either short or long.  The name is matched\n     * loosely.  See PropertyAliases.txt for names and a description of loose\n     * matching.  If the value string is empty, then this string is interpreted\n     * as either a General_Category value alias, a Script value alias, a binary\n     * property alias, or a special ID.  Special IDs are matched loosely and\n     * correspond to the following sets:\n     *\n     * \"ANY\" = [\\\\u0000-\\\\U0010FFFF],\n     * \"ASCII\" = [\\\\u0000-\\\\u007F],\n     * \"Assigned\" = [:^Cn:].\n     *\n     * @param value a value alias, either short or long.  The name is matched\n     * loosely.  See PropertyValueAliases.txt for names and a description of\n     * loose matching.  In addition to aliases listed, numeric values and\n     * canonical combining classes may be expressed numerically, e.g., (\"nv\",\n     * \"0.5\") or (\"ccc\", \"220\").  The value string may also be empty.\n     *\n     * @param ec error code input/output parameter\n     *\n     * @return a reference to this set\n     *\n     * @stable ICU 2.4\n     */\n    UnicodeSet& applyPropertyAlias(const UnicodeString& prop,\n                                   const UnicodeString& value,\n                                   UErrorCode& ec);\n\n    /**\n     * Returns the number of elements in this set (its cardinality).\n     * Note than the elements of a set may include both individual\n     * codepoints and strings.\n     *\n     * @return the number of elements in this set (its cardinality).\n     * @stable ICU 2.0\n     */\n    virtual int32_t size(void) const;\n\n    /**\n     * Returns <tt>true</tt> if this set contains no elements.\n     *\n     * @return <tt>true</tt> if this set contains no elements.\n     * @stable ICU 2.0\n     */\n    virtual UBool isEmpty(void) const;\n\n    /**\n     * Returns true if this set contains the given character.\n     * This function works faster with a frozen set.\n     * @param c character to be checked for containment\n     * @return true if the test condition is met\n     * @stable ICU 2.0\n     */\n    virtual UBool contains(UChar32 c) const;\n\n    /**\n     * Returns true if this set contains every character\n     * of the given range.\n     * @param start first character, inclusive, of the range\n     * @param end last character, inclusive, of the range\n     * @return true if the test condition is met\n     * @stable ICU 2.0\n     */\n    virtual UBool contains(UChar32 start, UChar32 end) const;\n\n    /**\n     * Returns <tt>true</tt> if this set contains the given\n     * multicharacter string.\n     * @param s string to be checked for containment\n     * @return <tt>true</tt> if this set contains the specified string\n     * @stable ICU 2.4\n     */\n    UBool contains(const UnicodeString& s) const;\n\n    /**\n     * Returns true if this set contains all the characters and strings\n     * of the given set.\n     * @param c set to be checked for containment\n     * @return true if the test condition is met\n     * @stable ICU 2.4\n     */\n    virtual UBool containsAll(const UnicodeSet& c) const;\n\n    /**\n     * Returns true if this set contains all the characters\n     * of the given string.\n     * @param s string containing characters to be checked for containment\n     * @return true if the test condition is met\n     * @stable ICU 2.4\n     */\n    UBool containsAll(const UnicodeString& s) const;\n\n    /**\n     * Returns true if this set contains none of the characters\n     * of the given range.\n     * @param start first character, inclusive, of the range\n     * @param end last character, inclusive, of the range\n     * @return true if the test condition is met\n     * @stable ICU 2.4\n     */\n    UBool containsNone(UChar32 start, UChar32 end) const;\n\n    /**\n     * Returns true if this set contains none of the characters and strings\n     * of the given set.\n     * @param c set to be checked for containment\n     * @return true if the test condition is met\n     * @stable ICU 2.4\n     */\n    UBool containsNone(const UnicodeSet& c) const;\n\n    /**\n     * Returns true if this set contains none of the characters\n     * of the given string.\n     * @param s string containing characters to be checked for containment\n     * @return true if the test condition is met\n     * @stable ICU 2.4\n     */\n    UBool containsNone(const UnicodeString& s) const;\n\n    /**\n     * Returns true if this set contains one or more of the characters\n     * in the given range.\n     * @param start first character, inclusive, of the range\n     * @param end last character, inclusive, of the range\n     * @return true if the condition is met\n     * @stable ICU 2.4\n     */\n    inline UBool containsSome(UChar32 start, UChar32 end) const;\n\n    /**\n     * Returns true if this set contains one or more of the characters\n     * and strings of the given set.\n     * @param s The set to be checked for containment\n     * @return true if the condition is met\n     * @stable ICU 2.4\n     */\n    inline UBool containsSome(const UnicodeSet& s) const;\n\n    /**\n     * Returns true if this set contains one or more of the characters\n     * of the given string.\n     * @param s string containing characters to be checked for containment\n     * @return true if the condition is met\n     * @stable ICU 2.4\n     */\n    inline UBool containsSome(const UnicodeString& s) const;\n\n    /**\n     * Returns the length of the initial substring of the input string which\n     * consists only of characters and strings that are contained in this set\n     * (USET_SPAN_CONTAINED, USET_SPAN_SIMPLE),\n     * or only of characters and strings that are not contained\n     * in this set (USET_SPAN_NOT_CONTAINED).\n     * See USetSpanCondition for details.\n     * Similar to the strspn() C library function.\n     * Unpaired surrogates are treated according to contains() of their surrogate code points.\n     * This function works faster with a frozen set and with a non-negative string length argument.\n     * @param s start of the string\n     * @param length of the string; can be -1 for NUL-terminated\n     * @param spanCondition specifies the containment condition\n     * @return the length of the initial substring according to the spanCondition;\n     *         0 if the start of the string does not fit the spanCondition\n     * @stable ICU 3.8\n     * @see USetSpanCondition\n     */\n    int32_t span(const UChar *s, int32_t length, USetSpanCondition spanCondition) const;\n\n    /**\n     * Returns the end of the substring of the input string according to the USetSpanCondition.\n     * Same as <code>start+span(s.getBuffer()+start, s.length()-start, spanCondition)</code>\n     * after pinning start to 0<=start<=s.length().\n     * @param s the string\n     * @param start the start index in the string for the span operation\n     * @param spanCondition specifies the containment condition\n     * @return the exclusive end of the substring according to the spanCondition;\n     *         the substring s.tempSubStringBetween(start, end) fulfills the spanCondition\n     * @stable ICU 4.4\n     * @see USetSpanCondition\n     */\n    inline int32_t span(const UnicodeString &s, int32_t start, USetSpanCondition spanCondition) const;\n\n    /**\n     * Returns the start of the trailing substring of the input string which\n     * consists only of characters and strings that are contained in this set\n     * (USET_SPAN_CONTAINED, USET_SPAN_SIMPLE),\n     * or only of characters and strings that are not contained\n     * in this set (USET_SPAN_NOT_CONTAINED).\n     * See USetSpanCondition for details.\n     * Unpaired surrogates are treated according to contains() of their surrogate code points.\n     * This function works faster with a frozen set and with a non-negative string length argument.\n     * @param s start of the string\n     * @param length of the string; can be -1 for NUL-terminated\n     * @param spanCondition specifies the containment condition\n     * @return the start of the trailing substring according to the spanCondition;\n     *         the string length if the end of the string does not fit the spanCondition\n     * @stable ICU 3.8\n     * @see USetSpanCondition\n     */\n    int32_t spanBack(const UChar *s, int32_t length, USetSpanCondition spanCondition) const;\n\n    /**\n     * Returns the start of the substring of the input string according to the USetSpanCondition.\n     * Same as <code>spanBack(s.getBuffer(), limit, spanCondition)</code>\n     * after pinning limit to 0<=end<=s.length().\n     * @param s the string\n     * @param limit the exclusive-end index in the string for the span operation\n     *              (use s.length() or INT32_MAX for spanning back from the end of the string)\n     * @param spanCondition specifies the containment condition\n     * @return the start of the substring according to the spanCondition;\n     *         the substring s.tempSubStringBetween(start, limit) fulfills the spanCondition\n     * @stable ICU 4.4\n     * @see USetSpanCondition\n     */\n    inline int32_t spanBack(const UnicodeString &s, int32_t limit, USetSpanCondition spanCondition) const;\n\n    /**\n     * Returns the length of the initial substring of the input string which\n     * consists only of characters and strings that are contained in this set\n     * (USET_SPAN_CONTAINED, USET_SPAN_SIMPLE),\n     * or only of characters and strings that are not contained\n     * in this set (USET_SPAN_NOT_CONTAINED).\n     * See USetSpanCondition for details.\n     * Similar to the strspn() C library function.\n     * Malformed byte sequences are treated according to contains(0xfffd).\n     * This function works faster with a frozen set and with a non-negative string length argument.\n     * @param s start of the string (UTF-8)\n     * @param length of the string; can be -1 for NUL-terminated\n     * @param spanCondition specifies the containment condition\n     * @return the length of the initial substring according to the spanCondition;\n     *         0 if the start of the string does not fit the spanCondition\n     * @stable ICU 3.8\n     * @see USetSpanCondition\n     */\n    int32_t spanUTF8(const char *s, int32_t length, USetSpanCondition spanCondition) const;\n\n    /**\n     * Returns the start of the trailing substring of the input string which\n     * consists only of characters and strings that are contained in this set\n     * (USET_SPAN_CONTAINED, USET_SPAN_SIMPLE),\n     * or only of characters and strings that are not contained\n     * in this set (USET_SPAN_NOT_CONTAINED).\n     * See USetSpanCondition for details.\n     * Malformed byte sequences are treated according to contains(0xfffd).\n     * This function works faster with a frozen set and with a non-negative string length argument.\n     * @param s start of the string (UTF-8)\n     * @param length of the string; can be -1 for NUL-terminated\n     * @param spanCondition specifies the containment condition\n     * @return the start of the trailing substring according to the spanCondition;\n     *         the string length if the end of the string does not fit the spanCondition\n     * @stable ICU 3.8\n     * @see USetSpanCondition\n     */\n    int32_t spanBackUTF8(const char *s, int32_t length, USetSpanCondition spanCondition) const;\n\n    /**\n     * Implement UnicodeMatcher::matches()\n     * @stable ICU 2.4\n     */\n    virtual UMatchDegree matches(const Replaceable& text,\n                         int32_t& offset,\n                         int32_t limit,\n                         UBool incremental);\n\nprivate:\n    /**\n     * Returns the longest match for s in text at the given position.\n     * If limit > start then match forward from start+1 to limit\n     * matching all characters except s.charAt(0).  If limit < start,\n     * go backward starting from start-1 matching all characters\n     * except s.charAt(s.length()-1).  This method assumes that the\n     * first character, text.charAt(start), matches s, so it does not\n     * check it.\n     * @param text the text to match\n     * @param start the first character to match.  In the forward\n     * direction, text.charAt(start) is matched against s.charAt(0).\n     * In the reverse direction, it is matched against\n     * s.charAt(s.length()-1).\n     * @param limit the limit offset for matching, either last+1 in\n     * the forward direction, or last-1 in the reverse direction,\n     * where last is the index of the last character to match.\n     * @param s\n     * @return If part of s matches up to the limit, return |limit -\n     * start|.  If all of s matches before reaching the limit, return\n     * s.length().  If there is a mismatch between s and text, return\n     * 0\n     */\n    static int32_t matchRest(const Replaceable& text,\n                             int32_t start, int32_t limit,\n                             const UnicodeString& s);\n\n    /**\n     * Returns the smallest value i such that c < list[i].  Caller\n     * must ensure that c is a legal value or this method will enter\n     * an infinite loop.  This method performs a binary search.\n     * @param c a character in the range MIN_VALUE..MAX_VALUE\n     * inclusive\n     * @return the smallest integer i in the range 0..len-1,\n     * inclusive, such that c < list[i]\n     */\n    int32_t findCodePoint(UChar32 c) const;\n\npublic:\n\n    /**\n     * Implementation of UnicodeMatcher API.  Union the set of all\n     * characters that may be matched by this object into the given\n     * set.\n     * @param toUnionTo the set into which to union the source characters\n     * @stable ICU 2.4\n     */\n    virtual void addMatchSetTo(UnicodeSet& toUnionTo) const;\n\n    /**\n     * Returns the index of the given character within this set, where\n     * the set is ordered by ascending code point.  If the character\n     * is not in this set, return -1.  The inverse of this method is\n     * <code>charAt()</code>.\n     * @return an index from 0..size()-1, or -1\n     * @stable ICU 2.4\n     */\n    int32_t indexOf(UChar32 c) const;\n\n    /**\n     * Returns the character at the given index within this set, where\n     * the set is ordered by ascending code point.  If the index is\n     * out of range, return (UChar32)-1.  The inverse of this method is\n     * <code>indexOf()</code>.\n     * @param index an index from 0..size()-1\n     * @return the character at the given index, or (UChar32)-1.\n     * @stable ICU 2.4\n     */\n    UChar32 charAt(int32_t index) const;\n\n    /**\n     * Adds the specified range to this set if it is not already\n     * present.  If this set already contains the specified range,\n     * the call leaves this set unchanged.  If <code>end > start</code>\n     * then an empty range is added, leaving the set unchanged.\n     * This is equivalent to a boolean logic OR, or a set UNION.\n     * A frozen set will not be modified.\n     *\n     * @param start first character, inclusive, of range to be added\n     * to this set.\n     * @param end last character, inclusive, of range to be added\n     * to this set.\n     * @stable ICU 2.0\n     */\n    virtual UnicodeSet& add(UChar32 start, UChar32 end);\n\n    /**\n     * Adds the specified character to this set if it is not already\n     * present.  If this set already contains the specified character,\n     * the call leaves this set unchanged.\n     * A frozen set will not be modified.\n     * @stable ICU 2.0\n     */\n    UnicodeSet& add(UChar32 c);\n\n    /**\n     * Adds the specified multicharacter to this set if it is not already\n     * present.  If this set already contains the multicharacter,\n     * the call leaves this set unchanged.\n     * Thus \"ch\" => {\"ch\"}\n     * <br><b>Warning: you cannot add an empty string (\"\") to a UnicodeSet.</b>\n     * A frozen set will not be modified.\n     * @param s the source string\n     * @return this object, for chaining\n     * @stable ICU 2.4\n     */\n    UnicodeSet& add(const UnicodeString& s);\n\n private:\n    /**\n     * @return a code point IF the string consists of a single one.\n     * otherwise returns -1.\n     * @param s string to test\n     */\n    static int32_t getSingleCP(const UnicodeString& s);\n\n    void _add(const UnicodeString& s);\n\n public:\n    /**\n     * Adds each of the characters in this string to the set. Thus \"ch\" => {\"c\", \"h\"}\n     * If this set already any particular character, it has no effect on that character.\n     * A frozen set will not be modified.\n     * @param s the source string\n     * @return this object, for chaining\n     * @stable ICU 2.4\n     */\n    UnicodeSet& addAll(const UnicodeString& s);\n\n    /**\n     * Retains EACH of the characters in this string. Note: \"ch\" == {\"c\", \"h\"}\n     * If this set already any particular character, it has no effect on that character.\n     * A frozen set will not be modified.\n     * @param s the source string\n     * @return this object, for chaining\n     * @stable ICU 2.4\n     */\n    UnicodeSet& retainAll(const UnicodeString& s);\n\n    /**\n     * Complement EACH of the characters in this string. Note: \"ch\" == {\"c\", \"h\"}\n     * If this set already any particular character, it has no effect on that character.\n     * A frozen set will not be modified.\n     * @param s the source string\n     * @return this object, for chaining\n     * @stable ICU 2.4\n     */\n    UnicodeSet& complementAll(const UnicodeString& s);\n\n    /**\n     * Remove EACH of the characters in this string. Note: \"ch\" == {\"c\", \"h\"}\n     * If this set already any particular character, it has no effect on that character.\n     * A frozen set will not be modified.\n     * @param s the source string\n     * @return this object, for chaining\n     * @stable ICU 2.4\n     */\n    UnicodeSet& removeAll(const UnicodeString& s);\n\n    /**\n     * Makes a set from a multicharacter string. Thus \"ch\" => {\"ch\"}\n     * <br><b>Warning: you cannot add an empty string (\"\") to a UnicodeSet.</b>\n     * @param s the source string\n     * @return a newly created set containing the given string.\n     * The caller owns the return object and is responsible for deleting it.\n     * @stable ICU 2.4\n     */\n    static UnicodeSet* U_EXPORT2 createFrom(const UnicodeString& s);\n\n\n    /**\n     * Makes a set from each of the characters in the string. Thus \"ch\" => {\"c\", \"h\"}\n     * @param s the source string\n     * @return a newly created set containing the given characters\n     * The caller owns the return object and is responsible for deleting it.\n     * @stable ICU 2.4\n     */\n    static UnicodeSet* U_EXPORT2 createFromAll(const UnicodeString& s);\n\n    /**\n     * Retain only the elements in this set that are contained in the\n     * specified range.  If <code>end > start</code> then an empty range is\n     * retained, leaving the set empty.  This is equivalent to\n     * a boolean logic AND, or a set INTERSECTION.\n     * A frozen set will not be modified.\n     *\n     * @param start first character, inclusive, of range to be retained\n     * to this set.\n     * @param end last character, inclusive, of range to be retained\n     * to this set.\n     * @stable ICU 2.0\n     */\n    virtual UnicodeSet& retain(UChar32 start, UChar32 end);\n\n\n    /**\n     * Retain the specified character from this set if it is present.\n     * A frozen set will not be modified.\n     * @stable ICU 2.0\n     */\n    UnicodeSet& retain(UChar32 c);\n\n    /**\n     * Removes the specified range from this set if it is present.\n     * The set will not contain the specified range once the call\n     * returns.  If <code>end > start</code> then an empty range is\n     * removed, leaving the set unchanged.\n     * A frozen set will not be modified.\n     *\n     * @param start first character, inclusive, of range to be removed\n     * from this set.\n     * @param end last character, inclusive, of range to be removed\n     * from this set.\n     * @stable ICU 2.0\n     */\n    virtual UnicodeSet& remove(UChar32 start, UChar32 end);\n\n    /**\n     * Removes the specified character from this set if it is present.\n     * The set will not contain the specified range once the call\n     * returns.\n     * A frozen set will not be modified.\n     * @stable ICU 2.0\n     */\n    UnicodeSet& remove(UChar32 c);\n\n    /**\n     * Removes the specified string from this set if it is present.\n     * The set will not contain the specified character once the call\n     * returns.\n     * A frozen set will not be modified.\n     * @param s the source string\n     * @return this object, for chaining\n     * @stable ICU 2.4\n     */\n    UnicodeSet& remove(const UnicodeString& s);\n\n    /**\n     * Inverts this set.  This operation modifies this set so that\n     * its value is its complement.  This is equivalent to\n     * <code>complement(MIN_VALUE, MAX_VALUE)</code>.\n     * A frozen set will not be modified.\n     * @stable ICU 2.0\n     */\n    virtual UnicodeSet& complement(void);\n\n    /**\n     * Complements the specified range in this set.  Any character in\n     * the range will be removed if it is in this set, or will be\n     * added if it is not in this set.  If <code>end > start</code>\n     * then an empty range is complemented, leaving the set unchanged.\n     * This is equivalent to a boolean logic XOR.\n     * A frozen set will not be modified.\n     *\n     * @param start first character, inclusive, of range to be removed\n     * from this set.\n     * @param end last character, inclusive, of range to be removed\n     * from this set.\n     * @stable ICU 2.0\n     */\n    virtual UnicodeSet& complement(UChar32 start, UChar32 end);\n\n    /**\n     * Complements the specified character in this set.  The character\n     * will be removed if it is in this set, or will be added if it is\n     * not in this set.\n     * A frozen set will not be modified.\n     * @stable ICU 2.0\n     */\n    UnicodeSet& complement(UChar32 c);\n\n    /**\n     * Complement the specified string in this set.\n     * The set will not contain the specified string once the call\n     * returns.\n     * <br><b>Warning: you cannot add an empty string (\"\") to a UnicodeSet.</b>\n     * A frozen set will not be modified.\n     * @param s the string to complement\n     * @return this object, for chaining\n     * @stable ICU 2.4\n     */\n    UnicodeSet& complement(const UnicodeString& s);\n\n    /**\n     * Adds all of the elements in the specified set to this set if\n     * they're not already present.  This operation effectively\n     * modifies this set so that its value is the <i>union</i> of the two\n     * sets.  The behavior of this operation is unspecified if the specified\n     * collection is modified while the operation is in progress.\n     * A frozen set will not be modified.\n     *\n     * @param c set whose elements are to be added to this set.\n     * @see #add(UChar32, UChar32)\n     * @stable ICU 2.0\n     */\n    virtual UnicodeSet& addAll(const UnicodeSet& c);\n\n    /**\n     * Retains only the elements in this set that are contained in the\n     * specified set.  In other words, removes from this set all of\n     * its elements that are not contained in the specified set.  This\n     * operation effectively modifies this set so that its value is\n     * the <i>intersection</i> of the two sets.\n     * A frozen set will not be modified.\n     *\n     * @param c set that defines which elements this set will retain.\n     * @stable ICU 2.0\n     */\n    virtual UnicodeSet& retainAll(const UnicodeSet& c);\n\n    /**\n     * Removes from this set all of its elements that are contained in the\n     * specified set.  This operation effectively modifies this\n     * set so that its value is the <i>asymmetric set difference</i> of\n     * the two sets.\n     * A frozen set will not be modified.\n     *\n     * @param c set that defines which elements will be removed from\n     *          this set.\n     * @stable ICU 2.0\n     */\n    virtual UnicodeSet& removeAll(const UnicodeSet& c);\n\n    /**\n     * Complements in this set all elements contained in the specified\n     * set.  Any character in the other set will be removed if it is\n     * in this set, or will be added if it is not in this set.\n     * A frozen set will not be modified.\n     *\n     * @param c set that defines which elements will be xor'ed from\n     *          this set.\n     * @stable ICU 2.4\n     */\n    virtual UnicodeSet& complementAll(const UnicodeSet& c);\n\n    /**\n     * Removes all of the elements from this set.  This set will be\n     * empty after this call returns.\n     * A frozen set will not be modified.\n     * @stable ICU 2.0\n     */\n    virtual UnicodeSet& clear(void);\n\n    /**\n     * Close this set over the given attribute.  For the attribute\n     * USET_CASE, the result is to modify this set so that:\n     *\n     * 1. For each character or string 'a' in this set, all strings or\n     * characters 'b' such that foldCase(a) == foldCase(b) are added\n     * to this set.\n     *\n     * 2. For each string 'e' in the resulting set, if e !=\n     * foldCase(e), 'e' will be removed.\n     *\n     * Example: [aq\\\\u00DF{Bc}{bC}{Fi}] => [aAqQ\\\\u00DF\\\\uFB01{ss}{bc}{fi}]\n     *\n     * (Here foldCase(x) refers to the operation u_strFoldCase, and a\n     * == b denotes that the contents are the same, not pointer\n     * comparison.)\n     *\n     * A frozen set will not be modified.\n     *\n     * @param attribute bitmask for attributes to close over.\n     * Currently only the USET_CASE bit is supported.  Any undefined bits\n     * are ignored.\n     * @return a reference to this set.\n     * @stable ICU 4.2\n     */\n    UnicodeSet& closeOver(int32_t attribute);\n\n    /**\n     * Remove all strings from this set.\n     *\n     * @return a reference to this set.\n     * @stable ICU 4.2\n     */\n    virtual UnicodeSet &removeAllStrings();\n\n    /**\n     * Iteration method that returns the number of ranges contained in\n     * this set.\n     * @see #getRangeStart\n     * @see #getRangeEnd\n     * @stable ICU 2.4\n     */\n    virtual int32_t getRangeCount(void) const;\n\n    /**\n     * Iteration method that returns the first character in the\n     * specified range of this set.\n     * @see #getRangeCount\n     * @see #getRangeEnd\n     * @stable ICU 2.4\n     */\n    virtual UChar32 getRangeStart(int32_t index) const;\n\n    /**\n     * Iteration method that returns the last character in the\n     * specified range of this set.\n     * @see #getRangeStart\n     * @see #getRangeEnd\n     * @stable ICU 2.4\n     */\n    virtual UChar32 getRangeEnd(int32_t index) const;\n\n    /**\n     * Serializes this set into an array of 16-bit integers.  Serialization\n     * (currently) only records the characters in the set; multicharacter\n     * strings are ignored.\n     *\n     * The array has following format (each line is one 16-bit\n     * integer):\n     *\n     *  length     = (n+2*m) | (m!=0?0x8000:0)\n     *  bmpLength  = n; present if m!=0\n     *  bmp[0]\n     *  bmp[1]\n     *  ...\n     *  bmp[n-1]\n     *  supp-high[0]\n     *  supp-low[0]\n     *  supp-high[1]\n     *  supp-low[1]\n     *  ...\n     *  supp-high[m-1]\n     *  supp-low[m-1]\n     *\n     * The array starts with a header.  After the header are n bmp\n     * code points, then m supplementary code points.  Either n or m\n     * or both may be zero.  n+2*m is always <= 0x7FFF.\n     *\n     * If there are no supplementary characters (if m==0) then the\n     * header is one 16-bit integer, 'length', with value n.\n     *\n     * If there are supplementary characters (if m!=0) then the header\n     * is two 16-bit integers.  The first, 'length', has value\n     * (n+2*m)|0x8000.  The second, 'bmpLength', has value n.\n     *\n     * After the header the code points are stored in ascending order.\n     * Supplementary code points are stored as most significant 16\n     * bits followed by least significant 16 bits.\n     *\n     * @param dest pointer to buffer of destCapacity 16-bit integers.\n     * May be NULL only if destCapacity is zero.\n     * @param destCapacity size of dest, or zero.  Must not be negative.\n     * @param ec error code.  Will be set to U_INDEX_OUTOFBOUNDS_ERROR\n     * if n+2*m > 0x7FFF.  Will be set to U_BUFFER_OVERFLOW_ERROR if\n     * n+2*m+(m!=0?2:1) > destCapacity.\n     * @return the total length of the serialized format, including\n     * the header, that is, n+2*m+(m!=0?2:1), or 0 on error other\n     * than U_BUFFER_OVERFLOW_ERROR.\n     * @stable ICU 2.4\n     */\n    int32_t serialize(uint16_t *dest, int32_t destCapacity, UErrorCode& ec) const;\n\n    /**\n     * Reallocate this objects internal structures to take up the least\n     * possible space, without changing this object's value.\n     * A frozen set will not be modified.\n     * @stable ICU 2.4\n     */\n    virtual UnicodeSet& compact();\n\n    /**\n     * Return the class ID for this class.  This is useful only for\n     * comparing to a return value from getDynamicClassID().  For example:\n     * <pre>\n     * .      Base* polymorphic_pointer = createPolymorphicObject();\n     * .      if (polymorphic_pointer->getDynamicClassID() ==\n     * .          Derived::getStaticClassID()) ...\n     * </pre>\n     * @return          The class ID for all objects of this class.\n     * @stable ICU 2.0\n     */\n    static UClassID U_EXPORT2 getStaticClassID(void);\n\n    /**\n     * Implement UnicodeFunctor API.\n     *\n     * @return The class ID for this object. All objects of a given\n     * class have the same class ID.  Objects of other classes have\n     * different class IDs.\n     * @stable ICU 2.4\n     */\n    virtual UClassID getDynamicClassID(void) const;\n\nprivate:\n\n    // Private API for the USet API\n\n    friend class USetAccess;\n\n    int32_t getStringCount() const;\n\n    const UnicodeString* getString(int32_t index) const;\n\n    //----------------------------------------------------------------\n    // RuleBasedTransliterator support\n    //----------------------------------------------------------------\n\nprivate:\n\n    /**\n     * Returns <tt>true</tt> if this set contains any character whose low byte\n     * is the given value.  This is used by <tt>RuleBasedTransliterator</tt> for\n     * indexing.\n     */\n    virtual UBool matchesIndexValue(uint8_t v) const;\n\nprivate:\n    friend class RBBIRuleScanner;\n\n    //----------------------------------------------------------------\n    // Implementation: Clone as thawed (see ICU4J Freezable)\n    //----------------------------------------------------------------\n\n    UnicodeSet(const UnicodeSet& o, UBool /* asThawed */);\n\n    //----------------------------------------------------------------\n    // Implementation: Pattern parsing\n    //----------------------------------------------------------------\n\n    void applyPatternIgnoreSpace(const UnicodeString& pattern,\n                                 ParsePosition& pos,\n                                 const SymbolTable* symbols,\n                                 UErrorCode& status);\n\n    void applyPattern(RuleCharacterIterator& chars,\n                      const SymbolTable* symbols,\n                      UnicodeString& rebuiltPat,\n                      uint32_t options,\n                      UnicodeSet& (UnicodeSet::*caseClosure)(int32_t attribute),\n                      UErrorCode& ec);\n\n    //----------------------------------------------------------------\n    // Implementation: Utility methods\n    //----------------------------------------------------------------\n\n    void ensureCapacity(int32_t newLen, UErrorCode& ec);\n\n    void ensureBufferCapacity(int32_t newLen, UErrorCode& ec);\n\n    void swapBuffers(void);\n\n    UBool allocateStrings(UErrorCode &status);\n\n    UnicodeString& _toPattern(UnicodeString& result,\n                              UBool escapeUnprintable) const;\n\n    UnicodeString& _generatePattern(UnicodeString& result,\n                                    UBool escapeUnprintable) const;\n\n    static void _appendToPat(UnicodeString& buf, const UnicodeString& s, UBool escapeUnprintable);\n\n    static void _appendToPat(UnicodeString& buf, UChar32 c, UBool escapeUnprintable);\n\n    //----------------------------------------------------------------\n    // Implementation: Fundamental operators\n    //----------------------------------------------------------------\n\n    void exclusiveOr(const UChar32* other, int32_t otherLen, int8_t polarity);\n\n    void add(const UChar32* other, int32_t otherLen, int8_t polarity);\n\n    void retain(const UChar32* other, int32_t otherLen, int8_t polarity);\n\n    /**\n     * Return true if the given position, in the given pattern, appears\n     * to be the start of a property set pattern [:foo:], \\\\p{foo}, or\n     * \\\\P{foo}, or \\\\N{name}.\n     */\n    static UBool resemblesPropertyPattern(const UnicodeString& pattern,\n                                          int32_t pos);\n\n    static UBool resemblesPropertyPattern(RuleCharacterIterator& chars,\n                                          int32_t iterOpts);\n\n    /**\n     * Parse the given property pattern at the given parse position\n     * and set this UnicodeSet to the result.\n     *\n     * The original design document is out of date, but still useful.\n     * Ignore the property and value names:\n     * http://source.icu-project.org/repos/icu/icuhtml/trunk/design/unicodeset_properties.html\n     *\n     * Recognized syntax:\n     *\n     * [:foo:] [:^foo:] - white space not allowed within \"[:\" or \":]\"\n     * \\\\p{foo} \\\\P{foo}  - white space not allowed within \"\\\\p\" or \"\\\\P\"\n     * \\\\N{name}         - white space not allowed within \"\\\\N\"\n     *\n     * Other than the above restrictions, Unicode Pattern_White_Space characters are ignored.\n     * Case is ignored except in \"\\\\p\" and \"\\\\P\" and \"\\\\N\".  In 'name' leading\n     * and trailing space is deleted, and internal runs of whitespace\n     * are collapsed to a single space.\n     *\n     * We support binary properties, enumerated properties, and the\n     * following non-enumerated properties:\n     *\n     *  Numeric_Value\n     *  Name\n     *  Unicode_1_Name\n     *\n     * @param pattern the pattern string\n     * @param ppos on entry, the position at which to begin parsing.\n     * This should be one of the locations marked '^':\n     *\n     *   [:blah:]     \\\\p{blah}     \\\\P{blah}     \\\\N{name}\n     *   ^       %    ^       %    ^       %    ^       %\n     *\n     * On return, the position after the last character parsed, that is,\n     * the locations marked '%'.  If the parse fails, ppos is returned\n     * unchanged.\n     * @param ec status\n     * @return a reference to this.\n     */\n    UnicodeSet& applyPropertyPattern(const UnicodeString& pattern,\n                                     ParsePosition& ppos,\n                                     UErrorCode &ec);\n\n    void applyPropertyPattern(RuleCharacterIterator& chars,\n                              UnicodeString& rebuiltPat,\n                              UErrorCode& ec);\n\n    static const UnicodeSet* getInclusions(int32_t src, UErrorCode &status);\n\n    /**\n     * A filter that returns TRUE if the given code point should be\n     * included in the UnicodeSet being constructed.\n     */\n    typedef UBool (*Filter)(UChar32 codePoint, void* context);\n\n    /**\n     * Given a filter, set this UnicodeSet to the code points\n     * contained by that filter.  The filter MUST be\n     * property-conformant.  That is, if it returns value v for one\n     * code point, then it must return v for all affiliated code\n     * points, as defined by the inclusions list.  See\n     * getInclusions().\n     * src is a UPropertySource value.\n     */\n    void applyFilter(Filter filter,\n                     void* context,\n                     int32_t src,\n                     UErrorCode &status);\n\n    /**\n     * Set the new pattern to cache.\n     */\n    void setPattern(const UnicodeString& newPat);\n    /**\n     * Release existing cached pattern.\n     */\n    void releasePattern();\n\n    friend class UnicodeSetIterator;\n};\n\n\n\ninline UBool UnicodeSet::operator!=(const UnicodeSet& o) const {\n    return !operator==(o);\n}\n\ninline UBool UnicodeSet::isFrozen() const {\n    return (UBool)(bmpSet!=NULL || stringSpan!=NULL);\n}\n\ninline UBool UnicodeSet::containsSome(UChar32 start, UChar32 end) const {\n    return !containsNone(start, end);\n}\n\ninline UBool UnicodeSet::containsSome(const UnicodeSet& s) const {\n    return !containsNone(s);\n}\n\ninline UBool UnicodeSet::containsSome(const UnicodeString& s) const {\n    return !containsNone(s);\n}\n\ninline UBool UnicodeSet::isBogus() const {\n    return (UBool)(fFlags & kIsBogus);\n}\n\ninline UnicodeSet *UnicodeSet::fromUSet(USet *uset) {\n    return reinterpret_cast<UnicodeSet *>(uset);\n}\n\ninline const UnicodeSet *UnicodeSet::fromUSet(const USet *uset) {\n    return reinterpret_cast<const UnicodeSet *>(uset);\n}\n\ninline USet *UnicodeSet::toUSet() {\n    return reinterpret_cast<USet *>(this);\n}\n\ninline const USet *UnicodeSet::toUSet() const {\n    return reinterpret_cast<const USet *>(this);\n}\n\ninline int32_t UnicodeSet::span(const UnicodeString &s, int32_t start, USetSpanCondition spanCondition) const {\n    int32_t sLength=s.length();\n    if(start<0) {\n        start=0;\n    } else if(start>sLength) {\n        start=sLength;\n    }\n    return start+span(s.getBuffer()+start, sLength-start, spanCondition);\n}\n\ninline int32_t UnicodeSet::spanBack(const UnicodeString &s, int32_t limit, USetSpanCondition spanCondition) const {\n    int32_t sLength=s.length();\n    if(limit<0) {\n        limit=0;\n    } else if(limit>sLength) {\n        limit=sLength;\n    }\n    return spanBack(s.getBuffer(), limit, spanCondition);\n}\n\nU_NAMESPACE_END\n\n#endif\n"
  },
  {
    "path": "deprecated/android/addons/icucompat/unicode/unistr.h",
    "content": "/*\n**********************************************************************\n*   Copyright (C) 1998-2012, International Business Machines\n*   Corporation and others.  All Rights Reserved.\n**********************************************************************\n*\n* File unistr.h\n*\n* Modification History:\n*\n*   Date        Name        Description\n*   09/25/98    stephen     Creation.\n*   11/11/98    stephen     Changed per 11/9 code review.\n*   04/20/99    stephen     Overhauled per 4/16 code review.\n*   11/18/99    aliu        Made to inherit from Replaceable.  Added method\n*                           handleReplaceBetween(); other methods unchanged.\n*   06/25/01    grhoten     Remove dependency on iostream.\n******************************************************************************\n*/\n\n#ifndef UNISTR_H\n#define UNISTR_H\n\n/**\n * \\file \n * \\brief C++ API: Unicode String \n */\n\n#include \"unicode/utypes.h\"\n#include \"unicode/rep.h\"\n#include \"unicode/std_string.h\"\n#include \"unicode/stringpiece.h\"\n#include \"unicode/bytestream.h\"\n#include \"unicode/ucasemap.h\"\n\nstruct UConverter;          // unicode/ucnv.h\nclass  StringThreadTest;\n\n#ifndef U_COMPARE_CODE_POINT_ORDER\n/* see also ustring.h and unorm.h */\n/**\n * Option bit for u_strCaseCompare, u_strcasecmp, unorm_compare, etc:\n * Compare strings in code point order instead of code unit order.\n * @stable ICU 2.2\n */\n#define U_COMPARE_CODE_POINT_ORDER  0x8000\n#endif\n\n#ifndef USTRING_H\n/**\n * \\ingroup ustring_ustrlen\n */\nU_STABLE int32_t U_EXPORT2\nu_strlen(const UChar *s);\n#endif\n\n/**\n * \\def U_STRING_CASE_MAPPER_DEFINED\n * @internal\n */\n\n#ifndef U_STRING_CASE_MAPPER_DEFINED\n#define U_STRING_CASE_MAPPER_DEFINED\n\n/**\n * Internal string case mapping function type.\n * @internal\n */\ntypedef int32_t U_CALLCONV\nUStringCaseMapper(const UCaseMap *csm,\n                  UChar *dest, int32_t destCapacity,\n                  const UChar *src, int32_t srcLength,\n                  UErrorCode *pErrorCode);\n\n#endif\n\nU_NAMESPACE_BEGIN\n\nclass BreakIterator;        // unicode/brkiter.h\nclass Locale;               // unicode/locid.h\nclass StringCharacterIterator;\nclass UnicodeStringAppendable;  // unicode/appendable.h\n\n/* The <iostream> include has been moved to unicode/ustream.h */\n\n/**\n * Constant to be used in the UnicodeString(char *, int32_t, EInvariant) constructor\n * which constructs a Unicode string from an invariant-character char * string.\n * About invariant characters see utypes.h.\n * This constructor has no runtime dependency on conversion code and is\n * therefore recommended over ones taking a charset name string\n * (where the empty string \"\" indicates invariant-character conversion).\n *\n * @stable ICU 3.2\n */\n#define US_INV icu::UnicodeString::kInvariant\n\n/**\n * Unicode String literals in C++.\n * Dependent on the platform properties, different UnicodeString\n * constructors should be used to create a UnicodeString object from\n * a string literal.\n * The macros are defined for maximum performance.\n * They work only for strings that contain \"invariant characters\", i.e.,\n * only latin letters, digits, and some punctuation.\n * See utypes.h for details.\n *\n * The string parameter must be a C string literal.\n * The length of the string, not including the terminating\n * <code>NUL</code>, must be specified as a constant.\n * The U_STRING_DECL macro should be invoked exactly once for one\n * such string variable before it is used.\n * @stable ICU 2.0\n */\n#if defined(U_DECLARE_UTF16)\n#   define UNICODE_STRING(cs, _length) icu::UnicodeString(TRUE, (const UChar *)U_DECLARE_UTF16(cs), _length)\n#elif U_SIZEOF_WCHAR_T==U_SIZEOF_UCHAR && (U_CHARSET_FAMILY==U_ASCII_FAMILY || (U_SIZEOF_UCHAR == 2 && defined(U_WCHAR_IS_UTF16)))\n#   define UNICODE_STRING(cs, _length) icu::UnicodeString(TRUE, (const UChar *)L ## cs, _length)\n#elif U_SIZEOF_UCHAR==1 && U_CHARSET_FAMILY==U_ASCII_FAMILY\n#   define UNICODE_STRING(cs, _length) icu::UnicodeString(TRUE, (const UChar *)cs, _length)\n#else\n#   define UNICODE_STRING(cs, _length) icu::UnicodeString(cs, _length, US_INV)\n#endif\n\n/**\n * Unicode String literals in C++.\n * Dependent on the platform properties, different UnicodeString\n * constructors should be used to create a UnicodeString object from\n * a string literal.\n * The macros are defined for improved performance.\n * They work only for strings that contain \"invariant characters\", i.e.,\n * only latin letters, digits, and some punctuation.\n * See utypes.h for details.\n *\n * The string parameter must be a C string literal.\n * @stable ICU 2.0\n */\n#define UNICODE_STRING_SIMPLE(cs) UNICODE_STRING(cs, -1)\n\n/**\n * \\def UNISTR_FROM_CHAR_EXPLICIT\n * This can be defined to be empty or \"explicit\".\n * If explicit, then the UnicodeString(UChar) and UnicodeString(UChar32)\n * constructors are marked as explicit, preventing their inadvertent use.\n * @draft ICU 49\n */\n#ifndef UNISTR_FROM_CHAR_EXPLICIT\n# if defined(U_COMBINED_IMPLEMENTATION) || defined(U_COMMON_IMPLEMENTATION) || defined(U_I18N_IMPLEMENTATION) || defined(U_IO_IMPLEMENTATION)\n    // Auto-\"explicit\" in ICU library code.\n#   define UNISTR_FROM_CHAR_EXPLICIT explicit\n# else\n    // Empty by default for source code compatibility.\n#   define UNISTR_FROM_CHAR_EXPLICIT\n# endif\n#endif\n\n/**\n * \\def UNISTR_FROM_STRING_EXPLICIT\n * This can be defined to be empty or \"explicit\".\n * If explicit, then the UnicodeString(const char *) and UnicodeString(const UChar *)\n * constructors are marked as explicit, preventing their inadvertent use.\n *\n * In particular, this helps prevent accidentally depending on ICU conversion code\n * by passing a string literal into an API with a const UnicodeString & parameter.\n * @draft ICU 49\n */\n#ifndef UNISTR_FROM_STRING_EXPLICIT\n# if defined(U_COMBINED_IMPLEMENTATION) || defined(U_COMMON_IMPLEMENTATION) || defined(U_I18N_IMPLEMENTATION) || defined(U_IO_IMPLEMENTATION)\n    // Auto-\"explicit\" in ICU library code.\n#   define UNISTR_FROM_STRING_EXPLICIT explicit\n# else\n    // Empty by default for source code compatibility.\n#   define UNISTR_FROM_STRING_EXPLICIT\n# endif\n#endif\n\n/**\n * UnicodeString is a string class that stores Unicode characters directly and provides\n * similar functionality as the Java String and StringBuffer classes.\n * It is a concrete implementation of the abstract class Replaceable (for transliteration).\n *\n * The UnicodeString class is not suitable for subclassing.\n *\n * <p>For an overview of Unicode strings in C and C++ see the\n * <a href=\"http://icu-project.org/userguide/strings.html\">User Guide Strings chapter</a>.</p>\n *\n * <p>In ICU, a Unicode string consists of 16-bit Unicode <em>code units</em>.\n * A Unicode character may be stored with either one code unit\n * (the most common case) or with a matched pair of special code units\n * (\"surrogates\"). The data type for code units is UChar. \n * For single-character handling, a Unicode character code <em>point</em> is a value\n * in the range 0..0x10ffff. ICU uses the UChar32 type for code points.</p>\n *\n * <p>Indexes and offsets into and lengths of strings always count code units, not code points.\n * This is the same as with multi-byte char* strings in traditional string handling.\n * Operations on partial strings typically do not test for code point boundaries.\n * If necessary, the user needs to take care of such boundaries by testing for the code unit\n * values or by using functions like\n * UnicodeString::getChar32Start() and UnicodeString::getChar32Limit()\n * (or, in C, the equivalent macros U16_SET_CP_START() and U16_SET_CP_LIMIT(), see utf.h).</p>\n *\n * UnicodeString methods are more lenient with regard to input parameter values\n * than other ICU APIs. In particular:\n * - If indexes are out of bounds for a UnicodeString object\n *   (<0 or >length()) then they are \"pinned\" to the nearest boundary.\n * - If primitive string pointer values (e.g., const UChar * or char *)\n *   for input strings are NULL, then those input string parameters are treated\n *   as if they pointed to an empty string.\n *   However, this is <em>not</em> the case for char * parameters for charset names\n *   or other IDs.\n * - Most UnicodeString methods do not take a UErrorCode parameter because\n *   there are usually very few opportunities for failure other than a shortage\n *   of memory, error codes in low-level C++ string methods would be inconvenient,\n *   and the error code as the last parameter (ICU convention) would prevent\n *   the use of default parameter values.\n *   Instead, such methods set the UnicodeString into a \"bogus\" state\n *   (see isBogus()) if an error occurs.\n *\n * In string comparisons, two UnicodeString objects that are both \"bogus\"\n * compare equal (to be transitive and prevent endless loops in sorting),\n * and a \"bogus\" string compares less than any non-\"bogus\" one.\n *\n * Const UnicodeString methods are thread-safe. Multiple threads can use\n * const methods on the same UnicodeString object simultaneously,\n * but non-const methods must not be called concurrently (in multiple threads)\n * with any other (const or non-const) methods.\n *\n * Similarly, const UnicodeString & parameters are thread-safe.\n * One object may be passed in as such a parameter concurrently in multiple threads.\n * This includes the const UnicodeString & parameters for\n * copy construction, assignment, and cloning.\n *\n * <p>UnicodeString uses several storage methods.\n * String contents can be stored inside the UnicodeString object itself,\n * in an allocated and shared buffer, or in an outside buffer that is \"aliased\".\n * Most of this is done transparently, but careful aliasing in particular provides\n * significant performance improvements.\n * Also, the internal buffer is accessible via special functions.\n * For details see the\n * <a href=\"http://icu-project.org/userguide/strings.html\">User Guide Strings chapter</a>.</p>\n *\n * @see utf.h\n * @see CharacterIterator\n * @stable ICU 2.0\n */\nclass U_COMMON_API UnicodeString : public Replaceable\n{\npublic:\n\n  /**\n   * Constant to be used in the UnicodeString(char *, int32_t, EInvariant) constructor\n   * which constructs a Unicode string from an invariant-character char * string.\n   * Use the macro US_INV instead of the full qualification for this value.\n   *\n   * @see US_INV\n   * @stable ICU 3.2\n   */\n  enum EInvariant {\n    /**\n     * @see EInvariant\n     * @stable ICU 3.2\n     */\n    kInvariant\n  };\n\n  //========================================\n  // Read-only operations\n  //========================================\n\n  /* Comparison - bitwise only - for international comparison use collation */\n\n  /**\n   * Equality operator. Performs only bitwise comparison.\n   * @param text The UnicodeString to compare to this one.\n   * @return TRUE if <TT>text</TT> contains the same characters as this one,\n   * FALSE otherwise.\n   * @stable ICU 2.0\n   */\n  inline UBool operator== (const UnicodeString& text) const;\n\n  /**\n   * Inequality operator. Performs only bitwise comparison.\n   * @param text The UnicodeString to compare to this one.\n   * @return FALSE if <TT>text</TT> contains the same characters as this one,\n   * TRUE otherwise.\n   * @stable ICU 2.0\n   */\n  inline UBool operator!= (const UnicodeString& text) const;\n\n  /**\n   * Greater than operator. Performs only bitwise comparison.\n   * @param text The UnicodeString to compare to this one.\n   * @return TRUE if the characters in this are bitwise\n   * greater than the characters in <code>text</code>, FALSE otherwise\n   * @stable ICU 2.0\n   */\n  inline UBool operator> (const UnicodeString& text) const;\n\n  /**\n   * Less than operator. Performs only bitwise comparison.\n   * @param text The UnicodeString to compare to this one.\n   * @return TRUE if the characters in this are bitwise\n   * less than the characters in <code>text</code>, FALSE otherwise\n   * @stable ICU 2.0\n   */\n  inline UBool operator< (const UnicodeString& text) const;\n\n  /**\n   * Greater than or equal operator. Performs only bitwise comparison.\n   * @param text The UnicodeString to compare to this one.\n   * @return TRUE if the characters in this are bitwise\n   * greater than or equal to the characters in <code>text</code>, FALSE otherwise\n   * @stable ICU 2.0\n   */\n  inline UBool operator>= (const UnicodeString& text) const;\n\n  /**\n   * Less than or equal operator. Performs only bitwise comparison.\n   * @param text The UnicodeString to compare to this one.\n   * @return TRUE if the characters in this are bitwise\n   * less than or equal to the characters in <code>text</code>, FALSE otherwise\n   * @stable ICU 2.0\n   */\n  inline UBool operator<= (const UnicodeString& text) const;\n\n  /**\n   * Compare the characters bitwise in this UnicodeString to\n   * the characters in <code>text</code>.\n   * @param text The UnicodeString to compare to this one.\n   * @return The result of bitwise character comparison: 0 if this\n   * contains the same characters as <code>text</code>, -1 if the characters in\n   * this are bitwise less than the characters in <code>text</code>, +1 if the\n   * characters in this are bitwise greater than the characters\n   * in <code>text</code>.\n   * @stable ICU 2.0\n   */\n  inline int8_t compare(const UnicodeString& text) const;\n\n  /**\n   * Compare the characters bitwise in the range\n   * [<TT>start</TT>, <TT>start + length</TT>) with the characters\n   * in <TT>text</TT>\n   * @param start the offset at which the compare operation begins\n   * @param length the number of characters of text to compare.\n   * @param text the other text to be compared against this string.\n   * @return The result of bitwise character comparison: 0 if this\n   * contains the same characters as <code>text</code>, -1 if the characters in\n   * this are bitwise less than the characters in <code>text</code>, +1 if the\n   * characters in this are bitwise greater than the characters\n   * in <code>text</code>.\n   * @stable ICU 2.0\n   */\n  inline int8_t compare(int32_t start,\n         int32_t length,\n         const UnicodeString& text) const;\n\n  /**\n   * Compare the characters bitwise in the range\n   * [<TT>start</TT>, <TT>start + length</TT>) with the characters\n   * in <TT>srcText</TT> in the range\n   * [<TT>srcStart</TT>, <TT>srcStart + srcLength</TT>).\n   * @param start the offset at which the compare operation begins\n   * @param length the number of characters in this to compare.\n   * @param srcText the text to be compared\n   * @param srcStart the offset into <TT>srcText</TT> to start comparison\n   * @param srcLength the number of characters in <TT>src</TT> to compare\n   * @return The result of bitwise character comparison: 0 if this\n   * contains the same characters as <code>srcText</code>, -1 if the characters in\n   * this are bitwise less than the characters in <code>srcText</code>, +1 if the\n   * characters in this are bitwise greater than the characters\n   * in <code>srcText</code>.\n   * @stable ICU 2.0\n   */\n   inline int8_t compare(int32_t start,\n         int32_t length,\n         const UnicodeString& srcText,\n         int32_t srcStart,\n         int32_t srcLength) const;\n\n  /**\n   * Compare the characters bitwise in this UnicodeString with the first\n   * <TT>srcLength</TT> characters in <TT>srcChars</TT>.\n   * @param srcChars The characters to compare to this UnicodeString.\n   * @param srcLength the number of characters in <TT>srcChars</TT> to compare\n   * @return The result of bitwise character comparison: 0 if this\n   * contains the same characters as <code>srcChars</code>, -1 if the characters in\n   * this are bitwise less than the characters in <code>srcChars</code>, +1 if the\n   * characters in this are bitwise greater than the characters\n   * in <code>srcChars</code>.\n   * @stable ICU 2.0\n   */\n  inline int8_t compare(const UChar *srcChars,\n         int32_t srcLength) const;\n\n  /**\n   * Compare the characters bitwise in the range\n   * [<TT>start</TT>, <TT>start + length</TT>) with the first\n   * <TT>length</TT> characters in <TT>srcChars</TT>\n   * @param start the offset at which the compare operation begins\n   * @param length the number of characters to compare.\n   * @param srcChars the characters to be compared\n   * @return The result of bitwise character comparison: 0 if this\n   * contains the same characters as <code>srcChars</code>, -1 if the characters in\n   * this are bitwise less than the characters in <code>srcChars</code>, +1 if the\n   * characters in this are bitwise greater than the characters\n   * in <code>srcChars</code>.\n   * @stable ICU 2.0\n   */\n  inline int8_t compare(int32_t start,\n         int32_t length,\n         const UChar *srcChars) const;\n\n  /**\n   * Compare the characters bitwise in the range\n   * [<TT>start</TT>, <TT>start + length</TT>) with the characters\n   * in <TT>srcChars</TT> in the range\n   * [<TT>srcStart</TT>, <TT>srcStart + srcLength</TT>).\n   * @param start the offset at which the compare operation begins\n   * @param length the number of characters in this to compare\n   * @param srcChars the characters to be compared\n   * @param srcStart the offset into <TT>srcChars</TT> to start comparison\n   * @param srcLength the number of characters in <TT>srcChars</TT> to compare\n   * @return The result of bitwise character comparison: 0 if this\n   * contains the same characters as <code>srcChars</code>, -1 if the characters in\n   * this are bitwise less than the characters in <code>srcChars</code>, +1 if the\n   * characters in this are bitwise greater than the characters\n   * in <code>srcChars</code>.\n   * @stable ICU 2.0\n   */\n  inline int8_t compare(int32_t start,\n         int32_t length,\n         const UChar *srcChars,\n         int32_t srcStart,\n         int32_t srcLength) const;\n\n  /**\n   * Compare the characters bitwise in the range\n   * [<TT>start</TT>, <TT>limit</TT>) with the characters\n   * in <TT>srcText</TT> in the range\n   * [<TT>srcStart</TT>, <TT>srcLimit</TT>).\n   * @param start the offset at which the compare operation begins\n   * @param limit the offset immediately following the compare operation\n   * @param srcText the text to be compared\n   * @param srcStart the offset into <TT>srcText</TT> to start comparison\n   * @param srcLimit the offset into <TT>srcText</TT> to limit comparison\n   * @return The result of bitwise character comparison: 0 if this\n   * contains the same characters as <code>srcText</code>, -1 if the characters in\n   * this are bitwise less than the characters in <code>srcText</code>, +1 if the\n   * characters in this are bitwise greater than the characters\n   * in <code>srcText</code>.\n   * @stable ICU 2.0\n   */\n  inline int8_t compareBetween(int32_t start,\n            int32_t limit,\n            const UnicodeString& srcText,\n            int32_t srcStart,\n            int32_t srcLimit) const;\n\n  /**\n   * Compare two Unicode strings in code point order.\n   * The result may be different from the results of compare(), operator<, etc.\n   * if supplementary characters are present:\n   *\n   * In UTF-16, supplementary characters (with code points U+10000 and above) are\n   * stored with pairs of surrogate code units. These have values from 0xd800 to 0xdfff,\n   * which means that they compare as less than some other BMP characters like U+feff.\n   * This function compares Unicode strings in code point order.\n   * If either of the UTF-16 strings is malformed (i.e., it contains unpaired surrogates), then the result is not defined.\n   *\n   * @param text Another string to compare this one to.\n   * @return a negative/zero/positive integer corresponding to whether\n   * this string is less than/equal to/greater than the second one\n   * in code point order\n   * @stable ICU 2.0\n   */\n  inline int8_t compareCodePointOrder(const UnicodeString& text) const;\n\n  /**\n   * Compare two Unicode strings in code point order.\n   * The result may be different from the results of compare(), operator<, etc.\n   * if supplementary characters are present:\n   *\n   * In UTF-16, supplementary characters (with code points U+10000 and above) are\n   * stored with pairs of surrogate code units. These have values from 0xd800 to 0xdfff,\n   * which means that they compare as less than some other BMP characters like U+feff.\n   * This function compares Unicode strings in code point order.\n   * If either of the UTF-16 strings is malformed (i.e., it contains unpaired surrogates), then the result is not defined.\n   *\n   * @param start The start offset in this string at which the compare operation begins.\n   * @param length The number of code units from this string to compare.\n   * @param srcText Another string to compare this one to.\n   * @return a negative/zero/positive integer corresponding to whether\n   * this string is less than/equal to/greater than the second one\n   * in code point order\n   * @stable ICU 2.0\n   */\n  inline int8_t compareCodePointOrder(int32_t start,\n                                      int32_t length,\n                                      const UnicodeString& srcText) const;\n\n  /**\n   * Compare two Unicode strings in code point order.\n   * The result may be different from the results of compare(), operator<, etc.\n   * if supplementary characters are present:\n   *\n   * In UTF-16, supplementary characters (with code points U+10000 and above) are\n   * stored with pairs of surrogate code units. These have values from 0xd800 to 0xdfff,\n   * which means that they compare as less than some other BMP characters like U+feff.\n   * This function compares Unicode strings in code point order.\n   * If either of the UTF-16 strings is malformed (i.e., it contains unpaired surrogates), then the result is not defined.\n   *\n   * @param start The start offset in this string at which the compare operation begins.\n   * @param length The number of code units from this string to compare.\n   * @param srcText Another string to compare this one to.\n   * @param srcStart The start offset in that string at which the compare operation begins.\n   * @param srcLength The number of code units from that string to compare.\n   * @return a negative/zero/positive integer corresponding to whether\n   * this string is less than/equal to/greater than the second one\n   * in code point order\n   * @stable ICU 2.0\n   */\n   inline int8_t compareCodePointOrder(int32_t start,\n                                       int32_t length,\n                                       const UnicodeString& srcText,\n                                       int32_t srcStart,\n                                       int32_t srcLength) const;\n\n  /**\n   * Compare two Unicode strings in code point order.\n   * The result may be different from the results of compare(), operator<, etc.\n   * if supplementary characters are present:\n   *\n   * In UTF-16, supplementary characters (with code points U+10000 and above) are\n   * stored with pairs of surrogate code units. These have values from 0xd800 to 0xdfff,\n   * which means that they compare as less than some other BMP characters like U+feff.\n   * This function compares Unicode strings in code point order.\n   * If either of the UTF-16 strings is malformed (i.e., it contains unpaired surrogates), then the result is not defined.\n   *\n   * @param srcChars A pointer to another string to compare this one to.\n   * @param srcLength The number of code units from that string to compare.\n   * @return a negative/zero/positive integer corresponding to whether\n   * this string is less than/equal to/greater than the second one\n   * in code point order\n   * @stable ICU 2.0\n   */\n  inline int8_t compareCodePointOrder(const UChar *srcChars,\n                                      int32_t srcLength) const;\n\n  /**\n   * Compare two Unicode strings in code point order.\n   * The result may be different from the results of compare(), operator<, etc.\n   * if supplementary characters are present:\n   *\n   * In UTF-16, supplementary characters (with code points U+10000 and above) are\n   * stored with pairs of surrogate code units. These have values from 0xd800 to 0xdfff,\n   * which means that they compare as less than some other BMP characters like U+feff.\n   * This function compares Unicode strings in code point order.\n   * If either of the UTF-16 strings is malformed (i.e., it contains unpaired surrogates), then the result is not defined.\n   *\n   * @param start The start offset in this string at which the compare operation begins.\n   * @param length The number of code units from this string to compare.\n   * @param srcChars A pointer to another string to compare this one to.\n   * @return a negative/zero/positive integer corresponding to whether\n   * this string is less than/equal to/greater than the second one\n   * in code point order\n   * @stable ICU 2.0\n   */\n  inline int8_t compareCodePointOrder(int32_t start,\n                                      int32_t length,\n                                      const UChar *srcChars) const;\n\n  /**\n   * Compare two Unicode strings in code point order.\n   * The result may be different from the results of compare(), operator<, etc.\n   * if supplementary characters are present:\n   *\n   * In UTF-16, supplementary characters (with code points U+10000 and above) are\n   * stored with pairs of surrogate code units. These have values from 0xd800 to 0xdfff,\n   * which means that they compare as less than some other BMP characters like U+feff.\n   * This function compares Unicode strings in code point order.\n   * If either of the UTF-16 strings is malformed (i.e., it contains unpaired surrogates), then the result is not defined.\n   *\n   * @param start The start offset in this string at which the compare operation begins.\n   * @param length The number of code units from this string to compare.\n   * @param srcChars A pointer to another string to compare this one to.\n   * @param srcStart The start offset in that string at which the compare operation begins.\n   * @param srcLength The number of code units from that string to compare.\n   * @return a negative/zero/positive integer corresponding to whether\n   * this string is less than/equal to/greater than the second one\n   * in code point order\n   * @stable ICU 2.0\n   */\n  inline int8_t compareCodePointOrder(int32_t start,\n                                      int32_t length,\n                                      const UChar *srcChars,\n                                      int32_t srcStart,\n                                      int32_t srcLength) const;\n\n  /**\n   * Compare two Unicode strings in code point order.\n   * The result may be different from the results of compare(), operator<, etc.\n   * if supplementary characters are present:\n   *\n   * In UTF-16, supplementary characters (with code points U+10000 and above) are\n   * stored with pairs of surrogate code units. These have values from 0xd800 to 0xdfff,\n   * which means that they compare as less than some other BMP characters like U+feff.\n   * This function compares Unicode strings in code point order.\n   * If either of the UTF-16 strings is malformed (i.e., it contains unpaired surrogates), then the result is not defined.\n   *\n   * @param start The start offset in this string at which the compare operation begins.\n   * @param limit The offset after the last code unit from this string to compare.\n   * @param srcText Another string to compare this one to.\n   * @param srcStart The start offset in that string at which the compare operation begins.\n   * @param srcLimit The offset after the last code unit from that string to compare.\n   * @return a negative/zero/positive integer corresponding to whether\n   * this string is less than/equal to/greater than the second one\n   * in code point order\n   * @stable ICU 2.0\n   */\n  inline int8_t compareCodePointOrderBetween(int32_t start,\n                                             int32_t limit,\n                                             const UnicodeString& srcText,\n                                             int32_t srcStart,\n                                             int32_t srcLimit) const;\n\n  /**\n   * Compare two strings case-insensitively using full case folding.\n   * This is equivalent to this->foldCase(options).compare(text.foldCase(options)).\n   *\n   * @param text Another string to compare this one to.\n   * @param options A bit set of options:\n   *   - U_FOLD_CASE_DEFAULT or 0 is used for default options:\n   *     Comparison in code unit order with default case folding.\n   *\n   *   - U_COMPARE_CODE_POINT_ORDER\n   *     Set to choose code point order instead of code unit order\n   *     (see u_strCompare for details).\n   *\n   *   - U_FOLD_CASE_EXCLUDE_SPECIAL_I\n   *\n   * @return A negative, zero, or positive integer indicating the comparison result.\n   * @stable ICU 2.0\n   */\n  inline int8_t caseCompare(const UnicodeString& text, uint32_t options) const;\n\n  /**\n   * Compare two strings case-insensitively using full case folding.\n   * This is equivalent to this->foldCase(options).compare(srcText.foldCase(options)).\n   *\n   * @param start The start offset in this string at which the compare operation begins.\n   * @param length The number of code units from this string to compare.\n   * @param srcText Another string to compare this one to.\n   * @param options A bit set of options:\n   *   - U_FOLD_CASE_DEFAULT or 0 is used for default options:\n   *     Comparison in code unit order with default case folding.\n   *\n   *   - U_COMPARE_CODE_POINT_ORDER\n   *     Set to choose code point order instead of code unit order\n   *     (see u_strCompare for details).\n   *\n   *   - U_FOLD_CASE_EXCLUDE_SPECIAL_I\n   *\n   * @return A negative, zero, or positive integer indicating the comparison result.\n   * @stable ICU 2.0\n   */\n  inline int8_t caseCompare(int32_t start,\n         int32_t length,\n         const UnicodeString& srcText,\n         uint32_t options) const;\n\n  /**\n   * Compare two strings case-insensitively using full case folding.\n   * This is equivalent to this->foldCase(options).compare(srcText.foldCase(options)).\n   *\n   * @param start The start offset in this string at which the compare operation begins.\n   * @param length The number of code units from this string to compare.\n   * @param srcText Another string to compare this one to.\n   * @param srcStart The start offset in that string at which the compare operation begins.\n   * @param srcLength The number of code units from that string to compare.\n   * @param options A bit set of options:\n   *   - U_FOLD_CASE_DEFAULT or 0 is used for default options:\n   *     Comparison in code unit order with default case folding.\n   *\n   *   - U_COMPARE_CODE_POINT_ORDER\n   *     Set to choose code point order instead of code unit order\n   *     (see u_strCompare for details).\n   *\n   *   - U_FOLD_CASE_EXCLUDE_SPECIAL_I\n   *\n   * @return A negative, zero, or positive integer indicating the comparison result.\n   * @stable ICU 2.0\n   */\n  inline int8_t caseCompare(int32_t start,\n         int32_t length,\n         const UnicodeString& srcText,\n         int32_t srcStart,\n         int32_t srcLength,\n         uint32_t options) const;\n\n  /**\n   * Compare two strings case-insensitively using full case folding.\n   * This is equivalent to this->foldCase(options).compare(srcChars.foldCase(options)).\n   *\n   * @param srcChars A pointer to another string to compare this one to.\n   * @param srcLength The number of code units from that string to compare.\n   * @param options A bit set of options:\n   *   - U_FOLD_CASE_DEFAULT or 0 is used for default options:\n   *     Comparison in code unit order with default case folding.\n   *\n   *   - U_COMPARE_CODE_POINT_ORDER\n   *     Set to choose code point order instead of code unit order\n   *     (see u_strCompare for details).\n   *\n   *   - U_FOLD_CASE_EXCLUDE_SPECIAL_I\n   *\n   * @return A negative, zero, or positive integer indicating the comparison result.\n   * @stable ICU 2.0\n   */\n  inline int8_t caseCompare(const UChar *srcChars,\n         int32_t srcLength,\n         uint32_t options) const;\n\n  /**\n   * Compare two strings case-insensitively using full case folding.\n   * This is equivalent to this->foldCase(options).compare(srcChars.foldCase(options)).\n   *\n   * @param start The start offset in this string at which the compare operation begins.\n   * @param length The number of code units from this string to compare.\n   * @param srcChars A pointer to another string to compare this one to.\n   * @param options A bit set of options:\n   *   - U_FOLD_CASE_DEFAULT or 0 is used for default options:\n   *     Comparison in code unit order with default case folding.\n   *\n   *   - U_COMPARE_CODE_POINT_ORDER\n   *     Set to choose code point order instead of code unit order\n   *     (see u_strCompare for details).\n   *\n   *   - U_FOLD_CASE_EXCLUDE_SPECIAL_I\n   *\n   * @return A negative, zero, or positive integer indicating the comparison result.\n   * @stable ICU 2.0\n   */\n  inline int8_t caseCompare(int32_t start,\n         int32_t length,\n         const UChar *srcChars,\n         uint32_t options) const;\n\n  /**\n   * Compare two strings case-insensitively using full case folding.\n   * This is equivalent to this->foldCase(options).compare(srcChars.foldCase(options)).\n   *\n   * @param start The start offset in this string at which the compare operation begins.\n   * @param length The number of code units from this string to compare.\n   * @param srcChars A pointer to another string to compare this one to.\n   * @param srcStart The start offset in that string at which the compare operation begins.\n   * @param srcLength The number of code units from that string to compare.\n   * @param options A bit set of options:\n   *   - U_FOLD_CASE_DEFAULT or 0 is used for default options:\n   *     Comparison in code unit order with default case folding.\n   *\n   *   - U_COMPARE_CODE_POINT_ORDER\n   *     Set to choose code point order instead of code unit order\n   *     (see u_strCompare for details).\n   *\n   *   - U_FOLD_CASE_EXCLUDE_SPECIAL_I\n   *\n   * @return A negative, zero, or positive integer indicating the comparison result.\n   * @stable ICU 2.0\n   */\n  inline int8_t caseCompare(int32_t start,\n         int32_t length,\n         const UChar *srcChars,\n         int32_t srcStart,\n         int32_t srcLength,\n         uint32_t options) const;\n\n  /**\n   * Compare two strings case-insensitively using full case folding.\n   * This is equivalent to this->foldCase(options).compareBetween(text.foldCase(options)).\n   *\n   * @param start The start offset in this string at which the compare operation begins.\n   * @param limit The offset after the last code unit from this string to compare.\n   * @param srcText Another string to compare this one to.\n   * @param srcStart The start offset in that string at which the compare operation begins.\n   * @param srcLimit The offset after the last code unit from that string to compare.\n   * @param options A bit set of options:\n   *   - U_FOLD_CASE_DEFAULT or 0 is used for default options:\n   *     Comparison in code unit order with default case folding.\n   *\n   *   - U_COMPARE_CODE_POINT_ORDER\n   *     Set to choose code point order instead of code unit order\n   *     (see u_strCompare for details).\n   *\n   *   - U_FOLD_CASE_EXCLUDE_SPECIAL_I\n   *\n   * @return A negative, zero, or positive integer indicating the comparison result.\n   * @stable ICU 2.0\n   */\n  inline int8_t caseCompareBetween(int32_t start,\n            int32_t limit,\n            const UnicodeString& srcText,\n            int32_t srcStart,\n            int32_t srcLimit,\n            uint32_t options) const;\n\n  /**\n   * Determine if this starts with the characters in <TT>text</TT>\n   * @param text The text to match.\n   * @return TRUE if this starts with the characters in <TT>text</TT>,\n   * FALSE otherwise\n   * @stable ICU 2.0\n   */\n  inline UBool startsWith(const UnicodeString& text) const;\n\n  /**\n   * Determine if this starts with the characters in <TT>srcText</TT>\n   * in the range [<TT>srcStart</TT>, <TT>srcStart + srcLength</TT>).\n   * @param srcText The text to match.\n   * @param srcStart the offset into <TT>srcText</TT> to start matching\n   * @param srcLength the number of characters in <TT>srcText</TT> to match\n   * @return TRUE if this starts with the characters in <TT>text</TT>,\n   * FALSE otherwise\n   * @stable ICU 2.0\n   */\n  inline UBool startsWith(const UnicodeString& srcText,\n            int32_t srcStart,\n            int32_t srcLength) const;\n\n  /**\n   * Determine if this starts with the characters in <TT>srcChars</TT>\n   * @param srcChars The characters to match.\n   * @param srcLength the number of characters in <TT>srcChars</TT>\n   * @return TRUE if this starts with the characters in <TT>srcChars</TT>,\n   * FALSE otherwise\n   * @stable ICU 2.0\n   */\n  inline UBool startsWith(const UChar *srcChars,\n            int32_t srcLength) const;\n\n  /**\n   * Determine if this ends with the characters in <TT>srcChars</TT>\n   * in the range  [<TT>srcStart</TT>, <TT>srcStart + srcLength</TT>).\n   * @param srcChars The characters to match.\n   * @param srcStart the offset into <TT>srcText</TT> to start matching\n   * @param srcLength the number of characters in <TT>srcChars</TT> to match\n   * @return TRUE if this ends with the characters in <TT>srcChars</TT>, FALSE otherwise\n   * @stable ICU 2.0\n   */\n  inline UBool startsWith(const UChar *srcChars,\n            int32_t srcStart,\n            int32_t srcLength) const;\n\n  /**\n   * Determine if this ends with the characters in <TT>text</TT>\n   * @param text The text to match.\n   * @return TRUE if this ends with the characters in <TT>text</TT>,\n   * FALSE otherwise\n   * @stable ICU 2.0\n   */\n  inline UBool endsWith(const UnicodeString& text) const;\n\n  /**\n   * Determine if this ends with the characters in <TT>srcText</TT>\n   * in the range [<TT>srcStart</TT>, <TT>srcStart + srcLength</TT>).\n   * @param srcText The text to match.\n   * @param srcStart the offset into <TT>srcText</TT> to start matching\n   * @param srcLength the number of characters in <TT>srcText</TT> to match\n   * @return TRUE if this ends with the characters in <TT>text</TT>,\n   * FALSE otherwise\n   * @stable ICU 2.0\n   */\n  inline UBool endsWith(const UnicodeString& srcText,\n          int32_t srcStart,\n          int32_t srcLength) const;\n\n  /**\n   * Determine if this ends with the characters in <TT>srcChars</TT>\n   * @param srcChars The characters to match.\n   * @param srcLength the number of characters in <TT>srcChars</TT>\n   * @return TRUE if this ends with the characters in <TT>srcChars</TT>,\n   * FALSE otherwise\n   * @stable ICU 2.0\n   */\n  inline UBool endsWith(const UChar *srcChars,\n          int32_t srcLength) const;\n\n  /**\n   * Determine if this ends with the characters in <TT>srcChars</TT>\n   * in the range  [<TT>srcStart</TT>, <TT>srcStart + srcLength</TT>).\n   * @param srcChars The characters to match.\n   * @param srcStart the offset into <TT>srcText</TT> to start matching\n   * @param srcLength the number of characters in <TT>srcChars</TT> to match\n   * @return TRUE if this ends with the characters in <TT>srcChars</TT>,\n   * FALSE otherwise\n   * @stable ICU 2.0\n   */\n  inline UBool endsWith(const UChar *srcChars,\n          int32_t srcStart,\n          int32_t srcLength) const;\n\n\n  /* Searching - bitwise only */\n\n  /**\n   * Locate in this the first occurrence of the characters in <TT>text</TT>,\n   * using bitwise comparison.\n   * @param text The text to search for.\n   * @return The offset into this of the start of <TT>text</TT>,\n   * or -1 if not found.\n   * @stable ICU 2.0\n   */\n  inline int32_t indexOf(const UnicodeString& text) const;\n\n  /**\n   * Locate in this the first occurrence of the characters in <TT>text</TT>\n   * starting at offset <TT>start</TT>, using bitwise comparison.\n   * @param text The text to search for.\n   * @param start The offset at which searching will start.\n   * @return The offset into this of the start of <TT>text</TT>,\n   * or -1 if not found.\n   * @stable ICU 2.0\n   */\n  inline int32_t indexOf(const UnicodeString& text,\n              int32_t start) const;\n\n  /**\n   * Locate in this the first occurrence in the range\n   * [<TT>start</TT>, <TT>start + length</TT>) of the characters\n   * in <TT>text</TT>, using bitwise comparison.\n   * @param text The text to search for.\n   * @param start The offset at which searching will start.\n   * @param length The number of characters to search\n   * @return The offset into this of the start of <TT>text</TT>,\n   * or -1 if not found.\n   * @stable ICU 2.0\n   */\n  inline int32_t indexOf(const UnicodeString& text,\n              int32_t start,\n              int32_t length) const;\n\n  /**\n   * Locate in this the first occurrence in the range\n   * [<TT>start</TT>, <TT>start + length</TT>) of the characters\n   *  in <TT>srcText</TT> in the range\n   * [<TT>srcStart</TT>, <TT>srcStart + srcLength</TT>),\n   * using bitwise comparison.\n   * @param srcText The text to search for.\n   * @param srcStart the offset into <TT>srcText</TT> at which\n   * to start matching\n   * @param srcLength the number of characters in <TT>srcText</TT> to match\n   * @param start the offset into this at which to start matching\n   * @param length the number of characters in this to search\n   * @return The offset into this of the start of <TT>text</TT>,\n   * or -1 if not found.\n   * @stable ICU 2.0\n   */\n  inline int32_t indexOf(const UnicodeString& srcText,\n              int32_t srcStart,\n              int32_t srcLength,\n              int32_t start,\n              int32_t length) const;\n\n  /**\n   * Locate in this the first occurrence of the characters in\n   * <TT>srcChars</TT>\n   * starting at offset <TT>start</TT>, using bitwise comparison.\n   * @param srcChars The text to search for.\n   * @param srcLength the number of characters in <TT>srcChars</TT> to match\n   * @param start the offset into this at which to start matching\n   * @return The offset into this of the start of <TT>text</TT>,\n   * or -1 if not found.\n   * @stable ICU 2.0\n   */\n  inline int32_t indexOf(const UChar *srcChars,\n              int32_t srcLength,\n              int32_t start) const;\n\n  /**\n   * Locate in this the first occurrence in the range\n   * [<TT>start</TT>, <TT>start + length</TT>) of the characters\n   * in <TT>srcChars</TT>, using bitwise comparison.\n   * @param srcChars The text to search for.\n   * @param srcLength the number of characters in <TT>srcChars</TT>\n   * @param start The offset at which searching will start.\n   * @param length The number of characters to search\n   * @return The offset into this of the start of <TT>srcChars</TT>,\n   * or -1 if not found.\n   * @stable ICU 2.0\n   */\n  inline int32_t indexOf(const UChar *srcChars,\n              int32_t srcLength,\n              int32_t start,\n              int32_t length) const;\n\n  /**\n   * Locate in this the first occurrence in the range\n   * [<TT>start</TT>, <TT>start + length</TT>) of the characters\n   * in <TT>srcChars</TT> in the range\n   * [<TT>srcStart</TT>, <TT>srcStart + srcLength</TT>),\n   * using bitwise comparison.\n   * @param srcChars The text to search for.\n   * @param srcStart the offset into <TT>srcChars</TT> at which\n   * to start matching\n   * @param srcLength the number of characters in <TT>srcChars</TT> to match\n   * @param start the offset into this at which to start matching\n   * @param length the number of characters in this to search\n   * @return The offset into this of the start of <TT>text</TT>,\n   * or -1 if not found.\n   * @stable ICU 2.0\n   */\n  int32_t indexOf(const UChar *srcChars,\n              int32_t srcStart,\n              int32_t srcLength,\n              int32_t start,\n              int32_t length) const;\n\n  /**\n   * Locate in this the first occurrence of the BMP code point <code>c</code>,\n   * using bitwise comparison.\n   * @param c The code unit to search for.\n   * @return The offset into this of <TT>c</TT>, or -1 if not found.\n   * @stable ICU 2.0\n   */\n  inline int32_t indexOf(UChar c) const;\n\n  /**\n   * Locate in this the first occurrence of the code point <TT>c</TT>,\n   * using bitwise comparison.\n   *\n   * @param c The code point to search for.\n   * @return The offset into this of <TT>c</TT>, or -1 if not found.\n   * @stable ICU 2.0\n   */\n  inline int32_t indexOf(UChar32 c) const;\n\n  /**\n   * Locate in this the first occurrence of the BMP code point <code>c</code>,\n   * starting at offset <TT>start</TT>, using bitwise comparison.\n   * @param c The code unit to search for.\n   * @param start The offset at which searching will start.\n   * @return The offset into this of <TT>c</TT>, or -1 if not found.\n   * @stable ICU 2.0\n   */\n  inline int32_t indexOf(UChar c,\n              int32_t start) const;\n\n  /**\n   * Locate in this the first occurrence of the code point <TT>c</TT>\n   * starting at offset <TT>start</TT>, using bitwise comparison.\n   *\n   * @param c The code point to search for.\n   * @param start The offset at which searching will start.\n   * @return The offset into this of <TT>c</TT>, or -1 if not found.\n   * @stable ICU 2.0\n   */\n  inline int32_t indexOf(UChar32 c,\n              int32_t start) const;\n\n  /**\n   * Locate in this the first occurrence of the BMP code point <code>c</code>\n   * in the range [<TT>start</TT>, <TT>start + length</TT>),\n   * using bitwise comparison.\n   * @param c The code unit to search for.\n   * @param start the offset into this at which to start matching\n   * @param length the number of characters in this to search\n   * @return The offset into this of <TT>c</TT>, or -1 if not found.\n   * @stable ICU 2.0\n   */\n  inline int32_t indexOf(UChar c,\n              int32_t start,\n              int32_t length) const;\n\n  /**\n   * Locate in this the first occurrence of the code point <TT>c</TT>\n   * in the range [<TT>start</TT>, <TT>start + length</TT>),\n   * using bitwise comparison.\n   *\n   * @param c The code point to search for.\n   * @param start the offset into this at which to start matching\n   * @param length the number of characters in this to search\n   * @return The offset into this of <TT>c</TT>, or -1 if not found.\n   * @stable ICU 2.0\n   */\n  inline int32_t indexOf(UChar32 c,\n              int32_t start,\n              int32_t length) const;\n\n  /**\n   * Locate in this the last occurrence of the characters in <TT>text</TT>,\n   * using bitwise comparison.\n   * @param text The text to search for.\n   * @return The offset into this of the start of <TT>text</TT>,\n   * or -1 if not found.\n   * @stable ICU 2.0\n   */\n  inline int32_t lastIndexOf(const UnicodeString& text) const;\n\n  /**\n   * Locate in this the last occurrence of the characters in <TT>text</TT>\n   * starting at offset <TT>start</TT>, using bitwise comparison.\n   * @param text The text to search for.\n   * @param start The offset at which searching will start.\n   * @return The offset into this of the start of <TT>text</TT>,\n   * or -1 if not found.\n   * @stable ICU 2.0\n   */\n  inline int32_t lastIndexOf(const UnicodeString& text,\n              int32_t start) const;\n\n  /**\n   * Locate in this the last occurrence in the range\n   * [<TT>start</TT>, <TT>start + length</TT>) of the characters\n   * in <TT>text</TT>, using bitwise comparison.\n   * @param text The text to search for.\n   * @param start The offset at which searching will start.\n   * @param length The number of characters to search\n   * @return The offset into this of the start of <TT>text</TT>,\n   * or -1 if not found.\n   * @stable ICU 2.0\n   */\n  inline int32_t lastIndexOf(const UnicodeString& text,\n              int32_t start,\n              int32_t length) const;\n\n  /**\n   * Locate in this the last occurrence in the range\n   * [<TT>start</TT>, <TT>start + length</TT>) of the characters\n   * in <TT>srcText</TT> in the range\n   * [<TT>srcStart</TT>, <TT>srcStart + srcLength</TT>),\n   * using bitwise comparison.\n   * @param srcText The text to search for.\n   * @param srcStart the offset into <TT>srcText</TT> at which\n   * to start matching\n   * @param srcLength the number of characters in <TT>srcText</TT> to match\n   * @param start the offset into this at which to start matching\n   * @param length the number of characters in this to search\n   * @return The offset into this of the start of <TT>text</TT>,\n   * or -1 if not found.\n   * @stable ICU 2.0\n   */\n  inline int32_t lastIndexOf(const UnicodeString& srcText,\n              int32_t srcStart,\n              int32_t srcLength,\n              int32_t start,\n              int32_t length) const;\n\n  /**\n   * Locate in this the last occurrence of the characters in <TT>srcChars</TT>\n   * starting at offset <TT>start</TT>, using bitwise comparison.\n   * @param srcChars The text to search for.\n   * @param srcLength the number of characters in <TT>srcChars</TT> to match\n   * @param start the offset into this at which to start matching\n   * @return The offset into this of the start of <TT>text</TT>,\n   * or -1 if not found.\n   * @stable ICU 2.0\n   */\n  inline int32_t lastIndexOf(const UChar *srcChars,\n              int32_t srcLength,\n              int32_t start) const;\n\n  /**\n   * Locate in this the last occurrence in the range\n   * [<TT>start</TT>, <TT>start + length</TT>) of the characters\n   * in <TT>srcChars</TT>, using bitwise comparison.\n   * @param srcChars The text to search for.\n   * @param srcLength the number of characters in <TT>srcChars</TT>\n   * @param start The offset at which searching will start.\n   * @param length The number of characters to search\n   * @return The offset into this of the start of <TT>srcChars</TT>,\n   * or -1 if not found.\n   * @stable ICU 2.0\n   */\n  inline int32_t lastIndexOf(const UChar *srcChars,\n              int32_t srcLength,\n              int32_t start,\n              int32_t length) const;\n\n  /**\n   * Locate in this the last occurrence in the range\n   * [<TT>start</TT>, <TT>start + length</TT>) of the characters\n   * in <TT>srcChars</TT> in the range\n   * [<TT>srcStart</TT>, <TT>srcStart + srcLength</TT>),\n   * using bitwise comparison.\n   * @param srcChars The text to search for.\n   * @param srcStart the offset into <TT>srcChars</TT> at which\n   * to start matching\n   * @param srcLength the number of characters in <TT>srcChars</TT> to match\n   * @param start the offset into this at which to start matching\n   * @param length the number of characters in this to search\n   * @return The offset into this of the start of <TT>text</TT>,\n   * or -1 if not found.\n   * @stable ICU 2.0\n   */\n  int32_t lastIndexOf(const UChar *srcChars,\n              int32_t srcStart,\n              int32_t srcLength,\n              int32_t start,\n              int32_t length) const;\n\n  /**\n   * Locate in this the last occurrence of the BMP code point <code>c</code>,\n   * using bitwise comparison.\n   * @param c The code unit to search for.\n   * @return The offset into this of <TT>c</TT>, or -1 if not found.\n   * @stable ICU 2.0\n   */\n  inline int32_t lastIndexOf(UChar c) const;\n\n  /**\n   * Locate in this the last occurrence of the code point <TT>c</TT>,\n   * using bitwise comparison.\n   *\n   * @param c The code point to search for.\n   * @return The offset into this of <TT>c</TT>, or -1 if not found.\n   * @stable ICU 2.0\n   */\n  inline int32_t lastIndexOf(UChar32 c) const;\n\n  /**\n   * Locate in this the last occurrence of the BMP code point <code>c</code>\n   * starting at offset <TT>start</TT>, using bitwise comparison.\n   * @param c The code unit to search for.\n   * @param start The offset at which searching will start.\n   * @return The offset into this of <TT>c</TT>, or -1 if not found.\n   * @stable ICU 2.0\n   */\n  inline int32_t lastIndexOf(UChar c,\n              int32_t start) const;\n\n  /**\n   * Locate in this the last occurrence of the code point <TT>c</TT>\n   * starting at offset <TT>start</TT>, using bitwise comparison.\n   *\n   * @param c The code point to search for.\n   * @param start The offset at which searching will start.\n   * @return The offset into this of <TT>c</TT>, or -1 if not found.\n   * @stable ICU 2.0\n   */\n  inline int32_t lastIndexOf(UChar32 c,\n              int32_t start) const;\n\n  /**\n   * Locate in this the last occurrence of the BMP code point <code>c</code>\n   * in the range [<TT>start</TT>, <TT>start + length</TT>),\n   * using bitwise comparison.\n   * @param c The code unit to search for.\n   * @param start the offset into this at which to start matching\n   * @param length the number of characters in this to search\n   * @return The offset into this of <TT>c</TT>, or -1 if not found.\n   * @stable ICU 2.0\n   */\n  inline int32_t lastIndexOf(UChar c,\n              int32_t start,\n              int32_t length) const;\n\n  /**\n   * Locate in this the last occurrence of the code point <TT>c</TT>\n   * in the range [<TT>start</TT>, <TT>start + length</TT>),\n   * using bitwise comparison.\n   *\n   * @param c The code point to search for.\n   * @param start the offset into this at which to start matching\n   * @param length the number of characters in this to search\n   * @return The offset into this of <TT>c</TT>, or -1 if not found.\n   * @stable ICU 2.0\n   */\n  inline int32_t lastIndexOf(UChar32 c,\n              int32_t start,\n              int32_t length) const;\n\n\n  /* Character access */\n\n  /**\n   * Return the code unit at offset <tt>offset</tt>.\n   * If the offset is not valid (0..length()-1) then U+ffff is returned.\n   * @param offset a valid offset into the text\n   * @return the code unit at offset <tt>offset</tt>\n   *         or 0xffff if the offset is not valid for this string\n   * @stable ICU 2.0\n   */\n  inline UChar charAt(int32_t offset) const;\n\n  /**\n   * Return the code unit at offset <tt>offset</tt>.\n   * If the offset is not valid (0..length()-1) then U+ffff is returned.\n   * @param offset a valid offset into the text\n   * @return the code unit at offset <tt>offset</tt>\n   * @stable ICU 2.0\n   */\n  inline UChar operator[] (int32_t offset) const;\n\n  /**\n   * Return the code point that contains the code unit\n   * at offset <tt>offset</tt>.\n   * If the offset is not valid (0..length()-1) then U+ffff is returned.\n   * @param offset a valid offset into the text\n   * that indicates the text offset of any of the code units\n   * that will be assembled into a code point (21-bit value) and returned\n   * @return the code point of text at <tt>offset</tt>\n   *         or 0xffff if the offset is not valid for this string\n   * @stable ICU 2.0\n   */\n  UChar32 char32At(int32_t offset) const;\n\n  /**\n   * Adjust a random-access offset so that\n   * it points to the beginning of a Unicode character.\n   * The offset that is passed in points to\n   * any code unit of a code point,\n   * while the returned offset will point to the first code unit\n   * of the same code point.\n   * In UTF-16, if the input offset points to a second surrogate\n   * of a surrogate pair, then the returned offset will point\n   * to the first surrogate.\n   * @param offset a valid offset into one code point of the text\n   * @return offset of the first code unit of the same code point\n   * @see U16_SET_CP_START\n   * @stable ICU 2.0\n   */\n  int32_t getChar32Start(int32_t offset) const;\n\n  /**\n   * Adjust a random-access offset so that\n   * it points behind a Unicode character.\n   * The offset that is passed in points behind\n   * any code unit of a code point,\n   * while the returned offset will point behind the last code unit\n   * of the same code point.\n   * In UTF-16, if the input offset points behind the first surrogate\n   * (i.e., to the second surrogate)\n   * of a surrogate pair, then the returned offset will point\n   * behind the second surrogate (i.e., to the first surrogate).\n   * @param offset a valid offset after any code unit of a code point of the text\n   * @return offset of the first code unit after the same code point\n   * @see U16_SET_CP_LIMIT\n   * @stable ICU 2.0\n   */\n  int32_t getChar32Limit(int32_t offset) const;\n\n  /**\n   * Move the code unit index along the string by delta code points.\n   * Interpret the input index as a code unit-based offset into the string,\n   * move the index forward or backward by delta code points, and\n   * return the resulting index.\n   * The input index should point to the first code unit of a code point,\n   * if there is more than one.\n   *\n   * Both input and output indexes are code unit-based as for all\n   * string indexes/offsets in ICU (and other libraries, like MBCS char*).\n   * If delta<0 then the index is moved backward (toward the start of the string).\n   * If delta>0 then the index is moved forward (toward the end of the string).\n   *\n   * This behaves like CharacterIterator::move32(delta, kCurrent).\n   *\n   * Behavior for out-of-bounds indexes:\n   * <code>moveIndex32</code> pins the input index to 0..length(), i.e.,\n   * if the input index<0 then it is pinned to 0;\n   * if it is index>length() then it is pinned to length().\n   * Afterwards, the index is moved by <code>delta</code> code points\n   * forward or backward,\n   * but no further backward than to 0 and no further forward than to length().\n   * The resulting index return value will be in between 0 and length(), inclusively.\n   *\n   * Examples:\n   * <pre>\n   * // s has code points 'a' U+10000 'b' U+10ffff U+2029\n   * UnicodeString s=UNICODE_STRING(\"a\\\\U00010000b\\\\U0010ffff\\\\u2029\", 31).unescape();\n   *\n   * // initial index: position of U+10000\n   * int32_t index=1;\n   *\n   * // the following examples will all result in index==4, position of U+10ffff\n   *\n   * // skip 2 code points from some position in the string\n   * index=s.moveIndex32(index, 2); // skips U+10000 and 'b'\n   *\n   * // go to the 3rd code point from the start of s (0-based)\n   * index=s.moveIndex32(0, 3); // skips 'a', U+10000, and 'b'\n   *\n   * // go to the next-to-last code point of s\n   * index=s.moveIndex32(s.length(), -2); // backward-skips U+2029 and U+10ffff\n   * </pre>\n   *\n   * @param index input code unit index\n   * @param delta (signed) code point count to move the index forward or backward\n   *        in the string\n   * @return the resulting code unit index\n   * @stable ICU 2.0\n   */\n  int32_t moveIndex32(int32_t index, int32_t delta) const;\n\n  /* Substring extraction */\n\n  /**\n   * Copy the characters in the range\n   * [<tt>start</tt>, <tt>start + length</tt>) into the array <tt>dst</tt>,\n   * beginning at <tt>dstStart</tt>.\n   * If the string aliases to <code>dst</code> itself as an external buffer,\n   * then extract() will not copy the contents.\n   *\n   * @param start offset of first character which will be copied into the array\n   * @param length the number of characters to extract\n   * @param dst array in which to copy characters.  The length of <tt>dst</tt>\n   * must be at least (<tt>dstStart + length</tt>).\n   * @param dstStart the offset in <TT>dst</TT> where the first character\n   * will be extracted\n   * @stable ICU 2.0\n   */\n  inline void extract(int32_t start,\n           int32_t length,\n           UChar *dst,\n           int32_t dstStart = 0) const;\n\n  /**\n   * Copy the contents of the string into dest.\n   * This is a convenience function that\n   * checks if there is enough space in dest,\n   * extracts the entire string if possible,\n   * and NUL-terminates dest if possible.\n   *\n   * If the string fits into dest but cannot be NUL-terminated\n   * (length()==destCapacity) then the error code is set to U_STRING_NOT_TERMINATED_WARNING.\n   * If the string itself does not fit into dest\n   * (length()>destCapacity) then the error code is set to U_BUFFER_OVERFLOW_ERROR.\n   *\n   * If the string aliases to <code>dest</code> itself as an external buffer,\n   * then extract() will not copy the contents.\n   *\n   * @param dest Destination string buffer.\n   * @param destCapacity Number of UChars available at dest.\n   * @param errorCode ICU error code.\n   * @return length()\n   * @stable ICU 2.0\n   */\n  int32_t\n  extract(UChar *dest, int32_t destCapacity,\n          UErrorCode &errorCode) const;\n\n  /**\n   * Copy the characters in the range\n   * [<tt>start</tt>, <tt>start + length</tt>) into the  UnicodeString\n   * <tt>target</tt>.\n   * @param start offset of first character which will be copied\n   * @param length the number of characters to extract\n   * @param target UnicodeString into which to copy characters.\n   * @return A reference to <TT>target</TT>\n   * @stable ICU 2.0\n   */\n  inline void extract(int32_t start,\n           int32_t length,\n           UnicodeString& target) const;\n\n  /**\n   * Copy the characters in the range [<tt>start</tt>, <tt>limit</tt>)\n   * into the array <tt>dst</tt>, beginning at <tt>dstStart</tt>.\n   * @param start offset of first character which will be copied into the array\n   * @param limit offset immediately following the last character to be copied\n   * @param dst array in which to copy characters.  The length of <tt>dst</tt>\n   * must be at least (<tt>dstStart + (limit - start)</tt>).\n   * @param dstStart the offset in <TT>dst</TT> where the first character\n   * will be extracted\n   * @stable ICU 2.0\n   */\n  inline void extractBetween(int32_t start,\n              int32_t limit,\n              UChar *dst,\n              int32_t dstStart = 0) const;\n\n  /**\n   * Copy the characters in the range [<tt>start</tt>, <tt>limit</tt>)\n   * into the UnicodeString <tt>target</tt>.  Replaceable API.\n   * @param start offset of first character which will be copied\n   * @param limit offset immediately following the last character to be copied\n   * @param target UnicodeString into which to copy characters.\n   * @return A reference to <TT>target</TT>\n   * @stable ICU 2.0\n   */\n  virtual void extractBetween(int32_t start,\n              int32_t limit,\n              UnicodeString& target) const;\n\n  /**\n   * Copy the characters in the range \n   * [<tt>start</TT>, <tt>start + length</TT>) into an array of characters.\n   * All characters must be invariant (see utypes.h).\n   * Use US_INV as the last, signature-distinguishing parameter.\n   *\n   * This function does not write any more than <code>targetLength</code>\n   * characters but returns the length of the entire output string\n   * so that one can allocate a larger buffer and call the function again\n   * if necessary.\n   * The output string is NUL-terminated if possible.\n   *\n   * @param start offset of first character which will be copied\n   * @param startLength the number of characters to extract\n   * @param target the target buffer for extraction, can be NULL\n   *               if targetLength is 0\n   * @param targetCapacity the length of the target buffer\n   * @param inv Signature-distinguishing paramater, use US_INV.\n   * @return the output string length, not including the terminating NUL\n   * @stable ICU 3.2\n   */\n  int32_t extract(int32_t start,\n           int32_t startLength,\n           char *target,\n           int32_t targetCapacity,\n           enum EInvariant inv) const;\n\n#if U_CHARSET_IS_UTF8 || !UCONFIG_NO_CONVERSION\n\n  /**\n   * Copy the characters in the range\n   * [<tt>start</TT>, <tt>start + length</TT>) into an array of characters\n   * in the platform's default codepage.\n   * This function does not write any more than <code>targetLength</code>\n   * characters but returns the length of the entire output string\n   * so that one can allocate a larger buffer and call the function again\n   * if necessary.\n   * The output string is NUL-terminated if possible.\n   *\n   * @param start offset of first character which will be copied\n   * @param startLength the number of characters to extract\n   * @param target the target buffer for extraction\n   * @param targetLength the length of the target buffer\n   * If <TT>target</TT> is NULL, then the number of bytes required for\n   * <TT>target</TT> is returned.\n   * @return the output string length, not including the terminating NUL\n   * @stable ICU 2.0\n   */\n  int32_t extract(int32_t start,\n           int32_t startLength,\n           char *target,\n           uint32_t targetLength) const;\n\n#endif\n\n#if !UCONFIG_NO_CONVERSION\n\n  /**\n   * Copy the characters in the range\n   * [<tt>start</TT>, <tt>start + length</TT>) into an array of characters\n   * in a specified codepage.\n   * The output string is NUL-terminated.\n   *\n   * Recommendation: For invariant-character strings use\n   * extract(int32_t start, int32_t length, char *target, int32_t targetCapacity, enum EInvariant inv) const\n   * because it avoids object code dependencies of UnicodeString on\n   * the conversion code.\n   *\n   * @param start offset of first character which will be copied\n   * @param startLength the number of characters to extract\n   * @param target the target buffer for extraction\n   * @param codepage the desired codepage for the characters.  0 has\n   * the special meaning of the default codepage\n   * If <code>codepage</code> is an empty string (<code>\"\"</code>),\n   * then a simple conversion is performed on the codepage-invariant\n   * subset (\"invariant characters\") of the platform encoding. See utypes.h.\n   * If <TT>target</TT> is NULL, then the number of bytes required for\n   * <TT>target</TT> is returned. It is assumed that the target is big enough\n   * to fit all of the characters.\n   * @return the output string length, not including the terminating NUL\n   * @stable ICU 2.0\n   */\n  inline int32_t extract(int32_t start,\n                 int32_t startLength,\n                 char *target,\n                 const char *codepage = 0) const;\n\n  /**\n   * Copy the characters in the range\n   * [<tt>start</TT>, <tt>start + length</TT>) into an array of characters\n   * in a specified codepage.\n   * This function does not write any more than <code>targetLength</code>\n   * characters but returns the length of the entire output string\n   * so that one can allocate a larger buffer and call the function again\n   * if necessary.\n   * The output string is NUL-terminated if possible.\n   *\n   * Recommendation: For invariant-character strings use\n   * extract(int32_t start, int32_t length, char *target, int32_t targetCapacity, enum EInvariant inv) const\n   * because it avoids object code dependencies of UnicodeString on\n   * the conversion code.\n   *\n   * @param start offset of first character which will be copied\n   * @param startLength the number of characters to extract\n   * @param target the target buffer for extraction\n   * @param targetLength the length of the target buffer\n   * @param codepage the desired codepage for the characters.  0 has\n   * the special meaning of the default codepage\n   * If <code>codepage</code> is an empty string (<code>\"\"</code>),\n   * then a simple conversion is performed on the codepage-invariant\n   * subset (\"invariant characters\") of the platform encoding. See utypes.h.\n   * If <TT>target</TT> is NULL, then the number of bytes required for\n   * <TT>target</TT> is returned.\n   * @return the output string length, not including the terminating NUL\n   * @stable ICU 2.0\n   */\n  int32_t extract(int32_t start,\n           int32_t startLength,\n           char *target,\n           uint32_t targetLength,\n           const char *codepage) const;\n\n  /**\n   * Convert the UnicodeString into a codepage string using an existing UConverter.\n   * The output string is NUL-terminated if possible.\n   *\n   * This function avoids the overhead of opening and closing a converter if\n   * multiple strings are extracted.\n   *\n   * @param dest destination string buffer, can be NULL if destCapacity==0\n   * @param destCapacity the number of chars available at dest\n   * @param cnv the converter object to be used (ucnv_resetFromUnicode() will be called),\n   *        or NULL for the default converter\n   * @param errorCode normal ICU error code\n   * @return the length of the output string, not counting the terminating NUL;\n   *         if the length is greater than destCapacity, then the string will not fit\n   *         and a buffer of the indicated length would need to be passed in\n   * @stable ICU 2.0\n   */\n  int32_t extract(char *dest, int32_t destCapacity,\n                  UConverter *cnv,\n                  UErrorCode &errorCode) const;\n\n#endif\n\n  /**\n   * Create a temporary substring for the specified range.\n   * Unlike the substring constructor and setTo() functions,\n   * the object returned here will be a read-only alias (using getBuffer())\n   * rather than copying the text.\n   * As a result, this substring operation is much faster but requires\n   * that the original string not be modified or deleted during the lifetime\n   * of the returned substring object.\n   * @param start offset of the first character visible in the substring\n   * @param length length of the substring\n   * @return a read-only alias UnicodeString object for the substring\n   * @stable ICU 4.4\n   */\n  UnicodeString tempSubString(int32_t start=0, int32_t length=INT32_MAX) const;\n\n  /**\n   * Create a temporary substring for the specified range.\n   * Same as tempSubString(start, length) except that the substring range\n   * is specified as a (start, limit) pair (with an exclusive limit index)\n   * rather than a (start, length) pair.\n   * @param start offset of the first character visible in the substring\n   * @param limit offset immediately following the last character visible in the substring\n   * @return a read-only alias UnicodeString object for the substring\n   * @stable ICU 4.4\n   */\n  inline UnicodeString tempSubStringBetween(int32_t start, int32_t limit=INT32_MAX) const;\n\n  /**\n   * Convert the UnicodeString to UTF-8 and write the result\n   * to a ByteSink. This is called by toUTF8String().\n   * Unpaired surrogates are replaced with U+FFFD.\n   * Calls u_strToUTF8WithSub().\n   *\n   * @param sink A ByteSink to which the UTF-8 version of the string is written.\n   *             sink.Flush() is called at the end.\n   * @stable ICU 4.2\n   * @see toUTF8String\n   */\n  void toUTF8(ByteSink &sink) const;\n\n#if U_HAVE_STD_STRING\n\n  /**\n   * Convert the UnicodeString to UTF-8 and append the result\n   * to a standard string.\n   * Unpaired surrogates are replaced with U+FFFD.\n   * Calls toUTF8().\n   *\n   * @param result A standard string (or a compatible object)\n   *        to which the UTF-8 version of the string is appended.\n   * @return The string object.\n   * @stable ICU 4.2\n   * @see toUTF8\n   */\n  template<typename StringClass>\n  StringClass &toUTF8String(StringClass &result) const {\n    StringByteSink<StringClass> sbs(&result);\n    toUTF8(sbs);\n    return result;\n  }\n\n#endif\n\n  /**\n   * Convert the UnicodeString to UTF-32.\n   * Unpaired surrogates are replaced with U+FFFD.\n   * Calls u_strToUTF32WithSub().\n   *\n   * @param utf32 destination string buffer, can be NULL if capacity==0\n   * @param capacity the number of UChar32s available at utf32\n   * @param errorCode Standard ICU error code. Its input value must\n   *                  pass the U_SUCCESS() test, or else the function returns\n   *                  immediately. Check for U_FAILURE() on output or use with\n   *                  function chaining. (See User Guide for details.)\n   * @return The length of the UTF-32 string.\n   * @see fromUTF32\n   * @stable ICU 4.2\n   */\n  int32_t toUTF32(UChar32 *utf32, int32_t capacity, UErrorCode &errorCode) const;\n\n  /* Length operations */\n\n  /**\n   * Return the length of the UnicodeString object.\n   * The length is the number of UChar code units are in the UnicodeString.\n   * If you want the number of code points, please use countChar32().\n   * @return the length of the UnicodeString object\n   * @see countChar32\n   * @stable ICU 2.0\n   */\n  inline int32_t length(void) const;\n\n  /**\n   * Count Unicode code points in the length UChar code units of the string.\n   * A code point may occupy either one or two UChar code units.\n   * Counting code points involves reading all code units.\n   *\n   * This functions is basically the inverse of moveIndex32().\n   *\n   * @param start the index of the first code unit to check\n   * @param length the number of UChar code units to check\n   * @return the number of code points in the specified code units\n   * @see length\n   * @stable ICU 2.0\n   */\n  int32_t\n  countChar32(int32_t start=0, int32_t length=INT32_MAX) const;\n\n  /**\n   * Check if the length UChar code units of the string\n   * contain more Unicode code points than a certain number.\n   * This is more efficient than counting all code points in this part of the string\n   * and comparing that number with a threshold.\n   * This function may not need to scan the string at all if the length\n   * falls within a certain range, and\n   * never needs to count more than 'number+1' code points.\n   * Logically equivalent to (countChar32(start, length)>number).\n   * A Unicode code point may occupy either one or two UChar code units.\n   *\n   * @param start the index of the first code unit to check (0 for the entire string)\n   * @param length the number of UChar code units to check\n   *               (use INT32_MAX for the entire string; remember that start/length\n   *                values are pinned)\n   * @param number The number of code points in the (sub)string is compared against\n   *               the 'number' parameter.\n   * @return Boolean value for whether the string contains more Unicode code points\n   *         than 'number'. Same as (u_countChar32(s, length)>number).\n   * @see countChar32\n   * @see u_strHasMoreChar32Than\n   * @stable ICU 2.4\n   */\n  UBool\n  hasMoreChar32Than(int32_t start, int32_t length, int32_t number) const;\n\n  /**\n   * Determine if this string is empty.\n   * @return TRUE if this string contains 0 characters, FALSE otherwise.\n   * @stable ICU 2.0\n   */\n  inline UBool isEmpty(void) const;\n\n  /**\n   * Return the capacity of the internal buffer of the UnicodeString object.\n   * This is useful together with the getBuffer functions.\n   * See there for details.\n   *\n   * @return the number of UChars available in the internal buffer\n   * @see getBuffer\n   * @stable ICU 2.0\n   */\n  inline int32_t getCapacity(void) const;\n\n  /* Other operations */\n\n  /**\n   * Generate a hash code for this object.\n   * @return The hash code of this UnicodeString.\n   * @stable ICU 2.0\n   */\n  inline int32_t hashCode(void) const;\n\n  /**\n   * Determine if this object contains a valid string.\n   * A bogus string has no value. It is different from an empty string,\n   * although in both cases isEmpty() returns TRUE and length() returns 0.\n   * setToBogus() and isBogus() can be used to indicate that no string value is available.\n   * For a bogus string, getBuffer() and getTerminatedBuffer() return NULL, and\n   * length() returns 0.\n   *\n   * @return TRUE if the string is valid, FALSE otherwise\n   * @see setToBogus()\n   * @stable ICU 2.0\n   */\n  inline UBool isBogus(void) const;\n\n\n  //========================================\n  // Write operations\n  //========================================\n\n  /* Assignment operations */\n\n  /**\n   * Assignment operator.  Replace the characters in this UnicodeString\n   * with the characters from <TT>srcText</TT>.\n   * @param srcText The text containing the characters to replace\n   * @return a reference to this\n   * @stable ICU 2.0\n   */\n  UnicodeString &operator=(const UnicodeString &srcText);\n\n  /**\n   * Almost the same as the assignment operator.\n   * Replace the characters in this UnicodeString\n   * with the characters from <code>srcText</code>.\n   *\n   * This function works the same as the assignment operator\n   * for all strings except for ones that are readonly aliases.\n   *\n   * Starting with ICU 2.4, the assignment operator and the copy constructor\n   * allocate a new buffer and copy the buffer contents even for readonly aliases.\n   * This function implements the old, more efficient but less safe behavior\n   * of making this string also a readonly alias to the same buffer.\n   *\n   * The fastCopyFrom function must be used only if it is known that the lifetime of\n   * this UnicodeString does not exceed the lifetime of the aliased buffer\n   * including its contents, for example for strings from resource bundles\n   * or aliases to string constants.\n   *\n   * @param src The text containing the characters to replace.\n   * @return a reference to this\n   * @stable ICU 2.4\n   */\n  UnicodeString &fastCopyFrom(const UnicodeString &src);\n\n  /**\n   * Assignment operator.  Replace the characters in this UnicodeString\n   * with the code unit <TT>ch</TT>.\n   * @param ch the code unit to replace\n   * @return a reference to this\n   * @stable ICU 2.0\n   */\n  inline UnicodeString& operator= (UChar ch);\n\n  /**\n   * Assignment operator.  Replace the characters in this UnicodeString\n   * with the code point <TT>ch</TT>.\n   * @param ch the code point to replace\n   * @return a reference to this\n   * @stable ICU 2.0\n   */\n  inline UnicodeString& operator= (UChar32 ch);\n\n  /**\n   * Set the text in the UnicodeString object to the characters\n   * in <TT>srcText</TT> in the range\n   * [<TT>srcStart</TT>, <TT>srcText.length()</TT>).\n   * <TT>srcText</TT> is not modified.\n   * @param srcText the source for the new characters\n   * @param srcStart the offset into <TT>srcText</TT> where new characters\n   * will be obtained\n   * @return a reference to this\n   * @stable ICU 2.2\n   */\n  inline UnicodeString& setTo(const UnicodeString& srcText,\n               int32_t srcStart);\n\n  /**\n   * Set the text in the UnicodeString object to the characters\n   * in <TT>srcText</TT> in the range\n   * [<TT>srcStart</TT>, <TT>srcStart + srcLength</TT>).\n   * <TT>srcText</TT> is not modified.\n   * @param srcText the source for the new characters\n   * @param srcStart the offset into <TT>srcText</TT> where new characters\n   * will be obtained\n   * @param srcLength the number of characters in <TT>srcText</TT> in the\n   * replace string.\n   * @return a reference to this\n   * @stable ICU 2.0\n   */\n  inline UnicodeString& setTo(const UnicodeString& srcText,\n               int32_t srcStart,\n               int32_t srcLength);\n\n  /**\n   * Set the text in the UnicodeString object to the characters in\n   * <TT>srcText</TT>.\n   * <TT>srcText</TT> is not modified.\n   * @param srcText the source for the new characters\n   * @return a reference to this\n   * @stable ICU 2.0\n   */\n  inline UnicodeString& setTo(const UnicodeString& srcText);\n\n  /**\n   * Set the characters in the UnicodeString object to the characters\n   * in <TT>srcChars</TT>. <TT>srcChars</TT> is not modified.\n   * @param srcChars the source for the new characters\n   * @param srcLength the number of Unicode characters in srcChars.\n   * @return a reference to this\n   * @stable ICU 2.0\n   */\n  inline UnicodeString& setTo(const UChar *srcChars,\n               int32_t srcLength);\n\n  /**\n   * Set the characters in the UnicodeString object to the code unit\n   * <TT>srcChar</TT>.\n   * @param srcChar the code unit which becomes the UnicodeString's character\n   * content\n   * @return a reference to this\n   * @stable ICU 2.0\n   */\n  UnicodeString& setTo(UChar srcChar);\n\n  /**\n   * Set the characters in the UnicodeString object to the code point\n   * <TT>srcChar</TT>.\n   * @param srcChar the code point which becomes the UnicodeString's character\n   * content\n   * @return a reference to this\n   * @stable ICU 2.0\n   */\n  UnicodeString& setTo(UChar32 srcChar);\n\n  /**\n   * Aliasing setTo() function, analogous to the readonly-aliasing UChar* constructor.\n   * The text will be used for the UnicodeString object, but\n   * it will not be released when the UnicodeString is destroyed.\n   * This has copy-on-write semantics:\n   * When the string is modified, then the buffer is first copied into\n   * newly allocated memory.\n   * The aliased buffer is never modified.\n   *\n   * In an assignment to another UnicodeString, when using the copy constructor\n   * or the assignment operator, the text will be copied.\n   * When using fastCopyFrom(), the text will be aliased again,\n   * so that both strings then alias the same readonly-text.\n   *\n   * @param isTerminated specifies if <code>text</code> is <code>NUL</code>-terminated.\n   *                     This must be true if <code>textLength==-1</code>.\n   * @param text The characters to alias for the UnicodeString.\n   * @param textLength The number of Unicode characters in <code>text</code> to alias.\n   *                   If -1, then this constructor will determine the length\n   *                   by calling <code>u_strlen()</code>.\n   * @return a reference to this\n   * @stable ICU 2.0\n   */\n  UnicodeString &setTo(UBool isTerminated,\n                       const UChar *text,\n                       int32_t textLength);\n\n  /**\n   * Aliasing setTo() function, analogous to the writable-aliasing UChar* constructor.\n   * The text will be used for the UnicodeString object, but\n   * it will not be released when the UnicodeString is destroyed.\n   * This has write-through semantics:\n   * For as long as the capacity of the buffer is sufficient, write operations\n   * will directly affect the buffer. When more capacity is necessary, then\n   * a new buffer will be allocated and the contents copied as with regularly\n   * constructed strings.\n   * In an assignment to another UnicodeString, the buffer will be copied.\n   * The extract(UChar *dst) function detects whether the dst pointer is the same\n   * as the string buffer itself and will in this case not copy the contents.\n   *\n   * @param buffer The characters to alias for the UnicodeString.\n   * @param buffLength The number of Unicode characters in <code>buffer</code> to alias.\n   * @param buffCapacity The size of <code>buffer</code> in UChars.\n   * @return a reference to this\n   * @stable ICU 2.0\n   */\n  UnicodeString &setTo(UChar *buffer,\n                       int32_t buffLength,\n                       int32_t buffCapacity);\n\n  /**\n   * Make this UnicodeString object invalid.\n   * The string will test TRUE with isBogus().\n   *\n   * A bogus string has no value. It is different from an empty string.\n   * It can be used to indicate that no string value is available.\n   * getBuffer() and getTerminatedBuffer() return NULL, and\n   * length() returns 0.\n   *\n   * This utility function is used throughout the UnicodeString\n   * implementation to indicate that a UnicodeString operation failed,\n   * and may be used in other functions,\n   * especially but not exclusively when such functions do not\n   * take a UErrorCode for simplicity.\n   *\n   * The following methods, and no others, will clear a string object's bogus flag:\n   * - remove()\n   * - remove(0, INT32_MAX)\n   * - truncate(0)\n   * - operator=() (assignment operator)\n   * - setTo(...)\n   *\n   * The simplest ways to turn a bogus string into an empty one\n   * is to use the remove() function.\n   * Examples for other functions that are equivalent to \"set to empty string\":\n   * \\code\n   * if(s.isBogus()) {\n   *   s.remove();           // set to an empty string (remove all), or\n   *   s.remove(0, INT32_MAX); // set to an empty string (remove all), or\n   *   s.truncate(0);        // set to an empty string (complete truncation), or\n   *   s=UnicodeString();    // assign an empty string, or\n   *   s.setTo((UChar32)-1); // set to a pseudo code point that is out of range, or\n   *   static const UChar nul=0;\n   *   s.setTo(&nul, 0);     // set to an empty C Unicode string\n   * }\n   * \\endcode\n   *\n   * @see isBogus()\n   * @stable ICU 2.0\n   */\n  void setToBogus();\n\n  /**\n   * Set the character at the specified offset to the specified character.\n   * @param offset A valid offset into the text of the character to set\n   * @param ch The new character\n   * @return A reference to this\n   * @stable ICU 2.0\n   */\n  UnicodeString& setCharAt(int32_t offset,\n               UChar ch);\n\n\n  /* Append operations */\n\n  /**\n   * Append operator. Append the code unit <TT>ch</TT> to the UnicodeString\n   * object.\n   * @param ch the code unit to be appended\n   * @return a reference to this\n   * @stable ICU 2.0\n   */\n inline  UnicodeString& operator+= (UChar ch);\n\n  /**\n   * Append operator. Append the code point <TT>ch</TT> to the UnicodeString\n   * object.\n   * @param ch the code point to be appended\n   * @return a reference to this\n   * @stable ICU 2.0\n   */\n inline  UnicodeString& operator+= (UChar32 ch);\n\n  /**\n   * Append operator. Append the characters in <TT>srcText</TT> to the\n   * UnicodeString object. <TT>srcText</TT> is not modified.\n   * @param srcText the source for the new characters\n   * @return a reference to this\n   * @stable ICU 2.0\n   */\n  inline UnicodeString& operator+= (const UnicodeString& srcText);\n\n  /**\n   * Append the characters\n   * in <TT>srcText</TT> in the range\n   * [<TT>srcStart</TT>, <TT>srcStart + srcLength</TT>) to the\n   * UnicodeString object at offset <TT>start</TT>. <TT>srcText</TT>\n   * is not modified.\n   * @param srcText the source for the new characters\n   * @param srcStart the offset into <TT>srcText</TT> where new characters\n   * will be obtained\n   * @param srcLength the number of characters in <TT>srcText</TT> in\n   * the append string\n   * @return a reference to this\n   * @stable ICU 2.0\n   */\n  inline UnicodeString& append(const UnicodeString& srcText,\n            int32_t srcStart,\n            int32_t srcLength);\n\n  /**\n   * Append the characters in <TT>srcText</TT> to the UnicodeString object.\n   * <TT>srcText</TT> is not modified.\n   * @param srcText the source for the new characters\n   * @return a reference to this\n   * @stable ICU 2.0\n   */\n  inline UnicodeString& append(const UnicodeString& srcText);\n\n  /**\n   * Append the characters in <TT>srcChars</TT> in the range\n   * [<TT>srcStart</TT>, <TT>srcStart + srcLength</TT>) to the UnicodeString\n   * object at offset\n   * <TT>start</TT>. <TT>srcChars</TT> is not modified.\n   * @param srcChars the source for the new characters\n   * @param srcStart the offset into <TT>srcChars</TT> where new characters\n   * will be obtained\n   * @param srcLength the number of characters in <TT>srcChars</TT> in\n   *                  the append string; can be -1 if <TT>srcChars</TT> is NUL-terminated\n   * @return a reference to this\n   * @stable ICU 2.0\n   */\n  inline UnicodeString& append(const UChar *srcChars,\n            int32_t srcStart,\n            int32_t srcLength);\n\n  /**\n   * Append the characters in <TT>srcChars</TT> to the UnicodeString object\n   * at offset <TT>start</TT>. <TT>srcChars</TT> is not modified.\n   * @param srcChars the source for the new characters\n   * @param srcLength the number of Unicode characters in <TT>srcChars</TT>;\n   *                  can be -1 if <TT>srcChars</TT> is NUL-terminated\n   * @return a reference to this\n   * @stable ICU 2.0\n   */\n  inline UnicodeString& append(const UChar *srcChars,\n            int32_t srcLength);\n\n  /**\n   * Append the code unit <TT>srcChar</TT> to the UnicodeString object.\n   * @param srcChar the code unit to append\n   * @return a reference to this\n   * @stable ICU 2.0\n   */\n  inline UnicodeString& append(UChar srcChar);\n\n  /**\n   * Append the code point <TT>srcChar</TT> to the UnicodeString object.\n   * @param srcChar the code point to append\n   * @return a reference to this\n   * @stable ICU 2.0\n   */\n  UnicodeString& append(UChar32 srcChar);\n\n\n  /* Insert operations */\n\n  /**\n   * Insert the characters in <TT>srcText</TT> in the range\n   * [<TT>srcStart</TT>, <TT>srcStart + srcLength</TT>) into the UnicodeString\n   * object at offset <TT>start</TT>. <TT>srcText</TT> is not modified.\n   * @param start the offset where the insertion begins\n   * @param srcText the source for the new characters\n   * @param srcStart the offset into <TT>srcText</TT> where new characters\n   * will be obtained\n   * @param srcLength the number of characters in <TT>srcText</TT> in\n   * the insert string\n   * @return a reference to this\n   * @stable ICU 2.0\n   */\n  inline UnicodeString& insert(int32_t start,\n            const UnicodeString& srcText,\n            int32_t srcStart,\n            int32_t srcLength);\n\n  /**\n   * Insert the characters in <TT>srcText</TT> into the UnicodeString object\n   * at offset <TT>start</TT>. <TT>srcText</TT> is not modified.\n   * @param start the offset where the insertion begins\n   * @param srcText the source for the new characters\n   * @return a reference to this\n   * @stable ICU 2.0\n   */\n  inline UnicodeString& insert(int32_t start,\n            const UnicodeString& srcText);\n\n  /**\n   * Insert the characters in <TT>srcChars</TT> in the range\n   * [<TT>srcStart</TT>, <TT>srcStart + srcLength</TT>) into the UnicodeString\n   *  object at offset <TT>start</TT>. <TT>srcChars</TT> is not modified.\n   * @param start the offset at which the insertion begins\n   * @param srcChars the source for the new characters\n   * @param srcStart the offset into <TT>srcChars</TT> where new characters\n   * will be obtained\n   * @param srcLength the number of characters in <TT>srcChars</TT>\n   * in the insert string\n   * @return a reference to this\n   * @stable ICU 2.0\n   */\n  inline UnicodeString& insert(int32_t start,\n            const UChar *srcChars,\n            int32_t srcStart,\n            int32_t srcLength);\n\n  /**\n   * Insert the characters in <TT>srcChars</TT> into the UnicodeString object\n   * at offset <TT>start</TT>. <TT>srcChars</TT> is not modified.\n   * @param start the offset where the insertion begins\n   * @param srcChars the source for the new characters\n   * @param srcLength the number of Unicode characters in srcChars.\n   * @return a reference to this\n   * @stable ICU 2.0\n   */\n  inline UnicodeString& insert(int32_t start,\n            const UChar *srcChars,\n            int32_t srcLength);\n\n  /**\n   * Insert the code unit <TT>srcChar</TT> into the UnicodeString object at\n   * offset <TT>start</TT>.\n   * @param start the offset at which the insertion occurs\n   * @param srcChar the code unit to insert\n   * @return a reference to this\n   * @stable ICU 2.0\n   */\n  inline UnicodeString& insert(int32_t start,\n            UChar srcChar);\n\n  /**\n   * Insert the code point <TT>srcChar</TT> into the UnicodeString object at\n   * offset <TT>start</TT>.\n   * @param start the offset at which the insertion occurs\n   * @param srcChar the code point to insert\n   * @return a reference to this\n   * @stable ICU 2.0\n   */\n  inline UnicodeString& insert(int32_t start,\n            UChar32 srcChar);\n\n\n  /* Replace operations */\n\n  /**\n   * Replace the characters in the range\n   * [<TT>start</TT>, <TT>start + length</TT>) with the characters in\n   * <TT>srcText</TT> in the range\n   * [<TT>srcStart</TT>, <TT>srcStart + srcLength</TT>).\n   * <TT>srcText</TT> is not modified.\n   * @param start the offset at which the replace operation begins\n   * @param length the number of characters to replace. The character at\n   * <TT>start + length</TT> is not modified.\n   * @param srcText the source for the new characters\n   * @param srcStart the offset into <TT>srcText</TT> where new characters\n   * will be obtained\n   * @param srcLength the number of characters in <TT>srcText</TT> in\n   * the replace string\n   * @return a reference to this\n   * @stable ICU 2.0\n   */\n  UnicodeString& replace(int32_t start,\n             int32_t length,\n             const UnicodeString& srcText,\n             int32_t srcStart,\n             int32_t srcLength);\n\n  /**\n   * Replace the characters in the range\n   * [<TT>start</TT>, <TT>start + length</TT>)\n   * with the characters in <TT>srcText</TT>.  <TT>srcText</TT> is\n   *  not modified.\n   * @param start the offset at which the replace operation begins\n   * @param length the number of characters to replace. The character at\n   * <TT>start + length</TT> is not modified.\n   * @param srcText the source for the new characters\n   * @return a reference to this\n   * @stable ICU 2.0\n   */\n  UnicodeString& replace(int32_t start,\n             int32_t length,\n             const UnicodeString& srcText);\n\n  /**\n   * Replace the characters in the range\n   * [<TT>start</TT>, <TT>start + length</TT>) with the characters in\n   * <TT>srcChars</TT> in the range\n   * [<TT>srcStart</TT>, <TT>srcStart + srcLength</TT>). <TT>srcChars</TT>\n   * is not modified.\n   * @param start the offset at which the replace operation begins\n   * @param length the number of characters to replace.  The character at\n   * <TT>start + length</TT> is not modified.\n   * @param srcChars the source for the new characters\n   * @param srcStart the offset into <TT>srcChars</TT> where new characters\n   * will be obtained\n   * @param srcLength the number of characters in <TT>srcChars</TT>\n   * in the replace string\n   * @return a reference to this\n   * @stable ICU 2.0\n   */\n  UnicodeString& replace(int32_t start,\n             int32_t length,\n             const UChar *srcChars,\n             int32_t srcStart,\n             int32_t srcLength);\n\n  /**\n   * Replace the characters in the range\n   * [<TT>start</TT>, <TT>start + length</TT>) with the characters in\n   * <TT>srcChars</TT>.  <TT>srcChars</TT> is not modified.\n   * @param start the offset at which the replace operation begins\n   * @param length number of characters to replace.  The character at\n   * <TT>start + length</TT> is not modified.\n   * @param srcChars the source for the new characters\n   * @param srcLength the number of Unicode characters in srcChars\n   * @return a reference to this\n   * @stable ICU 2.0\n   */\n  inline UnicodeString& replace(int32_t start,\n             int32_t length,\n             const UChar *srcChars,\n             int32_t srcLength);\n\n  /**\n   * Replace the characters in the range\n   * [<TT>start</TT>, <TT>start + length</TT>) with the code unit\n   * <TT>srcChar</TT>.\n   * @param start the offset at which the replace operation begins\n   * @param length the number of characters to replace.  The character at\n   * <TT>start + length</TT> is not modified.\n   * @param srcChar the new code unit\n   * @return a reference to this\n   * @stable ICU 2.0\n   */\n  inline UnicodeString& replace(int32_t start,\n             int32_t length,\n             UChar srcChar);\n\n  /**\n   * Replace the characters in the range\n   * [<TT>start</TT>, <TT>start + length</TT>) with the code point\n   * <TT>srcChar</TT>.\n   * @param start the offset at which the replace operation begins\n   * @param length the number of characters to replace.  The character at\n   * <TT>start + length</TT> is not modified.\n   * @param srcChar the new code point\n   * @return a reference to this\n   * @stable ICU 2.0\n   */\n  UnicodeString& replace(int32_t start, int32_t length, UChar32 srcChar);\n\n  /**\n   * Replace the characters in the range [<TT>start</TT>, <TT>limit</TT>)\n   * with the characters in <TT>srcText</TT>. <TT>srcText</TT> is not modified.\n   * @param start the offset at which the replace operation begins\n   * @param limit the offset immediately following the replace range\n   * @param srcText the source for the new characters\n   * @return a reference to this\n   * @stable ICU 2.0\n   */\n  inline UnicodeString& replaceBetween(int32_t start,\n                int32_t limit,\n                const UnicodeString& srcText);\n\n  /**\n   * Replace the characters in the range [<TT>start</TT>, <TT>limit</TT>)\n   * with the characters in <TT>srcText</TT> in the range\n   * [<TT>srcStart</TT>, <TT>srcLimit</TT>). <TT>srcText</TT> is not modified.\n   * @param start the offset at which the replace operation begins\n   * @param limit the offset immediately following the replace range\n   * @param srcText the source for the new characters\n   * @param srcStart the offset into <TT>srcChars</TT> where new characters\n   * will be obtained\n   * @param srcLimit the offset immediately following the range to copy\n   * in <TT>srcText</TT>\n   * @return a reference to this\n   * @stable ICU 2.0\n   */\n  inline UnicodeString& replaceBetween(int32_t start,\n                int32_t limit,\n                const UnicodeString& srcText,\n                int32_t srcStart,\n                int32_t srcLimit);\n\n  /**\n   * Replace a substring of this object with the given text.\n   * @param start the beginning index, inclusive; <code>0 <= start\n   * <= limit</code>.\n   * @param limit the ending index, exclusive; <code>start <= limit\n   * <= length()</code>.\n   * @param text the text to replace characters <code>start</code>\n   * to <code>limit - 1</code>\n   * @stable ICU 2.0\n   */\n  virtual void handleReplaceBetween(int32_t start,\n                                    int32_t limit,\n                                    const UnicodeString& text);\n\n  /**\n   * Replaceable API\n   * @return TRUE if it has MetaData\n   * @stable ICU 2.4\n   */\n  virtual UBool hasMetaData() const;\n\n  /**\n   * Copy a substring of this object, retaining attribute (out-of-band)\n   * information.  This method is used to duplicate or reorder substrings.\n   * The destination index must not overlap the source range.\n   *\n   * @param start the beginning index, inclusive; <code>0 <= start <=\n   * limit</code>.\n   * @param limit the ending index, exclusive; <code>start <= limit <=\n   * length()</code>.\n   * @param dest the destination index.  The characters from\n   * <code>start..limit-1</code> will be copied to <code>dest</code>.\n   * Implementations of this method may assume that <code>dest <= start ||\n   * dest >= limit</code>.\n   * @stable ICU 2.0\n   */\n  virtual void copy(int32_t start, int32_t limit, int32_t dest);\n\n  /* Search and replace operations */\n\n  /**\n   * Replace all occurrences of characters in oldText with the characters\n   * in newText\n   * @param oldText the text containing the search text\n   * @param newText the text containing the replacement text\n   * @return a reference to this\n   * @stable ICU 2.0\n   */\n  inline UnicodeString& findAndReplace(const UnicodeString& oldText,\n                const UnicodeString& newText);\n\n  /**\n   * Replace all occurrences of characters in oldText with characters\n   * in newText\n   * in the range [<TT>start</TT>, <TT>start + length</TT>).\n   * @param start the start of the range in which replace will performed\n   * @param length the length of the range in which replace will be performed\n   * @param oldText the text containing the search text\n   * @param newText the text containing the replacement text\n   * @return a reference to this\n   * @stable ICU 2.0\n   */\n  inline UnicodeString& findAndReplace(int32_t start,\n                int32_t length,\n                const UnicodeString& oldText,\n                const UnicodeString& newText);\n\n  /**\n   * Replace all occurrences of characters in oldText in the range\n   * [<TT>oldStart</TT>, <TT>oldStart + oldLength</TT>) with the characters\n   * in newText in the range\n   * [<TT>newStart</TT>, <TT>newStart + newLength</TT>)\n   * in the range [<TT>start</TT>, <TT>start + length</TT>).\n   * @param start the start of the range in which replace will performed\n   * @param length the length of the range in which replace will be performed\n   * @param oldText the text containing the search text\n   * @param oldStart the start of the search range in <TT>oldText</TT>\n   * @param oldLength the length of the search range in <TT>oldText</TT>\n   * @param newText the text containing the replacement text\n   * @param newStart the start of the replacement range in <TT>newText</TT>\n   * @param newLength the length of the replacement range in <TT>newText</TT>\n   * @return a reference to this\n   * @stable ICU 2.0\n   */\n  UnicodeString& findAndReplace(int32_t start,\n                int32_t length,\n                const UnicodeString& oldText,\n                int32_t oldStart,\n                int32_t oldLength,\n                const UnicodeString& newText,\n                int32_t newStart,\n                int32_t newLength);\n\n\n  /* Remove operations */\n\n  /**\n   * Remove all characters from the UnicodeString object.\n   * @return a reference to this\n   * @stable ICU 2.0\n   */\n  inline UnicodeString& remove(void);\n\n  /**\n   * Remove the characters in the range\n   * [<TT>start</TT>, <TT>start + length</TT>) from the UnicodeString object.\n   * @param start the offset of the first character to remove\n   * @param length the number of characters to remove\n   * @return a reference to this\n   * @stable ICU 2.0\n   */\n  inline UnicodeString& remove(int32_t start,\n                               int32_t length = (int32_t)INT32_MAX);\n\n  /**\n   * Remove the characters in the range\n   * [<TT>start</TT>, <TT>limit</TT>) from the UnicodeString object.\n   * @param start the offset of the first character to remove\n   * @param limit the offset immediately following the range to remove\n   * @return a reference to this\n   * @stable ICU 2.0\n   */\n  inline UnicodeString& removeBetween(int32_t start,\n                                      int32_t limit = (int32_t)INT32_MAX);\n\n  /**\n   * Retain only the characters in the range\n   * [<code>start</code>, <code>limit</code>) from the UnicodeString object.\n   * Removes characters before <code>start</code> and at and after <code>limit</code>.\n   * @param start the offset of the first character to retain\n   * @param limit the offset immediately following the range to retain\n   * @return a reference to this\n   * @stable ICU 4.4\n   */\n  inline UnicodeString &retainBetween(int32_t start, int32_t limit = INT32_MAX);\n\n  /* Length operations */\n\n  /**\n   * Pad the start of this UnicodeString with the character <TT>padChar</TT>.\n   * If the length of this UnicodeString is less than targetLength,\n   * length() - targetLength copies of padChar will be added to the\n   * beginning of this UnicodeString.\n   * @param targetLength the desired length of the string\n   * @param padChar the character to use for padding. Defaults to\n   * space (U+0020)\n   * @return TRUE if the text was padded, FALSE otherwise.\n   * @stable ICU 2.0\n   */\n  UBool padLeading(int32_t targetLength,\n                    UChar padChar = 0x0020);\n\n  /**\n   * Pad the end of this UnicodeString with the character <TT>padChar</TT>.\n   * If the length of this UnicodeString is less than targetLength,\n   * length() - targetLength copies of padChar will be added to the\n   * end of this UnicodeString.\n   * @param targetLength the desired length of the string\n   * @param padChar the character to use for padding. Defaults to\n   * space (U+0020)\n   * @return TRUE if the text was padded, FALSE otherwise.\n   * @stable ICU 2.0\n   */\n  UBool padTrailing(int32_t targetLength,\n                     UChar padChar = 0x0020);\n\n  /**\n   * Truncate this UnicodeString to the <TT>targetLength</TT>.\n   * @param targetLength the desired length of this UnicodeString.\n   * @return TRUE if the text was truncated, FALSE otherwise\n   * @stable ICU 2.0\n   */\n  inline UBool truncate(int32_t targetLength);\n\n  /**\n   * Trims leading and trailing whitespace from this UnicodeString.\n   * @return a reference to this\n   * @stable ICU 2.0\n   */\n  UnicodeString& trim(void);\n\n\n  /* Miscellaneous operations */\n\n  /**\n   * Reverse this UnicodeString in place.\n   * @return a reference to this\n   * @stable ICU 2.0\n   */\n  inline UnicodeString& reverse(void);\n\n  /**\n   * Reverse the range [<TT>start</TT>, <TT>start + length</TT>) in\n   * this UnicodeString.\n   * @param start the start of the range to reverse\n   * @param length the number of characters to to reverse\n   * @return a reference to this\n   * @stable ICU 2.0\n   */\n  inline UnicodeString& reverse(int32_t start,\n             int32_t length);\n\n  /**\n   * Convert the characters in this to UPPER CASE following the conventions of\n   * the default locale.\n   * @return A reference to this.\n   * @stable ICU 2.0\n   */\n  UnicodeString& toUpper(void);\n\n  /**\n   * Convert the characters in this to UPPER CASE following the conventions of\n   * a specific locale.\n   * @param locale The locale containing the conventions to use.\n   * @return A reference to this.\n   * @stable ICU 2.0\n   */\n  UnicodeString& toUpper(const Locale& locale);\n\n  /**\n   * Convert the characters in this to lower case following the conventions of\n   * the default locale.\n   * @return A reference to this.\n   * @stable ICU 2.0\n   */\n  UnicodeString& toLower(void);\n\n  /**\n   * Convert the characters in this to lower case following the conventions of\n   * a specific locale.\n   * @param locale The locale containing the conventions to use.\n   * @return A reference to this.\n   * @stable ICU 2.0\n   */\n  UnicodeString& toLower(const Locale& locale);\n\n#if !UCONFIG_NO_BREAK_ITERATION\n\n  /**\n   * Titlecase this string, convenience function using the default locale.\n   *\n   * Casing is locale-dependent and context-sensitive.\n   * Titlecasing uses a break iterator to find the first characters of words\n   * that are to be titlecased. It titlecases those characters and lowercases\n   * all others.\n   *\n   * The titlecase break iterator can be provided to customize for arbitrary\n   * styles, using rules and dictionaries beyond the standard iterators.\n   * It may be more efficient to always provide an iterator to avoid\n   * opening and closing one for each string.\n   * The standard titlecase iterator for the root locale implements the\n   * algorithm of Unicode TR 21.\n   *\n   * This function uses only the setText(), first() and next() methods of the\n   * provided break iterator.\n   *\n   * @param titleIter A break iterator to find the first characters of words\n   *                  that are to be titlecased.\n   *                  If none is provided (0), then a standard titlecase\n   *                  break iterator is opened.\n   *                  Otherwise the provided iterator is set to the string's text.\n   * @return A reference to this.\n   * @stable ICU 2.1\n   */\n  UnicodeString &toTitle(BreakIterator *titleIter);\n\n  /**\n   * Titlecase this string.\n   *\n   * Casing is locale-dependent and context-sensitive.\n   * Titlecasing uses a break iterator to find the first characters of words\n   * that are to be titlecased. It titlecases those characters and lowercases\n   * all others.\n   *\n   * The titlecase break iterator can be provided to customize for arbitrary\n   * styles, using rules and dictionaries beyond the standard iterators.\n   * It may be more efficient to always provide an iterator to avoid\n   * opening and closing one for each string.\n   * The standard titlecase iterator for the root locale implements the\n   * algorithm of Unicode TR 21.\n   *\n   * This function uses only the setText(), first() and next() methods of the\n   * provided break iterator.\n   *\n   * @param titleIter A break iterator to find the first characters of words\n   *                  that are to be titlecased.\n   *                  If none is provided (0), then a standard titlecase\n   *                  break iterator is opened.\n   *                  Otherwise the provided iterator is set to the string's text.\n   * @param locale    The locale to consider.\n   * @return A reference to this.\n   * @stable ICU 2.1\n   */\n  UnicodeString &toTitle(BreakIterator *titleIter, const Locale &locale);\n\n  /**\n   * Titlecase this string, with options.\n   *\n   * Casing is locale-dependent and context-sensitive.\n   * Titlecasing uses a break iterator to find the first characters of words\n   * that are to be titlecased. It titlecases those characters and lowercases\n   * all others. (This can be modified with options.)\n   *\n   * The titlecase break iterator can be provided to customize for arbitrary\n   * styles, using rules and dictionaries beyond the standard iterators.\n   * It may be more efficient to always provide an iterator to avoid\n   * opening and closing one for each string.\n   * The standard titlecase iterator for the root locale implements the\n   * algorithm of Unicode TR 21.\n   *\n   * This function uses only the setText(), first() and next() methods of the\n   * provided break iterator.\n   *\n   * @param titleIter A break iterator to find the first characters of words\n   *                  that are to be titlecased.\n   *                  If none is provided (0), then a standard titlecase\n   *                  break iterator is opened.\n   *                  Otherwise the provided iterator is set to the string's text.\n   * @param locale    The locale to consider.\n   * @param options Options bit set, see ucasemap_open().\n   * @return A reference to this.\n   * @see U_TITLECASE_NO_LOWERCASE\n   * @see U_TITLECASE_NO_BREAK_ADJUSTMENT\n   * @see ucasemap_open\n   * @stable ICU 3.8\n   */\n  UnicodeString &toTitle(BreakIterator *titleIter, const Locale &locale, uint32_t options);\n\n#endif\n\n  /**\n   * Case-folds the characters in this string.\n   *\n   * Case-folding is locale-independent and not context-sensitive,\n   * but there is an option for whether to include or exclude mappings for dotted I\n   * and dotless i that are marked with 'T' in CaseFolding.txt.\n   *\n   * The result may be longer or shorter than the original.\n   *\n   * @param options Either U_FOLD_CASE_DEFAULT or U_FOLD_CASE_EXCLUDE_SPECIAL_I\n   * @return A reference to this.\n   * @stable ICU 2.0\n   */\n  UnicodeString &foldCase(uint32_t options=0 /*U_FOLD_CASE_DEFAULT*/);\n\n  //========================================\n  // Access to the internal buffer\n  //========================================\n\n  /**\n   * Get a read/write pointer to the internal buffer.\n   * The buffer is guaranteed to be large enough for at least minCapacity UChars,\n   * writable, and is still owned by the UnicodeString object.\n   * Calls to getBuffer(minCapacity) must not be nested, and\n   * must be matched with calls to releaseBuffer(newLength).\n   * If the string buffer was read-only or shared,\n   * then it will be reallocated and copied.\n   *\n   * An attempted nested call will return 0, and will not further modify the\n   * state of the UnicodeString object.\n   * It also returns 0 if the string is bogus.\n   *\n   * The actual capacity of the string buffer may be larger than minCapacity.\n   * getCapacity() returns the actual capacity.\n   * For many operations, the full capacity should be used to avoid reallocations.\n   *\n   * While the buffer is \"open\" between getBuffer(minCapacity)\n   * and releaseBuffer(newLength), the following applies:\n   * - The string length is set to 0.\n   * - Any read API call on the UnicodeString object will behave like on a 0-length string.\n   * - Any write API call on the UnicodeString object is disallowed and will have no effect.\n   * - You can read from and write to the returned buffer.\n   * - The previous string contents will still be in the buffer;\n   *   if you want to use it, then you need to call length() before getBuffer(minCapacity).\n   *   If the length() was greater than minCapacity, then any contents after minCapacity\n   *   may be lost.\n   *   The buffer contents is not NUL-terminated by getBuffer().\n   *   If length()<getCapacity() then you can terminate it by writing a NUL\n   *   at index length().\n   * - You must call releaseBuffer(newLength) before and in order to\n   *   return to normal UnicodeString operation.\n   *\n   * @param minCapacity the minimum number of UChars that are to be available\n   *        in the buffer, starting at the returned pointer;\n   *        default to the current string capacity if minCapacity==-1\n   * @return a writable pointer to the internal string buffer,\n   *         or 0 if an error occurs (nested calls, out of memory)\n   *\n   * @see releaseBuffer\n   * @see getTerminatedBuffer()\n   * @stable ICU 2.0\n   */\n  UChar *getBuffer(int32_t minCapacity);\n\n  /**\n   * Release a read/write buffer on a UnicodeString object with an\n   * \"open\" getBuffer(minCapacity).\n   * This function must be called in a matched pair with getBuffer(minCapacity).\n   * releaseBuffer(newLength) must be called if and only if a getBuffer(minCapacity) is \"open\".\n   *\n   * It will set the string length to newLength, at most to the current capacity.\n   * If newLength==-1 then it will set the length according to the\n   * first NUL in the buffer, or to the capacity if there is no NUL.\n   *\n   * After calling releaseBuffer(newLength) the UnicodeString is back to normal operation.\n   *\n   * @param newLength the new length of the UnicodeString object;\n   *        defaults to the current capacity if newLength is greater than that;\n   *        if newLength==-1, it defaults to u_strlen(buffer) but not more than\n   *        the current capacity of the string\n   *\n   * @see getBuffer(int32_t minCapacity)\n   * @stable ICU 2.0\n   */\n  void releaseBuffer(int32_t newLength=-1);\n\n  /**\n   * Get a read-only pointer to the internal buffer.\n   * This can be called at any time on a valid UnicodeString.\n   *\n   * It returns 0 if the string is bogus, or\n   * during an \"open\" getBuffer(minCapacity).\n   *\n   * It can be called as many times as desired.\n   * The pointer that it returns will remain valid until the UnicodeString object is modified,\n   * at which time the pointer is semantically invalidated and must not be used any more.\n   *\n   * The capacity of the buffer can be determined with getCapacity().\n   * The part after length() may or may not be initialized and valid,\n   * depending on the history of the UnicodeString object.\n   *\n   * The buffer contents is (probably) not NUL-terminated.\n   * You can check if it is with\n   * <code>(s.length()<s.getCapacity() && buffer[s.length()]==0)</code>.\n   * (See getTerminatedBuffer().)\n   *\n   * The buffer may reside in read-only memory. Its contents must not\n   * be modified.\n   *\n   * @return a read-only pointer to the internal string buffer,\n   *         or 0 if the string is empty or bogus\n   *\n   * @see getBuffer(int32_t minCapacity)\n   * @see getTerminatedBuffer()\n   * @stable ICU 2.0\n   */\n  inline const UChar *getBuffer() const;\n\n  /**\n   * Get a read-only pointer to the internal buffer,\n   * making sure that it is NUL-terminated.\n   * This can be called at any time on a valid UnicodeString.\n   *\n   * It returns 0 if the string is bogus, or\n   * during an \"open\" getBuffer(minCapacity), or if the buffer cannot\n   * be NUL-terminated (because memory allocation failed).\n   *\n   * It can be called as many times as desired.\n   * The pointer that it returns will remain valid until the UnicodeString object is modified,\n   * at which time the pointer is semantically invalidated and must not be used any more.\n   *\n   * The capacity of the buffer can be determined with getCapacity().\n   * The part after length()+1 may or may not be initialized and valid,\n   * depending on the history of the UnicodeString object.\n   *\n   * The buffer contents is guaranteed to be NUL-terminated.\n   * getTerminatedBuffer() may reallocate the buffer if a terminating NUL\n   * is written.\n   * For this reason, this function is not const, unlike getBuffer().\n   * Note that a UnicodeString may also contain NUL characters as part of its contents.\n   *\n   * The buffer may reside in read-only memory. Its contents must not\n   * be modified.\n   *\n   * @return a read-only pointer to the internal string buffer,\n   *         or 0 if the string is empty or bogus\n   *\n   * @see getBuffer(int32_t minCapacity)\n   * @see getBuffer()\n   * @stable ICU 2.2\n   */\n  inline const UChar *getTerminatedBuffer();\n\n  //========================================\n  // Constructors\n  //========================================\n\n  /** Construct an empty UnicodeString.\n   * @stable ICU 2.0\n   */\n  UnicodeString();\n\n  /**\n   * Construct a UnicodeString with capacity to hold <TT>capacity</TT> UChars\n   * @param capacity the number of UChars this UnicodeString should hold\n   * before a resize is necessary; if count is greater than 0 and count\n   * code points c take up more space than capacity, then capacity is adjusted\n   * accordingly.\n   * @param c is used to initially fill the string\n   * @param count specifies how many code points c are to be written in the\n   *              string\n   * @stable ICU 2.0\n   */\n  UnicodeString(int32_t capacity, UChar32 c, int32_t count);\n\n  /**\n   * Single UChar (code unit) constructor.\n   *\n   * It is recommended to mark this constructor \"explicit\" by\n   * <code>-DUNISTR_FROM_CHAR_EXPLICIT=explicit</code>\n   * on the compiler command line or similar.\n   * @param ch the character to place in the UnicodeString\n   * @stable ICU 2.0\n   */\n  UNISTR_FROM_CHAR_EXPLICIT UnicodeString(UChar ch);\n\n  /**\n   * Single UChar32 (code point) constructor.\n   *\n   * It is recommended to mark this constructor \"explicit\" by\n   * <code>-DUNISTR_FROM_CHAR_EXPLICIT=explicit</code>\n   * on the compiler command line or similar.\n   * @param ch the character to place in the UnicodeString\n   * @stable ICU 2.0\n   */\n  UNISTR_FROM_CHAR_EXPLICIT UnicodeString(UChar32 ch);\n\n  /**\n   * UChar* constructor.\n   *\n   * It is recommended to mark this constructor \"explicit\" by\n   * <code>-DUNISTR_FROM_STRING_EXPLICIT=explicit</code>\n   * on the compiler command line or similar.\n   * @param text The characters to place in the UnicodeString.  <TT>text</TT>\n   * must be NULL (U+0000) terminated.\n   * @stable ICU 2.0\n   */\n  UNISTR_FROM_STRING_EXPLICIT UnicodeString(const UChar *text);\n\n  /**\n   * UChar* constructor.\n   * @param text The characters to place in the UnicodeString.\n   * @param textLength The number of Unicode characters in <TT>text</TT>\n   * to copy.\n   * @stable ICU 2.0\n   */\n  UnicodeString(const UChar *text,\n        int32_t textLength);\n\n  /**\n   * Readonly-aliasing UChar* constructor.\n   * The text will be used for the UnicodeString object, but\n   * it will not be released when the UnicodeString is destroyed.\n   * This has copy-on-write semantics:\n   * When the string is modified, then the buffer is first copied into\n   * newly allocated memory.\n   * The aliased buffer is never modified.\n   *\n   * In an assignment to another UnicodeString, when using the copy constructor\n   * or the assignment operator, the text will be copied.\n   * When using fastCopyFrom(), the text will be aliased again,\n   * so that both strings then alias the same readonly-text.\n   *\n   * @param isTerminated specifies if <code>text</code> is <code>NUL</code>-terminated.\n   *                     This must be true if <code>textLength==-1</code>.\n   * @param text The characters to alias for the UnicodeString.\n   * @param textLength The number of Unicode characters in <code>text</code> to alias.\n   *                   If -1, then this constructor will determine the length\n   *                   by calling <code>u_strlen()</code>.\n   * @stable ICU 2.0\n   */\n  UnicodeString(UBool isTerminated,\n                const UChar *text,\n                int32_t textLength);\n\n  /**\n   * Writable-aliasing UChar* constructor.\n   * The text will be used for the UnicodeString object, but\n   * it will not be released when the UnicodeString is destroyed.\n   * This has write-through semantics:\n   * For as long as the capacity of the buffer is sufficient, write operations\n   * will directly affect the buffer. When more capacity is necessary, then\n   * a new buffer will be allocated and the contents copied as with regularly\n   * constructed strings.\n   * In an assignment to another UnicodeString, the buffer will be copied.\n   * The extract(UChar *dst) function detects whether the dst pointer is the same\n   * as the string buffer itself and will in this case not copy the contents.\n   *\n   * @param buffer The characters to alias for the UnicodeString.\n   * @param buffLength The number of Unicode characters in <code>buffer</code> to alias.\n   * @param buffCapacity The size of <code>buffer</code> in UChars.\n   * @stable ICU 2.0\n   */\n  UnicodeString(UChar *buffer, int32_t buffLength, int32_t buffCapacity);\n\n#if U_CHARSET_IS_UTF8 || !UCONFIG_NO_CONVERSION\n\n  /**\n   * char* constructor.\n   * Uses the default converter (and thus depends on the ICU conversion code)\n   * unless U_CHARSET_IS_UTF8 is set to 1.\n   *\n   * For ASCII (really \"invariant character\") strings it is more efficient to use\n   * the constructor that takes a US_INV (for its enum EInvariant).\n   * For ASCII (invariant-character) string literals, see UNICODE_STRING and\n   * UNICODE_STRING_SIMPLE.\n   *\n   * It is recommended to mark this constructor \"explicit\" by\n   * <code>-DUNISTR_FROM_STRING_EXPLICIT=explicit</code>\n   * on the compiler command line or similar.\n   * @param codepageData an array of bytes, null-terminated,\n   *                     in the platform's default codepage.\n   * @stable ICU 2.0\n   * @see UNICODE_STRING\n   * @see UNICODE_STRING_SIMPLE\n   */\n  UNISTR_FROM_STRING_EXPLICIT UnicodeString(const char *codepageData);\n\n  /**\n   * char* constructor.\n   * Uses the default converter (and thus depends on the ICU conversion code)\n   * unless U_CHARSET_IS_UTF8 is set to 1.\n   * @param codepageData an array of bytes in the platform's default codepage.\n   * @param dataLength The number of bytes in <TT>codepageData</TT>.\n   * @stable ICU 2.0\n   */\n  UnicodeString(const char *codepageData, int32_t dataLength);\n\n#endif\n\n#if !UCONFIG_NO_CONVERSION\n\n  /**\n   * char* constructor.\n   * @param codepageData an array of bytes, null-terminated\n   * @param codepage the encoding of <TT>codepageData</TT>.  The special\n   * value 0 for <TT>codepage</TT> indicates that the text is in the\n   * platform's default codepage.\n   *\n   * If <code>codepage</code> is an empty string (<code>\"\"</code>),\n   * then a simple conversion is performed on the codepage-invariant\n   * subset (\"invariant characters\") of the platform encoding. See utypes.h.\n   * Recommendation: For invariant-character strings use the constructor\n   * UnicodeString(const char *src, int32_t length, enum EInvariant inv)\n   * because it avoids object code dependencies of UnicodeString on\n   * the conversion code.\n   *\n   * @stable ICU 2.0\n   */\n  UnicodeString(const char *codepageData, const char *codepage);\n\n  /**\n   * char* constructor.\n   * @param codepageData an array of bytes.\n   * @param dataLength The number of bytes in <TT>codepageData</TT>.\n   * @param codepage the encoding of <TT>codepageData</TT>.  The special\n   * value 0 for <TT>codepage</TT> indicates that the text is in the\n   * platform's default codepage.\n   * If <code>codepage</code> is an empty string (<code>\"\"</code>),\n   * then a simple conversion is performed on the codepage-invariant\n   * subset (\"invariant characters\") of the platform encoding. See utypes.h.\n   * Recommendation: For invariant-character strings use the constructor\n   * UnicodeString(const char *src, int32_t length, enum EInvariant inv)\n   * because it avoids object code dependencies of UnicodeString on\n   * the conversion code.\n   *\n   * @stable ICU 2.0\n   */\n  UnicodeString(const char *codepageData, int32_t dataLength, const char *codepage);\n\n  /**\n   * char * / UConverter constructor.\n   * This constructor uses an existing UConverter object to\n   * convert the codepage string to Unicode and construct a UnicodeString\n   * from that.\n   *\n   * The converter is reset at first.\n   * If the error code indicates a failure before this constructor is called,\n   * or if an error occurs during conversion or construction,\n   * then the string will be bogus.\n   *\n   * This function avoids the overhead of opening and closing a converter if\n   * multiple strings are constructed.\n   *\n   * @param src input codepage string\n   * @param srcLength length of the input string, can be -1 for NUL-terminated strings\n   * @param cnv converter object (ucnv_resetToUnicode() will be called),\n   *        can be NULL for the default converter\n   * @param errorCode normal ICU error code\n   * @stable ICU 2.0\n   */\n  UnicodeString(\n        const char *src, int32_t srcLength,\n        UConverter *cnv,\n        UErrorCode &errorCode);\n\n#endif\n\n  /**\n   * Constructs a Unicode string from an invariant-character char * string.\n   * About invariant characters see utypes.h.\n   * This constructor has no runtime dependency on conversion code and is\n   * therefore recommended over ones taking a charset name string\n   * (where the empty string \"\" indicates invariant-character conversion).\n   *\n   * Use the macro US_INV as the third, signature-distinguishing parameter.\n   *\n   * For example:\n   * \\code\n   * void fn(const char *s) {\n   *   UnicodeString ustr(s, -1, US_INV);\n   *   // use ustr ...\n   * }\n   * \\endcode\n   *\n   * @param src String using only invariant characters.\n   * @param length Length of src, or -1 if NUL-terminated.\n   * @param inv Signature-distinguishing paramater, use US_INV.\n   *\n   * @see US_INV\n   * @stable ICU 3.2\n   */\n  UnicodeString(const char *src, int32_t length, enum EInvariant inv);\n\n\n  /**\n   * Copy constructor.\n   * @param that The UnicodeString object to copy.\n   * @stable ICU 2.0\n   */\n  UnicodeString(const UnicodeString& that);\n\n  /**\n   * 'Substring' constructor from tail of source string.\n   * @param src The UnicodeString object to copy.\n   * @param srcStart The offset into <tt>src</tt> at which to start copying.\n   * @stable ICU 2.2\n   */\n  UnicodeString(const UnicodeString& src, int32_t srcStart);\n\n  /**\n   * 'Substring' constructor from subrange of source string.\n   * @param src The UnicodeString object to copy.\n   * @param srcStart The offset into <tt>src</tt> at which to start copying.\n   * @param srcLength The number of characters from <tt>src</tt> to copy.\n   * @stable ICU 2.2\n   */\n  UnicodeString(const UnicodeString& src, int32_t srcStart, int32_t srcLength);\n\n  /**\n   * Clone this object, an instance of a subclass of Replaceable.\n   * Clones can be used concurrently in multiple threads.\n   * If a subclass does not implement clone(), or if an error occurs,\n   * then NULL is returned.\n   * The clone functions in all subclasses return a pointer to a Replaceable\n   * because some compilers do not support covariant (same-as-this)\n   * return types; cast to the appropriate subclass if necessary.\n   * The caller must delete the clone.\n   *\n   * @return a clone of this object\n   *\n   * @see Replaceable::clone\n   * @see getDynamicClassID\n   * @stable ICU 2.6\n   */\n  virtual Replaceable *clone() const;\n\n  /** Destructor.\n   * @stable ICU 2.0\n   */\n  virtual ~UnicodeString();\n\n  /**\n   * Create a UnicodeString from a UTF-8 string.\n   * Illegal input is replaced with U+FFFD. Otherwise, errors result in a bogus string.\n   * Calls u_strFromUTF8WithSub().\n   *\n   * @param utf8 UTF-8 input string.\n   *             Note that a StringPiece can be implicitly constructed\n   *             from a std::string or a NUL-terminated const char * string.\n   * @return A UnicodeString with equivalent UTF-16 contents.\n   * @see toUTF8\n   * @see toUTF8String\n   * @stable ICU 4.2\n   */\n  static UnicodeString fromUTF8(const StringPiece &utf8);\n\n  /**\n   * Create a UnicodeString from a UTF-32 string.\n   * Illegal input is replaced with U+FFFD. Otherwise, errors result in a bogus string.\n   * Calls u_strFromUTF32WithSub().\n   *\n   * @param utf32 UTF-32 input string. Must not be NULL.\n   * @param length Length of the input string, or -1 if NUL-terminated.\n   * @return A UnicodeString with equivalent UTF-16 contents.\n   * @see toUTF32\n   * @stable ICU 4.2\n   */\n  static UnicodeString fromUTF32(const UChar32 *utf32, int32_t length);\n\n  /* Miscellaneous operations */\n\n  /**\n   * Unescape a string of characters and return a string containing\n   * the result.  The following escape sequences are recognized:\n   *\n   * \\\\uhhhh       4 hex digits; h in [0-9A-Fa-f]\n   * \\\\Uhhhhhhhh   8 hex digits\n   * \\\\xhh         1-2 hex digits\n   * \\\\ooo         1-3 octal digits; o in [0-7]\n   * \\\\cX          control-X; X is masked with 0x1F\n   *\n   * as well as the standard ANSI C escapes:\n   *\n   * \\\\a => U+0007, \\\\b => U+0008, \\\\t => U+0009, \\\\n => U+000A,\n   * \\\\v => U+000B, \\\\f => U+000C, \\\\r => U+000D, \\\\e => U+001B,\n   * \\\\&quot; => U+0022, \\\\' => U+0027, \\\\? => U+003F, \\\\\\\\ => U+005C\n   *\n   * Anything else following a backslash is generically escaped.  For\n   * example, \"[a\\\\-z]\" returns \"[a-z]\".\n   *\n   * If an escape sequence is ill-formed, this method returns an empty\n   * string.  An example of an ill-formed sequence is \"\\\\u\" followed by\n   * fewer than 4 hex digits.\n   *\n   * This function is similar to u_unescape() but not identical to it.\n   * The latter takes a source char*, so it does escape recognition\n   * and also invariant conversion.\n   *\n   * @return a string with backslash escapes interpreted, or an\n   * empty string on error.\n   * @see UnicodeString#unescapeAt()\n   * @see u_unescape()\n   * @see u_unescapeAt()\n   * @stable ICU 2.0\n   */\n  UnicodeString unescape() const;\n\n  /**\n   * Unescape a single escape sequence and return the represented\n   * character.  See unescape() for a listing of the recognized escape\n   * sequences.  The character at offset-1 is assumed (without\n   * checking) to be a backslash.  If the escape sequence is\n   * ill-formed, or the offset is out of range, (UChar32)0xFFFFFFFF is\n   * returned.\n   *\n   * @param offset an input output parameter.  On input, it is the\n   * offset into this string where the escape sequence is located,\n   * after the initial backslash.  On output, it is advanced after the\n   * last character parsed.  On error, it is not advanced at all.\n   * @return the character represented by the escape sequence at\n   * offset, or (UChar32)0xFFFFFFFF on error.\n   * @see UnicodeString#unescape()\n   * @see u_unescape()\n   * @see u_unescapeAt()\n   * @stable ICU 2.0\n   */\n  UChar32 unescapeAt(int32_t &offset) const;\n\n  /**\n   * ICU \"poor man's RTTI\", returns a UClassID for this class.\n   *\n   * @stable ICU 2.2\n   */\n  static UClassID U_EXPORT2 getStaticClassID();\n\n  /**\n   * ICU \"poor man's RTTI\", returns a UClassID for the actual class.\n   *\n   * @stable ICU 2.2\n   */\n  virtual UClassID getDynamicClassID() const;\n\n  //========================================\n  // Implementation methods\n  //========================================\n\nprotected:\n  /**\n   * Implement Replaceable::getLength() (see jitterbug 1027).\n   * @stable ICU 2.4\n   */\n  virtual int32_t getLength() const;\n\n  /**\n   * The change in Replaceable to use virtual getCharAt() allows\n   * UnicodeString::charAt() to be inline again (see jitterbug 709).\n   * @stable ICU 2.4\n   */\n  virtual UChar getCharAt(int32_t offset) const;\n\n  /**\n   * The change in Replaceable to use virtual getChar32At() allows\n   * UnicodeString::char32At() to be inline again (see jitterbug 709).\n   * @stable ICU 2.4\n   */\n  virtual UChar32 getChar32At(int32_t offset) const;\n\nprivate:\n  // For char* constructors. Could be made public.\n  UnicodeString &setToUTF8(const StringPiece &utf8);\n  // For extract(char*).\n  // We could make a toUTF8(target, capacity, errorCode) public but not\n  // this version: New API will be cleaner if we make callers create substrings\n  // rather than having start+length on every method,\n  // and it should take a UErrorCode&.\n  int32_t\n  toUTF8(int32_t start, int32_t len,\n         char *target, int32_t capacity) const;\n\n  /**\n   * Internal string contents comparison, called by operator==.\n   * Requires: this & text not bogus and have same lengths.\n   */\n  UBool doEquals(const UnicodeString &text, int32_t len) const;\n\n  inline int8_t\n  doCompare(int32_t start,\n           int32_t length,\n           const UnicodeString& srcText,\n           int32_t srcStart,\n           int32_t srcLength) const;\n\n  int8_t doCompare(int32_t start,\n           int32_t length,\n           const UChar *srcChars,\n           int32_t srcStart,\n           int32_t srcLength) const;\n\n  inline int8_t\n  doCompareCodePointOrder(int32_t start,\n                          int32_t length,\n                          const UnicodeString& srcText,\n                          int32_t srcStart,\n                          int32_t srcLength) const;\n\n  int8_t doCompareCodePointOrder(int32_t start,\n                                 int32_t length,\n                                 const UChar *srcChars,\n                                 int32_t srcStart,\n                                 int32_t srcLength) const;\n\n  inline int8_t\n  doCaseCompare(int32_t start,\n                int32_t length,\n                const UnicodeString &srcText,\n                int32_t srcStart,\n                int32_t srcLength,\n                uint32_t options) const;\n\n  int8_t\n  doCaseCompare(int32_t start,\n                int32_t length,\n                const UChar *srcChars,\n                int32_t srcStart,\n                int32_t srcLength,\n                uint32_t options) const;\n\n  int32_t doIndexOf(UChar c,\n            int32_t start,\n            int32_t length) const;\n\n  int32_t doIndexOf(UChar32 c,\n                        int32_t start,\n                        int32_t length) const;\n\n  int32_t doLastIndexOf(UChar c,\n                int32_t start,\n                int32_t length) const;\n\n  int32_t doLastIndexOf(UChar32 c,\n                            int32_t start,\n                            int32_t length) const;\n\n  void doExtract(int32_t start,\n         int32_t length,\n         UChar *dst,\n         int32_t dstStart) const;\n\n  inline void doExtract(int32_t start,\n         int32_t length,\n         UnicodeString& target) const;\n\n  inline UChar doCharAt(int32_t offset)  const;\n\n  UnicodeString& doReplace(int32_t start,\n               int32_t length,\n               const UnicodeString& srcText,\n               int32_t srcStart,\n               int32_t srcLength);\n\n  UnicodeString& doReplace(int32_t start,\n               int32_t length,\n               const UChar *srcChars,\n               int32_t srcStart,\n               int32_t srcLength);\n\n  UnicodeString& doReverse(int32_t start,\n               int32_t length);\n\n  // calculate hash code\n  int32_t doHashCode(void) const;\n\n  // get pointer to start of array\n  // these do not check for kOpenGetBuffer, unlike the public getBuffer() function\n  inline UChar* getArrayStart(void);\n  inline const UChar* getArrayStart(void) const;\n\n  // A UnicodeString object (not necessarily its current buffer)\n  // is writable unless it isBogus() or it has an \"open\" getBuffer(minCapacity).\n  inline UBool isWritable() const;\n\n  // Is the current buffer writable?\n  inline UBool isBufferWritable() const;\n\n  // None of the following does releaseArray().\n  inline void setLength(int32_t len);        // sets only fShortLength and fLength\n  inline void setToEmpty();                  // sets fFlags=kShortString\n  inline void setArray(UChar *array, int32_t len, int32_t capacity); // does not set fFlags\n\n  // allocate the array; result may be fStackBuffer\n  // sets refCount to 1 if appropriate\n  // sets fArray, fCapacity, and fFlags\n  // returns boolean for success or failure\n  UBool allocate(int32_t capacity);\n\n  // release the array if owned\n  void releaseArray(void);\n\n  // turn a bogus string into an empty one\n  void unBogus();\n\n  // implements assigment operator, copy constructor, and fastCopyFrom()\n  UnicodeString &copyFrom(const UnicodeString &src, UBool fastCopy=FALSE);\n\n  // Pin start and limit to acceptable values.\n  inline void pinIndex(int32_t& start) const;\n  inline void pinIndices(int32_t& start,\n                         int32_t& length) const;\n\n#if !UCONFIG_NO_CONVERSION\n\n  /* Internal extract() using UConverter. */\n  int32_t doExtract(int32_t start, int32_t length,\n                    char *dest, int32_t destCapacity,\n                    UConverter *cnv,\n                    UErrorCode &errorCode) const;\n\n  /*\n   * Real constructor for converting from codepage data.\n   * It assumes that it is called with !fRefCounted.\n   *\n   * If <code>codepage==0</code>, then the default converter\n   * is used for the platform encoding.\n   * If <code>codepage</code> is an empty string (<code>\"\"</code>),\n   * then a simple conversion is performed on the codepage-invariant\n   * subset (\"invariant characters\") of the platform encoding. See utypes.h.\n   */\n  void doCodepageCreate(const char *codepageData,\n                        int32_t dataLength,\n                        const char *codepage);\n\n  /*\n   * Worker function for creating a UnicodeString from\n   * a codepage string using a UConverter.\n   */\n  void\n  doCodepageCreate(const char *codepageData,\n                   int32_t dataLength,\n                   UConverter *converter,\n                   UErrorCode &status);\n\n#endif\n\n  /*\n   * This function is called when write access to the array\n   * is necessary.\n   *\n   * We need to make a copy of the array if\n   * the buffer is read-only, or\n   * the buffer is refCounted (shared), and refCount>1, or\n   * the buffer is too small.\n   *\n   * Return FALSE if memory could not be allocated.\n   */\n  UBool cloneArrayIfNeeded(int32_t newCapacity = -1,\n                            int32_t growCapacity = -1,\n                            UBool doCopyArray = TRUE,\n                            int32_t **pBufferToDelete = 0,\n                            UBool forceClone = FALSE);\n\n  /**\n   * Common function for UnicodeString case mappings.\n   * The stringCaseMapper has the same type UStringCaseMapper\n   * as in ustr_imp.h for ustrcase_map().\n   */\n  UnicodeString &\n  caseMap(const UCaseMap *csm, UStringCaseMapper *stringCaseMapper);\n\n  // ref counting\n  void addRef(void);\n  int32_t removeRef(void);\n  int32_t refCount(void) const;\n\n  // constants\n  enum {\n    // Set the stack buffer size so that sizeof(UnicodeString) is,\n    // naturally (without padding), a multiple of sizeof(pointer).\n    US_STACKBUF_SIZE= sizeof(void *)==4 ? 13 : 15, // Size of stack buffer for short strings\n    kInvalidUChar=0xffff, // invalid UChar index\n    kGrowSize=128, // grow size for this buffer\n    kInvalidHashCode=0, // invalid hash code\n    kEmptyHashCode=1, // hash code for empty string\n\n    // bit flag values for fFlags\n    kIsBogus=1,         // this string is bogus, i.e., not valid or NULL\n    kUsingStackBuffer=2,// using fUnion.fStackBuffer instead of fUnion.fFields\n    kRefCounted=4,      // there is a refCount field before the characters in fArray\n    kBufferIsReadonly=8,// do not write to this buffer\n    kOpenGetBuffer=16,  // getBuffer(minCapacity) was called (is \"open\"),\n                        // and releaseBuffer(newLength) must be called\n\n    // combined values for convenience\n    kShortString=kUsingStackBuffer,\n    kLongString=kRefCounted,\n    kReadonlyAlias=kBufferIsReadonly,\n    kWritableAlias=0\n  };\n\n  friend class StringThreadTest;\n  friend class UnicodeStringAppendable;\n\n  union StackBufferOrFields;        // forward declaration necessary before friend declaration\n  friend union StackBufferOrFields; // make US_STACKBUF_SIZE visible inside fUnion\n\n  /*\n   * The following are all the class fields that are stored\n   * in each UnicodeString object.\n   * Note that UnicodeString has virtual functions,\n   * therefore there is an implicit vtable pointer\n   * as the first real field.\n   * The fields should be aligned such that no padding is necessary.\n   * On 32-bit machines, the size should be 32 bytes,\n   * on 64-bit machines (8-byte pointers), it should be 40 bytes.\n   *\n   * We use a hack to achieve this.\n   *\n   * With at least some compilers, each of the following is forced to\n   * a multiple of sizeof(pointer) [the largest field base unit here is a data pointer],\n   * rounded up with additional padding if the fields do not already fit that requirement:\n   * - sizeof(class UnicodeString)\n   * - offsetof(UnicodeString, fUnion)\n   * - sizeof(fUnion)\n   * - sizeof(fFields)\n   *\n   * In order to avoid padding, we make sizeof(fStackBuffer)=16 (=8 UChars)\n   * which is at least as large as sizeof(fFields) on 32-bit and 64-bit machines.\n   * (Padding at the end of fFields is ok:\n   * As long as there is no padding after fStackBuffer, it is not wasted space.)\n   *\n   * We further assume that the compiler does not reorder the fields,\n   * so that fRestOfStackBuffer (which holds a few more UChars) immediately follows after fUnion,\n   * with at most some padding (but no other field) in between.\n   * (Padding there would be wasted space, but functionally harmless.)\n   *\n   * We use a few more sizeof(pointer)'s chunks of space with\n   * fRestOfStackBuffer, fShortLength and fFlags,\n   * to get up exactly to the intended sizeof(UnicodeString).\n   */\n  // (implicit) *vtable;\n  union StackBufferOrFields {\n    // fStackBuffer is used iff (fFlags&kUsingStackBuffer)\n    // else fFields is used\n    UChar fStackBuffer[8];  // buffer for short strings, together with fRestOfStackBuffer\n    struct {\n      UChar   *fArray;    // the Unicode data\n      int32_t fCapacity;  // capacity of fArray (in UChars)\n      int32_t fLength;    // number of characters in fArray if >127; else undefined\n    } fFields;\n  } fUnion;\n  UChar fRestOfStackBuffer[US_STACKBUF_SIZE-8];\n  int8_t fShortLength;  // 0..127: length  <0: real length is in fUnion.fFields.fLength\n  uint8_t fFlags;       // bit flags: see constants above\n};\n\n/**\n * Create a new UnicodeString with the concatenation of two others.\n *\n * @param s1 The first string to be copied to the new one.\n * @param s2 The second string to be copied to the new one, after s1.\n * @return UnicodeString(s1).append(s2)\n * @stable ICU 2.8\n */\nU_COMMON_API UnicodeString U_EXPORT2\noperator+ (const UnicodeString &s1, const UnicodeString &s2);\n\n//========================================\n// Inline members\n//========================================\n\n//========================================\n// Privates\n//========================================\n\ninline void\nUnicodeString::pinIndex(int32_t& start) const\n{\n  // pin index\n  if(start < 0) {\n    start = 0;\n  } else if(start > length()) {\n    start = length();\n  }\n}\n\ninline void\nUnicodeString::pinIndices(int32_t& start,\n                          int32_t& _length) const\n{\n  // pin indices\n  int32_t len = length();\n  if(start < 0) {\n    start = 0;\n  } else if(start > len) {\n    start = len;\n  }\n  if(_length < 0) {\n    _length = 0;\n  } else if(_length > (len - start)) {\n    _length = (len - start);\n  }\n}\n\ninline UChar*\nUnicodeString::getArrayStart()\n{ return (fFlags&kUsingStackBuffer) ? fUnion.fStackBuffer : fUnion.fFields.fArray; }\n\ninline const UChar*\nUnicodeString::getArrayStart() const\n{ return (fFlags&kUsingStackBuffer) ? fUnion.fStackBuffer : fUnion.fFields.fArray; }\n\n//========================================\n// Read-only implementation methods\n//========================================\ninline int32_t\nUnicodeString::length() const\n{ return fShortLength>=0 ? fShortLength : fUnion.fFields.fLength; }\n\ninline int32_t\nUnicodeString::getCapacity() const\n{ return (fFlags&kUsingStackBuffer) ? US_STACKBUF_SIZE : fUnion.fFields.fCapacity; }\n\ninline int32_t\nUnicodeString::hashCode() const\n{ return doHashCode(); }\n\ninline UBool\nUnicodeString::isBogus() const\n{ return (UBool)(fFlags & kIsBogus); }\n\ninline UBool\nUnicodeString::isWritable() const\n{ return (UBool)!(fFlags&(kOpenGetBuffer|kIsBogus)); }\n\ninline UBool\nUnicodeString::isBufferWritable() const\n{\n  return (UBool)(\n      !(fFlags&(kOpenGetBuffer|kIsBogus|kBufferIsReadonly)) &&\n      (!(fFlags&kRefCounted) || refCount()==1));\n}\n\ninline const UChar *\nUnicodeString::getBuffer() const {\n  if(fFlags&(kIsBogus|kOpenGetBuffer)) {\n    return 0;\n  } else if(fFlags&kUsingStackBuffer) {\n    return fUnion.fStackBuffer;\n  } else {\n    return fUnion.fFields.fArray;\n  }\n}\n\n//========================================\n// Read-only alias methods\n//========================================\ninline int8_t\nUnicodeString::doCompare(int32_t start,\n              int32_t thisLength,\n              const UnicodeString& srcText,\n              int32_t srcStart,\n              int32_t srcLength) const\n{\n  if(srcText.isBogus()) {\n    return (int8_t)!isBogus(); // 0 if both are bogus, 1 otherwise\n  } else {\n    srcText.pinIndices(srcStart, srcLength);\n    return doCompare(start, thisLength, srcText.getArrayStart(), srcStart, srcLength);\n  }\n}\n\ninline UBool\nUnicodeString::operator== (const UnicodeString& text) const\n{\n  if(isBogus()) {\n    return text.isBogus();\n  } else {\n    int32_t len = length(), textLength = text.length();\n    return !text.isBogus() && len == textLength && doEquals(text, len);\n  }\n}\n\ninline UBool\nUnicodeString::operator!= (const UnicodeString& text) const\n{ return (! operator==(text)); }\n\ninline UBool\nUnicodeString::operator> (const UnicodeString& text) const\n{ return doCompare(0, length(), text, 0, text.length()) == 1; }\n\ninline UBool\nUnicodeString::operator< (const UnicodeString& text) const\n{ return doCompare(0, length(), text, 0, text.length()) == -1; }\n\ninline UBool\nUnicodeString::operator>= (const UnicodeString& text) const\n{ return doCompare(0, length(), text, 0, text.length()) != -1; }\n\ninline UBool\nUnicodeString::operator<= (const UnicodeString& text) const\n{ return doCompare(0, length(), text, 0, text.length()) != 1; }\n\ninline int8_t\nUnicodeString::compare(const UnicodeString& text) const\n{ return doCompare(0, length(), text, 0, text.length()); }\n\ninline int8_t\nUnicodeString::compare(int32_t start,\n               int32_t _length,\n               const UnicodeString& srcText) const\n{ return doCompare(start, _length, srcText, 0, srcText.length()); }\n\ninline int8_t\nUnicodeString::compare(const UChar *srcChars,\n               int32_t srcLength) const\n{ return doCompare(0, length(), srcChars, 0, srcLength); }\n\ninline int8_t\nUnicodeString::compare(int32_t start,\n               int32_t _length,\n               const UnicodeString& srcText,\n               int32_t srcStart,\n               int32_t srcLength) const\n{ return doCompare(start, _length, srcText, srcStart, srcLength); }\n\ninline int8_t\nUnicodeString::compare(int32_t start,\n               int32_t _length,\n               const UChar *srcChars) const\n{ return doCompare(start, _length, srcChars, 0, _length); }\n\ninline int8_t\nUnicodeString::compare(int32_t start,\n               int32_t _length,\n               const UChar *srcChars,\n               int32_t srcStart,\n               int32_t srcLength) const\n{ return doCompare(start, _length, srcChars, srcStart, srcLength); }\n\ninline int8_t\nUnicodeString::compareBetween(int32_t start,\n                  int32_t limit,\n                  const UnicodeString& srcText,\n                  int32_t srcStart,\n                  int32_t srcLimit) const\n{ return doCompare(start, limit - start,\n           srcText, srcStart, srcLimit - srcStart); }\n\ninline int8_t\nUnicodeString::doCompareCodePointOrder(int32_t start,\n                                       int32_t thisLength,\n                                       const UnicodeString& srcText,\n                                       int32_t srcStart,\n                                       int32_t srcLength) const\n{\n  if(srcText.isBogus()) {\n    return (int8_t)!isBogus(); // 0 if both are bogus, 1 otherwise\n  } else {\n    srcText.pinIndices(srcStart, srcLength);\n    return doCompareCodePointOrder(start, thisLength, srcText.getArrayStart(), srcStart, srcLength);\n  }\n}\n\ninline int8_t\nUnicodeString::compareCodePointOrder(const UnicodeString& text) const\n{ return doCompareCodePointOrder(0, length(), text, 0, text.length()); }\n\ninline int8_t\nUnicodeString::compareCodePointOrder(int32_t start,\n                                     int32_t _length,\n                                     const UnicodeString& srcText) const\n{ return doCompareCodePointOrder(start, _length, srcText, 0, srcText.length()); }\n\ninline int8_t\nUnicodeString::compareCodePointOrder(const UChar *srcChars,\n                                     int32_t srcLength) const\n{ return doCompareCodePointOrder(0, length(), srcChars, 0, srcLength); }\n\ninline int8_t\nUnicodeString::compareCodePointOrder(int32_t start,\n                                     int32_t _length,\n                                     const UnicodeString& srcText,\n                                     int32_t srcStart,\n                                     int32_t srcLength) const\n{ return doCompareCodePointOrder(start, _length, srcText, srcStart, srcLength); }\n\ninline int8_t\nUnicodeString::compareCodePointOrder(int32_t start,\n                                     int32_t _length,\n                                     const UChar *srcChars) const\n{ return doCompareCodePointOrder(start, _length, srcChars, 0, _length); }\n\ninline int8_t\nUnicodeString::compareCodePointOrder(int32_t start,\n                                     int32_t _length,\n                                     const UChar *srcChars,\n                                     int32_t srcStart,\n                                     int32_t srcLength) const\n{ return doCompareCodePointOrder(start, _length, srcChars, srcStart, srcLength); }\n\ninline int8_t\nUnicodeString::compareCodePointOrderBetween(int32_t start,\n                                            int32_t limit,\n                                            const UnicodeString& srcText,\n                                            int32_t srcStart,\n                                            int32_t srcLimit) const\n{ return doCompareCodePointOrder(start, limit - start,\n           srcText, srcStart, srcLimit - srcStart); }\n\ninline int8_t\nUnicodeString::doCaseCompare(int32_t start,\n                             int32_t thisLength,\n                             const UnicodeString &srcText,\n                             int32_t srcStart,\n                             int32_t srcLength,\n                             uint32_t options) const\n{\n  if(srcText.isBogus()) {\n    return (int8_t)!isBogus(); // 0 if both are bogus, 1 otherwise\n  } else {\n    srcText.pinIndices(srcStart, srcLength);\n    return doCaseCompare(start, thisLength, srcText.getArrayStart(), srcStart, srcLength, options);\n  }\n}\n\ninline int8_t\nUnicodeString::caseCompare(const UnicodeString &text, uint32_t options) const {\n  return doCaseCompare(0, length(), text, 0, text.length(), options);\n}\n\ninline int8_t\nUnicodeString::caseCompare(int32_t start,\n                           int32_t _length,\n                           const UnicodeString &srcText,\n                           uint32_t options) const {\n  return doCaseCompare(start, _length, srcText, 0, srcText.length(), options);\n}\n\ninline int8_t\nUnicodeString::caseCompare(const UChar *srcChars,\n                           int32_t srcLength,\n                           uint32_t options) const {\n  return doCaseCompare(0, length(), srcChars, 0, srcLength, options);\n}\n\ninline int8_t\nUnicodeString::caseCompare(int32_t start,\n                           int32_t _length,\n                           const UnicodeString &srcText,\n                           int32_t srcStart,\n                           int32_t srcLength,\n                           uint32_t options) const {\n  return doCaseCompare(start, _length, srcText, srcStart, srcLength, options);\n}\n\ninline int8_t\nUnicodeString::caseCompare(int32_t start,\n                           int32_t _length,\n                           const UChar *srcChars,\n                           uint32_t options) const {\n  return doCaseCompare(start, _length, srcChars, 0, _length, options);\n}\n\ninline int8_t\nUnicodeString::caseCompare(int32_t start,\n                           int32_t _length,\n                           const UChar *srcChars,\n                           int32_t srcStart,\n                           int32_t srcLength,\n                           uint32_t options) const {\n  return doCaseCompare(start, _length, srcChars, srcStart, srcLength, options);\n}\n\ninline int8_t\nUnicodeString::caseCompareBetween(int32_t start,\n                                  int32_t limit,\n                                  const UnicodeString &srcText,\n                                  int32_t srcStart,\n                                  int32_t srcLimit,\n                                  uint32_t options) const {\n  return doCaseCompare(start, limit - start, srcText, srcStart, srcLimit - srcStart, options);\n}\n\ninline int32_t\nUnicodeString::indexOf(const UnicodeString& srcText,\n               int32_t srcStart,\n               int32_t srcLength,\n               int32_t start,\n               int32_t _length) const\n{\n  if(!srcText.isBogus()) {\n    srcText.pinIndices(srcStart, srcLength);\n    if(srcLength > 0) {\n      return indexOf(srcText.getArrayStart(), srcStart, srcLength, start, _length);\n    }\n  }\n  return -1;\n}\n\ninline int32_t\nUnicodeString::indexOf(const UnicodeString& text) const\n{ return indexOf(text, 0, text.length(), 0, length()); }\n\ninline int32_t\nUnicodeString::indexOf(const UnicodeString& text,\n               int32_t start) const {\n  pinIndex(start);\n  return indexOf(text, 0, text.length(), start, length() - start);\n}\n\ninline int32_t\nUnicodeString::indexOf(const UnicodeString& text,\n               int32_t start,\n               int32_t _length) const\n{ return indexOf(text, 0, text.length(), start, _length); }\n\ninline int32_t\nUnicodeString::indexOf(const UChar *srcChars,\n               int32_t srcLength,\n               int32_t start) const {\n  pinIndex(start);\n  return indexOf(srcChars, 0, srcLength, start, length() - start);\n}\n\ninline int32_t\nUnicodeString::indexOf(const UChar *srcChars,\n               int32_t srcLength,\n               int32_t start,\n               int32_t _length) const\n{ return indexOf(srcChars, 0, srcLength, start, _length); }\n\ninline int32_t\nUnicodeString::indexOf(UChar c,\n               int32_t start,\n               int32_t _length) const\n{ return doIndexOf(c, start, _length); }\n\ninline int32_t\nUnicodeString::indexOf(UChar32 c,\n               int32_t start,\n               int32_t _length) const\n{ return doIndexOf(c, start, _length); }\n\ninline int32_t\nUnicodeString::indexOf(UChar c) const\n{ return doIndexOf(c, 0, length()); }\n\ninline int32_t\nUnicodeString::indexOf(UChar32 c) const\n{ return indexOf(c, 0, length()); }\n\ninline int32_t\nUnicodeString::indexOf(UChar c,\n               int32_t start) const {\n  pinIndex(start);\n  return doIndexOf(c, start, length() - start);\n}\n\ninline int32_t\nUnicodeString::indexOf(UChar32 c,\n               int32_t start) const {\n  pinIndex(start);\n  return indexOf(c, start, length() - start);\n}\n\ninline int32_t\nUnicodeString::lastIndexOf(const UChar *srcChars,\n               int32_t srcLength,\n               int32_t start,\n               int32_t _length) const\n{ return lastIndexOf(srcChars, 0, srcLength, start, _length); }\n\ninline int32_t\nUnicodeString::lastIndexOf(const UChar *srcChars,\n               int32_t srcLength,\n               int32_t start) const {\n  pinIndex(start);\n  return lastIndexOf(srcChars, 0, srcLength, start, length() - start);\n}\n\ninline int32_t\nUnicodeString::lastIndexOf(const UnicodeString& srcText,\n               int32_t srcStart,\n               int32_t srcLength,\n               int32_t start,\n               int32_t _length) const\n{\n  if(!srcText.isBogus()) {\n    srcText.pinIndices(srcStart, srcLength);\n    if(srcLength > 0) {\n      return lastIndexOf(srcText.getArrayStart(), srcStart, srcLength, start, _length);\n    }\n  }\n  return -1;\n}\n\ninline int32_t\nUnicodeString::lastIndexOf(const UnicodeString& text,\n               int32_t start,\n               int32_t _length) const\n{ return lastIndexOf(text, 0, text.length(), start, _length); }\n\ninline int32_t\nUnicodeString::lastIndexOf(const UnicodeString& text,\n               int32_t start) const {\n  pinIndex(start);\n  return lastIndexOf(text, 0, text.length(), start, length() - start);\n}\n\ninline int32_t\nUnicodeString::lastIndexOf(const UnicodeString& text) const\n{ return lastIndexOf(text, 0, text.length(), 0, length()); }\n\ninline int32_t\nUnicodeString::lastIndexOf(UChar c,\n               int32_t start,\n               int32_t _length) const\n{ return doLastIndexOf(c, start, _length); }\n\ninline int32_t\nUnicodeString::lastIndexOf(UChar32 c,\n               int32_t start,\n               int32_t _length) const {\n  return doLastIndexOf(c, start, _length);\n}\n\ninline int32_t\nUnicodeString::lastIndexOf(UChar c) const\n{ return doLastIndexOf(c, 0, length()); }\n\ninline int32_t\nUnicodeString::lastIndexOf(UChar32 c) const {\n  return lastIndexOf(c, 0, length());\n}\n\ninline int32_t\nUnicodeString::lastIndexOf(UChar c,\n               int32_t start) const {\n  pinIndex(start);\n  return doLastIndexOf(c, start, length() - start);\n}\n\ninline int32_t\nUnicodeString::lastIndexOf(UChar32 c,\n               int32_t start) const {\n  pinIndex(start);\n  return lastIndexOf(c, start, length() - start);\n}\n\ninline UBool\nUnicodeString::startsWith(const UnicodeString& text) const\n{ return compare(0, text.length(), text, 0, text.length()) == 0; }\n\ninline UBool\nUnicodeString::startsWith(const UnicodeString& srcText,\n              int32_t srcStart,\n              int32_t srcLength) const\n{ return doCompare(0, srcLength, srcText, srcStart, srcLength) == 0; }\n\ninline UBool\nUnicodeString::startsWith(const UChar *srcChars, int32_t srcLength) const {\n  if(srcLength < 0) {\n    srcLength = u_strlen(srcChars);\n  }\n  return doCompare(0, srcLength, srcChars, 0, srcLength) == 0;\n}\n\ninline UBool\nUnicodeString::startsWith(const UChar *srcChars, int32_t srcStart, int32_t srcLength) const {\n  if(srcLength < 0) {\n    srcLength = u_strlen(srcChars);\n  }\n  return doCompare(0, srcLength, srcChars, srcStart, srcLength) == 0;\n}\n\ninline UBool\nUnicodeString::endsWith(const UnicodeString& text) const\n{ return doCompare(length() - text.length(), text.length(),\n           text, 0, text.length()) == 0; }\n\ninline UBool\nUnicodeString::endsWith(const UnicodeString& srcText,\n            int32_t srcStart,\n            int32_t srcLength) const {\n  srcText.pinIndices(srcStart, srcLength);\n  return doCompare(length() - srcLength, srcLength,\n                   srcText, srcStart, srcLength) == 0;\n}\n\ninline UBool\nUnicodeString::endsWith(const UChar *srcChars,\n            int32_t srcLength) const {\n  if(srcLength < 0) {\n    srcLength = u_strlen(srcChars);\n  }\n  return doCompare(length() - srcLength, srcLength,\n                   srcChars, 0, srcLength) == 0;\n}\n\ninline UBool\nUnicodeString::endsWith(const UChar *srcChars,\n            int32_t srcStart,\n            int32_t srcLength) const {\n  if(srcLength < 0) {\n    srcLength = u_strlen(srcChars + srcStart);\n  }\n  return doCompare(length() - srcLength, srcLength,\n                   srcChars, srcStart, srcLength) == 0;\n}\n\n//========================================\n// replace\n//========================================\ninline UnicodeString&\nUnicodeString::replace(int32_t start,\n               int32_t _length,\n               const UnicodeString& srcText)\n{ return doReplace(start, _length, srcText, 0, srcText.length()); }\n\ninline UnicodeString&\nUnicodeString::replace(int32_t start,\n               int32_t _length,\n               const UnicodeString& srcText,\n               int32_t srcStart,\n               int32_t srcLength)\n{ return doReplace(start, _length, srcText, srcStart, srcLength); }\n\ninline UnicodeString&\nUnicodeString::replace(int32_t start,\n               int32_t _length,\n               const UChar *srcChars,\n               int32_t srcLength)\n{ return doReplace(start, _length, srcChars, 0, srcLength); }\n\ninline UnicodeString&\nUnicodeString::replace(int32_t start,\n               int32_t _length,\n               const UChar *srcChars,\n               int32_t srcStart,\n               int32_t srcLength)\n{ return doReplace(start, _length, srcChars, srcStart, srcLength); }\n\ninline UnicodeString&\nUnicodeString::replace(int32_t start,\n               int32_t _length,\n               UChar srcChar)\n{ return doReplace(start, _length, &srcChar, 0, 1); }\n\ninline UnicodeString&\nUnicodeString::replaceBetween(int32_t start,\n                  int32_t limit,\n                  const UnicodeString& srcText)\n{ return doReplace(start, limit - start, srcText, 0, srcText.length()); }\n\ninline UnicodeString&\nUnicodeString::replaceBetween(int32_t start,\n                  int32_t limit,\n                  const UnicodeString& srcText,\n                  int32_t srcStart,\n                  int32_t srcLimit)\n{ return doReplace(start, limit - start, srcText, srcStart, srcLimit - srcStart); }\n\ninline UnicodeString&\nUnicodeString::findAndReplace(const UnicodeString& oldText,\n                  const UnicodeString& newText)\n{ return findAndReplace(0, length(), oldText, 0, oldText.length(),\n            newText, 0, newText.length()); }\n\ninline UnicodeString&\nUnicodeString::findAndReplace(int32_t start,\n                  int32_t _length,\n                  const UnicodeString& oldText,\n                  const UnicodeString& newText)\n{ return findAndReplace(start, _length, oldText, 0, oldText.length(),\n            newText, 0, newText.length()); }\n\n// ============================\n// extract\n// ============================\ninline void\nUnicodeString::doExtract(int32_t start,\n             int32_t _length,\n             UnicodeString& target) const\n{ target.replace(0, target.length(), *this, start, _length); }\n\ninline void\nUnicodeString::extract(int32_t start,\n               int32_t _length,\n               UChar *target,\n               int32_t targetStart) const\n{ doExtract(start, _length, target, targetStart); }\n\ninline void\nUnicodeString::extract(int32_t start,\n               int32_t _length,\n               UnicodeString& target) const\n{ doExtract(start, _length, target); }\n\n#if !UCONFIG_NO_CONVERSION\n\ninline int32_t\nUnicodeString::extract(int32_t start,\n               int32_t _length,\n               char *dst,\n               const char *codepage) const\n\n{\n  // This dstSize value will be checked explicitly\n  return extract(start, _length, dst, dst!=0 ? 0xffffffff : 0, codepage);\n}\n\n#endif\n\ninline void\nUnicodeString::extractBetween(int32_t start,\n                  int32_t limit,\n                  UChar *dst,\n                  int32_t dstStart) const {\n  pinIndex(start);\n  pinIndex(limit);\n  doExtract(start, limit - start, dst, dstStart);\n}\n\ninline UnicodeString\nUnicodeString::tempSubStringBetween(int32_t start, int32_t limit) const {\n    return tempSubString(start, limit - start);\n}\n\ninline UChar\nUnicodeString::doCharAt(int32_t offset) const\n{\n  if((uint32_t)offset < (uint32_t)length()) {\n    return getArrayStart()[offset];\n  } else {\n    return kInvalidUChar;\n  }\n}\n\ninline UChar\nUnicodeString::charAt(int32_t offset) const\n{ return doCharAt(offset); }\n\ninline UChar\nUnicodeString::operator[] (int32_t offset) const\n{ return doCharAt(offset); }\n\ninline UBool\nUnicodeString::isEmpty() const {\n  return fShortLength == 0;\n}\n\n//========================================\n// Write implementation methods\n//========================================\ninline void\nUnicodeString::setLength(int32_t len) {\n  if(len <= 127) {\n    fShortLength = (int8_t)len;\n  } else {\n    fShortLength = (int8_t)-1;\n    fUnion.fFields.fLength = len;\n  }\n}\n\ninline void\nUnicodeString::setToEmpty() {\n  fShortLength = 0;\n  fFlags = kShortString;\n}\n\ninline void\nUnicodeString::setArray(UChar *array, int32_t len, int32_t capacity) {\n  setLength(len);\n  fUnion.fFields.fArray = array;\n  fUnion.fFields.fCapacity = capacity;\n}\n\ninline const UChar *\nUnicodeString::getTerminatedBuffer() {\n  if(!isWritable()) {\n    return 0;\n  } else {\n    UChar *array = getArrayStart();\n    int32_t len = length();\n    if(len < getCapacity() && ((fFlags&kRefCounted) == 0 || refCount() == 1)) {\n      /*\n       * kRefCounted: Do not write the NUL if the buffer is shared.\n       * That is mostly safe, except when the length of one copy was modified\n       * without copy-on-write, e.g., via truncate(newLength) or remove(void).\n       * Then the NUL would be written into the middle of another copy's string.\n       */\n      if(!(fFlags&kBufferIsReadonly)) {\n        /*\n         * We must not write to a readonly buffer, but it is known to be\n         * NUL-terminated if len<capacity.\n         * A shared, allocated buffer (refCount()>1) must not have its contents\n         * modified, but the NUL at [len] is beyond the string contents,\n         * and multiple string objects and threads writing the same NUL into the\n         * same location is harmless.\n         * In all other cases, the buffer is fully writable and it is anyway safe\n         * to write the NUL.\n         *\n         * Note: An earlier version of this code tested whether there is a NUL\n         * at [len] already, but, while safe, it generated lots of warnings from\n         * tools like valgrind and Purify.\n         */\n        array[len] = 0;\n      }\n      return array;\n    } else if(cloneArrayIfNeeded(len+1)) {\n      array = getArrayStart();\n      array[len] = 0;\n      return array;\n    } else {\n      return 0;\n    }\n  }\n}\n\ninline UnicodeString&\nUnicodeString::operator= (UChar ch)\n{ return doReplace(0, length(), &ch, 0, 1); }\n\ninline UnicodeString&\nUnicodeString::operator= (UChar32 ch)\n{ return replace(0, length(), ch); }\n\ninline UnicodeString&\nUnicodeString::setTo(const UnicodeString& srcText,\n             int32_t srcStart,\n             int32_t srcLength)\n{\n  unBogus();\n  return doReplace(0, length(), srcText, srcStart, srcLength);\n}\n\ninline UnicodeString&\nUnicodeString::setTo(const UnicodeString& srcText,\n             int32_t srcStart)\n{\n  unBogus();\n  srcText.pinIndex(srcStart);\n  return doReplace(0, length(), srcText, srcStart, srcText.length() - srcStart);\n}\n\ninline UnicodeString&\nUnicodeString::setTo(const UnicodeString& srcText)\n{\n  return copyFrom(srcText);\n}\n\ninline UnicodeString&\nUnicodeString::setTo(const UChar *srcChars,\n             int32_t srcLength)\n{\n  unBogus();\n  return doReplace(0, length(), srcChars, 0, srcLength);\n}\n\ninline UnicodeString&\nUnicodeString::setTo(UChar srcChar)\n{\n  unBogus();\n  return doReplace(0, length(), &srcChar, 0, 1);\n}\n\ninline UnicodeString&\nUnicodeString::setTo(UChar32 srcChar)\n{\n  unBogus();\n  return replace(0, length(), srcChar);\n}\n\ninline UnicodeString&\nUnicodeString::append(const UnicodeString& srcText,\n              int32_t srcStart,\n              int32_t srcLength)\n{ return doReplace(length(), 0, srcText, srcStart, srcLength); }\n\ninline UnicodeString&\nUnicodeString::append(const UnicodeString& srcText)\n{ return doReplace(length(), 0, srcText, 0, srcText.length()); }\n\ninline UnicodeString&\nUnicodeString::append(const UChar *srcChars,\n              int32_t srcStart,\n              int32_t srcLength)\n{ return doReplace(length(), 0, srcChars, srcStart, srcLength); }\n\ninline UnicodeString&\nUnicodeString::append(const UChar *srcChars,\n              int32_t srcLength)\n{ return doReplace(length(), 0, srcChars, 0, srcLength); }\n\ninline UnicodeString&\nUnicodeString::append(UChar srcChar)\n{ return doReplace(length(), 0, &srcChar, 0, 1); }\n\ninline UnicodeString&\nUnicodeString::operator+= (UChar ch)\n{ return doReplace(length(), 0, &ch, 0, 1); }\n\ninline UnicodeString&\nUnicodeString::operator+= (UChar32 ch) {\n  return append(ch);\n}\n\ninline UnicodeString&\nUnicodeString::operator+= (const UnicodeString& srcText)\n{ return doReplace(length(), 0, srcText, 0, srcText.length()); }\n\ninline UnicodeString&\nUnicodeString::insert(int32_t start,\n              const UnicodeString& srcText,\n              int32_t srcStart,\n              int32_t srcLength)\n{ return doReplace(start, 0, srcText, srcStart, srcLength); }\n\ninline UnicodeString&\nUnicodeString::insert(int32_t start,\n              const UnicodeString& srcText)\n{ return doReplace(start, 0, srcText, 0, srcText.length()); }\n\ninline UnicodeString&\nUnicodeString::insert(int32_t start,\n              const UChar *srcChars,\n              int32_t srcStart,\n              int32_t srcLength)\n{ return doReplace(start, 0, srcChars, srcStart, srcLength); }\n\ninline UnicodeString&\nUnicodeString::insert(int32_t start,\n              const UChar *srcChars,\n              int32_t srcLength)\n{ return doReplace(start, 0, srcChars, 0, srcLength); }\n\ninline UnicodeString&\nUnicodeString::insert(int32_t start,\n              UChar srcChar)\n{ return doReplace(start, 0, &srcChar, 0, 1); }\n\ninline UnicodeString&\nUnicodeString::insert(int32_t start,\n              UChar32 srcChar)\n{ return replace(start, 0, srcChar); }\n\n\ninline UnicodeString&\nUnicodeString::remove()\n{\n  // remove() of a bogus string makes the string empty and non-bogus\n  // we also un-alias a read-only alias to deal with NUL-termination\n  // issues with getTerminatedBuffer()\n  if(fFlags & (kIsBogus|kBufferIsReadonly)) {\n    setToEmpty();\n  } else {\n    fShortLength = 0;\n  }\n  return *this;\n}\n\ninline UnicodeString&\nUnicodeString::remove(int32_t start,\n             int32_t _length)\n{\n    if(start <= 0 && _length == INT32_MAX) {\n        // remove(guaranteed everything) of a bogus string makes the string empty and non-bogus\n        return remove();\n    }\n    return doReplace(start, _length, NULL, 0, 0);\n}\n\ninline UnicodeString&\nUnicodeString::removeBetween(int32_t start,\n                int32_t limit)\n{ return doReplace(start, limit - start, NULL, 0, 0); }\n\ninline UnicodeString &\nUnicodeString::retainBetween(int32_t start, int32_t limit) {\n  truncate(limit);\n  return doReplace(0, start, NULL, 0, 0);\n}\n\ninline UBool\nUnicodeString::truncate(int32_t targetLength)\n{\n  if(isBogus() && targetLength == 0) {\n    // truncate(0) of a bogus string makes the string empty and non-bogus\n    unBogus();\n    return FALSE;\n  } else if((uint32_t)targetLength < (uint32_t)length()) {\n    setLength(targetLength);\n    if(fFlags&kBufferIsReadonly) {\n      fUnion.fFields.fCapacity = targetLength;  // not NUL-terminated any more\n    }\n    return TRUE;\n  } else {\n    return FALSE;\n  }\n}\n\ninline UnicodeString&\nUnicodeString::reverse()\n{ return doReverse(0, length()); }\n\ninline UnicodeString&\nUnicodeString::reverse(int32_t start,\n               int32_t _length)\n{ return doReverse(start, _length); }\n\nU_NAMESPACE_END\n\n#endif\n"
  },
  {
    "path": "deprecated/android/addons/icucompat/unicode/unorm.h",
    "content": "/*\n*******************************************************************************\n* Copyright (c) 1996-2010, International Business Machines Corporation\n*               and others. All Rights Reserved.\n*******************************************************************************\n* File unorm.h\n*\n* Created by: Vladimir Weinstein 12052000\n*\n* Modification history :\n*\n* Date        Name        Description\n* 02/01/01    synwee      Added normalization quickcheck enum and method.\n*/\n#ifndef UNORM_H\n#define UNORM_H\n\n#include \"unicode/utypes.h\"\n\n#if !UCONFIG_NO_NORMALIZATION\n\n#include \"unicode/uiter.h\"\n#include \"unicode/unorm2.h\"\n\n/**\n * \\file\n * \\brief C API: Unicode Normalization \n *\n * <h2>Unicode normalization API</h2>\n *\n * Note: This API has been replaced by the unorm2.h API and is only available\n * for backward compatibility. The functions here simply delegate to the\n * unorm2.h functions, for example unorm2_getInstance() and unorm2_normalize().\n * There is one exception: The new API does not provide a replacement for unorm_compare().\n *\n * <code>unorm_normalize</code> transforms Unicode text into an equivalent composed or\n * decomposed form, allowing for easier sorting and searching of text.\n * <code>unorm_normalize</code> supports the standard normalization forms described in\n * <a href=\"http://www.unicode.org/unicode/reports/tr15/\" target=\"unicode\">\n * Unicode Standard Annex #15: Unicode Normalization Forms</a>.\n *\n * Characters with accents or other adornments can be encoded in\n * several different ways in Unicode.  For example, take the character A-acute.\n * In Unicode, this can be encoded as a single character (the\n * \"composed\" form):\n *\n * \\code\n *      00C1    LATIN CAPITAL LETTER A WITH ACUTE\n * \\endcode\n *\n * or as two separate characters (the \"decomposed\" form):\n *\n * \\code\n *      0041    LATIN CAPITAL LETTER A\n *      0301    COMBINING ACUTE ACCENT\n * \\endcode\n *\n * To a user of your program, however, both of these sequences should be\n * treated as the same \"user-level\" character \"A with acute accent\".  When you are searching or\n * comparing text, you must ensure that these two sequences are treated \n * equivalently.  In addition, you must handle characters with more than one\n * accent.  Sometimes the order of a character's combining accents is\n * significant, while in other cases accent sequences in different orders are\n * really equivalent.\n *\n * Similarly, the string \"ffi\" can be encoded as three separate letters:\n *\n * \\code\n *      0066    LATIN SMALL LETTER F\n *      0066    LATIN SMALL LETTER F\n *      0069    LATIN SMALL LETTER I\n * \\endcode\n *\n * or as the single character\n *\n * \\code\n *      FB03    LATIN SMALL LIGATURE FFI\n * \\endcode\n *\n * The ffi ligature is not a distinct semantic character, and strictly speaking\n * it shouldn't be in Unicode at all, but it was included for compatibility\n * with existing character sets that already provided it.  The Unicode standard\n * identifies such characters by giving them \"compatibility\" decompositions\n * into the corresponding semantic characters.  When sorting and searching, you\n * will often want to use these mappings.\n *\n * <code>unorm_normalize</code> helps solve these problems by transforming text into the\n * canonical composed and decomposed forms as shown in the first example above.  \n * In addition, you can have it perform compatibility decompositions so that \n * you can treat compatibility characters the same as their equivalents.\n * Finally, <code>unorm_normalize</code> rearranges accents into the proper canonical\n * order, so that you do not have to worry about accent rearrangement on your\n * own.\n *\n * Form FCD, \"Fast C or D\", is also designed for collation.\n * It allows to work on strings that are not necessarily normalized\n * with an algorithm (like in collation) that works under \"canonical closure\", i.e., it treats precomposed\n * characters and their decomposed equivalents the same.\n *\n * It is not a normalization form because it does not provide for uniqueness of representation. Multiple strings\n * may be canonically equivalent (their NFDs are identical) and may all conform to FCD without being identical\n * themselves.\n *\n * The form is defined such that the \"raw decomposition\", the recursive canonical decomposition of each character,\n * results in a string that is canonically ordered. This means that precomposed characters are allowed for as long\n * as their decompositions do not need canonical reordering.\n *\n * Its advantage for a process like collation is that all NFD and most NFC texts - and many unnormalized texts -\n * already conform to FCD and do not need to be normalized (NFD) for such a process. The FCD quick check will\n * return UNORM_YES for most strings in practice.\n *\n * unorm_normalize(UNORM_FCD) may be implemented with UNORM_NFD.\n *\n * For more details on FCD see the collation design document:\n * http://source.icu-project.org/repos/icu/icuhtml/trunk/design/collation/ICU_collation_design.htm\n *\n * ICU collation performs either NFD or FCD normalization automatically if normalization\n * is turned on for the collator object.\n * Beyond collation and string search, normalized strings may be useful for string equivalence comparisons,\n * transliteration/transcription, unique representations, etc.\n *\n * The W3C generally recommends to exchange texts in NFC.\n * Note also that most legacy character encodings use only precomposed forms and often do not\n * encode any combining marks by themselves. For conversion to such character encodings the\n * Unicode text needs to be normalized to NFC.\n * For more usage examples, see the Unicode Standard Annex.\n */\n\n/**\n * Constants for normalization modes.\n * @stable ICU 2.0\n */\ntypedef enum {\n  /** No decomposition/composition. @stable ICU 2.0 */\n  UNORM_NONE = 1, \n  /** Canonical decomposition. @stable ICU 2.0 */\n  UNORM_NFD = 2,\n  /** Compatibility decomposition. @stable ICU 2.0 */\n  UNORM_NFKD = 3,\n  /** Canonical decomposition followed by canonical composition. @stable ICU 2.0 */\n  UNORM_NFC = 4,\n  /** Default normalization. @stable ICU 2.0 */\n  UNORM_DEFAULT = UNORM_NFC, \n  /** Compatibility decomposition followed by canonical composition. @stable ICU 2.0 */\n  UNORM_NFKC =5,\n  /** \"Fast C or D\" form. @stable ICU 2.0 */\n  UNORM_FCD = 6,\n\n  /** One more than the highest normalization mode constant. @stable ICU 2.0 */\n  UNORM_MODE_COUNT\n} UNormalizationMode;\n\n/**\n * Constants for options flags for normalization.\n * Use 0 for default options,\n * including normalization according to the Unicode version\n * that is currently supported by ICU (see u_getUnicodeVersion).\n * @stable ICU 2.6\n */\nenum {\n    /**\n     * Options bit set value to select Unicode 3.2 normalization\n     * (except NormalizationCorrections).\n     * At most one Unicode version can be selected at a time.\n     * @stable ICU 2.6\n     */\n    UNORM_UNICODE_3_2=0x20\n};\n\n/**\n * Lowest-order bit number of unorm_compare() options bits corresponding to\n * normalization options bits.\n *\n * The options parameter for unorm_compare() uses most bits for\n * itself and for various comparison and folding flags.\n * The most significant bits, however, are shifted down and passed on\n * to the normalization implementation.\n * (That is, from unorm_compare(..., options, ...),\n * options>>UNORM_COMPARE_NORM_OPTIONS_SHIFT will be passed on to the\n * internal normalization functions.)\n *\n * @see unorm_compare\n * @stable ICU 2.6\n */\n#define UNORM_COMPARE_NORM_OPTIONS_SHIFT 20\n\n/**\n * Normalize a string.\n * The string will be normalized according the specified normalization mode\n * and options.\n * The source and result buffers must not be the same, nor overlap.\n *\n * @param source The string to normalize.\n * @param sourceLength The length of source, or -1 if NUL-terminated.\n * @param mode The normalization mode; one of UNORM_NONE, \n *             UNORM_NFD, UNORM_NFC, UNORM_NFKC, UNORM_NFKD, UNORM_DEFAULT.\n * @param options The normalization options, ORed together (0 for no options).\n * @param result A pointer to a buffer to receive the result string.\n *               The result string is NUL-terminated if possible.\n * @param resultLength The maximum size of result.\n * @param status A pointer to a UErrorCode to receive any errors.\n * @return The total buffer size needed; if greater than resultLength,\n *         the output was truncated, and the error code is set to U_BUFFER_OVERFLOW_ERROR.\n * @stable ICU 2.0\n */\nU_STABLE int32_t U_EXPORT2 \nunorm_normalize(const UChar *source, int32_t sourceLength,\n                UNormalizationMode mode, int32_t options,\n                UChar *result, int32_t resultLength,\n                UErrorCode *status);\n\n/**\n * Performing quick check on a string, to quickly determine if the string is \n * in a particular normalization format.\n * Three types of result can be returned UNORM_YES, UNORM_NO or\n * UNORM_MAYBE. Result UNORM_YES indicates that the argument\n * string is in the desired normalized format, UNORM_NO determines that\n * argument string is not in the desired normalized format. A \n * UNORM_MAYBE result indicates that a more thorough check is required, \n * the user may have to put the string in its normalized form and compare the \n * results.\n *\n * @param source       string for determining if it is in a normalized format\n * @param sourcelength length of source to test, or -1 if NUL-terminated\n * @param mode         which normalization form to test for\n * @param status       a pointer to a UErrorCode to receive any errors\n * @return UNORM_YES, UNORM_NO or UNORM_MAYBE\n *\n * @see unorm_isNormalized\n * @stable ICU 2.0\n */\nU_STABLE UNormalizationCheckResult U_EXPORT2\nunorm_quickCheck(const UChar *source, int32_t sourcelength,\n                 UNormalizationMode mode,\n                 UErrorCode *status);\n\n/**\n * Performing quick check on a string; same as unorm_quickCheck but\n * takes an extra options parameter like most normalization functions.\n *\n * @param src        String that is to be tested if it is in a normalization format.\n * @param srcLength  Length of source to test, or -1 if NUL-terminated.\n * @param mode       Which normalization form to test for.\n * @param options    The normalization options, ORed together (0 for no options).\n * @param pErrorCode ICU error code in/out parameter.\n *                   Must fulfill U_SUCCESS before the function call.\n * @return UNORM_YES, UNORM_NO or UNORM_MAYBE\n *\n * @see unorm_quickCheck\n * @see unorm_isNormalized\n * @stable ICU 2.6\n */\nU_STABLE UNormalizationCheckResult U_EXPORT2\nunorm_quickCheckWithOptions(const UChar *src, int32_t srcLength, \n                            UNormalizationMode mode, int32_t options,\n                            UErrorCode *pErrorCode);\n\n/**\n * Test if a string is in a given normalization form.\n * This is semantically equivalent to source.equals(normalize(source, mode)) .\n *\n * Unlike unorm_quickCheck(), this function returns a definitive result,\n * never a \"maybe\".\n * For NFD, NFKD, and FCD, both functions work exactly the same.\n * For NFC and NFKC where quickCheck may return \"maybe\", this function will\n * perform further tests to arrive at a TRUE/FALSE result.\n *\n * @param src        String that is to be tested if it is in a normalization format.\n * @param srcLength  Length of source to test, or -1 if NUL-terminated.\n * @param mode       Which normalization form to test for.\n * @param pErrorCode ICU error code in/out parameter.\n *                   Must fulfill U_SUCCESS before the function call.\n * @return Boolean value indicating whether the source string is in the\n *         \"mode\" normalization form.\n *\n * @see unorm_quickCheck\n * @stable ICU 2.2\n */\nU_STABLE UBool U_EXPORT2\nunorm_isNormalized(const UChar *src, int32_t srcLength,\n                   UNormalizationMode mode,\n                   UErrorCode *pErrorCode);\n\n/**\n * Test if a string is in a given normalization form; same as unorm_isNormalized but\n * takes an extra options parameter like most normalization functions.\n *\n * @param src        String that is to be tested if it is in a normalization format.\n * @param srcLength  Length of source to test, or -1 if NUL-terminated.\n * @param mode       Which normalization form to test for.\n * @param options    The normalization options, ORed together (0 for no options).\n * @param pErrorCode ICU error code in/out parameter.\n *                   Must fulfill U_SUCCESS before the function call.\n * @return Boolean value indicating whether the source string is in the\n *         \"mode/options\" normalization form.\n *\n * @see unorm_quickCheck\n * @see unorm_isNormalized\n * @stable ICU 2.6\n */\nU_STABLE UBool U_EXPORT2\nunorm_isNormalizedWithOptions(const UChar *src, int32_t srcLength,\n                              UNormalizationMode mode, int32_t options,\n                              UErrorCode *pErrorCode);\n\n/**\n * Iterative normalization forward.\n * This function (together with unorm_previous) is somewhat\n * similar to the C++ Normalizer class (see its non-static functions).\n *\n * Iterative normalization is useful when only a small portion of a longer\n * string/text needs to be processed.\n *\n * For example, the likelihood may be high that processing the first 10% of some\n * text will be sufficient to find certain data.\n * Another example: When one wants to concatenate two normalized strings and get a\n * normalized result, it is much more efficient to normalize just a small part of\n * the result around the concatenation place instead of re-normalizing everything.\n *\n * The input text is an instance of the C character iteration API UCharIterator.\n * It may wrap around a simple string, a CharacterIterator, a Replaceable, or any\n * other kind of text object.\n *\n * If a buffer overflow occurs, then the caller needs to reset the iterator to the\n * old index and call the function again with a larger buffer - if the caller cares\n * for the actual output.\n * Regardless of the output buffer, the iterator will always be moved to the next\n * normalization boundary.\n *\n * This function (like unorm_previous) serves two purposes:\n *\n * 1) To find the next boundary so that the normalization of the part of the text\n * from the current position to that boundary does not affect and is not affected\n * by the part of the text beyond that boundary.\n *\n * 2) To normalize the text up to the boundary.\n *\n * The second step is optional, per the doNormalize parameter.\n * It is omitted for operations like string concatenation, where the two adjacent\n * string ends need to be normalized together.\n * In such a case, the output buffer will just contain a copy of the text up to the\n * boundary.\n *\n * pNeededToNormalize is an output-only parameter. Its output value is only defined\n * if normalization was requested (doNormalize) and successful (especially, no\n * buffer overflow).\n * It is useful for operations like a normalizing transliterator, where one would\n * not want to replace a piece of text if it is not modified.\n *\n * If doNormalize==TRUE and pNeededToNormalize!=NULL then *pNeeded... is set TRUE\n * if the normalization was necessary.\n *\n * If doNormalize==FALSE then *pNeededToNormalize will be set to FALSE.\n *\n * If the buffer overflows, then *pNeededToNormalize will be undefined;\n * essentially, whenever U_FAILURE is true (like in buffer overflows), this result\n * will be undefined.\n *\n * @param src The input text in the form of a C character iterator.\n * @param dest The output buffer; can be NULL if destCapacity==0 for pure preflighting.\n * @param destCapacity The number of UChars that fit into dest.\n * @param mode The normalization mode.\n * @param options The normalization options, ORed together (0 for no options).\n * @param doNormalize Indicates if the source text up to the next boundary\n *                    is to be normalized (TRUE) or just copied (FALSE).\n * @param pNeededToNormalize Output flag indicating if the normalization resulted in\n *                           different text from the input.\n *                           Not defined if an error occurs including buffer overflow.\n *                           Always FALSE if !doNormalize.\n * @param pErrorCode ICU error code in/out parameter.\n *                   Must fulfill U_SUCCESS before the function call.\n * @return Length of output (number of UChars) when successful or buffer overflow.\n *\n * @see unorm_previous\n * @see unorm_normalize\n *\n * @stable ICU 2.1\n */\nU_STABLE int32_t U_EXPORT2\nunorm_next(UCharIterator *src,\n           UChar *dest, int32_t destCapacity,\n           UNormalizationMode mode, int32_t options,\n           UBool doNormalize, UBool *pNeededToNormalize,\n           UErrorCode *pErrorCode);\n\n/**\n * Iterative normalization backward.\n * This function (together with unorm_next) is somewhat\n * similar to the C++ Normalizer class (see its non-static functions).\n * For all details see unorm_next.\n *\n * @param src The input text in the form of a C character iterator.\n * @param dest The output buffer; can be NULL if destCapacity==0 for pure preflighting.\n * @param destCapacity The number of UChars that fit into dest.\n * @param mode The normalization mode.\n * @param options The normalization options, ORed together (0 for no options).\n * @param doNormalize Indicates if the source text up to the next boundary\n *                    is to be normalized (TRUE) or just copied (FALSE).\n * @param pNeededToNormalize Output flag indicating if the normalization resulted in\n *                           different text from the input.\n *                           Not defined if an error occurs including buffer overflow.\n *                           Always FALSE if !doNormalize.\n * @param pErrorCode ICU error code in/out parameter.\n *                   Must fulfill U_SUCCESS before the function call.\n * @return Length of output (number of UChars) when successful or buffer overflow.\n *\n * @see unorm_next\n * @see unorm_normalize\n *\n * @stable ICU 2.1\n */\nU_STABLE int32_t U_EXPORT2\nunorm_previous(UCharIterator *src,\n               UChar *dest, int32_t destCapacity,\n               UNormalizationMode mode, int32_t options,\n               UBool doNormalize, UBool *pNeededToNormalize,\n               UErrorCode *pErrorCode);\n\n/**\n * Concatenate normalized strings, making sure that the result is normalized as well.\n *\n * If both the left and the right strings are in\n * the normalization form according to \"mode/options\",\n * then the result will be\n *\n * \\code\n *     dest=normalize(left+right, mode, options)\n * \\endcode\n *\n * With the input strings already being normalized,\n * this function will use unorm_next() and unorm_previous()\n * to find the adjacent end pieces of the input strings.\n * Only the concatenation of these end pieces will be normalized and\n * then concatenated with the remaining parts of the input strings.\n *\n * It is allowed to have dest==left to avoid copying the entire left string.\n *\n * @param left Left source string, may be same as dest.\n * @param leftLength Length of left source string, or -1 if NUL-terminated.\n * @param right Right source string. Must not be the same as dest, nor overlap.\n * @param rightLength Length of right source string, or -1 if NUL-terminated.\n * @param dest The output buffer; can be NULL if destCapacity==0 for pure preflighting.\n * @param destCapacity The number of UChars that fit into dest.\n * @param mode The normalization mode.\n * @param options The normalization options, ORed together (0 for no options).\n * @param pErrorCode ICU error code in/out parameter.\n *                   Must fulfill U_SUCCESS before the function call.\n * @return Length of output (number of UChars) when successful or buffer overflow.\n *\n * @see unorm_normalize\n * @see unorm_next\n * @see unorm_previous\n *\n * @stable ICU 2.1\n */\nU_STABLE int32_t U_EXPORT2\nunorm_concatenate(const UChar *left, int32_t leftLength,\n                  const UChar *right, int32_t rightLength,\n                  UChar *dest, int32_t destCapacity,\n                  UNormalizationMode mode, int32_t options,\n                  UErrorCode *pErrorCode);\n\n/**\n * Option bit for unorm_compare:\n * Both input strings are assumed to fulfill FCD conditions.\n * @stable ICU 2.2\n */\n#define UNORM_INPUT_IS_FCD          0x20000\n\n/**\n * Option bit for unorm_compare:\n * Perform case-insensitive comparison.\n * @stable ICU 2.2\n */\n#define U_COMPARE_IGNORE_CASE       0x10000\n\n#ifndef U_COMPARE_CODE_POINT_ORDER\n/* see also unistr.h and ustring.h */\n/**\n * Option bit for u_strCaseCompare, u_strcasecmp, unorm_compare, etc:\n * Compare strings in code point order instead of code unit order.\n * @stable ICU 2.2\n */\n#define U_COMPARE_CODE_POINT_ORDER  0x8000\n#endif\n\n/**\n * Compare two strings for canonical equivalence.\n * Further options include case-insensitive comparison and\n * code point order (as opposed to code unit order).\n *\n * Canonical equivalence between two strings is defined as their normalized\n * forms (NFD or NFC) being identical.\n * This function compares strings incrementally instead of normalizing\n * (and optionally case-folding) both strings entirely,\n * improving performance significantly.\n *\n * Bulk normalization is only necessary if the strings do not fulfill the FCD\n * conditions. Only in this case, and only if the strings are relatively long,\n * is memory allocated temporarily.\n * For FCD strings and short non-FCD strings there is no memory allocation.\n *\n * Semantically, this is equivalent to\n *   strcmp[CodePointOrder](NFD(foldCase(NFD(s1))), NFD(foldCase(NFD(s2))))\n * where code point order and foldCase are all optional.\n *\n * UAX 21 2.5 Caseless Matching specifies that for a canonical caseless match\n * the case folding must be performed first, then the normalization.\n *\n * @param s1 First source string.\n * @param length1 Length of first source string, or -1 if NUL-terminated.\n *\n * @param s2 Second source string.\n * @param length2 Length of second source string, or -1 if NUL-terminated.\n *\n * @param options A bit set of options:\n *   - U_FOLD_CASE_DEFAULT or 0 is used for default options:\n *     Case-sensitive comparison in code unit order, and the input strings\n *     are quick-checked for FCD.\n *\n *   - UNORM_INPUT_IS_FCD\n *     Set if the caller knows that both s1 and s2 fulfill the FCD conditions.\n *     If not set, the function will quickCheck for FCD\n *     and normalize if necessary.\n *\n *   - U_COMPARE_CODE_POINT_ORDER\n *     Set to choose code point order instead of code unit order\n *     (see u_strCompare for details).\n *\n *   - U_COMPARE_IGNORE_CASE\n *     Set to compare strings case-insensitively using case folding,\n *     instead of case-sensitively.\n *     If set, then the following case folding options are used.\n *\n *   - Options as used with case-insensitive comparisons, currently:\n *\n *   - U_FOLD_CASE_EXCLUDE_SPECIAL_I\n *    (see u_strCaseCompare for details)\n *\n *   - regular normalization options shifted left by UNORM_COMPARE_NORM_OPTIONS_SHIFT\n *\n * @param pErrorCode ICU error code in/out parameter.\n *                   Must fulfill U_SUCCESS before the function call.\n * @return <0 or 0 or >0 as usual for string comparisons\n *\n * @see unorm_normalize\n * @see UNORM_FCD\n * @see u_strCompare\n * @see u_strCaseCompare\n *\n * @stable ICU 2.2\n */\nU_STABLE int32_t U_EXPORT2\nunorm_compare(const UChar *s1, int32_t length1,\n              const UChar *s2, int32_t length2,\n              uint32_t options,\n              UErrorCode *pErrorCode);\n\n#endif /* #if !UCONFIG_NO_NORMALIZATION */\n\n#endif\n"
  },
  {
    "path": "deprecated/android/addons/icucompat/unicode/unorm2.h",
    "content": "/*\n*******************************************************************************\n*\n*   Copyright (C) 2009-2012, International Business Machines\n*   Corporation and others.  All Rights Reserved.\n*\n*******************************************************************************\n*   file name:  unorm2.h\n*   encoding:   US-ASCII\n*   tab size:   8 (not used)\n*   indentation:4\n*\n*   created on: 2009dec15\n*   created by: Markus W. Scherer\n*/\n\n#ifndef __UNORM2_H__\n#define __UNORM2_H__\n\n/**\n * \\file\n * \\brief C API: New API for Unicode Normalization.\n *\n * Unicode normalization functionality for standard Unicode normalization or\n * for using custom mapping tables.\n * All instances of UNormalizer2 are unmodifiable/immutable.\n * Instances returned by unorm2_getInstance() are singletons that must not be deleted by the caller.\n * For more details see the Normalizer2 C++ class.\n */\n\n#include \"unicode/utypes.h\"\n#include \"unicode/localpointer.h\"\n#include \"unicode/uset.h\"\n\n/**\n * Constants for normalization modes.\n * For details about standard Unicode normalization forms\n * and about the algorithms which are also used with custom mapping tables\n * see http://www.unicode.org/unicode/reports/tr15/\n * @stable ICU 4.4\n */\ntypedef enum {\n    /**\n     * Decomposition followed by composition.\n     * Same as standard NFC when using an \"nfc\" instance.\n     * Same as standard NFKC when using an \"nfkc\" instance.\n     * For details about standard Unicode normalization forms\n     * see http://www.unicode.org/unicode/reports/tr15/\n     * @stable ICU 4.4\n     */\n    UNORM2_COMPOSE,\n    /**\n     * Map, and reorder canonically.\n     * Same as standard NFD when using an \"nfc\" instance.\n     * Same as standard NFKD when using an \"nfkc\" instance.\n     * For details about standard Unicode normalization forms\n     * see http://www.unicode.org/unicode/reports/tr15/\n     * @stable ICU 4.4\n     */\n    UNORM2_DECOMPOSE,\n    /**\n     * \"Fast C or D\" form.\n     * If a string is in this form, then further decomposition <i>without reordering</i>\n     * would yield the same form as DECOMPOSE.\n     * Text in \"Fast C or D\" form can be processed efficiently with data tables\n     * that are \"canonically closed\", that is, that provide equivalent data for\n     * equivalent text, without having to be fully normalized.\n     * Not a standard Unicode normalization form.\n     * Not a unique form: Different FCD strings can be canonically equivalent.\n     * For details see http://www.unicode.org/notes/tn5/#FCD\n     * @stable ICU 4.4\n     */\n    UNORM2_FCD,\n    /**\n     * Compose only contiguously.\n     * Also known as \"FCC\" or \"Fast C Contiguous\".\n     * The result will often but not always be in NFC.\n     * The result will conform to FCD which is useful for processing.\n     * Not a standard Unicode normalization form.\n     * For details see http://www.unicode.org/notes/tn5/#FCC\n     * @stable ICU 4.4\n     */\n    UNORM2_COMPOSE_CONTIGUOUS\n} UNormalization2Mode;\n\n/**\n * Result values for normalization quick check functions.\n * For details see http://www.unicode.org/reports/tr15/#Detecting_Normalization_Forms\n * @stable ICU 2.0\n */\ntypedef enum UNormalizationCheckResult {\n  /**\n   * The input string is not in the normalization form.\n   * @stable ICU 2.0\n   */\n  UNORM_NO,\n  /**\n   * The input string is in the normalization form.\n   * @stable ICU 2.0\n   */\n  UNORM_YES,\n  /**\n   * The input string may or may not be in the normalization form.\n   * This value is only returned for composition forms like NFC and FCC,\n   * when a backward-combining character is found for which the surrounding text\n   * would have to be analyzed further.\n   * @stable ICU 2.0\n   */\n  UNORM_MAYBE\n} UNormalizationCheckResult;\n\n/**\n * Opaque C service object type for the new normalization API.\n * @stable ICU 4.4\n */\nstruct UNormalizer2;\ntypedef struct UNormalizer2 UNormalizer2;  /**< C typedef for struct UNormalizer2. @stable ICU 4.4 */\n\n#if !UCONFIG_NO_NORMALIZATION\n\n#ifndef U_HIDE_DRAFT_API\n/**\n * Returns a UNormalizer2 instance for Unicode NFC normalization.\n * Same as unorm2_getInstance(NULL, \"nfc\", UNORM2_COMPOSE, pErrorCode).\n * Returns an unmodifiable singleton instance. Do not delete it.\n * @param pErrorCode Standard ICU error code. Its input value must\n *                  pass the U_SUCCESS() test, or else the function returns\n *                  immediately. Check for U_FAILURE() on output or use with\n *                  function chaining. (See User Guide for details.)\n * @return the requested Normalizer2, if successful\n * @draft ICU 49\n */\nU_DRAFT const UNormalizer2 * U_EXPORT2\nunorm2_getNFCInstance(UErrorCode *pErrorCode);\n\n/**\n * Returns a UNormalizer2 instance for Unicode NFD normalization.\n * Same as unorm2_getInstance(NULL, \"nfc\", UNORM2_DECOMPOSE, pErrorCode).\n * Returns an unmodifiable singleton instance. Do not delete it.\n * @param pErrorCode Standard ICU error code. Its input value must\n *                  pass the U_SUCCESS() test, or else the function returns\n *                  immediately. Check for U_FAILURE() on output or use with\n *                  function chaining. (See User Guide for details.)\n * @return the requested Normalizer2, if successful\n * @draft ICU 49\n */\nU_DRAFT const UNormalizer2 * U_EXPORT2\nunorm2_getNFDInstance(UErrorCode *pErrorCode);\n\n/**\n * Returns a UNormalizer2 instance for Unicode NFKC normalization.\n * Same as unorm2_getInstance(NULL, \"nfkc\", UNORM2_COMPOSE, pErrorCode).\n * Returns an unmodifiable singleton instance. Do not delete it.\n * @param pErrorCode Standard ICU error code. Its input value must\n *                  pass the U_SUCCESS() test, or else the function returns\n *                  immediately. Check for U_FAILURE() on output or use with\n *                  function chaining. (See User Guide for details.)\n * @return the requested Normalizer2, if successful\n * @draft ICU 49\n */\nU_DRAFT const UNormalizer2 * U_EXPORT2\nunorm2_getNFKCInstance(UErrorCode *pErrorCode);\n\n/**\n * Returns a UNormalizer2 instance for Unicode NFKD normalization.\n * Same as unorm2_getInstance(NULL, \"nfkc\", UNORM2_DECOMPOSE, pErrorCode).\n * Returns an unmodifiable singleton instance. Do not delete it.\n * @param pErrorCode Standard ICU error code. Its input value must\n *                  pass the U_SUCCESS() test, or else the function returns\n *                  immediately. Check for U_FAILURE() on output or use with\n *                  function chaining. (See User Guide for details.)\n * @return the requested Normalizer2, if successful\n * @draft ICU 49\n */\nU_DRAFT const UNormalizer2 * U_EXPORT2\nunorm2_getNFKDInstance(UErrorCode *pErrorCode);\n\n/**\n * Returns a UNormalizer2 instance for Unicode NFKC_Casefold normalization.\n * Same as unorm2_getInstance(NULL, \"nfkc_cf\", UNORM2_COMPOSE, pErrorCode).\n * Returns an unmodifiable singleton instance. Do not delete it.\n * @param pErrorCode Standard ICU error code. Its input value must\n *                  pass the U_SUCCESS() test, or else the function returns\n *                  immediately. Check for U_FAILURE() on output or use with\n *                  function chaining. (See User Guide for details.)\n * @return the requested Normalizer2, if successful\n * @draft ICU 49\n */\nU_DRAFT const UNormalizer2 * U_EXPORT2\nunorm2_getNFKCCasefoldInstance(UErrorCode *pErrorCode);\n#endif  /* U_HIDE_DRAFT_API */\n\n/**\n * Returns a UNormalizer2 instance which uses the specified data file\n * (packageName/name similar to ucnv_openPackage() and ures_open()/ResourceBundle)\n * and which composes or decomposes text according to the specified mode.\n * Returns an unmodifiable singleton instance. Do not delete it.\n *\n * Use packageName=NULL for data files that are part of ICU's own data.\n * Use name=\"nfc\" and UNORM2_COMPOSE/UNORM2_DECOMPOSE for Unicode standard NFC/NFD.\n * Use name=\"nfkc\" and UNORM2_COMPOSE/UNORM2_DECOMPOSE for Unicode standard NFKC/NFKD.\n * Use name=\"nfkc_cf\" and UNORM2_COMPOSE for Unicode standard NFKC_CF=NFKC_Casefold.\n *\n * @param packageName NULL for ICU built-in data, otherwise application data package name\n * @param name \"nfc\" or \"nfkc\" or \"nfkc_cf\" or name of custom data file\n * @param mode normalization mode (compose or decompose etc.)\n * @param pErrorCode Standard ICU error code. Its input value must\n *                  pass the U_SUCCESS() test, or else the function returns\n *                  immediately. Check for U_FAILURE() on output or use with\n *                  function chaining. (See User Guide for details.)\n * @return the requested UNormalizer2, if successful\n * @stable ICU 4.4\n */\nU_STABLE const UNormalizer2 * U_EXPORT2\nunorm2_getInstance(const char *packageName,\n                   const char *name,\n                   UNormalization2Mode mode,\n                   UErrorCode *pErrorCode);\n\n/**\n * Constructs a filtered normalizer wrapping any UNormalizer2 instance\n * and a filter set.\n * Both are aliased and must not be modified or deleted while this object\n * is used.\n * The filter set should be frozen; otherwise the performance will suffer greatly.\n * @param norm2 wrapped UNormalizer2 instance\n * @param filterSet USet which determines the characters to be normalized\n * @param pErrorCode Standard ICU error code. Its input value must\n *                   pass the U_SUCCESS() test, or else the function returns\n *                   immediately. Check for U_FAILURE() on output or use with\n *                   function chaining. (See User Guide for details.)\n * @return the requested UNormalizer2, if successful\n * @stable ICU 4.4\n */\nU_STABLE UNormalizer2 * U_EXPORT2\nunorm2_openFiltered(const UNormalizer2 *norm2, const USet *filterSet, UErrorCode *pErrorCode);\n\n/**\n * Closes a UNormalizer2 instance from unorm2_openFiltered().\n * Do not close instances from unorm2_getInstance()!\n * @param norm2 UNormalizer2 instance to be closed\n * @stable ICU 4.4\n */\nU_STABLE void U_EXPORT2\nunorm2_close(UNormalizer2 *norm2);\n\n#if U_SHOW_CPLUSPLUS_API\n\nU_NAMESPACE_BEGIN\n\n/**\n * \\class LocalUNormalizer2Pointer\n * \"Smart pointer\" class, closes a UNormalizer2 via unorm2_close().\n * For most methods see the LocalPointerBase base class.\n *\n * @see LocalPointerBase\n * @see LocalPointer\n * @stable ICU 4.4\n */\nU_DEFINE_LOCAL_OPEN_POINTER(LocalUNormalizer2Pointer, UNormalizer2, unorm2_close);\n\nU_NAMESPACE_END\n\n#endif\n\n/**\n * Writes the normalized form of the source string to the destination string\n * (replacing its contents) and returns the length of the destination string.\n * The source and destination strings must be different buffers.\n * @param norm2 UNormalizer2 instance\n * @param src source string\n * @param length length of the source string, or -1 if NUL-terminated\n * @param dest destination string; its contents is replaced with normalized src\n * @param capacity number of UChars that can be written to dest\n * @param pErrorCode Standard ICU error code. Its input value must\n *                   pass the U_SUCCESS() test, or else the function returns\n *                   immediately. Check for U_FAILURE() on output or use with\n *                   function chaining. (See User Guide for details.)\n * @return dest\n * @stable ICU 4.4\n */\nU_STABLE int32_t U_EXPORT2\nunorm2_normalize(const UNormalizer2 *norm2,\n                 const UChar *src, int32_t length,\n                 UChar *dest, int32_t capacity,\n                 UErrorCode *pErrorCode);\n/**\n * Appends the normalized form of the second string to the first string\n * (merging them at the boundary) and returns the length of the first string.\n * The result is normalized if the first string was normalized.\n * The first and second strings must be different buffers.\n * @param norm2 UNormalizer2 instance\n * @param first string, should be normalized\n * @param firstLength length of the first string, or -1 if NUL-terminated\n * @param firstCapacity number of UChars that can be written to first\n * @param second string, will be normalized\n * @param secondLength length of the source string, or -1 if NUL-terminated\n * @param pErrorCode Standard ICU error code. Its input value must\n *                   pass the U_SUCCESS() test, or else the function returns\n *                   immediately. Check for U_FAILURE() on output or use with\n *                   function chaining. (See User Guide for details.)\n * @return first\n * @stable ICU 4.4\n */\nU_STABLE int32_t U_EXPORT2\nunorm2_normalizeSecondAndAppend(const UNormalizer2 *norm2,\n                                UChar *first, int32_t firstLength, int32_t firstCapacity,\n                                const UChar *second, int32_t secondLength,\n                                UErrorCode *pErrorCode);\n/**\n * Appends the second string to the first string\n * (merging them at the boundary) and returns the length of the first string.\n * The result is normalized if both the strings were normalized.\n * The first and second strings must be different buffers.\n * @param norm2 UNormalizer2 instance\n * @param first string, should be normalized\n * @param firstLength length of the first string, or -1 if NUL-terminated\n * @param firstCapacity number of UChars that can be written to first\n * @param second string, should be normalized\n * @param secondLength length of the source string, or -1 if NUL-terminated\n * @param pErrorCode Standard ICU error code. Its input value must\n *                   pass the U_SUCCESS() test, or else the function returns\n *                   immediately. Check for U_FAILURE() on output or use with\n *                   function chaining. (See User Guide for details.)\n * @return first\n * @stable ICU 4.4\n */\nU_STABLE int32_t U_EXPORT2\nunorm2_append(const UNormalizer2 *norm2,\n              UChar *first, int32_t firstLength, int32_t firstCapacity,\n              const UChar *second, int32_t secondLength,\n              UErrorCode *pErrorCode);\n\n/**\n * Gets the decomposition mapping of c.\n * Roughly equivalent to normalizing the String form of c\n * on a UNORM2_DECOMPOSE UNormalizer2 instance, but much faster, and except that this function\n * returns a negative value and does not write a string\n * if c does not have a decomposition mapping in this instance's data.\n * This function is independent of the mode of the UNormalizer2.\n * @param norm2 UNormalizer2 instance\n * @param c code point\n * @param decomposition String buffer which will be set to c's\n *                      decomposition mapping, if there is one.\n * @param capacity number of UChars that can be written to decomposition\n * @param pErrorCode Standard ICU error code. Its input value must\n *                   pass the U_SUCCESS() test, or else the function returns\n *                   immediately. Check for U_FAILURE() on output or use with\n *                   function chaining. (See User Guide for details.)\n * @return the non-negative length of c's decomposition, if there is one; otherwise a negative value\n * @stable ICU 4.6\n */\nU_STABLE int32_t U_EXPORT2\nunorm2_getDecomposition(const UNormalizer2 *norm2,\n                        UChar32 c, UChar *decomposition, int32_t capacity,\n                        UErrorCode *pErrorCode);\n\n#ifndef U_HIDE_DRAFT_API\n/**\n * Gets the raw decomposition mapping of c.\n *\n * This is similar to the unorm2_getDecomposition() function but returns the\n * raw decomposition mapping as specified in UnicodeData.txt or\n * (for custom data) in the mapping files processed by the gennorm2 tool.\n * By contrast, unorm2_getDecomposition() returns the processed,\n * recursively-decomposed version of this mapping.\n *\n * When used on a standard NFKC Normalizer2 instance,\n * unorm2_getRawDecomposition() returns the Unicode Decomposition_Mapping (dm) property.\n *\n * When used on a standard NFC Normalizer2 instance,\n * it returns the Decomposition_Mapping only if the Decomposition_Type (dt) is Canonical (Can);\n * in this case, the result contains either one or two code points (=1..4 UChars).\n *\n * This function is independent of the mode of the UNormalizer2.\n * @param norm2 UNormalizer2 instance\n * @param c code point\n * @param decomposition String buffer which will be set to c's\n *                      raw decomposition mapping, if there is one.\n * @param capacity number of UChars that can be written to decomposition\n * @param pErrorCode Standard ICU error code. Its input value must\n *                   pass the U_SUCCESS() test, or else the function returns\n *                   immediately. Check for U_FAILURE() on output or use with\n *                   function chaining. (See User Guide for details.)\n * @return the non-negative length of c's raw decomposition, if there is one; otherwise a negative value\n * @draft ICU 49\n */\nU_DRAFT int32_t U_EXPORT2\nunorm2_getRawDecomposition(const UNormalizer2 *norm2,\n                           UChar32 c, UChar *decomposition, int32_t capacity,\n                           UErrorCode *pErrorCode);\n\n/**\n * Performs pairwise composition of a & b and returns the composite if there is one.\n *\n * Returns a composite code point c only if c has a two-way mapping to a+b.\n * In standard Unicode normalization, this means that\n * c has a canonical decomposition to a+b\n * and c does not have the Full_Composition_Exclusion property.\n *\n * This function is independent of the mode of the UNormalizer2.\n * @param norm2 UNormalizer2 instance\n * @param a A (normalization starter) code point.\n * @param b Another code point.\n * @return The non-negative composite code point if there is one; otherwise a negative value.\n * @draft ICU 49\n */\nU_DRAFT UChar32 U_EXPORT2\nunorm2_composePair(const UNormalizer2 *norm2, UChar32 a, UChar32 b);\n\n/**\n * Gets the combining class of c.\n * The default implementation returns 0\n * but all standard implementations return the Unicode Canonical_Combining_Class value.\n * @param norm2 UNormalizer2 instance\n * @param c code point\n * @return c's combining class\n * @draft ICU 49\n */\nU_DRAFT uint8_t U_EXPORT2\nunorm2_getCombiningClass(const UNormalizer2 *norm2, UChar32 c);\n#endif  /* U_HIDE_DRAFT_API */\n\n/**\n * Tests if the string is normalized.\n * Internally, in cases where the quickCheck() method would return \"maybe\"\n * (which is only possible for the two COMPOSE modes) this method\n * resolves to \"yes\" or \"no\" to provide a definitive result,\n * at the cost of doing more work in those cases.\n * @param norm2 UNormalizer2 instance\n * @param s input string\n * @param length length of the string, or -1 if NUL-terminated\n * @param pErrorCode Standard ICU error code. Its input value must\n *                   pass the U_SUCCESS() test, or else the function returns\n *                   immediately. Check for U_FAILURE() on output or use with\n *                   function chaining. (See User Guide for details.)\n * @return TRUE if s is normalized\n * @stable ICU 4.4\n */\nU_STABLE UBool U_EXPORT2\nunorm2_isNormalized(const UNormalizer2 *norm2,\n                    const UChar *s, int32_t length,\n                    UErrorCode *pErrorCode);\n\n/**\n * Tests if the string is normalized.\n * For the two COMPOSE modes, the result could be \"maybe\" in cases that\n * would take a little more work to resolve definitively.\n * Use spanQuickCheckYes() and normalizeSecondAndAppend() for a faster\n * combination of quick check + normalization, to avoid\n * re-checking the \"yes\" prefix.\n * @param norm2 UNormalizer2 instance\n * @param s input string\n * @param length length of the string, or -1 if NUL-terminated\n * @param pErrorCode Standard ICU error code. Its input value must\n *                   pass the U_SUCCESS() test, or else the function returns\n *                   immediately. Check for U_FAILURE() on output or use with\n *                   function chaining. (See User Guide for details.)\n * @return UNormalizationCheckResult\n * @stable ICU 4.4\n */\nU_STABLE UNormalizationCheckResult U_EXPORT2\nunorm2_quickCheck(const UNormalizer2 *norm2,\n                  const UChar *s, int32_t length,\n                  UErrorCode *pErrorCode);\n\n/**\n * Returns the end of the normalized substring of the input string.\n * In other words, with <code>end=spanQuickCheckYes(s, ec);</code>\n * the substring <code>UnicodeString(s, 0, end)</code>\n * will pass the quick check with a \"yes\" result.\n *\n * The returned end index is usually one or more characters before the\n * \"no\" or \"maybe\" character: The end index is at a normalization boundary.\n * (See the class documentation for more about normalization boundaries.)\n *\n * When the goal is a normalized string and most input strings are expected\n * to be normalized already, then call this method,\n * and if it returns a prefix shorter than the input string,\n * copy that prefix and use normalizeSecondAndAppend() for the remainder.\n * @param norm2 UNormalizer2 instance\n * @param s input string\n * @param length length of the string, or -1 if NUL-terminated\n * @param pErrorCode Standard ICU error code. Its input value must\n *                   pass the U_SUCCESS() test, or else the function returns\n *                   immediately. Check for U_FAILURE() on output or use with\n *                   function chaining. (See User Guide for details.)\n * @return \"yes\" span end index\n * @stable ICU 4.4\n */\nU_STABLE int32_t U_EXPORT2\nunorm2_spanQuickCheckYes(const UNormalizer2 *norm2,\n                         const UChar *s, int32_t length,\n                         UErrorCode *pErrorCode);\n\n/**\n * Tests if the character always has a normalization boundary before it,\n * regardless of context.\n * For details see the Normalizer2 base class documentation.\n * @param norm2 UNormalizer2 instance\n * @param c character to test\n * @return TRUE if c has a normalization boundary before it\n * @stable ICU 4.4\n */\nU_STABLE UBool U_EXPORT2\nunorm2_hasBoundaryBefore(const UNormalizer2 *norm2, UChar32 c);\n\n/**\n * Tests if the character always has a normalization boundary after it,\n * regardless of context.\n * For details see the Normalizer2 base class documentation.\n * @param norm2 UNormalizer2 instance\n * @param c character to test\n * @return TRUE if c has a normalization boundary after it\n * @stable ICU 4.4\n */\nU_STABLE UBool U_EXPORT2\nunorm2_hasBoundaryAfter(const UNormalizer2 *norm2, UChar32 c);\n\n/**\n * Tests if the character is normalization-inert.\n * For details see the Normalizer2 base class documentation.\n * @param norm2 UNormalizer2 instance\n * @param c character to test\n * @return TRUE if c is normalization-inert\n * @stable ICU 4.4\n */\nU_STABLE UBool U_EXPORT2\nunorm2_isInert(const UNormalizer2 *norm2, UChar32 c);\n\n#endif  /* !UCONFIG_NO_NORMALIZATION */\n#endif  /* __UNORM2_H__ */\n"
  },
  {
    "path": "deprecated/android/addons/icucompat/unicode/unum.h",
    "content": "/*\n*******************************************************************************\n* Copyright (C) 1997-2012, International Business Machines Corporation and others.\n* All Rights Reserved.\n* Modification History:\n*\n*   Date        Name        Description\n*   06/24/99    helena      Integrated Alan's NF enhancements and Java2 bug fixes\n*******************************************************************************\n*/\n\n#ifndef _UNUM\n#define _UNUM\n\n#include \"unicode/utypes.h\"\n\n#if !UCONFIG_NO_FORMATTING\n\n#include \"unicode/localpointer.h\"\n#include \"unicode/uloc.h\"\n#include \"unicode/umisc.h\"\n#include \"unicode/parseerr.h\"\n/**\n * \\file\n * \\brief C API: NumberFormat\n *\n * <h2> Number Format C API </h2>\n *\n * Number Format C API  Provides functions for\n * formatting and parsing a number.  Also provides methods for\n * determining which locales have number formats, and what their names\n * are.\n * <P>\n * UNumberFormat helps you to format and parse numbers for any locale.\n * Your code can be completely independent of the locale conventions\n * for decimal points, thousands-separators, or even the particular\n * decimal digits used, or whether the number format is even decimal.\n * There are different number format styles like decimal, currency,\n * percent and spellout.\n * <P>\n * To format a number for the current Locale, use one of the static\n * factory methods:\n * <pre>\n * \\code\n *    UChar myString[20];\n *    double myNumber = 7.0;\n *    UErrorCode status = U_ZERO_ERROR;\n *    UNumberFormat* nf = unum_open(UNUM_DEFAULT, NULL, -1, NULL, NULL, &status);\n *    unum_formatDouble(nf, myNumber, myString, 20, NULL, &status);\n *    printf(\" Example 1: %s\\n\", austrdup(myString) ); //austrdup( a function used to convert UChar* to char*)\n * \\endcode\n * </pre>\n * If you are formatting multiple numbers, it is more efficient to get\n * the format and use it multiple times so that the system doesn't\n * have to fetch the information about the local language and country\n * conventions multiple times.\n * <pre>\n * \\code\n * uint32_t i, resultlength, reslenneeded;\n * UErrorCode status = U_ZERO_ERROR;\n * UFieldPosition pos;\n * uint32_t a[] = { 123, 3333, -1234567 };\n * const uint32_t a_len = sizeof(a) / sizeof(a[0]);\n * UNumberFormat* nf;\n * UChar* result = NULL;\n *\n * nf = unum_open(UNUM_DEFAULT, NULL, -1, NULL, NULL, &status);\n * for (i = 0; i < a_len; i++) {\n *    resultlength=0;\n *    reslenneeded=unum_format(nf, a[i], NULL, resultlength, &pos, &status);\n *    result = NULL;\n *    if(status==U_BUFFER_OVERFLOW_ERROR){\n *       status=U_ZERO_ERROR;\n *       resultlength=reslenneeded+1;\n *       result=(UChar*)malloc(sizeof(UChar) * resultlength);\n *       unum_format(nf, a[i], result, resultlength, &pos, &status);\n *    }\n *    printf( \" Example 2: %s\\n\", austrdup(result));\n *    free(result);\n * }\n * \\endcode\n * </pre>\n * To format a number for a different Locale, specify it in the\n * call to unum_open().\n * <pre>\n * \\code\n *     UNumberFormat* nf = unum_open(UNUM_DEFAULT, NULL, -1, \"fr_FR\", NULL, &success)\n * \\endcode\n * </pre>\n * You can use a NumberFormat API unum_parse() to parse.\n * <pre>\n * \\code\n *    UErrorCode status = U_ZERO_ERROR;\n *    int32_t pos=0;\n *    int32_t num;\n *    num = unum_parse(nf, str, u_strlen(str), &pos, &status);\n * \\endcode\n * </pre>\n * Use UNUM_DECIMAL to get the normal number format for that country.\n * There are other static options available.  Use UNUM_CURRENCY\n * to get the currency number format for that country.  Use UNUM_PERCENT\n * to get a format for displaying percentages. With this format, a\n * fraction from 0.53 is displayed as 53%.\n * <P>\n * Use a pattern to create either a DecimalFormat or a RuleBasedNumberFormat\n * formatter.  The pattern must conform to the syntax defined for those\n * formatters.\n * <P>\n * You can also control the display of numbers with such function as\n * unum_getAttributes() and unum_setAttributes(), which let you set the\n * miminum fraction digits, grouping, etc.\n * @see UNumberFormatAttributes for more details\n * <P>\n * You can also use forms of the parse and format methods with\n * ParsePosition and UFieldPosition to allow you to:\n * <ul type=round>\n *   <li>(a) progressively parse through pieces of a string.\n *   <li>(b) align the decimal point and other areas.\n * </ul>\n * <p>\n * It is also possible to change or set the symbols used for a particular\n * locale like the currency symbol, the grouping seperator , monetary seperator\n * etc by making use of functions unum_setSymbols() and unum_getSymbols().\n */\n\n/** A number formatter.\n *  For usage in C programs.\n *  @stable ICU 2.0\n */\ntypedef void* UNumberFormat;\n\n/** The possible number format styles. \n *  @stable ICU 2.0\n */\ntypedef enum UNumberFormatStyle {\n    /**\n     * Decimal format defined by a pattern string.\n     * @stable ICU 3.0\n     */\n    UNUM_PATTERN_DECIMAL=0,\n    /**\n     * Decimal format (\"normal\" style).\n     * @stable ICU 2.0\n     */\n    UNUM_DECIMAL=1,\n    /**\n     * Currency format with a currency symbol, e.g., \"$1.00\".\n     * @stable ICU 2.0\n     */\n    UNUM_CURRENCY,\n    /**\n     * Percent format\n     * @stable ICU 2.0\n     */\n    UNUM_PERCENT,\n    /**\n     * Scientific format\n     * @stable ICU 2.1\n     */\n    UNUM_SCIENTIFIC,\n    /**\n     * Spellout rule-based format\n     * @stable ICU 2.0\n     */\n    UNUM_SPELLOUT,\n    /** \n     * Ordinal rule-based format \n     * @stable ICU 3.0\n     */\n    UNUM_ORDINAL,\n    /** \n     * Duration rule-based format \n     * @stable ICU 3.0\n     */\n    UNUM_DURATION,\n    /** \n     * Numbering system rule-based format\n     * @stable ICU 4.2\n     */\n    UNUM_NUMBERING_SYSTEM,\n    /** \n     * Rule-based format defined by a pattern string.\n     * @stable ICU 3.0\n     */\n    UNUM_PATTERN_RULEBASED,\n    /**\n     * Currency format with an ISO currency code, e.g., \"USD1.00\".\n     * @stable ICU 4.8\n     */\n    UNUM_CURRENCY_ISO,\n    /**\n     * Currency format with a pluralized currency name,\n     * e.g., \"1.00 US dollar\" and \"3.00 US dollars\".\n     * @stable ICU 4.8\n     */\n    UNUM_CURRENCY_PLURAL,\n    /**\n     * One more than the highest number format style constant.\n     * @stable ICU 4.8\n     */\n    UNUM_FORMAT_STYLE_COUNT,\n    /**\n     * Default format\n     * @stable ICU 2.0\n     */\n    UNUM_DEFAULT = UNUM_DECIMAL,\n    /**\n     * Alias for UNUM_PATTERN_DECIMAL\n     * @stable ICU 3.0\n     */\n    UNUM_IGNORE = UNUM_PATTERN_DECIMAL\n} UNumberFormatStyle;\n\n/** The possible number format rounding modes. \n *  @stable ICU 2.0\n */\ntypedef enum UNumberFormatRoundingMode {\n    UNUM_ROUND_CEILING,\n    UNUM_ROUND_FLOOR,\n    UNUM_ROUND_DOWN,\n    UNUM_ROUND_UP,\n    /**\n     * Half-even rounding\n     * @stable, ICU 3.8\n     */\n    UNUM_ROUND_HALFEVEN,\n#ifndef U_HIDE_DEPRECATED_API\n    /**\n     * Half-even rounding, misspelled name\n     * @deprecated, ICU 3.8\n     */\n    UNUM_FOUND_HALFEVEN = UNUM_ROUND_HALFEVEN,\n#endif  /* U_HIDE_DEPRECATED_API */\n    UNUM_ROUND_HALFDOWN,\n    UNUM_ROUND_HALFUP,\n    /** \n      * ROUND_UNNECESSARY reports an error if formatted result is not exact.\n      * @stable ICU 4.8\n      */\n    UNUM_ROUND_UNNECESSARY\n} UNumberFormatRoundingMode;\n\n/** The possible number format pad positions. \n *  @stable ICU 2.0\n */\ntypedef enum UNumberFormatPadPosition {\n    UNUM_PAD_BEFORE_PREFIX,\n    UNUM_PAD_AFTER_PREFIX,\n    UNUM_PAD_BEFORE_SUFFIX,\n    UNUM_PAD_AFTER_SUFFIX\n} UNumberFormatPadPosition;\n\n/**\n * Constants for specifying currency spacing\n * @stable ICU 4.8\n */\nenum UCurrencySpacing {\n    /** @stable ICU 4.8 */\n    UNUM_CURRENCY_MATCH,\n    /** @stable ICU 4.8 */\n    UNUM_CURRENCY_SURROUNDING_MATCH,\n    /** @stable ICU 4.8 */\n    UNUM_CURRENCY_INSERT,\n    /** @stable ICU 4.8 */\n    UNUM_CURRENCY_SPACING_COUNT\n};\ntypedef enum UCurrencySpacing UCurrencySpacing; /**< @stable ICU 4.8 */\n\n\n/**\n * FieldPosition and UFieldPosition selectors for format fields\n * defined by NumberFormat and UNumberFormat.\n * @stable ICU 49\n */\ntypedef enum UNumberFormatFields {\n    /** @stable ICU 49 */\n    UNUM_INTEGER_FIELD,\n    /** @stable ICU 49 */\n    UNUM_FRACTION_FIELD,\n    /** @stable ICU 49 */\n    UNUM_DECIMAL_SEPARATOR_FIELD,\n    /** @stable ICU 49 */\n    UNUM_EXPONENT_SYMBOL_FIELD,\n    /** @stable ICU 49 */\n    UNUM_EXPONENT_SIGN_FIELD,\n    /** @stable ICU 49 */\n    UNUM_EXPONENT_FIELD,\n    /** @stable ICU 49 */\n    UNUM_GROUPING_SEPARATOR_FIELD,\n    /** @stable ICU 49 */\n    UNUM_CURRENCY_FIELD,\n    /** @stable ICU 49 */\n    UNUM_PERCENT_FIELD,\n    /** @stable ICU 49 */\n    UNUM_PERMILL_FIELD,\n    /** @stable ICU 49 */\n    UNUM_SIGN_FIELD,\n    /** @stable ICU 49 */\n    UNUM_FIELD_COUNT\n} UNumberFormatFields;\n\n\n/**\n * Create and return a new UNumberFormat for formatting and parsing\n * numbers.  A UNumberFormat may be used to format numbers by calling\n * {@link #unum_format }, and to parse numbers by calling {@link #unum_parse }.\n * The caller must call {@link #unum_close } when done to release resources\n * used by this object.\n * @param style The type of number format to open: one of\n * UNUM_DECIMAL, UNUM_CURRENCY, UNUM_PERCENT, UNUM_SCIENTIFIC, UNUM_SPELLOUT,\n * UNUM_PATTERN_DECIMAL, UNUM_PATTERN_RULEBASED, or UNUM_DEFAULT.\n * If UNUM_PATTERN_DECIMAL or UNUM_PATTERN_RULEBASED is passed then the\n * number format is opened using the given pattern, which must conform\n * to the syntax described in DecimalFormat or RuleBasedNumberFormat,\n * respectively.\n * @param pattern A pattern specifying the format to use. \n * This parameter is ignored unless the style is\n * UNUM_PATTERN_DECIMAL or UNUM_PATTERN_RULEBASED.\n * @param patternLength The number of characters in the pattern, or -1\n * if null-terminated. This parameter is ignored unless the style is\n * UNUM_PATTERN.\n * @param locale A locale identifier to use to determine formatting\n * and parsing conventions, or NULL to use the default locale.\n * @param parseErr A pointer to a UParseError struct to receive the\n * details of any parsing errors, or NULL if no parsing error details\n * are desired.\n * @param status A pointer to an input-output UErrorCode.\n * @return A pointer to a newly created UNumberFormat, or NULL if an\n * error occurred.\n * @see unum_close\n * @see DecimalFormat\n * @stable ICU 2.0\n */\nU_STABLE UNumberFormat* U_EXPORT2 \nunum_open(  UNumberFormatStyle    style,\n            const    UChar*    pattern,\n            int32_t            patternLength,\n            const    char*     locale,\n            UParseError*       parseErr,\n            UErrorCode*        status);\n\n\n/**\n* Close a UNumberFormat.\n* Once closed, a UNumberFormat may no longer be used.\n* @param fmt The formatter to close.\n* @stable ICU 2.0\n*/\nU_STABLE void U_EXPORT2 \nunum_close(UNumberFormat* fmt);\n\n#if U_SHOW_CPLUSPLUS_API\n\nU_NAMESPACE_BEGIN\n\n/**\n * \\class LocalUNumberFormatPointer\n * \"Smart pointer\" class, closes a UNumberFormat via unum_close().\n * For most methods see the LocalPointerBase base class.\n *\n * @see LocalPointerBase\n * @see LocalPointer\n * @stable ICU 4.4\n */\nU_DEFINE_LOCAL_OPEN_POINTER(LocalUNumberFormatPointer, UNumberFormat, unum_close);\n\nU_NAMESPACE_END\n\n#endif\n\n/**\n * Open a copy of a UNumberFormat.\n * This function performs a deep copy.\n * @param fmt The format to copy\n * @param status A pointer to an UErrorCode to receive any errors.\n * @return A pointer to a UNumberFormat identical to fmt.\n * @stable ICU 2.0\n */\nU_STABLE UNumberFormat* U_EXPORT2 \nunum_clone(const UNumberFormat *fmt,\n       UErrorCode *status);\n\n/**\n* Format an integer using a UNumberFormat.\n* The integer will be formatted according to the UNumberFormat's locale.\n* @param fmt The formatter to use.\n* @param number The number to format.\n* @param result A pointer to a buffer to receive the formatted number.\n* @param resultLength The maximum size of result.\n* @param pos    A pointer to a UFieldPosition.  On input, position->field\n* is read.  On output, position->beginIndex and position->endIndex indicate\n* the beginning and ending indices of field number position->field, if such\n* a field exists.  This parameter may be NULL, in which case no field\n* @param status A pointer to an UErrorCode to receive any errors\n* @return The total buffer size needed; if greater than resultLength, the output was truncated.\n* @see unum_formatInt64\n* @see unum_formatDouble\n* @see unum_parse\n* @see unum_parseInt64\n* @see unum_parseDouble\n* @see UFieldPosition\n* @stable ICU 2.0\n*/\nU_STABLE int32_t U_EXPORT2 \nunum_format(    const    UNumberFormat*    fmt,\n        int32_t            number,\n        UChar*            result,\n        int32_t            resultLength,\n        UFieldPosition    *pos,\n        UErrorCode*        status);\n\n/**\n* Format an int64 using a UNumberFormat.\n* The int64 will be formatted according to the UNumberFormat's locale.\n* @param fmt The formatter to use.\n* @param number The number to format.\n* @param result A pointer to a buffer to receive the formatted number.\n* @param resultLength The maximum size of result.\n* @param pos    A pointer to a UFieldPosition.  On input, position->field\n* is read.  On output, position->beginIndex and position->endIndex indicate\n* the beginning and ending indices of field number position->field, if such\n* a field exists.  This parameter may be NULL, in which case no field\n* @param status A pointer to an UErrorCode to receive any errors\n* @return The total buffer size needed; if greater than resultLength, the output was truncated.\n* @see unum_format\n* @see unum_formatDouble\n* @see unum_parse\n* @see unum_parseInt64\n* @see unum_parseDouble\n* @see UFieldPosition\n* @stable ICU 2.0\n*/\nU_STABLE int32_t U_EXPORT2 \nunum_formatInt64(const UNumberFormat *fmt,\n        int64_t         number,\n        UChar*          result,\n        int32_t         resultLength,\n        UFieldPosition *pos,\n        UErrorCode*     status);\n\n/**\n* Format a double using a UNumberFormat.\n* The double will be formatted according to the UNumberFormat's locale.\n* @param fmt The formatter to use.\n* @param number The number to format.\n* @param result A pointer to a buffer to receive the formatted number.\n* @param resultLength The maximum size of result.\n* @param pos    A pointer to a UFieldPosition.  On input, position->field\n* is read.  On output, position->beginIndex and position->endIndex indicate\n* the beginning and ending indices of field number position->field, if such\n* a field exists.  This parameter may be NULL, in which case no field\n* @param status A pointer to an UErrorCode to receive any errors\n* @return The total buffer size needed; if greater than resultLength, the output was truncated.\n* @see unum_format\n* @see unum_formatInt64\n* @see unum_parse\n* @see unum_parseInt64\n* @see unum_parseDouble\n* @see UFieldPosition\n* @stable ICU 2.0\n*/\nU_STABLE int32_t U_EXPORT2 \nunum_formatDouble(    const    UNumberFormat*  fmt,\n            double          number,\n            UChar*          result,\n            int32_t         resultLength,\n            UFieldPosition  *pos, /* 0 if ignore */\n            UErrorCode*     status);\n\n/**\n* Format a decimal number using a UNumberFormat.\n* The number will be formatted according to the UNumberFormat's locale.\n* The syntax of the input number is a \"numeric string\"\n* as defined in the Decimal Arithmetic Specification, available at\n* http://speleotrove.com/decimal\n* @param fmt The formatter to use.\n* @param number The number to format.\n* @param length The length of the input number, or -1 if the input is nul-terminated.\n* @param result A pointer to a buffer to receive the formatted number.\n* @param resultLength The maximum size of result.\n* @param pos    A pointer to a UFieldPosition.  On input, position->field\n*               is read.  On output, position->beginIndex and position->endIndex indicate\n*               the beginning and ending indices of field number position->field, if such\n*               a field exists.  This parameter may be NULL, in which case it is ignored.\n* @param status A pointer to an UErrorCode to receive any errors\n* @return The total buffer size needed; if greater than resultLength, the output was truncated.\n* @see unum_format\n* @see unum_formatInt64\n* @see unum_parse\n* @see unum_parseInt64\n* @see unum_parseDouble\n* @see UFieldPosition\n* @stable ICU 4.4 \n*/\nU_STABLE int32_t U_EXPORT2 \nunum_formatDecimal(    const    UNumberFormat*  fmt,\n            const char *    number,\n            int32_t         length,\n            UChar*          result,\n            int32_t         resultLength,\n            UFieldPosition  *pos, /* 0 if ignore */\n            UErrorCode*     status);\n\n/**\n * Format a double currency amount using a UNumberFormat.\n * The double will be formatted according to the UNumberFormat's locale.\n * @param fmt the formatter to use\n * @param number the number to format\n * @param currency the 3-letter null-terminated ISO 4217 currency code\n * @param result a pointer to the buffer to receive the formatted number\n * @param resultLength the maximum number of UChars to write to result\n * @param pos a pointer to a UFieldPosition.  On input,\n * position->field is read.  On output, position->beginIndex and\n * position->endIndex indicate the beginning and ending indices of\n * field number position->field, if such a field exists.  This\n * parameter may be NULL, in which case it is ignored.\n * @param status a pointer to an input-output UErrorCode\n * @return the total buffer size needed; if greater than resultLength,\n * the output was truncated.\n * @see unum_formatDouble\n * @see unum_parseDoubleCurrency\n * @see UFieldPosition\n * @stable ICU 3.0\n */\nU_STABLE int32_t U_EXPORT2 \nunum_formatDoubleCurrency(const UNumberFormat* fmt,\n                          double number,\n                          UChar* currency,\n                          UChar* result,\n                          int32_t resultLength,\n                          UFieldPosition* pos, /* ignored if 0 */\n                          UErrorCode* status);\n\n/**\n* Parse a string into an integer using a UNumberFormat.\n* The string will be parsed according to the UNumberFormat's locale.\n* @param fmt The formatter to use.\n* @param text The text to parse.\n* @param textLength The length of text, or -1 if null-terminated.\n* @param parsePos If not 0, on input a pointer to an integer specifying the offset at which\n* to begin parsing.  If not 0, on output the offset at which parsing ended.\n* @param status A pointer to an UErrorCode to receive any errors\n* @return The value of the parsed integer\n* @see unum_parseInt64\n* @see unum_parseDouble\n* @see unum_format\n* @see unum_formatInt64\n* @see unum_formatDouble\n* @stable ICU 2.0\n*/\nU_STABLE int32_t U_EXPORT2 \nunum_parse(    const   UNumberFormat*  fmt,\n        const   UChar*          text,\n        int32_t         textLength,\n        int32_t         *parsePos /* 0 = start */,\n        UErrorCode      *status);\n\n/**\n* Parse a string into an int64 using a UNumberFormat.\n* The string will be parsed according to the UNumberFormat's locale.\n* @param fmt The formatter to use.\n* @param text The text to parse.\n* @param textLength The length of text, or -1 if null-terminated.\n* @param parsePos If not 0, on input a pointer to an integer specifying the offset at which\n* to begin parsing.  If not 0, on output the offset at which parsing ended.\n* @param status A pointer to an UErrorCode to receive any errors\n* @return The value of the parsed integer\n* @see unum_parse\n* @see unum_parseDouble\n* @see unum_format\n* @see unum_formatInt64\n* @see unum_formatDouble\n* @stable ICU 2.8\n*/\nU_STABLE int64_t U_EXPORT2 \nunum_parseInt64(const UNumberFormat*  fmt,\n        const UChar*  text,\n        int32_t       textLength,\n        int32_t       *parsePos /* 0 = start */,\n        UErrorCode    *status);\n\n/**\n* Parse a string into a double using a UNumberFormat.\n* The string will be parsed according to the UNumberFormat's locale.\n* @param fmt The formatter to use.\n* @param text The text to parse.\n* @param textLength The length of text, or -1 if null-terminated.\n* @param parsePos If not 0, on input a pointer to an integer specifying the offset at which\n* to begin parsing.  If not 0, on output the offset at which parsing ended.\n* @param status A pointer to an UErrorCode to receive any errors\n* @return The value of the parsed double\n* @see unum_parse\n* @see unum_parseInt64\n* @see unum_format\n* @see unum_formatInt64\n* @see unum_formatDouble\n* @stable ICU 2.0\n*/\nU_STABLE double U_EXPORT2 \nunum_parseDouble(    const   UNumberFormat*  fmt,\n            const   UChar*          text,\n            int32_t         textLength,\n            int32_t         *parsePos /* 0 = start */,\n            UErrorCode      *status);\n\n\n/**\n* Parse a number from a string into an unformatted numeric string using a UNumberFormat.\n* The input string will be parsed according to the UNumberFormat's locale.\n* The syntax of the output is a \"numeric string\"\n* as defined in the Decimal Arithmetic Specification, available at\n* http://speleotrove.com/decimal\n* @param fmt The formatter to use.\n* @param text The text to parse.\n* @param textLength The length of text, or -1 if null-terminated.\n* @param parsePos If not 0, on input a pointer to an integer specifying the offset at which\n*                 to begin parsing.  If not 0, on output the offset at which parsing ended.\n* @param outBuf A (char *) buffer to receive the parsed number as a string.  The output string\n*               will be nul-terminated if there is sufficient space.\n* @param outBufLength The size of the output buffer.  May be zero, in which case\n*               the outBuf pointer may be NULL, and the function will return the\n*               size of the output string.\n* @param status A pointer to an UErrorCode to receive any errors\n* @return the length of the output string, not including any terminating nul.\n* @see unum_parse\n* @see unum_parseInt64\n* @see unum_format\n* @see unum_formatInt64\n* @see unum_formatDouble\n* @stable ICU 4.4\n*/\nU_STABLE int32_t U_EXPORT2 \nunum_parseDecimal(const   UNumberFormat*  fmt,\n                 const   UChar*          text,\n                         int32_t         textLength,\n                         int32_t         *parsePos /* 0 = start */,\n                         char            *outBuf,\n                         int32_t         outBufLength,\n                         UErrorCode      *status);\n\n/**\n * Parse a string into a double and a currency using a UNumberFormat.\n * The string will be parsed according to the UNumberFormat's locale.\n * @param fmt the formatter to use\n * @param text the text to parse\n * @param textLength the length of text, or -1 if null-terminated\n * @param parsePos a pointer to an offset index into text at which to\n * begin parsing. On output, *parsePos will point after the last\n * parsed character.  This parameter may be 0, in which case parsing\n * begins at offset 0.\n * @param currency a pointer to the buffer to receive the parsed null-\n * terminated currency.  This buffer must have a capacity of at least\n * 4 UChars.\n * @param status a pointer to an input-output UErrorCode\n * @return the parsed double\n * @see unum_parseDouble\n * @see unum_formatDoubleCurrency\n * @stable ICU 3.0\n */\nU_STABLE double U_EXPORT2\nunum_parseDoubleCurrency(const UNumberFormat* fmt,\n                         const UChar* text,\n                         int32_t textLength,\n                         int32_t* parsePos, /* 0 = start */\n                         UChar* currency,\n                         UErrorCode* status);\n\n/**\n * Set the pattern used by a UNumberFormat.  This can only be used\n * on a DecimalFormat, other formats return U_UNSUPPORTED_ERROR\n * in the status.\n * @param format The formatter to set.\n * @param localized TRUE if the pattern is localized, FALSE otherwise.\n * @param pattern The new pattern\n * @param patternLength The length of pattern, or -1 if null-terminated.\n * @param parseError A pointer to UParseError to recieve information\n * about errors occurred during parsing, or NULL if no parse error\n * information is desired.\n * @param status A pointer to an input-output UErrorCode.\n * @see unum_toPattern\n * @see DecimalFormat\n * @stable ICU 2.0\n */\nU_STABLE void U_EXPORT2 \nunum_applyPattern(          UNumberFormat  *format,\n                            UBool          localized,\n                    const   UChar          *pattern,\n                            int32_t         patternLength,\n                            UParseError    *parseError,\n                            UErrorCode     *status\n                                    );\n\n/**\n* Get a locale for which decimal formatting patterns are available.\n* A UNumberFormat in a locale returned by this function will perform the correct\n* formatting and parsing for the locale.  The results of this call are not\n* valid for rule-based number formats.\n* @param localeIndex The index of the desired locale.\n* @return A locale for which number formatting patterns are available, or 0 if none.\n* @see unum_countAvailable\n* @stable ICU 2.0\n*/\nU_STABLE const char* U_EXPORT2 \nunum_getAvailable(int32_t localeIndex);\n\n/**\n* Determine how many locales have decimal formatting patterns available.  The\n* results of this call are not valid for rule-based number formats.\n* This function is useful for determining the loop ending condition for\n* calls to {@link #unum_getAvailable }.\n* @return The number of locales for which decimal formatting patterns are available.\n* @see unum_getAvailable\n* @stable ICU 2.0\n*/\nU_STABLE int32_t U_EXPORT2 \nunum_countAvailable(void);\n\n#if UCONFIG_HAVE_PARSEALLINPUT\n/**\n * @internal\n */\ntypedef enum UNumberFormatAttributeValue {\n  /** @internal */\n  UNUM_NO = 0,\n  /** @internal */\n  UNUM_YES = 1,\n  /** @internal */\n  UNUM_MAYBE = 2\n} UNumberFormatAttributeValue;\n#endif\n\n/** The possible UNumberFormat numeric attributes @stable ICU 2.0 */\ntypedef enum UNumberFormatAttribute {\n  /** Parse integers only */\n  UNUM_PARSE_INT_ONLY,\n  /** Use grouping separator */\n  UNUM_GROUPING_USED,\n  /** Always show decimal point */\n  UNUM_DECIMAL_ALWAYS_SHOWN,\n  /** Maximum integer digits */\n  UNUM_MAX_INTEGER_DIGITS,\n  /** Minimum integer digits */\n  UNUM_MIN_INTEGER_DIGITS,\n  /** Integer digits */\n  UNUM_INTEGER_DIGITS,\n  /** Maximum fraction digits */\n  UNUM_MAX_FRACTION_DIGITS,\n  /** Minimum fraction digits */\n  UNUM_MIN_FRACTION_DIGITS,\n  /** Fraction digits */\n  UNUM_FRACTION_DIGITS,\n  /** Multiplier */\n  UNUM_MULTIPLIER,\n  /** Grouping size */\n  UNUM_GROUPING_SIZE,\n  /** Rounding Mode */\n  UNUM_ROUNDING_MODE,\n  /** Rounding increment */\n  UNUM_ROUNDING_INCREMENT,\n  /** The width to which the output of <code>format()</code> is padded. */\n  UNUM_FORMAT_WIDTH,\n  /** The position at which padding will take place. */\n  UNUM_PADDING_POSITION,\n  /** Secondary grouping size */\n  UNUM_SECONDARY_GROUPING_SIZE,\n  /** Use significant digits\n   * @stable ICU 3.0 */\n  UNUM_SIGNIFICANT_DIGITS_USED,\n  /** Minimum significant digits\n   * @stable ICU 3.0 */\n  UNUM_MIN_SIGNIFICANT_DIGITS,\n  /** Maximum significant digits\n   * @stable ICU 3.0 */\n  UNUM_MAX_SIGNIFICANT_DIGITS,\n  /** Lenient parse mode used by rule-based formats.\n   * @stable ICU 3.0\n   */\n  UNUM_LENIENT_PARSE,\n#if UCONFIG_HAVE_PARSEALLINPUT\n  /** Consume all input. (may use fastpath). Set to UNUM_YES (require fastpath), UNUM_NO (skip fastpath), or UNUM_MAYBE (heuristic).\n   * This is an internal ICU API. Do not use.\n   * @internal\n   */\n  UNUM_PARSE_ALL_INPUT,\n#endif\n\n  /** Count of \"regular\" numeric attributes.\n   * @internal */\n  UNUM_NUMERIC_ATTRIBUTE_COUNT,\n\n  /** One below the first bitfield-boolean item.\n   * All items after this one are stored in boolean form.\n   * @internal */\n  UNUM_MAX_NONBOOLEAN_ATTRIBUTE = 0x0FFF,\n\n  /** If 1, specifies that if setting the \"max integer digits\" attribute would truncate a value, set an error status rather than silently truncating.\n   * For example,  formatting the value 1234 with 4 max int digits would succeed, but formatting 12345 would fail. There is no effect on parsing.\n   * Default: 0 (not set)\n   * @draft ICU 50\n   */\n  UNUM_FORMAT_FAIL_IF_MORE_THAN_MAX_DIGITS,\n  /** \n   * if this attribute is set to 1, specifies that, if the pattern doesn't contain an exponent, the exponent will not be parsed. If the pattern does contain an exponent, this attribute has no effect.\n   * Has no effect on formatting.\n   * Default: 0 (unset)\n   * @draft ICU 50\n   */\n  UNUM_PARSE_NO_EXPONENT,\n\n  /** Limit of boolean attributes.\n   * @internal */\n  UNUM_LIMIT_BOOLEAN_ATTRIBUTE\n} UNumberFormatAttribute;\n\n/**\n* Get a numeric attribute associated with a UNumberFormat.\n* An example of a numeric attribute is the number of integer digits a formatter will produce.\n* @param fmt The formatter to query.\n* @param attr The attribute to query; one of UNUM_PARSE_INT_ONLY, UNUM_GROUPING_USED,\n* UNUM_DECIMAL_ALWAYS_SHOWN, UNUM_MAX_INTEGER_DIGITS, UNUM_MIN_INTEGER_DIGITS, UNUM_INTEGER_DIGITS,\n* UNUM_MAX_FRACTION_DIGITS, UNUM_MIN_FRACTION_DIGITS, UNUM_FRACTION_DIGITS, UNUM_MULTIPLIER,\n* UNUM_GROUPING_SIZE, UNUM_ROUNDING_MODE, UNUM_FORMAT_WIDTH, UNUM_PADDING_POSITION, UNUM_SECONDARY_GROUPING_SIZE.\n* @return The value of attr.\n* @see unum_setAttribute\n* @see unum_getDoubleAttribute\n* @see unum_setDoubleAttribute\n* @see unum_getTextAttribute\n* @see unum_setTextAttribute\n* @stable ICU 2.0\n*/\nU_STABLE int32_t U_EXPORT2 \nunum_getAttribute(const UNumberFormat*          fmt,\n          UNumberFormatAttribute  attr);\n\n/**\n* Set a numeric attribute associated with a UNumberFormat.\n* An example of a numeric attribute is the number of integer digits a formatter will produce.  If the\n* formatter does not understand the attribute, the call is ignored.  Rule-based formatters only understand\n* the lenient-parse attribute.\n* @param fmt The formatter to set.\n* @param attr The attribute to set; one of UNUM_PARSE_INT_ONLY, UNUM_GROUPING_USED,\n* UNUM_DECIMAL_ALWAYS_SHOWN, UNUM_MAX_INTEGER_DIGITS, UNUM_MIN_INTEGER_DIGITS, UNUM_INTEGER_DIGITS,\n* UNUM_MAX_FRACTION_DIGITS, UNUM_MIN_FRACTION_DIGITS, UNUM_FRACTION_DIGITS, UNUM_MULTIPLIER,\n* UNUM_GROUPING_SIZE, UNUM_ROUNDING_MODE, UNUM_FORMAT_WIDTH, UNUM_PADDING_POSITION, UNUM_SECONDARY_GROUPING_SIZE,\n* or UNUM_LENIENT_PARSE.\n* @param newValue The new value of attr.\n* @see unum_getAttribute\n* @see unum_getDoubleAttribute\n* @see unum_setDoubleAttribute\n* @see unum_getTextAttribute\n* @see unum_setTextAttribute\n* @stable ICU 2.0\n*/\nU_STABLE void U_EXPORT2 \nunum_setAttribute(    UNumberFormat*          fmt,\n            UNumberFormatAttribute  attr,\n            int32_t                 newValue);\n\n\n/**\n* Get a numeric attribute associated with a UNumberFormat.\n* An example of a numeric attribute is the number of integer digits a formatter will produce.\n* If the formatter does not understand the attribute, -1 is returned.\n* @param fmt The formatter to query.\n* @param attr The attribute to query; e.g. UNUM_ROUNDING_INCREMENT.\n* @return The value of attr.\n* @see unum_getAttribute\n* @see unum_setAttribute\n* @see unum_setDoubleAttribute\n* @see unum_getTextAttribute\n* @see unum_setTextAttribute\n* @stable ICU 2.0\n*/\nU_STABLE double U_EXPORT2 \nunum_getDoubleAttribute(const UNumberFormat*          fmt,\n          UNumberFormatAttribute  attr);\n\n/**\n* Set a numeric attribute associated with a UNumberFormat.\n* An example of a numeric attribute is the number of integer digits a formatter will produce.\n* If the formatter does not understand the attribute, this call is ignored.\n* @param fmt The formatter to set.\n* @param attr The attribute to set; e.g. UNUM_ROUNDING_INCREMENT.\n* @param newValue The new value of attr.\n* @see unum_getAttribute\n* @see unum_setAttribute\n* @see unum_getDoubleAttribute\n* @see unum_getTextAttribute\n* @see unum_setTextAttribute\n* @stable ICU 2.0\n*/\nU_STABLE void U_EXPORT2 \nunum_setDoubleAttribute(    UNumberFormat*          fmt,\n            UNumberFormatAttribute  attr,\n            double                 newValue);\n\n/** The possible UNumberFormat text attributes @stable ICU 2.0*/\ntypedef enum UNumberFormatTextAttribute {\n  /** Positive prefix */\n  UNUM_POSITIVE_PREFIX,\n  /** Positive suffix */\n  UNUM_POSITIVE_SUFFIX,\n  /** Negative prefix */\n  UNUM_NEGATIVE_PREFIX,\n  /** Negative suffix */\n  UNUM_NEGATIVE_SUFFIX,\n  /** The character used to pad to the format width. */\n  UNUM_PADDING_CHARACTER,\n  /** The ISO currency code */\n  UNUM_CURRENCY_CODE,\n  /**\n   * The default rule set.  This is only available with rule-based formatters.\n   * @stable ICU 3.0\n   */\n  UNUM_DEFAULT_RULESET,\n  /**\n   * The public rule sets.  This is only available with rule-based formatters.\n   * This is a read-only attribute.  The public rulesets are returned as a\n   * single string, with each ruleset name delimited by ';' (semicolon).\n   * @stable ICU 3.0\n   */\n  UNUM_PUBLIC_RULESETS\n} UNumberFormatTextAttribute;\n\n/**\n* Get a text attribute associated with a UNumberFormat.\n* An example of a text attribute is the suffix for positive numbers.  If the formatter\n* does not understand the attribute, U_UNSUPPORTED_ERROR is returned as the status.\n* Rule-based formatters only understand UNUM_DEFAULT_RULESET and UNUM_PUBLIC_RULESETS.\n* @param fmt The formatter to query.\n* @param tag The attribute to query; one of UNUM_POSITIVE_PREFIX, UNUM_POSITIVE_SUFFIX,\n* UNUM_NEGATIVE_PREFIX, UNUM_NEGATIVE_SUFFIX, UNUM_PADDING_CHARACTER, UNUM_CURRENCY_CODE,\n* UNUM_DEFAULT_RULESET, or UNUM_PUBLIC_RULESETS.\n* @param result A pointer to a buffer to receive the attribute.\n* @param resultLength The maximum size of result.\n* @param status A pointer to an UErrorCode to receive any errors\n* @return The total buffer size needed; if greater than resultLength, the output was truncated.\n* @see unum_setTextAttribute\n* @see unum_getAttribute\n* @see unum_setAttribute\n* @stable ICU 2.0\n*/\nU_STABLE int32_t U_EXPORT2 \nunum_getTextAttribute(    const    UNumberFormat*                    fmt,\n            UNumberFormatTextAttribute      tag,\n            UChar*                            result,\n            int32_t                            resultLength,\n            UErrorCode*                        status);\n\n/**\n* Set a text attribute associated with a UNumberFormat.\n* An example of a text attribute is the suffix for positive numbers.  Rule-based formatters\n* only understand UNUM_DEFAULT_RULESET.\n* @param fmt The formatter to set.\n* @param tag The attribute to set; one of UNUM_POSITIVE_PREFIX, UNUM_POSITIVE_SUFFIX,\n* UNUM_NEGATIVE_PREFIX, UNUM_NEGATIVE_SUFFIX, UNUM_PADDING_CHARACTER, UNUM_CURRENCY_CODE,\n* or UNUM_DEFAULT_RULESET.\n* @param newValue The new value of attr.\n* @param newValueLength The length of newValue, or -1 if null-terminated.\n* @param status A pointer to an UErrorCode to receive any errors\n* @see unum_getTextAttribute\n* @see unum_getAttribute\n* @see unum_setAttribute\n* @stable ICU 2.0\n*/\nU_STABLE void U_EXPORT2 \nunum_setTextAttribute(    UNumberFormat*                    fmt,\n            UNumberFormatTextAttribute      tag,\n            const    UChar*                            newValue,\n            int32_t                            newValueLength,\n            UErrorCode                        *status);\n\n/**\n * Extract the pattern from a UNumberFormat.  The pattern will follow\n * the DecimalFormat pattern syntax.\n * @param fmt The formatter to query.\n * @param isPatternLocalized TRUE if the pattern should be localized,\n * FALSE otherwise.  This is ignored if the formatter is a rule-based\n * formatter.\n * @param result A pointer to a buffer to receive the pattern.\n * @param resultLength The maximum size of result.\n * @param status A pointer to an input-output UErrorCode.\n * @return The total buffer size needed; if greater than resultLength,\n * the output was truncated.\n * @see unum_applyPattern\n * @see DecimalFormat\n * @stable ICU 2.0\n */\nU_STABLE int32_t U_EXPORT2 \nunum_toPattern(    const    UNumberFormat*          fmt,\n        UBool                  isPatternLocalized,\n        UChar*                  result,\n        int32_t                 resultLength,\n        UErrorCode*             status);\n\n\n/**\n * Constants for specifying a number format symbol.\n * @stable ICU 2.0\n */\ntypedef enum UNumberFormatSymbol {\n  /** The decimal separator */\n  UNUM_DECIMAL_SEPARATOR_SYMBOL = 0,\n  /** The grouping separator */\n  UNUM_GROUPING_SEPARATOR_SYMBOL = 1,\n  /** The pattern separator */\n  UNUM_PATTERN_SEPARATOR_SYMBOL = 2,\n  /** The percent sign */\n  UNUM_PERCENT_SYMBOL = 3,\n  /** Zero*/\n  UNUM_ZERO_DIGIT_SYMBOL = 4,\n  /** Character representing a digit in the pattern */\n  UNUM_DIGIT_SYMBOL = 5,\n  /** The minus sign */\n  UNUM_MINUS_SIGN_SYMBOL = 6,\n  /** The plus sign */\n  UNUM_PLUS_SIGN_SYMBOL = 7,\n  /** The currency symbol */\n  UNUM_CURRENCY_SYMBOL = 8,\n  /** The international currency symbol */\n  UNUM_INTL_CURRENCY_SYMBOL = 9,\n  /** The monetary separator */\n  UNUM_MONETARY_SEPARATOR_SYMBOL = 10,\n  /** The exponential symbol */\n  UNUM_EXPONENTIAL_SYMBOL = 11,\n  /** Per mill symbol */\n  UNUM_PERMILL_SYMBOL = 12,\n  /** Escape padding character */\n  UNUM_PAD_ESCAPE_SYMBOL = 13,\n  /** Infinity symbol */\n  UNUM_INFINITY_SYMBOL = 14,\n  /** Nan symbol */\n  UNUM_NAN_SYMBOL = 15,\n  /** Significant digit symbol\n   * @stable ICU 3.0 */\n  UNUM_SIGNIFICANT_DIGIT_SYMBOL = 16,\n  /** The monetary grouping separator \n   * @stable ICU 3.6\n   */\n  UNUM_MONETARY_GROUPING_SEPARATOR_SYMBOL = 17,\n  /** One\n   * @stable ICU 4.6\n   */\n  UNUM_ONE_DIGIT_SYMBOL = 18,\n  /** Two\n   * @stable ICU 4.6\n   */\n  UNUM_TWO_DIGIT_SYMBOL = 19,\n  /** Three\n   * @stable ICU 4.6\n   */\n  UNUM_THREE_DIGIT_SYMBOL = 20,\n  /** Four\n   * @stable ICU 4.6\n   */\n  UNUM_FOUR_DIGIT_SYMBOL = 21,\n  /** Five\n   * @stable ICU 4.6\n   */\n  UNUM_FIVE_DIGIT_SYMBOL = 22,\n  /** Six\n   * @stable ICU 4.6\n   */\n  UNUM_SIX_DIGIT_SYMBOL = 23,\n  /** Seven\n    * @stable ICU 4.6\n   */\n  UNUM_SEVEN_DIGIT_SYMBOL = 24,\n  /** Eight\n   * @stable ICU 4.6\n   */\n  UNUM_EIGHT_DIGIT_SYMBOL = 25,\n  /** Nine\n   * @stable ICU 4.6\n   */\n  UNUM_NINE_DIGIT_SYMBOL = 26,\n  /** count symbol constants */\n  UNUM_FORMAT_SYMBOL_COUNT = 27\n} UNumberFormatSymbol;\n\n/**\n* Get a symbol associated with a UNumberFormat.\n* A UNumberFormat uses symbols to represent the special locale-dependent\n* characters in a number, for example the percent sign. This API is not\n* supported for rule-based formatters.\n* @param fmt The formatter to query.\n* @param symbol The UNumberFormatSymbol constant for the symbol to get\n* @param buffer The string buffer that will receive the symbol string;\n*               if it is NULL, then only the length of the symbol is returned\n* @param size The size of the string buffer\n* @param status A pointer to an UErrorCode to receive any errors\n* @return The length of the symbol; the buffer is not modified if\n*         <code>length&gt;=size</code>\n* @see unum_setSymbol\n* @stable ICU 2.0\n*/\nU_STABLE int32_t U_EXPORT2\nunum_getSymbol(const UNumberFormat *fmt,\n               UNumberFormatSymbol symbol,\n               UChar *buffer,\n               int32_t size,\n               UErrorCode *status);\n\n/**\n* Set a symbol associated with a UNumberFormat.\n* A UNumberFormat uses symbols to represent the special locale-dependent\n* characters in a number, for example the percent sign.  This API is not\n* supported for rule-based formatters.\n* @param fmt The formatter to set.\n* @param symbol The UNumberFormatSymbol constant for the symbol to set\n* @param value The string to set the symbol to\n* @param length The length of the string, or -1 for a zero-terminated string\n* @param status A pointer to an UErrorCode to receive any errors.\n* @see unum_getSymbol\n* @stable ICU 2.0\n*/\nU_STABLE void U_EXPORT2\nunum_setSymbol(UNumberFormat *fmt,\n               UNumberFormatSymbol symbol,\n               const UChar *value,\n               int32_t length,\n               UErrorCode *status);\n\n\n/**\n * Get the locale for this number format object.\n * You can choose between valid and actual locale.\n * @param fmt The formatter to get the locale from\n * @param type type of the locale we're looking for (valid or actual) \n * @param status error code for the operation\n * @return the locale name\n * @stable ICU 2.8\n */\nU_STABLE const char* U_EXPORT2\nunum_getLocaleByType(const UNumberFormat *fmt,\n                     ULocDataLocaleType type,\n                     UErrorCode* status); \n\n#endif /* #if !UCONFIG_NO_FORMATTING */\n\n#endif\n"
  },
  {
    "path": "deprecated/android/addons/icucompat/unicode/uobject.h",
    "content": "/*\n******************************************************************************\n*\n*   Copyright (C) 2002-2012, International Business Machines\n*   Corporation and others.  All Rights Reserved.\n*\n******************************************************************************\n*   file name:  uobject.h\n*   encoding:   US-ASCII\n*   tab size:   8 (not used)\n*   indentation:4\n*\n*   created on: 2002jun26\n*   created by: Markus W. Scherer\n*/\n\n#ifndef __UOBJECT_H__\n#define __UOBJECT_H__\n\n#include \"unicode/utypes.h\"\n\n/**\n * \\file\n * \\brief C++ API: Common ICU base class UObject.\n */\n\n/**\n * @{\n * \\def U_NO_THROW\n *         Define this to define the throw() specification so\n *                 certain functions do not throw any exceptions\n *\n *         UMemory operator new methods should have the throw() specification \n *         appended to them, so that the compiler adds the additional NULL check \n *         before calling constructors. Without, if <code>operator new</code> returns NULL the \n *         constructor is still called, and if the constructor references member \n *         data, (which it typically does), the result is a segmentation violation.\n *\n * @stable ICU 4.2\n */\n#ifndef U_NO_THROW\n#define U_NO_THROW throw()\n#endif\n\n/** @} */\n\n/*===========================================================================*/\n/* UClassID-based RTTI */\n/*===========================================================================*/\n\n/**\n * UClassID is used to identify classes without using the compiler's RTTI.\n * This was used before C++ compilers consistently supported RTTI.\n * ICU 4.6 requires compiler RTTI to be turned on.\n *\n * Each class hierarchy which needs\n * to implement polymorphic clone() or operator==() defines two methods,\n * described in detail below.  UClassID values can be compared using\n * operator==(). Nothing else should be done with them.\n *\n * \\par\n * getDynamicClassID() is declared in the base class of the hierarchy as\n * a pure virtual.  Each concrete subclass implements it in the same way:\n *\n * \\code\n *      class Base {\n *      public:\n *          virtual UClassID getDynamicClassID() const = 0;\n *      }\n *\n *      class Derived {\n *      public:\n *          virtual UClassID getDynamicClassID() const\n *            { return Derived::getStaticClassID(); }\n *      }\n * \\endcode\n *\n * Each concrete class implements getStaticClassID() as well, which allows\n * clients to test for a specific type.\n *\n * \\code\n *      class Derived {\n *      public:\n *          static UClassID U_EXPORT2 getStaticClassID();\n *      private:\n *          static char fgClassID;\n *      }\n *\n *      // In Derived.cpp:\n *      UClassID Derived::getStaticClassID()\n *        { return (UClassID)&Derived::fgClassID; }\n *      char Derived::fgClassID = 0; // Value is irrelevant\n * \\endcode\n * @stable ICU 2.0\n */\ntypedef void* UClassID;\n\nU_NAMESPACE_BEGIN\n\n/**\n * UMemory is the common ICU base class.\n * All other ICU C++ classes are derived from UMemory (starting with ICU 2.4).\n *\n * This is primarily to make it possible and simple to override the\n * C++ memory management by adding new/delete operators to this base class.\n *\n * To override ALL ICU memory management, including that from plain C code,\n * replace the allocation functions declared in cmemory.h\n *\n * UMemory does not contain any virtual functions.\n * Common \"boilerplate\" functions are defined in UObject.\n *\n * @stable ICU 2.4\n */\nclass U_COMMON_API UMemory {\npublic:\n\n/* test versions for debugging shaper heap memory problems */\n#ifdef SHAPER_MEMORY_DEBUG  \n    static void * NewArray(int size, int count);\n    static void * GrowArray(void * array, int newSize );\n    static void   FreeArray(void * array );\n#endif\n\n#if U_OVERRIDE_CXX_ALLOCATION\n    /**\n     * Override for ICU4C C++ memory management.\n     * simple, non-class types are allocated using the macros in common/cmemory.h\n     * (uprv_malloc(), uprv_free(), uprv_realloc());\n     * they or something else could be used here to implement C++ new/delete\n     * for ICU4C C++ classes\n     * @stable ICU 2.4\n     */\n    static void * U_EXPORT2 operator new(size_t size) U_NO_THROW;\n\n    /**\n     * Override for ICU4C C++ memory management.\n     * See new().\n     * @stable ICU 2.4\n     */\n    static void * U_EXPORT2 operator new[](size_t size) U_NO_THROW;\n\n    /**\n     * Override for ICU4C C++ memory management.\n     * simple, non-class types are allocated using the macros in common/cmemory.h\n     * (uprv_malloc(), uprv_free(), uprv_realloc());\n     * they or something else could be used here to implement C++ new/delete\n     * for ICU4C C++ classes\n     * @stable ICU 2.4\n     */\n    static void U_EXPORT2 operator delete(void *p) U_NO_THROW;\n\n    /**\n     * Override for ICU4C C++ memory management.\n     * See delete().\n     * @stable ICU 2.4\n     */\n    static void U_EXPORT2 operator delete[](void *p) U_NO_THROW;\n\n#if U_HAVE_PLACEMENT_NEW\n    /**\n     * Override for ICU4C C++ memory management for STL.\n     * See new().\n     * @stable ICU 2.6\n     */\n    static inline void * U_EXPORT2 operator new(size_t, void *ptr) U_NO_THROW { return ptr; }\n\n    /**\n     * Override for ICU4C C++ memory management for STL.\n     * See delete().\n     * @stable ICU 2.6\n     */\n    static inline void U_EXPORT2 operator delete(void *, void *) U_NO_THROW {}\n#endif /* U_HAVE_PLACEMENT_NEW */\n#if U_HAVE_DEBUG_LOCATION_NEW\n    /**\n      * This method overrides the MFC debug version of the operator new\n      * \n      * @param size   The requested memory size\n      * @param file   The file where the allocation was requested\n      * @param line   The line where the allocation was requested \n      */ \n    static void * U_EXPORT2 operator new(size_t size, const char* file, int line) U_NO_THROW;\n    /**\n      * This method provides a matching delete for the MFC debug new\n      * \n      * @param p      The pointer to the allocated memory\n      * @param file   The file where the allocation was requested\n      * @param line   The line where the allocation was requested \n      */ \n    static void U_EXPORT2 operator delete(void* p, const char* file, int line) U_NO_THROW;\n#endif /* U_HAVE_DEBUG_LOCATION_NEW */\n#endif /* U_OVERRIDE_CXX_ALLOCATION */\n\n    /*\n     * Assignment operator not declared. The compiler will provide one\n     * which does nothing since this class does not contain any data members.\n     * API/code coverage may show the assignment operator as present and\n     * untested - ignore.\n     * Subclasses need this assignment operator if they use compiler-provided\n     * assignment operators of their own. An alternative to not declaring one\n     * here would be to declare and empty-implement a protected or public one.\n    UMemory &UMemory::operator=(const UMemory &);\n     */\n};\n\n/**\n * UObject is the common ICU \"boilerplate\" class.\n * UObject inherits UMemory (starting with ICU 2.4),\n * and all other public ICU C++ classes\n * are derived from UObject (starting with ICU 2.2).\n *\n * UObject contains common virtual functions like for ICU's \"poor man's RTTI\".\n * It does not contain default implementations of virtual methods\n * like getDynamicClassID to allow derived classes such as Format\n * to declare these as pure virtual.\n *\n * The clone() function is not available in UObject because it is not\n * implemented by all ICU classes.\n * Many ICU services provide a clone() function for their class trees,\n * defined on the service's C++ base class, and all subclasses within that\n * service class tree return a pointer to the service base class\n * (which itself is a subclass of UObject).\n * This is because some compilers do not support covariant (same-as-this)\n * return types; cast to the appropriate subclass if necessary.\n *\n * @stable ICU 2.2\n */\nclass U_COMMON_API UObject : public UMemory {\npublic:\n    /**\n     * Destructor.\n     *\n     * @stable ICU 2.2\n     */\n    virtual ~UObject();\n\n    /**\n     * ICU4C \"poor man's RTTI\", returns a UClassID for the actual ICU class.\n     *\n     * @stable ICU 2.2\n     */\n    virtual UClassID getDynamicClassID() const;  // Android patch: tiny part of ICU 51's r32776\n\nprotected:\n    // the following functions are protected to prevent instantiation and\n    // direct use of UObject itself\n\n    // default constructor\n    // commented out because UObject is abstract (see getDynamicClassID)\n    // inline UObject() {}\n\n    // copy constructor\n    // commented out because UObject is abstract (see getDynamicClassID)\n    // inline UObject(const UObject &other) {}\n\n#if 0\n    // TODO Sometime in the future. Implement operator==().\n    // (This comment inserted in 2.2)\n    // some or all of the following \"boilerplate\" functions may be made public\n    // in a future ICU4C release when all subclasses implement them\n\n    // assignment operator\n    // (not virtual, see \"Taligent's Guide to Designing Programs\" pp.73..74)\n    // commented out because the implementation is the same as a compiler's default\n    // UObject &operator=(const UObject &other) { return *this; }\n\n    // comparison operators\n    virtual inline UBool operator==(const UObject &other) const { return this==&other; }\n    inline UBool operator!=(const UObject &other) const { return !operator==(other); }\n\n    // clone() commented out from the base class:\n    // some compilers do not support co-variant return types\n    // (i.e., subclasses would have to return UObject * as well, instead of SubClass *)\n    // see also UObject class documentation.\n    // virtual UObject *clone() const;\n#endif\n\n    /*\n     * Assignment operator not declared. The compiler will provide one\n     * which does nothing since this class does not contain any data members.\n     * API/code coverage may show the assignment operator as present and\n     * untested - ignore.\n     * Subclasses need this assignment operator if they use compiler-provided\n     * assignment operators of their own. An alternative to not declaring one\n     * here would be to declare and empty-implement a protected or public one.\n    UObject &UObject::operator=(const UObject &);\n     */\n\n// Future implementation for RTTI that support subtyping. [alan]\n// \n//  public:\n//     /**\n//      * @internal\n//      */\n//     static UClassID getStaticClassID();\n// \n//     /**\n//      * @internal\n//      */\n//     UBool instanceOf(UClassID type) const;\n};\n\n#ifndef U_HIDE_INTERNAL_API\n/**\n * This is a simple macro to add ICU RTTI to an ICU object implementation.\n * This does not go into the header. This should only be used in *.cpp files.\n *\n * @param myClass The name of the class that needs RTTI defined.\n * @internal\n */\n#define UOBJECT_DEFINE_RTTI_IMPLEMENTATION(myClass) \\\n    UClassID U_EXPORT2 myClass::getStaticClassID() { \\\n        static char classID = 0; \\\n        return (UClassID)&classID; \\\n    } \\\n    UClassID myClass::getDynamicClassID() const \\\n    { return myClass::getStaticClassID(); }\n\n\n/**\n * This macro adds ICU RTTI to an ICU abstract class implementation.\n * This macro should be invoked in *.cpp files.  The corresponding\n * header should declare getStaticClassID.\n *\n * @param myClass The name of the class that needs RTTI defined.\n * @internal\n */\n#define UOBJECT_DEFINE_ABSTRACT_RTTI_IMPLEMENTATION(myClass) \\\n    UClassID U_EXPORT2 myClass::getStaticClassID() { \\\n        static char classID = 0; \\\n        return (UClassID)&classID; \\\n    }\n\n/**\n * This is a simple macro to express that a class and its subclasses do not offer\n * ICU's \"poor man's RTTI\".\n * Beginning with ICU 4.6, ICU requires C++ compiler RTTI.\n * This does not go into the header. This should only be used in *.cpp files.\n * Use this with a private getDynamicClassID() in an immediate subclass of UObject.\n *\n * @param myClass The name of the class that needs RTTI defined.\n * @internal\n */\n#define UOBJECT_DEFINE_NO_RTTI_IMPLEMENTATION(myClass) \\\n    UClassID myClass::getDynamicClassID() const { return NULL; }\n\n// /**\n//  * This macro adds ICU RTTI to an ICU concrete class implementation.\n//  * This macro should be invoked in *.cpp files.  The corresponding\n//  * header should declare getDynamicClassID and getStaticClassID.\n//  *\n//  * @param myClass The name of the class that needs RTTI defined.\n//  * @param myParent The name of the myClass's parent.\n//  * @internal\n//  */\n/*#define UOBJECT_DEFINE_RTTI_IMPLEMENTATION(myClass, myParent) \\\n    UOBJECT_DEFINE_ABSTRACT_RTTI_IMPLEMENTATION(myClass, myParent) \\\n    UClassID myClass::getDynamicClassID() const { \\\n        return myClass::getStaticClassID(); \\\n    }\n*/\n#endif  /* U_HIDE_INTERNAL_API */\n\nU_NAMESPACE_END\n\n#endif\n"
  },
  {
    "path": "deprecated/android/addons/icucompat/unicode/upluralrules.h",
    "content": "/*\n*****************************************************************************************\n* Copyright (C) 2010-2012, International Business Machines\n* Corporation and others. All Rights Reserved.\n*****************************************************************************************\n*/\n\n#ifndef UPLURALRULES_H\n#define UPLURALRULES_H\n\n#include \"unicode/utypes.h\"\n\n#if !UCONFIG_NO_FORMATTING\n\n#include \"unicode/localpointer.h\"\n\n/**\n * \\file\n * \\brief C API: Plural rules, select plural keywords for numeric values.\n *\n * A UPluralRules object defines rules for mapping non-negative numeric\n * values onto a small set of keywords. Rules are constructed from a text\n * description, consisting of a series of keywords and conditions.\n * The uplrules_select function examines each condition in order and\n * returns the keyword for the first condition that matches the number.\n * If none match, the default rule(other) is returned.\n *\n * For more information, see the LDML spec, C.11 Language Plural Rules:\n * http://www.unicode.org/reports/tr35/#Language_Plural_Rules\n *\n * Keywords: ICU locale data has 6 predefined values -\n * 'zero', 'one', 'two', 'few', 'many' and 'other'. Callers need to check\n * the value of keyword returned by the uplrules_select function.\n *\n * These are based on CLDR <i>Language Plural Rules</i>. For these\n * predefined rules, see the CLDR page at\n * http://unicode.org/repos/cldr-tmp/trunk/diff/supplemental/language_plural_rules.html\n */\n\n/**\n * Type of plurals and PluralRules.\n * @draft ICU 50\n */\nenum UPluralType {\n    /**\n     * Plural rules for cardinal numbers: 1 file vs. 2 files.\n     * @draft ICU 50\n     */\n    UPLURAL_TYPE_CARDINAL,\n    /**\n     * Plural rules for ordinal numbers: 1st file, 2nd file, 3rd file, 4th file, etc.\n     * @draft ICU 50\n     */\n    UPLURAL_TYPE_ORDINAL,\n    /**\n     * Number of Plural rules types.\n     * @draft ICU 50\n     */\n    UPLURAL_TYPE_COUNT\n};\n/**\n * @draft ICU 50\n */\ntypedef enum UPluralType UPluralType;\n\n/**\n * Opaque UPluralRules object for use in C programs.\n * @stable ICU 4.8\n */\nstruct UPluralRules;\ntypedef struct UPluralRules UPluralRules;  /**< C typedef for struct UPluralRules. @stable ICU 4.8 */\n\n/**\n * Opens a new UPluralRules object using the predefined cardinal-number plural rules for a\n * given locale.\n * Same as uplrules_openForType(locale, UPLURAL_TYPE_CARDINAL, status).\n * @param locale The locale for which the rules are desired.\n * @param status A pointer to a UErrorCode to receive any errors.\n * @return A UPluralRules for the specified locale, or NULL if an error occurred.\n * @stable ICU 4.8\n */\nU_STABLE UPluralRules* U_EXPORT2\nuplrules_open(const char *locale, UErrorCode *status);\n\n/**\n * Opens a new UPluralRules object using the predefined plural rules for a\n * given locale and the plural type.\n * @param locale The locale for which the rules are desired.\n * @param type The plural type (e.g., cardinal or ordinal).\n * @param status A pointer to a UErrorCode to receive any errors.\n * @return A UPluralRules for the specified locale, or NULL if an error occurred.\n * @draft ICU 50\n */\nU_DRAFT UPluralRules* U_EXPORT2\nuplrules_openForType(const char *locale, UPluralType type, UErrorCode *status);\n\n/**\n * Closes a UPluralRules object. Once closed it may no longer be used.\n * @param uplrules The UPluralRules object to close.\n * @stable ICU 4.8\n */\nU_STABLE void U_EXPORT2\nuplrules_close(UPluralRules *uplrules);\n\n\n#if U_SHOW_CPLUSPLUS_API\n\nU_NAMESPACE_BEGIN\n\n/**\n * \\class LocalUPluralRulesPointer\n * \"Smart pointer\" class, closes a UPluralRules via uplrules_close().\n * For most methods see the LocalPointerBase base class.\n *\n * @see LocalPointerBase\n * @see LocalPointer\n * @stable ICU 4.8\n */\nU_DEFINE_LOCAL_OPEN_POINTER(LocalUPluralRulesPointer, UPluralRules, uplrules_close);\n\nU_NAMESPACE_END\n\n#endif\n\n\n/**\n * Given a number, returns the keyword of the first rule that\n * applies to the number, according to the supplied UPluralRules object.\n * @param uplrules The UPluralRules object specifying the rules.\n * @param number The number for which the rule has to be determined.\n * @param keyword The keyword of the rule that applies to number.\n * @param capacity The capacity of keyword.\n * @param status A pointer to a UErrorCode to receive any errors.\n * @return The length of keyword.\n * @stable ICU 4.8\n */\nU_STABLE int32_t U_EXPORT2\nuplrules_select(const UPluralRules *uplrules,\n               double number,\n               UChar *keyword, int32_t capacity,\n               UErrorCode *status);\n\n#endif /* #if !UCONFIG_NO_FORMATTING */\n\n#endif\n"
  },
  {
    "path": "deprecated/android/addons/icucompat/unicode/uregex.h",
    "content": "/*\n**********************************************************************\n*   Copyright (C) 2004-2012, International Business Machines\n*   Corporation and others.  All Rights Reserved.\n**********************************************************************\n*   file name:  uregex.h\n*   encoding:   US-ASCII\n*   indentation:4\n*\n*   created on: 2004mar09\n*   created by: Andy Heninger\n*\n*   ICU Regular Expressions, API for C\n*/\n\n/**\n * \\file\n * \\brief C API: Regular Expressions\n *\n * <p>This is a C wrapper around the C++ RegexPattern and RegexMatcher classes.</p>\n */\n\n#ifndef UREGEX_H\n#define UREGEX_H\n\n#include \"unicode/utext.h\"\n#include \"unicode/utypes.h\"\n\n#if !UCONFIG_NO_REGULAR_EXPRESSIONS\n\n#include \"unicode/localpointer.h\"\n#include \"unicode/parseerr.h\"\n\nstruct URegularExpression;\n/**\n  * Structure representing a compiled regular expression, plus the results\n  *    of a match operation.\n  * @stable ICU 3.0\n  */\ntypedef struct URegularExpression URegularExpression;\n\n\n/**\n * Constants for Regular Expression Match Modes.\n * @stable ICU 2.4\n */\ntypedef enum URegexpFlag{\n\n#ifndef U_HIDE_DRAFT_API \n    /** Forces normalization of pattern and strings. \n    Not implemented yet, just a placeholder, hence draft. \n    @draft ICU 2.4 */\n    UREGEX_CANON_EQ         = 128,\n#endif\n    /**  Enable case insensitive matching.  @stable ICU 2.4 */\n    UREGEX_CASE_INSENSITIVE = 2,\n\n    /**  Allow white space and comments within patterns  @stable ICU 2.4 */\n    UREGEX_COMMENTS         = 4,\n\n    /**  If set, '.' matches line terminators,  otherwise '.' matching stops at line end.\n      *  @stable ICU 2.4 */\n    UREGEX_DOTALL           = 32,\n    \n    /**  If set, treat the entire pattern as a literal string.  \n      *  Metacharacters or escape sequences in the input sequence will be given \n      *  no special meaning. \n      *\n      *  The flag UREGEX_CASE_INSENSITIVE retains its impact\n      *  on matching when used in conjunction with this flag.\n      *  The other flags become superfluous.\n      *\n      * @stable ICU 4.0\n      */\n    UREGEX_LITERAL = 16,\n\n    /**   Control behavior of \"$\" and \"^\"\n      *    If set, recognize line terminators within string,\n      *    otherwise, match only at start and end of input string.\n      *   @stable ICU 2.4 */\n    UREGEX_MULTILINE        = 8,\n    \n    /**   Unix-only line endings.\n      *   When this mode is enabled, only \\\\u000a is recognized as a line ending\n      *    in the behavior of ., ^, and $.\n      *   @stable ICU 4.0\n      */\n    UREGEX_UNIX_LINES = 1,\n\n    /**  Unicode word boundaries.\n      *     If set, \\b uses the Unicode TR 29 definition of word boundaries.\n      *     Warning: Unicode word boundaries are quite different from\n      *     traditional regular expression word boundaries.  See\n      *     http://unicode.org/reports/tr29/#Word_Boundaries\n      *     @stable ICU 2.8\n      */\n    UREGEX_UWORD            = 256,\n\n     /**  Error on Unrecognized backslash escapes.\n       *     If set, fail with an error on patterns that contain\n       *     backslash-escaped ASCII letters without a known special\n       *     meaning.  If this flag is not set, these\n       *     escaped letters represent themselves.\n       *     @stable ICU 4.0\n       */\n     UREGEX_ERROR_ON_UNKNOWN_ESCAPES = 512\n\n}  URegexpFlag;\n\n/**\n  *  Open (compile) an ICU regular expression.  Compiles the regular expression in\n  *  string form into an internal representation using the specified match mode flags.\n  *  The resulting regular expression handle can then be used to perform various\n  *   matching operations.\n  * \n  *\n  * @param pattern        The Regular Expression pattern to be compiled. \n  * @param patternLength  The length of the pattern, or -1 if the pattern is\n  *                       NUL terminated.\n  * @param flags          Flags that alter the default matching behavior for\n  *                       the regular expression, UREGEX_CASE_INSENSITIVE, for\n  *                       example.  For default behavior, set this parameter to zero.\n  *                       See <code>enum URegexpFlag</code>.  All desired flags\n  *                       are bitwise-ORed together.\n  * @param pe             Receives the position (line and column numbers) of any syntax\n  *                       error within the source regular expression string.  If this\n  *                       information is not wanted, pass NULL for this parameter.\n  * @param status         Receives error detected by this function.\n  * @stable ICU 3.0\n  *\n  */\nU_STABLE URegularExpression * U_EXPORT2\nuregex_open( const  UChar          *pattern,\n                    int32_t         patternLength,\n                    uint32_t        flags,\n                    UParseError    *pe,\n                    UErrorCode     *status);\n\n/**\n  *  Open (compile) an ICU regular expression.  Compiles the regular expression in\n  *  string form into an internal representation using the specified match mode flags.\n  *  The resulting regular expression handle can then be used to perform various\n  *   matching operations.\n  *  <p>\n  *  The contents of the pattern UText will be extracted and saved. Ownership of the\n  *   UText struct itself remains with the caller. This is to match the behavior of\n  *   uregex_open().\n  *\n  * @param pattern        The Regular Expression pattern to be compiled. \n  * @param flags          Flags that alter the default matching behavior for\n  *                       the regular expression, UREGEX_CASE_INSENSITIVE, for\n  *                       example.  For default behavior, set this parameter to zero.\n  *                       See <code>enum URegexpFlag</code>.  All desired flags\n  *                       are bitwise-ORed together.\n  * @param pe             Receives the position (line and column numbers) of any syntax\n  *                       error within the source regular expression string.  If this\n  *                       information is not wanted, pass NULL for this parameter.\n  * @param status         Receives error detected by this function.\n  *\n  * @stable ICU 4.6\n  */\nU_STABLE URegularExpression *  U_EXPORT2\nuregex_openUText(UText          *pattern,\n                 uint32_t        flags,\n                 UParseError    *pe,\n                 UErrorCode     *status);\n\n/**\n  *  Open (compile) an ICU regular expression.  The resulting regular expression\n  *   handle can then be used to perform various matching operations.\n  *  <p>\n  *   This function is the same as uregex_open, except that the pattern\n  *   is supplied as an 8 bit char * string in the default code page.\n  *\n  * @param pattern        The Regular Expression pattern to be compiled, \n  *                       NUL terminated.  \n  * @param flags          Flags that alter the default matching behavior for\n  *                       the regular expression, UREGEX_CASE_INSENSITIVE, for\n  *                       example.  For default behavior, set this parameter to zero.\n  *                       See <code>enum URegexpFlag</code>.  All desired flags\n  *                       are bitwise-ORed together.\n  * @param pe             Receives the position (line and column numbers) of any syntax\n  *                       error within the source regular expression string.  If this\n  *                       information is not wanted, pass NULL for this parameter.\n  * @param status         Receives errors detected by this function.\n  * @return               The URegularExpression object representing the compiled\n  *                       pattern.\n  *\n  * @stable ICU 3.0\n  */\n#if !UCONFIG_NO_CONVERSION\nU_STABLE URegularExpression * U_EXPORT2\nuregex_openC( const char           *pattern,\n                    uint32_t        flags,\n                    UParseError    *pe,\n                    UErrorCode     *status);\n#endif\n\n\n\n/**\n  *  Close the regular expression, recovering all resources (memory) it\n  *   was holding.\n  *\n  * @param regexp   The regular expression to be closed.\n  * @stable ICU 3.0\n  */\nU_STABLE void U_EXPORT2 \nuregex_close(URegularExpression *regexp);\n\n#if U_SHOW_CPLUSPLUS_API\n\nU_NAMESPACE_BEGIN\n\n/**\n * \\class LocalURegularExpressionPointer\n * \"Smart pointer\" class, closes a URegularExpression via uregex_close().\n * For most methods see the LocalPointerBase base class.\n *\n * @see LocalPointerBase\n * @see LocalPointer\n * @stable ICU 4.4\n */\nU_DEFINE_LOCAL_OPEN_POINTER(LocalURegularExpressionPointer, URegularExpression, uregex_close);\n\nU_NAMESPACE_END\n\n#endif\n\n/**\n * Make a copy of a compiled regular expression.  Cloning a regular\n * expression is faster than opening a second instance from the source\n * form of the expression, and requires less memory.\n * <p>\n * Note that the current input string and the position of any matched text\n *  within it are not cloned; only the pattern itself and the\n *  match mode flags are copied.\n * <p>\n * Cloning can be particularly useful to threaded applications that perform\n * multiple match operations in parallel.  Each concurrent RE\n * operation requires its own instance of a URegularExpression.\n *\n * @param regexp   The compiled regular expression to be cloned.\n * @param status   Receives indication of any errors encountered\n * @return the cloned copy of the compiled regular expression.\n * @stable ICU 3.0\n */\nU_STABLE URegularExpression * U_EXPORT2 \nuregex_clone(const URegularExpression *regexp, UErrorCode *status);\n\n/**\n *  Returns a pointer to the source form of the pattern for this regular expression.\n *  This function will work even if the pattern was originally specified as a UText.\n *\n * @param regexp     The compiled regular expression.\n * @param patLength  This output parameter will be set to the length of the\n *                   pattern string.  A NULL pointer may be used here if the\n *                   pattern length is not needed, as would be the case if\n *                   the pattern is known in advance to be a NUL terminated\n *                   string.\n * @param status     Receives errors detected by this function.\n * @return a pointer to the pattern string.  The storage for the string is\n *                   owned by the regular expression object, and must not be\n *                   altered or deleted by the application.  The returned string\n *                   will remain valid until the regular expression is closed.\n * @stable ICU 3.0\n */\nU_STABLE const UChar * U_EXPORT2 \nuregex_pattern(const URegularExpression *regexp,\n                     int32_t            *patLength,\n                     UErrorCode         *status);\n\n/**\n *  Returns the source text of the pattern for this regular expression.\n *  This function will work even if the pattern was originally specified as a UChar string.\n *\n * @param regexp     The compiled regular expression.\n * @param status     Receives errors detected by this function.\n * @return the pattern text.  The storage for the text is owned by the regular expression\n *                   object, and must not be altered or deleted.\n *\n * @stable ICU 4.6\n */\nU_STABLE UText * U_EXPORT2 \nuregex_patternUText(const URegularExpression *regexp,\n                          UErrorCode         *status);\n\n/**\n  * Get the match mode flags that were specified when compiling this regular expression.\n  * @param status   Receives errors detected by this function.\n  * @param regexp   The compiled regular expression.\n  * @return         The match mode flags\n  * @see URegexpFlag\n  * @stable ICU 3.0\n  */\nU_STABLE int32_t U_EXPORT2 \nuregex_flags(const  URegularExpression   *regexp,\n                    UErrorCode           *status);\n\n\n/**\n  *  Set the subject text string upon which the regular expression will look for matches.\n  *  This function may be called any number of times, allowing the regular\n  *  expression pattern to be applied to different strings.\n  *  <p>\n  *  Regular expression matching operations work directly on the application's\n  *  string data.  No copy is made.  The subject string data must not be\n  *  altered after calling this function until after all regular expression\n  *  operations involving this string data are completed.  \n  *  <p>\n  *  Zero length strings are permitted.  In this case, no subsequent match\n  *  operation will dereference the text string pointer.\n  *\n  * @param regexp     The compiled regular expression.\n  * @param text       The subject text string.\n  * @param textLength The length of the subject text, or -1 if the string\n  *                   is NUL terminated.\n  * @param status     Receives errors detected by this function.\n  * @stable ICU 3.0\n  */\nU_STABLE void U_EXPORT2 \nuregex_setText(URegularExpression *regexp,\n               const UChar        *text,\n               int32_t             textLength,\n               UErrorCode         *status);\n\n\n/**\n  *  Set the subject text string upon which the regular expression will look for matches.\n  *  This function may be called any number of times, allowing the regular\n  *  expression pattern to be applied to different strings.\n  *  <p>\n  *  Regular expression matching operations work directly on the application's\n  *  string data; only a shallow clone is made.  The subject string data must not be\n  *  altered after calling this function until after all regular expression\n  *  operations involving this string data are completed.  \n  *\n  * @param regexp     The compiled regular expression.\n  * @param text       The subject text string.\n  * @param status     Receives errors detected by this function.\n  *\n  * @stable ICU 4.6\n  */\nU_STABLE void U_EXPORT2 \nuregex_setUText(URegularExpression *regexp,\n                UText              *text,\n                UErrorCode         *status);\n\n/**\n  *  Get the subject text that is currently associated with this \n  *   regular expression object.  If the input was supplied using uregex_setText(),\n  *   that pointer will be returned.  Otherwise, the characters in the input will\n  *   be extracted to a buffer and returned.  In either case, ownership remains\n  *   with the regular expression object.\n  *\n  *  This function will work even if the input was originally specified as a UText.\n  *\n  * @param regexp      The compiled regular expression.\n  * @param textLength  The length of the string is returned in this output parameter. \n  *                    A NULL pointer may be used here if the\n  *                    text length is not needed, as would be the case if\n  *                    the text is known in advance to be a NUL terminated\n  *                    string.\n  * @param status      Receives errors detected by this function.\n  * @return            Pointer to the subject text string currently associated with\n  *                    this regular expression.\n  * @stable ICU 3.0\n  */\nU_STABLE const UChar * U_EXPORT2 \nuregex_getText(URegularExpression *regexp,\n               int32_t            *textLength,\n               UErrorCode         *status);\n\n/**\n  *  Get the subject text that is currently associated with this \n  *   regular expression object.\n  *\n  *  This function will work even if the input was originally specified as a UChar string.\n  *\n  * @param regexp      The compiled regular expression.\n  * @param dest        A mutable UText in which to store the current input.\n  *                    If NULL, a new UText will be created as an immutable shallow clone\n  *                    of the actual input string.\n  * @param status      Receives errors detected by this function.\n  * @return            The subject text currently associated with this regular expression.\n  *                    If a pre-allocated UText was provided, it will always be used and returned.\n  *\n  * @stable ICU 4.6\n  */\nU_STABLE UText * U_EXPORT2 \nuregex_getUText(URegularExpression *regexp,\n                UText              *dest,\n                UErrorCode         *status);\n\n/**\n  *  Set the subject text string upon which the regular expression is looking for matches\n  *  without changing any other aspect of the matching state.\n  *  The new and previous text strings must have the same content.\n  *\n  *  This function is intended for use in environments where ICU is operating on \n  *  strings that may move around in memory.  It provides a mechanism for notifying\n  *  ICU that the string has been relocated, and providing a new UText to access the\n  *  string in its new position.\n  *\n  *  Note that the regular expression implementation never copies the underlying text\n  *  of a string being matched, but always operates directly on the original text \n  *  provided by the user. Refreshing simply drops the references to the old text \n  *  and replaces them with references to the new.\n  *\n  *  Caution:  this function is normally used only by very specialized\n  *            system-level code.   One example use case is with garbage collection \n  *            that moves the text in memory. \n  *\n  * @param regexp     The compiled regular expression.\n  * @param text       The new (moved) text string.\n  * @param status     Receives errors detected by this function.\n  *\n  * @stable ICU 4.8\n  */\nU_STABLE void U_EXPORT2 \nuregex_refreshUText(URegularExpression *regexp,\n                    UText              *text,\n                    UErrorCode         *status);\n\n/**\n  *   Attempts to match the input string against the pattern.\n  *   To succeed, the match must extend to the end of the string,\n  *   or cover the complete match region.\n  *\n  *   If startIndex >= zero the match operation starts at the specified\n  *   index and must extend to the end of the input string.  Any region\n  *   that has been specified is reset.\n  *\n  *   If startIndex == -1 the match must cover the input region, or the entire\n  *   input string if no region has been set.  This directly corresponds to\n  *   Matcher.matches() in Java\n  *\n  *    @param  regexp      The compiled regular expression.\n  *    @param  startIndex  The input string (native) index at which to begin matching, or -1\n  *                        to match the input Region.\n  *    @param  status      Receives errors detected by this function.\n  *    @return             TRUE if there is a match\n  *    @stable ICU 3.0\n  */\nU_STABLE UBool U_EXPORT2 \nuregex_matches(URegularExpression *regexp,\n                int32_t            startIndex,\n                UErrorCode        *status);\n\n/**\n  *   64bit version of uregex_matches.\n  *   Attempts to match the input string against the pattern.\n  *   To succeed, the match must extend to the end of the string,\n  *   or cover the complete match region.\n  *\n  *   If startIndex >= zero the match operation starts at the specified\n  *   index and must extend to the end of the input string.  Any region\n  *   that has been specified is reset.\n  *\n  *   If startIndex == -1 the match must cover the input region, or the entire\n  *   input string if no region has been set.  This directly corresponds to\n  *   Matcher.matches() in Java\n  *\n  *    @param  regexp      The compiled regular expression.\n  *    @param  startIndex  The input string (native) index at which to begin matching, or -1\n  *                        to match the input Region.\n  *    @param  status      Receives errors detected by this function.\n  *    @return             TRUE if there is a match\n  *   @stable ICU 4.6\n  */\nU_STABLE UBool U_EXPORT2 \nuregex_matches64(URegularExpression *regexp,\n                 int64_t            startIndex,\n                 UErrorCode        *status);\n\n/**\n  *   Attempts to match the input string, starting from the specified index, against the pattern.\n  *   The match may be of any length, and is not required to extend to the end\n  *   of the input string.  Contrast with uregex_matches().\n  *\n  *   <p>If startIndex is >= 0 any input region that was set for this\n  *   URegularExpression is reset before the operation begins.\n  *\n  *   <p>If the specified starting index == -1 the match begins at the start of the input \n  *   region, or at the start of the full string if no region has been specified.\n  *   This corresponds directly with Matcher.lookingAt() in Java.\n  *\n  *   <p>If the match succeeds then more information can be obtained via the\n  *    <code>uregexp_start()</code>, <code>uregexp_end()</code>,\n  *    and <code>uregexp_group()</code> functions.</p>\n  *\n  *    @param   regexp      The compiled regular expression.\n  *    @param   startIndex  The input string (native) index at which to begin matching, or\n  *                         -1 to match the Input Region\n  *    @param   status      A reference to a UErrorCode to receive any errors.\n  *    @return  TRUE if there is a match.\n  *    @stable ICU 3.0\n  */\nU_STABLE UBool U_EXPORT2 \nuregex_lookingAt(URegularExpression *regexp,\n                 int32_t             startIndex,\n                 UErrorCode         *status);\n\n/**\n  *   64bit version of uregex_lookingAt.\n  *   Attempts to match the input string, starting from the specified index, against the pattern.\n  *   The match may be of any length, and is not required to extend to the end\n  *   of the input string.  Contrast with uregex_matches().\n  *\n  *   <p>If startIndex is >= 0 any input region that was set for this\n  *   URegularExpression is reset before the operation begins.\n  *\n  *   <p>If the specified starting index == -1 the match begins at the start of the input \n  *   region, or at the start of the full string if no region has been specified.\n  *   This corresponds directly with Matcher.lookingAt() in Java.\n  *\n  *   <p>If the match succeeds then more information can be obtained via the\n  *    <code>uregexp_start()</code>, <code>uregexp_end()</code>,\n  *    and <code>uregexp_group()</code> functions.</p>\n  *\n  *    @param   regexp      The compiled regular expression.\n  *    @param   startIndex  The input string (native) index at which to begin matching, or\n  *                         -1 to match the Input Region\n  *    @param   status      A reference to a UErrorCode to receive any errors.\n  *    @return  TRUE if there is a match.\n  *    @stable ICU 4.6\n  */\nU_STABLE UBool U_EXPORT2 \nuregex_lookingAt64(URegularExpression *regexp,\n                   int64_t             startIndex,\n                   UErrorCode         *status);\n\n/**\n  *   Find the first matching substring of the input string that matches the pattern.\n  *   If startIndex is >= zero the search for a match begins at the specified index,\n  *          and any match region is reset.  This corresponds directly with\n  *          Matcher.find(startIndex) in Java.\n  *\n  *   If startIndex == -1 the search begins at the start of the input region,\n  *           or at the start of the full string if no region has been specified.\n  *\n  *   If a match is found, <code>uregex_start(), uregex_end()</code>, and\n  *   <code>uregex_group()</code> will provide more information regarding the match.\n  *\n  *   @param   regexp      The compiled regular expression.\n  *   @param   startIndex  The position (native) in the input string to begin the search, or\n  *                        -1 to search within the Input Region.\n  *   @param   status      A reference to a UErrorCode to receive any errors.\n  *   @return              TRUE if a match is found.\n  *   @stable ICU 3.0\n  */\nU_STABLE UBool U_EXPORT2 \nuregex_find(URegularExpression *regexp,\n            int32_t             startIndex, \n            UErrorCode         *status);\n\n/**\n  *   64bit version of uregex_find.\n  *   Find the first matching substring of the input string that matches the pattern.\n  *   If startIndex is >= zero the search for a match begins at the specified index,\n  *          and any match region is reset.  This corresponds directly with\n  *          Matcher.find(startIndex) in Java.\n  *\n  *   If startIndex == -1 the search begins at the start of the input region,\n  *           or at the start of the full string if no region has been specified.\n  *\n  *   If a match is found, <code>uregex_start(), uregex_end()</code>, and\n  *   <code>uregex_group()</code> will provide more information regarding the match.\n  *\n  *   @param   regexp      The compiled regular expression.\n  *   @param   startIndex  The position (native) in the input string to begin the search, or\n  *                        -1 to search within the Input Region.\n  *   @param   status      A reference to a UErrorCode to receive any errors.\n  *   @return              TRUE if a match is found.\n  *   @stable ICU 4.6\n  */\nU_STABLE UBool U_EXPORT2 \nuregex_find64(URegularExpression *regexp,\n              int64_t             startIndex, \n              UErrorCode         *status);\n\n/**\n  *  Find the next pattern match in the input string.  Begin searching \n  *  the input at the location following the end of he previous match, \n  *  or at the start of the string (or region) if there is no \n  *  previous match.  If a match is found, <code>uregex_start(), uregex_end()</code>, and\n  *  <code>uregex_group()</code> will provide more information regarding the match.\n  *\n  *  @param   regexp      The compiled regular expression.\n  *  @param   status      A reference to a UErrorCode to receive any errors.\n  *  @return              TRUE if a match is found.\n  *  @see uregex_reset\n  *  @stable ICU 3.0\n  */\nU_STABLE UBool U_EXPORT2 \nuregex_findNext(URegularExpression *regexp,\n                UErrorCode         *status);\n\n/**\n  *   Get the number of capturing groups in this regular expression's pattern.\n  *   @param   regexp      The compiled regular expression.\n  *   @param   status      A reference to a UErrorCode to receive any errors.\n  *   @return the number of capture groups\n  *   @stable ICU 3.0\n  */\nU_STABLE int32_t U_EXPORT2 \nuregex_groupCount(URegularExpression *regexp,\n                  UErrorCode         *status);\n\n/** Extract the string for the specified matching expression or subexpression.\n  * Group #0 is the complete string of matched text.\n  * Group #1 is the text matched by the first set of capturing parentheses.\n  *\n  *   @param   regexp       The compiled regular expression.\n  *   @param   groupNum     The capture group to extract.  Group 0 is the complete\n  *                         match.  The value of this parameter must be\n  *                         less than or equal to the number of capture groups in\n  *                         the pattern.\n  *   @param   dest         Buffer to receive the matching string data\n  *   @param   destCapacity Capacity of the dest buffer.\n  *   @param   status       A reference to a UErrorCode to receive any errors.\n  *   @return               Length of matching data,\n  *                         or -1 if no applicable match.\n  *   @stable ICU 3.0\n  */\nU_STABLE int32_t U_EXPORT2 \nuregex_group(URegularExpression *regexp,\n             int32_t             groupNum,\n             UChar              *dest,\n             int32_t             destCapacity,\n             UErrorCode          *status);\n\n/** Returns a shallow immutable clone of the entire input string.  The returned UText current native index\n  *   is set to the beginning of the requested capture group.  The capture group length is also\n  *   returned via groupLength.\n  * Group #0 is the complete string of matched text.\n  * Group #1 is the text matched by the first set of capturing parentheses.\n  *\n  *   @param   regexp       The compiled regular expression.\n  *   @param   groupNum     The capture group to extract.  Group 0 is the complete\n  *                         match.  The value of this parameter must be\n  *                         less than or equal to the number of capture groups in\n  *                         the pattern.\n  *   @param   dest         A mutable UText in which to store the current input.\n  *                         If NULL, a new UText will be created as an immutable shallow clone\n  *                         of the entire input string.\n  *   @param   groupLength  The group length of the desired capture group.\n  *   @param   status       A reference to a UErrorCode to receive any errors.\n  *   @return               The subject text currently associated with this regular expression.\n  *                         If a pre-allocated UText was provided, it will always be used and returned.\n\n  *\n  *   @stable ICU 4.6\n  */\nU_STABLE UText * U_EXPORT2 \nuregex_groupUText(URegularExpression *regexp,\n                  int32_t             groupNum,\n                  UText              *dest,\n                  int64_t            *groupLength,\n                  UErrorCode         *status);\n\n#ifndef U_HIDE_INTERNAL_API\n/** Extract the string for the specified matching expression or subexpression.\n  * Group #0 is the complete string of matched text.\n  * Group #1 is the text matched by the first set of capturing parentheses.\n  *\n  *   @param   regexp       The compiled regular expression.\n  *   @param   groupNum     The capture group to extract.  Group 0 is the complete\n  *                         match.  The value of this parameter must be\n  *                         less than or equal to the number of capture groups in\n  *                         the pattern.\n  *   @param   dest         Mutable UText to receive the matching string data.\n  *                         If NULL, a new UText will be created (which may not be mutable).\n  *   @param   status       A reference to a UErrorCode to receive any errors.\n  *   @return               The matching string data. If a pre-allocated UText was provided,\n  *                          it will always be used and returned.\n  *\n  *   @internal ICU 4.4 technology preview\n  */\nU_INTERNAL UText * U_EXPORT2 \nuregex_groupUTextDeep(URegularExpression *regexp,\n                  int32_t             groupNum,\n                  UText              *dest,\n                  UErrorCode         *status);\n#endif  /* U_HIDE_INTERNAL_API */\n\n/**\n  *   Returns the index in the input string of the start of the text matched by the\n  *   specified capture group during the previous match operation.  Return -1 if\n  *   the capture group was not part of the last match.\n  *   Group #0 refers to the complete range of matched text.\n  *   Group #1 refers to the text matched by the first set of capturing parentheses.\n  *\n  *    @param   regexp      The compiled regular expression.\n  *    @param   groupNum    The capture group number\n  *    @param   status      A reference to a UErrorCode to receive any errors.\n  *    @return              the starting (native) position in the input of the text matched \n  *                         by the specified group.\n  *    @stable ICU 3.0\n  */\nU_STABLE int32_t U_EXPORT2 \nuregex_start(URegularExpression *regexp,\n             int32_t             groupNum,\n             UErrorCode          *status);\n\n/**\n  *   64bit version of uregex_start.\n  *   Returns the index in the input string of the start of the text matched by the\n  *   specified capture group during the previous match operation.  Return -1 if\n  *   the capture group was not part of the last match.\n  *   Group #0 refers to the complete range of matched text.\n  *   Group #1 refers to the text matched by the first set of capturing parentheses.\n  *\n  *    @param   regexp      The compiled regular expression.\n  *    @param   groupNum    The capture group number\n  *    @param   status      A reference to a UErrorCode to receive any errors.\n  *    @return              the starting (native) position in the input of the text matched \n  *                         by the specified group.\n  *   @stable ICU 4.6\n  */\nU_STABLE int64_t U_EXPORT2 \nuregex_start64(URegularExpression *regexp,\n               int32_t             groupNum,\n               UErrorCode          *status);\n\n/**\n  *   Returns the index in the input string of the position following the end\n  *   of the text matched by the specified capture group.\n  *   Return -1 if the capture group was not part of the last match.\n  *   Group #0 refers to the complete range of matched text.\n  *   Group #1 refers to the text matched by the first set of capturing parentheses.\n  *\n  *    @param   regexp      The compiled regular expression.\n  *    @param   groupNum    The capture group number\n  *    @param   status      A reference to a UErrorCode to receive any errors.\n  *    @return              the (native) index of the position following the last matched character.\n  *    @stable ICU 3.0\n  */\nU_STABLE int32_t U_EXPORT2 \nuregex_end(URegularExpression   *regexp,\n           int32_t               groupNum,\n           UErrorCode           *status);\n\n/**\n  *   64bit version of uregex_end.\n  *   Returns the index in the input string of the position following the end\n  *   of the text matched by the specified capture group.\n  *   Return -1 if the capture group was not part of the last match.\n  *   Group #0 refers to the complete range of matched text.\n  *   Group #1 refers to the text matched by the first set of capturing parentheses.\n  *\n  *    @param   regexp      The compiled regular expression.\n  *    @param   groupNum    The capture group number\n  *    @param   status      A reference to a UErrorCode to receive any errors.\n  *    @return              the (native) index of the position following the last matched character.\n  *   @stable ICU 4.6\n  */\nU_STABLE int64_t U_EXPORT2 \nuregex_end64(URegularExpression *regexp,\n             int32_t               groupNum,\n             UErrorCode           *status);\n\n/**\n  *  Reset any saved state from the previous match.  Has the effect of\n  *  causing uregex_findNext to begin at the specified index, and causing\n  *  uregex_start(), uregex_end() and uregex_group() to return an error \n  *  indicating that there is no match information available.  Clears any\n  *  match region that may have been set.\n  *\n  *    @param   regexp      The compiled regular expression.\n  *    @param   index       The position (native) in the text at which a\n  *                         uregex_findNext() should begin searching.\n  *    @param   status      A reference to a UErrorCode to receive any errors.\n  *    @stable ICU 3.0\n  */\nU_STABLE void U_EXPORT2 \nuregex_reset(URegularExpression    *regexp,\n             int32_t               index,\n             UErrorCode            *status);\n\n/**\n  *  64bit version of uregex_reset.\n  *  Reset any saved state from the previous match.  Has the effect of\n  *  causing uregex_findNext to begin at the specified index, and causing\n  *  uregex_start(), uregex_end() and uregex_group() to return an error \n  *  indicating that there is no match information available.  Clears any\n  *  match region that may have been set.\n  *\n  *    @param   regexp      The compiled regular expression.\n  *    @param   index       The position (native) in the text at which a\n  *                         uregex_findNext() should begin searching.\n  *    @param   status      A reference to a UErrorCode to receive any errors.\n  *    @stable ICU 4.6\n  */\nU_STABLE void U_EXPORT2 \nuregex_reset64(URegularExpression  *regexp,\n               int64_t               index,\n               UErrorCode            *status);\n\n/**\n  * Sets the limits of the matching region for this URegularExpression.\n  * The region is the part of the input string that will be considered when matching.\n  * Invoking this method resets any saved state from the previous match, \n  * then sets the region to start at the index specified by the start parameter\n  * and end at the index specified by the end parameter.\n  *\n  * Depending on the transparency and anchoring being used (see useTransparentBounds\n  * and useAnchoringBounds), certain constructs such as anchors may behave differently\n  * at or around the boundaries of the region\n  *\n  * The function will fail if start is greater than limit, or if either index\n  *  is less than zero or greater than the length of the string being matched.\n  *\n  * @param regexp The compiled regular expression.\n  * @param regionStart  The (native) index to begin searches at.\n  * @param regionLimit  The (native) index to end searches at (exclusive).\n  * @param status A pointer to a UErrorCode to receive any errors.\n  * @stable ICU 4.0\n  */\nU_STABLE void U_EXPORT2\nuregex_setRegion(URegularExpression   *regexp,\n                 int32_t               regionStart,\n                 int32_t               regionLimit,\n                 UErrorCode           *status);\n\n/**\n  * 64bit version of uregex_setRegion.\n  * Sets the limits of the matching region for this URegularExpression.\n  * The region is the part of the input string that will be considered when matching.\n  * Invoking this method resets any saved state from the previous match, \n  * then sets the region to start at the index specified by the start parameter\n  * and end at the index specified by the end parameter.\n  *\n  * Depending on the transparency and anchoring being used (see useTransparentBounds\n  * and useAnchoringBounds), certain constructs such as anchors may behave differently\n  * at or around the boundaries of the region\n  *\n  * The function will fail if start is greater than limit, or if either index\n  *  is less than zero or greater than the length of the string being matched.\n  *\n  * @param regexp The compiled regular expression.\n  * @param regionStart  The (native) index to begin searches at.\n  * @param regionLimit  The (native) index to end searches at (exclusive).\n  * @param status A pointer to a UErrorCode to receive any errors.\n  * @stable ICU 4.6\n  */\nU_STABLE void U_EXPORT2 \nuregex_setRegion64(URegularExpression *regexp,\n                 int64_t               regionStart,\n                 int64_t               regionLimit,\n                 UErrorCode           *status);\n\n/**\n  *  Set the matching region and the starting index for subsequent matches\n  *  in a single operation.\n  *  This is useful because the usual function for setting the starting\n  *  index, urgex_reset(), also resets any region limits.\n  *\n  * @param regexp The compiled regular expression.\n  * @param regionStart  The (native) index to begin searches at.\n  * @param regionLimit  The (native) index to end searches at (exclusive).\n  * @param startIndex   The index in the input text at which the next \n  *                     match operation should begin.\n  * @param status A pointer to a UErrorCode to receive any errors.\n  * @stable ICU 4.6\n  */\nU_STABLE void U_EXPORT2 \nuregex_setRegionAndStart(URegularExpression *regexp,\n                 int64_t               regionStart,\n                 int64_t               regionLimit,\n                 int64_t               startIndex,\n                 UErrorCode           *status);\n\n/**\n  * Reports the start index of the matching region. Any matches found are limited to\n  * to the region bounded by regionStart (inclusive) and regionEnd (exclusive).\n  *\n  * @param regexp The compiled regular expression.\n  * @param status A pointer to a UErrorCode to receive any errors.\n  * @return The starting (native) index of this matcher's region.\n  * @stable ICU 4.0\n  */\nU_STABLE int32_t U_EXPORT2\nuregex_regionStart(const  URegularExpression   *regexp,\n                          UErrorCode           *status);\n\n/**\n  * 64bit version of uregex_regionStart.\n  * Reports the start index of the matching region. Any matches found are limited to\n  * to the region bounded by regionStart (inclusive) and regionEnd (exclusive).\n  *\n  * @param regexp The compiled regular expression.\n  * @param status A pointer to a UErrorCode to receive any errors.\n  * @return The starting (native) index of this matcher's region.\n  * @stable ICU 4.6\n  */\nU_STABLE int64_t U_EXPORT2 \nuregex_regionStart64(const  URegularExpression   *regexp,\n                            UErrorCode           *status);\n\n/**\n  * Reports the end index (exclusive) of the matching region for this URegularExpression.\n  * Any matches found are limited to to the region bounded by regionStart (inclusive)\n  * and regionEnd (exclusive).\n  *\n  * @param regexp The compiled regular expression.\n  * @param status A pointer to a UErrorCode to receive any errors.\n  * @return The ending point (native) of this matcher's region.\n  * @stable ICU 4.0\n  */\nU_STABLE int32_t U_EXPORT2\nuregex_regionEnd(const  URegularExpression   *regexp,\n                        UErrorCode           *status);\n\n/**\n  * 64bit version of uregex_regionEnd.\n  * Reports the end index (exclusive) of the matching region for this URegularExpression.\n  * Any matches found are limited to to the region bounded by regionStart (inclusive)\n  * and regionEnd (exclusive).\n  *\n  * @param regexp The compiled regular expression.\n  * @param status A pointer to a UErrorCode to receive any errors.\n  * @return The ending point (native) of this matcher's region.\n  * @stable ICU 4.6\n  */\nU_STABLE int64_t U_EXPORT2 \nuregex_regionEnd64(const  URegularExpression   *regexp,\n                          UErrorCode           *status);\n\n/**\n  * Queries the transparency of region bounds for this URegularExpression.\n  * See useTransparentBounds for a description of transparent and opaque bounds.\n  * By default, matching boundaries are opaque.\n  *\n  * @param regexp The compiled regular expression.\n  * @param status A pointer to a UErrorCode to receive any errors.\n  * @return TRUE if this matcher is using opaque bounds, false if it is not.\n  * @stable ICU 4.0\n  */\nU_STABLE UBool U_EXPORT2\nuregex_hasTransparentBounds(const  URegularExpression   *regexp,\n                                   UErrorCode           *status);\n\n\n/**\n  * Sets the transparency of region bounds for this URegularExpression.\n  * Invoking this function with an argument of TRUE will set matches to use transparent bounds.\n  * If the boolean argument is FALSE, then opaque bounds will be used.\n  *\n  * Using transparent bounds, the boundaries of the matching region are transparent\n  * to lookahead, lookbehind, and boundary matching constructs. Those constructs can\n  * see text beyond the boundaries of the region while checking for a match.\n  *\n  * With opaque bounds, no text outside of the matching region is visible to lookahead,\n  * lookbehind, and boundary matching constructs.\n  *\n  * By default, opaque bounds are used.\n  *\n  * @param   regexp The compiled regular expression.\n  * @param   b      TRUE for transparent bounds; FALSE for opaque bounds\n  * @param   status A pointer to a UErrorCode to receive any errors.\n  * @stable ICU 4.0\n  **/\nU_STABLE void U_EXPORT2  \nuregex_useTransparentBounds(URegularExpression   *regexp, \n                            UBool                b,\n                            UErrorCode           *status);\n\n\n/**\n  * Return true if this URegularExpression is using anchoring bounds.\n  * By default, anchoring region bounds are used.\n  *\n  * @param  regexp The compiled regular expression.\n  * @param  status A pointer to a UErrorCode to receive any errors.\n  * @return TRUE if this matcher is using anchoring bounds.\n  * @stable ICU 4.0\n  */\nU_STABLE UBool U_EXPORT2\nuregex_hasAnchoringBounds(const  URegularExpression   *regexp,\n                                 UErrorCode           *status);\n\n\n/**\n  * Set whether this URegularExpression is using Anchoring Bounds for its region.\n  * With anchoring bounds, pattern anchors such as ^ and $ will match at the start\n  * and end of the region.  Without Anchoring Bounds, anchors will only match at\n  * the positions they would in the complete text.\n  *\n  * Anchoring Bounds are the default for regions.\n  *\n  * @param regexp The compiled regular expression.\n  * @param b      TRUE if to enable anchoring bounds; FALSE to disable them.\n  * @param status A pointer to a UErrorCode to receive any errors.\n  * @stable ICU 4.0\n  */\nU_STABLE void U_EXPORT2\nuregex_useAnchoringBounds(URegularExpression   *regexp,\n                          UBool                 b,\n                          UErrorCode           *status);\n\n/**\n  * Return TRUE if the most recent matching operation touched the\n  *  end of the text being processed.  In this case, additional input text could\n  *  change the results of that match.\n  *\n  *  @param regexp The compiled regular expression.\n  *  @param status A pointer to a UErrorCode to receive any errors.\n  *  @return  TRUE if the most recent match hit the end of input\n  *  @stable ICU 4.0\n  */\nU_STABLE UBool U_EXPORT2\nuregex_hitEnd(const  URegularExpression   *regexp,\n                     UErrorCode           *status);\n\n/**\n  * Return TRUE the most recent match succeeded and additional input could cause\n  * it to fail. If this function returns false and a match was found, then more input\n  * might change the match but the match won't be lost. If a match was not found,\n  * then requireEnd has no meaning.\n  *\n  * @param regexp The compiled regular expression.\n  * @param status A pointer to a UErrorCode to receive any errors.\n  * @return TRUE  if more input could cause the most recent match to no longer match.\n  * @stable ICU 4.0\n  */\nU_STABLE UBool U_EXPORT2   \nuregex_requireEnd(const  URegularExpression   *regexp,\n                         UErrorCode           *status);\n\n\n\n\n\n/**\n  *    Replaces every substring of the input that matches the pattern\n  *    with the given replacement string.  This is a convenience function that\n  *    provides a complete find-and-replace-all operation.\n  *\n  *    This method scans the input string looking for matches of the pattern. \n  *    Input that is not part of any match is copied unchanged to the\n  *    destination buffer.  Matched regions are replaced in the output\n  *    buffer by the replacement string.   The replacement string may contain\n  *    references to capture groups; these take the form of $1, $2, etc.\n  *\n  *    @param   regexp             The compiled regular expression.\n  *    @param   replacementText    A string containing the replacement text.\n  *    @param   replacementLength  The length of the replacement string, or\n  *                                -1 if it is NUL terminated.\n  *    @param   destBuf            A (UChar *) buffer that will receive the result.\n  *    @param   destCapacity       The capacity of the destination buffer.\n  *    @param   status             A reference to a UErrorCode to receive any errors.\n  *    @return                     The length of the string resulting from the find\n  *                                and replace operation.  In the event that the\n  *                                destination capacity is inadequate, the return value\n  *                                is still the full length of the untruncated string.\n  *    @stable ICU 3.0\n  */\nU_STABLE int32_t U_EXPORT2 \nuregex_replaceAll(URegularExpression    *regexp,\n                  const UChar           *replacementText,\n                  int32_t                replacementLength,\n                  UChar                 *destBuf,\n                  int32_t                destCapacity,\n                  UErrorCode            *status);\n\n/**\n  *    Replaces every substring of the input that matches the pattern\n  *    with the given replacement string.  This is a convenience function that\n  *    provides a complete find-and-replace-all operation.\n  *\n  *    This method scans the input string looking for matches of the pattern. \n  *    Input that is not part of any match is copied unchanged to the\n  *    destination buffer.  Matched regions are replaced in the output\n  *    buffer by the replacement string.   The replacement string may contain\n  *    references to capture groups; these take the form of $1, $2, etc.\n  *\n  *    @param   regexp         The compiled regular expression.\n  *    @param   replacement    A string containing the replacement text.\n  *    @param   dest           A mutable UText that will receive the result.\n  *                             If NULL, a new UText will be created (which may not be mutable).\n  *    @param   status         A reference to a UErrorCode to receive any errors.\n  *    @return                 A UText containing the results of the find and replace.\n  *                             If a pre-allocated UText was provided, it will always be used and returned.\n  *\n  *    @stable ICU 4.6\n  */\nU_STABLE UText * U_EXPORT2 \nuregex_replaceAllUText(URegularExpression *regexp,\n                       UText              *replacement,\n                       UText              *dest,\n                       UErrorCode         *status);\n\n/**\n  *    Replaces the first substring of the input that matches the pattern\n  *    with the given replacement string.  This is a convenience function that\n  *    provides a complete find-and-replace operation.\n  *\n  *    This method scans the input string looking for a match of the pattern. \n  *    All input that is not part of the match is copied unchanged to the\n  *    destination buffer.  The matched region is replaced in the output\n  *    buffer by the replacement string.   The replacement string may contain\n  *    references to capture groups; these take the form of $1, $2, etc.\n  *\n  *    @param   regexp             The compiled regular expression.\n  *    @param   replacementText    A string containing the replacement text.\n  *    @param   replacementLength  The length of the replacement string, or\n  *                                -1 if it is NUL terminated.\n  *    @param   destBuf            A (UChar *) buffer that will receive the result.\n  *    @param   destCapacity       The capacity of the destination buffer.\n  *    @param   status             a reference to a UErrorCode to receive any errors.\n  *    @return                     The length of the string resulting from the find\n  *                                and replace operation.  In the event that the\n  *                                destination capacity is inadequate, the return value\n  *                                is still the full length of the untruncated string.\n  *    @stable ICU 3.0\n  */\nU_STABLE int32_t U_EXPORT2 \nuregex_replaceFirst(URegularExpression  *regexp,\n                    const UChar         *replacementText,\n                    int32_t              replacementLength,\n                    UChar               *destBuf,\n                    int32_t              destCapacity,\n                    UErrorCode          *status);\n\n/**\n  *    Replaces the first substring of the input that matches the pattern\n  *    with the given replacement string.  This is a convenience function that\n  *    provides a complete find-and-replace operation.\n  *\n  *    This method scans the input string looking for a match of the pattern. \n  *    All input that is not part of the match is copied unchanged to the\n  *    destination buffer.  The matched region is replaced in the output\n  *    buffer by the replacement string.   The replacement string may contain\n  *    references to capture groups; these take the form of $1, $2, etc.\n  *\n  *    @param   regexp         The compiled regular expression.\n  *    @param   replacement    A string containing the replacement text.\n  *    @param   dest           A mutable UText that will receive the result.\n  *                             If NULL, a new UText will be created (which may not be mutable).\n  *    @param   status         A reference to a UErrorCode to receive any errors.\n  *    @return                 A UText containing the results of the find and replace.\n  *                             If a pre-allocated UText was provided, it will always be used and returned.\n  *\n  *    @stable ICU 4.6\n  */\nU_STABLE UText * U_EXPORT2 \nuregex_replaceFirstUText(URegularExpression *regexp,\n                         UText              *replacement,\n                         UText              *dest,\n                         UErrorCode         *status);\n\n/**\n  *   Implements a replace operation intended to be used as part of an\n  *   incremental find-and-replace.\n  *\n  *   <p>The input string, starting from the end of the previous match and ending at\n  *   the start of the current match, is appended to the destination string.  Then the\n  *   replacement string is appended to the output string,\n  *   including handling any substitutions of captured text.</p>\n  *\n  *   <p>A note on preflight computation of buffersize and error handling:\n  *   Calls to uregex_appendReplacement() and uregex_appendTail() are\n  *   designed to be chained, one after another, with the destination\n  *   buffer pointer and buffer capacity updated after each in preparation\n  *   to for the next.  If the destination buffer is exhausted partway through such a\n  *   sequence, a U_BUFFER_OVERFLOW_ERROR status will be returned.  Normal\n  *   ICU conventions are for a function to perform no action if it is\n  *   called with an error status, but for this one case, uregex_appendRepacement()\n  *   will operate normally so that buffer size computations will complete\n  *   correctly.\n  *\n  *   <p>For simple, prepackaged, non-incremental find-and-replace\n  *      operations, see replaceFirst() or replaceAll().</p>\n  *\n  *   @param   regexp      The regular expression object.  \n  *   @param   replacementText The string that will replace the matched portion of the\n  *                        input string as it is copied to the destination buffer.\n  *                        The replacement text may contain references ($1, for\n  *                        example) to capture groups from the match.\n  *   @param   replacementLength  The length of the replacement text string,\n  *                        or -1 if the string is NUL terminated.\n  *   @param   destBuf     The buffer into which the results of the\n  *                        find-and-replace are placed.  On return, this pointer\n  *                        will be updated to refer to the beginning of the\n  *                        unused portion of buffer, leaving it in position for\n  *                        a subsequent call to this function.\n  *   @param   destCapacity The size of the output buffer,  On return, this\n  *                        parameter will be updated to reflect the space remaining\n  *                        unused in the output buffer.\n  *   @param   status      A reference to a UErrorCode to receive any errors. \n  *   @return              The length of the result string.  In the event that\n  *                        destCapacity is inadequate, the full length of the\n  *                        untruncated output string is returned.\n  *\n  *   @stable ICU 3.0\n  *\n  */\nU_STABLE int32_t U_EXPORT2 \nuregex_appendReplacement(URegularExpression    *regexp,\n                         const UChar           *replacementText,\n                         int32_t                replacementLength,\n                         UChar                **destBuf,\n                         int32_t               *destCapacity,\n                         UErrorCode            *status);\n\n/**\n  *   Implements a replace operation intended to be used as part of an\n  *   incremental find-and-replace.\n  *\n  *   <p>The input string, starting from the end of the previous match and ending at\n  *   the start of the current match, is appended to the destination string.  Then the\n  *   replacement string is appended to the output string,\n  *   including handling any substitutions of captured text.</p>\n  *\n  *   <p>For simple, prepackaged, non-incremental find-and-replace\n  *      operations, see replaceFirst() or replaceAll().</p>\n  *\n  *   @param   regexp      The regular expression object.  \n  *   @param   replacementText The string that will replace the matched portion of the\n  *                        input string as it is copied to the destination buffer.\n  *                        The replacement text may contain references ($1, for\n  *                        example) to capture groups from the match.\n  *   @param   dest        A mutable UText that will receive the result. Must not be NULL.\n  *   @param   status      A reference to a UErrorCode to receive any errors. \n  *\n  *   @stable ICU 4.6\n  */\nU_STABLE void U_EXPORT2 \nuregex_appendReplacementUText(URegularExpression    *regexp,\n                              UText                 *replacementText,\n                              UText                 *dest,\n                              UErrorCode            *status);\n\n/**\n  * As the final step in a find-and-replace operation, append the remainder\n  * of the input string, starting at the position following the last match,\n  * to the destination string. <code>uregex_appendTail()</code> is intended \n  *  to be invoked after one or more invocations of the\n  *  <code>uregex_appendReplacement()</code> function.\n  *\n  *   @param   regexp      The regular expression object.  This is needed to \n  *                        obtain the input string and with the position\n  *                        of the last match within it.\n  *   @param   destBuf     The buffer in which the results of the\n  *                        find-and-replace are placed.  On return, the pointer\n  *                        will be updated to refer to the beginning of the\n  *                        unused portion of buffer.\n  *   @param   destCapacity The size of the output buffer,  On return, this\n  *                        value will be updated to reflect the space remaining\n  *                        unused in the output buffer.\n  *   @param   status      A reference to a UErrorCode to receive any errors. \n  *   @return              The length of the result string.  In the event that\n  *                        destCapacity is inadequate, the full length of the\n  *                        untruncated output string is returned.\n  *\n  *   @stable ICU 3.0\n  */\nU_STABLE int32_t U_EXPORT2 \nuregex_appendTail(URegularExpression    *regexp,\n                  UChar                **destBuf,\n                  int32_t               *destCapacity,\n                  UErrorCode            *status);\n\n/**\n  * As the final step in a find-and-replace operation, append the remainder\n  * of the input string, starting at the position following the last match,\n  * to the destination string. <code>uregex_appendTailUText()</code> is intended \n  *  to be invoked after one or more invocations of the\n  *  <code>uregex_appendReplacementUText()</code> function.\n  *\n  *   @param   regexp      The regular expression object.  This is needed to \n  *                        obtain the input string and with the position\n  *                        of the last match within it.\n  *   @param   dest        A mutable UText that will receive the result. Must not be NULL.\n  *\n  *   @param status        Error code\n  *\n  *   @return              The destination UText.\n  *\n  *   @stable ICU 4.6\n  */\nU_STABLE UText * U_EXPORT2 \nuregex_appendTailUText(URegularExpression    *regexp,\n                       UText                 *dest,\n                       UErrorCode            *status);\n\n /**\n   * Split a string into fields.  Somewhat like split() from Perl.\n   *  The pattern matches identify delimiters that separate the input\n   *  into fields.  The input data between the matches becomes the\n   *  fields themselves.\n   *\n   *  Each of the fields is copied from the input string to the destination\n   *  buffer, and NUL terminated.  The position of each field within\n   *  the destination buffer is returned in the destFields array.\n   *\n   *  If the delimiter pattern includes capture groups, the captured text will\n   *  also appear in the destination array of output strings, interspersed\n   *  with the fields.  This is similar to Perl, but differs from Java, \n   *  which ignores the presence of capture groups in the pattern.\n   * \n   *  Trailing empty fields will always be returned, assuming sufficient\n   *  destination capacity.  This differs from the default behavior for Java\n   *  and Perl where trailing empty fields are not returned.\n   *\n   *  The number of strings produced by the split operation is returned.\n   *  This count includes the strings from capture groups in the delimiter pattern.\n   *  This behavior differs from Java, which ignores capture groups.\n   * \n   *    @param   regexp      The compiled regular expression.\n   *    @param   destBuf     A (UChar *) buffer to receive the fields that\n   *                         are extracted from the input string. These\n   *                         field pointers will refer to positions within the\n   *                         destination buffer supplied by the caller.  Any\n   *                         extra positions within the destFields array will be\n   *                         set to NULL.\n   *    @param   destCapacity The capacity of the destBuf.\n   *    @param   requiredCapacity  The actual capacity required of the destBuf.\n   *                         If destCapacity is too small, requiredCapacity will return \n   *                         the total capacity required to hold all of the output, and\n   *                         a U_BUFFER_OVERFLOW_ERROR will be returned.\n   *    @param   destFields  An array to be filled with the position of each\n   *                         of the extracted fields within destBuf.\n   *    @param   destFieldsCapacity  The number of elements in the destFields array.\n   *                If the number of fields found is less than destFieldsCapacity,\n   *                the extra destFields elements are set to zero.\n   *                If destFieldsCapacity is too small, the trailing part of the\n   *                input, including any field delimiters, is treated as if it\n   *                were the last field - it is copied to the destBuf, and\n   *                its position is in the destBuf is stored in the last element\n   *                of destFields.  This behavior mimics that of Perl.  It is not\n   *                an error condition, and no error status is returned when all destField\n   *                positions are used.\n   * @param status  A reference to a UErrorCode to receive any errors.\n   * @return        The number of fields into which the input string was split.\n   * @stable ICU 3.0\n   */\nU_STABLE int32_t U_EXPORT2 \nuregex_split(   URegularExpression      *regexp,\n                  UChar                 *destBuf,\n                  int32_t                destCapacity,\n                  int32_t               *requiredCapacity,\n                  UChar                 *destFields[],\n                  int32_t                destFieldsCapacity,\n                  UErrorCode            *status);\n\n  /**\n   * Split a string into fields.  Somewhat like split() from Perl.\n   * The pattern matches identify delimiters that separate the input\n   *  into fields.  The input data between the matches becomes the\n   *  fields themselves.\n   * <p>\n   * The behavior of this function is not very closely aligned with uregex_split();\n   * instead, it is based on (and implemented directly on top of) the C++ split method.\n   *\n   * @param regexp  The compiled regular expression.\n   * @param destFields    An array of mutable UText structs to receive the results of the split.\n   *                If a field is NULL, a new UText is allocated to contain the results for\n   *                that field. This new UText is not guaranteed to be mutable.\n   * @param destFieldsCapacity  The number of elements in the destination array.\n   *                If the number of fields found is less than destCapacity, the\n   *                extra strings in the destination array are not altered.\n   *                If the number of destination strings is less than the number\n   *                of fields, the trailing part of the input string, including any\n   *                field delimiters, is placed in the last destination string.\n   *                This behavior mimics that of Perl.  It is not  an error condition, and no\n   *                error status is returned when all destField positions are used.\n   * @param status  A reference to a UErrorCode to receive any errors.\n   * @return        The number of fields into which the input string was split.\n   *\n   * @stable ICU 4.6\n   */\nU_STABLE int32_t U_EXPORT2 \nuregex_splitUText(URegularExpression    *regexp,\n                  UText                 *destFields[],\n                  int32_t                destFieldsCapacity,\n                  UErrorCode            *status);\n\n/**\n * Set a processing time limit for match operations with this URegularExpression.\n *\n * Some patterns, when matching certain strings, can run in exponential time.\n * For practical purposes, the match operation may appear to be in an\n * infinite loop.\n * When a limit is set a match operation will fail with an error if the\n * limit is exceeded.\n * <p>\n * The units of the limit are steps of the match engine.\n * Correspondence with actual processor time will depend on the speed\n * of the processor and the details of the specific pattern, but will\n * typically be on the order of milliseconds.\n * <p>\n * By default, the matching time is not limited.\n * <p>\n *\n * @param   regexp      The compiled regular expression.\n * @param   limit       The limit value, or 0 for no limit.\n * @param   status      A reference to a UErrorCode to receive any errors.\n * @stable ICU 4.0\n */\nU_STABLE void U_EXPORT2\nuregex_setTimeLimit(URegularExpression      *regexp,\n                    int32_t                  limit,\n                    UErrorCode              *status);\n\n/**\n * Get the time limit for for matches with this URegularExpression.\n * A return value of zero indicates that there is no limit.\n *\n * @param   regexp      The compiled regular expression.\n * @param   status      A reference to a UErrorCode to receive any errors.\n * @return the maximum allowed time for a match, in units of processing steps.\n * @stable ICU 4.0\n */\nU_STABLE int32_t U_EXPORT2\nuregex_getTimeLimit(const URegularExpression      *regexp,\n                          UErrorCode              *status);\n\n/**\n * Set the amount of heap storage available for use by the match backtracking stack.\n * <p>\n * ICU uses a backtracking regular expression engine, with the backtrack stack\n * maintained on the heap.  This function sets the limit to the amount of memory\n * that can be used  for this purpose.  A backtracking stack overflow will\n * result in an error from the match operation that caused it.\n * <p>\n * A limit is desirable because a malicious or poorly designed pattern can use\n * excessive memory, potentially crashing the process.  A limit is enabled\n * by default.\n * <p>\n * @param   regexp      The compiled regular expression.\n * @param   limit       The maximum size, in bytes, of the matching backtrack stack.\n *                      A value of -1 means no limit.\n *                      The limit must be greater than zero, or -1.\n * @param   status      A reference to a UErrorCode to receive any errors.\n *\n * @stable ICU 4.0\n */\nU_STABLE void U_EXPORT2\nuregex_setStackLimit(URegularExpression      *regexp,\n                     int32_t                  limit,\n                     UErrorCode              *status);\n\n/**\n * Get the size of the heap storage available for use by the back tracking stack.\n *\n * @return  the maximum backtracking stack size, in bytes, or zero if the\n *          stack size is unlimited.\n * @stable ICU 4.0\n */\nU_STABLE int32_t U_EXPORT2\nuregex_getStackLimit(const URegularExpression      *regexp,\n                           UErrorCode              *status);\n\n\n/**\n * Function pointer for a regular expression matching callback function.\n * When set, a callback function will be called periodically during matching\n * operations.  If the call back function returns FALSE, the matching\n * operation will be terminated early.\n *\n * Note:  the callback function must not call other functions on this\n *        URegularExpression.\n *\n * @param context  context pointer.  The callback function will be invoked\n *                 with the context specified at the time that\n *                 uregex_setMatchCallback() is called.\n * @param steps    the accumulated processing time, in match steps, \n *                 for this matching operation.\n * @return         TRUE to continue the matching operation.\n *                 FALSE to terminate the matching operation.\n * @stable ICU 4.0\n */\nU_CDECL_BEGIN\ntypedef UBool U_CALLCONV URegexMatchCallback (\n                   const void *context,\n                   int32_t     steps);\nU_CDECL_END\n\n/**\n * Set a callback function for this URegularExpression.\n * During matching operations the function will be called periodically,\n * giving the application the opportunity to terminate a long-running\n * match.\n *\n * @param   regexp      The compiled regular expression.\n * @param   callback    A pointer to the user-supplied callback function.\n * @param   context     User context pointer.  The value supplied at the\n *                      time the callback function is set will be saved\n *                      and passed to the callback each time that it is called.\n * @param   status      A reference to a UErrorCode to receive any errors.\n * @stable ICU 4.0\n */\nU_STABLE void U_EXPORT2\nuregex_setMatchCallback(URegularExpression      *regexp,\n                        URegexMatchCallback     *callback,\n                        const void              *context,\n                        UErrorCode              *status);\n\n\n/**\n *  Get the callback function for this URegularExpression.\n *\n * @param   regexp      The compiled regular expression.\n * @param   callback    Out parameter, receives a pointer to the user-supplied \n *                      callback function.\n * @param   context     Out parameter, receives the user context pointer that\n *                      was set when uregex_setMatchCallback() was called.\n * @param   status      A reference to a UErrorCode to receive any errors.\n * @stable ICU 4.0\n */\nU_STABLE void U_EXPORT2\nuregex_getMatchCallback(const URegularExpression    *regexp,\n                        URegexMatchCallback        **callback,\n                        const void                 **context,\n                        UErrorCode                  *status);\n\n/**\n * Function pointer for a regular expression find callback function.\n * \n * When set, a callback function will be called during a find operation\n * and for operations that depend on find, such as findNext, split and some replace\n * operations like replaceFirst.\n * The callback will usually be called after each attempt at a match, but this is not a\n * guarantee that the callback will be invoked at each character.  For finds where the\n * match engine is invoked at each character, this may be close to true, but less likely\n * for more optimized loops where the pattern is known to only start, and the match\n * engine invoked, at certain characters.\n * When invoked, this callback will specify the index at which a match operation is about\n * to be attempted, giving the application the opportunity to terminate a long-running\n * find operation.\n * \n * If the call back function returns FALSE, the find operation will be terminated early.\n *\n * Note:  the callback function must not call other functions on this\n *        URegularExpression\n *\n * @param context  context pointer.  The callback function will be invoked\n *                 with the context specified at the time that\n *                 uregex_setFindProgressCallback() is called.\n * @param matchIndex  the next index at which a match attempt will be attempted for this\n *                 find operation.  If this callback interrupts the search, this is the\n *                 index at which a find/findNext operation may be re-initiated.\n * @return         TRUE to continue the matching operation.\n *                 FALSE to terminate the matching operation.\n * @stable ICU 4.6\n */\nU_CDECL_BEGIN\ntypedef UBool U_CALLCONV URegexFindProgressCallback (\n                   const void *context,\n                   int64_t     matchIndex);\nU_CDECL_END\n\n\n/**\n *  Set the find progress callback function for this URegularExpression.\n *\n * @param   regexp      The compiled regular expression.\n * @param   callback    A pointer to the user-supplied callback function.\n * @param   context     User context pointer.  The value supplied at the\n *                      time the callback function is set will be saved\n *                      and passed to the callback each time that it is called.\n * @param   status      A reference to a UErrorCode to receive any errors.\n * @stable ICU 4.6\n */\nU_STABLE void U_EXPORT2\nuregex_setFindProgressCallback(URegularExpression              *regexp,\n                                URegexFindProgressCallback      *callback,\n                                const void                      *context,\n                                UErrorCode                      *status);\n\n/**\n *  Get the find progress callback function for this URegularExpression.\n *\n * @param   regexp      The compiled regular expression.\n * @param   callback    Out parameter, receives a pointer to the user-supplied \n *                      callback function.\n * @param   context     Out parameter, receives the user context pointer that\n *                      was set when uregex_setFindProgressCallback() was called.\n * @param   status      A reference to a UErrorCode to receive any errors.\n * @stable ICU 4.6\n */\nU_STABLE void U_EXPORT2\nuregex_getFindProgressCallback(const URegularExpression          *regexp,\n                                URegexFindProgressCallback        **callback,\n                                const void                        **context,\n                                UErrorCode                        *status);\n\n#endif   /*  !UCONFIG_NO_REGULAR_EXPRESSIONS  */\n#endif   /*  UREGEX_H  */\n"
  },
  {
    "path": "deprecated/android/addons/icucompat/unicode/urename.h",
    "content": "/*\n*******************************************************************************\n*   Copyright (C) 2002-2012, International Business Machines\n*   Corporation and others.  All Rights Reserved.\n*******************************************************************************\n*\n*   file name:  urename.h\n*   encoding:   US-ASCII\n*   tab size:   8 (not used)\n*   indentation:4\n*\n*   Created by: Perl script tools/genren.pl written by Vladimir Weinstein\n*\n*  Contains data for renaming ICU exports.\n*  Gets included by umachine.h\n*\n*  THIS FILE IS MACHINE-GENERATED, DON'T PLAY WITH IT IF YOU DON'T KNOW WHAT\n*  YOU ARE DOING, OTHERWISE VERY BAD THINGS WILL HAPPEN!\n*/\n\n#ifndef URENAME_H\n#define URENAME_H\n\n/* U_DISABLE_RENAMING can be defined in the following ways:\n *   - when running configure, e.g.\n *        runConfigureICU Linux --disable-renaming\n *   - by changing the default setting of U_DISABLE_RENAMING in uconfig.h\n */\n\n#include \"unicode/uconfig.h\"\n\n#if !U_DISABLE_RENAMING\n\n/* We need the U_ICU_ENTRY_POINT_RENAME definition. There's a default one in unicode/uvernum.h we can use, but we will give\n   the platform a chance to define it first.\n   Normally (if utypes.h or umachine.h was included first) this will not be necessary as it will already be defined.\n */\n\n#ifndef U_ICU_ENTRY_POINT_RENAME\n#include \"unicode/umachine.h\"\n#endif\n\n/* If we still don't have U_ICU_ENTRY_POINT_RENAME use the default. */\n#ifndef U_ICU_ENTRY_POINT_RENAME\n#include \"unicode/uvernum.h\"\n#endif\n\n/* Error out before the following defines cause very strange and unexpected code breakage */\n#ifndef U_ICU_ENTRY_POINT_RENAME\n#error U_ICU_ENTRY_POINT_RENAME is not defined - cannot continue. Consider defining U_DISABLE_RENAMING if renaming should not be used.\n#endif\n\n\n/* C exports renaming data */\n\n#define T_CString_int64ToString U_ICU_ENTRY_POINT_RENAME(T_CString_int64ToString)\n#define T_CString_integerToString U_ICU_ENTRY_POINT_RENAME(T_CString_integerToString)\n#define T_CString_stringToInteger U_ICU_ENTRY_POINT_RENAME(T_CString_stringToInteger)\n#define T_CString_toLowerCase U_ICU_ENTRY_POINT_RENAME(T_CString_toLowerCase)\n#define T_CString_toUpperCase U_ICU_ENTRY_POINT_RENAME(T_CString_toUpperCase)\n#define UCNV_FROM_U_CALLBACK_ESCAPE U_ICU_ENTRY_POINT_RENAME(UCNV_FROM_U_CALLBACK_ESCAPE)\n#define UCNV_FROM_U_CALLBACK_SKIP U_ICU_ENTRY_POINT_RENAME(UCNV_FROM_U_CALLBACK_SKIP)\n#define UCNV_FROM_U_CALLBACK_STOP U_ICU_ENTRY_POINT_RENAME(UCNV_FROM_U_CALLBACK_STOP)\n#define UCNV_FROM_U_CALLBACK_SUBSTITUTE U_ICU_ENTRY_POINT_RENAME(UCNV_FROM_U_CALLBACK_SUBSTITUTE)\n#define UCNV_TO_U_CALLBACK_ESCAPE U_ICU_ENTRY_POINT_RENAME(UCNV_TO_U_CALLBACK_ESCAPE)\n#define UCNV_TO_U_CALLBACK_SKIP U_ICU_ENTRY_POINT_RENAME(UCNV_TO_U_CALLBACK_SKIP)\n#define UCNV_TO_U_CALLBACK_STOP U_ICU_ENTRY_POINT_RENAME(UCNV_TO_U_CALLBACK_STOP)\n#define UCNV_TO_U_CALLBACK_SUBSTITUTE U_ICU_ENTRY_POINT_RENAME(UCNV_TO_U_CALLBACK_SUBSTITUTE)\n#define UDataMemory_createNewInstance U_ICU_ENTRY_POINT_RENAME(UDataMemory_createNewInstance)\n#define UDataMemory_init U_ICU_ENTRY_POINT_RENAME(UDataMemory_init)\n#define UDataMemory_isLoaded U_ICU_ENTRY_POINT_RENAME(UDataMemory_isLoaded)\n#define UDataMemory_normalizeDataPointer U_ICU_ENTRY_POINT_RENAME(UDataMemory_normalizeDataPointer)\n#define UDataMemory_setData U_ICU_ENTRY_POINT_RENAME(UDataMemory_setData)\n#define UDatamemory_assign U_ICU_ENTRY_POINT_RENAME(UDatamemory_assign)\n#define _ASCIIData U_ICU_ENTRY_POINT_RENAME(_ASCIIData)\n#define _Bocu1Data U_ICU_ENTRY_POINT_RENAME(_Bocu1Data)\n#define _CESU8Data U_ICU_ENTRY_POINT_RENAME(_CESU8Data)\n#define _CompoundTextData U_ICU_ENTRY_POINT_RENAME(_CompoundTextData)\n#define _HZData U_ICU_ENTRY_POINT_RENAME(_HZData)\n#define _IMAPData U_ICU_ENTRY_POINT_RENAME(_IMAPData)\n#define _ISCIIData U_ICU_ENTRY_POINT_RENAME(_ISCIIData)\n#define _ISO2022Data U_ICU_ENTRY_POINT_RENAME(_ISO2022Data)\n#define _LMBCSData1 U_ICU_ENTRY_POINT_RENAME(_LMBCSData1)\n#define _LMBCSData11 U_ICU_ENTRY_POINT_RENAME(_LMBCSData11)\n#define _LMBCSData16 U_ICU_ENTRY_POINT_RENAME(_LMBCSData16)\n#define _LMBCSData17 U_ICU_ENTRY_POINT_RENAME(_LMBCSData17)\n#define _LMBCSData18 U_ICU_ENTRY_POINT_RENAME(_LMBCSData18)\n#define _LMBCSData19 U_ICU_ENTRY_POINT_RENAME(_LMBCSData19)\n#define _LMBCSData2 U_ICU_ENTRY_POINT_RENAME(_LMBCSData2)\n#define _LMBCSData3 U_ICU_ENTRY_POINT_RENAME(_LMBCSData3)\n#define _LMBCSData4 U_ICU_ENTRY_POINT_RENAME(_LMBCSData4)\n#define _LMBCSData5 U_ICU_ENTRY_POINT_RENAME(_LMBCSData5)\n#define _LMBCSData6 U_ICU_ENTRY_POINT_RENAME(_LMBCSData6)\n#define _LMBCSData8 U_ICU_ENTRY_POINT_RENAME(_LMBCSData8)\n#define _Latin1Data U_ICU_ENTRY_POINT_RENAME(_Latin1Data)\n#define _MBCSData U_ICU_ENTRY_POINT_RENAME(_MBCSData)\n#define _SCSUData U_ICU_ENTRY_POINT_RENAME(_SCSUData)\n#define _UTF16BEData U_ICU_ENTRY_POINT_RENAME(_UTF16BEData)\n#define _UTF16Data U_ICU_ENTRY_POINT_RENAME(_UTF16Data)\n#define _UTF16LEData U_ICU_ENTRY_POINT_RENAME(_UTF16LEData)\n#define _UTF32BEData U_ICU_ENTRY_POINT_RENAME(_UTF32BEData)\n#define _UTF32Data U_ICU_ENTRY_POINT_RENAME(_UTF32Data)\n#define _UTF32LEData U_ICU_ENTRY_POINT_RENAME(_UTF32LEData)\n#define _UTF7Data U_ICU_ENTRY_POINT_RENAME(_UTF7Data)\n#define _UTF8Data U_ICU_ENTRY_POINT_RENAME(_UTF8Data)\n#define bms_close U_ICU_ENTRY_POINT_RENAME(bms_close)\n#define bms_empty U_ICU_ENTRY_POINT_RENAME(bms_empty)\n#define bms_getData U_ICU_ENTRY_POINT_RENAME(bms_getData)\n#define bms_open U_ICU_ENTRY_POINT_RENAME(bms_open)\n#define bms_search U_ICU_ENTRY_POINT_RENAME(bms_search)\n#define bms_setTargetString U_ICU_ENTRY_POINT_RENAME(bms_setTargetString)\n#define cmemory_cleanup U_ICU_ENTRY_POINT_RENAME(cmemory_cleanup)\n#define cmemory_inUse U_ICU_ENTRY_POINT_RENAME(cmemory_inUse)\n#define izrule_clone U_ICU_ENTRY_POINT_RENAME(izrule_clone)\n#define izrule_close U_ICU_ENTRY_POINT_RENAME(izrule_close)\n#define izrule_equals U_ICU_ENTRY_POINT_RENAME(izrule_equals)\n#define izrule_getDSTSavings U_ICU_ENTRY_POINT_RENAME(izrule_getDSTSavings)\n#define izrule_getDynamicClassID U_ICU_ENTRY_POINT_RENAME(izrule_getDynamicClassID)\n#define izrule_getFinalStart U_ICU_ENTRY_POINT_RENAME(izrule_getFinalStart)\n#define izrule_getFirstStart U_ICU_ENTRY_POINT_RENAME(izrule_getFirstStart)\n#define izrule_getName U_ICU_ENTRY_POINT_RENAME(izrule_getName)\n#define izrule_getNextStart U_ICU_ENTRY_POINT_RENAME(izrule_getNextStart)\n#define izrule_getPreviousStart U_ICU_ENTRY_POINT_RENAME(izrule_getPreviousStart)\n#define izrule_getRawOffset U_ICU_ENTRY_POINT_RENAME(izrule_getRawOffset)\n#define izrule_getStaticClassID U_ICU_ENTRY_POINT_RENAME(izrule_getStaticClassID)\n#define izrule_isEquivalentTo U_ICU_ENTRY_POINT_RENAME(izrule_isEquivalentTo)\n#define izrule_open U_ICU_ENTRY_POINT_RENAME(izrule_open)\n#define le_close U_ICU_ENTRY_POINT_RENAME(le_close)\n#define le_create U_ICU_ENTRY_POINT_RENAME(le_create)\n#define le_getCharIndices U_ICU_ENTRY_POINT_RENAME(le_getCharIndices)\n#define le_getCharIndicesWithBase U_ICU_ENTRY_POINT_RENAME(le_getCharIndicesWithBase)\n#define le_getGlyphCount U_ICU_ENTRY_POINT_RENAME(le_getGlyphCount)\n#define le_getGlyphPosition U_ICU_ENTRY_POINT_RENAME(le_getGlyphPosition)\n#define le_getGlyphPositions U_ICU_ENTRY_POINT_RENAME(le_getGlyphPositions)\n#define le_getGlyphs U_ICU_ENTRY_POINT_RENAME(le_getGlyphs)\n#define le_layoutChars U_ICU_ENTRY_POINT_RENAME(le_layoutChars)\n#define le_reset U_ICU_ENTRY_POINT_RENAME(le_reset)\n#define locale_getKeywords U_ICU_ENTRY_POINT_RENAME(locale_getKeywords)\n#define locale_getKeywordsStart U_ICU_ENTRY_POINT_RENAME(locale_getKeywordsStart)\n#define locale_get_default U_ICU_ENTRY_POINT_RENAME(locale_get_default)\n#define locale_set_default U_ICU_ENTRY_POINT_RENAME(locale_set_default)\n#define pl_addFontRun U_ICU_ENTRY_POINT_RENAME(pl_addFontRun)\n#define pl_addLocaleRun U_ICU_ENTRY_POINT_RENAME(pl_addLocaleRun)\n#define pl_addValueRun U_ICU_ENTRY_POINT_RENAME(pl_addValueRun)\n#define pl_close U_ICU_ENTRY_POINT_RENAME(pl_close)\n#define pl_closeFontRuns U_ICU_ENTRY_POINT_RENAME(pl_closeFontRuns)\n#define pl_closeLine U_ICU_ENTRY_POINT_RENAME(pl_closeLine)\n#define pl_closeLocaleRuns U_ICU_ENTRY_POINT_RENAME(pl_closeLocaleRuns)\n#define pl_closeValueRuns U_ICU_ENTRY_POINT_RENAME(pl_closeValueRuns)\n#define pl_countLineRuns U_ICU_ENTRY_POINT_RENAME(pl_countLineRuns)\n#define pl_create U_ICU_ENTRY_POINT_RENAME(pl_create)\n#define pl_getAscent U_ICU_ENTRY_POINT_RENAME(pl_getAscent)\n#define pl_getDescent U_ICU_ENTRY_POINT_RENAME(pl_getDescent)\n#define pl_getFontRunCount U_ICU_ENTRY_POINT_RENAME(pl_getFontRunCount)\n#define pl_getFontRunFont U_ICU_ENTRY_POINT_RENAME(pl_getFontRunFont)\n#define pl_getFontRunLastLimit U_ICU_ENTRY_POINT_RENAME(pl_getFontRunLastLimit)\n#define pl_getFontRunLimit U_ICU_ENTRY_POINT_RENAME(pl_getFontRunLimit)\n#define pl_getLeading U_ICU_ENTRY_POINT_RENAME(pl_getLeading)\n#define pl_getLineAscent U_ICU_ENTRY_POINT_RENAME(pl_getLineAscent)\n#define pl_getLineDescent U_ICU_ENTRY_POINT_RENAME(pl_getLineDescent)\n#define pl_getLineLeading U_ICU_ENTRY_POINT_RENAME(pl_getLineLeading)\n#define pl_getLineVisualRun U_ICU_ENTRY_POINT_RENAME(pl_getLineVisualRun)\n#define pl_getLineWidth U_ICU_ENTRY_POINT_RENAME(pl_getLineWidth)\n#define pl_getLocaleRunCount U_ICU_ENTRY_POINT_RENAME(pl_getLocaleRunCount)\n#define pl_getLocaleRunLastLimit U_ICU_ENTRY_POINT_RENAME(pl_getLocaleRunLastLimit)\n#define pl_getLocaleRunLimit U_ICU_ENTRY_POINT_RENAME(pl_getLocaleRunLimit)\n#define pl_getLocaleRunLocale U_ICU_ENTRY_POINT_RENAME(pl_getLocaleRunLocale)\n#define pl_getParagraphLevel U_ICU_ENTRY_POINT_RENAME(pl_getParagraphLevel)\n#define pl_getTextDirection U_ICU_ENTRY_POINT_RENAME(pl_getTextDirection)\n#define pl_getValueRunCount U_ICU_ENTRY_POINT_RENAME(pl_getValueRunCount)\n#define pl_getValueRunLastLimit U_ICU_ENTRY_POINT_RENAME(pl_getValueRunLastLimit)\n#define pl_getValueRunLimit U_ICU_ENTRY_POINT_RENAME(pl_getValueRunLimit)\n#define pl_getValueRunValue U_ICU_ENTRY_POINT_RENAME(pl_getValueRunValue)\n#define pl_getVisualRunAscent U_ICU_ENTRY_POINT_RENAME(pl_getVisualRunAscent)\n#define pl_getVisualRunDescent U_ICU_ENTRY_POINT_RENAME(pl_getVisualRunDescent)\n#define pl_getVisualRunDirection U_ICU_ENTRY_POINT_RENAME(pl_getVisualRunDirection)\n#define pl_getVisualRunFont U_ICU_ENTRY_POINT_RENAME(pl_getVisualRunFont)\n#define pl_getVisualRunGlyphCount U_ICU_ENTRY_POINT_RENAME(pl_getVisualRunGlyphCount)\n#define pl_getVisualRunGlyphToCharMap U_ICU_ENTRY_POINT_RENAME(pl_getVisualRunGlyphToCharMap)\n#define pl_getVisualRunGlyphs U_ICU_ENTRY_POINT_RENAME(pl_getVisualRunGlyphs)\n#define pl_getVisualRunLeading U_ICU_ENTRY_POINT_RENAME(pl_getVisualRunLeading)\n#define pl_getVisualRunPositions U_ICU_ENTRY_POINT_RENAME(pl_getVisualRunPositions)\n#define pl_isComplex U_ICU_ENTRY_POINT_RENAME(pl_isComplex)\n#define pl_nextLine U_ICU_ENTRY_POINT_RENAME(pl_nextLine)\n#define pl_openEmptyFontRuns U_ICU_ENTRY_POINT_RENAME(pl_openEmptyFontRuns)\n#define pl_openEmptyLocaleRuns U_ICU_ENTRY_POINT_RENAME(pl_openEmptyLocaleRuns)\n#define pl_openEmptyValueRuns U_ICU_ENTRY_POINT_RENAME(pl_openEmptyValueRuns)\n#define pl_openFontRuns U_ICU_ENTRY_POINT_RENAME(pl_openFontRuns)\n#define pl_openLocaleRuns U_ICU_ENTRY_POINT_RENAME(pl_openLocaleRuns)\n#define pl_openValueRuns U_ICU_ENTRY_POINT_RENAME(pl_openValueRuns)\n#define pl_reflow U_ICU_ENTRY_POINT_RENAME(pl_reflow)\n#define pl_resetFontRuns U_ICU_ENTRY_POINT_RENAME(pl_resetFontRuns)\n#define pl_resetLocaleRuns U_ICU_ENTRY_POINT_RENAME(pl_resetLocaleRuns)\n#define pl_resetValueRuns U_ICU_ENTRY_POINT_RENAME(pl_resetValueRuns)\n#define res_countArrayItems U_ICU_ENTRY_POINT_RENAME(res_countArrayItems)\n#define res_findResource U_ICU_ENTRY_POINT_RENAME(res_findResource)\n#define res_getAlias U_ICU_ENTRY_POINT_RENAME(res_getAlias)\n#define res_getArrayItem U_ICU_ENTRY_POINT_RENAME(res_getArrayItem)\n#define res_getBinary U_ICU_ENTRY_POINT_RENAME(res_getBinary)\n#define res_getIntVector U_ICU_ENTRY_POINT_RENAME(res_getIntVector)\n#define res_getPublicType U_ICU_ENTRY_POINT_RENAME(res_getPublicType)\n#define res_getResource U_ICU_ENTRY_POINT_RENAME(res_getResource)\n#define res_getString U_ICU_ENTRY_POINT_RENAME(res_getString)\n#define res_getTableItemByIndex U_ICU_ENTRY_POINT_RENAME(res_getTableItemByIndex)\n#define res_getTableItemByKey U_ICU_ENTRY_POINT_RENAME(res_getTableItemByKey)\n#define res_load U_ICU_ENTRY_POINT_RENAME(res_load)\n#define res_read U_ICU_ENTRY_POINT_RENAME(res_read)\n#define res_unload U_ICU_ENTRY_POINT_RENAME(res_unload)\n#define u_UCharsToChars U_ICU_ENTRY_POINT_RENAME(u_UCharsToChars)\n#define u_austrcpy U_ICU_ENTRY_POINT_RENAME(u_austrcpy)\n#define u_austrncpy U_ICU_ENTRY_POINT_RENAME(u_austrncpy)\n#define u_catclose U_ICU_ENTRY_POINT_RENAME(u_catclose)\n#define u_catgets U_ICU_ENTRY_POINT_RENAME(u_catgets)\n#define u_catopen U_ICU_ENTRY_POINT_RENAME(u_catopen)\n#define u_charAge U_ICU_ENTRY_POINT_RENAME(u_charAge)\n#define u_charDigitValue U_ICU_ENTRY_POINT_RENAME(u_charDigitValue)\n#define u_charDirection U_ICU_ENTRY_POINT_RENAME(u_charDirection)\n#define u_charFromName U_ICU_ENTRY_POINT_RENAME(u_charFromName)\n#define u_charMirror U_ICU_ENTRY_POINT_RENAME(u_charMirror)\n#define u_charName U_ICU_ENTRY_POINT_RENAME(u_charName)\n#define u_charType U_ICU_ENTRY_POINT_RENAME(u_charType)\n#define u_charsToUChars U_ICU_ENTRY_POINT_RENAME(u_charsToUChars)\n#define u_cleanup U_ICU_ENTRY_POINT_RENAME(u_cleanup)\n#define u_countChar32 U_ICU_ENTRY_POINT_RENAME(u_countChar32)\n#define u_digit U_ICU_ENTRY_POINT_RENAME(u_digit)\n#define u_enumCharNames U_ICU_ENTRY_POINT_RENAME(u_enumCharNames)\n#define u_enumCharTypes U_ICU_ENTRY_POINT_RENAME(u_enumCharTypes)\n#define u_errorName U_ICU_ENTRY_POINT_RENAME(u_errorName)\n#define u_fadopt U_ICU_ENTRY_POINT_RENAME(u_fadopt)\n#define u_fclose U_ICU_ENTRY_POINT_RENAME(u_fclose)\n#define u_feof U_ICU_ENTRY_POINT_RENAME(u_feof)\n#define u_fflush U_ICU_ENTRY_POINT_RENAME(u_fflush)\n#define u_fgetConverter U_ICU_ENTRY_POINT_RENAME(u_fgetConverter)\n#define u_fgetc U_ICU_ENTRY_POINT_RENAME(u_fgetc)\n#define u_fgetcodepage U_ICU_ENTRY_POINT_RENAME(u_fgetcodepage)\n#define u_fgetcx U_ICU_ENTRY_POINT_RENAME(u_fgetcx)\n#define u_fgetfile U_ICU_ENTRY_POINT_RENAME(u_fgetfile)\n#define u_fgetlocale U_ICU_ENTRY_POINT_RENAME(u_fgetlocale)\n#define u_fgets U_ICU_ENTRY_POINT_RENAME(u_fgets)\n#define u_file_read U_ICU_ENTRY_POINT_RENAME(u_file_read)\n#define u_file_write U_ICU_ENTRY_POINT_RENAME(u_file_write)\n#define u_file_write_flush U_ICU_ENTRY_POINT_RENAME(u_file_write_flush)\n#define u_finit U_ICU_ENTRY_POINT_RENAME(u_finit)\n#define u_flushDefaultConverter U_ICU_ENTRY_POINT_RENAME(u_flushDefaultConverter)\n#define u_foldCase U_ICU_ENTRY_POINT_RENAME(u_foldCase)\n#define u_fopen U_ICU_ENTRY_POINT_RENAME(u_fopen)\n#define u_forDigit U_ICU_ENTRY_POINT_RENAME(u_forDigit)\n#define u_formatMessage U_ICU_ENTRY_POINT_RENAME(u_formatMessage)\n#define u_formatMessageWithError U_ICU_ENTRY_POINT_RENAME(u_formatMessageWithError)\n#define u_fprintf U_ICU_ENTRY_POINT_RENAME(u_fprintf)\n#define u_fprintf_u U_ICU_ENTRY_POINT_RENAME(u_fprintf_u)\n#define u_fputc U_ICU_ENTRY_POINT_RENAME(u_fputc)\n#define u_fputs U_ICU_ENTRY_POINT_RENAME(u_fputs)\n#define u_frewind U_ICU_ENTRY_POINT_RENAME(u_frewind)\n#define u_fscanf U_ICU_ENTRY_POINT_RENAME(u_fscanf)\n#define u_fscanf_u U_ICU_ENTRY_POINT_RENAME(u_fscanf_u)\n#define u_fsetcodepage U_ICU_ENTRY_POINT_RENAME(u_fsetcodepage)\n#define u_fsetlocale U_ICU_ENTRY_POINT_RENAME(u_fsetlocale)\n#define u_fsettransliterator U_ICU_ENTRY_POINT_RENAME(u_fsettransliterator)\n#define u_fstropen U_ICU_ENTRY_POINT_RENAME(u_fstropen)\n#define u_fungetc U_ICU_ENTRY_POINT_RENAME(u_fungetc)\n#define u_getCombiningClass U_ICU_ENTRY_POINT_RENAME(u_getCombiningClass)\n#define u_getDataDirectory U_ICU_ENTRY_POINT_RENAME(u_getDataDirectory)\n#define u_getDataVersion U_ICU_ENTRY_POINT_RENAME(u_getDataVersion)\n#define u_getDefaultConverter U_ICU_ENTRY_POINT_RENAME(u_getDefaultConverter)\n#define u_getFC_NFKC_Closure U_ICU_ENTRY_POINT_RENAME(u_getFC_NFKC_Closure)\n#define u_getISOComment U_ICU_ENTRY_POINT_RENAME(u_getISOComment)\n#define u_getIntPropertyMaxValue U_ICU_ENTRY_POINT_RENAME(u_getIntPropertyMaxValue)\n#define u_getIntPropertyMinValue U_ICU_ENTRY_POINT_RENAME(u_getIntPropertyMinValue)\n#define u_getIntPropertyValue U_ICU_ENTRY_POINT_RENAME(u_getIntPropertyValue)\n#define u_getMainProperties U_ICU_ENTRY_POINT_RENAME(u_getMainProperties)\n#define u_getNumericValue U_ICU_ENTRY_POINT_RENAME(u_getNumericValue)\n#define u_getPropertyEnum U_ICU_ENTRY_POINT_RENAME(u_getPropertyEnum)\n#define u_getPropertyName U_ICU_ENTRY_POINT_RENAME(u_getPropertyName)\n#define u_getPropertyValueEnum U_ICU_ENTRY_POINT_RENAME(u_getPropertyValueEnum)\n#define u_getPropertyValueName U_ICU_ENTRY_POINT_RENAME(u_getPropertyValueName)\n#define u_getUnicodeProperties U_ICU_ENTRY_POINT_RENAME(u_getUnicodeProperties)\n#define u_getUnicodeVersion U_ICU_ENTRY_POINT_RENAME(u_getUnicodeVersion)\n#define u_getVersion U_ICU_ENTRY_POINT_RENAME(u_getVersion)\n#define u_get_stdout U_ICU_ENTRY_POINT_RENAME(u_get_stdout)\n#define u_hasBinaryProperty U_ICU_ENTRY_POINT_RENAME(u_hasBinaryProperty)\n#define u_init U_ICU_ENTRY_POINT_RENAME(u_init)\n#define u_isIDIgnorable U_ICU_ENTRY_POINT_RENAME(u_isIDIgnorable)\n#define u_isIDPart U_ICU_ENTRY_POINT_RENAME(u_isIDPart)\n#define u_isIDStart U_ICU_ENTRY_POINT_RENAME(u_isIDStart)\n#define u_isISOControl U_ICU_ENTRY_POINT_RENAME(u_isISOControl)\n#define u_isJavaIDPart U_ICU_ENTRY_POINT_RENAME(u_isJavaIDPart)\n#define u_isJavaIDStart U_ICU_ENTRY_POINT_RENAME(u_isJavaIDStart)\n#define u_isJavaSpaceChar U_ICU_ENTRY_POINT_RENAME(u_isJavaSpaceChar)\n#define u_isMirrored U_ICU_ENTRY_POINT_RENAME(u_isMirrored)\n#define u_isUAlphabetic U_ICU_ENTRY_POINT_RENAME(u_isUAlphabetic)\n#define u_isULowercase U_ICU_ENTRY_POINT_RENAME(u_isULowercase)\n#define u_isUUppercase U_ICU_ENTRY_POINT_RENAME(u_isUUppercase)\n#define u_isUWhiteSpace U_ICU_ENTRY_POINT_RENAME(u_isUWhiteSpace)\n#define u_isWhitespace U_ICU_ENTRY_POINT_RENAME(u_isWhitespace)\n#define u_isalnum U_ICU_ENTRY_POINT_RENAME(u_isalnum)\n#define u_isalnumPOSIX U_ICU_ENTRY_POINT_RENAME(u_isalnumPOSIX)\n#define u_isalpha U_ICU_ENTRY_POINT_RENAME(u_isalpha)\n#define u_isbase U_ICU_ENTRY_POINT_RENAME(u_isbase)\n#define u_isblank U_ICU_ENTRY_POINT_RENAME(u_isblank)\n#define u_iscntrl U_ICU_ENTRY_POINT_RENAME(u_iscntrl)\n#define u_isdefined U_ICU_ENTRY_POINT_RENAME(u_isdefined)\n#define u_isdigit U_ICU_ENTRY_POINT_RENAME(u_isdigit)\n#define u_isgraph U_ICU_ENTRY_POINT_RENAME(u_isgraph)\n#define u_isgraphPOSIX U_ICU_ENTRY_POINT_RENAME(u_isgraphPOSIX)\n#define u_islower U_ICU_ENTRY_POINT_RENAME(u_islower)\n#define u_isprint U_ICU_ENTRY_POINT_RENAME(u_isprint)\n#define u_isprintPOSIX U_ICU_ENTRY_POINT_RENAME(u_isprintPOSIX)\n#define u_ispunct U_ICU_ENTRY_POINT_RENAME(u_ispunct)\n#define u_isspace U_ICU_ENTRY_POINT_RENAME(u_isspace)\n#define u_istitle U_ICU_ENTRY_POINT_RENAME(u_istitle)\n#define u_isupper U_ICU_ENTRY_POINT_RENAME(u_isupper)\n#define u_isxdigit U_ICU_ENTRY_POINT_RENAME(u_isxdigit)\n#define u_locbund_close U_ICU_ENTRY_POINT_RENAME(u_locbund_close)\n#define u_locbund_getNumberFormat U_ICU_ENTRY_POINT_RENAME(u_locbund_getNumberFormat)\n#define u_locbund_init U_ICU_ENTRY_POINT_RENAME(u_locbund_init)\n#define u_memcasecmp U_ICU_ENTRY_POINT_RENAME(u_memcasecmp)\n#define u_memchr U_ICU_ENTRY_POINT_RENAME(u_memchr)\n#define u_memchr32 U_ICU_ENTRY_POINT_RENAME(u_memchr32)\n#define u_memcmp U_ICU_ENTRY_POINT_RENAME(u_memcmp)\n#define u_memcmpCodePointOrder U_ICU_ENTRY_POINT_RENAME(u_memcmpCodePointOrder)\n#define u_memcpy U_ICU_ENTRY_POINT_RENAME(u_memcpy)\n#define u_memmove U_ICU_ENTRY_POINT_RENAME(u_memmove)\n#define u_memrchr U_ICU_ENTRY_POINT_RENAME(u_memrchr)\n#define u_memrchr32 U_ICU_ENTRY_POINT_RENAME(u_memrchr32)\n#define u_memset U_ICU_ENTRY_POINT_RENAME(u_memset)\n#define u_parseMessage U_ICU_ENTRY_POINT_RENAME(u_parseMessage)\n#define u_parseMessageWithError U_ICU_ENTRY_POINT_RENAME(u_parseMessageWithError)\n#define u_printf U_ICU_ENTRY_POINT_RENAME(u_printf)\n#define u_printf_parse U_ICU_ENTRY_POINT_RENAME(u_printf_parse)\n#define u_printf_u U_ICU_ENTRY_POINT_RENAME(u_printf_u)\n#define u_releaseDefaultConverter U_ICU_ENTRY_POINT_RENAME(u_releaseDefaultConverter)\n#define u_scanf_parse U_ICU_ENTRY_POINT_RENAME(u_scanf_parse)\n#define u_setAtomicIncDecFunctions U_ICU_ENTRY_POINT_RENAME(u_setAtomicIncDecFunctions)\n#define u_setDataDirectory U_ICU_ENTRY_POINT_RENAME(u_setDataDirectory)\n#define u_setMemoryFunctions U_ICU_ENTRY_POINT_RENAME(u_setMemoryFunctions)\n#define u_setMutexFunctions U_ICU_ENTRY_POINT_RENAME(u_setMutexFunctions)\n#define u_shapeArabic U_ICU_ENTRY_POINT_RENAME(u_shapeArabic)\n#define u_snprintf U_ICU_ENTRY_POINT_RENAME(u_snprintf)\n#define u_snprintf_u U_ICU_ENTRY_POINT_RENAME(u_snprintf_u)\n#define u_sprintf U_ICU_ENTRY_POINT_RENAME(u_sprintf)\n#define u_sprintf_u U_ICU_ENTRY_POINT_RENAME(u_sprintf_u)\n#define u_sscanf U_ICU_ENTRY_POINT_RENAME(u_sscanf)\n#define u_sscanf_u U_ICU_ENTRY_POINT_RENAME(u_sscanf_u)\n#define u_strCaseCompare U_ICU_ENTRY_POINT_RENAME(u_strCaseCompare)\n#define u_strCompare U_ICU_ENTRY_POINT_RENAME(u_strCompare)\n#define u_strCompareIter U_ICU_ENTRY_POINT_RENAME(u_strCompareIter)\n#define u_strFindFirst U_ICU_ENTRY_POINT_RENAME(u_strFindFirst)\n#define u_strFindLast U_ICU_ENTRY_POINT_RENAME(u_strFindLast)\n#define u_strFoldCase U_ICU_ENTRY_POINT_RENAME(u_strFoldCase)\n#define u_strFromJavaModifiedUTF8WithSub U_ICU_ENTRY_POINT_RENAME(u_strFromJavaModifiedUTF8WithSub)\n#define u_strFromPunycode U_ICU_ENTRY_POINT_RENAME(u_strFromPunycode)\n#define u_strFromUTF32 U_ICU_ENTRY_POINT_RENAME(u_strFromUTF32)\n#define u_strFromUTF32WithSub U_ICU_ENTRY_POINT_RENAME(u_strFromUTF32WithSub)\n#define u_strFromUTF8 U_ICU_ENTRY_POINT_RENAME(u_strFromUTF8)\n#define u_strFromUTF8Lenient U_ICU_ENTRY_POINT_RENAME(u_strFromUTF8Lenient)\n#define u_strFromUTF8WithSub U_ICU_ENTRY_POINT_RENAME(u_strFromUTF8WithSub)\n#define u_strFromWCS U_ICU_ENTRY_POINT_RENAME(u_strFromWCS)\n#define u_strHasMoreChar32Than U_ICU_ENTRY_POINT_RENAME(u_strHasMoreChar32Than)\n#define u_strToJavaModifiedUTF8 U_ICU_ENTRY_POINT_RENAME(u_strToJavaModifiedUTF8)\n#define u_strToLower U_ICU_ENTRY_POINT_RENAME(u_strToLower)\n#define u_strToPunycode U_ICU_ENTRY_POINT_RENAME(u_strToPunycode)\n#define u_strToTitle U_ICU_ENTRY_POINT_RENAME(u_strToTitle)\n#define u_strToUTF32 U_ICU_ENTRY_POINT_RENAME(u_strToUTF32)\n#define u_strToUTF32WithSub U_ICU_ENTRY_POINT_RENAME(u_strToUTF32WithSub)\n#define u_strToUTF8 U_ICU_ENTRY_POINT_RENAME(u_strToUTF8)\n#define u_strToUTF8WithSub U_ICU_ENTRY_POINT_RENAME(u_strToUTF8WithSub)\n#define u_strToUpper U_ICU_ENTRY_POINT_RENAME(u_strToUpper)\n#define u_strToWCS U_ICU_ENTRY_POINT_RENAME(u_strToWCS)\n#define u_strcasecmp U_ICU_ENTRY_POINT_RENAME(u_strcasecmp)\n#define u_strcat U_ICU_ENTRY_POINT_RENAME(u_strcat)\n#define u_strchr U_ICU_ENTRY_POINT_RENAME(u_strchr)\n#define u_strchr32 U_ICU_ENTRY_POINT_RENAME(u_strchr32)\n#define u_strcmp U_ICU_ENTRY_POINT_RENAME(u_strcmp)\n#define u_strcmpCodePointOrder U_ICU_ENTRY_POINT_RENAME(u_strcmpCodePointOrder)\n#define u_strcmpFold U_ICU_ENTRY_POINT_RENAME(u_strcmpFold)\n#define u_strcpy U_ICU_ENTRY_POINT_RENAME(u_strcpy)\n#define u_strcspn U_ICU_ENTRY_POINT_RENAME(u_strcspn)\n#define u_strlen U_ICU_ENTRY_POINT_RENAME(u_strlen)\n#define u_strncasecmp U_ICU_ENTRY_POINT_RENAME(u_strncasecmp)\n#define u_strncat U_ICU_ENTRY_POINT_RENAME(u_strncat)\n#define u_strncmp U_ICU_ENTRY_POINT_RENAME(u_strncmp)\n#define u_strncmpCodePointOrder U_ICU_ENTRY_POINT_RENAME(u_strncmpCodePointOrder)\n#define u_strncpy U_ICU_ENTRY_POINT_RENAME(u_strncpy)\n#define u_strpbrk U_ICU_ENTRY_POINT_RENAME(u_strpbrk)\n#define u_strrchr U_ICU_ENTRY_POINT_RENAME(u_strrchr)\n#define u_strrchr32 U_ICU_ENTRY_POINT_RENAME(u_strrchr32)\n#define u_strrstr U_ICU_ENTRY_POINT_RENAME(u_strrstr)\n#define u_strspn U_ICU_ENTRY_POINT_RENAME(u_strspn)\n#define u_strstr U_ICU_ENTRY_POINT_RENAME(u_strstr)\n#define u_strtok_r U_ICU_ENTRY_POINT_RENAME(u_strtok_r)\n#define u_terminateChars U_ICU_ENTRY_POINT_RENAME(u_terminateChars)\n#define u_terminateUChar32s U_ICU_ENTRY_POINT_RENAME(u_terminateUChar32s)\n#define u_terminateUChars U_ICU_ENTRY_POINT_RENAME(u_terminateUChars)\n#define u_terminateWChars U_ICU_ENTRY_POINT_RENAME(u_terminateWChars)\n#define u_tolower U_ICU_ENTRY_POINT_RENAME(u_tolower)\n#define u_totitle U_ICU_ENTRY_POINT_RENAME(u_totitle)\n#define u_toupper U_ICU_ENTRY_POINT_RENAME(u_toupper)\n#define u_uastrcpy U_ICU_ENTRY_POINT_RENAME(u_uastrcpy)\n#define u_uastrncpy U_ICU_ENTRY_POINT_RENAME(u_uastrncpy)\n#define u_unescape U_ICU_ENTRY_POINT_RENAME(u_unescape)\n#define u_unescapeAt U_ICU_ENTRY_POINT_RENAME(u_unescapeAt)\n#define u_versionFromString U_ICU_ENTRY_POINT_RENAME(u_versionFromString)\n#define u_versionFromUString U_ICU_ENTRY_POINT_RENAME(u_versionFromUString)\n#define u_versionToString U_ICU_ENTRY_POINT_RENAME(u_versionToString)\n#define u_vformatMessage U_ICU_ENTRY_POINT_RENAME(u_vformatMessage)\n#define u_vformatMessageWithError U_ICU_ENTRY_POINT_RENAME(u_vformatMessageWithError)\n#define u_vfprintf U_ICU_ENTRY_POINT_RENAME(u_vfprintf)\n#define u_vfprintf_u U_ICU_ENTRY_POINT_RENAME(u_vfprintf_u)\n#define u_vfscanf U_ICU_ENTRY_POINT_RENAME(u_vfscanf)\n#define u_vfscanf_u U_ICU_ENTRY_POINT_RENAME(u_vfscanf_u)\n#define u_vparseMessage U_ICU_ENTRY_POINT_RENAME(u_vparseMessage)\n#define u_vparseMessageWithError U_ICU_ENTRY_POINT_RENAME(u_vparseMessageWithError)\n#define u_vsnprintf U_ICU_ENTRY_POINT_RENAME(u_vsnprintf)\n#define u_vsnprintf_u U_ICU_ENTRY_POINT_RENAME(u_vsnprintf_u)\n#define u_vsprintf U_ICU_ENTRY_POINT_RENAME(u_vsprintf)\n#define u_vsprintf_u U_ICU_ENTRY_POINT_RENAME(u_vsprintf_u)\n#define u_vsscanf U_ICU_ENTRY_POINT_RENAME(u_vsscanf)\n#define u_vsscanf_u U_ICU_ENTRY_POINT_RENAME(u_vsscanf_u)\n#define u_writeDiff U_ICU_ENTRY_POINT_RENAME(u_writeDiff)\n#define u_writeIdenticalLevelRun U_ICU_ENTRY_POINT_RENAME(u_writeIdenticalLevelRun)\n#define u_writeIdenticalLevelRunTwoChars U_ICU_ENTRY_POINT_RENAME(u_writeIdenticalLevelRunTwoChars)\n#define ubidi_addPropertyStarts U_ICU_ENTRY_POINT_RENAME(ubidi_addPropertyStarts)\n#define ubidi_close U_ICU_ENTRY_POINT_RENAME(ubidi_close)\n#define ubidi_countParagraphs U_ICU_ENTRY_POINT_RENAME(ubidi_countParagraphs)\n#define ubidi_countRuns U_ICU_ENTRY_POINT_RENAME(ubidi_countRuns)\n#define ubidi_getBaseDirection U_ICU_ENTRY_POINT_RENAME(ubidi_getBaseDirection)\n#define ubidi_getClass U_ICU_ENTRY_POINT_RENAME(ubidi_getClass)\n#define ubidi_getClassCallback U_ICU_ENTRY_POINT_RENAME(ubidi_getClassCallback)\n#define ubidi_getCustomizedClass U_ICU_ENTRY_POINT_RENAME(ubidi_getCustomizedClass)\n#define ubidi_getDirection U_ICU_ENTRY_POINT_RENAME(ubidi_getDirection)\n#define ubidi_getJoiningGroup U_ICU_ENTRY_POINT_RENAME(ubidi_getJoiningGroup)\n#define ubidi_getJoiningType U_ICU_ENTRY_POINT_RENAME(ubidi_getJoiningType)\n#define ubidi_getLength U_ICU_ENTRY_POINT_RENAME(ubidi_getLength)\n#define ubidi_getLevelAt U_ICU_ENTRY_POINT_RENAME(ubidi_getLevelAt)\n#define ubidi_getLevels U_ICU_ENTRY_POINT_RENAME(ubidi_getLevels)\n#define ubidi_getLogicalIndex U_ICU_ENTRY_POINT_RENAME(ubidi_getLogicalIndex)\n#define ubidi_getLogicalMap U_ICU_ENTRY_POINT_RENAME(ubidi_getLogicalMap)\n#define ubidi_getLogicalRun U_ICU_ENTRY_POINT_RENAME(ubidi_getLogicalRun)\n#define ubidi_getMaxValue U_ICU_ENTRY_POINT_RENAME(ubidi_getMaxValue)\n#define ubidi_getMemory U_ICU_ENTRY_POINT_RENAME(ubidi_getMemory)\n#define ubidi_getMirror U_ICU_ENTRY_POINT_RENAME(ubidi_getMirror)\n#define ubidi_getParaLevel U_ICU_ENTRY_POINT_RENAME(ubidi_getParaLevel)\n#define ubidi_getParagraph U_ICU_ENTRY_POINT_RENAME(ubidi_getParagraph)\n#define ubidi_getParagraphByIndex U_ICU_ENTRY_POINT_RENAME(ubidi_getParagraphByIndex)\n#define ubidi_getProcessedLength U_ICU_ENTRY_POINT_RENAME(ubidi_getProcessedLength)\n#define ubidi_getReorderingMode U_ICU_ENTRY_POINT_RENAME(ubidi_getReorderingMode)\n#define ubidi_getReorderingOptions U_ICU_ENTRY_POINT_RENAME(ubidi_getReorderingOptions)\n#define ubidi_getResultLength U_ICU_ENTRY_POINT_RENAME(ubidi_getResultLength)\n#define ubidi_getRuns U_ICU_ENTRY_POINT_RENAME(ubidi_getRuns)\n#define ubidi_getSingleton U_ICU_ENTRY_POINT_RENAME(ubidi_getSingleton)\n#define ubidi_getText U_ICU_ENTRY_POINT_RENAME(ubidi_getText)\n#define ubidi_getVisualIndex U_ICU_ENTRY_POINT_RENAME(ubidi_getVisualIndex)\n#define ubidi_getVisualMap U_ICU_ENTRY_POINT_RENAME(ubidi_getVisualMap)\n#define ubidi_getVisualRun U_ICU_ENTRY_POINT_RENAME(ubidi_getVisualRun)\n#define ubidi_invertMap U_ICU_ENTRY_POINT_RENAME(ubidi_invertMap)\n#define ubidi_isBidiControl U_ICU_ENTRY_POINT_RENAME(ubidi_isBidiControl)\n#define ubidi_isInverse U_ICU_ENTRY_POINT_RENAME(ubidi_isInverse)\n#define ubidi_isJoinControl U_ICU_ENTRY_POINT_RENAME(ubidi_isJoinControl)\n#define ubidi_isMirrored U_ICU_ENTRY_POINT_RENAME(ubidi_isMirrored)\n#define ubidi_isOrderParagraphsLTR U_ICU_ENTRY_POINT_RENAME(ubidi_isOrderParagraphsLTR)\n#define ubidi_open U_ICU_ENTRY_POINT_RENAME(ubidi_open)\n#define ubidi_openSized U_ICU_ENTRY_POINT_RENAME(ubidi_openSized)\n#define ubidi_orderParagraphsLTR U_ICU_ENTRY_POINT_RENAME(ubidi_orderParagraphsLTR)\n#define ubidi_reorderLogical U_ICU_ENTRY_POINT_RENAME(ubidi_reorderLogical)\n#define ubidi_reorderVisual U_ICU_ENTRY_POINT_RENAME(ubidi_reorderVisual)\n#define ubidi_setClassCallback U_ICU_ENTRY_POINT_RENAME(ubidi_setClassCallback)\n#define ubidi_setContext U_ICU_ENTRY_POINT_RENAME(ubidi_setContext)\n#define ubidi_setInverse U_ICU_ENTRY_POINT_RENAME(ubidi_setInverse)\n#define ubidi_setLine U_ICU_ENTRY_POINT_RENAME(ubidi_setLine)\n#define ubidi_setPara U_ICU_ENTRY_POINT_RENAME(ubidi_setPara)\n#define ubidi_setReorderingMode U_ICU_ENTRY_POINT_RENAME(ubidi_setReorderingMode)\n#define ubidi_setReorderingOptions U_ICU_ENTRY_POINT_RENAME(ubidi_setReorderingOptions)\n#define ubidi_writeReordered U_ICU_ENTRY_POINT_RENAME(ubidi_writeReordered)\n#define ubidi_writeReverse U_ICU_ENTRY_POINT_RENAME(ubidi_writeReverse)\n#define ublock_getCode U_ICU_ENTRY_POINT_RENAME(ublock_getCode)\n#define ubrk_close U_ICU_ENTRY_POINT_RENAME(ubrk_close)\n#define ubrk_countAvailable U_ICU_ENTRY_POINT_RENAME(ubrk_countAvailable)\n#define ubrk_current U_ICU_ENTRY_POINT_RENAME(ubrk_current)\n#define ubrk_first U_ICU_ENTRY_POINT_RENAME(ubrk_first)\n#define ubrk_following U_ICU_ENTRY_POINT_RENAME(ubrk_following)\n#define ubrk_getAvailable U_ICU_ENTRY_POINT_RENAME(ubrk_getAvailable)\n#define ubrk_getLocaleByType U_ICU_ENTRY_POINT_RENAME(ubrk_getLocaleByType)\n#define ubrk_getRuleStatus U_ICU_ENTRY_POINT_RENAME(ubrk_getRuleStatus)\n#define ubrk_getRuleStatusVec U_ICU_ENTRY_POINT_RENAME(ubrk_getRuleStatusVec)\n#define ubrk_isBoundary U_ICU_ENTRY_POINT_RENAME(ubrk_isBoundary)\n#define ubrk_last U_ICU_ENTRY_POINT_RENAME(ubrk_last)\n#define ubrk_next U_ICU_ENTRY_POINT_RENAME(ubrk_next)\n#define ubrk_open U_ICU_ENTRY_POINT_RENAME(ubrk_open)\n#define ubrk_openRules U_ICU_ENTRY_POINT_RENAME(ubrk_openRules)\n#define ubrk_preceding U_ICU_ENTRY_POINT_RENAME(ubrk_preceding)\n#define ubrk_previous U_ICU_ENTRY_POINT_RENAME(ubrk_previous)\n#define ubrk_refreshUText U_ICU_ENTRY_POINT_RENAME(ubrk_refreshUText)\n#define ubrk_safeClone U_ICU_ENTRY_POINT_RENAME(ubrk_safeClone)\n#define ubrk_setText U_ICU_ENTRY_POINT_RENAME(ubrk_setText)\n#define ubrk_setUText U_ICU_ENTRY_POINT_RENAME(ubrk_setUText)\n#define ubrk_swap U_ICU_ENTRY_POINT_RENAME(ubrk_swap)\n#define ucal_add U_ICU_ENTRY_POINT_RENAME(ucal_add)\n#define ucal_clear U_ICU_ENTRY_POINT_RENAME(ucal_clear)\n#define ucal_clearField U_ICU_ENTRY_POINT_RENAME(ucal_clearField)\n#define ucal_clone U_ICU_ENTRY_POINT_RENAME(ucal_clone)\n#define ucal_close U_ICU_ENTRY_POINT_RENAME(ucal_close)\n#define ucal_countAvailable U_ICU_ENTRY_POINT_RENAME(ucal_countAvailable)\n#define ucal_equivalentTo U_ICU_ENTRY_POINT_RENAME(ucal_equivalentTo)\n#define ucal_get U_ICU_ENTRY_POINT_RENAME(ucal_get)\n#define ucal_getAttribute U_ICU_ENTRY_POINT_RENAME(ucal_getAttribute)\n#define ucal_getAvailable U_ICU_ENTRY_POINT_RENAME(ucal_getAvailable)\n#define ucal_getCanonicalTimeZoneID U_ICU_ENTRY_POINT_RENAME(ucal_getCanonicalTimeZoneID)\n#define ucal_getDSTSavings U_ICU_ENTRY_POINT_RENAME(ucal_getDSTSavings)\n#define ucal_getDayOfWeekType U_ICU_ENTRY_POINT_RENAME(ucal_getDayOfWeekType)\n#define ucal_getDefaultTimeZone U_ICU_ENTRY_POINT_RENAME(ucal_getDefaultTimeZone)\n#define ucal_getFieldDifference U_ICU_ENTRY_POINT_RENAME(ucal_getFieldDifference)\n#define ucal_getGregorianChange U_ICU_ENTRY_POINT_RENAME(ucal_getGregorianChange)\n#define ucal_getKeywordValuesForLocale U_ICU_ENTRY_POINT_RENAME(ucal_getKeywordValuesForLocale)\n#define ucal_getLimit U_ICU_ENTRY_POINT_RENAME(ucal_getLimit)\n#define ucal_getLocaleByType U_ICU_ENTRY_POINT_RENAME(ucal_getLocaleByType)\n#define ucal_getMillis U_ICU_ENTRY_POINT_RENAME(ucal_getMillis)\n#define ucal_getNow U_ICU_ENTRY_POINT_RENAME(ucal_getNow)\n#define ucal_getTZDataVersion U_ICU_ENTRY_POINT_RENAME(ucal_getTZDataVersion)\n#define ucal_getTimeZoneDisplayName U_ICU_ENTRY_POINT_RENAME(ucal_getTimeZoneDisplayName)\n#define ucal_getTimeZoneTransitionDate U_ICU_ENTRY_POINT_RENAME(ucal_getTimeZoneTransitionDate)\n#define ucal_getType U_ICU_ENTRY_POINT_RENAME(ucal_getType)\n#define ucal_getWeekendTransition U_ICU_ENTRY_POINT_RENAME(ucal_getWeekendTransition)\n#define ucal_inDaylightTime U_ICU_ENTRY_POINT_RENAME(ucal_inDaylightTime)\n#define ucal_isSet U_ICU_ENTRY_POINT_RENAME(ucal_isSet)\n#define ucal_isWeekend U_ICU_ENTRY_POINT_RENAME(ucal_isWeekend)\n#define ucal_open U_ICU_ENTRY_POINT_RENAME(ucal_open)\n#define ucal_openCountryTimeZones U_ICU_ENTRY_POINT_RENAME(ucal_openCountryTimeZones)\n#define ucal_openTimeZoneIDEnumeration U_ICU_ENTRY_POINT_RENAME(ucal_openTimeZoneIDEnumeration)\n#define ucal_openTimeZones U_ICU_ENTRY_POINT_RENAME(ucal_openTimeZones)\n#define ucal_roll U_ICU_ENTRY_POINT_RENAME(ucal_roll)\n#define ucal_set U_ICU_ENTRY_POINT_RENAME(ucal_set)\n#define ucal_setAttribute U_ICU_ENTRY_POINT_RENAME(ucal_setAttribute)\n#define ucal_setDate U_ICU_ENTRY_POINT_RENAME(ucal_setDate)\n#define ucal_setDateTime U_ICU_ENTRY_POINT_RENAME(ucal_setDateTime)\n#define ucal_setDefaultTimeZone U_ICU_ENTRY_POINT_RENAME(ucal_setDefaultTimeZone)\n#define ucal_setGregorianChange U_ICU_ENTRY_POINT_RENAME(ucal_setGregorianChange)\n#define ucal_setMillis U_ICU_ENTRY_POINT_RENAME(ucal_setMillis)\n#define ucal_setTimeZone U_ICU_ENTRY_POINT_RENAME(ucal_setTimeZone)\n#define ucase_addCaseClosure U_ICU_ENTRY_POINT_RENAME(ucase_addCaseClosure)\n#define ucase_addPropertyStarts U_ICU_ENTRY_POINT_RENAME(ucase_addPropertyStarts)\n#define ucase_addStringCaseClosure U_ICU_ENTRY_POINT_RENAME(ucase_addStringCaseClosure)\n#define ucase_fold U_ICU_ENTRY_POINT_RENAME(ucase_fold)\n#define ucase_getCaseLocale U_ICU_ENTRY_POINT_RENAME(ucase_getCaseLocale)\n#define ucase_getSingleton U_ICU_ENTRY_POINT_RENAME(ucase_getSingleton)\n#define ucase_getType U_ICU_ENTRY_POINT_RENAME(ucase_getType)\n#define ucase_getTypeOrIgnorable U_ICU_ENTRY_POINT_RENAME(ucase_getTypeOrIgnorable)\n#define ucase_hasBinaryProperty U_ICU_ENTRY_POINT_RENAME(ucase_hasBinaryProperty)\n#define ucase_isCaseSensitive U_ICU_ENTRY_POINT_RENAME(ucase_isCaseSensitive)\n#define ucase_isSoftDotted U_ICU_ENTRY_POINT_RENAME(ucase_isSoftDotted)\n#define ucase_toFullFolding U_ICU_ENTRY_POINT_RENAME(ucase_toFullFolding)\n#define ucase_toFullLower U_ICU_ENTRY_POINT_RENAME(ucase_toFullLower)\n#define ucase_toFullTitle U_ICU_ENTRY_POINT_RENAME(ucase_toFullTitle)\n#define ucase_toFullUpper U_ICU_ENTRY_POINT_RENAME(ucase_toFullUpper)\n#define ucase_tolower U_ICU_ENTRY_POINT_RENAME(ucase_tolower)\n#define ucase_totitle U_ICU_ENTRY_POINT_RENAME(ucase_totitle)\n#define ucase_toupper U_ICU_ENTRY_POINT_RENAME(ucase_toupper)\n#define ucasemap_close U_ICU_ENTRY_POINT_RENAME(ucasemap_close)\n#define ucasemap_getBreakIterator U_ICU_ENTRY_POINT_RENAME(ucasemap_getBreakIterator)\n#define ucasemap_getLocale U_ICU_ENTRY_POINT_RENAME(ucasemap_getLocale)\n#define ucasemap_getOptions U_ICU_ENTRY_POINT_RENAME(ucasemap_getOptions)\n#define ucasemap_internalUTF8ToTitle U_ICU_ENTRY_POINT_RENAME(ucasemap_internalUTF8ToTitle)\n#define ucasemap_mapUTF8 U_ICU_ENTRY_POINT_RENAME(ucasemap_mapUTF8)\n#define ucasemap_open U_ICU_ENTRY_POINT_RENAME(ucasemap_open)\n#define ucasemap_setBreakIterator U_ICU_ENTRY_POINT_RENAME(ucasemap_setBreakIterator)\n#define ucasemap_setLocale U_ICU_ENTRY_POINT_RENAME(ucasemap_setLocale)\n#define ucasemap_setOptions U_ICU_ENTRY_POINT_RENAME(ucasemap_setOptions)\n#define ucasemap_toTitle U_ICU_ENTRY_POINT_RENAME(ucasemap_toTitle)\n#define ucasemap_utf8FoldCase U_ICU_ENTRY_POINT_RENAME(ucasemap_utf8FoldCase)\n#define ucasemap_utf8ToLower U_ICU_ENTRY_POINT_RENAME(ucasemap_utf8ToLower)\n#define ucasemap_utf8ToTitle U_ICU_ENTRY_POINT_RENAME(ucasemap_utf8ToTitle)\n#define ucasemap_utf8ToUpper U_ICU_ENTRY_POINT_RENAME(ucasemap_utf8ToUpper)\n#define ucd_close U_ICU_ENTRY_POINT_RENAME(ucd_close)\n#define ucd_flushCache U_ICU_ENTRY_POINT_RENAME(ucd_flushCache)\n#define ucd_freeCache U_ICU_ENTRY_POINT_RENAME(ucd_freeCache)\n#define ucd_getCollator U_ICU_ENTRY_POINT_RENAME(ucd_getCollator)\n#define ucd_open U_ICU_ENTRY_POINT_RENAME(ucd_open)\n#define uchar_addPropertyStarts U_ICU_ENTRY_POINT_RENAME(uchar_addPropertyStarts)\n#define uchar_swapNames U_ICU_ENTRY_POINT_RENAME(uchar_swapNames)\n#define ucln_cleanupOne U_ICU_ENTRY_POINT_RENAME(ucln_cleanupOne)\n#define ucln_common_registerCleanup U_ICU_ENTRY_POINT_RENAME(ucln_common_registerCleanup)\n#define ucln_i18n_registerCleanup U_ICU_ENTRY_POINT_RENAME(ucln_i18n_registerCleanup)\n#define ucln_io_registerCleanup U_ICU_ENTRY_POINT_RENAME(ucln_io_registerCleanup)\n#define ucln_lib_cleanup U_ICU_ENTRY_POINT_RENAME(ucln_lib_cleanup)\n#define ucln_mutexedInit U_ICU_ENTRY_POINT_RENAME(ucln_mutexedInit)\n#define ucln_registerCleanup U_ICU_ENTRY_POINT_RENAME(ucln_registerCleanup)\n#define ucnv_MBCSFromUChar32 U_ICU_ENTRY_POINT_RENAME(ucnv_MBCSFromUChar32)\n#define ucnv_MBCSFromUnicodeWithOffsets U_ICU_ENTRY_POINT_RENAME(ucnv_MBCSFromUnicodeWithOffsets)\n#define ucnv_MBCSGetFilteredUnicodeSetForUnicode U_ICU_ENTRY_POINT_RENAME(ucnv_MBCSGetFilteredUnicodeSetForUnicode)\n#define ucnv_MBCSGetType U_ICU_ENTRY_POINT_RENAME(ucnv_MBCSGetType)\n#define ucnv_MBCSGetUnicodeSetForUnicode U_ICU_ENTRY_POINT_RENAME(ucnv_MBCSGetUnicodeSetForUnicode)\n#define ucnv_MBCSIsLeadByte U_ICU_ENTRY_POINT_RENAME(ucnv_MBCSIsLeadByte)\n#define ucnv_MBCSSimpleGetNextUChar U_ICU_ENTRY_POINT_RENAME(ucnv_MBCSSimpleGetNextUChar)\n#define ucnv_MBCSToUnicodeWithOffsets U_ICU_ENTRY_POINT_RENAME(ucnv_MBCSToUnicodeWithOffsets)\n#define ucnv_bld_countAvailableConverters U_ICU_ENTRY_POINT_RENAME(ucnv_bld_countAvailableConverters)\n#define ucnv_bld_getAvailableConverter U_ICU_ENTRY_POINT_RENAME(ucnv_bld_getAvailableConverter)\n#define ucnv_canCreateConverter U_ICU_ENTRY_POINT_RENAME(ucnv_canCreateConverter)\n#define ucnv_cbFromUWriteBytes U_ICU_ENTRY_POINT_RENAME(ucnv_cbFromUWriteBytes)\n#define ucnv_cbFromUWriteSub U_ICU_ENTRY_POINT_RENAME(ucnv_cbFromUWriteSub)\n#define ucnv_cbFromUWriteUChars U_ICU_ENTRY_POINT_RENAME(ucnv_cbFromUWriteUChars)\n#define ucnv_cbToUWriteSub U_ICU_ENTRY_POINT_RENAME(ucnv_cbToUWriteSub)\n#define ucnv_cbToUWriteUChars U_ICU_ENTRY_POINT_RENAME(ucnv_cbToUWriteUChars)\n#define ucnv_close U_ICU_ENTRY_POINT_RENAME(ucnv_close)\n#define ucnv_compareNames U_ICU_ENTRY_POINT_RENAME(ucnv_compareNames)\n#define ucnv_convert U_ICU_ENTRY_POINT_RENAME(ucnv_convert)\n#define ucnv_convertEx U_ICU_ENTRY_POINT_RENAME(ucnv_convertEx)\n#define ucnv_countAliases U_ICU_ENTRY_POINT_RENAME(ucnv_countAliases)\n#define ucnv_countAvailable U_ICU_ENTRY_POINT_RENAME(ucnv_countAvailable)\n#define ucnv_countStandards U_ICU_ENTRY_POINT_RENAME(ucnv_countStandards)\n#define ucnv_createAlgorithmicConverter U_ICU_ENTRY_POINT_RENAME(ucnv_createAlgorithmicConverter)\n#define ucnv_createConverter U_ICU_ENTRY_POINT_RENAME(ucnv_createConverter)\n#define ucnv_createConverterFromPackage U_ICU_ENTRY_POINT_RENAME(ucnv_createConverterFromPackage)\n#define ucnv_createConverterFromSharedData U_ICU_ENTRY_POINT_RENAME(ucnv_createConverterFromSharedData)\n#define ucnv_detectUnicodeSignature U_ICU_ENTRY_POINT_RENAME(ucnv_detectUnicodeSignature)\n#define ucnv_extContinueMatchFromU U_ICU_ENTRY_POINT_RENAME(ucnv_extContinueMatchFromU)\n#define ucnv_extContinueMatchToU U_ICU_ENTRY_POINT_RENAME(ucnv_extContinueMatchToU)\n#define ucnv_extGetUnicodeSet U_ICU_ENTRY_POINT_RENAME(ucnv_extGetUnicodeSet)\n#define ucnv_extInitialMatchFromU U_ICU_ENTRY_POINT_RENAME(ucnv_extInitialMatchFromU)\n#define ucnv_extInitialMatchToU U_ICU_ENTRY_POINT_RENAME(ucnv_extInitialMatchToU)\n#define ucnv_extSimpleMatchFromU U_ICU_ENTRY_POINT_RENAME(ucnv_extSimpleMatchFromU)\n#define ucnv_extSimpleMatchToU U_ICU_ENTRY_POINT_RENAME(ucnv_extSimpleMatchToU)\n#define ucnv_fixFileSeparator U_ICU_ENTRY_POINT_RENAME(ucnv_fixFileSeparator)\n#define ucnv_flushCache U_ICU_ENTRY_POINT_RENAME(ucnv_flushCache)\n#define ucnv_fromAlgorithmic U_ICU_ENTRY_POINT_RENAME(ucnv_fromAlgorithmic)\n#define ucnv_fromUChars U_ICU_ENTRY_POINT_RENAME(ucnv_fromUChars)\n#define ucnv_fromUCountPending U_ICU_ENTRY_POINT_RENAME(ucnv_fromUCountPending)\n#define ucnv_fromUWriteBytes U_ICU_ENTRY_POINT_RENAME(ucnv_fromUWriteBytes)\n#define ucnv_fromUnicode U_ICU_ENTRY_POINT_RENAME(ucnv_fromUnicode)\n#define ucnv_fromUnicode_UTF8 U_ICU_ENTRY_POINT_RENAME(ucnv_fromUnicode_UTF8)\n#define ucnv_fromUnicode_UTF8_OFFSETS_LOGIC U_ICU_ENTRY_POINT_RENAME(ucnv_fromUnicode_UTF8_OFFSETS_LOGIC)\n#define ucnv_getAlias U_ICU_ENTRY_POINT_RENAME(ucnv_getAlias)\n#define ucnv_getAliases U_ICU_ENTRY_POINT_RENAME(ucnv_getAliases)\n#define ucnv_getAvailableName U_ICU_ENTRY_POINT_RENAME(ucnv_getAvailableName)\n#define ucnv_getCCSID U_ICU_ENTRY_POINT_RENAME(ucnv_getCCSID)\n#define ucnv_getCanonicalName U_ICU_ENTRY_POINT_RENAME(ucnv_getCanonicalName)\n#define ucnv_getCompleteUnicodeSet U_ICU_ENTRY_POINT_RENAME(ucnv_getCompleteUnicodeSet)\n#define ucnv_getDefaultName U_ICU_ENTRY_POINT_RENAME(ucnv_getDefaultName)\n#define ucnv_getDisplayName U_ICU_ENTRY_POINT_RENAME(ucnv_getDisplayName)\n#define ucnv_getFromUCallBack U_ICU_ENTRY_POINT_RENAME(ucnv_getFromUCallBack)\n#define ucnv_getInvalidChars U_ICU_ENTRY_POINT_RENAME(ucnv_getInvalidChars)\n#define ucnv_getInvalidUChars U_ICU_ENTRY_POINT_RENAME(ucnv_getInvalidUChars)\n#define ucnv_getMaxCharSize U_ICU_ENTRY_POINT_RENAME(ucnv_getMaxCharSize)\n#define ucnv_getMinCharSize U_ICU_ENTRY_POINT_RENAME(ucnv_getMinCharSize)\n#define ucnv_getName U_ICU_ENTRY_POINT_RENAME(ucnv_getName)\n#define ucnv_getNextUChar U_ICU_ENTRY_POINT_RENAME(ucnv_getNextUChar)\n#define ucnv_getNonSurrogateUnicodeSet U_ICU_ENTRY_POINT_RENAME(ucnv_getNonSurrogateUnicodeSet)\n#define ucnv_getPlatform U_ICU_ENTRY_POINT_RENAME(ucnv_getPlatform)\n#define ucnv_getStandard U_ICU_ENTRY_POINT_RENAME(ucnv_getStandard)\n#define ucnv_getStandardName U_ICU_ENTRY_POINT_RENAME(ucnv_getStandardName)\n#define ucnv_getStarters U_ICU_ENTRY_POINT_RENAME(ucnv_getStarters)\n#define ucnv_getSubstChars U_ICU_ENTRY_POINT_RENAME(ucnv_getSubstChars)\n#define ucnv_getToUCallBack U_ICU_ENTRY_POINT_RENAME(ucnv_getToUCallBack)\n#define ucnv_getType U_ICU_ENTRY_POINT_RENAME(ucnv_getType)\n#define ucnv_getUnicodeSet U_ICU_ENTRY_POINT_RENAME(ucnv_getUnicodeSet)\n#define ucnv_incrementRefCount U_ICU_ENTRY_POINT_RENAME(ucnv_incrementRefCount)\n#define ucnv_io_countKnownConverters U_ICU_ENTRY_POINT_RENAME(ucnv_io_countKnownConverters)\n#define ucnv_io_getConverterName U_ICU_ENTRY_POINT_RENAME(ucnv_io_getConverterName)\n#define ucnv_io_stripASCIIForCompare U_ICU_ENTRY_POINT_RENAME(ucnv_io_stripASCIIForCompare)\n#define ucnv_io_stripEBCDICForCompare U_ICU_ENTRY_POINT_RENAME(ucnv_io_stripEBCDICForCompare)\n#define ucnv_isAmbiguous U_ICU_ENTRY_POINT_RENAME(ucnv_isAmbiguous)\n#define ucnv_isFixedWidth U_ICU_ENTRY_POINT_RENAME(ucnv_isFixedWidth)\n#define ucnv_load U_ICU_ENTRY_POINT_RENAME(ucnv_load)\n#define ucnv_loadSharedData U_ICU_ENTRY_POINT_RENAME(ucnv_loadSharedData)\n#define ucnv_open U_ICU_ENTRY_POINT_RENAME(ucnv_open)\n#define ucnv_openAllNames U_ICU_ENTRY_POINT_RENAME(ucnv_openAllNames)\n#define ucnv_openCCSID U_ICU_ENTRY_POINT_RENAME(ucnv_openCCSID)\n#define ucnv_openPackage U_ICU_ENTRY_POINT_RENAME(ucnv_openPackage)\n#define ucnv_openStandardNames U_ICU_ENTRY_POINT_RENAME(ucnv_openStandardNames)\n#define ucnv_openU U_ICU_ENTRY_POINT_RENAME(ucnv_openU)\n#define ucnv_reset U_ICU_ENTRY_POINT_RENAME(ucnv_reset)\n#define ucnv_resetFromUnicode U_ICU_ENTRY_POINT_RENAME(ucnv_resetFromUnicode)\n#define ucnv_resetToUnicode U_ICU_ENTRY_POINT_RENAME(ucnv_resetToUnicode)\n#define ucnv_safeClone U_ICU_ENTRY_POINT_RENAME(ucnv_safeClone)\n#define ucnv_setDefaultName U_ICU_ENTRY_POINT_RENAME(ucnv_setDefaultName)\n#define ucnv_setFallback U_ICU_ENTRY_POINT_RENAME(ucnv_setFallback)\n#define ucnv_setFromUCallBack U_ICU_ENTRY_POINT_RENAME(ucnv_setFromUCallBack)\n#define ucnv_setSubstChars U_ICU_ENTRY_POINT_RENAME(ucnv_setSubstChars)\n#define ucnv_setSubstString U_ICU_ENTRY_POINT_RENAME(ucnv_setSubstString)\n#define ucnv_setToUCallBack U_ICU_ENTRY_POINT_RENAME(ucnv_setToUCallBack)\n#define ucnv_swap U_ICU_ENTRY_POINT_RENAME(ucnv_swap)\n#define ucnv_swapAliases U_ICU_ENTRY_POINT_RENAME(ucnv_swapAliases)\n#define ucnv_toAlgorithmic U_ICU_ENTRY_POINT_RENAME(ucnv_toAlgorithmic)\n#define ucnv_toUChars U_ICU_ENTRY_POINT_RENAME(ucnv_toUChars)\n#define ucnv_toUCountPending U_ICU_ENTRY_POINT_RENAME(ucnv_toUCountPending)\n#define ucnv_toUWriteCodePoint U_ICU_ENTRY_POINT_RENAME(ucnv_toUWriteCodePoint)\n#define ucnv_toUWriteUChars U_ICU_ENTRY_POINT_RENAME(ucnv_toUWriteUChars)\n#define ucnv_toUnicode U_ICU_ENTRY_POINT_RENAME(ucnv_toUnicode)\n#define ucnv_unload U_ICU_ENTRY_POINT_RENAME(ucnv_unload)\n#define ucnv_unloadSharedDataIfReady U_ICU_ENTRY_POINT_RENAME(ucnv_unloadSharedDataIfReady)\n#define ucnv_usesFallback U_ICU_ENTRY_POINT_RENAME(ucnv_usesFallback)\n#define ucnvsel_close U_ICU_ENTRY_POINT_RENAME(ucnvsel_close)\n#define ucnvsel_open U_ICU_ENTRY_POINT_RENAME(ucnvsel_open)\n#define ucnvsel_openFromSerialized U_ICU_ENTRY_POINT_RENAME(ucnvsel_openFromSerialized)\n#define ucnvsel_selectForString U_ICU_ENTRY_POINT_RENAME(ucnvsel_selectForString)\n#define ucnvsel_selectForUTF8 U_ICU_ENTRY_POINT_RENAME(ucnvsel_selectForUTF8)\n#define ucnvsel_serialize U_ICU_ENTRY_POINT_RENAME(ucnvsel_serialize)\n#define ucol_allocWeights U_ICU_ENTRY_POINT_RENAME(ucol_allocWeights)\n#define ucol_assembleTailoringTable U_ICU_ENTRY_POINT_RENAME(ucol_assembleTailoringTable)\n#define ucol_buildPermutationTable U_ICU_ENTRY_POINT_RENAME(ucol_buildPermutationTable)\n#define ucol_calcSortKey U_ICU_ENTRY_POINT_RENAME(ucol_calcSortKey)\n#define ucol_calcSortKeySimpleTertiary U_ICU_ENTRY_POINT_RENAME(ucol_calcSortKeySimpleTertiary)\n#define ucol_cloneBinary U_ICU_ENTRY_POINT_RENAME(ucol_cloneBinary)\n#define ucol_cloneRuleData U_ICU_ENTRY_POINT_RENAME(ucol_cloneRuleData)\n#define ucol_close U_ICU_ENTRY_POINT_RENAME(ucol_close)\n#define ucol_closeElements U_ICU_ENTRY_POINT_RENAME(ucol_closeElements)\n#define ucol_countAvailable U_ICU_ENTRY_POINT_RENAME(ucol_countAvailable)\n#define ucol_createElements U_ICU_ENTRY_POINT_RENAME(ucol_createElements)\n#define ucol_doCE U_ICU_ENTRY_POINT_RENAME(ucol_doCE)\n#define ucol_equal U_ICU_ENTRY_POINT_RENAME(ucol_equal)\n#define ucol_equals U_ICU_ENTRY_POINT_RENAME(ucol_equals)\n#define ucol_findReorderingEntry U_ICU_ENTRY_POINT_RENAME(ucol_findReorderingEntry)\n#define ucol_forceHanImplicit U_ICU_ENTRY_POINT_RENAME(ucol_forceHanImplicit)\n#define ucol_forgetUCA U_ICU_ENTRY_POINT_RENAME(ucol_forgetUCA)\n#define ucol_freeOffsetBuffer U_ICU_ENTRY_POINT_RENAME(ucol_freeOffsetBuffer)\n#define ucol_getAttribute U_ICU_ENTRY_POINT_RENAME(ucol_getAttribute)\n#define ucol_getAttributeOrDefault U_ICU_ENTRY_POINT_RENAME(ucol_getAttributeOrDefault)\n#define ucol_getAvailable U_ICU_ENTRY_POINT_RENAME(ucol_getAvailable)\n#define ucol_getBound U_ICU_ENTRY_POINT_RENAME(ucol_getBound)\n#define ucol_getCEStrengthDifference U_ICU_ENTRY_POINT_RENAME(ucol_getCEStrengthDifference)\n#define ucol_getCollationKey U_ICU_ENTRY_POINT_RENAME(ucol_getCollationKey)\n#define ucol_getContractions U_ICU_ENTRY_POINT_RENAME(ucol_getContractions)\n#define ucol_getContractionsAndExpansions U_ICU_ENTRY_POINT_RENAME(ucol_getContractionsAndExpansions)\n#define ucol_getDisplayName U_ICU_ENTRY_POINT_RENAME(ucol_getDisplayName)\n#define ucol_getEquivalentReorderCodes U_ICU_ENTRY_POINT_RENAME(ucol_getEquivalentReorderCodes)\n#define ucol_getFirstCE U_ICU_ENTRY_POINT_RENAME(ucol_getFirstCE)\n#define ucol_getFunctionalEquivalent U_ICU_ENTRY_POINT_RENAME(ucol_getFunctionalEquivalent)\n#define ucol_getKeywordValues U_ICU_ENTRY_POINT_RENAME(ucol_getKeywordValues)\n#define ucol_getKeywordValuesForLocale U_ICU_ENTRY_POINT_RENAME(ucol_getKeywordValuesForLocale)\n#define ucol_getKeywords U_ICU_ENTRY_POINT_RENAME(ucol_getKeywords)\n#define ucol_getLeadBytesForReorderCode U_ICU_ENTRY_POINT_RENAME(ucol_getLeadBytesForReorderCode)\n#define ucol_getLocale U_ICU_ENTRY_POINT_RENAME(ucol_getLocale)\n#define ucol_getLocaleByType U_ICU_ENTRY_POINT_RENAME(ucol_getLocaleByType)\n#define ucol_getMaxExpansion U_ICU_ENTRY_POINT_RENAME(ucol_getMaxExpansion)\n#define ucol_getNextCE U_ICU_ENTRY_POINT_RENAME(ucol_getNextCE)\n#define ucol_getOffset U_ICU_ENTRY_POINT_RENAME(ucol_getOffset)\n#define ucol_getPrevCE U_ICU_ENTRY_POINT_RENAME(ucol_getPrevCE)\n#define ucol_getReorderCodes U_ICU_ENTRY_POINT_RENAME(ucol_getReorderCodes)\n#define ucol_getReorderCodesForLeadByte U_ICU_ENTRY_POINT_RENAME(ucol_getReorderCodesForLeadByte)\n#define ucol_getRules U_ICU_ENTRY_POINT_RENAME(ucol_getRules)\n#define ucol_getRulesEx U_ICU_ENTRY_POINT_RENAME(ucol_getRulesEx)\n#define ucol_getShortDefinitionString U_ICU_ENTRY_POINT_RENAME(ucol_getShortDefinitionString)\n#define ucol_getSortKey U_ICU_ENTRY_POINT_RENAME(ucol_getSortKey)\n#define ucol_getStrength U_ICU_ENTRY_POINT_RENAME(ucol_getStrength)\n#define ucol_getTailoredSet U_ICU_ENTRY_POINT_RENAME(ucol_getTailoredSet)\n#define ucol_getUCAVersion U_ICU_ENTRY_POINT_RENAME(ucol_getUCAVersion)\n#define ucol_getUnsafeSet U_ICU_ENTRY_POINT_RENAME(ucol_getUnsafeSet)\n#define ucol_getVariableTop U_ICU_ENTRY_POINT_RENAME(ucol_getVariableTop)\n#define ucol_getVersion U_ICU_ENTRY_POINT_RENAME(ucol_getVersion)\n#define ucol_greater U_ICU_ENTRY_POINT_RENAME(ucol_greater)\n#define ucol_greaterOrEqual U_ICU_ENTRY_POINT_RENAME(ucol_greaterOrEqual)\n#define ucol_initBuffers U_ICU_ENTRY_POINT_RENAME(ucol_initBuffers)\n#define ucol_initCollator U_ICU_ENTRY_POINT_RENAME(ucol_initCollator)\n#define ucol_initInverseUCA U_ICU_ENTRY_POINT_RENAME(ucol_initInverseUCA)\n#define ucol_initUCA U_ICU_ENTRY_POINT_RENAME(ucol_initUCA)\n#define ucol_inv_getNextCE U_ICU_ENTRY_POINT_RENAME(ucol_inv_getNextCE)\n#define ucol_inv_getPrevCE U_ICU_ENTRY_POINT_RENAME(ucol_inv_getPrevCE)\n#define ucol_isTailored U_ICU_ENTRY_POINT_RENAME(ucol_isTailored)\n#define ucol_keyHashCode U_ICU_ENTRY_POINT_RENAME(ucol_keyHashCode)\n#define ucol_looksLikeCollationBinary U_ICU_ENTRY_POINT_RENAME(ucol_looksLikeCollationBinary)\n#define ucol_mergeSortkeys U_ICU_ENTRY_POINT_RENAME(ucol_mergeSortkeys)\n#define ucol_next U_ICU_ENTRY_POINT_RENAME(ucol_next)\n#define ucol_nextProcessed U_ICU_ENTRY_POINT_RENAME(ucol_nextProcessed)\n#define ucol_nextSortKeyPart U_ICU_ENTRY_POINT_RENAME(ucol_nextSortKeyPart)\n#define ucol_nextWeight U_ICU_ENTRY_POINT_RENAME(ucol_nextWeight)\n#define ucol_normalizeShortDefinitionString U_ICU_ENTRY_POINT_RENAME(ucol_normalizeShortDefinitionString)\n#define ucol_open U_ICU_ENTRY_POINT_RENAME(ucol_open)\n#define ucol_openAvailableLocales U_ICU_ENTRY_POINT_RENAME(ucol_openAvailableLocales)\n#define ucol_openBinary U_ICU_ENTRY_POINT_RENAME(ucol_openBinary)\n#define ucol_openElements U_ICU_ENTRY_POINT_RENAME(ucol_openElements)\n#define ucol_openFromShortString U_ICU_ENTRY_POINT_RENAME(ucol_openFromShortString)\n#define ucol_openRules U_ICU_ENTRY_POINT_RENAME(ucol_openRules)\n#define ucol_openRulesForImport U_ICU_ENTRY_POINT_RENAME(ucol_openRulesForImport)\n#define ucol_open_internal U_ICU_ENTRY_POINT_RENAME(ucol_open_internal)\n#define ucol_prepareShortStringOpen U_ICU_ENTRY_POINT_RENAME(ucol_prepareShortStringOpen)\n#define ucol_previous U_ICU_ENTRY_POINT_RENAME(ucol_previous)\n#define ucol_previousProcessed U_ICU_ENTRY_POINT_RENAME(ucol_previousProcessed)\n#define ucol_primaryOrder U_ICU_ENTRY_POINT_RENAME(ucol_primaryOrder)\n#define ucol_prv_getSpecialCE U_ICU_ENTRY_POINT_RENAME(ucol_prv_getSpecialCE)\n#define ucol_prv_getSpecialPrevCE U_ICU_ENTRY_POINT_RENAME(ucol_prv_getSpecialPrevCE)\n#define ucol_reset U_ICU_ENTRY_POINT_RENAME(ucol_reset)\n#define ucol_restoreVariableTop U_ICU_ENTRY_POINT_RENAME(ucol_restoreVariableTop)\n#define ucol_safeClone U_ICU_ENTRY_POINT_RENAME(ucol_safeClone)\n#define ucol_secondaryOrder U_ICU_ENTRY_POINT_RENAME(ucol_secondaryOrder)\n#define ucol_setAttribute U_ICU_ENTRY_POINT_RENAME(ucol_setAttribute)\n#define ucol_setOffset U_ICU_ENTRY_POINT_RENAME(ucol_setOffset)\n#define ucol_setOptionsFromHeader U_ICU_ENTRY_POINT_RENAME(ucol_setOptionsFromHeader)\n#define ucol_setReorderCodes U_ICU_ENTRY_POINT_RENAME(ucol_setReorderCodes)\n#define ucol_setReqValidLocales U_ICU_ENTRY_POINT_RENAME(ucol_setReqValidLocales)\n#define ucol_setStrength U_ICU_ENTRY_POINT_RENAME(ucol_setStrength)\n#define ucol_setText U_ICU_ENTRY_POINT_RENAME(ucol_setText)\n#define ucol_setVariableTop U_ICU_ENTRY_POINT_RENAME(ucol_setVariableTop)\n#define ucol_strcoll U_ICU_ENTRY_POINT_RENAME(ucol_strcoll)\n#define ucol_strcollIter U_ICU_ENTRY_POINT_RENAME(ucol_strcollIter)\n#define ucol_strcollUTF8 U_ICU_ENTRY_POINT_RENAME(ucol_strcollUTF8)\n#define ucol_swap U_ICU_ENTRY_POINT_RENAME(ucol_swap)\n#define ucol_swapBinary U_ICU_ENTRY_POINT_RENAME(ucol_swapBinary)\n#define ucol_swapInverseUCA U_ICU_ENTRY_POINT_RENAME(ucol_swapInverseUCA)\n#define ucol_tertiaryOrder U_ICU_ENTRY_POINT_RENAME(ucol_tertiaryOrder)\n#define ucol_tok_assembleTokenList U_ICU_ENTRY_POINT_RENAME(ucol_tok_assembleTokenList)\n#define ucol_tok_closeTokenList U_ICU_ENTRY_POINT_RENAME(ucol_tok_closeTokenList)\n#define ucol_tok_getNextArgument U_ICU_ENTRY_POINT_RENAME(ucol_tok_getNextArgument)\n#define ucol_tok_getRulesFromBundle U_ICU_ENTRY_POINT_RENAME(ucol_tok_getRulesFromBundle)\n#define ucol_tok_initTokenList U_ICU_ENTRY_POINT_RENAME(ucol_tok_initTokenList)\n#define ucol_tok_parseNextToken U_ICU_ENTRY_POINT_RENAME(ucol_tok_parseNextToken)\n#define ucol_updateInternalState U_ICU_ENTRY_POINT_RENAME(ucol_updateInternalState)\n#define ucsdet_close U_ICU_ENTRY_POINT_RENAME(ucsdet_close)\n#define ucsdet_detect U_ICU_ENTRY_POINT_RENAME(ucsdet_detect)\n#define ucsdet_detectAll U_ICU_ENTRY_POINT_RENAME(ucsdet_detectAll)\n#define ucsdet_enableInputFilter U_ICU_ENTRY_POINT_RENAME(ucsdet_enableInputFilter)\n#define ucsdet_getAllDetectableCharsets U_ICU_ENTRY_POINT_RENAME(ucsdet_getAllDetectableCharsets)\n#define ucsdet_getConfidence U_ICU_ENTRY_POINT_RENAME(ucsdet_getConfidence)\n#define ucsdet_getLanguage U_ICU_ENTRY_POINT_RENAME(ucsdet_getLanguage)\n#define ucsdet_getName U_ICU_ENTRY_POINT_RENAME(ucsdet_getName)\n#define ucsdet_getUChars U_ICU_ENTRY_POINT_RENAME(ucsdet_getUChars)\n#define ucsdet_isInputFilterEnabled U_ICU_ENTRY_POINT_RENAME(ucsdet_isInputFilterEnabled)\n#define ucsdet_open U_ICU_ENTRY_POINT_RENAME(ucsdet_open)\n#define ucsdet_setDeclaredEncoding U_ICU_ENTRY_POINT_RENAME(ucsdet_setDeclaredEncoding)\n#define ucsdet_setText U_ICU_ENTRY_POINT_RENAME(ucsdet_setText)\n#define ucurr_countCurrencies U_ICU_ENTRY_POINT_RENAME(ucurr_countCurrencies)\n#define ucurr_forLocale U_ICU_ENTRY_POINT_RENAME(ucurr_forLocale)\n#define ucurr_forLocaleAndDate U_ICU_ENTRY_POINT_RENAME(ucurr_forLocaleAndDate)\n#define ucurr_getDefaultFractionDigits U_ICU_ENTRY_POINT_RENAME(ucurr_getDefaultFractionDigits)\n#define ucurr_getKeywordValuesForLocale U_ICU_ENTRY_POINT_RENAME(ucurr_getKeywordValuesForLocale)\n#define ucurr_getName U_ICU_ENTRY_POINT_RENAME(ucurr_getName)\n#define ucurr_getNumericCode U_ICU_ENTRY_POINT_RENAME(ucurr_getNumericCode)\n#define ucurr_getPluralName U_ICU_ENTRY_POINT_RENAME(ucurr_getPluralName)\n#define ucurr_getRoundingIncrement U_ICU_ENTRY_POINT_RENAME(ucurr_getRoundingIncrement)\n#define ucurr_isAvailable U_ICU_ENTRY_POINT_RENAME(ucurr_isAvailable)\n#define ucurr_openISOCurrencies U_ICU_ENTRY_POINT_RENAME(ucurr_openISOCurrencies)\n#define ucurr_register U_ICU_ENTRY_POINT_RENAME(ucurr_register)\n#define ucurr_unregister U_ICU_ENTRY_POINT_RENAME(ucurr_unregister)\n#define udat_applyPattern U_ICU_ENTRY_POINT_RENAME(udat_applyPattern)\n#define udat_applyPatternRelative U_ICU_ENTRY_POINT_RENAME(udat_applyPatternRelative)\n#define udat_clone U_ICU_ENTRY_POINT_RENAME(udat_clone)\n#define udat_close U_ICU_ENTRY_POINT_RENAME(udat_close)\n#define udat_countAvailable U_ICU_ENTRY_POINT_RENAME(udat_countAvailable)\n#define udat_countSymbols U_ICU_ENTRY_POINT_RENAME(udat_countSymbols)\n#define udat_format U_ICU_ENTRY_POINT_RENAME(udat_format)\n#define udat_get2DigitYearStart U_ICU_ENTRY_POINT_RENAME(udat_get2DigitYearStart)\n#define udat_getAvailable U_ICU_ENTRY_POINT_RENAME(udat_getAvailable)\n#define udat_getCalendar U_ICU_ENTRY_POINT_RENAME(udat_getCalendar)\n#define udat_getContext U_ICU_ENTRY_POINT_RENAME(udat_getContext)\n#define udat_getLocaleByType U_ICU_ENTRY_POINT_RENAME(udat_getLocaleByType)\n#define udat_getNumberFormat U_ICU_ENTRY_POINT_RENAME(udat_getNumberFormat)\n#define udat_getSymbols U_ICU_ENTRY_POINT_RENAME(udat_getSymbols)\n#define udat_isLenient U_ICU_ENTRY_POINT_RENAME(udat_isLenient)\n#define udat_open U_ICU_ENTRY_POINT_RENAME(udat_open)\n#define udat_parse U_ICU_ENTRY_POINT_RENAME(udat_parse)\n#define udat_parseCalendar U_ICU_ENTRY_POINT_RENAME(udat_parseCalendar)\n#define udat_registerOpener U_ICU_ENTRY_POINT_RENAME(udat_registerOpener)\n#define udat_set2DigitYearStart U_ICU_ENTRY_POINT_RENAME(udat_set2DigitYearStart)\n#define udat_setCalendar U_ICU_ENTRY_POINT_RENAME(udat_setCalendar)\n#define udat_setContext U_ICU_ENTRY_POINT_RENAME(udat_setContext)\n#define udat_setLenient U_ICU_ENTRY_POINT_RENAME(udat_setLenient)\n#define udat_setNumberFormat U_ICU_ENTRY_POINT_RENAME(udat_setNumberFormat)\n#define udat_setSymbols U_ICU_ENTRY_POINT_RENAME(udat_setSymbols)\n#define udat_toCalendarDateField U_ICU_ENTRY_POINT_RENAME(udat_toCalendarDateField)\n#define udat_toPattern U_ICU_ENTRY_POINT_RENAME(udat_toPattern)\n#define udat_toPatternRelativeDate U_ICU_ENTRY_POINT_RENAME(udat_toPatternRelativeDate)\n#define udat_toPatternRelativeTime U_ICU_ENTRY_POINT_RENAME(udat_toPatternRelativeTime)\n#define udat_unregisterOpener U_ICU_ENTRY_POINT_RENAME(udat_unregisterOpener)\n#define udata_checkCommonData U_ICU_ENTRY_POINT_RENAME(udata_checkCommonData)\n#define udata_close U_ICU_ENTRY_POINT_RENAME(udata_close)\n#define udata_closeSwapper U_ICU_ENTRY_POINT_RENAME(udata_closeSwapper)\n#define udata_getHeaderSize U_ICU_ENTRY_POINT_RENAME(udata_getHeaderSize)\n#define udata_getInfo U_ICU_ENTRY_POINT_RENAME(udata_getInfo)\n#define udata_getInfoSize U_ICU_ENTRY_POINT_RENAME(udata_getInfoSize)\n#define udata_getLength U_ICU_ENTRY_POINT_RENAME(udata_getLength)\n#define udata_getMemory U_ICU_ENTRY_POINT_RENAME(udata_getMemory)\n#define udata_getRawMemory U_ICU_ENTRY_POINT_RENAME(udata_getRawMemory)\n#define udata_open U_ICU_ENTRY_POINT_RENAME(udata_open)\n#define udata_openChoice U_ICU_ENTRY_POINT_RENAME(udata_openChoice)\n#define udata_openSwapper U_ICU_ENTRY_POINT_RENAME(udata_openSwapper)\n#define udata_openSwapperForInputData U_ICU_ENTRY_POINT_RENAME(udata_openSwapperForInputData)\n#define udata_printError U_ICU_ENTRY_POINT_RENAME(udata_printError)\n#define udata_readInt16 U_ICU_ENTRY_POINT_RENAME(udata_readInt16)\n#define udata_readInt32 U_ICU_ENTRY_POINT_RENAME(udata_readInt32)\n#define udata_setAppData U_ICU_ENTRY_POINT_RENAME(udata_setAppData)\n#define udata_setCommonData U_ICU_ENTRY_POINT_RENAME(udata_setCommonData)\n#define udata_setFileAccess U_ICU_ENTRY_POINT_RENAME(udata_setFileAccess)\n#define udata_swapDataHeader U_ICU_ENTRY_POINT_RENAME(udata_swapDataHeader)\n#define udata_swapInvStringBlock U_ICU_ENTRY_POINT_RENAME(udata_swapInvStringBlock)\n#define udatpg_addPattern U_ICU_ENTRY_POINT_RENAME(udatpg_addPattern)\n#define udatpg_clone U_ICU_ENTRY_POINT_RENAME(udatpg_clone)\n#define udatpg_close U_ICU_ENTRY_POINT_RENAME(udatpg_close)\n#define udatpg_getAppendItemFormat U_ICU_ENTRY_POINT_RENAME(udatpg_getAppendItemFormat)\n#define udatpg_getAppendItemName U_ICU_ENTRY_POINT_RENAME(udatpg_getAppendItemName)\n#define udatpg_getBaseSkeleton U_ICU_ENTRY_POINT_RENAME(udatpg_getBaseSkeleton)\n#define udatpg_getBestPattern U_ICU_ENTRY_POINT_RENAME(udatpg_getBestPattern)\n#define udatpg_getBestPatternWithOptions U_ICU_ENTRY_POINT_RENAME(udatpg_getBestPatternWithOptions)\n#define udatpg_getDateTimeFormat U_ICU_ENTRY_POINT_RENAME(udatpg_getDateTimeFormat)\n#define udatpg_getDecimal U_ICU_ENTRY_POINT_RENAME(udatpg_getDecimal)\n#define udatpg_getPatternForSkeleton U_ICU_ENTRY_POINT_RENAME(udatpg_getPatternForSkeleton)\n#define udatpg_getSkeleton U_ICU_ENTRY_POINT_RENAME(udatpg_getSkeleton)\n#define udatpg_open U_ICU_ENTRY_POINT_RENAME(udatpg_open)\n#define udatpg_openBaseSkeletons U_ICU_ENTRY_POINT_RENAME(udatpg_openBaseSkeletons)\n#define udatpg_openEmpty U_ICU_ENTRY_POINT_RENAME(udatpg_openEmpty)\n#define udatpg_openSkeletons U_ICU_ENTRY_POINT_RENAME(udatpg_openSkeletons)\n#define udatpg_replaceFieldTypes U_ICU_ENTRY_POINT_RENAME(udatpg_replaceFieldTypes)\n#define udatpg_replaceFieldTypesWithOptions U_ICU_ENTRY_POINT_RENAME(udatpg_replaceFieldTypesWithOptions)\n#define udatpg_setAppendItemFormat U_ICU_ENTRY_POINT_RENAME(udatpg_setAppendItemFormat)\n#define udatpg_setAppendItemName U_ICU_ENTRY_POINT_RENAME(udatpg_setAppendItemName)\n#define udatpg_setDateTimeFormat U_ICU_ENTRY_POINT_RENAME(udatpg_setDateTimeFormat)\n#define udatpg_setDecimal U_ICU_ENTRY_POINT_RENAME(udatpg_setDecimal)\n#define udict_swap U_ICU_ENTRY_POINT_RENAME(udict_swap)\n#define udtitvfmt_close U_ICU_ENTRY_POINT_RENAME(udtitvfmt_close)\n#define udtitvfmt_format U_ICU_ENTRY_POINT_RENAME(udtitvfmt_format)\n#define udtitvfmt_open U_ICU_ENTRY_POINT_RENAME(udtitvfmt_open)\n#define uenum_close U_ICU_ENTRY_POINT_RENAME(uenum_close)\n#define uenum_count U_ICU_ENTRY_POINT_RENAME(uenum_count)\n#define uenum_next U_ICU_ENTRY_POINT_RENAME(uenum_next)\n#define uenum_nextDefault U_ICU_ENTRY_POINT_RENAME(uenum_nextDefault)\n#define uenum_openCharStringsEnumeration U_ICU_ENTRY_POINT_RENAME(uenum_openCharStringsEnumeration)\n#define uenum_openFromStringEnumeration U_ICU_ENTRY_POINT_RENAME(uenum_openFromStringEnumeration)\n#define uenum_openUCharStringsEnumeration U_ICU_ENTRY_POINT_RENAME(uenum_openUCharStringsEnumeration)\n#define uenum_reset U_ICU_ENTRY_POINT_RENAME(uenum_reset)\n#define uenum_unext U_ICU_ENTRY_POINT_RENAME(uenum_unext)\n#define uenum_unextDefault U_ICU_ENTRY_POINT_RENAME(uenum_unextDefault)\n#define ufile_close_translit U_ICU_ENTRY_POINT_RENAME(ufile_close_translit)\n#define ufile_fill_uchar_buffer U_ICU_ENTRY_POINT_RENAME(ufile_fill_uchar_buffer)\n#define ufile_flush_io U_ICU_ENTRY_POINT_RENAME(ufile_flush_io)\n#define ufile_flush_translit U_ICU_ENTRY_POINT_RENAME(ufile_flush_translit)\n#define ufile_getch U_ICU_ENTRY_POINT_RENAME(ufile_getch)\n#define ufile_getch32 U_ICU_ENTRY_POINT_RENAME(ufile_getch32)\n#define ufmt_64tou U_ICU_ENTRY_POINT_RENAME(ufmt_64tou)\n#define ufmt_defaultCPToUnicode U_ICU_ENTRY_POINT_RENAME(ufmt_defaultCPToUnicode)\n#define ufmt_digitvalue U_ICU_ENTRY_POINT_RENAME(ufmt_digitvalue)\n#define ufmt_isdigit U_ICU_ENTRY_POINT_RENAME(ufmt_isdigit)\n#define ufmt_ptou U_ICU_ENTRY_POINT_RENAME(ufmt_ptou)\n#define ufmt_uto64 U_ICU_ENTRY_POINT_RENAME(ufmt_uto64)\n#define ufmt_utop U_ICU_ENTRY_POINT_RENAME(ufmt_utop)\n#define ugender_getInstance U_ICU_ENTRY_POINT_RENAME(ugender_getInstance)\n#define ugender_getListGender U_ICU_ENTRY_POINT_RENAME(ugender_getListGender)\n#define uhash_close U_ICU_ENTRY_POINT_RENAME(uhash_close)\n#define uhash_compareCaselessUnicodeString U_ICU_ENTRY_POINT_RENAME(uhash_compareCaselessUnicodeString)\n#define uhash_compareChars U_ICU_ENTRY_POINT_RENAME(uhash_compareChars)\n#define uhash_compareIChars U_ICU_ENTRY_POINT_RENAME(uhash_compareIChars)\n#define uhash_compareLong U_ICU_ENTRY_POINT_RENAME(uhash_compareLong)\n#define uhash_compareUChars U_ICU_ENTRY_POINT_RENAME(uhash_compareUChars)\n#define uhash_compareUnicodeString U_ICU_ENTRY_POINT_RENAME(uhash_compareUnicodeString)\n#define uhash_count U_ICU_ENTRY_POINT_RENAME(uhash_count)\n#define uhash_deleteHashtable U_ICU_ENTRY_POINT_RENAME(uhash_deleteHashtable)\n#define uhash_equals U_ICU_ENTRY_POINT_RENAME(uhash_equals)\n#define uhash_find U_ICU_ENTRY_POINT_RENAME(uhash_find)\n#define uhash_get U_ICU_ENTRY_POINT_RENAME(uhash_get)\n#define uhash_geti U_ICU_ENTRY_POINT_RENAME(uhash_geti)\n#define uhash_hashCaselessUnicodeString U_ICU_ENTRY_POINT_RENAME(uhash_hashCaselessUnicodeString)\n#define uhash_hashChars U_ICU_ENTRY_POINT_RENAME(uhash_hashChars)\n#define uhash_hashIChars U_ICU_ENTRY_POINT_RENAME(uhash_hashIChars)\n#define uhash_hashLong U_ICU_ENTRY_POINT_RENAME(uhash_hashLong)\n#define uhash_hashUChars U_ICU_ENTRY_POINT_RENAME(uhash_hashUChars)\n#define uhash_hashUnicodeString U_ICU_ENTRY_POINT_RENAME(uhash_hashUnicodeString)\n#define uhash_iget U_ICU_ENTRY_POINT_RENAME(uhash_iget)\n#define uhash_igeti U_ICU_ENTRY_POINT_RENAME(uhash_igeti)\n#define uhash_init U_ICU_ENTRY_POINT_RENAME(uhash_init)\n#define uhash_iput U_ICU_ENTRY_POINT_RENAME(uhash_iput)\n#define uhash_iputi U_ICU_ENTRY_POINT_RENAME(uhash_iputi)\n#define uhash_iremove U_ICU_ENTRY_POINT_RENAME(uhash_iremove)\n#define uhash_iremovei U_ICU_ENTRY_POINT_RENAME(uhash_iremovei)\n#define uhash_nextElement U_ICU_ENTRY_POINT_RENAME(uhash_nextElement)\n#define uhash_open U_ICU_ENTRY_POINT_RENAME(uhash_open)\n#define uhash_openSize U_ICU_ENTRY_POINT_RENAME(uhash_openSize)\n#define uhash_put U_ICU_ENTRY_POINT_RENAME(uhash_put)\n#define uhash_puti U_ICU_ENTRY_POINT_RENAME(uhash_puti)\n#define uhash_remove U_ICU_ENTRY_POINT_RENAME(uhash_remove)\n#define uhash_removeAll U_ICU_ENTRY_POINT_RENAME(uhash_removeAll)\n#define uhash_removeElement U_ICU_ENTRY_POINT_RENAME(uhash_removeElement)\n#define uhash_removei U_ICU_ENTRY_POINT_RENAME(uhash_removei)\n#define uhash_setKeyComparator U_ICU_ENTRY_POINT_RENAME(uhash_setKeyComparator)\n#define uhash_setKeyDeleter U_ICU_ENTRY_POINT_RENAME(uhash_setKeyDeleter)\n#define uhash_setKeyHasher U_ICU_ENTRY_POINT_RENAME(uhash_setKeyHasher)\n#define uhash_setResizePolicy U_ICU_ENTRY_POINT_RENAME(uhash_setResizePolicy)\n#define uhash_setValueComparator U_ICU_ENTRY_POINT_RENAME(uhash_setValueComparator)\n#define uhash_setValueDeleter U_ICU_ENTRY_POINT_RENAME(uhash_setValueDeleter)\n#define uidna_IDNToASCII U_ICU_ENTRY_POINT_RENAME(uidna_IDNToASCII)\n#define uidna_IDNToUnicode U_ICU_ENTRY_POINT_RENAME(uidna_IDNToUnicode)\n#define uidna_close U_ICU_ENTRY_POINT_RENAME(uidna_close)\n#define uidna_compare U_ICU_ENTRY_POINT_RENAME(uidna_compare)\n#define uidna_labelToASCII U_ICU_ENTRY_POINT_RENAME(uidna_labelToASCII)\n#define uidna_labelToASCII_UTF8 U_ICU_ENTRY_POINT_RENAME(uidna_labelToASCII_UTF8)\n#define uidna_labelToUnicode U_ICU_ENTRY_POINT_RENAME(uidna_labelToUnicode)\n#define uidna_labelToUnicodeUTF8 U_ICU_ENTRY_POINT_RENAME(uidna_labelToUnicodeUTF8)\n#define uidna_nameToASCII U_ICU_ENTRY_POINT_RENAME(uidna_nameToASCII)\n#define uidna_nameToASCII_UTF8 U_ICU_ENTRY_POINT_RENAME(uidna_nameToASCII_UTF8)\n#define uidna_nameToUnicode U_ICU_ENTRY_POINT_RENAME(uidna_nameToUnicode)\n#define uidna_nameToUnicodeUTF8 U_ICU_ENTRY_POINT_RENAME(uidna_nameToUnicodeUTF8)\n#define uidna_openUTS46 U_ICU_ENTRY_POINT_RENAME(uidna_openUTS46)\n#define uidna_toASCII U_ICU_ENTRY_POINT_RENAME(uidna_toASCII)\n#define uidna_toUnicode U_ICU_ENTRY_POINT_RENAME(uidna_toUnicode)\n#define uiter_current32 U_ICU_ENTRY_POINT_RENAME(uiter_current32)\n#define uiter_getState U_ICU_ENTRY_POINT_RENAME(uiter_getState)\n#define uiter_next32 U_ICU_ENTRY_POINT_RENAME(uiter_next32)\n#define uiter_previous32 U_ICU_ENTRY_POINT_RENAME(uiter_previous32)\n#define uiter_setCharacterIterator U_ICU_ENTRY_POINT_RENAME(uiter_setCharacterIterator)\n#define uiter_setReplaceable U_ICU_ENTRY_POINT_RENAME(uiter_setReplaceable)\n#define uiter_setState U_ICU_ENTRY_POINT_RENAME(uiter_setState)\n#define uiter_setString U_ICU_ENTRY_POINT_RENAME(uiter_setString)\n#define uiter_setUTF16BE U_ICU_ENTRY_POINT_RENAME(uiter_setUTF16BE)\n#define uiter_setUTF8 U_ICU_ENTRY_POINT_RENAME(uiter_setUTF8)\n#define uldn_close U_ICU_ENTRY_POINT_RENAME(uldn_close)\n#define uldn_getContext U_ICU_ENTRY_POINT_RENAME(uldn_getContext)\n#define uldn_getDialectHandling U_ICU_ENTRY_POINT_RENAME(uldn_getDialectHandling)\n#define uldn_getLocale U_ICU_ENTRY_POINT_RENAME(uldn_getLocale)\n#define uldn_keyDisplayName U_ICU_ENTRY_POINT_RENAME(uldn_keyDisplayName)\n#define uldn_keyValueDisplayName U_ICU_ENTRY_POINT_RENAME(uldn_keyValueDisplayName)\n#define uldn_languageDisplayName U_ICU_ENTRY_POINT_RENAME(uldn_languageDisplayName)\n#define uldn_localeDisplayName U_ICU_ENTRY_POINT_RENAME(uldn_localeDisplayName)\n#define uldn_open U_ICU_ENTRY_POINT_RENAME(uldn_open)\n#define uldn_openForContext U_ICU_ENTRY_POINT_RENAME(uldn_openForContext)\n#define uldn_regionDisplayName U_ICU_ENTRY_POINT_RENAME(uldn_regionDisplayName)\n#define uldn_scriptCodeDisplayName U_ICU_ENTRY_POINT_RENAME(uldn_scriptCodeDisplayName)\n#define uldn_scriptDisplayName U_ICU_ENTRY_POINT_RENAME(uldn_scriptDisplayName)\n#define uldn_variantDisplayName U_ICU_ENTRY_POINT_RENAME(uldn_variantDisplayName)\n#define ulist_addItemBeginList U_ICU_ENTRY_POINT_RENAME(ulist_addItemBeginList)\n#define ulist_addItemEndList U_ICU_ENTRY_POINT_RENAME(ulist_addItemEndList)\n#define ulist_close_keyword_values_iterator U_ICU_ENTRY_POINT_RENAME(ulist_close_keyword_values_iterator)\n#define ulist_containsString U_ICU_ENTRY_POINT_RENAME(ulist_containsString)\n#define ulist_count_keyword_values U_ICU_ENTRY_POINT_RENAME(ulist_count_keyword_values)\n#define ulist_createEmptyList U_ICU_ENTRY_POINT_RENAME(ulist_createEmptyList)\n#define ulist_deleteList U_ICU_ENTRY_POINT_RENAME(ulist_deleteList)\n#define ulist_getListFromEnum U_ICU_ENTRY_POINT_RENAME(ulist_getListFromEnum)\n#define ulist_getListSize U_ICU_ENTRY_POINT_RENAME(ulist_getListSize)\n#define ulist_getNext U_ICU_ENTRY_POINT_RENAME(ulist_getNext)\n#define ulist_next_keyword_value U_ICU_ENTRY_POINT_RENAME(ulist_next_keyword_value)\n#define ulist_resetList U_ICU_ENTRY_POINT_RENAME(ulist_resetList)\n#define ulist_reset_keyword_values_iterator U_ICU_ENTRY_POINT_RENAME(ulist_reset_keyword_values_iterator)\n#define uloc_acceptLanguage U_ICU_ENTRY_POINT_RENAME(uloc_acceptLanguage)\n#define uloc_acceptLanguageFromHTTP U_ICU_ENTRY_POINT_RENAME(uloc_acceptLanguageFromHTTP)\n#define uloc_addLikelySubtags U_ICU_ENTRY_POINT_RENAME(uloc_addLikelySubtags)\n#define uloc_canonicalize U_ICU_ENTRY_POINT_RENAME(uloc_canonicalize)\n#define uloc_countAvailable U_ICU_ENTRY_POINT_RENAME(uloc_countAvailable)\n#define uloc_forLanguageTag U_ICU_ENTRY_POINT_RENAME(uloc_forLanguageTag)\n#define uloc_getAvailable U_ICU_ENTRY_POINT_RENAME(uloc_getAvailable)\n#define uloc_getBaseName U_ICU_ENTRY_POINT_RENAME(uloc_getBaseName)\n#define uloc_getCharacterOrientation U_ICU_ENTRY_POINT_RENAME(uloc_getCharacterOrientation)\n#define uloc_getCountry U_ICU_ENTRY_POINT_RENAME(uloc_getCountry)\n#define uloc_getCurrentCountryID U_ICU_ENTRY_POINT_RENAME(uloc_getCurrentCountryID)\n#define uloc_getCurrentLanguageID U_ICU_ENTRY_POINT_RENAME(uloc_getCurrentLanguageID)\n#define uloc_getDefault U_ICU_ENTRY_POINT_RENAME(uloc_getDefault)\n#define uloc_getDisplayCountry U_ICU_ENTRY_POINT_RENAME(uloc_getDisplayCountry)\n#define uloc_getDisplayKeyword U_ICU_ENTRY_POINT_RENAME(uloc_getDisplayKeyword)\n#define uloc_getDisplayKeywordValue U_ICU_ENTRY_POINT_RENAME(uloc_getDisplayKeywordValue)\n#define uloc_getDisplayLanguage U_ICU_ENTRY_POINT_RENAME(uloc_getDisplayLanguage)\n#define uloc_getDisplayName U_ICU_ENTRY_POINT_RENAME(uloc_getDisplayName)\n#define uloc_getDisplayScript U_ICU_ENTRY_POINT_RENAME(uloc_getDisplayScript)\n#define uloc_getDisplayScriptInContext U_ICU_ENTRY_POINT_RENAME(uloc_getDisplayScriptInContext)\n#define uloc_getDisplayVariant U_ICU_ENTRY_POINT_RENAME(uloc_getDisplayVariant)\n#define uloc_getISO3Country U_ICU_ENTRY_POINT_RENAME(uloc_getISO3Country)\n#define uloc_getISO3Language U_ICU_ENTRY_POINT_RENAME(uloc_getISO3Language)\n#define uloc_getISOCountries U_ICU_ENTRY_POINT_RENAME(uloc_getISOCountries)\n#define uloc_getISOLanguages U_ICU_ENTRY_POINT_RENAME(uloc_getISOLanguages)\n#define uloc_getKeywordValue U_ICU_ENTRY_POINT_RENAME(uloc_getKeywordValue)\n#define uloc_getLCID U_ICU_ENTRY_POINT_RENAME(uloc_getLCID)\n#define uloc_getLanguage U_ICU_ENTRY_POINT_RENAME(uloc_getLanguage)\n#define uloc_getLineOrientation U_ICU_ENTRY_POINT_RENAME(uloc_getLineOrientation)\n#define uloc_getLocaleForLCID U_ICU_ENTRY_POINT_RENAME(uloc_getLocaleForLCID)\n#define uloc_getName U_ICU_ENTRY_POINT_RENAME(uloc_getName)\n#define uloc_getParent U_ICU_ENTRY_POINT_RENAME(uloc_getParent)\n#define uloc_getScript U_ICU_ENTRY_POINT_RENAME(uloc_getScript)\n#define uloc_getTableStringWithFallback U_ICU_ENTRY_POINT_RENAME(uloc_getTableStringWithFallback)\n#define uloc_getVariant U_ICU_ENTRY_POINT_RENAME(uloc_getVariant)\n#define uloc_minimizeSubtags U_ICU_ENTRY_POINT_RENAME(uloc_minimizeSubtags)\n#define uloc_openKeywordList U_ICU_ENTRY_POINT_RENAME(uloc_openKeywordList)\n#define uloc_openKeywords U_ICU_ENTRY_POINT_RENAME(uloc_openKeywords)\n#define uloc_setDefault U_ICU_ENTRY_POINT_RENAME(uloc_setDefault)\n#define uloc_setKeywordValue U_ICU_ENTRY_POINT_RENAME(uloc_setKeywordValue)\n#define uloc_toLanguageTag U_ICU_ENTRY_POINT_RENAME(uloc_toLanguageTag)\n#define ulocdata_close U_ICU_ENTRY_POINT_RENAME(ulocdata_close)\n#define ulocdata_getCLDRVersion U_ICU_ENTRY_POINT_RENAME(ulocdata_getCLDRVersion)\n#define ulocdata_getDelimiter U_ICU_ENTRY_POINT_RENAME(ulocdata_getDelimiter)\n#define ulocdata_getExemplarSet U_ICU_ENTRY_POINT_RENAME(ulocdata_getExemplarSet)\n#define ulocdata_getLocaleDisplayPattern U_ICU_ENTRY_POINT_RENAME(ulocdata_getLocaleDisplayPattern)\n#define ulocdata_getLocaleSeparator U_ICU_ENTRY_POINT_RENAME(ulocdata_getLocaleSeparator)\n#define ulocdata_getMeasurementSystem U_ICU_ENTRY_POINT_RENAME(ulocdata_getMeasurementSystem)\n#define ulocdata_getNoSubstitute U_ICU_ENTRY_POINT_RENAME(ulocdata_getNoSubstitute)\n#define ulocdata_getPaperSize U_ICU_ENTRY_POINT_RENAME(ulocdata_getPaperSize)\n#define ulocdata_open U_ICU_ENTRY_POINT_RENAME(ulocdata_open)\n#define ulocdata_setNoSubstitute U_ICU_ENTRY_POINT_RENAME(ulocdata_setNoSubstitute)\n#define ulocimp_getCountry U_ICU_ENTRY_POINT_RENAME(ulocimp_getCountry)\n#define ulocimp_getLanguage U_ICU_ENTRY_POINT_RENAME(ulocimp_getLanguage)\n#define ulocimp_getScript U_ICU_ENTRY_POINT_RENAME(ulocimp_getScript)\n#define umsg_applyPattern U_ICU_ENTRY_POINT_RENAME(umsg_applyPattern)\n#define umsg_autoQuoteApostrophe U_ICU_ENTRY_POINT_RENAME(umsg_autoQuoteApostrophe)\n#define umsg_clone U_ICU_ENTRY_POINT_RENAME(umsg_clone)\n#define umsg_close U_ICU_ENTRY_POINT_RENAME(umsg_close)\n#define umsg_format U_ICU_ENTRY_POINT_RENAME(umsg_format)\n#define umsg_getLocale U_ICU_ENTRY_POINT_RENAME(umsg_getLocale)\n#define umsg_open U_ICU_ENTRY_POINT_RENAME(umsg_open)\n#define umsg_parse U_ICU_ENTRY_POINT_RENAME(umsg_parse)\n#define umsg_setLocale U_ICU_ENTRY_POINT_RENAME(umsg_setLocale)\n#define umsg_toPattern U_ICU_ENTRY_POINT_RENAME(umsg_toPattern)\n#define umsg_vformat U_ICU_ENTRY_POINT_RENAME(umsg_vformat)\n#define umsg_vparse U_ICU_ENTRY_POINT_RENAME(umsg_vparse)\n#define umtx_atomic_dec U_ICU_ENTRY_POINT_RENAME(umtx_atomic_dec)\n#define umtx_atomic_inc U_ICU_ENTRY_POINT_RENAME(umtx_atomic_inc)\n#define umtx_cleanup U_ICU_ENTRY_POINT_RENAME(umtx_cleanup)\n#define umtx_lock U_ICU_ENTRY_POINT_RENAME(umtx_lock)\n#define umtx_unlock U_ICU_ENTRY_POINT_RENAME(umtx_unlock)\n#define uniset_getUnicode32Instance U_ICU_ENTRY_POINT_RENAME(uniset_getUnicode32Instance)\n#define unorm2_append U_ICU_ENTRY_POINT_RENAME(unorm2_append)\n#define unorm2_close U_ICU_ENTRY_POINT_RENAME(unorm2_close)\n#define unorm2_composePair U_ICU_ENTRY_POINT_RENAME(unorm2_composePair)\n#define unorm2_getCombiningClass U_ICU_ENTRY_POINT_RENAME(unorm2_getCombiningClass)\n#define unorm2_getDecomposition U_ICU_ENTRY_POINT_RENAME(unorm2_getDecomposition)\n#define unorm2_getInstance U_ICU_ENTRY_POINT_RENAME(unorm2_getInstance)\n#define unorm2_getNFCInstance U_ICU_ENTRY_POINT_RENAME(unorm2_getNFCInstance)\n#define unorm2_getNFDInstance U_ICU_ENTRY_POINT_RENAME(unorm2_getNFDInstance)\n#define unorm2_getNFKCCasefoldInstance U_ICU_ENTRY_POINT_RENAME(unorm2_getNFKCCasefoldInstance)\n#define unorm2_getNFKCInstance U_ICU_ENTRY_POINT_RENAME(unorm2_getNFKCInstance)\n#define unorm2_getNFKDInstance U_ICU_ENTRY_POINT_RENAME(unorm2_getNFKDInstance)\n#define unorm2_getRawDecomposition U_ICU_ENTRY_POINT_RENAME(unorm2_getRawDecomposition)\n#define unorm2_hasBoundaryAfter U_ICU_ENTRY_POINT_RENAME(unorm2_hasBoundaryAfter)\n#define unorm2_hasBoundaryBefore U_ICU_ENTRY_POINT_RENAME(unorm2_hasBoundaryBefore)\n#define unorm2_isInert U_ICU_ENTRY_POINT_RENAME(unorm2_isInert)\n#define unorm2_isNormalized U_ICU_ENTRY_POINT_RENAME(unorm2_isNormalized)\n#define unorm2_normalize U_ICU_ENTRY_POINT_RENAME(unorm2_normalize)\n#define unorm2_normalizeSecondAndAppend U_ICU_ENTRY_POINT_RENAME(unorm2_normalizeSecondAndAppend)\n#define unorm2_openFiltered U_ICU_ENTRY_POINT_RENAME(unorm2_openFiltered)\n#define unorm2_quickCheck U_ICU_ENTRY_POINT_RENAME(unorm2_quickCheck)\n#define unorm2_spanQuickCheckYes U_ICU_ENTRY_POINT_RENAME(unorm2_spanQuickCheckYes)\n#define unorm2_swap U_ICU_ENTRY_POINT_RENAME(unorm2_swap)\n#define unorm_closeIter U_ICU_ENTRY_POINT_RENAME(unorm_closeIter)\n#define unorm_compare U_ICU_ENTRY_POINT_RENAME(unorm_compare)\n#define unorm_concatenate U_ICU_ENTRY_POINT_RENAME(unorm_concatenate)\n#define unorm_getFCD16 U_ICU_ENTRY_POINT_RENAME(unorm_getFCD16)\n#define unorm_getQuickCheck U_ICU_ENTRY_POINT_RENAME(unorm_getQuickCheck)\n#define unorm_isNormalized U_ICU_ENTRY_POINT_RENAME(unorm_isNormalized)\n#define unorm_isNormalizedWithOptions U_ICU_ENTRY_POINT_RENAME(unorm_isNormalizedWithOptions)\n#define unorm_next U_ICU_ENTRY_POINT_RENAME(unorm_next)\n#define unorm_normalize U_ICU_ENTRY_POINT_RENAME(unorm_normalize)\n#define unorm_openIter U_ICU_ENTRY_POINT_RENAME(unorm_openIter)\n#define unorm_previous U_ICU_ENTRY_POINT_RENAME(unorm_previous)\n#define unorm_quickCheck U_ICU_ENTRY_POINT_RENAME(unorm_quickCheck)\n#define unorm_quickCheckWithOptions U_ICU_ENTRY_POINT_RENAME(unorm_quickCheckWithOptions)\n#define unorm_setIter U_ICU_ENTRY_POINT_RENAME(unorm_setIter)\n#define unum_applyPattern U_ICU_ENTRY_POINT_RENAME(unum_applyPattern)\n#define unum_clone U_ICU_ENTRY_POINT_RENAME(unum_clone)\n#define unum_close U_ICU_ENTRY_POINT_RENAME(unum_close)\n#define unum_countAvailable U_ICU_ENTRY_POINT_RENAME(unum_countAvailable)\n#define unum_format U_ICU_ENTRY_POINT_RENAME(unum_format)\n#define unum_formatDecimal U_ICU_ENTRY_POINT_RENAME(unum_formatDecimal)\n#define unum_formatDouble U_ICU_ENTRY_POINT_RENAME(unum_formatDouble)\n#define unum_formatDoubleCurrency U_ICU_ENTRY_POINT_RENAME(unum_formatDoubleCurrency)\n#define unum_formatInt64 U_ICU_ENTRY_POINT_RENAME(unum_formatInt64)\n#define unum_getAttribute U_ICU_ENTRY_POINT_RENAME(unum_getAttribute)\n#define unum_getAvailable U_ICU_ENTRY_POINT_RENAME(unum_getAvailable)\n#define unum_getDoubleAttribute U_ICU_ENTRY_POINT_RENAME(unum_getDoubleAttribute)\n#define unum_getLocaleByType U_ICU_ENTRY_POINT_RENAME(unum_getLocaleByType)\n#define unum_getSymbol U_ICU_ENTRY_POINT_RENAME(unum_getSymbol)\n#define unum_getTextAttribute U_ICU_ENTRY_POINT_RENAME(unum_getTextAttribute)\n#define unum_open U_ICU_ENTRY_POINT_RENAME(unum_open)\n#define unum_parse U_ICU_ENTRY_POINT_RENAME(unum_parse)\n#define unum_parseDecimal U_ICU_ENTRY_POINT_RENAME(unum_parseDecimal)\n#define unum_parseDouble U_ICU_ENTRY_POINT_RENAME(unum_parseDouble)\n#define unum_parseDoubleCurrency U_ICU_ENTRY_POINT_RENAME(unum_parseDoubleCurrency)\n#define unum_parseInt64 U_ICU_ENTRY_POINT_RENAME(unum_parseInt64)\n#define unum_setAttribute U_ICU_ENTRY_POINT_RENAME(unum_setAttribute)\n#define unum_setDoubleAttribute U_ICU_ENTRY_POINT_RENAME(unum_setDoubleAttribute)\n#define unum_setSymbol U_ICU_ENTRY_POINT_RENAME(unum_setSymbol)\n#define unum_setTextAttribute U_ICU_ENTRY_POINT_RENAME(unum_setTextAttribute)\n#define unum_toPattern U_ICU_ENTRY_POINT_RENAME(unum_toPattern)\n#define uplrules_close U_ICU_ENTRY_POINT_RENAME(uplrules_close)\n#define uplrules_open U_ICU_ENTRY_POINT_RENAME(uplrules_open)\n#define uplrules_openForType U_ICU_ENTRY_POINT_RENAME(uplrules_openForType)\n#define uplrules_select U_ICU_ENTRY_POINT_RENAME(uplrules_select)\n#define uplug_closeLibrary U_ICU_ENTRY_POINT_RENAME(uplug_closeLibrary)\n#define uplug_findLibrary U_ICU_ENTRY_POINT_RENAME(uplug_findLibrary)\n#define uplug_getConfiguration U_ICU_ENTRY_POINT_RENAME(uplug_getConfiguration)\n#define uplug_getContext U_ICU_ENTRY_POINT_RENAME(uplug_getContext)\n#define uplug_getCurrentLevel U_ICU_ENTRY_POINT_RENAME(uplug_getCurrentLevel)\n#define uplug_getLibrary U_ICU_ENTRY_POINT_RENAME(uplug_getLibrary)\n#define uplug_getLibraryName U_ICU_ENTRY_POINT_RENAME(uplug_getLibraryName)\n#define uplug_getPlugInternal U_ICU_ENTRY_POINT_RENAME(uplug_getPlugInternal)\n#define uplug_getPlugLevel U_ICU_ENTRY_POINT_RENAME(uplug_getPlugLevel)\n#define uplug_getPlugLoadStatus U_ICU_ENTRY_POINT_RENAME(uplug_getPlugLoadStatus)\n#define uplug_getPlugName U_ICU_ENTRY_POINT_RENAME(uplug_getPlugName)\n#define uplug_getPluginFile U_ICU_ENTRY_POINT_RENAME(uplug_getPluginFile)\n#define uplug_getSymbolName U_ICU_ENTRY_POINT_RENAME(uplug_getSymbolName)\n#define uplug_init U_ICU_ENTRY_POINT_RENAME(uplug_init)\n#define uplug_loadPlugFromEntrypoint U_ICU_ENTRY_POINT_RENAME(uplug_loadPlugFromEntrypoint)\n#define uplug_loadPlugFromLibrary U_ICU_ENTRY_POINT_RENAME(uplug_loadPlugFromLibrary)\n#define uplug_nextPlug U_ICU_ENTRY_POINT_RENAME(uplug_nextPlug)\n#define uplug_openLibrary U_ICU_ENTRY_POINT_RENAME(uplug_openLibrary)\n#define uplug_removePlug U_ICU_ENTRY_POINT_RENAME(uplug_removePlug)\n#define uplug_setContext U_ICU_ENTRY_POINT_RENAME(uplug_setContext)\n#define uplug_setPlugLevel U_ICU_ENTRY_POINT_RENAME(uplug_setPlugLevel)\n#define uplug_setPlugName U_ICU_ENTRY_POINT_RENAME(uplug_setPlugName)\n#define uplug_setPlugNoUnload U_ICU_ENTRY_POINT_RENAME(uplug_setPlugNoUnload)\n#define uprops_getSource U_ICU_ENTRY_POINT_RENAME(uprops_getSource)\n#define upropsvec_addPropertyStarts U_ICU_ENTRY_POINT_RENAME(upropsvec_addPropertyStarts)\n#define uprv_aestrncpy U_ICU_ENTRY_POINT_RENAME(uprv_aestrncpy)\n#define uprv_asciiFromEbcdic U_ICU_ENTRY_POINT_RENAME(uprv_asciiFromEbcdic)\n#define uprv_asciitolower U_ICU_ENTRY_POINT_RENAME(uprv_asciitolower)\n#define uprv_calloc U_ICU_ENTRY_POINT_RENAME(uprv_calloc)\n#define uprv_ceil U_ICU_ENTRY_POINT_RENAME(uprv_ceil)\n#define uprv_cnttab_addContraction U_ICU_ENTRY_POINT_RENAME(uprv_cnttab_addContraction)\n#define uprv_cnttab_changeContraction U_ICU_ENTRY_POINT_RENAME(uprv_cnttab_changeContraction)\n#define uprv_cnttab_changeLastCE U_ICU_ENTRY_POINT_RENAME(uprv_cnttab_changeLastCE)\n#define uprv_cnttab_clone U_ICU_ENTRY_POINT_RENAME(uprv_cnttab_clone)\n#define uprv_cnttab_close U_ICU_ENTRY_POINT_RENAME(uprv_cnttab_close)\n#define uprv_cnttab_constructTable U_ICU_ENTRY_POINT_RENAME(uprv_cnttab_constructTable)\n#define uprv_cnttab_findCE U_ICU_ENTRY_POINT_RENAME(uprv_cnttab_findCE)\n#define uprv_cnttab_findCP U_ICU_ENTRY_POINT_RENAME(uprv_cnttab_findCP)\n#define uprv_cnttab_getCE U_ICU_ENTRY_POINT_RENAME(uprv_cnttab_getCE)\n#define uprv_cnttab_insertContraction U_ICU_ENTRY_POINT_RENAME(uprv_cnttab_insertContraction)\n#define uprv_cnttab_isTailored U_ICU_ENTRY_POINT_RENAME(uprv_cnttab_isTailored)\n#define uprv_cnttab_open U_ICU_ENTRY_POINT_RENAME(uprv_cnttab_open)\n#define uprv_cnttab_setContraction U_ICU_ENTRY_POINT_RENAME(uprv_cnttab_setContraction)\n#define uprv_collIterateAtEnd U_ICU_ENTRY_POINT_RENAME(uprv_collIterateAtEnd)\n#define uprv_compareASCIIPropertyNames U_ICU_ENTRY_POINT_RENAME(uprv_compareASCIIPropertyNames)\n#define uprv_compareEBCDICPropertyNames U_ICU_ENTRY_POINT_RENAME(uprv_compareEBCDICPropertyNames)\n#define uprv_compareInvAscii U_ICU_ENTRY_POINT_RENAME(uprv_compareInvAscii)\n#define uprv_compareInvEbcdic U_ICU_ENTRY_POINT_RENAME(uprv_compareInvEbcdic)\n#define uprv_compareInvEbcdicAsAscii U_ICU_ENTRY_POINT_RENAME(uprv_compareInvEbcdicAsAscii)\n#define uprv_convertToLCID U_ICU_ENTRY_POINT_RENAME(uprv_convertToLCID)\n#define uprv_convertToPosix U_ICU_ENTRY_POINT_RENAME(uprv_convertToPosix)\n#define uprv_copyAscii U_ICU_ENTRY_POINT_RENAME(uprv_copyAscii)\n#define uprv_copyEbcdic U_ICU_ENTRY_POINT_RENAME(uprv_copyEbcdic)\n#define uprv_decContextClearStatus U_ICU_ENTRY_POINT_RENAME(uprv_decContextClearStatus)\n#define uprv_decContextDefault U_ICU_ENTRY_POINT_RENAME(uprv_decContextDefault)\n#define uprv_decContextGetRounding U_ICU_ENTRY_POINT_RENAME(uprv_decContextGetRounding)\n#define uprv_decContextGetStatus U_ICU_ENTRY_POINT_RENAME(uprv_decContextGetStatus)\n#define uprv_decContextRestoreStatus U_ICU_ENTRY_POINT_RENAME(uprv_decContextRestoreStatus)\n#define uprv_decContextSaveStatus U_ICU_ENTRY_POINT_RENAME(uprv_decContextSaveStatus)\n#define uprv_decContextSetRounding U_ICU_ENTRY_POINT_RENAME(uprv_decContextSetRounding)\n#define uprv_decContextSetStatus U_ICU_ENTRY_POINT_RENAME(uprv_decContextSetStatus)\n#define uprv_decContextSetStatusFromString U_ICU_ENTRY_POINT_RENAME(uprv_decContextSetStatusFromString)\n#define uprv_decContextSetStatusFromStringQuiet U_ICU_ENTRY_POINT_RENAME(uprv_decContextSetStatusFromStringQuiet)\n#define uprv_decContextSetStatusQuiet U_ICU_ENTRY_POINT_RENAME(uprv_decContextSetStatusQuiet)\n#define uprv_decContextStatusToString U_ICU_ENTRY_POINT_RENAME(uprv_decContextStatusToString)\n#define uprv_decContextTestSavedStatus U_ICU_ENTRY_POINT_RENAME(uprv_decContextTestSavedStatus)\n#define uprv_decContextTestStatus U_ICU_ENTRY_POINT_RENAME(uprv_decContextTestStatus)\n#define uprv_decContextZeroStatus U_ICU_ENTRY_POINT_RENAME(uprv_decContextZeroStatus)\n#define uprv_decNumberAbs U_ICU_ENTRY_POINT_RENAME(uprv_decNumberAbs)\n#define uprv_decNumberAdd U_ICU_ENTRY_POINT_RENAME(uprv_decNumberAdd)\n#define uprv_decNumberAnd U_ICU_ENTRY_POINT_RENAME(uprv_decNumberAnd)\n#define uprv_decNumberClass U_ICU_ENTRY_POINT_RENAME(uprv_decNumberClass)\n#define uprv_decNumberClassToString U_ICU_ENTRY_POINT_RENAME(uprv_decNumberClassToString)\n#define uprv_decNumberCompare U_ICU_ENTRY_POINT_RENAME(uprv_decNumberCompare)\n#define uprv_decNumberCompareSignal U_ICU_ENTRY_POINT_RENAME(uprv_decNumberCompareSignal)\n#define uprv_decNumberCompareTotal U_ICU_ENTRY_POINT_RENAME(uprv_decNumberCompareTotal)\n#define uprv_decNumberCompareTotalMag U_ICU_ENTRY_POINT_RENAME(uprv_decNumberCompareTotalMag)\n#define uprv_decNumberCopy U_ICU_ENTRY_POINT_RENAME(uprv_decNumberCopy)\n#define uprv_decNumberCopyAbs U_ICU_ENTRY_POINT_RENAME(uprv_decNumberCopyAbs)\n#define uprv_decNumberCopyNegate U_ICU_ENTRY_POINT_RENAME(uprv_decNumberCopyNegate)\n#define uprv_decNumberCopySign U_ICU_ENTRY_POINT_RENAME(uprv_decNumberCopySign)\n#define uprv_decNumberDivide U_ICU_ENTRY_POINT_RENAME(uprv_decNumberDivide)\n#define uprv_decNumberDivideInteger U_ICU_ENTRY_POINT_RENAME(uprv_decNumberDivideInteger)\n#define uprv_decNumberExp U_ICU_ENTRY_POINT_RENAME(uprv_decNumberExp)\n#define uprv_decNumberFMA U_ICU_ENTRY_POINT_RENAME(uprv_decNumberFMA)\n#define uprv_decNumberFromInt32 U_ICU_ENTRY_POINT_RENAME(uprv_decNumberFromInt32)\n#define uprv_decNumberFromString U_ICU_ENTRY_POINT_RENAME(uprv_decNumberFromString)\n#define uprv_decNumberFromUInt32 U_ICU_ENTRY_POINT_RENAME(uprv_decNumberFromUInt32)\n#define uprv_decNumberGetBCD U_ICU_ENTRY_POINT_RENAME(uprv_decNumberGetBCD)\n#define uprv_decNumberInvert U_ICU_ENTRY_POINT_RENAME(uprv_decNumberInvert)\n#define uprv_decNumberIsNormal U_ICU_ENTRY_POINT_RENAME(uprv_decNumberIsNormal)\n#define uprv_decNumberIsSubnormal U_ICU_ENTRY_POINT_RENAME(uprv_decNumberIsSubnormal)\n#define uprv_decNumberLn U_ICU_ENTRY_POINT_RENAME(uprv_decNumberLn)\n#define uprv_decNumberLog10 U_ICU_ENTRY_POINT_RENAME(uprv_decNumberLog10)\n#define uprv_decNumberLogB U_ICU_ENTRY_POINT_RENAME(uprv_decNumberLogB)\n#define uprv_decNumberMax U_ICU_ENTRY_POINT_RENAME(uprv_decNumberMax)\n#define uprv_decNumberMaxMag U_ICU_ENTRY_POINT_RENAME(uprv_decNumberMaxMag)\n#define uprv_decNumberMin U_ICU_ENTRY_POINT_RENAME(uprv_decNumberMin)\n#define uprv_decNumberMinMag U_ICU_ENTRY_POINT_RENAME(uprv_decNumberMinMag)\n#define uprv_decNumberMinus U_ICU_ENTRY_POINT_RENAME(uprv_decNumberMinus)\n#define uprv_decNumberMultiply U_ICU_ENTRY_POINT_RENAME(uprv_decNumberMultiply)\n#define uprv_decNumberNextMinus U_ICU_ENTRY_POINT_RENAME(uprv_decNumberNextMinus)\n#define uprv_decNumberNextPlus U_ICU_ENTRY_POINT_RENAME(uprv_decNumberNextPlus)\n#define uprv_decNumberNextToward U_ICU_ENTRY_POINT_RENAME(uprv_decNumberNextToward)\n#define uprv_decNumberNormalize U_ICU_ENTRY_POINT_RENAME(uprv_decNumberNormalize)\n#define uprv_decNumberOr U_ICU_ENTRY_POINT_RENAME(uprv_decNumberOr)\n#define uprv_decNumberPlus U_ICU_ENTRY_POINT_RENAME(uprv_decNumberPlus)\n#define uprv_decNumberPower U_ICU_ENTRY_POINT_RENAME(uprv_decNumberPower)\n#define uprv_decNumberQuantize U_ICU_ENTRY_POINT_RENAME(uprv_decNumberQuantize)\n#define uprv_decNumberReduce U_ICU_ENTRY_POINT_RENAME(uprv_decNumberReduce)\n#define uprv_decNumberRemainder U_ICU_ENTRY_POINT_RENAME(uprv_decNumberRemainder)\n#define uprv_decNumberRemainderNear U_ICU_ENTRY_POINT_RENAME(uprv_decNumberRemainderNear)\n#define uprv_decNumberRescale U_ICU_ENTRY_POINT_RENAME(uprv_decNumberRescale)\n#define uprv_decNumberRotate U_ICU_ENTRY_POINT_RENAME(uprv_decNumberRotate)\n#define uprv_decNumberSameQuantum U_ICU_ENTRY_POINT_RENAME(uprv_decNumberSameQuantum)\n#define uprv_decNumberScaleB U_ICU_ENTRY_POINT_RENAME(uprv_decNumberScaleB)\n#define uprv_decNumberSetBCD U_ICU_ENTRY_POINT_RENAME(uprv_decNumberSetBCD)\n#define uprv_decNumberShift U_ICU_ENTRY_POINT_RENAME(uprv_decNumberShift)\n#define uprv_decNumberSquareRoot U_ICU_ENTRY_POINT_RENAME(uprv_decNumberSquareRoot)\n#define uprv_decNumberSubtract U_ICU_ENTRY_POINT_RENAME(uprv_decNumberSubtract)\n#define uprv_decNumberToEngString U_ICU_ENTRY_POINT_RENAME(uprv_decNumberToEngString)\n#define uprv_decNumberToInt32 U_ICU_ENTRY_POINT_RENAME(uprv_decNumberToInt32)\n#define uprv_decNumberToIntegralExact U_ICU_ENTRY_POINT_RENAME(uprv_decNumberToIntegralExact)\n#define uprv_decNumberToIntegralValue U_ICU_ENTRY_POINT_RENAME(uprv_decNumberToIntegralValue)\n#define uprv_decNumberToString U_ICU_ENTRY_POINT_RENAME(uprv_decNumberToString)\n#define uprv_decNumberToUInt32 U_ICU_ENTRY_POINT_RENAME(uprv_decNumberToUInt32)\n#define uprv_decNumberTrim U_ICU_ENTRY_POINT_RENAME(uprv_decNumberTrim)\n#define uprv_decNumberVersion U_ICU_ENTRY_POINT_RENAME(uprv_decNumberVersion)\n#define uprv_decNumberXor U_ICU_ENTRY_POINT_RENAME(uprv_decNumberXor)\n#define uprv_decNumberZero U_ICU_ENTRY_POINT_RENAME(uprv_decNumberZero)\n#define uprv_deleteUObject U_ICU_ENTRY_POINT_RENAME(uprv_deleteUObject)\n#define uprv_delete_collIterate U_ICU_ENTRY_POINT_RENAME(uprv_delete_collIterate)\n#define uprv_dl_close U_ICU_ENTRY_POINT_RENAME(uprv_dl_close)\n#define uprv_dl_open U_ICU_ENTRY_POINT_RENAME(uprv_dl_open)\n#define uprv_dlsym_func U_ICU_ENTRY_POINT_RENAME(uprv_dlsym_func)\n#define uprv_eastrncpy U_ICU_ENTRY_POINT_RENAME(uprv_eastrncpy)\n#define uprv_ebcdicFromAscii U_ICU_ENTRY_POINT_RENAME(uprv_ebcdicFromAscii)\n#define uprv_ebcdicToLowercaseAscii U_ICU_ENTRY_POINT_RENAME(uprv_ebcdicToLowercaseAscii)\n#define uprv_ebcdictolower U_ICU_ENTRY_POINT_RENAME(uprv_ebcdictolower)\n#define uprv_fabs U_ICU_ENTRY_POINT_RENAME(uprv_fabs)\n#define uprv_floor U_ICU_ENTRY_POINT_RENAME(uprv_floor)\n#define uprv_fmax U_ICU_ENTRY_POINT_RENAME(uprv_fmax)\n#define uprv_fmin U_ICU_ENTRY_POINT_RENAME(uprv_fmin)\n#define uprv_fmod U_ICU_ENTRY_POINT_RENAME(uprv_fmod)\n#define uprv_free U_ICU_ENTRY_POINT_RENAME(uprv_free)\n#define uprv_getCharNameCharacters U_ICU_ENTRY_POINT_RENAME(uprv_getCharNameCharacters)\n#define uprv_getDefaultCodepage U_ICU_ENTRY_POINT_RENAME(uprv_getDefaultCodepage)\n#define uprv_getDefaultLocaleID U_ICU_ENTRY_POINT_RENAME(uprv_getDefaultLocaleID)\n#define uprv_getInfinity U_ICU_ENTRY_POINT_RENAME(uprv_getInfinity)\n#define uprv_getMaxCharNameLength U_ICU_ENTRY_POINT_RENAME(uprv_getMaxCharNameLength)\n#define uprv_getMaxValues U_ICU_ENTRY_POINT_RENAME(uprv_getMaxValues)\n#define uprv_getNaN U_ICU_ENTRY_POINT_RENAME(uprv_getNaN)\n#define uprv_getRawUTCtime U_ICU_ENTRY_POINT_RENAME(uprv_getRawUTCtime)\n#define uprv_getStaticCurrencyName U_ICU_ENTRY_POINT_RENAME(uprv_getStaticCurrencyName)\n#define uprv_getUTCtime U_ICU_ENTRY_POINT_RENAME(uprv_getUTCtime)\n#define uprv_haveProperties U_ICU_ENTRY_POINT_RENAME(uprv_haveProperties)\n#define uprv_init_collIterate U_ICU_ENTRY_POINT_RENAME(uprv_init_collIterate)\n#define uprv_init_pce U_ICU_ENTRY_POINT_RENAME(uprv_init_pce)\n#define uprv_int32Comparator U_ICU_ENTRY_POINT_RENAME(uprv_int32Comparator)\n#define uprv_isASCIILetter U_ICU_ENTRY_POINT_RENAME(uprv_isASCIILetter)\n#define uprv_isInfinite U_ICU_ENTRY_POINT_RENAME(uprv_isInfinite)\n#define uprv_isInvariantString U_ICU_ENTRY_POINT_RENAME(uprv_isInvariantString)\n#define uprv_isInvariantUString U_ICU_ENTRY_POINT_RENAME(uprv_isInvariantUString)\n#define uprv_isNaN U_ICU_ENTRY_POINT_RENAME(uprv_isNaN)\n#define uprv_isNegativeInfinity U_ICU_ENTRY_POINT_RENAME(uprv_isNegativeInfinity)\n#define uprv_isPositiveInfinity U_ICU_ENTRY_POINT_RENAME(uprv_isPositiveInfinity)\n#define uprv_itou U_ICU_ENTRY_POINT_RENAME(uprv_itou)\n#define uprv_log U_ICU_ENTRY_POINT_RENAME(uprv_log)\n#define uprv_malloc U_ICU_ENTRY_POINT_RENAME(uprv_malloc)\n#define uprv_mapFile U_ICU_ENTRY_POINT_RENAME(uprv_mapFile)\n#define uprv_max U_ICU_ENTRY_POINT_RENAME(uprv_max)\n#define uprv_maxMantissa U_ICU_ENTRY_POINT_RENAME(uprv_maxMantissa)\n#define uprv_maximumPtr U_ICU_ENTRY_POINT_RENAME(uprv_maximumPtr)\n#define uprv_min U_ICU_ENTRY_POINT_RENAME(uprv_min)\n#define uprv_modf U_ICU_ENTRY_POINT_RENAME(uprv_modf)\n#define uprv_new_collIterate U_ICU_ENTRY_POINT_RENAME(uprv_new_collIterate)\n#define uprv_parseCurrency U_ICU_ENTRY_POINT_RENAME(uprv_parseCurrency)\n#define uprv_pathIsAbsolute U_ICU_ENTRY_POINT_RENAME(uprv_pathIsAbsolute)\n#define uprv_pow U_ICU_ENTRY_POINT_RENAME(uprv_pow)\n#define uprv_pow10 U_ICU_ENTRY_POINT_RENAME(uprv_pow10)\n#define uprv_realloc U_ICU_ENTRY_POINT_RENAME(uprv_realloc)\n#define uprv_round U_ICU_ENTRY_POINT_RENAME(uprv_round)\n#define uprv_sortArray U_ICU_ENTRY_POINT_RENAME(uprv_sortArray)\n#define uprv_strCompare U_ICU_ENTRY_POINT_RENAME(uprv_strCompare)\n#define uprv_strdup U_ICU_ENTRY_POINT_RENAME(uprv_strdup)\n#define uprv_stricmp U_ICU_ENTRY_POINT_RENAME(uprv_stricmp)\n#define uprv_strndup U_ICU_ENTRY_POINT_RENAME(uprv_strndup)\n#define uprv_strnicmp U_ICU_ENTRY_POINT_RENAME(uprv_strnicmp)\n#define uprv_syntaxError U_ICU_ENTRY_POINT_RENAME(uprv_syntaxError)\n#define uprv_timezone U_ICU_ENTRY_POINT_RENAME(uprv_timezone)\n#define uprv_toupper U_ICU_ENTRY_POINT_RENAME(uprv_toupper)\n#define uprv_trunc U_ICU_ENTRY_POINT_RENAME(uprv_trunc)\n#define uprv_tzname U_ICU_ENTRY_POINT_RENAME(uprv_tzname)\n#define uprv_tzset U_ICU_ENTRY_POINT_RENAME(uprv_tzset)\n#define uprv_uca_addAnElement U_ICU_ENTRY_POINT_RENAME(uprv_uca_addAnElement)\n#define uprv_uca_assembleTable U_ICU_ENTRY_POINT_RENAME(uprv_uca_assembleTable)\n#define uprv_uca_canonicalClosure U_ICU_ENTRY_POINT_RENAME(uprv_uca_canonicalClosure)\n#define uprv_uca_closeTempTable U_ICU_ENTRY_POINT_RENAME(uprv_uca_closeTempTable)\n#define uprv_uca_getCodePointFromRaw U_ICU_ENTRY_POINT_RENAME(uprv_uca_getCodePointFromRaw)\n#define uprv_uca_getImplicitFromRaw U_ICU_ENTRY_POINT_RENAME(uprv_uca_getImplicitFromRaw)\n#define uprv_uca_getRawFromCodePoint U_ICU_ENTRY_POINT_RENAME(uprv_uca_getRawFromCodePoint)\n#define uprv_uca_getRawFromImplicit U_ICU_ENTRY_POINT_RENAME(uprv_uca_getRawFromImplicit)\n#define uprv_uca_initImplicitConstants U_ICU_ENTRY_POINT_RENAME(uprv_uca_initImplicitConstants)\n#define uprv_uca_initTempTable U_ICU_ENTRY_POINT_RENAME(uprv_uca_initTempTable)\n#define uprv_uint16Comparator U_ICU_ENTRY_POINT_RENAME(uprv_uint16Comparator)\n#define uprv_uint32Comparator U_ICU_ENTRY_POINT_RENAME(uprv_uint32Comparator)\n#define uprv_unmapFile U_ICU_ENTRY_POINT_RENAME(uprv_unmapFile)\n#define upvec_cloneArray U_ICU_ENTRY_POINT_RENAME(upvec_cloneArray)\n#define upvec_close U_ICU_ENTRY_POINT_RENAME(upvec_close)\n#define upvec_compact U_ICU_ENTRY_POINT_RENAME(upvec_compact)\n#define upvec_compactToUTrie2Handler U_ICU_ENTRY_POINT_RENAME(upvec_compactToUTrie2Handler)\n#define upvec_compactToUTrie2WithRowIndexes U_ICU_ENTRY_POINT_RENAME(upvec_compactToUTrie2WithRowIndexes)\n#define upvec_getArray U_ICU_ENTRY_POINT_RENAME(upvec_getArray)\n#define upvec_getRow U_ICU_ENTRY_POINT_RENAME(upvec_getRow)\n#define upvec_getValue U_ICU_ENTRY_POINT_RENAME(upvec_getValue)\n#define upvec_open U_ICU_ENTRY_POINT_RENAME(upvec_open)\n#define upvec_setValue U_ICU_ENTRY_POINT_RENAME(upvec_setValue)\n#define uregex_appendReplacement U_ICU_ENTRY_POINT_RENAME(uregex_appendReplacement)\n#define uregex_appendReplacementUText U_ICU_ENTRY_POINT_RENAME(uregex_appendReplacementUText)\n#define uregex_appendTail U_ICU_ENTRY_POINT_RENAME(uregex_appendTail)\n#define uregex_appendTailUText U_ICU_ENTRY_POINT_RENAME(uregex_appendTailUText)\n#define uregex_clone U_ICU_ENTRY_POINT_RENAME(uregex_clone)\n#define uregex_close U_ICU_ENTRY_POINT_RENAME(uregex_close)\n#define uregex_end U_ICU_ENTRY_POINT_RENAME(uregex_end)\n#define uregex_end64 U_ICU_ENTRY_POINT_RENAME(uregex_end64)\n#define uregex_find U_ICU_ENTRY_POINT_RENAME(uregex_find)\n#define uregex_find64 U_ICU_ENTRY_POINT_RENAME(uregex_find64)\n#define uregex_findNext U_ICU_ENTRY_POINT_RENAME(uregex_findNext)\n#define uregex_flags U_ICU_ENTRY_POINT_RENAME(uregex_flags)\n#define uregex_getFindProgressCallback U_ICU_ENTRY_POINT_RENAME(uregex_getFindProgressCallback)\n#define uregex_getMatchCallback U_ICU_ENTRY_POINT_RENAME(uregex_getMatchCallback)\n#define uregex_getStackLimit U_ICU_ENTRY_POINT_RENAME(uregex_getStackLimit)\n#define uregex_getText U_ICU_ENTRY_POINT_RENAME(uregex_getText)\n#define uregex_getTimeLimit U_ICU_ENTRY_POINT_RENAME(uregex_getTimeLimit)\n#define uregex_getUText U_ICU_ENTRY_POINT_RENAME(uregex_getUText)\n#define uregex_group U_ICU_ENTRY_POINT_RENAME(uregex_group)\n#define uregex_groupCount U_ICU_ENTRY_POINT_RENAME(uregex_groupCount)\n#define uregex_groupUText U_ICU_ENTRY_POINT_RENAME(uregex_groupUText)\n#define uregex_groupUTextDeep U_ICU_ENTRY_POINT_RENAME(uregex_groupUTextDeep)\n#define uregex_hasAnchoringBounds U_ICU_ENTRY_POINT_RENAME(uregex_hasAnchoringBounds)\n#define uregex_hasTransparentBounds U_ICU_ENTRY_POINT_RENAME(uregex_hasTransparentBounds)\n#define uregex_hitEnd U_ICU_ENTRY_POINT_RENAME(uregex_hitEnd)\n#define uregex_lookingAt U_ICU_ENTRY_POINT_RENAME(uregex_lookingAt)\n#define uregex_lookingAt64 U_ICU_ENTRY_POINT_RENAME(uregex_lookingAt64)\n#define uregex_matches U_ICU_ENTRY_POINT_RENAME(uregex_matches)\n#define uregex_matches64 U_ICU_ENTRY_POINT_RENAME(uregex_matches64)\n#define uregex_open U_ICU_ENTRY_POINT_RENAME(uregex_open)\n#define uregex_openC U_ICU_ENTRY_POINT_RENAME(uregex_openC)\n#define uregex_openUText U_ICU_ENTRY_POINT_RENAME(uregex_openUText)\n#define uregex_pattern U_ICU_ENTRY_POINT_RENAME(uregex_pattern)\n#define uregex_patternUText U_ICU_ENTRY_POINT_RENAME(uregex_patternUText)\n#define uregex_refreshUText U_ICU_ENTRY_POINT_RENAME(uregex_refreshUText)\n#define uregex_regionEnd U_ICU_ENTRY_POINT_RENAME(uregex_regionEnd)\n#define uregex_regionEnd64 U_ICU_ENTRY_POINT_RENAME(uregex_regionEnd64)\n#define uregex_regionStart U_ICU_ENTRY_POINT_RENAME(uregex_regionStart)\n#define uregex_regionStart64 U_ICU_ENTRY_POINT_RENAME(uregex_regionStart64)\n#define uregex_replaceAll U_ICU_ENTRY_POINT_RENAME(uregex_replaceAll)\n#define uregex_replaceAllUText U_ICU_ENTRY_POINT_RENAME(uregex_replaceAllUText)\n#define uregex_replaceFirst U_ICU_ENTRY_POINT_RENAME(uregex_replaceFirst)\n#define uregex_replaceFirstUText U_ICU_ENTRY_POINT_RENAME(uregex_replaceFirstUText)\n#define uregex_requireEnd U_ICU_ENTRY_POINT_RENAME(uregex_requireEnd)\n#define uregex_reset U_ICU_ENTRY_POINT_RENAME(uregex_reset)\n#define uregex_reset64 U_ICU_ENTRY_POINT_RENAME(uregex_reset64)\n#define uregex_setFindProgressCallback U_ICU_ENTRY_POINT_RENAME(uregex_setFindProgressCallback)\n#define uregex_setMatchCallback U_ICU_ENTRY_POINT_RENAME(uregex_setMatchCallback)\n#define uregex_setRegion U_ICU_ENTRY_POINT_RENAME(uregex_setRegion)\n#define uregex_setRegion64 U_ICU_ENTRY_POINT_RENAME(uregex_setRegion64)\n#define uregex_setRegionAndStart U_ICU_ENTRY_POINT_RENAME(uregex_setRegionAndStart)\n#define uregex_setStackLimit U_ICU_ENTRY_POINT_RENAME(uregex_setStackLimit)\n#define uregex_setText U_ICU_ENTRY_POINT_RENAME(uregex_setText)\n#define uregex_setTimeLimit U_ICU_ENTRY_POINT_RENAME(uregex_setTimeLimit)\n#define uregex_setUText U_ICU_ENTRY_POINT_RENAME(uregex_setUText)\n#define uregex_split U_ICU_ENTRY_POINT_RENAME(uregex_split)\n#define uregex_splitUText U_ICU_ENTRY_POINT_RENAME(uregex_splitUText)\n#define uregex_start U_ICU_ENTRY_POINT_RENAME(uregex_start)\n#define uregex_start64 U_ICU_ENTRY_POINT_RENAME(uregex_start64)\n#define uregex_ucstr_unescape_charAt U_ICU_ENTRY_POINT_RENAME(uregex_ucstr_unescape_charAt)\n#define uregex_useAnchoringBounds U_ICU_ENTRY_POINT_RENAME(uregex_useAnchoringBounds)\n#define uregex_useTransparentBounds U_ICU_ENTRY_POINT_RENAME(uregex_useTransparentBounds)\n#define uregex_utext_unescape_charAt U_ICU_ENTRY_POINT_RENAME(uregex_utext_unescape_charAt)\n#define ures_close U_ICU_ENTRY_POINT_RENAME(ures_close)\n#define ures_copyResb U_ICU_ENTRY_POINT_RENAME(ures_copyResb)\n#define ures_countArrayItems U_ICU_ENTRY_POINT_RENAME(ures_countArrayItems)\n#define ures_findResource U_ICU_ENTRY_POINT_RENAME(ures_findResource)\n#define ures_findSubResource U_ICU_ENTRY_POINT_RENAME(ures_findSubResource)\n#define ures_getBinary U_ICU_ENTRY_POINT_RENAME(ures_getBinary)\n#define ures_getByIndex U_ICU_ENTRY_POINT_RENAME(ures_getByIndex)\n#define ures_getByKey U_ICU_ENTRY_POINT_RENAME(ures_getByKey)\n#define ures_getByKeyWithFallback U_ICU_ENTRY_POINT_RENAME(ures_getByKeyWithFallback)\n#define ures_getFunctionalEquivalent U_ICU_ENTRY_POINT_RENAME(ures_getFunctionalEquivalent)\n#define ures_getInt U_ICU_ENTRY_POINT_RENAME(ures_getInt)\n#define ures_getIntVector U_ICU_ENTRY_POINT_RENAME(ures_getIntVector)\n#define ures_getKey U_ICU_ENTRY_POINT_RENAME(ures_getKey)\n#define ures_getKeywordValues U_ICU_ENTRY_POINT_RENAME(ures_getKeywordValues)\n#define ures_getLocale U_ICU_ENTRY_POINT_RENAME(ures_getLocale)\n#define ures_getLocaleByType U_ICU_ENTRY_POINT_RENAME(ures_getLocaleByType)\n#define ures_getLocaleInternal U_ICU_ENTRY_POINT_RENAME(ures_getLocaleInternal)\n#define ures_getName U_ICU_ENTRY_POINT_RENAME(ures_getName)\n#define ures_getNextResource U_ICU_ENTRY_POINT_RENAME(ures_getNextResource)\n#define ures_getNextString U_ICU_ENTRY_POINT_RENAME(ures_getNextString)\n#define ures_getSize U_ICU_ENTRY_POINT_RENAME(ures_getSize)\n#define ures_getString U_ICU_ENTRY_POINT_RENAME(ures_getString)\n#define ures_getStringByIndex U_ICU_ENTRY_POINT_RENAME(ures_getStringByIndex)\n#define ures_getStringByKey U_ICU_ENTRY_POINT_RENAME(ures_getStringByKey)\n#define ures_getStringByKeyWithFallback U_ICU_ENTRY_POINT_RENAME(ures_getStringByKeyWithFallback)\n#define ures_getType U_ICU_ENTRY_POINT_RENAME(ures_getType)\n#define ures_getUInt U_ICU_ENTRY_POINT_RENAME(ures_getUInt)\n#define ures_getUTF8String U_ICU_ENTRY_POINT_RENAME(ures_getUTF8String)\n#define ures_getUTF8StringByIndex U_ICU_ENTRY_POINT_RENAME(ures_getUTF8StringByIndex)\n#define ures_getUTF8StringByKey U_ICU_ENTRY_POINT_RENAME(ures_getUTF8StringByKey)\n#define ures_getVersion U_ICU_ENTRY_POINT_RENAME(ures_getVersion)\n#define ures_getVersionByKey U_ICU_ENTRY_POINT_RENAME(ures_getVersionByKey)\n#define ures_getVersionNumber U_ICU_ENTRY_POINT_RENAME(ures_getVersionNumber)\n#define ures_getVersionNumberInternal U_ICU_ENTRY_POINT_RENAME(ures_getVersionNumberInternal)\n#define ures_hasNext U_ICU_ENTRY_POINT_RENAME(ures_hasNext)\n#define ures_initStackObject U_ICU_ENTRY_POINT_RENAME(ures_initStackObject)\n#define ures_open U_ICU_ENTRY_POINT_RENAME(ures_open)\n#define ures_openAvailableLocales U_ICU_ENTRY_POINT_RENAME(ures_openAvailableLocales)\n#define ures_openDirect U_ICU_ENTRY_POINT_RENAME(ures_openDirect)\n#define ures_openFillIn U_ICU_ENTRY_POINT_RENAME(ures_openFillIn)\n#define ures_openU U_ICU_ENTRY_POINT_RENAME(ures_openU)\n#define ures_resetIterator U_ICU_ENTRY_POINT_RENAME(ures_resetIterator)\n#define ures_swap U_ICU_ENTRY_POINT_RENAME(ures_swap)\n#define uscript_closeRun U_ICU_ENTRY_POINT_RENAME(uscript_closeRun)\n#define uscript_getCode U_ICU_ENTRY_POINT_RENAME(uscript_getCode)\n#define uscript_getName U_ICU_ENTRY_POINT_RENAME(uscript_getName)\n#define uscript_getScript U_ICU_ENTRY_POINT_RENAME(uscript_getScript)\n#define uscript_getScriptExtensions U_ICU_ENTRY_POINT_RENAME(uscript_getScriptExtensions)\n#define uscript_getShortName U_ICU_ENTRY_POINT_RENAME(uscript_getShortName)\n#define uscript_hasScript U_ICU_ENTRY_POINT_RENAME(uscript_hasScript)\n#define uscript_nextRun U_ICU_ENTRY_POINT_RENAME(uscript_nextRun)\n#define uscript_openRun U_ICU_ENTRY_POINT_RENAME(uscript_openRun)\n#define uscript_resetRun U_ICU_ENTRY_POINT_RENAME(uscript_resetRun)\n#define uscript_setRunText U_ICU_ENTRY_POINT_RENAME(uscript_setRunText)\n#define usearch_close U_ICU_ENTRY_POINT_RENAME(usearch_close)\n#define usearch_first U_ICU_ENTRY_POINT_RENAME(usearch_first)\n#define usearch_following U_ICU_ENTRY_POINT_RENAME(usearch_following)\n#define usearch_getAttribute U_ICU_ENTRY_POINT_RENAME(usearch_getAttribute)\n#define usearch_getBreakIterator U_ICU_ENTRY_POINT_RENAME(usearch_getBreakIterator)\n#define usearch_getCollator U_ICU_ENTRY_POINT_RENAME(usearch_getCollator)\n#define usearch_getMatchedLength U_ICU_ENTRY_POINT_RENAME(usearch_getMatchedLength)\n#define usearch_getMatchedStart U_ICU_ENTRY_POINT_RENAME(usearch_getMatchedStart)\n#define usearch_getMatchedText U_ICU_ENTRY_POINT_RENAME(usearch_getMatchedText)\n#define usearch_getOffset U_ICU_ENTRY_POINT_RENAME(usearch_getOffset)\n#define usearch_getPattern U_ICU_ENTRY_POINT_RENAME(usearch_getPattern)\n#define usearch_getText U_ICU_ENTRY_POINT_RENAME(usearch_getText)\n#define usearch_handleNextCanonical U_ICU_ENTRY_POINT_RENAME(usearch_handleNextCanonical)\n#define usearch_handleNextExact U_ICU_ENTRY_POINT_RENAME(usearch_handleNextExact)\n#define usearch_handlePreviousCanonical U_ICU_ENTRY_POINT_RENAME(usearch_handlePreviousCanonical)\n#define usearch_handlePreviousExact U_ICU_ENTRY_POINT_RENAME(usearch_handlePreviousExact)\n#define usearch_last U_ICU_ENTRY_POINT_RENAME(usearch_last)\n#define usearch_next U_ICU_ENTRY_POINT_RENAME(usearch_next)\n#define usearch_open U_ICU_ENTRY_POINT_RENAME(usearch_open)\n#define usearch_openFromCollator U_ICU_ENTRY_POINT_RENAME(usearch_openFromCollator)\n#define usearch_preceding U_ICU_ENTRY_POINT_RENAME(usearch_preceding)\n#define usearch_previous U_ICU_ENTRY_POINT_RENAME(usearch_previous)\n#define usearch_reset U_ICU_ENTRY_POINT_RENAME(usearch_reset)\n#define usearch_search U_ICU_ENTRY_POINT_RENAME(usearch_search)\n#define usearch_searchBackwards U_ICU_ENTRY_POINT_RENAME(usearch_searchBackwards)\n#define usearch_setAttribute U_ICU_ENTRY_POINT_RENAME(usearch_setAttribute)\n#define usearch_setBreakIterator U_ICU_ENTRY_POINT_RENAME(usearch_setBreakIterator)\n#define usearch_setCollator U_ICU_ENTRY_POINT_RENAME(usearch_setCollator)\n#define usearch_setOffset U_ICU_ENTRY_POINT_RENAME(usearch_setOffset)\n#define usearch_setPattern U_ICU_ENTRY_POINT_RENAME(usearch_setPattern)\n#define usearch_setText U_ICU_ENTRY_POINT_RENAME(usearch_setText)\n#define uset_add U_ICU_ENTRY_POINT_RENAME(uset_add)\n#define uset_addAll U_ICU_ENTRY_POINT_RENAME(uset_addAll)\n#define uset_addAllCodePoints U_ICU_ENTRY_POINT_RENAME(uset_addAllCodePoints)\n#define uset_addRange U_ICU_ENTRY_POINT_RENAME(uset_addRange)\n#define uset_addString U_ICU_ENTRY_POINT_RENAME(uset_addString)\n#define uset_applyIntPropertyValue U_ICU_ENTRY_POINT_RENAME(uset_applyIntPropertyValue)\n#define uset_applyPattern U_ICU_ENTRY_POINT_RENAME(uset_applyPattern)\n#define uset_applyPropertyAlias U_ICU_ENTRY_POINT_RENAME(uset_applyPropertyAlias)\n#define uset_charAt U_ICU_ENTRY_POINT_RENAME(uset_charAt)\n#define uset_clear U_ICU_ENTRY_POINT_RENAME(uset_clear)\n#define uset_clone U_ICU_ENTRY_POINT_RENAME(uset_clone)\n#define uset_cloneAsThawed U_ICU_ENTRY_POINT_RENAME(uset_cloneAsThawed)\n#define uset_close U_ICU_ENTRY_POINT_RENAME(uset_close)\n#define uset_closeOver U_ICU_ENTRY_POINT_RENAME(uset_closeOver)\n#define uset_compact U_ICU_ENTRY_POINT_RENAME(uset_compact)\n#define uset_complement U_ICU_ENTRY_POINT_RENAME(uset_complement)\n#define uset_complementAll U_ICU_ENTRY_POINT_RENAME(uset_complementAll)\n#define uset_contains U_ICU_ENTRY_POINT_RENAME(uset_contains)\n#define uset_containsAll U_ICU_ENTRY_POINT_RENAME(uset_containsAll)\n#define uset_containsAllCodePoints U_ICU_ENTRY_POINT_RENAME(uset_containsAllCodePoints)\n#define uset_containsNone U_ICU_ENTRY_POINT_RENAME(uset_containsNone)\n#define uset_containsRange U_ICU_ENTRY_POINT_RENAME(uset_containsRange)\n#define uset_containsSome U_ICU_ENTRY_POINT_RENAME(uset_containsSome)\n#define uset_containsString U_ICU_ENTRY_POINT_RENAME(uset_containsString)\n#define uset_equals U_ICU_ENTRY_POINT_RENAME(uset_equals)\n#define uset_freeze U_ICU_ENTRY_POINT_RENAME(uset_freeze)\n#define uset_getItem U_ICU_ENTRY_POINT_RENAME(uset_getItem)\n#define uset_getItemCount U_ICU_ENTRY_POINT_RENAME(uset_getItemCount)\n#define uset_getSerializedRange U_ICU_ENTRY_POINT_RENAME(uset_getSerializedRange)\n#define uset_getSerializedRangeCount U_ICU_ENTRY_POINT_RENAME(uset_getSerializedRangeCount)\n#define uset_getSerializedSet U_ICU_ENTRY_POINT_RENAME(uset_getSerializedSet)\n#define uset_indexOf U_ICU_ENTRY_POINT_RENAME(uset_indexOf)\n#define uset_isEmpty U_ICU_ENTRY_POINT_RENAME(uset_isEmpty)\n#define uset_isFrozen U_ICU_ENTRY_POINT_RENAME(uset_isFrozen)\n#define uset_open U_ICU_ENTRY_POINT_RENAME(uset_open)\n#define uset_openEmpty U_ICU_ENTRY_POINT_RENAME(uset_openEmpty)\n#define uset_openPattern U_ICU_ENTRY_POINT_RENAME(uset_openPattern)\n#define uset_openPatternOptions U_ICU_ENTRY_POINT_RENAME(uset_openPatternOptions)\n#define uset_remove U_ICU_ENTRY_POINT_RENAME(uset_remove)\n#define uset_removeAll U_ICU_ENTRY_POINT_RENAME(uset_removeAll)\n#define uset_removeAllStrings U_ICU_ENTRY_POINT_RENAME(uset_removeAllStrings)\n#define uset_removeRange U_ICU_ENTRY_POINT_RENAME(uset_removeRange)\n#define uset_removeString U_ICU_ENTRY_POINT_RENAME(uset_removeString)\n#define uset_resemblesPattern U_ICU_ENTRY_POINT_RENAME(uset_resemblesPattern)\n#define uset_retain U_ICU_ENTRY_POINT_RENAME(uset_retain)\n#define uset_retainAll U_ICU_ENTRY_POINT_RENAME(uset_retainAll)\n#define uset_serialize U_ICU_ENTRY_POINT_RENAME(uset_serialize)\n#define uset_serializedContains U_ICU_ENTRY_POINT_RENAME(uset_serializedContains)\n#define uset_set U_ICU_ENTRY_POINT_RENAME(uset_set)\n#define uset_setSerializedToOne U_ICU_ENTRY_POINT_RENAME(uset_setSerializedToOne)\n#define uset_size U_ICU_ENTRY_POINT_RENAME(uset_size)\n#define uset_span U_ICU_ENTRY_POINT_RENAME(uset_span)\n#define uset_spanBack U_ICU_ENTRY_POINT_RENAME(uset_spanBack)\n#define uset_spanBackUTF8 U_ICU_ENTRY_POINT_RENAME(uset_spanBackUTF8)\n#define uset_spanUTF8 U_ICU_ENTRY_POINT_RENAME(uset_spanUTF8)\n#define uset_toPattern U_ICU_ENTRY_POINT_RENAME(uset_toPattern)\n#define uspoof_areConfusable U_ICU_ENTRY_POINT_RENAME(uspoof_areConfusable)\n#define uspoof_areConfusableUTF8 U_ICU_ENTRY_POINT_RENAME(uspoof_areConfusableUTF8)\n#define uspoof_areConfusableUnicodeString U_ICU_ENTRY_POINT_RENAME(uspoof_areConfusableUnicodeString)\n#define uspoof_check U_ICU_ENTRY_POINT_RENAME(uspoof_check)\n#define uspoof_checkUTF8 U_ICU_ENTRY_POINT_RENAME(uspoof_checkUTF8)\n#define uspoof_checkUnicodeString U_ICU_ENTRY_POINT_RENAME(uspoof_checkUnicodeString)\n#define uspoof_clone U_ICU_ENTRY_POINT_RENAME(uspoof_clone)\n#define uspoof_close U_ICU_ENTRY_POINT_RENAME(uspoof_close)\n#define uspoof_getAllowedChars U_ICU_ENTRY_POINT_RENAME(uspoof_getAllowedChars)\n#define uspoof_getAllowedLocales U_ICU_ENTRY_POINT_RENAME(uspoof_getAllowedLocales)\n#define uspoof_getAllowedUnicodeSet U_ICU_ENTRY_POINT_RENAME(uspoof_getAllowedUnicodeSet)\n#define uspoof_getChecks U_ICU_ENTRY_POINT_RENAME(uspoof_getChecks)\n#define uspoof_getSkeleton U_ICU_ENTRY_POINT_RENAME(uspoof_getSkeleton)\n#define uspoof_getSkeletonUTF8 U_ICU_ENTRY_POINT_RENAME(uspoof_getSkeletonUTF8)\n#define uspoof_getSkeletonUnicodeString U_ICU_ENTRY_POINT_RENAME(uspoof_getSkeletonUnicodeString)\n#define uspoof_open U_ICU_ENTRY_POINT_RENAME(uspoof_open)\n#define uspoof_openFromSerialized U_ICU_ENTRY_POINT_RENAME(uspoof_openFromSerialized)\n#define uspoof_openFromSource U_ICU_ENTRY_POINT_RENAME(uspoof_openFromSource)\n#define uspoof_serialize U_ICU_ENTRY_POINT_RENAME(uspoof_serialize)\n#define uspoof_setAllowedChars U_ICU_ENTRY_POINT_RENAME(uspoof_setAllowedChars)\n#define uspoof_setAllowedLocales U_ICU_ENTRY_POINT_RENAME(uspoof_setAllowedLocales)\n#define uspoof_setAllowedUnicodeSet U_ICU_ENTRY_POINT_RENAME(uspoof_setAllowedUnicodeSet)\n#define uspoof_setChecks U_ICU_ENTRY_POINT_RENAME(uspoof_setChecks)\n#define uspoof_swap U_ICU_ENTRY_POINT_RENAME(uspoof_swap)\n#define usprep_close U_ICU_ENTRY_POINT_RENAME(usprep_close)\n#define usprep_open U_ICU_ENTRY_POINT_RENAME(usprep_open)\n#define usprep_openByType U_ICU_ENTRY_POINT_RENAME(usprep_openByType)\n#define usprep_prepare U_ICU_ENTRY_POINT_RENAME(usprep_prepare)\n#define usprep_swap U_ICU_ENTRY_POINT_RENAME(usprep_swap)\n#define ustr_hashCharsN U_ICU_ENTRY_POINT_RENAME(ustr_hashCharsN)\n#define ustr_hashICharsN U_ICU_ENTRY_POINT_RENAME(ustr_hashICharsN)\n#define ustr_hashUCharsN U_ICU_ENTRY_POINT_RENAME(ustr_hashUCharsN)\n#define ustrcase_internalFold U_ICU_ENTRY_POINT_RENAME(ustrcase_internalFold)\n#define ustrcase_internalToLower U_ICU_ENTRY_POINT_RENAME(ustrcase_internalToLower)\n#define ustrcase_internalToTitle U_ICU_ENTRY_POINT_RENAME(ustrcase_internalToTitle)\n#define ustrcase_internalToUpper U_ICU_ENTRY_POINT_RENAME(ustrcase_internalToUpper)\n#define ustrcase_map U_ICU_ENTRY_POINT_RENAME(ustrcase_map)\n#define ustrcase_setTempCaseMapLocale U_ICU_ENTRY_POINT_RENAME(ustrcase_setTempCaseMapLocale)\n#define utext_char32At U_ICU_ENTRY_POINT_RENAME(utext_char32At)\n#define utext_clone U_ICU_ENTRY_POINT_RENAME(utext_clone)\n#define utext_close U_ICU_ENTRY_POINT_RENAME(utext_close)\n#define utext_copy U_ICU_ENTRY_POINT_RENAME(utext_copy)\n#define utext_current32 U_ICU_ENTRY_POINT_RENAME(utext_current32)\n#define utext_equals U_ICU_ENTRY_POINT_RENAME(utext_equals)\n#define utext_extract U_ICU_ENTRY_POINT_RENAME(utext_extract)\n#define utext_freeze U_ICU_ENTRY_POINT_RENAME(utext_freeze)\n#define utext_getNativeIndex U_ICU_ENTRY_POINT_RENAME(utext_getNativeIndex)\n#define utext_getPreviousNativeIndex U_ICU_ENTRY_POINT_RENAME(utext_getPreviousNativeIndex)\n#define utext_hasMetaData U_ICU_ENTRY_POINT_RENAME(utext_hasMetaData)\n#define utext_isLengthExpensive U_ICU_ENTRY_POINT_RENAME(utext_isLengthExpensive)\n#define utext_isWritable U_ICU_ENTRY_POINT_RENAME(utext_isWritable)\n#define utext_moveIndex32 U_ICU_ENTRY_POINT_RENAME(utext_moveIndex32)\n#define utext_nativeLength U_ICU_ENTRY_POINT_RENAME(utext_nativeLength)\n#define utext_next32 U_ICU_ENTRY_POINT_RENAME(utext_next32)\n#define utext_next32From U_ICU_ENTRY_POINT_RENAME(utext_next32From)\n#define utext_openCharacterIterator U_ICU_ENTRY_POINT_RENAME(utext_openCharacterIterator)\n#define utext_openConstUnicodeString U_ICU_ENTRY_POINT_RENAME(utext_openConstUnicodeString)\n#define utext_openReplaceable U_ICU_ENTRY_POINT_RENAME(utext_openReplaceable)\n#define utext_openUChars U_ICU_ENTRY_POINT_RENAME(utext_openUChars)\n#define utext_openUTF8 U_ICU_ENTRY_POINT_RENAME(utext_openUTF8)\n#define utext_openUnicodeString U_ICU_ENTRY_POINT_RENAME(utext_openUnicodeString)\n#define utext_previous32 U_ICU_ENTRY_POINT_RENAME(utext_previous32)\n#define utext_previous32From U_ICU_ENTRY_POINT_RENAME(utext_previous32From)\n#define utext_replace U_ICU_ENTRY_POINT_RENAME(utext_replace)\n#define utext_setNativeIndex U_ICU_ENTRY_POINT_RENAME(utext_setNativeIndex)\n#define utext_setup U_ICU_ENTRY_POINT_RENAME(utext_setup)\n#define utf8_appendCharSafeBody U_ICU_ENTRY_POINT_RENAME(utf8_appendCharSafeBody)\n#define utf8_back1SafeBody U_ICU_ENTRY_POINT_RENAME(utf8_back1SafeBody)\n#define utf8_countTrailBytes U_ICU_ENTRY_POINT_RENAME(utf8_countTrailBytes)\n#define utf8_nextCharSafeBody U_ICU_ENTRY_POINT_RENAME(utf8_nextCharSafeBody)\n#define utf8_prevCharSafeBody U_ICU_ENTRY_POINT_RENAME(utf8_prevCharSafeBody)\n#define utmscale_fromInt64 U_ICU_ENTRY_POINT_RENAME(utmscale_fromInt64)\n#define utmscale_getTimeScaleValue U_ICU_ENTRY_POINT_RENAME(utmscale_getTimeScaleValue)\n#define utmscale_toInt64 U_ICU_ENTRY_POINT_RENAME(utmscale_toInt64)\n#define utrace_cleanup U_ICU_ENTRY_POINT_RENAME(utrace_cleanup)\n#define utrace_data U_ICU_ENTRY_POINT_RENAME(utrace_data)\n#define utrace_entry U_ICU_ENTRY_POINT_RENAME(utrace_entry)\n#define utrace_exit U_ICU_ENTRY_POINT_RENAME(utrace_exit)\n#define utrace_format U_ICU_ENTRY_POINT_RENAME(utrace_format)\n#define utrace_functionName U_ICU_ENTRY_POINT_RENAME(utrace_functionName)\n#define utrace_getFunctions U_ICU_ENTRY_POINT_RENAME(utrace_getFunctions)\n#define utrace_getLevel U_ICU_ENTRY_POINT_RENAME(utrace_getLevel)\n#define utrace_level U_ICU_ENTRY_POINT_RENAME(utrace_level)\n#define utrace_setFunctions U_ICU_ENTRY_POINT_RENAME(utrace_setFunctions)\n#define utrace_setLevel U_ICU_ENTRY_POINT_RENAME(utrace_setLevel)\n#define utrace_vformat U_ICU_ENTRY_POINT_RENAME(utrace_vformat)\n#define utrans_clone U_ICU_ENTRY_POINT_RENAME(utrans_clone)\n#define utrans_close U_ICU_ENTRY_POINT_RENAME(utrans_close)\n#define utrans_countAvailableIDs U_ICU_ENTRY_POINT_RENAME(utrans_countAvailableIDs)\n#define utrans_getAvailableID U_ICU_ENTRY_POINT_RENAME(utrans_getAvailableID)\n#define utrans_getID U_ICU_ENTRY_POINT_RENAME(utrans_getID)\n#define utrans_getUnicodeID U_ICU_ENTRY_POINT_RENAME(utrans_getUnicodeID)\n#define utrans_open U_ICU_ENTRY_POINT_RENAME(utrans_open)\n#define utrans_openIDs U_ICU_ENTRY_POINT_RENAME(utrans_openIDs)\n#define utrans_openInverse U_ICU_ENTRY_POINT_RENAME(utrans_openInverse)\n#define utrans_openU U_ICU_ENTRY_POINT_RENAME(utrans_openU)\n#define utrans_register U_ICU_ENTRY_POINT_RENAME(utrans_register)\n#define utrans_rep_caseContextIterator U_ICU_ENTRY_POINT_RENAME(utrans_rep_caseContextIterator)\n#define utrans_setFilter U_ICU_ENTRY_POINT_RENAME(utrans_setFilter)\n#define utrans_stripRules U_ICU_ENTRY_POINT_RENAME(utrans_stripRules)\n#define utrans_trans U_ICU_ENTRY_POINT_RENAME(utrans_trans)\n#define utrans_transIncremental U_ICU_ENTRY_POINT_RENAME(utrans_transIncremental)\n#define utrans_transIncrementalUChars U_ICU_ENTRY_POINT_RENAME(utrans_transIncrementalUChars)\n#define utrans_transUChars U_ICU_ENTRY_POINT_RENAME(utrans_transUChars)\n#define utrans_transliterator_cleanup U_ICU_ENTRY_POINT_RENAME(utrans_transliterator_cleanup)\n#define utrans_unregister U_ICU_ENTRY_POINT_RENAME(utrans_unregister)\n#define utrans_unregisterID U_ICU_ENTRY_POINT_RENAME(utrans_unregisterID)\n#define utrie2_clone U_ICU_ENTRY_POINT_RENAME(utrie2_clone)\n#define utrie2_cloneAsThawed U_ICU_ENTRY_POINT_RENAME(utrie2_cloneAsThawed)\n#define utrie2_close U_ICU_ENTRY_POINT_RENAME(utrie2_close)\n#define utrie2_enum U_ICU_ENTRY_POINT_RENAME(utrie2_enum)\n#define utrie2_enumForLeadSurrogate U_ICU_ENTRY_POINT_RENAME(utrie2_enumForLeadSurrogate)\n#define utrie2_freeze U_ICU_ENTRY_POINT_RENAME(utrie2_freeze)\n#define utrie2_fromUTrie U_ICU_ENTRY_POINT_RENAME(utrie2_fromUTrie)\n#define utrie2_get32 U_ICU_ENTRY_POINT_RENAME(utrie2_get32)\n#define utrie2_get32FromLeadSurrogateCodeUnit U_ICU_ENTRY_POINT_RENAME(utrie2_get32FromLeadSurrogateCodeUnit)\n#define utrie2_getVersion U_ICU_ENTRY_POINT_RENAME(utrie2_getVersion)\n#define utrie2_internalU8NextIndex U_ICU_ENTRY_POINT_RENAME(utrie2_internalU8NextIndex)\n#define utrie2_internalU8PrevIndex U_ICU_ENTRY_POINT_RENAME(utrie2_internalU8PrevIndex)\n#define utrie2_isFrozen U_ICU_ENTRY_POINT_RENAME(utrie2_isFrozen)\n#define utrie2_open U_ICU_ENTRY_POINT_RENAME(utrie2_open)\n#define utrie2_openDummy U_ICU_ENTRY_POINT_RENAME(utrie2_openDummy)\n#define utrie2_openFromSerialized U_ICU_ENTRY_POINT_RENAME(utrie2_openFromSerialized)\n#define utrie2_serialize U_ICU_ENTRY_POINT_RENAME(utrie2_serialize)\n#define utrie2_set32 U_ICU_ENTRY_POINT_RENAME(utrie2_set32)\n#define utrie2_set32ForLeadSurrogateCodeUnit U_ICU_ENTRY_POINT_RENAME(utrie2_set32ForLeadSurrogateCodeUnit)\n#define utrie2_setRange32 U_ICU_ENTRY_POINT_RENAME(utrie2_setRange32)\n#define utrie2_swap U_ICU_ENTRY_POINT_RENAME(utrie2_swap)\n#define utrie2_swapAnyVersion U_ICU_ENTRY_POINT_RENAME(utrie2_swapAnyVersion)\n#define utrie_clone U_ICU_ENTRY_POINT_RENAME(utrie_clone)\n#define utrie_close U_ICU_ENTRY_POINT_RENAME(utrie_close)\n#define utrie_defaultGetFoldingOffset U_ICU_ENTRY_POINT_RENAME(utrie_defaultGetFoldingOffset)\n#define utrie_enum U_ICU_ENTRY_POINT_RENAME(utrie_enum)\n#define utrie_get32 U_ICU_ENTRY_POINT_RENAME(utrie_get32)\n#define utrie_getData U_ICU_ENTRY_POINT_RENAME(utrie_getData)\n#define utrie_open U_ICU_ENTRY_POINT_RENAME(utrie_open)\n#define utrie_serialize U_ICU_ENTRY_POINT_RENAME(utrie_serialize)\n#define utrie_set32 U_ICU_ENTRY_POINT_RENAME(utrie_set32)\n#define utrie_setRange32 U_ICU_ENTRY_POINT_RENAME(utrie_setRange32)\n#define utrie_swap U_ICU_ENTRY_POINT_RENAME(utrie_swap)\n#define utrie_unserialize U_ICU_ENTRY_POINT_RENAME(utrie_unserialize)\n#define utrie_unserializeDummy U_ICU_ENTRY_POINT_RENAME(utrie_unserializeDummy)\n#define vzone_clone U_ICU_ENTRY_POINT_RENAME(vzone_clone)\n#define vzone_close U_ICU_ENTRY_POINT_RENAME(vzone_close)\n#define vzone_countTransitionRules U_ICU_ENTRY_POINT_RENAME(vzone_countTransitionRules)\n#define vzone_equals U_ICU_ENTRY_POINT_RENAME(vzone_equals)\n#define vzone_getDynamicClassID U_ICU_ENTRY_POINT_RENAME(vzone_getDynamicClassID)\n#define vzone_getLastModified U_ICU_ENTRY_POINT_RENAME(vzone_getLastModified)\n#define vzone_getNextTransition U_ICU_ENTRY_POINT_RENAME(vzone_getNextTransition)\n#define vzone_getOffset U_ICU_ENTRY_POINT_RENAME(vzone_getOffset)\n#define vzone_getOffset2 U_ICU_ENTRY_POINT_RENAME(vzone_getOffset2)\n#define vzone_getOffset3 U_ICU_ENTRY_POINT_RENAME(vzone_getOffset3)\n#define vzone_getPreviousTransition U_ICU_ENTRY_POINT_RENAME(vzone_getPreviousTransition)\n#define vzone_getRawOffset U_ICU_ENTRY_POINT_RENAME(vzone_getRawOffset)\n#define vzone_getStaticClassID U_ICU_ENTRY_POINT_RENAME(vzone_getStaticClassID)\n#define vzone_getTZURL U_ICU_ENTRY_POINT_RENAME(vzone_getTZURL)\n#define vzone_hasSameRules U_ICU_ENTRY_POINT_RENAME(vzone_hasSameRules)\n#define vzone_inDaylightTime U_ICU_ENTRY_POINT_RENAME(vzone_inDaylightTime)\n#define vzone_openData U_ICU_ENTRY_POINT_RENAME(vzone_openData)\n#define vzone_openID U_ICU_ENTRY_POINT_RENAME(vzone_openID)\n#define vzone_setLastModified U_ICU_ENTRY_POINT_RENAME(vzone_setLastModified)\n#define vzone_setRawOffset U_ICU_ENTRY_POINT_RENAME(vzone_setRawOffset)\n#define vzone_setTZURL U_ICU_ENTRY_POINT_RENAME(vzone_setTZURL)\n#define vzone_useDaylightTime U_ICU_ENTRY_POINT_RENAME(vzone_useDaylightTime)\n#define vzone_write U_ICU_ENTRY_POINT_RENAME(vzone_write)\n#define vzone_writeFromStart U_ICU_ENTRY_POINT_RENAME(vzone_writeFromStart)\n#define vzone_writeSimple U_ICU_ENTRY_POINT_RENAME(vzone_writeSimple)\n#define zrule_close U_ICU_ENTRY_POINT_RENAME(zrule_close)\n#define zrule_equals U_ICU_ENTRY_POINT_RENAME(zrule_equals)\n#define zrule_getDSTSavings U_ICU_ENTRY_POINT_RENAME(zrule_getDSTSavings)\n#define zrule_getName U_ICU_ENTRY_POINT_RENAME(zrule_getName)\n#define zrule_getRawOffset U_ICU_ENTRY_POINT_RENAME(zrule_getRawOffset)\n#define zrule_isEquivalentTo U_ICU_ENTRY_POINT_RENAME(zrule_isEquivalentTo)\n#define ztrans_adoptFrom U_ICU_ENTRY_POINT_RENAME(ztrans_adoptFrom)\n#define ztrans_adoptTo U_ICU_ENTRY_POINT_RENAME(ztrans_adoptTo)\n#define ztrans_clone U_ICU_ENTRY_POINT_RENAME(ztrans_clone)\n#define ztrans_close U_ICU_ENTRY_POINT_RENAME(ztrans_close)\n#define ztrans_equals U_ICU_ENTRY_POINT_RENAME(ztrans_equals)\n#define ztrans_getDynamicClassID U_ICU_ENTRY_POINT_RENAME(ztrans_getDynamicClassID)\n#define ztrans_getFrom U_ICU_ENTRY_POINT_RENAME(ztrans_getFrom)\n#define ztrans_getStaticClassID U_ICU_ENTRY_POINT_RENAME(ztrans_getStaticClassID)\n#define ztrans_getTime U_ICU_ENTRY_POINT_RENAME(ztrans_getTime)\n#define ztrans_getTo U_ICU_ENTRY_POINT_RENAME(ztrans_getTo)\n#define ztrans_open U_ICU_ENTRY_POINT_RENAME(ztrans_open)\n#define ztrans_openEmpty U_ICU_ENTRY_POINT_RENAME(ztrans_openEmpty)\n#define ztrans_setFrom U_ICU_ENTRY_POINT_RENAME(ztrans_setFrom)\n#define ztrans_setTime U_ICU_ENTRY_POINT_RENAME(ztrans_setTime)\n#define ztrans_setTo U_ICU_ENTRY_POINT_RENAME(ztrans_setTo)\n\n#endif\n\n#endif\n"
  },
  {
    "path": "deprecated/android/addons/icucompat/unicode/urep.h",
    "content": "/*\n******************************************************************************\n*   Copyright (C) 1997-2010, International Business Machines\n*   Corporation and others.  All Rights Reserved.\n******************************************************************************\n*   Date        Name        Description\n*   06/23/00    aliu        Creation.\n******************************************************************************\n*/\n\n#ifndef __UREP_H\n#define __UREP_H\n\n#include \"unicode/utypes.h\"\n\nU_CDECL_BEGIN\n\n/********************************************************************\n * General Notes\n ********************************************************************\n * TODO\n * Add usage scenario\n * Add test code\n * Talk about pinning\n * Talk about \"can truncate result if out of memory\"\n */\n\n/********************************************************************\n * Data Structures\n ********************************************************************/\n/**\n * \\file\n * \\brief C API: Callbacks for UReplaceable\n */\n/**\n * An opaque replaceable text object.  This will be manipulated only\n * through the caller-supplied UReplaceableFunctor struct.  Related\n * to the C++ class Replaceable.\n * This is currently only used in the Transliterator C API, see utrans.h .\n * @stable ICU 2.0\n */\ntypedef void* UReplaceable;\n\n/**\n * A set of function pointers that transliterators use to manipulate a\n * UReplaceable.  The caller should supply the required functions to\n * manipulate their text appropriately.  Related to the C++ class\n * Replaceable.\n * @stable ICU 2.0\n */\ntypedef struct UReplaceableCallbacks {\n\n    /**\n     * Function pointer that returns the number of UChar code units in\n     * this text.\n     *\n     * @param rep A pointer to \"this\" UReplaceable object.\n     * @return The length of the text.\n     * @stable ICU 2.0\n     */\n    int32_t (*length)(const UReplaceable* rep);\n\n    /**\n     * Function pointer that returns a UChar code units at the given\n     * offset into this text; 0 <= offset < n, where n is the value\n     * returned by (*length)(rep).  See unistr.h for a description of\n     * charAt() vs. char32At().\n     *\n     * @param rep A pointer to \"this\" UReplaceable object.\n     * @param offset The index at which to fetch the UChar (code unit).\n     * @return The UChar (code unit) at offset, or U+FFFF if the offset is out of bounds.\n     * @stable ICU 2.0\n     */\n    UChar   (*charAt)(const UReplaceable* rep,\n                      int32_t offset);\n\n    /**\n     * Function pointer that returns a UChar32 code point at the given\n     * offset into this text.  See unistr.h for a description of\n     * charAt() vs. char32At().\n     *\n     * @param rep A pointer to \"this\" UReplaceable object.\n     * @param offset The index at which to fetch the UChar32 (code point).\n     * @return The UChar32 (code point) at offset, or U+FFFF if the offset is out of bounds.\n     * @stable ICU 2.0\n     */\n    UChar32 (*char32At)(const UReplaceable* rep,\n                        int32_t offset);\n    \n    /**\n     * Function pointer that replaces text between start and limit in\n     * this text with the given text.  Attributes (out of band info)\n     * should be retained.\n     *\n     * @param rep A pointer to \"this\" UReplaceable object.\n     * @param start the starting index of the text to be replaced,\n     * inclusive.\n     * @param limit the ending index of the text to be replaced,\n     * exclusive.\n     * @param text the new text to replace the UChars from\n     * start..limit-1.\n     * @param textLength the number of UChars at text, or -1 if text\n     * is null-terminated.\n     * @stable ICU 2.0\n     */\n    void    (*replace)(UReplaceable* rep,\n                       int32_t start,\n                       int32_t limit,\n                       const UChar* text,\n                       int32_t textLength);\n    \n    /**\n     * Function pointer that copies the characters in the range\n     * [<tt>start</tt>, <tt>limit</tt>) into the array <tt>dst</tt>.\n     *\n     * @param rep A pointer to \"this\" UReplaceable object.\n     * @param start offset of first character which will be copied\n     * into the array\n     * @param limit offset immediately following the last character to\n     * be copied\n     * @param dst array in which to copy characters.  The length of\n     * <tt>dst</tt> must be at least <tt>(limit - start)</tt>.\n     * @stable ICU 2.1\n     */\n    void    (*extract)(UReplaceable* rep,\n                       int32_t start,\n                       int32_t limit,\n                       UChar* dst);\n\n    /**\n     * Function pointer that copies text between start and limit in\n     * this text to another index in the text.  Attributes (out of\n     * band info) should be retained.  After this call, there will be\n     * (at least) two copies of the characters originally located at\n     * start..limit-1.\n     *\n     * @param rep A pointer to \"this\" UReplaceable object.\n     * @param start the starting index of the text to be copied,\n     * inclusive.\n     * @param limit the ending index of the text to be copied,\n     * exclusive.\n     * @param dest the index at which the copy of the UChars should be\n     * inserted.\n     * @stable ICU 2.0\n     */\n    void    (*copy)(UReplaceable* rep,\n                    int32_t start,\n                    int32_t limit,\n                    int32_t dest);    \n\n} UReplaceableCallbacks;\n\nU_CDECL_END\n\n#endif\n"
  },
  {
    "path": "deprecated/android/addons/icucompat/unicode/ures.h",
    "content": "/*\n**********************************************************************\n*   Copyright (C) 1997-2012, International Business Machines\n*   Corporation and others.  All Rights Reserved.\n**********************************************************************\n*\n* File URES.H (formerly CRESBUND.H)\n*\n* Modification History:\n*\n*   Date        Name        Description\n*   04/01/97    aliu        Creation.\n*   02/22/99    damiba      overhaul.\n*   04/04/99    helena      Fixed internal header inclusion.\n*   04/15/99    Madhu       Updated Javadoc  \n*   06/14/99    stephen     Removed functions taking a filename suffix.\n*   07/20/99    stephen     Language-independent ypedef to void*\n*   11/09/99    weiv        Added ures_getLocale()\n*   06/24/02    weiv        Added support for resource sharing\n******************************************************************************\n*/\n\n#ifndef URES_H\n#define URES_H\n\n#include \"unicode/utypes.h\"\n#include \"unicode/uloc.h\"\n#include \"unicode/localpointer.h\"\n\n/**\n * \\file\n * \\brief C API: Resource Bundle \n *\n * <h2>C API: Resource Bundle</h2>\n *\n * C API representing a collection of resource information pertaining to a given\n * locale. A resource bundle provides a way of accessing locale- specific information in\n * a data file. You create a resource bundle that manages the resources for a given\n * locale and then ask it for individual resources.\n * <P>\n * Resource bundles in ICU4C are currently defined using text files which conform to the following\n * <a href=\"http://source.icu-project.org/repos/icu/icuhtml/trunk/design/bnf_rb.txt\">BNF definition</a>.\n * More on resource bundle concepts and syntax can be found in the \n * <a href=\"http://icu-project.org/userguide/ResourceManagement.html\">Users Guide</a>.\n * <P>\n */\n\n/**\n * UResourceBundle is an opaque type for handles for resource bundles in C APIs.\n * @stable ICU 2.0\n */\nstruct UResourceBundle;\n\n/**\n * @stable ICU 2.0\n */\ntypedef struct UResourceBundle UResourceBundle;\n\n/**\n * Numeric constants for types of resource items.\n * @see ures_getType\n * @stable ICU 2.0\n */\ntypedef enum {\n    /** Resource type constant for \"no resource\". @stable ICU 2.6 */\n    URES_NONE=-1,\n\n    /** Resource type constant for 16-bit Unicode strings. @stable ICU 2.6 */\n    URES_STRING=0,\n\n    /** Resource type constant for binary data. @stable ICU 2.6 */\n    URES_BINARY=1,\n\n    /** Resource type constant for tables of key-value pairs. @stable ICU 2.6 */\n    URES_TABLE=2,\n\n    /**\n     * Resource type constant for aliases;\n     * internally stores a string which identifies the actual resource\n     * storing the data (can be in a different resource bundle).\n     * Resolved internally before delivering the actual resource through the API.\n     * @stable ICU 2.6\n     */\n    URES_ALIAS=3,\n\n    /**\n     * Resource type constant for a single 28-bit integer, interpreted as\n     * signed or unsigned by the ures_getInt() or ures_getUInt() function.\n     * @see ures_getInt\n     * @see ures_getUInt\n     * @stable ICU 2.6\n     */\n    URES_INT=7,\n\n    /** Resource type constant for arrays of resources. @stable ICU 2.6 */\n    URES_ARRAY=8,\n\n    /**\n     * Resource type constant for vectors of 32-bit integers.\n     * @see ures_getIntVector\n     * @stable ICU 2.6\n     */\n    URES_INT_VECTOR = 14,\n#ifndef U_HIDE_DEPRECATED_API\n    /** @deprecated ICU 2.6 Use the URES_ constant instead. */\n    RES_NONE=URES_NONE,\n    /** @deprecated ICU 2.6 Use the URES_ constant instead. */\n    RES_STRING=URES_STRING,\n    /** @deprecated ICU 2.6 Use the URES_ constant instead. */\n    RES_BINARY=URES_BINARY,\n    /** @deprecated ICU 2.6 Use the URES_ constant instead. */\n    RES_TABLE=URES_TABLE,\n    /** @deprecated ICU 2.6 Use the URES_ constant instead. */\n    RES_ALIAS=URES_ALIAS,\n    /** @deprecated ICU 2.6 Use the URES_ constant instead. */\n    RES_INT=URES_INT,\n    /** @deprecated ICU 2.6 Use the URES_ constant instead. */\n    RES_ARRAY=URES_ARRAY,\n    /** @deprecated ICU 2.6 Use the URES_ constant instead. */\n    RES_INT_VECTOR=URES_INT_VECTOR,\n    /** @deprecated ICU 2.6 Not used. */\n    RES_RESERVED=15, \n#endif /* U_HIDE_DEPRECATED_API */\n\n    URES_LIMIT = 16\n} UResType;\n\n/*\n * Functions to create and destroy resource bundles.\n */\n\n/**\n * Opens a UResourceBundle, from which users can extract strings by using\n * their corresponding keys.\n * Note that the caller is responsible of calling <TT>ures_close</TT> on each succesfully\n * opened resource bundle.\n * @param packageName   The packageName and locale together point to an ICU udata object, \n *                      as defined by <code> udata_open( packageName, \"res\", locale, err) </code> \n *                      or equivalent.  Typically, packageName will refer to a (.dat) file, or to\n *                      a package registered with udata_setAppData(). Using a full file or directory\n *                      pathname for packageName is deprecated. If NULL, ICU data will be used.\n * @param locale  specifies the locale for which we want to open the resource\n *                if NULL, the default locale will be used. If strlen(locale) == 0\n *                root locale will be used.\n *                \n * @param status  fills in the outgoing error code.\n * The UErrorCode err parameter is used to return status information to the user. To\n * check whether the construction succeeded or not, you should check the value of\n * U_SUCCESS(err). If you wish more detailed information, you can check for\n * informational status results which still indicate success. U_USING_FALLBACK_WARNING\n * indicates that a fall back locale was used. For example, 'de_CH' was requested,\n * but nothing was found there, so 'de' was used. U_USING_DEFAULT_WARNING indicates that\n * the default locale data or root locale data was used; neither the requested locale \n * nor any of its fall back locales could be found. Please see the users guide for more \n * information on this topic.\n * @return      a newly allocated resource bundle.\n * @see ures_close\n * @stable ICU 2.0\n */\nU_STABLE UResourceBundle*  U_EXPORT2 \nures_open(const char*    packageName,\n          const char*  locale, \n          UErrorCode*     status);\n\n\n/** This function does not care what kind of localeID is passed in. It simply opens a bundle with \n *  that name. Fallback mechanism is disabled for the new bundle. If the requested bundle contains\n *  an %%ALIAS directive, the results are undefined.\n * @param packageName   The packageName and locale together point to an ICU udata object, \n *                      as defined by <code> udata_open( packageName, \"res\", locale, err) </code> \n *                      or equivalent.  Typically, packageName will refer to a (.dat) file, or to\n *                      a package registered with udata_setAppData(). Using a full file or directory\n *                      pathname for packageName is deprecated. If NULL, ICU data will be used.\n * @param locale  specifies the locale for which we want to open the resource\n *                if NULL, the default locale will be used. If strlen(locale) == 0\n *                root locale will be used.\n *                \n * @param status fills in the outgoing error code. Either U_ZERO_ERROR or U_MISSING_RESOURCE_ERROR\n * @return      a newly allocated resource bundle or NULL if it doesn't exist.\n * @see ures_close\n * @stable ICU 2.0\n */\nU_STABLE UResourceBundle* U_EXPORT2 \nures_openDirect(const char* packageName, \n                const char* locale, \n                UErrorCode* status);\n\n/**\n * Same as ures_open() but takes a const UChar *path.\n * This path will be converted to char * using the default converter,\n * then ures_open() is called.\n *\n * @param packageName   The packageName and locale together point to an ICU udata object, \n *                      as defined by <code> udata_open( packageName, \"res\", locale, err) </code> \n *                      or equivalent.  Typically, packageName will refer to a (.dat) file, or to\n *                      a package registered with udata_setAppData(). Using a full file or directory\n *                      pathname for packageName is deprecated. If NULL, ICU data will be used.\n * @param locale  specifies the locale for which we want to open the resource\n *                if NULL, the default locale will be used. If strlen(locale) == 0\n *                root locale will be used.\n * @param status  fills in the outgoing error code.\n * @return      a newly allocated resource bundle.\n * @see ures_open\n * @stable ICU 2.0\n */\nU_STABLE UResourceBundle* U_EXPORT2 \nures_openU(const UChar* packageName, \n           const char* locale, \n           UErrorCode* status);\n\n#ifndef U_HIDE_DEPRECATED_API\n/**\n * Returns the number of strings/arrays in resource bundles.\n * Better to use ures_getSize, as this function will be deprecated. \n *\n *@param resourceBundle resource bundle containing the desired strings\n *@param resourceKey key tagging the resource\n *@param err fills in the outgoing error code\n *                could be <TT>U_MISSING_RESOURCE_ERROR</TT> if the key is not found\n *                could be a non-failing error \n *                e.g.: <TT>U_USING_FALLBACK_WARNING</TT>,<TT>U_USING_FALLBACK_WARNING </TT>\n *@return: for    <STRONG>Arrays</STRONG>: returns the number of resources in the array\n *                <STRONG>Tables</STRONG>: returns the number of resources in the table\n *                <STRONG>single string</STRONG>: returns 1\n *@see ures_getSize\n * @deprecated ICU 2.8 User ures_getSize instead\n */\nU_DEPRECATED int32_t U_EXPORT2 \nures_countArrayItems(const UResourceBundle* resourceBundle,\n                     const char* resourceKey,\n                     UErrorCode* err);\n#endif  /* U_HIDE_DEPRECATED_API */\n/**\n * Close a resource bundle, all pointers returned from the various ures_getXXX calls\n * on this particular bundle should be considered invalid henceforth.\n *\n * @param resourceBundle a pointer to a resourceBundle struct. Can be NULL.\n * @see ures_open\n * @stable ICU 2.0\n */\nU_STABLE void U_EXPORT2 \nures_close(UResourceBundle* resourceBundle);\n\n#if U_SHOW_CPLUSPLUS_API\n\nU_NAMESPACE_BEGIN\n\n/**\n * \\class LocalUResourceBundlePointer\n * \"Smart pointer\" class, closes a UResourceBundle via ures_close().\n * For most methods see the LocalPointerBase base class.\n *\n * @see LocalPointerBase\n * @see LocalPointer\n * @stable ICU 4.4\n */\nU_DEFINE_LOCAL_OPEN_POINTER(LocalUResourceBundlePointer, UResourceBundle, ures_close);\n\nU_NAMESPACE_END\n\n#endif\n\n#ifndef U_HIDE_DEPRECATED_API\n/**\n * Return the version number associated with this ResourceBundle as a string. Please\n * use ures_getVersion as this function is going to be deprecated.\n *\n * @param resourceBundle The resource bundle for which the version is checked.\n * @return  A version number string as specified in the resource bundle or its parent.\n *          The caller does not own this string.\n * @see ures_getVersion\n * @deprecated ICU 2.8 Use ures_getVersion instead.\n */\nU_DEPRECATED const char* U_EXPORT2 \nures_getVersionNumber(const UResourceBundle*   resourceBundle);\n#endif  /* U_HIDE_DEPRECATED_API */\n\n/**\n * Return the version number associated with this ResourceBundle as an \n * UVersionInfo array.\n *\n * @param resB The resource bundle for which the version is checked.\n * @param versionInfo A UVersionInfo array that is filled with the version number\n *                    as specified in the resource bundle or its parent.\n * @stable ICU 2.0\n */\nU_STABLE void U_EXPORT2 \nures_getVersion(const UResourceBundle* resB, \n                UVersionInfo versionInfo);\n\n#ifndef U_HIDE_DEPRECATED_API\n/**\n * Return the name of the Locale associated with this ResourceBundle. This API allows\n * you to query for the real locale of the resource. For example, if you requested \n * \"en_US_CALIFORNIA\" and only \"en_US\" bundle exists, \"en_US\" will be returned. \n * For subresources, the locale where this resource comes from will be returned.\n * If fallback has occured, getLocale will reflect this.\n *\n * @param resourceBundle resource bundle in question\n * @param status just for catching illegal arguments\n * @return  A Locale name\n * @deprecated ICU 2.8 Use ures_getLocaleByType instead.\n */\nU_DEPRECATED const char* U_EXPORT2 \nures_getLocale(const UResourceBundle* resourceBundle, \n               UErrorCode* status);\n#endif  /* U_HIDE_DEPRECATED_API */\n\n/**\n * Return the name of the Locale associated with this ResourceBundle. \n * You can choose between requested, valid and real locale.\n *\n * @param resourceBundle resource bundle in question\n * @param type You can choose between requested, valid and actual\n *             locale. For description see the definition of\n *             ULocDataLocaleType in uloc.h\n * @param status just for catching illegal arguments\n * @return  A Locale name\n * @stable ICU 2.8\n */\nU_STABLE const char* U_EXPORT2 \nures_getLocaleByType(const UResourceBundle* resourceBundle, \n                     ULocDataLocaleType type, \n                     UErrorCode* status);\n\n\n#ifndef U_HIDE_INTERNAL_API\n/**\n * Same as ures_open() but uses the fill-in parameter instead of allocating\n * a bundle, if r!=NULL.\n * TODO need to revisit usefulness of this function\n *      and usage model for fillIn parameters without knowing sizeof(UResourceBundle)\n * @param r The resourcebundle to open\n * @param packageName   The packageName and locale together point to an ICU udata object, \n *                      as defined by <code> udata_open( packageName, \"res\", locale, err) </code> \n *                      or equivalent.  Typically, packageName will refer to a (.dat) file, or to\n *                      a package registered with udata_setAppData(). Using a full file or directory\n *                      pathname for packageName is deprecated. If NULL, ICU data will be used.\n * @param localeID specifies the locale for which we want to open the resource\n * @param status The error code\n * @return a newly allocated resource bundle or NULL if it doesn't exist.\n * @internal\n */\nU_INTERNAL void U_EXPORT2 \nures_openFillIn(UResourceBundle *r, \n                const char* packageName,\n                const char* localeID, \n                UErrorCode* status);\n#endif  /* U_HIDE_INTERNAL_API */\n\n/**\n * Returns a string from a string resource type\n *\n * @param resourceBundle a string resource\n * @param len    fills in the length of resulting string\n * @param status fills in the outgoing error code\n *                could be <TT>U_MISSING_RESOURCE_ERROR</TT> if the key is not found\n *                Always check the value of status. Don't count on returning NULL.\n *                could be a non-failing error \n *                e.g.: <TT>U_USING_FALLBACK_WARNING</TT>,<TT>U_USING_DEFAULT_WARNING </TT>\n * @return a pointer to a zero-terminated UChar array which lives in a memory mapped/DLL file.\n * @see ures_getBinary\n * @see ures_getIntVector\n * @see ures_getInt\n * @see ures_getUInt\n * @stable ICU 2.0\n */\nU_STABLE const UChar* U_EXPORT2 \nures_getString(const UResourceBundle* resourceBundle, \n               int32_t* len, \n               UErrorCode* status);\n\n/**\n * Returns a UTF-8 string from a string resource.\n * The UTF-8 string may be returnable directly as a pointer, or\n * it may need to be copied, or transformed from UTF-16 using u_strToUTF8()\n * or equivalent.\n *\n * If forceCopy==TRUE, then the string is always written to the dest buffer\n * and dest is returned.\n *\n * If forceCopy==FALSE, then the string is returned as a pointer if possible,\n * without needing a dest buffer (it can be NULL). If the string needs to be\n * copied or transformed, then it may be placed into dest at an arbitrary offset.\n *\n * If the string is to be written to dest, then U_BUFFER_OVERFLOW_ERROR and\n * U_STRING_NOT_TERMINATED_WARNING are set if appropriate, as usual.\n *\n * If the string is transformed from UTF-16, then a conversion error may occur\n * if an unpaired surrogate is encountered. If the function is successful, then\n * the output UTF-8 string is always well-formed.\n *\n * @param resB Resource bundle.\n * @param dest Destination buffer. Can be NULL only if capacity=*length==0.\n * @param length Input: Capacity of destination buffer.\n *               Output: Actual length of the UTF-8 string, not counting the\n *               terminating NUL, even in case of U_BUFFER_OVERFLOW_ERROR.\n *               Can be NULL, meaning capacity=0 and the string length is not\n *               returned to the caller.\n * @param forceCopy If TRUE, then the output string will always be written to\n *                  dest, with U_BUFFER_OVERFLOW_ERROR and\n *                  U_STRING_NOT_TERMINATED_WARNING set if appropriate.\n *                  If FALSE, then the dest buffer may or may not contain a\n *                  copy of the string. dest may or may not be modified.\n *                  If a copy needs to be written, then the UErrorCode parameter\n *                  indicates overflow etc. as usual.\n * @param status Pointer to a standard ICU error code. Its input value must\n *               pass the U_SUCCESS() test, or else the function returns\n *               immediately. Check for U_FAILURE() on output or use with\n *               function chaining. (See User Guide for details.)\n * @return The pointer to the UTF-8 string. It may be dest, or at some offset\n *         from dest (only if !forceCopy), or in unrelated memory.\n *         Always NUL-terminated unless the string was written to dest and\n *         length==capacity (in which case U_STRING_NOT_TERMINATED_WARNING is set).\n *\n * @see ures_getString\n * @see u_strToUTF8\n * @stable ICU 3.6\n */\nU_STABLE const char * U_EXPORT2\nures_getUTF8String(const UResourceBundle *resB,\n                   char *dest, int32_t *length,\n                   UBool forceCopy,\n                   UErrorCode *status);\n\n/**\n * Returns a binary data from a binary resource. \n *\n * @param resourceBundle a string resource\n * @param len    fills in the length of resulting byte chunk\n * @param status fills in the outgoing error code\n *                could be <TT>U_MISSING_RESOURCE_ERROR</TT> if the key is not found\n *                Always check the value of status. Don't count on returning NULL.\n *                could be a non-failing error \n *                e.g.: <TT>U_USING_FALLBACK_WARNING</TT>,<TT>U_USING_DEFAULT_WARNING </TT>\n * @return a pointer to a chunk of unsigned bytes which live in a memory mapped/DLL file.\n * @see ures_getString\n * @see ures_getIntVector\n * @see ures_getInt\n * @see ures_getUInt\n * @stable ICU 2.0\n */\nU_STABLE const uint8_t* U_EXPORT2 \nures_getBinary(const UResourceBundle* resourceBundle, \n               int32_t* len, \n               UErrorCode* status);\n\n/**\n * Returns a 32 bit integer array from a resource. \n *\n * @param resourceBundle an int vector resource\n * @param len    fills in the length of resulting byte chunk\n * @param status fills in the outgoing error code\n *                could be <TT>U_MISSING_RESOURCE_ERROR</TT> if the key is not found\n *                Always check the value of status. Don't count on returning NULL.\n *                could be a non-failing error \n *                e.g.: <TT>U_USING_FALLBACK_WARNING</TT>,<TT>U_USING_DEFAULT_WARNING </TT>\n * @return a pointer to a chunk of integers which live in a memory mapped/DLL file.\n * @see ures_getBinary\n * @see ures_getString\n * @see ures_getInt\n * @see ures_getUInt\n * @stable ICU 2.0\n */\nU_STABLE const int32_t* U_EXPORT2 \nures_getIntVector(const UResourceBundle* resourceBundle, \n                  int32_t* len, \n                  UErrorCode* status);\n\n/**\n * Returns an unsigned integer from a resource. \n * This integer is originally 28 bits.\n *\n * @param resourceBundle a string resource\n * @param status fills in the outgoing error code\n *                could be <TT>U_MISSING_RESOURCE_ERROR</TT> if the key is not found\n *                could be a non-failing error \n *                e.g.: <TT>U_USING_FALLBACK_WARNING</TT>,<TT>U_USING_DEFAULT_WARNING </TT>\n * @return an integer value\n * @see ures_getInt\n * @see ures_getIntVector\n * @see ures_getBinary\n * @see ures_getString\n * @stable ICU 2.0\n */\nU_STABLE uint32_t U_EXPORT2 \nures_getUInt(const UResourceBundle* resourceBundle, \n             UErrorCode *status);\n\n/**\n * Returns a signed integer from a resource. \n * This integer is originally 28 bit and the sign gets propagated.\n *\n * @param resourceBundle a string resource\n * @param status  fills in the outgoing error code\n *                could be <TT>U_MISSING_RESOURCE_ERROR</TT> if the key is not found\n *                could be a non-failing error \n *                e.g.: <TT>U_USING_FALLBACK_WARNING</TT>,<TT>U_USING_DEFAULT_WARNING </TT>\n * @return an integer value\n * @see ures_getUInt\n * @see ures_getIntVector\n * @see ures_getBinary\n * @see ures_getString\n * @stable ICU 2.0\n */\nU_STABLE int32_t U_EXPORT2 \nures_getInt(const UResourceBundle* resourceBundle, \n            UErrorCode *status);\n\n/**\n * Returns the size of a resource. Size for scalar types is always 1, \n * and for vector/table types is the number of child resources.\n * @warning Integer array is treated as a scalar type. There are no \n *          APIs to access individual members of an integer array. It\n *          is always returned as a whole.\n * @param resourceBundle a resource\n * @return number of resources in a given resource.\n * @stable ICU 2.0\n */\nU_STABLE int32_t U_EXPORT2 \nures_getSize(const UResourceBundle *resourceBundle);\n\n/**\n * Returns the type of a resource. Available types are defined in enum UResType\n *\n * @param resourceBundle a resource\n * @return type of the given resource.\n * @see UResType\n * @stable ICU 2.0\n */\nU_STABLE UResType U_EXPORT2 \nures_getType(const UResourceBundle *resourceBundle);\n\n/**\n * Returns the key associated with a given resource. Not all the resources have a key - only \n * those that are members of a table.\n *\n * @param resourceBundle a resource\n * @return a key associated to this resource, or NULL if it doesn't have a key\n * @stable ICU 2.0\n */\nU_STABLE const char * U_EXPORT2 \nures_getKey(const UResourceBundle *resourceBundle);\n\n/* ITERATION API \n    This API provides means for iterating through a resource\n*/\n\n/**\n * Resets the internal context of a resource so that iteration starts from the first element.\n *\n * @param resourceBundle a resource\n * @stable ICU 2.0\n */\nU_STABLE void U_EXPORT2 \nures_resetIterator(UResourceBundle *resourceBundle);\n\n/**\n * Checks whether the given resource has another element to iterate over.\n *\n * @param resourceBundle a resource\n * @return TRUE if there are more elements, FALSE if there is no more elements\n * @stable ICU 2.0\n */\nU_STABLE UBool U_EXPORT2 \nures_hasNext(const UResourceBundle *resourceBundle);\n\n/**\n * Returns the next resource in a given resource or NULL if there are no more resources \n * to iterate over. Features a fill-in parameter. \n *\n * @param resourceBundle    a resource\n * @param fillIn            if NULL a new UResourceBundle struct is allocated and must be closed by the caller.\n *                          Alternatively, you can supply a struct to be filled by this function.\n * @param status            fills in the outgoing error code. You may still get a non NULL result even if an\n *                          error occured. Check status instead.\n * @return                  a pointer to a UResourceBundle struct. If fill in param was NULL, caller must close it\n * @stable ICU 2.0\n */\nU_STABLE UResourceBundle* U_EXPORT2 \nures_getNextResource(UResourceBundle *resourceBundle, \n                     UResourceBundle *fillIn, \n                     UErrorCode *status);\n\n/**\n * Returns the next string in a given resource or NULL if there are no more resources \n * to iterate over. \n *\n * @param resourceBundle    a resource\n * @param len               fill in length of the string\n * @param key               fill in for key associated with this string. NULL if no key\n * @param status            fills in the outgoing error code. If an error occured, we may return NULL, but don't\n *                          count on it. Check status instead!\n * @return a pointer to a zero-terminated UChar array which lives in a memory mapped/DLL file.\n * @stable ICU 2.0\n */\nU_STABLE const UChar* U_EXPORT2 \nures_getNextString(UResourceBundle *resourceBundle, \n                   int32_t* len, \n                   const char ** key, \n                   UErrorCode *status);\n\n/**\n * Returns the resource in a given resource at the specified index. Features a fill-in parameter. \n *\n * @param resourceBundle    the resource bundle from which to get a sub-resource\n * @param indexR            an index to the wanted resource.\n * @param fillIn            if NULL a new UResourceBundle struct is allocated and must be closed by the caller.\n *                          Alternatively, you can supply a struct to be filled by this function.\n * @param status            fills in the outgoing error code. Don't count on NULL being returned if an error has\n *                          occured. Check status instead.\n * @return                  a pointer to a UResourceBundle struct. If fill in param was NULL, caller must close it\n * @stable ICU 2.0\n */\nU_STABLE UResourceBundle* U_EXPORT2 \nures_getByIndex(const UResourceBundle *resourceBundle, \n                int32_t indexR, \n                UResourceBundle *fillIn, \n                UErrorCode *status);\n\n/**\n * Returns the string in a given resource at the specified index.\n *\n * @param resourceBundle    a resource\n * @param indexS            an index to the wanted string.\n * @param len               fill in length of the string\n * @param status            fills in the outgoing error code. If an error occured, we may return NULL, but don't\n *                          count on it. Check status instead!\n * @return                  a pointer to a zero-terminated UChar array which lives in a memory mapped/DLL file.\n * @stable ICU 2.0\n */\nU_STABLE const UChar* U_EXPORT2 \nures_getStringByIndex(const UResourceBundle *resourceBundle, \n                      int32_t indexS, \n                      int32_t* len, \n                      UErrorCode *status);\n\n/**\n * Returns a UTF-8 string from a resource at the specified index.\n * The UTF-8 string may be returnable directly as a pointer, or\n * it may need to be copied, or transformed from UTF-16 using u_strToUTF8()\n * or equivalent.\n *\n * If forceCopy==TRUE, then the string is always written to the dest buffer\n * and dest is returned.\n *\n * If forceCopy==FALSE, then the string is returned as a pointer if possible,\n * without needing a dest buffer (it can be NULL). If the string needs to be\n * copied or transformed, then it may be placed into dest at an arbitrary offset.\n *\n * If the string is to be written to dest, then U_BUFFER_OVERFLOW_ERROR and\n * U_STRING_NOT_TERMINATED_WARNING are set if appropriate, as usual.\n *\n * If the string is transformed from UTF-16, then a conversion error may occur\n * if an unpaired surrogate is encountered. If the function is successful, then\n * the output UTF-8 string is always well-formed.\n *\n * @param resB Resource bundle.\n * @param stringIndex An index to the wanted string.\n * @param dest Destination buffer. Can be NULL only if capacity=*length==0.\n * @param pLength Input: Capacity of destination buffer.\n *               Output: Actual length of the UTF-8 string, not counting the\n *               terminating NUL, even in case of U_BUFFER_OVERFLOW_ERROR.\n *               Can be NULL, meaning capacity=0 and the string length is not\n *               returned to the caller.\n * @param forceCopy If TRUE, then the output string will always be written to\n *                  dest, with U_BUFFER_OVERFLOW_ERROR and\n *                  U_STRING_NOT_TERMINATED_WARNING set if appropriate.\n *                  If FALSE, then the dest buffer may or may not contain a\n *                  copy of the string. dest may or may not be modified.\n *                  If a copy needs to be written, then the UErrorCode parameter\n *                  indicates overflow etc. as usual.\n * @param status Pointer to a standard ICU error code. Its input value must\n *               pass the U_SUCCESS() test, or else the function returns\n *               immediately. Check for U_FAILURE() on output or use with\n *               function chaining. (See User Guide for details.)\n * @return The pointer to the UTF-8 string. It may be dest, or at some offset\n *         from dest (only if !forceCopy), or in unrelated memory.\n *         Always NUL-terminated unless the string was written to dest and\n *         length==capacity (in which case U_STRING_NOT_TERMINATED_WARNING is set).\n *\n * @see ures_getStringByIndex\n * @see u_strToUTF8\n * @stable ICU 3.6\n */\nU_STABLE const char * U_EXPORT2\nures_getUTF8StringByIndex(const UResourceBundle *resB,\n                          int32_t stringIndex,\n                          char *dest, int32_t *pLength,\n                          UBool forceCopy,\n                          UErrorCode *status);\n\n/**\n * Returns a resource in a given resource that has a given key. This procedure works only with table\n * resources. Features a fill-in parameter. \n *\n * @param resourceBundle    a resource\n * @param key               a key associated with the wanted resource\n * @param fillIn            if NULL a new UResourceBundle struct is allocated and must be closed by the caller.\n *                          Alternatively, you can supply a struct to be filled by this function.\n * @param status            fills in the outgoing error code.\n * @return                  a pointer to a UResourceBundle struct. If fill in param was NULL, caller must close it\n * @stable ICU 2.0\n */\nU_STABLE UResourceBundle* U_EXPORT2 \nures_getByKey(const UResourceBundle *resourceBundle, \n              const char* key, \n              UResourceBundle *fillIn, \n              UErrorCode *status);\n\n/**\n * Returns a string in a given resource that has a given key. This procedure works only with table\n * resources. \n *\n * @param resB              a resource\n * @param key               a key associated with the wanted string\n * @param len               fill in length of the string\n * @param status            fills in the outgoing error code. If an error occured, we may return NULL, but don't\n *                          count on it. Check status instead!\n * @return                  a pointer to a zero-terminated UChar array which lives in a memory mapped/DLL file.\n * @stable ICU 2.0\n */\nU_STABLE const UChar* U_EXPORT2 \nures_getStringByKey(const UResourceBundle *resB, \n                    const char* key, \n                    int32_t* len, \n                    UErrorCode *status);\n\n/**\n * Returns a UTF-8 string from a resource and a key.\n * This function works only with table resources.\n *\n * The UTF-8 string may be returnable directly as a pointer, or\n * it may need to be copied, or transformed from UTF-16 using u_strToUTF8()\n * or equivalent.\n *\n * If forceCopy==TRUE, then the string is always written to the dest buffer\n * and dest is returned.\n *\n * If forceCopy==FALSE, then the string is returned as a pointer if possible,\n * without needing a dest buffer (it can be NULL). If the string needs to be\n * copied or transformed, then it may be placed into dest at an arbitrary offset.\n *\n * If the string is to be written to dest, then U_BUFFER_OVERFLOW_ERROR and\n * U_STRING_NOT_TERMINATED_WARNING are set if appropriate, as usual.\n *\n * If the string is transformed from UTF-16, then a conversion error may occur\n * if an unpaired surrogate is encountered. If the function is successful, then\n * the output UTF-8 string is always well-formed.\n *\n * @param resB Resource bundle.\n * @param key  A key associated with the wanted resource\n * @param dest Destination buffer. Can be NULL only if capacity=*length==0.\n * @param pLength Input: Capacity of destination buffer.\n *               Output: Actual length of the UTF-8 string, not counting the\n *               terminating NUL, even in case of U_BUFFER_OVERFLOW_ERROR.\n *               Can be NULL, meaning capacity=0 and the string length is not\n *               returned to the caller.\n * @param forceCopy If TRUE, then the output string will always be written to\n *                  dest, with U_BUFFER_OVERFLOW_ERROR and\n *                  U_STRING_NOT_TERMINATED_WARNING set if appropriate.\n *                  If FALSE, then the dest buffer may or may not contain a\n *                  copy of the string. dest may or may not be modified.\n *                  If a copy needs to be written, then the UErrorCode parameter\n *                  indicates overflow etc. as usual.\n * @param status Pointer to a standard ICU error code. Its input value must\n *               pass the U_SUCCESS() test, or else the function returns\n *               immediately. Check for U_FAILURE() on output or use with\n *               function chaining. (See User Guide for details.)\n * @return The pointer to the UTF-8 string. It may be dest, or at some offset\n *         from dest (only if !forceCopy), or in unrelated memory.\n *         Always NUL-terminated unless the string was written to dest and\n *         length==capacity (in which case U_STRING_NOT_TERMINATED_WARNING is set).\n *\n * @see ures_getStringByKey\n * @see u_strToUTF8\n * @stable ICU 3.6\n */\nU_STABLE const char * U_EXPORT2\nures_getUTF8StringByKey(const UResourceBundle *resB,\n                        const char *key,\n                        char *dest, int32_t *pLength,\n                        UBool forceCopy,\n                        UErrorCode *status);\n\n#if U_SHOW_CPLUSPLUS_API\n#include \"unicode/unistr.h\"\n\nU_NAMESPACE_BEGIN\n/**\n * returns a string from a string resource type\n *\n * @param resB    a resource\n * @param status: fills in the outgoing error code\n *                could be <TT>U_MISSING_RESOURCE_ERROR</TT> if the key is not found\n *                could be a non-failing error \n *                e.g.: <TT>U_USING_FALLBACK_WARNING</TT>,<TT>U_USING_DEFAULT_WARNING </TT>\n * @return        a UnicodeString object. If there is an error, string is bogus\n * @stable ICU 2.0\n */\ninline UnicodeString \nures_getUnicodeString(const UResourceBundle *resB, \n                      UErrorCode* status) \n{\n    int32_t len = 0;\n    const UChar *r = ures_getString(resB, &len, status);\n    return UnicodeString(TRUE, r, len);\n}\n\n/**\n * Returns the next string in a resource or NULL if there are no more resources \n * to iterate over. \n *\n * @param resB              a resource\n * @param key               fill in for key associated with this string\n * @param status            fills in the outgoing error code\n * @return an UnicodeString object.\n * @stable ICU 2.0\n */\ninline UnicodeString \nures_getNextUnicodeString(UResourceBundle *resB, \n                          const char ** key, \n                          UErrorCode* status) \n{\n    int32_t len = 0;\n    const UChar* r = ures_getNextString(resB, &len, key, status);\n    return UnicodeString(TRUE, r, len);\n}\n\n/**\n * Returns the string in a given resource at the specified index.\n *\n * @param resB              a resource\n * @param indexS            an index to the wanted string.\n * @param status            fills in the outgoing error code\n * @return                  an UnicodeString object. If there is an error, string is bogus\n * @stable ICU 2.0\n */\ninline UnicodeString \nures_getUnicodeStringByIndex(const UResourceBundle *resB, \n                             int32_t indexS, \n                             UErrorCode* status) \n{\n    int32_t len = 0;\n    const UChar* r = ures_getStringByIndex(resB, indexS, &len, status);\n    return UnicodeString(TRUE, r, len);\n}\n\n/**\n * Returns a string in a resource that has a given key. This procedure works only with table\n * resources. \n *\n * @param resB              a resource\n * @param key               a key associated with the wanted string\n * @param status            fills in the outgoing error code\n * @return                  an UnicodeString object. If there is an error, string is bogus\n * @stable ICU 2.0\n */\ninline UnicodeString \nures_getUnicodeStringByKey(const UResourceBundle *resB, \n                           const char* key, \n                           UErrorCode* status) \n{\n    int32_t len = 0;\n    const UChar* r = ures_getStringByKey(resB, key, &len, status);\n    return UnicodeString(TRUE, r, len);\n}\n\nU_NAMESPACE_END\n\n#endif\n\n/**\n * Create a string enumerator, owned by the caller, of all locales located within \n * the specified resource tree.\n * @param packageName name of the tree, such as (NULL) or U_ICUDATA_ALIAS or  or \"ICUDATA-coll\"\n * This call is similar to uloc_getAvailable().\n * @param status error code\n * @stable ICU 3.2\n */\nU_STABLE UEnumeration* U_EXPORT2\nures_openAvailableLocales(const char *packageName, UErrorCode *status);\n\n\n#endif /*_URES*/\n/*eof*/\n"
  },
  {
    "path": "deprecated/android/addons/icucompat/unicode/uscript.h",
    "content": "/*\n **********************************************************************\n *   Copyright (C) 1997-2012, International Business Machines\n *   Corporation and others.  All Rights Reserved.\n **********************************************************************\n *\n * File USCRIPT.H\n *\n * Modification History:\n *\n *   Date        Name        Description\n *   07/06/2001    Ram         Creation.\n ******************************************************************************\n */\n\n#ifndef USCRIPT_H\n#define USCRIPT_H\n#include \"unicode/utypes.h\"\n\n/**\n * \\file\n * \\brief C API: Unicode Script Information\n */\n \n/**\n * Constants for ISO 15924 script codes.\n *\n * Many of these script codes - those from Unicode's ScriptNames.txt -\n * are character property values for Unicode's Script property.\n * See UAX #24 Script Names (http://www.unicode.org/reports/tr24/).\n *\n * Starting with ICU 3.6, constants for most ISO 15924 script codes\n * are included (currently excluding private-use codes Qaaa..Qabx).\n * For scripts for which there are codes in ISO 15924 but which are not\n * used in the Unicode Character Database (UCD), there are no Unicode characters\n * associated with those scripts.\n *\n * For example, there are no characters that have a UCD script code of\n * Hans or Hant. All Han ideographs have the Hani script code.\n * The Hans and Hant script codes are used with CLDR data.\n *\n * ISO 15924 script codes are included for use with CLDR and similar.\n *\n * @stable ICU 2.2\n */\ntypedef enum UScriptCode {\n    /*\n     * Note: UScriptCode constants and their ISO script code comments\n     * are parsed by preparseucd.py.\n     * It matches lines like\n     *     USCRIPT_<Unicode Script value name> = <integer>,  / * <ISO script code> * /\n     */\n\n      /** @stable ICU 2.2 */\n      USCRIPT_INVALID_CODE = -1,\n      /** @stable ICU 2.2 */\n      USCRIPT_COMMON       =  0,  /* Zyyy */\n      /** @stable ICU 2.2 */\n      USCRIPT_INHERITED    =  1,  /* Zinh */ /* \"Code for inherited script\", for non-spacing combining marks; also Qaai */\n      /** @stable ICU 2.2 */\n      USCRIPT_ARABIC       =  2,  /* Arab */\n      /** @stable ICU 2.2 */\n      USCRIPT_ARMENIAN     =  3,  /* Armn */\n      /** @stable ICU 2.2 */\n      USCRIPT_BENGALI      =  4,  /* Beng */\n      /** @stable ICU 2.2 */\n      USCRIPT_BOPOMOFO     =  5,  /* Bopo */\n      /** @stable ICU 2.2 */\n      USCRIPT_CHEROKEE     =  6,  /* Cher */\n      /** @stable ICU 2.2 */\n      USCRIPT_COPTIC       =  7,  /* Copt */\n      /** @stable ICU 2.2 */\n      USCRIPT_CYRILLIC     =  8,  /* Cyrl */\n      /** @stable ICU 2.2 */\n      USCRIPT_DESERET      =  9,  /* Dsrt */\n      /** @stable ICU 2.2 */\n      USCRIPT_DEVANAGARI   = 10,  /* Deva */\n      /** @stable ICU 2.2 */\n      USCRIPT_ETHIOPIC     = 11,  /* Ethi */\n      /** @stable ICU 2.2 */\n      USCRIPT_GEORGIAN     = 12,  /* Geor */\n      /** @stable ICU 2.2 */\n      USCRIPT_GOTHIC       = 13,  /* Goth */\n      /** @stable ICU 2.2 */\n      USCRIPT_GREEK        = 14,  /* Grek */\n      /** @stable ICU 2.2 */\n      USCRIPT_GUJARATI     = 15,  /* Gujr */\n      /** @stable ICU 2.2 */\n      USCRIPT_GURMUKHI     = 16,  /* Guru */\n      /** @stable ICU 2.2 */\n      USCRIPT_HAN          = 17,  /* Hani */\n      /** @stable ICU 2.2 */\n      USCRIPT_HANGUL       = 18,  /* Hang */\n      /** @stable ICU 2.2 */\n      USCRIPT_HEBREW       = 19,  /* Hebr */\n      /** @stable ICU 2.2 */\n      USCRIPT_HIRAGANA     = 20,  /* Hira */\n      /** @stable ICU 2.2 */\n      USCRIPT_KANNADA      = 21,  /* Knda */\n      /** @stable ICU 2.2 */\n      USCRIPT_KATAKANA     = 22,  /* Kana */\n      /** @stable ICU 2.2 */\n      USCRIPT_KHMER        = 23,  /* Khmr */\n      /** @stable ICU 2.2 */\n      USCRIPT_LAO          = 24,  /* Laoo */\n      /** @stable ICU 2.2 */\n      USCRIPT_LATIN        = 25,  /* Latn */\n      /** @stable ICU 2.2 */\n      USCRIPT_MALAYALAM    = 26,  /* Mlym */\n      /** @stable ICU 2.2 */\n      USCRIPT_MONGOLIAN    = 27,  /* Mong */\n      /** @stable ICU 2.2 */\n      USCRIPT_MYANMAR      = 28,  /* Mymr */\n      /** @stable ICU 2.2 */\n      USCRIPT_OGHAM        = 29,  /* Ogam */\n      /** @stable ICU 2.2 */\n      USCRIPT_OLD_ITALIC   = 30,  /* Ital */\n      /** @stable ICU 2.2 */\n      USCRIPT_ORIYA        = 31,  /* Orya */\n      /** @stable ICU 2.2 */\n      USCRIPT_RUNIC        = 32,  /* Runr */\n      /** @stable ICU 2.2 */\n      USCRIPT_SINHALA      = 33,  /* Sinh */\n      /** @stable ICU 2.2 */\n      USCRIPT_SYRIAC       = 34,  /* Syrc */\n      /** @stable ICU 2.2 */\n      USCRIPT_TAMIL        = 35,  /* Taml */\n      /** @stable ICU 2.2 */\n      USCRIPT_TELUGU       = 36,  /* Telu */\n      /** @stable ICU 2.2 */\n      USCRIPT_THAANA       = 37,  /* Thaa */\n      /** @stable ICU 2.2 */\n      USCRIPT_THAI         = 38,  /* Thai */\n      /** @stable ICU 2.2 */\n      USCRIPT_TIBETAN      = 39,  /* Tibt */\n      /** Canadian_Aboriginal script. @stable ICU 2.6 */\n      USCRIPT_CANADIAN_ABORIGINAL = 40,  /* Cans */\n      /** Canadian_Aboriginal script (alias). @stable ICU 2.2 */\n      USCRIPT_UCAS         = USCRIPT_CANADIAN_ABORIGINAL,\n      /** @stable ICU 2.2 */\n      USCRIPT_YI           = 41,  /* Yiii */\n      /* New scripts in Unicode 3.2 */\n      /** @stable ICU 2.2 */\n      USCRIPT_TAGALOG      = 42,  /* Tglg */\n      /** @stable ICU 2.2 */\n      USCRIPT_HANUNOO      = 43,  /* Hano */\n      /** @stable ICU 2.2 */\n      USCRIPT_BUHID        = 44,  /* Buhd */\n      /** @stable ICU 2.2 */\n      USCRIPT_TAGBANWA     = 45,  /* Tagb */\n\n      /* New scripts in Unicode 4 */\n      /** @stable ICU 2.6 */\n      USCRIPT_BRAILLE      = 46,  /* Brai */\n      /** @stable ICU 2.6 */\n      USCRIPT_CYPRIOT      = 47,  /* Cprt */\n      /** @stable ICU 2.6 */\n      USCRIPT_LIMBU        = 48,  /* Limb */\n      /** @stable ICU 2.6 */\n      USCRIPT_LINEAR_B     = 49,  /* Linb */\n      /** @stable ICU 2.6 */\n      USCRIPT_OSMANYA      = 50,  /* Osma */\n      /** @stable ICU 2.6 */\n      USCRIPT_SHAVIAN      = 51,  /* Shaw */\n      /** @stable ICU 2.6 */\n      USCRIPT_TAI_LE       = 52,  /* Tale */\n      /** @stable ICU 2.6 */\n      USCRIPT_UGARITIC     = 53,  /* Ugar */\n\n      /** New script code in Unicode 4.0.1 @stable ICU 3.0 */\n      USCRIPT_KATAKANA_OR_HIRAGANA = 54,/*Hrkt */\n\n      /* New scripts in Unicode 4.1 */\n      /** @stable ICU 3.4 */\n      USCRIPT_BUGINESE      = 55, /* Bugi */\n      /** @stable ICU 3.4 */\n      USCRIPT_GLAGOLITIC    = 56, /* Glag */\n      /** @stable ICU 3.4 */\n      USCRIPT_KHAROSHTHI    = 57, /* Khar */\n      /** @stable ICU 3.4 */\n      USCRIPT_SYLOTI_NAGRI  = 58, /* Sylo */\n      /** @stable ICU 3.4 */\n      USCRIPT_NEW_TAI_LUE   = 59, /* Talu */\n      /** @stable ICU 3.4 */\n      USCRIPT_TIFINAGH      = 60, /* Tfng */\n      /** @stable ICU 3.4 */\n      USCRIPT_OLD_PERSIAN   = 61, /* Xpeo */\n\n      /* New script codes from ISO 15924 */\n      /** @stable ICU 3.6 */\n      USCRIPT_BALINESE                      = 62, /* Bali */\n      /** @stable ICU 3.6 */\n      USCRIPT_BATAK                         = 63, /* Batk */\n      /** @stable ICU 3.6 */\n      USCRIPT_BLISSYMBOLS                   = 64, /* Blis */\n      /** @stable ICU 3.6 */\n      USCRIPT_BRAHMI                        = 65, /* Brah */\n      /** @stable ICU 3.6 */\n      USCRIPT_CHAM                          = 66, /* Cham */\n      /** @stable ICU 3.6 */\n      USCRIPT_CIRTH                         = 67, /* Cirt */\n      /** @stable ICU 3.6 */\n      USCRIPT_OLD_CHURCH_SLAVONIC_CYRILLIC  = 68, /* Cyrs */\n      /** @stable ICU 3.6 */\n      USCRIPT_DEMOTIC_EGYPTIAN              = 69, /* Egyd */\n      /** @stable ICU 3.6 */\n      USCRIPT_HIERATIC_EGYPTIAN             = 70, /* Egyh */\n      /** @stable ICU 3.6 */\n      USCRIPT_EGYPTIAN_HIEROGLYPHS          = 71, /* Egyp */\n      /** @stable ICU 3.6 */\n      USCRIPT_KHUTSURI                      = 72, /* Geok */\n      /** @stable ICU 3.6 */\n      USCRIPT_SIMPLIFIED_HAN                = 73, /* Hans */\n      /** @stable ICU 3.6 */\n      USCRIPT_TRADITIONAL_HAN               = 74, /* Hant */\n      /** @stable ICU 3.6 */\n      USCRIPT_PAHAWH_HMONG                  = 75, /* Hmng */\n      /** @stable ICU 3.6 */\n      USCRIPT_OLD_HUNGARIAN                 = 76, /* Hung */\n      /** @stable ICU 3.6 */\n      USCRIPT_HARAPPAN_INDUS                = 77, /* Inds */\n      /** @stable ICU 3.6 */\n      USCRIPT_JAVANESE                      = 78, /* Java */\n      /** @stable ICU 3.6 */\n      USCRIPT_KAYAH_LI                      = 79, /* Kali */\n      /** @stable ICU 3.6 */\n      USCRIPT_LATIN_FRAKTUR                 = 80, /* Latf */\n      /** @stable ICU 3.6 */\n      USCRIPT_LATIN_GAELIC                  = 81, /* Latg */\n      /** @stable ICU 3.6 */\n      USCRIPT_LEPCHA                        = 82, /* Lepc */\n      /** @stable ICU 3.6 */\n      USCRIPT_LINEAR_A                      = 83, /* Lina */\n      /** @stable ICU 4.6 */\n      USCRIPT_MANDAIC                       = 84, /* Mand */\n      /** @stable ICU 3.6 */\n      USCRIPT_MANDAEAN                      = USCRIPT_MANDAIC,\n      /** @stable ICU 3.6 */\n      USCRIPT_MAYAN_HIEROGLYPHS             = 85, /* Maya */\n      /** @stable ICU 4.6 */\n      USCRIPT_MEROITIC_HIEROGLYPHS          = 86, /* Mero */\n      /** @stable ICU 3.6 */\n      USCRIPT_MEROITIC                      = USCRIPT_MEROITIC_HIEROGLYPHS,\n      /** @stable ICU 3.6 */\n      USCRIPT_NKO                           = 87, /* Nkoo */\n      /** @stable ICU 3.6 */\n      USCRIPT_ORKHON                        = 88, /* Orkh */\n      /** @stable ICU 3.6 */\n      USCRIPT_OLD_PERMIC                    = 89, /* Perm */\n      /** @stable ICU 3.6 */\n      USCRIPT_PHAGS_PA                      = 90, /* Phag */\n      /** @stable ICU 3.6 */\n      USCRIPT_PHOENICIAN                    = 91, /* Phnx */\n      /** @stable ICU 3.6 */\n      USCRIPT_PHONETIC_POLLARD              = 92, /* Plrd */\n      /** @stable ICU 3.6 */\n      USCRIPT_RONGORONGO                    = 93, /* Roro */\n      /** @stable ICU 3.6 */\n      USCRIPT_SARATI                        = 94, /* Sara */\n      /** @stable ICU 3.6 */\n      USCRIPT_ESTRANGELO_SYRIAC             = 95, /* Syre */\n      /** @stable ICU 3.6 */\n      USCRIPT_WESTERN_SYRIAC                = 96, /* Syrj */\n      /** @stable ICU 3.6 */\n      USCRIPT_EASTERN_SYRIAC                = 97, /* Syrn */\n      /** @stable ICU 3.6 */\n      USCRIPT_TENGWAR                       = 98, /* Teng */\n      /** @stable ICU 3.6 */\n      USCRIPT_VAI                           = 99, /* Vaii */\n      /** @stable ICU 3.6 */\n      USCRIPT_VISIBLE_SPEECH                = 100,/* Visp */\n      /** @stable ICU 3.6 */\n      USCRIPT_CUNEIFORM                     = 101,/* Xsux */\n      /** @stable ICU 3.6 */\n      USCRIPT_UNWRITTEN_LANGUAGES           = 102,/* Zxxx */\n      /** @stable ICU 3.6 */\n      USCRIPT_UNKNOWN                       = 103,/* Zzzz */ /* Unknown=\"Code for uncoded script\", for unassigned code points */\n\n      /* New script codes from ISO 15924 */\n      /** @stable ICU 3.8 */\n      USCRIPT_CARIAN                        = 104,/* Cari */\n      /** @stable ICU 3.8 */\n      USCRIPT_JAPANESE                      = 105,/* Jpan */\n      /** @stable ICU 3.8 */\n      USCRIPT_LANNA                         = 106,/* Lana */\n      /** @stable ICU 3.8 */\n      USCRIPT_LYCIAN                        = 107,/* Lyci */\n      /** @stable ICU 3.8 */\n      USCRIPT_LYDIAN                        = 108,/* Lydi */\n      /** @stable ICU 3.8 */\n      USCRIPT_OL_CHIKI                      = 109,/* Olck */\n      /** @stable ICU 3.8 */\n      USCRIPT_REJANG                        = 110,/* Rjng */\n      /** @stable ICU 3.8 */\n      USCRIPT_SAURASHTRA                    = 111,/* Saur */\n      /** @stable ICU 3.8 */\n      USCRIPT_SIGN_WRITING                  = 112,/* Sgnw */\n      /** @stable ICU 3.8 */\n      USCRIPT_SUNDANESE                     = 113,/* Sund */\n      /** @stable ICU 3.8 */\n      USCRIPT_MOON                          = 114,/* Moon */\n      /** @stable ICU 3.8 */\n      USCRIPT_MEITEI_MAYEK                  = 115,/* Mtei */\n\n      /* New script codes from ISO 15924 */\n      /** @stable ICU 4.0 */\n      USCRIPT_IMPERIAL_ARAMAIC              = 116,/* Armi */\n      /** @stable ICU 4.0 */\n      USCRIPT_AVESTAN                       = 117,/* Avst */\n      /** @stable ICU 4.0 */\n      USCRIPT_CHAKMA                        = 118,/* Cakm */\n      /** @stable ICU 4.0 */\n      USCRIPT_KOREAN                        = 119,/* Kore */\n      /** @stable ICU 4.0 */\n      USCRIPT_KAITHI                        = 120,/* Kthi */\n      /** @stable ICU 4.0 */\n      USCRIPT_MANICHAEAN                    = 121,/* Mani */\n      /** @stable ICU 4.0 */\n      USCRIPT_INSCRIPTIONAL_PAHLAVI         = 122,/* Phli */\n      /** @stable ICU 4.0 */\n      USCRIPT_PSALTER_PAHLAVI               = 123,/* Phlp */\n      /** @stable ICU 4.0 */\n      USCRIPT_BOOK_PAHLAVI                  = 124,/* Phlv */\n      /** @stable ICU 4.0 */\n      USCRIPT_INSCRIPTIONAL_PARTHIAN        = 125,/* Prti */\n      /** @stable ICU 4.0 */\n      USCRIPT_SAMARITAN                     = 126,/* Samr */\n      /** @stable ICU 4.0 */\n      USCRIPT_TAI_VIET                      = 127,/* Tavt */\n      /** @stable ICU 4.0 */\n      USCRIPT_MATHEMATICAL_NOTATION         = 128,/* Zmth */\n      /** @stable ICU 4.0 */\n      USCRIPT_SYMBOLS                       = 129,/* Zsym */\n\n      /* New script codes from ISO 15924 */\n      /** @stable ICU 4.4 */\n      USCRIPT_BAMUM                         = 130,/* Bamu */\n      /** @stable ICU 4.4 */\n      USCRIPT_LISU                          = 131,/* Lisu */\n      /** @stable ICU 4.4 */\n      USCRIPT_NAKHI_GEBA                    = 132,/* Nkgb */\n      /** @stable ICU 4.4 */\n      USCRIPT_OLD_SOUTH_ARABIAN             = 133,/* Sarb */\n\n      /* New script codes from ISO 15924 */\n      /** @stable ICU 4.6 */\n      USCRIPT_BASSA_VAH                     = 134,/* Bass */\n      /** @stable ICU 4.6 */\n      USCRIPT_DUPLOYAN_SHORTAND             = 135,/* Dupl */\n      /** @stable ICU 4.6 */\n      USCRIPT_ELBASAN                       = 136,/* Elba */\n      /** @stable ICU 4.6 */\n      USCRIPT_GRANTHA                       = 137,/* Gran */\n      /** @stable ICU 4.6 */\n      USCRIPT_KPELLE                        = 138,/* Kpel */\n      /** @stable ICU 4.6 */\n      USCRIPT_LOMA                          = 139,/* Loma */\n      /** @stable ICU 4.6 */\n      USCRIPT_MENDE                         = 140,/* Mend */\n      /** @stable ICU 4.6 */\n      USCRIPT_MEROITIC_CURSIVE              = 141,/* Merc */\n      /** @stable ICU 4.6 */\n      USCRIPT_OLD_NORTH_ARABIAN             = 142,/* Narb */\n      /** @stable ICU 4.6 */\n      USCRIPT_NABATAEAN                     = 143,/* Nbat */\n      /** @stable ICU 4.6 */\n      USCRIPT_PALMYRENE                     = 144,/* Palm */\n      /** @stable ICU 4.6 */\n      USCRIPT_SINDHI                        = 145,/* Sind */\n      /** @stable ICU 4.6 */\n      USCRIPT_WARANG_CITI                   = 146,/* Wara */\n\n      /** @stable ICU 4.8 */\n      USCRIPT_AFAKA                         = 147,/* Afak */\n      /** @stable ICU 4.8 */\n      USCRIPT_JURCHEN                       = 148,/* Jurc */\n      /** @stable ICU 4.8 */\n      USCRIPT_MRO                           = 149,/* Mroo */\n      /** @stable ICU 4.8 */\n      USCRIPT_NUSHU                         = 150,/* Nshu */\n      /** @stable ICU 4.8 */\n      USCRIPT_SHARADA                       = 151,/* Shrd */\n      /** @stable ICU 4.8 */\n      USCRIPT_SORA_SOMPENG                  = 152,/* Sora */\n      /** @stable ICU 4.8 */\n      USCRIPT_TAKRI                         = 153,/* Takr */\n      /** @stable ICU 4.8 */\n      USCRIPT_TANGUT                        = 154,/* Tang */\n      /** @stable ICU 4.8 */\n      USCRIPT_WOLEAI                        = 155,/* Wole */\n\n      /** @stable ICU 49 */\n      USCRIPT_ANATOLIAN_HIEROGLYPHS         = 156,/* Hluw */\n      /** @stable ICU 49 */\n      USCRIPT_KHOJKI                        = 157,/* Khoj */\n      /** @stable ICU 49 */\n      USCRIPT_TIRHUTA                       = 158,/* Tirh */\n\n      /* Private use codes from Qaaa - Qabx are not supported */\n\n      /** @stable ICU 2.2 */\n      USCRIPT_CODE_LIMIT    = 159\n} UScriptCode;\n\n/**\n * Gets script codes associated with the given locale or ISO 15924 abbreviation or name. \n * Fills in USCRIPT_MALAYALAM given \"Malayam\" OR \"Mlym\".\n * Fills in USCRIPT_LATIN given \"en\" OR \"en_US\" \n * If required capacity is greater than capacity of the destination buffer then the error code\n * is set to U_BUFFER_OVERFLOW_ERROR and the required capacity is returned\n *\n * <p>Note: To search by short or long script alias only, use\n * u_getPropertyValueEnum(UCHAR_SCRIPT, alias) instead.  This does\n * a fast lookup with no access of the locale data.\n * @param nameOrAbbrOrLocale name of the script, as given in\n * PropertyValueAliases.txt, or ISO 15924 code or locale\n * @param fillIn the UScriptCode buffer to fill in the script code\n * @param capacity the capacity (size) fo UScriptCode buffer passed in.\n * @param err the error status code.\n * @return The number of script codes filled in the buffer passed in \n * @stable ICU 2.4\n */\nU_STABLE int32_t  U_EXPORT2 \nuscript_getCode(const char* nameOrAbbrOrLocale,UScriptCode* fillIn,int32_t capacity,UErrorCode *err);\n\n/**\n * Gets a script name associated with the given script code. \n * Returns  \"Malayam\" given USCRIPT_MALAYALAM\n * @param scriptCode UScriptCode enum\n * @return script long name as given in\n * PropertyValueAliases.txt, or NULL if scriptCode is invalid\n * @stable ICU 2.4\n */\nU_STABLE const char*  U_EXPORT2 \nuscript_getName(UScriptCode scriptCode);\n\n/**\n * Gets a script name associated with the given script code. \n * Returns  \"Mlym\" given USCRIPT_MALAYALAM\n * @param scriptCode UScriptCode enum\n * @return script abbreviated name as given in\n * PropertyValueAliases.txt, or NULL if scriptCode is invalid\n * @stable ICU 2.4\n */\nU_STABLE const char*  U_EXPORT2 \nuscript_getShortName(UScriptCode scriptCode);\n\n/**\n * Gets the script code associated with the given codepoint.\n * Returns USCRIPT_MALAYALAM given 0x0D02 \n * @param codepoint UChar32 codepoint\n * @param err the error status code.\n * @return The UScriptCode, or 0 if codepoint is invalid \n * @stable ICU 2.4\n */\nU_STABLE UScriptCode  U_EXPORT2 \nuscript_getScript(UChar32 codepoint, UErrorCode *err);\n\n#ifndef U_HIDE_DRAFT_API\n/**\n * Do the Script_Extensions of code point c contain script sc?\n * If c does not have explicit Script_Extensions, then this tests whether\n * c has the Script property value sc.\n *\n * Some characters are commonly used in multiple scripts.\n * For more information, see UAX #24: http://www.unicode.org/reports/tr24/.\n *\n * The Script_Extensions property is provisional. It may be modified or removed\n * in future versions of the Unicode Standard, and thus in ICU.\n * @param c code point\n * @param sc script code\n * @return TRUE if sc is in Script_Extensions(c)\n * @draft ICU 49\n */\nU_DRAFT UBool U_EXPORT2\nuscript_hasScript(UChar32 c, UScriptCode sc);\n\n/**\n * Writes code point c's Script_Extensions as a list of UScriptCode values\n * to the output scripts array and returns the number of script codes.\n * - If c does have Script_Extensions, then the Script property value\n *   (normally Common or Inherited) is not included.\n * - If c does not have Script_Extensions, then the one Script code is written to the output array.\n * - If c is not a valid code point, then the one USCRIPT_UNKNOWN code is written.\n * In other words, if the return value is 1,\n * then the output array contains exactly c's single Script code.\n * If the return value is n>=2, then the output array contains c's n Script_Extensions script codes.\n *\n * Some characters are commonly used in multiple scripts.\n * For more information, see UAX #24: http://www.unicode.org/reports/tr24/.\n *\n * If there are more than capacity script codes to be written, then\n * U_BUFFER_OVERFLOW_ERROR is set and the number of Script_Extensions is returned.\n * (Usual ICU buffer handling behavior.)\n *\n * The Script_Extensions property is provisional. It may be modified or removed\n * in future versions of the Unicode Standard, and thus in ICU.\n * @param c code point\n * @param scripts output script code array\n * @param capacity capacity of the scripts array\n * @param errorCode Standard ICU error code. Its input value must\n *                  pass the U_SUCCESS() test, or else the function returns\n *                  immediately. Check for U_FAILURE() on output or use with\n *                  function chaining. (See User Guide for details.)\n * @return number of script codes in c's Script_Extensions, or 1 for the single Script value,\n *         written to scripts unless U_BUFFER_OVERFLOW_ERROR indicates insufficient capacity\n * @draft ICU 49\n */\nU_DRAFT int32_t U_EXPORT2\nuscript_getScriptExtensions(UChar32 c,\n                            UScriptCode *scripts, int32_t capacity,\n                            UErrorCode *errorCode);\n#endif  /* U_HIDE_DRAFT_API */\n\n#endif\n"
  },
  {
    "path": "deprecated/android/addons/icucompat/unicode/usearch.h",
    "content": "/*\n**********************************************************************\n*   Copyright (C) 2001-2011 IBM and others. All rights reserved.\n**********************************************************************\n*   Date        Name        Description\n*  06/28/2001   synwee      Creation.\n**********************************************************************\n*/\n#ifndef USEARCH_H\n#define USEARCH_H\n\n#include \"unicode/utypes.h\"\n\n#if !UCONFIG_NO_COLLATION && !UCONFIG_NO_BREAK_ITERATION\n\n#include \"unicode/localpointer.h\"\n#include \"unicode/ucol.h\"\n#include \"unicode/ucoleitr.h\"\n#include \"unicode/ubrk.h\"\n\n/**\n * \\file\n * \\brief C API: StringSearch\n *\n * C Apis for an engine that provides language-sensitive text searching based \n * on the comparison rules defined in a <tt>UCollator</tt> data struct,\n * see <tt>ucol.h</tt>. This ensures that language eccentricity can be \n * handled, e.g. for the German collator, characters &szlig; and SS will be matched \n * if case is chosen to be ignored. \n * See the <a href=\"http://source.icu-project.org/repos/icu/icuhtml/trunk/design/collation/ICU_collation_design.htm\">\n * \"ICU Collation Design Document\"</a> for more information.\n * <p> \n * The algorithm implemented is a modified form of the Boyer Moore's search.\n * For more information  see \n * <a href=\"http://icu-project.org/docs/papers/efficient_text_searching_in_java.html\">\n * \"Efficient Text Searching in Java\"</a>, published in <i>Java Report</i> \n * in February, 1999, for further information on the algorithm.\n * <p>\n * There are 2 match options for selection:<br>\n * Let S' be the sub-string of a text string S between the offsets start and \n * end <start, end>.\n * <br>\n * A pattern string P matches a text string S at the offsets <start, end> \n * if\n * <pre> \n * option 1. Some canonical equivalent of P matches some canonical equivalent \n *           of S'\n * option 2. P matches S' and if P starts or ends with a combining mark, \n *           there exists no non-ignorable combining mark before or after S' \n *           in S respectively. \n * </pre>\n * Option 2. will be the default.\n * <p>\n * This search has APIs similar to that of other text iteration mechanisms \n * such as the break iterators in <tt>ubrk.h</tt>. Using these \n * APIs, it is easy to scan through text looking for all occurances of \n * a given pattern. This search iterator allows changing of direction by \n * calling a <tt>reset</tt> followed by a <tt>next</tt> or <tt>previous</tt>. \n * Though a direction change can occur without calling <tt>reset</tt> first,  \n * this operation comes with some speed penalty.\n * Generally, match results in the forward direction will match the result \n * matches in the backwards direction in the reverse order\n * <p>\n * <tt>usearch.h</tt> provides APIs to specify the starting position \n * within the text string to be searched, e.g. <tt>usearch_setOffset</tt>,\n * <tt>usearch_preceding</tt> and <tt>usearch_following</tt>. Since the \n * starting position will be set as it is specified, please take note that \n * there are some dangerous positions which the search may render incorrect \n * results:\n * <ul>\n * <li> The midst of a substring that requires normalization.\n * <li> If the following match is to be found, the position should not be the\n *      second character which requires to be swapped with the preceding \n *      character. Vice versa, if the preceding match is to be found, \n *      position to search from should not be the first character which \n *      requires to be swapped with the next character. E.g certain Thai and\n *      Lao characters require swapping.\n * <li> If a following pattern match is to be found, any position within a \n *      contracting sequence except the first will fail. Vice versa if a \n *      preceding pattern match is to be found, a invalid starting point \n *      would be any character within a contracting sequence except the last.\n * </ul>\n * <p>\n * A breakiterator can be used if only matches at logical breaks are desired.\n * Using a breakiterator will only give you results that exactly matches the\n * boundaries given by the breakiterator. For instance the pattern \"e\" will\n * not be found in the string \"\\u00e9\" if a character break iterator is used.\n * <p>\n * Options are provided to handle overlapping matches. \n * E.g. In English, overlapping matches produces the result 0 and 2 \n * for the pattern \"abab\" in the text \"ababab\", where else mutually \n * exclusive matches only produce the result of 0.\n * <p>\n * Though collator attributes will be taken into consideration while \n * performing matches, there are no APIs here for setting and getting the \n * attributes. These attributes can be set by getting the collator\n * from <tt>usearch_getCollator</tt> and using the APIs in <tt>ucol.h</tt>.\n * Lastly to update String Search to the new collator attributes, \n * usearch_reset() has to be called.\n * <p> \n * Restriction: <br>\n * Currently there are no composite characters that consists of a\n * character with combining class > 0 before a character with combining \n * class == 0. However, if such a character exists in the future, the \n * search mechanism does not guarantee the results for option 1.\n * \n * <p>\n * Example of use:<br>\n * <pre><code>\n * char *tgtstr = \"The quick brown fox jumped over the lazy fox\";\n * char *patstr = \"fox\";\n * UChar target[64];\n * UChar pattern[16];\n * UErrorCode status = U_ZERO_ERROR;\n * u_uastrcpy(target, tgtstr);\n * u_uastrcpy(pattern, patstr);\n *\n * UStringSearch *search = usearch_open(pattern, -1, target, -1, \"en_US\", \n *                                  NULL, &status);\n * if (U_SUCCESS(status)) {\n *     for (int pos = usearch_first(search, &status); \n *          pos != USEARCH_DONE; \n *          pos = usearch_next(search, &status))\n *     {\n *         printf(\"Found match at %d pos, length is %d\\n\", pos, \n *                                        usearch_getMatchLength(search));\n *     }\n * }\n *\n * usearch_close(search);\n * </code></pre>\n * @stable ICU 2.4\n */\n\n/**\n* DONE is returned by previous() and next() after all valid matches have \n* been returned, and by first() and last() if there are no matches at all.\n* @stable ICU 2.4\n*/\n#define USEARCH_DONE -1\n\n/**\n* Data structure for searching\n* @stable ICU 2.4\n*/\nstruct UStringSearch;\n/**\n* Data structure for searching\n* @stable ICU 2.4\n*/\ntypedef struct UStringSearch UStringSearch;\n\n/**\n* @stable ICU 2.4\n*/\ntypedef enum {\n    /** Option for overlapping matches */\n    USEARCH_OVERLAP,\n    /** \n     * Option for canonical matches. option 1 in header documentation.\n     * The default value will be USEARCH_OFF\n     */\n    USEARCH_CANONICAL_MATCH,\n    /** \n     * Option to control how collation elements are compared.\n     * The default value will be USEARCH_STANDARD_ELEMENT_COMPARISON.\n     * @stable ICU 4.4\n     */\n    USEARCH_ELEMENT_COMPARISON,\n\n    USEARCH_ATTRIBUTE_COUNT\n} USearchAttribute;\n\n/**\n* @stable ICU 2.4\n*/\ntypedef enum {\n    /** Default value for any USearchAttribute */\n    USEARCH_DEFAULT = -1,\n    /** Value for USEARCH_OVERLAP and USEARCH_CANONICAL_MATCH */\n    USEARCH_OFF, \n    /** Value for USEARCH_OVERLAP and USEARCH_CANONICAL_MATCH */\n    USEARCH_ON,\n    /** \n     * Value (default) for USEARCH_ELEMENT_COMPARISON;\n     * standard collation element comparison at the specified collator\n     * strength.\n     * @stable ICU 4.4\n     */\n    USEARCH_STANDARD_ELEMENT_COMPARISON,\n    /** \n     * Value for USEARCH_ELEMENT_COMPARISON;\n     * collation element comparison is modified to effectively provide\n     * behavior between the specified strength and strength - 1. Collation\n     * elements in the pattern that have the base weight for the specified\n     * strength are treated as \"wildcards\" that match an element with any\n     * other weight at that collation level in the searched text. For\n     * example, with a secondary-strength English collator, a plain 'e' in\n     * the pattern will match a plain e or an e with any diacritic in the\n     * searched text, but an e with diacritic in the pattern will only\n     * match an e with the same diacritic in the searched text.\n     * @stable ICU 4.4\n     */\n    USEARCH_PATTERN_BASE_WEIGHT_IS_WILDCARD,\n    /** \n     * Value for USEARCH_ELEMENT_COMPARISON.\n     * collation element comparison is modified to effectively provide\n     * behavior between the specified strength and strength - 1. Collation\n     * elements in either the pattern or the searched text that have the\n     * base weight for the specified strength are treated as \"wildcards\"\n     * that match an element with any other weight at that collation level.\n     * For example, with a secondary-strength English collator, a plain 'e'\n     * in the pattern will match a plain e or an e with any diacritic in the\n     * searched text, but an e with diacritic in the pattern will only\n     * match an e with the same diacritic or a plain e in the searched text.\n     * @stable ICU 4.4\n     */\n    USEARCH_ANY_BASE_WEIGHT_IS_WILDCARD,\n\n    USEARCH_ATTRIBUTE_VALUE_COUNT\n} USearchAttributeValue;\n\n/* open and close ------------------------------------------------------ */\n\n/**\n* Creating a search iterator data struct using the argument locale language\n* rule set. A collator will be created in the process, which will be owned by\n* this search and will be deleted in <tt>usearch_close</tt>.\n* @param pattern for matching\n* @param patternlength length of the pattern, -1 for null-termination\n* @param text text string\n* @param textlength length of the text string, -1 for null-termination\n* @param locale name of locale for the rules to be used\n* @param breakiter A BreakIterator that will be used to restrict the points\n*                  at which matches are detected. If a match is found, but \n*                  the match's start or end index is not a boundary as \n*                  determined by the <tt>BreakIterator</tt>, the match will \n*                  be rejected and another will be searched for. \n*                  If this parameter is <tt>NULL</tt>, no break detection is \n*                  attempted.\n* @param status for errors if it occurs. If pattern or text is NULL, or if\n*               patternlength or textlength is 0 then an \n*               U_ILLEGAL_ARGUMENT_ERROR is returned.\n* @return search iterator data structure, or NULL if there is an error.\n* @stable ICU 2.4\n*/\nU_STABLE UStringSearch * U_EXPORT2 usearch_open(const UChar          *pattern, \n                                              int32_t         patternlength, \n                                        const UChar          *text, \n                                              int32_t         textlength,\n                                        const char           *locale,\n                                              UBreakIterator *breakiter,\n                                              UErrorCode     *status);\n\n/**\n* Creating a search iterator data struct using the argument collator language\n* rule set. Note, user retains the ownership of this collator, thus the \n* responsibility of deletion lies with the user.\n* NOTE: string search cannot be instantiated from a collator that has \n* collate digits as numbers (CODAN) turned on.\n* @param pattern for matching\n* @param patternlength length of the pattern, -1 for null-termination\n* @param text text string\n* @param textlength length of the text string, -1 for null-termination\n* @param collator used for the language rules\n* @param breakiter A BreakIterator that will be used to restrict the points\n*                  at which matches are detected. If a match is found, but \n*                  the match's start or end index is not a boundary as \n*                  determined by the <tt>BreakIterator</tt>, the match will \n*                  be rejected and another will be searched for. \n*                  If this parameter is <tt>NULL</tt>, no break detection is \n*                  attempted.\n* @param status for errors if it occurs. If collator, pattern or text is NULL, \n*               or if patternlength or textlength is 0 then an \n*               U_ILLEGAL_ARGUMENT_ERROR is returned.\n* @return search iterator data structure, or NULL if there is an error.\n* @stable ICU 2.4\n*/\nU_STABLE UStringSearch * U_EXPORT2 usearch_openFromCollator(\n                                         const UChar *pattern, \n                                               int32_t         patternlength,\n                                         const UChar          *text, \n                                               int32_t         textlength,\n                                         const UCollator      *collator,\n                                               UBreakIterator *breakiter,\n                                               UErrorCode     *status);\n\n/**\n* Destroying and cleaning up the search iterator data struct.\n* If a collator is created in <tt>usearch_open</tt>, it will be destroyed here.\n* @param searchiter data struct to clean up\n* @stable ICU 2.4\n*/\nU_STABLE void U_EXPORT2 usearch_close(UStringSearch *searchiter);\n\n#if U_SHOW_CPLUSPLUS_API\n\nU_NAMESPACE_BEGIN\n\n/**\n * \\class LocalUStringSearchPointer\n * \"Smart pointer\" class, closes a UStringSearch via usearch_close().\n * For most methods see the LocalPointerBase base class.\n *\n * @see LocalPointerBase\n * @see LocalPointer\n * @stable ICU 4.4\n */\nU_DEFINE_LOCAL_OPEN_POINTER(LocalUStringSearchPointer, UStringSearch, usearch_close);\n\nU_NAMESPACE_END\n\n#endif\n\n/* get and set methods -------------------------------------------------- */\n\n/**\n* Sets the current position in the text string which the next search will \n* start from. Clears previous states. \n* This method takes the argument index and sets the position in the text \n* string accordingly without checking if the index is pointing to a \n* valid starting point to begin searching. \n* Search positions that may render incorrect results are highlighted in the\n* header comments\n* @param strsrch search iterator data struct\n* @param position position to start next search from. If position is less\n*          than or greater than the text range for searching, \n*          an U_INDEX_OUTOFBOUNDS_ERROR will be returned\n* @param status error status if any.\n* @stable ICU 2.4\n*/\nU_STABLE void U_EXPORT2 usearch_setOffset(UStringSearch *strsrch, \n                                        int32_t    position,\n                                        UErrorCode    *status);\n\n/**\n* Return the current index in the string text being searched.\n* If the iteration has gone past the end of the text (or past the beginning \n* for a backwards search), <tt>USEARCH_DONE</tt> is returned.\n* @param strsrch search iterator data struct\n* @see #USEARCH_DONE\n* @stable ICU 2.4\n*/\nU_STABLE int32_t U_EXPORT2 usearch_getOffset(const UStringSearch *strsrch);\n    \n/**\n* Sets the text searching attributes located in the enum USearchAttribute\n* with values from the enum USearchAttributeValue.\n* <tt>USEARCH_DEFAULT</tt> can be used for all attributes for resetting.\n* @param strsrch search iterator data struct\n* @param attribute text attribute to be set\n* @param value text attribute value\n* @param status for errors if it occurs\n* @see #usearch_getAttribute\n* @stable ICU 2.4\n*/\nU_STABLE void U_EXPORT2 usearch_setAttribute(UStringSearch         *strsrch, \n                                           USearchAttribute       attribute,\n                                           USearchAttributeValue  value,\n                                           UErrorCode            *status);\n\n/**    \n* Gets the text searching attributes.\n* @param strsrch search iterator data struct\n* @param attribute text attribute to be retrieve\n* @return text attribute value\n* @see #usearch_setAttribute\n* @stable ICU 2.4\n*/\nU_STABLE USearchAttributeValue U_EXPORT2 usearch_getAttribute(\n                                         const UStringSearch    *strsrch,\n                                               USearchAttribute  attribute);\n\n/**\n* Returns the index to the match in the text string that was searched.\n* This call returns a valid result only after a successful call to \n* <tt>usearch_first</tt>, <tt>usearch_next</tt>, <tt>usearch_previous</tt>, \n* or <tt>usearch_last</tt>.\n* Just after construction, or after a searching method returns \n* <tt>USEARCH_DONE</tt>, this method will return <tt>USEARCH_DONE</tt>.\n* <p>\n* Use <tt>usearch_getMatchedLength</tt> to get the matched string length.\n* @param strsrch search iterator data struct\n* @return index to a substring within the text string that is being \n*         searched.\n* @see #usearch_first\n* @see #usearch_next\n* @see #usearch_previous\n* @see #usearch_last\n* @see #USEARCH_DONE\n* @stable ICU 2.4\n*/\nU_STABLE int32_t U_EXPORT2 usearch_getMatchedStart(\n                                               const UStringSearch *strsrch);\n    \n/**\n* Returns the length of text in the string which matches the search pattern. \n* This call returns a valid result only after a successful call to \n* <tt>usearch_first</tt>, <tt>usearch_next</tt>, <tt>usearch_previous</tt>, \n* or <tt>usearch_last</tt>.\n* Just after construction, or after a searching method returns \n* <tt>USEARCH_DONE</tt>, this method will return 0.\n* @param strsrch search iterator data struct\n* @return The length of the match in the string text, or 0 if there is no \n*         match currently.\n* @see #usearch_first\n* @see #usearch_next\n* @see #usearch_previous\n* @see #usearch_last\n* @see #USEARCH_DONE\n* @stable ICU 2.4\n*/\nU_STABLE int32_t U_EXPORT2 usearch_getMatchedLength(\n                                               const UStringSearch *strsrch);\n\n/**\n* Returns the text that was matched by the most recent call to \n* <tt>usearch_first</tt>, <tt>usearch_next</tt>, <tt>usearch_previous</tt>, \n* or <tt>usearch_last</tt>.\n* If the iterator is not pointing at a valid match (e.g. just after \n* construction or after <tt>USEARCH_DONE</tt> has been returned, returns\n* an empty string. If result is not large enough to store the matched text,\n* result will be filled with the partial text and an U_BUFFER_OVERFLOW_ERROR \n* will be returned in status. result will be null-terminated whenever \n* possible. If the buffer fits the matched text exactly, a null-termination \n* is not possible, then a U_STRING_NOT_TERMINATED_ERROR set in status.\n* Pre-flighting can be either done with length = 0 or the API \n* <tt>usearch_getMatchLength</tt>.\n* @param strsrch search iterator data struct\n* @param result UChar buffer to store the matched string\n* @param resultCapacity length of the result buffer\n* @param status error returned if result is not large enough\n* @return exact length of the matched text, not counting the null-termination\n* @see #usearch_first\n* @see #usearch_next\n* @see #usearch_previous\n* @see #usearch_last\n* @see #USEARCH_DONE\n* @stable ICU 2.4\n*/\nU_STABLE int32_t U_EXPORT2 usearch_getMatchedText(const UStringSearch *strsrch, \n                                            UChar         *result, \n                                            int32_t        resultCapacity, \n                                            UErrorCode    *status);\n\n#if !UCONFIG_NO_BREAK_ITERATION\n\n/**\n* Set the BreakIterator that will be used to restrict the points at which \n* matches are detected.\n* @param strsrch search iterator data struct\n* @param breakiter A BreakIterator that will be used to restrict the points\n*                  at which matches are detected. If a match is found, but \n*                  the match's start or end index is not a boundary as \n*                  determined by the <tt>BreakIterator</tt>, the match will \n*                  be rejected and another will be searched for. \n*                  If this parameter is <tt>NULL</tt>, no break detection is \n*                  attempted.\n* @param status for errors if it occurs\n* @see #usearch_getBreakIterator\n* @stable ICU 2.4\n*/\nU_STABLE void U_EXPORT2 usearch_setBreakIterator(UStringSearch  *strsrch, \n                                               UBreakIterator *breakiter,\n                                               UErrorCode     *status);\n\n/**\n* Returns the BreakIterator that is used to restrict the points at which \n* matches are detected. This will be the same object that was passed to the \n* constructor or to <tt>usearch_setBreakIterator</tt>. Note that \n* <tt>NULL</tt> \n* is a legal value; it means that break detection should not be attempted.\n* @param strsrch search iterator data struct\n* @return break iterator used\n* @see #usearch_setBreakIterator\n* @stable ICU 2.4\n*/\nU_STABLE const UBreakIterator * U_EXPORT2 usearch_getBreakIterator(\n                                              const UStringSearch *strsrch);\n    \n#endif\n    \n/**\n* Set the string text to be searched. Text iteration will hence begin at the \n* start of the text string. This method is useful if you want to re-use an \n* iterator to search for the same pattern within a different body of text.\n* @param strsrch search iterator data struct\n* @param text new string to look for match\n* @param textlength length of the new string, -1 for null-termination\n* @param status for errors if it occurs. If text is NULL, or textlength is 0 \n*               then an U_ILLEGAL_ARGUMENT_ERROR is returned with no change\n*               done to strsrch.\n* @see #usearch_getText\n* @stable ICU 2.4\n*/\nU_STABLE void U_EXPORT2 usearch_setText(      UStringSearch *strsrch, \n                                      const UChar         *text,\n                                            int32_t        textlength,\n                                            UErrorCode    *status);\n\n/**\n* Return the string text to be searched.\n* @param strsrch search iterator data struct\n* @param length returned string text length\n* @return string text \n* @see #usearch_setText\n* @stable ICU 2.4\n*/\nU_STABLE const UChar * U_EXPORT2 usearch_getText(const UStringSearch *strsrch, \n                                               int32_t       *length);\n\n/**\n* Gets the collator used for the language rules. \n* <p>\n* Deleting the returned <tt>UCollator</tt> before calling \n* <tt>usearch_close</tt> would cause the string search to fail.\n* <tt>usearch_close</tt> will delete the collator if this search owns it.\n* @param strsrch search iterator data struct\n* @return collator\n* @stable ICU 2.4\n*/\nU_STABLE UCollator * U_EXPORT2 usearch_getCollator(\n                                               const UStringSearch *strsrch);\n\n/**\n* Sets the collator used for the language rules. User retains the ownership \n* of this collator, thus the responsibility of deletion lies with the user.\n* This method causes internal data such as Boyer-Moore shift tables to  \n* be recalculated, but the iterator's position is unchanged.\n* @param strsrch search iterator data struct\n* @param collator to be used\n* @param status for errors if it occurs\n* @stable ICU 2.4\n*/\nU_STABLE void U_EXPORT2 usearch_setCollator(      UStringSearch *strsrch, \n                                          const UCollator     *collator,\n                                                UErrorCode    *status);\n\n/**\n* Sets the pattern used for matching.\n* Internal data like the Boyer Moore table will be recalculated, but the \n* iterator's position is unchanged.\n* @param strsrch search iterator data struct\n* @param pattern string\n* @param patternlength pattern length, -1 for null-terminated string\n* @param status for errors if it occurs. If text is NULL, or textlength is 0 \n*               then an U_ILLEGAL_ARGUMENT_ERROR is returned with no change\n*               done to strsrch.\n* @stable ICU 2.4\n*/\nU_STABLE void U_EXPORT2 usearch_setPattern(      UStringSearch *strsrch, \n                                         const UChar         *pattern,\n                                               int32_t        patternlength,\n                                               UErrorCode    *status);\n\n/**\n* Gets the search pattern\n* @param strsrch search iterator data struct\n* @param length return length of the pattern, -1 indicates that the pattern \n*               is null-terminated\n* @return pattern string\n* @stable ICU 2.4\n*/\nU_STABLE const UChar * U_EXPORT2 usearch_getPattern(\n                                               const UStringSearch *strsrch, \n                                                     int32_t       *length);\n\n/* methods ------------------------------------------------------------- */\n\n/**\n* Returns the first index at which the string text matches the search \n* pattern.  \n* The iterator is adjusted so that its current index (as returned by \n* <tt>usearch_getOffset</tt>) is the match position if one was found.\n* If a match is not found, <tt>USEARCH_DONE</tt> will be returned and\n* the iterator will be adjusted to the index <tt>USEARCH_DONE</tt>.\n* @param strsrch search iterator data struct\n* @param status for errors if it occurs\n* @return The character index of the first match, or \n* <tt>USEARCH_DONE</tt> if there are no matches.\n* @see #usearch_getOffset\n* @see #USEARCH_DONE\n* @stable ICU 2.4\n*/\nU_STABLE int32_t U_EXPORT2 usearch_first(UStringSearch *strsrch, \n                                           UErrorCode    *status);\n\n/**\n* Returns the first index equal or greater than <tt>position</tt> at which\n* the string text\n* matches the search pattern. The iterator is adjusted so that its current \n* index (as returned by <tt>usearch_getOffset</tt>) is the match position if \n* one was found.\n* If a match is not found, <tt>USEARCH_DONE</tt> will be returned and\n* the iterator will be adjusted to the index <tt>USEARCH_DONE</tt>\n* <p>\n* Search positions that may render incorrect results are highlighted in the\n* header comments. If position is less than or greater than the text range \n* for searching, an U_INDEX_OUTOFBOUNDS_ERROR will be returned\n* @param strsrch search iterator data struct\n* @param position to start the search at\n* @param status for errors if it occurs\n* @return The character index of the first match following <tt>pos</tt>,\n*         or <tt>USEARCH_DONE</tt> if there are no matches.\n* @see #usearch_getOffset\n* @see #USEARCH_DONE\n* @stable ICU 2.4\n*/\nU_STABLE int32_t U_EXPORT2 usearch_following(UStringSearch *strsrch, \n                                               int32_t    position, \n                                               UErrorCode    *status);\n    \n/**\n* Returns the last index in the target text at which it matches the search \n* pattern. The iterator is adjusted so that its current \n* index (as returned by <tt>usearch_getOffset</tt>) is the match position if \n* one was found.\n* If a match is not found, <tt>USEARCH_DONE</tt> will be returned and\n* the iterator will be adjusted to the index <tt>USEARCH_DONE</tt>.\n* @param strsrch search iterator data struct\n* @param status for errors if it occurs\n* @return The index of the first match, or <tt>USEARCH_DONE</tt> if there \n*         are no matches.\n* @see #usearch_getOffset\n* @see #USEARCH_DONE\n* @stable ICU 2.4\n*/\nU_STABLE int32_t U_EXPORT2 usearch_last(UStringSearch *strsrch, \n                                          UErrorCode    *status);\n\n/**\n* Returns the first index less than <tt>position</tt> at which the string text \n* matches the search pattern. The iterator is adjusted so that its current \n* index (as returned by <tt>usearch_getOffset</tt>) is the match position if \n* one was found.\n* If a match is not found, <tt>USEARCH_DONE</tt> will be returned and\n* the iterator will be adjusted to the index <tt>USEARCH_DONE</tt>\n* <p>\n* Search positions that may render incorrect results are highlighted in the\n* header comments. If position is less than or greater than the text range \n* for searching, an U_INDEX_OUTOFBOUNDS_ERROR will be returned.\n* <p>\n* When <tt>USEARCH_OVERLAP</tt> option is off, the last index of the\n* result match is always less than <tt>position</tt>.\n* When <tt>USERARCH_OVERLAP</tt> is on, the result match may span across\n* <tt>position</tt>.\n* @param strsrch search iterator data struct\n* @param position index position the search is to begin at\n* @param status for errors if it occurs\n* @return The character index of the first match preceding <tt>pos</tt>,\n*         or <tt>USEARCH_DONE</tt> if there are no matches.\n* @see #usearch_getOffset\n* @see #USEARCH_DONE\n* @stable ICU 2.4\n*/\nU_STABLE int32_t U_EXPORT2 usearch_preceding(UStringSearch *strsrch, \n                                               int32_t    position, \n                                               UErrorCode    *status);\n    \n/**\n* Returns the index of the next point at which the string text matches the\n* search pattern, starting from the current position.\n* The iterator is adjusted so that its current \n* index (as returned by <tt>usearch_getOffset</tt>) is the match position if \n* one was found.\n* If a match is not found, <tt>USEARCH_DONE</tt> will be returned and\n* the iterator will be adjusted to the index <tt>USEARCH_DONE</tt>\n* @param strsrch search iterator data struct\n* @param status for errors if it occurs\n* @return The index of the next match after the current position, or \n*         <tt>USEARCH_DONE</tt> if there are no more matches.\n* @see #usearch_first\n* @see #usearch_getOffset\n* @see #USEARCH_DONE\n* @stable ICU 2.4\n*/\nU_STABLE int32_t U_EXPORT2 usearch_next(UStringSearch *strsrch, \n                                          UErrorCode    *status);\n\n/**\n* Returns the index of the previous point at which the string text matches\n* the search pattern, starting at the current position.\n* The iterator is adjusted so that its current \n* index (as returned by <tt>usearch_getOffset</tt>) is the match position if \n* one was found.\n* If a match is not found, <tt>USEARCH_DONE</tt> will be returned and\n* the iterator will be adjusted to the index <tt>USEARCH_DONE</tt>\n* @param strsrch search iterator data struct\n* @param status for errors if it occurs\n* @return The index of the previous match before the current position,\n*         or <tt>USEARCH_DONE</tt> if there are no more matches.\n* @see #usearch_last\n* @see #usearch_getOffset\n* @see #USEARCH_DONE\n* @stable ICU 2.4\n*/\nU_STABLE int32_t U_EXPORT2 usearch_previous(UStringSearch *strsrch, \n                                              UErrorCode    *status);\n    \n/** \n* Reset the iteration.\n* Search will begin at the start of the text string if a forward iteration \n* is initiated before a backwards iteration. Otherwise if a backwards \n* iteration is initiated before a forwards iteration, the search will begin\n* at the end of the text string.\n* @param strsrch search iterator data struct\n* @see #usearch_first\n* @stable ICU 2.4\n*/\nU_STABLE void U_EXPORT2 usearch_reset(UStringSearch *strsrch);\n\n#ifndef U_HIDE_INTERNAL_API\n/**\n  *  Simple forward search for the pattern, starting at a specified index,\n  *     and using using a default set search options.\n  *\n  *  This is an experimental function, and is not an official part of the\n  *      ICU API.\n  *\n  *  The collator options, such as UCOL_STRENGTH and UCOL_NORMALIZTION, are honored.\n  *\n  *  The UStringSearch options USEARCH_CANONICAL_MATCH, USEARCH_OVERLAP and\n  *  any Break Iterator are ignored.\n  *\n  *  Matches obey the following constraints:\n  *\n  *      Characters at the start or end positions of a match that are ignorable\n  *      for collation are not included as part of the match, unless they\n  *      are part of a combining sequence, as described below.\n  *\n  *      A match will not include a partial combining sequence.  Combining\n  *      character sequences  are considered to be  inseperable units,\n  *      and either match the pattern completely, or are considered to not match\n  *      at all.  Thus, for example, an A followed a combining accent mark will \n  *      not be found when searching for a plain (unaccented) A.   (unless\n  *      the collation strength has been set to ignore all accents).\n  *\n  *      When beginning a search, the initial starting position, startIdx,\n  *      is assumed to be an acceptable match boundary with respect to\n  *      combining characters.  A combining sequence that spans across the\n  *      starting point will not supress a match beginning at startIdx.\n  *\n  *      Characters that expand to multiple collation elements\n  *      (German sharp-S becoming 'ss', or the composed forms of accented\n  *      characters, for example) also must match completely.\n  *      Searching for a single 's' in a string containing only a sharp-s will \n  *      find no match.\n  *\n  *\n  *  @param strsrch    the UStringSearch struct, which references both\n  *                    the text to be searched  and the pattern being sought.\n  *  @param startIdx   The index into the text to begin the search.\n  *  @param matchStart An out parameter, the starting index of the matched text.\n  *                    This parameter may be NULL.\n  *                    A value of -1 will be returned if no match was found.\n  *  @param matchLimit Out parameter, the index of the first position following the matched text.\n  *                    The matchLimit will be at a suitable position for beginning a subsequent search\n  *                    in the input text.\n  *                    This parameter may be NULL.\n  *                    A value of -1 will be returned if no match was found.\n  *          \n  *  @param status     Report any errors.  Note that no match found is not an error.\n  *  @return           TRUE if a match was found, FALSE otherwise.\n  *\n  *  @internal\n  */\nU_INTERNAL UBool U_EXPORT2 usearch_search(UStringSearch *strsrch,\n                                          int32_t        startIdx,\n                                          int32_t        *matchStart,\n                                          int32_t        *matchLimit,\n                                          UErrorCode     *status);\n\n/**\n  *  Simple backwards search for the pattern, starting at a specified index,\n  *     and using using a default set search options.\n  *\n  *  This is an experimental function, and is not an official part of the\n  *      ICU API.\n  *\n  *  The collator options, such as UCOL_STRENGTH and UCOL_NORMALIZTION, are honored.\n  *\n  *  The UStringSearch options USEARCH_CANONICAL_MATCH, USEARCH_OVERLAP and\n  *  any Break Iterator are ignored.\n  *\n  *  Matches obey the following constraints:\n  *\n  *      Characters at the start or end positions of a match that are ignorable\n  *      for collation are not included as part of the match, unless they\n  *      are part of a combining sequence, as described below.\n  *\n  *      A match will not include a partial combining sequence.  Combining\n  *      character sequences  are considered to be  inseperable units,\n  *      and either match the pattern completely, or are considered to not match\n  *      at all.  Thus, for example, an A followed a combining accent mark will \n  *      not be found when searching for a plain (unaccented) A.   (unless\n  *      the collation strength has been set to ignore all accents).\n  *\n  *      When beginning a search, the initial starting position, startIdx,\n  *      is assumed to be an acceptable match boundary with respect to\n  *      combining characters.  A combining sequence that spans across the\n  *      starting point will not supress a match beginning at startIdx.\n  *\n  *      Characters that expand to multiple collation elements\n  *      (German sharp-S becoming 'ss', or the composed forms of accented\n  *      characters, for example) also must match completely.\n  *      Searching for a single 's' in a string containing only a sharp-s will \n  *      find no match.\n  *\n  *\n  *  @param strsrch    the UStringSearch struct, which references both\n  *                    the text to be searched  and the pattern being sought.\n  *  @param startIdx   The index into the text to begin the search.\n  *  @param matchStart An out parameter, the starting index of the matched text.\n  *                    This parameter may be NULL.\n  *                    A value of -1 will be returned if no match was found.\n  *  @param matchLimit Out parameter, the index of the first position following the matched text.\n  *                    The matchLimit will be at a suitable position for beginning a subsequent search\n  *                    in the input text.\n  *                    This parameter may be NULL.\n  *                    A value of -1 will be returned if no match was found.\n  *          \n  *  @param status     Report any errors.  Note that no match found is not an error.\n  *  @return           TRUE if a match was found, FALSE otherwise.\n  *\n  *  @internal\n  */\nU_INTERNAL UBool U_EXPORT2 usearch_searchBackwards(UStringSearch *strsrch,\n                                                   int32_t        startIdx,\n                                                   int32_t        *matchStart,\n                                                   int32_t        *matchLimit,\n                                                   UErrorCode     *status);\n#endif  /* U_HIDE_INTERNAL_API */\n\n#endif /* #if !UCONFIG_NO_COLLATION  && !UCONFIG_NO_BREAK_ITERATION */\n\n#endif\n"
  },
  {
    "path": "deprecated/android/addons/icucompat/unicode/uset.h",
    "content": "/*\n*******************************************************************************\n*\n*   Copyright (C) 2002-2012, International Business Machines\n*   Corporation and others.  All Rights Reserved.\n*\n*******************************************************************************\n*   file name:  uset.h\n*   encoding:   US-ASCII\n*   tab size:   8 (not used)\n*   indentation:4\n*\n*   created on: 2002mar07\n*   created by: Markus W. Scherer\n*\n*   C version of UnicodeSet.\n*/\n\n\n/**\n * \\file\n * \\brief C API: Unicode Set\n *\n * <p>This is a C wrapper around the C++ UnicodeSet class.</p>\n */\n\n#ifndef __USET_H__\n#define __USET_H__\n\n#include \"unicode/utypes.h\"\n#include \"unicode/uchar.h\"\n#include \"unicode/localpointer.h\"\n\n#ifndef UCNV_H\nstruct USet;\n/**\n * A UnicodeSet.  Use the uset_* API to manipulate.  Create with\n * uset_open*, and destroy with uset_close.\n * @stable ICU 2.4\n */\ntypedef struct USet USet;\n#endif\n\n/**\n * Bitmask values to be passed to uset_openPatternOptions() or\n * uset_applyPattern() taking an option parameter.\n * @stable ICU 2.4\n */\nenum {\n    /**\n     * Ignore white space within patterns unless quoted or escaped.\n     * @stable ICU 2.4\n     */\n    USET_IGNORE_SPACE = 1,  \n\n    /**\n     * Enable case insensitive matching.  E.g., \"[ab]\" with this flag\n     * will match 'a', 'A', 'b', and 'B'.  \"[^ab]\" with this flag will\n     * match all except 'a', 'A', 'b', and 'B'. This performs a full\n     * closure over case mappings, e.g. U+017F for s.\n     *\n     * The resulting set is a superset of the input for the code points but\n     * not for the strings.\n     * It performs a case mapping closure of the code points and adds\n     * full case folding strings for the code points, and reduces strings of\n     * the original set to their full case folding equivalents.\n     *\n     * This is designed for case-insensitive matches, for example\n     * in regular expressions. The full code point case closure allows checking of\n     * an input character directly against the closure set.\n     * Strings are matched by comparing the case-folded form from the closure\n     * set with an incremental case folding of the string in question.\n     *\n     * The closure set will also contain single code points if the original\n     * set contained case-equivalent strings (like U+00DF for \"ss\" or \"Ss\" etc.).\n     * This is not necessary (that is, redundant) for the above matching method\n     * but results in the same closure sets regardless of whether the original\n     * set contained the code point or a string.\n     *\n     * @stable ICU 2.4\n     */\n    USET_CASE_INSENSITIVE = 2,  \n\n    /**\n     * Enable case insensitive matching.  E.g., \"[ab]\" with this flag\n     * will match 'a', 'A', 'b', and 'B'.  \"[^ab]\" with this flag will\n     * match all except 'a', 'A', 'b', and 'B'. This adds the lower-,\n     * title-, and uppercase mappings as well as the case folding\n     * of each existing element in the set.\n     * @stable ICU 3.2\n     */\n    USET_ADD_CASE_MAPPINGS = 4\n};\n\n/**\n * Argument values for whether span() and similar functions continue while\n * the current character is contained vs. not contained in the set.\n *\n * The functionality is straightforward for sets with only single code points,\n * without strings (which is the common case):\n * - USET_SPAN_CONTAINED and USET_SPAN_SIMPLE\n *   work the same.\n * - span() and spanBack() partition any string the same way when\n *   alternating between span(USET_SPAN_NOT_CONTAINED) and\n *   span(either \"contained\" condition).\n * - Using a complemented (inverted) set and the opposite span conditions\n *   yields the same results.\n *\n * When a set contains multi-code point strings, then these statements may not\n * be true, depending on the strings in the set (for example, whether they\n * overlap with each other) and the string that is processed.\n * For a set with strings:\n * - The complement of the set contains the opposite set of code points,\n *   but the same set of strings.\n *   Therefore, complementing both the set and the span conditions\n *   may yield different results.\n * - When starting spans at different positions in a string\n *   (span(s, ...) vs. span(s+1, ...)) the ends of the spans may be different\n *   because a set string may start before the later position.\n * - span(USET_SPAN_SIMPLE) may be shorter than\n *   span(USET_SPAN_CONTAINED) because it will not recursively try\n *   all possible paths.\n *   For example, with a set which contains the three strings \"xy\", \"xya\" and \"ax\",\n *   span(\"xyax\", USET_SPAN_CONTAINED) will return 4 but\n *   span(\"xyax\", USET_SPAN_SIMPLE) will return 3.\n *   span(USET_SPAN_SIMPLE) will never be longer than\n *   span(USET_SPAN_CONTAINED).\n * - With either \"contained\" condition, span() and spanBack() may partition\n *   a string in different ways.\n *   For example, with a set which contains the two strings \"ab\" and \"ba\",\n *   and when processing the string \"aba\",\n *   span() will yield contained/not-contained boundaries of { 0, 2, 3 }\n *   while spanBack() will yield boundaries of { 0, 1, 3 }.\n *\n * Note: If it is important to get the same boundaries whether iterating forward\n * or backward through a string, then either only span() should be used and\n * the boundaries cached for backward operation, or an ICU BreakIterator\n * could be used.\n *\n * Note: Unpaired surrogates are treated like surrogate code points.\n * Similarly, set strings match only on code point boundaries,\n * never in the middle of a surrogate pair.\n * Illegal UTF-8 sequences are treated like U+FFFD.\n * When processing UTF-8 strings, malformed set strings\n * (strings with unpaired surrogates which cannot be converted to UTF-8)\n * are ignored.\n *\n * @stable ICU 3.8\n */\ntypedef enum USetSpanCondition {\n    /**\n     * Continue a span() while there is no set element at the current position.\n     * Stops before the first set element (character or string).\n     * (For code points only, this is like while contains(current)==FALSE).\n     *\n     * When span() returns, the substring between where it started and the position\n     * it returned consists only of characters that are not in the set,\n     * and none of its strings overlap with the span.\n     *\n     * @stable ICU 3.8\n     */\n    USET_SPAN_NOT_CONTAINED = 0,\n    /**\n     * Continue a span() while there is a set element at the current position.\n     * (For characters only, this is like while contains(current)==TRUE).\n     *\n     * When span() returns, the substring between where it started and the position\n     * it returned consists only of set elements (characters or strings) that are in the set.\n     *\n     * If a set contains strings, then the span will be the longest substring\n     * matching any of the possible concatenations of set elements (characters or strings).\n     * (There must be a single, non-overlapping concatenation of characters or strings.)\n     * This is equivalent to a POSIX regular expression for (OR of each set element)*.\n     *\n     * @stable ICU 3.8\n     */\n    USET_SPAN_CONTAINED = 1,\n    /**\n     * Continue a span() while there is a set element at the current position.\n     * (For characters only, this is like while contains(current)==TRUE).\n     *\n     * When span() returns, the substring between where it started and the position\n     * it returned consists only of set elements (characters or strings) that are in the set.\n     *\n     * If a set only contains single characters, then this is the same\n     * as USET_SPAN_CONTAINED.\n     *\n     * If a set contains strings, then the span will be the longest substring\n     * with a match at each position with the longest single set element (character or string).\n     *\n     * Use this span condition together with other longest-match algorithms,\n     * such as ICU converters (ucnv_getUnicodeSet()).\n     *\n     * @stable ICU 3.8\n     */\n    USET_SPAN_SIMPLE = 2,\n    /**\n     * One more than the last span condition.\n     * @stable ICU 3.8\n     */\n    USET_SPAN_CONDITION_COUNT\n} USetSpanCondition;\n\nenum {\n    /**\n     * Capacity of USerializedSet::staticArray.\n     * Enough for any single-code point set.\n     * Also provides padding for nice sizeof(USerializedSet).\n     * @stable ICU 2.4\n     */\n    USET_SERIALIZED_STATIC_ARRAY_CAPACITY=8\n};\n\n/**\n * A serialized form of a Unicode set.  Limited manipulations are\n * possible directly on a serialized set.  See below.\n * @stable ICU 2.4\n */\ntypedef struct USerializedSet {\n    /**\n     * The serialized Unicode Set.\n     * @stable ICU 2.4\n     */\n    const uint16_t *array;\n    /**\n     * The length of the array that contains BMP characters.\n     * @stable ICU 2.4\n     */\n    int32_t bmpLength;\n    /**\n     * The total length of the array.\n     * @stable ICU 2.4\n     */\n    int32_t length;\n    /**\n     * A small buffer for the array to reduce memory allocations.\n     * @stable ICU 2.4\n     */\n    uint16_t staticArray[USET_SERIALIZED_STATIC_ARRAY_CAPACITY];\n} USerializedSet;\n\n/*********************************************************************\n * USet API\n *********************************************************************/\n\n/**\n * Create an empty USet object.\n * Equivalent to uset_open(1, 0).\n * @return a newly created USet.  The caller must call uset_close() on\n * it when done.\n * @stable ICU 4.2\n */\nU_STABLE USet* U_EXPORT2\nuset_openEmpty(void);\n\n/**\n * Creates a USet object that contains the range of characters\n * start..end, inclusive.  If <code>start > end</code> \n * then an empty set is created (same as using uset_openEmpty()).\n * @param start first character of the range, inclusive\n * @param end last character of the range, inclusive\n * @return a newly created USet.  The caller must call uset_close() on\n * it when done.\n * @stable ICU 2.4\n */\nU_STABLE USet* U_EXPORT2\nuset_open(UChar32 start, UChar32 end);\n\n/**\n * Creates a set from the given pattern.  See the UnicodeSet class\n * description for the syntax of the pattern language.\n * @param pattern a string specifying what characters are in the set\n * @param patternLength the length of the pattern, or -1 if null\n * terminated\n * @param ec the error code\n * @stable ICU 2.4\n */\nU_STABLE USet* U_EXPORT2\nuset_openPattern(const UChar* pattern, int32_t patternLength,\n                 UErrorCode* ec);\n\n/**\n * Creates a set from the given pattern.  See the UnicodeSet class\n * description for the syntax of the pattern language.\n * @param pattern a string specifying what characters are in the set\n * @param patternLength the length of the pattern, or -1 if null\n * terminated\n * @param options bitmask for options to apply to the pattern.\n * Valid options are USET_IGNORE_SPACE and USET_CASE_INSENSITIVE.\n * @param ec the error code\n * @stable ICU 2.4\n */\nU_STABLE USet* U_EXPORT2\nuset_openPatternOptions(const UChar* pattern, int32_t patternLength,\n                 uint32_t options,\n                 UErrorCode* ec);\n\n/**\n * Disposes of the storage used by a USet object.  This function should\n * be called exactly once for objects returned by uset_open().\n * @param set the object to dispose of\n * @stable ICU 2.4\n */\nU_STABLE void U_EXPORT2\nuset_close(USet* set);\n\n#if U_SHOW_CPLUSPLUS_API\n\nU_NAMESPACE_BEGIN\n\n/**\n * \\class LocalUSetPointer\n * \"Smart pointer\" class, closes a USet via uset_close().\n * For most methods see the LocalPointerBase base class.\n *\n * @see LocalPointerBase\n * @see LocalPointer\n * @stable ICU 4.4\n */\nU_DEFINE_LOCAL_OPEN_POINTER(LocalUSetPointer, USet, uset_close);\n\nU_NAMESPACE_END\n\n#endif\n\n/**\n * Returns a copy of this object.\n * If this set is frozen, then the clone will be frozen as well.\n * Use uset_cloneAsThawed() for a mutable clone of a frozen set.\n * @param set the original set\n * @return the newly allocated copy of the set\n * @see uset_cloneAsThawed\n * @stable ICU 3.8\n */\nU_STABLE USet * U_EXPORT2\nuset_clone(const USet *set);\n\n/**\n * Determines whether the set has been frozen (made immutable) or not.\n * See the ICU4J Freezable interface for details.\n * @param set the set\n * @return TRUE/FALSE for whether the set has been frozen\n * @see uset_freeze\n * @see uset_cloneAsThawed\n * @stable ICU 3.8\n */\nU_STABLE UBool U_EXPORT2\nuset_isFrozen(const USet *set);\n\n/**\n * Freeze the set (make it immutable).\n * Once frozen, it cannot be unfrozen and is therefore thread-safe\n * until it is deleted.\n * See the ICU4J Freezable interface for details.\n * Freezing the set may also make some operations faster, for example\n * uset_contains() and uset_span().\n * A frozen set will not be modified. (It remains frozen.)\n * @param set the set\n * @return the same set, now frozen\n * @see uset_isFrozen\n * @see uset_cloneAsThawed\n * @stable ICU 3.8\n */\nU_STABLE void U_EXPORT2\nuset_freeze(USet *set);\n\n/**\n * Clone the set and make the clone mutable.\n * See the ICU4J Freezable interface for details.\n * @param set the set\n * @return the mutable clone\n * @see uset_freeze\n * @see uset_isFrozen\n * @see uset_clone\n * @stable ICU 3.8\n */\nU_STABLE USet * U_EXPORT2\nuset_cloneAsThawed(const USet *set);\n\n/**\n * Causes the USet object to represent the range <code>start - end</code>.\n * If <code>start > end</code> then this USet is set to an empty range.\n * A frozen set will not be modified.\n * @param set the object to set to the given range\n * @param start first character in the set, inclusive\n * @param end last character in the set, inclusive\n * @stable ICU 3.2\n */\nU_STABLE void U_EXPORT2\nuset_set(USet* set,\n         UChar32 start, UChar32 end);\n\n/**\n * Modifies the set to represent the set specified by the given\n * pattern. See the UnicodeSet class description for the syntax of \n * the pattern language. See also the User Guide chapter about UnicodeSet.\n * <em>Empties the set passed before applying the pattern.</em>\n * A frozen set will not be modified.\n * @param set               The set to which the pattern is to be applied. \n * @param pattern           A pointer to UChar string specifying what characters are in the set.\n *                          The character at pattern[0] must be a '['.\n * @param patternLength     The length of the UChar string. -1 if NUL terminated.\n * @param options           A bitmask for options to apply to the pattern.\n *                          Valid options are USET_IGNORE_SPACE and USET_CASE_INSENSITIVE.\n * @param status            Returns an error if the pattern cannot be parsed.\n * @return                  Upon successful parse, the value is either\n *                          the index of the character after the closing ']' \n *                          of the parsed pattern.\n *                          If the status code indicates failure, then the return value \n *                          is the index of the error in the source.\n *\n * @stable ICU 2.8\n */\nU_STABLE int32_t U_EXPORT2 \nuset_applyPattern(USet *set,\n                  const UChar *pattern, int32_t patternLength,\n                  uint32_t options,\n                  UErrorCode *status);\n\n/**\n * Modifies the set to contain those code points which have the given value\n * for the given binary or enumerated property, as returned by\n * u_getIntPropertyValue.  Prior contents of this set are lost.\n * A frozen set will not be modified.\n *\n * @param set the object to contain the code points defined by the property\n *\n * @param prop a property in the range UCHAR_BIN_START..UCHAR_BIN_LIMIT-1\n * or UCHAR_INT_START..UCHAR_INT_LIMIT-1\n * or UCHAR_MASK_START..UCHAR_MASK_LIMIT-1.\n *\n * @param value a value in the range u_getIntPropertyMinValue(prop)..\n * u_getIntPropertyMaxValue(prop), with one exception.  If prop is\n * UCHAR_GENERAL_CATEGORY_MASK, then value should not be a UCharCategory, but\n * rather a mask value produced by U_GET_GC_MASK().  This allows grouped\n * categories such as [:L:] to be represented.\n *\n * @param ec error code input/output parameter\n *\n * @stable ICU 3.2\n */\nU_STABLE void U_EXPORT2\nuset_applyIntPropertyValue(USet* set,\n                           UProperty prop, int32_t value, UErrorCode* ec);\n\n/**\n * Modifies the set to contain those code points which have the\n * given value for the given property.  Prior contents of this\n * set are lost.\n * A frozen set will not be modified.\n *\n * @param set the object to contain the code points defined by the given\n * property and value alias\n *\n * @param prop a string specifying a property alias, either short or long.\n * The name is matched loosely.  See PropertyAliases.txt for names and a\n * description of loose matching.  If the value string is empty, then this\n * string is interpreted as either a General_Category value alias, a Script\n * value alias, a binary property alias, or a special ID.  Special IDs are\n * matched loosely and correspond to the following sets:\n *\n * \"ANY\" = [\\\\u0000-\\\\U0010FFFF],\n * \"ASCII\" = [\\\\u0000-\\\\u007F],\n * \"Assigned\" = [:^Cn:].\n *\n * @param propLength the length of the prop, or -1 if NULL\n *\n * @param value a string specifying a value alias, either short or long.\n * The name is matched loosely.  See PropertyValueAliases.txt for names\n * and a description of loose matching.  In addition to aliases listed,\n * numeric values and canonical combining classes may be expressed\n * numerically, e.g., (\"nv\", \"0.5\") or (\"ccc\", \"220\").  The value string\n * may also be empty.\n *\n * @param valueLength the length of the value, or -1 if NULL\n *\n * @param ec error code input/output parameter\n *\n * @stable ICU 3.2\n */\nU_STABLE void U_EXPORT2\nuset_applyPropertyAlias(USet* set,\n                        const UChar *prop, int32_t propLength,\n                        const UChar *value, int32_t valueLength,\n                        UErrorCode* ec);\n\n/**\n * Return true if the given position, in the given pattern, appears\n * to be the start of a UnicodeSet pattern.\n *\n * @param pattern a string specifying the pattern\n * @param patternLength the length of the pattern, or -1 if NULL\n * @param pos the given position\n * @stable ICU 3.2\n */\nU_STABLE UBool U_EXPORT2\nuset_resemblesPattern(const UChar *pattern, int32_t patternLength,\n                      int32_t pos);\n\n/**\n * Returns a string representation of this set.  If the result of\n * calling this function is passed to a uset_openPattern(), it\n * will produce another set that is equal to this one.\n * @param set the set\n * @param result the string to receive the rules, may be NULL\n * @param resultCapacity the capacity of result, may be 0 if result is NULL\n * @param escapeUnprintable if TRUE then convert unprintable\n * character to their hex escape representations, \\\\uxxxx or\n * \\\\Uxxxxxxxx.  Unprintable characters are those other than\n * U+000A, U+0020..U+007E.\n * @param ec error code.\n * @return length of string, possibly larger than resultCapacity\n * @stable ICU 2.4\n */\nU_STABLE int32_t U_EXPORT2\nuset_toPattern(const USet* set,\n               UChar* result, int32_t resultCapacity,\n               UBool escapeUnprintable,\n               UErrorCode* ec);\n\n/**\n * Adds the given character to the given USet.  After this call,\n * uset_contains(set, c) will return TRUE.\n * A frozen set will not be modified.\n * @param set the object to which to add the character\n * @param c the character to add\n * @stable ICU 2.4\n */\nU_STABLE void U_EXPORT2\nuset_add(USet* set, UChar32 c);\n\n/**\n * Adds all of the elements in the specified set to this set if\n * they're not already present.  This operation effectively\n * modifies this set so that its value is the <i>union</i> of the two\n * sets.  The behavior of this operation is unspecified if the specified\n * collection is modified while the operation is in progress.\n * A frozen set will not be modified.\n *\n * @param set the object to which to add the set\n * @param additionalSet the source set whose elements are to be added to this set.\n * @stable ICU 2.6\n */\nU_STABLE void U_EXPORT2\nuset_addAll(USet* set, const USet *additionalSet);\n\n/**\n * Adds the given range of characters to the given USet.  After this call,\n * uset_contains(set, start, end) will return TRUE.\n * A frozen set will not be modified.\n * @param set the object to which to add the character\n * @param start the first character of the range to add, inclusive\n * @param end the last character of the range to add, inclusive\n * @stable ICU 2.2\n */\nU_STABLE void U_EXPORT2\nuset_addRange(USet* set, UChar32 start, UChar32 end);\n\n/**\n * Adds the given string to the given USet.  After this call,\n * uset_containsString(set, str, strLen) will return TRUE.\n * A frozen set will not be modified.\n * @param set the object to which to add the character\n * @param str the string to add\n * @param strLen the length of the string or -1 if null terminated.\n * @stable ICU 2.4\n */\nU_STABLE void U_EXPORT2\nuset_addString(USet* set, const UChar* str, int32_t strLen);\n\n/**\n * Adds each of the characters in this string to the set. Thus \"ch\" => {\"c\", \"h\"}\n * If this set already any particular character, it has no effect on that character.\n * A frozen set will not be modified.\n * @param set the object to which to add the character\n * @param str the source string\n * @param strLen the length of the string or -1 if null terminated.\n * @stable ICU 3.4\n */\nU_STABLE void U_EXPORT2\nuset_addAllCodePoints(USet* set, const UChar *str, int32_t strLen);\n\n/**\n * Removes the given character from the given USet.  After this call,\n * uset_contains(set, c) will return FALSE.\n * A frozen set will not be modified.\n * @param set the object from which to remove the character\n * @param c the character to remove\n * @stable ICU 2.4\n */\nU_STABLE void U_EXPORT2\nuset_remove(USet* set, UChar32 c);\n\n/**\n * Removes the given range of characters from the given USet.  After this call,\n * uset_contains(set, start, end) will return FALSE.\n * A frozen set will not be modified.\n * @param set the object to which to add the character\n * @param start the first character of the range to remove, inclusive\n * @param end the last character of the range to remove, inclusive\n * @stable ICU 2.2\n */\nU_STABLE void U_EXPORT2\nuset_removeRange(USet* set, UChar32 start, UChar32 end);\n\n/**\n * Removes the given string to the given USet.  After this call,\n * uset_containsString(set, str, strLen) will return FALSE.\n * A frozen set will not be modified.\n * @param set the object to which to add the character\n * @param str the string to remove\n * @param strLen the length of the string or -1 if null terminated.\n * @stable ICU 2.4\n */\nU_STABLE void U_EXPORT2\nuset_removeString(USet* set, const UChar* str, int32_t strLen);\n\n/**\n * Removes from this set all of its elements that are contained in the\n * specified set.  This operation effectively modifies this\n * set so that its value is the <i>asymmetric set difference</i> of\n * the two sets.\n * A frozen set will not be modified.\n * @param set the object from which the elements are to be removed\n * @param removeSet the object that defines which elements will be\n * removed from this set\n * @stable ICU 3.2\n */\nU_STABLE void U_EXPORT2\nuset_removeAll(USet* set, const USet* removeSet);\n\n/**\n * Retain only the elements in this set that are contained in the\n * specified range.  If <code>start > end</code> then an empty range is\n * retained, leaving the set empty.  This is equivalent to\n * a boolean logic AND, or a set INTERSECTION.\n * A frozen set will not be modified.\n *\n * @param set the object for which to retain only the specified range\n * @param start first character, inclusive, of range to be retained\n * to this set.\n * @param end last character, inclusive, of range to be retained\n * to this set.\n * @stable ICU 3.2\n */\nU_STABLE void U_EXPORT2\nuset_retain(USet* set, UChar32 start, UChar32 end);\n\n/**\n * Retains only the elements in this set that are contained in the\n * specified set.  In other words, removes from this set all of\n * its elements that are not contained in the specified set.  This\n * operation effectively modifies this set so that its value is\n * the <i>intersection</i> of the two sets.\n * A frozen set will not be modified.\n *\n * @param set the object on which to perform the retain\n * @param retain set that defines which elements this set will retain\n * @stable ICU 3.2\n */\nU_STABLE void U_EXPORT2\nuset_retainAll(USet* set, const USet* retain);\n\n/**\n * Reallocate this objects internal structures to take up the least\n * possible space, without changing this object's value.\n * A frozen set will not be modified.\n *\n * @param set the object on which to perfrom the compact\n * @stable ICU 3.2\n */\nU_STABLE void U_EXPORT2\nuset_compact(USet* set);\n\n/**\n * Inverts this set.  This operation modifies this set so that\n * its value is its complement.  This operation does not affect\n * the multicharacter strings, if any.\n * A frozen set will not be modified.\n * @param set the set\n * @stable ICU 2.4\n */\nU_STABLE void U_EXPORT2\nuset_complement(USet* set);\n\n/**\n * Complements in this set all elements contained in the specified\n * set.  Any character in the other set will be removed if it is\n * in this set, or will be added if it is not in this set.\n * A frozen set will not be modified.\n *\n * @param set the set with which to complement\n * @param complement set that defines which elements will be xor'ed\n * from this set.\n * @stable ICU 3.2\n */\nU_STABLE void U_EXPORT2\nuset_complementAll(USet* set, const USet* complement);\n\n/**\n * Removes all of the elements from this set.  This set will be\n * empty after this call returns.\n * A frozen set will not be modified.\n * @param set the set\n * @stable ICU 2.4\n */\nU_STABLE void U_EXPORT2\nuset_clear(USet* set);\n\n/**\n * Close this set over the given attribute.  For the attribute\n * USET_CASE, the result is to modify this set so that:\n *\n * 1. For each character or string 'a' in this set, all strings or\n * characters 'b' such that foldCase(a) == foldCase(b) are added\n * to this set.\n *\n * 2. For each string 'e' in the resulting set, if e !=\n * foldCase(e), 'e' will be removed.\n *\n * Example: [aq\\\\u00DF{Bc}{bC}{Fi}] => [aAqQ\\\\u00DF\\\\uFB01{ss}{bc}{fi}]\n *\n * (Here foldCase(x) refers to the operation u_strFoldCase, and a\n * == b denotes that the contents are the same, not pointer\n * comparison.)\n *\n * A frozen set will not be modified.\n *\n * @param set the set\n *\n * @param attributes bitmask for attributes to close over.\n * Currently only the USET_CASE bit is supported.  Any undefined bits\n * are ignored.\n * @stable ICU 4.2\n */\nU_STABLE void U_EXPORT2\nuset_closeOver(USet* set, int32_t attributes);\n\n/**\n * Remove all strings from this set.\n *\n * @param set the set\n * @stable ICU 4.2\n */\nU_STABLE void U_EXPORT2\nuset_removeAllStrings(USet* set);\n\n/**\n * Returns TRUE if the given USet contains no characters and no\n * strings.\n * @param set the set\n * @return true if set is empty\n * @stable ICU 2.4\n */\nU_STABLE UBool U_EXPORT2\nuset_isEmpty(const USet* set);\n\n/**\n * Returns TRUE if the given USet contains the given character.\n * This function works faster with a frozen set.\n * @param set the set\n * @param c The codepoint to check for within the set\n * @return true if set contains c\n * @stable ICU 2.4\n */\nU_STABLE UBool U_EXPORT2\nuset_contains(const USet* set, UChar32 c);\n\n/**\n * Returns TRUE if the given USet contains all characters c\n * where start <= c && c <= end.\n * @param set the set\n * @param start the first character of the range to test, inclusive\n * @param end the last character of the range to test, inclusive\n * @return TRUE if set contains the range\n * @stable ICU 2.2\n */\nU_STABLE UBool U_EXPORT2\nuset_containsRange(const USet* set, UChar32 start, UChar32 end);\n\n/**\n * Returns TRUE if the given USet contains the given string.\n * @param set the set\n * @param str the string\n * @param strLen the length of the string or -1 if null terminated.\n * @return true if set contains str\n * @stable ICU 2.4\n */\nU_STABLE UBool U_EXPORT2\nuset_containsString(const USet* set, const UChar* str, int32_t strLen);\n\n/**\n * Returns the index of the given character within this set, where\n * the set is ordered by ascending code point.  If the character\n * is not in this set, return -1.  The inverse of this method is\n * <code>charAt()</code>.\n * @param set the set\n * @param c the character to obtain the index for\n * @return an index from 0..size()-1, or -1\n * @stable ICU 3.2\n */\nU_STABLE int32_t U_EXPORT2\nuset_indexOf(const USet* set, UChar32 c);\n\n/**\n * Returns the character at the given index within this set, where\n * the set is ordered by ascending code point.  If the index is\n * out of range, return (UChar32)-1.  The inverse of this method is\n * <code>indexOf()</code>.\n * @param set the set\n * @param charIndex an index from 0..size()-1 to obtain the char for\n * @return the character at the given index, or (UChar32)-1.\n * @stable ICU 3.2\n */\nU_STABLE UChar32 U_EXPORT2\nuset_charAt(const USet* set, int32_t charIndex);\n\n/**\n * Returns the number of characters and strings contained in the given\n * USet.\n * @param set the set\n * @return a non-negative integer counting the characters and strings\n * contained in set\n * @stable ICU 2.4\n */\nU_STABLE int32_t U_EXPORT2\nuset_size(const USet* set);\n\n/**\n * Returns the number of items in this set.  An item is either a range\n * of characters or a single multicharacter string.\n * @param set the set\n * @return a non-negative integer counting the character ranges\n * and/or strings contained in set\n * @stable ICU 2.4\n */\nU_STABLE int32_t U_EXPORT2\nuset_getItemCount(const USet* set);\n\n/**\n * Returns an item of this set.  An item is either a range of\n * characters or a single multicharacter string.\n * @param set the set\n * @param itemIndex a non-negative integer in the range 0..\n * uset_getItemCount(set)-1\n * @param start pointer to variable to receive first character\n * in range, inclusive\n * @param end pointer to variable to receive last character in range,\n * inclusive\n * @param str buffer to receive the string, may be NULL\n * @param strCapacity capacity of str, or 0 if str is NULL\n * @param ec error code\n * @return the length of the string (>= 2), or 0 if the item is a\n * range, in which case it is the range *start..*end, or -1 if\n * itemIndex is out of range\n * @stable ICU 2.4\n */\nU_STABLE int32_t U_EXPORT2\nuset_getItem(const USet* set, int32_t itemIndex,\n             UChar32* start, UChar32* end,\n             UChar* str, int32_t strCapacity,\n             UErrorCode* ec);\n\n/**\n * Returns true if set1 contains all the characters and strings\n * of set2. It answers the question, 'Is set1 a superset of set2?'\n * @param set1 set to be checked for containment\n * @param set2 set to be checked for containment\n * @return true if the test condition is met\n * @stable ICU 3.2\n */\nU_STABLE UBool U_EXPORT2\nuset_containsAll(const USet* set1, const USet* set2);\n\n/**\n * Returns true if this set contains all the characters\n * of the given string. This is does not check containment of grapheme\n * clusters, like uset_containsString.\n * @param set set of characters to be checked for containment\n * @param str string containing codepoints to be checked for containment\n * @param strLen the length of the string or -1 if null terminated.\n * @return true if the test condition is met\n * @stable ICU 3.4\n */\nU_STABLE UBool U_EXPORT2\nuset_containsAllCodePoints(const USet* set, const UChar *str, int32_t strLen);\n\n/**\n * Returns true if set1 contains none of the characters and strings\n * of set2. It answers the question, 'Is set1 a disjoint set of set2?'\n * @param set1 set to be checked for containment\n * @param set2 set to be checked for containment\n * @return true if the test condition is met\n * @stable ICU 3.2\n */\nU_STABLE UBool U_EXPORT2\nuset_containsNone(const USet* set1, const USet* set2);\n\n/**\n * Returns true if set1 contains some of the characters and strings\n * of set2. It answers the question, 'Does set1 and set2 have an intersection?'\n * @param set1 set to be checked for containment\n * @param set2 set to be checked for containment\n * @return true if the test condition is met\n * @stable ICU 3.2\n */\nU_STABLE UBool U_EXPORT2\nuset_containsSome(const USet* set1, const USet* set2);\n\n/**\n * Returns the length of the initial substring of the input string which\n * consists only of characters and strings that are contained in this set\n * (USET_SPAN_CONTAINED, USET_SPAN_SIMPLE),\n * or only of characters and strings that are not contained\n * in this set (USET_SPAN_NOT_CONTAINED).\n * See USetSpanCondition for details.\n * Similar to the strspn() C library function.\n * Unpaired surrogates are treated according to contains() of their surrogate code points.\n * This function works faster with a frozen set and with a non-negative string length argument.\n * @param set the set\n * @param s start of the string\n * @param length of the string; can be -1 for NUL-terminated\n * @param spanCondition specifies the containment condition\n * @return the length of the initial substring according to the spanCondition;\n *         0 if the start of the string does not fit the spanCondition\n * @stable ICU 3.8\n * @see USetSpanCondition\n */\nU_STABLE int32_t U_EXPORT2\nuset_span(const USet *set, const UChar *s, int32_t length, USetSpanCondition spanCondition);\n\n/**\n * Returns the start of the trailing substring of the input string which\n * consists only of characters and strings that are contained in this set\n * (USET_SPAN_CONTAINED, USET_SPAN_SIMPLE),\n * or only of characters and strings that are not contained\n * in this set (USET_SPAN_NOT_CONTAINED).\n * See USetSpanCondition for details.\n * Unpaired surrogates are treated according to contains() of their surrogate code points.\n * This function works faster with a frozen set and with a non-negative string length argument.\n * @param set the set\n * @param s start of the string\n * @param length of the string; can be -1 for NUL-terminated\n * @param spanCondition specifies the containment condition\n * @return the start of the trailing substring according to the spanCondition;\n *         the string length if the end of the string does not fit the spanCondition\n * @stable ICU 3.8\n * @see USetSpanCondition\n */\nU_STABLE int32_t U_EXPORT2\nuset_spanBack(const USet *set, const UChar *s, int32_t length, USetSpanCondition spanCondition);\n\n/**\n * Returns the length of the initial substring of the input string which\n * consists only of characters and strings that are contained in this set\n * (USET_SPAN_CONTAINED, USET_SPAN_SIMPLE),\n * or only of characters and strings that are not contained\n * in this set (USET_SPAN_NOT_CONTAINED).\n * See USetSpanCondition for details.\n * Similar to the strspn() C library function.\n * Malformed byte sequences are treated according to contains(0xfffd).\n * This function works faster with a frozen set and with a non-negative string length argument.\n * @param set the set\n * @param s start of the string (UTF-8)\n * @param length of the string; can be -1 for NUL-terminated\n * @param spanCondition specifies the containment condition\n * @return the length of the initial substring according to the spanCondition;\n *         0 if the start of the string does not fit the spanCondition\n * @stable ICU 3.8\n * @see USetSpanCondition\n */\nU_STABLE int32_t U_EXPORT2\nuset_spanUTF8(const USet *set, const char *s, int32_t length, USetSpanCondition spanCondition);\n\n/**\n * Returns the start of the trailing substring of the input string which\n * consists only of characters and strings that are contained in this set\n * (USET_SPAN_CONTAINED, USET_SPAN_SIMPLE),\n * or only of characters and strings that are not contained\n * in this set (USET_SPAN_NOT_CONTAINED).\n * See USetSpanCondition for details.\n * Malformed byte sequences are treated according to contains(0xfffd).\n * This function works faster with a frozen set and with a non-negative string length argument.\n * @param set the set\n * @param s start of the string (UTF-8)\n * @param length of the string; can be -1 for NUL-terminated\n * @param spanCondition specifies the containment condition\n * @return the start of the trailing substring according to the spanCondition;\n *         the string length if the end of the string does not fit the spanCondition\n * @stable ICU 3.8\n * @see USetSpanCondition\n */\nU_STABLE int32_t U_EXPORT2\nuset_spanBackUTF8(const USet *set, const char *s, int32_t length, USetSpanCondition spanCondition);\n\n/**\n * Returns true if set1 contains all of the characters and strings\n * of set2, and vis versa. It answers the question, 'Is set1 equal to set2?'\n * @param set1 set to be checked for containment\n * @param set2 set to be checked for containment\n * @return true if the test condition is met\n * @stable ICU 3.2\n */\nU_STABLE UBool U_EXPORT2\nuset_equals(const USet* set1, const USet* set2);\n\n/*********************************************************************\n * Serialized set API\n *********************************************************************/\n\n/**\n * Serializes this set into an array of 16-bit integers.  Serialization\n * (currently) only records the characters in the set; multicharacter\n * strings are ignored.\n *\n * The array\n * has following format (each line is one 16-bit integer):\n *\n *  length     = (n+2*m) | (m!=0?0x8000:0)\n *  bmpLength  = n; present if m!=0\n *  bmp[0]\n *  bmp[1]\n *  ...\n *  bmp[n-1]\n *  supp-high[0]\n *  supp-low[0]\n *  supp-high[1]\n *  supp-low[1]\n *  ...\n *  supp-high[m-1]\n *  supp-low[m-1]\n *\n * The array starts with a header.  After the header are n bmp\n * code points, then m supplementary code points.  Either n or m\n * or both may be zero.  n+2*m is always <= 0x7FFF.\n *\n * If there are no supplementary characters (if m==0) then the\n * header is one 16-bit integer, 'length', with value n.\n *\n * If there are supplementary characters (if m!=0) then the header\n * is two 16-bit integers.  The first, 'length', has value\n * (n+2*m)|0x8000.  The second, 'bmpLength', has value n.\n *\n * After the header the code points are stored in ascending order.\n * Supplementary code points are stored as most significant 16\n * bits followed by least significant 16 bits.\n *\n * @param set the set\n * @param dest pointer to buffer of destCapacity 16-bit integers.\n * May be NULL only if destCapacity is zero.\n * @param destCapacity size of dest, or zero.  Must not be negative.\n * @param pErrorCode pointer to the error code.  Will be set to\n * U_INDEX_OUTOFBOUNDS_ERROR if n+2*m > 0x7FFF.  Will be set to\n * U_BUFFER_OVERFLOW_ERROR if n+2*m+(m!=0?2:1) > destCapacity.\n * @return the total length of the serialized format, including\n * the header, that is, n+2*m+(m!=0?2:1), or 0 on error other\n * than U_BUFFER_OVERFLOW_ERROR.\n * @stable ICU 2.4\n */\nU_STABLE int32_t U_EXPORT2\nuset_serialize(const USet* set, uint16_t* dest, int32_t destCapacity, UErrorCode* pErrorCode);\n\n/**\n * Given a serialized array, fill in the given serialized set object.\n * @param fillSet pointer to result\n * @param src pointer to start of array\n * @param srcLength length of array\n * @return true if the given array is valid, otherwise false\n * @stable ICU 2.4\n */\nU_STABLE UBool U_EXPORT2\nuset_getSerializedSet(USerializedSet* fillSet, const uint16_t* src, int32_t srcLength);\n\n/**\n * Set the USerializedSet to contain the given character (and nothing\n * else).\n * @param fillSet pointer to result\n * @param c The codepoint to set\n * @stable ICU 2.4\n */\nU_STABLE void U_EXPORT2\nuset_setSerializedToOne(USerializedSet* fillSet, UChar32 c);\n\n/**\n * Returns TRUE if the given USerializedSet contains the given\n * character.\n * @param set the serialized set\n * @param c The codepoint to check for within the set\n * @return true if set contains c\n * @stable ICU 2.4\n */\nU_STABLE UBool U_EXPORT2\nuset_serializedContains(const USerializedSet* set, UChar32 c);\n\n/**\n * Returns the number of disjoint ranges of characters contained in\n * the given serialized set.  Ignores any strings contained in the\n * set.\n * @param set the serialized set\n * @return a non-negative integer counting the character ranges\n * contained in set\n * @stable ICU 2.4\n */\nU_STABLE int32_t U_EXPORT2\nuset_getSerializedRangeCount(const USerializedSet* set);\n\n/**\n * Returns a range of characters contained in the given serialized\n * set.\n * @param set the serialized set\n * @param rangeIndex a non-negative integer in the range 0..\n * uset_getSerializedRangeCount(set)-1\n * @param pStart pointer to variable to receive first character\n * in range, inclusive\n * @param pEnd pointer to variable to receive last character in range,\n * inclusive\n * @return true if rangeIndex is valid, otherwise false\n * @stable ICU 2.4\n */\nU_STABLE UBool U_EXPORT2\nuset_getSerializedRange(const USerializedSet* set, int32_t rangeIndex,\n                        UChar32* pStart, UChar32* pEnd);\n\n#endif\n"
  },
  {
    "path": "deprecated/android/addons/icucompat/unicode/usetiter.h",
    "content": "/*\n**********************************************************************\n* Copyright (c) 2002-2008, International Business Machines\n* Corporation and others.  All Rights Reserved.\n**********************************************************************\n*/\n#ifndef USETITER_H\n#define USETITER_H\n\n#include \"unicode/utypes.h\"\n#include \"unicode/uobject.h\"\n#include \"unicode/unistr.h\"\n\n/**\n * \\file \n * \\brief C++ API: UnicodeSetIterator iterates over the contents of a UnicodeSet.\n */\n\nU_NAMESPACE_BEGIN\n\nclass UnicodeSet;\nclass UnicodeString;\n\n/**\n *\n * UnicodeSetIterator iterates over the contents of a UnicodeSet.  It\n * iterates over either code points or code point ranges.  After all\n * code points or ranges have been returned, it returns the\n * multicharacter strings of the UnicodeSet, if any.\n *\n * This class is not intended to be subclassed.  Consider any fields\n *  or methods declared as \"protected\" to be private.  The use of\n *  protected in this class is an artifact of history.\n *\n * <p>To iterate over code points and strings, use a loop like this:\n * <pre>\n * UnicodeSetIterator it(set);\n * while (it.next()) {\n *     processItem(it.getString());\n * }\n * </pre>\n * <p>Each item in the set is accessed as a string.  Set elements\n *    consisting of single code points are returned as strings containing\n *    just the one code point.\n *\n * <p>To iterate over code point ranges, instead of individual code points,\n *    use a loop like this:\n * <pre>\n * UnicodeSetIterator it(set);\n * while (it.nextRange()) {\n *   if (it.isString()) {\n *     processString(it.getString());\n *   } else {\n *     processCodepointRange(it.getCodepoint(), it.getCodepointEnd());\n *   }\n * }\n * </pre>\n * @author M. Davis\n * @stable ICU 2.4\n */\nclass U_COMMON_API UnicodeSetIterator : public UObject {\n\n protected:\n\n    /**\n     * Value of <tt>codepoint</tt> if the iterator points to a string.\n     * If <tt>codepoint == IS_STRING</tt>, then examine\n     * <tt>string</tt> for the current iteration result.\n     * @stable ICU 2.4\n     */\n    enum { IS_STRING = -1 };\n\n    /**\n     * Current code point, or the special value <tt>IS_STRING</tt>, if\n     * the iterator points to a string.\n     * @stable ICU 2.4\n     */\n    UChar32 codepoint;\n\n    /**\n     * When iterating over ranges using <tt>nextRange()</tt>,\n     * <tt>codepointEnd</tt> contains the inclusive end of the\n     * iteration range, if <tt>codepoint != IS_STRING</tt>.  If\n     * iterating over code points using <tt>next()</tt>, or if\n     * <tt>codepoint == IS_STRING</tt>, then the value of\n     * <tt>codepointEnd</tt> is undefined.\n     * @stable ICU 2.4\n     */\n    UChar32 codepointEnd;\n\n    /**\n     * If <tt>codepoint == IS_STRING</tt>, then <tt>string</tt> points\n     * to the current string.  If <tt>codepoint != IS_STRING</tt>, the\n     * value of <tt>string</tt> is undefined.\n     * @stable ICU 2.4\n     */\n    const UnicodeString* string;\n\n public:\n\n    /**\n     * Create an iterator over the given set.  The iterator is valid\n     * only so long as <tt>set</tt> is valid.\n     * @param set set to iterate over\n     * @stable ICU 2.4\n     */\n    UnicodeSetIterator(const UnicodeSet& set);\n\n    /**\n     * Create an iterator over nothing.  <tt>next()</tt> and\n     * <tt>nextRange()</tt> return false. This is a convenience\n     * constructor allowing the target to be set later.\n     * @stable ICU 2.4\n     */\n    UnicodeSetIterator();\n\n    /**\n     * Destructor.\n     * @stable ICU 2.4\n     */\n    virtual ~UnicodeSetIterator();\n\n    /**\n     * Returns true if the current element is a string.  If so, the\n     * caller can retrieve it with <tt>getString()</tt>.  If this\n     * method returns false, the current element is a code point or\n     * code point range, depending on whether <tt>next()</tt> or\n     * <tt>nextRange()</tt> was called.\n     * Elements of types string and codepoint can both be retrieved\n     * with the function <tt>getString()</tt>.\n     * Elements of type codepoint can also be retrieved with\n     * <tt>getCodepoint()</tt>.\n     * For ranges, <tt>getCodepoint()</tt> returns the starting codepoint\n     * of the range, and <tt>getCodepointEnd()</tt> returns the end\n     * of the range.\n     * @stable ICU 2.4\n     */\n    inline UBool isString() const;\n\n    /**\n     * Returns the current code point, if <tt>isString()</tt> returned\n     * false.  Otherwise returns an undefined result.\n     * @stable ICU 2.4\n     */\n    inline UChar32 getCodepoint() const;\n\n    /**\n     * Returns the end of the current code point range, if\n     * <tt>isString()</tt> returned false and <tt>nextRange()</tt> was\n     * called.  Otherwise returns an undefined result.\n     * @stable ICU 2.4\n     */\n    inline UChar32 getCodepointEnd() const;\n\n    /**\n     * Returns the current string, if <tt>isString()</tt> returned\n     * true.  If the current iteration item is a code point, a UnicodeString\n     * containing that single code point is returned.\n     *\n     * Ownership of the returned string remains with the iterator.\n     * The string is guaranteed to remain valid only until the iterator is\n     *   advanced to the next item, or until the iterator is deleted.\n     * \n     * @stable ICU 2.4\n     */\n    const UnicodeString& getString();\n\n    /**\n     * Advances the iteration position to the next element in the set, \n     * which can be either a single code point or a string.  \n     * If there are no more elements in the set, return false.\n     *\n     * <p>\n     * If <tt>isString() == TRUE</tt>, the value is a\n     * string, otherwise the value is a\n     * single code point.  Elements of either type can be retrieved\n     * with the function <tt>getString()</tt>, while elements of\n     * consisting of a single code point can be retrieved with\n     * <tt>getCodepoint()</tt>\n     *\n     * <p>The order of iteration is all code points in sorted order,\n     * followed by all strings sorted order.    Do not mix\n     * calls to <tt>next()</tt> and <tt>nextRange()</tt> without\n     * calling <tt>reset()</tt> between them.  The results of doing so\n     * are undefined.\n     *\n     * @return true if there was another element in the set.\n     * @stable ICU 2.4\n     */\n    UBool next();\n\n    /**\n     * Returns the next element in the set, either a code point range\n     * or a string.  If there are no more elements in the set, return\n     * false.  If <tt>isString() == TRUE</tt>, the value is a\n     * string and can be accessed with <tt>getString()</tt>.  Otherwise the value is a\n     * range of one or more code points from <tt>getCodepoint()</tt> to\n     * <tt>getCodepointeEnd()</tt> inclusive.\n     *\n     * <p>The order of iteration is all code points ranges in sorted\n     * order, followed by all strings sorted order.  Ranges are\n     * disjoint and non-contiguous.  The value returned from <tt>getString()</tt>\n     * is undefined unless <tt>isString() == TRUE</tt>.  Do not mix calls to\n     * <tt>next()</tt> and <tt>nextRange()</tt> without calling\n     * <tt>reset()</tt> between them.  The results of doing so are\n     * undefined.\n     *\n     * @return true if there was another element in the set.\n     * @stable ICU 2.4\n     */\n    UBool nextRange();\n\n    /**\n     * Sets this iterator to visit the elements of the given set and\n     * resets it to the start of that set.  The iterator is valid only\n     * so long as <tt>set</tt> is valid.\n     * @param set the set to iterate over.\n     * @stable ICU 2.4\n     */\n    void reset(const UnicodeSet& set);\n\n    /**\n     * Resets this iterator to the start of the set.\n     * @stable ICU 2.4\n     */\n    void reset();\n\n    /**\n     * ICU \"poor man's RTTI\", returns a UClassID for this class.\n     *\n     * @stable ICU 2.4\n     */\n    static UClassID U_EXPORT2 getStaticClassID();\n\n    /**\n     * ICU \"poor man's RTTI\", returns a UClassID for the actual class.\n     *\n     * @stable ICU 2.4\n     */\n    virtual UClassID getDynamicClassID() const;\n\n    // ======================= PRIVATES ===========================\n\n protected:\n\n    // endElement and nextElements are really UChar32's, but we keep\n    // them as signed int32_t's so we can do comparisons with\n    // endElement set to -1.  Leave them as int32_t's.\n    /** The set\n     * @stable ICU 2.4\n     */\n    const UnicodeSet* set;\n    /** End range\n     * @stable ICU 2.4\n     */\n    int32_t endRange;\n    /** Range\n     * @stable ICU 2.4\n     */\n    int32_t range;\n    /** End element\n     * @stable ICU 2.4\n     */\n    int32_t endElement;\n    /** Next element\n     * @stable ICU 2.4\n     */\n    int32_t nextElement;\n    //UBool abbreviated;\n    /** Next string\n     * @stable ICU 2.4\n     */\n    int32_t nextString;\n    /** String count\n     * @stable ICU 2.4\n     */\n    int32_t stringCount;\n\n    /**\n     *  Points to the string to use when the caller asks for a\n     *  string and the current iteration item is a code point, not a string.\n     *  @internal\n     */\n    UnicodeString *cpString;\n\n    /** Copy constructor. Disallowed.\n     * @stable ICU 2.4\n     */\n    UnicodeSetIterator(const UnicodeSetIterator&); // disallow\n\n    /** Assignment operator. Disallowed.\n     * @stable ICU 2.4\n     */\n    UnicodeSetIterator& operator=(const UnicodeSetIterator&); // disallow\n\n    /** Load range\n     * @stable ICU 2.4\n     */\n    virtual void loadRange(int32_t range);\n\n};\n\ninline UBool UnicodeSetIterator::isString() const {\n    return codepoint == (UChar32)IS_STRING;\n}\n\ninline UChar32 UnicodeSetIterator::getCodepoint() const {\n    return codepoint;\n}\n\ninline UChar32 UnicodeSetIterator::getCodepointEnd() const {\n    return codepointEnd;\n}\n\n\nU_NAMESPACE_END\n\n#endif\n"
  },
  {
    "path": "deprecated/android/addons/icucompat/unicode/ushape.h",
    "content": "/*\n******************************************************************************\n*\n*   Copyright (C) 2000-2012, International Business Machines\n*   Corporation and others.  All Rights Reserved.\n*\n******************************************************************************\n*   file name:  ushape.h\n*   encoding:   US-ASCII\n*   tab size:   8 (not used)\n*   indentation:4\n*\n*   created on: 2000jun29\n*   created by: Markus W. Scherer\n*/\n\n#ifndef __USHAPE_H__\n#define __USHAPE_H__\n\n#include \"unicode/utypes.h\"\n\n/**\n * \\file\n * \\brief C API:  Arabic shaping\n * \n */\n\n/**\n * Shape Arabic text on a character basis.\n *\n * <p>This function performs basic operations for \"shaping\" Arabic text. It is most\n * useful for use with legacy data formats and legacy display technology\n * (simple terminals). All operations are performed on Unicode characters.</p>\n *\n * <p>Text-based shaping means that some character code points in the text are\n * replaced by others depending on the context. It transforms one kind of text\n * into another. In comparison, modern displays for Arabic text select\n * appropriate, context-dependent font glyphs for each text element, which means\n * that they transform text into a glyph vector.</p>\n *\n * <p>Text transformations are necessary when modern display technology is not\n * available or when text needs to be transformed to or from legacy formats that\n * use \"shaped\" characters. Since the Arabic script is cursive, connecting\n * adjacent letters to each other, computers select images for each letter based\n * on the surrounding letters. This usually results in four images per Arabic\n * letter: initial, middle, final, and isolated forms. In Unicode, on the other\n * hand, letters are normally stored abstract, and a display system is expected\n * to select the necessary glyphs. (This makes searching and other text\n * processing easier because the same letter has only one code.) It is possible\n * to mimic this with text transformations because there are characters in\n * Unicode that are rendered as letters with a specific shape\n * (or cursive connectivity). They were included for interoperability with\n * legacy systems and codepages, and for unsophisticated display systems.</p>\n *\n * <p>A second kind of text transformations is supported for Arabic digits:\n * For compatibility with legacy codepages that only include European digits,\n * it is possible to replace one set of digits by another, changing the\n * character code points. These operations can be performed for either\n * Arabic-Indic Digits (U+0660...U+0669) or Eastern (Extended) Arabic-Indic\n * digits (U+06f0...U+06f9).</p>\n *\n * <p>Some replacements may result in more or fewer characters (code points).\n * By default, this means that the destination buffer may receive text with a\n * length different from the source length. Some legacy systems rely on the\n * length of the text to be constant. They expect extra spaces to be added\n * or consumed either next to the affected character or at the end of the\n * text.</p>\n *\n * <p>For details about the available operations, see the description of the\n * <code>U_SHAPE_...</code> options.</p>\n *\n * @param source The input text.\n *\n * @param sourceLength The number of UChars in <code>source</code>.\n *\n * @param dest The destination buffer that will receive the results of the\n *             requested operations. It may be <code>NULL</code> only if\n *             <code>destSize</code> is 0. The source and destination must not\n *             overlap.\n *\n * @param destSize The size (capacity) of the destination buffer in UChars.\n *                 If <code>destSize</code> is 0, then no output is produced,\n *                 but the necessary buffer size is returned (\"preflighting\").\n *\n * @param options This is a 32-bit set of flags that specify the operations\n *                that are performed on the input text. If no error occurs,\n *                then the result will always be written to the destination\n *                buffer.\n *\n * @param pErrorCode must be a valid pointer to an error code value,\n *        which must not indicate a failure before the function call.\n *\n * @return The number of UChars written to the destination buffer.\n *         If an error occured, then no output was written, or it may be\n *         incomplete. If <code>U_BUFFER_OVERFLOW_ERROR</code> is set, then\n *         the return value indicates the necessary destination buffer size.\n * @stable ICU 2.0\n */\n/* BEGIN android-changed */\nU_STABLE int32_t U_EXPORT2\nu_shapeArabic(const UChar *source, int32_t sourceLength,\n              UChar *dest, int32_t destSize,\n              uint64_t options,\n              UErrorCode *pErrorCode);\n/* END android-changed */\n\n/**\n * Memory option: allow the result to have a different length than the source.\n * Affects: LamAlef options\n * @stable ICU 2.0\n */\n#define U_SHAPE_LENGTH_GROW_SHRINK              0\n\n/**\n * Memory option: allow the result to have a different length than the source.\n * Affects: LamAlef options\n * This option is an alias to U_SHAPE_LENGTH_GROW_SHRINK\n * @stable ICU 4.2\n */\n#define U_SHAPE_LAMALEF_RESIZE                  0 \n\n/**\n * Memory option: the result must have the same length as the source.\n * If more room is necessary, then try to consume spaces next to modified characters.\n * @stable ICU 2.0\n */\n#define U_SHAPE_LENGTH_FIXED_SPACES_NEAR        1\n\n/**\n * Memory option: the result must have the same length as the source.\n * If more room is necessary, then try to consume spaces next to modified characters.\n * Affects: LamAlef options\n * This option is an alias to U_SHAPE_LENGTH_FIXED_SPACES_NEAR\n * @stable ICU 4.2\n */\n#define U_SHAPE_LAMALEF_NEAR                    1 \n\n/**\n * Memory option: the result must have the same length as the source.\n * If more room is necessary, then try to consume spaces at the end of the text.\n * @stable ICU 2.0\n */\n#define U_SHAPE_LENGTH_FIXED_SPACES_AT_END      2\n\n/**\n * Memory option: the result must have the same length as the source.\n * If more room is necessary, then try to consume spaces at the end of the text.\n * Affects: LamAlef options\n * This option is an alias to U_SHAPE_LENGTH_FIXED_SPACES_AT_END\n * @stable ICU 4.2\n */\n#define U_SHAPE_LAMALEF_END                     2 \n\n/**\n * Memory option: the result must have the same length as the source.\n * If more room is necessary, then try to consume spaces at the beginning of the text.\n * @stable ICU 2.0\n */\n#define U_SHAPE_LENGTH_FIXED_SPACES_AT_BEGINNING 3\n\n/**\n * Memory option: the result must have the same length as the source.\n * If more room is necessary, then try to consume spaces at the beginning of the text.\n * Affects: LamAlef options\n * This option is an alias to U_SHAPE_LENGTH_FIXED_SPACES_AT_BEGINNING\n * @stable ICU 4.2\n */\n#define U_SHAPE_LAMALEF_BEGIN                    3 \n\n\n/**\n * Memory option: the result must have the same length as the source.\n * Shaping Mode: For each LAMALEF character found, expand LAMALEF using space at end.\n *               If there is no space at end, use spaces at beginning of the buffer. If there\n *               is no space at beginning of the buffer, use spaces at the near (i.e. the space\n *               after the LAMALEF character).\n *               If there are no spaces found, an error U_NO_SPACE_AVAILABLE (as defined in utypes.h) \n *               will be set in pErrorCode\n *\n * Deshaping Mode: Perform the same function as the flag equals U_SHAPE_LAMALEF_END. \n * Affects: LamAlef options\n * @stable ICU 4.2\n */\n#define U_SHAPE_LAMALEF_AUTO                     0x10000 \n\n/** Bit mask for memory options. @stable ICU 2.0 */\n#define U_SHAPE_LENGTH_MASK                      0x10003 /* Changed old value 3 */\n\n\n/**\n * Bit mask for LamAlef memory options.\n * @stable ICU 4.2\n */\n#define U_SHAPE_LAMALEF_MASK                     0x10003 /* updated */\n\n/** Direction indicator: the source is in logical (keyboard) order. @stable ICU 2.0 */\n#define U_SHAPE_TEXT_DIRECTION_LOGICAL          0\n\n/**\n * Direction indicator:\n * the source is in visual RTL order,\n * the rightmost displayed character stored first.\n * This option is an alias to U_SHAPE_TEXT_DIRECTION_LOGICAL\n * @stable ICU 4.2\n */\n#define U_SHAPE_TEXT_DIRECTION_VISUAL_RTL       0\n\n/**\n * Direction indicator:\n * the source is in visual LTR order,\n * the leftmost displayed character stored first.\n * @stable ICU 2.0\n */\n#define U_SHAPE_TEXT_DIRECTION_VISUAL_LTR       4\n\n/** Bit mask for direction indicators. @stable ICU 2.0 */\n#define U_SHAPE_TEXT_DIRECTION_MASK             4\n\n\n/** Letter shaping option: do not perform letter shaping. @stable ICU 2.0 */\n#define U_SHAPE_LETTERS_NOOP                    0\n\n/** Letter shaping option: replace abstract letter characters by \"shaped\" ones. @stable ICU 2.0 */\n#define U_SHAPE_LETTERS_SHAPE                   8\n\n/** Letter shaping option: replace \"shaped\" letter characters by abstract ones. @stable ICU 2.0 */\n#define U_SHAPE_LETTERS_UNSHAPE                 0x10\n\n/**\n * Letter shaping option: replace abstract letter characters by \"shaped\" ones.\n * The only difference with U_SHAPE_LETTERS_SHAPE is that Tashkeel letters\n * are always \"shaped\" into the isolated form instead of the medial form\n * (selecting code points from the Arabic Presentation Forms-B block).\n * @stable ICU 2.0\n */\n#define U_SHAPE_LETTERS_SHAPE_TASHKEEL_ISOLATED 0x18\n\n\n/** Bit mask for letter shaping options. @stable ICU 2.0 */\n#define U_SHAPE_LETTERS_MASK                        0x18\n\n\n/** Digit shaping option: do not perform digit shaping. @stable ICU 2.0 */\n#define U_SHAPE_DIGITS_NOOP                     0\n\n/**\n * Digit shaping option:\n * Replace European digits (U+0030...) by Arabic-Indic digits.\n * @stable ICU 2.0\n */\n#define U_SHAPE_DIGITS_EN2AN                    0x20\n\n/**\n * Digit shaping option:\n * Replace Arabic-Indic digits by European digits (U+0030...).\n * @stable ICU 2.0\n */\n#define U_SHAPE_DIGITS_AN2EN                    0x40\n\n/**\n * Digit shaping option:\n * Replace European digits (U+0030...) by Arabic-Indic digits if the most recent\n * strongly directional character is an Arabic letter\n * (<code>u_charDirection()</code> result <code>U_RIGHT_TO_LEFT_ARABIC</code> [AL]).<br>\n * The direction of \"preceding\" depends on the direction indicator option.\n * For the first characters, the preceding strongly directional character\n * (initial state) is assumed to be not an Arabic letter\n * (it is <code>U_LEFT_TO_RIGHT</code> [L] or <code>U_RIGHT_TO_LEFT</code> [R]).\n * @stable ICU 2.0\n */\n#define U_SHAPE_DIGITS_ALEN2AN_INIT_LR          0x60\n\n/**\n * Digit shaping option:\n * Replace European digits (U+0030...) by Arabic-Indic digits if the most recent\n * strongly directional character is an Arabic letter\n * (<code>u_charDirection()</code> result <code>U_RIGHT_TO_LEFT_ARABIC</code> [AL]).<br>\n * The direction of \"preceding\" depends on the direction indicator option.\n * For the first characters, the preceding strongly directional character\n * (initial state) is assumed to be an Arabic letter.\n * @stable ICU 2.0\n */\n#define U_SHAPE_DIGITS_ALEN2AN_INIT_AL          0x80\n\n/** Not a valid option value. May be replaced by a new option. @stable ICU 2.0 */\n#define U_SHAPE_DIGITS_RESERVED                 0xa0\n\n/** Bit mask for digit shaping options. @stable ICU 2.0 */\n#define U_SHAPE_DIGITS_MASK                     0xe0\n\n\n/** Digit type option: Use Arabic-Indic digits (U+0660...U+0669). @stable ICU 2.0 */\n#define U_SHAPE_DIGIT_TYPE_AN                   0\n\n/** Digit type option: Use Eastern (Extended) Arabic-Indic digits (U+06f0...U+06f9). @stable ICU 2.0 */\n#define U_SHAPE_DIGIT_TYPE_AN_EXTENDED          0x100\n\n/** Not a valid option value. May be replaced by a new option. @stable ICU 2.0 */\n#define U_SHAPE_DIGIT_TYPE_RESERVED             0x200\n\n/** Bit mask for digit type options. @stable ICU 2.0 */\n#define U_SHAPE_DIGIT_TYPE_MASK                 0x300 /* I need to change this from 0x3f00 to 0x300 */\n\n/** \n * Tashkeel aggregation option:\n * Replaces any combination of U+0651 with one of\n * U+064C, U+064D, U+064E, U+064F, U+0650 with\n * U+FC5E, U+FC5F, U+FC60, U+FC61, U+FC62 consecutively.\n * @stable ICU 3.6\n */\n#define U_SHAPE_AGGREGATE_TASHKEEL              0x4000\n/** Tashkeel aggregation option: do not aggregate tashkeels. @stable ICU 3.6 */\n#define U_SHAPE_AGGREGATE_TASHKEEL_NOOP         0\n/** Bit mask for tashkeel aggregation. @stable ICU 3.6 */\n#define U_SHAPE_AGGREGATE_TASHKEEL_MASK         0x4000\n\n/** \n * Presentation form option:\n * Don't replace Arabic Presentation Forms-A and Arabic Presentation Forms-B\n * characters with 0+06xx characters, before shaping.\n * @stable ICU 3.6\n */\n#define U_SHAPE_PRESERVE_PRESENTATION           0x8000\n/** Presentation form option: \n * Replace Arabic Presentation Forms-A and Arabic Presentationo Forms-B with \n * their unshaped correspondants in range 0+06xx, before shaping.\n * @stable ICU 3.6 \n */\n#define U_SHAPE_PRESERVE_PRESENTATION_NOOP      0\n/** Bit mask for preserve presentation form. @stable ICU 3.6 */\n#define U_SHAPE_PRESERVE_PRESENTATION_MASK      0x8000\n\n/* Seen Tail option */ \n/**\n * Memory option: the result must have the same length as the source.\n * Shaping mode: The SEEN family character will expand into two characters using space near \n *               the SEEN family character(i.e. the space after the character).\n *               If there are no spaces found, an error U_NO_SPACE_AVAILABLE (as defined in utypes.h) \n *               will be set in pErrorCode\n *\n * De-shaping mode: Any Seen character followed by Tail character will be\n *                  replaced by one cell Seen and a space will replace the Tail.\n * Affects: Seen options\n * @stable ICU 4.2\n */\n#define U_SHAPE_SEEN_TWOCELL_NEAR     0x200000\n\n/**\n * Bit mask for Seen memory options. \n * @stable ICU 4.2\n */\n#define U_SHAPE_SEEN_MASK             0x700000\n\n/* YehHamza option */ \n/**\n * Memory option: the result must have the same length as the source.\n * Shaping mode: The YEHHAMZA character will expand into two characters using space near it \n *              (i.e. the space after the character\n *               If there are no spaces found, an error U_NO_SPACE_AVAILABLE (as defined in utypes.h) \n *               will be set in pErrorCode\n *\n * De-shaping mode: Any Yeh (final or isolated) character followed by Hamza character will be\n *                  replaced by one cell YehHamza and space will replace the Hamza.\n * Affects: YehHamza options\n * @stable ICU 4.2\n */\n#define U_SHAPE_YEHHAMZA_TWOCELL_NEAR      0x1000000\n\n\n/**\n * Bit mask for YehHamza memory options. \n * @stable ICU 4.2\n */\n#define U_SHAPE_YEHHAMZA_MASK              0x3800000\n\n/* New Tashkeel options */ \n/**\n * Memory option: the result must have the same length as the source.\n * Shaping mode: Tashkeel characters will be replaced by spaces. \n *               Spaces will be placed at beginning of the buffer\n *\n * De-shaping mode: N/A\n * Affects: Tashkeel options\n * @stable ICU 4.2\n */\n#define U_SHAPE_TASHKEEL_BEGIN                      0x40000\n\n/**\n * Memory option: the result must have the same length as the source.\n * Shaping mode: Tashkeel characters will be replaced by spaces. \n *               Spaces will be placed at end of the buffer\n *\n * De-shaping mode: N/A\n * Affects: Tashkeel options\n * @stable ICU 4.2\n */\n#define U_SHAPE_TASHKEEL_END                        0x60000\n\n/**\n * Memory option: allow the result to have a different length than the source.\n * Shaping mode: Tashkeel characters will be removed, buffer length will shrink. \n * De-shaping mode: N/A \n *\n * Affect: Tashkeel options\n * @stable ICU 4.2\n */\n#define U_SHAPE_TASHKEEL_RESIZE                     0x80000\n\n/**\n * Memory option: the result must have the same length as the source.\n * Shaping mode: Tashkeel characters will be replaced by Tatweel if it is connected to adjacent\n *               characters (i.e. shaped on Tatweel) or replaced by space if it is not connected.\n *\n * De-shaping mode: N/A\n * Affects: YehHamza options\n * @stable ICU 4.2\n */\n#define U_SHAPE_TASHKEEL_REPLACE_BY_TATWEEL         0xC0000\n\n/** \n * Bit mask for Tashkeel replacement with Space or Tatweel memory options. \n * @stable ICU 4.2\n */\n#define U_SHAPE_TASHKEEL_MASK                       0xE0000\n\n\n/* Space location Control options */ \n/**\n * This option affect the meaning of BEGIN and END options. if this option is not used the default\n * for BEGIN and END will be as following: \n * The Default (for both Visual LTR, Visual RTL and Logical Text)\n *           1. BEGIN always refers to the start address of physical memory.\n *           2. END always refers to the end address of physical memory.\n *\n * If this option is used it will swap the meaning of BEGIN and END only for Visual LTR text. \n *\n * The effect on BEGIN and END Memory Options will be as following:\n *    A. BEGIN For Visual LTR text: This will be the beginning (right side) of the visual text(\n *       corresponding to the physical memory address end for Visual LTR text, Same as END in \n *       default behavior)\n *    B. BEGIN For Logical text: Same as BEGIN in default behavior. \n *    C. END For Visual LTR text: This will be the end (left side) of the visual text (corresponding\n *       to the physical memory address beginning for Visual LTR text, Same as BEGIN in default behavior.\n *    D. END For Logical text: Same as END in default behavior). \n * Affects: All LamAlef BEGIN, END and AUTO options.\n * @stable ICU 4.2\n */\n#define U_SHAPE_SPACES_RELATIVE_TO_TEXT_BEGIN_END 0x4000000\n\n/**\n * Bit mask for swapping BEGIN and END for Visual LTR text \n * @stable ICU 4.2\n */\n#define U_SHAPE_SPACES_RELATIVE_TO_TEXT_MASK      0x4000000\n\n/**\n * If this option is used, shaping will use the new Unicode code point for TAIL (i.e. 0xFE73). \n * If this option is not specified (Default), old unofficial Unicode TAIL code point is used (i.e. 0x200B)\n * De-shaping will not use this option as it will always search for both the new Unicode code point for the \n * TAIL (i.e. 0xFE73) or the old unofficial Unicode TAIL code point (i.e. 0x200B) and de-shape the\n * Seen-Family letter accordingly.\n *\n * Shaping Mode: Only shaping.\n * De-shaping Mode: N/A.\n * Affects: All Seen options\n * @stable ICU 4.8\n */\n#define U_SHAPE_TAIL_NEW_UNICODE        0x8000000\n\n/**\n * Bit mask for new Unicode Tail option \n * @stable ICU 4.8\n */\n#define U_SHAPE_TAIL_TYPE_MASK          0x8000000\n\n/* BEGIN Android-added */\n/**\n * Option used when forming LamAlef ligatures and\n * U_SHAPE_LAMALEF_NEAR is set.  When this option is selected, inserts\n * 0xffff instead of 0x0020 (space) after the ligature.  Use this when\n * you need to identify these substitutions during later processing.\n */\n/* END Android-added */\n#define U_SHAPE_X_LAMALEF_SUB_ALTERNATE (0x1ULL << 32)\n#endif\n"
  },
  {
    "path": "deprecated/android/addons/icucompat/unicode/uspoof.h",
    "content": "/*\n***************************************************************************\n* Copyright (C) 2008-2012, International Business Machines Corporation\n* and others. All Rights Reserved.\n***************************************************************************\n*   file name:  uspoof.h\n*   encoding:   US-ASCII\n*   tab size:   8 (not used)\n*   indentation:4\n*\n*   created on: 2008Feb13\n*   created by: Andy Heninger\n*\n*   Unicode Spoof Detection\n*/\n\n#ifndef USPOOF_H\n#define USPOOF_H\n\n#include \"unicode/utypes.h\"\n#include \"unicode/uset.h\"\n#include \"unicode/parseerr.h\"\n#include \"unicode/localpointer.h\"\n\n#if !UCONFIG_NO_NORMALIZATION\n\n\n#if U_SHOW_CPLUSPLUS_API\n#include \"unicode/unistr.h\"\n#include \"unicode/uniset.h\"\n#endif\n\n\n/**\n * \\file\n * \\brief Unicode Security and Spoofing Detection, C API.\n *\n * These functions are intended to check strings, typically\n * identifiers of some type, such as URLs, for the presence of\n * characters that are likely to be visually confusing - \n * for cases where the displayed form of an identifier may\n * not be what it appears to be.\n *\n * Unicode Technical Report #36, http://unicode.org/reports/tr36, and\n * Unicode Technical Standard #39, http://unicode.org/reports/tr39\n * \"Unicode security considerations\", give more background on \n * security an spoofing issues with Unicode identifiers.\n * The tests and checks provided by this module implement the recommendations\n * from those Unicode documents.\n *\n * The tests available on identifiers fall into two general categories:\n *   -#  Single identifier tests.  Check whether an identifier is\n *       potentially confusable with any other string, or is suspicious\n *       for other reasons.\n *   -#  Two identifier tests.  Check whether two specific identifiers are confusable.\n *       This does not consider whether either of strings is potentially\n *       confusable with any string other than the exact one specified.\n *\n * The steps to perform confusability testing are\n *   -#  Open a USpoofChecker.\n *   -#  Configure the USPoofChecker for the desired set of tests.  The tests that will\n *       be performed are specified by a set of USpoofChecks flags.\n *   -#  Perform the checks using the pre-configured USpoofChecker.  The results indicate\n *       which (if any) of the selected tests have identified possible problems with the identifier.\n *       Results are reported as a set of USpoofChecks flags;  this mirrors the form in which\n *       the set of tests to perform was originally specified to the USpoofChecker.\n *\n * A USpoofChecker may be used repeatedly to perform checks on any number of identifiers.\n *\n * Thread Safety: The test functions for checking a single identifier, or for testing \n * whether two identifiers are possible confusable, are thread safe.  \n * They may called concurrently, from multiple threads, using the same USpoofChecker instance.\n *\n * More generally, the standard ICU thread safety rules apply:  functions that take a\n * const USpoofChecker parameter are thread safe.  Those that take a non-const \n * USpoofChecier are not thread safe.\n *\n *\n * Descriptions of the available checks.\n *\n * When testing whether pairs of identifiers are confusable, with the uspoof_areConfusable()\n * family of functions, the relevant tests are\n *\n *   -# USPOOF_SINGLE_SCRIPT_CONFUSABLE:  All of the characters from the two identifiers are\n *      from a single script, and the two identifiers are visually confusable.\n *   -# USPOOF_MIXED_SCRIPT_CONFUSABLE:  At least one of the identifiers contains characters\n *      from more than one script, and the two identifiers are visually confusable.\n *   -# USPOOF_WHOLE_SCRIPT_CONFUSABLE: Each of the two identifiers is of a single script, but\n *      the two identifiers are from different scripts, and they are visually confusable.\n *\n * The safest approach is to enable all three of these checks as a group.\n *\n * USPOOF_ANY_CASE is a modifier for the above tests.  If the identifiers being checked can\n * be of mixed case and are used in a case-sensitive manner, this option should be specified.\n *\n * If the identifiers being checked are used in a case-insensitive manner, and if they are\n * displayed to users in lower-case form only, the USPOOF_ANY_CASE option should not be\n * specified.  Confusabality issues involving upper case letters will not be reported.\n *\n * When performing tests on a single identifier, with the uspoof_check() family of functions,\n * the relevant tests are:\n *\n *    -# USPOOF_MIXED_SCRIPT_CONFUSABLE: the identifier contains characters from multiple\n *       scripts, and there exists an identifier of a single script that is visually confusable.\n *    -# USPOOF_WHOLE_SCRIPT_CONFUSABLE: the identifier consists of characters from a single\n *       script, and there exists a visually confusable identifier.\n *       The visually confusable identifier also consists of characters from a single script.\n *       but not the same script as the identifier being checked.\n *    -# USPOOF_ANY_CASE: modifies the mixed script and whole script confusables tests.  If\n *       specified, the checks will consider confusable characters of any case.  If this flag is not\n *       set, the test is performed assuming case folded identifiers.\n *    -# USPOOF_SINGLE_SCRIPT: check that the identifier contains only characters from a\n *       single script.  (Characters from the 'common' and 'inherited' scripts are ignored.)\n *       This is not a test for confusable identifiers\n *    -# USPOOF_INVISIBLE: check an identifier for the presence of invisible characters,\n *       such as zero-width spaces, or character sequences that are\n *       likely not to display, such as multiple occurrences of the same\n *       non-spacing mark.  This check does not test the input string as a whole\n *       for conformance to any particular syntax for identifiers.\n *    -# USPOOF_CHAR_LIMIT: check that an identifier contains only characters from a specified set\n *       of acceptable characters.  See uspoof_setAllowedChars() and\n *       uspoof_setAllowedLocales().\n *\n *  Note on Scripts:\n *     Characters from the Unicode Scripts \"Common\" and \"Inherited\" are ignored when considering\n *     the script of an identifier. Common characters include digits and symbols that\n *     are normally used with text from more than one script.\n *\n *  Identifier Skeletons:  A skeleton is a transformation of an identifier, such that\n *  all identifiers that are confusable with each other have the same skeleton.\n *  Using skeletons, it is possible to build a dictionary data structure for\n *  a set of identifiers, and then quickly test whether a new identifier is\n *  confusable with an identifier already in the set.  The uspoof_getSkeleton()\n *  family of functions will produce the skeleton from an identifier.\n *\n *  Note that skeletons are not guaranteed to be stable between versions \n *  of Unicode or ICU, so an applications should not rely on creating a permanent,\n *  or difficult to update, database of skeletons.  Instabilities result from\n *  identifying new pairs or sequences of characters that are visually\n *  confusable, and thus must be mapped to the same skeleton character(s).\n *\n */\n\nstruct USpoofChecker;\ntypedef struct USpoofChecker USpoofChecker; /**< typedef for C of USpoofChecker */\n\n/**\n * Enum for the kinds of checks that USpoofChecker can perform.\n * These enum values are used both to select the set of checks that\n * will be performed, and to report results from the check function.\n *\n * @stable ICU 4.2\n */\ntypedef enum USpoofChecks {\n    /**   Single script confusable test.\n      *   When testing whether two identifiers are confusable, report that they are if\n      *   both are from the same script and they are visually confusable.\n      *   Note: this test is not applicable to a check of a single identifier.\n      */\n    USPOOF_SINGLE_SCRIPT_CONFUSABLE =   1,\n\n    /** Mixed script confusable test.\n     *  When checking a single identifier, report a problem if\n     *    the identifier contains multiple scripts, and\n     *    is confusable with some other identifier in a single script\n     *  When testing whether two identifiers are confusable, report that they are if\n     *    the two IDs are visually confusable, \n     *    and at least one contains characters from more than one script.\n     */\n    USPOOF_MIXED_SCRIPT_CONFUSABLE  =   2,\n\n    /** Whole script confusable test.\n     *  When checking a single identifier, report a problem if\n     *    The identifier is of a single script, and\n     *    there exists a confusable identifier in another script.\n     *  When testing whether two identifiers are confusable, report that they are if\n     *    each is of a single script, \n     *    the scripts of the two identifiers are different, and\n     *    the identifiers are visually confusable.\n     */\n    USPOOF_WHOLE_SCRIPT_CONFUSABLE  =   4,\n    \n    /** Any Case Modifier for confusable identifier tests.\n        If specified, consider all characters, of any case, when looking for confusables.\n        If USPOOF_ANY_CASE is not specified, identifiers being checked are assumed to have been\n        case folded.  Upper case confusable characters will not be checked.\n        Selects between Lower Case Confusable and\n        Any Case Confusable.   */\n    USPOOF_ANY_CASE                 =   8,\n\n    /** Check that an identifier contains only characters from a\n      * single script (plus chars from the common and inherited scripts.)\n      * Applies to checks of a single identifier check only.\n      */\n    USPOOF_SINGLE_SCRIPT            =  16,\n    \n    /** Check an identifier for the presence of invisible characters,\n      * such as zero-width spaces, or character sequences that are\n      * likely not to display, such as multiple occurrences of the same\n      * non-spacing mark.  This check does not test the input string as a whole\n      * for conformance to any particular syntax for identifiers.\n      */\n    USPOOF_INVISIBLE                =  32,\n\n    /** Check that an identifier contains only characters from a specified set\n      * of acceptable characters.  See uspoof_setAllowedChars() and\n      * uspoof_setAllowedLocales().\n      */\n    USPOOF_CHAR_LIMIT               =  64,\n\n    USPOOF_ALL_CHECKS               = 0x7f\n    } USpoofChecks;\n    \n    \n/**\n *  Create a Unicode Spoof Checker, configured to perform all \n *  checks except for USPOOF_LOCALE_LIMIT and USPOOF_CHAR_LIMIT.\n *  Note that additional checks may be added in the future,\n *  resulting in the changes to the default checking behavior.\n *\n *  @param status  The error code, set if this function encounters a problem.\n *  @return        the newly created Spoof Checker\n *  @stable ICU 4.2\n */\nU_STABLE USpoofChecker * U_EXPORT2\nuspoof_open(UErrorCode *status);\n\n\n/**\n * Open a Spoof checker from its serialized from, stored in 32-bit-aligned memory.\n * Inverse of uspoof_serialize().\n * The memory containing the serialized data must remain valid and unchanged\n * as long as the spoof checker, or any cloned copies of the spoof checker,\n * are in use.  Ownership of the memory remains with the caller.\n * The spoof checker (and any clones) must be closed prior to deleting the\n * serialized data.\n *\n * @param data a pointer to 32-bit-aligned memory containing the serialized form of spoof data\n * @param length the number of bytes available at data;\n *               can be more than necessary\n * @param pActualLength receives the actual number of bytes at data taken up by the data;\n *                      can be NULL\n * @param pErrorCode ICU error code\n * @return the spoof checker.\n *\n * @see uspoof_open\n * @see uspoof_serialize\n * @stable ICU 4.2\n */\nU_STABLE USpoofChecker * U_EXPORT2\nuspoof_openFromSerialized(const void *data, int32_t length, int32_t *pActualLength,\n                          UErrorCode *pErrorCode);\n\n/**\n  * Open a Spoof Checker from the source form of the spoof data.\n  * The Three inputs correspond to the Unicode data files confusables.txt\n  * confusablesWholeScript.txt and xidmdifications.txt as described in\n  * Unicode UAX 39.  The syntax of the source data is as described in UAX 39 for\n  * these files, and the content of these files is acceptable input.\n  *\n  * The character encoding of the (char *) input text is UTF-8.\n  *\n  * @param confusables a pointer to the confusable characters definitions,\n  *                    as found in file confusables.txt from unicode.org.\n  * @param confusablesLen The length of the confusables text, or -1 if the\n  *                    input string is zero terminated.\n  * @param confusablesWholeScript\n  *                    a pointer to the whole script confusables definitions,\n  *                    as found in the file confusablesWholeScript.txt from unicode.org.\n  * @param confusablesWholeScriptLen The length of the whole script confusables text, or\n  *                    -1 if the input string is zero terminated.\n  * @param errType     In the event of an error in the input, indicates\n  *                    which of the input files contains the error.\n  *                    The value is one of USPOOF_SINGLE_SCRIPT_CONFUSABLE or\n  *                    USPOOF_WHOLE_SCRIPT_CONFUSABLE, or\n  *                    zero if no errors are found.\n  * @param pe          In the event of an error in the input, receives the position\n  *                    in the input text (line, offset) of the error.\n  * @param status      an in/out ICU UErrorCode.  Among the possible errors is\n  *                    U_PARSE_ERROR, which is used to report syntax errors\n  *                    in the input.\n  * @return            A spoof checker that uses the rules from the input files.\n  * @stable ICU 4.2\n  */\nU_STABLE USpoofChecker * U_EXPORT2\nuspoof_openFromSource(const char *confusables,  int32_t confusablesLen,\n                      const char *confusablesWholeScript, int32_t confusablesWholeScriptLen,\n                      int32_t *errType, UParseError *pe, UErrorCode *status);\n\n\n/**\n  * Close a Spoof Checker, freeing any memory that was being held by\n  *   its implementation.\n  * @stable ICU 4.2\n  */\nU_STABLE void U_EXPORT2\nuspoof_close(USpoofChecker *sc);\n\n#if U_SHOW_CPLUSPLUS_API\n\nU_NAMESPACE_BEGIN\n\n/**\n * \\class LocalUSpoofCheckerPointer\n * \"Smart pointer\" class, closes a USpoofChecker via uspoof_close().\n * For most methods see the LocalPointerBase base class.\n *\n * @see LocalPointerBase\n * @see LocalPointer\n * @stable ICU 4.4\n */\nU_DEFINE_LOCAL_OPEN_POINTER(LocalUSpoofCheckerPointer, USpoofChecker, uspoof_close);\n\nU_NAMESPACE_END\n\n#endif\n\n/**\n * Clone a Spoof Checker.  The clone will be set to perform the same checks\n *   as the original source.\n *\n * @param sc       The source USpoofChecker\n * @param status   The error code, set if this function encounters a problem.\n * @return\n * @stable ICU 4.2\n */\nU_STABLE USpoofChecker * U_EXPORT2\nuspoof_clone(const USpoofChecker *sc, UErrorCode *status);\n\n\n/**\n * Specify the set of checks that will be performed by the check\n * functions of this Spoof Checker.\n *\n * @param sc       The USpoofChecker\n * @param checks         The set of checks that this spoof checker will perform.\n *                 The value is a bit set, obtained by OR-ing together\n *                 values from enum USpoofChecks.\n * @param status   The error code, set if this function encounters a problem.\n * @stable ICU 4.2\n *\n */\nU_STABLE void U_EXPORT2\nuspoof_setChecks(USpoofChecker *sc, int32_t checks, UErrorCode *status);\n\n/**\n * Get the set of checks that this Spoof Checker has been configured to perform.\n * \n * @param sc       The USpoofChecker\n * @param status   The error code, set if this function encounters a problem.\n * @return         The set of checks that this spoof checker will perform.\n *                 The value is a bit set, obtained by OR-ing together\n *                 values from enum USpoofChecks.\n * @stable ICU 4.2\n *\n */\nU_STABLE int32_t U_EXPORT2\nuspoof_getChecks(const USpoofChecker *sc, UErrorCode *status);\n\n/**\n * Limit characters that are acceptable in identifiers being checked to those \n * normally used with the languages associated with the specified locales.\n * Any previously specified list of locales is replaced by the new settings.\n *\n * A set of languages is determined from the locale(s), and\n * from those a set of acceptable Unicode scripts is determined.\n * Characters from this set of scripts, along with characters from\n * the \"common\" and \"inherited\" Unicode Script categories\n * will be permitted.\n *\n * Supplying an empty string removes all restrictions;\n * characters from any script will be allowed.\n *\n * The USPOOF_CHAR_LIMIT test is automatically enabled for this\n * USpoofChecker when calling this function with a non-empty list\n * of locales.\n *\n * The Unicode Set of characters that will be allowed is accessible\n * via the uspoof_getAllowedChars() function.  uspoof_setAllowedLocales()\n * will <i>replace</i> any previously applied set of allowed characters.\n *\n * Adjustments, such as additions or deletions of certain classes of characters,\n * can be made to the result of uspoof_setAllowedLocales() by\n * fetching the resulting set with uspoof_getAllowedChars(),\n * manipulating it with the Unicode Set API, then resetting the\n * spoof detectors limits with uspoof_setAllowedChars()\n *\n * @param sc           The USpoofChecker \n * @param localesList  A list list of locales, from which the language\n *                     and associated script are extracted.  The locales\n *                     are comma-separated if there is more than one.\n *                     White space may not appear within an individual locale,\n *                     but is ignored otherwise.\n *                     The locales are syntactically like those from the\n *                     HTTP Accept-Language header.\n *                     If the localesList is empty, no restrictions will be placed on\n *                     the allowed characters.\n *\n * @param status       The error code, set if this function encounters a problem.\n * @stable ICU 4.2\n */\nU_STABLE void U_EXPORT2\nuspoof_setAllowedLocales(USpoofChecker *sc, const char *localesList, UErrorCode *status);\n\n/**\n * Get a list of locales for the scripts that are acceptable in strings\n *  to be checked.  If no limitations on scripts have been specified,\n *  an empty string will be returned.\n *\n *  uspoof_setAllowedChars() will reset the list of allowed to be empty.\n *\n *  The format of the returned list is the same as that supplied to \n *  uspoof_setAllowedLocales(), but returned list may not be identical \n *  to the originally specified string; the string may be reformatted, \n *  and information other than languages from\n *  the originally specified locales may be omitted.\n *\n * @param sc           The USpoofChecker \n * @param status       The error code, set if this function encounters a problem.\n * @return             A string containing a list of  locales corresponding\n *                     to the acceptable scripts, formatted like an\n *                     HTTP Accept Language value.\n *  \n * @stable ICU 4.2\n */\nU_STABLE const char * U_EXPORT2\nuspoof_getAllowedLocales(USpoofChecker *sc, UErrorCode *status);\n\n\n/**\n * Limit the acceptable characters to those specified by a Unicode Set.\n *   Any previously specified character limit is\n *   is replaced by the new settings.  This includes limits on\n *   characters that were set with the uspoof_setAllowedLocales() function.\n *\n * The USPOOF_CHAR_LIMIT test is automatically enabled for this\n * USpoofChecker by this function.\n *\n * @param sc       The USpoofChecker \n * @param chars    A Unicode Set containing the list of\n *                 characters that are permitted.  Ownership of the set\n *                 remains with the caller.  The incoming set is cloned by\n *                 this function, so there are no restrictions on modifying\n *                 or deleting the USet after calling this function.\n * @param status   The error code, set if this function encounters a problem.\n * @stable ICU 4.2\n */\nU_STABLE void U_EXPORT2\nuspoof_setAllowedChars(USpoofChecker *sc, const USet *chars, UErrorCode *status);\n\n\n/**\n * Get a USet for the characters permitted in an identifier.\n * This corresponds to the limits imposed by the Set Allowed Characters\n * functions. Limitations imposed by other checks will not be\n * reflected in the set returned by this function.\n *\n * The returned set will be frozen, meaning that it cannot be modified\n * by the caller.\n *\n * Ownership of the returned set remains with the Spoof Detector.  The\n * returned set will become invalid if the spoof detector is closed,\n * or if a new set of allowed characters is specified.\n *\n *\n * @param sc       The USpoofChecker \n * @param status   The error code, set if this function encounters a problem.\n * @return         A USet containing the characters that are permitted by\n *                 the USPOOF_CHAR_LIMIT test.\n * @stable ICU 4.2\n */\nU_STABLE const USet * U_EXPORT2\nuspoof_getAllowedChars(const USpoofChecker *sc, UErrorCode *status);\n\n\n#if U_SHOW_CPLUSPLUS_API\n/**\n * Limit the acceptable characters to those specified by a Unicode Set.\n *   Any previously specified character limit is\n *   is replaced by the new settings.    This includes limits on\n *   characters that were set with the uspoof_setAllowedLocales() function.\n *\n * The USPOOF_CHAR_LIMIT test is automatically enabled for this\n * USoofChecker by this function.\n *\n * @param sc       The USpoofChecker \n * @param chars    A Unicode Set containing the list of\n *                 characters that are permitted.  Ownership of the set\n *                 remains with the caller.  The incoming set is cloned by\n *                 this function, so there are no restrictions on modifying\n *                 or deleting the USet after calling this function.\n * @param status   The error code, set if this function encounters a problem.\n * @stable ICU 4.2\n */\nU_STABLE void U_EXPORT2\nuspoof_setAllowedUnicodeSet(USpoofChecker *sc, const icu::UnicodeSet *chars, UErrorCode *status);\n\n\n/**\n * Get a UnicodeSet for the characters permitted in an identifier.\n * This corresponds to the limits imposed by the Set Allowed Characters / \n * UnicodeSet functions. Limitations imposed by other checks will not be\n * reflected in the set returned by this function.\n *\n * The returned set will be frozen, meaning that it cannot be modified\n * by the caller.\n *\n * Ownership of the returned set remains with the Spoof Detector.  The\n * returned set will become invalid if the spoof detector is closed,\n * or if a new set of allowed characters is specified.\n *\n *\n * @param sc       The USpoofChecker \n * @param status   The error code, set if this function encounters a problem.\n * @return         A UnicodeSet containing the characters that are permitted by\n *                 the USPOOF_CHAR_LIMIT test.\n * @stable ICU 4.2\n */\nU_STABLE const icu::UnicodeSet * U_EXPORT2\nuspoof_getAllowedUnicodeSet(const USpoofChecker *sc, UErrorCode *status);\n#endif\n\n\n/**\n * Check the specified string for possible security issues.\n * The text to be checked will typically be an identifier of some sort.\n * The set of checks to be performed is specified with uspoof_setChecks().\n * \n * @param sc      The USpoofChecker \n * @param text    The string to be checked for possible security issues,\n *                in UTF-16 format.\n * @param length  the length of the string to be checked, expressed in\n *                16 bit UTF-16 code units, or -1 if the string is \n *                zero terminated.\n * @param position      An out parameter that receives the index of the\n *                first string position that fails the allowed character\n *                limitation checks.\n *                This parameter may be null if the position information\n *                is not needed.\n *                If the string passes the requested checks the\n *                parameter value will not be set.\n * @param status  The error code, set if an error occurred while attempting to\n *                perform the check.\n *                Spoofing or security issues detected with the input string are\n *                not reported here, but through the function's return value.\n * @return        An integer value with bits set for any potential security\n *                or spoofing issues detected.  The bits are defined by\n *                enum USpoofChecks.  Zero is returned if no issues\n *                are found with the input string.\n * @stable ICU 4.2\n */\nU_STABLE int32_t U_EXPORT2\nuspoof_check(const USpoofChecker *sc,\n                         const UChar *text, int32_t length, \n                         int32_t *position,\n                         UErrorCode *status);\n\n\n/**\n * Check the specified string for possible security issues.\n * The text to be checked will typically be an identifier of some sort.\n * The set of checks to be performed is specified with uspoof_setChecks().\n * \n * @param sc      The USpoofChecker \n * @param text    A UTF-8 string to be checked for possible security issues.\n * @param length  the length of the string to be checked, or -1 if the string is \n *                zero terminated.\n * @param position      An out parameter that receives the index of the\n *                first string position that fails the allowed character\n *                limitation checks.\n *                This parameter may be null if the position information\n *                is not needed.\n *                If the string passes the requested checks the\n *                parameter value will not be set.\n * @param status  The error code, set if an error occurred while attempting to\n *                perform the check.\n *                Spoofing or security issues detected with the input string are\n *                not reported here, but through the function's return value.\n *                If the input contains invalid UTF-8 sequences,\n *                a status of U_INVALID_CHAR_FOUND will be returned.\n * @return        An integer value with bits set for any potential security\n *                or spoofing issues detected.  The bits are defined by\n *                enum USpoofChecks.  Zero is returned if no issues\n *                are found with the input string.\n * @stable ICU 4.2\n */\nU_STABLE int32_t U_EXPORT2\nuspoof_checkUTF8(const USpoofChecker *sc,\n                 const char *text, int32_t length,\n                 int32_t *position,\n                 UErrorCode *status);\n\n\n#if U_SHOW_CPLUSPLUS_API\n/**\n * Check the specified string for possible security issues.\n * The text to be checked will typically be an identifier of some sort.\n * The set of checks to be performed is specified with uspoof_setChecks().\n * \n * @param sc      The USpoofChecker \n * @param text    A UnicodeString to be checked for possible security issues.\n * @param position      An out parameter that receives the index of the\n *                first string position that fails the allowed character\n *                limitation checks.\n *                This parameter may be null if the position information\n *                is not needed.\n *                If the string passes the requested checks the\n *                parameter value will not be set.\n * @param status  The error code, set if an error occurred while attempting to\n *                perform the check.\n *                Spoofing or security issues detected with the input string are\n *                not reported here, but through the function's return value.\n\n * @return        An integer value with bits set for any potential security\n *                or spoofing issues detected.  The bits are defined by\n *                enum USpoofChecks.  Zero is returned if no issues\n *                are found with the input string.\n * @stable ICU 4.2\n */\nU_STABLE int32_t U_EXPORT2\nuspoof_checkUnicodeString(const USpoofChecker *sc,\n                          const icu::UnicodeString &text, \n                          int32_t *position,\n                          UErrorCode *status);\n\n#endif\n\n\n/**\n * Check the whether two specified strings are visually confusable.\n * The types of confusability to be tested - single script, mixed script,\n * or whole script - are determined by the check options set for the\n * USpoofChecker.\n *\n * The tests to be performed are controlled by the flags\n *   USPOOF_SINGLE_SCRIPT_CONFUSABLE \n *   USPOOF_MIXED_SCRIPT_CONFUSABLE  \n *   USPOOF_WHOLE_SCRIPT_CONFUSABLE\n * At least one of these tests must be selected.\n * \n * USPOOF_ANY_CASE is a modifier for the tests.  Select it if the identifiers\n *   may be of mixed case.\n * If identifiers are case folded for comparison and\n * display to the user, do not select the USPOOF_ANY_CASE option.\n *\n *\n * @param sc      The USpoofChecker\n * @param s1      The first of the two strings to be compared for \n *                confusability.  The strings are in UTF-16 format.\n * @param length1 the length of the first string, expressed in\n *                16 bit UTF-16 code units, or -1 if the string is \n *                zero terminated.\n * @param s2      The second of the two strings to be compared for \n *                confusability.  The strings are in UTF-16 format.\n * @param length2 The length of the second string, expressed in\n *                16 bit UTF-16 code units, or -1 if the string is \n *                zero terminated.\n * @param status  The error code, set if an error occurred while attempting to\n *                perform the check.\n *                Confusability of the strings is not reported here,\n *                but through this function's return value.\n * @return        An integer value with bit(s) set corresponding to\n *                the type of confusability found, as defined by\n *                enum USpoofChecks.  Zero is returned if the strings\n *                are not confusable.\n * @stable ICU 4.2\n */\nU_STABLE int32_t U_EXPORT2\nuspoof_areConfusable(const USpoofChecker *sc,\n                     const UChar *s1, int32_t length1,\n                     const UChar *s2, int32_t length2,\n                     UErrorCode *status);\n\n\n\n/**\n * Check the whether two specified strings are visually confusable.\n * The types of confusability to be tested - single script, mixed script,\n * or whole script - are determined by the check options set for the\n * USpoofChecker.\n *\n * @param sc      The USpoofChecker\n * @param s1      The first of the two strings to be compared for \n *                confusability.  The strings are in UTF-8 format.\n * @param length1 the length of the first string, in bytes, or -1 \n *                if the string is zero terminated.\n * @param s2      The second of the two strings to be compared for \n *                confusability.  The strings are in UTF-18 format.\n * @param length2 The length of the second string in bytes, or -1 \n *                if the string is zero terminated.\n * @param status  The error code, set if an error occurred while attempting to\n *                perform the check.\n *                Confusability of the strings is not reported here,\n *                but through this function's return value.\n * @return        An integer value with bit(s) set corresponding to\n *                the type of confusability found, as defined by\n *                enum USpoofChecks.  Zero is returned if the strings\n *                are not confusable.\n * @stable ICU 4.2\n */\nU_STABLE int32_t U_EXPORT2\nuspoof_areConfusableUTF8(const USpoofChecker *sc,\n                         const char *s1, int32_t length1,\n                         const char *s2, int32_t length2,\n                         UErrorCode *status);\n\n\n\n\n#if U_SHOW_CPLUSPLUS_API\n/**\n * Check the whether two specified strings are visually confusable.\n * The types of confusability to be tested - single script, mixed script,\n * or whole script - are determined by the check options set for the\n * USpoofChecker.\n *\n * @param sc      The USpoofChecker\n * @param s1      The first of the two strings to be compared for \n *                confusability.  The strings are in UTF-8 format.\n * @param s2      The second of the two strings to be compared for \n *                confusability.  The strings are in UTF-18 format.\n * @param status  The error code, set if an error occurred while attempting to\n *                perform the check.\n *                Confusability of the strings is not reported here,\n *                but through this function's return value.\n * @return        An integer value with bit(s) set corresponding to\n *                the type of confusability found, as defined by\n *                enum USpoofChecks.  Zero is returned if the strings\n *                are not confusable.\n * @stable ICU 4.2\n */\nU_STABLE int32_t U_EXPORT2\nuspoof_areConfusableUnicodeString(const USpoofChecker *sc,\n                                  const icu::UnicodeString &s1,\n                                  const icu::UnicodeString &s2,\n                                  UErrorCode *status);\n#endif\n\n\n/**\n  *  Get the \"skeleton\" for an identifier string.\n  *  Skeletons are a transformation of the input string;\n  *  Two strings are confusable if their skeletons are identical.\n  *  See Unicode UAX 39 for additional information.\n  *\n  *  Using skeletons directly makes it possible to quickly check\n  *  whether an identifier is confusable with any of some large\n  *  set of existing identifiers, by creating an efficiently\n  *  searchable collection of the skeletons.\n  *\n  * @param sc      The USpoofChecker\n  * @param type    The type of skeleton, corresponding to which\n  *                of the Unicode confusable data tables to use.\n  *                The default is Mixed-Script, Lowercase.\n  *                Allowed options are USPOOF_SINGLE_SCRIPT_CONFUSABLE and\n  *                USPOOF_ANY_CASE_CONFUSABLE.  The two flags may be ORed.\n  * @param s       The input string whose skeleton will be computed.\n  * @param length  The length of the input string, expressed in 16 bit\n  *                UTF-16 code units, or -1 if the string is zero terminated.\n  * @param dest    The output buffer, to receive the skeleton string.\n  * @param destCapacity  The length of the output buffer, in 16 bit units.\n  *                The destCapacity may be zero, in which case the function will\n  *                return the actual length of the skeleton.\n  * @param status  The error code, set if an error occurred while attempting to\n  *                perform the check.\n  * @return        The length of the skeleton string.  The returned length\n  *                is always that of the complete skeleton, even when the\n  *                supplied buffer is too small (or of zero length)\n  *                \n  * @stable ICU 4.2\n  */\nU_STABLE int32_t U_EXPORT2\nuspoof_getSkeleton(const USpoofChecker *sc,\n                   uint32_t type,\n                   const UChar *s,  int32_t length,\n                   UChar *dest, int32_t destCapacity,\n                   UErrorCode *status);\n    \n/**\n  *  Get the \"skeleton\" for an identifier string.\n  *  Skeletons are a transformation of the input string;\n  *  Two strings are confusable if their skeletons are identical.\n  *  See Unicode UAX 39 for additional information.\n  *\n  *  Using skeletons directly makes it possible to quickly check\n  *  whether an identifier is confusable with any of some large\n  *  set of existing identifiers, by creating an efficiently\n  *  searchable collection of the skeletons.\n  *\n  * @param sc      The USpoofChecker \n  * @param type    The type of skeleton, corresponding to which\n  *                of the Unicode confusable data tables to use.\n  *                The default is Mixed-Script, Lowercase.\n  *                Allowed options are USPOOF_SINGLE_SCRIPT_CONFUSABLE and\n  *                USPOOF_ANY_CASE.  The two flags may be ORed.\n  * @param s       The UTF-8 format input string whose skeleton will be computed.\n  * @param length  The length of the input string, in bytes,\n  *                or -1 if the string is zero terminated.\n  * @param dest    The output buffer, to receive the skeleton string.\n  * @param destCapacity  The length of the output buffer, in bytes.\n  *                The destCapacity may be zero, in which case the function will\n  *                return the actual length of the skeleton.\n  * @param status  The error code, set if an error occurred while attempting to\n  *                perform the check.  Possible Errors include U_INVALID_CHAR_FOUND\n  *                   for invalid UTF-8 sequences, and\n  *                   U_BUFFER_OVERFLOW_ERROR if the destination buffer is too small\n  *                   to hold the complete skeleton.\n  * @return        The length of the skeleton string, in bytes.  The returned length\n  *                is always that of the complete skeleton, even when the\n  *                supplied buffer is too small (or of zero length)\n  *                \n  * @stable ICU 4.2\n  */   \nU_STABLE int32_t U_EXPORT2\nuspoof_getSkeletonUTF8(const USpoofChecker *sc,\n                       uint32_t type,\n                       const char *s,  int32_t length,\n                       char *dest, int32_t destCapacity,\n                       UErrorCode *status);\n    \n#if U_SHOW_CPLUSPLUS_API\n/**\n  *  Get the \"skeleton\" for an identifier string.\n  *  Skeletons are a transformation of the input string;\n  *  Two strings are confusable if their skeletons are identical.\n  *  See Unicode UAX 39 for additional information.\n  *\n  *  Using skeletons directly makes it possible to quickly check\n  *  whether an identifier is confusable with any of some large\n  *  set of existing identifiers, by creating an efficiently\n  *  searchable collection of the skeletons.\n  *\n  * @param sc      The USpoofChecker.\n  * @param type    The type of skeleton, corresponding to which\n  *                of the Unicode confusable data tables to use.\n  *                The default is Mixed-Script, Lowercase.\n  *                Allowed options are USPOOF_SINGLE_SCRIPT_CONFUSABLE and\n  *                USPOOF_ANY_CASE_CONFUSABLE.  The two flags may be ORed.\n  * @param s       The input string whose skeleton will be computed.\n  * @param dest    The output string, to receive the skeleton string.\n  * @param status  The error code, set if an error occurred while attempting to\n  *                perform the check.\n  * @return        A reference to the destination (skeleton) string.\n  *                \n  * @stable ICU 4.2\n  */   \nU_I18N_API icu::UnicodeString & U_EXPORT2\nuspoof_getSkeletonUnicodeString(const USpoofChecker *sc,\n                                uint32_t type,\n                                const icu::UnicodeString &s,\n                                icu::UnicodeString &dest,\n                                UErrorCode *status);\n#endif   /* U_SHOW_CPLUSPLUS_API */\n\n\n/**\n * Serialize the data for a spoof detector into a chunk of memory.\n * The flattened spoof detection tables can later be used to efficiently\n * instantiate a new Spoof Detector.\n *\n * @param sc   the Spoof Detector whose data is to be serialized.\n * @param data a pointer to 32-bit-aligned memory to be filled with the data,\n *             can be NULL if capacity==0\n * @param capacity the number of bytes available at data,\n *                 or 0 for preflighting\n * @param status an in/out ICU UErrorCode; possible errors include:\n * - U_BUFFER_OVERFLOW_ERROR if the data storage block is too small for serialization\n * - U_ILLEGAL_ARGUMENT_ERROR  the data or capacity parameters are bad\n * @return the number of bytes written or needed for the spoof data\n *\n * @see utrie2_openFromSerialized()\n * @stable ICU 4.2\n */\nU_STABLE int32_t U_EXPORT2\nuspoof_serialize(USpoofChecker *sc,\n                 void *data, int32_t capacity,\n                 UErrorCode *status);\n\n\n#endif\n\n#endif   /* USPOOF_H */\n"
  },
  {
    "path": "deprecated/android/addons/icucompat/unicode/usprep.h",
    "content": "/*\n *******************************************************************************\n *\n *   Copyright (C) 2003-2010, International Business Machines\n *   Corporation and others.  All Rights Reserved.\n *\n *******************************************************************************\n *   file name:  usprep.h\n *   encoding:   US-ASCII\n *   tab size:   8 (not used)\n *   indentation:4\n *\n *   created on: 2003jul2\n *   created by: Ram Viswanadha\n */\n\n#ifndef __USPREP_H__\n#define __USPREP_H__\n\n/**\n * \\file \n * \\brief C API: Implements the StringPrep algorithm.\n */\n\n#include \"unicode/utypes.h\"\n#include \"unicode/localpointer.h\"\n\n/**\n *\n * StringPrep API implements the StingPrep framework as described by RFC 3454.\n * StringPrep prepares Unicode strings for use in network protocols.\n * Profiles of StingPrep are set of rules and data according to with the\n * Unicode Strings are prepared. Each profiles contains tables which describe\n * how a code point should be treated. The tables are broadly classied into\n * <ul>\n *     <li> Unassinged Table: Contains code points that are unassigned \n *          in the Unicode Version supported by StringPrep. Currently \n *          RFC 3454 supports Unicode 3.2. </li>\n *     <li> Prohibited Table: Contains code points that are prohibted from\n *          the output of the StringPrep processing function. </li>\n *     <li> Mapping Table: Contains code ponts that are deleted from the output or case mapped. </li>\n * </ul>\n * \n * The procedure for preparing Unicode strings:\n * <ol>\n *      <li> Map: For each character in the input, check if it has a mapping\n *           and, if so, replace it with its mapping. </li>\n *      <li> Normalize: Possibly normalize the result of step 1 using Unicode\n *           normalization. </li>\n *      <li> Prohibit: Check for any characters that are not allowed in the\n *        output.  If any are found, return an error.</li>\n *      <li> Check bidi: Possibly check for right-to-left characters, and if\n *           any are found, make sure that the whole string satisfies the\n *           requirements for bidirectional strings.  If the string does not\n *           satisfy the requirements for bidirectional strings, return an\n *           error.  </li>\n * </ol>\n * @author Ram Viswanadha\n */\n#if !UCONFIG_NO_IDNA\n\n#include \"unicode/parseerr.h\"\n\n/**\n * The StringPrep profile\n * @stable ICU 2.8\n */\ntypedef struct UStringPrepProfile UStringPrepProfile;\n\n\n/** \n * Option to prohibit processing of unassigned code points in the input\n * \n * @see  usprep_prepare\n * @stable ICU 2.8\n */\n#define USPREP_DEFAULT 0x0000\n\n/** \n * Option to allow processing of unassigned code points in the input\n * \n * @see  usprep_prepare\n * @stable ICU 2.8\n */\n#define USPREP_ALLOW_UNASSIGNED 0x0001\n\n/**\n * enums for the standard stringprep profile types\n * supported by usprep_openByType.\n * @see usprep_openByType\n * @stable ICU 4.2\n */\ntypedef enum UStringPrepProfileType {\n    /**\n     * RFC3491 Nameprep\n     * @stable ICU 4.2\n     */\n    USPREP_RFC3491_NAMEPREP,\n    /**\n     * RFC3530 nfs4_cs_prep\n     * @stable ICU 4.2\n     */\n\tUSPREP_RFC3530_NFS4_CS_PREP,\n    /**\n     * RFC3530 nfs4_cs_prep with case insensitive option\n     * @stable ICU 4.2\n     */\n\tUSPREP_RFC3530_NFS4_CS_PREP_CI,\n    /**\n     * RFC3530 nfs4_cis_prep\n     * @stable ICU 4.2\n     */\n\tUSPREP_RFC3530_NFS4_CIS_PREP,\n    /**\n     * RFC3530 nfs4_mixed_prep for prefix\n     * @stable ICU 4.2\n     */\n\tUSPREP_RFC3530_NFS4_MIXED_PREP_PREFIX,\n    /**\n     * RFC3530 nfs4_mixed_prep for suffix\n     * @stable ICU 4.2\n     */\n\tUSPREP_RFC3530_NFS4_MIXED_PREP_SUFFIX,\n    /**\n     * RFC3722 iSCSI\n     * @stable ICU 4.2\n     */\n\tUSPREP_RFC3722_ISCSI,\n    /**\n     * RFC3920 XMPP Nodeprep\n     * @stable ICU 4.2\n     */\n\tUSPREP_RFC3920_NODEPREP,\n    /**\n     * RFC3920 XMPP Resourceprep\n     * @stable ICU 4.2\n     */\n\tUSPREP_RFC3920_RESOURCEPREP,\n    /**\n     * RFC4011 Policy MIB Stringprep\n     * @stable ICU 4.2\n     */\n\tUSPREP_RFC4011_MIB,\n    /**\n     * RFC4013 SASLprep\n     * @stable ICU 4.2\n     */\n    USPREP_RFC4013_SASLPREP,\n    /**\n     * RFC4505 trace\n     * @stable ICU 4.2\n     */\n\tUSPREP_RFC4505_TRACE,\n    /**\n     * RFC4518 LDAP\n     * @stable ICU 4.2\n     */\n\tUSPREP_RFC4518_LDAP,\n    /**\n     * RFC4518 LDAP for case ignore, numeric and stored prefix\n     * matching rules\n     * @stable ICU 4.2\n     */\n\tUSPREP_RFC4518_LDAP_CI\n} UStringPrepProfileType;\n\n/**\n * Creates a StringPrep profile from the data file.\n *\n * @param path      string containing the full path pointing to the directory\n *                  where the profile reside followed by the package name\n *                  e.g. \"/usr/resource/my_app/profiles/mydata\" on a Unix system.\n *                  if NULL, ICU default data files will be used.\n * @param fileName  name of the profile file to be opened\n * @param status    ICU error code in/out parameter. Must not be NULL.\n *                  Must fulfill U_SUCCESS before the function call.\n * @return Pointer to UStringPrepProfile that is opened. Should be closed by\n * calling usprep_close()\n * @see usprep_close()\n * @stable ICU 2.8\n */\nU_STABLE UStringPrepProfile* U_EXPORT2\nusprep_open(const char* path, \n            const char* fileName,\n            UErrorCode* status);\n\n/**\n * Creates a StringPrep profile for the specified profile type.\n *\n * @param type\t\tThe profile type\n * @param status    ICU error code in/out parameter. Must not be NULL.\n *                  Must fulfill U_SUCCESS before the function call.\n * @return          Pointer to UStringPrepProfile that is opened. Should be closed by\n *                  calling usprep_close()\n * @see usprep_close()\n * @stable ICU 4.2\n */\nU_STABLE UStringPrepProfile* U_EXPORT2\nusprep_openByType(UStringPrepProfileType type,\n\t\t\t\t  UErrorCode* status);\n\n/**\n * Closes the profile\n * @param profile The profile to close\n * @stable ICU 2.8\n */\nU_STABLE void U_EXPORT2\nusprep_close(UStringPrepProfile* profile);\n\n#if U_SHOW_CPLUSPLUS_API\n\nU_NAMESPACE_BEGIN\n\n/**\n * \\class LocalUStringPrepProfilePointer\n * \"Smart pointer\" class, closes a UStringPrepProfile via usprep_close().\n * For most methods see the LocalPointerBase base class.\n *\n * @see LocalPointerBase\n * @see LocalPointer\n * @stable ICU 4.4\n */\nU_DEFINE_LOCAL_OPEN_POINTER(LocalUStringPrepProfilePointer, UStringPrepProfile, usprep_close);\n\nU_NAMESPACE_END\n\n#endif\n\n/**\n * Prepare the input buffer for use in applications with the given profile. This operation maps, normalizes(NFKC),\n * checks for prohited and BiDi characters in the order defined by RFC 3454\n * depending on the options specified in the profile.\n *\n * @param prep          The profile to use \n * @param src           Pointer to UChar buffer containing the string to prepare\n * @param srcLength     Number of characters in the source string\n * @param dest          Pointer to the destination buffer to receive the output\n * @param destCapacity  The capacity of destination array\n * @param options       A bit set of options:\n *\n *  - USPREP_NONE               Prohibit processing of unassigned code points in the input\n *\n *  - USPREP_ALLOW_UNASSIGNED   Treat the unassigned code points are in the input \n *                              as normal Unicode code points.\n *\n * @param parseError        Pointer to UParseError struct to receive information on position \n *                          of error if an error is encountered. Can be NULL.\n * @param status            ICU in/out error code parameter.\n *                          U_INVALID_CHAR_FOUND if src contains\n *                          unmatched single surrogates.\n *                          U_INDEX_OUTOFBOUNDS_ERROR if src contains\n *                          too many code points.\n *                          U_BUFFER_OVERFLOW_ERROR if destCapacity is not enough\n * @return The number of UChars in the destination buffer\n * @stable ICU 2.8\n */\n\nU_STABLE int32_t U_EXPORT2\nusprep_prepare(   const UStringPrepProfile* prep,\n                  const UChar* src, int32_t srcLength, \n                  UChar* dest, int32_t destCapacity,\n                  int32_t options,\n                  UParseError* parseError,\n                  UErrorCode* status );\n\n\n#endif /* #if !UCONFIG_NO_IDNA */\n\n#endif\n"
  },
  {
    "path": "deprecated/android/addons/icucompat/unicode/ustring.h",
    "content": "/*\n**********************************************************************\n*   Copyright (C) 1998-2012, International Business Machines\n*   Corporation and others.  All Rights Reserved.\n**********************************************************************\n*\n* File ustring.h\n*\n* Modification History:\n*\n*   Date        Name        Description\n*   12/07/98    bertrand    Creation.\n******************************************************************************\n*/\n\n#ifndef USTRING_H\n#define USTRING_H\n\n#include \"unicode/utypes.h\"\n#include \"unicode/putil.h\"\n#include \"unicode/uiter.h\"\n\n/**\n * \\def UBRK_TYPEDEF_UBREAK_ITERATOR\n * @internal \n */\n\n#ifndef UBRK_TYPEDEF_UBREAK_ITERATOR\n#   define UBRK_TYPEDEF_UBREAK_ITERATOR\n/** Simple declaration for u_strToTitle() to avoid including unicode/ubrk.h. @stable ICU 2.1*/\n    typedef struct UBreakIterator UBreakIterator;\n#endif\n\n/**\n * \\file\n * \\brief C API: Unicode string handling functions\n *\n * These C API functions provide general Unicode string handling.\n *\n * Some functions are equivalent in name, signature, and behavior to the ANSI C <string.h>\n * functions. (For example, they do not check for bad arguments like NULL string pointers.)\n * In some cases, only the thread-safe variant of such a function is implemented here\n * (see u_strtok_r()).\n *\n * Other functions provide more Unicode-specific functionality like locale-specific\n * upper/lower-casing and string comparison in code point order.\n *\n * ICU uses 16-bit Unicode (UTF-16) in the form of arrays of UChar code units.\n * UTF-16 encodes each Unicode code point with either one or two UChar code units.\n * (This is the default form of Unicode, and a forward-compatible extension of the original,\n * fixed-width form that was known as UCS-2. UTF-16 superseded UCS-2 with Unicode 2.0\n * in 1996.)\n *\n * Some APIs accept a 32-bit UChar32 value for a single code point.\n *\n * ICU also handles 16-bit Unicode text with unpaired surrogates.\n * Such text is not well-formed UTF-16.\n * Code-point-related functions treat unpaired surrogates as surrogate code points,\n * i.e., as separate units.\n *\n * Although UTF-16 is a variable-width encoding form (like some legacy multi-byte encodings),\n * it is much more efficient even for random access because the code unit values\n * for single-unit characters vs. lead units vs. trail units are completely disjoint.\n * This means that it is easy to determine character (code point) boundaries from\n * random offsets in the string.\n *\n * Unicode (UTF-16) string processing is optimized for the single-unit case.\n * Although it is important to support supplementary characters\n * (which use pairs of lead/trail code units called \"surrogates\"),\n * their occurrence is rare. Almost all characters in modern use require only\n * a single UChar code unit (i.e., their code point values are <=0xffff).\n *\n * For more details see the User Guide Strings chapter (http://icu-project.org/userguide/strings.html).\n * For a discussion of the handling of unpaired surrogates see also\n * Jitterbug 2145 and its icu mailing list proposal on 2002-sep-18.\n */\n\n/**\n * \\defgroup ustring_ustrlen String Length\n * \\ingroup ustring_strlen\n */\n/*@{*/\n/**\n * Determine the length of an array of UChar.\n *\n * @param s The array of UChars, NULL (U+0000) terminated.\n * @return The number of UChars in <code>chars</code>, minus the terminator.\n * @stable ICU 2.0\n */\nU_STABLE int32_t U_EXPORT2\nu_strlen(const UChar *s);\n/*@}*/\n\n/**\n * Count Unicode code points in the length UChar code units of the string.\n * A code point may occupy either one or two UChar code units.\n * Counting code points involves reading all code units.\n *\n * This functions is basically the inverse of the U16_FWD_N() macro (see utf.h).\n *\n * @param s The input string.\n * @param length The number of UChar code units to be checked, or -1 to count all\n *               code points before the first NUL (U+0000).\n * @return The number of code points in the specified code units.\n * @stable ICU 2.0\n */\nU_STABLE int32_t U_EXPORT2\nu_countChar32(const UChar *s, int32_t length);\n\n/**\n * Check if the string contains more Unicode code points than a certain number.\n * This is more efficient than counting all code points in the entire string\n * and comparing that number with a threshold.\n * This function may not need to scan the string at all if the length is known\n * (not -1 for NUL-termination) and falls within a certain range, and\n * never needs to count more than 'number+1' code points.\n * Logically equivalent to (u_countChar32(s, length)>number).\n * A Unicode code point may occupy either one or two UChar code units.\n *\n * @param s The input string.\n * @param length The length of the string, or -1 if it is NUL-terminated.\n * @param number The number of code points in the string is compared against\n *               the 'number' parameter.\n * @return Boolean value for whether the string contains more Unicode code points\n *         than 'number'. Same as (u_countChar32(s, length)>number).\n * @stable ICU 2.4\n */\nU_STABLE UBool U_EXPORT2\nu_strHasMoreChar32Than(const UChar *s, int32_t length, int32_t number);\n\n/**\n * Concatenate two ustrings.  Appends a copy of <code>src</code>,\n * including the null terminator, to <code>dst</code>. The initial copied\n * character from <code>src</code> overwrites the null terminator in <code>dst</code>.\n *\n * @param dst The destination string.\n * @param src The source string.\n * @return A pointer to <code>dst</code>.\n * @stable ICU 2.0\n */\nU_STABLE UChar* U_EXPORT2\nu_strcat(UChar     *dst, \n    const UChar     *src);\n\n/**\n * Concatenate two ustrings.  \n * Appends at most <code>n</code> characters from <code>src</code> to <code>dst</code>.\n * Adds a terminating NUL.\n * If src is too long, then only <code>n-1</code> characters will be copied\n * before the terminating NUL.\n * If <code>n&lt;=0</code> then dst is not modified.\n *\n * @param dst The destination string.\n * @param src The source string (can be NULL/invalid if n<=0).\n * @param n The maximum number of characters to append; no-op if <=0.\n * @return A pointer to <code>dst</code>.\n * @stable ICU 2.0\n */\nU_STABLE UChar* U_EXPORT2\nu_strncat(UChar     *dst, \n     const UChar     *src, \n     int32_t     n);\n\n/**\n * Find the first occurrence of a substring in a string.\n * The substring is found at code point boundaries.\n * That means that if the substring begins with\n * a trail surrogate or ends with a lead surrogate,\n * then it is found only if these surrogates stand alone in the text.\n * Otherwise, the substring edge units would be matched against\n * halves of surrogate pairs.\n *\n * @param s The string to search (NUL-terminated).\n * @param substring The substring to find (NUL-terminated).\n * @return A pointer to the first occurrence of <code>substring</code> in <code>s</code>,\n *         or <code>s</code> itself if the <code>substring</code> is empty,\n *         or <code>NULL</code> if <code>substring</code> is not in <code>s</code>.\n * @stable ICU 2.0\n *\n * @see u_strrstr\n * @see u_strFindFirst\n * @see u_strFindLast\n */\nU_STABLE UChar * U_EXPORT2\nu_strstr(const UChar *s, const UChar *substring);\n\n/**\n * Find the first occurrence of a substring in a string.\n * The substring is found at code point boundaries.\n * That means that if the substring begins with\n * a trail surrogate or ends with a lead surrogate,\n * then it is found only if these surrogates stand alone in the text.\n * Otherwise, the substring edge units would be matched against\n * halves of surrogate pairs.\n *\n * @param s The string to search.\n * @param length The length of s (number of UChars), or -1 if it is NUL-terminated.\n * @param substring The substring to find (NUL-terminated).\n * @param subLength The length of substring (number of UChars), or -1 if it is NUL-terminated.\n * @return A pointer to the first occurrence of <code>substring</code> in <code>s</code>,\n *         or <code>s</code> itself if the <code>substring</code> is empty,\n *         or <code>NULL</code> if <code>substring</code> is not in <code>s</code>.\n * @stable ICU 2.4\n *\n * @see u_strstr\n * @see u_strFindLast\n */\nU_STABLE UChar * U_EXPORT2\nu_strFindFirst(const UChar *s, int32_t length, const UChar *substring, int32_t subLength);\n\n/**\n * Find the first occurrence of a BMP code point in a string.\n * A surrogate code point is found only if its match in the text is not\n * part of a surrogate pair.\n * A NUL character is found at the string terminator.\n *\n * @param s The string to search (NUL-terminated).\n * @param c The BMP code point to find.\n * @return A pointer to the first occurrence of <code>c</code> in <code>s</code>\n *         or <code>NULL</code> if <code>c</code> is not in <code>s</code>.\n * @stable ICU 2.0\n *\n * @see u_strchr32\n * @see u_memchr\n * @see u_strstr\n * @see u_strFindFirst\n */\nU_STABLE UChar * U_EXPORT2\nu_strchr(const UChar *s, UChar c);\n\n/**\n * Find the first occurrence of a code point in a string.\n * A surrogate code point is found only if its match in the text is not\n * part of a surrogate pair.\n * A NUL character is found at the string terminator.\n *\n * @param s The string to search (NUL-terminated).\n * @param c The code point to find.\n * @return A pointer to the first occurrence of <code>c</code> in <code>s</code>\n *         or <code>NULL</code> if <code>c</code> is not in <code>s</code>.\n * @stable ICU 2.0\n *\n * @see u_strchr\n * @see u_memchr32\n * @see u_strstr\n * @see u_strFindFirst\n */\nU_STABLE UChar * U_EXPORT2\nu_strchr32(const UChar *s, UChar32 c);\n\n/**\n * Find the last occurrence of a substring in a string.\n * The substring is found at code point boundaries.\n * That means that if the substring begins with\n * a trail surrogate or ends with a lead surrogate,\n * then it is found only if these surrogates stand alone in the text.\n * Otherwise, the substring edge units would be matched against\n * halves of surrogate pairs.\n *\n * @param s The string to search (NUL-terminated).\n * @param substring The substring to find (NUL-terminated).\n * @return A pointer to the last occurrence of <code>substring</code> in <code>s</code>,\n *         or <code>s</code> itself if the <code>substring</code> is empty,\n *         or <code>NULL</code> if <code>substring</code> is not in <code>s</code>.\n * @stable ICU 2.4\n *\n * @see u_strstr\n * @see u_strFindFirst\n * @see u_strFindLast\n */\nU_STABLE UChar * U_EXPORT2\nu_strrstr(const UChar *s, const UChar *substring);\n\n/**\n * Find the last occurrence of a substring in a string.\n * The substring is found at code point boundaries.\n * That means that if the substring begins with\n * a trail surrogate or ends with a lead surrogate,\n * then it is found only if these surrogates stand alone in the text.\n * Otherwise, the substring edge units would be matched against\n * halves of surrogate pairs.\n *\n * @param s The string to search.\n * @param length The length of s (number of UChars), or -1 if it is NUL-terminated.\n * @param substring The substring to find (NUL-terminated).\n * @param subLength The length of substring (number of UChars), or -1 if it is NUL-terminated.\n * @return A pointer to the last occurrence of <code>substring</code> in <code>s</code>,\n *         or <code>s</code> itself if the <code>substring</code> is empty,\n *         or <code>NULL</code> if <code>substring</code> is not in <code>s</code>.\n * @stable ICU 2.4\n *\n * @see u_strstr\n * @see u_strFindLast\n */\nU_STABLE UChar * U_EXPORT2\nu_strFindLast(const UChar *s, int32_t length, const UChar *substring, int32_t subLength);\n\n/**\n * Find the last occurrence of a BMP code point in a string.\n * A surrogate code point is found only if its match in the text is not\n * part of a surrogate pair.\n * A NUL character is found at the string terminator.\n *\n * @param s The string to search (NUL-terminated).\n * @param c The BMP code point to find.\n * @return A pointer to the last occurrence of <code>c</code> in <code>s</code>\n *         or <code>NULL</code> if <code>c</code> is not in <code>s</code>.\n * @stable ICU 2.4\n *\n * @see u_strrchr32\n * @see u_memrchr\n * @see u_strrstr\n * @see u_strFindLast\n */\nU_STABLE UChar * U_EXPORT2\nu_strrchr(const UChar *s, UChar c);\n\n/**\n * Find the last occurrence of a code point in a string.\n * A surrogate code point is found only if its match in the text is not\n * part of a surrogate pair.\n * A NUL character is found at the string terminator.\n *\n * @param s The string to search (NUL-terminated).\n * @param c The code point to find.\n * @return A pointer to the last occurrence of <code>c</code> in <code>s</code>\n *         or <code>NULL</code> if <code>c</code> is not in <code>s</code>.\n * @stable ICU 2.4\n *\n * @see u_strrchr\n * @see u_memchr32\n * @see u_strrstr\n * @see u_strFindLast\n */\nU_STABLE UChar * U_EXPORT2\nu_strrchr32(const UChar *s, UChar32 c);\n\n/**\n * Locates the first occurrence in the string <code>string</code> of any of the characters\n * in the string <code>matchSet</code>.\n * Works just like C's strpbrk but with Unicode.\n *\n * @param string The string in which to search, NUL-terminated.\n * @param matchSet A NUL-terminated string defining a set of code points\n *                 for which to search in the text string.\n * @return A pointer to the  character in <code>string</code> that matches one of the\n *         characters in <code>matchSet</code>, or NULL if no such character is found.\n * @stable ICU 2.0\n */\nU_STABLE UChar * U_EXPORT2\nu_strpbrk(const UChar *string, const UChar *matchSet);\n\n/**\n * Returns the number of consecutive characters in <code>string</code>,\n * beginning with the first, that do not occur somewhere in <code>matchSet</code>.\n * Works just like C's strcspn but with Unicode.\n *\n * @param string The string in which to search, NUL-terminated.\n * @param matchSet A NUL-terminated string defining a set of code points\n *                 for which to search in the text string.\n * @return The number of initial characters in <code>string</code> that do not\n *         occur in <code>matchSet</code>.\n * @see u_strspn\n * @stable ICU 2.0\n */\nU_STABLE int32_t U_EXPORT2\nu_strcspn(const UChar *string, const UChar *matchSet);\n\n/**\n * Returns the number of consecutive characters in <code>string</code>,\n * beginning with the first, that occur somewhere in <code>matchSet</code>.\n * Works just like C's strspn but with Unicode.\n *\n * @param string The string in which to search, NUL-terminated.\n * @param matchSet A NUL-terminated string defining a set of code points\n *                 for which to search in the text string.\n * @return The number of initial characters in <code>string</code> that do\n *         occur in <code>matchSet</code>.\n * @see u_strcspn\n * @stable ICU 2.0\n */\nU_STABLE int32_t U_EXPORT2\nu_strspn(const UChar *string, const UChar *matchSet);\n\n/**\n * The string tokenizer API allows an application to break a string into\n * tokens. Unlike strtok(), the saveState (the current pointer within the\n * original string) is maintained in saveState. In the first call, the\n * argument src is a pointer to the string. In subsequent calls to\n * return successive tokens of that string, src must be specified as\n * NULL. The value saveState is set by this function to maintain the\n * function's position within the string, and on each subsequent call\n * you must give this argument the same variable. This function does\n * handle surrogate pairs. This function is similar to the strtok_r()\n * the POSIX Threads Extension (1003.1c-1995) version.\n *\n * @param src String containing token(s). This string will be modified.\n *            After the first call to u_strtok_r(), this argument must\n *            be NULL to get to the next token.\n * @param delim Set of delimiter characters (Unicode code points).\n * @param saveState The current pointer within the original string,\n *              which is set by this function. The saveState\n *              parameter should the address of a local variable of type\n *              UChar *. (i.e. defined \"Uhar *myLocalSaveState\" and use\n *              &myLocalSaveState for this parameter).\n * @return A pointer to the next token found in src, or NULL\n *         when there are no more tokens.\n * @stable ICU 2.0\n */\nU_STABLE UChar * U_EXPORT2\nu_strtok_r(UChar    *src, \n     const UChar    *delim,\n           UChar   **saveState);\n\n/**\n * Compare two Unicode strings for bitwise equality (code unit order).\n *\n * @param s1 A string to compare.\n * @param s2 A string to compare.\n * @return 0 if <code>s1</code> and <code>s2</code> are bitwise equal; a negative\n * value if <code>s1</code> is bitwise less than <code>s2,</code>; a positive\n * value if <code>s1</code> is bitwise greater than <code>s2</code>.\n * @stable ICU 2.0\n */\nU_STABLE int32_t  U_EXPORT2\nu_strcmp(const UChar     *s1, \n         const UChar     *s2);\n\n/**\n * Compare two Unicode strings in code point order.\n * See u_strCompare for details.\n *\n * @param s1 A string to compare.\n * @param s2 A string to compare.\n * @return a negative/zero/positive integer corresponding to whether\n * the first string is less than/equal to/greater than the second one\n * in code point order\n * @stable ICU 2.0\n */\nU_STABLE int32_t U_EXPORT2\nu_strcmpCodePointOrder(const UChar *s1, const UChar *s2);\n\n/**\n * Compare two Unicode strings (binary order).\n *\n * The comparison can be done in code unit order or in code point order.\n * They differ only in UTF-16 when\n * comparing supplementary code points (U+10000..U+10ffff)\n * to BMP code points near the end of the BMP (i.e., U+e000..U+ffff).\n * In code unit order, high BMP code points sort after supplementary code points\n * because they are stored as pairs of surrogates which are at U+d800..U+dfff.\n *\n * This functions works with strings of different explicitly specified lengths\n * unlike the ANSI C-like u_strcmp() and u_memcmp() etc.\n * NUL-terminated strings are possible with length arguments of -1.\n *\n * @param s1 First source string.\n * @param length1 Length of first source string, or -1 if NUL-terminated.\n *\n * @param s2 Second source string.\n * @param length2 Length of second source string, or -1 if NUL-terminated.\n *\n * @param codePointOrder Choose between code unit order (FALSE)\n *                       and code point order (TRUE).\n *\n * @return <0 or 0 or >0 as usual for string comparisons\n *\n * @stable ICU 2.2\n */\nU_STABLE int32_t U_EXPORT2\nu_strCompare(const UChar *s1, int32_t length1,\n             const UChar *s2, int32_t length2,\n             UBool codePointOrder);\n\n/**\n * Compare two Unicode strings (binary order)\n * as presented by UCharIterator objects.\n * Works otherwise just like u_strCompare().\n *\n * Both iterators are reset to their start positions.\n * When the function returns, it is undefined where the iterators\n * have stopped.\n *\n * @param iter1 First source string iterator.\n * @param iter2 Second source string iterator.\n * @param codePointOrder Choose between code unit order (FALSE)\n *                       and code point order (TRUE).\n *\n * @return <0 or 0 or >0 as usual for string comparisons\n *\n * @see u_strCompare\n *\n * @stable ICU 2.6\n */\nU_STABLE int32_t U_EXPORT2\nu_strCompareIter(UCharIterator *iter1, UCharIterator *iter2, UBool codePointOrder);\n\n#ifndef U_COMPARE_CODE_POINT_ORDER\n/* see also unistr.h and unorm.h */\n/**\n * Option bit for u_strCaseCompare, u_strcasecmp, unorm_compare, etc:\n * Compare strings in code point order instead of code unit order.\n * @stable ICU 2.2\n */\n#define U_COMPARE_CODE_POINT_ORDER  0x8000\n#endif\n\n/**\n * Compare two strings case-insensitively using full case folding.\n * This is equivalent to\n *   u_strCompare(u_strFoldCase(s1, options),\n *                u_strFoldCase(s2, options),\n *                (options&U_COMPARE_CODE_POINT_ORDER)!=0).\n *\n * The comparison can be done in UTF-16 code unit order or in code point order.\n * They differ only when comparing supplementary code points (U+10000..U+10ffff)\n * to BMP code points near the end of the BMP (i.e., U+e000..U+ffff).\n * In code unit order, high BMP code points sort after supplementary code points\n * because they are stored as pairs of surrogates which are at U+d800..U+dfff.\n *\n * This functions works with strings of different explicitly specified lengths\n * unlike the ANSI C-like u_strcmp() and u_memcmp() etc.\n * NUL-terminated strings are possible with length arguments of -1.\n *\n * @param s1 First source string.\n * @param length1 Length of first source string, or -1 if NUL-terminated.\n *\n * @param s2 Second source string.\n * @param length2 Length of second source string, or -1 if NUL-terminated.\n *\n * @param options A bit set of options:\n *   - U_FOLD_CASE_DEFAULT or 0 is used for default options:\n *     Comparison in code unit order with default case folding.\n *\n *   - U_COMPARE_CODE_POINT_ORDER\n *     Set to choose code point order instead of code unit order\n *     (see u_strCompare for details).\n *\n *   - U_FOLD_CASE_EXCLUDE_SPECIAL_I\n *\n * @param pErrorCode Must be a valid pointer to an error code value,\n *                  which must not indicate a failure before the function call.\n *\n * @return <0 or 0 or >0 as usual for string comparisons\n *\n * @stable ICU 2.2\n */\nU_STABLE int32_t U_EXPORT2\nu_strCaseCompare(const UChar *s1, int32_t length1,\n                 const UChar *s2, int32_t length2,\n                 uint32_t options,\n                 UErrorCode *pErrorCode);\n\n/**\n * Compare two ustrings for bitwise equality. \n * Compares at most <code>n</code> characters.\n *\n * @param ucs1 A string to compare (can be NULL/invalid if n<=0).\n * @param ucs2 A string to compare (can be NULL/invalid if n<=0).\n * @param n The maximum number of characters to compare; always returns 0 if n<=0.\n * @return 0 if <code>s1</code> and <code>s2</code> are bitwise equal; a negative\n * value if <code>s1</code> is bitwise less than <code>s2</code>; a positive\n * value if <code>s1</code> is bitwise greater than <code>s2</code>.\n * @stable ICU 2.0\n */\nU_STABLE int32_t U_EXPORT2\nu_strncmp(const UChar     *ucs1, \n     const UChar     *ucs2, \n     int32_t     n);\n\n/**\n * Compare two Unicode strings in code point order.\n * This is different in UTF-16 from u_strncmp() if supplementary characters are present.\n * For details, see u_strCompare().\n *\n * @param s1 A string to compare.\n * @param s2 A string to compare.\n * @param n The maximum number of characters to compare.\n * @return a negative/zero/positive integer corresponding to whether\n * the first string is less than/equal to/greater than the second one\n * in code point order\n * @stable ICU 2.0\n */\nU_STABLE int32_t U_EXPORT2\nu_strncmpCodePointOrder(const UChar *s1, const UChar *s2, int32_t n);\n\n/**\n * Compare two strings case-insensitively using full case folding.\n * This is equivalent to u_strcmp(u_strFoldCase(s1, options), u_strFoldCase(s2, options)).\n *\n * @param s1 A string to compare.\n * @param s2 A string to compare.\n * @param options A bit set of options:\n *   - U_FOLD_CASE_DEFAULT or 0 is used for default options:\n *     Comparison in code unit order with default case folding.\n *\n *   - U_COMPARE_CODE_POINT_ORDER\n *     Set to choose code point order instead of code unit order\n *     (see u_strCompare for details).\n *\n *   - U_FOLD_CASE_EXCLUDE_SPECIAL_I\n *\n * @return A negative, zero, or positive integer indicating the comparison result.\n * @stable ICU 2.0\n */\nU_STABLE int32_t U_EXPORT2\nu_strcasecmp(const UChar *s1, const UChar *s2, uint32_t options);\n\n/**\n * Compare two strings case-insensitively using full case folding.\n * This is equivalent to u_strcmp(u_strFoldCase(s1, at most n, options),\n * u_strFoldCase(s2, at most n, options)).\n *\n * @param s1 A string to compare.\n * @param s2 A string to compare.\n * @param n The maximum number of characters each string to case-fold and then compare.\n * @param options A bit set of options:\n *   - U_FOLD_CASE_DEFAULT or 0 is used for default options:\n *     Comparison in code unit order with default case folding.\n *\n *   - U_COMPARE_CODE_POINT_ORDER\n *     Set to choose code point order instead of code unit order\n *     (see u_strCompare for details).\n *\n *   - U_FOLD_CASE_EXCLUDE_SPECIAL_I\n *\n * @return A negative, zero, or positive integer indicating the comparison result.\n * @stable ICU 2.0\n */\nU_STABLE int32_t U_EXPORT2\nu_strncasecmp(const UChar *s1, const UChar *s2, int32_t n, uint32_t options);\n\n/**\n * Compare two strings case-insensitively using full case folding.\n * This is equivalent to u_strcmp(u_strFoldCase(s1, n, options),\n * u_strFoldCase(s2, n, options)).\n *\n * @param s1 A string to compare.\n * @param s2 A string to compare.\n * @param length The number of characters in each string to case-fold and then compare.\n * @param options A bit set of options:\n *   - U_FOLD_CASE_DEFAULT or 0 is used for default options:\n *     Comparison in code unit order with default case folding.\n *\n *   - U_COMPARE_CODE_POINT_ORDER\n *     Set to choose code point order instead of code unit order\n *     (see u_strCompare for details).\n *\n *   - U_FOLD_CASE_EXCLUDE_SPECIAL_I\n *\n * @return A negative, zero, or positive integer indicating the comparison result.\n * @stable ICU 2.0\n */\nU_STABLE int32_t U_EXPORT2\nu_memcasecmp(const UChar *s1, const UChar *s2, int32_t length, uint32_t options);\n\n/**\n * Copy a ustring. Adds a null terminator.\n *\n * @param dst The destination string.\n * @param src The source string.\n * @return A pointer to <code>dst</code>.\n * @stable ICU 2.0\n */\nU_STABLE UChar* U_EXPORT2\nu_strcpy(UChar     *dst, \n    const UChar     *src);\n\n/**\n * Copy a ustring.\n * Copies at most <code>n</code> characters.  The result will be null terminated\n * if the length of <code>src</code> is less than <code>n</code>.\n *\n * @param dst The destination string.\n * @param src The source string (can be NULL/invalid if n<=0).\n * @param n The maximum number of characters to copy; no-op if <=0.\n * @return A pointer to <code>dst</code>.\n * @stable ICU 2.0\n */\nU_STABLE UChar* U_EXPORT2\nu_strncpy(UChar     *dst, \n     const UChar     *src, \n     int32_t     n);\n\n#if !UCONFIG_NO_CONVERSION\n\n/**\n * Copy a byte string encoded in the default codepage to a ustring.\n * Adds a null terminator.\n * Performs a host byte to UChar conversion\n *\n * @param dst The destination string.\n * @param src The source string.\n * @return A pointer to <code>dst</code>.\n * @stable ICU 2.0\n */\nU_STABLE UChar* U_EXPORT2 u_uastrcpy(UChar *dst,\n               const char *src );\n\n/**\n * Copy a byte string encoded in the default codepage to a ustring.\n * Copies at most <code>n</code> characters.  The result will be null terminated\n * if the length of <code>src</code> is less than <code>n</code>.\n * Performs a host byte to UChar conversion\n *\n * @param dst The destination string.\n * @param src The source string.\n * @param n The maximum number of characters to copy.\n * @return A pointer to <code>dst</code>.\n * @stable ICU 2.0\n */\nU_STABLE UChar* U_EXPORT2 u_uastrncpy(UChar *dst,\n            const char *src,\n            int32_t n);\n\n/**\n * Copy ustring to a byte string encoded in the default codepage.\n * Adds a null terminator.\n * Performs a UChar to host byte conversion\n *\n * @param dst The destination string.\n * @param src The source string.\n * @return A pointer to <code>dst</code>.\n * @stable ICU 2.0\n */\nU_STABLE char* U_EXPORT2 u_austrcpy(char *dst,\n            const UChar *src );\n\n/**\n * Copy ustring to a byte string encoded in the default codepage.\n * Copies at most <code>n</code> characters.  The result will be null terminated\n * if the length of <code>src</code> is less than <code>n</code>.\n * Performs a UChar to host byte conversion\n *\n * @param dst The destination string.\n * @param src The source string.\n * @param n The maximum number of characters to copy.\n * @return A pointer to <code>dst</code>.\n * @stable ICU 2.0\n */\nU_STABLE char* U_EXPORT2 u_austrncpy(char *dst,\n            const UChar *src,\n            int32_t n );\n\n#endif\n\n/**\n * Synonym for memcpy(), but with UChars only.\n * @param dest The destination string\n * @param src The source string (can be NULL/invalid if count<=0)\n * @param count The number of characters to copy; no-op if <=0\n * @return A pointer to <code>dest</code>\n * @stable ICU 2.0\n */\nU_STABLE UChar* U_EXPORT2\nu_memcpy(UChar *dest, const UChar *src, int32_t count);\n\n/**\n * Synonym for memmove(), but with UChars only.\n * @param dest The destination string\n * @param src The source string (can be NULL/invalid if count<=0)\n * @param count The number of characters to move; no-op if <=0\n * @return A pointer to <code>dest</code>\n * @stable ICU 2.0\n */\nU_STABLE UChar* U_EXPORT2\nu_memmove(UChar *dest, const UChar *src, int32_t count);\n\n/**\n * Initialize <code>count</code> characters of <code>dest</code> to <code>c</code>.\n *\n * @param dest The destination string.\n * @param c The character to initialize the string.\n * @param count The maximum number of characters to set.\n * @return A pointer to <code>dest</code>.\n * @stable ICU 2.0\n */\nU_STABLE UChar* U_EXPORT2\nu_memset(UChar *dest, UChar c, int32_t count);\n\n/**\n * Compare the first <code>count</code> UChars of each buffer.\n *\n * @param buf1 The first string to compare.\n * @param buf2 The second string to compare.\n * @param count The maximum number of UChars to compare.\n * @return When buf1 < buf2, a negative number is returned.\n *      When buf1 == buf2, 0 is returned.\n *      When buf1 > buf2, a positive number is returned.\n * @stable ICU 2.0\n */\nU_STABLE int32_t U_EXPORT2\nu_memcmp(const UChar *buf1, const UChar *buf2, int32_t count);\n\n/**\n * Compare two Unicode strings in code point order.\n * This is different in UTF-16 from u_memcmp() if supplementary characters are present.\n * For details, see u_strCompare().\n *\n * @param s1 A string to compare.\n * @param s2 A string to compare.\n * @param count The maximum number of characters to compare.\n * @return a negative/zero/positive integer corresponding to whether\n * the first string is less than/equal to/greater than the second one\n * in code point order\n * @stable ICU 2.0\n */\nU_STABLE int32_t U_EXPORT2\nu_memcmpCodePointOrder(const UChar *s1, const UChar *s2, int32_t count);\n\n/**\n * Find the first occurrence of a BMP code point in a string.\n * A surrogate code point is found only if its match in the text is not\n * part of a surrogate pair.\n * A NUL character is found at the string terminator.\n *\n * @param s The string to search (contains <code>count</code> UChars).\n * @param c The BMP code point to find.\n * @param count The length of the string.\n * @return A pointer to the first occurrence of <code>c</code> in <code>s</code>\n *         or <code>NULL</code> if <code>c</code> is not in <code>s</code>.\n * @stable ICU 2.0\n *\n * @see u_strchr\n * @see u_memchr32\n * @see u_strFindFirst\n */\nU_STABLE UChar* U_EXPORT2\nu_memchr(const UChar *s, UChar c, int32_t count);\n\n/**\n * Find the first occurrence of a code point in a string.\n * A surrogate code point is found only if its match in the text is not\n * part of a surrogate pair.\n * A NUL character is found at the string terminator.\n *\n * @param s The string to search (contains <code>count</code> UChars).\n * @param c The code point to find.\n * @param count The length of the string.\n * @return A pointer to the first occurrence of <code>c</code> in <code>s</code>\n *         or <code>NULL</code> if <code>c</code> is not in <code>s</code>.\n * @stable ICU 2.0\n *\n * @see u_strchr32\n * @see u_memchr\n * @see u_strFindFirst\n */\nU_STABLE UChar* U_EXPORT2\nu_memchr32(const UChar *s, UChar32 c, int32_t count);\n\n/**\n * Find the last occurrence of a BMP code point in a string.\n * A surrogate code point is found only if its match in the text is not\n * part of a surrogate pair.\n * A NUL character is found at the string terminator.\n *\n * @param s The string to search (contains <code>count</code> UChars).\n * @param c The BMP code point to find.\n * @param count The length of the string.\n * @return A pointer to the last occurrence of <code>c</code> in <code>s</code>\n *         or <code>NULL</code> if <code>c</code> is not in <code>s</code>.\n * @stable ICU 2.4\n *\n * @see u_strrchr\n * @see u_memrchr32\n * @see u_strFindLast\n */\nU_STABLE UChar* U_EXPORT2\nu_memrchr(const UChar *s, UChar c, int32_t count);\n\n/**\n * Find the last occurrence of a code point in a string.\n * A surrogate code point is found only if its match in the text is not\n * part of a surrogate pair.\n * A NUL character is found at the string terminator.\n *\n * @param s The string to search (contains <code>count</code> UChars).\n * @param c The code point to find.\n * @param count The length of the string.\n * @return A pointer to the last occurrence of <code>c</code> in <code>s</code>\n *         or <code>NULL</code> if <code>c</code> is not in <code>s</code>.\n * @stable ICU 2.4\n *\n * @see u_strrchr32\n * @see u_memrchr\n * @see u_strFindLast\n */\nU_STABLE UChar* U_EXPORT2\nu_memrchr32(const UChar *s, UChar32 c, int32_t count);\n\n/**\n * Unicode String literals in C.\n * We need one macro to declare a variable for the string\n * and to statically preinitialize it if possible,\n * and a second macro to dynamically intialize such a string variable if necessary.\n *\n * The macros are defined for maximum performance.\n * They work only for strings that contain \"invariant characters\", i.e.,\n * only latin letters, digits, and some punctuation.\n * See utypes.h for details.\n *\n * A pair of macros for a single string must be used with the same\n * parameters.\n * The string parameter must be a C string literal.\n * The length of the string, not including the terminating\n * <code>NUL</code>, must be specified as a constant.\n * The U_STRING_DECL macro should be invoked exactly once for one\n * such string variable before it is used.\n *\n * Usage:\n * <pre>\n *    U_STRING_DECL(ustringVar1, \"Quick-Fox 2\", 11);\n *    U_STRING_DECL(ustringVar2, \"jumps 5%\", 8);\n *    static UBool didInit=FALSE;\n * \n *    int32_t function() {\n *        if(!didInit) {\n *            U_STRING_INIT(ustringVar1, \"Quick-Fox 2\", 11);\n *            U_STRING_INIT(ustringVar2, \"jumps 5%\", 8);\n *            didInit=TRUE;\n *        }\n *        return u_strcmp(ustringVar1, ustringVar2);\n *    }\n * </pre>\n * \n * Note that the macros will NOT consistently work if their argument is another <code>#define</code>. \n *  The following will not work on all platforms, don't use it.\n * \n * <pre>\n *     #define GLUCK \"Mr. Gluck\"\n *     U_STRING_DECL(var, GLUCK, 9)\n *     U_STRING_INIT(var, GLUCK, 9)\n * </pre>\n * \n * Instead, use the string literal \"Mr. Gluck\"  as the argument to both macro\n * calls.\n *\n *\n * @stable ICU 2.0\n */\n#if defined(U_DECLARE_UTF16)\n#   define U_STRING_DECL(var, cs, length) static const UChar *var=(const UChar *)U_DECLARE_UTF16(cs)\n    /**@stable ICU 2.0 */\n#   define U_STRING_INIT(var, cs, length)\n#elif U_SIZEOF_WCHAR_T==U_SIZEOF_UCHAR && (U_CHARSET_FAMILY==U_ASCII_FAMILY || (U_SIZEOF_UCHAR == 2 && defined(U_WCHAR_IS_UTF16)))\n#   define U_STRING_DECL(var, cs, length) static const UChar var[(length)+1]=L ## cs\n    /**@stable ICU 2.0 */\n#   define U_STRING_INIT(var, cs, length)\n#elif U_SIZEOF_UCHAR==1 && U_CHARSET_FAMILY==U_ASCII_FAMILY\n#   define U_STRING_DECL(var, cs, length) static const UChar var[(length)+1]=cs\n    /**@stable ICU 2.0 */\n#   define U_STRING_INIT(var, cs, length)\n#else\n#   define U_STRING_DECL(var, cs, length) static UChar var[(length)+1]\n    /**@stable ICU 2.0 */\n#   define U_STRING_INIT(var, cs, length) u_charsToUChars(cs, var, length+1)\n#endif\n\n/**\n * Unescape a string of characters and write the resulting\n * Unicode characters to the destination buffer.  The following escape\n * sequences are recognized:\n *\n * \\\\uhhhh       4 hex digits; h in [0-9A-Fa-f]\n * \\\\Uhhhhhhhh   8 hex digits\n * \\\\xhh         1-2 hex digits\n * \\\\x{h...}     1-8 hex digits\n * \\\\ooo         1-3 octal digits; o in [0-7]\n * \\\\cX          control-X; X is masked with 0x1F\n *\n * as well as the standard ANSI C escapes:\n *\n * \\\\a => U+0007, \\\\b => U+0008, \\\\t => U+0009, \\\\n => U+000A,\n * \\\\v => U+000B, \\\\f => U+000C, \\\\r => U+000D, \\\\e => U+001B,\n * \\\\&quot; => U+0022, \\\\' => U+0027, \\\\? => U+003F, \\\\\\\\ => U+005C\n *\n * Anything else following a backslash is generically escaped.  For\n * example, \"[a\\\\-z]\" returns \"[a-z]\".\n *\n * If an escape sequence is ill-formed, this method returns an empty\n * string.  An example of an ill-formed sequence is \"\\\\u\" followed by\n * fewer than 4 hex digits.\n *\n * The above characters are recognized in the compiler's codepage,\n * that is, they are coded as 'u', '\\\\', etc.  Characters that are\n * not parts of escape sequences are converted using u_charsToUChars().\n *\n * This function is similar to UnicodeString::unescape() but not\n * identical to it.  The latter takes a source UnicodeString, so it\n * does escape recognition but no conversion.\n *\n * @param src a zero-terminated string of invariant characters\n * @param dest pointer to buffer to receive converted and unescaped\n * text and, if there is room, a zero terminator.  May be NULL for\n * preflighting, in which case no UChars will be written, but the\n * return value will still be valid.  On error, an empty string is\n * stored here (if possible).\n * @param destCapacity the number of UChars that may be written at\n * dest.  Ignored if dest == NULL.\n * @return the length of unescaped string.\n * @see u_unescapeAt\n * @see UnicodeString#unescape()\n * @see UnicodeString#unescapeAt()\n * @stable ICU 2.0\n */\nU_STABLE int32_t U_EXPORT2\nu_unescape(const char *src,\n           UChar *dest, int32_t destCapacity);\n\nU_CDECL_BEGIN\n/**\n * Callback function for u_unescapeAt() that returns a character of\n * the source text given an offset and a context pointer.  The context\n * pointer will be whatever is passed into u_unescapeAt().\n *\n * @param offset pointer to the offset that will be passed to u_unescapeAt().\n * @param context an opaque pointer passed directly into u_unescapeAt()\n * @return the character represented by the escape sequence at\n * offset\n * @see u_unescapeAt\n * @stable ICU 2.0\n */\ntypedef UChar (U_CALLCONV *UNESCAPE_CHAR_AT)(int32_t offset, void *context);\nU_CDECL_END\n\n/**\n * Unescape a single sequence. The character at offset-1 is assumed\n * (without checking) to be a backslash.  This method takes a callback\n * pointer to a function that returns the UChar at a given offset.  By\n * varying this callback, ICU functions are able to unescape char*\n * strings, UnicodeString objects, and UFILE pointers.\n *\n * If offset is out of range, or if the escape sequence is ill-formed,\n * (UChar32)0xFFFFFFFF is returned.  See documentation of u_unescape()\n * for a list of recognized sequences.\n *\n * @param charAt callback function that returns a UChar of the source\n * text given an offset and a context pointer.\n * @param offset pointer to the offset that will be passed to charAt.\n * The offset value will be updated upon return to point after the\n * last parsed character of the escape sequence.  On error the offset\n * is unchanged.\n * @param length the number of characters in the source text.  The\n * last character of the source text is considered to be at offset\n * length-1.\n * @param context an opaque pointer passed directly into charAt.\n * @return the character represented by the escape sequence at\n * offset, or (UChar32)0xFFFFFFFF on error.\n * @see u_unescape()\n * @see UnicodeString#unescape()\n * @see UnicodeString#unescapeAt()\n * @stable ICU 2.0\n */\nU_STABLE UChar32 U_EXPORT2\nu_unescapeAt(UNESCAPE_CHAR_AT charAt,\n             int32_t *offset,\n             int32_t length,\n             void *context);\n\n/**\n * Uppercase the characters in a string.\n * Casing is locale-dependent and context-sensitive.\n * The result may be longer or shorter than the original.\n * The source string and the destination buffer are allowed to overlap.\n *\n * @param dest      A buffer for the result string. The result will be zero-terminated if\n *                  the buffer is large enough.\n * @param destCapacity The size of the buffer (number of UChars). If it is 0, then\n *                  dest may be NULL and the function will only return the length of the result\n *                  without writing any of the result string.\n * @param src       The original string\n * @param srcLength The length of the original string. If -1, then src must be zero-terminated.\n * @param locale    The locale to consider, or \"\" for the root locale or NULL for the default locale.\n * @param pErrorCode Must be a valid pointer to an error code value,\n *                  which must not indicate a failure before the function call.\n * @return The length of the result string. It may be greater than destCapacity. In that case,\n *         only some of the result was written to the destination buffer.\n * @stable ICU 2.0\n */\nU_STABLE int32_t U_EXPORT2\nu_strToUpper(UChar *dest, int32_t destCapacity,\n             const UChar *src, int32_t srcLength,\n             const char *locale,\n             UErrorCode *pErrorCode);\n\n/**\n * Lowercase the characters in a string.\n * Casing is locale-dependent and context-sensitive.\n * The result may be longer or shorter than the original.\n * The source string and the destination buffer are allowed to overlap.\n *\n * @param dest      A buffer for the result string. The result will be zero-terminated if\n *                  the buffer is large enough.\n * @param destCapacity The size of the buffer (number of UChars). If it is 0, then\n *                  dest may be NULL and the function will only return the length of the result\n *                  without writing any of the result string.\n * @param src       The original string\n * @param srcLength The length of the original string. If -1, then src must be zero-terminated.\n * @param locale    The locale to consider, or \"\" for the root locale or NULL for the default locale.\n * @param pErrorCode Must be a valid pointer to an error code value,\n *                  which must not indicate a failure before the function call.\n * @return The length of the result string. It may be greater than destCapacity. In that case,\n *         only some of the result was written to the destination buffer.\n * @stable ICU 2.0\n */\nU_STABLE int32_t U_EXPORT2\nu_strToLower(UChar *dest, int32_t destCapacity,\n             const UChar *src, int32_t srcLength,\n             const char *locale,\n             UErrorCode *pErrorCode);\n\n#if !UCONFIG_NO_BREAK_ITERATION\n\n/**\n * Titlecase a string.\n * Casing is locale-dependent and context-sensitive.\n * Titlecasing uses a break iterator to find the first characters of words\n * that are to be titlecased. It titlecases those characters and lowercases\n * all others.\n *\n * The titlecase break iterator can be provided to customize for arbitrary\n * styles, using rules and dictionaries beyond the standard iterators.\n * It may be more efficient to always provide an iterator to avoid\n * opening and closing one for each string.\n * The standard titlecase iterator for the root locale implements the\n * algorithm of Unicode TR 21.\n *\n * This function uses only the setText(), first() and next() methods of the\n * provided break iterator.\n *\n * The result may be longer or shorter than the original.\n * The source string and the destination buffer are allowed to overlap.\n *\n * @param dest      A buffer for the result string. The result will be zero-terminated if\n *                  the buffer is large enough.\n * @param destCapacity The size of the buffer (number of UChars). If it is 0, then\n *                  dest may be NULL and the function will only return the length of the result\n *                  without writing any of the result string.\n * @param src       The original string\n * @param srcLength The length of the original string. If -1, then src must be zero-terminated.\n * @param titleIter A break iterator to find the first characters of words\n *                  that are to be titlecased.\n *                  If none is provided (NULL), then a standard titlecase\n *                  break iterator is opened.\n * @param locale    The locale to consider, or \"\" for the root locale or NULL for the default locale.\n * @param pErrorCode Must be a valid pointer to an error code value,\n *                  which must not indicate a failure before the function call.\n * @return The length of the result string. It may be greater than destCapacity. In that case,\n *         only some of the result was written to the destination buffer.\n * @stable ICU 2.1\n */\nU_STABLE int32_t U_EXPORT2\nu_strToTitle(UChar *dest, int32_t destCapacity,\n             const UChar *src, int32_t srcLength,\n             UBreakIterator *titleIter,\n             const char *locale,\n             UErrorCode *pErrorCode);\n\n#endif\n\n/**\n * Case-folds the characters in a string.\n *\n * Case-folding is locale-independent and not context-sensitive,\n * but there is an option for whether to include or exclude mappings for dotted I\n * and dotless i that are marked with 'T' in CaseFolding.txt.\n *\n * The result may be longer or shorter than the original.\n * The source string and the destination buffer are allowed to overlap.\n *\n * @param dest      A buffer for the result string. The result will be zero-terminated if\n *                  the buffer is large enough.\n * @param destCapacity The size of the buffer (number of UChars). If it is 0, then\n *                  dest may be NULL and the function will only return the length of the result\n *                  without writing any of the result string.\n * @param src       The original string\n * @param srcLength The length of the original string. If -1, then src must be zero-terminated.\n * @param options   Either U_FOLD_CASE_DEFAULT or U_FOLD_CASE_EXCLUDE_SPECIAL_I\n * @param pErrorCode Must be a valid pointer to an error code value,\n *                  which must not indicate a failure before the function call.\n * @return The length of the result string. It may be greater than destCapacity. In that case,\n *         only some of the result was written to the destination buffer.\n * @stable ICU 2.0\n */\nU_STABLE int32_t U_EXPORT2\nu_strFoldCase(UChar *dest, int32_t destCapacity,\n              const UChar *src, int32_t srcLength,\n              uint32_t options,\n              UErrorCode *pErrorCode);\n\n#if defined(U_WCHAR_IS_UTF16) || defined(U_WCHAR_IS_UTF32) || !UCONFIG_NO_CONVERSION\n/**\n * Convert a UTF-16 string to a wchar_t string.\n * If it is known at compile time that wchar_t strings are in UTF-16 or UTF-32, then\n * this function simply calls the fast, dedicated function for that.\n * Otherwise, two conversions UTF-16 -> default charset -> wchar_t* are performed.\n *\n * @param dest          A buffer for the result string. The result will be zero-terminated if\n *                      the buffer is large enough.\n * @param destCapacity  The size of the buffer (number of wchar_t's). If it is 0, then\n *                      dest may be NULL and the function will only return the length of the \n *                      result without writing any of the result string (pre-flighting).\n * @param pDestLength   A pointer to receive the number of units written to the destination. If \n *                      pDestLength!=NULL then *pDestLength is always set to the \n *                      number of output units corresponding to the transformation of \n *                      all the input units, even in case of a buffer overflow.\n * @param src           The original source string\n * @param srcLength     The length of the original string. If -1, then src must be zero-terminated.\n * @param pErrorCode    Must be a valid pointer to an error code value,\n *                      which must not indicate a failure before the function call.\n * @return The pointer to destination buffer.\n * @stable ICU 2.0\n */\nU_STABLE wchar_t* U_EXPORT2\nu_strToWCS(wchar_t *dest, \n           int32_t destCapacity,\n           int32_t *pDestLength,\n           const UChar *src, \n           int32_t srcLength,\n           UErrorCode *pErrorCode);\n/**\n * Convert a wchar_t string to UTF-16.\n * If it is known at compile time that wchar_t strings are in UTF-16 or UTF-32, then\n * this function simply calls the fast, dedicated function for that.\n * Otherwise, two conversions wchar_t* -> default charset -> UTF-16 are performed.\n *\n * @param dest          A buffer for the result string. The result will be zero-terminated if\n *                      the buffer is large enough.\n * @param destCapacity  The size of the buffer (number of UChars). If it is 0, then\n *                      dest may be NULL and the function will only return the length of the \n *                      result without writing any of the result string (pre-flighting).\n * @param pDestLength   A pointer to receive the number of units written to the destination. If \n *                      pDestLength!=NULL then *pDestLength is always set to the \n *                      number of output units corresponding to the transformation of \n *                      all the input units, even in case of a buffer overflow.\n * @param src           The original source string\n * @param srcLength     The length of the original string. If -1, then src must be zero-terminated.\n * @param pErrorCode    Must be a valid pointer to an error code value,\n *                      which must not indicate a failure before the function call.\n * @return The pointer to destination buffer.\n * @stable ICU 2.0\n */\nU_STABLE UChar* U_EXPORT2\nu_strFromWCS(UChar   *dest,\n             int32_t destCapacity, \n             int32_t *pDestLength,\n             const wchar_t *src,\n             int32_t srcLength,\n             UErrorCode *pErrorCode);\n#endif /* defined(U_WCHAR_IS_UTF16) || defined(U_WCHAR_IS_UTF32) || !UCONFIG_NO_CONVERSION */\n\n/**\n * Convert a UTF-16 string to UTF-8.\n * If the input string is not well-formed, then the U_INVALID_CHAR_FOUND error code is set.\n *\n * @param dest          A buffer for the result string. The result will be zero-terminated if\n *                      the buffer is large enough.\n * @param destCapacity  The size of the buffer (number of chars). If it is 0, then\n *                      dest may be NULL and the function will only return the length of the \n *                      result without writing any of the result string (pre-flighting).\n * @param pDestLength   A pointer to receive the number of units written to the destination. If \n *                      pDestLength!=NULL then *pDestLength is always set to the \n *                      number of output units corresponding to the transformation of \n *                      all the input units, even in case of a buffer overflow.\n * @param src           The original source string\n * @param srcLength     The length of the original string. If -1, then src must be zero-terminated.\n * @param pErrorCode    Must be a valid pointer to an error code value,\n *                      which must not indicate a failure before the function call.\n * @return The pointer to destination buffer.\n * @stable ICU 2.0\n * @see u_strToUTF8WithSub\n * @see u_strFromUTF8\n */\nU_STABLE char* U_EXPORT2 \nu_strToUTF8(char *dest,           \n            int32_t destCapacity,\n            int32_t *pDestLength,\n            const UChar *src, \n            int32_t srcLength,\n            UErrorCode *pErrorCode);\n\n/**\n * Convert a UTF-8 string to UTF-16.\n * If the input string is not well-formed, then the U_INVALID_CHAR_FOUND error code is set.\n *\n * @param dest          A buffer for the result string. The result will be zero-terminated if\n *                      the buffer is large enough.\n * @param destCapacity  The size of the buffer (number of UChars). If it is 0, then\n *                      dest may be NULL and the function will only return the length of the \n *                      result without writing any of the result string (pre-flighting).\n * @param pDestLength   A pointer to receive the number of units written to the destination. If \n *                      pDestLength!=NULL then *pDestLength is always set to the \n *                      number of output units corresponding to the transformation of \n *                      all the input units, even in case of a buffer overflow.\n * @param src           The original source string\n * @param srcLength     The length of the original string. If -1, then src must be zero-terminated.\n * @param pErrorCode    Must be a valid pointer to an error code value,\n *                      which must not indicate a failure before the function call.\n * @return The pointer to destination buffer.\n * @stable ICU 2.0\n * @see u_strFromUTF8WithSub\n * @see u_strFromUTF8Lenient\n */\nU_STABLE UChar* U_EXPORT2\nu_strFromUTF8(UChar *dest,             \n              int32_t destCapacity,\n              int32_t *pDestLength,\n              const char *src, \n              int32_t srcLength,\n              UErrorCode *pErrorCode);\n\n/**\n * Convert a UTF-16 string to UTF-8.\n * If the input string is not well-formed, then the U_INVALID_CHAR_FOUND error code is set.\n *\n * Same as u_strToUTF8() except for the additional subchar which is output for\n * illegal input sequences, instead of stopping with the U_INVALID_CHAR_FOUND error code.\n * With subchar==U_SENTINEL, this function behaves exactly like u_strToUTF8().\n *\n * @param dest          A buffer for the result string. The result will be zero-terminated if\n *                      the buffer is large enough.\n * @param destCapacity  The size of the buffer (number of chars). If it is 0, then\n *                      dest may be NULL and the function will only return the length of the \n *                      result without writing any of the result string (pre-flighting).\n * @param pDestLength   A pointer to receive the number of units written to the destination. If \n *                      pDestLength!=NULL then *pDestLength is always set to the \n *                      number of output units corresponding to the transformation of \n *                      all the input units, even in case of a buffer overflow.\n * @param src           The original source string\n * @param srcLength     The length of the original string. If -1, then src must be zero-terminated.\n * @param subchar       The substitution character to use in place of an illegal input sequence,\n *                      or U_SENTINEL if the function is to return with U_INVALID_CHAR_FOUND instead.\n *                      A substitution character can be any valid Unicode code point (up to U+10FFFF)\n *                      except for surrogate code points (U+D800..U+DFFF).\n *                      The recommended value is U+FFFD \"REPLACEMENT CHARACTER\".\n * @param pNumSubstitutions Output parameter receiving the number of substitutions if subchar>=0.\n *                      Set to 0 if no substitutions occur or subchar<0.\n *                      pNumSubstitutions can be NULL.\n * @param pErrorCode    Pointer to a standard ICU error code. Its input value must\n *                      pass the U_SUCCESS() test, or else the function returns\n *                      immediately. Check for U_FAILURE() on output or use with\n *                      function chaining. (See User Guide for details.)\n * @return The pointer to destination buffer.\n * @see u_strToUTF8\n * @see u_strFromUTF8WithSub\n * @stable ICU 3.6\n */\nU_STABLE char* U_EXPORT2\nu_strToUTF8WithSub(char *dest,\n            int32_t destCapacity,\n            int32_t *pDestLength,\n            const UChar *src,\n            int32_t srcLength,\n            UChar32 subchar, int32_t *pNumSubstitutions,\n            UErrorCode *pErrorCode);\n\n/**\n * Convert a UTF-8 string to UTF-16.\n * If the input string is not well-formed, then the U_INVALID_CHAR_FOUND error code is set.\n *\n * Same as u_strFromUTF8() except for the additional subchar which is output for\n * illegal input sequences, instead of stopping with the U_INVALID_CHAR_FOUND error code.\n * With subchar==U_SENTINEL, this function behaves exactly like u_strFromUTF8().\n *\n * @param dest          A buffer for the result string. The result will be zero-terminated if\n *                      the buffer is large enough.\n * @param destCapacity  The size of the buffer (number of UChars). If it is 0, then\n *                      dest may be NULL and the function will only return the length of the \n *                      result without writing any of the result string (pre-flighting).\n * @param pDestLength   A pointer to receive the number of units written to the destination. If \n *                      pDestLength!=NULL then *pDestLength is always set to the \n *                      number of output units corresponding to the transformation of \n *                      all the input units, even in case of a buffer overflow.\n * @param src           The original source string\n * @param srcLength     The length of the original string. If -1, then src must be zero-terminated.\n * @param subchar       The substitution character to use in place of an illegal input sequence,\n *                      or U_SENTINEL if the function is to return with U_INVALID_CHAR_FOUND instead.\n *                      A substitution character can be any valid Unicode code point (up to U+10FFFF)\n *                      except for surrogate code points (U+D800..U+DFFF).\n *                      The recommended value is U+FFFD \"REPLACEMENT CHARACTER\".\n * @param pNumSubstitutions Output parameter receiving the number of substitutions if subchar>=0.\n *                      Set to 0 if no substitutions occur or subchar<0.\n *                      pNumSubstitutions can be NULL.\n * @param pErrorCode    Pointer to a standard ICU error code. Its input value must\n *                      pass the U_SUCCESS() test, or else the function returns\n *                      immediately. Check for U_FAILURE() on output or use with\n *                      function chaining. (See User Guide for details.)\n * @return The pointer to destination buffer.\n * @see u_strFromUTF8\n * @see u_strFromUTF8Lenient\n * @see u_strToUTF8WithSub\n * @stable ICU 3.6\n */\nU_STABLE UChar* U_EXPORT2\nu_strFromUTF8WithSub(UChar *dest,\n              int32_t destCapacity,\n              int32_t *pDestLength,\n              const char *src,\n              int32_t srcLength,\n              UChar32 subchar, int32_t *pNumSubstitutions,\n              UErrorCode *pErrorCode);\n\n/**\n * Convert a UTF-8 string to UTF-16.\n *\n * Same as u_strFromUTF8() except that this function is designed to be very fast,\n * which it achieves by being lenient about malformed UTF-8 sequences.\n * This function is intended for use in environments where UTF-8 text is\n * expected to be well-formed.\n *\n * Its semantics are:\n * - Well-formed UTF-8 text is correctly converted to well-formed UTF-16 text.\n * - The function will not read beyond the input string, nor write beyond\n *   the destCapacity.\n * - Malformed UTF-8 results in \"garbage\" 16-bit Unicode strings which may not\n *   be well-formed UTF-16.\n *   The function will resynchronize to valid code point boundaries\n *   within a small number of code points after an illegal sequence.\n * - Non-shortest forms are not detected and will result in \"spoofing\" output.\n *\n * For further performance improvement, if srcLength is given (>=0),\n * then it must be destCapacity>=srcLength.\n *\n * There is no inverse u_strToUTF8Lenient() function because there is practically\n * no performance gain from not checking that a UTF-16 string is well-formed.\n *\n * @param dest          A buffer for the result string. The result will be zero-terminated if\n *                      the buffer is large enough.\n * @param destCapacity  The size of the buffer (number of UChars). If it is 0, then\n *                      dest may be NULL and the function will only return the length of the \n *                      result without writing any of the result string (pre-flighting).\n *                      Unlike for other ICU functions, if srcLength>=0 then it\n *                      must be destCapacity>=srcLength.\n * @param pDestLength   A pointer to receive the number of units written to the destination. If \n *                      pDestLength!=NULL then *pDestLength is always set to the \n *                      number of output units corresponding to the transformation of \n *                      all the input units, even in case of a buffer overflow.\n *                      Unlike for other ICU functions, if srcLength>=0 but\n *                      destCapacity<srcLength, then *pDestLength will be set to srcLength\n *                      (and U_BUFFER_OVERFLOW_ERROR will be set)\n *                      regardless of the actual result length.\n * @param src           The original source string\n * @param srcLength     The length of the original string. If -1, then src must be zero-terminated.\n * @param pErrorCode    Pointer to a standard ICU error code. Its input value must\n *                      pass the U_SUCCESS() test, or else the function returns\n *                      immediately. Check for U_FAILURE() on output or use with\n *                      function chaining. (See User Guide for details.)\n * @return The pointer to destination buffer.\n * @see u_strFromUTF8\n * @see u_strFromUTF8WithSub\n * @see u_strToUTF8WithSub\n * @stable ICU 3.6\n */\nU_STABLE UChar * U_EXPORT2\nu_strFromUTF8Lenient(UChar *dest,\n                     int32_t destCapacity,\n                     int32_t *pDestLength,\n                     const char *src,\n                     int32_t srcLength,\n                     UErrorCode *pErrorCode);\n\n/**\n * Convert a UTF-16 string to UTF-32.\n * If the input string is not well-formed, then the U_INVALID_CHAR_FOUND error code is set.\n *\n * @param dest          A buffer for the result string. The result will be zero-terminated if\n *                      the buffer is large enough.\n * @param destCapacity  The size of the buffer (number of UChar32s). If it is 0, then\n *                      dest may be NULL and the function will only return the length of the \n *                      result without writing any of the result string (pre-flighting).\n * @param pDestLength   A pointer to receive the number of units written to the destination. If \n *                      pDestLength!=NULL then *pDestLength is always set to the \n *                      number of output units corresponding to the transformation of \n *                      all the input units, even in case of a buffer overflow.\n * @param src           The original source string\n * @param srcLength     The length of the original string. If -1, then src must be zero-terminated.\n * @param pErrorCode    Must be a valid pointer to an error code value,\n *                      which must not indicate a failure before the function call.\n * @return The pointer to destination buffer.\n * @see u_strToUTF32WithSub\n * @see u_strFromUTF32\n * @stable ICU 2.0\n */\nU_STABLE UChar32* U_EXPORT2 \nu_strToUTF32(UChar32 *dest, \n             int32_t  destCapacity,\n             int32_t  *pDestLength,\n             const UChar *src, \n             int32_t  srcLength,\n             UErrorCode *pErrorCode);\n\n/**\n * Convert a UTF-32 string to UTF-16.\n * If the input string is not well-formed, then the U_INVALID_CHAR_FOUND error code is set.\n *\n * @param dest          A buffer for the result string. The result will be zero-terminated if\n *                      the buffer is large enough.\n * @param destCapacity  The size of the buffer (number of UChars). If it is 0, then\n *                      dest may be NULL and the function will only return the length of the \n *                      result without writing any of the result string (pre-flighting).\n * @param pDestLength   A pointer to receive the number of units written to the destination. If \n *                      pDestLength!=NULL then *pDestLength is always set to the \n *                      number of output units corresponding to the transformation of \n *                      all the input units, even in case of a buffer overflow.\n * @param src           The original source string\n * @param srcLength     The length of the original string. If -1, then src must be zero-terminated.\n * @param pErrorCode    Must be a valid pointer to an error code value,\n *                      which must not indicate a failure before the function call.\n * @return The pointer to destination buffer.\n * @see u_strFromUTF32WithSub\n * @see u_strToUTF32\n * @stable ICU 2.0\n */\nU_STABLE UChar* U_EXPORT2 \nu_strFromUTF32(UChar   *dest,\n               int32_t destCapacity, \n               int32_t *pDestLength,\n               const UChar32 *src,\n               int32_t srcLength,\n               UErrorCode *pErrorCode);\n\n/**\n * Convert a UTF-16 string to UTF-32.\n * If the input string is not well-formed, then the U_INVALID_CHAR_FOUND error code is set.\n *\n * Same as u_strToUTF32() except for the additional subchar which is output for\n * illegal input sequences, instead of stopping with the U_INVALID_CHAR_FOUND error code.\n * With subchar==U_SENTINEL, this function behaves exactly like u_strToUTF32().\n *\n * @param dest          A buffer for the result string. The result will be zero-terminated if\n *                      the buffer is large enough.\n * @param destCapacity  The size of the buffer (number of UChar32s). If it is 0, then\n *                      dest may be NULL and the function will only return the length of the\n *                      result without writing any of the result string (pre-flighting).\n * @param pDestLength   A pointer to receive the number of units written to the destination. If\n *                      pDestLength!=NULL then *pDestLength is always set to the\n *                      number of output units corresponding to the transformation of\n *                      all the input units, even in case of a buffer overflow.\n * @param src           The original source string\n * @param srcLength     The length of the original string. If -1, then src must be zero-terminated.\n * @param subchar       The substitution character to use in place of an illegal input sequence,\n *                      or U_SENTINEL if the function is to return with U_INVALID_CHAR_FOUND instead.\n *                      A substitution character can be any valid Unicode code point (up to U+10FFFF)\n *                      except for surrogate code points (U+D800..U+DFFF).\n *                      The recommended value is U+FFFD \"REPLACEMENT CHARACTER\".\n * @param pNumSubstitutions Output parameter receiving the number of substitutions if subchar>=0.\n *                      Set to 0 if no substitutions occur or subchar<0.\n *                      pNumSubstitutions can be NULL.\n * @param pErrorCode    Pointer to a standard ICU error code. Its input value must\n *                      pass the U_SUCCESS() test, or else the function returns\n *                      immediately. Check for U_FAILURE() on output or use with\n *                      function chaining. (See User Guide for details.)\n * @return The pointer to destination buffer.\n * @see u_strToUTF32\n * @see u_strFromUTF32WithSub\n * @stable ICU 4.2\n */\nU_STABLE UChar32* U_EXPORT2\nu_strToUTF32WithSub(UChar32 *dest,\n             int32_t destCapacity,\n             int32_t *pDestLength,\n             const UChar *src,\n             int32_t srcLength,\n             UChar32 subchar, int32_t *pNumSubstitutions,\n             UErrorCode *pErrorCode);\n\n/**\n * Convert a UTF-32 string to UTF-16.\n * If the input string is not well-formed, then the U_INVALID_CHAR_FOUND error code is set.\n *\n * Same as u_strFromUTF32() except for the additional subchar which is output for\n * illegal input sequences, instead of stopping with the U_INVALID_CHAR_FOUND error code.\n * With subchar==U_SENTINEL, this function behaves exactly like u_strFromUTF32().\n *\n * @param dest          A buffer for the result string. The result will be zero-terminated if\n *                      the buffer is large enough.\n * @param destCapacity  The size of the buffer (number of UChars). If it is 0, then\n *                      dest may be NULL and the function will only return the length of the\n *                      result without writing any of the result string (pre-flighting).\n * @param pDestLength   A pointer to receive the number of units written to the destination. If\n *                      pDestLength!=NULL then *pDestLength is always set to the\n *                      number of output units corresponding to the transformation of\n *                      all the input units, even in case of a buffer overflow.\n * @param src           The original source string\n * @param srcLength     The length of the original string. If -1, then src must be zero-terminated.\n * @param subchar       The substitution character to use in place of an illegal input sequence,\n *                      or U_SENTINEL if the function is to return with U_INVALID_CHAR_FOUND instead.\n *                      A substitution character can be any valid Unicode code point (up to U+10FFFF)\n *                      except for surrogate code points (U+D800..U+DFFF).\n *                      The recommended value is U+FFFD \"REPLACEMENT CHARACTER\".\n * @param pNumSubstitutions Output parameter receiving the number of substitutions if subchar>=0.\n *                      Set to 0 if no substitutions occur or subchar<0.\n *                      pNumSubstitutions can be NULL.\n * @param pErrorCode    Pointer to a standard ICU error code. Its input value must\n *                      pass the U_SUCCESS() test, or else the function returns\n *                      immediately. Check for U_FAILURE() on output or use with\n *                      function chaining. (See User Guide for details.)\n * @return The pointer to destination buffer.\n * @see u_strFromUTF32\n * @see u_strToUTF32WithSub\n * @stable ICU 4.2\n */\nU_STABLE UChar* U_EXPORT2\nu_strFromUTF32WithSub(UChar *dest,\n               int32_t destCapacity,\n               int32_t *pDestLength,\n               const UChar32 *src,\n               int32_t srcLength,\n               UChar32 subchar, int32_t *pNumSubstitutions,\n               UErrorCode *pErrorCode);\n\n/**\n * Convert a 16-bit Unicode string to Java Modified UTF-8.\n * See http://java.sun.com/javase/6/docs/api/java/io/DataInput.html#modified-utf-8\n *\n * This function behaves according to the documentation for Java DataOutput.writeUTF()\n * except that it does not encode the output length in the destination buffer\n * and does not have an output length restriction.\n * See http://java.sun.com/javase/6/docs/api/java/io/DataOutput.html#writeUTF(java.lang.String)\n *\n * The input string need not be well-formed UTF-16.\n * (Therefore there is no subchar parameter.)\n *\n * @param dest          A buffer for the result string. The result will be zero-terminated if\n *                      the buffer is large enough.\n * @param destCapacity  The size of the buffer (number of chars). If it is 0, then\n *                      dest may be NULL and the function will only return the length of the \n *                      result without writing any of the result string (pre-flighting).\n * @param pDestLength   A pointer to receive the number of units written to the destination. If \n *                      pDestLength!=NULL then *pDestLength is always set to the \n *                      number of output units corresponding to the transformation of \n *                      all the input units, even in case of a buffer overflow.\n * @param src           The original source string\n * @param srcLength     The length of the original string. If -1, then src must be zero-terminated.\n * @param pErrorCode    Pointer to a standard ICU error code. Its input value must\n *                      pass the U_SUCCESS() test, or else the function returns\n *                      immediately. Check for U_FAILURE() on output or use with\n *                      function chaining. (See User Guide for details.)\n * @return The pointer to destination buffer.\n * @stable ICU 4.4\n * @see u_strToUTF8WithSub\n * @see u_strFromJavaModifiedUTF8WithSub\n */\nU_STABLE char* U_EXPORT2 \nu_strToJavaModifiedUTF8(\n        char *dest,\n        int32_t destCapacity,\n        int32_t *pDestLength,\n        const UChar *src, \n        int32_t srcLength,\n        UErrorCode *pErrorCode);\n\n/**\n * Convert a Java Modified UTF-8 string to a 16-bit Unicode string.\n * If the input string is not well-formed, then the U_INVALID_CHAR_FOUND error code is set.\n *\n * This function behaves according to the documentation for Java DataInput.readUTF()\n * except that it takes a length parameter rather than\n * interpreting the first two input bytes as the length.\n * See http://java.sun.com/javase/6/docs/api/java/io/DataInput.html#readUTF()\n *\n * The output string may not be well-formed UTF-16.\n *\n * @param dest          A buffer for the result string. The result will be zero-terminated if\n *                      the buffer is large enough.\n * @param destCapacity  The size of the buffer (number of UChars). If it is 0, then\n *                      dest may be NULL and the function will only return the length of the \n *                      result without writing any of the result string (pre-flighting).\n * @param pDestLength   A pointer to receive the number of units written to the destination. If \n *                      pDestLength!=NULL then *pDestLength is always set to the \n *                      number of output units corresponding to the transformation of \n *                      all the input units, even in case of a buffer overflow.\n * @param src           The original source string\n * @param srcLength     The length of the original string. If -1, then src must be zero-terminated.\n * @param subchar       The substitution character to use in place of an illegal input sequence,\n *                      or U_SENTINEL if the function is to return with U_INVALID_CHAR_FOUND instead.\n *                      A substitution character can be any valid Unicode code point (up to U+10FFFF)\n *                      except for surrogate code points (U+D800..U+DFFF).\n *                      The recommended value is U+FFFD \"REPLACEMENT CHARACTER\".\n * @param pNumSubstitutions Output parameter receiving the number of substitutions if subchar>=0.\n *                      Set to 0 if no substitutions occur or subchar<0.\n *                      pNumSubstitutions can be NULL.\n * @param pErrorCode    Pointer to a standard ICU error code. Its input value must\n *                      pass the U_SUCCESS() test, or else the function returns\n *                      immediately. Check for U_FAILURE() on output or use with\n *                      function chaining. (See User Guide for details.)\n * @return The pointer to destination buffer.\n * @see u_strFromUTF8WithSub\n * @see u_strFromUTF8Lenient\n * @see u_strToJavaModifiedUTF8\n * @stable ICU 4.4\n */\nU_STABLE UChar* U_EXPORT2\nu_strFromJavaModifiedUTF8WithSub(\n        UChar *dest,\n        int32_t destCapacity,\n        int32_t *pDestLength,\n        const char *src,\n        int32_t srcLength,\n        UChar32 subchar, int32_t *pNumSubstitutions,\n        UErrorCode *pErrorCode);\n\n#endif\n"
  },
  {
    "path": "deprecated/android/addons/icucompat/unicode/ustringtrie.h",
    "content": "/*\n*******************************************************************************\n*   Copyright (C) 2010-2012, International Business Machines\n*   Corporation and others.  All Rights Reserved.\n*******************************************************************************\n*   file name:  udicttrie.h\n*   encoding:   US-ASCII\n*   tab size:   8 (not used)\n*   indentation:4\n*\n*   created on: 2010dec17\n*   created by: Markus W. Scherer\n*/\n\n#ifndef __USTRINGTRIE_H__\n#define __USTRINGTRIE_H__\n\n/**\n * \\file\n * \\brief C API: Helper definitions for dictionary trie APIs.\n */\n\n#include \"unicode/utypes.h\"\n\n\n/**\n * Return values for BytesTrie::next(), UCharsTrie::next() and similar methods.\n * @see USTRINGTRIE_MATCHES\n * @see USTRINGTRIE_HAS_VALUE\n * @see USTRINGTRIE_HAS_NEXT\n * @stable ICU 4.8\n */\nenum UStringTrieResult {\n    /**\n     * The input unit(s) did not continue a matching string.\n     * Once current()/next() return USTRINGTRIE_NO_MATCH,\n     * all further calls to current()/next() will also return USTRINGTRIE_NO_MATCH,\n     * until the trie is reset to its original state or to a saved state.\n     * @stable ICU 4.8\n     */\n    USTRINGTRIE_NO_MATCH,\n    /**\n     * The input unit(s) continued a matching string\n     * but there is no value for the string so far.\n     * (It is a prefix of a longer string.)\n     * @stable ICU 4.8\n     */\n    USTRINGTRIE_NO_VALUE,\n    /**\n     * The input unit(s) continued a matching string\n     * and there is a value for the string so far.\n     * This value will be returned by getValue().\n     * No further input byte/unit can continue a matching string.\n     * @stable ICU 4.8\n     */\n    USTRINGTRIE_FINAL_VALUE,\n    /**\n     * The input unit(s) continued a matching string\n     * and there is a value for the string so far.\n     * This value will be returned by getValue().\n     * Another input byte/unit can continue a matching string.\n     * @stable ICU 4.8\n     */\n    USTRINGTRIE_INTERMEDIATE_VALUE\n};\n\n/**\n * Same as (result!=USTRINGTRIE_NO_MATCH).\n * @param result A result from BytesTrie::first(), UCharsTrie::next() etc.\n * @return true if the input bytes/units so far are part of a matching string/byte sequence.\n * @stable ICU 4.8\n */\n#define USTRINGTRIE_MATCHES(result) ((result)!=USTRINGTRIE_NO_MATCH)\n\n/**\n * Equivalent to (result==USTRINGTRIE_INTERMEDIATE_VALUE || result==USTRINGTRIE_FINAL_VALUE) but\n * this macro evaluates result exactly once.\n * @param result A result from BytesTrie::first(), UCharsTrie::next() etc.\n * @return true if there is a value for the input bytes/units so far.\n * @see BytesTrie::getValue\n * @see UCharsTrie::getValue\n * @stable ICU 4.8\n */\n#define USTRINGTRIE_HAS_VALUE(result) ((result)>=USTRINGTRIE_FINAL_VALUE)\n\n/**\n * Equivalent to (result==USTRINGTRIE_NO_VALUE || result==USTRINGTRIE_INTERMEDIATE_VALUE) but\n * this macro evaluates result exactly once.\n * @param result A result from BytesTrie::first(), UCharsTrie::next() etc.\n * @return true if another input byte/unit can continue a matching string.\n * @stable ICU 4.8\n */\n#define USTRINGTRIE_HAS_NEXT(result) ((result)&1)\n\n#endif  /* __USTRINGTRIE_H__ */\n"
  },
  {
    "path": "deprecated/android/addons/icucompat/unicode/utext.h",
    "content": "/*\n*******************************************************************************\n*\n*   Copyright (C) 2004-2012, International Business Machines\n*   Corporation and others.  All Rights Reserved.\n*\n*******************************************************************************\n*   file name:  utext.h\n*   encoding:   US-ASCII\n*   tab size:   8 (not used)\n*   indentation:4\n*\n*   created on: 2004oct06\n*   created by: Markus W. Scherer\n*/\n\n#ifndef __UTEXT_H__\n#define __UTEXT_H__\n\n/**\n * \\file\n * \\brief C API: Abstract Unicode Text API\n *\n * The Text Access API provides a means to allow text that is stored in alternative\n * formats to work with ICU services.  ICU normally operates on text that is\n * stored in UTF-16 format, in (UChar *) arrays for the C APIs or as type\n * UnicodeString for C++ APIs.\n *\n * ICU Text Access allows other formats, such as UTF-8 or non-contiguous\n * UTF-16 strings, to be placed in a UText wrapper and then passed to ICU services.\n *\n * There are three general classes of usage for UText:\n *\n *     Application Level Use.  This is the simplest usage - applications would\n *     use one of the utext_open() functions on their input text, and pass\n *     the resulting UText to the desired ICU service.\n *\n *     Second is usage in ICU Services, such as break iteration, that will need to\n *     operate on input presented to them as a UText.  These implementations\n *     will need to use the iteration and related UText functions to gain\n *     access to the actual text.\n *\n *     The third class of UText users are \"text providers.\"  These are the\n *     UText implementations for the various text storage formats.  An application\n *     or system with a unique text storage format can implement a set of\n *     UText provider functions for that format, which will then allow\n *     ICU services to operate on that format.\n *\n *\n * <em>Iterating over text</em>\n *\n * Here is sample code for a forward iteration over the contents of a UText\n *\n * \\code\n *    UChar32  c;\n *    UText    *ut = whatever();\n *\n *    for (c=utext_next32From(ut, 0); c>=0; c=utext_next32(ut)) {\n *       // do whatever with the codepoint c here.\n *    }\n * \\endcode\n *\n * And here is similar code to iterate in the reverse direction, from the end\n * of the text towards the beginning.\n *\n * \\code\n *    UChar32  c;\n *    UText    *ut = whatever();\n *    int      textLength = utext_nativeLength(ut);\n *    for (c=utext_previous32From(ut, textLength); c>=0; c=utext_previous32(ut)) {\n *       // do whatever with the codepoint c here.\n *    }\n * \\endcode\n *\n * <em>Characters and Indexing</em>\n *\n * Indexing into text by UText functions is nearly always in terms of the native\n * indexing of the underlying text storage.  The storage format could be UTF-8\n * or UTF-32, for example.  When coding to the UText access API, no assumptions\n * can be made regarding the size of characters, or how far an index\n * may move when iterating between characters.\n *\n * All indices supplied to UText functions are pinned to the length of the\n * text.  An out-of-bounds index is not considered to be an error, but is\n * adjusted to be in the range  0 <= index <= length of input text.\n *\n *\n * When an index position is returned from a UText function, it will be\n * a native index to the underlying text.  In the case of multi-unit characters,\n * it will  always refer to the first position of the character,\n * never to the interior.  This is essentially the same thing as saying that\n * a returned index will always point to a boundary between characters.\n *\n * When a native index is supplied to a UText function, all indices that\n * refer to any part of a multi-unit character representation are considered\n * to be equivalent.  In the case of multi-unit characters, an incoming index\n * will be logically normalized to refer to the start of the character.\n * \n * It is possible to test whether a native index is on a code point boundary\n * by doing a utext_setNativeIndex() followed by a utext_getNativeIndex().\n * If the index is returned unchanged, it was on a code point boundary.  If\n * an adjusted index is returned, the original index referred to the\n * interior of a character.\n *\n * <em>Conventions for calling UText functions</em>\n *\n * Most UText access functions have as their first parameter a (UText *) pointer,\n * which specifies the UText to be used.  Unless otherwise noted, the\n * pointer must refer to a valid, open UText.  Attempting to\n * use a closed UText or passing a NULL pointer is a programming error and\n * will produce undefined results or NULL pointer exceptions.\n * \n * The UText_Open family of functions can either open an existing (closed)\n * UText, or heap allocate a new UText.  Here is sample code for creating\n * a stack-allocated UText.\n *\n * \\code\n *    char     *s = whatever();  // A utf-8 string \n *    U_ErrorCode status = U_ZERO_ERROR;\n *    UText    ut = UTEXT_INITIALIZER;\n *    utext_openUTF8(ut, s, -1, &status);\n *    if (U_FAILURE(status)) {\n *        // error handling\n *    } else {\n *        // work with the UText\n *    }\n * \\endcode\n *\n * Any existing UText passed to an open function _must_ have been initialized, \n * either by the UTEXT_INITIALIZER, or by having been originally heap-allocated\n * by an open function.  Passing NULL will cause the open function to\n * heap-allocate and fully initialize a new UText.\n *\n */\n\n\n\n#include \"unicode/utypes.h\"\n#include \"unicode/uchar.h\"\n#if U_SHOW_CPLUSPLUS_API\n#include \"unicode/localpointer.h\"\n#include \"unicode/rep.h\"\n#include \"unicode/unistr.h\"\n#include \"unicode/chariter.h\"\n#endif\n\n\nU_CDECL_BEGIN\n\nstruct UText;\ntypedef struct UText UText; /**< C typedef for struct UText. @stable ICU 3.6 */\n\n\n/***************************************************************************************\n *\n *   C Functions for creating UText wrappers around various kinds of text strings.\n *\n ****************************************************************************************/\n\n\n/**\n  * Close function for UText instances.\n  * Cleans up, releases any resources being held by an open UText.\n  * <p>\n  *   If the UText was originally allocated by one of the utext_open functions,\n  *   the storage associated with the utext will also be freed.\n  *   If the UText storage originated with the application, as it would with\n  *   a local or static instance, the storage will not be deleted.\n  *\n  *   An open UText can be reset to refer to new string by using one of the utext_open()\n  *   functions without first closing the UText.  \n  *\n  * @param ut  The UText to be closed.\n  * @return    NULL if the UText struct was deleted by the close.  If the UText struct\n  *            was originally provided by the caller to the open function, it is\n  *            returned by this function, and may be safely used again in\n  *            a subsequent utext_open.\n  *\n  * @stable ICU 3.4\n  */\nU_STABLE UText * U_EXPORT2\nutext_close(UText *ut);\n\n#if U_SHOW_CPLUSPLUS_API\n\nU_NAMESPACE_BEGIN\n\n/**\n * \\class LocalUTextPointer\n * \"Smart pointer\" class, closes a UText via utext_close().\n * For most methods see the LocalPointerBase base class.\n *\n * @see LocalPointerBase\n * @see LocalPointer\n * @stable ICU 4.4\n */\nU_DEFINE_LOCAL_OPEN_POINTER(LocalUTextPointer, UText, utext_close);\n\nU_NAMESPACE_END\n\n#endif\n\n/**\n * Open a read-only UText implementation for UTF-8 strings.\n * \n * \\htmlonly\n * Any invalid UTF-8 in the input will be handled in this way:\n * a sequence of bytes that has the form of a truncated, but otherwise valid,\n * UTF-8 sequence will be replaced by a single unicode replacement character, \\uFFFD. \n * Any other illegal bytes will each be replaced by a \\uFFFD.\n * \\endhtmlonly\n * \n * @param ut     Pointer to a UText struct.  If NULL, a new UText will be created.\n *               If non-NULL, must refer to an initialized UText struct, which will then\n *               be reset to reference the specified UTF-8 string.\n * @param s      A UTF-8 string.  Must not be NULL.\n * @param length The length of the UTF-8 string in bytes, or -1 if the string is\n *               zero terminated.\n * @param status Errors are returned here.\n * @return       A pointer to the UText.  If a pre-allocated UText was provided, it\n *               will always be used and returned.\n * @stable ICU 3.4\n */\nU_STABLE UText * U_EXPORT2\nutext_openUTF8(UText *ut, const char *s, int64_t length, UErrorCode *status);\n\n\n/**\n * Open a read-only UText for UChar * string.\n * \n * @param ut     Pointer to a UText struct.  If NULL, a new UText will be created.\n *               If non-NULL, must refer to an initialized UText struct, which will then\n *               be reset to reference the specified UChar string.\n * @param s      A UChar (UTF-16) string\n * @param length The number of UChars in the input string, or -1 if the string is\n *               zero terminated.\n * @param status Errors are returned here.\n * @return       A pointer to the UText.  If a pre-allocated UText was provided, it\n *               will always be used and returned.\n * @stable ICU 3.4\n */\nU_STABLE UText * U_EXPORT2\nutext_openUChars(UText *ut, const UChar *s, int64_t length, UErrorCode *status);\n\n\n#if U_SHOW_CPLUSPLUS_API\n/**\n * Open a writable UText for a non-const UnicodeString. \n * \n * @param ut      Pointer to a UText struct.  If NULL, a new UText will be created.\n *                 If non-NULL, must refer to an initialized UText struct, which will then\n *                 be reset to reference the specified input string.\n * @param s       A UnicodeString.\n * @param status Errors are returned here.\n * @return        Pointer to the UText.  If a UText was supplied as input, this\n *                 will always be used and returned.\n * @stable ICU 3.4\n */\nU_STABLE UText * U_EXPORT2\nutext_openUnicodeString(UText *ut, icu::UnicodeString *s, UErrorCode *status);\n\n\n/**\n * Open a UText for a const UnicodeString.   The resulting UText will not be writable.\n * \n * @param ut    Pointer to a UText struct.  If NULL, a new UText will be created.\n *               If non-NULL, must refer to an initialized UText struct, which will then\n *               be reset to reference the specified input string.\n * @param s      A const UnicodeString to be wrapped.\n * @param status Errors are returned here.\n * @return       Pointer to the UText.  If a UText was supplied as input, this\n *               will always be used and returned.\n * @stable ICU 3.4\n */\nU_STABLE UText * U_EXPORT2\nutext_openConstUnicodeString(UText *ut, const icu::UnicodeString *s, UErrorCode *status);\n\n\n/**\n * Open a writable UText implementation for an ICU Replaceable object.\n * @param ut    Pointer to a UText struct.  If NULL, a new UText will be created.\n *               If non-NULL, must refer to an already existing UText, which will then\n *               be reset to reference the specified replaceable text.\n * @param rep    A Replaceable text object.\n * @param status Errors are returned here.\n * @return       Pointer to the UText.  If a UText was supplied as input, this\n *               will always be used and returned.\n * @see Replaceable\n * @stable ICU 3.4\n */\nU_STABLE UText * U_EXPORT2\nutext_openReplaceable(UText *ut, icu::Replaceable *rep, UErrorCode *status);\n\n/**\n * Open a  UText implementation over an ICU CharacterIterator.\n * @param ut    Pointer to a UText struct.  If NULL, a new UText will be created.\n *               If non-NULL, must refer to an already existing UText, which will then\n *               be reset to reference the specified replaceable text.\n * @param ci     A Character Iterator.\n * @param status Errors are returned here.\n * @return       Pointer to the UText.  If a UText was supplied as input, this\n *               will always be used and returned.\n * @see Replaceable\n * @stable ICU 3.4\n */\nU_STABLE UText * U_EXPORT2\nutext_openCharacterIterator(UText *ut, icu::CharacterIterator *ci, UErrorCode *status);\n\n#endif\n\n\n/**\n  *  Clone a UText.  This is much like opening a UText where the source text is itself\n  *  another UText.\n  *\n  *  A deep clone will copy both the UText data structures and the underlying text.\n  *  The original and cloned UText will operate completely independently; modifications\n  *  made to the text in one will not affect the other.  Text providers are not\n  *  required to support deep clones.  The user of clone() must check the status return\n  *  and be prepared to handle failures.\n  *\n  *  The standard UText implementations for UTF8, UChar *, UnicodeString and\n  *  Replaceable all support deep cloning.\n  *\n  *  The UText returned from a deep clone will be writable, assuming that the text\n  *  provider is able to support writing, even if the source UText had been made\n  *  non-writable by means of UText_freeze().\n  *\n  *  A shallow clone replicates only the UText data structures; it does not make\n  *  a copy of the underlying text.  Shallow clones can be used as an efficient way to \n  *  have multiple iterators active in a single text string that is not being\n  *  modified.\n  *\n  *  A shallow clone operation will not fail, barring truly exceptional conditions such\n  *  as memory allocation failures.\n  *\n  *  Shallow UText clones should be avoided if the UText functions that modify the\n  *  text are expected to be used, either on the original or the cloned UText.\n  *  Any such modifications  can cause unpredictable behavior.  Read Only\n  *  shallow clones provide some protection against errors of this type by\n  *  disabling text modification via the cloned UText.\n  *\n  *  A shallow clone made with the readOnly parameter == FALSE will preserve the \n  *  utext_isWritable() state of the source object.  Note, however, that\n  *  write operations must be avoided while more than one UText exists that refer\n  *  to the same underlying text.\n  *\n  *  A UText and its clone may be safely concurrently accessed by separate threads.\n  *  This is true for read access only with shallow clones, and for both read and\n  *  write access with deep clones.\n  *  It is the responsibility of the Text Provider to ensure that this thread safety\n  *  constraint is met.\n  *\n  *  @param dest   A UText struct to be filled in with the result of the clone operation,\n  *                or NULL if the clone function should heap-allocate a new UText struct.\n  *                If non-NULL, must refer to an already existing UText, which will then\n  *                be reset to become the clone.\n  *  @param src    The UText to be cloned.\n  *  @param deep   TRUE to request a deep clone, FALSE for a shallow clone.\n  *  @param readOnly TRUE to request that the cloned UText have read only access to the \n  *                underlying text.  \n\n  *  @param status Errors are returned here.  For deep clones, U_UNSUPPORTED_ERROR\n  *                will be returned if the text provider is unable to clone the\n  *                original text.\n  *  @return       The newly created clone, or NULL if the clone operation failed.\n  *  @stable ICU 3.4\n  */\nU_STABLE UText * U_EXPORT2\nutext_clone(UText *dest, const UText *src, UBool deep, UBool readOnly, UErrorCode *status);\n\n\n/**\n  *  Compare two UText objects for equality.\n  *  UTexts are equal if they are iterating over the same text, and\n  *    have the same iteration position within the text.\n  *    If either or both of the parameters are NULL, the comparison is FALSE.\n  *\n  *  @param a   The first of the two UTexts to compare.\n  *  @param b   The other UText to be compared.\n  *  @return    TRUE if the two UTexts are equal.\n  *  @stable ICU 3.6\n  */\nU_STABLE UBool U_EXPORT2\nutext_equals(const UText *a, const UText *b);\n\n\n/*****************************************************************************\n *\n *   Functions to work with the text represeted by a UText wrapper\n *\n *****************************************************************************/\n\n/**\n  * Get the length of the text.  Depending on the characteristics\n  * of the underlying text representation, this may be expensive.  \n  * @see  utext_isLengthExpensive()\n  *\n  *\n  * @param ut  the text to be accessed.\n  * @return the length of the text, expressed in native units.\n  *\n  * @stable ICU 3.4\n  */\nU_STABLE int64_t U_EXPORT2\nutext_nativeLength(UText *ut);\n\n/**\n *  Return TRUE if calculating the length of the text could be expensive.\n *  Finding the length of NUL terminated strings is considered to be expensive.\n *\n *  Note that the value of this function may change\n *  as the result of other operations on a UText.\n *  Once the length of a string has been discovered, it will no longer\n *  be expensive to report it.\n *\n * @param ut the text to be accessed.\n * @return TRUE if determining the length of the text could be time consuming.\n * @stable ICU 3.4\n */\nU_STABLE UBool U_EXPORT2\nutext_isLengthExpensive(const UText *ut);\n\n/**\n * Returns the code point at the requested index,\n * or U_SENTINEL (-1) if it is out of bounds.\n *\n * If the specified index points to the interior of a multi-unit\n * character - one of the trail bytes of a UTF-8 sequence, for example -\n * the complete code point will be returned.\n *\n * The iteration position will be set to the start of the returned code point.\n *\n * This function is roughly equivalent to the the sequence\n *    utext_setNativeIndex(index);\n *    utext_current32();\n * (There is a subtle difference if the index is out of bounds by being less than zero - \n * utext_setNativeIndex(negative value) sets the index to zero, after which utext_current()\n * will return the char at zero.  utext_char32At(negative index), on the other hand, will\n * return the U_SENTINEL value of -1.)\n * \n * @param ut the text to be accessed\n * @param nativeIndex the native index of the character to be accessed.  If the index points\n *        to other than the first unit of a multi-unit character, it will be adjusted\n *        to the start of the character.\n * @return the code point at the specified index.\n * @stable ICU 3.4\n */\nU_STABLE UChar32 U_EXPORT2\nutext_char32At(UText *ut, int64_t nativeIndex);\n\n\n/**\n *\n * Get the code point at the current iteration position,\n * or U_SENTINEL (-1) if the iteration has reached the end of\n * the input text.\n *\n * @param ut the text to be accessed.\n * @return the Unicode code point at the current iterator position.\n * @stable ICU 3.4\n */\nU_STABLE UChar32 U_EXPORT2\nutext_current32(UText *ut);\n\n\n/**\n * Get the code point at the current iteration position of the UText, and\n * advance the position to the first index following the character.\n *\n * If the position is at the end of the text (the index following\n * the last character, which is also the length of the text), \n * return U_SENTINEL (-1) and do not advance the index. \n *\n * This is a post-increment operation.\n *\n * An inline macro version of this function, UTEXT_NEXT32(), \n * is available for performance critical use.\n *\n * @param ut the text to be accessed.\n * @return the Unicode code point at the iteration position.\n * @see UTEXT_NEXT32\n * @stable ICU 3.4\n */\nU_STABLE UChar32 U_EXPORT2\nutext_next32(UText *ut);\n\n\n/**\n *  Move the iterator position to the character (code point) whose\n *  index precedes the current position, and return that character.\n *  This is a pre-decrement operation.\n *\n *  If the initial position is at the start of the text (index of 0) \n *  return U_SENTINEL (-1), and leave the position unchanged.\n *\n *  An inline macro version of this function, UTEXT_PREVIOUS32(), \n *  is available for performance critical use.\n *\n *  @param ut the text to be accessed.\n *  @return the previous UChar32 code point, or U_SENTINEL (-1) \n *          if the iteration has reached the start of the text.\n *  @see UTEXT_PREVIOUS32\n *  @stable ICU 3.4\n */\nU_STABLE UChar32 U_EXPORT2\nutext_previous32(UText *ut);\n\n\n/**\n  * Set the iteration index and return the code point at that index. \n  * Leave the iteration index at the start of the following code point.\n  *\n  * This function is the most efficient and convenient way to\n  * begin a forward iteration.  The results are identical to the those\n  * from the sequence\n  * \\code\n  *    utext_setIndex();\n  *    utext_next32();\n  * \\endcode\n  *\n  *  @param ut the text to be accessed.\n  *  @param nativeIndex Iteration index, in the native units of the text provider.\n  *  @return Code point which starts at or before index,\n  *         or U_SENTINEL (-1) if it is out of bounds.\n  * @stable ICU 3.4\n  */\nU_STABLE UChar32 U_EXPORT2\nutext_next32From(UText *ut, int64_t nativeIndex);\n\n\n\n/**\n  * Set the iteration index, and return the code point preceding the\n  * one specified by the initial index.  Leave the iteration position\n  * at the start of the returned code point.\n  *\n  * This function is the most efficient and convenient way to\n  * begin a backwards iteration.\n  *\n  * @param ut the text to be accessed.\n  * @param nativeIndex Iteration index in the native units of the text provider.\n  * @return Code point preceding the one at the initial index,\n  *         or U_SENTINEL (-1) if it is out of bounds.\n  *\n  * @stable ICU 3.4\n  */\nU_STABLE UChar32 U_EXPORT2\nutext_previous32From(UText *ut, int64_t nativeIndex);\n\n/**\n  * Get the current iterator position, which can range from 0 to \n  * the length of the text.\n  * The position is a native index into the input text, in whatever format it\n  * may have (possibly UTF-8 for example), and may not always be the same as\n  * the corresponding UChar (UTF-16) index.\n  * The returned position will always be aligned to a code point boundary. \n  *\n  * @param ut the text to be accessed.\n  * @return the current index position, in the native units of the text provider.\n  * @stable ICU 3.4\n  */\nU_STABLE int64_t U_EXPORT2\nutext_getNativeIndex(const UText *ut);\n\n/**\n * Set the current iteration position to the nearest code point\n * boundary at or preceding the specified index.\n * The index is in the native units of the original input text.\n * If the index is out of range, it will be pinned to be within\n * the range of the input text.\n * <p>\n * It will usually be more efficient to begin an iteration\n * using the functions utext_next32From() or utext_previous32From()\n * rather than setIndex().\n * <p>\n * Moving the index position to an adjacent character is best done\n * with utext_next32(), utext_previous32() or utext_moveIndex32().\n * Attempting to do direct arithmetic on the index position is\n * complicated by the fact that the size (in native units) of a\n * character depends on the underlying representation of the character\n * (UTF-8, UTF-16, UTF-32, arbitrary codepage), and is not\n * easily knowable.\n *\n * @param ut the text to be accessed.\n * @param nativeIndex the native unit index of the new iteration position.\n * @stable ICU 3.4\n */\nU_STABLE void U_EXPORT2\nutext_setNativeIndex(UText *ut, int64_t nativeIndex);\n\n/**\n * Move the iterator postion by delta code points.  The number of code points\n * is a signed number; a negative delta will move the iterator backwards,\n * towards the start of the text.\n * <p>\n * The index is moved by <code>delta</code> code points\n * forward or backward, but no further backward than to 0 and\n * no further forward than to utext_nativeLength().\n * The resulting index value will be in between 0 and length, inclusive.\n *\n * @param ut the text to be accessed.\n * @param delta the signed number of code points to move the iteration position.\n * @return TRUE if the position could be moved the requested number of positions while\n *              staying within the range [0 - text length].\n * @stable ICU 3.4\n */\nU_STABLE UBool U_EXPORT2\nutext_moveIndex32(UText *ut, int32_t delta);\n\n/**\n * Get the native index of the character preceeding the current position.\n * If the iteration position is already at the start of the text, zero\n * is returned.\n * The value returned is the same as that obtained from the following sequence,\n * but without the side effect of changing the iteration position.\n *   \n * \\code\n *    UText  *ut = whatever;\n *      ...\n *    utext_previous(ut)\n *    utext_getNativeIndex(ut);\n * \\endcode\n *\n * This function is most useful during forwards iteration, where it will get the\n *   native index of the character most recently returned from utext_next().\n *\n * @param ut the text to be accessed\n * @return the native index of the character preceeding the current index position,\n *         or zero if the current position is at the start of the text.\n * @stable ICU 3.6\n */\nU_STABLE int64_t U_EXPORT2\nutext_getPreviousNativeIndex(UText *ut); \n\n\n/**\n *\n * Extract text from a UText into a UChar buffer.  The range of text to be extracted\n * is specified in the native indices of the UText provider.  These may not necessarily\n * be UTF-16 indices.\n * <p>\n * The size (number of 16 bit UChars) of the data to be extracted is returned.  The\n * full number of UChars is returned, even when the extracted text is truncated\n * because the specified buffer size is too small.\n * <p>\n * The extracted string will (if you are a user) / must (if you are a text provider)\n * be NUL-terminated if there is sufficient space in the destination buffer.  This\n * terminating NUL is not included in the returned length.\n * <p>\n * The iteration index is left at the position following the last extracted character.\n *\n * @param  ut    the UText from which to extract data.\n * @param  nativeStart the native index of the first character to extract.\\\n *               If the specified index is out of range,\n *               it will be pinned to to be within 0 <= index <= textLength\n * @param  nativeLimit the native string index of the position following the last\n *               character to extract.  If the specified index is out of range,\n *               it will be pinned to to be within 0 <= index <= textLength.\n *               nativeLimit must be >= nativeStart.\n * @param  dest  the UChar (UTF-16) buffer into which the extracted text is placed\n * @param  destCapacity  The size, in UChars, of the destination buffer.  May be zero\n *               for precomputing the required size.\n * @param  status receives any error status.\n *         U_BUFFER_OVERFLOW_ERROR: the extracted text was truncated because the \n *         buffer was too small.  Returns number of UChars for preflighting.\n * @return Number of UChars in the data to be extracted.  Does not include a trailing NUL.\n *\n * @stable ICU 3.4\n */\nU_STABLE int32_t U_EXPORT2\nutext_extract(UText *ut,\n             int64_t nativeStart, int64_t nativeLimit,\n             UChar *dest, int32_t destCapacity,\n             UErrorCode *status);\n\n\n\n/************************************************************************************\n *\n *  #define inline versions of selected performance-critical text access functions\n *          Caution:  do not use auto increment++ or decrement-- expressions\n *                    as parameters to these macros.\n *\n *          For most use, where there is no extreme performance constraint, the\n *          normal, non-inline functions are a better choice.  The resulting code\n *          will be smaller, and, if the need ever arises, easier to debug.\n *\n *          These are implemented as #defines rather than real functions\n *          because there is no fully portable way to do inline functions in plain C.\n *\n ************************************************************************************/\n\n#ifndef U_HIDE_INTERNAL_API\n/**\n * inline version of utext_current32(), for performance-critical situations.\n *\n * Get the code point at the current iteration position of the UText.\n * Returns U_SENTINEL (-1) if the position is at the end of the\n * text.\n *\n * @internal ICU 4.4 technology preview\n */\n#define UTEXT_CURRENT32(ut)  \\\n    ((ut)->chunkOffset < (ut)->chunkLength && ((ut)->chunkContents)[(ut)->chunkOffset]<0xd800 ? \\\n    ((ut)->chunkContents)[((ut)->chunkOffset)] : utext_current32(ut))\n#endif  /* U_HIDE_INTERNAL_API */\n\n/**\n * inline version of utext_next32(), for performance-critical situations.\n *\n * Get the code point at the current iteration position of the UText, and\n * advance the position to the first index following the character.\n * This is a post-increment operation.\n * Returns U_SENTINEL (-1) if the position is at the end of the\n * text.\n *\n * @stable ICU 3.4\n */\n#define UTEXT_NEXT32(ut)  \\\n    ((ut)->chunkOffset < (ut)->chunkLength && ((ut)->chunkContents)[(ut)->chunkOffset]<0xd800 ? \\\n    ((ut)->chunkContents)[((ut)->chunkOffset)++] : utext_next32(ut))\n\n/**\n * inline version of utext_previous32(), for performance-critical situations.\n *\n *  Move the iterator position to the character (code point) whose\n *  index precedes the current position, and return that character.\n *  This is a pre-decrement operation.\n *  Returns U_SENTINEL (-1) if the position is at the start of the  text.\n *\n * @stable ICU 3.4\n */\n#define UTEXT_PREVIOUS32(ut)  \\\n    ((ut)->chunkOffset > 0 && \\\n     (ut)->chunkContents[(ut)->chunkOffset-1] < 0xd800 ? \\\n          (ut)->chunkContents[--((ut)->chunkOffset)]  :  utext_previous32(ut))\n\n/**\n  *  inline version of utext_getNativeIndex(), for performance-critical situations.\n  *\n  * Get the current iterator position, which can range from 0 to \n  * the length of the text.\n  * The position is a native index into the input text, in whatever format it\n  * may have (possibly UTF-8 for example), and may not always be the same as\n  * the corresponding UChar (UTF-16) index.\n  * The returned position will always be aligned to a code point boundary. \n  *\n  * @stable ICU 3.6\n  */\n#define UTEXT_GETNATIVEINDEX(ut)                       \\\n    ((ut)->chunkOffset <= (ut)->nativeIndexingLimit?   \\\n        (ut)->chunkNativeStart+(ut)->chunkOffset :     \\\n        (ut)->pFuncs->mapOffsetToNative(ut))    \n\n/**\n  *  inline version of utext_setNativeIndex(), for performance-critical situations.\n  *\n  * Set the current iteration position to the nearest code point\n  * boundary at or preceding the specified index.\n  * The index is in the native units of the original input text.\n  * If the index is out of range, it will be pinned to be within\n  * the range of the input text.\n  *\n  * @stable ICU 3.8\n  */\n#define UTEXT_SETNATIVEINDEX(ut, ix)                       \\\n    { int64_t __offset = (ix) - (ut)->chunkNativeStart; \\\n      if (__offset>=0 && __offset<=(int64_t)(ut)->nativeIndexingLimit) { \\\n          (ut)->chunkOffset=(int32_t)__offset; \\\n      } else { \\\n          utext_setNativeIndex((ut), (ix)); } }\n\n\n\n/************************************************************************************\n *\n *   Functions related to writing or modifying the text.\n *   These will work only with modifiable UTexts.  Attempting to\n *   modify a read-only UText will return an error status.\n *\n ************************************************************************************/\n\n\n/**\n *  Return TRUE if the text can be written (modified) with utext_replace() or\n *  utext_copy().  For the text to be writable, the text provider must\n *  be of a type that supports writing and the UText must not be frozen.\n *\n *  Attempting to modify text when utext_isWriteable() is FALSE will fail -\n *  the text will not be modified, and an error will be returned from the function\n *  that attempted the modification.\n *\n * @param  ut   the UText to be tested.\n * @return TRUE if the text is modifiable.\n *\n * @see    utext_freeze()\n * @see    utext_replace()\n * @see    utext_copy()\n * @stable ICU 3.4\n *\n */\nU_STABLE UBool U_EXPORT2\nutext_isWritable(const UText *ut);\n\n\n/**\n  * Test whether there is meta data associated with the text.\n  * @see Replaceable::hasMetaData()\n  *\n  * @param ut The UText to be tested\n  * @return TRUE if the underlying text includes meta data.\n  * @stable ICU 3.4\n  */\nU_STABLE UBool U_EXPORT2\nutext_hasMetaData(const UText *ut);\n\n\n/**\n * Replace a range of the original text with a replacement text.\n *\n * Leaves the current iteration position at the position following the\n *  newly inserted replacement text.\n *\n * This function is only available on UText types that support writing,\n * that is, ones where utext_isWritable() returns TRUE.\n *\n * When using this function, there should be only a single UText opened onto the\n * underlying native text string.  Behavior after a replace operation\n * on a UText is undefined for any other additional UTexts that refer to the\n * modified string.\n *\n * @param ut               the UText representing the text to be operated on.\n * @param nativeStart      the native index of the start of the region to be replaced\n * @param nativeLimit      the native index of the character following the region to be replaced.\n * @param replacementText  pointer to the replacement text\n * @param replacementLength length of the replacement text, or -1 if the text is NUL terminated.\n * @param status           receives any error status.  Possible errors include\n *                         U_NO_WRITE_PERMISSION\n *\n * @return The signed number of (native) storage units by which\n *         the length of the text expanded or contracted.\n *\n * @stable ICU 3.4\n */\nU_STABLE int32_t U_EXPORT2\nutext_replace(UText *ut,\n             int64_t nativeStart, int64_t nativeLimit,\n             const UChar *replacementText, int32_t replacementLength,\n             UErrorCode *status);\n\n\n\n/**\n *\n * Copy or move a substring from one position to another within the text,\n * while retaining any metadata associated with the text.\n * This function is used to duplicate or reorder substrings.\n * The destination index must not overlap the source range.\n *\n * The text to be copied or moved is inserted at destIndex;\n * it does not replace or overwrite any existing text.\n *\n * The iteration position is left following the newly inserted text\n * at the destination position.\n *\n * This function is only available on UText types that support writing,\n * that is, ones where utext_isWritable() returns TRUE.\n *\n * When using this function, there should be only a single UText opened onto the\n * underlying native text string.  Behavior after a copy operation\n * on a UText is undefined in any other additional UTexts that refer to the\n * modified string.\n *\n * @param ut           The UText representing the text to be operated on.\n * @param nativeStart  The native index of the start of the region to be copied or moved\n * @param nativeLimit  The native index of the character position following the region\n *                     to be copied.\n * @param destIndex    The native destination index to which the source substring is\n *                     copied or moved.\n * @param move         If TRUE, then the substring is moved, not copied/duplicated.\n * @param status       receives any error status.  Possible errors include U_NO_WRITE_PERMISSION\n *                       \n * @stable ICU 3.4\n */\nU_STABLE void U_EXPORT2\nutext_copy(UText *ut,\n          int64_t nativeStart, int64_t nativeLimit,\n          int64_t destIndex,\n          UBool move,\n          UErrorCode *status);\n\n\n/**\n  *  <p>\n  *  Freeze a UText.  This prevents any modification to the underlying text itself\n  *  by means of functions operating on this UText.\n  *  </p>\n  *  <p>\n  *  Once frozen, a UText can not be unfrozen.  The intent is to ensure\n  *  that a the text underlying a frozen UText wrapper cannot be modified via that UText.\n  *  </p>\n  *  <p>\n  *  Caution:  freezing a UText will disable changes made via the specific\n  *   frozen UText wrapper only; it will not have any effect on the ability to\n  *   directly modify the text by bypassing the UText.  Any such backdoor modifications\n  *   are always an error while UText access is occuring because the underlying\n  *   text can get out of sync with UText's buffering.\n  *  </p>\n  *\n  *  @param ut  The UText to be frozen.\n  *  @see   utext_isWritable()\n  *  @stable ICU 3.6\n  */\nU_STABLE void U_EXPORT2\nutext_freeze(UText *ut);\n\n\n/**\n * UText provider properties (bit field indexes).\n *\n * @see UText\n * @stable ICU 3.4\n */\nenum {\n    /**\n     * It is potentially time consuming for the provider to determine the length of the text.\n     * @stable ICU 3.4\n     */\n    UTEXT_PROVIDER_LENGTH_IS_EXPENSIVE = 1,\n    /**\n     * Text chunks remain valid and usable until the text object is modified or\n     * deleted, not just until the next time the access() function is called\n     * (which is the default).\n     * @stable ICU 3.4\n     */\n    UTEXT_PROVIDER_STABLE_CHUNKS = 2,\n    /**\n     * The provider supports modifying the text via the replace() and copy()\n     * functions.\n     * @see Replaceable\n     * @stable ICU 3.4\n     */\n    UTEXT_PROVIDER_WRITABLE = 3,\n    /**\n     * There is meta data associated with the text.\n     * @see Replaceable::hasMetaData()\n     * @stable ICU 3.4\n     */ \n    UTEXT_PROVIDER_HAS_META_DATA = 4,\n    /**\n     * Text provider owns the text storage.\n     *  Generally occurs as the result of a deep clone of the UText.\n     *  When closing the UText, the associated text must\n     *  also be closed/deleted/freed/ whatever is appropriate.\n     * @stable ICU 3.6\n     */\n     UTEXT_PROVIDER_OWNS_TEXT = 5\n};\n\n/**\n  * Function type declaration for UText.clone().\n  *\n  *  clone a UText.  Much like opening a UText where the source text is itself\n  *  another UText.\n  *\n  *  A deep clone will copy both the UText data structures and the underlying text.\n  *  The original and cloned UText will operate completely independently; modifications\n  *  made to the text in one will not effect the other.  Text providers are not\n  *  required to support deep clones.  The user of clone() must check the status return\n  *  and be prepared to handle failures.\n  *\n  *  A shallow clone replicates only the UText data structures; it does not make\n  *  a copy of the underlying text.  Shallow clones can be used as an efficient way to \n  *  have multiple iterators active in a single text string that is not being\n  *  modified.\n  *\n  *  A shallow clone operation must not fail except for truly exceptional conditions such\n  *  as memory allocation failures.\n  *\n  *  A UText and its clone may be safely concurrently accessed by separate threads.\n  *  This is true for both shallow and deep clones.\n  *  It is the responsibility of the Text Provider to ensure that this thread safety\n  *  constraint is met.\n\n  *\n  *  @param dest   A UText struct to be filled in with the result of the clone operation,\n  *                or NULL if the clone function should heap-allocate a new UText struct.\n  *  @param src    The UText to be cloned.\n  *  @param deep   TRUE to request a deep clone, FALSE for a shallow clone.\n  *  @param status Errors are returned here.  For deep clones, U_UNSUPPORTED_ERROR\n  *                should be returned if the text provider is unable to clone the\n  *                original text.\n  *  @return       The newly created clone, or NULL if the clone operation failed.\n  *\n  * @stable ICU 3.4\n  */\ntypedef UText * U_CALLCONV\nUTextClone(UText *dest, const UText *src, UBool deep, UErrorCode *status);\n\n\n/**\n * Function type declaration for UText.nativeLength().\n *\n * @param ut the UText to get the length of.\n * @return the length, in the native units of the original text string.\n * @see UText\n * @stable ICU 3.4\n */\ntypedef int64_t U_CALLCONV\nUTextNativeLength(UText *ut);\n\n/**\n * Function type declaration for UText.access().  Get the description of the text chunk\n *  containing the text at a requested native index.  The UText's iteration\n *  position will be left at the requested index.  If the index is out\n *  of bounds, the iteration position will be left at the start or end\n *  of the string, as appropriate.\n *\n *  Chunks must begin and end on code point boundaries.  A single code point\n *  comprised of multiple storage units must never span a chunk boundary.\n *\n *\n * @param ut          the UText being accessed.\n * @param nativeIndex Requested index of the text to be accessed.\n * @param forward     If TRUE, then the returned chunk must contain text\n *                    starting from the index, so that start<=index<limit.\n *                    If FALSE, then the returned chunk must contain text\n *                    before the index, so that start<index<=limit.\n * @return            True if the requested index could be accessed.  The chunk\n *                    will contain the requested text.\n *                    False value if a chunk cannot be accessed\n *                    (the requested index is out of bounds).\n *\n * @see UText\n * @stable ICU 3.4\n */\ntypedef UBool U_CALLCONV\nUTextAccess(UText *ut, int64_t nativeIndex, UBool forward);\n\n/**\n * Function type declaration for UText.extract().\n *\n * Extract text from a UText into a UChar buffer.  The range of text to be extracted\n * is specified in the native indices of the UText provider.  These may not necessarily\n * be UTF-16 indices.\n * <p>\n * The size (number of 16 bit UChars) in the data to be extracted is returned.  The\n * full amount is returned, even when the specified buffer size is smaller.\n * <p>\n * The extracted string will (if you are a user) / must (if you are a text provider)\n * be NUL-terminated if there is sufficient space in the destination buffer.\n *\n * @param  ut            the UText from which to extract data.\n * @param  nativeStart   the native index of the first characer to extract.\n * @param  nativeLimit   the native string index of the position following the last\n *                       character to extract.\n * @param  dest          the UChar (UTF-16) buffer into which the extracted text is placed\n * @param  destCapacity  The size, in UChars, of the destination buffer.  May be zero\n *                       for precomputing the required size.\n * @param  status        receives any error status.\n *                       If U_BUFFER_OVERFLOW_ERROR: Returns number of UChars for\n *                       preflighting.\n * @return Number of UChars in the data.  Does not include a trailing NUL.\n *\n * @stable ICU 3.4\n */\ntypedef int32_t U_CALLCONV\nUTextExtract(UText *ut,\n             int64_t nativeStart, int64_t nativeLimit,\n             UChar *dest, int32_t destCapacity,\n             UErrorCode *status);\n\n/**\n * Function type declaration for UText.replace().\n *\n * Replace a range of the original text with a replacement text.\n *\n * Leaves the current iteration position at the position following the\n *  newly inserted replacement text.\n *\n * This function need only be implemented on UText types that support writing.\n *\n * When using this function, there should be only a single UText opened onto the\n * underlying native text string.  The function is responsible for updating the\n * text chunk within the UText to reflect the updated iteration position,\n * taking into account any changes to the underlying string's structure caused\n * by the replace operation.\n *\n * @param ut               the UText representing the text to be operated on.\n * @param nativeStart      the index of the start of the region to be replaced\n * @param nativeLimit      the index of the character following the region to be replaced.\n * @param replacementText  pointer to the replacement text\n * @param replacmentLength length of the replacement text in UChars, or -1 if the text is NUL terminated.\n * @param status           receives any error status.  Possible errors include\n *                         U_NO_WRITE_PERMISSION\n *\n * @return The signed number of (native) storage units by which\n *         the length of the text expanded or contracted.\n *\n * @stable ICU 3.4\n */\ntypedef int32_t U_CALLCONV\nUTextReplace(UText *ut,\n             int64_t nativeStart, int64_t nativeLimit,\n             const UChar *replacementText, int32_t replacmentLength,\n             UErrorCode *status);\n\n/**\n * Function type declaration for UText.copy().\n *\n * Copy or move a substring from one position to another within the text,\n * while retaining any metadata associated with the text.\n * This function is used to duplicate or reorder substrings.\n * The destination index must not overlap the source range.\n *\n * The text to be copied or moved is inserted at destIndex;\n * it does not replace or overwrite any existing text.\n *\n * This function need only be implemented for UText types that support writing.\n *\n * When using this function, there should be only a single UText opened onto the\n * underlying native text string.  The function is responsible for updating the\n * text chunk within the UText to reflect the updated iteration position,\n * taking into account any changes to the underlying string's structure caused\n * by the replace operation.\n *\n * @param ut           The UText representing the text to be operated on.\n * @param nativeStart  The index of the start of the region to be copied or moved\n * @param nativeLimit  The index of the character following the region to be replaced.\n * @param nativeDest   The destination index to which the source substring is copied or moved.\n * @param move         If TRUE, then the substring is moved, not copied/duplicated.\n * @param status       receives any error status.  Possible errors include U_NO_WRITE_PERMISSION\n *\n * @stable ICU 3.4\n */\ntypedef void U_CALLCONV\nUTextCopy(UText *ut,\n          int64_t nativeStart, int64_t nativeLimit,\n          int64_t nativeDest,\n          UBool move,\n          UErrorCode *status);\n\n/**\n * Function type declaration for UText.mapOffsetToNative().\n * Map from the current UChar offset within the current text chunk to\n *  the corresponding native index in the original source text.\n *\n * This is required only for text providers that do not use native UTF-16 indexes.\n *\n * @param ut     the UText.\n * @return Absolute (native) index corresponding to chunkOffset in the current chunk.\n *         The returned native index should always be to a code point boundary.\n *\n * @stable ICU 3.4\n */\ntypedef int64_t U_CALLCONV\nUTextMapOffsetToNative(const UText *ut);\n\n/**\n * Function type declaration for UText.mapIndexToUTF16().\n * Map from a native index to a UChar offset within a text chunk.\n * Behavior is undefined if the native index does not fall within the\n *   current chunk.\n *\n * This function is required only for text providers that do not use native UTF-16 indexes.\n *\n * @param ut          The UText containing the text chunk.\n * @param nativeIndex Absolute (native) text index, chunk->start<=index<=chunk->limit.\n * @return            Chunk-relative UTF-16 offset corresponding to the specified native\n *                    index.\n *\n * @stable ICU 3.4\n */\ntypedef int32_t U_CALLCONV\nUTextMapNativeIndexToUTF16(const UText *ut, int64_t nativeIndex);\n\n\n/**\n * Function type declaration for UText.utextClose().\n *\n * A Text Provider close function is only required for provider types that make\n *  allocations in their open function (or other functions) that must be \n *  cleaned when the UText is closed.\n *\n * The allocation of the UText struct itself and any \"extra\" storage\n * associated with the UText is handled by the common UText implementation\n * and does not require provider specific cleanup in a close function.\n *\n * Most UText provider implementations do not need to implement this function.\n *\n * @param ut A UText object to be closed.\n *\n * @stable ICU 3.4\n */\ntypedef void U_CALLCONV\nUTextClose(UText *ut);\n\n\n/**\n  *   (public)  Function dispatch table for UText.\n  *             Conceptually very much like a C++ Virtual Function Table.\n  *             This struct defines the organization of the table.\n  *             Each text provider implementation must provide an\n  *              actual table that is initialized with the appropriate functions\n  *              for the type of text being handled.\n  *   @stable ICU 3.6\n  */\nstruct UTextFuncs {\n    /**\n     *   (public)  Function table size, sizeof(UTextFuncs)\n     *             Intended for use should the table grow to accomodate added\n     *             functions in the future, to allow tests for older format\n     *             function tables that do not contain the extensions.\n     *\n     *             Fields are placed for optimal alignment on\n     *             32/64/128-bit-pointer machines, by normally grouping together\n     *             4 32-bit fields,\n     *             4 pointers,\n     *             2 64-bit fields\n     *             in sequence.\n     *   @stable ICU 3.6\n     */\n    int32_t       tableSize;\n\n    /**\n      *   (private)  Alignment padding.\n      *              Do not use, reserved for use by the UText framework only.\n      *   @internal\n      */\n    int32_t       reserved1, /** @internal */ reserved2, /** @internal */ reserved3;\n\n\n    /**\n     * (public) Function pointer for UTextClone\n     *\n     * @see UTextClone\n     * @stable ICU 3.6\n     */\n    UTextClone *clone;\n\n    /**\n     * (public) function pointer for UTextLength\n     * May be expensive to compute!\n     *\n     * @see UTextLength\n     * @stable ICU 3.6\n     */\n    UTextNativeLength *nativeLength;\n\n    /**\n     * (public) Function pointer for UTextAccess.\n     *\n     * @see UTextAccess\n     * @stable ICU 3.6\n     */\n    UTextAccess *access;\n\n    /**\n     * (public) Function pointer for UTextExtract.\n     *\n     * @see UTextExtract\n     * @stable ICU 3.6\n     */\n    UTextExtract *extract;\n\n    /**\n     * (public) Function pointer for UTextReplace.\n     *\n     * @see UTextReplace\n     * @stable ICU 3.6\n     */\n    UTextReplace *replace;\n\n    /**\n     * (public) Function pointer for UTextCopy.\n     *\n     * @see UTextCopy\n     * @stable ICU 3.6\n     */\n    UTextCopy *copy;\n\n    /**\n     * (public) Function pointer for UTextMapOffsetToNative.\n     *\n     * @see UTextMapOffsetToNative\n     * @stable ICU 3.6\n     */\n    UTextMapOffsetToNative *mapOffsetToNative;\n\n    /**\n     * (public) Function pointer for UTextMapNativeIndexToUTF16.\n     *\n     * @see UTextMapNativeIndexToUTF16\n     * @stable ICU 3.6\n     */\n    UTextMapNativeIndexToUTF16 *mapNativeIndexToUTF16;\n\n    /**\n     * (public) Function pointer for UTextClose.\n      *\n      * @see UTextClose\n      * @stable ICU 3.6\n      */\n    UTextClose  *close;\n\n    /**\n      * (private)  Spare function pointer\n      * @internal\n      */\n    UTextClose  *spare1;\n    \n    /**\n      * (private)  Spare function pointer\n      * @internal\n      */\n    UTextClose  *spare2;\n\n    /**\n      * (private)  Spare function pointer\n      * @internal\n      */\n    UTextClose  *spare3;\n\n};\n/**\n * Function dispatch table for UText\n * @see UTextFuncs\n */\ntypedef struct UTextFuncs UTextFuncs;\n\n /**\n  *   UText struct.  Provides the interface between the generic UText access code\n  *                  and the UText provider code that works on specific kinds of\n  *                  text  (UTF-8, noncontiguous UTF-16, whatever.)\n  *\n  *                  Applications that are using predefined types of text providers\n  *                  to pass text data to ICU services will have no need to view the\n  *                  internals of the UText structs that they open.\n  *\n  * @stable ICU 3.6\n  */\nstruct UText {\n    /**\n     *     (private)  Magic.  Used to help detect when UText functions are handed\n     *                        invalid or unitialized UText structs.\n     *                        utext_openXYZ() functions take an initialized,\n     *                        but not necessarily open, UText struct as an\n     *                        optional fill-in parameter.  This magic field\n     *                        is used to check for that initialization.\n     *                        Text provider close functions must NOT clear\n     *                        the magic field because that would prevent\n     *                        reuse of the UText struct.\n     * @internal\n     */\n    uint32_t       magic;\n\n\n    /**\n     *     (private)  Flags for managing the allocation and freeing of\n     *                memory associated with this UText.\n     * @internal\n     */\n    int32_t        flags;\n\n\n    /**\n      *  Text provider properties.  This set of flags is maintainted by the\n      *                             text provider implementation.\n      *  @stable ICU 3.4\n      */\n    int32_t         providerProperties;\n\n    /**\n     * (public) sizeOfStruct=sizeof(UText)\n     * Allows possible backward compatible extension.\n     *\n     * @stable ICU 3.4\n     */\n    int32_t         sizeOfStruct;\n    \n    /* ------ 16 byte alignment boundary -----------  */\n    \n\n    /**\n      *  (protected) Native index of the first character position following\n      *              the current chunk.\n      *  @stable ICU 3.6\n      */\n    int64_t         chunkNativeLimit;\n\n    /**\n     *   (protected)  Size in bytes of the extra space (pExtra).\n     *  @stable ICU 3.4\n     */\n    int32_t        extraSize;\n\n    /**\n      *    (protected) The highest chunk offset where native indexing and\n      *    chunk (UTF-16) indexing correspond.  For UTF-16 sources, value\n      *    will be equal to chunkLength.\n      *\n      *    @stable ICU 3.6\n      */\n    int32_t         nativeIndexingLimit;\n\n    /* ---- 16 byte alignment boundary------ */\n    \n    /**\n     *  (protected) Native index of the first character in the text chunk.\n     *  @stable ICU 3.6\n     */\n    int64_t         chunkNativeStart;\n\n    /**\n     *  (protected) Current iteration position within the text chunk (UTF-16 buffer).\n     *  This is the index to the character that will be returned by utext_next32().\n     *  @stable ICU 3.6\n     */\n    int32_t         chunkOffset;\n\n    /**\n     *  (protected) Length the text chunk (UTF-16 buffer), in UChars.\n     *  @stable ICU 3.6\n     */\n    int32_t         chunkLength;\n\n    /* ---- 16  byte alignment boundary-- */\n    \n\n    /**\n     *  (protected)  pointer to a chunk of text in UTF-16 format.\n     *  May refer either to original storage of the source of the text, or\n     *  if conversion was required, to a buffer owned by the UText.\n     *  @stable ICU 3.6\n     */\n    const UChar    *chunkContents;\n\n     /**\n      * (public)     Pointer to Dispatch table for accessing functions for this UText.\n      * @stable ICU 3.6\n      */\n    const UTextFuncs     *pFuncs;\n\n    /**\n     *  (protected)  Pointer to additional space requested by the\n     *               text provider during the utext_open operation.\n     * @stable ICU 3.4\n     */\n    void          *pExtra;\n\n    /**\n     * (protected) Pointer to string or text-containin object or similar.\n     * This is the source of the text that this UText is wrapping, in a format\n     *  that is known to the text provider functions.\n     * @stable ICU 3.4\n     */\n    const void   *context;\n\n    /* --- 16 byte alignment boundary--- */\n\n    /**\n     * (protected) Pointer fields available for use by the text provider.\n     * Not used by UText common code.\n     * @stable ICU 3.6\n     */\n    const void     *p; \n    /**\n     * (protected) Pointer fields available for use by the text provider.\n     * Not used by UText common code.\n     * @stable ICU 3.6\n     */\n    const void     *q;\n     /**\n     * (protected) Pointer fields available for use by the text provider.\n     * Not used by UText common code.\n     * @stable ICU 3.6\n      */\n    const void     *r;\n\n    /**\n      *  Private field reserved for future use by the UText framework\n      *     itself.  This is not to be touched by the text providers.\n      * @internal ICU 3.4\n      */\n    void           *privP;\n\n\n    /* --- 16 byte alignment boundary--- */\n    \n\n    /**\n      * (protected) Integer field reserved for use by the text provider.\n      * Not used by the UText framework, or by the client (user) of the UText.\n      * @stable ICU 3.4\n      */\n    int64_t         a;\n\n    /**\n      * (protected) Integer field reserved for use by the text provider.\n      * Not used by the UText framework, or by the client (user) of the UText.\n      * @stable ICU 3.4\n      */\n    int32_t         b;\n\n    /**\n      * (protected) Integer field reserved for use by the text provider.\n      * Not used by the UText framework, or by the client (user) of the UText.\n      * @stable ICU 3.4\n      */\n    int32_t         c;\n\n    /*  ---- 16 byte alignment boundary---- */\n\n\n    /**\n      *  Private field reserved for future use by the UText framework\n      *     itself.  This is not to be touched by the text providers.\n      * @internal ICU 3.4\n      */\n    int64_t         privA;\n    /**\n      *  Private field reserved for future use by the UText framework\n      *     itself.  This is not to be touched by the text providers.\n      * @internal ICU 3.4\n      */\n    int32_t         privB;\n    /**\n      *  Private field reserved for future use by the UText framework\n      *     itself.  This is not to be touched by the text providers.\n      * @internal ICU 3.4\n      */\n    int32_t         privC;\n};\n\n\n/**\n *  Common function for use by Text Provider implementations to allocate and/or initialize\n *  a new UText struct.  To be called in the implementation of utext_open() functions.\n *  If the supplied UText parameter is null, a new UText struct will be allocated on the heap.\n *  If the supplied UText is already open, the provider's close function will be called\n *  so that the struct can be reused by the open that is in progress.\n *\n * @param ut   pointer to a UText struct to be re-used, or null if a new UText\n *             should be allocated.\n * @param extraSpace The amount of additional space to be allocated as part\n *             of this UText, for use by types of providers that require\n *             additional storage.\n * @param status Errors are returned here.\n * @return pointer to the UText, allocated if necessary, with extra space set up if requested.\n * @stable ICU 3.4\n */\nU_STABLE UText * U_EXPORT2\nutext_setup(UText *ut, int32_t extraSpace, UErrorCode *status);\n\n#ifndef U_HIDE_INTERNAL_API\n/**\n  * @internal\n  *  Value used to help identify correctly initialized UText structs.\n  *  Note:  must be publicly visible so that UTEXT_INITIALIZER can access it.\n  */\nenum {\n    UTEXT_MAGIC = 0x345ad82c\n};\n#endif  /* U_HIDE_INTERNAL_API */\n\n/**\n * initializer to be used with local (stack) instances of a UText\n *  struct.  UText structs must be initialized before passing\n *  them to one of the utext_open functions.\n *\n * @stable ICU 3.6\n */\n#define UTEXT_INITIALIZER {                                        \\\n                  UTEXT_MAGIC,          /* magic                */ \\\n                  0,                    /* flags                */ \\\n                  0,                    /* providerProps        */ \\\n                  sizeof(UText),        /* sizeOfStruct         */ \\\n                  0,                    /* chunkNativeLimit     */ \\\n                  0,                    /* extraSize            */ \\\n                  0,                    /* nativeIndexingLimit  */ \\\n                  0,                    /* chunkNativeStart     */ \\\n                  0,                    /* chunkOffset          */ \\\n                  0,                    /* chunkLength          */ \\\n                  NULL,                 /* chunkContents        */ \\\n                  NULL,                 /* pFuncs               */ \\\n                  NULL,                 /* pExtra               */ \\\n                  NULL,                 /* context              */ \\\n                  NULL, NULL, NULL,     /* p, q, r              */ \\\n                  NULL,                 /* privP                */ \\\n                  0, 0, 0,              /* a, b, c              */ \\\n                  0, 0, 0               /* privA,B,C,           */ \\\n                  }\n\n\nU_CDECL_END\n\n\n\n#endif\n"
  },
  {
    "path": "deprecated/android/addons/icucompat/unicode/utf.h",
    "content": "/*\n*******************************************************************************\n*\n*   Copyright (C) 1999-2011, International Business Machines\n*   Corporation and others.  All Rights Reserved.\n*\n*******************************************************************************\n*   file name:  utf.h\n*   encoding:   US-ASCII\n*   tab size:   8 (not used)\n*   indentation:4\n*\n*   created on: 1999sep09\n*   created by: Markus W. Scherer\n*/\n\n/**\n * \\file\n * \\brief C API: Code point macros\n *\n * This file defines macros for checking whether a code point is\n * a surrogate or a non-character etc.\n *\n * The UChar and UChar32 data types for Unicode code units and code points\n * are defined in umachine.h because they can be machine-dependent.\n *\n * If U_NO_DEFAULT_INCLUDE_UTF_HEADERS is 0 then utf.h is included by utypes.h\n * and itself includes utf8.h and utf16.h after some\n * common definitions.\n * If U_NO_DEFAULT_INCLUDE_UTF_HEADERS is 1 then each of these headers must be\n * included explicitly if their definitions are used.\n *\n * utf8.h and utf16.h define macros for efficiently getting code points\n * in and out of UTF-8/16 strings.\n * utf16.h macros have \"U16_\" prefixes.\n * utf8.h defines similar macros with \"U8_\" prefixes for UTF-8 string handling.\n *\n * ICU mostly processes 16-bit Unicode strings.\n * Most of the time, such strings are well-formed UTF-16.\n * Single, unpaired surrogates must be handled as well, and are treated in ICU\n * like regular code points where possible.\n * (Pairs of surrogate code points are indistinguishable from supplementary\n * code points encoded as pairs of supplementary code units.)\n *\n * In fact, almost all Unicode code points in normal text (>99%)\n * are on the BMP (<=U+ffff) and even <=U+d7ff.\n * ICU functions handle supplementary code points (U+10000..U+10ffff)\n * but are optimized for the much more frequently occurring BMP code points.\n *\n * umachine.h defines UChar to be an unsigned 16-bit integer.\n * Where available, UChar is defined to be a char16_t\n * or a wchar_t (if that is an unsigned 16-bit type), otherwise uint16_t.\n *\n * UChar32 is defined to be a signed 32-bit integer (int32_t), large enough for a 21-bit\n * Unicode code point (Unicode scalar value, 0..0x10ffff).\n * Before ICU 2.4, the definition of UChar32 was similarly platform-dependent as\n * the definition of UChar. For details see the documentation for UChar32 itself.\n *\n * utf.h defines a small number of C macros for single Unicode code points.\n * These are simple checks for surrogates and non-characters.\n * For actual Unicode character properties see uchar.h.\n *\n * By default, string operations must be done with error checking in case\n * a string is not well-formed UTF-16.\n * The macros will detect if a surrogate code unit is unpaired\n * (lead unit without trail unit or vice versa) and just return the unit itself\n * as the code point.\n *\n * The regular \"safe\" macros require that the initial, passed-in string index\n * is within bounds. They only check the index when they read more than one\n * code unit. This is usually done with code similar to the following loop:\n * <pre>while(i<length) {\n *   U16_NEXT(s, i, length, c);\n *   // use c\n * }</pre>\n *\n * When it is safe to assume that text is well-formed UTF-16\n * (does not contain single, unpaired surrogates), then one can use\n * U16_..._UNSAFE macros.\n * These do not check for proper code unit sequences or truncated text and may\n * yield wrong results or even cause a crash if they are used with \"malformed\"\n * text.\n * In practice, U16_..._UNSAFE macros will produce slightly less code but\n * should not be faster because the processing is only different when a\n * surrogate code unit is detected, which will be rare.\n *\n * Similarly for UTF-8, there are \"safe\" macros without a suffix,\n * and U8_..._UNSAFE versions.\n * The performance differences are much larger here because UTF-8 provides so\n * many opportunities for malformed sequences.\n * The unsafe UTF-8 macros are entirely implemented inside the macro definitions\n * and are fast, while the safe UTF-8 macros call functions for all but the\n * trivial (ASCII) cases.\n * (ICU 3.6 optimizes U8_NEXT() and U8_APPEND() to handle most other common\n * characters inline as well.)\n *\n * Unlike with UTF-16, malformed sequences cannot be expressed with distinct\n * code point values (0..U+10ffff). They are indicated with negative values instead.\n *\n * For more information see the ICU User Guide Strings chapter\n * (http://userguide.icu-project.org/strings).\n *\n * <em>Usage:</em>\n * ICU coding guidelines for if() statements should be followed when using these macros.\n * Compound statements (curly braces {}) must be used  for if-else-while... \n * bodies and all macro statements should be terminated with semicolon.\n *\n * @stable ICU 2.4\n */\n\n#ifndef __UTF_H__\n#define __UTF_H__\n\n#include \"unicode/umachine.h\"\n/* include the utfXX.h after the following definitions */\n\n/* single-code point definitions -------------------------------------------- */\n\n/**\n * Is this code point a Unicode noncharacter?\n * @param c 32-bit code point\n * @return TRUE or FALSE\n * @stable ICU 2.4\n */\n#define U_IS_UNICODE_NONCHAR(c) \\\n    ((c)>=0xfdd0 && \\\n     ((uint32_t)(c)<=0xfdef || ((c)&0xfffe)==0xfffe) && \\\n     (uint32_t)(c)<=0x10ffff)\n\n/**\n * Is c a Unicode code point value (0..U+10ffff)\n * that can be assigned a character?\n *\n * Code points that are not characters include:\n * - single surrogate code points (U+d800..U+dfff, 2048 code points)\n * - the last two code points on each plane (U+__fffe and U+__ffff, 34 code points)\n * - U+fdd0..U+fdef (new with Unicode 3.1, 32 code points)\n * - the highest Unicode code point value is U+10ffff\n *\n * This means that all code points below U+d800 are character code points,\n * and that boundary is tested first for performance.\n *\n * @param c 32-bit code point\n * @return TRUE or FALSE\n * @stable ICU 2.4\n */\n#define U_IS_UNICODE_CHAR(c) \\\n    ((uint32_t)(c)<0xd800 || \\\n        ((uint32_t)(c)>0xdfff && \\\n         (uint32_t)(c)<=0x10ffff && \\\n         !U_IS_UNICODE_NONCHAR(c)))\n\n/**\n * Is this code point a BMP code point (U+0000..U+ffff)?\n * @param c 32-bit code point\n * @return TRUE or FALSE\n * @stable ICU 2.8\n */\n#define U_IS_BMP(c) ((uint32_t)(c)<=0xffff)\n\n/**\n * Is this code point a supplementary code point (U+10000..U+10ffff)?\n * @param c 32-bit code point\n * @return TRUE or FALSE\n * @stable ICU 2.8\n */\n#define U_IS_SUPPLEMENTARY(c) ((uint32_t)((c)-0x10000)<=0xfffff)\n \n/**\n * Is this code point a lead surrogate (U+d800..U+dbff)?\n * @param c 32-bit code point\n * @return TRUE or FALSE\n * @stable ICU 2.4\n */\n#define U_IS_LEAD(c) (((c)&0xfffffc00)==0xd800)\n\n/**\n * Is this code point a trail surrogate (U+dc00..U+dfff)?\n * @param c 32-bit code point\n * @return TRUE or FALSE\n * @stable ICU 2.4\n */\n#define U_IS_TRAIL(c) (((c)&0xfffffc00)==0xdc00)\n\n/**\n * Is this code point a surrogate (U+d800..U+dfff)?\n * @param c 32-bit code point\n * @return TRUE or FALSE\n * @stable ICU 2.4\n */\n#define U_IS_SURROGATE(c) (((c)&0xfffff800)==0xd800)\n\n/**\n * Assuming c is a surrogate code point (U_IS_SURROGATE(c)),\n * is it a lead surrogate?\n * @param c 32-bit code point\n * @return TRUE or FALSE\n * @stable ICU 2.4\n */\n#define U_IS_SURROGATE_LEAD(c) (((c)&0x400)==0)\n\n/**\n * Assuming c is a surrogate code point (U_IS_SURROGATE(c)),\n * is it a trail surrogate?\n * @param c 32-bit code point\n * @return TRUE or FALSE\n * @stable ICU 4.2\n */\n#define U_IS_SURROGATE_TRAIL(c) (((c)&0x400)!=0)\n\n/* include the utfXX.h ------------------------------------------------------ */\n\n#if !U_NO_DEFAULT_INCLUDE_UTF_HEADERS\n\n#include \"unicode/utf8.h\"\n#include \"unicode/utf16.h\"\n\n/* utf_old.h contains deprecated, pre-ICU 2.4 definitions */\n#include \"unicode/utf_old.h\"\n\n#endif  /* !U_NO_DEFAULT_INCLUDE_UTF_HEADERS */\n\n#endif  /* __UTF_H__ */\n"
  },
  {
    "path": "deprecated/android/addons/icucompat/unicode/utf16.h",
    "content": "/*\n*******************************************************************************\n*\n*   Copyright (C) 1999-2011, International Business Machines\n*   Corporation and others.  All Rights Reserved.\n*\n*******************************************************************************\n*   file name:  utf16.h\n*   encoding:   US-ASCII\n*   tab size:   8 (not used)\n*   indentation:4\n*\n*   created on: 1999sep09\n*   created by: Markus W. Scherer\n*/\n\n/**\n * \\file\n * \\brief C API: 16-bit Unicode handling macros\n * \n * This file defines macros to deal with 16-bit Unicode (UTF-16) code units and strings.\n *\n * For more information see utf.h and the ICU User Guide Strings chapter\n * (http://userguide.icu-project.org/strings).\n *\n * <em>Usage:</em>\n * ICU coding guidelines for if() statements should be followed when using these macros.\n * Compound statements (curly braces {}) must be used  for if-else-while... \n * bodies and all macro statements should be terminated with semicolon.\n */\n\n#ifndef __UTF16_H__\n#define __UTF16_H__\n\n#include \"unicode/umachine.h\"\n#ifndef __UTF_H__\n#   include \"unicode/utf.h\"\n#endif\n\n/* single-code point definitions -------------------------------------------- */\n\n/**\n * Does this code unit alone encode a code point (BMP, not a surrogate)?\n * @param c 16-bit code unit\n * @return TRUE or FALSE\n * @stable ICU 2.4\n */\n#define U16_IS_SINGLE(c) !U_IS_SURROGATE(c)\n\n/**\n * Is this code unit a lead surrogate (U+d800..U+dbff)?\n * @param c 16-bit code unit\n * @return TRUE or FALSE\n * @stable ICU 2.4\n */\n#define U16_IS_LEAD(c) (((c)&0xfffffc00)==0xd800)\n\n/**\n * Is this code unit a trail surrogate (U+dc00..U+dfff)?\n * @param c 16-bit code unit\n * @return TRUE or FALSE\n * @stable ICU 2.4\n */\n#define U16_IS_TRAIL(c) (((c)&0xfffffc00)==0xdc00)\n\n/**\n * Is this code unit a surrogate (U+d800..U+dfff)?\n * @param c 16-bit code unit\n * @return TRUE or FALSE\n * @stable ICU 2.4\n */\n#define U16_IS_SURROGATE(c) U_IS_SURROGATE(c)\n\n/**\n * Assuming c is a surrogate code point (U16_IS_SURROGATE(c)),\n * is it a lead surrogate?\n * @param c 16-bit code unit\n * @return TRUE or FALSE\n * @stable ICU 2.4\n */\n#define U16_IS_SURROGATE_LEAD(c) (((c)&0x400)==0)\n\n/**\n * Assuming c is a surrogate code point (U16_IS_SURROGATE(c)),\n * is it a trail surrogate?\n * @param c 16-bit code unit\n * @return TRUE or FALSE\n * @stable ICU 4.2\n */\n#define U16_IS_SURROGATE_TRAIL(c) (((c)&0x400)!=0)\n\n/**\n * Helper constant for U16_GET_SUPPLEMENTARY.\n * @internal\n */\n#define U16_SURROGATE_OFFSET ((0xd800<<10UL)+0xdc00-0x10000)\n\n/**\n * Get a supplementary code point value (U+10000..U+10ffff)\n * from its lead and trail surrogates.\n * The result is undefined if the input values are not\n * lead and trail surrogates.\n *\n * @param lead lead surrogate (U+d800..U+dbff)\n * @param trail trail surrogate (U+dc00..U+dfff)\n * @return supplementary code point (U+10000..U+10ffff)\n * @stable ICU 2.4\n */\n#define U16_GET_SUPPLEMENTARY(lead, trail) \\\n    (((UChar32)(lead)<<10UL)+(UChar32)(trail)-U16_SURROGATE_OFFSET)\n\n\n/**\n * Get the lead surrogate (0xd800..0xdbff) for a\n * supplementary code point (0x10000..0x10ffff).\n * @param supplementary 32-bit code point (U+10000..U+10ffff)\n * @return lead surrogate (U+d800..U+dbff) for supplementary\n * @stable ICU 2.4\n */\n#define U16_LEAD(supplementary) (UChar)(((supplementary)>>10)+0xd7c0)\n\n/**\n * Get the trail surrogate (0xdc00..0xdfff) for a\n * supplementary code point (0x10000..0x10ffff).\n * @param supplementary 32-bit code point (U+10000..U+10ffff)\n * @return trail surrogate (U+dc00..U+dfff) for supplementary\n * @stable ICU 2.4\n */\n#define U16_TRAIL(supplementary) (UChar)(((supplementary)&0x3ff)|0xdc00)\n\n/**\n * How many 16-bit code units are used to encode this Unicode code point? (1 or 2)\n * The result is not defined if c is not a Unicode code point (U+0000..U+10ffff).\n * @param c 32-bit code point\n * @return 1 or 2\n * @stable ICU 2.4\n */\n#define U16_LENGTH(c) ((uint32_t)(c)<=0xffff ? 1 : 2)\n\n/**\n * The maximum number of 16-bit code units per Unicode code point (U+0000..U+10ffff).\n * @return 2\n * @stable ICU 2.4\n */\n#define U16_MAX_LENGTH 2\n\n/**\n * Get a code point from a string at a random-access offset,\n * without changing the offset.\n * \"Unsafe\" macro, assumes well-formed UTF-16.\n *\n * The offset may point to either the lead or trail surrogate unit\n * for a supplementary code point, in which case the macro will read\n * the adjacent matching surrogate as well.\n * The result is undefined if the offset points to a single, unpaired surrogate.\n * Iteration through a string is more efficient with U16_NEXT_UNSAFE or U16_NEXT.\n *\n * @param s const UChar * string\n * @param i string offset\n * @param c output UChar32 variable\n * @see U16_GET\n * @stable ICU 2.4\n */\n#define U16_GET_UNSAFE(s, i, c) { \\\n    (c)=(s)[i]; \\\n    if(U16_IS_SURROGATE(c)) { \\\n        if(U16_IS_SURROGATE_LEAD(c)) { \\\n            (c)=U16_GET_SUPPLEMENTARY((c), (s)[(i)+1]); \\\n        } else { \\\n            (c)=U16_GET_SUPPLEMENTARY((s)[(i)-1], (c)); \\\n        } \\\n    } \\\n}\n\n/**\n * Get a code point from a string at a random-access offset,\n * without changing the offset.\n * \"Safe\" macro, handles unpaired surrogates and checks for string boundaries.\n *\n * The offset may point to either the lead or trail surrogate unit\n * for a supplementary code point, in which case the macro will read\n * the adjacent matching surrogate as well.\n * If the offset points to a single, unpaired surrogate, then that itself\n * will be returned as the code point.\n * Iteration through a string is more efficient with U16_NEXT_UNSAFE or U16_NEXT.\n *\n * @param s const UChar * string\n * @param start starting string offset (usually 0)\n * @param i string offset, must be start<=i<length\n * @param length string length\n * @param c output UChar32 variable\n * @see U16_GET_UNSAFE\n * @stable ICU 2.4\n */\n#define U16_GET(s, start, i, length, c) { \\\n    (c)=(s)[i]; \\\n    if(U16_IS_SURROGATE(c)) { \\\n        uint16_t __c2; \\\n        if(U16_IS_SURROGATE_LEAD(c)) { \\\n            if((i)+1<(length) && U16_IS_TRAIL(__c2=(s)[(i)+1])) { \\\n                (c)=U16_GET_SUPPLEMENTARY((c), __c2); \\\n            } \\\n        } else { \\\n            if((i)>(start) && U16_IS_LEAD(__c2=(s)[(i)-1])) { \\\n                (c)=U16_GET_SUPPLEMENTARY(__c2, (c)); \\\n            } \\\n        } \\\n    } \\\n}\n\n/* definitions with forward iteration --------------------------------------- */\n\n/**\n * Get a code point from a string at a code point boundary offset,\n * and advance the offset to the next code point boundary.\n * (Post-incrementing forward iteration.)\n * \"Unsafe\" macro, assumes well-formed UTF-16.\n *\n * The offset may point to the lead surrogate unit\n * for a supplementary code point, in which case the macro will read\n * the following trail surrogate as well.\n * If the offset points to a trail surrogate, then that itself\n * will be returned as the code point.\n * The result is undefined if the offset points to a single, unpaired lead surrogate.\n *\n * @param s const UChar * string\n * @param i string offset\n * @param c output UChar32 variable\n * @see U16_NEXT\n * @stable ICU 2.4\n */\n#define U16_NEXT_UNSAFE(s, i, c) { \\\n    (c)=(s)[(i)++]; \\\n    if(U16_IS_LEAD(c)) { \\\n        (c)=U16_GET_SUPPLEMENTARY((c), (s)[(i)++]); \\\n    } \\\n}\n\n/**\n * Get a code point from a string at a code point boundary offset,\n * and advance the offset to the next code point boundary.\n * (Post-incrementing forward iteration.)\n * \"Safe\" macro, handles unpaired surrogates and checks for string boundaries.\n *\n * The offset may point to the lead surrogate unit\n * for a supplementary code point, in which case the macro will read\n * the following trail surrogate as well.\n * If the offset points to a trail surrogate or\n * to a single, unpaired lead surrogate, then that itself\n * will be returned as the code point.\n *\n * @param s const UChar * string\n * @param i string offset, must be i<length\n * @param length string length\n * @param c output UChar32 variable\n * @see U16_NEXT_UNSAFE\n * @stable ICU 2.4\n */\n#define U16_NEXT(s, i, length, c) { \\\n    (c)=(s)[(i)++]; \\\n    if(U16_IS_LEAD(c)) { \\\n        uint16_t __c2; \\\n        if((i)<(length) && U16_IS_TRAIL(__c2=(s)[(i)])) { \\\n            ++(i); \\\n            (c)=U16_GET_SUPPLEMENTARY((c), __c2); \\\n        } \\\n    } \\\n}\n\n/**\n * Append a code point to a string, overwriting 1 or 2 code units.\n * The offset points to the current end of the string contents\n * and is advanced (post-increment).\n * \"Unsafe\" macro, assumes a valid code point and sufficient space in the string.\n * Otherwise, the result is undefined.\n *\n * @param s const UChar * string buffer\n * @param i string offset\n * @param c code point to append\n * @see U16_APPEND\n * @stable ICU 2.4\n */\n#define U16_APPEND_UNSAFE(s, i, c) { \\\n    if((uint32_t)(c)<=0xffff) { \\\n        (s)[(i)++]=(uint16_t)(c); \\\n    } else { \\\n        (s)[(i)++]=(uint16_t)(((c)>>10)+0xd7c0); \\\n        (s)[(i)++]=(uint16_t)(((c)&0x3ff)|0xdc00); \\\n    } \\\n}\n\n/**\n * Append a code point to a string, overwriting 1 or 2 code units.\n * The offset points to the current end of the string contents\n * and is advanced (post-increment).\n * \"Safe\" macro, checks for a valid code point.\n * If a surrogate pair is written, checks for sufficient space in the string.\n * If the code point is not valid or a trail surrogate does not fit,\n * then isError is set to TRUE.\n *\n * @param s const UChar * string buffer\n * @param i string offset, must be i<capacity\n * @param capacity size of the string buffer\n * @param c code point to append\n * @param isError output UBool set to TRUE if an error occurs, otherwise not modified\n * @see U16_APPEND_UNSAFE\n * @stable ICU 2.4\n */\n#define U16_APPEND(s, i, capacity, c, isError) { \\\n    if((uint32_t)(c)<=0xffff) { \\\n        (s)[(i)++]=(uint16_t)(c); \\\n    } else if((uint32_t)(c)<=0x10ffff && (i)+1<(capacity)) { \\\n        (s)[(i)++]=(uint16_t)(((c)>>10)+0xd7c0); \\\n        (s)[(i)++]=(uint16_t)(((c)&0x3ff)|0xdc00); \\\n    } else /* c>0x10ffff or not enough space */ { \\\n        (isError)=TRUE; \\\n    } \\\n}\n\n/**\n * Advance the string offset from one code point boundary to the next.\n * (Post-incrementing iteration.)\n * \"Unsafe\" macro, assumes well-formed UTF-16.\n *\n * @param s const UChar * string\n * @param i string offset\n * @see U16_FWD_1\n * @stable ICU 2.4\n */\n#define U16_FWD_1_UNSAFE(s, i) { \\\n    if(U16_IS_LEAD((s)[(i)++])) { \\\n        ++(i); \\\n    } \\\n}\n\n/**\n * Advance the string offset from one code point boundary to the next.\n * (Post-incrementing iteration.)\n * \"Safe\" macro, handles unpaired surrogates and checks for string boundaries.\n *\n * @param s const UChar * string\n * @param i string offset, must be i<length\n * @param length string length\n * @see U16_FWD_1_UNSAFE\n * @stable ICU 2.4\n */\n#define U16_FWD_1(s, i, length) { \\\n    if(U16_IS_LEAD((s)[(i)++]) && (i)<(length) && U16_IS_TRAIL((s)[i])) { \\\n        ++(i); \\\n    } \\\n}\n\n/**\n * Advance the string offset from one code point boundary to the n-th next one,\n * i.e., move forward by n code points.\n * (Post-incrementing iteration.)\n * \"Unsafe\" macro, assumes well-formed UTF-16.\n *\n * @param s const UChar * string\n * @param i string offset\n * @param n number of code points to skip\n * @see U16_FWD_N\n * @stable ICU 2.4\n */\n#define U16_FWD_N_UNSAFE(s, i, n) { \\\n    int32_t __N=(n); \\\n    while(__N>0) { \\\n        U16_FWD_1_UNSAFE(s, i); \\\n        --__N; \\\n    } \\\n}\n\n/**\n * Advance the string offset from one code point boundary to the n-th next one,\n * i.e., move forward by n code points.\n * (Post-incrementing iteration.)\n * \"Safe\" macro, handles unpaired surrogates and checks for string boundaries.\n *\n * @param s const UChar * string\n * @param i string offset, must be i<length\n * @param length string length\n * @param n number of code points to skip\n * @see U16_FWD_N_UNSAFE\n * @stable ICU 2.4\n */\n#define U16_FWD_N(s, i, length, n) { \\\n    int32_t __N=(n); \\\n    while(__N>0 && (i)<(length)) { \\\n        U16_FWD_1(s, i, length); \\\n        --__N; \\\n    } \\\n}\n\n/**\n * Adjust a random-access offset to a code point boundary\n * at the start of a code point.\n * If the offset points to the trail surrogate of a surrogate pair,\n * then the offset is decremented.\n * Otherwise, it is not modified.\n * \"Unsafe\" macro, assumes well-formed UTF-16.\n *\n * @param s const UChar * string\n * @param i string offset\n * @see U16_SET_CP_START\n * @stable ICU 2.4\n */\n#define U16_SET_CP_START_UNSAFE(s, i) { \\\n    if(U16_IS_TRAIL((s)[i])) { \\\n        --(i); \\\n    } \\\n}\n\n/**\n * Adjust a random-access offset to a code point boundary\n * at the start of a code point.\n * If the offset points to the trail surrogate of a surrogate pair,\n * then the offset is decremented.\n * Otherwise, it is not modified.\n * \"Safe\" macro, handles unpaired surrogates and checks for string boundaries.\n *\n * @param s const UChar * string\n * @param start starting string offset (usually 0)\n * @param i string offset, must be start<=i\n * @see U16_SET_CP_START_UNSAFE\n * @stable ICU 2.4\n */\n#define U16_SET_CP_START(s, start, i) { \\\n    if(U16_IS_TRAIL((s)[i]) && (i)>(start) && U16_IS_LEAD((s)[(i)-1])) { \\\n        --(i); \\\n    } \\\n}\n\n/* definitions with backward iteration -------------------------------------- */\n\n/**\n * Move the string offset from one code point boundary to the previous one\n * and get the code point between them.\n * (Pre-decrementing backward iteration.)\n * \"Unsafe\" macro, assumes well-formed UTF-16.\n *\n * The input offset may be the same as the string length.\n * If the offset is behind a trail surrogate unit\n * for a supplementary code point, then the macro will read\n * the preceding lead surrogate as well.\n * If the offset is behind a lead surrogate, then that itself\n * will be returned as the code point.\n * The result is undefined if the offset is behind a single, unpaired trail surrogate.\n *\n * @param s const UChar * string\n * @param i string offset\n * @param c output UChar32 variable\n * @see U16_PREV\n * @stable ICU 2.4\n */\n#define U16_PREV_UNSAFE(s, i, c) { \\\n    (c)=(s)[--(i)]; \\\n    if(U16_IS_TRAIL(c)) { \\\n        (c)=U16_GET_SUPPLEMENTARY((s)[--(i)], (c)); \\\n    } \\\n}\n\n/**\n * Move the string offset from one code point boundary to the previous one\n * and get the code point between them.\n * (Pre-decrementing backward iteration.)\n * \"Safe\" macro, handles unpaired surrogates and checks for string boundaries.\n *\n * The input offset may be the same as the string length.\n * If the offset is behind a trail surrogate unit\n * for a supplementary code point, then the macro will read\n * the preceding lead surrogate as well.\n * If the offset is behind a lead surrogate or behind a single, unpaired\n * trail surrogate, then that itself\n * will be returned as the code point.\n *\n * @param s const UChar * string\n * @param start starting string offset (usually 0)\n * @param i string offset, must be start<i\n * @param c output UChar32 variable\n * @see U16_PREV_UNSAFE\n * @stable ICU 2.4\n */\n#define U16_PREV(s, start, i, c) { \\\n    (c)=(s)[--(i)]; \\\n    if(U16_IS_TRAIL(c)) { \\\n        uint16_t __c2; \\\n        if((i)>(start) && U16_IS_LEAD(__c2=(s)[(i)-1])) { \\\n            --(i); \\\n            (c)=U16_GET_SUPPLEMENTARY(__c2, (c)); \\\n        } \\\n    } \\\n}\n\n/**\n * Move the string offset from one code point boundary to the previous one.\n * (Pre-decrementing backward iteration.)\n * The input offset may be the same as the string length.\n * \"Unsafe\" macro, assumes well-formed UTF-16.\n *\n * @param s const UChar * string\n * @param i string offset\n * @see U16_BACK_1\n * @stable ICU 2.4\n */\n#define U16_BACK_1_UNSAFE(s, i) { \\\n    if(U16_IS_TRAIL((s)[--(i)])) { \\\n        --(i); \\\n    } \\\n}\n\n/**\n * Move the string offset from one code point boundary to the previous one.\n * (Pre-decrementing backward iteration.)\n * The input offset may be the same as the string length.\n * \"Safe\" macro, handles unpaired surrogates and checks for string boundaries.\n *\n * @param s const UChar * string\n * @param start starting string offset (usually 0)\n * @param i string offset, must be start<i\n * @see U16_BACK_1_UNSAFE\n * @stable ICU 2.4\n */\n#define U16_BACK_1(s, start, i) { \\\n    if(U16_IS_TRAIL((s)[--(i)]) && (i)>(start) && U16_IS_LEAD((s)[(i)-1])) { \\\n        --(i); \\\n    } \\\n}\n\n/**\n * Move the string offset from one code point boundary to the n-th one before it,\n * i.e., move backward by n code points.\n * (Pre-decrementing backward iteration.)\n * The input offset may be the same as the string length.\n * \"Unsafe\" macro, assumes well-formed UTF-16.\n *\n * @param s const UChar * string\n * @param i string offset\n * @param n number of code points to skip\n * @see U16_BACK_N\n * @stable ICU 2.4\n */\n#define U16_BACK_N_UNSAFE(s, i, n) { \\\n    int32_t __N=(n); \\\n    while(__N>0) { \\\n        U16_BACK_1_UNSAFE(s, i); \\\n        --__N; \\\n    } \\\n}\n\n/**\n * Move the string offset from one code point boundary to the n-th one before it,\n * i.e., move backward by n code points.\n * (Pre-decrementing backward iteration.)\n * The input offset may be the same as the string length.\n * \"Safe\" macro, handles unpaired surrogates and checks for string boundaries.\n *\n * @param s const UChar * string\n * @param start start of string\n * @param i string offset, must be start<i\n * @param n number of code points to skip\n * @see U16_BACK_N_UNSAFE\n * @stable ICU 2.4\n */\n#define U16_BACK_N(s, start, i, n) { \\\n    int32_t __N=(n); \\\n    while(__N>0 && (i)>(start)) { \\\n        U16_BACK_1(s, start, i); \\\n        --__N; \\\n    } \\\n}\n\n/**\n * Adjust a random-access offset to a code point boundary after a code point.\n * If the offset is behind the lead surrogate of a surrogate pair,\n * then the offset is incremented.\n * Otherwise, it is not modified.\n * The input offset may be the same as the string length.\n * \"Unsafe\" macro, assumes well-formed UTF-16.\n *\n * @param s const UChar * string\n * @param i string offset\n * @see U16_SET_CP_LIMIT\n * @stable ICU 2.4\n */\n#define U16_SET_CP_LIMIT_UNSAFE(s, i) { \\\n    if(U16_IS_LEAD((s)[(i)-1])) { \\\n        ++(i); \\\n    } \\\n}\n\n/**\n * Adjust a random-access offset to a code point boundary after a code point.\n * If the offset is behind the lead surrogate of a surrogate pair,\n * then the offset is incremented.\n * Otherwise, it is not modified.\n * The input offset may be the same as the string length.\n * \"Safe\" macro, handles unpaired surrogates and checks for string boundaries.\n *\n * @param s const UChar * string\n * @param start starting string offset (usually 0)\n * @param i string offset, start<=i<=length\n * @param length string length\n * @see U16_SET_CP_LIMIT_UNSAFE\n * @stable ICU 2.4\n */\n#define U16_SET_CP_LIMIT(s, start, i, length) { \\\n    if((start)<(i) && (i)<(length) && U16_IS_LEAD((s)[(i)-1]) && U16_IS_TRAIL((s)[i])) { \\\n        ++(i); \\\n    } \\\n}\n\n#endif\n"
  },
  {
    "path": "deprecated/android/addons/icucompat/unicode/utf32.h",
    "content": "/*\n*******************************************************************************\n*\n*   Copyright (C) 1999-2001, International Business Machines\n*   Corporation and others.  All Rights Reserved.\n*\n*******************************************************************************\n*   file name:  utf32.h\n*   encoding:   US-ASCII\n*   tab size:   8 (not used)\n*   indentation:4\n*\n*   created on: 1999sep20\n*   created by: Markus W. Scherer\n*/\n/**\n * \\file\n * \\brief C API: UTF-32 macros\n *\n * This file is obsolete and its contents moved to utf_old.h.\n * See utf_old.h and Jitterbug 2150 and its discussion on the ICU mailing list\n * in September 2002.\n */\n"
  },
  {
    "path": "deprecated/android/addons/icucompat/unicode/utf8.h",
    "content": "/*\n*******************************************************************************\n*\n*   Copyright (C) 1999-2012, International Business Machines\n*   Corporation and others.  All Rights Reserved.\n*\n*******************************************************************************\n*   file name:  utf8.h\n*   encoding:   US-ASCII\n*   tab size:   8 (not used)\n*   indentation:4\n*\n*   created on: 1999sep13\n*   created by: Markus W. Scherer\n*/\n\n/**\n * \\file\n * \\brief C API: 8-bit Unicode handling macros\n * \n * This file defines macros to deal with 8-bit Unicode (UTF-8) code units (bytes) and strings.\n *\n * For more information see utf.h and the ICU User Guide Strings chapter\n * (http://userguide.icu-project.org/strings).\n *\n * <em>Usage:</em>\n * ICU coding guidelines for if() statements should be followed when using these macros.\n * Compound statements (curly braces {}) must be used  for if-else-while... \n * bodies and all macro statements should be terminated with semicolon.\n */\n\n#ifndef __UTF8_H__\n#define __UTF8_H__\n\n#include \"unicode/umachine.h\"\n#ifndef __UTF_H__\n#   include \"unicode/utf.h\"\n#endif\n\n/* internal definitions ----------------------------------------------------- */\n\n/**\n * \\var utf8_countTrailBytes\n * Internal array with numbers of trail bytes for any given byte used in\n * lead byte position.\n *\n * This is internal since it is not meant to be called directly by external clients;\n * however it is called by public macros in this file and thus must remain stable,\n * and should not be hidden when other internal functions are hidden (otherwise\n * public macros would fail to compile).\n * @internal\n */\n#ifdef U_UTF8_IMPL\nU_EXPORT const uint8_t \n#elif defined(U_STATIC_IMPLEMENTATION) || defined(U_COMMON_IMPLEMENTATION)\nU_CFUNC const uint8_t\n#else\nU_CFUNC U_IMPORT const uint8_t /* U_IMPORT2? */ /*U_IMPORT*/ \n#endif\nutf8_countTrailBytes[256];\n\n/**\n * Counts the trail bytes for a UTF-8 lead byte.\n * Returns 0 for 0..0xbf as well as for 0xfe and 0xff.\n *\n * This is internal since it is not meant to be called directly by external clients;\n * however it is called by public macros in this file and thus must remain stable.\n *\n * Note: Beginning with ICU 50, the implementation uses a multi-condition expression\n * which was shown in 2012 (on x86-64) to compile to fast, branch-free code.\n * leadByte is evaluated multiple times.\n *\n * The pre-ICU 50 implementation used the exported array utf8_countTrailBytes:\n * #define U8_COUNT_TRAIL_BYTES(leadByte) (utf8_countTrailBytes[leadByte])\n * leadByte was evaluated exactly once.\n *\n * @param leadByte The first byte of a UTF-8 sequence. Must be 0..0xff.\n * @internal\n */\n#define U8_COUNT_TRAIL_BYTES(leadByte) \\\n    ((leadByte)<0xf0 ? \\\n        ((leadByte)>=0xc0)+((leadByte)>=0xe0) : \\\n        (leadByte)<0xfe ? 3+((leadByte)>=0xf8)+((leadByte)>=0xfc) : 0)\n\n/**\n * Counts the trail bytes for a UTF-8 lead byte of a valid UTF-8 sequence.\n * The maximum supported lead byte is 0xf4 corresponding to U+10FFFF.\n * leadByte might be evaluated multiple times.\n *\n * This is internal since it is not meant to be called directly by external clients;\n * however it is called by public macros in this file and thus must remain stable.\n *\n * @param leadByte The first byte of a UTF-8 sequence. Must be 0..0xff.\n * @internal\n */\n#define U8_COUNT_TRAIL_BYTES_UNSAFE(leadByte) \\\n    (((leadByte)>=0xc0)+((leadByte)>=0xe0)+((leadByte)>=0xf0))\n\n/**\n * Mask a UTF-8 lead byte, leave only the lower bits that form part of the code point value.\n *\n * This is internal since it is not meant to be called directly by external clients;\n * however it is called by public macros in this file and thus must remain stable.\n * @internal\n */\n#define U8_MASK_LEAD_BYTE(leadByte, countTrailBytes) ((leadByte)&=(1<<(6-(countTrailBytes)))-1)\n\n/**\n * Function for handling \"next code point\" with error-checking.\n *\n * This is internal since it is not meant to be called directly by external clients;\n * however it is U_STABLE (not U_INTERNAL) since it is called by public macros in this\n * file and thus must remain stable, and should not be hidden when other internal\n * functions are hidden (otherwise public macros would fail to compile).\n * @internal\n */\nU_STABLE UChar32 U_EXPORT2\nutf8_nextCharSafeBody(const uint8_t *s, int32_t *pi, int32_t length, UChar32 c, UBool strict);\n\n/**\n * Function for handling \"append code point\" with error-checking.\n *\n * This is internal since it is not meant to be called directly by external clients;\n * however it is U_STABLE (not U_INTERNAL) since it is called by public macros in this\n * file and thus must remain stable, and should not be hidden when other internal\n * functions are hidden (otherwise public macros would fail to compile).\n * @internal\n */\nU_STABLE int32_t U_EXPORT2\nutf8_appendCharSafeBody(uint8_t *s, int32_t i, int32_t length, UChar32 c, UBool *pIsError);\n\n/**\n * Function for handling \"previous code point\" with error-checking.\n *\n * This is internal since it is not meant to be called directly by external clients;\n * however it is U_STABLE (not U_INTERNAL) since it is called by public macros in this\n * file and thus must remain stable, and should not be hidden when other internal\n * functions are hidden (otherwise public macros would fail to compile).\n * @internal\n */\nU_STABLE UChar32 U_EXPORT2\nutf8_prevCharSafeBody(const uint8_t *s, int32_t start, int32_t *pi, UChar32 c, UBool strict);\n\n/**\n * Function for handling \"skip backward one code point\" with error-checking.\n *\n * This is internal since it is not meant to be called directly by external clients;\n * however it is U_STABLE (not U_INTERNAL) since it is called by public macros in this\n * file and thus must remain stable, and should not be hidden when other internal\n * functions are hidden (otherwise public macros would fail to compile).\n * @internal\n */\nU_STABLE int32_t U_EXPORT2\nutf8_back1SafeBody(const uint8_t *s, int32_t start, int32_t i);\n\n/* single-code point definitions -------------------------------------------- */\n\n/**\n * Does this code unit (byte) encode a code point by itself (US-ASCII 0..0x7f)?\n * @param c 8-bit code unit (byte)\n * @return TRUE or FALSE\n * @stable ICU 2.4\n */\n#define U8_IS_SINGLE(c) (((c)&0x80)==0)\n\n/**\n * Is this code unit (byte) a UTF-8 lead byte?\n * @param c 8-bit code unit (byte)\n * @return TRUE or FALSE\n * @stable ICU 2.4\n */\n#define U8_IS_LEAD(c) ((uint8_t)((c)-0xc0)<0x3e)\n\n/**\n * Is this code unit (byte) a UTF-8 trail byte?\n * @param c 8-bit code unit (byte)\n * @return TRUE or FALSE\n * @stable ICU 2.4\n */\n#define U8_IS_TRAIL(c) (((c)&0xc0)==0x80)\n\n/**\n * How many code units (bytes) are used for the UTF-8 encoding\n * of this Unicode code point?\n * @param c 32-bit code point\n * @return 1..4, or 0 if c is a surrogate or not a Unicode code point\n * @stable ICU 2.4\n */\n#define U8_LENGTH(c) \\\n    ((uint32_t)(c)<=0x7f ? 1 : \\\n        ((uint32_t)(c)<=0x7ff ? 2 : \\\n            ((uint32_t)(c)<=0xd7ff ? 3 : \\\n                ((uint32_t)(c)<=0xdfff || (uint32_t)(c)>0x10ffff ? 0 : \\\n                    ((uint32_t)(c)<=0xffff ? 3 : 4)\\\n                ) \\\n            ) \\\n        ) \\\n    )\n\n/**\n * The maximum number of UTF-8 code units (bytes) per Unicode code point (U+0000..U+10ffff).\n * @return 4\n * @stable ICU 2.4\n */\n#define U8_MAX_LENGTH 4\n\n/**\n * Get a code point from a string at a random-access offset,\n * without changing the offset.\n * The offset may point to either the lead byte or one of the trail bytes\n * for a code point, in which case the macro will read all of the bytes\n * for the code point.\n * The result is undefined if the offset points to an illegal UTF-8\n * byte sequence.\n * Iteration through a string is more efficient with U8_NEXT_UNSAFE or U8_NEXT.\n *\n * @param s const uint8_t * string\n * @param i string offset\n * @param c output UChar32 variable\n * @see U8_GET\n * @stable ICU 2.4\n */\n#define U8_GET_UNSAFE(s, i, c) { \\\n    int32_t _u8_get_unsafe_index=(int32_t)(i); \\\n    U8_SET_CP_START_UNSAFE(s, _u8_get_unsafe_index); \\\n    U8_NEXT_UNSAFE(s, _u8_get_unsafe_index, c); \\\n}\n\n/**\n * Get a code point from a string at a random-access offset,\n * without changing the offset.\n * The offset may point to either the lead byte or one of the trail bytes\n * for a code point, in which case the macro will read all of the bytes\n * for the code point.\n * If the offset points to an illegal UTF-8 byte sequence, then\n * c is set to a negative value.\n * Iteration through a string is more efficient with U8_NEXT_UNSAFE or U8_NEXT.\n *\n * @param s const uint8_t * string\n * @param start starting string offset\n * @param i string offset, must be start<=i<length\n * @param length string length\n * @param c output UChar32 variable, set to <0 in case of an error\n * @see U8_GET_UNSAFE\n * @stable ICU 2.4\n */\n#define U8_GET(s, start, i, length, c) { \\\n    int32_t _u8_get_index=(int32_t)(i); \\\n    U8_SET_CP_START(s, start, _u8_get_index); \\\n    U8_NEXT(s, _u8_get_index, length, c); \\\n}\n\n/* definitions with forward iteration --------------------------------------- */\n\n/**\n * Get a code point from a string at a code point boundary offset,\n * and advance the offset to the next code point boundary.\n * (Post-incrementing forward iteration.)\n * \"Unsafe\" macro, assumes well-formed UTF-8.\n *\n * The offset may point to the lead byte of a multi-byte sequence,\n * in which case the macro will read the whole sequence.\n * The result is undefined if the offset points to a trail byte\n * or an illegal UTF-8 sequence.\n *\n * @param s const uint8_t * string\n * @param i string offset\n * @param c output UChar32 variable\n * @see U8_NEXT\n * @stable ICU 2.4\n */\n#define U8_NEXT_UNSAFE(s, i, c) { \\\n    (c)=(uint8_t)(s)[(i)++]; \\\n    if((c)>=0x80) { \\\n        if((c)<0xe0) { \\\n            (c)=(((c)&0x1f)<<6)|((s)[(i)++]&0x3f); \\\n        } else if((c)<0xf0) { \\\n            /* no need for (c&0xf) because the upper bits are truncated after <<12 in the cast to (UChar) */ \\\n            (c)=(UChar)(((c)<<12)|(((s)[i]&0x3f)<<6)|((s)[(i)+1]&0x3f)); \\\n            (i)+=2; \\\n        } else { \\\n            (c)=(((c)&7)<<18)|(((s)[i]&0x3f)<<12)|(((s)[(i)+1]&0x3f)<<6)|((s)[(i)+2]&0x3f); \\\n            (i)+=3; \\\n        } \\\n    } \\\n}\n\n/**\n * Get a code point from a string at a code point boundary offset,\n * and advance the offset to the next code point boundary.\n * (Post-incrementing forward iteration.)\n * \"Safe\" macro, checks for illegal sequences and for string boundaries.\n *\n * The offset may point to the lead byte of a multi-byte sequence,\n * in which case the macro will read the whole sequence.\n * If the offset points to a trail byte or an illegal UTF-8 sequence, then\n * c is set to a negative value.\n *\n * @param s const uint8_t * string\n * @param i string offset, must be i<length\n * @param length string length\n * @param c output UChar32 variable, set to <0 in case of an error\n * @see U8_NEXT_UNSAFE\n * @stable ICU 2.4\n */\n#define U8_NEXT(s, i, length, c) { \\\n    (c)=(uint8_t)(s)[(i)++]; \\\n    if((c)>=0x80) { \\\n        uint8_t __t1, __t2; \\\n        if( /* handle U+1000..U+CFFF inline */ \\\n            (0xe0<(c) && (c)<=0xec) && \\\n            (((i)+1)<(length)) && \\\n            (__t1=(uint8_t)((s)[i]-0x80))<=0x3f && \\\n            (__t2=(uint8_t)((s)[(i)+1]-0x80))<= 0x3f \\\n        ) { \\\n            /* no need for (c&0xf) because the upper bits are truncated after <<12 in the cast to (UChar) */ \\\n            (c)=(UChar)(((c)<<12)|(__t1<<6)|__t2); \\\n            (i)+=2; \\\n        } else if( /* handle U+0080..U+07FF inline */ \\\n            ((c)<0xe0 && (c)>=0xc2) && \\\n            ((i)<(length)) && \\\n            (__t1=(uint8_t)((s)[i]-0x80))<=0x3f \\\n        ) { \\\n            (c)=(UChar)((((c)&0x1f)<<6)|__t1); \\\n            ++(i); \\\n        } else if(U8_IS_LEAD(c)) { \\\n            /* function call for \"complicated\" and error cases */ \\\n            (c)=utf8_nextCharSafeBody((const uint8_t *)s, &(i), (int32_t)(length), c, -1); \\\n        } else { \\\n            (c)=U_SENTINEL; \\\n        } \\\n    } \\\n}\n\n/**\n * Append a code point to a string, overwriting 1 to 4 bytes.\n * The offset points to the current end of the string contents\n * and is advanced (post-increment).\n * \"Unsafe\" macro, assumes a valid code point and sufficient space in the string.\n * Otherwise, the result is undefined.\n *\n * @param s const uint8_t * string buffer\n * @param i string offset\n * @param c code point to append\n * @see U8_APPEND\n * @stable ICU 2.4\n */\n#define U8_APPEND_UNSAFE(s, i, c) { \\\n    if((uint32_t)(c)<=0x7f) { \\\n        (s)[(i)++]=(uint8_t)(c); \\\n    } else { \\\n        if((uint32_t)(c)<=0x7ff) { \\\n            (s)[(i)++]=(uint8_t)(((c)>>6)|0xc0); \\\n        } else { \\\n            if((uint32_t)(c)<=0xffff) { \\\n                (s)[(i)++]=(uint8_t)(((c)>>12)|0xe0); \\\n            } else { \\\n                (s)[(i)++]=(uint8_t)(((c)>>18)|0xf0); \\\n                (s)[(i)++]=(uint8_t)((((c)>>12)&0x3f)|0x80); \\\n            } \\\n            (s)[(i)++]=(uint8_t)((((c)>>6)&0x3f)|0x80); \\\n        } \\\n        (s)[(i)++]=(uint8_t)(((c)&0x3f)|0x80); \\\n    } \\\n}\n\n/**\n * Append a code point to a string, overwriting 1 to 4 bytes.\n * The offset points to the current end of the string contents\n * and is advanced (post-increment).\n * \"Safe\" macro, checks for a valid code point.\n * If a non-ASCII code point is written, checks for sufficient space in the string.\n * If the code point is not valid or trail bytes do not fit,\n * then isError is set to TRUE.\n *\n * @param s const uint8_t * string buffer\n * @param i string offset, must be i<capacity\n * @param capacity size of the string buffer\n * @param c code point to append\n * @param isError output UBool set to TRUE if an error occurs, otherwise not modified\n * @see U8_APPEND_UNSAFE\n * @stable ICU 2.4\n */\n#define U8_APPEND(s, i, capacity, c, isError) { \\\n    if((uint32_t)(c)<=0x7f) { \\\n        (s)[(i)++]=(uint8_t)(c); \\\n    } else if((uint32_t)(c)<=0x7ff && (i)+1<(capacity)) { \\\n        (s)[(i)++]=(uint8_t)(((c)>>6)|0xc0); \\\n        (s)[(i)++]=(uint8_t)(((c)&0x3f)|0x80); \\\n    } else if((uint32_t)(c)<=0xd7ff && (i)+2<(capacity)) { \\\n        (s)[(i)++]=(uint8_t)(((c)>>12)|0xe0); \\\n        (s)[(i)++]=(uint8_t)((((c)>>6)&0x3f)|0x80); \\\n        (s)[(i)++]=(uint8_t)(((c)&0x3f)|0x80); \\\n    } else { \\\n        (i)=utf8_appendCharSafeBody(s, (int32_t)(i), (int32_t)(capacity), c, &(isError)); \\\n    } \\\n}\n\n/**\n * Advance the string offset from one code point boundary to the next.\n * (Post-incrementing iteration.)\n * \"Unsafe\" macro, assumes well-formed UTF-8.\n *\n * @param s const uint8_t * string\n * @param i string offset\n * @see U8_FWD_1\n * @stable ICU 2.4\n */\n#define U8_FWD_1_UNSAFE(s, i) { \\\n    (i)+=1+U8_COUNT_TRAIL_BYTES_UNSAFE((uint8_t)(s)[i]); \\\n}\n\n/**\n * Advance the string offset from one code point boundary to the next.\n * (Post-incrementing iteration.)\n * \"Safe\" macro, checks for illegal sequences and for string boundaries.\n *\n * @param s const uint8_t * string\n * @param i string offset, must be i<length\n * @param length string length\n * @see U8_FWD_1_UNSAFE\n * @stable ICU 2.4\n */\n#define U8_FWD_1(s, i, length) { \\\n    uint8_t __b=(uint8_t)(s)[(i)++]; \\\n    if(U8_IS_LEAD(__b)) { \\\n        uint8_t __count=U8_COUNT_TRAIL_BYTES(__b); \\\n        if((i)+__count>(length)) { \\\n            __count=(uint8_t)((length)-(i)); \\\n        } \\\n        while(__count>0 && U8_IS_TRAIL((s)[i])) { \\\n            ++(i); \\\n            --__count; \\\n        } \\\n    } \\\n}\n\n/**\n * Advance the string offset from one code point boundary to the n-th next one,\n * i.e., move forward by n code points.\n * (Post-incrementing iteration.)\n * \"Unsafe\" macro, assumes well-formed UTF-8.\n *\n * @param s const uint8_t * string\n * @param i string offset\n * @param n number of code points to skip\n * @see U8_FWD_N\n * @stable ICU 2.4\n */\n#define U8_FWD_N_UNSAFE(s, i, n) { \\\n    int32_t __N=(n); \\\n    while(__N>0) { \\\n        U8_FWD_1_UNSAFE(s, i); \\\n        --__N; \\\n    } \\\n}\n\n/**\n * Advance the string offset from one code point boundary to the n-th next one,\n * i.e., move forward by n code points.\n * (Post-incrementing iteration.)\n * \"Safe\" macro, checks for illegal sequences and for string boundaries.\n *\n * @param s const uint8_t * string\n * @param i string offset, must be i<length\n * @param length string length\n * @param n number of code points to skip\n * @see U8_FWD_N_UNSAFE\n * @stable ICU 2.4\n */\n#define U8_FWD_N(s, i, length, n) { \\\n    int32_t __N=(n); \\\n    while(__N>0 && (i)<(length)) { \\\n        U8_FWD_1(s, i, length); \\\n        --__N; \\\n    } \\\n}\n\n/**\n * Adjust a random-access offset to a code point boundary\n * at the start of a code point.\n * If the offset points to a UTF-8 trail byte,\n * then the offset is moved backward to the corresponding lead byte.\n * Otherwise, it is not modified.\n * \"Unsafe\" macro, assumes well-formed UTF-8.\n *\n * @param s const uint8_t * string\n * @param i string offset\n * @see U8_SET_CP_START\n * @stable ICU 2.4\n */\n#define U8_SET_CP_START_UNSAFE(s, i) { \\\n    while(U8_IS_TRAIL((s)[i])) { --(i); } \\\n}\n\n/**\n * Adjust a random-access offset to a code point boundary\n * at the start of a code point.\n * If the offset points to a UTF-8 trail byte,\n * then the offset is moved backward to the corresponding lead byte.\n * Otherwise, it is not modified.\n * \"Safe\" macro, checks for illegal sequences and for string boundaries.\n *\n * @param s const uint8_t * string\n * @param start starting string offset (usually 0)\n * @param i string offset, must be start<=i\n * @see U8_SET_CP_START_UNSAFE\n * @stable ICU 2.4\n */\n#define U8_SET_CP_START(s, start, i) { \\\n    if(U8_IS_TRAIL((s)[(i)])) { \\\n        (i)=utf8_back1SafeBody(s, start, (int32_t)(i)); \\\n    } \\\n}\n\n/* definitions with backward iteration -------------------------------------- */\n\n/**\n * Move the string offset from one code point boundary to the previous one\n * and get the code point between them.\n * (Pre-decrementing backward iteration.)\n * \"Unsafe\" macro, assumes well-formed UTF-8.\n *\n * The input offset may be the same as the string length.\n * If the offset is behind a multi-byte sequence, then the macro will read\n * the whole sequence.\n * If the offset is behind a lead byte, then that itself\n * will be returned as the code point.\n * The result is undefined if the offset is behind an illegal UTF-8 sequence.\n *\n * @param s const uint8_t * string\n * @param i string offset\n * @param c output UChar32 variable\n * @see U8_PREV\n * @stable ICU 2.4\n */\n#define U8_PREV_UNSAFE(s, i, c) { \\\n    (c)=(uint8_t)(s)[--(i)]; \\\n    if(U8_IS_TRAIL(c)) { \\\n        uint8_t __b, __count=1, __shift=6; \\\n\\\n        /* c is a trail byte */ \\\n        (c)&=0x3f; \\\n        for(;;) { \\\n            __b=(uint8_t)(s)[--(i)]; \\\n            if(__b>=0xc0) { \\\n                U8_MASK_LEAD_BYTE(__b, __count); \\\n                (c)|=(UChar32)__b<<__shift; \\\n                break; \\\n            } else { \\\n                (c)|=(UChar32)(__b&0x3f)<<__shift; \\\n                ++__count; \\\n                __shift+=6; \\\n            } \\\n        } \\\n    } \\\n}\n\n/**\n * Move the string offset from one code point boundary to the previous one\n * and get the code point between them.\n * (Pre-decrementing backward iteration.)\n * \"Safe\" macro, checks for illegal sequences and for string boundaries.\n *\n * The input offset may be the same as the string length.\n * If the offset is behind a multi-byte sequence, then the macro will read\n * the whole sequence.\n * If the offset is behind a lead byte, then that itself\n * will be returned as the code point.\n * If the offset is behind an illegal UTF-8 sequence, then c is set to a negative value.\n *\n * @param s const uint8_t * string\n * @param start starting string offset (usually 0)\n * @param i string offset, must be start<i\n * @param c output UChar32 variable, set to <0 in case of an error\n * @see U8_PREV_UNSAFE\n * @stable ICU 2.4\n */\n#define U8_PREV(s, start, i, c) { \\\n    (c)=(uint8_t)(s)[--(i)]; \\\n    if((c)>=0x80) { \\\n        if((c)<=0xbf) { \\\n            (c)=utf8_prevCharSafeBody((const uint8_t *)s, start, &(i), c, -1); \\\n        } else { \\\n            (c)=U_SENTINEL; \\\n        } \\\n    } \\\n}\n\n/**\n * Move the string offset from one code point boundary to the previous one.\n * (Pre-decrementing backward iteration.)\n * The input offset may be the same as the string length.\n * \"Unsafe\" macro, assumes well-formed UTF-8.\n *\n * @param s const uint8_t * string\n * @param i string offset\n * @see U8_BACK_1\n * @stable ICU 2.4\n */\n#define U8_BACK_1_UNSAFE(s, i) { \\\n    while(U8_IS_TRAIL((s)[--(i)])) {} \\\n}\n\n/**\n * Move the string offset from one code point boundary to the previous one.\n * (Pre-decrementing backward iteration.)\n * The input offset may be the same as the string length.\n * \"Safe\" macro, checks for illegal sequences and for string boundaries.\n *\n * @param s const uint8_t * string\n * @param start starting string offset (usually 0)\n * @param i string offset, must be start<i\n * @see U8_BACK_1_UNSAFE\n * @stable ICU 2.4\n */\n#define U8_BACK_1(s, start, i) { \\\n    if(U8_IS_TRAIL((s)[--(i)])) { \\\n        (i)=utf8_back1SafeBody(s, start, (int32_t)(i)); \\\n    } \\\n}\n\n/**\n * Move the string offset from one code point boundary to the n-th one before it,\n * i.e., move backward by n code points.\n * (Pre-decrementing backward iteration.)\n * The input offset may be the same as the string length.\n * \"Unsafe\" macro, assumes well-formed UTF-8.\n *\n * @param s const uint8_t * string\n * @param i string offset\n * @param n number of code points to skip\n * @see U8_BACK_N\n * @stable ICU 2.4\n */\n#define U8_BACK_N_UNSAFE(s, i, n) { \\\n    int32_t __N=(n); \\\n    while(__N>0) { \\\n        U8_BACK_1_UNSAFE(s, i); \\\n        --__N; \\\n    } \\\n}\n\n/**\n * Move the string offset from one code point boundary to the n-th one before it,\n * i.e., move backward by n code points.\n * (Pre-decrementing backward iteration.)\n * The input offset may be the same as the string length.\n * \"Safe\" macro, checks for illegal sequences and for string boundaries.\n *\n * @param s const uint8_t * string\n * @param start index of the start of the string\n * @param i string offset, must be start<i\n * @param n number of code points to skip\n * @see U8_BACK_N_UNSAFE\n * @stable ICU 2.4\n */\n#define U8_BACK_N(s, start, i, n) { \\\n    int32_t __N=(n); \\\n    while(__N>0 && (i)>(start)) { \\\n        U8_BACK_1(s, start, i); \\\n        --__N; \\\n    } \\\n}\n\n/**\n * Adjust a random-access offset to a code point boundary after a code point.\n * If the offset is behind a partial multi-byte sequence,\n * then the offset is incremented to behind the whole sequence.\n * Otherwise, it is not modified.\n * The input offset may be the same as the string length.\n * \"Unsafe\" macro, assumes well-formed UTF-8.\n *\n * @param s const uint8_t * string\n * @param i string offset\n * @see U8_SET_CP_LIMIT\n * @stable ICU 2.4\n */\n#define U8_SET_CP_LIMIT_UNSAFE(s, i) { \\\n    U8_BACK_1_UNSAFE(s, i); \\\n    U8_FWD_1_UNSAFE(s, i); \\\n}\n\n/**\n * Adjust a random-access offset to a code point boundary after a code point.\n * If the offset is behind a partial multi-byte sequence,\n * then the offset is incremented to behind the whole sequence.\n * Otherwise, it is not modified.\n * The input offset may be the same as the string length.\n * \"Safe\" macro, checks for illegal sequences and for string boundaries.\n *\n * @param s const uint8_t * string\n * @param start starting string offset (usually 0)\n * @param i string offset, must be start<=i<=length\n * @param length string length\n * @see U8_SET_CP_LIMIT_UNSAFE\n * @stable ICU 2.4\n */\n#define U8_SET_CP_LIMIT(s, start, i, length) { \\\n    if((start)<(i) && (i)<(length)) { \\\n        U8_BACK_1(s, start, i); \\\n        U8_FWD_1(s, i, length); \\\n    } \\\n}\n\n#endif\n"
  },
  {
    "path": "deprecated/android/addons/icucompat/unicode/utf_old.h",
    "content": "/*\n*******************************************************************************\n*\n*   Copyright (C) 2002-2012, International Business Machines\n*   Corporation and others.  All Rights Reserved.\n*\n*******************************************************************************\n*   file name:  utf_old.h\n*   encoding:   US-ASCII\n*   tab size:   8 (not used)\n*   indentation:4\n*\n*   created on: 2002sep21\n*   created by: Markus W. Scherer\n*/\n\n/**\n * \\file \n * \\brief C API: Deprecated macros for Unicode string handling\n */\n\n/**\n * \n * The macros in utf_old.h are all deprecated and their use discouraged.\n * Some of the design principles behind the set of UTF macros\n * have changed or proved impractical.\n * Almost all of the old \"UTF macros\" are at least renamed.\n * If you are looking for a new equivalent to an old macro, please see the\n * comment at the old one.\n *\n * Brief summary of reasons for deprecation:\n * - Switch on UTF_SIZE (selection of UTF-8/16/32 default string processing)\n *   was impractical.\n * - Switch on UTF_SAFE etc. (selection of unsafe/safe/strict default string processing)\n *   was of little use and impractical.\n * - Whole classes of macros became obsolete outside of the UTF_SIZE/UTF_SAFE\n *   selection framework: UTF32_ macros (all trivial)\n *   and UTF_ default and intermediate macros (all aliases).\n * - The selection framework also caused many macro aliases.\n * - Change in Unicode standard: \"irregular\" sequences (3.0) became illegal (3.2).\n * - Change of language in Unicode standard:\n *   Growing distinction between internal x-bit Unicode strings and external UTF-x\n *   forms, with the former more lenient.\n *   Suggests renaming of UTF16_ macros to U16_.\n * - The prefix \"UTF_\" without a width number confused some users.\n * - \"Safe\" append macros needed the addition of an error indicator output.\n * - \"Safe\" UTF-8 macros used legitimate (if rarely used) code point values\n *   to indicate error conditions.\n * - The use of the \"_CHAR\" infix for code point operations confused some users.\n *\n * More details:\n *\n * Until ICU 2.2, utf.h theoretically allowed to choose among UTF-8/16/32\n * for string processing, and among unsafe/safe/strict default macros for that.\n *\n * It proved nearly impossible to write non-trivial, high-performance code\n * that is UTF-generic.\n * Unsafe default macros would be dangerous for default string processing,\n * and the main reason for the \"strict\" versions disappeared:\n * Between Unicode 3.0 and 3.2 all \"irregular\" UTF-8 sequences became illegal.\n * The only other conditions that \"strict\" checked for were non-characters,\n * which are valid during processing. Only during text input/output should they\n * be checked, and at that time other well-formedness checks may be\n * necessary or useful as well.\n * This can still be done by using U16_NEXT and U_IS_UNICODE_NONCHAR\n * or U_IS_UNICODE_CHAR.\n *\n * The old UTF8_..._SAFE macros also used some normal Unicode code points\n * to indicate malformed sequences.\n * The new UTF8_ macros without suffix use negative values instead.\n *\n * The entire contents of utf32.h was moved here without replacement\n * because all those macros were trivial and\n * were meaningful only in the framework of choosing the UTF size.\n *\n * See Jitterbug 2150 and its discussion on the ICU mailing list\n * in September 2002.\n *\n * <hr>\n *\n * <em>Obsolete part</em> of pre-ICU 2.4 utf.h file documentation:\n *\n * <p>The original concept for these files was for ICU to allow\n * in principle to set which UTF (UTF-8/16/32) is used internally\n * by defining UTF_SIZE to either 8, 16, or 32. utf.h would then define the UChar type\n * accordingly. UTF-16 was the default.</p>\n *\n * <p>This concept has been abandoned.\n * A lot of the ICU source code assumes UChar strings are in UTF-16.\n * This is especially true for low-level code like\n * conversion, normalization, and collation.\n * The utf.h header enforces the default of UTF-16.\n * The UTF-8 and UTF-32 macros remain for now for completeness and backward compatibility.</p>\n *\n * <p>Accordingly, utf.h defines UChar to be an unsigned 16-bit integer. If this matches wchar_t, then\n * UChar is defined to be exactly wchar_t, otherwise uint16_t.</p>\n *\n * <p>UChar32 is defined to be a signed 32-bit integer (int32_t), large enough for a 21-bit\n * Unicode code point (Unicode scalar value, 0..0x10ffff).\n * Before ICU 2.4, the definition of UChar32 was similarly platform-dependent as\n * the definition of UChar. For details see the documentation for UChar32 itself.</p>\n *\n * <p>utf.h also defines a number of C macros for handling single Unicode code points and\n * for using UTF Unicode strings. It includes utf8.h, utf16.h, and utf32.h for the actual\n * implementations of those macros and then aliases one set of them (for UTF-16) for general use.\n * The UTF-specific macros have the UTF size in the macro name prefixes (UTF16_...), while\n * the general alias macros always begin with UTF_...</p>\n *\n * <p>Many string operations can be done with or without error checking.\n * Where such a distinction is useful, there are two versions of the macros, \"unsafe\" and \"safe\"\n * ones with ..._UNSAFE and ..._SAFE suffixes. The unsafe macros are fast but may cause\n * program failures if the strings are not well-formed. The safe macros have an additional, boolean\n * parameter \"strict\". If strict is FALSE, then only illegal sequences are detected.\n * Otherwise, irregular sequences and non-characters are detected as well (like single surrogates).\n * Safe macros return special error code points for illegal/irregular sequences:\n * Typically, U+ffff, or values that would result in a code unit sequence of the same length\n * as the erroneous input sequence.<br>\n * Note that _UNSAFE macros have fewer parameters: They do not have the strictness parameter, and\n * they do not have start/length parameters for boundary checking.</p>\n *\n * <p>Here, the macros are aliased in two steps:\n * In the first step, the UTF-specific macros with UTF16_ prefix and _UNSAFE and _SAFE suffixes are\n * aliased according to the UTF_SIZE to macros with UTF_ prefix and the same suffixes and signatures.\n * Then, in a second step, the default, general alias macros are set to use either the unsafe or\n * the safe/not strict (default) or the safe/strict macro;\n * these general macros do not have a strictness parameter.</p>\n *\n * <p>It is possible to change the default choice for the general alias macros to be unsafe, safe/not strict or safe/strict.\n * The default is safe/not strict. It is not recommended to select the unsafe macros as the basis for\n * Unicode string handling in ICU! To select this, define UTF_SAFE, UTF_STRICT, or UTF_UNSAFE.</p>\n *\n * <p>For general use, one should use the default, general macros with UTF_ prefix and no _SAFE/_UNSAFE suffix.\n * Only in some cases it may be necessary to control the choice of macro directly and use a less generic alias.\n * For example, if it can be assumed that a string is well-formed and the index will stay within the bounds,\n * then the _UNSAFE version may be used.\n * If a UTF-8 string is to be processed, then the macros with UTF8_ prefixes need to be used.</p>\n *\n * <hr>\n *\n * @deprecated ICU 2.4. Use the macros in utf.h, utf16.h, utf8.h instead.\n */\n\n#ifndef __UTF_OLD_H__\n#define __UTF_OLD_H__\n\n#ifndef U_HIDE_DEPRECATED_API\n\n#include \"unicode/utf.h\"\n#include \"unicode/utf8.h\"\n#include \"unicode/utf16.h\"\n\n/* Formerly utf.h, part 1 --------------------------------------------------- */\n\n#ifdef U_USE_UTF_DEPRECATES\n/**\n * Unicode string and array offset and index type.\n * ICU always counts Unicode code units (UChars) for\n * string offsets, indexes, and lengths, not Unicode code points.\n *\n * @obsolete ICU 2.6. Use int32_t directly instead since this API will be removed in that release.\n */\ntypedef int32_t UTextOffset;\n#endif\n\n/** Number of bits in a Unicode string code unit - ICU uses 16-bit Unicode. @deprecated ICU 2.4. Obsolete, see utf_old.h. */\n#define UTF_SIZE 16\n\n/**\n * The default choice for general Unicode string macros is to use the ..._SAFE macro implementations\n * with strict=FALSE.\n *\n * @deprecated ICU 2.4. Obsolete, see utf_old.h.\n */\n#define UTF_SAFE\n/** @deprecated ICU 2.4. Obsolete, see utf_old.h. */\n#undef UTF_UNSAFE\n/** @deprecated ICU 2.4. Obsolete, see utf_old.h. */\n#undef UTF_STRICT\n\n/**\n * UTF8_ERROR_VALUE_1 and UTF8_ERROR_VALUE_2 are special error values for UTF-8,\n * which need 1 or 2 bytes in UTF-8:\n * \\code\n * U+0015 = NAK = Negative Acknowledge, C0 control character\n * U+009f = highest C1 control character\n * \\endcode\n *\n * These are used by UTF8_..._SAFE macros so that they can return an error value\n * that needs the same number of code units (bytes) as were seen by\n * a macro. They should be tested with UTF_IS_ERROR() or UTF_IS_VALID().\n *\n * @deprecated ICU 2.4. Obsolete, see utf_old.h.\n */\n#define UTF8_ERROR_VALUE_1 0x15\n\n/**\n * See documentation on UTF8_ERROR_VALUE_1 for details.\n *\n * @deprecated ICU 2.4. Obsolete, see utf_old.h.\n */\n#define UTF8_ERROR_VALUE_2 0x9f\n\n/**\n * Error value for all UTFs. This code point value will be set by macros with error\n * checking if an error is detected.\n *\n * @deprecated ICU 2.4. Obsolete, see utf_old.h.\n */\n#define UTF_ERROR_VALUE 0xffff\n\n/**\n * Is a given 32-bit code an error value\n * as returned by one of the macros for any UTF?\n *\n * @deprecated ICU 2.4. Obsolete, see utf_old.h.\n */\n#define UTF_IS_ERROR(c) \\\n    (((c)&0xfffe)==0xfffe || (c)==UTF8_ERROR_VALUE_1 || (c)==UTF8_ERROR_VALUE_2)\n\n/**\n * This is a combined macro: Is c a valid Unicode value _and_ not an error code?\n *\n * @deprecated ICU 2.4. Obsolete, see utf_old.h.\n */\n#define UTF_IS_VALID(c) \\\n    (UTF_IS_UNICODE_CHAR(c) && \\\n     (c)!=UTF8_ERROR_VALUE_1 && (c)!=UTF8_ERROR_VALUE_2)\n\n/**\n * Is this code unit or code point a surrogate (U+d800..U+dfff)?\n * @deprecated ICU 2.4. Renamed to U_IS_SURROGATE and U16_IS_SURROGATE, see utf_old.h.\n */\n#define UTF_IS_SURROGATE(uchar) (((uchar)&0xfffff800)==0xd800)\n\n/**\n * Is a given 32-bit code point a Unicode noncharacter?\n *\n * @deprecated ICU 2.4. Renamed to U_IS_UNICODE_NONCHAR, see utf_old.h.\n */\n#define UTF_IS_UNICODE_NONCHAR(c) \\\n    ((c)>=0xfdd0 && \\\n     ((uint32_t)(c)<=0xfdef || ((c)&0xfffe)==0xfffe) && \\\n     (uint32_t)(c)<=0x10ffff)\n\n/**\n * Is a given 32-bit value a Unicode code point value (0..U+10ffff)\n * that can be assigned a character?\n *\n * Code points that are not characters include:\n * - single surrogate code points (U+d800..U+dfff, 2048 code points)\n * - the last two code points on each plane (U+__fffe and U+__ffff, 34 code points)\n * - U+fdd0..U+fdef (new with Unicode 3.1, 32 code points)\n * - the highest Unicode code point value is U+10ffff\n *\n * This means that all code points below U+d800 are character code points,\n * and that boundary is tested first for performance.\n *\n * @deprecated ICU 2.4. Renamed to U_IS_UNICODE_CHAR, see utf_old.h.\n */\n#define UTF_IS_UNICODE_CHAR(c) \\\n    ((uint32_t)(c)<0xd800 || \\\n        ((uint32_t)(c)>0xdfff && \\\n         (uint32_t)(c)<=0x10ffff && \\\n         !UTF_IS_UNICODE_NONCHAR(c)))\n\n/* Formerly utf8.h ---------------------------------------------------------- */\n\n/**\n * Count the trail bytes for a UTF-8 lead byte.\n * @deprecated ICU 2.4. Renamed to U8_COUNT_TRAIL_BYTES, see utf_old.h.\n */\n#define UTF8_COUNT_TRAIL_BYTES(leadByte) (utf8_countTrailBytes[(uint8_t)leadByte])\n\n/**\n * Mask a UTF-8 lead byte, leave only the lower bits that form part of the code point value.\n * @deprecated ICU 2.4. Renamed to U8_MASK_LEAD_BYTE, see utf_old.h.\n */\n#define UTF8_MASK_LEAD_BYTE(leadByte, countTrailBytes) ((leadByte)&=(1<<(6-(countTrailBytes)))-1)\n\n/** Is this this code point a single code unit (byte)? @deprecated ICU 2.4. Renamed to U8_IS_SINGLE, see utf_old.h. */\n#define UTF8_IS_SINGLE(uchar) (((uchar)&0x80)==0)\n/** Is this this code unit the lead code unit (byte) of a code point? @deprecated ICU 2.4. Renamed to U8_IS_LEAD, see utf_old.h. */\n#define UTF8_IS_LEAD(uchar) ((uint8_t)((uchar)-0xc0)<0x3e)\n/** Is this this code unit a trailing code unit (byte) of a code point? @deprecated ICU 2.4. Renamed to U8_IS_TRAIL, see utf_old.h. */\n#define UTF8_IS_TRAIL(uchar) (((uchar)&0xc0)==0x80)\n\n/** Does this scalar Unicode value need multiple code units for storage? @deprecated ICU 2.4. Use U8_LENGTH or test ((uint32_t)(c)>0x7f) instead, see utf_old.h. */\n#define UTF8_NEED_MULTIPLE_UCHAR(c) ((uint32_t)(c)>0x7f)\n\n/**\n * Given the lead character, how many bytes are taken by this code point.\n * ICU does not deal with code points >0x10ffff\n * unless necessary for advancing in the byte stream.\n *\n * These length macros take into account that for values >0x10ffff\n * the UTF8_APPEND_CHAR_SAFE macros would write the error code point 0xffff\n * with 3 bytes.\n * Code point comparisons need to be in uint32_t because UChar32\n * may be a signed type, and negative values must be recognized.\n *\n * @deprecated ICU 2.4. Use U8_LENGTH instead, see utf.h.\n */\n#if 1\n#   define UTF8_CHAR_LENGTH(c) \\\n        ((uint32_t)(c)<=0x7f ? 1 : \\\n            ((uint32_t)(c)<=0x7ff ? 2 : \\\n                ((uint32_t)((c)-0x10000)>0xfffff ? 3 : 4) \\\n            ) \\\n        )\n#else\n#   define UTF8_CHAR_LENGTH(c) \\\n        ((uint32_t)(c)<=0x7f ? 1 : \\\n            ((uint32_t)(c)<=0x7ff ? 2 : \\\n                ((uint32_t)(c)<=0xffff ? 3 : \\\n                    ((uint32_t)(c)<=0x10ffff ? 4 : \\\n                        ((uint32_t)(c)<=0x3ffffff ? 5 : \\\n                            ((uint32_t)(c)<=0x7fffffff ? 6 : 3) \\\n                        ) \\\n                    ) \\\n                ) \\\n            ) \\\n        )\n#endif\n\n/** The maximum number of bytes per code point. @deprecated ICU 2.4. Renamed to U8_MAX_LENGTH, see utf_old.h. */\n#define UTF8_MAX_CHAR_LENGTH 4\n\n/** Average number of code units compared to UTF-16. @deprecated ICU 2.4. Obsolete, see utf_old.h. */\n#define UTF8_ARRAY_SIZE(size) ((5*(size))/2)\n\n/** @deprecated ICU 2.4. Renamed to U8_GET_UNSAFE, see utf_old.h. */\n#define UTF8_GET_CHAR_UNSAFE(s, i, c) { \\\n    int32_t _utf8_get_char_unsafe_index=(int32_t)(i); \\\n    UTF8_SET_CHAR_START_UNSAFE(s, _utf8_get_char_unsafe_index); \\\n    UTF8_NEXT_CHAR_UNSAFE(s, _utf8_get_char_unsafe_index, c); \\\n}\n\n/** @deprecated ICU 2.4. Use U8_GET instead, see utf_old.h. */\n#define UTF8_GET_CHAR_SAFE(s, start, i, length, c, strict) { \\\n    int32_t _utf8_get_char_safe_index=(int32_t)(i); \\\n    UTF8_SET_CHAR_START_SAFE(s, start, _utf8_get_char_safe_index); \\\n    UTF8_NEXT_CHAR_SAFE(s, _utf8_get_char_safe_index, length, c, strict); \\\n}\n\n/** @deprecated ICU 2.4. Renamed to U8_NEXT_UNSAFE, see utf_old.h. */\n#define UTF8_NEXT_CHAR_UNSAFE(s, i, c) { \\\n    (c)=(s)[(i)++]; \\\n    if((uint8_t)((c)-0xc0)<0x35) { \\\n        uint8_t __count=UTF8_COUNT_TRAIL_BYTES(c); \\\n        UTF8_MASK_LEAD_BYTE(c, __count); \\\n        switch(__count) { \\\n        /* each following branch falls through to the next one */ \\\n        case 3: \\\n            (c)=((c)<<6)|((s)[(i)++]&0x3f); \\\n        case 2: \\\n            (c)=((c)<<6)|((s)[(i)++]&0x3f); \\\n        case 1: \\\n            (c)=((c)<<6)|((s)[(i)++]&0x3f); \\\n        /* no other branches to optimize switch() */ \\\n            break; \\\n        } \\\n    } \\\n}\n\n/** @deprecated ICU 2.4. Renamed to U8_APPEND_UNSAFE, see utf_old.h. */\n#define UTF8_APPEND_CHAR_UNSAFE(s, i, c) { \\\n    if((uint32_t)(c)<=0x7f) { \\\n        (s)[(i)++]=(uint8_t)(c); \\\n    } else { \\\n        if((uint32_t)(c)<=0x7ff) { \\\n            (s)[(i)++]=(uint8_t)(((c)>>6)|0xc0); \\\n        } else { \\\n            if((uint32_t)(c)<=0xffff) { \\\n                (s)[(i)++]=(uint8_t)(((c)>>12)|0xe0); \\\n            } else { \\\n                (s)[(i)++]=(uint8_t)(((c)>>18)|0xf0); \\\n                (s)[(i)++]=(uint8_t)((((c)>>12)&0x3f)|0x80); \\\n            } \\\n            (s)[(i)++]=(uint8_t)((((c)>>6)&0x3f)|0x80); \\\n        } \\\n        (s)[(i)++]=(uint8_t)(((c)&0x3f)|0x80); \\\n    } \\\n}\n\n/** @deprecated ICU 2.4. Renamed to U8_FWD_1_UNSAFE, see utf_old.h. */\n#define UTF8_FWD_1_UNSAFE(s, i) { \\\n    (i)+=1+UTF8_COUNT_TRAIL_BYTES((s)[i]); \\\n}\n\n/** @deprecated ICU 2.4. Renamed to U8_FWD_N_UNSAFE, see utf_old.h. */\n#define UTF8_FWD_N_UNSAFE(s, i, n) { \\\n    int32_t __N=(n); \\\n    while(__N>0) { \\\n        UTF8_FWD_1_UNSAFE(s, i); \\\n        --__N; \\\n    } \\\n}\n\n/** @deprecated ICU 2.4. Renamed to U8_SET_CP_START_UNSAFE, see utf_old.h. */\n#define UTF8_SET_CHAR_START_UNSAFE(s, i) { \\\n    while(UTF8_IS_TRAIL((s)[i])) { --(i); } \\\n}\n\n/** @deprecated ICU 2.4. Use U8_NEXT instead, see utf_old.h. */\n#define UTF8_NEXT_CHAR_SAFE(s, i, length, c, strict) { \\\n    (c)=(s)[(i)++]; \\\n    if((c)>=0x80) { \\\n        if(UTF8_IS_LEAD(c)) { \\\n            (c)=utf8_nextCharSafeBody(s, &(i), (int32_t)(length), c, strict); \\\n        } else { \\\n            (c)=UTF8_ERROR_VALUE_1; \\\n        } \\\n    } \\\n}\n\n/** @deprecated ICU 2.4. Use U8_APPEND instead, see utf_old.h. */\n#define UTF8_APPEND_CHAR_SAFE(s, i, length, c)  { \\\n    if((uint32_t)(c)<=0x7f) { \\\n        (s)[(i)++]=(uint8_t)(c); \\\n    } else { \\\n        (i)=utf8_appendCharSafeBody(s, (int32_t)(i), (int32_t)(length), c, NULL); \\\n    } \\\n}\n\n/** @deprecated ICU 2.4. Renamed to U8_FWD_1, see utf_old.h. */\n#define UTF8_FWD_1_SAFE(s, i, length) U8_FWD_1(s, i, length)\n\n/** @deprecated ICU 2.4. Renamed to U8_FWD_N, see utf_old.h. */\n#define UTF8_FWD_N_SAFE(s, i, length, n) U8_FWD_N(s, i, length, n)\n\n/** @deprecated ICU 2.4. Renamed to U8_SET_CP_START, see utf_old.h. */\n#define UTF8_SET_CHAR_START_SAFE(s, start, i) U8_SET_CP_START(s, start, i)\n\n/** @deprecated ICU 2.4. Renamed to U8_PREV_UNSAFE, see utf_old.h. */\n#define UTF8_PREV_CHAR_UNSAFE(s, i, c) { \\\n    (c)=(s)[--(i)]; \\\n    if(UTF8_IS_TRAIL(c)) { \\\n        uint8_t __b, __count=1, __shift=6; \\\n\\\n        /* c is a trail byte */ \\\n        (c)&=0x3f; \\\n        for(;;) { \\\n            __b=(s)[--(i)]; \\\n            if(__b>=0xc0) { \\\n                UTF8_MASK_LEAD_BYTE(__b, __count); \\\n                (c)|=(UChar32)__b<<__shift; \\\n                break; \\\n            } else { \\\n                (c)|=(UChar32)(__b&0x3f)<<__shift; \\\n                ++__count; \\\n                __shift+=6; \\\n            } \\\n        } \\\n    } \\\n}\n\n/** @deprecated ICU 2.4. Renamed to U8_BACK_1_UNSAFE, see utf_old.h. */\n#define UTF8_BACK_1_UNSAFE(s, i) { \\\n    while(UTF8_IS_TRAIL((s)[--(i)])) {} \\\n}\n\n/** @deprecated ICU 2.4. Renamed to U8_BACK_N_UNSAFE, see utf_old.h. */\n#define UTF8_BACK_N_UNSAFE(s, i, n) { \\\n    int32_t __N=(n); \\\n    while(__N>0) { \\\n        UTF8_BACK_1_UNSAFE(s, i); \\\n        --__N; \\\n    } \\\n}\n\n/** @deprecated ICU 2.4. Renamed to U8_SET_CP_LIMIT_UNSAFE, see utf_old.h. */\n#define UTF8_SET_CHAR_LIMIT_UNSAFE(s, i) { \\\n    UTF8_BACK_1_UNSAFE(s, i); \\\n    UTF8_FWD_1_UNSAFE(s, i); \\\n}\n\n/** @deprecated ICU 2.4. Use U8_PREV instead, see utf_old.h. */\n#define UTF8_PREV_CHAR_SAFE(s, start, i, c, strict) { \\\n    (c)=(s)[--(i)]; \\\n    if((c)>=0x80) { \\\n        if((c)<=0xbf) { \\\n            (c)=utf8_prevCharSafeBody(s, start, &(i), c, strict); \\\n        } else { \\\n            (c)=UTF8_ERROR_VALUE_1; \\\n        } \\\n    } \\\n}\n\n/** @deprecated ICU 2.4. Renamed to U8_BACK_1, see utf_old.h. */\n#define UTF8_BACK_1_SAFE(s, start, i) U8_BACK_1(s, start, i)\n\n/** @deprecated ICU 2.4. Renamed to U8_BACK_N, see utf_old.h. */\n#define UTF8_BACK_N_SAFE(s, start, i, n) U8_BACK_N(s, start, i, n)\n\n/** @deprecated ICU 2.4. Renamed to U8_SET_CP_LIMIT, see utf_old.h. */\n#define UTF8_SET_CHAR_LIMIT_SAFE(s, start, i, length) U8_SET_CP_LIMIT(s, start, i, length)\n\n/* Formerly utf16.h --------------------------------------------------------- */\n\n/** Is uchar a first/lead surrogate? @deprecated ICU 2.4. Renamed to U_IS_LEAD and U16_IS_LEAD, see utf_old.h. */\n#define UTF_IS_FIRST_SURROGATE(uchar) (((uchar)&0xfffffc00)==0xd800)\n\n/** Is uchar a second/trail surrogate? @deprecated ICU 2.4. Renamed to U_IS_TRAIL and U16_IS_TRAIL, see utf_old.h. */\n#define UTF_IS_SECOND_SURROGATE(uchar) (((uchar)&0xfffffc00)==0xdc00)\n\n/** Assuming c is a surrogate, is it a first/lead surrogate? @deprecated ICU 2.4. Renamed to U_IS_SURROGATE_LEAD and U16_IS_SURROGATE_LEAD, see utf_old.h. */\n#define UTF_IS_SURROGATE_FIRST(c) (((c)&0x400)==0)\n\n/** Helper constant for UTF16_GET_PAIR_VALUE. @deprecated ICU 2.4. Renamed to U16_SURROGATE_OFFSET, see utf_old.h. */\n#define UTF_SURROGATE_OFFSET ((0xd800<<10UL)+0xdc00-0x10000)\n\n/** Get the UTF-32 value from the surrogate code units. @deprecated ICU 2.4. Renamed to U16_GET_SUPPLEMENTARY, see utf_old.h. */\n#define UTF16_GET_PAIR_VALUE(first, second) \\\n    (((first)<<10UL)+(second)-UTF_SURROGATE_OFFSET)\n\n/** @deprecated ICU 2.4. Renamed to U16_LEAD, see utf_old.h. */\n#define UTF_FIRST_SURROGATE(supplementary) (UChar)(((supplementary)>>10)+0xd7c0)\n\n/** @deprecated ICU 2.4. Renamed to U16_TRAIL, see utf_old.h. */\n#define UTF_SECOND_SURROGATE(supplementary) (UChar)(((supplementary)&0x3ff)|0xdc00)\n\n/** @deprecated ICU 2.4. Renamed to U16_LEAD, see utf_old.h. */\n#define UTF16_LEAD(supplementary) UTF_FIRST_SURROGATE(supplementary)\n\n/** @deprecated ICU 2.4. Renamed to U16_TRAIL, see utf_old.h. */\n#define UTF16_TRAIL(supplementary) UTF_SECOND_SURROGATE(supplementary)\n\n/** @deprecated ICU 2.4. Renamed to U16_IS_SINGLE, see utf_old.h. */\n#define UTF16_IS_SINGLE(uchar) !UTF_IS_SURROGATE(uchar)\n\n/** @deprecated ICU 2.4. Renamed to U16_IS_LEAD, see utf_old.h. */\n#define UTF16_IS_LEAD(uchar) UTF_IS_FIRST_SURROGATE(uchar)\n\n/** @deprecated ICU 2.4. Renamed to U16_IS_TRAIL, see utf_old.h. */\n#define UTF16_IS_TRAIL(uchar) UTF_IS_SECOND_SURROGATE(uchar)\n\n/** Does this scalar Unicode value need multiple code units for storage? @deprecated ICU 2.4. Use U16_LENGTH or test ((uint32_t)(c)>0xffff) instead, see utf_old.h. */\n#define UTF16_NEED_MULTIPLE_UCHAR(c) ((uint32_t)(c)>0xffff)\n\n/** @deprecated ICU 2.4. Renamed to U16_LENGTH, see utf_old.h. */\n#define UTF16_CHAR_LENGTH(c) ((uint32_t)(c)<=0xffff ? 1 : 2)\n\n/** @deprecated ICU 2.4. Renamed to U16_MAX_LENGTH, see utf_old.h. */\n#define UTF16_MAX_CHAR_LENGTH 2\n\n/** Average number of code units compared to UTF-16. @deprecated ICU 2.4. Obsolete, see utf_old.h. */\n#define UTF16_ARRAY_SIZE(size) (size)\n\n/**\n * Get a single code point from an offset that points to any\n * of the code units that belong to that code point.\n * Assume 0<=i<length.\n *\n * This could be used for iteration together with\n * UTF16_CHAR_LENGTH() and UTF_IS_ERROR(),\n * but the use of UTF16_NEXT_CHAR[_UNSAFE]() and\n * UTF16_PREV_CHAR[_UNSAFE]() is more efficient for that.\n * @deprecated ICU 2.4. Renamed to U16_GET_UNSAFE, see utf_old.h.\n */\n#define UTF16_GET_CHAR_UNSAFE(s, i, c) { \\\n    (c)=(s)[i]; \\\n    if(UTF_IS_SURROGATE(c)) { \\\n        if(UTF_IS_SURROGATE_FIRST(c)) { \\\n            (c)=UTF16_GET_PAIR_VALUE((c), (s)[(i)+1]); \\\n        } else { \\\n            (c)=UTF16_GET_PAIR_VALUE((s)[(i)-1], (c)); \\\n        } \\\n    } \\\n}\n\n/** @deprecated ICU 2.4. Use U16_GET instead, see utf_old.h. */\n#define UTF16_GET_CHAR_SAFE(s, start, i, length, c, strict) { \\\n    (c)=(s)[i]; \\\n    if(UTF_IS_SURROGATE(c)) { \\\n        uint16_t __c2; \\\n        if(UTF_IS_SURROGATE_FIRST(c)) { \\\n            if((i)+1<(length) && UTF_IS_SECOND_SURROGATE(__c2=(s)[(i)+1])) { \\\n                (c)=UTF16_GET_PAIR_VALUE((c), __c2); \\\n                /* strict: ((c)&0xfffe)==0xfffe is caught by UTF_IS_ERROR() and UTF_IS_UNICODE_CHAR() */ \\\n            } else if(strict) {\\\n                /* unmatched first surrogate */ \\\n                (c)=UTF_ERROR_VALUE; \\\n            } \\\n        } else { \\\n            if((i)-1>=(start) && UTF_IS_FIRST_SURROGATE(__c2=(s)[(i)-1])) { \\\n                (c)=UTF16_GET_PAIR_VALUE(__c2, (c)); \\\n                /* strict: ((c)&0xfffe)==0xfffe is caught by UTF_IS_ERROR() and UTF_IS_UNICODE_CHAR() */ \\\n            } else if(strict) {\\\n                /* unmatched second surrogate */ \\\n                (c)=UTF_ERROR_VALUE; \\\n            } \\\n        } \\\n    } else if((strict) && !UTF_IS_UNICODE_CHAR(c)) { \\\n        (c)=UTF_ERROR_VALUE; \\\n    } \\\n}\n\n/** @deprecated ICU 2.4. Renamed to U16_NEXT_UNSAFE, see utf_old.h. */\n#define UTF16_NEXT_CHAR_UNSAFE(s, i, c) { \\\n    (c)=(s)[(i)++]; \\\n    if(UTF_IS_FIRST_SURROGATE(c)) { \\\n        (c)=UTF16_GET_PAIR_VALUE((c), (s)[(i)++]); \\\n    } \\\n}\n\n/** @deprecated ICU 2.4. Renamed to U16_APPEND_UNSAFE, see utf_old.h. */\n#define UTF16_APPEND_CHAR_UNSAFE(s, i, c) { \\\n    if((uint32_t)(c)<=0xffff) { \\\n        (s)[(i)++]=(uint16_t)(c); \\\n    } else { \\\n        (s)[(i)++]=(uint16_t)(((c)>>10)+0xd7c0); \\\n        (s)[(i)++]=(uint16_t)(((c)&0x3ff)|0xdc00); \\\n    } \\\n}\n\n/** @deprecated ICU 2.4. Renamed to U16_FWD_1_UNSAFE, see utf_old.h. */\n#define UTF16_FWD_1_UNSAFE(s, i) { \\\n    if(UTF_IS_FIRST_SURROGATE((s)[(i)++])) { \\\n        ++(i); \\\n    } \\\n}\n\n/** @deprecated ICU 2.4. Renamed to U16_FWD_N_UNSAFE, see utf_old.h. */\n#define UTF16_FWD_N_UNSAFE(s, i, n) { \\\n    int32_t __N=(n); \\\n    while(__N>0) { \\\n        UTF16_FWD_1_UNSAFE(s, i); \\\n        --__N; \\\n    } \\\n}\n\n/** @deprecated ICU 2.4. Renamed to U16_SET_CP_START_UNSAFE, see utf_old.h. */\n#define UTF16_SET_CHAR_START_UNSAFE(s, i) { \\\n    if(UTF_IS_SECOND_SURROGATE((s)[i])) { \\\n        --(i); \\\n    } \\\n}\n\n/** @deprecated ICU 2.4. Use U16_NEXT instead, see utf_old.h. */\n#define UTF16_NEXT_CHAR_SAFE(s, i, length, c, strict) { \\\n    (c)=(s)[(i)++]; \\\n    if(UTF_IS_FIRST_SURROGATE(c)) { \\\n        uint16_t __c2; \\\n        if((i)<(length) && UTF_IS_SECOND_SURROGATE(__c2=(s)[(i)])) { \\\n            ++(i); \\\n            (c)=UTF16_GET_PAIR_VALUE((c), __c2); \\\n            /* strict: ((c)&0xfffe)==0xfffe is caught by UTF_IS_ERROR() and UTF_IS_UNICODE_CHAR() */ \\\n        } else if(strict) {\\\n            /* unmatched first surrogate */ \\\n            (c)=UTF_ERROR_VALUE; \\\n        } \\\n    } else if((strict) && !UTF_IS_UNICODE_CHAR(c)) { \\\n        /* unmatched second surrogate or other non-character */ \\\n        (c)=UTF_ERROR_VALUE; \\\n    } \\\n}\n\n/** @deprecated ICU 2.4. Use U16_APPEND instead, see utf_old.h. */\n#define UTF16_APPEND_CHAR_SAFE(s, i, length, c) { \\\n    if((uint32_t)(c)<=0xffff) { \\\n        (s)[(i)++]=(uint16_t)(c); \\\n    } else if((uint32_t)(c)<=0x10ffff) { \\\n        if((i)+1<(length)) { \\\n            (s)[(i)++]=(uint16_t)(((c)>>10)+0xd7c0); \\\n            (s)[(i)++]=(uint16_t)(((c)&0x3ff)|0xdc00); \\\n        } else /* not enough space */ { \\\n            (s)[(i)++]=UTF_ERROR_VALUE; \\\n        } \\\n    } else /* c>0x10ffff, write error value */ { \\\n        (s)[(i)++]=UTF_ERROR_VALUE; \\\n    } \\\n}\n\n/** @deprecated ICU 2.4. Renamed to U16_FWD_1, see utf_old.h. */\n#define UTF16_FWD_1_SAFE(s, i, length) U16_FWD_1(s, i, length)\n\n/** @deprecated ICU 2.4. Renamed to U16_FWD_N, see utf_old.h. */\n#define UTF16_FWD_N_SAFE(s, i, length, n) U16_FWD_N(s, i, length, n)\n\n/** @deprecated ICU 2.4. Renamed to U16_SET_CP_START, see utf_old.h. */\n#define UTF16_SET_CHAR_START_SAFE(s, start, i) U16_SET_CP_START(s, start, i)\n\n/** @deprecated ICU 2.4. Renamed to U16_PREV_UNSAFE, see utf_old.h. */\n#define UTF16_PREV_CHAR_UNSAFE(s, i, c) { \\\n    (c)=(s)[--(i)]; \\\n    if(UTF_IS_SECOND_SURROGATE(c)) { \\\n        (c)=UTF16_GET_PAIR_VALUE((s)[--(i)], (c)); \\\n    } \\\n}\n\n/** @deprecated ICU 2.4. Renamed to U16_BACK_1_UNSAFE, see utf_old.h. */\n#define UTF16_BACK_1_UNSAFE(s, i) { \\\n    if(UTF_IS_SECOND_SURROGATE((s)[--(i)])) { \\\n        --(i); \\\n    } \\\n}\n\n/** @deprecated ICU 2.4. Renamed to U16_BACK_N_UNSAFE, see utf_old.h. */\n#define UTF16_BACK_N_UNSAFE(s, i, n) { \\\n    int32_t __N=(n); \\\n    while(__N>0) { \\\n        UTF16_BACK_1_UNSAFE(s, i); \\\n        --__N; \\\n    } \\\n}\n\n/** @deprecated ICU 2.4. Renamed to U16_SET_CP_LIMIT_UNSAFE, see utf_old.h. */\n#define UTF16_SET_CHAR_LIMIT_UNSAFE(s, i) { \\\n    if(UTF_IS_FIRST_SURROGATE((s)[(i)-1])) { \\\n        ++(i); \\\n    } \\\n}\n\n/** @deprecated ICU 2.4. Use U16_PREV instead, see utf_old.h. */\n#define UTF16_PREV_CHAR_SAFE(s, start, i, c, strict) { \\\n    (c)=(s)[--(i)]; \\\n    if(UTF_IS_SECOND_SURROGATE(c)) { \\\n        uint16_t __c2; \\\n        if((i)>(start) && UTF_IS_FIRST_SURROGATE(__c2=(s)[(i)-1])) { \\\n            --(i); \\\n            (c)=UTF16_GET_PAIR_VALUE(__c2, (c)); \\\n            /* strict: ((c)&0xfffe)==0xfffe is caught by UTF_IS_ERROR() and UTF_IS_UNICODE_CHAR() */ \\\n        } else if(strict) {\\\n            /* unmatched second surrogate */ \\\n            (c)=UTF_ERROR_VALUE; \\\n        } \\\n    } else if((strict) && !UTF_IS_UNICODE_CHAR(c)) { \\\n        /* unmatched first surrogate or other non-character */ \\\n        (c)=UTF_ERROR_VALUE; \\\n    } \\\n}\n\n/** @deprecated ICU 2.4. Renamed to U16_BACK_1, see utf_old.h. */\n#define UTF16_BACK_1_SAFE(s, start, i) U16_BACK_1(s, start, i)\n\n/** @deprecated ICU 2.4. Renamed to U16_BACK_N, see utf_old.h. */\n#define UTF16_BACK_N_SAFE(s, start, i, n) U16_BACK_N(s, start, i, n)\n\n/** @deprecated ICU 2.4. Renamed to U16_SET_CP_LIMIT, see utf_old.h. */\n#define UTF16_SET_CHAR_LIMIT_SAFE(s, start, i, length) U16_SET_CP_LIMIT(s, start, i, length)\n\n/* Formerly utf32.h --------------------------------------------------------- */\n\n/*\n* Old documentation:\n*\n*   This file defines macros to deal with UTF-32 code units and code points.\n*   Signatures and semantics are the same as for the similarly named macros\n*   in utf16.h.\n*   utf32.h is included by utf.h after unicode/umachine.h</p>\n*   and some common definitions.\n*   <p><b>Usage:</b>  ICU coding guidelines for if() statements should be followed when using these macros.\n*                  Compound statements (curly braces {}) must be used  for if-else-while...\n*                  bodies and all macro statements should be terminated with semicolon.</p>\n*/\n\n/* internal definitions ----------------------------------------------------- */\n\n/** @deprecated ICU 2.4. Obsolete, see utf_old.h. */\n#define UTF32_IS_SAFE(c, strict) \\\n    (!(strict) ? \\\n        (uint32_t)(c)<=0x10ffff : \\\n        UTF_IS_UNICODE_CHAR(c))\n\n/*\n * For the semantics of all of these macros, see utf16.h.\n * The UTF-32 versions are trivial because any code point is\n * encoded using exactly one code unit.\n */\n\n/* single-code point definitions -------------------------------------------- */\n\n/* classes of code unit values */\n\n/** @deprecated ICU 2.4. Obsolete, see utf_old.h. */\n#define UTF32_IS_SINGLE(uchar) 1\n/** @deprecated ICU 2.4. Obsolete, see utf_old.h. */\n#define UTF32_IS_LEAD(uchar) 0\n/** @deprecated ICU 2.4. Obsolete, see utf_old.h. */\n#define UTF32_IS_TRAIL(uchar) 0\n\n/* number of code units per code point */\n\n/** @deprecated ICU 2.4. Obsolete, see utf_old.h. */\n#define UTF32_NEED_MULTIPLE_UCHAR(c) 0\n/** @deprecated ICU 2.4. Obsolete, see utf_old.h. */\n#define UTF32_CHAR_LENGTH(c) 1\n/** @deprecated ICU 2.4. Obsolete, see utf_old.h. */\n#define UTF32_MAX_CHAR_LENGTH 1\n\n/* average number of code units compared to UTF-16 */\n\n/** @deprecated ICU 2.4. Obsolete, see utf_old.h. */\n#define UTF32_ARRAY_SIZE(size) (size)\n\n/** @deprecated ICU 2.4. Obsolete, see utf_old.h. */\n#define UTF32_GET_CHAR_UNSAFE(s, i, c) { \\\n    (c)=(s)[i]; \\\n}\n\n/** @deprecated ICU 2.4. Obsolete, see utf_old.h. */\n#define UTF32_GET_CHAR_SAFE(s, start, i, length, c, strict) { \\\n    (c)=(s)[i]; \\\n    if(!UTF32_IS_SAFE(c, strict)) { \\\n        (c)=UTF_ERROR_VALUE; \\\n    } \\\n}\n\n/* definitions with forward iteration --------------------------------------- */\n\n/** @deprecated ICU 2.4. Obsolete, see utf_old.h. */\n#define UTF32_NEXT_CHAR_UNSAFE(s, i, c) { \\\n    (c)=(s)[(i)++]; \\\n}\n\n/** @deprecated ICU 2.4. Obsolete, see utf_old.h. */\n#define UTF32_APPEND_CHAR_UNSAFE(s, i, c) { \\\n    (s)[(i)++]=(c); \\\n}\n\n/** @deprecated ICU 2.4. Obsolete, see utf_old.h. */\n#define UTF32_FWD_1_UNSAFE(s, i) { \\\n    ++(i); \\\n}\n\n/** @deprecated ICU 2.4. Obsolete, see utf_old.h. */\n#define UTF32_FWD_N_UNSAFE(s, i, n) { \\\n    (i)+=(n); \\\n}\n\n/** @deprecated ICU 2.4. Obsolete, see utf_old.h. */\n#define UTF32_SET_CHAR_START_UNSAFE(s, i) { \\\n}\n\n/** @deprecated ICU 2.4. Obsolete, see utf_old.h. */\n#define UTF32_NEXT_CHAR_SAFE(s, i, length, c, strict) { \\\n    (c)=(s)[(i)++]; \\\n    if(!UTF32_IS_SAFE(c, strict)) { \\\n        (c)=UTF_ERROR_VALUE; \\\n    } \\\n}\n\n/** @deprecated ICU 2.4. Obsolete, see utf_old.h. */\n#define UTF32_APPEND_CHAR_SAFE(s, i, length, c) { \\\n    if((uint32_t)(c)<=0x10ffff) { \\\n        (s)[(i)++]=(c); \\\n    } else /* c>0x10ffff, write 0xfffd */ { \\\n        (s)[(i)++]=0xfffd; \\\n    } \\\n}\n\n/** @deprecated ICU 2.4. Obsolete, see utf_old.h. */\n#define UTF32_FWD_1_SAFE(s, i, length) { \\\n    ++(i); \\\n}\n\n/** @deprecated ICU 2.4. Obsolete, see utf_old.h. */\n#define UTF32_FWD_N_SAFE(s, i, length, n) { \\\n    if(((i)+=(n))>(length)) { \\\n        (i)=(length); \\\n    } \\\n}\n\n/** @deprecated ICU 2.4. Obsolete, see utf_old.h. */\n#define UTF32_SET_CHAR_START_SAFE(s, start, i) { \\\n}\n\n/* definitions with backward iteration -------------------------------------- */\n\n/** @deprecated ICU 2.4. Obsolete, see utf_old.h. */\n#define UTF32_PREV_CHAR_UNSAFE(s, i, c) { \\\n    (c)=(s)[--(i)]; \\\n}\n\n/** @deprecated ICU 2.4. Obsolete, see utf_old.h. */\n#define UTF32_BACK_1_UNSAFE(s, i) { \\\n    --(i); \\\n}\n\n/** @deprecated ICU 2.4. Obsolete, see utf_old.h. */\n#define UTF32_BACK_N_UNSAFE(s, i, n) { \\\n    (i)-=(n); \\\n}\n\n/** @deprecated ICU 2.4. Obsolete, see utf_old.h. */\n#define UTF32_SET_CHAR_LIMIT_UNSAFE(s, i) { \\\n}\n\n/** @deprecated ICU 2.4. Obsolete, see utf_old.h. */\n#define UTF32_PREV_CHAR_SAFE(s, start, i, c, strict) { \\\n    (c)=(s)[--(i)]; \\\n    if(!UTF32_IS_SAFE(c, strict)) { \\\n        (c)=UTF_ERROR_VALUE; \\\n    } \\\n}\n\n/** @deprecated ICU 2.4. Obsolete, see utf_old.h. */\n#define UTF32_BACK_1_SAFE(s, start, i) { \\\n    --(i); \\\n}\n\n/** @deprecated ICU 2.4. Obsolete, see utf_old.h. */\n#define UTF32_BACK_N_SAFE(s, start, i, n) { \\\n    (i)-=(n); \\\n    if((i)<(start)) { \\\n        (i)=(start); \\\n    } \\\n}\n\n/** @deprecated ICU 2.4. Obsolete, see utf_old.h. */\n#define UTF32_SET_CHAR_LIMIT_SAFE(s, i, length) { \\\n}\n\n/* Formerly utf.h, part 2 --------------------------------------------------- */\n\n/**\n * Estimate the number of code units for a string based on the number of UTF-16 code units.\n *\n * @deprecated ICU 2.4. Obsolete, see utf_old.h.\n */\n#define UTF_ARRAY_SIZE(size) UTF16_ARRAY_SIZE(size)\n\n/** @deprecated ICU 2.4. Renamed to U16_GET_UNSAFE, see utf_old.h. */\n#define UTF_GET_CHAR_UNSAFE(s, i, c)                 UTF16_GET_CHAR_UNSAFE(s, i, c)\n\n/** @deprecated ICU 2.4. Use U16_GET instead, see utf_old.h. */\n#define UTF_GET_CHAR_SAFE(s, start, i, length, c, strict) UTF16_GET_CHAR_SAFE(s, start, i, length, c, strict)\n\n\n/** @deprecated ICU 2.4. Renamed to U16_NEXT_UNSAFE, see utf_old.h. */\n#define UTF_NEXT_CHAR_UNSAFE(s, i, c)                UTF16_NEXT_CHAR_UNSAFE(s, i, c)\n\n/** @deprecated ICU 2.4. Use U16_NEXT instead, see utf_old.h. */\n#define UTF_NEXT_CHAR_SAFE(s, i, length, c, strict)  UTF16_NEXT_CHAR_SAFE(s, i, length, c, strict)\n\n\n/** @deprecated ICU 2.4. Renamed to U16_APPEND_UNSAFE, see utf_old.h. */\n#define UTF_APPEND_CHAR_UNSAFE(s, i, c)              UTF16_APPEND_CHAR_UNSAFE(s, i, c)\n\n/** @deprecated ICU 2.4. Use U16_APPEND instead, see utf_old.h. */\n#define UTF_APPEND_CHAR_SAFE(s, i, length, c)        UTF16_APPEND_CHAR_SAFE(s, i, length, c)\n\n\n/** @deprecated ICU 2.4. Renamed to U16_FWD_1_UNSAFE, see utf_old.h. */\n#define UTF_FWD_1_UNSAFE(s, i)                       UTF16_FWD_1_UNSAFE(s, i)\n\n/** @deprecated ICU 2.4. Renamed to U16_FWD_1, see utf_old.h. */\n#define UTF_FWD_1_SAFE(s, i, length)                 UTF16_FWD_1_SAFE(s, i, length)\n\n\n/** @deprecated ICU 2.4. Renamed to U16_FWD_N_UNSAFE, see utf_old.h. */\n#define UTF_FWD_N_UNSAFE(s, i, n)                    UTF16_FWD_N_UNSAFE(s, i, n)\n\n/** @deprecated ICU 2.4. Renamed to U16_FWD_N, see utf_old.h. */\n#define UTF_FWD_N_SAFE(s, i, length, n)              UTF16_FWD_N_SAFE(s, i, length, n)\n\n\n/** @deprecated ICU 2.4. Renamed to U16_SET_CP_START_UNSAFE, see utf_old.h. */\n#define UTF_SET_CHAR_START_UNSAFE(s, i)              UTF16_SET_CHAR_START_UNSAFE(s, i)\n\n/** @deprecated ICU 2.4. Renamed to U16_SET_CP_START, see utf_old.h. */\n#define UTF_SET_CHAR_START_SAFE(s, start, i)         UTF16_SET_CHAR_START_SAFE(s, start, i)\n\n\n/** @deprecated ICU 2.4. Renamed to U16_PREV_UNSAFE, see utf_old.h. */\n#define UTF_PREV_CHAR_UNSAFE(s, i, c)                UTF16_PREV_CHAR_UNSAFE(s, i, c)\n\n/** @deprecated ICU 2.4. Use U16_PREV instead, see utf_old.h. */\n#define UTF_PREV_CHAR_SAFE(s, start, i, c, strict)   UTF16_PREV_CHAR_SAFE(s, start, i, c, strict)\n\n\n/** @deprecated ICU 2.4. Renamed to U16_BACK_1_UNSAFE, see utf_old.h. */\n#define UTF_BACK_1_UNSAFE(s, i)                      UTF16_BACK_1_UNSAFE(s, i)\n\n/** @deprecated ICU 2.4. Renamed to U16_BACK_1, see utf_old.h. */\n#define UTF_BACK_1_SAFE(s, start, i)                 UTF16_BACK_1_SAFE(s, start, i)\n\n\n/** @deprecated ICU 2.4. Renamed to U16_BACK_N_UNSAFE, see utf_old.h. */\n#define UTF_BACK_N_UNSAFE(s, i, n)                   UTF16_BACK_N_UNSAFE(s, i, n)\n\n/** @deprecated ICU 2.4. Renamed to U16_BACK_N, see utf_old.h. */\n#define UTF_BACK_N_SAFE(s, start, i, n)              UTF16_BACK_N_SAFE(s, start, i, n)\n\n\n/** @deprecated ICU 2.4. Renamed to U16_SET_CP_LIMIT_UNSAFE, see utf_old.h. */\n#define UTF_SET_CHAR_LIMIT_UNSAFE(s, i)              UTF16_SET_CHAR_LIMIT_UNSAFE(s, i)\n\n/** @deprecated ICU 2.4. Renamed to U16_SET_CP_LIMIT, see utf_old.h. */\n#define UTF_SET_CHAR_LIMIT_SAFE(s, start, i, length) UTF16_SET_CHAR_LIMIT_SAFE(s, start, i, length)\n\n/* Define default macros (UTF-16 \"safe\") ------------------------------------ */\n\n/**\n * Does this code unit alone encode a code point (BMP, not a surrogate)?\n * Same as UTF16_IS_SINGLE.\n * @deprecated ICU 2.4. Renamed to U_IS_SINGLE and U16_IS_SINGLE, see utf_old.h.\n */\n#define UTF_IS_SINGLE(uchar) U16_IS_SINGLE(uchar)\n\n/**\n * Is this code unit the first one of several (a lead surrogate)?\n * Same as UTF16_IS_LEAD.\n * @deprecated ICU 2.4. Renamed to U_IS_LEAD and U16_IS_LEAD, see utf_old.h.\n */\n#define UTF_IS_LEAD(uchar) U16_IS_LEAD(uchar)\n\n/**\n * Is this code unit one of several but not the first one (a trail surrogate)?\n * Same as UTF16_IS_TRAIL.\n * @deprecated ICU 2.4. Renamed to U_IS_TRAIL and U16_IS_TRAIL, see utf_old.h.\n */\n#define UTF_IS_TRAIL(uchar) U16_IS_TRAIL(uchar)\n\n/**\n * Does this code point require multiple code units (is it a supplementary code point)?\n * Same as UTF16_NEED_MULTIPLE_UCHAR.\n * @deprecated ICU 2.4. Use U16_LENGTH or test ((uint32_t)(c)>0xffff) instead.\n */\n#define UTF_NEED_MULTIPLE_UCHAR(c) UTF16_NEED_MULTIPLE_UCHAR(c)\n\n/**\n * How many code units are used to encode this code point (1 or 2)?\n * Same as UTF16_CHAR_LENGTH.\n * @deprecated ICU 2.4. Renamed to U16_LENGTH, see utf_old.h.\n */\n#define UTF_CHAR_LENGTH(c) U16_LENGTH(c)\n\n/**\n * How many code units are used at most for any Unicode code point (2)?\n * Same as UTF16_MAX_CHAR_LENGTH.\n * @deprecated ICU 2.4. Renamed to U16_MAX_LENGTH, see utf_old.h.\n */\n#define UTF_MAX_CHAR_LENGTH U16_MAX_LENGTH\n\n/**\n * Set c to the code point that contains the code unit i.\n * i could point to the lead or the trail surrogate for the code point.\n * i is not modified.\n * Same as UTF16_GET_CHAR.\n * \\pre 0<=i<length\n *\n * @deprecated ICU 2.4. Renamed to U16_GET, see utf_old.h.\n */\n#define UTF_GET_CHAR(s, start, i, length, c) U16_GET(s, start, i, length, c)\n\n/**\n * Set c to the code point that starts at code unit i\n * and advance i to beyond the code units of this code point (post-increment).\n * i must point to the first code unit of a code point.\n * Otherwise c is set to the trail unit (surrogate) itself.\n * Same as UTF16_NEXT_CHAR.\n * \\pre 0<=i<length\n * \\post 0<i<=length\n *\n * @deprecated ICU 2.4. Renamed to U16_NEXT, see utf_old.h.\n */\n#define UTF_NEXT_CHAR(s, i, length, c) U16_NEXT(s, i, length, c)\n\n/**\n * Append the code units of code point c to the string at index i\n * and advance i to beyond the new code units (post-increment).\n * The code units beginning at index i will be overwritten.\n * Same as UTF16_APPEND_CHAR.\n * \\pre 0<=c<=0x10ffff\n * \\pre 0<=i<length\n * \\post 0<i<=length\n *\n * @deprecated ICU 2.4. Use U16_APPEND instead, see utf_old.h.\n */\n#define UTF_APPEND_CHAR(s, i, length, c) UTF16_APPEND_CHAR_SAFE(s, i, length, c)\n\n/**\n * Advance i to beyond the code units of the code point that begins at i.\n * I.e., advance i by one code point.\n * Same as UTF16_FWD_1.\n * \\pre 0<=i<length\n * \\post 0<i<=length\n *\n * @deprecated ICU 2.4. Renamed to U16_FWD_1, see utf_old.h.\n */\n#define UTF_FWD_1(s, i, length) U16_FWD_1(s, i, length)\n\n/**\n * Advance i to beyond the code units of the n code points where the first one begins at i.\n * I.e., advance i by n code points.\n * Same as UT16_FWD_N.\n * \\pre 0<=i<length\n * \\post 0<i<=length\n *\n * @deprecated ICU 2.4. Renamed to U16_FWD_N, see utf_old.h.\n */\n#define UTF_FWD_N(s, i, length, n) U16_FWD_N(s, i, length, n)\n\n/**\n * Take the random-access index i and adjust it so that it points to the beginning\n * of a code point.\n * The input index points to any code unit of a code point and is moved to point to\n * the first code unit of the same code point. i is never incremented.\n * In other words, if i points to a trail surrogate that is preceded by a matching\n * lead surrogate, then i is decremented. Otherwise it is not modified.\n * This can be used to start an iteration with UTF_NEXT_CHAR() from a random index.\n * Same as UTF16_SET_CHAR_START.\n * \\pre start<=i<length\n * \\post start<=i<length\n *\n * @deprecated ICU 2.4. Renamed to U16_SET_CP_START, see utf_old.h.\n */\n#define UTF_SET_CHAR_START(s, start, i) U16_SET_CP_START(s, start, i)\n\n/**\n * Set c to the code point that has code units before i\n * and move i backward (towards the beginning of the string)\n * to the first code unit of this code point (pre-increment).\n * i must point to the first code unit after the last unit of a code point (i==length is allowed).\n * Same as UTF16_PREV_CHAR.\n * \\pre start<i<=length\n * \\post start<=i<length\n *\n * @deprecated ICU 2.4. Renamed to U16_PREV, see utf_old.h.\n */\n#define UTF_PREV_CHAR(s, start, i, c) U16_PREV(s, start, i, c)\n\n/**\n * Move i backward (towards the beginning of the string)\n * to the first code unit of the code point that has code units before i.\n * I.e., move i backward by one code point.\n * i must point to the first code unit after the last unit of a code point (i==length is allowed).\n * Same as UTF16_BACK_1.\n * \\pre start<i<=length\n * \\post start<=i<length\n *\n * @deprecated ICU 2.4. Renamed to U16_BACK_1, see utf_old.h.\n */\n#define UTF_BACK_1(s, start, i) U16_BACK_1(s, start, i)\n\n/**\n * Move i backward (towards the beginning of the string)\n * to the first code unit of the n code points that have code units before i.\n * I.e., move i backward by n code points.\n * i must point to the first code unit after the last unit of a code point (i==length is allowed).\n * Same as UTF16_BACK_N.\n * \\pre start<i<=length\n * \\post start<=i<length\n *\n * @deprecated ICU 2.4. Renamed to U16_BACK_N, see utf_old.h.\n */\n#define UTF_BACK_N(s, start, i, n) U16_BACK_N(s, start, i, n)\n\n/**\n * Take the random-access index i and adjust it so that it points beyond\n * a code point. The input index points beyond any code unit\n * of a code point and is moved to point beyond the last code unit of the same\n * code point. i is never decremented.\n * In other words, if i points to a trail surrogate that is preceded by a matching\n * lead surrogate, then i is incremented. Otherwise it is not modified.\n * This can be used to start an iteration with UTF_PREV_CHAR() from a random index.\n * Same as UTF16_SET_CHAR_LIMIT.\n * \\pre start<i<=length\n * \\post start<i<=length\n *\n * @deprecated ICU 2.4. Renamed to U16_SET_CP_LIMIT, see utf_old.h.\n */\n#define UTF_SET_CHAR_LIMIT(s, start, i, length) U16_SET_CP_LIMIT(s, start, i, length)\n\n#endif /* U_HIDE_DEPRECATED_API */\n\n#endif\n\n"
  },
  {
    "path": "deprecated/android/addons/icucompat/unicode/utmscale.h",
    "content": "/*\n*******************************************************************************\n* Copyright (C) 2004 - 2008, International Business Machines Corporation and\n* others. All Rights Reserved.\n*******************************************************************************\n*/\n\n#ifndef UTMSCALE_H\n#define UTMSCALE_H\n\n#include \"unicode/utypes.h\"\n\n#if !UCONFIG_NO_FORMATTING\n\n/** \n * \\file\n * \\brief C API: Universal Time Scale\n *\n * There are quite a few different conventions for binary datetime, depending on different\n * platforms and protocols. Some of these have severe drawbacks. For example, people using\n * Unix time (seconds since Jan 1, 1970) think that they are safe until near the year 2038.\n * But cases can and do arise where arithmetic manipulations causes serious problems. Consider\n * the computation of the average of two datetimes, for example: if one calculates them with\n * <code>averageTime = (time1 + time2)/2</code>, there will be overflow even with dates\n * around the present. Moreover, even if these problems don't occur, there is the issue of\n * conversion back and forth between different systems.\n *\n * <p>\n * Binary datetimes differ in a number of ways: the datatype, the unit,\n * and the epoch (origin). We'll refer to these as time scales. For example:\n *\n * <table border=\"1\" cellspacing=\"0\" cellpadding=\"4\">\n *  <caption>Table 1: Binary Time Scales</caption>\n *  <tr>\n *    <th align=\"left\">Source</th>\n *    <th align=\"left\">Datatype</th>\n *    <th align=\"left\">Unit</th>\n *    <th align=\"left\">Epoch</th>\n *  </tr>\n *\n *  <tr>\n *    <td>UDTS_JAVA_TIME</td>\n *    <td>int64_t</td>\n *    <td>milliseconds</td>\n *    <td>Jan 1, 1970</td>\n *  </tr>\n *  <tr>\n *\n *    <td>UDTS_UNIX_TIME</td>\n *    <td>int32_t or int64_t</td>\n *    <td>seconds</td>\n *    <td>Jan 1, 1970</td>\n *  </tr>\n *  <tr>\n *    <td>UDTS_ICU4C_TIME</td>\n *\n *    <td>double</td>\n *    <td>milliseconds</td>\n *    <td>Jan 1, 1970</td>\n *  </tr>\n *  <tr>\n *    <td>UDTS_WINDOWS_FILE_TIME</td>\n *    <td>int64_t</td>\n *\n *    <td>ticks (100 nanoseconds)</td>\n *    <td>Jan 1, 1601</td>\n *  </tr>\n *  <tr>\n *    <td>UDTS_DOTNET_DATE_TIME</td>\n *    <td>int64_t</td>\n *    <td>ticks (100 nanoseconds)</td>\n *\n *    <td>Jan 1, 0001</td>\n *  </tr>\n *  <tr>\n *    <td>UDTS_MAC_OLD_TIME</td>\n *    <td>int32_t or int64_t</td>\n *    <td>seconds</td>\n *    <td>Jan 1, 1904</td>\n *\n *  </tr>\n *  <tr>\n *    <td>UDTS_MAC_TIME</td>\n *    <td>double</td>\n *    <td>seconds</td>\n *    <td>Jan 1, 2001</td>\n *  </tr>\n *\n *  <tr>\n *    <td>UDTS_EXCEL_TIME</td>\n *    <td>?</td>\n *    <td>days</td>\n *    <td>Dec 31, 1899</td>\n *  </tr>\n *  <tr>\n *\n *    <td>UDTS_DB2_TIME</td>\n *    <td>?</td>\n *    <td>days</td>\n *    <td>Dec 31, 1899</td>\n *  </tr>\n *\n *  <tr>\n *    <td>UDTS_UNIX_MICROSECONDS_TIME</td>\n *    <td>int64_t</td>\n *    <td>microseconds</td>\n *    <td>Jan 1, 1970</td>\n *  </tr>\n * </table>\n *\n * <p>\n * All of the epochs start at 00:00 am (the earliest possible time on the day in question),\n * and are assumed to be UTC.\n *\n * <p>\n * The ranges for different datatypes are given in the following table (all values in years).\n * The range of years includes the entire range expressible with positive and negative\n * values of the datatype. The range of years for double is the range that would be allowed\n * without losing precision to the corresponding unit.\n *\n * <table border=\"1\" cellspacing=\"0\" cellpadding=\"4\">\n *  <tr>\n *    <th align=\"left\">Units</th>\n *    <th align=\"left\">int64_t</th>\n *    <th align=\"left\">double</th>\n *    <th align=\"left\">int32_t</th>\n *  </tr>\n *\n *  <tr>\n *    <td>1 sec</td>\n *    <td align=\"right\">5.84542x10<sup>11</sup></td>\n *    <td align=\"right\">285,420,920.94</td>\n *    <td align=\"right\">136.10</td>\n *  </tr>\n *  <tr>\n *\n *    <td>1 millisecond</td>\n *    <td align=\"right\">584,542,046.09</td>\n *    <td align=\"right\">285,420.92</td>\n *    <td align=\"right\">0.14</td>\n *  </tr>\n *  <tr>\n *    <td>1 microsecond</td>\n *\n *    <td align=\"right\">584,542.05</td>\n *    <td align=\"right\">285.42</td>\n *    <td align=\"right\">0.00</td>\n *  </tr>\n *  <tr>\n *    <td>100 nanoseconds (tick)</td>\n *    <td align=\"right\">58,454.20</td>\n *    <td align=\"right\">28.54</td>\n *    <td align=\"right\">0.00</td>\n *  </tr>\n *  <tr>\n *    <td>1 nanosecond</td>\n *    <td align=\"right\">584.5420461</td>\n *    <td align=\"right\">0.2854</td>\n *    <td align=\"right\">0.00</td>\n *  </tr>\n * </table>\n *\n * <p>\n * These functions implement a universal time scale which can be used as a 'pivot',\n * and provide conversion functions to and from all other major time scales.\n * This datetimes to be converted to the pivot time, safely manipulated,\n * and converted back to any other datetime time scale.\n *\n *<p>\n * So what to use for this pivot? Java time has plenty of range, but cannot represent\n * .NET <code>System.DateTime</code> values without severe loss of precision. ICU4C time addresses this by using a\n * <code>double</code> that is otherwise equivalent to the Java time. However, there are disadvantages\n * with <code>doubles</code>. They provide for much more graceful degradation in arithmetic operations.\n * But they only have 53 bits of accuracy, which means that they will lose precision when\n * converting back and forth to ticks. What would really be nice would be a\n * <code>long double</code> (80 bits -- 64 bit mantissa), but that is not supported on most systems.\n *\n *<p>\n * The Unix extended time uses a structure with two components: time in seconds and a\n * fractional field (microseconds). However, this is clumsy, slow, and\n * prone to error (you always have to keep track of overflow and underflow in the\n * fractional field). <code>BigDecimal</code> would allow for arbitrary precision and arbitrary range,\n * but we do not want to use this as the normal type, because it is slow and does not\n * have a fixed size.\n *\n *<p>\n * Because of these issues, we ended up concluding that the .NET framework's\n * <code>System.DateTime</code> would be the best pivot. However, we use the full range\n * allowed by the datatype, allowing for datetimes back to 29,000 BC and up to 29,000 AD.\n * This time scale is very fine grained, does not lose precision, and covers a range that\n * will meet almost all requirements. It will not handle the range that Java times do,\n * but frankly, being able to handle dates before 29,000 BC or after 29,000 AD is of very limited interest.\n *\n */\n\n/**\n * <code>UDateTimeScale</code> values are used to specify the time scale used for\n * conversion into or out if the universal time scale.\n *\n * @stable ICU 3.2\n */\ntypedef enum UDateTimeScale {\n    /**\n     * Used in the JDK. Data is a Java <code>long</code> (<code>int64_t</code>). Value\n     * is milliseconds since January 1, 1970.\n     *\n     * @stable ICU 3.2\n     */\n    UDTS_JAVA_TIME = 0,\n\n    /**\n     * Used on Unix systems. Data is <code>int32_t</code> or <code>int64_t</code>. Value\n     * is seconds since January 1, 1970.\n     *\n     * @stable ICU 3.2\n     */\n    UDTS_UNIX_TIME,\n    \n    /**\n     * Used in IUC4C. Data is a <code>double</code>. Value\n     * is milliseconds since January 1, 1970.\n     *\n     * @stable ICU 3.2\n     */\n    UDTS_ICU4C_TIME,\n    \n    /**\n     * Used in Windows for file times. Data is an <code>int64_t</code>. Value\n     * is ticks (1 tick == 100 nanoseconds) since January 1, 1601.\n     *\n     * @stable ICU 3.2\n     */\n    UDTS_WINDOWS_FILE_TIME,\n    \n    /**\n     * Used in the .NET framework's <code>System.DateTime</code> structure. Data is an <code>int64_t</code>. Value\n     * is ticks (1 tick == 100 nanoseconds) since January 1, 0001.\n     *\n     * @stable ICU 3.2\n     */\n    UDTS_DOTNET_DATE_TIME,\n    \n    /**\n     * Used in older Macintosh systems. Data is <code>int32_t</code> or <code>int64_t</code>. Value\n     * is seconds since January 1, 1904.\n     *\n     * @stable ICU 3.2\n     */\n    UDTS_MAC_OLD_TIME,\n    \n    /**\n     * Used in newer Macintosh systems. Data is a <code>double</code>. Value\n     * is seconds since January 1, 2001.\n     *\n     * @stable ICU 3.2\n     */\n    UDTS_MAC_TIME,\n    \n    /**\n     * Used in Excel. Data is an <code>?unknown?</code>. Value\n     * is days since December 31, 1899.\n     *\n     * @stable ICU 3.2\n     */\n    UDTS_EXCEL_TIME,\n    \n    /**\n     * Used in DB2. Data is an <code>?unknown?</code>. Value\n     * is days since December 31, 1899.\n     *\n     * @stable ICU 3.2\n     */\n    UDTS_DB2_TIME,\n\n    /**\n     * Data is a <code>long</code>. Value is microseconds since January 1, 1970.\n     * Similar to Unix time (linear value from 1970) and struct timeval\n     * (microseconds resolution).\n     *\n     * @stable ICU 3.8\n     */\n    UDTS_UNIX_MICROSECONDS_TIME,\n\n    /**\n     * The first unused time scale value. The limit of this enum\n     */\n    UDTS_MAX_SCALE\n} UDateTimeScale;\n\n/**\n * <code>UTimeScaleValue</code> values are used to specify the time scale values\n * to <code>utmscale_getTimeScaleValue</code>.\n *\n * @see utmscale_getTimeScaleValue\n *\n * @stable ICU 3.2\n */\ntypedef enum UTimeScaleValue {\n    /**\n     * The constant used to select the units vale\n     * for a time scale.\n     * \n     * @see utmscale_getTimeScaleValue\n     *\n     * @stable ICU 3.2\n     */\n    UTSV_UNITS_VALUE = 0,\n\n    /**\n     * The constant used to select the epoch offset value\n     * for a time scale.\n     * \n     * @see utmscale_getTimeScaleValue\n     *\n     * @stable ICU 3.2\n     */\n    UTSV_EPOCH_OFFSET_VALUE=1,\n\n    /**\n     * The constant used to select the minimum from value\n     * for a time scale.\n     * \n     * @see utmscale_getTimeScaleValue\n     *\n     * @stable ICU 3.2\n     */\n    UTSV_FROM_MIN_VALUE=2,\n\n    /**\n     * The constant used to select the maximum from value\n     * for a time scale.\n     * \n     * @see utmscale_getTimeScaleValue\n     *\n     * @stable ICU 3.2\n     */\n    UTSV_FROM_MAX_VALUE=3,\n\n    /**\n     * The constant used to select the minimum to value\n     * for a time scale.\n     * \n     * @see utmscale_getTimeScaleValue\n     *\n     * @stable ICU 3.2\n     */\n    UTSV_TO_MIN_VALUE=4,\n\n    /**\n     * The constant used to select the maximum to value\n     * for a time scale.\n     * \n     * @see utmscale_getTimeScaleValue\n     *\n     * @stable ICU 3.2\n     */\n    UTSV_TO_MAX_VALUE=5,\n\n#ifndef U_HIDE_INTERNAL_API\n    /**\n     * The constant used to select the epoch plus one value\n     * for a time scale.\n     * \n     * NOTE: This is an internal value. DO NOT USE IT. May not\n     * actually be equal to the epoch offset value plus one.\n     * \n     * @see utmscale_getTimeScaleValue\n     *\n     * @internal ICU 3.2\n     */\n    UTSV_EPOCH_OFFSET_PLUS_1_VALUE=6,\n\n    /**\n     * The constant used to select the epoch plus one value\n     * for a time scale.\n     * \n     * NOTE: This is an internal value. DO NOT USE IT. May not\n     * actually be equal to the epoch offset value plus one.\n     * \n     * @see utmscale_getTimeScaleValue\n     *\n     * @internal ICU 3.2\n     */\n    UTSV_EPOCH_OFFSET_MINUS_1_VALUE=7,\n\n    /**\n     * The constant used to select the units round value\n     * for a time scale.\n     * \n     * NOTE: This is an internal value. DO NOT USE IT.\n     * \n     * @see utmscale_getTimeScaleValue\n     *\n     * @internal ICU 3.2\n     */\n    UTSV_UNITS_ROUND_VALUE=8,\n\n    /**\n     * The constant used to select the minimum safe rounding value\n     * for a time scale.\n     * \n     * NOTE: This is an internal value. DO NOT USE IT.\n     * \n     * @see utmscale_getTimeScaleValue\n     *\n     * @internal ICU 3.2\n     */\n    UTSV_MIN_ROUND_VALUE=9,\n\n    /**\n     * The constant used to select the maximum safe rounding value\n     * for a time scale.\n     * \n     * NOTE: This is an internal value. DO NOT USE IT.\n     * \n     * @see utmscale_getTimeScaleValue\n     *\n     * @internal ICU 3.2\n     */\n    UTSV_MAX_ROUND_VALUE=10,\n\n#endif /* U_HIDE_INTERNAL_API */\n\n    /**\n     * The number of time scale values, in other words limit of this enum.\n     * \n     * @see utmscale_getTimeScaleValue\n     */\n    UTSV_MAX_SCALE_VALUE=11\n\n} UTimeScaleValue;\n\n/**\n * Get a value associated with a particular time scale.\n * \n * @param timeScale The time scale\n * @param value A constant representing the value to get\n * @param status The status code. Set to <code>U_ILLEGAL_ARGUMENT_ERROR</code> if arguments are invalid.\n * @return - the value.\n * \n * @stable ICU 3.2\n */\nU_STABLE int64_t U_EXPORT2\n    utmscale_getTimeScaleValue(UDateTimeScale timeScale, UTimeScaleValue value, UErrorCode *status);\n\n/* Conversion to 'universal time scale' */\n\n/**\n * Convert a <code>int64_t</code> datetime from the given time scale to the universal time scale.\n *\n * @param otherTime The <code>int64_t</code> datetime\n * @param timeScale The time scale to convert from\n * @param status The status code. Set to <code>U_ILLEGAL_ARGUMENT_ERROR</code> if the conversion is out of range.\n * \n * @return The datetime converted to the universal time scale\n *\n * @stable ICU 3.2\n */\nU_STABLE int64_t U_EXPORT2\n    utmscale_fromInt64(int64_t otherTime, UDateTimeScale timeScale, UErrorCode *status);\n\n/* Conversion from 'universal time scale' */\n\n/**\n * Convert a datetime from the universal time scale to a <code>int64_t</code> in the given time scale.\n *\n * @param universalTime The datetime in the universal time scale\n * @param timeScale The time scale to convert to\n * @param status The status code. Set to <code>U_ILLEGAL_ARGUMENT_ERROR</code> if the conversion is out of range.\n * \n * @return The datetime converted to the given time scale\n *\n * @stable ICU 3.2\n */\nU_STABLE int64_t U_EXPORT2\n    utmscale_toInt64(int64_t universalTime, UDateTimeScale timeScale, UErrorCode *status);\n\n#endif /* #if !UCONFIG_NO_FORMATTING */\n\n#endif\n\n"
  },
  {
    "path": "deprecated/android/addons/icucompat/unicode/utrace.h",
    "content": "/*\n*******************************************************************************\n*\n*   Copyright (C) 2003-2012, International Business Machines\n*   Corporation and others.  All Rights Reserved.\n*\n*******************************************************************************\n*   file name:  utrace.h\n*   encoding:   US-ASCII\n*   tab size:   8 (not used)\n*   indentation:4\n*\n*   created on: 2003aug06\n*   created by: Markus W. Scherer\n*\n*   Definitions for ICU tracing/logging.\n*\n*/\n\n#ifndef __UTRACE_H__\n#define __UTRACE_H__\n\n#include <stdarg.h>\n#include \"unicode/utypes.h\"\n\n/**\n * \\file\n * \\brief C API:  Definitions for ICU tracing/logging. \n *\n * This provides API for debugging the internals of ICU without the use of\n * a traditional debugger.\n *\n * By default, tracing is disabled in ICU. If you need to debug ICU with \n * tracing, please compile ICU with the --enable-tracing configure option.\n */\n \nU_CDECL_BEGIN\n\n/**\n * Trace severity levels.  Higher levels increase the verbosity of the trace output.\n * @see utrace_setLevel\n * @stable ICU 2.8\n */\ntypedef enum UTraceLevel {\n    /** Disable all tracing  @stable ICU 2.8*/\n    UTRACE_OFF=-1,\n    /** Trace error conditions only  @stable ICU 2.8*/\n    UTRACE_ERROR=0,\n    /** Trace errors and warnings  @stable ICU 2.8*/\n    UTRACE_WARNING=3,\n    /** Trace opens and closes of ICU services  @stable ICU 2.8*/\n    UTRACE_OPEN_CLOSE=5,\n    /** Trace an intermediate number of ICU operations  @stable ICU 2.8*/\n    UTRACE_INFO=7,\n    /** Trace the maximum number of ICU operations  @stable ICU 2.8*/\n    UTRACE_VERBOSE=9\n} UTraceLevel;\n\n/**\n *  These are the ICU functions that will be traced when tracing is enabled.\n *  @stable ICU 2.8\n */\ntypedef enum UTraceFunctionNumber {\n    UTRACE_FUNCTION_START=0,\n    UTRACE_U_INIT=UTRACE_FUNCTION_START,\n    UTRACE_U_CLEANUP,\n    UTRACE_FUNCTION_LIMIT,\n\n    UTRACE_CONVERSION_START=0x1000,\n    UTRACE_UCNV_OPEN=UTRACE_CONVERSION_START,\n    UTRACE_UCNV_OPEN_PACKAGE,\n    UTRACE_UCNV_OPEN_ALGORITHMIC,\n    UTRACE_UCNV_CLONE,\n    UTRACE_UCNV_CLOSE,\n    UTRACE_UCNV_FLUSH_CACHE,\n    UTRACE_UCNV_LOAD,\n    UTRACE_UCNV_UNLOAD,\n    UTRACE_CONVERSION_LIMIT,\n\n    UTRACE_COLLATION_START=0x2000,\n    UTRACE_UCOL_OPEN=UTRACE_COLLATION_START,\n    UTRACE_UCOL_CLOSE,\n    UTRACE_UCOL_STRCOLL,\n    UTRACE_UCOL_GET_SORTKEY,\n    UTRACE_UCOL_GETLOCALE,\n    UTRACE_UCOL_NEXTSORTKEYPART,\n    UTRACE_UCOL_STRCOLLITER,\n    UTRACE_UCOL_OPEN_FROM_SHORT_STRING,\n    UTRACE_UCOL_STRCOLLUTF8, /**< @draft ICU 50 */\n    UTRACE_COLLATION_LIMIT\n} UTraceFunctionNumber;\n\n/**\n * Setter for the trace level.\n * @param traceLevel A UTraceLevel value.\n * @stable ICU 2.8\n */\nU_STABLE void U_EXPORT2\nutrace_setLevel(int32_t traceLevel);\n\n/**\n * Getter for the trace level.\n * @return The UTraceLevel value being used by ICU.\n * @stable ICU 2.8\n */\nU_STABLE int32_t U_EXPORT2\nutrace_getLevel(void);\n\n/* Trace function pointers types  ----------------------------- */\n\n/**\n  *  Type signature for the trace function to be called when entering a function.\n  *  @param context value supplied at the time the trace functions are set.\n  *  @param fnNumber Enum value indicating the ICU function being entered.\n  *  @stable ICU 2.8\n  */\ntypedef void U_CALLCONV\nUTraceEntry(const void *context, int32_t fnNumber);\n\n/**\n  *  Type signature for the trace function to be called when exiting from a function.\n  *  @param context value supplied at the time the trace functions are set.\n  *  @param fnNumber Enum value indicating the ICU function being exited.\n  *  @param fmt     A formatting string that describes the number and types\n  *                 of arguments included with the variable args.  The fmt\n  *                 string has the same form as the utrace_vformat format\n  *                 string.\n  *  @param args    A variable arguments list.  Contents are described by\n  *                 the fmt parameter.\n  *  @see   utrace_vformat\n  *  @stable ICU 2.8\n  */\ntypedef void U_CALLCONV\nUTraceExit(const void *context, int32_t fnNumber, \n           const char *fmt, va_list args);\n\n/**\n  *  Type signature for the trace function to be called from within an ICU function\n  *  to display data or messages.\n  *  @param context  value supplied at the time the trace functions are set.\n  *  @param fnNumber Enum value indicating the ICU function being exited.\n  *  @param level    The current tracing level\n  *  @param fmt      A format string describing the tracing data that is supplied\n  *                  as variable args\n  *  @param args     The data being traced, passed as variable args.\n  *  @stable ICU 2.8\n  */\ntypedef void U_CALLCONV\nUTraceData(const void *context, int32_t fnNumber, int32_t level,\n           const char *fmt, va_list args);\n\n/**\n  *  Set ICU Tracing functions.  Installs application-provided tracing\n  *  functions into ICU.  After doing this, subsequent ICU operations\n  *  will call back to the installed functions, providing a trace\n  *  of the use of ICU.  Passing a NULL pointer for a tracing function\n  *  is allowed, and inhibits tracing action at points where that function\n  *  would be called.\n  *  <p>\n  *  Tracing and Threads:  Tracing functions are global to a process, and\n  *  will be called in response to ICU operations performed by any\n  *  thread.  If tracing of an individual thread is desired, the\n  *  tracing functions must themselves filter by checking that the\n  *  current thread is the desired thread.\n  *\n  *  @param context an uninterpretted pointer.  Whatever is passed in\n  *                 here will in turn be passed to each of the tracing\n  *                 functions UTraceEntry, UTraceExit and UTraceData.\n  *                 ICU does not use or alter this pointer.\n  *  @param e       Callback function to be called on entry to a \n  *                 a traced ICU function.\n  *  @param x       Callback function to be called on exit from a\n  *                 traced ICU function.\n  *  @param d       Callback function to be called from within a \n  *                 traced ICU function, for the purpose of providing\n  *                 data to the trace.\n  *\n  *  @stable ICU 2.8\n  */\nU_STABLE void U_EXPORT2\nutrace_setFunctions(const void *context,\n                    UTraceEntry *e, UTraceExit *x, UTraceData *d);\n\n/**\n  * Get the currently installed ICU tracing functions.   Note that a null function\n  *   pointer will be returned if no trace function has been set.\n  *\n  * @param context  The currently installed tracing context.\n  * @param e        The currently installed UTraceEntry function.\n  * @param x        The currently installed UTraceExit function.\n  * @param d        The currently installed UTraceData function.\n  * @stable ICU 2.8\n  */\nU_STABLE void U_EXPORT2\nutrace_getFunctions(const void **context,\n                    UTraceEntry **e, UTraceExit **x, UTraceData **d);\n\n\n\n/*\n *\n * ICU trace format string syntax\n *\n * Format Strings are passed to UTraceData functions, and define the\n * number and types of the trace data being passed on each call.\n *\n * The UTraceData function, which is supplied by the application,\n * not by ICU, can either forward the trace data (passed via\n * varargs) and the format string back to ICU for formatting into\n * a displayable string, or it can interpret the format itself,\n * and do as it wishes with the trace data.\n *\n *\n * Goals for the format string\n * - basic data output\n * - easy to use for trace programmer\n * - sufficient provision for data types for trace output readability\n * - well-defined types and binary portable APIs\n *\n * Non-goals\n * - printf compatibility\n * - fancy formatting\n * - argument reordering and other internationalization features\n *\n * ICU trace format strings contain plain text with argument inserts,\n * much like standard printf format strings.\n * Each insert begins with a '%', then optionally contains a 'v',\n * then exactly one type character.\n * Two '%' in a row represent a '%' instead of an insert.\n * The trace format strings need not have \\n at the end.\n *\n *\n * Types\n * -----\n *\n * Type characters:\n * - c A char character in the default codepage.\n * - s A NUL-terminated char * string in the default codepage.\n * - S A UChar * string.  Requires two params, (ptr, length).  Length=-1 for nul term.\n * - b A byte (8-bit integer).\n * - h A 16-bit integer.  Also a 16 bit Unicode code unit.\n * - d A 32-bit integer.  Also a 20 bit Unicode code point value. \n * - l A 64-bit integer.\n * - p A data pointer.\n *\n * Vectors\n * -------\n *\n * If the 'v' is not specified, then one item of the specified type\n * is passed in.\n * If the 'v' (for \"vector\") is specified, then a vector of items of the\n * specified type is passed in, via a pointer to the first item\n * and an int32_t value for the length of the vector.\n * Length==-1 means zero or NUL termination.  Works for vectors of all types.\n *\n * Note:  %vS is a vector of (UChar *) strings.  The strings must\n *        be nul terminated as there is no way to provide a\n *        separate length parameter for each string.  The length\n *        parameter (required for all vectors) is the number of\n *        strings, not the length of the strings.\n *\n * Examples\n * --------\n *\n * These examples show the parameters that will be passed to an application's\n *   UTraceData() function for various formats.\n *\n * - the precise formatting is up to the application!\n * - the examples use type casts for arguments only to _show_ the types of\n *   arguments without needing variable declarations in the examples;\n *   the type casts will not be necessary in actual code\n *\n * UTraceDataFunc(context, fnNumber, level,\n *              \"There is a character %c in the string %s.\",   // Format String \n *              (char)c, (const char *)s);                     // varargs parameters\n * ->   There is a character 0x42 'B' in the string \"Bravo\".\n *\n * UTraceDataFunc(context, fnNumber, level,\n *              \"Vector of bytes %vb vector of chars %vc\",\n *              (const uint8_t *)bytes, (int32_t)bytesLength,\n *              (const char *)chars, (int32_t)charsLength);\n * ->  Vector of bytes\n *      42 63 64 3f [4]\n *     vector of chars\n *      \"Bcd?\"[4]\n *\n * UTraceDataFunc(context, fnNumber, level,\n *              \"An int32_t %d and a whole bunch of them %vd\",\n *              (int32_t)-5, (const int32_t *)ints, (int32_t)intsLength);\n * ->   An int32_t 0xfffffffb and a whole bunch of them\n *      fffffffb 00000005 0000010a [3]\n *\n */\n\n\n\n/**\n  *  Trace output Formatter.  An application's UTraceData tracing functions may call\n  *                 back to this function to format the trace output in a\n  *                 human readable form.  Note that a UTraceData function may choose\n  *                 to not format the data;  it could, for example, save it in\n  *                 in the raw form it was received (more compact), leaving\n  *                 formatting for a later trace analyis tool.\n  *  @param outBuf  pointer to a buffer to receive the formatted output.  Output\n  *                 will be nul terminated if there is space in the buffer -\n  *                 if the length of the requested output < the output buffer size.\n  *  @param capacity  Length of the output buffer.\n  *  @param indent  Number of spaces to indent the output.  Intended to allow\n  *                 data displayed from nested functions to be indented for readability.\n  *  @param fmt     Format specification for the data to output\n  *  @param args    Data to be formatted.\n  *  @return        Length of formatted output, including the terminating NUL.\n  *                 If buffer capacity is insufficient, the required capacity is returned. \n  *  @stable ICU 2.8\n  */\nU_STABLE int32_t U_EXPORT2\nutrace_vformat(char *outBuf, int32_t capacity,\n              int32_t indent, const char *fmt,  va_list args);\n\n/**\n  *  Trace output Formatter.  An application's UTraceData tracing functions may call\n  *                 this function to format any additional trace data, beyond that\n  *                 provided by default, in human readable form with the same\n  *                 formatting conventions used by utrace_vformat().\n  *  @param outBuf  pointer to a buffer to receive the formatted output.  Output\n  *                 will be nul terminated if there is space in the buffer -\n  *                 if the length of the requested output < the output buffer size.\n  *  @param capacity  Length of the output buffer.\n  *  @param indent  Number of spaces to indent the output.  Intended to allow\n  *                 data displayed from nested functions to be indented for readability.\n  *  @param fmt     Format specification for the data to output\n  *  @param ...     Data to be formatted.\n  *  @return        Length of formatted output, including the terminating NUL.\n  *                 If buffer capacity is insufficient, the required capacity is returned. \n  *  @stable ICU 2.8\n  */\nU_STABLE int32_t U_EXPORT2\nutrace_format(char *outBuf, int32_t capacity,\n              int32_t indent, const char *fmt,  ...);\n\n\n\n/* Trace function numbers --------------------------------------------------- */\n\n/**\n * Get the name of a function from its trace function number.\n *\n * @param fnNumber The trace number for an ICU function.\n * @return The name string for the function.\n *\n * @see UTraceFunctionNumber\n * @stable ICU 2.8\n */\nU_STABLE const char * U_EXPORT2\nutrace_functionName(int32_t fnNumber);\n\nU_CDECL_END\n\n#endif\n"
  },
  {
    "path": "deprecated/android/addons/icucompat/unicode/utrans.h",
    "content": "/*\n*******************************************************************************\n*   Copyright (C) 1997-2011, International Business Machines\n*   Corporation and others.  All Rights Reserved.\n*******************************************************************************\n*   Date        Name        Description\n*   06/21/00    aliu        Creation.\n*******************************************************************************\n*/\n\n#ifndef UTRANS_H\n#define UTRANS_H\n\n#include \"unicode/utypes.h\"\n\n#if !UCONFIG_NO_TRANSLITERATION\n\n#include \"unicode/localpointer.h\"\n#include \"unicode/urep.h\"\n#include \"unicode/parseerr.h\"\n#include \"unicode/uenum.h\"\n\n/********************************************************************\n * General Notes\n ********************************************************************\n */\n/**\n * \\file\n * \\brief C API: Transliterator\n *\n * <h2> Transliteration </h2>\n * The data structures and functions described in this header provide\n * transliteration services.  Transliteration services are implemented\n * as C++ classes.  The comments and documentation in this header\n * assume the reader is familiar with the C++ headers translit.h and\n * associated documentation.\n *\n * A significant but incomplete subset of the C++ transliteration\n * services are available to C code through this header.  In order to\n * access more complex transliteration services, refer to the C++\n * headers and documentation.\n *\n * There are two sets of functions for working with transliterator IDs:\n *\n * An old, deprecated set uses char * IDs, which works for true and pure\n * identifiers that these APIs were designed for,\n * for example \"Cyrillic-Latin\".\n * It does not work when the ID contains filters (\"[:Script=Cyrl:]\")\n * or even a complete set of rules because then the ID string contains more\n * than just \"invariant\" characters (see utypes.h).\n *\n * A new set of functions replaces the old ones and uses UChar * IDs,\n * paralleling the UnicodeString IDs in the C++ API. (New in ICU 2.8.)\n */\n\n/********************************************************************\n * Data Structures\n ********************************************************************/\n\n/**\n * An opaque transliterator for use in C.  Open with utrans_openxxx()\n * and close with utrans_close() when done.  Equivalent to the C++ class\n * Transliterator and its subclasses.\n * @see Transliterator\n * @stable ICU 2.0\n */\ntypedef void* UTransliterator;\n\n/**\n * Direction constant indicating the direction in a transliterator,\n * e.g., the forward or reverse rules of a RuleBasedTransliterator.\n * Specified when a transliterator is opened.  An \"A-B\" transliterator\n * transliterates A to B when operating in the forward direction, and\n * B to A when operating in the reverse direction.\n * @stable ICU 2.0\n */\ntypedef enum UTransDirection {\n    \n    /**\n     * UTRANS_FORWARD means from &lt;source&gt; to &lt;target&gt; for a\n     * transliterator with ID &lt;source&gt;-&lt;target&gt;.  For a transliterator\n     * opened using a rule, it means forward direction rules, e.g.,\n     * \"A > B\".\n     */\n    UTRANS_FORWARD,\n\n    /**\n     * UTRANS_REVERSE means from &lt;target&gt; to &lt;source&gt; for a\n     * transliterator with ID &lt;source&gt;-&lt;target&gt;.  For a transliterator\n     * opened using a rule, it means reverse direction rules, e.g.,\n     * \"A < B\".\n     */\n    UTRANS_REVERSE\n\n} UTransDirection;\n\n/**\n * Position structure for utrans_transIncremental() incremental\n * transliteration.  This structure defines two substrings of the text\n * being transliterated.  The first region, [contextStart,\n * contextLimit), defines what characters the transliterator will read\n * as context.  The second region, [start, limit), defines what\n * characters will actually be transliterated.  The second region\n * should be a subset of the first.\n *\n * <p>After a transliteration operation, some of the indices in this\n * structure will be modified.  See the field descriptions for\n * details.\n *\n * <p>contextStart <= start <= limit <= contextLimit\n *\n * <p>Note: All index values in this structure must be at code point\n * boundaries.  That is, none of them may occur between two code units\n * of a surrogate pair.  If any index does split a surrogate pair,\n * results are unspecified.\n *\n * @stable ICU 2.0\n */\ntypedef struct UTransPosition {\n\n    /**\n     * Beginning index, inclusive, of the context to be considered for\n     * a transliteration operation.  The transliterator will ignore\n     * anything before this index.  INPUT/OUTPUT parameter: This parameter\n     * is updated by a transliteration operation to reflect the maximum\n     * amount of antecontext needed by a transliterator.\n     * @stable ICU 2.4\n     */\n    int32_t contextStart;\n    \n    /**\n     * Ending index, exclusive, of the context to be considered for a\n     * transliteration operation.  The transliterator will ignore\n     * anything at or after this index.  INPUT/OUTPUT parameter: This\n     * parameter is updated to reflect changes in the length of the\n     * text, but points to the same logical position in the text.\n     * @stable ICU 2.4\n     */\n    int32_t contextLimit;\n    \n    /**\n     * Beginning index, inclusive, of the text to be transliteratd.\n     * INPUT/OUTPUT parameter: This parameter is advanced past\n     * characters that have already been transliterated by a\n     * transliteration operation.\n     * @stable ICU 2.4\n     */\n    int32_t start;\n    \n    /**\n     * Ending index, exclusive, of the text to be transliteratd.\n     * INPUT/OUTPUT parameter: This parameter is updated to reflect\n     * changes in the length of the text, but points to the same\n     * logical position in the text.\n     * @stable ICU 2.4\n     */\n    int32_t limit;\n\n} UTransPosition;\n\n/********************************************************************\n * General API\n ********************************************************************/\n\n/**\n * Open a custom transliterator, given a custom rules string \n * OR \n * a system transliterator, given its ID.  \n * Any non-NULL result from this function should later be closed with\n * utrans_close().\n *\n * @param id a valid transliterator ID\n * @param idLength the length of the ID string, or -1 if NUL-terminated\n * @param dir the desired direction\n * @param rules the transliterator rules.  See the C++ header rbt.h for\n *              rules syntax. If NULL then a system transliterator matching\n *              the ID is returned.\n * @param rulesLength the length of the rules, or -1 if the rules\n *                    are NUL-terminated.\n * @param parseError a pointer to a UParseError struct to receive the details\n *                   of any parsing errors. This parameter may be NULL if no\n *                   parsing error details are desired.\n * @param pErrorCode a pointer to the UErrorCode\n * @return a transliterator pointer that may be passed to other\n *         utrans_xxx() functions, or NULL if the open call fails.\n * @stable ICU 2.8\n */\nU_STABLE UTransliterator* U_EXPORT2\nutrans_openU(const UChar *id,\n             int32_t idLength,\n             UTransDirection dir,\n             const UChar *rules,\n             int32_t rulesLength,\n             UParseError *parseError,\n             UErrorCode *pErrorCode);\n\n/**\n * Open an inverse of an existing transliterator.  For this to work,\n * the inverse must be registered with the system.  For example, if\n * the Transliterator \"A-B\" is opened, and then its inverse is opened,\n * the result is the Transliterator \"B-A\", if such a transliterator is\n * registered with the system.  Otherwise the result is NULL and a\n * failing UErrorCode is set.  Any non-NULL result from this function\n * should later be closed with utrans_close().\n *\n * @param trans the transliterator to open the inverse of.\n * @param status a pointer to the UErrorCode\n * @return a pointer to a newly-opened transliterator that is the\n * inverse of trans, or NULL if the open call fails.\n * @stable ICU 2.0\n */\nU_STABLE UTransliterator* U_EXPORT2 \nutrans_openInverse(const UTransliterator* trans,\n                   UErrorCode* status);\n\n/**\n * Create a copy of a transliterator.  Any non-NULL result from this\n * function should later be closed with utrans_close().\n *\n * @param trans the transliterator to be copied.\n * @param status a pointer to the UErrorCode\n * @return a transliterator pointer that may be passed to other\n * utrans_xxx() functions, or NULL if the clone call fails.\n * @stable ICU 2.0\n */\nU_STABLE UTransliterator* U_EXPORT2 \nutrans_clone(const UTransliterator* trans,\n             UErrorCode* status);\n\n/**\n * Close a transliterator.  Any non-NULL pointer returned by\n * utrans_openXxx() or utrans_clone() should eventually be closed.\n * @param trans the transliterator to be closed.\n * @stable ICU 2.0\n */\nU_STABLE void U_EXPORT2 \nutrans_close(UTransliterator* trans);\n\n#if U_SHOW_CPLUSPLUS_API\n\nU_NAMESPACE_BEGIN\n\n/**\n * \\class LocalUTransliteratorPointer\n * \"Smart pointer\" class, closes a UTransliterator via utrans_close().\n * For most methods see the LocalPointerBase base class.\n *\n * @see LocalPointerBase\n * @see LocalPointer\n * @stable ICU 4.4\n */\nU_DEFINE_LOCAL_OPEN_POINTER(LocalUTransliteratorPointer, UTransliterator, utrans_close);\n\nU_NAMESPACE_END\n\n#endif\n\n/**\n * Return the programmatic identifier for this transliterator.\n * If this identifier is passed to utrans_openU(), it will open\n * a transliterator equivalent to this one, if the ID has been\n * registered.\n *\n * @param trans the transliterator to return the ID of.\n * @param resultLength pointer to an output variable receiving the length\n *        of the ID string; can be NULL\n * @return the NUL-terminated ID string. This pointer remains\n * valid until utrans_close() is called on this transliterator.\n *\n * @stable ICU 2.8\n */\nU_STABLE const UChar * U_EXPORT2\nutrans_getUnicodeID(const UTransliterator *trans,\n                    int32_t *resultLength);\n\n/**\n * Register an open transliterator with the system.  When\n * utrans_open() is called with an ID string that is equal to that\n * returned by utrans_getID(adoptedTrans,...), then\n * utrans_clone(adoptedTrans,...) is returned.\n *\n * <p>NOTE: After this call the system owns the adoptedTrans and will\n * close it.  The user must not call utrans_close() on adoptedTrans.\n *\n * @param adoptedTrans a transliterator, typically the result of\n * utrans_openRules(), to be registered with the system.\n * @param status a pointer to the UErrorCode\n * @stable ICU 2.0\n */\nU_STABLE void U_EXPORT2 \nutrans_register(UTransliterator* adoptedTrans,\n                UErrorCode* status);\n\n/**\n * Unregister a transliterator from the system.  After this call the\n * system will no longer recognize the given ID when passed to\n * utrans_open(). If the ID is invalid then nothing is done.\n *\n * @param id an ID to unregister\n * @param idLength the length of id, or -1 if id is zero-terminated\n * @stable ICU 2.8\n */\nU_STABLE void U_EXPORT2\nutrans_unregisterID(const UChar* id, int32_t idLength);\n\n/**\n * Set the filter used by a transliterator.  A filter can be used to\n * make the transliterator pass certain characters through untouched.\n * The filter is expressed using a UnicodeSet pattern.  If the\n * filterPattern is NULL or the empty string, then the transliterator\n * will be reset to use no filter.\n *\n * @param trans the transliterator\n * @param filterPattern a pattern string, in the form accepted by\n * UnicodeSet, specifying which characters to apply the\n * transliteration to.  May be NULL or the empty string to indicate no\n * filter.\n * @param filterPatternLen the length of filterPattern, or -1 if\n * filterPattern is zero-terminated\n * @param status a pointer to the UErrorCode\n * @see UnicodeSet\n * @stable ICU 2.0\n */\nU_STABLE void U_EXPORT2 \nutrans_setFilter(UTransliterator* trans,\n                 const UChar* filterPattern,\n                 int32_t filterPatternLen,\n                 UErrorCode* status);\n\n/**\n * Return the number of system transliterators.\n * It is recommended to use utrans_openIDs() instead.\n *\n * @return the number of system transliterators.\n * @stable ICU 2.0\n */\nU_STABLE int32_t U_EXPORT2 \nutrans_countAvailableIDs(void);\n\n/**\n * Return a UEnumeration for the available transliterators.\n *\n * @param pErrorCode Pointer to the UErrorCode in/out parameter.\n * @return UEnumeration for the available transliterators.\n *         Close with uenum_close().\n *\n * @stable ICU 2.8\n */\nU_STABLE UEnumeration * U_EXPORT2\nutrans_openIDs(UErrorCode *pErrorCode);\n\n/********************************************************************\n * Transliteration API\n ********************************************************************/\n\n/**\n * Transliterate a segment of a UReplaceable string.  The string is\n * passed in as a UReplaceable pointer rep and a UReplaceableCallbacks\n * function pointer struct repFunc.  Functions in the repFunc struct\n * will be called in order to modify the rep string.\n *\n * @param trans the transliterator\n * @param rep a pointer to the string.  This will be passed to the\n * repFunc functions.\n * @param repFunc a set of function pointers that will be used to\n * modify the string pointed to by rep.\n * @param start the beginning index, inclusive; <code>0 <= start <=\n * limit</code>.\n * @param limit pointer to the ending index, exclusive; <code>start <=\n * limit <= repFunc->length(rep)</code>.  Upon return, *limit will\n * contain the new limit index.  The text previously occupying\n * <code>[start, limit)</code> has been transliterated, possibly to a\n * string of a different length, at <code>[start,\n * </code><em>new-limit</em><code>)</code>, where <em>new-limit</em>\n * is the return value.\n * @param status a pointer to the UErrorCode\n * @stable ICU 2.0\n */\nU_STABLE void U_EXPORT2 \nutrans_trans(const UTransliterator* trans,\n             UReplaceable* rep,\n             UReplaceableCallbacks* repFunc,\n             int32_t start,\n             int32_t* limit,\n             UErrorCode* status);\n\n/**\n * Transliterate the portion of the UReplaceable text buffer that can\n * be transliterated unambiguosly.  This method is typically called\n * after new text has been inserted, e.g. as a result of a keyboard\n * event.  The transliterator will try to transliterate characters of\n * <code>rep</code> between <code>index.cursor</code> and\n * <code>index.limit</code>.  Characters before\n * <code>index.cursor</code> will not be changed.\n *\n * <p>Upon return, values in <code>index</code> will be updated.\n * <code>index.start</code> will be advanced to the first\n * character that future calls to this method will read.\n * <code>index.cursor</code> and <code>index.limit</code> will\n * be adjusted to delimit the range of text that future calls to\n * this method may change.\n *\n * <p>Typical usage of this method begins with an initial call\n * with <code>index.start</code> and <code>index.limit</code>\n * set to indicate the portion of <code>text</code> to be\n * transliterated, and <code>index.cursor == index.start</code>.\n * Thereafter, <code>index</code> can be used without\n * modification in future calls, provided that all changes to\n * <code>text</code> are made via this method.\n *\n * <p>This method assumes that future calls may be made that will\n * insert new text into the buffer.  As a result, it only performs\n * unambiguous transliterations.  After the last call to this method,\n * there may be untransliterated text that is waiting for more input\n * to resolve an ambiguity.  In order to perform these pending\n * transliterations, clients should call utrans_trans() with a start\n * of index.start and a limit of index.end after the last call to this\n * method has been made.\n *\n * @param trans the transliterator\n * @param rep a pointer to the string.  This will be passed to the\n * repFunc functions.\n * @param repFunc a set of function pointers that will be used to\n * modify the string pointed to by rep.\n * @param pos a struct containing the start and limit indices of the\n * text to be read and the text to be transliterated\n * @param status a pointer to the UErrorCode\n * @stable ICU 2.0\n */\nU_STABLE void U_EXPORT2 \nutrans_transIncremental(const UTransliterator* trans,\n                        UReplaceable* rep,\n                        UReplaceableCallbacks* repFunc,\n                        UTransPosition* pos,\n                        UErrorCode* status);\n\n/**\n * Transliterate a segment of a UChar* string.  The string is passed\n * in in a UChar* buffer.  The string is modified in place.  If the\n * result is longer than textCapacity, it is truncated.  The actual\n * length of the result is returned in *textLength, if textLength is\n * non-NULL. *textLength may be greater than textCapacity, but only\n * textCapacity UChars will be written to *text, including the zero\n * terminator.\n *\n * @param trans the transliterator\n * @param text a pointer to a buffer containing the text to be\n * transliterated on input and the result text on output.\n * @param textLength a pointer to the length of the string in text.\n * If the length is -1 then the string is assumed to be\n * zero-terminated.  Upon return, the new length is stored in\n * *textLength.  If textLength is NULL then the string is assumed to\n * be zero-terminated.\n * @param textCapacity a pointer to the length of the text buffer.\n * Upon return, \n * @param start the beginning index, inclusive; <code>0 <= start <=\n * limit</code>.\n * @param limit pointer to the ending index, exclusive; <code>start <=\n * limit <= repFunc->length(rep)</code>.  Upon return, *limit will\n * contain the new limit index.  The text previously occupying\n * <code>[start, limit)</code> has been transliterated, possibly to a\n * string of a different length, at <code>[start,\n * </code><em>new-limit</em><code>)</code>, where <em>new-limit</em>\n * is the return value.\n * @param status a pointer to the UErrorCode\n * @stable ICU 2.0\n */\nU_STABLE void U_EXPORT2 \nutrans_transUChars(const UTransliterator* trans,\n                   UChar* text,\n                   int32_t* textLength,\n                   int32_t textCapacity,\n                   int32_t start,\n                   int32_t* limit,\n                   UErrorCode* status);\n\n/**\n * Transliterate the portion of the UChar* text buffer that can be\n * transliterated unambiguosly.  See utrans_transIncremental().  The\n * string is passed in in a UChar* buffer.  The string is modified in\n * place.  If the result is longer than textCapacity, it is truncated.\n * The actual length of the result is returned in *textLength, if\n * textLength is non-NULL. *textLength may be greater than\n * textCapacity, but only textCapacity UChars will be written to\n * *text, including the zero terminator.  See utrans_transIncremental()\n * for usage details.\n *\n * @param trans the transliterator\n * @param text a pointer to a buffer containing the text to be\n * transliterated on input and the result text on output.\n * @param textLength a pointer to the length of the string in text.\n * If the length is -1 then the string is assumed to be\n * zero-terminated.  Upon return, the new length is stored in\n * *textLength.  If textLength is NULL then the string is assumed to\n * be zero-terminated.\n * @param textCapacity the length of the text buffer\n * @param pos a struct containing the start and limit indices of the\n * text to be read and the text to be transliterated\n * @param status a pointer to the UErrorCode\n * @see utrans_transIncremental\n * @stable ICU 2.0\n */\nU_STABLE void U_EXPORT2 \nutrans_transIncrementalUChars(const UTransliterator* trans,\n                              UChar* text,\n                              int32_t* textLength,\n                              int32_t textCapacity,\n                              UTransPosition* pos,\n                              UErrorCode* status);\n\n/* deprecated API ----------------------------------------------------------- */\n\n#ifndef U_HIDE_DEPRECATED_API\n\n/* see utrans.h documentation for why these functions are deprecated */\n\n/**\n * Deprecated, use utrans_openU() instead.\n * Open a custom transliterator, given a custom rules string \n * OR \n * a system transliterator, given its ID.  \n * Any non-NULL result from this function should later be closed with\n * utrans_close().\n *\n * @param id a valid ID, as returned by utrans_getAvailableID()\n * @param dir the desired direction\n * @param rules the transliterator rules.  See the C++ header rbt.h\n * for rules syntax. If NULL then a system transliterator matching \n * the ID is returned.\n * @param rulesLength the length of the rules, or -1 if the rules\n * are zero-terminated.\n * @param parseError a pointer to a UParseError struct to receive the\n * details of any parsing errors. This parameter may be NULL if no\n * parsing error details are desired.\n * @param status a pointer to the UErrorCode\n * @return a transliterator pointer that may be passed to other\n * utrans_xxx() functions, or NULL if the open call fails.\n * @deprecated ICU 2.8 Use utrans_openU() instead, see utrans.h\n */\nU_DEPRECATED UTransliterator* U_EXPORT2 \nutrans_open(const char* id,\n            UTransDirection dir,\n            const UChar* rules,         /* may be Null */\n            int32_t rulesLength,        /* -1 if null-terminated */ \n            UParseError* parseError,    /* may be Null */\n            UErrorCode* status);\n\n/**\n * Deprecated, use utrans_getUnicodeID() instead.\n * Return the programmatic identifier for this transliterator.\n * If this identifier is passed to utrans_open(), it will open\n * a transliterator equivalent to this one, if the ID has been\n * registered.\n * @param trans the transliterator to return the ID of.\n * @param buf the buffer in which to receive the ID.  This may be\n * NULL, in which case no characters are copied.\n * @param bufCapacity the capacity of the buffer.  Ignored if buf is\n * NULL.\n * @return the actual length of the ID, not including\n * zero-termination.  This may be greater than bufCapacity.\n * @deprecated ICU 2.8 Use utrans_getUnicodeID() instead, see utrans.h\n */\nU_DEPRECATED int32_t U_EXPORT2 \nutrans_getID(const UTransliterator* trans,\n             char* buf,\n             int32_t bufCapacity);\n\n/**\n * Deprecated, use utrans_unregisterID() instead.\n * Unregister a transliterator from the system.  After this call the\n * system will no longer recognize the given ID when passed to\n * utrans_open().  If the id is invalid then nothing is done.\n *\n * @param id a zero-terminated ID\n * @deprecated ICU 2.8 Use utrans_unregisterID() instead, see utrans.h\n */\nU_DEPRECATED void U_EXPORT2 \nutrans_unregister(const char* id);\n\n/**\n * Deprecated, use utrans_openIDs() instead.\n * Return the ID of the index-th system transliterator.  The result\n * is placed in the given buffer.  If the given buffer is too small,\n * the initial substring is copied to buf.  The result in buf is\n * always zero-terminated.\n *\n * @param index the number of the transliterator to return.  Must\n * satisfy 0 <= index < utrans_countAvailableIDs().  If index is out\n * of range then it is treated as if it were 0.\n * @param buf the buffer in which to receive the ID.  This may be\n * NULL, in which case no characters are copied.\n * @param bufCapacity the capacity of the buffer.  Ignored if buf is\n * NULL.\n * @return the actual length of the index-th ID, not including\n * zero-termination.  This may be greater than bufCapacity.\n * @deprecated ICU 2.8 Use utrans_openIDs() instead, see utrans.h\n */\nU_DEPRECATED int32_t U_EXPORT2 \nutrans_getAvailableID(int32_t index,\n                      char* buf,\n                      int32_t bufCapacity);\n\n#endif  /* U_HIDE_DEPRECATED_API */\n\n#endif /* #if !UCONFIG_NO_TRANSLITERATION */\n\n#endif\n"
  },
  {
    "path": "deprecated/android/addons/icucompat/unicode/utypes.h",
    "content": "/*\n**********************************************************************\n*   Copyright (C) 1996-2012, International Business Machines\n*   Corporation and others.  All Rights Reserved.\n**********************************************************************\n*\n*  FILE NAME : UTYPES.H (formerly ptypes.h)\n*\n*   Date        Name        Description\n*   12/11/96    helena      Creation.\n*   02/27/97    aliu        Added typedefs for UClassID, int8, int16, int32,\n*                           uint8, uint16, and uint32.\n*   04/01/97    aliu        Added XP_CPLUSPLUS and modified to work under C as\n*                            well as C++.\n*                           Modified to use memcpy() for uprv_arrayCopy() fns.\n*   04/14/97    aliu        Added TPlatformUtilities.\n*   05/07/97    aliu        Added import/export specifiers (replacing the old\n*                           broken EXT_CLASS).  Added version number for our\n*                           code.  Cleaned up header.\n*    6/20/97    helena      Java class name change.\n*   08/11/98    stephen     UErrorCode changed from typedef to enum\n*   08/12/98    erm         Changed T_ANALYTIC_PACKAGE_VERSION to 3\n*   08/14/98    stephen     Added uprv_arrayCopy() for int8_t, int16_t, int32_t\n*   12/09/98    jfitz       Added BUFFER_OVERFLOW_ERROR (bug 1100066)\n*   04/20/99    stephen     Cleaned up & reworked for autoconf.\n*                           Renamed to utypes.h.\n*   05/05/99    stephen     Changed to use <inttypes.h>\n*   12/07/99    helena      Moved copyright notice string from ucnv_bld.h here.\n*******************************************************************************\n*/\n\n#ifndef UTYPES_H\n#define UTYPES_H\n\n\n#include \"unicode/umachine.h\"\n#include \"unicode/uversion.h\"\n#include \"unicode/uconfig.h\"\n#include <float.h>\n\n#if !U_NO_DEFAULT_INCLUDE_UTF_HEADERS\n#   include \"unicode/utf.h\"\n#endif\n\n/*!\n * \\file\n * \\brief Basic definitions for ICU, for both C and C++ APIs\n *\n * This file defines basic types, constants, and enumerations directly or\n * indirectly by including other header files, especially utf.h for the\n * basic character and string definitions and umachine.h for consistent\n * integer and other types.\n */\n\n\n/**\n * \\def U_SHOW_CPLUSPLUS_API\n * @internal\n */\n#ifdef __cplusplus\n#   ifndef U_SHOW_CPLUSPLUS_API\n#       define U_SHOW_CPLUSPLUS_API 1\n#   endif\n#else\n#   undef U_SHOW_CPLUSPLUS_API\n#   define U_SHOW_CPLUSPLUS_API 0\n#endif\n\n/** @{ API visibility control */\n\n/**\n * \\def U_HIDE_DRAFT_API\n * Define this to 1 to request that draft API be \"hidden\"\n * @internal\n */\n/**\n * \\def U_HIDE_INTERNAL_API\n * Define this to 1 to request that internal API be \"hidden\"\n * @internal\n */\n#if !U_DEFAULT_SHOW_DRAFT && !defined(U_SHOW_DRAFT_API)\n#define U_HIDE_DRAFT_API 1\n#endif\n#if !U_DEFAULT_SHOW_DRAFT && !defined(U_SHOW_INTERNAL_API)\n#define U_HIDE_INTERNAL_API 1\n#endif\n\n/** @} */\n\n/*===========================================================================*/\n/* ICUDATA naming scheme                                                     */\n/*===========================================================================*/\n\n/**\n * \\def U_ICUDATA_TYPE_LETTER\n *\n * This is a platform-dependent string containing one letter:\n * - b for big-endian, ASCII-family platforms\n * - l for little-endian, ASCII-family platforms\n * - e for big-endian, EBCDIC-family platforms\n * This letter is part of the common data file name.\n * @stable ICU 2.0\n */\n\n/**\n * \\def U_ICUDATA_TYPE_LITLETTER\n * The non-string form of U_ICUDATA_TYPE_LETTER\n * @stable ICU 2.0\n */\n#if U_CHARSET_FAMILY\n#   if U_IS_BIG_ENDIAN\n   /* EBCDIC - should always be BE */\n#     define U_ICUDATA_TYPE_LETTER \"e\"\n#     define U_ICUDATA_TYPE_LITLETTER e\n#   else\n#     error \"Don't know what to do with little endian EBCDIC!\"\n#     define U_ICUDATA_TYPE_LETTER \"x\"\n#     define U_ICUDATA_TYPE_LITLETTER x\n#   endif\n#else\n#   if U_IS_BIG_ENDIAN\n      /* Big-endian ASCII */\n#     define U_ICUDATA_TYPE_LETTER \"b\"\n#     define U_ICUDATA_TYPE_LITLETTER b\n#   else\n      /* Little-endian ASCII */\n#     define U_ICUDATA_TYPE_LETTER \"l\"\n#     define U_ICUDATA_TYPE_LITLETTER l\n#   endif\n#endif\n\n/**\n * A single string literal containing the icudata stub name. i.e. 'icudt18e' for\n * ICU 1.8.x on EBCDIC, etc..\n * @stable ICU 2.0\n */\n#define U_ICUDATA_NAME    \"icudt\" U_ICU_VERSION_SHORT U_ICUDATA_TYPE_LETTER\n#ifndef U_HIDE_INTERNAL_API\n#define U_USRDATA_NAME    \"usrdt\" U_ICU_VERSION_SHORT U_ICUDATA_TYPE_LETTER  /**< @internal */\n#define U_USE_USRDATA     1  /**< @internal */\n#endif  /* U_HIDE_INTERNAL_API */\n\n/**\n *  U_ICU_ENTRY_POINT is the name of the DLL entry point to the ICU data library.\n *    Defined as a literal, not a string.\n *    Tricky Preprocessor use - ## operator replaces macro paramters with the literal string\n *                              from the corresponding macro invocation, _before_ other macro substitutions.\n *                              Need a nested \\#defines to get the actual version numbers rather than\n *                              the literal text U_ICU_VERSION_MAJOR_NUM into the name.\n *                              The net result will be something of the form\n *                                  \\#define U_ICU_ENTRY_POINT icudt19_dat\n * @stable ICU 2.4\n */\n#define U_ICUDATA_ENTRY_POINT  U_DEF2_ICUDATA_ENTRY_POINT(U_ICU_VERSION_MAJOR_NUM,U_LIB_SUFFIX_C_NAME)\n\n#ifndef U_HIDE_INTERNAL_API\n/**\n * Do not use. Note that it's OK for the 2nd argument to be undefined (literal).\n * @internal\n */\n#define U_DEF2_ICUDATA_ENTRY_POINT(major,suff) U_DEF_ICUDATA_ENTRY_POINT(major,suff)\n\n/**\n * Do not use.\n * @internal\n */\n#ifndef U_DEF_ICUDATA_ENTRY_POINT\n/* affected by symbol renaming. See platform.h */\n#ifndef U_LIB_SUFFIX_C_NAME\n#define U_DEF_ICUDATA_ENTRY_POINT(major, suff) icudt##major##_dat\n#else\n#define U_DEF_ICUDATA_ENTRY_POINT(major, suff) icudt##suff ## major##_dat\n#endif\n#endif\n#endif  /* U_HIDE_INTERNAL_API */\n\n/**\n * \\def NULL\n * Define NULL if necessary, to 0 for C++ and to ((void *)0) for C.\n * @stable ICU 2.0\n */\n#ifndef NULL\n#ifdef __cplusplus\n#define NULL    0\n#else\n#define NULL    ((void *)0)\n#endif\n#endif\n\n/*===========================================================================*/\n/* Calendar/TimeZone data types                                              */\n/*===========================================================================*/\n\n/**\n * Date and Time data type.\n * This is a primitive data type that holds the date and time\n * as the number of milliseconds since 1970-jan-01, 00:00 UTC.\n * UTC leap seconds are ignored.\n * @stable ICU 2.0\n */\ntypedef double UDate;\n\n/** The number of milliseconds per second @stable ICU 2.0 */\n#define U_MILLIS_PER_SECOND        (1000)\n/** The number of milliseconds per minute @stable ICU 2.0 */\n#define U_MILLIS_PER_MINUTE       (60000)\n/** The number of milliseconds per hour @stable ICU 2.0 */\n#define U_MILLIS_PER_HOUR       (3600000)\n/** The number of milliseconds per day @stable ICU 2.0 */\n#define U_MILLIS_PER_DAY       (86400000)\n\n/** \n * Maximum UDate value \n * @stable ICU 4.8 \n */ \n#define U_DATE_MAX DBL_MAX\n\n/**\n * Minimum UDate value \n * @stable ICU 4.8 \n */ \n#define U_DATE_MIN -U_DATE_MAX\n\n/*===========================================================================*/\n/* Shared library/DLL import-export API control                              */\n/*===========================================================================*/\n\n/*\n * Control of symbol import/export.\n * ICU is separated into three libraries.\n */\n\n/**\n * \\def U_COMBINED_IMPLEMENTATION\n * Set to export library symbols from inside the ICU library\n * when all of ICU is in a single library.\n * This can be set as a compiler option while building ICU, and it\n * needs to be the first one tested to override U_COMMON_API, U_I18N_API, etc.\n * @stable ICU 2.0\n */\n\n/**\n * \\def U_DATA_API\n * Set to export library symbols from inside the stubdata library,\n * and to import them from outside.\n * @stable ICU 3.0\n */\n\n/**\n * \\def U_COMMON_API\n * Set to export library symbols from inside the common library,\n * and to import them from outside.\n * @stable ICU 2.0\n */\n\n/**\n * \\def U_I18N_API\n * Set to export library symbols from inside the i18n library,\n * and to import them from outside.\n * @stable ICU 2.0\n */\n\n/**\n * \\def U_LAYOUT_API\n * Set to export library symbols from inside the layout engine library,\n * and to import them from outside.\n * @stable ICU 2.0\n */\n\n/**\n * \\def U_LAYOUTEX_API\n * Set to export library symbols from inside the layout extensions library,\n * and to import them from outside.\n * @stable ICU 2.6\n */\n\n/**\n * \\def U_IO_API\n * Set to export library symbols from inside the ustdio library,\n * and to import them from outside.\n * @stable ICU 2.0\n */\n\n/**\n * \\def U_TOOLUTIL_API\n * Set to export library symbols from inside the toolutil library,\n * and to import them from outside.\n * @stable ICU 3.4\n */\n\n#if defined(U_COMBINED_IMPLEMENTATION)\n#define U_DATA_API     U_EXPORT\n#define U_COMMON_API   U_EXPORT\n#define U_I18N_API     U_EXPORT\n#define U_LAYOUT_API   U_EXPORT\n#define U_LAYOUTEX_API U_EXPORT\n#define U_IO_API       U_EXPORT\n#define U_TOOLUTIL_API U_EXPORT\n#elif defined(U_STATIC_IMPLEMENTATION)\n#define U_DATA_API\n#define U_COMMON_API\n#define U_I18N_API\n#define U_LAYOUT_API\n#define U_LAYOUTEX_API\n#define U_IO_API\n#define U_TOOLUTIL_API\n#elif defined(U_COMMON_IMPLEMENTATION)\n#define U_DATA_API     U_IMPORT\n#define U_COMMON_API   U_EXPORT\n#define U_I18N_API     U_IMPORT\n#define U_LAYOUT_API   U_IMPORT\n#define U_LAYOUTEX_API U_IMPORT\n#define U_IO_API       U_IMPORT\n#define U_TOOLUTIL_API U_IMPORT\n#elif defined(U_I18N_IMPLEMENTATION)\n#define U_DATA_API     U_IMPORT\n#define U_COMMON_API   U_IMPORT\n#define U_I18N_API     U_EXPORT\n#define U_LAYOUT_API   U_IMPORT\n#define U_LAYOUTEX_API U_IMPORT\n#define U_IO_API       U_IMPORT\n#define U_TOOLUTIL_API U_IMPORT\n#elif defined(U_LAYOUT_IMPLEMENTATION)\n#define U_DATA_API     U_IMPORT\n#define U_COMMON_API   U_IMPORT\n#define U_I18N_API     U_IMPORT\n#define U_LAYOUT_API   U_EXPORT\n#define U_LAYOUTEX_API U_IMPORT\n#define U_IO_API       U_IMPORT\n#define U_TOOLUTIL_API U_IMPORT\n#elif defined(U_LAYOUTEX_IMPLEMENTATION)\n#define U_DATA_API     U_IMPORT\n#define U_COMMON_API   U_IMPORT\n#define U_I18N_API     U_IMPORT\n#define U_LAYOUT_API   U_IMPORT\n#define U_LAYOUTEX_API U_EXPORT\n#define U_IO_API       U_IMPORT\n#define U_TOOLUTIL_API U_IMPORT\n#elif defined(U_IO_IMPLEMENTATION)\n#define U_DATA_API     U_IMPORT\n#define U_COMMON_API   U_IMPORT\n#define U_I18N_API     U_IMPORT\n#define U_LAYOUT_API   U_IMPORT\n#define U_LAYOUTEX_API U_IMPORT\n#define U_IO_API       U_EXPORT\n#define U_TOOLUTIL_API U_IMPORT\n#elif defined(U_TOOLUTIL_IMPLEMENTATION)\n#define U_DATA_API     U_IMPORT\n#define U_COMMON_API   U_IMPORT\n#define U_I18N_API     U_IMPORT\n#define U_LAYOUT_API   U_IMPORT\n#define U_LAYOUTEX_API U_IMPORT\n#define U_IO_API       U_IMPORT\n#define U_TOOLUTIL_API U_EXPORT\n#else\n#define U_DATA_API     U_IMPORT\n#define U_COMMON_API   U_IMPORT\n#define U_I18N_API     U_IMPORT\n#define U_LAYOUT_API   U_IMPORT\n#define U_LAYOUTEX_API U_IMPORT\n#define U_IO_API       U_IMPORT\n#define U_TOOLUTIL_API U_IMPORT\n#endif\n\n/**\n * \\def U_STANDARD_CPP_NAMESPACE\n * Control of C++ Namespace\n * @stable ICU 2.0\n */\n#ifdef __cplusplus\n#define U_STANDARD_CPP_NAMESPACE        ::\n#else\n#define U_STANDARD_CPP_NAMESPACE\n#endif\n\n\n/*===========================================================================*/\n/* Global delete operator                                                    */\n/*===========================================================================*/\n\n/*\n * The ICU4C library must not use the global new and delete operators.\n * These operators here are defined to enable testing for this.\n * See Jitterbug 2581 for details of why this is necessary.\n *\n * Verification that ICU4C's memory usage is correct, i.e.,\n * that global new/delete are not used:\n *\n * a) Check for imports of global new/delete (see uobject.cpp for details)\n * b) Verify that new is never imported.\n * c) Verify that delete is only imported from object code for interface/mixin classes.\n * d) Add global delete and delete[] only for the ICU4C library itself\n *    and define them in a way that crashes or otherwise easily shows a problem.\n *\n * The following implements d).\n * The operator implementations crash; this is intentional and used for library debugging.\n *\n * Note: This is currently only done on Windows because\n * some Linux/Unix compilers have problems with defining global new/delete.\n * On Windows, it is _MSC_VER>=1200 for MSVC 6.0 and higher.\n */\n#if defined(__cplusplus) && U_DEBUG && U_OVERRIDE_CXX_ALLOCATION && (_MSC_VER>=1200) && !defined(U_STATIC_IMPLEMENTATION) && (defined(U_COMMON_IMPLEMENTATION) || defined(U_I18N_IMPLEMENTATION) || defined(U_IO_IMPLEMENTATION) || defined(U_LAYOUT_IMPLEMENTATION) || defined(U_LAYOUTEX_IMPLEMENTATION))\n\n#ifndef U_HIDE_INTERNAL_API\n/**\n * Global operator new, defined only inside ICU4C, must not be used.\n * Crashes intentionally.\n * @internal\n */\ninline void *\noperator new(size_t /*size*/) {\n    char *q=NULL;\n    *q=5; /* break it */\n    return q;\n}\n\n#ifdef _Ret_bytecap_\n/* This is only needed to suppress a Visual C++ 2008 warning for operator new[]. */\n_Ret_bytecap_(_Size)\n#endif\n/**\n * Global operator new[], defined only inside ICU4C, must not be used.\n * Crashes intentionally.\n * @internal\n */\ninline void *\noperator new[](size_t /*size*/) {\n    char *q=NULL;\n    *q=5; /* break it */\n    return q;\n}\n\n/**\n * Global operator delete, defined only inside ICU4C, must not be used.\n * Crashes intentionally.\n * @internal\n */\ninline void\noperator delete(void * /*p*/) {\n    char *q=NULL;\n    *q=5; /* break it */\n}\n\n/**\n * Global operator delete[], defined only inside ICU4C, must not be used.\n * Crashes intentionally.\n * @internal\n */\ninline void\noperator delete[](void * /*p*/) {\n    char *q=NULL;\n    *q=5; /* break it */\n}\n\n#endif /* U_HIDE_INTERNAL_API */\n#endif\n\n/*===========================================================================*/\n/* UErrorCode */\n/*===========================================================================*/\n\n/**\n * Error code to replace exception handling, so that the code is compatible with all C++ compilers,\n * and to use the same mechanism for C and C++.\n *\n * \\par\n * ICU functions that take a reference (C++) or a pointer (C) to a UErrorCode\n * first test if(U_FAILURE(errorCode)) { return immediately; }\n * so that in a chain of such functions the first one that sets an error code\n * causes the following ones to not perform any operations.\n *\n * \\par\n * Error codes should be tested using U_FAILURE() and U_SUCCESS().\n * @stable ICU 2.0\n */\ntypedef enum UErrorCode {\n    /* The ordering of U_ERROR_INFO_START Vs U_USING_FALLBACK_WARNING looks weird\n     * and is that way because VC++ debugger displays first encountered constant,\n     * which is not the what the code is used for\n     */\n\n    U_USING_FALLBACK_WARNING  = -128,   /**< A resource bundle lookup returned a fallback result (not an error) */\n\n    U_ERROR_WARNING_START     = -128,   /**< Start of information results (semantically successful) */\n\n    U_USING_DEFAULT_WARNING   = -127,   /**< A resource bundle lookup returned a result from the root locale (not an error) */\n\n    U_SAFECLONE_ALLOCATED_WARNING = -126, /**< A SafeClone operation required allocating memory (informational only) */\n\n    U_STATE_OLD_WARNING       = -125,   /**< ICU has to use compatibility layer to construct the service. Expect performance/memory usage degradation. Consider upgrading */\n\n    U_STRING_NOT_TERMINATED_WARNING = -124,/**< An output string could not be NUL-terminated because output length==destCapacity. */\n\n    U_SORT_KEY_TOO_SHORT_WARNING = -123, /**< Number of levels requested in getBound is higher than the number of levels in the sort key */\n\n    U_AMBIGUOUS_ALIAS_WARNING = -122,   /**< This converter alias can go to different converter implementations */\n\n    U_DIFFERENT_UCA_VERSION = -121,     /**< ucol_open encountered a mismatch between UCA version and collator image version, so the collator was constructed from rules. No impact to further function */\n    \n    U_PLUGIN_CHANGED_LEVEL_WARNING = -120, /**< A plugin caused a level change. May not be an error, but later plugins may not load. */\n\n    U_ERROR_WARNING_LIMIT,              /**< This must always be the last warning value to indicate the limit for UErrorCode warnings (last warning code +1) */\n\n\n    U_ZERO_ERROR              =  0,     /**< No error, no warning. */\n\n    U_ILLEGAL_ARGUMENT_ERROR  =  1,     /**< Start of codes indicating failure */\n    U_MISSING_RESOURCE_ERROR  =  2,     /**< The requested resource cannot be found */\n    U_INVALID_FORMAT_ERROR    =  3,     /**< Data format is not what is expected */\n    U_FILE_ACCESS_ERROR       =  4,     /**< The requested file cannot be found */\n    U_INTERNAL_PROGRAM_ERROR  =  5,     /**< Indicates a bug in the library code */\n    U_MESSAGE_PARSE_ERROR     =  6,     /**< Unable to parse a message (message format) */\n    U_MEMORY_ALLOCATION_ERROR =  7,     /**< Memory allocation error */\n    U_INDEX_OUTOFBOUNDS_ERROR =  8,     /**< Trying to access the index that is out of bounds */\n    U_PARSE_ERROR             =  9,     /**< Equivalent to Java ParseException */\n    U_INVALID_CHAR_FOUND      = 10,     /**< Character conversion: Unmappable input sequence. In other APIs: Invalid character. */\n    U_TRUNCATED_CHAR_FOUND    = 11,     /**< Character conversion: Incomplete input sequence. */\n    U_ILLEGAL_CHAR_FOUND      = 12,     /**< Character conversion: Illegal input sequence/combination of input units. */\n    U_INVALID_TABLE_FORMAT    = 13,     /**< Conversion table file found, but corrupted */\n    U_INVALID_TABLE_FILE      = 14,     /**< Conversion table file not found */\n    U_BUFFER_OVERFLOW_ERROR   = 15,     /**< A result would not fit in the supplied buffer */\n    U_UNSUPPORTED_ERROR       = 16,     /**< Requested operation not supported in current context */\n    U_RESOURCE_TYPE_MISMATCH  = 17,     /**< an operation is requested over a resource that does not support it */\n    U_ILLEGAL_ESCAPE_SEQUENCE = 18,     /**< ISO-2022 illlegal escape sequence */\n    U_UNSUPPORTED_ESCAPE_SEQUENCE = 19, /**< ISO-2022 unsupported escape sequence */\n    U_NO_SPACE_AVAILABLE      = 20,     /**< No space available for in-buffer expansion for Arabic shaping */\n    U_CE_NOT_FOUND_ERROR      = 21,     /**< Currently used only while setting variable top, but can be used generally */\n    U_PRIMARY_TOO_LONG_ERROR  = 22,     /**< User tried to set variable top to a primary that is longer than two bytes */\n    U_STATE_TOO_OLD_ERROR     = 23,     /**< ICU cannot construct a service from this state, as it is no longer supported */\n    U_TOO_MANY_ALIASES_ERROR  = 24,     /**< There are too many aliases in the path to the requested resource.\n                                             It is very possible that a circular alias definition has occured */\n    U_ENUM_OUT_OF_SYNC_ERROR  = 25,     /**< UEnumeration out of sync with underlying collection */\n    U_INVARIANT_CONVERSION_ERROR = 26,  /**< Unable to convert a UChar* string to char* with the invariant converter. */\n    U_INVALID_STATE_ERROR     = 27,     /**< Requested operation can not be completed with ICU in its current state */\n    U_COLLATOR_VERSION_MISMATCH = 28,   /**< Collator version is not compatible with the base version */\n    U_USELESS_COLLATOR_ERROR  = 29,     /**< Collator is options only and no base is specified */\n    U_NO_WRITE_PERMISSION     = 30,     /**< Attempt to modify read-only or constant data. */\n\n    U_STANDARD_ERROR_LIMIT,             /**< This must always be the last value to indicate the limit for standard errors */\n    /*\n     * the error code range 0x10000 0x10100 are reserved for Transliterator\n     */\n    U_BAD_VARIABLE_DEFINITION=0x10000,/**< Missing '$' or duplicate variable name */\n    U_PARSE_ERROR_START = 0x10000,    /**< Start of Transliterator errors */\n    U_MALFORMED_RULE,                 /**< Elements of a rule are misplaced */\n    U_MALFORMED_SET,                  /**< A UnicodeSet pattern is invalid*/\n    U_MALFORMED_SYMBOL_REFERENCE,     /**< UNUSED as of ICU 2.4 */\n    U_MALFORMED_UNICODE_ESCAPE,       /**< A Unicode escape pattern is invalid*/\n    U_MALFORMED_VARIABLE_DEFINITION,  /**< A variable definition is invalid */\n    U_MALFORMED_VARIABLE_REFERENCE,   /**< A variable reference is invalid */\n    U_MISMATCHED_SEGMENT_DELIMITERS,  /**< UNUSED as of ICU 2.4 */\n    U_MISPLACED_ANCHOR_START,         /**< A start anchor appears at an illegal position */\n    U_MISPLACED_CURSOR_OFFSET,        /**< A cursor offset occurs at an illegal position */\n    U_MISPLACED_QUANTIFIER,           /**< A quantifier appears after a segment close delimiter */\n    U_MISSING_OPERATOR,               /**< A rule contains no operator */\n    U_MISSING_SEGMENT_CLOSE,          /**< UNUSED as of ICU 2.4 */\n    U_MULTIPLE_ANTE_CONTEXTS,         /**< More than one ante context */\n    U_MULTIPLE_CURSORS,               /**< More than one cursor */\n    U_MULTIPLE_POST_CONTEXTS,         /**< More than one post context */\n    U_TRAILING_BACKSLASH,             /**< A dangling backslash */\n    U_UNDEFINED_SEGMENT_REFERENCE,    /**< A segment reference does not correspond to a defined segment */\n    U_UNDEFINED_VARIABLE,             /**< A variable reference does not correspond to a defined variable */\n    U_UNQUOTED_SPECIAL,               /**< A special character was not quoted or escaped */\n    U_UNTERMINATED_QUOTE,             /**< A closing single quote is missing */\n    U_RULE_MASK_ERROR,                /**< A rule is hidden by an earlier more general rule */\n    U_MISPLACED_COMPOUND_FILTER,      /**< A compound filter is in an invalid location */\n    U_MULTIPLE_COMPOUND_FILTERS,      /**< More than one compound filter */\n    U_INVALID_RBT_SYNTAX,             /**< A \"::id\" rule was passed to the RuleBasedTransliterator parser */\n    U_INVALID_PROPERTY_PATTERN,       /**< UNUSED as of ICU 2.4 */\n    U_MALFORMED_PRAGMA,               /**< A 'use' pragma is invlalid */\n    U_UNCLOSED_SEGMENT,               /**< A closing ')' is missing */\n    U_ILLEGAL_CHAR_IN_SEGMENT,        /**< UNUSED as of ICU 2.4 */\n    U_VARIABLE_RANGE_EXHAUSTED,       /**< Too many stand-ins generated for the given variable range */\n    U_VARIABLE_RANGE_OVERLAP,         /**< The variable range overlaps characters used in rules */\n    U_ILLEGAL_CHARACTER,              /**< A special character is outside its allowed context */\n    U_INTERNAL_TRANSLITERATOR_ERROR,  /**< Internal transliterator system error */\n    U_INVALID_ID,                     /**< A \"::id\" rule specifies an unknown transliterator */\n    U_INVALID_FUNCTION,               /**< A \"&fn()\" rule specifies an unknown transliterator */\n    U_PARSE_ERROR_LIMIT,              /**< The limit for Transliterator errors */\n\n    /*\n     * the error code range 0x10100 0x10200 are reserved for formatting API parsing error\n     */\n    U_UNEXPECTED_TOKEN=0x10100,       /**< Syntax error in format pattern */\n    U_FMT_PARSE_ERROR_START=0x10100,  /**< Start of format library errors */\n    U_MULTIPLE_DECIMAL_SEPARATORS,    /**< More than one decimal separator in number pattern */\n    U_MULTIPLE_DECIMAL_SEPERATORS = U_MULTIPLE_DECIMAL_SEPARATORS, /**< Typo: kept for backward compatibility. Use U_MULTIPLE_DECIMAL_SEPARATORS */\n    U_MULTIPLE_EXPONENTIAL_SYMBOLS,   /**< More than one exponent symbol in number pattern */\n    U_MALFORMED_EXPONENTIAL_PATTERN,  /**< Grouping symbol in exponent pattern */\n    U_MULTIPLE_PERCENT_SYMBOLS,       /**< More than one percent symbol in number pattern */\n    U_MULTIPLE_PERMILL_SYMBOLS,       /**< More than one permill symbol in number pattern */\n    U_MULTIPLE_PAD_SPECIFIERS,        /**< More than one pad symbol in number pattern */\n    U_PATTERN_SYNTAX_ERROR,           /**< Syntax error in format pattern */\n    U_ILLEGAL_PAD_POSITION,           /**< Pad symbol misplaced in number pattern */\n    U_UNMATCHED_BRACES,               /**< Braces do not match in message pattern */\n    U_UNSUPPORTED_PROPERTY,           /**< UNUSED as of ICU 2.4 */\n    U_UNSUPPORTED_ATTRIBUTE,          /**< UNUSED as of ICU 2.4 */\n    U_ARGUMENT_TYPE_MISMATCH,         /**< Argument name and argument index mismatch in MessageFormat functions */\n    U_DUPLICATE_KEYWORD,              /**< Duplicate keyword in PluralFormat */\n    U_UNDEFINED_KEYWORD,              /**< Undefined Plural keyword */\n    U_DEFAULT_KEYWORD_MISSING,        /**< Missing DEFAULT rule in plural rules */\n    U_DECIMAL_NUMBER_SYNTAX_ERROR,    /**< Decimal number syntax error */\n    U_FORMAT_INEXACT_ERROR,           /**< Cannot format a number exactly and rounding mode is ROUND_UNNECESSARY @stable ICU 4.8 */\n    U_FMT_PARSE_ERROR_LIMIT,          /**< The limit for format library errors */\n\n    /*\n     * the error code range 0x10200 0x102ff are reserved for Break Iterator related error\n     */\n    U_BRK_INTERNAL_ERROR=0x10200,          /**< An internal error (bug) was detected.             */\n    U_BRK_ERROR_START=0x10200,             /**< Start of codes indicating Break Iterator failures */\n    U_BRK_HEX_DIGITS_EXPECTED,             /**< Hex digits expected as part of a escaped char in a rule. */\n    U_BRK_SEMICOLON_EXPECTED,              /**< Missing ';' at the end of a RBBI rule.            */\n    U_BRK_RULE_SYNTAX,                     /**< Syntax error in RBBI rule.                        */\n    U_BRK_UNCLOSED_SET,                    /**< UnicodeSet witing an RBBI rule missing a closing ']'.  */\n    U_BRK_ASSIGN_ERROR,                    /**< Syntax error in RBBI rule assignment statement.   */\n    U_BRK_VARIABLE_REDFINITION,            /**< RBBI rule $Variable redefined.                    */\n    U_BRK_MISMATCHED_PAREN,                /**< Mis-matched parentheses in an RBBI rule.          */\n    U_BRK_NEW_LINE_IN_QUOTED_STRING,       /**< Missing closing quote in an RBBI rule.            */\n    U_BRK_UNDEFINED_VARIABLE,              /**< Use of an undefined $Variable in an RBBI rule.    */\n    U_BRK_INIT_ERROR,                      /**< Initialization failure.  Probable missing ICU Data. */\n    U_BRK_RULE_EMPTY_SET,                  /**< Rule contains an empty Unicode Set.               */\n    U_BRK_UNRECOGNIZED_OPTION,             /**< !!option in RBBI rules not recognized.            */\n    U_BRK_MALFORMED_RULE_TAG,              /**< The {nnn} tag on a rule is mal formed             */\n    U_BRK_ERROR_LIMIT,                     /**< This must always be the last value to indicate the limit for Break Iterator failures */\n\n    /*\n     * The error codes in the range 0x10300-0x103ff are reserved for regular expression related errrs\n     */\n    U_REGEX_INTERNAL_ERROR=0x10300,       /**< An internal error (bug) was detected.              */\n    U_REGEX_ERROR_START=0x10300,          /**< Start of codes indicating Regexp failures          */\n    U_REGEX_RULE_SYNTAX,                  /**< Syntax error in regexp pattern.                    */\n    U_REGEX_INVALID_STATE,                /**< RegexMatcher in invalid state for requested operation */\n    U_REGEX_BAD_ESCAPE_SEQUENCE,          /**< Unrecognized backslash escape sequence in pattern  */\n    U_REGEX_PROPERTY_SYNTAX,              /**< Incorrect Unicode property                         */\n    U_REGEX_UNIMPLEMENTED,                /**< Use of regexp feature that is not yet implemented. */\n    U_REGEX_MISMATCHED_PAREN,             /**< Incorrectly nested parentheses in regexp pattern.  */\n    U_REGEX_NUMBER_TOO_BIG,               /**< Decimal number is too large.                       */\n    U_REGEX_BAD_INTERVAL,                 /**< Error in {min,max} interval                        */\n    U_REGEX_MAX_LT_MIN,                   /**< In {min,max}, max is less than min.                */\n    U_REGEX_INVALID_BACK_REF,             /**< Back-reference to a non-existent capture group.    */\n    U_REGEX_INVALID_FLAG,                 /**< Invalid value for match mode flags.                */\n    U_REGEX_LOOK_BEHIND_LIMIT,            /**< Look-Behind pattern matches must have a bounded maximum length.    */\n    U_REGEX_SET_CONTAINS_STRING,          /**< Regexps cannot have UnicodeSets containing strings.*/\n    U_REGEX_OCTAL_TOO_BIG,                /**< Octal character constants must be <= 0377.         */\n    U_REGEX_MISSING_CLOSE_BRACKET,        /**< Missing closing bracket on a bracket expression.   */\n    U_REGEX_INVALID_RANGE,                /**< In a character range [x-y], x is greater than y.   */\n    U_REGEX_STACK_OVERFLOW,               /**< Regular expression backtrack stack overflow.       */\n    U_REGEX_TIME_OUT,                     /**< Maximum allowed match time exceeded                */\n    U_REGEX_STOPPED_BY_CALLER,            /**< Matching operation aborted by user callback fn.    */\n    U_REGEX_ERROR_LIMIT,                  /**< This must always be the last value to indicate the limit for regexp errors */\n\n    /*\n     * The error code in the range 0x10400-0x104ff are reserved for IDNA related error codes\n     */\n    U_IDNA_PROHIBITED_ERROR=0x10400,\n    U_IDNA_ERROR_START=0x10400,\n    U_IDNA_UNASSIGNED_ERROR,\n    U_IDNA_CHECK_BIDI_ERROR,\n    U_IDNA_STD3_ASCII_RULES_ERROR,\n    U_IDNA_ACE_PREFIX_ERROR,\n    U_IDNA_VERIFICATION_ERROR,\n    U_IDNA_LABEL_TOO_LONG_ERROR,\n    U_IDNA_ZERO_LENGTH_LABEL_ERROR,\n    U_IDNA_DOMAIN_NAME_TOO_LONG_ERROR,\n    U_IDNA_ERROR_LIMIT,\n    /*\n     * Aliases for StringPrep\n     */\n    U_STRINGPREP_PROHIBITED_ERROR = U_IDNA_PROHIBITED_ERROR,\n    U_STRINGPREP_UNASSIGNED_ERROR = U_IDNA_UNASSIGNED_ERROR,\n    U_STRINGPREP_CHECK_BIDI_ERROR = U_IDNA_CHECK_BIDI_ERROR,\n    \n    /*\n     * The error code in the range 0x10500-0x105ff are reserved for Plugin related error codes\n     */\n    U_PLUGIN_ERROR_START=0x10500,         /**< Start of codes indicating plugin failures */\n    U_PLUGIN_TOO_HIGH=0x10500,            /**< The plugin's level is too high to be loaded right now. */\n    U_PLUGIN_DIDNT_SET_LEVEL,             /**< The plugin didn't call uplug_setPlugLevel in response to a QUERY */\n    U_PLUGIN_ERROR_LIMIT,                 /**< This must always be the last value to indicate the limit for plugin errors */\n\n    U_ERROR_LIMIT=U_PLUGIN_ERROR_LIMIT      /**< This must always be the last value to indicate the limit for UErrorCode (last error code +1) */\n} UErrorCode;\n\n/* Use the following to determine if an UErrorCode represents */\n/* operational success or failure. */\n\n#ifdef __cplusplus\n    /**\n     * Does the error code indicate success?\n     * @stable ICU 2.0\n     */\n    static\n    inline UBool U_SUCCESS(UErrorCode code) { return (UBool)(code<=U_ZERO_ERROR); }\n    /**\n     * Does the error code indicate a failure?\n     * @stable ICU 2.0\n     */\n    static\n    inline UBool U_FAILURE(UErrorCode code) { return (UBool)(code>U_ZERO_ERROR); }\n#else\n    /**\n     * Does the error code indicate success?\n     * @stable ICU 2.0\n     */\n#   define U_SUCCESS(x) ((x)<=U_ZERO_ERROR)\n    /**\n     * Does the error code indicate a failure?\n     * @stable ICU 2.0\n     */\n#   define U_FAILURE(x) ((x)>U_ZERO_ERROR)\n#endif\n\n/**\n * Return a string for a UErrorCode value.\n * The string will be the same as the name of the error code constant\n * in the UErrorCode enum above.\n * @stable ICU 2.0\n */\nU_STABLE const char * U_EXPORT2\nu_errorName(UErrorCode code);\n\n\n#endif /* _UTYPES */\n"
  },
  {
    "path": "deprecated/android/addons/icucompat/unicode/uvernum.h",
    "content": "/*\n*******************************************************************************\n*   Copyright (C) 2000-2012, International Business Machines\n*   Corporation and others.  All Rights Reserved.\n*******************************************************************************\n*\n*   file name:  uvernum.h\n*   encoding:   US-ASCII\n*   tab size:   8 (not used)\n*   indentation:4\n*\n*   Created by: Vladimir Weinstein\n*   Updated by: Steven R. Loomis\n*\n*/\n\n/**\n * \\file\n * \\brief C API: definitions of ICU version numbers\n * \n * This file is included by uversion.h and other files. This file contains only \n * macros and definitions. The actual version numbers are defined here.\n */\n\n /*\n  * IMPORTANT: When updating version, the following things need to be done:\n  * source/common/unicode/uvernum.h - this file: update major, minor,\n  *        patchlevel, suffix, version, short version constants, namespace,\n  *                    renaming macro, and copyright\n  *\n  * The following files need to be updated as well, which can be done\n  *  by running the UNIX makefile target 'update-windows-makefiles' in icu/source.\n  *\n  *\n  * source/common/common.vcproj - update 'Output file name' on the link tab so\n  *                   that it contains the new major/minor combination\n  * source/i18n/i18n.vcproj - same as for the common.vcproj\n  * source/layout/layout.vcproj - same as for the common.vcproj\n  * source/layoutex/layoutex.vcproj - same\n  * source/stubdata/stubdata.vcproj - same as for the common.vcproj\n  * source/io/io.vcproj - same as for the common.vcproj\n  * source/data/makedata.mak - change U_ICUDATA_NAME so that it contains\n  *                            the new major/minor combination and the Unicode version.\n  */\n\n#ifndef UVERNUM_H\n#define UVERNUM_H\n\n/** The standard copyright notice that gets compiled into each library. \n *  This value will change in the subsequent releases of ICU\n *  @stable ICU 2.4\n */\n#define U_COPYRIGHT_STRING \\\n  \" Copyright (C) 2012, International Business Machines Corporation and others. All Rights Reserved. \"\n\n/** The current ICU major version as an integer. \n *  This value will change in the subsequent releases of ICU\n *  @stable ICU 2.4\n */\n#define U_ICU_VERSION_MAJOR_NUM 50\n\n/** The current ICU minor version as an integer. \n *  This value will change in the subsequent releases of ICU\n *  @stable ICU 2.6\n */\n#define U_ICU_VERSION_MINOR_NUM 1\n\n/** The current ICU patchlevel version as an integer.  \n *  This value will change in the subsequent releases of ICU\n *  @stable ICU 2.4\n */\n#define U_ICU_VERSION_PATCHLEVEL_NUM 1\n\n/** The current ICU build level version as an integer.  \n *  This value is for use by ICU clients. It defaults to 0.\n *  @stable ICU 4.0\n * BEGIN Android patch\n * Update U_ICU_VERSION below for consistency.\n */\n#ifndef U_ICU_VERSION_BUILDLEVEL_NUM\n#define U_ICU_VERSION_BUILDLEVEL_NUM 2\n#endif\n/* END Android patch */\n\n/** Glued version suffix for renamers \n *  This value will change in the subsequent releases of ICU\n *  @stable ICU 2.6\n */\n#define U_ICU_VERSION_SUFFIX _50\n\n/**\n * \\def U_DEF2_ICU_ENTRY_POINT_RENAME\n * @internal\n */\n/**\n * \\def U_DEF_ICU_ENTRY_POINT_RENAME\n * @internal\n */\n/** Glued version suffix function for renamers \n *  This value will change in the subsequent releases of ICU.\n *  If a custom suffix (such as matching library suffixes) is desired, this can be modified.\n *  Note that if present, platform.h may contain an earlier definition of this macro.\n *  \\def U_ICU_ENTRY_POINT_RENAME\n *  @stable ICU 4.2\n */\n\n#ifndef U_ICU_ENTRY_POINT_RENAME\n#ifdef U_HAVE_LIB_SUFFIX\n#define U_DEF_ICU_ENTRY_POINT_RENAME(x,y,z) x ## y ##  z\n#define U_DEF2_ICU_ENTRY_POINT_RENAME(x,y,z) U_DEF_ICU_ENTRY_POINT_RENAME(x,y,z)\n#define U_ICU_ENTRY_POINT_RENAME(x)    U_DEF2_ICU_ENTRY_POINT_RENAME(x,U_ICU_VERSION_SUFFIX,U_LIB_SUFFIX_C_NAME)\n#else\n#define U_DEF_ICU_ENTRY_POINT_RENAME(x,y) x ## y\n#define U_DEF2_ICU_ENTRY_POINT_RENAME(x,y) U_DEF_ICU_ENTRY_POINT_RENAME(x,y)\n#define U_ICU_ENTRY_POINT_RENAME(x)    U_DEF2_ICU_ENTRY_POINT_RENAME(x,U_ICU_VERSION_SUFFIX)\n#endif\n#endif\n\n/** The current ICU library version as a dotted-decimal string. The patchlevel\n *  only appears in this string if it non-zero. \n *  This value will change in the subsequent releases of ICU.\n *  @stable ICU 2.4\n * BEGIN Android patch: We increment the last version field when we make non-trivial changes\n * to Android ICU.\n * Update U_ICU_VERSION_BUILDLEVEL_NUM above for consistency.\n */\n#define U_ICU_VERSION \"50.1.1.2\"\n/* END Android patch */\n\n/** The current ICU library major/minor version as a string without dots, for library name suffixes. \n *  This value will change in the subsequent releases of ICU\n *  @stable ICU 2.6\n */\n#define U_ICU_VERSION_SHORT \"50\"\n\n#ifndef U_HIDE_INTERNAL_API\n/** Data version in ICU4C.\n * @internal ICU 4.4 Internal Use Only\n **/\n#define U_ICU_DATA_VERSION \"50.1\"\n#endif  /* U_HIDE_INTERNAL_API */\n\n/*===========================================================================\n * ICU collation framework version information\n * Version info that can be obtained from a collator is affected by these\n * numbers in a secret and magic way. Please use collator version as whole\n *===========================================================================\n */\n\n/**\n * Collation runtime version (sort key generator, strcoll).\n * If the version is different, sort keys for the same string could be different.\n * This value may change in subsequent releases of ICU.\n * @stable ICU 2.4\n */\n#define UCOL_RUNTIME_VERSION 7\n\n/**\n * Collation builder code version.\n * When this is different, the same tailoring might result\n * in assigning different collation elements to code points.\n * This value may change in subsequent releases of ICU.\n * @stable ICU 2.4\n */\n#define UCOL_BUILDER_VERSION 8\n\n/**\n * This is the version of collation tailorings.\n * This value may change in subsequent releases of ICU.\n * @stable ICU 2.4\n */\n#define UCOL_TAILORINGS_VERSION 1\n\n#endif\n"
  },
  {
    "path": "deprecated/android/addons/icucompat/unicode/uversion.h",
    "content": "/*\n*******************************************************************************\n*   Copyright (C) 2000-2011, International Business Machines\n*   Corporation and others.  All Rights Reserved.\n*******************************************************************************\n*\n*   file name:  uversion.h\n*   encoding:   US-ASCII\n*   tab size:   8 (not used)\n*   indentation:4\n*\n*   Created by: Vladimir Weinstein\n*\n*  Gets included by utypes.h and Windows .rc files\n*/\n\n/**\n * \\file\n * \\brief C API: API for accessing ICU version numbers. \n */\n/*===========================================================================*/\n/* Main ICU version information                                              */\n/*===========================================================================*/\n\n#ifndef UVERSION_H\n#define UVERSION_H\n\n#include \"unicode/umachine.h\"\n\n/* Actual version info lives in uvernum.h */\n#include \"unicode/uvernum.h\"\n\n/** Maximum length of the copyright string.\n *  @stable ICU 2.4\n */\n#define U_COPYRIGHT_STRING_LENGTH  128\n\n/** An ICU version consists of up to 4 numbers from 0..255.\n *  @stable ICU 2.4\n */\n#define U_MAX_VERSION_LENGTH 4\n\n/** In a string, ICU version fields are delimited by dots.\n *  @stable ICU 2.4\n */\n#define U_VERSION_DELIMITER '.'\n\n/** The maximum length of an ICU version string.\n *  @stable ICU 2.4\n */\n#define U_MAX_VERSION_STRING_LENGTH 20\n\n/** The binary form of a version on ICU APIs is an array of 4 uint8_t.\n *  To compare two versions, use memcmp(v1,v2,sizeof(UVersionInfo)).\n *  @stable ICU 2.4\n */\ntypedef uint8_t UVersionInfo[U_MAX_VERSION_LENGTH];\n\n/*===========================================================================*/\n/* C++ namespace if supported. Versioned unless versioning is disabled.      */\n/*===========================================================================*/\n\n/**\n * \\def U_NAMESPACE_BEGIN\n * This is used to begin a declaration of a public ICU C++ API.\n * When not compiling for C++, it does nothing.\n * When compiling for C++, it begins an extern \"C++\" linkage block (to protect\n * against cases in which an external client includes ICU header files inside\n * an extern \"C\" linkage block).\n *\n * It also begins a versioned-ICU-namespace block.\n * @stable ICU 2.4\n */\n\n/**\n * \\def U_NAMESPACE_END\n * This is used to end a declaration of a public ICU C++ API.\n * When not compiling for C++, it does nothing.\n * When compiling for C++, it ends the extern \"C++\" block begun by\n * U_NAMESPACE_BEGIN.\n *\n * It also ends the versioned-ICU-namespace block begun by U_NAMESPACE_BEGIN.\n * @stable ICU 2.4\n */\n\n/**\n * \\def U_NAMESPACE_USE\n * This is used to specify that the rest of the code uses the\n * public ICU C++ API namespace.\n * This is invoked by default; we recommend that you turn it off:\n * See the \"Recommended Build Options\" section of the ICU4C readme\n * (http://source.icu-project.org/repos/icu/icu/trunk/readme.html#RecBuild)\n * @stable ICU 2.4\n */\n\n/**\n * \\def U_NAMESPACE_QUALIFIER\n * This is used to qualify that a function or class is part of\n * the public ICU C++ API namespace.\n *\n * This macro is unnecessary since ICU 49 requires namespace support.\n * You can just use \"icu::\" instead.\n * @stable ICU 2.4\n */\n\n/* Define namespace symbols if the compiler supports it. */\n#ifdef __cplusplus\n#   if U_DISABLE_RENAMING\n#       define U_ICU_NAMESPACE icu\n        namespace U_ICU_NAMESPACE { }\n#   else\n#       define U_ICU_NAMESPACE U_ICU_ENTRY_POINT_RENAME(icu)\n        namespace U_ICU_NAMESPACE { }\n        namespace icu = U_ICU_NAMESPACE;\n#   endif\n\n#   define U_NAMESPACE_BEGIN extern \"C++\" { namespace U_ICU_NAMESPACE {\n#   define U_NAMESPACE_END } }\n#   define U_NAMESPACE_USE using namespace U_ICU_NAMESPACE;\n#   define U_NAMESPACE_QUALIFIER U_ICU_NAMESPACE::\n\n#   ifndef U_USING_ICU_NAMESPACE\n#       define U_USING_ICU_NAMESPACE 1\n#   endif\n#   if U_USING_ICU_NAMESPACE\n        U_NAMESPACE_USE\n#   endif\n#else\n#   define U_NAMESPACE_BEGIN\n#   define U_NAMESPACE_END\n#   define U_NAMESPACE_USE\n#   define U_NAMESPACE_QUALIFIER\n#endif\n\n/*===========================================================================*/\n/* General version helper functions. Definitions in putil.c                  */\n/*===========================================================================*/\n\n/**\n * Parse a string with dotted-decimal version information and\n * fill in a UVersionInfo structure with the result.\n * Definition of this function lives in putil.c\n *\n * @param versionArray The destination structure for the version information.\n * @param versionString A string with dotted-decimal version information,\n *                      with up to four non-negative number fields with\n *                      values of up to 255 each.\n * @stable ICU 2.4\n */\nU_STABLE void U_EXPORT2\nu_versionFromString(UVersionInfo versionArray, const char *versionString);\n\n/**\n * Parse a Unicode string with dotted-decimal version information and\n * fill in a UVersionInfo structure with the result.\n * Definition of this function lives in putil.c\n *\n * @param versionArray The destination structure for the version information.\n * @param versionString A Unicode string with dotted-decimal version\n *                      information, with up to four non-negative number\n *                      fields with values of up to 255 each.\n * @stable ICU 4.2\n */\nU_STABLE void U_EXPORT2\nu_versionFromUString(UVersionInfo versionArray, const UChar *versionString);\n\n\n/**\n * Write a string with dotted-decimal version information according\n * to the input UVersionInfo.\n * Definition of this function lives in putil.c\n *\n * @param versionArray The version information to be written as a string.\n * @param versionString A string buffer that will be filled in with\n *                      a string corresponding to the numeric version\n *                      information in versionArray.\n *                      The buffer size must be at least U_MAX_VERSION_STRING_LENGTH.\n * @stable ICU 2.4\n */\nU_STABLE void U_EXPORT2\nu_versionToString(const UVersionInfo versionArray, char *versionString);\n\n/**\n * Gets the ICU release version.  The version array stores the version information\n * for ICU.  For example, release \"1.3.31.2\" is then represented as 0x01031F02.\n * Definition of this function lives in putil.c\n *\n * @param versionArray the version # information, the result will be filled in\n * @stable ICU 2.0\n */\nU_STABLE void U_EXPORT2\nu_getVersion(UVersionInfo versionArray);\n#endif\n"
  },
  {
    "path": "deprecated/android/addons/icucompat/unicode/vtzone.h",
    "content": "/*\n*******************************************************************************\n* Copyright (C) 2007-2012, International Business Machines Corporation and\n* others. All Rights Reserved.\n*******************************************************************************\n*/\n#ifndef VTZONE_H\n#define VTZONE_H\n\n#include \"unicode/utypes.h\"\n\n/**\n * \\file \n * \\brief C++ API: RFC2445 VTIMEZONE support\n */\n\n#if !UCONFIG_NO_FORMATTING\n\n#include \"unicode/basictz.h\"\n\nU_NAMESPACE_BEGIN\n\nclass VTZWriter;\nclass VTZReader;\nclass UVector;\n\n/**\n * <code>VTimeZone</code> is a class implementing RFC2445 VTIMEZONE.  You can create a\n * <code>VTimeZone</code> instance from a time zone ID supported by <code>TimeZone</code>.\n * With the <code>VTimeZone</code> instance created from the ID, you can write out the rule\n * in RFC2445 VTIMEZONE format.  Also, you can create a <code>VTimeZone</code> instance\n * from RFC2445 VTIMEZONE data stream, which allows you to calculate time\n * zone offset by the rules defined by the data. Or, you can create a\n * <code>VTimeZone</code> from any other ICU <code>BasicTimeZone</code>.\n * <br><br>\n * Note: The consumer of this class reading or writing VTIMEZONE data is responsible to\n * decode or encode Non-ASCII text.  Methods reading/writing VTIMEZONE data in this class\n * do nothing with MIME encoding.\n * @stable ICU 3.8\n */\nclass U_I18N_API VTimeZone : public BasicTimeZone {\npublic:\n    /**\n     * Copy constructor.\n     * @param source    The <code>VTimeZone</code> object to be copied.\n     * @stable ICU 3.8\n     */\n    VTimeZone(const VTimeZone& source);\n\n    /**\n     * Destructor.\n     * @stable ICU 3.8\n     */\n    virtual ~VTimeZone();\n\n    /**\n     * Assignment operator.\n     * @param right The object to be copied.\n     * @stable ICU 3.8\n     */\n    VTimeZone& operator=(const VTimeZone& right);\n\n    /**\n     * Return true if the given <code>TimeZone</code> objects are\n     * semantically equal. Objects of different subclasses are considered unequal.\n     * @param that  The object to be compared with.\n     * @return  true if the given <code>TimeZone</code> objects are\n      *semantically equal.\n     * @stable ICU 3.8\n     */\n    virtual UBool operator==(const TimeZone& that) const;\n\n    /**\n     * Return true if the given <code>TimeZone</code> objects are\n     * semantically unequal. Objects of different subclasses are considered unequal.\n     * @param that  The object to be compared with.\n     * @return  true if the given <code>TimeZone</code> objects are\n     * semantically unequal.\n     * @stable ICU 3.8\n     */\n    virtual UBool operator!=(const TimeZone& that) const;\n\n    /**\n     * Create a <code>VTimeZone</code> instance by the time zone ID.\n     * @param ID The time zone ID, such as America/New_York\n     * @return A <code>VTimeZone</code> object initialized by the time zone ID,\n     * or NULL when the ID is unknown.\n     * @stable ICU 3.8\n     */\n    static VTimeZone* createVTimeZoneByID(const UnicodeString& ID);\n\n    /**\n     * Create a <code>VTimeZone</code> instance using a basic time zone.\n     * @param basicTZ The basic time zone instance\n     * @param status Output param to filled in with a success or an error.\n     * @return A <code>VTimeZone</code> object initialized by the basic time zone.\n     * @stable ICU 4.6\n     */\n    static VTimeZone* createVTimeZoneFromBasicTimeZone(const BasicTimeZone& basicTZ,\n                                                       UErrorCode &status);\n\n    /**\n     * Create a <code>VTimeZone</code> instance by RFC2445 VTIMEZONE data\n     * \n     * @param vtzdata The string including VTIMEZONE data block\n     * @param status Output param to filled in with a success or an error.\n     * @return A <code>VTimeZone</code> initialized by the VTIMEZONE data or\n     * NULL if failed to load the rule from the VTIMEZONE data.\n     * @stable ICU 3.8\n     */\n    static VTimeZone* createVTimeZone(const UnicodeString& vtzdata, UErrorCode& status);\n\n    /**\n     * Gets the RFC2445 TZURL property value.  When a <code>VTimeZone</code> instance was\n     * created from VTIMEZONE data, the initial value is set by the TZURL property value\n     * in the data.  Otherwise, the initial value is not set.\n     * @param url Receives the RFC2445 TZURL property value.\n     * @return TRUE if TZURL attribute is available and value is set.\n     * @stable ICU 3.8\n     */\n    UBool getTZURL(UnicodeString& url) const;\n\n    /**\n     * Sets the RFC2445 TZURL property value.\n     * @param url The TZURL property value.\n     * @stable ICU 3.8\n     */\n    void setTZURL(const UnicodeString& url);\n\n    /**\n     * Gets the RFC2445 LAST-MODIFIED property value.  When a <code>VTimeZone</code> instance\n     * was created from VTIMEZONE data, the initial value is set by the LAST-MODIFIED property\n     * value in the data.  Otherwise, the initial value is not set.\n     * @param lastModified Receives the last modified date.\n     * @return TRUE if lastModified attribute is available and value is set.\n     * @stable ICU 3.8\n     */\n    UBool getLastModified(UDate& lastModified) const;\n\n    /**\n     * Sets the RFC2445 LAST-MODIFIED property value.\n     * @param lastModified The LAST-MODIFIED date.\n     * @stable ICU 3.8\n     */\n    void setLastModified(UDate lastModified);\n\n    /**\n     * Writes RFC2445 VTIMEZONE data for this time zone\n     * @param result Output param to filled in with the VTIMEZONE data.\n     * @param status Output param to filled in with a success or an error.\n     * @stable ICU 3.8\n     */\n    void write(UnicodeString& result, UErrorCode& status) const;\n\n    /**\n     * Writes RFC2445 VTIMEZONE data for this time zone applicalbe\n     * for dates after the specified start time.\n     * @param start The start date.\n     * @param result Output param to filled in with the VTIMEZONE data.\n     * @param status Output param to filled in with a success or an error.\n     * @stable ICU 3.8\n     */\n    void write(UDate start, UnicodeString& result, UErrorCode& status) /*const*/;\n\n    /**\n     * Writes RFC2445 VTIMEZONE data applicalbe for the specified date.\n     * Some common iCalendar implementations can only handle a single time\n     * zone property or a pair of standard and daylight time properties using\n     * BYDAY rule with day of week (such as BYDAY=1SUN).  This method produce\n     * the VTIMEZONE data which can be handled these implementations.  The rules\n     * produced by this method can be used only for calculating time zone offset\n     * around the specified date.\n     * @param time The date used for rule extraction.\n     * @param result Output param to filled in with the VTIMEZONE data.\n     * @param status Output param to filled in with a success or an error.\n     * @stable ICU 3.8\n     */\n    void writeSimple(UDate time, UnicodeString& result, UErrorCode& status) /*const*/;\n\n    /**\n     * Clones TimeZone objects polymorphically. Clients are responsible for deleting\n     * the TimeZone object cloned.\n     * @return   A new copy of this TimeZone object.\n     * @stable ICU 3.8\n     */\n    virtual TimeZone* clone(void) const;\n\n    /**\n     * Returns the TimeZone's adjusted GMT offset (i.e., the number of milliseconds to add\n     * to GMT to get local time in this time zone, taking daylight savings time into\n     * account) as of a particular reference date.  The reference date is used to determine\n     * whether daylight savings time is in effect and needs to be figured into the offset\n     * that is returned (in other words, what is the adjusted GMT offset in this time zone\n     * at this particular date and time?).  For the time zones produced by createTimeZone(),\n     * the reference data is specified according to the Gregorian calendar, and the date\n     * and time fields are local standard time.\n     *\n     * <p>Note: Don't call this method. Instead, call the getOffset(UDate...) overload,\n     * which returns both the raw and the DST offset for a given time. This method\n     * is retained only for backward compatibility.\n     *\n     * @param era        The reference date's era\n     * @param year       The reference date's year\n     * @param month      The reference date's month (0-based; 0 is January)\n     * @param day        The reference date's day-in-month (1-based)\n     * @param dayOfWeek  The reference date's day-of-week (1-based; 1 is Sunday)\n     * @param millis     The reference date's milliseconds in day, local standard time\n     * @param status     Output param to filled in with a success or an error.\n     * @return           The offset in milliseconds to add to GMT to get local time.\n     * @stable ICU 3.8\n     */\n    virtual int32_t getOffset(uint8_t era, int32_t year, int32_t month, int32_t day,\n                              uint8_t dayOfWeek, int32_t millis, UErrorCode& status) const;\n\n    /**\n     * Gets the time zone offset, for current date, modified in case of\n     * daylight savings. This is the offset to add *to* UTC to get local time.\n     *\n     * <p>Note: Don't call this method. Instead, call the getOffset(UDate...) overload,\n     * which returns both the raw and the DST offset for a given time. This method\n     * is retained only for backward compatibility.\n     *\n     * @param era        The reference date's era\n     * @param year       The reference date's year\n     * @param month      The reference date's month (0-based; 0 is January)\n     * @param day        The reference date's day-in-month (1-based)\n     * @param dayOfWeek  The reference date's day-of-week (1-based; 1 is Sunday)\n     * @param millis     The reference date's milliseconds in day, local standard time\n     * @param monthLength The length of the given month in days.\n     * @param status     Output param to filled in with a success or an error.\n     * @return           The offset in milliseconds to add to GMT to get local time.\n     * @stable ICU 3.8\n     */\n    virtual int32_t getOffset(uint8_t era, int32_t year, int32_t month, int32_t day,\n                           uint8_t dayOfWeek, int32_t millis,\n                           int32_t monthLength, UErrorCode& status) const;\n\n    /**\n     * Returns the time zone raw and GMT offset for the given moment\n     * in time.  Upon return, local-millis = GMT-millis + rawOffset +\n     * dstOffset.  All computations are performed in the proleptic\n     * Gregorian calendar.  The default implementation in the TimeZone\n     * class delegates to the 8-argument getOffset().\n     *\n     * @param date moment in time for which to return offsets, in\n     * units of milliseconds from January 1, 1970 0:00 GMT, either GMT\n     * time or local wall time, depending on `local'.\n     * @param local if true, `date' is local wall time; otherwise it\n     * is in GMT time.\n     * @param rawOffset output parameter to receive the raw offset, that\n     * is, the offset not including DST adjustments\n     * @param dstOffset output parameter to receive the DST offset,\n     * that is, the offset to be added to `rawOffset' to obtain the\n     * total offset between local and GMT time. If DST is not in\n     * effect, this value is zero; otherwise it is a positive value,\n     * typically one hour.\n     * @param ec input-output error code\n     * @stable ICU 3.8\n     */\n    virtual void getOffset(UDate date, UBool local, int32_t& rawOffset,\n                           int32_t& dstOffset, UErrorCode& ec) const;\n\n    /**\n     * Sets the TimeZone's raw GMT offset (i.e., the number of milliseconds to add\n     * to GMT to get local time, before taking daylight savings time into account).\n     *\n     * @param offsetMillis  The new raw GMT offset for this time zone.\n     * @stable ICU 3.8\n     */\n    virtual void setRawOffset(int32_t offsetMillis);\n\n    /**\n     * Returns the TimeZone's raw GMT offset (i.e., the number of milliseconds to add\n     * to GMT to get local time, before taking daylight savings time into account).\n     *\n     * @return   The TimeZone's raw GMT offset.\n     * @stable ICU 3.8\n     */\n    virtual int32_t getRawOffset(void) const;\n\n    /**\n     * Queries if this time zone uses daylight savings time.\n     * @return true if this time zone uses daylight savings time,\n     * false, otherwise.\n     * @stable ICU 3.8\n     */\n    virtual UBool useDaylightTime(void) const;\n\n    /**\n     * Queries if the given date is in daylight savings time in\n     * this time zone.\n     * This method is wasteful since it creates a new GregorianCalendar and\n     * deletes it each time it is called. This is a deprecated method\n     * and provided only for Java compatibility.\n     *\n     * @param date the given UDate.\n     * @param status Output param filled in with success/error code.\n     * @return true if the given date is in daylight savings time,\n     * false, otherwise.\n     * @deprecated ICU 2.4. Use Calendar::inDaylightTime() instead.\n     */\n    virtual UBool inDaylightTime(UDate date, UErrorCode& status) const;\n\n    /**\n     * Returns true if this zone has the same rule and offset as another zone.\n     * That is, if this zone differs only in ID, if at all.\n     * @param other the <code>TimeZone</code> object to be compared with\n     * @return true if the given zone is the same as this one,\n     * with the possible exception of the ID\n     * @stable ICU 3.8\n     */\n    virtual UBool hasSameRules(const TimeZone& other) const;\n\n    /**\n     * Gets the first time zone transition after the base time.\n     * @param base      The base time.\n     * @param inclusive Whether the base time is inclusive or not.\n     * @param result    Receives the first transition after the base time.\n     * @return  TRUE if the transition is found.\n     * @stable ICU 3.8\n     */\n    virtual UBool getNextTransition(UDate base, UBool inclusive, TimeZoneTransition& result) /*const*/;\n\n    /**\n     * Gets the most recent time zone transition before the base time.\n     * @param base      The base time.\n     * @param inclusive Whether the base time is inclusive or not.\n     * @param result    Receives the most recent transition before the base time.\n     * @return  TRUE if the transition is found.\n     * @stable ICU 3.8\n     */\n    virtual UBool getPreviousTransition(UDate base, UBool inclusive, TimeZoneTransition& result) /*const*/;\n\n    /**\n     * Returns the number of <code>TimeZoneRule</code>s which represents time transitions,\n     * for this time zone, that is, all <code>TimeZoneRule</code>s for this time zone except\n     * <code>InitialTimeZoneRule</code>.  The return value range is 0 or any positive value.\n     * @param status    Receives error status code.\n     * @return The number of <code>TimeZoneRule</code>s representing time transitions.\n     * @stable ICU 3.8\n     */\n    virtual int32_t countTransitionRules(UErrorCode& status) /*const*/;\n\n    /**\n     * Gets the <code>InitialTimeZoneRule</code> and the set of <code>TimeZoneRule</code>\n     * which represent time transitions for this time zone.  On successful return,\n     * the argument initial points to non-NULL <code>InitialTimeZoneRule</code> and\n     * the array trsrules is filled with 0 or multiple <code>TimeZoneRule</code>\n     * instances up to the size specified by trscount.  The results are referencing the\n     * rule instance held by this time zone instance.  Therefore, after this time zone\n     * is destructed, they are no longer available.\n     * @param initial       Receives the initial timezone rule\n     * @param trsrules      Receives the timezone transition rules\n     * @param trscount      On input, specify the size of the array 'transitions' receiving\n     *                      the timezone transition rules.  On output, actual number of\n     *                      rules filled in the array will be set.\n     * @param status        Receives error status code.\n     * @stable ICU 3.8\n     */\n    virtual void getTimeZoneRules(const InitialTimeZoneRule*& initial,\n        const TimeZoneRule* trsrules[], int32_t& trscount, UErrorCode& status) /*const*/;\n\nprivate:\n    enum { DEFAULT_VTIMEZONE_LINES = 100 };\n\n    /**\n     * Default constructor.\n     */\n    VTimeZone();\n    static VTimeZone* createVTimeZone(VTZReader* reader);\n    void write(VTZWriter& writer, UErrorCode& status) const;\n    void write(UDate start, VTZWriter& writer, UErrorCode& status) /*const*/;\n    void writeSimple(UDate time, VTZWriter& writer, UErrorCode& status) /*const*/;\n    void load(VTZReader& reader, UErrorCode& status);\n    void parse(UErrorCode& status);\n\n    void writeZone(VTZWriter& w, BasicTimeZone& basictz, UVector* customProps,\n        UErrorCode& status) const;\n\n    void writeHeaders(VTZWriter& w, UErrorCode& status) const;\n    void writeFooter(VTZWriter& writer, UErrorCode& status) const;\n\n    void writeZonePropsByTime(VTZWriter& writer, UBool isDst, const UnicodeString& zonename,\n                              int32_t fromOffset, int32_t toOffset, UDate time, UBool withRDATE,\n                              UErrorCode& status) const;\n    void writeZonePropsByDOM(VTZWriter& writer, UBool isDst, const UnicodeString& zonename,\n                             int32_t fromOffset, int32_t toOffset,\n                             int32_t month, int32_t dayOfMonth, UDate startTime, UDate untilTime,\n                             UErrorCode& status) const;\n    void writeZonePropsByDOW(VTZWriter& writer, UBool isDst, const UnicodeString& zonename,\n                             int32_t fromOffset, int32_t toOffset,\n                             int32_t month, int32_t weekInMonth, int32_t dayOfWeek,\n                             UDate startTime, UDate untilTime, UErrorCode& status) const;\n    void writeZonePropsByDOW_GEQ_DOM(VTZWriter& writer, UBool isDst, const UnicodeString& zonename,\n                                     int32_t fromOffset, int32_t toOffset,\n                                     int32_t month, int32_t dayOfMonth, int32_t dayOfWeek,\n                                     UDate startTime, UDate untilTime, UErrorCode& status) const;\n    void writeZonePropsByDOW_GEQ_DOM_sub(VTZWriter& writer, int32_t month, int32_t dayOfMonth,\n                                         int32_t dayOfWeek, int32_t numDays,\n                                         UDate untilTime, int32_t fromOffset, UErrorCode& status) const;\n    void writeZonePropsByDOW_LEQ_DOM(VTZWriter& writer, UBool isDst, const UnicodeString& zonename,\n                                     int32_t fromOffset, int32_t toOffset,\n                                     int32_t month, int32_t dayOfMonth, int32_t dayOfWeek,\n                                     UDate startTime, UDate untilTime, UErrorCode& status) const;\n    void writeFinalRule(VTZWriter& writer, UBool isDst, const AnnualTimeZoneRule* rule,\n                        int32_t fromRawOffset, int32_t fromDSTSavings,\n                        UDate startTime, UErrorCode& status) const;\n\n    void beginZoneProps(VTZWriter& writer, UBool isDst, const UnicodeString& zonename,\n                        int32_t fromOffset, int32_t toOffset, UDate startTime, UErrorCode& status) const;\n    void endZoneProps(VTZWriter& writer, UBool isDst, UErrorCode& status) const;\n    void beginRRULE(VTZWriter& writer, int32_t month, UErrorCode& status) const;\n    void appendUNTIL(VTZWriter& writer, const UnicodeString& until, UErrorCode& status) const;\n\n    BasicTimeZone   *tz;\n    UVector         *vtzlines;\n    UnicodeString   tzurl;\n    UDate           lastmod;\n    UnicodeString   olsonzid;\n    UnicodeString   icutzver;\n\npublic:\n    /**\n     * Return the class ID for this class. This is useful only for comparing to\n     * a return value from getDynamicClassID(). For example:\n     * <pre>\n     * .   Base* polymorphic_pointer = createPolymorphicObject();\n     * .   if (polymorphic_pointer->getDynamicClassID() ==\n     * .       erived::getStaticClassID()) ...\n     * </pre>\n     * @return          The class ID for all objects of this class.\n     * @stable ICU 3.8\n     */\n    static UClassID U_EXPORT2 getStaticClassID(void);\n\n    /**\n     * Returns a unique class ID POLYMORPHICALLY. Pure virtual override. This\n     * method is to implement a simple version of RTTI, since not all C++\n     * compilers support genuine RTTI. Polymorphic operator==() and clone()\n     * methods call this method.\n     *\n     * @return          The class ID for this object. All objects of a\n     *                  given class have the same class ID.  Objects of\n     *                  other classes have different class IDs.\n     * @stable ICU 3.8\n     */\n    virtual UClassID getDynamicClassID(void) const;\n};\n\nU_NAMESPACE_END\n\n#endif /* #if !UCONFIG_NO_FORMATTING */\n\n#endif // VTZONE_H\n//eof\n"
  },
  {
    "path": "deprecated/android/addons/repair/SQLiteRepairKit.h",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#ifndef SQLiteRepairKit_h\n#define SQLiteRepairKit_h\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n#include <stdlib.h>\n\ntypedef struct sqliterk sqliterk;\ntypedef struct sqliterk_table sqliterk_table;\ntypedef struct sqliterk_column sqliterk_column;\n\ntypedef struct sqliterk_notify sqliterk_notify;\nstruct sqliterk_notify {\n    void (*onBeginParseTable)(sqliterk *rk, sqliterk_table *table);\n    // Only a column that make sense will trigger this callback,\n    // which is the column in a non-system table or the \"sqlite_master\"\n    // return SQLITERK_OK to tell sqliterk that you already know that\n    // meaning of this column\n    int (*onParseColumn)(sqliterk *rk,\n                         sqliterk_table *table,\n                         sqliterk_column *column);\n    void (*onEndParseTable)(sqliterk *rk, sqliterk_table *table);\n    void (*didParsePage)(sqliterk *rk, int pageno);\n};\nint sqliterk_register_notify(sqliterk *rk, sqliterk_notify notify);\n\ntypedef struct sqliterk_cipher_conf {\n    const void *key;\n    int key_len;\n    int page_size;\n    int kdf_iter;\n    int use_hmac;\n    const unsigned char *kdf_salt;\n} sqliterk_cipher_conf;\n    \nvoid sqliterk_cipher_conf_set_key(sqliterk_cipher_conf *conf, const void* key, int key_len);\n\ntypedef struct sqlite3 sqlite3;\ntypedef struct sqliterk_master_info sqliterk_master_info;\ntypedef struct sqliterk_leaf_info sqliterk_leaf_info;\n\n#define SQLITERK_OUTPUT_NO_CREATE_TABLES 0x0001\n#define SQLITERK_OUTPUT_ALL_TABLES 0x0002\n#define SQLITERK_OUTPUT_CHECK_TABLE_COLUMNS 0x0004\n\nint sqliterk_open(const char *path,\n                  const sqliterk_cipher_conf *cipher,\n                  sqliterk **rk);\nint sqliterk_parse(sqliterk *rk);\nint sqliterk_parse_page(sqliterk *rk, int pageno);\nint sqliterk_parse_master(sqliterk *rk);\nint sqliterk_close(sqliterk *rk);\nvoid *sqliterk_get_user_info(sqliterk *rk);\nvoid sqliterk_set_user_info(sqliterk *rk, void *userInfo);\nvoid sqliterk_set_recursive(sqliterk *rk, int recursive);\n\nint sqliterk_output(sqliterk *rk,\n                    sqlite3 *db,\n                    sqliterk_master_info *master,\n                    unsigned int flags);\nint sqliterk_output_cb(sqliterk *rk,\n                       sqlite3 *db,\n                       sqliterk_master_info *master,\n                       unsigned int flags,\n                       int (*callback)(void *user,\n                                       sqliterk *rk,\n                                       sqliterk_table *table,\n                                       sqliterk_column *column),\n                       void *user);\nint sqliterk_output_cb_leaf(sqliterk *rk,\n                            sqlite3 *db,\n                            sqliterk_master_info *master,\n                            sqliterk_leaf_info *leaf,\n                            unsigned int flags,\n                            int (*callback)(void *user,\n                                            sqliterk *rk,\n                                            sqliterk_table *table,\n                                            sqliterk_column *column),\n                            void *user);\nvoid sqliterk_cancel(sqliterk *rk);\nint sqliterk_make_master(const char **tables,\n                         int num_tables,\n                         sqliterk_master_info **out_master);\nint sqliterk_save_master(sqlite3 *db,\n                         const char *path,\n                         const void *key,\n                         int key_len);\nint sqliterk_load_master(const char *path,\n                         const void *key,\n                         int key_len,\n                         const char **tables,\n                         int num_tables,\n                         sqliterk_master_info **out_master,\n                         unsigned char *out_kdf_salt);\nvoid sqliterk_free_master(sqliterk_master_info *master);\nint sqliterk_scan_leaf(sqlite3 *db, const char * const *tables, int num_tables,\n                       sqliterk_leaf_info **out, volatile int *cancelFlag);\nint sqliterk_save_leaf(const sqliterk_leaf_info *li, const char *path);\nint sqliterk_load_leaf(const char *path, sqliterk_leaf_info** out);\nvoid sqliterk_free_leaf(sqliterk_leaf_info *li);\n\n// A database may have many kind of tables or indexes, such as a customized\n// index or a system-level table and so on. But you should be only concern\n// about the listed types below.\n// Since the system-level tables or indexes is generated. And you do know\n// the index of a certain table (you make this table).\ntypedef enum {\n    sqliterk_type_index = -2,\n    sqliterk_type_table = -1,\n    sqliterk_type_unknown = 0,\n    sqliterk_type_sequence = 1,\n    sqliterk_type_autoindex = 2,\n    sqliterk_type_stat = 3,\n    sqliterk_type_master = 4,\n} sqliterk_type;\n\n// This method may return NULL since SQLiteRepairKir may not understand\n// a corrupted b-tree.\nconst char *sqliterk_table_name(sqliterk_table *table);\nsqliterk_type sqliterk_table_type(sqliterk_table *table);\nint sqliterk_table_root(sqliterk_table *table);\nvoid sqliterk_table_set_user_info(sqliterk_table *table, void *userInfo);\nvoid *sqliterk_table_get_user_info(sqliterk_table *table);\n\ntypedef enum {\n    sqliterk_value_type_null,\n    sqliterk_value_type_integer,\n    sqliterk_value_type_number,\n    sqliterk_value_type_text,\n    sqliterk_value_type_binary,\n} sqliterk_value_type;\n\nint sqliterk_column_count(sqliterk_column *column);\nsqliterk_value_type sqliterk_column_type(sqliterk_column *column, int index);\nint sqliterk_column_integer(sqliterk_column *column, int index);\nint64_t sqliterk_column_integer64(sqliterk_column *column, int index);\ndouble sqliterk_column_number(sqliterk_column *column, int index);\nconst char *sqliterk_column_text(sqliterk_column *column, int index);\nconst void *sqliterk_column_binary(sqliterk_column *column, int index);\nint sqliterk_column_bytes(sqliterk_column *column, int index);\nint64_t sqliterk_column_rowid(sqliterk_column *column);\n\n#define SQLITERK_INTEGRITY_HEADER 0x0001\n#define SQLITERK_INTEGRITY_DATA 0x0002\n#define SQLITERK_INTEGRITY_KDF_SALT 0x0004\n\nint sqliterk_parsed_page_count(sqliterk *rk);\nint sqliterk_damaged_page_count(sqliterk *rk);\nint sqliterk_valid_page_count(sqliterk *rk);\nint sqliterk_page_count(sqliterk *rk);\nunsigned int sqliterk_integrity(sqliterk *rk);\n\ntypedef enum {\n    sqliterk_loglevel_debug,\n    sqliterk_loglevel_warning,\n    sqliterk_loglevel_error,\n    sqliterk_loglevel_info,\n} sqliterk_loglevel;\n\ntypedef struct sqliterk_os sqliterk_os;\nstruct sqliterk_os {\n    void (*xLog)(sqliterk_loglevel level, int result, const char *msg);\n    //TODO\n};\nint sqliterk_register(sqliterk_os os);\n\n#define SQLITERK_OK 0\n#define SQLITERK_CANTOPEN 1\n#define SQLITERK_MISUSE 2\n#define SQLITERK_IOERR 3\n#define SQLITERK_NOMEM 4\n#define SQLITERK_SHORT_READ 5\n#define SQLITERK_DAMAGED 6\n#define SQLITERK_DISCARD 7\n#define SQLITERK_CANCELLED 8\n#define SQLITERK_IGNORE 100\nconst char *sqliterk_description(int result);\n\n#ifndef SQLITRK_CONFIG_DEFAULT_PAGESIZE\n#define SQLITRK_CONFIG_DEFAULT_PAGESIZE 4096\n#endif\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* SQLiteRepairKit_h */\n"
  },
  {
    "path": "deprecated/android/addons/repair/sqliterk.c",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"sqliterk.h\"\n#include \"SQLiteRepairKit.h\"\n#include \"sqliterk_btree.h\"\n#include \"sqliterk_column.h\"\n#include \"sqliterk_os.h\"\n#include \"sqliterk_pager.h\"\n#include \"sqliterk_util.h\"\n#include \"sqliterk_values.h\"\n#include <string.h>\n\nstruct sqliterk {\n    sqliterk_pager *pager;\n    sqliterk_btree_notify listen;\n    sqliterk_notify notify;\n    void *userInfo;\n    char recursive;\n};\n\n//declaration\nstatic void sqliterkNotify_onBeginParseBtree(sqliterk *rk,\n                                             sqliterk_btree *btree);\nstatic void\nsqliterkNotify_onEndParseBtree(sqliterk *rk, sqliterk_btree *btree, int result);\nstatic int sqliterkNotify_onParseColumn(sqliterk *rk,\n                                        sqliterk_btree *btree,\n                                        sqliterk_page *page,\n                                        sqliterk_column *column);\nstatic int sqliterkNotify_onBeginParsePage(sqliterk *rk,\n                                           sqliterk_btree *btree,\n                                           int pageno);\nstatic void sqliterkNotify_onEndParsePage(sqliterk *rk,\n                                          sqliterk_btree *btree,\n                                          int pageno,\n                                          int result);\nstatic int sqliterkParseBtree(sqliterk *rk, sqliterk_btree *btree);\n\nint sqliterkOpen(const char *path,\n                 const sqliterk_cipher_conf *cipher,\n                 sqliterk **rk)\n{\n    if (!rk) {\n        return SQLITERK_MISUSE;\n    }\n    int rc = SQLITERK_OK;\n    sqliterk *therk = sqliterkOSMalloc(sizeof(sqliterk));\n    if (!therk) {\n        rc = SQLITERK_NOMEM;\n        sqliterkOSError(rc, \"Not enough memory, required: %zu bytes\",\n                        sizeof(sqliterk));\n        goto sqliterkOpen_Failed;\n    }\n\n    rc = sqliterkPagerOpen(path, cipher, &therk->pager);\n    if (rc != SQLITERK_OK) {\n        goto sqliterkOpen_Failed;\n    }\n\n    therk->listen.onBeginParsePage = sqliterkNotify_onBeginParsePage;\n    therk->listen.onEndParsePage = sqliterkNotify_onEndParsePage;\n    therk->listen.onBeginParseBtree = sqliterkNotify_onBeginParseBtree;\n    therk->listen.onEndParseBtree = sqliterkNotify_onEndParseBtree;\n    therk->listen.onParseColumn = sqliterkNotify_onParseColumn;\n    therk->recursive = 1;\n\n    *rk = therk;\n    sqliterkOSInfo(SQLITERK_OK, \"RepairKit on '%s' opened, %s.\", path,\n                   cipher ? \"encrypted\" : \"plain-text\");\n    return SQLITERK_OK;\n\nsqliterkOpen_Failed:\n    if (therk) {\n        sqliterkClose(therk);\n    }\n    *rk = NULL;\n    return rc;\n}\n\nvoid sqliterk_set_recursive(sqliterk *rk, int recursive)\n{\n    rk->recursive = (char) recursive;\n}\n\nint sqliterkParse(sqliterk *rk)\n{\n    if (!rk) {\n        return SQLITERK_MISUSE;\n    }\n\n    int i;\n    for (i = 0; i < sqliterkPagerGetPageCount(rk->pager); i++) {\n        int pageno = i + 1;\n        sqliterkParsePage(rk, pageno);\n    }\n    return SQLITERK_OK;\n}\n\nint sqliterkParsePage(sqliterk *rk, int pageno)\n{\n    if (!rk) {\n        return SQLITERK_MISUSE;\n    }\n    if (sqliterkPagerGetStatus(rk->pager, pageno) !=\n        sqliterk_status_unchecked) {\n        return SQLITERK_OK;\n    }\n    int rc = SQLITERK_OK;\n    sqliterk_btree *btree = NULL;\n    rc = sqliterkBtreeOpen(rk, rk->pager, pageno, &btree);\n    if (rc != SQLITERK_OK) {\n        goto sqliterkParsePage_End;\n    }\n    rc = sqliterkParseBtree(rk, btree);\nsqliterkParsePage_End:\n    if (btree) {\n        sqliterkBtreeClose(btree);\n    }\n    return rc;\n}\n\nstatic int sqliterkParseBtree(sqliterk *rk, sqliterk_btree *btree)\n{\n    if (!rk) {\n        return SQLITERK_MISUSE;\n    }\n    sqliterk_page *page = sqliterkBtreeGetRootPage(btree);\n    int pageno = sqliterkPageGetPageno(page);\n    if (!page || sqliterkPagerIsPagenoValid(rk->pager, pageno) != SQLITERK_OK) {\n        return SQLITERK_MISUSE;\n    }\n    int rc = SQLITERK_OK;\n    sqliterkBtreeSetNotify(btree, &rk->listen);\n    rc = sqliterkBtreeParse(btree);\n    return rc;\n}\n\nint sqliterkParseMaster(sqliterk *rk)\n{\n    // The page 1 is always sqlite_master. See [B-tree Pages] at\n    // https://www.sqlite.org/fileformat2.html\n    return sqliterkParsePage(rk, 1);\n}\n\nint sqliterkClose(sqliterk *rk)\n{\n    if (!rk) {\n        return SQLITERK_MISUSE;\n    }\n    if (rk->pager) {\n        sqliterkPagerClose(rk->pager);\n        rk->pager = NULL;\n    }\n    sqliterkOSFree(rk);\n    return SQLITERK_OK;\n}\n\nstatic void sqliterkNotify_onBeginParseBtree(sqliterk *rk,\n                                             sqliterk_btree *btree)\n{\n    if (rk->notify.onBeginParseTable) {\n        rk->notify.onBeginParseTable(rk, (sqliterk_table *) btree);\n    }\n    sqliterk_page *rootpage = sqliterkBtreeGetRootPage(btree);\n    sqliterkOSDebug(\n        SQLITERK_OK, \"Parsing B-tree -> [root: %d, name: %s, type: %s]\",\n        sqliterkPageGetPageno(rootpage), sqliterkBtreeGetName(btree),\n        sqliterkBtreeGetTypeName(sqliterkBtreeGetType(btree)));\n}\n\nstatic void\nsqliterkNotify_onEndParseBtree(sqliterk *rk, sqliterk_btree *btree, int result)\n{\n    if (rk->notify.onEndParseTable) {\n        rk->notify.onEndParseTable(rk, (sqliterk_table *) btree);\n    }\n}\n\nstatic int sqliterkNotify_onParseColumn(sqliterk *rk,\n                                        sqliterk_btree *btree,\n                                        sqliterk_page *page,\n                                        sqliterk_column *column)\n{\n    if (!rk) {\n        return SQLITERK_MISUSE;\n    }\n\n    int result;\n    if (rk->notify.onParseColumn) {\n        result = rk->notify.onParseColumn(rk, (sqliterk_table *) btree, column);\n        if (result == SQLITERK_CANCELLED) {\n            return result;\n        } else if (result != SQLITERK_OK) {\n            int pageno = sqliterkPageGetPageno(page);\n            sqliterkPagerSetStatus(rk->pager, pageno,\n                                   sqliterk_status_discarded);\n            sqliterk_values *overflowPages =\n                sqliterkColumnGetOverflowPages(column);\n\n            int i;\n            for (i = 0; i < sqliterkValuesGetCount(overflowPages); i++) {\n                sqliterkPagerSetStatus(\n                    rk->pager, sqliterkValuesGetInteger(overflowPages, i),\n                    sqliterk_status_discarded);\n            }\n        }\n    } else {\n        result = SQLITERK_OK;\n    }\n\n    if (sqliterkBtreeGetType(btree) == sqliterk_btree_type_master &&\n        rk->recursive) {\n        // Recursively decode the page since the mapping of [table]->[rootPageno] is known\n        sqliterk_values *values = sqliterkColumnGetValues(column);\n        const char *type = sqliterkValuesGetText(values, 0);\n        const char *name = sqliterkValuesGetText(values, 1);\n        int rootPageno = sqliterkValuesGetInteger(values, 3);\n        int rc = SQLITERK_OK;\n        if (type && name) {\n            sqliterk_btree *subbtree;\n            rc = sqliterkBtreeOpen(rk, rk->pager, rootPageno, &subbtree);\n            if (rc == SQLITERK_OK) {\n                if (memcmp(\"table\", type, 5) == 0) {\n                    sqliterkBtreeSetMeta(subbtree, name,\n                                         sqliterk_btree_type_table);\n                } else if (memcmp(\"index\", type, 5) == 0) {\n                    sqliterkBtreeSetMeta(subbtree, name,\n                                         sqliterk_btree_type_index);\n                } else {\n                    sqliterkBtreeSetMeta(subbtree, name,\n                                         sqliterk_btree_type_unknown);\n                }\n                rc = sqliterkParseBtree(rk, subbtree);\n            }\n            if (rc != SQLITERK_OK) {\n                sqliterk_page *rootpage = sqliterkBtreeGetRootPage(subbtree);\n                sqliterkOSError(\n                    rc,\n                    \"sqliterkNotify_onParseColumn: failed to parse known \"\n                    \"table with root page no. %d, name %s, type %s\",\n                    sqliterkPageGetPageno(rootpage),\n                    sqliterkBtreeGetName(subbtree),\n                    sqliterkBtreeGetTypeName(sqliterkBtreeGetType(subbtree)));\n            }\n            if (subbtree) {\n                sqliterkBtreeClose(subbtree);\n            }\n        }\n    }\n\n    return result;\n}\n\nstatic int\nsqliterkNotify_onBeginParsePage(sqliterk *rk, sqliterk_btree *btree, int pageno)\n{\n    //sqliterkOSDebug(SQLITERK_OK, \"sqliterkNotify_onBeginParsePage: %d\", pageno);\n    if (sqliterkPagerGetStatus(rk->pager, pageno) == sqliterk_status_checking) {\n        return SQLITERK_MISUSE;\n    }\n    sqliterkPagerSetStatus(rk->pager, pageno, sqliterk_status_checking);\n    return SQLITERK_OK;\n}\n\nstatic void sqliterkNotify_onEndParsePage(sqliterk *rk,\n                                          sqliterk_btree *btree,\n                                          int pageno,\n                                          int result)\n{\n    if (!rk) {\n        return;\n    }\n    switch (result) {\n        case SQLITERK_OK:\n            sqliterkPagerSetStatus(rk->pager, pageno, sqliterk_status_checked);\n            break;\n        case SQLITERK_DAMAGED:\n            sqliterkPagerSetStatus(rk->pager, pageno, sqliterk_status_damaged);\n            break;\n        case SQLITERK_CANCELLED:\n            sqliterkOSDebug(SQLITERK_CANCELLED, \"Cancelled parsing page %d.\",\n                            pageno);\n            break;\n        default:\n            sqliterkOSWarning(SQLITERK_MISUSE,\n                              \"Cannot parse page %d. Invalid type.\", pageno);\n            sqliterkPagerSetStatus(rk->pager, pageno, sqliterk_status_invalid);\n            break;\n    }\n    //sqliterkOSDebug(result, \"sqliterkNotify_onEndParsePage: %d\", pageno);\n    if (rk->notify.didParsePage) {\n        rk->notify.didParsePage(rk, pageno);\n    }\n}\n\nint sqliterkSetNotify(sqliterk *rk, sqliterk_notify notify)\n{\n    if (!rk) {\n        return SQLITERK_MISUSE;\n    }\n    rk->notify = notify;\n    return SQLITERK_OK;\n}\n\nint sqliterkSetUserInfo(sqliterk *rk, void *userInfo)\n{\n    if (!rk) {\n        return SQLITERK_MISUSE;\n    }\n    rk->userInfo = userInfo;\n    return SQLITERK_OK;\n}\n\nvoid *sqliterkGetUserInfo(sqliterk *rk)\n{\n    if (!rk) {\n        return NULL;\n    }\n    return rk->userInfo;\n}\n\nint sqliterkGetParsedPageCount(sqliterk *rk)\n{\n    if (!rk) {\n        return 0;\n    }\n    return sqliterkPagerGetParsedPageCount(rk->pager);\n}\n\nint sqliterkGetDamagedPageCount(sqliterk *rk)\n{\n    if (!rk) {\n        return 0;\n    }\n    return sqliterkPagerGetDamagedPageCount(rk->pager);\n}\n\nint sqliterkGetValidPageCount(sqliterk *rk)\n{\n    if (!rk) {\n        return 0;\n    }\n    return sqliterkPagerGetValidPageCount(rk->pager);\n}\n\nint sqliterkGetPageCount(sqliterk *rk)\n{\n    if (!rk) {\n        return 0;\n    }\n    return sqliterkPagerGetPageCount(rk->pager);\n}\n\nunsigned int sqliterkGetIntegrity(sqliterk *rk)\n{\n    if (!rk) {\n        return 0;\n    }\n    return sqliterkPagerGetIntegrity(rk->pager);\n}\n"
  },
  {
    "path": "deprecated/android/addons/repair/sqliterk.h",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#ifndef sqliterk_h\n#define sqliterk_h\n\ntypedef struct sqliterk sqliterk;\ntypedef struct sqliterk_cipher_conf sqliterk_cipher_conf;\ntypedef struct sqliterk_notify sqliterk_notify;\n\nint sqliterkOpen(const char *path,\n                 const sqliterk_cipher_conf *cipher,\n                 sqliterk **rk);\nint sqliterkParse(sqliterk *rk);\nint sqliterkParsePage(sqliterk *rk, int pageno);\nint sqliterkParseMaster(sqliterk *rk);\nint sqliterkClose(sqliterk *rk);\nint sqliterkSetNotify(sqliterk *rk, sqliterk_notify notify);\nint sqliterkSetUserInfo(sqliterk *rk, void *userInfo);\nvoid *sqliterkGetUserInfo(sqliterk *rk);\n\nint sqliterkGetParsedPageCount(sqliterk *rk);\nint sqliterkGetDamagedPageCount(sqliterk *rk);\nint sqliterkGetValidPageCount(sqliterk *rk);\nint sqliterkGetPageCount(sqliterk *rk);\nunsigned int sqliterkGetIntegrity(sqliterk *rk);\n\n#endif /* sqliterk_h */\n"
  },
  {
    "path": "deprecated/android/addons/repair/sqliterk_api.c",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"SQLiteRepairKit.h\"\n#include \"sqliterk.h\"\n#include \"sqliterk_btree.h\"\n#include \"sqliterk_column.h\"\n#include \"sqliterk_os.h\"\n#include \"sqliterk_pager.h\"\n#include \"sqliterk_util.h\"\n#include \"sqliterk_values.h\"\n\nint sqliterk_register_notify(sqliterk *rk, sqliterk_notify notify)\n{\n    return sqliterkSetNotify(rk, notify);\n}\n\nint sqliterk_open(const char *path,\n                  const sqliterk_cipher_conf *cipher,\n                  sqliterk **rk)\n{\n    return sqliterkOpen(path, cipher, rk);\n}\n\nvoid *sqliterk_user_info(sqliterk *rk)\n{\n    return sqliterkGetUserInfo(rk);\n}\n\nint sqliterk_parse(sqliterk *rk)\n{\n    return sqliterkParse(rk);\n}\n\nint sqliterk_parse_page(sqliterk *rk, int pageno)\n{\n    return sqliterkParsePage(rk, pageno);\n}\n\nint sqliterk_parse_master(sqliterk *rk)\n{\n    return sqliterkParseMaster(rk);\n}\n\nint sqliterk_close(sqliterk *rk)\n{\n    return sqliterkClose(rk);\n}\n\nvoid *sqliterk_get_user_info(sqliterk *rk)\n{\n    return sqliterkGetUserInfo(rk);\n}\n\nvoid sqliterk_set_user_info(sqliterk *rk, void *userInfo)\n{\n    sqliterkSetUserInfo(rk, userInfo);\n}\n\nint sqliterk_column_count(sqliterk_column *column)\n{\n    return sqliterkValuesGetCount(sqliterkColumnGetValues(column));\n}\n\nsqliterk_value_type sqliterk_column_type(sqliterk_column *column, int index)\n{\n    return sqliterkValuesGetType(sqliterkColumnGetValues(column), index);\n}\n\nint sqliterk_column_integer(sqliterk_column *column, int index)\n{\n    return sqliterkValuesGetInteger(sqliterkColumnGetValues(column), index);\n}\n\nint64_t sqliterk_column_integer64(sqliterk_column *column, int index)\n{\n    return sqliterkValuesGetInteger64(sqliterkColumnGetValues(column), index);\n}\n\ndouble sqliterk_column_number(sqliterk_column *column, int index)\n{\n    return sqliterkValuesGetNumber(sqliterkColumnGetValues(column), index);\n}\n\nconst char *sqliterk_column_text(sqliterk_column *column, int index)\n{\n    return sqliterkValuesGetText(sqliterkColumnGetValues(column), index);\n}\n\nconst void *sqliterk_column_binary(sqliterk_column *column, int index)\n{\n    return sqliterkValuesGetBinary(sqliterkColumnGetValues(column), index);\n}\n\nint sqliterk_column_bytes(sqliterk_column *column, int index)\n{\n    return sqliterkValuesGetBytes(sqliterkColumnGetValues(column), index);\n}\n\nint64_t sqliterk_column_rowid(sqliterk_column *column)\n{\n    return sqliterkColumnGetRowId(column);\n}\n\nconst char *sqliterk_table_name(sqliterk_table *table)\n{\n    return sqliterkBtreeGetName((sqliterk_btree *) table);\n}\n\nvoid sqliterk_table_set_user_info(sqliterk_table *table, void *userInfo)\n{\n    sqliterkBtreeSetUserInfo((sqliterk_btree *) table, userInfo);\n}\n\nvoid *sqliterk_table_get_user_info(sqliterk_table *table)\n{\n    return sqliterkBtreeGetUserInfo((sqliterk_btree *) table);\n}\n\nsqliterk_type sqliterk_table_type(sqliterk_table *table)\n{\n    return (sqliterk_type) sqliterkBtreeGetType((sqliterk_btree *) table);\n}\n\nint sqliterk_register(sqliterk_os os)\n{\n    return sqliterkOSRegister(os);\n}\n\nint sqliterk_table_root(sqliterk_table *table)\n{\n    sqliterk_page *page = sqliterkBtreeGetRootPage((sqliterk_btree *) table);\n    return sqliterkPageGetPageno(page);\n}\n\nconst char *sqliterk_description(int result)\n{\n    return sqliterkGetResultCodeDescription(result);\n}\n\nint sqliterk_parsed_page_count(sqliterk *rk)\n{\n    return sqliterkGetParsedPageCount(rk);\n}\n\nint sqliterk_damaged_page_count(sqliterk *rk)\n{\n    return sqliterkGetDamagedPageCount(rk);\n}\n\nint sqliterk_valid_page_count(sqliterk *rk)\n{\n    return sqliterkGetValidPageCount(rk);\n}\n\nint sqliterk_page_count(sqliterk *rk)\n{\n    return sqliterkGetPageCount(rk);\n}\n\nunsigned int sqliterk_integrity(sqliterk *rk)\n{\n    return sqliterkGetIntegrity(rk);\n}\n\nvoid sqliterk_cipher_conf_set_key(sqliterk_cipher_conf *conf, const void* key, int key_len)\n{\n    if (conf != NULL) {\n        conf->key = key;\n        conf->key_len = key_len;\n    }\n}\n"
  },
  {
    "path": "deprecated/android/addons/repair/sqliterk_btree.c",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"sqliterk_btree.h\"\n#include \"SQLiteRepairKit.h\"\n#include \"sqliterk_column.h\"\n#include \"sqliterk_os.h\"\n#include \"sqliterk_pager.h\"\n#include \"sqliterk_util.h\"\n#include \"sqliterk_values.h\"\n#include <string.h>\n#include <inttypes.h>\n\n// Declarations\nstatic int sqliterkBtreeParsePage(sqliterk_btree *btree, int pageno);\nstatic int sqliterkBtreeParseCell(sqliterk_btree *btree,\n                                  sqliterk_page *page,\n                                  const int *cellPointerArray,\n                                  const int cellsCount);\nstatic int sqliterkBtreeParsePayload(sqliterk_btree *btree,\n                                     sqliterk_page *page,\n                                     int offset,\n                                     int payloadSize,\n                                     sqliterk_column *column);\nstatic int sqliterkBtreeGetLengthForSerialType(int serialType);\n\nstruct sqliterk_btree {\n    sqliterk *rk;\n    char *name;\n    sqliterk_btree_type type;\n    sqliterk_pager *pager;\n    sqliterk_page *rootpage;\n    // For leaf-table. See https://www.sqlite.org/fileformat2.html#btree\n    int maxLocal;\n    int minLocal;\n    int maxLeaf;\n    int minLeaf;\n\n    sqliterk_btree_notify notify;\n    void *userInfo;\n};\n\nint sqliterkBtreeOpen(sqliterk *rk,\n                      sqliterk_pager *pager,\n                      int rootPageno,\n                      sqliterk_btree **btree)\n{\n    if (!pager || !btree) {\n        return SQLITERK_MISUSE;\n    }\n    int rc = SQLITERK_OK;\n    sqliterk_btree *theBtree = sqliterkOSMalloc(sizeof(sqliterk_btree));\n    if (!theBtree) {\n        rc = SQLITERK_NOMEM;\n        goto sqliterkBtreeOpen_Failed;\n    }\n    theBtree->pager = pager;\n\n    rc = sqliterkPageAcquire(theBtree->pager, rootPageno, &theBtree->rootpage);\n    if (rc != SQLITERK_OK) {\n        goto sqliterkBtreeOpen_Failed;\n    }\n    if (rootPageno == 1) {\n        rc = sqliterkBtreeSetMeta(theBtree, \"sqlite_master\",\n                                  sqliterk_btree_type_master);\n        if (rc != SQLITERK_OK) {\n            goto sqliterkBtreeOpen_Failed;\n        }\n    } else {\n        switch (sqliterkPageGetType(theBtree->rootpage)) {\n            case sqliterk_page_type_interior_index:\n            case sqliterk_page_type_leaf_index:\n                theBtree->type = sqliterk_btree_type_index;\n                break;\n            case sqliterk_page_type_interior_table:\n            case sqliterk_page_type_leaf_table:\n                theBtree->type = sqliterk_btree_type_table;\n                break;\n            default:\n                rc = SQLITERK_DAMAGED;\n                goto sqliterkBtreeOpen_Failed;\n        }\n    }\n    // Save memory\n    sqliterkPageClearData(theBtree->rootpage);\n\n    theBtree->maxLocal =\n        (sqliterkPagerGetUsableSize(theBtree->pager) - 12) * 64 / 255 - 23;\n    theBtree->minLocal =\n        (sqliterkPagerGetUsableSize(theBtree->pager) - 12) * 32 / 255 - 23;\n    theBtree->maxLeaf = sqliterkPagerGetUsableSize(theBtree->pager) - 35;\n    theBtree->minLeaf =\n        (sqliterkPagerGetUsableSize(theBtree->pager) - 12) * 32 / 255 - 23;\n\n    theBtree->rk = rk;\n\n    *btree = theBtree;\n    return SQLITERK_OK;\n\nsqliterkBtreeOpen_Failed:\n    if (theBtree) {\n        sqliterkBtreeClose(theBtree);\n    }\n    *btree = NULL;\n    return rc;\n}\n\nint sqliterkBtreeParse(sqliterk_btree *btree)\n{\n    if (!btree) {\n        return SQLITERK_MISUSE;\n    }\n    if (btree->notify.onBeginParseBtree) {\n        btree->notify.onBeginParseBtree(btree->rk, btree);\n    }\n    int rc =\n        sqliterkBtreeParsePage(btree, sqliterkPageGetPageno(btree->rootpage));\n    if (btree->notify.onEndParseBtree) {\n        btree->notify.onEndParseBtree(btree->rk, btree, rc);\n    }\n    return rc;\n}\n\n// If the page is an interior-btree, no matter is an interior-table btree\n// or an interior-index btree, this function will recursively parse the page\n// until it find the leaf page or any error occur.\n// A leaf-index btree will only be found but not parse, since its data make\n// no sense.\nstatic int sqliterkBtreeParsePage(sqliterk_btree *btree, int pageno)\n{\n    int i;\n\n    if (!btree || pageno > sqliterkPagerGetPageCount(btree->pager)) {\n        return SQLITERK_MISUSE;\n    }\n\n    int rc;\n\n    if (btree->notify.onBeginParsePage) {\n        rc = btree->notify.onBeginParsePage(btree->rk, btree, pageno);\n        if (rc != SQLITERK_OK) {\n            return rc;\n        }\n    }\n\n    int *cellPointerArray = NULL;\n    sqliterk_page *page = NULL;\n\n    // ahead checking type to fast up parsing\n    rc = sqliterkPageAcquire(btree->pager, pageno, &page);\n    if (rc != SQLITERK_OK) {\n        goto sqliterkBtreeParsePage_End;\n    }\n    sqliterk_page_type type = sqliterkPageGetType(page);\n    if (type != sqliterk_page_type_interior_index &&\n        type != sqliterk_page_type_interior_table &&\n        type != sqliterk_page_type_leaf_index &&\n        type != sqliterk_page_type_leaf_table) {\n        rc = sqliterkOSWarning(SQLITERK_DAMAGED, \"Page %d has invalid type\",\n                               pageno);\n        goto sqliterkBtreeParsePage_End;\n    }\n\n    //sqliterkOSDebug(SQLITERK_OK, \"Page %d is %s\", pageno, sqliterkPageGetTypeName(type));\n\n    // Parse cell pointer array. For further information, see [cell pointer]\n    // at https://www.sqlite.org/fileformat2.html#btree\n    const unsigned char *pagedata = sqliterkPageGetData(page);\n    int offsetCellPointerArray =\n        (type == sqliterk_page_type_interior_table) ? 12 : 8;\n    int cellsCount;\n    sqliterkParseInt(pagedata, 3 + sqliterkPageHeaderOffset(page), 2,\n                     &cellsCount);\n    if (cellsCount < 0 || cellsCount * 2 + offsetCellPointerArray >\n                               sqliterkPagerGetSize(btree->pager)) {\n        rc = SQLITERK_DAMAGED;\n        goto sqliterkBtreeParsePage_End;\n    }\n    cellPointerArray = sqliterkOSMalloc(sizeof(int) * (cellsCount + 1));\n    if (!cellPointerArray) {\n        rc = SQLITERK_NOMEM;\n        goto sqliterkBtreeParsePage_End;\n    }\n\n    for (i = 0; i < cellsCount; i++) {\n        int cellPointer;\n        sqliterkParseInt(pagedata,\n                         sqliterkPageHeaderOffset(page) +\n                             offsetCellPointerArray + i * 2,\n                         2, &cellPointer);\n        cellPointerArray[i] = cellPointer;\n    }\n\n    switch (type) {\n        case sqliterk_page_type_interior_table:\n        case sqliterk_page_type_interior_index: {\n            int hasRightMostPageno =\n                (type == sqliterk_page_type_interior_table);\n            int pagenosCount = cellsCount + hasRightMostPageno;\n            int *pagenos = sqliterkOSMalloc(sizeof(int) * (pagenosCount + 1));\n            if (!pagenos) {\n                rc = SQLITERK_NOMEM;\n                goto sqliterkBtreeParsePage_End;\n            }\n            for (i = 0; i < cellsCount; i++) {\n                sqliterkParseInt(pagedata, cellPointerArray[i], 4, pagenos + i);\n            }\n            if (hasRightMostPageno) {\n                sqliterkParseInt(pagedata, 8, 4, pagenos + cellsCount);\n            }\n            // All done for page data. Ahead release the page data to avoid memory overflow\n            sqliterkOSFree(cellPointerArray);\n            cellPointerArray = NULL;\n            sqliterkPageClearData(page);\n            // Recursively decode the page\n            for (i = 0; i < pagenosCount; i++) {\n                if (sqliterkBtreeParsePage(btree, pagenos[i]) ==\n                    SQLITERK_CANCELLED)\n                    break;\n            }\n            sqliterkOSFree(pagenos);\n            break;\n        }\n        case sqliterk_page_type_leaf_table:\n            if (sqliterkBtreeIsSystemType(sqliterkBtreeGetType(btree)) &&\n                btree->type != sqliterk_btree_type_master) {\n                //skip a non-master system table, since its column is generated.\n                goto sqliterkBtreeParsePage_End;\n            }\n            rc = sqliterkBtreeParseCell(btree, page, cellPointerArray,\n                                        cellsCount);\n            break;\n        case sqliterk_page_type_leaf_index:\n            // Just skip it since the column in leaf index make no sense.\n            break;\n        default:\n            break;\n    }\n\nsqliterkBtreeParsePage_End:\n    if (cellPointerArray) {\n        sqliterkOSFree(cellPointerArray);\n    }\n    if (btree->notify.onEndParsePage) {\n        btree->notify.onEndParsePage(btree->rk, btree, pageno, rc);\n    }\n    if (page) {\n        sqliterkPageRelease(page);\n    }\n    if (rc != SQLITERK_OK && rc != SQLITERK_CANCELLED) {\n        sqliterkOSDebug(rc, \"Failed to parse page %d.\", pageno);\n    }\n    return rc;\n}\n\n// Parse the payload data. see [B-tree Cell Format]\n// at https://www.sqlite.org/fileformat2.html#btree\nstatic int sqliterkBtreeParseCell(sqliterk_btree *btree,\n                                  sqliterk_page *page,\n                                  const int *cellPointerArray,\n                                  const int cellsCount)\n{\n    if (!btree || !page || !cellPointerArray || cellsCount < 0) {\n        return SQLITERK_MISUSE;\n    }\n    const unsigned char *pagedata = sqliterkPageGetData(page);\n    int rc = SQLITERK_OK;\n    sqliterk_column *column;\n    rc = sqliterkColumnAlloc(&column);\n    if (rc != SQLITERK_OK) {\n        goto sqliterkBtreeParsePayload_End;\n    }\n\n    int i;\n    for (i = 0; i < cellsCount; i++) {\n        sqliterkColumnClear(column);\n        int offset = cellPointerArray[i];\n        // Find payload\n        int payloadSizeLength;\n        int64_t payloadSize;\n        rc = sqliterkParseVarint64(pagedata, offset, &payloadSizeLength,\n                                 &payloadSize);\n        if (rc != SQLITERK_OK) {\n            goto sqliterkBtreeParsePayload_End;\n        } else if (payloadSize > 64 * 1024 * 1024) {\n            // We assume that payload is at most 64MB.\n            rc = SQLITERK_DAMAGED;\n            sqliterkOSDebug(rc, \"Invalid payload size: %\" PRId64 \".\", payloadSize);\n            goto sqliterkBtreeParsePayload_End;\n        }\n        offset += payloadSizeLength;\n\n        int rowidLength;\n        int64_t rowid;\n        rc = sqliterkParseVarint64(pagedata, offset, &rowidLength, &rowid);\n        if (rc != SQLITERK_OK) {\n            goto sqliterkBtreeParsePayload_End;\n        }\n        offset += rowidLength;\n        sqliterkColumnSetRowId(column, rowid);\n\n        rc =\n            sqliterkBtreeParsePayload(btree, page, offset, payloadSize, column);\n        if (rc != SQLITERK_OK) {\n            goto sqliterkBtreeParsePayload_End;\n        }\n    }\nsqliterkBtreeParsePayload_End:\n    if (column) {\n        sqliterkColumnFree(column);\n    }\n    if (rc != SQLITERK_OK && rc != SQLITERK_CANCELLED) {\n        sqliterkOSDebug(rc, \"Failed to parse payload.\");\n    }\n    return rc;\n}\n\n// Parse the payload for leaf-table page only. We don't implement the parse\n// method for index page, since we are not concerned about the data in an\n// index page. See [Record Format] at https://www.sqlite.org/fileformat2.html\nstatic int sqliterkBtreeParsePayload(sqliterk_btree *btree,\n                                     sqliterk_page *page,\n                                     int offset,\n                                     int payloadSize,\n                                     sqliterk_column *column)\n{\n    if (!btree || payloadSize <= 0 || !column) {\n        return SQLITERK_MISUSE;\n    }\n    int rc = SQLITERK_OK;\n    unsigned char *payloadData = sqliterkOSMalloc(payloadSize);\n    if (!payloadData) {\n        rc = SQLITERK_NOMEM;\n        goto sqliterkBtreeParseColumn_End;\n    }\n\n    // Check overflow\n    int local = 0;\n    if (payloadSize <= btree->maxLeaf) {\n        local = payloadSize;\n    } else {\n        // Since it is a leaf-table page, the max local should be equal to max leaf\n        int maxPageLocal = btree->maxLeaf;\n        int minPageLocal = btree->minLocal;\n        int surplus =\n            minPageLocal + (payloadSize - minPageLocal) %\n                               (sqliterkPagerGetUsableSize(btree->pager) - 4);\n        if (surplus <= maxPageLocal) {\n            local = surplus;\n        } else {\n            local = minPageLocal;\n        }\n    }\n\n    // Read data\n    int payloadPointer = 0;\n    const unsigned char *pagedata = sqliterkPageGetData(page);\n    if (offset + local > sqliterkPagerGetSize(btree->pager)) {\n        rc = SQLITERK_DAMAGED;\n        goto sqliterkBtreeParseColumn_End;\n    }\n    memcpy(payloadData, pagedata + offset, local);\n    payloadPointer += local;\n\n    if (payloadPointer < payloadSize) {\n        sqliterk_values *overflowPages = sqliterkColumnGetOverflowPages(column);\n        int overflowPageno;\n        const unsigned char *pagedata = sqliterkPageGetData(page);\n        sqliterkParseInt(pagedata, offset + local, 4, &overflowPageno);\n        while (sqliterkPagerIsPagenoValid(btree->pager, overflowPageno) ==\n               SQLITERK_OK) {\n            sqliterkValuesAddInteger(overflowPages, overflowPageno);\n            if (btree->notify.onBeginParsePage) {\n                btree->notify.onBeginParsePage(btree->rk, btree,\n                                               overflowPageno);\n            }\n            sqliterk_page *page;\n            rc = sqliterkPageAcquireOverflow(btree->pager, overflowPageno,\n                                             &page);\n            if (btree->notify.onEndParsePage) {\n                btree->notify.onEndParsePage(btree->rk, btree, overflowPageno,\n                                             rc);\n            }\n            if (rc != SQLITERK_OK) {\n                break;\n            }\n            // Read data\n            int overflowSize = payloadSize - payloadPointer;\n            if (overflowSize <= 0) break;\n\n            int maxSize = sqliterkPagerGetUsableSize(btree->pager) - 4;\n            if (overflowSize > maxSize) {\n                overflowSize = maxSize;\n            }\n\n            const unsigned char *pageData = sqliterkPageGetData(page);\n            memcpy(payloadData + payloadPointer, pageData + 4, overflowSize);\n            payloadPointer += overflowSize;\n            // Iterate\n            sqliterkParseInt(pageData, 0, 4, &overflowPageno);\n            // Clear\n            sqliterkPageRelease(page);\n        }\n    }\n\n    int columnOffsetValue = 0;\n    int columnOffsetValueLength = 0;\n    rc = sqliterkParseVarint(payloadData, 0, &columnOffsetValueLength,\n                             &columnOffsetValue);\n    if (rc != SQLITERK_OK) {\n        goto sqliterkBtreeParseColumn_End;\n    }\n\n    int offsetSerialType = columnOffsetValueLength;\n    int offsetValue = columnOffsetValue;\n    const int endSerialType = offsetValue;\n    const int endValue = payloadSize;\n\n    int serialTypeLength = 0;\n    int serialType = 0;\n    int valueLength = 0;\n\n    sqliterk_values *values = sqliterkColumnGetValues(column);\n    while (offsetValue < endValue || offsetSerialType < endSerialType) {\n        rc = sqliterkParseVarint(payloadData, offsetSerialType,\n                                 &serialTypeLength, &serialType);\n        if (rc != SQLITERK_OK) {\n            goto sqliterkBtreeParseColumn_End;\n        }\n        valueLength = sqliterkBtreeGetLengthForSerialType(serialType);\n        if (serialType == 0) {\n            rc = sqliterkValuesAddNull(values);\n        } else if (serialType < 7) {\n            int64_t value;\n            sqliterkParseInt64(payloadData, offsetValue, valueLength, &value);\n            rc = sqliterkValuesAddInteger64(values, value);\n        } else if (serialType == 7) {\n            double value;\n            sqliterkParseNumber(payloadData, offsetValue, &value);\n            rc = sqliterkValuesAddNumber(values, value);\n        } else if (serialType == 8) {\n            rc = sqliterkValuesAddInteger(values, 0);\n        } else if (serialType == 9) {\n            rc = sqliterkValuesAddInteger(values, 1);\n        } else if (serialType >= 12) {\n            if (serialType % 2 == 0) {\n                rc = sqliterkValuesAddBinary(values, payloadData + offsetValue,\n                                             valueLength);\n            } else {\n                rc = sqliterkValuesAddNoTerminatorText(\n                    values, (const char *) payloadData + offsetValue,\n                    valueLength);\n            }\n        } else {\n            rc = SQLITERK_DAMAGED;\n        }\n        if (rc != SQLITERK_OK) {\n            goto sqliterkBtreeParseColumn_End;\n        }\n        offsetValue += valueLength;\n        offsetSerialType += serialTypeLength;\n    }\n    if (offsetSerialType != endSerialType || offsetValue != endValue) {\n        rc = SQLITERK_DAMAGED;\n        goto sqliterkBtreeParseColumn_End;\n    }\n\nsqliterkBtreeParseColumn_End:\n    if (rc == SQLITERK_OK && btree->notify.onParseColumn) {\n        rc = btree->notify.onParseColumn(btree->rk, btree, page, column);\n    }\n    if (payloadData) {\n        sqliterkOSFree(payloadData);\n    }\n    return rc;\n}\n\nint sqliterkBtreeClose(sqliterk_btree *btree)\n{\n    if (!btree) {\n        return SQLITERK_MISUSE;\n    }\n    if (btree->name) {\n        sqliterkOSFree(btree->name);\n        btree->name = NULL;\n    }\n    if (btree->rootpage) {\n        sqliterkPageRelease(btree->rootpage);\n        btree->rootpage = NULL;\n    }\n    btree->pager = NULL;\n    btree->userInfo = NULL;\n    btree->rk = NULL;\n    btree->type = 0;\n    sqliterkOSFree(btree);\n    return SQLITERK_OK;\n}\n\nint sqliterkBtreeSetMeta(sqliterk_btree *btree,\n                         const char *name,\n                         sqliterk_btree_type type)\n{\n    if (!btree) {\n        return SQLITERK_MISUSE;\n    }\n    if (btree->name) {\n        sqliterkOSFree(btree->name);\n        btree->name = NULL;\n    }\n    if (name) {\n        size_t length = strlen(name);\n        btree->name = sqliterkOSMalloc(sizeof(char) * (length + 1));\n        if (!btree->name) {\n            return SQLITERK_NOMEM;\n        }\n        strncpy(btree->name, name, length);\n        // If it's a system btree name, then setup its b-tree type.\n        sqliterk_btree_type i;\n        for (i = sqliterk_btree_type_system_begin;\n             i < sqliterk_btree_type_system_end; i++) {\n            const char *typename = sqliterkBtreeGetTypeName(i);\n            if (strncmp(btree->name, typename, strlen(typename)) == 0) {\n                btree->type = i;\n                break;\n            }\n        }\n    } else {\n        btree->name = NULL;\n    }\n    if (!sqliterkBtreeIsSystemType(btree->type) &&\n        type != sqliterk_btree_type_unknown) {\n        btree->type = type;\n    }\n    return SQLITERK_OK;\n}\n\nconst char *sqliterkBtreeGetName(sqliterk_btree *btree)\n{\n    if (!btree) {\n        return NULL;\n    }\n    return btree->name;\n}\n\nsqliterk_btree_type sqliterkBtreeGetType(sqliterk_btree *btree)\n{\n    if (!btree) {\n        return sqliterk_btree_type_unknown;\n    }\n    return btree->type;\n}\n\nint sqliterkBtreeSetType(sqliterk_btree *btree, sqliterk_btree_type type)\n{\n    if (!btree) {\n        return SQLITERK_MISUSE;\n    }\n    if (sqliterkBtreeIsSystemType(btree->type)) {\n        // You can only set the type manually when the type is not a system type\n        return SQLITERK_MISUSE;\n    }\n    btree->type = type;\n    return SQLITERK_OK;\n}\n\nint sqliterkBtreeIsSystemType(sqliterk_btree_type type)\n{\n    if (type >= sqliterk_btree_type_system_begin &&\n        type < sqliterk_btree_type_system_end) {\n        return 1;\n    }\n    return 0;\n}\n\nvoid sqliterkBtreeSetNotify(sqliterk_btree *btree,\n                            sqliterk_btree_notify *notify)\n{\n    if (!btree || !notify) {\n        return;\n    }\n    btree->notify = *notify;\n}\n\nvoid sqliterkBtreeSetUserInfo(sqliterk_btree *btree, void *userInfo)\n{\n    if (!btree) {\n        return;\n    }\n    btree->userInfo = userInfo;\n}\n\nvoid *sqliterkBtreeGetUserInfo(sqliterk_btree *btree)\n{\n    if (!btree) {\n        return NULL;\n    }\n    return btree->userInfo;\n}\n\nsqliterk_page *sqliterkBtreeGetRootPage(sqliterk_btree *btree)\n{\n    if (!btree) {\n        return NULL;\n    }\n    return btree->rootpage;\n}\n\nconst char *sqliterkBtreeGetTypeName(sqliterk_btree_type type)\n{\n    char *name;\n    switch (type) {\n        case sqliterk_btree_type_autoindex:\n            name = \"sqlite_autoindex\";\n            break;\n        case sqliterk_btree_type_sequence:\n            name = \"sqlite_sequence\";\n            break;\n        case sqliterk_btree_type_stat:\n            name = \"sqlite_stat\";\n            break;\n        case sqliterk_btree_type_master:\n            name = \"sqlite_master\";\n            break;\n        case sqliterk_btree_type_table:\n            name = \"table\";\n            break;\n        case sqliterk_btree_type_index:\n            name = \"index\";\n            break;\n        default:\n            name = \"unknown\";\n            break;\n    }\n    return name;\n}\n\n// See [Serial Type Codes Of The Record Format]\n// at https://www.sqlite.org/fileformat2.html\nstatic int sqliterkBtreeGetLengthForSerialType(int serialType)\n{\n    if (serialType < 0) {\n        return 0;\n    }\n    static int sqliterk_btree_serialtype_fixlengths[12] = {0, 1, 2, 3, 4, 6,\n                                                           8, 8, 0, 0, 0, 0};\n    if (serialType < 12) {\n        return sqliterk_btree_serialtype_fixlengths[serialType];\n    }\n    return (serialType - 12 - serialType % 2) / 2;\n}"
  },
  {
    "path": "deprecated/android/addons/repair/sqliterk_output.cpp",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"SQLiteRepairKit.h\"\n#include <assert.h>\n#include <errno.h>\n#include <map>\n#ifdef WCDB_BUILTIN_SQLCIPHER\n#include <sqlcipher/sqlite3.h>\n#else  //WCDB_BUILTIN_SQLCIPHER\n#include <sqlite3.h>\n#endif //WCDB_BUILTIN_SQLCIPHER\n#include <stdint.h>\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include <string>\n#include <strings.h>\n#include <vector>\n#include <zlib.h>\n#if defined(__APPLE__)\n#include <CommonCrypto/CommonCrypto.h>\n#include <Security/Security.h>\n#else\n#include <openssl/rc4.h>\n#endif\n\nextern \"C\" {\n#include \"sqliterk_btree.h\"\n#include \"sqliterk_os.h\"\n}\n\nclass CipherContext {\npublic:\n    enum Op {\n        Encrypt,\n        Decrypt,\n    };\n    CipherContext(Op op)\n#if defined(__APPLE__)\n    : m_op(op), m_key(nullptr), m_keyLength(0), m_cryptor(nullptr)\n#endif\n    {\n    }\n\n    void setKey(const void *key, unsigned int keyLength)\n    {\n#if defined(__APPLE__)\n        m_keyLength = keyLength;\n        m_key = (unsigned char *) realloc(m_key, m_keyLength);\n        memcpy(m_key, key, m_keyLength);\n#else\n        RC4_set_key(&m_rc4Key, keyLength, (const unsigned char *) key);\n#endif\n    }\n\n    void cipher(unsigned char *data, unsigned int length)\n    {\n#if defined(__APPLE__)\n        if (!m_cryptor) {\n            CCCryptorCreate(kCCEncrypt, kCCAlgorithmRC4, 0, m_key, m_keyLength,\n                            nullptr, &m_cryptor);\n        }\n\n        size_t cryptBytes = 0;\n        CCCryptorUpdate(m_cryptor, data, length, data, length, &cryptBytes);\n        CCCryptorFinal(m_cryptor, data, length, &cryptBytes);\n#else\n        RC4(&m_rc4Key, length, data, data);\n#endif\n    }\n\n    ~CipherContext()\n    {\n#if defined(__APPLE__)\n        if (m_cryptor) {\n            CCCryptorRelease(m_cryptor);\n        }\n        if (m_key) {\n            free(m_key);\n        }\n#endif\n    }\n\nprotected:\n#if defined(__APPLE__)\n    unsigned char *m_key;\n    unsigned int m_keyLength;\n    Op m_op;\n    CCCryptorRef m_cryptor;\n#else\n    RC4_KEY m_rc4Key;\n#endif\n};\n\nstruct sqliterk_master_entity {\n    sqliterk_type type;\n    std::string sql;\n    int root_page;\n\n    sqliterk_master_entity() {}\n\n    sqliterk_master_entity(sqliterk_type type_,\n                           const char *sql_,\n                           int root_page_)\n            : type(type_), sql(sql_), root_page(root_page_)\n    {\n    }\n};\ntypedef std::map<std::string, sqliterk_master_entity> sqliterk_master_map;\nstruct sqliterk_master_info : public sqliterk_master_map {};\n\ntypedef std::map<std::string, std::vector<int>> sqliterk_leaf_map;\nstruct sqliterk_leaf_info : public sqliterk_leaf_map {};\n\nstruct sqliterk_output_column_info {\n    char affinity;\n    bool not_null;\n    sqlite3_value *default_value = NULL;\n\n    sqliterk_output_column_info(char aff, bool nn, sqlite3_value *dflt) :\n            affinity(aff), not_null(nn), default_value(dflt) {}\n\n    sqliterk_output_column_info(sqliterk_output_column_info&& other) :\n            affinity(other.affinity), not_null(other.not_null), default_value(other.default_value) {\n        other.default_value = NULL;\n    }\n\n    ~sqliterk_output_column_info() {\n        if (default_value) {\n            sqlite3_value_free(default_value);\n        }\n    }\n};\n\nstruct sqliterk_output_ctx {\n    sqlite3 *db;\n    sqlite3_stmt *stmt;\n    int real_columns;\n    std::vector<sqliterk_output_column_info> column_info;\n    int ipk_column;\n\n    sqliterk_master_map tables;\n    sqliterk_master_map::const_iterator table_cursor;\n    unsigned int flags;\n\n    unsigned int success_count;\n    unsigned int fail_count;\n    volatile unsigned cancelled;\n\n    int (*callback)(void *user,\n                    sqliterk *rk,\n                    sqliterk_table *table,\n                    sqliterk_column *column);\n    void *user;\n};\n\nstatic void dummyParseTableCallback(sqliterk *rk, sqliterk_table *table)\n{\n}\n\nstatic int master_onParseColumn(sqliterk *rk,\n                                sqliterk_table *table,\n                                sqliterk_column *column)\n{\n    sqliterk_output_ctx *ctx =\n            (sqliterk_output_ctx *) sqliterk_get_user_info(rk);\n\n    if (ctx->cancelled)\n        return SQLITERK_CANCELLED;\n\n    // For master table, check whether we should ignore, or create table\n    // and prepare for insertion.\n    if (sqliterk_table_type(table) != sqliterk_type_master)\n        return SQLITERK_MISUSE;\n\n    const char *typestr = sqliterk_column_text(column, 0);\n    const char *name = sqliterk_column_text(column, 1);\n    const char *tbl_name = sqliterk_column_text(column, 2);\n    int root_page = sqliterk_column_integer(column, 3);\n    const char *sql = sqliterk_column_text(column, 4);\n    sqliterk_type type;\n\n    if (!typestr || !name || !sql || root_page <= 0)\n        return SQLITERK_OK;\n\n    if (strcmp(typestr, \"table\") == 0)\n        type = sqliterk_type_table;\n    else if (strcmp(typestr, \"index\") == 0)\n        type = sqliterk_type_index;\n    else\n        return SQLITERK_OK;\n\n    // TODO: deal with system tables.\n    if (strncmp(name, \"sqlite_\", 7) == 0)\n        return SQLITERK_OK;\n\n    // Skip table if we are not interested.\n    if (!(ctx->flags & SQLITERK_OUTPUT_ALL_TABLES)) {\n        sqliterk_master_map::iterator it = ctx->tables.find(tbl_name);\n        if (it == ctx->tables.end())\n            return SQLITERK_OK;\n    }\n\n    // Check CREATE statement if requested.\n    if (ctx->flags & SQLITERK_OUTPUT_CHECK_TABLE_COLUMNS) {\n        sqliterk_master_map::iterator it = ctx->tables.find(name);\n        if (it != ctx->tables.end()) {\n            const sqliterk_master_entity &e = it->second;\n            if (e.root_page > 0 && !e.sql.empty() &&\n                (e.type == sqliterk_type_table || e.type == sqliterk_type_index)) {\n                if (e.sql != sql) {\n                    sqliterkOSWarning(SQLITERK_DAMAGED, \"SQL mismatch: '%s' <-> '%s'\", sql, e.sql.c_str());\n                    if (strlen(sql) < e.sql.size()) {\n                        return SQLITERK_OK;\n                    }\n                }\n            }\n        }\n    }\n\n    ctx->tables[name] = sqliterk_master_entity(type, sql, root_page);\n    return SQLITERK_OK;\n}\n\nstatic void fini_insert(sqliterk_output_ctx *ctx)\n{\n    if (ctx->stmt) {\n        sqlite3_finalize(ctx->stmt);\n        ctx->stmt = NULL;\n    }\n\n    ctx->column_info.clear();\n    ctx->real_columns = 0;\n    ctx->ipk_column = 0;\n}\n\nstatic sqlite3_value *eval_value(sqlite3 *db, const char *value)\n{\n    if (!value || !*value)\n        return NULL;\n\n    std::string sql(\"SELECT \");\n    sql += value;\n    sql += ';';\n    sqlite3_stmt *stmt = NULL;\n    int rc = sqlite3_prepare_v2(db, sql.c_str(), -1, &stmt, NULL);\n    if (rc != SQLITE_OK || !stmt) {\n        return NULL;\n    }\n    rc = sqlite3_step(stmt);\n    sqlite3_value *result = NULL;\n    if (rc == SQLITE_ROW) {\n        result = sqlite3_column_value(stmt, 0);\n        result = sqlite3_value_dup(result);\n    }\n    sqlite3_finalize(stmt);\n    return result;\n}\n\nstatic constexpr char SQLITE_AFF_BLOB = 'A';\nstatic constexpr char SQLITE_AFF_TEXT = 'B';\nstatic constexpr char SQLITE_AFF_NUMERIC = 'C';\nstatic constexpr char SQLITE_AFF_INTEGER = 'D';\nstatic constexpr char SQLITE_AFF_REAL = 'E';\nstatic constexpr uint32_t string_digits(const char *s)\n{\n    uint32_t h = 0;\n    if (s[0] == '\\0') return h;\n    h = s[0] << 24;\n    if (s[1] == '\\0') return h;\n    h |= s[1] << 16;\n    if (s[2] == '\\0') return h;\n    h |= s[2] << 8;\n    h |= s[3];\n    return h;\n}\n\nstatic char parse_affinity(const char *type)\n{\n    if (!type || !*type) {\n        return SQLITE_AFF_BLOB;\n    }\n\n    uint32_t h = 0;\n    char aff = SQLITE_AFF_NUMERIC;\n    do {\n        h = (h << 8) + toupper((*type++) & 0xFF);\n        if ((h << 8) == string_digits(\"INT\")) {\n            aff = SQLITE_AFF_INTEGER;\n        } else {\n            switch (h) {\n                case string_digits(\"CHAR\"):\n                case string_digits(\"CLOB\"):\n                case string_digits(\"TEXT\"):\n                    aff = SQLITE_AFF_TEXT;\n                    break;\n                case string_digits(\"BLOB\"):\n                    if (aff == SQLITE_AFF_NUMERIC || aff == SQLITE_AFF_REAL)\n                        aff = SQLITE_AFF_BLOB;\n                    break;\n                case string_digits(\"REAL\"):\n                case string_digits(\"FLOA\"):\n                case string_digits(\"DOUB\"):\n                    if (aff == SQLITE_AFF_NUMERIC)\n                        aff = SQLITE_AFF_REAL;\n                    break;\n            }\n        }\n    } while (*type);\n    return aff;\n}\n\nstatic int init_insert(sqliterk_output_ctx *ctx, const std::string &table)\n{\n    std::string sql;\n    sqlite3_stmt *table_info_stmt;\n\n    assert(ctx->stmt == NULL && ctx->column_info.empty());\n\n    sql.reserve(512);\n    sql = \"PRAGMA table_info(\";\n    sql += table;\n    sql += \");\";\n    int rc =\n            sqlite3_prepare_v2(ctx->db, sql.c_str(), -1, &table_info_stmt, NULL);\n    if (rc != SQLITE_OK) {\n        sqliterkOSWarning(rc, \"Failed to prepare SQL: %s [SQL: %s]\",\n                          sqlite3_errmsg(ctx->db), sql.c_str());\n        fini_insert(ctx);\n        return -1;\n    }\n\n    sql = \"REPLACE INTO \";\n    sql += table;\n    sql += \" VALUES(\";\n    ctx->real_columns = 0;\n    int ipk_column = 0;\n    while (sqlite3_step(table_info_stmt) == SQLITE_ROW) {\n        // Record the real column count defined by the SQL.\n        ctx->real_columns++;\n\n        // Evaluate the default value for the rows missing some columns in B-tree.\n        const char *expr = (const char *) sqlite3_column_text(table_info_stmt, 4);\n        sqlite3_value *default_value = eval_value(ctx->db, expr);\n\n        // Evaluate column affinity for dirty detection.\n        expr = (const char *) sqlite3_column_text(table_info_stmt, 2);\n        char aff = parse_affinity(expr);\n\n        bool not_null = sqlite3_column_int(table_info_stmt, 3) != 0;\n        ctx->column_info.emplace_back(aff, not_null, default_value);\n\n        // determine INTEGER PRIMARY KEY\n        if (ipk_column >= 0) {\n            int pk_idx = sqlite3_column_int(table_info_stmt, 5);\n            if (pk_idx == 1) {\n                const char *column_type =\n                        (const char *) sqlite3_column_text(table_info_stmt, 2);\n                if (strcasecmp(column_type, \"INTEGER\") == 0)\n                    ipk_column = ctx->real_columns;\n            } else if (pk_idx != 0) {\n                ipk_column = -1;\n            }\n        }\n\n        sql += \"?,\";\n    }\n    rc = sqlite3_finalize(table_info_stmt);\n    if (rc != SQLITE_OK || ctx->real_columns == 0) {\n        sqliterkOSWarning(\n                rc, \"Failed to execute SQL: %s [SQL: PRAGMA table_info(%s);]\",\n                sqlite3_errmsg(ctx->db), table.c_str());\n        fini_insert(ctx);\n        return -1;\n    }\n\n    sql[sql.length() - 1] = ')';\n    sql += ';';\n\n    sqlite3_stmt *stmt;\n    rc = sqlite3_prepare_v2(ctx->db, sql.c_str(), -1, &stmt, NULL);\n    if (rc != SQLITE_OK) {\n        sqliterkOSWarning(rc, \"Failed to prepare SQL: %s [SQL: %s]\",\n                          sqlite3_errmsg(ctx->db), sql.c_str());\n        fini_insert(ctx);\n        return -1;\n    }\n    ctx->stmt = stmt;\n    ctx->ipk_column = (ipk_column > 0) ? ipk_column : 0;\n\n    return ctx->real_columns;\n}\n\nstatic void table_onBeginParseTable(sqliterk *rk, sqliterk_table *table)\n{\n    sqliterk_output_ctx *ctx =\n            (sqliterk_output_ctx *) sqliterk_get_user_info(rk);\n\n    sqliterkBtreeSetMeta((sqliterk_btree *) table,\n                         ctx->table_cursor->first.c_str(),\n                         sqliterk_btree_type_table);\n}\n\nstatic int table_onParseColumn(sqliterk *rk,\n                               sqliterk_table *table,\n                               sqliterk_column *column)\n{\n    sqliterk_output_ctx *ctx =\n            (sqliterk_output_ctx *) sqliterk_get_user_info(rk);\n\n    if (ctx->cancelled)\n        return SQLITERK_CANCELLED;\n\n    int rc;\n    if (ctx->callback) {\n        rc = ctx->callback(ctx->user, rk, table, column);\n        if (rc != SQLITERK_OK) {\n            if (rc == SQLITERK_IGNORE)\n                rc = SQLITERK_OK;\n            return rc;\n        }\n    }\n\n    int columns = sqliterk_column_count(column);\n    sqlite3_stmt *stmt = ctx->stmt;\n\n    if (!stmt) {\n        // Invalid table_cursor means failed statement compilation.\n        if (ctx->table_cursor == ctx->tables.end()) {\n            ctx->fail_count++;\n            return SQLITERK_OK;\n        }\n\n        rc = init_insert(ctx, ctx->table_cursor->first);\n        if (rc <= 0) {\n            ctx->table_cursor = ctx->tables.end();\n            ctx->fail_count++;\n            return SQLITERK_OK;\n        }\n\n        // Begin transaction.\n        char *errmsg;\n        rc = sqlite3_exec(ctx->db, \"BEGIN;\", NULL, NULL, &errmsg);\n        if (errmsg) {\n            sqliterkOSWarning(rc, \"Failed to begin transaction: %s\", errmsg);\n            sqlite3_free(errmsg);\n        }\n\n        stmt = ctx->stmt;\n    }\n\n    int i;\n\n    // Check column count: if row has more columns in B-tree than in SQL statement, it's probably\n    // come from wrong table and should consider corrupted.\n    if (columns > ctx->real_columns || columns > ctx->column_info.size()) {\n        sqliterkOSWarning(SQLITERK_DAMAGED, \"Column count mismatch: %d vs %d\", columns, ctx->real_columns);\n        ctx->fail_count++;\n        return SQLITERK_OK;\n    }\n\n    // Bind values provided by the repair kit.\n    sqlite3_clear_bindings(stmt);\n    for (i = 0; i < columns; i++) {\n        sqliterk_value_type type = sqliterk_column_type(column, i);\n        switch (type) {\n            case sqliterk_value_type_binary:\n                sqlite3_bind_blob(stmt, i + 1,\n                                  sqliterk_column_binary(column, i),\n                                  sqliterk_column_bytes(column, i), NULL);\n                break;\n            case sqliterk_value_type_integer:\n                // INTEGER value should not be stored in columns with TEXT affinity.\n                if (ctx->column_info[i].affinity == SQLITE_AFF_TEXT) {\n                    sqliterkOSWarning(SQLITERK_DAMAGED, \"INTEGER value detected in column with TEXT affinity.\");\n                    ctx->fail_count++;\n                    return SQLITERK_OK;\n                }\n\n                sqlite3_bind_int64(stmt, i + 1,\n                                   sqliterk_column_integer64(column, i));\n                break;\n            case sqliterk_value_type_null:\n                // If NOT NULL is defined in this column, the recovered row is considered corrupted.\n                if (ctx->column_info[i].not_null) {\n                    sqliterkOSWarning(SQLITERK_DAMAGED, \"NULL value detected in NOT NULL column.\");\n                    ctx->fail_count++;\n                    return SQLITERK_OK;\n                }\n\n                // If it's INTEGER PRIMARY KEY column, bind rowid instead.\n                if (ctx->ipk_column == i + 1)\n                    sqlite3_bind_int64(stmt, i + 1,\n                                       sqliterk_column_rowid(column));\n                else\n                    sqlite3_bind_null(stmt, i + 1);\n                break;\n            case sqliterk_value_type_number:\n                // REAL value should not be stored in columns with TEXT affinity.\n                if (ctx->column_info[i].affinity == SQLITE_AFF_TEXT) {\n                    sqliterkOSWarning(SQLITERK_DAMAGED, \"REAL value detected in column with TEXT affinity.\");\n                    ctx->fail_count++;\n                    return SQLITERK_OK;\n                }\n\n                sqlite3_bind_double(stmt, i + 1,\n                                    sqliterk_column_number(column, i));\n                break;\n            case sqliterk_value_type_text:\n                sqlite3_bind_text(stmt, i + 1, sqliterk_column_text(column, i),\n                                  sqliterk_column_bytes(column, i), NULL);\n                break;\n        }\n    }\n\n    // Use defaults for remaining values.\n    for (; i < ctx->real_columns; i++) {\n        sqlite3_value *v = ctx->column_info[i].default_value;\n        if (v) {\n            sqlite3_bind_value(stmt, i, v);\n        }\n    }\n\n    while (sqlite3_step(stmt) == SQLITE_ROW) {\n    }\n    rc = sqlite3_reset(stmt);\n    if (rc != SQLITE_OK) {\n        sqliterkOSWarning(rc, \"Failed to execute SQL: %s [SQL: %s]\",\n                          sqlite3_errmsg(ctx->db), sqlite3_sql(stmt));\n        ctx->fail_count++;\n        return SQLITERK_OK;\n    }\n\n    ctx->success_count++;\n    if (ctx->success_count % 256 == 0) {\n        char *errmsg;\n        rc = sqlite3_exec(ctx->db, \"COMMIT; BEGIN;\", NULL, NULL, &errmsg);\n        if (errmsg) {\n            sqliterkOSWarning(rc, \"Failed to commit transaction: %s\", errmsg);\n            sqlite3_free(errmsg);\n        }\n    }\n\n    return SQLITERK_OK;\n}\n\nint sqliterk_output(sqliterk *rk,\n                    sqlite3 *db,\n                    sqliterk_master_info *master_,\n                    unsigned int flags)\n{\n    return sqliterk_output_cb_leaf(rk, db, master_, NULL, flags, NULL, NULL);\n}\n\nint sqliterk_output_cb(sqliterk *rk,\n                       sqlite3 *db,\n                       sqliterk_master_info *master_,\n                       unsigned int flags,\n                       int (*callback)(void *user,\n                                       sqliterk *rk,\n                                       sqliterk_table *table,\n                                       sqliterk_column *column),\n                       void *user)\n{\n    return sqliterk_output_cb_leaf(rk, db, master_, NULL, flags, callback, user);\n}\n\nint sqliterk_output_cb_leaf(sqliterk *rk,\n                            sqlite3 *db,\n                            sqliterk_master_info *master_,\n                            sqliterk_leaf_info *leaf_,\n                            unsigned int flags,\n                            int (*callback)(void *user,\n                                            sqliterk *rk,\n                                            sqliterk_table *table,\n                                            sqliterk_column *column),\n                            void *user)\n{\n    if (!rk || !db)\n        return SQLITERK_MISUSE;\n\n    sqliterk_master_map *master = static_cast<sqliterk_master_map *>(master_);\n    const sqliterk_leaf_map *leaf = static_cast<sqliterk_leaf_map *>(leaf_);\n    sqliterk_output_ctx ctx;\n    ctx.db = db;\n    ctx.stmt = NULL;\n    ctx.flags = flags;\n    ctx.success_count = 0;\n    ctx.fail_count = 0;\n    ctx.ipk_column = 0;\n    ctx.callback = callback;\n    ctx.user = user;\n    ctx.cancelled = 0;\n\n    if (!master)\n        ctx.flags |= SQLITERK_OUTPUT_ALL_TABLES;\n    else\n        ctx.tables = *master;\n\n    sqliterk_set_user_info(rk, &ctx);\n    sqliterk_notify notify;\n    notify.onBeginParseTable = dummyParseTableCallback;\n    notify.onEndParseTable = dummyParseTableCallback;\n    notify.onParseColumn = master_onParseColumn;\n    notify.didParsePage = NULL;\n    sqliterk_register_notify(rk, notify);\n    sqliterk_set_recursive(rk, 0);\n\n    const char *db_file = sqlite3_db_filename(db, \"main\");\n    sqliterkOSInfo(SQLITERK_OK, \"Output recovered data to '%s', flags 0x%04x\",\n                   db_file ? db_file : \"unknown\", flags);\n\n    // Parse sqlite_master for table info.\n    sqliterkOSDebug(SQLITERK_OK, \"Begin parsing sqlite_master...\");\n    int rc = sqliterk_parse_page(rk, 1);\n    if (rc == SQLITERK_CANCELLED) {\n        goto cancelled;\n    } else if (rc != SQLITERK_OK)\n        sqliterkOSWarning(rc, \"Failed to parse sqlite_master.\");\n    else\n        sqliterkOSInfo(rc, \"Parsed sqlite_master. [table/index: %zu]\",\n                       ctx.tables.size());\n\n    // Parse all tables.\n    notify.onBeginParseTable = table_onBeginParseTable;\n    notify.onParseColumn = table_onParseColumn;\n    sqliterk_register_notify(rk, notify);\n\n    for (sqliterk_master_map::iterator it = ctx.tables.begin();\n         it != ctx.tables.end(); ++it) {\n        if (ctx.cancelled)\n            goto cancelled;\n\n        if (it->second.type != sqliterk_type_table)\n            continue;\n\n        // Run CREATE TABLE statements if necessary.\n        if (!(ctx.flags & SQLITERK_OUTPUT_NO_CREATE_TABLES) &&\n            !it->second.sql.empty()) {\n            sqliterkOSInfo(SQLITERK_OK, \">>> %s\", it->second.sql.c_str());\n            char *errmsg = NULL;\n            const char *sql = it->second.sql.c_str();\n            rc = sqlite3_exec(ctx.db, sql, NULL, NULL, &errmsg);\n            if (errmsg) {\n                sqliterkOSWarning(rc, \"EXEC FAILED: %s [SQL: %s]\", errmsg, sql);\n                ctx.fail_count++;\n                sqlite3_free(errmsg);\n            } else\n                ctx.success_count++;\n        }\n\n        if (it->second.root_page != 0) {\n            const char *name = it->first.c_str();\n            int root_page = it->second.root_page;\n            sqliterkOSInfo(SQLITERK_OK, \"[%s] -> pgno: %d\", name, root_page);\n            ctx.table_cursor = it;\n            rc = sqliterk_parse_page(rk, root_page);\n            if (rc != SQLITERK_CANCELLED && leaf) {\n                auto leafIt = leaf->find(it->first);\n                if (leafIt != leaf->end()) {\n                    auto& allPages = leafIt->second;\n                    for (int pgno : allPages) {\n                        rc = sqliterk_parse_page(rk, pgno);\n                        if (rc == SQLITERK_CANCELLED)\n                            break;\n                    }\n                }\n            }\n            if (ctx.stmt) {\n                const char *sql =\n                        (rc == SQLITERK_CANCELLED) ? \"ROLLBACK;\" : \"COMMIT;\";\n\n                // Commit transaction and free statement.\n                char *errmsg;\n                int rc2 = sqlite3_exec(ctx.db, sql, NULL, NULL, &errmsg);\n                if (errmsg) {\n                    sqliterkOSWarning(rc2, \"Failed to commit transaction: %s\",\n                                      errmsg);\n                    sqlite3_free(errmsg);\n                }\n\n                fini_insert(&ctx);\n            }\n            if (rc == SQLITERK_CANCELLED) {\n                goto cancelled;\n            } else if (rc != SQLITERK_OK) {\n                sqliterkOSWarning(rc,\n                                  \"Failed to parse B-tree with root page %d.\",\n                                  it->second.root_page);\n            }\n        }\n    }\n\n    // Iterate through indices, create them if necessary.\n    if (!(ctx.flags & SQLITERK_OUTPUT_NO_CREATE_TABLES)) {\n        for (sqliterk_master_map::iterator it = ctx.tables.begin();\n             it != ctx.tables.end(); ++it) {\n            if (ctx.cancelled)\n                goto cancelled;\n\n            if (it->second.type != sqliterk_type_index)\n                continue;\n\n            const char *sql = it->second.sql.c_str();\n            sqliterkOSDebug(SQLITERK_OK, \">>> %s\", sql);\n            char *errmsg = NULL;\n            rc = sqlite3_exec(ctx.db, sql, NULL, NULL, &errmsg);\n            if (errmsg) {\n                sqliterkOSWarning(rc, \"EXEC FAILED: %s [SQL: %s]\", errmsg, sql);\n                ctx.fail_count++;\n                sqlite3_free(errmsg);\n            } else\n                ctx.success_count++;\n        }\n    }\n\n    // Return OK only if we had successfully output at least one row.\n    if (ctx.success_count == 0) {\n        if (ctx.tables.empty())\n            sqliterkOSError(SQLITERK_DAMAGED,\n                            \"No valid sqlite_master info available, \"\n                            \"sqlite_master is corrupted.\");\n        else\n            sqliterkOSError(SQLITERK_DAMAGED,\n                            \"No rows can be successfully output. [failed: %u]\",\n                            ctx.fail_count);\n        return SQLITERK_DAMAGED;\n    } else {\n        sqliterkOSInfo(SQLITERK_OK,\n                       \"Recovery output finished. [succeeded: %u, failed: %u]\",\n                       ctx.success_count, ctx.fail_count);\n        return SQLITERK_OK;\n    }\n\n    cancelled:\n    sqliterkOSInfo(SQLITERK_CANCELLED,\n                   \"Recovery cancelled. [succeeded: %u, failed: %u]\",\n                   ctx.success_count, ctx.fail_count);\n    return SQLITERK_CANCELLED;\n}\n\nvoid sqliterk_cancel(sqliterk *rk)\n{\n    sqliterk_output_ctx *ctx =\n            (sqliterk_output_ctx *) sqliterk_get_user_info(rk);\n    if (ctx) {\n        ctx->cancelled = 1;\n    }\n}\n\nint sqliterk_make_master(const char **tables,\n                         int num_tables,\n                         sqliterk_master_info **out_master)\n{\n    if (!tables || !num_tables) {\n        *out_master = NULL;\n        return SQLITERK_OK;\n    }\n\n    sqliterk_master_map *master = new sqliterk_master_map();\n    for (int i = 0; i < num_tables; i++)\n        (*master)[tables[i]] =\n                sqliterk_master_entity(sqliterk_type_unknown, \"\", 0);\n\n    *out_master = static_cast<sqliterk_master_info *>(master);\n    return SQLITERK_OK;\n}\n\n#define SQLITERK_SM_TYPE_TABLE 0x01\n#define SQLITERK_SM_TYPE_INDEX 0x02\n\n#define SQLITERK_SM_MAGIC \"\\0dBmSt\"\n#define SQLITERK_SM_VERSION 1\n\n#pragma pack(push, 1)\nstruct master_file_header {\n    char magic[6];\n    uint16_t version;\n    uint32_t entities;\n    unsigned char kdf_salt[16];\n};\n\nstruct master_file_entity {\n    uint32_t root_page;\n    uint8_t type;\n    uint8_t name_len;\n    uint8_t tbl_name_len;\n    uint8_t reserved;\n    uint16_t sql_len;\n\n    unsigned char data[0];\n};\n#pragma pack(pop)\n\nint sqliterk_save_master(sqlite3 *db,\n                         const char *path,\n                         const void *key,\n                         int key_len)\n{\n    FILE *fp = NULL;\n    int rc = SQLITERK_OK;\n    sqlite3_stmt *stmt = NULL;\n    z_stream zstrm = {0};\n    CipherContext cipherContext(CipherContext::Encrypt);\n    unsigned char in_buf[512 + 8];\n    unsigned char out_buf[2048];\n    uint32_t entities = 0;\n    master_file_header header;\n\n    // Prepare deflate stream.\n    rc = deflateInit(&zstrm, Z_DEFAULT_COMPRESSION);\n    if (rc != Z_OK)\n        goto bail_zlib;\n    zstrm.data_type = Z_TEXT;\n\n    // Open output file.\n    fp = fopen(path, \"wb\");\n    if (!fp)\n        goto bail_errno;\n\n    // Prepare cipher key.\n    if (key && key_len) {\n        cipherContext.setKey(key, key_len);\n    } else {\n        key = NULL;\n    }\n\n    // Prepare SQL statement.\n    rc =\n            sqlite3_prepare_v2(db, \"SELECT * FROM sqlite_master;\", -1, &stmt, NULL);\n    if (rc != SQLITE_OK)\n        goto bail_sqlite;\n\n    // Write dummy header.\n    memset(&header, 0, sizeof(header));\n    if (fwrite(&header, sizeof(header), 1, fp) != 1)\n        goto bail_errno;\n\n    // Read all rows.\n    while ((rc = sqlite3_step(stmt)) == SQLITE_ROW) {\n        const char *typestr = (const char *) sqlite3_column_text(stmt, 0);\n        int name_len = sqlite3_column_bytes(stmt, 1);\n        const char *name = (const char *) sqlite3_column_text(stmt, 1);\n        int tbl_name_len = sqlite3_column_bytes(stmt, 2);\n        const char *tbl_name = (const char *) sqlite3_column_text(stmt, 2);\n        int root_page = sqlite3_column_int(stmt, 3);\n        int sql_len = sqlite3_column_bytes(stmt, 4);\n        const char *sql = (const char *) sqlite3_column_text(stmt, 4);\n\n        // Skip invalid rows.\n        if (!typestr || !name || !tbl_name || !sql)\n            continue;\n\n        // Skip system tables and indices.\n        if (strncmp(name, \"sqlite_\", 7) == 0)\n            continue;\n\n        unsigned char type;\n        if (strcmp(typestr, \"table\") == 0)\n            type = SQLITERK_SM_TYPE_TABLE;\n        else if (strcmp(typestr, \"index\") == 0)\n            type = SQLITERK_SM_TYPE_INDEX;\n        else\n            continue;\n\n        if (name_len > 255 || tbl_name_len > 255 || sql_len > 65535) {\n            sqliterkOSError(SQLITERK_IOERR,\n                            \"Table/index has name longer than 255: %s, %s\",\n                            name, tbl_name);\n            goto bail;\n        }\n\n        // Write to zip-stream buffer.\n        master_file_entity *entity = (master_file_entity *) in_buf;\n        entity->root_page = root_page;\n        entity->type = type;\n        entity->name_len = (unsigned char) name_len;\n        entity->tbl_name_len = (unsigned char) tbl_name_len;\n        entity->reserved = 0;\n        entity->sql_len = (unsigned short) sql_len;\n        unsigned char *p_data = entity->data;\n        memcpy(p_data, name, name_len + 1);\n        p_data += name_len + 1;\n        memcpy(p_data, tbl_name, tbl_name_len + 1);\n        p_data += tbl_name_len + 1;\n\n        zstrm.next_in = in_buf;\n        zstrm.avail_in = (uInt)(p_data - in_buf);\n\n        do {\n            zstrm.next_out = out_buf;\n            zstrm.avail_out = sizeof(out_buf);\n            rc = deflate(&zstrm, Z_NO_FLUSH);\n            if (rc == Z_STREAM_ERROR)\n                goto bail_zlib;\n\n            unsigned have = sizeof(out_buf) - zstrm.avail_out;\n            if (key) {\n                cipherContext.cipher(out_buf, have);\n            }\n            if (fwrite(out_buf, 1, have, fp) != have) {\n                sqliterkOSError(SQLITERK_IOERR,\n                                \"Cannot write to backup file: %s\",\n                                strerror(errno));\n                goto bail;\n            }\n        } while (zstrm.avail_out == 0);\n\n        zstrm.next_in = (unsigned char *) sql;\n        zstrm.avail_in = sql_len + 1;\n\n        do {\n            zstrm.next_out = out_buf;\n            zstrm.avail_out = sizeof(out_buf);\n            rc = deflate(&zstrm, Z_NO_FLUSH);\n            if (rc == Z_STREAM_ERROR)\n                goto bail_zlib;\n\n            unsigned have = sizeof(out_buf) - zstrm.avail_out;\n            if (key) {\n                cipherContext.cipher(out_buf, have);\n            }\n            if (fwrite(out_buf, 1, have, fp) != have) {\n                sqliterkOSError(SQLITERK_IOERR,\n                                \"Cannot write to backup file: %s\",\n                                strerror(errno));\n                goto bail;\n            }\n        } while (zstrm.avail_out == 0);\n\n        entities++;\n    } // sqlite3_step\n    rc = sqlite3_finalize(stmt);\n    stmt = NULL;\n    if (rc != SQLITE_OK)\n        goto bail_sqlite;\n\n    // Flush Z-stream.\n    zstrm.avail_in = 0;\n    do {\n        zstrm.next_out = out_buf;\n        zstrm.avail_out = sizeof(out_buf);\n        rc = deflate(&zstrm, Z_FINISH);\n        if (rc == Z_STREAM_ERROR)\n            goto bail_zlib;\n\n        unsigned have = sizeof(out_buf) - zstrm.avail_out;\n        if (key) {\n            cipherContext.cipher(out_buf, have);\n        }\n        if (fwrite(out_buf, 1, have, fp) != have) {\n            sqliterkOSError(SQLITERK_IOERR, \"Cannot write to backup file: %s\",\n                            strerror(errno));\n            goto bail;\n        }\n    } while (zstrm.avail_out == 0);\n    deflateEnd(&zstrm);\n\n    // Read KDF salt from file header.\n    sqlite3_file *db_file;\n    rc = sqlite3_file_control(db, \"main\", SQLITE_FCNTL_FILE_POINTER, &db_file);\n    if (rc != SQLITE_OK)\n        goto bail_sqlite;\n\n    rc = db_file->pMethods->xRead(db_file, header.kdf_salt,\n                                  sizeof(header.kdf_salt), 0);\n    if (rc != SQLITE_OK)\n        goto bail_sqlite;\n\n    // Write real header.\n    memcpy(header.magic, SQLITERK_SM_MAGIC, sizeof(header.magic));\n    header.version = SQLITERK_SM_VERSION;\n    header.entities = entities;\n    fseek(fp, 0, SEEK_SET);\n    fwrite(&header, sizeof(header), 1, fp);\n    fclose(fp);\n\n    sqliterkOSInfo(SQLITERK_OK, \"Saved master info with %u entries.\", entities);\n    return SQLITERK_OK;\n\n    bail_zlib:\n    sqliterkOSError(SQLITERK_CANTOPEN, \"Failed to backup master table: %s\",\n                    zstrm.msg);\n    goto bail;\n    bail_errno:\n    sqliterkOSError(rc, \"Failed to backup master table: %s\", strerror(errno));\n    goto bail;\n    bail_sqlite:\n    sqliterkOSError(rc, \"Failed to backup master table: %s\",\n                    sqlite3_errmsg(db));\n\n    bail:\n    if (fp)\n        fclose(fp);\n    if (stmt)\n        sqlite3_finalize(stmt);\n    deflateEnd(&zstrm);\n    return rc;\n}\n\nstatic const size_t IN_BUF_SIZE = 4096;\nstatic int inflate_read(FILE *fp,\n                        z_streamp strm,\n                        void *buf,\n                        unsigned size,\n                        CipherContext *cipherContext)\n{\n    int ret;\n    if (size == 0)\n        return SQLITERK_OK;\n\n    strm->next_out = (unsigned char *) buf;\n    strm->avail_out = size;\n\n    do {\n        if (strm->avail_in == 0 && !feof(fp)) {\n            unsigned char *in_buf = strm->next_in - strm->total_in;\n            strm->total_in = 0;\n\n            ret = (int) fread(in_buf, 1, IN_BUF_SIZE, fp);\n            if (ret == 0 && ferror(fp))\n                return SQLITERK_IOERR;\n            if (ret > 0) {\n                if (cipherContext) {\n                    cipherContext->cipher(in_buf, ret);\n                }\n                strm->next_in = in_buf;\n                strm->avail_in = ret;\n            }\n        }\n\n        ret = inflate(strm, Z_NO_FLUSH);\n        if (ret != Z_OK && ret != Z_STREAM_END)\n            return SQLITERK_DAMAGED;\n\n    } while (strm->avail_out > 0 && ret != Z_STREAM_END);\n\n    return strm->avail_out ? SQLITERK_DAMAGED : SQLITERK_OK;\n}\n\nstatic int pstrcmp(const void *p1, const void *p2)\n{\n    return strcmp(*(char *const *) p1, *(char *const *) p2);\n}\n\nint sqliterk_load_master(const char *path,\n                         const void *key,\n                         int key_len,\n                         const char **tables,\n                         int num_tables,\n                         sqliterk_master_info **out_master,\n                         unsigned char *out_kdf_salt)\n{\n    FILE *fp = NULL;\n    z_stream zstrm = {0};\n    CipherContext cipherContext(CipherContext::Decrypt);\n    int rc;\n    unsigned char in_buf[IN_BUF_SIZE];\n    const char **filter = NULL;\n    sqliterk_master_map *master = NULL;\n    uint32_t entities;\n\n    // Allocate output buffer.\n    char *str_buf = (char *) malloc(65536 + 512);\n    if (!str_buf)\n        goto bail_errno;\n\n    // Sort table filter for later binary searching.\n    if (tables && num_tables) {\n        sqliterk_make_master(tables, num_tables,\n                             (sqliterk_master_info **) &master);\n\n        size_t filter_size = num_tables * sizeof(const char *);\n        filter = (const char **) malloc(filter_size);\n        if (!filter)\n            goto bail_errno;\n\n        memcpy(filter, tables, filter_size);\n        qsort(filter, num_tables, sizeof(const char *), pstrcmp);\n    }\n    if (!master)\n        master = new sqliterk_master_map();\n\n    fp = fopen(path, \"rb\");\n    if (!fp)\n        goto bail_errno;\n\n    // Read header.\n    master_file_header header;\n    if (fread(&header, sizeof(header), 1, fp) != 1)\n        goto bail_errno;\n    if (memcmp(header.magic, SQLITERK_SM_MAGIC, sizeof(header.magic)) != 0 ||\n        header.version != SQLITERK_SM_VERSION) {\n        sqliterkOSError(SQLITERK_DAMAGED, \"Invalid format: %s\", path);\n        goto bail;\n    }\n\n    // Initialize zlib and RC4.\n    rc = inflateInit(&zstrm);\n    if (rc != Z_OK)\n        goto bail_zlib;\n\n    if (key && key_len) {\n        cipherContext.setKey(key, key_len);\n    } else {\n        key = NULL;\n    }\n\n    // Read all entities.\n    entities = header.entities;\n    zstrm.next_in = in_buf;\n    zstrm.avail_in = 0;\n    while (entities--) {\n        // Read entity header.\n        master_file_entity entity;\n        rc = inflate_read(fp, &zstrm, &entity, sizeof(entity),\n                          key ? &cipherContext : NULL);\n        if (rc == SQLITERK_IOERR)\n            goto bail_errno;\n        else if (rc == SQLITERK_DAMAGED)\n            goto bail_zlib;\n\n        // Read names and SQL.\n        rc = inflate_read(fp, &zstrm, str_buf,\n                          entity.name_len + entity.tbl_name_len +\n                          entity.sql_len + 3,\n                          key ? &cipherContext : NULL);\n        if (rc == SQLITERK_IOERR)\n            goto bail_errno;\n        else if (rc == SQLITERK_DAMAGED)\n            goto bail_zlib;\n\n        const char *name = str_buf;\n        const char *tbl_name = name + entity.name_len + 1;\n        const char *sql = tbl_name + entity.tbl_name_len + 1;\n        if (name[entity.name_len] != '\\0' ||\n            tbl_name[entity.tbl_name_len] != '\\0' ||\n            sql[entity.sql_len] != '\\0') {\n            sqliterkOSError(SQLITERK_DAMAGED,\n                            \"Invalid string. File corrupted.\");\n            goto bail;\n        }\n\n        // Filter tables.\n        if (!filter || bsearch(&tbl_name, filter, num_tables,\n                               sizeof(const char *), pstrcmp)) {\n            sqliterk_master_entity e(sqliterk_type_unknown, sql,\n                                     entity.root_page);\n            if (entity.type == SQLITERK_SM_TYPE_TABLE)\n                e.type = sqliterk_type_table;\n            else if (entity.type == SQLITERK_SM_TYPE_INDEX)\n                e.type = sqliterk_type_index;\n\n            (*master)[name] = e;\n        }\n    }\n\n    inflateEnd(&zstrm);\n    free(str_buf);\n    free(filter);\n    fclose(fp);\n\n    if (out_kdf_salt)\n        memcpy(out_kdf_salt, header.kdf_salt, sizeof(header.kdf_salt));\n    *out_master = static_cast<sqliterk_master_info *>(master);\n    sqliterkOSInfo(SQLITERK_OK, \"Loaded master info with %zu valid entries.\",\n                   master->size());\n    return SQLITERK_OK;\n\n    bail_errno:\n    sqliterkOSError(SQLITERK_IOERR, \"Cannot load master table: %s\",\n                    strerror(errno));\n    goto bail;\n    bail_zlib:\n    sqliterkOSError(SQLITERK_DAMAGED, \"Cannot load master table: %s\",\n                    zstrm.msg);\n    bail:\n    if (master)\n        delete master;\n    free(str_buf);\n    free(filter);\n    inflateEnd(&zstrm);\n    if (fp)\n        fclose(fp);\n    return SQLITERK_DAMAGED;\n}\n\nvoid sqliterk_free_master(sqliterk_master_info *master)\n{\n    if (master)\n        delete static_cast<sqliterk_master_map *>(master);\n}\n\nint sqliterk_scan_leaf(sqlite3 *db, const char * const *tables, int num_tables, sqliterk_leaf_info **out,\n                       volatile int *cancelFlag)\n{\n    int rc;\n    sqlite3_stmt *stmt = NULL;\n    sqliterk_leaf_map *result = new sqliterk_leaf_map();\n    auto lastRecord = result->end();\n    int row_count = 0;\n\n    std::string sql = \"SELECT name, pageno FROM dbstat WHERE pagetype = 'leaf'\";\n    if (tables && num_tables > 0) {\n        sql += \" AND name IN (\";\n        for (int i = 0; i < num_tables; ++i) {\n            sql += '\\'';\n            sql += tables[i];\n            sql += \"',\";\n        }\n        sql.back() = ')';\n    }\n\n    rc = sqlite3_prepare_v2(db, sql.c_str(), sql.size(), &stmt, NULL);\n    if (rc != SQLITE_OK) goto bail;\n\n    if (cancelFlag) {\n        sqlite3_progress_handler(db, 8,\n                                 [](void *p) { return *reinterpret_cast<volatile int *>(p); },\n                                 (void *) cancelFlag);\n    }\n\n    while ((rc = sqlite3_step(stmt)) == SQLITE_ROW) {\n        const char *name = (const char *) sqlite3_column_text(stmt, 0);\n        int pageNo = sqlite3_column_int(stmt, 1);\n        if (lastRecord == result->end() || lastRecord->first != name) {\n            lastRecord = result->emplace(std::string(name), std::vector<int>()).first;\n        }\n        lastRecord->second.push_back(pageNo);\n        ++row_count;\n    }\n    sqlite3_progress_handler(db, 0, NULL, NULL);\n    rc = sqlite3_finalize(stmt);\n    stmt = NULL;\n    if (rc != SQLITE_OK) goto bail;\n\n    sqliterkOSInfo(SQLITERK_OK, \"Scanned leaf info with %zu tables and %d entries.\",\n                   result->size(), row_count);\n    *out = static_cast<sqliterk_leaf_info *>(result);\n    return SQLITERK_OK;\n\nbail:\n    sqliterkOSError(rc, \"Failed to backup master table: %s\",\n                    sqlite3_errmsg(db));\n    if (stmt) {\n        sqlite3_finalize(stmt);\n    }\n    delete result;\n    return rc;\n}\n\nstatic const uint8_t LEAF_HEADER[] = {0x64, 0x42, 0x6c, 0x65, 0x61, 0x46, 0x00, 0x00}; // \"dBleaF\\0\\0\"\nint sqliterk_save_leaf(const sqliterk_leaf_info *li, const char *path)\n{\n    uint32_t uint_buf;\n    uint16_t strlen_buf;\n    const sqliterk_leaf_map& leafMap = *li;\n    FILE *fp = fopen(path, \"wb\");\n    if (!fp) goto bail;\n\n    // HEADER\n    if (fwrite(LEAF_HEADER, sizeof(LEAF_HEADER), 1, fp) != 1) goto bail;\n\n    // table count\n    uint_buf = li->size();\n    if (fwrite(&uint_buf, sizeof(uint_buf), 1, fp) != 1) goto bail;\n\n    for (auto const& tbl : leafMap) {\n        strlen_buf = tbl.first.size();\n        if (fwrite(&strlen_buf, sizeof(strlen_buf), 1, fp) != 1) goto bail;\n        if (fwrite(tbl.first.c_str(), strlen_buf, 1, fp) != 1) goto bail;\n\n        auto const& pages = tbl.second;\n        uint_buf = pages.size();\n        if (fwrite(&uint_buf, sizeof(uint_buf), 1, fp) != 1) goto bail;\n\n        for (int pageNo : pages) {\n            uint_buf = pageNo;\n            if (fwrite(&uint_buf, sizeof(uint_buf), 1, fp) != 1) goto bail;\n        }\n    }\n\n    fclose(fp);\n    return SQLITERK_OK;\n\nbail:\n    sqliterkOSError(SQLITERK_IOERR, \"Cannot write to file '%s': %s\", path, strerror(errno));\n    if (fp) fclose(fp);\n    return SQLITERK_IOERR;\n}\n\nint sqliterk_load_leaf(const char *path, sqliterk_leaf_info** out)\n{\n    sqliterk_leaf_map *result = new sqliterk_leaf_map();\n    uint8_t header[8];\n    uint32_t table_count;\n\n    FILE *fp = fopen(path, \"rb\");\n    if (!fp) goto bail;\n\n    if (fread(header, sizeof(header), 1, fp) != 1) goto bail;\n    if (memcmp(header, LEAF_HEADER, sizeof(LEAF_HEADER))) goto bail;\n\n    if (fread(&table_count, sizeof(table_count), 1, fp) != 1) goto bail;\n    while (table_count--) {\n        uint16_t strlen_buf;\n        if (fread(&strlen_buf, sizeof(strlen_buf), 1, fp) != 1) goto bail;\n        std::string name(strlen_buf, '\\0');\n        if (fread(name.data(), strlen_buf, 1, fp) != 1) goto bail;\n\n        uint32_t page_count;\n        if (fread(&page_count, sizeof(page_count), 1, fp) != 1) goto bail;\n        std::vector<int> pages(page_count);\n\n        while (page_count--) {\n            int page_no;\n            if (fread(&page_no, sizeof(int), 1, fp) != 1) goto bail;\n            pages.push_back(page_no);\n        }\n\n        result->emplace(std::move(name), std::move(pages));\n    }\n\n    fclose(fp);\n    *out = static_cast<sqliterk_leaf_info *>(result);\n    return SQLITERK_OK;\n\nbail:\n    sqliterkOSError(SQLITERK_IOERR, \"Cannot load file '%s': %s\", path, strerror(errno));\n    if (fp) fclose(fp);\n    delete result;\n    return SQLITERK_IOERR;\n}\n\nvoid sqliterk_free_leaf(sqliterk_leaf_info *li)\n{\n    delete static_cast<sqliterk_leaf_map *>(li);\n}\n"
  },
  {
    "path": "deprecated/android/addons/repair/sqliterk_pager.c",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"sqliterk_pager.h\"\n#include \"SQLiteRepairKit.h\"\n#include \"sqliterk_crypto.h\"\n#include \"sqliterk_os.h\"\n#include \"sqliterk_util.h\"\n#include <errno.h>\n#include <string.h>\n\nstatic int sqliterkPagerParseHeader(sqliterk_pager *pager, int forcePageSize);\nstatic int sqliterkPageAcquireOne(sqliterk_pager *pager,\n                                  int pageno,\n                                  sqliterk_page **page,\n                                  sqliterk_page_type type);\n\nstruct sqliterk_page {\n    int pageno;\n    unsigned char *data; // page data\n    sqliterk_page_type type;\n};\n\nint sqliterkPagerOpen(const char *path,\n                      const sqliterk_cipher_conf *cipher,\n                      sqliterk_pager **pager)\n{\n    // Workaround page size cannot be specified for plain-text\n    // databases. For that case, pass non-null cipher_conf with\n    // null key and non-zero page size.\n    int forcePageSize = 0;\n    if (cipher && !cipher->key) {\n        forcePageSize = cipher->page_size;\n        cipher = NULL;\n    }\n\n    if (!pager) {\n        return SQLITERK_MISUSE;\n    }\n    int rc = SQLITERK_OK;\n    sqliterk_pager *thePager = sqliterkOSMalloc(sizeof(sqliterk_pager));\n    if (!thePager) {\n        rc = SQLITERK_NOMEM;\n        sqliterkOSError(rc, \"Not enough memory, required %zu bytes.\",\n                        sizeof(sqliterk_pager));\n        goto sqliterkPagerOpen_Failed;\n    }\n\n    rc = sqliterkOSReadOnlyOpen(path, &thePager->file);\n    if (rc != SQLITERK_OK) {\n        goto sqliterkPagerOpen_Failed;\n    }\n\n    if (cipher) {\n        // Try KDF salt in SQLite file first.\n        sqliterk_cipher_conf c;\n        memcpy(&c, cipher, sizeof(c));\n        c.kdf_salt = NULL;\n\n        rc = sqliterkCryptoSetCipher(thePager, thePager->file, &c);\n        if (rc != SQLITERK_OK)\n            goto sqliterkPagerOpen_Failed;\n\n        // Try parsing header.\n        sqliterkPagerParseHeader(thePager, 0);\n\n        if (thePager->integrity & SQLITERK_INTEGRITY_HEADER) {\n            // If header is parsed successfully, original KDF salt is also correct.\n            thePager->integrity |= SQLITERK_INTEGRITY_KDF_SALT;\n        } else if (cipher->kdf_salt) {\n            // If anything goes wrong, use KDF salt specified in cipher config.\n            sqliterkOSWarning(SQLITERK_DAMAGED, \"Header cannot be decoded \"\n                                                \"correctly. Trying to apply \"\n                                                \"recovery data.\");\n            rc = sqliterkCryptoSetCipher(thePager, thePager->file, cipher);\n            if (rc != SQLITERK_OK)\n                goto sqliterkPagerOpen_Failed;\n\n            rc = sqliterkPagerParseHeader(thePager, 0);\n            if (rc != SQLITERK_OK)\n                goto sqliterkPagerOpen_Failed;\n        }\n    } else {\n        rc = sqliterkPagerParseHeader(thePager, forcePageSize);\n        if (rc != SQLITERK_OK)\n            goto sqliterkPagerOpen_Failed;\n\n        // For plain-text databases, just mark KDF salt correct.\n        if (thePager->integrity & SQLITERK_INTEGRITY_HEADER)\n            thePager->integrity |= SQLITERK_INTEGRITY_KDF_SALT;\n    }\n    if (!(thePager->integrity & SQLITERK_INTEGRITY_HEADER))\n        sqliterkOSWarning(SQLITERK_DAMAGED, \"Header corrupted.\");\n    else\n        sqliterkOSInfo(SQLITERK_OK, \"Header checksum OK.\");\n\n    int pageCount = thePager->pagecount;\n    size_t len = sizeof(sqliterk_status) * (pageCount + 1);\n    thePager->pagesStatus = sqliterkOSMalloc(len);\n    if (!thePager->pagesStatus) {\n        rc = SQLITERK_NOMEM;\n        sqliterkOSError(rc, \"Not enough memory, required %zu bytes.\", len);\n        goto sqliterkPagerOpen_Failed;\n    }\n\n    *pager = thePager;\n\n    return SQLITERK_OK;\n\nsqliterkPagerOpen_Failed:\n    if (thePager) {\n        sqliterkPagerClose(thePager);\n    }\n    *pager = NULL;\n    return rc;\n}\n\n// Get the meta from header and set it into pager.\n// For further information, see https://www.sqlite.org/fileformat2.html\nstatic int sqliterkPagerParseHeader(sqliterk_pager *pager, int forcePageSize)\n{\n    // For encrypted databases, assume default page size, decode the first\n    // page, and we have the plain-text header.\n\n    if (!pager) {\n        return SQLITERK_MISUSE;\n    }\n    int rc = SQLITERK_OK;\n\n    // Overwrite pager page size if forcePageSize is specified.\n    if (forcePageSize) {\n        pager->pagesize = forcePageSize;\n    }\n\n    size_t size = pager->codec ? pager->pagesize : 100;\n\n    // Read data\n    unsigned char *buffer = sqliterkOSMalloc(size);\n    if (!buffer) {\n        rc = SQLITERK_NOMEM;\n        sqliterkOSError(rc, \"Not enough memory, required %zu bytes.\", size);\n        goto sqliterkPagerParseHeader_End;\n    }\n\n    rc = sqliterkOSRead(pager->file, 0, buffer, &size);\n    if (rc != SQLITERK_OK) {\n        if (rc == SQLITERK_SHORT_READ)\n            sqliterkOSError(rc, \"File truncated.\");\n        else\n            sqliterkOSError(rc, \"Cannot read file '%s': %s\",\n                            sqliterkOSGetFilePath(pager->file),\n                            strerror(errno));\n        pager->integrity &= ~SQLITERK_INTEGRITY_HEADER;\n        goto sqliterkPagerParseHeader_End;\n    }\n\n    pager->integrity |= SQLITERK_INTEGRITY_HEADER;\n\n    if (pager->codec) {\n        rc = sqliterkCryptoDecode(pager->codec, 1, buffer);\n        if (rc != SQLITERK_OK) {\n            sqliterkOSWarning(SQLITERK_DAMAGED,\n                              \"Failed to decode page 1, header corrupted.\");\n            pager->integrity &= ~SQLITERK_INTEGRITY_HEADER;\n        }\n    }\n\n    if (pager->integrity & SQLITERK_INTEGRITY_HEADER) {\n        if (memcmp(buffer, \"SQLite format 3\\000\", 16) == 0) {\n            //parse pagesize\n            int pagesize;\n            sqliterkParseInt(buffer, 16, 2, &pagesize);\n            if (pager->codec || forcePageSize) {\n                // Page size is predefined, check whether it matches the header.\n                if (pagesize != pager->pagesize) {\n                    sqliterkOSWarning(\n                        SQLITERK_DAMAGED,\n                        \"Invalid page size: %d expected, %d returned.\",\n                        pager->pagesize, pagesize);\n                    pager->integrity &= ~SQLITERK_INTEGRITY_HEADER;\n                }\n            } else if (((pagesize - 1) & pagesize) != 0 || pagesize < 512) {\n                // Page size is not predefined and value in the header is invalid,\n                // use the default page size.\n                sqliterkOSWarning(SQLITERK_DAMAGED,\n                                  \"Page size field is corrupted. Default page \"\n                                  \"size %d is used\",\n                                  SQLITRK_CONFIG_DEFAULT_PAGESIZE);\n                pager->pagesize = SQLITRK_CONFIG_DEFAULT_PAGESIZE;\n                pager->integrity &= ~SQLITERK_INTEGRITY_HEADER;\n            } else {\n                // Page size is not predefined and value in the header is valid,\n                // use the value in header.\n                pager->pagesize = pagesize;\n            }\n\n            // parse free page count\n            sqliterkParseInt(buffer, 36, 4, &pager->freepagecount);\n\n            // parse reserved bytes\n            int reservedBytes;\n            sqliterkParseInt(buffer, 20, 1, &reservedBytes);\n            if (pager->codec) {\n                if (reservedBytes != pager->reservedBytes) {\n                    sqliterkOSWarning(SQLITERK_DAMAGED,\n                                      \"Reserved bytes field doesn't match. %d \"\n                                      \"expected, %d returned.\",\n                                      pager->reservedBytes, reservedBytes);\n                    pager->integrity &= ~SQLITERK_INTEGRITY_HEADER;\n                }\n            } else if (reservedBytes < 0 || reservedBytes > 255) {\n                sqliterkOSWarning(\n                    SQLITERK_DAMAGED,\n                    \"The [reserved bytes] field is corrupted. 0 is used\");\n                pager->reservedBytes = 0;\n                pager->integrity &= ~SQLITERK_INTEGRITY_HEADER;\n            } else\n                pager->reservedBytes = reservedBytes;\n        } else {\n            // Header is corrupted. Defaults the config\n            sqliterkOSWarning(SQLITERK_DAMAGED,\n                              \"SQLite format magic corrupted.\");\n            if (!pager->codec) {\n                pager->pagesize = SQLITRK_CONFIG_DEFAULT_PAGESIZE;\n                pager->reservedBytes = 0;\n            }\n            pager->freepagecount = 0;\n            pager->integrity &= ~SQLITERK_INTEGRITY_HEADER;\n        }\n    }\n\n    // Assign page count\n    size_t filesize;\n    rc = sqliterkOSFileSize(pager->file, &filesize);\n    if (rc != SQLITERK_OK) {\n        sqliterkOSError(rc, \"Failed to get size of file '%s': %s\",\n                        sqliterkOSGetFilePath(pager->file), strerror(errno));\n        goto sqliterkPagerParseHeader_End;\n    }\n\n    pager->pagecount =\n        (int) ((filesize + pager->pagesize - 1) / pager->pagesize);\n    if (pager->pagecount < 1) {\n        rc = SQLITERK_DAMAGED;\n        sqliterkOSError(rc, \"File truncated.\");\n        goto sqliterkPagerParseHeader_End;\n    }\n\n    // Check free page\n    if (pager->freepagecount < 0 || pager->freepagecount > pager->pagecount) {\n        sqliterkOSWarning(\n            SQLITERK_DAMAGED,\n            \"The [free page count] field is corrupted. 0 is used\");\n        pager->freepagecount = 0;\n        pager->integrity &= ~SQLITERK_INTEGRITY_HEADER;\n    }\n\n    // Assign usableSize\n    pager->usableSize = pager->pagesize - pager->reservedBytes;\n\nsqliterkPagerParseHeader_End:\n    if (buffer) {\n        sqliterkOSFree(buffer);\n    }\n    return rc;\n}\n\nint sqliterkPagerClose(sqliterk_pager *pager)\n{\n    if (!pager) {\n        return SQLITERK_MISUSE;\n    }\n    int rc = SQLITERK_OK;\n    if (pager->file) {\n        rc = sqliterkOSClose(pager->file);\n        pager->file = NULL;\n    }\n    if (pager->pagesStatus) {\n        sqliterkOSFree(pager->pagesStatus);\n        pager->pagesStatus = NULL;\n    }\n    pager->pagesize = 0;\n    pager->pagecount = 0;\n\n    sqliterkCryptoFreeCodec(pager);\n\n    sqliterkOSFree(pager);\n    return rc;\n}\n\nint sqliterkPagerGetPageCount(sqliterk_pager *pager)\n{\n    if (!pager) {\n        return 0;\n    }\n    return pager->pagecount;\n}\n\nint sqliterkPagerIsPagenoValid(sqliterk_pager *pager, int pageno)\n{\n    if (!pager || pageno < 1 || pageno > pager->pagecount) {\n        return SQLITERK_MISUSE;\n    }\n    return SQLITERK_OK;\n}\n\n// Get the page type from file at page [pageno]\nint sqliterkPageAcquireType(sqliterk_pager *pager,\n                            int pageno,\n                            sqliterk_page_type *type)\n{\n    // TODO: for encrypted databases, decode the whole page.\n    // Use sqliterkPageAcquire instead.\n\n    if (!pager || sqliterkPagerIsPagenoValid(pager, pageno) != SQLITERK_OK ||\n        !type) {\n        return SQLITERK_MISUSE;\n    }\n    int rc = SQLITERK_OK;\n    unsigned char typedata;\n    size_t typesize = 1;\n    rc = sqliterkOSRead(pager->file,\n                        sqliterkPagenoHeaderOffset(pageno) +\n                            (pageno - 1) * pager->pagesize,\n                        &typedata, &typesize);\n    if (rc != SQLITERK_OK) {\n        goto sqliterkPageAcquireType_Failed;\n    }\n\n    int theType;\n    sqliterkParseInt(&typedata, 0, 1, &theType);\n    switch (theType) {\n        case sqliterk_page_type_interior_index:\n        case sqliterk_page_type_interior_table:\n        case sqliterk_page_type_leaf_index:\n        case sqliterk_page_type_leaf_table:\n            *type = theType;\n            break;\n        default:\n            *type = sqliterk_page_type_unknown;\n            break;\n    }\n    return SQLITERK_OK;\n\nsqliterkPageAcquireType_Failed:\n    *type = sqliterk_page_type_unknown;\n    return rc;\n}\n\n// Get whole page data from file at page [pageno] and setup the [page].\nint sqliterkPageAcquire(sqliterk_pager *pager, int pageno, sqliterk_page **page)\n{\n    return sqliterkPageAcquireOne(pager, pageno, page,\n                                  sqliterk_page_type_unknown);\n}\n\nint sqliterkPageAcquireOverflow(sqliterk_pager *pager,\n                                int pageno,\n                                sqliterk_page **page)\n{\n    return sqliterkPageAcquireOne(pager, pageno, page,\n                                  sqliterk_page_type_overflow);\n}\n\nstatic int sqliterkPageAcquireOne(sqliterk_pager *pager,\n                                  int pageno,\n                                  sqliterk_page **page,\n                                  sqliterk_page_type type)\n{\n    if (!pager || !page ||\n        sqliterkPagerIsPagenoValid(pager, pageno) != SQLITERK_OK) {\n        return SQLITERK_MISUSE;\n    }\n    int rc = SQLITERK_OK;\n    sqliterk_page *thePage = sqliterkOSMalloc(sizeof(sqliterk_page));\n    if (!thePage) {\n        rc = SQLITERK_NOMEM;\n        goto sqliterkPageAcquire_Failed;\n    }\n\n    thePage->pageno = pageno;\n\n    thePage->data = sqliterkOSMalloc(pager->pagesize);\n    if (!thePage->data) {\n        rc = SQLITERK_NOMEM;\n        goto sqliterkPageAcquire_Failed;\n    }\n\n    size_t size = pager->pagesize;\n    rc = sqliterkOSRead(pager->file, (pageno - 1) * pager->pagesize,\n                        thePage->data, &size);\n    if (rc != SQLITERK_OK) {\n        goto sqliterkPageAcquire_Failed;\n    }\n\n    // For encrypted databases, decode page.\n    if (pager->codec) {\n        rc = sqliterkCryptoDecode(pager->codec, pageno, thePage->data);\n        if (rc != SQLITERK_OK)\n            goto sqliterkPageAcquire_Failed;\n    }\n\n    // Check type\n    if (type == sqliterk_page_type_unknown) {\n        sqliterkParseInt(thePage->data, sqliterkPageHeaderOffset(thePage), 1,\n                         &type);\n        switch (type) {\n            case sqliterk_page_type_interior_index:\n            case sqliterk_page_type_interior_table:\n            case sqliterk_page_type_leaf_index:\n            case sqliterk_page_type_leaf_table:\n                thePage->type = type;\n                break;\n            default:\n                thePage->type = sqliterk_page_type_unknown;\n                break;\n        }\n    } else {\n        thePage->type = type;\n    }\n\n    *page = thePage;\n    return SQLITERK_OK;\n\nsqliterkPageAcquire_Failed:\n    if (thePage) {\n        sqliterkPageRelease(thePage);\n    }\n    *page = NULL;\n    return rc;\n}\n\nint sqliterkPageRelease(sqliterk_page *page)\n{\n    if (!page) {\n        return SQLITERK_MISUSE;\n    }\n    if (page->data) {\n        sqliterkOSFree(page->data);\n        page->data = NULL;\n    }\n    sqliterkOSFree(page);\n    return SQLITERK_OK;\n}\n\n// Ahead release the page data to save memory\nint sqliterkPageClearData(sqliterk_page *page)\n{\n    if (!page) {\n        return SQLITERK_MISUSE;\n    }\n    if (page->data) {\n        sqliterkOSFree(page->data);\n        page->data = NULL;\n    }\n    return SQLITERK_OK;\n}\n\nconst unsigned char *sqliterkPageGetData(sqliterk_page *page)\n{\n    if (!page) {\n        return NULL;\n    }\n    return page->data;\n}\n\nint sqliterkPagerGetSize(sqliterk_pager *pager)\n{\n    if (!pager) {\n        return 0;\n    }\n    return pager->pagesize;\n}\n\nint sqliterkPagerGetUsableSize(sqliterk_pager *pager)\n{\n    if (!pager) {\n        return 0;\n    }\n    return pager->usableSize;\n}\n\nint sqliterkPageGetPageno(sqliterk_page *page)\n{\n    if (!page) {\n        return 0;\n    }\n    return page->pageno;\n}\nsqliterk_page_type sqliterkPageGetType(sqliterk_page *page)\n{\n    if (!page) {\n        return sqliterk_page_type_unknown;\n    }\n    return page->type;\n}\n\nint sqliterkPagenoHeaderOffset(int pageno)\n{\n    if (pageno == 1) {\n        return 100;\n    }\n    return 0;\n}\n\nint sqliterkPageHeaderOffset(sqliterk_page *page)\n{\n    if (!page) {\n        return 0;\n    }\n    return sqliterkPagenoHeaderOffset(page->pageno);\n}\n\nconst char *sqliterkPageGetTypeName(sqliterk_page_type type)\n{\n    char *name;\n    switch (type) {\n        case sqliterk_page_type_interior_index:\n            name = \"interior-index btree\";\n            break;\n        case sqliterk_page_type_interior_table:\n            name = \"interior-table btree\";\n            break;\n        case sqliterk_page_type_leaf_index:\n            name = \"leaf-index btree\";\n            break;\n        case sqliterk_page_type_leaf_table:\n            name = \"leaf-table btree\";\n            break;\n        default:\n            name = \"unknown page\";\n            break;\n    }\n    return name;\n}\n\nvoid sqliterkPagerSetStatus(sqliterk_pager *pager,\n                            int pageno,\n                            sqliterk_status status)\n{\n    if (!pager || !pager->pagesStatus ||\n        sqliterkPagerIsPagenoValid(pager, pageno) != SQLITERK_OK) {\n        return;\n    }\n\n    pager->pagesStatus[pageno - 1] = status;\n    if (status == sqliterk_status_checked) {\n        pager->integrity |= SQLITERK_INTEGRITY_DATA;\n        pager->checkedPageCount++;\n    } else if (status == sqliterk_status_damaged) {\n        pager->damagedPageCount++;\n    }\n}\n\nsqliterk_status sqliterkPagerGetStatus(sqliterk_pager *pager, int pageno)\n{\n    if (!pager || !pager->pagesStatus ||\n        sqliterkPagerIsPagenoValid(pager, pageno) != SQLITERK_OK) {\n        return sqliterk_status_invalid;\n    }\n    return pager->pagesStatus[pageno - 1];\n}\n\nint sqliterkPagerGetParsedPageCount(sqliterk_pager *pager)\n{\n    if (!pager) {\n        return 0;\n    }\n    return pager->checkedPageCount;\n}\n\nint sqliterkPagerGetDamagedPageCount(sqliterk_pager *pager)\n{\n    if (!pager) {\n        return 0;\n    }\n    return pager->damagedPageCount;\n}\n\nint sqliterkPagerGetValidPageCount(sqliterk_pager *pager)\n{\n    if (!pager) {\n        return 0;\n    }\n    return pager->pagecount - pager->freepagecount;\n}\n\nunsigned int sqliterkPagerGetIntegrity(sqliterk_pager *pager)\n{\n    if (!pager) {\n        return 0;\n    }\n    return pager->integrity;\n}\n"
  },
  {
    "path": "deprecated/android/addons/repair/sqliterk_pager.h",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#ifndef sqliterk_pager_h\n#define sqliterk_pager_h\n\n#include \"sqliterk_crypto.h\"\n#include <stdio.h>\n\n// A legal state transfer is:\n// unchecked --> checking\n// checking --> invalid\n// checking --> damaged\n// checking --> checked\n// checking --> discarded\n// default status is unchecked\ntypedef enum {\n    sqliterk_status_invalid = -1,\n    sqliterk_status_unchecked = 0,\n    sqliterk_status_checking = 1,\n    sqliterk_status_damaged = 2,\n    sqliterk_status_discarded = 3,\n    sqliterk_status_checked = 4,\n} sqliterk_status;\n\n// We are only concerned about the listed types. See https://www.sqlite.org/fileformat2.html#btree\ntypedef enum {\n    sqliterk_page_type_interior_index = 2,\n    sqliterk_page_type_interior_table = 5,\n    sqliterk_page_type_leaf_index = 10,\n    sqliterk_page_type_leaf_table = 13,\n    sqliterk_page_type_overflow = 1,\n    sqliterk_page_type_unknown = -1,\n} sqliterk_page_type;\n\n// sqliterk_pager is the management class for all page in single db file\ntypedef struct sqliterk_pager sqliterk_pager;\n// sqliterk_page is single page in db file, including its page data. But sometime, page data will be ahead release to save memory.\ntypedef struct sqliterk_page sqliterk_page;\n\ntypedef struct sqliterk_file sqliterk_file;\ntypedef struct sqliterk_cipher_conf sqliterk_cipher_conf;\nstruct sqliterk_pager {\n    sqliterk_file *file;\n    sqliterk_status *pagesStatus;\n    int pagesize;\n    int freepagecount;\n    int reservedBytes;\n    int pagecount;\n    int usableSize;         // pagesize-reservedBytes\n    unsigned int integrity; // integrity flags.\n\n    int checkedPageCount;\n    int damagedPageCount;\n\n    sqliterk_codec *codec; // Codec context, implemented in SQLCipher library.\n};\n\nint sqliterkPagerOpen(const char *path,\n                      const sqliterk_cipher_conf *cipher,\n                      sqliterk_pager **pager);\nint sqliterkPagerClose(sqliterk_pager *pager);\nint sqliterkPagerGetPageCount(sqliterk_pager *pager);\nint sqliterkPagerIsPagenoValid(sqliterk_pager *pager, int pageno);\nint sqliterkPagerGetSize(sqliterk_pager *pager);\nint sqliterkPagerGetUsableSize(sqliterk_pager *pager);\n\nvoid sqliterkPagerSetStatus(sqliterk_pager *pager,\n                            int pageno,\n                            sqliterk_status status);\nsqliterk_status sqliterkPagerGetStatus(sqliterk_pager *pager, int pageno);\nint sqliterkPagerGetParsedPageCount(sqliterk_pager *pager);\nint sqliterkPagerGetDamagedPageCount(sqliterk_pager *pager);\nint sqliterkPagerGetValidPageCount(sqliterk_pager *pager);\nunsigned int sqliterkPagerGetIntegrity(sqliterk_pager *pager);\n\nint sqliterkPageAcquire(sqliterk_pager *pager,\n                        int pageno,\n                        sqliterk_page **page);\nint sqliterkPageAcquireOverflow(sqliterk_pager *pager,\n                                int pageno,\n                                sqliterk_page **page);\nint sqliterkPageAcquireType(sqliterk_pager *pager,\n                            int pageno,\n                            sqliterk_page_type *type);\nint sqliterkPageClearData(sqliterk_page *page);\nint sqliterkPageRelease(sqliterk_page *page);\n\nint sqliterkPagenoHeaderOffset(int pageno);\nint sqliterkPageHeaderOffset(sqliterk_page *page);\n\nconst unsigned char *sqliterkPageGetData(sqliterk_page *page);\n\nint sqliterkPageGetPageno(sqliterk_page *page);\nsqliterk_page_type sqliterkPageGetType(sqliterk_page *page);\n\nconst char *sqliterkPageGetTypeName(sqliterk_page_type type);\n\n#endif /* sqliterk_pager_h */\n"
  },
  {
    "path": "deprecated/android/addons/repair/sqliterk_values.c",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"sqliterk_values.h\"\n#include \"SQLiteRepairKit.h\"\n#include \"sqliterk_os.h\"\n#include \"sqliterk_util.h\"\n#include <stdlib.h>\n#include <string.h>\n\n//declaration\nstatic int sqliterkValuesAutoGrow(sqliterk_values *values);\n\ntypedef int64_t sqliterk_integer;\ntypedef double sqliterk_number;\ntypedef struct sqliterk_text sqliterk_text;\nstruct sqliterk_text {\n    char *t;\n    int s;\n};\ntypedef struct sqliterk_binary sqliterk_binary;\nstruct sqliterk_binary {\n    void *b;\n    int s;\n};\ntypedef union sqliterk_any sqliterk_any;\nunion sqliterk_any {\n    sqliterk_integer integer;\n    sqliterk_number number;\n    sqliterk_text text;\n    sqliterk_binary binary;\n};\n\nstruct sqliterk_value {\n    sqliterk_value_type type;\n    sqliterk_any any;\n};\n\nstruct sqliterk_values {\n    int count;\n    int capacity;\n    sqliterk_value *values;\n};\n\nint sqliterkValuesAlloc(sqliterk_values **values)\n{\n    if (!values) {\n        return SQLITERK_MISUSE;\n    }\n    int rc = SQLITERK_OK;\n    sqliterk_values *theValues = sqliterkOSMalloc(sizeof(sqliterk_values));\n    if (!theValues) {\n        rc = SQLITERK_NOMEM;\n        goto sqliterkValuesAlloc_Failed;\n    }\n    rc = sqliterkValuesAutoGrow(theValues);\n    if (rc != SQLITERK_OK) {\n        goto sqliterkValuesAlloc_Failed;\n    }\n    *values = theValues;\n    return SQLITERK_OK;\nsqliterkValuesAlloc_Failed:\n    if (theValues) {\n        sqliterkValuesFree(theValues);\n    }\n    return rc;\n}\n\nint sqliterkValuesFree(sqliterk_values *values)\n{\n    if (!values) {\n        return SQLITERK_MISUSE;\n    }\n\n    int i;\n    for (i = 0; i < values->count; i++) {\n        sqliterk_value *value = &values->values[i];\n        sqliterkValueClear(value);\n    }\n    values->count = 0;\n    if (values->values) {\n        sqliterkOSFree(values->values);\n        values->values = NULL;\n    }\n    values->capacity = 0;\n    sqliterkOSFree(values);\n    return SQLITERK_OK;\n}\n\nint sqliterkValuesClear(sqliterk_values *values)\n{\n    if (!values) {\n        return SQLITERK_MISUSE;\n    }\n\n    int i;\n    for (i = 0; i < values->count; i++) {\n        sqliterk_value *value = &values->values[i];\n        sqliterkValueClear(value);\n    }\n    values->count = 0;\n    return SQLITERK_OK;\n}\n\nstatic int sqliterkValuesAutoGrow(sqliterk_values *values)\n{\n    if (!values) {\n        return SQLITERK_MISUSE;\n    }\n    if (values->count >= values->capacity) {\n        int oldCapacity = values->capacity;\n        int newCapacity;\n        if (oldCapacity <= 0) {\n            //init for 4\n            newCapacity = 4;\n        } else if (oldCapacity > 8 * 1024 * 1024) {\n            newCapacity = oldCapacity + 8 * 1024 * 1024;\n        } else {\n            newCapacity = oldCapacity * 2;\n        }\n        sqliterk_value *newValues =\n            sqliterkOSMalloc(sizeof(sqliterk_value) * (newCapacity + 1));\n        if (!newValues) {\n            return SQLITERK_NOMEM;\n        }\n        if (values->values) {\n            memcpy(newValues, values->values,\n                   sizeof(sqliterk_value) * oldCapacity);\n            sqliterkOSFree(values->values);\n        }\n        values->values = newValues;\n        values->capacity = newCapacity;\n    }\n    return SQLITERK_OK;\n}\n\nint sqliterkValuesGetCount(sqliterk_values *values)\n{\n    if (!values) {\n        return 0;\n    }\n    return values->count;\n}\n\nsqliterk_value_type sqliterkValuesGetType(sqliterk_values *values, int index)\n{\n    if (values && index < sqliterkValuesGetCount(values)) {\n        return values->values[index].type;\n    }\n    return sqliterk_value_type_null;\n}\n\nint64_t sqliterkValuesGetInteger64(sqliterk_values *values, int index)\n{\n    int64_t out = 0;\n    if (values && index < sqliterkValuesGetCount(values)) {\n        sqliterk_value *value = &values->values[index];\n        switch (sqliterkValuesGetType(values, index)) {\n            case sqliterk_value_type_integer:\n                out = (int64_t)(value->any.integer);\n                break;\n            case sqliterk_value_type_number:\n                out = (int64_t)(value->any.number);\n                break;\n            case sqliterk_value_type_text:\n                out = atol(value->any.text.t);\n                break;\n            default:\n                break;\n        }\n    }\n    return out;\n}\n\nint sqliterkValuesGetInteger(sqliterk_values *values, int index)\n{\n    return (int) sqliterkValuesGetInteger64(values, index);\n}\n\ndouble sqliterkValuesGetNumber(sqliterk_values *values, int index)\n{\n    double out = 0;\n    if (values && index < sqliterkValuesGetCount(values)) {\n        sqliterk_value *value = &values->values[index];\n        switch (sqliterkValuesGetType(values, index)) {\n            case sqliterk_value_type_integer:\n                out = (double) (value->any.integer);\n                break;\n            case sqliterk_value_type_number:\n                out = (double) (value->any.number);\n                break;\n            case sqliterk_value_type_text:\n                out = atof(value->any.text.t);\n                break;\n            default:\n                break;\n        }\n    }\n    return out;\n}\n\nconst char *sqliterkValuesGetText(sqliterk_values *values, int index)\n{\n    char *out = NULL;\n    if (values && index < sqliterkValuesGetCount(values)) {\n        sqliterk_value *value = &values->values[index];\n        switch (value->type) {\n            case sqliterk_value_type_text:\n                out = value->any.text.t;\n                break;\n            default:\n                break;\n        }\n    }\n    return out;\n}\n\nconst void *sqliterkValuesGetBinary(sqliterk_values *values, int index)\n{\n    void *out = NULL;\n    if (values && index < sqliterkValuesGetCount(values)) {\n        sqliterk_value *value = &values->values[index];\n        switch (value->type) {\n            case sqliterk_value_type_binary:\n                out = value->any.binary.b;\n                break;\n            default:\n                break;\n        }\n    }\n    return out;\n}\n\nint sqliterkValuesGetBytes(sqliterk_values *values, int index)\n{\n    int out = 0;\n    if (values && index < sqliterkValuesGetCount(values)) {\n        sqliterk_value *value = &values->values[index];\n        switch (value->type) {\n            case sqliterk_value_type_binary:\n                out = value->any.binary.s;\n                break;\n            case sqliterk_value_type_text:\n                out = value->any.text.s;\n                break;\n            default:\n                break;\n        }\n    }\n    return out;\n}\n\nint sqliterkValuesAddInteger64(sqliterk_values *values, int64_t i)\n{\n    if (!values) {\n        return SQLITERK_MISUSE;\n    }\n    int rc = sqliterkValuesAutoGrow(values);\n    if (rc != SQLITERK_OK) {\n        return rc;\n    }\n    sqliterk_value *value = &values->values[values->count];\n    value->type = sqliterk_value_type_integer;\n    value->any.integer = i;\n    values->count++;\n    return SQLITERK_OK;\n}\n\nint sqliterkValuesAddInteger(sqliterk_values *values, int i)\n{\n    return sqliterkValuesAddInteger64(values, i);\n}\n\nint sqliterkValuesAddNumber(sqliterk_values *values, double d)\n{\n    if (!values) {\n        return SQLITERK_MISUSE;\n    }\n    int rc = sqliterkValuesAutoGrow(values);\n    if (rc != SQLITERK_OK) {\n        return rc;\n    }\n    sqliterk_value *value = &values->values[values->count];\n    value->type = sqliterk_value_type_number;\n    value->any.number = d;\n    values->count++;\n    return SQLITERK_OK;\n}\n\nint sqliterkValuesAddText(sqliterk_values *values, const char *t)\n{\n    return sqliterkValuesAddNoTerminatorText(values, t, (int) strlen(t));\n}\n\nint sqliterkValuesAddNoTerminatorText(sqliterk_values *values,\n                                      const char *t,\n                                      const int s)\n{\n    if (!values || !t) {\n        return SQLITERK_MISUSE;\n    }\n    int rc = sqliterkValuesAutoGrow(values);\n    if (rc != SQLITERK_OK) {\n        return rc;\n    }\n    sqliterk_value *value = &values->values[values->count];\n    value->type = sqliterk_value_type_text;\n    value->any.text.s = s;\n    value->any.text.t = sqliterkOSMalloc(sizeof(char) * (s + 1));\n    if (!value->any.text.t) {\n        rc = SQLITERK_NOMEM;\n        goto sqliterkValuesAddNoTerminatorText_Failed;\n    }\n    memcpy(value->any.text.t, t, s);\n    value->any.text.t[s] = '\\0';\n    values->count++;\n    return SQLITERK_OK;\n\nsqliterkValuesAddNoTerminatorText_Failed:\n    sqliterkValueClear(value);\n    return rc;\n}\n\nint sqliterkValuesAddBinary(sqliterk_values *values, const void *b, const int s)\n{\n    if (!values || !b) {\n        return SQLITERK_MISUSE;\n    }\n    int rc = sqliterkValuesAutoGrow(values);\n    if (rc != SQLITERK_OK) {\n        return rc;\n    }\n    sqliterk_value *value = &values->values[values->count];\n    value->type = sqliterk_value_type_binary;\n    value->any.binary.s = s;\n    value->any.binary.b = sqliterkOSMalloc(s);\n    if (!value->any.binary.b) {\n        return SQLITERK_NOMEM;\n    }\n    memcpy(value->any.binary.b, b, s);\n    values->count++;\n    return SQLITERK_OK;\n}\n\nint sqliterkValuesAddNull(sqliterk_values *values)\n{\n    if (!values) {\n        return SQLITERK_MISUSE;\n    }\n    int rc = sqliterkValuesAutoGrow(values);\n    if (rc != SQLITERK_OK) {\n        return rc;\n    }\n    sqliterk_value *value = &values->values[values->count];\n    value->type = sqliterk_value_type_null;\n    values->count++;\n    return SQLITERK_OK;\n}\n\nint sqliterkValueClear(sqliterk_value *value)\n{\n    if (!value) {\n        return SQLITERK_MISUSE;\n    }\n\n    switch (value->type) {\n        case sqliterk_value_type_text:\n            if (value->any.text.t) {\n                sqliterkOSFree(value->any.text.t);\n                value->any.text.t = NULL;\n            }\n            break;\n        case sqliterk_value_type_binary:\n            if (value->any.binary.b) {\n                sqliterkOSFree(value->any.binary.b);\n                value->any.binary.b = NULL;\n            }\n            break;\n        default:\n            break;\n    }\n\n    value->type = sqliterk_value_type_null;\n    return SQLITERK_OK;\n}\n"
  },
  {
    "path": "deprecated/android/addons/vfslog/vfslog.c",
    "content": "/*\n** 2013-10-09\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n******************************************************************************\n**\n** This file contains the implementation of an SQLite vfs wrapper for\n** unix that generates per-database log files of all disk activity.\n*/\n\n/*\n** This module contains code for a wrapper VFS that causes a log of\n** most VFS calls to be written into a file on disk.\n**\n** Each database connection creates a separate log file in the same\n** directory as the original database and named after the original\n** database.  A unique suffix is added to avoid name collisions.\n** Separate log files are used so that concurrent processes do not\n** try to write log operations to the same file at the same instant,\n** resulting in overwritten or comingled log text.\n**\n** Each individual log file records operations by a single database\n** connection on both the original database and its associated rollback\n** journal.\n**\n** The log files are in the comma-separated-value (CSV) format.  The\n** log files can be imported into an SQLite database using the \".import\"\n** command of the SQLite command-line shell for analysis.\n**\n** One technique for using this module is to append the text of this\n** module to the end of a standard \"sqlite3.c\" amalgamation file then\n** add the following compile-time options:\n**\n**     -DSQLITE_EXTRA_INIT=sqlite3_register_vfslog\n**     -DSQLITE_USE_FCNTL_TRACE\n**\n** The first compile-time option causes the sqlite3_register_vfslog()\n** function, defined below, to be invoked when SQLite is initialized.\n** That causes this custom VFS to become the default VFS for all\n** subsequent connections.  The SQLITE_USE_FCNTL_TRACE option causes\n** the SQLite core to issue extra sqlite3_file_control() operations\n** with SQLITE_FCNTL_TRACE to give some indication of what is going\n** on in the core.\n*/\n\n#include \"sqlite3.h\"\n#include <assert.h>\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#if SQLITE_OS_UNIX\n#include <unistd.h>\n#endif\n\n#include \"vfslog.h\"\n#include <zlib.h>\n\n/*\n** Log is flushed to gzip stream on 64kB boundary.\n*/\n#define VFSLOG_GZIP_BLOCK_SIZE 65536\n\nstatic const char *const VLOG_OPNAME[] = {\n    \"CLOSE\",\n    \"READ\",\n    \"CHNGCTR_READ\",\n    \"WRITE\",\n    \"CHNGCTR_WRITE\",\n    \"TRUNCATE\",\n    \"SYNC\",\n    \"FILESIZE\",\n    \"LOCK\",\n    \"UNLOCK\",\n    \"CHECKRESERVEDLOCK\",\n    \"FILECONTROL\",\n    \"SECTORSIZE\",\n    \"DEVCHAR\",\n    \"SHMMAP\",\n    \"SHMLOCK\",\n    \"SHMUNMAP\",\n    \"FETCH\",\n    \"UNFETCH\",\n\n    \"OPEN\",\n    \"DELETE\",\n    \"ACCESS\",\n};\n\nvolatile uint32_t vlogDefaultLogFlags =\n    1 << VLOG_OP_CLOSE | 1 << VLOG_OP_READ | 1 << VLOG_OP_CHNGCTR_READ |\n    1 << VLOG_OP_WRITE | 1 << VLOG_OP_CHNGCTR_WRITE | 1 << VLOG_OP_TRUNCATE |\n    1 << VLOG_OP_SYNC | 1 << VLOG_OP_FILESIZE | 1 << VLOG_OP_OPEN |\n    1 << VLOG_OP_DELETE;\n\n/*\n** Forward declaration of objects used by this utility\n*/\ntypedef struct VLogLog VLogLog;\ntypedef struct VLogVfs VLogVfs;\ntypedef struct VLogFile VLogFile;\n\n/* There is a pair (an array of size 2) of the following objects for\n** each database file being logged.  The first contains the filename\n** and is used to log I/O with the main database.  The second has\n** a NULL filename and is used to log I/O for the journal.  Both\n** out pointers are the same.\n*/\nstruct VLogLog {\n    VLogLog *pNext;   /* Next in a list of all active logs */\n    VLogLog **ppPrev; /* Pointer to this in the list */\n    int nRef;         /* Number of references to this object */\n    int nFilename;    /* Length of zFilename in bytes */\n    char *zFilename;  /* Name of database file.  NULL for journal */\n    uint32_t flags;\n    int64_t lastReadOfs;\n    int64_t lastWriteOfs;\n\n    FILE *tmpOut;\n    gzFile gzOut;           /* Write gzip-ed logs here */\n    sqlite3_mutex *gzMutex; /* Mutex to protect file handle above */\n};\n\nstruct VLogVfs {\n    sqlite3_vfs base;  /* VFS methods */\n    sqlite3_vfs *pVfs; /* Parent VFS */\n};\n\nstruct VLogFile {\n    sqlite3_file base;   /* IO methods */\n    sqlite3_file *pReal; /* Underlying file handle */\n    VLogLog *pLog;       /* The log file for this file */\n};\n\n#define REALVFS(p) (((VLogVfs *) (p))->pVfs)\n\n/*\n** Methods for VLogFile\n*/\nstatic int vlogClose(sqlite3_file *);\nstatic int vlogRead(sqlite3_file *, void *, int iAmt, sqlite3_int64 iOfst);\nstatic int\nvlogWrite(sqlite3_file *, const void *, int iAmt, sqlite3_int64 iOfst);\nstatic int vlogTruncate(sqlite3_file *, sqlite3_int64 size);\nstatic int vlogSync(sqlite3_file *, int flags);\nstatic int vlogFileSize(sqlite3_file *, sqlite3_int64 *pSize);\nstatic int vlogLock(sqlite3_file *, int);\nstatic int vlogUnlock(sqlite3_file *, int);\nstatic int vlogCheckReservedLock(sqlite3_file *, int *pResOut);\nstatic int vlogFileControl(sqlite3_file *, int op, void *pArg);\nstatic int vlogSectorSize(sqlite3_file *);\nstatic int vlogDeviceCharacteristics(sqlite3_file *);\nstatic int vlogShmMap(sqlite3_file *, int, int, int, void volatile **);\nstatic int vlogShmLock(sqlite3_file *, int, int, int);\nstatic void vlogShmBarrier(sqlite3_file *);\nstatic int vlogShmUnmap(sqlite3_file *, int);\nstatic int vlogFetch(sqlite3_file *, sqlite3_int64, int, void **);\nstatic int vlogUnfetch(sqlite3_file *, sqlite3_int64, void *);\n\n/*\n** Methods for VLogVfs\n*/\nstatic int vlogOpen(sqlite3_vfs *, const char *, sqlite3_file *, int, int *);\nstatic int vlogDelete(sqlite3_vfs *, const char *zName, int syncDir);\nstatic int vlogAccess(sqlite3_vfs *, const char *zName, int flags, int *);\nstatic int vlogFullPathname(sqlite3_vfs *, const char *zName, int, char *zOut);\nstatic void *vlogDlOpen(sqlite3_vfs *, const char *zFilename);\nstatic void vlogDlError(sqlite3_vfs *, int nByte, char *zErrMsg);\nstatic void (*vlogDlSym(sqlite3_vfs *pVfs, void *p, const char *zSym))(void);\nstatic void vlogDlClose(sqlite3_vfs *, void *);\nstatic int vlogRandomness(sqlite3_vfs *, int nByte, char *zOut);\nstatic int vlogSleep(sqlite3_vfs *, int microseconds);\nstatic int vlogCurrentTime(sqlite3_vfs *, double *);\nstatic int vlogGetLastError(sqlite3_vfs *, int, char *);\nstatic int vlogCurrentTimeInt64(sqlite3_vfs *, sqlite3_int64 *);\nstatic int vlogSetSystemCall(sqlite3_vfs *, const char *, sqlite3_syscall_ptr);\nstatic sqlite3_syscall_ptr vlogGetSystemCall(sqlite3_vfs *, const char *);\nstatic const char *vlogNextSystemCall(sqlite3_vfs *, const char *);\n\nstatic VLogVfs vlog_vfs = {{\n                               3,        /* iVersion (set by register_vlog()) */\n                               0,        /* szOsFile (set by register_vlog()) */\n                               1024,     /* mxPathname */\n                               0,        /* pNext */\n                               \"vfslog\", /* zName */\n                               0,        /* pAppData */\n                               vlogOpen, /* xOpen */\n                               vlogDelete,           /* xDelete */\n                               vlogAccess,           /* xAccess */\n                               vlogFullPathname,     /* xFullPathname */\n                               vlogDlOpen,           /* xDlOpen */\n                               vlogDlError,          /* xDlError */\n                               vlogDlSym,            /* xDlSym */\n                               vlogDlClose,          /* xDlClose */\n                               vlogRandomness,       /* xRandomness */\n                               vlogSleep,            /* xSleep */\n                               vlogCurrentTime,      /* xCurrentTime */\n                               vlogGetLastError,     /* xGetLastError */\n                               vlogCurrentTimeInt64, /* xCurrentTimeInt64 */\n                               vlogSetSystemCall,    /* xSetSystemCall */\n                               vlogGetSystemCall,    /* xGetSystemCall */\n                               vlogNextSystemCall,   /* xNextSystemCall */\n                           },\n                           0};\n\nstatic sqlite3_io_methods vlog_io_methods = {\n    3,                         /* iVersion */\n    vlogClose,                 /* xClose */\n    vlogRead,                  /* xRead */\n    vlogWrite,                 /* xWrite */\n    vlogTruncate,              /* xTruncate */\n    vlogSync,                  /* xSync */\n    vlogFileSize,              /* xFileSize */\n    vlogLock,                  /* xLock */\n    vlogUnlock,                /* xUnlock */\n    vlogCheckReservedLock,     /* xCheckReservedLock */\n    vlogFileControl,           /* xFileControl */\n    vlogSectorSize,            /* xSectorSize */\n    vlogDeviceCharacteristics, /* xDeviceCharacteristics */\n    vlogShmMap,                /* xShmMap */\n    vlogShmLock,               /* xShmLock */\n    vlogShmBarrier,            /* xShmBarrier */\n    vlogShmUnmap,              /* xShmUnmap */\n    vlogFetch,                 /* xFetch */\n    vlogUnfetch,               /* xUnfetch */\n};\n\n#if SQLITE_OS_UNIX && !defined(NO_GETTOD)\n#include <sys/time.h>\nstatic sqlite3_uint64 vlog_time()\n{\n    struct timeval sTime;\n    gettimeofday(&sTime, 0);\n    return sTime.tv_usec + (sqlite3_uint64) sTime.tv_sec * 1000000;\n}\n#elif SQLITE_OS_WIN\n#include <time.h>\n#include <windows.h>\nstatic sqlite3_uint64 vlog_time()\n{\n    FILETIME ft;\n    sqlite3_uint64 u64time = 0;\n\n    GetSystemTimeAsFileTime(&ft);\n\n    u64time |= ft.dwHighDateTime;\n    u64time <<= 32;\n    u64time |= ft.dwLowDateTime;\n\n    /* ft is 100-nanosecond intervals, we want microseconds */\n    return u64time / (sqlite3_uint64) 10;\n}\n#else\nstatic sqlite3_uint64 vlog_time()\n{\n    return 0;\n}\n#endif\n\n/*\n** Write a message to the log file\n*/\nstatic void vlogLogPrint(VLogLog *pLog,         /* The log file to write into */\n                         sqlite3_int64 tStart,  /* Start time of system call */\n                         sqlite3_int64 tElapse, /* Elapse time of system call */\n                         VLogOp iOp,            /* Type of system call */\n                         sqlite3_int64 iArg1,   /* First argument */\n                         sqlite3_int64 iArg2,   /* Second argument */\n                         const char *zArg3,     /* Third argument */\n                         int iRes               /* Result */\n                         )\n{\n    if (!pLog || (pLog->flags & (1 << iOp)) == 0)\n        return;\n\n    char z1[40], z2[40], z3[1024];\n    if (iArg1 >= 0) {\n        sqlite3_snprintf(sizeof(z1), z1, \"%lld\", iArg1);\n    } else {\n        z1[0] = 0;\n    }\n    if (iArg2 >= 0) {\n        sqlite3_snprintf(sizeof(z2), z2, \"%lld\", iArg2);\n    } else {\n        z2[0] = 0;\n    }\n    if (zArg3) {\n        sqlite3_snprintf(sizeof(z3), z3, \"\\\"%.*w\\\"\", sizeof(z3) - 4, zArg3);\n    } else {\n        z3[0] = 0;\n    }\n\n    char buf[2048];\n    int len = snprintf(buf, sizeof(buf), \"%lld,%lld,%s,%d,%s,%s,%s,%d\\n\",\n                       tStart, tElapse, VLOG_OPNAME[iOp], pLog->zFilename == 0,\n                       z1, z2, z3, iRes);\n\n    sqlite3_mutex_enter(pLog->gzMutex);\n    fwrite(buf, 1, len, pLog->tmpOut);\n    fflush(pLog->tmpOut);\n    gzwrite(pLog->gzOut, buf, len);\n    if (ftell(pLog->tmpOut) >= VFSLOG_GZIP_BLOCK_SIZE) {\n        gzflush(pLog->gzOut, Z_FINISH);\n        fseek(pLog->tmpOut, 0, SEEK_SET);\n        ftruncate(fileno(pLog->tmpOut), 0);\n    }\n    sqlite3_mutex_leave(pLog->gzMutex);\n}\n\n/*\n** List of all active log connections.  Protected by the master mutex.\n*/\nstatic VLogLog *allLogs = 0;\n\n/*\n** Close a VLogLog object\n*/\nstatic void vlogLogClose(VLogLog *p)\n{\n    if (p) {\n        sqlite3_mutex *pMutex;\n        p->nRef--;\n        if (p->nRef > 0 || p->zFilename == 0)\n            return;\n        pMutex = sqlite3_mutex_alloc(SQLITE_MUTEX_STATIC_MASTER);\n        sqlite3_mutex_enter(pMutex);\n        *p->ppPrev = p->pNext;\n        if (p->pNext)\n            p->pNext->ppPrev = p->ppPrev;\n        sqlite3_mutex_leave(pMutex);\n\n        fclose(p->tmpOut);\n        gzclose(p->gzOut);\n        sqlite3_mutex_free(p->gzMutex);\n        sqlite3_free(p);\n    }\n}\n\n/*\n** Open a VLogLog object on the given file\n*/\nstatic VLogLog *vlogLogOpen(const char *zFilename)\n{\n    int nName = (int) strlen(zFilename);\n    int fileType = 0;\n    sqlite3_mutex *pMutex;\n    VLogLog *pLog, *pTemp;\n    if (nName > 4 && strcmp(zFilename + nName - 4, \"-wal\") == 0) {\n        nName -= 4;\n        fileType = 1; /* wal */\n    }\n\n    if (nName > 8 && strcmp(zFilename + nName - 8, \"-journal\") == 0) {\n        nName -= 8;\n        fileType = 1; /* journal */\n    } else if (nName > 12 &&\n               sqlite3_strglob(\"-mj??????9??\", zFilename + nName - 12) == 0) {\n        return 0; /* Do not log master journal files */\n    }\n\n    pTemp = sqlite3_malloc(sizeof(*pLog) * 2 + nName + 60);\n    if (pTemp == 0)\n        return 0;\n    pMutex = sqlite3_mutex_alloc(SQLITE_MUTEX_STATIC_MASTER);\n    sqlite3_mutex_enter(pMutex);\n    for (pLog = allLogs; pLog; pLog = pLog->pNext) {\n        if (pLog->nFilename == nName &&\n            !memcmp(pLog->zFilename, zFilename, nName)) {\n            break;\n        }\n    }\n\n    if (pLog == 0) {\n        pLog = pTemp;\n        pTemp = 0;\n        memset(pLog, 0, sizeof(*pLog) * 2);\n        pLog->zFilename = (char *) &pLog[2];\n        sqlite3_snprintf(nName + 60, pLog->zFilename, \"%.*s-vfslog\", nName,\n                         zFilename);\n\n        char *tmpName = alloca(nName + 60);\n        sqlite3_snprintf(nName + 60, tmpName, \"%.*s-vfslo1\", nName, zFilename);\n\n        pLog->tmpOut = fopen(tmpName, \"ab+\");\n        pLog->gzOut = gzopen(pLog->zFilename, \"ab\");\n        pLog->gzMutex = sqlite3_mutex_alloc(SQLITE_MUTEX_FAST);\n        if (!pLog->tmpOut || !pLog->gzOut || !pLog->gzMutex) {\n            if (pLog->tmpOut)\n                fclose(pLog->tmpOut);\n            if (pLog->gzOut)\n                gzclose(pLog->gzOut);\n            if (pLog->gzMutex)\n                sqlite3_mutex_free(pLog->gzMutex);\n\n            sqlite3_mutex_leave(pMutex);\n            sqlite3_free(pLog);\n            return 0;\n        }\n\n        /* Flush existing content in tmpOut to gzOut */\n        if (fseek(pLog->tmpOut, 0, SEEK_END) > 0) {\n            fseek(pLog->tmpOut, 0, SEEK_SET);\n            char buf[1024];\n            int ret;\n            while ((ret = fread(buf, 1, sizeof(buf), pLog->tmpOut)) >= 0) {\n                gzwrite(pLog->gzOut, buf, ret);\n            }\n            fseek(pLog->tmpOut, 0, SEEK_END);\n        }\n\n        pLog->nFilename = nName;\n        pLog->flags = vlogDefaultLogFlags;\n        pLog[1].tmpOut = pLog[0].tmpOut;\n        pLog[1].gzOut = pLog[0].gzOut;\n        pLog[1].gzMutex = pLog[0].gzMutex;\n        pLog->ppPrev = &allLogs;\n        if (allLogs)\n            allLogs->ppPrev = &pLog->pNext;\n        pLog->pNext = allLogs;\n        allLogs = pLog;\n    }\n    sqlite3_mutex_leave(pMutex);\n    if (pTemp) {\n        sqlite3_free(pTemp);\n    }\n    if (pLog)\n        pLog += fileType;\n    pLog->nRef++;\n\n    pLog->lastReadOfs = -1;\n    pLog->lastWriteOfs = -1;\n    return pLog;\n}\n\n/*\n** Close an vlog-file.\n*/\nstatic int vlogClose(sqlite3_file *pFile)\n{\n    sqlite3_uint64 tStart, tElapse;\n    int rc = SQLITE_OK;\n    VLogFile *p = (VLogFile *) pFile;\n\n    tStart = vlog_time();\n    if (p->pReal->pMethods) {\n        rc = p->pReal->pMethods->xClose(p->pReal);\n    }\n    tElapse = vlog_time() - tStart;\n    vlogLogPrint(p->pLog, tStart, tElapse, VLOG_OP_CLOSE, -1, -1, 0, rc);\n    vlogLogClose(p->pLog);\n    return rc;\n}\n\n/*\n** Compute signature for a block of content.\n**\n** For blocks of 16 or fewer bytes, the signature is just a hex dump of\n** the entire block.\n**\n** For blocks of more than 16 bytes, the signature is a hex dump of the\n** first 8 bytes followed by a 64-bit has of the entire block.\n*/\nstatic void vlogSignature(unsigned char *p, int n, char *zCksum)\n{\n    unsigned int s0 = 0, s1 = 0;\n    unsigned int *pI;\n    int i;\n    if (n <= 16) {\n        for (i = 0; i < n; i++)\n            sqlite3_snprintf(3, zCksum + i * 2, \"%02x\", p[i]);\n    } else {\n        pI = (unsigned int *) p;\n        for (i = 0; i < n - 7; i += 8) {\n            s0 += pI[0] + s1;\n            s1 += pI[1] + s0;\n            pI += 2;\n        }\n        for (i = 0; i < 8; i++)\n            sqlite3_snprintf(3, zCksum + i * 2, \"%02x\", p[i]);\n        sqlite3_snprintf(18, zCksum + i * 2, \"-%08x%08x\", s0, s1);\n    }\n}\n\n/*\n** Convert a big-endian 32-bit integer into a native integer\n*/\nstatic int bigToNative(const unsigned char *x)\n{\n    return (x[0] << 24) + (x[1] << 16) + (x[2] << 8) + x[3];\n}\n\n/*\n** Read data from an vlog-file.\n*/\nstatic int\nvlogRead(sqlite3_file *pFile, void *zBuf, int iAmt, sqlite_int64 iOfst)\n{\n    int rc;\n    sqlite3_uint64 tStart, tElapse;\n    VLogFile *p = (VLogFile *) pFile;\n\n    tStart = vlog_time();\n    rc = p->pReal->pMethods->xRead(p->pReal, zBuf, iAmt, iOfst);\n    tElapse = vlog_time() - tStart;\n\n    if (rc == SQLITE_OK && p->pLog && p->pLog->zFilename && iOfst <= 24 &&\n        iOfst + iAmt >= 28) {\n\n        unsigned char *x = ((unsigned char *) zBuf) + (24 - iOfst);\n        unsigned iCtr, nFree = -1;\n        char *zFree = 0;\n        char zStr[12];\n        iCtr = bigToNative(x);\n        if (iOfst + iAmt >= 40) {\n            zFree = zStr;\n            sqlite3_snprintf(sizeof(zStr), zStr, \"%d\", bigToNative(x + 8));\n            nFree = bigToNative(x + 12);\n        }\n\n        /* XXX: Values are meaningful only for plain-text databases */\n        vlogLogPrint(p->pLog, tStart, tElapse, VLOG_OP_CHNGCTR_READ, iCtr,\n                     nFree, zFree, 0);\n    } else {\n        char zSig[40];\n        if (rc == SQLITE_OK) {\n            vlogSignature(zBuf, iAmt, zSig);\n        } else {\n            zSig[0] = 0;\n        }\n\n        /* Record last read position */\n        sqlite3_mutex_enter(p->pLog->gzMutex);\n        p->pLog->lastReadOfs = iOfst;\n        sqlite3_mutex_leave(p->pLog->gzMutex);\n\n        vlogLogPrint(p->pLog, tStart, tElapse, VLOG_OP_READ, iAmt, iOfst, zSig,\n                     rc);\n    }\n    return rc;\n}\n\n/*\n** Write data to an vlog-file.\n*/\nstatic int\nvlogWrite(sqlite3_file *pFile, const void *z, int iAmt, sqlite_int64 iOfst)\n{\n    int rc;\n    sqlite3_uint64 tStart, tElapse;\n    VLogFile *p = (VLogFile *) pFile;\n\n    tStart = vlog_time();\n    rc = p->pReal->pMethods->xWrite(p->pReal, z, iAmt, iOfst);\n    tElapse = vlog_time() - tStart;\n\n    if (rc == SQLITE_OK && p->pLog && p->pLog->zFilename && iOfst <= 24 &&\n        iOfst + iAmt >= 28) {\n        unsigned char *x = ((unsigned char *) z) + (24 - iOfst);\n        unsigned iCtr, nFree = -1;\n        char *zFree = 0;\n        char zStr[12];\n        iCtr = bigToNative(x);\n        if (iOfst + iAmt >= 40) {\n            zFree = zStr;\n            sqlite3_snprintf(sizeof(zStr), zStr, \"%d\", bigToNative(x + 8));\n            nFree = bigToNative(x + 12);\n        }\n\n        /* XXX: Values are meaningful only for plain-text databases */\n        vlogLogPrint(p->pLog, tStart, 0, VLOG_OP_CHNGCTR_WRITE, iCtr, nFree,\n                     zFree, 0);\n    } else {\n        char zSig[40];\n        vlogSignature((unsigned char *) z, iAmt, zSig);\n\n        /* Record last write position */\n        sqlite3_mutex_enter(p->pLog->gzMutex);\n        p->pLog->lastWriteOfs = iOfst;\n        sqlite3_mutex_leave(p->pLog->gzMutex);\n\n        vlogLogPrint(p->pLog, tStart, tElapse, VLOG_OP_WRITE, iAmt, iOfst, zSig,\n                     rc);\n    }\n    return rc;\n}\n\n/*\n** Truncate an vlog-file.\n*/\nstatic int vlogTruncate(sqlite3_file *pFile, sqlite_int64 size)\n{\n    int rc;\n    sqlite3_uint64 tStart, tElapse;\n    VLogFile *p = (VLogFile *) pFile;\n    tStart = vlog_time();\n    rc = p->pReal->pMethods->xTruncate(p->pReal, size);\n    tElapse = vlog_time() - tStart;\n    vlogLogPrint(p->pLog, tStart, tElapse, VLOG_OP_TRUNCATE, size, -1, 0, rc);\n    return rc;\n}\n\n/*\n** Sync an vlog-file.\n*/\nstatic int vlogSync(sqlite3_file *pFile, int flags)\n{\n    int rc;\n    sqlite3_uint64 tStart, tElapse;\n    VLogFile *p = (VLogFile *) pFile;\n    tStart = vlog_time();\n    rc = p->pReal->pMethods->xSync(p->pReal, flags);\n    tElapse = vlog_time() - tStart;\n    vlogLogPrint(p->pLog, tStart, tElapse, VLOG_OP_SYNC, flags, -1, 0, rc);\n    return rc;\n}\n\n/*\n** Return the current file-size of an vlog-file.\n*/\nstatic int vlogFileSize(sqlite3_file *pFile, sqlite_int64 *pSize)\n{\n    int rc;\n    sqlite3_uint64 tStart, tElapse;\n    VLogFile *p = (VLogFile *) pFile;\n    tStart = vlog_time();\n    rc = p->pReal->pMethods->xFileSize(p->pReal, pSize);\n    tElapse = vlog_time() - tStart;\n    vlogLogPrint(p->pLog, tStart, tElapse, VLOG_OP_FILESIZE, *pSize, -1, 0, rc);\n    return rc;\n}\n\n/*\n** Lock an vlog-file.\n*/\nstatic int vlogLock(sqlite3_file *pFile, int eLock)\n{\n    int rc;\n    sqlite3_uint64 tStart, tElapse;\n    VLogFile *p = (VLogFile *) pFile;\n    tStart = vlog_time();\n    rc = p->pReal->pMethods->xLock(p->pReal, eLock);\n    tElapse = vlog_time() - tStart;\n    vlogLogPrint(p->pLog, tStart, tElapse, VLOG_OP_LOCK, eLock, -1, 0, rc);\n    return rc;\n}\n\n/*\n** Unlock an vlog-file.\n*/\nstatic int vlogUnlock(sqlite3_file *pFile, int eLock)\n{\n    int rc;\n    sqlite3_uint64 tStart;\n    VLogFile *p = (VLogFile *) pFile;\n    tStart = vlog_time();\n    vlogLogPrint(p->pLog, tStart, 0, VLOG_OP_UNLOCK, eLock, -1, 0, 0);\n    rc = p->pReal->pMethods->xUnlock(p->pReal, eLock);\n    return rc;\n}\n\n/*\n** Check if another file-handle holds a RESERVED lock on an vlog-file.\n*/\nstatic int vlogCheckReservedLock(sqlite3_file *pFile, int *pResOut)\n{\n    int rc;\n    sqlite3_uint64 tStart, tElapse;\n    VLogFile *p = (VLogFile *) pFile;\n    tStart = vlog_time();\n    rc = p->pReal->pMethods->xCheckReservedLock(p->pReal, pResOut);\n    tElapse = vlog_time() - tStart;\n    vlogLogPrint(p->pLog, tStart, tElapse, VLOG_OP_CHECKRESERVEDLOCK, *pResOut,\n                 -1, \"\", rc);\n    return rc;\n}\n\nstatic int vlogFcntlStats(VLogFile *p, VLogStat *stats)\n{\n    VLogLog *pLog = p->pLog;\n\n    /* Ensure we are operating on the main DB file. */\n    if (p->pLog->nFilename == 0)\n        return SQLITE_ERROR;\n\n    sqlite3_mutex_enter(pLog->gzMutex);\n    stats->lastMainReadOffset = pLog->lastReadOfs;\n    stats->lastMainWriteOffset = pLog->lastWriteOfs;\n\n    /* Move to the journal file. */\n    pLog++;\n    stats->lastJournalReadOffset = pLog->lastReadOfs;\n    stats->lastJournalWriteOffset = pLog->lastWriteOfs;\n    sqlite3_mutex_leave(pLog->gzMutex);\n\n    return SQLITE_OK;\n}\n\n/*\n** File control method. For custom operations on an vlog-file.\n*/\nstatic int vlogFileControl(sqlite3_file *pFile, int op, void *pArg)\n{\n    VLogFile *p = (VLogFile *) pFile;\n    if (op == SQLITE_FCNTL_VFSLOG_STAT) {\n        return vlogFcntlStats(p, (VLogStat *) pArg);\n    }\n\n    sqlite3_uint64 tStart, tElapse;\n    int rc;\n    tStart = vlog_time();\n    rc = p->pReal->pMethods->xFileControl(p->pReal, op, pArg);\n    if (op == SQLITE_FCNTL_VFSNAME && rc == SQLITE_OK) {\n        *(char **) pArg = sqlite3_mprintf(\"vlog/%z\", *(char **) pArg);\n    }\n    tElapse = vlog_time() - tStart;\n    if (op == SQLITE_FCNTL_TRACE) {\n        vlogLogPrint(p->pLog, tStart, tElapse, VLOG_OP_FILECONTROL, op, -1,\n                     pArg, rc);\n    } else if (op == SQLITE_FCNTL_PRAGMA) {\n        const char **azArg = (const char **) pArg;\n        vlogLogPrint(p->pLog, tStart, tElapse, VLOG_OP_FILECONTROL, op, -1,\n                     azArg[1], rc);\n    } else if (op == SQLITE_FCNTL_SIZE_HINT) {\n        sqlite3_int64 sz = *(sqlite3_int64 *) pArg;\n        vlogLogPrint(p->pLog, tStart, tElapse, VLOG_OP_FILECONTROL, op, sz, 0,\n                     rc);\n    } else {\n        vlogLogPrint(p->pLog, tStart, tElapse, VLOG_OP_FILECONTROL, op, -1, 0,\n                     rc);\n    }\n    return rc;\n}\n\n/*\n** Return the sector-size in bytes for an vlog-file.\n*/\nstatic int vlogSectorSize(sqlite3_file *pFile)\n{\n    int rc;\n    sqlite3_uint64 tStart, tElapse;\n    VLogFile *p = (VLogFile *) pFile;\n    tStart = vlog_time();\n    rc = p->pReal->pMethods->xSectorSize(p->pReal);\n    tElapse = vlog_time() - tStart;\n    vlogLogPrint(p->pLog, tStart, tElapse, VLOG_OP_SECTORSIZE, -1, -1, 0, rc);\n    return rc;\n}\n\n/*\n** Return the device characteristic flags supported by an vlog-file.\n*/\nstatic int vlogDeviceCharacteristics(sqlite3_file *pFile)\n{\n    int rc;\n    sqlite3_uint64 tStart, tElapse;\n    VLogFile *p = (VLogFile *) pFile;\n    tStart = vlog_time();\n    rc = p->pReal->pMethods->xDeviceCharacteristics(p->pReal);\n    tElapse = vlog_time() - tStart;\n    vlogLogPrint(p->pLog, tStart, tElapse, VLOG_OP_DEVCHAR, -1, -1, 0, rc);\n    return rc;\n}\n\nstatic int vlogShmMap(sqlite3_file *pFile,\n                      int iRegion,\n                      int szRegion,\n                      int bExtend,\n                      void volatile **pp)\n{\n    int rc;\n    sqlite3_uint64 tStart, tElapse;\n    VLogFile *p = (VLogFile *) pFile;\n    tStart = vlog_time();\n    rc = p->pReal->pMethods->xShmMap(p->pReal, iRegion, szRegion, bExtend, pp);\n    tElapse = vlog_time() - tStart;\n    vlogLogPrint(p->pLog, tStart, tElapse, VLOG_OP_SHMMAP, iRegion, szRegion, 0,\n                 rc);\n    return rc;\n}\n\nstatic int vlogShmLock(sqlite3_file *pFile, int offset, int n, int flags)\n{\n    int rc;\n    sqlite3_uint64 tStart, tElapse;\n    VLogFile *p = (VLogFile *) pFile;\n    tStart = vlog_time();\n    rc = p->pReal->pMethods->xShmLock(p->pReal, offset, n, flags);\n    tElapse = vlog_time() - tStart;\n\n    const char *op = NULL;\n    switch (flags) {\n        case SQLITE_SHM_LOCK | SQLITE_SHM_SHARED:\n            op = \"LS\";\n            break;\n        case SQLITE_SHM_LOCK | SQLITE_SHM_EXCLUSIVE:\n            op = \"LE\";\n            break;\n        case SQLITE_SHM_UNLOCK | SQLITE_SHM_SHARED:\n            op = \"US\";\n            break;\n        case SQLITE_SHM_UNLOCK | SQLITE_SHM_EXCLUSIVE:\n            op = \"UE\";\n            break;\n    }\n    vlogLogPrint(p->pLog, tStart, tElapse, VLOG_OP_SHMLOCK, offset, n, op, rc);\n    return rc;\n}\n\nstatic void vlogShmBarrier(sqlite3_file *pFile)\n{\n    // Bypass, no logging.\n    VLogFile *p = (VLogFile *) pFile;\n    return p->pReal->pMethods->xShmBarrier(p->pReal);\n}\n\nstatic int vlogShmUnmap(sqlite3_file *pFile, int deleteFlag)\n{\n    int rc;\n    sqlite3_uint64 tStart, tElapse;\n    VLogFile *p = (VLogFile *) pFile;\n    tStart = vlog_time();\n    rc = p->pReal->pMethods->xShmUnmap(p->pReal, deleteFlag);\n    tElapse = vlog_time() - tStart;\n    vlogLogPrint(p->pLog, tStart, tElapse, VLOG_OP_SHMUNMAP, deleteFlag, -1, 0,\n                 rc);\n    return rc;\n}\n\nstatic int\nvlogFetch(sqlite3_file *pFile, sqlite3_int64 iOff, int nAmt, void **pp)\n{\n    int rc;\n    sqlite3_uint64 tStart, tElapse;\n    VLogFile *p = (VLogFile *) pFile;\n    tStart = vlog_time();\n    rc = p->pReal->pMethods->xFetch(p->pReal, iOff, nAmt, pp);\n    tElapse = vlog_time() - tStart;\n    const char *result = pp ? \"OK\" : \"Failed\";\n    vlogLogPrint(p->pLog, tStart, tElapse, VLOG_OP_FETCH, iOff, nAmt, result,\n                 rc);\n    return rc;\n}\n\nstatic int vlogUnfetch(sqlite3_file *pFile, sqlite3_int64 iOff, void *pp)\n{\n    int rc;\n    sqlite3_uint64 tStart, tElapse;\n    VLogFile *p = (VLogFile *) pFile;\n    tStart = vlog_time();\n    rc = p->pReal->pMethods->xUnfetch(p->pReal, iOff, pp);\n    tElapse = vlog_time() - tStart;\n    vlogLogPrint(p->pLog, tStart, tElapse, VLOG_OP_UNFETCH, iOff, -1, 0, rc);\n    return rc;\n}\n\n/*\n** Open an vlog file handle.\n*/\nstatic int vlogOpen(sqlite3_vfs *pVfs,\n                    const char *zName,\n                    sqlite3_file *pFile,\n                    int flags,\n                    int *pOutFlags)\n{\n    int rc;\n    sqlite3_uint64 tStart, tElapse;\n    sqlite3_int64 iArg2;\n    VLogFile *p = (VLogFile *) pFile;\n\n    p->pReal = (sqlite3_file *) &p[1];\n    if ((flags & (SQLITE_OPEN_MAIN_DB | SQLITE_OPEN_MAIN_JOURNAL |\n                  SQLITE_OPEN_WAL)) != 0) {\n        p->pLog = vlogLogOpen(zName);\n    } else {\n        p->pLog = 0;\n    }\n    tStart = vlog_time();\n    rc = REALVFS(pVfs)->xOpen(REALVFS(pVfs), zName, p->pReal, flags, pOutFlags);\n    tElapse = vlog_time() - tStart;\n    iArg2 = pOutFlags ? *pOutFlags : -1;\n    vlogLogPrint(p->pLog, tStart, tElapse, VLOG_OP_OPEN, flags, iArg2, 0, rc);\n    if (rc == SQLITE_OK) {\n        vlog_io_methods.iVersion = p->pReal->pMethods->iVersion;\n        pFile->pMethods = &vlog_io_methods;\n    } else {\n        if (p->pLog)\n            vlogLogClose(p->pLog);\n        p->pLog = 0;\n    }\n    return rc;\n}\n\n/*\n** Delete the file located at zPath. If the dirSync argument is true,\n** ensure the file-system modifications are synced to disk before\n** returning.\n*/\nstatic int vlogDelete(sqlite3_vfs *pVfs, const char *zPath, int dirSync)\n{\n    int rc;\n    sqlite3_uint64 tStart, tElapse;\n    VLogLog *pLog;\n    tStart = vlog_time();\n    rc = REALVFS(pVfs)->xDelete(REALVFS(pVfs), zPath, dirSync);\n    tElapse = vlog_time() - tStart;\n    pLog = vlogLogOpen(zPath);\n    vlogLogPrint(pLog, tStart, tElapse, VLOG_OP_DELETE, dirSync, -1, 0, rc);\n    vlogLogClose(pLog);\n    return rc;\n}\n\n/*\n** Test for access permissions. Return true if the requested permission\n** is available, or false otherwise.\n*/\nstatic int\nvlogAccess(sqlite3_vfs *pVfs, const char *zPath, int flags, int *pResOut)\n{\n    int rc;\n    sqlite3_uint64 tStart, tElapse;\n    VLogLog *pLog;\n    tStart = vlog_time();\n    rc = REALVFS(pVfs)->xAccess(REALVFS(pVfs), zPath, flags, pResOut);\n    tElapse = vlog_time() - tStart;\n    pLog = vlogLogOpen(zPath);\n    vlogLogPrint(pLog, tStart, tElapse, VLOG_OP_ACCESS, flags, *pResOut, 0, rc);\n    vlogLogClose(pLog);\n    return rc;\n}\n\n/*\n** Populate buffer zOut with the full canonical pathname corresponding\n** to the pathname in zPath. zOut is guaranteed to point to a buffer\n** of at least (INST_MAX_PATHNAME+1) bytes.\n*/\nstatic int\nvlogFullPathname(sqlite3_vfs *pVfs, const char *zPath, int nOut, char *zOut)\n{\n    return REALVFS(pVfs)->xFullPathname(REALVFS(pVfs), zPath, nOut, zOut);\n}\n\n/*\n** Open the dynamic library located at zPath and return a handle.\n*/\nstatic void *vlogDlOpen(sqlite3_vfs *pVfs, const char *zPath)\n{\n    return REALVFS(pVfs)->xDlOpen(REALVFS(pVfs), zPath);\n}\n\n/*\n** Populate the buffer zErrMsg (size nByte bytes) with a human readable\n** utf-8 string describing the most recent error encountered associated\n** with dynamic libraries.\n*/\nstatic void vlogDlError(sqlite3_vfs *pVfs, int nByte, char *zErrMsg)\n{\n    REALVFS(pVfs)->xDlError(REALVFS(pVfs), nByte, zErrMsg);\n}\n\n/*\n** Return a pointer to the symbol zSymbol in the dynamic library pHandle.\n*/\nstatic void (*vlogDlSym(sqlite3_vfs *pVfs, void *p, const char *zSym))(void)\n{\n    return REALVFS(pVfs)->xDlSym(REALVFS(pVfs), p, zSym);\n}\n\n/*\n** Close the dynamic library handle pHandle.\n*/\nstatic void vlogDlClose(sqlite3_vfs *pVfs, void *pHandle)\n{\n    REALVFS(pVfs)->xDlClose(REALVFS(pVfs), pHandle);\n}\n\n/*\n** Populate the buffer pointed to by zBufOut with nByte bytes of\n** random data.\n*/\nstatic int vlogRandomness(sqlite3_vfs *pVfs, int nByte, char *zBufOut)\n{\n    return REALVFS(pVfs)->xRandomness(REALVFS(pVfs), nByte, zBufOut);\n}\n\n/*\n** Sleep for nMicro microseconds. Return the number of microseconds\n** actually slept.\n*/\nstatic int vlogSleep(sqlite3_vfs *pVfs, int nMicro)\n{\n    return REALVFS(pVfs)->xSleep(REALVFS(pVfs), nMicro);\n}\n\n/*\n** Return the current time as a Julian Day number in *pTimeOut.\n*/\nstatic int vlogCurrentTime(sqlite3_vfs *pVfs, double *pTimeOut)\n{\n    return REALVFS(pVfs)->xCurrentTime(REALVFS(pVfs), pTimeOut);\n}\n\nstatic int vlogGetLastError(sqlite3_vfs *pVfs, int a, char *b)\n{\n    return REALVFS(pVfs)->xGetLastError(REALVFS(pVfs), a, b);\n}\n\nstatic int vlogCurrentTimeInt64(sqlite3_vfs *pVfs, sqlite3_int64 *p)\n{\n    return REALVFS(pVfs)->xCurrentTimeInt64(REALVFS(pVfs), p);\n}\n\nstatic int vlogSetSystemCall(sqlite3_vfs *pVfs,\n                             const char *zName,\n                             sqlite3_syscall_ptr pSyscall)\n{\n    return REALVFS(pVfs)->xSetSystemCall(pVfs, zName, pSyscall);\n}\n\nstatic sqlite3_syscall_ptr vlogGetSystemCall(sqlite3_vfs *pVfs,\n                                             const char *zName)\n{\n    return REALVFS(pVfs)->xGetSystemCall(pVfs, zName);\n}\n\nstatic const char *vlogNextSystemCall(sqlite3_vfs *pVfs, const char *zName)\n{\n    return REALVFS(pVfs)->xNextSystemCall(pVfs, zName);\n}\n\n/*\n** Register debugvfs as the default VFS for this process.\n*/\nint sqlite3_register_vfslog(const char *zArg)\n{\n    vlog_vfs.pVfs = sqlite3_vfs_find(0);\n\n    vlog_vfs.base.iVersion = vlog_vfs.pVfs->iVersion;\n    vlog_vfs.base.szOsFile = sizeof(VLogFile) + vlog_vfs.pVfs->szOsFile;\n    return sqlite3_vfs_register(&vlog_vfs.base, 0);\n}\n\nint vlogGetStats(sqlite3 *db, const char *dbName, VLogStat *stats)\n{\n    sqlite3_vfs *vfs;\n    int rc = sqlite3_file_control(db, dbName, SQLITE_FCNTL_VFS_POINTER, &vfs);\n    if (rc != SQLITE_OK)\n        return rc;\n    else if (!vfs->zName || strcmp(vfs->zName, \"vfslog\") != 0)\n        return SQLITE_NOTFOUND;\n\n    rc = sqlite3_file_control(db, dbName, SQLITE_FCNTL_VFSLOG_STAT, stats);\n    return rc;\n}\n"
  },
  {
    "path": "deprecated/android/addons/vfslog/vfslog.h",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#ifndef __WCDB_VFSLOG_H__\n#define __WCDB_VFSLOG_H__\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n#include <sqlite3.h>\n#include <stdint.h>\n\n#define SQLITE_FCNTL_VFSLOG_STAT 10001\n\ntypedef enum VLogOp {\n    VLOG_OP_CLOSE = 0,\n    VLOG_OP_READ,\n    VLOG_OP_CHNGCTR_READ,\n    VLOG_OP_WRITE,\n    VLOG_OP_CHNGCTR_WRITE,\n    VLOG_OP_TRUNCATE,\n    VLOG_OP_SYNC,\n    VLOG_OP_FILESIZE,\n    VLOG_OP_LOCK,\n    VLOG_OP_UNLOCK,\n    VLOG_OP_CHECKRESERVEDLOCK,\n    VLOG_OP_FILECONTROL,\n    VLOG_OP_SECTORSIZE,\n    VLOG_OP_DEVCHAR,\n    VLOG_OP_SHMMAP,\n    VLOG_OP_SHMLOCK,\n    VLOG_OP_SHMUNMAP,\n    VLOG_OP_FETCH,\n    VLOG_OP_UNFETCH,\n\n    VLOG_OP_OPEN,\n    VLOG_OP_DELETE,\n    VLOG_OP_ACCESS,\n} VLogOp;\n\nextern volatile uint32_t vlogDefaultLogFlags;\n\ntypedef struct VLogStat {\n    int64_t lastMainReadOffset;\n    int64_t lastMainWriteOffset;\n    int64_t lastJournalReadOffset;\n    int64_t lastJournalWriteOffset;\n} VLogStat;\n\nint vlogGetStats(sqlite3 *db, const char *dbName, VLogStat *stats);\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif"
  },
  {
    "path": "deprecated/android/build.gradle",
    "content": "// Top-level build file where you can add configuration options common to all sub-projects/modules.\n\nbuildscript {\n    repositories {\n        jcenter()\n        google()\n    }\n\n    dependencies {\n        classpath 'com.android.tools.build:gradle:7.2.2'\n        classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.3'\n\n        // NOTE: Do not place your application dependencies here; they belong\n        // in the individual module build.gradle files\n    }\n}\n\ndef myVersion = file('../VERSION').text\nallprojects {\n    group 'com.tencent.wcdb'\n    version myVersion\n\n    repositories {\n        jcenter()\n        google()\n    }\n}\n"
  },
  {
    "path": "deprecated/android/gradle/WeChatArmeabiCompat.gradle",
    "content": "if (!plugins.hasPlugin('com.android.library'))\n    throw new GradleException('This plugin must be applied after \"com.android.library\" plugin')\n\nandroid.libraryVariants.all { variant ->\n    def srcAbi = 'armeabi-v7a'\n    def targetAbi = 'armeabi'\n    \n    def bundleTask = variant.getPackageLibrary() as Zip\n    def makeCompatAbiTask = project.task(\"makeArmeabiCompatFor${variant.name.capitalize()}\")\n    makeCompatAbiTask.doFirst {\n        bundleTask.inputs.files.files.each { fileIn ->\n            def nameIn = fileIn.name\n            def pathIn = fileIn.absolutePath\n            def srcAbiPathSeg = \"${File.separator}${srcAbi}${File.separator}\"\n            if ((!nameIn.endsWith('.so') && !nameIn.endsWith('.a')) || !pathIn.contains(srcAbiPathSeg)) {\n                return\n            }\n\n            def targetAbiPathSeg = \"${File.separator}${targetAbi}${File.separator}\"\n            def targetAbiPathIn = pathIn.replace(srcAbiPathSeg, targetAbiPathSeg)\n            if (new File(targetAbiPathIn).exists()) {\n                System.err.println(\"[!] ${targetAbi} version of file ${nameIn} exists, skip compat copy logic.\")\n            } else {\n                bundleTask.from(fileIn) {\n                    into \"jni/${targetAbi}/\"\n                }\n            }\n        }\n    }\n    makeCompatAbiTask.dependsOn(bundleTask.taskDependencies.getDependencies(bundleTask).toArray())\n    bundleTask.dependsOn makeCompatAbiTask\n}"
  },
  {
    "path": "deprecated/android/gradle/WeChatNativeDepend.gradle",
    "content": "//////////////////////////////////////////////////////////////\n//  使用方法：\n//  1. 将此脚本放到repo根目录/gradle/下。\n//\n//  2. 在主模块和所有依赖模块的build.gradle中增加：\n//    apply from: rootProject.file('gradle/WeChatNativeDepend.gradle')\n//\n//  3. 在依赖模块的build.gradle中指定需要导出的头文件路径，一般只需在defaultConfig中配置：\n//    android {\n//      defaultConfig {\n//        externalNativeBuild {\n//          exportHeaders {\n//              from('path/to/headers/you/want/to/export') {\n//                include '**/*.h'\n//                exclude '**/not-to-expose.h'\n//              }\n//          }\n//        }\n//      }\n//    }\n//\n//  4. buildTypes和productFlavors中的externalNativeBuild也可以指定要导出的头文件路径，规则同上。\n//\n//  5. 编译脚本中增加include路径和ld路径。\n//       Android.mk:\n//         LOCAL_C_INCLUDES := $(EXT_DEP)/include\n//         LOCAL_LDLIBS := -L$(EXT_DEP)/lib/$(TARGET_ARCH_ABI)/ -l依赖so的名称，如为libxx.so，则这里输入xx\n//       CMakeLists.txt:\n//         TARGET_INCLUDE_DIRECTORIES(your-target PRIVATE ${EXT_DEP}/include)\n//         TARGET_LINK_LIBRARIES(your-target PRIVATE ${EXT_DEP}/lib/${ANDROID_ABI}/依赖的so名称\n//////////////////////////////////////////////////////////////\n\n\n//////////////////////////////////////////////////////////////\n//  Constant Declarations\n//////////////////////////////////////////////////////////////\n\nproject.ext.ANDROID_APP_PLUGIN_ID = 'com.android.application'\nproject.ext.ANDROID_LIB_PLUGIN_ID = 'com.android.library'\n\nproject.ext.NATIVE_DEPENDENCY_ROOT_NAME = 'native_deps'\nproject.ext.EXPORTED_NATIVE_ARTIFACTS_DIR_NAME = 'exported_native_artifacts'\nproject.ext.HEADERS_DIR_NAME = 'include'\nproject.ext.PREBUILTS_DIR_NAME = 'lib'\nproject.ext.EXTRACTED_NATIVE_DEPENDENCIES_DIR_NAME = 'extracted_native_dependencies'\nproject.ext.AAR_JNI_DIRENTRY_NAME = 'jni'\nproject.ext.AAR_HEADERS_DIRENTRY_NAME = 'jni/include'\n\nproject.ext.ATTR_ARTIFACT_TYPE = Attribute.of('artifactType', String)\n\n//////////////////////////////////////////////////////////////\n\n\n//////////////////////////////////////////////////////////////\n//  DSL Definitions\n//////////////////////////////////////////////////////////////\n\nclass ExportedHeadersExtension {\n    Set<HeaderFilter> headerFilters = []\n\n    def from(String path) {\n        headerFilters.add(new HeaderFilter(path))\n    }\n\n    def from(String path, Action<HeaderFilter> configAction) {\n        def headerFilter = new HeaderFilter(path)\n        configAction.execute(headerFilter)\n        headerFilters.add(headerFilter)\n    }\n\n    def from(File file) {\n        from(file.absolutePath)\n    }\n\n    def from(File file, Action<HeaderFilter> configAction) {\n        from(file.absolutePath, configAction)\n    }\n}\n\nclass HeaderFilter {\n    String dirPath\n    Set<String> includePatterns = []\n    Set<String> excludePatterns = []\n\n    HeaderFilter(String dirPath) {\n        this.dirPath = dirPath\n    }\n\n    def include(String pattern) {\n        includePatterns.add(pattern)\n    }\n\n    def exclude(String pattern) {\n        excludePatterns.add(pattern)\n    }\n}\n\n//////////////////////////////////////////////////////////////\n\n\n//////////////////////////////////////////////////////////////\n//  Entry Codes\n//////////////////////////////////////////////////////////////\n\nif (project.pluginManager.hasPlugin(ANDROID_APP_PLUGIN_ID)) {\n    handleAndroidApplication()\n} else if (project.pluginManager.hasPlugin(ANDROID_LIB_PLUGIN_ID)) {\n    handleAndroidLibrary()\n} else {\n    throw new GradleException(\"[-] Either ${ANDROID_APP_PLUGIN_ID} or ${ANDROID_LIB_PLUGIN_ID} \"\n            + \"should be applied when use this script.\")\n}\n\n//////////////////////////////////////////////////////////////\n\n\n//////////////////////////////////////////////////////////////\n//  Helper Methods\n//////////////////////////////////////////////////////////////\ndef cleanDirectory(File dir) {\n    if (dir.isDirectory()) {\n        dir.deleteDir()\n        dir.mkdirs()\n    }\n}\n\ndef getGenerateOpsAnchorTask(variant) {\n    final List<String> startTaskNames = gradle.startParameter.taskNames\n    if (startTaskNames.isEmpty()) {\n        return null\n    }\n    final String firstTaskName = startTaskNames.get(0)\n    return firstTaskName.equals('clean') || firstTaskName.endsWith(':clean')\n            ? project.tasks.findByName(firstTaskName)\n            : project.tasks.findByName(\"externalNativeBuild${variant.name.capitalize()}\")\n}\n\ndef handleAndroidApplication() {\n    injectNativeDependenciesPath()\n    injectBuildInfoModule()\n    generateBuildInfoHeader(true)\n    \n    def generateAction = {\n//        extractNativeDependencies(project.android.applicationVariants)\n    }\n\n    project.afterEvaluate {\n        generateBuildInfoModule()\n        generateBuildInfoHeader(false)\n        project.android.applicationVariants.each { variant ->\n            def anchorTask = getGenerateOpsAnchorTask(variant)\n            if (anchorTask != null) {\n                anchorTask.doFirst generateAction\n            } else {\n                project.afterEvaluate generateAction\n            }\n        }\n        extractNativeDependencies(project.android.applicationVariants)\n    }\n}\n\ndef handleAndroidLibrary() {\n    mountExtension()\n    injectNativeDependenciesPath()\n    injectBuildInfoModule()\n    generateBuildInfoHeader(true)\n\n    def libVariants = project.android.libraryVariants\n    project.afterEvaluate {\n        libVariants.each { variant ->\n            exposeNativeArtifacts(variant)\n        }\n    }\n    \n    def generateBeforeAction = {\n        libVariants.each { variant ->\n            def externalNativeBuildTask = project.tasks.findByName(\"externalNativeBuild${variant.name.capitalize()}\")\n            if (externalNativeBuildTask == null) {\n                copyExportedHeaders(variant)\n            }\n//            mountCopyNativePrebuiltsAction(variant)\n        }\n//        extractNativeDependencies(libVariants)\n    }\n\n    project.afterEvaluate {\n        generateBuildInfoModule()\n        generateBuildInfoHeader(false)\n        libVariants.each { variant ->\n            def anchorTask = getGenerateOpsAnchorTask(variant)\n            if (anchorTask != null) {\n                mountCopyNativePrebuiltsAction(variant)\n                anchorTask.doFirst generateBeforeAction\n                anchorTask.doLast {\n                    copyExportedHeaders(variant)\n                }\n            } else {\n                project.afterEvaluate generateBeforeAction\n            }\n        }\n        extractNativeDependencies(libVariants)\n    }\n}\n\ndef mountExtension() {\n    def extensionCreator = new Action<ExtensionAware>() {\n        @Override\n        void execute(ExtensionAware extensionAware) {\n            extensionAware.extensions.create('exportHeaders', ExportedHeadersExtension)\n        }\n    }\n    extensionCreator.execute(project.android.defaultConfig.externalNativeBuildOptions)\n    project.android.buildTypes.all { buildType ->\n        extensionCreator.execute(buildType.externalNativeBuildOptions)\n    }\n    project.android.productFlavors.all { flavor ->\n        extensionCreator.execute(flavor.externalNativeBuildOptions)\n    }\n}\n\ndef getUniformedPath(path) {\n    return (File.separator != '/') ? path.replace(File.separator, '/') : path\n}\n\ndef getNativeDependencyRoot() {\n    return new File(project.buildDir, \"intermediates/${NATIVE_DEPENDENCY_ROOT_NAME}\")\n}\n\ndef getExportedNativeArtifactsDir(targetVariant) {\n    return new File(getNativeDependencyRoot(), \"${EXPORTED_NATIVE_ARTIFACTS_DIR_NAME}/${targetVariant.dirName}\")\n}\n\ndef getExtractedNativeDependenciesDir() {\n    return new File(getNativeDependencyRoot(), EXTRACTED_NATIVE_DEPENDENCIES_DIR_NAME)\n}\n\ndef copyExportedHeaders(targetVariant) {\n    def exportedArtifactsDir = getExportedNativeArtifactsDir(targetVariant)\n    def exportedHeadersDir = new File(exportedArtifactsDir, HEADERS_DIR_NAME)\n    if (!exportedHeadersDir.exists()) {\n        exportedHeadersDir.mkdirs()\n    } else {\n        cleanDirectory(exportedHeadersDir)\n    }\n    def headerFilters = getExportedHeaderFilters(targetVariant)\n    headerFilters.each { filter ->\n        copy {\n            exclude exportedHeadersDir.absolutePath\n            duplicatesStrategy DuplicatesStrategy.FAIL\n            includeEmptyDirs false\n            from(getUniformedPath(filter.dirPath)) {\n                filter.includePatterns.each { pattern -> include pattern }\n                filter.excludePatterns.each { pattern -> exclude pattern }\n            }\n            rename { name ->\n                return name.replace(filter.dirPath, '')\n            }\n            into exportedHeadersDir\n        }\n    }\n}\n\ndef getExportedHeaderFilters(targetVariant) {\n    Set<HeaderFilter> includeFilters = []\n    def exportedFilterFetcher = { ExtensionAware target ->\n        def exportedHeaderExt = target.extensions.findByName('exportHeaders')\n        if(exportedHeaderExt) {\n            return ((ExportedHeadersExtension) exportedHeaderExt).headerFilters\n        }\n    }\n    includeFilters.addAll(exportedFilterFetcher(project.android.defaultConfig.externalNativeBuildOptions))\n    includeFilters.addAll(exportedFilterFetcher(targetVariant.buildType.buildType.externalNativeBuildOptions))\n    targetVariant.productFlavors*.each { flavor ->\n        includeFilters.addAll(exportedFilterFetcher(flavor.productFlavor.externalNativeBuildOptions))\n    }\n    return includeFilters\n}\n\ndef mountCopyNativePrebuiltsAction(targetVariant) {\n    def exportedArtifactsDir = getExportedNativeArtifactsDir(targetVariant)\n    def exportedHeadersDir = new File(exportedArtifactsDir, HEADERS_DIR_NAME)\n    def exportedPrebuiltsDir = new File(exportedArtifactsDir, PREBUILTS_DIR_NAME)\n    if (!exportedPrebuiltsDir.exists()) {\n        exportedPrebuiltsDir.mkdirs()\n    }\n    def bundleTask = targetVariant.getPackageLibrary() as Zip\n    targetVariant.getExternalNativeBuildTasks().each { nativeBuildTask ->\n        nativeBuildTask.doLast {\n            cleanDirectory(exportedPrebuiltsDir)\n            copy {\n                duplicatesStrategy DuplicatesStrategy.FAIL\n                includeEmptyDirs = false\n                from(nativeBuildTask.getObjFolder()) {\n                    include '**/*.so'\n                    include '**/*.a'\n                }\n                into exportedPrebuiltsDir\n            }\n        }\n    }\n    bundleTask.with {\n        from(exportedPrebuiltsDir) {\n            // 'so' file is automatically packaged into the AAR.\n            exclude '**/*.so'\n            into AAR_JNI_DIRENTRY_NAME\n        }\n        from(exportedHeadersDir) {\n            into AAR_HEADERS_DIRENTRY_NAME\n        }\n    }\n}\n\ndef exposeNativeArtifacts(targetVariant) {\n    def apiElements = configurations.findByName(\"${targetVariant.name}ApiElements\")\n    def exposedVariant = apiElements.outgoing.variants.create(EXPORTED_NATIVE_ARTIFACTS_DIR_NAME)\n    def exportedArtifactsDir = getExportedNativeArtifactsDir(targetVariant)\n    exposedVariant.artifact(exportedArtifactsDir) { artifact ->\n        artifact.setType(EXPORTED_NATIVE_ARTIFACTS_DIR_NAME)\n    }\n}\n\ndef injectNativeDependenciesPath() {\n    def extractedNativeDepsDir = getExtractedNativeDependenciesDir()\n\n    def ndkBuildOpt = project.android.defaultConfig.externalNativeBuild.ndkBuild\n    ndkBuildOpt.getArguments().add('EXT_DEP=' + extractedNativeDepsDir.absolutePath)\n\n    def cmakeOpt = project.android.defaultConfig.externalNativeBuild.cmake\n    cmakeOpt.getArguments().add('-DEXT_DEP=' + extractedNativeDepsDir.absolutePath)\n}\n\ndef generateBuildInfoHeader(boolean stubOnly) {\n    def hasBuildRevision = project.hasProperty('WX_BUILD_REVISION')\n    def hasBuildBranch = project.hasProperty('WX_BUILD_BRANCH')\n    def hasBuildTime = project.hasProperty('WX_BUILD_TIME')\n    def hasBuildJob = project.hasProperty('WX_BUILD_JOB')\n    def hasBuildVersion = project.extensions.findByName('wechatPublish') != null\n\n    def extractedNativeDepsDir = getExtractedNativeDependenciesDir()\n    def exportedHeadersDir = new File(extractedNativeDepsDir, HEADERS_DIR_NAME)\n    def buildInfoHeaderDir = new File(exportedHeadersDir, 'build-info')\n    if (!buildInfoHeaderDir.exists()) {\n        buildInfoHeaderDir.mkdirs()\n    }\n    def buildInfoHeaderFile = new File(buildInfoHeaderDir, 'build-info.h')\n    buildInfoHeaderFile.withPrintWriter { pw ->\n        pw.println('#ifndef __MM_AUTOGENARATED_BUILD_INFO_H__')\n        pw.println('#define __MM_AUTOGENARATED_BUILD_INFO_H__')\n        if (!stubOnly && hasBuildVersion) {\n            pw.println(\"#define WX_BUILD_VERSION \\\"${wechatPublish.fullVersion}\\\"\")\n        } else {\n            pw.println(\"#define WX_BUILD_VERSION \\\"\\\"\")\n        }\n        if (!stubOnly && hasBuildRevision) {\n            pw.println(\"#define WX_BUILD_REVISION \\\"${WX_BUILD_REVISION.replace('\\\"', '')}\\\"\")\n        } else {\n            pw.println(\"#define WX_BUILD_REVISION \\\"\\\"\")\n        }\n        if (!stubOnly && hasBuildBranch) {\n            pw.println(\"#define WX_BUILD_BRANCH \\\"${WX_BUILD_BRANCH.replace('\\\"', '')}\\\"\")\n        } else {\n            pw.println(\"#define WX_BUILD_BRANCH \\\"\\\"\")\n        }\n        if (!stubOnly && hasBuildTime) {\n            pw.println(\"#define WX_BUILD_TIME \\\"${WX_BUILD_TIME.replace('\\\"', '')}\\\"\")\n        } else {\n            pw.println(\"#define WX_BUILD_TIME \\\"\\\"\")\n        }\n        if (!stubOnly && hasBuildJob) {\n            pw.println(\"#define WX_BUILD_JOB \\\"${WX_BUILD_JOB.replace('\\\"', '')}\\\"\")\n        } else {\n            pw.println(\"#define WX_BUILD_JOB \\\"\\\"\")\n        }\n        pw.println('#endif //__MM_AUTOGENARATED_BUILD_INFO_H__')\n    }\n}\n\ndef extractNativeDependencies(targetVariants) {\n    def extractedNativeDepsDir = getExtractedNativeDependenciesDir()\n\n    targetVariants.each { targetVariant ->\n        def compileClasspath = configurations.findByName(\"${targetVariant.name}CompileClasspath\")\n\n        def projectNativeDepDirs = compileClasspath.incoming.artifactView { config ->\n            config.attributes.attribute(ATTR_ARTIFACT_TYPE, EXPORTED_NATIVE_ARTIFACTS_DIR_NAME)\n        }.artifacts.artifactFiles.files\n\n        def aarPaths = compileClasspath.incoming.artifactView { config ->\n            config.attributes.attribute(ATTR_ARTIFACT_TYPE, 'aar')\n        }.getArtifacts().artifactFiles.files\n\n        projectNativeDepDirs.each { projDir ->\n            copy {\n                duplicatesStrategy DuplicatesStrategy.FAIL\n                includeEmptyDirs false\n                from new File(projDir, HEADERS_DIR_NAME)\n                into new File(extractedNativeDepsDir, HEADERS_DIR_NAME)\n            }\n        }\n\n        aarPaths.each { aarPath ->\n            copy {\n                duplicatesStrategy DuplicatesStrategy.FAIL\n                includeEmptyDirs false\n                from zipTree(aarPath)\n                into new File(extractedNativeDepsDir, HEADERS_DIR_NAME)\n                eachFile { details ->\n                    if (details.path.endsWith('.h')) {\n                        details.path = details.path - AAR_HEADERS_DIRENTRY_NAME - '/'\n                    } else {\n                        details.exclude()\n                    }\n                }\n            }\n        }\n\n        targetVariant.getExternalNativeBuildTasks().each { nativeBuildTask ->\n\n            nativeBuildTask.doFirst {\n\n                projectNativeDepDirs.each { projDir ->\n                    copy {\n                        duplicatesStrategy DuplicatesStrategy.FAIL\n                        includeEmptyDirs false\n                        from new File(projDir, HEADERS_DIR_NAME)\n                        into new File(extractedNativeDepsDir, HEADERS_DIR_NAME)\n                    }\n                }\n\n                aarPaths.each { aarPath ->\n                    copy {\n                        duplicatesStrategy DuplicatesStrategy.FAIL\n                        includeEmptyDirs false\n                        from zipTree(aarPath)\n                        into new File(extractedNativeDepsDir, HEADERS_DIR_NAME)\n                        eachFile { details ->\n                            if (details.path.endsWith('.h')) {\n                                details.path = details.path - AAR_HEADERS_DIRENTRY_NAME - '/'\n                            } else {\n                                details.exclude()\n                            }\n                        }\n                    }\n                }\n\n                projectNativeDepDirs.each { projDir ->\n                    copy {\n                        duplicatesStrategy DuplicatesStrategy.FAIL\n                        includeEmptyDirs false\n                        from(projDir) {\n                            include \"**/${PREBUILTS_DIR_NAME}/**\"\n                        }\n                        into extractedNativeDepsDir\n                    }\n                }\n\n                aarPaths.each { aarPath ->\n                    copy {\n                        duplicatesStrategy DuplicatesStrategy.FAIL\n                        includeEmptyDirs false\n                        from zipTree(aarPath)\n                        into new File(extractedNativeDepsDir, PREBUILTS_DIR_NAME)\n                        eachFile { details ->\n                            if (details.path.endsWith('.so') || details.path.endsWith('.a')) {\n                                details.path = (details.path - AAR_JNI_DIRENTRY_NAME - '/')\n                            } else {\n                                details.exclude()\n                            }\n                        }\n                    }\n                }\n            }\n        }\n    }\n}\n\ndef injectBuildInfoModule() {\n    def hasBuildRevision = project.hasProperty('WX_BUILD_REVISION')\n    def hasBuildBranch = project.hasProperty('WX_BUILD_BRANCH')\n    def hasBuildTime = project.hasProperty('WX_BUILD_TIME')\n    def hasBuildJob = project.hasProperty('WX_BUILD_JOB')\n\n    if (!hasBuildRevision && !hasBuildBranch && !hasBuildTime && !hasBuildJob) {\n        System.err.println(\"[!] There's no any build-info values, skip injecting build-info module.\")\n        return\n    }\n\n    def nativeModuleDir = new File(project.buildDir, \"generated/native-modules/\")\n    def buildInfoModuleDir = new File(nativeModuleDir, 'build-info')\n\n    def makeFilePath = new File(buildInfoModuleDir, 'Android.mk')\n    def ndkBuildOpts = project.android.defaultConfig.externalNativeBuildOptions.ndkBuild\n    ndkBuildOpts.arguments \"BUILD_SHARED_LIBRARY=${makeFilePath.absolutePath}\"\n\n    def cmakeInitFilePath = new File(buildInfoModuleDir, 'Init.cmake')\n    def cmakeBuildOpts = project.android.defaultConfig.externalNativeBuildOptions.cmake\n    cmakeBuildOpts.arguments \"-DCMAKE_USER_MAKE_RULES_OVERRIDE=${cmakeInitFilePath.absolutePath}\"\n}\n\ndef generateBuildInfoModule() {\n    def hasBuildRevision = project.hasProperty('WX_BUILD_REVISION')\n    def hasBuildBranch = project.hasProperty('WX_BUILD_BRANCH')\n    def hasBuildTime = project.hasProperty('WX_BUILD_TIME')\n    def hasBuildJob = project.hasProperty('WX_BUILD_JOB')\n\n    if (!hasBuildRevision && !hasBuildBranch && !hasBuildTime && !hasBuildJob) {\n        System.err.println(\"[!] There's no any build-info values, skip generating build-info module.\")\n        return\n    }\n\n    def nativeModuleDir = new File(project.buildDir, \"generated/native-modules/\")\n    def buildInfoModuleDir = new File(nativeModuleDir, 'build-info')\n    if (!buildInfoModuleDir.exists()) {\n        buildInfoModuleDir.mkdirs()\n    } else {\n        cleanDirectory(buildInfoModuleDir)\n    }\n\n    def hasBuildVersion = project.extensions.findByName('wechatPublish') != null\n    def assemblyFilePath = new File(buildInfoModuleDir, 'build-info.S')\n    assemblyFilePath.withPrintWriter { pw ->\n        pw.println('.section .comment')\n        pw.println('.global WX_BUILD_INFO')\n        pw.println('WX_BUILD_INFO:')\n        if (hasBuildVersion)\n            pw.println(\".string \\\"WX_BUILD_VERSION: ${wechatPublish.fullVersion}\\\"\")\n        if (hasBuildRevision)\n            pw.println(\".string \\\"WX_BUILD_REVISION: ${WX_BUILD_REVISION.replace('\\\"', '')}\\\"\")\n        if (hasBuildBranch)\n            pw.println(\".string \\\"WX_BUILD_BRANCH: ${WX_BUILD_BRANCH.replace('\\\"', '')}\\\"\")\n        if (hasBuildTime)\n            pw.println(\".string \\\"WX_BUILD_TIME: ${WX_BUILD_TIME.replace('\\\"', '')}\\\"\")\n        if (hasBuildJob)\n            pw.println(\".string \\\"WX_BUILD_JOB: ${WX_BUILD_JOB.replace('\\\"', '')}\\\"\")\n    }\n\n    def makeFilePath = new File(buildInfoModuleDir, 'Android.mk')\n    makeFilePath.withPrintWriter { pw ->\n        pw.println(\"BUILD_INFO_SRC := \")\n        pw.println(\"LOCAL_SRC_FILES += ${assemblyFilePath.absolutePath.replace('\\\\', '/')}\")\n        pw.println('include $(BUILD_SYSTEM)/build-shared-library.mk')\n    }\n\n    def cmakeInitFilePath = new File(buildInfoModuleDir, 'Init.cmake')\n    cmakeInitFilePath.withPrintWriter { pw ->\n        pw.println('if(NOT RUN)')\n        pw.println('  set(RUN 1)')\n        pw.println('  enable_language(ASM)')\n        pw.println('  function(add_library name type)')\n        pw.println('    if(type STREQUAL \"SHARED\")')\n        pw.println(\"      _add_library(\\${ARGV} ${assemblyFilePath.absolutePath.replace('\\\\', '/')})\")\n        pw.println('    else()')\n        pw.println('      _add_library(${ARGV})')\n        pw.println('    endif()')\n        pw.println('  endfunction(add_library)')\n        pw.println('endif()')\n    }\n}\n\n//////////////////////////////////////////////////////////////"
  },
  {
    "path": "deprecated/android/gradle/WeChatPublish.gradle",
    "content": "def extensionClass\n\n// Detect supported plugin modules\nif (plugins.hasPlugin('com.android.library')) {\n    // Android library mode\n    extensionClass = WeChatAndroidLibraryPublishExtension.class\n} else if (plugins.hasPlugin('java')) {\n    // Java library mode\n    extensionClass = WeChatJavaLibraryPublishExtension.class\n} else {\n    // TODO: Support more languages\n    throw new GradleException('This plugin must be applied after \"java\" or \"com.android.library\" plugin')\n}\n\n// Register wechatPublish extension\nextensions.create('wechatPublish', extensionClass, project)\next.artifactId = name\n\nclass WeChatPublishExtension {\n\n    boolean isSnapshot = true\n    private String versionSuffix = ''\n    protected boolean printModules = false\n\n    boolean withJavadoc = true\n    boolean withSources = true\n    boolean withNativeSymbols = true\n    boolean withDependencies = true\n\n    boolean publishToBintray = false /* Deprecated */\n\n    boolean publishAllVariants = false\n    Set<String> publishVariants = []\n\n    boolean publishAllFlavors = true\n    Set<String> publishFlavors = []\n    String defaultFlavor\n\n    boolean checkRemoteArtifactExistence = false\n\n    private final Project project\n    private boolean usedDefaultIsSnapshot = true\n\n    private final ArrayList<Closure> mavenPublishClosures = []\n\n    protected final ArrayList<Closure> pomClosures = []\n\n    WeChatPublishExtension(Project proj) {\n        project = proj\n        fillDefaultConfiguration()\n        proj.afterEvaluate { this.publish() }\n    }\n\n    protected final String uncapitalize(String str) {\n        if (str == null || str.isEmpty()) {\n            return str\n        }\n        return \"\" + Character.toLowerCase(str.charAt(0)) + str.substring(1)\n    }\n\n    protected void publish() {\n        // Load local gradle script\n        applyLocalScript()\n\n        // Verify configuration values\n        verifyPublishConfiguration()\n\n        // Emit Maven DSL\n        // Apply plugins if not done already\n        if (!project.plugins.hasPlugin('maven-publish')) {\n            project.plugins.apply('maven-publish')\n        }\n\n        mountAdditionalLogic(project)\n\n        emitPublicationDSL(project)\n\n        if (project.hasProperty('signingKeyId') || project.hasProperty('signing.keyId')) {\n            if (!project.plugins.hasPlugin('signing')) {\n                project.plugins.apply('signing')\n            }\n            emitSigningConfig(project)\n        }\n\n        emitRepositoryDSL(project)\n    }\n\n    void bintrayPackage(Closure cl) {\n         // if (cl != null)\n         //     bintrayConfigureClosures << cl\n    }\n\n    void publishToMaven(Closure cl) {\n        if (cl != null)\n            mavenPublishClosures << cl\n    }\n\n    void pom(Closure cl) {\n        if (cl != null)\n            pomClosures << cl\n    }\n\n    void publishToBintray(Closure cl) {\n         if (cl != null) {\n             publishToBintray = true\n             // bintrayConfigureClosures << cl\n         }\n    }\n\n    String getFullVersion() {\n        def ver = version + versionSuffix\n        if (isSnapshot && !ver.endsWith('-SNAPSHOT'))\n            ver += '-SNAPSHOT'\n        return ver\n    }\n\n    protected void fillDefaultConfiguration() {\n        isSnapshot = !project.rootProject.hasProperty('release')\n        printModules = project.rootProject.hasProperty('printModules')\n        if (project.rootProject.hasProperty('versionSuffix'))\n            versionSuffix = project.rootProject.versionSuffix\n    }\n\n    private void applyLocalScript() {\n        def localScriptFile\n        if (project.rootProject.hasProperty('repoScript')) {\n            // Repo script file specified using -PrepoScript=xxx argument, use that script.\n            def repoScript = project.rootProject.property('repoScript')\n            if (!repoScript.startsWith('/'))\n                repoScript = \"${System.getProperty('user.dir')}/${repoScript}\"\n            localScriptFile = new File(repoScript)\n        } else {\n            // No -PrepoScript=xxx argument, try 'local.gradle' in projectDir then rootProjectDir\n            localScriptFile = project.file('local.gradle')\n            if (!localScriptFile.file)\n                localScriptFile = project.rootProject.file('local.gradle')\n        }\n\n        if (localScriptFile.file) {\n            project.apply from: localScriptFile\n        }\n    }\n\n    private void verifyPublishConfiguration() {\n        // Warn default artifactId, groupId, version\n        if (groupId.empty) {\n            groupId = 'com.tencent.mm'\n            System.err.println \"groupId not specified, used default value: ${groupId}\"\n        }\n\n        if (version == 'unspecified') {\n            version = '0.1'\n            System.err.println \"version not specified, used default value: ${version}\"\n        }\n        checkVersion()\n\n        if (!usedDefaultIsSnapshot) {\n            System.err.println 'isSnapshot should be avoided in build scripts.'\n        }\n\n        if (isSnapshot) {\n            // Bintray does not allow SNAPSHOT publish\n            publishToBintray = false\n        }\n\n        project.ext.fullVersion = fullVersion\n    }\n\n    private void checkVersion() {\n        if (!(fullVersion ==~ /\\d+\\.\\d+(?:\\.\\d+)?(?:\\.\\d+)?(?:-[\\w-]+)?/)) {\n            def message = \"Invalid version: ${fullVersion}\"\n            if (!isSnapshot)\n                throw new GradleException(message)\n            System.err.println(message)\n        }\n    }\n\n    final protected String getPublicationName() {\n        String result = \"\"\n        artifactId.split(\"[-_]\").each { result += it.capitalize() }\n        return uncapitalize(result)\n    }\n\n    protected void mountAdditionalLogic(project) {}\n\n    protected void emitPublicationDSL(Project project) {}\n\n    private void emitSigningConfig(Project project) {\n        project.ext['signing.keyId'] = project.findProperty(\"signingKeyId\")\n        project.ext['signing.password'] = project.findProperty(\"signingPassword\")\n        project.ext['signing.secretKeyRingFile'] = project.findProperty(\"signingSecretKeyRingFile\")\n        project.signing {\n            project.publishing.publications.all { publication ->\n                sign publication\n            }\n        }\n    }\n\n    private void emitRepositoryDSL(Project project) {\n        mavenPublishClosures.each { cl ->\n            project.publishing.repositories {\n                maven {\n                    cl.delegate = delegate\n                    cl()\n                }\n            }\n        }\n\n        if (publishToBintray) {\n            System.err.println(\"[WeChatPublish] [W] 'publishToBintray' was deprecated and ignored now, consider migrate to MavenCentral instead.\")\n        }\n    }\n\n    protected void validateArtifactNotExists(Project project, String groupId, String artifactId, String version) {\n        if (!checkRemoteArtifactExistence) {\n            return\n        }\n        if (isSnapshot) {\n            System.out.println(\"[WeChatPublish] [I] Snapshot version, skip artifact existance validation.\")\n            return\n        }\n        project.gradle.taskGraph.whenReady {\n            project.publishing.repositories.each { repo ->\n                def conn\n                try {\n                    def repoUrlStr = repo.url.toString()\n                    if (repoUrlStr.startsWith('https://')) {\n                        repoUrlStr = 'http://' + repoUrlStr.substring(8)\n                    }\n                    def url = new URL(\"${repoUrlStr}/${groupId.replace('.', '/')}/${artifactId}/${version}\")\n                    conn = url.openConnection() as HttpURLConnection\n                    conn.setRequestMethod('GET')\n                    conn.connectTimeout = 3000\n                    conn.readTimeout = 5000\n                    try {\n                        def respHttpCode = conn.responseCode\n                        if (respHttpCode == 200 || respHttpCode == 302) {\n                            throw new GradleException(\"Artifact ${groupId}:${artifactId}:${version} has already exist in repo ${repoUrlStr}\")\n                        }\n                    } catch (SocketTimeoutException e) {\n                        System.err.println(\"Timeout when checking if '${groupId}:${artifactId}:${version}' exists in '${repoUrlStr}'.\")\n                    }\n                } finally {\n                    try {\n                        conn.disconnect()\n                    } catch (ignored) {\n                        // Ignored.\n                    }\n                }\n            }\n        }\n    }\n\n    String getArtifactId() {\n        return project.artifactId\n    }\n\n    void setArtifactId(String id) {\n        project.artifactId = id\n    }\n\n    String getGroupId() {\n        return project.group\n    }\n\n    void setGroupId(String id) {\n        project.group = id\n    }\n\n    String getVersion() {\n        return project.version\n    }\n\n    void setVersion(String ver) {\n        project.version = ver\n    }\n\n    void setIsSnapshot(boolean v) {\n        isSnapshot = v\n        usedDefaultIsSnapshot = false\n    }\n}\n\nclass WeChatJavaLibraryPublishExtension extends WeChatPublishExtension {\n\n    WeChatJavaLibraryPublishExtension(Project project) {\n        super(project)\n    }\n\n    @Override\n    protected void mountAdditionalLogic(project) {\n        // Print module description if needed\n        if (printModules) {\n            def anchorTask = project.tasks.findByName('compileJava')\n            def printTask = project.task('printPublishArtifactInfo').doFirst {\n                println \"@@@WeChatPublish@@@ ${artifactId}: ${fullVersion}\"\n            }\n            anchorTask.dependsOn printTask\n        }\n    }\n\n    @Override\n    protected void emitPublicationDSL(Project project) {\n\n        def sourcesJarTask = project.task('sourcesJar', type: Jar) {\n            classifier = 'sources'\n\n            def srcDirs = []\n            def sources = project.sourceSets.main\n            ['java', 'groovy', 'scala', 'kotlin'].each {\n                if (sources.hasProperty(it))\n                    srcDirs << sources[it].srcDirs\n            }\n\n            from srcDirs\n        }\n\n        def javadocTask = (project.tasks.findByName('javadoc') as Javadoc).with {\n            title = null\n            options {\n                memberLevel = JavadocMemberLevel.PUBLIC\n\n                def doclavaJar = project.rootProject.file('gradle/doclava-1.0.6.jar')\n                if (doclavaJar.exists()) {\n                    doclet = 'com.google.doclava.Doclava'\n                    docletpath = [doclavaJar]\n                }\n                //docletpath = project.configurations.doclava.files as List\n            }\n            it\n        }\n        def javadocJarTask = project.task('javadocJar', type: Jar) {\n            dependsOn javadocTask\n            classifier = 'javadoc'\n            from javadocTask.destinationDir\n        }\n        // TODO: upload javadoc to documentation site\n\n        project.publishing.publications {\n            \"${publicationName}\" (MavenPublication) {\n                from project.components.java\n\n                groupId this.groupId\n                artifactId this.artifactId\n                version this.fullVersion\n\n                validateArtifactNotExists(project, groupId, artifactId, version)\n\n                // Emit sourcesJar task\n                if (withSources) {\n                    artifact sourcesJarTask\n                }\n\n                // Emit javadocJar task\n                if (withJavadoc) {\n                    artifact javadocJarTask\n                }\n            }\n        }\n\n        pomClosures.each { cl ->\n            project.publishing.publications {\n                \"${publicationName}\"(MavenPublication) {\n                    pom cl\n                }\n            }\n        }\n    }\n}\n\nclass WeChatAndroidLibraryPublishExtension extends WeChatPublishExtension {\n\n    WeChatAndroidLibraryPublishExtension(Project project) {\n        super(project)\n    }\n\n    @Override\n    protected void mountAdditionalLogic(project) {\n        // Print module description if needed\n        if (printModules) {\n            def anchorTask = project.tasks.findByName('preBuild')\n            def printTask = project.task('printPublishArtifactInfo').doFirst {\n                println \"@@@WeChatPublish@@@ ${artifactId}: ${fullVersion}\"\n            }\n            anchorTask.dependsOn printTask\n        }\n    }\n\n    @Override\n    protected void emitPublicationDSL(Project project) {\n        HashSet<String> emittedFlavors = new HashSet<>()\n        def android = project.android\n        def hasReleaseVariant = false\n\n        android.libraryVariants.all { variant ->\n            def variantName = variant.name\n            def cVariantName = variantName.capitalize()\n\n            def flavorName = variant.flavorName\n            def variantOnlyName = uncapitalize(variantName.substring(flavorName.length(), variantName.length()))\n            def hasFlavor = variant.flavorName != null && !variant.flavorName.isEmpty()\n\n            if (flavorName == defaultFlavor)\n                flavorName = ''\n            def cFlavorName = flavorName.capitalize()\n\n            if (!publishAllFlavors && !flavorName.empty && !publishFlavors.contains(flavorName))\n                return\n\n            def generateSourcesTask = project.tasks.findByName(\"generate${cVariantName}Sources\")\n\n            def javadocTask = project.task(\"javadoc${cVariantName}\", type: Javadoc) {\n                group = 'documentation'\n                title = null\n\n                def classpathFiles = project.files(android.getBootClasspath().join(File.pathSeparator))\n                classpathFiles += project.files(project.configurations.api)\n                classpathFiles += project.files(project.configurations.implementation)\n                doFirst { classpath += classpathFiles }\n\n                source = variant.javaCompile.source\n                options {\n                    memberLevel = JavadocMemberLevel.PUBLIC\n\n                    def doclavaJar = project.rootProject.file('gradle/doclava-1.0.6.jar')\n                    if (doclavaJar.exists()) {\n                        doclet = 'com.google.doclava.Doclava'\n                        docletpath = [doclavaJar]\n                    }\n                    //docletpath = project.configurations.doclava.files as List\n                }\n                destinationDir = project.file(\"${project.buildDir}/docs/javadoc\")\n                exclude '**/BuildConfig.java'\n                exclude '**/R.java'\n                failOnError false\n\n                dependsOn generateSourcesTask\n            }\n\n            def javadocJarTask = project.task(\"javadocJar${cVariantName}\", type: Jar) {\n                classifier = 'javadoc'\n                from javadocTask.destinationDir\n                dependsOn javadocTask\n            }\n\n            def sourcesJarTask = project.task(\"sourcesJar${cVariantName}\", type: Jar) {\n                classifier = 'sources'\n\n                def srcDirs = []\n                variant.sourceSets.each { sources ->\n                    ['java', 'groovy', 'scala', 'kotlin'].each {\n                        if (sources.hasProperty(it))\n                            srcDirs << sources[it].srcDirs\n                    }\n                }\n\n                from srcDirs\n                dependsOn generateSourcesTask\n            }\n\n            def externalNativeBuildTask = project.tasks.findByName(\n                    \"externalNativeBuild${cVariantName}\")\n            Zip nativeSymbolZipTask = null\n            if (externalNativeBuildTask != null) {\n                nativeSymbolZipTask = project.task(\"nativeSymbolZip${cVariantName}\", type: Zip) {\n                    classifier = \"${variantOnlyName}Symbols\"\n                    from(externalNativeBuildTask.objFolder) {\n                        include '*/*.so'\n                    }\n                    from(externalNativeBuildTask.objFolder.dir('obj/local')) {\n                        include '*/*.so'\n                    }\n                    dependsOn externalNativeBuildTask\n                }\n\n                externalNativeBuildTask.doLast {\n                    // If externalNativeBuild generates no shared library files,\n                    // remove symbols artifact from the publication.\n                    if (nativeSymbolZipTask.inputs.sourceFiles.empty) {\n                        def publication = project.publishing.publications\n                                .getByName(\"${publicationName}${cFlavorName}\")\n                        publication.artifacts.removeIf {\n                            it.file == nativeSymbolZipTask.archivePath\n                        }\n                    }\n                }\n            }\n\n            def bundleTask = project.tasks.findByName(\"bundle${cVariantName}Aar\")\n            if (bundleTask == null)\n                bundleTask = project.tasks.findByName(\"bundle${cVariantName}\")\n\n            project.publishing.publications {\n                \"${publicationName}${cFlavorName}\"(MavenPublication) {\n                    if (variantOnlyName == 'release') {\n                        hasReleaseVariant = true\n\n                        artifact(source: bundleTask, classifier: null)\n\n                        if (withSources) {\n                            artifact(source: sourcesJarTask, classifier: 'sources')\n                        }\n                        if (withJavadoc) {\n                            artifact(source: javadocJarTask, classifier: 'javadoc')\n                        }\n                        if (withNativeSymbols && nativeSymbolZipTask != null) {\n                            artifact(source: nativeSymbolZipTask, classifier: 'symbols')\n                        }\n                    } else if (publishAllVariants || publishVariants.contains(variantOnlyName)) {\n                        artifact(source: bundleTask, classifier: variantOnlyName)\n\n                        if (withNativeSymbols && nativeSymbolZipTask != null) {\n                            artifact(source: nativeSymbolZipTask, classifier: \"${variantOnlyName}Symbols\")\n                        }\n                    }\n\n                    if (!emittedFlavors.contains(flavorName)) {\n                        emittedFlavors << flavorName\n\n                        groupId this.groupId\n                        version this.fullVersion\n\n                        if (hasFlavor) {\n                            def currFlavor = variant.productFlavors.get(0)\n                            def actualArtifactIdSuffix = ''\n                            if (currFlavor.ext.has('artifactIdSuffix')) {\n                                actualArtifactIdSuffix = currFlavor.ext.artifactIdSuffix\n                                int firstNotBarPos = 0\n                                while (firstNotBarPos < actualArtifactIdSuffix.length()\n                                        && actualArtifactIdSuffix.charAt(firstNotBarPos) == '-') {\n                                    ++firstNotBarPos\n                                }\n                                actualArtifactIdSuffix = actualArtifactIdSuffix.substring(firstNotBarPos)\n                            } else {\n                                actualArtifactIdSuffix = flavorName\n                            }\n                            artifactId actualArtifactIdSuffix.empty ?\n                                    this.artifactId : \"${this.artifactId}-${actualArtifactIdSuffix}\"\n                        } else {\n                            artifactId this.artifactId\n                        }\n\n                        validateArtifactNotExists(project, groupId, artifactId, version)\n\n                        pom {\n                            packaging 'aar'\n\n                            withXml {\n                                // Resolve dependencies\n                                final depsNode = asNode().appendNode('dependencies')\n                                final addDep = { Dependency dep, String scope ->\n                                    if (dep.group == null || dep.version == null || dep.name == null\n                                            || dep.name == \"unspecified\")\n                                        return // ignore invalid dependencies\n\n                                    // Determine actual artifactId for the dependency\n                                    def artifactId = dep.name\n                                    def version = dep.version\n                                    if (dep instanceof ProjectDependency) {\n                                        def p = (dep as ProjectDependency).dependencyProject\n                                        if (p.hasProperty('artifactId'))\n                                            artifactId = p.property('artifactId')\n                                        if (p.hasProperty('fullVersion'))\n                                            version = p.property('fullVersion')\n                                    }\n\n                                    def node = depsNode.appendNode('dependency')\n                                    node.appendNode('groupId', dep.group)\n                                    node.appendNode('artifactId', artifactId)\n                                    node.appendNode('version', version)\n                                    node.appendNode('scope', scope)\n\n                                    if (!dep.transitive) {\n                                        // If this dependency is transitive, we should force exclude all its dependencies them from the POM\n                                        final exclusionNode = node.appendNode('exclusions').appendNode('exclusion')\n                                        exclusionNode.appendNode('groupId', '*')\n                                        exclusionNode.appendNode('artifactId', '*')\n                                    } else if (!dep.properties.excludeRules.empty) {\n                                        // Otherwise add specified exclude rules\n                                        final exclusions = node.appendNode('exclusions')\n                                        dep.properties.excludeRules.each { ExcludeRule rule ->\n                                            def exclusionNode = exclusions.appendNode('exclusion')\n                                            exclusionNode.appendNode('groupId', rule.group ?: '*')\n                                            exclusionNode.appendNode('artifactId', rule.module ?: '*')\n                                        }\n                                    }\n                                }\n\n                                if (withDependencies) {\n                                    def visitedDeps = [] as Set<Dependency>\n\n                                    [\n                                            'compile':            'compile',\n                                            'api':                'compile',\n                                            'implementation':     'compile',\n                                            'runtimeOnly':        'runtime',\n                                            'provided':           'runtime'\n                                    ].each { conf, scope ->\n                                        if (project.configurations.find {\n                                            it.name.equals(conf)\n                                        }) {\n                                            project.configurations[conf].allDependencies.each {\n                                                if (visitedDeps.contains(it)) {\n                                                    return\n                                                }\n                                                addDep(it, scope)\n                                                visitedDeps.add(it)\n                                            }\n                                        }\n                                    }\n                                }\n                            }\n                        }\n                    }\n                }\n            }\n\n            pomClosures.each { cl ->\n                project.publishing.publications {\n                    \"${publicationName}${cFlavorName}\"(MavenPublication) {\n                        pom cl\n                    }\n                }\n            }\n        } // android.libraryVariants.all\n\n        // Check whether \"release\" variant is published\n        project.afterEvaluate {\n            if (!hasReleaseVariant)\n                throw new GradleException('Publishing Android library require \"release\" variant')\n        }\n    }\n}\n"
  },
  {
    "path": "deprecated/android/gradle/wrapper/gradle-wrapper.properties",
    "content": "#Sun Jun 24 01:57:56 CST 2018\ndistributionBase=GRADLE_USER_HOME\ndistributionPath=wrapper/dists\nzipStoreBase=GRADLE_USER_HOME\nzipStorePath=wrapper/dists\ndistributionUrl=https\\://services.gradle.org/distributions/gradle-7.5-bin.zip\n"
  },
  {
    "path": "deprecated/android/gradlew",
    "content": "#!/usr/bin/env bash\n\n##############################################################################\n##\n##  Gradle start up script for UN*X\n##\n##############################################################################\n\n# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.\nDEFAULT_JVM_OPTS=\"\"\n\nAPP_NAME=\"Gradle\"\nAPP_BASE_NAME=`basename \"$0\"`\n\n# Use the maximum available, or set MAX_FD != -1 to use that value.\nMAX_FD=\"maximum\"\n\nwarn ( ) {\n    echo \"$*\"\n}\n\ndie ( ) {\n    echo\n    echo \"$*\"\n    echo\n    exit 1\n}\n\n# OS specific support (must be 'true' or 'false').\ncygwin=false\nmsys=false\ndarwin=false\ncase \"`uname`\" in\n  CYGWIN* )\n    cygwin=true\n    ;;\n  Darwin* )\n    darwin=true\n    ;;\n  MINGW* )\n    msys=true\n    ;;\nesac\n\n# Attempt to set APP_HOME\n# Resolve links: $0 may be a link\nPRG=\"$0\"\n# Need this for relative symlinks.\nwhile [ -h \"$PRG\" ] ; do\n    ls=`ls -ld \"$PRG\"`\n    link=`expr \"$ls\" : '.*-> \\(.*\\)$'`\n    if expr \"$link\" : '/.*' > /dev/null; then\n        PRG=\"$link\"\n    else\n        PRG=`dirname \"$PRG\"`\"/$link\"\n    fi\ndone\nSAVED=\"`pwd`\"\ncd \"`dirname \\\"$PRG\\\"`/\" >/dev/null\nAPP_HOME=\"`pwd -P`\"\ncd \"$SAVED\" >/dev/null\n\nCLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar\n\n# Determine the Java command to use to start the JVM.\nif [ -n \"$JAVA_HOME\" ] ; then\n    if [ -x \"$JAVA_HOME/jre/sh/java\" ] ; then\n        # IBM's JDK on AIX uses strange locations for the executables\n        JAVACMD=\"$JAVA_HOME/jre/sh/java\"\n    else\n        JAVACMD=\"$JAVA_HOME/bin/java\"\n    fi\n    if [ ! -x \"$JAVACMD\" ] ; then\n        die \"ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME\n\nPlease set the JAVA_HOME variable in your environment to match the\nlocation of your Java installation.\"\n    fi\nelse\n    JAVACMD=\"java\"\n    which java >/dev/null 2>&1 || die \"ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.\n\nPlease set the JAVA_HOME variable in your environment to match the\nlocation of your Java installation.\"\nfi\n\n# Increase the maximum file descriptors if we can.\nif [ \"$cygwin\" = \"false\" -a \"$darwin\" = \"false\" ] ; then\n    MAX_FD_LIMIT=`ulimit -H -n`\n    if [ $? -eq 0 ] ; then\n        if [ \"$MAX_FD\" = \"maximum\" -o \"$MAX_FD\" = \"max\" ] ; then\n            MAX_FD=\"$MAX_FD_LIMIT\"\n        fi\n        ulimit -n $MAX_FD\n        if [ $? -ne 0 ] ; then\n            warn \"Could not set maximum file descriptor limit: $MAX_FD\"\n        fi\n    else\n        warn \"Could not query maximum file descriptor limit: $MAX_FD_LIMIT\"\n    fi\nfi\n\n# For Darwin, add options to specify how the application appears in the dock\nif $darwin; then\n    GRADLE_OPTS=\"$GRADLE_OPTS \\\"-Xdock:name=$APP_NAME\\\" \\\"-Xdock:icon=$APP_HOME/media/gradle.icns\\\"\"\nfi\n\n# For Cygwin, switch paths to Windows format before running java\nif $cygwin ; then\n    APP_HOME=`cygpath --path --mixed \"$APP_HOME\"`\n    CLASSPATH=`cygpath --path --mixed \"$CLASSPATH\"`\n    JAVACMD=`cygpath --unix \"$JAVACMD\"`\n\n    # We build the pattern for arguments to be converted via cygpath\n    ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`\n    SEP=\"\"\n    for dir in $ROOTDIRSRAW ; do\n        ROOTDIRS=\"$ROOTDIRS$SEP$dir\"\n        SEP=\"|\"\n    done\n    OURCYGPATTERN=\"(^($ROOTDIRS))\"\n    # Add a user-defined pattern to the cygpath arguments\n    if [ \"$GRADLE_CYGPATTERN\" != \"\" ] ; then\n        OURCYGPATTERN=\"$OURCYGPATTERN|($GRADLE_CYGPATTERN)\"\n    fi\n    # Now convert the arguments - kludge to limit ourselves to /bin/sh\n    i=0\n    for arg in \"$@\" ; do\n        CHECK=`echo \"$arg\"|egrep -c \"$OURCYGPATTERN\" -`\n        CHECK2=`echo \"$arg\"|egrep -c \"^-\"`                                 ### Determine if an option\n\n        if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then                    ### Added a condition\n            eval `echo args$i`=`cygpath --path --ignore --mixed \"$arg\"`\n        else\n            eval `echo args$i`=\"\\\"$arg\\\"\"\n        fi\n        i=$((i+1))\n    done\n    case $i in\n        (0) set -- ;;\n        (1) set -- \"$args0\" ;;\n        (2) set -- \"$args0\" \"$args1\" ;;\n        (3) set -- \"$args0\" \"$args1\" \"$args2\" ;;\n        (4) set -- \"$args0\" \"$args1\" \"$args2\" \"$args3\" ;;\n        (5) set -- \"$args0\" \"$args1\" \"$args2\" \"$args3\" \"$args4\" ;;\n        (6) set -- \"$args0\" \"$args1\" \"$args2\" \"$args3\" \"$args4\" \"$args5\" ;;\n        (7) set -- \"$args0\" \"$args1\" \"$args2\" \"$args3\" \"$args4\" \"$args5\" \"$args6\" ;;\n        (8) set -- \"$args0\" \"$args1\" \"$args2\" \"$args3\" \"$args4\" \"$args5\" \"$args6\" \"$args7\" ;;\n        (9) set -- \"$args0\" \"$args1\" \"$args2\" \"$args3\" \"$args4\" \"$args5\" \"$args6\" \"$args7\" \"$args8\" ;;\n    esac\nfi\n\n# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules\nfunction splitJvmOpts() {\n    JVM_OPTS=(\"$@\")\n}\neval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS\nJVM_OPTS[${#JVM_OPTS[*]}]=\"-Dorg.gradle.appname=$APP_BASE_NAME\"\n\nexec \"$JAVACMD\" \"${JVM_OPTS[@]}\" -classpath \"$CLASSPATH\" org.gradle.wrapper.GradleWrapperMain \"$@\"\n"
  },
  {
    "path": "deprecated/android/gradlew.bat",
    "content": "@if \"%DEBUG%\" == \"\" @echo off\n@rem ##########################################################################\n@rem\n@rem  Gradle startup script for Windows\n@rem\n@rem ##########################################################################\n\n@rem Set local scope for the variables with windows NT shell\nif \"%OS%\"==\"Windows_NT\" setlocal\n\n@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.\nset DEFAULT_JVM_OPTS=\n\nset DIRNAME=%~dp0\nif \"%DIRNAME%\" == \"\" set DIRNAME=.\nset APP_BASE_NAME=%~n0\nset APP_HOME=%DIRNAME%\n\n@rem Find java.exe\nif defined JAVA_HOME goto findJavaFromJavaHome\n\nset JAVA_EXE=java.exe\n%JAVA_EXE% -version >NUL 2>&1\nif \"%ERRORLEVEL%\" == \"0\" goto init\n\necho.\necho ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.\necho.\necho Please set the JAVA_HOME variable in your environment to match the\necho location of your Java installation.\n\ngoto fail\n\n:findJavaFromJavaHome\nset JAVA_HOME=%JAVA_HOME:\"=%\nset JAVA_EXE=%JAVA_HOME%/bin/java.exe\n\nif exist \"%JAVA_EXE%\" goto init\n\necho.\necho ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%\necho.\necho Please set the JAVA_HOME variable in your environment to match the\necho location of your Java installation.\n\ngoto fail\n\n:init\n@rem Get command-line arguments, handling Windowz variants\n\nif not \"%OS%\" == \"Windows_NT\" goto win9xME_args\nif \"%@eval[2+2]\" == \"4\" goto 4NT_args\n\n:win9xME_args\n@rem Slurp the command line arguments.\nset CMD_LINE_ARGS=\nset _SKIP=2\n\n:win9xME_args_slurp\nif \"x%~1\" == \"x\" goto execute\n\nset CMD_LINE_ARGS=%*\ngoto execute\n\n:4NT_args\n@rem Get arguments from the 4NT Shell from JP Software\nset CMD_LINE_ARGS=%$\n\n:execute\n@rem Setup the command line\n\nset CLASSPATH=%APP_HOME%\\gradle\\wrapper\\gradle-wrapper.jar\n\n@rem Execute Gradle\n\"%JAVA_EXE%\" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% \"-Dorg.gradle.appname=%APP_BASE_NAME%\" -classpath \"%CLASSPATH%\" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%\n\n:end\n@rem End local scope for the variables with windows NT shell\nif \"%ERRORLEVEL%\"==\"0\" goto mainEnd\n\n:fail\nrem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of\nrem the _cmd.exe /c_ return code!\nif  not \"\" == \"%GRADLE_EXIT_CONSOLE%\" exit 1\nexit /b 1\n\n:mainEnd\nif \"%OS%\"==\"Windows_NT\" endlocal\n\n:omega\n"
  },
  {
    "path": "deprecated/android/jni/ChunkedCursorWindow.cpp",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"ChunkedCursorWindow.h\"\n#include <assert.h>\n\nnamespace wcdb {\n\n#define CHUNK_CONFLICT ((Chunk *) -1)\n#define CHUNK_NOT_FOUND ((Chunk *) 0)\n\nChunkedCursorWindow::Chunk::Chunk(CursorWindow *window_, uint32_t startPos_)\n    : window(window_), startPos(startPos_), mRefCount(1)\n{\n}\n\nChunkedCursorWindow::Chunk::~Chunk()\n{\n    delete window;\n}\n\nvoid ChunkedCursorWindow::Chunk::acquire()\n{\n    int ref = __sync_fetch_and_add(&mRefCount, 1);\n    assert(ref > 0);\n    (void) ref;\n}\n\nvoid ChunkedCursorWindow::Chunk::release()\n{\n    if (__sync_fetch_and_sub(&mRefCount, 1) == 1)\n        delete this;\n}\n\nChunkedCursorWindow::Chunk *\nChunkedCursorWindow::Chunk::create(uint32_t startPos_, size_t size)\n{\n    CursorWindow *window;\n    status_t ret = CursorWindow::create(size, &window);\n    if (ret == OK && window) {\n        return new Chunk(window, startPos_);\n    } else {\n        return nullptr;\n    }\n}\n\nChunkedCursorWindow::ChunkedCursorWindow(uint32_t chunkCapacity)\n    : mChunkCapacity(chunkCapacity)\n    , mNumColumns(0)\n    , mLastReadChunk(nullptr)\n    , mLastWriteChunk(nullptr)\n    , mLastWriteChunkRowLimit(__UINT32_MAX__)\n    , mCurrentWritingRow(__UINT32_MAX__)\n    , mRowPool(nullptr)\n{\n}\n\nChunkedCursorWindow::~ChunkedCursorWindow()\n{\n    // Release all allocated chunk.\n    for (auto it = mChunkMap.begin(); it != mChunkMap.end(); ++it) {\n        it->second->release();\n    }\n\n    // Free Row object pool.\n    for (Row *p = mRowPool; p; p = p->mPoolNext) {\n        delete p;\n    }\n}\n\nstatus_t ChunkedCursorWindow::create(size_t size,\n                                     ChunkedCursorWindow **outWindow)\n{\n    uint32_t capacity = size / CHUNK_SIZE;\n    if (size % CHUNK_SIZE > 0)\n        capacity++;\n\n    *outWindow = new ChunkedCursorWindow(capacity);\n    return OK;\n}\n\nChunkedCursorWindow::Row *ChunkedCursorWindow::allocRowLocked()\n{\n    // Must be called with mMutex locked.\n\n    Row *r;\n    if (mRowPool) {\n        r = mRowPool;\n        mRowPool = r->mPoolNext;\n        r->mPoolNext = nullptr;\n    } else {\n        r = new Row();\n    }\n    return r;\n}\n\nvoid ChunkedCursorWindow::recycleRowLocked(ChunkedCursorWindow::Row *row)\n{\n    // Must be called with mMutex locked.\n\n    assert(row->mPoolNext == nullptr);\n    row->mPoolNext = mRowPool;\n    mRowPool = row;\n}\n\nsize_t ChunkedCursorWindow::capacity() const\n{\n    AutoMutex lock(mMutex);\n    return mChunkCapacity * CHUNK_SIZE;\n}\n\nvoid ChunkedCursorWindow::capacity(size_t size)\n{\n    AutoMutex lock(mMutex);\n\n    uint32_t capacity = size / CHUNK_SIZE;\n    if (size % CHUNK_SIZE > 0)\n        capacity++;\n    mChunkCapacity = capacity;\n}\n\nstatus_t ChunkedCursorWindow::setNumColumns(uint32_t columns)\n{\n    AutoMutex lock(mMutex);\n\n    if (columns == mNumColumns)\n        return OK;\n\n    if (mNumColumns > 0 || !mChunkMap.empty())\n        return INVALID_OPERATION;\n\n    mNumColumns = columns;\n    return OK;\n}\n\nChunkedCursorWindow::Chunk *\nChunkedCursorWindow::findChunkByRowLocked(uint32_t row)\n{\n    // Must be called with mMutex locked.\n\n    // Lookup mLastReadChunk first.\n    if (mLastReadChunk &&\n        row - mLastReadChunk->startPos < mLastReadChunk->window->getNumRows()) {\n        return mLastReadChunk;\n    }\n\n    // Not found, search ChunkMap.\n    Chunk *chunk = nullptr;\n    auto it = mChunkMap.lower_bound(row);\n    if (it != mChunkMap.end() && it->first == row) {\n        chunk = it->second;\n    } else if (it != mChunkMap.begin()) {\n        chunk = (--it)->second;\n    }\n\n    if (chunk) {\n        if (row - chunk->startPos >= chunk->window->getNumRows())\n            chunk = nullptr;\n        else\n            mLastReadChunk = chunk;\n    }\n\n    return chunk;\n}\n\nChunkedCursorWindow::Chunk *\nChunkedCursorWindow::getChunkForWritingLocked(uint32_t row)\n{\n    // Must be called with mMutex locked.\n\n    // Lookup mLastWriteChunk first.\n    if (mLastWriteChunk &&\n        row - mLastWriteChunk->startPos ==\n            mLastWriteChunk->window->getNumRows()) {\n        if (row >= mLastWriteChunkRowLimit)\n            return CHUNK_CONFLICT;\n        else\n            return mLastWriteChunk;\n    }\n\n    // By supporting only linear insertions, there are only two possible scenarios:\n    // 1) append to last active chunk, which is handled above;\n    // 2) allocate new chunk, which should call allocChunkLocked.\n    // We don't even need to search ChunkMap here.\n    return CHUNK_NOT_FOUND;\n}\n\nChunkedCursorWindow::Chunk *\nChunkedCursorWindow::allocChunkLocked(uint32_t startPos)\n{\n    // TODO: check capacity.\n\n    // Lookup if row to insert already existed.\n    auto it = mChunkMap.lower_bound(startPos);\n    auto hint = it;\n    if (it != mChunkMap.end() && it->first == startPos) {\n        // Found a chunk with exactly the same startPos.\n        // Anyway it's not possible to insert a chunk here, just return failure.\n        return nullptr;\n    } else if (it != mChunkMap.begin()) {\n        Chunk *chunk = (--it)->second;\n\n        // Got chunk just before the insertion point, check for conflict.\n        if (startPos - chunk->startPos < chunk->window->getNumRows())\n            return nullptr;\n    }\n    // If we found no chunk with startPos lesser than insertion point, it's perfectly\n    // okay to insert a chunk at the beginning.\n\n    // Allocate new chunk and push to the map.\n    Chunk *chunk = Chunk::create(startPos, CHUNK_SIZE);\n    if (chunk->window->setNumColumns(mNumColumns) != OK) {\n        chunk->release();\n        return nullptr;\n    }\n    mChunkMap.emplace_hint(hint, startPos, chunk);\n\n    // Update cache.\n    mLastWriteChunk = chunk;\n    mLastWriteChunkRowLimit =\n        (hint == mChunkMap.end()) ? __UINT32_MAX__ : hint->second->startPos;\n    return chunk;\n}\n\nChunkedCursorWindow::Chunk *ChunkedCursorWindow::removeChunkLocked(uint32_t row)\n{\n    Chunk *chunk;\n    ChunkMap::iterator it = mChunkMap.lower_bound(row);\n    if (it != mChunkMap.end() && it->first == row) {\n        chunk = it->second;\n    } else if (it != mChunkMap.begin()) {\n        chunk = (--it)->second;\n        if (row - chunk->startPos < chunk->window->getNumRows())\n            return nullptr;\n    } else { // it == mChunkMap.begin()\n        return nullptr;\n    }\n\n    if (mLastReadChunk == chunk)\n        mLastReadChunk = nullptr;\n    if (mLastWriteChunk == chunk) {\n        mLastWriteChunk = nullptr;\n        mLastWriteChunkRowLimit = __UINT32_MAX__;\n    }\n\n    mChunkMap.erase(it);\n    return chunk;\n}\n\nChunkedCursorWindow::Row *ChunkedCursorWindow::newRow(uint32_t row,\n                                                      bool newChunk)\n{\n    AutoMutex lock(mMutex);\n\n    if (mCurrentWritingRow != __UINT32_MAX__)\n        return nullptr;\n\n    Chunk *chunk = nullptr;\n    if (!newChunk) {\n        // Not forced to new chunk, lookup cache.\n        chunk = getChunkForWritingLocked(row);\n\n        if (chunk == CHUNK_CONFLICT) {\n            // We are in conflict, remove the chunk in requesting position.\n            Chunk *removedChunk = removeChunkLocked(row);\n            assert(removedChunk != nullptr);\n            removedChunk->release();\n            chunk = nullptr;\n        }\n    }\n\n    if (!chunk) {\n        // No existing chunk, allocate a new one.\n        chunk = allocChunkLocked(row);\n        if (!chunk) {\n            // Chunk allocation failed.\n            return nullptr;\n\n            // TODO: handle capacity limit.\n        }\n    }\n\n    // Allocate row on the chunk.\n    assert(chunk->startPos + chunk->window->getNumRows() == row);\n\n    CursorWindow *window = chunk->window;\n    CursorWindow::RowSlot *slot;\n    status_t ret = window->allocRow(&slot);\n    if (ret != OK || !slot) {\n        // Row allocation failed, probably because there is no space left on the window\n        // to allocate RowSlotChunk or field directory. Return failure and let caller retry.\n        return nullptr;\n    }\n\n    // Fill Row object and return.\n    chunk->acquire();\n    Row *rowObj = allocRowLocked();\n    rowObj->mRow = row;\n    rowObj->mChunk = chunk;\n    rowObj->mWindow = window;\n    rowObj->mSlot = slot;\n\n    mCurrentWritingRow = row;\n    return rowObj;\n}\n\nChunkedCursorWindow::Row *ChunkedCursorWindow::getRow(uint32_t row)\n{\n    AutoMutex lock(mMutex);\n\n    if (mCurrentWritingRow == row)\n        return nullptr;\n\n    Chunk *chunk = findChunkByRowLocked(row);\n    if (!chunk)\n        return nullptr;\n\n    assert(row >= chunk->startPos);\n    CursorWindow *window = chunk->window;\n    CursorWindow::RowSlot *slot = window->getRowSlot(row - chunk->startPos);\n    if (!slot)\n        return nullptr;\n\n    chunk->acquire();\n    Row *rowObj = allocRowLocked();\n    rowObj->mRow = row;\n    rowObj->mChunk = chunk;\n    rowObj->mWindow = window;\n    rowObj->mSlot = slot;\n    return rowObj;\n}\n\nvoid ChunkedCursorWindow::endRow(ChunkedCursorWindow::Row *row)\n{\n    AutoMutex lock(mMutex);\n\n    if (mCurrentWritingRow == row->mRow)\n        mCurrentWritingRow = __UINT32_MAX__;\n\n    row->mChunk->release();\n    recycleRowLocked(row);\n}\n\nvoid ChunkedCursorWindow::rollbackRow(ChunkedCursorWindow::Row *row)\n{\n    AutoMutex lock(mMutex);\n\n    if (mCurrentWritingRow == row->mRow) {\n        row->mWindow->freeLastRow();\n        mCurrentWritingRow = __UINT32_MAX__;\n    }\n\n    row->mChunk->release();\n    recycleRowLocked(row);\n}\n\nstatus_t ChunkedCursorWindow::clear()\n{\n    AutoMutex lock(mMutex);\n\n    ChunkMap::iterator it;\n    for (it = mChunkMap.begin(); it != mChunkMap.end(); ++it) {\n        it->second->release();\n    }\n    mChunkMap.clear();\n\n    mNumColumns = 0;\n    mLastReadChunk = nullptr;\n    mLastWriteChunk = nullptr;\n    mLastWriteChunkRowLimit = __UINT32_MAX__;\n    mCurrentWritingRow = __UINT32_MAX__;\n    return OK;\n}\n\nstatus_t ChunkedCursorWindow::removeChunk(uint32_t row,\n                                          uint32_t &outStart,\n                                          uint32_t &outEnd)\n{\n    AutoMutex lock(mMutex);\n\n    Chunk *chunk = removeChunkLocked(row);\n    if (chunk) {\n        outStart = chunk->startPos;\n        outEnd = outStart + chunk->window->getNumRows();\n        chunk->release();\n    }\n\n    return chunk ? OK : BAD_INDEX;\n}\n\n} // namespace wcdb\n"
  },
  {
    "path": "deprecated/android/jni/ChunkedCursorWindow.h",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#ifndef __WCDB_CHUNKED_CURSOR_WINDOW_H__\n#define __WCDB_CHUNKED_CURSOR_WINDOW_H__\n\n#include \"CursorWindow.h\"\n#include \"Mutex.h\"\n#include <map>\n\nnamespace wcdb {\n\nclass ChunkedCursorWindow {\n    // Each CursorWindow chunk is 256 kB.\n    static const uint32_t CHUNK_SIZE = 256 * 1024;\n\n    struct Chunk {\n        CursorWindow *window;\n        uint32_t startPos;\n\n        static Chunk *create(uint32_t startPos_, size_t size);\n\n        void acquire();\n        void release();\n\n    private:\n        Chunk(CursorWindow *window_, uint32_t startPos_);\n        ~Chunk();\n        volatile int mRefCount;\n    };\n\npublic:\n    class Row;\n    class Field {\n        Field(CursorWindow::FieldSlot *slot) : mSlot(slot) {}\n\n        CursorWindow::FieldSlot *mSlot;\n\n        friend class Row;\n    };\n\n    class Row {\n        Row() : mPoolNext(nullptr) {}\n\n        ~Row() {}\n\n        uint32_t mRow;\n        Chunk *mChunk;\n        CursorWindow *mWindow;\n        CursorWindow::RowSlot *mSlot;\n        Row *mPoolNext;\n\n        friend class ChunkedCursorWindow;\n\n    public:\n        inline uint32_t getRowPos() const { return mRow; }\n\n        inline Field getField(uint32_t column)\n        {\n            return Field(mWindow->getFieldSlot(mSlot, column));\n        }\n\n        inline bool isFieldValid(const Field &field)\n        {\n            return field.mSlot != nullptr;\n        }\n\n        inline int32_t getFieldType(const Field &field)\n        {\n            return mWindow->getFieldSlotType(field.mSlot);\n        }\n        inline int64_t getFieldLong(const Field &field)\n        {\n            return mWindow->getFieldSlotValueLong(field.mSlot);\n        }\n        inline double getFieldDouble(const Field &field)\n        {\n            return mWindow->getFieldSlotValueDouble(field.mSlot);\n        }\n        inline const char *getFieldString(const Field &field,\n                                          size_t &outSizeIncludingNull)\n        {\n            return mWindow->getFieldSlotValueString(field.mSlot,\n                                                    &outSizeIncludingNull);\n        }\n        inline const void *getFieldBlob(const Field &field, size_t &outSize)\n        {\n            return mWindow->getFieldSlotValueBlob(field.mSlot, &outSize);\n        }\n\n        inline status_t putBlob(uint32_t column, const void *value, size_t size)\n        {\n            return mWindow->putBlob(mSlot, column, value, size);\n        }\n        inline status_t\n        putString(uint32_t column, const char *value, size_t sizeIncludingNull)\n        {\n            return mWindow->putString(mSlot, column, value, sizeIncludingNull);\n        }\n        inline status_t putLong(uint32_t column, int64_t value)\n        {\n            return mWindow->putLong(mSlot, column, value);\n        }\n        inline status_t putDouble(uint32_t column, double value)\n        {\n            return mWindow->putDouble(mSlot, column, value);\n        }\n        inline status_t putNull(uint32_t column)\n        {\n            return mWindow->putNull(mSlot, column);\n        }\n    };\n\n    ~ChunkedCursorWindow();\n\n    static status_t create(size_t size, ChunkedCursorWindow **outWindow);\n\n    inline uint32_t getNumColumns()\n    {\n        AutoMutex lock(mMutex);\n        return mNumColumns;\n    }\n    status_t setNumColumns(uint32_t columns);\n\n    Row *newRow(uint32_t row, bool newChunk);\n    Row *getRow(uint32_t row);\n    void endRow(Row *row);\n    void rollbackRow(Row *row);\n    status_t clear();\n    status_t removeChunk(uint32_t row, uint32_t &outStart, uint32_t &outEnd);\n\n    size_t capacity() const;\n    void capacity(size_t size);\n\n    inline size_t getNumChunks() const\n    {\n        AutoMutex lock(mMutex);\n        return mChunkMap.size();\n    }\n\nprivate:\n    ChunkedCursorWindow(uint32_t chunkCapacity);\n\n    // startRow -> CursorWindow chunk mapping, used in row lookup.\n    typedef std::map<uint32_t, Chunk *> ChunkMap;\n    ChunkMap mChunkMap;\n    uint32_t mChunkCapacity;\n\n    // Mutex and condition to protect data and recieve notification\n    // when data is ready for reading.\n    mutable Mutex mMutex;\n\n    uint32_t mNumColumns;\n\n    // Last chunk accessed, cached for fast lookup of rows nearby.\n    Chunk *mLastReadChunk;\n    Chunk *mLastWriteChunk;\n    uint32_t mLastWriteChunkRowLimit;\n    uint32_t mCurrentWritingRow;\n\n    Chunk *findChunkByRowLocked(uint32_t row);\n    Chunk *getChunkForWritingLocked(uint32_t row);\n    Chunk *allocChunkLocked(uint32_t startPos);\n    Chunk *removeChunkLocked(uint32_t row);\n\n    // Pool for Row objects to prevent frequent memory allocations.\n    Row *mRowPool;\n    Row *allocRowLocked();\n    void recycleRowLocked(Row *row);\n};\n\n} // namespace wcdb\n\n#endif\n"
  },
  {
    "path": "deprecated/android/jni/CursorWindow.cpp",
    "content": "/*\n * Copyright (C) 2006-2007 The Android Open Source Project\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#undef LOG_TAG\n#define LOG_TAG \"WCDB.CursorWindow\"\n\n#ifndef __STDC_FORMAT_MACROS\n#define __STDC_FORMAT_MACROS\n#endif\n\n#include \"CursorWindow.h\"\n\n#include <assert.h>\n#include <inttypes.h>\n#include <stdlib.h>\n#include <string.h>\n#include <string>\n\nnamespace wcdb {\n\nCursorWindow::CursorWindow(void *data, size_t size) : mData(data), mSize(size)\n{\n    mHeader = static_cast<Header *>(mData);\n}\n\nCursorWindow::~CursorWindow()\n{\n    if (mData)\n        free(mData);\n}\n\nstatus_t CursorWindow::create(size_t size, CursorWindow **outCursorWindow)\n{\n    status_t result;\n    void *data = malloc(size);\n    if (data) {\n        CursorWindow *window = new CursorWindow(data, size);\n        result = window->clear();\n        if (!result) {\n            LOG_WINDOW(\"Created new CursorWindow: freeOffset=%\" PRIu32 \", \"\n                       \"numRows=%\" PRIu32 \", numColumns=%\" PRIu32\n                       \", mSize=%zu, mData=%p\",\n                       window->mHeader->freeOffset, window->mHeader->numRows,\n                       window->mHeader->numColumns, window->mSize,\n                       window->mData);\n            *outCursorWindow = window;\n        }\n        return OK;\n    } else {\n        *outCursorWindow = nullptr;\n        return NO_MEMORY;\n    }\n}\n\nstatus_t CursorWindow::clear()\n{\n    mHeader->freeOffset = sizeof(Header) + sizeof(RowSlotChunk);\n    mHeader->firstChunkOffset = sizeof(Header);\n    mHeader->numRows = 0;\n    mHeader->numColumns = 0;\n\n    RowSlotChunk *firstChunk =\n        static_cast<RowSlotChunk *>(offsetToPtr(mHeader->firstChunkOffset));\n    firstChunk->nextChunkOffset = 0;\n    return OK;\n}\n\nstatus_t CursorWindow::setNumColumns(uint32_t numColumns)\n{\n    uint32_t cur = mHeader->numColumns;\n    if ((cur > 0 || mHeader->numRows > 0) && cur != numColumns) {\n        ALOGE(\"Trying to go from %d columns to %d\", cur, numColumns);\n        return INVALID_OPERATION;\n    }\n    mHeader->numColumns = numColumns;\n    return OK;\n}\n\nstatus_t CursorWindow::allocRow(RowSlot **outSlot)\n{\n    // Fill in the row slot\n    RowSlot *rowSlot = allocRowSlot();\n    if (rowSlot == nullptr) {\n        if (outSlot)\n            *outSlot = nullptr;\n        return NO_MEMORY;\n    }\n\n    // Allocate the slots for the field directory\n    size_t fieldDirSize = mHeader->numColumns * sizeof(FieldSlot);\n    uint32_t fieldDirOffset = alloc(fieldDirSize, true /*aligned*/);\n    if (!fieldDirOffset) {\n        mHeader->numRows--;\n        LOG_WINDOW(\"The row failed, so back out the new row accounting \"\n                   \"from allocRowSlot %d\",\n                   mHeader->numRows);\n        if (outSlot)\n            *outSlot = nullptr;\n        return NO_MEMORY;\n    }\n    FieldSlot *fieldDir = static_cast<FieldSlot *>(offsetToPtr(fieldDirOffset));\n    memset(fieldDir, 0, fieldDirSize);\n\n    LOG_WINDOW(\"Allocated row %\" PRIu32 \", rowSlot is at offset %\" PRIu32\n               \", fieldDir is %zu bytes at offset %\" PRIu32 \"\\n\",\n               mHeader->numRows - 1, offsetFromPtr(rowSlot), fieldDirSize,\n               fieldDirOffset);\n    rowSlot->offset = fieldDirOffset;\n\n    if (outSlot)\n        *outSlot = rowSlot;\n    return OK;\n}\n\nstatus_t CursorWindow::freeLastRow()\n{\n    if (mHeader->numRows > 0) {\n        mHeader->numRows--;\n    }\n    return OK;\n}\n\nuint32_t CursorWindow::alloc(size_t size, bool aligned)\n{\n    uint32_t padding;\n    if (aligned) {\n        // 4 byte alignment\n        padding = (~mHeader->freeOffset + 1) & 3;\n    } else {\n        padding = 0;\n    }\n\n    uint32_t offset = mHeader->freeOffset + padding;\n    uint32_t nextFreeOffset = offset + size;\n    if (nextFreeOffset > mSize) {\n        ALOGW(\"Window is full: requested allocation %zu bytes, \"\n              \"free space %zu bytes, window size %zu bytes\",\n              size, freeSpace(), mSize);\n        return 0;\n    }\n\n    mHeader->freeOffset = nextFreeOffset;\n    return offset;\n}\n\nCursorWindow::RowSlot *CursorWindow::getRowSlot(uint32_t row)\n{\n    if (row >= mHeader->numRows) {\n        ALOGE(\"Failed to read row %d from a CursorWindow which has %d rows.\",\n              row, mHeader->numRows);\n        return nullptr;\n    }\n\n    uint32_t chunkPos = row;\n    RowSlotChunk *chunk =\n        static_cast<RowSlotChunk *>(offsetToPtr(mHeader->firstChunkOffset));\n    while (chunkPos >= ROW_SLOT_CHUNK_NUM_ROWS) {\n        chunk =\n            static_cast<RowSlotChunk *>(offsetToPtr(chunk->nextChunkOffset));\n        chunkPos -= ROW_SLOT_CHUNK_NUM_ROWS;\n    }\n    return &chunk->slots[chunkPos];\n}\n\nCursorWindow::RowSlot *CursorWindow::allocRowSlot()\n{\n    uint32_t chunkPos = mHeader->numRows;\n    RowSlotChunk *chunk =\n        static_cast<RowSlotChunk *>(offsetToPtr(mHeader->firstChunkOffset));\n    while (chunkPos > ROW_SLOT_CHUNK_NUM_ROWS) {\n        chunk =\n            static_cast<RowSlotChunk *>(offsetToPtr(chunk->nextChunkOffset));\n        chunkPos -= ROW_SLOT_CHUNK_NUM_ROWS;\n    }\n    if (chunkPos == ROW_SLOT_CHUNK_NUM_ROWS) {\n        if (!chunk->nextChunkOffset) {\n            chunk->nextChunkOffset =\n                alloc(sizeof(RowSlotChunk), true /*aligned*/);\n            if (!chunk->nextChunkOffset) {\n                return nullptr;\n            }\n        }\n        chunk =\n            static_cast<RowSlotChunk *>(offsetToPtr(chunk->nextChunkOffset));\n        chunk->nextChunkOffset = 0;\n        chunkPos = 0;\n    }\n    mHeader->numRows += 1;\n    return &chunk->slots[chunkPos];\n}\n\nCursorWindow::FieldSlot *CursorWindow::getFieldSlot(RowSlot *rowSlot,\n                                                    uint32_t column)\n{\n    if (!rowSlot || column >= mHeader->numColumns) {\n        ALOGE(\"Failed to find row or column(%d) from a CursorWindow (has %d \"\n              \"columns).\",\n              column, mHeader->numColumns);\n        return nullptr;\n    }\n    FieldSlot *fieldDir =\n        static_cast<FieldSlot *>(offsetToPtr(rowSlot->offset));\n    return &fieldDir[column];\n}\n\nstatus_t CursorWindow::putBlob(RowSlot *row,\n                               uint32_t column,\n                               const void *value,\n                               size_t size)\n{\n    return putBlobOrString(row, column, value, size, FIELD_TYPE_BLOB);\n}\n\nstatus_t CursorWindow::putString(RowSlot *row,\n                                 uint32_t column,\n                                 const char *value,\n                                 size_t sizeIncludingNull)\n{\n    return putBlobOrString(row, column, value, sizeIncludingNull,\n                           FIELD_TYPE_STRING);\n}\n\nstatus_t CursorWindow::putBlobOrString(\n    RowSlot *row, uint32_t column, const void *value, size_t size, int32_t type)\n{\n\n    FieldSlot *fieldSlot = getFieldSlot(row, column);\n    if (!fieldSlot) {\n        return BAD_VALUE;\n    }\n\n    uint32_t offset = alloc(size);\n    if (!offset) {\n        return NO_MEMORY;\n    }\n\n    memcpy(offsetToPtr(offset), value, size);\n\n    fieldSlot->type = type;\n    fieldSlot->data.buffer.offset = offset;\n    fieldSlot->data.buffer.size = size;\n    return OK;\n}\n\nstatus_t CursorWindow::putLong(RowSlot *row, uint32_t column, int64_t value)\n{\n    FieldSlot *fieldSlot = getFieldSlot(row, column);\n    if (!fieldSlot) {\n        return BAD_VALUE;\n    }\n\n    fieldSlot->type = FIELD_TYPE_INTEGER;\n    fieldSlot->data.l = value;\n    return OK;\n}\n\nstatus_t CursorWindow::putDouble(RowSlot *row, uint32_t column, double value)\n{\n    FieldSlot *fieldSlot = getFieldSlot(row, column);\n    if (!fieldSlot) {\n        return BAD_VALUE;\n    }\n\n    fieldSlot->type = FIELD_TYPE_FLOAT;\n    fieldSlot->data.d = value;\n    return OK;\n}\n\nstatus_t CursorWindow::putNull(RowSlot *row, uint32_t column)\n{\n    FieldSlot *fieldSlot = getFieldSlot(row, column);\n    if (!fieldSlot) {\n        return BAD_VALUE;\n    }\n\n    fieldSlot->type = FIELD_TYPE_NULL;\n    fieldSlot->data.buffer.offset = 0;\n    fieldSlot->data.buffer.size = 0;\n    return OK;\n}\n\n} // namespace wcdb\n"
  },
  {
    "path": "deprecated/android/jni/CursorWindow.h",
    "content": "/*\n * Copyright (C) 2006 The Android Open Source Project\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#ifndef __WCDB_CURSOR_WINDOW_H__\n#define __WCDB_CURSOR_WINDOW_H__\n\n#include <stddef.h>\n#include <stdint.h>\n#include <string>\n\n#include \"Errors.h\"\n#include \"Logger.h\"\n\n#if 1\n\n#define IF_LOG_WINDOW() if (false)\n#define LOG_WINDOW(...)\n\n#else\n\n#define IF_LOG_WINDOW() IF_ALOG(LOG_DEBUG, \"WCDB.CursorWindow\")\n#define LOG_WINDOW(...) LOGD(\"WCDB.CursorWindow\", __VA_ARGS__)\n\n#endif\n\nnamespace wcdb {\n\n/**\n * This class stores a set of rows from a database in a buffer. The begining of the\n * window has first chunk of RowSlots, which are offsets to the row directory, followed by\n * an offset to the next chunk in a linked-list of additional chunk of RowSlots in case\n * the pre-allocated chunk isn't big enough to refer to all rows. Each row directory has a\n * FieldSlot per column, which has the size, offset, and type of the data for that field.\n * Note that the data types come from sqlite3.h.\n *\n * Strings are stored in UTF-8.\n**/\nclass CursorWindow {\n    CursorWindow(void *data, size_t size);\n\npublic:\n    /* Field types. */\n    enum {\n        FIELD_TYPE_NULL = 0,\n        FIELD_TYPE_INTEGER = 1,\n        FIELD_TYPE_FLOAT = 2,\n        FIELD_TYPE_STRING = 3,\n        FIELD_TYPE_BLOB = 4,\n    };\n\n    struct RowSlot {\n        uint32_t offset;\n    };\n\n    /* Opaque type that describes a field slot. */\n    struct FieldSlot {\n    private:\n        int32_t type;\n        union {\n            double d;\n            int64_t l;\n            struct {\n                uint32_t offset;\n                uint32_t size;\n            } buffer;\n        } data;\n\n        friend class CursorWindow;\n    } __attribute((packed));\n\n    ~CursorWindow();\n\n    static status_t create(size_t size, CursorWindow **outCursorWindow);\n\n    inline size_t size() { return mSize; }\n    inline size_t freeSpace() { return mSize - mHeader->freeOffset; }\n    inline uint32_t getNumRows() { return mHeader->numRows; }\n    inline uint32_t getNumColumns() { return mHeader->numColumns; }\n\n    status_t clear();\n    status_t setNumColumns(uint32_t numColumns);\n\n    /**\n         * Allocate a row slot and its directory.\n         * The row is initialized will null entries for each field.\n         */\n    status_t allocRow(RowSlot **outSlot);\n    status_t freeLastRow();\n\n    RowSlot *getRowSlot(uint32_t row);\n\n    status_t\n    putBlob(RowSlot *row, uint32_t column, const void *value, size_t size);\n    inline status_t\n    putBlob(uint32_t row, uint32_t column, const void *value, size_t size)\n    {\n        return putBlob(getRowSlot(row), column, value, size);\n    }\n\n    status_t putString(RowSlot *row,\n                       uint32_t column,\n                       const char *value,\n                       size_t sizeIncludingNull);\n    inline status_t putString(uint32_t row,\n                              uint32_t column,\n                              const char *value,\n                              size_t sizeIncludingNull)\n    {\n        return putString(getRowSlot(row), column, value, sizeIncludingNull);\n    }\n\n    status_t putLong(RowSlot *row, uint32_t column, int64_t value);\n    inline status_t putLong(uint32_t row, uint32_t column, int64_t value)\n    {\n        return putLong(getRowSlot(row), column, value);\n    }\n\n    status_t putDouble(RowSlot *row, uint32_t column, double value);\n    inline status_t putDouble(uint32_t row, uint32_t column, double value)\n    {\n        return putDouble(getRowSlot(row), column, value);\n    }\n\n    status_t putNull(RowSlot *row, uint32_t column);\n    inline status_t putNull(uint32_t row, uint32_t column)\n    {\n        return putNull(getRowSlot(row), column);\n    }\n\n    /**\n    * Gets the field slot at the specified row and column.\n    * Returns null if the requested row or column is not in the window.\n    */\n    FieldSlot *getFieldSlot(RowSlot *rowSlot, uint32_t column);\n    inline FieldSlot *getFieldSlot(uint32_t row, uint32_t column)\n    {\n        return getFieldSlot(getRowSlot(row), column);\n    }\n\n    inline int32_t getFieldSlotType(FieldSlot *fieldSlot)\n    {\n        return fieldSlot->type;\n    }\n\n    inline int64_t getFieldSlotValueLong(FieldSlot *fieldSlot)\n    {\n        return fieldSlot->data.l;\n    }\n\n    inline double getFieldSlotValueDouble(FieldSlot *fieldSlot)\n    {\n        return fieldSlot->data.d;\n    }\n\n    inline const char *getFieldSlotValueString(FieldSlot *fieldSlot,\n                                               size_t *outSizeIncludingNull)\n    {\n        *outSizeIncludingNull = fieldSlot->data.buffer.size;\n        return static_cast<char *>(offsetToPtr(fieldSlot->data.buffer.offset));\n    }\n\n    inline const void *getFieldSlotValueBlob(FieldSlot *fieldSlot,\n                                             size_t *outSize)\n    {\n        *outSize = fieldSlot->data.buffer.size;\n        return offsetToPtr(fieldSlot->data.buffer.offset);\n    }\n\nprivate:\n    static const size_t ROW_SLOT_CHUNK_NUM_ROWS = 1023;\n\n    struct Header {\n        // Offset of the lowest unused byte in the window.\n        uint32_t freeOffset;\n\n        // Offset of the first row slot chunk.\n        uint32_t firstChunkOffset;\n\n        uint32_t numRows;\n        uint32_t numColumns;\n    };\n\n    struct RowSlotChunk {\n        uint32_t nextChunkOffset;\n        RowSlot slots[ROW_SLOT_CHUNK_NUM_ROWS];\n    };\n\n    void *mData;\n    size_t mSize;\n    Header *mHeader;\n\n    inline void *offsetToPtr(uint32_t offset)\n    {\n        return static_cast<uint8_t *>(mData) + offset;\n    }\n\n    inline uint32_t offsetFromPtr(void *ptr)\n    {\n        return static_cast<uint8_t *>(ptr) - static_cast<uint8_t *>(mData);\n    }\n\n    /**\n         * Allocate a portion of the window. Returns the offset\n         * of the allocation, or 0 if there isn't enough space.\n         * If aligned is true, the allocation gets 4 byte alignment.\n         */\n    uint32_t alloc(size_t size, bool aligned = false);\n\n    RowSlot *allocRowSlot();\n\n    status_t putBlobOrString(RowSlot *row,\n                             uint32_t column,\n                             const void *value,\n                             size_t size,\n                             int32_t type);\n};\n\n} // namespace wcdb\n\n#endif\n"
  },
  {
    "path": "deprecated/android/jni/Errors.h",
    "content": "/*\n * Copyright (C) 2007 The Android Open Source Project\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#ifndef ANDROID_ERRORS_H\n#define ANDROID_ERRORS_H\n\n#include <sys/types.h>\n#include <errno.h>\n\nnamespace wcdb {\n\n// use this type to return error codes\n#ifdef HAVE_MS_C_RUNTIME\ntypedef int         status_t;\n#else\ntypedef int32_t     status_t;\n#endif\n\n/* the MS C runtime lacks a few error codes */\n\n/*\n * Error codes. \n * All error codes are negative values.\n */\n\n// Win32 #defines NO_ERROR as well.  It has the same value, so there's no\n// real conflict, though it's a bit awkward.\n#ifdef _WIN32\n# undef NO_ERROR\n#endif\n \nenum {\n    OK                = 0,    // Everything's swell.\n    NO_ERROR          = 0,    // No errors.\n    \n    UNKNOWN_ERROR       = (-2147483647-1),\n\n    NO_MEMORY           = -ENOMEM,\n    INVALID_OPERATION   = -ENOSYS,\n    BAD_VALUE           = -EINVAL,\n    BAD_TYPE            = (UNKNOWN_ERROR + 1),\n    NAME_NOT_FOUND      = -ENOENT,\n    PERMISSION_DENIED   = -EPERM,\n    NO_INIT             = -ENODEV,\n    ALREADY_EXISTS      = -EEXIST,\n    DEAD_OBJECT         = -EPIPE,\n    FAILED_TRANSACTION  = (UNKNOWN_ERROR + 2),\n    JPARKS_BROKE_IT     = -EPIPE,\n#if !defined(HAVE_MS_C_RUNTIME)\n    BAD_INDEX           = -EOVERFLOW,\n    NOT_ENOUGH_DATA     = -ENODATA,\n    WOULD_BLOCK         = -EWOULDBLOCK, \n    TIMED_OUT           = -ETIMEDOUT,\n    UNKNOWN_TRANSACTION = -EBADMSG,\n#else    \n    BAD_INDEX           = -E2BIG,\n    NOT_ENOUGH_DATA     = (UNKNOWN_ERROR + 3),\n    WOULD_BLOCK         = (UNKNOWN_ERROR + 4),\n    TIMED_OUT           = (UNKNOWN_ERROR + 5),\n    UNKNOWN_TRANSACTION = (UNKNOWN_ERROR + 6),\n#endif    \n    FDS_NOT_ALLOWED     = (UNKNOWN_ERROR + 7),\n};\n\n// Restore define; enumeration is in \"android\" namespace, so the value defined\n// there won't work for Win32 code in a different namespace.\n#ifdef _WIN32\n# define NO_ERROR 0L\n#endif\n\n} // namespace wcdb\n    \n// ---------------------------------------------------------------------------\n    \n#endif // ANDROID_ERRORS_H\n"
  },
  {
    "path": "deprecated/android/jni/JNIHelp.cpp",
    "content": "/*\n * Copyright (C) 2006 The Android Open Source Project\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#define LOG_TAG \"WCDB.JNIHelp\"\n\n#include \"JNIHelp.h\"\n#include \"Logger.h\"\n\n#include <assert.h>\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n\n/**\n * Equivalent to ScopedLocalRef, but for C_JNIEnv instead. (And slightly more powerful.)\n */\ntemplate <typename T>\nclass scoped_local_ref {\npublic:\n    scoped_local_ref(C_JNIEnv *env, T localRef = NULL)\n        : mEnv(env), mLocalRef(localRef)\n    {\n    }\n\n    ~scoped_local_ref() { reset(); }\n\n    void reset(T localRef = NULL)\n    {\n        if (mLocalRef != NULL) {\n            (*mEnv)->DeleteLocalRef(reinterpret_cast<JNIEnv *>(mEnv),\n                                    mLocalRef);\n            mLocalRef = localRef;\n        }\n    }\n\n    T get() const { return mLocalRef; }\n\nprivate:\n    C_JNIEnv *mEnv;\n    T mLocalRef;\n\n    // Disallow copy and assignment.\n    scoped_local_ref(const scoped_local_ref &);\n    void operator=(const scoped_local_ref &);\n};\n\nstatic jclass findClass(C_JNIEnv *env, const char *className)\n{\n    JNIEnv *e = reinterpret_cast<JNIEnv *>(env);\n    return (*env)->FindClass(e, className);\n}\n\nextern \"C\" int jniRegisterNativeMethods(C_JNIEnv *env,\n                                        const char *className,\n                                        const JNINativeMethod *gMethods,\n                                        int numMethods)\n{\n    JNIEnv *e = reinterpret_cast<JNIEnv *>(env);\n\n    ALOGV(\"Registering %s natives\", className);\n\n    scoped_local_ref<jclass> c(env, findClass(env, className));\n    if (c.get() == NULL) {\n        char msg[256];\n        snprintf(msg, sizeof(msg),\n                 \"Native registration unable to find class '%s', aborting\",\n                 className);\n        e->FatalError(msg);\n    }\n\n    if ((*env)->RegisterNatives(e, c.get(), gMethods, numMethods) < 0) {\n        char msg[256];\n        snprintf(msg, sizeof(msg), \"RegisterNatives failed for '%s', aborting\",\n                 className);\n        e->FatalError(msg);\n    }\n\n    return 0;\n}\n\n/*\n * Returns a human-readable summary of an exception object.  The buffer will\n * be populated with the \"binary\" class name and, if present, the\n * exception message.\n */\nstatic char *getExceptionSummary0(C_JNIEnv *env, jthrowable exception)\n{\n    JNIEnv *e = reinterpret_cast<JNIEnv *>(env);\n\n    /* get the name of the exception's class */\n    scoped_local_ref<jclass> exceptionClass(\n        env, (*env)->GetObjectClass(e, exception)); // can't fail\n    scoped_local_ref<jclass> classClass(\n        env,\n        (*env)->GetObjectClass(\n            e, exceptionClass.get())); // java.lang.Class, can't fail\n    jmethodID classGetNameMethod = (*env)->GetMethodID(\n        e, classClass.get(), \"getName\", \"()Ljava/lang/String;\");\n    scoped_local_ref<jstring> classNameStr(\n        env,\n        (jstring)(*env)->CallObjectMethod(e, exceptionClass.get(),\n                                          classGetNameMethod));\n    if (classNameStr.get() == NULL) {\n        return NULL;\n    }\n\n    /* get printable string */\n    const char *classNameChars =\n        (*env)->GetStringUTFChars(e, classNameStr.get(), NULL);\n    if (classNameChars == NULL) {\n        return NULL;\n    }\n\n    /* if the exception has a detail message, get that */\n    jmethodID getMessage = (*env)->GetMethodID(\n        e, exceptionClass.get(), \"getMessage\", \"()Ljava/lang/String;\");\n    scoped_local_ref<jstring> messageStr(\n        env, (jstring)(*env)->CallObjectMethod(e, exception, getMessage));\n    if (messageStr.get() == NULL) {\n        return strdup(classNameChars);\n    }\n\n    char *result = NULL;\n    const char *messageChars =\n        (*env)->GetStringUTFChars(e, messageStr.get(), NULL);\n    if (messageChars != NULL) {\n        asprintf(&result, \"%s: %s\", classNameChars, messageChars);\n        (*env)->ReleaseStringUTFChars(e, messageStr.get(), messageChars);\n    } else {\n        (*env)->ExceptionClear(e); // clear OOM\n        asprintf(&result, \"%s: <error getting message>\", classNameChars);\n    }\n\n    (*env)->ReleaseStringUTFChars(e, classNameStr.get(), classNameChars);\n    return result;\n}\n\nstatic char *getExceptionSummary(C_JNIEnv *env, jthrowable exception)\n{\n    JNIEnv *e = reinterpret_cast<JNIEnv *>(env);\n    char *result = getExceptionSummary0(env, exception);\n    if (result == NULL) {\n        (*env)->ExceptionClear(e);\n        result = strdup(\"<error getting class name>\");\n    }\n    return result;\n}\n\n/*\n * Returns an exception (with stack trace) as a string.\n */\nstatic char *getStackTrace(C_JNIEnv *env, jthrowable exception)\n{\n    JNIEnv *e = reinterpret_cast<JNIEnv *>(env);\n\n    scoped_local_ref<jclass> stringWriterClass(\n        env, findClass(env, \"java/io/StringWriter\"));\n    if (stringWriterClass.get() == NULL) {\n        return NULL;\n    }\n\n    jmethodID stringWriterCtor =\n        (*env)->GetMethodID(e, stringWriterClass.get(), \"<init>\", \"()V\");\n    jmethodID stringWriterToStringMethod = (*env)->GetMethodID(\n        e, stringWriterClass.get(), \"toString\", \"()Ljava/lang/String;\");\n\n    scoped_local_ref<jclass> printWriterClass(\n        env, findClass(env, \"java/io/PrintWriter\"));\n    if (printWriterClass.get() == NULL) {\n        return NULL;\n    }\n\n    jmethodID printWriterCtor = (*env)->GetMethodID(\n        e, printWriterClass.get(), \"<init>\", \"(Ljava/io/Writer;)V\");\n\n    scoped_local_ref<jobject> stringWriter(\n        env, (*env)->NewObject(e, stringWriterClass.get(), stringWriterCtor));\n    if (stringWriter.get() == NULL) {\n        return NULL;\n    }\n\n    jobject printWriter = (*env)->NewObject(\n        e, printWriterClass.get(), printWriterCtor, stringWriter.get());\n    if (printWriter == NULL) {\n        return NULL;\n    }\n\n    scoped_local_ref<jclass> exceptionClass(\n        env, (*env)->GetObjectClass(e, exception)); // can't fail\n    jmethodID printStackTraceMethod = (*env)->GetMethodID(\n        e, exceptionClass.get(), \"printStackTrace\", \"(Ljava/io/PrintWriter;)V\");\n    (*env)->CallVoidMethod(e, exception, printStackTraceMethod, printWriter);\n\n    if ((*env)->ExceptionCheck(e)) {\n        return NULL;\n    }\n\n    scoped_local_ref<jstring> messageStr(\n        env,\n        (jstring)(*env)->CallObjectMethod(e, stringWriter.get(),\n                                          stringWriterToStringMethod));\n    if (messageStr.get() == NULL) {\n        return NULL;\n    }\n\n    const char *utfChars = (*env)->GetStringUTFChars(e, messageStr.get(), NULL);\n    if (utfChars == NULL) {\n        return NULL;\n    }\n\n    char *result = strdup(utfChars);\n    (*env)->ReleaseStringUTFChars(e, messageStr.get(), utfChars);\n    return result;\n}\n\nextern \"C\" int\njniThrowException(C_JNIEnv *env, const char *className, const char *msg)\n{\n    JNIEnv *e = reinterpret_cast<JNIEnv *>(env);\n\n    if ((*env)->ExceptionCheck(e)) {\n        /* TODO: consider creating the new exception with this as \"cause\" */\n        scoped_local_ref<jthrowable> exception(env,\n                                               (*env)->ExceptionOccurred(e));\n        (*env)->ExceptionClear(e);\n\n        if (exception.get() != NULL) {\n            char *text = getExceptionSummary(env, exception.get());\n            ALOGW(\"Discarding pending exception (%s) to throw %s\", text,\n                  className);\n            free(text);\n        }\n    }\n\n    scoped_local_ref<jclass> exceptionClass(env, findClass(env, className));\n    if (exceptionClass.get() == NULL) {\n        ALOGE(\"Unable to find exception class %s\", className);\n        /* ClassNotFoundException now pending */\n        return -1;\n    }\n\n    if ((*env)->ThrowNew(e, exceptionClass.get(), msg) != JNI_OK) {\n        ALOGE(\"Failed throwing '%s' '%s'\", className, msg);\n        /* an exception, most likely OOM, will now be pending */\n        return -1;\n    }\n\n    return 0;\n}\n\nint jniThrowExceptionFmt(C_JNIEnv *env,\n                         const char *className,\n                         const char *fmt,\n                         va_list args)\n{\n    char msgBuf[512];\n    vsnprintf(msgBuf, sizeof(msgBuf), fmt, args);\n    return jniThrowException(env, className, msgBuf);\n}\n\nint jniThrowNullPointerException(C_JNIEnv *env, const char *msg)\n{\n    return jniThrowException(env, \"java/lang/NullPointerException\", msg);\n}\n\nint jniThrowRuntimeException(C_JNIEnv *env, const char *msg)\n{\n    return jniThrowException(env, \"java/lang/RuntimeException\", msg);\n}\n\nint jniThrowIOException(C_JNIEnv *env, int errnum)\n{\n    char buffer[80];\n    const char *message = jniStrError(errnum, buffer, sizeof(buffer));\n    return jniThrowException(env, \"java/io/IOException\", message);\n}\n\nvoid jniLogException(C_JNIEnv *env,\n                     int priority,\n                     const char *tag,\n                     jthrowable exception)\n{\n    JNIEnv *e = reinterpret_cast<JNIEnv *>(env);\n\n    scoped_local_ref<jthrowable> currentException(env,\n                                                  (*env)->ExceptionOccurred(e));\n    if (exception == NULL) {\n        exception = currentException.get();\n        if (exception == NULL) {\n            return;\n        }\n    }\n\n    if (currentException.get() != NULL) {\n        (*env)->ExceptionClear(e);\n    }\n\n    char *buffer = getStackTrace(env, exception);\n    if (buffer == NULL) {\n        (*env)->ExceptionClear(e);\n        buffer = getExceptionSummary(env, exception);\n    }\n\n    wcdb_log_write(priority, tag, buffer);\n    free(buffer);\n\n    if (currentException.get() != NULL) {\n        (*env)->Throw(e, currentException.get()); // rethrow\n    }\n}\n\nconst char *jniStrError(int errnum, char *buf, size_t buflen)\n{\n    // Note: glibc has a nonstandard strerror_r that returns char* rather than POSIX's int.\n    // char *strerror_r(int errnum, char *buf, size_t n);\n    int ret = strerror_r(errnum, buf, buflen);\n    if (ret == 0) {\n        // POSIX strerror_r, success\n        return buf;\n    } else {\n        // POSIX strerror_r, failure\n        // (Strictly, POSIX only guarantees a value other than 0. The safest\n        // way to implement this function is to use C++ and overload on the\n        // type of strerror_r to accurately distinguish GNU from POSIX. But\n        // realistic implementations will always return -1.)\n        snprintf(buf, buflen, \"errno %d\", errnum);\n        return buf;\n    }\n}\n\nstatic struct {\n    jclass clazz;\n    jmethodID ctor;\n    jfieldID descriptor;\n} gFileDescriptorClassInfo;\n\nstatic struct {\n    jmethodID get;\n} gReferenceClassInfo;\n\nstatic JavaVM *g_VM = NULL;\n\nextern \"C\" jint JNIHelp_JNI_OnLoad(JavaVM *vm, void *)\n{\n    JNIEnv *env;\n    if (vm->GetEnv(reinterpret_cast<void **>(&env), JNI_VERSION_1_6) !=\n        JNI_OK) {\n        ALOGE(\"JavaVM::GetEnv() failed\");\n        abort();\n    }\n\n    gFileDescriptorClassInfo.clazz = reinterpret_cast<jclass>(\n        env->NewGlobalRef(env->FindClass(\"java/io/FileDescriptor\")));\n    if (gFileDescriptorClassInfo.clazz == NULL) {\n        abort();\n    }\n\n    gFileDescriptorClassInfo.ctor =\n        env->GetMethodID(gFileDescriptorClassInfo.clazz, \"<init>\", \"()V\");\n    if (gFileDescriptorClassInfo.ctor == NULL) {\n        abort();\n    }\n\n    gFileDescriptorClassInfo.descriptor =\n        env->GetFieldID(gFileDescriptorClassInfo.clazz, \"descriptor\", \"I\");\n    if (gFileDescriptorClassInfo.descriptor == NULL) {\n        abort();\n    }\n\n    jclass clazz =\n        reinterpret_cast<jclass>(env->FindClass(\"java/lang/ref/Reference\"));\n    if (clazz == NULL) {\n        abort();\n    }\n\n    gReferenceClassInfo.get =\n        env->GetMethodID(clazz, \"get\", \"()Ljava/lang/Object;\");\n    if (gReferenceClassInfo.get == NULL) {\n        abort();\n    }\n\n    g_VM = vm;\n    return JNI_VERSION_1_6;\n}\n\nC_JNIEnv *jniGetEnv_()\n{\n    C_JNIEnv *env;\n\n    if (!g_VM)\n        return NULL;\n    if (g_VM->GetEnv((void **) &env, JNI_VERSION_1_6) != JNI_OK)\n        return NULL;\n    return env;\n}\n\njobject jniCreateFileDescriptor(C_JNIEnv *env, int fd)\n{\n    JNIEnv *e = reinterpret_cast<JNIEnv *>(env);\n    jobject fileDescriptor = (*env)->NewObject(\n        e, gFileDescriptorClassInfo.clazz, gFileDescriptorClassInfo.ctor);\n    jniSetFileDescriptorOfFD(env, fileDescriptor, fd);\n    return fileDescriptor;\n}\n\nint jniGetFDFromFileDescriptor(C_JNIEnv *env, jobject fileDescriptor)\n{\n    JNIEnv *e = reinterpret_cast<JNIEnv *>(env);\n    return (*env)->GetIntField(e, fileDescriptor,\n                               gFileDescriptorClassInfo.descriptor);\n}\n\nvoid jniSetFileDescriptorOfFD(C_JNIEnv *env, jobject fileDescriptor, int value)\n{\n    JNIEnv *e = reinterpret_cast<JNIEnv *>(env);\n    (*env)->SetIntField(e, fileDescriptor, gFileDescriptorClassInfo.descriptor,\n                        value);\n}\n\njobject jniGetReferent(C_JNIEnv *env, jobject ref)\n{\n    JNIEnv *e = reinterpret_cast<JNIEnv *>(env);\n    return (*env)->CallObjectMethod(e, ref, gReferenceClassInfo.get);\n}\n\n/*\n * DO NOT USE THIS FUNCTION\n *\n * Get a pointer to the elements of a non-movable array.\n *\n * The semantics are similar to GetDirectBufferAddress.  Specifically, the VM\n * guarantees that the array will not move, and the caller must ensure that\n * it does not continue to use the pointer after the object is collected.\n *\n * We currently use an illegal sequence that trips up CheckJNI when\n * the \"forcecopy\" mode is enabled.  We pass in a magic value to work\n * around the problem.\n *\n * Returns NULL if the array is movable.\n */\n#define kNoCopyMagic 0xd5aab57f /* also in CheckJni.c */\nextern \"C\" jbyte *jniGetNonMovableArrayElements(C_JNIEnv *env, jarray arrayObj)\n{\n    JNIEnv *e = reinterpret_cast<JNIEnv *>(env);\n\n    jbyteArray byteArray = reinterpret_cast<jbyteArray>(arrayObj);\n\n    /*\n     * Normally the \"isCopy\" parameter is for a return value only, so the\n     * non-CheckJNI VM will ignore whatever we pass in.\n     */\n    uint32_t noCopy = kNoCopyMagic;\n    jbyte *result = (*env)->GetByteArrayElements(\n        e, byteArray, reinterpret_cast<jboolean *>(&noCopy));\n\n    /*\n     * The non-CheckJNI implementation only cares about the array object,\n     * so we can replace the element pointer with the magic value.\n     */\n    (*env)->ReleaseByteArrayElements(\n        e, byteArray, reinterpret_cast<jbyte *>(kNoCopyMagic), 0);\n    return result;\n}\n"
  },
  {
    "path": "deprecated/android/jni/JNIHelp.h",
    "content": "/*\n * Copyright (C) 2007 The Android Open Source Project\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/*\n * JNI helper functions.\n *\n * This file may be included by C or C++ code, which is trouble because jni.h\n * uses different typedefs for JNIEnv in each language.\n */\n#ifndef NATIVEHELPER_JNIHELP_H_\n#define NATIVEHELPER_JNIHELP_H_\n\n#include \"Logger.h\"\n#include <jni.h>\n#include <unistd.h>\n\n#ifndef NELEM\n#define NELEM(x) ((int) (sizeof(x) / sizeof((x)[0])))\n#endif\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\njint JNIHelp_JNI_OnLoad(JavaVM *vm, void *);\n\n/*\n * Register one or more native methods with a particular class.\n * \"className\" looks like \"java/lang/String\". Aborts on failure.\n * TODO: fix all callers and change the return type to void.\n */\nint jniRegisterNativeMethods(C_JNIEnv *env,\n                             const char *className,\n                             const JNINativeMethod *gMethods,\n                             int numMethods);\n\n/*\n * Throw an exception with the specified class and an optional message.\n *\n * The \"className\" argument will be passed directly to FindClass, which\n * takes strings with slashes (e.g. \"java/lang/Object\").\n *\n * If an exception is currently pending, we log a warning message and\n * clear it.\n *\n * Returns 0 on success, nonzero if something failed (e.g. the exception\n * class couldn't be found, so *an* exception will still be pending).\n *\n * Currently aborts the VM if it can't throw the exception.\n */\nint jniThrowException(C_JNIEnv *env, const char *className, const char *msg);\n\n/*\n * Throw a java.lang.NullPointerException, with an optional message.\n */\nint jniThrowNullPointerException(C_JNIEnv *env, const char *msg);\n\n/*\n * Throw a java.lang.RuntimeException, with an optional message.\n */\nint jniThrowRuntimeException(C_JNIEnv *env, const char *msg);\n\n/*\n * Throw a java.io.IOException, generating the message from errno.\n */\nint jniThrowIOException(C_JNIEnv *env, int errnum);\n\n/*\n * Return a pointer to a locale-dependent error string explaining errno\n * value 'errnum'. The returned pointer may or may not be equal to 'buf'.\n * This function is thread-safe (unlike strerror) and portable (unlike\n * strerror_r).\n */\nconst char *jniStrError(int errnum, char *buf, size_t buflen);\n\n/*\n * Returns a new java.io.FileDescriptor for the given int fd.\n */\njobject jniCreateFileDescriptor(C_JNIEnv *env, int fd);\n\n/*\n * Returns the int fd from a java.io.FileDescriptor.\n */\nint jniGetFDFromFileDescriptor(C_JNIEnv *env, jobject fileDescriptor);\n\n/*\n * Sets the int fd in a java.io.FileDescriptor.\n */\nvoid jniSetFileDescriptorOfFD(C_JNIEnv *env, jobject fileDescriptor, int value);\n\n/*\n * Returns the reference from a java.lang.ref.Reference.\n */\njobject jniGetReferent(C_JNIEnv *env, jobject ref);\n\n/*\n * Log a message and an exception.\n * If exception is NULL, logs the current exception in the JNI environment.\n */\nvoid jniLogException(C_JNIEnv *env,\n                     int priority,\n                     const char *tag,\n                     jthrowable exception);\n\nC_JNIEnv *jniGetEnv_();\n\n#ifdef __cplusplus\n}\n#endif\n\n/*\n * For C++ code, we provide inlines that map to the C functions.  g++ always\n * inlines these, even on non-optimized builds.\n */\n#if defined(__cplusplus)\ninline int jniRegisterNativeMethods(JNIEnv *env,\n                                    const char *className,\n                                    const JNINativeMethod *gMethods,\n                                    int numMethods)\n{\n    return jniRegisterNativeMethods(&env->functions, className, gMethods,\n                                    numMethods);\n}\n\ninline int\njniThrowException(JNIEnv *env, const char *className, const char *msg)\n{\n    return jniThrowException(&env->functions, className, msg);\n}\n\nextern \"C\" int jniThrowExceptionFmt(C_JNIEnv *env,\n                                    const char *className,\n                                    const char *fmt,\n                                    va_list args);\n\n/*\n * Equivalent to jniThrowException but with a printf-like format string and\n * variable-length argument list. This is only available in C++.\n */\ninline int\njniThrowExceptionFmt(JNIEnv *env, const char *className, const char *fmt, ...)\n{\n    va_list args;\n    va_start(args, fmt);\n    return jniThrowExceptionFmt(&env->functions, className, fmt, args);\n    va_end(args);\n}\n\ninline int jniThrowNullPointerException(JNIEnv *env, const char *msg)\n{\n    return jniThrowNullPointerException(&env->functions, msg);\n}\n\ninline int jniThrowRuntimeException(JNIEnv *env, const char *msg)\n{\n    return jniThrowRuntimeException(&env->functions, msg);\n}\n\ninline int jniThrowIOException(JNIEnv *env, int errnum)\n{\n    return jniThrowIOException(&env->functions, errnum);\n}\n\ninline jobject jniCreateFileDescriptor(JNIEnv *env, int fd)\n{\n    return jniCreateFileDescriptor(&env->functions, fd);\n}\n\ninline int jniGetFDFromFileDescriptor(JNIEnv *env, jobject fileDescriptor)\n{\n    return jniGetFDFromFileDescriptor(&env->functions, fileDescriptor);\n}\n\ninline void\njniSetFileDescriptorOfFD(JNIEnv *env, jobject fileDescriptor, int value)\n{\n    jniSetFileDescriptorOfFD(&env->functions, fileDescriptor, value);\n}\n\ninline jobject jniGetReferent(JNIEnv *env, jobject ref)\n{\n    return jniGetReferent(&env->functions, ref);\n}\n\ninline void jniLogException(JNIEnv *env,\n                            int priority,\n                            const char *tag,\n                            jthrowable exception = NULL)\n{\n    jniLogException(&env->functions, priority, tag, exception);\n}\n\ninline JNIEnv *jniGetEnv()\n{\n    return reinterpret_cast<JNIEnv *>(jniGetEnv_());\n}\n#endif\n\n/* Logging macros.\n *\n * Logs an exception.  If the exception is omitted or NULL, logs the current exception\n * from the JNI environment, if any.\n */\n#define LOG_EX(env, priority, tag, ...)                                        \\\n    IF_ALOG(priority, tag)                                                     \\\n    jniLogException(env, ANDROID_##priority, tag, ##__VA_ARGS__)\n#define LOGV_EX(env, ...) LOG_EX(env, LOG_VERBOSE, LOG_TAG, ##__VA_ARGS__)\n#define LOGD_EX(env, ...) LOG_EX(env, LOG_DEBUG, LOG_TAG, ##__VA_ARGS__)\n#define LOGI_EX(env, ...) LOG_EX(env, LOG_INFO, LOG_TAG, ##__VA_ARGS__)\n#define LOGW_EX(env, ...) LOG_EX(env, LOG_WARN, LOG_TAG, ##__VA_ARGS__)\n#define LOGE_EX(env, ...) LOG_EX(env, LOG_ERROR, LOG_TAG, ##__VA_ARGS__)\n\n/*\n * TEMP_FAILURE_RETRY is defined by some, but not all, versions of\n * <unistd.h>. (Alas, it is not as standard as we'd hoped!) So, if it's\n * not already defined, then define it here.\n */\n#ifndef TEMP_FAILURE_RETRY\n/* Used to retry syscalls that can return EINTR. */\n#define TEMP_FAILURE_RETRY(exp)                                                \\\n    ({                                                                         \\\n        typeof(exp) _rc;                                                       \\\n        do {                                                                   \\\n            _rc = (exp);                                                       \\\n        } while (_rc == -1 && errno == EINTR);                                 \\\n        _rc;                                                                   \\\n    })\n#endif\n\n#endif /* NATIVEHELPER_JNIHELP_H_ */\n"
  },
  {
    "path": "deprecated/android/jni/Logger.c",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"Logger.h\"\n#include <stdio.h>\n\nstatic wcdb_logfunc_t g_logfunc = __android_log_write;\n\nstatic int dummy_log(int prio, const char *tag, const char *msg)\n{\n    return 0;\n}\n\nwcdb_logfunc_t wcdb_get_log_function()\n{\n    return g_logfunc;\n}\n\nvoid wcdb_set_log_function(wcdb_logfunc_t func)\n{\n    if (!func)\n        func = dummy_log;\n    g_logfunc = func;\n}\n\nint wcdb_log_vprint(int prio, const char *tag, const char *fmt, va_list ap)\n{\n    char buf[1024];\n    vsnprintf(buf, sizeof(buf), fmt, ap);\n    return g_logfunc(prio, tag, buf);\n}\n\nint wcdb_log_print(int prio, const char *tag, const char *fmt, ...)\n{\n    va_list ap;\n    char buf[1024];\n\n    va_start(ap, fmt);\n    vsnprintf(buf, sizeof(buf), fmt, ap);\n    va_end(ap);\n\n    return g_logfunc(prio, tag, buf);\n}\n"
  },
  {
    "path": "deprecated/android/jni/Logger.h",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#ifndef __WCDB_ANDROID_LOG_H__\n#define __WCDB_ANDROID_LOG_H__\n\n#include <android/log.h>\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\ntypedef int (*wcdb_logfunc_t)(int prio, const char *tag, const char *msg);\n\nwcdb_logfunc_t wcdb_get_log_function();\nvoid wcdb_set_log_function(wcdb_logfunc_t func);\n\nint wcdb_log_print(int prio, const char *tag, const char *fmt, ...)\n#ifdef __GNUC__\n    __attribute__((format(printf, 3, 4)))\n#endif\n    ;\n\nint wcdb_log_vprint(int prio, const char *tag, const char *fmt, va_list ap);\n\ninline static int wcdb_log_write(int prio, const char *tag, const char *msg)\n{\n    return wcdb_get_log_function()(prio, tag, msg);\n}\n\n#ifndef MMDB_NO_LOGX_MACRO\n\n#define LOGV(tag, fmt, args...)                                                \\\n    wcdb_log_print(ANDROID_LOG_VERBOSE, (tag), (fmt), ##args)\n#define LOGD(tag, fmt, args...)                                                \\\n    wcdb_log_print(ANDROID_LOG_DEBUG, (tag), (fmt), ##args)\n#define LOGI(tag, fmt, args...)                                                \\\n    wcdb_log_print(ANDROID_LOG_INFO, (tag), (fmt), ##args)\n#define LOGW(tag, fmt, args...)                                                \\\n    wcdb_log_print(ANDROID_LOG_WARN, (tag), (fmt), ##args)\n#define LOGE(tag, fmt, args...)                                                \\\n    wcdb_log_print(ANDROID_LOG_ERROR, (tag), (fmt), ##args)\n\n#define ALOG(priority, tag, ...)                                               \\\n    wcdb_log_print(ANDROID_##priority, (tag), __VA_ARGS__)\n#define ALOGV(...) ((void) LOGV(LOG_TAG, __VA_ARGS__))\n#define ALOGD(...) ((void) LOGD(LOG_TAG, __VA_ARGS__))\n#define ALOGI(...) ((void) LOGI(LOG_TAG, __VA_ARGS__))\n#define ALOGW(...) ((void) LOGW(LOG_TAG, __VA_ARGS__))\n#define ALOGE(...) ((void) LOGE(LOG_TAG, __VA_ARGS__))\n\n#define IF_ALOG(priority, tag) if (1)\n#define LOG_FATAL_IF(cond, ...) // do nothing\n#define ALOG_ASSERT(cond, ...) LOG_FATAL_IF(!(cond), ##__VA_ARGS__)\n\n#endif\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif\n"
  },
  {
    "path": "deprecated/android/jni/ModuleLoader.c",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"ModuleLoader.h\"\n#include \"Logger.h\"\n#include <jni.h>\n#include <stdint.h>\n#include <stdlib.h>\n\n#define LOG_TAG \"WCDB\"\n\ntypedef int (*jni_init_func_t)(JavaVM *vm, JNIEnv *env);\n\ntypedef struct wcdb_moddef_t {\n    const char *name;\n    void *func;\n} wcdb_moddef_t;\n\nstatic wcdb_moddef_t *g_moddef[WCDB_INITTAG_COUNT] = {0};\nstatic size_t g_moddef_num[WCDB_INITTAG_COUNT] = {0};\nstatic size_t g_moddef_capacity[WCDB_INITTAG_COUNT] = {0};\n\nvoid register_module_func(const char *name, void *func, unsigned tag)\n{\n    if (g_moddef_num[tag] == g_moddef_capacity[tag]) {\n        size_t new_size =\n            g_moddef_capacity[tag] ? g_moddef_capacity[tag] * 2 : 16;\n        void *ptr = realloc(g_moddef[tag], new_size * sizeof(wcdb_moddef_t));\n        if (!ptr)\n            *(char *) (0xdeadbeaf) = 0;\n\n        g_moddef[tag] = (wcdb_moddef_t *) ptr;\n        g_moddef_capacity[tag] = new_size;\n    }\n\n    wcdb_moddef_t *mod = g_moddef[tag] + (g_moddef_num[tag]++);\n    mod->name = name;\n    mod->func = func;\n}\n\nJNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *reserved)\n{\n    JNIEnv *env;\n    if ((*vm)->GetEnv(vm, (void **) (&env), JNI_VERSION_1_6) != JNI_OK)\n        return -1;\n\n    wcdb_moddef_t *mod = g_moddef[WCDB_INITTAG_JNI_INIT];\n    size_t num_mod = g_moddef_num[WCDB_INITTAG_JNI_INIT];\n\n    int i;\n    for (i = 0; i < num_mod; i++) {\n        LOGI(LOG_TAG, \"Initialize JNI module (%d/%d) %s...\", i + 1,\n             (int) num_mod, mod->name);\n        int ret = ((jni_init_func_t)(mod->func))(vm, env);\n        if (ret != 0)\n            return ret;\n        mod++;\n    }\n\n    return JNI_VERSION_1_6;\n}\n\nJNIEXPORT void JNICALL JNI_OnUnload(JavaVM *vm, void *reserved)\n{\n    JNIEnv *env;\n    if ((*vm)->GetEnv(vm, (void **) (&env), JNI_VERSION_1_6) != JNI_OK)\n        return;\n\n    wcdb_moddef_t *mod = g_moddef[WCDB_INITTAG_JNI_FINI];\n    size_t num_mod = g_moddef_num[WCDB_INITTAG_JNI_FINI];\n    while (num_mod--) {\n        LOGI(LOG_TAG, \"Finalize JNI module '%s'...\", mod->name);\n        ((jni_init_func_t)(mod->func))(vm, env);\n        mod++;\n    }\n}\n\nstatic void __attribute__((destructor)) wcdb_init_destroy()\n{\n    int i;\n    for (i = 0; i < WCDB_INITTAG_COUNT; i++)\n        free(g_moddef[i]);\n}\n"
  },
  {
    "path": "deprecated/android/jni/ModuleLoader.h",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#ifndef __WCDB_MODULE_LOADER_H__\n#define __WCDB_MODULE_LOADER_H__\n\ntypedef struct sqlite3 sqlite3;\n\ntypedef enum wcdb_inittag_t {\n    WCDB_INITTAG_INVALID = -1,\n\n    WCDB_INITTAG_JNI_INIT,\n    WCDB_INITTAG_JNI_FINI,\n\n    WCDB_INITTAG_COUNT\n} wcdb_inittag_t;\n\n// typedef int (*jni_init_func_t)(JavaVM *vm, JNIEnv *env);\n// typedef int (*dbconn_init_func_t)(sqlite3 *db, char **errmsg, const void *);\n\n#define WCDB_INITTAG_DEFINE(name, func, tag)                                   \\\n    static void __attribute__((constructor)) __WCDB__##tag##name()             \\\n    {                                                                          \\\n        register_module_func(#name, (void *) (func), (tag));                   \\\n    }\n\n#define WCDB_JNI_INIT(name, func)                                              \\\n    WCDB_INITTAG_DEFINE(name, func, WCDB_INITTAG_JNI_INIT)\n#define WCDB_JNI_FINI(name, func)                                              \\\n    WCDB_INITTAG_DEFINE(name, func, WCDB_INITTAG_JNI_FINI)\n\n#ifdef __cplusplus\n#define WECHAT_EXPORT extern \"C\"\n#else\n#define WECHAT_EXPORT\n#endif\n\nWECHAT_EXPORT void\nregister_module_func(const char *name, void *func, unsigned tag);\n\n#endif\n"
  },
  {
    "path": "deprecated/android/jni/Mutex.h",
    "content": "/*\n * Copyright (C) 2007 The Android Open Source Project\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#ifndef _LIBS_UTILS_MUTEX_H\n#define _LIBS_UTILS_MUTEX_H\n\n#include <pthread.h>\n#include <stdint.h>\n#include <sys/types.h>\n#include <time.h>\n\n#include \"Errors.h\"\n\n// ---------------------------------------------------------------------------\nnamespace wcdb {\n// ---------------------------------------------------------------------------\n\nclass Condition;\n\n/*\n    * Simple mutex class.  The implementation is system-dependent.\n    *\n    * The mutex must be unlocked by the thread that locked it.  They are not\n    * recursive, i.e. the same thread can't lock it multiple times.\n    */\nclass Mutex {\npublic:\n    enum { PRIVATE = 0, SHARED = 1 };\n\n    Mutex();\n    Mutex(const char *name);\n    Mutex(int type, const char *name = NULL);\n    ~Mutex();\n\n    // lock or unlock the mutex\n    status_t lock();\n    void unlock();\n\n    // lock if possible; returns 0 on success, error otherwise\n    status_t tryLock();\n\n    // Manages the mutex automatically. It'll be locked when Autolock is\n    // constructed and released when Autolock goes out of scope.\n    class Autolock {\n    public:\n        inline Autolock(Mutex &mutex) : mLock(mutex) { mLock.lock(); }\n        inline Autolock(Mutex *mutex) : mLock(*mutex) { mLock.lock(); }\n        inline ~Autolock() { mLock.unlock(); }\n\n    private:\n        Mutex &mLock;\n    };\n\nprivate:\n    friend class Condition;\n\n    // A mutex cannot be copied\n    Mutex(const Mutex &);\n    Mutex &operator=(const Mutex &);\n\n    pthread_mutex_t mMutex;\n};\n\n// ---------------------------------------------------------------------------\n\ninline Mutex::Mutex()\n{\n    pthread_mutex_init(&mMutex, NULL);\n}\n\ninline Mutex::Mutex(const char *name)\n{\n    pthread_mutex_init(&mMutex, NULL);\n}\n\ninline Mutex::Mutex(int type, const char *name)\n{\n    if (type == SHARED) {\n        pthread_mutexattr_t attr;\n        pthread_mutexattr_init(&attr);\n        pthread_mutexattr_setpshared(&attr, PTHREAD_PROCESS_SHARED);\n        pthread_mutex_init(&mMutex, &attr);\n        pthread_mutexattr_destroy(&attr);\n    } else {\n        pthread_mutex_init(&mMutex, NULL);\n    }\n}\n\ninline Mutex::~Mutex()\n{\n    pthread_mutex_destroy(&mMutex);\n}\n\ninline status_t Mutex::lock()\n{\n    return -pthread_mutex_lock(&mMutex);\n}\n\ninline void Mutex::unlock()\n{\n    pthread_mutex_unlock(&mMutex);\n}\n\ninline status_t Mutex::tryLock()\n{\n    return -pthread_mutex_trylock(&mMutex);\n}\n\n// ---------------------------------------------------------------------------\n\n/*\n    * Automatic mutex.  Declare one of these at the top of a function.\n    * When the function returns, it will go out of scope, and release the\n    * mutex.\n    */\ntypedef Mutex::Autolock AutoMutex;\n\n// ---------------------------------------------------------------------------\n}; // namespace wcdb\n// ---------------------------------------------------------------------------\n\n#endif // _LIBS_UTILS_MUTEX_H\n"
  },
  {
    "path": "deprecated/android/jni/SQLiteCommon.cpp",
    "content": "/*\n * Copyright (C) 2011 The Android Open Source Project\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n#define LOG_TAG \"WCDB.SQLiteCommon\"\n#include \"SQLiteCommon.h\"\n#include <stdio.h>\n#include <stdlib.h>\n\nnamespace wcdb {\n\n/** \n * Throw a SQLiteException with a message appropriate for the error in handle.\n */\nvoid throw_sqlite3_exception(JNIEnv *env, sqlite3 *handle)\n{\n    throw_sqlite3_exception(env, handle, NULL);\n}\n\n/** Throw a SQLiteException with the given message */\nvoid throw_sqlite3_exception(JNIEnv *env, const char *message)\n{\n    throw_sqlite3_exception(env, NULL, message);\n}\n\n/** \n * Throw a SQLiteException with a message appropriate for the error in handle\n * concatenated with the given message.\n */\nvoid throw_sqlite3_exception(JNIEnv *env, sqlite3 *handle, const char *message)\n{\n    if (handle) {\n        // get the error code and message from the SQLite connection\n        // the error message may contain more information than the error code\n        // because it is based on the extended error code rather than the simplified\n        // error code that SQLite normally returns.\n        throw_sqlite3_exception(env, sqlite3_extended_errcode(handle),\n                                sqlite3_system_errno(handle),\n                                sqlite3_errmsg(handle), message);\n    } else {\n        // we use SQLITE_OK so that a generic SQLiteException is thrown;\n        // any code not specified in the switch statement below would do.\n        throw_sqlite3_exception(env, SQLITE_OK, \"unknown error\", message);\n    }\n}\n\n/** \n * Throw a SQLiteException for a given error code should only be used when the\n * database connection is not available because the error information will not \n * be quite as rich.\n */\nvoid throw_sqlite3_exception_errcode(JNIEnv *env,\n                                     int errcode,\n                                     const char *message)\n{\n    throw_sqlite3_exception(env, errcode, \"unknown error\", message);\n}\n\n/** \n * Throw a SQLiteException for a given error code, sqlite3message, and user \n * message. \n */\nvoid throw_sqlite3_exception(JNIEnv *env,\n                             int errcode,\n                             const char *sqlite3Message,\n                             const char *message)\n{\n    throw_sqlite3_exception(env, errcode, -1, sqlite3Message, message);\n}\n\n/** \n * Throw a SQLiteException for a given error code, errno, sqlite3message, \n * and user message.\n */\nvoid throw_sqlite3_exception(JNIEnv *env,\n                             int errcode,\n                             int sysErrno,\n                             const char *sqlite3Message,\n                             const char *message)\n{\n    const char *exceptionClass;\n    switch (errcode & 0xff) { /* mask off extended error code */\n        case SQLITE_IOERR:\n            exceptionClass = \"com/tencent/wcdb/database/SQLiteDiskIOException\";\n            break;\n        case SQLITE_CORRUPT:\n        case SQLITE_NOTADB: // treat \"unsupported file format\" error as corruption also\n            exceptionClass =\n                \"com/tencent/wcdb/database/SQLiteDatabaseCorruptException\";\n            break;\n        case SQLITE_CONSTRAINT:\n            exceptionClass =\n                \"com/tencent/wcdb/database/SQLiteConstraintException\";\n            break;\n        case SQLITE_ABORT:\n            exceptionClass = \"com/tencent/wcdb/database/SQLiteAbortException\";\n            break;\n        case SQLITE_DONE:\n            exceptionClass = \"com/tencent/wcdb/database/SQLiteDoneException\";\n            sqlite3Message =\n                NULL; // SQLite error message is irrelevant in this case\n            break;\n        case SQLITE_FULL:\n            exceptionClass = \"com/tencent/wcdb/database/SQLiteFullException\";\n            break;\n        case SQLITE_MISUSE:\n            exceptionClass = \"com/tencent/wcdb/database/SQLiteMisuseException\";\n            break;\n        case SQLITE_PERM:\n            exceptionClass =\n                \"com/tencent/wcdb/database/SQLiteAccessPermException\";\n            break;\n        case SQLITE_BUSY:\n            exceptionClass =\n                \"com/tencent/wcdb/database/SQLiteDatabaseLockedException\";\n            break;\n        case SQLITE_LOCKED:\n            exceptionClass =\n                \"com/tencent/wcdb/database/SQLiteTableLockedException\";\n            break;\n        case SQLITE_READONLY:\n            exceptionClass =\n                \"com/tencent/wcdb/database/SQLiteReadOnlyDatabaseException\";\n            break;\n        case SQLITE_CANTOPEN:\n            exceptionClass =\n                \"com/tencent/wcdb/database/SQLiteCantOpenDatabaseException\";\n            break;\n        case SQLITE_TOOBIG:\n            exceptionClass =\n                \"com/tencent/wcdb/database/SQLiteBlobTooBigException\";\n            break;\n        case SQLITE_RANGE:\n            exceptionClass = \"com/tencent/wcdb/database/\"\n                             \"SQLiteBindOrColumnIndexOutOfRangeException\";\n            break;\n        case SQLITE_NOMEM:\n            exceptionClass =\n                \"com/tencent/wcdb/database/SQLiteOutOfMemoryException\";\n            break;\n        case SQLITE_MISMATCH:\n            exceptionClass =\n                \"com/tencent/wcdb/database/SQLiteDatatypeMismatchException\";\n            break;\n        case SQLITE_INTERRUPT:\n            exceptionClass =\n                \"com/tencent/wcdb/support/OperationCanceledException\";\n            break;\n        default:\n            exceptionClass = \"com/tencent/wcdb/database/SQLiteException\";\n            break;\n    }\n\n    if (sqlite3Message) {\n        char buf[2048];\n        snprintf(buf, sizeof(buf), \"%s (code %d, errno %d): %s\", sqlite3Message,\n                 errcode, sysErrno, message ? message : \"\");\n        jniThrowException(env, exceptionClass, buf);\n    } else {\n        jniThrowException(env, exceptionClass, message);\n    }\n}\n\nvoid throw_sqlite3_exception_format(JNIEnv *env,\n                                    sqlite3 *handle,\n                                    const char *fmt,\n                                    ...)\n{\n    char buf[256];\n    va_list ap;\n\n    va_start(ap, fmt);\n    vsnprintf(buf, sizeof(buf), fmt, ap);\n    va_end(ap);\n\n    throw_sqlite3_exception(env, handle, buf);\n}\n\n} // namespace wcdb\n"
  },
  {
    "path": "deprecated/android/jni/SQLiteCommon.h",
    "content": "/*\n * Copyright (C) 2007 The Android Open Source Project\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#ifndef __WCDB_SQLITE_COMMON_H__\n#define __WCDB_SQLITE_COMMON_H__\n\n#include \"JNIHelp.h\"\n#include <jni.h>\n\n#include <sqlite3.h>\n\n// Special log tags defined in SQLiteDebug.java.\n#define SQLITE_LOG_TAG \"SQLiteLog\"\n#define SQLITE_TRACE_TAG \"SQLiteStatements\"\n#define SQLITE_PROFILE_TAG \"SQLiteTime\"\n\nnamespace wcdb {\n\n#define FIND_CLASS(var, className)                                             \\\n    var = env->FindClass(className);                                           \\\n    LOG_FATAL_IF(!var, \"Unable to find class \" className);\n\n#define GET_STATIC_FIELD_ID(var, clazz, fieldName, fieldDescriptor)            \\\n    var = env->GetStaticFieldID(clazz, fieldName, fieldDescriptor);            \\\n    LOG_FATAL_IF(!var, \"Unable to find field \" fieldName);\n\n#define GET_METHOD_ID(var, clazz, methodName, fieldDescriptor)                 \\\n    var = env->GetMethodID(clazz, methodName, fieldDescriptor);                \\\n    LOG_FATAL_IF(!var, \"Unable to find method\" methodName);\n\n#define GET_FIELD_ID(var, clazz, fieldName, fieldDescriptor)                   \\\n    var = env->GetFieldID(clazz, fieldName, fieldDescriptor);                  \\\n    LOG_FATAL_IF(!var, \"Unable to find field \" fieldName);\n\n/* throw a SQLiteException with a message appropriate for the error in handle */\nvoid throw_sqlite3_exception(JNIEnv *env, sqlite3 *handle);\n\n/* throw a SQLiteException with the given message */\nvoid throw_sqlite3_exception(JNIEnv *env, const char *message);\n\n/* throw a SQLiteException with a message appropriate for the error in handle\n       concatenated with the given message\n     */\nvoid throw_sqlite3_exception(JNIEnv *env, sqlite3 *handle, const char *message);\n\n/* throw a SQLiteException for a given error code */\nvoid throw_sqlite3_exception_errcode(JNIEnv *env,\n                                     int errcode,\n                                     const char *message);\n\nvoid throw_sqlite3_exception(JNIEnv *env,\n                             int errcode,\n                             const char *sqlite3Message,\n                             const char *message);\n\nvoid throw_sqlite3_exception(JNIEnv *env,\n                             int errcode,\n                             int sysErrno,\n                             const char *sqlite3Message,\n                             const char *message);\n\nvoid throw_sqlite3_exception_format(JNIEnv *env,\n                                    sqlite3 *handle,\n                                    const char *fmt,\n                                    ...);\n}\n\n#endif // _ANDROID_DATABASE_SQLITE_COMMON_H\n"
  },
  {
    "path": "deprecated/android/jni/Unicode.cpp",
    "content": "/*\n * Copyright (C) 2005 The Android Open Source Project\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"Unicode.h\"\n\n#include <stddef.h>\n\n#ifdef HAVE_WINSOCK\n#undef nhtol\n#undef htonl\n#undef nhtos\n#undef htons\n\n#ifdef HAVE_LITTLE_ENDIAN\n#define ntohl(x)                                                               \\\n    (((x) << 24) | (((x) >> 24) & 255) | (((x) << 8) & 0xff0000) |             \\\n     (((x) >> 8) & 0xff00))\n#define htonl(x) ntohl(x)\n#define ntohs(x) ((((x) << 8) & 0xff00) | (((x) >> 8) & 255))\n#define htons(x) ntohs(x)\n#else\n#define ntohl(x) (x)\n#define htonl(x) (x)\n#define ntohs(x) (x)\n#define htons(x) (x)\n#endif\n#else\n#include <netinet/in.h>\n#endif\n\nextern \"C\" {\n\nstatic const uint32_t kByteMask = 0x000000BF;\nstatic const uint32_t kByteMark = 0x00000080;\n\n// Surrogates aren't valid for UTF-32 characters, so define some\n// constants that will let us screen them out.\nstatic const uint32_t kUnicodeSurrogateHighStart = 0x0000D800;\nstatic const uint32_t kUnicodeSurrogateHighEnd = 0x0000DBFF;\nstatic const uint32_t kUnicodeSurrogateLowStart = 0x0000DC00;\nstatic const uint32_t kUnicodeSurrogateLowEnd = 0x0000DFFF;\nstatic const uint32_t kUnicodeSurrogateStart = kUnicodeSurrogateHighStart;\nstatic const uint32_t kUnicodeSurrogateEnd = kUnicodeSurrogateLowEnd;\nstatic const uint32_t kUnicodeMaxCodepoint = 0x0010FFFF;\n\n// Mask used to set appropriate bits in first byte of UTF-8 sequence,\n// indexed by number of bytes in the sequence.\n// 0xxxxxxx\n// -> (00-7f) 7bit. Bit mask for the first byte is 0x00000000\n// 110yyyyx 10xxxxxx\n// -> (c0-df)(80-bf) 11bit. Bit mask is 0x000000C0\n// 1110yyyy 10yxxxxx 10xxxxxx\n// -> (e0-ef)(80-bf)(80-bf) 16bit. Bit mask is 0x000000E0\n// 11110yyy 10yyxxxx 10xxxxxx 10xxxxxx\n// -> (f0-f7)(80-bf)(80-bf)(80-bf) 21bit. Bit mask is 0x000000F0\nstatic const uint32_t kFirstByteMark[] = {0x00000000, 0x00000000, 0x000000C0,\n                                          0x000000E0, 0x000000F0};\n\n// --------------------------------------------------------------------------\n// UTF-32\n// --------------------------------------------------------------------------\n\n/**\n     * Return number of UTF-8 bytes required for the character. If the character\n     * is invalid, return size of 0.\n     */\nstatic inline size_t utf32_codepoint_utf8_length(uint32_t srcChar)\n{\n    // Figure out how many bytes the result will require.\n    if (srcChar < 0x00000080) {\n        return 1;\n    } else if (srcChar < 0x00000800) {\n        return 2;\n    } else if (srcChar < 0x00010000) {\n        if ((srcChar < kUnicodeSurrogateStart) ||\n            (srcChar > kUnicodeSurrogateEnd)) {\n            return 3;\n        } else {\n            // Surrogates are invalid UTF-32 characters.\n            return 0;\n        }\n    }\n    // Max code point for Unicode is 0x0010FFFF.\n    else if (srcChar <= kUnicodeMaxCodepoint) {\n        return 4;\n    } else {\n        // Invalid UTF-32 character.\n        return 0;\n    }\n}\n\n// Write out the source character to <dstP>.\n\nstatic inline void\nutf32_codepoint_to_utf8(uint8_t *dstP, uint32_t srcChar, size_t bytes)\n{\n    dstP += bytes;\n    switch (bytes) { /* note: everything falls through. */\n        case 4:\n            *--dstP = (uint8_t)((srcChar | kByteMark) & kByteMask);\n            srcChar >>= 6;\n        case 3:\n            *--dstP = (uint8_t)((srcChar | kByteMark) & kByteMask);\n            srcChar >>= 6;\n        case 2:\n            *--dstP = (uint8_t)((srcChar | kByteMark) & kByteMask);\n            srcChar >>= 6;\n        case 1:\n            *--dstP = (uint8_t)(srcChar | kFirstByteMark[bytes]);\n    }\n}\n\nsize_t strlen32(const uint32_t *s)\n{\n    const uint32_t *ss = s;\n    while (*ss)\n        ss++;\n    return ss - s;\n}\n\nsize_t strnlen32(const uint32_t *s, size_t maxlen)\n{\n    const uint32_t *ss = s;\n    while ((maxlen > 0) && *ss) {\n        ss++;\n        maxlen--;\n    }\n    return ss - s;\n}\n\nstatic inline int32_t utf32_at_internal(const char *cur, size_t *num_read)\n{\n    const char first_char = *cur;\n    if ((first_char & 0x80) == 0) { // ASCII\n        *num_read = 1;\n        return *cur;\n    }\n    cur++;\n    uint32_t mask, to_ignore_mask;\n    size_t num_to_read = 0;\n    uint32_t utf32 = first_char;\n    for (num_to_read = 1, mask = 0x40, to_ignore_mask = 0xFFFFFF80;\n         (first_char & mask);\n         num_to_read++, to_ignore_mask |= mask, mask >>= 1) {\n        // 0x3F == 00111111\n        utf32 = (utf32 << 6) + (*cur++ & 0x3F);\n    }\n    to_ignore_mask |= mask;\n    utf32 &= ~(to_ignore_mask << (6 * (num_to_read - 1)));\n\n    *num_read = num_to_read;\n    return static_cast<int32_t>(utf32);\n}\n\nint32_t utf32_from_utf8_at(const char *src,\n                           size_t src_len,\n                           size_t index,\n                           size_t *next_index)\n{\n    if (index >= src_len) {\n        return -1;\n    }\n    size_t dummy_index;\n    if (next_index == NULL) {\n        next_index = &dummy_index;\n    }\n    size_t num_read;\n    int32_t ret = utf32_at_internal(src + index, &num_read);\n    if (ret >= 0) {\n        *next_index = index + num_read;\n    }\n\n    return ret;\n}\n\nssize_t utf32_to_utf8_length(const uint32_t *src, size_t src_len)\n{\n    if (src == NULL || src_len == 0) {\n        return -1;\n    }\n\n    size_t ret = 0;\n    const uint32_t *end = src + src_len;\n    while (src < end) {\n        ret += utf32_codepoint_utf8_length(*src++);\n    }\n    return ret;\n}\n\nvoid utf32_to_utf8(const uint32_t *src, size_t src_len, char *dst)\n{\n    if (src == NULL || src_len == 0 || dst == NULL) {\n        return;\n    }\n\n    const uint32_t *cur_utf32 = src;\n    const uint32_t *end_utf32 = src + src_len;\n    char *cur = dst;\n    while (cur_utf32 < end_utf32) {\n        size_t len = utf32_codepoint_utf8_length(*cur_utf32);\n        utf32_codepoint_to_utf8((uint8_t *) cur, *cur_utf32++, len);\n        cur += len;\n    }\n    *cur = '\\0';\n}\n\n// --------------------------------------------------------------------------\n// UTF-16\n// --------------------------------------------------------------------------\n\nint strcmp16(const uint16_t *s1, const uint16_t *s2)\n{\n    uint16_t ch;\n    int d = 0;\n\n    while (1) {\n        d = (int) (ch = *s1++) - (int) *s2++;\n        if (d || !ch)\n            break;\n    }\n\n    return d;\n}\n\nint strncmp16(const uint16_t *s1, const uint16_t *s2, size_t n)\n{\n    uint16_t ch;\n    int d = 0;\n\n    while (n--) {\n        d = (int) (ch = *s1++) - (int) *s2++;\n        if (d || !ch)\n            break;\n    }\n\n    return d;\n}\n\nuint16_t *strcpy16(uint16_t *dst, const uint16_t *src)\n{\n    uint16_t *q = dst;\n    const uint16_t *p = src;\n    uint16_t ch;\n\n    do {\n        *q++ = ch = *p++;\n    } while (ch);\n\n    return dst;\n}\n\nsize_t strlen16(const uint16_t *s)\n{\n    const uint16_t *ss = s;\n    while (*ss)\n        ss++;\n    return ss - s;\n}\n\nuint16_t *strncpy16(uint16_t *dst, const uint16_t *src, size_t n)\n{\n    uint16_t *q = dst;\n    const uint16_t *p = src;\n    char ch;\n\n    while (n) {\n        n--;\n        *q++ = ch = *p++;\n        if (!ch)\n            break;\n    }\n\n    *q = 0;\n\n    return dst;\n}\n\nsize_t strnlen16(const uint16_t *s, size_t maxlen)\n{\n    const uint16_t *ss = s;\n\n    /* Important: the maxlen test must precede the reference through ss;\n           since the byte beyond the maximum may segfault */\n    while ((maxlen > 0) && *ss) {\n        ss++;\n        maxlen--;\n    }\n    return ss - s;\n}\n\nint strzcmp16(const uint16_t *s1, size_t n1, const uint16_t *s2, size_t n2)\n{\n    const uint16_t *e1 = s1 + n1;\n    const uint16_t *e2 = s2 + n2;\n\n    while (s1 < e1 && s2 < e2) {\n        const int d = (int) *s1++ - (int) *s2++;\n        if (d) {\n            return d;\n        }\n    }\n\n    return n1 < n2 ? (0 - (int) *s2) : (n1 > n2 ? ((int) *s1 - 0) : 0);\n}\n\nint strzcmp16_h_n(const uint16_t *s1H,\n                  size_t n1,\n                  const uint16_t *s2N,\n                  size_t n2)\n{\n    const uint16_t *e1 = s1H + n1;\n    const uint16_t *e2 = s2N + n2;\n\n    while (s1H < e1 && s2N < e2) {\n        const uint16_t c2 = ntohs(*s2N);\n        const int d = (int) *s1H++ - (int) c2;\n        s2N++;\n        if (d) {\n            return d;\n        }\n    }\n\n    return n1 < n2 ? (0 - (int) ntohs(*s2N)) : (n1 > n2 ? ((int) *s1H - 0) : 0);\n}\n\nvoid utf16_to_utf8(const uint16_t *src, size_t src_len, char *dst)\n{\n    if (src == NULL || src_len == 0 || dst == NULL) {\n        return;\n    }\n\n    const uint16_t *cur_utf16 = src;\n    const uint16_t *const end_utf16 = src + src_len;\n    char *cur = dst;\n    while (cur_utf16 < end_utf16) {\n        uint32_t utf32;\n        // surrogate pairs\n        if ((*cur_utf16 & 0xFC00) == 0xD800) {\n            utf32 = (*cur_utf16++ - 0xD800) << 10;\n            utf32 |= *cur_utf16++ - 0xDC00;\n            utf32 += 0x10000;\n        } else {\n            utf32 = (uint32_t) *cur_utf16++;\n        }\n        const size_t len = utf32_codepoint_utf8_length(utf32);\n        utf32_codepoint_to_utf8((uint8_t *) cur, utf32, len);\n        cur += len;\n    }\n    *cur = '\\0';\n}\n\n// --------------------------------------------------------------------------\n// UTF-8\n// --------------------------------------------------------------------------\n\nssize_t utf8_length(const char *src)\n{\n    const char *cur = src;\n    size_t ret = 0;\n    while (*cur != '\\0') {\n        const char first_char = *cur++;\n        if ((first_char & 0x80) == 0) { // ASCII\n            ret += 1;\n            continue;\n        }\n        // (UTF-8's character must not be like 10xxxxxx,\n        //  but 110xxxxx, 1110xxxx, ... or 1111110x)\n        if ((first_char & 0x40) == 0) {\n            return -1;\n        }\n\n        int32_t mask, to_ignore_mask;\n        size_t num_to_read = 0;\n        uint32_t utf32 = 0;\n        for (num_to_read = 1, mask = 0x40, to_ignore_mask = 0x80;\n             num_to_read < 5 && (first_char & mask);\n             num_to_read++, to_ignore_mask |= mask, mask >>= 1) {\n            if ((*cur & 0xC0) != 0x80) { // must be 10xxxxxx\n                return -1;\n            }\n            // 0x3F == 00111111\n            utf32 = (utf32 << 6) + (*cur++ & 0x3F);\n        }\n        // \"first_char\" must be (110xxxxx - 11110xxx)\n        if (num_to_read == 5) {\n            return -1;\n        }\n        to_ignore_mask |= mask;\n        utf32 |= ((~to_ignore_mask) & first_char) << (6 * (num_to_read - 1));\n        if (utf32 > kUnicodeMaxCodepoint) {\n            return -1;\n        }\n\n        ret += num_to_read;\n    }\n    return ret;\n}\n\nssize_t utf16_to_utf8_length(const uint16_t *src, size_t src_len)\n{\n    if (src == NULL || src_len == 0) {\n        return -1;\n    }\n\n    size_t ret = 0;\n    const uint16_t *const end = src + src_len;\n    while (src < end) {\n        if ((*src & 0xFC00) == 0xD800 && (src + 1) < end &&\n            (*++src & 0xFC00) == 0xDC00) {\n            // surrogate pairs are always 4 bytes.\n            ret += 4;\n            src++;\n        } else {\n            ret += utf32_codepoint_utf8_length((uint32_t) *src++);\n        }\n    }\n    return ret;\n}\n\n/**\n     * Returns 1-4 based on the number of leading bits.\n     *\n     * 1111 -> 4\n     * 1110 -> 3\n     * 110x -> 2\n     * 10xx -> 1\n     * 0xxx -> 1\n     */\nstatic inline size_t utf8_codepoint_len(uint8_t ch)\n{\n    return ((0xe5000000 >> ((ch >> 3) & 0x1e)) & 3) + 1;\n}\n\nstatic inline void utf8_shift_and_mask(uint32_t *codePoint, const uint8_t byte)\n{\n    *codePoint <<= 6;\n    *codePoint |= 0x3F & byte;\n}\n\nsize_t utf8_to_utf32_length(const char *src, size_t src_len)\n{\n    if (src == NULL || src_len == 0) {\n        return 0;\n    }\n    size_t ret = 0;\n    const char *cur;\n    const char *end;\n    size_t num_to_skip;\n    for (cur = src, end = src + src_len, num_to_skip = 1; cur < end;\n         cur += num_to_skip, ret++) {\n        const char first_char = *cur;\n        num_to_skip = 1;\n        if ((first_char & 0x80) == 0) { // ASCII\n            continue;\n        }\n        int32_t mask;\n\n        for (mask = 0x40; (first_char & mask); num_to_skip++, mask >>= 1) {\n        }\n    }\n    return ret;\n}\n\nvoid utf8_to_utf32(const char *src, size_t src_len, uint32_t *dst)\n{\n    if (src == NULL || src_len == 0 || dst == NULL) {\n        return;\n    }\n\n    const char *cur = src;\n    const char *const end = src + src_len;\n    uint32_t *cur_utf32 = dst;\n    while (cur < end) {\n        size_t num_read;\n        *cur_utf32++ = static_cast<uint32_t>(utf32_at_internal(cur, &num_read));\n        cur += num_read;\n    }\n    *cur_utf32 = 0;\n}\n\nstatic inline uint32_t utf8_to_utf32_codepoint(const uint8_t *src,\n                                               size_t length)\n{\n    uint32_t unicode;\n\n    switch (length) {\n        case 1:\n            return src[0];\n        case 2:\n            unicode = src[0] & 0x1f;\n            utf8_shift_and_mask(&unicode, src[1]);\n            return unicode;\n        case 3:\n            unicode = src[0] & 0x0f;\n            utf8_shift_and_mask(&unicode, src[1]);\n            utf8_shift_and_mask(&unicode, src[2]);\n            return unicode;\n        case 4:\n            unicode = src[0] & 0x07;\n            utf8_shift_and_mask(&unicode, src[1]);\n            utf8_shift_and_mask(&unicode, src[2]);\n            utf8_shift_and_mask(&unicode, src[3]);\n            return unicode;\n        default:\n            return 0xffff;\n    }\n\n    //printf(\"Char at %p: len=%d, utf-16=%p\\n\", src, length, (void*)result);\n}\n\nssize_t utf8_to_utf16_length(const uint8_t *u8str, size_t u8len)\n{\n    const uint8_t *const u8end = u8str + u8len;\n    const uint8_t *u8cur = u8str;\n\n    /* Validate that the UTF-8 is the correct len */\n    size_t u16measuredLen = 0;\n    while (u8cur < u8end) {\n        u16measuredLen++;\n        int u8charLen = utf8_codepoint_len(*u8cur);\n        uint32_t codepoint = utf8_to_utf32_codepoint(u8cur, u8charLen);\n        if (codepoint > 0xFFFF)\n            u16measuredLen++; // this will be a surrogate pair in utf16\n        u8cur += u8charLen;\n    }\n\n    /**\n         * Make sure that we ended where we thought we would and the output UTF-16\n         * will be exactly how long we were told it would be.\n         */\n    if (u8cur != u8end) {\n        return -1;\n    }\n\n    return u16measuredLen;\n}\n\nuint16_t *utf8_to_utf16_no_null_terminator(const uint8_t *u8str,\n                                           size_t u8len,\n                                           uint16_t *u16str)\n{\n    const uint8_t *const u8end = u8str + u8len;\n    const uint8_t *u8cur = u8str;\n    uint16_t *u16cur = u16str;\n\n    while (u8cur < u8end) {\n        size_t u8len = utf8_codepoint_len(*u8cur);\n        uint32_t codepoint = utf8_to_utf32_codepoint(u8cur, u8len);\n\n        // Convert the UTF32 codepoint to one or more UTF16 codepoints\n        if (codepoint <= 0xFFFF) {\n            // Single UTF16 character\n            *u16cur++ = (uint16_t) codepoint;\n        } else {\n            // Multiple UTF16 characters with surrogates\n            codepoint = codepoint - 0x10000;\n            *u16cur++ = (uint16_t)((codepoint >> 10) + 0xD800);\n            *u16cur++ = (uint16_t)((codepoint & 0x3FF) + 0xDC00);\n        }\n\n        u8cur += u8len;\n    }\n    return u16cur;\n}\n\nvoid utf8_to_utf16(const uint8_t *u8str, size_t u8len, uint16_t *u16str)\n{\n    uint16_t *end = utf8_to_utf16_no_null_terminator(u8str, u8len, u16str);\n    *end = 0;\n}\n}\n"
  },
  {
    "path": "deprecated/android/jni/Unicode.h",
    "content": "/*\n * Copyright (C) 2005 The Android Open Source Project\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#ifndef ANDROID_UNICODE_H\n#define ANDROID_UNICODE_H\n\n#include <stdint.h>\n#include <sys/types.h>\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n// Standard string functions on char16_t strings.\nint strcmp16(const uint16_t *, const uint16_t *);\nint strncmp16(const uint16_t *s1, const uint16_t *s2, size_t n);\nsize_t strlen16(const uint16_t *);\nsize_t strnlen16(const uint16_t *, size_t);\nuint16_t *strcpy16(uint16_t *, const uint16_t *);\nuint16_t *strncpy16(uint16_t *, const uint16_t *, size_t);\n\n// Version of comparison that supports embedded nulls.\n// This is different than strncmp() because we don't stop\n// at a nul character and consider the strings to be different\n// if the lengths are different (thus we need to supply the\n// lengths of both strings).  This can also be used when\n// your string is not nul-terminated as it will have the\n// equivalent result as strcmp16 (unlike strncmp16).\nint strzcmp16(const uint16_t *s1, size_t n1, const uint16_t *s2, size_t n2);\n\n// Version of strzcmp16 for comparing strings in different endianness.\nint strzcmp16_h_n(const uint16_t *s1H,\n                  size_t n1,\n                  const uint16_t *s2N,\n                  size_t n2);\n\n// Standard string functions on char32_t strings.\nsize_t strlen32(const uint32_t *);\nsize_t strnlen32(const uint32_t *, size_t);\n\n/**\n * Measure the length of a UTF-32 string in UTF-8. If the string is invalid\n * such as containing a surrogate character, -1 will be returned.\n */\nssize_t utf32_to_utf8_length(const uint32_t *src, size_t src_len);\n\n/**\n * Stores a UTF-8 string converted from \"src\" in \"dst\", if \"dst_length\" is not\n * large enough to store the string, the part of the \"src\" string is stored\n * into \"dst\" as much as possible. See the examples for more detail.\n * Returns the size actually used for storing the string.\n * dst\" is not null-terminated when dst_len is fully used (like strncpy).\n *\n * Example 1\n * \"src\" == \\u3042\\u3044 (\\xE3\\x81\\x82\\xE3\\x81\\x84)\n * \"src_len\" == 2\n * \"dst_len\" >= 7\n * ->\n * Returned value == 6\n * \"dst\" becomes \\xE3\\x81\\x82\\xE3\\x81\\x84\\0\n * (note that \"dst\" is null-terminated)\n *\n * Example 2\n * \"src\" == \\u3042\\u3044 (\\xE3\\x81\\x82\\xE3\\x81\\x84)\n * \"src_len\" == 2\n * \"dst_len\" == 5\n * ->\n * Returned value == 3\n * \"dst\" becomes \\xE3\\x81\\x82\\0\n * (note that \"dst\" is null-terminated, but \\u3044 is not stored in \"dst\"\n * since \"dst\" does not have enough size to store the character)\n *\n * Example 3\n * \"src\" == \\u3042\\u3044 (\\xE3\\x81\\x82\\xE3\\x81\\x84)\n * \"src_len\" == 2\n * \"dst_len\" == 6\n * ->\n * Returned value == 6\n * \"dst\" becomes \\xE3\\x81\\x82\\xE3\\x81\\x84\n * (note that \"dst\" is NOT null-terminated, like strncpy)\n */\nvoid utf32_to_utf8(const uint32_t *src, size_t src_len, char *dst);\n\n/**\n * Returns the unicode value at \"index\".\n * Returns -1 when the index is invalid (equals to or more than \"src_len\").\n * If returned value is positive, it is able to be converted to char32_t, which\n * is unsigned. Then, if \"next_index\" is not NULL, the next index to be used is\n * stored in \"next_index\". \"next_index\" can be NULL.\n */\nint32_t utf32_from_utf8_at(const char *src,\n                           size_t src_len,\n                           size_t index,\n                           size_t *next_index);\n\n/**\n * Returns the UTF-8 length of UTF-16 string \"src\".\n */\nssize_t utf16_to_utf8_length(const uint16_t *src, size_t src_len);\n\n/**\n * Converts a UTF-16 string to UTF-8. The destination buffer must be large\n * enough to fit the UTF-16 as measured by utf16_to_utf8_length with an added\n * NULL terminator.\n */\nvoid utf16_to_utf8(const uint16_t *src, size_t src_len, char *dst);\n\n/**\n * Returns the length of \"src\" when \"src\" is valid UTF-8 string.\n * Returns 0 if src is NULL or 0-length string. Returns -1 when the source\n * is an invalid string.\n *\n * This function should be used to determine whether \"src\" is valid UTF-8\n * characters with valid unicode codepoints. \"src\" must be null-terminated.\n *\n * If you are going to use other utf8_to_... functions defined in this header\n * with string which may not be valid UTF-8 with valid codepoint (form 0 to\n * 0x10FFFF), you should use this function before calling others, since the\n * other functions do not check whether the string is valid UTF-8 or not.\n *\n * If you do not care whether \"src\" is valid UTF-8 or not, you should use\n * strlen() as usual, which should be much faster.\n */\nssize_t utf8_length(const char *src);\n\n/**\n * Measure the length of a UTF-32 string.\n */\nsize_t utf8_to_utf32_length(const char *src, size_t src_len);\n\n/**\n * Stores a UTF-32 string converted from \"src\" in \"dst\". \"dst\" must be large\n * enough to store the entire converted string as measured by\n * utf8_to_utf32_length plus space for a NULL terminator.\n */\nvoid utf8_to_utf32(const char *src, size_t src_len, uint32_t *dst);\n\n/**\n * Returns the UTF-16 length of UTF-8 string \"src\".\n */\nssize_t utf8_to_utf16_length(const uint8_t *src, size_t srcLen);\n\n/**\n * Convert UTF-8 to UTF-16 including surrogate pairs.\n * Returns a pointer to the end of the string (where a null terminator might go\n * if you wanted to add one).\n */\nuint16_t *utf8_to_utf16_no_null_terminator(const uint8_t *src,\n                                           size_t srcLen,\n                                           uint16_t *dst);\n\n/**\n * Convert UTF-8 to UTF-16 including surrogate pairs. The destination buffer\n * must be large enough to hold the result as measured by utf8_to_utf16_length\n * plus an added NULL terminator.\n */\nvoid utf8_to_utf16(const uint8_t *src, size_t srcLen, uint16_t *dst);\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif\n"
  },
  {
    "path": "deprecated/android/jni/com_tencent_wcdb_CursorWindow.cpp",
    "content": "/*\n * Copyright (C) 2007 The Android Open Source Project\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#undef LOG_TAG\n#define LOG_TAG \"WCDB.CursorWindow\"\n\n#ifndef __STDC_FORMAT_MACROS\n#define __STDC_FORMAT_MACROS\n#endif\n\n#include \"ModuleLoader.h\"\n\n#include <inttypes.h>\n#include <jni.h>\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include <unistd.h>\n\n#include \"CursorWindow.h\"\n#include \"Errors.h\"\n#include \"JNIHelp.h\"\n#include \"Logger.h\"\n#include \"SQLiteCommon.h\"\n#include \"Unicode.h\"\n\nnamespace wcdb {\n\nstatic struct {\n    jfieldID data;\n    jfieldID sizeCopied;\n} gCharArrayBufferClassInfo;\n\nstatic void throwExceptionWithRowCol(JNIEnv *env, jint row, jint column)\n{\n    char buf[256];\n    snprintf(buf, sizeof(buf),\n             \"Couldn't read row %d, col %d from CursorWindow.  \"\n             \"Make sure the Cursor is initialized correctly before accessing \"\n             \"data from it.\",\n             row, column);\n    jniThrowException(env, \"java/lang/IllegalStateException\", buf);\n}\n\nstatic void throwUnknownTypeException(JNIEnv *env, jint type)\n{\n    char buf[128];\n    snprintf(buf, sizeof(buf), \"UNKNOWN type %d\", type);\n    jniThrowException(env, \"java/lang/IllegalStateException\", buf);\n}\n\nstatic jlong\nnativeCreate(JNIEnv *env, jclass clazz, jstring nameObj, jint cursorWindowSize)\n{\n    CursorWindow *window;\n    status_t status = CursorWindow::create(cursorWindowSize, &window);\n    if (status || !window) {\n        LOGE(LOG_TAG,\n             \"Could not allocate CursorWindow of size %d due to error %d.\",\n             cursorWindowSize, status);\n        return 0;\n    }\n\n    //LOGV(LOG_TAG,\"nativeInitializeEmpty: window = %p\", window);\n    return (jlong)(intptr_t) window;\n}\n\nstatic void nativeDispose(JNIEnv *env, jclass clazz, jlong windowPtr)\n{\n    CursorWindow *window = (CursorWindow *) (intptr_t) windowPtr;\n    if (window) {\n        //LOGV(LOG_TAG,\"Closing window %p\", window);\n        delete window;\n    }\n}\n\nstatic void nativeClear(JNIEnv *env, jclass clazz, jlong windowPtr)\n{\n    CursorWindow *window = (CursorWindow *) (intptr_t) windowPtr;\n    LOG_WINDOW(\"Clearing window %p\", window);\n    status_t status = window->clear();\n    if (status) {\n        LOGW(LOG_TAG, \"Could not clear window. error=%d\", status);\n    }\n}\n\nstatic jint nativeGetNumRows(JNIEnv *env, jclass clazz, jlong windowPtr)\n{\n    CursorWindow *window = (CursorWindow *) (intptr_t) windowPtr;\n    return window->getNumRows();\n}\n\nstatic jboolean\nnativeSetNumColumns(JNIEnv *env, jclass clazz, jlong windowPtr, jint columnNum)\n{\n    CursorWindow *window = (CursorWindow *) (intptr_t) windowPtr;\n    status_t status = window->setNumColumns(columnNum);\n    return status == OK;\n}\n\nstatic jboolean nativeAllocRow(JNIEnv *env, jclass clazz, jlong windowPtr)\n{\n    CursorWindow *window = (CursorWindow *) (intptr_t) windowPtr;\n    status_t status = window->allocRow(nullptr);\n    return status == OK;\n}\n\nstatic void nativeFreeLastRow(JNIEnv *env, jclass clazz, jlong windowPtr)\n{\n    CursorWindow *window = (CursorWindow *) (intptr_t) windowPtr;\n    window->freeLastRow();\n}\n\nstatic jint\nnativeGetType(JNIEnv *env, jclass clazz, jlong windowPtr, jint row, jint column)\n{\n    CursorWindow *window = (CursorWindow *) (intptr_t) windowPtr;\n    LOG_WINDOW(\"returning column type affinity for %d,%d from %p\", row, column,\n               window);\n\n    CursorWindow::FieldSlot *fieldSlot = window->getFieldSlot(row, column);\n    if (!fieldSlot) {\n        throwExceptionWithRowCol(env, row, column);\n        return CursorWindow::FIELD_TYPE_NULL;\n    }\n    return window->getFieldSlotType(fieldSlot);\n}\n\nstatic jbyteArray\nnativeGetBlob(JNIEnv *env, jclass clazz, jlong windowPtr, jint row, jint column)\n{\n    CursorWindow *window = (CursorWindow *) (intptr_t) windowPtr;\n    LOG_WINDOW(\"Getting blob for %d,%d from %p\", row, column, window);\n\n    CursorWindow::FieldSlot *fieldSlot = window->getFieldSlot(row, column);\n    if (!fieldSlot) {\n        throwExceptionWithRowCol(env, row, column);\n        return nullptr;\n    }\n\n    int32_t type = window->getFieldSlotType(fieldSlot);\n    if (type == CursorWindow::FIELD_TYPE_BLOB ||\n        type == CursorWindow::FIELD_TYPE_STRING) {\n        size_t size;\n        const void *value = window->getFieldSlotValueBlob(fieldSlot, &size);\n        jbyteArray byteArray = env->NewByteArray(size);\n        if (!byteArray) {\n            env->ExceptionClear();\n            throw_sqlite3_exception(env, \"Native could not create new byte[]\");\n            return nullptr;\n        }\n        env->SetByteArrayRegion(byteArray, 0, size,\n                                static_cast<const jbyte *>(value));\n        return byteArray;\n    } else if (type == CursorWindow::FIELD_TYPE_INTEGER) {\n        throw_sqlite3_exception(env, \"INTEGER data in nativeGetBlob \");\n    } else if (type == CursorWindow::FIELD_TYPE_FLOAT) {\n        throw_sqlite3_exception(env, \"FLOAT data in nativeGetBlob \");\n    } else if (type == CursorWindow::FIELD_TYPE_NULL) {\n        // do nothing\n    } else {\n        throwUnknownTypeException(env, type);\n    }\n    return nullptr;\n}\n\nstatic jstring nativeGetString(\n    JNIEnv *env, jclass clazz, jlong windowPtr, jint row, jint column)\n{\n    CursorWindow *window = (CursorWindow *) (intptr_t) windowPtr;\n    LOG_WINDOW(\"Getting string for %d,%d from %p\", row, column, window);\n\n    CursorWindow::FieldSlot *fieldSlot = window->getFieldSlot(row, column);\n    if (!fieldSlot) {\n        throwExceptionWithRowCol(env, row, column);\n        return nullptr;\n    }\n\n    int32_t type = window->getFieldSlotType(fieldSlot);\n    if (type == CursorWindow::FIELD_TYPE_STRING) {\n        size_t sizeIncludingNull;\n        const char *value =\n            window->getFieldSlotValueString(fieldSlot, &sizeIncludingNull);\n        if (sizeIncludingNull <= 1) {\n            return env->NewStringUTF(\"\");\n        }\n        // Convert to UTF-16 here instead of calling NewStringUTF.  NewStringUTF\n        // doesn't like UTF-8 strings with high codepoints.  It actually expects\n        // Modified UTF-8 with encoded surrogate pairs.\n        ssize_t u16_size = utf8_to_utf16_length((const uint8_t *) value,\n                                                sizeIncludingNull - 1);\n        if (u16_size < 0) {\n            // Invalid UTF-16 detected, return empty string.\n            return env->NewStringUTF(\"\");\n        }\n        uint16_t *u16_buf = new uint16_t[u16_size + 1];\n        utf8_to_utf16((const uint8_t *) value, sizeIncludingNull - 1, u16_buf);\n        jstring ret = env->NewString(u16_buf, u16_size);\n        delete[] u16_buf;\n        return ret;\n    } else if (type == CursorWindow::FIELD_TYPE_INTEGER) {\n        int64_t value = window->getFieldSlotValueLong(fieldSlot);\n        char buf[32];\n        snprintf(buf, sizeof(buf), \"%\" PRId64, value);\n        return env->NewStringUTF(buf);\n    } else if (type == CursorWindow::FIELD_TYPE_FLOAT) {\n        double value = window->getFieldSlotValueDouble(fieldSlot);\n        char buf[32];\n        snprintf(buf, sizeof(buf), \"%g\", value);\n        return env->NewStringUTF(buf);\n    } else if (type == CursorWindow::FIELD_TYPE_NULL) {\n        return nullptr;\n    } else if (type == CursorWindow::FIELD_TYPE_BLOB) {\n        throw_sqlite3_exception(env, \"Unable to convert BLOB to string\");\n        return nullptr;\n    } else {\n        throwUnknownTypeException(env, type);\n        return nullptr;\n    }\n}\n\nstatic jcharArray\nallocCharArrayBuffer(JNIEnv *env, jobject bufferObj, size_t size)\n{\n    jcharArray dataObj = jcharArray(\n        env->GetObjectField(bufferObj, gCharArrayBufferClassInfo.data));\n    if (dataObj && size) {\n        jsize capacity = env->GetArrayLength(dataObj);\n        if (size_t(capacity) < size) {\n            env->DeleteLocalRef(dataObj);\n            dataObj = nullptr;\n        }\n    }\n    if (!dataObj) {\n        jsize capacity = size;\n        if (capacity < 64) {\n            capacity = 64;\n        }\n        dataObj = env->NewCharArray(capacity); // might throw OOM\n        if (dataObj) {\n            env->SetObjectField(bufferObj, gCharArrayBufferClassInfo.data,\n                                dataObj);\n        }\n    }\n    return dataObj;\n}\n\nstatic void fillCharArrayBufferUTF(JNIEnv *env,\n                                   jobject bufferObj,\n                                   const char *str,\n                                   size_t len)\n{\n    ssize_t size =\n        utf8_to_utf16_length(reinterpret_cast<const uint8_t *>(str), len);\n    if (size < 0) {\n        size = 0; // invalid UTF8 string\n    }\n    jcharArray dataObj = allocCharArrayBuffer(env, bufferObj, size);\n    if (dataObj) {\n        if (size) {\n            jchar *data = static_cast<jchar *>(\n                env->GetPrimitiveArrayCritical(dataObj, nullptr));\n            utf8_to_utf16_no_null_terminator(\n                reinterpret_cast<const uint8_t *>(str), len,\n                reinterpret_cast<uint16_t *>(data));\n            env->ReleasePrimitiveArrayCritical(dataObj, data, 0);\n        }\n        env->SetIntField(bufferObj, gCharArrayBufferClassInfo.sizeCopied, size);\n    }\n}\n\nstatic void clearCharArrayBuffer(JNIEnv *env, jobject bufferObj)\n{\n    jcharArray dataObj = allocCharArrayBuffer(env, bufferObj, 0);\n    if (dataObj) {\n        env->SetIntField(bufferObj, gCharArrayBufferClassInfo.sizeCopied, 0);\n    }\n}\n\nstatic void nativeCopyStringToBuffer(JNIEnv *env,\n                                     jclass clazz,\n                                     jlong windowPtr,\n                                     jint row,\n                                     jint column,\n                                     jobject bufferObj)\n{\n    CursorWindow *window = (CursorWindow *) (intptr_t) windowPtr;\n    LOG_WINDOW(\"Copying string for %d,%d from %p\", row, column, window);\n\n    CursorWindow::FieldSlot *fieldSlot = window->getFieldSlot(row, column);\n    if (!fieldSlot) {\n        throwExceptionWithRowCol(env, row, column);\n        return;\n    }\n\n    int32_t type = window->getFieldSlotType(fieldSlot);\n    if (type == CursorWindow::FIELD_TYPE_STRING) {\n        size_t sizeIncludingNull;\n        const char *value =\n            window->getFieldSlotValueString(fieldSlot, &sizeIncludingNull);\n        if (sizeIncludingNull > 1) {\n            fillCharArrayBufferUTF(env, bufferObj, value,\n                                   sizeIncludingNull - 1);\n        } else {\n            clearCharArrayBuffer(env, bufferObj);\n        }\n    } else if (type == CursorWindow::FIELD_TYPE_INTEGER) {\n        int64_t value = window->getFieldSlotValueLong(fieldSlot);\n        char buf[32];\n        snprintf(buf, sizeof(buf), \"%\" PRId64, value);\n        fillCharArrayBufferUTF(env, bufferObj, buf, strlen(buf));\n    } else if (type == CursorWindow::FIELD_TYPE_FLOAT) {\n        double value = window->getFieldSlotValueDouble(fieldSlot);\n        char buf[32];\n        snprintf(buf, sizeof(buf), \"%g\", value);\n        fillCharArrayBufferUTF(env, bufferObj, buf, strlen(buf));\n    } else if (type == CursorWindow::FIELD_TYPE_NULL) {\n        clearCharArrayBuffer(env, bufferObj);\n    } else if (type == CursorWindow::FIELD_TYPE_BLOB) {\n        throw_sqlite3_exception(env, \"Unable to convert BLOB to string\");\n    } else {\n        throwUnknownTypeException(env, type);\n    }\n}\n\nstatic jlong\nnativeGetLong(JNIEnv *env, jclass clazz, jlong windowPtr, jint row, jint column)\n{\n    CursorWindow *window = (CursorWindow *) (intptr_t) windowPtr;\n    LOG_WINDOW(\"Getting long for %d,%d from %p\", row, column, window);\n\n    CursorWindow::FieldSlot *fieldSlot = window->getFieldSlot(row, column);\n    if (!fieldSlot) {\n        throwExceptionWithRowCol(env, row, column);\n        return 0;\n    }\n\n    int32_t type = window->getFieldSlotType(fieldSlot);\n    if (type == CursorWindow::FIELD_TYPE_INTEGER) {\n        return window->getFieldSlotValueLong(fieldSlot);\n    } else if (type == CursorWindow::FIELD_TYPE_STRING) {\n        size_t sizeIncludingNull;\n        const char *value =\n            window->getFieldSlotValueString(fieldSlot, &sizeIncludingNull);\n        return sizeIncludingNull > 1 ? strtoll(value, nullptr, 0) : 0L;\n    } else if (type == CursorWindow::FIELD_TYPE_FLOAT) {\n        return jlong(window->getFieldSlotValueDouble(fieldSlot));\n    } else if (type == CursorWindow::FIELD_TYPE_NULL) {\n        return 0;\n    } else if (type == CursorWindow::FIELD_TYPE_BLOB) {\n        throw_sqlite3_exception(env, \"Unable to convert BLOB to long\");\n        return 0;\n    } else {\n        throwUnknownTypeException(env, type);\n        return 0;\n    }\n}\n\nstatic jdouble nativeGetDouble(\n    JNIEnv *env, jclass clazz, jlong windowPtr, jint row, jint column)\n{\n    CursorWindow *window = (CursorWindow *) (intptr_t) windowPtr;\n    LOG_WINDOW(\"Getting double for %d,%d from %p\", row, column, window);\n\n    CursorWindow::FieldSlot *fieldSlot = window->getFieldSlot(row, column);\n    if (!fieldSlot) {\n        throwExceptionWithRowCol(env, row, column);\n        return 0.0;\n    }\n\n    int32_t type = window->getFieldSlotType(fieldSlot);\n    if (type == CursorWindow::FIELD_TYPE_FLOAT) {\n        return window->getFieldSlotValueDouble(fieldSlot);\n    } else if (type == CursorWindow::FIELD_TYPE_STRING) {\n        size_t sizeIncludingNull;\n        const char *value =\n            window->getFieldSlotValueString(fieldSlot, &sizeIncludingNull);\n        return sizeIncludingNull > 1 ? strtod(value, nullptr) : 0.0;\n    } else if (type == CursorWindow::FIELD_TYPE_INTEGER) {\n        return jdouble(window->getFieldSlotValueLong(fieldSlot));\n    } else if (type == CursorWindow::FIELD_TYPE_NULL) {\n        return 0.0;\n    } else if (type == CursorWindow::FIELD_TYPE_BLOB) {\n        throw_sqlite3_exception(env, \"Unable to convert BLOB to double\");\n        return 0.0;\n    } else {\n        throwUnknownTypeException(env, type);\n        return 0.0;\n    }\n}\n\nstatic jboolean nativePutBlob(JNIEnv *env,\n                              jclass clazz,\n                              jlong windowPtr,\n                              jbyteArray valueObj,\n                              jint row,\n                              jint column)\n{\n    CursorWindow *window = (CursorWindow *) (intptr_t) windowPtr;\n    jsize len = env->GetArrayLength(valueObj);\n\n    void *value = env->GetPrimitiveArrayCritical(valueObj, nullptr);\n    status_t status = window->putBlob(row, column, value, len);\n    env->ReleasePrimitiveArrayCritical(valueObj, value, JNI_ABORT);\n\n    if (status) {\n        LOGW(LOG_TAG, \"Failed to put blob. error=%d\", status);\n        return false;\n    }\n\n    LOG_WINDOW(\"%d,%d is BLOB with %u bytes\", row, column, len);\n    return true;\n}\n\nstatic jboolean nativePutString(JNIEnv *env,\n                                jclass clazz,\n                                jlong windowPtr,\n                                jstring valueObj,\n                                jint row,\n                                jint column)\n{\n    CursorWindow *window = (CursorWindow *) (intptr_t) windowPtr;\n\n    size_t sizeIncludingNull = env->GetStringUTFLength(valueObj) + 1;\n    const char *valueStr = env->GetStringUTFChars(valueObj, nullptr);\n    if (!valueStr) {\n        LOG_WINDOW(\"value can't be transferred to UTFChars\");\n        return false;\n    }\n    status_t status =\n        window->putString(row, column, valueStr, sizeIncludingNull);\n    env->ReleaseStringUTFChars(valueObj, valueStr);\n\n    if (status) {\n        LOG_WINDOW(\"Failed to put string. error=%d\", status);\n        return false;\n    }\n\n    LOG_WINDOW(\"%d,%d is TEXT with %zu bytes\", row, column, sizeIncludingNull);\n    return true;\n}\n\nstatic jboolean nativePutLong(JNIEnv *env,\n                              jclass clazz,\n                              jlong windowPtr,\n                              jlong value,\n                              jint row,\n                              jint column)\n{\n    CursorWindow *window = (CursorWindow *) (intptr_t) windowPtr;\n    status_t status = window->putLong(row, column, value);\n\n    if (status) {\n        LOG_WINDOW(\"Failed to put long. error=%d\", status);\n        return false;\n    }\n\n    LOG_WINDOW(\"%d,%d is INTEGER 0x%016\" PRIx64, row, column, (uint64_t) value);\n    return true;\n}\n\nstatic jboolean nativePutDouble(JNIEnv *env,\n                                jclass clazz,\n                                jlong windowPtr,\n                                jdouble value,\n                                jint row,\n                                jint column)\n{\n    CursorWindow *window = (CursorWindow *) (intptr_t) windowPtr;\n    status_t status = window->putDouble(row, column, value);\n\n    if (status) {\n        LOG_WINDOW(\"Failed to put double. error=%d\", status);\n        return false;\n    }\n\n    LOG_WINDOW(\"%d,%d is FLOAT %lf\", row, column, value);\n    return true;\n}\n\nstatic jboolean\nnativePutNull(JNIEnv *env, jclass clazz, jlong windowPtr, jint row, jint column)\n{\n    CursorWindow *window = (CursorWindow *) (intptr_t) windowPtr;\n    status_t status = window->putNull(row, column);\n\n    if (status) {\n        LOG_WINDOW(\"Failed to put null. error=%d\", status);\n        return false;\n    }\n\n    LOG_WINDOW(\"%d,%d is NULL\", row, column);\n    return true;\n}\n\nstatic const JNINativeMethod sMethods[] = {\n    /* name, signature, funcPtr */\n    {\"nativeCreate\", \"(Ljava/lang/String;I)J\", (void *) nativeCreate},\n    {\"nativeDispose\", \"(J)V\", (void *) nativeDispose},\n    {\"nativeClear\", \"(J)V\", (void *) nativeClear},\n    {\"nativeGetNumRows\", \"(J)I\", (void *) nativeGetNumRows},\n    {\"nativeSetNumColumns\", \"(JI)Z\", (void *) nativeSetNumColumns},\n    {\"nativeAllocRow\", \"(J)Z\", (void *) nativeAllocRow},\n    {\"nativeFreeLastRow\", \"(J)V\", (void *) nativeFreeLastRow},\n    {\"nativeGetType\", \"(JII)I\", (void *) nativeGetType},\n    {\"nativeGetBlob\", \"(JII)[B\", (void *) nativeGetBlob},\n    {\"nativeGetString\", \"(JII)Ljava/lang/String;\", (void *) nativeGetString},\n    {\"nativeGetLong\", \"(JII)J\", (void *) nativeGetLong},\n    {\"nativeGetDouble\", \"(JII)D\", (void *) nativeGetDouble},\n    {\"nativeCopyStringToBuffer\", \"(JIILandroid/database/CharArrayBuffer;)V\",\n     (void *) nativeCopyStringToBuffer},\n    {\"nativePutBlob\", \"(J[BII)Z\", (void *) nativePutBlob},\n    {\"nativePutString\", \"(JLjava/lang/String;II)Z\", (void *) nativePutString},\n    {\"nativePutLong\", \"(JJII)Z\", (void *) nativePutLong},\n    {\"nativePutDouble\", \"(JDII)Z\", (void *) nativePutDouble},\n    {\"nativePutNull\", \"(JII)Z\", (void *) nativePutNull},\n};\n\nstatic int register_wcdb_CursorWindow(JavaVM *vm, JNIEnv *env)\n{\n    jclass clazz;\n    FIND_CLASS(clazz, \"android/database/CharArrayBuffer\");\n\n    GET_FIELD_ID(gCharArrayBufferClassInfo.data, clazz, \"data\", \"[C\");\n    GET_FIELD_ID(gCharArrayBufferClassInfo.sizeCopied, clazz, \"sizeCopied\",\n                 \"I\");\n\n    return jniRegisterNativeMethods(env, \"com/tencent/wcdb/CursorWindow\",\n                                    sMethods, NELEM(sMethods));\n}\nWCDB_JNI_INIT(CursorWindow, register_wcdb_CursorWindow)\n\n} // namespace wcdb\n"
  },
  {
    "path": "deprecated/android/jni/com_tencent_wcdb_FileUtils.cpp",
    "content": "/* //device/libs/android_runtime/android_util_Process.cpp\n**\n** Copyright 2006, The Android Open Source Project\n**\n** Licensed under the Apache License, Version 2.0 (the \"License\");\n** you may not use this file except in compliance with the License.\n** You may obtain a copy of the License at\n**\n**     http://www.apache.org/licenses/LICENSE-2.0\n**\n** Unless required by applicable law or agreed to in writing, software\n** distributed under the License is distributed on an \"AS IS\" BASIS,\n** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n** See the License for the specific language governing permissions and\n** limitations under the License.\n*/\n\n#define LOG_TAG \"WCDB.FileUtils\"\n\n#include <errno.h>\n#include <jni.h>\n#include <sys/stat.h>\n#include <unistd.h>\n\n#include \"JNIHelp.h\"\n#include \"ModuleLoader.h\"\n\nnamespace wcdb {\n\njint android_os_FileUtils_setPermissions(\n    JNIEnv *env, jobject clazz, jstring file, jint mode, jint uid, jint gid)\n{\n    int ret = 0;\n    if (!file)\n        return ENOENT;\n\n    const char *path = env->GetStringUTFChars(file, nullptr);\n    if (uid >= 0 || gid >= 0) {\n        int res = chown(path, uid, gid);\n        if (res != 0) {\n            ret = errno;\n            goto end;\n        }\n    }\n\n    if (chmod(path, mode) != 0)\n        ret = errno;\n\nend:\n    env->ReleaseStringUTFChars(file, path);\n    return ret;\n}\n\nstatic const JNINativeMethod methods[] = {\n    {\"setPermissions\", \"(Ljava/lang/String;III)I\",\n     (void *) android_os_FileUtils_setPermissions}};\n\nstatic int register_wcdb_FileUtils(JavaVM *vm, JNIEnv *env)\n{\n    return jniRegisterNativeMethods(env, \"com/tencent/wcdb/FileUtils\", methods,\n                                    NELEM(methods));\n}\nWCDB_JNI_INIT(FileUtils, register_wcdb_FileUtils)\n}\n"
  },
  {
    "path": "deprecated/android/jni/com_tencent_wcdb_database_ChunkedCursorWindow.cpp",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#define LOG_TAG \"WCDB.ChunkedCursorWindow\"\n\n#ifndef __STDC_FORMAT_MACROS\n#define __STDC_FORMAT_MACROS\n#endif\n\n#include \"ChunkedCursorWindow.h\"\n#include \"JNIHelp.h\"\n#include \"Logger.h\"\n#include \"ModuleLoader.h\"\n#include \"SQLiteCommon.h\"\n#include \"Unicode.h\"\n#include <inttypes.h>\n#include <jni.h>\n#include <sqlite3.h>\n#include <stdlib.h>\n\nnamespace wcdb {\n\nstatic void throwExceptionWithRowCol(JNIEnv *env, jint row, jint column)\n{\n    char buf[256];\n    snprintf(buf, sizeof(buf),\n             \"Couldn't read row %d, col %d from ChunkedCursorWindow.\", row,\n             column);\n    jniThrowException(env, \"java/lang/IllegalStateException\", buf);\n}\n\nstatic void throwUnknownTypeException(JNIEnv *env, jint type)\n{\n    char buf[128];\n    snprintf(buf, sizeof(buf), \"UNKNOWN type %d\", type);\n    jniThrowException(env, \"java/lang/IllegalStateException\", buf);\n}\n\n/****************************\n     ChunkedCursorWindow\n*****************************/\nstatic jlong nativeCreate(JNIEnv *env, jclass cls, jint capacity)\n{\n    ChunkedCursorWindow *window;\n\n    status_t status = ChunkedCursorWindow::create(capacity, &window);\n    if (status != OK || !window) {\n        LOGE(LOG_TAG,\n             \"Could not allocate CursorWindow of size %d due to error %d.\",\n             capacity, status);\n        return 0;\n    }\n\n    return (jlong)(intptr_t) window;\n}\n\nstatic void nativeDispose(JNIEnv *env, jclass cls, jlong windowPtr)\n{\n    ChunkedCursorWindow *window = (ChunkedCursorWindow *) (intptr_t) windowPtr;\n\n    if (window)\n        delete window;\n}\n\nstatic void nativeClear(JNIEnv *env, jclass cls, jlong windowPtr)\n{\n    ChunkedCursorWindow *window = (ChunkedCursorWindow *) (intptr_t) windowPtr;\n\n    status_t status = window->clear();\n    if (status != OK) {\n        LOGE(LOG_TAG, \"Could not clear window. error=%d\", status);\n    }\n}\n\nstatic jlong\nnativeRemoveChunk(JNIEnv *env, jclass cls, jlong windowPtr, jint pos)\n{\n    ChunkedCursorWindow *window = (ChunkedCursorWindow *) (intptr_t) windowPtr;\n\n    uint32_t start, end;\n    status_t status = window->removeChunk(pos, start, end);\n    if (status != OK)\n        return (jlong) 0xFFFFFFFFFFFFFFFFLL;\n    else\n        return ((jlong) start << 32) | end;\n}\n\nstatic jint nativeGetNumChunks(JNIEnv *env, jclass cls, jlong windowPtr)\n{\n    ChunkedCursorWindow *window = (ChunkedCursorWindow *) (intptr_t) windowPtr;\n    return window->getNumChunks();\n}\n\nstatic jboolean\nnativeSetNumColumns(JNIEnv *env, jclass cls, jlong windowPtr, jint columnNum)\n{\n    ChunkedCursorWindow *window = (ChunkedCursorWindow *) (intptr_t) windowPtr;\n\n    status_t status = window->setNumColumns(columnNum);\n    return status == OK;\n}\n\nstatic jlong nativeGetRow(JNIEnv *env, jclass cls, jlong windowPtr, jint pos)\n{\n    if (pos < 0)\n        return 0;\n\n    ChunkedCursorWindow *window = (ChunkedCursorWindow *) (intptr_t) windowPtr;\n    ChunkedCursorWindow::Row *row = window->getRow(pos);\n\n    return (jlong)(intptr_t) row;\n}\n\nstatic void nativeEndRow(JNIEnv *env, jclass cls, jlong windowPtr, jlong rowPtr)\n{\n    ChunkedCursorWindow *window = (ChunkedCursorWindow *) (intptr_t) windowPtr;\n    ChunkedCursorWindow::Row *row =\n        (ChunkedCursorWindow::Row *) (intptr_t) rowPtr;\n\n    window->endRow(row);\n}\n\nstatic jint nativeGetType(JNIEnv *env, jclass cls, jlong rowPtr, jint column)\n{\n    ChunkedCursorWindow::Row *row =\n        (ChunkedCursorWindow::Row *) (intptr_t) rowPtr;\n\n    ChunkedCursorWindow::Field field = row->getField(column);\n    if (!row->isFieldValid(field)) {\n        throwExceptionWithRowCol(env, row->getRowPos(), column);\n        return 0;\n    }\n\n    return row->getFieldType(field);\n}\n\nstatic jbyteArray\nnativeGetBlob(JNIEnv *env, jclass cls, jlong rowPtr, jint column)\n{\n    ChunkedCursorWindow::Row *row =\n        (ChunkedCursorWindow::Row *) (intptr_t) rowPtr;\n\n    ChunkedCursorWindow::Field field = row->getField(column);\n    if (!row->isFieldValid(field)) {\n        throwExceptionWithRowCol(env, row->getRowPos(), column);\n        return 0;\n    }\n\n    int32_t type = row->getFieldType(field);\n    if (type == CursorWindow::FIELD_TYPE_BLOB ||\n        type == CursorWindow::FIELD_TYPE_STRING) {\n        size_t size;\n        const void *value = row->getFieldBlob(field, size);\n        jbyteArray byteArray = env->NewByteArray(size);\n        if (!byteArray) {\n            env->ExceptionClear();\n            throw_sqlite3_exception(env, \"Native could not create new byte[]\");\n            return nullptr;\n        }\n        env->SetByteArrayRegion(byteArray, 0, size,\n                                static_cast<const jbyte *>(value));\n        return byteArray;\n    } else if (type == CursorWindow::FIELD_TYPE_INTEGER) {\n        throw_sqlite3_exception(env, \"Unable to convert INTEGER to BLOB\");\n    } else if (type == CursorWindow::FIELD_TYPE_FLOAT) {\n        throw_sqlite3_exception(env, \"Unable to convert FLOAT to BLOB\");\n    } else if (type == CursorWindow::FIELD_TYPE_NULL) {\n        // do nothing\n    } else {\n        throwUnknownTypeException(env, type);\n    }\n    return nullptr;\n}\n\nstatic jstring\nnativeGetString(JNIEnv *env, jclass cls, jlong rowPtr, jint column)\n{\n    ChunkedCursorWindow::Row *row =\n        (ChunkedCursorWindow::Row *) (intptr_t) rowPtr;\n\n    ChunkedCursorWindow::Field field = row->getField(column);\n    if (!row->isFieldValid(field)) {\n        throwExceptionWithRowCol(env, row->getRowPos(), column);\n        return 0;\n    }\n\n    int32_t type = row->getFieldType(field);\n    if (type == CursorWindow::FIELD_TYPE_STRING) {\n        size_t sizeIncludingNull;\n        const char *value = row->getFieldString(field, sizeIncludingNull);\n\n        if (sizeIncludingNull <= 1) {\n            return env->NewStringUTF(\"\");\n        }\n\n        // Convert to UTF-16 here instead of calling NewStringUTF.  NewStringUTF\n        // doesn't like UTF-8 strings with high codepoints.  It actually expects\n        // Modified UTF-8 with encoded surrogate pairs.\n        ssize_t u16_size = utf8_to_utf16_length((const uint8_t *) value,\n                                                sizeIncludingNull - 1);\n        if (u16_size < 0) {\n            // Invalid UTF-16 detected, return empty string.\n            return env->NewStringUTF(\"\");\n        }\n        uint16_t *u16_buf = new uint16_t[u16_size + 1];\n        utf8_to_utf16((const uint8_t *) value, sizeIncludingNull - 1, u16_buf);\n        jstring ret = env->NewString(u16_buf, u16_size);\n        delete[] u16_buf;\n        return ret;\n    } else if (type == CursorWindow::FIELD_TYPE_INTEGER) {\n        int64_t value = row->getFieldLong(field);\n        char buf[32];\n        snprintf(buf, sizeof(buf), \"%\" PRId64, value);\n        return env->NewStringUTF(buf);\n    } else if (type == CursorWindow::FIELD_TYPE_FLOAT) {\n        double value = row->getFieldDouble(field);\n        char buf[32];\n        snprintf(buf, sizeof(buf), \"%g\", value);\n        return env->NewStringUTF(buf);\n    } else if (type == CursorWindow::FIELD_TYPE_BLOB) {\n        throw_sqlite3_exception(env, \"Unable to covert BLOB to string\");\n        return nullptr;\n    } else if (type == CursorWindow::FIELD_TYPE_NULL) {\n        return nullptr;\n    } else {\n        throwUnknownTypeException(env, type);\n        return nullptr;\n    }\n}\n\nstatic jlong nativeGetLong(JNIEnv *env, jclass cls, jlong rowPtr, jint column)\n{\n    ChunkedCursorWindow::Row *row =\n        (ChunkedCursorWindow::Row *) (intptr_t) rowPtr;\n\n    ChunkedCursorWindow::Field field = row->getField(column);\n    if (!row->isFieldValid(field)) {\n        throwExceptionWithRowCol(env, row->getRowPos(), column);\n        return 0;\n    }\n\n    int32_t type = row->getFieldType(field);\n    if (type == CursorWindow::FIELD_TYPE_INTEGER) {\n        return row->getFieldLong(field);\n    } else if (type == CursorWindow::FIELD_TYPE_STRING) {\n        size_t sizeIncludingNull;\n        const char *value = row->getFieldString(field, sizeIncludingNull);\n        return sizeIncludingNull > 1 ? strtoll(value, nullptr, 0) : 0L;\n    } else if (type == CursorWindow::FIELD_TYPE_FLOAT) {\n        return jlong(row->getFieldDouble(field));\n    } else if (type == CursorWindow::FIELD_TYPE_NULL) {\n        return 0;\n    } else if (type == CursorWindow::FIELD_TYPE_BLOB) {\n        throw_sqlite3_exception(env, \"Unable to convert BLOB to long\");\n        return 0;\n    } else {\n        throwUnknownTypeException(env, type);\n        return 0;\n    }\n}\n\nstatic jdouble\nnativeGetDouble(JNIEnv *env, jclass clazz, jlong rowPtr, jint column)\n{\n    ChunkedCursorWindow::Row *row =\n        (ChunkedCursorWindow::Row *) (intptr_t) rowPtr;\n\n    ChunkedCursorWindow::Field field = row->getField(column);\n    if (!row->isFieldValid(field)) {\n        throwExceptionWithRowCol(env, row->getRowPos(), column);\n        return 0;\n    }\n\n    int32_t type = row->getFieldType(field);\n    if (type == CursorWindow::FIELD_TYPE_FLOAT) {\n        return row->getFieldDouble(field);\n    } else if (type == CursorWindow::FIELD_TYPE_STRING) {\n        size_t sizeIncludingNull;\n        const char *value = row->getFieldString(field, sizeIncludingNull);\n        return sizeIncludingNull > 1 ? strtod(value, nullptr) : 0.0;\n    } else if (type == CursorWindow::FIELD_TYPE_INTEGER) {\n        return jdouble(row->getFieldLong(field));\n    } else if (type == CursorWindow::FIELD_TYPE_NULL) {\n        return 0.0;\n    } else if (type == CursorWindow::FIELD_TYPE_BLOB) {\n        throw_sqlite3_exception(env, \"Unable to convert BLOB to double\");\n        return 0.0;\n    } else {\n        throwUnknownTypeException(env, type);\n        return 0.0;\n    }\n}\n\n/****************************\n       SQLiteAsyncQuery\n*****************************/\nstatic status_t copyRow(sqlite3_stmt *statement,\n                        ChunkedCursorWindow::Row *row,\n                        int numColumns,\n                        int pos)\n{\n\n    status_t status;\n\n    // Pack the row into the window.\n    int i;\n    for (i = 0; i < numColumns; i++) {\n        int type = sqlite3_column_type(statement, i);\n        if (type == SQLITE_TEXT) {\n            // TEXT data\n            const char *text = (const char *) sqlite3_column_text(statement, i);\n            // SQLite does not include the NULL terminator in size, but does\n            // ensure all strings are NULL terminated, so increase size by\n            // one to make sure we store the terminator.\n            size_t size = sqlite3_column_bytes(statement, i) + 1;\n\n            status = row->putString(i, text, size);\n            if (status != OK) {\n                return status;\n            }\n        } else if (type == SQLITE_BLOB) {\n            // BLOB data\n            const void *blob = sqlite3_column_blob(statement, i);\n            size_t size = sqlite3_column_bytes(statement, i);\n\n            status = row->putBlob(i, blob, size);\n            if (status != OK) {\n                return status;\n            }\n        } else if (type == SQLITE_INTEGER) {\n            // INTEGER data\n            int64_t value = sqlite3_column_int64(statement, i);\n\n            status = row->putLong(i, value);\n            if (status != OK) {\n                return status;\n            }\n        } else if (type == SQLITE_FLOAT) {\n            // FLOAT data\n            double value = sqlite3_column_double(statement, i);\n\n            status = row->putDouble(i, value);\n            if (status != OK) {\n                return status;\n            }\n        } else if (type == SQLITE_NULL) {\n            // NULL data\n            status = row->putNull(i);\n            if (status != OK) {\n                return status;\n            }\n        } else {\n            // Unknown type\n            return BAD_TYPE;\n        }\n    }\n\n    return OK;\n}\n\nstatic jint nativeFillRows(JNIEnv *env,\n                           jclass cls,\n                           jlong statementPtr,\n                           jlong windowPtr,\n                           jint startPos,\n                           jint count)\n{\n\n    sqlite3_stmt *stmt = (sqlite3_stmt *) (intptr_t) statementPtr;\n    ChunkedCursorWindow *window = (ChunkedCursorWindow *) (intptr_t) windowPtr;\n\n    int i;\n    for (i = 0; i < count; i++) {\n        int rc = sqlite3_step(stmt);\n        if (rc == SQLITE_DONE) {\n            // Reached the end of the result set, no more rows can be filled.\n            break;\n        } else if (rc != SQLITE_ROW) {\n            // Error occured, throw exception.\n            throw_sqlite3_exception(env, sqlite3_db_handle(stmt));\n            return -1;\n        } else {\n            // Got a row, fill it to the window.\n            int pos = startPos + i;\n\n            // Allocate row slot.\n            ChunkedCursorWindow::Row *row = window->newRow(pos, false);\n            if (!row) {\n                // Probably no space left on the current chunk, allocate new chunk and retry.\n                row = window->newRow(pos, true);\n                if (!row) {\n                    // Cannot allocate new chunk, throw exception.\n                    throw_sqlite3_exception(\n                        env,\n                        \"Failed to allocate new chunk in ChunkedCursorWindow.\");\n                    return -1;\n                }\n            }\n\n            // Copy columns to the window.\n            int numColumns = sqlite3_column_count(stmt);\n            status_t status = copyRow(stmt, row, numColumns, pos);\n\n            if (status == NO_MEMORY) {\n                // Existing chunk is full, allocate new chunk and retry.\n                window->rollbackRow(row);\n                row = window->newRow(pos, true);\n                if (!row) {\n                    // Cannot allocate new chunk, throw exception.\n                    throw_sqlite3_exception(\n                        env,\n                        \"Failed to allocate new chunk in ChunkedCursorWindow.\");\n                    return -1;\n                }\n\n                status = copyRow(stmt, row, numColumns, pos);\n            }\n\n            if (status != OK) {\n                // Failed, rollback row and throw exception.\n                window->rollbackRow(row);\n                char msg[256];\n                snprintf(msg, sizeof(msg),\n                         \"nativeFillRows failed, row = %d, status = %d\", pos,\n                         status);\n                throw_sqlite3_exception(env, msg);\n                return -1;\n            }\n\n            // status == OK\n            window->endRow(row);\n        }\n    }\n\n    return i;\n}\n\nstatic jint nativeCount(JNIEnv *env, jclass cls, jlong statementPtr)\n{\n    sqlite3_stmt *stmt = (sqlite3_stmt *) (intptr_t) statementPtr;\n    int result = 0;\n    while (sqlite3_step(stmt) == SQLITE_ROW) {\n        result++;\n    }\n\n    int rc = sqlite3_reset(stmt);\n    if (rc != SQLITE_OK) {\n        throw_sqlite3_exception(env, sqlite3_db_handle(stmt));\n        return -1;\n    }\n    return result;\n}\n\nstatic const JNINativeMethod sWindowMethods[] = {\n    {\"nativeCreate\", \"(I)J\", (void *) nativeCreate},\n    {\"nativeDispose\", \"(J)V\", (void *) nativeDispose},\n    {\"nativeClear\", \"(J)V\", (void *) nativeClear},\n    {\"nativeRemoveChunk\", \"(JI)J\", (void *) nativeRemoveChunk},\n    {\"nativeGetNumChunks\", \"(J)I\", (void *) nativeGetNumChunks},\n    {\"nativeSetNumColumns\", \"(JI)Z\", (void *) nativeSetNumColumns},\n    {\"nativeGetRow\", \"(JI)J\", (void *) nativeGetRow},\n    {\"nativeEndRow\", \"(JJ)V\", (void *) nativeEndRow},\n    {\"nativeGetType\", \"(JI)I\", (void *) nativeGetType},\n    {\"nativeGetBlob\", \"(JI)[B\", (void *) nativeGetBlob},\n    {\"nativeGetString\", \"(JI)Ljava/lang/String;\", (void *) nativeGetString},\n    {\"nativeGetLong\", \"(JI)J\", (void *) nativeGetLong},\n    {\"nativeGetDouble\", \"(JI)D\", (void *) nativeGetDouble},\n};\n\nstatic const JNINativeMethod sQueryMethods[] = {\n    {\"nativeFillRows\", \"(JJII)I\", (void *) nativeFillRows},\n    {\"nativeCount\", \"(J)I\", (void *) nativeCount},\n};\n\nstatic jint register_wcdb_ChunkedCursorWindow(JavaVM *vm, JNIEnv *env)\n{\n    int ret = jniRegisterNativeMethods(\n        env, \"com/tencent/wcdb/database/ChunkedCursorWindow\", sWindowMethods,\n        NELEM(sWindowMethods));\n    if (ret == 0)\n        ret = jniRegisterNativeMethods(\n            env, \"com/tencent/wcdb/database/SQLiteAsyncQuery\", sQueryMethods,\n            NELEM(sQueryMethods));\n    return ret;\n}\nWCDB_JNI_INIT(ChunkedCursorWindow, register_wcdb_ChunkedCursorWindow)\n}\n"
  },
  {
    "path": "deprecated/android/jni/com_tencent_wcdb_database_SQLiteConnection.cpp",
    "content": "/*\n * Copyright (C) 2011 The Android Open Source Project\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#define LOG_TAG \"WCDB.SQLiteConnection\"\n\n#include <assert.h>\n#include <jni.h>\n#include <sqlite3.h>\n#include <stdlib.h>\n#include <string.h>\n#include <unistd.h>\n#include <limits.h>\n\n#include <algorithm>\n#include <map>\n#include <vector>\n\n#include \"CursorWindow.h\"\n#include \"Errors.h\"\n#include \"JNIHelp.h\"\n#include \"Logger.h\"\n#include \"ModuleLoader.h\"\n#include \"SQLiteCommon.h\"\n\n// Set to 1 to use UTF16 storage for localized indexes.\n#define UTF16_STORAGE 0\n\nnamespace wcdb {\n\n/* Busy timeout in milliseconds.\n * If another connection (possibly in another process) has the database locked for\n * longer than this amount of time then SQLite will generate a SQLITE_BUSY error.\n * The SQLITE_BUSY error is then raised as a SQLiteDatabaseLockedException.\n *\n * In ordinary usage, busy timeouts are quite rare.  Most databases only ever\n * have a single open connection at a time unless they are using WAL.  When using\n * WAL, a timeout could occur if one connection is busy performing an auto-checkpoint\n * operation.  The busy timeout needs to be long enough to tolerate slow I/O write\n * operations but not so long as to cause the application to hang indefinitely if\n * there is a problem acquiring a database lock.\n */\n//static const int BUSY_TIMEOUT_MS = 2500;\nstatic const int BUSY_TIMEOUT_MS = 10 * 1000;\n\nstatic JavaVM *gVM;\n\nstatic struct {\n    jfieldID name;\n    jfieldID numArgs;\n    jmethodID dispatchCallback;\n} gSQLiteCustomFunctionClassInfo;\n\nstatic struct {\n    jclass clazz;\n} gStringClassInfo;\n\nstatic struct {\n    jmethodID notifyCheckpoint;\n    jmethodID notifyChange;\n} gSQLiteConnectionClassInfo;\n\nstruct SQLiteConnection {\n    // Open flags.\n    // Must be kept in sync with the constants defined in SQLiteDatabase.java.\n    enum {\n        OPEN_READWRITE = 0x00000000,\n        OPEN_READONLY = 0x00000001,\n        OPEN_READ_MASK = 0x00000001,\n        NO_LOCALIZED_COLLATORS = 0x00000010,\n        CREATE_IF_NECESSARY = 0x10000000,\n    };\n\n    jobject const dbObj;\n    sqlite3 *const db;\n    const int openFlags;\n\n    volatile bool canceled;\n\n    // Update notification stuff\n    struct NotificationKey {\n        std::string table;\n        std::string db;\n\n        NotificationKey(const char *d_, const char *t_) : table(t_), db(d_) {}\n\n        friend bool operator<(const NotificationKey &lhs,\n                              const NotificationKey &rhs)\n        {\n            int cmp = lhs.table.compare(rhs.table);\n            if (!cmp)\n                cmp = lhs.db.compare(rhs.db);\n            return cmp < 0;\n        }\n    };\n\n    struct NotificationItem {\n        sqlite_int64 rowid;\n        int op;\n\n        enum { OP_NOOP = 0, OP_INSERT = 1, OP_UPDATE = 2, OP_DELETE = 3 };\n\n        NotificationItem(sqlite_int64 r_, int op_) : rowid(r_), op(op_) {}\n\n        friend bool operator<(const NotificationItem &lhs,\n                              const NotificationItem &rhs)\n        {\n            return lhs.rowid < rhs.rowid;\n        }\n    };\n\n    struct NotificationItems {\n        int numNotify[3];\n        std::vector<NotificationItem> items;\n\n        NotificationItems() : numNotify{0, 0, 0} {}\n    };\n\n    typedef std::map<NotificationKey, NotificationItems> NotificationMap;\n\n    bool notifyEnabled;          // whether notification is enabled\n    bool notifyRowId;            // whether rowid is requested on notification\n    bool notifyCommited;         // whether transaction has been commited\n    NotificationMap notifyMap;   // notification operations\n    const char *lastNotifyDb;    // cached DB name of the last operation\n    const char *lastNotifyTable; // cached table name of the last operation\n    NotificationMap::iterator lastNotifyIterator; // cached iterator\n\n    SQLiteConnection(jobject dbObj, sqlite3 *db, int openFlags)\n        : dbObj(dbObj)\n        , db(db)\n        , openFlags(openFlags)\n        , canceled(false)\n        , notifyEnabled(false)\n        , notifyRowId(false)\n        , notifyCommited(false)\n        , lastNotifyDb(nullptr)\n        , lastNotifyTable(nullptr)\n    {\n    }\n};\n\n// Notification implementation\nstatic inline int toNotifyOp(int op)\n{\n    switch (op) {\n        case SQLITE_INSERT:\n            return SQLiteConnection::NotificationItem::OP_INSERT;\n        case SQLITE_UPDATE:\n            return SQLiteConnection::NotificationItem::OP_UPDATE;\n        case SQLITE_DELETE:\n            return SQLiteConnection::NotificationItem::OP_DELETE;\n        default:\n            return 0;\n    }\n}\n\nstatic void sqliteUpdateHookCallback(void *ud,\n                                     int op,\n                                     const char *dbName,\n                                     const char *tableName,\n                                     sqlite3_int64 rowid)\n{\n    SQLiteConnection *conn = (SQLiteConnection *) ud;\n    assert(conn->notifyEnabled && !conn->notifyCommited);\n\n    // Find or create the table entry.\n    SQLiteConnection::NotificationMap::iterator it;\n\n    // XXX: SQLite passes pointer to internal table description structure, which\n    // doesn't change during VDBE execution. Thus it's safe to compare the pointer\n    // value instead for the fast path.\n    if (dbName == conn->lastNotifyDb && tableName == conn->lastNotifyTable) {\n        it = conn->lastNotifyIterator;\n    } else {\n        it = conn->notifyMap\n                 .emplace(\n                     SQLiteConnection::NotificationKey(dbName, tableName),\n                     SQLiteConnection::NotificationItems())\n                 .first;\n\n        conn->lastNotifyDb = dbName;\n        conn->lastNotifyTable = tableName;\n        conn->lastNotifyIterator = it;\n    }\n\n    if (conn->notifyRowId) {\n        it->second.items.emplace_back(rowid, toNotifyOp(op));\n    }\n}\n\nstatic const int NOTIFY_OP_MERGE[] = {\n    /*           N/A  INSERT UPDATE DELETE */\n    /* N/A    */ 0x00, 0x01, 0x02, 0x03,\n    /* INSERT */ 0x01, 0x81, 0x01, 0x00,\n    /* UPDATE */ 0x02, 0x81, 0x02, 0x03,\n    /* DELETE */ 0x03, 0x02, 0x82, 0x83,\n};\nstatic inline int mergeOp(int op1, int op2)\n{\n    int outOp = NOTIFY_OP_MERGE[((op1 & 0x03) << 2) | (op2 & 0x03)];\n\n    // TODO: warn unexpected operation pair?\n    return (outOp & 0x03);\n}\n\nstatic int sqliteCommitHookCallback(void *ud)\n{\n    SQLiteConnection *conn = (SQLiteConnection *) ud;\n    assert(conn->notifyEnabled && !conn->notifyCommited);\n\n    for (auto it = conn->notifyMap.begin(); it != conn->notifyMap.end(); ++it) {\n\n        memset(it->second.numNotify, 0, sizeof(it->second.numNotify));\n        if (conn->notifyRowId && !it->second.items.empty()) {\n            // Sort IDs.\n            auto &opList = it->second.items;\n            std::stable_sort(opList.begin(), opList.end());\n\n            // Merge operations of the same ID.\n            sqlite_int64 rowid = opList[0].rowid;\n            int op = opList[0].op;\n            int startIdx = 0;\n            it->second.numNotify[op - 1]++;\n            for (size_t i = 1; i < opList.size(); i++) {\n                if (opList[i].rowid == rowid) {\n                    // found the same rowId, merge with the previous ones.\n                    op = opList[startIdx].op = mergeOp(op, opList[i].op);\n                    opList[i].op = SQLiteConnection::NotificationItem::OP_NOOP;\n                } else {\n                    if (op > 0 && op < 4) // INSERT, UPDATE or DELETE\n                        it->second.numNotify[op - 1]++;\n\n                    rowid = opList[i].rowid;\n                    op = opList[i].op;\n                    startIdx = i;\n                }\n            }\n        }\n    }\n\n    conn->lastNotifyDb = nullptr;\n    conn->lastNotifyTable = nullptr;\n    conn->lastNotifyIterator = conn->notifyMap.end();\n    conn->notifyCommited = true;\n\n    return 0;\n}\n\nstatic void sqliteRollbackHookCallback(void *ud)\n{\n    SQLiteConnection *conn = (SQLiteConnection *) ud;\n    assert(conn->notifyEnabled && !conn->notifyCommited);\n\n    // Clear notification records.\n    conn->notifyMap.clear();\n    conn->lastNotifyDb = nullptr;\n    conn->lastNotifyTable = nullptr;\n    conn->lastNotifyIterator = conn->notifyMap.end();\n}\n\nstatic void emitUpdateNotifications(JNIEnv *env, SQLiteConnection *conn)\n{\n\n    if (!conn->notifyEnabled || !conn->notifyCommited) {\n        conn->notifyCommited = false;\n        return;\n    }\n\n    for (auto it = conn->notifyMap.begin(); it != conn->notifyMap.end(); ++it) {\n        jstring dbNameStr = env->NewStringUTF(it->first.db.c_str());\n        jstring tableNameStr = env->NewStringUTF(it->first.table.c_str());\n\n        jlongArray idsArr[3] = {nullptr};\n\n        if (conn->notifyRowId) {\n            int *numNotify = it->second.numNotify;\n            for (int i = 0; i < 3; i++)\n                idsArr[i] = env->NewLongArray(numNotify[i]);\n\n            jlong *ids[3];\n            int idsIdx[3] = {0};\n            for (int i = 0; i < 3; i++)\n                ids[i] =\n                    (jlong *) env->GetPrimitiveArrayCritical(idsArr[i], nullptr);\n\n            auto &opList = it->second.items;\n            for (size_t i = 0; i < opList.size(); i++) {\n                int op = opList[i].op - 1;\n                assert(op >= 0 && op < 3);\n                assert(idsIdx[op] < numNotify[op]);\n\n                ids[op][idsIdx[op]++] = opList[i].rowid;\n            }\n\n            for (int i = 2; i >= 0; i--)\n                env->ReleasePrimitiveArrayCritical(idsArr[i], ids[i], 0);\n        }\n\n        env->CallVoidMethod(conn->dbObj,\n                            gSQLiteConnectionClassInfo.notifyChange, dbNameStr,\n                            tableNameStr, idsArr[0], idsArr[1], idsArr[2]);\n        if (env->ExceptionCheck()) {\n            jniLogException(env, ANDROID_LOG_ERROR, LOG_TAG);\n            return;\n        }\n\n        env->DeleteLocalRef(dbNameStr);\n        env->DeleteLocalRef(tableNameStr);\n        for (int i = 0; i < 3; i++)\n            if (idsArr[i])\n                env->DeleteLocalRef(idsArr[i]);\n    }\n\n    conn->notifyCommited = false;\n    conn->notifyMap.clear();\n}\n\n// Called after each SQLite VM instruction when cancelation is enabled.\nstatic int sqliteProgressHandlerCallback(void *data)\n{\n    SQLiteConnection *connection = static_cast<SQLiteConnection *>(data);\n    return connection->canceled;\n}\n\n// Called after commiting transactions in WAL mode.\nstatic int\nsqliteWalHookCallback(void *data, sqlite3 *db, const char *dbName, int pages)\n{\n    SQLiteConnection *connection = static_cast<SQLiteConnection *>(data);\n\n    JNIEnv *env = nullptr;\n    bool attached = false;\n    jint ret = gVM->GetEnv((void **) &env, JNI_VERSION_1_6);\n    if (ret == JNI_EDETACHED) {\n        jint ret = gVM->AttachCurrentThread(&env, nullptr);\n        assert(ret == JNI_OK);\n        (void) ret;\n        attached = true;\n    }\n\n    jstring dbNameStr = env->NewStringUTF(dbName);\n    env->CallVoidMethod(connection->dbObj,\n                        gSQLiteConnectionClassInfo.notifyCheckpoint, dbNameStr,\n                        (jint) pages);\n    bool exceptionOccurred = env->ExceptionCheck();\n    if (exceptionOccurred) {\n        jniLogException(env, ANDROID_LOG_ERROR, LOG_TAG);\n        env->ExceptionClear();\n    }\n    env->DeleteLocalRef(dbNameStr);\n\n    if (attached) {\n        gVM->DetachCurrentThread();\n    }\n    return exceptionOccurred ? SQLITE_ERROR : SQLITE_OK;\n}\n\nstatic void\nnativeSetKey(JNIEnv *env, jclass clazz, jlong connectionPtr, jbyteArray keyArr)\n{\n\n    SQLiteConnection *connection =\n        (SQLiteConnection *) (intptr_t) connectionPtr;\n    if (!connection)\n        return;\n\n    jbyte *key = nullptr;\n    int keyLen = 0;\n    if (keyArr) {\n        keyLen = env->GetArrayLength(keyArr);\n        if (keyLen > 0 && keyLen <= 4096) {\n            key = (jbyte *) alloca(keyLen);\n            env->GetByteArrayRegion(keyArr, 0, keyLen, key);\n        }\n    }\n\n    if (key && keyLen > 0) {\n        int status = sqlite3_key(connection->db, key, keyLen);\n\n        if (status != SQLITE_OK) {\n            throw_sqlite3_exception(env, connection->db, \"Could not set key\");\n        } else {\n            LOGI(LOG_TAG, \"sqlite3_key verification passed.\");\n        }\n    }\n}\n\nstatic jlong nativeOpen(JNIEnv *env,\n                        jobject obj,\n                        jstring pathStr,\n                        jint openFlags,\n                        jstring vfsNameStr)\n{\n    int sqliteFlags;\n    if (openFlags & SQLiteConnection::CREATE_IF_NECESSARY) {\n        sqliteFlags = SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE;\n    } else {\n        // Try read/write mode even if OPEN_READONLY flag is set,\n        // for compatibility to WAL.\n        sqliteFlags = SQLITE_OPEN_READWRITE;\n    }\n\n    const char *pathChars = env->GetStringUTFChars(pathStr, nullptr);\n    std::string path(pathChars);\n    env->ReleaseStringUTFChars(pathStr, pathChars);\n\n    const char *vfsNameChars = nullptr;\n    if (vfsNameStr)\n        vfsNameChars = env->GetStringUTFChars(vfsNameStr, nullptr);\n\n    sqlite3 *db;\n    int err = sqlite3_open_v2(path.c_str(), &db, sqliteFlags, vfsNameChars);\n\n    if (vfsNameStr)\n        env->ReleaseStringUTFChars(vfsNameStr, vfsNameChars);\n\n    if (err != SQLITE_OK) {\n        throw_sqlite3_exception_errcode(env, err, \"Could not open database\");\n        return 0;\n    }\n    // Check that the database is really read/write when that is what we asked for.\n    if (!(openFlags & SQLiteConnection::OPEN_READONLY) &&\n        sqlite3_db_readonly(db, nullptr)) {\n        throw_sqlite3_exception(\n            env, db, \"Could not open the database in read/write mode.\");\n        sqlite3_close(db);\n        return 0;\n    }\n\n    // Reset the API stealer auto extension, it is only needed to be called once.\n    sqlite3_reset_auto_extension();\n\n    // Set the default busy handler to retry automatically before returning SQLITE_BUSY.\n    err = sqlite3_busy_timeout(db, BUSY_TIMEOUT_MS);\n    if (err != SQLITE_OK) {\n        throw_sqlite3_exception(env, db, \"Could not set busy timeout\");\n        sqlite3_close(db);\n        return 0;\n    }\n\n    //    // Register custom Android functions.\n    //    err = register_android_functions(db, UTF16_STORAGE);\n    //    if (err) {\n    //        throw_sqlite3_exception(env, db, \"Could not register Android SQL functions.\");\n    //        sqlite3_close(db);\n    //        return 0;\n    //    }\n\n    // Create wrapper object.\n    SQLiteConnection *connection =\n        new SQLiteConnection(env->NewGlobalRef(obj), db, openFlags);\n\n    LOGI(LOG_TAG, \"Opened connection %p with label '%s'\", db, path.c_str());\n    return (jlong)(intptr_t) connection;\n}\n\nstatic void nativeClose(JNIEnv *env, jclass clazz, jlong connectionPtr)\n{\n    SQLiteConnection *connection =\n        (SQLiteConnection *) (intptr_t) connectionPtr;\n\n    if (connection) {\n        LOGI(LOG_TAG, \"Closing connection %p\", connection->db);\n        int err = sqlite3_close(connection->db);\n        if (err != SQLITE_OK) {\n            throw_sqlite3_exception(env, connection->db,\n                                    \"Failed to close database.\");\n            return;\n        }\n\n        env->DeleteGlobalRef(connection->dbObj);\n        delete connection;\n    }\n}\n\n// Called each time a custom function is evaluated.\nstatic void sqliteCustomFunctionCallback(sqlite3_context *context,\n                                         int argc,\n                                         sqlite3_value **argv)\n{\n    JNIEnv *env = jniGetEnv();\n\n    // Get the callback function object.\n    // Create a new local reference to it in case the callback tries to do something\n    // dumb like unregister the function (thereby destroying the global ref) while it is running.\n    jobject functionObjGlobal =\n        reinterpret_cast<jobject>(sqlite3_user_data(context));\n    jobject functionObj = env->NewLocalRef(functionObjGlobal);\n\n    jobjectArray argsArray =\n        env->NewObjectArray(argc, gStringClassInfo.clazz, nullptr);\n    if (argsArray) {\n        for (int i = 0; i < argc; i++) {\n            const jchar *arg =\n                static_cast<const jchar *>(sqlite3_value_text16(argv[i]));\n            if (!arg) {\n                LOGW(LOG_TAG, \"NULL argument in custom_function_callback.  \"\n                              \"This should not happen.\");\n            } else {\n                size_t argLen = sqlite3_value_bytes16(argv[i]) / sizeof(jchar);\n                jstring argStr = env->NewString(arg, argLen);\n                if (!argStr) {\n                    goto error; // out of memory error\n                }\n                env->SetObjectArrayElement(argsArray, i, argStr);\n                env->DeleteLocalRef(argStr);\n            }\n        }\n\n        // TODO: Support functions that return values.\n        env->CallVoidMethod(functionObj,\n                            gSQLiteCustomFunctionClassInfo.dispatchCallback,\n                            argsArray);\n\n    error:\n        env->DeleteLocalRef(argsArray);\n    }\n\n    env->DeleteLocalRef(functionObj);\n\n    if (env->ExceptionCheck()) {\n        LOGE(LOG_TAG, \"An exception was thrown by custom SQLite function.\");\n        LOGE_EX(env);\n        env->ExceptionClear();\n    }\n}\n\n// Called when a custom function is destroyed.\nstatic void sqliteCustomFunctionDestructor(void *data)\n{\n    jobject functionObjGlobal = reinterpret_cast<jobject>(data);\n\n    JNIEnv *env = jniGetEnv();\n    env->DeleteGlobalRef(functionObjGlobal);\n}\n\nstatic void nativeRegisterCustomFunction(JNIEnv *env,\n                                         jclass clazz,\n                                         jlong connectionPtr,\n                                         jobject functionObj)\n{\n    SQLiteConnection *connection =\n        (SQLiteConnection *) (intptr_t) connectionPtr;\n\n    jstring nameStr = jstring(\n        env->GetObjectField(functionObj, gSQLiteCustomFunctionClassInfo.name));\n    jint numArgs =\n        env->GetIntField(functionObj, gSQLiteCustomFunctionClassInfo.numArgs);\n\n    jobject functionObjGlobal = env->NewGlobalRef(functionObj);\n\n    const char *name = env->GetStringUTFChars(nameStr, nullptr);\n    int err =\n        sqlite3_create_function_v2(connection->db, name, numArgs, SQLITE_UTF16,\n                                   reinterpret_cast<void *>(functionObjGlobal),\n                                   &sqliteCustomFunctionCallback, nullptr, nullptr,\n                                   &sqliteCustomFunctionDestructor);\n    env->ReleaseStringUTFChars(nameStr, name);\n\n    if (err != SQLITE_OK) {\n        LOGE(LOG_TAG, \"sqlite3_create_function returned %d\", err);\n        env->DeleteGlobalRef(functionObjGlobal);\n        throw_sqlite3_exception(env, connection->db);\n        return;\n    }\n}\n\nstatic void nativeRegisterLocalizedCollators(JNIEnv *env,\n                                             jclass clazz,\n                                             jlong connectionPtr,\n                                             jstring localeStr)\n{\n    SQLiteConnection *connection =\n        (SQLiteConnection *) (intptr_t) connectionPtr;\n\n    const char *locale = env->GetStringUTFChars(localeStr, nullptr);\n    int err = SQLITE_OK; //(connection->db, locale, UTF16_STORAGE);\n    env->ReleaseStringUTFChars(localeStr, locale);\n\n    if (err != SQLITE_OK) {\n        throw_sqlite3_exception(env, connection->db);\n    }\n}\n\nstatic jlong nativePrepareStatement(JNIEnv *env,\n                                    jclass clazz,\n                                    jlong connectionPtr,\n                                    jstring sqlString)\n{\n    SQLiteConnection *connection =\n        (SQLiteConnection *) (intptr_t) connectionPtr;\n\n    jsize sqlLength = env->GetStringLength(sqlString);\n    const jchar *sql = env->GetStringChars(sqlString, nullptr);\n    sqlite3_stmt *statement;\n\n    int err = sqlite3_prepare16_v2(connection->db, sql,\n                                   sqlLength * sizeof(jchar), &statement, nullptr);\n\n    env->ReleaseStringChars(sqlString, sql);\n\n    if (err != SQLITE_OK) {\n        // Error messages like 'near \")\": syntax error' are not\n        // always helpful enough, so construct an error string that\n        // includes the query itself.\n        const char *query = env->GetStringUTFChars(sqlString, nullptr);\n        size_t message_len = strlen(query) + 50;\n        char *message = (char *) malloc(message_len);\n        if (message) {\n            size_t len = strlcpy(message, \", while compiling: \", message_len);\n            strlcpy(message + len, query, message_len - len);\n        }\n        env->ReleaseStringUTFChars(sqlString, query);\n        throw_sqlite3_exception(env, connection->db, message);\n        free(message);\n        return 0;\n    }\n\n    //    LOGV(LOG_TAG,\"Prepared statement %p on connection %p\", statement, connection->db);\n    return (jlong)(intptr_t) statement;\n}\n\nstatic void nativeFinalizeStatement(JNIEnv *env,\n                                    jclass clazz,\n                                    jlong connectionPtr,\n                                    jlong statementPtr)\n{\n    sqlite3_stmt *statement = (sqlite3_stmt *) (intptr_t) statementPtr;\n\n    // We ignore the result of sqlite3_finalize because it is really telling us about\n    // whether any errors occurred while executing the statement.  The statement itself\n    // is always finalized regardless.\n    //    LOGV(LOG_TAG,\"Finalized statement %p on connection %p\", statement, connection->db);\n    sqlite3_finalize(statement);\n}\n\nstatic jint nativeGetParameterCount(JNIEnv *env,\n                                    jclass clazz,\n                                    jlong connectionPtr,\n                                    jlong statementPtr)\n{\n    sqlite3_stmt *statement = (sqlite3_stmt *) (intptr_t) statementPtr;\n\n    return sqlite3_bind_parameter_count(statement);\n}\n\nstatic jboolean nativeIsReadOnly(JNIEnv *env,\n                                 jclass clazz,\n                                 jlong connectionPtr,\n                                 jlong statementPtr)\n{\n    sqlite3_stmt *statement = (sqlite3_stmt *) (intptr_t) statementPtr;\n\n    return static_cast<jboolean>(sqlite3_stmt_readonly(statement) ? 1 : 0);\n}\n\nstatic jint nativeGetColumnCount(JNIEnv *env,\n                                 jclass clazz,\n                                 jlong connectionPtr,\n                                 jlong statementPtr)\n{\n    sqlite3_stmt *statement = (sqlite3_stmt *) (intptr_t) statementPtr;\n\n    return sqlite3_column_count(statement);\n}\n\nstatic jstring nativeGetColumnName(JNIEnv *env,\n                                   jclass clazz,\n                                   jlong connectionPtr,\n                                   jlong statementPtr,\n                                   jint index)\n{\n    sqlite3_stmt *statement = (sqlite3_stmt *) (intptr_t) statementPtr;\n\n    const jchar *name =\n        static_cast<const jchar *>(sqlite3_column_name16(statement, index));\n    if (name) {\n        size_t length = 0;\n        while (name[length]) {\n            length += 1;\n        }\n        return env->NewString(name, length);\n    }\n    return nullptr;\n}\n\nstatic void nativeBindNull(JNIEnv *env,\n                           jclass clazz,\n                           jlong connectionPtr,\n                           jlong statementPtr,\n                           jint index)\n{\n    sqlite3_stmt *statement = (sqlite3_stmt *) (intptr_t) statementPtr;\n\n    int err = sqlite3_bind_null(statement, index);\n    if (err != SQLITE_OK) {\n        SQLiteConnection *connection =\n            (SQLiteConnection *) (intptr_t) connectionPtr;\n        throw_sqlite3_exception(env, connection->db, nullptr);\n    }\n}\n\nstatic void nativeBindLong(JNIEnv *env,\n                           jclass clazz,\n                           jlong connectionPtr,\n                           jlong statementPtr,\n                           jint index,\n                           jlong value)\n{\n    sqlite3_stmt *statement = (sqlite3_stmt *) (intptr_t) statementPtr;\n\n    int err = sqlite3_bind_int64(statement, index, value);\n    if (err != SQLITE_OK) {\n        SQLiteConnection *connection =\n            (SQLiteConnection *) (intptr_t) connectionPtr;\n        throw_sqlite3_exception(env, connection->db, nullptr);\n    }\n}\n\nstatic void nativeBindDouble(JNIEnv *env,\n                             jclass clazz,\n                             jlong connectionPtr,\n                             jlong statementPtr,\n                             jint index,\n                             jdouble value)\n{\n    sqlite3_stmt *statement = (sqlite3_stmt *) (intptr_t) statementPtr;\n\n    int err = sqlite3_bind_double(statement, index, value);\n    if (err != SQLITE_OK) {\n        SQLiteConnection *connection =\n            (SQLiteConnection *) (intptr_t) connectionPtr;\n        throw_sqlite3_exception(env, connection->db, nullptr);\n    }\n}\n\nstatic void nativeBindString(JNIEnv *env,\n                             jclass clazz,\n                             jlong connectionPtr,\n                             jlong statementPtr,\n                             jint index,\n                             jstring valueString)\n{\n    sqlite3_stmt *statement = (sqlite3_stmt *) (intptr_t) statementPtr;\n\n    jsize valueLength = env->GetStringLength(valueString);\n    const jchar *value = env->GetStringCritical(valueString, nullptr);\n    int err = sqlite3_bind_text16(\n        statement, index, value, valueLength * sizeof(jchar), SQLITE_TRANSIENT);\n    env->ReleaseStringCritical(valueString, value);\n    if (err != SQLITE_OK) {\n        SQLiteConnection *connection =\n            (SQLiteConnection *) (intptr_t) connectionPtr;\n        throw_sqlite3_exception(env, connection->db, nullptr);\n    }\n}\n\nstatic void nativeBindBlob(JNIEnv *env,\n                           jclass clazz,\n                           jlong connectionPtr,\n                           jlong statementPtr,\n                           jint index,\n                           jbyteArray valueArray)\n{\n    sqlite3_stmt *statement = (sqlite3_stmt *) (intptr_t) statementPtr;\n\n    jsize valueLength = env->GetArrayLength(valueArray);\n    jbyte *value =\n        static_cast<jbyte *>(env->GetPrimitiveArrayCritical(valueArray, nullptr));\n    int err = sqlite3_bind_blob(statement, index, value, valueLength,\n                                SQLITE_TRANSIENT);\n    env->ReleasePrimitiveArrayCritical(valueArray, value, JNI_ABORT);\n    if (err != SQLITE_OK) {\n        SQLiteConnection *connection =\n            (SQLiteConnection *) (intptr_t) connectionPtr;\n        throw_sqlite3_exception(env, connection->db, nullptr);\n    }\n}\n\nstatic void nativeResetStatement(JNIEnv *env,\n                                 jclass clazz,\n                                 jlong connectionPtr,\n                                 jlong statementPtr,\n                                 jboolean clearBindings)\n{\n    sqlite3_stmt *statement = (sqlite3_stmt *) (intptr_t) statementPtr;\n\n    int err = sqlite3_reset(statement);\n    if (err == SQLITE_OK && clearBindings) {\n        err = sqlite3_clear_bindings(statement);\n    }\n    if (err != SQLITE_OK) {\n        SQLiteConnection *connection =\n            (SQLiteConnection *) (intptr_t) connectionPtr;\n        throw_sqlite3_exception(env, connection->db, nullptr);\n    }\n}\n\nstatic int executeNonQuery(JNIEnv *env,\n                           SQLiteConnection *connection,\n                           sqlite3_stmt *statement)\n{\n    int err;\n    do {\n        err = sqlite3_step(statement);\n    } while (err == SQLITE_ROW);\n\n    if (err != SQLITE_DONE) {\n        throw_sqlite3_exception(env, connection->db);\n    } else {\n        emitUpdateNotifications(env, connection);\n    }\n\n    return err;\n}\n\nstatic void nativeExecute(JNIEnv *env,\n                          jclass clazz,\n                          jlong connectionPtr,\n                          jlong statementPtr)\n{\n    SQLiteConnection *conn = (SQLiteConnection *) (intptr_t) connectionPtr;\n    sqlite3_stmt *stmt = (sqlite3_stmt *) (intptr_t) statementPtr;\n\n    executeNonQuery(env, conn, stmt);\n}\n\nstatic jint nativeExecuteForChangedRowCount(JNIEnv *env,\n                                            jclass clazz,\n                                            jlong connectionPtr,\n                                            jlong statementPtr)\n{\n    SQLiteConnection *conn = (SQLiteConnection *) (intptr_t) connectionPtr;\n    sqlite3_stmt *stmt = (sqlite3_stmt *) (intptr_t) statementPtr;\n\n    int err = executeNonQuery(env, conn, stmt);\n    return err == SQLITE_DONE ? sqlite3_changes(conn->db) : -1;\n}\n\nstatic jlong nativeExecuteForLastInsertedRowId(JNIEnv *env,\n                                               jclass clazz,\n                                               jlong connectionPtr,\n                                               jlong statementPtr)\n{\n    SQLiteConnection *conn = (SQLiteConnection *) (intptr_t) connectionPtr;\n    sqlite3_stmt *stmt = (sqlite3_stmt *) (intptr_t) statementPtr;\n\n    int err = executeNonQuery(env, conn, stmt);\n    return err == SQLITE_DONE && sqlite3_changes(conn->db) > 0\n               ? sqlite3_last_insert_rowid(conn->db)\n               : LONG_MIN;\n}\n\nstatic int executeOneRowQuery(JNIEnv *env,\n                              SQLiteConnection *connection,\n                              sqlite3_stmt *statement)\n{\n    int err = sqlite3_step(statement);\n    if (err != SQLITE_ROW) {\n        throw_sqlite3_exception(env, connection->db);\n    } else {\n        emitUpdateNotifications(env, connection);\n    }\n    return err;\n}\n\nstatic jlong nativeExecuteForLong(JNIEnv *env,\n                                  jclass clazz,\n                                  jlong connectionPtr,\n                                  jlong statementPtr)\n{\n    SQLiteConnection *connection =\n        (SQLiteConnection *) (intptr_t) connectionPtr;\n    sqlite3_stmt *statement = (sqlite3_stmt *) (intptr_t) statementPtr;\n\n    int err = executeOneRowQuery(env, connection, statement);\n    if (err == SQLITE_ROW && sqlite3_column_count(statement) >= 1) {\n        return sqlite3_column_int64(statement, 0);\n    }\n    return -1;\n}\n\nstatic jstring nativeExecuteForString(JNIEnv *env,\n                                      jclass clazz,\n                                      jlong connectionPtr,\n                                      jlong statementPtr)\n{\n    SQLiteConnection *conn = (SQLiteConnection *) (intptr_t) connectionPtr;\n    sqlite3_stmt *stmt = (sqlite3_stmt *) (intptr_t) statementPtr;\n\n    int err = executeOneRowQuery(env, conn, stmt);\n    if (err == SQLITE_ROW && sqlite3_column_count(stmt) >= 1) {\n        const jchar *text = (const jchar *) (sqlite3_column_text16(stmt, 0));\n        if (text) {\n            size_t length = sqlite3_column_bytes16(stmt, 0) / sizeof(jchar);\n            return env->NewString(text, length);\n        }\n    }\n    return nullptr;\n}\n\nenum CopyRowResult {\n    CPR_OK,\n    CPR_FULL,\n    CPR_ERROR,\n};\n\nstatic CopyRowResult copyRow(JNIEnv *env,\n                             CursorWindow *window,\n                             sqlite3_stmt *statement,\n                             int numColumns,\n                             int startPos,\n                             int addedRows)\n{\n    // Allocate a new field directory for the row.\n    CursorWindow::RowSlot *rowSlot;\n    status_t status = window->allocRow(&rowSlot);\n    if (status) {\n        LOGV(LOG_TAG,\n             \"Failed allocating fieldDir at startPos %d row %d, error=%d\",\n             startPos, addedRows, status);\n        return CPR_FULL;\n    }\n\n    // Pack the row into the window.\n    CopyRowResult result = CPR_OK;\n    for (int i = 0; i < numColumns; i++) {\n        int type = sqlite3_column_type(statement, i);\n        if (type == SQLITE_TEXT) {\n            // TEXT data\n            const char *text = reinterpret_cast<const char *>(\n                sqlite3_column_text(statement, i));\n            // SQLite does not include the NULL terminator in size, but does\n            // ensure all strings are NULL terminated, so increase size by\n            // one to make sure we store the terminator.\n            size_t sizeIncludingNull = sqlite3_column_bytes(statement, i) + 1;\n            status = window->putString(rowSlot, i, text, sizeIncludingNull);\n            if (status) {\n                LOGW(LOG_TAG,\n                     \"Failed allocating %zu bytes for text at %d,%d, error=%d\",\n                     sizeIncludingNull, startPos + addedRows, i, status);\n                result = CPR_FULL;\n                break;\n            }\n        } else if (type == SQLITE_INTEGER) {\n            // INTEGER data\n            int64_t value = sqlite3_column_int64(statement, i);\n            status = window->putLong(rowSlot, i, value);\n            if (status) {\n                LOGW(\n                    LOG_TAG,\n                    \"Failed allocating space for a long in column %d, error=%d\",\n                    i, status);\n                result = CPR_FULL;\n                break;\n            }\n        } else if (type == SQLITE_FLOAT) {\n            // FLOAT data\n            double value = sqlite3_column_double(statement, i);\n            status = window->putDouble(rowSlot, i, value);\n            if (status) {\n                LOGW(LOG_TAG,\n                     \"Failed allocating space for a double in column \"\n                     \"%d, error=%d\",\n                     i, status);\n                result = CPR_FULL;\n                break;\n            }\n        } else if (type == SQLITE_BLOB) {\n            // BLOB data\n            const void *blob = sqlite3_column_blob(statement, i);\n            size_t size = sqlite3_column_bytes(statement, i);\n            status = window->putBlob(rowSlot, i, blob, size);\n            if (status) {\n                LOGW(LOG_TAG,\n                     \"Failed allocating %zu bytes for blob at %d,%d, error=%d\",\n                     size, startPos + addedRows, i, status);\n                result = CPR_FULL;\n                break;\n            }\n        } else if (type == SQLITE_NULL) {\n            // NULL field\n            status = window->putNull(rowSlot, i);\n            if (status) {\n                LOGW(\n                    LOG_TAG,\n                    \"Failed allocating space for a null in column %d, error=%d\",\n                    i, status);\n                result = CPR_FULL;\n                break;\n            }\n        } else {\n            // Unknown data\n            LOGE(LOG_TAG, \"Unknown column type when filling database window\");\n            throw_sqlite3_exception(env,\n                                    \"Unknown column type when filling window\");\n            result = CPR_ERROR;\n            break;\n        }\n    }\n\n    // Free the last row if if was not successfully copied.\n    if (result != CPR_OK) {\n        window->freeLastRow();\n    }\n    return result;\n}\n\nstatic jlong nativeExecuteForCursorWindow(JNIEnv *env,\n                                          jclass clazz,\n                                          jlong connectionPtr,\n                                          jlong statementPtr,\n                                          jlong windowPtr,\n                                          jint startPos,\n                                          jint requiredPos,\n                                          jboolean countAllRows)\n{\n    SQLiteConnection *conn = (SQLiteConnection *) (intptr_t) connectionPtr;\n    sqlite3_stmt *stmt = (sqlite3_stmt *) (intptr_t) statementPtr;\n    CursorWindow *window = (CursorWindow *) (intptr_t) windowPtr;\n\n    status_t status = window->clear();\n    if (status) {\n        throw_sqlite3_exception_format(\n            env, conn->db, \"Failed to clear the cursor window, status=%d\",\n            status);\n        return 0;\n    }\n\n    int numColumns = -1;\n    int retryCount = 0;\n    int totalRows = 0;\n    int addedRows = 0;\n    bool windowFull = false;\n    bool gotException = false;\n    while (!gotException && (!windowFull || countAllRows)) {\n        int err = sqlite3_step(stmt);\n        if (err == SQLITE_ROW) {\n\n            // Delay column count determination to the first time we got a row.\n            // This is because schema can be changed by other connection but we\n            // cannot notice before statement was actually executed by sqlite3_step().\n            if (numColumns < 0) {\n                numColumns = sqlite3_column_count(stmt);\n                status = window->setNumColumns(numColumns);\n                if (status) {\n                    throw_sqlite3_exception_format(env, conn->db,\n                                                   \"Failed to set the cursor \"\n                                                   \"window column count to %d, \"\n                                                   \"status=%d\",\n                                                   numColumns, status);\n                    return 0;\n                }\n            }\n\n            //LOGV(LOG_TAG,\"Stepped statement %p to row %d\", statement, totalRows);\n            retryCount = 0;\n            totalRows += 1;\n\n            // Skip the row if the window is full or we haven't reached the start position yet.\n            if (startPos >= totalRows || windowFull) {\n                continue;\n            }\n\n            CopyRowResult cpr =\n                copyRow(env, window, stmt, numColumns, startPos, addedRows);\n            if (cpr == CPR_FULL && addedRows &&\n                startPos + addedRows <= requiredPos) {\n                // We filled the window before we got to the one row that we really wanted.\n                // Clear the window and start filling it again from here.\n                // TODO: Would be nicer if we could progressively replace earlier rows.\n                window->clear();\n                window->setNumColumns(numColumns);\n                startPos += addedRows;\n                addedRows = 0;\n                cpr =\n                    copyRow(env, window, stmt, numColumns, startPos, addedRows);\n            }\n\n            if (cpr == CPR_OK) {\n                addedRows += 1;\n            } else if (cpr == CPR_FULL) {\n                windowFull = true;\n            } else {\n                gotException = true;\n            }\n        } else if (err == SQLITE_DONE) {\n            // All rows processed, bail\n            break;\n        } else if (err == SQLITE_LOCKED || err == SQLITE_BUSY) {\n            // The table is locked, retry\n            LOGI(LOG_TAG, \"Database locked, retrying error code is %d\", err);\n            if (retryCount > 5) {\n                LOGE(LOG_TAG, \"Bailing on database busy retry\");\n                throw_sqlite3_exception(env, conn->db, \"retrycount exceeded\");\n                gotException = true;\n            } else {\n                // Sleep to give the thread holding the lock a chance to finish\n                usleep(1000);\n                retryCount++;\n            }\n        } else {\n            throw_sqlite3_exception(env, conn->db);\n            gotException = true;\n        }\n    }\n\n    //    LOGV(LOG_TAG,\"Resetting statement %p after fetching %d rows and adding %d rows\"\n    //            \"to the window in %d bytes\",\n    //            statement, totalRows, addedRows, window->size() - window->freeSpace());\n    sqlite3_reset(stmt);\n\n    // Report the total number of rows on request.\n    if (startPos > totalRows) {\n        LOGE(LOG_TAG, \"startPos %d > actual rows %d\", startPos, totalRows);\n    }\n\n    if (!gotException)\n        emitUpdateNotifications(env, conn);\n\n    jlong result = jlong(startPos) << 32 | jlong(totalRows);\n    return result;\n}\n\nstatic jint nativeGetDbLookaside(JNIEnv *env, jclass clazz, jlong connectionPtr) {\n    SQLiteConnection *connection =\n        (SQLiteConnection *) (intptr_t) connectionPtr;\n\n    int cur = -1;\n    int unused;\n    sqlite3_db_status(connection->db, SQLITE_DBSTATUS_LOOKASIDE_USED, &cur,\n                      &unused, 0);\n    return cur;\n}\n\nstatic void nativeCancel(JNIEnv *env, jclass clazz, jlong connectionPtr) {\n    SQLiteConnection *connection =\n        (SQLiteConnection *) (intptr_t) connectionPtr;\n    connection->canceled = true;\n}\n\nstatic void nativeResetCancel(JNIEnv *env,\n                              jclass clazz,\n                              jlong connectionPtr,\n                              jboolean cancelable)\n{\n    SQLiteConnection *connection =\n        (SQLiteConnection *) (intptr_t) connectionPtr;\n    connection->canceled = false;\n\n    if (cancelable) {\n        sqlite3_progress_handler(connection->db, 4,\n                                 sqliteProgressHandlerCallback, connection);\n    } else {\n        sqlite3_progress_handler(connection->db, 0, nullptr, nullptr);\n    }\n}\n\nstatic void nativeSetWalHook(JNIEnv *env, jclass clazz, jlong connectionPtr)\n{\n    SQLiteConnection *connection =\n        (SQLiteConnection *) (intptr_t) connectionPtr;\n\n    sqlite3_wal_hook(connection->db, sqliteWalHookCallback, connection);\n}\n\nstatic jlong nativeWalCheckpoint(JNIEnv *env,\n                                 jclass clazz,\n                                 jlong connectionPtr,\n                                 jstring dbNameStr)\n{\n    SQLiteConnection *connection =\n        (SQLiteConnection *) (intptr_t) connectionPtr;\n\n    int nLog = 0, nCkpt = 0;\n    const char *dbName = env->GetStringUTFChars(dbNameStr, nullptr);\n    int ret = sqlite3_wal_checkpoint_v2(\n        connection->db, dbName, SQLITE_CHECKPOINT_PASSIVE, &nLog, &nCkpt);\n    env->ReleaseStringUTFChars(dbNameStr, dbName);\n    if (ret != SQLITE_OK) {\n        // sqlite3_wal_checkpoint_v2 returns SQLITE_BUSY if any other process is running\n        // a checkpoint operation at the same time. This is generally not an error.\n        if (ret != SQLITE_BUSY)\n            throw_sqlite3_exception(env, connection->db,\n                                    \"Cannot checkpoint the WAL database\");\n        return -1;\n    }\n\n    return jlong(nLog) << 32 | jlong(nCkpt);\n}\n\nstatic jlong nativeSQLiteHandle(JNIEnv *env,\n                                jclass clazz,\n                                jlong connectionPtr,\n                                jboolean acquire)\n{\n    SQLiteConnection *conn = (SQLiteConnection *) (intptr_t) connectionPtr;\n    sqlite3 *db = conn->db;\n\n    if (acquire) {\n        if (conn->notifyEnabled) {\n            // temporarily disable update hooks.\n            sqlite3_update_hook(db, nullptr, nullptr);\n            sqlite3_commit_hook(db, nullptr, nullptr);\n            sqlite3_rollback_hook(db, nullptr, nullptr);\n        }\n\n        return (jlong)(intptr_t) db;\n    } else {\n        if (conn->notifyEnabled) {\n            // reenable update hooks.\n            sqlite3_update_hook(db, sqliteUpdateHookCallback, conn);\n            sqlite3_commit_hook(db, sqliteCommitHookCallback, conn);\n            sqlite3_rollback_hook(db, sqliteRollbackHookCallback, conn);\n        }\n\n        return 0;\n    }\n}\n\nstatic void nativeSetUpdateNotification(JNIEnv *env,\n                                        jclass cls,\n                                        jlong connectionPtr,\n                                        jboolean enabled,\n                                        jboolean notifyRowId)\n{\n\n    SQLiteConnection *conn = (SQLiteConnection *) (intptr_t) connectionPtr;\n    assert(!conn->notifyCommited);\n    assert(!conn->lastNotifyDb && !conn->lastNotifyTable);\n\n    sqlite3 *db = conn->db;\n\n    if (enabled) {\n        sqlite3_update_hook(db, sqliteUpdateHookCallback, conn);\n        sqlite3_commit_hook(db, sqliteCommitHookCallback, conn);\n        sqlite3_rollback_hook(db, sqliteRollbackHookCallback, conn);\n    } else {\n        sqlite3_update_hook(db, nullptr, nullptr);\n        sqlite3_commit_hook(db, nullptr, nullptr);\n        sqlite3_rollback_hook(db, nullptr, nullptr);\n    }\n\n    conn->notifyEnabled = enabled;\n    conn->notifyRowId = notifyRowId;\n}\n\nstatic JNINativeMethod sMethods[] = {\n    {\"nativeOpen\", \"(Ljava/lang/String;ILjava/lang/String;)J\",\n     (void *) nativeOpen},\n    {\"nativeClose\", \"(J)V\", (void *) nativeClose},\n    {\"nativeSetKey\", \"(J[B)V\", (void *) nativeSetKey},\n    {\"nativeRegisterCustomFunction\",\n     \"(JLcom/tencent/wcdb/database/SQLiteCustomFunction;)V\",\n     (void *) nativeRegisterCustomFunction},\n    {\"nativeRegisterLocalizedCollators\", \"(JLjava/lang/String;)V\",\n     (void *) nativeRegisterLocalizedCollators},\n    {\"nativePrepareStatement\", \"(JLjava/lang/String;)J\",\n     (void *) nativePrepareStatement},\n    {\"nativeFinalizeStatement\", \"(JJ)V\", (void *) nativeFinalizeStatement},\n    {\"nativeGetParameterCount\", \"(JJ)I\", (void *) nativeGetParameterCount},\n    {\"nativeIsReadOnly\", \"(JJ)Z\", (void *) nativeIsReadOnly},\n    {\"nativeGetColumnCount\", \"(JJ)I\", (void *) nativeGetColumnCount},\n    {\"nativeGetColumnName\", \"(JJI)Ljava/lang/String;\",\n     (void *) nativeGetColumnName},\n    {\"nativeBindNull\", \"(JJI)V\", (void *) nativeBindNull},\n    {\"nativeBindLong\", \"(JJIJ)V\", (void *) nativeBindLong},\n    {\"nativeBindDouble\", \"(JJID)V\", (void *) nativeBindDouble},\n    {\"nativeBindString\", \"(JJILjava/lang/String;)V\", (void *) nativeBindString},\n    {\"nativeBindBlob\", \"(JJI[B)V\", (void *) nativeBindBlob},\n    {\"nativeResetStatement\", \"(JJZ)V\", (void *) nativeResetStatement},\n    {\"nativeExecute\", \"(JJ)V\", (void *) nativeExecute},\n    {\"nativeExecuteForLong\", \"(JJ)J\", (void *) nativeExecuteForLong},\n    {\"nativeExecuteForString\", \"(JJ)Ljava/lang/String;\",\n     (void *) nativeExecuteForString},\n    {\"nativeExecuteForChangedRowCount\", \"(JJ)I\",\n     (void *) nativeExecuteForChangedRowCount},\n    {\"nativeExecuteForLastInsertedRowId\", \"(JJ)J\",\n     (void *) nativeExecuteForLastInsertedRowId},\n    {\"nativeExecuteForCursorWindow\", \"(JJJIIZ)J\",\n     (void *) nativeExecuteForCursorWindow},\n    {\"nativeGetDbLookaside\", \"(J)I\", (void *) nativeGetDbLookaside},\n    {\"nativeCancel\", \"(J)V\", (void *) nativeCancel},\n    {\"nativeResetCancel\", \"(JZ)V\", (void *) nativeResetCancel},\n    {\"nativeSetWalHook\", \"(J)V\", (void *) nativeSetWalHook},\n    {\"nativeWalCheckpoint\", \"(JLjava/lang/String;)J\",\n     (void *) nativeWalCheckpoint},\n    {\"nativeSQLiteHandle\", \"(JZ)J\", (void *) nativeSQLiteHandle},\n    {\"nativeSetUpdateNotification\", \"(JZZ)V\",\n     (void *) nativeSetUpdateNotification},\n};\n\nstatic int register_wcdb_SQLiteConnection(JavaVM *vm, JNIEnv *env)\n{\n    gVM = vm;\n\n    jclass clazz;\n    FIND_CLASS(clazz, \"com/tencent/wcdb/database/SQLiteCustomFunction\");\n\n    GET_FIELD_ID(gSQLiteCustomFunctionClassInfo.name, clazz, \"name\",\n                 \"Ljava/lang/String;\");\n    GET_FIELD_ID(gSQLiteCustomFunctionClassInfo.numArgs, clazz, \"numArgs\", \"I\");\n    GET_METHOD_ID(gSQLiteCustomFunctionClassInfo.dispatchCallback, clazz,\n                  \"dispatchCallback\", \"([Ljava/lang/String;)V\");\n    env->DeleteLocalRef(clazz);\n\n    FIND_CLASS(clazz, \"java/lang/String\");\n    gStringClassInfo.clazz = jclass(env->NewGlobalRef(clazz));\n    env->DeleteLocalRef(clazz);\n\n    FIND_CLASS(clazz, \"com/tencent/wcdb/database/SQLiteConnection\");\n    GET_METHOD_ID(gSQLiteConnectionClassInfo.notifyCheckpoint, clazz,\n                  \"notifyCheckpoint\", \"(Ljava/lang/String;I)V\");\n    GET_METHOD_ID(gSQLiteConnectionClassInfo.notifyChange, clazz,\n                  \"notifyChange\",\n                  \"(Ljava/lang/String;Ljava/lang/String;[J[J[J)V\");\n\n    if (env->RegisterNatives(clazz, sMethods, NELEM(sMethods)) < 0) {\n        char msg[256];\n        snprintf(msg, sizeof(msg), \"RegisterNatives failed for '%s', aborting\",\n                 \"com/tencent/wcdb/database/SQLiteConnection\");\n        env->FatalError(msg);\n    }\n    env->DeleteLocalRef(clazz);\n\n    return 0;\n}\nWCDB_JNI_INIT(SQLiteConnection, register_wcdb_SQLiteConnection)\n\n} // namespace wcdb\n"
  },
  {
    "path": "deprecated/android/jni/com_tencent_wcdb_database_SQLiteDebug.cpp",
    "content": "/*\n * Copyright (C) 2007 The Android Open Source Project\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#define LOG_TAG \"WCDB.SQLiteDebug\"\n\n#include <jni.h>\n#include <sqlite3.h>\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include <unistd.h>\n\n#include \"JNIHelp.h\"\n#include \"Logger.h\"\n#include \"ModuleLoader.h\"\n#include \"SQLiteCommon.h\"\n#include <vfslog.h>\n\nnamespace wcdb {\n\nvolatile int sLastErrorLine = 0;\n\nstatic struct {\n    jfieldID memoryUsed;\n    jfieldID pageCacheOverflow;\n    jfieldID largestMemAlloc;\n} gSQLiteDebugPagerStatsClassInfo;\n\nstatic void nativeGetPagerStats(JNIEnv *env, jobject clazz, jobject statsObj)\n{\n    int memoryUsed;\n    int pageCacheOverflow;\n    int largestMemAlloc;\n    int unused;\n\n    sqlite3_status(SQLITE_STATUS_MEMORY_USED, &memoryUsed, &unused, 0);\n    sqlite3_status(SQLITE_STATUS_MALLOC_SIZE, &unused, &largestMemAlloc, 0);\n    sqlite3_status(SQLITE_STATUS_PAGECACHE_OVERFLOW, &pageCacheOverflow,\n                   &unused, 0);\n    env->SetIntField(statsObj, gSQLiteDebugPagerStatsClassInfo.memoryUsed,\n                     memoryUsed);\n    env->SetIntField(statsObj,\n                     gSQLiteDebugPagerStatsClassInfo.pageCacheOverflow,\n                     pageCacheOverflow);\n    env->SetIntField(statsObj, gSQLiteDebugPagerStatsClassInfo.largestMemAlloc,\n                     largestMemAlloc);\n}\n\nstatic jint nativeGetLastErrorLine(JNIEnv *env, jclass cls)\n{\n    return sLastErrorLine;\n}\n\nstatic void nativeSetIOTraceFlags(JNIEnv *env, jclass cls, jint flags)\n{\n    vlogDefaultLogFlags = (uint32_t) flags;\n}\n\nstatic void nativeGetIOTraceStats(JNIEnv *env,\n                                  jclass cls,\n                                  jlong connectionPtr,\n                                  jobject statsList)\n{\n    struct {\n        jfieldID dbName;\n        jfieldID path;\n        jfieldID pageSize;\n        jfieldID pageCount;\n        jfieldID journalMode;\n        jfieldID lastReadOffset;\n        jfieldID lastReadPage;\n        jfieldID lastWriteOffset;\n        jfieldID lastWritePage;\n        jfieldID lastJournalReadOffset;\n        jfieldID lastJournalReadPage;\n        jfieldID lastJournalWriteOffset;\n        jfieldID lastJournalWritePage;\n    } fieldsStats;\n\n    // Gather information from Java.\n    jclass clsArrayList = env->FindClass(\"java/util/ArrayList\");\n    if (!clsArrayList)\n        return;\n    jmethodID midArrayListAdd =\n        env->GetMethodID(clsArrayList, \"add\", \"(Ljava/lang/Object;)Z\");\n    if (!midArrayListAdd)\n        return;\n\n    jclass clsIOTraceStats =\n        env->FindClass(\"com/tencent/wcdb/database/SQLiteDebug$IOTraceStats\");\n    if (!clsIOTraceStats)\n        return;\n    jmethodID midIOTraceStatsCtor =\n        env->GetMethodID(clsIOTraceStats, \"<init>\", \"()V\");\n    if (!midIOTraceStatsCtor)\n        return;\n\n#define GET_FID(var, cls, name, sig)                                           \\\n    do {                                                                       \\\n        (var).name = env->GetFieldID((cls), #name, (sig));                     \\\n        if (!(var).name)                                                       \\\n            return;                                                            \\\n    } while (0)\n\n    GET_FID(fieldsStats, clsIOTraceStats, dbName, \"Ljava/lang/String;\");\n    GET_FID(fieldsStats, clsIOTraceStats, path, \"Ljava/lang/String;\");\n    GET_FID(fieldsStats, clsIOTraceStats, pageSize, \"J\");\n    GET_FID(fieldsStats, clsIOTraceStats, pageCount, \"J\");\n    GET_FID(fieldsStats, clsIOTraceStats, journalMode, \"Ljava/lang/String;\");\n    GET_FID(fieldsStats, clsIOTraceStats, lastReadOffset, \"J\");\n    GET_FID(fieldsStats, clsIOTraceStats, lastReadPage, \"[B\");\n    GET_FID(fieldsStats, clsIOTraceStats, lastWriteOffset, \"J\");\n    GET_FID(fieldsStats, clsIOTraceStats, lastWritePage, \"[B\");\n    GET_FID(fieldsStats, clsIOTraceStats, lastJournalReadOffset, \"J\");\n    GET_FID(fieldsStats, clsIOTraceStats, lastJournalReadPage, \"[B\");\n    GET_FID(fieldsStats, clsIOTraceStats, lastJournalWriteOffset, \"J\");\n    GET_FID(fieldsStats, clsIOTraceStats, lastJournalWritePage, \"[B\");\n\n#undef GET_FID\n\n    // List all attached databases.\n    sqlite3 *db = (sqlite3 *) (intptr_t) connectionPtr;\n    sqlite3_stmt *stmt;\n    int rc = sqlite3_prepare_v2(db, \"PRAGMA database_list;\", -1, &stmt, nullptr);\n    if (rc != SQLITE_OK) {\n        // Failed to compile PRAGMA database_list; probably caused by database corruption.\n        // Use hardcoded name and path for main database.\n        const char *path = sqlite3_db_filename(db, \"main\");\n        if (!path)\n            path = \"\";\n\n        char sql[256];\n        sqlite3_snprintf(sizeof(sql), sql,\n                         \"SELECT 0 as seq, 'main' as name, %Q as file;\", path);\n        rc = sqlite3_prepare_v2(db, sql, -1, &stmt, nullptr);\n        if (rc != SQLITE_OK) {\n            // Still failed, throw exception.\n            throw_sqlite3_exception(env, db, \"Cannot get I/O trace stats.\");\n            return;\n        }\n    }\n\n    while ((rc = sqlite3_step(stmt)) == SQLITE_ROW) {\n        // Create new IOTraceStats object.\n        jobject statsObj = env->NewObject(clsIOTraceStats, midIOTraceStatsCtor);\n        if (!statsObj) {\n            sqlite3_finalize(stmt);\n            return;\n        }\n\n        // Get and fill dbName.\n        const char *dbName = (const char *) sqlite3_column_text(stmt, 1);\n        const char *dbPath = (const char *) sqlite3_column_text(stmt, 2);\n        int pageSize = 4096;\n        jstring jstr = env->NewStringUTF(dbName);\n        env->SetObjectField(statsObj, fieldsStats.dbName, jstr);\n        env->DeleteLocalRef(jstr);\n        jstr = env->NewStringUTF(dbPath);\n        env->SetObjectField(statsObj, fieldsStats.path, jstr);\n        env->DeleteLocalRef(jstr);\n\n        char sql[256];\n        sqlite3_stmt *stmt2;\n\n        // pageSize\n        snprintf(sql, sizeof(sql), \"PRAGMA %s.page_size;\", dbName);\n        if (sqlite3_prepare_v2(db, sql, -1, &stmt2, nullptr) == SQLITE_OK) {\n            if (sqlite3_step(stmt2) == SQLITE_ROW) {\n                pageSize = sqlite3_column_int(stmt2, 0);\n                env->SetLongField(statsObj, fieldsStats.pageSize, pageSize);\n            }\n            sqlite3_finalize(stmt2);\n        }\n\n        // pageCount\n        snprintf(sql, sizeof(sql), \"PRAGMA %s.page_count;\", dbName);\n        if (sqlite3_prepare_v2(db, sql, -1, &stmt2, nullptr) == SQLITE_OK) {\n            if (sqlite3_step(stmt2) == SQLITE_ROW) {\n                int64_t pageCount = sqlite3_column_int64(stmt2, 0);\n                env->SetLongField(statsObj, fieldsStats.pageCount, pageCount);\n            }\n            sqlite3_finalize(stmt2);\n        }\n\n        // journalMode\n        snprintf(sql, sizeof(sql), \"PRAGMA %s.journal_mode;\", dbName);\n        if (sqlite3_prepare_v2(db, sql, -1, &stmt2, nullptr) == SQLITE_OK) {\n            if (sqlite3_step(stmt2) == SQLITE_ROW) {\n                const char *journalMode =\n                    (const char *) sqlite3_column_text(stmt2, 0);\n                jstring journalModeStr = env->NewStringUTF(journalMode);\n                env->SetObjectField(statsObj, fieldsStats.journalMode,\n                                    journalModeStr);\n                env->DeleteLocalRef(journalModeStr);\n            }\n            sqlite3_finalize(stmt2);\n        }\n\n        // last*Offset and last*Page\n        VLogStat stats;\n        rc = vlogGetStats(db, dbName, &stats);\n        if (rc == SQLITE_OK) {\n            sqlite3_file *f = nullptr;\n            sqlite3_file_control(db, dbName, SQLITE_FCNTL_FILE_POINTER, &f);\n            if (f) {\n                jbyteArray pageArr;\n                jbyte *page;\n\n                if (stats.lastMainReadOffset >= 0) {\n                    pageArr = env->NewByteArray(pageSize);\n                    if (!pageArr) {\n                        sqlite3_finalize(stmt);\n                        return;\n                    }\n                    jbyte *page = env->GetByteArrayElements(pageArr, nullptr);\n                    f->pMethods->xRead(f, page, pageSize,\n                                       stats.lastMainReadOffset);\n                    env->ReleaseByteArrayElements(pageArr, page, 0);\n                    env->SetObjectField(statsObj, fieldsStats.lastReadPage,\n                                        pageArr);\n                    env->DeleteLocalRef(pageArr);\n                } else {\n                    env->SetObjectField(statsObj, fieldsStats.lastReadPage,\n                                        nullptr);\n                }\n\n                if (stats.lastMainWriteOffset >= 0) {\n                    pageArr = env->NewByteArray(pageSize);\n                    if (!pageArr) {\n                        sqlite3_finalize(stmt);\n                        return;\n                    }\n                    page = env->GetByteArrayElements(pageArr, nullptr);\n                    f->pMethods->xRead(f, page, pageSize,\n                                       stats.lastMainWriteOffset);\n                    env->ReleaseByteArrayElements(pageArr, page, 0);\n                    env->SetObjectField(statsObj, fieldsStats.lastWritePage,\n                                        pageArr);\n                    env->DeleteLocalRef(pageArr);\n                } else {\n                    env->SetObjectField(statsObj, fieldsStats.lastWritePage,\n                                        nullptr);\n                }\n            }\n\n            f = nullptr;\n            sqlite3_file_control(db, dbName, SQLITE_FCNTL_JOURNAL_POINTER, &f);\n            if (f) {\n                jbyteArray pageArr;\n                jbyte *page;\n\n                if (stats.lastJournalReadOffset >= 0) {\n                    pageArr = env->NewByteArray(pageSize);\n                    if (!pageArr) {\n                        sqlite3_finalize(stmt);\n                        return;\n                    }\n                    jbyte *page = env->GetByteArrayElements(pageArr, nullptr);\n                    f->pMethods->xRead(f, page, pageSize,\n                                       stats.lastJournalReadOffset);\n                    env->ReleaseByteArrayElements(pageArr, page, 0);\n                    env->SetObjectField(\n                        statsObj, fieldsStats.lastJournalReadPage, pageArr);\n                    env->DeleteLocalRef(pageArr);\n                } else {\n                    env->SetObjectField(statsObj,\n                                        fieldsStats.lastJournalReadPage, nullptr);\n                }\n\n                if (stats.lastJournalWriteOffset >= 0) {\n                    pageArr = env->NewByteArray(pageSize);\n                    if (!pageArr) {\n                        sqlite3_finalize(stmt);\n                        return;\n                    }\n                    page = env->GetByteArrayElements(pageArr, nullptr);\n                    f->pMethods->xRead(f, page, pageSize,\n                                       stats.lastJournalWriteOffset);\n                    env->ReleaseByteArrayElements(pageArr, page, 0);\n                    env->SetObjectField(\n                        statsObj, fieldsStats.lastJournalWritePage, pageArr);\n                    env->DeleteLocalRef(pageArr);\n                } else {\n                    env->SetObjectField(statsObj,\n                                        fieldsStats.lastJournalWritePage, nullptr);\n                }\n            }\n\n            env->SetLongField(statsObj, fieldsStats.lastReadOffset,\n                              stats.lastMainReadOffset);\n            env->SetLongField(statsObj, fieldsStats.lastWriteOffset,\n                              stats.lastMainWriteOffset);\n            env->SetLongField(statsObj, fieldsStats.lastJournalReadOffset,\n                              stats.lastJournalReadOffset);\n            env->SetLongField(statsObj, fieldsStats.lastJournalWriteOffset,\n                              stats.lastJournalWriteOffset);\n        }\n\n        env->CallBooleanMethod(statsList, midArrayListAdd, statsObj);\n        env->DeleteLocalRef(statsObj);\n    } // while (sqlite3_step(stmt)\n    sqlite3_finalize(stmt);\n}\n\n/*\n     * JNI registration.\n     */\n\nstatic JNINativeMethod gMethods[] = {\n    {\"nativeGetPagerStats\",\n     \"(Lcom/tencent/wcdb/database/SQLiteDebug$PagerStats;)V\",\n     (void *) nativeGetPagerStats},\n    {\"nativeGetLastErrorLine\", \"()I\", (void *) nativeGetLastErrorLine},\n    {\"nativeSetIOTraceFlags\", \"(I)V\", (void *) nativeSetIOTraceFlags},\n    {\"nativeGetIOTraceStats\", \"(JLjava/util/ArrayList;)V\",\n     (void *) nativeGetIOTraceStats},\n};\n\nstatic int register_wcdb_SQLiteDebug(JavaVM *vm, JNIEnv *env)\n{\n    // Default vfslog flags.\n    vlogDefaultLogFlags = 0x001F407F;\n\n    jclass clazz;\n    FIND_CLASS(clazz, \"com/tencent/wcdb/database/SQLiteDebug$PagerStats\");\n\n    GET_FIELD_ID(gSQLiteDebugPagerStatsClassInfo.memoryUsed, clazz,\n                 \"memoryUsed\", \"I\");\n    GET_FIELD_ID(gSQLiteDebugPagerStatsClassInfo.largestMemAlloc, clazz,\n                 \"largestMemAlloc\", \"I\");\n    GET_FIELD_ID(gSQLiteDebugPagerStatsClassInfo.pageCacheOverflow, clazz,\n                 \"pageCacheOverflow\", \"I\");\n\n    return jniRegisterNativeMethods(env,\n                                    \"com/tencent/wcdb/database/SQLiteDebug\",\n                                    gMethods, NELEM(gMethods));\n}\nWCDB_JNI_INIT(SQLiteDebug, register_wcdb_SQLiteDebug)\n\n} // namespace wcdb\n"
  },
  {
    "path": "deprecated/android/jni/com_tencent_wcdb_database_SQLiteDirectQuery.cpp",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"JNIHelp.h\"\n#include \"ModuleLoader.h\"\n#include \"SQLiteCommon.h\"\n#include <jni.h>\n#include <sqlite3.h>\n#include <stdint.h>\n\nnamespace wcdb {\n\nstatic jlong\nnativeGetLong(JNIEnv *env, jclass cls, jlong statementPtr, jint column)\n{\n    sqlite3_stmt *stmt = (sqlite3_stmt *) (intptr_t) statementPtr;\n    return sqlite3_column_int64(stmt, column);\n}\n\nstatic jdouble\nnativeGetDouble(JNIEnv *env, jclass cls, jlong statementPtr, jint column)\n{\n    sqlite3_stmt *stmt = (sqlite3_stmt *) (intptr_t) statementPtr;\n    return sqlite3_column_double(stmt, column);\n}\n\nstatic jstring\nnativeGetString(JNIEnv *env, jclass cls, jlong statementPtr, jint column)\n{\n    sqlite3_stmt *stmt = (sqlite3_stmt *) (intptr_t) statementPtr;\n\n    // Use sqlite internal UTF-8 to UTF-16 conversion instead of NewStringUTF.\n    int len = sqlite3_column_bytes16(stmt, column) / 2;\n    const jchar *str = (const jchar *) sqlite3_column_text16(stmt, column);\n    return env->NewString(str, len);\n}\n\nstatic jbyteArray\nnativeGetBlob(JNIEnv *env, jclass cls, jlong statementPtr, jint column)\n{\n    sqlite3_stmt *stmt = (sqlite3_stmt *) (intptr_t) statementPtr;\n\n    const jbyte *blob = (const jbyte *) sqlite3_column_blob(stmt, column);\n    int len = sqlite3_column_bytes(stmt, column);\n\n    jbyteArray result = env->NewByteArray(len);\n    env->SetByteArrayRegion(result, 0, len, blob);\n    return result;\n}\n\nstatic jint\nnativeGetType(JNIEnv *env, jclass cls, jlong statementPtr, jint column)\n{\n    sqlite3_stmt *stmt = (sqlite3_stmt *) (intptr_t) statementPtr;\n    return sqlite3_column_type(stmt, column);\n}\n\nstatic jint nativeStep(JNIEnv *env, jclass cls, jlong statementPtr, jint count)\n{\n    sqlite3_stmt *stmt = (sqlite3_stmt *) (intptr_t) statementPtr;\n\n    jint i;\n    for (i = 0; i < count; i++) {\n        int ret = sqlite3_step(stmt);\n        if (ret == SQLITE_DONE) {\n            // Reach end of result, return i as total rows steped.\n            break;\n        } else if (ret != SQLITE_ROW) {\n            throw_sqlite3_exception(env, sqlite3_db_handle(stmt));\n            return -1;\n        }\n    }\n\n    return i;\n}\n\nstatic JNINativeMethod sMethods[] = {\n    {\"nativeGetLong\", \"(JI)J\", (void *) nativeGetLong},\n    {\"nativeGetDouble\", \"(JI)D\", (void *) nativeGetDouble},\n    {\"nativeGetString\", \"(JI)Ljava/lang/String;\", (void *) nativeGetString},\n    {\"nativeGetBlob\", \"(JI)[B\", (void *) nativeGetBlob},\n    {\"nativeGetType\", \"(JI)I\", (void *) nativeGetType},\n    {\"nativeStep\", \"(JI)I\", (void *) nativeStep},\n};\n\nstatic jint register_wcdb_SQLiteDirectQuery(JavaVM *vm, JNIEnv *env)\n{\n    return jniRegisterNativeMethods(\n        env, \"com/tencent/wcdb/database/SQLiteDirectQuery\", sMethods,\n        NELEM(sMethods));\n}\nWCDB_JNI_INIT(SQLiteDirectCursor, register_wcdb_SQLiteDirectQuery)\n}\n"
  },
  {
    "path": "deprecated/android/jni/com_tencent_wcdb_database_SQLiteGlobal.cpp",
    "content": "/*\n * Copyright (C) 2011 The Android Open Source Project\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include <jni.h>\n#include <sqlite3.h>\n#include <stdio.h>\n#include <assert.h>\n\n#include \"JNIHelp.h\"\n#include \"Logger.h\"\n#include \"ModuleLoader.h\"\n#include \"SQLiteCommon.h\"\n\n// Forward declarations\nextern \"C\" {\n    void sqlcipher_set_default_pagesize(int page_size);\n    void sqlcipher_set_default_kdf_iter(int iter);\n    void sqlcipher_set_default_use_hmac(int use);\n    int sqlcipher_set_default_hmac_algorithm(int algorithm);\n    int sqlcipher_set_default_kdf_algorithm(int algorithm);\n    void sqlcipher_set_mem_security(int);\n    int sqlite3_register_vfslog(const char *);\n}\nextern volatile uint32_t vlogDefaultLogFlags;\n\nnamespace wcdb {\n\nstatic JavaVM *gVM = nullptr;\n\n// Limit heap to 8MB for now.  This is 4 times the maximum cursor window\n// size, as has been used by the original code in SQLiteDatabase for\n// a long time.\nstatic const int SOFT_HEAP_LIMIT = 8 * 1024 * 1024;\n\nextern volatile int sLastErrorLine;\n\n// Called each time a message is logged.\nstatic void sqliteLogCallback(void *data, int iErrCode, const char *zMsg)\n{\n    // Extract line number for specific error codes.\n    const char *pattern = nullptr;\n    int priority = ANDROID_LOG_WARN;\n    switch (iErrCode & 0xFF) {\n        case SQLITE_NOTICE:\n            priority = ANDROID_LOG_INFO;\n            break;\n        case SQLITE_OK:\n        case SQLITE_SCHEMA:\n        case SQLITE_CONSTRAINT:\n            priority = ANDROID_LOG_DEBUG;\n            break;\n        case SQLITE_CORRUPT:\n            priority = ANDROID_LOG_ERROR;\n            pattern = \"database corruption at line %d of [\";\n            break;\n        case SQLITE_MISUSE:\n            priority = ANDROID_LOG_ERROR;\n            pattern = \"misuse at line %d of [\";\n            break;\n        case SQLITE_CANTOPEN:\n            priority = ANDROID_LOG_ERROR;\n            pattern = \"cannot open file at line %d of [\";\n            break;\n    }\n\n    if (pattern) {\n        int lineno;\n        int ret = sscanf(zMsg, pattern, &lineno);\n        if (ret > 0)\n            sLastErrorLine = lineno;\n    }\n\n    wcdb_log_print(priority, \"WCDB.SQLite\", \"[SQLite ErrCode: %d] %s\\n\",\n                   iErrCode, zMsg);\n}\n\nstatic int sqliteExtensionApiStealer(sqlite3 *db, const char **pzErrMsg,\n                                     const sqlite3_api_routines *pThunk)\n{\n    // Set the global API environment pointer then exit.\n    // XXX: Currently SQLite calls extension entry point with a static global sqlite3_api_routines\n    // structure that never change. We can safely store and reuse this structure.\n    JNIEnv *env = nullptr;\n    bool attached = false;\n    jint ret = gVM->GetEnv((void **) &env, JNI_VERSION_1_6);\n    if (ret == JNI_EDETACHED) {\n        jint ret = gVM->AttachCurrentThread(&env, nullptr);\n        assert(ret == JNI_OK);\n        (void) ret;\n        attached = true;\n    }\n\n    jclass clazz;\n    FIND_CLASS(clazz, \"com/tencent/wcdb/database/WCDBInitializationProbe\");\n\n    jfieldID fidApiEnv = env->GetStaticFieldID(clazz, \"apiEnv\", \"J\");\n    env->SetStaticLongField(clazz, fidApiEnv, (jlong)(intptr_t) pThunk);\n    env->DeleteLocalRef(clazz);\n\n    if (attached) {\n        gVM->DetachCurrentThread();\n    }\n    return SQLITE_OK;\n}\n\n// Sets the global SQLite configuration.\n// This must be called before any other SQLite functions are called.\nstatic void sqliteInitialize()\n{\n    // Enable multi-threaded mode.  In this mode, SQLite is safe to use by multiple\n    // threads as long as no two threads use the same database connection at the same\n    // time (which we guarantee in the SQLite database wrappers).\n    sqlite3_config(SQLITE_CONFIG_MULTITHREAD);\n\n    // Redirect SQLite log messages to the Android log.\n    sqlite3_config(SQLITE_CONFIG_LOG, &sqliteLogCallback, (void *) 1);\n\n    // The soft heap limit prevents the page cache allocations from growing\n    // beyond the given limit, no matter what the max page cache sizes are\n    // set to. The limit does not, as of 3.5.0, affect any other allocations.\n    sqlite3_soft_heap_limit(SOFT_HEAP_LIMIT);\n\n    // Register vfslog VFS.\n    sqlite3_register_vfslog(nullptr);\n\n    // Initialize SQLite.\n    sqlite3_initialize();\n\n    // Register the API environment stealer as the auto-loaded extension.\n    sqlite3_auto_extension((void (*)(void)) sqliteExtensionApiStealer);\n}\n\nstatic jint nativeReleaseMemory(JNIEnv *env, jclass clazz)\n{\n    return sqlite3_release_memory(SOFT_HEAP_LIMIT);\n}\n\nstatic void nativeInitialize(JNIEnv *env, jclass clazz, jint pageSize)\n{\n    sqliteInitialize();\n    sqlcipher_set_default_pagesize(pageSize);\n\n    // Keep compatibility to WCDB version 1.0, mainly the same as SQLCipher 3.\n    sqlcipher_set_default_kdf_iter(64000);\n    sqlcipher_set_default_use_hmac(1);\n    sqlcipher_set_default_hmac_algorithm(0);    // SHA1\n    sqlcipher_set_default_kdf_algorithm(0);     // SHA1\n    sqlcipher_set_mem_security(0);\n}\n\nstatic JNINativeMethod sMethods[] = {\n    /* name, signature, funcPtr */\n    {\"nativeInitialize\", \"(I)V\", (void *) nativeInitialize},\n    {\"nativeReleaseMemory\", \"()I\", (void *) nativeReleaseMemory},\n};\n\nstatic int register_wcdb_SQLiteGlobal(JavaVM *vm, JNIEnv *env)\n{\n    gVM = vm;\n\n    jclass clazz;\n    FIND_CLASS(clazz, \"com/tencent/wcdb/database/WCDBInitializationProbe\");\n\n    jfieldID fidLibLoaded = env->GetStaticFieldID(clazz, \"libLoaded\", \"Z\");\n    env->SetStaticBooleanField(clazz, fidLibLoaded, JNI_TRUE);\n    env->DeleteLocalRef(clazz);\n\n    return jniRegisterNativeMethods(env,\n                                    \"com/tencent/wcdb/database/SQLiteGlobal\",\n                                    sMethods, NELEM(sMethods));\n}\nWCDB_JNI_INIT(SQLiteGlobal, register_wcdb_SQLiteGlobal)\n\n} // namespace wcdb\n"
  },
  {
    "path": "deprecated/android/jni/com_tencent_wcdb_extension_fts_MMFtsTokenizer.cpp",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2018 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include <jni.h>\n#include \"JNIHelp.h\"\n#include \"SQLiteCommon.h\"\n#include <mm_fts.h>\n#include \"ModuleLoader.h\"\n\nSQLITE_EXTENSION_INIT3\n\nnamespace wcdb {\n\nstatic void nativeInitialize(JNIEnv *env, jclass cls, jlong sqlite3Ptr, jlong apiPtr) {\n    sqlite3 *db = (sqlite3 *)(intptr_t) sqlite3Ptr;\n    const sqlite3_api_routines *api = (const sqlite3_api_routines *)(intptr_t) apiPtr;\n\n    char *errMsg = NULL;\n    int rc = sqlite3_mmftsext_init(db, &errMsg, api);\n    if (rc != SQLITE_OK) {\n        throw_sqlite3_exception(env, rc, errMsg, \"Cannot initialize MMFtsTokenizer extension.\");\n        sqlite3_free(errMsg);\n    }\n}\n\nstatic JNINativeMethod sMethods[] = {\n        {\"nativeInitialize\", \"(JJ)V\", (void *) nativeInitialize},\n};\n\nstatic int register_extension_MMFtsTokenizer(JavaVM *vm, JNIEnv *env)\n{\n    return jniRegisterNativeMethods(env,\n                                    \"com/tencent/wcdb/extension/fts/MMFtsTokenizer\",\n                                    sMethods, NELEM(sMethods));\n}\nWCDB_JNI_INIT(MMFtsTokenizer, register_extension_MMFtsTokenizer)\n\n}\n"
  },
  {
    "path": "deprecated/android/jni/com_tencent_wcdb_repair_Backup.cpp",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"JNIHelp.h\"\n#include \"Logger.h\"\n#include \"ModuleLoader.h\"\n#include <mm_backup.h>\n#include <jni.h>\n#include <stdlib.h>\n#include <sys/time.h>\n\nnamespace wcdb {\n\nstatic void print_xlog(int prio, const char *msg)\n{\n    android_LogPriority level;\n    if (prio == MMBAK_LOG_DEBUG)\n        level = ANDROID_LOG_DEBUG;\n    else if (prio == MMBAK_LOG_INFO)\n        level = ANDROID_LOG_INFO;\n    else\n        level = ANDROID_LOG_ERROR;\n\n    wcdb_log_write(level, \"WCDB.BackupKit\", msg);\n}\n\nstatic jlong JNICALL BackupKit_nativeInit(\n    JNIEnv *env, jclass cls, jstring outPath, jbyteArray key, jint flags)\n{\n    const char *path_ = env->GetStringUTFChars(outPath, nullptr);\n    const unsigned char *key_;\n    int key_len_;\n\n    if (key) {\n        key_len_ = env->GetArrayLength(key);\n        key_ = (unsigned char *) env->GetByteArrayElements(key, nullptr);\n    } else {\n        key_len_ = 0;\n        key_ = nullptr;\n    }\n\n    mm_backup_ctx *ctx =\n        mm_backup_init(key_, key_len_, path_, (uint32_t) flags, print_xlog);\n    env->ReleaseStringUTFChars(outPath, path_);\n    if (key_)\n        env->ReleaseByteArrayElements(key, (jbyte *) key_, 0);\n\n    return (jlong)(intptr_t) ctx;\n}\n\nstatic jint JNICALL BackupKit_nativeRun(JNIEnv *env,\n                                        jclass cls,\n                                        jlong ctxHandle,\n                                        jlong dbHandle,\n                                        jobjectArray tableDesc)\n{\n    mm_backup_ctx *ctx = (mm_backup_ctx *) (intptr_t) ctxHandle;\n    sqlite3 *db = (sqlite3 *) (intptr_t) dbHandle;\n\n    mm_backup_tabdesc *tabdesc;\n    int num_tabdesc;\n    jstring *strarr;\n\n    if (tableDesc) {\n        // translate tableDesc to tabdesc array.\n        int count = env->GetArrayLength(tableDesc);\n        if (count & 0x01)\n            return -1; // make sure count is even.\n\n        num_tabdesc = count / 2;\n        tabdesc = (mm_backup_tabdesc *) alloca(sizeof(mm_backup_tabdesc) *\n                                               num_tabdesc);\n        strarr = (jstring *) alloca(sizeof(jstring) * count);\n        for (int i = 0; i < num_tabdesc; i++) {\n            const int ii = i + i;\n            strarr[ii] = (jstring) env->GetObjectArrayElement(tableDesc, ii);\n            strarr[ii + 1] =\n                (jstring) env->GetObjectArrayElement(tableDesc, ii + 1);\n            tabdesc[i].table =\n                strarr[ii] ? env->GetStringUTFChars(strarr[ii], nullptr) : nullptr;\n            tabdesc[i].condition =\n                strarr[ii + 1] ? env->GetStringUTFChars(strarr[ii + 1], nullptr)\n                               : nullptr;\n        }\n    } else {\n        tabdesc = nullptr;\n        num_tabdesc = 0;\n        strarr = nullptr;\n    }\n\n    int ret = mm_backup_run(ctx, db, tabdesc, num_tabdesc);\n\n    for (int i = 0; i < num_tabdesc; i++) {\n        const int ii = i + i;\n        if (strarr[ii])\n            env->ReleaseStringUTFChars(strarr[ii], tabdesc[i].table);\n        if (strarr[ii + 1])\n            env->ReleaseStringUTFChars(strarr[ii + 1], tabdesc[i].condition);\n    }\n\n    return ret;\n}\n\nstatic void JNICALL BackupKit_nativeCancel(JNIEnv *env,\n                                           jclass cls,\n                                           jlong ctxHandle)\n{\n    mm_backup_ctx *ctx = (mm_backup_ctx *) (intptr_t) ctxHandle;\n    mm_backup_cancel(ctx);\n}\n\nstatic void JNICALL BackupKit_nativeFinish(JNIEnv *env,\n                                           jclass cls,\n                                           jlong ctxHandle)\n{\n    mm_backup_ctx *ctx = (mm_backup_ctx *) (intptr_t) ctxHandle;\n    mm_backup_finish(ctx);\n}\n\nstatic jint JNICALL\nBackupKit_nativeStatementCount(JNIEnv *env, jclass cls, jlong ctxHandle)\n{\n    unsigned int stmt_count;\n    mm_backup_ctx *ctx = (mm_backup_ctx *) (intptr_t) ctxHandle;\n    mm_backup_statistics(ctx, &stmt_count);\n    return stmt_count;\n}\n\nstatic jstring\nBackupKit_nativeLastError(JNIEnv *env, jclass cls, jlong ctxHandle)\n{\n    mm_backup_ctx *ctx = (mm_backup_ctx *) (intptr_t) ctxHandle;\n    const char *errmsg = mm_backup_last_error(ctx);\n    return errmsg ? env->NewStringUTF(errmsg) : nullptr;\n}\n\nstatic jlong JNICALL RecoverKit_nativeInit(JNIEnv *env,\n                                           jclass cls,\n                                           jstring inPath,\n                                           jbyteArray key)\n{\n    const char *path_ = env->GetStringUTFChars(inPath, nullptr);\n    const unsigned char *key_;\n    int key_len_;\n\n    if (key) {\n        key_len_ = env->GetArrayLength(key);\n        key_ = (unsigned char *) env->GetByteArrayElements(key, nullptr);\n    } else {\n        key_len_ = 0;\n        key_ = nullptr;\n    }\n\n    mm_recover_ctx *ctx = mm_recover_init(path_, key_, key_len_, print_xlog);\n    env->ReleaseStringUTFChars(inPath, path_);\n    if (key_)\n        env->ReleaseByteArrayElements(key, (jbyte *) key_, 0);\n\n    return (jlong)(intptr_t) ctx;\n}\n\nstatic jint JNICALL RecoverKit_nativeRun(\n    JNIEnv *env, jclass cls, jlong ctxHandle, jlong dbHandle, jboolean fatal)\n{\n    mm_recover_ctx *ctx = (mm_recover_ctx *) (intptr_t) ctxHandle;\n    sqlite3 *db = (sqlite3 *) (intptr_t) dbHandle;\n\n    return mm_recover_run(ctx, db, fatal);\n}\n\nstatic void JNICALL RecoverKit_nativeCancel(JNIEnv *env,\n                                            jclass cls,\n                                            jlong ctxHandle)\n{\n    mm_recover_ctx *ctx = (mm_recover_ctx *) (intptr_t) ctxHandle;\n    mm_recover_cancel(ctx);\n}\n\nstatic void JNICALL RecoverKit_nativeFinish(JNIEnv *env,\n                                            jclass cls,\n                                            jlong ctxHandle)\n{\n    mm_recover_ctx *ctx = (mm_recover_ctx *) (intptr_t) ctxHandle;\n    mm_recover_finish(ctx);\n}\n\nstatic jint JNICALL RecoverKit_nativeSuccessCount(JNIEnv *env,\n                                                  jclass cls,\n                                                  jlong ctxHandle)\n{\n    unsigned int succ = 0;\n    mm_recover_ctx *ctx = (mm_recover_ctx *) (intptr_t) ctxHandle;\n    mm_recover_statistics(ctx, &succ, nullptr);\n    return succ;\n}\n\nstatic jint JNICALL RecoverKit_nativeFailureCount(JNIEnv *env,\n                                                  jclass cls,\n                                                  jlong ctxHandle)\n{\n    unsigned int fail = 0;\n    mm_recover_ctx *ctx = (mm_recover_ctx *) (intptr_t) ctxHandle;\n    mm_recover_statistics(ctx, nullptr, &fail);\n    return fail;\n}\n\nstatic jstring\nRecoverKit_nativeLastError(JNIEnv *env, jclass cls, jlong ctxHandle)\n{\n    mm_recover_ctx *ctx = (mm_recover_ctx *) (intptr_t) ctxHandle;\n    const char *errmsg = mm_recover_last_error(ctx);\n    return errmsg ? env->NewStringUTF(errmsg) : nullptr;\n}\n\nstatic const JNINativeMethod BackupKit_methods[] = {\n    {\"nativeInit\", \"(Ljava/lang/String;[BI)J\", (void *) BackupKit_nativeInit},\n    {\"nativeRun\", \"(JJ[Ljava/lang/String;)I\", (void *) BackupKit_nativeRun},\n    {\"nativeCancel\", \"(J)V\", (void *) BackupKit_nativeCancel},\n    {\"nativeFinish\", \"(J)V\", (void *) BackupKit_nativeFinish},\n    {\"nativeStatementCount\", \"(J)I\", (void *) BackupKit_nativeStatementCount},\n    {\"nativeLastError\", \"(J)Ljava/lang/String;\",\n     (void *) BackupKit_nativeLastError},\n};\n\nstatic const JNINativeMethod RecoverKit_methods[] = {\n    {\"nativeInit\", \"(Ljava/lang/String;[B)J\", (void *) RecoverKit_nativeInit},\n    {\"nativeRun\", \"(JJZ)I\", (void *) RecoverKit_nativeRun},\n    {\"nativeCancel\", \"(J)V\", (void *) RecoverKit_nativeCancel},\n    {\"nativeFinish\", \"(J)V\", (void *) RecoverKit_nativeFinish},\n    {\"nativeSuccessCount\", \"(J)I\", (void *) RecoverKit_nativeSuccessCount},\n    {\"nativeFailureCount\", \"(J)I\", (void *) RecoverKit_nativeFailureCount},\n    {\"nativeLastError\", \"(J)Ljava/lang/String;\",\n     (void *) RecoverKit_nativeLastError},\n};\n\nstatic int register_wcdb_repair_backup(JavaVM *vm, JNIEnv *env)\n{\n    jniRegisterNativeMethods(env, \"com/tencent/wcdb/repair/BackupKit\",\n                             BackupKit_methods, NELEM(BackupKit_methods));\n    jniRegisterNativeMethods(env, \"com/tencent/wcdb/repair/RecoverKit\",\n                             RecoverKit_methods, NELEM(RecoverKit_methods));\n\n    return 0;\n}\nWCDB_JNI_INIT(DBBackup, register_wcdb_repair_backup)\n}\n"
  },
  {
    "path": "deprecated/android/jni/com_tencent_wcdb_repair_DBDumpUtil.cpp",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#define LOG_TAG \"WCDB.DBDumpUtil\"\n\n#include <assert.h>\n#include <jni.h>\n#include <sqlite3.h>\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n\n#include \"JNIHelp.h\"\n#include \"Logger.h\"\n#include \"ModuleLoader.h\"\n\nnamespace wcdb {\n\nstruct previous_mode_data {\n    int valid; /* Is there legit data in here? */\n    int mode;\n    int showHeader;\n    int colWidth[100];\n};\n\n/*\n    ** An pointer to an instance of this structure is passed from\n    ** the main program to the callback.  This is used to communicate\n    ** state and mode information.\n    */\nstruct callback_data {\n    sqlite3 *db;        /* The database */\n    int echoOn;         /* True to echo input commands */\n    int statsOn;        /* True to display memory stats before each finalize */\n    int cnt;            /* Number of records displayed so far */\n    FILE *out;          /* Write results here */\n    FILE *traceOut;     /* Output for sqlite3_trace() */\n    int nErr;           /* Number of errors seen */\n    int mode;           /* An output mode setting */\n    int writableSchema; /* True if PRAGMA writable_schema=ON */\n    int showHeader;     /* True to show column names in List or Column mode */\n    char *zDestTable;   /* Name of destination table when MODE_Insert */\n    char separator[20]; /* Separator character for MODE_List */\n    int colWidth[100];  /* Requested width of each column when in column mode*/\n    int actualWidth[100]; /* Actual width of each column */\n    char nullvalue[20];   /* The text to print when a NULL comes back from\n                               ** the database */\n    struct previous_mode_data explainPrev;\n    /* Holds the mode information just before\n        ** .explain ON */\n    char outfile[FILENAME_MAX]; /* Filename for *out */\n    const char *zDbFilename;    /* name of the database file */\n    const char *zVfs;           /* Name of VFS to use */\n    sqlite3_stmt *pStmt;        /* Current statement if any. */\n    FILE *pLog;                 /* Write log output here */\n};\n\n/* zIn is either a pointer to a NULL-terminated string in memory obtained\n    ** from malloc(), or a NULL pointer. The string pointed to by zAppend is\n    ** added to zIn, and the result returned in memory obtained from malloc().\n    ** zIn, if it was not NULL, is freed.\n    **\n    ** If the third argument, quote, is not '\\0', then it is used as a\n    ** quote character for zAppend.\n    */\nchar *appendText(char *zIn, char const *zAppend, char quote)\n{\n    int len;\n    int i;\n    int nAppend = strlen(zAppend);\n    int nIn = (zIn ? strlen(zIn) : 0);\n\n    len = nAppend + nIn + 1;\n    if (quote) {\n        len += 2;\n        for (i = 0; i < nAppend; i++) {\n            if (zAppend[i] == quote)\n                len++;\n        }\n    }\n\n    zIn = (char *) realloc(zIn, len);\n    if (!zIn)\n        return 0;\n\n    if (quote) {\n        char *zCsr = &zIn[nIn];\n        *zCsr++ = quote;\n        for (i = 0; i < nAppend; i++) {\n            *zCsr++ = zAppend[i];\n            if (zAppend[i] == quote)\n                *zCsr++ = quote;\n        }\n        *zCsr++ = quote;\n        *zCsr++ = '\\0';\n        assert((zCsr - zIn) == len);\n    } else {\n        memcpy(&zIn[nIn], zAppend, nAppend);\n        zIn[len - 1] = '\\0';\n    }\n\n    return zIn;\n}\n\n/*\n    ** Execute a query statement that will generate SQL output.  Print\n    ** the result columns, comma-separated, on a line and then add a\n    ** semicolon terminator to the end of that line.\n    **\n    ** If the number of columns is 1 and that column contains text \"--\"\n    ** then write the semicolon on a separate line.  That way, if a\n    ** \"--\" comment occurs at the end of the statement, the comment\n    ** won't consume the semicolon terminator.\n    */\nint run_table_dump_query(\n    struct callback_data *p, /* Query context */\n    const char *zSelect,     /* SELECT statement to extract content */\n    const char *zFirstRow    /* Print before first row, if not NULL */\n    )\n{\n    sqlite3_stmt *pSelect;\n    int rc;\n    int nResult;\n    int i;\n    const char *z;\n    rc = sqlite3_prepare(p->db, zSelect, -1, &pSelect, 0);\n    if (rc != SQLITE_OK || !pSelect) {\n        fprintf(p->out, \"/**** ERROR: (%d) %s *****/\\n\", rc,\n                sqlite3_errmsg(p->db));\n        p->nErr++;\n        return rc;\n    }\n    rc = sqlite3_step(pSelect);\n    nResult = sqlite3_column_count(pSelect);\n    while (rc == SQLITE_ROW) {\n        if (zFirstRow) {\n            fprintf(p->out, \"%s\", zFirstRow);\n            zFirstRow = 0;\n        }\n        z = (const char *) sqlite3_column_text(pSelect, 0);\n        fprintf(p->out, \"%s\", z);\n        for (i = 1; i < nResult; i++) {\n            fprintf(p->out, \",%s\", sqlite3_column_text(pSelect, i));\n        }\n        if (z == 0)\n            z = \"\";\n        while (z[0] && (z[0] != '-' || z[1] != '-'))\n            z++;\n        if (z[0]) {\n            fprintf(p->out, \"\\n;\\n\");\n        } else {\n            fprintf(p->out, \";\\n\");\n        }\n        rc = sqlite3_step(pSelect);\n    }\n\n    rc = sqlite3_finalize(pSelect);\n    if (rc != SQLITE_OK) {\n        LOGI(LOG_TAG, \"/**** ERROR: (%d) %s *****/\\n\", rc,\n             sqlite3_errmsg(p->db));\n        p->nErr++;\n    }\n    return rc;\n}\n\n/*\n    ** This is a different callback routine used for dumping the database.\n    ** Each row received by this callback consists of a table name,\n    ** the table type (\"index\" or \"table\") and SQL to create the table.\n    ** This routine should print text sufficient to recreate the table.\n    */\nint dump_callback(void *pArg, int nArg, char **azArg, char **azCol)\n{\n    int rc;\n    const char *zTable;\n    const char *zType;\n    const char *zSql;\n    const char *zPrepStmt = 0;\n    struct callback_data *p = (struct callback_data *) pArg;\n\n    if (nArg != 3)\n        return 1;\n    zTable = azArg[0];\n    zType = azArg[1];\n    zSql = azArg[2];\n\n    if (strcmp(zTable, \"sqlite_sequence\") == 0) {\n        zPrepStmt = \"DELETE FROM sqlite_sequence;\\n\";\n    } else if (strcmp(zTable, \"sqlite_stat1\") == 0) {\n        fprintf(p->out, \"ANALYZE sqlite_master;\\n\");\n    } else if (strncmp(zTable, \"sqlite_\", 7) == 0) {\n        return 0;\n    } else if (strncmp(zSql, \"CREATE VIRTUAL TABLE\", 20) == 0) {\n        char *zIns;\n        if (!p->writableSchema) {\n            fprintf(p->out, \"PRAGMA writable_schema=ON;\\n\");\n            p->writableSchema = 1;\n        }\n        zIns = sqlite3_mprintf(\n            \"INSERT INTO sqlite_master(type,name,tbl_name,rootpage,sql)\"\n            \"VALUES('table','%q','%q',0,'%q');\",\n            zTable, zTable, zSql);\n        fprintf(p->out, \"%s\\n\", zIns);\n        sqlite3_free(zIns);\n        return 0;\n    } else {\n        fprintf(p->out, \"%s;\\n\", zSql);\n    }\n    if (strcmp(zType, \"table\") == 0) {\n        sqlite3_stmt *pTableInfo = 0;\n        char *zSelect = 0;\n        char *zTableInfo = 0;\n        char *zTmp = 0;\n        int nRow = 0;\n\n        zTableInfo = appendText(zTableInfo, \"PRAGMA table_info(\", 0);\n        zTableInfo = appendText(zTableInfo, zTable, '\"');\n        zTableInfo = appendText(zTableInfo, \");\", 0);\n\n        rc = sqlite3_prepare(p->db, zTableInfo, -1, &pTableInfo, 0);\n        free(zTableInfo);\n        if (rc != SQLITE_OK || !pTableInfo) {\n            return 1;\n        }\n\n        zSelect = appendText(zSelect, \"SELECT 'INSERT INTO ' || \", 0);\n        /* Always quote the table name, even if it appears to be pure ascii,\n            ** in case it is a keyword. Ex:  INSERT INTO \"table\" ... */\n        zTmp = appendText(zTmp, zTable, '\"');\n        if (zTmp) {\n            zSelect = appendText(zSelect, zTmp, '\\'');\n            free(zTmp);\n        }\n        zSelect = appendText(zSelect, \" || ' VALUES(' || \", 0);\n        rc = sqlite3_step(pTableInfo);\n        while (rc == SQLITE_ROW) {\n            const char *zText =\n                (const char *) sqlite3_column_text(pTableInfo, 1);\n            zSelect = appendText(zSelect, \"quote(\", 0);\n            zSelect = appendText(zSelect, zText, '\"');\n            rc = sqlite3_step(pTableInfo);\n            if (rc == SQLITE_ROW) {\n                zSelect = appendText(zSelect, \"), \", 0);\n            } else {\n                zSelect = appendText(zSelect, \") \", 0);\n            }\n            nRow++;\n        }\n        rc = sqlite3_finalize(pTableInfo);\n        if (rc != SQLITE_OK || nRow == 0) {\n            free(zSelect);\n            return 1;\n        }\n        zSelect = appendText(zSelect, \"|| ')' FROM  \", 0);\n        zSelect = appendText(zSelect, zTable, '\"');\n\n        rc = run_table_dump_query(p, zSelect, zPrepStmt);\n        if (rc == SQLITE_CORRUPT) {\n            zSelect = appendText(zSelect, \" ORDER BY rowid DESC\", 0);\n            run_table_dump_query(p, zSelect, 0);\n        }\n        free(zSelect);\n    }\n    return 0;\n}\n\nint run_schema_dump_query(struct callback_data *p, const char *zQuery)\n{\n    int rc;\n    char *zErr = 0;\n    rc = sqlite3_exec(p->db, zQuery, dump_callback, p, &zErr);\n    if (rc == SQLITE_CORRUPT) {\n        char *zQ2;\n        int len = strlen(zQuery);\n        fprintf(p->out, \"/****** ERROR: %s ******/\\n\", zErr);\n        if (zErr) {\n            LOGI(LOG_TAG, \"/****** %s ******/\\n\", zErr);\n            sqlite3_free(zErr);\n            zErr = 0;\n        }\n        zQ2 = (char *) malloc(len + 100);\n        if (zQ2 == 0)\n            return rc;\n        sqlite3_snprintf(len + 100, zQ2, \"%s ORDER BY rowid DESC\", zQuery);\n        rc = sqlite3_exec(p->db, zQ2, dump_callback, p, &zErr);\n        if (rc) {\n            fprintf(p->out, \"/****** ERROR: %s ******/\\n\", zErr);\n        } else {\n            rc = SQLITE_CORRUPT;\n        }\n        sqlite3_free(zErr);\n        free(zQ2);\n    }\n    return rc;\n}\n\n/*\n** Make sure the database is open.  If it is not, then open it.  If\n** the database fails to open, print an error message and exit.\n*/\nint open_db(struct callback_data *p, const char *key)\n{\n    if (p->db == 0) {\n        int errcode = 0;\n        sqlite3_initialize();\n        errcode = sqlite3_open(p->zDbFilename, &p->db);\n        if (errcode != SQLITE_DONE && errcode != SQLITE_OK &&\n            errcode != SQLITE_ROW) {\n            LOGE(LOG_TAG, \"Error: in sqlite3_open \");\n            return -1;\n        }\n        if (key) {\n            errcode = sqlite3_key(p->db, key, 7);\n            if (errcode != SQLITE_DONE && errcode != SQLITE_OK &&\n                errcode != SQLITE_ROW) {\n                LOGE(LOG_TAG, \"Error: setKey \");\n                return -1;\n            }\n        }\n        sqlite3 *db = p->db;\n        if (db == 0 || SQLITE_OK != sqlite3_errcode(db)) {\n            LOGE(LOG_TAG, \"Error: unable to open database \\\"%s\\\": %s\\n\",\n                 p->zDbFilename, sqlite3_errmsg(db));\n            return -1;\n        }\n#ifndef SQLITE_OMIT_LOAD_EXTENSION\n        sqlite3_enable_load_extension(p->db, 1);\n#endif\n    }\n    return 0;\n}\n\nint run_command_db_dump(const char *dbPath,\n                        const char *dbKey,\n                        const char *outFile)\n{\n    struct callback_data data, *p;\n    p = &data;\n\n    //main_init(p);\n    memset(&data, 0, sizeof(data));\n    data.mode = 2;\n    memcpy(data.separator, \"|\", 2);\n    data.showHeader = 0;\n\n    data.zDbFilename = dbPath;\n    int errcode = open_db(p, dbKey);\n    if (errcode < 0)\n        return errcode;\n\n    p->out = fopen(outFile, \"w\");\n    fprintf(p->out, \"PRAGMA foreign_keys=OFF;\\n\");\n    fprintf(p->out, \"BEGIN TRANSACTION;\\n\");\n    p->writableSchema = 0;\n    errcode = sqlite3_exec(p->db, \"SAVEPOINT dump; PRAGMA writable_schema=ON\",\n                           0, 0, 0);\n    if (errcode != SQLITE_DONE && errcode != SQLITE_OK &&\n        errcode != SQLITE_ROW) {\n        if (p->db)\n            sqlite3_close(p->db);\n        LOGE(LOG_TAG,\n             \"error in execute SAVEPOINT dump; PRAGMA writable_schema=ON\");\n        return -1;\n    }\n    p->nErr = 0;\n    errcode = run_schema_dump_query(\n        p, \"SELECT name, type, sql FROM sqlite_master \"\n           \"WHERE sql NOT NULL AND type=='table' AND name!='sqlite_sequence'\");\n    if (errcode != SQLITE_DONE && errcode != SQLITE_OK &&\n        errcode != SQLITE_ROW) {\n        if (p->db)\n            sqlite3_close(p->db);\n        LOGE(\n            LOG_TAG, \"error in run_schema_dump_query %s\",\n            \"SELECT name, type, sql FROM sqlite_master \"\n            \"WHERE sql NOT NULL AND type=='table' AND name!='sqlite_sequence'\");\n        return -1;\n    }\n    errcode =\n        run_schema_dump_query(p, \"SELECT name, type, sql FROM sqlite_master \"\n                                 \"WHERE name=='sqlite_sequence'\");\n    if (errcode != SQLITE_DONE && errcode != SQLITE_OK &&\n        errcode != SQLITE_ROW) {\n        if (p->db)\n            sqlite3_close(p->db);\n        LOGE(LOG_TAG, \"error in run_schema_dump_query %s\",\n             \"SELECT name, type, sql FROM sqlite_master \"\n             \"WHERE name=='sqlite_sequence'\");\n        return -1;\n    }\n    errcode = run_table_dump_query(\n        p, \"SELECT sql FROM sqlite_master \"\n           \"WHERE sql NOT NULL AND type IN ('index','trigger','view')\",\n        0);\n    if (errcode != SQLITE_DONE && errcode != SQLITE_OK &&\n        errcode != SQLITE_ROW) {\n        if (p->db)\n            sqlite3_close(p->db);\n        LOGE(LOG_TAG, \"error in SELECT sql FROM sqlite_master WHERE sql NOT \"\n                      \"NULL AND type IN ('index','trigger','view')\");\n        return -1;\n    }\n    if (p->writableSchema) {\n        fprintf(p->out, \"PRAGMA writable_schema=OFF;\\n\");\n        p->writableSchema = 0;\n    }\n    sqlite3_exec(p->db, \"PRAGMA writable_schema=OFF;\", 0, 0, 0);\n    sqlite3_exec(p->db, \"RELEASE dump;\", 0, 0, 0);\n    fprintf(p->out, p->nErr ? \"ROLLBACK; -- due to errors\\n\" : \"COMMIT;\\n\");\n    if (p->out) {\n        fclose(p->out);\n    }\n    if (p->db)\n        sqlite3_close(p->db);\n    return 0;\n}\n\nstatic jboolean JNICALL nativeDumpDB(JNIEnv *env,\n                                     jclass clazz,\n                                     jstring dbPathStr,\n                                     jstring keyStr,\n                                     jstring outPathStr)\n{\n    const char *dbPath = env->GetStringUTFChars(dbPathStr, nullptr);\n    const char *key = nullptr;\n    if (keyStr)\n        key = env->GetStringUTFChars(keyStr, nullptr);\n    const char *outPath = (env)->GetStringUTFChars(outPathStr, nullptr);\n\n    int rc = run_command_db_dump(dbPath, key, outPath);\n\n    env->ReleaseStringUTFChars(dbPathStr, dbPath);\n    if (key)\n        env->ReleaseStringUTFChars(keyStr, key);\n    env->ReleaseStringUTFChars(outPathStr, outPath);\n\n    return (rc < 0) ? JNI_FALSE : JNI_TRUE;\n}\n\nstatic jboolean nativeIsSqlComplete(JNIEnv *env, jclass clazz, jstring sqlStr)\n{\n    const char *sql = env->GetStringUTFChars(sqlStr, nullptr);\n    int rc = sqlite3_complete(sql);\n    env->ReleaseStringUTFChars(sqlStr, sql);\n\n    return rc > 0 ? JNI_TRUE : JNI_FALSE;\n}\n\nstatic const JNINativeMethod sMethods[] = {\n    {\"nativeDumpDB\",\n     \"(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Z\",\n     (void *) nativeDumpDB},\n    {\"nativeIsSqlComplete\", \"(Ljava/lang/String;)Z\",\n     (void *) nativeIsSqlComplete}};\n\nstatic int register_wcdb_DBDumpUtil(JavaVM *vm, JNIEnv *env)\n{\n    return jniRegisterNativeMethods(env, \"com/tencent/wcdb/repair/DBDumpUtil\",\n                                    sMethods, NELEM(sMethods));\n}\nWCDB_JNI_INIT(DBDumpUtil, register_wcdb_DBDumpUtil)\n}\n"
  },
  {
    "path": "deprecated/android/jni/com_tencent_wcdb_repair_RepairKit.cpp",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"JNIHelp.h\"\n#include \"Logger.h\"\n#include \"ModuleLoader.h\"\n#include \"SQLiteCommon.h\"\n#include <sqlite3.h>\n#include <jni.h>\n#include <SQLiteRepairKit.h>\n#include <stdlib.h>\n#include <stdio.h>\n#include <string.h>\n#include <vector>\n\nstatic int g_error_result = 0;\nstatic char g_error_msg[2048] = {0};\n\nnamespace wcdb {\n\nstatic jmethodID sMID_onProgress = nullptr;\n\nstatic sqliterk_cipher_conf *parseCipherSpec(JNIEnv *env, jobject cipherSpec)\n{\n    sqliterk_cipher_conf *result = nullptr;\n    jfieldID fidKdfIteration;\n    jfieldID fidHmacEnabled;\n    jfieldID fidPageSize;\n\n    if (!cipherSpec) {\n        result = (sqliterk_cipher_conf *) malloc(sizeof(sqliterk_cipher_conf));\n        if (!result) return nullptr;\n\n        memset(result, 0, sizeof(sqliterk_cipher_conf));\n        result->use_hmac = -1;\n        return result;\n    }\n\n    jclass clsCipherSpec =\n        env->FindClass(\"com/tencent/wcdb/database/SQLiteCipherSpec\");\n    if (!clsCipherSpec)\n        goto bail;\n\n    fidKdfIteration = env->GetFieldID(clsCipherSpec, \"kdfIteration\", \"I\");\n    if (!fidKdfIteration)\n        goto bail;\n    fidHmacEnabled = env->GetFieldID(clsCipherSpec, \"hmacEnabled\", \"Z\");\n    if (!fidHmacEnabled)\n        goto bail;\n    fidPageSize = env->GetFieldID(clsCipherSpec, \"pageSize\", \"I\");\n    if (!fidPageSize)\n        goto bail;\n\n    result = (sqliterk_cipher_conf *) malloc(sizeof(sqliterk_cipher_conf));\n    if (!result) return nullptr;\n    memset(result, 0, sizeof(sqliterk_cipher_conf));\n\n    result->page_size = env->GetIntField(cipherSpec, fidPageSize);\n    result->kdf_iter = env->GetIntField(cipherSpec, fidKdfIteration);\n    result->use_hmac = env->GetBooleanField(cipherSpec, fidHmacEnabled);\n\n    return result;\n\nbail:\n    free(result);\n    return nullptr;\n}\n\nstatic JNICALL jlong nativeInit(JNIEnv *env,\n                                jclass cls,\n                                jstring pathStr,\n                                jbyteArray keyArr,\n                                jobject cipherSpec,\n                                jbyteArray saltArr)\n{\n\n    sqliterk *rk = nullptr;\n    sqliterk_cipher_conf *conf = parseCipherSpec(env, cipherSpec);\n    if (!conf)\n        return 0;\n\n    if (keyArr) {\n        conf->key_len = env->GetArrayLength(keyArr);\n        if (conf->key_len > 4096) {\n            free(conf);\n            return 0;\n        }\n\n        conf->key = alloca(conf->key_len);\n        env->GetByteArrayRegion(keyArr, 0, conf->key_len, (jbyte *) conf->key);\n    }\n    if (saltArr) {\n        if (env->GetArrayLength(saltArr) < 16) {\n            free(conf);\n            return 0;\n        }\n\n        conf->kdf_salt = (unsigned char *) alloca(16);\n        env->GetByteArrayRegion(saltArr, 0, 16, (jbyte *) conf->kdf_salt);\n    } else {\n        conf->kdf_salt = nullptr;\n    }\n\n    const char *path = env->GetStringUTFChars(pathStr, nullptr);\n    int rc = sqliterk_open(path, conf, &rk);\n    env->ReleaseStringUTFChars(pathStr, path);\n\n    free(conf);\n    return (rc == SQLITERK_OK) ? (jlong)(intptr_t) rk : 0;\n}\n\nstatic JNICALL void nativeFini(JNIEnv *env, jclass cls, jlong rkPtr)\n{\n    sqliterk *rk = (sqliterk *) (intptr_t) rkPtr;\n    sqliterk_close(rk);\n}\n\nstruct callback_data {\n    JNIEnv *env;\n    jobject obj;\n    jstring last_table;\n    int last_root;\n};\n\nstatic int output_callback(void *user, sqliterk *rk, sqliterk_table *table, sqliterk_column *column)\n{\n    callback_data *d = (callback_data *) user;\n    const char *table_name = sqliterk_table_name(table);\n    int root = sqliterk_table_root(table);\n\n    if (d->last_root != root) {\n        if (d->last_table)\n            d->env->DeleteLocalRef(d->last_table);\n        \n        d->last_table = d->env->NewStringUTF(table_name);\n        d->last_root = root;\n    }\n\n    jint result = d->env->CallIntMethod(d->obj, sMID_onProgress, d->last_table,\n        root, (jlong) (intptr_t) column);\n\n    switch (result) {\n        case 0: // RESULT_OK\n            return SQLITERK_OK;\n        case 1: // RESULT_CANCELLED\n            return SQLITERK_CANCELLED;\n        case 2: // RESULT_IGNORE\n            return SQLITERK_IGNORE;\n    }\n    return SQLITERK_MISUSE;\n}\n\nstatic JNICALL jint nativeOutput(JNIEnv *env,\n                                     jobject obj,\n                                     jlong rkPtr,\n                                     jlong dbPtr,\n                                     jlong masterPtr,\n                                     jlong leafPtr,\n                                     jint flags)\n{\n    sqliterk *rk = (sqliterk *) (intptr_t) rkPtr;\n    sqlite3 *db = (sqlite3 *) (intptr_t) dbPtr;\n    sqliterk_master_info *master =(sqliterk_master_info *) (intptr_t) masterPtr;\n    sqliterk_leaf_info *leaf = (sqliterk_leaf_info *) (intptr_t) leafPtr;\n\n    callback_data data;\n    data.env = env;\n    data.obj = obj;\n    data.last_table = nullptr;\n    data.last_root = 0;\n    \n    int rc = sqliterk_output_cb_leaf(rk, db, master, leaf, flags, output_callback, &data);\n    if (rc == SQLITERK_OK) return 0;\n    if (rc == SQLITERK_CANCELLED) return 1;\n    return -1;\n}\n\nstatic JNICALL void nativeCancel(JNIEnv *env, jclass cls, jlong rkPtr)\n{\n    sqliterk *rk = (sqliterk *) (intptr_t) rkPtr;\n    sqliterk_cancel(rk);\n}\n\nstatic JNICALL jint nativeIntegrityFlags(JNIEnv *env, jclass cls, jlong rkPtr)\n{\n    sqliterk *rk = (sqliterk *) (intptr_t) rkPtr;\n    return (jint) sqliterk_integrity(rk);\n}\n\nstatic JNICALL jstring nativeLastError(JNIEnv *env, jclass cls)\n{\n    return env->NewStringUTF(g_error_msg);\n}\n\nstatic JNICALL jintArray nativeGetStatistics(JNIEnv *env, jclass cls, jlong rkPtr)\n{\n    sqliterk *rk = (sqliterk *) (intptr_t) rkPtr;\n    jint st[4];\n\n    st[0] = sqliterk_page_count(rk);\n    st[1] = sqliterk_valid_page_count(rk);\n    st[2] = sqliterk_parsed_page_count(rk);\n    st[3] = sqliterk_damaged_page_count(rk);\n\n    jintArray result = env->NewIntArray(4);\n    env->SetIntArrayRegion(result, 0, 4, st);\n    return result;\n}\n\nstatic JNICALL jlong nativeMakeMaster(JNIEnv *env,\n                                      jclass cls,\n                                      jobjectArray tableArr)\n{\n    int num_tables = env->GetArrayLength(tableArr);\n    const char **tables =\n        (const char **) malloc(sizeof(const char *) * num_tables);\n\n    for (int i = 0; i < num_tables; i++) {\n        jstring str = (jstring) env->GetObjectArrayElement(tableArr, i);\n        tables[i] = env->GetStringUTFChars(str, nullptr);\n        env->DeleteLocalRef(str);\n    }\n\n    sqliterk_master_info *master = nullptr;\n    int rc = sqliterk_make_master(tables, num_tables, &master);\n\n    for (int i = 0; i < num_tables; i++) {\n        jstring str = (jstring) env->GetObjectArrayElement(tableArr, i);\n        env->ReleaseStringUTFChars(str, tables[i]);\n        env->DeleteLocalRef(str);\n    }\n    free(tables);\n\n    return (rc == SQLITERK_OK) ? (jlong) master : 0;\n}\n\nstatic JNICALL jboolean nativeSaveMaster(\n    JNIEnv *env, jclass cls, jlong dbPtr, jstring pathStr, jbyteArray keyArr)\n{\n    sqlite3 *db = (sqlite3 *) (intptr_t) dbPtr;\n\n    int key_len = 0;\n    jbyte *key = nullptr;\n    if (keyArr) {\n        key_len = env->GetArrayLength(keyArr);\n        if (key_len > 4096)\n            return 0;\n\n        key = (jbyte *) alloca(key_len);\n        env->GetByteArrayRegion(keyArr, 0, key_len, key);\n    }\n\n    const char *path = env->GetStringUTFChars(pathStr, nullptr);\n    int rc = sqliterk_save_master(db, path, key, key_len);\n    env->ReleaseStringUTFChars(pathStr, path);\n\n    return (rc == SQLITERK_OK) ? JNI_TRUE : JNI_FALSE;\n}\n\nstatic JNICALL jlong nativeLoadMaster(JNIEnv *env,\n                                      jclass cls,\n                                      jstring pathStr,\n                                      jbyteArray keyArr,\n                                      jobjectArray tableArr,\n                                      jbyteArray outSaltArr)\n{\n    // Path is guaranteed to be non-null by the Java part.\n    const char *path = env->GetStringUTFChars(pathStr, nullptr);\n\n    int key_len = 0;\n    jbyte *key = nullptr;\n    if (keyArr) {\n        key_len = env->GetArrayLength(keyArr);\n        key = env->GetByteArrayElements(keyArr, nullptr);\n    }\n\n    int num_tables = 0;\n    const char **tables = nullptr;\n    if (tableArr) {\n        num_tables = env->GetArrayLength(tableArr);\n        tables = (const char **) malloc(sizeof(const char *) * num_tables);\n\n        for (int i = 0; i < num_tables; i++) {\n            jstring str = (jstring) env->GetObjectArrayElement(tableArr, i);\n            tables[i] = env->GetStringUTFChars(str, nullptr);\n            env->DeleteLocalRef(str);\n        }\n    }\n\n    unsigned char salt[16];\n    sqliterk_master_info *master = nullptr;\n    int rc = sqliterk_load_master(path, key, key_len, tables, num_tables,\n                                  &master, salt);\n\n    if (outSaltArr) {\n        int len = env->GetArrayLength(outSaltArr);\n        if (len < 16)\n            return 0;\n\n        env->SetByteArrayRegion(outSaltArr, 0, sizeof(salt), (jbyte *) salt);\n    }\n\n    if (tableArr) {\n        for (int i = 0; i < num_tables; i++) {\n            jstring str = (jstring) env->GetObjectArrayElement(tableArr, i);\n            env->ReleaseStringUTFChars(str, tables[i]);\n            env->DeleteLocalRef(str);\n        }\n        free(tables);\n    }\n\n    if (key)\n        env->ReleaseByteArrayElements(keyArr, key, 0);\n\n    env->ReleaseStringUTFChars(pathStr, path);\n\n    return (rc == SQLITERK_OK) ? (jlong)(intptr_t) master : 0;\n}\n\nstatic JNICALL void nativeFreeMaster(JNIEnv *env, jclass cls, jlong masterPtr)\n{\n    sqliterk_master_info *master =\n        (sqliterk_master_info *) (intptr_t) masterPtr;\n    sqliterk_free_master(master);\n}\n\n// TODO: global variable should not be used here\nstatic volatile int sScanCancelFlag = 0;\nstatic JNICALL jlong nativeScanLeaf(JNIEnv *env, jclass cls, jlong dbPtr, jobjectArray tableArr,\n                                    jlongArray outCancelFlag)\n{\n    sqlite3 *db = (sqlite3 *) (intptr_t) dbPtr;\n    std::vector<const char *> tables;\n    if (tableArr) {\n        int num_tables = env->GetArrayLength(tableArr);\n        tables = std::vector<const char *>(num_tables);\n        for (int i = 0; i < num_tables; ++i) {\n            jstring str = static_cast<jstring>(env->GetObjectArrayElement(tableArr, i));\n            tables[i] = (env->GetStringUTFChars(str, NULL));\n            env->DeleteLocalRef(str);\n        }\n    }\n\n    if (outCancelFlag) {\n        sScanCancelFlag = 0;\n        jlong ptr = (jlong) (intptr_t) &sScanCancelFlag;\n        env->SetLongArrayRegion(outCancelFlag, 0, 1, &ptr);\n    }\n\n    sqliterk_leaf_info *out;\n    int rc = sqliterk_scan_leaf(db, tables.data(), tables.size(), &out,\n                                outCancelFlag ? &sScanCancelFlag : nullptr);\n    jlong result = (rc == SQLITE_OK) ? (jlong) (intptr_t) out : 0;\n\n    for (int i = 0; i < tables.size(); ++i) {\n        jstring str = static_cast<jstring>(env->GetObjectArrayElement(tableArr, i));\n        env->ReleaseStringUTFChars(str, tables[i]);\n        env->DeleteLocalRef(str);\n    }\n\n    if (rc != SQLITE_OK) {\n        throw_sqlite3_exception(env, db);\n    }\n\n    return result;\n}\n\nstatic JNICALL void nativeCancelScanLeaf(JNIEnv *env, jclass cls, jlong cancelFlagPtr) {\n    *(volatile int *) (intptr_t) cancelFlagPtr = 1;\n}\n\nstatic JNICALL jboolean nativeSaveLeaf(JNIEnv *env, jclass cls, jlong leafPtr, jstring pathStr) {\n    sqliterk_leaf_info *li = (sqliterk_leaf_info *) (intptr_t) leafPtr;\n\n    const char *path = env->GetStringUTFChars(pathStr, nullptr);\n    int rc = sqliterk_save_leaf(li, path);\n\n    env->ReleaseStringUTFChars(pathStr, path);\n    return rc == SQLITERK_OK;\n}\n\nstatic JNICALL jlong nativeLoadLeaf(JNIEnv *env, jclass cls, jstring pathStr) {\n    const char *path = env->GetStringUTFChars(pathStr, nullptr);\n\n    sqliterk_leaf_info *out;\n    int rc = sqliterk_load_leaf(path, &out);\n\n    env->ReleaseStringUTFChars(pathStr, path);\n    return rc == SQLITERK_OK ? (jlong) (intptr_t) out : 0;\n}\n\nstatic JNICALL void nativeFreeLeaf(JNIEnv *env, jclass cls, jlong leafPtr) {\n    sqliterk_free_leaf((sqliterk_leaf_info *) (intptr_t) leafPtr);\n}\n\nstatic JNICALL jint cursorNativeGetColumnCount(JNIEnv *env, jclass, jlong ptr)\n{\n    sqliterk_column *column = (sqliterk_column *) (intptr_t) ptr;\n    return sqliterk_column_count(column);\n}\n\nstatic JNICALL jint cursorNativeGetType(JNIEnv *env, jclass, jlong ptr, jint idx)\n{\n    sqliterk_column *column = (sqliterk_column *) (intptr_t) ptr;\n    return sqliterk_column_type(column, idx);\n}\n\nstatic JNICALL jlong cursorNativeGetLong(JNIEnv *env, jclass, jlong ptr, jint idx)\n{\n    sqliterk_column *column = (sqliterk_column *) (intptr_t) ptr;\n    return sqliterk_column_integer64(column, idx);\n}\n\nstatic JNICALL double cursorNativeGetDouble(JNIEnv *env, jclass, jlong ptr, jint idx)\n{\n    sqliterk_column *column = (sqliterk_column *) (intptr_t) ptr;\n    return sqliterk_column_number(column, idx);\n}\n\nstatic JNICALL jstring cursorNativeGetString(JNIEnv *env, jclass, jlong ptr, jint idx)\n{\n    sqliterk_column *column = (sqliterk_column *) (intptr_t) ptr;\n\n    // TODO: handle UTF-8 => UTF-16 convertion\n    const char *result = sqliterk_column_text(column, idx);\n    return env->NewStringUTF(result);\n}\n\nstatic JNICALL jbyteArray cursorNativeGetBlob(JNIEnv *env, jclass, jlong ptr, jint idx)\n{\n    sqliterk_column *column = (sqliterk_column *) (intptr_t) ptr;\n    const void *arr = sqliterk_column_binary(column, idx);\n    int size = sqliterk_column_bytes(column, idx);\n    jbyteArray result = env->NewByteArray(size);\n    env->SetByteArrayRegion(result, 0, size, (const jbyte *) arr);\n    return result;\n}\n\nstatic const JNINativeMethod sRepairMethods[] = {\n    {\"nativeInit\",\n     \"(Ljava/lang/String;[BLcom/tencent/wcdb/database/SQLiteCipherSpec;[B)J\",\n     (void *) nativeInit},\n    {\"nativeFini\", \"(J)V\", (void *) nativeFini},\n    {\"nativeOutput\", \"(JJJJI)I\", (void *) nativeOutput},\n    {\"nativeCancel\", \"(J)V\", (void *) nativeCancel},\n    {\"nativeIntegrityFlags\", \"(J)I\", (void *) nativeIntegrityFlags},\n    {\"nativeLastError\", \"()Ljava/lang/String;\", (void *) nativeLastError},\n    {\"nativeGetStatistics\", \"(J)[I\", (void *) nativeGetStatistics},\n    {\"nativeMakeMaster\", \"([Ljava/lang/String;)J\", (void *) nativeMakeMaster},\n    {\"nativeSaveMaster\", \"(JLjava/lang/String;[B)Z\", (void *) nativeSaveMaster},\n    {\"nativeLoadMaster\", \"(Ljava/lang/String;[B[Ljava/lang/String;[B)J\",\n     (void *) nativeLoadMaster},\n    {\"nativeFreeMaster\", \"(J)V\", (void *) nativeFreeMaster},\n    {\"nativeScanLeaf\", \"(J[Ljava/lang/String;[J)J\", (void *) nativeScanLeaf},\n    {\"nativeCancelScanLeaf\", \"(J)V\", (void *) nativeCancelScanLeaf},\n    {\"nativeSaveLeaf\", \"(JLjava/lang/String;)Z\", (void *) nativeSaveLeaf},\n    {\"nativeLoadLeaf\", \"(Ljava/lang/String;)J\", (void *) nativeLoadLeaf},\n    {\"nativeFreeLeaf\", \"(J)V\", (void *) nativeFreeLeaf},\n};\n\nstatic const JNINativeMethod sCursorMethods[] = {\n    {\"nativeGetColumnCount\", \"(J)I\", (void *) cursorNativeGetColumnCount},\n    {\"nativeGetType\", \"(JI)I\", (void *) cursorNativeGetType},\n    {\"nativeGetLong\", \"(JI)J\", (void *) cursorNativeGetLong},\n    {\"nativeGetDouble\", \"(JI)D\", (void *) cursorNativeGetDouble},\n    {\"nativeGetString\", \"(JI)Ljava/lang/String;\", (void *) cursorNativeGetString},\n    {\"nativeGetBlob\", \"(JI)[B\", (void *) cursorNativeGetBlob},\n};\n\nstatic void xlog(sqliterk_loglevel level, int result, const char *msg)\n{\n    android_LogPriority lv;\n    switch (level) {\n        case sqliterk_loglevel_error:\n            // XXX: thread-safety is not considered here, which may cause problems.\n            g_error_result = result;\n            strlcpy(g_error_msg, msg, sizeof(g_error_msg));\n\n            lv = ANDROID_LOG_ERROR;\n            break;\n        case sqliterk_loglevel_warning:\n            lv = ANDROID_LOG_WARN;\n            break;\n        case sqliterk_loglevel_info:\n            lv = ANDROID_LOG_INFO;\n            break;\n        case sqliterk_loglevel_debug:\n            lv = ANDROID_LOG_DEBUG;\n            break;\n        default:\n            lv = ANDROID_LOG_VERBOSE;\n    }\n\n    wcdb_log_write(lv, \"WCDB.RepairKit\", msg);\n}\n\nstatic int register_wcdb_repair(JavaVM *vm, JNIEnv *env)\n{\n    char msg[256];\n    sqliterk_os os = {xlog};\n    sqliterk_register(os);\n\n    jclass cls = env->FindClass(\"com/tencent/wcdb/repair/RepairKit\");\n    if (!cls) {\n        snprintf(msg, sizeof(msg),\n                 \"Unable to find class '%s', aborting\",\n                 \"com/tencent/wcdb/repair/RepairKit\");\n        env->FatalError(msg);\n    }\n    \n    sMID_onProgress = env->GetMethodID(cls, \"onProgress\", \"(Ljava/lang/String;IJ)I\");\n    if (!sMID_onProgress) {\n        snprintf(msg, sizeof(msg),\n                 \"Unable to find method '%s' with signature '%s', aborting\",\n                 \"onProgress\", \"(Ljava/lang/String;IJ)I\");\n        env->FatalError(msg);\n    }\n\n    if (env->RegisterNatives(cls, sRepairMethods, NELEM(sRepairMethods)) < 0) {\n        snprintf(msg, sizeof(msg), \"RegisterNatives failed for '%s', aborting\",\n                 \"com/tencent/wcdb/repair/RepairKit\");\n        env->FatalError(msg);\n    }\n    env->DeleteLocalRef(cls);\n\n    jniRegisterNativeMethods(env, \"com/tencent/wcdb/repair/RepairKit$RepairCursor\", \n                             sCursorMethods, NELEM(sCursorMethods));\n\n    return 0;\n}\nWCDB_JNI_INIT(DBRepair, register_wcdb_repair)\n}\n"
  },
  {
    "path": "deprecated/android/jni/com_tencent_wcdb_support_Log.cpp",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"JNIHelp.h\"\n#include \"Logger.h\"\n#include \"ModuleLoader.h\"\n\n#include <android/log.h>\n#include <assert.h>\n#include <jni.h>\n#include <stdlib.h>\n\nnamespace wcdb {\n\nstatic JavaVM *g_jvm = nullptr;\nstatic jobject g_callbackObj = nullptr;\nstatic jmethodID g_callbackPrintLnMethod = nullptr;\n\nconst static wcdb_logfunc_t LOGGERS[] = {\n    nullptr,             // LOGGER_NONE\n    __android_log_write, // LOGGER_DEFAULT\n};\n\nstatic int jniCallbackLogger(int priority, const char *tag, const char *msg)\n{\n    assert(g_callbackObj && g_callbackPrintLnMethod && g_jvm);\n\n    JNIEnv *env = nullptr;\n    bool attached = false;\n    jint ret = g_jvm->GetEnv((void **) &env, JNI_VERSION_1_6);\n    if (ret == JNI_EDETACHED) {\n        jint ret = g_jvm->AttachCurrentThread(&env, nullptr);\n        assert(ret == JNI_OK);\n        (void) ret;\n        attached = true;\n    }\n\n    jstring tagStr = env->NewStringUTF(tag);\n    jstring msgStr = env->NewStringUTF(msg);\n    env->CallVoidMethod(g_callbackObj, g_callbackPrintLnMethod, priority,\n                        tagStr, msgStr);\n    env->ExceptionClear();\n    env->DeleteLocalRef(tagStr);\n    env->DeleteLocalRef(msgStr);\n\n    if (attached)\n        g_jvm->DetachCurrentThread();\n    return 0;\n}\n\nstatic void\nnativeSetLogger(JNIEnv *env, jclass cls, jint logger, jobject callback)\n{\n    if (g_callbackObj)\n        env->DeleteGlobalRef(g_callbackObj);\n\n    if (callback) {\n        g_callbackObj = env->NewGlobalRef(callback);\n        wcdb_set_log_function(jniCallbackLogger);\n    } else {\n        if (logger < 0 || logger > NELEM(LOGGERS)) {\n            jniThrowException(env, \"java/lang/IllegalArgumentException\",\n                              \"Invalid preset logger.\");\n            return;\n        }\n\n        g_callbackObj = nullptr;\n        wcdb_set_log_function(LOGGERS[logger]);\n    }\n}\n\nstatic void nativePrintLn(\n    JNIEnv *env, jclass cls, jint priority, jstring tagStr, jstring msgStr)\n{\n    if (!tagStr || !msgStr)\n        return;\n\n    const char *tag = env->GetStringUTFChars(tagStr, nullptr);\n    const char *msg = env->GetStringUTFChars(msgStr, nullptr);\n    wcdb_log_write(priority, tag, msg);\n    env->ReleaseStringUTFChars(tagStr, tag);\n    env->ReleaseStringUTFChars(msgStr, msg);\n}\n\nstatic const JNINativeMethod sMethods[] = {\n    {\"nativeSetLogger\", \"(ILcom/tencent/wcdb/support/Log$LogCallback;)V\",\n     (void *) nativeSetLogger},\n    {\"nativePrintLn\", \"(ILjava/lang/String;Ljava/lang/String;)V\",\n     (void *) nativePrintLn},\n};\n\nstatic int register_wcdb_Log(JavaVM *vm, JNIEnv *env)\n{\n    g_jvm = vm;\n\n    jclass cls = env->FindClass(\"com/tencent/wcdb/support/Log$LogCallback\");\n    if (!cls)\n        return -1;\n\n    g_callbackPrintLnMethod = env->GetMethodID(\n        cls, \"println\", \"(ILjava/lang/String;Ljava/lang/String;)V\");\n    if (!g_callbackPrintLnMethod)\n        return -1;\n\n    return jniRegisterNativeMethods(env, \"com/tencent/wcdb/support/Log\",\n                                    sMethods, NELEM(sMethods));\n}\nWCDB_JNI_INIT(Log, register_wcdb_Log)\n\nstatic int unregister_wcdb_Log(JavaVM *vm, JNIEnv *env)\n{\n    if (g_callbackObj)\n        env->DeleteGlobalRef(g_callbackObj);\n    return 0;\n}\nWCDB_JNI_FINI(Log, unregister_wcdb_Log)\n}"
  },
  {
    "path": "deprecated/android/room/.gitignore",
    "content": "/build"
  },
  {
    "path": "deprecated/android/room/build.gradle",
    "content": "apply plugin: 'com.android.library'\napply from: rootProject.file('gradle/WeChatPublish.gradle')\n\nartifactId = 'room'\n\nandroid {\n    compileSdkVersion 32\n\n    defaultConfig {\n        minSdkVersion 14\n        targetSdkVersion 32\n        versionCode 1\n        versionName version\n\n        testInstrumentationRunner \"android.support.test.runner.AndroidJUnitRunner\"\n\n    }\n    buildTypes {\n        release {\n            minifyEnabled false\n            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'\n        }\n    }\n}\n\ndependencies {\n    api project(':wcdb')\n\n    api 'android.arch.persistence.room:runtime:1.1.1'\n    annotationProcessor 'android.arch.persistence.room:compiler:1.1.1'\n}\n\nwechatPublish {\n    publishAllVariants true\n    withJavadoc false\n\n    publishToBintray {\n        repo = 'wcdb'\n        name = 'room'\n        desc = ''\n        websiteUrl = 'https://github.com/Tencent/wcdb'\n        issueTrackerUrl = 'https://github.com/Tencent/wcdb/issues'\n        vcsUrl = 'https://github.com/Tencent/wcdb.git'\n        licenses = ['BSD 3-Clause']\n    }\n}\n"
  },
  {
    "path": "deprecated/android/room/proguard-rules.pro",
    "content": "# Add project specific ProGuard rules here.\n# By default, the flags in this file are appended to flags specified\n# in C:\\android\\sdk/tools/proguard/proguard-android.txt\n# You can edit the include path and order by changing the proguardFiles\n# directive in build.gradle.\n#\n# For more details, see\n#   http://developer.android.com/guide/developing/tools/proguard.html\n\n# Add any project specific keep options here:\n\n# If your project uses WebView with JS, uncomment the following\n# and specify the fully qualified class name to the JavaScript interface\n# class:\n#-keepclassmembers class fqcn.of.javascript.interface.for.webview {\n#   public *;\n#}\n\n# Uncomment this to preserve the line number information for\n# debugging stack traces.\n#-keepattributes SourceFile,LineNumberTable\n\n# If you keep the line number information, uncomment this to\n# hide the original source file name.\n#-renamesourcefileattribute SourceFile\n"
  },
  {
    "path": "deprecated/android/room/src/main/AndroidManifest.xml",
    "content": "<manifest package=\"com.tencent.wcdb.room\"/>\n"
  },
  {
    "path": "deprecated/android/room/src/main/java/com/tencent/wcdb/room/db/WCDBDatabase.java",
    "content": "/*\n * Copyright (C) 2016 The Android Open Source Project\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdb.room.db;\n\nimport android.arch.persistence.db.SimpleSQLiteQuery;\nimport android.arch.persistence.db.SupportSQLiteDatabase;\nimport android.arch.persistence.db.SupportSQLiteQuery;\nimport android.arch.persistence.db.SupportSQLiteStatement;\nimport android.content.ContentValues;\nimport android.database.Cursor;\nimport android.database.SQLException;\nimport android.database.sqlite.SQLiteTransactionListener;\nimport android.os.Build;\nimport android.os.CancellationSignal;\nimport android.support.annotation.RequiresApi;\nimport android.util.Pair;\n\nimport com.tencent.wcdb.database.SQLiteCursor;\nimport com.tencent.wcdb.database.SQLiteCursorDriver;\nimport com.tencent.wcdb.database.SQLiteDatabase;\nimport com.tencent.wcdb.database.SQLiteProgram;\n\nimport java.io.IOException;\nimport java.util.List;\nimport java.util.Locale;\n\n/**\n * Delegates all calls to an implementation of {@link SQLiteDatabase}.\n *\n * @hide\n */\npublic class WCDBDatabase implements SupportSQLiteDatabase {\n    private static final String[] CONFLICT_VALUES = new String[]\n            {\"\", \" OR ROLLBACK \", \" OR ABORT \", \" OR FAIL \", \" OR IGNORE \", \" OR REPLACE \"};\n    private static final String[] EMPTY_STRING_ARRAY = new String[0];\n\n    private final SQLiteDatabase mDelegate;\n\n    /**\n     * Creates a wrapper around {@link SQLiteDatabase}.\n     *\n     * @param delegate The delegate to receive all calls.\n     */\n    public WCDBDatabase(SQLiteDatabase delegate) {\n        mDelegate = delegate;\n    }\n\n    /**\n     * Retrieve the wrapped {@link SQLiteDatabase} object.\n     *\n     * @return the real, wrapped database object\n     */\n    public final SQLiteDatabase getInnerDatabase() {\n        return mDelegate;\n    }\n\n    @Override\n    public SupportSQLiteStatement compileStatement(String sql) {\n        return new WCDBStatement(mDelegate.compileStatement(sql));\n    }\n\n    @Override\n    public void beginTransaction() {\n        mDelegate.beginTransaction();\n    }\n\n    @Override\n    public void beginTransactionNonExclusive() {\n        mDelegate.beginTransactionNonExclusive();\n    }\n\n    @Override\n    public void beginTransactionWithListener(SQLiteTransactionListener transactionListener) {\n        mDelegate.beginTransactionWithListener(transactionListener);\n    }\n\n    @Override\n    public void beginTransactionWithListenerNonExclusive(\n            SQLiteTransactionListener transactionListener) {\n        mDelegate.beginTransactionWithListenerNonExclusive(transactionListener);\n    }\n\n    @Override\n    public void endTransaction() {\n        mDelegate.endTransaction();\n    }\n\n    @Override\n    public void setTransactionSuccessful() {\n        mDelegate.setTransactionSuccessful();\n    }\n\n    @Override\n    public boolean inTransaction() {\n        return mDelegate.inTransaction();\n    }\n\n    @Override\n    public boolean isDbLockedByCurrentThread() {\n        return mDelegate.isDbLockedByCurrentThread();\n    }\n\n    @Override\n    public boolean yieldIfContendedSafely() {\n        return mDelegate.yieldIfContendedSafely();\n    }\n\n    @Override\n    public boolean yieldIfContendedSafely(long sleepAfterYieldDelay) {\n        return mDelegate.yieldIfContendedSafely(sleepAfterYieldDelay);\n    }\n\n    @Override\n    public int getVersion() {\n        return mDelegate.getVersion();\n    }\n\n    @Override\n    public void setVersion(int version) {\n        mDelegate.setVersion(version);\n    }\n\n    @Override\n    public long getMaximumSize() {\n        return mDelegate.getMaximumSize();\n    }\n\n    @Override\n    public long setMaximumSize(long numBytes) {\n        return mDelegate.setMaximumSize(numBytes);\n    }\n\n    @Override\n    public long getPageSize() {\n        return mDelegate.getPageSize();\n    }\n\n    @Override\n    public void setPageSize(long numBytes) {\n        mDelegate.setPageSize(numBytes);\n    }\n\n    @Override\n    public Cursor query(String query) {\n        return mDelegate.rawQuery(query, null);\n    }\n\n    @Override\n    public Cursor query(String query, Object[] bindArgs) {\n        return mDelegate.rawQuery(query, bindArgs);\n    }\n\n\n    @Override\n    public Cursor query(final SupportSQLiteQuery supportQuery) {\n        return mDelegate.rawQueryWithFactory(new SQLiteDatabase.CursorFactory() {\n            @Override\n            public com.tencent.wcdb.Cursor newCursor(SQLiteDatabase db, SQLiteCursorDriver masterQuery,\n                    String editTable, SQLiteProgram query) {\n                supportQuery.bindTo(new WCDBProgram(query));\n                return SQLiteCursor.FACTORY.newCursor(db, masterQuery, editTable, query);\n            }\n\n            @Override\n            public SQLiteProgram newQuery(SQLiteDatabase db, String query, Object[] bindArgs,\n                    com.tencent.wcdb.support.CancellationSignal cancellationSignalForPrepare) {\n                return SQLiteCursor.FACTORY.newQuery(db, query, bindArgs, cancellationSignalForPrepare);\n            }\n        }, supportQuery.getSql(), null, null);\n    }\n\n    @Override\n    @RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN)\n    public Cursor query(final SupportSQLiteQuery supportQuery,\n            CancellationSignal cancellationSignal) {\n\n        final com.tencent.wcdb.support.CancellationSignal realSignal;\n        if (cancellationSignal != null) {\n            // Be compatible to CancellationSignal from official SDK.\n            realSignal = new com.tencent.wcdb.support.CancellationSignal();\n\n            if (cancellationSignal.isCanceled()) {\n                realSignal.cancel();\n            }\n            cancellationSignal.setOnCancelListener(new CancellationSignal.OnCancelListener() {\n                @Override\n                public void onCancel() {\n                    realSignal.cancel();\n                }\n            });\n        } else {\n            realSignal = null;\n        }\n\n        return mDelegate.rawQueryWithFactory(new SQLiteDatabase.CursorFactory() {\n            @Override\n            public com.tencent.wcdb.Cursor newCursor(SQLiteDatabase db, SQLiteCursorDriver masterQuery,\n                    String editTable, SQLiteProgram query) {\n                supportQuery.bindTo(new WCDBProgram(query));\n                return SQLiteCursor.FACTORY.newCursor(db, masterQuery, editTable, query);\n            }\n\n            @Override\n            public SQLiteProgram newQuery(SQLiteDatabase db, String query, Object[] bindArgs,\n                    com.tencent.wcdb.support.CancellationSignal cancellationSignalForPrepare) {\n                return SQLiteCursor.FACTORY.newQuery(db, query, bindArgs, cancellationSignalForPrepare);\n            }\n        }, supportQuery.getSql(), null, null, realSignal);\n    }\n\n    @Override\n    public long insert(String table, int conflictAlgorithm, ContentValues values)\n            throws SQLException {\n        return mDelegate.insertWithOnConflict(table, null, values,\n                conflictAlgorithm);\n    }\n\n    @Override\n    public int delete(String table, String whereClause, Object[] whereArgs) {\n        String query = \"DELETE FROM \" + table\n                + (isEmpty(whereClause) ? \"\" : \" WHERE \" + whereClause);\n        SupportSQLiteStatement statement = compileStatement(query);\n        SimpleSQLiteQuery.bind(statement, whereArgs);\n        return statement.executeUpdateDelete();\n    }\n\n\n    @Override\n    public int update(String table, int conflictAlgorithm, ContentValues values, String whereClause,\n            Object[] whereArgs) {\n        // taken from SQLiteDatabase class.\n        if (values == null || values.size() == 0) {\n            throw new IllegalArgumentException(\"Empty values\");\n        }\n        StringBuilder sql = new StringBuilder(120);\n        sql.append(\"UPDATE \");\n        sql.append(CONFLICT_VALUES[conflictAlgorithm]);\n        sql.append(table);\n        sql.append(\" SET \");\n\n        // move all bind args to one array\n        int setValuesSize = values.size();\n        int bindArgsSize = (whereArgs == null) ? setValuesSize : (setValuesSize + whereArgs.length);\n        Object[] bindArgs = new Object[bindArgsSize];\n        int i = 0;\n        for (String colName : values.keySet()) {\n            sql.append((i > 0) ? \",\" : \"\");\n            sql.append(colName);\n            bindArgs[i++] = values.get(colName);\n            sql.append(\"=?\");\n        }\n        if (whereArgs != null) {\n            for (i = setValuesSize; i < bindArgsSize; i++) {\n                bindArgs[i] = whereArgs[i - setValuesSize];\n            }\n        }\n        if (!isEmpty(whereClause)) {\n            sql.append(\" WHERE \");\n            sql.append(whereClause);\n        }\n        SupportSQLiteStatement stmt = compileStatement(sql.toString());\n        SimpleSQLiteQuery.bind(stmt, bindArgs);\n        return stmt.executeUpdateDelete();\n    }\n\n    @Override\n    public void execSQL(String sql) throws SQLException {\n        mDelegate.execSQL(sql);\n    }\n\n    @Override\n    public void execSQL(String sql, Object[] bindArgs) throws SQLException {\n        mDelegate.execSQL(sql, bindArgs);\n    }\n\n    @Override\n    public boolean isReadOnly() {\n        return mDelegate.isReadOnly();\n    }\n\n    @Override\n    public boolean isOpen() {\n        return mDelegate.isOpen();\n    }\n\n    @Override\n    public boolean needUpgrade(int newVersion) {\n        return mDelegate.needUpgrade(newVersion);\n    }\n\n    @Override\n    public String getPath() {\n        return mDelegate.getPath();\n    }\n\n    @Override\n    public void setLocale(Locale locale) {\n        mDelegate.setLocale(locale);\n    }\n\n    @Override\n    public void setMaxSqlCacheSize(int cacheSize) {\n        mDelegate.setMaxSqlCacheSize(cacheSize);\n    }\n\n    @Override\n    @RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN)\n    public void setForeignKeyConstraintsEnabled(boolean enable) {\n        mDelegate.setForeignKeyConstraintsEnabled(enable);\n    }\n\n    @Override\n    public boolean enableWriteAheadLogging() {\n        return mDelegate.enableWriteAheadLogging();\n    }\n\n    @Override\n    @RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN)\n    public void disableWriteAheadLogging() {\n        mDelegate.disableWriteAheadLogging();\n    }\n\n    @Override\n    @RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN)\n    public boolean isWriteAheadLoggingEnabled() {\n        return mDelegate.isWriteAheadLoggingEnabled();\n    }\n\n    @Override\n    public List<Pair<String, String>> getAttachedDbs() {\n        return mDelegate.getAttachedDbs();\n    }\n\n    @Override\n    public boolean isDatabaseIntegrityOk() {\n        return mDelegate.isDatabaseIntegrityOk();\n    }\n\n    @Override\n    public void close() throws IOException {\n        mDelegate.close();\n    }\n\n    private static boolean isEmpty(String input) {\n        return input == null || input.length() == 0;\n    }\n}\n"
  },
  {
    "path": "deprecated/android/room/src/main/java/com/tencent/wcdb/room/db/WCDBOpenHelper.java",
    "content": "/*\n * Copyright (C) 2016 The Android Open Source Project\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdb.room.db;\n\nimport android.arch.persistence.db.SupportSQLiteDatabase;\nimport android.arch.persistence.db.SupportSQLiteOpenHelper;\nimport android.content.Context;\n\nimport com.tencent.wcdb.DatabaseErrorHandler;\nimport com.tencent.wcdb.database.SQLiteCipherSpec;\nimport com.tencent.wcdb.database.SQLiteDatabase;\nimport com.tencent.wcdb.database.SQLiteOpenHelper;\n\nclass WCDBOpenHelper implements SupportSQLiteOpenHelper {\n    private final OpenHelper mDelegate;\n\n    WCDBOpenHelper(Context context, String name, byte[] passphrase, SQLiteCipherSpec cipherSpec,\n                   Callback callback) {\n        mDelegate = createDelegate(context, name, passphrase, cipherSpec, callback);\n    }\n\n    private OpenHelper createDelegate(Context context, String name, byte[] passphrase,\n                                      SQLiteCipherSpec cipherSpec, Callback callback) {\n        final WCDBDatabase[] dbRef = new WCDBDatabase[1];\n        return new OpenHelper(context, name, dbRef, passphrase, cipherSpec, callback);\n    }\n\n    @Override\n    public String getDatabaseName() {\n        return mDelegate.getDatabaseName();\n    }\n\n    @Override\n    public void setWriteAheadLoggingEnabled(boolean enabled) {\n        mDelegate.setWriteAheadLoggingEnabled(enabled);\n    }\n\n    void setAsyncCheckpointEnabled(boolean enabled) {\n        mDelegate.mAsyncCheckpoint = enabled;\n    }\n\n    @Override\n    public SupportSQLiteDatabase getWritableDatabase() {\n        return mDelegate.getWritableSupportDatabase();\n    }\n\n    @Override\n    public SupportSQLiteDatabase getReadableDatabase() {\n        return mDelegate.getReadableSupportDatabase();\n    }\n\n    @Override\n    public void close() {\n        mDelegate.close();\n    }\n\n    static class OpenHelper extends SQLiteOpenHelper {\n        /**\n         * This is used as an Object reference so that we can access the wrapped database inside\n         * the constructor. SQLiteOpenHelper requires the error handler to be passed in the\n         * constructor.\n         */\n        final WCDBDatabase[] mDbRef;\n        final Callback mCallback;\n\n        boolean mAsyncCheckpoint;\n\n        OpenHelper(Context context, String name, final WCDBDatabase[] dbRef,\n                   byte[] passphrase, SQLiteCipherSpec cipherSpec,\n                   final Callback callback) {\n            super(context, name, passphrase, cipherSpec, null, callback.version,\n                    new DatabaseErrorHandler() {\n                        @Override\n                        public void onCorruption(SQLiteDatabase dbObj) {\n                            WCDBDatabase db = dbRef[0];\n                            if (db != null) {\n                                callback.onCorruption(db);\n                            }\n                        }\n                    });\n            mCallback = callback;\n            mDbRef = dbRef;\n            mAsyncCheckpoint = false;\n        }\n\n        SupportSQLiteDatabase getWritableSupportDatabase() {\n            SQLiteDatabase db = super.getWritableDatabase();\n            return getWrappedDb(db);\n        }\n\n        SupportSQLiteDatabase getReadableSupportDatabase() {\n            SQLiteDatabase db = super.getReadableDatabase();\n            return getWrappedDb(db);\n        }\n\n        WCDBDatabase getWrappedDb(SQLiteDatabase sqLiteDatabase) {\n            WCDBDatabase dbRef = mDbRef[0];\n            if (dbRef == null) {\n                dbRef = new WCDBDatabase(sqLiteDatabase);\n                mDbRef[0] = dbRef;\n            }\n            return mDbRef[0];\n        }\n\n        @Override\n        public void onCreate(SQLiteDatabase sqLiteDatabase) {\n            mCallback.onCreate(getWrappedDb(sqLiteDatabase));\n        }\n\n        @Override\n        public void onUpgrade(SQLiteDatabase sqLiteDatabase, int oldVersion, int newVersion) {\n            mCallback.onUpgrade(getWrappedDb(sqLiteDatabase), oldVersion, newVersion);\n        }\n\n        @Override\n        public void onConfigure(SQLiteDatabase db) {\n            db.setAsyncCheckpointEnabled(mAsyncCheckpoint);\n            mCallback.onConfigure(getWrappedDb(db));\n        }\n\n        @Override\n        public void onDowngrade(SQLiteDatabase db, int oldVersion, int newVersion) {\n            mCallback.onDowngrade(getWrappedDb(db), oldVersion, newVersion);\n        }\n\n        @Override\n        public void onOpen(SQLiteDatabase db) {\n            mCallback.onOpen(getWrappedDb(db));\n        }\n\n        @Override\n        public synchronized void close() {\n            super.close();\n            mDbRef[0] = null;\n        }\n    }\n\n}\n"
  },
  {
    "path": "deprecated/android/room/src/main/java/com/tencent/wcdb/room/db/WCDBOpenHelperFactory.java",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdb.room.db;\n\nimport android.arch.persistence.db.SupportSQLiteOpenHelper;\n\nimport com.tencent.wcdb.database.SQLiteCipherSpec;\n\npublic class WCDBOpenHelperFactory implements SupportSQLiteOpenHelper.Factory {\n\n    private byte[] mPassphrase;\n    private SQLiteCipherSpec mCipherSpec;\n    private boolean mWALMode;\n    private boolean mAsyncCheckpoint;\n\n    public WCDBOpenHelperFactory passphrase(byte[] value) {\n        mPassphrase = value;\n        return this;\n    }\n\n    public WCDBOpenHelperFactory cipherSpec(SQLiteCipherSpec cipher) {\n        mCipherSpec = cipher;\n        return this;\n    }\n\n    public WCDBOpenHelperFactory writeAheadLoggingEnabled(boolean wal) {\n        mWALMode = wal;\n        return this;\n    }\n\n    public WCDBOpenHelperFactory asyncCheckpointEnabled(boolean acp) {\n        mAsyncCheckpoint = acp;\n        return this;\n    }\n\n    @Override\n    public SupportSQLiteOpenHelper create(SupportSQLiteOpenHelper.Configuration configuration) {\n        WCDBOpenHelper result = new WCDBOpenHelper(configuration.context, configuration.name,\n                mPassphrase, mCipherSpec, configuration.callback);\n        result.setWriteAheadLoggingEnabled(mWALMode);\n        result.setAsyncCheckpointEnabled(mAsyncCheckpoint);\n        return result;\n    }\n}\n"
  },
  {
    "path": "deprecated/android/room/src/main/java/com/tencent/wcdb/room/db/WCDBProgram.java",
    "content": "/*\n * Copyright (C) 2017 The Android Open Source Project\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdb.room.db;\n\nimport android.arch.persistence.db.SupportSQLiteProgram;\n\nimport com.tencent.wcdb.database.SQLiteProgram;\n\nimport java.io.IOException;\n\n/**\n * An wrapper around {@link SQLiteProgram} to implement {@link SupportSQLiteProgram} API.\n */\nclass WCDBProgram implements SupportSQLiteProgram {\n    private final SQLiteProgram mDelegate;\n\n    WCDBProgram(SQLiteProgram delegate) {\n        mDelegate = delegate;\n    }\n\n    @Override\n    public void bindNull(int index) {\n        mDelegate.bindNull(index);\n    }\n\n    @Override\n    public void bindLong(int index, long value) {\n        mDelegate.bindLong(index, value);\n    }\n\n    @Override\n    public void bindDouble(int index, double value) {\n        mDelegate.bindDouble(index, value);\n    }\n\n    @Override\n    public void bindString(int index, String value) {\n        mDelegate.bindString(index, value);\n    }\n\n    @Override\n    public void bindBlob(int index, byte[] value) {\n        mDelegate.bindBlob(index, value);\n    }\n\n    @Override\n    public void clearBindings() {\n        mDelegate.clearBindings();\n    }\n\n    @Override\n    public void close() throws IOException {\n        mDelegate.close();\n    }\n}\n"
  },
  {
    "path": "deprecated/android/room/src/main/java/com/tencent/wcdb/room/db/WCDBStatement.java",
    "content": "/*\n * Copyright (C) 2016 The Android Open Source Project\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdb.room.db;\n\nimport android.arch.persistence.db.SupportSQLiteStatement;\n\nimport com.tencent.wcdb.database.SQLiteStatement;\n\nimport java.io.IOException;\n\n/**\n * Delegates all calls to a {@link SQLiteStatement}.\n */\nclass WCDBStatement implements SupportSQLiteStatement {\n    private final SQLiteStatement mDelegate;\n\n    /**\n     * Creates a wrapper around a framework {@link SQLiteStatement}.\n     *\n     * @param delegate The SQLiteStatement to delegate calls to.\n     */\n    public WCDBStatement(SQLiteStatement delegate) {\n        mDelegate = delegate;\n    }\n\n    @Override\n    public void bindNull(int index) {\n        mDelegate.bindNull(index);\n    }\n\n    @Override\n    public void bindLong(int index, long value) {\n        mDelegate.bindLong(index, value);\n    }\n\n    @Override\n    public void bindDouble(int index, double value) {\n        mDelegate.bindDouble(index, value);\n    }\n\n    @Override\n    public void bindString(int index, String value) {\n        mDelegate.bindString(index, value);\n    }\n\n    @Override\n    public void bindBlob(int index, byte[] value) {\n        mDelegate.bindBlob(index, value);\n    }\n\n    @Override\n    public void clearBindings() {\n        mDelegate.clearBindings();\n    }\n\n    @Override\n    public void execute() {\n        mDelegate.execute();\n    }\n\n    @Override\n    public int executeUpdateDelete() {\n        return mDelegate.executeUpdateDelete();\n    }\n\n    @Override\n    public long executeInsert() {\n        return mDelegate.executeInsert();\n    }\n\n    @Override\n    public long simpleQueryForLong() {\n        return mDelegate.simpleQueryForLong();\n    }\n\n    @Override\n    public String simpleQueryForString() {\n        return mDelegate.simpleQueryForString();\n    }\n\n    @Override\n    public void close() throws IOException {\n        mDelegate.close();\n    }\n}\n"
  },
  {
    "path": "deprecated/android/samples/benchmark/.gitignore",
    "content": "/build\n"
  },
  {
    "path": "deprecated/android/samples/benchmark/build.gradle",
    "content": "apply plugin: 'com.android.application'\n\nandroid {\n    compileSdkVersion 32\n\n    defaultConfig {\n        applicationId \"com.tencent.wcdb.benchmark\"\n        minSdkVersion 14\n        targetSdkVersion 32\n\n        testInstrumentationRunner \"android.support.test.runner.AndroidJUnitRunner\"\n\n    }\n    buildTypes {\n        release {\n            minifyEnabled false\n            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'\n        }\n    }\n    //testBuildType 'release'\n}\n\ndependencies {\n    androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {\n        exclude group: 'com.android.support', module: 'support-annotations'\n    })\n\n    implementation project(':wcdb')\n    //implementation 'com.tencent.wcdb:wcdb-android:1.0.4'\n    implementation 'net.zetetic:android-database-sqlcipher:3.5.7@aar'\n    implementation 'com.android.support:appcompat-v7:28.0.0'\n    testImplementation 'junit:junit:4.12'\n}\n"
  },
  {
    "path": "deprecated/android/samples/benchmark/proguard-rules.pro",
    "content": "# Add project specific ProGuard rules here.\n# By default, the flags in this file are appended to flags specified\n# in C:\\android\\sdk/tools/proguard/proguard-android.txt\n# You can edit the include path and order by changing the proguardFiles\n# directive in build.gradle.\n#\n# For more details, see\n#   http://developer.android.com/guide/developing/tools/proguard.html\n\n# Add any project specific keep options here:\n\n# If your project uses WebView with JS, uncomment the following\n# and specify the fully qualified class name to the JavaScript interface\n# class:\n#-keepclassmembers class fqcn.of.javascript.interface.for.webview {\n#   public *;\n#}\n\n# Uncomment this to preserve the line number information for\n# debugging stack traces.\n#-keepattributes SourceFile,LineNumberTable\n\n# If you keep the line number information, uncomment this to\n# hide the original source file name.\n#-renamesourcefileattribute SourceFile\n"
  },
  {
    "path": "deprecated/android/samples/benchmark/src/androidTest/java/com/tencent/wcdb/benchmark/concurrent/ConcurrentTest.java",
    "content": "package com.tencent.wcdb.benchmark.concurrent;\n\nimport android.content.Context;\nimport android.database.Cursor;\nimport android.support.test.InstrumentationRegistry;\nimport android.util.Log;\n\nimport junit.framework.Assert;\n\nimport java.io.File;\nimport java.util.ArrayList;\nimport java.util.concurrent.ExecutorService;\nimport java.util.concurrent.Executors;\nimport java.util.concurrent.Future;\n\n/**\n * Created by johnh on 2017/6/29.\n */\n\npublic abstract class ConcurrentTest {\n\n    private static final String TAG = \"WCDB.Benchmark\";\n    private static final String DATABASE_NAME = \"test.db\";\n\n    protected abstract void createDB(String path);\n    protected abstract void closeDB();\n    protected abstract void execSQL(String sql);\n    protected abstract void execSQL(String sql, Object[] bindArgs);\n    protected abstract void beginTransaction();\n    protected abstract void setTransactionSuccessful();\n    protected abstract void endTransaction();\n    protected abstract long longForQuery(String sql, String[] selectionArgs);\n    protected abstract String stringForQuery(String sql, String[] selectionArgs);\n    protected abstract Cursor rawQuery(String sql, String[] selectionArgs);\n\n    private ExecutorService mExecutor = Executors.newFixedThreadPool(4);\n    private ArrayList<Future> mFutureList = new ArrayList<>(4);\n\n    public void doBefore() {\n        Log.i(\"WCDB.Benchmark\", \"[DB BENCHMARK] | Begin | \" + getClass().getSimpleName());\n        Context context = InstrumentationRegistry.getTargetContext();\n\n        // Remove pre-existing database.\n        File dbFile = context.getDatabasePath(DATABASE_NAME);\n        dbFile.getParentFile().mkdirs();\n        dbFile.delete();\n        new File(dbFile.getParentFile(), dbFile.getName() + \"-journal\").delete();\n        new File(dbFile.getParentFile(), dbFile.getName() + \"-wal\").delete();\n\n        // Create database and table, measuring time.\n        createDB(dbFile.getPath());\n        execSQL(\"CREATE TABLE message (id INTEGER PRIMARY KEY, user TEXT, content TEXT);\");\n        execSQL(\"CREATE INDEX message_user ON message (user);\");\n    }\n\n    private class WriteOneByOneTask implements Runnable {\n        private int mFrom;\n        private int mTo;\n        private boolean mInTransaction;\n        private Object[] mArgs = new Object[3];\n\n        WriteOneByOneTask(int from, int to, boolean transaction) {\n            mFrom = from;\n            mTo = to;\n            mInTransaction = transaction;\n        }\n\n        @Override\n        public void run() {\n            long time = System.nanoTime();\n\n            if (mInTransaction) {\n                beginTransaction();\n            }\n            for (int i = mFrom; i < mTo; i++) {\n                mArgs[0] = i;\n                mArgs[1] = \"u\" + i;\n                mArgs[2] = \"Test message: \" + i;\n                execSQL(\"REPLACE INTO message VALUES (?, ?, ?);\", mArgs);\n            }\n            if (mInTransaction) {\n                setTransactionSuccessful();\n                endTransaction();\n            }\n\n            time = System.nanoTime() - time;\n            Log.i(TAG, String.format(\"[DB BENCHMARK] | > WriteOneByOneTask(%d, %d, %b) [%d]\",\n                    mFrom, mTo, mInTransaction, time));\n        }\n    }\n\n    private class WriteBatchTask implements Runnable {\n        private int mFrom;\n        private int mTo;\n\n        WriteBatchTask(int from, int to) {\n            mFrom = from;\n            mTo = to;\n        }\n\n        @Override\n        public void run() {\n            long time = System.nanoTime();\n            execSQL(\"UPDATE message SET content = 'Test message: ' || id WHERE id >= ? AND id < ?\",\n                    new Object[] {mFrom, mTo});\n            time = System.nanoTime() - time;\n            Log.i(TAG, String.format(\"[DB BENCHMARK] | > WriteBatchTask(%d, %d) [%d]\",\n                    mFrom, mTo, time));\n        }\n    }\n\n    private class ReadOneByOneTask implements Runnable {\n        private int mFrom;\n        private int mTo;\n        private String[] mArgs = new String[1];\n\n        ReadOneByOneTask(int from, int to) {\n            mFrom = from;\n            mTo = to;\n        }\n\n        @Override\n        public void run() {\n            long time = System.nanoTime();\n            for (int i = mFrom; i < mTo; i++) {\n                mArgs[0] = Integer.toString(i);\n                Cursor cursor = rawQuery(\"SELECT * FROM message WHERE id = ?;\", mArgs);\n                Assert.assertTrue(cursor.moveToFirst());\n                Assert.assertEquals(cursor.getInt(0), i);\n                Assert.assertEquals(cursor.getString(1), \"u\" + i);\n                Assert.assertEquals(cursor.getString(2), \"Test message: \" + i);\n                cursor.close();\n            }\n            time = System.nanoTime() - time;\n            Log.i(TAG, String.format(\"[DB BENCHMARK] | > ReadOneByOneTask(%d, %d) [%d]\",\n                    mFrom, mTo, time));\n        }\n    }\n\n    private class ReadBatchTask implements Runnable {\n        private int mFrom;\n        private int mTo;\n\n        ReadBatchTask(int from, int to) {\n            mFrom = from;\n            mTo = to;\n        }\n\n        @Override\n        public void run() {\n            long time = System.nanoTime();\n            Cursor cursor = rawQuery(\"SELECT * FROM message WHERE id >= ? AND id < ?;\",\n                    new String[] {Integer.toString(mFrom), Integer.toString(mTo)});\n            for (int i = mFrom; i < mTo; i++) {\n                Assert.assertTrue(cursor.moveToNext());\n                Assert.assertEquals(cursor.getInt(0), i);\n                Assert.assertEquals(cursor.getString(1), \"u\" + i);\n                Assert.assertEquals(cursor.getString(2), \"Test message: \" + i);\n            }\n            Assert.assertFalse(cursor.moveToNext());\n            cursor.close();\n            time = System.nanoTime() - time;\n            Log.i(TAG, String.format(\"[DB BENCHMARK] | > ReadBatchTask(%d, %d) [%d]\",\n                    mFrom, mTo, time));\n        }\n    }\n\n    private void submitTask(Runnable r) {\n        mFutureList.add(mExecutor.submit(r));\n        try { Thread.sleep(10); } catch (InterruptedException e) {}\n    }\n\n    private void waitUntilFinished() {\n        try {\n            for (Future<?> future : mFutureList) {\n                future.get();\n            }\n        } catch (Exception e) {\n            throw new RuntimeException(e);\n        }\n        mFutureList.clear();\n    }\n\n    public void doTest() {\n        // 4 write tasks (transaction).\n        long time = System.nanoTime();\n        submitTask(new WriteOneByOneTask(0, 5000, true));\n        submitTask(new WriteOneByOneTask(5000, 10000, true));\n        submitTask(new WriteOneByOneTask(10000, 15000, true));\n        submitTask(new WriteOneByOneTask(15000, 20000, true));\n        waitUntilFinished();\n        time = System.nanoTime() - time;\n        Log.i(TAG, \"[DB BENCHMARK] | WWWW (transaction) | \" + time);\n\n        // 4 write tasks (separated).\n        time = System.nanoTime();\n        submitTask(new WriteOneByOneTask(0, 500, false));\n        submitTask(new WriteOneByOneTask(5000, 5500, false));\n        submitTask(new WriteOneByOneTask(10000, 10500, false));\n        submitTask(new WriteOneByOneTask(15000, 15500, false));\n        waitUntilFinished();\n        time = System.nanoTime() - time;\n        Log.i(TAG, \"[DB BENCHMARK] | WWWW (separated) | \" + time);\n\n        // 2 write tasks, 2 read tasks (batch).\n        time = System.nanoTime();\n        submitTask(new WriteBatchTask(5000, 10000));\n        submitTask(new WriteBatchTask(15000, 20000));\n        submitTask(new ReadBatchTask(0, 5000));\n        submitTask(new ReadBatchTask(10000, 15000));\n        waitUntilFinished();\n        time = System.nanoTime() - time;\n        Log.i(TAG, \"[DB BENCHMARK] | WWRR (batch) | \" + time);\n\n        // 1 write task, 3 read tasks.\n        time = System.nanoTime();\n        submitTask(new WriteBatchTask(0, 5000));\n        submitTask(new ReadOneByOneTask(5000, 10000));\n        submitTask(new ReadBatchTask(10000, 15000));\n        submitTask(new ReadOneByOneTask(15000, 20000));\n        waitUntilFinished();\n        time = System.nanoTime() - time;\n        Log.i(TAG, \"[DB BENCHMARK] | WRRR | \" + time);\n\n        // 4 read tasks.\n        time = System.nanoTime();\n        submitTask(new ReadOneByOneTask(0, 5000));\n        submitTask(new ReadBatchTask(5000, 10000));\n        submitTask(new ReadOneByOneTask(10000, 15000));\n        submitTask(new ReadBatchTask(15000, 20000));\n        waitUntilFinished();\n        time = System.nanoTime() - time;\n        Log.i(TAG, \"[DB BENCHMARK] | RRRR | \" + time);\n    }\n\n    public void doAfter() {\n        closeDB();\n        Log.i(TAG, \"[DB BENCHMARK] | End | \" + getClass().getSimpleName());\n    }\n}\n"
  },
  {
    "path": "deprecated/android/samples/benchmark/src/androidTest/java/com/tencent/wcdb/benchmark/concurrent/FrameworkConcurrentTest.java",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdb.benchmark.concurrent;\n\nimport android.database.Cursor;\nimport android.database.DatabaseUtils;\nimport android.database.sqlite.SQLiteDatabase;\n\nimport com.tencent.wcdb.benchmark.single.SingleThreadedTest;\n\nimport org.junit.After;\nimport org.junit.Before;\nimport org.junit.Test;\n\npublic class FrameworkConcurrentTest extends ConcurrentTest {\n\n    @Override\n    @Before\n    public void doBefore() {\n        super.doBefore();\n    }\n\n    @Override\n    @After\n    public void doAfter() {\n        super.doAfter();\n    }\n\n    @Override\n    @Test\n    public void doTest() {\n        super.doTest();\n    }\n\n\n    protected SQLiteDatabase mDB;\n\n    @Override\n    protected void createDB(String path) {\n        mDB = SQLiteDatabase.openOrCreateDatabase(path, null);\n    }\n\n    @Override\n    protected void closeDB() {\n        mDB.close();\n        mDB = null;\n    }\n\n    @Override\n    protected void execSQL(String sql) {\n        mDB.execSQL(sql);\n    }\n\n    @Override\n    protected void execSQL(String sql, Object[] bindArgs) {\n        mDB.execSQL(sql, bindArgs);\n    }\n\n    @Override\n    protected void beginTransaction() {\n        mDB.beginTransaction();\n    }\n\n    @Override\n    protected void setTransactionSuccessful() {\n        mDB.setTransactionSuccessful();\n    }\n\n    @Override\n    protected void endTransaction() {\n        mDB.endTransaction();\n    }\n\n    @Override\n    protected long longForQuery(String sql, String[] selectionArgs) {\n        return DatabaseUtils.longForQuery(mDB, sql, selectionArgs);\n    }\n\n    @Override\n    protected String stringForQuery(String sql, String[] selectionArgs) {\n        return DatabaseUtils.stringForQuery(mDB, sql, selectionArgs);\n    }\n\n    @Override\n    protected Cursor rawQuery(String sql, String[] selectionArgs) {\n        return mDB.rawQuery(sql, selectionArgs);\n    }\n}\n"
  },
  {
    "path": "deprecated/android/samples/benchmark/src/androidTest/java/com/tencent/wcdb/benchmark/concurrent/FrameworkWalConcurrentTest.java",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdb.benchmark.concurrent;\n\nimport android.annotation.TargetApi;\nimport android.database.sqlite.SQLiteDatabase;\n\nimport org.junit.After;\nimport org.junit.Before;\nimport org.junit.Test;\n\npublic class FrameworkWalConcurrentTest extends FrameworkConcurrentTest {\n\n    @Override\n    @Before\n    public void doBefore() {\n        super.doBefore();\n    }\n\n    @Override\n    @After\n    public void doAfter() {\n        super.doAfter();\n    }\n\n    @Override\n    @Test\n    public void doTest() {\n        super.doTest();\n    }\n\n    @Override\n    @TargetApi(16)\n    protected void createDB(String path) {\n        mDB = SQLiteDatabase.openDatabase(path, null,\n                SQLiteDatabase.CREATE_IF_NECESSARY | SQLiteDatabase.ENABLE_WRITE_AHEAD_LOGGING);\n    }\n}\n"
  },
  {
    "path": "deprecated/android/samples/benchmark/src/androidTest/java/com/tencent/wcdb/benchmark/concurrent/SQLCipherConcurrentTest.java",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdb.benchmark.concurrent;\n\nimport android.database.Cursor;\nimport android.support.test.InstrumentationRegistry;\n\nimport com.tencent.wcdb.benchmark.single.SingleThreadedTest;\n\nimport net.sqlcipher.DatabaseUtils;\nimport net.sqlcipher.database.SQLiteDatabase;\n\nimport org.junit.After;\nimport org.junit.Before;\nimport org.junit.Test;\n\npublic class SQLCipherConcurrentTest extends ConcurrentTest {\n\n    @Override\n    @Before\n    public void doBefore() {\n        SQLiteDatabase.loadLibs(InstrumentationRegistry.getTargetContext());\n        super.doBefore();\n    }\n\n    @Override\n    @After\n    public void doAfter() {\n        super.doAfter();\n    }\n\n    @Override\n    @Test\n    public void doTest() {\n        super.doTest();\n    }\n\n\n    protected SQLiteDatabase mDB;\n\n    @Override\n    protected void createDB(String path) {\n        mDB = SQLiteDatabase.openOrCreateDatabase(path, (String) null, null, null);\n    }\n\n    @Override\n    protected void closeDB() {\n        mDB.close();\n        mDB = null;\n    }\n\n    @Override\n    protected void execSQL(String sql) {\n        mDB.execSQL(sql);\n    }\n\n    @Override\n    protected void execSQL(String sql, Object[] bindArgs) {\n        mDB.execSQL(sql, bindArgs);\n    }\n\n    @Override\n    protected void beginTransaction() {\n        mDB.beginTransaction();\n    }\n\n    @Override\n    protected void setTransactionSuccessful() {\n        mDB.setTransactionSuccessful();\n    }\n\n    @Override\n    protected void endTransaction() {\n        mDB.endTransaction();\n    }\n\n    @Override\n    protected long longForQuery(String sql, String[] selectionArgs) {\n        return DatabaseUtils.longForQuery(mDB, sql, selectionArgs);\n    }\n\n    @Override\n    protected String stringForQuery(String sql, String[] selectionArgs) {\n        return DatabaseUtils.stringForQuery(mDB, sql, selectionArgs);\n    }\n\n    @Override\n    protected Cursor rawQuery(String sql, String[] selectionArgs) {\n        return mDB.rawQuery(sql, selectionArgs);\n    }\n}\n"
  },
  {
    "path": "deprecated/android/samples/benchmark/src/androidTest/java/com/tencent/wcdb/benchmark/concurrent/SQLCipherEncryptedConcurrentTest.java",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdb.benchmark.concurrent;\n\nimport net.sqlcipher.database.SQLiteDatabase;\n\nimport org.junit.After;\nimport org.junit.Before;\nimport org.junit.Test;\n\npublic class SQLCipherEncryptedConcurrentTest extends SQLCipherConcurrentTest {\n\n    @Override\n    @Before\n    public void doBefore() {\n        super.doBefore();\n    }\n\n    @Override\n    @After\n    public void doAfter() {\n        super.doAfter();\n    }\n\n    @Override\n    @Test\n    public void doTest() {\n        super.doTest();\n    }\n\n\n    private static final String PASSPHRASE = \"passphrase\";\n\n    @Override\n    public void createDB(String path) {\n        mDB = SQLiteDatabase.openOrCreateDatabase(path, PASSPHRASE, null, null);\n    }\n\n}\n"
  },
  {
    "path": "deprecated/android/samples/benchmark/src/androidTest/java/com/tencent/wcdb/benchmark/concurrent/WCDBConcurrentTest.java",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdb.benchmark.concurrent;\n\nimport android.database.Cursor;\n\nimport com.tencent.wcdb.DatabaseUtils;\nimport com.tencent.wcdb.database.SQLiteDatabase;\nimport com.tencent.wcdb.database.SQLiteDirectCursor;\nimport com.tencent.wcdb.database.SQLiteGlobal;\n\nimport org.junit.After;\nimport org.junit.Before;\nimport org.junit.Test;\n\npublic class WCDBConcurrentTest extends ConcurrentTest {\n\n    @Override\n    @Before\n    public void doBefore() {\n        SQLiteGlobal.initialize();\n        super.doBefore();\n    }\n\n    @Override\n    @After\n    public void doAfter() {\n        super.doAfter();\n    }\n\n    @Override\n    @Test\n    public void doTest() {\n        super.doTest();\n    }\n\n\n    protected SQLiteDatabase mDB;\n\n    @Override\n    protected void createDB(String path) {\n        mDB = SQLiteDatabase.openOrCreateDatabase(path, SQLiteDirectCursor.FACTORY);\n    }\n\n    @Override\n    protected void closeDB() {\n        mDB.close();\n        mDB = null;\n    }\n\n    @Override\n    protected void execSQL(String sql) {\n        mDB.execSQL(sql);\n    }\n\n    @Override\n    protected void execSQL(String sql, Object[] bindArgs) {\n        mDB.execSQL(sql, bindArgs);\n    }\n\n    @Override\n    protected void beginTransaction() {\n        mDB.beginTransaction();\n    }\n\n    @Override\n    protected void setTransactionSuccessful() {\n        mDB.setTransactionSuccessful();\n    }\n\n    @Override\n    protected void endTransaction() {\n        mDB.endTransaction();\n    }\n\n    @Override\n    protected long longForQuery(String sql, String[] selectionArgs) {\n        return DatabaseUtils.longForQuery(mDB, sql, selectionArgs);\n    }\n\n    @Override\n    protected String stringForQuery(String sql, String[] selectionArgs) {\n        return DatabaseUtils.stringForQuery(mDB, sql, selectionArgs);\n    }\n\n    @Override\n    protected Cursor rawQuery(String sql, String[] selectionArgs) {\n        return mDB.rawQuery(sql, selectionArgs);\n    }\n}\n"
  },
  {
    "path": "deprecated/android/samples/benchmark/src/androidTest/java/com/tencent/wcdb/benchmark/concurrent/WCDBEncryptedConcurrentTest.java",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdb.benchmark.concurrent;\n\nimport com.tencent.wcdb.database.SQLiteDatabase;\n\nimport org.junit.After;\nimport org.junit.Before;\nimport org.junit.Test;\n\npublic class WCDBEncryptedConcurrentTest extends WCDBConcurrentTest {\n\n    @Override\n    @Before\n    public void doBefore() {\n        super.doBefore();\n    }\n\n    @Override\n    @After\n    public void doAfter() {\n        super.doAfter();\n    }\n\n    @Override\n    @Test\n    public void doTest() {\n        super.doTest();\n    }\n\n\n    private static final String PASSPHRASE = \"passphrase\";\n\n    @Override\n    public void createDB(String path) {\n        mDB = SQLiteDatabase.openOrCreateDatabase(path, PASSPHRASE.getBytes(), null, null);\n    }\n\n}\n"
  },
  {
    "path": "deprecated/android/samples/benchmark/src/androidTest/java/com/tencent/wcdb/benchmark/concurrent/WCDBWalConcurrentTest.java",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdb.benchmark.concurrent;\n\nimport com.tencent.wcdb.database.SQLiteDatabase;\n\nimport org.junit.After;\nimport org.junit.Before;\nimport org.junit.Test;\n\npublic class WCDBWalConcurrentTest extends WCDBConcurrentTest {\n\n    @Override\n    @Before\n    public void doBefore() {\n        super.doBefore();\n    }\n\n    @Override\n    @After\n    public void doAfter() {\n        super.doAfter();\n    }\n\n    @Override\n    @Test\n    public void doTest() {\n        super.doTest();\n    }\n\n    @Override\n    public void createDB(String path) {\n        mDB = SQLiteDatabase.openOrCreateDatabaseInWalMode(path, null);\n    }\n\n}\n"
  },
  {
    "path": "deprecated/android/samples/benchmark/src/androidTest/java/com/tencent/wcdb/benchmark/concurrent/WCDBWalEncryptedConcurrentTest.java",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdb.benchmark.concurrent;\n\nimport com.tencent.wcdb.database.SQLiteDatabase;\n\nimport org.junit.After;\nimport org.junit.Before;\nimport org.junit.Test;\n\npublic class WCDBWalEncryptedConcurrentTest extends WCDBConcurrentTest {\n\n    @Override\n    @Before\n    public void doBefore() {\n        super.doBefore();\n    }\n\n    @Override\n    @After\n    public void doAfter() {\n        super.doAfter();\n    }\n\n    @Override\n    @Test\n    public void doTest() {\n        super.doTest();\n    }\n\n\n    private static final String PASSPHRASE = \"passphrase\";\n\n    @Override\n    public void createDB(String path) {\n        mDB = SQLiteDatabase.openOrCreateDatabaseInWalMode(path, PASSPHRASE.getBytes(), null, null);\n    }\n\n}\n"
  },
  {
    "path": "deprecated/android/samples/benchmark/src/androidTest/java/com/tencent/wcdb/benchmark/single/FrameworkSingleThreadedTest.java",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdb.benchmark.single;\n\nimport android.database.Cursor;\nimport android.database.DatabaseUtils;\nimport android.database.sqlite.SQLiteDatabase;\n\nimport org.junit.After;\nimport org.junit.Before;\nimport org.junit.Test;\n\npublic class FrameworkSingleThreadedTest extends SingleThreadedTest {\n\n    @Override\n    @Before\n    public void doBefore() {\n        super.doBefore();\n    }\n\n    @Override\n    @After\n    public void doAfter() {\n        super.doAfter();\n    }\n\n    @Override\n    @Test\n    public void doTest() {\n        super.doTest();\n    }\n\n\n    protected SQLiteDatabase mDB;\n\n    @Override\n    protected void createDB(String path) {\n        mDB = SQLiteDatabase.openOrCreateDatabase(path, null);\n    }\n\n    @Override\n    protected void closeDB() {\n        mDB.close();\n        mDB = null;\n    }\n\n    @Override\n    protected void execSQL(String sql) {\n        mDB.execSQL(sql);\n    }\n\n    @Override\n    protected void execSQL(String sql, Object[] bindArgs) {\n        mDB.execSQL(sql, bindArgs);\n    }\n\n    @Override\n    protected void beginTransaction() {\n        mDB.beginTransaction();\n    }\n\n    @Override\n    protected void setTransactionSuccessful() {\n        mDB.setTransactionSuccessful();\n    }\n\n    @Override\n    protected void endTransaction() {\n        mDB.endTransaction();\n    }\n\n    @Override\n    protected long longForQuery(String sql, String[] selectionArgs) {\n        return DatabaseUtils.longForQuery(mDB, sql, selectionArgs);\n    }\n\n    @Override\n    protected String stringForQuery(String sql, String[] selectionArgs) {\n        return DatabaseUtils.stringForQuery(mDB, sql, selectionArgs);\n    }\n\n    @Override\n    protected Cursor rawQuery(String sql, String[] selectionArgs) {\n        return mDB.rawQuery(sql, selectionArgs);\n    }\n}\n"
  },
  {
    "path": "deprecated/android/samples/benchmark/src/androidTest/java/com/tencent/wcdb/benchmark/single/FrameworkWalSingleThreadedTest.java",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdb.benchmark.single;\n\nimport android.annotation.TargetApi;\nimport android.database.Cursor;\nimport android.database.DatabaseUtils;\nimport android.database.sqlite.SQLiteDatabase;\n\nimport org.junit.After;\nimport org.junit.Before;\nimport org.junit.Test;\n\npublic class FrameworkWalSingleThreadedTest extends FrameworkSingleThreadedTest {\n\n    @Override\n    @Before\n    public void doBefore() {\n        super.doBefore();\n    }\n\n    @Override\n    @After\n    public void doAfter() {\n        super.doAfter();\n    }\n\n    @Override\n    @Test\n    public void doTest() {\n        super.doTest();\n    }\n\n    @Override\n    @TargetApi(16)\n    protected void createDB(String path) {\n        mDB = SQLiteDatabase.openDatabase(path, null,\n                SQLiteDatabase.CREATE_IF_NECESSARY | SQLiteDatabase.ENABLE_WRITE_AHEAD_LOGGING);\n    }\n}\n"
  },
  {
    "path": "deprecated/android/samples/benchmark/src/androidTest/java/com/tencent/wcdb/benchmark/single/SQLCipherEncryptedSingleThreadedTest.java",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdb.benchmark.single;\n\nimport net.sqlcipher.database.SQLiteDatabase;\n\nimport org.junit.After;\nimport org.junit.Before;\nimport org.junit.Test;\n\npublic class SQLCipherEncryptedSingleThreadedTest extends SQLCipherSingleThreadedTest {\n\n    @Override\n    @Before\n    public void doBefore() {\n        super.doBefore();\n    }\n\n    @Override\n    @After\n    public void doAfter() {\n        super.doAfter();\n    }\n\n    @Override\n    @Test\n    public void doTest() {\n        super.doTest();\n    }\n\n\n    private static final String PASSPHRASE = \"passphrase\";\n\n    @Override\n    public void createDB(String path) {\n        mDB = SQLiteDatabase.openOrCreateDatabase(path, PASSPHRASE, null, null);\n    }\n\n}\n"
  },
  {
    "path": "deprecated/android/samples/benchmark/src/androidTest/java/com/tencent/wcdb/benchmark/single/SQLCipherSingleThreadedTest.java",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdb.benchmark.single;\n\nimport android.database.Cursor;\nimport android.support.test.InstrumentationRegistry;\n\nimport net.sqlcipher.DatabaseUtils;\nimport net.sqlcipher.database.SQLiteDatabase;\n\nimport org.junit.After;\nimport org.junit.Before;\nimport org.junit.Test;\n\npublic class SQLCipherSingleThreadedTest extends SingleThreadedTest {\n\n    @Override\n    @Before\n    public void doBefore() {\n        SQLiteDatabase.loadLibs(InstrumentationRegistry.getTargetContext());\n        super.doBefore();\n    }\n\n    @Override\n    @After\n    public void doAfter() {\n        super.doAfter();\n    }\n\n    @Override\n    @Test\n    public void doTest() {\n        super.doTest();\n    }\n\n\n    protected SQLiteDatabase mDB;\n\n    @Override\n    protected void createDB(String path) {\n        mDB = SQLiteDatabase.openOrCreateDatabase(path, (String) null, null, null);\n    }\n\n    @Override\n    protected void closeDB() {\n        mDB.close();\n        mDB = null;\n    }\n\n    @Override\n    protected void execSQL(String sql) {\n        mDB.execSQL(sql);\n    }\n\n    @Override\n    protected void execSQL(String sql, Object[] bindArgs) {\n        mDB.execSQL(sql, bindArgs);\n    }\n\n    @Override\n    protected void beginTransaction() {\n        mDB.beginTransaction();\n    }\n\n    @Override\n    protected void setTransactionSuccessful() {\n        mDB.setTransactionSuccessful();\n    }\n\n    @Override\n    protected void endTransaction() {\n        mDB.endTransaction();\n    }\n\n    @Override\n    protected long longForQuery(String sql, String[] selectionArgs) {\n        return DatabaseUtils.longForQuery(mDB, sql, selectionArgs);\n    }\n\n    @Override\n    protected String stringForQuery(String sql, String[] selectionArgs) {\n        return DatabaseUtils.stringForQuery(mDB, sql, selectionArgs);\n    }\n\n    @Override\n    protected Cursor rawQuery(String sql, String[] selectionArgs) {\n        return mDB.rawQuery(sql, selectionArgs);\n    }\n}\n"
  },
  {
    "path": "deprecated/android/samples/benchmark/src/androidTest/java/com/tencent/wcdb/benchmark/single/SingleThreadedTest.java",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdb.benchmark.single;\n\nimport android.content.Context;\nimport android.database.Cursor;\nimport android.support.test.InstrumentationRegistry;\nimport android.util.Log;\n\nimport junit.framework.Assert;\n\nimport java.io.File;\n\npublic abstract class SingleThreadedTest {\n\n    private static final String TAG = \"WCDB.Benchmark\";\n    private static final String DATABASE_NAME = \"test.db\";\n\n    protected abstract void createDB(String path);\n    protected abstract void closeDB();\n    protected abstract void execSQL(String sql);\n    protected abstract void execSQL(String sql, Object[] bindArgs);\n    protected abstract void beginTransaction();\n    protected abstract void setTransactionSuccessful();\n    protected abstract void endTransaction();\n    protected abstract long longForQuery(String sql, String[] selectionArgs);\n    protected abstract String stringForQuery(String sql, String[] selectionArgs);\n    protected abstract Cursor rawQuery(String sql, String[] selectionArgs);\n\n    public void doBefore() {\n        Log.i(\"WCDB.Benchmark\", \"[DB BENCHMARK] | Begin | \" + getClass().getSimpleName());\n        Context context = InstrumentationRegistry.getTargetContext();\n\n        // Remove pre-existing database.\n        File dbFile = context.getDatabasePath(DATABASE_NAME);\n        dbFile.getParentFile().mkdirs();\n        dbFile.delete();\n        new File(dbFile.getParentFile(), dbFile.getName() + \"-journal\").delete();\n        new File(dbFile.getParentFile(), dbFile.getName() + \"-wal\").delete();\n\n        // Create database and table, measuring time.\n        long time = System.nanoTime();\n        createDB(dbFile.getPath());\n        execSQL(\"CREATE TABLE message (id INTEGER PRIMARY KEY, user TEXT, content TEXT);\");\n        execSQL(\"CREATE INDEX message_user ON message (user);\");\n        time = System.nanoTime() - time;\n        Log.i(TAG, \"[DB BENCHMARK] | Create database | \" + time);\n    }\n\n    public void doTest() {\n        // MEASUREMENT: Insertion in one transaction\n        long time = System.nanoTime();\n        beginTransaction();\n        for (int i = 0; i < 19000; i++) {\n            execSQL(\"INSERT INTO message (id, user, content) VALUES (?, ?, ?);\",\n                    new Object[] {i, \"u\" + i, \"Test message: \" + i});\n        }\n        setTransactionSuccessful();\n        endTransaction();\n        time = System.nanoTime() - time;\n        Log.i(TAG, \"[DB BENCHMARK] | Insertion in one transaction | \" + time);\n\n        // TEST: count rows\n        int count = (int) longForQuery(\"SELECT count(*) FROM message;\", null);\n        Assert.assertEquals(count, 19000);\n\n        // MEASUREMENT: Insertion in separated transactions\n        time = System.nanoTime();\n        for (int i = 19000; i < 20000; i++) {\n            execSQL(\"INSERT INTO message (id, user, content) VALUES (?, ?, ?);\",\n                    new Object[] {i, \"u\" + i, \"Test message: \" + i});\n        }\n        time = System.nanoTime() - time;\n        Log.i(TAG, \"[DB BENCHMARK] | Insertion in separated transactions | \" + time);\n\n        // TEST: count rows\n        count = (int) longForQuery(\"SELECT count(*) FROM message;\", null);\n        Assert.assertEquals(count, 20000);\n\n        // MEASUREMENT: Insertion rollback\n        time = System.nanoTime();\n        beginTransaction();\n        for (int i = 20000; i < 21000; i++) {\n            execSQL(\"INSERT INTO message (id, user, content) VALUES (?, ?, ?);\",\n                    new Object[] {i, \"u\" + i, \"Test message: \" + i});\n        }\n        endTransaction();\n        time = System.nanoTime() - time;\n        Log.i(TAG, \"[DB BENCHMARK] | Insertion rollback | \" + time);\n\n        // MEASUREMENT & TEST: count rows\n        time = System.nanoTime();\n        count = (int) longForQuery(\"SELECT count(*) FROM message;\", null);\n        time = System.nanoTime() - time;\n        Assert.assertEquals(count, 20000);\n        Log.i(TAG, \"[DB BENCHMARK] | Count rows (B-tree traversal) | \" + time);\n\n        // MEASUREMENT & TEST: update in one SQL\n        time = System.nanoTime();\n        execSQL(\"UPDATE message SET content = 'Modified message: ' || id WHERE id < ?;\",\n                new Object[] {10000});\n        time = System.nanoTime() - time;\n\n        String text = stringForQuery(\"SELECT content FROM message WHERE id = ?;\",\n                new String[] {\"4567\"});\n        Assert.assertEquals(text, \"Modified message: 4567\");\n        Log.i(TAG, \"[DB BENCHMARK] | Update in one SQL | \" + time);\n\n        // MEASUREMENT & TEST: update in one transaction\n        time = System.nanoTime();\n        beginTransaction();\n        for (int i = 5000; i < 15000; i++) {\n            execSQL(\"UPDATE message SET content = ? WHERE id = ?;\",\n                    new Object[]{\"Again modified message: \" + i, i});\n        }\n        setTransactionSuccessful();\n        endTransaction();\n        time = System.nanoTime() - time;\n\n        text = stringForQuery(\"SELECT content FROM message WHERE id = ?;\",\n                new String[] {\"12345\"});\n        Assert.assertEquals(text, \"Again modified message: 12345\");\n        Log.i(TAG, \"[DB BENCHMARK] | Update in one transaction | \" + time);\n\n        // MEASUREMENT & TEST: update in separated transactions\n        time = System.nanoTime();\n        for (int i = 15000; i < 16000; i++) {\n            execSQL(\"UPDATE message SET content = ? WHERE id = ?;\",\n                    new Object[]{\"Again2 modified message: \" + i, i});\n        }\n        time = System.nanoTime() - time;\n\n        text = stringForQuery(\"SELECT content FROM message WHERE id = ?;\",\n                new String[] {\"15678\"});\n        Assert.assertEquals(text, \"Again2 modified message: 15678\");\n        Log.i(TAG, \"[DB BENCHMARK] | Update in separated transactions | \" + time);\n\n        // MEASUREMENT & TEST: query one by one\n        Cursor cursor;\n        time = System.nanoTime();\n        for (int i = 0; i < 10000; i++) {\n            cursor = rawQuery(\"SELECT * FROM message WHERE id = ?;\",\n                    new String[] {Integer.toString(i)});\n            Assert.assertTrue(cursor.moveToFirst());\n            Assert.assertEquals(cursor.getInt(0), i);\n            Assert.assertEquals(cursor.getString(1), \"u\" + i);\n            Assert.assertEquals(cursor.getString(2), ((i < 5000) ?\n                    \"Modified message: \" : \"Again modified message: \") + i);\n            cursor.close();\n            Assert.assertTrue(cursor.isClosed());\n        }\n        time = System.nanoTime() - time;\n        Log.i(TAG, \"[DB BENCHMARK] | Query one by one | \" + time);\n\n        // MEASUREMENT & TEST: query fill\n        count = 10000;\n        time = System.nanoTime();\n        cursor = rawQuery(\"SELECT * FROM message WHERE id >= ?;\",\n                new String[] {Integer.toString(10000)});\n        while (cursor.moveToNext()) {\n            String expected;\n            if (count < 15000)\n                expected = \"Again modified message: \";\n            else if (count < 16000)\n                expected = \"Again2 modified message: \";\n            else\n                expected = \"Test message: \";\n\n            Assert.assertEquals(cursor.getInt(0), count);\n            Assert.assertEquals(cursor.getString(1), \"u\" + count);\n            Assert.assertEquals(cursor.getString(2), expected + count);\n            count++;\n        }\n        cursor.close();\n        Assert.assertTrue(cursor.isClosed());\n        Assert.assertEquals(count, 20000);\n        time = System.nanoTime() - time;\n        Log.i(TAG, \"[DB BENCHMARK] | Query fill | \" + time);\n\n        // MEASUREMENT: delete in one SQL\n        time = System.nanoTime();\n        execSQL(\"DELETE FROM message WHERE id >= ?;\", new Object[] {15000});\n        time = System.nanoTime() - time;\n        Log.i(TAG, \"[DB BENCHMARK] | Delete in one SQL | \" + time);\n\n        // MEASUREMENT: delete in one transaction\n        time = System.nanoTime();\n        beginTransaction();\n        for (int i = 10000; i < 15000; i++) {\n            execSQL(\"DELETE FROM message WHERE id = ?;\", new Object[] {i});\n        }\n        setTransactionSuccessful();\n        endTransaction();\n        time = System.nanoTime() - time;\n        Log.i(TAG, \"[DB BENCHMARK] | Delete in one transaction | \" + time);\n\n        // MEASUREMENT: delete in separated transactions\n        time = System.nanoTime();\n        for (int i = 5000; i < 6000; i++) {\n            execSQL(\"DELETE FROM message WHERE id = ?;\", new Object[] {i});\n        }\n        time = System.nanoTime() - time;\n        Log.i(TAG, \"[DB BENCHMARK] | Delete in separated transactions | \" + time);\n\n        // TEST: count\n        count = (int) longForQuery(\"SELECT count(*) FROM message;\", null);\n        Assert.assertEquals(count, 9000);\n    }\n\n    public void doAfter() {\n        long time = System.nanoTime();\n        closeDB();\n        time = System.nanoTime() - time;\n        Log.i(TAG, \"[DB BENCHMARK] | Close database | \" + time);\n        Log.i(\"WCDB.Benchmark\", \"[DB BENCHMARK] | End | \" + getClass().getSimpleName());\n    }\n}\n"
  },
  {
    "path": "deprecated/android/samples/benchmark/src/androidTest/java/com/tencent/wcdb/benchmark/single/WCDBEncryptedSingleThreadedTest.java",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdb.benchmark.single;\n\nimport com.tencent.wcdb.database.SQLiteDatabase;\n\nimport org.junit.After;\nimport org.junit.Before;\nimport org.junit.Test;\n\npublic class WCDBEncryptedSingleThreadedTest extends WCDBSingleThreadedTest {\n\n    @Override\n    @Before\n    public void doBefore() {\n        super.doBefore();\n    }\n\n    @Override\n    @After\n    public void doAfter() {\n        super.doAfter();\n    }\n\n    @Override\n    @Test\n    public void doTest() {\n        super.doTest();\n    }\n\n\n    private static final String PASSPHRASE = \"passphrase\";\n\n    @Override\n    public void createDB(String path) {\n        mDB = SQLiteDatabase.openOrCreateDatabase(path, PASSPHRASE.getBytes(), null, null);\n    }\n\n}\n"
  },
  {
    "path": "deprecated/android/samples/benchmark/src/androidTest/java/com/tencent/wcdb/benchmark/single/WCDBSingleThreadedTest.java",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdb.benchmark.single;\n\nimport android.database.Cursor;\n\nimport com.tencent.wcdb.DatabaseUtils;\nimport com.tencent.wcdb.database.SQLiteDatabase;\nimport com.tencent.wcdb.database.SQLiteGlobal;\n\nimport org.junit.After;\nimport org.junit.Before;\nimport org.junit.Test;\n\npublic class WCDBSingleThreadedTest extends SingleThreadedTest {\n\n    @Override\n    @Before\n    public void doBefore() {\n        SQLiteGlobal.initialize();\n        super.doBefore();\n    }\n\n    @Override\n    @After\n    public void doAfter() {\n        super.doAfter();\n    }\n\n    @Override\n    @Test\n    public void doTest() {\n        super.doTest();\n    }\n\n\n    protected SQLiteDatabase mDB;\n\n    @Override\n    protected void createDB(String path) {\n        mDB = SQLiteDatabase.openOrCreateDatabase(path, null);\n    }\n\n    @Override\n    protected void closeDB() {\n        mDB.close();\n        mDB = null;\n    }\n\n    @Override\n    protected void execSQL(String sql) {\n        mDB.execSQL(sql);\n    }\n\n    @Override\n    protected void execSQL(String sql, Object[] bindArgs) {\n        mDB.execSQL(sql, bindArgs);\n    }\n\n    @Override\n    protected void beginTransaction() {\n        mDB.beginTransaction();\n    }\n\n    @Override\n    protected void setTransactionSuccessful() {\n        mDB.setTransactionSuccessful();\n    }\n\n    @Override\n    protected void endTransaction() {\n        mDB.endTransaction();\n    }\n\n    @Override\n    protected long longForQuery(String sql, String[] selectionArgs) {\n        return DatabaseUtils.longForQuery(mDB, sql, selectionArgs);\n    }\n\n    @Override\n    protected String stringForQuery(String sql, String[] selectionArgs) {\n        return DatabaseUtils.stringForQuery(mDB, sql, selectionArgs);\n    }\n\n    @Override\n    protected Cursor rawQuery(String sql, String[] selectionArgs) {\n        return mDB.rawQuery(sql, selectionArgs);\n    }\n}\n"
  },
  {
    "path": "deprecated/android/samples/benchmark/src/androidTest/java/com/tencent/wcdb/benchmark/single/WCDBWalAsyncCpSingleThreadedTest.java",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdb.benchmark.single;\n\nimport com.tencent.wcdb.database.SQLiteDatabase;\n\nimport org.junit.After;\nimport org.junit.Before;\nimport org.junit.Test;\n\npublic class WCDBWalAsyncCpSingleThreadedTest extends WCDBSingleThreadedTest {\n\n    @Override\n    @Before\n    public void doBefore() {\n        super.doBefore();\n    }\n\n    @Override\n    @After\n    public void doAfter() {\n        super.doAfter();\n    }\n\n    @Override\n    @Test\n    public void doTest() {\n        super.doTest();\n    }\n\n    @Override\n    public void createDB(String path) {\n        mDB = SQLiteDatabase.openOrCreateDatabaseInWalMode(path, null);\n        mDB.setAsyncCheckpointEnabled(true);\n    }\n\n}\n"
  },
  {
    "path": "deprecated/android/samples/benchmark/src/androidTest/java/com/tencent/wcdb/benchmark/single/WCDBWalEncryptedAsyncCpSingleThreadedTest.java",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdb.benchmark.single;\n\nimport com.tencent.wcdb.database.SQLiteDatabase;\n\nimport org.junit.After;\nimport org.junit.Before;\nimport org.junit.Test;\n\npublic class WCDBWalEncryptedAsyncCpSingleThreadedTest extends WCDBSingleThreadedTest {\n\n    @Override\n    @Before\n    public void doBefore() {\n        super.doBefore();\n    }\n\n    @Override\n    @After\n    public void doAfter() {\n        super.doAfter();\n    }\n\n    @Override\n    @Test\n    public void doTest() {\n        super.doTest();\n    }\n\n\n    private static final String PASSPHRASE = \"passphrase\";\n\n    @Override\n    public void createDB(String path) {\n        mDB = SQLiteDatabase.openOrCreateDatabaseInWalMode(path, PASSPHRASE.getBytes(), null, null);\n        mDB.setAsyncCheckpointEnabled(true);\n    }\n\n}\n"
  },
  {
    "path": "deprecated/android/samples/benchmark/src/androidTest/java/com/tencent/wcdb/benchmark/single/WCDBWalEncryptedSingleThreadedTest.java",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdb.benchmark.single;\n\nimport com.tencent.wcdb.database.SQLiteDatabase;\n\nimport org.junit.After;\nimport org.junit.Before;\nimport org.junit.Test;\n\npublic class WCDBWalEncryptedSingleThreadedTest extends WCDBSingleThreadedTest {\n\n    @Override\n    @Before\n    public void doBefore() {\n        super.doBefore();\n    }\n\n    @Override\n    @After\n    public void doAfter() {\n        super.doAfter();\n    }\n\n    @Override\n    @Test\n    public void doTest() {\n        super.doTest();\n    }\n\n\n    private static final String PASSPHRASE = \"passphrase\";\n\n    @Override\n    public void createDB(String path) {\n        mDB = SQLiteDatabase.openOrCreateDatabaseInWalMode(path, PASSPHRASE.getBytes(), null, null);\n    }\n\n}\n"
  },
  {
    "path": "deprecated/android/samples/benchmark/src/androidTest/java/com/tencent/wcdb/benchmark/single/WCDBWalSingleThreadedTest.java",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdb.benchmark.single;\n\nimport com.tencent.wcdb.database.SQLiteDatabase;\n\nimport org.junit.After;\nimport org.junit.Before;\nimport org.junit.Test;\n\npublic class WCDBWalSingleThreadedTest extends WCDBSingleThreadedTest {\n\n    @Override\n    @Before\n    public void doBefore() {\n        super.doBefore();\n    }\n\n    @Override\n    @After\n    public void doAfter() {\n        super.doAfter();\n    }\n\n    @Override\n    @Test\n    public void doTest() {\n        super.doTest();\n    }\n\n    @Override\n    public void createDB(String path) {\n        mDB = SQLiteDatabase.openOrCreateDatabaseInWalMode(path, null);\n    }\n\n}\n"
  },
  {
    "path": "deprecated/android/samples/benchmark/src/main/AndroidManifest.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<manifest xmlns:android=\"http://schemas.android.com/apk/res/android\"\n          package=\"com.tencent.wcdb.benchmark\">\n\n    <application\n        android:allowBackup=\"true\"\n        android:icon=\"@mipmap/ic_launcher\"\n        android:label=\"@string/app_name\"\n        android:roundIcon=\"@mipmap/ic_launcher_round\"\n        android:supportsRtl=\"true\">\n    </application>\n\n</manifest>"
  },
  {
    "path": "deprecated/android/samples/benchmark/src/main/res/values/strings.xml",
    "content": "<resources>\n    <string name=\"app_name\">WCDB Benchmark</string>\n</resources>\n"
  },
  {
    "path": "deprecated/android/samples/benchmark/summary.awk",
    "content": "BEGIN { \n    FS = \" \\\\| \" \n    printf \"Test Name\"\n}\n$1 !~ /\\[DB BENCHMARK\\]/ { next }\n\n$2 == \"Begin\" {\n    testName = $3\n    next\n}\n\n$2 == \"End\" {\n    testName = \"\"\n    next\n}\n\n{\n    if (substr($2, 1, 1) == \">\")\n        next\n\n    item = $2\n    value = $3\n    \n    if (!(item in itemMapping)) {\n        itemMapping[item] = itemMapping[0] += 1\n        printf \",%s\", item\n    }\n\n    idxItem = itemMapping[item]\n    idx = bench[testName][idxItem][0] += 1\n    bench[testName][idxItem][idx] = value\n}\n\nEND {\n    printf \"\\n\"\n    for (testName in bench) {\n        for (itemId in bench[testName]) {\n            delete bench[testName][itemId][0]\n            total = 0\n            count = 0\n            for (idx in bench[testName][itemId]) {\n                total += bench[testName][itemId][idx]\n                count += 1\n            }\n            delete bench[testName][itemId]\n            bench[testName][itemId] = total / count / 1000000\n        }\n\n        printf \"%s\", testName\n        for (i = 1; i <= itemMapping[0]; i++) {\n            printf \",%.0f\", bench[testName][i]\n        }\n        printf \"\\n\"\n    }\n}"
  },
  {
    "path": "deprecated/android/samples/sample-encryptdb/.gitignore",
    "content": "/build\n"
  },
  {
    "path": "deprecated/android/samples/sample-encryptdb/build.gradle",
    "content": "apply plugin: 'com.android.application'\n\nandroid {\n    compileSdkVersion 32\n\n    defaultConfig {\n        applicationId \"com.tencent.wcdb.sample.encryptdb\"\n        minSdkVersion 14\n        targetSdkVersion 32\n\n        testInstrumentationRunner \"android.support.test.runner.AndroidJUnitRunner\"\n\n    }\n    buildTypes {\n        release {\n            minifyEnabled false\n            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'\n        }\n    }\n}\n\ndependencies {\n    androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {\n        exclude group: 'com.android.support', module: 'support-annotations'\n    })\n\n    implementation project(':wcdb')\n    //implementation 'com.tencent.wcdb:wcdb-android:1.0.4'\n    implementation 'com.android.support:appcompat-v7:28.0.0'\n    testImplementation 'junit:junit:4.12'\n}\n"
  },
  {
    "path": "deprecated/android/samples/sample-encryptdb/proguard-rules.pro",
    "content": "# Add project specific ProGuard rules here.\n# By default, the flags in this file are appended to flags specified\n# in C:\\android\\sdk/tools/proguard/proguard-android.txt\n# You can edit the include path and order by changing the proguardFiles\n# directive in build.gradle.\n#\n# For more details, see\n#   http://developer.android.com/guide/developing/tools/proguard.html\n\n# Add any project specific keep options here:\n\n# If your project uses WebView with JS, uncomment the following\n# and specify the fully qualified class name to the JavaScript interface\n# class:\n#-keepclassmembers class fqcn.of.javascript.interface.for.webview {\n#   public *;\n#}\n\n# Uncomment this to preserve the line number information for\n# debugging stack traces.\n#-keepattributes SourceFile,LineNumberTable\n\n# If you keep the line number information, uncomment this to\n# hide the original source file name.\n#-renamesourcefileattribute SourceFile\n"
  },
  {
    "path": "deprecated/android/samples/sample-encryptdb/src/androidTest/java/com/tencent/wcdb/sample/encryptdb/ExampleInstrumentedTest.java",
    "content": "package com.tencent.wcdb.sample.encryptdb;\n\nimport android.content.Context;\nimport android.support.test.InstrumentationRegistry;\nimport android.support.test.runner.AndroidJUnit4;\n\nimport org.junit.Test;\nimport org.junit.runner.RunWith;\n\nimport static org.junit.Assert.*;\n\n/**\n * Instrumentation test, which will execute on an Android device.\n *\n * @see <a href=\"http://d.android.com/tools/testing\">Testing documentation</a>\n */\n@RunWith(AndroidJUnit4.class)\npublic class ExampleInstrumentedTest {\n    @Test\n    public void useAppContext() throws Exception {\n        // Context of the app under test.\n        Context appContext = InstrumentationRegistry.getTargetContext();\n\n        assertEquals(\"com.tencent.wcdb.sample.encryptdb\", appContext.getPackageName());\n    }\n}\n"
  },
  {
    "path": "deprecated/android/samples/sample-encryptdb/src/main/AndroidManifest.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<manifest xmlns:android=\"http://schemas.android.com/apk/res/android\"\n          package=\"com.tencent.wcdb.sample.encryptdb\">\n\n    <application\n        android:allowBackup=\"true\"\n        android:icon=\"@mipmap/ic_launcher\"\n        android:label=\"@string/app_name\"\n        android:roundIcon=\"@mipmap/ic_launcher_round\"\n        android:supportsRtl=\"true\"\n        android:theme=\"@style/AppTheme\">\n        <activity\n            android:name=\".MainActivity\"\n            android:label=\"@string/app_name\"\n            android:theme=\"@style/AppTheme.NoActionBar\"\n            android:exported=\"true\">\n            <intent-filter>\n                <action android:name=\"android.intent.action.MAIN\"/>\n\n                <category android:name=\"android.intent.category.LAUNCHER\"/>\n            </intent-filter>\n        </activity>\n    </application>\n\n</manifest>"
  },
  {
    "path": "deprecated/android/samples/sample-encryptdb/src/main/java/com/tencent/wcdb/sample/encryptdb/EncryptedDBHelper.java",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdb.sample.encryptdb;\n\nimport android.content.Context;\nimport android.util.Log;\n\nimport com.tencent.wcdb.DatabaseUtils;\nimport com.tencent.wcdb.database.SQLiteChangeListener;\nimport com.tencent.wcdb.database.SQLiteDatabase;\nimport com.tencent.wcdb.database.SQLiteOpenHelper;\nimport com.tencent.wcdb.repair.RepairKit;\n\nimport java.io.File;\n\n\npublic class EncryptedDBHelper extends SQLiteOpenHelper {\n\n    private static final String TAG = \"EncryptedDBHelper\";\n\n    private static final String DATABASE_NAME = \"encrypted.db\";\n    private static final String OLD_DATABASE_NAME = \"plain-text.db\";\n    private static final int DATABASE_VERSION = 2;\n\n    private Context mContext;\n    private String mPassphrase;\n\n    public EncryptedDBHelper(Context context, String passphrase) {\n\n        // Call \"encrypted\" version of the superclass constructor.\n        super(context, DATABASE_NAME, passphrase.getBytes(), null, null, DATABASE_VERSION,\n                null);\n\n        // Save context object for later use.\n        mContext = context;\n        mPassphrase = passphrase;\n    }\n\n    @Override\n    public void onCreate(SQLiteDatabase db) {\n        // Check whether old plain-text database exists, if so, export it\n        // to the new, encrypted one.\n        File oldDbFile = mContext.getDatabasePath(OLD_DATABASE_NAME);\n        if (oldDbFile.exists()) {\n\n            Log.i(TAG, \"Migrating plain-text database to encrypted one.\");\n\n            // SQLiteOpenHelper begins a transaction before calling onCreate().\n            // We have to end the transaction before we can attach a new database.\n            db.endTransaction();\n\n            // Attach old database to the newly created, encrypted database.\n            String sql = String.format(\"ATTACH DATABASE %s AS old KEY '';\",\n                    DatabaseUtils.sqlEscapeString(oldDbFile.getPath()));\n            db.execSQL(sql);\n\n            // Export old database.\n            db.beginTransaction();\n            DatabaseUtils.stringForQuery(db, \"SELECT sqlcipher_export('main', 'old');\", null);\n            db.setTransactionSuccessful();\n            db.endTransaction();\n\n            // Get old database version for later upgrading.\n            int oldVersion = (int) DatabaseUtils.longForQuery(db, \"PRAGMA old.user_version;\", null);\n\n            // Detach old database and enter a new transaction.\n            db.execSQL(\"DETACH DATABASE old;\");\n\n            // Old database can be deleted now.\n            oldDbFile.delete();\n\n            // Before further actions, restore the transaction.\n            db.beginTransaction();\n\n            // Check if we need to upgrade the schema.\n            if (oldVersion > DATABASE_VERSION) {\n                onDowngrade(db, oldVersion, DATABASE_VERSION);\n            } else if (oldVersion < DATABASE_VERSION) {\n                onUpgrade(db, oldVersion, DATABASE_VERSION);\n            }\n        } else {\n            Log.i(TAG, \"Creating new encrypted database.\");\n\n            // Do the real initialization if the old database is absent.\n            db.execSQL(\"CREATE TABLE message (content TEXT, \"\n                    + \"sender TEXT);\");\n        }\n\n        // OPTIONAL: backup master info for corruption recovery.\n        RepairKit.MasterInfo.save(db, db.getPath() + \"-mbak\", mPassphrase.getBytes());\n    }\n\n    @Override\n    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {\n\n        Log.i(TAG, String.format(\"Upgrading database from version %d to version %d.\",\n                oldVersion, newVersion));\n\n        // Add new column to message table on database upgrade.\n        db.execSQL(\"ALTER TABLE message ADD COLUMN sender TEXT;\");\n\n        // OPTIONAL: backup master info for corruption recovery.\n        RepairKit.MasterInfo.save(db, db.getPath() + \"-mbak\", mPassphrase.getBytes());\n    }\n\n    @Override\n    public void onConfigure(SQLiteDatabase db) {\n        db.setAsyncCheckpointEnabled(true);\n        db.setChangeListener(new SQLiteChangeListener() {\n\n            private StringBuilder mSB = new StringBuilder();\n            private void printIds(String prefix, long[] ids) {\n                mSB.append(prefix).append(\": \");\n                for (long id : ids) {\n                    mSB.append(id).append(\", \");\n                }\n                Log.i(TAG, mSB.toString());\n                mSB.setLength(0);\n            }\n\n            @Override\n            public void onChange(SQLiteDatabase db, String dbName, String table,\n                    long[] insertIds, long[] updateIds, long[] deleteIds) {\n                Log.i(TAG, \"onChange called: dbName = \" + dbName + \", table = \" + table);\n                printIds(\"INSERT\", insertIds);\n                printIds(\"UPDATE\", updateIds);\n                printIds(\"DELETE\", deleteIds);\n            }\n        }, true);\n    }\n}\n"
  },
  {
    "path": "deprecated/android/samples/sample-encryptdb/src/main/java/com/tencent/wcdb/sample/encryptdb/MainActivity.java",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdb.sample.encryptdb;\n\nimport android.database.Cursor;\nimport android.os.AsyncTask;\nimport android.support.v4.widget.SimpleCursorAdapter;\nimport android.support.v7.app.AppCompatActivity;\nimport android.os.Bundle;\nimport android.view.View;\nimport android.widget.ListView;\n\nimport com.tencent.wcdb.database.SQLiteDatabase;\nimport com.tencent.wcdb.database.SQLiteOpenHelper;\n\nimport java.text.DateFormat;\nimport java.text.SimpleDateFormat;\nimport java.util.Date;\n\npublic class MainActivity extends AppCompatActivity {\n\n    private static final String TAG = \"WCDB.EncryptDBSample\";\n\n    private SQLiteDatabase mDB;\n    private SQLiteOpenHelper mDBHelper;\n    private int mDBVersion;\n\n    private ListView mListView;\n    private SimpleCursorAdapter mAdapter;\n\n\n    @Override\n    protected void onCreate(Bundle savedInstanceState) {\n        super.onCreate(savedInstanceState);\n        setContentView(R.layout.activity_main);\n\n        mListView = (ListView) findViewById(R.id.list);\n        mAdapter = new SimpleCursorAdapter(this, R.layout.main_listitem, null,\n                new String[] {\"content\", \"_id\", \"sender\"},\n                new int[] {R.id.list_tv_content, R.id.list_tv_id, R.id.list_tv_sender},\n                0);\n\n        mListView.setAdapter(mAdapter);\n\n        findViewById(R.id.btn_init_plain).setOnClickListener(new View.OnClickListener() {\n            // Init plain-text button pressed.\n            // Create or open database in version 1, then refresh adapter.\n\n            @Override\n            public void onClick(View v) {\n                new AsyncTask<Void, Void, Cursor>() {\n                    @Override\n                    protected void onPreExecute() {\n                        mAdapter.changeCursor(null);\n                    }\n\n                    @Override\n                    protected Cursor doInBackground(Void... params) {\n                        if (mDBHelper != null && mDB != null && mDB.isOpen()) {\n                            mDBHelper.close();\n                            mDBHelper = null;\n                            mDB = null;\n                        }\n\n                        mDBHelper = new PlainTextDBHelper(MainActivity.this);\n                        mDBHelper.setWriteAheadLoggingEnabled(true);\n                        mDB = mDBHelper.getWritableDatabase();\n                        mDBVersion = mDB.getVersion();\n                        return mDB.rawQuery(\"SELECT rowid as _id, content, '???' as sender FROM message;\",\n                                null);\n                    }\n\n                    @Override\n                    protected void onPostExecute(Cursor cursor) {\n                        mAdapter.changeCursor(cursor);\n                    }\n                }.execute();\n            }\n        });\n\n        findViewById(R.id.btn_init_encrypted).setOnClickListener(new View.OnClickListener() {\n            // Init encrypted button pressed.\n            // Create or open database in version 2, then refresh adapter.\n            // If plain-text database exists and encrypted one does not, transfer all\n            // data from the plain-text database (which in version 1), then upgrade it\n            // to version 2.\n\n            // See EncryptedDBHelper.java for details about data transfer and schema upgrade.\n\n            @Override\n            public void onClick(View v) {\n                new AsyncTask<Void, Void, Cursor>() {\n                    @Override\n                    protected void onPreExecute() {\n                        mAdapter.changeCursor(null);\n                    }\n\n                    @Override\n                    protected Cursor doInBackground(Void... params) {\n                        if (mDBHelper != null && mDB != null && mDB.isOpen()) {\n                            mDBHelper.close();\n                            mDBHelper = null;\n                            mDB = null;\n                        }\n\n                        String passphrase = \"passphrase\";\n                        mDBHelper = new EncryptedDBHelper(MainActivity.this, passphrase);\n                        mDBHelper.setWriteAheadLoggingEnabled(true);\n                        mDB = mDBHelper.getWritableDatabase();\n                        mDBVersion = mDB.getVersion();\n                        return mDB.rawQuery(\"SELECT rowid as _id, content, sender FROM message;\",\n                                null);\n                    }\n\n                    @Override\n                    protected void onPostExecute(Cursor cursor) {\n                        mAdapter.changeCursor(cursor);\n                    }\n                }.execute();\n            }\n        });\n\n        findViewById(R.id.btn_insert).setOnClickListener(new View.OnClickListener() {\n            // Insert button pressed.\n            // Insert a message to the database.\n\n            // To test data transfer, init plain-text database, insert messages,\n            // then init encrypted database.\n\n            final DateFormat DATE_FORMAT = SimpleDateFormat.getDateTimeInstance();\n\n            @Override\n            public void onClick(View v) {\n                new AsyncTask<Void, Void, Cursor>() {\n                    @Override\n                    protected void onPreExecute() {\n                        mAdapter.changeCursor(null);\n                    }\n\n                    @Override\n                    protected Cursor doInBackground(Void... params) {\n                        if (mDB == null || !mDB.isOpen())\n                            return null;\n\n                        String message = \"Message inserted on \" + DATE_FORMAT.format(new Date());\n\n                        if (mDBVersion == 1) {\n                            mDB.execSQL(\"INSERT INTO message VALUES (?);\",\n                                    new Object[]{message});\n                            return mDB.rawQuery(\"SELECT rowid as _id, content, '???' as sender FROM message;\",\n                                    null);\n                        } else {\n                            mDB.execSQL(\"INSERT INTO message VALUES (?, ?);\",\n                                    new Object[]{message, \"Me\"});\n                            return mDB.rawQuery(\"SELECT rowid as _id, content, sender FROM message;\",\n                                    null);\n                        }\n                    }\n\n                    @Override\n                    protected void onPostExecute(Cursor cursor) {\n                        if (cursor == null)\n                            return;\n                        mAdapter.changeCursor(cursor);\n                    }\n                }.execute();\n            }\n        });\n    }\n}\n"
  },
  {
    "path": "deprecated/android/samples/sample-encryptdb/src/main/java/com/tencent/wcdb/sample/encryptdb/PlainTextDBHelper.java",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdb.sample.encryptdb;\n\nimport android.content.Context;\n\nimport com.tencent.wcdb.database.SQLiteDatabase;\nimport com.tencent.wcdb.database.SQLiteOpenHelper;\n\n\npublic class PlainTextDBHelper extends SQLiteOpenHelper {\n\n    private static final String DATABASE_NAME = \"plain-text.db\";\n    private static final int DATABASE_VERSION = 1;\n\n    public PlainTextDBHelper(Context context) {\n\n        // Call \"plain-text\" version of the superclass constructor.\n        super(context, DATABASE_NAME, null, DATABASE_VERSION, null);\n    }\n\n    @Override\n    public void onCreate(SQLiteDatabase db) {\n        db.execSQL(\"CREATE TABLE message (content TEXT);\");\n    }\n\n    @Override\n    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {\n        // Do nothing.\n    }\n}\n"
  },
  {
    "path": "deprecated/android/samples/sample-encryptdb/src/main/res/layout/activity_main.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<LinearLayout\n    xmlns:android=\"http://schemas.android.com/apk/res/android\"\n    android:layout_width=\"match_parent\"\n    android:layout_height=\"match_parent\"\n    android:orientation=\"vertical\">\n\n    <LinearLayout\n        android:layout_width=\"match_parent\"\n        android:layout_height=\"wrap_content\"\n        android:orientation=\"horizontal\">\n\n        <Button\n            android:id=\"@+id/btn_init_plain\"\n            android:layout_width=\"match_parent\"\n            android:layout_height=\"match_parent\"\n            android:layout_weight=\"1\"\n            android:text=\"@string/init_plain_text_db\"/>\n\n        <Button\n            android:id=\"@+id/btn_init_encrypted\"\n            android:layout_width=\"match_parent\"\n            android:layout_height=\"match_parent\"\n            android:layout_weight=\"1\"\n            android:text=\"@string/init_encrypted_db\"/>\n\n        <Button\n            android:id=\"@+id/btn_insert\"\n            android:layout_width=\"match_parent\"\n            android:layout_height=\"match_parent\"\n            android:layout_weight=\"1\"\n            android:text=\"@string/insert_message\"/>\n\n    </LinearLayout>\n\n    <ListView\n        android:id=\"@+id/list\"\n        android:layout_width=\"match_parent\"\n        android:layout_height=\"match_parent\"/>\n\n</LinearLayout>\n"
  },
  {
    "path": "deprecated/android/samples/sample-encryptdb/src/main/res/layout/main_listitem.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<RelativeLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"\n                android:layout_width=\"match_parent\"\n                android:layout_height=\"wrap_content\"\n                android:padding=\"5dp\">\n\n    <TextView\n        android:id=\"@+id/list_tv_sender\"\n        android:layout_width=\"wrap_content\"\n        android:layout_height=\"wrap_content\"\n        android:layout_alignParentLeft=\"true\"\n        android:layout_alignParentStart=\"true\"\n        android:layout_alignParentTop=\"true\"\n        android:textStyle=\"bold\"/>\n\n    <TextView\n        android:id=\"@+id/list_tv_id\"\n        android:layout_width=\"wrap_content\"\n        android:layout_height=\"wrap_content\"\n        android:layout_alignParentRight=\"true\"\n        android:layout_alignParentEnd=\"true\"\n        android:layout_alignParentTop=\"true\"/>\n\n    <TextView\n        android:id=\"@+id/list_tv_content\"\n        android:layout_width=\"wrap_content\"\n        android:layout_height=\"wrap_content\"\n        android:layout_alignParentLeft=\"true\"\n        android:layout_alignParentStart=\"true\"\n        android:layout_alignParentBottom=\"true\"\n        android:layout_marginTop=\"5dp\"/>\n\n</RelativeLayout>\n"
  },
  {
    "path": "deprecated/android/samples/sample-encryptdb/src/main/res/menu/menu_main.xml",
    "content": "<menu xmlns:android=\"http://schemas.android.com/apk/res/android\"\n      xmlns:app=\"http://schemas.android.com/apk/res-auto\"\n      xmlns:tools=\"http://schemas.android.com/tools\"\n      tools:context=\"com.tencent.wcdb.sample.encryptdb.MainActivity\">\n    <item android:id=\"@+id/action_settings\"\n          android:orderInCategory=\"100\"\n          android:title=\"@string/action_settings\"\n          app:showAsAction=\"never\"/>\n</menu>\n"
  },
  {
    "path": "deprecated/android/samples/sample-encryptdb/src/main/res/values/colors.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<resources>\n    <color name=\"colorPrimary\">#3F51B5</color>\n    <color name=\"colorPrimaryDark\">#303F9F</color>\n    <color name=\"colorAccent\">#FF4081</color>\n</resources>\n"
  },
  {
    "path": "deprecated/android/samples/sample-encryptdb/src/main/res/values/dimens.xml",
    "content": "<resources>\n    <dimen name=\"fab_margin\">16dp</dimen>\n</resources>\n"
  },
  {
    "path": "deprecated/android/samples/sample-encryptdb/src/main/res/values/strings.xml",
    "content": "<resources>\n    <string name=\"app_name\">EncryptedDBSample</string>\n    <string name=\"action_settings\">Settings</string>\n    <string name=\"init_plain_text_db\">Init Plain-text DB</string>\n    <string name=\"init_encrypted_db\">Init Encrypted DB</string>\n    <string name=\"insert_message\">Insert Message</string>\n</resources>\n"
  },
  {
    "path": "deprecated/android/samples/sample-encryptdb/src/main/res/values/styles.xml",
    "content": "<resources>\n\n    <!-- Base application theme. -->\n    <style name=\"AppTheme\" parent=\"Theme.AppCompat\">\n        <!-- Customize your theme here. -->\n        <item name=\"colorPrimary\">@color/colorPrimary</item>\n        <item name=\"colorPrimaryDark\">@color/colorPrimaryDark</item>\n        <item name=\"colorAccent\">@color/colorAccent</item>\n    </style>\n    <style name=\"AppTheme.NoActionBar\">\n        <item name=\"windowActionBar\">false</item>\n        <item name=\"windowNoTitle\">true</item>\n    </style>\n    <style name=\"AppTheme.AppBarOverlay\" parent=\"ThemeOverlay.AppCompat.Dark.ActionBar\"/>\n    <style name=\"AppTheme.PopupOverlay\" parent=\"ThemeOverlay.AppCompat.Light\"/>\n\n</resources>\n"
  },
  {
    "path": "deprecated/android/samples/sample-encryptdb/src/test/java/com/tencent/wcdb/sample/encryptdb/ExampleUnitTest.java",
    "content": "package com.tencent.wcdb.sample.encryptdb;\n\nimport org.junit.Test;\n\nimport static org.junit.Assert.*;\n\n/**\n * Example local unit test, which will execute on the development machine (host).\n *\n * @see <a href=\"http://d.android.com/tools/testing\">Testing documentation</a>\n */\npublic class ExampleUnitTest {\n    @Test\n    public void addition_isCorrect() throws Exception {\n        assertEquals(4, 2 + 2);\n    }\n}"
  },
  {
    "path": "deprecated/android/samples/sample-persistence/.gitignore",
    "content": "/build\n"
  },
  {
    "path": "deprecated/android/samples/sample-persistence/build.gradle",
    "content": "apply plugin: 'com.android.application'\n\nandroid {\n    compileSdkVersion 32\n\n    defaultConfig {\n        applicationId \"com.example.wcdb.sample.persistence\"\n        minSdkVersion 14\n        targetSdkVersion 32\n\n        testInstrumentationRunner \"android.support.test.runner.AndroidJUnitRunner\"\n\n    }\n    buildTypes {\n        release {\n            minifyEnabled false\n            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'\n        }\n    }\n}\n\ndependencies {\n    implementation fileTree(dir: 'libs', include: ['*.jar'])\n    androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {\n        exclude group: 'com.android.support', module: 'support-annotations'\n    })\n    implementation 'com.android.support:appcompat-v7:28.0.0'\n    implementation 'com.android.support.constraint:constraint-layout:1.1.0'\n    testImplementation 'junit:junit:4.12'\n\n    implementation project(':wcdb')\n    implementation project(':room')\n    annotationProcessor 'android.arch.persistence.room:compiler:1.1.1'\n}\n"
  },
  {
    "path": "deprecated/android/samples/sample-persistence/proguard-rules.pro",
    "content": "# Add project specific ProGuard rules here.\n# By default, the flags in this file are appended to flags specified\n# in C:\\android\\sdk/tools/proguard/proguard-android.txt\n# You can edit the include path and order by changing the proguardFiles\n# directive in build.gradle.\n#\n# For more details, see\n#   http://developer.android.com/guide/developing/tools/proguard.html\n\n# Add any project specific keep options here:\n\n# If your project uses WebView with JS, uncomment the following\n# and specify the fully qualified class name to the JavaScript interface\n# class:\n#-keepclassmembers class fqcn.of.javascript.interface.for.webview {\n#   public *;\n#}\n\n# Uncomment this to preserve the line number information for\n# debugging stack traces.\n#-keepattributes SourceFile,LineNumberTable\n\n# If you keep the line number information, uncomment this to\n# hide the original source file name.\n#-renamesourcefileattribute SourceFile\n"
  },
  {
    "path": "deprecated/android/samples/sample-persistence/src/androidTest/java/com/example/wcdb/sample/persistence/ExampleInstrumentedTest.java",
    "content": "package com.example.wcdb.sample.persistence;\n\nimport android.content.Context;\nimport android.support.test.InstrumentationRegistry;\nimport android.support.test.runner.AndroidJUnit4;\n\nimport org.junit.Test;\nimport org.junit.runner.RunWith;\n\nimport static org.junit.Assert.*;\n\n/**\n * Instrumentation test, which will execute on an Android device.\n *\n * @see <a href=\"http://d.android.com/tools/testing\">Testing documentation</a>\n */\n@RunWith(AndroidJUnit4.class)\npublic class ExampleInstrumentedTest {\n    @Test\n    public void useAppContext() throws Exception {\n        // Context of the app under test.\n        Context appContext = InstrumentationRegistry.getTargetContext();\n\n        assertEquals(\"com.example.wcdb.sample.persistence\", appContext.getPackageName());\n    }\n}\n"
  },
  {
    "path": "deprecated/android/samples/sample-persistence/src/main/AndroidManifest.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<manifest xmlns:android=\"http://schemas.android.com/apk/res/android\"\n    package=\"com.example.wcdb.sample.persistence\">\n\n    <application android:allowBackup=\"true\" android:icon=\"@mipmap/ic_launcher\"\n        android:label=\"@string/app_name\" android:roundIcon=\"@mipmap/ic_launcher_round\"\n        android:supportsRtl=\"true\" android:theme=\"@style/AppTheme\">\n        <activity android:name=\".MainActivity\"\n            android:exported=\"true\">\n            <intent-filter>\n                <action android:name=\"android.intent.action.MAIN\" />\n\n                <category android:name=\"android.intent.category.LAUNCHER\" />\n            </intent-filter>\n        </activity>\n    </application>\n\n</manifest>"
  },
  {
    "path": "deprecated/android/samples/sample-persistence/src/main/java/com/example/wcdb/sample/persistence/MainActivity.java",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.example.wcdb.sample.persistence;\n\nimport android.arch.persistence.db.SupportSQLiteDatabase;\nimport android.arch.persistence.room.Room;\nimport android.arch.persistence.room.RoomDatabase;\nimport android.support.annotation.NonNull;\nimport android.support.v7.app.AppCompatActivity;\nimport android.os.Bundle;\n\nimport com.example.wcdb.sample.persistence.entity.AppDatabase;\nimport com.example.wcdb.sample.persistence.entity.User;\nimport com.example.wcdb.sample.persistence.entity.UserDao;\nimport com.tencent.wcdb.database.SQLiteCipherSpec;\nimport com.tencent.wcdb.database.SQLiteDatabase;\nimport com.tencent.wcdb.extension.fts.MMFtsTokenizer;\nimport com.tencent.wcdb.room.db.WCDBDatabase;\nimport com.tencent.wcdb.room.db.WCDBOpenHelperFactory;\n\nimport java.util.List;\n\npublic class MainActivity extends AppCompatActivity {\n\n    private static final SQLiteCipherSpec sCipherSpec = new SQLiteCipherSpec()\n            .setPageSize(4096)\n            .setKDFIteration(64000);\n\n    private AppDatabase mAppDB;\n    private UserDao mUsers;\n\n    @Override\n    protected void onCreate(Bundle savedInstanceState) {\n        super.onCreate(savedInstanceState);\n        setContentView(R.layout.activity_main);\n\n        mAppDB = Room.databaseBuilder(this, AppDatabase.class, \"app-db\")\n                .allowMainThreadQueries()\n                .openHelperFactory(new WCDBOpenHelperFactory()\n                    .passphrase(\"passphrase\".getBytes())\n                    .cipherSpec(sCipherSpec)\n                    .writeAheadLoggingEnabled(true)\n                    .asyncCheckpointEnabled(true)\n                )\n                .addCallback(new RoomDatabase.Callback() {\n                    @Override\n                    public void onOpen(@NonNull SupportSQLiteDatabase db) {\n                        SQLiteDatabase realDb = ((WCDBDatabase) db).getInnerDatabase();\n\n                        realDb.addExtension(MMFtsTokenizer.EXTENSION);\n                    }\n                })\n                .build();\n\n        mUsers = mAppDB.userDao();\n\n        User user = new User();\n        user.firstName = \"John\";\n        user.lastName = \"He\";\n        mUsers.insert(user);\n\n        user.firstName = \"Sanhua\";\n        user.lastName = \"Zhang\";\n        mUsers.insert(user);\n\n        List<User> userList = mUsers.getAll();\n    }\n}\n"
  },
  {
    "path": "deprecated/android/samples/sample-persistence/src/main/java/com/example/wcdb/sample/persistence/entity/AppDatabase.java",
    "content": "package com.example.wcdb.sample.persistence.entity;\n\nimport android.arch.persistence.room.Database;\nimport android.arch.persistence.room.RoomDatabase;\n\n/**\n * Created by johnwhe on 2017/7/12.\n */\n\n@Database(entities = {User.class}, version = 1)\npublic abstract class AppDatabase extends RoomDatabase {\n    public abstract UserDao userDao();\n}\n"
  },
  {
    "path": "deprecated/android/samples/sample-persistence/src/main/java/com/example/wcdb/sample/persistence/entity/User.java",
    "content": "package com.example.wcdb.sample.persistence.entity;\n\nimport android.arch.persistence.room.Entity;\nimport android.arch.persistence.room.PrimaryKey;\n\n/**\n * Created by johnwhe on 2017/7/12.\n */\n\n@Entity\npublic class User {\n    @PrimaryKey(autoGenerate = true)\n    public int userId;\n\n    public String firstName;\n    public String lastName;\n}\n"
  },
  {
    "path": "deprecated/android/samples/sample-persistence/src/main/java/com/example/wcdb/sample/persistence/entity/UserDao.java",
    "content": "package com.example.wcdb.sample.persistence.entity;\n\nimport android.arch.persistence.room.Dao;\nimport android.arch.persistence.room.Delete;\nimport android.arch.persistence.room.Insert;\nimport android.arch.persistence.room.Query;\nimport android.arch.persistence.room.Update;\n\nimport java.util.List;\n\n/**\n * Created by johnwhe on 2017/7/12.\n */\n\n@Dao\npublic interface UserDao {\n    @Query(\"SELECT * FROM user\")\n    List<User> getAll();\n\n    @Query(\"SELECT * FROM user WHERE userId = :userId\")\n    User getById(int userId);\n\n    @Insert\n    void insert(User... users);\n\n    @Delete\n    void delete(User user);\n\n    @Update\n    void update(User user);\n}\n"
  },
  {
    "path": "deprecated/android/samples/sample-persistence/src/main/res/layout/activity_main.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<android.support.constraint.ConstraintLayout\n    xmlns:android=\"http://schemas.android.com/apk/res/android\"\n    xmlns:app=\"http://schemas.android.com/apk/res-auto\"\n    xmlns:tools=\"http://schemas.android.com/tools\" android:layout_width=\"match_parent\"\n    android:layout_height=\"match_parent\"\n    tools:context=\"com.example.wcdb.sample.persistence.MainActivity\">\n\n    <TextView android:layout_width=\"wrap_content\" android:layout_height=\"wrap_content\"\n        android:text=\"Hello World!\" app:layout_constraintBottom_toBottomOf=\"parent\"\n        app:layout_constraintLeft_toLeftOf=\"parent\" app:layout_constraintRight_toRightOf=\"parent\"\n        app:layout_constraintTop_toTopOf=\"parent\" />\n\n</android.support.constraint.ConstraintLayout>\n"
  },
  {
    "path": "deprecated/android/samples/sample-persistence/src/main/res/values/colors.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<resources>\n    <color name=\"colorPrimary\">#3F51B5</color>\n    <color name=\"colorPrimaryDark\">#303F9F</color>\n    <color name=\"colorAccent\">#FF4081</color>\n</resources>\n"
  },
  {
    "path": "deprecated/android/samples/sample-persistence/src/main/res/values/strings.xml",
    "content": "<resources>\n    <string name=\"app_name\">PersistenceSample</string>\n</resources>\n"
  },
  {
    "path": "deprecated/android/samples/sample-persistence/src/main/res/values/styles.xml",
    "content": "<resources>\n\n    <!-- Base application theme. -->\n    <style name=\"AppTheme\" parent=\"Theme.AppCompat.Light.DarkActionBar\">\n        <!-- Customize your theme here. -->\n        <item name=\"colorPrimary\">@color/colorPrimary</item>\n        <item name=\"colorPrimaryDark\">@color/colorPrimaryDark</item>\n        <item name=\"colorAccent\">@color/colorAccent</item>\n    </style>\n\n</resources>\n"
  },
  {
    "path": "deprecated/android/samples/sample-persistence/src/test/java/com/example/wcdb/sample/persistence/ExampleUnitTest.java",
    "content": "package com.example.wcdb.sample.persistence;\n\nimport org.junit.Test;\n\nimport static org.junit.Assert.*;\n\n/**\n * Example local unit test, which will execute on the development machine (host).\n *\n * @see <a href=\"http://d.android.com/tools/testing\">Testing documentation</a>\n */\npublic class ExampleUnitTest {\n    @Test\n    public void addition_isCorrect() throws Exception {\n        assertEquals(4, 2 + 2);\n    }\n}"
  },
  {
    "path": "deprecated/android/samples/sample-repairdb/.gitignore",
    "content": "/build\n"
  },
  {
    "path": "deprecated/android/samples/sample-repairdb/build.gradle",
    "content": "apply plugin: 'com.android.application'\n\nandroid {\n    compileSdkVersion 32\n\n    defaultConfig {\n        applicationId \"com.tencent.wcdb.sample.repairdb\"\n        minSdkVersion 14\n        targetSdkVersion 32\n        versionCode 1\n        versionName \"1.0\"\n\n        testInstrumentationRunner \"android.support.test.runner.AndroidJUnitRunner\"\n\n    }\n    buildTypes {\n        release {\n            minifyEnabled false\n            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'\n        }\n    }\n}\n\ndependencies {\n    androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {\n        exclude group: 'com.android.support', module: 'support-annotations'\n    })\n\n    implementation project(':wcdb')\n    implementation 'com.android.support:appcompat-v7:28.0.0'\n    testImplementation 'junit:junit:4.12'\n}\n"
  },
  {
    "path": "deprecated/android/samples/sample-repairdb/proguard-rules.pro",
    "content": "# Add project specific ProGuard rules here.\n# By default, the flags in this file are appended to flags specified\n# in C:\\android\\sdk/tools/proguard/proguard-android.txt\n# You can edit the include path and order by changing the proguardFiles\n# directive in build.gradle.\n#\n# For more details, see\n#   http://developer.android.com/guide/developing/tools/proguard.html\n\n# Add any project specific keep options here:\n\n# If your project uses WebView with JS, uncomment the following\n# and specify the fully qualified class name to the JavaScript interface\n# class:\n#-keepclassmembers class fqcn.of.javascript.interface.for.webview {\n#   public *;\n#}\n\n# Uncomment this to preserve the line number information for\n# debugging stack traces.\n#-keepattributes SourceFile,LineNumberTable\n\n# If you keep the line number information, uncomment this to\n# hide the original source file name.\n#-renamesourcefileattribute SourceFile\n"
  },
  {
    "path": "deprecated/android/samples/sample-repairdb/src/androidTest/java/com/tencent/wcdb/sample/repairdb/ExampleInstrumentedTest.java",
    "content": "package com.tencent.wcdb.sample.repairdb;\n\nimport android.content.Context;\nimport android.support.test.InstrumentationRegistry;\nimport android.support.test.runner.AndroidJUnit4;\n\nimport org.junit.Test;\nimport org.junit.runner.RunWith;\n\nimport static org.junit.Assert.*;\n\n/**\n * Instrumentation test, which will execute on an Android device.\n *\n * @see <a href=\"http://d.android.com/tools/testing\">Testing documentation</a>\n */\n@RunWith(AndroidJUnit4.class)\npublic class ExampleInstrumentedTest {\n    @Test\n    public void useAppContext() throws Exception {\n        // Context of the app under test.\n        Context appContext = InstrumentationRegistry.getTargetContext();\n\n        assertEquals(\"com.tencent.wcdb.sample.repairdb\", appContext.getPackageName());\n    }\n}\n"
  },
  {
    "path": "deprecated/android/samples/sample-repairdb/src/main/AndroidManifest.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<manifest xmlns:android=\"http://schemas.android.com/apk/res/android\"\n          package=\"com.tencent.wcdb.sample.repairdb\">\n\n    <application\n        android:allowBackup=\"true\"\n        android:icon=\"@mipmap/ic_launcher\"\n        android:label=\"@string/app_name\"\n        android:roundIcon=\"@mipmap/ic_launcher_round\"\n        android:supportsRtl=\"true\"\n        android:theme=\"@style/AppTheme\">\n        <activity android:name=\".MainActivity\"\n            android:exported=\"true\">\n            <intent-filter>\n                <action android:name=\"android.intent.action.MAIN\"/>\n\n                <category android:name=\"android.intent.category.LAUNCHER\"/>\n            </intent-filter>\n        </activity>\n    </application>\n\n</manifest>"
  },
  {
    "path": "deprecated/android/samples/sample-repairdb/src/main/java/com/tencent/wcdb/sample/repairdb/DBHelper.java",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdb.sample.repairdb;\n\nimport android.content.Context;\n\nimport com.tencent.wcdb.DatabaseErrorHandler;\nimport com.tencent.wcdb.database.SQLiteCipherSpec;\nimport com.tencent.wcdb.database.SQLiteDatabase;\nimport com.tencent.wcdb.database.SQLiteOpenHelper;\n\n\npublic class DBHelper extends SQLiteOpenHelper {\n\n    static final String DATABASE_NAME = \"test-repair.db\";\n    static final int DATABASE_VERSION = 1;\n\n    static final byte[] PASSPHRASE = \"testkey\".getBytes();\n\n    // The test database is taken from SQLCipher test-suit.\n    //\n    // To be compatible with databases created by the official SQLCipher\n    // library, a SQLiteCipherSpec must be specified with page size of\n    // 1024 bytes.\n    static final SQLiteCipherSpec CIPHER_SPEC = new SQLiteCipherSpec()\n            .setPageSize(1024);\n\n\n    // We don't want corrupted databases get deleted or renamed on this sample,\n    // so use an empty DatabaseErrorHandler.\n    static final DatabaseErrorHandler ERROR_HANDLER = new DatabaseErrorHandler() {\n        @Override\n        public void onCorruption(SQLiteDatabase dbObj) {\n            // Do nothing\n        }\n    };\n\n    public DBHelper(Context context) {\n\n        super(context, DATABASE_NAME, PASSPHRASE, CIPHER_SPEC, null,\n                DATABASE_VERSION, ERROR_HANDLER);\n    }\n\n    @Override\n    public void onCreate(SQLiteDatabase db) {\n        db.execSQL(\"CREATE TABLE t1(a,b);\");\n\n        // OPTIONAL: backup master info for corruption recovery.\n        // However, we want to test recovery feature, so omit backup here.\n\n        //RepairKit.MasterInfo.save(db, db.getPath() + \"-mbak\", PASSPHRASE);\n    }\n\n    @Override\n    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {\n        // Do nothing.\n    }\n}"
  },
  {
    "path": "deprecated/android/samples/sample-repairdb/src/main/java/com/tencent/wcdb/sample/repairdb/MainActivity.java",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdb.sample.repairdb;\n\nimport android.app.Activity;\nimport android.database.Cursor;\nimport android.os.AsyncTask;\nimport android.os.Bundle;\nimport android.util.Log;\nimport android.view.View;\nimport android.widget.Button;\nimport android.widget.ListView;\nimport android.widget.SimpleCursorAdapter;\nimport android.widget.Toast;\n\nimport com.tencent.wcdb.database.SQLiteDatabase;\nimport com.tencent.wcdb.database.SQLiteException;\nimport com.tencent.wcdb.database.SQLiteOpenHelper;\nimport com.tencent.wcdb.repair.RepairKit;\nimport com.tencent.wcdb.support.CancellationSignal;\n\nimport java.io.File;\nimport java.io.FileOutputStream;\nimport java.io.IOException;\nimport java.io.InputStream;\nimport java.io.OutputStream;\nimport java.io.RandomAccessFile;\nimport java.util.Random;\n\npublic class MainActivity extends Activity {\n\n    private static final String TAG = \"WCDB.RepairDBSample\";\n\n    private SQLiteDatabase mDB;\n    private final SQLiteOpenHelper mDBHelper = new DBHelper(this);\n\n    private ListView mListView;\n    private SimpleCursorAdapter mAdapter;\n    private RepairKit mRepair;\n    private CancellationSignal mCancellationSignal;\n    private Button mCancelButton;\n\n\n    @Override\n    protected void onCreate(Bundle savedInstanceState) {\n        super.onCreate(savedInstanceState);\n\n        // Extract test database from assets.\n        new AsyncTask<Void, Void, Void>() {\n            @Override\n            protected Void doInBackground(Void... params) {\n                File dbFile = getDatabasePath(DBHelper.DATABASE_NAME);\n\n                if (!dbFile.exists()) {\n                    dbFile.getParentFile().mkdirs();\n\n                    InputStream in = null;\n                    OutputStream out = null;\n                    try {\n                        byte[] buffer = new byte[1024];\n                        in = getAssets().open(DBHelper.DATABASE_NAME);\n                        out = new FileOutputStream(dbFile);\n                        int len;\n                        while ((len = in.read(buffer)) != -1) {\n                            out.write(buffer, 0, len);\n                        }\n                    } catch (IOException e) {\n                        throw new RuntimeException(e);\n                    } finally {\n                        if (in != null) try { in.close(); } catch (IOException e) {}\n                        if (out != null) try { out.close(); } catch (IOException e) {}\n                    }\n                }\n                return null;\n            }\n        }.execute();\n\n        setContentView(R.layout.activity_main);\n\n        mListView = (ListView) findViewById(R.id.list);\n        mAdapter = new SimpleCursorAdapter(this, R.layout.main_listitem, null,\n                new String[] {\"a\", \"b\"},\n                new int[] {R.id.list_tv_a, R.id.list_tv_b},\n                0);\n\n        mListView.setAdapter(mAdapter);\n\n        findViewById(R.id.btn_init_db).setOnClickListener(new View.OnClickListener() {\n            @Override\n            public void onClick(View v) {\n                new AsyncTask<Void, Void, SQLiteException>() {\n                    @Override\n                    protected void onPreExecute() {\n                        mAdapter.changeCursor(null);\n                    }\n\n                    @Override\n                    protected SQLiteException doInBackground(Void... params) {\n                        if (mDB != null && mDB.isOpen()) {\n                            mDBHelper.close();\n                            mDB = null;\n                        }\n\n                        try {\n                            mDBHelper.setWriteAheadLoggingEnabled(true);\n                            mDB = mDBHelper.getWritableDatabase();\n\n                            // After successfully opened the database, backup its master info.\n                            RepairKit.MasterInfo.save(mDB, mDB.getPath() + \"-mbak\", DBHelper.PASSPHRASE);\n                        } catch (SQLiteException e) {\n                            // Failed to open database, probably due to corruption.\n                            mDB = null;\n                            return e;\n                        }\n\n                        return null;\n                    }\n\n                    @Override\n                    protected void onPostExecute(SQLiteException e) {\n                        if (e == null) {\n                            // Database is successfully opened, query and refresh ListView.\n                            Cursor cursor = mDB.rawQuery(\"SELECT rowid as _id, a, b FROM t1;\",\n                                    null);\n                            mAdapter.changeCursor(cursor);\n\n                            Toast.makeText(MainActivity.this, \"Database is successfully opened.\",\n                                    Toast.LENGTH_SHORT).show();\n                        } else {\n                            // Database could not be opened, show toast.\n                            Toast.makeText(MainActivity.this, \"Database cannot be opened, exception: \"\n                                    + e.getMessage(), Toast.LENGTH_LONG).show();\n                        }\n                    }\n                }.execute();\n            }\n        });\n\n        findViewById(R.id.btn_corrupt_db).setOnClickListener(new View.OnClickListener() {\n            @Override\n            public void onClick(View v) {\n                new AsyncTask<Void, Void, Exception>() {\n                    @Override\n                    protected void onPreExecute() {\n                        mAdapter.changeCursor(null);\n                    }\n\n                    @Override\n                    protected Exception doInBackground(Void... params) {\n                        if (mDB != null && mDB.isOpen()) {\n                            mDBHelper.close();\n                            mDB = null;\n                        }\n\n                        // Write random noise to the first page to corrupt the database.\n                        RandomAccessFile raf = null;\n                        try {\n                            File dbFile = getDatabasePath(DBHelper.DATABASE_NAME);\n                            raf = new RandomAccessFile(dbFile, \"rw\");\n                            byte[] buffer = new byte[1024];\n                            new Random().nextBytes(buffer);\n                            raf.seek(0);\n                            raf.write(buffer);\n                        } catch (IOException e) {\n                            return e;\n                        } finally {\n                            if (raf != null) try { raf.close(); } catch (IOException e) {}\n                        }\n\n                        return null;\n                    }\n\n                    @Override\n                    protected void onPostExecute(Exception e) {\n                        if (e == null) {\n                            Toast.makeText(MainActivity.this, \"Database is now CORRUPTED!\",\n                                    Toast.LENGTH_SHORT).show();\n                        } else {\n                            Toast.makeText(MainActivity.this, \"Unable to overwrite database: \"\n                                    + e.getMessage(), Toast.LENGTH_LONG).show();\n                        }\n                    }\n                }.execute();\n            }\n        });\n\n        mCancelButton = (Button) findViewById(R.id.btn_repair_cancel);\n        findViewById(R.id.btn_repair_db).setOnClickListener(new View.OnClickListener() {\n\n            @Override\n            public void onClick(View v) {\n                new AsyncTask<Void, Void, SQLiteException>() {\n                    @Override\n                    protected void onPreExecute() {\n                        mAdapter.changeCursor(null);\n                        mCancellationSignal = new CancellationSignal();\n                        mCancelButton.setEnabled(true);\n                    }\n\n                    @Override\n                    protected SQLiteException doInBackground(Void... params) {\n                        if (mDB != null && mDB.isOpen()) {\n                            mDBHelper.close();\n                            mDB = null;\n                        }\n\n                        RepairKit.MasterInfo master = null;\n                        File dbFile = getDatabasePath(DBHelper.DATABASE_NAME);\n                        File masterFile = new File(dbFile.getPath() + \"-mbak\");\n                        File newDbFile = getDatabasePath(DBHelper.DATABASE_NAME + \"-recover\");\n\n                        if (masterFile.exists()) {\n                            try {\n                                master = RepairKit.MasterInfo.load(masterFile.getPath(),\n                                        DBHelper.PASSPHRASE, null);\n                            } catch (SQLiteException e) {\n                                // Could not load master info. Maybe backup file itself corrupted?\n                            }\n                        }\n\n                        mRepair = null;\n                        try {\n                            mRepair = new RepairKit(\n                                    dbFile.getPath(),       // corrupted database file\n                                    DBHelper.PASSPHRASE,    // passphrase to the database\n                                    DBHelper.CIPHER_SPEC,   // cipher spec to the database\n                                    master                  // backup master info just loaded\n                            );\n\n                            if (newDbFile.exists())\n                                newDbFile.delete();\n\n                            SQLiteDatabase newDb = SQLiteDatabase.openOrCreateDatabase(newDbFile,\n                                    DBHelper.PASSPHRASE, DBHelper.CIPHER_SPEC, null,\n                                    DBHelper.ERROR_HANDLER);\n                            mRepair.setCallback(new RepairKit.Callback() {\n                                @Override\n                                public int onProgress(String table, int root, Cursor cursor) {\n                                    Log.d(TAG, String.format(\"table: %s, root: %d, count: %d\",\n                                            table, root, cursor.getColumnCount()));\n                                    return RepairKit.RESULT_OK;\n                                }\n                            });\n                            int result = mRepair.output(newDb, 0);\n                            if (result != RepairKit.RESULT_OK && result != RepairKit.RESULT_CANCELED) {\n                                throw new SQLiteException(\"Repair returns failure.\");\n                            }\n\n                            newDb.setVersion(DBHelper.DATABASE_VERSION);\n                            newDb.close();\n                            mRepair.release();\n                            mRepair = null;\n\n                            if (!dbFile.delete() || !newDbFile.renameTo(dbFile))\n                                throw new SQLiteException(\"Cannot rename database.\");\n                        } catch (SQLiteException e) {\n                            return e;\n                        } finally {\n                            if (mRepair != null) {\n                                mRepair.release();\n                                mRepair = null;\n                            }\n                        }\n\n                        return null;\n                    }\n\n                    @Override\n                    protected void onPostExecute(SQLiteException e) {\n                        if (e == null) {\n                            Toast.makeText(MainActivity.this, \"Repair succeeded.\", Toast.LENGTH_SHORT)\n                                    .show();\n                        } else {\n                            Toast.makeText(MainActivity.this, \"Repair failed: \"\n                                    + e.getMessage(), Toast.LENGTH_LONG).show();\n                        }\n\n                        mCancelButton.setEnabled(false);\n                        mCancellationSignal = null;\n                    }\n                }.execute();\n            }\n        });\n\n        mCancelButton.setOnClickListener(new View.OnClickListener() {\n            @Override\n            public void onClick(View v) {\n                if (mCancellationSignal != null) {\n                    mCancellationSignal.cancel();\n                }\n            }\n        });\n    }\n}\n"
  },
  {
    "path": "deprecated/android/samples/sample-repairdb/src/main/res/layout/activity_main.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<LinearLayout\n    xmlns:android=\"http://schemas.android.com/apk/res/android\"\n    android:layout_width=\"match_parent\"\n    android:layout_height=\"match_parent\"\n    android:orientation=\"vertical\">\n\n    <LinearLayout\n        android:layout_width=\"match_parent\"\n        android:layout_height=\"wrap_content\"\n        android:orientation=\"vertical\">\n\n        <LinearLayout\n            android:layout_width=\"match_parent\"\n            android:layout_height=\"wrap_content\"\n            android:orientation=\"horizontal\">\n\n            <Button\n                android:id=\"@+id/btn_init_db\"\n                android:layout_width=\"match_parent\"\n                android:layout_height=\"match_parent\"\n                android:layout_weight=\"1\"\n                android:text=\"@string/init_db\"/>\n\n            <Button\n                android:id=\"@+id/btn_corrupt_db\"\n                android:layout_width=\"match_parent\"\n                android:layout_height=\"match_parent\"\n                android:layout_weight=\"1\"\n                android:text=\"@string/corrupt_db\"/>\n\n        </LinearLayout>\n\n        <LinearLayout\n            android:layout_width=\"match_parent\"\n            android:layout_height=\"wrap_content\"\n            android:orientation=\"horizontal\">\n\n            <Button\n                android:id=\"@+id/btn_repair_db\"\n                android:layout_width=\"match_parent\"\n                android:layout_height=\"match_parent\"\n                android:layout_weight=\"1\"\n                android:text=\"@string/repair_db\"/>\n\n            <Button\n                android:id=\"@+id/btn_repair_cancel\"\n                android:layout_width=\"match_parent\"\n                android:layout_height=\"match_parent\"\n                android:layout_weight=\"1\"\n                android:text=\"@string/cancel\"/>\n\n        </LinearLayout>\n\n    </LinearLayout>\n\n\n    <ListView\n        android:id=\"@+id/list\"\n        android:layout_width=\"match_parent\"\n        android:layout_height=\"match_parent\"/>\n\n</LinearLayout>\n"
  },
  {
    "path": "deprecated/android/samples/sample-repairdb/src/main/res/layout/main_listitem.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<RelativeLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"\n                android:layout_width=\"match_parent\"\n                android:layout_height=\"wrap_content\"\n                android:padding=\"5dp\">\n\n    <TextView\n        android:id=\"@+id/list_tv_a\"\n        android:layout_width=\"wrap_content\"\n        android:layout_height=\"wrap_content\"\n        android:layout_alignParentLeft=\"true\"\n        android:layout_alignParentStart=\"true\"\n        android:layout_centerVertical=\"true\"\n        android:textStyle=\"bold\"/>\n\n    <TextView\n        android:id=\"@+id/list_tv_b\"\n        android:layout_width=\"wrap_content\"\n        android:layout_height=\"wrap_content\"\n        android:layout_alignParentRight=\"true\"\n        android:layout_alignParentEnd=\"true\"\n        android:layout_centerVertical=\"true\"/>\n\n</RelativeLayout>\n"
  },
  {
    "path": "deprecated/android/samples/sample-repairdb/src/main/res/values/colors.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<resources>\n    <color name=\"colorPrimary\">#3F51B5</color>\n    <color name=\"colorPrimaryDark\">#303F9F</color>\n    <color name=\"colorAccent\">#FF4081</color>\n</resources>\n"
  },
  {
    "path": "deprecated/android/samples/sample-repairdb/src/main/res/values/strings.xml",
    "content": "<resources>\n    <string name=\"app_name\">RepairDBSample</string>\n    <string name=\"init_db\">Init</string>\n    <string name=\"corrupt_db\">Corrupt!</string>\n    <string name=\"repair_db\">Repair</string>\n    <string name=\"cancel\">Cancel</string>\n</resources>\n"
  },
  {
    "path": "deprecated/android/samples/sample-repairdb/src/main/res/values/styles.xml",
    "content": "<resources>\n\n    <!-- Base application theme. -->\n    <style name=\"AppTheme\" parent=\"Theme.AppCompat.Light\">\n        <!-- Customize your theme here. -->\n        <item name=\"colorPrimary\">@color/colorPrimary</item>\n        <item name=\"colorPrimaryDark\">@color/colorPrimaryDark</item>\n        <item name=\"colorAccent\">@color/colorAccent</item>\n    </style>\n\n</resources>\n"
  },
  {
    "path": "deprecated/android/samples/sample-repairdb/src/test/java/com/tencent/wcdb/sample/repairdb/ExampleUnitTest.java",
    "content": "package com.tencent.wcdb.sample.repairdb;\n\nimport org.junit.Test;\n\nimport static org.junit.Assert.*;\n\n/**\n * Example local unit test, which will execute on the development machine (host).\n *\n * @see <a href=\"http://d.android.com/tools/testing\">Testing documentation</a>\n */\npublic class ExampleUnitTest {\n    @Test\n    public void addition_isCorrect() throws Exception {\n        assertEquals(4, 2 + 2);\n    }\n}"
  },
  {
    "path": "deprecated/android/samples/sample-room-with-a-view/.gitignore",
    "content": "/build\n"
  },
  {
    "path": "deprecated/android/samples/sample-room-with-a-view/LICENSE",
    "content": "Apache License\n--------------\n\n                           Version 2.0, January 2004\n                        http://www.apache.org/licenses/\n\n   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION\n\n   1. Definitions.\n\n      \"License\" shall mean the terms and conditions for use, reproduction,\n      and distribution as defined by Sections 1 through 9 of this document.\n\n      \"Licensor\" shall mean the copyright owner or entity authorized by\n      the copyright owner that is granting the License.\n\n      \"Legal Entity\" shall mean the union of the acting entity and all\n      other entities that control, are controlled by, or are under common\n      control with that entity. For the purposes of this definition,\n      \"control\" means (i) the power, direct or indirect, to cause the\n      direction or management of such entity, whether by contract or\n      otherwise, or (ii) ownership of fifty percent (50%) or more of the\n      outstanding shares, or (iii) beneficial ownership of such entity.\n\n      \"You\" (or \"Your\") shall mean an individual or Legal Entity\n      exercising permissions granted by this License.\n\n      \"Source\" form shall mean the preferred form for making modifications,\n      including but not limited to software source code, documentation\n      source, and configuration files.\n\n      \"Object\" form shall mean any form resulting from mechanical\n      transformation or translation of a Source form, including but\n      not limited to compiled object code, generated documentation,\n      and conversions to other media types.\n\n      \"Work\" shall mean the work of authorship, whether in Source or\n      Object form, made available under the License, as indicated by a\n      copyright notice that is included in or attached to the work\n      (an example is provided in the Appendix below).\n\n      \"Derivative Works\" shall mean any work, whether in Source or Object\n      form, that is based on (or derived from) the Work and for which the\n      editorial revisions, annotations, elaborations, or other modifications\n      represent, as a whole, an original work of authorship. For the purposes\n      of this License, Derivative Works shall not include works that remain\n      separable from, or merely link (or bind by name) to the interfaces of,\n      the Work and Derivative Works thereof.\n\n      \"Contribution\" shall mean any work of authorship, including\n      the original version of the Work and any modifications or additions\n      to that Work or Derivative Works thereof, that is intentionally\n      submitted to Licensor for inclusion in the Work by the copyright owner\n      or by an individual or Legal Entity authorized to submit on behalf of\n      the copyright owner. For the purposes of this definition, \"submitted\"\n      means any form of electronic, verbal, or written communication sent\n      to the Licensor or its representatives, including but not limited to\n      communication on electronic mailing lists, source code control systems,\n      and issue tracking systems that are managed by, or on behalf of, the\n      Licensor for the purpose of discussing and improving the Work, but\n      excluding communication that is conspicuously marked or otherwise\n      designated in writing by the copyright owner as \"Not a Contribution.\"\n\n      \"Contributor\" shall mean Licensor and any individual or Legal Entity\n      on behalf of whom a Contribution has been received by Licensor and\n      subsequently incorporated within the Work.\n\n   2. Grant of Copyright License. Subject to the terms and conditions of\n      this License, each Contributor hereby grants to You a perpetual,\n      worldwide, non-exclusive, no-charge, royalty-free, irrevocable\n      copyright license to reproduce, prepare Derivative Works of,\n      publicly display, publicly perform, sublicense, and distribute the\n      Work and such Derivative Works in Source or Object form.\n\n   3. Grant of Patent License. Subject to the terms and conditions of\n      this License, each Contributor hereby grants to You a perpetual,\n      worldwide, non-exclusive, no-charge, royalty-free, irrevocable\n      (except as stated in this section) patent license to make, have made,\n      use, offer to sell, sell, import, and otherwise transfer the Work,\n      where such license applies only to those patent claims licensable\n      by such Contributor that are necessarily infringed by their\n      Contribution(s) alone or by combination of their Contribution(s)\n      with the Work to which such Contribution(s) was submitted. If You\n      institute patent litigation against any entity (including a\n      cross-claim or counterclaim in a lawsuit) alleging that the Work\n      or a Contribution incorporated within the Work constitutes direct\n      or contributory patent infringement, then any patent licenses\n      granted to You under this License for that Work shall terminate\n      as of the date such litigation is filed.\n\n   4. Redistribution. You may reproduce and distribute copies of the\n      Work or Derivative Works thereof in any medium, with or without\n      modifications, and in Source or Object form, provided that You\n      meet the following conditions:\n\n      (a) You must give any other recipients of the Work or\n          Derivative Works a copy of this License; and\n\n      (b) You must cause any modified files to carry prominent notices\n          stating that You changed the files; and\n\n      (c) You must retain, in the Source form of any Derivative Works\n          that You distribute, all copyright, patent, trademark, and\n          attribution notices from the Source form of the Work,\n          excluding those notices that do not pertain to any part of\n          the Derivative Works; and\n\n      (d) If the Work includes a \"NOTICE\" text file as part of its\n          distribution, then any Derivative Works that You distribute must\n          include a readable copy of the attribution notices contained\n          within such NOTICE file, excluding those notices that do not\n          pertain to any part of the Derivative Works, in at least one\n          of the following places: within a NOTICE text file distributed\n          as part of the Derivative Works; within the Source form or\n          documentation, if provided along with the Derivative Works; or,\n          within a display generated by the Derivative Works, if and\n          wherever such third-party notices normally appear. The contents\n          of the NOTICE file are for informational purposes only and\n          do not modify the License. You may add Your own attribution\n          notices within Derivative Works that You distribute, alongside\n          or as an addendum to the NOTICE text from the Work, provided\n          that such additional attribution notices cannot be construed\n          as modifying the License.\n\n      You may add Your own copyright statement to Your modifications and\n      may provide additional or different license terms and conditions\n      for use, reproduction, or distribution of Your modifications, or\n      for any such Derivative Works as a whole, provided Your use,\n      reproduction, and distribution of the Work otherwise complies with\n      the conditions stated in this License.\n\n   5. Submission of Contributions. Unless You explicitly state otherwise,\n      any Contribution intentionally submitted for inclusion in the Work\n      by You to the Licensor shall be under the terms and conditions of\n      this License, without any additional terms or conditions.\n      Notwithstanding the above, nothing herein shall supersede or modify\n      the terms of any separate license agreement you may have executed\n      with Licensor regarding such Contributions.\n\n   6. Trademarks. This License does not grant permission to use the trade\n      names, trademarks, service marks, or product names of the Licensor,\n      except as required for reasonable and customary use in describing the\n      origin of the Work and reproducing the content of the NOTICE file.\n\n   7. Disclaimer of Warranty. Unless required by applicable law or\n      agreed to in writing, Licensor provides the Work (and each\n      Contributor provides its Contributions) on an \"AS IS\" BASIS,\n      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or\n      implied, including, without limitation, any warranties or conditions\n      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A\n      PARTICULAR PURPOSE. You are solely responsible for determining the\n      appropriateness of using or redistributing the Work and assume any\n      risks associated with Your exercise of permissions under this License.\n\n   8. Limitation of Liability. In no event and under no legal theory,\n      whether in tort (including negligence), contract, or otherwise,\n      unless required by applicable law (such as deliberate and grossly\n      negligent acts) or agreed to in writing, shall any Contributor be\n      liable to You for damages, including any direct, indirect, special,\n      incidental, or consequential damages of any character arising as a\n      result of this License or out of the use or inability to use the\n      Work (including but not limited to damages for loss of goodwill,\n      work stoppage, computer failure or malfunction, or any and all\n      other commercial damages or losses), even if such Contributor\n      has been advised of the possibility of such damages.\n\n   9. Accepting Warranty or Additional Liability. While redistributing\n      the Work or Derivative Works thereof, You may choose to offer,\n      and charge a fee for, acceptance of support, warranty, indemnity,\n      or other liability obligations and/or rights consistent with this\n      License. However, in accepting such obligations, You may act only\n      on Your own behalf and on Your sole responsibility, not on behalf\n      of any other Contributor, and only if You agree to indemnify,\n      defend, and hold each Contributor harmless for any liability\n      incurred by, or claims asserted against, such Contributor by reason\n      of your accepting any such warranty or additional liability.\n\n   END OF TERMS AND CONDITIONS\n\n   APPENDIX: How to apply the Apache License to your work.\n\n      To apply the Apache License to your work, attach the following\n      boilerplate notice, with the fields enclosed by brackets \"{}\"\n      replaced with your own identifying information. (Don't include\n      the brackets!)  The text should be enclosed in the appropriate\n      comment syntax for the file format. We also recommend that a\n      file or class name and description of purpose be included on the\n      same \"printed page\" as the copyright notice for easier\n      identification within third-party archives.\n\n   Copyright {yyyy} {name of copyright owner}\n\n   Licensed under the Apache License, Version 2.0 (the \"License\");\n   you may not use this file except in compliance with the License.\n   You may obtain a copy of the License at\n\n       http://www.apache.org/licenses/LICENSE-2.0\n\n   Unless required by applicable law or agreed to in writing, software\n   distributed under the License is distributed on an \"AS IS\" BASIS,\n   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n   See the License for the specific language governing permissions and\n   limitations under the License.\n"
  },
  {
    "path": "deprecated/android/samples/sample-room-with-a-view/README.md",
    "content": "RoomWordsSample\n================\n\nThis repository contains the finished sample code for the\n[Architecture Components codelab](https://codelabs.developers.google.com/codelabs/android-room-with-a-view/index.html?index=..%2F..%2Findex#0) in Java on the master branch and in Kotlin for the [Architecture Components Kotlin codelab](https://codelabs.developers.google.com/codelabs/android-room-with-a-view-kotlin) on the [kotlin](https://github.com/googlecodelabs/android-room-with-a-view/tree/kotlin) branch.\n\nIntroduction\n------------\n\nIn May 2017 Google released the Architecture Components libraries.\nEach library manages and simplifies aspects of data persistence and the\nUI component lifecycle. Together, the libraries encourage a modular\napp architecture that results in reduced complexity and less code.\n\nThis sample shows how to use the libraries to build\na complete basic app that implements the recommended architecture\nand can be used as a template for further explorations.\n\n\nPre-requisites\n--------------\n\n* Android Studio 3.0 or later and you know how to use it.\n\n* Make sure Android Studio is updated, as well as your SDK and Gradle.\nOtherwise, you may have to wait for a while until all the updates are done.\n\n* A device or emulator that runs API level 26\n\nYou need to be solidly familiar with the Java programming language,\nobject-oriented design concepts, and Android Development Fundamentals.\nIn particular:\n\n* RecyclerView and Adapters\n* SQLite database and the SQLite query language\n* Threading and AsyncTask\n* It helps to be familiar with software architectural patterns that separate\n  data from the user interface, such as MVP or MVC. This codelab implements the\n  architecture defined in the\n  [Guide to App Architecture](\n  https://developer.android.com/topic/libraries/architecture/guide.html)\n\nGetting Started\n---------------\n\n1. [Install Android Studio](https://developer.android.com/studio/install.html),\nif you don't already have it.\n2. Download the sample.\n2. Import the sample into Android Studio.\n3. Build and run the sample.\n\nLicense\n-------\n\nCopyright 2017 Google, Inc.\n\nAll image and audio files (including *.png, *.jpg, *.svg, *.mp3, *.wav\nand *.ogg) are licensed under the CC BY 4.0 license. All other files are\nlicensed under the Apache 2 license.\n\nLicensed to the Apache Software Foundation (ASF) under one or more contributor\nlicense agreements.  See the LICENSE file distributed with this work for\nadditional information regarding copyright ownership.  The ASF licenses this\nfile to you under the Apache License, Version 2.0 (the \"License\"); you may not\nuse this file except in compliance with the License.  You may obtain a copy of\nthe License at\n\n  http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\nWARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the\nLicense for the specific language governing permissions and limitations under\nthe License.\n"
  },
  {
    "path": "deprecated/android/samples/sample-room-with-a-view/build.gradle",
    "content": "apply plugin: 'com.android.application'\n\nandroid {\n    compileSdkVersion 32\n    defaultConfig {\n        applicationId \"com.example.android.roomwordssample\"\n        minSdkVersion 20\n        targetSdkVersion 32\n        versionCode 1\n        versionName \"1.0\"\n        testInstrumentationRunner \"android.support.test.runner.AndroidJUnitRunner\"\n    }\n    buildTypes {\n        release {\n            minifyEnabled false\n            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'\n        }\n    }\n\n    defaultConfig {\n        javaCompileOptions {\n            annotationProcessorOptions {\n                arguments = ['room.schemaLocation': \"${project.buildDir}/outputs/schema.txt\".toString()]\n            }\n        }\n    }\n}\ndependencies {\n    implementation fileTree(dir: 'libs', include: ['*.jar'])\n    implementation 'com.android.support:appcompat-v7:28.0.0'\n    implementation 'com.android.support.constraint:constraint-layout:1.1.0'\n    implementation 'com.android.support:design:28.0.0'\n\n    // Dependencies for working with Architecture components\n    // You'll probably have to update the version numbers in guild.gradle (Project)\n\n    implementation project(':room')\n    // implementation 'com.tencent.wcdb:room:1.0.8'\n\n    annotationProcessor \"android.arch.persistence.room:compiler:1.1.1\"\n    androidTestImplementation \"android.arch.persistence.room:testing:1.1.1\"\n\n    implementation \"android.arch.lifecycle:extensions:1.1.1\"\n    annotationProcessor \"android.arch.lifecycle:compiler:1.1.1\"\n\n    testImplementation 'junit:junit:4.12'\n    androidTestImplementation \"android.arch.core:core-testing:1.1.1\"\n    androidTestImplementation ('com.android.support.test.espresso:espresso-core:3.0.1', {\n        exclude group: 'com.android.support', module: 'support-annotations'\n    })\n}\n"
  },
  {
    "path": "deprecated/android/samples/sample-room-with-a-view/proguard-rules.pro",
    "content": "# Add project specific ProGuard rules here.\n# You can control the set of applied configuration files using the\n# proguardFiles setting in build.gradle.\n#\n# For more details, see\n#   http://developer.android.com/guide/developing/tools/proguard.html\n\n# If your project uses WebView with JS, uncomment the following\n# and specify the fully qualified class name to the JavaScript interface\n# class:\n#-keepclassmembers class fqcn.of.javascript.interface.for.webview {\n#   public *;\n#}\n\n# Uncomment this to preserve the line number information for\n# debugging stack traces.\n#-keepattributes SourceFile,LineNumberTable\n\n# If you keep the line number information, uncomment this to\n# hide the original source file name.\n#-renamesourcefileattribute SourceFile\n"
  },
  {
    "path": "deprecated/android/samples/sample-room-with-a-view/src/androidTest/java/com/example/android/roomwordssample/LiveDataTestUtil.java",
    "content": "package com.example.android.roomwordssample;\n/*\n * Copyright (C) 2017 The Android Open Source Project\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport android.arch.lifecycle.LiveData;\nimport android.arch.lifecycle.Observer;\nimport android.support.annotation.Nullable;\n\nimport java.util.concurrent.CountDownLatch;\nimport java.util.concurrent.TimeUnit;\n\npublic class LiveDataTestUtil {\n\n    /**\n     * Get the value from a LiveData object. We're waiting for LiveData to emit, for 2 seconds.\n     * Once we got a notification via onChanged, we stop observing.\n     */\n    public static <T> T getValue(final LiveData<T> liveData) throws InterruptedException {\n        final Object[] data = new Object[1];\n        final CountDownLatch latch = new CountDownLatch(1);\n        Observer<T> observer = new Observer<T>() {\n            @Override\n            public void onChanged(@Nullable T o) {\n                data[0] = o;\n                latch.countDown();\n                liveData.removeObserver(this);\n            }\n        };\n        liveData.observeForever(observer);\n        latch.await(2, TimeUnit.SECONDS);\n        //noinspection unchecked\n        return (T) data[0];\n    }\n}"
  },
  {
    "path": "deprecated/android/samples/sample-room-with-a-view/src/androidTest/java/com/example/android/roomwordssample/WordDaoTest.java",
    "content": "package com.example.android.roomwordssample;\n\n/*\n * Copyright (C) 2017 Google Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport android.arch.core.executor.testing.InstantTaskExecutorRule;\nimport android.arch.persistence.room.Room;\nimport android.content.Context;\nimport android.support.test.InstrumentationRegistry;\nimport android.support.test.runner.AndroidJUnit4;\n\nimport org.junit.After;\nimport org.junit.Before;\nimport org.junit.Rule;\nimport org.junit.Test;\nimport org.junit.runner.RunWith;\n\nimport java.io.IOException;\nimport java.util.List;\n\nimport static junit.framework.Assert.assertEquals;\nimport static junit.framework.Assert.assertTrue;\n\n\n/**\n * This is not meant to be a full set of tests. For simplicity, most of your samples do not\n * include tests. However, when building the Room, it is helpful to make sure it works before\n * adding the UI.\n */\n\n@RunWith(AndroidJUnit4.class)\npublic class WordDaoTest {\n\n    @Rule\n    public InstantTaskExecutorRule instantTaskExecutorRule = new InstantTaskExecutorRule();\n\n    private WordDao mWordDao;\n    private WordRoomDatabase mDb;\n\n    @Before\n    public void createDb() {\n        Context context = InstrumentationRegistry.getTargetContext();\n        // Using an in-memory database because the information stored here disappears when the\n        // process is killed.\n        mDb = Room.inMemoryDatabaseBuilder(context, WordRoomDatabase.class)\n                // Allowing main thread queries, just for testing.\n                .allowMainThreadQueries()\n                .build();\n        mWordDao = mDb.wordDao();\n    }\n\n    @After\n    public void closeDb() {\n        mDb.close();\n    }\n\n    @Test\n    public void insertAndGetWord() throws Exception {\n        Word word = new Word(\"word\");\n        mWordDao.insert(word);\n        List<Word> allWords = LiveDataTestUtil.getValue(mWordDao.getAlphabetizedWords());\n        assertEquals(allWords.get(0).getWord(), word.getWord());\n    }\n\n    @Test\n    public void getAllWords() throws Exception {\n        Word word = new Word(\"aaa\");\n        mWordDao.insert(word);\n        Word word2 = new Word(\"bbb\");\n        mWordDao.insert(word2);\n        List<Word> allWords = LiveDataTestUtil.getValue(mWordDao.getAlphabetizedWords());\n        assertEquals(allWords.get(0).getWord(), word.getWord());\n        assertEquals(allWords.get(1).getWord(), word2.getWord());\n    }\n\n    @Test\n    public void deleteAll() throws Exception {\n        Word word = new Word(\"word\");\n        mWordDao.insert(word);\n        Word word2 = new Word(\"word2\");\n        mWordDao.insert(word2);\n        mWordDao.deleteAll();\n        List<Word> allWords = LiveDataTestUtil.getValue(mWordDao.getAlphabetizedWords());\n        assertTrue(allWords.isEmpty());\n    }\n}\n"
  },
  {
    "path": "deprecated/android/samples/sample-room-with-a-view/src/main/AndroidManifest.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<manifest xmlns:android=\"http://schemas.android.com/apk/res/android\"\n    package=\"com.example.android.roomwordssample\">\n\n    <application\n        android:allowBackup=\"true\"\n        android:icon=\"@mipmap/ic_launcher\"\n        android:label=\"@string/app_name\"\n        android:roundIcon=\"@mipmap/ic_launcher_round\"\n        android:supportsRtl=\"true\"\n        android:theme=\"@style/AppTheme\">\n        <activity\n            android:name=\".MainActivity\"\n            android:label=\"@string/app_name\"\n            android:theme=\"@style/AppTheme.NoActionBar\"\n            android:exported=\"true\">\n            <intent-filter>\n                <action android:name=\"android.intent.action.MAIN\" />\n\n                <category android:name=\"android.intent.category.LAUNCHER\" />\n            </intent-filter>\n        </activity>\n        <activity android:name=\".NewWordActivity\"></activity>\n    </application>\n\n</manifest>"
  },
  {
    "path": "deprecated/android/samples/sample-room-with-a-view/src/main/java/com/example/android/roomwordssample/MainActivity.java",
    "content": "package com.example.android.roomwordssample;\n\n/*\n * Copyright (C) 2017 Google Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport android.arch.lifecycle.Observer;\nimport android.arch.lifecycle.ViewModelProviders;\nimport android.content.Intent;\nimport android.os.Bundle;\nimport android.support.annotation.Nullable;\nimport android.support.design.widget.FloatingActionButton;\nimport android.support.v7.app.AppCompatActivity;\nimport android.support.v7.widget.LinearLayoutManager;\nimport android.support.v7.widget.RecyclerView;\nimport android.support.v7.widget.Toolbar;\nimport android.view.View;\nimport android.widget.Toast;\n\nimport java.util.List;\n\n\npublic class MainActivity extends AppCompatActivity {\n\n    public static final int NEW_WORD_ACTIVITY_REQUEST_CODE = 1;\n\n    private WordViewModel mWordViewModel;\n\n    @Override\n    protected void onCreate(Bundle savedInstanceState) {\n        super.onCreate(savedInstanceState);\n        setContentView(R.layout.activity_main);\n\n        Toolbar toolbar = findViewById(R.id.toolbar);\n        setSupportActionBar(toolbar);\n\n        RecyclerView recyclerView = findViewById(R.id.recyclerview);\n        final WordListAdapter adapter = new WordListAdapter(this);\n        recyclerView.setAdapter(adapter);\n        recyclerView.setLayoutManager(new LinearLayoutManager(this));\n\n        // Get a new or existing ViewModel from the ViewModelProvider.\n        mWordViewModel = ViewModelProviders.of(this).get(WordViewModel.class);\n\n        // Add an observer on the LiveData returned by getAlphabetizedWords.\n        // The onChanged() method fires when the observed data changes and the activity is\n        // in the foreground.\n        mWordViewModel.getAllWords().observe(this, new Observer<List<Word>>() {\n            @Override\n            public void onChanged(@Nullable final List<Word> words) {\n                // Update the cached copy of the words in the adapter.\n                adapter.setWords(words);\n            }\n        });\n\n        FloatingActionButton fab = findViewById(R.id.fab);\n        fab.setOnClickListener(new View.OnClickListener() {\n            @Override\n            public void onClick(View view) {\n                Intent intent = new Intent(MainActivity.this, NewWordActivity.class);\n                startActivityForResult(intent, NEW_WORD_ACTIVITY_REQUEST_CODE);\n            }\n        });\n    }\n\n    public void onActivityResult(int requestCode, int resultCode, Intent data) {\n        super.onActivityResult(requestCode, resultCode, data);\n\n        if (requestCode == NEW_WORD_ACTIVITY_REQUEST_CODE && resultCode == RESULT_OK) {\n            Word word = new Word(data.getStringExtra(NewWordActivity.EXTRA_REPLY));\n            mWordViewModel.insert(word);\n        } else {\n            Toast.makeText(\n                    getApplicationContext(),\n                    R.string.empty_not_saved,\n                    Toast.LENGTH_LONG).show();\n        }\n    }\n}\n"
  },
  {
    "path": "deprecated/android/samples/sample-room-with-a-view/src/main/java/com/example/android/roomwordssample/NewWordActivity.java",
    "content": "package com.example.android.roomwordssample;\n\n/*\n * Copyright (C) 2017 Google Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport android.content.Intent;\nimport android.os.Bundle;\nimport android.support.v7.app.AppCompatActivity;\nimport android.text.TextUtils;\nimport android.view.View;\nimport android.widget.Button;\nimport android.widget.EditText;\n\n/**\n * Activity for entering a word.\n */\n\npublic class NewWordActivity extends AppCompatActivity {\n\n    public static final String EXTRA_REPLY = \"com.example.android.wordlistsql.REPLY\";\n\n    private EditText mEditWordView;\n\n    @Override\n    public void onCreate(Bundle savedInstanceState) {\n        super.onCreate(savedInstanceState);\n        setContentView(R.layout.activity_new_word);\n        mEditWordView = findViewById(R.id.edit_word);\n\n        final Button button = findViewById(R.id.button_save);\n        button.setOnClickListener(new View.OnClickListener() {\n            public void onClick(View view) {\n                Intent replyIntent = new Intent();\n                if (TextUtils.isEmpty(mEditWordView.getText())) {\n                    setResult(RESULT_CANCELED, replyIntent);\n                } else {\n                    String word = mEditWordView.getText().toString();\n                    replyIntent.putExtra(EXTRA_REPLY, word);\n                    setResult(RESULT_OK, replyIntent);\n                }\n                finish();\n            }\n        });\n    }\n}\n\n"
  },
  {
    "path": "deprecated/android/samples/sample-room-with-a-view/src/main/java/com/example/android/roomwordssample/Word.java",
    "content": "package com.example.android.roomwordssample;\n\n/*\n * Copyright (C) 2017 Google Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport android.arch.persistence.room.ColumnInfo;\nimport android.arch.persistence.room.Entity;\nimport android.arch.persistence.room.PrimaryKey;\nimport android.support.annotation.NonNull;\n\n/**\n * A basic class representing an entity that is a row in a one-column database table.\n *\n * @ Entity - You must annotate the class as an entity and supply a table name if not class name.\n * @ PrimaryKey - You must identify the primary key.\n * @ ColumnInfo - You must supply the column name if it is different from the variable name.\n *\n * See the documentation for the full rich set of annotations.\n * https://developer.android.com/topic/libraries/architecture/room.html\n */\n\n@Entity(tableName = \"word_table\")\npublic class Word {\n\n    @PrimaryKey\n    @NonNull\n    @ColumnInfo(name = \"word\")\n    private String mWord;\n\n    public Word(@NonNull String word) {\n        this.mWord = word;\n    }\n\n    @NonNull\n    public String getWord() {\n        return this.mWord;\n    }\n}"
  },
  {
    "path": "deprecated/android/samples/sample-room-with-a-view/src/main/java/com/example/android/roomwordssample/WordDao.java",
    "content": "package com.example.android.roomwordssample;\n\n/*\n * Copyright (C) 2017 Google Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport android.arch.lifecycle.LiveData;\nimport android.arch.persistence.room.Dao;\nimport android.arch.persistence.room.Insert;\nimport android.arch.persistence.room.Query;\n\nimport java.util.List;\n\n/**\n * The Room Magic is in this file, where you map a Java method call to an SQL query.\n *\n * When you are using complex data types, such as Date, you have to also supply type converters.\n * To keep this example basic, no types that require type converters are used.\n * See the documentation at\n * https://developer.android.com/topic/libraries/architecture/room.html#type-converters\n */\n\n@Dao\npublic interface WordDao {\n\n    // LiveData is a data holder class that can be observed within a given lifecycle.\n    // Always holds/caches latest version of data. Notifies its active observers when the\n    // data has changed. Since we are getting all the contents of the database,\n    // we are notified whenever any of the database contents have changed.\n    @Query(\"SELECT * from word_table ORDER BY word ASC\")\n    LiveData<List<Word>> getAlphabetizedWords();\n\n    // We do not need a conflict strategy, because the word is our primary key, and you cannot\n    // add two items with the same primary key to the database. If the table has more than one\n    // column, you can use @Insert(onConflict = OnConflictStrategy.REPLACE) to update a row.\n    @Insert\n    void insert(Word word);\n\n    @Query(\"DELETE FROM word_table\")\n    void deleteAll();\n}\n"
  },
  {
    "path": "deprecated/android/samples/sample-room-with-a-view/src/main/java/com/example/android/roomwordssample/WordListAdapter.java",
    "content": "package com.example.android.roomwordssample;\n\n/*\n * Copyright (C) 2017 Google Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport android.content.Context;\nimport android.support.v7.widget.RecyclerView;\nimport android.view.LayoutInflater;\nimport android.view.View;\nimport android.view.ViewGroup;\nimport android.widget.TextView;\n\nimport java.util.Collections;\nimport java.util.List;\n\n\npublic class WordListAdapter extends RecyclerView.Adapter<WordListAdapter.WordViewHolder> {\n\n    class WordViewHolder extends RecyclerView.ViewHolder {\n        private final TextView wordItemView;\n\n        private WordViewHolder(View itemView) {\n            super(itemView);\n            wordItemView = itemView.findViewById(R.id.textView);\n        }\n    }\n\n    private final LayoutInflater mInflater;\n    private List<Word> mWords = Collections.emptyList(); // Cached copy of words\n\n    WordListAdapter(Context context) {\n        mInflater = LayoutInflater.from(context);\n    }\n\n    @Override\n    public WordViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {\n        View itemView = mInflater.inflate(R.layout.recyclerview_item, parent, false);\n        return new WordViewHolder(itemView);\n    }\n\n    @Override\n    public void onBindViewHolder(WordViewHolder holder, int position) {\n        Word current = mWords.get(position);\n        holder.wordItemView.setText(current.getWord());\n    }\n\n    void setWords(List<Word> words) {\n        mWords = words;\n        notifyDataSetChanged();\n    }\n\n    @Override\n    public int getItemCount() {\n        return mWords.size();\n    }\n}\n\n\n"
  },
  {
    "path": "deprecated/android/samples/sample-room-with-a-view/src/main/java/com/example/android/roomwordssample/WordRepository.java",
    "content": "package com.example.android.roomwordssample;\n\n/*\n * Copyright (C) 2017 Google Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport android.app.Application;\nimport android.arch.lifecycle.LiveData;\nimport android.os.AsyncTask;\n\nimport java.util.List;\n\n/**\n * Abstracted Repository as promoted by the Architecture Guide.\n * https://developer.android.com/topic/libraries/architecture/guide.html\n */\n\nclass WordRepository {\n\n    private WordDao mWordDao;\n    private LiveData<List<Word>> mAllWords;\n\n    // Note that in order to unit test the WordRepository, you have to remove the Application\n    // dependency. This adds complexity and much more code, and this sample is not about testing.\n    // See the BasicSample in the android-architecture-components repository at\n    // https://github.com/googlesamples\n    WordRepository(Application application) {\n        WordRoomDatabase db = WordRoomDatabase.getDatabase(application);\n        mWordDao = db.wordDao();\n        mAllWords = mWordDao.getAlphabetizedWords();\n    }\n\n    // Room executes all queries on a separate thread.\n    // Observed LiveData will notify the observer when the data has changed.\n    LiveData<List<Word>> getAllWords() {\n        return mAllWords;\n    }\n\n    // You must call this on a non-UI thread or your app will crash.\n    // Like this, Room ensures that you're not doing any long running operations on the main\n    // thread, blocking the UI.\n    void insert(Word word) {\n        new insertAsyncTask(mWordDao).execute(word);\n    }\n\n    private static class insertAsyncTask extends AsyncTask<Word, Void, Void> {\n\n        private WordDao mAsyncTaskDao;\n\n        insertAsyncTask(WordDao dao) {\n            mAsyncTaskDao = dao;\n        }\n\n        @Override\n        protected Void doInBackground(final Word... params) {\n            mAsyncTaskDao.insert(params[0]);\n            return null;\n        }\n    }\n}\n"
  },
  {
    "path": "deprecated/android/samples/sample-room-with-a-view/src/main/java/com/example/android/roomwordssample/WordRoomDatabase.java",
    "content": "package com.example.android.roomwordssample;\n\n/*\n * Copyright (C) 2017 Google Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport android.arch.persistence.db.SupportSQLiteDatabase;\nimport android.arch.persistence.room.Database;\nimport android.arch.persistence.room.Room;\nimport android.arch.persistence.room.RoomDatabase;\nimport android.content.Context;\nimport android.os.AsyncTask;\nimport android.support.annotation.NonNull;\n\nimport com.tencent.wcdb.database.SQLiteCipherSpec;\nimport com.tencent.wcdb.room.db.WCDBOpenHelperFactory;\n\n/**\n * This is the backend. The database. This used to be done by the OpenHelper.\n * The fact that this has very few comments emphasizes its coolness.\n */\n\n@Database(entities = {Word.class}, version = 1)\npublic abstract class WordRoomDatabase extends RoomDatabase {\n\n    public abstract WordDao wordDao();\n\n    // marking the instance as volatile to ensure atomic access to the variable\n    private static volatile WordRoomDatabase INSTANCE;\n\n    static WordRoomDatabase getDatabase(final Context context) {\n        if (INSTANCE == null) {\n            synchronized (WordRoomDatabase.class) {\n                if (INSTANCE == null) {\n                    // [WCDB] To use Room library with WCDB, pass a WCDBOpenHelper factory object\n                    // to the database builder with .openHelperFactory(...). In the factory object,\n                    // you can specify passphrase and cipher options to open or create encrypted\n                    // database, as well as optimization options like asynchronous checkpoint.\n                    SQLiteCipherSpec cipherSpec = new SQLiteCipherSpec()\n                            .setPageSize(4096)\n                            .setKDFIteration(64000);\n\n                    WCDBOpenHelperFactory factory = new WCDBOpenHelperFactory()\n                            .passphrase(\"passphrase\".getBytes())  // passphrase to the database, remove this line for plain-text\n                            .cipherSpec(cipherSpec)               // cipher to use, remove for default settings\n                            .writeAheadLoggingEnabled(true)       // enable WAL mode, remove if not needed\n                            .asyncCheckpointEnabled(true);        // enable asynchronous checkpoint, remove if not needed\n\n                    INSTANCE = Room.databaseBuilder(context.getApplicationContext(),\n                            WordRoomDatabase.class, \"word_database\")\n\n                            // [WCDB] Specify open helper to use WCDB database implementation instead\n                            // of the Android framework.\n                            .openHelperFactory(factory)\n\n                            // Wipes and rebuilds instead of migrating if no Migration object.\n                            // Migration is not part of this codelab.\n                            .fallbackToDestructiveMigration()\n                            .addCallback(sRoomDatabaseCallback)\n                            .build();\n                }\n            }\n        }\n        return INSTANCE;\n    }\n\n    /**\n     * Override the onOpen method to populate the database.\n     * For this sample, we clear the database every time it is created or opened.\n     *\n     * If you want to populate the database only when the database is created for the 1st time,\n     * override RoomDatabase.Callback()#onCreate\n     */\n    private static RoomDatabase.Callback sRoomDatabaseCallback = new RoomDatabase.Callback() {\n\n        @Override\n        public void onOpen(@NonNull SupportSQLiteDatabase db) {\n            super.onOpen(db);\n            // If you want to keep the data through app restarts,\n            // comment out the following line.\n            new PopulateDbAsync(INSTANCE).execute();\n        }\n    };\n\n    /**\n     * Populate the database in the background.\n     * If you want to start with more words, just add them.\n     */\n    private static class PopulateDbAsync extends AsyncTask<Void, Void, Void> {\n\n        private final WordDao mDao;\n\n        PopulateDbAsync(WordRoomDatabase db) {\n            mDao = db.wordDao();\n        }\n\n        @Override\n        protected Void doInBackground(final Void... params) {\n            // Start the app with a clean database every time.\n            // Not needed if you only populate on creation.\n            mDao.deleteAll();\n\n            Word word = new Word(\"Hello\");\n            mDao.insert(word);\n            word = new Word(\"World\");\n            mDao.insert(word);\n            return null;\n        }\n    }\n\n}\n"
  },
  {
    "path": "deprecated/android/samples/sample-room-with-a-view/src/main/java/com/example/android/roomwordssample/WordViewModel.java",
    "content": "package com.example.android.roomwordssample;\n\n/*\n * Copyright (C) 2017 Google Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport android.app.Application;\nimport android.arch.lifecycle.AndroidViewModel;\nimport android.arch.lifecycle.LiveData;\n\nimport java.util.List;\n\n/**\n * View Model to keep a reference to the word repository and\n * an up-to-date list of all words.\n */\n\npublic class WordViewModel extends AndroidViewModel {\n\n    private WordRepository mRepository;\n    // Using LiveData and caching what getAlphabetizedWords returns has several benefits:\n    // - We can put an observer on the data (instead of polling for changes) and only update the\n    //   the UI when the data actually changes.\n    // - Repository is completely separated from the UI through the ViewModel.\n    private LiveData<List<Word>> mAllWords;\n\n    public WordViewModel(Application application) {\n        super(application);\n        mRepository = new WordRepository(application);\n        mAllWords = mRepository.getAllWords();\n    }\n\n    LiveData<List<Word>> getAllWords() {\n        return mAllWords;\n    }\n\n    void insert(Word word) {\n        mRepository.insert(word);\n    }\n}"
  },
  {
    "path": "deprecated/android/samples/sample-room-with-a-view/src/main/res/drawable/ic_add_black_24dp.xml",
    "content": "<vector xmlns:android=\"http://schemas.android.com/apk/res/android\"\n        android:width=\"24dp\"\n        android:height=\"24dp\"\n        android:viewportWidth=\"24.0\"\n        android:viewportHeight=\"24.0\">\n    <path\n        android:fillColor=\"#FF000000\"\n        android:pathData=\"M19,13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z\"/>\n</vector>\n"
  },
  {
    "path": "deprecated/android/samples/sample-room-with-a-view/src/main/res/drawable/ic_launcher_background.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<vector xmlns:android=\"http://schemas.android.com/apk/res/android\"\n    android:width=\"24dp\"\n    android:height=\"24dp\"\n    android:viewportHeight=\"108.0\"\n    android:viewportWidth=\"108.0\">\n    <path\n        android:fillColor=\"#26A69A\"\n        android:pathData=\"M0,0h108v108h-108z\"\n        android:strokeColor=\"#66FFFFFF\"\n        android:strokeWidth=\"0.8\" />\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M19,0L19,108\"\n        android:strokeColor=\"#33FFFFFF\"\n        android:strokeWidth=\"0.8\" />\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M9,0L9,108\"\n        android:strokeColor=\"#66FFFFFF\"\n        android:strokeWidth=\"0.8\" />\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M39,0L39,108\"\n        android:strokeColor=\"#66FFFFFF\"\n        android:strokeWidth=\"0.8\" />\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M29,0L29,108\"\n        android:strokeColor=\"#66FFFFFF\"\n        android:strokeWidth=\"0.8\" />\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M59,0L59,108\"\n        android:strokeColor=\"#66FFFFFF\"\n        android:strokeWidth=\"0.8\" />\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M49,0L49,108\"\n        android:strokeColor=\"#66FFFFFF\"\n        android:strokeWidth=\"0.8\" />\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M79,0L79,108\"\n        android:strokeColor=\"#66FFFFFF\"\n        android:strokeWidth=\"0.8\" />\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M69,0L69,108\"\n        android:strokeColor=\"#66FFFFFF\"\n        android:strokeWidth=\"0.8\" />\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M89,0L89,108\"\n        android:strokeColor=\"#33FFFFFF\"\n        android:strokeWidth=\"0.8\" />\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M99,0L99,108\"\n        android:strokeColor=\"#66FFFFFF\"\n        android:strokeWidth=\"0.8\" />\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M0,89L108,89\"\n        android:strokeColor=\"#33FFFFFF\"\n        android:strokeWidth=\"0.8\" />\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M0,99L108,99\"\n        android:strokeColor=\"#66FFFFFF\"\n        android:strokeWidth=\"0.8\" />\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M0,69L108,69\"\n        android:strokeColor=\"#66FFFFFF\"\n        android:strokeWidth=\"0.8\" />\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M0,79L108,79\"\n        android:strokeColor=\"#66FFFFFF\"\n        android:strokeWidth=\"0.8\" />\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M0,49L108,49\"\n        android:strokeColor=\"#66FFFFFF\"\n        android:strokeWidth=\"0.8\" />\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M0,59L108,59\"\n        android:strokeColor=\"#66FFFFFF\"\n        android:strokeWidth=\"0.8\" />\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M0,29L108,29\"\n        android:strokeColor=\"#66FFFFFF\"\n        android:strokeWidth=\"0.8\" />\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M0,39L108,39\"\n        android:strokeColor=\"#66FFFFFF\"\n        android:strokeWidth=\"0.8\" />\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M0,19L108,19\"\n        android:strokeColor=\"#33FFFFFF\"\n        android:strokeWidth=\"0.8\" />\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M0,9L108,9\"\n        android:strokeColor=\"#66FFFFFF\"\n        android:strokeWidth=\"0.8\" />\n</vector>\n\n"
  },
  {
    "path": "deprecated/android/samples/sample-room-with-a-view/src/main/res/layout/activity_main.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n\n<!-- Copyright 2017 Google Inc.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n    http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License. -->\n\n<!-- Uses the Basic Activity Template.\nWant to minimize unrelated busy work where students just remove code.\nSo, we are leaving the template code in. -->\n\n<android.support.design.widget.CoordinatorLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"\n    xmlns:app=\"http://schemas.android.com/apk/res-auto\"\n    xmlns:tools=\"http://schemas.android.com/tools\"\n    android:layout_width=\"match_parent\"\n    android:layout_height=\"match_parent\"\n    tools:context=\"com.example.android.roomwordssample.MainActivity\">\n\n    <android.support.design.widget.AppBarLayout\n        android:layout_width=\"match_parent\"\n        android:layout_height=\"wrap_content\"\n        android:theme=\"@style/AppTheme.AppBarOverlay\">\n\n        <android.support.v7.widget.Toolbar\n            android:id=\"@+id/toolbar\"\n            android:layout_width=\"match_parent\"\n            android:layout_height=\"?attr/actionBarSize\"\n            android:background=\"?attr/colorPrimary\"\n            app:popupTheme=\"@style/AppTheme.PopupOverlay\" />\n\n    </android.support.design.widget.AppBarLayout>\n\n    <include layout=\"@layout/content_main\" />\n\n    <android.support.design.widget.FloatingActionButton\n        android:id=\"@+id/fab\"\n        android:layout_width=\"wrap_content\"\n        android:layout_height=\"wrap_content\"\n        android:layout_gravity=\"bottom|end\"\n        android:layout_margin=\"@dimen/fab_margin\"\n        android:src=\"@drawable/ic_add_black_24dp\" />\n\n</android.support.design.widget.CoordinatorLayout>\n"
  },
  {
    "path": "deprecated/android/samples/sample-room-with-a-view/src/main/res/layout/activity_new_word.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n\n<!-- Copyright 2017 Google Inc.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n    http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License. -->\n\n<LinearLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"\n    android:orientation=\"vertical\" android:layout_width=\"match_parent\"\n    android:layout_height=\"match_parent\">\n\n    <EditText\n        android:id=\"@+id/edit_word\"\n        android:layout_width=\"match_parent\"\n        android:layout_height=\"wrap_content\"\n        android:fontFamily=\"sans-serif-light\"\n        android:hint=\"@string/hint_word\"\n        android:inputType=\"textAutoComplete\"\n        android:padding=\"@dimen/small_padding\"\n        android:layout_marginBottom=\"@dimen/big_padding\"\n        android:layout_marginTop=\"@dimen/big_padding\"\n        android:textSize=\"18sp\" />\n\n    <Button\n        android:id=\"@+id/button_save\"\n        android:layout_width=\"match_parent\"\n        android:layout_height=\"wrap_content\"\n        android:background=\"@color/colorPrimary\"\n        android:text=\"@string/button_save\"\n        android:textColor=\"@color/buttonLabel\" />\n\n</LinearLayout>"
  },
  {
    "path": "deprecated/android/samples/sample-room-with-a-view/src/main/res/layout/content_main.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n\n<!-- Copyright 2017 Google Inc.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n    http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License. -->\n\n<!-- Uses the Basic Activity Template.\n  Removed most of its unnecessary code for the  RecyclerView\n  to make the code much more readable. -->\n\n<android.support.constraint.ConstraintLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"\n    xmlns:app=\"http://schemas.android.com/apk/res-auto\"\n    xmlns:tools=\"http://schemas.android.com/tools\"\n    android:layout_width=\"match_parent\"\n    android:layout_height=\"match_parent\"\n    app:layout_behavior=\"@string/appbar_scrolling_view_behavior\"\n    tools:context=\"com.example.android.roomwordssample.MainActivity\"\n    tools:showIn=\"@layout/activity_main\">\n\n    <android.support.v7.widget.RecyclerView\n        android:id=\"@+id/recyclerview\"\n        android:layout_width=\"match_parent\"\n        android:layout_height=\"match_parent\"\n        android:background=\"@android:color/darker_gray\"\n        tools:listitem=\"@layout/recyclerview_item\" />\n\n</android.support.constraint.ConstraintLayout>\n"
  },
  {
    "path": "deprecated/android/samples/sample-room-with-a-view/src/main/res/layout/recyclerview_item.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!-- Copyright 2017 Google Inc.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n    http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License. -->\n\n<LinearLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"\n    android:orientation=\"vertical\" android:layout_width=\"match_parent\"\n    android:layout_height=\"wrap_content\">\n\n    <TextView\n        android:id=\"@+id/textView\"\n        style=\"@style/word_title\"\n        android:layout_width=\"match_parent\"\n        android:layout_height=\"wrap_content\"\n        android:background=\"@android:color/holo_orange_light\" />\n</LinearLayout>"
  },
  {
    "path": "deprecated/android/samples/sample-room-with-a-view/src/main/res/mipmap-anydpi-v26/ic_launcher.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<adaptive-icon xmlns:android=\"http://schemas.android.com/apk/res/android\">\n    <background android:drawable=\"@drawable/ic_launcher_background\" />\n    <foreground android:drawable=\"@mipmap/ic_launcher_foreground\" />\n</adaptive-icon>"
  },
  {
    "path": "deprecated/android/samples/sample-room-with-a-view/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<adaptive-icon xmlns:android=\"http://schemas.android.com/apk/res/android\">\n    <background android:drawable=\"@drawable/ic_launcher_background\" />\n    <foreground android:drawable=\"@mipmap/ic_launcher_foreground\" />\n</adaptive-icon>"
  },
  {
    "path": "deprecated/android/samples/sample-room-with-a-view/src/main/res/values/colors.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!-- Copyright 2017 Google Inc.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n    http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License. -->\n\n<resources>\n    <color name=\"colorPrimary\">#3F51B5</color>\n    <color name=\"colorPrimaryDark\">#303F9F</color>\n    <color name=\"colorAccent\">#FF4081</color>\n    <color name=\"buttonLabel\">#d3d3d3</color>\n</resources>\n"
  },
  {
    "path": "deprecated/android/samples/sample-room-with-a-view/src/main/res/values/dimens.xml",
    "content": "<!-- Copyright 2017 Google Inc.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n    http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License. -->\n\n<resources>\n    <dimen name=\"fab_margin\">16dp</dimen>\n    <dimen name=\"small_padding\">6dp</dimen>\n    <dimen name=\"big_padding\">16dp</dimen>\n</resources>\n"
  },
  {
    "path": "deprecated/android/samples/sample-room-with-a-view/src/main/res/values/strings.xml",
    "content": "<!-- Copyright 2017 Google Inc.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n    http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License. -->\n\n<resources>\n    <string name=\"app_name\">RoomWordsSample</string>\n    <string name=\"action_settings\">Settings</string>\n    <string name=\"hint_word\">Word…</string>\n    <string name=\"button_save\">Save</string>\n    <string name=\"empty_not_saved\">Word not saved because it is empty.</string>\n</resources>\n"
  },
  {
    "path": "deprecated/android/samples/sample-room-with-a-view/src/main/res/values/styles.xml",
    "content": "<!-- Copyright 2017 Google Inc.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n    http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License. -->\n\n<resources>\n\n    <!-- Base application theme. -->\n    <style name=\"AppTheme\" parent=\"Theme.AppCompat.Light.DarkActionBar\">\n        <!-- Customize your theme here. -->\n        <item name=\"colorPrimary\">@color/colorPrimary</item>\n        <item name=\"colorPrimaryDark\">@color/colorPrimaryDark</item>\n        <item name=\"colorAccent\">@color/colorAccent</item>\n    </style>\n\n    <style name=\"AppTheme.NoActionBar\">\n        <item name=\"windowActionBar\">false</item>\n        <item name=\"windowNoTitle\">true</item>\n    </style>\n\n    <style name=\"AppTheme.AppBarOverlay\" parent=\"ThemeOverlay.AppCompat.Dark.ActionBar\" />\n\n    <style name=\"AppTheme.PopupOverlay\" parent=\"ThemeOverlay.AppCompat.Light\" />\n\n    <!-- The default font for RecyclerView items is too small.\n    The margin is a simple delimiter between the words. -->\n    <style name=\"word_title\">\n        <item name=\"android:layout_width\">match_parent</item>\n        <item name=\"android:layout_height\">26dp</item>\n        <item name=\"android:textSize\">24sp</item>\n        <item name=\"android:textStyle\">bold</item>\n        <item name=\"android:layout_marginBottom\">6dp</item>\n        <item name=\"android:paddingLeft\">8dp</item>\n    </style>\n\n\n</resources>\n"
  },
  {
    "path": "deprecated/android/settings.gradle",
    "content": "rootProject.name = 'wcdb-android'\ninclude ':wcdb', ':room'\n\nfile('samples').eachDir { dir ->\n    if (new File(dir, 'build.gradle').exists()) {\n        include dir.name\n        project(\":${dir.name}\").projectDir = dir\n    }\n}"
  },
  {
    "path": "deprecated/android/sqlcipher/sqlcipher.h",
    "content": "/* \n** SQLCipher\n** sqlcipher.h developed by Stephen Lombardo (Zetetic LLC) \n** sjlombardo at zetetic dot net\n** http://zetetic.net\n** \n** Copyright (c) 2008, ZETETIC LLC\n** All rights reserved.\n** \n** Redistribution and use in source and binary forms, with or without\n** modification, are permitted provided that the following conditions are met:\n**     * Redistributions of source code must retain the above copyright\n**       notice, this list of conditions and the following disclaimer.\n**     * Redistributions in binary form must reproduce the above copyright\n**       notice, this list of conditions and the following disclaimer in the\n**       documentation and/or other materials provided with the distribution.\n**     * Neither the name of the ZETETIC LLC nor the\n**       names of its contributors may be used to endorse or promote products\n**       derived from this software without specific prior written permission.\n** \n** THIS SOFTWARE IS PROVIDED BY ZETETIC LLC ''AS IS'' AND ANY\n** EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n** DISCLAIMED. IN NO EVENT SHALL ZETETIC LLC BE LIABLE FOR ANY\n** DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n** (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n** LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n** ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n**  \n*/\n/* BEGIN SQLCIPHER */\n#ifdef SQLITE_HAS_CODEC\n#ifndef SQLCIPHER_H\n#define SQLCIPHER_H\n\n#define SQLCIPHER_HMAC_SHA1 0\n#define SQLCIPHER_HMAC_SHA1_LABEL \"HMAC_SHA1\"\n#define SQLCIPHER_HMAC_SHA256 1\n#define SQLCIPHER_HMAC_SHA256_LABEL \"HMAC_SHA256\"\n#define SQLCIPHER_HMAC_SHA512 2\n#define SQLCIPHER_HMAC_SHA512_LABEL \"HMAC_SHA512\"\n\n\n#define SQLCIPHER_PBKDF2_HMAC_SHA1 0\n#define SQLCIPHER_PBKDF2_HMAC_SHA1_LABEL \"PBKDF2_HMAC_SHA1\"\n#define SQLCIPHER_PBKDF2_HMAC_SHA256 1\n#define SQLCIPHER_PBKDF2_HMAC_SHA256_LABEL \"PBKDF2_HMAC_SHA256\"\n#define SQLCIPHER_PBKDF2_HMAC_SHA512 2\n#define SQLCIPHER_PBKDF2_HMAC_SHA512_LABEL \"PBKDF2_HMAC_SHA512\"\n\n\ntypedef struct {\n  int (*activate)(void *ctx);\n  int (*deactivate)(void *ctx);\n  const char* (*get_provider_name)(void *ctx);\n  int (*add_random)(void *ctx, void *buffer, int length);\n  int (*random)(void *ctx, void *buffer, int length);\n  int (*hmac)(void *ctx, int algorithm, unsigned char *hmac_key, int key_sz, unsigned char *in, int in_sz, unsigned char *in2, int in2_sz, unsigned char *out);\n  int (*kdf)(void *ctx, int algorithm, const unsigned char *pass, int pass_sz, unsigned char* salt, int salt_sz, int workfactor, int key_sz, unsigned char *key);\n  int (*cipher)(void *ctx, int mode, unsigned char *key, int key_sz, unsigned char *iv, unsigned char *in, int in_sz, unsigned char *out);\n  const char* (*get_cipher)(void *ctx);\n  int (*get_key_sz)(void *ctx);\n  int (*get_iv_sz)(void *ctx);\n  int (*get_block_sz)(void *ctx);\n  int (*get_hmac_sz)(void *ctx, int algorithm);\n  int (*ctx_copy)(void *target_ctx, void *source_ctx);\n  int (*ctx_cmp)(void *c1, void *c2);\n  int (*ctx_init)(void **ctx);\n  int (*ctx_free)(void **ctx);\n  int (*fips_status)(void *ctx);\n  const char* (*get_provider_version)(void *ctx);\n} sqlcipher_provider;\n\n/* provider interfaces */\nint sqlcipher_register_provider(sqlcipher_provider *p);\nsqlcipher_provider* sqlcipher_get_provider();\n\n#endif\n#endif\n/* END SQLCIPHER */\n\n"
  },
  {
    "path": "deprecated/android/sqlcipher/sqlite3.c",
    "content": "/******************************************************************************\n** This file is an amalgamation of many separate C source files from SQLite\n** version 3.27.2.  By combining all the individual C code files into this\n** single large file, the entire code can be compiled as a single translation\n** unit.  This allows many compilers to do optimizations that would not be\n** possible if the files were compiled separately.  Performance improvements\n** of 5% or more are commonly seen when SQLite is compiled as a single\n** translation unit.\n**\n** This file is all you need to compile SQLite.  To use SQLite in other\n** programs, you need this file and the \"sqlite3.h\" header file that defines\n** the programming interface to the SQLite library.  (If you do not have\n** the \"sqlite3.h\" header file at hand, you will find a copy embedded within\n** the text of this file.  Search for \"Begin file sqlite3.h\" to find the start\n** of the embedded sqlite3.h header file.) Additional code files may be needed\n** if you want a wrapper to interface SQLite with your choice of programming\n** language. The code for the \"sqlite3\" command-line shell is also in a\n** separate file. This file contains only code for the core SQLite library.\n*/\n#define SQLITE_CORE 1\n#define SQLITE_AMALGAMATION 1\n#ifndef SQLITE_PRIVATE\n# define SQLITE_PRIVATE static\n#endif\n/************** Begin file ctime.c *******************************************/\n/*\n** 2010 February 23\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n**\n** This file implements routines used to report what compile-time options\n** SQLite was built with.\n*/\n\n#ifndef SQLITE_OMIT_COMPILEOPTION_DIAGS\n\n/*\n** Include the configuration header output by 'configure' if we're using the\n** autoconf-based build\n*/\n#if defined(_HAVE_SQLITE_CONFIG_H) && !defined(SQLITECONFIG_H)\n#include \"config.h\"\n#define SQLITECONFIG_H 1\n#endif\n\n/* These macros are provided to \"stringify\" the value of the define\n** for those options in which the value is meaningful. */\n#define CTIMEOPT_VAL_(opt) #opt\n#define CTIMEOPT_VAL(opt) CTIMEOPT_VAL_(opt)\n\n/* Like CTIMEOPT_VAL, but especially for SQLITE_DEFAULT_LOOKASIDE. This\n** option requires a separate macro because legal values contain a single\n** comma. e.g. (-DSQLITE_DEFAULT_LOOKASIDE=\"100,100\") */\n#define CTIMEOPT_VAL2_(opt1,opt2) #opt1 \",\" #opt2\n#define CTIMEOPT_VAL2(opt) CTIMEOPT_VAL2_(opt)\n\n/*\n** An array of names of all compile-time options.  This array should \n** be sorted A-Z.\n**\n** This array looks large, but in a typical installation actually uses\n** only a handful of compile-time options, so most times this array is usually\n** rather short and uses little memory space.\n*/\nstatic const char * const sqlite3azCompileOpt[] = {\n\n/* \n** BEGIN CODE GENERATED BY tool/mkctime.tcl \n*/\n#if SQLITE_32BIT_ROWID\n  \"32BIT_ROWID\",\n#endif\n#if SQLITE_4_BYTE_ALIGNED_MALLOC\n  \"4_BYTE_ALIGNED_MALLOC\",\n#endif\n#if SQLITE_64BIT_STATS\n  \"64BIT_STATS\",\n#endif\n#if SQLITE_ALLOW_COVERING_INDEX_SCAN\n  \"ALLOW_COVERING_INDEX_SCAN\",\n#endif\n#if SQLITE_ALLOW_URI_AUTHORITY\n  \"ALLOW_URI_AUTHORITY\",\n#endif\n#ifdef SQLITE_BITMASK_TYPE\n  \"BITMASK_TYPE=\" CTIMEOPT_VAL(SQLITE_BITMASK_TYPE),\n#endif\n#if SQLITE_BUG_COMPATIBLE_20160819\n  \"BUG_COMPATIBLE_20160819\",\n#endif\n#if SQLITE_CASE_SENSITIVE_LIKE\n  \"CASE_SENSITIVE_LIKE\",\n#endif\n#if SQLITE_CHECK_PAGES\n  \"CHECK_PAGES\",\n#endif\n#if defined(__clang__) && defined(__clang_major__)\n  \"COMPILER=clang-\" CTIMEOPT_VAL(__clang_major__) \".\"\n                    CTIMEOPT_VAL(__clang_minor__) \".\"\n                    CTIMEOPT_VAL(__clang_patchlevel__),\n#elif defined(_MSC_VER)\n  \"COMPILER=msvc-\" CTIMEOPT_VAL(_MSC_VER),\n#elif defined(__GNUC__) && defined(__VERSION__)\n  \"COMPILER=gcc-\" __VERSION__,\n#endif\n#if SQLITE_COVERAGE_TEST\n  \"COVERAGE_TEST\",\n#endif\n#if SQLITE_DEBUG\n  \"DEBUG\",\n#endif\n#if SQLITE_DEFAULT_AUTOMATIC_INDEX\n  \"DEFAULT_AUTOMATIC_INDEX\",\n#endif\n#if SQLITE_DEFAULT_AUTOVACUUM\n  \"DEFAULT_AUTOVACUUM\",\n#endif\n#ifdef SQLITE_DEFAULT_CACHE_SIZE\n  \"DEFAULT_CACHE_SIZE=\" CTIMEOPT_VAL(SQLITE_DEFAULT_CACHE_SIZE),\n#endif\n#if SQLITE_DEFAULT_CKPTFULLFSYNC\n  \"DEFAULT_CKPTFULLFSYNC\",\n#endif\n#ifdef SQLITE_DEFAULT_FILE_FORMAT\n  \"DEFAULT_FILE_FORMAT=\" CTIMEOPT_VAL(SQLITE_DEFAULT_FILE_FORMAT),\n#endif\n#ifdef SQLITE_DEFAULT_FILE_PERMISSIONS\n  \"DEFAULT_FILE_PERMISSIONS=\" CTIMEOPT_VAL(SQLITE_DEFAULT_FILE_PERMISSIONS),\n#endif\n#if SQLITE_DEFAULT_FOREIGN_KEYS\n  \"DEFAULT_FOREIGN_KEYS\",\n#endif\n#ifdef SQLITE_DEFAULT_JOURNAL_SIZE_LIMIT\n  \"DEFAULT_JOURNAL_SIZE_LIMIT=\" CTIMEOPT_VAL(SQLITE_DEFAULT_JOURNAL_SIZE_LIMIT),\n#endif\n#ifdef SQLITE_DEFAULT_LOCKING_MODE\n  \"DEFAULT_LOCKING_MODE=\" CTIMEOPT_VAL(SQLITE_DEFAULT_LOCKING_MODE),\n#endif\n#ifdef SQLITE_DEFAULT_LOOKASIDE\n  \"DEFAULT_LOOKASIDE=\" CTIMEOPT_VAL2(SQLITE_DEFAULT_LOOKASIDE),\n#endif\n#if SQLITE_DEFAULT_MEMSTATUS\n  \"DEFAULT_MEMSTATUS\",\n#endif\n#ifdef SQLITE_DEFAULT_MMAP_SIZE\n  \"DEFAULT_MMAP_SIZE=\" CTIMEOPT_VAL(SQLITE_DEFAULT_MMAP_SIZE),\n#endif\n#ifdef SQLITE_DEFAULT_PAGE_SIZE\n  \"DEFAULT_PAGE_SIZE=\" CTIMEOPT_VAL(SQLITE_DEFAULT_PAGE_SIZE),\n#endif\n#ifdef SQLITE_DEFAULT_PCACHE_INITSZ\n  \"DEFAULT_PCACHE_INITSZ=\" CTIMEOPT_VAL(SQLITE_DEFAULT_PCACHE_INITSZ),\n#endif\n#ifdef SQLITE_DEFAULT_PROXYDIR_PERMISSIONS\n  \"DEFAULT_PROXYDIR_PERMISSIONS=\" CTIMEOPT_VAL(SQLITE_DEFAULT_PROXYDIR_PERMISSIONS),\n#endif\n#if SQLITE_DEFAULT_RECURSIVE_TRIGGERS\n  \"DEFAULT_RECURSIVE_TRIGGERS\",\n#endif\n#ifdef SQLITE_DEFAULT_ROWEST\n  \"DEFAULT_ROWEST=\" CTIMEOPT_VAL(SQLITE_DEFAULT_ROWEST),\n#endif\n#ifdef SQLITE_DEFAULT_SECTOR_SIZE\n  \"DEFAULT_SECTOR_SIZE=\" CTIMEOPT_VAL(SQLITE_DEFAULT_SECTOR_SIZE),\n#endif\n#ifdef SQLITE_DEFAULT_SYNCHRONOUS\n  \"DEFAULT_SYNCHRONOUS=\" CTIMEOPT_VAL(SQLITE_DEFAULT_SYNCHRONOUS),\n#endif\n#ifdef SQLITE_DEFAULT_WAL_AUTOCHECKPOINT\n  \"DEFAULT_WAL_AUTOCHECKPOINT=\" CTIMEOPT_VAL(SQLITE_DEFAULT_WAL_AUTOCHECKPOINT),\n#endif\n#ifdef SQLITE_DEFAULT_WAL_SYNCHRONOUS\n  \"DEFAULT_WAL_SYNCHRONOUS=\" CTIMEOPT_VAL(SQLITE_DEFAULT_WAL_SYNCHRONOUS),\n#endif\n#ifdef SQLITE_DEFAULT_WORKER_THREADS\n  \"DEFAULT_WORKER_THREADS=\" CTIMEOPT_VAL(SQLITE_DEFAULT_WORKER_THREADS),\n#endif\n#if SQLITE_DIRECT_OVERFLOW_READ\n  \"DIRECT_OVERFLOW_READ\",\n#endif\n#if SQLITE_DISABLE_DIRSYNC\n  \"DISABLE_DIRSYNC\",\n#endif\n#if SQLITE_DISABLE_FTS3_UNICODE\n  \"DISABLE_FTS3_UNICODE\",\n#endif\n#if SQLITE_DISABLE_FTS4_DEFERRED\n  \"DISABLE_FTS4_DEFERRED\",\n#endif\n#if SQLITE_DISABLE_INTRINSIC\n  \"DISABLE_INTRINSIC\",\n#endif\n#if SQLITE_DISABLE_LFS\n  \"DISABLE_LFS\",\n#endif\n#if SQLITE_DISABLE_PAGECACHE_OVERFLOW_STATS\n  \"DISABLE_PAGECACHE_OVERFLOW_STATS\",\n#endif\n#if SQLITE_DISABLE_SKIPAHEAD_DISTINCT\n  \"DISABLE_SKIPAHEAD_DISTINCT\",\n#endif\n#ifdef SQLITE_ENABLE_8_3_NAMES\n  \"ENABLE_8_3_NAMES=\" CTIMEOPT_VAL(SQLITE_ENABLE_8_3_NAMES),\n#endif\n#if SQLITE_ENABLE_API_ARMOR\n  \"ENABLE_API_ARMOR\",\n#endif\n#if SQLITE_ENABLE_ATOMIC_WRITE\n  \"ENABLE_ATOMIC_WRITE\",\n#endif\n#if SQLITE_ENABLE_BATCH_ATOMIC_WRITE\n  \"ENABLE_BATCH_ATOMIC_WRITE\",\n#endif\n#if SQLITE_ENABLE_CEROD\n  \"ENABLE_CEROD=\" CTIMEOPT_VAL(SQLITE_ENABLE_CEROD),\n#endif\n#if SQLITE_ENABLE_COLUMN_METADATA\n  \"ENABLE_COLUMN_METADATA\",\n#endif\n#if SQLITE_ENABLE_COLUMN_USED_MASK\n  \"ENABLE_COLUMN_USED_MASK\",\n#endif\n#if SQLITE_ENABLE_COSTMULT\n  \"ENABLE_COSTMULT\",\n#endif\n#if SQLITE_ENABLE_CURSOR_HINTS\n  \"ENABLE_CURSOR_HINTS\",\n#endif\n#if SQLITE_ENABLE_DBSTAT_VTAB\n  \"ENABLE_DBSTAT_VTAB\",\n#endif\n#if SQLITE_ENABLE_EXPENSIVE_ASSERT\n  \"ENABLE_EXPENSIVE_ASSERT\",\n#endif\n#if SQLITE_ENABLE_FTS1\n  \"ENABLE_FTS1\",\n#endif\n#if SQLITE_ENABLE_FTS2\n  \"ENABLE_FTS2\",\n#endif\n#if SQLITE_ENABLE_FTS3\n  \"ENABLE_FTS3\",\n#endif\n#if SQLITE_ENABLE_FTS3_PARENTHESIS\n  \"ENABLE_FTS3_PARENTHESIS\",\n#endif\n#if SQLITE_ENABLE_FTS3_TOKENIZER\n  \"ENABLE_FTS3_TOKENIZER\",\n#endif\n#if SQLITE_ENABLE_FTS4\n  \"ENABLE_FTS4\",\n#endif\n#if SQLITE_ENABLE_FTS5\n  \"ENABLE_FTS5\",\n#endif\n#if SQLITE_ENABLE_GEOPOLY\n  \"ENABLE_GEOPOLY\",\n#endif\n#if SQLITE_ENABLE_HIDDEN_COLUMNS\n  \"ENABLE_HIDDEN_COLUMNS\",\n#endif\n#if SQLITE_ENABLE_ICU\n  \"ENABLE_ICU\",\n#endif\n#if SQLITE_ENABLE_IOTRACE\n  \"ENABLE_IOTRACE\",\n#endif\n#if SQLITE_ENABLE_JSON1\n  \"ENABLE_JSON1\",\n#endif\n#if SQLITE_ENABLE_LOAD_EXTENSION\n  \"ENABLE_LOAD_EXTENSION\",\n#endif\n#ifdef SQLITE_ENABLE_LOCKING_STYLE\n  \"ENABLE_LOCKING_STYLE=\" CTIMEOPT_VAL(SQLITE_ENABLE_LOCKING_STYLE),\n#endif\n#if SQLITE_ENABLE_MEMORY_MANAGEMENT\n  \"ENABLE_MEMORY_MANAGEMENT\",\n#endif\n#if SQLITE_ENABLE_MEMSYS3\n  \"ENABLE_MEMSYS3\",\n#endif\n#if SQLITE_ENABLE_MEMSYS5\n  \"ENABLE_MEMSYS5\",\n#endif\n#if SQLITE_ENABLE_MULTIPLEX\n  \"ENABLE_MULTIPLEX\",\n#endif\n#if SQLITE_ENABLE_NORMALIZE\n  \"ENABLE_NORMALIZE\",\n#endif\n#if SQLITE_ENABLE_NULL_TRIM\n  \"ENABLE_NULL_TRIM\",\n#endif\n#if SQLITE_ENABLE_OVERSIZE_CELL_CHECK\n  \"ENABLE_OVERSIZE_CELL_CHECK\",\n#endif\n#if SQLITE_ENABLE_PREUPDATE_HOOK\n  \"ENABLE_PREUPDATE_HOOK\",\n#endif\n#if SQLITE_ENABLE_QPSG\n  \"ENABLE_QPSG\",\n#endif\n#if SQLITE_ENABLE_RBU\n  \"ENABLE_RBU\",\n#endif\n#if SQLITE_ENABLE_RTREE\n  \"ENABLE_RTREE\",\n#endif\n#if SQLITE_ENABLE_SELECTTRACE\n  \"ENABLE_SELECTTRACE\",\n#endif\n#if SQLITE_ENABLE_SESSION\n  \"ENABLE_SESSION\",\n#endif\n#if SQLITE_ENABLE_SNAPSHOT\n  \"ENABLE_SNAPSHOT\",\n#endif\n#if SQLITE_ENABLE_SORTER_REFERENCES\n  \"ENABLE_SORTER_REFERENCES\",\n#endif\n#if SQLITE_ENABLE_SQLLOG\n  \"ENABLE_SQLLOG\",\n#endif\n#if defined(SQLITE_ENABLE_STAT4)\n  \"ENABLE_STAT4\",\n#elif defined(SQLITE_ENABLE_STAT3)\n  \"ENABLE_STAT3\",\n#endif\n#if SQLITE_ENABLE_STMTVTAB\n  \"ENABLE_STMTVTAB\",\n#endif\n#if SQLITE_ENABLE_STMT_SCANSTATUS\n  \"ENABLE_STMT_SCANSTATUS\",\n#endif\n#if SQLITE_ENABLE_UNKNOWN_SQL_FUNCTION\n  \"ENABLE_UNKNOWN_SQL_FUNCTION\",\n#endif\n#if SQLITE_ENABLE_UNLOCK_NOTIFY\n  \"ENABLE_UNLOCK_NOTIFY\",\n#endif\n#if SQLITE_ENABLE_UPDATE_DELETE_LIMIT\n  \"ENABLE_UPDATE_DELETE_LIMIT\",\n#endif\n#if SQLITE_ENABLE_URI_00_ERROR\n  \"ENABLE_URI_00_ERROR\",\n#endif\n#if SQLITE_ENABLE_VFSTRACE\n  \"ENABLE_VFSTRACE\",\n#endif\n#if SQLITE_ENABLE_WHERETRACE\n  \"ENABLE_WHERETRACE\",\n#endif\n#if SQLITE_ENABLE_ZIPVFS\n  \"ENABLE_ZIPVFS\",\n#endif\n#if SQLITE_EXPLAIN_ESTIMATED_ROWS\n  \"EXPLAIN_ESTIMATED_ROWS\",\n#endif\n#if SQLITE_EXTRA_IFNULLROW\n  \"EXTRA_IFNULLROW\",\n#endif\n#ifdef SQLITE_EXTRA_INIT\n  \"EXTRA_INIT=\" CTIMEOPT_VAL(SQLITE_EXTRA_INIT),\n#endif\n#ifdef SQLITE_EXTRA_SHUTDOWN\n  \"EXTRA_SHUTDOWN=\" CTIMEOPT_VAL(SQLITE_EXTRA_SHUTDOWN),\n#endif\n#ifdef SQLITE_FTS3_MAX_EXPR_DEPTH\n  \"FTS3_MAX_EXPR_DEPTH=\" CTIMEOPT_VAL(SQLITE_FTS3_MAX_EXPR_DEPTH),\n#endif\n#if SQLITE_FTS5_ENABLE_TEST_MI\n  \"FTS5_ENABLE_TEST_MI\",\n#endif\n#if SQLITE_FTS5_NO_WITHOUT_ROWID\n  \"FTS5_NO_WITHOUT_ROWID\",\n#endif\n#if SQLITE_HAS_CODEC\n  \"HAS_CODEC\",\n#endif\n#if HAVE_ISNAN || SQLITE_HAVE_ISNAN\n  \"HAVE_ISNAN\",\n#endif\n#if SQLITE_HOMEGROWN_RECURSIVE_MUTEX\n  \"HOMEGROWN_RECURSIVE_MUTEX\",\n#endif\n#if SQLITE_IGNORE_AFP_LOCK_ERRORS\n  \"IGNORE_AFP_LOCK_ERRORS\",\n#endif\n#if SQLITE_IGNORE_FLOCK_LOCK_ERRORS\n  \"IGNORE_FLOCK_LOCK_ERRORS\",\n#endif\n#if SQLITE_INLINE_MEMCPY\n  \"INLINE_MEMCPY\",\n#endif\n#if SQLITE_INT64_TYPE\n  \"INT64_TYPE\",\n#endif\n#ifdef SQLITE_INTEGRITY_CHECK_ERROR_MAX\n  \"INTEGRITY_CHECK_ERROR_MAX=\" CTIMEOPT_VAL(SQLITE_INTEGRITY_CHECK_ERROR_MAX),\n#endif\n#if SQLITE_LIKE_DOESNT_MATCH_BLOBS\n  \"LIKE_DOESNT_MATCH_BLOBS\",\n#endif\n#if SQLITE_LOCK_TRACE\n  \"LOCK_TRACE\",\n#endif\n#if SQLITE_LOG_CACHE_SPILL\n  \"LOG_CACHE_SPILL\",\n#endif\n#ifdef SQLITE_MALLOC_SOFT_LIMIT\n  \"MALLOC_SOFT_LIMIT=\" CTIMEOPT_VAL(SQLITE_MALLOC_SOFT_LIMIT),\n#endif\n#ifdef SQLITE_MAX_ATTACHED\n  \"MAX_ATTACHED=\" CTIMEOPT_VAL(SQLITE_MAX_ATTACHED),\n#endif\n#ifdef SQLITE_MAX_COLUMN\n  \"MAX_COLUMN=\" CTIMEOPT_VAL(SQLITE_MAX_COLUMN),\n#endif\n#ifdef SQLITE_MAX_COMPOUND_SELECT\n  \"MAX_COMPOUND_SELECT=\" CTIMEOPT_VAL(SQLITE_MAX_COMPOUND_SELECT),\n#endif\n#ifdef SQLITE_MAX_DEFAULT_PAGE_SIZE\n  \"MAX_DEFAULT_PAGE_SIZE=\" CTIMEOPT_VAL(SQLITE_MAX_DEFAULT_PAGE_SIZE),\n#endif\n#ifdef SQLITE_MAX_EXPR_DEPTH\n  \"MAX_EXPR_DEPTH=\" CTIMEOPT_VAL(SQLITE_MAX_EXPR_DEPTH),\n#endif\n#ifdef SQLITE_MAX_FUNCTION_ARG\n  \"MAX_FUNCTION_ARG=\" CTIMEOPT_VAL(SQLITE_MAX_FUNCTION_ARG),\n#endif\n#ifdef SQLITE_MAX_LENGTH\n  \"MAX_LENGTH=\" CTIMEOPT_VAL(SQLITE_MAX_LENGTH),\n#endif\n#ifdef SQLITE_MAX_LIKE_PATTERN_LENGTH\n  \"MAX_LIKE_PATTERN_LENGTH=\" CTIMEOPT_VAL(SQLITE_MAX_LIKE_PATTERN_LENGTH),\n#endif\n#ifdef SQLITE_MAX_MEMORY\n  \"MAX_MEMORY=\" CTIMEOPT_VAL(SQLITE_MAX_MEMORY),\n#endif\n#ifdef SQLITE_MAX_MMAP_SIZE\n  \"MAX_MMAP_SIZE=\" CTIMEOPT_VAL(SQLITE_MAX_MMAP_SIZE),\n#endif\n#ifdef SQLITE_MAX_MMAP_SIZE_\n  \"MAX_MMAP_SIZE_=\" CTIMEOPT_VAL(SQLITE_MAX_MMAP_SIZE_),\n#endif\n#ifdef SQLITE_MAX_PAGE_COUNT\n  \"MAX_PAGE_COUNT=\" CTIMEOPT_VAL(SQLITE_MAX_PAGE_COUNT),\n#endif\n#ifdef SQLITE_MAX_PAGE_SIZE\n  \"MAX_PAGE_SIZE=\" CTIMEOPT_VAL(SQLITE_MAX_PAGE_SIZE),\n#endif\n#ifdef SQLITE_MAX_SCHEMA_RETRY\n  \"MAX_SCHEMA_RETRY=\" CTIMEOPT_VAL(SQLITE_MAX_SCHEMA_RETRY),\n#endif\n#ifdef SQLITE_MAX_SQL_LENGTH\n  \"MAX_SQL_LENGTH=\" CTIMEOPT_VAL(SQLITE_MAX_SQL_LENGTH),\n#endif\n#ifdef SQLITE_MAX_TRIGGER_DEPTH\n  \"MAX_TRIGGER_DEPTH=\" CTIMEOPT_VAL(SQLITE_MAX_TRIGGER_DEPTH),\n#endif\n#ifdef SQLITE_MAX_VARIABLE_NUMBER\n  \"MAX_VARIABLE_NUMBER=\" CTIMEOPT_VAL(SQLITE_MAX_VARIABLE_NUMBER),\n#endif\n#ifdef SQLITE_MAX_VDBE_OP\n  \"MAX_VDBE_OP=\" CTIMEOPT_VAL(SQLITE_MAX_VDBE_OP),\n#endif\n#ifdef SQLITE_MAX_WORKER_THREADS\n  \"MAX_WORKER_THREADS=\" CTIMEOPT_VAL(SQLITE_MAX_WORKER_THREADS),\n#endif\n#if SQLITE_MEMDEBUG\n  \"MEMDEBUG\",\n#endif\n#if SQLITE_MIXED_ENDIAN_64BIT_FLOAT\n  \"MIXED_ENDIAN_64BIT_FLOAT\",\n#endif\n#if SQLITE_MMAP_READWRITE\n  \"MMAP_READWRITE\",\n#endif\n#if SQLITE_MUTEX_NOOP\n  \"MUTEX_NOOP\",\n#endif\n#if SQLITE_MUTEX_NREF\n  \"MUTEX_NREF\",\n#endif\n#if SQLITE_MUTEX_OMIT\n  \"MUTEX_OMIT\",\n#endif\n#if SQLITE_MUTEX_PTHREADS\n  \"MUTEX_PTHREADS\",\n#endif\n#if SQLITE_MUTEX_W32\n  \"MUTEX_W32\",\n#endif\n#if SQLITE_NEED_ERR_NAME\n  \"NEED_ERR_NAME\",\n#endif\n#if SQLITE_NOINLINE\n  \"NOINLINE\",\n#endif\n#if SQLITE_NO_SYNC\n  \"NO_SYNC\",\n#endif\n#if SQLITE_OMIT_ALTERTABLE\n  \"OMIT_ALTERTABLE\",\n#endif\n#if SQLITE_OMIT_ANALYZE\n  \"OMIT_ANALYZE\",\n#endif\n#if SQLITE_OMIT_ATTACH\n  \"OMIT_ATTACH\",\n#endif\n#if SQLITE_OMIT_AUTHORIZATION\n  \"OMIT_AUTHORIZATION\",\n#endif\n#if SQLITE_OMIT_AUTOINCREMENT\n  \"OMIT_AUTOINCREMENT\",\n#endif\n#if SQLITE_OMIT_AUTOINIT\n  \"OMIT_AUTOINIT\",\n#endif\n#if SQLITE_OMIT_AUTOMATIC_INDEX\n  \"OMIT_AUTOMATIC_INDEX\",\n#endif\n#if SQLITE_OMIT_AUTORESET\n  \"OMIT_AUTORESET\",\n#endif\n#if SQLITE_OMIT_AUTOVACUUM\n  \"OMIT_AUTOVACUUM\",\n#endif\n#if SQLITE_OMIT_BETWEEN_OPTIMIZATION\n  \"OMIT_BETWEEN_OPTIMIZATION\",\n#endif\n#if SQLITE_OMIT_BLOB_LITERAL\n  \"OMIT_BLOB_LITERAL\",\n#endif\n#if SQLITE_OMIT_BTREECOUNT\n  \"OMIT_BTREECOUNT\",\n#endif\n#if SQLITE_OMIT_CAST\n  \"OMIT_CAST\",\n#endif\n#if SQLITE_OMIT_CHECK\n  \"OMIT_CHECK\",\n#endif\n#if SQLITE_OMIT_COMPLETE\n  \"OMIT_COMPLETE\",\n#endif\n#if SQLITE_OMIT_COMPOUND_SELECT\n  \"OMIT_COMPOUND_SELECT\",\n#endif\n#if SQLITE_OMIT_CONFLICT_CLAUSE\n  \"OMIT_CONFLICT_CLAUSE\",\n#endif\n#if SQLITE_OMIT_CTE\n  \"OMIT_CTE\",\n#endif\n#if SQLITE_OMIT_DATETIME_FUNCS\n  \"OMIT_DATETIME_FUNCS\",\n#endif\n#if SQLITE_OMIT_DECLTYPE\n  \"OMIT_DECLTYPE\",\n#endif\n#if SQLITE_OMIT_DEPRECATED\n  \"OMIT_DEPRECATED\",\n#endif\n#if SQLITE_OMIT_DISKIO\n  \"OMIT_DISKIO\",\n#endif\n#if SQLITE_OMIT_EXPLAIN\n  \"OMIT_EXPLAIN\",\n#endif\n#if SQLITE_OMIT_FLAG_PRAGMAS\n  \"OMIT_FLAG_PRAGMAS\",\n#endif\n#if SQLITE_OMIT_FLOATING_POINT\n  \"OMIT_FLOATING_POINT\",\n#endif\n#if SQLITE_OMIT_FOREIGN_KEY\n  \"OMIT_FOREIGN_KEY\",\n#endif\n#if SQLITE_OMIT_GET_TABLE\n  \"OMIT_GET_TABLE\",\n#endif\n#if SQLITE_OMIT_HEX_INTEGER\n  \"OMIT_HEX_INTEGER\",\n#endif\n#if SQLITE_OMIT_INCRBLOB\n  \"OMIT_INCRBLOB\",\n#endif\n#if SQLITE_OMIT_INTEGRITY_CHECK\n  \"OMIT_INTEGRITY_CHECK\",\n#endif\n#if SQLITE_OMIT_LIKE_OPTIMIZATION\n  \"OMIT_LIKE_OPTIMIZATION\",\n#endif\n#if SQLITE_OMIT_LOAD_EXTENSION\n  \"OMIT_LOAD_EXTENSION\",\n#endif\n#if SQLITE_OMIT_LOCALTIME\n  \"OMIT_LOCALTIME\",\n#endif\n#if SQLITE_OMIT_LOOKASIDE\n  \"OMIT_LOOKASIDE\",\n#endif\n#if SQLITE_OMIT_MEMORYDB\n  \"OMIT_MEMORYDB\",\n#endif\n#if SQLITE_OMIT_OR_OPTIMIZATION\n  \"OMIT_OR_OPTIMIZATION\",\n#endif\n#if SQLITE_OMIT_PAGER_PRAGMAS\n  \"OMIT_PAGER_PRAGMAS\",\n#endif\n#if SQLITE_OMIT_PARSER_TRACE\n  \"OMIT_PARSER_TRACE\",\n#endif\n#if SQLITE_OMIT_POPEN\n  \"OMIT_POPEN\",\n#endif\n#if SQLITE_OMIT_PRAGMA\n  \"OMIT_PRAGMA\",\n#endif\n#if SQLITE_OMIT_PROGRESS_CALLBACK\n  \"OMIT_PROGRESS_CALLBACK\",\n#endif\n#if SQLITE_OMIT_QUICKBALANCE\n  \"OMIT_QUICKBALANCE\",\n#endif\n#if SQLITE_OMIT_REINDEX\n  \"OMIT_REINDEX\",\n#endif\n#if SQLITE_OMIT_SCHEMA_PRAGMAS\n  \"OMIT_SCHEMA_PRAGMAS\",\n#endif\n#if SQLITE_OMIT_SCHEMA_VERSION_PRAGMAS\n  \"OMIT_SCHEMA_VERSION_PRAGMAS\",\n#endif\n#if SQLITE_OMIT_SHARED_CACHE\n  \"OMIT_SHARED_CACHE\",\n#endif\n#if SQLITE_OMIT_SHUTDOWN_DIRECTORIES\n  \"OMIT_SHUTDOWN_DIRECTORIES\",\n#endif\n#if SQLITE_OMIT_SUBQUERY\n  \"OMIT_SUBQUERY\",\n#endif\n#if SQLITE_OMIT_TCL_VARIABLE\n  \"OMIT_TCL_VARIABLE\",\n#endif\n#if SQLITE_OMIT_TEMPDB\n  \"OMIT_TEMPDB\",\n#endif\n#if SQLITE_OMIT_TEST_CONTROL\n  \"OMIT_TEST_CONTROL\",\n#endif\n#if SQLITE_OMIT_TRACE\n  \"OMIT_TRACE\",\n#endif\n#if SQLITE_OMIT_TRIGGER\n  \"OMIT_TRIGGER\",\n#endif\n#if SQLITE_OMIT_TRUNCATE_OPTIMIZATION\n  \"OMIT_TRUNCATE_OPTIMIZATION\",\n#endif\n#if SQLITE_OMIT_UTF16\n  \"OMIT_UTF16\",\n#endif\n#if SQLITE_OMIT_VACUUM\n  \"OMIT_VACUUM\",\n#endif\n#if SQLITE_OMIT_VIEW\n  \"OMIT_VIEW\",\n#endif\n#if SQLITE_OMIT_VIRTUALTABLE\n  \"OMIT_VIRTUALTABLE\",\n#endif\n#if SQLITE_OMIT_WAL\n  \"OMIT_WAL\",\n#endif\n#if SQLITE_OMIT_WSD\n  \"OMIT_WSD\",\n#endif\n#if SQLITE_OMIT_XFER_OPT\n  \"OMIT_XFER_OPT\",\n#endif\n#if SQLITE_PCACHE_SEPARATE_HEADER\n  \"PCACHE_SEPARATE_HEADER\",\n#endif\n#if SQLITE_PERFORMANCE_TRACE\n  \"PERFORMANCE_TRACE\",\n#endif\n#if SQLITE_POWERSAFE_OVERWRITE\n  \"POWERSAFE_OVERWRITE\",\n#endif\n#if SQLITE_PREFER_PROXY_LOCKING\n  \"PREFER_PROXY_LOCKING\",\n#endif\n#if SQLITE_PROXY_DEBUG\n  \"PROXY_DEBUG\",\n#endif\n#if SQLITE_REVERSE_UNORDERED_SELECTS\n  \"REVERSE_UNORDERED_SELECTS\",\n#endif\n#if SQLITE_RTREE_INT_ONLY\n  \"RTREE_INT_ONLY\",\n#endif\n#if SQLITE_SECURE_DELETE\n  \"SECURE_DELETE\",\n#endif\n#if SQLITE_SMALL_STACK\n  \"SMALL_STACK\",\n#endif\n#ifdef SQLITE_SORTER_PMASZ\n  \"SORTER_PMASZ=\" CTIMEOPT_VAL(SQLITE_SORTER_PMASZ),\n#endif\n#if SQLITE_SOUNDEX\n  \"SOUNDEX\",\n#endif\n#ifdef SQLITE_STAT4_SAMPLES\n  \"STAT4_SAMPLES=\" CTIMEOPT_VAL(SQLITE_STAT4_SAMPLES),\n#endif\n#ifdef SQLITE_STMTJRNL_SPILL\n  \"STMTJRNL_SPILL=\" CTIMEOPT_VAL(SQLITE_STMTJRNL_SPILL),\n#endif\n#if SQLITE_SUBSTR_COMPATIBILITY\n  \"SUBSTR_COMPATIBILITY\",\n#endif\n#if SQLITE_SYSTEM_MALLOC\n  \"SYSTEM_MALLOC\",\n#endif\n#if SQLITE_TCL\n  \"TCL\",\n#endif\n#ifdef SQLITE_TEMP_STORE\n  \"TEMP_STORE=\" CTIMEOPT_VAL(SQLITE_TEMP_STORE),\n#endif\n#if SQLITE_TEST\n  \"TEST\",\n#endif\n#if defined(SQLITE_THREADSAFE)\n  \"THREADSAFE=\" CTIMEOPT_VAL(SQLITE_THREADSAFE),\n#elif defined(THREADSAFE)\n  \"THREADSAFE=\" CTIMEOPT_VAL(THREADSAFE),\n#else\n  \"THREADSAFE=1\",\n#endif\n#if SQLITE_UNLINK_AFTER_CLOSE\n  \"UNLINK_AFTER_CLOSE\",\n#endif\n#if SQLITE_UNTESTABLE\n  \"UNTESTABLE\",\n#endif\n#if SQLITE_USER_AUTHENTICATION\n  \"USER_AUTHENTICATION\",\n#endif\n#if SQLITE_USE_ALLOCA\n  \"USE_ALLOCA\",\n#endif\n#if SQLITE_USE_FCNTL_TRACE\n  \"USE_FCNTL_TRACE\",\n#endif\n#if SQLITE_USE_URI\n  \"USE_URI\",\n#endif\n#if SQLITE_VDBE_COVERAGE\n  \"VDBE_COVERAGE\",\n#endif\n#if SQLITE_WIN32_MALLOC\n  \"WIN32_MALLOC\",\n#endif\n#if SQLITE_ZERO_MALLOC\n  \"ZERO_MALLOC\",\n#endif\n/* \n** END CODE GENERATED BY tool/mkctime.tcl \n*/\n};\n\nSQLITE_PRIVATE const char **sqlite3CompileOptions(int *pnOpt){\n  *pnOpt = sizeof(sqlite3azCompileOpt) / sizeof(sqlite3azCompileOpt[0]);\n  return (const char**)sqlite3azCompileOpt;\n}\n\n#endif /* SQLITE_OMIT_COMPILEOPTION_DIAGS */\n\n/************** End of ctime.c ***********************************************/\n/************** Begin file sqliteInt.h ***************************************/\n/*\n** 2001 September 15\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** Internal interface definitions for SQLite.\n**\n*/\n#ifndef SQLITEINT_H\n#define SQLITEINT_H\n\n/* Special Comments:\n**\n** Some comments have special meaning to the tools that measure test\n** coverage:\n**\n**    NO_TEST                     - The branches on this line are not\n**                                  measured by branch coverage.  This is\n**                                  used on lines of code that actually\n**                                  implement parts of coverage testing.\n**\n**    OPTIMIZATION-IF-TRUE        - This branch is allowed to alway be false\n**                                  and the correct answer is still obtained,\n**                                  though perhaps more slowly.\n**\n**    OPTIMIZATION-IF-FALSE       - This branch is allowed to alway be true\n**                                  and the correct answer is still obtained,\n**                                  though perhaps more slowly.\n**\n**    PREVENTS-HARMLESS-OVERREAD  - This branch prevents a buffer overread\n**                                  that would be harmless and undetectable\n**                                  if it did occur.  \n**\n** In all cases, the special comment must be enclosed in the usual\n** slash-asterisk...asterisk-slash comment marks, with no spaces between the \n** asterisks and the comment text.\n*/\n\n/*\n** Make sure the Tcl calling convention macro is defined.  This macro is\n** only used by test code and Tcl integration code.\n*/\n#ifndef SQLITE_TCLAPI\n#  define SQLITE_TCLAPI\n#endif\n\n/*\n** Include the header file used to customize the compiler options for MSVC.\n** This should be done first so that it can successfully prevent spurious\n** compiler warnings due to subsequent content in this file and other files\n** that are included by this file.\n*/\n/************** Include msvc.h in the middle of sqliteInt.h ******************/\n/************** Begin file msvc.h ********************************************/\n/*\n** 2015 January 12\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n******************************************************************************\n**\n** This file contains code that is specific to MSVC.\n*/\n#ifndef SQLITE_MSVC_H\n#define SQLITE_MSVC_H\n\n#if defined(_MSC_VER)\n#pragma warning(disable : 4054)\n#pragma warning(disable : 4055)\n#pragma warning(disable : 4100)\n#pragma warning(disable : 4127)\n#pragma warning(disable : 4130)\n#pragma warning(disable : 4152)\n#pragma warning(disable : 4189)\n#pragma warning(disable : 4206)\n#pragma warning(disable : 4210)\n#pragma warning(disable : 4232)\n#pragma warning(disable : 4244)\n#pragma warning(disable : 4305)\n#pragma warning(disable : 4306)\n#pragma warning(disable : 4702)\n#pragma warning(disable : 4706)\n#endif /* defined(_MSC_VER) */\n\n#endif /* SQLITE_MSVC_H */\n\n/************** End of msvc.h ************************************************/\n/************** Continuing where we left off in sqliteInt.h ******************/\n\n/*\n** Special setup for VxWorks\n*/\n/************** Include vxworks.h in the middle of sqliteInt.h ***************/\n/************** Begin file vxworks.h *****************************************/\n/*\n** 2015-03-02\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n******************************************************************************\n**\n** This file contains code that is specific to Wind River's VxWorks\n*/\n#if defined(__RTP__) || defined(_WRS_KERNEL)\n/* This is VxWorks.  Set up things specially for that OS\n*/\n#include <vxWorks.h>\n#include <pthread.h>  /* amalgamator: dontcache */\n#define OS_VXWORKS 1\n#define SQLITE_OS_OTHER 0\n#define SQLITE_HOMEGROWN_RECURSIVE_MUTEX 1\n#define SQLITE_OMIT_LOAD_EXTENSION 1\n#define SQLITE_ENABLE_LOCKING_STYLE 0\n#define HAVE_UTIME 1\n#else\n/* This is not VxWorks. */\n#define OS_VXWORKS 0\n#define HAVE_FCHOWN 1\n#define HAVE_READLINK 1\n#define HAVE_LSTAT 1\n#endif /* defined(_WRS_KERNEL) */\n\n/************** End of vxworks.h *********************************************/\n/************** Continuing where we left off in sqliteInt.h ******************/\n\n/*\n** These #defines should enable >2GB file support on POSIX if the\n** underlying operating system supports it.  If the OS lacks\n** large file support, or if the OS is windows, these should be no-ops.\n**\n** Ticket #2739:  The _LARGEFILE_SOURCE macro must appear before any\n** system #includes.  Hence, this block of code must be the very first\n** code in all source files.\n**\n** Large file support can be disabled using the -DSQLITE_DISABLE_LFS switch\n** on the compiler command line.  This is necessary if you are compiling\n** on a recent machine (ex: Red Hat 7.2) but you want your code to work\n** on an older machine (ex: Red Hat 6.0).  If you compile on Red Hat 7.2\n** without this option, LFS is enable.  But LFS does not exist in the kernel\n** in Red Hat 6.0, so the code won't work.  Hence, for maximum binary\n** portability you should omit LFS.\n**\n** The previous paragraph was written in 2005.  (This paragraph is written\n** on 2008-11-28.) These days, all Linux kernels support large files, so\n** you should probably leave LFS enabled.  But some embedded platforms might\n** lack LFS in which case the SQLITE_DISABLE_LFS macro might still be useful.\n**\n** Similar is true for Mac OS X.  LFS is only supported on Mac OS X 9 and later.\n*/\n#ifndef SQLITE_DISABLE_LFS\n# define _LARGE_FILE       1\n# ifndef _FILE_OFFSET_BITS\n#   define _FILE_OFFSET_BITS 64\n# endif\n# define _LARGEFILE_SOURCE 1\n#endif\n\n/* The GCC_VERSION and MSVC_VERSION macros are used to\n** conditionally include optimizations for each of these compilers.  A\n** value of 0 means that compiler is not being used.  The\n** SQLITE_DISABLE_INTRINSIC macro means do not use any compiler-specific\n** optimizations, and hence set all compiler macros to 0\n**\n** There was once also a CLANG_VERSION macro.  However, we learn that the\n** version numbers in clang are for \"marketing\" only and are inconsistent\n** and unreliable.  Fortunately, all versions of clang also recognize the\n** gcc version numbers and have reasonable settings for gcc version numbers,\n** so the GCC_VERSION macro will be set to a correct non-zero value even\n** when compiling with clang.\n*/\n#if defined(__GNUC__) && !defined(SQLITE_DISABLE_INTRINSIC)\n# define GCC_VERSION (__GNUC__*1000000+__GNUC_MINOR__*1000+__GNUC_PATCHLEVEL__)\n#else\n# define GCC_VERSION 0\n#endif\n#if defined(_MSC_VER) && !defined(SQLITE_DISABLE_INTRINSIC)\n# define MSVC_VERSION _MSC_VER\n#else\n# define MSVC_VERSION 0\n#endif\n\n/* Needed for various definitions... */\n#if defined(__GNUC__) && !defined(_GNU_SOURCE)\n# define _GNU_SOURCE\n#endif\n\n#if defined(__OpenBSD__) && !defined(_BSD_SOURCE)\n# define _BSD_SOURCE\n#endif\n\n/*\n** For MinGW, check to see if we can include the header file containing its\n** version information, among other things.  Normally, this internal MinGW\n** header file would [only] be included automatically by other MinGW header\n** files; however, the contained version information is now required by this\n** header file to work around binary compatibility issues (see below) and\n** this is the only known way to reliably obtain it.  This entire #if block\n** would be completely unnecessary if there was any other way of detecting\n** MinGW via their preprocessor (e.g. if they customized their GCC to define\n** some MinGW-specific macros).  When compiling for MinGW, either the\n** _HAVE_MINGW_H or _HAVE__MINGW_H (note the extra underscore) macro must be\n** defined; otherwise, detection of conditions specific to MinGW will be\n** disabled.\n*/\n#if defined(_HAVE_MINGW_H)\n# include \"mingw.h\"\n#elif defined(_HAVE__MINGW_H)\n# include \"_mingw.h\"\n#endif\n\n/*\n** For MinGW version 4.x (and higher), check to see if the _USE_32BIT_TIME_T\n** define is required to maintain binary compatibility with the MSVC runtime\n** library in use (e.g. for Windows XP).\n*/\n#if !defined(_USE_32BIT_TIME_T) && !defined(_USE_64BIT_TIME_T) && \\\n    defined(_WIN32) && !defined(_WIN64) && \\\n    defined(__MINGW_MAJOR_VERSION) && __MINGW_MAJOR_VERSION >= 4 && \\\n    defined(__MSVCRT__)\n# define _USE_32BIT_TIME_T\n#endif\n\n/* The public SQLite interface.  The _FILE_OFFSET_BITS macro must appear\n** first in QNX.  Also, the _USE_32BIT_TIME_T macro must appear first for\n** MinGW.\n*/\n/************** Include sqlite3.h in the middle of sqliteInt.h ***************/\n/************** Begin file sqlite3.h *****************************************/\n/*\n** 2001-09-15\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This header file defines the interface that the SQLite library\n** presents to client programs.  If a C-function, structure, datatype,\n** or constant definition does not appear in this file, then it is\n** not a published API of SQLite, is subject to change without\n** notice, and should not be referenced by programs that use SQLite.\n**\n** Some of the definitions that are in this file are marked as\n** \"experimental\".  Experimental interfaces are normally new\n** features recently added to SQLite.  We do not anticipate changes\n** to experimental interfaces but reserve the right to make minor changes\n** if experience from use \"in the wild\" suggest such changes are prudent.\n**\n** The official C-language API documentation for SQLite is derived\n** from comments in this file.  This file is the authoritative source\n** on how SQLite interfaces are supposed to operate.\n**\n** The name of this file under configuration management is \"sqlite.h.in\".\n** The makefile makes some minor changes to this file (such as inserting\n** the version number) and changes its name to \"sqlite3.h\" as\n** part of the build process.\n*/\n#ifndef SQLITE3_H\n#define SQLITE3_H\n#include <stdarg.h>     /* Needed for the definition of va_list */\n\n/*\n** Make sure we can call this stuff from C++.\n*/\n#if 0\nextern \"C\" {\n#endif\n\n\n/*\n** Provide the ability to override linkage features of the interface.\n*/\n#ifndef SQLITE_EXTERN\n# define SQLITE_EXTERN extern\n#endif\n#ifndef SQLITE_API\n# define SQLITE_API\n#endif\n#ifndef SQLITE_CDECL\n# define SQLITE_CDECL\n#endif\n#ifndef SQLITE_APICALL\n# define SQLITE_APICALL\n#endif\n#ifndef SQLITE_STDCALL\n# define SQLITE_STDCALL SQLITE_APICALL\n#endif\n#ifndef SQLITE_CALLBACK\n# define SQLITE_CALLBACK\n#endif\n#ifndef SQLITE_SYSAPI\n# define SQLITE_SYSAPI\n#endif\n\n/*\n** These no-op macros are used in front of interfaces to mark those\n** interfaces as either deprecated or experimental.  New applications\n** should not use deprecated interfaces - they are supported for backwards\n** compatibility only.  Application writers should be aware that\n** experimental interfaces are subject to change in point releases.\n**\n** These macros used to resolve to various kinds of compiler magic that\n** would generate warning messages when they were used.  But that\n** compiler magic ended up generating such a flurry of bug reports\n** that we have taken it all out and gone back to using simple\n** noop macros.\n*/\n#define SQLITE_DEPRECATED\n#define SQLITE_EXPERIMENTAL\n\n/*\n** Ensure these symbols were not defined by some previous header file.\n*/\n#ifdef SQLITE_VERSION\n# undef SQLITE_VERSION\n#endif\n#ifdef SQLITE_VERSION_NUMBER\n# undef SQLITE_VERSION_NUMBER\n#endif\n\n/*\n** CAPI3REF: Compile-Time Library Version Numbers\n**\n** ^(The [SQLITE_VERSION] C preprocessor macro in the sqlite3.h header\n** evaluates to a string literal that is the SQLite version in the\n** format \"X.Y.Z\" where X is the major version number (always 3 for\n** SQLite3) and Y is the minor version number and Z is the release number.)^\n** ^(The [SQLITE_VERSION_NUMBER] C preprocessor macro resolves to an integer\n** with the value (X*1000000 + Y*1000 + Z) where X, Y, and Z are the same\n** numbers used in [SQLITE_VERSION].)^\n** The SQLITE_VERSION_NUMBER for any given release of SQLite will also\n** be larger than the release from which it is derived.  Either Y will\n** be held constant and Z will be incremented or else Y will be incremented\n** and Z will be reset to zero.\n**\n** Since [version 3.6.18] ([dateof:3.6.18]), \n** SQLite source code has been stored in the\n** <a href=\"http://www.fossil-scm.org/\">Fossil configuration management\n** system</a>.  ^The SQLITE_SOURCE_ID macro evaluates to\n** a string which identifies a particular check-in of SQLite\n** within its configuration management system.  ^The SQLITE_SOURCE_ID\n** string contains the date and time of the check-in (UTC) and a SHA1\n** or SHA3-256 hash of the entire source tree.  If the source code has\n** been edited in any way since it was last checked in, then the last\n** four hexadecimal digits of the hash may be modified.\n**\n** See also: [sqlite3_libversion()],\n** [sqlite3_libversion_number()], [sqlite3_sourceid()],\n** [sqlite_version()] and [sqlite_source_id()].\n*/\n#define SQLITE_VERSION        \"3.27.2\"\n#define SQLITE_VERSION_NUMBER 3027002\n#define SQLITE_SOURCE_ID      \"2019-02-25 16:06:06 bd49a8271d650fa89e446b42e513b595a717b9212c91dd384aab871fc1d0alt1\"\n\n/*\n** CAPI3REF: Run-Time Library Version Numbers\n** KEYWORDS: sqlite3_version sqlite3_sourceid\n**\n** These interfaces provide the same information as the [SQLITE_VERSION],\n** [SQLITE_VERSION_NUMBER], and [SQLITE_SOURCE_ID] C preprocessor macros\n** but are associated with the library instead of the header file.  ^(Cautious\n** programmers might include assert() statements in their application to\n** verify that values returned by these interfaces match the macros in\n** the header, and thus ensure that the application is\n** compiled with matching library and header files.\n**\n** <blockquote><pre>\n** assert( sqlite3_libversion_number()==SQLITE_VERSION_NUMBER );\n** assert( strncmp(sqlite3_sourceid(),SQLITE_SOURCE_ID,80)==0 );\n** assert( strcmp(sqlite3_libversion(),SQLITE_VERSION)==0 );\n** </pre></blockquote>)^\n**\n** ^The sqlite3_version[] string constant contains the text of [SQLITE_VERSION]\n** macro.  ^The sqlite3_libversion() function returns a pointer to the\n** to the sqlite3_version[] string constant.  The sqlite3_libversion()\n** function is provided for use in DLLs since DLL users usually do not have\n** direct access to string constants within the DLL.  ^The\n** sqlite3_libversion_number() function returns an integer equal to\n** [SQLITE_VERSION_NUMBER].  ^(The sqlite3_sourceid() function returns \n** a pointer to a string constant whose value is the same as the \n** [SQLITE_SOURCE_ID] C preprocessor macro.  Except if SQLite is built\n** using an edited copy of [the amalgamation], then the last four characters\n** of the hash might be different from [SQLITE_SOURCE_ID].)^\n**\n** See also: [sqlite_version()] and [sqlite_source_id()].\n*/\nSQLITE_API const char sqlite3_version[] = SQLITE_VERSION;\nSQLITE_API const char *sqlite3_libversion(void);\nSQLITE_API const char *sqlite3_sourceid(void);\nSQLITE_API int sqlite3_libversion_number(void);\n\n/*\n** CAPI3REF: Run-Time Library Compilation Options Diagnostics\n**\n** ^The sqlite3_compileoption_used() function returns 0 or 1 \n** indicating whether the specified option was defined at \n** compile time.  ^The SQLITE_ prefix may be omitted from the \n** option name passed to sqlite3_compileoption_used().  \n**\n** ^The sqlite3_compileoption_get() function allows iterating\n** over the list of options that were defined at compile time by\n** returning the N-th compile time option string.  ^If N is out of range,\n** sqlite3_compileoption_get() returns a NULL pointer.  ^The SQLITE_ \n** prefix is omitted from any strings returned by \n** sqlite3_compileoption_get().\n**\n** ^Support for the diagnostic functions sqlite3_compileoption_used()\n** and sqlite3_compileoption_get() may be omitted by specifying the \n** [SQLITE_OMIT_COMPILEOPTION_DIAGS] option at compile time.\n**\n** See also: SQL functions [sqlite_compileoption_used()] and\n** [sqlite_compileoption_get()] and the [compile_options pragma].\n*/\n#ifndef SQLITE_OMIT_COMPILEOPTION_DIAGS\nSQLITE_API int sqlite3_compileoption_used(const char *zOptName);\nSQLITE_API const char *sqlite3_compileoption_get(int N);\n#endif\n\n/*\n** CAPI3REF: Test To See If The Library Is Threadsafe\n**\n** ^The sqlite3_threadsafe() function returns zero if and only if\n** SQLite was compiled with mutexing code omitted due to the\n** [SQLITE_THREADSAFE] compile-time option being set to 0.\n**\n** SQLite can be compiled with or without mutexes.  When\n** the [SQLITE_THREADSAFE] C preprocessor macro is 1 or 2, mutexes\n** are enabled and SQLite is threadsafe.  When the\n** [SQLITE_THREADSAFE] macro is 0, \n** the mutexes are omitted.  Without the mutexes, it is not safe\n** to use SQLite concurrently from more than one thread.\n**\n** Enabling mutexes incurs a measurable performance penalty.\n** So if speed is of utmost importance, it makes sense to disable\n** the mutexes.  But for maximum safety, mutexes should be enabled.\n** ^The default behavior is for mutexes to be enabled.\n**\n** This interface can be used by an application to make sure that the\n** version of SQLite that it is linking against was compiled with\n** the desired setting of the [SQLITE_THREADSAFE] macro.\n**\n** This interface only reports on the compile-time mutex setting\n** of the [SQLITE_THREADSAFE] flag.  If SQLite is compiled with\n** SQLITE_THREADSAFE=1 or =2 then mutexes are enabled by default but\n** can be fully or partially disabled using a call to [sqlite3_config()]\n** with the verbs [SQLITE_CONFIG_SINGLETHREAD], [SQLITE_CONFIG_MULTITHREAD],\n** or [SQLITE_CONFIG_SERIALIZED].  ^(The return value of the\n** sqlite3_threadsafe() function shows only the compile-time setting of\n** thread safety, not any run-time changes to that setting made by\n** sqlite3_config(). In other words, the return value from sqlite3_threadsafe()\n** is unchanged by calls to sqlite3_config().)^\n**\n** See the [threading mode] documentation for additional information.\n*/\nSQLITE_API int sqlite3_threadsafe(void);\n\n/*\n** CAPI3REF: Database Connection Handle\n** KEYWORDS: {database connection} {database connections}\n**\n** Each open SQLite database is represented by a pointer to an instance of\n** the opaque structure named \"sqlite3\".  It is useful to think of an sqlite3\n** pointer as an object.  The [sqlite3_open()], [sqlite3_open16()], and\n** [sqlite3_open_v2()] interfaces are its constructors, and [sqlite3_close()]\n** and [sqlite3_close_v2()] are its destructors.  There are many other\n** interfaces (such as\n** [sqlite3_prepare_v2()], [sqlite3_create_function()], and\n** [sqlite3_busy_timeout()] to name but three) that are methods on an\n** sqlite3 object.\n*/\ntypedef struct sqlite3 sqlite3;\n\n/*\n** CAPI3REF: 64-Bit Integer Types\n** KEYWORDS: sqlite_int64 sqlite_uint64\n**\n** Because there is no cross-platform way to specify 64-bit integer types\n** SQLite includes typedefs for 64-bit signed and unsigned integers.\n**\n** The sqlite3_int64 and sqlite3_uint64 are the preferred type definitions.\n** The sqlite_int64 and sqlite_uint64 types are supported for backwards\n** compatibility only.\n**\n** ^The sqlite3_int64 and sqlite_int64 types can store integer values\n** between -9223372036854775808 and +9223372036854775807 inclusive.  ^The\n** sqlite3_uint64 and sqlite_uint64 types can store integer values \n** between 0 and +18446744073709551615 inclusive.\n*/\n#ifdef SQLITE_INT64_TYPE\n  typedef SQLITE_INT64_TYPE sqlite_int64;\n# ifdef SQLITE_UINT64_TYPE\n    typedef SQLITE_UINT64_TYPE sqlite_uint64;\n# else  \n    typedef unsigned SQLITE_INT64_TYPE sqlite_uint64;\n# endif\n#elif defined(_MSC_VER) || defined(__BORLANDC__)\n  typedef __int64 sqlite_int64;\n  typedef unsigned __int64 sqlite_uint64;\n#else\n  typedef long long int sqlite_int64;\n  typedef unsigned long long int sqlite_uint64;\n#endif\ntypedef sqlite_int64 sqlite3_int64;\ntypedef sqlite_uint64 sqlite3_uint64;\n\n/*\n** If compiling for a processor that lacks floating point support,\n** substitute integer for floating-point.\n*/\n#ifdef SQLITE_OMIT_FLOATING_POINT\n# define double sqlite3_int64\n#endif\n\n/*\n** CAPI3REF: Closing A Database Connection\n** DESTRUCTOR: sqlite3\n**\n** ^The sqlite3_close() and sqlite3_close_v2() routines are destructors\n** for the [sqlite3] object.\n** ^Calls to sqlite3_close() and sqlite3_close_v2() return [SQLITE_OK] if\n** the [sqlite3] object is successfully destroyed and all associated\n** resources are deallocated.\n**\n** ^If the database connection is associated with unfinalized prepared\n** statements or unfinished sqlite3_backup objects then sqlite3_close()\n** will leave the database connection open and return [SQLITE_BUSY].\n** ^If sqlite3_close_v2() is called with unfinalized prepared statements\n** and/or unfinished sqlite3_backups, then the database connection becomes\n** an unusable \"zombie\" which will automatically be deallocated when the\n** last prepared statement is finalized or the last sqlite3_backup is\n** finished.  The sqlite3_close_v2() interface is intended for use with\n** host languages that are garbage collected, and where the order in which\n** destructors are called is arbitrary.\n**\n** Applications should [sqlite3_finalize | finalize] all [prepared statements],\n** [sqlite3_blob_close | close] all [BLOB handles], and \n** [sqlite3_backup_finish | finish] all [sqlite3_backup] objects associated\n** with the [sqlite3] object prior to attempting to close the object.  ^If\n** sqlite3_close_v2() is called on a [database connection] that still has\n** outstanding [prepared statements], [BLOB handles], and/or\n** [sqlite3_backup] objects then it returns [SQLITE_OK] and the deallocation\n** of resources is deferred until all [prepared statements], [BLOB handles],\n** and [sqlite3_backup] objects are also destroyed.\n**\n** ^If an [sqlite3] object is destroyed while a transaction is open,\n** the transaction is automatically rolled back.\n**\n** The C parameter to [sqlite3_close(C)] and [sqlite3_close_v2(C)]\n** must be either a NULL\n** pointer or an [sqlite3] object pointer obtained\n** from [sqlite3_open()], [sqlite3_open16()], or\n** [sqlite3_open_v2()], and not previously closed.\n** ^Calling sqlite3_close() or sqlite3_close_v2() with a NULL pointer\n** argument is a harmless no-op.\n*/\nSQLITE_API int sqlite3_close(sqlite3*);\nSQLITE_API int sqlite3_close_v2(sqlite3*);\n\n/*\n** The type for a callback function.\n** This is legacy and deprecated.  It is included for historical\n** compatibility and is not documented.\n*/\ntypedef int (*sqlite3_callback)(void*,int,char**, char**);\n\n/*\n** CAPI3REF: One-Step Query Execution Interface\n** METHOD: sqlite3\n**\n** The sqlite3_exec() interface is a convenience wrapper around\n** [sqlite3_prepare_v2()], [sqlite3_step()], and [sqlite3_finalize()],\n** that allows an application to run multiple statements of SQL\n** without having to use a lot of C code. \n**\n** ^The sqlite3_exec() interface runs zero or more UTF-8 encoded,\n** semicolon-separate SQL statements passed into its 2nd argument,\n** in the context of the [database connection] passed in as its 1st\n** argument.  ^If the callback function of the 3rd argument to\n** sqlite3_exec() is not NULL, then it is invoked for each result row\n** coming out of the evaluated SQL statements.  ^The 4th argument to\n** sqlite3_exec() is relayed through to the 1st argument of each\n** callback invocation.  ^If the callback pointer to sqlite3_exec()\n** is NULL, then no callback is ever invoked and result rows are\n** ignored.\n**\n** ^If an error occurs while evaluating the SQL statements passed into\n** sqlite3_exec(), then execution of the current statement stops and\n** subsequent statements are skipped.  ^If the 5th parameter to sqlite3_exec()\n** is not NULL then any error message is written into memory obtained\n** from [sqlite3_malloc()] and passed back through the 5th parameter.\n** To avoid memory leaks, the application should invoke [sqlite3_free()]\n** on error message strings returned through the 5th parameter of\n** sqlite3_exec() after the error message string is no longer needed.\n** ^If the 5th parameter to sqlite3_exec() is not NULL and no errors\n** occur, then sqlite3_exec() sets the pointer in its 5th parameter to\n** NULL before returning.\n**\n** ^If an sqlite3_exec() callback returns non-zero, the sqlite3_exec()\n** routine returns SQLITE_ABORT without invoking the callback again and\n** without running any subsequent SQL statements.\n**\n** ^The 2nd argument to the sqlite3_exec() callback function is the\n** number of columns in the result.  ^The 3rd argument to the sqlite3_exec()\n** callback is an array of pointers to strings obtained as if from\n** [sqlite3_column_text()], one for each column.  ^If an element of a\n** result row is NULL then the corresponding string pointer for the\n** sqlite3_exec() callback is a NULL pointer.  ^The 4th argument to the\n** sqlite3_exec() callback is an array of pointers to strings where each\n** entry represents the name of corresponding result column as obtained\n** from [sqlite3_column_name()].\n**\n** ^If the 2nd parameter to sqlite3_exec() is a NULL pointer, a pointer\n** to an empty string, or a pointer that contains only whitespace and/or \n** SQL comments, then no SQL statements are evaluated and the database\n** is not changed.\n**\n** Restrictions:\n**\n** <ul>\n** <li> The application must ensure that the 1st parameter to sqlite3_exec()\n**      is a valid and open [database connection].\n** <li> The application must not close the [database connection] specified by\n**      the 1st parameter to sqlite3_exec() while sqlite3_exec() is running.\n** <li> The application must not modify the SQL statement text passed into\n**      the 2nd parameter of sqlite3_exec() while sqlite3_exec() is running.\n** </ul>\n*/\nSQLITE_API int sqlite3_exec(\n  sqlite3*,                                  /* An open database */\n  const char *sql,                           /* SQL to be evaluated */\n  int (*callback)(void*,int,char**,char**),  /* Callback function */\n  void *,                                    /* 1st argument to callback */\n  char **errmsg                              /* Error msg written here */\n);\n\n/*\n** CAPI3REF: Result Codes\n** KEYWORDS: {result code definitions}\n**\n** Many SQLite functions return an integer result code from the set shown\n** here in order to indicate success or failure.\n**\n** New error codes may be added in future versions of SQLite.\n**\n** See also: [extended result code definitions]\n*/\n#define SQLITE_OK           0   /* Successful result */\n/* beginning-of-error-codes */\n#define SQLITE_ERROR        1   /* Generic error */\n#define SQLITE_INTERNAL     2   /* Internal logic error in SQLite */\n#define SQLITE_PERM         3   /* Access permission denied */\n#define SQLITE_ABORT        4   /* Callback routine requested an abort */\n#define SQLITE_BUSY         5   /* The database file is locked */\n#define SQLITE_LOCKED       6   /* A table in the database is locked */\n#define SQLITE_NOMEM        7   /* A malloc() failed */\n#define SQLITE_READONLY     8   /* Attempt to write a readonly database */\n#define SQLITE_INTERRUPT    9   /* Operation terminated by sqlite3_interrupt()*/\n#define SQLITE_IOERR       10   /* Some kind of disk I/O error occurred */\n#define SQLITE_CORRUPT     11   /* The database disk image is malformed */\n#define SQLITE_NOTFOUND    12   /* Unknown opcode in sqlite3_file_control() */\n#define SQLITE_FULL        13   /* Insertion failed because database is full */\n#define SQLITE_CANTOPEN    14   /* Unable to open the database file */\n#define SQLITE_PROTOCOL    15   /* Database lock protocol error */\n#define SQLITE_EMPTY       16   /* Internal use only */\n#define SQLITE_SCHEMA      17   /* The database schema changed */\n#define SQLITE_TOOBIG      18   /* String or BLOB exceeds size limit */\n#define SQLITE_CONSTRAINT  19   /* Abort due to constraint violation */\n#define SQLITE_MISMATCH    20   /* Data type mismatch */\n#define SQLITE_MISUSE      21   /* Library used incorrectly */\n#define SQLITE_NOLFS       22   /* Uses OS features not supported on host */\n#define SQLITE_AUTH        23   /* Authorization denied */\n#define SQLITE_FORMAT      24   /* Not used */\n#define SQLITE_RANGE       25   /* 2nd parameter to sqlite3_bind out of range */\n#define SQLITE_NOTADB      26   /* File opened that is not a database file */\n#define SQLITE_NOTICE      27   /* Notifications from sqlite3_log() */\n#define SQLITE_WARNING     28   /* Warnings from sqlite3_log() */\n#define SQLITE_ROW         100  /* sqlite3_step() has another row ready */\n#define SQLITE_DONE        101  /* sqlite3_step() has finished executing */\n/* end-of-error-codes */\n\n/*\n** CAPI3REF: Extended Result Codes\n** KEYWORDS: {extended result code definitions}\n**\n** In its default configuration, SQLite API routines return one of 30 integer\n** [result codes].  However, experience has shown that many of\n** these result codes are too coarse-grained.  They do not provide as\n** much information about problems as programmers might like.  In an effort to\n** address this, newer versions of SQLite (version 3.3.8 [dateof:3.3.8]\n** and later) include\n** support for additional result codes that provide more detailed information\n** about errors. These [extended result codes] are enabled or disabled\n** on a per database connection basis using the\n** [sqlite3_extended_result_codes()] API.  Or, the extended code for\n** the most recent error can be obtained using\n** [sqlite3_extended_errcode()].\n*/\n#define SQLITE_ERROR_MISSING_COLLSEQ   (SQLITE_ERROR | (1<<8))\n#define SQLITE_ERROR_RETRY             (SQLITE_ERROR | (2<<8))\n#define SQLITE_ERROR_SNAPSHOT          (SQLITE_ERROR | (3<<8))\n#define SQLITE_IOERR_READ              (SQLITE_IOERR | (1<<8))\n#define SQLITE_IOERR_SHORT_READ        (SQLITE_IOERR | (2<<8))\n#define SQLITE_IOERR_WRITE             (SQLITE_IOERR | (3<<8))\n#define SQLITE_IOERR_FSYNC             (SQLITE_IOERR | (4<<8))\n#define SQLITE_IOERR_DIR_FSYNC         (SQLITE_IOERR | (5<<8))\n#define SQLITE_IOERR_TRUNCATE          (SQLITE_IOERR | (6<<8))\n#define SQLITE_IOERR_FSTAT             (SQLITE_IOERR | (7<<8))\n#define SQLITE_IOERR_UNLOCK            (SQLITE_IOERR | (8<<8))\n#define SQLITE_IOERR_RDLOCK            (SQLITE_IOERR | (9<<8))\n#define SQLITE_IOERR_DELETE            (SQLITE_IOERR | (10<<8))\n#define SQLITE_IOERR_BLOCKED           (SQLITE_IOERR | (11<<8))\n#define SQLITE_IOERR_NOMEM             (SQLITE_IOERR | (12<<8))\n#define SQLITE_IOERR_ACCESS            (SQLITE_IOERR | (13<<8))\n#define SQLITE_IOERR_CHECKRESERVEDLOCK (SQLITE_IOERR | (14<<8))\n#define SQLITE_IOERR_LOCK              (SQLITE_IOERR | (15<<8))\n#define SQLITE_IOERR_CLOSE             (SQLITE_IOERR | (16<<8))\n#define SQLITE_IOERR_DIR_CLOSE         (SQLITE_IOERR | (17<<8))\n#define SQLITE_IOERR_SHMOPEN           (SQLITE_IOERR | (18<<8))\n#define SQLITE_IOERR_SHMSIZE           (SQLITE_IOERR | (19<<8))\n#define SQLITE_IOERR_SHMLOCK           (SQLITE_IOERR | (20<<8))\n#define SQLITE_IOERR_SHMMAP            (SQLITE_IOERR | (21<<8))\n#define SQLITE_IOERR_SEEK              (SQLITE_IOERR | (22<<8))\n#define SQLITE_IOERR_DELETE_NOENT      (SQLITE_IOERR | (23<<8))\n#define SQLITE_IOERR_MMAP              (SQLITE_IOERR | (24<<8))\n#define SQLITE_IOERR_GETTEMPPATH       (SQLITE_IOERR | (25<<8))\n#define SQLITE_IOERR_CONVPATH          (SQLITE_IOERR | (26<<8))\n#define SQLITE_IOERR_VNODE             (SQLITE_IOERR | (27<<8))\n#define SQLITE_IOERR_AUTH              (SQLITE_IOERR | (28<<8))\n#define SQLITE_IOERR_BEGIN_ATOMIC      (SQLITE_IOERR | (29<<8))\n#define SQLITE_IOERR_COMMIT_ATOMIC     (SQLITE_IOERR | (30<<8))\n#define SQLITE_IOERR_ROLLBACK_ATOMIC   (SQLITE_IOERR | (31<<8))\n#define SQLITE_LOCKED_SHAREDCACHE      (SQLITE_LOCKED |  (1<<8))\n#define SQLITE_LOCKED_VTAB             (SQLITE_LOCKED |  (2<<8))\n#define SQLITE_BUSY_RECOVERY           (SQLITE_BUSY   |  (1<<8))\n#define SQLITE_BUSY_SNAPSHOT           (SQLITE_BUSY   |  (2<<8))\n#define SQLITE_CANTOPEN_NOTEMPDIR      (SQLITE_CANTOPEN | (1<<8))\n#define SQLITE_CANTOPEN_ISDIR          (SQLITE_CANTOPEN | (2<<8))\n#define SQLITE_CANTOPEN_FULLPATH       (SQLITE_CANTOPEN | (3<<8))\n#define SQLITE_CANTOPEN_CONVPATH       (SQLITE_CANTOPEN | (4<<8))\n#define SQLITE_CANTOPEN_DIRTYWAL       (SQLITE_CANTOPEN | (5<<8)) /* Not Used */\n#define SQLITE_CORRUPT_VTAB            (SQLITE_CORRUPT | (1<<8))\n#define SQLITE_CORRUPT_SEQUENCE        (SQLITE_CORRUPT | (2<<8))\n#define SQLITE_READONLY_RECOVERY       (SQLITE_READONLY | (1<<8))\n#define SQLITE_READONLY_CANTLOCK       (SQLITE_READONLY | (2<<8))\n#define SQLITE_READONLY_ROLLBACK       (SQLITE_READONLY | (3<<8))\n#define SQLITE_READONLY_DBMOVED        (SQLITE_READONLY | (4<<8))\n#define SQLITE_READONLY_CANTINIT       (SQLITE_READONLY | (5<<8))\n#define SQLITE_READONLY_DIRECTORY      (SQLITE_READONLY | (6<<8))\n#define SQLITE_ABORT_ROLLBACK          (SQLITE_ABORT | (2<<8))\n#define SQLITE_CONSTRAINT_CHECK        (SQLITE_CONSTRAINT | (1<<8))\n#define SQLITE_CONSTRAINT_COMMITHOOK   (SQLITE_CONSTRAINT | (2<<8))\n#define SQLITE_CONSTRAINT_FOREIGNKEY   (SQLITE_CONSTRAINT | (3<<8))\n#define SQLITE_CONSTRAINT_FUNCTION     (SQLITE_CONSTRAINT | (4<<8))\n#define SQLITE_CONSTRAINT_NOTNULL      (SQLITE_CONSTRAINT | (5<<8))\n#define SQLITE_CONSTRAINT_PRIMARYKEY   (SQLITE_CONSTRAINT | (6<<8))\n#define SQLITE_CONSTRAINT_TRIGGER      (SQLITE_CONSTRAINT | (7<<8))\n#define SQLITE_CONSTRAINT_UNIQUE       (SQLITE_CONSTRAINT | (8<<8))\n#define SQLITE_CONSTRAINT_VTAB         (SQLITE_CONSTRAINT | (9<<8))\n#define SQLITE_CONSTRAINT_ROWID        (SQLITE_CONSTRAINT |(10<<8))\n#define SQLITE_NOTICE_RECOVER_WAL      (SQLITE_NOTICE | (1<<8))\n#define SQLITE_NOTICE_RECOVER_ROLLBACK (SQLITE_NOTICE | (2<<8))\n#define SQLITE_WARNING_AUTOINDEX       (SQLITE_WARNING | (1<<8))\n#define SQLITE_AUTH_USER               (SQLITE_AUTH | (1<<8))\n#define SQLITE_OK_LOAD_PERMANENTLY     (SQLITE_OK | (1<<8))\n\n/*\n** CAPI3REF: Flags For File Open Operations\n**\n** These bit values are intended for use in the\n** 3rd parameter to the [sqlite3_open_v2()] interface and\n** in the 4th parameter to the [sqlite3_vfs.xOpen] method.\n*/\n#define SQLITE_OPEN_READONLY         0x00000001  /* Ok for sqlite3_open_v2() */\n#define SQLITE_OPEN_READWRITE        0x00000002  /* Ok for sqlite3_open_v2() */\n#define SQLITE_OPEN_CREATE           0x00000004  /* Ok for sqlite3_open_v2() */\n#define SQLITE_OPEN_DELETEONCLOSE    0x00000008  /* VFS only */\n#define SQLITE_OPEN_EXCLUSIVE        0x00000010  /* VFS only */\n#define SQLITE_OPEN_AUTOPROXY        0x00000020  /* VFS only */\n#define SQLITE_OPEN_URI              0x00000040  /* Ok for sqlite3_open_v2() */\n#define SQLITE_OPEN_MEMORY           0x00000080  /* Ok for sqlite3_open_v2() */\n#define SQLITE_OPEN_MAIN_DB          0x00000100  /* VFS only */\n#define SQLITE_OPEN_TEMP_DB          0x00000200  /* VFS only */\n#define SQLITE_OPEN_TRANSIENT_DB     0x00000400  /* VFS only */\n#define SQLITE_OPEN_MAIN_JOURNAL     0x00000800  /* VFS only */\n#define SQLITE_OPEN_TEMP_JOURNAL     0x00001000  /* VFS only */\n#define SQLITE_OPEN_SUBJOURNAL       0x00002000  /* VFS only */\n#define SQLITE_OPEN_MASTER_JOURNAL   0x00004000  /* VFS only */\n#define SQLITE_OPEN_NOMUTEX          0x00008000  /* Ok for sqlite3_open_v2() */\n#define SQLITE_OPEN_FULLMUTEX        0x00010000  /* Ok for sqlite3_open_v2() */\n#define SQLITE_OPEN_SHAREDCACHE      0x00020000  /* Ok for sqlite3_open_v2() */\n#define SQLITE_OPEN_PRIVATECACHE     0x00040000  /* Ok for sqlite3_open_v2() */\n#define SQLITE_OPEN_WAL              0x00080000  /* VFS only */\n#define SQLITE_OPEN_MAINDB_READONLY  0x00100000  /* Main db readonly */\n\n/* Reserved:                         0x00F00000 */\n\n/*\n** CAPI3REF: Device Characteristics\n**\n** The xDeviceCharacteristics method of the [sqlite3_io_methods]\n** object returns an integer which is a vector of these\n** bit values expressing I/O characteristics of the mass storage\n** device that holds the file that the [sqlite3_io_methods]\n** refers to.\n**\n** The SQLITE_IOCAP_ATOMIC property means that all writes of\n** any size are atomic.  The SQLITE_IOCAP_ATOMICnnn values\n** mean that writes of blocks that are nnn bytes in size and\n** are aligned to an address which is an integer multiple of\n** nnn are atomic.  The SQLITE_IOCAP_SAFE_APPEND value means\n** that when data is appended to a file, the data is appended\n** first then the size of the file is extended, never the other\n** way around.  The SQLITE_IOCAP_SEQUENTIAL property means that\n** information is written to disk in the same order as calls\n** to xWrite().  The SQLITE_IOCAP_POWERSAFE_OVERWRITE property means that\n** after reboot following a crash or power loss, the only bytes in a\n** file that were written at the application level might have changed\n** and that adjacent bytes, even bytes within the same sector are\n** guaranteed to be unchanged.  The SQLITE_IOCAP_UNDELETABLE_WHEN_OPEN\n** flag indicates that a file cannot be deleted when open.  The\n** SQLITE_IOCAP_IMMUTABLE flag indicates that the file is on\n** read-only media and cannot be changed even by processes with\n** elevated privileges.\n**\n** The SQLITE_IOCAP_BATCH_ATOMIC property means that the underlying\n** filesystem supports doing multiple write operations atomically when those\n** write operations are bracketed by [SQLITE_FCNTL_BEGIN_ATOMIC_WRITE] and\n** [SQLITE_FCNTL_COMMIT_ATOMIC_WRITE].\n*/\n#define SQLITE_IOCAP_ATOMIC                 0x00000001\n#define SQLITE_IOCAP_ATOMIC512              0x00000002\n#define SQLITE_IOCAP_ATOMIC1K               0x00000004\n#define SQLITE_IOCAP_ATOMIC2K               0x00000008\n#define SQLITE_IOCAP_ATOMIC4K               0x00000010\n#define SQLITE_IOCAP_ATOMIC8K               0x00000020\n#define SQLITE_IOCAP_ATOMIC16K              0x00000040\n#define SQLITE_IOCAP_ATOMIC32K              0x00000080\n#define SQLITE_IOCAP_ATOMIC64K              0x00000100\n#define SQLITE_IOCAP_SAFE_APPEND            0x00000200\n#define SQLITE_IOCAP_SEQUENTIAL             0x00000400\n#define SQLITE_IOCAP_UNDELETABLE_WHEN_OPEN  0x00000800\n#define SQLITE_IOCAP_POWERSAFE_OVERWRITE    0x00001000\n#define SQLITE_IOCAP_IMMUTABLE              0x00002000\n#define SQLITE_IOCAP_BATCH_ATOMIC           0x00004000\n\n/*\n** CAPI3REF: File Locking Levels\n**\n** SQLite uses one of these integer values as the second\n** argument to calls it makes to the xLock() and xUnlock() methods\n** of an [sqlite3_io_methods] object.\n*/\n#define SQLITE_LOCK_NONE          0\n#define SQLITE_LOCK_SHARED        1\n#define SQLITE_LOCK_RESERVED      2\n#define SQLITE_LOCK_PENDING       3\n#define SQLITE_LOCK_EXCLUSIVE     4\n\n/*\n** CAPI3REF: Synchronization Type Flags\n**\n** When SQLite invokes the xSync() method of an\n** [sqlite3_io_methods] object it uses a combination of\n** these integer values as the second argument.\n**\n** When the SQLITE_SYNC_DATAONLY flag is used, it means that the\n** sync operation only needs to flush data to mass storage.  Inode\n** information need not be flushed. If the lower four bits of the flag\n** equal SQLITE_SYNC_NORMAL, that means to use normal fsync() semantics.\n** If the lower four bits equal SQLITE_SYNC_FULL, that means\n** to use Mac OS X style fullsync instead of fsync().\n**\n** Do not confuse the SQLITE_SYNC_NORMAL and SQLITE_SYNC_FULL flags\n** with the [PRAGMA synchronous]=NORMAL and [PRAGMA synchronous]=FULL\n** settings.  The [synchronous pragma] determines when calls to the\n** xSync VFS method occur and applies uniformly across all platforms.\n** The SQLITE_SYNC_NORMAL and SQLITE_SYNC_FULL flags determine how\n** energetic or rigorous or forceful the sync operations are and\n** only make a difference on Mac OSX for the default SQLite code.\n** (Third-party VFS implementations might also make the distinction\n** between SQLITE_SYNC_NORMAL and SQLITE_SYNC_FULL, but among the\n** operating systems natively supported by SQLite, only Mac OSX\n** cares about the difference.)\n*/\n#define SQLITE_SYNC_NORMAL        0x00002\n#define SQLITE_SYNC_FULL          0x00003\n#define SQLITE_SYNC_DATAONLY      0x00010\n\n/*\n** CAPI3REF: OS Interface Open File Handle\n**\n** An [sqlite3_file] object represents an open file in the \n** [sqlite3_vfs | OS interface layer].  Individual OS interface\n** implementations will\n** want to subclass this object by appending additional fields\n** for their own use.  The pMethods entry is a pointer to an\n** [sqlite3_io_methods] object that defines methods for performing\n** I/O operations on the open file.\n*/\ntypedef struct sqlite3_file sqlite3_file;\nstruct sqlite3_file {\n  const struct sqlite3_io_methods *pMethods;  /* Methods for an open file */\n};\n\n/*\n** CAPI3REF: OS Interface File Virtual Methods Object\n**\n** Every file opened by the [sqlite3_vfs.xOpen] method populates an\n** [sqlite3_file] object (or, more commonly, a subclass of the\n** [sqlite3_file] object) with a pointer to an instance of this object.\n** This object defines the methods used to perform various operations\n** against the open file represented by the [sqlite3_file] object.\n**\n** If the [sqlite3_vfs.xOpen] method sets the sqlite3_file.pMethods element \n** to a non-NULL pointer, then the sqlite3_io_methods.xClose method\n** may be invoked even if the [sqlite3_vfs.xOpen] reported that it failed.  The\n** only way to prevent a call to xClose following a failed [sqlite3_vfs.xOpen]\n** is for the [sqlite3_vfs.xOpen] to set the sqlite3_file.pMethods element\n** to NULL.\n**\n** The flags argument to xSync may be one of [SQLITE_SYNC_NORMAL] or\n** [SQLITE_SYNC_FULL].  The first choice is the normal fsync().\n** The second choice is a Mac OS X style fullsync.  The [SQLITE_SYNC_DATAONLY]\n** flag may be ORed in to indicate that only the data of the file\n** and not its inode needs to be synced.\n**\n** The integer values to xLock() and xUnlock() are one of\n** <ul>\n** <li> [SQLITE_LOCK_NONE],\n** <li> [SQLITE_LOCK_SHARED],\n** <li> [SQLITE_LOCK_RESERVED],\n** <li> [SQLITE_LOCK_PENDING], or\n** <li> [SQLITE_LOCK_EXCLUSIVE].\n** </ul>\n** xLock() increases the lock. xUnlock() decreases the lock.\n** The xCheckReservedLock() method checks whether any database connection,\n** either in this process or in some other process, is holding a RESERVED,\n** PENDING, or EXCLUSIVE lock on the file.  It returns true\n** if such a lock exists and false otherwise.\n**\n** The xFileControl() method is a generic interface that allows custom\n** VFS implementations to directly control an open file using the\n** [sqlite3_file_control()] interface.  The second \"op\" argument is an\n** integer opcode.  The third argument is a generic pointer intended to\n** point to a structure that may contain arguments or space in which to\n** write return values.  Potential uses for xFileControl() might be\n** functions to enable blocking locks with timeouts, to change the\n** locking strategy (for example to use dot-file locks), to inquire\n** about the status of a lock, or to break stale locks.  The SQLite\n** core reserves all opcodes less than 100 for its own use.\n** A [file control opcodes | list of opcodes] less than 100 is available.\n** Applications that define a custom xFileControl method should use opcodes\n** greater than 100 to avoid conflicts.  VFS implementations should\n** return [SQLITE_NOTFOUND] for file control opcodes that they do not\n** recognize.\n**\n** The xSectorSize() method returns the sector size of the\n** device that underlies the file.  The sector size is the\n** minimum write that can be performed without disturbing\n** other bytes in the file.  The xDeviceCharacteristics()\n** method returns a bit vector describing behaviors of the\n** underlying device:\n**\n** <ul>\n** <li> [SQLITE_IOCAP_ATOMIC]\n** <li> [SQLITE_IOCAP_ATOMIC512]\n** <li> [SQLITE_IOCAP_ATOMIC1K]\n** <li> [SQLITE_IOCAP_ATOMIC2K]\n** <li> [SQLITE_IOCAP_ATOMIC4K]\n** <li> [SQLITE_IOCAP_ATOMIC8K]\n** <li> [SQLITE_IOCAP_ATOMIC16K]\n** <li> [SQLITE_IOCAP_ATOMIC32K]\n** <li> [SQLITE_IOCAP_ATOMIC64K]\n** <li> [SQLITE_IOCAP_SAFE_APPEND]\n** <li> [SQLITE_IOCAP_SEQUENTIAL]\n** <li> [SQLITE_IOCAP_UNDELETABLE_WHEN_OPEN]\n** <li> [SQLITE_IOCAP_POWERSAFE_OVERWRITE]\n** <li> [SQLITE_IOCAP_IMMUTABLE]\n** <li> [SQLITE_IOCAP_BATCH_ATOMIC]\n** </ul>\n**\n** The SQLITE_IOCAP_ATOMIC property means that all writes of\n** any size are atomic.  The SQLITE_IOCAP_ATOMICnnn values\n** mean that writes of blocks that are nnn bytes in size and\n** are aligned to an address which is an integer multiple of\n** nnn are atomic.  The SQLITE_IOCAP_SAFE_APPEND value means\n** that when data is appended to a file, the data is appended\n** first then the size of the file is extended, never the other\n** way around.  The SQLITE_IOCAP_SEQUENTIAL property means that\n** information is written to disk in the same order as calls\n** to xWrite().\n**\n** If xRead() returns SQLITE_IOERR_SHORT_READ it must also fill\n** in the unread portions of the buffer with zeros.  A VFS that\n** fails to zero-fill short reads might seem to work.  However,\n** failure to zero-fill short reads will eventually lead to\n** database corruption.\n*/\ntypedef struct sqlite3_io_methods sqlite3_io_methods;\nstruct sqlite3_io_methods {\n  int iVersion;\n  int (*xClose)(sqlite3_file*);\n  int (*xRead)(sqlite3_file*, void*, int iAmt, sqlite3_int64 iOfst);\n  int (*xWrite)(sqlite3_file*, const void*, int iAmt, sqlite3_int64 iOfst);\n  int (*xTruncate)(sqlite3_file*, sqlite3_int64 size);\n  int (*xSync)(sqlite3_file*, int flags);\n  int (*xFileSize)(sqlite3_file*, sqlite3_int64 *pSize);\n  int (*xLock)(sqlite3_file*, int);\n  int (*xUnlock)(sqlite3_file*, int);\n  int (*xCheckReservedLock)(sqlite3_file*, int *pResOut);\n  int (*xFileControl)(sqlite3_file*, int op, void *pArg);\n  int (*xSectorSize)(sqlite3_file*);\n  int (*xDeviceCharacteristics)(sqlite3_file*);\n  /* Methods above are valid for version 1 */\n  int (*xShmMap)(sqlite3_file*, int iPg, int pgsz, int, void volatile**);\n  int (*xShmLock)(sqlite3_file*, int offset, int n, int flags);\n  void (*xShmBarrier)(sqlite3_file*);\n  int (*xShmUnmap)(sqlite3_file*, int deleteFlag);\n  /* Methods above are valid for version 2 */\n  int (*xFetch)(sqlite3_file*, sqlite3_int64 iOfst, int iAmt, void **pp);\n  int (*xUnfetch)(sqlite3_file*, sqlite3_int64 iOfst, void *p);\n  /* Methods above are valid for version 3 */\n  /* Additional methods may be added in future releases */\n};\n\n/*\n** CAPI3REF: Standard File Control Opcodes\n** KEYWORDS: {file control opcodes} {file control opcode}\n**\n** These integer constants are opcodes for the xFileControl method\n** of the [sqlite3_io_methods] object and for the [sqlite3_file_control()]\n** interface.\n**\n** <ul>\n** <li>[[SQLITE_FCNTL_LOCKSTATE]]\n** The [SQLITE_FCNTL_LOCKSTATE] opcode is used for debugging.  This\n** opcode causes the xFileControl method to write the current state of\n** the lock (one of [SQLITE_LOCK_NONE], [SQLITE_LOCK_SHARED],\n** [SQLITE_LOCK_RESERVED], [SQLITE_LOCK_PENDING], or [SQLITE_LOCK_EXCLUSIVE])\n** into an integer that the pArg argument points to. This capability\n** is used during testing and is only available when the SQLITE_TEST\n** compile-time option is used.\n**\n** <li>[[SQLITE_FCNTL_SIZE_HINT]]\n** The [SQLITE_FCNTL_SIZE_HINT] opcode is used by SQLite to give the VFS\n** layer a hint of how large the database file will grow to be during the\n** current transaction.  This hint is not guaranteed to be accurate but it\n** is often close.  The underlying VFS might choose to preallocate database\n** file space based on this hint in order to help writes to the database\n** file run faster.\n**\n** <li>[[SQLITE_FCNTL_SIZE_LIMIT]]\n** The [SQLITE_FCNTL_SIZE_LIMIT] opcode is used by in-memory VFS that\n** implements [sqlite3_deserialize()] to set an upper bound on the size\n** of the in-memory database.  The argument is a pointer to a [sqlite3_int64].\n** If the integer pointed to is negative, then it is filled in with the\n** current limit.  Otherwise the limit is set to the larger of the value\n** of the integer pointed to and the current database size.  The integer\n** pointed to is set to the new limit.\n**\n** <li>[[SQLITE_FCNTL_CHUNK_SIZE]]\n** The [SQLITE_FCNTL_CHUNK_SIZE] opcode is used to request that the VFS\n** extends and truncates the database file in chunks of a size specified\n** by the user. The fourth argument to [sqlite3_file_control()] should \n** point to an integer (type int) containing the new chunk-size to use\n** for the nominated database. Allocating database file space in large\n** chunks (say 1MB at a time), may reduce file-system fragmentation and\n** improve performance on some systems.\n**\n** <li>[[SQLITE_FCNTL_FILE_POINTER]]\n** The [SQLITE_FCNTL_FILE_POINTER] opcode is used to obtain a pointer\n** to the [sqlite3_file] object associated with a particular database\n** connection.  See also [SQLITE_FCNTL_JOURNAL_POINTER].\n**\n** <li>[[SQLITE_FCNTL_JOURNAL_POINTER]]\n** The [SQLITE_FCNTL_JOURNAL_POINTER] opcode is used to obtain a pointer\n** to the [sqlite3_file] object associated with the journal file (either\n** the [rollback journal] or the [write-ahead log]) for a particular database\n** connection.  See also [SQLITE_FCNTL_FILE_POINTER].\n**\n** <li>[[SQLITE_FCNTL_SYNC_OMITTED]]\n** No longer in use.\n**\n** <li>[[SQLITE_FCNTL_SYNC]]\n** The [SQLITE_FCNTL_SYNC] opcode is generated internally by SQLite and\n** sent to the VFS immediately before the xSync method is invoked on a\n** database file descriptor. Or, if the xSync method is not invoked \n** because the user has configured SQLite with \n** [PRAGMA synchronous | PRAGMA synchronous=OFF] it is invoked in place \n** of the xSync method. In most cases, the pointer argument passed with\n** this file-control is NULL. However, if the database file is being synced\n** as part of a multi-database commit, the argument points to a nul-terminated\n** string containing the transactions master-journal file name. VFSes that \n** do not need this signal should silently ignore this opcode. Applications \n** should not call [sqlite3_file_control()] with this opcode as doing so may \n** disrupt the operation of the specialized VFSes that do require it.  \n**\n** <li>[[SQLITE_FCNTL_COMMIT_PHASETWO]]\n** The [SQLITE_FCNTL_COMMIT_PHASETWO] opcode is generated internally by SQLite\n** and sent to the VFS after a transaction has been committed immediately\n** but before the database is unlocked. VFSes that do not need this signal\n** should silently ignore this opcode. Applications should not call\n** [sqlite3_file_control()] with this opcode as doing so may disrupt the \n** operation of the specialized VFSes that do require it.  \n**\n** <li>[[SQLITE_FCNTL_WIN32_AV_RETRY]]\n** ^The [SQLITE_FCNTL_WIN32_AV_RETRY] opcode is used to configure automatic\n** retry counts and intervals for certain disk I/O operations for the\n** windows [VFS] in order to provide robustness in the presence of\n** anti-virus programs.  By default, the windows VFS will retry file read,\n** file write, and file delete operations up to 10 times, with a delay\n** of 25 milliseconds before the first retry and with the delay increasing\n** by an additional 25 milliseconds with each subsequent retry.  This\n** opcode allows these two values (10 retries and 25 milliseconds of delay)\n** to be adjusted.  The values are changed for all database connections\n** within the same process.  The argument is a pointer to an array of two\n** integers where the first integer is the new retry count and the second\n** integer is the delay.  If either integer is negative, then the setting\n** is not changed but instead the prior value of that setting is written\n** into the array entry, allowing the current retry settings to be\n** interrogated.  The zDbName parameter is ignored.\n**\n** <li>[[SQLITE_FCNTL_PERSIST_WAL]]\n** ^The [SQLITE_FCNTL_PERSIST_WAL] opcode is used to set or query the\n** persistent [WAL | Write Ahead Log] setting.  By default, the auxiliary\n** write ahead log ([WAL file]) and shared memory\n** files used for transaction control\n** are automatically deleted when the latest connection to the database\n** closes.  Setting persistent WAL mode causes those files to persist after\n** close.  Persisting the files is useful when other processes that do not\n** have write permission on the directory containing the database file want\n** to read the database file, as the WAL and shared memory files must exist\n** in order for the database to be readable.  The fourth parameter to\n** [sqlite3_file_control()] for this opcode should be a pointer to an integer.\n** That integer is 0 to disable persistent WAL mode or 1 to enable persistent\n** WAL mode.  If the integer is -1, then it is overwritten with the current\n** WAL persistence setting.\n**\n** <li>[[SQLITE_FCNTL_POWERSAFE_OVERWRITE]]\n** ^The [SQLITE_FCNTL_POWERSAFE_OVERWRITE] opcode is used to set or query the\n** persistent \"powersafe-overwrite\" or \"PSOW\" setting.  The PSOW setting\n** determines the [SQLITE_IOCAP_POWERSAFE_OVERWRITE] bit of the\n** xDeviceCharacteristics methods. The fourth parameter to\n** [sqlite3_file_control()] for this opcode should be a pointer to an integer.\n** That integer is 0 to disable zero-damage mode or 1 to enable zero-damage\n** mode.  If the integer is -1, then it is overwritten with the current\n** zero-damage mode setting.\n**\n** <li>[[SQLITE_FCNTL_OVERWRITE]]\n** ^The [SQLITE_FCNTL_OVERWRITE] opcode is invoked by SQLite after opening\n** a write transaction to indicate that, unless it is rolled back for some\n** reason, the entire database file will be overwritten by the current \n** transaction. This is used by VACUUM operations.\n**\n** <li>[[SQLITE_FCNTL_VFSNAME]]\n** ^The [SQLITE_FCNTL_VFSNAME] opcode can be used to obtain the names of\n** all [VFSes] in the VFS stack.  The names are of all VFS shims and the\n** final bottom-level VFS are written into memory obtained from \n** [sqlite3_malloc()] and the result is stored in the char* variable\n** that the fourth parameter of [sqlite3_file_control()] points to.\n** The caller is responsible for freeing the memory when done.  As with\n** all file-control actions, there is no guarantee that this will actually\n** do anything.  Callers should initialize the char* variable to a NULL\n** pointer in case this file-control is not implemented.  This file-control\n** is intended for diagnostic use only.\n**\n** <li>[[SQLITE_FCNTL_VFS_POINTER]]\n** ^The [SQLITE_FCNTL_VFS_POINTER] opcode finds a pointer to the top-level\n** [VFSes] currently in use.  ^(The argument X in\n** sqlite3_file_control(db,SQLITE_FCNTL_VFS_POINTER,X) must be\n** of type \"[sqlite3_vfs] **\".  This opcodes will set *X\n** to a pointer to the top-level VFS.)^\n** ^When there are multiple VFS shims in the stack, this opcode finds the\n** upper-most shim only.\n**\n** <li>[[SQLITE_FCNTL_PRAGMA]]\n** ^Whenever a [PRAGMA] statement is parsed, an [SQLITE_FCNTL_PRAGMA] \n** file control is sent to the open [sqlite3_file] object corresponding\n** to the database file to which the pragma statement refers. ^The argument\n** to the [SQLITE_FCNTL_PRAGMA] file control is an array of\n** pointers to strings (char**) in which the second element of the array\n** is the name of the pragma and the third element is the argument to the\n** pragma or NULL if the pragma has no argument.  ^The handler for an\n** [SQLITE_FCNTL_PRAGMA] file control can optionally make the first element\n** of the char** argument point to a string obtained from [sqlite3_mprintf()]\n** or the equivalent and that string will become the result of the pragma or\n** the error message if the pragma fails. ^If the\n** [SQLITE_FCNTL_PRAGMA] file control returns [SQLITE_NOTFOUND], then normal \n** [PRAGMA] processing continues.  ^If the [SQLITE_FCNTL_PRAGMA]\n** file control returns [SQLITE_OK], then the parser assumes that the\n** VFS has handled the PRAGMA itself and the parser generates a no-op\n** prepared statement if result string is NULL, or that returns a copy\n** of the result string if the string is non-NULL.\n** ^If the [SQLITE_FCNTL_PRAGMA] file control returns\n** any result code other than [SQLITE_OK] or [SQLITE_NOTFOUND], that means\n** that the VFS encountered an error while handling the [PRAGMA] and the\n** compilation of the PRAGMA fails with an error.  ^The [SQLITE_FCNTL_PRAGMA]\n** file control occurs at the beginning of pragma statement analysis and so\n** it is able to override built-in [PRAGMA] statements.\n**\n** <li>[[SQLITE_FCNTL_BUSYHANDLER]]\n** ^The [SQLITE_FCNTL_BUSYHANDLER]\n** file-control may be invoked by SQLite on the database file handle\n** shortly after it is opened in order to provide a custom VFS with access\n** to the connections busy-handler callback. The argument is of type (void **)\n** - an array of two (void *) values. The first (void *) actually points\n** to a function of type (int (*)(void *)). In order to invoke the connections\n** busy-handler, this function should be invoked with the second (void *) in\n** the array as the only argument. If it returns non-zero, then the operation\n** should be retried. If it returns zero, the custom VFS should abandon the\n** current operation.\n**\n** <li>[[SQLITE_FCNTL_TEMPFILENAME]]\n** ^Application can invoke the [SQLITE_FCNTL_TEMPFILENAME] file-control\n** to have SQLite generate a\n** temporary filename using the same algorithm that is followed to generate\n** temporary filenames for TEMP tables and other internal uses.  The\n** argument should be a char** which will be filled with the filename\n** written into memory obtained from [sqlite3_malloc()].  The caller should\n** invoke [sqlite3_free()] on the result to avoid a memory leak.\n**\n** <li>[[SQLITE_FCNTL_MMAP_SIZE]]\n** The [SQLITE_FCNTL_MMAP_SIZE] file control is used to query or set the\n** maximum number of bytes that will be used for memory-mapped I/O.\n** The argument is a pointer to a value of type sqlite3_int64 that\n** is an advisory maximum number of bytes in the file to memory map.  The\n** pointer is overwritten with the old value.  The limit is not changed if\n** the value originally pointed to is negative, and so the current limit \n** can be queried by passing in a pointer to a negative number.  This\n** file-control is used internally to implement [PRAGMA mmap_size].\n**\n** <li>[[SQLITE_FCNTL_TRACE]]\n** The [SQLITE_FCNTL_TRACE] file control provides advisory information\n** to the VFS about what the higher layers of the SQLite stack are doing.\n** This file control is used by some VFS activity tracing [shims].\n** The argument is a zero-terminated string.  Higher layers in the\n** SQLite stack may generate instances of this file control if\n** the [SQLITE_USE_FCNTL_TRACE] compile-time option is enabled.\n**\n** <li>[[SQLITE_FCNTL_HAS_MOVED]]\n** The [SQLITE_FCNTL_HAS_MOVED] file control interprets its argument as a\n** pointer to an integer and it writes a boolean into that integer depending\n** on whether or not the file has been renamed, moved, or deleted since it\n** was first opened.\n**\n** <li>[[SQLITE_FCNTL_WIN32_GET_HANDLE]]\n** The [SQLITE_FCNTL_WIN32_GET_HANDLE] opcode can be used to obtain the\n** underlying native file handle associated with a file handle.  This file\n** control interprets its argument as a pointer to a native file handle and\n** writes the resulting value there.\n**\n** <li>[[SQLITE_FCNTL_WIN32_SET_HANDLE]]\n** The [SQLITE_FCNTL_WIN32_SET_HANDLE] opcode is used for debugging.  This\n** opcode causes the xFileControl method to swap the file handle with the one\n** pointed to by the pArg argument.  This capability is used during testing\n** and only needs to be supported when SQLITE_TEST is defined.\n**\n** <li>[[SQLITE_FCNTL_WAL_BLOCK]]\n** The [SQLITE_FCNTL_WAL_BLOCK] is a signal to the VFS layer that it might\n** be advantageous to block on the next WAL lock if the lock is not immediately\n** available.  The WAL subsystem issues this signal during rare\n** circumstances in order to fix a problem with priority inversion.\n** Applications should <em>not</em> use this file-control.\n**\n** <li>[[SQLITE_FCNTL_ZIPVFS]]\n** The [SQLITE_FCNTL_ZIPVFS] opcode is implemented by zipvfs only. All other\n** VFS should return SQLITE_NOTFOUND for this opcode.\n**\n** <li>[[SQLITE_FCNTL_RBU]]\n** The [SQLITE_FCNTL_RBU] opcode is implemented by the special VFS used by\n** the RBU extension only.  All other VFS should return SQLITE_NOTFOUND for\n** this opcode.  \n**\n** <li>[[SQLITE_FCNTL_BEGIN_ATOMIC_WRITE]]\n** If the [SQLITE_FCNTL_BEGIN_ATOMIC_WRITE] opcode returns SQLITE_OK, then\n** the file descriptor is placed in \"batch write mode\", which\n** means all subsequent write operations will be deferred and done\n** atomically at the next [SQLITE_FCNTL_COMMIT_ATOMIC_WRITE].  Systems\n** that do not support batch atomic writes will return SQLITE_NOTFOUND.\n** ^Following a successful SQLITE_FCNTL_BEGIN_ATOMIC_WRITE and prior to\n** the closing [SQLITE_FCNTL_COMMIT_ATOMIC_WRITE] or\n** [SQLITE_FCNTL_ROLLBACK_ATOMIC_WRITE], SQLite will make\n** no VFS interface calls on the same [sqlite3_file] file descriptor\n** except for calls to the xWrite method and the xFileControl method\n** with [SQLITE_FCNTL_SIZE_HINT].\n**\n** <li>[[SQLITE_FCNTL_COMMIT_ATOMIC_WRITE]]\n** The [SQLITE_FCNTL_COMMIT_ATOMIC_WRITE] opcode causes all write\n** operations since the previous successful call to \n** [SQLITE_FCNTL_BEGIN_ATOMIC_WRITE] to be performed atomically.\n** This file control returns [SQLITE_OK] if and only if the writes were\n** all performed successfully and have been committed to persistent storage.\n** ^Regardless of whether or not it is successful, this file control takes\n** the file descriptor out of batch write mode so that all subsequent\n** write operations are independent.\n** ^SQLite will never invoke SQLITE_FCNTL_COMMIT_ATOMIC_WRITE without\n** a prior successful call to [SQLITE_FCNTL_BEGIN_ATOMIC_WRITE].\n**\n** <li>[[SQLITE_FCNTL_ROLLBACK_ATOMIC_WRITE]]\n** The [SQLITE_FCNTL_ROLLBACK_ATOMIC_WRITE] opcode causes all write\n** operations since the previous successful call to \n** [SQLITE_FCNTL_BEGIN_ATOMIC_WRITE] to be rolled back.\n** ^This file control takes the file descriptor out of batch write mode\n** so that all subsequent write operations are independent.\n** ^SQLite will never invoke SQLITE_FCNTL_ROLLBACK_ATOMIC_WRITE without\n** a prior successful call to [SQLITE_FCNTL_BEGIN_ATOMIC_WRITE].\n**\n** <li>[[SQLITE_FCNTL_LOCK_TIMEOUT]]\n** The [SQLITE_FCNTL_LOCK_TIMEOUT] opcode causes attempts to obtain\n** a file lock using the xLock or xShmLock methods of the VFS to wait\n** for up to M milliseconds before failing, where M is the single \n** unsigned integer parameter.\n**\n** <li>[[SQLITE_FCNTL_DATA_VERSION]]\n** The [SQLITE_FCNTL_DATA_VERSION] opcode is used to detect changes to\n** a database file.  The argument is a pointer to a 32-bit unsigned integer.\n** The \"data version\" for the pager is written into the pointer.  The\n** \"data version\" changes whenever any change occurs to the corresponding\n** database file, either through SQL statements on the same database\n** connection or through transactions committed by separate database\n** connections possibly in other processes. The [sqlite3_total_changes()]\n** interface can be used to find if any database on the connection has changed,\n** but that interface responds to changes on TEMP as well as MAIN and does\n** not provide a mechanism to detect changes to MAIN only.  Also, the\n** [sqlite3_total_changes()] interface responds to internal changes only and\n** omits changes made by other database connections.  The\n** [PRAGMA data_version] command provide a mechanism to detect changes to\n** a single attached database that occur due to other database connections,\n** but omits changes implemented by the database connection on which it is\n** called.  This file control is the only mechanism to detect changes that\n** happen either internally or externally and that are associated with\n** a particular attached database.\n** </ul>\n*/\n#define SQLITE_FCNTL_LOCKSTATE               1\n#define SQLITE_FCNTL_GET_LOCKPROXYFILE       2\n#define SQLITE_FCNTL_SET_LOCKPROXYFILE       3\n#define SQLITE_FCNTL_LAST_ERRNO              4\n#define SQLITE_FCNTL_SIZE_HINT               5\n#define SQLITE_FCNTL_CHUNK_SIZE              6\n#define SQLITE_FCNTL_FILE_POINTER            7\n#define SQLITE_FCNTL_SYNC_OMITTED            8\n#define SQLITE_FCNTL_WIN32_AV_RETRY          9\n#define SQLITE_FCNTL_PERSIST_WAL            10\n#define SQLITE_FCNTL_OVERWRITE              11\n#define SQLITE_FCNTL_VFSNAME                12\n#define SQLITE_FCNTL_POWERSAFE_OVERWRITE    13\n#define SQLITE_FCNTL_PRAGMA                 14\n#define SQLITE_FCNTL_BUSYHANDLER            15\n#define SQLITE_FCNTL_TEMPFILENAME           16\n#define SQLITE_FCNTL_MMAP_SIZE              18\n#define SQLITE_FCNTL_TRACE                  19\n#define SQLITE_FCNTL_HAS_MOVED              20\n#define SQLITE_FCNTL_SYNC                   21\n#define SQLITE_FCNTL_COMMIT_PHASETWO        22\n#define SQLITE_FCNTL_WIN32_SET_HANDLE       23\n#define SQLITE_FCNTL_WAL_BLOCK              24\n#define SQLITE_FCNTL_ZIPVFS                 25\n#define SQLITE_FCNTL_RBU                    26\n#define SQLITE_FCNTL_VFS_POINTER            27\n#define SQLITE_FCNTL_JOURNAL_POINTER        28\n#define SQLITE_FCNTL_WIN32_GET_HANDLE       29\n#define SQLITE_FCNTL_PDB                    30\n#define SQLITE_FCNTL_BEGIN_ATOMIC_WRITE     31\n#define SQLITE_FCNTL_COMMIT_ATOMIC_WRITE    32\n#define SQLITE_FCNTL_ROLLBACK_ATOMIC_WRITE  33\n#define SQLITE_FCNTL_LOCK_TIMEOUT           34\n#define SQLITE_FCNTL_DATA_VERSION           35\n#define SQLITE_FCNTL_SIZE_LIMIT             36\n\n/* deprecated names */\n#define SQLITE_GET_LOCKPROXYFILE      SQLITE_FCNTL_GET_LOCKPROXYFILE\n#define SQLITE_SET_LOCKPROXYFILE      SQLITE_FCNTL_SET_LOCKPROXYFILE\n#define SQLITE_LAST_ERRNO             SQLITE_FCNTL_LAST_ERRNO\n\n\n/*\n** CAPI3REF: Mutex Handle\n**\n** The mutex module within SQLite defines [sqlite3_mutex] to be an\n** abstract type for a mutex object.  The SQLite core never looks\n** at the internal representation of an [sqlite3_mutex].  It only\n** deals with pointers to the [sqlite3_mutex] object.\n**\n** Mutexes are created using [sqlite3_mutex_alloc()].\n*/\ntypedef struct sqlite3_mutex sqlite3_mutex;\n\n/*\n** CAPI3REF: Loadable Extension Thunk\n**\n** A pointer to the opaque sqlite3_api_routines structure is passed as\n** the third parameter to entry points of [loadable extensions].  This\n** structure must be typedefed in order to work around compiler warnings\n** on some platforms.\n*/\ntypedef struct sqlite3_api_routines sqlite3_api_routines;\n\n/*\n** CAPI3REF: OS Interface Object\n**\n** An instance of the sqlite3_vfs object defines the interface between\n** the SQLite core and the underlying operating system.  The \"vfs\"\n** in the name of the object stands for \"virtual file system\".  See\n** the [VFS | VFS documentation] for further information.\n**\n** The VFS interface is sometimes extended by adding new methods onto\n** the end.  Each time such an extension occurs, the iVersion field\n** is incremented.  The iVersion value started out as 1 in\n** SQLite [version 3.5.0] on [dateof:3.5.0], then increased to 2\n** with SQLite [version 3.7.0] on [dateof:3.7.0], and then increased\n** to 3 with SQLite [version 3.7.6] on [dateof:3.7.6].  Additional fields\n** may be appended to the sqlite3_vfs object and the iVersion value\n** may increase again in future versions of SQLite.\n** Note that the structure\n** of the sqlite3_vfs object changes in the transition from\n** SQLite [version 3.5.9] to [version 3.6.0] on [dateof:3.6.0]\n** and yet the iVersion field was not modified.\n**\n** The szOsFile field is the size of the subclassed [sqlite3_file]\n** structure used by this VFS.  mxPathname is the maximum length of\n** a pathname in this VFS.\n**\n** Registered sqlite3_vfs objects are kept on a linked list formed by\n** the pNext pointer.  The [sqlite3_vfs_register()]\n** and [sqlite3_vfs_unregister()] interfaces manage this list\n** in a thread-safe way.  The [sqlite3_vfs_find()] interface\n** searches the list.  Neither the application code nor the VFS\n** implementation should use the pNext pointer.\n**\n** The pNext field is the only field in the sqlite3_vfs\n** structure that SQLite will ever modify.  SQLite will only access\n** or modify this field while holding a particular static mutex.\n** The application should never modify anything within the sqlite3_vfs\n** object once the object has been registered.\n**\n** The zName field holds the name of the VFS module.  The name must\n** be unique across all VFS modules.\n**\n** [[sqlite3_vfs.xOpen]]\n** ^SQLite guarantees that the zFilename parameter to xOpen\n** is either a NULL pointer or string obtained\n** from xFullPathname() with an optional suffix added.\n** ^If a suffix is added to the zFilename parameter, it will\n** consist of a single \"-\" character followed by no more than\n** 11 alphanumeric and/or \"-\" characters.\n** ^SQLite further guarantees that\n** the string will be valid and unchanged until xClose() is\n** called. Because of the previous sentence,\n** the [sqlite3_file] can safely store a pointer to the\n** filename if it needs to remember the filename for some reason.\n** If the zFilename parameter to xOpen is a NULL pointer then xOpen\n** must invent its own temporary name for the file.  ^Whenever the \n** xFilename parameter is NULL it will also be the case that the\n** flags parameter will include [SQLITE_OPEN_DELETEONCLOSE].\n**\n** The flags argument to xOpen() includes all bits set in\n** the flags argument to [sqlite3_open_v2()].  Or if [sqlite3_open()]\n** or [sqlite3_open16()] is used, then flags includes at least\n** [SQLITE_OPEN_READWRITE] | [SQLITE_OPEN_CREATE]. \n** If xOpen() opens a file read-only then it sets *pOutFlags to\n** include [SQLITE_OPEN_READONLY].  Other bits in *pOutFlags may be set.\n**\n** ^(SQLite will also add one of the following flags to the xOpen()\n** call, depending on the object being opened:\n**\n** <ul>\n** <li>  [SQLITE_OPEN_MAIN_DB]\n** <li>  [SQLITE_OPEN_MAIN_JOURNAL]\n** <li>  [SQLITE_OPEN_TEMP_DB]\n** <li>  [SQLITE_OPEN_TEMP_JOURNAL]\n** <li>  [SQLITE_OPEN_TRANSIENT_DB]\n** <li>  [SQLITE_OPEN_SUBJOURNAL]\n** <li>  [SQLITE_OPEN_MASTER_JOURNAL]\n** <li>  [SQLITE_OPEN_WAL]\n** </ul>)^\n**\n** The file I/O implementation can use the object type flags to\n** change the way it deals with files.  For example, an application\n** that does not care about crash recovery or rollback might make\n** the open of a journal file a no-op.  Writes to this journal would\n** also be no-ops, and any attempt to read the journal would return\n** SQLITE_IOERR.  Or the implementation might recognize that a database\n** file will be doing page-aligned sector reads and writes in a random\n** order and set up its I/O subsystem accordingly.\n**\n** SQLite might also add one of the following flags to the xOpen method:\n**\n** <ul>\n** <li> [SQLITE_OPEN_DELETEONCLOSE]\n** <li> [SQLITE_OPEN_EXCLUSIVE]\n** </ul>\n**\n** The [SQLITE_OPEN_DELETEONCLOSE] flag means the file should be\n** deleted when it is closed.  ^The [SQLITE_OPEN_DELETEONCLOSE]\n** will be set for TEMP databases and their journals, transient\n** databases, and subjournals.\n**\n** ^The [SQLITE_OPEN_EXCLUSIVE] flag is always used in conjunction\n** with the [SQLITE_OPEN_CREATE] flag, which are both directly\n** analogous to the O_EXCL and O_CREAT flags of the POSIX open()\n** API.  The SQLITE_OPEN_EXCLUSIVE flag, when paired with the \n** SQLITE_OPEN_CREATE, is used to indicate that file should always\n** be created, and that it is an error if it already exists.\n** It is <i>not</i> used to indicate the file should be opened \n** for exclusive access.\n**\n** ^At least szOsFile bytes of memory are allocated by SQLite\n** to hold the  [sqlite3_file] structure passed as the third\n** argument to xOpen.  The xOpen method does not have to\n** allocate the structure; it should just fill it in.  Note that\n** the xOpen method must set the sqlite3_file.pMethods to either\n** a valid [sqlite3_io_methods] object or to NULL.  xOpen must do\n** this even if the open fails.  SQLite expects that the sqlite3_file.pMethods\n** element will be valid after xOpen returns regardless of the success\n** or failure of the xOpen call.\n**\n** [[sqlite3_vfs.xAccess]]\n** ^The flags argument to xAccess() may be [SQLITE_ACCESS_EXISTS]\n** to test for the existence of a file, or [SQLITE_ACCESS_READWRITE] to\n** test whether a file is readable and writable, or [SQLITE_ACCESS_READ]\n** to test whether a file is at least readable.   The file can be a\n** directory.\n**\n** ^SQLite will always allocate at least mxPathname+1 bytes for the\n** output buffer xFullPathname.  The exact size of the output buffer\n** is also passed as a parameter to both  methods. If the output buffer\n** is not large enough, [SQLITE_CANTOPEN] should be returned. Since this is\n** handled as a fatal error by SQLite, vfs implementations should endeavor\n** to prevent this by setting mxPathname to a sufficiently large value.\n**\n** The xRandomness(), xSleep(), xCurrentTime(), and xCurrentTimeInt64()\n** interfaces are not strictly a part of the filesystem, but they are\n** included in the VFS structure for completeness.\n** The xRandomness() function attempts to return nBytes bytes\n** of good-quality randomness into zOut.  The return value is\n** the actual number of bytes of randomness obtained.\n** The xSleep() method causes the calling thread to sleep for at\n** least the number of microseconds given.  ^The xCurrentTime()\n** method returns a Julian Day Number for the current date and time as\n** a floating point value.\n** ^The xCurrentTimeInt64() method returns, as an integer, the Julian\n** Day Number multiplied by 86400000 (the number of milliseconds in \n** a 24-hour day).  \n** ^SQLite will use the xCurrentTimeInt64() method to get the current\n** date and time if that method is available (if iVersion is 2 or \n** greater and the function pointer is not NULL) and will fall back\n** to xCurrentTime() if xCurrentTimeInt64() is unavailable.\n**\n** ^The xSetSystemCall(), xGetSystemCall(), and xNestSystemCall() interfaces\n** are not used by the SQLite core.  These optional interfaces are provided\n** by some VFSes to facilitate testing of the VFS code. By overriding \n** system calls with functions under its control, a test program can\n** simulate faults and error conditions that would otherwise be difficult\n** or impossible to induce.  The set of system calls that can be overridden\n** varies from one VFS to another, and from one version of the same VFS to the\n** next.  Applications that use these interfaces must be prepared for any\n** or all of these interfaces to be NULL or for their behavior to change\n** from one release to the next.  Applications must not attempt to access\n** any of these methods if the iVersion of the VFS is less than 3.\n*/\ntypedef struct sqlite3_vfs sqlite3_vfs;\ntypedef void (*sqlite3_syscall_ptr)(void);\nstruct sqlite3_vfs {\n  int iVersion;            /* Structure version number (currently 3) */\n  int szOsFile;            /* Size of subclassed sqlite3_file */\n  int mxPathname;          /* Maximum file pathname length */\n  sqlite3_vfs *pNext;      /* Next registered VFS */\n  const char *zName;       /* Name of this virtual file system */\n  void *pAppData;          /* Pointer to application-specific data */\n  int (*xOpen)(sqlite3_vfs*, const char *zName, sqlite3_file*,\n               int flags, int *pOutFlags);\n  int (*xDelete)(sqlite3_vfs*, const char *zName, int syncDir);\n  int (*xAccess)(sqlite3_vfs*, const char *zName, int flags, int *pResOut);\n  int (*xFullPathname)(sqlite3_vfs*, const char *zName, int nOut, char *zOut);\n  void *(*xDlOpen)(sqlite3_vfs*, const char *zFilename);\n  void (*xDlError)(sqlite3_vfs*, int nByte, char *zErrMsg);\n  void (*(*xDlSym)(sqlite3_vfs*,void*, const char *zSymbol))(void);\n  void (*xDlClose)(sqlite3_vfs*, void*);\n  int (*xRandomness)(sqlite3_vfs*, int nByte, char *zOut);\n  int (*xSleep)(sqlite3_vfs*, int microseconds);\n  int (*xCurrentTime)(sqlite3_vfs*, double*);\n  int (*xGetLastError)(sqlite3_vfs*, int, char *);\n  /*\n  ** The methods above are in version 1 of the sqlite_vfs object\n  ** definition.  Those that follow are added in version 2 or later\n  */\n  int (*xCurrentTimeInt64)(sqlite3_vfs*, sqlite3_int64*);\n  /*\n  ** The methods above are in versions 1 and 2 of the sqlite_vfs object.\n  ** Those below are for version 3 and greater.\n  */\n  int (*xSetSystemCall)(sqlite3_vfs*, const char *zName, sqlite3_syscall_ptr);\n  sqlite3_syscall_ptr (*xGetSystemCall)(sqlite3_vfs*, const char *zName);\n  const char *(*xNextSystemCall)(sqlite3_vfs*, const char *zName);\n  /*\n  ** The methods above are in versions 1 through 3 of the sqlite_vfs object.\n  ** New fields may be appended in future versions.  The iVersion\n  ** value will increment whenever this happens. \n  */\n};\n\n/*\n** CAPI3REF: Flags for the xAccess VFS method\n**\n** These integer constants can be used as the third parameter to\n** the xAccess method of an [sqlite3_vfs] object.  They determine\n** what kind of permissions the xAccess method is looking for.\n** With SQLITE_ACCESS_EXISTS, the xAccess method\n** simply checks whether the file exists.\n** With SQLITE_ACCESS_READWRITE, the xAccess method\n** checks whether the named directory is both readable and writable\n** (in other words, if files can be added, removed, and renamed within\n** the directory).\n** The SQLITE_ACCESS_READWRITE constant is currently used only by the\n** [temp_store_directory pragma], though this could change in a future\n** release of SQLite.\n** With SQLITE_ACCESS_READ, the xAccess method\n** checks whether the file is readable.  The SQLITE_ACCESS_READ constant is\n** currently unused, though it might be used in a future release of\n** SQLite.\n*/\n#define SQLITE_ACCESS_EXISTS    0\n#define SQLITE_ACCESS_READWRITE 1   /* Used by PRAGMA temp_store_directory */\n#define SQLITE_ACCESS_READ      2   /* Unused */\n\n/*\n** CAPI3REF: Flags for the xShmLock VFS method\n**\n** These integer constants define the various locking operations\n** allowed by the xShmLock method of [sqlite3_io_methods].  The\n** following are the only legal combinations of flags to the\n** xShmLock method:\n**\n** <ul>\n** <li>  SQLITE_SHM_LOCK | SQLITE_SHM_SHARED\n** <li>  SQLITE_SHM_LOCK | SQLITE_SHM_EXCLUSIVE\n** <li>  SQLITE_SHM_UNLOCK | SQLITE_SHM_SHARED\n** <li>  SQLITE_SHM_UNLOCK | SQLITE_SHM_EXCLUSIVE\n** </ul>\n**\n** When unlocking, the same SHARED or EXCLUSIVE flag must be supplied as\n** was given on the corresponding lock.  \n**\n** The xShmLock method can transition between unlocked and SHARED or\n** between unlocked and EXCLUSIVE.  It cannot transition between SHARED\n** and EXCLUSIVE.\n*/\n#define SQLITE_SHM_UNLOCK       1\n#define SQLITE_SHM_LOCK         2\n#define SQLITE_SHM_SHARED       4\n#define SQLITE_SHM_EXCLUSIVE    8\n\n/*\n** CAPI3REF: Maximum xShmLock index\n**\n** The xShmLock method on [sqlite3_io_methods] may use values\n** between 0 and this upper bound as its \"offset\" argument.\n** The SQLite core will never attempt to acquire or release a\n** lock outside of this range\n*/\n#define SQLITE_SHM_NLOCK        8\n\n\n/*\n** CAPI3REF: Initialize The SQLite Library\n**\n** ^The sqlite3_initialize() routine initializes the\n** SQLite library.  ^The sqlite3_shutdown() routine\n** deallocates any resources that were allocated by sqlite3_initialize().\n** These routines are designed to aid in process initialization and\n** shutdown on embedded systems.  Workstation applications using\n** SQLite normally do not need to invoke either of these routines.\n**\n** A call to sqlite3_initialize() is an \"effective\" call if it is\n** the first time sqlite3_initialize() is invoked during the lifetime of\n** the process, or if it is the first time sqlite3_initialize() is invoked\n** following a call to sqlite3_shutdown().  ^(Only an effective call\n** of sqlite3_initialize() does any initialization.  All other calls\n** are harmless no-ops.)^\n**\n** A call to sqlite3_shutdown() is an \"effective\" call if it is the first\n** call to sqlite3_shutdown() since the last sqlite3_initialize().  ^(Only\n** an effective call to sqlite3_shutdown() does any deinitialization.\n** All other valid calls to sqlite3_shutdown() are harmless no-ops.)^\n**\n** The sqlite3_initialize() interface is threadsafe, but sqlite3_shutdown()\n** is not.  The sqlite3_shutdown() interface must only be called from a\n** single thread.  All open [database connections] must be closed and all\n** other SQLite resources must be deallocated prior to invoking\n** sqlite3_shutdown().\n**\n** Among other things, ^sqlite3_initialize() will invoke\n** sqlite3_os_init().  Similarly, ^sqlite3_shutdown()\n** will invoke sqlite3_os_end().\n**\n** ^The sqlite3_initialize() routine returns [SQLITE_OK] on success.\n** ^If for some reason, sqlite3_initialize() is unable to initialize\n** the library (perhaps it is unable to allocate a needed resource such\n** as a mutex) it returns an [error code] other than [SQLITE_OK].\n**\n** ^The sqlite3_initialize() routine is called internally by many other\n** SQLite interfaces so that an application usually does not need to\n** invoke sqlite3_initialize() directly.  For example, [sqlite3_open()]\n** calls sqlite3_initialize() so the SQLite library will be automatically\n** initialized when [sqlite3_open()] is called if it has not be initialized\n** already.  ^However, if SQLite is compiled with the [SQLITE_OMIT_AUTOINIT]\n** compile-time option, then the automatic calls to sqlite3_initialize()\n** are omitted and the application must call sqlite3_initialize() directly\n** prior to using any other SQLite interface.  For maximum portability,\n** it is recommended that applications always invoke sqlite3_initialize()\n** directly prior to using any other SQLite interface.  Future releases\n** of SQLite may require this.  In other words, the behavior exhibited\n** when SQLite is compiled with [SQLITE_OMIT_AUTOINIT] might become the\n** default behavior in some future release of SQLite.\n**\n** The sqlite3_os_init() routine does operating-system specific\n** initialization of the SQLite library.  The sqlite3_os_end()\n** routine undoes the effect of sqlite3_os_init().  Typical tasks\n** performed by these routines include allocation or deallocation\n** of static resources, initialization of global variables,\n** setting up a default [sqlite3_vfs] module, or setting up\n** a default configuration using [sqlite3_config()].\n**\n** The application should never invoke either sqlite3_os_init()\n** or sqlite3_os_end() directly.  The application should only invoke\n** sqlite3_initialize() and sqlite3_shutdown().  The sqlite3_os_init()\n** interface is called automatically by sqlite3_initialize() and\n** sqlite3_os_end() is called by sqlite3_shutdown().  Appropriate\n** implementations for sqlite3_os_init() and sqlite3_os_end()\n** are built into SQLite when it is compiled for Unix, Windows, or OS/2.\n** When [custom builds | built for other platforms]\n** (using the [SQLITE_OS_OTHER=1] compile-time\n** option) the application must supply a suitable implementation for\n** sqlite3_os_init() and sqlite3_os_end().  An application-supplied\n** implementation of sqlite3_os_init() or sqlite3_os_end()\n** must return [SQLITE_OK] on success and some other [error code] upon\n** failure.\n*/\nSQLITE_API int sqlite3_initialize(void);\nSQLITE_API int sqlite3_shutdown(void);\nSQLITE_API int sqlite3_os_init(void);\nSQLITE_API int sqlite3_os_end(void);\n\n/*\n** CAPI3REF: Configuring The SQLite Library\n**\n** The sqlite3_config() interface is used to make global configuration\n** changes to SQLite in order to tune SQLite to the specific needs of\n** the application.  The default configuration is recommended for most\n** applications and so this routine is usually not necessary.  It is\n** provided to support rare applications with unusual needs.\n**\n** <b>The sqlite3_config() interface is not threadsafe. The application\n** must ensure that no other SQLite interfaces are invoked by other\n** threads while sqlite3_config() is running.</b>\n**\n** The sqlite3_config() interface\n** may only be invoked prior to library initialization using\n** [sqlite3_initialize()] or after shutdown by [sqlite3_shutdown()].\n** ^If sqlite3_config() is called after [sqlite3_initialize()] and before\n** [sqlite3_shutdown()] then it will return SQLITE_MISUSE.\n** Note, however, that ^sqlite3_config() can be called as part of the\n** implementation of an application-defined [sqlite3_os_init()].\n**\n** The first argument to sqlite3_config() is an integer\n** [configuration option] that determines\n** what property of SQLite is to be configured.  Subsequent arguments\n** vary depending on the [configuration option]\n** in the first argument.\n**\n** ^When a configuration option is set, sqlite3_config() returns [SQLITE_OK].\n** ^If the option is unknown or SQLite is unable to set the option\n** then this routine returns a non-zero [error code].\n*/\nSQLITE_API int sqlite3_config(int, ...);\n\n/*\n** CAPI3REF: Configure database connections\n** METHOD: sqlite3\n**\n** The sqlite3_db_config() interface is used to make configuration\n** changes to a [database connection].  The interface is similar to\n** [sqlite3_config()] except that the changes apply to a single\n** [database connection] (specified in the first argument).\n**\n** The second argument to sqlite3_db_config(D,V,...)  is the\n** [SQLITE_DBCONFIG_LOOKASIDE | configuration verb] - an integer code \n** that indicates what aspect of the [database connection] is being configured.\n** Subsequent arguments vary depending on the configuration verb.\n**\n** ^Calls to sqlite3_db_config() return SQLITE_OK if and only if\n** the call is considered successful.\n*/\nSQLITE_API int sqlite3_db_config(sqlite3*, int op, ...);\n\n/*\n** CAPI3REF: Memory Allocation Routines\n**\n** An instance of this object defines the interface between SQLite\n** and low-level memory allocation routines.\n**\n** This object is used in only one place in the SQLite interface.\n** A pointer to an instance of this object is the argument to\n** [sqlite3_config()] when the configuration option is\n** [SQLITE_CONFIG_MALLOC] or [SQLITE_CONFIG_GETMALLOC].  \n** By creating an instance of this object\n** and passing it to [sqlite3_config]([SQLITE_CONFIG_MALLOC])\n** during configuration, an application can specify an alternative\n** memory allocation subsystem for SQLite to use for all of its\n** dynamic memory needs.\n**\n** Note that SQLite comes with several [built-in memory allocators]\n** that are perfectly adequate for the overwhelming majority of applications\n** and that this object is only useful to a tiny minority of applications\n** with specialized memory allocation requirements.  This object is\n** also used during testing of SQLite in order to specify an alternative\n** memory allocator that simulates memory out-of-memory conditions in\n** order to verify that SQLite recovers gracefully from such\n** conditions.\n**\n** The xMalloc, xRealloc, and xFree methods must work like the\n** malloc(), realloc() and free() functions from the standard C library.\n** ^SQLite guarantees that the second argument to\n** xRealloc is always a value returned by a prior call to xRoundup.\n**\n** xSize should return the allocated size of a memory allocation\n** previously obtained from xMalloc or xRealloc.  The allocated size\n** is always at least as big as the requested size but may be larger.\n**\n** The xRoundup method returns what would be the allocated size of\n** a memory allocation given a particular requested size.  Most memory\n** allocators round up memory allocations at least to the next multiple\n** of 8.  Some allocators round up to a larger multiple or to a power of 2.\n** Every memory allocation request coming in through [sqlite3_malloc()]\n** or [sqlite3_realloc()] first calls xRoundup.  If xRoundup returns 0, \n** that causes the corresponding memory allocation to fail.\n**\n** The xInit method initializes the memory allocator.  For example,\n** it might allocate any require mutexes or initialize internal data\n** structures.  The xShutdown method is invoked (indirectly) by\n** [sqlite3_shutdown()] and should deallocate any resources acquired\n** by xInit.  The pAppData pointer is used as the only parameter to\n** xInit and xShutdown.\n**\n** SQLite holds the [SQLITE_MUTEX_STATIC_MASTER] mutex when it invokes\n** the xInit method, so the xInit method need not be threadsafe.  The\n** xShutdown method is only called from [sqlite3_shutdown()] so it does\n** not need to be threadsafe either.  For all other methods, SQLite\n** holds the [SQLITE_MUTEX_STATIC_MEM] mutex as long as the\n** [SQLITE_CONFIG_MEMSTATUS] configuration option is turned on (which\n** it is by default) and so the methods are automatically serialized.\n** However, if [SQLITE_CONFIG_MEMSTATUS] is disabled, then the other\n** methods must be threadsafe or else make their own arrangements for\n** serialization.\n**\n** SQLite will never invoke xInit() more than once without an intervening\n** call to xShutdown().\n*/\ntypedef struct sqlite3_mem_methods sqlite3_mem_methods;\nstruct sqlite3_mem_methods {\n  void *(*xMalloc)(int);         /* Memory allocation function */\n  void (*xFree)(void*);          /* Free a prior allocation */\n  void *(*xRealloc)(void*,int);  /* Resize an allocation */\n  int (*xSize)(void*);           /* Return the size of an allocation */\n  int (*xRoundup)(int);          /* Round up request size to allocation size */\n  int (*xInit)(void*);           /* Initialize the memory allocator */\n  void (*xShutdown)(void*);      /* Deinitialize the memory allocator */\n  void *pAppData;                /* Argument to xInit() and xShutdown() */\n};\n\n/*\n** CAPI3REF: Configuration Options\n** KEYWORDS: {configuration option}\n**\n** These constants are the available integer configuration options that\n** can be passed as the first argument to the [sqlite3_config()] interface.\n**\n** New configuration options may be added in future releases of SQLite.\n** Existing configuration options might be discontinued.  Applications\n** should check the return code from [sqlite3_config()] to make sure that\n** the call worked.  The [sqlite3_config()] interface will return a\n** non-zero [error code] if a discontinued or unsupported configuration option\n** is invoked.\n**\n** <dl>\n** [[SQLITE_CONFIG_SINGLETHREAD]] <dt>SQLITE_CONFIG_SINGLETHREAD</dt>\n** <dd>There are no arguments to this option.  ^This option sets the\n** [threading mode] to Single-thread.  In other words, it disables\n** all mutexing and puts SQLite into a mode where it can only be used\n** by a single thread.   ^If SQLite is compiled with\n** the [SQLITE_THREADSAFE | SQLITE_THREADSAFE=0] compile-time option then\n** it is not possible to change the [threading mode] from its default\n** value of Single-thread and so [sqlite3_config()] will return \n** [SQLITE_ERROR] if called with the SQLITE_CONFIG_SINGLETHREAD\n** configuration option.</dd>\n**\n** [[SQLITE_CONFIG_MULTITHREAD]] <dt>SQLITE_CONFIG_MULTITHREAD</dt>\n** <dd>There are no arguments to this option.  ^This option sets the\n** [threading mode] to Multi-thread.  In other words, it disables\n** mutexing on [database connection] and [prepared statement] objects.\n** The application is responsible for serializing access to\n** [database connections] and [prepared statements].  But other mutexes\n** are enabled so that SQLite will be safe to use in a multi-threaded\n** environment as long as no two threads attempt to use the same\n** [database connection] at the same time.  ^If SQLite is compiled with\n** the [SQLITE_THREADSAFE | SQLITE_THREADSAFE=0] compile-time option then\n** it is not possible to set the Multi-thread [threading mode] and\n** [sqlite3_config()] will return [SQLITE_ERROR] if called with the\n** SQLITE_CONFIG_MULTITHREAD configuration option.</dd>\n**\n** [[SQLITE_CONFIG_SERIALIZED]] <dt>SQLITE_CONFIG_SERIALIZED</dt>\n** <dd>There are no arguments to this option.  ^This option sets the\n** [threading mode] to Serialized. In other words, this option enables\n** all mutexes including the recursive\n** mutexes on [database connection] and [prepared statement] objects.\n** In this mode (which is the default when SQLite is compiled with\n** [SQLITE_THREADSAFE=1]) the SQLite library will itself serialize access\n** to [database connections] and [prepared statements] so that the\n** application is free to use the same [database connection] or the\n** same [prepared statement] in different threads at the same time.\n** ^If SQLite is compiled with\n** the [SQLITE_THREADSAFE | SQLITE_THREADSAFE=0] compile-time option then\n** it is not possible to set the Serialized [threading mode] and\n** [sqlite3_config()] will return [SQLITE_ERROR] if called with the\n** SQLITE_CONFIG_SERIALIZED configuration option.</dd>\n**\n** [[SQLITE_CONFIG_MALLOC]] <dt>SQLITE_CONFIG_MALLOC</dt>\n** <dd> ^(The SQLITE_CONFIG_MALLOC option takes a single argument which is \n** a pointer to an instance of the [sqlite3_mem_methods] structure.\n** The argument specifies\n** alternative low-level memory allocation routines to be used in place of\n** the memory allocation routines built into SQLite.)^ ^SQLite makes\n** its own private copy of the content of the [sqlite3_mem_methods] structure\n** before the [sqlite3_config()] call returns.</dd>\n**\n** [[SQLITE_CONFIG_GETMALLOC]] <dt>SQLITE_CONFIG_GETMALLOC</dt>\n** <dd> ^(The SQLITE_CONFIG_GETMALLOC option takes a single argument which\n** is a pointer to an instance of the [sqlite3_mem_methods] structure.\n** The [sqlite3_mem_methods]\n** structure is filled with the currently defined memory allocation routines.)^\n** This option can be used to overload the default memory allocation\n** routines with a wrapper that simulations memory allocation failure or\n** tracks memory usage, for example. </dd>\n**\n** [[SQLITE_CONFIG_SMALL_MALLOC]] <dt>SQLITE_CONFIG_SMALL_MALLOC</dt>\n** <dd> ^The SQLITE_CONFIG_SMALL_MALLOC option takes single argument of\n** type int, interpreted as a boolean, which if true provides a hint to\n** SQLite that it should avoid large memory allocations if possible.\n** SQLite will run faster if it is free to make large memory allocations,\n** but some application might prefer to run slower in exchange for\n** guarantees about memory fragmentation that are possible if large\n** allocations are avoided.  This hint is normally off.\n** </dd>\n**\n** [[SQLITE_CONFIG_MEMSTATUS]] <dt>SQLITE_CONFIG_MEMSTATUS</dt>\n** <dd> ^The SQLITE_CONFIG_MEMSTATUS option takes single argument of type int,\n** interpreted as a boolean, which enables or disables the collection of\n** memory allocation statistics. ^(When memory allocation statistics are\n** disabled, the following SQLite interfaces become non-operational:\n**   <ul>\n**   <li> [sqlite3_memory_used()]\n**   <li> [sqlite3_memory_highwater()]\n**   <li> [sqlite3_soft_heap_limit64()]\n**   <li> [sqlite3_status64()]\n**   </ul>)^\n** ^Memory allocation statistics are enabled by default unless SQLite is\n** compiled with [SQLITE_DEFAULT_MEMSTATUS]=0 in which case memory\n** allocation statistics are disabled by default.\n** </dd>\n**\n** [[SQLITE_CONFIG_SCRATCH]] <dt>SQLITE_CONFIG_SCRATCH</dt>\n** <dd> The SQLITE_CONFIG_SCRATCH option is no longer used.\n** </dd>\n**\n** [[SQLITE_CONFIG_PAGECACHE]] <dt>SQLITE_CONFIG_PAGECACHE</dt>\n** <dd> ^The SQLITE_CONFIG_PAGECACHE option specifies a memory pool\n** that SQLite can use for the database page cache with the default page\n** cache implementation.  \n** This configuration option is a no-op if an application-define page\n** cache implementation is loaded using the [SQLITE_CONFIG_PCACHE2].\n** ^There are three arguments to SQLITE_CONFIG_PAGECACHE: A pointer to\n** 8-byte aligned memory (pMem), the size of each page cache line (sz),\n** and the number of cache lines (N).\n** The sz argument should be the size of the largest database page\n** (a power of two between 512 and 65536) plus some extra bytes for each\n** page header.  ^The number of extra bytes needed by the page header\n** can be determined using [SQLITE_CONFIG_PCACHE_HDRSZ].\n** ^It is harmless, apart from the wasted memory,\n** for the sz parameter to be larger than necessary.  The pMem\n** argument must be either a NULL pointer or a pointer to an 8-byte\n** aligned block of memory of at least sz*N bytes, otherwise\n** subsequent behavior is undefined.\n** ^When pMem is not NULL, SQLite will strive to use the memory provided\n** to satisfy page cache needs, falling back to [sqlite3_malloc()] if\n** a page cache line is larger than sz bytes or if all of the pMem buffer\n** is exhausted.\n** ^If pMem is NULL and N is non-zero, then each database connection\n** does an initial bulk allocation for page cache memory\n** from [sqlite3_malloc()] sufficient for N cache lines if N is positive or\n** of -1024*N bytes if N is negative, . ^If additional\n** page cache memory is needed beyond what is provided by the initial\n** allocation, then SQLite goes to [sqlite3_malloc()] separately for each\n** additional cache line. </dd>\n**\n** [[SQLITE_CONFIG_HEAP]] <dt>SQLITE_CONFIG_HEAP</dt>\n** <dd> ^The SQLITE_CONFIG_HEAP option specifies a static memory buffer \n** that SQLite will use for all of its dynamic memory allocation needs\n** beyond those provided for by [SQLITE_CONFIG_PAGECACHE].\n** ^The SQLITE_CONFIG_HEAP option is only available if SQLite is compiled\n** with either [SQLITE_ENABLE_MEMSYS3] or [SQLITE_ENABLE_MEMSYS5] and returns\n** [SQLITE_ERROR] if invoked otherwise.\n** ^There are three arguments to SQLITE_CONFIG_HEAP:\n** An 8-byte aligned pointer to the memory,\n** the number of bytes in the memory buffer, and the minimum allocation size.\n** ^If the first pointer (the memory pointer) is NULL, then SQLite reverts\n** to using its default memory allocator (the system malloc() implementation),\n** undoing any prior invocation of [SQLITE_CONFIG_MALLOC].  ^If the\n** memory pointer is not NULL then the alternative memory\n** allocator is engaged to handle all of SQLites memory allocation needs.\n** The first pointer (the memory pointer) must be aligned to an 8-byte\n** boundary or subsequent behavior of SQLite will be undefined.\n** The minimum allocation size is capped at 2**12. Reasonable values\n** for the minimum allocation size are 2**5 through 2**8.</dd>\n**\n** [[SQLITE_CONFIG_MUTEX]] <dt>SQLITE_CONFIG_MUTEX</dt>\n** <dd> ^(The SQLITE_CONFIG_MUTEX option takes a single argument which is a\n** pointer to an instance of the [sqlite3_mutex_methods] structure.\n** The argument specifies alternative low-level mutex routines to be used\n** in place the mutex routines built into SQLite.)^  ^SQLite makes a copy of\n** the content of the [sqlite3_mutex_methods] structure before the call to\n** [sqlite3_config()] returns. ^If SQLite is compiled with\n** the [SQLITE_THREADSAFE | SQLITE_THREADSAFE=0] compile-time option then\n** the entire mutexing subsystem is omitted from the build and hence calls to\n** [sqlite3_config()] with the SQLITE_CONFIG_MUTEX configuration option will\n** return [SQLITE_ERROR].</dd>\n**\n** [[SQLITE_CONFIG_GETMUTEX]] <dt>SQLITE_CONFIG_GETMUTEX</dt>\n** <dd> ^(The SQLITE_CONFIG_GETMUTEX option takes a single argument which\n** is a pointer to an instance of the [sqlite3_mutex_methods] structure.  The\n** [sqlite3_mutex_methods]\n** structure is filled with the currently defined mutex routines.)^\n** This option can be used to overload the default mutex allocation\n** routines with a wrapper used to track mutex usage for performance\n** profiling or testing, for example.   ^If SQLite is compiled with\n** the [SQLITE_THREADSAFE | SQLITE_THREADSAFE=0] compile-time option then\n** the entire mutexing subsystem is omitted from the build and hence calls to\n** [sqlite3_config()] with the SQLITE_CONFIG_GETMUTEX configuration option will\n** return [SQLITE_ERROR].</dd>\n**\n** [[SQLITE_CONFIG_LOOKASIDE]] <dt>SQLITE_CONFIG_LOOKASIDE</dt>\n** <dd> ^(The SQLITE_CONFIG_LOOKASIDE option takes two arguments that determine\n** the default size of lookaside memory on each [database connection].\n** The first argument is the\n** size of each lookaside buffer slot and the second is the number of\n** slots allocated to each database connection.)^  ^(SQLITE_CONFIG_LOOKASIDE\n** sets the <i>default</i> lookaside size. The [SQLITE_DBCONFIG_LOOKASIDE]\n** option to [sqlite3_db_config()] can be used to change the lookaside\n** configuration on individual connections.)^ </dd>\n**\n** [[SQLITE_CONFIG_PCACHE2]] <dt>SQLITE_CONFIG_PCACHE2</dt>\n** <dd> ^(The SQLITE_CONFIG_PCACHE2 option takes a single argument which is \n** a pointer to an [sqlite3_pcache_methods2] object.  This object specifies\n** the interface to a custom page cache implementation.)^\n** ^SQLite makes a copy of the [sqlite3_pcache_methods2] object.</dd>\n**\n** [[SQLITE_CONFIG_GETPCACHE2]] <dt>SQLITE_CONFIG_GETPCACHE2</dt>\n** <dd> ^(The SQLITE_CONFIG_GETPCACHE2 option takes a single argument which\n** is a pointer to an [sqlite3_pcache_methods2] object.  SQLite copies of\n** the current page cache implementation into that object.)^ </dd>\n**\n** [[SQLITE_CONFIG_LOG]] <dt>SQLITE_CONFIG_LOG</dt>\n** <dd> The SQLITE_CONFIG_LOG option is used to configure the SQLite\n** global [error log].\n** (^The SQLITE_CONFIG_LOG option takes two arguments: a pointer to a\n** function with a call signature of void(*)(void*,int,const char*), \n** and a pointer to void. ^If the function pointer is not NULL, it is\n** invoked by [sqlite3_log()] to process each logging event.  ^If the\n** function pointer is NULL, the [sqlite3_log()] interface becomes a no-op.\n** ^The void pointer that is the second argument to SQLITE_CONFIG_LOG is\n** passed through as the first parameter to the application-defined logger\n** function whenever that function is invoked.  ^The second parameter to\n** the logger function is a copy of the first parameter to the corresponding\n** [sqlite3_log()] call and is intended to be a [result code] or an\n** [extended result code].  ^The third parameter passed to the logger is\n** log message after formatting via [sqlite3_snprintf()].\n** The SQLite logging interface is not reentrant; the logger function\n** supplied by the application must not invoke any SQLite interface.\n** In a multi-threaded application, the application-defined logger\n** function must be threadsafe. </dd>\n**\n** [[SQLITE_CONFIG_URI]] <dt>SQLITE_CONFIG_URI\n** <dd>^(The SQLITE_CONFIG_URI option takes a single argument of type int.\n** If non-zero, then URI handling is globally enabled. If the parameter is zero,\n** then URI handling is globally disabled.)^ ^If URI handling is globally\n** enabled, all filenames passed to [sqlite3_open()], [sqlite3_open_v2()],\n** [sqlite3_open16()] or\n** specified as part of [ATTACH] commands are interpreted as URIs, regardless\n** of whether or not the [SQLITE_OPEN_URI] flag is set when the database\n** connection is opened. ^If it is globally disabled, filenames are\n** only interpreted as URIs if the SQLITE_OPEN_URI flag is set when the\n** database connection is opened. ^(By default, URI handling is globally\n** disabled. The default value may be changed by compiling with the\n** [SQLITE_USE_URI] symbol defined.)^\n**\n** [[SQLITE_CONFIG_COVERING_INDEX_SCAN]] <dt>SQLITE_CONFIG_COVERING_INDEX_SCAN\n** <dd>^The SQLITE_CONFIG_COVERING_INDEX_SCAN option takes a single integer\n** argument which is interpreted as a boolean in order to enable or disable\n** the use of covering indices for full table scans in the query optimizer.\n** ^The default setting is determined\n** by the [SQLITE_ALLOW_COVERING_INDEX_SCAN] compile-time option, or is \"on\"\n** if that compile-time option is omitted.\n** The ability to disable the use of covering indices for full table scans\n** is because some incorrectly coded legacy applications might malfunction\n** when the optimization is enabled.  Providing the ability to\n** disable the optimization allows the older, buggy application code to work\n** without change even with newer versions of SQLite.\n**\n** [[SQLITE_CONFIG_PCACHE]] [[SQLITE_CONFIG_GETPCACHE]]\n** <dt>SQLITE_CONFIG_PCACHE and SQLITE_CONFIG_GETPCACHE\n** <dd> These options are obsolete and should not be used by new code.\n** They are retained for backwards compatibility but are now no-ops.\n** </dd>\n**\n** [[SQLITE_CONFIG_SQLLOG]]\n** <dt>SQLITE_CONFIG_SQLLOG\n** <dd>This option is only available if sqlite is compiled with the\n** [SQLITE_ENABLE_SQLLOG] pre-processor macro defined. The first argument should\n** be a pointer to a function of type void(*)(void*,sqlite3*,const char*, int).\n** The second should be of type (void*). The callback is invoked by the library\n** in three separate circumstances, identified by the value passed as the\n** fourth parameter. If the fourth parameter is 0, then the database connection\n** passed as the second argument has just been opened. The third argument\n** points to a buffer containing the name of the main database file. If the\n** fourth parameter is 1, then the SQL statement that the third parameter\n** points to has just been executed. Or, if the fourth parameter is 2, then\n** the connection being passed as the second parameter is being closed. The\n** third parameter is passed NULL In this case.  An example of using this\n** configuration option can be seen in the \"test_sqllog.c\" source file in\n** the canonical SQLite source tree.</dd>\n**\n** [[SQLITE_CONFIG_MMAP_SIZE]]\n** <dt>SQLITE_CONFIG_MMAP_SIZE\n** <dd>^SQLITE_CONFIG_MMAP_SIZE takes two 64-bit integer (sqlite3_int64) values\n** that are the default mmap size limit (the default setting for\n** [PRAGMA mmap_size]) and the maximum allowed mmap size limit.\n** ^The default setting can be overridden by each database connection using\n** either the [PRAGMA mmap_size] command, or by using the\n** [SQLITE_FCNTL_MMAP_SIZE] file control.  ^(The maximum allowed mmap size\n** will be silently truncated if necessary so that it does not exceed the\n** compile-time maximum mmap size set by the\n** [SQLITE_MAX_MMAP_SIZE] compile-time option.)^\n** ^If either argument to this option is negative, then that argument is\n** changed to its compile-time default.\n**\n** [[SQLITE_CONFIG_WIN32_HEAPSIZE]]\n** <dt>SQLITE_CONFIG_WIN32_HEAPSIZE\n** <dd>^The SQLITE_CONFIG_WIN32_HEAPSIZE option is only available if SQLite is\n** compiled for Windows with the [SQLITE_WIN32_MALLOC] pre-processor macro\n** defined. ^SQLITE_CONFIG_WIN32_HEAPSIZE takes a 32-bit unsigned integer value\n** that specifies the maximum size of the created heap.\n**\n** [[SQLITE_CONFIG_PCACHE_HDRSZ]]\n** <dt>SQLITE_CONFIG_PCACHE_HDRSZ\n** <dd>^The SQLITE_CONFIG_PCACHE_HDRSZ option takes a single parameter which\n** is a pointer to an integer and writes into that integer the number of extra\n** bytes per page required for each page in [SQLITE_CONFIG_PAGECACHE].\n** The amount of extra space required can change depending on the compiler,\n** target platform, and SQLite version.\n**\n** [[SQLITE_CONFIG_PMASZ]]\n** <dt>SQLITE_CONFIG_PMASZ\n** <dd>^The SQLITE_CONFIG_PMASZ option takes a single parameter which\n** is an unsigned integer and sets the \"Minimum PMA Size\" for the multithreaded\n** sorter to that integer.  The default minimum PMA Size is set by the\n** [SQLITE_SORTER_PMASZ] compile-time option.  New threads are launched\n** to help with sort operations when multithreaded sorting\n** is enabled (using the [PRAGMA threads] command) and the amount of content\n** to be sorted exceeds the page size times the minimum of the\n** [PRAGMA cache_size] setting and this value.\n**\n** [[SQLITE_CONFIG_STMTJRNL_SPILL]]\n** <dt>SQLITE_CONFIG_STMTJRNL_SPILL\n** <dd>^The SQLITE_CONFIG_STMTJRNL_SPILL option takes a single parameter which\n** becomes the [statement journal] spill-to-disk threshold.  \n** [Statement journals] are held in memory until their size (in bytes)\n** exceeds this threshold, at which point they are written to disk.\n** Or if the threshold is -1, statement journals are always held\n** exclusively in memory.\n** Since many statement journals never become large, setting the spill\n** threshold to a value such as 64KiB can greatly reduce the amount of\n** I/O required to support statement rollback.\n** The default value for this setting is controlled by the\n** [SQLITE_STMTJRNL_SPILL] compile-time option.\n**\n** [[SQLITE_CONFIG_SORTERREF_SIZE]]\n** <dt>SQLITE_CONFIG_SORTERREF_SIZE\n** <dd>The SQLITE_CONFIG_SORTERREF_SIZE option accepts a single parameter\n** of type (int) - the new value of the sorter-reference size threshold.\n** Usually, when SQLite uses an external sort to order records according\n** to an ORDER BY clause, all fields required by the caller are present in the\n** sorted records. However, if SQLite determines based on the declared type\n** of a table column that its values are likely to be very large - larger\n** than the configured sorter-reference size threshold - then a reference\n** is stored in each sorted record and the required column values loaded\n** from the database as records are returned in sorted order. The default\n** value for this option is to never use this optimization. Specifying a \n** negative value for this option restores the default behaviour.\n** This option is only available if SQLite is compiled with the\n** [SQLITE_ENABLE_SORTER_REFERENCES] compile-time option.\n**\n** [[SQLITE_CONFIG_MEMDB_MAXSIZE]]\n** <dt>SQLITE_CONFIG_MEMDB_MAXSIZE\n** <dd>The SQLITE_CONFIG_MEMDB_MAXSIZE option accepts a single parameter\n** [sqlite3_int64] parameter which is the default maximum size for an in-memory\n** database created using [sqlite3_deserialize()].  This default maximum\n** size can be adjusted up or down for individual databases using the\n** [SQLITE_FCNTL_SIZE_LIMIT] [sqlite3_file_control|file-control].  If this\n** configuration setting is never used, then the default maximum is determined\n** by the [SQLITE_MEMDB_DEFAULT_MAXSIZE] compile-time option.  If that\n** compile-time option is not set, then the default maximum is 1073741824.\n** </dl>\n*/\n#define SQLITE_CONFIG_SINGLETHREAD  1  /* nil */\n#define SQLITE_CONFIG_MULTITHREAD   2  /* nil */\n#define SQLITE_CONFIG_SERIALIZED    3  /* nil */\n#define SQLITE_CONFIG_MALLOC        4  /* sqlite3_mem_methods* */\n#define SQLITE_CONFIG_GETMALLOC     5  /* sqlite3_mem_methods* */\n#define SQLITE_CONFIG_SCRATCH       6  /* No longer used */\n#define SQLITE_CONFIG_PAGECACHE     7  /* void*, int sz, int N */\n#define SQLITE_CONFIG_HEAP          8  /* void*, int nByte, int min */\n#define SQLITE_CONFIG_MEMSTATUS     9  /* boolean */\n#define SQLITE_CONFIG_MUTEX        10  /* sqlite3_mutex_methods* */\n#define SQLITE_CONFIG_GETMUTEX     11  /* sqlite3_mutex_methods* */\n/* previously SQLITE_CONFIG_CHUNKALLOC 12 which is now unused. */ \n#define SQLITE_CONFIG_LOOKASIDE    13  /* int int */\n#define SQLITE_CONFIG_PCACHE       14  /* no-op */\n#define SQLITE_CONFIG_GETPCACHE    15  /* no-op */\n#define SQLITE_CONFIG_LOG          16  /* xFunc, void* */\n#define SQLITE_CONFIG_URI          17  /* int */\n#define SQLITE_CONFIG_PCACHE2      18  /* sqlite3_pcache_methods2* */\n#define SQLITE_CONFIG_GETPCACHE2   19  /* sqlite3_pcache_methods2* */\n#define SQLITE_CONFIG_COVERING_INDEX_SCAN 20  /* int */\n#define SQLITE_CONFIG_SQLLOG       21  /* xSqllog, void* */\n#define SQLITE_CONFIG_MMAP_SIZE    22  /* sqlite3_int64, sqlite3_int64 */\n#define SQLITE_CONFIG_WIN32_HEAPSIZE      23  /* int nByte */\n#define SQLITE_CONFIG_PCACHE_HDRSZ        24  /* int *psz */\n#define SQLITE_CONFIG_PMASZ               25  /* unsigned int szPma */\n#define SQLITE_CONFIG_STMTJRNL_SPILL      26  /* int nByte */\n#define SQLITE_CONFIG_SMALL_MALLOC        27  /* boolean */\n#define SQLITE_CONFIG_SORTERREF_SIZE      28  /* int nByte */\n#define SQLITE_CONFIG_MEMDB_MAXSIZE       29  /* sqlite3_int64 */\n\n/*\n** CAPI3REF: Database Connection Configuration Options\n**\n** These constants are the available integer configuration options that\n** can be passed as the second argument to the [sqlite3_db_config()] interface.\n**\n** New configuration options may be added in future releases of SQLite.\n** Existing configuration options might be discontinued.  Applications\n** should check the return code from [sqlite3_db_config()] to make sure that\n** the call worked.  ^The [sqlite3_db_config()] interface will return a\n** non-zero [error code] if a discontinued or unsupported configuration option\n** is invoked.\n**\n** <dl>\n** [[SQLITE_DBCONFIG_LOOKASIDE]]\n** <dt>SQLITE_DBCONFIG_LOOKASIDE</dt>\n** <dd> ^This option takes three additional arguments that determine the \n** [lookaside memory allocator] configuration for the [database connection].\n** ^The first argument (the third parameter to [sqlite3_db_config()] is a\n** pointer to a memory buffer to use for lookaside memory.\n** ^The first argument after the SQLITE_DBCONFIG_LOOKASIDE verb\n** may be NULL in which case SQLite will allocate the\n** lookaside buffer itself using [sqlite3_malloc()]. ^The second argument is the\n** size of each lookaside buffer slot.  ^The third argument is the number of\n** slots.  The size of the buffer in the first argument must be greater than\n** or equal to the product of the second and third arguments.  The buffer\n** must be aligned to an 8-byte boundary.  ^If the second argument to\n** SQLITE_DBCONFIG_LOOKASIDE is not a multiple of 8, it is internally\n** rounded down to the next smaller multiple of 8.  ^(The lookaside memory\n** configuration for a database connection can only be changed when that\n** connection is not currently using lookaside memory, or in other words\n** when the \"current value\" returned by\n** [sqlite3_db_status](D,[SQLITE_CONFIG_LOOKASIDE],...) is zero.\n** Any attempt to change the lookaside memory configuration when lookaside\n** memory is in use leaves the configuration unchanged and returns \n** [SQLITE_BUSY].)^</dd>\n**\n** [[SQLITE_DBCONFIG_ENABLE_FKEY]]\n** <dt>SQLITE_DBCONFIG_ENABLE_FKEY</dt>\n** <dd> ^This option is used to enable or disable the enforcement of\n** [foreign key constraints].  There should be two additional arguments.\n** The first argument is an integer which is 0 to disable FK enforcement,\n** positive to enable FK enforcement or negative to leave FK enforcement\n** unchanged.  The second parameter is a pointer to an integer into which\n** is written 0 or 1 to indicate whether FK enforcement is off or on\n** following this call.  The second parameter may be a NULL pointer, in\n** which case the FK enforcement setting is not reported back. </dd>\n**\n** [[SQLITE_DBCONFIG_ENABLE_TRIGGER]]\n** <dt>SQLITE_DBCONFIG_ENABLE_TRIGGER</dt>\n** <dd> ^This option is used to enable or disable [CREATE TRIGGER | triggers].\n** There should be two additional arguments.\n** The first argument is an integer which is 0 to disable triggers,\n** positive to enable triggers or negative to leave the setting unchanged.\n** The second parameter is a pointer to an integer into which\n** is written 0 or 1 to indicate whether triggers are disabled or enabled\n** following this call.  The second parameter may be a NULL pointer, in\n** which case the trigger setting is not reported back. </dd>\n**\n** [[SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER]]\n** <dt>SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER</dt>\n** <dd> ^This option is used to enable or disable the two-argument\n** version of the [fts3_tokenizer()] function which is part of the\n** [FTS3] full-text search engine extension.\n** There should be two additional arguments.\n** The first argument is an integer which is 0 to disable fts3_tokenizer() or\n** positive to enable fts3_tokenizer() or negative to leave the setting\n** unchanged.\n** The second parameter is a pointer to an integer into which\n** is written 0 or 1 to indicate whether fts3_tokenizer is disabled or enabled\n** following this call.  The second parameter may be a NULL pointer, in\n** which case the new setting is not reported back. </dd>\n**\n** [[SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION]]\n** <dt>SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION</dt>\n** <dd> ^This option is used to enable or disable the [sqlite3_load_extension()]\n** interface independently of the [load_extension()] SQL function.\n** The [sqlite3_enable_load_extension()] API enables or disables both the\n** C-API [sqlite3_load_extension()] and the SQL function [load_extension()].\n** There should be two additional arguments.\n** When the first argument to this interface is 1, then only the C-API is\n** enabled and the SQL function remains disabled.  If the first argument to\n** this interface is 0, then both the C-API and the SQL function are disabled.\n** If the first argument is -1, then no changes are made to state of either the\n** C-API or the SQL function.\n** The second parameter is a pointer to an integer into which\n** is written 0 or 1 to indicate whether [sqlite3_load_extension()] interface\n** is disabled or enabled following this call.  The second parameter may\n** be a NULL pointer, in which case the new setting is not reported back.\n** </dd>\n**\n** [[SQLITE_DBCONFIG_MAINDBNAME]] <dt>SQLITE_DBCONFIG_MAINDBNAME</dt>\n** <dd> ^This option is used to change the name of the \"main\" database\n** schema.  ^The sole argument is a pointer to a constant UTF8 string\n** which will become the new schema name in place of \"main\".  ^SQLite\n** does not make a copy of the new main schema name string, so the application\n** must ensure that the argument passed into this DBCONFIG option is unchanged\n** until after the database connection closes.\n** </dd>\n**\n** [[SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE]] \n** <dt>SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE</dt>\n** <dd> Usually, when a database in wal mode is closed or detached from a \n** database handle, SQLite checks if this will mean that there are now no \n** connections at all to the database. If so, it performs a checkpoint \n** operation before closing the connection. This option may be used to\n** override this behaviour. The first parameter passed to this operation\n** is an integer - positive to disable checkpoints-on-close, or zero (the\n** default) to enable them, and negative to leave the setting unchanged.\n** The second parameter is a pointer to an integer\n** into which is written 0 or 1 to indicate whether checkpoints-on-close\n** have been disabled - 0 if they are not disabled, 1 if they are.\n** </dd>\n**\n** [[SQLITE_DBCONFIG_ENABLE_QPSG]] <dt>SQLITE_DBCONFIG_ENABLE_QPSG</dt>\n** <dd>^(The SQLITE_DBCONFIG_ENABLE_QPSG option activates or deactivates\n** the [query planner stability guarantee] (QPSG).  When the QPSG is active,\n** a single SQL query statement will always use the same algorithm regardless\n** of values of [bound parameters].)^ The QPSG disables some query optimizations\n** that look at the values of bound parameters, which can make some queries\n** slower.  But the QPSG has the advantage of more predictable behavior.  With\n** the QPSG active, SQLite will always use the same query plan in the field as\n** was used during testing in the lab.\n** The first argument to this setting is an integer which is 0 to disable \n** the QPSG, positive to enable QPSG, or negative to leave the setting\n** unchanged. The second parameter is a pointer to an integer into which\n** is written 0 or 1 to indicate whether the QPSG is disabled or enabled\n** following this call.\n** </dd>\n**\n** [[SQLITE_DBCONFIG_TRIGGER_EQP]] <dt>SQLITE_DBCONFIG_TRIGGER_EQP</dt>\n** <dd> By default, the output of EXPLAIN QUERY PLAN commands does not \n** include output for any operations performed by trigger programs. This\n** option is used to set or clear (the default) a flag that governs this\n** behavior. The first parameter passed to this operation is an integer -\n** positive to enable output for trigger programs, or zero to disable it,\n** or negative to leave the setting unchanged.\n** The second parameter is a pointer to an integer into which is written \n** 0 or 1 to indicate whether output-for-triggers has been disabled - 0 if \n** it is not disabled, 1 if it is.  \n** </dd>\n**\n** [[SQLITE_DBCONFIG_RESET_DATABASE]] <dt>SQLITE_DBCONFIG_RESET_DATABASE</dt>\n** <dd> Set the SQLITE_DBCONFIG_RESET_DATABASE flag and then run\n** [VACUUM] in order to reset a database back to an empty database\n** with no schema and no content. The following process works even for\n** a badly corrupted database file:\n** <ol>\n** <li> If the database connection is newly opened, make sure it has read the\n**      database schema by preparing then discarding some query against the\n**      database, or calling sqlite3_table_column_metadata(), ignoring any\n**      errors.  This step is only necessary if the application desires to keep\n**      the database in WAL mode after the reset if it was in WAL mode before\n**      the reset.  \n** <li> sqlite3_db_config(db, SQLITE_DBCONFIG_RESET_DATABASE, 1, 0);\n** <li> [sqlite3_exec](db, \"[VACUUM]\", 0, 0, 0);\n** <li> sqlite3_db_config(db, SQLITE_DBCONFIG_RESET_DATABASE, 0, 0);\n** </ol>\n** Because resetting a database is destructive and irreversible, the\n** process requires the use of this obscure API and multiple steps to help\n** ensure that it does not happen by accident.\n**\n** [[SQLITE_DBCONFIG_DEFENSIVE]] <dt>SQLITE_DBCONFIG_DEFENSIVE</dt>\n** <dd>The SQLITE_DBCONFIG_DEFENSIVE option activates or deactivates the\n** \"defensive\" flag for a database connection.  When the defensive\n** flag is enabled, language features that allow ordinary SQL to \n** deliberately corrupt the database file are disabled.  The disabled\n** features include but are not limited to the following:\n** <ul>\n** <li> The [PRAGMA writable_schema=ON] statement.\n** <li> Writes to the [sqlite_dbpage] virtual table.\n** <li> Direct writes to [shadow tables].\n** </ul>\n** </dd>\n** </dl>\n*/\n#define SQLITE_DBCONFIG_MAINDBNAME            1000 /* const char* */\n#define SQLITE_DBCONFIG_LOOKASIDE             1001 /* void* int int */\n#define SQLITE_DBCONFIG_ENABLE_FKEY           1002 /* int int* */\n#define SQLITE_DBCONFIG_ENABLE_TRIGGER        1003 /* int int* */\n#define SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER 1004 /* int int* */\n#define SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION 1005 /* int int* */\n#define SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE      1006 /* int int* */\n#define SQLITE_DBCONFIG_ENABLE_QPSG           1007 /* int int* */\n#define SQLITE_DBCONFIG_TRIGGER_EQP           1008 /* int int* */\n#define SQLITE_DBCONFIG_RESET_DATABASE        1009 /* int int* */\n#define SQLITE_DBCONFIG_DEFENSIVE             1010 /* int int* */\n#define SQLITE_DBCONFIG_MAX                   1010 /* Largest DBCONFIG */\n\n/*\n** CAPI3REF: Enable Or Disable Extended Result Codes\n** METHOD: sqlite3\n**\n** ^The sqlite3_extended_result_codes() routine enables or disables the\n** [extended result codes] feature of SQLite. ^The extended result\n** codes are disabled by default for historical compatibility.\n*/\nSQLITE_API int sqlite3_extended_result_codes(sqlite3*, int onoff);\n\n/*\n** CAPI3REF: Last Insert Rowid\n** METHOD: sqlite3\n**\n** ^Each entry in most SQLite tables (except for [WITHOUT ROWID] tables)\n** has a unique 64-bit signed\n** integer key called the [ROWID | \"rowid\"]. ^The rowid is always available\n** as an undeclared column named ROWID, OID, or _ROWID_ as long as those\n** names are not also used by explicitly declared columns. ^If\n** the table has a column of type [INTEGER PRIMARY KEY] then that column\n** is another alias for the rowid.\n**\n** ^The sqlite3_last_insert_rowid(D) interface usually returns the [rowid] of\n** the most recent successful [INSERT] into a rowid table or [virtual table]\n** on database connection D. ^Inserts into [WITHOUT ROWID] tables are not\n** recorded. ^If no successful [INSERT]s into rowid tables have ever occurred \n** on the database connection D, then sqlite3_last_insert_rowid(D) returns \n** zero.\n**\n** As well as being set automatically as rows are inserted into database\n** tables, the value returned by this function may be set explicitly by\n** [sqlite3_set_last_insert_rowid()]\n**\n** Some virtual table implementations may INSERT rows into rowid tables as\n** part of committing a transaction (e.g. to flush data accumulated in memory\n** to disk). In this case subsequent calls to this function return the rowid\n** associated with these internal INSERT operations, which leads to \n** unintuitive results. Virtual table implementations that do write to rowid\n** tables in this way can avoid this problem by restoring the original \n** rowid value using [sqlite3_set_last_insert_rowid()] before returning \n** control to the user.\n**\n** ^(If an [INSERT] occurs within a trigger then this routine will \n** return the [rowid] of the inserted row as long as the trigger is \n** running. Once the trigger program ends, the value returned \n** by this routine reverts to what it was before the trigger was fired.)^\n**\n** ^An [INSERT] that fails due to a constraint violation is not a\n** successful [INSERT] and does not change the value returned by this\n** routine.  ^Thus INSERT OR FAIL, INSERT OR IGNORE, INSERT OR ROLLBACK,\n** and INSERT OR ABORT make no changes to the return value of this\n** routine when their insertion fails.  ^(When INSERT OR REPLACE\n** encounters a constraint violation, it does not fail.  The\n** INSERT continues to completion after deleting rows that caused\n** the constraint problem so INSERT OR REPLACE will always change\n** the return value of this interface.)^\n**\n** ^For the purposes of this routine, an [INSERT] is considered to\n** be successful even if it is subsequently rolled back.\n**\n** This function is accessible to SQL statements via the\n** [last_insert_rowid() SQL function].\n**\n** If a separate thread performs a new [INSERT] on the same\n** database connection while the [sqlite3_last_insert_rowid()]\n** function is running and thus changes the last insert [rowid],\n** then the value returned by [sqlite3_last_insert_rowid()] is\n** unpredictable and might not equal either the old or the new\n** last insert [rowid].\n*/\nSQLITE_API sqlite3_int64 sqlite3_last_insert_rowid(sqlite3*);\n\n/*\n** CAPI3REF: Set the Last Insert Rowid value.\n** METHOD: sqlite3\n**\n** The sqlite3_set_last_insert_rowid(D, R) method allows the application to\n** set the value returned by calling sqlite3_last_insert_rowid(D) to R \n** without inserting a row into the database.\n*/\nSQLITE_API void sqlite3_set_last_insert_rowid(sqlite3*,sqlite3_int64);\n\n/*\n** CAPI3REF: Count The Number Of Rows Modified\n** METHOD: sqlite3\n**\n** ^This function returns the number of rows modified, inserted or\n** deleted by the most recently completed INSERT, UPDATE or DELETE\n** statement on the database connection specified by the only parameter.\n** ^Executing any other type of SQL statement does not modify the value\n** returned by this function.\n**\n** ^Only changes made directly by the INSERT, UPDATE or DELETE statement are\n** considered - auxiliary changes caused by [CREATE TRIGGER | triggers], \n** [foreign key actions] or [REPLACE] constraint resolution are not counted.\n** \n** Changes to a view that are intercepted by \n** [INSTEAD OF trigger | INSTEAD OF triggers] are not counted. ^The value \n** returned by sqlite3_changes() immediately after an INSERT, UPDATE or \n** DELETE statement run on a view is always zero. Only changes made to real \n** tables are counted.\n**\n** Things are more complicated if the sqlite3_changes() function is\n** executed while a trigger program is running. This may happen if the\n** program uses the [changes() SQL function], or if some other callback\n** function invokes sqlite3_changes() directly. Essentially:\n** \n** <ul>\n**   <li> ^(Before entering a trigger program the value returned by\n**        sqlite3_changes() function is saved. After the trigger program \n**        has finished, the original value is restored.)^\n** \n**   <li> ^(Within a trigger program each INSERT, UPDATE and DELETE \n**        statement sets the value returned by sqlite3_changes() \n**        upon completion as normal. Of course, this value will not include \n**        any changes performed by sub-triggers, as the sqlite3_changes() \n**        value will be saved and restored after each sub-trigger has run.)^\n** </ul>\n** \n** ^This means that if the changes() SQL function (or similar) is used\n** by the first INSERT, UPDATE or DELETE statement within a trigger, it \n** returns the value as set when the calling statement began executing.\n** ^If it is used by the second or subsequent such statement within a trigger \n** program, the value returned reflects the number of rows modified by the \n** previous INSERT, UPDATE or DELETE statement within the same trigger.\n**\n** If a separate thread makes changes on the same database connection\n** while [sqlite3_changes()] is running then the value returned\n** is unpredictable and not meaningful.\n**\n** See also:\n** <ul>\n** <li> the [sqlite3_total_changes()] interface\n** <li> the [count_changes pragma]\n** <li> the [changes() SQL function]\n** <li> the [data_version pragma]\n** </ul>\n*/\nSQLITE_API int sqlite3_changes(sqlite3*);\n\n/*\n** CAPI3REF: Total Number Of Rows Modified\n** METHOD: sqlite3\n**\n** ^This function returns the total number of rows inserted, modified or\n** deleted by all [INSERT], [UPDATE] or [DELETE] statements completed\n** since the database connection was opened, including those executed as\n** part of trigger programs. ^Executing any other type of SQL statement\n** does not affect the value returned by sqlite3_total_changes().\n** \n** ^Changes made as part of [foreign key actions] are included in the\n** count, but those made as part of REPLACE constraint resolution are\n** not. ^Changes to a view that are intercepted by INSTEAD OF triggers \n** are not counted.\n**\n** The [sqlite3_total_changes(D)] interface only reports the number\n** of rows that changed due to SQL statement run against database\n** connection D.  Any changes by other database connections are ignored.\n** To detect changes against a database file from other database\n** connections use the [PRAGMA data_version] command or the\n** [SQLITE_FCNTL_DATA_VERSION] [file control].\n** \n** If a separate thread makes changes on the same database connection\n** while [sqlite3_total_changes()] is running then the value\n** returned is unpredictable and not meaningful.\n**\n** See also:\n** <ul>\n** <li> the [sqlite3_changes()] interface\n** <li> the [count_changes pragma]\n** <li> the [changes() SQL function]\n** <li> the [data_version pragma]\n** <li> the [SQLITE_FCNTL_DATA_VERSION] [file control]\n** </ul>\n*/\nSQLITE_API int sqlite3_total_changes(sqlite3*);\n\n/*\n** CAPI3REF: Interrupt A Long-Running Query\n** METHOD: sqlite3\n**\n** ^This function causes any pending database operation to abort and\n** return at its earliest opportunity. This routine is typically\n** called in response to a user action such as pressing \"Cancel\"\n** or Ctrl-C where the user wants a long query operation to halt\n** immediately.\n**\n** ^It is safe to call this routine from a thread different from the\n** thread that is currently running the database operation.  But it\n** is not safe to call this routine with a [database connection] that\n** is closed or might close before sqlite3_interrupt() returns.\n**\n** ^If an SQL operation is very nearly finished at the time when\n** sqlite3_interrupt() is called, then it might not have an opportunity\n** to be interrupted and might continue to completion.\n**\n** ^An SQL operation that is interrupted will return [SQLITE_INTERRUPT].\n** ^If the interrupted SQL operation is an INSERT, UPDATE, or DELETE\n** that is inside an explicit transaction, then the entire transaction\n** will be rolled back automatically.\n**\n** ^The sqlite3_interrupt(D) call is in effect until all currently running\n** SQL statements on [database connection] D complete.  ^Any new SQL statements\n** that are started after the sqlite3_interrupt() call and before the \n** running statements reaches zero are interrupted as if they had been\n** running prior to the sqlite3_interrupt() call.  ^New SQL statements\n** that are started after the running statement count reaches zero are\n** not effected by the sqlite3_interrupt().\n** ^A call to sqlite3_interrupt(D) that occurs when there are no running\n** SQL statements is a no-op and has no effect on SQL statements\n** that are started after the sqlite3_interrupt() call returns.\n*/\nSQLITE_API void sqlite3_interrupt(sqlite3*);\n\n/*\n** CAPI3REF: Determine If An SQL Statement Is Complete\n**\n** These routines are useful during command-line input to determine if the\n** currently entered text seems to form a complete SQL statement or\n** if additional input is needed before sending the text into\n** SQLite for parsing.  ^These routines return 1 if the input string\n** appears to be a complete SQL statement.  ^A statement is judged to be\n** complete if it ends with a semicolon token and is not a prefix of a\n** well-formed CREATE TRIGGER statement.  ^Semicolons that are embedded within\n** string literals or quoted identifier names or comments are not\n** independent tokens (they are part of the token in which they are\n** embedded) and thus do not count as a statement terminator.  ^Whitespace\n** and comments that follow the final semicolon are ignored.\n**\n** ^These routines return 0 if the statement is incomplete.  ^If a\n** memory allocation fails, then SQLITE_NOMEM is returned.\n**\n** ^These routines do not parse the SQL statements thus\n** will not detect syntactically incorrect SQL.\n**\n** ^(If SQLite has not been initialized using [sqlite3_initialize()] prior \n** to invoking sqlite3_complete16() then sqlite3_initialize() is invoked\n** automatically by sqlite3_complete16().  If that initialization fails,\n** then the return value from sqlite3_complete16() will be non-zero\n** regardless of whether or not the input SQL is complete.)^\n**\n** The input to [sqlite3_complete()] must be a zero-terminated\n** UTF-8 string.\n**\n** The input to [sqlite3_complete16()] must be a zero-terminated\n** UTF-16 string in native byte order.\n*/\nSQLITE_API int sqlite3_complete(const char *sql);\nSQLITE_API int sqlite3_complete16(const void *sql);\n\n/*\n** CAPI3REF: Register A Callback To Handle SQLITE_BUSY Errors\n** KEYWORDS: {busy-handler callback} {busy handler}\n** METHOD: sqlite3\n**\n** ^The sqlite3_busy_handler(D,X,P) routine sets a callback function X\n** that might be invoked with argument P whenever\n** an attempt is made to access a database table associated with\n** [database connection] D when another thread\n** or process has the table locked.\n** The sqlite3_busy_handler() interface is used to implement\n** [sqlite3_busy_timeout()] and [PRAGMA busy_timeout].\n**\n** ^If the busy callback is NULL, then [SQLITE_BUSY]\n** is returned immediately upon encountering the lock.  ^If the busy callback\n** is not NULL, then the callback might be invoked with two arguments.\n**\n** ^The first argument to the busy handler is a copy of the void* pointer which\n** is the third argument to sqlite3_busy_handler().  ^The second argument to\n** the busy handler callback is the number of times that the busy handler has\n** been invoked previously for the same locking event.  ^If the\n** busy callback returns 0, then no additional attempts are made to\n** access the database and [SQLITE_BUSY] is returned\n** to the application.\n** ^If the callback returns non-zero, then another attempt\n** is made to access the database and the cycle repeats.\n**\n** The presence of a busy handler does not guarantee that it will be invoked\n** when there is lock contention. ^If SQLite determines that invoking the busy\n** handler could result in a deadlock, it will go ahead and return [SQLITE_BUSY]\n** to the application instead of invoking the \n** busy handler.\n** Consider a scenario where one process is holding a read lock that\n** it is trying to promote to a reserved lock and\n** a second process is holding a reserved lock that it is trying\n** to promote to an exclusive lock.  The first process cannot proceed\n** because it is blocked by the second and the second process cannot\n** proceed because it is blocked by the first.  If both processes\n** invoke the busy handlers, neither will make any progress.  Therefore,\n** SQLite returns [SQLITE_BUSY] for the first process, hoping that this\n** will induce the first process to release its read lock and allow\n** the second process to proceed.\n**\n** ^The default busy callback is NULL.\n**\n** ^(There can only be a single busy handler defined for each\n** [database connection].  Setting a new busy handler clears any\n** previously set handler.)^  ^Note that calling [sqlite3_busy_timeout()]\n** or evaluating [PRAGMA busy_timeout=N] will change the\n** busy handler and thus clear any previously set busy handler.\n**\n** The busy callback should not take any actions which modify the\n** database connection that invoked the busy handler.  In other words,\n** the busy handler is not reentrant.  Any such actions\n** result in undefined behavior.\n** \n** A busy handler must not close the database connection\n** or [prepared statement] that invoked the busy handler.\n*/\nSQLITE_API int sqlite3_busy_handler(sqlite3*,int(*)(void*,int),void*);\n\n/*\n** CAPI3REF: Set A Busy Timeout\n** METHOD: sqlite3\n**\n** ^This routine sets a [sqlite3_busy_handler | busy handler] that sleeps\n** for a specified amount of time when a table is locked.  ^The handler\n** will sleep multiple times until at least \"ms\" milliseconds of sleeping\n** have accumulated.  ^After at least \"ms\" milliseconds of sleeping,\n** the handler returns 0 which causes [sqlite3_step()] to return\n** [SQLITE_BUSY].\n**\n** ^Calling this routine with an argument less than or equal to zero\n** turns off all busy handlers.\n**\n** ^(There can only be a single busy handler for a particular\n** [database connection] at any given moment.  If another busy handler\n** was defined  (using [sqlite3_busy_handler()]) prior to calling\n** this routine, that other busy handler is cleared.)^\n**\n** See also:  [PRAGMA busy_timeout]\n*/\nSQLITE_API int sqlite3_busy_timeout(sqlite3*, int ms);\n\n/*\n** CAPI3REF: Convenience Routines For Running Queries\n** METHOD: sqlite3\n**\n** This is a legacy interface that is preserved for backwards compatibility.\n** Use of this interface is not recommended.\n**\n** Definition: A <b>result table</b> is memory data structure created by the\n** [sqlite3_get_table()] interface.  A result table records the\n** complete query results from one or more queries.\n**\n** The table conceptually has a number of rows and columns.  But\n** these numbers are not part of the result table itself.  These\n** numbers are obtained separately.  Let N be the number of rows\n** and M be the number of columns.\n**\n** A result table is an array of pointers to zero-terminated UTF-8 strings.\n** There are (N+1)*M elements in the array.  The first M pointers point\n** to zero-terminated strings that  contain the names of the columns.\n** The remaining entries all point to query results.  NULL values result\n** in NULL pointers.  All other values are in their UTF-8 zero-terminated\n** string representation as returned by [sqlite3_column_text()].\n**\n** A result table might consist of one or more memory allocations.\n** It is not safe to pass a result table directly to [sqlite3_free()].\n** A result table should be deallocated using [sqlite3_free_table()].\n**\n** ^(As an example of the result table format, suppose a query result\n** is as follows:\n**\n** <blockquote><pre>\n**        Name        | Age\n**        -----------------------\n**        Alice       | 43\n**        Bob         | 28\n**        Cindy       | 21\n** </pre></blockquote>\n**\n** There are two column (M==2) and three rows (N==3).  Thus the\n** result table has 8 entries.  Suppose the result table is stored\n** in an array names azResult.  Then azResult holds this content:\n**\n** <blockquote><pre>\n**        azResult&#91;0] = \"Name\";\n**        azResult&#91;1] = \"Age\";\n**        azResult&#91;2] = \"Alice\";\n**        azResult&#91;3] = \"43\";\n**        azResult&#91;4] = \"Bob\";\n**        azResult&#91;5] = \"28\";\n**        azResult&#91;6] = \"Cindy\";\n**        azResult&#91;7] = \"21\";\n** </pre></blockquote>)^\n**\n** ^The sqlite3_get_table() function evaluates one or more\n** semicolon-separated SQL statements in the zero-terminated UTF-8\n** string of its 2nd parameter and returns a result table to the\n** pointer given in its 3rd parameter.\n**\n** After the application has finished with the result from sqlite3_get_table(),\n** it must pass the result table pointer to sqlite3_free_table() in order to\n** release the memory that was malloced.  Because of the way the\n** [sqlite3_malloc()] happens within sqlite3_get_table(), the calling\n** function must not try to call [sqlite3_free()] directly.  Only\n** [sqlite3_free_table()] is able to release the memory properly and safely.\n**\n** The sqlite3_get_table() interface is implemented as a wrapper around\n** [sqlite3_exec()].  The sqlite3_get_table() routine does not have access\n** to any internal data structures of SQLite.  It uses only the public\n** interface defined here.  As a consequence, errors that occur in the\n** wrapper layer outside of the internal [sqlite3_exec()] call are not\n** reflected in subsequent calls to [sqlite3_errcode()] or\n** [sqlite3_errmsg()].\n*/\nSQLITE_API int sqlite3_get_table(\n  sqlite3 *db,          /* An open database */\n  const char *zSql,     /* SQL to be evaluated */\n  char ***pazResult,    /* Results of the query */\n  int *pnRow,           /* Number of result rows written here */\n  int *pnColumn,        /* Number of result columns written here */\n  char **pzErrmsg       /* Error msg written here */\n);\nSQLITE_API void sqlite3_free_table(char **result);\n\n/*\n** CAPI3REF: Formatted String Printing Functions\n**\n** These routines are work-alikes of the \"printf()\" family of functions\n** from the standard C library.\n** These routines understand most of the common formatting options from\n** the standard library printf() \n** plus some additional non-standard formats ([%q], [%Q], [%w], and [%z]).\n** See the [built-in printf()] documentation for details.\n**\n** ^The sqlite3_mprintf() and sqlite3_vmprintf() routines write their\n** results into memory obtained from [sqlite3_malloc64()].\n** The strings returned by these two routines should be\n** released by [sqlite3_free()].  ^Both routines return a\n** NULL pointer if [sqlite3_malloc64()] is unable to allocate enough\n** memory to hold the resulting string.\n**\n** ^(The sqlite3_snprintf() routine is similar to \"snprintf()\" from\n** the standard C library.  The result is written into the\n** buffer supplied as the second parameter whose size is given by\n** the first parameter. Note that the order of the\n** first two parameters is reversed from snprintf().)^  This is an\n** historical accident that cannot be fixed without breaking\n** backwards compatibility.  ^(Note also that sqlite3_snprintf()\n** returns a pointer to its buffer instead of the number of\n** characters actually written into the buffer.)^  We admit that\n** the number of characters written would be a more useful return\n** value but we cannot change the implementation of sqlite3_snprintf()\n** now without breaking compatibility.\n**\n** ^As long as the buffer size is greater than zero, sqlite3_snprintf()\n** guarantees that the buffer is always zero-terminated.  ^The first\n** parameter \"n\" is the total size of the buffer, including space for\n** the zero terminator.  So the longest string that can be completely\n** written will be n-1 characters.\n**\n** ^The sqlite3_vsnprintf() routine is a varargs version of sqlite3_snprintf().\n**\n** See also:  [built-in printf()], [printf() SQL function]\n*/\nSQLITE_API char *sqlite3_mprintf(const char*,...);\nSQLITE_API char *sqlite3_vmprintf(const char*, va_list);\nSQLITE_API char *sqlite3_snprintf(int,char*,const char*, ...);\nSQLITE_API char *sqlite3_vsnprintf(int,char*,const char*, va_list);\n\n/*\n** CAPI3REF: Memory Allocation Subsystem\n**\n** The SQLite core uses these three routines for all of its own\n** internal memory allocation needs. \"Core\" in the previous sentence\n** does not include operating-system specific VFS implementation.  The\n** Windows VFS uses native malloc() and free() for some operations.\n**\n** ^The sqlite3_malloc() routine returns a pointer to a block\n** of memory at least N bytes in length, where N is the parameter.\n** ^If sqlite3_malloc() is unable to obtain sufficient free\n** memory, it returns a NULL pointer.  ^If the parameter N to\n** sqlite3_malloc() is zero or negative then sqlite3_malloc() returns\n** a NULL pointer.\n**\n** ^The sqlite3_malloc64(N) routine works just like\n** sqlite3_malloc(N) except that N is an unsigned 64-bit integer instead\n** of a signed 32-bit integer.\n**\n** ^Calling sqlite3_free() with a pointer previously returned\n** by sqlite3_malloc() or sqlite3_realloc() releases that memory so\n** that it might be reused.  ^The sqlite3_free() routine is\n** a no-op if is called with a NULL pointer.  Passing a NULL pointer\n** to sqlite3_free() is harmless.  After being freed, memory\n** should neither be read nor written.  Even reading previously freed\n** memory might result in a segmentation fault or other severe error.\n** Memory corruption, a segmentation fault, or other severe error\n** might result if sqlite3_free() is called with a non-NULL pointer that\n** was not obtained from sqlite3_malloc() or sqlite3_realloc().\n**\n** ^The sqlite3_realloc(X,N) interface attempts to resize a\n** prior memory allocation X to be at least N bytes.\n** ^If the X parameter to sqlite3_realloc(X,N)\n** is a NULL pointer then its behavior is identical to calling\n** sqlite3_malloc(N).\n** ^If the N parameter to sqlite3_realloc(X,N) is zero or\n** negative then the behavior is exactly the same as calling\n** sqlite3_free(X).\n** ^sqlite3_realloc(X,N) returns a pointer to a memory allocation\n** of at least N bytes in size or NULL if insufficient memory is available.\n** ^If M is the size of the prior allocation, then min(N,M) bytes\n** of the prior allocation are copied into the beginning of buffer returned\n** by sqlite3_realloc(X,N) and the prior allocation is freed.\n** ^If sqlite3_realloc(X,N) returns NULL and N is positive, then the\n** prior allocation is not freed.\n**\n** ^The sqlite3_realloc64(X,N) interfaces works the same as\n** sqlite3_realloc(X,N) except that N is a 64-bit unsigned integer instead\n** of a 32-bit signed integer.\n**\n** ^If X is a memory allocation previously obtained from sqlite3_malloc(),\n** sqlite3_malloc64(), sqlite3_realloc(), or sqlite3_realloc64(), then\n** sqlite3_msize(X) returns the size of that memory allocation in bytes.\n** ^The value returned by sqlite3_msize(X) might be larger than the number\n** of bytes requested when X was allocated.  ^If X is a NULL pointer then\n** sqlite3_msize(X) returns zero.  If X points to something that is not\n** the beginning of memory allocation, or if it points to a formerly\n** valid memory allocation that has now been freed, then the behavior\n** of sqlite3_msize(X) is undefined and possibly harmful.\n**\n** ^The memory returned by sqlite3_malloc(), sqlite3_realloc(),\n** sqlite3_malloc64(), and sqlite3_realloc64()\n** is always aligned to at least an 8 byte boundary, or to a\n** 4 byte boundary if the [SQLITE_4_BYTE_ALIGNED_MALLOC] compile-time\n** option is used.\n**\n** In SQLite version 3.5.0 and 3.5.1, it was possible to define\n** the SQLITE_OMIT_MEMORY_ALLOCATION which would cause the built-in\n** implementation of these routines to be omitted.  That capability\n** is no longer provided.  Only built-in memory allocators can be used.\n**\n** Prior to SQLite version 3.7.10, the Windows OS interface layer called\n** the system malloc() and free() directly when converting\n** filenames between the UTF-8 encoding used by SQLite\n** and whatever filename encoding is used by the particular Windows\n** installation.  Memory allocation errors were detected, but\n** they were reported back as [SQLITE_CANTOPEN] or\n** [SQLITE_IOERR] rather than [SQLITE_NOMEM].\n**\n** The pointer arguments to [sqlite3_free()] and [sqlite3_realloc()]\n** must be either NULL or else pointers obtained from a prior\n** invocation of [sqlite3_malloc()] or [sqlite3_realloc()] that have\n** not yet been released.\n**\n** The application must not read or write any part of\n** a block of memory after it has been released using\n** [sqlite3_free()] or [sqlite3_realloc()].\n*/\nSQLITE_API void *sqlite3_malloc(int);\nSQLITE_API void *sqlite3_malloc64(sqlite3_uint64);\nSQLITE_API void *sqlite3_realloc(void*, int);\nSQLITE_API void *sqlite3_realloc64(void*, sqlite3_uint64);\nSQLITE_API void sqlite3_free(void*);\nSQLITE_API sqlite3_uint64 sqlite3_msize(void*);\n\n/*\n** CAPI3REF: Memory Allocator Statistics\n**\n** SQLite provides these two interfaces for reporting on the status\n** of the [sqlite3_malloc()], [sqlite3_free()], and [sqlite3_realloc()]\n** routines, which form the built-in memory allocation subsystem.\n**\n** ^The [sqlite3_memory_used()] routine returns the number of bytes\n** of memory currently outstanding (malloced but not freed).\n** ^The [sqlite3_memory_highwater()] routine returns the maximum\n** value of [sqlite3_memory_used()] since the high-water mark\n** was last reset.  ^The values returned by [sqlite3_memory_used()] and\n** [sqlite3_memory_highwater()] include any overhead\n** added by SQLite in its implementation of [sqlite3_malloc()],\n** but not overhead added by the any underlying system library\n** routines that [sqlite3_malloc()] may call.\n**\n** ^The memory high-water mark is reset to the current value of\n** [sqlite3_memory_used()] if and only if the parameter to\n** [sqlite3_memory_highwater()] is true.  ^The value returned\n** by [sqlite3_memory_highwater(1)] is the high-water mark\n** prior to the reset.\n*/\nSQLITE_API sqlite3_int64 sqlite3_memory_used(void);\nSQLITE_API sqlite3_int64 sqlite3_memory_highwater(int resetFlag);\n\n/*\n** CAPI3REF: Pseudo-Random Number Generator\n**\n** SQLite contains a high-quality pseudo-random number generator (PRNG) used to\n** select random [ROWID | ROWIDs] when inserting new records into a table that\n** already uses the largest possible [ROWID].  The PRNG is also used for\n** the build-in random() and randomblob() SQL functions.  This interface allows\n** applications to access the same PRNG for other purposes.\n**\n** ^A call to this routine stores N bytes of randomness into buffer P.\n** ^The P parameter can be a NULL pointer.\n**\n** ^If this routine has not been previously called or if the previous\n** call had N less than one or a NULL pointer for P, then the PRNG is\n** seeded using randomness obtained from the xRandomness method of\n** the default [sqlite3_vfs] object.\n** ^If the previous call to this routine had an N of 1 or more and a\n** non-NULL P then the pseudo-randomness is generated\n** internally and without recourse to the [sqlite3_vfs] xRandomness\n** method.\n*/\nSQLITE_API void sqlite3_randomness(int N, void *P);\n\n/*\n** CAPI3REF: Compile-Time Authorization Callbacks\n** METHOD: sqlite3\n** KEYWORDS: {authorizer callback}\n**\n** ^This routine registers an authorizer callback with a particular\n** [database connection], supplied in the first argument.\n** ^The authorizer callback is invoked as SQL statements are being compiled\n** by [sqlite3_prepare()] or its variants [sqlite3_prepare_v2()],\n** [sqlite3_prepare_v3()], [sqlite3_prepare16()], [sqlite3_prepare16_v2()],\n** and [sqlite3_prepare16_v3()].  ^At various\n** points during the compilation process, as logic is being created\n** to perform various actions, the authorizer callback is invoked to\n** see if those actions are allowed.  ^The authorizer callback should\n** return [SQLITE_OK] to allow the action, [SQLITE_IGNORE] to disallow the\n** specific action but allow the SQL statement to continue to be\n** compiled, or [SQLITE_DENY] to cause the entire SQL statement to be\n** rejected with an error.  ^If the authorizer callback returns\n** any value other than [SQLITE_IGNORE], [SQLITE_OK], or [SQLITE_DENY]\n** then the [sqlite3_prepare_v2()] or equivalent call that triggered\n** the authorizer will fail with an error message.\n**\n** When the callback returns [SQLITE_OK], that means the operation\n** requested is ok.  ^When the callback returns [SQLITE_DENY], the\n** [sqlite3_prepare_v2()] or equivalent call that triggered the\n** authorizer will fail with an error message explaining that\n** access is denied. \n**\n** ^The first parameter to the authorizer callback is a copy of the third\n** parameter to the sqlite3_set_authorizer() interface. ^The second parameter\n** to the callback is an integer [SQLITE_COPY | action code] that specifies\n** the particular action to be authorized. ^The third through sixth parameters\n** to the callback are either NULL pointers or zero-terminated strings\n** that contain additional details about the action to be authorized.\n** Applications must always be prepared to encounter a NULL pointer in any\n** of the third through the sixth parameters of the authorization callback.\n**\n** ^If the action code is [SQLITE_READ]\n** and the callback returns [SQLITE_IGNORE] then the\n** [prepared statement] statement is constructed to substitute\n** a NULL value in place of the table column that would have\n** been read if [SQLITE_OK] had been returned.  The [SQLITE_IGNORE]\n** return can be used to deny an untrusted user access to individual\n** columns of a table.\n** ^When a table is referenced by a [SELECT] but no column values are\n** extracted from that table (for example in a query like\n** \"SELECT count(*) FROM tab\") then the [SQLITE_READ] authorizer callback\n** is invoked once for that table with a column name that is an empty string.\n** ^If the action code is [SQLITE_DELETE] and the callback returns\n** [SQLITE_IGNORE] then the [DELETE] operation proceeds but the\n** [truncate optimization] is disabled and all rows are deleted individually.\n**\n** An authorizer is used when [sqlite3_prepare | preparing]\n** SQL statements from an untrusted source, to ensure that the SQL statements\n** do not try to access data they are not allowed to see, or that they do not\n** try to execute malicious statements that damage the database.  For\n** example, an application may allow a user to enter arbitrary\n** SQL queries for evaluation by a database.  But the application does\n** not want the user to be able to make arbitrary changes to the\n** database.  An authorizer could then be put in place while the\n** user-entered SQL is being [sqlite3_prepare | prepared] that\n** disallows everything except [SELECT] statements.\n**\n** Applications that need to process SQL from untrusted sources\n** might also consider lowering resource limits using [sqlite3_limit()]\n** and limiting database size using the [max_page_count] [PRAGMA]\n** in addition to using an authorizer.\n**\n** ^(Only a single authorizer can be in place on a database connection\n** at a time.  Each call to sqlite3_set_authorizer overrides the\n** previous call.)^  ^Disable the authorizer by installing a NULL callback.\n** The authorizer is disabled by default.\n**\n** The authorizer callback must not do anything that will modify\n** the database connection that invoked the authorizer callback.\n** Note that [sqlite3_prepare_v2()] and [sqlite3_step()] both modify their\n** database connections for the meaning of \"modify\" in this paragraph.\n**\n** ^When [sqlite3_prepare_v2()] is used to prepare a statement, the\n** statement might be re-prepared during [sqlite3_step()] due to a \n** schema change.  Hence, the application should ensure that the\n** correct authorizer callback remains in place during the [sqlite3_step()].\n**\n** ^Note that the authorizer callback is invoked only during\n** [sqlite3_prepare()] or its variants.  Authorization is not\n** performed during statement evaluation in [sqlite3_step()], unless\n** as stated in the previous paragraph, sqlite3_step() invokes\n** sqlite3_prepare_v2() to reprepare a statement after a schema change.\n*/\nSQLITE_API int sqlite3_set_authorizer(\n  sqlite3*,\n  int (*xAuth)(void*,int,const char*,const char*,const char*,const char*),\n  void *pUserData\n);\n\n/*\n** CAPI3REF: Authorizer Return Codes\n**\n** The [sqlite3_set_authorizer | authorizer callback function] must\n** return either [SQLITE_OK] or one of these two constants in order\n** to signal SQLite whether or not the action is permitted.  See the\n** [sqlite3_set_authorizer | authorizer documentation] for additional\n** information.\n**\n** Note that SQLITE_IGNORE is also used as a [conflict resolution mode]\n** returned from the [sqlite3_vtab_on_conflict()] interface.\n*/\n#define SQLITE_DENY   1   /* Abort the SQL statement with an error */\n#define SQLITE_IGNORE 2   /* Don't allow access, but don't generate an error */\n\n/*\n** CAPI3REF: Authorizer Action Codes\n**\n** The [sqlite3_set_authorizer()] interface registers a callback function\n** that is invoked to authorize certain SQL statement actions.  The\n** second parameter to the callback is an integer code that specifies\n** what action is being authorized.  These are the integer action codes that\n** the authorizer callback may be passed.\n**\n** These action code values signify what kind of operation is to be\n** authorized.  The 3rd and 4th parameters to the authorization\n** callback function will be parameters or NULL depending on which of these\n** codes is used as the second parameter.  ^(The 5th parameter to the\n** authorizer callback is the name of the database (\"main\", \"temp\",\n** etc.) if applicable.)^  ^The 6th parameter to the authorizer callback\n** is the name of the inner-most trigger or view that is responsible for\n** the access attempt or NULL if this access attempt is directly from\n** top-level SQL code.\n*/\n/******************************************* 3rd ************ 4th ***********/\n#define SQLITE_CREATE_INDEX          1   /* Index Name      Table Name      */\n#define SQLITE_CREATE_TABLE          2   /* Table Name      NULL            */\n#define SQLITE_CREATE_TEMP_INDEX     3   /* Index Name      Table Name      */\n#define SQLITE_CREATE_TEMP_TABLE     4   /* Table Name      NULL            */\n#define SQLITE_CREATE_TEMP_TRIGGER   5   /* Trigger Name    Table Name      */\n#define SQLITE_CREATE_TEMP_VIEW      6   /* View Name       NULL            */\n#define SQLITE_CREATE_TRIGGER        7   /* Trigger Name    Table Name      */\n#define SQLITE_CREATE_VIEW           8   /* View Name       NULL            */\n#define SQLITE_DELETE                9   /* Table Name      NULL            */\n#define SQLITE_DROP_INDEX           10   /* Index Name      Table Name      */\n#define SQLITE_DROP_TABLE           11   /* Table Name      NULL            */\n#define SQLITE_DROP_TEMP_INDEX      12   /* Index Name      Table Name      */\n#define SQLITE_DROP_TEMP_TABLE      13   /* Table Name      NULL            */\n#define SQLITE_DROP_TEMP_TRIGGER    14   /* Trigger Name    Table Name      */\n#define SQLITE_DROP_TEMP_VIEW       15   /* View Name       NULL            */\n#define SQLITE_DROP_TRIGGER         16   /* Trigger Name    Table Name      */\n#define SQLITE_DROP_VIEW            17   /* View Name       NULL            */\n#define SQLITE_INSERT               18   /* Table Name      NULL            */\n#define SQLITE_PRAGMA               19   /* Pragma Name     1st arg or NULL */\n#define SQLITE_READ                 20   /* Table Name      Column Name     */\n#define SQLITE_SELECT               21   /* NULL            NULL            */\n#define SQLITE_TRANSACTION          22   /* Operation       NULL            */\n#define SQLITE_UPDATE               23   /* Table Name      Column Name     */\n#define SQLITE_ATTACH               24   /* Filename        NULL            */\n#define SQLITE_DETACH               25   /* Database Name   NULL            */\n#define SQLITE_ALTER_TABLE          26   /* Database Name   Table Name      */\n#define SQLITE_REINDEX              27   /* Index Name      NULL            */\n#define SQLITE_ANALYZE              28   /* Table Name      NULL            */\n#define SQLITE_CREATE_VTABLE        29   /* Table Name      Module Name     */\n#define SQLITE_DROP_VTABLE          30   /* Table Name      Module Name     */\n#define SQLITE_FUNCTION             31   /* NULL            Function Name   */\n#define SQLITE_SAVEPOINT            32   /* Operation       Savepoint Name  */\n#define SQLITE_COPY                  0   /* No longer used */\n#define SQLITE_RECURSIVE            33   /* NULL            NULL            */\n\n/*\n** CAPI3REF: Tracing And Profiling Functions\n** METHOD: sqlite3\n**\n** These routines are deprecated. Use the [sqlite3_trace_v2()] interface\n** instead of the routines described here.\n**\n** These routines register callback functions that can be used for\n** tracing and profiling the execution of SQL statements.\n**\n** ^The callback function registered by sqlite3_trace() is invoked at\n** various times when an SQL statement is being run by [sqlite3_step()].\n** ^The sqlite3_trace() callback is invoked with a UTF-8 rendering of the\n** SQL statement text as the statement first begins executing.\n** ^(Additional sqlite3_trace() callbacks might occur\n** as each triggered subprogram is entered.  The callbacks for triggers\n** contain a UTF-8 SQL comment that identifies the trigger.)^\n**\n** The [SQLITE_TRACE_SIZE_LIMIT] compile-time option can be used to limit\n** the length of [bound parameter] expansion in the output of sqlite3_trace().\n**\n** ^The callback function registered by sqlite3_profile() is invoked\n** as each SQL statement finishes.  ^The profile callback contains\n** the original statement text and an estimate of wall-clock time\n** of how long that statement took to run.  ^The profile callback\n** time is in units of nanoseconds, however the current implementation\n** is only capable of millisecond resolution so the six least significant\n** digits in the time are meaningless.  Future versions of SQLite\n** might provide greater resolution on the profiler callback.  Invoking\n** either [sqlite3_trace()] or [sqlite3_trace_v2()] will cancel the\n** profile callback.\n*/\nSQLITE_API SQLITE_DEPRECATED void *sqlite3_trace(sqlite3*,\n   void(*xTrace)(void*,const char*), void*);\nSQLITE_API SQLITE_DEPRECATED void *sqlite3_profile(sqlite3*,\n   void(*xProfile)(void*,const char*,sqlite3_uint64), void*);\n\n/*\n** CAPI3REF: SQL Trace Event Codes\n** KEYWORDS: SQLITE_TRACE\n**\n** These constants identify classes of events that can be monitored\n** using the [sqlite3_trace_v2()] tracing logic.  The M argument\n** to [sqlite3_trace_v2(D,M,X,P)] is an OR-ed combination of one or more of\n** the following constants.  ^The first argument to the trace callback\n** is one of the following constants.\n**\n** New tracing constants may be added in future releases.\n**\n** ^A trace callback has four arguments: xCallback(T,C,P,X).\n** ^The T argument is one of the integer type codes above.\n** ^The C argument is a copy of the context pointer passed in as the\n** fourth argument to [sqlite3_trace_v2()].\n** The P and X arguments are pointers whose meanings depend on T.\n**\n** <dl>\n** [[SQLITE_TRACE_STMT]] <dt>SQLITE_TRACE_STMT</dt>\n** <dd>^An SQLITE_TRACE_STMT callback is invoked when a prepared statement\n** first begins running and possibly at other times during the\n** execution of the prepared statement, such as at the start of each\n** trigger subprogram. ^The P argument is a pointer to the\n** [prepared statement]. ^The X argument is a pointer to a string which\n** is the unexpanded SQL text of the prepared statement or an SQL comment \n** that indicates the invocation of a trigger.  ^The callback can compute\n** the same text that would have been returned by the legacy [sqlite3_trace()]\n** interface by using the X argument when X begins with \"--\" and invoking\n** [sqlite3_expanded_sql(P)] otherwise.\n**\n** [[SQLITE_TRACE_PROFILE]] <dt>SQLITE_TRACE_PROFILE</dt>\n** <dd>^An SQLITE_TRACE_PROFILE callback provides approximately the same\n** information as is provided by the [sqlite3_profile()] callback.\n** ^The P argument is a pointer to the [prepared statement] and the\n** X argument points to a 64-bit integer which is the estimated of\n** the number of nanosecond that the prepared statement took to run.\n** ^The SQLITE_TRACE_PROFILE callback is invoked when the statement finishes.\n**\n** [[SQLITE_TRACE_ROW]] <dt>SQLITE_TRACE_ROW</dt>\n** <dd>^An SQLITE_TRACE_ROW callback is invoked whenever a prepared\n** statement generates a single row of result.  \n** ^The P argument is a pointer to the [prepared statement] and the\n** X argument is unused.\n**\n** [[SQLITE_TRACE_CLOSE]] <dt>SQLITE_TRACE_CLOSE</dt>\n** <dd>^An SQLITE_TRACE_CLOSE callback is invoked when a database\n** connection closes.\n** ^The P argument is a pointer to the [database connection] object\n** and the X argument is unused.\n** </dl>\n*/\n#define SQLITE_TRACE_STMT       0x01\n#define SQLITE_TRACE_PROFILE    0x02\n#define SQLITE_TRACE_ROW        0x04\n#define SQLITE_TRACE_CLOSE      0x08\n\n/*\n** CAPI3REF: SQL Trace Hook\n** METHOD: sqlite3\n**\n** ^The sqlite3_trace_v2(D,M,X,P) interface registers a trace callback\n** function X against [database connection] D, using property mask M\n** and context pointer P.  ^If the X callback is\n** NULL or if the M mask is zero, then tracing is disabled.  The\n** M argument should be the bitwise OR-ed combination of\n** zero or more [SQLITE_TRACE] constants.\n**\n** ^Each call to either sqlite3_trace() or sqlite3_trace_v2() overrides \n** (cancels) any prior calls to sqlite3_trace() or sqlite3_trace_v2().\n**\n** ^The X callback is invoked whenever any of the events identified by \n** mask M occur.  ^The integer return value from the callback is currently\n** ignored, though this may change in future releases.  Callback\n** implementations should return zero to ensure future compatibility.\n**\n** ^A trace callback is invoked with four arguments: callback(T,C,P,X).\n** ^The T argument is one of the [SQLITE_TRACE]\n** constants to indicate why the callback was invoked.\n** ^The C argument is a copy of the context pointer.\n** The P and X arguments are pointers whose meanings depend on T.\n**\n** The sqlite3_trace_v2() interface is intended to replace the legacy\n** interfaces [sqlite3_trace()] and [sqlite3_profile()], both of which\n** are deprecated.\n*/\nSQLITE_API int sqlite3_trace_v2(\n  sqlite3*,\n  unsigned uMask,\n  int(*xCallback)(unsigned,void*,void*,void*),\n  void *pCtx\n);\n\n/*\n** CAPI3REF: Query Progress Callbacks\n** METHOD: sqlite3\n**\n** ^The sqlite3_progress_handler(D,N,X,P) interface causes the callback\n** function X to be invoked periodically during long running calls to\n** [sqlite3_exec()], [sqlite3_step()] and [sqlite3_get_table()] for\n** database connection D.  An example use for this\n** interface is to keep a GUI updated during a large query.\n**\n** ^The parameter P is passed through as the only parameter to the \n** callback function X.  ^The parameter N is the approximate number of \n** [virtual machine instructions] that are evaluated between successive\n** invocations of the callback X.  ^If N is less than one then the progress\n** handler is disabled.\n**\n** ^Only a single progress handler may be defined at one time per\n** [database connection]; setting a new progress handler cancels the\n** old one.  ^Setting parameter X to NULL disables the progress handler.\n** ^The progress handler is also disabled by setting N to a value less\n** than 1.\n**\n** ^If the progress callback returns non-zero, the operation is\n** interrupted.  This feature can be used to implement a\n** \"Cancel\" button on a GUI progress dialog box.\n**\n** The progress handler callback must not do anything that will modify\n** the database connection that invoked the progress handler.\n** Note that [sqlite3_prepare_v2()] and [sqlite3_step()] both modify their\n** database connections for the meaning of \"modify\" in this paragraph.\n**\n*/\nSQLITE_API void sqlite3_progress_handler(sqlite3*, int, int(*)(void*), void*);\n\n/*\n** CAPI3REF: Opening A New Database Connection\n** CONSTRUCTOR: sqlite3\n**\n** ^These routines open an SQLite database file as specified by the \n** filename argument. ^The filename argument is interpreted as UTF-8 for\n** sqlite3_open() and sqlite3_open_v2() and as UTF-16 in the native byte\n** order for sqlite3_open16(). ^(A [database connection] handle is usually\n** returned in *ppDb, even if an error occurs.  The only exception is that\n** if SQLite is unable to allocate memory to hold the [sqlite3] object,\n** a NULL will be written into *ppDb instead of a pointer to the [sqlite3]\n** object.)^ ^(If the database is opened (and/or created) successfully, then\n** [SQLITE_OK] is returned.  Otherwise an [error code] is returned.)^ ^The\n** [sqlite3_errmsg()] or [sqlite3_errmsg16()] routines can be used to obtain\n** an English language description of the error following a failure of any\n** of the sqlite3_open() routines.\n**\n** ^The default encoding will be UTF-8 for databases created using\n** sqlite3_open() or sqlite3_open_v2().  ^The default encoding for databases\n** created using sqlite3_open16() will be UTF-16 in the native byte order.\n**\n** Whether or not an error occurs when it is opened, resources\n** associated with the [database connection] handle should be released by\n** passing it to [sqlite3_close()] when it is no longer required.\n**\n** The sqlite3_open_v2() interface works like sqlite3_open()\n** except that it accepts two additional parameters for additional control\n** over the new database connection.  ^(The flags parameter to\n** sqlite3_open_v2() can take one of\n** the following three values, optionally combined with the \n** [SQLITE_OPEN_NOMUTEX], [SQLITE_OPEN_FULLMUTEX], [SQLITE_OPEN_SHAREDCACHE],\n** [SQLITE_OPEN_PRIVATECACHE], and/or [SQLITE_OPEN_URI] flags:)^\n**\n** <dl>\n** ^(<dt>[SQLITE_OPEN_READONLY]</dt>\n** <dd>The database is opened in read-only mode.  If the database does not\n** already exist, an error is returned.</dd>)^\n**\n** ^(<dt>[SQLITE_OPEN_READWRITE]</dt>\n** <dd>The database is opened for reading and writing if possible, or reading\n** only if the file is write protected by the operating system.  In either\n** case the database must already exist, otherwise an error is returned.</dd>)^\n**\n** ^(<dt>[SQLITE_OPEN_READWRITE] | [SQLITE_OPEN_CREATE]</dt>\n** <dd>The database is opened for reading and writing, and is created if\n** it does not already exist. This is the behavior that is always used for\n** sqlite3_open() and sqlite3_open16().</dd>)^\n** </dl>\n**\n** If the 3rd parameter to sqlite3_open_v2() is not one of the\n** combinations shown above optionally combined with other\n** [SQLITE_OPEN_READONLY | SQLITE_OPEN_* bits]\n** then the behavior is undefined.\n**\n** ^If the [SQLITE_OPEN_NOMUTEX] flag is set, then the database connection\n** opens in the multi-thread [threading mode] as long as the single-thread\n** mode has not been set at compile-time or start-time.  ^If the\n** [SQLITE_OPEN_FULLMUTEX] flag is set then the database connection opens\n** in the serialized [threading mode] unless single-thread was\n** previously selected at compile-time or start-time.\n** ^The [SQLITE_OPEN_SHAREDCACHE] flag causes the database connection to be\n** eligible to use [shared cache mode], regardless of whether or not shared\n** cache is enabled using [sqlite3_enable_shared_cache()].  ^The\n** [SQLITE_OPEN_PRIVATECACHE] flag causes the database connection to not\n** participate in [shared cache mode] even if it is enabled.\n**\n** ^The fourth parameter to sqlite3_open_v2() is the name of the\n** [sqlite3_vfs] object that defines the operating system interface that\n** the new database connection should use.  ^If the fourth parameter is\n** a NULL pointer then the default [sqlite3_vfs] object is used.\n**\n** ^If the filename is \":memory:\", then a private, temporary in-memory database\n** is created for the connection.  ^This in-memory database will vanish when\n** the database connection is closed.  Future versions of SQLite might\n** make use of additional special filenames that begin with the \":\" character.\n** It is recommended that when a database filename actually does begin with\n** a \":\" character you should prefix the filename with a pathname such as\n** \"./\" to avoid ambiguity.\n**\n** ^If the filename is an empty string, then a private, temporary\n** on-disk database will be created.  ^This private database will be\n** automatically deleted as soon as the database connection is closed.\n**\n** [[URI filenames in sqlite3_open()]] <h3>URI Filenames</h3>\n**\n** ^If [URI filename] interpretation is enabled, and the filename argument\n** begins with \"file:\", then the filename is interpreted as a URI. ^URI\n** filename interpretation is enabled if the [SQLITE_OPEN_URI] flag is\n** set in the third argument to sqlite3_open_v2(), or if it has\n** been enabled globally using the [SQLITE_CONFIG_URI] option with the\n** [sqlite3_config()] method or by the [SQLITE_USE_URI] compile-time option.\n** URI filename interpretation is turned off\n** by default, but future releases of SQLite might enable URI filename\n** interpretation by default.  See \"[URI filenames]\" for additional\n** information.\n**\n** URI filenames are parsed according to RFC 3986. ^If the URI contains an\n** authority, then it must be either an empty string or the string \n** \"localhost\". ^If the authority is not an empty string or \"localhost\", an \n** error is returned to the caller. ^The fragment component of a URI, if \n** present, is ignored.\n**\n** ^SQLite uses the path component of the URI as the name of the disk file\n** which contains the database. ^If the path begins with a '/' character, \n** then it is interpreted as an absolute path. ^If the path does not begin \n** with a '/' (meaning that the authority section is omitted from the URI)\n** then the path is interpreted as a relative path. \n** ^(On windows, the first component of an absolute path \n** is a drive specification (e.g. \"C:\").)^\n**\n** [[core URI query parameters]]\n** The query component of a URI may contain parameters that are interpreted\n** either by SQLite itself, or by a [VFS | custom VFS implementation].\n** SQLite and its built-in [VFSes] interpret the\n** following query parameters:\n**\n** <ul>\n**   <li> <b>vfs</b>: ^The \"vfs\" parameter may be used to specify the name of\n**     a VFS object that provides the operating system interface that should\n**     be used to access the database file on disk. ^If this option is set to\n**     an empty string the default VFS object is used. ^Specifying an unknown\n**     VFS is an error. ^If sqlite3_open_v2() is used and the vfs option is\n**     present, then the VFS specified by the option takes precedence over\n**     the value passed as the fourth parameter to sqlite3_open_v2().\n**\n**   <li> <b>mode</b>: ^(The mode parameter may be set to either \"ro\", \"rw\",\n**     \"rwc\", or \"memory\". Attempting to set it to any other value is\n**     an error)^. \n**     ^If \"ro\" is specified, then the database is opened for read-only \n**     access, just as if the [SQLITE_OPEN_READONLY] flag had been set in the \n**     third argument to sqlite3_open_v2(). ^If the mode option is set to \n**     \"rw\", then the database is opened for read-write (but not create) \n**     access, as if SQLITE_OPEN_READWRITE (but not SQLITE_OPEN_CREATE) had \n**     been set. ^Value \"rwc\" is equivalent to setting both \n**     SQLITE_OPEN_READWRITE and SQLITE_OPEN_CREATE.  ^If the mode option is\n**     set to \"memory\" then a pure [in-memory database] that never reads\n**     or writes from disk is used. ^It is an error to specify a value for\n**     the mode parameter that is less restrictive than that specified by\n**     the flags passed in the third parameter to sqlite3_open_v2().\n**\n**   <li> <b>cache</b>: ^The cache parameter may be set to either \"shared\" or\n**     \"private\". ^Setting it to \"shared\" is equivalent to setting the\n**     SQLITE_OPEN_SHAREDCACHE bit in the flags argument passed to\n**     sqlite3_open_v2(). ^Setting the cache parameter to \"private\" is \n**     equivalent to setting the SQLITE_OPEN_PRIVATECACHE bit.\n**     ^If sqlite3_open_v2() is used and the \"cache\" parameter is present in\n**     a URI filename, its value overrides any behavior requested by setting\n**     SQLITE_OPEN_PRIVATECACHE or SQLITE_OPEN_SHAREDCACHE flag.\n**\n**  <li> <b>psow</b>: ^The psow parameter indicates whether or not the\n**     [powersafe overwrite] property does or does not apply to the\n**     storage media on which the database file resides.\n**\n**  <li> <b>nolock</b>: ^The nolock parameter is a boolean query parameter\n**     which if set disables file locking in rollback journal modes.  This\n**     is useful for accessing a database on a filesystem that does not\n**     support locking.  Caution:  Database corruption might result if two\n**     or more processes write to the same database and any one of those\n**     processes uses nolock=1.\n**\n**  <li> <b>immutable</b>: ^The immutable parameter is a boolean query\n**     parameter that indicates that the database file is stored on\n**     read-only media.  ^When immutable is set, SQLite assumes that the\n**     database file cannot be changed, even by a process with higher\n**     privilege, and so the database is opened read-only and all locking\n**     and change detection is disabled.  Caution: Setting the immutable\n**     property on a database file that does in fact change can result\n**     in incorrect query results and/or [SQLITE_CORRUPT] errors.\n**     See also: [SQLITE_IOCAP_IMMUTABLE].\n**       \n** </ul>\n**\n** ^Specifying an unknown parameter in the query component of a URI is not an\n** error.  Future versions of SQLite might understand additional query\n** parameters.  See \"[query parameters with special meaning to SQLite]\" for\n** additional information.\n**\n** [[URI filename examples]] <h3>URI filename examples</h3>\n**\n** <table border=\"1\" align=center cellpadding=5>\n** <tr><th> URI filenames <th> Results\n** <tr><td> file:data.db <td> \n**          Open the file \"data.db\" in the current directory.\n** <tr><td> file:/home/fred/data.db<br>\n**          file:///home/fred/data.db <br> \n**          file://localhost/home/fred/data.db <br> <td> \n**          Open the database file \"/home/fred/data.db\".\n** <tr><td> file://darkstar/home/fred/data.db <td> \n**          An error. \"darkstar\" is not a recognized authority.\n** <tr><td style=\"white-space:nowrap\"> \n**          file:///C:/Documents%20and%20Settings/fred/Desktop/data.db\n**     <td> Windows only: Open the file \"data.db\" on fred's desktop on drive\n**          C:. Note that the %20 escaping in this example is not strictly \n**          necessary - space characters can be used literally\n**          in URI filenames.\n** <tr><td> file:data.db?mode=ro&cache=private <td> \n**          Open file \"data.db\" in the current directory for read-only access.\n**          Regardless of whether or not shared-cache mode is enabled by\n**          default, use a private cache.\n** <tr><td> file:/home/fred/data.db?vfs=unix-dotfile <td>\n**          Open file \"/home/fred/data.db\". Use the special VFS \"unix-dotfile\"\n**          that uses dot-files in place of posix advisory locking.\n** <tr><td> file:data.db?mode=readonly <td> \n**          An error. \"readonly\" is not a valid option for the \"mode\" parameter.\n** </table>\n**\n** ^URI hexadecimal escape sequences (%HH) are supported within the path and\n** query components of a URI. A hexadecimal escape sequence consists of a\n** percent sign - \"%\" - followed by exactly two hexadecimal digits \n** specifying an octet value. ^Before the path or query components of a\n** URI filename are interpreted, they are encoded using UTF-8 and all \n** hexadecimal escape sequences replaced by a single byte containing the\n** corresponding octet. If this process generates an invalid UTF-8 encoding,\n** the results are undefined.\n**\n** <b>Note to Windows users:</b>  The encoding used for the filename argument\n** of sqlite3_open() and sqlite3_open_v2() must be UTF-8, not whatever\n** codepage is currently defined.  Filenames containing international\n** characters must be converted to UTF-8 prior to passing them into\n** sqlite3_open() or sqlite3_open_v2().\n**\n** <b>Note to Windows Runtime users:</b>  The temporary directory must be set\n** prior to calling sqlite3_open() or sqlite3_open_v2().  Otherwise, various\n** features that require the use of temporary files may fail.\n**\n** See also: [sqlite3_temp_directory]\n*/\nSQLITE_API int sqlite3_open(\n  const char *filename,   /* Database filename (UTF-8) */\n  sqlite3 **ppDb          /* OUT: SQLite db handle */\n);\nSQLITE_API int sqlite3_open16(\n  const void *filename,   /* Database filename (UTF-16) */\n  sqlite3 **ppDb          /* OUT: SQLite db handle */\n);\nSQLITE_API int sqlite3_open_v2(\n  const char *filename,   /* Database filename (UTF-8) */\n  sqlite3 **ppDb,         /* OUT: SQLite db handle */\n  int flags,              /* Flags */\n  const char *zVfs        /* Name of VFS module to use */\n);\n\n/*\n** CAPI3REF: Obtain Values For URI Parameters\n**\n** These are utility routines, useful to VFS implementations, that check\n** to see if a database file was a URI that contained a specific query \n** parameter, and if so obtains the value of that query parameter.\n**\n** If F is the database filename pointer passed into the xOpen() method of \n** a VFS implementation when the flags parameter to xOpen() has one or \n** more of the [SQLITE_OPEN_URI] or [SQLITE_OPEN_MAIN_DB] bits set and\n** P is the name of the query parameter, then\n** sqlite3_uri_parameter(F,P) returns the value of the P\n** parameter if it exists or a NULL pointer if P does not appear as a \n** query parameter on F.  If P is a query parameter of F\n** has no explicit value, then sqlite3_uri_parameter(F,P) returns\n** a pointer to an empty string.\n**\n** The sqlite3_uri_boolean(F,P,B) routine assumes that P is a boolean\n** parameter and returns true (1) or false (0) according to the value\n** of P.  The sqlite3_uri_boolean(F,P,B) routine returns true (1) if the\n** value of query parameter P is one of \"yes\", \"true\", or \"on\" in any\n** case or if the value begins with a non-zero number.  The \n** sqlite3_uri_boolean(F,P,B) routines returns false (0) if the value of\n** query parameter P is one of \"no\", \"false\", or \"off\" in any case or\n** if the value begins with a numeric zero.  If P is not a query\n** parameter on F or if the value of P is does not match any of the\n** above, then sqlite3_uri_boolean(F,P,B) returns (B!=0).\n**\n** The sqlite3_uri_int64(F,P,D) routine converts the value of P into a\n** 64-bit signed integer and returns that integer, or D if P does not\n** exist.  If the value of P is something other than an integer, then\n** zero is returned.\n** \n** If F is a NULL pointer, then sqlite3_uri_parameter(F,P) returns NULL and\n** sqlite3_uri_boolean(F,P,B) returns B.  If F is not a NULL pointer and\n** is not a database file pathname pointer that SQLite passed into the xOpen\n** VFS method, then the behavior of this routine is undefined and probably\n** undesirable.\n**\n** See the [URI filename] documentation for additional information.\n*/\nSQLITE_API const char *sqlite3_uri_parameter(const char *zFilename, const char *zParam);\nSQLITE_API int sqlite3_uri_boolean(const char *zFile, const char *zParam, int bDefault);\nSQLITE_API sqlite3_int64 sqlite3_uri_int64(const char*, const char*, sqlite3_int64);\n\n\n/*\n** CAPI3REF: Error Codes And Messages\n** METHOD: sqlite3\n**\n** ^If the most recent sqlite3_* API call associated with \n** [database connection] D failed, then the sqlite3_errcode(D) interface\n** returns the numeric [result code] or [extended result code] for that\n** API call.\n** ^The sqlite3_extended_errcode()\n** interface is the same except that it always returns the \n** [extended result code] even when extended result codes are\n** disabled.\n**\n** The values returned by sqlite3_errcode() and/or\n** sqlite3_extended_errcode() might change with each API call.\n** Except, there are some interfaces that are guaranteed to never\n** change the value of the error code.  The error-code preserving\n** interfaces are:\n**\n** <ul>\n** <li> sqlite3_errcode()\n** <li> sqlite3_extended_errcode()\n** <li> sqlite3_errmsg()\n** <li> sqlite3_errmsg16()\n** </ul>\n**\n** ^The sqlite3_errmsg() and sqlite3_errmsg16() return English-language\n** text that describes the error, as either UTF-8 or UTF-16 respectively.\n** ^(Memory to hold the error message string is managed internally.\n** The application does not need to worry about freeing the result.\n** However, the error string might be overwritten or deallocated by\n** subsequent calls to other SQLite interface functions.)^\n**\n** ^The sqlite3_errstr() interface returns the English-language text\n** that describes the [result code], as UTF-8.\n** ^(Memory to hold the error message string is managed internally\n** and must not be freed by the application)^.\n**\n** When the serialized [threading mode] is in use, it might be the\n** case that a second error occurs on a separate thread in between\n** the time of the first error and the call to these interfaces.\n** When that happens, the second error will be reported since these\n** interfaces always report the most recent result.  To avoid\n** this, each thread can obtain exclusive use of the [database connection] D\n** by invoking [sqlite3_mutex_enter]([sqlite3_db_mutex](D)) before beginning\n** to use D and invoking [sqlite3_mutex_leave]([sqlite3_db_mutex](D)) after\n** all calls to the interfaces listed here are completed.\n**\n** If an interface fails with SQLITE_MISUSE, that means the interface\n** was invoked incorrectly by the application.  In that case, the\n** error code and message may or may not be set.\n*/\nSQLITE_API int sqlite3_errcode(sqlite3 *db);\nSQLITE_API int sqlite3_extended_errcode(sqlite3 *db);\nSQLITE_API const char *sqlite3_errmsg(sqlite3*);\nSQLITE_API const void *sqlite3_errmsg16(sqlite3*);\nSQLITE_API const char *sqlite3_errstr(int);\n\n/*\n** CAPI3REF: Prepared Statement Object\n** KEYWORDS: {prepared statement} {prepared statements}\n**\n** An instance of this object represents a single SQL statement that\n** has been compiled into binary form and is ready to be evaluated.\n**\n** Think of each SQL statement as a separate computer program.  The\n** original SQL text is source code.  A prepared statement object \n** is the compiled object code.  All SQL must be converted into a\n** prepared statement before it can be run.\n**\n** The life-cycle of a prepared statement object usually goes like this:\n**\n** <ol>\n** <li> Create the prepared statement object using [sqlite3_prepare_v2()].\n** <li> Bind values to [parameters] using the sqlite3_bind_*()\n**      interfaces.\n** <li> Run the SQL by calling [sqlite3_step()] one or more times.\n** <li> Reset the prepared statement using [sqlite3_reset()] then go back\n**      to step 2.  Do this zero or more times.\n** <li> Destroy the object using [sqlite3_finalize()].\n** </ol>\n*/\ntypedef struct sqlite3_stmt sqlite3_stmt;\n\n/*\n** CAPI3REF: Run-time Limits\n** METHOD: sqlite3\n**\n** ^(This interface allows the size of various constructs to be limited\n** on a connection by connection basis.  The first parameter is the\n** [database connection] whose limit is to be set or queried.  The\n** second parameter is one of the [limit categories] that define a\n** class of constructs to be size limited.  The third parameter is the\n** new limit for that construct.)^\n**\n** ^If the new limit is a negative number, the limit is unchanged.\n** ^(For each limit category SQLITE_LIMIT_<i>NAME</i> there is a \n** [limits | hard upper bound]\n** set at compile-time by a C preprocessor macro called\n** [limits | SQLITE_MAX_<i>NAME</i>].\n** (The \"_LIMIT_\" in the name is changed to \"_MAX_\".))^\n** ^Attempts to increase a limit above its hard upper bound are\n** silently truncated to the hard upper bound.\n**\n** ^Regardless of whether or not the limit was changed, the \n** [sqlite3_limit()] interface returns the prior value of the limit.\n** ^Hence, to find the current value of a limit without changing it,\n** simply invoke this interface with the third parameter set to -1.\n**\n** Run-time limits are intended for use in applications that manage\n** both their own internal database and also databases that are controlled\n** by untrusted external sources.  An example application might be a\n** web browser that has its own databases for storing history and\n** separate databases controlled by JavaScript applications downloaded\n** off the Internet.  The internal databases can be given the\n** large, default limits.  Databases managed by external sources can\n** be given much smaller limits designed to prevent a denial of service\n** attack.  Developers might also want to use the [sqlite3_set_authorizer()]\n** interface to further control untrusted SQL.  The size of the database\n** created by an untrusted script can be contained using the\n** [max_page_count] [PRAGMA].\n**\n** New run-time limit categories may be added in future releases.\n*/\nSQLITE_API int sqlite3_limit(sqlite3*, int id, int newVal);\n\n/*\n** CAPI3REF: Run-Time Limit Categories\n** KEYWORDS: {limit category} {*limit categories}\n**\n** These constants define various performance limits\n** that can be lowered at run-time using [sqlite3_limit()].\n** The synopsis of the meanings of the various limits is shown below.\n** Additional information is available at [limits | Limits in SQLite].\n**\n** <dl>\n** [[SQLITE_LIMIT_LENGTH]] ^(<dt>SQLITE_LIMIT_LENGTH</dt>\n** <dd>The maximum size of any string or BLOB or table row, in bytes.<dd>)^\n**\n** [[SQLITE_LIMIT_SQL_LENGTH]] ^(<dt>SQLITE_LIMIT_SQL_LENGTH</dt>\n** <dd>The maximum length of an SQL statement, in bytes.</dd>)^\n**\n** [[SQLITE_LIMIT_COLUMN]] ^(<dt>SQLITE_LIMIT_COLUMN</dt>\n** <dd>The maximum number of columns in a table definition or in the\n** result set of a [SELECT] or the maximum number of columns in an index\n** or in an ORDER BY or GROUP BY clause.</dd>)^\n**\n** [[SQLITE_LIMIT_EXPR_DEPTH]] ^(<dt>SQLITE_LIMIT_EXPR_DEPTH</dt>\n** <dd>The maximum depth of the parse tree on any expression.</dd>)^\n**\n** [[SQLITE_LIMIT_COMPOUND_SELECT]] ^(<dt>SQLITE_LIMIT_COMPOUND_SELECT</dt>\n** <dd>The maximum number of terms in a compound SELECT statement.</dd>)^\n**\n** [[SQLITE_LIMIT_VDBE_OP]] ^(<dt>SQLITE_LIMIT_VDBE_OP</dt>\n** <dd>The maximum number of instructions in a virtual machine program\n** used to implement an SQL statement.  If [sqlite3_prepare_v2()] or\n** the equivalent tries to allocate space for more than this many opcodes\n** in a single prepared statement, an SQLITE_NOMEM error is returned.</dd>)^\n**\n** [[SQLITE_LIMIT_FUNCTION_ARG]] ^(<dt>SQLITE_LIMIT_FUNCTION_ARG</dt>\n** <dd>The maximum number of arguments on a function.</dd>)^\n**\n** [[SQLITE_LIMIT_ATTACHED]] ^(<dt>SQLITE_LIMIT_ATTACHED</dt>\n** <dd>The maximum number of [ATTACH | attached databases].)^</dd>\n**\n** [[SQLITE_LIMIT_LIKE_PATTERN_LENGTH]]\n** ^(<dt>SQLITE_LIMIT_LIKE_PATTERN_LENGTH</dt>\n** <dd>The maximum length of the pattern argument to the [LIKE] or\n** [GLOB] operators.</dd>)^\n**\n** [[SQLITE_LIMIT_VARIABLE_NUMBER]]\n** ^(<dt>SQLITE_LIMIT_VARIABLE_NUMBER</dt>\n** <dd>The maximum index number of any [parameter] in an SQL statement.)^\n**\n** [[SQLITE_LIMIT_TRIGGER_DEPTH]] ^(<dt>SQLITE_LIMIT_TRIGGER_DEPTH</dt>\n** <dd>The maximum depth of recursion for triggers.</dd>)^\n**\n** [[SQLITE_LIMIT_WORKER_THREADS]] ^(<dt>SQLITE_LIMIT_WORKER_THREADS</dt>\n** <dd>The maximum number of auxiliary worker threads that a single\n** [prepared statement] may start.</dd>)^\n** </dl>\n*/\n#define SQLITE_LIMIT_LENGTH                    0\n#define SQLITE_LIMIT_SQL_LENGTH                1\n#define SQLITE_LIMIT_COLUMN                    2\n#define SQLITE_LIMIT_EXPR_DEPTH                3\n#define SQLITE_LIMIT_COMPOUND_SELECT           4\n#define SQLITE_LIMIT_VDBE_OP                   5\n#define SQLITE_LIMIT_FUNCTION_ARG              6\n#define SQLITE_LIMIT_ATTACHED                  7\n#define SQLITE_LIMIT_LIKE_PATTERN_LENGTH       8\n#define SQLITE_LIMIT_VARIABLE_NUMBER           9\n#define SQLITE_LIMIT_TRIGGER_DEPTH            10\n#define SQLITE_LIMIT_WORKER_THREADS           11\n\n/*\n** CAPI3REF: Prepare Flags\n**\n** These constants define various flags that can be passed into\n** \"prepFlags\" parameter of the [sqlite3_prepare_v3()] and\n** [sqlite3_prepare16_v3()] interfaces.\n**\n** New flags may be added in future releases of SQLite.\n**\n** <dl>\n** [[SQLITE_PREPARE_PERSISTENT]] ^(<dt>SQLITE_PREPARE_PERSISTENT</dt>\n** <dd>The SQLITE_PREPARE_PERSISTENT flag is a hint to the query planner\n** that the prepared statement will be retained for a long time and\n** probably reused many times.)^ ^Without this flag, [sqlite3_prepare_v3()]\n** and [sqlite3_prepare16_v3()] assume that the prepared statement will \n** be used just once or at most a few times and then destroyed using\n** [sqlite3_finalize()] relatively soon. The current implementation acts\n** on this hint by avoiding the use of [lookaside memory] so as not to\n** deplete the limited store of lookaside memory. Future versions of\n** SQLite may act on this hint differently.\n**\n** [[SQLITE_PREPARE_NORMALIZE]] <dt>SQLITE_PREPARE_NORMALIZE</dt>\n** <dd>The SQLITE_PREPARE_NORMALIZE flag is a no-op. This flag used\n** to be required for any prepared statement that wanted to use the\n** [sqlite3_normalized_sql()] interface.  However, the\n** [sqlite3_normalized_sql()] interface is now available to all\n** prepared statements, regardless of whether or not they use this\n** flag.\n**\n** [[SQLITE_PREPARE_NO_VTAB]] <dt>SQLITE_PREPARE_NO_VTAB</dt>\n** <dd>The SQLITE_PREPARE_NO_VTAB flag causes the SQL compiler\n** to return an error (error code SQLITE_ERROR) if the statement uses\n** any virtual tables.\n** </dl>\n*/\n#define SQLITE_PREPARE_PERSISTENT              0x01\n#define SQLITE_PREPARE_NORMALIZE               0x02\n#define SQLITE_PREPARE_NO_VTAB                 0x04\n\n/*\n** CAPI3REF: Compiling An SQL Statement\n** KEYWORDS: {SQL statement compiler}\n** METHOD: sqlite3\n** CONSTRUCTOR: sqlite3_stmt\n**\n** To execute an SQL statement, it must first be compiled into a byte-code\n** program using one of these routines.  Or, in other words, these routines\n** are constructors for the [prepared statement] object.\n**\n** The preferred routine to use is [sqlite3_prepare_v2()].  The\n** [sqlite3_prepare()] interface is legacy and should be avoided.\n** [sqlite3_prepare_v3()] has an extra \"prepFlags\" option that is used\n** for special purposes.\n**\n** The use of the UTF-8 interfaces is preferred, as SQLite currently\n** does all parsing using UTF-8.  The UTF-16 interfaces are provided\n** as a convenience.  The UTF-16 interfaces work by converting the\n** input text into UTF-8, then invoking the corresponding UTF-8 interface.\n**\n** The first argument, \"db\", is a [database connection] obtained from a\n** prior successful call to [sqlite3_open()], [sqlite3_open_v2()] or\n** [sqlite3_open16()].  The database connection must not have been closed.\n**\n** The second argument, \"zSql\", is the statement to be compiled, encoded\n** as either UTF-8 or UTF-16.  The sqlite3_prepare(), sqlite3_prepare_v2(),\n** and sqlite3_prepare_v3()\n** interfaces use UTF-8, and sqlite3_prepare16(), sqlite3_prepare16_v2(),\n** and sqlite3_prepare16_v3() use UTF-16.\n**\n** ^If the nByte argument is negative, then zSql is read up to the\n** first zero terminator. ^If nByte is positive, then it is the\n** number of bytes read from zSql.  ^If nByte is zero, then no prepared\n** statement is generated.\n** If the caller knows that the supplied string is nul-terminated, then\n** there is a small performance advantage to passing an nByte parameter that\n** is the number of bytes in the input string <i>including</i>\n** the nul-terminator.\n**\n** ^If pzTail is not NULL then *pzTail is made to point to the first byte\n** past the end of the first SQL statement in zSql.  These routines only\n** compile the first statement in zSql, so *pzTail is left pointing to\n** what remains uncompiled.\n**\n** ^*ppStmt is left pointing to a compiled [prepared statement] that can be\n** executed using [sqlite3_step()].  ^If there is an error, *ppStmt is set\n** to NULL.  ^If the input text contains no SQL (if the input is an empty\n** string or a comment) then *ppStmt is set to NULL.\n** The calling procedure is responsible for deleting the compiled\n** SQL statement using [sqlite3_finalize()] after it has finished with it.\n** ppStmt may not be NULL.\n**\n** ^On success, the sqlite3_prepare() family of routines return [SQLITE_OK];\n** otherwise an [error code] is returned.\n**\n** The sqlite3_prepare_v2(), sqlite3_prepare_v3(), sqlite3_prepare16_v2(),\n** and sqlite3_prepare16_v3() interfaces are recommended for all new programs.\n** The older interfaces (sqlite3_prepare() and sqlite3_prepare16())\n** are retained for backwards compatibility, but their use is discouraged.\n** ^In the \"vX\" interfaces, the prepared statement\n** that is returned (the [sqlite3_stmt] object) contains a copy of the\n** original SQL text. This causes the [sqlite3_step()] interface to\n** behave differently in three ways:\n**\n** <ol>\n** <li>\n** ^If the database schema changes, instead of returning [SQLITE_SCHEMA] as it\n** always used to do, [sqlite3_step()] will automatically recompile the SQL\n** statement and try to run it again. As many as [SQLITE_MAX_SCHEMA_RETRY]\n** retries will occur before sqlite3_step() gives up and returns an error.\n** </li>\n**\n** <li>\n** ^When an error occurs, [sqlite3_step()] will return one of the detailed\n** [error codes] or [extended error codes].  ^The legacy behavior was that\n** [sqlite3_step()] would only return a generic [SQLITE_ERROR] result code\n** and the application would have to make a second call to [sqlite3_reset()]\n** in order to find the underlying cause of the problem. With the \"v2\" prepare\n** interfaces, the underlying reason for the error is returned immediately.\n** </li>\n**\n** <li>\n** ^If the specific value bound to [parameter | host parameter] in the \n** WHERE clause might influence the choice of query plan for a statement,\n** then the statement will be automatically recompiled, as if there had been \n** a schema change, on the first  [sqlite3_step()] call following any change\n** to the [sqlite3_bind_text | bindings] of that [parameter]. \n** ^The specific value of WHERE-clause [parameter] might influence the \n** choice of query plan if the parameter is the left-hand side of a [LIKE]\n** or [GLOB] operator or if the parameter is compared to an indexed column\n** and the [SQLITE_ENABLE_STAT3] compile-time option is enabled.\n** </li>\n** </ol>\n**\n** <p>^sqlite3_prepare_v3() differs from sqlite3_prepare_v2() only in having\n** the extra prepFlags parameter, which is a bit array consisting of zero or\n** more of the [SQLITE_PREPARE_PERSISTENT|SQLITE_PREPARE_*] flags.  ^The\n** sqlite3_prepare_v2() interface works exactly the same as\n** sqlite3_prepare_v3() with a zero prepFlags parameter.\n*/\nSQLITE_API int sqlite3_prepare(\n  sqlite3 *db,            /* Database handle */\n  const char *zSql,       /* SQL statement, UTF-8 encoded */\n  int nByte,              /* Maximum length of zSql in bytes. */\n  sqlite3_stmt **ppStmt,  /* OUT: Statement handle */\n  const char **pzTail     /* OUT: Pointer to unused portion of zSql */\n);\nSQLITE_API int sqlite3_prepare_v2(\n  sqlite3 *db,            /* Database handle */\n  const char *zSql,       /* SQL statement, UTF-8 encoded */\n  int nByte,              /* Maximum length of zSql in bytes. */\n  sqlite3_stmt **ppStmt,  /* OUT: Statement handle */\n  const char **pzTail     /* OUT: Pointer to unused portion of zSql */\n);\nSQLITE_API int sqlite3_prepare_v3(\n  sqlite3 *db,            /* Database handle */\n  const char *zSql,       /* SQL statement, UTF-8 encoded */\n  int nByte,              /* Maximum length of zSql in bytes. */\n  unsigned int prepFlags, /* Zero or more SQLITE_PREPARE_ flags */\n  sqlite3_stmt **ppStmt,  /* OUT: Statement handle */\n  const char **pzTail     /* OUT: Pointer to unused portion of zSql */\n);\nSQLITE_API int sqlite3_prepare16(\n  sqlite3 *db,            /* Database handle */\n  const void *zSql,       /* SQL statement, UTF-16 encoded */\n  int nByte,              /* Maximum length of zSql in bytes. */\n  sqlite3_stmt **ppStmt,  /* OUT: Statement handle */\n  const void **pzTail     /* OUT: Pointer to unused portion of zSql */\n);\nSQLITE_API int sqlite3_prepare16_v2(\n  sqlite3 *db,            /* Database handle */\n  const void *zSql,       /* SQL statement, UTF-16 encoded */\n  int nByte,              /* Maximum length of zSql in bytes. */\n  sqlite3_stmt **ppStmt,  /* OUT: Statement handle */\n  const void **pzTail     /* OUT: Pointer to unused portion of zSql */\n);\nSQLITE_API int sqlite3_prepare16_v3(\n  sqlite3 *db,            /* Database handle */\n  const void *zSql,       /* SQL statement, UTF-16 encoded */\n  int nByte,              /* Maximum length of zSql in bytes. */\n  unsigned int prepFlags, /* Zero or more SQLITE_PREPARE_ flags */\n  sqlite3_stmt **ppStmt,  /* OUT: Statement handle */\n  const void **pzTail     /* OUT: Pointer to unused portion of zSql */\n);\n\n/*\n** CAPI3REF: Retrieving Statement SQL\n** METHOD: sqlite3_stmt\n**\n** ^The sqlite3_sql(P) interface returns a pointer to a copy of the UTF-8\n** SQL text used to create [prepared statement] P if P was\n** created by [sqlite3_prepare_v2()], [sqlite3_prepare_v3()],\n** [sqlite3_prepare16_v2()], or [sqlite3_prepare16_v3()].\n** ^The sqlite3_expanded_sql(P) interface returns a pointer to a UTF-8\n** string containing the SQL text of prepared statement P with\n** [bound parameters] expanded.\n** ^The sqlite3_normalized_sql(P) interface returns a pointer to a UTF-8\n** string containing the normalized SQL text of prepared statement P.  The\n** semantics used to normalize a SQL statement are unspecified and subject\n** to change.  At a minimum, literal values will be replaced with suitable\n** placeholders.\n**\n** ^(For example, if a prepared statement is created using the SQL\n** text \"SELECT $abc,:xyz\" and if parameter $abc is bound to integer 2345\n** and parameter :xyz is unbound, then sqlite3_sql() will return\n** the original string, \"SELECT $abc,:xyz\" but sqlite3_expanded_sql()\n** will return \"SELECT 2345,NULL\".)^\n**\n** ^The sqlite3_expanded_sql() interface returns NULL if insufficient memory\n** is available to hold the result, or if the result would exceed the\n** the maximum string length determined by the [SQLITE_LIMIT_LENGTH].\n**\n** ^The [SQLITE_TRACE_SIZE_LIMIT] compile-time option limits the size of\n** bound parameter expansions.  ^The [SQLITE_OMIT_TRACE] compile-time\n** option causes sqlite3_expanded_sql() to always return NULL.\n**\n** ^The strings returned by sqlite3_sql(P) and sqlite3_normalized_sql(P)\n** are managed by SQLite and are automatically freed when the prepared\n** statement is finalized.\n** ^The string returned by sqlite3_expanded_sql(P), on the other hand,\n** is obtained from [sqlite3_malloc()] and must be free by the application\n** by passing it to [sqlite3_free()].\n*/\nSQLITE_API const char *sqlite3_sql(sqlite3_stmt *pStmt);\nSQLITE_API char *sqlite3_expanded_sql(sqlite3_stmt *pStmt);\nSQLITE_API const char *sqlite3_normalized_sql(sqlite3_stmt *pStmt);\n\n/*\n** CAPI3REF: Determine If An SQL Statement Writes The Database\n** METHOD: sqlite3_stmt\n**\n** ^The sqlite3_stmt_readonly(X) interface returns true (non-zero) if\n** and only if the [prepared statement] X makes no direct changes to\n** the content of the database file.\n**\n** Note that [application-defined SQL functions] or\n** [virtual tables] might change the database indirectly as a side effect.  \n** ^(For example, if an application defines a function \"eval()\" that \n** calls [sqlite3_exec()], then the following SQL statement would\n** change the database file through side-effects:\n**\n** <blockquote><pre>\n**    SELECT eval('DELETE FROM t1') FROM t2;\n** </pre></blockquote>\n**\n** But because the [SELECT] statement does not change the database file\n** directly, sqlite3_stmt_readonly() would still return true.)^\n**\n** ^Transaction control statements such as [BEGIN], [COMMIT], [ROLLBACK],\n** [SAVEPOINT], and [RELEASE] cause sqlite3_stmt_readonly() to return true,\n** since the statements themselves do not actually modify the database but\n** rather they control the timing of when other statements modify the \n** database.  ^The [ATTACH] and [DETACH] statements also cause\n** sqlite3_stmt_readonly() to return true since, while those statements\n** change the configuration of a database connection, they do not make \n** changes to the content of the database files on disk.\n** ^The sqlite3_stmt_readonly() interface returns true for [BEGIN] since\n** [BEGIN] merely sets internal flags, but the [BEGIN|BEGIN IMMEDIATE] and\n** [BEGIN|BEGIN EXCLUSIVE] commands do touch the database and so\n** sqlite3_stmt_readonly() returns false for those commands.\n*/\nSQLITE_API int sqlite3_stmt_readonly(sqlite3_stmt *pStmt);\n\n/*\n** CAPI3REF: Determine If A Prepared Statement Has Been Reset\n** METHOD: sqlite3_stmt\n**\n** ^The sqlite3_stmt_busy(S) interface returns true (non-zero) if the\n** [prepared statement] S has been stepped at least once using \n** [sqlite3_step(S)] but has neither run to completion (returned\n** [SQLITE_DONE] from [sqlite3_step(S)]) nor\n** been reset using [sqlite3_reset(S)].  ^The sqlite3_stmt_busy(S)\n** interface returns false if S is a NULL pointer.  If S is not a \n** NULL pointer and is not a pointer to a valid [prepared statement]\n** object, then the behavior is undefined and probably undesirable.\n**\n** This interface can be used in combination [sqlite3_next_stmt()]\n** to locate all prepared statements associated with a database \n** connection that are in need of being reset.  This can be used,\n** for example, in diagnostic routines to search for prepared \n** statements that are holding a transaction open.\n*/\nSQLITE_API int sqlite3_stmt_busy(sqlite3_stmt*);\n\n/*\n** CAPI3REF: Dynamically Typed Value Object\n** KEYWORDS: {protected sqlite3_value} {unprotected sqlite3_value}\n**\n** SQLite uses the sqlite3_value object to represent all values\n** that can be stored in a database table. SQLite uses dynamic typing\n** for the values it stores.  ^Values stored in sqlite3_value objects\n** can be integers, floating point values, strings, BLOBs, or NULL.\n**\n** An sqlite3_value object may be either \"protected\" or \"unprotected\".\n** Some interfaces require a protected sqlite3_value.  Other interfaces\n** will accept either a protected or an unprotected sqlite3_value.\n** Every interface that accepts sqlite3_value arguments specifies\n** whether or not it requires a protected sqlite3_value.  The\n** [sqlite3_value_dup()] interface can be used to construct a new \n** protected sqlite3_value from an unprotected sqlite3_value.\n**\n** The terms \"protected\" and \"unprotected\" refer to whether or not\n** a mutex is held.  An internal mutex is held for a protected\n** sqlite3_value object but no mutex is held for an unprotected\n** sqlite3_value object.  If SQLite is compiled to be single-threaded\n** (with [SQLITE_THREADSAFE=0] and with [sqlite3_threadsafe()] returning 0)\n** or if SQLite is run in one of reduced mutex modes \n** [SQLITE_CONFIG_SINGLETHREAD] or [SQLITE_CONFIG_MULTITHREAD]\n** then there is no distinction between protected and unprotected\n** sqlite3_value objects and they can be used interchangeably.  However,\n** for maximum code portability it is recommended that applications\n** still make the distinction between protected and unprotected\n** sqlite3_value objects even when not strictly required.\n**\n** ^The sqlite3_value objects that are passed as parameters into the\n** implementation of [application-defined SQL functions] are protected.\n** ^The sqlite3_value object returned by\n** [sqlite3_column_value()] is unprotected.\n** Unprotected sqlite3_value objects may only be used as arguments\n** to [sqlite3_result_value()], [sqlite3_bind_value()], and\n** [sqlite3_value_dup()].\n** The [sqlite3_value_blob | sqlite3_value_type()] family of\n** interfaces require protected sqlite3_value objects.\n*/\ntypedef struct sqlite3_value sqlite3_value;\n\n/*\n** CAPI3REF: SQL Function Context Object\n**\n** The context in which an SQL function executes is stored in an\n** sqlite3_context object.  ^A pointer to an sqlite3_context object\n** is always first parameter to [application-defined SQL functions].\n** The application-defined SQL function implementation will pass this\n** pointer through into calls to [sqlite3_result_int | sqlite3_result()],\n** [sqlite3_aggregate_context()], [sqlite3_user_data()],\n** [sqlite3_context_db_handle()], [sqlite3_get_auxdata()],\n** and/or [sqlite3_set_auxdata()].\n*/\ntypedef struct sqlite3_context sqlite3_context;\n\n/*\n** CAPI3REF: Binding Values To Prepared Statements\n** KEYWORDS: {host parameter} {host parameters} {host parameter name}\n** KEYWORDS: {SQL parameter} {SQL parameters} {parameter binding}\n** METHOD: sqlite3_stmt\n**\n** ^(In the SQL statement text input to [sqlite3_prepare_v2()] and its variants,\n** literals may be replaced by a [parameter] that matches one of following\n** templates:\n**\n** <ul>\n** <li>  ?\n** <li>  ?NNN\n** <li>  :VVV\n** <li>  @VVV\n** <li>  $VVV\n** </ul>\n**\n** In the templates above, NNN represents an integer literal,\n** and VVV represents an alphanumeric identifier.)^  ^The values of these\n** parameters (also called \"host parameter names\" or \"SQL parameters\")\n** can be set using the sqlite3_bind_*() routines defined here.\n**\n** ^The first argument to the sqlite3_bind_*() routines is always\n** a pointer to the [sqlite3_stmt] object returned from\n** [sqlite3_prepare_v2()] or its variants.\n**\n** ^The second argument is the index of the SQL parameter to be set.\n** ^The leftmost SQL parameter has an index of 1.  ^When the same named\n** SQL parameter is used more than once, second and subsequent\n** occurrences have the same index as the first occurrence.\n** ^The index for named parameters can be looked up using the\n** [sqlite3_bind_parameter_index()] API if desired.  ^The index\n** for \"?NNN\" parameters is the value of NNN.\n** ^The NNN value must be between 1 and the [sqlite3_limit()]\n** parameter [SQLITE_LIMIT_VARIABLE_NUMBER] (default value: 999).\n**\n** ^The third argument is the value to bind to the parameter.\n** ^If the third parameter to sqlite3_bind_text() or sqlite3_bind_text16()\n** or sqlite3_bind_blob() is a NULL pointer then the fourth parameter\n** is ignored and the end result is the same as sqlite3_bind_null().\n**\n** ^(In those routines that have a fourth argument, its value is the\n** number of bytes in the parameter.  To be clear: the value is the\n** number of <u>bytes</u> in the value, not the number of characters.)^\n** ^If the fourth parameter to sqlite3_bind_text() or sqlite3_bind_text16()\n** is negative, then the length of the string is\n** the number of bytes up to the first zero terminator.\n** If the fourth parameter to sqlite3_bind_blob() is negative, then\n** the behavior is undefined.\n** If a non-negative fourth parameter is provided to sqlite3_bind_text()\n** or sqlite3_bind_text16() or sqlite3_bind_text64() then\n** that parameter must be the byte offset\n** where the NUL terminator would occur assuming the string were NUL\n** terminated.  If any NUL characters occur at byte offsets less than \n** the value of the fourth parameter then the resulting string value will\n** contain embedded NULs.  The result of expressions involving strings\n** with embedded NULs is undefined.\n**\n** ^The fifth argument to the BLOB and string binding interfaces\n** is a destructor used to dispose of the BLOB or\n** string after SQLite has finished with it.  ^The destructor is called\n** to dispose of the BLOB or string even if the call to bind API fails.\n** ^If the fifth argument is\n** the special value [SQLITE_STATIC], then SQLite assumes that the\n** information is in static, unmanaged space and does not need to be freed.\n** ^If the fifth argument has the value [SQLITE_TRANSIENT], then\n** SQLite makes its own private copy of the data immediately, before\n** the sqlite3_bind_*() routine returns.\n**\n** ^The sixth argument to sqlite3_bind_text64() must be one of\n** [SQLITE_UTF8], [SQLITE_UTF16], [SQLITE_UTF16BE], or [SQLITE_UTF16LE]\n** to specify the encoding of the text in the third parameter.  If\n** the sixth argument to sqlite3_bind_text64() is not one of the\n** allowed values shown above, or if the text encoding is different\n** from the encoding specified by the sixth parameter, then the behavior\n** is undefined.\n**\n** ^The sqlite3_bind_zeroblob() routine binds a BLOB of length N that\n** is filled with zeroes.  ^A zeroblob uses a fixed amount of memory\n** (just an integer to hold its size) while it is being processed.\n** Zeroblobs are intended to serve as placeholders for BLOBs whose\n** content is later written using\n** [sqlite3_blob_open | incremental BLOB I/O] routines.\n** ^A negative value for the zeroblob results in a zero-length BLOB.\n**\n** ^The sqlite3_bind_pointer(S,I,P,T,D) routine causes the I-th parameter in\n** [prepared statement] S to have an SQL value of NULL, but to also be\n** associated with the pointer P of type T.  ^D is either a NULL pointer or\n** a pointer to a destructor function for P. ^SQLite will invoke the\n** destructor D with a single argument of P when it is finished using\n** P.  The T parameter should be a static string, preferably a string\n** literal. The sqlite3_bind_pointer() routine is part of the\n** [pointer passing interface] added for SQLite 3.20.0.\n**\n** ^If any of the sqlite3_bind_*() routines are called with a NULL pointer\n** for the [prepared statement] or with a prepared statement for which\n** [sqlite3_step()] has been called more recently than [sqlite3_reset()],\n** then the call will return [SQLITE_MISUSE].  If any sqlite3_bind_()\n** routine is passed a [prepared statement] that has been finalized, the\n** result is undefined and probably harmful.\n**\n** ^Bindings are not cleared by the [sqlite3_reset()] routine.\n** ^Unbound parameters are interpreted as NULL.\n**\n** ^The sqlite3_bind_* routines return [SQLITE_OK] on success or an\n** [error code] if anything goes wrong.\n** ^[SQLITE_TOOBIG] might be returned if the size of a string or BLOB\n** exceeds limits imposed by [sqlite3_limit]([SQLITE_LIMIT_LENGTH]) or\n** [SQLITE_MAX_LENGTH].\n** ^[SQLITE_RANGE] is returned if the parameter\n** index is out of range.  ^[SQLITE_NOMEM] is returned if malloc() fails.\n**\n** See also: [sqlite3_bind_parameter_count()],\n** [sqlite3_bind_parameter_name()], and [sqlite3_bind_parameter_index()].\n*/\nSQLITE_API int sqlite3_bind_blob(sqlite3_stmt*, int, const void*, int n, void(*)(void*));\nSQLITE_API int sqlite3_bind_blob64(sqlite3_stmt*, int, const void*, sqlite3_uint64,\n                        void(*)(void*));\nSQLITE_API int sqlite3_bind_double(sqlite3_stmt*, int, double);\nSQLITE_API int sqlite3_bind_int(sqlite3_stmt*, int, int);\nSQLITE_API int sqlite3_bind_int64(sqlite3_stmt*, int, sqlite3_int64);\nSQLITE_API int sqlite3_bind_null(sqlite3_stmt*, int);\nSQLITE_API int sqlite3_bind_text(sqlite3_stmt*,int,const char*,int,void(*)(void*));\nSQLITE_API int sqlite3_bind_text16(sqlite3_stmt*, int, const void*, int, void(*)(void*));\nSQLITE_API int sqlite3_bind_text64(sqlite3_stmt*, int, const char*, sqlite3_uint64,\n                         void(*)(void*), unsigned char encoding);\nSQLITE_API int sqlite3_bind_value(sqlite3_stmt*, int, const sqlite3_value*);\nSQLITE_API int sqlite3_bind_pointer(sqlite3_stmt*, int, void*, const char*,void(*)(void*));\nSQLITE_API int sqlite3_bind_zeroblob(sqlite3_stmt*, int, int n);\nSQLITE_API int sqlite3_bind_zeroblob64(sqlite3_stmt*, int, sqlite3_uint64);\n\n/*\n** CAPI3REF: Number Of SQL Parameters\n** METHOD: sqlite3_stmt\n**\n** ^This routine can be used to find the number of [SQL parameters]\n** in a [prepared statement].  SQL parameters are tokens of the\n** form \"?\", \"?NNN\", \":AAA\", \"$AAA\", or \"@AAA\" that serve as\n** placeholders for values that are [sqlite3_bind_blob | bound]\n** to the parameters at a later time.\n**\n** ^(This routine actually returns the index of the largest (rightmost)\n** parameter. For all forms except ?NNN, this will correspond to the\n** number of unique parameters.  If parameters of the ?NNN form are used,\n** there may be gaps in the list.)^\n**\n** See also: [sqlite3_bind_blob|sqlite3_bind()],\n** [sqlite3_bind_parameter_name()], and\n** [sqlite3_bind_parameter_index()].\n*/\nSQLITE_API int sqlite3_bind_parameter_count(sqlite3_stmt*);\n\n/*\n** CAPI3REF: Name Of A Host Parameter\n** METHOD: sqlite3_stmt\n**\n** ^The sqlite3_bind_parameter_name(P,N) interface returns\n** the name of the N-th [SQL parameter] in the [prepared statement] P.\n** ^(SQL parameters of the form \"?NNN\" or \":AAA\" or \"@AAA\" or \"$AAA\"\n** have a name which is the string \"?NNN\" or \":AAA\" or \"@AAA\" or \"$AAA\"\n** respectively.\n** In other words, the initial \":\" or \"$\" or \"@\" or \"?\"\n** is included as part of the name.)^\n** ^Parameters of the form \"?\" without a following integer have no name\n** and are referred to as \"nameless\" or \"anonymous parameters\".\n**\n** ^The first host parameter has an index of 1, not 0.\n**\n** ^If the value N is out of range or if the N-th parameter is\n** nameless, then NULL is returned.  ^The returned string is\n** always in UTF-8 encoding even if the named parameter was\n** originally specified as UTF-16 in [sqlite3_prepare16()],\n** [sqlite3_prepare16_v2()], or [sqlite3_prepare16_v3()].\n**\n** See also: [sqlite3_bind_blob|sqlite3_bind()],\n** [sqlite3_bind_parameter_count()], and\n** [sqlite3_bind_parameter_index()].\n*/\nSQLITE_API const char *sqlite3_bind_parameter_name(sqlite3_stmt*, int);\n\n/*\n** CAPI3REF: Index Of A Parameter With A Given Name\n** METHOD: sqlite3_stmt\n**\n** ^Return the index of an SQL parameter given its name.  ^The\n** index value returned is suitable for use as the second\n** parameter to [sqlite3_bind_blob|sqlite3_bind()].  ^A zero\n** is returned if no matching parameter is found.  ^The parameter\n** name must be given in UTF-8 even if the original statement\n** was prepared from UTF-16 text using [sqlite3_prepare16_v2()] or\n** [sqlite3_prepare16_v3()].\n**\n** See also: [sqlite3_bind_blob|sqlite3_bind()],\n** [sqlite3_bind_parameter_count()], and\n** [sqlite3_bind_parameter_name()].\n*/\nSQLITE_API int sqlite3_bind_parameter_index(sqlite3_stmt*, const char *zName);\n\n/*\n** CAPI3REF: Reset All Bindings On A Prepared Statement\n** METHOD: sqlite3_stmt\n**\n** ^Contrary to the intuition of many, [sqlite3_reset()] does not reset\n** the [sqlite3_bind_blob | bindings] on a [prepared statement].\n** ^Use this routine to reset all host parameters to NULL.\n*/\nSQLITE_API int sqlite3_clear_bindings(sqlite3_stmt*);\n\n/*\n** CAPI3REF: Number Of Columns In A Result Set\n** METHOD: sqlite3_stmt\n**\n** ^Return the number of columns in the result set returned by the\n** [prepared statement]. ^If this routine returns 0, that means the \n** [prepared statement] returns no data (for example an [UPDATE]).\n** ^However, just because this routine returns a positive number does not\n** mean that one or more rows of data will be returned.  ^A SELECT statement\n** will always have a positive sqlite3_column_count() but depending on the\n** WHERE clause constraints and the table content, it might return no rows.\n**\n** See also: [sqlite3_data_count()]\n*/\nSQLITE_API int sqlite3_column_count(sqlite3_stmt *pStmt);\n\n/*\n** CAPI3REF: Column Names In A Result Set\n** METHOD: sqlite3_stmt\n**\n** ^These routines return the name assigned to a particular column\n** in the result set of a [SELECT] statement.  ^The sqlite3_column_name()\n** interface returns a pointer to a zero-terminated UTF-8 string\n** and sqlite3_column_name16() returns a pointer to a zero-terminated\n** UTF-16 string.  ^The first parameter is the [prepared statement]\n** that implements the [SELECT] statement. ^The second parameter is the\n** column number.  ^The leftmost column is number 0.\n**\n** ^The returned string pointer is valid until either the [prepared statement]\n** is destroyed by [sqlite3_finalize()] or until the statement is automatically\n** reprepared by the first call to [sqlite3_step()] for a particular run\n** or until the next call to\n** sqlite3_column_name() or sqlite3_column_name16() on the same column.\n**\n** ^If sqlite3_malloc() fails during the processing of either routine\n** (for example during a conversion from UTF-8 to UTF-16) then a\n** NULL pointer is returned.\n**\n** ^The name of a result column is the value of the \"AS\" clause for\n** that column, if there is an AS clause.  If there is no AS clause\n** then the name of the column is unspecified and may change from\n** one release of SQLite to the next.\n*/\nSQLITE_API const char *sqlite3_column_name(sqlite3_stmt*, int N);\nSQLITE_API const void *sqlite3_column_name16(sqlite3_stmt*, int N);\n\n/*\n** CAPI3REF: Source Of Data In A Query Result\n** METHOD: sqlite3_stmt\n**\n** ^These routines provide a means to determine the database, table, and\n** table column that is the origin of a particular result column in\n** [SELECT] statement.\n** ^The name of the database or table or column can be returned as\n** either a UTF-8 or UTF-16 string.  ^The _database_ routines return\n** the database name, the _table_ routines return the table name, and\n** the origin_ routines return the column name.\n** ^The returned string is valid until the [prepared statement] is destroyed\n** using [sqlite3_finalize()] or until the statement is automatically\n** reprepared by the first call to [sqlite3_step()] for a particular run\n** or until the same information is requested\n** again in a different encoding.\n**\n** ^The names returned are the original un-aliased names of the\n** database, table, and column.\n**\n** ^The first argument to these interfaces is a [prepared statement].\n** ^These functions return information about the Nth result column returned by\n** the statement, where N is the second function argument.\n** ^The left-most column is column 0 for these routines.\n**\n** ^If the Nth column returned by the statement is an expression or\n** subquery and is not a column value, then all of these functions return\n** NULL.  ^These routine might also return NULL if a memory allocation error\n** occurs.  ^Otherwise, they return the name of the attached database, table,\n** or column that query result column was extracted from.\n**\n** ^As with all other SQLite APIs, those whose names end with \"16\" return\n** UTF-16 encoded strings and the other functions return UTF-8.\n**\n** ^These APIs are only available if the library was compiled with the\n** [SQLITE_ENABLE_COLUMN_METADATA] C-preprocessor symbol.\n**\n** If two or more threads call one or more of these routines against the same\n** prepared statement and column at the same time then the results are\n** undefined.\n**\n** If two or more threads call one or more\n** [sqlite3_column_database_name | column metadata interfaces]\n** for the same [prepared statement] and result column\n** at the same time then the results are undefined.\n*/\nSQLITE_API const char *sqlite3_column_database_name(sqlite3_stmt*,int);\nSQLITE_API const void *sqlite3_column_database_name16(sqlite3_stmt*,int);\nSQLITE_API const char *sqlite3_column_table_name(sqlite3_stmt*,int);\nSQLITE_API const void *sqlite3_column_table_name16(sqlite3_stmt*,int);\nSQLITE_API const char *sqlite3_column_origin_name(sqlite3_stmt*,int);\nSQLITE_API const void *sqlite3_column_origin_name16(sqlite3_stmt*,int);\n\n/*\n** CAPI3REF: Declared Datatype Of A Query Result\n** METHOD: sqlite3_stmt\n**\n** ^(The first parameter is a [prepared statement].\n** If this statement is a [SELECT] statement and the Nth column of the\n** returned result set of that [SELECT] is a table column (not an\n** expression or subquery) then the declared type of the table\n** column is returned.)^  ^If the Nth column of the result set is an\n** expression or subquery, then a NULL pointer is returned.\n** ^The returned string is always UTF-8 encoded.\n**\n** ^(For example, given the database schema:\n**\n** CREATE TABLE t1(c1 VARIANT);\n**\n** and the following statement to be compiled:\n**\n** SELECT c1 + 1, c1 FROM t1;\n**\n** this routine would return the string \"VARIANT\" for the second result\n** column (i==1), and a NULL pointer for the first result column (i==0).)^\n**\n** ^SQLite uses dynamic run-time typing.  ^So just because a column\n** is declared to contain a particular type does not mean that the\n** data stored in that column is of the declared type.  SQLite is\n** strongly typed, but the typing is dynamic not static.  ^Type\n** is associated with individual values, not with the containers\n** used to hold those values.\n*/\nSQLITE_API const char *sqlite3_column_decltype(sqlite3_stmt*,int);\nSQLITE_API const void *sqlite3_column_decltype16(sqlite3_stmt*,int);\n\n/*\n** CAPI3REF: Evaluate An SQL Statement\n** METHOD: sqlite3_stmt\n**\n** After a [prepared statement] has been prepared using any of\n** [sqlite3_prepare_v2()], [sqlite3_prepare_v3()], [sqlite3_prepare16_v2()],\n** or [sqlite3_prepare16_v3()] or one of the legacy\n** interfaces [sqlite3_prepare()] or [sqlite3_prepare16()], this function\n** must be called one or more times to evaluate the statement.\n**\n** The details of the behavior of the sqlite3_step() interface depend\n** on whether the statement was prepared using the newer \"vX\" interfaces\n** [sqlite3_prepare_v3()], [sqlite3_prepare_v2()], [sqlite3_prepare16_v3()],\n** [sqlite3_prepare16_v2()] or the older legacy\n** interfaces [sqlite3_prepare()] and [sqlite3_prepare16()].  The use of the\n** new \"vX\" interface is recommended for new applications but the legacy\n** interface will continue to be supported.\n**\n** ^In the legacy interface, the return value will be either [SQLITE_BUSY],\n** [SQLITE_DONE], [SQLITE_ROW], [SQLITE_ERROR], or [SQLITE_MISUSE].\n** ^With the \"v2\" interface, any of the other [result codes] or\n** [extended result codes] might be returned as well.\n**\n** ^[SQLITE_BUSY] means that the database engine was unable to acquire the\n** database locks it needs to do its job.  ^If the statement is a [COMMIT]\n** or occurs outside of an explicit transaction, then you can retry the\n** statement.  If the statement is not a [COMMIT] and occurs within an\n** explicit transaction then you should rollback the transaction before\n** continuing.\n**\n** ^[SQLITE_DONE] means that the statement has finished executing\n** successfully.  sqlite3_step() should not be called again on this virtual\n** machine without first calling [sqlite3_reset()] to reset the virtual\n** machine back to its initial state.\n**\n** ^If the SQL statement being executed returns any data, then [SQLITE_ROW]\n** is returned each time a new row of data is ready for processing by the\n** caller. The values may be accessed using the [column access functions].\n** sqlite3_step() is called again to retrieve the next row of data.\n**\n** ^[SQLITE_ERROR] means that a run-time error (such as a constraint\n** violation) has occurred.  sqlite3_step() should not be called again on\n** the VM. More information may be found by calling [sqlite3_errmsg()].\n** ^With the legacy interface, a more specific error code (for example,\n** [SQLITE_INTERRUPT], [SQLITE_SCHEMA], [SQLITE_CORRUPT], and so forth)\n** can be obtained by calling [sqlite3_reset()] on the\n** [prepared statement].  ^In the \"v2\" interface,\n** the more specific error code is returned directly by sqlite3_step().\n**\n** [SQLITE_MISUSE] means that the this routine was called inappropriately.\n** Perhaps it was called on a [prepared statement] that has\n** already been [sqlite3_finalize | finalized] or on one that had\n** previously returned [SQLITE_ERROR] or [SQLITE_DONE].  Or it could\n** be the case that the same database connection is being used by two or\n** more threads at the same moment in time.\n**\n** For all versions of SQLite up to and including 3.6.23.1, a call to\n** [sqlite3_reset()] was required after sqlite3_step() returned anything\n** other than [SQLITE_ROW] before any subsequent invocation of\n** sqlite3_step().  Failure to reset the prepared statement using \n** [sqlite3_reset()] would result in an [SQLITE_MISUSE] return from\n** sqlite3_step().  But after [version 3.6.23.1] ([dateof:3.6.23.1],\n** sqlite3_step() began\n** calling [sqlite3_reset()] automatically in this circumstance rather\n** than returning [SQLITE_MISUSE].  This is not considered a compatibility\n** break because any application that ever receives an SQLITE_MISUSE error\n** is broken by definition.  The [SQLITE_OMIT_AUTORESET] compile-time option\n** can be used to restore the legacy behavior.\n**\n** <b>Goofy Interface Alert:</b> In the legacy interface, the sqlite3_step()\n** API always returns a generic error code, [SQLITE_ERROR], following any\n** error other than [SQLITE_BUSY] and [SQLITE_MISUSE].  You must call\n** [sqlite3_reset()] or [sqlite3_finalize()] in order to find one of the\n** specific [error codes] that better describes the error.\n** We admit that this is a goofy design.  The problem has been fixed\n** with the \"v2\" interface.  If you prepare all of your SQL statements\n** using [sqlite3_prepare_v3()] or [sqlite3_prepare_v2()]\n** or [sqlite3_prepare16_v2()] or [sqlite3_prepare16_v3()] instead\n** of the legacy [sqlite3_prepare()] and [sqlite3_prepare16()] interfaces,\n** then the more specific [error codes] are returned directly\n** by sqlite3_step().  The use of the \"vX\" interfaces is recommended.\n*/\nSQLITE_API int sqlite3_step(sqlite3_stmt*);\n\n/*\n** CAPI3REF: Number of columns in a result set\n** METHOD: sqlite3_stmt\n**\n** ^The sqlite3_data_count(P) interface returns the number of columns in the\n** current row of the result set of [prepared statement] P.\n** ^If prepared statement P does not have results ready to return\n** (via calls to the [sqlite3_column_int | sqlite3_column_*()] of\n** interfaces) then sqlite3_data_count(P) returns 0.\n** ^The sqlite3_data_count(P) routine also returns 0 if P is a NULL pointer.\n** ^The sqlite3_data_count(P) routine returns 0 if the previous call to\n** [sqlite3_step](P) returned [SQLITE_DONE].  ^The sqlite3_data_count(P)\n** will return non-zero if previous call to [sqlite3_step](P) returned\n** [SQLITE_ROW], except in the case of the [PRAGMA incremental_vacuum]\n** where it always returns zero since each step of that multi-step\n** pragma returns 0 columns of data.\n**\n** See also: [sqlite3_column_count()]\n*/\nSQLITE_API int sqlite3_data_count(sqlite3_stmt *pStmt);\n\n/*\n** CAPI3REF: Fundamental Datatypes\n** KEYWORDS: SQLITE_TEXT\n**\n** ^(Every value in SQLite has one of five fundamental datatypes:\n**\n** <ul>\n** <li> 64-bit signed integer\n** <li> 64-bit IEEE floating point number\n** <li> string\n** <li> BLOB\n** <li> NULL\n** </ul>)^\n**\n** These constants are codes for each of those types.\n**\n** Note that the SQLITE_TEXT constant was also used in SQLite version 2\n** for a completely different meaning.  Software that links against both\n** SQLite version 2 and SQLite version 3 should use SQLITE3_TEXT, not\n** SQLITE_TEXT.\n*/\n#define SQLITE_INTEGER  1\n#define SQLITE_FLOAT    2\n#define SQLITE_BLOB     4\n#define SQLITE_NULL     5\n#ifdef SQLITE_TEXT\n# undef SQLITE_TEXT\n#else\n# define SQLITE_TEXT     3\n#endif\n#define SQLITE3_TEXT     3\n\n/*\n** CAPI3REF: Result Values From A Query\n** KEYWORDS: {column access functions}\n** METHOD: sqlite3_stmt\n**\n** <b>Summary:</b>\n** <blockquote><table border=0 cellpadding=0 cellspacing=0>\n** <tr><td><b>sqlite3_column_blob</b><td>&rarr;<td>BLOB result\n** <tr><td><b>sqlite3_column_double</b><td>&rarr;<td>REAL result\n** <tr><td><b>sqlite3_column_int</b><td>&rarr;<td>32-bit INTEGER result\n** <tr><td><b>sqlite3_column_int64</b><td>&rarr;<td>64-bit INTEGER result\n** <tr><td><b>sqlite3_column_text</b><td>&rarr;<td>UTF-8 TEXT result\n** <tr><td><b>sqlite3_column_text16</b><td>&rarr;<td>UTF-16 TEXT result\n** <tr><td><b>sqlite3_column_value</b><td>&rarr;<td>The result as an \n** [sqlite3_value|unprotected sqlite3_value] object.\n** <tr><td>&nbsp;<td>&nbsp;<td>&nbsp;\n** <tr><td><b>sqlite3_column_bytes</b><td>&rarr;<td>Size of a BLOB\n** or a UTF-8 TEXT result in bytes\n** <tr><td><b>sqlite3_column_bytes16&nbsp;&nbsp;</b>\n** <td>&rarr;&nbsp;&nbsp;<td>Size of UTF-16\n** TEXT in bytes\n** <tr><td><b>sqlite3_column_type</b><td>&rarr;<td>Default\n** datatype of the result\n** </table></blockquote>\n**\n** <b>Details:</b>\n**\n** ^These routines return information about a single column of the current\n** result row of a query.  ^In every case the first argument is a pointer\n** to the [prepared statement] that is being evaluated (the [sqlite3_stmt*]\n** that was returned from [sqlite3_prepare_v2()] or one of its variants)\n** and the second argument is the index of the column for which information\n** should be returned. ^The leftmost column of the result set has the index 0.\n** ^The number of columns in the result can be determined using\n** [sqlite3_column_count()].\n**\n** If the SQL statement does not currently point to a valid row, or if the\n** column index is out of range, the result is undefined.\n** These routines may only be called when the most recent call to\n** [sqlite3_step()] has returned [SQLITE_ROW] and neither\n** [sqlite3_reset()] nor [sqlite3_finalize()] have been called subsequently.\n** If any of these routines are called after [sqlite3_reset()] or\n** [sqlite3_finalize()] or after [sqlite3_step()] has returned\n** something other than [SQLITE_ROW], the results are undefined.\n** If [sqlite3_step()] or [sqlite3_reset()] or [sqlite3_finalize()]\n** are called from a different thread while any of these routines\n** are pending, then the results are undefined.\n**\n** The first six interfaces (_blob, _double, _int, _int64, _text, and _text16)\n** each return the value of a result column in a specific data format.  If\n** the result column is not initially in the requested format (for example,\n** if the query returns an integer but the sqlite3_column_text() interface\n** is used to extract the value) then an automatic type conversion is performed.\n**\n** ^The sqlite3_column_type() routine returns the\n** [SQLITE_INTEGER | datatype code] for the initial data type\n** of the result column.  ^The returned value is one of [SQLITE_INTEGER],\n** [SQLITE_FLOAT], [SQLITE_TEXT], [SQLITE_BLOB], or [SQLITE_NULL].\n** The return value of sqlite3_column_type() can be used to decide which\n** of the first six interface should be used to extract the column value.\n** The value returned by sqlite3_column_type() is only meaningful if no\n** automatic type conversions have occurred for the value in question.  \n** After a type conversion, the result of calling sqlite3_column_type()\n** is undefined, though harmless.  Future\n** versions of SQLite may change the behavior of sqlite3_column_type()\n** following a type conversion.\n**\n** If the result is a BLOB or a TEXT string, then the sqlite3_column_bytes()\n** or sqlite3_column_bytes16() interfaces can be used to determine the size\n** of that BLOB or string.\n**\n** ^If the result is a BLOB or UTF-8 string then the sqlite3_column_bytes()\n** routine returns the number of bytes in that BLOB or string.\n** ^If the result is a UTF-16 string, then sqlite3_column_bytes() converts\n** the string to UTF-8 and then returns the number of bytes.\n** ^If the result is a numeric value then sqlite3_column_bytes() uses\n** [sqlite3_snprintf()] to convert that value to a UTF-8 string and returns\n** the number of bytes in that string.\n** ^If the result is NULL, then sqlite3_column_bytes() returns zero.\n**\n** ^If the result is a BLOB or UTF-16 string then the sqlite3_column_bytes16()\n** routine returns the number of bytes in that BLOB or string.\n** ^If the result is a UTF-8 string, then sqlite3_column_bytes16() converts\n** the string to UTF-16 and then returns the number of bytes.\n** ^If the result is a numeric value then sqlite3_column_bytes16() uses\n** [sqlite3_snprintf()] to convert that value to a UTF-16 string and returns\n** the number of bytes in that string.\n** ^If the result is NULL, then sqlite3_column_bytes16() returns zero.\n**\n** ^The values returned by [sqlite3_column_bytes()] and \n** [sqlite3_column_bytes16()] do not include the zero terminators at the end\n** of the string.  ^For clarity: the values returned by\n** [sqlite3_column_bytes()] and [sqlite3_column_bytes16()] are the number of\n** bytes in the string, not the number of characters.\n**\n** ^Strings returned by sqlite3_column_text() and sqlite3_column_text16(),\n** even empty strings, are always zero-terminated.  ^The return\n** value from sqlite3_column_blob() for a zero-length BLOB is a NULL pointer.\n**\n** <b>Warning:</b> ^The object returned by [sqlite3_column_value()] is an\n** [unprotected sqlite3_value] object.  In a multithreaded environment,\n** an unprotected sqlite3_value object may only be used safely with\n** [sqlite3_bind_value()] and [sqlite3_result_value()].\n** If the [unprotected sqlite3_value] object returned by\n** [sqlite3_column_value()] is used in any other way, including calls\n** to routines like [sqlite3_value_int()], [sqlite3_value_text()],\n** or [sqlite3_value_bytes()], the behavior is not threadsafe.\n** Hence, the sqlite3_column_value() interface\n** is normally only useful within the implementation of \n** [application-defined SQL functions] or [virtual tables], not within\n** top-level application code.\n**\n** The these routines may attempt to convert the datatype of the result.\n** ^For example, if the internal representation is FLOAT and a text result\n** is requested, [sqlite3_snprintf()] is used internally to perform the\n** conversion automatically.  ^(The following table details the conversions\n** that are applied:\n**\n** <blockquote>\n** <table border=\"1\">\n** <tr><th> Internal<br>Type <th> Requested<br>Type <th>  Conversion\n**\n** <tr><td>  NULL    <td> INTEGER   <td> Result is 0\n** <tr><td>  NULL    <td>  FLOAT    <td> Result is 0.0\n** <tr><td>  NULL    <td>   TEXT    <td> Result is a NULL pointer\n** <tr><td>  NULL    <td>   BLOB    <td> Result is a NULL pointer\n** <tr><td> INTEGER  <td>  FLOAT    <td> Convert from integer to float\n** <tr><td> INTEGER  <td>   TEXT    <td> ASCII rendering of the integer\n** <tr><td> INTEGER  <td>   BLOB    <td> Same as INTEGER->TEXT\n** <tr><td>  FLOAT   <td> INTEGER   <td> [CAST] to INTEGER\n** <tr><td>  FLOAT   <td>   TEXT    <td> ASCII rendering of the float\n** <tr><td>  FLOAT   <td>   BLOB    <td> [CAST] to BLOB\n** <tr><td>  TEXT    <td> INTEGER   <td> [CAST] to INTEGER\n** <tr><td>  TEXT    <td>  FLOAT    <td> [CAST] to REAL\n** <tr><td>  TEXT    <td>   BLOB    <td> No change\n** <tr><td>  BLOB    <td> INTEGER   <td> [CAST] to INTEGER\n** <tr><td>  BLOB    <td>  FLOAT    <td> [CAST] to REAL\n** <tr><td>  BLOB    <td>   TEXT    <td> Add a zero terminator if needed\n** </table>\n** </blockquote>)^\n**\n** Note that when type conversions occur, pointers returned by prior\n** calls to sqlite3_column_blob(), sqlite3_column_text(), and/or\n** sqlite3_column_text16() may be invalidated.\n** Type conversions and pointer invalidations might occur\n** in the following cases:\n**\n** <ul>\n** <li> The initial content is a BLOB and sqlite3_column_text() or\n**      sqlite3_column_text16() is called.  A zero-terminator might\n**      need to be added to the string.</li>\n** <li> The initial content is UTF-8 text and sqlite3_column_bytes16() or\n**      sqlite3_column_text16() is called.  The content must be converted\n**      to UTF-16.</li>\n** <li> The initial content is UTF-16 text and sqlite3_column_bytes() or\n**      sqlite3_column_text() is called.  The content must be converted\n**      to UTF-8.</li>\n** </ul>\n**\n** ^Conversions between UTF-16be and UTF-16le are always done in place and do\n** not invalidate a prior pointer, though of course the content of the buffer\n** that the prior pointer references will have been modified.  Other kinds\n** of conversion are done in place when it is possible, but sometimes they\n** are not possible and in those cases prior pointers are invalidated.\n**\n** The safest policy is to invoke these routines\n** in one of the following ways:\n**\n** <ul>\n**  <li>sqlite3_column_text() followed by sqlite3_column_bytes()</li>\n**  <li>sqlite3_column_blob() followed by sqlite3_column_bytes()</li>\n**  <li>sqlite3_column_text16() followed by sqlite3_column_bytes16()</li>\n** </ul>\n**\n** In other words, you should call sqlite3_column_text(),\n** sqlite3_column_blob(), or sqlite3_column_text16() first to force the result\n** into the desired format, then invoke sqlite3_column_bytes() or\n** sqlite3_column_bytes16() to find the size of the result.  Do not mix calls\n** to sqlite3_column_text() or sqlite3_column_blob() with calls to\n** sqlite3_column_bytes16(), and do not mix calls to sqlite3_column_text16()\n** with calls to sqlite3_column_bytes().\n**\n** ^The pointers returned are valid until a type conversion occurs as\n** described above, or until [sqlite3_step()] or [sqlite3_reset()] or\n** [sqlite3_finalize()] is called.  ^The memory space used to hold strings\n** and BLOBs is freed automatically.  Do not pass the pointers returned\n** from [sqlite3_column_blob()], [sqlite3_column_text()], etc. into\n** [sqlite3_free()].\n**\n** As long as the input parameters are correct, these routines will only\n** fail if an out-of-memory error occurs during a format conversion.\n** Only the following subset of interfaces are subject to out-of-memory\n** errors:\n**\n** <ul>\n** <li> sqlite3_column_blob()\n** <li> sqlite3_column_text()\n** <li> sqlite3_column_text16()\n** <li> sqlite3_column_bytes()\n** <li> sqlite3_column_bytes16()\n** </ul>\n**\n** If an out-of-memory error occurs, then the return value from these\n** routines is the same as if the column had contained an SQL NULL value.\n** Valid SQL NULL returns can be distinguished from out-of-memory errors\n** by invoking the [sqlite3_errcode()] immediately after the suspect\n** return value is obtained and before any\n** other SQLite interface is called on the same [database connection].\n*/\nSQLITE_API const void *sqlite3_column_blob(sqlite3_stmt*, int iCol);\nSQLITE_API double sqlite3_column_double(sqlite3_stmt*, int iCol);\nSQLITE_API int sqlite3_column_int(sqlite3_stmt*, int iCol);\nSQLITE_API sqlite3_int64 sqlite3_column_int64(sqlite3_stmt*, int iCol);\nSQLITE_API const unsigned char *sqlite3_column_text(sqlite3_stmt*, int iCol);\nSQLITE_API const void *sqlite3_column_text16(sqlite3_stmt*, int iCol);\nSQLITE_API sqlite3_value *sqlite3_column_value(sqlite3_stmt*, int iCol);\nSQLITE_API int sqlite3_column_bytes(sqlite3_stmt*, int iCol);\nSQLITE_API int sqlite3_column_bytes16(sqlite3_stmt*, int iCol);\nSQLITE_API int sqlite3_column_type(sqlite3_stmt*, int iCol);\n\n/*\n** CAPI3REF: Destroy A Prepared Statement Object\n** DESTRUCTOR: sqlite3_stmt\n**\n** ^The sqlite3_finalize() function is called to delete a [prepared statement].\n** ^If the most recent evaluation of the statement encountered no errors\n** or if the statement is never been evaluated, then sqlite3_finalize() returns\n** SQLITE_OK.  ^If the most recent evaluation of statement S failed, then\n** sqlite3_finalize(S) returns the appropriate [error code] or\n** [extended error code].\n**\n** ^The sqlite3_finalize(S) routine can be called at any point during\n** the life cycle of [prepared statement] S:\n** before statement S is ever evaluated, after\n** one or more calls to [sqlite3_reset()], or after any call\n** to [sqlite3_step()] regardless of whether or not the statement has\n** completed execution.\n**\n** ^Invoking sqlite3_finalize() on a NULL pointer is a harmless no-op.\n**\n** The application must finalize every [prepared statement] in order to avoid\n** resource leaks.  It is a grievous error for the application to try to use\n** a prepared statement after it has been finalized.  Any use of a prepared\n** statement after it has been finalized can result in undefined and\n** undesirable behavior such as segfaults and heap corruption.\n*/\nSQLITE_API int sqlite3_finalize(sqlite3_stmt *pStmt);\n\n/*\n** CAPI3REF: Reset A Prepared Statement Object\n** METHOD: sqlite3_stmt\n**\n** The sqlite3_reset() function is called to reset a [prepared statement]\n** object back to its initial state, ready to be re-executed.\n** ^Any SQL statement variables that had values bound to them using\n** the [sqlite3_bind_blob | sqlite3_bind_*() API] retain their values.\n** Use [sqlite3_clear_bindings()] to reset the bindings.\n**\n** ^The [sqlite3_reset(S)] interface resets the [prepared statement] S\n** back to the beginning of its program.\n**\n** ^If the most recent call to [sqlite3_step(S)] for the\n** [prepared statement] S returned [SQLITE_ROW] or [SQLITE_DONE],\n** or if [sqlite3_step(S)] has never before been called on S,\n** then [sqlite3_reset(S)] returns [SQLITE_OK].\n**\n** ^If the most recent call to [sqlite3_step(S)] for the\n** [prepared statement] S indicated an error, then\n** [sqlite3_reset(S)] returns an appropriate [error code].\n**\n** ^The [sqlite3_reset(S)] interface does not change the values\n** of any [sqlite3_bind_blob|bindings] on the [prepared statement] S.\n*/\nSQLITE_API int sqlite3_reset(sqlite3_stmt *pStmt);\n\n/*\n** CAPI3REF: Create Or Redefine SQL Functions\n** KEYWORDS: {function creation routines}\n** KEYWORDS: {application-defined SQL function}\n** KEYWORDS: {application-defined SQL functions}\n** METHOD: sqlite3\n**\n** ^These functions (collectively known as \"function creation routines\")\n** are used to add SQL functions or aggregates or to redefine the behavior\n** of existing SQL functions or aggregates. The only differences between\n** the three \"sqlite3_create_function*\" routines are the text encoding \n** expected for the second parameter (the name of the function being \n** created) and the presence or absence of a destructor callback for\n** the application data pointer. Function sqlite3_create_window_function()\n** is similar, but allows the user to supply the extra callback functions\n** needed by [aggregate window functions].\n**\n** ^The first parameter is the [database connection] to which the SQL\n** function is to be added.  ^If an application uses more than one database\n** connection then application-defined SQL functions must be added\n** to each database connection separately.\n**\n** ^The second parameter is the name of the SQL function to be created or\n** redefined.  ^The length of the name is limited to 255 bytes in a UTF-8\n** representation, exclusive of the zero-terminator.  ^Note that the name\n** length limit is in UTF-8 bytes, not characters nor UTF-16 bytes.  \n** ^Any attempt to create a function with a longer name\n** will result in [SQLITE_MISUSE] being returned.\n**\n** ^The third parameter (nArg)\n** is the number of arguments that the SQL function or\n** aggregate takes. ^If this parameter is -1, then the SQL function or\n** aggregate may take any number of arguments between 0 and the limit\n** set by [sqlite3_limit]([SQLITE_LIMIT_FUNCTION_ARG]).  If the third\n** parameter is less than -1 or greater than 127 then the behavior is\n** undefined.\n**\n** ^The fourth parameter, eTextRep, specifies what\n** [SQLITE_UTF8 | text encoding] this SQL function prefers for\n** its parameters.  The application should set this parameter to\n** [SQLITE_UTF16LE] if the function implementation invokes \n** [sqlite3_value_text16le()] on an input, or [SQLITE_UTF16BE] if the\n** implementation invokes [sqlite3_value_text16be()] on an input, or\n** [SQLITE_UTF16] if [sqlite3_value_text16()] is used, or [SQLITE_UTF8]\n** otherwise.  ^The same SQL function may be registered multiple times using\n** different preferred text encodings, with different implementations for\n** each encoding.\n** ^When multiple implementations of the same function are available, SQLite\n** will pick the one that involves the least amount of data conversion.\n**\n** ^The fourth parameter may optionally be ORed with [SQLITE_DETERMINISTIC]\n** to signal that the function will always return the same result given\n** the same inputs within a single SQL statement.  Most SQL functions are\n** deterministic.  The built-in [random()] SQL function is an example of a\n** function that is not deterministic.  The SQLite query planner is able to\n** perform additional optimizations on deterministic functions, so use\n** of the [SQLITE_DETERMINISTIC] flag is recommended where possible.\n**\n** ^(The fifth parameter is an arbitrary pointer.  The implementation of the\n** function can gain access to this pointer using [sqlite3_user_data()].)^\n**\n** ^The sixth, seventh and eighth parameters passed to the three\n** \"sqlite3_create_function*\" functions, xFunc, xStep and xFinal, are\n** pointers to C-language functions that implement the SQL function or\n** aggregate. ^A scalar SQL function requires an implementation of the xFunc\n** callback only; NULL pointers must be passed as the xStep and xFinal\n** parameters. ^An aggregate SQL function requires an implementation of xStep\n** and xFinal and NULL pointer must be passed for xFunc. ^To delete an existing\n** SQL function or aggregate, pass NULL pointers for all three function\n** callbacks.\n**\n** ^The sixth, seventh, eighth and ninth parameters (xStep, xFinal, xValue \n** and xInverse) passed to sqlite3_create_window_function are pointers to\n** C-language callbacks that implement the new function. xStep and xFinal\n** must both be non-NULL. xValue and xInverse may either both be NULL, in\n** which case a regular aggregate function is created, or must both be \n** non-NULL, in which case the new function may be used as either an aggregate\n** or aggregate window function. More details regarding the implementation\n** of aggregate window functions are \n** [user-defined window functions|available here].\n**\n** ^(If the final parameter to sqlite3_create_function_v2() or\n** sqlite3_create_window_function() is not NULL, then it is destructor for\n** the application data pointer. The destructor is invoked when the function \n** is deleted, either by being overloaded or when the database connection \n** closes.)^ ^The destructor is also invoked if the call to \n** sqlite3_create_function_v2() fails.  ^When the destructor callback is\n** invoked, it is passed a single argument which is a copy of the application\n** data pointer which was the fifth parameter to sqlite3_create_function_v2().\n**\n** ^It is permitted to register multiple implementations of the same\n** functions with the same name but with either differing numbers of\n** arguments or differing preferred text encodings.  ^SQLite will use\n** the implementation that most closely matches the way in which the\n** SQL function is used.  ^A function implementation with a non-negative\n** nArg parameter is a better match than a function implementation with\n** a negative nArg.  ^A function where the preferred text encoding\n** matches the database encoding is a better\n** match than a function where the encoding is different.  \n** ^A function where the encoding difference is between UTF16le and UTF16be\n** is a closer match than a function where the encoding difference is\n** between UTF8 and UTF16.\n**\n** ^Built-in functions may be overloaded by new application-defined functions.\n**\n** ^An application-defined function is permitted to call other\n** SQLite interfaces.  However, such calls must not\n** close the database connection nor finalize or reset the prepared\n** statement in which the function is running.\n*/\nSQLITE_API int sqlite3_create_function(\n  sqlite3 *db,\n  const char *zFunctionName,\n  int nArg,\n  int eTextRep,\n  void *pApp,\n  void (*xFunc)(sqlite3_context*,int,sqlite3_value**),\n  void (*xStep)(sqlite3_context*,int,sqlite3_value**),\n  void (*xFinal)(sqlite3_context*)\n);\nSQLITE_API int sqlite3_create_function16(\n  sqlite3 *db,\n  const void *zFunctionName,\n  int nArg,\n  int eTextRep,\n  void *pApp,\n  void (*xFunc)(sqlite3_context*,int,sqlite3_value**),\n  void (*xStep)(sqlite3_context*,int,sqlite3_value**),\n  void (*xFinal)(sqlite3_context*)\n);\nSQLITE_API int sqlite3_create_function_v2(\n  sqlite3 *db,\n  const char *zFunctionName,\n  int nArg,\n  int eTextRep,\n  void *pApp,\n  void (*xFunc)(sqlite3_context*,int,sqlite3_value**),\n  void (*xStep)(sqlite3_context*,int,sqlite3_value**),\n  void (*xFinal)(sqlite3_context*),\n  void(*xDestroy)(void*)\n);\nSQLITE_API int sqlite3_create_window_function(\n  sqlite3 *db,\n  const char *zFunctionName,\n  int nArg,\n  int eTextRep,\n  void *pApp,\n  void (*xStep)(sqlite3_context*,int,sqlite3_value**),\n  void (*xFinal)(sqlite3_context*),\n  void (*xValue)(sqlite3_context*),\n  void (*xInverse)(sqlite3_context*,int,sqlite3_value**),\n  void(*xDestroy)(void*)\n);\n\n/*\n** CAPI3REF: Text Encodings\n**\n** These constant define integer codes that represent the various\n** text encodings supported by SQLite.\n*/\n#define SQLITE_UTF8           1    /* IMP: R-37514-35566 */\n#define SQLITE_UTF16LE        2    /* IMP: R-03371-37637 */\n#define SQLITE_UTF16BE        3    /* IMP: R-51971-34154 */\n#define SQLITE_UTF16          4    /* Use native byte order */\n#define SQLITE_ANY            5    /* Deprecated */\n#define SQLITE_UTF16_ALIGNED  8    /* sqlite3_create_collation only */\n\n/*\n** CAPI3REF: Function Flags\n**\n** These constants may be ORed together with the \n** [SQLITE_UTF8 | preferred text encoding] as the fourth argument\n** to [sqlite3_create_function()], [sqlite3_create_function16()], or\n** [sqlite3_create_function_v2()].\n*/\n#define SQLITE_DETERMINISTIC    0x800\n\n/*\n** CAPI3REF: Deprecated Functions\n** DEPRECATED\n**\n** These functions are [deprecated].  In order to maintain\n** backwards compatibility with older code, these functions continue \n** to be supported.  However, new applications should avoid\n** the use of these functions.  To encourage programmers to avoid\n** these functions, we will not explain what they do.\n*/\n#ifndef SQLITE_OMIT_DEPRECATED\nSQLITE_API SQLITE_DEPRECATED int sqlite3_aggregate_count(sqlite3_context*);\nSQLITE_API SQLITE_DEPRECATED int sqlite3_expired(sqlite3_stmt*);\nSQLITE_API SQLITE_DEPRECATED int sqlite3_transfer_bindings(sqlite3_stmt*, sqlite3_stmt*);\nSQLITE_API SQLITE_DEPRECATED int sqlite3_global_recover(void);\nSQLITE_API SQLITE_DEPRECATED void sqlite3_thread_cleanup(void);\nSQLITE_API SQLITE_DEPRECATED int sqlite3_memory_alarm(void(*)(void*,sqlite3_int64,int),\n                      void*,sqlite3_int64);\n#endif\n\n/*\n** CAPI3REF: Obtaining SQL Values\n** METHOD: sqlite3_value\n**\n** <b>Summary:</b>\n** <blockquote><table border=0 cellpadding=0 cellspacing=0>\n** <tr><td><b>sqlite3_value_blob</b><td>&rarr;<td>BLOB value\n** <tr><td><b>sqlite3_value_double</b><td>&rarr;<td>REAL value\n** <tr><td><b>sqlite3_value_int</b><td>&rarr;<td>32-bit INTEGER value\n** <tr><td><b>sqlite3_value_int64</b><td>&rarr;<td>64-bit INTEGER value\n** <tr><td><b>sqlite3_value_pointer</b><td>&rarr;<td>Pointer value\n** <tr><td><b>sqlite3_value_text</b><td>&rarr;<td>UTF-8 TEXT value\n** <tr><td><b>sqlite3_value_text16</b><td>&rarr;<td>UTF-16 TEXT value in\n** the native byteorder\n** <tr><td><b>sqlite3_value_text16be</b><td>&rarr;<td>UTF-16be TEXT value\n** <tr><td><b>sqlite3_value_text16le</b><td>&rarr;<td>UTF-16le TEXT value\n** <tr><td>&nbsp;<td>&nbsp;<td>&nbsp;\n** <tr><td><b>sqlite3_value_bytes</b><td>&rarr;<td>Size of a BLOB\n** or a UTF-8 TEXT in bytes\n** <tr><td><b>sqlite3_value_bytes16&nbsp;&nbsp;</b>\n** <td>&rarr;&nbsp;&nbsp;<td>Size of UTF-16\n** TEXT in bytes\n** <tr><td><b>sqlite3_value_type</b><td>&rarr;<td>Default\n** datatype of the value\n** <tr><td><b>sqlite3_value_numeric_type&nbsp;&nbsp;</b>\n** <td>&rarr;&nbsp;&nbsp;<td>Best numeric datatype of the value\n** <tr><td><b>sqlite3_value_nochange&nbsp;&nbsp;</b>\n** <td>&rarr;&nbsp;&nbsp;<td>True if the column is unchanged in an UPDATE\n** against a virtual table.\n** </table></blockquote>\n**\n** <b>Details:</b>\n**\n** These routines extract type, size, and content information from\n** [protected sqlite3_value] objects.  Protected sqlite3_value objects\n** are used to pass parameter information into implementation of\n** [application-defined SQL functions] and [virtual tables].\n**\n** These routines work only with [protected sqlite3_value] objects.\n** Any attempt to use these routines on an [unprotected sqlite3_value]\n** is not threadsafe.\n**\n** ^These routines work just like the corresponding [column access functions]\n** except that these routines take a single [protected sqlite3_value] object\n** pointer instead of a [sqlite3_stmt*] pointer and an integer column number.\n**\n** ^The sqlite3_value_text16() interface extracts a UTF-16 string\n** in the native byte-order of the host machine.  ^The\n** sqlite3_value_text16be() and sqlite3_value_text16le() interfaces\n** extract UTF-16 strings as big-endian and little-endian respectively.\n**\n** ^If [sqlite3_value] object V was initialized \n** using [sqlite3_bind_pointer(S,I,P,X,D)] or [sqlite3_result_pointer(C,P,X,D)]\n** and if X and Y are strings that compare equal according to strcmp(X,Y),\n** then sqlite3_value_pointer(V,Y) will return the pointer P.  ^Otherwise,\n** sqlite3_value_pointer(V,Y) returns a NULL. The sqlite3_bind_pointer() \n** routine is part of the [pointer passing interface] added for SQLite 3.20.0.\n**\n** ^(The sqlite3_value_type(V) interface returns the\n** [SQLITE_INTEGER | datatype code] for the initial datatype of the\n** [sqlite3_value] object V. The returned value is one of [SQLITE_INTEGER],\n** [SQLITE_FLOAT], [SQLITE_TEXT], [SQLITE_BLOB], or [SQLITE_NULL].)^\n** Other interfaces might change the datatype for an sqlite3_value object.\n** For example, if the datatype is initially SQLITE_INTEGER and\n** sqlite3_value_text(V) is called to extract a text value for that\n** integer, then subsequent calls to sqlite3_value_type(V) might return\n** SQLITE_TEXT.  Whether or not a persistent internal datatype conversion\n** occurs is undefined and may change from one release of SQLite to the next.\n**\n** ^(The sqlite3_value_numeric_type() interface attempts to apply\n** numeric affinity to the value.  This means that an attempt is\n** made to convert the value to an integer or floating point.  If\n** such a conversion is possible without loss of information (in other\n** words, if the value is a string that looks like a number)\n** then the conversion is performed.  Otherwise no conversion occurs.\n** The [SQLITE_INTEGER | datatype] after conversion is returned.)^\n**\n** ^Within the [xUpdate] method of a [virtual table], the\n** sqlite3_value_nochange(X) interface returns true if and only if\n** the column corresponding to X is unchanged by the UPDATE operation\n** that the xUpdate method call was invoked to implement and if\n** and the prior [xColumn] method call that was invoked to extracted\n** the value for that column returned without setting a result (probably\n** because it queried [sqlite3_vtab_nochange()] and found that the column\n** was unchanging).  ^Within an [xUpdate] method, any value for which\n** sqlite3_value_nochange(X) is true will in all other respects appear\n** to be a NULL value.  If sqlite3_value_nochange(X) is invoked anywhere other\n** than within an [xUpdate] method call for an UPDATE statement, then\n** the return value is arbitrary and meaningless.\n**\n** Please pay particular attention to the fact that the pointer returned\n** from [sqlite3_value_blob()], [sqlite3_value_text()], or\n** [sqlite3_value_text16()] can be invalidated by a subsequent call to\n** [sqlite3_value_bytes()], [sqlite3_value_bytes16()], [sqlite3_value_text()],\n** or [sqlite3_value_text16()].\n**\n** These routines must be called from the same thread as\n** the SQL function that supplied the [sqlite3_value*] parameters.\n**\n** As long as the input parameter is correct, these routines can only\n** fail if an out-of-memory error occurs during a format conversion.\n** Only the following subset of interfaces are subject to out-of-memory\n** errors:\n**\n** <ul>\n** <li> sqlite3_value_blob()\n** <li> sqlite3_value_text()\n** <li> sqlite3_value_text16()\n** <li> sqlite3_value_text16le()\n** <li> sqlite3_value_text16be()\n** <li> sqlite3_value_bytes()\n** <li> sqlite3_value_bytes16()\n** </ul>\n**\n** If an out-of-memory error occurs, then the return value from these\n** routines is the same as if the column had contained an SQL NULL value.\n** Valid SQL NULL returns can be distinguished from out-of-memory errors\n** by invoking the [sqlite3_errcode()] immediately after the suspect\n** return value is obtained and before any\n** other SQLite interface is called on the same [database connection].\n*/\nSQLITE_API const void *sqlite3_value_blob(sqlite3_value*);\nSQLITE_API double sqlite3_value_double(sqlite3_value*);\nSQLITE_API int sqlite3_value_int(sqlite3_value*);\nSQLITE_API sqlite3_int64 sqlite3_value_int64(sqlite3_value*);\nSQLITE_API void *sqlite3_value_pointer(sqlite3_value*, const char*);\nSQLITE_API const unsigned char *sqlite3_value_text(sqlite3_value*);\nSQLITE_API const void *sqlite3_value_text16(sqlite3_value*);\nSQLITE_API const void *sqlite3_value_text16le(sqlite3_value*);\nSQLITE_API const void *sqlite3_value_text16be(sqlite3_value*);\nSQLITE_API int sqlite3_value_bytes(sqlite3_value*);\nSQLITE_API int sqlite3_value_bytes16(sqlite3_value*);\nSQLITE_API int sqlite3_value_type(sqlite3_value*);\nSQLITE_API int sqlite3_value_numeric_type(sqlite3_value*);\nSQLITE_API int sqlite3_value_nochange(sqlite3_value*);\n\n/*\n** CAPI3REF: Finding The Subtype Of SQL Values\n** METHOD: sqlite3_value\n**\n** The sqlite3_value_subtype(V) function returns the subtype for\n** an [application-defined SQL function] argument V.  The subtype\n** information can be used to pass a limited amount of context from\n** one SQL function to another.  Use the [sqlite3_result_subtype()]\n** routine to set the subtype for the return value of an SQL function.\n*/\nSQLITE_API unsigned int sqlite3_value_subtype(sqlite3_value*);\n\n/*\n** CAPI3REF: Copy And Free SQL Values\n** METHOD: sqlite3_value\n**\n** ^The sqlite3_value_dup(V) interface makes a copy of the [sqlite3_value]\n** object D and returns a pointer to that copy.  ^The [sqlite3_value] returned\n** is a [protected sqlite3_value] object even if the input is not.\n** ^The sqlite3_value_dup(V) interface returns NULL if V is NULL or if a\n** memory allocation fails.\n**\n** ^The sqlite3_value_free(V) interface frees an [sqlite3_value] object\n** previously obtained from [sqlite3_value_dup()].  ^If V is a NULL pointer\n** then sqlite3_value_free(V) is a harmless no-op.\n*/\nSQLITE_API sqlite3_value *sqlite3_value_dup(const sqlite3_value*);\nSQLITE_API void sqlite3_value_free(sqlite3_value*);\n\n/*\n** CAPI3REF: Obtain Aggregate Function Context\n** METHOD: sqlite3_context\n**\n** Implementations of aggregate SQL functions use this\n** routine to allocate memory for storing their state.\n**\n** ^The first time the sqlite3_aggregate_context(C,N) routine is called \n** for a particular aggregate function, SQLite\n** allocates N of memory, zeroes out that memory, and returns a pointer\n** to the new memory. ^On second and subsequent calls to\n** sqlite3_aggregate_context() for the same aggregate function instance,\n** the same buffer is returned.  Sqlite3_aggregate_context() is normally\n** called once for each invocation of the xStep callback and then one\n** last time when the xFinal callback is invoked.  ^(When no rows match\n** an aggregate query, the xStep() callback of the aggregate function\n** implementation is never called and xFinal() is called exactly once.\n** In those cases, sqlite3_aggregate_context() might be called for the\n** first time from within xFinal().)^\n**\n** ^The sqlite3_aggregate_context(C,N) routine returns a NULL pointer \n** when first called if N is less than or equal to zero or if a memory\n** allocate error occurs.\n**\n** ^(The amount of space allocated by sqlite3_aggregate_context(C,N) is\n** determined by the N parameter on first successful call.  Changing the\n** value of N in subsequent call to sqlite3_aggregate_context() within\n** the same aggregate function instance will not resize the memory\n** allocation.)^  Within the xFinal callback, it is customary to set\n** N=0 in calls to sqlite3_aggregate_context(C,N) so that no \n** pointless memory allocations occur.\n**\n** ^SQLite automatically frees the memory allocated by \n** sqlite3_aggregate_context() when the aggregate query concludes.\n**\n** The first parameter must be a copy of the\n** [sqlite3_context | SQL function context] that is the first parameter\n** to the xStep or xFinal callback routine that implements the aggregate\n** function.\n**\n** This routine must be called from the same thread in which\n** the aggregate SQL function is running.\n*/\nSQLITE_API void *sqlite3_aggregate_context(sqlite3_context*, int nBytes);\n\n/*\n** CAPI3REF: User Data For Functions\n** METHOD: sqlite3_context\n**\n** ^The sqlite3_user_data() interface returns a copy of\n** the pointer that was the pUserData parameter (the 5th parameter)\n** of the [sqlite3_create_function()]\n** and [sqlite3_create_function16()] routines that originally\n** registered the application defined function.\n**\n** This routine must be called from the same thread in which\n** the application-defined function is running.\n*/\nSQLITE_API void *sqlite3_user_data(sqlite3_context*);\n\n/*\n** CAPI3REF: Database Connection For Functions\n** METHOD: sqlite3_context\n**\n** ^The sqlite3_context_db_handle() interface returns a copy of\n** the pointer to the [database connection] (the 1st parameter)\n** of the [sqlite3_create_function()]\n** and [sqlite3_create_function16()] routines that originally\n** registered the application defined function.\n*/\nSQLITE_API sqlite3 *sqlite3_context_db_handle(sqlite3_context*);\n\n/*\n** CAPI3REF: Function Auxiliary Data\n** METHOD: sqlite3_context\n**\n** These functions may be used by (non-aggregate) SQL functions to\n** associate metadata with argument values. If the same value is passed to\n** multiple invocations of the same SQL function during query execution, under\n** some circumstances the associated metadata may be preserved.  An example\n** of where this might be useful is in a regular-expression matching\n** function. The compiled version of the regular expression can be stored as\n** metadata associated with the pattern string.  \n** Then as long as the pattern string remains the same,\n** the compiled regular expression can be reused on multiple\n** invocations of the same function.\n**\n** ^The sqlite3_get_auxdata(C,N) interface returns a pointer to the metadata\n** associated by the sqlite3_set_auxdata(C,N,P,X) function with the Nth argument\n** value to the application-defined function.  ^N is zero for the left-most\n** function argument.  ^If there is no metadata\n** associated with the function argument, the sqlite3_get_auxdata(C,N) interface\n** returns a NULL pointer.\n**\n** ^The sqlite3_set_auxdata(C,N,P,X) interface saves P as metadata for the N-th\n** argument of the application-defined function.  ^Subsequent\n** calls to sqlite3_get_auxdata(C,N) return P from the most recent\n** sqlite3_set_auxdata(C,N,P,X) call if the metadata is still valid or\n** NULL if the metadata has been discarded.\n** ^After each call to sqlite3_set_auxdata(C,N,P,X) where X is not NULL,\n** SQLite will invoke the destructor function X with parameter P exactly\n** once, when the metadata is discarded.\n** SQLite is free to discard the metadata at any time, including: <ul>\n** <li> ^(when the corresponding function parameter changes)^, or\n** <li> ^(when [sqlite3_reset()] or [sqlite3_finalize()] is called for the\n**      SQL statement)^, or\n** <li> ^(when sqlite3_set_auxdata() is invoked again on the same\n**       parameter)^, or\n** <li> ^(during the original sqlite3_set_auxdata() call when a memory \n**      allocation error occurs.)^ </ul>\n**\n** Note the last bullet in particular.  The destructor X in \n** sqlite3_set_auxdata(C,N,P,X) might be called immediately, before the\n** sqlite3_set_auxdata() interface even returns.  Hence sqlite3_set_auxdata()\n** should be called near the end of the function implementation and the\n** function implementation should not make any use of P after\n** sqlite3_set_auxdata() has been called.\n**\n** ^(In practice, metadata is preserved between function calls for\n** function parameters that are compile-time constants, including literal\n** values and [parameters] and expressions composed from the same.)^\n**\n** The value of the N parameter to these interfaces should be non-negative.\n** Future enhancements may make use of negative N values to define new\n** kinds of function caching behavior.\n**\n** These routines must be called from the same thread in which\n** the SQL function is running.\n*/\nSQLITE_API void *sqlite3_get_auxdata(sqlite3_context*, int N);\nSQLITE_API void sqlite3_set_auxdata(sqlite3_context*, int N, void*, void (*)(void*));\n\n\n/*\n** CAPI3REF: Constants Defining Special Destructor Behavior\n**\n** These are special values for the destructor that is passed in as the\n** final argument to routines like [sqlite3_result_blob()].  ^If the destructor\n** argument is SQLITE_STATIC, it means that the content pointer is constant\n** and will never change.  It does not need to be destroyed.  ^The\n** SQLITE_TRANSIENT value means that the content will likely change in\n** the near future and that SQLite should make its own private copy of\n** the content before returning.\n**\n** The typedef is necessary to work around problems in certain\n** C++ compilers.\n*/\ntypedef void (*sqlite3_destructor_type)(void*);\n#define SQLITE_STATIC      ((sqlite3_destructor_type)0)\n#define SQLITE_TRANSIENT   ((sqlite3_destructor_type)-1)\n\n/*\n** CAPI3REF: Setting The Result Of An SQL Function\n** METHOD: sqlite3_context\n**\n** These routines are used by the xFunc or xFinal callbacks that\n** implement SQL functions and aggregates.  See\n** [sqlite3_create_function()] and [sqlite3_create_function16()]\n** for additional information.\n**\n** These functions work very much like the [parameter binding] family of\n** functions used to bind values to host parameters in prepared statements.\n** Refer to the [SQL parameter] documentation for additional information.\n**\n** ^The sqlite3_result_blob() interface sets the result from\n** an application-defined function to be the BLOB whose content is pointed\n** to by the second parameter and which is N bytes long where N is the\n** third parameter.\n**\n** ^The sqlite3_result_zeroblob(C,N) and sqlite3_result_zeroblob64(C,N)\n** interfaces set the result of the application-defined function to be\n** a BLOB containing all zero bytes and N bytes in size.\n**\n** ^The sqlite3_result_double() interface sets the result from\n** an application-defined function to be a floating point value specified\n** by its 2nd argument.\n**\n** ^The sqlite3_result_error() and sqlite3_result_error16() functions\n** cause the implemented SQL function to throw an exception.\n** ^SQLite uses the string pointed to by the\n** 2nd parameter of sqlite3_result_error() or sqlite3_result_error16()\n** as the text of an error message.  ^SQLite interprets the error\n** message string from sqlite3_result_error() as UTF-8. ^SQLite\n** interprets the string from sqlite3_result_error16() as UTF-16 in native\n** byte order.  ^If the third parameter to sqlite3_result_error()\n** or sqlite3_result_error16() is negative then SQLite takes as the error\n** message all text up through the first zero character.\n** ^If the third parameter to sqlite3_result_error() or\n** sqlite3_result_error16() is non-negative then SQLite takes that many\n** bytes (not characters) from the 2nd parameter as the error message.\n** ^The sqlite3_result_error() and sqlite3_result_error16()\n** routines make a private copy of the error message text before\n** they return.  Hence, the calling function can deallocate or\n** modify the text after they return without harm.\n** ^The sqlite3_result_error_code() function changes the error code\n** returned by SQLite as a result of an error in a function.  ^By default,\n** the error code is SQLITE_ERROR.  ^A subsequent call to sqlite3_result_error()\n** or sqlite3_result_error16() resets the error code to SQLITE_ERROR.\n**\n** ^The sqlite3_result_error_toobig() interface causes SQLite to throw an\n** error indicating that a string or BLOB is too long to represent.\n**\n** ^The sqlite3_result_error_nomem() interface causes SQLite to throw an\n** error indicating that a memory allocation failed.\n**\n** ^The sqlite3_result_int() interface sets the return value\n** of the application-defined function to be the 32-bit signed integer\n** value given in the 2nd argument.\n** ^The sqlite3_result_int64() interface sets the return value\n** of the application-defined function to be the 64-bit signed integer\n** value given in the 2nd argument.\n**\n** ^The sqlite3_result_null() interface sets the return value\n** of the application-defined function to be NULL.\n**\n** ^The sqlite3_result_text(), sqlite3_result_text16(),\n** sqlite3_result_text16le(), and sqlite3_result_text16be() interfaces\n** set the return value of the application-defined function to be\n** a text string which is represented as UTF-8, UTF-16 native byte order,\n** UTF-16 little endian, or UTF-16 big endian, respectively.\n** ^The sqlite3_result_text64() interface sets the return value of an\n** application-defined function to be a text string in an encoding\n** specified by the fifth (and last) parameter, which must be one\n** of [SQLITE_UTF8], [SQLITE_UTF16], [SQLITE_UTF16BE], or [SQLITE_UTF16LE].\n** ^SQLite takes the text result from the application from\n** the 2nd parameter of the sqlite3_result_text* interfaces.\n** ^If the 3rd parameter to the sqlite3_result_text* interfaces\n** is negative, then SQLite takes result text from the 2nd parameter\n** through the first zero character.\n** ^If the 3rd parameter to the sqlite3_result_text* interfaces\n** is non-negative, then as many bytes (not characters) of the text\n** pointed to by the 2nd parameter are taken as the application-defined\n** function result.  If the 3rd parameter is non-negative, then it\n** must be the byte offset into the string where the NUL terminator would\n** appear if the string where NUL terminated.  If any NUL characters occur\n** in the string at a byte offset that is less than the value of the 3rd\n** parameter, then the resulting string will contain embedded NULs and the\n** result of expressions operating on strings with embedded NULs is undefined.\n** ^If the 4th parameter to the sqlite3_result_text* interfaces\n** or sqlite3_result_blob is a non-NULL pointer, then SQLite calls that\n** function as the destructor on the text or BLOB result when it has\n** finished using that result.\n** ^If the 4th parameter to the sqlite3_result_text* interfaces or to\n** sqlite3_result_blob is the special constant SQLITE_STATIC, then SQLite\n** assumes that the text or BLOB result is in constant space and does not\n** copy the content of the parameter nor call a destructor on the content\n** when it has finished using that result.\n** ^If the 4th parameter to the sqlite3_result_text* interfaces\n** or sqlite3_result_blob is the special constant SQLITE_TRANSIENT\n** then SQLite makes a copy of the result into space obtained\n** from [sqlite3_malloc()] before it returns.\n**\n** ^The sqlite3_result_value() interface sets the result of\n** the application-defined function to be a copy of the\n** [unprotected sqlite3_value] object specified by the 2nd parameter.  ^The\n** sqlite3_result_value() interface makes a copy of the [sqlite3_value]\n** so that the [sqlite3_value] specified in the parameter may change or\n** be deallocated after sqlite3_result_value() returns without harm.\n** ^A [protected sqlite3_value] object may always be used where an\n** [unprotected sqlite3_value] object is required, so either\n** kind of [sqlite3_value] object can be used with this interface.\n**\n** ^The sqlite3_result_pointer(C,P,T,D) interface sets the result to an\n** SQL NULL value, just like [sqlite3_result_null(C)], except that it\n** also associates the host-language pointer P or type T with that \n** NULL value such that the pointer can be retrieved within an\n** [application-defined SQL function] using [sqlite3_value_pointer()].\n** ^If the D parameter is not NULL, then it is a pointer to a destructor\n** for the P parameter.  ^SQLite invokes D with P as its only argument\n** when SQLite is finished with P.  The T parameter should be a static\n** string and preferably a string literal. The sqlite3_result_pointer()\n** routine is part of the [pointer passing interface] added for SQLite 3.20.0.\n**\n** If these routines are called from within the different thread\n** than the one containing the application-defined function that received\n** the [sqlite3_context] pointer, the results are undefined.\n*/\nSQLITE_API void sqlite3_result_blob(sqlite3_context*, const void*, int, void(*)(void*));\nSQLITE_API void sqlite3_result_blob64(sqlite3_context*,const void*,\n                           sqlite3_uint64,void(*)(void*));\nSQLITE_API void sqlite3_result_double(sqlite3_context*, double);\nSQLITE_API void sqlite3_result_error(sqlite3_context*, const char*, int);\nSQLITE_API void sqlite3_result_error16(sqlite3_context*, const void*, int);\nSQLITE_API void sqlite3_result_error_toobig(sqlite3_context*);\nSQLITE_API void sqlite3_result_error_nomem(sqlite3_context*);\nSQLITE_API void sqlite3_result_error_code(sqlite3_context*, int);\nSQLITE_API void sqlite3_result_int(sqlite3_context*, int);\nSQLITE_API void sqlite3_result_int64(sqlite3_context*, sqlite3_int64);\nSQLITE_API void sqlite3_result_null(sqlite3_context*);\nSQLITE_API void sqlite3_result_text(sqlite3_context*, const char*, int, void(*)(void*));\nSQLITE_API void sqlite3_result_text64(sqlite3_context*, const char*,sqlite3_uint64,\n                           void(*)(void*), unsigned char encoding);\nSQLITE_API void sqlite3_result_text16(sqlite3_context*, const void*, int, void(*)(void*));\nSQLITE_API void sqlite3_result_text16le(sqlite3_context*, const void*, int,void(*)(void*));\nSQLITE_API void sqlite3_result_text16be(sqlite3_context*, const void*, int,void(*)(void*));\nSQLITE_API void sqlite3_result_value(sqlite3_context*, sqlite3_value*);\nSQLITE_API void sqlite3_result_pointer(sqlite3_context*, void*,const char*,void(*)(void*));\nSQLITE_API void sqlite3_result_zeroblob(sqlite3_context*, int n);\nSQLITE_API int sqlite3_result_zeroblob64(sqlite3_context*, sqlite3_uint64 n);\n\n\n/*\n** CAPI3REF: Setting The Subtype Of An SQL Function\n** METHOD: sqlite3_context\n**\n** The sqlite3_result_subtype(C,T) function causes the subtype of\n** the result from the [application-defined SQL function] with \n** [sqlite3_context] C to be the value T.  Only the lower 8 bits \n** of the subtype T are preserved in current versions of SQLite;\n** higher order bits are discarded.\n** The number of subtype bytes preserved by SQLite might increase\n** in future releases of SQLite.\n*/\nSQLITE_API void sqlite3_result_subtype(sqlite3_context*,unsigned int);\n\n/*\n** CAPI3REF: Define New Collating Sequences\n** METHOD: sqlite3\n**\n** ^These functions add, remove, or modify a [collation] associated\n** with the [database connection] specified as the first argument.\n**\n** ^The name of the collation is a UTF-8 string\n** for sqlite3_create_collation() and sqlite3_create_collation_v2()\n** and a UTF-16 string in native byte order for sqlite3_create_collation16().\n** ^Collation names that compare equal according to [sqlite3_strnicmp()] are\n** considered to be the same name.\n**\n** ^(The third argument (eTextRep) must be one of the constants:\n** <ul>\n** <li> [SQLITE_UTF8],\n** <li> [SQLITE_UTF16LE],\n** <li> [SQLITE_UTF16BE],\n** <li> [SQLITE_UTF16], or\n** <li> [SQLITE_UTF16_ALIGNED].\n** </ul>)^\n** ^The eTextRep argument determines the encoding of strings passed\n** to the collating function callback, xCallback.\n** ^The [SQLITE_UTF16] and [SQLITE_UTF16_ALIGNED] values for eTextRep\n** force strings to be UTF16 with native byte order.\n** ^The [SQLITE_UTF16_ALIGNED] value for eTextRep forces strings to begin\n** on an even byte address.\n**\n** ^The fourth argument, pArg, is an application data pointer that is passed\n** through as the first argument to the collating function callback.\n**\n** ^The fifth argument, xCallback, is a pointer to the collating function.\n** ^Multiple collating functions can be registered using the same name but\n** with different eTextRep parameters and SQLite will use whichever\n** function requires the least amount of data transformation.\n** ^If the xCallback argument is NULL then the collating function is\n** deleted.  ^When all collating functions having the same name are deleted,\n** that collation is no longer usable.\n**\n** ^The collating function callback is invoked with a copy of the pArg \n** application data pointer and with two strings in the encoding specified\n** by the eTextRep argument.  The collating function must return an\n** integer that is negative, zero, or positive\n** if the first string is less than, equal to, or greater than the second,\n** respectively.  A collating function must always return the same answer\n** given the same inputs.  If two or more collating functions are registered\n** to the same collation name (using different eTextRep values) then all\n** must give an equivalent answer when invoked with equivalent strings.\n** The collating function must obey the following properties for all\n** strings A, B, and C:\n**\n** <ol>\n** <li> If A==B then B==A.\n** <li> If A==B and B==C then A==C.\n** <li> If A&lt;B THEN B&gt;A.\n** <li> If A&lt;B and B&lt;C then A&lt;C.\n** </ol>\n**\n** If a collating function fails any of the above constraints and that\n** collating function is  registered and used, then the behavior of SQLite\n** is undefined.\n**\n** ^The sqlite3_create_collation_v2() works like sqlite3_create_collation()\n** with the addition that the xDestroy callback is invoked on pArg when\n** the collating function is deleted.\n** ^Collating functions are deleted when they are overridden by later\n** calls to the collation creation functions or when the\n** [database connection] is closed using [sqlite3_close()].\n**\n** ^The xDestroy callback is <u>not</u> called if the \n** sqlite3_create_collation_v2() function fails.  Applications that invoke\n** sqlite3_create_collation_v2() with a non-NULL xDestroy argument should \n** check the return code and dispose of the application data pointer\n** themselves rather than expecting SQLite to deal with it for them.\n** This is different from every other SQLite interface.  The inconsistency \n** is unfortunate but cannot be changed without breaking backwards \n** compatibility.\n**\n** See also:  [sqlite3_collation_needed()] and [sqlite3_collation_needed16()].\n*/\nSQLITE_API int sqlite3_create_collation(\n  sqlite3*, \n  const char *zName, \n  int eTextRep, \n  void *pArg,\n  int(*xCompare)(void*,int,const void*,int,const void*)\n);\nSQLITE_API int sqlite3_create_collation_v2(\n  sqlite3*, \n  const char *zName, \n  int eTextRep, \n  void *pArg,\n  int(*xCompare)(void*,int,const void*,int,const void*),\n  void(*xDestroy)(void*)\n);\nSQLITE_API int sqlite3_create_collation16(\n  sqlite3*, \n  const void *zName,\n  int eTextRep, \n  void *pArg,\n  int(*xCompare)(void*,int,const void*,int,const void*)\n);\n\n/*\n** CAPI3REF: Collation Needed Callbacks\n** METHOD: sqlite3\n**\n** ^To avoid having to register all collation sequences before a database\n** can be used, a single callback function may be registered with the\n** [database connection] to be invoked whenever an undefined collation\n** sequence is required.\n**\n** ^If the function is registered using the sqlite3_collation_needed() API,\n** then it is passed the names of undefined collation sequences as strings\n** encoded in UTF-8. ^If sqlite3_collation_needed16() is used,\n** the names are passed as UTF-16 in machine native byte order.\n** ^A call to either function replaces the existing collation-needed callback.\n**\n** ^(When the callback is invoked, the first argument passed is a copy\n** of the second argument to sqlite3_collation_needed() or\n** sqlite3_collation_needed16().  The second argument is the database\n** connection.  The third argument is one of [SQLITE_UTF8], [SQLITE_UTF16BE],\n** or [SQLITE_UTF16LE], indicating the most desirable form of the collation\n** sequence function required.  The fourth parameter is the name of the\n** required collation sequence.)^\n**\n** The callback function should register the desired collation using\n** [sqlite3_create_collation()], [sqlite3_create_collation16()], or\n** [sqlite3_create_collation_v2()].\n*/\nSQLITE_API int sqlite3_collation_needed(\n  sqlite3*, \n  void*, \n  void(*)(void*,sqlite3*,int eTextRep,const char*)\n);\nSQLITE_API int sqlite3_collation_needed16(\n  sqlite3*, \n  void*,\n  void(*)(void*,sqlite3*,int eTextRep,const void*)\n);\n\n#ifdef SQLITE_HAS_CODEC\n/*\n** Specify the key for an encrypted database.  This routine should be\n** called right after sqlite3_open().\n**\n** The code to implement this API is not available in the public release\n** of SQLite.\n*/\nSQLITE_API int sqlite3_key(\n  sqlite3 *db,                   /* Database to be rekeyed */\n  const void *pKey, int nKey     /* The key */\n);\nSQLITE_API int sqlite3_key_v2(\n  sqlite3 *db,                   /* Database to be rekeyed */\n  const char *zDbName,           /* Name of the database */\n  const void *pKey, int nKey     /* The key */\n);\n\n/*\n** Change the key on an open database.  If the current database is not\n** encrypted, this routine will encrypt it.  If pNew==0 or nNew==0, the\n** database is decrypted.\n**\n** The code to implement this API is not available in the public release\n** of SQLite.\n*/\n/* BEGIN SQLCIPHER\n   SQLCipher usage note:\n\n   If the current database is plaintext SQLCipher will NOT encrypt it.\n   If the current database is encrypted and pNew==0 or nNew==0, SQLCipher\n   will NOT decrypt it.\n\n   This routine will ONLY work on an already encrypted database in order\n   to change the key.\n\n   Conversion from plaintext-to-encrypted or encrypted-to-plaintext should\n   use an ATTACHed database and the sqlcipher_export() convenience function\n   as per the SQLCipher Documentation.\n\n   END SQLCIPHER\n*/\nSQLITE_API int sqlite3_rekey(\n  sqlite3 *db,                   /* Database to be rekeyed */\n  const void *pKey, int nKey     /* The new key */\n);\nSQLITE_API int sqlite3_rekey_v2(\n  sqlite3 *db,                   /* Database to be rekeyed */\n  const char *zDbName,           /* Name of the database */\n  const void *pKey, int nKey     /* The new key */\n);\n\n/*\n** Specify the activation key for a SEE database.  Unless \n** activated, none of the SEE routines will work.\n*/\nSQLITE_API void sqlite3_activate_see(\n  const char *zPassPhrase        /* Activation phrase */\n);\n#endif\n\n#ifdef SQLITE_ENABLE_CEROD\n/*\n** Specify the activation key for a CEROD database.  Unless \n** activated, none of the CEROD routines will work.\n*/\nSQLITE_API void sqlite3_activate_cerod(\n  const char *zPassPhrase        /* Activation phrase */\n);\n#endif\n\n/*\n** CAPI3REF: Suspend Execution For A Short Time\n**\n** The sqlite3_sleep() function causes the current thread to suspend execution\n** for at least a number of milliseconds specified in its parameter.\n**\n** If the operating system does not support sleep requests with\n** millisecond time resolution, then the time will be rounded up to\n** the nearest second. The number of milliseconds of sleep actually\n** requested from the operating system is returned.\n**\n** ^SQLite implements this interface by calling the xSleep()\n** method of the default [sqlite3_vfs] object.  If the xSleep() method\n** of the default VFS is not implemented correctly, or not implemented at\n** all, then the behavior of sqlite3_sleep() may deviate from the description\n** in the previous paragraphs.\n*/\nSQLITE_API int sqlite3_sleep(int);\n\n/*\n** CAPI3REF: Name Of The Folder Holding Temporary Files\n**\n** ^(If this global variable is made to point to a string which is\n** the name of a folder (a.k.a. directory), then all temporary files\n** created by SQLite when using a built-in [sqlite3_vfs | VFS]\n** will be placed in that directory.)^  ^If this variable\n** is a NULL pointer, then SQLite performs a search for an appropriate\n** temporary file directory.\n**\n** Applications are strongly discouraged from using this global variable.\n** It is required to set a temporary folder on Windows Runtime (WinRT).\n** But for all other platforms, it is highly recommended that applications\n** neither read nor write this variable.  This global variable is a relic\n** that exists for backwards compatibility of legacy applications and should\n** be avoided in new projects.\n**\n** It is not safe to read or modify this variable in more than one\n** thread at a time.  It is not safe to read or modify this variable\n** if a [database connection] is being used at the same time in a separate\n** thread.\n** It is intended that this variable be set once\n** as part of process initialization and before any SQLite interface\n** routines have been called and that this variable remain unchanged\n** thereafter.\n**\n** ^The [temp_store_directory pragma] may modify this variable and cause\n** it to point to memory obtained from [sqlite3_malloc].  ^Furthermore,\n** the [temp_store_directory pragma] always assumes that any string\n** that this variable points to is held in memory obtained from \n** [sqlite3_malloc] and the pragma may attempt to free that memory\n** using [sqlite3_free].\n** Hence, if this variable is modified directly, either it should be\n** made NULL or made to point to memory obtained from [sqlite3_malloc]\n** or else the use of the [temp_store_directory pragma] should be avoided.\n** Except when requested by the [temp_store_directory pragma], SQLite\n** does not free the memory that sqlite3_temp_directory points to.  If\n** the application wants that memory to be freed, it must do\n** so itself, taking care to only do so after all [database connection]\n** objects have been destroyed.\n**\n** <b>Note to Windows Runtime users:</b>  The temporary directory must be set\n** prior to calling [sqlite3_open] or [sqlite3_open_v2].  Otherwise, various\n** features that require the use of temporary files may fail.  Here is an\n** example of how to do this using C++ with the Windows Runtime:\n**\n** <blockquote><pre>\n** LPCWSTR zPath = Windows::Storage::ApplicationData::Current->\n** &nbsp;     TemporaryFolder->Path->Data();\n** char zPathBuf&#91;MAX_PATH + 1&#93;;\n** memset(zPathBuf, 0, sizeof(zPathBuf));\n** WideCharToMultiByte(CP_UTF8, 0, zPath, -1, zPathBuf, sizeof(zPathBuf),\n** &nbsp;     NULL, NULL);\n** sqlite3_temp_directory = sqlite3_mprintf(\"%s\", zPathBuf);\n** </pre></blockquote>\n*/\nSQLITE_API char *sqlite3_temp_directory;\n\n/*\n** CAPI3REF: Name Of The Folder Holding Database Files\n**\n** ^(If this global variable is made to point to a string which is\n** the name of a folder (a.k.a. directory), then all database files\n** specified with a relative pathname and created or accessed by\n** SQLite when using a built-in windows [sqlite3_vfs | VFS] will be assumed\n** to be relative to that directory.)^ ^If this variable is a NULL\n** pointer, then SQLite assumes that all database files specified\n** with a relative pathname are relative to the current directory\n** for the process.  Only the windows VFS makes use of this global\n** variable; it is ignored by the unix VFS.\n**\n** Changing the value of this variable while a database connection is\n** open can result in a corrupt database.\n**\n** It is not safe to read or modify this variable in more than one\n** thread at a time.  It is not safe to read or modify this variable\n** if a [database connection] is being used at the same time in a separate\n** thread.\n** It is intended that this variable be set once\n** as part of process initialization and before any SQLite interface\n** routines have been called and that this variable remain unchanged\n** thereafter.\n**\n** ^The [data_store_directory pragma] may modify this variable and cause\n** it to point to memory obtained from [sqlite3_malloc].  ^Furthermore,\n** the [data_store_directory pragma] always assumes that any string\n** that this variable points to is held in memory obtained from \n** [sqlite3_malloc] and the pragma may attempt to free that memory\n** using [sqlite3_free].\n** Hence, if this variable is modified directly, either it should be\n** made NULL or made to point to memory obtained from [sqlite3_malloc]\n** or else the use of the [data_store_directory pragma] should be avoided.\n*/\nSQLITE_API char *sqlite3_data_directory;\n\n/*\n** CAPI3REF: Win32 Specific Interface\n**\n** These interfaces are available only on Windows.  The\n** [sqlite3_win32_set_directory] interface is used to set the value associated\n** with the [sqlite3_temp_directory] or [sqlite3_data_directory] variable, to\n** zValue, depending on the value of the type parameter.  The zValue parameter\n** should be NULL to cause the previous value to be freed via [sqlite3_free];\n** a non-NULL value will be copied into memory obtained from [sqlite3_malloc]\n** prior to being used.  The [sqlite3_win32_set_directory] interface returns\n** [SQLITE_OK] to indicate success, [SQLITE_ERROR] if the type is unsupported,\n** or [SQLITE_NOMEM] if memory could not be allocated.  The value of the\n** [sqlite3_data_directory] variable is intended to act as a replacement for\n** the current directory on the sub-platforms of Win32 where that concept is\n** not present, e.g. WinRT and UWP.  The [sqlite3_win32_set_directory8] and\n** [sqlite3_win32_set_directory16] interfaces behave exactly the same as the\n** sqlite3_win32_set_directory interface except the string parameter must be\n** UTF-8 or UTF-16, respectively.\n*/\nSQLITE_API int sqlite3_win32_set_directory(\n  unsigned long type, /* Identifier for directory being set or reset */\n  void *zValue        /* New value for directory being set or reset */\n);\nSQLITE_API int sqlite3_win32_set_directory8(unsigned long type, const char *zValue);\nSQLITE_API int sqlite3_win32_set_directory16(unsigned long type, const void *zValue);\n\n/*\n** CAPI3REF: Win32 Directory Types\n**\n** These macros are only available on Windows.  They define the allowed values\n** for the type argument to the [sqlite3_win32_set_directory] interface.\n*/\n#define SQLITE_WIN32_DATA_DIRECTORY_TYPE  1\n#define SQLITE_WIN32_TEMP_DIRECTORY_TYPE  2\n\n/*\n** CAPI3REF: Test For Auto-Commit Mode\n** KEYWORDS: {autocommit mode}\n** METHOD: sqlite3\n**\n** ^The sqlite3_get_autocommit() interface returns non-zero or\n** zero if the given database connection is or is not in autocommit mode,\n** respectively.  ^Autocommit mode is on by default.\n** ^Autocommit mode is disabled by a [BEGIN] statement.\n** ^Autocommit mode is re-enabled by a [COMMIT] or [ROLLBACK].\n**\n** If certain kinds of errors occur on a statement within a multi-statement\n** transaction (errors including [SQLITE_FULL], [SQLITE_IOERR],\n** [SQLITE_NOMEM], [SQLITE_BUSY], and [SQLITE_INTERRUPT]) then the\n** transaction might be rolled back automatically.  The only way to\n** find out whether SQLite automatically rolled back the transaction after\n** an error is to use this function.\n**\n** If another thread changes the autocommit status of the database\n** connection while this routine is running, then the return value\n** is undefined.\n*/\nSQLITE_API int sqlite3_get_autocommit(sqlite3*);\n\n/*\n** CAPI3REF: Find The Database Handle Of A Prepared Statement\n** METHOD: sqlite3_stmt\n**\n** ^The sqlite3_db_handle interface returns the [database connection] handle\n** to which a [prepared statement] belongs.  ^The [database connection]\n** returned by sqlite3_db_handle is the same [database connection]\n** that was the first argument\n** to the [sqlite3_prepare_v2()] call (or its variants) that was used to\n** create the statement in the first place.\n*/\nSQLITE_API sqlite3 *sqlite3_db_handle(sqlite3_stmt*);\n\n/*\n** CAPI3REF: Return The Filename For A Database Connection\n** METHOD: sqlite3\n**\n** ^The sqlite3_db_filename(D,N) interface returns a pointer to a filename\n** associated with database N of connection D.  ^The main database file\n** has the name \"main\".  If there is no attached database N on the database\n** connection D, or if database N is a temporary or in-memory database, then\n** a NULL pointer is returned.\n**\n** ^The filename returned by this function is the output of the\n** xFullPathname method of the [VFS].  ^In other words, the filename\n** will be an absolute pathname, even if the filename used\n** to open the database originally was a URI or relative pathname.\n*/\nSQLITE_API const char *sqlite3_db_filename(sqlite3 *db, const char *zDbName);\n\n/*\n** CAPI3REF: Determine if a database is read-only\n** METHOD: sqlite3\n**\n** ^The sqlite3_db_readonly(D,N) interface returns 1 if the database N\n** of connection D is read-only, 0 if it is read/write, or -1 if N is not\n** the name of a database on connection D.\n*/\nSQLITE_API int sqlite3_db_readonly(sqlite3 *db, const char *zDbName);\n\n/*\n** CAPI3REF: Find the next prepared statement\n** METHOD: sqlite3\n**\n** ^This interface returns a pointer to the next [prepared statement] after\n** pStmt associated with the [database connection] pDb.  ^If pStmt is NULL\n** then this interface returns a pointer to the first prepared statement\n** associated with the database connection pDb.  ^If no prepared statement\n** satisfies the conditions of this routine, it returns NULL.\n**\n** The [database connection] pointer D in a call to\n** [sqlite3_next_stmt(D,S)] must refer to an open database\n** connection and in particular must not be a NULL pointer.\n*/\nSQLITE_API sqlite3_stmt *sqlite3_next_stmt(sqlite3 *pDb, sqlite3_stmt *pStmt);\n\n/*\n** CAPI3REF: Commit And Rollback Notification Callbacks\n** METHOD: sqlite3\n**\n** ^The sqlite3_commit_hook() interface registers a callback\n** function to be invoked whenever a transaction is [COMMIT | committed].\n** ^Any callback set by a previous call to sqlite3_commit_hook()\n** for the same database connection is overridden.\n** ^The sqlite3_rollback_hook() interface registers a callback\n** function to be invoked whenever a transaction is [ROLLBACK | rolled back].\n** ^Any callback set by a previous call to sqlite3_rollback_hook()\n** for the same database connection is overridden.\n** ^The pArg argument is passed through to the callback.\n** ^If the callback on a commit hook function returns non-zero,\n** then the commit is converted into a rollback.\n**\n** ^The sqlite3_commit_hook(D,C,P) and sqlite3_rollback_hook(D,C,P) functions\n** return the P argument from the previous call of the same function\n** on the same [database connection] D, or NULL for\n** the first call for each function on D.\n**\n** The commit and rollback hook callbacks are not reentrant.\n** The callback implementation must not do anything that will modify\n** the database connection that invoked the callback.  Any actions\n** to modify the database connection must be deferred until after the\n** completion of the [sqlite3_step()] call that triggered the commit\n** or rollback hook in the first place.\n** Note that running any other SQL statements, including SELECT statements,\n** or merely calling [sqlite3_prepare_v2()] and [sqlite3_step()] will modify\n** the database connections for the meaning of \"modify\" in this paragraph.\n**\n** ^Registering a NULL function disables the callback.\n**\n** ^When the commit hook callback routine returns zero, the [COMMIT]\n** operation is allowed to continue normally.  ^If the commit hook\n** returns non-zero, then the [COMMIT] is converted into a [ROLLBACK].\n** ^The rollback hook is invoked on a rollback that results from a commit\n** hook returning non-zero, just as it would be with any other rollback.\n**\n** ^For the purposes of this API, a transaction is said to have been\n** rolled back if an explicit \"ROLLBACK\" statement is executed, or\n** an error or constraint causes an implicit rollback to occur.\n** ^The rollback callback is not invoked if a transaction is\n** automatically rolled back because the database connection is closed.\n**\n** See also the [sqlite3_update_hook()] interface.\n*/\nSQLITE_API void *sqlite3_commit_hook(sqlite3*, int(*)(void*), void*);\nSQLITE_API void *sqlite3_rollback_hook(sqlite3*, void(*)(void *), void*);\n\n/*\n** CAPI3REF: Data Change Notification Callbacks\n** METHOD: sqlite3\n**\n** ^The sqlite3_update_hook() interface registers a callback function\n** with the [database connection] identified by the first argument\n** to be invoked whenever a row is updated, inserted or deleted in\n** a [rowid table].\n** ^Any callback set by a previous call to this function\n** for the same database connection is overridden.\n**\n** ^The second argument is a pointer to the function to invoke when a\n** row is updated, inserted or deleted in a rowid table.\n** ^The first argument to the callback is a copy of the third argument\n** to sqlite3_update_hook().\n** ^The second callback argument is one of [SQLITE_INSERT], [SQLITE_DELETE],\n** or [SQLITE_UPDATE], depending on the operation that caused the callback\n** to be invoked.\n** ^The third and fourth arguments to the callback contain pointers to the\n** database and table name containing the affected row.\n** ^The final callback parameter is the [rowid] of the row.\n** ^In the case of an update, this is the [rowid] after the update takes place.\n**\n** ^(The update hook is not invoked when internal system tables are\n** modified (i.e. sqlite_master and sqlite_sequence).)^\n** ^The update hook is not invoked when [WITHOUT ROWID] tables are modified.\n**\n** ^In the current implementation, the update hook\n** is not invoked when conflicting rows are deleted because of an\n** [ON CONFLICT | ON CONFLICT REPLACE] clause.  ^Nor is the update hook\n** invoked when rows are deleted using the [truncate optimization].\n** The exceptions defined in this paragraph might change in a future\n** release of SQLite.\n**\n** The update hook implementation must not do anything that will modify\n** the database connection that invoked the update hook.  Any actions\n** to modify the database connection must be deferred until after the\n** completion of the [sqlite3_step()] call that triggered the update hook.\n** Note that [sqlite3_prepare_v2()] and [sqlite3_step()] both modify their\n** database connections for the meaning of \"modify\" in this paragraph.\n**\n** ^The sqlite3_update_hook(D,C,P) function\n** returns the P argument from the previous call\n** on the same [database connection] D, or NULL for\n** the first call on D.\n**\n** See also the [sqlite3_commit_hook()], [sqlite3_rollback_hook()],\n** and [sqlite3_preupdate_hook()] interfaces.\n*/\nSQLITE_API void *sqlite3_update_hook(\n  sqlite3*, \n  void(*)(void *,int ,char const *,char const *,sqlite3_int64),\n  void*\n);\n\n/*\n** CAPI3REF: Enable Or Disable Shared Pager Cache\n**\n** ^(This routine enables or disables the sharing of the database cache\n** and schema data structures between [database connection | connections]\n** to the same database. Sharing is enabled if the argument is true\n** and disabled if the argument is false.)^\n**\n** ^Cache sharing is enabled and disabled for an entire process.\n** This is a change as of SQLite [version 3.5.0] ([dateof:3.5.0]). \n** In prior versions of SQLite,\n** sharing was enabled or disabled for each thread separately.\n**\n** ^(The cache sharing mode set by this interface effects all subsequent\n** calls to [sqlite3_open()], [sqlite3_open_v2()], and [sqlite3_open16()].\n** Existing database connections continue use the sharing mode\n** that was in effect at the time they were opened.)^\n**\n** ^(This routine returns [SQLITE_OK] if shared cache was enabled or disabled\n** successfully.  An [error code] is returned otherwise.)^\n**\n** ^Shared cache is disabled by default. But this might change in\n** future releases of SQLite.  Applications that care about shared\n** cache setting should set it explicitly.\n**\n** Note: This method is disabled on MacOS X 10.7 and iOS version 5.0\n** and will always return SQLITE_MISUSE. On those systems, \n** shared cache mode should be enabled per-database connection via \n** [sqlite3_open_v2()] with [SQLITE_OPEN_SHAREDCACHE].\n**\n** This interface is threadsafe on processors where writing a\n** 32-bit integer is atomic.\n**\n** See Also:  [SQLite Shared-Cache Mode]\n*/\nSQLITE_API int sqlite3_enable_shared_cache(int);\n\n/*\n** CAPI3REF: Attempt To Free Heap Memory\n**\n** ^The sqlite3_release_memory() interface attempts to free N bytes\n** of heap memory by deallocating non-essential memory allocations\n** held by the database library.   Memory used to cache database\n** pages to improve performance is an example of non-essential memory.\n** ^sqlite3_release_memory() returns the number of bytes actually freed,\n** which might be more or less than the amount requested.\n** ^The sqlite3_release_memory() routine is a no-op returning zero\n** if SQLite is not compiled with [SQLITE_ENABLE_MEMORY_MANAGEMENT].\n**\n** See also: [sqlite3_db_release_memory()]\n*/\nSQLITE_API int sqlite3_release_memory(int);\n\n/*\n** CAPI3REF: Free Memory Used By A Database Connection\n** METHOD: sqlite3\n**\n** ^The sqlite3_db_release_memory(D) interface attempts to free as much heap\n** memory as possible from database connection D. Unlike the\n** [sqlite3_release_memory()] interface, this interface is in effect even\n** when the [SQLITE_ENABLE_MEMORY_MANAGEMENT] compile-time option is\n** omitted.\n**\n** See also: [sqlite3_release_memory()]\n*/\nSQLITE_API int sqlite3_db_release_memory(sqlite3*);\n\n/*\n** CAPI3REF: Impose A Limit On Heap Size\n**\n** ^The sqlite3_soft_heap_limit64() interface sets and/or queries the\n** soft limit on the amount of heap memory that may be allocated by SQLite.\n** ^SQLite strives to keep heap memory utilization below the soft heap\n** limit by reducing the number of pages held in the page cache\n** as heap memory usages approaches the limit.\n** ^The soft heap limit is \"soft\" because even though SQLite strives to stay\n** below the limit, it will exceed the limit rather than generate\n** an [SQLITE_NOMEM] error.  In other words, the soft heap limit \n** is advisory only.\n**\n** ^The return value from sqlite3_soft_heap_limit64() is the size of\n** the soft heap limit prior to the call, or negative in the case of an\n** error.  ^If the argument N is negative\n** then no change is made to the soft heap limit.  Hence, the current\n** size of the soft heap limit can be determined by invoking\n** sqlite3_soft_heap_limit64() with a negative argument.\n**\n** ^If the argument N is zero then the soft heap limit is disabled.\n**\n** ^(The soft heap limit is not enforced in the current implementation\n** if one or more of following conditions are true:\n**\n** <ul>\n** <li> The soft heap limit is set to zero.\n** <li> Memory accounting is disabled using a combination of the\n**      [sqlite3_config]([SQLITE_CONFIG_MEMSTATUS],...) start-time option and\n**      the [SQLITE_DEFAULT_MEMSTATUS] compile-time option.\n** <li> An alternative page cache implementation is specified using\n**      [sqlite3_config]([SQLITE_CONFIG_PCACHE2],...).\n** <li> The page cache allocates from its own memory pool supplied\n**      by [sqlite3_config]([SQLITE_CONFIG_PAGECACHE],...) rather than\n**      from the heap.\n** </ul>)^\n**\n** Beginning with SQLite [version 3.7.3] ([dateof:3.7.3]), \n** the soft heap limit is enforced\n** regardless of whether or not the [SQLITE_ENABLE_MEMORY_MANAGEMENT]\n** compile-time option is invoked.  With [SQLITE_ENABLE_MEMORY_MANAGEMENT],\n** the soft heap limit is enforced on every memory allocation.  Without\n** [SQLITE_ENABLE_MEMORY_MANAGEMENT], the soft heap limit is only enforced\n** when memory is allocated by the page cache.  Testing suggests that because\n** the page cache is the predominate memory user in SQLite, most\n** applications will achieve adequate soft heap limit enforcement without\n** the use of [SQLITE_ENABLE_MEMORY_MANAGEMENT].\n**\n** The circumstances under which SQLite will enforce the soft heap limit may\n** changes in future releases of SQLite.\n*/\nSQLITE_API sqlite3_int64 sqlite3_soft_heap_limit64(sqlite3_int64 N);\n\n/*\n** CAPI3REF: Deprecated Soft Heap Limit Interface\n** DEPRECATED\n**\n** This is a deprecated version of the [sqlite3_soft_heap_limit64()]\n** interface.  This routine is provided for historical compatibility\n** only.  All new applications should use the\n** [sqlite3_soft_heap_limit64()] interface rather than this one.\n*/\nSQLITE_API SQLITE_DEPRECATED void sqlite3_soft_heap_limit(int N);\n\n\n/*\n** CAPI3REF: Extract Metadata About A Column Of A Table\n** METHOD: sqlite3\n**\n** ^(The sqlite3_table_column_metadata(X,D,T,C,....) routine returns\n** information about column C of table T in database D\n** on [database connection] X.)^  ^The sqlite3_table_column_metadata()\n** interface returns SQLITE_OK and fills in the non-NULL pointers in\n** the final five arguments with appropriate values if the specified\n** column exists.  ^The sqlite3_table_column_metadata() interface returns\n** SQLITE_ERROR and if the specified column does not exist.\n** ^If the column-name parameter to sqlite3_table_column_metadata() is a\n** NULL pointer, then this routine simply checks for the existence of the\n** table and returns SQLITE_OK if the table exists and SQLITE_ERROR if it\n** does not.  If the table name parameter T in a call to\n** sqlite3_table_column_metadata(X,D,T,C,...) is NULL then the result is\n** undefined behavior.\n**\n** ^The column is identified by the second, third and fourth parameters to\n** this function. ^(The second parameter is either the name of the database\n** (i.e. \"main\", \"temp\", or an attached database) containing the specified\n** table or NULL.)^ ^If it is NULL, then all attached databases are searched\n** for the table using the same algorithm used by the database engine to\n** resolve unqualified table references.\n**\n** ^The third and fourth parameters to this function are the table and column\n** name of the desired column, respectively.\n**\n** ^Metadata is returned by writing to the memory locations passed as the 5th\n** and subsequent parameters to this function. ^Any of these arguments may be\n** NULL, in which case the corresponding element of metadata is omitted.\n**\n** ^(<blockquote>\n** <table border=\"1\">\n** <tr><th> Parameter <th> Output<br>Type <th>  Description\n**\n** <tr><td> 5th <td> const char* <td> Data type\n** <tr><td> 6th <td> const char* <td> Name of default collation sequence\n** <tr><td> 7th <td> int         <td> True if column has a NOT NULL constraint\n** <tr><td> 8th <td> int         <td> True if column is part of the PRIMARY KEY\n** <tr><td> 9th <td> int         <td> True if column is [AUTOINCREMENT]\n** </table>\n** </blockquote>)^\n**\n** ^The memory pointed to by the character pointers returned for the\n** declaration type and collation sequence is valid until the next\n** call to any SQLite API function.\n**\n** ^If the specified table is actually a view, an [error code] is returned.\n**\n** ^If the specified column is \"rowid\", \"oid\" or \"_rowid_\" and the table \n** is not a [WITHOUT ROWID] table and an\n** [INTEGER PRIMARY KEY] column has been explicitly declared, then the output\n** parameters are set for the explicitly declared column. ^(If there is no\n** [INTEGER PRIMARY KEY] column, then the outputs\n** for the [rowid] are set as follows:\n**\n** <pre>\n**     data type: \"INTEGER\"\n**     collation sequence: \"BINARY\"\n**     not null: 0\n**     primary key: 1\n**     auto increment: 0\n** </pre>)^\n**\n** ^This function causes all database schemas to be read from disk and\n** parsed, if that has not already been done, and returns an error if\n** any errors are encountered while loading the schema.\n*/\nSQLITE_API int sqlite3_table_column_metadata(\n  sqlite3 *db,                /* Connection handle */\n  const char *zDbName,        /* Database name or NULL */\n  const char *zTableName,     /* Table name */\n  const char *zColumnName,    /* Column name */\n  char const **pzDataType,    /* OUTPUT: Declared data type */\n  char const **pzCollSeq,     /* OUTPUT: Collation sequence name */\n  int *pNotNull,              /* OUTPUT: True if NOT NULL constraint exists */\n  int *pPrimaryKey,           /* OUTPUT: True if column part of PK */\n  int *pAutoinc               /* OUTPUT: True if column is auto-increment */\n);\n\n/*\n** CAPI3REF: Load An Extension\n** METHOD: sqlite3\n**\n** ^This interface loads an SQLite extension library from the named file.\n**\n** ^The sqlite3_load_extension() interface attempts to load an\n** [SQLite extension] library contained in the file zFile.  If\n** the file cannot be loaded directly, attempts are made to load\n** with various operating-system specific extensions added.\n** So for example, if \"samplelib\" cannot be loaded, then names like\n** \"samplelib.so\" or \"samplelib.dylib\" or \"samplelib.dll\" might\n** be tried also.\n**\n** ^The entry point is zProc.\n** ^(zProc may be 0, in which case SQLite will try to come up with an\n** entry point name on its own.  It first tries \"sqlite3_extension_init\".\n** If that does not work, it constructs a name \"sqlite3_X_init\" where the\n** X is consists of the lower-case equivalent of all ASCII alphabetic\n** characters in the filename from the last \"/\" to the first following\n** \".\" and omitting any initial \"lib\".)^\n** ^The sqlite3_load_extension() interface returns\n** [SQLITE_OK] on success and [SQLITE_ERROR] if something goes wrong.\n** ^If an error occurs and pzErrMsg is not 0, then the\n** [sqlite3_load_extension()] interface shall attempt to\n** fill *pzErrMsg with error message text stored in memory\n** obtained from [sqlite3_malloc()]. The calling function\n** should free this memory by calling [sqlite3_free()].\n**\n** ^Extension loading must be enabled using\n** [sqlite3_enable_load_extension()] or\n** [sqlite3_db_config](db,[SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION],1,NULL)\n** prior to calling this API,\n** otherwise an error will be returned.\n**\n** <b>Security warning:</b> It is recommended that the \n** [SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION] method be used to enable only this\n** interface.  The use of the [sqlite3_enable_load_extension()] interface\n** should be avoided.  This will keep the SQL function [load_extension()]\n** disabled and prevent SQL injections from giving attackers\n** access to extension loading capabilities.\n**\n** See also the [load_extension() SQL function].\n*/\nSQLITE_API int sqlite3_load_extension(\n  sqlite3 *db,          /* Load the extension into this database connection */\n  const char *zFile,    /* Name of the shared library containing extension */\n  const char *zProc,    /* Entry point.  Derived from zFile if 0 */\n  char **pzErrMsg       /* Put error message here if not 0 */\n);\n\n/*\n** CAPI3REF: Enable Or Disable Extension Loading\n** METHOD: sqlite3\n**\n** ^So as not to open security holes in older applications that are\n** unprepared to deal with [extension loading], and as a means of disabling\n** [extension loading] while evaluating user-entered SQL, the following API\n** is provided to turn the [sqlite3_load_extension()] mechanism on and off.\n**\n** ^Extension loading is off by default.\n** ^Call the sqlite3_enable_load_extension() routine with onoff==1\n** to turn extension loading on and call it with onoff==0 to turn\n** it back off again.\n**\n** ^This interface enables or disables both the C-API\n** [sqlite3_load_extension()] and the SQL function [load_extension()].\n** ^(Use [sqlite3_db_config](db,[SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION],..)\n** to enable or disable only the C-API.)^\n**\n** <b>Security warning:</b> It is recommended that extension loading\n** be disabled using the [SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION] method\n** rather than this interface, so the [load_extension()] SQL function\n** remains disabled. This will prevent SQL injections from giving attackers\n** access to extension loading capabilities.\n*/\nSQLITE_API int sqlite3_enable_load_extension(sqlite3 *db, int onoff);\n\n/*\n** CAPI3REF: Automatically Load Statically Linked Extensions\n**\n** ^This interface causes the xEntryPoint() function to be invoked for\n** each new [database connection] that is created.  The idea here is that\n** xEntryPoint() is the entry point for a statically linked [SQLite extension]\n** that is to be automatically loaded into all new database connections.\n**\n** ^(Even though the function prototype shows that xEntryPoint() takes\n** no arguments and returns void, SQLite invokes xEntryPoint() with three\n** arguments and expects an integer result as if the signature of the\n** entry point where as follows:\n**\n** <blockquote><pre>\n** &nbsp;  int xEntryPoint(\n** &nbsp;    sqlite3 *db,\n** &nbsp;    const char **pzErrMsg,\n** &nbsp;    const struct sqlite3_api_routines *pThunk\n** &nbsp;  );\n** </pre></blockquote>)^\n**\n** If the xEntryPoint routine encounters an error, it should make *pzErrMsg\n** point to an appropriate error message (obtained from [sqlite3_mprintf()])\n** and return an appropriate [error code].  ^SQLite ensures that *pzErrMsg\n** is NULL before calling the xEntryPoint().  ^SQLite will invoke\n** [sqlite3_free()] on *pzErrMsg after xEntryPoint() returns.  ^If any\n** xEntryPoint() returns an error, the [sqlite3_open()], [sqlite3_open16()],\n** or [sqlite3_open_v2()] call that provoked the xEntryPoint() will fail.\n**\n** ^Calling sqlite3_auto_extension(X) with an entry point X that is already\n** on the list of automatic extensions is a harmless no-op. ^No entry point\n** will be called more than once for each database connection that is opened.\n**\n** See also: [sqlite3_reset_auto_extension()]\n** and [sqlite3_cancel_auto_extension()]\n*/\nSQLITE_API int sqlite3_auto_extension(void(*xEntryPoint)(void));\n\n/*\n** CAPI3REF: Cancel Automatic Extension Loading\n**\n** ^The [sqlite3_cancel_auto_extension(X)] interface unregisters the\n** initialization routine X that was registered using a prior call to\n** [sqlite3_auto_extension(X)].  ^The [sqlite3_cancel_auto_extension(X)]\n** routine returns 1 if initialization routine X was successfully \n** unregistered and it returns 0 if X was not on the list of initialization\n** routines.\n*/\nSQLITE_API int sqlite3_cancel_auto_extension(void(*xEntryPoint)(void));\n\n/*\n** CAPI3REF: Reset Automatic Extension Loading\n**\n** ^This interface disables all automatic extensions previously\n** registered using [sqlite3_auto_extension()].\n*/\nSQLITE_API void sqlite3_reset_auto_extension(void);\n\n/*\n** The interface to the virtual-table mechanism is currently considered\n** to be experimental.  The interface might change in incompatible ways.\n** If this is a problem for you, do not use the interface at this time.\n**\n** When the virtual-table mechanism stabilizes, we will declare the\n** interface fixed, support it indefinitely, and remove this comment.\n*/\n\n/*\n** Structures used by the virtual table interface\n*/\ntypedef struct sqlite3_vtab sqlite3_vtab;\ntypedef struct sqlite3_index_info sqlite3_index_info;\ntypedef struct sqlite3_vtab_cursor sqlite3_vtab_cursor;\ntypedef struct sqlite3_module sqlite3_module;\n\n/*\n** CAPI3REF: Virtual Table Object\n** KEYWORDS: sqlite3_module {virtual table module}\n**\n** This structure, sometimes called a \"virtual table module\", \n** defines the implementation of a [virtual tables].  \n** This structure consists mostly of methods for the module.\n**\n** ^A virtual table module is created by filling in a persistent\n** instance of this structure and passing a pointer to that instance\n** to [sqlite3_create_module()] or [sqlite3_create_module_v2()].\n** ^The registration remains valid until it is replaced by a different\n** module or until the [database connection] closes.  The content\n** of this structure must not change while it is registered with\n** any database connection.\n*/\nstruct sqlite3_module {\n  int iVersion;\n  int (*xCreate)(sqlite3*, void *pAux,\n               int argc, const char *const*argv,\n               sqlite3_vtab **ppVTab, char**);\n  int (*xConnect)(sqlite3*, void *pAux,\n               int argc, const char *const*argv,\n               sqlite3_vtab **ppVTab, char**);\n  int (*xBestIndex)(sqlite3_vtab *pVTab, sqlite3_index_info*);\n  int (*xDisconnect)(sqlite3_vtab *pVTab);\n  int (*xDestroy)(sqlite3_vtab *pVTab);\n  int (*xOpen)(sqlite3_vtab *pVTab, sqlite3_vtab_cursor **ppCursor);\n  int (*xClose)(sqlite3_vtab_cursor*);\n  int (*xFilter)(sqlite3_vtab_cursor*, int idxNum, const char *idxStr,\n                int argc, sqlite3_value **argv);\n  int (*xNext)(sqlite3_vtab_cursor*);\n  int (*xEof)(sqlite3_vtab_cursor*);\n  int (*xColumn)(sqlite3_vtab_cursor*, sqlite3_context*, int);\n  int (*xRowid)(sqlite3_vtab_cursor*, sqlite3_int64 *pRowid);\n  int (*xUpdate)(sqlite3_vtab *, int, sqlite3_value **, sqlite3_int64 *);\n  int (*xBegin)(sqlite3_vtab *pVTab);\n  int (*xSync)(sqlite3_vtab *pVTab);\n  int (*xCommit)(sqlite3_vtab *pVTab);\n  int (*xRollback)(sqlite3_vtab *pVTab);\n  int (*xFindFunction)(sqlite3_vtab *pVtab, int nArg, const char *zName,\n                       void (**pxFunc)(sqlite3_context*,int,sqlite3_value**),\n                       void **ppArg);\n  int (*xRename)(sqlite3_vtab *pVtab, const char *zNew);\n  /* The methods above are in version 1 of the sqlite_module object. Those \n  ** below are for version 2 and greater. */\n  int (*xSavepoint)(sqlite3_vtab *pVTab, int);\n  int (*xRelease)(sqlite3_vtab *pVTab, int);\n  int (*xRollbackTo)(sqlite3_vtab *pVTab, int);\n  /* The methods above are in versions 1 and 2 of the sqlite_module object.\n  ** Those below are for version 3 and greater. */\n  int (*xShadowName)(const char*);\n};\n\n/*\n** CAPI3REF: Virtual Table Indexing Information\n** KEYWORDS: sqlite3_index_info\n**\n** The sqlite3_index_info structure and its substructures is used as part\n** of the [virtual table] interface to\n** pass information into and receive the reply from the [xBestIndex]\n** method of a [virtual table module].  The fields under **Inputs** are the\n** inputs to xBestIndex and are read-only.  xBestIndex inserts its\n** results into the **Outputs** fields.\n**\n** ^(The aConstraint[] array records WHERE clause constraints of the form:\n**\n** <blockquote>column OP expr</blockquote>\n**\n** where OP is =, &lt;, &lt;=, &gt;, or &gt;=.)^  ^(The particular operator is\n** stored in aConstraint[].op using one of the\n** [SQLITE_INDEX_CONSTRAINT_EQ | SQLITE_INDEX_CONSTRAINT_ values].)^\n** ^(The index of the column is stored in\n** aConstraint[].iColumn.)^  ^(aConstraint[].usable is TRUE if the\n** expr on the right-hand side can be evaluated (and thus the constraint\n** is usable) and false if it cannot.)^\n**\n** ^The optimizer automatically inverts terms of the form \"expr OP column\"\n** and makes other simplifications to the WHERE clause in an attempt to\n** get as many WHERE clause terms into the form shown above as possible.\n** ^The aConstraint[] array only reports WHERE clause terms that are\n** relevant to the particular virtual table being queried.\n**\n** ^Information about the ORDER BY clause is stored in aOrderBy[].\n** ^Each term of aOrderBy records a column of the ORDER BY clause.\n**\n** The colUsed field indicates which columns of the virtual table may be\n** required by the current scan. Virtual table columns are numbered from\n** zero in the order in which they appear within the CREATE TABLE statement\n** passed to sqlite3_declare_vtab(). For the first 63 columns (columns 0-62),\n** the corresponding bit is set within the colUsed mask if the column may be\n** required by SQLite. If the table has at least 64 columns and any column\n** to the right of the first 63 is required, then bit 63 of colUsed is also\n** set. In other words, column iCol may be required if the expression\n** (colUsed & ((sqlite3_uint64)1 << (iCol>=63 ? 63 : iCol))) evaluates to \n** non-zero.\n**\n** The [xBestIndex] method must fill aConstraintUsage[] with information\n** about what parameters to pass to xFilter.  ^If argvIndex>0 then\n** the right-hand side of the corresponding aConstraint[] is evaluated\n** and becomes the argvIndex-th entry in argv.  ^(If aConstraintUsage[].omit\n** is true, then the constraint is assumed to be fully handled by the\n** virtual table and is not checked again by SQLite.)^\n**\n** ^The idxNum and idxPtr values are recorded and passed into the\n** [xFilter] method.\n** ^[sqlite3_free()] is used to free idxPtr if and only if\n** needToFreeIdxPtr is true.\n**\n** ^The orderByConsumed means that output from [xFilter]/[xNext] will occur in\n** the correct order to satisfy the ORDER BY clause so that no separate\n** sorting step is required.\n**\n** ^The estimatedCost value is an estimate of the cost of a particular\n** strategy. A cost of N indicates that the cost of the strategy is similar\n** to a linear scan of an SQLite table with N rows. A cost of log(N) \n** indicates that the expense of the operation is similar to that of a\n** binary search on a unique indexed field of an SQLite table with N rows.\n**\n** ^The estimatedRows value is an estimate of the number of rows that\n** will be returned by the strategy.\n**\n** The xBestIndex method may optionally populate the idxFlags field with a \n** mask of SQLITE_INDEX_SCAN_* flags. Currently there is only one such flag -\n** SQLITE_INDEX_SCAN_UNIQUE. If the xBestIndex method sets this flag, SQLite\n** assumes that the strategy may visit at most one row. \n**\n** Additionally, if xBestIndex sets the SQLITE_INDEX_SCAN_UNIQUE flag, then\n** SQLite also assumes that if a call to the xUpdate() method is made as\n** part of the same statement to delete or update a virtual table row and the\n** implementation returns SQLITE_CONSTRAINT, then there is no need to rollback\n** any database changes. In other words, if the xUpdate() returns\n** SQLITE_CONSTRAINT, the database contents must be exactly as they were\n** before xUpdate was called. By contrast, if SQLITE_INDEX_SCAN_UNIQUE is not\n** set and xUpdate returns SQLITE_CONSTRAINT, any database changes made by\n** the xUpdate method are automatically rolled back by SQLite.\n**\n** IMPORTANT: The estimatedRows field was added to the sqlite3_index_info\n** structure for SQLite [version 3.8.2] ([dateof:3.8.2]). \n** If a virtual table extension is\n** used with an SQLite version earlier than 3.8.2, the results of attempting \n** to read or write the estimatedRows field are undefined (but are likely \n** to included crashing the application). The estimatedRows field should\n** therefore only be used if [sqlite3_libversion_number()] returns a\n** value greater than or equal to 3008002. Similarly, the idxFlags field\n** was added for [version 3.9.0] ([dateof:3.9.0]). \n** It may therefore only be used if\n** sqlite3_libversion_number() returns a value greater than or equal to\n** 3009000.\n*/\nstruct sqlite3_index_info {\n  /* Inputs */\n  int nConstraint;           /* Number of entries in aConstraint */\n  struct sqlite3_index_constraint {\n     int iColumn;              /* Column constrained.  -1 for ROWID */\n     unsigned char op;         /* Constraint operator */\n     unsigned char usable;     /* True if this constraint is usable */\n     int iTermOffset;          /* Used internally - xBestIndex should ignore */\n  } *aConstraint;            /* Table of WHERE clause constraints */\n  int nOrderBy;              /* Number of terms in the ORDER BY clause */\n  struct sqlite3_index_orderby {\n     int iColumn;              /* Column number */\n     unsigned char desc;       /* True for DESC.  False for ASC. */\n  } *aOrderBy;               /* The ORDER BY clause */\n  /* Outputs */\n  struct sqlite3_index_constraint_usage {\n    int argvIndex;           /* if >0, constraint is part of argv to xFilter */\n    unsigned char omit;      /* Do not code a test for this constraint */\n  } *aConstraintUsage;\n  int idxNum;                /* Number used to identify the index */\n  char *idxStr;              /* String, possibly obtained from sqlite3_malloc */\n  int needToFreeIdxStr;      /* Free idxStr using sqlite3_free() if true */\n  int orderByConsumed;       /* True if output is already ordered */\n  double estimatedCost;           /* Estimated cost of using this index */\n  /* Fields below are only available in SQLite 3.8.2 and later */\n  sqlite3_int64 estimatedRows;    /* Estimated number of rows returned */\n  /* Fields below are only available in SQLite 3.9.0 and later */\n  int idxFlags;              /* Mask of SQLITE_INDEX_SCAN_* flags */\n  /* Fields below are only available in SQLite 3.10.0 and later */\n  sqlite3_uint64 colUsed;    /* Input: Mask of columns used by statement */\n};\n\n/*\n** CAPI3REF: Virtual Table Scan Flags\n**\n** Virtual table implementations are allowed to set the \n** [sqlite3_index_info].idxFlags field to some combination of\n** these bits.\n*/\n#define SQLITE_INDEX_SCAN_UNIQUE      1     /* Scan visits at most 1 row */\n\n/*\n** CAPI3REF: Virtual Table Constraint Operator Codes\n**\n** These macros defined the allowed values for the\n** [sqlite3_index_info].aConstraint[].op field.  Each value represents\n** an operator that is part of a constraint term in the wHERE clause of\n** a query that uses a [virtual table].\n*/\n#define SQLITE_INDEX_CONSTRAINT_EQ         2\n#define SQLITE_INDEX_CONSTRAINT_GT         4\n#define SQLITE_INDEX_CONSTRAINT_LE         8\n#define SQLITE_INDEX_CONSTRAINT_LT        16\n#define SQLITE_INDEX_CONSTRAINT_GE        32\n#define SQLITE_INDEX_CONSTRAINT_MATCH     64\n#define SQLITE_INDEX_CONSTRAINT_LIKE      65\n#define SQLITE_INDEX_CONSTRAINT_GLOB      66\n#define SQLITE_INDEX_CONSTRAINT_REGEXP    67\n#define SQLITE_INDEX_CONSTRAINT_NE        68\n#define SQLITE_INDEX_CONSTRAINT_ISNOT     69\n#define SQLITE_INDEX_CONSTRAINT_ISNOTNULL 70\n#define SQLITE_INDEX_CONSTRAINT_ISNULL    71\n#define SQLITE_INDEX_CONSTRAINT_IS        72\n#define SQLITE_INDEX_CONSTRAINT_FUNCTION 150\n\n/*\n** CAPI3REF: Register A Virtual Table Implementation\n** METHOD: sqlite3\n**\n** ^These routines are used to register a new [virtual table module] name.\n** ^Module names must be registered before\n** creating a new [virtual table] using the module and before using a\n** preexisting [virtual table] for the module.\n**\n** ^The module name is registered on the [database connection] specified\n** by the first parameter.  ^The name of the module is given by the \n** second parameter.  ^The third parameter is a pointer to\n** the implementation of the [virtual table module].   ^The fourth\n** parameter is an arbitrary client data pointer that is passed through\n** into the [xCreate] and [xConnect] methods of the virtual table module\n** when a new virtual table is be being created or reinitialized.\n**\n** ^The sqlite3_create_module_v2() interface has a fifth parameter which\n** is a pointer to a destructor for the pClientData.  ^SQLite will\n** invoke the destructor function (if it is not NULL) when SQLite\n** no longer needs the pClientData pointer.  ^The destructor will also\n** be invoked if the call to sqlite3_create_module_v2() fails.\n** ^The sqlite3_create_module()\n** interface is equivalent to sqlite3_create_module_v2() with a NULL\n** destructor.\n*/\nSQLITE_API int sqlite3_create_module(\n  sqlite3 *db,               /* SQLite connection to register module with */\n  const char *zName,         /* Name of the module */\n  const sqlite3_module *p,   /* Methods for the module */\n  void *pClientData          /* Client data for xCreate/xConnect */\n);\nSQLITE_API int sqlite3_create_module_v2(\n  sqlite3 *db,               /* SQLite connection to register module with */\n  const char *zName,         /* Name of the module */\n  const sqlite3_module *p,   /* Methods for the module */\n  void *pClientData,         /* Client data for xCreate/xConnect */\n  void(*xDestroy)(void*)     /* Module destructor function */\n);\n\n/*\n** CAPI3REF: Virtual Table Instance Object\n** KEYWORDS: sqlite3_vtab\n**\n** Every [virtual table module] implementation uses a subclass\n** of this object to describe a particular instance\n** of the [virtual table].  Each subclass will\n** be tailored to the specific needs of the module implementation.\n** The purpose of this superclass is to define certain fields that are\n** common to all module implementations.\n**\n** ^Virtual tables methods can set an error message by assigning a\n** string obtained from [sqlite3_mprintf()] to zErrMsg.  The method should\n** take care that any prior string is freed by a call to [sqlite3_free()]\n** prior to assigning a new string to zErrMsg.  ^After the error message\n** is delivered up to the client application, the string will be automatically\n** freed by sqlite3_free() and the zErrMsg field will be zeroed.\n*/\nstruct sqlite3_vtab {\n  const sqlite3_module *pModule;  /* The module for this virtual table */\n  int nRef;                       /* Number of open cursors */\n  char *zErrMsg;                  /* Error message from sqlite3_mprintf() */\n  /* Virtual table implementations will typically add additional fields */\n};\n\n/*\n** CAPI3REF: Virtual Table Cursor Object\n** KEYWORDS: sqlite3_vtab_cursor {virtual table cursor}\n**\n** Every [virtual table module] implementation uses a subclass of the\n** following structure to describe cursors that point into the\n** [virtual table] and are used\n** to loop through the virtual table.  Cursors are created using the\n** [sqlite3_module.xOpen | xOpen] method of the module and are destroyed\n** by the [sqlite3_module.xClose | xClose] method.  Cursors are used\n** by the [xFilter], [xNext], [xEof], [xColumn], and [xRowid] methods\n** of the module.  Each module implementation will define\n** the content of a cursor structure to suit its own needs.\n**\n** This superclass exists in order to define fields of the cursor that\n** are common to all implementations.\n*/\nstruct sqlite3_vtab_cursor {\n  sqlite3_vtab *pVtab;      /* Virtual table of this cursor */\n  /* Virtual table implementations will typically add additional fields */\n};\n\n/*\n** CAPI3REF: Declare The Schema Of A Virtual Table\n**\n** ^The [xCreate] and [xConnect] methods of a\n** [virtual table module] call this interface\n** to declare the format (the names and datatypes of the columns) of\n** the virtual tables they implement.\n*/\nSQLITE_API int sqlite3_declare_vtab(sqlite3*, const char *zSQL);\n\n/*\n** CAPI3REF: Overload A Function For A Virtual Table\n** METHOD: sqlite3\n**\n** ^(Virtual tables can provide alternative implementations of functions\n** using the [xFindFunction] method of the [virtual table module].  \n** But global versions of those functions\n** must exist in order to be overloaded.)^\n**\n** ^(This API makes sure a global version of a function with a particular\n** name and number of parameters exists.  If no such function exists\n** before this API is called, a new function is created.)^  ^The implementation\n** of the new function always causes an exception to be thrown.  So\n** the new function is not good for anything by itself.  Its only\n** purpose is to be a placeholder function that can be overloaded\n** by a [virtual table].\n*/\nSQLITE_API int sqlite3_overload_function(sqlite3*, const char *zFuncName, int nArg);\n\n/*\n** The interface to the virtual-table mechanism defined above (back up\n** to a comment remarkably similar to this one) is currently considered\n** to be experimental.  The interface might change in incompatible ways.\n** If this is a problem for you, do not use the interface at this time.\n**\n** When the virtual-table mechanism stabilizes, we will declare the\n** interface fixed, support it indefinitely, and remove this comment.\n*/\n\n/*\n** CAPI3REF: A Handle To An Open BLOB\n** KEYWORDS: {BLOB handle} {BLOB handles}\n**\n** An instance of this object represents an open BLOB on which\n** [sqlite3_blob_open | incremental BLOB I/O] can be performed.\n** ^Objects of this type are created by [sqlite3_blob_open()]\n** and destroyed by [sqlite3_blob_close()].\n** ^The [sqlite3_blob_read()] and [sqlite3_blob_write()] interfaces\n** can be used to read or write small subsections of the BLOB.\n** ^The [sqlite3_blob_bytes()] interface returns the size of the BLOB in bytes.\n*/\ntypedef struct sqlite3_blob sqlite3_blob;\n\n/*\n** CAPI3REF: Open A BLOB For Incremental I/O\n** METHOD: sqlite3\n** CONSTRUCTOR: sqlite3_blob\n**\n** ^(This interfaces opens a [BLOB handle | handle] to the BLOB located\n** in row iRow, column zColumn, table zTable in database zDb;\n** in other words, the same BLOB that would be selected by:\n**\n** <pre>\n**     SELECT zColumn FROM zDb.zTable WHERE [rowid] = iRow;\n** </pre>)^\n**\n** ^(Parameter zDb is not the filename that contains the database, but \n** rather the symbolic name of the database. For attached databases, this is\n** the name that appears after the AS keyword in the [ATTACH] statement.\n** For the main database file, the database name is \"main\". For TEMP\n** tables, the database name is \"temp\".)^\n**\n** ^If the flags parameter is non-zero, then the BLOB is opened for read\n** and write access. ^If the flags parameter is zero, the BLOB is opened for\n** read-only access.\n**\n** ^(On success, [SQLITE_OK] is returned and the new [BLOB handle] is stored\n** in *ppBlob. Otherwise an [error code] is returned and, unless the error\n** code is SQLITE_MISUSE, *ppBlob is set to NULL.)^ ^This means that, provided\n** the API is not misused, it is always safe to call [sqlite3_blob_close()] \n** on *ppBlob after this function it returns.\n**\n** This function fails with SQLITE_ERROR if any of the following are true:\n** <ul>\n**   <li> ^(Database zDb does not exist)^, \n**   <li> ^(Table zTable does not exist within database zDb)^, \n**   <li> ^(Table zTable is a WITHOUT ROWID table)^, \n**   <li> ^(Column zColumn does not exist)^,\n**   <li> ^(Row iRow is not present in the table)^,\n**   <li> ^(The specified column of row iRow contains a value that is not\n**         a TEXT or BLOB value)^,\n**   <li> ^(Column zColumn is part of an index, PRIMARY KEY or UNIQUE \n**         constraint and the blob is being opened for read/write access)^,\n**   <li> ^([foreign key constraints | Foreign key constraints] are enabled, \n**         column zColumn is part of a [child key] definition and the blob is\n**         being opened for read/write access)^.\n** </ul>\n**\n** ^Unless it returns SQLITE_MISUSE, this function sets the \n** [database connection] error code and message accessible via \n** [sqlite3_errcode()] and [sqlite3_errmsg()] and related functions. \n**\n** A BLOB referenced by sqlite3_blob_open() may be read using the\n** [sqlite3_blob_read()] interface and modified by using\n** [sqlite3_blob_write()].  The [BLOB handle] can be moved to a\n** different row of the same table using the [sqlite3_blob_reopen()]\n** interface.  However, the column, table, or database of a [BLOB handle]\n** cannot be changed after the [BLOB handle] is opened.\n**\n** ^(If the row that a BLOB handle points to is modified by an\n** [UPDATE], [DELETE], or by [ON CONFLICT] side-effects\n** then the BLOB handle is marked as \"expired\".\n** This is true if any column of the row is changed, even a column\n** other than the one the BLOB handle is open on.)^\n** ^Calls to [sqlite3_blob_read()] and [sqlite3_blob_write()] for\n** an expired BLOB handle fail with a return code of [SQLITE_ABORT].\n** ^(Changes written into a BLOB prior to the BLOB expiring are not\n** rolled back by the expiration of the BLOB.  Such changes will eventually\n** commit if the transaction continues to completion.)^\n**\n** ^Use the [sqlite3_blob_bytes()] interface to determine the size of\n** the opened blob.  ^The size of a blob may not be changed by this\n** interface.  Use the [UPDATE] SQL command to change the size of a\n** blob.\n**\n** ^The [sqlite3_bind_zeroblob()] and [sqlite3_result_zeroblob()] interfaces\n** and the built-in [zeroblob] SQL function may be used to create a \n** zero-filled blob to read or write using the incremental-blob interface.\n**\n** To avoid a resource leak, every open [BLOB handle] should eventually\n** be released by a call to [sqlite3_blob_close()].\n**\n** See also: [sqlite3_blob_close()],\n** [sqlite3_blob_reopen()], [sqlite3_blob_read()],\n** [sqlite3_blob_bytes()], [sqlite3_blob_write()].\n*/\nSQLITE_API int sqlite3_blob_open(\n  sqlite3*,\n  const char *zDb,\n  const char *zTable,\n  const char *zColumn,\n  sqlite3_int64 iRow,\n  int flags,\n  sqlite3_blob **ppBlob\n);\n\n/*\n** CAPI3REF: Move a BLOB Handle to a New Row\n** METHOD: sqlite3_blob\n**\n** ^This function is used to move an existing [BLOB handle] so that it points\n** to a different row of the same database table. ^The new row is identified\n** by the rowid value passed as the second argument. Only the row can be\n** changed. ^The database, table and column on which the blob handle is open\n** remain the same. Moving an existing [BLOB handle] to a new row is\n** faster than closing the existing handle and opening a new one.\n**\n** ^(The new row must meet the same criteria as for [sqlite3_blob_open()] -\n** it must exist and there must be either a blob or text value stored in\n** the nominated column.)^ ^If the new row is not present in the table, or if\n** it does not contain a blob or text value, or if another error occurs, an\n** SQLite error code is returned and the blob handle is considered aborted.\n** ^All subsequent calls to [sqlite3_blob_read()], [sqlite3_blob_write()] or\n** [sqlite3_blob_reopen()] on an aborted blob handle immediately return\n** SQLITE_ABORT. ^Calling [sqlite3_blob_bytes()] on an aborted blob handle\n** always returns zero.\n**\n** ^This function sets the database handle error code and message.\n*/\nSQLITE_API int sqlite3_blob_reopen(sqlite3_blob *, sqlite3_int64);\n\n/*\n** CAPI3REF: Close A BLOB Handle\n** DESTRUCTOR: sqlite3_blob\n**\n** ^This function closes an open [BLOB handle]. ^(The BLOB handle is closed\n** unconditionally.  Even if this routine returns an error code, the \n** handle is still closed.)^\n**\n** ^If the blob handle being closed was opened for read-write access, and if\n** the database is in auto-commit mode and there are no other open read-write\n** blob handles or active write statements, the current transaction is\n** committed. ^If an error occurs while committing the transaction, an error\n** code is returned and the transaction rolled back.\n**\n** Calling this function with an argument that is not a NULL pointer or an\n** open blob handle results in undefined behaviour. ^Calling this routine \n** with a null pointer (such as would be returned by a failed call to \n** [sqlite3_blob_open()]) is a harmless no-op. ^Otherwise, if this function\n** is passed a valid open blob handle, the values returned by the \n** sqlite3_errcode() and sqlite3_errmsg() functions are set before returning.\n*/\nSQLITE_API int sqlite3_blob_close(sqlite3_blob *);\n\n/*\n** CAPI3REF: Return The Size Of An Open BLOB\n** METHOD: sqlite3_blob\n**\n** ^Returns the size in bytes of the BLOB accessible via the \n** successfully opened [BLOB handle] in its only argument.  ^The\n** incremental blob I/O routines can only read or overwriting existing\n** blob content; they cannot change the size of a blob.\n**\n** This routine only works on a [BLOB handle] which has been created\n** by a prior successful call to [sqlite3_blob_open()] and which has not\n** been closed by [sqlite3_blob_close()].  Passing any other pointer in\n** to this routine results in undefined and probably undesirable behavior.\n*/\nSQLITE_API int sqlite3_blob_bytes(sqlite3_blob *);\n\n/*\n** CAPI3REF: Read Data From A BLOB Incrementally\n** METHOD: sqlite3_blob\n**\n** ^(This function is used to read data from an open [BLOB handle] into a\n** caller-supplied buffer. N bytes of data are copied into buffer Z\n** from the open BLOB, starting at offset iOffset.)^\n**\n** ^If offset iOffset is less than N bytes from the end of the BLOB,\n** [SQLITE_ERROR] is returned and no data is read.  ^If N or iOffset is\n** less than zero, [SQLITE_ERROR] is returned and no data is read.\n** ^The size of the blob (and hence the maximum value of N+iOffset)\n** can be determined using the [sqlite3_blob_bytes()] interface.\n**\n** ^An attempt to read from an expired [BLOB handle] fails with an\n** error code of [SQLITE_ABORT].\n**\n** ^(On success, sqlite3_blob_read() returns SQLITE_OK.\n** Otherwise, an [error code] or an [extended error code] is returned.)^\n**\n** This routine only works on a [BLOB handle] which has been created\n** by a prior successful call to [sqlite3_blob_open()] and which has not\n** been closed by [sqlite3_blob_close()].  Passing any other pointer in\n** to this routine results in undefined and probably undesirable behavior.\n**\n** See also: [sqlite3_blob_write()].\n*/\nSQLITE_API int sqlite3_blob_read(sqlite3_blob *, void *Z, int N, int iOffset);\n\n/*\n** CAPI3REF: Write Data Into A BLOB Incrementally\n** METHOD: sqlite3_blob\n**\n** ^(This function is used to write data into an open [BLOB handle] from a\n** caller-supplied buffer. N bytes of data are copied from the buffer Z\n** into the open BLOB, starting at offset iOffset.)^\n**\n** ^(On success, sqlite3_blob_write() returns SQLITE_OK.\n** Otherwise, an  [error code] or an [extended error code] is returned.)^\n** ^Unless SQLITE_MISUSE is returned, this function sets the \n** [database connection] error code and message accessible via \n** [sqlite3_errcode()] and [sqlite3_errmsg()] and related functions. \n**\n** ^If the [BLOB handle] passed as the first argument was not opened for\n** writing (the flags parameter to [sqlite3_blob_open()] was zero),\n** this function returns [SQLITE_READONLY].\n**\n** This function may only modify the contents of the BLOB; it is\n** not possible to increase the size of a BLOB using this API.\n** ^If offset iOffset is less than N bytes from the end of the BLOB,\n** [SQLITE_ERROR] is returned and no data is written. The size of the \n** BLOB (and hence the maximum value of N+iOffset) can be determined \n** using the [sqlite3_blob_bytes()] interface. ^If N or iOffset are less \n** than zero [SQLITE_ERROR] is returned and no data is written.\n**\n** ^An attempt to write to an expired [BLOB handle] fails with an\n** error code of [SQLITE_ABORT].  ^Writes to the BLOB that occurred\n** before the [BLOB handle] expired are not rolled back by the\n** expiration of the handle, though of course those changes might\n** have been overwritten by the statement that expired the BLOB handle\n** or by other independent statements.\n**\n** This routine only works on a [BLOB handle] which has been created\n** by a prior successful call to [sqlite3_blob_open()] and which has not\n** been closed by [sqlite3_blob_close()].  Passing any other pointer in\n** to this routine results in undefined and probably undesirable behavior.\n**\n** See also: [sqlite3_blob_read()].\n*/\nSQLITE_API int sqlite3_blob_write(sqlite3_blob *, const void *z, int n, int iOffset);\n\n/*\n** CAPI3REF: Virtual File System Objects\n**\n** A virtual filesystem (VFS) is an [sqlite3_vfs] object\n** that SQLite uses to interact\n** with the underlying operating system.  Most SQLite builds come with a\n** single default VFS that is appropriate for the host computer.\n** New VFSes can be registered and existing VFSes can be unregistered.\n** The following interfaces are provided.\n**\n** ^The sqlite3_vfs_find() interface returns a pointer to a VFS given its name.\n** ^Names are case sensitive.\n** ^Names are zero-terminated UTF-8 strings.\n** ^If there is no match, a NULL pointer is returned.\n** ^If zVfsName is NULL then the default VFS is returned.\n**\n** ^New VFSes are registered with sqlite3_vfs_register().\n** ^Each new VFS becomes the default VFS if the makeDflt flag is set.\n** ^The same VFS can be registered multiple times without injury.\n** ^To make an existing VFS into the default VFS, register it again\n** with the makeDflt flag set.  If two different VFSes with the\n** same name are registered, the behavior is undefined.  If a\n** VFS is registered with a name that is NULL or an empty string,\n** then the behavior is undefined.\n**\n** ^Unregister a VFS with the sqlite3_vfs_unregister() interface.\n** ^(If the default VFS is unregistered, another VFS is chosen as\n** the default.  The choice for the new VFS is arbitrary.)^\n*/\nSQLITE_API sqlite3_vfs *sqlite3_vfs_find(const char *zVfsName);\nSQLITE_API int sqlite3_vfs_register(sqlite3_vfs*, int makeDflt);\nSQLITE_API int sqlite3_vfs_unregister(sqlite3_vfs*);\n\n/*\n** CAPI3REF: Mutexes\n**\n** The SQLite core uses these routines for thread\n** synchronization. Though they are intended for internal\n** use by SQLite, code that links against SQLite is\n** permitted to use any of these routines.\n**\n** The SQLite source code contains multiple implementations\n** of these mutex routines.  An appropriate implementation\n** is selected automatically at compile-time.  The following\n** implementations are available in the SQLite core:\n**\n** <ul>\n** <li>   SQLITE_MUTEX_PTHREADS\n** <li>   SQLITE_MUTEX_W32\n** <li>   SQLITE_MUTEX_NOOP\n** </ul>\n**\n** The SQLITE_MUTEX_NOOP implementation is a set of routines\n** that does no real locking and is appropriate for use in\n** a single-threaded application.  The SQLITE_MUTEX_PTHREADS and\n** SQLITE_MUTEX_W32 implementations are appropriate for use on Unix\n** and Windows.\n**\n** If SQLite is compiled with the SQLITE_MUTEX_APPDEF preprocessor\n** macro defined (with \"-DSQLITE_MUTEX_APPDEF=1\"), then no mutex\n** implementation is included with the library. In this case the\n** application must supply a custom mutex implementation using the\n** [SQLITE_CONFIG_MUTEX] option of the sqlite3_config() function\n** before calling sqlite3_initialize() or any other public sqlite3_\n** function that calls sqlite3_initialize().\n**\n** ^The sqlite3_mutex_alloc() routine allocates a new\n** mutex and returns a pointer to it. ^The sqlite3_mutex_alloc()\n** routine returns NULL if it is unable to allocate the requested\n** mutex.  The argument to sqlite3_mutex_alloc() must one of these\n** integer constants:\n**\n** <ul>\n** <li>  SQLITE_MUTEX_FAST\n** <li>  SQLITE_MUTEX_RECURSIVE\n** <li>  SQLITE_MUTEX_STATIC_MASTER\n** <li>  SQLITE_MUTEX_STATIC_MEM\n** <li>  SQLITE_MUTEX_STATIC_OPEN\n** <li>  SQLITE_MUTEX_STATIC_PRNG\n** <li>  SQLITE_MUTEX_STATIC_LRU\n** <li>  SQLITE_MUTEX_STATIC_PMEM\n** <li>  SQLITE_MUTEX_STATIC_APP1\n** <li>  SQLITE_MUTEX_STATIC_APP2\n** <li>  SQLITE_MUTEX_STATIC_APP3\n** <li>  SQLITE_MUTEX_STATIC_VFS1\n** <li>  SQLITE_MUTEX_STATIC_VFS2\n** <li>  SQLITE_MUTEX_STATIC_VFS3\n** </ul>\n**\n** ^The first two constants (SQLITE_MUTEX_FAST and SQLITE_MUTEX_RECURSIVE)\n** cause sqlite3_mutex_alloc() to create\n** a new mutex.  ^The new mutex is recursive when SQLITE_MUTEX_RECURSIVE\n** is used but not necessarily so when SQLITE_MUTEX_FAST is used.\n** The mutex implementation does not need to make a distinction\n** between SQLITE_MUTEX_RECURSIVE and SQLITE_MUTEX_FAST if it does\n** not want to.  SQLite will only request a recursive mutex in\n** cases where it really needs one.  If a faster non-recursive mutex\n** implementation is available on the host platform, the mutex subsystem\n** might return such a mutex in response to SQLITE_MUTEX_FAST.\n**\n** ^The other allowed parameters to sqlite3_mutex_alloc() (anything other\n** than SQLITE_MUTEX_FAST and SQLITE_MUTEX_RECURSIVE) each return\n** a pointer to a static preexisting mutex.  ^Nine static mutexes are\n** used by the current version of SQLite.  Future versions of SQLite\n** may add additional static mutexes.  Static mutexes are for internal\n** use by SQLite only.  Applications that use SQLite mutexes should\n** use only the dynamic mutexes returned by SQLITE_MUTEX_FAST or\n** SQLITE_MUTEX_RECURSIVE.\n**\n** ^Note that if one of the dynamic mutex parameters (SQLITE_MUTEX_FAST\n** or SQLITE_MUTEX_RECURSIVE) is used then sqlite3_mutex_alloc()\n** returns a different mutex on every call.  ^For the static\n** mutex types, the same mutex is returned on every call that has\n** the same type number.\n**\n** ^The sqlite3_mutex_free() routine deallocates a previously\n** allocated dynamic mutex.  Attempting to deallocate a static\n** mutex results in undefined behavior.\n**\n** ^The sqlite3_mutex_enter() and sqlite3_mutex_try() routines attempt\n** to enter a mutex.  ^If another thread is already within the mutex,\n** sqlite3_mutex_enter() will block and sqlite3_mutex_try() will return\n** SQLITE_BUSY.  ^The sqlite3_mutex_try() interface returns [SQLITE_OK]\n** upon successful entry.  ^(Mutexes created using\n** SQLITE_MUTEX_RECURSIVE can be entered multiple times by the same thread.\n** In such cases, the\n** mutex must be exited an equal number of times before another thread\n** can enter.)^  If the same thread tries to enter any mutex other\n** than an SQLITE_MUTEX_RECURSIVE more than once, the behavior is undefined.\n**\n** ^(Some systems (for example, Windows 95) do not support the operation\n** implemented by sqlite3_mutex_try().  On those systems, sqlite3_mutex_try()\n** will always return SQLITE_BUSY. The SQLite core only ever uses\n** sqlite3_mutex_try() as an optimization so this is acceptable \n** behavior.)^\n**\n** ^The sqlite3_mutex_leave() routine exits a mutex that was\n** previously entered by the same thread.   The behavior\n** is undefined if the mutex is not currently entered by the\n** calling thread or is not currently allocated.\n**\n** ^If the argument to sqlite3_mutex_enter(), sqlite3_mutex_try(), or\n** sqlite3_mutex_leave() is a NULL pointer, then all three routines\n** behave as no-ops.\n**\n** See also: [sqlite3_mutex_held()] and [sqlite3_mutex_notheld()].\n*/\nSQLITE_API sqlite3_mutex *sqlite3_mutex_alloc(int);\nSQLITE_API void sqlite3_mutex_free(sqlite3_mutex*);\nSQLITE_API void sqlite3_mutex_enter(sqlite3_mutex*);\nSQLITE_API int sqlite3_mutex_try(sqlite3_mutex*);\nSQLITE_API void sqlite3_mutex_leave(sqlite3_mutex*);\n\n/*\n** CAPI3REF: Mutex Methods Object\n**\n** An instance of this structure defines the low-level routines\n** used to allocate and use mutexes.\n**\n** Usually, the default mutex implementations provided by SQLite are\n** sufficient, however the application has the option of substituting a custom\n** implementation for specialized deployments or systems for which SQLite\n** does not provide a suitable implementation. In this case, the application\n** creates and populates an instance of this structure to pass\n** to sqlite3_config() along with the [SQLITE_CONFIG_MUTEX] option.\n** Additionally, an instance of this structure can be used as an\n** output variable when querying the system for the current mutex\n** implementation, using the [SQLITE_CONFIG_GETMUTEX] option.\n**\n** ^The xMutexInit method defined by this structure is invoked as\n** part of system initialization by the sqlite3_initialize() function.\n** ^The xMutexInit routine is called by SQLite exactly once for each\n** effective call to [sqlite3_initialize()].\n**\n** ^The xMutexEnd method defined by this structure is invoked as\n** part of system shutdown by the sqlite3_shutdown() function. The\n** implementation of this method is expected to release all outstanding\n** resources obtained by the mutex methods implementation, especially\n** those obtained by the xMutexInit method.  ^The xMutexEnd()\n** interface is invoked exactly once for each call to [sqlite3_shutdown()].\n**\n** ^(The remaining seven methods defined by this structure (xMutexAlloc,\n** xMutexFree, xMutexEnter, xMutexTry, xMutexLeave, xMutexHeld and\n** xMutexNotheld) implement the following interfaces (respectively):\n**\n** <ul>\n**   <li>  [sqlite3_mutex_alloc()] </li>\n**   <li>  [sqlite3_mutex_free()] </li>\n**   <li>  [sqlite3_mutex_enter()] </li>\n**   <li>  [sqlite3_mutex_try()] </li>\n**   <li>  [sqlite3_mutex_leave()] </li>\n**   <li>  [sqlite3_mutex_held()] </li>\n**   <li>  [sqlite3_mutex_notheld()] </li>\n** </ul>)^\n**\n** The only difference is that the public sqlite3_XXX functions enumerated\n** above silently ignore any invocations that pass a NULL pointer instead\n** of a valid mutex handle. The implementations of the methods defined\n** by this structure are not required to handle this case, the results\n** of passing a NULL pointer instead of a valid mutex handle are undefined\n** (i.e. it is acceptable to provide an implementation that segfaults if\n** it is passed a NULL pointer).\n**\n** The xMutexInit() method must be threadsafe.  It must be harmless to\n** invoke xMutexInit() multiple times within the same process and without\n** intervening calls to xMutexEnd().  Second and subsequent calls to\n** xMutexInit() must be no-ops.\n**\n** xMutexInit() must not use SQLite memory allocation ([sqlite3_malloc()]\n** and its associates).  Similarly, xMutexAlloc() must not use SQLite memory\n** allocation for a static mutex.  ^However xMutexAlloc() may use SQLite\n** memory allocation for a fast or recursive mutex.\n**\n** ^SQLite will invoke the xMutexEnd() method when [sqlite3_shutdown()] is\n** called, but only if the prior call to xMutexInit returned SQLITE_OK.\n** If xMutexInit fails in any way, it is expected to clean up after itself\n** prior to returning.\n*/\ntypedef struct sqlite3_mutex_methods sqlite3_mutex_methods;\nstruct sqlite3_mutex_methods {\n  int (*xMutexInit)(void);\n  int (*xMutexEnd)(void);\n  sqlite3_mutex *(*xMutexAlloc)(int);\n  void (*xMutexFree)(sqlite3_mutex *);\n  void (*xMutexEnter)(sqlite3_mutex *);\n  int (*xMutexTry)(sqlite3_mutex *);\n  void (*xMutexLeave)(sqlite3_mutex *);\n  int (*xMutexHeld)(sqlite3_mutex *);\n  int (*xMutexNotheld)(sqlite3_mutex *);\n};\n\n/*\n** CAPI3REF: Mutex Verification Routines\n**\n** The sqlite3_mutex_held() and sqlite3_mutex_notheld() routines\n** are intended for use inside assert() statements.  The SQLite core\n** never uses these routines except inside an assert() and applications\n** are advised to follow the lead of the core.  The SQLite core only\n** provides implementations for these routines when it is compiled\n** with the SQLITE_DEBUG flag.  External mutex implementations\n** are only required to provide these routines if SQLITE_DEBUG is\n** defined and if NDEBUG is not defined.\n**\n** These routines should return true if the mutex in their argument\n** is held or not held, respectively, by the calling thread.\n**\n** The implementation is not required to provide versions of these\n** routines that actually work. If the implementation does not provide working\n** versions of these routines, it should at least provide stubs that always\n** return true so that one does not get spurious assertion failures.\n**\n** If the argument to sqlite3_mutex_held() is a NULL pointer then\n** the routine should return 1.   This seems counter-intuitive since\n** clearly the mutex cannot be held if it does not exist.  But\n** the reason the mutex does not exist is because the build is not\n** using mutexes.  And we do not want the assert() containing the\n** call to sqlite3_mutex_held() to fail, so a non-zero return is\n** the appropriate thing to do.  The sqlite3_mutex_notheld()\n** interface should also return 1 when given a NULL pointer.\n*/\n#ifndef NDEBUG\nSQLITE_API int sqlite3_mutex_held(sqlite3_mutex*);\nSQLITE_API int sqlite3_mutex_notheld(sqlite3_mutex*);\n#endif\n\n/*\n** CAPI3REF: Mutex Types\n**\n** The [sqlite3_mutex_alloc()] interface takes a single argument\n** which is one of these integer constants.\n**\n** The set of static mutexes may change from one SQLite release to the\n** next.  Applications that override the built-in mutex logic must be\n** prepared to accommodate additional static mutexes.\n*/\n#define SQLITE_MUTEX_FAST             0\n#define SQLITE_MUTEX_RECURSIVE        1\n#define SQLITE_MUTEX_STATIC_MASTER    2\n#define SQLITE_MUTEX_STATIC_MEM       3  /* sqlite3_malloc() */\n#define SQLITE_MUTEX_STATIC_MEM2      4  /* NOT USED */\n#define SQLITE_MUTEX_STATIC_OPEN      4  /* sqlite3BtreeOpen() */\n#define SQLITE_MUTEX_STATIC_PRNG      5  /* sqlite3_randomness() */\n#define SQLITE_MUTEX_STATIC_LRU       6  /* lru page list */\n#define SQLITE_MUTEX_STATIC_LRU2      7  /* NOT USED */\n#define SQLITE_MUTEX_STATIC_PMEM      7  /* sqlite3PageMalloc() */\n#define SQLITE_MUTEX_STATIC_APP1      8  /* For use by application */\n#define SQLITE_MUTEX_STATIC_APP2      9  /* For use by application */\n#define SQLITE_MUTEX_STATIC_APP3     10  /* For use by application */\n#define SQLITE_MUTEX_STATIC_VFS1     11  /* For use by built-in VFS */\n#define SQLITE_MUTEX_STATIC_VFS2     12  /* For use by extension VFS */\n#define SQLITE_MUTEX_STATIC_VFS3     13  /* For use by application VFS */\n\n/*\n** CAPI3REF: Retrieve the mutex for a database connection\n** METHOD: sqlite3\n**\n** ^This interface returns a pointer the [sqlite3_mutex] object that \n** serializes access to the [database connection] given in the argument\n** when the [threading mode] is Serialized.\n** ^If the [threading mode] is Single-thread or Multi-thread then this\n** routine returns a NULL pointer.\n*/\nSQLITE_API sqlite3_mutex *sqlite3_db_mutex(sqlite3*);\n\n/*\n** CAPI3REF: Low-Level Control Of Database Files\n** METHOD: sqlite3\n** KEYWORDS: {file control}\n**\n** ^The [sqlite3_file_control()] interface makes a direct call to the\n** xFileControl method for the [sqlite3_io_methods] object associated\n** with a particular database identified by the second argument. ^The\n** name of the database is \"main\" for the main database or \"temp\" for the\n** TEMP database, or the name that appears after the AS keyword for\n** databases that are added using the [ATTACH] SQL command.\n** ^A NULL pointer can be used in place of \"main\" to refer to the\n** main database file.\n** ^The third and fourth parameters to this routine\n** are passed directly through to the second and third parameters of\n** the xFileControl method.  ^The return value of the xFileControl\n** method becomes the return value of this routine.\n**\n** A few opcodes for [sqlite3_file_control()] are handled directly\n** by the SQLite core and never invoke the \n** sqlite3_io_methods.xFileControl method.\n** ^The [SQLITE_FCNTL_FILE_POINTER] value for the op parameter causes\n** a pointer to the underlying [sqlite3_file] object to be written into\n** the space pointed to by the 4th parameter.  The\n** [SQLITE_FCNTL_JOURNAL_POINTER] works similarly except that it returns\n** the [sqlite3_file] object associated with the journal file instead of\n** the main database.  The [SQLITE_FCNTL_VFS_POINTER] opcode returns\n** a pointer to the underlying [sqlite3_vfs] object for the file.\n** The [SQLITE_FCNTL_DATA_VERSION] returns the data version counter\n** from the pager.\n**\n** ^If the second parameter (zDbName) does not match the name of any\n** open database file, then SQLITE_ERROR is returned.  ^This error\n** code is not remembered and will not be recalled by [sqlite3_errcode()]\n** or [sqlite3_errmsg()].  The underlying xFileControl method might\n** also return SQLITE_ERROR.  There is no way to distinguish between\n** an incorrect zDbName and an SQLITE_ERROR return from the underlying\n** xFileControl method.\n**\n** See also: [file control opcodes]\n*/\nSQLITE_API int sqlite3_file_control(sqlite3*, const char *zDbName, int op, void*);\n\n/*\n** CAPI3REF: Testing Interface\n**\n** ^The sqlite3_test_control() interface is used to read out internal\n** state of SQLite and to inject faults into SQLite for testing\n** purposes.  ^The first parameter is an operation code that determines\n** the number, meaning, and operation of all subsequent parameters.\n**\n** This interface is not for use by applications.  It exists solely\n** for verifying the correct operation of the SQLite library.  Depending\n** on how the SQLite library is compiled, this interface might not exist.\n**\n** The details of the operation codes, their meanings, the parameters\n** they take, and what they do are all subject to change without notice.\n** Unlike most of the SQLite API, this function is not guaranteed to\n** operate consistently from one release to the next.\n*/\nSQLITE_API int sqlite3_test_control(int op, ...);\n\n/*\n** CAPI3REF: Testing Interface Operation Codes\n**\n** These constants are the valid operation code parameters used\n** as the first argument to [sqlite3_test_control()].\n**\n** These parameters and their meanings are subject to change\n** without notice.  These values are for testing purposes only.\n** Applications should not use any of these parameters or the\n** [sqlite3_test_control()] interface.\n*/\n#define SQLITE_TESTCTRL_FIRST                    5\n#define SQLITE_TESTCTRL_PRNG_SAVE                5\n#define SQLITE_TESTCTRL_PRNG_RESTORE             6\n#define SQLITE_TESTCTRL_PRNG_RESET               7\n#define SQLITE_TESTCTRL_BITVEC_TEST              8\n#define SQLITE_TESTCTRL_FAULT_INSTALL            9\n#define SQLITE_TESTCTRL_BENIGN_MALLOC_HOOKS     10\n#define SQLITE_TESTCTRL_PENDING_BYTE            11\n#define SQLITE_TESTCTRL_ASSERT                  12\n#define SQLITE_TESTCTRL_ALWAYS                  13\n#define SQLITE_TESTCTRL_RESERVE                 14\n#define SQLITE_TESTCTRL_OPTIMIZATIONS           15\n#define SQLITE_TESTCTRL_ISKEYWORD               16  /* NOT USED */\n#define SQLITE_TESTCTRL_SCRATCHMALLOC           17  /* NOT USED */\n#define SQLITE_TESTCTRL_INTERNAL_FUNCTIONS      17\n#define SQLITE_TESTCTRL_LOCALTIME_FAULT         18\n#define SQLITE_TESTCTRL_EXPLAIN_STMT            19  /* NOT USED */\n#define SQLITE_TESTCTRL_ONCE_RESET_THRESHOLD    19\n#define SQLITE_TESTCTRL_NEVER_CORRUPT           20\n#define SQLITE_TESTCTRL_VDBE_COVERAGE           21\n#define SQLITE_TESTCTRL_BYTEORDER               22\n#define SQLITE_TESTCTRL_ISINIT                  23\n#define SQLITE_TESTCTRL_SORTER_MMAP             24\n#define SQLITE_TESTCTRL_IMPOSTER                25\n#define SQLITE_TESTCTRL_PARSER_COVERAGE         26\n#define SQLITE_TESTCTRL_LAST                    26  /* Largest TESTCTRL */\n\n/*\n** CAPI3REF: SQL Keyword Checking\n**\n** These routines provide access to the set of SQL language keywords \n** recognized by SQLite.  Applications can uses these routines to determine\n** whether or not a specific identifier needs to be escaped (for example,\n** by enclosing in double-quotes) so as not to confuse the parser.\n**\n** The sqlite3_keyword_count() interface returns the number of distinct\n** keywords understood by SQLite.\n**\n** The sqlite3_keyword_name(N,Z,L) interface finds the N-th keyword and\n** makes *Z point to that keyword expressed as UTF8 and writes the number\n** of bytes in the keyword into *L.  The string that *Z points to is not\n** zero-terminated.  The sqlite3_keyword_name(N,Z,L) routine returns\n** SQLITE_OK if N is within bounds and SQLITE_ERROR if not. If either Z\n** or L are NULL or invalid pointers then calls to\n** sqlite3_keyword_name(N,Z,L) result in undefined behavior.\n**\n** The sqlite3_keyword_check(Z,L) interface checks to see whether or not\n** the L-byte UTF8 identifier that Z points to is a keyword, returning non-zero\n** if it is and zero if not.\n**\n** The parser used by SQLite is forgiving.  It is often possible to use\n** a keyword as an identifier as long as such use does not result in a\n** parsing ambiguity.  For example, the statement\n** \"CREATE TABLE BEGIN(REPLACE,PRAGMA,END);\" is accepted by SQLite, and\n** creates a new table named \"BEGIN\" with three columns named\n** \"REPLACE\", \"PRAGMA\", and \"END\".  Nevertheless, best practice is to avoid\n** using keywords as identifiers.  Common techniques used to avoid keyword\n** name collisions include:\n** <ul>\n** <li> Put all identifier names inside double-quotes.  This is the official\n**      SQL way to escape identifier names.\n** <li> Put identifier names inside &#91;...&#93;.  This is not standard SQL,\n**      but it is what SQL Server does and so lots of programmers use this\n**      technique.\n** <li> Begin every identifier with the letter \"Z\" as no SQL keywords start\n**      with \"Z\".\n** <li> Include a digit somewhere in every identifier name.\n** </ul>\n**\n** Note that the number of keywords understood by SQLite can depend on\n** compile-time options.  For example, \"VACUUM\" is not a keyword if\n** SQLite is compiled with the [-DSQLITE_OMIT_VACUUM] option.  Also,\n** new keywords may be added to future releases of SQLite.\n*/\nSQLITE_API int sqlite3_keyword_count(void);\nSQLITE_API int sqlite3_keyword_name(int,const char**,int*);\nSQLITE_API int sqlite3_keyword_check(const char*,int);\n\n/*\n** CAPI3REF: Dynamic String Object\n** KEYWORDS: {dynamic string}\n**\n** An instance of the sqlite3_str object contains a dynamically-sized\n** string under construction.\n**\n** The lifecycle of an sqlite3_str object is as follows:\n** <ol>\n** <li> ^The sqlite3_str object is created using [sqlite3_str_new()].\n** <li> ^Text is appended to the sqlite3_str object using various\n** methods, such as [sqlite3_str_appendf()].\n** <li> ^The sqlite3_str object is destroyed and the string it created\n** is returned using the [sqlite3_str_finish()] interface.\n** </ol>\n*/\ntypedef struct sqlite3_str sqlite3_str;\n\n/*\n** CAPI3REF: Create A New Dynamic String Object\n** CONSTRUCTOR: sqlite3_str\n**\n** ^The [sqlite3_str_new(D)] interface allocates and initializes\n** a new [sqlite3_str] object.  To avoid memory leaks, the object returned by\n** [sqlite3_str_new()] must be freed by a subsequent call to \n** [sqlite3_str_finish(X)].\n**\n** ^The [sqlite3_str_new(D)] interface always returns a pointer to a\n** valid [sqlite3_str] object, though in the event of an out-of-memory\n** error the returned object might be a special singleton that will\n** silently reject new text, always return SQLITE_NOMEM from \n** [sqlite3_str_errcode()], always return 0 for \n** [sqlite3_str_length()], and always return NULL from\n** [sqlite3_str_finish(X)].  It is always safe to use the value\n** returned by [sqlite3_str_new(D)] as the sqlite3_str parameter\n** to any of the other [sqlite3_str] methods.\n**\n** The D parameter to [sqlite3_str_new(D)] may be NULL.  If the\n** D parameter in [sqlite3_str_new(D)] is not NULL, then the maximum\n** length of the string contained in the [sqlite3_str] object will be\n** the value set for [sqlite3_limit](D,[SQLITE_LIMIT_LENGTH]) instead\n** of [SQLITE_MAX_LENGTH].\n*/\nSQLITE_API sqlite3_str *sqlite3_str_new(sqlite3*);\n\n/*\n** CAPI3REF: Finalize A Dynamic String\n** DESTRUCTOR: sqlite3_str\n**\n** ^The [sqlite3_str_finish(X)] interface destroys the sqlite3_str object X\n** and returns a pointer to a memory buffer obtained from [sqlite3_malloc64()]\n** that contains the constructed string.  The calling application should\n** pass the returned value to [sqlite3_free()] to avoid a memory leak.\n** ^The [sqlite3_str_finish(X)] interface may return a NULL pointer if any\n** errors were encountered during construction of the string.  ^The\n** [sqlite3_str_finish(X)] interface will also return a NULL pointer if the\n** string in [sqlite3_str] object X is zero bytes long.\n*/\nSQLITE_API char *sqlite3_str_finish(sqlite3_str*);\n\n/*\n** CAPI3REF: Add Content To A Dynamic String\n** METHOD: sqlite3_str\n**\n** These interfaces add content to an sqlite3_str object previously obtained\n** from [sqlite3_str_new()].\n**\n** ^The [sqlite3_str_appendf(X,F,...)] and \n** [sqlite3_str_vappendf(X,F,V)] interfaces uses the [built-in printf]\n** functionality of SQLite to append formatted text onto the end of \n** [sqlite3_str] object X.\n**\n** ^The [sqlite3_str_append(X,S,N)] method appends exactly N bytes from string S\n** onto the end of the [sqlite3_str] object X.  N must be non-negative.\n** S must contain at least N non-zero bytes of content.  To append a\n** zero-terminated string in its entirety, use the [sqlite3_str_appendall()]\n** method instead.\n**\n** ^The [sqlite3_str_appendall(X,S)] method appends the complete content of\n** zero-terminated string S onto the end of [sqlite3_str] object X.\n**\n** ^The [sqlite3_str_appendchar(X,N,C)] method appends N copies of the\n** single-byte character C onto the end of [sqlite3_str] object X.\n** ^This method can be used, for example, to add whitespace indentation.\n**\n** ^The [sqlite3_str_reset(X)] method resets the string under construction\n** inside [sqlite3_str] object X back to zero bytes in length.  \n**\n** These methods do not return a result code.  ^If an error occurs, that fact\n** is recorded in the [sqlite3_str] object and can be recovered by a\n** subsequent call to [sqlite3_str_errcode(X)].\n*/\nSQLITE_API void sqlite3_str_appendf(sqlite3_str*, const char *zFormat, ...);\nSQLITE_API void sqlite3_str_vappendf(sqlite3_str*, const char *zFormat, va_list);\nSQLITE_API void sqlite3_str_append(sqlite3_str*, const char *zIn, int N);\nSQLITE_API void sqlite3_str_appendall(sqlite3_str*, const char *zIn);\nSQLITE_API void sqlite3_str_appendchar(sqlite3_str*, int N, char C);\nSQLITE_API void sqlite3_str_reset(sqlite3_str*);\n\n/*\n** CAPI3REF: Status Of A Dynamic String\n** METHOD: sqlite3_str\n**\n** These interfaces return the current status of an [sqlite3_str] object.\n**\n** ^If any prior errors have occurred while constructing the dynamic string\n** in sqlite3_str X, then the [sqlite3_str_errcode(X)] method will return\n** an appropriate error code.  ^The [sqlite3_str_errcode(X)] method returns\n** [SQLITE_NOMEM] following any out-of-memory error, or\n** [SQLITE_TOOBIG] if the size of the dynamic string exceeds\n** [SQLITE_MAX_LENGTH], or [SQLITE_OK] if there have been no errors.\n**\n** ^The [sqlite3_str_length(X)] method returns the current length, in bytes,\n** of the dynamic string under construction in [sqlite3_str] object X.\n** ^The length returned by [sqlite3_str_length(X)] does not include the\n** zero-termination byte.\n**\n** ^The [sqlite3_str_value(X)] method returns a pointer to the current\n** content of the dynamic string under construction in X.  The value\n** returned by [sqlite3_str_value(X)] is managed by the sqlite3_str object X\n** and might be freed or altered by any subsequent method on the same\n** [sqlite3_str] object.  Applications must not used the pointer returned\n** [sqlite3_str_value(X)] after any subsequent method call on the same\n** object.  ^Applications may change the content of the string returned\n** by [sqlite3_str_value(X)] as long as they do not write into any bytes\n** outside the range of 0 to [sqlite3_str_length(X)] and do not read or\n** write any byte after any subsequent sqlite3_str method call.\n*/\nSQLITE_API int sqlite3_str_errcode(sqlite3_str*);\nSQLITE_API int sqlite3_str_length(sqlite3_str*);\nSQLITE_API char *sqlite3_str_value(sqlite3_str*);\n\n/*\n** CAPI3REF: SQLite Runtime Status\n**\n** ^These interfaces are used to retrieve runtime status information\n** about the performance of SQLite, and optionally to reset various\n** highwater marks.  ^The first argument is an integer code for\n** the specific parameter to measure.  ^(Recognized integer codes\n** are of the form [status parameters | SQLITE_STATUS_...].)^\n** ^The current value of the parameter is returned into *pCurrent.\n** ^The highest recorded value is returned in *pHighwater.  ^If the\n** resetFlag is true, then the highest record value is reset after\n** *pHighwater is written.  ^(Some parameters do not record the highest\n** value.  For those parameters\n** nothing is written into *pHighwater and the resetFlag is ignored.)^\n** ^(Other parameters record only the highwater mark and not the current\n** value.  For these latter parameters nothing is written into *pCurrent.)^\n**\n** ^The sqlite3_status() and sqlite3_status64() routines return\n** SQLITE_OK on success and a non-zero [error code] on failure.\n**\n** If either the current value or the highwater mark is too large to\n** be represented by a 32-bit integer, then the values returned by\n** sqlite3_status() are undefined.\n**\n** See also: [sqlite3_db_status()]\n*/\nSQLITE_API int sqlite3_status(int op, int *pCurrent, int *pHighwater, int resetFlag);\nSQLITE_API int sqlite3_status64(\n  int op,\n  sqlite3_int64 *pCurrent,\n  sqlite3_int64 *pHighwater,\n  int resetFlag\n);\n\n\n/*\n** CAPI3REF: Status Parameters\n** KEYWORDS: {status parameters}\n**\n** These integer constants designate various run-time status parameters\n** that can be returned by [sqlite3_status()].\n**\n** <dl>\n** [[SQLITE_STATUS_MEMORY_USED]] ^(<dt>SQLITE_STATUS_MEMORY_USED</dt>\n** <dd>This parameter is the current amount of memory checked out\n** using [sqlite3_malloc()], either directly or indirectly.  The\n** figure includes calls made to [sqlite3_malloc()] by the application\n** and internal memory usage by the SQLite library.  Auxiliary page-cache\n** memory controlled by [SQLITE_CONFIG_PAGECACHE] is not included in\n** this parameter.  The amount returned is the sum of the allocation\n** sizes as reported by the xSize method in [sqlite3_mem_methods].</dd>)^\n**\n** [[SQLITE_STATUS_MALLOC_SIZE]] ^(<dt>SQLITE_STATUS_MALLOC_SIZE</dt>\n** <dd>This parameter records the largest memory allocation request\n** handed to [sqlite3_malloc()] or [sqlite3_realloc()] (or their\n** internal equivalents).  Only the value returned in the\n** *pHighwater parameter to [sqlite3_status()] is of interest.  \n** The value written into the *pCurrent parameter is undefined.</dd>)^\n**\n** [[SQLITE_STATUS_MALLOC_COUNT]] ^(<dt>SQLITE_STATUS_MALLOC_COUNT</dt>\n** <dd>This parameter records the number of separate memory allocations\n** currently checked out.</dd>)^\n**\n** [[SQLITE_STATUS_PAGECACHE_USED]] ^(<dt>SQLITE_STATUS_PAGECACHE_USED</dt>\n** <dd>This parameter returns the number of pages used out of the\n** [pagecache memory allocator] that was configured using \n** [SQLITE_CONFIG_PAGECACHE].  The\n** value returned is in pages, not in bytes.</dd>)^\n**\n** [[SQLITE_STATUS_PAGECACHE_OVERFLOW]] \n** ^(<dt>SQLITE_STATUS_PAGECACHE_OVERFLOW</dt>\n** <dd>This parameter returns the number of bytes of page cache\n** allocation which could not be satisfied by the [SQLITE_CONFIG_PAGECACHE]\n** buffer and where forced to overflow to [sqlite3_malloc()].  The\n** returned value includes allocations that overflowed because they\n** where too large (they were larger than the \"sz\" parameter to\n** [SQLITE_CONFIG_PAGECACHE]) and allocations that overflowed because\n** no space was left in the page cache.</dd>)^\n**\n** [[SQLITE_STATUS_PAGECACHE_SIZE]] ^(<dt>SQLITE_STATUS_PAGECACHE_SIZE</dt>\n** <dd>This parameter records the largest memory allocation request\n** handed to [pagecache memory allocator].  Only the value returned in the\n** *pHighwater parameter to [sqlite3_status()] is of interest.  \n** The value written into the *pCurrent parameter is undefined.</dd>)^\n**\n** [[SQLITE_STATUS_SCRATCH_USED]] <dt>SQLITE_STATUS_SCRATCH_USED</dt>\n** <dd>No longer used.</dd>\n**\n** [[SQLITE_STATUS_SCRATCH_OVERFLOW]] ^(<dt>SQLITE_STATUS_SCRATCH_OVERFLOW</dt>\n** <dd>No longer used.</dd>\n**\n** [[SQLITE_STATUS_SCRATCH_SIZE]] <dt>SQLITE_STATUS_SCRATCH_SIZE</dt>\n** <dd>No longer used.</dd>\n**\n** [[SQLITE_STATUS_PARSER_STACK]] ^(<dt>SQLITE_STATUS_PARSER_STACK</dt>\n** <dd>The *pHighwater parameter records the deepest parser stack. \n** The *pCurrent value is undefined.  The *pHighwater value is only\n** meaningful if SQLite is compiled with [YYTRACKMAXSTACKDEPTH].</dd>)^\n** </dl>\n**\n** New status parameters may be added from time to time.\n*/\n#define SQLITE_STATUS_MEMORY_USED          0\n#define SQLITE_STATUS_PAGECACHE_USED       1\n#define SQLITE_STATUS_PAGECACHE_OVERFLOW   2\n#define SQLITE_STATUS_SCRATCH_USED         3  /* NOT USED */\n#define SQLITE_STATUS_SCRATCH_OVERFLOW     4  /* NOT USED */\n#define SQLITE_STATUS_MALLOC_SIZE          5\n#define SQLITE_STATUS_PARSER_STACK         6\n#define SQLITE_STATUS_PAGECACHE_SIZE       7\n#define SQLITE_STATUS_SCRATCH_SIZE         8  /* NOT USED */\n#define SQLITE_STATUS_MALLOC_COUNT         9\n\n/*\n** CAPI3REF: Database Connection Status\n** METHOD: sqlite3\n**\n** ^This interface is used to retrieve runtime status information \n** about a single [database connection].  ^The first argument is the\n** database connection object to be interrogated.  ^The second argument\n** is an integer constant, taken from the set of\n** [SQLITE_DBSTATUS options], that\n** determines the parameter to interrogate.  The set of \n** [SQLITE_DBSTATUS options] is likely\n** to grow in future releases of SQLite.\n**\n** ^The current value of the requested parameter is written into *pCur\n** and the highest instantaneous value is written into *pHiwtr.  ^If\n** the resetFlg is true, then the highest instantaneous value is\n** reset back down to the current value.\n**\n** ^The sqlite3_db_status() routine returns SQLITE_OK on success and a\n** non-zero [error code] on failure.\n**\n** See also: [sqlite3_status()] and [sqlite3_stmt_status()].\n*/\nSQLITE_API int sqlite3_db_status(sqlite3*, int op, int *pCur, int *pHiwtr, int resetFlg);\n\n/*\n** CAPI3REF: Status Parameters for database connections\n** KEYWORDS: {SQLITE_DBSTATUS options}\n**\n** These constants are the available integer \"verbs\" that can be passed as\n** the second argument to the [sqlite3_db_status()] interface.\n**\n** New verbs may be added in future releases of SQLite. Existing verbs\n** might be discontinued. Applications should check the return code from\n** [sqlite3_db_status()] to make sure that the call worked.\n** The [sqlite3_db_status()] interface will return a non-zero error code\n** if a discontinued or unsupported verb is invoked.\n**\n** <dl>\n** [[SQLITE_DBSTATUS_LOOKASIDE_USED]] ^(<dt>SQLITE_DBSTATUS_LOOKASIDE_USED</dt>\n** <dd>This parameter returns the number of lookaside memory slots currently\n** checked out.</dd>)^\n**\n** [[SQLITE_DBSTATUS_LOOKASIDE_HIT]] ^(<dt>SQLITE_DBSTATUS_LOOKASIDE_HIT</dt>\n** <dd>This parameter returns the number malloc attempts that were \n** satisfied using lookaside memory. Only the high-water value is meaningful;\n** the current value is always zero.)^\n**\n** [[SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE]]\n** ^(<dt>SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE</dt>\n** <dd>This parameter returns the number malloc attempts that might have\n** been satisfied using lookaside memory but failed due to the amount of\n** memory requested being larger than the lookaside slot size.\n** Only the high-water value is meaningful;\n** the current value is always zero.)^\n**\n** [[SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL]]\n** ^(<dt>SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL</dt>\n** <dd>This parameter returns the number malloc attempts that might have\n** been satisfied using lookaside memory but failed due to all lookaside\n** memory already being in use.\n** Only the high-water value is meaningful;\n** the current value is always zero.)^\n**\n** [[SQLITE_DBSTATUS_CACHE_USED]] ^(<dt>SQLITE_DBSTATUS_CACHE_USED</dt>\n** <dd>This parameter returns the approximate number of bytes of heap\n** memory used by all pager caches associated with the database connection.)^\n** ^The highwater mark associated with SQLITE_DBSTATUS_CACHE_USED is always 0.\n**\n** [[SQLITE_DBSTATUS_CACHE_USED_SHARED]] \n** ^(<dt>SQLITE_DBSTATUS_CACHE_USED_SHARED</dt>\n** <dd>This parameter is similar to DBSTATUS_CACHE_USED, except that if a\n** pager cache is shared between two or more connections the bytes of heap\n** memory used by that pager cache is divided evenly between the attached\n** connections.)^  In other words, if none of the pager caches associated\n** with the database connection are shared, this request returns the same\n** value as DBSTATUS_CACHE_USED. Or, if one or more or the pager caches are\n** shared, the value returned by this call will be smaller than that returned\n** by DBSTATUS_CACHE_USED. ^The highwater mark associated with\n** SQLITE_DBSTATUS_CACHE_USED_SHARED is always 0.\n**\n** [[SQLITE_DBSTATUS_SCHEMA_USED]] ^(<dt>SQLITE_DBSTATUS_SCHEMA_USED</dt>\n** <dd>This parameter returns the approximate number of bytes of heap\n** memory used to store the schema for all databases associated\n** with the connection - main, temp, and any [ATTACH]-ed databases.)^ \n** ^The full amount of memory used by the schemas is reported, even if the\n** schema memory is shared with other database connections due to\n** [shared cache mode] being enabled.\n** ^The highwater mark associated with SQLITE_DBSTATUS_SCHEMA_USED is always 0.\n**\n** [[SQLITE_DBSTATUS_STMT_USED]] ^(<dt>SQLITE_DBSTATUS_STMT_USED</dt>\n** <dd>This parameter returns the approximate number of bytes of heap\n** and lookaside memory used by all prepared statements associated with\n** the database connection.)^\n** ^The highwater mark associated with SQLITE_DBSTATUS_STMT_USED is always 0.\n** </dd>\n**\n** [[SQLITE_DBSTATUS_CACHE_HIT]] ^(<dt>SQLITE_DBSTATUS_CACHE_HIT</dt>\n** <dd>This parameter returns the number of pager cache hits that have\n** occurred.)^ ^The highwater mark associated with SQLITE_DBSTATUS_CACHE_HIT \n** is always 0.\n** </dd>\n**\n** [[SQLITE_DBSTATUS_CACHE_MISS]] ^(<dt>SQLITE_DBSTATUS_CACHE_MISS</dt>\n** <dd>This parameter returns the number of pager cache misses that have\n** occurred.)^ ^The highwater mark associated with SQLITE_DBSTATUS_CACHE_MISS \n** is always 0.\n** </dd>\n**\n** [[SQLITE_DBSTATUS_CACHE_WRITE]] ^(<dt>SQLITE_DBSTATUS_CACHE_WRITE</dt>\n** <dd>This parameter returns the number of dirty cache entries that have\n** been written to disk. Specifically, the number of pages written to the\n** wal file in wal mode databases, or the number of pages written to the\n** database file in rollback mode databases. Any pages written as part of\n** transaction rollback or database recovery operations are not included.\n** If an IO or other error occurs while writing a page to disk, the effect\n** on subsequent SQLITE_DBSTATUS_CACHE_WRITE requests is undefined.)^ ^The\n** highwater mark associated with SQLITE_DBSTATUS_CACHE_WRITE is always 0.\n** </dd>\n**\n** [[SQLITE_DBSTATUS_CACHE_SPILL]] ^(<dt>SQLITE_DBSTATUS_CACHE_SPILL</dt>\n** <dd>This parameter returns the number of dirty cache entries that have\n** been written to disk in the middle of a transaction due to the page\n** cache overflowing. Transactions are more efficient if they are written\n** to disk all at once. When pages spill mid-transaction, that introduces\n** additional overhead. This parameter can be used help identify\n** inefficiencies that can be resolve by increasing the cache size.\n** </dd>\n**\n** [[SQLITE_DBSTATUS_DEFERRED_FKS]] ^(<dt>SQLITE_DBSTATUS_DEFERRED_FKS</dt>\n** <dd>This parameter returns zero for the current value if and only if\n** all foreign key constraints (deferred or immediate) have been\n** resolved.)^  ^The highwater mark is always 0.\n** </dd>\n** </dl>\n*/\n#define SQLITE_DBSTATUS_LOOKASIDE_USED       0\n#define SQLITE_DBSTATUS_CACHE_USED           1\n#define SQLITE_DBSTATUS_SCHEMA_USED          2\n#define SQLITE_DBSTATUS_STMT_USED            3\n#define SQLITE_DBSTATUS_LOOKASIDE_HIT        4\n#define SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE  5\n#define SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL  6\n#define SQLITE_DBSTATUS_CACHE_HIT            7\n#define SQLITE_DBSTATUS_CACHE_MISS           8\n#define SQLITE_DBSTATUS_CACHE_WRITE          9\n#define SQLITE_DBSTATUS_DEFERRED_FKS        10\n#define SQLITE_DBSTATUS_CACHE_USED_SHARED   11\n#define SQLITE_DBSTATUS_CACHE_SPILL         12\n#define SQLITE_DBSTATUS_MAX                 12   /* Largest defined DBSTATUS */\n\n\n/*\n** CAPI3REF: Prepared Statement Status\n** METHOD: sqlite3_stmt\n**\n** ^(Each prepared statement maintains various\n** [SQLITE_STMTSTATUS counters] that measure the number\n** of times it has performed specific operations.)^  These counters can\n** be used to monitor the performance characteristics of the prepared\n** statements.  For example, if the number of table steps greatly exceeds\n** the number of table searches or result rows, that would tend to indicate\n** that the prepared statement is using a full table scan rather than\n** an index.  \n**\n** ^(This interface is used to retrieve and reset counter values from\n** a [prepared statement].  The first argument is the prepared statement\n** object to be interrogated.  The second argument\n** is an integer code for a specific [SQLITE_STMTSTATUS counter]\n** to be interrogated.)^\n** ^The current value of the requested counter is returned.\n** ^If the resetFlg is true, then the counter is reset to zero after this\n** interface call returns.\n**\n** See also: [sqlite3_status()] and [sqlite3_db_status()].\n*/\nSQLITE_API int sqlite3_stmt_status(sqlite3_stmt*, int op,int resetFlg);\n\n/*\n** CAPI3REF: Status Parameters for prepared statements\n** KEYWORDS: {SQLITE_STMTSTATUS counter} {SQLITE_STMTSTATUS counters}\n**\n** These preprocessor macros define integer codes that name counter\n** values associated with the [sqlite3_stmt_status()] interface.\n** The meanings of the various counters are as follows:\n**\n** <dl>\n** [[SQLITE_STMTSTATUS_FULLSCAN_STEP]] <dt>SQLITE_STMTSTATUS_FULLSCAN_STEP</dt>\n** <dd>^This is the number of times that SQLite has stepped forward in\n** a table as part of a full table scan.  Large numbers for this counter\n** may indicate opportunities for performance improvement through \n** careful use of indices.</dd>\n**\n** [[SQLITE_STMTSTATUS_SORT]] <dt>SQLITE_STMTSTATUS_SORT</dt>\n** <dd>^This is the number of sort operations that have occurred.\n** A non-zero value in this counter may indicate an opportunity to\n** improvement performance through careful use of indices.</dd>\n**\n** [[SQLITE_STMTSTATUS_AUTOINDEX]] <dt>SQLITE_STMTSTATUS_AUTOINDEX</dt>\n** <dd>^This is the number of rows inserted into transient indices that\n** were created automatically in order to help joins run faster.\n** A non-zero value in this counter may indicate an opportunity to\n** improvement performance by adding permanent indices that do not\n** need to be reinitialized each time the statement is run.</dd>\n**\n** [[SQLITE_STMTSTATUS_VM_STEP]] <dt>SQLITE_STMTSTATUS_VM_STEP</dt>\n** <dd>^This is the number of virtual machine operations executed\n** by the prepared statement if that number is less than or equal\n** to 2147483647.  The number of virtual machine operations can be \n** used as a proxy for the total work done by the prepared statement.\n** If the number of virtual machine operations exceeds 2147483647\n** then the value returned by this statement status code is undefined.\n**\n** [[SQLITE_STMTSTATUS_REPREPARE]] <dt>SQLITE_STMTSTATUS_REPREPARE</dt>\n** <dd>^This is the number of times that the prepare statement has been\n** automatically regenerated due to schema changes or change to \n** [bound parameters] that might affect the query plan.\n**\n** [[SQLITE_STMTSTATUS_RUN]] <dt>SQLITE_STMTSTATUS_RUN</dt>\n** <dd>^This is the number of times that the prepared statement has\n** been run.  A single \"run\" for the purposes of this counter is one\n** or more calls to [sqlite3_step()] followed by a call to [sqlite3_reset()].\n** The counter is incremented on the first [sqlite3_step()] call of each\n** cycle.\n**\n** [[SQLITE_STMTSTATUS_MEMUSED]] <dt>SQLITE_STMTSTATUS_MEMUSED</dt>\n** <dd>^This is the approximate number of bytes of heap memory\n** used to store the prepared statement.  ^This value is not actually\n** a counter, and so the resetFlg parameter to sqlite3_stmt_status()\n** is ignored when the opcode is SQLITE_STMTSTATUS_MEMUSED.\n** </dd>\n** </dl>\n*/\n#define SQLITE_STMTSTATUS_FULLSCAN_STEP     1\n#define SQLITE_STMTSTATUS_SORT              2\n#define SQLITE_STMTSTATUS_AUTOINDEX         3\n#define SQLITE_STMTSTATUS_VM_STEP           4\n#define SQLITE_STMTSTATUS_REPREPARE         5\n#define SQLITE_STMTSTATUS_RUN               6\n#define SQLITE_STMTSTATUS_MEMUSED           99\n\n/*\n** CAPI3REF: Custom Page Cache Object\n**\n** The sqlite3_pcache type is opaque.  It is implemented by\n** the pluggable module.  The SQLite core has no knowledge of\n** its size or internal structure and never deals with the\n** sqlite3_pcache object except by holding and passing pointers\n** to the object.\n**\n** See [sqlite3_pcache_methods2] for additional information.\n*/\ntypedef struct sqlite3_pcache sqlite3_pcache;\n\n/*\n** CAPI3REF: Custom Page Cache Object\n**\n** The sqlite3_pcache_page object represents a single page in the\n** page cache.  The page cache will allocate instances of this\n** object.  Various methods of the page cache use pointers to instances\n** of this object as parameters or as their return value.\n**\n** See [sqlite3_pcache_methods2] for additional information.\n*/\ntypedef struct sqlite3_pcache_page sqlite3_pcache_page;\nstruct sqlite3_pcache_page {\n  void *pBuf;        /* The content of the page */\n  void *pExtra;      /* Extra information associated with the page */\n};\n\n/*\n** CAPI3REF: Application Defined Page Cache.\n** KEYWORDS: {page cache}\n**\n** ^(The [sqlite3_config]([SQLITE_CONFIG_PCACHE2], ...) interface can\n** register an alternative page cache implementation by passing in an \n** instance of the sqlite3_pcache_methods2 structure.)^\n** In many applications, most of the heap memory allocated by \n** SQLite is used for the page cache.\n** By implementing a \n** custom page cache using this API, an application can better control\n** the amount of memory consumed by SQLite, the way in which \n** that memory is allocated and released, and the policies used to \n** determine exactly which parts of a database file are cached and for \n** how long.\n**\n** The alternative page cache mechanism is an\n** extreme measure that is only needed by the most demanding applications.\n** The built-in page cache is recommended for most uses.\n**\n** ^(The contents of the sqlite3_pcache_methods2 structure are copied to an\n** internal buffer by SQLite within the call to [sqlite3_config].  Hence\n** the application may discard the parameter after the call to\n** [sqlite3_config()] returns.)^\n**\n** [[the xInit() page cache method]]\n** ^(The xInit() method is called once for each effective \n** call to [sqlite3_initialize()])^\n** (usually only once during the lifetime of the process). ^(The xInit()\n** method is passed a copy of the sqlite3_pcache_methods2.pArg value.)^\n** The intent of the xInit() method is to set up global data structures \n** required by the custom page cache implementation. \n** ^(If the xInit() method is NULL, then the \n** built-in default page cache is used instead of the application defined\n** page cache.)^\n**\n** [[the xShutdown() page cache method]]\n** ^The xShutdown() method is called by [sqlite3_shutdown()].\n** It can be used to clean up \n** any outstanding resources before process shutdown, if required.\n** ^The xShutdown() method may be NULL.\n**\n** ^SQLite automatically serializes calls to the xInit method,\n** so the xInit method need not be threadsafe.  ^The\n** xShutdown method is only called from [sqlite3_shutdown()] so it does\n** not need to be threadsafe either.  All other methods must be threadsafe\n** in multithreaded applications.\n**\n** ^SQLite will never invoke xInit() more than once without an intervening\n** call to xShutdown().\n**\n** [[the xCreate() page cache methods]]\n** ^SQLite invokes the xCreate() method to construct a new cache instance.\n** SQLite will typically create one cache instance for each open database file,\n** though this is not guaranteed. ^The\n** first parameter, szPage, is the size in bytes of the pages that must\n** be allocated by the cache.  ^szPage will always a power of two.  ^The\n** second parameter szExtra is a number of bytes of extra storage \n** associated with each page cache entry.  ^The szExtra parameter will\n** a number less than 250.  SQLite will use the\n** extra szExtra bytes on each page to store metadata about the underlying\n** database page on disk.  The value passed into szExtra depends\n** on the SQLite version, the target platform, and how SQLite was compiled.\n** ^The third argument to xCreate(), bPurgeable, is true if the cache being\n** created will be used to cache database pages of a file stored on disk, or\n** false if it is used for an in-memory database. The cache implementation\n** does not have to do anything special based with the value of bPurgeable;\n** it is purely advisory.  ^On a cache where bPurgeable is false, SQLite will\n** never invoke xUnpin() except to deliberately delete a page.\n** ^In other words, calls to xUnpin() on a cache with bPurgeable set to\n** false will always have the \"discard\" flag set to true.  \n** ^Hence, a cache created with bPurgeable false will\n** never contain any unpinned pages.\n**\n** [[the xCachesize() page cache method]]\n** ^(The xCachesize() method may be called at any time by SQLite to set the\n** suggested maximum cache-size (number of pages stored by) the cache\n** instance passed as the first argument. This is the value configured using\n** the SQLite \"[PRAGMA cache_size]\" command.)^  As with the bPurgeable\n** parameter, the implementation is not required to do anything with this\n** value; it is advisory only.\n**\n** [[the xPagecount() page cache methods]]\n** The xPagecount() method must return the number of pages currently\n** stored in the cache, both pinned and unpinned.\n** \n** [[the xFetch() page cache methods]]\n** The xFetch() method locates a page in the cache and returns a pointer to \n** an sqlite3_pcache_page object associated with that page, or a NULL pointer.\n** The pBuf element of the returned sqlite3_pcache_page object will be a\n** pointer to a buffer of szPage bytes used to store the content of a \n** single database page.  The pExtra element of sqlite3_pcache_page will be\n** a pointer to the szExtra bytes of extra storage that SQLite has requested\n** for each entry in the page cache.\n**\n** The page to be fetched is determined by the key. ^The minimum key value\n** is 1.  After it has been retrieved using xFetch, the page is considered\n** to be \"pinned\".\n**\n** If the requested page is already in the page cache, then the page cache\n** implementation must return a pointer to the page buffer with its content\n** intact.  If the requested page is not already in the cache, then the\n** cache implementation should use the value of the createFlag\n** parameter to help it determined what action to take:\n**\n** <table border=1 width=85% align=center>\n** <tr><th> createFlag <th> Behavior when page is not already in cache\n** <tr><td> 0 <td> Do not allocate a new page.  Return NULL.\n** <tr><td> 1 <td> Allocate a new page if it easy and convenient to do so.\n**                 Otherwise return NULL.\n** <tr><td> 2 <td> Make every effort to allocate a new page.  Only return\n**                 NULL if allocating a new page is effectively impossible.\n** </table>\n**\n** ^(SQLite will normally invoke xFetch() with a createFlag of 0 or 1.  SQLite\n** will only use a createFlag of 2 after a prior call with a createFlag of 1\n** failed.)^  In between the to xFetch() calls, SQLite may\n** attempt to unpin one or more cache pages by spilling the content of\n** pinned pages to disk and synching the operating system disk cache.\n**\n** [[the xUnpin() page cache method]]\n** ^xUnpin() is called by SQLite with a pointer to a currently pinned page\n** as its second argument.  If the third parameter, discard, is non-zero,\n** then the page must be evicted from the cache.\n** ^If the discard parameter is\n** zero, then the page may be discarded or retained at the discretion of\n** page cache implementation. ^The page cache implementation\n** may choose to evict unpinned pages at any time.\n**\n** The cache must not perform any reference counting. A single \n** call to xUnpin() unpins the page regardless of the number of prior calls \n** to xFetch().\n**\n** [[the xRekey() page cache methods]]\n** The xRekey() method is used to change the key value associated with the\n** page passed as the second argument. If the cache\n** previously contains an entry associated with newKey, it must be\n** discarded. ^Any prior cache entry associated with newKey is guaranteed not\n** to be pinned.\n**\n** When SQLite calls the xTruncate() method, the cache must discard all\n** existing cache entries with page numbers (keys) greater than or equal\n** to the value of the iLimit parameter passed to xTruncate(). If any\n** of these pages are pinned, they are implicitly unpinned, meaning that\n** they can be safely discarded.\n**\n** [[the xDestroy() page cache method]]\n** ^The xDestroy() method is used to delete a cache allocated by xCreate().\n** All resources associated with the specified cache should be freed. ^After\n** calling the xDestroy() method, SQLite considers the [sqlite3_pcache*]\n** handle invalid, and will not use it with any other sqlite3_pcache_methods2\n** functions.\n**\n** [[the xShrink() page cache method]]\n** ^SQLite invokes the xShrink() method when it wants the page cache to\n** free up as much of heap memory as possible.  The page cache implementation\n** is not obligated to free any memory, but well-behaved implementations should\n** do their best.\n*/\ntypedef struct sqlite3_pcache_methods2 sqlite3_pcache_methods2;\nstruct sqlite3_pcache_methods2 {\n  int iVersion;\n  void *pArg;\n  int (*xInit)(void*);\n  void (*xShutdown)(void*);\n  sqlite3_pcache *(*xCreate)(int szPage, int szExtra, int bPurgeable);\n  void (*xCachesize)(sqlite3_pcache*, int nCachesize);\n  int (*xPagecount)(sqlite3_pcache*);\n  sqlite3_pcache_page *(*xFetch)(sqlite3_pcache*, unsigned key, int createFlag);\n  void (*xUnpin)(sqlite3_pcache*, sqlite3_pcache_page*, int discard);\n  void (*xRekey)(sqlite3_pcache*, sqlite3_pcache_page*, \n      unsigned oldKey, unsigned newKey);\n  void (*xTruncate)(sqlite3_pcache*, unsigned iLimit);\n  void (*xDestroy)(sqlite3_pcache*);\n  void (*xShrink)(sqlite3_pcache*);\n};\n\n/*\n** This is the obsolete pcache_methods object that has now been replaced\n** by sqlite3_pcache_methods2.  This object is not used by SQLite.  It is\n** retained in the header file for backwards compatibility only.\n*/\ntypedef struct sqlite3_pcache_methods sqlite3_pcache_methods;\nstruct sqlite3_pcache_methods {\n  void *pArg;\n  int (*xInit)(void*);\n  void (*xShutdown)(void*);\n  sqlite3_pcache *(*xCreate)(int szPage, int bPurgeable);\n  void (*xCachesize)(sqlite3_pcache*, int nCachesize);\n  int (*xPagecount)(sqlite3_pcache*);\n  void *(*xFetch)(sqlite3_pcache*, unsigned key, int createFlag);\n  void (*xUnpin)(sqlite3_pcache*, void*, int discard);\n  void (*xRekey)(sqlite3_pcache*, void*, unsigned oldKey, unsigned newKey);\n  void (*xTruncate)(sqlite3_pcache*, unsigned iLimit);\n  void (*xDestroy)(sqlite3_pcache*);\n};\n\n\n/*\n** CAPI3REF: Online Backup Object\n**\n** The sqlite3_backup object records state information about an ongoing\n** online backup operation.  ^The sqlite3_backup object is created by\n** a call to [sqlite3_backup_init()] and is destroyed by a call to\n** [sqlite3_backup_finish()].\n**\n** See Also: [Using the SQLite Online Backup API]\n*/\ntypedef struct sqlite3_backup sqlite3_backup;\n\n/*\n** CAPI3REF: Online Backup API.\n**\n** The backup API copies the content of one database into another.\n** It is useful either for creating backups of databases or\n** for copying in-memory databases to or from persistent files. \n**\n** See Also: [Using the SQLite Online Backup API]\n**\n** ^SQLite holds a write transaction open on the destination database file\n** for the duration of the backup operation.\n** ^The source database is read-locked only while it is being read;\n** it is not locked continuously for the entire backup operation.\n** ^Thus, the backup may be performed on a live source database without\n** preventing other database connections from\n** reading or writing to the source database while the backup is underway.\n** \n** ^(To perform a backup operation: \n**   <ol>\n**     <li><b>sqlite3_backup_init()</b> is called once to initialize the\n**         backup, \n**     <li><b>sqlite3_backup_step()</b> is called one or more times to transfer \n**         the data between the two databases, and finally\n**     <li><b>sqlite3_backup_finish()</b> is called to release all resources \n**         associated with the backup operation. \n**   </ol>)^\n** There should be exactly one call to sqlite3_backup_finish() for each\n** successful call to sqlite3_backup_init().\n**\n** [[sqlite3_backup_init()]] <b>sqlite3_backup_init()</b>\n**\n** ^The D and N arguments to sqlite3_backup_init(D,N,S,M) are the \n** [database connection] associated with the destination database \n** and the database name, respectively.\n** ^The database name is \"main\" for the main database, \"temp\" for the\n** temporary database, or the name specified after the AS keyword in\n** an [ATTACH] statement for an attached database.\n** ^The S and M arguments passed to \n** sqlite3_backup_init(D,N,S,M) identify the [database connection]\n** and database name of the source database, respectively.\n** ^The source and destination [database connections] (parameters S and D)\n** must be different or else sqlite3_backup_init(D,N,S,M) will fail with\n** an error.\n**\n** ^A call to sqlite3_backup_init() will fail, returning NULL, if \n** there is already a read or read-write transaction open on the \n** destination database.\n**\n** ^If an error occurs within sqlite3_backup_init(D,N,S,M), then NULL is\n** returned and an error code and error message are stored in the\n** destination [database connection] D.\n** ^The error code and message for the failed call to sqlite3_backup_init()\n** can be retrieved using the [sqlite3_errcode()], [sqlite3_errmsg()], and/or\n** [sqlite3_errmsg16()] functions.\n** ^A successful call to sqlite3_backup_init() returns a pointer to an\n** [sqlite3_backup] object.\n** ^The [sqlite3_backup] object may be used with the sqlite3_backup_step() and\n** sqlite3_backup_finish() functions to perform the specified backup \n** operation.\n**\n** [[sqlite3_backup_step()]] <b>sqlite3_backup_step()</b>\n**\n** ^Function sqlite3_backup_step(B,N) will copy up to N pages between \n** the source and destination databases specified by [sqlite3_backup] object B.\n** ^If N is negative, all remaining source pages are copied. \n** ^If sqlite3_backup_step(B,N) successfully copies N pages and there\n** are still more pages to be copied, then the function returns [SQLITE_OK].\n** ^If sqlite3_backup_step(B,N) successfully finishes copying all pages\n** from source to destination, then it returns [SQLITE_DONE].\n** ^If an error occurs while running sqlite3_backup_step(B,N),\n** then an [error code] is returned. ^As well as [SQLITE_OK] and\n** [SQLITE_DONE], a call to sqlite3_backup_step() may return [SQLITE_READONLY],\n** [SQLITE_NOMEM], [SQLITE_BUSY], [SQLITE_LOCKED], or an\n** [SQLITE_IOERR_ACCESS | SQLITE_IOERR_XXX] extended error code.\n**\n** ^(The sqlite3_backup_step() might return [SQLITE_READONLY] if\n** <ol>\n** <li> the destination database was opened read-only, or\n** <li> the destination database is using write-ahead-log journaling\n** and the destination and source page sizes differ, or\n** <li> the destination database is an in-memory database and the\n** destination and source page sizes differ.\n** </ol>)^\n**\n** ^If sqlite3_backup_step() cannot obtain a required file-system lock, then\n** the [sqlite3_busy_handler | busy-handler function]\n** is invoked (if one is specified). ^If the \n** busy-handler returns non-zero before the lock is available, then \n** [SQLITE_BUSY] is returned to the caller. ^In this case the call to\n** sqlite3_backup_step() can be retried later. ^If the source\n** [database connection]\n** is being used to write to the source database when sqlite3_backup_step()\n** is called, then [SQLITE_LOCKED] is returned immediately. ^Again, in this\n** case the call to sqlite3_backup_step() can be retried later on. ^(If\n** [SQLITE_IOERR_ACCESS | SQLITE_IOERR_XXX], [SQLITE_NOMEM], or\n** [SQLITE_READONLY] is returned, then \n** there is no point in retrying the call to sqlite3_backup_step(). These \n** errors are considered fatal.)^  The application must accept \n** that the backup operation has failed and pass the backup operation handle \n** to the sqlite3_backup_finish() to release associated resources.\n**\n** ^The first call to sqlite3_backup_step() obtains an exclusive lock\n** on the destination file. ^The exclusive lock is not released until either \n** sqlite3_backup_finish() is called or the backup operation is complete \n** and sqlite3_backup_step() returns [SQLITE_DONE].  ^Every call to\n** sqlite3_backup_step() obtains a [shared lock] on the source database that\n** lasts for the duration of the sqlite3_backup_step() call.\n** ^Because the source database is not locked between calls to\n** sqlite3_backup_step(), the source database may be modified mid-way\n** through the backup process.  ^If the source database is modified by an\n** external process or via a database connection other than the one being\n** used by the backup operation, then the backup will be automatically\n** restarted by the next call to sqlite3_backup_step(). ^If the source \n** database is modified by the using the same database connection as is used\n** by the backup operation, then the backup database is automatically\n** updated at the same time.\n**\n** [[sqlite3_backup_finish()]] <b>sqlite3_backup_finish()</b>\n**\n** When sqlite3_backup_step() has returned [SQLITE_DONE], or when the \n** application wishes to abandon the backup operation, the application\n** should destroy the [sqlite3_backup] by passing it to sqlite3_backup_finish().\n** ^The sqlite3_backup_finish() interfaces releases all\n** resources associated with the [sqlite3_backup] object. \n** ^If sqlite3_backup_step() has not yet returned [SQLITE_DONE], then any\n** active write-transaction on the destination database is rolled back.\n** The [sqlite3_backup] object is invalid\n** and may not be used following a call to sqlite3_backup_finish().\n**\n** ^The value returned by sqlite3_backup_finish is [SQLITE_OK] if no\n** sqlite3_backup_step() errors occurred, regardless or whether or not\n** sqlite3_backup_step() completed.\n** ^If an out-of-memory condition or IO error occurred during any prior\n** sqlite3_backup_step() call on the same [sqlite3_backup] object, then\n** sqlite3_backup_finish() returns the corresponding [error code].\n**\n** ^A return of [SQLITE_BUSY] or [SQLITE_LOCKED] from sqlite3_backup_step()\n** is not a permanent error and does not affect the return value of\n** sqlite3_backup_finish().\n**\n** [[sqlite3_backup_remaining()]] [[sqlite3_backup_pagecount()]]\n** <b>sqlite3_backup_remaining() and sqlite3_backup_pagecount()</b>\n**\n** ^The sqlite3_backup_remaining() routine returns the number of pages still\n** to be backed up at the conclusion of the most recent sqlite3_backup_step().\n** ^The sqlite3_backup_pagecount() routine returns the total number of pages\n** in the source database at the conclusion of the most recent\n** sqlite3_backup_step().\n** ^(The values returned by these functions are only updated by\n** sqlite3_backup_step(). If the source database is modified in a way that\n** changes the size of the source database or the number of pages remaining,\n** those changes are not reflected in the output of sqlite3_backup_pagecount()\n** and sqlite3_backup_remaining() until after the next\n** sqlite3_backup_step().)^\n**\n** <b>Concurrent Usage of Database Handles</b>\n**\n** ^The source [database connection] may be used by the application for other\n** purposes while a backup operation is underway or being initialized.\n** ^If SQLite is compiled and configured to support threadsafe database\n** connections, then the source database connection may be used concurrently\n** from within other threads.\n**\n** However, the application must guarantee that the destination \n** [database connection] is not passed to any other API (by any thread) after \n** sqlite3_backup_init() is called and before the corresponding call to\n** sqlite3_backup_finish().  SQLite does not currently check to see\n** if the application incorrectly accesses the destination [database connection]\n** and so no error code is reported, but the operations may malfunction\n** nevertheless.  Use of the destination database connection while a\n** backup is in progress might also also cause a mutex deadlock.\n**\n** If running in [shared cache mode], the application must\n** guarantee that the shared cache used by the destination database\n** is not accessed while the backup is running. In practice this means\n** that the application must guarantee that the disk file being \n** backed up to is not accessed by any connection within the process,\n** not just the specific connection that was passed to sqlite3_backup_init().\n**\n** The [sqlite3_backup] object itself is partially threadsafe. Multiple \n** threads may safely make multiple concurrent calls to sqlite3_backup_step().\n** However, the sqlite3_backup_remaining() and sqlite3_backup_pagecount()\n** APIs are not strictly speaking threadsafe. If they are invoked at the\n** same time as another thread is invoking sqlite3_backup_step() it is\n** possible that they return invalid values.\n*/\nSQLITE_API sqlite3_backup *sqlite3_backup_init(\n  sqlite3 *pDest,                        /* Destination database handle */\n  const char *zDestName,                 /* Destination database name */\n  sqlite3 *pSource,                      /* Source database handle */\n  const char *zSourceName                /* Source database name */\n);\nSQLITE_API int sqlite3_backup_step(sqlite3_backup *p, int nPage);\nSQLITE_API int sqlite3_backup_finish(sqlite3_backup *p);\nSQLITE_API int sqlite3_backup_remaining(sqlite3_backup *p);\nSQLITE_API int sqlite3_backup_pagecount(sqlite3_backup *p);\n\n/*\n** CAPI3REF: Unlock Notification\n** METHOD: sqlite3\n**\n** ^When running in shared-cache mode, a database operation may fail with\n** an [SQLITE_LOCKED] error if the required locks on the shared-cache or\n** individual tables within the shared-cache cannot be obtained. See\n** [SQLite Shared-Cache Mode] for a description of shared-cache locking. \n** ^This API may be used to register a callback that SQLite will invoke \n** when the connection currently holding the required lock relinquishes it.\n** ^This API is only available if the library was compiled with the\n** [SQLITE_ENABLE_UNLOCK_NOTIFY] C-preprocessor symbol defined.\n**\n** See Also: [Using the SQLite Unlock Notification Feature].\n**\n** ^Shared-cache locks are released when a database connection concludes\n** its current transaction, either by committing it or rolling it back. \n**\n** ^When a connection (known as the blocked connection) fails to obtain a\n** shared-cache lock and SQLITE_LOCKED is returned to the caller, the\n** identity of the database connection (the blocking connection) that\n** has locked the required resource is stored internally. ^After an \n** application receives an SQLITE_LOCKED error, it may call the\n** sqlite3_unlock_notify() method with the blocked connection handle as \n** the first argument to register for a callback that will be invoked\n** when the blocking connections current transaction is concluded. ^The\n** callback is invoked from within the [sqlite3_step] or [sqlite3_close]\n** call that concludes the blocking connections transaction.\n**\n** ^(If sqlite3_unlock_notify() is called in a multi-threaded application,\n** there is a chance that the blocking connection will have already\n** concluded its transaction by the time sqlite3_unlock_notify() is invoked.\n** If this happens, then the specified callback is invoked immediately,\n** from within the call to sqlite3_unlock_notify().)^\n**\n** ^If the blocked connection is attempting to obtain a write-lock on a\n** shared-cache table, and more than one other connection currently holds\n** a read-lock on the same table, then SQLite arbitrarily selects one of \n** the other connections to use as the blocking connection.\n**\n** ^(There may be at most one unlock-notify callback registered by a \n** blocked connection. If sqlite3_unlock_notify() is called when the\n** blocked connection already has a registered unlock-notify callback,\n** then the new callback replaces the old.)^ ^If sqlite3_unlock_notify() is\n** called with a NULL pointer as its second argument, then any existing\n** unlock-notify callback is canceled. ^The blocked connections \n** unlock-notify callback may also be canceled by closing the blocked\n** connection using [sqlite3_close()].\n**\n** The unlock-notify callback is not reentrant. If an application invokes\n** any sqlite3_xxx API functions from within an unlock-notify callback, a\n** crash or deadlock may be the result.\n**\n** ^Unless deadlock is detected (see below), sqlite3_unlock_notify() always\n** returns SQLITE_OK.\n**\n** <b>Callback Invocation Details</b>\n**\n** When an unlock-notify callback is registered, the application provides a \n** single void* pointer that is passed to the callback when it is invoked.\n** However, the signature of the callback function allows SQLite to pass\n** it an array of void* context pointers. The first argument passed to\n** an unlock-notify callback is a pointer to an array of void* pointers,\n** and the second is the number of entries in the array.\n**\n** When a blocking connections transaction is concluded, there may be\n** more than one blocked connection that has registered for an unlock-notify\n** callback. ^If two or more such blocked connections have specified the\n** same callback function, then instead of invoking the callback function\n** multiple times, it is invoked once with the set of void* context pointers\n** specified by the blocked connections bundled together into an array.\n** This gives the application an opportunity to prioritize any actions \n** related to the set of unblocked database connections.\n**\n** <b>Deadlock Detection</b>\n**\n** Assuming that after registering for an unlock-notify callback a \n** database waits for the callback to be issued before taking any further\n** action (a reasonable assumption), then using this API may cause the\n** application to deadlock. For example, if connection X is waiting for\n** connection Y's transaction to be concluded, and similarly connection\n** Y is waiting on connection X's transaction, then neither connection\n** will proceed and the system may remain deadlocked indefinitely.\n**\n** To avoid this scenario, the sqlite3_unlock_notify() performs deadlock\n** detection. ^If a given call to sqlite3_unlock_notify() would put the\n** system in a deadlocked state, then SQLITE_LOCKED is returned and no\n** unlock-notify callback is registered. The system is said to be in\n** a deadlocked state if connection A has registered for an unlock-notify\n** callback on the conclusion of connection B's transaction, and connection\n** B has itself registered for an unlock-notify callback when connection\n** A's transaction is concluded. ^Indirect deadlock is also detected, so\n** the system is also considered to be deadlocked if connection B has\n** registered for an unlock-notify callback on the conclusion of connection\n** C's transaction, where connection C is waiting on connection A. ^Any\n** number of levels of indirection are allowed.\n**\n** <b>The \"DROP TABLE\" Exception</b>\n**\n** When a call to [sqlite3_step()] returns SQLITE_LOCKED, it is almost \n** always appropriate to call sqlite3_unlock_notify(). There is however,\n** one exception. When executing a \"DROP TABLE\" or \"DROP INDEX\" statement,\n** SQLite checks if there are any currently executing SELECT statements\n** that belong to the same connection. If there are, SQLITE_LOCKED is\n** returned. In this case there is no \"blocking connection\", so invoking\n** sqlite3_unlock_notify() results in the unlock-notify callback being\n** invoked immediately. If the application then re-attempts the \"DROP TABLE\"\n** or \"DROP INDEX\" query, an infinite loop might be the result.\n**\n** One way around this problem is to check the extended error code returned\n** by an sqlite3_step() call. ^(If there is a blocking connection, then the\n** extended error code is set to SQLITE_LOCKED_SHAREDCACHE. Otherwise, in\n** the special \"DROP TABLE/INDEX\" case, the extended error code is just \n** SQLITE_LOCKED.)^\n*/\nSQLITE_API int sqlite3_unlock_notify(\n  sqlite3 *pBlocked,                          /* Waiting connection */\n  void (*xNotify)(void **apArg, int nArg),    /* Callback function to invoke */\n  void *pNotifyArg                            /* Argument to pass to xNotify */\n);\n\n\n/*\n** CAPI3REF: String Comparison\n**\n** ^The [sqlite3_stricmp()] and [sqlite3_strnicmp()] APIs allow applications\n** and extensions to compare the contents of two buffers containing UTF-8\n** strings in a case-independent fashion, using the same definition of \"case\n** independence\" that SQLite uses internally when comparing identifiers.\n*/\nSQLITE_API int sqlite3_stricmp(const char *, const char *);\nSQLITE_API int sqlite3_strnicmp(const char *, const char *, int);\n\n/*\n** CAPI3REF: String Globbing\n*\n** ^The [sqlite3_strglob(P,X)] interface returns zero if and only if\n** string X matches the [GLOB] pattern P.\n** ^The definition of [GLOB] pattern matching used in\n** [sqlite3_strglob(P,X)] is the same as for the \"X GLOB P\" operator in the\n** SQL dialect understood by SQLite.  ^The [sqlite3_strglob(P,X)] function\n** is case sensitive.\n**\n** Note that this routine returns zero on a match and non-zero if the strings\n** do not match, the same as [sqlite3_stricmp()] and [sqlite3_strnicmp()].\n**\n** See also: [sqlite3_strlike()].\n*/\nSQLITE_API int sqlite3_strglob(const char *zGlob, const char *zStr);\n\n/*\n** CAPI3REF: String LIKE Matching\n*\n** ^The [sqlite3_strlike(P,X,E)] interface returns zero if and only if\n** string X matches the [LIKE] pattern P with escape character E.\n** ^The definition of [LIKE] pattern matching used in\n** [sqlite3_strlike(P,X,E)] is the same as for the \"X LIKE P ESCAPE E\"\n** operator in the SQL dialect understood by SQLite.  ^For \"X LIKE P\" without\n** the ESCAPE clause, set the E parameter of [sqlite3_strlike(P,X,E)] to 0.\n** ^As with the LIKE operator, the [sqlite3_strlike(P,X,E)] function is case\n** insensitive - equivalent upper and lower case ASCII characters match\n** one another.\n**\n** ^The [sqlite3_strlike(P,X,E)] function matches Unicode characters, though\n** only ASCII characters are case folded.\n**\n** Note that this routine returns zero on a match and non-zero if the strings\n** do not match, the same as [sqlite3_stricmp()] and [sqlite3_strnicmp()].\n**\n** See also: [sqlite3_strglob()].\n*/\nSQLITE_API int sqlite3_strlike(const char *zGlob, const char *zStr, unsigned int cEsc);\n\n/*\n** CAPI3REF: Error Logging Interface\n**\n** ^The [sqlite3_log()] interface writes a message into the [error log]\n** established by the [SQLITE_CONFIG_LOG] option to [sqlite3_config()].\n** ^If logging is enabled, the zFormat string and subsequent arguments are\n** used with [sqlite3_snprintf()] to generate the final output string.\n**\n** The sqlite3_log() interface is intended for use by extensions such as\n** virtual tables, collating functions, and SQL functions.  While there is\n** nothing to prevent an application from calling sqlite3_log(), doing so\n** is considered bad form.\n**\n** The zFormat string must not be NULL.\n**\n** To avoid deadlocks and other threading problems, the sqlite3_log() routine\n** will not use dynamically allocated memory.  The log message is stored in\n** a fixed-length buffer on the stack.  If the log message is longer than\n** a few hundred characters, it will be truncated to the length of the\n** buffer.\n*/\nSQLITE_API void sqlite3_log(int iErrCode, const char *zFormat, ...);\n\n/*\n** CAPI3REF: Write-Ahead Log Commit Hook\n** METHOD: sqlite3\n**\n** ^The [sqlite3_wal_hook()] function is used to register a callback that\n** is invoked each time data is committed to a database in wal mode.\n**\n** ^(The callback is invoked by SQLite after the commit has taken place and \n** the associated write-lock on the database released)^, so the implementation \n** may read, write or [checkpoint] the database as required.\n**\n** ^The first parameter passed to the callback function when it is invoked\n** is a copy of the third parameter passed to sqlite3_wal_hook() when\n** registering the callback. ^The second is a copy of the database handle.\n** ^The third parameter is the name of the database that was written to -\n** either \"main\" or the name of an [ATTACH]-ed database. ^The fourth parameter\n** is the number of pages currently in the write-ahead log file,\n** including those that were just committed.\n**\n** The callback function should normally return [SQLITE_OK].  ^If an error\n** code is returned, that error will propagate back up through the\n** SQLite code base to cause the statement that provoked the callback\n** to report an error, though the commit will have still occurred. If the\n** callback returns [SQLITE_ROW] or [SQLITE_DONE], or if it returns a value\n** that does not correspond to any valid SQLite error code, the results\n** are undefined.\n**\n** A single database handle may have at most a single write-ahead log callback \n** registered at one time. ^Calling [sqlite3_wal_hook()] replaces any\n** previously registered write-ahead log callback. ^Note that the\n** [sqlite3_wal_autocheckpoint()] interface and the\n** [wal_autocheckpoint pragma] both invoke [sqlite3_wal_hook()] and will\n** overwrite any prior [sqlite3_wal_hook()] settings.\n*/\nSQLITE_API void *sqlite3_wal_hook(\n  sqlite3*, \n  int(*)(void *,sqlite3*,const char*,int),\n  void*\n);\n\n/*\n** CAPI3REF: Configure an auto-checkpoint\n** METHOD: sqlite3\n**\n** ^The [sqlite3_wal_autocheckpoint(D,N)] is a wrapper around\n** [sqlite3_wal_hook()] that causes any database on [database connection] D\n** to automatically [checkpoint]\n** after committing a transaction if there are N or\n** more frames in the [write-ahead log] file.  ^Passing zero or \n** a negative value as the nFrame parameter disables automatic\n** checkpoints entirely.\n**\n** ^The callback registered by this function replaces any existing callback\n** registered using [sqlite3_wal_hook()].  ^Likewise, registering a callback\n** using [sqlite3_wal_hook()] disables the automatic checkpoint mechanism\n** configured by this function.\n**\n** ^The [wal_autocheckpoint pragma] can be used to invoke this interface\n** from SQL.\n**\n** ^Checkpoints initiated by this mechanism are\n** [sqlite3_wal_checkpoint_v2|PASSIVE].\n**\n** ^Every new [database connection] defaults to having the auto-checkpoint\n** enabled with a threshold of 1000 or [SQLITE_DEFAULT_WAL_AUTOCHECKPOINT]\n** pages.  The use of this interface\n** is only necessary if the default setting is found to be suboptimal\n** for a particular application.\n*/\nSQLITE_API int sqlite3_wal_autocheckpoint(sqlite3 *db, int N);\n\n/*\n** CAPI3REF: Checkpoint a database\n** METHOD: sqlite3\n**\n** ^(The sqlite3_wal_checkpoint(D,X) is equivalent to\n** [sqlite3_wal_checkpoint_v2](D,X,[SQLITE_CHECKPOINT_PASSIVE],0,0).)^\n**\n** In brief, sqlite3_wal_checkpoint(D,X) causes the content in the \n** [write-ahead log] for database X on [database connection] D to be\n** transferred into the database file and for the write-ahead log to\n** be reset.  See the [checkpointing] documentation for addition\n** information.\n**\n** This interface used to be the only way to cause a checkpoint to\n** occur.  But then the newer and more powerful [sqlite3_wal_checkpoint_v2()]\n** interface was added.  This interface is retained for backwards\n** compatibility and as a convenience for applications that need to manually\n** start a callback but which do not need the full power (and corresponding\n** complication) of [sqlite3_wal_checkpoint_v2()].\n*/\nSQLITE_API int sqlite3_wal_checkpoint(sqlite3 *db, const char *zDb);\n\n/*\n** CAPI3REF: Checkpoint a database\n** METHOD: sqlite3\n**\n** ^(The sqlite3_wal_checkpoint_v2(D,X,M,L,C) interface runs a checkpoint\n** operation on database X of [database connection] D in mode M.  Status\n** information is written back into integers pointed to by L and C.)^\n** ^(The M parameter must be a valid [checkpoint mode]:)^\n**\n** <dl>\n** <dt>SQLITE_CHECKPOINT_PASSIVE<dd>\n**   ^Checkpoint as many frames as possible without waiting for any database \n**   readers or writers to finish, then sync the database file if all frames \n**   in the log were checkpointed. ^The [busy-handler callback]\n**   is never invoked in the SQLITE_CHECKPOINT_PASSIVE mode.  \n**   ^On the other hand, passive mode might leave the checkpoint unfinished\n**   if there are concurrent readers or writers.\n**\n** <dt>SQLITE_CHECKPOINT_FULL<dd>\n**   ^This mode blocks (it invokes the\n**   [sqlite3_busy_handler|busy-handler callback]) until there is no\n**   database writer and all readers are reading from the most recent database\n**   snapshot. ^It then checkpoints all frames in the log file and syncs the\n**   database file. ^This mode blocks new database writers while it is pending,\n**   but new database readers are allowed to continue unimpeded.\n**\n** <dt>SQLITE_CHECKPOINT_RESTART<dd>\n**   ^This mode works the same way as SQLITE_CHECKPOINT_FULL with the addition\n**   that after checkpointing the log file it blocks (calls the \n**   [busy-handler callback])\n**   until all readers are reading from the database file only. ^This ensures \n**   that the next writer will restart the log file from the beginning.\n**   ^Like SQLITE_CHECKPOINT_FULL, this mode blocks new\n**   database writer attempts while it is pending, but does not impede readers.\n**\n** <dt>SQLITE_CHECKPOINT_TRUNCATE<dd>\n**   ^This mode works the same way as SQLITE_CHECKPOINT_RESTART with the\n**   addition that it also truncates the log file to zero bytes just prior\n**   to a successful return.\n** </dl>\n**\n** ^If pnLog is not NULL, then *pnLog is set to the total number of frames in\n** the log file or to -1 if the checkpoint could not run because\n** of an error or because the database is not in [WAL mode]. ^If pnCkpt is not\n** NULL,then *pnCkpt is set to the total number of checkpointed frames in the\n** log file (including any that were already checkpointed before the function\n** was called) or to -1 if the checkpoint could not run due to an error or\n** because the database is not in WAL mode. ^Note that upon successful\n** completion of an SQLITE_CHECKPOINT_TRUNCATE, the log file will have been\n** truncated to zero bytes and so both *pnLog and *pnCkpt will be set to zero.\n**\n** ^All calls obtain an exclusive \"checkpoint\" lock on the database file. ^If\n** any other process is running a checkpoint operation at the same time, the \n** lock cannot be obtained and SQLITE_BUSY is returned. ^Even if there is a \n** busy-handler configured, it will not be invoked in this case.\n**\n** ^The SQLITE_CHECKPOINT_FULL, RESTART and TRUNCATE modes also obtain the \n** exclusive \"writer\" lock on the database file. ^If the writer lock cannot be\n** obtained immediately, and a busy-handler is configured, it is invoked and\n** the writer lock retried until either the busy-handler returns 0 or the lock\n** is successfully obtained. ^The busy-handler is also invoked while waiting for\n** database readers as described above. ^If the busy-handler returns 0 before\n** the writer lock is obtained or while waiting for database readers, the\n** checkpoint operation proceeds from that point in the same way as \n** SQLITE_CHECKPOINT_PASSIVE - checkpointing as many frames as possible \n** without blocking any further. ^SQLITE_BUSY is returned in this case.\n**\n** ^If parameter zDb is NULL or points to a zero length string, then the\n** specified operation is attempted on all WAL databases [attached] to \n** [database connection] db.  In this case the\n** values written to output parameters *pnLog and *pnCkpt are undefined. ^If \n** an SQLITE_BUSY error is encountered when processing one or more of the \n** attached WAL databases, the operation is still attempted on any remaining \n** attached databases and SQLITE_BUSY is returned at the end. ^If any other \n** error occurs while processing an attached database, processing is abandoned \n** and the error code is returned to the caller immediately. ^If no error \n** (SQLITE_BUSY or otherwise) is encountered while processing the attached \n** databases, SQLITE_OK is returned.\n**\n** ^If database zDb is the name of an attached database that is not in WAL\n** mode, SQLITE_OK is returned and both *pnLog and *pnCkpt set to -1. ^If\n** zDb is not NULL (or a zero length string) and is not the name of any\n** attached database, SQLITE_ERROR is returned to the caller.\n**\n** ^Unless it returns SQLITE_MISUSE,\n** the sqlite3_wal_checkpoint_v2() interface\n** sets the error information that is queried by\n** [sqlite3_errcode()] and [sqlite3_errmsg()].\n**\n** ^The [PRAGMA wal_checkpoint] command can be used to invoke this interface\n** from SQL.\n*/\nSQLITE_API int sqlite3_wal_checkpoint_v2(\n  sqlite3 *db,                    /* Database handle */\n  const char *zDb,                /* Name of attached database (or NULL) */\n  int eMode,                      /* SQLITE_CHECKPOINT_* value */\n  int *pnLog,                     /* OUT: Size of WAL log in frames */\n  int *pnCkpt                     /* OUT: Total number of frames checkpointed */\n);\n\n/*\n** CAPI3REF: Checkpoint Mode Values\n** KEYWORDS: {checkpoint mode}\n**\n** These constants define all valid values for the \"checkpoint mode\" passed\n** as the third parameter to the [sqlite3_wal_checkpoint_v2()] interface.\n** See the [sqlite3_wal_checkpoint_v2()] documentation for details on the\n** meaning of each of these checkpoint modes.\n*/\n#define SQLITE_CHECKPOINT_PASSIVE  0  /* Do as much as possible w/o blocking */\n#define SQLITE_CHECKPOINT_FULL     1  /* Wait for writers, then checkpoint */\n#define SQLITE_CHECKPOINT_RESTART  2  /* Like FULL but wait for for readers */\n#define SQLITE_CHECKPOINT_TRUNCATE 3  /* Like RESTART but also truncate WAL */\n\n/*\n** CAPI3REF: Virtual Table Interface Configuration\n**\n** This function may be called by either the [xConnect] or [xCreate] method\n** of a [virtual table] implementation to configure\n** various facets of the virtual table interface.\n**\n** If this interface is invoked outside the context of an xConnect or\n** xCreate virtual table method then the behavior is undefined.\n**\n** At present, there is only one option that may be configured using\n** this function. (See [SQLITE_VTAB_CONSTRAINT_SUPPORT].)  Further options\n** may be added in the future.\n*/\nSQLITE_API int sqlite3_vtab_config(sqlite3*, int op, ...);\n\n/*\n** CAPI3REF: Virtual Table Configuration Options\n**\n** These macros define the various options to the\n** [sqlite3_vtab_config()] interface that [virtual table] implementations\n** can use to customize and optimize their behavior.\n**\n** <dl>\n** [[SQLITE_VTAB_CONSTRAINT_SUPPORT]]\n** <dt>SQLITE_VTAB_CONSTRAINT_SUPPORT\n** <dd>Calls of the form\n** [sqlite3_vtab_config](db,SQLITE_VTAB_CONSTRAINT_SUPPORT,X) are supported,\n** where X is an integer.  If X is zero, then the [virtual table] whose\n** [xCreate] or [xConnect] method invoked [sqlite3_vtab_config()] does not\n** support constraints.  In this configuration (which is the default) if\n** a call to the [xUpdate] method returns [SQLITE_CONSTRAINT], then the entire\n** statement is rolled back as if [ON CONFLICT | OR ABORT] had been\n** specified as part of the users SQL statement, regardless of the actual\n** ON CONFLICT mode specified.\n**\n** If X is non-zero, then the virtual table implementation guarantees\n** that if [xUpdate] returns [SQLITE_CONSTRAINT], it will do so before\n** any modifications to internal or persistent data structures have been made.\n** If the [ON CONFLICT] mode is ABORT, FAIL, IGNORE or ROLLBACK, SQLite \n** is able to roll back a statement or database transaction, and abandon\n** or continue processing the current SQL statement as appropriate. \n** If the ON CONFLICT mode is REPLACE and the [xUpdate] method returns\n** [SQLITE_CONSTRAINT], SQLite handles this as if the ON CONFLICT mode\n** had been ABORT.\n**\n** Virtual table implementations that are required to handle OR REPLACE\n** must do so within the [xUpdate] method. If a call to the \n** [sqlite3_vtab_on_conflict()] function indicates that the current ON \n** CONFLICT policy is REPLACE, the virtual table implementation should \n** silently replace the appropriate rows within the xUpdate callback and\n** return SQLITE_OK. Or, if this is not possible, it may return\n** SQLITE_CONSTRAINT, in which case SQLite falls back to OR ABORT \n** constraint handling.\n** </dl>\n*/\n#define SQLITE_VTAB_CONSTRAINT_SUPPORT 1\n\n/*\n** CAPI3REF: Determine The Virtual Table Conflict Policy\n**\n** This function may only be called from within a call to the [xUpdate] method\n** of a [virtual table] implementation for an INSERT or UPDATE operation. ^The\n** value returned is one of [SQLITE_ROLLBACK], [SQLITE_IGNORE], [SQLITE_FAIL],\n** [SQLITE_ABORT], or [SQLITE_REPLACE], according to the [ON CONFLICT] mode\n** of the SQL statement that triggered the call to the [xUpdate] method of the\n** [virtual table].\n*/\nSQLITE_API int sqlite3_vtab_on_conflict(sqlite3 *);\n\n/*\n** CAPI3REF: Determine If Virtual Table Column Access Is For UPDATE\n**\n** If the sqlite3_vtab_nochange(X) routine is called within the [xColumn]\n** method of a [virtual table], then it returns true if and only if the\n** column is being fetched as part of an UPDATE operation during which the\n** column value will not change.  Applications might use this to substitute\n** a return value that is less expensive to compute and that the corresponding\n** [xUpdate] method understands as a \"no-change\" value.\n**\n** If the [xColumn] method calls sqlite3_vtab_nochange() and finds that\n** the column is not changed by the UPDATE statement, then the xColumn\n** method can optionally return without setting a result, without calling\n** any of the [sqlite3_result_int|sqlite3_result_xxxxx() interfaces].\n** In that case, [sqlite3_value_nochange(X)] will return true for the\n** same column in the [xUpdate] method.\n*/\nSQLITE_API int sqlite3_vtab_nochange(sqlite3_context*);\n\n/*\n** CAPI3REF: Determine The Collation For a Virtual Table Constraint\n**\n** This function may only be called from within a call to the [xBestIndex]\n** method of a [virtual table]. \n**\n** The first argument must be the sqlite3_index_info object that is the\n** first parameter to the xBestIndex() method. The second argument must be\n** an index into the aConstraint[] array belonging to the sqlite3_index_info\n** structure passed to xBestIndex. This function returns a pointer to a buffer \n** containing the name of the collation sequence for the corresponding\n** constraint.\n*/\nSQLITE_API SQLITE_EXPERIMENTAL const char *sqlite3_vtab_collation(sqlite3_index_info*,int);\n\n/*\n** CAPI3REF: Conflict resolution modes\n** KEYWORDS: {conflict resolution mode}\n**\n** These constants are returned by [sqlite3_vtab_on_conflict()] to\n** inform a [virtual table] implementation what the [ON CONFLICT] mode\n** is for the SQL statement being evaluated.\n**\n** Note that the [SQLITE_IGNORE] constant is also used as a potential\n** return value from the [sqlite3_set_authorizer()] callback and that\n** [SQLITE_ABORT] is also a [result code].\n*/\n#define SQLITE_ROLLBACK 1\n/* #define SQLITE_IGNORE 2 // Also used by sqlite3_authorizer() callback */\n#define SQLITE_FAIL     3\n/* #define SQLITE_ABORT 4  // Also an error code */\n#define SQLITE_REPLACE  5\n\n/*\n** CAPI3REF: Prepared Statement Scan Status Opcodes\n** KEYWORDS: {scanstatus options}\n**\n** The following constants can be used for the T parameter to the\n** [sqlite3_stmt_scanstatus(S,X,T,V)] interface.  Each constant designates a\n** different metric for sqlite3_stmt_scanstatus() to return.\n**\n** When the value returned to V is a string, space to hold that string is\n** managed by the prepared statement S and will be automatically freed when\n** S is finalized.\n**\n** <dl>\n** [[SQLITE_SCANSTAT_NLOOP]] <dt>SQLITE_SCANSTAT_NLOOP</dt>\n** <dd>^The [sqlite3_int64] variable pointed to by the T parameter will be\n** set to the total number of times that the X-th loop has run.</dd>\n**\n** [[SQLITE_SCANSTAT_NVISIT]] <dt>SQLITE_SCANSTAT_NVISIT</dt>\n** <dd>^The [sqlite3_int64] variable pointed to by the T parameter will be set\n** to the total number of rows examined by all iterations of the X-th loop.</dd>\n**\n** [[SQLITE_SCANSTAT_EST]] <dt>SQLITE_SCANSTAT_EST</dt>\n** <dd>^The \"double\" variable pointed to by the T parameter will be set to the\n** query planner's estimate for the average number of rows output from each\n** iteration of the X-th loop.  If the query planner's estimates was accurate,\n** then this value will approximate the quotient NVISIT/NLOOP and the\n** product of this value for all prior loops with the same SELECTID will\n** be the NLOOP value for the current loop.\n**\n** [[SQLITE_SCANSTAT_NAME]] <dt>SQLITE_SCANSTAT_NAME</dt>\n** <dd>^The \"const char *\" variable pointed to by the T parameter will be set\n** to a zero-terminated UTF-8 string containing the name of the index or table\n** used for the X-th loop.\n**\n** [[SQLITE_SCANSTAT_EXPLAIN]] <dt>SQLITE_SCANSTAT_EXPLAIN</dt>\n** <dd>^The \"const char *\" variable pointed to by the T parameter will be set\n** to a zero-terminated UTF-8 string containing the [EXPLAIN QUERY PLAN]\n** description for the X-th loop.\n**\n** [[SQLITE_SCANSTAT_SELECTID]] <dt>SQLITE_SCANSTAT_SELECT</dt>\n** <dd>^The \"int\" variable pointed to by the T parameter will be set to the\n** \"select-id\" for the X-th loop.  The select-id identifies which query or\n** subquery the loop is part of.  The main query has a select-id of zero.\n** The select-id is the same value as is output in the first column\n** of an [EXPLAIN QUERY PLAN] query.\n** </dl>\n*/\n#define SQLITE_SCANSTAT_NLOOP    0\n#define SQLITE_SCANSTAT_NVISIT   1\n#define SQLITE_SCANSTAT_EST      2\n#define SQLITE_SCANSTAT_NAME     3\n#define SQLITE_SCANSTAT_EXPLAIN  4\n#define SQLITE_SCANSTAT_SELECTID 5\n\n/*\n** CAPI3REF: Prepared Statement Scan Status\n** METHOD: sqlite3_stmt\n**\n** This interface returns information about the predicted and measured\n** performance for pStmt.  Advanced applications can use this\n** interface to compare the predicted and the measured performance and\n** issue warnings and/or rerun [ANALYZE] if discrepancies are found.\n**\n** Since this interface is expected to be rarely used, it is only\n** available if SQLite is compiled using the [SQLITE_ENABLE_STMT_SCANSTATUS]\n** compile-time option.\n**\n** The \"iScanStatusOp\" parameter determines which status information to return.\n** The \"iScanStatusOp\" must be one of the [scanstatus options] or the behavior\n** of this interface is undefined.\n** ^The requested measurement is written into a variable pointed to by\n** the \"pOut\" parameter.\n** Parameter \"idx\" identifies the specific loop to retrieve statistics for.\n** Loops are numbered starting from zero. ^If idx is out of range - less than\n** zero or greater than or equal to the total number of loops used to implement\n** the statement - a non-zero value is returned and the variable that pOut\n** points to is unchanged.\n**\n** ^Statistics might not be available for all loops in all statements. ^In cases\n** where there exist loops with no available statistics, this function behaves\n** as if the loop did not exist - it returns non-zero and leave the variable\n** that pOut points to unchanged.\n**\n** See also: [sqlite3_stmt_scanstatus_reset()]\n*/\nSQLITE_API int sqlite3_stmt_scanstatus(\n  sqlite3_stmt *pStmt,      /* Prepared statement for which info desired */\n  int idx,                  /* Index of loop to report on */\n  int iScanStatusOp,        /* Information desired.  SQLITE_SCANSTAT_* */\n  void *pOut                /* Result written here */\n);     \n\n/*\n** CAPI3REF: Zero Scan-Status Counters\n** METHOD: sqlite3_stmt\n**\n** ^Zero all [sqlite3_stmt_scanstatus()] related event counters.\n**\n** This API is only available if the library is built with pre-processor\n** symbol [SQLITE_ENABLE_STMT_SCANSTATUS] defined.\n*/\nSQLITE_API void sqlite3_stmt_scanstatus_reset(sqlite3_stmt*);\n\n/*\n** CAPI3REF: Flush caches to disk mid-transaction\n**\n** ^If a write-transaction is open on [database connection] D when the\n** [sqlite3_db_cacheflush(D)] interface invoked, any dirty\n** pages in the pager-cache that are not currently in use are written out \n** to disk. A dirty page may be in use if a database cursor created by an\n** active SQL statement is reading from it, or if it is page 1 of a database\n** file (page 1 is always \"in use\").  ^The [sqlite3_db_cacheflush(D)]\n** interface flushes caches for all schemas - \"main\", \"temp\", and\n** any [attached] databases.\n**\n** ^If this function needs to obtain extra database locks before dirty pages \n** can be flushed to disk, it does so. ^If those locks cannot be obtained \n** immediately and there is a busy-handler callback configured, it is invoked\n** in the usual manner. ^If the required lock still cannot be obtained, then\n** the database is skipped and an attempt made to flush any dirty pages\n** belonging to the next (if any) database. ^If any databases are skipped\n** because locks cannot be obtained, but no other error occurs, this\n** function returns SQLITE_BUSY.\n**\n** ^If any other error occurs while flushing dirty pages to disk (for\n** example an IO error or out-of-memory condition), then processing is\n** abandoned and an SQLite [error code] is returned to the caller immediately.\n**\n** ^Otherwise, if no error occurs, [sqlite3_db_cacheflush()] returns SQLITE_OK.\n**\n** ^This function does not set the database handle error code or message\n** returned by the [sqlite3_errcode()] and [sqlite3_errmsg()] functions.\n*/\nSQLITE_API int sqlite3_db_cacheflush(sqlite3*);\n\n/*\n** CAPI3REF: The pre-update hook.\n**\n** ^These interfaces are only available if SQLite is compiled using the\n** [SQLITE_ENABLE_PREUPDATE_HOOK] compile-time option.\n**\n** ^The [sqlite3_preupdate_hook()] interface registers a callback function\n** that is invoked prior to each [INSERT], [UPDATE], and [DELETE] operation\n** on a database table.\n** ^At most one preupdate hook may be registered at a time on a single\n** [database connection]; each call to [sqlite3_preupdate_hook()] overrides\n** the previous setting.\n** ^The preupdate hook is disabled by invoking [sqlite3_preupdate_hook()]\n** with a NULL pointer as the second parameter.\n** ^The third parameter to [sqlite3_preupdate_hook()] is passed through as\n** the first parameter to callbacks.\n**\n** ^The preupdate hook only fires for changes to real database tables; the\n** preupdate hook is not invoked for changes to [virtual tables] or to\n** system tables like sqlite_master or sqlite_stat1.\n**\n** ^The second parameter to the preupdate callback is a pointer to\n** the [database connection] that registered the preupdate hook.\n** ^The third parameter to the preupdate callback is one of the constants\n** [SQLITE_INSERT], [SQLITE_DELETE], or [SQLITE_UPDATE] to identify the\n** kind of update operation that is about to occur.\n** ^(The fourth parameter to the preupdate callback is the name of the\n** database within the database connection that is being modified.  This\n** will be \"main\" for the main database or \"temp\" for TEMP tables or \n** the name given after the AS keyword in the [ATTACH] statement for attached\n** databases.)^\n** ^The fifth parameter to the preupdate callback is the name of the\n** table that is being modified.\n**\n** For an UPDATE or DELETE operation on a [rowid table], the sixth\n** parameter passed to the preupdate callback is the initial [rowid] of the \n** row being modified or deleted. For an INSERT operation on a rowid table,\n** or any operation on a WITHOUT ROWID table, the value of the sixth \n** parameter is undefined. For an INSERT or UPDATE on a rowid table the\n** seventh parameter is the final rowid value of the row being inserted\n** or updated. The value of the seventh parameter passed to the callback\n** function is not defined for operations on WITHOUT ROWID tables, or for\n** INSERT operations on rowid tables.\n**\n** The [sqlite3_preupdate_old()], [sqlite3_preupdate_new()],\n** [sqlite3_preupdate_count()], and [sqlite3_preupdate_depth()] interfaces\n** provide additional information about a preupdate event. These routines\n** may only be called from within a preupdate callback.  Invoking any of\n** these routines from outside of a preupdate callback or with a\n** [database connection] pointer that is different from the one supplied\n** to the preupdate callback results in undefined and probably undesirable\n** behavior.\n**\n** ^The [sqlite3_preupdate_count(D)] interface returns the number of columns\n** in the row that is being inserted, updated, or deleted.\n**\n** ^The [sqlite3_preupdate_old(D,N,P)] interface writes into P a pointer to\n** a [protected sqlite3_value] that contains the value of the Nth column of\n** the table row before it is updated.  The N parameter must be between 0\n** and one less than the number of columns or the behavior will be\n** undefined. This must only be used within SQLITE_UPDATE and SQLITE_DELETE\n** preupdate callbacks; if it is used by an SQLITE_INSERT callback then the\n** behavior is undefined.  The [sqlite3_value] that P points to\n** will be destroyed when the preupdate callback returns.\n**\n** ^The [sqlite3_preupdate_new(D,N,P)] interface writes into P a pointer to\n** a [protected sqlite3_value] that contains the value of the Nth column of\n** the table row after it is updated.  The N parameter must be between 0\n** and one less than the number of columns or the behavior will be\n** undefined. This must only be used within SQLITE_INSERT and SQLITE_UPDATE\n** preupdate callbacks; if it is used by an SQLITE_DELETE callback then the\n** behavior is undefined.  The [sqlite3_value] that P points to\n** will be destroyed when the preupdate callback returns.\n**\n** ^The [sqlite3_preupdate_depth(D)] interface returns 0 if the preupdate\n** callback was invoked as a result of a direct insert, update, or delete\n** operation; or 1 for inserts, updates, or deletes invoked by top-level \n** triggers; or 2 for changes resulting from triggers called by top-level\n** triggers; and so forth.\n**\n** See also:  [sqlite3_update_hook()]\n*/\n#if defined(SQLITE_ENABLE_PREUPDATE_HOOK)\nSQLITE_API void *sqlite3_preupdate_hook(\n  sqlite3 *db,\n  void(*xPreUpdate)(\n    void *pCtx,                   /* Copy of third arg to preupdate_hook() */\n    sqlite3 *db,                  /* Database handle */\n    int op,                       /* SQLITE_UPDATE, DELETE or INSERT */\n    char const *zDb,              /* Database name */\n    char const *zName,            /* Table name */\n    sqlite3_int64 iKey1,          /* Rowid of row about to be deleted/updated */\n    sqlite3_int64 iKey2           /* New rowid value (for a rowid UPDATE) */\n  ),\n  void*\n);\nSQLITE_API int sqlite3_preupdate_old(sqlite3 *, int, sqlite3_value **);\nSQLITE_API int sqlite3_preupdate_count(sqlite3 *);\nSQLITE_API int sqlite3_preupdate_depth(sqlite3 *);\nSQLITE_API int sqlite3_preupdate_new(sqlite3 *, int, sqlite3_value **);\n#endif\n\n/*\n** CAPI3REF: Low-level system error code\n**\n** ^Attempt to return the underlying operating system error code or error\n** number that caused the most recent I/O error or failure to open a file.\n** The return value is OS-dependent.  For example, on unix systems, after\n** [sqlite3_open_v2()] returns [SQLITE_CANTOPEN], this interface could be\n** called to get back the underlying \"errno\" that caused the problem, such\n** as ENOSPC, EAUTH, EISDIR, and so forth.  \n*/\nSQLITE_API int sqlite3_system_errno(sqlite3*);\n\n/*\n** CAPI3REF: Database Snapshot\n** KEYWORDS: {snapshot} {sqlite3_snapshot}\n**\n** An instance of the snapshot object records the state of a [WAL mode]\n** database for some specific point in history.\n**\n** In [WAL mode], multiple [database connections] that are open on the\n** same database file can each be reading a different historical version\n** of the database file.  When a [database connection] begins a read\n** transaction, that connection sees an unchanging copy of the database\n** as it existed for the point in time when the transaction first started.\n** Subsequent changes to the database from other connections are not seen\n** by the reader until a new read transaction is started.\n**\n** The sqlite3_snapshot object records state information about an historical\n** version of the database file so that it is possible to later open a new read\n** transaction that sees that historical version of the database rather than\n** the most recent version.\n*/\ntypedef struct sqlite3_snapshot {\n  unsigned char hidden[48];\n} sqlite3_snapshot;\n\n/*\n** CAPI3REF: Record A Database Snapshot\n** CONSTRUCTOR: sqlite3_snapshot\n**\n** ^The [sqlite3_snapshot_get(D,S,P)] interface attempts to make a\n** new [sqlite3_snapshot] object that records the current state of\n** schema S in database connection D.  ^On success, the\n** [sqlite3_snapshot_get(D,S,P)] interface writes a pointer to the newly\n** created [sqlite3_snapshot] object into *P and returns SQLITE_OK.\n** If there is not already a read-transaction open on schema S when\n** this function is called, one is opened automatically. \n**\n** The following must be true for this function to succeed. If any of\n** the following statements are false when sqlite3_snapshot_get() is\n** called, SQLITE_ERROR is returned. The final value of *P is undefined\n** in this case. \n**\n** <ul>\n**   <li> The database handle must not be in [autocommit mode].\n**\n**   <li> Schema S of [database connection] D must be a [WAL mode] database.\n**\n**   <li> There must not be a write transaction open on schema S of database\n**        connection D.\n**\n**   <li> One or more transactions must have been written to the current wal\n**        file since it was created on disk (by any connection). This means\n**        that a snapshot cannot be taken on a wal mode database with no wal \n**        file immediately after it is first opened. At least one transaction\n**        must be written to it first.\n** </ul>\n**\n** This function may also return SQLITE_NOMEM.  If it is called with the\n** database handle in autocommit mode but fails for some other reason, \n** whether or not a read transaction is opened on schema S is undefined.\n**\n** The [sqlite3_snapshot] object returned from a successful call to\n** [sqlite3_snapshot_get()] must be freed using [sqlite3_snapshot_free()]\n** to avoid a memory leak.\n**\n** The [sqlite3_snapshot_get()] interface is only available when the\n** [SQLITE_ENABLE_SNAPSHOT] compile-time option is used.\n*/\nSQLITE_API SQLITE_EXPERIMENTAL int sqlite3_snapshot_get(\n  sqlite3 *db,\n  const char *zSchema,\n  sqlite3_snapshot **ppSnapshot\n);\n\n/*\n** CAPI3REF: Start a read transaction on an historical snapshot\n** METHOD: sqlite3_snapshot\n**\n** ^The [sqlite3_snapshot_open(D,S,P)] interface either starts a new read \n** transaction or upgrades an existing one for schema S of \n** [database connection] D such that the read transaction refers to \n** historical [snapshot] P, rather than the most recent change to the \n** database. ^The [sqlite3_snapshot_open()] interface returns SQLITE_OK \n** on success or an appropriate [error code] if it fails.\n**\n** ^In order to succeed, the database connection must not be in \n** [autocommit mode] when [sqlite3_snapshot_open(D,S,P)] is called. If there\n** is already a read transaction open on schema S, then the database handle\n** must have no active statements (SELECT statements that have been passed\n** to sqlite3_step() but not sqlite3_reset() or sqlite3_finalize()). \n** SQLITE_ERROR is returned if either of these conditions is violated, or\n** if schema S does not exist, or if the snapshot object is invalid.\n**\n** ^A call to sqlite3_snapshot_open() will fail to open if the specified\n** snapshot has been overwritten by a [checkpoint]. In this case \n** SQLITE_ERROR_SNAPSHOT is returned.\n**\n** If there is already a read transaction open when this function is \n** invoked, then the same read transaction remains open (on the same\n** database snapshot) if SQLITE_ERROR, SQLITE_BUSY or SQLITE_ERROR_SNAPSHOT\n** is returned. If another error code - for example SQLITE_PROTOCOL or an\n** SQLITE_IOERR error code - is returned, then the final state of the\n** read transaction is undefined. If SQLITE_OK is returned, then the \n** read transaction is now open on database snapshot P.\n**\n** ^(A call to [sqlite3_snapshot_open(D,S,P)] will fail if the\n** database connection D does not know that the database file for\n** schema S is in [WAL mode].  A database connection might not know\n** that the database file is in [WAL mode] if there has been no prior\n** I/O on that database connection, or if the database entered [WAL mode] \n** after the most recent I/O on the database connection.)^\n** (Hint: Run \"[PRAGMA application_id]\" against a newly opened\n** database connection in order to make it ready to use snapshots.)\n**\n** The [sqlite3_snapshot_open()] interface is only available when the\n** [SQLITE_ENABLE_SNAPSHOT] compile-time option is used.\n*/\nSQLITE_API SQLITE_EXPERIMENTAL int sqlite3_snapshot_open(\n  sqlite3 *db,\n  const char *zSchema,\n  sqlite3_snapshot *pSnapshot\n);\n\n/*\n** CAPI3REF: Destroy a snapshot\n** DESTRUCTOR: sqlite3_snapshot\n**\n** ^The [sqlite3_snapshot_free(P)] interface destroys [sqlite3_snapshot] P.\n** The application must eventually free every [sqlite3_snapshot] object\n** using this routine to avoid a memory leak.\n**\n** The [sqlite3_snapshot_free()] interface is only available when the\n** [SQLITE_ENABLE_SNAPSHOT] compile-time option is used.\n*/\nSQLITE_API SQLITE_EXPERIMENTAL void sqlite3_snapshot_free(sqlite3_snapshot*);\n\n/*\n** CAPI3REF: Compare the ages of two snapshot handles.\n** METHOD: sqlite3_snapshot\n**\n** The sqlite3_snapshot_cmp(P1, P2) interface is used to compare the ages\n** of two valid snapshot handles. \n**\n** If the two snapshot handles are not associated with the same database \n** file, the result of the comparison is undefined. \n**\n** Additionally, the result of the comparison is only valid if both of the\n** snapshot handles were obtained by calling sqlite3_snapshot_get() since the\n** last time the wal file was deleted. The wal file is deleted when the\n** database is changed back to rollback mode or when the number of database\n** clients drops to zero. If either snapshot handle was obtained before the \n** wal file was last deleted, the value returned by this function \n** is undefined.\n**\n** Otherwise, this API returns a negative value if P1 refers to an older\n** snapshot than P2, zero if the two handles refer to the same database\n** snapshot, and a positive value if P1 is a newer snapshot than P2.\n**\n** This interface is only available if SQLite is compiled with the\n** [SQLITE_ENABLE_SNAPSHOT] option.\n*/\nSQLITE_API SQLITE_EXPERIMENTAL int sqlite3_snapshot_cmp(\n  sqlite3_snapshot *p1,\n  sqlite3_snapshot *p2\n);\n\n/*\n** CAPI3REF: Recover snapshots from a wal file\n** METHOD: sqlite3_snapshot\n**\n** If a [WAL file] remains on disk after all database connections close\n** (either through the use of the [SQLITE_FCNTL_PERSIST_WAL] [file control]\n** or because the last process to have the database opened exited without\n** calling [sqlite3_close()]) and a new connection is subsequently opened\n** on that database and [WAL file], the [sqlite3_snapshot_open()] interface\n** will only be able to open the last transaction added to the WAL file\n** even though the WAL file contains other valid transactions.\n**\n** This function attempts to scan the WAL file associated with database zDb\n** of database handle db and make all valid snapshots available to\n** sqlite3_snapshot_open(). It is an error if there is already a read\n** transaction open on the database, or if the database is not a WAL mode\n** database.\n**\n** SQLITE_OK is returned if successful, or an SQLite error code otherwise.\n**\n** This interface is only available if SQLite is compiled with the\n** [SQLITE_ENABLE_SNAPSHOT] option.\n*/\nSQLITE_API SQLITE_EXPERIMENTAL int sqlite3_snapshot_recover(sqlite3 *db, const char *zDb);\n\n/*\n** CAPI3REF: Serialize a database\n**\n** The sqlite3_serialize(D,S,P,F) interface returns a pointer to memory\n** that is a serialization of the S database on [database connection] D.\n** If P is not a NULL pointer, then the size of the database in bytes\n** is written into *P.\n**\n** For an ordinary on-disk database file, the serialization is just a\n** copy of the disk file.  For an in-memory database or a \"TEMP\" database,\n** the serialization is the same sequence of bytes which would be written\n** to disk if that database where backed up to disk.\n**\n** The usual case is that sqlite3_serialize() copies the serialization of\n** the database into memory obtained from [sqlite3_malloc64()] and returns\n** a pointer to that memory.  The caller is responsible for freeing the\n** returned value to avoid a memory leak.  However, if the F argument\n** contains the SQLITE_SERIALIZE_NOCOPY bit, then no memory allocations\n** are made, and the sqlite3_serialize() function will return a pointer\n** to the contiguous memory representation of the database that SQLite\n** is currently using for that database, or NULL if the no such contiguous\n** memory representation of the database exists.  A contiguous memory\n** representation of the database will usually only exist if there has\n** been a prior call to [sqlite3_deserialize(D,S,...)] with the same\n** values of D and S.\n** The size of the database is written into *P even if the \n** SQLITE_SERIALIZE_NOCOPY bit is set but no contiguous copy\n** of the database exists.\n**\n** A call to sqlite3_serialize(D,S,P,F) might return NULL even if the\n** SQLITE_SERIALIZE_NOCOPY bit is omitted from argument F if a memory\n** allocation error occurs.\n**\n** This interface is only available if SQLite is compiled with the\n** [SQLITE_ENABLE_DESERIALIZE] option.\n*/\nSQLITE_API unsigned char *sqlite3_serialize(\n  sqlite3 *db,           /* The database connection */\n  const char *zSchema,   /* Which DB to serialize. ex: \"main\", \"temp\", ... */\n  sqlite3_int64 *piSize, /* Write size of the DB here, if not NULL */\n  unsigned int mFlags    /* Zero or more SQLITE_SERIALIZE_* flags */\n);\n\n/*\n** CAPI3REF: Flags for sqlite3_serialize\n**\n** Zero or more of the following constants can be OR-ed together for\n** the F argument to [sqlite3_serialize(D,S,P,F)].\n**\n** SQLITE_SERIALIZE_NOCOPY means that [sqlite3_serialize()] will return\n** a pointer to contiguous in-memory database that it is currently using,\n** without making a copy of the database.  If SQLite is not currently using\n** a contiguous in-memory database, then this option causes\n** [sqlite3_serialize()] to return a NULL pointer.  SQLite will only be\n** using a contiguous in-memory database if it has been initialized by a\n** prior call to [sqlite3_deserialize()].\n*/\n#define SQLITE_SERIALIZE_NOCOPY 0x001   /* Do no memory allocations */\n\n/*\n** CAPI3REF: Deserialize a database\n**\n** The sqlite3_deserialize(D,S,P,N,M,F) interface causes the \n** [database connection] D to disconnect from database S and then\n** reopen S as an in-memory database based on the serialization contained\n** in P.  The serialized database P is N bytes in size.  M is the size of\n** the buffer P, which might be larger than N.  If M is larger than N, and\n** the SQLITE_DESERIALIZE_READONLY bit is not set in F, then SQLite is\n** permitted to add content to the in-memory database as long as the total\n** size does not exceed M bytes.\n**\n** If the SQLITE_DESERIALIZE_FREEONCLOSE bit is set in F, then SQLite will\n** invoke sqlite3_free() on the serialization buffer when the database\n** connection closes.  If the SQLITE_DESERIALIZE_RESIZEABLE bit is set, then\n** SQLite will try to increase the buffer size using sqlite3_realloc64()\n** if writes on the database cause it to grow larger than M bytes.\n**\n** The sqlite3_deserialize() interface will fail with SQLITE_BUSY if the\n** database is currently in a read transaction or is involved in a backup\n** operation.\n**\n** If sqlite3_deserialize(D,S,P,N,M,F) fails for any reason and if the \n** SQLITE_DESERIALIZE_FREEONCLOSE bit is set in argument F, then\n** [sqlite3_free()] is invoked on argument P prior to returning.\n**\n** This interface is only available if SQLite is compiled with the\n** [SQLITE_ENABLE_DESERIALIZE] option.\n*/\nSQLITE_API int sqlite3_deserialize(\n  sqlite3 *db,            /* The database connection */\n  const char *zSchema,    /* Which DB to reopen with the deserialization */\n  unsigned char *pData,   /* The serialized database content */\n  sqlite3_int64 szDb,     /* Number bytes in the deserialization */\n  sqlite3_int64 szBuf,    /* Total size of buffer pData[] */\n  unsigned mFlags         /* Zero or more SQLITE_DESERIALIZE_* flags */\n);\n\n/*\n** CAPI3REF: Flags for sqlite3_deserialize()\n**\n** The following are allowed values for 6th argument (the F argument) to\n** the [sqlite3_deserialize(D,S,P,N,M,F)] interface.\n**\n** The SQLITE_DESERIALIZE_FREEONCLOSE means that the database serialization\n** in the P argument is held in memory obtained from [sqlite3_malloc64()]\n** and that SQLite should take ownership of this memory and automatically\n** free it when it has finished using it.  Without this flag, the caller\n** is responsible for freeing any dynamically allocated memory.\n**\n** The SQLITE_DESERIALIZE_RESIZEABLE flag means that SQLite is allowed to\n** grow the size of the database using calls to [sqlite3_realloc64()].  This\n** flag should only be used if SQLITE_DESERIALIZE_FREEONCLOSE is also used.\n** Without this flag, the deserialized database cannot increase in size beyond\n** the number of bytes specified by the M parameter.\n**\n** The SQLITE_DESERIALIZE_READONLY flag means that the deserialized database\n** should be treated as read-only.\n*/\n#define SQLITE_DESERIALIZE_FREEONCLOSE 1 /* Call sqlite3_free() on close */\n#define SQLITE_DESERIALIZE_RESIZEABLE  2 /* Resize using sqlite3_realloc64() */\n#define SQLITE_DESERIALIZE_READONLY    4 /* Database is read-only */\n\n/*\n** Undo the hack that converts floating point types to integer for\n** builds on processors without floating point support.\n*/\n#ifdef SQLITE_OMIT_FLOATING_POINT\n# undef double\n#endif\n\n#if 0\n}  /* End of the 'extern \"C\"' block */\n#endif\n#endif /* SQLITE3_H */\n\n/******** Begin file sqlite3rtree.h *********/\n/*\n** 2010 August 30\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n*/\n\n#ifndef _SQLITE3RTREE_H_\n#define _SQLITE3RTREE_H_\n\n\n#if 0\nextern \"C\" {\n#endif\n\ntypedef struct sqlite3_rtree_geometry sqlite3_rtree_geometry;\ntypedef struct sqlite3_rtree_query_info sqlite3_rtree_query_info;\n\n/* The double-precision datatype used by RTree depends on the\n** SQLITE_RTREE_INT_ONLY compile-time option.\n*/\n#ifdef SQLITE_RTREE_INT_ONLY\n  typedef sqlite3_int64 sqlite3_rtree_dbl;\n#else\n  typedef double sqlite3_rtree_dbl;\n#endif\n\n/*\n** Register a geometry callback named zGeom that can be used as part of an\n** R-Tree geometry query as follows:\n**\n**   SELECT ... FROM <rtree> WHERE <rtree col> MATCH $zGeom(... params ...)\n*/\nSQLITE_API int sqlite3_rtree_geometry_callback(\n  sqlite3 *db,\n  const char *zGeom,\n  int (*xGeom)(sqlite3_rtree_geometry*, int, sqlite3_rtree_dbl*,int*),\n  void *pContext\n);\n\n\n/*\n** A pointer to a structure of the following type is passed as the first\n** argument to callbacks registered using rtree_geometry_callback().\n*/\nstruct sqlite3_rtree_geometry {\n  void *pContext;                 /* Copy of pContext passed to s_r_g_c() */\n  int nParam;                     /* Size of array aParam[] */\n  sqlite3_rtree_dbl *aParam;      /* Parameters passed to SQL geom function */\n  void *pUser;                    /* Callback implementation user data */\n  void (*xDelUser)(void *);       /* Called by SQLite to clean up pUser */\n};\n\n/*\n** Register a 2nd-generation geometry callback named zScore that can be \n** used as part of an R-Tree geometry query as follows:\n**\n**   SELECT ... FROM <rtree> WHERE <rtree col> MATCH $zQueryFunc(... params ...)\n*/\nSQLITE_API int sqlite3_rtree_query_callback(\n  sqlite3 *db,\n  const char *zQueryFunc,\n  int (*xQueryFunc)(sqlite3_rtree_query_info*),\n  void *pContext,\n  void (*xDestructor)(void*)\n);\n\n\n/*\n** A pointer to a structure of the following type is passed as the \n** argument to scored geometry callback registered using\n** sqlite3_rtree_query_callback().\n**\n** Note that the first 5 fields of this structure are identical to\n** sqlite3_rtree_geometry.  This structure is a subclass of\n** sqlite3_rtree_geometry.\n*/\nstruct sqlite3_rtree_query_info {\n  void *pContext;                   /* pContext from when function registered */\n  int nParam;                       /* Number of function parameters */\n  sqlite3_rtree_dbl *aParam;        /* value of function parameters */\n  void *pUser;                      /* callback can use this, if desired */\n  void (*xDelUser)(void*);          /* function to free pUser */\n  sqlite3_rtree_dbl *aCoord;        /* Coordinates of node or entry to check */\n  unsigned int *anQueue;            /* Number of pending entries in the queue */\n  int nCoord;                       /* Number of coordinates */\n  int iLevel;                       /* Level of current node or entry */\n  int mxLevel;                      /* The largest iLevel value in the tree */\n  sqlite3_int64 iRowid;             /* Rowid for current entry */\n  sqlite3_rtree_dbl rParentScore;   /* Score of parent node */\n  int eParentWithin;                /* Visibility of parent node */\n  int eWithin;                      /* OUT: Visibility */\n  sqlite3_rtree_dbl rScore;         /* OUT: Write the score here */\n  /* The following fields are only available in 3.8.11 and later */\n  sqlite3_value **apSqlParam;       /* Original SQL values of parameters */\n};\n\n/*\n** Allowed values for sqlite3_rtree_query.eWithin and .eParentWithin.\n*/\n#define NOT_WITHIN       0   /* Object completely outside of query region */\n#define PARTLY_WITHIN    1   /* Object partially overlaps query region */\n#define FULLY_WITHIN     2   /* Object fully contained within query region */\n\n\n#if 0\n}  /* end of the 'extern \"C\"' block */\n#endif\n\n#endif  /* ifndef _SQLITE3RTREE_H_ */\n\n/******** End of sqlite3rtree.h *********/\n/******** Begin file sqlite3session.h *********/\n\n#if !defined(__SQLITESESSION_H_) && defined(SQLITE_ENABLE_SESSION)\n#define __SQLITESESSION_H_ 1\n\n/*\n** Make sure we can call this stuff from C++.\n*/\n#if 0\nextern \"C\" {\n#endif\n\n\n/*\n** CAPI3REF: Session Object Handle\n**\n** An instance of this object is a [session] that can be used to\n** record changes to a database.\n*/\ntypedef struct sqlite3_session sqlite3_session;\n\n/*\n** CAPI3REF: Changeset Iterator Handle\n**\n** An instance of this object acts as a cursor for iterating\n** over the elements of a [changeset] or [patchset].\n*/\ntypedef struct sqlite3_changeset_iter sqlite3_changeset_iter;\n\n/*\n** CAPI3REF: Create A New Session Object\n** CONSTRUCTOR: sqlite3_session\n**\n** Create a new session object attached to database handle db. If successful,\n** a pointer to the new object is written to *ppSession and SQLITE_OK is\n** returned. If an error occurs, *ppSession is set to NULL and an SQLite\n** error code (e.g. SQLITE_NOMEM) is returned.\n**\n** It is possible to create multiple session objects attached to a single\n** database handle.\n**\n** Session objects created using this function should be deleted using the\n** [sqlite3session_delete()] function before the database handle that they\n** are attached to is itself closed. If the database handle is closed before\n** the session object is deleted, then the results of calling any session\n** module function, including [sqlite3session_delete()] on the session object\n** are undefined.\n**\n** Because the session module uses the [sqlite3_preupdate_hook()] API, it\n** is not possible for an application to register a pre-update hook on a\n** database handle that has one or more session objects attached. Nor is\n** it possible to create a session object attached to a database handle for\n** which a pre-update hook is already defined. The results of attempting \n** either of these things are undefined.\n**\n** The session object will be used to create changesets for tables in\n** database zDb, where zDb is either \"main\", or \"temp\", or the name of an\n** attached database. It is not an error if database zDb is not attached\n** to the database when the session object is created.\n*/\nSQLITE_API int sqlite3session_create(\n  sqlite3 *db,                    /* Database handle */\n  const char *zDb,                /* Name of db (e.g. \"main\") */\n  sqlite3_session **ppSession     /* OUT: New session object */\n);\n\n/*\n** CAPI3REF: Delete A Session Object\n** DESTRUCTOR: sqlite3_session\n**\n** Delete a session object previously allocated using \n** [sqlite3session_create()]. Once a session object has been deleted, the\n** results of attempting to use pSession with any other session module\n** function are undefined.\n**\n** Session objects must be deleted before the database handle to which they\n** are attached is closed. Refer to the documentation for \n** [sqlite3session_create()] for details.\n*/\nSQLITE_API void sqlite3session_delete(sqlite3_session *pSession);\n\n\n/*\n** CAPI3REF: Enable Or Disable A Session Object\n** METHOD: sqlite3_session\n**\n** Enable or disable the recording of changes by a session object. When\n** enabled, a session object records changes made to the database. When\n** disabled - it does not. A newly created session object is enabled.\n** Refer to the documentation for [sqlite3session_changeset()] for further\n** details regarding how enabling and disabling a session object affects\n** the eventual changesets.\n**\n** Passing zero to this function disables the session. Passing a value\n** greater than zero enables it. Passing a value less than zero is a \n** no-op, and may be used to query the current state of the session.\n**\n** The return value indicates the final state of the session object: 0 if \n** the session is disabled, or 1 if it is enabled.\n*/\nSQLITE_API int sqlite3session_enable(sqlite3_session *pSession, int bEnable);\n\n/*\n** CAPI3REF: Set Or Clear the Indirect Change Flag\n** METHOD: sqlite3_session\n**\n** Each change recorded by a session object is marked as either direct or\n** indirect. A change is marked as indirect if either:\n**\n** <ul>\n**   <li> The session object \"indirect\" flag is set when the change is\n**        made, or\n**   <li> The change is made by an SQL trigger or foreign key action \n**        instead of directly as a result of a users SQL statement.\n** </ul>\n**\n** If a single row is affected by more than one operation within a session,\n** then the change is considered indirect if all operations meet the criteria\n** for an indirect change above, or direct otherwise.\n**\n** This function is used to set, clear or query the session object indirect\n** flag.  If the second argument passed to this function is zero, then the\n** indirect flag is cleared. If it is greater than zero, the indirect flag\n** is set. Passing a value less than zero does not modify the current value\n** of the indirect flag, and may be used to query the current state of the \n** indirect flag for the specified session object.\n**\n** The return value indicates the final state of the indirect flag: 0 if \n** it is clear, or 1 if it is set.\n*/\nSQLITE_API int sqlite3session_indirect(sqlite3_session *pSession, int bIndirect);\n\n/*\n** CAPI3REF: Attach A Table To A Session Object\n** METHOD: sqlite3_session\n**\n** If argument zTab is not NULL, then it is the name of a table to attach\n** to the session object passed as the first argument. All subsequent changes \n** made to the table while the session object is enabled will be recorded. See \n** documentation for [sqlite3session_changeset()] for further details.\n**\n** Or, if argument zTab is NULL, then changes are recorded for all tables\n** in the database. If additional tables are added to the database (by \n** executing \"CREATE TABLE\" statements) after this call is made, changes for \n** the new tables are also recorded.\n**\n** Changes can only be recorded for tables that have a PRIMARY KEY explicitly\n** defined as part of their CREATE TABLE statement. It does not matter if the \n** PRIMARY KEY is an \"INTEGER PRIMARY KEY\" (rowid alias) or not. The PRIMARY\n** KEY may consist of a single column, or may be a composite key.\n** \n** It is not an error if the named table does not exist in the database. Nor\n** is it an error if the named table does not have a PRIMARY KEY. However,\n** no changes will be recorded in either of these scenarios.\n**\n** Changes are not recorded for individual rows that have NULL values stored\n** in one or more of their PRIMARY KEY columns.\n**\n** SQLITE_OK is returned if the call completes without error. Or, if an error \n** occurs, an SQLite error code (e.g. SQLITE_NOMEM) is returned.\n**\n** <h3>Special sqlite_stat1 Handling</h3>\n**\n** As of SQLite version 3.22.0, the \"sqlite_stat1\" table is an exception to \n** some of the rules above. In SQLite, the schema of sqlite_stat1 is:\n**  <pre>\n**  &nbsp;     CREATE TABLE sqlite_stat1(tbl,idx,stat)  \n**  </pre>\n**\n** Even though sqlite_stat1 does not have a PRIMARY KEY, changes are \n** recorded for it as if the PRIMARY KEY is (tbl,idx). Additionally, changes \n** are recorded for rows for which (idx IS NULL) is true. However, for such\n** rows a zero-length blob (SQL value X'') is stored in the changeset or\n** patchset instead of a NULL value. This allows such changesets to be\n** manipulated by legacy implementations of sqlite3changeset_invert(),\n** concat() and similar.\n**\n** The sqlite3changeset_apply() function automatically converts the \n** zero-length blob back to a NULL value when updating the sqlite_stat1\n** table. However, if the application calls sqlite3changeset_new(),\n** sqlite3changeset_old() or sqlite3changeset_conflict on a changeset \n** iterator directly (including on a changeset iterator passed to a\n** conflict-handler callback) then the X'' value is returned. The application\n** must translate X'' to NULL itself if required.\n**\n** Legacy (older than 3.22.0) versions of the sessions module cannot capture\n** changes made to the sqlite_stat1 table. Legacy versions of the\n** sqlite3changeset_apply() function silently ignore any modifications to the\n** sqlite_stat1 table that are part of a changeset or patchset.\n*/\nSQLITE_API int sqlite3session_attach(\n  sqlite3_session *pSession,      /* Session object */\n  const char *zTab                /* Table name */\n);\n\n/*\n** CAPI3REF: Set a table filter on a Session Object.\n** METHOD: sqlite3_session\n**\n** The second argument (xFilter) is the \"filter callback\". For changes to rows \n** in tables that are not attached to the Session object, the filter is called\n** to determine whether changes to the table's rows should be tracked or not. \n** If xFilter returns 0, changes is not tracked. Note that once a table is \n** attached, xFilter will not be called again.\n*/\nSQLITE_API void sqlite3session_table_filter(\n  sqlite3_session *pSession,      /* Session object */\n  int(*xFilter)(\n    void *pCtx,                   /* Copy of third arg to _filter_table() */\n    const char *zTab              /* Table name */\n  ),\n  void *pCtx                      /* First argument passed to xFilter */\n);\n\n/*\n** CAPI3REF: Generate A Changeset From A Session Object\n** METHOD: sqlite3_session\n**\n** Obtain a changeset containing changes to the tables attached to the \n** session object passed as the first argument. If successful, \n** set *ppChangeset to point to a buffer containing the changeset \n** and *pnChangeset to the size of the changeset in bytes before returning\n** SQLITE_OK. If an error occurs, set both *ppChangeset and *pnChangeset to\n** zero and return an SQLite error code.\n**\n** A changeset consists of zero or more INSERT, UPDATE and/or DELETE changes,\n** each representing a change to a single row of an attached table. An INSERT\n** change contains the values of each field of a new database row. A DELETE\n** contains the original values of each field of a deleted database row. An\n** UPDATE change contains the original values of each field of an updated\n** database row along with the updated values for each updated non-primary-key\n** column. It is not possible for an UPDATE change to represent a change that\n** modifies the values of primary key columns. If such a change is made, it\n** is represented in a changeset as a DELETE followed by an INSERT.\n**\n** Changes are not recorded for rows that have NULL values stored in one or \n** more of their PRIMARY KEY columns. If such a row is inserted or deleted,\n** no corresponding change is present in the changesets returned by this\n** function. If an existing row with one or more NULL values stored in\n** PRIMARY KEY columns is updated so that all PRIMARY KEY columns are non-NULL,\n** only an INSERT is appears in the changeset. Similarly, if an existing row\n** with non-NULL PRIMARY KEY values is updated so that one or more of its\n** PRIMARY KEY columns are set to NULL, the resulting changeset contains a\n** DELETE change only.\n**\n** The contents of a changeset may be traversed using an iterator created\n** using the [sqlite3changeset_start()] API. A changeset may be applied to\n** a database with a compatible schema using the [sqlite3changeset_apply()]\n** API.\n**\n** Within a changeset generated by this function, all changes related to a\n** single table are grouped together. In other words, when iterating through\n** a changeset or when applying a changeset to a database, all changes related\n** to a single table are processed before moving on to the next table. Tables\n** are sorted in the same order in which they were attached (or auto-attached)\n** to the sqlite3_session object. The order in which the changes related to\n** a single table are stored is undefined.\n**\n** Following a successful call to this function, it is the responsibility of\n** the caller to eventually free the buffer that *ppChangeset points to using\n** [sqlite3_free()].\n**\n** <h3>Changeset Generation</h3>\n**\n** Once a table has been attached to a session object, the session object\n** records the primary key values of all new rows inserted into the table.\n** It also records the original primary key and other column values of any\n** deleted or updated rows. For each unique primary key value, data is only\n** recorded once - the first time a row with said primary key is inserted,\n** updated or deleted in the lifetime of the session.\n**\n** There is one exception to the previous paragraph: when a row is inserted,\n** updated or deleted, if one or more of its primary key columns contain a\n** NULL value, no record of the change is made.\n**\n** The session object therefore accumulates two types of records - those\n** that consist of primary key values only (created when the user inserts\n** a new record) and those that consist of the primary key values and the\n** original values of other table columns (created when the users deletes\n** or updates a record).\n**\n** When this function is called, the requested changeset is created using\n** both the accumulated records and the current contents of the database\n** file. Specifically:\n**\n** <ul>\n**   <li> For each record generated by an insert, the database is queried\n**        for a row with a matching primary key. If one is found, an INSERT\n**        change is added to the changeset. If no such row is found, no change \n**        is added to the changeset.\n**\n**   <li> For each record generated by an update or delete, the database is \n**        queried for a row with a matching primary key. If such a row is\n**        found and one or more of the non-primary key fields have been\n**        modified from their original values, an UPDATE change is added to \n**        the changeset. Or, if no such row is found in the table, a DELETE \n**        change is added to the changeset. If there is a row with a matching\n**        primary key in the database, but all fields contain their original\n**        values, no change is added to the changeset.\n** </ul>\n**\n** This means, amongst other things, that if a row is inserted and then later\n** deleted while a session object is active, neither the insert nor the delete\n** will be present in the changeset. Or if a row is deleted and then later a \n** row with the same primary key values inserted while a session object is\n** active, the resulting changeset will contain an UPDATE change instead of\n** a DELETE and an INSERT.\n**\n** When a session object is disabled (see the [sqlite3session_enable()] API),\n** it does not accumulate records when rows are inserted, updated or deleted.\n** This may appear to have some counter-intuitive effects if a single row\n** is written to more than once during a session. For example, if a row\n** is inserted while a session object is enabled, then later deleted while \n** the same session object is disabled, no INSERT record will appear in the\n** changeset, even though the delete took place while the session was disabled.\n** Or, if one field of a row is updated while a session is disabled, and \n** another field of the same row is updated while the session is enabled, the\n** resulting changeset will contain an UPDATE change that updates both fields.\n*/\nSQLITE_API int sqlite3session_changeset(\n  sqlite3_session *pSession,      /* Session object */\n  int *pnChangeset,               /* OUT: Size of buffer at *ppChangeset */\n  void **ppChangeset              /* OUT: Buffer containing changeset */\n);\n\n/*\n** CAPI3REF: Load The Difference Between Tables Into A Session\n** METHOD: sqlite3_session\n**\n** If it is not already attached to the session object passed as the first\n** argument, this function attaches table zTbl in the same manner as the\n** [sqlite3session_attach()] function. If zTbl does not exist, or if it\n** does not have a primary key, this function is a no-op (but does not return\n** an error).\n**\n** Argument zFromDb must be the name of a database (\"main\", \"temp\" etc.)\n** attached to the same database handle as the session object that contains \n** a table compatible with the table attached to the session by this function.\n** A table is considered compatible if it:\n**\n** <ul>\n**   <li> Has the same name,\n**   <li> Has the same set of columns declared in the same order, and\n**   <li> Has the same PRIMARY KEY definition.\n** </ul>\n**\n** If the tables are not compatible, SQLITE_SCHEMA is returned. If the tables\n** are compatible but do not have any PRIMARY KEY columns, it is not an error\n** but no changes are added to the session object. As with other session\n** APIs, tables without PRIMARY KEYs are simply ignored.\n**\n** This function adds a set of changes to the session object that could be\n** used to update the table in database zFrom (call this the \"from-table\") \n** so that its content is the same as the table attached to the session \n** object (call this the \"to-table\"). Specifically:\n**\n** <ul>\n**   <li> For each row (primary key) that exists in the to-table but not in \n**     the from-table, an INSERT record is added to the session object.\n**\n**   <li> For each row (primary key) that exists in the to-table but not in \n**     the from-table, a DELETE record is added to the session object.\n**\n**   <li> For each row (primary key) that exists in both tables, but features \n**     different non-PK values in each, an UPDATE record is added to the\n**     session.  \n** </ul>\n**\n** To clarify, if this function is called and then a changeset constructed\n** using [sqlite3session_changeset()], then after applying that changeset to \n** database zFrom the contents of the two compatible tables would be \n** identical.\n**\n** It an error if database zFrom does not exist or does not contain the\n** required compatible table.\n**\n** If the operation successful, SQLITE_OK is returned. Otherwise, an SQLite\n** error code. In this case, if argument pzErrMsg is not NULL, *pzErrMsg\n** may be set to point to a buffer containing an English language error \n** message. It is the responsibility of the caller to free this buffer using\n** sqlite3_free().\n*/\nSQLITE_API int sqlite3session_diff(\n  sqlite3_session *pSession,\n  const char *zFromDb,\n  const char *zTbl,\n  char **pzErrMsg\n);\n\n\n/*\n** CAPI3REF: Generate A Patchset From A Session Object\n** METHOD: sqlite3_session\n**\n** The differences between a patchset and a changeset are that:\n**\n** <ul>\n**   <li> DELETE records consist of the primary key fields only. The \n**        original values of other fields are omitted.\n**   <li> The original values of any modified fields are omitted from \n**        UPDATE records.\n** </ul>\n**\n** A patchset blob may be used with up to date versions of all \n** sqlite3changeset_xxx API functions except for sqlite3changeset_invert(), \n** which returns SQLITE_CORRUPT if it is passed a patchset. Similarly,\n** attempting to use a patchset blob with old versions of the\n** sqlite3changeset_xxx APIs also provokes an SQLITE_CORRUPT error. \n**\n** Because the non-primary key \"old.*\" fields are omitted, no \n** SQLITE_CHANGESET_DATA conflicts can be detected or reported if a patchset\n** is passed to the sqlite3changeset_apply() API. Other conflict types work\n** in the same way as for changesets.\n**\n** Changes within a patchset are ordered in the same way as for changesets\n** generated by the sqlite3session_changeset() function (i.e. all changes for\n** a single table are grouped together, tables appear in the order in which\n** they were attached to the session object).\n*/\nSQLITE_API int sqlite3session_patchset(\n  sqlite3_session *pSession,      /* Session object */\n  int *pnPatchset,                /* OUT: Size of buffer at *ppPatchset */\n  void **ppPatchset               /* OUT: Buffer containing patchset */\n);\n\n/*\n** CAPI3REF: Test if a changeset has recorded any changes.\n**\n** Return non-zero if no changes to attached tables have been recorded by \n** the session object passed as the first argument. Otherwise, if one or \n** more changes have been recorded, return zero.\n**\n** Even if this function returns zero, it is possible that calling\n** [sqlite3session_changeset()] on the session handle may still return a\n** changeset that contains no changes. This can happen when a row in \n** an attached table is modified and then later on the original values \n** are restored. However, if this function returns non-zero, then it is\n** guaranteed that a call to sqlite3session_changeset() will return a \n** changeset containing zero changes.\n*/\nSQLITE_API int sqlite3session_isempty(sqlite3_session *pSession);\n\n/*\n** CAPI3REF: Create An Iterator To Traverse A Changeset \n** CONSTRUCTOR: sqlite3_changeset_iter\n**\n** Create an iterator used to iterate through the contents of a changeset.\n** If successful, *pp is set to point to the iterator handle and SQLITE_OK\n** is returned. Otherwise, if an error occurs, *pp is set to zero and an\n** SQLite error code is returned.\n**\n** The following functions can be used to advance and query a changeset \n** iterator created by this function:\n**\n** <ul>\n**   <li> [sqlite3changeset_next()]\n**   <li> [sqlite3changeset_op()]\n**   <li> [sqlite3changeset_new()]\n**   <li> [sqlite3changeset_old()]\n** </ul>\n**\n** It is the responsibility of the caller to eventually destroy the iterator\n** by passing it to [sqlite3changeset_finalize()]. The buffer containing the\n** changeset (pChangeset) must remain valid until after the iterator is\n** destroyed.\n**\n** Assuming the changeset blob was created by one of the\n** [sqlite3session_changeset()], [sqlite3changeset_concat()] or\n** [sqlite3changeset_invert()] functions, all changes within the changeset \n** that apply to a single table are grouped together. This means that when \n** an application iterates through a changeset using an iterator created by \n** this function, all changes that relate to a single table are visited \n** consecutively. There is no chance that the iterator will visit a change \n** the applies to table X, then one for table Y, and then later on visit \n** another change for table X.\n**\n** The behavior of sqlite3changeset_start_v2() and its streaming equivalent\n** may be modified by passing a combination of\n** [SQLITE_CHANGESETSTART_INVERT | supported flags] as the 4th parameter.\n**\n** Note that the sqlite3changeset_start_v2() API is still <b>experimental</b>\n** and therefore subject to change.\n*/\nSQLITE_API int sqlite3changeset_start(\n  sqlite3_changeset_iter **pp,    /* OUT: New changeset iterator handle */\n  int nChangeset,                 /* Size of changeset blob in bytes */\n  void *pChangeset                /* Pointer to blob containing changeset */\n);\nSQLITE_API int sqlite3changeset_start_v2(\n  sqlite3_changeset_iter **pp,    /* OUT: New changeset iterator handle */\n  int nChangeset,                 /* Size of changeset blob in bytes */\n  void *pChangeset,               /* Pointer to blob containing changeset */\n  int flags                       /* SESSION_CHANGESETSTART_* flags */\n);\n\n/*\n** CAPI3REF: Flags for sqlite3changeset_start_v2\n**\n** The following flags may passed via the 4th parameter to\n** [sqlite3changeset_start_v2] and [sqlite3changeset_start_v2_strm]:\n**\n** <dt>SQLITE_CHANGESETAPPLY_INVERT <dd>\n**   Invert the changeset while iterating through it. This is equivalent to\n**   inverting a changeset using sqlite3changeset_invert() before applying it.\n**   It is an error to specify this flag with a patchset.\n*/\n#define SQLITE_CHANGESETSTART_INVERT        0x0002\n\n\n/*\n** CAPI3REF: Advance A Changeset Iterator\n** METHOD: sqlite3_changeset_iter\n**\n** This function may only be used with iterators created by function\n** [sqlite3changeset_start()]. If it is called on an iterator passed to\n** a conflict-handler callback by [sqlite3changeset_apply()], SQLITE_MISUSE\n** is returned and the call has no effect.\n**\n** Immediately after an iterator is created by sqlite3changeset_start(), it\n** does not point to any change in the changeset. Assuming the changeset\n** is not empty, the first call to this function advances the iterator to\n** point to the first change in the changeset. Each subsequent call advances\n** the iterator to point to the next change in the changeset (if any). If\n** no error occurs and the iterator points to a valid change after a call\n** to sqlite3changeset_next() has advanced it, SQLITE_ROW is returned. \n** Otherwise, if all changes in the changeset have already been visited,\n** SQLITE_DONE is returned.\n**\n** If an error occurs, an SQLite error code is returned. Possible error \n** codes include SQLITE_CORRUPT (if the changeset buffer is corrupt) or \n** SQLITE_NOMEM.\n*/\nSQLITE_API int sqlite3changeset_next(sqlite3_changeset_iter *pIter);\n\n/*\n** CAPI3REF: Obtain The Current Operation From A Changeset Iterator\n** METHOD: sqlite3_changeset_iter\n**\n** The pIter argument passed to this function may either be an iterator\n** passed to a conflict-handler by [sqlite3changeset_apply()], or an iterator\n** created by [sqlite3changeset_start()]. In the latter case, the most recent\n** call to [sqlite3changeset_next()] must have returned [SQLITE_ROW]. If this\n** is not the case, this function returns [SQLITE_MISUSE].\n**\n** If argument pzTab is not NULL, then *pzTab is set to point to a\n** nul-terminated utf-8 encoded string containing the name of the table\n** affected by the current change. The buffer remains valid until either\n** sqlite3changeset_next() is called on the iterator or until the \n** conflict-handler function returns. If pnCol is not NULL, then *pnCol is \n** set to the number of columns in the table affected by the change. If\n** pbIndirect is not NULL, then *pbIndirect is set to true (1) if the change\n** is an indirect change, or false (0) otherwise. See the documentation for\n** [sqlite3session_indirect()] for a description of direct and indirect\n** changes. Finally, if pOp is not NULL, then *pOp is set to one of \n** [SQLITE_INSERT], [SQLITE_DELETE] or [SQLITE_UPDATE], depending on the \n** type of change that the iterator currently points to.\n**\n** If no error occurs, SQLITE_OK is returned. If an error does occur, an\n** SQLite error code is returned. The values of the output variables may not\n** be trusted in this case.\n*/\nSQLITE_API int sqlite3changeset_op(\n  sqlite3_changeset_iter *pIter,  /* Iterator object */\n  const char **pzTab,             /* OUT: Pointer to table name */\n  int *pnCol,                     /* OUT: Number of columns in table */\n  int *pOp,                       /* OUT: SQLITE_INSERT, DELETE or UPDATE */\n  int *pbIndirect                 /* OUT: True for an 'indirect' change */\n);\n\n/*\n** CAPI3REF: Obtain The Primary Key Definition Of A Table\n** METHOD: sqlite3_changeset_iter\n**\n** For each modified table, a changeset includes the following:\n**\n** <ul>\n**   <li> The number of columns in the table, and\n**   <li> Which of those columns make up the tables PRIMARY KEY.\n** </ul>\n**\n** This function is used to find which columns comprise the PRIMARY KEY of\n** the table modified by the change that iterator pIter currently points to.\n** If successful, *pabPK is set to point to an array of nCol entries, where\n** nCol is the number of columns in the table. Elements of *pabPK are set to\n** 0x01 if the corresponding column is part of the tables primary key, or\n** 0x00 if it is not.\n**\n** If argument pnCol is not NULL, then *pnCol is set to the number of columns\n** in the table.\n**\n** If this function is called when the iterator does not point to a valid\n** entry, SQLITE_MISUSE is returned and the output variables zeroed. Otherwise,\n** SQLITE_OK is returned and the output variables populated as described\n** above.\n*/\nSQLITE_API int sqlite3changeset_pk(\n  sqlite3_changeset_iter *pIter,  /* Iterator object */\n  unsigned char **pabPK,          /* OUT: Array of boolean - true for PK cols */\n  int *pnCol                      /* OUT: Number of entries in output array */\n);\n\n/*\n** CAPI3REF: Obtain old.* Values From A Changeset Iterator\n** METHOD: sqlite3_changeset_iter\n**\n** The pIter argument passed to this function may either be an iterator\n** passed to a conflict-handler by [sqlite3changeset_apply()], or an iterator\n** created by [sqlite3changeset_start()]. In the latter case, the most recent\n** call to [sqlite3changeset_next()] must have returned SQLITE_ROW. \n** Furthermore, it may only be called if the type of change that the iterator\n** currently points to is either [SQLITE_DELETE] or [SQLITE_UPDATE]. Otherwise,\n** this function returns [SQLITE_MISUSE] and sets *ppValue to NULL.\n**\n** Argument iVal must be greater than or equal to 0, and less than the number\n** of columns in the table affected by the current change. Otherwise,\n** [SQLITE_RANGE] is returned and *ppValue is set to NULL.\n**\n** If successful, this function sets *ppValue to point to a protected\n** sqlite3_value object containing the iVal'th value from the vector of \n** original row values stored as part of the UPDATE or DELETE change and\n** returns SQLITE_OK. The name of the function comes from the fact that this \n** is similar to the \"old.*\" columns available to update or delete triggers.\n**\n** If some other error occurs (e.g. an OOM condition), an SQLite error code\n** is returned and *ppValue is set to NULL.\n*/\nSQLITE_API int sqlite3changeset_old(\n  sqlite3_changeset_iter *pIter,  /* Changeset iterator */\n  int iVal,                       /* Column number */\n  sqlite3_value **ppValue         /* OUT: Old value (or NULL pointer) */\n);\n\n/*\n** CAPI3REF: Obtain new.* Values From A Changeset Iterator\n** METHOD: sqlite3_changeset_iter\n**\n** The pIter argument passed to this function may either be an iterator\n** passed to a conflict-handler by [sqlite3changeset_apply()], or an iterator\n** created by [sqlite3changeset_start()]. In the latter case, the most recent\n** call to [sqlite3changeset_next()] must have returned SQLITE_ROW. \n** Furthermore, it may only be called if the type of change that the iterator\n** currently points to is either [SQLITE_UPDATE] or [SQLITE_INSERT]. Otherwise,\n** this function returns [SQLITE_MISUSE] and sets *ppValue to NULL.\n**\n** Argument iVal must be greater than or equal to 0, and less than the number\n** of columns in the table affected by the current change. Otherwise,\n** [SQLITE_RANGE] is returned and *ppValue is set to NULL.\n**\n** If successful, this function sets *ppValue to point to a protected\n** sqlite3_value object containing the iVal'th value from the vector of \n** new row values stored as part of the UPDATE or INSERT change and\n** returns SQLITE_OK. If the change is an UPDATE and does not include\n** a new value for the requested column, *ppValue is set to NULL and \n** SQLITE_OK returned. The name of the function comes from the fact that \n** this is similar to the \"new.*\" columns available to update or delete \n** triggers.\n**\n** If some other error occurs (e.g. an OOM condition), an SQLite error code\n** is returned and *ppValue is set to NULL.\n*/\nSQLITE_API int sqlite3changeset_new(\n  sqlite3_changeset_iter *pIter,  /* Changeset iterator */\n  int iVal,                       /* Column number */\n  sqlite3_value **ppValue         /* OUT: New value (or NULL pointer) */\n);\n\n/*\n** CAPI3REF: Obtain Conflicting Row Values From A Changeset Iterator\n** METHOD: sqlite3_changeset_iter\n**\n** This function should only be used with iterator objects passed to a\n** conflict-handler callback by [sqlite3changeset_apply()] with either\n** [SQLITE_CHANGESET_DATA] or [SQLITE_CHANGESET_CONFLICT]. If this function\n** is called on any other iterator, [SQLITE_MISUSE] is returned and *ppValue\n** is set to NULL.\n**\n** Argument iVal must be greater than or equal to 0, and less than the number\n** of columns in the table affected by the current change. Otherwise,\n** [SQLITE_RANGE] is returned and *ppValue is set to NULL.\n**\n** If successful, this function sets *ppValue to point to a protected\n** sqlite3_value object containing the iVal'th value from the \n** \"conflicting row\" associated with the current conflict-handler callback\n** and returns SQLITE_OK.\n**\n** If some other error occurs (e.g. an OOM condition), an SQLite error code\n** is returned and *ppValue is set to NULL.\n*/\nSQLITE_API int sqlite3changeset_conflict(\n  sqlite3_changeset_iter *pIter,  /* Changeset iterator */\n  int iVal,                       /* Column number */\n  sqlite3_value **ppValue         /* OUT: Value from conflicting row */\n);\n\n/*\n** CAPI3REF: Determine The Number Of Foreign Key Constraint Violations\n** METHOD: sqlite3_changeset_iter\n**\n** This function may only be called with an iterator passed to an\n** SQLITE_CHANGESET_FOREIGN_KEY conflict handler callback. In this case\n** it sets the output variable to the total number of known foreign key\n** violations in the destination database and returns SQLITE_OK.\n**\n** In all other cases this function returns SQLITE_MISUSE.\n*/\nSQLITE_API int sqlite3changeset_fk_conflicts(\n  sqlite3_changeset_iter *pIter,  /* Changeset iterator */\n  int *pnOut                      /* OUT: Number of FK violations */\n);\n\n\n/*\n** CAPI3REF: Finalize A Changeset Iterator\n** METHOD: sqlite3_changeset_iter\n**\n** This function is used to finalize an iterator allocated with\n** [sqlite3changeset_start()].\n**\n** This function should only be called on iterators created using the\n** [sqlite3changeset_start()] function. If an application calls this\n** function with an iterator passed to a conflict-handler by\n** [sqlite3changeset_apply()], [SQLITE_MISUSE] is immediately returned and the\n** call has no effect.\n**\n** If an error was encountered within a call to an sqlite3changeset_xxx()\n** function (for example an [SQLITE_CORRUPT] in [sqlite3changeset_next()] or an \n** [SQLITE_NOMEM] in [sqlite3changeset_new()]) then an error code corresponding\n** to that error is returned by this function. Otherwise, SQLITE_OK is\n** returned. This is to allow the following pattern (pseudo-code):\n**\n** <pre>\n**   sqlite3changeset_start();\n**   while( SQLITE_ROW==sqlite3changeset_next() ){\n**     // Do something with change.\n**   }\n**   rc = sqlite3changeset_finalize();\n**   if( rc!=SQLITE_OK ){\n**     // An error has occurred \n**   }\n** </pre>\n*/\nSQLITE_API int sqlite3changeset_finalize(sqlite3_changeset_iter *pIter);\n\n/*\n** CAPI3REF: Invert A Changeset\n**\n** This function is used to \"invert\" a changeset object. Applying an inverted\n** changeset to a database reverses the effects of applying the uninverted\n** changeset. Specifically:\n**\n** <ul>\n**   <li> Each DELETE change is changed to an INSERT, and\n**   <li> Each INSERT change is changed to a DELETE, and\n**   <li> For each UPDATE change, the old.* and new.* values are exchanged.\n** </ul>\n**\n** This function does not change the order in which changes appear within\n** the changeset. It merely reverses the sense of each individual change.\n**\n** If successful, a pointer to a buffer containing the inverted changeset\n** is stored in *ppOut, the size of the same buffer is stored in *pnOut, and\n** SQLITE_OK is returned. If an error occurs, both *pnOut and *ppOut are\n** zeroed and an SQLite error code returned.\n**\n** It is the responsibility of the caller to eventually call sqlite3_free()\n** on the *ppOut pointer to free the buffer allocation following a successful \n** call to this function.\n**\n** WARNING/TODO: This function currently assumes that the input is a valid\n** changeset. If it is not, the results are undefined.\n*/\nSQLITE_API int sqlite3changeset_invert(\n  int nIn, const void *pIn,       /* Input changeset */\n  int *pnOut, void **ppOut        /* OUT: Inverse of input */\n);\n\n/*\n** CAPI3REF: Concatenate Two Changeset Objects\n**\n** This function is used to concatenate two changesets, A and B, into a \n** single changeset. The result is a changeset equivalent to applying\n** changeset A followed by changeset B. \n**\n** This function combines the two input changesets using an \n** sqlite3_changegroup object. Calling it produces similar results as the\n** following code fragment:\n**\n** <pre>\n**   sqlite3_changegroup *pGrp;\n**   rc = sqlite3_changegroup_new(&pGrp);\n**   if( rc==SQLITE_OK ) rc = sqlite3changegroup_add(pGrp, nA, pA);\n**   if( rc==SQLITE_OK ) rc = sqlite3changegroup_add(pGrp, nB, pB);\n**   if( rc==SQLITE_OK ){\n**     rc = sqlite3changegroup_output(pGrp, pnOut, ppOut);\n**   }else{\n**     *ppOut = 0;\n**     *pnOut = 0;\n**   }\n** </pre>\n**\n** Refer to the sqlite3_changegroup documentation below for details.\n*/\nSQLITE_API int sqlite3changeset_concat(\n  int nA,                         /* Number of bytes in buffer pA */\n  void *pA,                       /* Pointer to buffer containing changeset A */\n  int nB,                         /* Number of bytes in buffer pB */\n  void *pB,                       /* Pointer to buffer containing changeset B */\n  int *pnOut,                     /* OUT: Number of bytes in output changeset */\n  void **ppOut                    /* OUT: Buffer containing output changeset */\n);\n\n\n/*\n** CAPI3REF: Changegroup Handle\n**\n** A changegroup is an object used to combine two or more \n** [changesets] or [patchsets]\n*/\ntypedef struct sqlite3_changegroup sqlite3_changegroup;\n\n/*\n** CAPI3REF: Create A New Changegroup Object\n** CONSTRUCTOR: sqlite3_changegroup\n**\n** An sqlite3_changegroup object is used to combine two or more changesets\n** (or patchsets) into a single changeset (or patchset). A single changegroup\n** object may combine changesets or patchsets, but not both. The output is\n** always in the same format as the input.\n**\n** If successful, this function returns SQLITE_OK and populates (*pp) with\n** a pointer to a new sqlite3_changegroup object before returning. The caller\n** should eventually free the returned object using a call to \n** sqlite3changegroup_delete(). If an error occurs, an SQLite error code\n** (i.e. SQLITE_NOMEM) is returned and *pp is set to NULL.\n**\n** The usual usage pattern for an sqlite3_changegroup object is as follows:\n**\n** <ul>\n**   <li> It is created using a call to sqlite3changegroup_new().\n**\n**   <li> Zero or more changesets (or patchsets) are added to the object\n**        by calling sqlite3changegroup_add().\n**\n**   <li> The result of combining all input changesets together is obtained \n**        by the application via a call to sqlite3changegroup_output().\n**\n**   <li> The object is deleted using a call to sqlite3changegroup_delete().\n** </ul>\n**\n** Any number of calls to add() and output() may be made between the calls to\n** new() and delete(), and in any order.\n**\n** As well as the regular sqlite3changegroup_add() and \n** sqlite3changegroup_output() functions, also available are the streaming\n** versions sqlite3changegroup_add_strm() and sqlite3changegroup_output_strm().\n*/\nSQLITE_API int sqlite3changegroup_new(sqlite3_changegroup **pp);\n\n/*\n** CAPI3REF: Add A Changeset To A Changegroup\n** METHOD: sqlite3_changegroup\n**\n** Add all changes within the changeset (or patchset) in buffer pData (size\n** nData bytes) to the changegroup. \n**\n** If the buffer contains a patchset, then all prior calls to this function\n** on the same changegroup object must also have specified patchsets. Or, if\n** the buffer contains a changeset, so must have the earlier calls to this\n** function. Otherwise, SQLITE_ERROR is returned and no changes are added\n** to the changegroup.\n**\n** Rows within the changeset and changegroup are identified by the values in\n** their PRIMARY KEY columns. A change in the changeset is considered to\n** apply to the same row as a change already present in the changegroup if\n** the two rows have the same primary key.\n**\n** Changes to rows that do not already appear in the changegroup are\n** simply copied into it. Or, if both the new changeset and the changegroup\n** contain changes that apply to a single row, the final contents of the\n** changegroup depends on the type of each change, as follows:\n**\n** <table border=1 style=\"margin-left:8ex;margin-right:8ex\">\n**   <tr><th style=\"white-space:pre\">Existing Change  </th>\n**       <th style=\"white-space:pre\">New Change       </th>\n**       <th>Output Change\n**   <tr><td>INSERT <td>INSERT <td>\n**       The new change is ignored. This case does not occur if the new\n**       changeset was recorded immediately after the changesets already\n**       added to the changegroup.\n**   <tr><td>INSERT <td>UPDATE <td>\n**       The INSERT change remains in the changegroup. The values in the \n**       INSERT change are modified as if the row was inserted by the\n**       existing change and then updated according to the new change.\n**   <tr><td>INSERT <td>DELETE <td>\n**       The existing INSERT is removed from the changegroup. The DELETE is\n**       not added.\n**   <tr><td>UPDATE <td>INSERT <td>\n**       The new change is ignored. This case does not occur if the new\n**       changeset was recorded immediately after the changesets already\n**       added to the changegroup.\n**   <tr><td>UPDATE <td>UPDATE <td>\n**       The existing UPDATE remains within the changegroup. It is amended \n**       so that the accompanying values are as if the row was updated once \n**       by the existing change and then again by the new change.\n**   <tr><td>UPDATE <td>DELETE <td>\n**       The existing UPDATE is replaced by the new DELETE within the\n**       changegroup.\n**   <tr><td>DELETE <td>INSERT <td>\n**       If one or more of the column values in the row inserted by the\n**       new change differ from those in the row deleted by the existing \n**       change, the existing DELETE is replaced by an UPDATE within the\n**       changegroup. Otherwise, if the inserted row is exactly the same \n**       as the deleted row, the existing DELETE is simply discarded.\n**   <tr><td>DELETE <td>UPDATE <td>\n**       The new change is ignored. This case does not occur if the new\n**       changeset was recorded immediately after the changesets already\n**       added to the changegroup.\n**   <tr><td>DELETE <td>DELETE <td>\n**       The new change is ignored. This case does not occur if the new\n**       changeset was recorded immediately after the changesets already\n**       added to the changegroup.\n** </table>\n**\n** If the new changeset contains changes to a table that is already present\n** in the changegroup, then the number of columns and the position of the\n** primary key columns for the table must be consistent. If this is not the\n** case, this function fails with SQLITE_SCHEMA. If the input changeset\n** appears to be corrupt and the corruption is detected, SQLITE_CORRUPT is\n** returned. Or, if an out-of-memory condition occurs during processing, this\n** function returns SQLITE_NOMEM. In all cases, if an error occurs the\n** final contents of the changegroup is undefined.\n**\n** If no error occurs, SQLITE_OK is returned.\n*/\nSQLITE_API int sqlite3changegroup_add(sqlite3_changegroup*, int nData, void *pData);\n\n/*\n** CAPI3REF: Obtain A Composite Changeset From A Changegroup\n** METHOD: sqlite3_changegroup\n**\n** Obtain a buffer containing a changeset (or patchset) representing the\n** current contents of the changegroup. If the inputs to the changegroup\n** were themselves changesets, the output is a changeset. Or, if the\n** inputs were patchsets, the output is also a patchset.\n**\n** As with the output of the sqlite3session_changeset() and\n** sqlite3session_patchset() functions, all changes related to a single\n** table are grouped together in the output of this function. Tables appear\n** in the same order as for the very first changeset added to the changegroup.\n** If the second or subsequent changesets added to the changegroup contain\n** changes for tables that do not appear in the first changeset, they are\n** appended onto the end of the output changeset, again in the order in\n** which they are first encountered.\n**\n** If an error occurs, an SQLite error code is returned and the output\n** variables (*pnData) and (*ppData) are set to 0. Otherwise, SQLITE_OK\n** is returned and the output variables are set to the size of and a \n** pointer to the output buffer, respectively. In this case it is the\n** responsibility of the caller to eventually free the buffer using a\n** call to sqlite3_free().\n*/\nSQLITE_API int sqlite3changegroup_output(\n  sqlite3_changegroup*,\n  int *pnData,                    /* OUT: Size of output buffer in bytes */\n  void **ppData                   /* OUT: Pointer to output buffer */\n);\n\n/*\n** CAPI3REF: Delete A Changegroup Object\n** DESTRUCTOR: sqlite3_changegroup\n*/\nSQLITE_API void sqlite3changegroup_delete(sqlite3_changegroup*);\n\n/*\n** CAPI3REF: Apply A Changeset To A Database\n**\n** Apply a changeset or patchset to a database. These functions attempt to\n** update the \"main\" database attached to handle db with the changes found in\n** the changeset passed via the second and third arguments. \n**\n** The fourth argument (xFilter) passed to these functions is the \"filter\n** callback\". If it is not NULL, then for each table affected by at least one\n** change in the changeset, the filter callback is invoked with\n** the table name as the second argument, and a copy of the context pointer\n** passed as the sixth argument as the first. If the \"filter callback\"\n** returns zero, then no attempt is made to apply any changes to the table.\n** Otherwise, if the return value is non-zero or the xFilter argument to\n** is NULL, all changes related to the table are attempted.\n**\n** For each table that is not excluded by the filter callback, this function \n** tests that the target database contains a compatible table. A table is \n** considered compatible if all of the following are true:\n**\n** <ul>\n**   <li> The table has the same name as the name recorded in the \n**        changeset, and\n**   <li> The table has at least as many columns as recorded in the \n**        changeset, and\n**   <li> The table has primary key columns in the same position as \n**        recorded in the changeset.\n** </ul>\n**\n** If there is no compatible table, it is not an error, but none of the\n** changes associated with the table are applied. A warning message is issued\n** via the sqlite3_log() mechanism with the error code SQLITE_SCHEMA. At most\n** one such warning is issued for each table in the changeset.\n**\n** For each change for which there is a compatible table, an attempt is made \n** to modify the table contents according to the UPDATE, INSERT or DELETE \n** change. If a change cannot be applied cleanly, the conflict handler \n** function passed as the fifth argument to sqlite3changeset_apply() may be \n** invoked. A description of exactly when the conflict handler is invoked for \n** each type of change is below.\n**\n** Unlike the xFilter argument, xConflict may not be passed NULL. The results\n** of passing anything other than a valid function pointer as the xConflict\n** argument are undefined.\n**\n** Each time the conflict handler function is invoked, it must return one\n** of [SQLITE_CHANGESET_OMIT], [SQLITE_CHANGESET_ABORT] or \n** [SQLITE_CHANGESET_REPLACE]. SQLITE_CHANGESET_REPLACE may only be returned\n** if the second argument passed to the conflict handler is either\n** SQLITE_CHANGESET_DATA or SQLITE_CHANGESET_CONFLICT. If the conflict-handler\n** returns an illegal value, any changes already made are rolled back and\n** the call to sqlite3changeset_apply() returns SQLITE_MISUSE. Different \n** actions are taken by sqlite3changeset_apply() depending on the value\n** returned by each invocation of the conflict-handler function. Refer to\n** the documentation for the three \n** [SQLITE_CHANGESET_OMIT|available return values] for details.\n**\n** <dl>\n** <dt>DELETE Changes<dd>\n**   For each DELETE change, the function checks if the target database \n**   contains a row with the same primary key value (or values) as the \n**   original row values stored in the changeset. If it does, and the values \n**   stored in all non-primary key columns also match the values stored in \n**   the changeset the row is deleted from the target database.\n**\n**   If a row with matching primary key values is found, but one or more of\n**   the non-primary key fields contains a value different from the original\n**   row value stored in the changeset, the conflict-handler function is\n**   invoked with [SQLITE_CHANGESET_DATA] as the second argument. If the\n**   database table has more columns than are recorded in the changeset,\n**   only the values of those non-primary key fields are compared against\n**   the current database contents - any trailing database table columns\n**   are ignored.\n**\n**   If no row with matching primary key values is found in the database,\n**   the conflict-handler function is invoked with [SQLITE_CHANGESET_NOTFOUND]\n**   passed as the second argument.\n**\n**   If the DELETE operation is attempted, but SQLite returns SQLITE_CONSTRAINT\n**   (which can only happen if a foreign key constraint is violated), the\n**   conflict-handler function is invoked with [SQLITE_CHANGESET_CONSTRAINT]\n**   passed as the second argument. This includes the case where the DELETE\n**   operation is attempted because an earlier call to the conflict handler\n**   function returned [SQLITE_CHANGESET_REPLACE].\n**\n** <dt>INSERT Changes<dd>\n**   For each INSERT change, an attempt is made to insert the new row into\n**   the database. If the changeset row contains fewer fields than the\n**   database table, the trailing fields are populated with their default\n**   values.\n**\n**   If the attempt to insert the row fails because the database already \n**   contains a row with the same primary key values, the conflict handler\n**   function is invoked with the second argument set to \n**   [SQLITE_CHANGESET_CONFLICT].\n**\n**   If the attempt to insert the row fails because of some other constraint\n**   violation (e.g. NOT NULL or UNIQUE), the conflict handler function is \n**   invoked with the second argument set to [SQLITE_CHANGESET_CONSTRAINT].\n**   This includes the case where the INSERT operation is re-attempted because \n**   an earlier call to the conflict handler function returned \n**   [SQLITE_CHANGESET_REPLACE].\n**\n** <dt>UPDATE Changes<dd>\n**   For each UPDATE change, the function checks if the target database \n**   contains a row with the same primary key value (or values) as the \n**   original row values stored in the changeset. If it does, and the values \n**   stored in all modified non-primary key columns also match the values\n**   stored in the changeset the row is updated within the target database.\n**\n**   If a row with matching primary key values is found, but one or more of\n**   the modified non-primary key fields contains a value different from an\n**   original row value stored in the changeset, the conflict-handler function\n**   is invoked with [SQLITE_CHANGESET_DATA] as the second argument. Since\n**   UPDATE changes only contain values for non-primary key fields that are\n**   to be modified, only those fields need to match the original values to\n**   avoid the SQLITE_CHANGESET_DATA conflict-handler callback.\n**\n**   If no row with matching primary key values is found in the database,\n**   the conflict-handler function is invoked with [SQLITE_CHANGESET_NOTFOUND]\n**   passed as the second argument.\n**\n**   If the UPDATE operation is attempted, but SQLite returns \n**   SQLITE_CONSTRAINT, the conflict-handler function is invoked with \n**   [SQLITE_CHANGESET_CONSTRAINT] passed as the second argument.\n**   This includes the case where the UPDATE operation is attempted after \n**   an earlier call to the conflict handler function returned\n**   [SQLITE_CHANGESET_REPLACE].  \n** </dl>\n**\n** It is safe to execute SQL statements, including those that write to the\n** table that the callback related to, from within the xConflict callback.\n** This can be used to further customize the applications conflict\n** resolution strategy.\n**\n** All changes made by these functions are enclosed in a savepoint transaction.\n** If any other error (aside from a constraint failure when attempting to\n** write to the target database) occurs, then the savepoint transaction is\n** rolled back, restoring the target database to its original state, and an \n** SQLite error code returned.\n**\n** If the output parameters (ppRebase) and (pnRebase) are non-NULL and\n** the input is a changeset (not a patchset), then sqlite3changeset_apply_v2()\n** may set (*ppRebase) to point to a \"rebase\" that may be used with the \n** sqlite3_rebaser APIs buffer before returning. In this case (*pnRebase)\n** is set to the size of the buffer in bytes. It is the responsibility of the\n** caller to eventually free any such buffer using sqlite3_free(). The buffer\n** is only allocated and populated if one or more conflicts were encountered\n** while applying the patchset. See comments surrounding the sqlite3_rebaser\n** APIs for further details.\n**\n** The behavior of sqlite3changeset_apply_v2() and its streaming equivalent\n** may be modified by passing a combination of\n** [SQLITE_CHANGESETAPPLY_NOSAVEPOINT | supported flags] as the 9th parameter.\n**\n** Note that the sqlite3changeset_apply_v2() API is still <b>experimental</b>\n** and therefore subject to change.\n*/\nSQLITE_API int sqlite3changeset_apply(\n  sqlite3 *db,                    /* Apply change to \"main\" db of this handle */\n  int nChangeset,                 /* Size of changeset in bytes */\n  void *pChangeset,               /* Changeset blob */\n  int(*xFilter)(\n    void *pCtx,                   /* Copy of sixth arg to _apply() */\n    const char *zTab              /* Table name */\n  ),\n  int(*xConflict)(\n    void *pCtx,                   /* Copy of sixth arg to _apply() */\n    int eConflict,                /* DATA, MISSING, CONFLICT, CONSTRAINT */\n    sqlite3_changeset_iter *p     /* Handle describing change and conflict */\n  ),\n  void *pCtx                      /* First argument passed to xConflict */\n);\nSQLITE_API int sqlite3changeset_apply_v2(\n  sqlite3 *db,                    /* Apply change to \"main\" db of this handle */\n  int nChangeset,                 /* Size of changeset in bytes */\n  void *pChangeset,               /* Changeset blob */\n  int(*xFilter)(\n    void *pCtx,                   /* Copy of sixth arg to _apply() */\n    const char *zTab              /* Table name */\n  ),\n  int(*xConflict)(\n    void *pCtx,                   /* Copy of sixth arg to _apply() */\n    int eConflict,                /* DATA, MISSING, CONFLICT, CONSTRAINT */\n    sqlite3_changeset_iter *p     /* Handle describing change and conflict */\n  ),\n  void *pCtx,                     /* First argument passed to xConflict */\n  void **ppRebase, int *pnRebase, /* OUT: Rebase data */\n  int flags                       /* SESSION_CHANGESETAPPLY_* flags */\n);\n\n/*\n** CAPI3REF: Flags for sqlite3changeset_apply_v2\n**\n** The following flags may passed via the 9th parameter to\n** [sqlite3changeset_apply_v2] and [sqlite3changeset_apply_v2_strm]:\n**\n** <dl>\n** <dt>SQLITE_CHANGESETAPPLY_NOSAVEPOINT <dd>\n**   Usually, the sessions module encloses all operations performed by\n**   a single call to apply_v2() or apply_v2_strm() in a [SAVEPOINT]. The\n**   SAVEPOINT is committed if the changeset or patchset is successfully\n**   applied, or rolled back if an error occurs. Specifying this flag\n**   causes the sessions module to omit this savepoint. In this case, if the\n**   caller has an open transaction or savepoint when apply_v2() is called, \n**   it may revert the partially applied changeset by rolling it back.\n**\n** <dt>SQLITE_CHANGESETAPPLY_INVERT <dd>\n**   Invert the changeset before applying it. This is equivalent to inverting\n**   a changeset using sqlite3changeset_invert() before applying it. It is\n**   an error to specify this flag with a patchset.\n*/\n#define SQLITE_CHANGESETAPPLY_NOSAVEPOINT   0x0001\n#define SQLITE_CHANGESETAPPLY_INVERT        0x0002\n\n/* \n** CAPI3REF: Constants Passed To The Conflict Handler\n**\n** Values that may be passed as the second argument to a conflict-handler.\n**\n** <dl>\n** <dt>SQLITE_CHANGESET_DATA<dd>\n**   The conflict handler is invoked with CHANGESET_DATA as the second argument\n**   when processing a DELETE or UPDATE change if a row with the required\n**   PRIMARY KEY fields is present in the database, but one or more other \n**   (non primary-key) fields modified by the update do not contain the \n**   expected \"before\" values.\n** \n**   The conflicting row, in this case, is the database row with the matching\n**   primary key.\n** \n** <dt>SQLITE_CHANGESET_NOTFOUND<dd>\n**   The conflict handler is invoked with CHANGESET_NOTFOUND as the second\n**   argument when processing a DELETE or UPDATE change if a row with the\n**   required PRIMARY KEY fields is not present in the database.\n** \n**   There is no conflicting row in this case. The results of invoking the\n**   sqlite3changeset_conflict() API are undefined.\n** \n** <dt>SQLITE_CHANGESET_CONFLICT<dd>\n**   CHANGESET_CONFLICT is passed as the second argument to the conflict\n**   handler while processing an INSERT change if the operation would result \n**   in duplicate primary key values.\n** \n**   The conflicting row in this case is the database row with the matching\n**   primary key.\n**\n** <dt>SQLITE_CHANGESET_FOREIGN_KEY<dd>\n**   If foreign key handling is enabled, and applying a changeset leaves the\n**   database in a state containing foreign key violations, the conflict \n**   handler is invoked with CHANGESET_FOREIGN_KEY as the second argument\n**   exactly once before the changeset is committed. If the conflict handler\n**   returns CHANGESET_OMIT, the changes, including those that caused the\n**   foreign key constraint violation, are committed. Or, if it returns\n**   CHANGESET_ABORT, the changeset is rolled back.\n**\n**   No current or conflicting row information is provided. The only function\n**   it is possible to call on the supplied sqlite3_changeset_iter handle\n**   is sqlite3changeset_fk_conflicts().\n** \n** <dt>SQLITE_CHANGESET_CONSTRAINT<dd>\n**   If any other constraint violation occurs while applying a change (i.e. \n**   a UNIQUE, CHECK or NOT NULL constraint), the conflict handler is \n**   invoked with CHANGESET_CONSTRAINT as the second argument.\n** \n**   There is no conflicting row in this case. The results of invoking the\n**   sqlite3changeset_conflict() API are undefined.\n**\n** </dl>\n*/\n#define SQLITE_CHANGESET_DATA        1\n#define SQLITE_CHANGESET_NOTFOUND    2\n#define SQLITE_CHANGESET_CONFLICT    3\n#define SQLITE_CHANGESET_CONSTRAINT  4\n#define SQLITE_CHANGESET_FOREIGN_KEY 5\n\n/* \n** CAPI3REF: Constants Returned By The Conflict Handler\n**\n** A conflict handler callback must return one of the following three values.\n**\n** <dl>\n** <dt>SQLITE_CHANGESET_OMIT<dd>\n**   If a conflict handler returns this value no special action is taken. The\n**   change that caused the conflict is not applied. The session module \n**   continues to the next change in the changeset.\n**\n** <dt>SQLITE_CHANGESET_REPLACE<dd>\n**   This value may only be returned if the second argument to the conflict\n**   handler was SQLITE_CHANGESET_DATA or SQLITE_CHANGESET_CONFLICT. If this\n**   is not the case, any changes applied so far are rolled back and the \n**   call to sqlite3changeset_apply() returns SQLITE_MISUSE.\n**\n**   If CHANGESET_REPLACE is returned by an SQLITE_CHANGESET_DATA conflict\n**   handler, then the conflicting row is either updated or deleted, depending\n**   on the type of change.\n**\n**   If CHANGESET_REPLACE is returned by an SQLITE_CHANGESET_CONFLICT conflict\n**   handler, then the conflicting row is removed from the database and a\n**   second attempt to apply the change is made. If this second attempt fails,\n**   the original row is restored to the database before continuing.\n**\n** <dt>SQLITE_CHANGESET_ABORT<dd>\n**   If this value is returned, any changes applied so far are rolled back \n**   and the call to sqlite3changeset_apply() returns SQLITE_ABORT.\n** </dl>\n*/\n#define SQLITE_CHANGESET_OMIT       0\n#define SQLITE_CHANGESET_REPLACE    1\n#define SQLITE_CHANGESET_ABORT      2\n\n/* \n** CAPI3REF: Rebasing changesets\n** EXPERIMENTAL\n**\n** Suppose there is a site hosting a database in state S0. And that\n** modifications are made that move that database to state S1 and a\n** changeset recorded (the \"local\" changeset). Then, a changeset based\n** on S0 is received from another site (the \"remote\" changeset) and \n** applied to the database. The database is then in state \n** (S1+\"remote\"), where the exact state depends on any conflict\n** resolution decisions (OMIT or REPLACE) made while applying \"remote\".\n** Rebasing a changeset is to update it to take those conflict \n** resolution decisions into account, so that the same conflicts\n** do not have to be resolved elsewhere in the network. \n**\n** For example, if both the local and remote changesets contain an\n** INSERT of the same key on \"CREATE TABLE t1(a PRIMARY KEY, b)\":\n**\n**   local:  INSERT INTO t1 VALUES(1, 'v1');\n**   remote: INSERT INTO t1 VALUES(1, 'v2');\n**\n** and the conflict resolution is REPLACE, then the INSERT change is\n** removed from the local changeset (it was overridden). Or, if the\n** conflict resolution was \"OMIT\", then the local changeset is modified\n** to instead contain:\n**\n**           UPDATE t1 SET b = 'v2' WHERE a=1;\n**\n** Changes within the local changeset are rebased as follows:\n**\n** <dl>\n** <dt>Local INSERT<dd>\n**   This may only conflict with a remote INSERT. If the conflict \n**   resolution was OMIT, then add an UPDATE change to the rebased\n**   changeset. Or, if the conflict resolution was REPLACE, add\n**   nothing to the rebased changeset.\n**\n** <dt>Local DELETE<dd>\n**   This may conflict with a remote UPDATE or DELETE. In both cases the\n**   only possible resolution is OMIT. If the remote operation was a\n**   DELETE, then add no change to the rebased changeset. If the remote\n**   operation was an UPDATE, then the old.* fields of change are updated\n**   to reflect the new.* values in the UPDATE.\n**\n** <dt>Local UPDATE<dd>\n**   This may conflict with a remote UPDATE or DELETE. If it conflicts\n**   with a DELETE, and the conflict resolution was OMIT, then the update\n**   is changed into an INSERT. Any undefined values in the new.* record\n**   from the update change are filled in using the old.* values from\n**   the conflicting DELETE. Or, if the conflict resolution was REPLACE,\n**   the UPDATE change is simply omitted from the rebased changeset.\n**\n**   If conflict is with a remote UPDATE and the resolution is OMIT, then\n**   the old.* values are rebased using the new.* values in the remote\n**   change. Or, if the resolution is REPLACE, then the change is copied\n**   into the rebased changeset with updates to columns also updated by\n**   the conflicting remote UPDATE removed. If this means no columns would \n**   be updated, the change is omitted.\n** </dl>\n**\n** A local change may be rebased against multiple remote changes \n** simultaneously. If a single key is modified by multiple remote \n** changesets, they are combined as follows before the local changeset\n** is rebased:\n**\n** <ul>\n**    <li> If there has been one or more REPLACE resolutions on a\n**         key, it is rebased according to a REPLACE.\n**\n**    <li> If there have been no REPLACE resolutions on a key, then\n**         the local changeset is rebased according to the most recent\n**         of the OMIT resolutions.\n** </ul>\n**\n** Note that conflict resolutions from multiple remote changesets are \n** combined on a per-field basis, not per-row. This means that in the \n** case of multiple remote UPDATE operations, some fields of a single \n** local change may be rebased for REPLACE while others are rebased for \n** OMIT.\n**\n** In order to rebase a local changeset, the remote changeset must first\n** be applied to the local database using sqlite3changeset_apply_v2() and\n** the buffer of rebase information captured. Then:\n**\n** <ol>\n**   <li> An sqlite3_rebaser object is created by calling \n**        sqlite3rebaser_create().\n**   <li> The new object is configured with the rebase buffer obtained from\n**        sqlite3changeset_apply_v2() by calling sqlite3rebaser_configure().\n**        If the local changeset is to be rebased against multiple remote\n**        changesets, then sqlite3rebaser_configure() should be called\n**        multiple times, in the same order that the multiple\n**        sqlite3changeset_apply_v2() calls were made.\n**   <li> Each local changeset is rebased by calling sqlite3rebaser_rebase().\n**   <li> The sqlite3_rebaser object is deleted by calling\n**        sqlite3rebaser_delete().\n** </ol>\n*/\ntypedef struct sqlite3_rebaser sqlite3_rebaser;\n\n/*\n** CAPI3REF: Create a changeset rebaser object.\n** EXPERIMENTAL\n**\n** Allocate a new changeset rebaser object. If successful, set (*ppNew) to\n** point to the new object and return SQLITE_OK. Otherwise, if an error\n** occurs, return an SQLite error code (e.g. SQLITE_NOMEM) and set (*ppNew) \n** to NULL. \n*/\nSQLITE_API int sqlite3rebaser_create(sqlite3_rebaser **ppNew);\n\n/*\n** CAPI3REF: Configure a changeset rebaser object.\n** EXPERIMENTAL\n**\n** Configure the changeset rebaser object to rebase changesets according\n** to the conflict resolutions described by buffer pRebase (size nRebase\n** bytes), which must have been obtained from a previous call to\n** sqlite3changeset_apply_v2().\n*/\nSQLITE_API int sqlite3rebaser_configure(\n  sqlite3_rebaser*, \n  int nRebase, const void *pRebase\n); \n\n/*\n** CAPI3REF: Rebase a changeset\n** EXPERIMENTAL\n**\n** Argument pIn must point to a buffer containing a changeset nIn bytes\n** in size. This function allocates and populates a buffer with a copy\n** of the changeset rebased rebased according to the configuration of the\n** rebaser object passed as the first argument. If successful, (*ppOut)\n** is set to point to the new buffer containing the rebased changset and \n** (*pnOut) to its size in bytes and SQLITE_OK returned. It is the\n** responsibility of the caller to eventually free the new buffer using\n** sqlite3_free(). Otherwise, if an error occurs, (*ppOut) and (*pnOut)\n** are set to zero and an SQLite error code returned.\n*/\nSQLITE_API int sqlite3rebaser_rebase(\n  sqlite3_rebaser*,\n  int nIn, const void *pIn, \n  int *pnOut, void **ppOut \n);\n\n/*\n** CAPI3REF: Delete a changeset rebaser object.\n** EXPERIMENTAL\n**\n** Delete the changeset rebaser object and all associated resources. There\n** should be one call to this function for each successful invocation\n** of sqlite3rebaser_create().\n*/\nSQLITE_API void sqlite3rebaser_delete(sqlite3_rebaser *p); \n\n/*\n** CAPI3REF: Streaming Versions of API functions.\n**\n** The six streaming API xxx_strm() functions serve similar purposes to the \n** corresponding non-streaming API functions:\n**\n** <table border=1 style=\"margin-left:8ex;margin-right:8ex\">\n**   <tr><th>Streaming function<th>Non-streaming equivalent</th>\n**   <tr><td>sqlite3changeset_apply_strm<td>[sqlite3changeset_apply] \n**   <tr><td>sqlite3changeset_apply_strm_v2<td>[sqlite3changeset_apply_v2] \n**   <tr><td>sqlite3changeset_concat_strm<td>[sqlite3changeset_concat] \n**   <tr><td>sqlite3changeset_invert_strm<td>[sqlite3changeset_invert] \n**   <tr><td>sqlite3changeset_start_strm<td>[sqlite3changeset_start] \n**   <tr><td>sqlite3session_changeset_strm<td>[sqlite3session_changeset] \n**   <tr><td>sqlite3session_patchset_strm<td>[sqlite3session_patchset] \n** </table>\n**\n** Non-streaming functions that accept changesets (or patchsets) as input\n** require that the entire changeset be stored in a single buffer in memory. \n** Similarly, those that return a changeset or patchset do so by returning \n** a pointer to a single large buffer allocated using sqlite3_malloc(). \n** Normally this is convenient. However, if an application running in a \n** low-memory environment is required to handle very large changesets, the\n** large contiguous memory allocations required can become onerous.\n**\n** In order to avoid this problem, instead of a single large buffer, input\n** is passed to a streaming API functions by way of a callback function that\n** the sessions module invokes to incrementally request input data as it is\n** required. In all cases, a pair of API function parameters such as\n**\n**  <pre>\n**  &nbsp;     int nChangeset,\n**  &nbsp;     void *pChangeset,\n**  </pre>\n**\n** Is replaced by:\n**\n**  <pre>\n**  &nbsp;     int (*xInput)(void *pIn, void *pData, int *pnData),\n**  &nbsp;     void *pIn,\n**  </pre>\n**\n** Each time the xInput callback is invoked by the sessions module, the first\n** argument passed is a copy of the supplied pIn context pointer. The second \n** argument, pData, points to a buffer (*pnData) bytes in size. Assuming no \n** error occurs the xInput method should copy up to (*pnData) bytes of data \n** into the buffer and set (*pnData) to the actual number of bytes copied \n** before returning SQLITE_OK. If the input is completely exhausted, (*pnData) \n** should be set to zero to indicate this. Or, if an error occurs, an SQLite \n** error code should be returned. In all cases, if an xInput callback returns\n** an error, all processing is abandoned and the streaming API function\n** returns a copy of the error code to the caller.\n**\n** In the case of sqlite3changeset_start_strm(), the xInput callback may be\n** invoked by the sessions module at any point during the lifetime of the\n** iterator. If such an xInput callback returns an error, the iterator enters\n** an error state, whereby all subsequent calls to iterator functions \n** immediately fail with the same error code as returned by xInput.\n**\n** Similarly, streaming API functions that return changesets (or patchsets)\n** return them in chunks by way of a callback function instead of via a\n** pointer to a single large buffer. In this case, a pair of parameters such\n** as:\n**\n**  <pre>\n**  &nbsp;     int *pnChangeset,\n**  &nbsp;     void **ppChangeset,\n**  </pre>\n**\n** Is replaced by:\n**\n**  <pre>\n**  &nbsp;     int (*xOutput)(void *pOut, const void *pData, int nData),\n**  &nbsp;     void *pOut\n**  </pre>\n**\n** The xOutput callback is invoked zero or more times to return data to\n** the application. The first parameter passed to each call is a copy of the\n** pOut pointer supplied by the application. The second parameter, pData,\n** points to a buffer nData bytes in size containing the chunk of output\n** data being returned. If the xOutput callback successfully processes the\n** supplied data, it should return SQLITE_OK to indicate success. Otherwise,\n** it should return some other SQLite error code. In this case processing\n** is immediately abandoned and the streaming API function returns a copy\n** of the xOutput error code to the application.\n**\n** The sessions module never invokes an xOutput callback with the third \n** parameter set to a value less than or equal to zero. Other than this,\n** no guarantees are made as to the size of the chunks of data returned.\n*/\nSQLITE_API int sqlite3changeset_apply_strm(\n  sqlite3 *db,                    /* Apply change to \"main\" db of this handle */\n  int (*xInput)(void *pIn, void *pData, int *pnData), /* Input function */\n  void *pIn,                                          /* First arg for xInput */\n  int(*xFilter)(\n    void *pCtx,                   /* Copy of sixth arg to _apply() */\n    const char *zTab              /* Table name */\n  ),\n  int(*xConflict)(\n    void *pCtx,                   /* Copy of sixth arg to _apply() */\n    int eConflict,                /* DATA, MISSING, CONFLICT, CONSTRAINT */\n    sqlite3_changeset_iter *p     /* Handle describing change and conflict */\n  ),\n  void *pCtx                      /* First argument passed to xConflict */\n);\nSQLITE_API int sqlite3changeset_apply_v2_strm(\n  sqlite3 *db,                    /* Apply change to \"main\" db of this handle */\n  int (*xInput)(void *pIn, void *pData, int *pnData), /* Input function */\n  void *pIn,                                          /* First arg for xInput */\n  int(*xFilter)(\n    void *pCtx,                   /* Copy of sixth arg to _apply() */\n    const char *zTab              /* Table name */\n  ),\n  int(*xConflict)(\n    void *pCtx,                   /* Copy of sixth arg to _apply() */\n    int eConflict,                /* DATA, MISSING, CONFLICT, CONSTRAINT */\n    sqlite3_changeset_iter *p     /* Handle describing change and conflict */\n  ),\n  void *pCtx,                     /* First argument passed to xConflict */\n  void **ppRebase, int *pnRebase,\n  int flags\n);\nSQLITE_API int sqlite3changeset_concat_strm(\n  int (*xInputA)(void *pIn, void *pData, int *pnData),\n  void *pInA,\n  int (*xInputB)(void *pIn, void *pData, int *pnData),\n  void *pInB,\n  int (*xOutput)(void *pOut, const void *pData, int nData),\n  void *pOut\n);\nSQLITE_API int sqlite3changeset_invert_strm(\n  int (*xInput)(void *pIn, void *pData, int *pnData),\n  void *pIn,\n  int (*xOutput)(void *pOut, const void *pData, int nData),\n  void *pOut\n);\nSQLITE_API int sqlite3changeset_start_strm(\n  sqlite3_changeset_iter **pp,\n  int (*xInput)(void *pIn, void *pData, int *pnData),\n  void *pIn\n);\nSQLITE_API int sqlite3changeset_start_v2_strm(\n  sqlite3_changeset_iter **pp,\n  int (*xInput)(void *pIn, void *pData, int *pnData),\n  void *pIn,\n  int flags\n);\nSQLITE_API int sqlite3session_changeset_strm(\n  sqlite3_session *pSession,\n  int (*xOutput)(void *pOut, const void *pData, int nData),\n  void *pOut\n);\nSQLITE_API int sqlite3session_patchset_strm(\n  sqlite3_session *pSession,\n  int (*xOutput)(void *pOut, const void *pData, int nData),\n  void *pOut\n);\nSQLITE_API int sqlite3changegroup_add_strm(sqlite3_changegroup*, \n    int (*xInput)(void *pIn, void *pData, int *pnData),\n    void *pIn\n);\nSQLITE_API int sqlite3changegroup_output_strm(sqlite3_changegroup*,\n    int (*xOutput)(void *pOut, const void *pData, int nData), \n    void *pOut\n);\nSQLITE_API int sqlite3rebaser_rebase_strm(\n  sqlite3_rebaser *pRebaser,\n  int (*xInput)(void *pIn, void *pData, int *pnData),\n  void *pIn,\n  int (*xOutput)(void *pOut, const void *pData, int nData),\n  void *pOut\n);\n\n/*\n** CAPI3REF: Configure global parameters\n**\n** The sqlite3session_config() interface is used to make global configuration\n** changes to the sessions module in order to tune it to the specific needs \n** of the application.\n**\n** The sqlite3session_config() interface is not threadsafe. If it is invoked\n** while any other thread is inside any other sessions method then the\n** results are undefined. Furthermore, if it is invoked after any sessions\n** related objects have been created, the results are also undefined. \n**\n** The first argument to the sqlite3session_config() function must be one\n** of the SQLITE_SESSION_CONFIG_XXX constants defined below. The \n** interpretation of the (void*) value passed as the second parameter and\n** the effect of calling this function depends on the value of the first\n** parameter.\n**\n** <dl>\n** <dt>SQLITE_SESSION_CONFIG_STRMSIZE<dd>\n**    By default, the sessions module streaming interfaces attempt to input\n**    and output data in approximately 1 KiB chunks. This operand may be used\n**    to set and query the value of this configuration setting. The pointer\n**    passed as the second argument must point to a value of type (int).\n**    If this value is greater than 0, it is used as the new streaming data\n**    chunk size for both input and output. Before returning, the (int) value\n**    pointed to by pArg is set to the final value of the streaming interface\n**    chunk size.\n** </dl>\n**\n** This function returns SQLITE_OK if successful, or an SQLite error code\n** otherwise.\n*/\nSQLITE_API int sqlite3session_config(int op, void *pArg);\n\n/*\n** CAPI3REF: Values for sqlite3session_config().\n*/\n#define SQLITE_SESSION_CONFIG_STRMSIZE 1\n\n/*\n** Make sure we can call this stuff from C++.\n*/\n#if 0\n}\n#endif\n\n#endif  /* !defined(__SQLITESESSION_H_) && defined(SQLITE_ENABLE_SESSION) */\n\n/******** End of sqlite3session.h *********/\n/******** Begin file fts5.h *********/\n/*\n** 2014 May 31\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n******************************************************************************\n**\n** Interfaces to extend FTS5. Using the interfaces defined in this file, \n** FTS5 may be extended with:\n**\n**     * custom tokenizers, and\n**     * custom auxiliary functions.\n*/\n\n\n#ifndef _FTS5_H\n#define _FTS5_H\n\n\n#if 0\nextern \"C\" {\n#endif\n\n/*************************************************************************\n** CUSTOM AUXILIARY FUNCTIONS\n**\n** Virtual table implementations may overload SQL functions by implementing\n** the sqlite3_module.xFindFunction() method.\n*/\n\ntypedef struct Fts5ExtensionApi Fts5ExtensionApi;\ntypedef struct Fts5Context Fts5Context;\ntypedef struct Fts5PhraseIter Fts5PhraseIter;\n\ntypedef void (*fts5_extension_function)(\n  const Fts5ExtensionApi *pApi,   /* API offered by current FTS version */\n  Fts5Context *pFts,              /* First arg to pass to pApi functions */\n  sqlite3_context *pCtx,          /* Context for returning result/error */\n  int nVal,                       /* Number of values in apVal[] array */\n  sqlite3_value **apVal           /* Array of trailing arguments */\n);\n\nstruct Fts5PhraseIter {\n  const unsigned char *a;\n  const unsigned char *b;\n};\n\n/*\n** EXTENSION API FUNCTIONS\n**\n** xUserData(pFts):\n**   Return a copy of the context pointer the extension function was \n**   registered with.\n**\n** xColumnTotalSize(pFts, iCol, pnToken):\n**   If parameter iCol is less than zero, set output variable *pnToken\n**   to the total number of tokens in the FTS5 table. Or, if iCol is\n**   non-negative but less than the number of columns in the table, return\n**   the total number of tokens in column iCol, considering all rows in \n**   the FTS5 table.\n**\n**   If parameter iCol is greater than or equal to the number of columns\n**   in the table, SQLITE_RANGE is returned. Or, if an error occurs (e.g.\n**   an OOM condition or IO error), an appropriate SQLite error code is \n**   returned.\n**\n** xColumnCount(pFts):\n**   Return the number of columns in the table.\n**\n** xColumnSize(pFts, iCol, pnToken):\n**   If parameter iCol is less than zero, set output variable *pnToken\n**   to the total number of tokens in the current row. Or, if iCol is\n**   non-negative but less than the number of columns in the table, set\n**   *pnToken to the number of tokens in column iCol of the current row.\n**\n**   If parameter iCol is greater than or equal to the number of columns\n**   in the table, SQLITE_RANGE is returned. Or, if an error occurs (e.g.\n**   an OOM condition or IO error), an appropriate SQLite error code is \n**   returned.\n**\n**   This function may be quite inefficient if used with an FTS5 table\n**   created with the \"columnsize=0\" option.\n**\n** xColumnText:\n**   This function attempts to retrieve the text of column iCol of the\n**   current document. If successful, (*pz) is set to point to a buffer\n**   containing the text in utf-8 encoding, (*pn) is set to the size in bytes\n**   (not characters) of the buffer and SQLITE_OK is returned. Otherwise,\n**   if an error occurs, an SQLite error code is returned and the final values\n**   of (*pz) and (*pn) are undefined.\n**\n** xPhraseCount:\n**   Returns the number of phrases in the current query expression.\n**\n** xPhraseSize:\n**   Returns the number of tokens in phrase iPhrase of the query. Phrases\n**   are numbered starting from zero.\n**\n** xInstCount:\n**   Set *pnInst to the total number of occurrences of all phrases within\n**   the query within the current row. Return SQLITE_OK if successful, or\n**   an error code (i.e. SQLITE_NOMEM) if an error occurs.\n**\n**   This API can be quite slow if used with an FTS5 table created with the\n**   \"detail=none\" or \"detail=column\" option. If the FTS5 table is created \n**   with either \"detail=none\" or \"detail=column\" and \"content=\" option \n**   (i.e. if it is a contentless table), then this API always returns 0.\n**\n** xInst:\n**   Query for the details of phrase match iIdx within the current row.\n**   Phrase matches are numbered starting from zero, so the iIdx argument\n**   should be greater than or equal to zero and smaller than the value\n**   output by xInstCount().\n**\n**   Usually, output parameter *piPhrase is set to the phrase number, *piCol\n**   to the column in which it occurs and *piOff the token offset of the\n**   first token of the phrase. Returns SQLITE_OK if successful, or an error\n**   code (i.e. SQLITE_NOMEM) if an error occurs.\n**\n**   This API can be quite slow if used with an FTS5 table created with the\n**   \"detail=none\" or \"detail=column\" option. \n**\n** xRowid:\n**   Returns the rowid of the current row.\n**\n** xTokenize:\n**   Tokenize text using the tokenizer belonging to the FTS5 table.\n**\n** xQueryPhrase(pFts5, iPhrase, pUserData, xCallback):\n**   This API function is used to query the FTS table for phrase iPhrase\n**   of the current query. Specifically, a query equivalent to:\n**\n**       ... FROM ftstable WHERE ftstable MATCH $p ORDER BY rowid\n**\n**   with $p set to a phrase equivalent to the phrase iPhrase of the\n**   current query is executed. Any column filter that applies to\n**   phrase iPhrase of the current query is included in $p. For each \n**   row visited, the callback function passed as the fourth argument \n**   is invoked. The context and API objects passed to the callback \n**   function may be used to access the properties of each matched row.\n**   Invoking Api.xUserData() returns a copy of the pointer passed as \n**   the third argument to pUserData.\n**\n**   If the callback function returns any value other than SQLITE_OK, the\n**   query is abandoned and the xQueryPhrase function returns immediately.\n**   If the returned value is SQLITE_DONE, xQueryPhrase returns SQLITE_OK.\n**   Otherwise, the error code is propagated upwards.\n**\n**   If the query runs to completion without incident, SQLITE_OK is returned.\n**   Or, if some error occurs before the query completes or is aborted by\n**   the callback, an SQLite error code is returned.\n**\n**\n** xSetAuxdata(pFts5, pAux, xDelete)\n**\n**   Save the pointer passed as the second argument as the extension functions \n**   \"auxiliary data\". The pointer may then be retrieved by the current or any\n**   future invocation of the same fts5 extension function made as part of\n**   of the same MATCH query using the xGetAuxdata() API.\n**\n**   Each extension function is allocated a single auxiliary data slot for\n**   each FTS query (MATCH expression). If the extension function is invoked \n**   more than once for a single FTS query, then all invocations share a \n**   single auxiliary data context.\n**\n**   If there is already an auxiliary data pointer when this function is\n**   invoked, then it is replaced by the new pointer. If an xDelete callback\n**   was specified along with the original pointer, it is invoked at this\n**   point.\n**\n**   The xDelete callback, if one is specified, is also invoked on the\n**   auxiliary data pointer after the FTS5 query has finished.\n**\n**   If an error (e.g. an OOM condition) occurs within this function, an\n**   the auxiliary data is set to NULL and an error code returned. If the\n**   xDelete parameter was not NULL, it is invoked on the auxiliary data\n**   pointer before returning.\n**\n**\n** xGetAuxdata(pFts5, bClear)\n**\n**   Returns the current auxiliary data pointer for the fts5 extension \n**   function. See the xSetAuxdata() method for details.\n**\n**   If the bClear argument is non-zero, then the auxiliary data is cleared\n**   (set to NULL) before this function returns. In this case the xDelete,\n**   if any, is not invoked.\n**\n**\n** xRowCount(pFts5, pnRow)\n**\n**   This function is used to retrieve the total number of rows in the table.\n**   In other words, the same value that would be returned by:\n**\n**        SELECT count(*) FROM ftstable;\n**\n** xPhraseFirst()\n**   This function is used, along with type Fts5PhraseIter and the xPhraseNext\n**   method, to iterate through all instances of a single query phrase within\n**   the current row. This is the same information as is accessible via the\n**   xInstCount/xInst APIs. While the xInstCount/xInst APIs are more convenient\n**   to use, this API may be faster under some circumstances. To iterate \n**   through instances of phrase iPhrase, use the following code:\n**\n**       Fts5PhraseIter iter;\n**       int iCol, iOff;\n**       for(pApi->xPhraseFirst(pFts, iPhrase, &iter, &iCol, &iOff);\n**           iCol>=0;\n**           pApi->xPhraseNext(pFts, &iter, &iCol, &iOff)\n**       ){\n**         // An instance of phrase iPhrase at offset iOff of column iCol\n**       }\n**\n**   The Fts5PhraseIter structure is defined above. Applications should not\n**   modify this structure directly - it should only be used as shown above\n**   with the xPhraseFirst() and xPhraseNext() API methods (and by\n**   xPhraseFirstColumn() and xPhraseNextColumn() as illustrated below).\n**\n**   This API can be quite slow if used with an FTS5 table created with the\n**   \"detail=none\" or \"detail=column\" option. If the FTS5 table is created \n**   with either \"detail=none\" or \"detail=column\" and \"content=\" option \n**   (i.e. if it is a contentless table), then this API always iterates\n**   through an empty set (all calls to xPhraseFirst() set iCol to -1).\n**\n** xPhraseNext()\n**   See xPhraseFirst above.\n**\n** xPhraseFirstColumn()\n**   This function and xPhraseNextColumn() are similar to the xPhraseFirst()\n**   and xPhraseNext() APIs described above. The difference is that instead\n**   of iterating through all instances of a phrase in the current row, these\n**   APIs are used to iterate through the set of columns in the current row\n**   that contain one or more instances of a specified phrase. For example:\n**\n**       Fts5PhraseIter iter;\n**       int iCol;\n**       for(pApi->xPhraseFirstColumn(pFts, iPhrase, &iter, &iCol);\n**           iCol>=0;\n**           pApi->xPhraseNextColumn(pFts, &iter, &iCol)\n**       ){\n**         // Column iCol contains at least one instance of phrase iPhrase\n**       }\n**\n**   This API can be quite slow if used with an FTS5 table created with the\n**   \"detail=none\" option. If the FTS5 table is created with either \n**   \"detail=none\" \"content=\" option (i.e. if it is a contentless table), \n**   then this API always iterates through an empty set (all calls to \n**   xPhraseFirstColumn() set iCol to -1).\n**\n**   The information accessed using this API and its companion\n**   xPhraseFirstColumn() may also be obtained using xPhraseFirst/xPhraseNext\n**   (or xInst/xInstCount). The chief advantage of this API is that it is\n**   significantly more efficient than those alternatives when used with\n**   \"detail=column\" tables.  \n**\n** xPhraseNextColumn()\n**   See xPhraseFirstColumn above.\n*/\nstruct Fts5ExtensionApi {\n  int iVersion;                   /* Currently always set to 3 */\n\n  void *(*xUserData)(Fts5Context*);\n\n  int (*xColumnCount)(Fts5Context*);\n  int (*xRowCount)(Fts5Context*, sqlite3_int64 *pnRow);\n  int (*xColumnTotalSize)(Fts5Context*, int iCol, sqlite3_int64 *pnToken);\n\n  int (*xTokenize)(Fts5Context*, \n    const char *pText, int nText, /* Text to tokenize */\n    void *pCtx,                   /* Context passed to xToken() */\n    int (*xToken)(void*, int, const char*, int, int, int)       /* Callback */\n  );\n\n  int (*xPhraseCount)(Fts5Context*);\n  int (*xPhraseSize)(Fts5Context*, int iPhrase);\n\n  int (*xInstCount)(Fts5Context*, int *pnInst);\n  int (*xInst)(Fts5Context*, int iIdx, int *piPhrase, int *piCol, int *piOff);\n\n  sqlite3_int64 (*xRowid)(Fts5Context*);\n  int (*xColumnText)(Fts5Context*, int iCol, const char **pz, int *pn);\n  int (*xColumnSize)(Fts5Context*, int iCol, int *pnToken);\n\n  int (*xQueryPhrase)(Fts5Context*, int iPhrase, void *pUserData,\n    int(*)(const Fts5ExtensionApi*,Fts5Context*,void*)\n  );\n  int (*xSetAuxdata)(Fts5Context*, void *pAux, void(*xDelete)(void*));\n  void *(*xGetAuxdata)(Fts5Context*, int bClear);\n\n  int (*xPhraseFirst)(Fts5Context*, int iPhrase, Fts5PhraseIter*, int*, int*);\n  void (*xPhraseNext)(Fts5Context*, Fts5PhraseIter*, int *piCol, int *piOff);\n\n  int (*xPhraseFirstColumn)(Fts5Context*, int iPhrase, Fts5PhraseIter*, int*);\n  void (*xPhraseNextColumn)(Fts5Context*, Fts5PhraseIter*, int *piCol);\n};\n\n/* \n** CUSTOM AUXILIARY FUNCTIONS\n*************************************************************************/\n\n/*************************************************************************\n** CUSTOM TOKENIZERS\n**\n** Applications may also register custom tokenizer types. A tokenizer \n** is registered by providing fts5 with a populated instance of the \n** following structure. All structure methods must be defined, setting\n** any member of the fts5_tokenizer struct to NULL leads to undefined\n** behaviour. The structure methods are expected to function as follows:\n**\n** xCreate:\n**   This function is used to allocate and initialize a tokenizer instance.\n**   A tokenizer instance is required to actually tokenize text.\n**\n**   The first argument passed to this function is a copy of the (void*)\n**   pointer provided by the application when the fts5_tokenizer object\n**   was registered with FTS5 (the third argument to xCreateTokenizer()). \n**   The second and third arguments are an array of nul-terminated strings\n**   containing the tokenizer arguments, if any, specified following the\n**   tokenizer name as part of the CREATE VIRTUAL TABLE statement used\n**   to create the FTS5 table.\n**\n**   The final argument is an output variable. If successful, (*ppOut) \n**   should be set to point to the new tokenizer handle and SQLITE_OK\n**   returned. If an error occurs, some value other than SQLITE_OK should\n**   be returned. In this case, fts5 assumes that the final value of *ppOut \n**   is undefined.\n**\n** xDelete:\n**   This function is invoked to delete a tokenizer handle previously\n**   allocated using xCreate(). Fts5 guarantees that this function will\n**   be invoked exactly once for each successful call to xCreate().\n**\n** xTokenize:\n**   This function is expected to tokenize the nText byte string indicated \n**   by argument pText. pText may or may not be nul-terminated. The first\n**   argument passed to this function is a pointer to an Fts5Tokenizer object\n**   returned by an earlier call to xCreate().\n**\n**   The second argument indicates the reason that FTS5 is requesting\n**   tokenization of the supplied text. This is always one of the following\n**   four values:\n**\n**   <ul><li> <b>FTS5_TOKENIZE_DOCUMENT</b> - A document is being inserted into\n**            or removed from the FTS table. The tokenizer is being invoked to\n**            determine the set of tokens to add to (or delete from) the\n**            FTS index.\n**\n**       <li> <b>FTS5_TOKENIZE_QUERY</b> - A MATCH query is being executed \n**            against the FTS index. The tokenizer is being called to tokenize \n**            a bareword or quoted string specified as part of the query.\n**\n**       <li> <b>(FTS5_TOKENIZE_QUERY | FTS5_TOKENIZE_PREFIX)</b> - Same as\n**            FTS5_TOKENIZE_QUERY, except that the bareword or quoted string is\n**            followed by a \"*\" character, indicating that the last token\n**            returned by the tokenizer will be treated as a token prefix.\n**\n**       <li> <b>FTS5_TOKENIZE_AUX</b> - The tokenizer is being invoked to \n**            satisfy an fts5_api.xTokenize() request made by an auxiliary\n**            function. Or an fts5_api.xColumnSize() request made by the same\n**            on a columnsize=0 database.  \n**   </ul>\n**\n**   For each token in the input string, the supplied callback xToken() must\n**   be invoked. The first argument to it should be a copy of the pointer\n**   passed as the second argument to xTokenize(). The third and fourth\n**   arguments are a pointer to a buffer containing the token text, and the\n**   size of the token in bytes. The 4th and 5th arguments are the byte offsets\n**   of the first byte of and first byte immediately following the text from\n**   which the token is derived within the input.\n**\n**   The second argument passed to the xToken() callback (\"tflags\") should\n**   normally be set to 0. The exception is if the tokenizer supports \n**   synonyms. In this case see the discussion below for details.\n**\n**   FTS5 assumes the xToken() callback is invoked for each token in the \n**   order that they occur within the input text.\n**\n**   If an xToken() callback returns any value other than SQLITE_OK, then\n**   the tokenization should be abandoned and the xTokenize() method should\n**   immediately return a copy of the xToken() return value. Or, if the\n**   input buffer is exhausted, xTokenize() should return SQLITE_OK. Finally,\n**   if an error occurs with the xTokenize() implementation itself, it\n**   may abandon the tokenization and return any error code other than\n**   SQLITE_OK or SQLITE_DONE.\n**\n** SYNONYM SUPPORT\n**\n**   Custom tokenizers may also support synonyms. Consider a case in which a\n**   user wishes to query for a phrase such as \"first place\". Using the \n**   built-in tokenizers, the FTS5 query 'first + place' will match instances\n**   of \"first place\" within the document set, but not alternative forms\n**   such as \"1st place\". In some applications, it would be better to match\n**   all instances of \"first place\" or \"1st place\" regardless of which form\n**   the user specified in the MATCH query text.\n**\n**   There are several ways to approach this in FTS5:\n**\n**   <ol><li> By mapping all synonyms to a single token. In this case, the \n**            In the above example, this means that the tokenizer returns the\n**            same token for inputs \"first\" and \"1st\". Say that token is in\n**            fact \"first\", so that when the user inserts the document \"I won\n**            1st place\" entries are added to the index for tokens \"i\", \"won\",\n**            \"first\" and \"place\". If the user then queries for '1st + place',\n**            the tokenizer substitutes \"first\" for \"1st\" and the query works\n**            as expected.\n**\n**       <li> By querying the index for all synonyms of each query term\n**            separately. In this case, when tokenizing query text, the\n**            tokenizer may provide multiple synonyms for a single term \n**            within the document. FTS5 then queries the index for each \n**            synonym individually. For example, faced with the query:\n**\n**   <codeblock>\n**     ... MATCH 'first place'</codeblock>\n**\n**            the tokenizer offers both \"1st\" and \"first\" as synonyms for the\n**            first token in the MATCH query and FTS5 effectively runs a query \n**            similar to:\n**\n**   <codeblock>\n**     ... MATCH '(first OR 1st) place'</codeblock>\n**\n**            except that, for the purposes of auxiliary functions, the query\n**            still appears to contain just two phrases - \"(first OR 1st)\" \n**            being treated as a single phrase.\n**\n**       <li> By adding multiple synonyms for a single term to the FTS index.\n**            Using this method, when tokenizing document text, the tokenizer\n**            provides multiple synonyms for each token. So that when a \n**            document such as \"I won first place\" is tokenized, entries are\n**            added to the FTS index for \"i\", \"won\", \"first\", \"1st\" and\n**            \"place\".\n**\n**            This way, even if the tokenizer does not provide synonyms\n**            when tokenizing query text (it should not - to do so would be\n**            inefficient), it doesn't matter if the user queries for \n**            'first + place' or '1st + place', as there are entries in the\n**            FTS index corresponding to both forms of the first token.\n**   </ol>\n**\n**   Whether it is parsing document or query text, any call to xToken that\n**   specifies a <i>tflags</i> argument with the FTS5_TOKEN_COLOCATED bit\n**   is considered to supply a synonym for the previous token. For example,\n**   when parsing the document \"I won first place\", a tokenizer that supports\n**   synonyms would call xToken() 5 times, as follows:\n**\n**   <codeblock>\n**       xToken(pCtx, 0, \"i\",                      1,  0,  1);\n**       xToken(pCtx, 0, \"won\",                    3,  2,  5);\n**       xToken(pCtx, 0, \"first\",                  5,  6, 11);\n**       xToken(pCtx, FTS5_TOKEN_COLOCATED, \"1st\", 3,  6, 11);\n**       xToken(pCtx, 0, \"place\",                  5, 12, 17);\n**</codeblock>\n**\n**   It is an error to specify the FTS5_TOKEN_COLOCATED flag the first time\n**   xToken() is called. Multiple synonyms may be specified for a single token\n**   by making multiple calls to xToken(FTS5_TOKEN_COLOCATED) in sequence. \n**   There is no limit to the number of synonyms that may be provided for a\n**   single token.\n**\n**   In many cases, method (1) above is the best approach. It does not add \n**   extra data to the FTS index or require FTS5 to query for multiple terms,\n**   so it is efficient in terms of disk space and query speed. However, it\n**   does not support prefix queries very well. If, as suggested above, the\n**   token \"first\" is substituted for \"1st\" by the tokenizer, then the query:\n**\n**   <codeblock>\n**     ... MATCH '1s*'</codeblock>\n**\n**   will not match documents that contain the token \"1st\" (as the tokenizer\n**   will probably not map \"1s\" to any prefix of \"first\").\n**\n**   For full prefix support, method (3) may be preferred. In this case, \n**   because the index contains entries for both \"first\" and \"1st\", prefix\n**   queries such as 'fi*' or '1s*' will match correctly. However, because\n**   extra entries are added to the FTS index, this method uses more space\n**   within the database.\n**\n**   Method (2) offers a midpoint between (1) and (3). Using this method,\n**   a query such as '1s*' will match documents that contain the literal \n**   token \"1st\", but not \"first\" (assuming the tokenizer is not able to\n**   provide synonyms for prefixes). However, a non-prefix query like '1st'\n**   will match against \"1st\" and \"first\". This method does not require\n**   extra disk space, as no extra entries are added to the FTS index. \n**   On the other hand, it may require more CPU cycles to run MATCH queries,\n**   as separate queries of the FTS index are required for each synonym.\n**\n**   When using methods (2) or (3), it is important that the tokenizer only\n**   provide synonyms when tokenizing document text (method (2)) or query\n**   text (method (3)), not both. Doing so will not cause any errors, but is\n**   inefficient.\n*/\ntypedef struct Fts5Tokenizer Fts5Tokenizer;\ntypedef struct fts5_tokenizer fts5_tokenizer;\nstruct fts5_tokenizer {\n  int (*xCreate)(void*, const char **azArg, int nArg, Fts5Tokenizer **ppOut);\n  void (*xDelete)(Fts5Tokenizer*);\n  int (*xTokenize)(Fts5Tokenizer*, \n      void *pCtx,\n      int flags,            /* Mask of FTS5_TOKENIZE_* flags */\n      const char *pText, int nText, \n      int (*xToken)(\n        void *pCtx,         /* Copy of 2nd argument to xTokenize() */\n        int tflags,         /* Mask of FTS5_TOKEN_* flags */\n        const char *pToken, /* Pointer to buffer containing token */\n        int nToken,         /* Size of token in bytes */\n        int iStart,         /* Byte offset of token within input text */\n        int iEnd            /* Byte offset of end of token within input text */\n      )\n  );\n};\n\n/* Flags that may be passed as the third argument to xTokenize() */\n#define FTS5_TOKENIZE_QUERY     0x0001\n#define FTS5_TOKENIZE_PREFIX    0x0002\n#define FTS5_TOKENIZE_DOCUMENT  0x0004\n#define FTS5_TOKENIZE_AUX       0x0008\n\n/* Flags that may be passed by the tokenizer implementation back to FTS5\n** as the third argument to the supplied xToken callback. */\n#define FTS5_TOKEN_COLOCATED    0x0001      /* Same position as prev. token */\n\n/*\n** END OF CUSTOM TOKENIZERS\n*************************************************************************/\n\n/*************************************************************************\n** FTS5 EXTENSION REGISTRATION API\n*/\ntypedef struct fts5_api fts5_api;\nstruct fts5_api {\n  int iVersion;                   /* Currently always set to 2 */\n\n  /* Create a new tokenizer */\n  int (*xCreateTokenizer)(\n    fts5_api *pApi,\n    const char *zName,\n    void *pContext,\n    fts5_tokenizer *pTokenizer,\n    void (*xDestroy)(void*)\n  );\n\n  /* Find an existing tokenizer */\n  int (*xFindTokenizer)(\n    fts5_api *pApi,\n    const char *zName,\n    void **ppContext,\n    fts5_tokenizer *pTokenizer\n  );\n\n  /* Create a new auxiliary function */\n  int (*xCreateFunction)(\n    fts5_api *pApi,\n    const char *zName,\n    void *pContext,\n    fts5_extension_function xFunction,\n    void (*xDestroy)(void*)\n  );\n};\n\n/*\n** END OF REGISTRATION API\n*************************************************************************/\n\n#if 0\n}  /* end of the 'extern \"C\"' block */\n#endif\n\n#endif /* _FTS5_H */\n\n/******** End of fts5.h *********/\n\n/************** End of sqlite3.h *********************************************/\n/************** Continuing where we left off in sqliteInt.h ******************/\n\n#if __STDC_VERSION__ >= 201112L\n#include <stdatomic.h>\n#define SQLITE_HAS_STDATOMIC\n#endif\n\n\n/*\n** Include the configuration header output by 'configure' if we're using the\n** autoconf-based build\n*/\n#if defined(_HAVE_SQLITE_CONFIG_H) && !defined(SQLITECONFIG_H)\n/* #include \"config.h\" */\n#define SQLITECONFIG_H 1\n#endif\n\n/************** Include sqliteLimit.h in the middle of sqliteInt.h ***********/\n/************** Begin file sqliteLimit.h *************************************/\n/*\n** 2007 May 7\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** \n** This file defines various limits of what SQLite can process.\n*/\n\n/*\n** The maximum length of a TEXT or BLOB in bytes.   This also\n** limits the size of a row in a table or index.\n**\n** The hard limit is the ability of a 32-bit signed integer\n** to count the size: 2^31-1 or 2147483647.\n*/\n#ifndef SQLITE_MAX_LENGTH\n# define SQLITE_MAX_LENGTH 1000000000\n#endif\n\n/*\n** This is the maximum number of\n**\n**    * Columns in a table\n**    * Columns in an index\n**    * Columns in a view\n**    * Terms in the SET clause of an UPDATE statement\n**    * Terms in the result set of a SELECT statement\n**    * Terms in the GROUP BY or ORDER BY clauses of a SELECT statement.\n**    * Terms in the VALUES clause of an INSERT statement\n**\n** The hard upper limit here is 32676.  Most database people will\n** tell you that in a well-normalized database, you usually should\n** not have more than a dozen or so columns in any table.  And if\n** that is the case, there is no point in having more than a few\n** dozen values in any of the other situations described above.\n*/\n#ifndef SQLITE_MAX_COLUMN\n# define SQLITE_MAX_COLUMN 2000\n#endif\n\n/*\n** The maximum length of a single SQL statement in bytes.\n**\n** It used to be the case that setting this value to zero would\n** turn the limit off.  That is no longer true.  It is not possible\n** to turn this limit off.\n*/\n#ifndef SQLITE_MAX_SQL_LENGTH\n# define SQLITE_MAX_SQL_LENGTH 1000000000\n#endif\n\n/*\n** The maximum depth of an expression tree. This is limited to \n** some extent by SQLITE_MAX_SQL_LENGTH. But sometime you might \n** want to place more severe limits on the complexity of an \n** expression.\n**\n** A value of 0 used to mean that the limit was not enforced.\n** But that is no longer true.  The limit is now strictly enforced\n** at all times.\n*/\n#ifndef SQLITE_MAX_EXPR_DEPTH\n# define SQLITE_MAX_EXPR_DEPTH 1000\n#endif\n\n/*\n** The maximum number of terms in a compound SELECT statement.\n** The code generator for compound SELECT statements does one\n** level of recursion for each term.  A stack overflow can result\n** if the number of terms is too large.  In practice, most SQL\n** never has more than 3 or 4 terms.  Use a value of 0 to disable\n** any limit on the number of terms in a compount SELECT.\n*/\n#ifndef SQLITE_MAX_COMPOUND_SELECT\n# define SQLITE_MAX_COMPOUND_SELECT 500\n#endif\n\n/*\n** The maximum number of opcodes in a VDBE program.\n** Not currently enforced.\n*/\n#ifndef SQLITE_MAX_VDBE_OP\n# define SQLITE_MAX_VDBE_OP 250000000\n#endif\n\n/*\n** The maximum number of arguments to an SQL function.\n*/\n#ifndef SQLITE_MAX_FUNCTION_ARG\n# define SQLITE_MAX_FUNCTION_ARG 127\n#endif\n\n/*\n** The suggested maximum number of in-memory pages to use for\n** the main database table and for temporary tables.\n**\n** IMPLEMENTATION-OF: R-30185-15359 The default suggested cache size is -2000,\n** which means the cache size is limited to 2048000 bytes of memory.\n** IMPLEMENTATION-OF: R-48205-43578 The default suggested cache size can be\n** altered using the SQLITE_DEFAULT_CACHE_SIZE compile-time options.\n*/\n#ifndef SQLITE_DEFAULT_CACHE_SIZE\n# define SQLITE_DEFAULT_CACHE_SIZE  -2000\n#endif\n\n/*\n** The default number of frames to accumulate in the log file before\n** checkpointing the database in WAL mode.\n*/\n#ifndef SQLITE_DEFAULT_WAL_AUTOCHECKPOINT\n# define SQLITE_DEFAULT_WAL_AUTOCHECKPOINT  1000\n#endif\n\n/*\n** The maximum number of attached databases.  This must be between 0\n** and 125.  The upper bound of 125 is because the attached databases are\n** counted using a signed 8-bit integer which has a maximum value of 127\n** and we have to allow 2 extra counts for the \"main\" and \"temp\" databases.\n*/\n#ifndef SQLITE_MAX_ATTACHED\n# define SQLITE_MAX_ATTACHED 10\n#endif\n\n\n/*\n** The maximum value of a ?nnn wildcard that the parser will accept.\n*/\n#ifndef SQLITE_MAX_VARIABLE_NUMBER\n# define SQLITE_MAX_VARIABLE_NUMBER 999\n#endif\n\n/* Maximum page size.  The upper bound on this value is 65536.  This a limit\n** imposed by the use of 16-bit offsets within each page.\n**\n** Earlier versions of SQLite allowed the user to change this value at\n** compile time. This is no longer permitted, on the grounds that it creates\n** a library that is technically incompatible with an SQLite library \n** compiled with a different limit. If a process operating on a database \n** with a page-size of 65536 bytes crashes, then an instance of SQLite \n** compiled with the default page-size limit will not be able to rollback \n** the aborted transaction. This could lead to database corruption.\n*/\n#ifdef SQLITE_MAX_PAGE_SIZE\n# undef SQLITE_MAX_PAGE_SIZE\n#endif\n#define SQLITE_MAX_PAGE_SIZE 65536\n\n\n/*\n** The default size of a database page.\n*/\n#ifndef SQLITE_DEFAULT_PAGE_SIZE\n# define SQLITE_DEFAULT_PAGE_SIZE 4096\n#endif\n#if SQLITE_DEFAULT_PAGE_SIZE>SQLITE_MAX_PAGE_SIZE\n# undef SQLITE_DEFAULT_PAGE_SIZE\n# define SQLITE_DEFAULT_PAGE_SIZE SQLITE_MAX_PAGE_SIZE\n#endif\n\n/*\n** Ordinarily, if no value is explicitly provided, SQLite creates databases\n** with page size SQLITE_DEFAULT_PAGE_SIZE. However, based on certain\n** device characteristics (sector-size and atomic write() support),\n** SQLite may choose a larger value. This constant is the maximum value\n** SQLite will choose on its own.\n*/\n#ifndef SQLITE_MAX_DEFAULT_PAGE_SIZE\n# define SQLITE_MAX_DEFAULT_PAGE_SIZE 8192\n#endif\n#if SQLITE_MAX_DEFAULT_PAGE_SIZE>SQLITE_MAX_PAGE_SIZE\n# undef SQLITE_MAX_DEFAULT_PAGE_SIZE\n# define SQLITE_MAX_DEFAULT_PAGE_SIZE SQLITE_MAX_PAGE_SIZE\n#endif\n\n\n/*\n** Maximum number of pages in one database file.\n**\n** This is really just the default value for the max_page_count pragma.\n** This value can be lowered (or raised) at run-time using that the\n** max_page_count macro.\n*/\n#ifndef SQLITE_MAX_PAGE_COUNT\n# define SQLITE_MAX_PAGE_COUNT 1073741823\n#endif\n\n/*\n** Maximum length (in bytes) of the pattern in a LIKE or GLOB\n** operator.\n*/\n#ifndef SQLITE_MAX_LIKE_PATTERN_LENGTH\n# define SQLITE_MAX_LIKE_PATTERN_LENGTH 50000\n#endif\n\n/*\n** Maximum depth of recursion for triggers.\n**\n** A value of 1 means that a trigger program will not be able to itself\n** fire any triggers. A value of 0 means that no trigger programs at all \n** may be executed.\n*/\n#ifndef SQLITE_MAX_TRIGGER_DEPTH\n# define SQLITE_MAX_TRIGGER_DEPTH 1000\n#endif\n\n/************** End of sqliteLimit.h *****************************************/\n/************** Continuing where we left off in sqliteInt.h ******************/\n\n/* Disable nuisance warnings on Borland compilers */\n#if defined(__BORLANDC__)\n#pragma warn -rch /* unreachable code */\n#pragma warn -ccc /* Condition is always true or false */\n#pragma warn -aus /* Assigned value is never used */\n#pragma warn -csu /* Comparing signed and unsigned */\n#pragma warn -spa /* Suspicious pointer arithmetic */\n#endif\n\n/*\n** Include standard header files as necessary\n*/\n#ifdef HAVE_STDINT_H\n#include <stdint.h>\n#endif\n#ifdef HAVE_INTTYPES_H\n#include <inttypes.h>\n#endif\n\n/*\n** The following macros are used to cast pointers to integers and\n** integers to pointers.  The way you do this varies from one compiler\n** to the next, so we have developed the following set of #if statements\n** to generate appropriate macros for a wide range of compilers.\n**\n** The correct \"ANSI\" way to do this is to use the intptr_t type.\n** Unfortunately, that typedef is not available on all compilers, or\n** if it is available, it requires an #include of specific headers\n** that vary from one machine to the next.\n**\n** Ticket #3860:  The llvm-gcc-4.2 compiler from Apple chokes on\n** the ((void*)&((char*)0)[X]) construct.  But MSVC chokes on ((void*)(X)).\n** So we have to define the macros in different ways depending on the\n** compiler.\n*/\n#if defined(__PTRDIFF_TYPE__)  /* This case should work for GCC */\n# define SQLITE_INT_TO_PTR(X)  ((void*)(__PTRDIFF_TYPE__)(X))\n# define SQLITE_PTR_TO_INT(X)  ((int)(__PTRDIFF_TYPE__)(X))\n#elif !defined(__GNUC__)       /* Works for compilers other than LLVM */\n# define SQLITE_INT_TO_PTR(X)  ((void*)&((char*)0)[X])\n# define SQLITE_PTR_TO_INT(X)  ((int)(((char*)X)-(char*)0))\n#elif defined(HAVE_STDINT_H)   /* Use this case if we have ANSI headers */\n# define SQLITE_INT_TO_PTR(X)  ((void*)(intptr_t)(X))\n# define SQLITE_PTR_TO_INT(X)  ((int)(intptr_t)(X))\n#else                          /* Generates a warning - but it always works */\n# define SQLITE_INT_TO_PTR(X)  ((void*)(X))\n# define SQLITE_PTR_TO_INT(X)  ((int)(X))\n#endif\n\n/*\n** A macro to hint to the compiler that a function should not be\n** inlined.\n*/\n#if defined(__GNUC__)\n#  define SQLITE_NOINLINE  __attribute__((noinline))\n#elif defined(_MSC_VER) && _MSC_VER>=1310\n#  define SQLITE_NOINLINE  __declspec(noinline)\n#else\n#  define SQLITE_NOINLINE\n#endif\n\n/*\n** Make sure that the compiler intrinsics we desire are enabled when\n** compiling with an appropriate version of MSVC unless prevented by\n** the SQLITE_DISABLE_INTRINSIC define.\n*/\n#if !defined(SQLITE_DISABLE_INTRINSIC)\n#  if defined(_MSC_VER) && _MSC_VER>=1400\n#    if !defined(_WIN32_WCE)\n#      include <intrin.h>\n#      pragma intrinsic(_byteswap_ushort)\n#      pragma intrinsic(_byteswap_ulong)\n#      pragma intrinsic(_byteswap_uint64)\n#      pragma intrinsic(_ReadWriteBarrier)\n#    else\n#      include <cmnintrin.h>\n#    endif\n#  endif\n#endif\n\n/*\n** The SQLITE_THREADSAFE macro must be defined as 0, 1, or 2.\n** 0 means mutexes are permanently disable and the library is never\n** threadsafe.  1 means the library is serialized which is the highest\n** level of threadsafety.  2 means the library is multithreaded - multiple\n** threads can use SQLite as long as no two threads try to use the same\n** database connection at the same time.\n**\n** Older versions of SQLite used an optional THREADSAFE macro.\n** We support that for legacy.\n**\n** To ensure that the correct value of \"THREADSAFE\" is reported when querying\n** for compile-time options at runtime (e.g. \"PRAGMA compile_options\"), this\n** logic is partially replicated in ctime.c. If it is updated here, it should\n** also be updated there.\n*/\n#if !defined(SQLITE_THREADSAFE)\n# if defined(THREADSAFE)\n#   define SQLITE_THREADSAFE THREADSAFE\n# else\n#   define SQLITE_THREADSAFE 1 /* IMP: R-07272-22309 */\n# endif\n#endif\n\n/*\n** Powersafe overwrite is on by default.  But can be turned off using\n** the -DSQLITE_POWERSAFE_OVERWRITE=0 command-line option.\n*/\n#ifndef SQLITE_POWERSAFE_OVERWRITE\n# define SQLITE_POWERSAFE_OVERWRITE 1\n#endif\n\n/*\n** EVIDENCE-OF: R-25715-37072 Memory allocation statistics are enabled by\n** default unless SQLite is compiled with SQLITE_DEFAULT_MEMSTATUS=0 in\n** which case memory allocation statistics are disabled by default.\n*/\n#if !defined(SQLITE_DEFAULT_MEMSTATUS)\n# define SQLITE_DEFAULT_MEMSTATUS 1\n#endif\n\n/*\n** Exactly one of the following macros must be defined in order to\n** specify which memory allocation subsystem to use.\n**\n**     SQLITE_SYSTEM_MALLOC          // Use normal system malloc()\n**     SQLITE_WIN32_MALLOC           // Use Win32 native heap API\n**     SQLITE_ZERO_MALLOC            // Use a stub allocator that always fails\n**     SQLITE_MEMDEBUG               // Debugging version of system malloc()\n**\n** On Windows, if the SQLITE_WIN32_MALLOC_VALIDATE macro is defined and the\n** assert() macro is enabled, each call into the Win32 native heap subsystem\n** will cause HeapValidate to be called.  If heap validation should fail, an\n** assertion will be triggered.\n**\n** If none of the above are defined, then set SQLITE_SYSTEM_MALLOC as\n** the default.\n*/\n#if defined(SQLITE_SYSTEM_MALLOC) \\\n  + defined(SQLITE_WIN32_MALLOC) \\\n  + defined(SQLITE_ZERO_MALLOC) \\\n  + defined(SQLITE_MEMDEBUG)>1\n# error \"Two or more of the following compile-time configuration options\\\n are defined but at most one is allowed:\\\n SQLITE_SYSTEM_MALLOC, SQLITE_WIN32_MALLOC, SQLITE_MEMDEBUG,\\\n SQLITE_ZERO_MALLOC\"\n#endif\n#if defined(SQLITE_SYSTEM_MALLOC) \\\n  + defined(SQLITE_WIN32_MALLOC) \\\n  + defined(SQLITE_ZERO_MALLOC) \\\n  + defined(SQLITE_MEMDEBUG)==0\n# define SQLITE_SYSTEM_MALLOC 1\n#endif\n\n/*\n** If SQLITE_MALLOC_SOFT_LIMIT is not zero, then try to keep the\n** sizes of memory allocations below this value where possible.\n*/\n#if !defined(SQLITE_MALLOC_SOFT_LIMIT)\n# define SQLITE_MALLOC_SOFT_LIMIT 1024\n#endif\n\n/*\n** We need to define _XOPEN_SOURCE as follows in order to enable\n** recursive mutexes on most Unix systems and fchmod() on OpenBSD.\n** But _XOPEN_SOURCE define causes problems for Mac OS X, so omit\n** it.\n*/\n#if !defined(_XOPEN_SOURCE) && !defined(__DARWIN__) && !defined(__APPLE__)\n#  define _XOPEN_SOURCE 600\n#endif\n\n/*\n** NDEBUG and SQLITE_DEBUG are opposites.  It should always be true that\n** defined(NDEBUG)==!defined(SQLITE_DEBUG).  If this is not currently true,\n** make it true by defining or undefining NDEBUG.\n**\n** Setting NDEBUG makes the code smaller and faster by disabling the\n** assert() statements in the code.  So we want the default action\n** to be for NDEBUG to be set and NDEBUG to be undefined only if SQLITE_DEBUG\n** is set.  Thus NDEBUG becomes an opt-in rather than an opt-out\n** feature.\n*/\n#if !defined(NDEBUG) && !defined(SQLITE_DEBUG)\n# define NDEBUG 1\n#endif\n#if defined(NDEBUG) && defined(SQLITE_DEBUG)\n# undef NDEBUG\n#endif\n\n/*\n** Enable SQLITE_ENABLE_EXPLAIN_COMMENTS if SQLITE_DEBUG is turned on.\n*/\n#if !defined(SQLITE_ENABLE_EXPLAIN_COMMENTS) && defined(SQLITE_DEBUG)\n# define SQLITE_ENABLE_EXPLAIN_COMMENTS 1\n#endif\n\n/*\n** The testcase() macro is used to aid in coverage testing.  When\n** doing coverage testing, the condition inside the argument to\n** testcase() must be evaluated both true and false in order to\n** get full branch coverage.  The testcase() macro is inserted\n** to help ensure adequate test coverage in places where simple\n** condition/decision coverage is inadequate.  For example, testcase()\n** can be used to make sure boundary values are tested.  For\n** bitmask tests, testcase() can be used to make sure each bit\n** is significant and used at least once.  On switch statements\n** where multiple cases go to the same block of code, testcase()\n** can insure that all cases are evaluated.\n**\n*/\n#ifdef SQLITE_COVERAGE_TEST\nSQLITE_PRIVATE   void sqlite3Coverage(int);\n# define testcase(X)  if( X ){ sqlite3Coverage(__LINE__); }\n#else\n# define testcase(X)\n#endif\n\n/*\n** The TESTONLY macro is used to enclose variable declarations or\n** other bits of code that are needed to support the arguments\n** within testcase() and assert() macros.\n*/\n#if !defined(NDEBUG) || defined(SQLITE_COVERAGE_TEST)\n# define TESTONLY(X)  X\n#else\n# define TESTONLY(X)\n#endif\n\n/*\n** Sometimes we need a small amount of code such as a variable initialization\n** to setup for a later assert() statement.  We do not want this code to\n** appear when assert() is disabled.  The following macro is therefore\n** used to contain that setup code.  The \"VVA\" acronym stands for\n** \"Verification, Validation, and Accreditation\".  In other words, the\n** code within VVA_ONLY() will only run during verification processes.\n*/\n#ifndef NDEBUG\n# define VVA_ONLY(X)  X\n#else\n# define VVA_ONLY(X)\n#endif\n\n/*\n** The ALWAYS and NEVER macros surround boolean expressions which\n** are intended to always be true or false, respectively.  Such\n** expressions could be omitted from the code completely.  But they\n** are included in a few cases in order to enhance the resilience\n** of SQLite to unexpected behavior - to make the code \"self-healing\"\n** or \"ductile\" rather than being \"brittle\" and crashing at the first\n** hint of unplanned behavior.\n**\n** In other words, ALWAYS and NEVER are added for defensive code.\n**\n** When doing coverage testing ALWAYS and NEVER are hard-coded to\n** be true and false so that the unreachable code they specify will\n** not be counted as untested code.\n*/\n#if defined(SQLITE_COVERAGE_TEST) || defined(SQLITE_MUTATION_TEST)\n# define ALWAYS(X)      (1)\n# define NEVER(X)       (0)\n#elif !defined(NDEBUG)\n# define ALWAYS(X)      ((X)?1:(assert(0),0))\n# define NEVER(X)       ((X)?(assert(0),1):0)\n#else\n# define ALWAYS(X)      (X)\n# define NEVER(X)       (X)\n#endif\n\n/*\n** Some conditionals are optimizations only.  In other words, if the\n** conditionals are replaced with a constant 1 (true) or 0 (false) then\n** the correct answer is still obtained, though perhaps not as quickly.\n**\n** The following macros mark these optimizations conditionals.\n*/\n#if defined(SQLITE_MUTATION_TEST)\n# define OK_IF_ALWAYS_TRUE(X)  (1)\n# define OK_IF_ALWAYS_FALSE(X) (0)\n#else\n# define OK_IF_ALWAYS_TRUE(X)  (X)\n# define OK_IF_ALWAYS_FALSE(X) (X)\n#endif\n\n/*\n** Some malloc failures are only possible if SQLITE_TEST_REALLOC_STRESS is\n** defined.  We need to defend against those failures when testing with\n** SQLITE_TEST_REALLOC_STRESS, but we don't want the unreachable branches\n** during a normal build.  The following macro can be used to disable tests\n** that are always false except when SQLITE_TEST_REALLOC_STRESS is set.\n*/\n#if defined(SQLITE_TEST_REALLOC_STRESS)\n# define ONLY_IF_REALLOC_STRESS(X)  (X)\n#elif !defined(NDEBUG)\n# define ONLY_IF_REALLOC_STRESS(X)  ((X)?(assert(0),1):0)\n#else\n# define ONLY_IF_REALLOC_STRESS(X)  (0)\n#endif\n\n/*\n** Declarations used for tracing the operating system interfaces.\n*/\n#if defined(SQLITE_FORCE_OS_TRACE) || defined(SQLITE_TEST) || \\\n    (defined(SQLITE_DEBUG) && SQLITE_OS_WIN)\n  extern int sqlite3OSTrace;\n# define OSTRACE(X)          if( sqlite3OSTrace ) sqlite3DebugPrintf X\n# define SQLITE_HAVE_OS_TRACE\n#else\n# define OSTRACE(X)\n# undef  SQLITE_HAVE_OS_TRACE\n#endif\n\n/*\n** Is the sqlite3ErrName() function needed in the build?  Currently,\n** it is needed by \"mutex_w32.c\" (when debugging), \"os_win.c\" (when\n** OSTRACE is enabled), and by several \"test*.c\" files (which are\n** compiled using SQLITE_TEST).\n*/\n#if defined(SQLITE_HAVE_OS_TRACE) || defined(SQLITE_TEST) || \\\n    (defined(SQLITE_DEBUG) && SQLITE_OS_WIN)\n# define SQLITE_NEED_ERR_NAME\n#else\n# undef  SQLITE_NEED_ERR_NAME\n#endif\n\n/*\n** SQLITE_ENABLE_EXPLAIN_COMMENTS is incompatible with SQLITE_OMIT_EXPLAIN\n*/\n#ifdef SQLITE_OMIT_EXPLAIN\n# undef SQLITE_ENABLE_EXPLAIN_COMMENTS\n#endif\n\n/*\n** Return true (non-zero) if the input is an integer that is too large\n** to fit in 32-bits.  This macro is used inside of various testcase()\n** macros to verify that we have tested SQLite for large-file support.\n*/\n#define IS_BIG_INT(X)  (((X)&~(i64)0xffffffff)!=0)\n\n/*\n** The macro unlikely() is a hint that surrounds a boolean\n** expression that is usually false.  Macro likely() surrounds\n** a boolean expression that is usually true.  These hints could,\n** in theory, be used by the compiler to generate better code, but\n** currently they are just comments for human readers.\n*/\n#define likely(X)    (X)\n#define unlikely(X)  (X)\n\n/************** Include hash.h in the middle of sqliteInt.h ******************/\n/************** Begin file hash.h ********************************************/\n/*\n** 2001 September 22\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This is the header file for the generic hash-table implementation\n** used in SQLite.\n*/\n#ifndef SQLITE_HASH_H\n#define SQLITE_HASH_H\n\n/* Forward declarations of structures. */\ntypedef struct Hash Hash;\ntypedef struct HashElem HashElem;\n\n/* A complete hash table is an instance of the following structure.\n** The internals of this structure are intended to be opaque -- client\n** code should not attempt to access or modify the fields of this structure\n** directly.  Change this structure only by using the routines below.\n** However, some of the \"procedures\" and \"functions\" for modifying and\n** accessing this structure are really macros, so we can't really make\n** this structure opaque.\n**\n** All elements of the hash table are on a single doubly-linked list.\n** Hash.first points to the head of this list.\n**\n** There are Hash.htsize buckets.  Each bucket points to a spot in\n** the global doubly-linked list.  The contents of the bucket are the\n** element pointed to plus the next _ht.count-1 elements in the list.\n**\n** Hash.htsize and Hash.ht may be zero.  In that case lookup is done\n** by a linear search of the global list.  For small tables, the \n** Hash.ht table is never allocated because if there are few elements\n** in the table, it is faster to do a linear search than to manage\n** the hash table.\n*/\nstruct Hash {\n  unsigned int htsize;      /* Number of buckets in the hash table */\n  unsigned int count;       /* Number of entries in this table */\n  HashElem *first;          /* The first element of the array */\n  struct _ht {              /* the hash table */\n    int count;                 /* Number of entries with this hash */\n    HashElem *chain;           /* Pointer to first entry with this hash */\n  } *ht;\n};\n\n/* Each element in the hash table is an instance of the following \n** structure.  All elements are stored on a single doubly-linked list.\n**\n** Again, this structure is intended to be opaque, but it can't really\n** be opaque because it is used by macros.\n*/\nstruct HashElem {\n  HashElem *next, *prev;       /* Next and previous elements in the table */\n  void *data;                  /* Data associated with this element */\n  const char *pKey;            /* Key associated with this element */\n};\n\n/*\n** Access routines.  To delete, insert a NULL pointer.\n*/\nSQLITE_PRIVATE void sqlite3HashInit(Hash*);\nSQLITE_PRIVATE void *sqlite3HashInsert(Hash*, const char *pKey, void *pData);\nSQLITE_PRIVATE void *sqlite3HashFind(const Hash*, const char *pKey);\nSQLITE_PRIVATE void sqlite3HashClear(Hash*);\n\n/*\n** Macros for looping over all elements of a hash table.  The idiom is\n** like this:\n**\n**   Hash h;\n**   HashElem *p;\n**   ...\n**   for(p=sqliteHashFirst(&h); p; p=sqliteHashNext(p)){\n**     SomeStructure *pData = sqliteHashData(p);\n**     // do something with pData\n**   }\n*/\n#define sqliteHashFirst(H)  ((H)->first)\n#define sqliteHashNext(E)   ((E)->next)\n#define sqliteHashData(E)   ((E)->data)\n/* #define sqliteHashKey(E)    ((E)->pKey) // NOT USED */\n/* #define sqliteHashKeysize(E) ((E)->nKey)  // NOT USED */\n\n/*\n** Number of entries in a hash table\n*/\n/* #define sqliteHashCount(H)  ((H)->count) // NOT USED */\n\n#endif /* SQLITE_HASH_H */\n\n/************** End of hash.h ************************************************/\n/************** Continuing where we left off in sqliteInt.h ******************/\n/************** Include parse.h in the middle of sqliteInt.h *****************/\n/************** Begin file parse.h *******************************************/\n#define TK_SEMI                             1\n#define TK_EXPLAIN                          2\n#define TK_QUERY                            3\n#define TK_PLAN                             4\n#define TK_BEGIN                            5\n#define TK_TRANSACTION                      6\n#define TK_DEFERRED                         7\n#define TK_IMMEDIATE                        8\n#define TK_EXCLUSIVE                        9\n#define TK_COMMIT                          10\n#define TK_END                             11\n#define TK_ROLLBACK                        12\n#define TK_SAVEPOINT                       13\n#define TK_RELEASE                         14\n#define TK_TO                              15\n#define TK_TABLE                           16\n#define TK_CREATE                          17\n#define TK_IF                              18\n#define TK_NOT                             19\n#define TK_EXISTS                          20\n#define TK_TEMP                            21\n#define TK_LP                              22\n#define TK_RP                              23\n#define TK_AS                              24\n#define TK_WITHOUT                         25\n#define TK_COMMA                           26\n#define TK_ABORT                           27\n#define TK_ACTION                          28\n#define TK_AFTER                           29\n#define TK_ANALYZE                         30\n#define TK_ASC                             31\n#define TK_ATTACH                          32\n#define TK_BEFORE                          33\n#define TK_BY                              34\n#define TK_CASCADE                         35\n#define TK_CAST                            36\n#define TK_CONFLICT                        37\n#define TK_DATABASE                        38\n#define TK_DESC                            39\n#define TK_DETACH                          40\n#define TK_EACH                            41\n#define TK_FAIL                            42\n#define TK_OR                              43\n#define TK_AND                             44\n#define TK_IS                              45\n#define TK_MATCH                           46\n#define TK_LIKE_KW                         47\n#define TK_BETWEEN                         48\n#define TK_IN                              49\n#define TK_ISNULL                          50\n#define TK_NOTNULL                         51\n#define TK_NE                              52\n#define TK_EQ                              53\n#define TK_GT                              54\n#define TK_LE                              55\n#define TK_LT                              56\n#define TK_GE                              57\n#define TK_ESCAPE                          58\n#define TK_ID                              59\n#define TK_COLUMNKW                        60\n#define TK_DO                              61\n#define TK_FOR                             62\n#define TK_IGNORE                          63\n#define TK_INITIALLY                       64\n#define TK_INSTEAD                         65\n#define TK_NO                              66\n#define TK_KEY                             67\n#define TK_OF                              68\n#define TK_OFFSET                          69\n#define TK_PRAGMA                          70\n#define TK_RAISE                           71\n#define TK_RECURSIVE                       72\n#define TK_REPLACE                         73\n#define TK_RESTRICT                        74\n#define TK_ROW                             75\n#define TK_ROWS                            76\n#define TK_TRIGGER                         77\n#define TK_VACUUM                          78\n#define TK_VIEW                            79\n#define TK_VIRTUAL                         80\n#define TK_WITH                            81\n#define TK_CURRENT                         82\n#define TK_FOLLOWING                       83\n#define TK_PARTITION                       84\n#define TK_PRECEDING                       85\n#define TK_RANGE                           86\n#define TK_UNBOUNDED                       87\n#define TK_REINDEX                         88\n#define TK_RENAME                          89\n#define TK_CTIME_KW                        90\n#define TK_ANY                             91\n#define TK_BITAND                          92\n#define TK_BITOR                           93\n#define TK_LSHIFT                          94\n#define TK_RSHIFT                          95\n#define TK_PLUS                            96\n#define TK_MINUS                           97\n#define TK_STAR                            98\n#define TK_SLASH                           99\n#define TK_REM                            100\n#define TK_CONCAT                         101\n#define TK_COLLATE                        102\n#define TK_BITNOT                         103\n#define TK_ON                             104\n#define TK_INDEXED                        105\n#define TK_STRING                         106\n#define TK_JOIN_KW                        107\n#define TK_CONSTRAINT                     108\n#define TK_DEFAULT                        109\n#define TK_NULL                           110\n#define TK_PRIMARY                        111\n#define TK_UNIQUE                         112\n#define TK_CHECK                          113\n#define TK_REFERENCES                     114\n#define TK_AUTOINCR                       115\n#define TK_INSERT                         116\n#define TK_DELETE                         117\n#define TK_UPDATE                         118\n#define TK_SET                            119\n#define TK_DEFERRABLE                     120\n#define TK_FOREIGN                        121\n#define TK_DROP                           122\n#define TK_UNION                          123\n#define TK_ALL                            124\n#define TK_EXCEPT                         125\n#define TK_INTERSECT                      126\n#define TK_SELECT                         127\n#define TK_VALUES                         128\n#define TK_DISTINCT                       129\n#define TK_DOT                            130\n#define TK_FROM                           131\n#define TK_JOIN                           132\n#define TK_USING                          133\n#define TK_ORDER                          134\n#define TK_GROUP                          135\n#define TK_HAVING                         136\n#define TK_LIMIT                          137\n#define TK_WHERE                          138\n#define TK_INTO                           139\n#define TK_NOTHING                        140\n#define TK_FLOAT                          141\n#define TK_BLOB                           142\n#define TK_INTEGER                        143\n#define TK_VARIABLE                       144\n#define TK_CASE                           145\n#define TK_WHEN                           146\n#define TK_THEN                           147\n#define TK_ELSE                           148\n#define TK_INDEX                          149\n#define TK_ALTER                          150\n#define TK_ADD                            151\n#define TK_WINDOW                         152\n#define TK_OVER                           153\n#define TK_FILTER                         154\n#define TK_TRUEFALSE                      155\n#define TK_ISNOT                          156\n#define TK_FUNCTION                       157\n#define TK_COLUMN                         158\n#define TK_AGG_FUNCTION                   159\n#define TK_AGG_COLUMN                     160\n#define TK_UMINUS                         161\n#define TK_UPLUS                          162\n#define TK_TRUTH                          163\n#define TK_REGISTER                       164\n#define TK_VECTOR                         165\n#define TK_SELECT_COLUMN                  166\n#define TK_IF_NULL_ROW                    167\n#define TK_ASTERISK                       168\n#define TK_SPAN                           169\n#define TK_END_OF_FILE                    170\n#define TK_UNCLOSED_STRING                171\n#define TK_SPACE                          172\n#define TK_ILLEGAL                        173\n\n/* The token codes above must all fit in 8 bits */\n#define TKFLG_MASK           0xff  \n\n/* Flags that can be added to a token code when it is not\n** being stored in a u8: */\n#define TKFLG_DONTFOLD       0x100  /* Omit constant folding optimizations */\n\n/************** End of parse.h ***********************************************/\n/************** Continuing where we left off in sqliteInt.h ******************/\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include <assert.h>\n#include <stddef.h>\n\n/*\n** Use a macro to replace memcpy() if compiled with SQLITE_INLINE_MEMCPY.\n** This allows better measurements of where memcpy() is used when running\n** cachegrind.  But this macro version of memcpy() is very slow so it\n** should not be used in production.  This is a performance measurement\n** hack only.\n*/\n#ifdef SQLITE_INLINE_MEMCPY\n# define memcpy(D,S,N) {char*xxd=(char*)(D);const char*xxs=(const char*)(S);\\\n                        int xxn=(N);while(xxn-->0)*(xxd++)=*(xxs++);}\n#endif\n\n/*\n** If compiling for a processor that lacks floating point support,\n** substitute integer for floating-point\n*/\n#ifdef SQLITE_OMIT_FLOATING_POINT\n# define double sqlite_int64\n# define float sqlite_int64\n# define LONGDOUBLE_TYPE sqlite_int64\n# ifndef SQLITE_BIG_DBL\n#   define SQLITE_BIG_DBL (((sqlite3_int64)1)<<50)\n# endif\n# define SQLITE_OMIT_DATETIME_FUNCS 1\n# define SQLITE_OMIT_TRACE 1\n# undef SQLITE_MIXED_ENDIAN_64BIT_FLOAT\n# undef SQLITE_HAVE_ISNAN\n#endif\n#ifndef SQLITE_BIG_DBL\n# define SQLITE_BIG_DBL (1e99)\n#endif\n\n/*\n** OMIT_TEMPDB is set to 1 if SQLITE_OMIT_TEMPDB is defined, or 0\n** afterward. Having this macro allows us to cause the C compiler\n** to omit code used by TEMP tables without messy #ifndef statements.\n*/\n#ifdef SQLITE_OMIT_TEMPDB\n#define OMIT_TEMPDB 1\n#else\n#define OMIT_TEMPDB 0\n#endif\n\n/*\n** The \"file format\" number is an integer that is incremented whenever\n** the VDBE-level file format changes.  The following macros define the\n** the default file format for new databases and the maximum file format\n** that the library can read.\n*/\n#define SQLITE_MAX_FILE_FORMAT 4\n#ifndef SQLITE_DEFAULT_FILE_FORMAT\n# define SQLITE_DEFAULT_FILE_FORMAT 4\n#endif\n\n/*\n** Determine whether triggers are recursive by default.  This can be\n** changed at run-time using a pragma.\n*/\n#ifndef SQLITE_DEFAULT_RECURSIVE_TRIGGERS\n# define SQLITE_DEFAULT_RECURSIVE_TRIGGERS 0\n#endif\n\n/*\n** Provide a default value for SQLITE_TEMP_STORE in case it is not specified\n** on the command-line\n*/\n#ifndef SQLITE_TEMP_STORE\n# define SQLITE_TEMP_STORE 1\n#endif\n\n/*\n** If no value has been provided for SQLITE_MAX_WORKER_THREADS, or if\n** SQLITE_TEMP_STORE is set to 3 (never use temporary files), set it\n** to zero.\n*/\n#if SQLITE_TEMP_STORE==3 || SQLITE_THREADSAFE==0\n# undef SQLITE_MAX_WORKER_THREADS\n# define SQLITE_MAX_WORKER_THREADS 0\n#endif\n#ifndef SQLITE_MAX_WORKER_THREADS\n# define SQLITE_MAX_WORKER_THREADS 8\n#endif\n#ifndef SQLITE_DEFAULT_WORKER_THREADS\n# define SQLITE_DEFAULT_WORKER_THREADS 0\n#endif\n#if SQLITE_DEFAULT_WORKER_THREADS>SQLITE_MAX_WORKER_THREADS\n# undef SQLITE_MAX_WORKER_THREADS\n# define SQLITE_MAX_WORKER_THREADS SQLITE_DEFAULT_WORKER_THREADS\n#endif\n\n/*\n** The default initial allocation for the pagecache when using separate\n** pagecaches for each database connection.  A positive number is the\n** number of pages.  A negative number N translations means that a buffer\n** of -1024*N bytes is allocated and used for as many pages as it will hold.\n**\n** The default value of \"20\" was choosen to minimize the run-time of the\n** speedtest1 test program with options: --shrink-memory --reprepare\n*/\n#ifndef SQLITE_DEFAULT_PCACHE_INITSZ\n# define SQLITE_DEFAULT_PCACHE_INITSZ 20\n#endif\n\n/*\n** Default value for the SQLITE_CONFIG_SORTERREF_SIZE option.\n*/\n#ifndef SQLITE_DEFAULT_SORTERREF_SIZE\n# define SQLITE_DEFAULT_SORTERREF_SIZE 0x7fffffff\n#endif\n\n/*\n** The compile-time options SQLITE_MMAP_READWRITE and \n** SQLITE_ENABLE_BATCH_ATOMIC_WRITE are not compatible with one another.\n** You must choose one or the other (or neither) but not both.\n*/\n#if defined(SQLITE_MMAP_READWRITE) && defined(SQLITE_ENABLE_BATCH_ATOMIC_WRITE)\n#error Cannot use both SQLITE_MMAP_READWRITE and SQLITE_ENABLE_BATCH_ATOMIC_WRITE\n#endif\n\n/*\n** GCC does not define the offsetof() macro so we'll have to do it\n** ourselves.\n*/\n#ifndef offsetof\n#define offsetof(STRUCTURE,FIELD) ((int)((char*)&((STRUCTURE*)0)->FIELD))\n#endif\n\n/*\n** Macros to compute minimum and maximum of two numbers.\n*/\n#ifndef MIN\n# define MIN(A,B) ((A)<(B)?(A):(B))\n#endif\n#ifndef MAX\n# define MAX(A,B) ((A)>(B)?(A):(B))\n#endif\n\n/*\n** Swap two objects of type TYPE.\n*/\n#define SWAP(TYPE,A,B) {TYPE t=A; A=B; B=t;}\n\n/*\n** Check to see if this machine uses EBCDIC.  (Yes, believe it or\n** not, there are still machines out there that use EBCDIC.)\n*/\n#if 'A' == '\\301'\n# define SQLITE_EBCDIC 1\n#else\n# define SQLITE_ASCII 1\n#endif\n\n/*\n** Integers of known sizes.  These typedefs might change for architectures\n** where the sizes very.  Preprocessor macros are available so that the\n** types can be conveniently redefined at compile-type.  Like this:\n**\n**         cc '-DUINTPTR_TYPE=long long int' ...\n*/\n#ifndef UINT32_TYPE\n# ifdef HAVE_UINT32_T\n#  define UINT32_TYPE uint32_t\n# else\n#  define UINT32_TYPE unsigned int\n# endif\n#endif\n#ifndef UINT16_TYPE\n# ifdef HAVE_UINT16_T\n#  define UINT16_TYPE uint16_t\n# else\n#  define UINT16_TYPE unsigned short int\n# endif\n#endif\n#ifndef INT16_TYPE\n# ifdef HAVE_INT16_T\n#  define INT16_TYPE int16_t\n# else\n#  define INT16_TYPE short int\n# endif\n#endif\n#ifndef UINT8_TYPE\n# ifdef HAVE_UINT8_T\n#  define UINT8_TYPE uint8_t\n# else\n#  define UINT8_TYPE unsigned char\n# endif\n#endif\n#ifndef INT8_TYPE\n# ifdef HAVE_INT8_T\n#  define INT8_TYPE int8_t\n# else\n#  define INT8_TYPE signed char\n# endif\n#endif\n#ifndef LONGDOUBLE_TYPE\n# define LONGDOUBLE_TYPE long double\n#endif\ntypedef sqlite_int64 i64;          /* 8-byte signed integer */\ntypedef sqlite_uint64 u64;         /* 8-byte unsigned integer */\ntypedef UINT32_TYPE u32;           /* 4-byte unsigned integer */\ntypedef UINT16_TYPE u16;           /* 2-byte unsigned integer */\ntypedef INT16_TYPE i16;            /* 2-byte signed integer */\ntypedef UINT8_TYPE u8;             /* 1-byte unsigned integer */\ntypedef INT8_TYPE i8;              /* 1-byte signed integer */\n\n/*\n** SQLITE_MAX_U32 is a u64 constant that is the maximum u64 value\n** that can be stored in a u32 without loss of data.  The value\n** is 0x00000000ffffffff.  But because of quirks of some compilers, we\n** have to specify the value in the less intuitive manner shown:\n*/\n#define SQLITE_MAX_U32  ((((u64)1)<<32)-1)\n\n/*\n** The datatype used to store estimates of the number of rows in a\n** table or index.  This is an unsigned integer type.  For 99.9% of\n** the world, a 32-bit integer is sufficient.  But a 64-bit integer\n** can be used at compile-time if desired.\n*/\n#ifdef SQLITE_64BIT_STATS\n typedef u64 tRowcnt;    /* 64-bit only if requested at compile-time */\n#else\n typedef u32 tRowcnt;    /* 32-bit is the default */\n#endif\n\n/*\n** Estimated quantities used for query planning are stored as 16-bit\n** logarithms.  For quantity X, the value stored is 10*log2(X).  This\n** gives a possible range of values of approximately 1.0e986 to 1e-986.\n** But the allowed values are \"grainy\".  Not every value is representable.\n** For example, quantities 16 and 17 are both represented by a LogEst\n** of 40.  However, since LogEst quantities are suppose to be estimates,\n** not exact values, this imprecision is not a problem.\n**\n** \"LogEst\" is short for \"Logarithmic Estimate\".\n**\n** Examples:\n**      1 -> 0              20 -> 43          10000 -> 132\n**      2 -> 10             25 -> 46          25000 -> 146\n**      3 -> 16            100 -> 66        1000000 -> 199\n**      4 -> 20           1000 -> 99        1048576 -> 200\n**     10 -> 33           1024 -> 100    4294967296 -> 320\n**\n** The LogEst can be negative to indicate fractional values.\n** Examples:\n**\n**    0.5 -> -10           0.1 -> -33        0.0625 -> -40\n*/\ntypedef INT16_TYPE LogEst;\n\n/*\n** Set the SQLITE_PTRSIZE macro to the number of bytes in a pointer\n*/\n#ifndef SQLITE_PTRSIZE\n# if defined(__SIZEOF_POINTER__)\n#   define SQLITE_PTRSIZE __SIZEOF_POINTER__\n# elif defined(i386)     || defined(__i386__)   || defined(_M_IX86) ||    \\\n       defined(_M_ARM)   || defined(__arm__)    || defined(__x86)   ||    \\\n      (defined(__TOS_AIX__) && !defined(__64BIT__))\n#   define SQLITE_PTRSIZE 4\n# else\n#   define SQLITE_PTRSIZE 8\n# endif\n#endif\n\n/* The uptr type is an unsigned integer large enough to hold a pointer\n*/\n#if defined(HAVE_STDINT_H)\n  typedef uintptr_t uptr;\n#elif SQLITE_PTRSIZE==4\n  typedef u32 uptr;\n#else\n  typedef u64 uptr;\n#endif\n\n/*\n** The SQLITE_WITHIN(P,S,E) macro checks to see if pointer P points to\n** something between S (inclusive) and E (exclusive).\n**\n** In other words, S is a buffer and E is a pointer to the first byte after\n** the end of buffer S.  This macro returns true if P points to something\n** contained within the buffer S.\n*/\n#define SQLITE_WITHIN(P,S,E) (((uptr)(P)>=(uptr)(S))&&((uptr)(P)<(uptr)(E)))\n\n\n/*\n** Macros to determine whether the machine is big or little endian,\n** and whether or not that determination is run-time or compile-time.\n**\n** For best performance, an attempt is made to guess at the byte-order\n** using C-preprocessor macros.  If that is unsuccessful, or if\n** -DSQLITE_BYTEORDER=0 is set, then byte-order is determined\n** at run-time.\n*/\n#ifndef SQLITE_BYTEORDER\n# if defined(i386)     || defined(__i386__)   || defined(_M_IX86) ||    \\\n     defined(__x86_64) || defined(__x86_64__) || defined(_M_X64)  ||    \\\n     defined(_M_AMD64) || defined(_M_ARM)     || defined(__x86)   ||    \\\n     defined(__arm__)  || defined(_M_ARM64)\n#   define SQLITE_BYTEORDER    1234\n# elif defined(sparc)    || defined(__ppc__)\n#   define SQLITE_BYTEORDER    4321\n# else\n#   define SQLITE_BYTEORDER 0\n# endif\n#endif\n#if SQLITE_BYTEORDER==4321\n# define SQLITE_BIGENDIAN    1\n# define SQLITE_LITTLEENDIAN 0\n# define SQLITE_UTF16NATIVE  SQLITE_UTF16BE\n#elif SQLITE_BYTEORDER==1234\n# define SQLITE_BIGENDIAN    0\n# define SQLITE_LITTLEENDIAN 1\n# define SQLITE_UTF16NATIVE  SQLITE_UTF16LE\n#else\n# ifdef SQLITE_AMALGAMATION\n  const int sqlite3one = 1;\n# else\n  extern const int sqlite3one;\n# endif\n# define SQLITE_BIGENDIAN    (*(char *)(&sqlite3one)==0)\n# define SQLITE_LITTLEENDIAN (*(char *)(&sqlite3one)==1)\n# define SQLITE_UTF16NATIVE  (SQLITE_BIGENDIAN?SQLITE_UTF16BE:SQLITE_UTF16LE)\n#endif\n\n/*\n** Constants for the largest and smallest possible 64-bit signed integers.\n** These macros are designed to work correctly on both 32-bit and 64-bit\n** compilers.\n*/\n#define LARGEST_INT64  (0xffffffff|(((i64)0x7fffffff)<<32))\n#define SMALLEST_INT64 (((i64)-1) - LARGEST_INT64)\n\n/*\n** Round up a number to the next larger multiple of 8.  This is used\n** to force 8-byte alignment on 64-bit architectures.\n*/\n#define ROUND8(x)     (((x)+7)&~7)\n\n/*\n** Round down to the nearest multiple of 8\n*/\n#define ROUNDDOWN8(x) ((x)&~7)\n\n/*\n** Assert that the pointer X is aligned to an 8-byte boundary.  This\n** macro is used only within assert() to verify that the code gets\n** all alignment restrictions correct.\n**\n** Except, if SQLITE_4_BYTE_ALIGNED_MALLOC is defined, then the\n** underlying malloc() implementation might return us 4-byte aligned\n** pointers.  In that case, only verify 4-byte alignment.\n*/\n#ifdef SQLITE_4_BYTE_ALIGNED_MALLOC\n# define EIGHT_BYTE_ALIGNMENT(X)   ((((char*)(X) - (char*)0)&3)==0)\n#else\n# define EIGHT_BYTE_ALIGNMENT(X)   ((((char*)(X) - (char*)0)&7)==0)\n#endif\n\n/*\n** Disable MMAP on platforms where it is known to not work\n*/\n#if defined(__OpenBSD__) || defined(__QNXNTO__)\n# undef SQLITE_MAX_MMAP_SIZE\n# define SQLITE_MAX_MMAP_SIZE 0\n#endif\n\n/*\n** Default maximum size of memory used by memory-mapped I/O in the VFS\n*/\n#ifdef __APPLE__\n# include <TargetConditionals.h>\n#endif\n#ifndef SQLITE_MAX_MMAP_SIZE\n# if defined(__linux__) \\\n  || defined(_WIN32) \\\n  || (defined(__APPLE__) && defined(__MACH__)) \\\n  || defined(__sun) \\\n  || defined(__FreeBSD__) \\\n  || defined(__DragonFly__)\n#   define SQLITE_MAX_MMAP_SIZE 0x7fff0000  /* 2147418112 */\n# else\n#   define SQLITE_MAX_MMAP_SIZE 0\n# endif\n#endif\n\n/*\n** The default MMAP_SIZE is zero on all platforms.  Or, even if a larger\n** default MMAP_SIZE is specified at compile-time, make sure that it does\n** not exceed the maximum mmap size.\n*/\n#ifndef SQLITE_DEFAULT_MMAP_SIZE\n# define SQLITE_DEFAULT_MMAP_SIZE 0\n#endif\n#if SQLITE_DEFAULT_MMAP_SIZE>SQLITE_MAX_MMAP_SIZE\n# undef SQLITE_DEFAULT_MMAP_SIZE\n# define SQLITE_DEFAULT_MMAP_SIZE SQLITE_MAX_MMAP_SIZE\n#endif\n\n/*\n** Only one of SQLITE_ENABLE_STAT3 or SQLITE_ENABLE_STAT4 can be defined.\n** Priority is given to SQLITE_ENABLE_STAT4.  If either are defined, also\n** define SQLITE_ENABLE_STAT3_OR_STAT4\n*/\n#ifdef SQLITE_ENABLE_STAT4\n# undef SQLITE_ENABLE_STAT3\n# define SQLITE_ENABLE_STAT3_OR_STAT4 1\n#elif SQLITE_ENABLE_STAT3\n# define SQLITE_ENABLE_STAT3_OR_STAT4 1\n#elif SQLITE_ENABLE_STAT3_OR_STAT4\n# undef SQLITE_ENABLE_STAT3_OR_STAT4\n#endif\n\n/*\n** SELECTTRACE_ENABLED will be either 1 or 0 depending on whether or not\n** the Select query generator tracing logic is turned on.\n*/\n#if defined(SQLITE_ENABLE_SELECTTRACE)\n# define SELECTTRACE_ENABLED 1\n#else\n# define SELECTTRACE_ENABLED 0\n#endif\n\n/*\n** An instance of the following structure is used to store the busy-handler\n** callback for a given sqlite handle.\n**\n** The sqlite.busyHandler member of the sqlite struct contains the busy\n** callback for the database handle. Each pager opened via the sqlite\n** handle is passed a pointer to sqlite.busyHandler. The busy-handler\n** callback is currently invoked only from within pager.c.\n*/\ntypedef struct BusyHandler BusyHandler;\nstruct BusyHandler {\n  int (*xBusyHandler)(void *,int);  /* The busy callback */\n  void *pBusyArg;                   /* First arg to busy callback */\n  int nBusy;                        /* Incremented with each busy call */\n  u8 bExtraFileArg;                 /* Include sqlite3_file as callback arg */\n};\n\n/*\n** Name of the master database table.  The master database table\n** is a special table that holds the names and attributes of all\n** user tables and indices.\n*/\n#define MASTER_NAME       \"sqlite_master\"\n#define TEMP_MASTER_NAME  \"sqlite_temp_master\"\n\n/*\n** The root-page of the master database table.\n*/\n#define MASTER_ROOT       1\n\n/*\n** The name of the schema table.\n*/\n#define SCHEMA_TABLE(x)  ((!OMIT_TEMPDB)&&(x==1)?TEMP_MASTER_NAME:MASTER_NAME)\n\n/*\n** A convenience macro that returns the number of elements in\n** an array.\n*/\n#define ArraySize(X)    ((int)(sizeof(X)/sizeof(X[0])))\n\n/*\n** Determine if the argument is a power of two\n*/\n#define IsPowerOfTwo(X) (((X)&((X)-1))==0)\n\n/*\n** The following value as a destructor means to use sqlite3DbFree().\n** The sqlite3DbFree() routine requires two parameters instead of the\n** one parameter that destructors normally want.  So we have to introduce\n** this magic value that the code knows to handle differently.  Any\n** pointer will work here as long as it is distinct from SQLITE_STATIC\n** and SQLITE_TRANSIENT.\n*/\n#define SQLITE_DYNAMIC   ((sqlite3_destructor_type)sqlite3MallocSize)\n\n/*\n** When SQLITE_OMIT_WSD is defined, it means that the target platform does\n** not support Writable Static Data (WSD) such as global and static variables.\n** All variables must either be on the stack or dynamically allocated from\n** the heap.  When WSD is unsupported, the variable declarations scattered\n** throughout the SQLite code must become constants instead.  The SQLITE_WSD\n** macro is used for this purpose.  And instead of referencing the variable\n** directly, we use its constant as a key to lookup the run-time allocated\n** buffer that holds real variable.  The constant is also the initializer\n** for the run-time allocated buffer.\n**\n** In the usual case where WSD is supported, the SQLITE_WSD and GLOBAL\n** macros become no-ops and have zero performance impact.\n*/\n#ifdef SQLITE_OMIT_WSD\n  #define SQLITE_WSD const\n  #define GLOBAL(t,v) (*(t*)sqlite3_wsd_find((void*)&(v), sizeof(v)))\n  #define sqlite3GlobalConfig GLOBAL(struct Sqlite3Config, sqlite3Config)\nSQLITE_API int sqlite3_wsd_init(int N, int J);\nSQLITE_API void *sqlite3_wsd_find(void *K, int L);\n#else\n  #define SQLITE_WSD\n  #define GLOBAL(t,v) v\n  #define sqlite3GlobalConfig sqlite3Config\n#endif\n\n/*\n** The following macros are used to suppress compiler warnings and to\n** make it clear to human readers when a function parameter is deliberately\n** left unused within the body of a function. This usually happens when\n** a function is called via a function pointer. For example the\n** implementation of an SQL aggregate step callback may not use the\n** parameter indicating the number of arguments passed to the aggregate,\n** if it knows that this is enforced elsewhere.\n**\n** When a function parameter is not used at all within the body of a function,\n** it is generally named \"NotUsed\" or \"NotUsed2\" to make things even clearer.\n** However, these macros may also be used to suppress warnings related to\n** parameters that may or may not be used depending on compilation options.\n** For example those parameters only used in assert() statements. In these\n** cases the parameters are named as per the usual conventions.\n*/\n#define UNUSED_PARAMETER(x) (void)(x)\n#define UNUSED_PARAMETER2(x,y) UNUSED_PARAMETER(x),UNUSED_PARAMETER(y)\n\n/*\n** Forward references to structures\n*/\ntypedef struct AggInfo AggInfo;\ntypedef struct AuthContext AuthContext;\ntypedef struct AutoincInfo AutoincInfo;\ntypedef struct Bitvec Bitvec;\ntypedef struct CollSeq CollSeq;\ntypedef struct Column Column;\ntypedef struct Db Db;\ntypedef struct Schema Schema;\ntypedef struct Expr Expr;\ntypedef struct ExprList ExprList;\ntypedef struct FKey FKey;\ntypedef struct FuncDestructor FuncDestructor;\ntypedef struct FuncDef FuncDef;\ntypedef struct FuncDefHash FuncDefHash;\ntypedef struct IdList IdList;\ntypedef struct Index Index;\ntypedef struct IndexSample IndexSample;\ntypedef struct KeyClass KeyClass;\ntypedef struct KeyInfo KeyInfo;\ntypedef struct Lookaside Lookaside;\ntypedef struct LookasideSlot LookasideSlot;\ntypedef struct Module Module;\ntypedef struct NameContext NameContext;\ntypedef struct Parse Parse;\ntypedef struct PreUpdate PreUpdate;\ntypedef struct PrintfArguments PrintfArguments;\ntypedef struct RenameToken RenameToken;\ntypedef struct RowSet RowSet;\ntypedef struct Savepoint Savepoint;\ntypedef struct Select Select;\ntypedef struct SQLiteThread SQLiteThread;\ntypedef struct SelectDest SelectDest;\ntypedef struct SrcList SrcList;\ntypedef struct sqlite3_str StrAccum; /* Internal alias for sqlite3_str */\ntypedef struct Table Table;\ntypedef struct TableLock TableLock;\ntypedef struct Token Token;\ntypedef struct TreeView TreeView;\ntypedef struct Trigger Trigger;\ntypedef struct TriggerPrg TriggerPrg;\ntypedef struct TriggerStep TriggerStep;\ntypedef struct UnpackedRecord UnpackedRecord;\ntypedef struct Upsert Upsert;\ntypedef struct VTable VTable;\ntypedef struct VtabCtx VtabCtx;\ntypedef struct Walker Walker;\ntypedef struct WhereInfo WhereInfo;\ntypedef struct Window Window;\ntypedef struct With With;\n\n\n/*\n** The bitmask datatype defined below is used for various optimizations.\n**\n** Changing this from a 64-bit to a 32-bit type limits the number of\n** tables in a join to 32 instead of 64.  But it also reduces the size\n** of the library by 738 bytes on ix86.\n*/\n#ifdef SQLITE_BITMASK_TYPE\n  typedef SQLITE_BITMASK_TYPE Bitmask;\n#else\n  typedef u64 Bitmask;\n#endif\n\n/*\n** The number of bits in a Bitmask.  \"BMS\" means \"BitMask Size\".\n*/\n#define BMS  ((int)(sizeof(Bitmask)*8))\n\n/*\n** A bit in a Bitmask\n*/\n#define MASKBIT(n)   (((Bitmask)1)<<(n))\n#define MASKBIT32(n) (((unsigned int)1)<<(n))\n#define ALLBITS      ((Bitmask)-1)\n\n/* A VList object records a mapping between parameters/variables/wildcards\n** in the SQL statement (such as $abc, @pqr, or :xyz) and the integer\n** variable number associated with that parameter.  See the format description\n** on the sqlite3VListAdd() routine for more information.  A VList is really\n** just an array of integers.\n*/\ntypedef int VList;\n\n/*\n** Defer sourcing vdbe.h and btree.h until after the \"u8\" and\n** \"BusyHandler\" typedefs. vdbe.h also requires a few of the opaque\n** pointer types (i.e. FuncDef) defined above.\n*/\n/************** Include btree.h in the middle of sqliteInt.h *****************/\n/************** Begin file btree.h *******************************************/\n/*\n** 2001 September 15\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This header file defines the interface that the sqlite B-Tree file\n** subsystem.  See comments in the source code for a detailed description\n** of what each interface routine does.\n*/\n#ifndef SQLITE_BTREE_H\n#define SQLITE_BTREE_H\n\n/* TODO: This definition is just included so other modules compile. It\n** needs to be revisited.\n*/\n#define SQLITE_N_BTREE_META 16\n\n/*\n** If defined as non-zero, auto-vacuum is enabled by default. Otherwise\n** it must be turned on for each database using \"PRAGMA auto_vacuum = 1\".\n*/\n#ifndef SQLITE_DEFAULT_AUTOVACUUM\n  #define SQLITE_DEFAULT_AUTOVACUUM 0\n#endif\n\n#define BTREE_AUTOVACUUM_NONE 0        /* Do not do auto-vacuum */\n#define BTREE_AUTOVACUUM_FULL 1        /* Do full auto-vacuum */\n#define BTREE_AUTOVACUUM_INCR 2        /* Incremental vacuum */\n\n/*\n** Forward declarations of structure\n*/\ntypedef struct Btree Btree;\ntypedef struct BtCursor BtCursor;\ntypedef struct BtShared BtShared;\ntypedef struct BtreePayload BtreePayload;\n\n\nSQLITE_PRIVATE int sqlite3BtreeOpen(\n  sqlite3_vfs *pVfs,       /* VFS to use with this b-tree */\n  const char *zFilename,   /* Name of database file to open */\n  sqlite3 *db,             /* Associated database connection */\n  Btree **ppBtree,         /* Return open Btree* here */\n  int flags,               /* Flags */\n  int vfsFlags             /* Flags passed through to VFS open */\n);\n\n/* The flags parameter to sqlite3BtreeOpen can be the bitwise or of the\n** following values.\n**\n** NOTE:  These values must match the corresponding PAGER_ values in\n** pager.h.\n*/\n#define BTREE_OMIT_JOURNAL  1  /* Do not create or use a rollback journal */\n#define BTREE_MEMORY        2  /* This is an in-memory DB */\n#define BTREE_SINGLE        4  /* The file contains at most 1 b-tree */\n#define BTREE_UNORDERED     8  /* Use of a hash implementation is OK */\n\nSQLITE_PRIVATE int sqlite3BtreeClose(Btree*);\nSQLITE_PRIVATE int sqlite3BtreeSetCacheSize(Btree*,int);\nSQLITE_PRIVATE int sqlite3BtreeSetSpillSize(Btree*,int);\n#if SQLITE_MAX_MMAP_SIZE>0\nSQLITE_PRIVATE   int sqlite3BtreeSetMmapLimit(Btree*,sqlite3_int64);\n#endif\nSQLITE_PRIVATE int sqlite3BtreeSetPagerFlags(Btree*,unsigned);\nSQLITE_PRIVATE int sqlite3BtreeSetPageSize(Btree *p, int nPagesize, int nReserve, int eFix);\nSQLITE_PRIVATE int sqlite3BtreeGetPageSize(Btree*);\nSQLITE_PRIVATE int sqlite3BtreeMaxPageCount(Btree*,int);\nSQLITE_PRIVATE u32 sqlite3BtreeLastPage(Btree*);\nSQLITE_PRIVATE int sqlite3BtreeSecureDelete(Btree*,int);\nSQLITE_PRIVATE int sqlite3BtreeGetOptimalReserve(Btree*);\nSQLITE_PRIVATE int sqlite3BtreeGetReserveNoMutex(Btree *p);\nSQLITE_PRIVATE int sqlite3BtreeSetAutoVacuum(Btree *, int);\nSQLITE_PRIVATE int sqlite3BtreeGetAutoVacuum(Btree *);\nSQLITE_PRIVATE int sqlite3BtreeBeginTrans(Btree*,int,int*);\nSQLITE_PRIVATE int sqlite3BtreeCommitPhaseOne(Btree*, const char *zMaster);\nSQLITE_PRIVATE int sqlite3BtreeCommitPhaseTwo(Btree*, int);\nSQLITE_PRIVATE int sqlite3BtreeCommit(Btree*);\nSQLITE_PRIVATE int sqlite3BtreeRollback(Btree*,int,int);\nSQLITE_PRIVATE int sqlite3BtreeBeginStmt(Btree*,int);\nSQLITE_PRIVATE int sqlite3BtreeCreateTable(Btree*, int*, int flags);\nSQLITE_PRIVATE int sqlite3BtreeIsInTrans(Btree*);\nSQLITE_PRIVATE int sqlite3BtreeIsInReadTrans(Btree*);\nSQLITE_PRIVATE int sqlite3BtreeIsInBackup(Btree*);\nSQLITE_PRIVATE void *sqlite3BtreeSchema(Btree *, int, void(*)(void *));\nSQLITE_PRIVATE int sqlite3BtreeSchemaLocked(Btree *pBtree);\n#ifndef SQLITE_OMIT_SHARED_CACHE\nSQLITE_PRIVATE int sqlite3BtreeLockTable(Btree *pBtree, int iTab, u8 isWriteLock);\n#endif\nSQLITE_PRIVATE int sqlite3BtreeSavepoint(Btree *, int, int);\n\nSQLITE_PRIVATE const char *sqlite3BtreeGetFilename(Btree *);\nSQLITE_PRIVATE const char *sqlite3BtreeGetJournalname(Btree *);\nSQLITE_PRIVATE int sqlite3BtreeCopyFile(Btree *, Btree *);\n\nSQLITE_PRIVATE int sqlite3BtreeIncrVacuum(Btree *);\n\n/* The flags parameter to sqlite3BtreeCreateTable can be the bitwise OR\n** of the flags shown below.\n**\n** Every SQLite table must have either BTREE_INTKEY or BTREE_BLOBKEY set.\n** With BTREE_INTKEY, the table key is a 64-bit integer and arbitrary data\n** is stored in the leaves.  (BTREE_INTKEY is used for SQL tables.)  With\n** BTREE_BLOBKEY, the key is an arbitrary BLOB and no content is stored\n** anywhere - the key is the content.  (BTREE_BLOBKEY is used for SQL\n** indices.)\n*/\n#define BTREE_INTKEY     1    /* Table has only 64-bit signed integer keys */\n#define BTREE_BLOBKEY    2    /* Table has keys only - no data */\n\nSQLITE_PRIVATE int sqlite3BtreeDropTable(Btree*, int, int*);\nSQLITE_PRIVATE int sqlite3BtreeClearTable(Btree*, int, int*);\nSQLITE_PRIVATE int sqlite3BtreeClearTableOfCursor(BtCursor*);\nSQLITE_PRIVATE int sqlite3BtreeTripAllCursors(Btree*, int, int);\n\nSQLITE_PRIVATE void sqlite3BtreeGetMeta(Btree *pBtree, int idx, u32 *pValue);\nSQLITE_PRIVATE int sqlite3BtreeUpdateMeta(Btree*, int idx, u32 value);\n\nSQLITE_PRIVATE int sqlite3BtreeNewDb(Btree *p);\n\n/*\n** The second parameter to sqlite3BtreeGetMeta or sqlite3BtreeUpdateMeta\n** should be one of the following values. The integer values are assigned \n** to constants so that the offset of the corresponding field in an\n** SQLite database header may be found using the following formula:\n**\n**   offset = 36 + (idx * 4)\n**\n** For example, the free-page-count field is located at byte offset 36 of\n** the database file header. The incr-vacuum-flag field is located at\n** byte offset 64 (== 36+4*7).\n**\n** The BTREE_DATA_VERSION value is not really a value stored in the header.\n** It is a read-only number computed by the pager.  But we merge it with\n** the header value access routines since its access pattern is the same.\n** Call it a \"virtual meta value\".\n*/\n#define BTREE_FREE_PAGE_COUNT     0\n#define BTREE_SCHEMA_VERSION      1\n#define BTREE_FILE_FORMAT         2\n#define BTREE_DEFAULT_CACHE_SIZE  3\n#define BTREE_LARGEST_ROOT_PAGE   4\n#define BTREE_TEXT_ENCODING       5\n#define BTREE_USER_VERSION        6\n#define BTREE_INCR_VACUUM         7\n#define BTREE_APPLICATION_ID      8\n#define BTREE_DATA_VERSION        15  /* A virtual meta-value */\n\n/*\n** Kinds of hints that can be passed into the sqlite3BtreeCursorHint()\n** interface.\n**\n** BTREE_HINT_RANGE  (arguments: Expr*, Mem*)\n**\n**     The first argument is an Expr* (which is guaranteed to be constant for\n**     the lifetime of the cursor) that defines constraints on which rows\n**     might be fetched with this cursor.  The Expr* tree may contain\n**     TK_REGISTER nodes that refer to values stored in the array of registers\n**     passed as the second parameter.  In other words, if Expr.op==TK_REGISTER\n**     then the value of the node is the value in Mem[pExpr.iTable].  Any\n**     TK_COLUMN node in the expression tree refers to the Expr.iColumn-th\n**     column of the b-tree of the cursor.  The Expr tree will not contain\n**     any function calls nor subqueries nor references to b-trees other than\n**     the cursor being hinted.\n**\n**     The design of the _RANGE hint is aid b-tree implementations that try\n**     to prefetch content from remote machines - to provide those\n**     implementations with limits on what needs to be prefetched and thereby\n**     reduce network bandwidth.\n**\n** Note that BTREE_HINT_FLAGS with BTREE_BULKLOAD is the only hint used by\n** standard SQLite.  The other hints are provided for extentions that use\n** the SQLite parser and code generator but substitute their own storage\n** engine.\n*/\n#define BTREE_HINT_RANGE 0       /* Range constraints on queries */\n\n/*\n** Values that may be OR'd together to form the argument to the\n** BTREE_HINT_FLAGS hint for sqlite3BtreeCursorHint():\n**\n** The BTREE_BULKLOAD flag is set on index cursors when the index is going\n** to be filled with content that is already in sorted order.\n**\n** The BTREE_SEEK_EQ flag is set on cursors that will get OP_SeekGE or\n** OP_SeekLE opcodes for a range search, but where the range of entries\n** selected will all have the same key.  In other words, the cursor will\n** be used only for equality key searches.\n**\n*/\n#define BTREE_BULKLOAD 0x00000001  /* Used to full index in sorted order */\n#define BTREE_SEEK_EQ  0x00000002  /* EQ seeks only - no range seeks */\n\n/* \n** Flags passed as the third argument to sqlite3BtreeCursor().\n**\n** For read-only cursors the wrFlag argument is always zero. For read-write\n** cursors it may be set to either (BTREE_WRCSR|BTREE_FORDELETE) or just\n** (BTREE_WRCSR). If the BTREE_FORDELETE bit is set, then the cursor will\n** only be used by SQLite for the following:\n**\n**   * to seek to and then delete specific entries, and/or\n**\n**   * to read values that will be used to create keys that other\n**     BTREE_FORDELETE cursors will seek to and delete.\n**\n** The BTREE_FORDELETE flag is an optimization hint.  It is not used by\n** by this, the native b-tree engine of SQLite, but it is available to\n** alternative storage engines that might be substituted in place of this\n** b-tree system.  For alternative storage engines in which a delete of\n** the main table row automatically deletes corresponding index rows,\n** the FORDELETE flag hint allows those alternative storage engines to\n** skip a lot of work.  Namely:  FORDELETE cursors may treat all SEEK\n** and DELETE operations as no-ops, and any READ operation against a\n** FORDELETE cursor may return a null row: 0x01 0x00.\n*/\n#define BTREE_WRCSR     0x00000004     /* read-write cursor */\n#define BTREE_FORDELETE 0x00000008     /* Cursor is for seek/delete only */\n\nSQLITE_PRIVATE int sqlite3BtreeCursor(\n  Btree*,                              /* BTree containing table to open */\n  int iTable,                          /* Index of root page */\n  int wrFlag,                          /* 1 for writing.  0 for read-only */\n  struct KeyInfo*,                     /* First argument to compare function */\n  BtCursor *pCursor                    /* Space to write cursor structure */\n);\nSQLITE_PRIVATE BtCursor *sqlite3BtreeFakeValidCursor(void);\nSQLITE_PRIVATE int sqlite3BtreeCursorSize(void);\nSQLITE_PRIVATE void sqlite3BtreeCursorZero(BtCursor*);\nSQLITE_PRIVATE void sqlite3BtreeCursorHintFlags(BtCursor*, unsigned);\n#ifdef SQLITE_ENABLE_CURSOR_HINTS\nSQLITE_PRIVATE void sqlite3BtreeCursorHint(BtCursor*, int, ...);\n#endif\n\nSQLITE_PRIVATE int sqlite3BtreeCloseCursor(BtCursor*);\nSQLITE_PRIVATE int sqlite3BtreeMovetoUnpacked(\n  BtCursor*,\n  UnpackedRecord *pUnKey,\n  i64 intKey,\n  int bias,\n  int *pRes\n);\nSQLITE_PRIVATE int sqlite3BtreeCursorHasMoved(BtCursor*);\nSQLITE_PRIVATE int sqlite3BtreeCursorRestore(BtCursor*, int*);\nSQLITE_PRIVATE int sqlite3BtreeDelete(BtCursor*, u8 flags);\n\n/* Allowed flags for sqlite3BtreeDelete() and sqlite3BtreeInsert() */\n#define BTREE_SAVEPOSITION 0x02  /* Leave cursor pointing at NEXT or PREV */\n#define BTREE_AUXDELETE    0x04  /* not the primary delete operation */\n#define BTREE_APPEND       0x08  /* Insert is likely an append */\n\n/* An instance of the BtreePayload object describes the content of a single\n** entry in either an index or table btree.\n**\n** Index btrees (used for indexes and also WITHOUT ROWID tables) contain\n** an arbitrary key and no data.  These btrees have pKey,nKey set to the\n** key and the pData,nData,nZero fields are uninitialized.  The aMem,nMem\n** fields give an array of Mem objects that are a decomposition of the key.\n** The nMem field might be zero, indicating that no decomposition is available.\n**\n** Table btrees (used for rowid tables) contain an integer rowid used as\n** the key and passed in the nKey field.  The pKey field is zero.  \n** pData,nData hold the content of the new entry.  nZero extra zero bytes\n** are appended to the end of the content when constructing the entry.\n** The aMem,nMem fields are uninitialized for table btrees.\n**\n** Field usage summary:\n**\n**               Table BTrees                   Index Btrees\n**\n**   pKey        always NULL                    encoded key\n**   nKey        the ROWID                      length of pKey\n**   pData       data                           not used\n**   aMem        not used                       decomposed key value\n**   nMem        not used                       entries in aMem\n**   nData       length of pData                not used\n**   nZero       extra zeros after pData        not used\n**\n** This object is used to pass information into sqlite3BtreeInsert().  The\n** same information used to be passed as five separate parameters.  But placing\n** the information into this object helps to keep the interface more \n** organized and understandable, and it also helps the resulting code to\n** run a little faster by using fewer registers for parameter passing.\n*/\nstruct BtreePayload {\n  const void *pKey;       /* Key content for indexes.  NULL for tables */\n  sqlite3_int64 nKey;     /* Size of pKey for indexes.  PRIMARY KEY for tabs */\n  const void *pData;      /* Data for tables. */\n  sqlite3_value *aMem;    /* First of nMem value in the unpacked pKey */\n  u16 nMem;               /* Number of aMem[] value.  Might be zero */\n  int nData;              /* Size of pData.  0 if none. */\n  int nZero;              /* Extra zero data appended after pData,nData */\n};\n\nSQLITE_PRIVATE int sqlite3BtreeInsert(BtCursor*, const BtreePayload *pPayload,\n                       int flags, int seekResult);\nSQLITE_PRIVATE int sqlite3BtreeFirst(BtCursor*, int *pRes);\n#ifndef SQLITE_OMIT_WINDOWFUNC\nSQLITE_PRIVATE void sqlite3BtreeSkipNext(BtCursor*);\n#endif\nSQLITE_PRIVATE int sqlite3BtreeLast(BtCursor*, int *pRes);\nSQLITE_PRIVATE int sqlite3BtreeNext(BtCursor*, int flags);\nSQLITE_PRIVATE int sqlite3BtreeEof(BtCursor*);\nSQLITE_PRIVATE int sqlite3BtreePrevious(BtCursor*, int flags);\nSQLITE_PRIVATE i64 sqlite3BtreeIntegerKey(BtCursor*);\n#ifdef SQLITE_ENABLE_OFFSET_SQL_FUNC\nSQLITE_PRIVATE i64 sqlite3BtreeOffset(BtCursor*);\n#endif\nSQLITE_PRIVATE int sqlite3BtreePayload(BtCursor*, u32 offset, u32 amt, void*);\nSQLITE_PRIVATE const void *sqlite3BtreePayloadFetch(BtCursor*, u32 *pAmt);\nSQLITE_PRIVATE u32 sqlite3BtreePayloadSize(BtCursor*);\nSQLITE_PRIVATE sqlite3_int64 sqlite3BtreeMaxRecordSize(BtCursor*);\n\nSQLITE_PRIVATE char *sqlite3BtreeIntegrityCheck(Btree*, int *aRoot, int nRoot, int, int*);\nSQLITE_PRIVATE struct Pager *sqlite3BtreePager(Btree*);\nSQLITE_PRIVATE i64 sqlite3BtreeRowCountEst(BtCursor*);\n\n#ifndef SQLITE_OMIT_INCRBLOB\nSQLITE_PRIVATE int sqlite3BtreePayloadChecked(BtCursor*, u32 offset, u32 amt, void*);\nSQLITE_PRIVATE int sqlite3BtreePutData(BtCursor*, u32 offset, u32 amt, void*);\nSQLITE_PRIVATE void sqlite3BtreeIncrblobCursor(BtCursor *);\n#endif\nSQLITE_PRIVATE void sqlite3BtreeClearCursor(BtCursor *);\nSQLITE_PRIVATE int sqlite3BtreeSetVersion(Btree *pBt, int iVersion);\nSQLITE_PRIVATE int sqlite3BtreeCursorHasHint(BtCursor*, unsigned int mask);\nSQLITE_PRIVATE int sqlite3BtreeIsReadonly(Btree *pBt);\nSQLITE_PRIVATE int sqlite3HeaderSizeBtree(void);\n\n#ifndef NDEBUG\nSQLITE_PRIVATE int sqlite3BtreeCursorIsValid(BtCursor*);\n#endif\nSQLITE_PRIVATE int sqlite3BtreeCursorIsValidNN(BtCursor*);\n\n#ifndef SQLITE_OMIT_BTREECOUNT\nSQLITE_PRIVATE int sqlite3BtreeCount(BtCursor *, i64 *);\n#endif\n\n#ifdef SQLITE_TEST\nSQLITE_PRIVATE int sqlite3BtreeCursorInfo(BtCursor*, int*, int);\nSQLITE_PRIVATE void sqlite3BtreeCursorList(Btree*);\n#endif\n\n#ifndef SQLITE_OMIT_WAL\nSQLITE_PRIVATE   int sqlite3BtreeCheckpoint(Btree*, int, int *, int *);\n#endif\n\n/*\n** If we are not using shared cache, then there is no need to\n** use mutexes to access the BtShared structures.  So make the\n** Enter and Leave procedures no-ops.\n*/\n#ifndef SQLITE_OMIT_SHARED_CACHE\nSQLITE_PRIVATE   void sqlite3BtreeEnter(Btree*);\nSQLITE_PRIVATE   void sqlite3BtreeEnterAll(sqlite3*);\nSQLITE_PRIVATE   int sqlite3BtreeSharable(Btree*);\nSQLITE_PRIVATE   void sqlite3BtreeEnterCursor(BtCursor*);\nSQLITE_PRIVATE   int sqlite3BtreeConnectionCount(Btree*);\n#else\n# define sqlite3BtreeEnter(X) \n# define sqlite3BtreeEnterAll(X)\n# define sqlite3BtreeSharable(X) 0\n# define sqlite3BtreeEnterCursor(X)\n# define sqlite3BtreeConnectionCount(X) 1\n#endif\n\n#if !defined(SQLITE_OMIT_SHARED_CACHE) && SQLITE_THREADSAFE\nSQLITE_PRIVATE   void sqlite3BtreeLeave(Btree*);\nSQLITE_PRIVATE   void sqlite3BtreeLeaveCursor(BtCursor*);\nSQLITE_PRIVATE   void sqlite3BtreeLeaveAll(sqlite3*);\n#ifndef NDEBUG\n  /* These routines are used inside assert() statements only. */\nSQLITE_PRIVATE   int sqlite3BtreeHoldsMutex(Btree*);\nSQLITE_PRIVATE   int sqlite3BtreeHoldsAllMutexes(sqlite3*);\nSQLITE_PRIVATE   int sqlite3SchemaMutexHeld(sqlite3*,int,Schema*);\n#endif\n#else\n\n# define sqlite3BtreeLeave(X)\n# define sqlite3BtreeLeaveCursor(X)\n# define sqlite3BtreeLeaveAll(X)\n\n# define sqlite3BtreeHoldsMutex(X) 1\n# define sqlite3BtreeHoldsAllMutexes(X) 1\n# define sqlite3SchemaMutexHeld(X,Y,Z) 1\n#endif\n\n\n#endif /* SQLITE_BTREE_H */\n\n/************** End of btree.h ***********************************************/\n/************** Continuing where we left off in sqliteInt.h ******************/\n/************** Include vdbe.h in the middle of sqliteInt.h ******************/\n/************** Begin file vdbe.h ********************************************/\n/*\n** 2001 September 15\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** Header file for the Virtual DataBase Engine (VDBE)\n**\n** This header defines the interface to the virtual database engine\n** or VDBE.  The VDBE implements an abstract machine that runs a\n** simple program to access and modify the underlying database.\n*/\n#ifndef SQLITE_VDBE_H\n#define SQLITE_VDBE_H\n/* #include <stdio.h> */\n\n/*\n** A single VDBE is an opaque structure named \"Vdbe\".  Only routines\n** in the source file sqliteVdbe.c are allowed to see the insides\n** of this structure.\n*/\ntypedef struct Vdbe Vdbe;\n\n/*\n** The names of the following types declared in vdbeInt.h are required\n** for the VdbeOp definition.\n*/\ntypedef struct sqlite3_value Mem;\ntypedef struct SubProgram SubProgram;\n\n/*\n** A single instruction of the virtual machine has an opcode\n** and as many as three operands.  The instruction is recorded\n** as an instance of the following structure:\n*/\nstruct VdbeOp {\n  u8 opcode;          /* What operation to perform */\n  signed char p4type; /* One of the P4_xxx constants for p4 */\n  u16 p5;             /* Fifth parameter is an unsigned 16-bit integer */\n  int p1;             /* First operand */\n  int p2;             /* Second parameter (often the jump destination) */\n  int p3;             /* The third parameter */\n  union p4union {     /* fourth parameter */\n    int i;                 /* Integer value if p4type==P4_INT32 */\n    void *p;               /* Generic pointer */\n    char *z;               /* Pointer to data for string (char array) types */\n    i64 *pI64;             /* Used when p4type is P4_INT64 */\n    double *pReal;         /* Used when p4type is P4_REAL */\n    FuncDef *pFunc;        /* Used when p4type is P4_FUNCDEF */\n    sqlite3_context *pCtx; /* Used when p4type is P4_FUNCCTX */\n    CollSeq *pColl;        /* Used when p4type is P4_COLLSEQ */\n    Mem *pMem;             /* Used when p4type is P4_MEM */\n    VTable *pVtab;         /* Used when p4type is P4_VTAB */\n    KeyInfo *pKeyInfo;     /* Used when p4type is P4_KEYINFO */\n    int *ai;               /* Used when p4type is P4_INTARRAY */\n    SubProgram *pProgram;  /* Used when p4type is P4_SUBPROGRAM */\n    Table *pTab;           /* Used when p4type is P4_TABLE */\n#ifdef SQLITE_ENABLE_CURSOR_HINTS\n    Expr *pExpr;           /* Used when p4type is P4_EXPR */\n#endif\n    int (*xAdvance)(BtCursor *, int);\n  } p4;\n#ifdef SQLITE_ENABLE_EXPLAIN_COMMENTS\n  char *zComment;          /* Comment to improve readability */\n#endif\n#ifdef VDBE_PROFILE\n  u32 cnt;                 /* Number of times this instruction was executed */\n  u64 cycles;              /* Total time spent executing this instruction */\n#endif\n#ifdef SQLITE_VDBE_COVERAGE\n  u32 iSrcLine;            /* Source-code line that generated this opcode\n                           ** with flags in the upper 8 bits */\n#endif\n};\ntypedef struct VdbeOp VdbeOp;\n\n\n/*\n** A sub-routine used to implement a trigger program.\n*/\nstruct SubProgram {\n  VdbeOp *aOp;                  /* Array of opcodes for sub-program */\n  int nOp;                      /* Elements in aOp[] */\n  int nMem;                     /* Number of memory cells required */\n  int nCsr;                     /* Number of cursors required */\n  u8 *aOnce;                    /* Array of OP_Once flags */\n  void *token;                  /* id that may be used to recursive triggers */\n  SubProgram *pNext;            /* Next sub-program already visited */\n};\n\n/*\n** A smaller version of VdbeOp used for the VdbeAddOpList() function because\n** it takes up less space.\n*/\nstruct VdbeOpList {\n  u8 opcode;          /* What operation to perform */\n  signed char p1;     /* First operand */\n  signed char p2;     /* Second parameter (often the jump destination) */\n  signed char p3;     /* Third parameter */\n};\ntypedef struct VdbeOpList VdbeOpList;\n\n/*\n** Allowed values of VdbeOp.p4type\n*/\n#define P4_NOTUSED      0   /* The P4 parameter is not used */\n#define P4_TRANSIENT    0   /* P4 is a pointer to a transient string */\n#define P4_STATIC     (-1)  /* Pointer to a static string */\n#define P4_COLLSEQ    (-2)  /* P4 is a pointer to a CollSeq structure */\n#define P4_INT32      (-3)  /* P4 is a 32-bit signed integer */\n#define P4_SUBPROGRAM (-4)  /* P4 is a pointer to a SubProgram structure */\n#define P4_ADVANCE    (-5)  /* P4 is a pointer to BtreeNext() or BtreePrev() */\n#define P4_TABLE      (-6)  /* P4 is a pointer to a Table structure */\n/* Above do not own any resources.  Must free those below */\n#define P4_FREE_IF_LE (-7)\n#define P4_DYNAMIC    (-7)  /* Pointer to memory from sqliteMalloc() */\n#define P4_FUNCDEF    (-8)  /* P4 is a pointer to a FuncDef structure */\n#define P4_KEYINFO    (-9)  /* P4 is a pointer to a KeyInfo structure */\n#define P4_EXPR       (-10) /* P4 is a pointer to an Expr tree */\n#define P4_MEM        (-11) /* P4 is a pointer to a Mem*    structure */\n#define P4_VTAB       (-12) /* P4 is a pointer to an sqlite3_vtab structure */\n#define P4_REAL       (-13) /* P4 is a 64-bit floating point value */\n#define P4_INT64      (-14) /* P4 is a 64-bit signed integer */\n#define P4_INTARRAY   (-15) /* P4 is a vector of 32-bit integers */\n#define P4_FUNCCTX    (-16) /* P4 is a pointer to an sqlite3_context object */\n#define P4_DYNBLOB    (-17) /* Pointer to memory from sqliteMalloc() */\n\n/* Error message codes for OP_Halt */\n#define P5_ConstraintNotNull 1\n#define P5_ConstraintUnique  2\n#define P5_ConstraintCheck   3\n#define P5_ConstraintFK      4\n\n/*\n** The Vdbe.aColName array contains 5n Mem structures, where n is the \n** number of columns of data returned by the statement.\n*/\n#define COLNAME_NAME     0\n#define COLNAME_DECLTYPE 1\n#define COLNAME_DATABASE 2\n#define COLNAME_TABLE    3\n#define COLNAME_COLUMN   4\n#ifdef SQLITE_ENABLE_COLUMN_METADATA\n# define COLNAME_N        5      /* Number of COLNAME_xxx symbols */\n#else\n# ifdef SQLITE_OMIT_DECLTYPE\n#   define COLNAME_N      1      /* Store only the name */\n# else\n#   define COLNAME_N      2      /* Store the name and decltype */\n# endif\n#endif\n\n/*\n** The following macro converts a label returned by sqlite3VdbeMakeLabel()\n** into an index into the Parse.aLabel[] array that contains the resolved\n** address of that label.\n*/\n#define ADDR(X)  (~(X))\n\n/*\n** The makefile scans the vdbe.c source file and creates the \"opcodes.h\"\n** header file that defines a number for each opcode used by the VDBE.\n*/\n/************** Include opcodes.h in the middle of vdbe.h ********************/\n/************** Begin file opcodes.h *****************************************/\n/* Automatically generated.  Do not edit */\n/* See the tool/mkopcodeh.tcl script for details */\n#define OP_Savepoint       0\n#define OP_AutoCommit      1\n#define OP_Transaction     2\n#define OP_SorterNext      3 /* jump                                       */\n#define OP_Prev            4 /* jump                                       */\n#define OP_Next            5 /* jump                                       */\n#define OP_Checkpoint      6\n#define OP_JournalMode     7\n#define OP_Vacuum          8\n#define OP_VFilter         9 /* jump, synopsis: iplan=r[P3] zplan='P4'     */\n#define OP_VUpdate        10 /* synopsis: data=r[P3@P2]                    */\n#define OP_Goto           11 /* jump                                       */\n#define OP_Gosub          12 /* jump                                       */\n#define OP_InitCoroutine  13 /* jump                                       */\n#define OP_Yield          14 /* jump                                       */\n#define OP_MustBeInt      15 /* jump                                       */\n#define OP_Jump           16 /* jump                                       */\n#define OP_Once           17 /* jump                                       */\n#define OP_If             18 /* jump                                       */\n#define OP_Not            19 /* same as TK_NOT, synopsis: r[P2]= !r[P1]    */\n#define OP_IfNot          20 /* jump                                       */\n#define OP_IfNullRow      21 /* jump, synopsis: if P1.nullRow then r[P3]=NULL, goto P2 */\n#define OP_SeekLT         22 /* jump, synopsis: key=r[P3@P4]               */\n#define OP_SeekLE         23 /* jump, synopsis: key=r[P3@P4]               */\n#define OP_SeekGE         24 /* jump, synopsis: key=r[P3@P4]               */\n#define OP_SeekGT         25 /* jump, synopsis: key=r[P3@P4]               */\n#define OP_IfNoHope       26 /* jump, synopsis: key=r[P3@P4]               */\n#define OP_NoConflict     27 /* jump, synopsis: key=r[P3@P4]               */\n#define OP_NotFound       28 /* jump, synopsis: key=r[P3@P4]               */\n#define OP_Found          29 /* jump, synopsis: key=r[P3@P4]               */\n#define OP_SeekRowid      30 /* jump, synopsis: intkey=r[P3]               */\n#define OP_NotExists      31 /* jump, synopsis: intkey=r[P3]               */\n#define OP_Last           32 /* jump                                       */\n#define OP_IfSmaller      33 /* jump                                       */\n#define OP_SorterSort     34 /* jump                                       */\n#define OP_Sort           35 /* jump                                       */\n#define OP_Rewind         36 /* jump                                       */\n#define OP_IdxLE          37 /* jump, synopsis: key=r[P3@P4]               */\n#define OP_IdxGT          38 /* jump, synopsis: key=r[P3@P4]               */\n#define OP_IdxLT          39 /* jump, synopsis: key=r[P3@P4]               */\n#define OP_IdxGE          40 /* jump, synopsis: key=r[P3@P4]               */\n#define OP_RowSetRead     41 /* jump, synopsis: r[P3]=rowset(P1)           */\n#define OP_RowSetTest     42 /* jump, synopsis: if r[P3] in rowset(P1) goto P2 */\n#define OP_Or             43 /* same as TK_OR, synopsis: r[P3]=(r[P1] || r[P2]) */\n#define OP_And            44 /* same as TK_AND, synopsis: r[P3]=(r[P1] && r[P2]) */\n#define OP_Program        45 /* jump                                       */\n#define OP_FkIfZero       46 /* jump, synopsis: if fkctr[P1]==0 goto P2    */\n#define OP_IfPos          47 /* jump, synopsis: if r[P1]>0 then r[P1]-=P3, goto P2 */\n#define OP_IfNotZero      48 /* jump, synopsis: if r[P1]!=0 then r[P1]--, goto P2 */\n#define OP_DecrJumpZero   49 /* jump, synopsis: if (--r[P1])==0 goto P2    */\n#define OP_IsNull         50 /* jump, same as TK_ISNULL, synopsis: if r[P1]==NULL goto P2 */\n#define OP_NotNull        51 /* jump, same as TK_NOTNULL, synopsis: if r[P1]!=NULL goto P2 */\n#define OP_Ne             52 /* jump, same as TK_NE, synopsis: IF r[P3]!=r[P1] */\n#define OP_Eq             53 /* jump, same as TK_EQ, synopsis: IF r[P3]==r[P1] */\n#define OP_Gt             54 /* jump, same as TK_GT, synopsis: IF r[P3]>r[P1] */\n#define OP_Le             55 /* jump, same as TK_LE, synopsis: IF r[P3]<=r[P1] */\n#define OP_Lt             56 /* jump, same as TK_LT, synopsis: IF r[P3]<r[P1] */\n#define OP_Ge             57 /* jump, same as TK_GE, synopsis: IF r[P3]>=r[P1] */\n#define OP_ElseNotEq      58 /* jump, same as TK_ESCAPE                    */\n#define OP_IncrVacuum     59 /* jump                                       */\n#define OP_VNext          60 /* jump                                       */\n#define OP_Init           61 /* jump, synopsis: Start at P2                */\n#define OP_PureFunc0      62\n#define OP_Function0      63 /* synopsis: r[P3]=func(r[P2@P5])             */\n#define OP_PureFunc       64\n#define OP_Function       65 /* synopsis: r[P3]=func(r[P2@P5])             */\n#define OP_Return         66\n#define OP_EndCoroutine   67\n#define OP_HaltIfNull     68 /* synopsis: if r[P3]=null halt               */\n#define OP_Halt           69\n#define OP_Integer        70 /* synopsis: r[P2]=P1                         */\n#define OP_Int64          71 /* synopsis: r[P2]=P4                         */\n#define OP_String         72 /* synopsis: r[P2]='P4' (len=P1)              */\n#define OP_Null           73 /* synopsis: r[P2..P3]=NULL                   */\n#define OP_SoftNull       74 /* synopsis: r[P1]=NULL                       */\n#define OP_Blob           75 /* synopsis: r[P2]=P4 (len=P1)                */\n#define OP_Variable       76 /* synopsis: r[P2]=parameter(P1,P4)           */\n#define OP_Move           77 /* synopsis: r[P2@P3]=r[P1@P3]                */\n#define OP_Copy           78 /* synopsis: r[P2@P3+1]=r[P1@P3+1]            */\n#define OP_SCopy          79 /* synopsis: r[P2]=r[P1]                      */\n#define OP_IntCopy        80 /* synopsis: r[P2]=r[P1]                      */\n#define OP_ResultRow      81 /* synopsis: output=r[P1@P2]                  */\n#define OP_CollSeq        82\n#define OP_AddImm         83 /* synopsis: r[P1]=r[P1]+P2                   */\n#define OP_RealAffinity   84\n#define OP_Cast           85 /* synopsis: affinity(r[P1])                  */\n#define OP_Permutation    86\n#define OP_Compare        87 /* synopsis: r[P1@P3] <-> r[P2@P3]            */\n#define OP_IsTrue         88 /* synopsis: r[P2] = coalesce(r[P1]==TRUE,P3) ^ P4 */\n#define OP_Offset         89 /* synopsis: r[P3] = sqlite_offset(P1)        */\n#define OP_Column         90 /* synopsis: r[P3]=PX                         */\n#define OP_Affinity       91 /* synopsis: affinity(r[P1@P2])               */\n#define OP_BitAnd         92 /* same as TK_BITAND, synopsis: r[P3]=r[P1]&r[P2] */\n#define OP_BitOr          93 /* same as TK_BITOR, synopsis: r[P3]=r[P1]|r[P2] */\n#define OP_ShiftLeft      94 /* same as TK_LSHIFT, synopsis: r[P3]=r[P2]<<r[P1] */\n#define OP_ShiftRight     95 /* same as TK_RSHIFT, synopsis: r[P3]=r[P2]>>r[P1] */\n#define OP_Add            96 /* same as TK_PLUS, synopsis: r[P3]=r[P1]+r[P2] */\n#define OP_Subtract       97 /* same as TK_MINUS, synopsis: r[P3]=r[P2]-r[P1] */\n#define OP_Multiply       98 /* same as TK_STAR, synopsis: r[P3]=r[P1]*r[P2] */\n#define OP_Divide         99 /* same as TK_SLASH, synopsis: r[P3]=r[P2]/r[P1] */\n#define OP_Remainder     100 /* same as TK_REM, synopsis: r[P3]=r[P2]%r[P1] */\n#define OP_Concat        101 /* same as TK_CONCAT, synopsis: r[P3]=r[P2]+r[P1] */\n#define OP_MakeRecord    102 /* synopsis: r[P3]=mkrec(r[P1@P2])            */\n#define OP_BitNot        103 /* same as TK_BITNOT, synopsis: r[P2]= ~r[P1] */\n#define OP_Count         104 /* synopsis: r[P2]=count()                    */\n#define OP_ReadCookie    105\n#define OP_String8       106 /* same as TK_STRING, synopsis: r[P2]='P4'    */\n#define OP_SetCookie     107\n#define OP_ReopenIdx     108 /* synopsis: root=P2 iDb=P3                   */\n#define OP_OpenRead      109 /* synopsis: root=P2 iDb=P3                   */\n#define OP_OpenWrite     110 /* synopsis: root=P2 iDb=P3                   */\n#define OP_OpenDup       111\n#define OP_OpenAutoindex 112 /* synopsis: nColumn=P2                       */\n#define OP_OpenEphemeral 113 /* synopsis: nColumn=P2                       */\n#define OP_SorterOpen    114\n#define OP_SequenceTest  115 /* synopsis: if( cursor[P1].ctr++ ) pc = P2   */\n#define OP_OpenPseudo    116 /* synopsis: P3 columns in r[P2]              */\n#define OP_Close         117\n#define OP_ColumnsUsed   118\n#define OP_SeekHit       119 /* synopsis: seekHit=P2                       */\n#define OP_Sequence      120 /* synopsis: r[P2]=cursor[P1].ctr++           */\n#define OP_NewRowid      121 /* synopsis: r[P2]=rowid                      */\n#define OP_Insert        122 /* synopsis: intkey=r[P3] data=r[P2]          */\n#define OP_Delete        123\n#define OP_ResetCount    124\n#define OP_SorterCompare 125 /* synopsis: if key(P1)!=trim(r[P3],P4) goto P2 */\n#define OP_SorterData    126 /* synopsis: r[P2]=data                       */\n#define OP_RowData       127 /* synopsis: r[P2]=data                       */\n#define OP_Rowid         128 /* synopsis: r[P2]=rowid                      */\n#define OP_NullRow       129\n#define OP_SeekEnd       130\n#define OP_SorterInsert  131 /* synopsis: key=r[P2]                        */\n#define OP_IdxInsert     132 /* synopsis: key=r[P2]                        */\n#define OP_IdxDelete     133 /* synopsis: key=r[P2@P3]                     */\n#define OP_DeferredSeek  134 /* synopsis: Move P3 to P1.rowid if needed    */\n#define OP_IdxRowid      135 /* synopsis: r[P2]=rowid                      */\n#define OP_Destroy       136\n#define OP_Clear         137\n#define OP_ResetSorter   138\n#define OP_CreateBtree   139 /* synopsis: r[P2]=root iDb=P1 flags=P3       */\n#define OP_SqlExec       140\n#define OP_Real          141 /* same as TK_FLOAT, synopsis: r[P2]=P4       */\n#define OP_ParseSchema   142\n#define OP_LoadAnalysis  143\n#define OP_DropTable     144\n#define OP_DropIndex     145\n#define OP_DropTrigger   146\n#define OP_IntegrityCk   147\n#define OP_RowSetAdd     148 /* synopsis: rowset(P1)=r[P2]                 */\n#define OP_Param         149\n#define OP_FkCounter     150 /* synopsis: fkctr[P1]+=P2                    */\n#define OP_MemMax        151 /* synopsis: r[P1]=max(r[P1],r[P2])           */\n#define OP_OffsetLimit   152 /* synopsis: if r[P1]>0 then r[P2]=r[P1]+max(0,r[P3]) else r[P2]=(-1) */\n#define OP_AggInverse    153 /* synopsis: accum=r[P3] inverse(r[P2@P5])    */\n#define OP_AggStep       154 /* synopsis: accum=r[P3] step(r[P2@P5])       */\n#define OP_AggStep1      155 /* synopsis: accum=r[P3] step(r[P2@P5])       */\n#define OP_AggValue      156 /* synopsis: r[P3]=value N=P2                 */\n#define OP_AggFinal      157 /* synopsis: accum=r[P1] N=P2                 */\n#define OP_Expire        158\n#define OP_TableLock     159 /* synopsis: iDb=P1 root=P2 write=P3          */\n#define OP_VBegin        160\n#define OP_VCreate       161\n#define OP_VDestroy      162\n#define OP_VOpen         163\n#define OP_VColumn       164 /* synopsis: r[P3]=vcolumn(P2)                */\n#define OP_VRename       165\n#define OP_Pagecount     166\n#define OP_MaxPgcnt      167\n#define OP_Trace         168\n#define OP_CursorHint    169\n#define OP_Noop          170\n#define OP_Explain       171\n#define OP_Abortable     172\n\n/* Properties such as \"out2\" or \"jump\" that are specified in\n** comments following the \"case\" for each opcode in the vdbe.c\n** are encoded into bitvectors as follows:\n*/\n#define OPFLG_JUMP        0x01  /* jump:  P2 holds jmp target */\n#define OPFLG_IN1         0x02  /* in1:   P1 is an input */\n#define OPFLG_IN2         0x04  /* in2:   P2 is an input */\n#define OPFLG_IN3         0x08  /* in3:   P3 is an input */\n#define OPFLG_OUT2        0x10  /* out2:  P2 is an output */\n#define OPFLG_OUT3        0x20  /* out3:  P3 is an output */\n#define OPFLG_INITIALIZER {\\\n/*   0 */ 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x10,\\\n/*   8 */ 0x00, 0x01, 0x00, 0x01, 0x01, 0x01, 0x03, 0x03,\\\n/*  16 */ 0x01, 0x01, 0x03, 0x12, 0x03, 0x01, 0x09, 0x09,\\\n/*  24 */ 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09,\\\n/*  32 */ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,\\\n/*  40 */ 0x01, 0x23, 0x0b, 0x26, 0x26, 0x01, 0x01, 0x03,\\\n/*  48 */ 0x03, 0x03, 0x03, 0x03, 0x0b, 0x0b, 0x0b, 0x0b,\\\n/*  56 */ 0x0b, 0x0b, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00,\\\n/*  64 */ 0x00, 0x00, 0x02, 0x02, 0x08, 0x00, 0x10, 0x10,\\\n/*  72 */ 0x10, 0x10, 0x00, 0x10, 0x10, 0x00, 0x00, 0x10,\\\n/*  80 */ 0x10, 0x00, 0x00, 0x02, 0x02, 0x02, 0x00, 0x00,\\\n/*  88 */ 0x12, 0x20, 0x00, 0x00, 0x26, 0x26, 0x26, 0x26,\\\n/*  96 */ 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x00, 0x12,\\\n/* 104 */ 0x10, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00,\\\n/* 112 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\\\n/* 120 */ 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\\\n/* 128 */ 0x10, 0x00, 0x00, 0x04, 0x04, 0x00, 0x00, 0x10,\\\n/* 136 */ 0x10, 0x00, 0x00, 0x10, 0x00, 0x10, 0x00, 0x00,\\\n/* 144 */ 0x00, 0x00, 0x00, 0x00, 0x06, 0x10, 0x00, 0x04,\\\n/* 152 */ 0x1a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\\\n/* 160 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x10,\\\n/* 168 */ 0x00, 0x00, 0x00, 0x00, 0x00,}\n\n/* The sqlite3P2Values() routine is able to run faster if it knows\n** the value of the largest JUMP opcode.  The smaller the maximum\n** JUMP opcode the better, so the mkopcodeh.tcl script that\n** generated this include file strives to group all JUMP opcodes\n** together near the beginning of the list.\n*/\n#define SQLITE_MX_JUMP_OPCODE  61  /* Maximum JUMP opcode */\n\n/************** End of opcodes.h *********************************************/\n/************** Continuing where we left off in vdbe.h ***********************/\n\n/*\n** Additional non-public SQLITE_PREPARE_* flags\n*/\n#define SQLITE_PREPARE_SAVESQL  0x80  /* Preserve SQL text */\n#define SQLITE_PREPARE_MASK     0x0f  /* Mask of public flags */\n\n/*\n** Prototypes for the VDBE interface.  See comments on the implementation\n** for a description of what each of these routines does.\n*/\nSQLITE_PRIVATE Vdbe *sqlite3VdbeCreate(Parse*);\nSQLITE_PRIVATE int sqlite3VdbeAddOp0(Vdbe*,int);\nSQLITE_PRIVATE int sqlite3VdbeAddOp1(Vdbe*,int,int);\nSQLITE_PRIVATE int sqlite3VdbeAddOp2(Vdbe*,int,int,int);\nSQLITE_PRIVATE int sqlite3VdbeGoto(Vdbe*,int);\nSQLITE_PRIVATE int sqlite3VdbeLoadString(Vdbe*,int,const char*);\nSQLITE_PRIVATE void sqlite3VdbeMultiLoad(Vdbe*,int,const char*,...);\nSQLITE_PRIVATE int sqlite3VdbeAddOp3(Vdbe*,int,int,int,int);\nSQLITE_PRIVATE int sqlite3VdbeAddOp4(Vdbe*,int,int,int,int,const char *zP4,int);\nSQLITE_PRIVATE int sqlite3VdbeAddOp4Dup8(Vdbe*,int,int,int,int,const u8*,int);\nSQLITE_PRIVATE int sqlite3VdbeAddOp4Int(Vdbe*,int,int,int,int,int);\nSQLITE_PRIVATE void sqlite3VdbeEndCoroutine(Vdbe*,int);\n#if defined(SQLITE_DEBUG) && !defined(SQLITE_TEST_REALLOC_STRESS)\nSQLITE_PRIVATE   void sqlite3VdbeVerifyNoMallocRequired(Vdbe *p, int N);\nSQLITE_PRIVATE   void sqlite3VdbeVerifyNoResultRow(Vdbe *p);\n#else\n# define sqlite3VdbeVerifyNoMallocRequired(A,B)\n# define sqlite3VdbeVerifyNoResultRow(A)\n#endif\n#if defined(SQLITE_DEBUG)\nSQLITE_PRIVATE   void sqlite3VdbeVerifyAbortable(Vdbe *p, int);\n#else\n# define sqlite3VdbeVerifyAbortable(A,B)\n#endif\nSQLITE_PRIVATE VdbeOp *sqlite3VdbeAddOpList(Vdbe*, int nOp, VdbeOpList const *aOp,int iLineno);\n#ifndef SQLITE_OMIT_EXPLAIN\nSQLITE_PRIVATE   void sqlite3VdbeExplain(Parse*,u8,const char*,...);\nSQLITE_PRIVATE   void sqlite3VdbeExplainPop(Parse*);\nSQLITE_PRIVATE   int sqlite3VdbeExplainParent(Parse*);\n# define ExplainQueryPlan(P)        sqlite3VdbeExplain P\n# define ExplainQueryPlanPop(P)     sqlite3VdbeExplainPop(P)\n# define ExplainQueryPlanParent(P)  sqlite3VdbeExplainParent(P)\n#else\n# define ExplainQueryPlan(P)\n# define ExplainQueryPlanPop(P)\n# define ExplainQueryPlanParent(P) 0\n# define sqlite3ExplainBreakpoint(A,B) /*no-op*/\n#endif\n#if defined(SQLITE_DEBUG) && !defined(SQLITE_OMIT_EXPLAIN)\nSQLITE_PRIVATE   void sqlite3ExplainBreakpoint(const char*,const char*);\n#else\n# define sqlite3ExplainBreakpoint(A,B) /*no-op*/\n#endif\nSQLITE_PRIVATE void sqlite3VdbeAddParseSchemaOp(Vdbe*,int,char*);\nSQLITE_PRIVATE void sqlite3VdbeChangeOpcode(Vdbe*, u32 addr, u8);\nSQLITE_PRIVATE void sqlite3VdbeChangeP1(Vdbe*, u32 addr, int P1);\nSQLITE_PRIVATE void sqlite3VdbeChangeP2(Vdbe*, u32 addr, int P2);\nSQLITE_PRIVATE void sqlite3VdbeChangeP3(Vdbe*, u32 addr, int P3);\nSQLITE_PRIVATE void sqlite3VdbeChangeP5(Vdbe*, u16 P5);\nSQLITE_PRIVATE void sqlite3VdbeJumpHere(Vdbe*, int addr);\nSQLITE_PRIVATE int sqlite3VdbeChangeToNoop(Vdbe*, int addr);\nSQLITE_PRIVATE int sqlite3VdbeDeletePriorOpcode(Vdbe*, u8 op);\nSQLITE_PRIVATE void sqlite3VdbeChangeP4(Vdbe*, int addr, const char *zP4, int N);\nSQLITE_PRIVATE void sqlite3VdbeAppendP4(Vdbe*, void *pP4, int p4type);\nSQLITE_PRIVATE void sqlite3VdbeSetP4KeyInfo(Parse*, Index*);\nSQLITE_PRIVATE void sqlite3VdbeUsesBtree(Vdbe*, int);\nSQLITE_PRIVATE VdbeOp *sqlite3VdbeGetOp(Vdbe*, int);\nSQLITE_PRIVATE int sqlite3VdbeMakeLabel(Parse*);\nSQLITE_PRIVATE void sqlite3VdbeRunOnlyOnce(Vdbe*);\nSQLITE_PRIVATE void sqlite3VdbeReusable(Vdbe*);\nSQLITE_PRIVATE void sqlite3VdbeDelete(Vdbe*);\nSQLITE_PRIVATE void sqlite3VdbeClearObject(sqlite3*,Vdbe*);\nSQLITE_PRIVATE void sqlite3VdbeMakeReady(Vdbe*,Parse*);\nSQLITE_PRIVATE int sqlite3VdbeFinalize(Vdbe*);\nSQLITE_PRIVATE void sqlite3VdbeResolveLabel(Vdbe*, int);\nSQLITE_PRIVATE int sqlite3VdbeCurrentAddr(Vdbe*);\n#ifdef SQLITE_DEBUG\nSQLITE_PRIVATE   int sqlite3VdbeAssertMayAbort(Vdbe *, int);\n#endif\nSQLITE_PRIVATE void sqlite3VdbeResetStepResult(Vdbe*);\nSQLITE_PRIVATE void sqlite3VdbeRewind(Vdbe*);\nSQLITE_PRIVATE int sqlite3VdbeReset(Vdbe*);\nSQLITE_PRIVATE void sqlite3VdbeSetNumCols(Vdbe*,int);\nSQLITE_PRIVATE int sqlite3VdbeSetColName(Vdbe*, int, int, const char *, void(*)(void*));\nSQLITE_PRIVATE void sqlite3VdbeCountChanges(Vdbe*);\nSQLITE_PRIVATE sqlite3 *sqlite3VdbeDb(Vdbe*);\nSQLITE_PRIVATE u8 sqlite3VdbePrepareFlags(Vdbe*);\nSQLITE_PRIVATE void sqlite3VdbeSetSql(Vdbe*, const char *z, int n, u8);\n#ifdef SQLITE_ENABLE_NORMALIZE\nSQLITE_PRIVATE void sqlite3VdbeAddDblquoteStr(sqlite3*,Vdbe*,const char*);\nSQLITE_PRIVATE int sqlite3VdbeUsesDoubleQuotedString(Vdbe*,const char*);\n#endif\nSQLITE_PRIVATE void sqlite3VdbeSwap(Vdbe*,Vdbe*);\nSQLITE_PRIVATE VdbeOp *sqlite3VdbeTakeOpArray(Vdbe*, int*, int*);\nSQLITE_PRIVATE sqlite3_value *sqlite3VdbeGetBoundValue(Vdbe*, int, u8);\nSQLITE_PRIVATE void sqlite3VdbeSetVarmask(Vdbe*, int);\n#ifndef SQLITE_OMIT_TRACE\nSQLITE_PRIVATE   char *sqlite3VdbeExpandSql(Vdbe*, const char*);\n#endif\nSQLITE_PRIVATE int sqlite3MemCompare(const Mem*, const Mem*, const CollSeq*);\nSQLITE_PRIVATE int sqlite3BlobCompare(const Mem*, const Mem*);\n\nSQLITE_PRIVATE void sqlite3VdbeRecordUnpack(KeyInfo*,int,const void*,UnpackedRecord*);\nSQLITE_PRIVATE int sqlite3VdbeRecordCompare(int,const void*,UnpackedRecord*);\nSQLITE_PRIVATE int sqlite3VdbeRecordCompareWithSkip(int, const void *, UnpackedRecord *, int);\nSQLITE_PRIVATE UnpackedRecord *sqlite3VdbeAllocUnpackedRecord(KeyInfo*);\n\ntypedef int (*RecordCompare)(int,const void*,UnpackedRecord*);\nSQLITE_PRIVATE RecordCompare sqlite3VdbeFindCompare(UnpackedRecord*);\n\n#ifndef SQLITE_OMIT_TRIGGER\nSQLITE_PRIVATE void sqlite3VdbeLinkSubProgram(Vdbe *, SubProgram *);\n#endif\n\nSQLITE_PRIVATE int sqlite3NotPureFunc(sqlite3_context*);\n\n/* Use SQLITE_ENABLE_COMMENTS to enable generation of extra comments on\n** each VDBE opcode.\n**\n** Use the SQLITE_ENABLE_MODULE_COMMENTS macro to see some extra no-op\n** comments in VDBE programs that show key decision points in the code\n** generator.\n*/\n#ifdef SQLITE_ENABLE_EXPLAIN_COMMENTS\nSQLITE_PRIVATE   void sqlite3VdbeComment(Vdbe*, const char*, ...);\n# define VdbeComment(X)  sqlite3VdbeComment X\nSQLITE_PRIVATE   void sqlite3VdbeNoopComment(Vdbe*, const char*, ...);\n# define VdbeNoopComment(X)  sqlite3VdbeNoopComment X\n# ifdef SQLITE_ENABLE_MODULE_COMMENTS\n#   define VdbeModuleComment(X)  sqlite3VdbeNoopComment X\n# else\n#   define VdbeModuleComment(X)\n# endif\n#else\n# define VdbeComment(X)\n# define VdbeNoopComment(X)\n# define VdbeModuleComment(X)\n#endif\n\n/*\n** The VdbeCoverage macros are used to set a coverage testing point\n** for VDBE branch instructions.  The coverage testing points are line\n** numbers in the sqlite3.c source file.  VDBE branch coverage testing\n** only works with an amalagmation build.  That's ok since a VDBE branch\n** coverage build designed for testing the test suite only.  No application\n** should ever ship with VDBE branch coverage measuring turned on.\n**\n**    VdbeCoverage(v)                  // Mark the previously coded instruction\n**                                     // as a branch\n**\n**    VdbeCoverageIf(v, conditional)   // Mark previous if conditional true\n**\n**    VdbeCoverageAlwaysTaken(v)       // Previous branch is always taken\n**\n**    VdbeCoverageNeverTaken(v)        // Previous branch is never taken\n**\n**    VdbeCoverageNeverNull(v)         // Previous three-way branch is only\n**                                     // taken on the first two ways.  The\n**                                     // NULL option is not possible\n**\n**    VdbeCoverageEqNe(v)              // Previous OP_Jump is only interested\n**                                     // in distingishing equal and not-equal.\n**\n** Every VDBE branch operation must be tagged with one of the macros above.\n** If not, then when \"make test\" is run with -DSQLITE_VDBE_COVERAGE and\n** -DSQLITE_DEBUG then an ALWAYS() will fail in the vdbeTakeBranch()\n** routine in vdbe.c, alerting the developer to the missed tag.\n**\n** During testing, the test application will invoke\n** sqlite3_test_control(SQLITE_TESTCTRL_VDBE_COVERAGE,...) to set a callback\n** routine that is invoked as each bytecode branch is taken.  The callback\n** contains the sqlite3.c source line number ov the VdbeCoverage macro and\n** flags to indicate whether or not the branch was taken.  The test application\n** is responsible for keeping track of this and reporting byte-code branches\n** that are never taken.\n**\n** See the VdbeBranchTaken() macro and vdbeTakeBranch() function in the\n** vdbe.c source file for additional information.\n*/\n#ifdef SQLITE_VDBE_COVERAGE\nSQLITE_PRIVATE   void sqlite3VdbeSetLineNumber(Vdbe*,int);\n# define VdbeCoverage(v) sqlite3VdbeSetLineNumber(v,__LINE__)\n# define VdbeCoverageIf(v,x) if(x)sqlite3VdbeSetLineNumber(v,__LINE__)\n# define VdbeCoverageAlwaysTaken(v) \\\n         sqlite3VdbeSetLineNumber(v,__LINE__|0x5000000);\n# define VdbeCoverageNeverTaken(v) \\\n         sqlite3VdbeSetLineNumber(v,__LINE__|0x6000000);\n# define VdbeCoverageNeverNull(v) \\\n         sqlite3VdbeSetLineNumber(v,__LINE__|0x4000000);\n# define VdbeCoverageNeverNullIf(v,x) \\\n         if(x)sqlite3VdbeSetLineNumber(v,__LINE__|0x4000000);\n# define VdbeCoverageEqNe(v) \\\n         sqlite3VdbeSetLineNumber(v,__LINE__|0x8000000);\n# define VDBE_OFFSET_LINENO(x) (__LINE__+x)\n#else\n# define VdbeCoverage(v)\n# define VdbeCoverageIf(v,x)\n# define VdbeCoverageAlwaysTaken(v)\n# define VdbeCoverageNeverTaken(v)\n# define VdbeCoverageNeverNull(v)\n# define VdbeCoverageNeverNullIf(v,x)\n# define VdbeCoverageEqNe(v)\n# define VDBE_OFFSET_LINENO(x) 0\n#endif\n\n#ifdef SQLITE_ENABLE_STMT_SCANSTATUS\nSQLITE_PRIVATE void sqlite3VdbeScanStatus(Vdbe*, int, int, int, LogEst, const char*);\n#else\n# define sqlite3VdbeScanStatus(a,b,c,d,e)\n#endif\n\n#if defined(SQLITE_DEBUG) || defined(VDBE_PROFILE)\nSQLITE_PRIVATE void sqlite3VdbePrintOp(FILE*, int, VdbeOp*);\n#endif\n\n#endif /* SQLITE_VDBE_H */\n\n/************** End of vdbe.h ************************************************/\n/************** Continuing where we left off in sqliteInt.h ******************/\n/************** Include pager.h in the middle of sqliteInt.h *****************/\n/************** Begin file pager.h *******************************************/\n/*\n** 2001 September 15\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This header file defines the interface that the sqlite page cache\n** subsystem.  The page cache subsystem reads and writes a file a page\n** at a time and provides a journal for rollback.\n*/\n\n#ifndef SQLITE_PAGER_H\n#define SQLITE_PAGER_H\n\n/*\n** Default maximum size for persistent journal files. A negative \n** value means no limit. This value may be overridden using the \n** sqlite3PagerJournalSizeLimit() API. See also \"PRAGMA journal_size_limit\".\n*/\n#ifndef SQLITE_DEFAULT_JOURNAL_SIZE_LIMIT\n  #define SQLITE_DEFAULT_JOURNAL_SIZE_LIMIT -1\n#endif\n\n/*\n** The type used to represent a page number.  The first page in a file\n** is called page 1.  0 is used to represent \"not a page\".\n*/\ntypedef u32 Pgno;\n\n/*\n** Each open file is managed by a separate instance of the \"Pager\" structure.\n*/\ntypedef struct Pager Pager;\n\n/*\n** Handle type for pages.\n*/\ntypedef struct PgHdr DbPage;\n\n/*\n** Page number PAGER_MJ_PGNO is never used in an SQLite database (it is\n** reserved for working around a windows/posix incompatibility). It is\n** used in the journal to signify that the remainder of the journal file \n** is devoted to storing a master journal name - there are no more pages to\n** roll back. See comments for function writeMasterJournal() in pager.c \n** for details.\n*/\n#define PAGER_MJ_PGNO(x) ((Pgno)((PENDING_BYTE/((x)->pageSize))+1))\n\n/*\n** Allowed values for the flags parameter to sqlite3PagerOpen().\n**\n** NOTE: These values must match the corresponding BTREE_ values in btree.h.\n*/\n#define PAGER_OMIT_JOURNAL  0x0001    /* Do not use a rollback journal */\n#define PAGER_MEMORY        0x0002    /* In-memory database */\n\n/*\n** Valid values for the second argument to sqlite3PagerLockingMode().\n*/\n#define PAGER_LOCKINGMODE_QUERY      -1\n#define PAGER_LOCKINGMODE_NORMAL      0\n#define PAGER_LOCKINGMODE_EXCLUSIVE   1\n\n/*\n** Numeric constants that encode the journalmode.\n**\n** The numeric values encoded here (other than PAGER_JOURNALMODE_QUERY)\n** are exposed in the API via the \"PRAGMA journal_mode\" command and\n** therefore cannot be changed without a compatibility break.\n*/\n#define PAGER_JOURNALMODE_QUERY     (-1)  /* Query the value of journalmode */\n#define PAGER_JOURNALMODE_DELETE      0   /* Commit by deleting journal file */\n#define PAGER_JOURNALMODE_PERSIST     1   /* Commit by zeroing journal header */\n#define PAGER_JOURNALMODE_OFF         2   /* Journal omitted.  */\n#define PAGER_JOURNALMODE_TRUNCATE    3   /* Commit by truncating journal */\n#define PAGER_JOURNALMODE_MEMORY      4   /* In-memory journal file */\n#define PAGER_JOURNALMODE_WAL         5   /* Use write-ahead logging */\n\n/*\n** Flags that make up the mask passed to sqlite3PagerGet().\n*/\n#define PAGER_GET_NOCONTENT     0x01  /* Do not load data from disk */\n#define PAGER_GET_READONLY      0x02  /* Read-only page is acceptable */\n\n/*\n** Flags for sqlite3PagerSetFlags()\n**\n** Value constraints (enforced via assert()):\n**    PAGER_FULLFSYNC      == SQLITE_FullFSync\n**    PAGER_CKPT_FULLFSYNC == SQLITE_CkptFullFSync\n**    PAGER_CACHE_SPILL    == SQLITE_CacheSpill\n*/\n#define PAGER_SYNCHRONOUS_OFF       0x01  /* PRAGMA synchronous=OFF */\n#define PAGER_SYNCHRONOUS_NORMAL    0x02  /* PRAGMA synchronous=NORMAL */\n#define PAGER_SYNCHRONOUS_FULL      0x03  /* PRAGMA synchronous=FULL */\n#define PAGER_SYNCHRONOUS_EXTRA     0x04  /* PRAGMA synchronous=EXTRA */\n#define PAGER_SYNCHRONOUS_MASK      0x07  /* Mask for four values above */\n#define PAGER_FULLFSYNC             0x08  /* PRAGMA fullfsync=ON */\n#define PAGER_CKPT_FULLFSYNC        0x10  /* PRAGMA checkpoint_fullfsync=ON */\n#define PAGER_CACHESPILL            0x20  /* PRAGMA cache_spill=ON */\n#define PAGER_FLAGS_MASK            0x38  /* All above except SYNCHRONOUS */\n\n/*\n** The remainder of this file contains the declarations of the functions\n** that make up the Pager sub-system API. See source code comments for \n** a detailed description of each routine.\n*/\n\n/* Open and close a Pager connection. */ \nSQLITE_PRIVATE int sqlite3PagerOpen(\n  sqlite3_vfs*,\n  Pager **ppPager,\n  const char*,\n  int,\n  int,\n  int,\n  void(*)(DbPage*)\n);\nSQLITE_PRIVATE int sqlite3PagerClose(Pager *pPager, sqlite3*);\nSQLITE_PRIVATE int sqlite3PagerReadFileheader(Pager*, int, unsigned char*);\n\n/* Functions used to configure a Pager object. */\nSQLITE_PRIVATE void sqlite3PagerSetBusyHandler(Pager*, int(*)(void *), void *);\nSQLITE_PRIVATE int sqlite3PagerSetPagesize(Pager*, u32*, int);\n#ifdef SQLITE_HAS_CODEC\nSQLITE_PRIVATE void sqlite3PagerAlignReserve(Pager*,Pager*);\n#endif\nSQLITE_PRIVATE int sqlite3PagerMaxPageCount(Pager*, int);\nSQLITE_PRIVATE void sqlite3PagerSetCachesize(Pager*, int);\nSQLITE_PRIVATE int sqlite3PagerSetSpillsize(Pager*, int);\nSQLITE_PRIVATE void sqlite3PagerSetMmapLimit(Pager *, sqlite3_int64);\nSQLITE_PRIVATE void sqlite3PagerShrink(Pager*);\nSQLITE_PRIVATE void sqlite3PagerSetFlags(Pager*,unsigned);\nSQLITE_PRIVATE int sqlite3PagerLockingMode(Pager *, int);\nSQLITE_PRIVATE int sqlite3PagerSetJournalMode(Pager *, int);\nSQLITE_PRIVATE int sqlite3PagerGetJournalMode(Pager*);\nSQLITE_PRIVATE int sqlite3PagerOkToChangeJournalMode(Pager*);\nSQLITE_PRIVATE i64 sqlite3PagerJournalSizeLimit(Pager *, i64);\nSQLITE_PRIVATE sqlite3_backup **sqlite3PagerBackupPtr(Pager*);\nSQLITE_PRIVATE int sqlite3PagerFlush(Pager*);\n\n/* Functions used to obtain and release page references. */ \nSQLITE_PRIVATE int sqlite3PagerGet(Pager *pPager, Pgno pgno, DbPage **ppPage, int clrFlag);\nSQLITE_PRIVATE DbPage *sqlite3PagerLookup(Pager *pPager, Pgno pgno);\nSQLITE_PRIVATE void sqlite3PagerRef(DbPage*);\nSQLITE_PRIVATE void sqlite3PagerUnref(DbPage*);\nSQLITE_PRIVATE void sqlite3PagerUnrefNotNull(DbPage*);\nSQLITE_PRIVATE void sqlite3PagerUnrefPageOne(DbPage*);\n\n/* Operations on page references. */\nSQLITE_PRIVATE int sqlite3PagerWrite(DbPage*);\nSQLITE_PRIVATE void sqlite3PagerDontWrite(DbPage*);\nSQLITE_PRIVATE int sqlite3PagerMovepage(Pager*,DbPage*,Pgno,int);\nSQLITE_PRIVATE int sqlite3PagerPageRefcount(DbPage*);\nSQLITE_PRIVATE void *sqlite3PagerGetData(DbPage *); \nSQLITE_PRIVATE void *sqlite3PagerGetExtra(DbPage *); \n\n/* Functions used to manage pager transactions and savepoints. */\nSQLITE_PRIVATE void sqlite3PagerPagecount(Pager*, int*);\nSQLITE_PRIVATE int sqlite3PagerBegin(Pager*, int exFlag, int);\nSQLITE_PRIVATE int sqlite3PagerCommitPhaseOne(Pager*,const char *zMaster, int);\nSQLITE_PRIVATE int sqlite3PagerExclusiveLock(Pager*);\nSQLITE_PRIVATE int sqlite3PagerSync(Pager *pPager, const char *zMaster);\nSQLITE_PRIVATE int sqlite3PagerCommitPhaseTwo(Pager*);\nSQLITE_PRIVATE int sqlite3PagerRollback(Pager*);\nSQLITE_PRIVATE int sqlite3PagerOpenSavepoint(Pager *pPager, int n);\nSQLITE_PRIVATE int sqlite3PagerSavepoint(Pager *pPager, int op, int iSavepoint);\nSQLITE_PRIVATE int sqlite3PagerSharedLock(Pager *pPager);\n\n#ifndef SQLITE_OMIT_WAL\nSQLITE_PRIVATE   int sqlite3PagerCheckpoint(Pager *pPager, sqlite3*, int, int*, int*);\nSQLITE_PRIVATE   int sqlite3PagerWalSupported(Pager *pPager);\nSQLITE_PRIVATE   int sqlite3PagerWalCallback(Pager *pPager);\nSQLITE_PRIVATE   int sqlite3PagerOpenWal(Pager *pPager, int *pisOpen);\nSQLITE_PRIVATE   int sqlite3PagerCloseWal(Pager *pPager, sqlite3*);\n\n# ifdef SQLITE_ENABLE_SNAPSHOT\nSQLITE_PRIVATE   int sqlite3PagerSnapshotGet(Pager *pPager, sqlite3_snapshot **ppSnapshot);\nSQLITE_PRIVATE   int sqlite3PagerSnapshotOpen(Pager *pPager, sqlite3_snapshot *pSnapshot);\nSQLITE_PRIVATE   int sqlite3PagerSnapshotRecover(Pager *pPager);\nSQLITE_PRIVATE   int sqlite3PagerSnapshotCheck(Pager *pPager, sqlite3_snapshot *pSnapshot);\nSQLITE_PRIVATE   void sqlite3PagerSnapshotUnlock(Pager *pPager);\n# endif\n#endif\n\n#ifdef SQLITE_DIRECT_OVERFLOW_READ\nSQLITE_PRIVATE   int sqlite3PagerDirectReadOk(Pager *pPager, Pgno pgno);\n#endif\n\n#ifdef SQLITE_ENABLE_ZIPVFS\nSQLITE_PRIVATE   int sqlite3PagerWalFramesize(Pager *pPager);\n#endif\n\n/* Functions used to query pager state and configuration. */\nSQLITE_PRIVATE u8 sqlite3PagerIsreadonly(Pager*);\nSQLITE_PRIVATE u32 sqlite3PagerDataVersion(Pager*);\n#ifdef SQLITE_DEBUG\nSQLITE_PRIVATE   int sqlite3PagerRefcount(Pager*);\n#endif\nSQLITE_PRIVATE int sqlite3PagerMemUsed(Pager*);\nSQLITE_PRIVATE const char *sqlite3PagerFilename(Pager*, int);\nSQLITE_PRIVATE sqlite3_vfs *sqlite3PagerVfs(Pager*);\nSQLITE_PRIVATE sqlite3_file *sqlite3PagerFile(Pager*);\nSQLITE_PRIVATE sqlite3_file *sqlite3PagerJrnlFile(Pager*);\nSQLITE_PRIVATE const char *sqlite3PagerJournalname(Pager*);\nSQLITE_PRIVATE void *sqlite3PagerTempSpace(Pager*);\nSQLITE_PRIVATE int sqlite3PagerIsMemdb(Pager*);\nSQLITE_PRIVATE void sqlite3PagerCacheStat(Pager *, int, int, int *);\nSQLITE_PRIVATE void sqlite3PagerClearCache(Pager*);\nSQLITE_PRIVATE int sqlite3SectorSize(sqlite3_file *);\n#ifdef SQLITE_ENABLE_SETLK_TIMEOUT\nSQLITE_PRIVATE void sqlite3PagerResetLockTimeout(Pager *pPager);\n#else\n# define sqlite3PagerResetLockTimeout(X)\n#endif\n\n/* Functions used to truncate the database file. */\nSQLITE_PRIVATE void sqlite3PagerTruncateImage(Pager*,Pgno);\n\nSQLITE_PRIVATE void sqlite3PagerRekey(DbPage*, Pgno, u16);\n\n#if defined(SQLITE_HAS_CODEC) && !defined(SQLITE_OMIT_WAL)\nSQLITE_PRIVATE void *sqlite3PagerCodec(DbPage *);\n#endif\n\n/* Functions to support testing and debugging. */\n#if !defined(NDEBUG) || defined(SQLITE_TEST)\nSQLITE_PRIVATE   Pgno sqlite3PagerPagenumber(DbPage*);\nSQLITE_PRIVATE   int sqlite3PagerIswriteable(DbPage*);\n#endif\n#ifdef SQLITE_TEST\nSQLITE_PRIVATE   int *sqlite3PagerStats(Pager*);\nSQLITE_PRIVATE   void sqlite3PagerRefdump(Pager*);\n  void disable_simulated_io_errors(void);\n  void enable_simulated_io_errors(void);\n#else\n# define disable_simulated_io_errors()\n# define enable_simulated_io_errors()\n#endif\n\n#endif /* SQLITE_PAGER_H */\n\n/************** End of pager.h ***********************************************/\n/************** Continuing where we left off in sqliteInt.h ******************/\n/************** Include pcache.h in the middle of sqliteInt.h ****************/\n/************** Begin file pcache.h ******************************************/\n/*\n** 2008 August 05\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This header file defines the interface that the sqlite page cache\n** subsystem. \n*/\n\n#ifndef _PCACHE_H_\n\ntypedef struct PgHdr PgHdr;\ntypedef struct PCache PCache;\n\n/*\n** Every page in the cache is controlled by an instance of the following\n** structure.\n*/\nstruct PgHdr {\n  sqlite3_pcache_page *pPage;    /* Pcache object page handle */\n  void *pData;                   /* Page data */\n  void *pExtra;                  /* Extra content */\n  PCache *pCache;                /* PRIVATE: Cache that owns this page */\n  PgHdr *pDirty;                 /* Transient list of dirty sorted by pgno */\n  Pager *pPager;                 /* The pager this page is part of */\n  Pgno pgno;                     /* Page number for this page */\n#ifdef SQLITE_CHECK_PAGES\n  u32 pageHash;                  /* Hash of page content */\n#endif\n  u16 flags;                     /* PGHDR flags defined below */\n\n  /**********************************************************************\n  ** Elements above, except pCache, are public.  All that follow are \n  ** private to pcache.c and should not be accessed by other modules.\n  ** pCache is grouped with the public elements for efficiency.\n  */\n  i16 nRef;                      /* Number of users of this page */\n  PgHdr *pDirtyNext;             /* Next element in list of dirty pages */\n  PgHdr *pDirtyPrev;             /* Previous element in list of dirty pages */\n                          /* NB: pDirtyNext and pDirtyPrev are undefined if the\n                          ** PgHdr object is not dirty */\n};\n\n/* Bit values for PgHdr.flags */\n#define PGHDR_CLEAN           0x001  /* Page not on the PCache.pDirty list */\n#define PGHDR_DIRTY           0x002  /* Page is on the PCache.pDirty list */\n#define PGHDR_WRITEABLE       0x004  /* Journaled and ready to modify */\n#define PGHDR_NEED_SYNC       0x008  /* Fsync the rollback journal before\n                                     ** writing this page to the database */\n#define PGHDR_DONT_WRITE      0x010  /* Do not write content to disk */\n#define PGHDR_MMAP            0x020  /* This is an mmap page object */\n\n#define PGHDR_WAL_APPEND      0x040  /* Appended to wal file */\n\n/* Initialize and shutdown the page cache subsystem */\nSQLITE_PRIVATE int sqlite3PcacheInitialize(void);\nSQLITE_PRIVATE void sqlite3PcacheShutdown(void);\n\n/* Page cache buffer management:\n** These routines implement SQLITE_CONFIG_PAGECACHE.\n*/\nSQLITE_PRIVATE void sqlite3PCacheBufferSetup(void *, int sz, int n);\n\n/* Create a new pager cache.\n** Under memory stress, invoke xStress to try to make pages clean.\n** Only clean and unpinned pages can be reclaimed.\n*/\nSQLITE_PRIVATE int sqlite3PcacheOpen(\n  int szPage,                    /* Size of every page */\n  int szExtra,                   /* Extra space associated with each page */\n  int bPurgeable,                /* True if pages are on backing store */\n  int (*xStress)(void*, PgHdr*), /* Call to try to make pages clean */\n  void *pStress,                 /* Argument to xStress */\n  PCache *pToInit                /* Preallocated space for the PCache */\n);\n\n/* Modify the page-size after the cache has been created. */\nSQLITE_PRIVATE int sqlite3PcacheSetPageSize(PCache *, int);\n\n/* Return the size in bytes of a PCache object.  Used to preallocate\n** storage space.\n*/\nSQLITE_PRIVATE int sqlite3PcacheSize(void);\n\n/* One release per successful fetch.  Page is pinned until released.\n** Reference counted. \n*/\nSQLITE_PRIVATE sqlite3_pcache_page *sqlite3PcacheFetch(PCache*, Pgno, int createFlag);\nSQLITE_PRIVATE int sqlite3PcacheFetchStress(PCache*, Pgno, sqlite3_pcache_page**);\nSQLITE_PRIVATE PgHdr *sqlite3PcacheFetchFinish(PCache*, Pgno, sqlite3_pcache_page *pPage);\nSQLITE_PRIVATE void sqlite3PcacheRelease(PgHdr*);\n\nSQLITE_PRIVATE void sqlite3PcacheDrop(PgHdr*);         /* Remove page from cache */\nSQLITE_PRIVATE void sqlite3PcacheMakeDirty(PgHdr*);    /* Make sure page is marked dirty */\nSQLITE_PRIVATE void sqlite3PcacheMakeClean(PgHdr*);    /* Mark a single page as clean */\nSQLITE_PRIVATE void sqlite3PcacheCleanAll(PCache*);    /* Mark all dirty list pages as clean */\nSQLITE_PRIVATE void sqlite3PcacheClearWritable(PCache*);\n\n/* Change a page number.  Used by incr-vacuum. */\nSQLITE_PRIVATE void sqlite3PcacheMove(PgHdr*, Pgno);\n\n/* Remove all pages with pgno>x.  Reset the cache if x==0 */\nSQLITE_PRIVATE void sqlite3PcacheTruncate(PCache*, Pgno x);\n\n/* Get a list of all dirty pages in the cache, sorted by page number */\nSQLITE_PRIVATE PgHdr *sqlite3PcacheDirtyList(PCache*);\n\n/* Reset and close the cache object */\nSQLITE_PRIVATE void sqlite3PcacheClose(PCache*);\n\n/* Clear flags from pages of the page cache */\nSQLITE_PRIVATE void sqlite3PcacheClearSyncFlags(PCache *);\n\n/* Discard the contents of the cache */\nSQLITE_PRIVATE void sqlite3PcacheClear(PCache*);\n\n/* Return the total number of outstanding page references */\nSQLITE_PRIVATE int sqlite3PcacheRefCount(PCache*);\n\n/* Increment the reference count of an existing page */\nSQLITE_PRIVATE void sqlite3PcacheRef(PgHdr*);\n\nSQLITE_PRIVATE int sqlite3PcachePageRefcount(PgHdr*);\n\n/* Return the total number of pages stored in the cache */\nSQLITE_PRIVATE int sqlite3PcachePagecount(PCache*);\n\n#if defined(SQLITE_CHECK_PAGES) || defined(SQLITE_DEBUG)\n/* Iterate through all dirty pages currently stored in the cache. This\n** interface is only available if SQLITE_CHECK_PAGES is defined when the \n** library is built.\n*/\nSQLITE_PRIVATE void sqlite3PcacheIterateDirty(PCache *pCache, void (*xIter)(PgHdr *));\n#endif\n\n#if defined(SQLITE_DEBUG)\n/* Check invariants on a PgHdr object */\nSQLITE_PRIVATE int sqlite3PcachePageSanity(PgHdr*);\n#endif\n\n/* Set and get the suggested cache-size for the specified pager-cache.\n**\n** If no global maximum is configured, then the system attempts to limit\n** the total number of pages cached by purgeable pager-caches to the sum\n** of the suggested cache-sizes.\n*/\nSQLITE_PRIVATE void sqlite3PcacheSetCachesize(PCache *, int);\n#ifdef SQLITE_TEST\nSQLITE_PRIVATE int sqlite3PcacheGetCachesize(PCache *);\n#endif\n\n/* Set or get the suggested spill-size for the specified pager-cache.\n**\n** The spill-size is the minimum number of pages in cache before the cache\n** will attempt to spill dirty pages by calling xStress.\n*/\nSQLITE_PRIVATE int sqlite3PcacheSetSpillsize(PCache *, int);\n\n/* Free up as much memory as possible from the page cache */\nSQLITE_PRIVATE void sqlite3PcacheShrink(PCache*);\n\n#ifdef SQLITE_ENABLE_MEMORY_MANAGEMENT\n/* Try to return memory used by the pcache module to the main memory heap */\nSQLITE_PRIVATE int sqlite3PcacheReleaseMemory(int);\n#endif\n\n#ifdef SQLITE_TEST\nSQLITE_PRIVATE void sqlite3PcacheStats(int*,int*,int*,int*);\n#endif\n\nSQLITE_PRIVATE void sqlite3PCacheSetDefault(void);\n\n/* Return the header size */\nSQLITE_PRIVATE int sqlite3HeaderSizePcache(void);\nSQLITE_PRIVATE int sqlite3HeaderSizePcache1(void);\n\n/* Number of dirty pages as a percentage of the configured cache size */\nSQLITE_PRIVATE int sqlite3PCachePercentDirty(PCache*);\n\n#ifdef SQLITE_DIRECT_OVERFLOW_READ\nSQLITE_PRIVATE int sqlite3PCacheIsDirty(PCache *pCache);\n#endif\n\n#endif /* _PCACHE_H_ */\n\n/************** End of pcache.h **********************************************/\n/************** Continuing where we left off in sqliteInt.h ******************/\n/************** Include os.h in the middle of sqliteInt.h ********************/\n/************** Begin file os.h **********************************************/\n/*\n** 2001 September 16\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n******************************************************************************\n**\n** This header file (together with is companion C source-code file\n** \"os.c\") attempt to abstract the underlying operating system so that\n** the SQLite library will work on both POSIX and windows systems.\n**\n** This header file is #include-ed by sqliteInt.h and thus ends up\n** being included by every source file.\n*/\n#ifndef _SQLITE_OS_H_\n#define _SQLITE_OS_H_\n\n/*\n** Attempt to automatically detect the operating system and setup the\n** necessary pre-processor macros for it.\n*/\n/************** Include os_setup.h in the middle of os.h *********************/\n/************** Begin file os_setup.h ****************************************/\n/*\n** 2013 November 25\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n******************************************************************************\n**\n** This file contains pre-processor directives related to operating system\n** detection and/or setup.\n*/\n#ifndef SQLITE_OS_SETUP_H\n#define SQLITE_OS_SETUP_H\n\n/*\n** Figure out if we are dealing with Unix, Windows, or some other operating\n** system.\n**\n** After the following block of preprocess macros, all of SQLITE_OS_UNIX,\n** SQLITE_OS_WIN, and SQLITE_OS_OTHER will defined to either 1 or 0.  One of\n** the three will be 1.  The other two will be 0.\n*/\n#if defined(SQLITE_OS_OTHER)\n#  if SQLITE_OS_OTHER==1\n#    undef SQLITE_OS_UNIX\n#    define SQLITE_OS_UNIX 0\n#    undef SQLITE_OS_WIN\n#    define SQLITE_OS_WIN 0\n#  else\n#    undef SQLITE_OS_OTHER\n#  endif\n#endif\n#if !defined(SQLITE_OS_UNIX) && !defined(SQLITE_OS_OTHER)\n#  define SQLITE_OS_OTHER 0\n#  ifndef SQLITE_OS_WIN\n#    if defined(_WIN32) || defined(WIN32) || defined(__CYGWIN__) || \\\n        defined(__MINGW32__) || defined(__BORLANDC__)\n#      define SQLITE_OS_WIN 1\n#      define SQLITE_OS_UNIX 0\n#    else\n#      define SQLITE_OS_WIN 0\n#      define SQLITE_OS_UNIX 1\n#    endif\n#  else\n#    define SQLITE_OS_UNIX 0\n#  endif\n#else\n#  ifndef SQLITE_OS_WIN\n#    define SQLITE_OS_WIN 0\n#  endif\n#endif\n\n#endif /* SQLITE_OS_SETUP_H */\n\n/************** End of os_setup.h ********************************************/\n/************** Continuing where we left off in os.h *************************/\n\n/* If the SET_FULLSYNC macro is not defined above, then make it\n** a no-op\n*/\n#ifndef SET_FULLSYNC\n# define SET_FULLSYNC(x,y)\n#endif\n\n/*\n** The default size of a disk sector\n*/\n#ifndef SQLITE_DEFAULT_SECTOR_SIZE\n# define SQLITE_DEFAULT_SECTOR_SIZE 4096\n#endif\n\n/*\n** Temporary files are named starting with this prefix followed by 16 random\n** alphanumeric characters, and no file extension. They are stored in the\n** OS's standard temporary file directory, and are deleted prior to exit.\n** If sqlite is being embedded in another program, you may wish to change the\n** prefix to reflect your program's name, so that if your program exits\n** prematurely, old temporary files can be easily identified. This can be done\n** using -DSQLITE_TEMP_FILE_PREFIX=myprefix_ on the compiler command line.\n**\n** 2006-10-31:  The default prefix used to be \"sqlite_\".  But then\n** Mcafee started using SQLite in their anti-virus product and it\n** started putting files with the \"sqlite\" name in the c:/temp folder.\n** This annoyed many windows users.  Those users would then do a \n** Google search for \"sqlite\", find the telephone numbers of the\n** developers and call to wake them up at night and complain.\n** For this reason, the default name prefix is changed to be \"sqlite\" \n** spelled backwards.  So the temp files are still identified, but\n** anybody smart enough to figure out the code is also likely smart\n** enough to know that calling the developer will not help get rid\n** of the file.\n*/\n#ifndef SQLITE_TEMP_FILE_PREFIX\n# define SQLITE_TEMP_FILE_PREFIX \"etilqs_\"\n#endif\n\n/*\n** The following values may be passed as the second argument to\n** sqlite3OsLock(). The various locks exhibit the following semantics:\n**\n** SHARED:    Any number of processes may hold a SHARED lock simultaneously.\n** RESERVED:  A single process may hold a RESERVED lock on a file at\n**            any time. Other processes may hold and obtain new SHARED locks.\n** PENDING:   A single process may hold a PENDING lock on a file at\n**            any one time. Existing SHARED locks may persist, but no new\n**            SHARED locks may be obtained by other processes.\n** EXCLUSIVE: An EXCLUSIVE lock precludes all other locks.\n**\n** PENDING_LOCK may not be passed directly to sqlite3OsLock(). Instead, a\n** process that requests an EXCLUSIVE lock may actually obtain a PENDING\n** lock. This can be upgraded to an EXCLUSIVE lock by a subsequent call to\n** sqlite3OsLock().\n*/\n#define NO_LOCK         0\n#define SHARED_LOCK     1\n#define RESERVED_LOCK   2\n#define PENDING_LOCK    3\n#define EXCLUSIVE_LOCK  4\n\n/*\n** File Locking Notes:  (Mostly about windows but also some info for Unix)\n**\n** We cannot use LockFileEx() or UnlockFileEx() on Win95/98/ME because\n** those functions are not available.  So we use only LockFile() and\n** UnlockFile().\n**\n** LockFile() prevents not just writing but also reading by other processes.\n** A SHARED_LOCK is obtained by locking a single randomly-chosen \n** byte out of a specific range of bytes. The lock byte is obtained at \n** random so two separate readers can probably access the file at the \n** same time, unless they are unlucky and choose the same lock byte.\n** An EXCLUSIVE_LOCK is obtained by locking all bytes in the range.\n** There can only be one writer.  A RESERVED_LOCK is obtained by locking\n** a single byte of the file that is designated as the reserved lock byte.\n** A PENDING_LOCK is obtained by locking a designated byte different from\n** the RESERVED_LOCK byte.\n**\n** On WinNT/2K/XP systems, LockFileEx() and UnlockFileEx() are available,\n** which means we can use reader/writer locks.  When reader/writer locks\n** are used, the lock is placed on the same range of bytes that is used\n** for probabilistic locking in Win95/98/ME.  Hence, the locking scheme\n** will support two or more Win95 readers or two or more WinNT readers.\n** But a single Win95 reader will lock out all WinNT readers and a single\n** WinNT reader will lock out all other Win95 readers.\n**\n** The following #defines specify the range of bytes used for locking.\n** SHARED_SIZE is the number of bytes available in the pool from which\n** a random byte is selected for a shared lock.  The pool of bytes for\n** shared locks begins at SHARED_FIRST. \n**\n** The same locking strategy and\n** byte ranges are used for Unix.  This leaves open the possibility of having\n** clients on win95, winNT, and unix all talking to the same shared file\n** and all locking correctly.  To do so would require that samba (or whatever\n** tool is being used for file sharing) implements locks correctly between\n** windows and unix.  I'm guessing that isn't likely to happen, but by\n** using the same locking range we are at least open to the possibility.\n**\n** Locking in windows is manditory.  For this reason, we cannot store\n** actual data in the bytes used for locking.  The pager never allocates\n** the pages involved in locking therefore.  SHARED_SIZE is selected so\n** that all locks will fit on a single page even at the minimum page size.\n** PENDING_BYTE defines the beginning of the locks.  By default PENDING_BYTE\n** is set high so that we don't have to allocate an unused page except\n** for very large databases.  But one should test the page skipping logic \n** by setting PENDING_BYTE low and running the entire regression suite.\n**\n** Changing the value of PENDING_BYTE results in a subtly incompatible\n** file format.  Depending on how it is changed, you might not notice\n** the incompatibility right away, even running a full regression test.\n** The default location of PENDING_BYTE is the first byte past the\n** 1GB boundary.\n**\n*/\n#ifdef SQLITE_OMIT_WSD\n# define PENDING_BYTE     (0x40000000)\n#else\n# define PENDING_BYTE      sqlite3PendingByte\n#endif\n#define RESERVED_BYTE     (PENDING_BYTE+1)\n#define SHARED_FIRST      (PENDING_BYTE+2)\n#define SHARED_SIZE       510\n\n/*\n** Wrapper around OS specific sqlite3_os_init() function.\n*/\nSQLITE_PRIVATE int sqlite3OsInit(void);\n\n/* \n** Functions for accessing sqlite3_file methods \n*/\nSQLITE_PRIVATE void sqlite3OsClose(sqlite3_file*);\nSQLITE_PRIVATE int sqlite3OsRead(sqlite3_file*, void*, int amt, i64 offset);\nSQLITE_PRIVATE int sqlite3OsWrite(sqlite3_file*, const void*, int amt, i64 offset);\nSQLITE_PRIVATE int sqlite3OsTruncate(sqlite3_file*, i64 size);\nSQLITE_PRIVATE int sqlite3OsSync(sqlite3_file*, int);\nSQLITE_PRIVATE int sqlite3OsFileSize(sqlite3_file*, i64 *pSize);\nSQLITE_PRIVATE int sqlite3OsLock(sqlite3_file*, int);\nSQLITE_PRIVATE int sqlite3OsUnlock(sqlite3_file*, int);\nSQLITE_PRIVATE int sqlite3OsCheckReservedLock(sqlite3_file *id, int *pResOut);\nSQLITE_PRIVATE int sqlite3OsFileControl(sqlite3_file*,int,void*);\nSQLITE_PRIVATE void sqlite3OsFileControlHint(sqlite3_file*,int,void*);\n#define SQLITE_FCNTL_DB_UNCHANGED 0xca093fa0\nSQLITE_PRIVATE int sqlite3OsSectorSize(sqlite3_file *id);\nSQLITE_PRIVATE int sqlite3OsDeviceCharacteristics(sqlite3_file *id);\n#ifndef SQLITE_OMIT_WAL\nSQLITE_PRIVATE int sqlite3OsShmMap(sqlite3_file *,int,int,int,void volatile **);\nSQLITE_PRIVATE int sqlite3OsShmLock(sqlite3_file *id, int, int, int);\nSQLITE_PRIVATE void sqlite3OsShmBarrier(sqlite3_file *id);\nSQLITE_PRIVATE int sqlite3OsShmUnmap(sqlite3_file *id, int);\n#endif /* SQLITE_OMIT_WAL */\nSQLITE_PRIVATE int sqlite3OsFetch(sqlite3_file *id, i64, int, void **);\nSQLITE_PRIVATE int sqlite3OsUnfetch(sqlite3_file *, i64, void *);\n\n\n/* \n** Functions for accessing sqlite3_vfs methods \n*/\nSQLITE_PRIVATE int sqlite3OsOpen(sqlite3_vfs *, const char *, sqlite3_file*, int, int *);\nSQLITE_PRIVATE int sqlite3OsDelete(sqlite3_vfs *, const char *, int);\nSQLITE_PRIVATE int sqlite3OsAccess(sqlite3_vfs *, const char *, int, int *pResOut);\nSQLITE_PRIVATE int sqlite3OsFullPathname(sqlite3_vfs *, const char *, int, char *);\n#ifndef SQLITE_OMIT_LOAD_EXTENSION\nSQLITE_PRIVATE void *sqlite3OsDlOpen(sqlite3_vfs *, const char *);\nSQLITE_PRIVATE void sqlite3OsDlError(sqlite3_vfs *, int, char *);\nSQLITE_PRIVATE void (*sqlite3OsDlSym(sqlite3_vfs *, void *, const char *))(void);\nSQLITE_PRIVATE void sqlite3OsDlClose(sqlite3_vfs *, void *);\n#endif /* SQLITE_OMIT_LOAD_EXTENSION */\nSQLITE_PRIVATE int sqlite3OsRandomness(sqlite3_vfs *, int, char *);\nSQLITE_PRIVATE int sqlite3OsSleep(sqlite3_vfs *, int);\nSQLITE_PRIVATE int sqlite3OsGetLastError(sqlite3_vfs*);\nSQLITE_PRIVATE int sqlite3OsCurrentTimeInt64(sqlite3_vfs *, sqlite3_int64*);\n\n/*\n** Convenience functions for opening and closing files using \n** sqlite3_malloc() to obtain space for the file-handle structure.\n*/\nSQLITE_PRIVATE int sqlite3OsOpenMalloc(sqlite3_vfs *, const char *, sqlite3_file **, int,int*);\nSQLITE_PRIVATE void sqlite3OsCloseFree(sqlite3_file *);\n\n#endif /* _SQLITE_OS_H_ */\n\n/************** End of os.h **************************************************/\n/************** Continuing where we left off in sqliteInt.h ******************/\n/************** Include mutex.h in the middle of sqliteInt.h *****************/\n/************** Begin file mutex.h *******************************************/\n/*\n** 2007 August 28\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n**\n** This file contains the common header for all mutex implementations.\n** The sqliteInt.h header #includes this file so that it is available\n** to all source files.  We break it out in an effort to keep the code\n** better organized.\n**\n** NOTE:  source files should *not* #include this header file directly.\n** Source files should #include the sqliteInt.h file and let that file\n** include this one indirectly.\n*/\n\n\n/*\n** Figure out what version of the code to use.  The choices are\n**\n**   SQLITE_MUTEX_OMIT         No mutex logic.  Not even stubs.  The\n**                             mutexes implementation cannot be overridden\n**                             at start-time.\n**\n**   SQLITE_MUTEX_NOOP         For single-threaded applications.  No\n**                             mutual exclusion is provided.  But this\n**                             implementation can be overridden at\n**                             start-time.\n**\n**   SQLITE_MUTEX_PTHREADS     For multi-threaded applications on Unix.\n**\n**   SQLITE_MUTEX_W32          For multi-threaded applications on Win32.\n*/\n#if !SQLITE_THREADSAFE\n# define SQLITE_MUTEX_OMIT\n#endif\n#if SQLITE_THREADSAFE && !defined(SQLITE_MUTEX_NOOP)\n#  if SQLITE_OS_UNIX\n#    define SQLITE_MUTEX_PTHREADS\n#  elif SQLITE_OS_WIN\n#    define SQLITE_MUTEX_W32\n#  else\n#    define SQLITE_MUTEX_NOOP\n#  endif\n#endif\n\n#ifdef SQLITE_MUTEX_OMIT\n/*\n** If this is a no-op implementation, implement everything as macros.\n*/\n#define sqlite3_mutex_alloc(X)    ((sqlite3_mutex*)8)\n#define sqlite3_mutex_free(X)\n#define sqlite3_mutex_enter(X)    \n#define sqlite3_mutex_try(X)      SQLITE_OK\n#define sqlite3_mutex_leave(X)    \n#define sqlite3_mutex_held(X)     ((void)(X),1)\n#define sqlite3_mutex_notheld(X)  ((void)(X),1)\n#define sqlite3MutexAlloc(X)      ((sqlite3_mutex*)8)\n#define sqlite3MutexInit()        SQLITE_OK\n#define sqlite3MutexEnd()\n#define MUTEX_LOGIC(X)\n#else\n#define MUTEX_LOGIC(X)            X\n#endif /* defined(SQLITE_MUTEX_OMIT) */\n\n/************** End of mutex.h ***********************************************/\n/************** Continuing where we left off in sqliteInt.h ******************/\n\n/* The SQLITE_EXTRA_DURABLE compile-time option used to set the default\n** synchronous setting to EXTRA.  It is no longer supported.\n*/\n#ifdef SQLITE_EXTRA_DURABLE\n# warning Use SQLITE_DEFAULT_SYNCHRONOUS=3 instead of SQLITE_EXTRA_DURABLE\n# define SQLITE_DEFAULT_SYNCHRONOUS 3\n#endif\n\n/*\n** Default synchronous levels.\n**\n** Note that (for historcal reasons) the PAGER_SYNCHRONOUS_* macros differ\n** from the SQLITE_DEFAULT_SYNCHRONOUS value by 1.\n**\n**           PAGER_SYNCHRONOUS       DEFAULT_SYNCHRONOUS\n**   OFF           1                         0\n**   NORMAL        2                         1\n**   FULL          3                         2\n**   EXTRA         4                         3\n**\n** The \"PRAGMA synchronous\" statement also uses the zero-based numbers.\n** In other words, the zero-based numbers are used for all external interfaces\n** and the one-based values are used internally.\n*/\n#ifndef SQLITE_DEFAULT_SYNCHRONOUS\n# define SQLITE_DEFAULT_SYNCHRONOUS 2\n#endif\n#ifndef SQLITE_DEFAULT_WAL_SYNCHRONOUS\n# define SQLITE_DEFAULT_WAL_SYNCHRONOUS SQLITE_DEFAULT_SYNCHRONOUS\n#endif\n\n/*\n** Each database file to be accessed by the system is an instance\n** of the following structure.  There are normally two of these structures\n** in the sqlite.aDb[] array.  aDb[0] is the main database file and\n** aDb[1] is the database file used to hold temporary tables.  Additional\n** databases may be attached.\n*/\nstruct Db {\n  char *zDbSName;      /* Name of this database. (schema name, not filename) */\n  Btree *pBt;          /* The B*Tree structure for this database file */\n  u8 safety_level;     /* How aggressive at syncing data to disk */\n  u8 bSyncSet;         /* True if \"PRAGMA synchronous=N\" has been run */\n  Schema *pSchema;     /* Pointer to database schema (possibly shared) */\n};\n\n/*\n** An instance of the following structure stores a database schema.\n**\n** Most Schema objects are associated with a Btree.  The exception is\n** the Schema for the TEMP databaes (sqlite3.aDb[1]) which is free-standing.\n** In shared cache mode, a single Schema object can be shared by multiple\n** Btrees that refer to the same underlying BtShared object.\n**\n** Schema objects are automatically deallocated when the last Btree that\n** references them is destroyed.   The TEMP Schema is manually freed by\n** sqlite3_close().\n*\n** A thread must be holding a mutex on the corresponding Btree in order\n** to access Schema content.  This implies that the thread must also be\n** holding a mutex on the sqlite3 connection pointer that owns the Btree.\n** For a TEMP Schema, only the connection mutex is required.\n*/\nstruct Schema {\n  int schema_cookie;   /* Database schema version number for this file */\n  int iGeneration;     /* Generation counter.  Incremented with each change */\n  Hash tblHash;        /* All tables indexed by name */\n  Hash idxHash;        /* All (named) indices indexed by name */\n  Hash trigHash;       /* All triggers indexed by name */\n  Hash fkeyHash;       /* All foreign keys by referenced table name */\n  Table *pSeqTab;      /* The sqlite_sequence table used by AUTOINCREMENT */\n  u8 file_format;      /* Schema format version for this file */\n  u8 enc;              /* Text encoding used by this database */\n  u16 schemaFlags;     /* Flags associated with this schema */\n  int cache_size;      /* Number of pages to use in the cache */\n};\n\n/*\n** These macros can be used to test, set, or clear bits in the\n** Db.pSchema->flags field.\n*/\n#define DbHasProperty(D,I,P)     (((D)->aDb[I].pSchema->schemaFlags&(P))==(P))\n#define DbHasAnyProperty(D,I,P)  (((D)->aDb[I].pSchema->schemaFlags&(P))!=0)\n#define DbSetProperty(D,I,P)     (D)->aDb[I].pSchema->schemaFlags|=(P)\n#define DbClearProperty(D,I,P)   (D)->aDb[I].pSchema->schemaFlags&=~(P)\n\n/*\n** Allowed values for the DB.pSchema->flags field.\n**\n** The DB_SchemaLoaded flag is set after the database schema has been\n** read into internal hash tables.\n**\n** DB_UnresetViews means that one or more views have column names that\n** have been filled out.  If the schema changes, these column names might\n** changes and so the view will need to be reset.\n*/\n#define DB_SchemaLoaded    0x0001  /* The schema has been loaded */\n#define DB_UnresetViews    0x0002  /* Some views have defined column names */\n#define DB_Empty           0x0004  /* The file is empty (length 0 bytes) */\n#define DB_ResetWanted     0x0008  /* Reset the schema when nSchemaLock==0 */\n\n/*\n** The number of different kinds of things that can be limited\n** using the sqlite3_limit() interface.\n*/\n#define SQLITE_N_LIMIT (SQLITE_LIMIT_WORKER_THREADS+1)\n\n/*\n** Lookaside malloc is a set of fixed-size buffers that can be used\n** to satisfy small transient memory allocation requests for objects\n** associated with a particular database connection.  The use of\n** lookaside malloc provides a significant performance enhancement\n** (approx 10%) by avoiding numerous malloc/free requests while parsing\n** SQL statements.\n**\n** The Lookaside structure holds configuration information about the\n** lookaside malloc subsystem.  Each available memory allocation in\n** the lookaside subsystem is stored on a linked list of LookasideSlot\n** objects.\n**\n** Lookaside allocations are only allowed for objects that are associated\n** with a particular database connection.  Hence, schema information cannot\n** be stored in lookaside because in shared cache mode the schema information\n** is shared by multiple database connections.  Therefore, while parsing\n** schema information, the Lookaside.bEnabled flag is cleared so that\n** lookaside allocations are not used to construct the schema objects.\n*/\nstruct Lookaside {\n  u32 bDisable;           /* Only operate the lookaside when zero */\n  u16 sz;                 /* Size of each buffer in bytes */\n  u8 bMalloced;           /* True if pStart obtained from sqlite3_malloc() */\n  u32 nSlot;              /* Number of lookaside slots allocated */\n  u32 anStat[3];          /* 0: hits.  1: size misses.  2: full misses */\n  LookasideSlot *pInit;   /* List of buffers not previously used */\n  LookasideSlot *pFree;   /* List of available buffers */\n  void *pStart;           /* First byte of available memory space */\n  void *pEnd;             /* First byte past end of available space */\n};\nstruct LookasideSlot {\n  LookasideSlot *pNext;    /* Next buffer in the list of free buffers */\n};\n\n/*\n** A hash table for built-in function definitions.  (Application-defined\n** functions use a regular table table from hash.h.)\n**\n** Hash each FuncDef structure into one of the FuncDefHash.a[] slots.\n** Collisions are on the FuncDef.u.pHash chain.  Use the SQLITE_FUNC_HASH()\n** macro to compute a hash on the function name.\n*/\n#define SQLITE_FUNC_HASH_SZ 23\nstruct FuncDefHash {\n  FuncDef *a[SQLITE_FUNC_HASH_SZ];       /* Hash table for functions */\n};\n#define SQLITE_FUNC_HASH(C,L) (((C)+(L))%SQLITE_FUNC_HASH_SZ)\n\n#ifdef SQLITE_USER_AUTHENTICATION\n/*\n** Information held in the \"sqlite3\" database connection object and used\n** to manage user authentication.\n*/\ntypedef struct sqlite3_userauth sqlite3_userauth;\nstruct sqlite3_userauth {\n  u8 authLevel;                 /* Current authentication level */\n  int nAuthPW;                  /* Size of the zAuthPW in bytes */\n  char *zAuthPW;                /* Password used to authenticate */\n  char *zAuthUser;              /* User name used to authenticate */\n};\n\n/* Allowed values for sqlite3_userauth.authLevel */\n#define UAUTH_Unknown     0     /* Authentication not yet checked */\n#define UAUTH_Fail        1     /* User authentication failed */\n#define UAUTH_User        2     /* Authenticated as a normal user */\n#define UAUTH_Admin       3     /* Authenticated as an administrator */\n\n/* Functions used only by user authorization logic */\nSQLITE_PRIVATE int sqlite3UserAuthTable(const char*);\nSQLITE_PRIVATE int sqlite3UserAuthCheckLogin(sqlite3*,const char*,u8*);\nSQLITE_PRIVATE void sqlite3UserAuthInit(sqlite3*);\nSQLITE_PRIVATE void sqlite3CryptFunc(sqlite3_context*,int,sqlite3_value**);\n\n#endif /* SQLITE_USER_AUTHENTICATION */\n\n/*\n** typedef for the authorization callback function.\n*/\n#ifdef SQLITE_USER_AUTHENTICATION\n  typedef int (*sqlite3_xauth)(void*,int,const char*,const char*,const char*,\n                               const char*, const char*);\n#else\n  typedef int (*sqlite3_xauth)(void*,int,const char*,const char*,const char*,\n                               const char*);\n#endif\n\n#ifndef SQLITE_OMIT_DEPRECATED\n/* This is an extra SQLITE_TRACE macro that indicates \"legacy\" tracing\n** in the style of sqlite3_trace()\n*/\n#define SQLITE_TRACE_LEGACY          0x40     /* Use the legacy xTrace */\n#define SQLITE_TRACE_XPROFILE        0x80     /* Use the legacy xProfile */\n#else\n#define SQLITE_TRACE_LEGACY          0\n#define SQLITE_TRACE_XPROFILE        0\n#endif /* SQLITE_OMIT_DEPRECATED */\n#define SQLITE_TRACE_NONLEGACY_MASK  0x0f     /* Normal flags */\n\n\n/*\n** Each database connection is an instance of the following structure.\n*/\nstruct sqlite3 {\n  sqlite3_vfs *pVfs;            /* OS Interface */\n  struct Vdbe *pVdbe;           /* List of active virtual machines */\n  CollSeq *pDfltColl;           /* The default collating sequence (BINARY) */\n  sqlite3_mutex *mutex;         /* Connection mutex */\n  Db *aDb;                      /* All backends */\n  int nDb;                      /* Number of backends currently in use */\n  u32 mDbFlags;                 /* flags recording internal state */\n  u64 flags;                    /* flags settable by pragmas. See below */\n  i64 lastRowid;                /* ROWID of most recent insert (see above) */\n  i64 szMmap;                   /* Default mmap_size setting */\n  u32 nSchemaLock;              /* Do not reset the schema when non-zero */\n  unsigned int openFlags;       /* Flags passed to sqlite3_vfs.xOpen() */\n  int errCode;                  /* Most recent error code (SQLITE_*) */\n  int errMask;                  /* & result codes with this before returning */\n  int iSysErrno;                /* Errno value from last system error */\n  u16 dbOptFlags;               /* Flags to enable/disable optimizations */\n  u8 enc;                       /* Text encoding */\n  u8 autoCommit;                /* The auto-commit flag. */\n  u8 temp_store;                /* 1: file 2: memory 0: default */\n  u8 mallocFailed;              /* True if we have seen a malloc failure */\n  u8 bBenignMalloc;             /* Do not require OOMs if true */\n  u8 dfltLockMode;              /* Default locking-mode for attached dbs */\n  signed char nextAutovac;      /* Autovac setting after VACUUM if >=0 */\n  u8 suppressErr;               /* Do not issue error messages if true */\n  u8 vtabOnConflict;            /* Value to return for s3_vtab_on_conflict() */\n  u8 isTransactionSavepoint;    /* True if the outermost savepoint is a TS */\n  u8 mTrace;                    /* zero or more SQLITE_TRACE flags */\n  u8 noSharedCache;             /* True if no shared-cache backends */\n  u8 nSqlExec;                  /* Number of pending OP_SqlExec opcodes */\n  int nextPagesize;             /* Pagesize after VACUUM if >0 */\n  u32 magic;                    /* Magic number for detect library misuse */\n  int nChange;                  /* Value returned by sqlite3_changes() */\n  int nTotalChange;             /* Value returned by sqlite3_total_changes() */\n  int aLimit[SQLITE_N_LIMIT];   /* Limits */\n  int nMaxSorterMmap;           /* Maximum size of regions mapped by sorter */\n  struct sqlite3InitInfo {      /* Information used during initialization */\n    int newTnum;                /* Rootpage of table being initialized */\n    u8 iDb;                     /* Which db file is being initialized */\n    u8 busy;                    /* TRUE if currently initializing */\n    unsigned orphanTrigger : 1; /* Last statement is orphaned TEMP trigger */\n    unsigned imposterTable : 1; /* Building an imposter table */\n    unsigned reopenMemdb : 1;   /* ATTACH is really a reopen using MemDB */\n  } init;\n  int nVdbeActive;              /* Number of VDBEs currently running */\n  int nVdbeRead;                /* Number of active VDBEs that read or write */\n  int nVdbeWrite;               /* Number of active VDBEs that read and write */\n  int nVdbeExec;                /* Number of nested calls to VdbeExec() */\n  int nVDestroy;                /* Number of active OP_VDestroy operations */\n  int nExtension;               /* Number of loaded extensions */\n  void **aExtension;            /* Array of shared library handles */\n  int (*xTrace)(u32,void*,void*,void*);     /* Trace function */\n  void *pTraceArg;                          /* Argument to the trace function */\n#ifndef SQLITE_OMIT_DEPRECATED\n  void (*xProfile)(void*,const char*,u64);  /* Profiling function */\n  void *pProfileArg;                        /* Argument to profile function */\n#endif\n  void *pCommitArg;                 /* Argument to xCommitCallback() */\n  int (*xCommitCallback)(void*);    /* Invoked at every commit. */\n  void *pRollbackArg;               /* Argument to xRollbackCallback() */\n  void (*xRollbackCallback)(void*); /* Invoked at every commit. */\n  void *pUpdateArg;\n  void (*xUpdateCallback)(void*,int, const char*,const char*,sqlite_int64);\n#ifdef SQLITE_ENABLE_PREUPDATE_HOOK\n  void *pPreUpdateArg;          /* First argument to xPreUpdateCallback */\n  void (*xPreUpdateCallback)(   /* Registered using sqlite3_preupdate_hook() */\n    void*,sqlite3*,int,char const*,char const*,sqlite3_int64,sqlite3_int64\n  );\n  PreUpdate *pPreUpdate;        /* Context for active pre-update callback */\n#endif /* SQLITE_ENABLE_PREUPDATE_HOOK */\n#ifndef SQLITE_OMIT_WAL\n  int (*xWalCallback)(void *, sqlite3 *, const char *, int);\n  void *pWalArg;\n#ifdef SQLITE_WCDB_CHECKPOINT_HANDLER\n  void (*xCheckpointCallback)(void *, sqlite3 *, const char *);\n  void *pCheckpointArg;\n#endif\n#endif\n  void(*xCollNeeded)(void*,sqlite3*,int eTextRep,const char*);\n  void(*xCollNeeded16)(void*,sqlite3*,int eTextRep,const void*);\n  void *pCollNeededArg;\n  sqlite3_value *pErr;          /* Most recent error message */\n  union {\n#ifdef SQLITE_HAS_STDATOMIC\n    atomic_int isInterrupted;\n#else\n    volatile int isInterrupted; /* True if sqlite3_interrupt has been called */\n    double notUsed1;            /* Spacer */\n#endif\n  } u1;\n#ifdef SQLITE_HAS_STDATOMIC\n  atomic_int suspended;         /* True if sqlite_suspend has been called */\n  atomic_int unimpeded;         /* True if interrupt and suspend are ignorable */\n#else\n  volatile int suspended;       /* True if sqlite_suspend has been called */\n  volatile int unimpeded;       /* True if interrupt and suspend are ignorable */\n#endif\n  Lookaside lookaside;          /* Lookaside malloc configuration */\n#ifndef SQLITE_OMIT_AUTHORIZATION\n  sqlite3_xauth xAuth;          /* Access authorization function */\n  void *pAuthArg;               /* 1st argument to the access auth function */\n#endif\n#ifndef SQLITE_OMIT_PROGRESS_CALLBACK\n  int (*xProgress)(void *);     /* The progress callback */\n  void *pProgressArg;           /* Argument to the progress callback */\n  unsigned nProgressOps;        /* Number of opcodes for progress callback */\n#endif\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n  int nVTrans;                  /* Allocated size of aVTrans */\n  Hash aModule;                 /* populated by sqlite3_create_module() */\n  VtabCtx *pVtabCtx;            /* Context for active vtab connect/create */\n  VTable **aVTrans;             /* Virtual tables with open transactions */\n  VTable *pDisconnect;          /* Disconnect these in next sqlite3_prepare() */\n#endif\n  Hash aFunc;                   /* Hash table of connection functions */\n  Hash aCollSeq;                /* All collating sequences */\n  BusyHandler busyHandler;      /* Busy callback */\n  Db aDbStatic[2];              /* Static space for the 2 default backends */\n  Savepoint *pSavepoint;        /* List of active savepoints */\n  int busyTimeout;              /* Busy handler timeout, in msec */\n  int nSavepoint;               /* Number of non-transaction savepoints */\n  int nStatement;               /* Number of nested statement-transactions  */\n  i64 nDeferredCons;            /* Net deferred constraints this transaction. */\n  i64 nDeferredImmCons;         /* Net deferred immediate constraints */\n  int *pnBytesFreed;            /* If not NULL, increment this in DbFree() */\n#ifdef SQLITE_ENABLE_UNLOCK_NOTIFY\n  /* The following variables are all protected by the STATIC_MASTER\n  ** mutex, not by sqlite3.mutex. They are used by code in notify.c.\n  **\n  ** When X.pUnlockConnection==Y, that means that X is waiting for Y to\n  ** unlock so that it can proceed.\n  **\n  ** When X.pBlockingConnection==Y, that means that something that X tried\n  ** tried to do recently failed with an SQLITE_LOCKED error due to locks\n  ** held by Y.\n  */\n  sqlite3 *pBlockingConnection; /* Connection that caused SQLITE_LOCKED */\n  sqlite3 *pUnlockConnection;           /* Connection to watch for unlock */\n  void *pUnlockArg;                     /* Argument to xUnlockNotify */\n  void (*xUnlockNotify)(void **, int);  /* Unlock notify callback */\n  sqlite3 *pNextBlocked;        /* Next in list of all blocked connections */\n#endif\n#ifdef SQLITE_USER_AUTHENTICATION\n  sqlite3_userauth auth;        /* User authentication information */\n#endif\n#ifdef SQLITE_WCDB\n  u8 revertCommit;\n#endif\n};\n\n/*\n** A macro to discover the encoding of a database.\n*/\n#define SCHEMA_ENC(db) ((db)->aDb[0].pSchema->enc)\n#define ENC(db)        ((db)->enc)\n\n/*\n** Possible values for the sqlite3.flags.\n**\n** Value constraints (enforced via assert()):\n**      SQLITE_FullFSync     == PAGER_FULLFSYNC\n**      SQLITE_CkptFullFSync == PAGER_CKPT_FULLFSYNC\n**      SQLITE_CacheSpill    == PAGER_CACHE_SPILL\n*/\n#define SQLITE_WriteSchema    0x00000001  /* OK to update SQLITE_MASTER */\n#define SQLITE_LegacyFileFmt  0x00000002  /* Create new databases in format 1 */\n#define SQLITE_FullColNames   0x00000004  /* Show full column names on SELECT */\n#define SQLITE_FullFSync      0x00000008  /* Use full fsync on the backend */\n#define SQLITE_CkptFullFSync  0x00000010  /* Use full fsync for checkpoint */\n#define SQLITE_CacheSpill     0x00000020  /* OK to spill pager cache */\n#define SQLITE_ShortColNames  0x00000040  /* Show short columns names */\n#define SQLITE_CountRows      0x00000080  /* Count rows changed by INSERT, */\n                                          /*   DELETE, or UPDATE and return */\n                                          /*   the count using a callback. */\n#define SQLITE_NullCallback   0x00000100  /* Invoke the callback once if the */\n                                          /*   result set is empty */\n#define SQLITE_IgnoreChecks   0x00000200  /* Do not enforce check constraints */\n#define SQLITE_ReadUncommit   0x00000400  /* READ UNCOMMITTED in shared-cache */\n#define SQLITE_NoCkptOnClose  0x00000800  /* No checkpoint on close()/DETACH */\n#define SQLITE_ReverseOrder   0x00001000  /* Reverse unordered SELECTs */\n#define SQLITE_RecTriggers    0x00002000  /* Enable recursive triggers */\n#define SQLITE_ForeignKeys    0x00004000  /* Enforce foreign key constraints  */\n#define SQLITE_AutoIndex      0x00008000  /* Enable automatic indexes */\n#define SQLITE_LoadExtension  0x00010000  /* Enable load_extension */\n#define SQLITE_LoadExtFunc    0x00020000  /* Enable load_extension() SQL func */\n#define SQLITE_EnableTrigger  0x00040000  /* True to enable triggers */\n#define SQLITE_DeferFKs       0x00080000  /* Defer all FK constraints */\n#define SQLITE_QueryOnly      0x00100000  /* Disable database changes */\n#define SQLITE_CellSizeCk     0x00200000  /* Check btree cell sizes on load */\n#define SQLITE_Fts3Tokenizer  0x00400000  /* Enable fts3_tokenizer(2) */\n#define SQLITE_EnableQPSG     0x00800000  /* Query Planner Stability Guarantee*/\n#define SQLITE_TriggerEQP     0x01000000  /* Show trigger EXPLAIN QUERY PLAN */\n#define SQLITE_ResetDatabase  0x02000000  /* Reset the database */\n#define SQLITE_LegacyAlter    0x04000000  /* Legacy ALTER TABLE behaviour */\n#define SQLITE_NoSchemaError  0x08000000  /* Do not report schema parse errors*/\n#define SQLITE_Defensive      0x10000000  /* Input SQL is likely hostile */\n\n/* Flags used only if debugging */\n#define HI(X)  ((u64)(X)<<32)\n#ifdef SQLITE_DEBUG\n#define SQLITE_SqlTrace       HI(0x0001)  /* Debug print SQL as it executes */\n#define SQLITE_VdbeListing    HI(0x0002)  /* Debug listings of VDBE progs */\n#define SQLITE_VdbeTrace      HI(0x0004)  /* True to trace VDBE execution */\n#define SQLITE_VdbeAddopTrace HI(0x0008)  /* Trace sqlite3VdbeAddOp() calls */\n#define SQLITE_VdbeEQP        HI(0x0010)  /* Debug EXPLAIN QUERY PLAN */\n#define SQLITE_ParserTrace    HI(0x0020)  /* PRAGMA parser_trace=ON */\n#endif\n\n/*\n** Allowed values for sqlite3.mDbFlags\n*/\n#define DBFLAG_SchemaChange   0x0001  /* Uncommitted Hash table changes */\n#define DBFLAG_PreferBuiltin  0x0002  /* Preference to built-in funcs */\n#define DBFLAG_Vacuum         0x0004  /* Currently in a VACUUM */\n#define DBFLAG_SchemaKnownOk  0x0008  /* Schema is known to be valid */\n\n/*\n** Bits of the sqlite3.dbOptFlags field that are used by the\n** sqlite3_test_control(SQLITE_TESTCTRL_OPTIMIZATIONS,...) interface to\n** selectively disable various optimizations.\n*/\n#define SQLITE_QueryFlattener 0x0001   /* Query flattening */\n                          /*  0x0002   available for reuse */\n#define SQLITE_GroupByOrder   0x0004   /* GROUPBY cover of ORDERBY */\n#define SQLITE_FactorOutConst 0x0008   /* Constant factoring */\n#define SQLITE_DistinctOpt    0x0010   /* DISTINCT using indexes */\n#define SQLITE_CoverIdxScan   0x0020   /* Covering index scans */\n#define SQLITE_OrderByIdxJoin 0x0040   /* ORDER BY of joins via index */\n#define SQLITE_Transitive     0x0080   /* Transitive constraints */\n#define SQLITE_OmitNoopJoin   0x0100   /* Omit unused tables in joins */\n#define SQLITE_CountOfView    0x0200   /* The count-of-view optimization */\n#define SQLITE_CursorHints    0x0400   /* Add OP_CursorHint opcodes */\n#define SQLITE_Stat34         0x0800   /* Use STAT3 or STAT4 data */\n   /* TH3 expects the Stat34  ^^^^^^ value to be 0x0800.  Don't change it */\n#define SQLITE_PushDown       0x1000   /* The push-down optimization */\n#define SQLITE_SimplifyJoin   0x2000   /* Convert LEFT JOIN to JOIN */\n#define SQLITE_SkipScan       0x4000   /* Skip-scans */\n#define SQLITE_PropagateConst 0x8000   /* The constant propagation opt */\n#define SQLITE_AllOpts        0xffff   /* All optimizations */\n\n/*\n** Macros for testing whether or not optimizations are enabled or disabled.\n*/\n#define OptimizationDisabled(db, mask)  (((db)->dbOptFlags&(mask))!=0)\n#define OptimizationEnabled(db, mask)   (((db)->dbOptFlags&(mask))==0)\n\n/*\n** Return true if it OK to factor constant expressions into the initialization\n** code. The argument is a Parse object for the code generator.\n*/\n#define ConstFactorOk(P) ((P)->okConstFactor)\n\n/*\n** Possible values for the sqlite.magic field.\n** The numbers are obtained at random and have no special meaning, other\n** than being distinct from one another.\n*/\n#define SQLITE_MAGIC_OPEN     0xa029a697  /* Database is open */\n#define SQLITE_MAGIC_CLOSED   0x9f3c2d33  /* Database is closed */\n#define SQLITE_MAGIC_SICK     0x4b771290  /* Error and awaiting close */\n#define SQLITE_MAGIC_BUSY     0xf03b7906  /* Database currently in use */\n#define SQLITE_MAGIC_ERROR    0xb5357930  /* An SQLITE_MISUSE error occurred */\n#define SQLITE_MAGIC_ZOMBIE   0x64cffc7f  /* Close with last statement close */\n\n/*\n** Each SQL function is defined by an instance of the following\n** structure.  For global built-in functions (ex: substr(), max(), count())\n** a pointer to this structure is held in the sqlite3BuiltinFunctions object.\n** For per-connection application-defined functions, a pointer to this\n** structure is held in the db->aHash hash table.\n**\n** The u.pHash field is used by the global built-ins.  The u.pDestructor\n** field is used by per-connection app-def functions.\n*/\nstruct FuncDef {\n  i8 nArg;             /* Number of arguments.  -1 means unlimited */\n  u32 funcFlags;       /* Some combination of SQLITE_FUNC_* */\n  void *pUserData;     /* User data parameter */\n  FuncDef *pNext;      /* Next function with same name */\n  void (*xSFunc)(sqlite3_context*,int,sqlite3_value**); /* func or agg-step */\n  void (*xFinalize)(sqlite3_context*);                  /* Agg finalizer */\n  void (*xValue)(sqlite3_context*);                     /* Current agg value */\n  void (*xInverse)(sqlite3_context*,int,sqlite3_value**); /* inverse agg-step */\n  const char *zName;   /* SQL name of the function. */\n  union {\n    FuncDef *pHash;      /* Next with a different name but the same hash */\n    FuncDestructor *pDestructor;   /* Reference counted destructor function */\n  } u;\n};\n\n/*\n** This structure encapsulates a user-function destructor callback (as\n** configured using create_function_v2()) and a reference counter. When\n** create_function_v2() is called to create a function with a destructor,\n** a single object of this type is allocated. FuncDestructor.nRef is set to\n** the number of FuncDef objects created (either 1 or 3, depending on whether\n** or not the specified encoding is SQLITE_ANY). The FuncDef.pDestructor\n** member of each of the new FuncDef objects is set to point to the allocated\n** FuncDestructor.\n**\n** Thereafter, when one of the FuncDef objects is deleted, the reference\n** count on this object is decremented. When it reaches 0, the destructor\n** is invoked and the FuncDestructor structure freed.\n*/\nstruct FuncDestructor {\n  int nRef;\n  void (*xDestroy)(void *);\n  void *pUserData;\n};\n\n/*\n** Possible values for FuncDef.flags.  Note that the _LENGTH and _TYPEOF\n** values must correspond to OPFLAG_LENGTHARG and OPFLAG_TYPEOFARG.  And\n** SQLITE_FUNC_CONSTANT must be the same as SQLITE_DETERMINISTIC.  There\n** are assert() statements in the code to verify this.\n**\n** Value constraints (enforced via assert()):\n**     SQLITE_FUNC_MINMAX    ==  NC_MinMaxAgg      == SF_MinMaxAgg\n**     SQLITE_FUNC_LENGTH    ==  OPFLAG_LENGTHARG\n**     SQLITE_FUNC_TYPEOF    ==  OPFLAG_TYPEOFARG\n**     SQLITE_FUNC_CONSTANT  ==  SQLITE_DETERMINISTIC from the API\n**     SQLITE_FUNC_ENCMASK   depends on SQLITE_UTF* macros in the API\n*/\n#define SQLITE_FUNC_ENCMASK  0x0003 /* SQLITE_UTF8, SQLITE_UTF16BE or UTF16LE */\n#define SQLITE_FUNC_LIKE     0x0004 /* Candidate for the LIKE optimization */\n#define SQLITE_FUNC_CASE     0x0008 /* Case-sensitive LIKE-type function */\n#define SQLITE_FUNC_EPHEM    0x0010 /* Ephemeral.  Delete with VDBE */\n#define SQLITE_FUNC_NEEDCOLL 0x0020 /* sqlite3GetFuncCollSeq() might be called*/\n#define SQLITE_FUNC_LENGTH   0x0040 /* Built-in length() function */\n#define SQLITE_FUNC_TYPEOF   0x0080 /* Built-in typeof() function */\n#define SQLITE_FUNC_COUNT    0x0100 /* Built-in count(*) aggregate */\n#define SQLITE_FUNC_COALESCE 0x0200 /* Built-in coalesce() or ifnull() */\n#define SQLITE_FUNC_UNLIKELY 0x0400 /* Built-in unlikely() function */\n#define SQLITE_FUNC_CONSTANT 0x0800 /* Constant inputs give a constant output */\n#define SQLITE_FUNC_MINMAX   0x1000 /* True for min() and max() aggregates */\n#define SQLITE_FUNC_SLOCHNG  0x2000 /* \"Slow Change\". Value constant during a\n                                    ** single query - might change over time */\n#define SQLITE_FUNC_AFFINITY 0x4000 /* Built-in affinity() function */\n#define SQLITE_FUNC_OFFSET   0x8000 /* Built-in sqlite_offset() function */\n#define SQLITE_FUNC_WINDOW   0x00010000 /* Built-in window-only function */\n#define SQLITE_FUNC_WINDOW_SIZE 0x20000 /* Requires partition size as arg. */\n#define SQLITE_FUNC_INTERNAL 0x00040000 /* For use by NestedParse() only */\n\n/*\n** The following three macros, FUNCTION(), LIKEFUNC() and AGGREGATE() are\n** used to create the initializers for the FuncDef structures.\n**\n**   FUNCTION(zName, nArg, iArg, bNC, xFunc)\n**     Used to create a scalar function definition of a function zName\n**     implemented by C function xFunc that accepts nArg arguments. The\n**     value passed as iArg is cast to a (void*) and made available\n**     as the user-data (sqlite3_user_data()) for the function. If\n**     argument bNC is true, then the SQLITE_FUNC_NEEDCOLL flag is set.\n**\n**   VFUNCTION(zName, nArg, iArg, bNC, xFunc)\n**     Like FUNCTION except it omits the SQLITE_FUNC_CONSTANT flag.\n**\n**   DFUNCTION(zName, nArg, iArg, bNC, xFunc)\n**     Like FUNCTION except it omits the SQLITE_FUNC_CONSTANT flag and\n**     adds the SQLITE_FUNC_SLOCHNG flag.  Used for date & time functions\n**     and functions like sqlite_version() that can change, but not during\n**     a single query.  The iArg is ignored.  The user-data is always set\n**     to a NULL pointer.  The bNC parameter is not used.\n**\n**   PURE_DATE(zName, nArg, iArg, bNC, xFunc)\n**     Used for \"pure\" date/time functions, this macro is like DFUNCTION\n**     except that it does set the SQLITE_FUNC_CONSTANT flags.  iArg is\n**     ignored and the user-data for these functions is set to an \n**     arbitrary non-NULL pointer.  The bNC parameter is not used.\n**\n**   AGGREGATE(zName, nArg, iArg, bNC, xStep, xFinal)\n**     Used to create an aggregate function definition implemented by\n**     the C functions xStep and xFinal. The first four parameters\n**     are interpreted in the same way as the first 4 parameters to\n**     FUNCTION().\n**\n**   WFUNCTION(zName, nArg, iArg, xStep, xFinal, xValue, xInverse)\n**     Used to create an aggregate function definition implemented by\n**     the C functions xStep and xFinal. The first four parameters\n**     are interpreted in the same way as the first 4 parameters to\n**     FUNCTION().\n**\n**   LIKEFUNC(zName, nArg, pArg, flags)\n**     Used to create a scalar function definition of a function zName\n**     that accepts nArg arguments and is implemented by a call to C\n**     function likeFunc. Argument pArg is cast to a (void *) and made\n**     available as the function user-data (sqlite3_user_data()). The\n**     FuncDef.flags variable is set to the value passed as the flags\n**     parameter.\n*/\n#define FUNCTION(zName, nArg, iArg, bNC, xFunc) \\\n  {nArg, SQLITE_FUNC_CONSTANT|SQLITE_UTF8|(bNC*SQLITE_FUNC_NEEDCOLL), \\\n   SQLITE_INT_TO_PTR(iArg), 0, xFunc, 0, 0, 0, #zName, {0} }\n#define VFUNCTION(zName, nArg, iArg, bNC, xFunc) \\\n  {nArg, SQLITE_UTF8|(bNC*SQLITE_FUNC_NEEDCOLL), \\\n   SQLITE_INT_TO_PTR(iArg), 0, xFunc, 0, 0, 0, #zName, {0} }\n#define DFUNCTION(zName, nArg, iArg, bNC, xFunc) \\\n  {nArg, SQLITE_FUNC_SLOCHNG|SQLITE_UTF8, \\\n   0, 0, xFunc, 0, 0, 0, #zName, {0} }\n#define PURE_DATE(zName, nArg, iArg, bNC, xFunc) \\\n  {nArg, SQLITE_FUNC_SLOCHNG|SQLITE_UTF8|SQLITE_FUNC_CONSTANT, \\\n   (void*)&sqlite3Config, 0, xFunc, 0, 0, 0, #zName, {0} }\n#define FUNCTION2(zName, nArg, iArg, bNC, xFunc, extraFlags) \\\n  {nArg,SQLITE_FUNC_CONSTANT|SQLITE_UTF8|(bNC*SQLITE_FUNC_NEEDCOLL)|extraFlags,\\\n   SQLITE_INT_TO_PTR(iArg), 0, xFunc, 0, 0, 0, #zName, {0} }\n#define STR_FUNCTION(zName, nArg, pArg, bNC, xFunc) \\\n  {nArg, SQLITE_FUNC_SLOCHNG|SQLITE_UTF8|(bNC*SQLITE_FUNC_NEEDCOLL), \\\n   pArg, 0, xFunc, 0, 0, 0, #zName, }\n#define LIKEFUNC(zName, nArg, arg, flags) \\\n  {nArg, SQLITE_FUNC_CONSTANT|SQLITE_UTF8|flags, \\\n   (void *)arg, 0, likeFunc, 0, 0, 0, #zName, {0} }\n#define AGGREGATE(zName, nArg, arg, nc, xStep, xFinal, xValue) \\\n  {nArg, SQLITE_UTF8|(nc*SQLITE_FUNC_NEEDCOLL), \\\n   SQLITE_INT_TO_PTR(arg), 0, xStep,xFinal,xValue,0,#zName, {0}}\n#define AGGREGATE2(zName, nArg, arg, nc, xStep, xFinal, extraFlags) \\\n  {nArg, SQLITE_UTF8|(nc*SQLITE_FUNC_NEEDCOLL)|extraFlags, \\\n   SQLITE_INT_TO_PTR(arg), 0, xStep,xFinal,xFinal,0,#zName, {0}}\n#define WAGGREGATE(zName, nArg, arg, nc, xStep, xFinal, xValue, xInverse, f) \\\n  {nArg, SQLITE_UTF8|(nc*SQLITE_FUNC_NEEDCOLL)|f, \\\n   SQLITE_INT_TO_PTR(arg), 0, xStep,xFinal,xValue,xInverse,#zName, {0}}\n#define INTERNAL_FUNCTION(zName, nArg, xFunc) \\\n  {nArg, SQLITE_FUNC_INTERNAL|SQLITE_UTF8|SQLITE_FUNC_CONSTANT, \\\n   0, 0, xFunc, 0, 0, 0, #zName, {0} }\n\n\n/*\n** All current savepoints are stored in a linked list starting at\n** sqlite3.pSavepoint. The first element in the list is the most recently\n** opened savepoint. Savepoints are added to the list by the vdbe\n** OP_Savepoint instruction.\n*/\nstruct Savepoint {\n  char *zName;                        /* Savepoint name (nul-terminated) */\n  i64 nDeferredCons;                  /* Number of deferred fk violations */\n  i64 nDeferredImmCons;               /* Number of deferred imm fk. */\n  Savepoint *pNext;                   /* Parent savepoint (if any) */\n};\n\n/*\n** The following are used as the second parameter to sqlite3Savepoint(),\n** and as the P1 argument to the OP_Savepoint instruction.\n*/\n#define SAVEPOINT_BEGIN      0\n#define SAVEPOINT_RELEASE    1\n#define SAVEPOINT_ROLLBACK   2\n\n\n/*\n** Each SQLite module (virtual table definition) is defined by an\n** instance of the following structure, stored in the sqlite3.aModule\n** hash table.\n*/\nstruct Module {\n  const sqlite3_module *pModule;       /* Callback pointers */\n  const char *zName;                   /* Name passed to create_module() */\n  void *pAux;                          /* pAux passed to create_module() */\n  void (*xDestroy)(void *);            /* Module destructor function */\n  Table *pEpoTab;                      /* Eponymous table for this module */\n};\n\n/*\n** information about each column of an SQL table is held in an instance\n** of this structure.\n*/\nstruct Column {\n  char *zName;     /* Name of this column, \\000, then the type */\n  Expr *pDflt;     /* Default value of this column */\n  char *zColl;     /* Collating sequence.  If NULL, use the default */\n  u8 notNull;      /* An OE_ code for handling a NOT NULL constraint */\n  char affinity;   /* One of the SQLITE_AFF_... values */\n  u8 szEst;        /* Estimated size of value in this column. sizeof(INT)==1 */\n  u8 colFlags;     /* Boolean properties.  See COLFLAG_ defines below */\n};\n\n/* Allowed values for Column.colFlags:\n*/\n#define COLFLAG_PRIMKEY  0x0001    /* Column is part of the primary key */\n#define COLFLAG_HIDDEN   0x0002    /* A hidden column in a virtual table */\n#define COLFLAG_HASTYPE  0x0004    /* Type name follows column name */\n#define COLFLAG_UNIQUE   0x0008    /* Column def contains \"UNIQUE\" or \"PK\" */\n#define COLFLAG_SORTERREF 0x0010   /* Use sorter-refs with this column */\n\n/*\n** A \"Collating Sequence\" is defined by an instance of the following\n** structure. Conceptually, a collating sequence consists of a name and\n** a comparison routine that defines the order of that sequence.\n**\n** If CollSeq.xCmp is NULL, it means that the\n** collating sequence is undefined.  Indices built on an undefined\n** collating sequence may not be read or written.\n*/\nstruct CollSeq {\n  char *zName;          /* Name of the collating sequence, UTF-8 encoded */\n  u8 enc;               /* Text encoding handled by xCmp() */\n  void *pUser;          /* First argument to xCmp() */\n  int (*xCmp)(void*,int, const void*, int, const void*);\n  void (*xDel)(void*);  /* Destructor for pUser */\n};\n\n/*\n** A sort order can be either ASC or DESC.\n*/\n#define SQLITE_SO_ASC       0  /* Sort in ascending order */\n#define SQLITE_SO_DESC      1  /* Sort in ascending order */\n#define SQLITE_SO_UNDEFINED -1 /* No sort order specified */\n\n/*\n** Column affinity types.\n**\n** These used to have mnemonic name like 'i' for SQLITE_AFF_INTEGER and\n** 't' for SQLITE_AFF_TEXT.  But we can save a little space and improve\n** the speed a little by numbering the values consecutively.\n**\n** But rather than start with 0 or 1, we begin with 'A'.  That way,\n** when multiple affinity types are concatenated into a string and\n** used as the P4 operand, they will be more readable.\n**\n** Note also that the numeric types are grouped together so that testing\n** for a numeric type is a single comparison.  And the BLOB type is first.\n*/\n#define SQLITE_AFF_BLOB     'A'\n#define SQLITE_AFF_TEXT     'B'\n#define SQLITE_AFF_NUMERIC  'C'\n#define SQLITE_AFF_INTEGER  'D'\n#define SQLITE_AFF_REAL     'E'\n\n#define sqlite3IsNumericAffinity(X)  ((X)>=SQLITE_AFF_NUMERIC)\n\n/*\n** The SQLITE_AFF_MASK values masks off the significant bits of an\n** affinity value.\n*/\n#define SQLITE_AFF_MASK     0x47\n\n/*\n** Additional bit values that can be ORed with an affinity without\n** changing the affinity.\n**\n** The SQLITE_NOTNULL flag is a combination of NULLEQ and JUMPIFNULL.\n** It causes an assert() to fire if either operand to a comparison\n** operator is NULL.  It is added to certain comparison operators to\n** prove that the operands are always NOT NULL.\n*/\n#define SQLITE_KEEPNULL     0x08  /* Used by vector == or <> */\n#define SQLITE_JUMPIFNULL   0x10  /* jumps if either operand is NULL */\n#define SQLITE_STOREP2      0x20  /* Store result in reg[P2] rather than jump */\n#define SQLITE_NULLEQ       0x80  /* NULL=NULL */\n#define SQLITE_NOTNULL      0x90  /* Assert that operands are never NULL */\n\n/*\n** An object of this type is created for each virtual table present in\n** the database schema.\n**\n** If the database schema is shared, then there is one instance of this\n** structure for each database connection (sqlite3*) that uses the shared\n** schema. This is because each database connection requires its own unique\n** instance of the sqlite3_vtab* handle used to access the virtual table\n** implementation. sqlite3_vtab* handles can not be shared between\n** database connections, even when the rest of the in-memory database\n** schema is shared, as the implementation often stores the database\n** connection handle passed to it via the xConnect() or xCreate() method\n** during initialization internally. This database connection handle may\n** then be used by the virtual table implementation to access real tables\n** within the database. So that they appear as part of the callers\n** transaction, these accesses need to be made via the same database\n** connection as that used to execute SQL operations on the virtual table.\n**\n** All VTable objects that correspond to a single table in a shared\n** database schema are initially stored in a linked-list pointed to by\n** the Table.pVTable member variable of the corresponding Table object.\n** When an sqlite3_prepare() operation is required to access the virtual\n** table, it searches the list for the VTable that corresponds to the\n** database connection doing the preparing so as to use the correct\n** sqlite3_vtab* handle in the compiled query.\n**\n** When an in-memory Table object is deleted (for example when the\n** schema is being reloaded for some reason), the VTable objects are not\n** deleted and the sqlite3_vtab* handles are not xDisconnect()ed\n** immediately. Instead, they are moved from the Table.pVTable list to\n** another linked list headed by the sqlite3.pDisconnect member of the\n** corresponding sqlite3 structure. They are then deleted/xDisconnected\n** next time a statement is prepared using said sqlite3*. This is done\n** to avoid deadlock issues involving multiple sqlite3.mutex mutexes.\n** Refer to comments above function sqlite3VtabUnlockList() for an\n** explanation as to why it is safe to add an entry to an sqlite3.pDisconnect\n** list without holding the corresponding sqlite3.mutex mutex.\n**\n** The memory for objects of this type is always allocated by\n** sqlite3DbMalloc(), using the connection handle stored in VTable.db as\n** the first argument.\n*/\nstruct VTable {\n  sqlite3 *db;              /* Database connection associated with this table */\n  Module *pMod;             /* Pointer to module implementation */\n  sqlite3_vtab *pVtab;      /* Pointer to vtab instance */\n  int nRef;                 /* Number of pointers to this structure */\n  u8 bConstraint;           /* True if constraints are supported */\n  int iSavepoint;           /* Depth of the SAVEPOINT stack */\n  VTable *pNext;            /* Next in linked list (see above) */\n};\n\n/*\n** The schema for each SQL table and view is represented in memory\n** by an instance of the following structure.\n*/\nstruct Table {\n  char *zName;         /* Name of the table or view */\n  Column *aCol;        /* Information about each column */\n  Index *pIndex;       /* List of SQL indexes on this table. */\n  Select *pSelect;     /* NULL for tables.  Points to definition if a view. */\n  FKey *pFKey;         /* Linked list of all foreign keys in this table */\n  char *zColAff;       /* String defining the affinity of each column */\n  ExprList *pCheck;    /* All CHECK constraints */\n                       /*   ... also used as column name list in a VIEW */\n  int tnum;            /* Root BTree page for this table */\n  u32 nTabRef;         /* Number of pointers to this Table */\n  u32 tabFlags;        /* Mask of TF_* values */\n  i16 iPKey;           /* If not negative, use aCol[iPKey] as the rowid */\n  i16 nCol;            /* Number of columns in this table */\n  LogEst nRowLogEst;   /* Estimated rows in table - from sqlite_stat1 table */\n  LogEst szTabRow;     /* Estimated size of each table row in bytes */\n#ifdef SQLITE_ENABLE_COSTMULT\n  LogEst costMult;     /* Cost multiplier for using this table */\n#endif\n  u8 keyConf;          /* What to do in case of uniqueness conflict on iPKey */\n#ifndef SQLITE_OMIT_ALTERTABLE\n  int addColOffset;    /* Offset in CREATE TABLE stmt to add a new column */\n#endif\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n  int nModuleArg;      /* Number of arguments to the module */\n  char **azModuleArg;  /* 0: module 1: schema 2: vtab name 3...: args */\n  VTable *pVTable;     /* List of VTable objects. */\n#endif\n  Trigger *pTrigger;   /* List of triggers stored in pSchema */\n  Schema *pSchema;     /* Schema that contains this table */\n  Table *pNextZombie;  /* Next on the Parse.pZombieTab list */\n};\n\n/*\n** Allowed values for Table.tabFlags.\n**\n** TF_OOOHidden applies to tables or view that have hidden columns that are\n** followed by non-hidden columns.  Example:  \"CREATE VIRTUAL TABLE x USING\n** vtab1(a HIDDEN, b);\".  Since \"b\" is a non-hidden column but \"a\" is hidden,\n** the TF_OOOHidden attribute would apply in this case.  Such tables require\n** special handling during INSERT processing.\n*/\n#define TF_Readonly        0x0001    /* Read-only system table */\n#define TF_Ephemeral       0x0002    /* An ephemeral table */\n#define TF_HasPrimaryKey   0x0004    /* Table has a primary key */\n#define TF_Autoincrement   0x0008    /* Integer primary key is autoincrement */\n#define TF_HasStat1        0x0010    /* nRowLogEst set from sqlite_stat1 */\n#define TF_WithoutRowid    0x0020    /* No rowid.  PRIMARY KEY is the key */\n#define TF_NoVisibleRowid  0x0040    /* No user-visible \"rowid\" column */\n#define TF_OOOHidden       0x0080    /* Out-of-Order hidden columns */\n#define TF_StatsUsed       0x0100    /* Query planner decisions affected by\n                                     ** Index.aiRowLogEst[] values */\n#define TF_HasNotNull      0x0200    /* Contains NOT NULL constraints */\n#define TF_Shadow          0x0400    /* True for a shadow table */\n\n/*\n** Test to see whether or not a table is a virtual table.  This is\n** done as a macro so that it will be optimized out when virtual\n** table support is omitted from the build.\n*/\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n#  define IsVirtual(X)      ((X)->nModuleArg)\n#else\n#  define IsVirtual(X)      0\n#endif\n\n/*\n** Macros to determine if a column is hidden.  IsOrdinaryHiddenColumn()\n** only works for non-virtual tables (ordinary tables and views) and is\n** always false unless SQLITE_ENABLE_HIDDEN_COLUMNS is defined.  The\n** IsHiddenColumn() macro is general purpose.\n*/\n#if defined(SQLITE_ENABLE_HIDDEN_COLUMNS)\n#  define IsHiddenColumn(X)         (((X)->colFlags & COLFLAG_HIDDEN)!=0)\n#  define IsOrdinaryHiddenColumn(X) (((X)->colFlags & COLFLAG_HIDDEN)!=0)\n#elif !defined(SQLITE_OMIT_VIRTUALTABLE)\n#  define IsHiddenColumn(X)         (((X)->colFlags & COLFLAG_HIDDEN)!=0)\n#  define IsOrdinaryHiddenColumn(X) 0\n#else\n#  define IsHiddenColumn(X)         0\n#  define IsOrdinaryHiddenColumn(X) 0\n#endif\n\n\n/* Does the table have a rowid */\n#define HasRowid(X)     (((X)->tabFlags & TF_WithoutRowid)==0)\n#define VisibleRowid(X) (((X)->tabFlags & TF_NoVisibleRowid)==0)\n\n/*\n** Each foreign key constraint is an instance of the following structure.\n**\n** A foreign key is associated with two tables.  The \"from\" table is\n** the table that contains the REFERENCES clause that creates the foreign\n** key.  The \"to\" table is the table that is named in the REFERENCES clause.\n** Consider this example:\n**\n**     CREATE TABLE ex1(\n**       a INTEGER PRIMARY KEY,\n**       b INTEGER CONSTRAINT fk1 REFERENCES ex2(x)\n**     );\n**\n** For foreign key \"fk1\", the from-table is \"ex1\" and the to-table is \"ex2\".\n** Equivalent names:\n**\n**     from-table == child-table\n**       to-table == parent-table\n**\n** Each REFERENCES clause generates an instance of the following structure\n** which is attached to the from-table.  The to-table need not exist when\n** the from-table is created.  The existence of the to-table is not checked.\n**\n** The list of all parents for child Table X is held at X.pFKey.\n**\n** A list of all children for a table named Z (which might not even exist)\n** is held in Schema.fkeyHash with a hash key of Z.\n*/\nstruct FKey {\n  Table *pFrom;     /* Table containing the REFERENCES clause (aka: Child) */\n  FKey *pNextFrom;  /* Next FKey with the same in pFrom. Next parent of pFrom */\n  char *zTo;        /* Name of table that the key points to (aka: Parent) */\n  FKey *pNextTo;    /* Next with the same zTo. Next child of zTo. */\n  FKey *pPrevTo;    /* Previous with the same zTo */\n  int nCol;         /* Number of columns in this key */\n  /* EV: R-30323-21917 */\n  u8 isDeferred;       /* True if constraint checking is deferred till COMMIT */\n  u8 aAction[2];        /* ON DELETE and ON UPDATE actions, respectively */\n  Trigger *apTrigger[2];/* Triggers for aAction[] actions */\n  struct sColMap {      /* Mapping of columns in pFrom to columns in zTo */\n    int iFrom;            /* Index of column in pFrom */\n    char *zCol;           /* Name of column in zTo.  If NULL use PRIMARY KEY */\n  } aCol[1];            /* One entry for each of nCol columns */\n};\n\n/*\n** SQLite supports many different ways to resolve a constraint\n** error.  ROLLBACK processing means that a constraint violation\n** causes the operation in process to fail and for the current transaction\n** to be rolled back.  ABORT processing means the operation in process\n** fails and any prior changes from that one operation are backed out,\n** but the transaction is not rolled back.  FAIL processing means that\n** the operation in progress stops and returns an error code.  But prior\n** changes due to the same operation are not backed out and no rollback\n** occurs.  IGNORE means that the particular row that caused the constraint\n** error is not inserted or updated.  Processing continues and no error\n** is returned.  REPLACE means that preexisting database rows that caused\n** a UNIQUE constraint violation are removed so that the new insert or\n** update can proceed.  Processing continues and no error is reported.\n**\n** RESTRICT, SETNULL, and CASCADE actions apply only to foreign keys.\n** RESTRICT is the same as ABORT for IMMEDIATE foreign keys and the\n** same as ROLLBACK for DEFERRED keys.  SETNULL means that the foreign\n** key is set to NULL.  CASCADE means that a DELETE or UPDATE of the\n** referenced table row is propagated into the row that holds the\n** foreign key.\n**\n** The following symbolic values are used to record which type\n** of action to take.\n*/\n#define OE_None     0   /* There is no constraint to check */\n#define OE_Rollback 1   /* Fail the operation and rollback the transaction */\n#define OE_Abort    2   /* Back out changes but do no rollback transaction */\n#define OE_Fail     3   /* Stop the operation but leave all prior changes */\n#define OE_Ignore   4   /* Ignore the error. Do not do the INSERT or UPDATE */\n#define OE_Replace  5   /* Delete existing record, then do INSERT or UPDATE */\n#define OE_Update   6   /* Process as a DO UPDATE in an upsert */\n#define OE_Restrict 7   /* OE_Abort for IMMEDIATE, OE_Rollback for DEFERRED */\n#define OE_SetNull  8   /* Set the foreign key value to NULL */\n#define OE_SetDflt  9   /* Set the foreign key value to its default */\n#define OE_Cascade  10  /* Cascade the changes */\n#define OE_Default  11  /* Do whatever the default action is */\n\n\n/*\n** An instance of the following structure is passed as the first\n** argument to sqlite3VdbeKeyCompare and is used to control the\n** comparison of the two index keys.\n**\n** Note that aSortOrder[] and aColl[] have nField+1 slots.  There\n** are nField slots for the columns of an index then one extra slot\n** for the rowid at the end.\n*/\nstruct KeyInfo {\n  u32 nRef;           /* Number of references to this KeyInfo object */\n  u8 enc;             /* Text encoding - one of the SQLITE_UTF* values */\n  u16 nKeyField;      /* Number of key columns in the index */\n  u16 nAllField;      /* Total columns, including key plus others */\n  sqlite3 *db;        /* The database connection */\n  u8 *aSortOrder;     /* Sort order for each column. */\n  CollSeq *aColl[1];  /* Collating sequence for each term of the key */\n};\n\n/*\n** This object holds a record which has been parsed out into individual\n** fields, for the purposes of doing a comparison.\n**\n** A record is an object that contains one or more fields of data.\n** Records are used to store the content of a table row and to store\n** the key of an index.  A blob encoding of a record is created by\n** the OP_MakeRecord opcode of the VDBE and is disassembled by the\n** OP_Column opcode.\n**\n** An instance of this object serves as a \"key\" for doing a search on\n** an index b+tree. The goal of the search is to find the entry that\n** is closed to the key described by this object.  This object might hold\n** just a prefix of the key.  The number of fields is given by\n** pKeyInfo->nField.\n**\n** The r1 and r2 fields are the values to return if this key is less than\n** or greater than a key in the btree, respectively.  These are normally\n** -1 and +1 respectively, but might be inverted to +1 and -1 if the b-tree\n** is in DESC order.\n**\n** The key comparison functions actually return default_rc when they find\n** an equals comparison.  default_rc can be -1, 0, or +1.  If there are\n** multiple entries in the b-tree with the same key (when only looking\n** at the first pKeyInfo->nFields,) then default_rc can be set to -1 to\n** cause the search to find the last match, or +1 to cause the search to\n** find the first match.\n**\n** The key comparison functions will set eqSeen to true if they ever\n** get and equal results when comparing this structure to a b-tree record.\n** When default_rc!=0, the search might end up on the record immediately\n** before the first match or immediately after the last match.  The\n** eqSeen field will indicate whether or not an exact match exists in the\n** b-tree.\n*/\nstruct UnpackedRecord {\n  KeyInfo *pKeyInfo;  /* Collation and sort-order information */\n  Mem *aMem;          /* Values */\n  u16 nField;         /* Number of entries in apMem[] */\n  i8 default_rc;      /* Comparison result if keys are equal */\n  u8 errCode;         /* Error detected by xRecordCompare (CORRUPT or NOMEM) */\n  i8 r1;              /* Value to return if (lhs < rhs) */\n  i8 r2;              /* Value to return if (lhs > rhs) */\n  u8 eqSeen;          /* True if an equality comparison has been seen */\n};\n\n\n/*\n** Each SQL index is represented in memory by an\n** instance of the following structure.\n**\n** The columns of the table that are to be indexed are described\n** by the aiColumn[] field of this structure.  For example, suppose\n** we have the following table and index:\n**\n**     CREATE TABLE Ex1(c1 int, c2 int, c3 text);\n**     CREATE INDEX Ex2 ON Ex1(c3,c1);\n**\n** In the Table structure describing Ex1, nCol==3 because there are\n** three columns in the table.  In the Index structure describing\n** Ex2, nColumn==2 since 2 of the 3 columns of Ex1 are indexed.\n** The value of aiColumn is {2, 0}.  aiColumn[0]==2 because the\n** first column to be indexed (c3) has an index of 2 in Ex1.aCol[].\n** The second column to be indexed (c1) has an index of 0 in\n** Ex1.aCol[], hence Ex2.aiColumn[1]==0.\n**\n** The Index.onError field determines whether or not the indexed columns\n** must be unique and what to do if they are not.  When Index.onError=OE_None,\n** it means this is not a unique index.  Otherwise it is a unique index\n** and the value of Index.onError indicate the which conflict resolution\n** algorithm to employ whenever an attempt is made to insert a non-unique\n** element.\n**\n** While parsing a CREATE TABLE or CREATE INDEX statement in order to\n** generate VDBE code (as opposed to parsing one read from an sqlite_master\n** table as part of parsing an existing database schema), transient instances\n** of this structure may be created. In this case the Index.tnum variable is\n** used to store the address of a VDBE instruction, not a database page\n** number (it cannot - the database page is not allocated until the VDBE\n** program is executed). See convertToWithoutRowidTable() for details.\n*/\nstruct Index {\n  char *zName;             /* Name of this index */\n  i16 *aiColumn;           /* Which columns are used by this index.  1st is 0 */\n  LogEst *aiRowLogEst;     /* From ANALYZE: Est. rows selected by each column */\n  Table *pTable;           /* The SQL table being indexed */\n  char *zColAff;           /* String defining the affinity of each column */\n  Index *pNext;            /* The next index associated with the same table */\n  Schema *pSchema;         /* Schema containing this index */\n  u8 *aSortOrder;          /* for each column: True==DESC, False==ASC */\n  const char **azColl;     /* Array of collation sequence names for index */\n  Expr *pPartIdxWhere;     /* WHERE clause for partial indices */\n  ExprList *aColExpr;      /* Column expressions */\n  int tnum;                /* DB Page containing root of this index */\n  LogEst szIdxRow;         /* Estimated average row size in bytes */\n  u16 nKeyCol;             /* Number of columns forming the key */\n  u16 nColumn;             /* Number of columns stored in the index */\n  u8 onError;              /* OE_Abort, OE_Ignore, OE_Replace, or OE_None */\n  unsigned idxType:2;      /* 0:Normal 1:UNIQUE, 2:PRIMARY KEY, 3:IPK */\n  unsigned bUnordered:1;   /* Use this index for == or IN queries only */\n  unsigned uniqNotNull:1;  /* True if UNIQUE and NOT NULL for all columns */\n  unsigned isResized:1;    /* True if resizeIndexObject() has been called */\n  unsigned isCovering:1;   /* True if this is a covering index */\n  unsigned noSkipScan:1;   /* Do not try to use skip-scan if true */\n  unsigned hasStat1:1;     /* aiRowLogEst values come from sqlite_stat1 */\n  unsigned bNoQuery:1;     /* Do not use this index to optimize queries */\n#ifdef SQLITE_ENABLE_STAT3_OR_STAT4\n  int nSample;             /* Number of elements in aSample[] */\n  int nSampleCol;          /* Size of IndexSample.anEq[] and so on */\n  tRowcnt *aAvgEq;         /* Average nEq values for keys not in aSample */\n  IndexSample *aSample;    /* Samples of the left-most key */\n  tRowcnt *aiRowEst;       /* Non-logarithmic stat1 data for this index */\n  tRowcnt nRowEst0;        /* Non-logarithmic number of rows in the index */\n#endif\n  Bitmask colNotIdxed;     /* 0 for unindexed columns in pTab */\n};\n\n/*\n** Allowed values for Index.idxType\n*/\n#define SQLITE_IDXTYPE_APPDEF      0   /* Created using CREATE INDEX */\n#define SQLITE_IDXTYPE_UNIQUE      1   /* Implements a UNIQUE constraint */\n#define SQLITE_IDXTYPE_PRIMARYKEY  2   /* Is the PRIMARY KEY for the table */\n#define SQLITE_IDXTYPE_IPK         3   /* INTEGER PRIMARY KEY index */\n\n/* Return true if index X is a PRIMARY KEY index */\n#define IsPrimaryKeyIndex(X)  ((X)->idxType==SQLITE_IDXTYPE_PRIMARYKEY)\n\n/* Return true if index X is a UNIQUE index */\n#define IsUniqueIndex(X)      ((X)->onError!=OE_None)\n\n/* The Index.aiColumn[] values are normally positive integer.  But\n** there are some negative values that have special meaning:\n*/\n#define XN_ROWID     (-1)     /* Indexed column is the rowid */\n#define XN_EXPR      (-2)     /* Indexed column is an expression */\n\n/*\n** Each sample stored in the sqlite_stat3 table is represented in memory\n** using a structure of this type.  See documentation at the top of the\n** analyze.c source file for additional information.\n*/\nstruct IndexSample {\n  void *p;          /* Pointer to sampled record */\n  int n;            /* Size of record in bytes */\n  tRowcnt *anEq;    /* Est. number of rows where the key equals this sample */\n  tRowcnt *anLt;    /* Est. number of rows where key is less than this sample */\n  tRowcnt *anDLt;   /* Est. number of distinct keys less than this sample */\n};\n\n/*\n** Possible values to use within the flags argument to sqlite3GetToken().\n*/\n#define SQLITE_TOKEN_QUOTED    0x1 /* Token is a quoted identifier. */\n#define SQLITE_TOKEN_KEYWORD   0x2 /* Token is a keyword. */\n\n/*\n** Each token coming out of the lexer is an instance of\n** this structure.  Tokens are also used as part of an expression.\n**\n** The memory that \"z\" points to is owned by other objects.  Take care\n** that the owner of the \"z\" string does not deallocate the string before\n** the Token goes out of scope!  Very often, the \"z\" points to some place\n** in the middle of the Parse.zSql text.  But it might also point to a\n** static string.\n*/\nstruct Token {\n  const char *z;     /* Text of the token.  Not NULL-terminated! */\n  unsigned int n;    /* Number of characters in this token */\n};\n\n/*\n** An instance of this structure contains information needed to generate\n** code for a SELECT that contains aggregate functions.\n**\n** If Expr.op==TK_AGG_COLUMN or TK_AGG_FUNCTION then Expr.pAggInfo is a\n** pointer to this structure.  The Expr.iColumn field is the index in\n** AggInfo.aCol[] or AggInfo.aFunc[] of information needed to generate\n** code for that node.\n**\n** AggInfo.pGroupBy and AggInfo.aFunc.pExpr point to fields within the\n** original Select structure that describes the SELECT statement.  These\n** fields do not need to be freed when deallocating the AggInfo structure.\n*/\nstruct AggInfo {\n  u8 directMode;          /* Direct rendering mode means take data directly\n                          ** from source tables rather than from accumulators */\n  u8 useSortingIdx;       /* In direct mode, reference the sorting index rather\n                          ** than the source table */\n  int sortingIdx;         /* Cursor number of the sorting index */\n  int sortingIdxPTab;     /* Cursor number of pseudo-table */\n  int nSortingColumn;     /* Number of columns in the sorting index */\n  int mnReg, mxReg;       /* Range of registers allocated for aCol and aFunc */\n  ExprList *pGroupBy;     /* The group by clause */\n  struct AggInfo_col {    /* For each column used in source tables */\n    Table *pTab;             /* Source table */\n    int iTable;              /* Cursor number of the source table */\n    int iColumn;             /* Column number within the source table */\n    int iSorterColumn;       /* Column number in the sorting index */\n    int iMem;                /* Memory location that acts as accumulator */\n    Expr *pExpr;             /* The original expression */\n  } *aCol;\n  int nColumn;            /* Number of used entries in aCol[] */\n  int nAccumulator;       /* Number of columns that show through to the output.\n                          ** Additional columns are used only as parameters to\n                          ** aggregate functions */\n  struct AggInfo_func {   /* For each aggregate function */\n    Expr *pExpr;             /* Expression encoding the function */\n    FuncDef *pFunc;          /* The aggregate function implementation */\n    int iMem;                /* Memory location that acts as accumulator */\n    int iDistinct;           /* Ephemeral table used to enforce DISTINCT */\n  } *aFunc;\n  int nFunc;              /* Number of entries in aFunc[] */\n};\n\n/*\n** The datatype ynVar is a signed integer, either 16-bit or 32-bit.\n** Usually it is 16-bits.  But if SQLITE_MAX_VARIABLE_NUMBER is greater\n** than 32767 we have to make it 32-bit.  16-bit is preferred because\n** it uses less memory in the Expr object, which is a big memory user\n** in systems with lots of prepared statements.  And few applications\n** need more than about 10 or 20 variables.  But some extreme users want\n** to have prepared statements with over 32767 variables, and for them\n** the option is available (at compile-time).\n*/\n#if SQLITE_MAX_VARIABLE_NUMBER<=32767\ntypedef i16 ynVar;\n#else\ntypedef int ynVar;\n#endif\n\n/*\n** Each node of an expression in the parse tree is an instance\n** of this structure.\n**\n** Expr.op is the opcode. The integer parser token codes are reused\n** as opcodes here. For example, the parser defines TK_GE to be an integer\n** code representing the \">=\" operator. This same integer code is reused\n** to represent the greater-than-or-equal-to operator in the expression\n** tree.\n**\n** If the expression is an SQL literal (TK_INTEGER, TK_FLOAT, TK_BLOB,\n** or TK_STRING), then Expr.token contains the text of the SQL literal. If\n** the expression is a variable (TK_VARIABLE), then Expr.token contains the\n** variable name. Finally, if the expression is an SQL function (TK_FUNCTION),\n** then Expr.token contains the name of the function.\n**\n** Expr.pRight and Expr.pLeft are the left and right subexpressions of a\n** binary operator. Either or both may be NULL.\n**\n** Expr.x.pList is a list of arguments if the expression is an SQL function,\n** a CASE expression or an IN expression of the form \"<lhs> IN (<y>, <z>...)\".\n** Expr.x.pSelect is used if the expression is a sub-select or an expression of\n** the form \"<lhs> IN (SELECT ...)\". If the EP_xIsSelect bit is set in the\n** Expr.flags mask, then Expr.x.pSelect is valid. Otherwise, Expr.x.pList is\n** valid.\n**\n** An expression of the form ID or ID.ID refers to a column in a table.\n** For such expressions, Expr.op is set to TK_COLUMN and Expr.iTable is\n** the integer cursor number of a VDBE cursor pointing to that table and\n** Expr.iColumn is the column number for the specific column.  If the\n** expression is used as a result in an aggregate SELECT, then the\n** value is also stored in the Expr.iAgg column in the aggregate so that\n** it can be accessed after all aggregates are computed.\n**\n** If the expression is an unbound variable marker (a question mark\n** character '?' in the original SQL) then the Expr.iTable holds the index\n** number for that variable.\n**\n** If the expression is a subquery then Expr.iColumn holds an integer\n** register number containing the result of the subquery.  If the\n** subquery gives a constant result, then iTable is -1.  If the subquery\n** gives a different answer at different times during statement processing\n** then iTable is the address of a subroutine that computes the subquery.\n**\n** If the Expr is of type OP_Column, and the table it is selecting from\n** is a disk table or the \"old.*\" pseudo-table, then pTab points to the\n** corresponding table definition.\n**\n** ALLOCATION NOTES:\n**\n** Expr objects can use a lot of memory space in database schema.  To\n** help reduce memory requirements, sometimes an Expr object will be\n** truncated.  And to reduce the number of memory allocations, sometimes\n** two or more Expr objects will be stored in a single memory allocation,\n** together with Expr.zToken strings.\n**\n** If the EP_Reduced and EP_TokenOnly flags are set when\n** an Expr object is truncated.  When EP_Reduced is set, then all\n** the child Expr objects in the Expr.pLeft and Expr.pRight subtrees\n** are contained within the same memory allocation.  Note, however, that\n** the subtrees in Expr.x.pList or Expr.x.pSelect are always separately\n** allocated, regardless of whether or not EP_Reduced is set.\n*/\nstruct Expr {\n  u8 op;                 /* Operation performed by this node */\n  char affinity;         /* The affinity of the column or 0 if not a column */\n  u32 flags;             /* Various flags.  EP_* See below */\n  union {\n    char *zToken;          /* Token value. Zero terminated and dequoted */\n    int iValue;            /* Non-negative integer value if EP_IntValue */\n  } u;\n\n  /* If the EP_TokenOnly flag is set in the Expr.flags mask, then no\n  ** space is allocated for the fields below this point. An attempt to\n  ** access them will result in a segfault or malfunction.\n  *********************************************************************/\n\n  Expr *pLeft;           /* Left subnode */\n  Expr *pRight;          /* Right subnode */\n  union {\n    ExprList *pList;     /* op = IN, EXISTS, SELECT, CASE, FUNCTION, BETWEEN */\n    Select *pSelect;     /* EP_xIsSelect and op = IN, EXISTS, SELECT */\n  } x;\n\n  /* If the EP_Reduced flag is set in the Expr.flags mask, then no\n  ** space is allocated for the fields below this point. An attempt to\n  ** access them will result in a segfault or malfunction.\n  *********************************************************************/\n\n#if SQLITE_MAX_EXPR_DEPTH>0\n  int nHeight;           /* Height of the tree headed by this node */\n#endif\n  int iTable;            /* TK_COLUMN: cursor number of table holding column\n                         ** TK_REGISTER: register number\n                         ** TK_TRIGGER: 1 -> new, 0 -> old\n                         ** EP_Unlikely:  134217728 times likelihood\n                         ** TK_SELECT: 1st register of result vector */\n  ynVar iColumn;         /* TK_COLUMN: column index.  -1 for rowid.\n                         ** TK_VARIABLE: variable number (always >= 1).\n                         ** TK_SELECT_COLUMN: column of the result vector */\n  i16 iAgg;              /* Which entry in pAggInfo->aCol[] or ->aFunc[] */\n  i16 iRightJoinTable;   /* If EP_FromJoin, the right table of the join */\n  u8 op2;                /* TK_REGISTER: original value of Expr.op\n                         ** TK_COLUMN: the value of p5 for OP_Column\n                         ** TK_AGG_FUNCTION: nesting depth */\n  AggInfo *pAggInfo;     /* Used by TK_AGG_COLUMN and TK_AGG_FUNCTION */\n  union {\n    Table *pTab;           /* TK_COLUMN: Table containing column. Can be NULL\n                           ** for a column of an index on an expression */\n    Window *pWin;          /* TK_FUNCTION: Window definition for the func */\n    struct {               /* TK_IN, TK_SELECT, and TK_EXISTS */\n      int iAddr;             /* Subroutine entry address */\n      int regReturn;         /* Register used to hold return address */\n    } sub;\n  } y;\n};\n\n/*\n** The following are the meanings of bits in the Expr.flags field.\n*/\n#define EP_FromJoin  0x000001 /* Originates in ON/USING clause of outer join */\n#define EP_Agg       0x000002 /* Contains one or more aggregate functions */\n#define EP_HasFunc   0x000004 /* Contains one or more functions of any kind */\n#define EP_FixedCol  0x000008 /* TK_Column with a known fixed value */\n#define EP_Distinct  0x000010 /* Aggregate function with DISTINCT keyword */\n#define EP_VarSelect 0x000020 /* pSelect is correlated, not constant */\n#define EP_DblQuoted 0x000040 /* token.z was originally in \"...\" */\n#define EP_InfixFunc 0x000080 /* True for an infix function: LIKE, GLOB, etc */\n#define EP_Collate   0x000100 /* Tree contains a TK_COLLATE operator */\n#define EP_Generic   0x000200 /* Ignore COLLATE or affinity on this tree */\n#define EP_IntValue  0x000400 /* Integer value contained in u.iValue */\n#define EP_xIsSelect 0x000800 /* x.pSelect is valid (otherwise x.pList is) */\n#define EP_Skip      0x001000 /* COLLATE, AS, or UNLIKELY */\n#define EP_Reduced   0x002000 /* Expr struct EXPR_REDUCEDSIZE bytes only */\n#define EP_TokenOnly 0x004000 /* Expr struct EXPR_TOKENONLYSIZE bytes only */\n#define EP_Static    0x008000 /* Held in memory not obtained from malloc() */\n#define EP_MemToken  0x010000 /* Need to sqlite3DbFree() Expr.zToken */\n#define EP_NoReduce  0x020000 /* Cannot EXPRDUP_REDUCE this Expr */\n#define EP_Unlikely  0x040000 /* unlikely() or likelihood() function */\n#define EP_ConstFunc 0x080000 /* A SQLITE_FUNC_CONSTANT or _SLOCHNG function */\n#define EP_CanBeNull 0x100000 /* Can be null despite NOT NULL constraint */\n#define EP_Subquery  0x200000 /* Tree contains a TK_SELECT operator */\n#define EP_Alias     0x400000 /* Is an alias for a result set column */\n#define EP_Leaf      0x800000 /* Expr.pLeft, .pRight, .u.pSelect all NULL */\n#define EP_WinFunc  0x1000000 /* TK_FUNCTION with Expr.y.pWin set */\n#define EP_Subrtn   0x2000000 /* Uses Expr.y.sub. TK_IN, _SELECT, or _EXISTS */\n#define EP_Quoted   0x4000000 /* TK_ID was originally quoted */\n\n/*\n** The EP_Propagate mask is a set of properties that automatically propagate\n** upwards into parent nodes.\n*/\n#define EP_Propagate (EP_Collate|EP_Subquery|EP_HasFunc)\n\n/*\n** These macros can be used to test, set, or clear bits in the\n** Expr.flags field.\n*/\n#define ExprHasProperty(E,P)     (((E)->flags&(P))!=0)\n#define ExprHasAllProperty(E,P)  (((E)->flags&(P))==(P))\n#define ExprSetProperty(E,P)     (E)->flags|=(P)\n#define ExprClearProperty(E,P)   (E)->flags&=~(P)\n\n/* The ExprSetVVAProperty() macro is used for Verification, Validation,\n** and Accreditation only.  It works like ExprSetProperty() during VVA\n** processes but is a no-op for delivery.\n*/\n#ifdef SQLITE_DEBUG\n# define ExprSetVVAProperty(E,P)  (E)->flags|=(P)\n#else\n# define ExprSetVVAProperty(E,P)\n#endif\n\n/*\n** Macros to determine the number of bytes required by a normal Expr\n** struct, an Expr struct with the EP_Reduced flag set in Expr.flags\n** and an Expr struct with the EP_TokenOnly flag set.\n*/\n#define EXPR_FULLSIZE           sizeof(Expr)           /* Full size */\n#define EXPR_REDUCEDSIZE        offsetof(Expr,iTable)  /* Common features */\n#define EXPR_TOKENONLYSIZE      offsetof(Expr,pLeft)   /* Fewer features */\n\n/*\n** Flags passed to the sqlite3ExprDup() function. See the header comment\n** above sqlite3ExprDup() for details.\n*/\n#define EXPRDUP_REDUCE         0x0001  /* Used reduced-size Expr nodes */\n\n/*\n** A list of expressions.  Each expression may optionally have a\n** name.  An expr/name combination can be used in several ways, such\n** as the list of \"expr AS ID\" fields following a \"SELECT\" or in the\n** list of \"ID = expr\" items in an UPDATE.  A list of expressions can\n** also be used as the argument to a function, in which case the a.zName\n** field is not used.\n**\n** By default the Expr.zSpan field holds a human-readable description of\n** the expression that is used in the generation of error messages and\n** column labels.  In this case, Expr.zSpan is typically the text of a\n** column expression as it exists in a SELECT statement.  However, if\n** the bSpanIsTab flag is set, then zSpan is overloaded to mean the name\n** of the result column in the form: DATABASE.TABLE.COLUMN.  This later\n** form is used for name resolution with nested FROM clauses.\n*/\nstruct ExprList {\n  int nExpr;             /* Number of expressions on the list */\n  struct ExprList_item { /* For each expression in the list */\n    Expr *pExpr;            /* The parse tree for this expression */\n    char *zName;            /* Token associated with this expression */\n    char *zSpan;            /* Original text of the expression */\n    u8 sortOrder;           /* 1 for DESC or 0 for ASC */\n    unsigned done :1;       /* A flag to indicate when processing is finished */\n    unsigned bSpanIsTab :1; /* zSpan holds DB.TABLE.COLUMN */\n    unsigned reusable :1;   /* Constant expression is reusable */\n    unsigned bSorterRef :1; /* Defer evaluation until after sorting */\n    union {\n      struct {\n        u16 iOrderByCol;      /* For ORDER BY, column number in result set */\n        u16 iAlias;           /* Index into Parse.aAlias[] for zName */\n      } x;\n      int iConstExprReg;      /* Register in which Expr value is cached */\n    } u;\n  } a[1];                  /* One slot for each expression in the list */\n};\n\n/*\n** An instance of this structure can hold a simple list of identifiers,\n** such as the list \"a,b,c\" in the following statements:\n**\n**      INSERT INTO t(a,b,c) VALUES ...;\n**      CREATE INDEX idx ON t(a,b,c);\n**      CREATE TRIGGER trig BEFORE UPDATE ON t(a,b,c) ...;\n**\n** The IdList.a.idx field is used when the IdList represents the list of\n** column names after a table name in an INSERT statement.  In the statement\n**\n**     INSERT INTO t(a,b,c) ...\n**\n** If \"a\" is the k-th column of table \"t\", then IdList.a[0].idx==k.\n*/\nstruct IdList {\n  struct IdList_item {\n    char *zName;      /* Name of the identifier */\n    int idx;          /* Index in some Table.aCol[] of a column named zName */\n  } *a;\n  int nId;         /* Number of identifiers on the list */\n};\n\n/*\n** The following structure describes the FROM clause of a SELECT statement.\n** Each table or subquery in the FROM clause is a separate element of\n** the SrcList.a[] array.\n**\n** With the addition of multiple database support, the following structure\n** can also be used to describe a particular table such as the table that\n** is modified by an INSERT, DELETE, or UPDATE statement.  In standard SQL,\n** such a table must be a simple name: ID.  But in SQLite, the table can\n** now be identified by a database name, a dot, then the table name: ID.ID.\n**\n** The jointype starts out showing the join type between the current table\n** and the next table on the list.  The parser builds the list this way.\n** But sqlite3SrcListShiftJoinType() later shifts the jointypes so that each\n** jointype expresses the join between the table and the previous table.\n**\n** In the colUsed field, the high-order bit (bit 63) is set if the table\n** contains more than 63 columns and the 64-th or later column is used.\n*/\nstruct SrcList {\n  int nSrc;        /* Number of tables or subqueries in the FROM clause */\n  u32 nAlloc;      /* Number of entries allocated in a[] below */\n  struct SrcList_item {\n    Schema *pSchema;  /* Schema to which this item is fixed */\n    char *zDatabase;  /* Name of database holding this table */\n    char *zName;      /* Name of the table */\n    char *zAlias;     /* The \"B\" part of a \"A AS B\" phrase.  zName is the \"A\" */\n    Table *pTab;      /* An SQL table corresponding to zName */\n    Select *pSelect;  /* A SELECT statement used in place of a table name */\n    int addrFillSub;  /* Address of subroutine to manifest a subquery */\n    int regReturn;    /* Register holding return address of addrFillSub */\n    int regResult;    /* Registers holding results of a co-routine */\n    struct {\n      u8 jointype;      /* Type of join between this table and the previous */\n      unsigned notIndexed :1;    /* True if there is a NOT INDEXED clause */\n      unsigned isIndexedBy :1;   /* True if there is an INDEXED BY clause */\n      unsigned isTabFunc :1;     /* True if table-valued-function syntax */\n      unsigned isCorrelated :1;  /* True if sub-query is correlated */\n      unsigned viaCoroutine :1;  /* Implemented as a co-routine */\n      unsigned isRecursive :1;   /* True for recursive reference in WITH */\n    } fg;\n    int iCursor;      /* The VDBE cursor number used to access this table */\n    Expr *pOn;        /* The ON clause of a join */\n    IdList *pUsing;   /* The USING clause of a join */\n    Bitmask colUsed;  /* Bit N (1<<N) set if column N of pTab is used */\n    union {\n      char *zIndexedBy;    /* Identifier from \"INDEXED BY <zIndex>\" clause */\n      ExprList *pFuncArg;  /* Arguments to table-valued-function */\n    } u1;\n    Index *pIBIndex;  /* Index structure corresponding to u1.zIndexedBy */\n  } a[1];             /* One entry for each identifier on the list */\n};\n\n/*\n** Permitted values of the SrcList.a.jointype field\n*/\n#define JT_INNER     0x0001    /* Any kind of inner or cross join */\n#define JT_CROSS     0x0002    /* Explicit use of the CROSS keyword */\n#define JT_NATURAL   0x0004    /* True for a \"natural\" join */\n#define JT_LEFT      0x0008    /* Left outer join */\n#define JT_RIGHT     0x0010    /* Right outer join */\n#define JT_OUTER     0x0020    /* The \"OUTER\" keyword is present */\n#define JT_ERROR     0x0040    /* unknown or unsupported join type */\n\n\n/*\n** Flags appropriate for the wctrlFlags parameter of sqlite3WhereBegin()\n** and the WhereInfo.wctrlFlags member.\n**\n** Value constraints (enforced via assert()):\n**     WHERE_USE_LIMIT  == SF_FixedLimit\n*/\n#define WHERE_ORDERBY_NORMAL   0x0000 /* No-op */\n#define WHERE_ORDERBY_MIN      0x0001 /* ORDER BY processing for min() func */\n#define WHERE_ORDERBY_MAX      0x0002 /* ORDER BY processing for max() func */\n#define WHERE_ONEPASS_DESIRED  0x0004 /* Want to do one-pass UPDATE/DELETE */\n#define WHERE_ONEPASS_MULTIROW 0x0008 /* ONEPASS is ok with multiple rows */\n#define WHERE_DUPLICATES_OK    0x0010 /* Ok to return a row more than once */\n#define WHERE_OR_SUBCLAUSE     0x0020 /* Processing a sub-WHERE as part of\n                                      ** the OR optimization  */\n#define WHERE_GROUPBY          0x0040 /* pOrderBy is really a GROUP BY */\n#define WHERE_DISTINCTBY       0x0080 /* pOrderby is really a DISTINCT clause */\n#define WHERE_WANT_DISTINCT    0x0100 /* All output needs to be distinct */\n#define WHERE_SORTBYGROUP      0x0200 /* Support sqlite3WhereIsSorted() */\n#define WHERE_SEEK_TABLE       0x0400 /* Do not defer seeks on main table */\n#define WHERE_ORDERBY_LIMIT    0x0800 /* ORDERBY+LIMIT on the inner loop */\n#define WHERE_SEEK_UNIQ_TABLE  0x1000 /* Do not defer seeks if unique */\n                        /*     0x2000    not currently used */\n#define WHERE_USE_LIMIT        0x4000 /* Use the LIMIT in cost estimates */\n                        /*     0x8000    not currently used */\n\n/* Allowed return values from sqlite3WhereIsDistinct()\n*/\n#define WHERE_DISTINCT_NOOP      0  /* DISTINCT keyword not used */\n#define WHERE_DISTINCT_UNIQUE    1  /* No duplicates */\n#define WHERE_DISTINCT_ORDERED   2  /* All duplicates are adjacent */\n#define WHERE_DISTINCT_UNORDERED 3  /* Duplicates are scattered */\n\n/*\n** A NameContext defines a context in which to resolve table and column\n** names.  The context consists of a list of tables (the pSrcList) field and\n** a list of named expression (pEList).  The named expression list may\n** be NULL.  The pSrc corresponds to the FROM clause of a SELECT or\n** to the table being operated on by INSERT, UPDATE, or DELETE.  The\n** pEList corresponds to the result set of a SELECT and is NULL for\n** other statements.\n**\n** NameContexts can be nested.  When resolving names, the inner-most\n** context is searched first.  If no match is found, the next outer\n** context is checked.  If there is still no match, the next context\n** is checked.  This process continues until either a match is found\n** or all contexts are check.  When a match is found, the nRef member of\n** the context containing the match is incremented.\n**\n** Each subquery gets a new NameContext.  The pNext field points to the\n** NameContext in the parent query.  Thus the process of scanning the\n** NameContext list corresponds to searching through successively outer\n** subqueries looking for a match.\n*/\nstruct NameContext {\n  Parse *pParse;       /* The parser */\n  SrcList *pSrcList;   /* One or more tables used to resolve names */\n  union {\n    ExprList *pEList;    /* Optional list of result-set columns */\n    AggInfo *pAggInfo;   /* Information about aggregates at this level */\n    Upsert *pUpsert;     /* ON CONFLICT clause information from an upsert */\n  } uNC;\n  NameContext *pNext;  /* Next outer name context.  NULL for outermost */\n  int nRef;            /* Number of names resolved by this context */\n  int nErr;            /* Number of errors encountered while resolving names */\n  u16 ncFlags;         /* Zero or more NC_* flags defined below */\n  Select *pWinSelect;  /* SELECT statement for any window functions */\n};\n\n/*\n** Allowed values for the NameContext, ncFlags field.\n**\n** Value constraints (all checked via assert()):\n**    NC_HasAgg    == SF_HasAgg\n**    NC_MinMaxAgg == SF_MinMaxAgg == SQLITE_FUNC_MINMAX\n**\n*/\n#define NC_AllowAgg  0x0001  /* Aggregate functions are allowed here */\n#define NC_PartIdx   0x0002  /* True if resolving a partial index WHERE */\n#define NC_IsCheck   0x0004  /* True if resolving names in a CHECK constraint */\n#define NC_InAggFunc 0x0008  /* True if analyzing arguments to an agg func */\n#define NC_HasAgg    0x0010  /* One or more aggregate functions seen */\n#define NC_IdxExpr   0x0020  /* True if resolving columns of CREATE INDEX */\n#define NC_VarSelect 0x0040  /* A correlated subquery has been seen */\n#define NC_UEList    0x0080  /* True if uNC.pEList is used */\n#define NC_UAggInfo  0x0100  /* True if uNC.pAggInfo is used */\n#define NC_UUpsert   0x0200  /* True if uNC.pUpsert is used */\n#define NC_MinMaxAgg 0x1000  /* min/max aggregates seen.  See note above */\n#define NC_Complex   0x2000  /* True if a function or subquery seen */\n#define NC_AllowWin  0x4000  /* Window functions are allowed here */\n\n/*\n** An instance of the following object describes a single ON CONFLICT\n** clause in an upsert.\n**\n** The pUpsertTarget field is only set if the ON CONFLICT clause includes\n** conflict-target clause.  (In \"ON CONFLICT(a,b)\" the \"(a,b)\" is the\n** conflict-target clause.)  The pUpsertTargetWhere is the optional\n** WHERE clause used to identify partial unique indexes.\n**\n** pUpsertSet is the list of column=expr terms of the UPDATE statement. \n** The pUpsertSet field is NULL for a ON CONFLICT DO NOTHING.  The\n** pUpsertWhere is the WHERE clause for the UPDATE and is NULL if the\n** WHERE clause is omitted.\n*/\nstruct Upsert {\n  ExprList *pUpsertTarget;  /* Optional description of conflicting index */\n  Expr *pUpsertTargetWhere; /* WHERE clause for partial index targets */\n  ExprList *pUpsertSet;     /* The SET clause from an ON CONFLICT UPDATE */\n  Expr *pUpsertWhere;       /* WHERE clause for the ON CONFLICT UPDATE */\n  /* The fields above comprise the parse tree for the upsert clause.\n  ** The fields below are used to transfer information from the INSERT\n  ** processing down into the UPDATE processing while generating code.\n  ** Upsert owns the memory allocated above, but not the memory below. */\n  Index *pUpsertIdx;        /* Constraint that pUpsertTarget identifies */\n  SrcList *pUpsertSrc;      /* Table to be updated */\n  int regData;              /* First register holding array of VALUES */\n  int iDataCur;             /* Index of the data cursor */\n  int iIdxCur;              /* Index of the first index cursor */\n};\n\n/*\n** An instance of the following structure contains all information\n** needed to generate code for a single SELECT statement.\n**\n** See the header comment on the computeLimitRegisters() routine for a\n** detailed description of the meaning of the iLimit and iOffset fields.\n**\n** addrOpenEphm[] entries contain the address of OP_OpenEphemeral opcodes.\n** These addresses must be stored so that we can go back and fill in\n** the P4_KEYINFO and P2 parameters later.  Neither the KeyInfo nor\n** the number of columns in P2 can be computed at the same time\n** as the OP_OpenEphm instruction is coded because not\n** enough information about the compound query is known at that point.\n** The KeyInfo for addrOpenTran[0] and [1] contains collating sequences\n** for the result set.  The KeyInfo for addrOpenEphm[2] contains collating\n** sequences for the ORDER BY clause.\n*/\nstruct Select {\n  ExprList *pEList;      /* The fields of the result */\n  u8 op;                 /* One of: TK_UNION TK_ALL TK_INTERSECT TK_EXCEPT */\n  LogEst nSelectRow;     /* Estimated number of result rows */\n  u32 selFlags;          /* Various SF_* values */\n  int iLimit, iOffset;   /* Memory registers holding LIMIT & OFFSET counters */\n  u32 selId;             /* Unique identifier number for this SELECT */\n  int addrOpenEphm[2];   /* OP_OpenEphem opcodes related to this select */\n  SrcList *pSrc;         /* The FROM clause */\n  Expr *pWhere;          /* The WHERE clause */\n  ExprList *pGroupBy;    /* The GROUP BY clause */\n  Expr *pHaving;         /* The HAVING clause */\n  ExprList *pOrderBy;    /* The ORDER BY clause */\n  Select *pPrior;        /* Prior select in a compound select statement */\n  Select *pNext;         /* Next select to the left in a compound */\n  Expr *pLimit;          /* LIMIT expression. NULL means not used. */\n  With *pWith;           /* WITH clause attached to this select. Or NULL. */\n#ifndef SQLITE_OMIT_WINDOWFUNC\n  Window *pWin;          /* List of window functions */\n  Window *pWinDefn;      /* List of named window definitions */\n#endif\n};\n\n/*\n** Allowed values for Select.selFlags.  The \"SF\" prefix stands for\n** \"Select Flag\".\n**\n** Value constraints (all checked via assert())\n**     SF_HasAgg     == NC_HasAgg\n**     SF_MinMaxAgg  == NC_MinMaxAgg     == SQLITE_FUNC_MINMAX\n**     SF_FixedLimit == WHERE_USE_LIMIT\n*/\n#define SF_Distinct       0x00001  /* Output should be DISTINCT */\n#define SF_All            0x00002  /* Includes the ALL keyword */\n#define SF_Resolved       0x00004  /* Identifiers have been resolved */\n#define SF_Aggregate      0x00008  /* Contains agg functions or a GROUP BY */\n#define SF_HasAgg         0x00010  /* Contains aggregate functions */\n#define SF_UsesEphemeral  0x00020  /* Uses the OpenEphemeral opcode */\n#define SF_Expanded       0x00040  /* sqlite3SelectExpand() called on this */\n#define SF_HasTypeInfo    0x00080  /* FROM subqueries have Table metadata */\n#define SF_Compound       0x00100  /* Part of a compound query */\n#define SF_Values         0x00200  /* Synthesized from VALUES clause */\n#define SF_MultiValue     0x00400  /* Single VALUES term with multiple rows */\n#define SF_NestedFrom     0x00800  /* Part of a parenthesized FROM clause */\n#define SF_MinMaxAgg      0x01000  /* Aggregate containing min() or max() */\n#define SF_Recursive      0x02000  /* The recursive part of a recursive CTE */\n#define SF_FixedLimit     0x04000  /* nSelectRow set by a constant LIMIT */\n#define SF_MaybeConvert   0x08000  /* Need convertCompoundSelectToSubquery() */\n#define SF_Converted      0x10000  /* By convertCompoundSelectToSubquery() */\n#define SF_IncludeHidden  0x20000  /* Include hidden columns in output */\n#define SF_ComplexResult  0x40000  /* Result contains subquery or function */\n\n/*\n** The results of a SELECT can be distributed in several ways, as defined\n** by one of the following macros.  The \"SRT\" prefix means \"SELECT Result\n** Type\".\n**\n**     SRT_Union       Store results as a key in a temporary index\n**                     identified by pDest->iSDParm.\n**\n**     SRT_Except      Remove results from the temporary index pDest->iSDParm.\n**\n**     SRT_Exists      Store a 1 in memory cell pDest->iSDParm if the result\n**                     set is not empty.\n**\n**     SRT_Discard     Throw the results away.  This is used by SELECT\n**                     statements within triggers whose only purpose is\n**                     the side-effects of functions.\n**\n** All of the above are free to ignore their ORDER BY clause. Those that\n** follow must honor the ORDER BY clause.\n**\n**     SRT_Output      Generate a row of output (using the OP_ResultRow\n**                     opcode) for each row in the result set.\n**\n**     SRT_Mem         Only valid if the result is a single column.\n**                     Store the first column of the first result row\n**                     in register pDest->iSDParm then abandon the rest\n**                     of the query.  This destination implies \"LIMIT 1\".\n**\n**     SRT_Set         The result must be a single column.  Store each\n**                     row of result as the key in table pDest->iSDParm.\n**                     Apply the affinity pDest->affSdst before storing\n**                     results.  Used to implement \"IN (SELECT ...)\".\n**\n**     SRT_EphemTab    Create an temporary table pDest->iSDParm and store\n**                     the result there. The cursor is left open after\n**                     returning.  This is like SRT_Table except that\n**                     this destination uses OP_OpenEphemeral to create\n**                     the table first.\n**\n**     SRT_Coroutine   Generate a co-routine that returns a new row of\n**                     results each time it is invoked.  The entry point\n**                     of the co-routine is stored in register pDest->iSDParm\n**                     and the result row is stored in pDest->nDest registers\n**                     starting with pDest->iSdst.\n**\n**     SRT_Table       Store results in temporary table pDest->iSDParm.\n**     SRT_Fifo        This is like SRT_EphemTab except that the table\n**                     is assumed to already be open.  SRT_Fifo has\n**                     the additional property of being able to ignore\n**                     the ORDER BY clause.\n**\n**     SRT_DistFifo    Store results in a temporary table pDest->iSDParm.\n**                     But also use temporary table pDest->iSDParm+1 as\n**                     a record of all prior results and ignore any duplicate\n**                     rows.  Name means:  \"Distinct Fifo\".\n**\n**     SRT_Queue       Store results in priority queue pDest->iSDParm (really\n**                     an index).  Append a sequence number so that all entries\n**                     are distinct.\n**\n**     SRT_DistQueue   Store results in priority queue pDest->iSDParm only if\n**                     the same record has never been stored before.  The\n**                     index at pDest->iSDParm+1 hold all prior stores.\n*/\n#define SRT_Union        1  /* Store result as keys in an index */\n#define SRT_Except       2  /* Remove result from a UNION index */\n#define SRT_Exists       3  /* Store 1 if the result is not empty */\n#define SRT_Discard      4  /* Do not save the results anywhere */\n#define SRT_Fifo         5  /* Store result as data with an automatic rowid */\n#define SRT_DistFifo     6  /* Like SRT_Fifo, but unique results only */\n#define SRT_Queue        7  /* Store result in an queue */\n#define SRT_DistQueue    8  /* Like SRT_Queue, but unique results only */\n\n/* The ORDER BY clause is ignored for all of the above */\n#define IgnorableOrderby(X) ((X->eDest)<=SRT_DistQueue)\n\n#define SRT_Output       9  /* Output each row of result */\n#define SRT_Mem         10  /* Store result in a memory cell */\n#define SRT_Set         11  /* Store results as keys in an index */\n#define SRT_EphemTab    12  /* Create transient tab and store like SRT_Table */\n#define SRT_Coroutine   13  /* Generate a single row of result */\n#define SRT_Table       14  /* Store result as data with an automatic rowid */\n\n/*\n** An instance of this object describes where to put of the results of\n** a SELECT statement.\n*/\nstruct SelectDest {\n  u8 eDest;            /* How to dispose of the results.  On of SRT_* above. */\n  int iSDParm;         /* A parameter used by the eDest disposal method */\n  int iSdst;           /* Base register where results are written */\n  int nSdst;           /* Number of registers allocated */\n  char *zAffSdst;      /* Affinity used when eDest==SRT_Set */\n  ExprList *pOrderBy;  /* Key columns for SRT_Queue and SRT_DistQueue */\n};\n\n/*\n** During code generation of statements that do inserts into AUTOINCREMENT\n** tables, the following information is attached to the Table.u.autoInc.p\n** pointer of each autoincrement table to record some side information that\n** the code generator needs.  We have to keep per-table autoincrement\n** information in case inserts are done within triggers.  Triggers do not\n** normally coordinate their activities, but we do need to coordinate the\n** loading and saving of autoincrement information.\n*/\nstruct AutoincInfo {\n  AutoincInfo *pNext;   /* Next info block in a list of them all */\n  Table *pTab;          /* Table this info block refers to */\n  int iDb;              /* Index in sqlite3.aDb[] of database holding pTab */\n  int regCtr;           /* Memory register holding the rowid counter */\n};\n\n/*\n** At least one instance of the following structure is created for each\n** trigger that may be fired while parsing an INSERT, UPDATE or DELETE\n** statement. All such objects are stored in the linked list headed at\n** Parse.pTriggerPrg and deleted once statement compilation has been\n** completed.\n**\n** A Vdbe sub-program that implements the body and WHEN clause of trigger\n** TriggerPrg.pTrigger, assuming a default ON CONFLICT clause of\n** TriggerPrg.orconf, is stored in the TriggerPrg.pProgram variable.\n** The Parse.pTriggerPrg list never contains two entries with the same\n** values for both pTrigger and orconf.\n**\n** The TriggerPrg.aColmask[0] variable is set to a mask of old.* columns\n** accessed (or set to 0 for triggers fired as a result of INSERT\n** statements). Similarly, the TriggerPrg.aColmask[1] variable is set to\n** a mask of new.* columns used by the program.\n*/\nstruct TriggerPrg {\n  Trigger *pTrigger;      /* Trigger this program was coded from */\n  TriggerPrg *pNext;      /* Next entry in Parse.pTriggerPrg list */\n  SubProgram *pProgram;   /* Program implementing pTrigger/orconf */\n  int orconf;             /* Default ON CONFLICT policy */\n  u32 aColmask[2];        /* Masks of old.*, new.* columns accessed */\n};\n\n/*\n** The yDbMask datatype for the bitmask of all attached databases.\n*/\n#if SQLITE_MAX_ATTACHED>30\n  typedef unsigned char yDbMask[(SQLITE_MAX_ATTACHED+9)/8];\n# define DbMaskTest(M,I)    (((M)[(I)/8]&(1<<((I)&7)))!=0)\n# define DbMaskZero(M)      memset((M),0,sizeof(M))\n# define DbMaskSet(M,I)     (M)[(I)/8]|=(1<<((I)&7))\n# define DbMaskAllZero(M)   sqlite3DbMaskAllZero(M)\n# define DbMaskNonZero(M)   (sqlite3DbMaskAllZero(M)==0)\n#else\n  typedef unsigned int yDbMask;\n# define DbMaskTest(M,I)    (((M)&(((yDbMask)1)<<(I)))!=0)\n# define DbMaskZero(M)      (M)=0\n# define DbMaskSet(M,I)     (M)|=(((yDbMask)1)<<(I))\n# define DbMaskAllZero(M)   (M)==0\n# define DbMaskNonZero(M)   (M)!=0\n#endif\n\n/*\n** An SQL parser context.  A copy of this structure is passed through\n** the parser and down into all the parser action routine in order to\n** carry around information that is global to the entire parse.\n**\n** The structure is divided into two parts.  When the parser and code\n** generate call themselves recursively, the first part of the structure\n** is constant but the second part is reset at the beginning and end of\n** each recursion.\n**\n** The nTableLock and aTableLock variables are only used if the shared-cache\n** feature is enabled (if sqlite3Tsd()->useSharedData is true). They are\n** used to store the set of table-locks required by the statement being\n** compiled. Function sqlite3TableLock() is used to add entries to the\n** list.\n*/\nstruct Parse {\n  sqlite3 *db;         /* The main database structure */\n  char *zErrMsg;       /* An error message */\n  Vdbe *pVdbe;         /* An engine for executing database bytecode */\n  int rc;              /* Return code from execution */\n  u8 colNamesSet;      /* TRUE after OP_ColumnName has been issued to pVdbe */\n  u8 checkSchema;      /* Causes schema cookie check after an error */\n  u8 nested;           /* Number of nested calls to the parser/code generator */\n  u8 nTempReg;         /* Number of temporary registers in aTempReg[] */\n  u8 isMultiWrite;     /* True if statement may modify/insert multiple rows */\n  u8 mayAbort;         /* True if statement may throw an ABORT exception */\n  u8 hasCompound;      /* Need to invoke convertCompoundSelectToSubquery() */\n  u8 okConstFactor;    /* OK to factor out constants */\n  u8 disableLookaside; /* Number of times lookaside has been disabled */\n  u8 disableVtab;      /* Disable all virtual tables for this parse */\n  int nRangeReg;       /* Size of the temporary register block */\n  int iRangeReg;       /* First register in temporary register block */\n  int nErr;            /* Number of errors seen */\n  int nTab;            /* Number of previously allocated VDBE cursors */\n  int nMem;            /* Number of memory cells used so far */\n  int szOpAlloc;       /* Bytes of memory space allocated for Vdbe.aOp[] */\n  int iSelfTab;        /* Table associated with an index on expr, or negative\n                       ** of the base register during check-constraint eval */\n  int nLabel;          /* The *negative* of the number of labels used */\n  int nLabelAlloc;     /* Number of slots in aLabel */\n  int *aLabel;         /* Space to hold the labels */\n  ExprList *pConstExpr;/* Constant expressions */\n  Token constraintName;/* Name of the constraint currently being parsed */\n  yDbMask writeMask;   /* Start a write transaction on these databases */\n  yDbMask cookieMask;  /* Bitmask of schema verified databases */\n  int regRowid;        /* Register holding rowid of CREATE TABLE entry */\n  int regRoot;         /* Register holding root page number for new objects */\n  int nMaxArg;         /* Max args passed to user function by sub-program */\n  int nSelect;         /* Number of SELECT stmts. Counter for Select.selId */\n#ifndef SQLITE_OMIT_SHARED_CACHE\n  int nTableLock;        /* Number of locks in aTableLock */\n  TableLock *aTableLock; /* Required table locks for shared-cache mode */\n#endif\n  AutoincInfo *pAinc;  /* Information about AUTOINCREMENT counters */\n  Parse *pToplevel;    /* Parse structure for main program (or NULL) */\n  Table *pTriggerTab;  /* Table triggers are being coded for */\n  int addrCrTab;       /* Address of OP_CreateBtree opcode on CREATE TABLE */\n  u32 nQueryLoop;      /* Est number of iterations of a query (10*log2(N)) */\n  u32 oldmask;         /* Mask of old.* columns referenced */\n  u32 newmask;         /* Mask of new.* columns referenced */\n  u8 eTriggerOp;       /* TK_UPDATE, TK_INSERT or TK_DELETE */\n  u8 eOrconf;          /* Default ON CONFLICT policy for trigger steps */\n  u8 disableTriggers;  /* True to disable triggers */\n\n  /**************************************************************************\n  ** Fields above must be initialized to zero.  The fields that follow,\n  ** down to the beginning of the recursive section, do not need to be\n  ** initialized as they will be set before being used.  The boundary is\n  ** determined by offsetof(Parse,aTempReg).\n  **************************************************************************/\n\n  int aTempReg[8];        /* Holding area for temporary registers */\n  Token sNameToken;       /* Token with unqualified schema object name */\n\n  /************************************************************************\n  ** Above is constant between recursions.  Below is reset before and after\n  ** each recursion.  The boundary between these two regions is determined\n  ** using offsetof(Parse,sLastToken) so the sLastToken field must be the\n  ** first field in the recursive region.\n  ************************************************************************/\n\n  Token sLastToken;       /* The last token parsed */\n  ynVar nVar;               /* Number of '?' variables seen in the SQL so far */\n  u8 iPkSortOrder;          /* ASC or DESC for INTEGER PRIMARY KEY */\n  u8 explain;               /* True if the EXPLAIN flag is found on the query */\n#if !(defined(SQLITE_OMIT_VIRTUALTABLE) && defined(SQLITE_OMIT_ALTERTABLE))\n  u8 eParseMode;            /* PARSE_MODE_XXX constant */\n#endif\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n  int nVtabLock;            /* Number of virtual tables to lock */\n#endif\n  int nHeight;              /* Expression tree height of current sub-select */\n#ifndef SQLITE_OMIT_EXPLAIN\n  int addrExplain;          /* Address of current OP_Explain opcode */\n#endif\n  VList *pVList;            /* Mapping between variable names and numbers */\n  Vdbe *pReprepare;         /* VM being reprepared (sqlite3Reprepare()) */\n  const char *zTail;        /* All SQL text past the last semicolon parsed */\n  Table *pNewTable;         /* A table being constructed by CREATE TABLE */\n  Index *pNewIndex;         /* An index being constructed by CREATE INDEX.\n                            ** Also used to hold redundant UNIQUE constraints\n                            ** during a RENAME COLUMN */\n  Trigger *pNewTrigger;     /* Trigger under construct by a CREATE TRIGGER */\n  const char *zAuthContext; /* The 6th parameter to db->xAuth callbacks */\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n  Token sArg;               /* Complete text of a module argument */\n  Table **apVtabLock;       /* Pointer to virtual tables needing locking */\n#endif\n  Table *pZombieTab;        /* List of Table objects to delete after code gen */\n  TriggerPrg *pTriggerPrg;  /* Linked list of coded triggers */\n  With *pWith;              /* Current WITH clause, or NULL */\n  With *pWithToFree;        /* Free this WITH object at the end of the parse */\n#ifndef SQLITE_OMIT_ALTERTABLE\n  RenameToken *pRename;     /* Tokens subject to renaming by ALTER TABLE */\n#endif\n};\n\n#define PARSE_MODE_NORMAL        0\n#define PARSE_MODE_DECLARE_VTAB  1\n#define PARSE_MODE_RENAME_COLUMN 2\n#define PARSE_MODE_RENAME_TABLE  3\n\n/*\n** Sizes and pointers of various parts of the Parse object.\n*/\n#define PARSE_HDR_SZ offsetof(Parse,aTempReg) /* Recursive part w/o aColCache*/\n#define PARSE_RECURSE_SZ offsetof(Parse,sLastToken)    /* Recursive part */\n#define PARSE_TAIL_SZ (sizeof(Parse)-PARSE_RECURSE_SZ) /* Non-recursive part */\n#define PARSE_TAIL(X) (((char*)(X))+PARSE_RECURSE_SZ)  /* Pointer to tail */\n\n/*\n** Return true if currently inside an sqlite3_declare_vtab() call.\n*/\n#ifdef SQLITE_OMIT_VIRTUALTABLE\n  #define IN_DECLARE_VTAB 0\n#else\n  #define IN_DECLARE_VTAB (pParse->eParseMode==PARSE_MODE_DECLARE_VTAB)\n#endif\n\n#if defined(SQLITE_OMIT_ALTERTABLE)\n  #define IN_RENAME_OBJECT 0\n#else\n  #define IN_RENAME_OBJECT (pParse->eParseMode>=PARSE_MODE_RENAME_COLUMN)\n#endif\n\n#if defined(SQLITE_OMIT_VIRTUALTABLE) && defined(SQLITE_OMIT_ALTERTABLE)\n  #define IN_SPECIAL_PARSE 0\n#else\n  #define IN_SPECIAL_PARSE (pParse->eParseMode!=PARSE_MODE_NORMAL)\n#endif\n\n/*\n** An instance of the following structure can be declared on a stack and used\n** to save the Parse.zAuthContext value so that it can be restored later.\n*/\nstruct AuthContext {\n  const char *zAuthContext;   /* Put saved Parse.zAuthContext here */\n  Parse *pParse;              /* The Parse structure */\n};\n\n/*\n** Bitfield flags for P5 value in various opcodes.\n**\n** Value constraints (enforced via assert()):\n**    OPFLAG_LENGTHARG    == SQLITE_FUNC_LENGTH\n**    OPFLAG_TYPEOFARG    == SQLITE_FUNC_TYPEOF\n**    OPFLAG_BULKCSR      == BTREE_BULKLOAD\n**    OPFLAG_SEEKEQ       == BTREE_SEEK_EQ\n**    OPFLAG_FORDELETE    == BTREE_FORDELETE\n**    OPFLAG_SAVEPOSITION == BTREE_SAVEPOSITION\n**    OPFLAG_AUXDELETE    == BTREE_AUXDELETE\n*/\n#define OPFLAG_NCHANGE       0x01    /* OP_Insert: Set to update db->nChange */\n                                     /* Also used in P2 (not P5) of OP_Delete */\n#define OPFLAG_NOCHNG        0x01    /* OP_VColumn nochange for UPDATE */\n#define OPFLAG_EPHEM         0x01    /* OP_Column: Ephemeral output is ok */\n#define OPFLAG_LASTROWID     0x20    /* Set to update db->lastRowid */\n#define OPFLAG_ISUPDATE      0x04    /* This OP_Insert is an sql UPDATE */\n#define OPFLAG_APPEND        0x08    /* This is likely to be an append */\n#define OPFLAG_USESEEKRESULT 0x10    /* Try to avoid a seek in BtreeInsert() */\n#define OPFLAG_ISNOOP        0x40    /* OP_Delete does pre-update-hook only */\n#define OPFLAG_LENGTHARG     0x40    /* OP_Column only used for length() */\n#define OPFLAG_TYPEOFARG     0x80    /* OP_Column only used for typeof() */\n#define OPFLAG_BULKCSR       0x01    /* OP_Open** used to open bulk cursor */\n#define OPFLAG_SEEKEQ        0x02    /* OP_Open** cursor uses EQ seek only */\n#define OPFLAG_FORDELETE     0x08    /* OP_Open should use BTREE_FORDELETE */\n#define OPFLAG_P2ISREG       0x10    /* P2 to OP_Open** is a register number */\n#define OPFLAG_PERMUTE       0x01    /* OP_Compare: use the permutation */\n#define OPFLAG_SAVEPOSITION  0x02    /* OP_Delete/Insert: save cursor pos */\n#define OPFLAG_AUXDELETE     0x04    /* OP_Delete: index in a DELETE op */\n#define OPFLAG_NOCHNG_MAGIC  0x6d    /* OP_MakeRecord: serialtype 10 is ok */\n\n/*\n * Each trigger present in the database schema is stored as an instance of\n * struct Trigger.\n *\n * Pointers to instances of struct Trigger are stored in two ways.\n * 1. In the \"trigHash\" hash table (part of the sqlite3* that represents the\n *    database). This allows Trigger structures to be retrieved by name.\n * 2. All triggers associated with a single table form a linked list, using the\n *    pNext member of struct Trigger. A pointer to the first element of the\n *    linked list is stored as the \"pTrigger\" member of the associated\n *    struct Table.\n *\n * The \"step_list\" member points to the first element of a linked list\n * containing the SQL statements specified as the trigger program.\n */\nstruct Trigger {\n  char *zName;            /* The name of the trigger                        */\n  char *table;            /* The table or view to which the trigger applies */\n  u8 op;                  /* One of TK_DELETE, TK_UPDATE, TK_INSERT         */\n  u8 tr_tm;               /* One of TRIGGER_BEFORE, TRIGGER_AFTER */\n  Expr *pWhen;            /* The WHEN clause of the expression (may be NULL) */\n  IdList *pColumns;       /* If this is an UPDATE OF <column-list> trigger,\n                             the <column-list> is stored here */\n  Schema *pSchema;        /* Schema containing the trigger */\n  Schema *pTabSchema;     /* Schema containing the table */\n  TriggerStep *step_list; /* Link list of trigger program steps             */\n  Trigger *pNext;         /* Next trigger associated with the table */\n};\n\n/*\n** A trigger is either a BEFORE or an AFTER trigger.  The following constants\n** determine which.\n**\n** If there are multiple triggers, you might of some BEFORE and some AFTER.\n** In that cases, the constants below can be ORed together.\n*/\n#define TRIGGER_BEFORE  1\n#define TRIGGER_AFTER   2\n\n/*\n * An instance of struct TriggerStep is used to store a single SQL statement\n * that is a part of a trigger-program.\n *\n * Instances of struct TriggerStep are stored in a singly linked list (linked\n * using the \"pNext\" member) referenced by the \"step_list\" member of the\n * associated struct Trigger instance. The first element of the linked list is\n * the first step of the trigger-program.\n *\n * The \"op\" member indicates whether this is a \"DELETE\", \"INSERT\", \"UPDATE\" or\n * \"SELECT\" statement. The meanings of the other members is determined by the\n * value of \"op\" as follows:\n *\n * (op == TK_INSERT)\n * orconf    -> stores the ON CONFLICT algorithm\n * pSelect   -> If this is an INSERT INTO ... SELECT ... statement, then\n *              this stores a pointer to the SELECT statement. Otherwise NULL.\n * zTarget   -> Dequoted name of the table to insert into.\n * pExprList -> If this is an INSERT INTO ... VALUES ... statement, then\n *              this stores values to be inserted. Otherwise NULL.\n * pIdList   -> If this is an INSERT INTO ... (<column-names>) VALUES ...\n *              statement, then this stores the column-names to be\n *              inserted into.\n *\n * (op == TK_DELETE)\n * zTarget   -> Dequoted name of the table to delete from.\n * pWhere    -> The WHERE clause of the DELETE statement if one is specified.\n *              Otherwise NULL.\n *\n * (op == TK_UPDATE)\n * zTarget   -> Dequoted name of the table to update.\n * pWhere    -> The WHERE clause of the UPDATE statement if one is specified.\n *              Otherwise NULL.\n * pExprList -> A list of the columns to update and the expressions to update\n *              them to. See sqlite3Update() documentation of \"pChanges\"\n *              argument.\n *\n */\nstruct TriggerStep {\n  u8 op;               /* One of TK_DELETE, TK_UPDATE, TK_INSERT, TK_SELECT */\n  u8 orconf;           /* OE_Rollback etc. */\n  Trigger *pTrig;      /* The trigger that this step is a part of */\n  Select *pSelect;     /* SELECT statement or RHS of INSERT INTO SELECT ... */\n  char *zTarget;       /* Target table for DELETE, UPDATE, INSERT */\n  Expr *pWhere;        /* The WHERE clause for DELETE or UPDATE steps */\n  ExprList *pExprList; /* SET clause for UPDATE */\n  IdList *pIdList;     /* Column names for INSERT */\n  Upsert *pUpsert;     /* Upsert clauses on an INSERT */\n  char *zSpan;         /* Original SQL text of this command */\n  TriggerStep *pNext;  /* Next in the link-list */\n  TriggerStep *pLast;  /* Last element in link-list. Valid for 1st elem only */\n};\n\n/*\n** The following structure contains information used by the sqliteFix...\n** routines as they walk the parse tree to make database references\n** explicit.\n*/\ntypedef struct DbFixer DbFixer;\nstruct DbFixer {\n  Parse *pParse;      /* The parsing context.  Error messages written here */\n  Schema *pSchema;    /* Fix items to this schema */\n  int bVarOnly;       /* Check for variable references only */\n  const char *zDb;    /* Make sure all objects are contained in this database */\n  const char *zType;  /* Type of the container - used for error messages */\n  const Token *pName; /* Name of the container - used for error messages */\n};\n\n/*\n** An objected used to accumulate the text of a string where we\n** do not necessarily know how big the string will be in the end.\n*/\nstruct sqlite3_str {\n  sqlite3 *db;         /* Optional database for lookaside.  Can be NULL */\n  char *zText;         /* The string collected so far */\n  u32  nAlloc;         /* Amount of space allocated in zText */\n  u32  mxAlloc;        /* Maximum allowed allocation.  0 for no malloc usage */\n  u32  nChar;          /* Length of the string so far */\n  u8   accError;       /* SQLITE_NOMEM or SQLITE_TOOBIG */\n  u8   printfFlags;    /* SQLITE_PRINTF flags below */\n};\n#define SQLITE_PRINTF_INTERNAL 0x01  /* Internal-use-only converters allowed */\n#define SQLITE_PRINTF_SQLFUNC  0x02  /* SQL function arguments to VXPrintf */\n#define SQLITE_PRINTF_MALLOCED 0x04  /* True if xText is allocated space */\n\n#define isMalloced(X)  (((X)->printfFlags & SQLITE_PRINTF_MALLOCED)!=0)\n\n\n/*\n** A pointer to this structure is used to communicate information\n** from sqlite3Init and OP_ParseSchema into the sqlite3InitCallback.\n*/\ntypedef struct {\n  sqlite3 *db;        /* The database being initialized */\n  char **pzErrMsg;    /* Error message stored here */\n  int iDb;            /* 0 for main database.  1 for TEMP, 2.. for ATTACHed */\n  int rc;             /* Result code stored here */\n  u32 mInitFlags;     /* Flags controlling error messages */\n  u32 nInitRow;       /* Number of rows processed */\n} InitData;\n\n/*\n** Allowed values for mInitFlags\n*/\n#define INITFLAG_AlterTable   0x0001  /* This is a reparse after ALTER TABLE */\n\n/*\n** Structure containing global configuration data for the SQLite library.\n**\n** This structure also contains some state information.\n*/\nstruct Sqlite3Config {\n  int bMemstat;                     /* True to enable memory status */\n  int bCoreMutex;                   /* True to enable core mutexing */\n  int bFullMutex;                   /* True to enable full mutexing */\n  int bOpenUri;                     /* True to interpret filenames as URIs */\n  int bUseCis;                      /* Use covering indices for full-scans */\n  int bSmallMalloc;                 /* Avoid large memory allocations if true */\n  int mxStrlen;                     /* Maximum string length */\n  int neverCorrupt;                 /* Database is always well-formed */\n  int szLookaside;                  /* Default lookaside buffer size */\n  int nLookaside;                   /* Default lookaside buffer count */\n  int nStmtSpill;                   /* Stmt-journal spill-to-disk threshold */\n  sqlite3_mem_methods m;            /* Low-level memory allocation interface */\n  sqlite3_mutex_methods mutex;      /* Low-level mutex interface */\n  sqlite3_pcache_methods2 pcache2;  /* Low-level page-cache interface */\n  void *pHeap;                      /* Heap storage space */\n  int nHeap;                        /* Size of pHeap[] */\n  int mnReq, mxReq;                 /* Min and max heap requests sizes */\n  sqlite3_int64 szMmap;             /* mmap() space per open file */\n  sqlite3_int64 mxMmap;             /* Maximum value for szMmap */\n  void *pPage;                      /* Page cache memory */\n  int szPage;                       /* Size of each page in pPage[] */\n  int nPage;                        /* Number of pages in pPage[] */\n  int mxParserStack;                /* maximum depth of the parser stack */\n  int sharedCacheEnabled;           /* true if shared-cache mode enabled */\n  u32 szPma;                        /* Maximum Sorter PMA size */\n  /* The above might be initialized to non-zero.  The following need to always\n  ** initially be zero, however. */\n  int isInit;                       /* True after initialization has finished */\n  int inProgress;                   /* True while initialization in progress */\n  int isMutexInit;                  /* True after mutexes are initialized */\n  int isMallocInit;                 /* True after malloc is initialized */\n  int isPCacheInit;                 /* True after malloc is initialized */\n  int nRefInitMutex;                /* Number of users of pInitMutex */\n  sqlite3_mutex *pInitMutex;        /* Mutex used by sqlite3_initialize() */\n  void (*xLog)(void*,int,const char*); /* Function for logging */\n  void *pLogArg;                       /* First argument to xLog() */\n#ifdef SQLITE_ENABLE_SQLLOG\n  void(*xSqllog)(void*,sqlite3*,const char*, int);\n  void *pSqllogArg;\n#endif\n#ifdef SQLITE_VDBE_COVERAGE\n  /* The following callback (if not NULL) is invoked on every VDBE branch\n  ** operation.  Set the callback using SQLITE_TESTCTRL_VDBE_COVERAGE.\n  */\n  void (*xVdbeBranch)(void*,unsigned iSrcLine,u8 eThis,u8 eMx);  /* Callback */\n  void *pVdbeBranchArg;                                     /* 1st argument */\n#endif\n#ifdef SQLITE_ENABLE_DESERIALIZE\n  sqlite3_int64 mxMemdbSize;        /* Default max memdb size */\n#endif\n#ifndef SQLITE_UNTESTABLE\n  int (*xTestCallback)(int);        /* Invoked by sqlite3FaultSim() */\n#endif\n  int bLocaltimeFault;              /* True to fail localtime() calls */\n  int bInternalFunctions;           /* Internal SQL functions are visible */\n  int iOnceResetThreshold;          /* When to reset OP_Once counters */\n  u32 szSorterRef;                  /* Min size in bytes to use sorter-refs */\n};\n\n/*\n** This macro is used inside of assert() statements to indicate that\n** the assert is only valid on a well-formed database.  Instead of:\n**\n**     assert( X );\n**\n** One writes:\n**\n**     assert( X || CORRUPT_DB );\n**\n** CORRUPT_DB is true during normal operation.  CORRUPT_DB does not indicate\n** that the database is definitely corrupt, only that it might be corrupt.\n** For most test cases, CORRUPT_DB is set to false using a special\n** sqlite3_test_control().  This enables assert() statements to prove\n** things that are always true for well-formed databases.\n*/\n#define CORRUPT_DB  (sqlite3Config.neverCorrupt==0)\n\n/*\n** Context pointer passed down through the tree-walk.\n*/\nstruct Walker {\n  Parse *pParse;                            /* Parser context.  */\n  int (*xExprCallback)(Walker*, Expr*);     /* Callback for expressions */\n  int (*xSelectCallback)(Walker*,Select*);  /* Callback for SELECTs */\n  void (*xSelectCallback2)(Walker*,Select*);/* Second callback for SELECTs */\n  int walkerDepth;                          /* Number of subqueries */\n  u8 eCode;                                 /* A small processing code */\n  union {                                   /* Extra data for callback */\n    NameContext *pNC;                         /* Naming context */\n    int n;                                    /* A counter */\n    int iCur;                                 /* A cursor number */\n    SrcList *pSrcList;                        /* FROM clause */\n    struct SrcCount *pSrcCount;               /* Counting column references */\n    struct CCurHint *pCCurHint;               /* Used by codeCursorHint() */\n    int *aiCol;                               /* array of column indexes */\n    struct IdxCover *pIdxCover;               /* Check for index coverage */\n    struct IdxExprTrans *pIdxTrans;           /* Convert idxed expr to column */\n    ExprList *pGroupBy;                       /* GROUP BY clause */\n    Select *pSelect;                          /* HAVING to WHERE clause ctx */\n    struct WindowRewrite *pRewrite;           /* Window rewrite context */\n    struct WhereConst *pConst;                /* WHERE clause constants */\n    struct RenameCtx *pRename;                /* RENAME COLUMN context */\n  } u;\n};\n\n/* Forward declarations */\nSQLITE_PRIVATE int sqlite3WalkExpr(Walker*, Expr*);\nSQLITE_PRIVATE int sqlite3WalkExprList(Walker*, ExprList*);\nSQLITE_PRIVATE int sqlite3WalkSelect(Walker*, Select*);\nSQLITE_PRIVATE int sqlite3WalkSelectExpr(Walker*, Select*);\nSQLITE_PRIVATE int sqlite3WalkSelectFrom(Walker*, Select*);\nSQLITE_PRIVATE int sqlite3ExprWalkNoop(Walker*, Expr*);\nSQLITE_PRIVATE int sqlite3SelectWalkNoop(Walker*, Select*);\nSQLITE_PRIVATE int sqlite3SelectWalkFail(Walker*, Select*);\n#ifdef SQLITE_DEBUG\nSQLITE_PRIVATE void sqlite3SelectWalkAssert2(Walker*, Select*);\n#endif\n\n/*\n** Return code from the parse-tree walking primitives and their\n** callbacks.\n*/\n#define WRC_Continue    0   /* Continue down into children */\n#define WRC_Prune       1   /* Omit children but continue walking siblings */\n#define WRC_Abort       2   /* Abandon the tree walk */\n\n/*\n** An instance of this structure represents a set of one or more CTEs\n** (common table expressions) created by a single WITH clause.\n*/\nstruct With {\n  int nCte;                       /* Number of CTEs in the WITH clause */\n  With *pOuter;                   /* Containing WITH clause, or NULL */\n  struct Cte {                    /* For each CTE in the WITH clause.... */\n    char *zName;                    /* Name of this CTE */\n    ExprList *pCols;                /* List of explicit column names, or NULL */\n    Select *pSelect;                /* The definition of this CTE */\n    const char *zCteErr;            /* Error message for circular references */\n  } a[1];\n};\n\n#ifdef SQLITE_DEBUG\n/*\n** An instance of the TreeView object is used for printing the content of\n** data structures on sqlite3DebugPrintf() using a tree-like view.\n*/\nstruct TreeView {\n  int iLevel;             /* Which level of the tree we are on */\n  u8  bLine[100];         /* Draw vertical in column i if bLine[i] is true */\n};\n#endif /* SQLITE_DEBUG */\n\n/*\n** This object is used in varioius ways, all related to window functions\n**\n**   (1) A single instance of this structure is attached to the\n**       the Expr.pWin field for each window function in an expression tree.\n**       This object holds the information contained in the OVER clause,\n**       plus additional fields used during code generation.\n**\n**   (2) All window functions in a single SELECT form a linked-list\n**       attached to Select.pWin.  The Window.pFunc and Window.pExpr\n**       fields point back to the expression that is the window function.\n**\n**   (3) The terms of the WINDOW clause of a SELECT are instances of this\n**       object on a linked list attached to Select.pWinDefn.\n**\n** The uses (1) and (2) are really the same Window object that just happens\n** to be accessible in two different ways.  Use (3) is are separate objects.\n*/\nstruct Window {\n  char *zName;            /* Name of window (may be NULL) */\n  ExprList *pPartition;   /* PARTITION BY clause */\n  ExprList *pOrderBy;     /* ORDER BY clause */\n  u8 eType;               /* TK_RANGE or TK_ROWS */\n  u8 eStart;              /* UNBOUNDED, CURRENT, PRECEDING or FOLLOWING */\n  u8 eEnd;                /* UNBOUNDED, CURRENT, PRECEDING or FOLLOWING */\n  Expr *pStart;           /* Expression for \"<expr> PRECEDING\" */\n  Expr *pEnd;             /* Expression for \"<expr> FOLLOWING\" */\n  Window *pNextWin;       /* Next window function belonging to this SELECT */\n  Expr *pFilter;          /* The FILTER expression */\n  FuncDef *pFunc;         /* The function */\n  int iEphCsr;            /* Partition buffer or Peer buffer */\n  int regAccum;\n  int regResult;\n  int csrApp;             /* Function cursor (used by min/max) */\n  int regApp;             /* Function register (also used by min/max) */\n  int regPart;            /* First in a set of registers holding PARTITION BY\n                          ** and ORDER BY values for the window */\n  Expr *pOwner;           /* Expression object this window is attached to */\n  int nBufferCol;         /* Number of columns in buffer table */\n  int iArgCol;            /* Offset of first argument for this function */\n};\n\n#ifndef SQLITE_OMIT_WINDOWFUNC\nSQLITE_PRIVATE void sqlite3WindowDelete(sqlite3*, Window*);\nSQLITE_PRIVATE void sqlite3WindowListDelete(sqlite3 *db, Window *p);\nSQLITE_PRIVATE Window *sqlite3WindowAlloc(Parse*, int, int, Expr*, int , Expr*);\nSQLITE_PRIVATE void sqlite3WindowAttach(Parse*, Expr*, Window*);\nSQLITE_PRIVATE int sqlite3WindowCompare(Parse*, Window*, Window*);\nSQLITE_PRIVATE void sqlite3WindowCodeInit(Parse*, Window*);\nSQLITE_PRIVATE void sqlite3WindowCodeStep(Parse*, Select*, WhereInfo*, int, int);\nSQLITE_PRIVATE int sqlite3WindowRewrite(Parse*, Select*);\nSQLITE_PRIVATE int sqlite3ExpandSubquery(Parse*, struct SrcList_item*);\nSQLITE_PRIVATE void sqlite3WindowUpdate(Parse*, Window*, Window*, FuncDef*);\nSQLITE_PRIVATE Window *sqlite3WindowDup(sqlite3 *db, Expr *pOwner, Window *p);\nSQLITE_PRIVATE Window *sqlite3WindowListDup(sqlite3 *db, Window *p);\nSQLITE_PRIVATE void sqlite3WindowFunctions(void);\n#else\n# define sqlite3WindowDelete(a,b)\n# define sqlite3WindowFunctions()\n# define sqlite3WindowAttach(a,b,c)\n#endif\n\n/*\n** Assuming zIn points to the first byte of a UTF-8 character,\n** advance zIn to point to the first byte of the next UTF-8 character.\n*/\n#define SQLITE_SKIP_UTF8(zIn) {                        \\\n  if( (*(zIn++))>=0xc0 ){                              \\\n    while( (*zIn & 0xc0)==0x80 ){ zIn++; }             \\\n  }                                                    \\\n}\n\n/*\n** The SQLITE_*_BKPT macros are substitutes for the error codes with\n** the same name but without the _BKPT suffix.  These macros invoke\n** routines that report the line-number on which the error originated\n** using sqlite3_log().  The routines also provide a convenient place\n** to set a debugger breakpoint.\n*/\nSQLITE_PRIVATE int sqlite3ReportError(int iErr, int lineno, const char *zType);\nSQLITE_PRIVATE int sqlite3CorruptError(int);\nSQLITE_PRIVATE int sqlite3MisuseError(int);\nSQLITE_PRIVATE int sqlite3CantopenError(int);\n#define SQLITE_CORRUPT_BKPT sqlite3CorruptError(__LINE__)\n#define SQLITE_MISUSE_BKPT sqlite3MisuseError(__LINE__)\n#define SQLITE_CANTOPEN_BKPT sqlite3CantopenError(__LINE__)\n#ifdef SQLITE_DEBUG\nSQLITE_PRIVATE   int sqlite3NomemError(int);\nSQLITE_PRIVATE   int sqlite3IoerrnomemError(int);\nSQLITE_PRIVATE   int sqlite3CorruptPgnoError(int,Pgno);\n# define SQLITE_NOMEM_BKPT sqlite3NomemError(__LINE__)\n# define SQLITE_IOERR_NOMEM_BKPT sqlite3IoerrnomemError(__LINE__)\n# define SQLITE_CORRUPT_PGNO(P) sqlite3CorruptPgnoError(__LINE__,(P))\n#else\n# define SQLITE_NOMEM_BKPT SQLITE_NOMEM\n# define SQLITE_IOERR_NOMEM_BKPT SQLITE_IOERR_NOMEM\n# define SQLITE_CORRUPT_PGNO(P) sqlite3CorruptError(__LINE__)\n#endif\n\n/*\n** FTS3 and FTS4 both require virtual table support\n*/\n#if defined(SQLITE_OMIT_VIRTUALTABLE)\n# undef SQLITE_ENABLE_FTS3\n# undef SQLITE_ENABLE_FTS4\n#endif\n\n/*\n** FTS4 is really an extension for FTS3.  It is enabled using the\n** SQLITE_ENABLE_FTS3 macro.  But to avoid confusion we also call\n** the SQLITE_ENABLE_FTS4 macro to serve as an alias for SQLITE_ENABLE_FTS3.\n*/\n#if defined(SQLITE_ENABLE_FTS4) && !defined(SQLITE_ENABLE_FTS3)\n# define SQLITE_ENABLE_FTS3 1\n#endif\n\n/*\n** The ctype.h header is needed for non-ASCII systems.  It is also\n** needed by FTS3 when FTS3 is included in the amalgamation.\n*/\n#if !defined(SQLITE_ASCII) || \\\n    (defined(SQLITE_ENABLE_FTS3) && defined(SQLITE_AMALGAMATION))\n# include <ctype.h>\n#endif\n\n/*\n** The following macros mimic the standard library functions toupper(),\n** isspace(), isalnum(), isdigit() and isxdigit(), respectively. The\n** sqlite versions only work for ASCII characters, regardless of locale.\n*/\n#ifdef SQLITE_ASCII\n# define sqlite3Toupper(x)  ((x)&~(sqlite3CtypeMap[(unsigned char)(x)]&0x20))\n# define sqlite3Isspace(x)   (sqlite3CtypeMap[(unsigned char)(x)]&0x01)\n# define sqlite3Isalnum(x)   (sqlite3CtypeMap[(unsigned char)(x)]&0x06)\n# define sqlite3Isalpha(x)   (sqlite3CtypeMap[(unsigned char)(x)]&0x02)\n# define sqlite3Isdigit(x)   (sqlite3CtypeMap[(unsigned char)(x)]&0x04)\n# define sqlite3Isxdigit(x)  (sqlite3CtypeMap[(unsigned char)(x)]&0x08)\n# define sqlite3Tolower(x)   (sqlite3UpperToLower[(unsigned char)(x)])\n# define sqlite3Isquote(x)   (sqlite3CtypeMap[(unsigned char)(x)]&0x80)\n#else\n# define sqlite3Toupper(x)   toupper((unsigned char)(x))\n# define sqlite3Isspace(x)   isspace((unsigned char)(x))\n# define sqlite3Isalnum(x)   isalnum((unsigned char)(x))\n# define sqlite3Isalpha(x)   isalpha((unsigned char)(x))\n# define sqlite3Isdigit(x)   isdigit((unsigned char)(x))\n# define sqlite3Isxdigit(x)  isxdigit((unsigned char)(x))\n# define sqlite3Tolower(x)   tolower((unsigned char)(x))\n# define sqlite3Isquote(x)   ((x)=='\"'||(x)=='\\''||(x)=='['||(x)=='`')\n#endif\nSQLITE_PRIVATE int sqlite3IsIdChar(u8);\n\n/*\n** Internal function prototypes\n*/\nSQLITE_PRIVATE int sqlite3StrICmp(const char*,const char*);\nSQLITE_PRIVATE int sqlite3Strlen30(const char*);\n#define sqlite3Strlen30NN(C) (strlen(C)&0x3fffffff)\nSQLITE_PRIVATE char *sqlite3ColumnType(Column*,char*);\n#define sqlite3StrNICmp sqlite3_strnicmp\n\nSQLITE_PRIVATE int sqlite3MallocInit(void);\nSQLITE_PRIVATE void sqlite3MallocEnd(void);\nSQLITE_PRIVATE void *sqlite3Malloc(u64);\nSQLITE_PRIVATE void *sqlite3MallocZero(u64);\nSQLITE_PRIVATE void *sqlite3DbMallocZero(sqlite3*, u64);\nSQLITE_PRIVATE void *sqlite3DbMallocRaw(sqlite3*, u64);\nSQLITE_PRIVATE void *sqlite3DbMallocRawNN(sqlite3*, u64);\nSQLITE_PRIVATE char *sqlite3DbStrDup(sqlite3*,const char*);\nSQLITE_PRIVATE char *sqlite3DbStrNDup(sqlite3*,const char*, u64);\nSQLITE_PRIVATE char *sqlite3DbSpanDup(sqlite3*,const char*,const char*);\nSQLITE_PRIVATE void *sqlite3Realloc(void*, u64);\nSQLITE_PRIVATE void *sqlite3DbReallocOrFree(sqlite3 *, void *, u64);\nSQLITE_PRIVATE void *sqlite3DbRealloc(sqlite3 *, void *, u64);\nSQLITE_PRIVATE void sqlite3DbFree(sqlite3*, void*);\nSQLITE_PRIVATE void sqlite3DbFreeNN(sqlite3*, void*);\nSQLITE_PRIVATE int sqlite3MallocSize(void*);\nSQLITE_PRIVATE int sqlite3DbMallocSize(sqlite3*, void*);\nSQLITE_PRIVATE void *sqlite3PageMalloc(int);\nSQLITE_PRIVATE void sqlite3PageFree(void*);\nSQLITE_PRIVATE void sqlite3MemSetDefault(void);\n#ifndef SQLITE_UNTESTABLE\nSQLITE_PRIVATE void sqlite3BenignMallocHooks(void (*)(void), void (*)(void));\n#endif\nSQLITE_PRIVATE int sqlite3HeapNearlyFull(void);\n\n/*\n** On systems with ample stack space and that support alloca(), make\n** use of alloca() to obtain space for large automatic objects.  By default,\n** obtain space from malloc().\n**\n** The alloca() routine never returns NULL.  This will cause code paths\n** that deal with sqlite3StackAlloc() failures to be unreachable.\n*/\n#ifdef SQLITE_USE_ALLOCA\n# define sqlite3StackAllocRaw(D,N)   alloca(N)\n# define sqlite3StackAllocZero(D,N)  memset(alloca(N), 0, N)\n# define sqlite3StackFree(D,P)\n#else\n# define sqlite3StackAllocRaw(D,N)   sqlite3DbMallocRaw(D,N)\n# define sqlite3StackAllocZero(D,N)  sqlite3DbMallocZero(D,N)\n# define sqlite3StackFree(D,P)       sqlite3DbFree(D,P)\n#endif\n\n/* Do not allow both MEMSYS5 and MEMSYS3 to be defined together.  If they\n** are, disable MEMSYS3\n*/\n#ifdef SQLITE_ENABLE_MEMSYS5\nSQLITE_PRIVATE const sqlite3_mem_methods *sqlite3MemGetMemsys5(void);\n#undef SQLITE_ENABLE_MEMSYS3\n#endif\n#ifdef SQLITE_ENABLE_MEMSYS3\nSQLITE_PRIVATE const sqlite3_mem_methods *sqlite3MemGetMemsys3(void);\n#endif\n\n\n#ifndef SQLITE_MUTEX_OMIT\nSQLITE_PRIVATE   sqlite3_mutex_methods const *sqlite3DefaultMutex(void);\nSQLITE_PRIVATE   sqlite3_mutex_methods const *sqlite3NoopMutex(void);\nSQLITE_PRIVATE   sqlite3_mutex *sqlite3MutexAlloc(int);\nSQLITE_PRIVATE   int sqlite3MutexInit(void);\nSQLITE_PRIVATE   int sqlite3MutexEnd(void);\n#endif\n#if !defined(SQLITE_MUTEX_OMIT) && !defined(SQLITE_MUTEX_NOOP)\nSQLITE_PRIVATE   void sqlite3MemoryBarrier(void);\n#else\n# define sqlite3MemoryBarrier()\n#endif\n\nSQLITE_PRIVATE sqlite3_int64 sqlite3StatusValue(int);\nSQLITE_PRIVATE void sqlite3StatusUp(int, int);\nSQLITE_PRIVATE void sqlite3StatusDown(int, int);\nSQLITE_PRIVATE void sqlite3StatusHighwater(int, int);\nSQLITE_PRIVATE int sqlite3LookasideUsed(sqlite3*,int*);\n\n/* Access to mutexes used by sqlite3_status() */\nSQLITE_PRIVATE sqlite3_mutex *sqlite3Pcache1Mutex(void);\nSQLITE_PRIVATE sqlite3_mutex *sqlite3MallocMutex(void);\n\n#if defined(SQLITE_ENABLE_MULTITHREADED_CHECKS) && !defined(SQLITE_MUTEX_OMIT)\nSQLITE_PRIVATE void sqlite3MutexWarnOnContention(sqlite3_mutex*);\n#else\n# define sqlite3MutexWarnOnContention(x)\n#endif\n\n#ifndef SQLITE_OMIT_FLOATING_POINT\nSQLITE_PRIVATE   int sqlite3IsNaN(double);\n#else\n# define sqlite3IsNaN(X)  0\n#endif\n\n/*\n** An instance of the following structure holds information about SQL\n** functions arguments that are the parameters to the printf() function.\n*/\nstruct PrintfArguments {\n  int nArg;                /* Total number of arguments */\n  int nUsed;               /* Number of arguments used so far */\n  sqlite3_value **apArg;   /* The argument values */\n};\n\nSQLITE_PRIVATE char *sqlite3MPrintf(sqlite3*,const char*, ...);\nSQLITE_PRIVATE char *sqlite3VMPrintf(sqlite3*,const char*, va_list);\n#if defined(SQLITE_DEBUG) || defined(SQLITE_HAVE_OS_TRACE)\nSQLITE_PRIVATE   void sqlite3DebugPrintf(const char*, ...);\n#endif\n#if defined(SQLITE_TEST)\nSQLITE_PRIVATE   void *sqlite3TestTextToPtr(const char*);\n#endif\n\n#if defined(SQLITE_DEBUG)\nSQLITE_PRIVATE   void sqlite3TreeViewExpr(TreeView*, const Expr*, u8);\nSQLITE_PRIVATE   void sqlite3TreeViewBareExprList(TreeView*, const ExprList*, const char*);\nSQLITE_PRIVATE   void sqlite3TreeViewExprList(TreeView*, const ExprList*, u8, const char*);\nSQLITE_PRIVATE   void sqlite3TreeViewSrcList(TreeView*, const SrcList*);\nSQLITE_PRIVATE   void sqlite3TreeViewSelect(TreeView*, const Select*, u8);\nSQLITE_PRIVATE   void sqlite3TreeViewWith(TreeView*, const With*, u8);\n#ifndef SQLITE_OMIT_WINDOWFUNC\nSQLITE_PRIVATE   void sqlite3TreeViewWindow(TreeView*, const Window*, u8);\nSQLITE_PRIVATE   void sqlite3TreeViewWinFunc(TreeView*, const Window*, u8);\n#endif\n#endif\n\n\nSQLITE_PRIVATE void sqlite3SetString(char **, sqlite3*, const char*);\nSQLITE_PRIVATE void sqlite3ErrorMsg(Parse*, const char*, ...);\nSQLITE_PRIVATE void sqlite3Dequote(char*);\nSQLITE_PRIVATE void sqlite3DequoteExpr(Expr*);\nSQLITE_PRIVATE void sqlite3TokenInit(Token*,char*);\nSQLITE_PRIVATE int sqlite3KeywordCode(const unsigned char*, int);\nSQLITE_PRIVATE int sqlite3RunParser(Parse*, const char*, char **);\nSQLITE_PRIVATE void sqlite3FinishCoding(Parse*);\nSQLITE_PRIVATE int sqlite3GetTempReg(Parse*);\nSQLITE_PRIVATE void sqlite3ReleaseTempReg(Parse*,int);\nSQLITE_PRIVATE int sqlite3GetTempRange(Parse*,int);\nSQLITE_PRIVATE void sqlite3ReleaseTempRange(Parse*,int,int);\nSQLITE_PRIVATE void sqlite3ClearTempRegCache(Parse*);\n#ifdef SQLITE_DEBUG\nSQLITE_PRIVATE int sqlite3NoTempsInRange(Parse*,int,int);\n#endif\nSQLITE_PRIVATE Expr *sqlite3ExprAlloc(sqlite3*,int,const Token*,int);\nSQLITE_PRIVATE Expr *sqlite3Expr(sqlite3*,int,const char*);\nSQLITE_PRIVATE void sqlite3ExprAttachSubtrees(sqlite3*,Expr*,Expr*,Expr*);\nSQLITE_PRIVATE Expr *sqlite3PExpr(Parse*, int, Expr*, Expr*);\nSQLITE_PRIVATE void sqlite3PExprAddSelect(Parse*, Expr*, Select*);\nSQLITE_PRIVATE Expr *sqlite3ExprAnd(sqlite3*,Expr*, Expr*);\nSQLITE_PRIVATE Expr *sqlite3ExprFunction(Parse*,ExprList*, Token*, int);\nSQLITE_PRIVATE void sqlite3ExprAssignVarNumber(Parse*, Expr*, u32);\nSQLITE_PRIVATE void sqlite3ExprDelete(sqlite3*, Expr*);\nSQLITE_PRIVATE ExprList *sqlite3ExprListAppend(Parse*,ExprList*,Expr*);\nSQLITE_PRIVATE ExprList *sqlite3ExprListAppendVector(Parse*,ExprList*,IdList*,Expr*);\nSQLITE_PRIVATE void sqlite3ExprListSetSortOrder(ExprList*,int);\nSQLITE_PRIVATE void sqlite3ExprListSetName(Parse*,ExprList*,Token*,int);\nSQLITE_PRIVATE void sqlite3ExprListSetSpan(Parse*,ExprList*,const char*,const char*);\nSQLITE_PRIVATE void sqlite3ExprListDelete(sqlite3*, ExprList*);\nSQLITE_PRIVATE u32 sqlite3ExprListFlags(const ExprList*);\nSQLITE_PRIVATE int sqlite3IndexHasDuplicateRootPage(Index*);\nSQLITE_PRIVATE int sqlite3Init(sqlite3*, char**);\nSQLITE_PRIVATE int sqlite3InitCallback(void*, int, char**, char**);\nSQLITE_PRIVATE int sqlite3InitOne(sqlite3*, int, char**, u32);\nSQLITE_PRIVATE void sqlite3Pragma(Parse*,Token*,Token*,Token*,int);\n#ifndef SQLITE_OMIT_VIRTUALTABLE\nSQLITE_PRIVATE Module *sqlite3PragmaVtabRegister(sqlite3*,const char *zName);\n#endif\nSQLITE_PRIVATE void sqlite3ResetAllSchemasOfConnection(sqlite3*);\nSQLITE_PRIVATE void sqlite3ResetOneSchema(sqlite3*,int);\nSQLITE_PRIVATE void sqlite3CollapseDatabaseArray(sqlite3*);\nSQLITE_PRIVATE void sqlite3CommitInternalChanges(sqlite3*);\nSQLITE_PRIVATE void sqlite3DeleteColumnNames(sqlite3*,Table*);\nSQLITE_PRIVATE int sqlite3ColumnsFromExprList(Parse*,ExprList*,i16*,Column**);\nSQLITE_PRIVATE void sqlite3SelectAddColumnTypeAndCollation(Parse*,Table*,Select*);\nSQLITE_PRIVATE Table *sqlite3ResultSetOfSelect(Parse*,Select*);\nSQLITE_PRIVATE void sqlite3OpenMasterTable(Parse *, int);\nSQLITE_PRIVATE Index *sqlite3PrimaryKeyIndex(Table*);\nSQLITE_PRIVATE i16 sqlite3ColumnOfIndex(Index*, i16);\nSQLITE_PRIVATE void sqlite3StartTable(Parse*,Token*,Token*,int,int,int,int);\n#if SQLITE_ENABLE_HIDDEN_COLUMNS\nSQLITE_PRIVATE   void sqlite3ColumnPropertiesFromName(Table*, Column*);\n#else\n# define sqlite3ColumnPropertiesFromName(T,C) /* no-op */\n#endif\nSQLITE_PRIVATE void sqlite3AddColumn(Parse*,Token*,Token*);\nSQLITE_PRIVATE void sqlite3AddNotNull(Parse*, int);\nSQLITE_PRIVATE void sqlite3AddPrimaryKey(Parse*, ExprList*, int, int, int);\nSQLITE_PRIVATE void sqlite3AddCheckConstraint(Parse*, Expr*);\nSQLITE_PRIVATE void sqlite3AddDefaultValue(Parse*,Expr*,const char*,const char*);\nSQLITE_PRIVATE void sqlite3AddCollateType(Parse*, Token*);\nSQLITE_PRIVATE void sqlite3EndTable(Parse*,Token*,Token*,u8,Select*);\nSQLITE_PRIVATE int sqlite3ParseUri(const char*,const char*,unsigned int*,\n                    sqlite3_vfs**,char**,char **);\n#ifdef SQLITE_HAS_CODEC\nSQLITE_PRIVATE   int sqlite3CodecQueryParameters(sqlite3*,const char*,const char*);\n#else\n# define sqlite3CodecQueryParameters(A,B,C) 0\n#endif\nSQLITE_PRIVATE Btree *sqlite3DbNameToBtree(sqlite3*,const char*);\n\n#ifdef SQLITE_UNTESTABLE\n# define sqlite3FaultSim(X) SQLITE_OK\n#else\nSQLITE_PRIVATE   int sqlite3FaultSim(int);\n#endif\n\nSQLITE_PRIVATE Bitvec *sqlite3BitvecCreate(u32);\nSQLITE_PRIVATE int sqlite3BitvecTest(Bitvec*, u32);\nSQLITE_PRIVATE int sqlite3BitvecTestNotNull(Bitvec*, u32);\nSQLITE_PRIVATE int sqlite3BitvecSet(Bitvec*, u32);\nSQLITE_PRIVATE void sqlite3BitvecClear(Bitvec*, u32, void*);\nSQLITE_PRIVATE void sqlite3BitvecDestroy(Bitvec*);\nSQLITE_PRIVATE u32 sqlite3BitvecSize(Bitvec*);\n#ifndef SQLITE_UNTESTABLE\nSQLITE_PRIVATE int sqlite3BitvecBuiltinTest(int,int*);\n#endif\n\nSQLITE_PRIVATE RowSet *sqlite3RowSetInit(sqlite3*);\nSQLITE_PRIVATE void sqlite3RowSetDelete(void*);\nSQLITE_PRIVATE void sqlite3RowSetClear(void*);\nSQLITE_PRIVATE void sqlite3RowSetInsert(RowSet*, i64);\nSQLITE_PRIVATE int sqlite3RowSetTest(RowSet*, int iBatch, i64);\nSQLITE_PRIVATE int sqlite3RowSetNext(RowSet*, i64*);\n\nSQLITE_PRIVATE void sqlite3CreateView(Parse*,Token*,Token*,Token*,ExprList*,Select*,int,int);\n\n#if !defined(SQLITE_OMIT_VIEW) || !defined(SQLITE_OMIT_VIRTUALTABLE)\nSQLITE_PRIVATE   int sqlite3ViewGetColumnNames(Parse*,Table*);\n#else\n# define sqlite3ViewGetColumnNames(A,B) 0\n#endif\n\n#if SQLITE_MAX_ATTACHED>30\nSQLITE_PRIVATE   int sqlite3DbMaskAllZero(yDbMask);\n#endif\nSQLITE_PRIVATE void sqlite3DropTable(Parse*, SrcList*, int, int);\nSQLITE_PRIVATE void sqlite3CodeDropTable(Parse*, Table*, int, int);\nSQLITE_PRIVATE void sqlite3DeleteTable(sqlite3*, Table*);\nSQLITE_PRIVATE void sqlite3FreeIndex(sqlite3*, Index*);\n#ifndef SQLITE_OMIT_AUTOINCREMENT\nSQLITE_PRIVATE   void sqlite3AutoincrementBegin(Parse *pParse);\nSQLITE_PRIVATE   void sqlite3AutoincrementEnd(Parse *pParse);\n#else\n# define sqlite3AutoincrementBegin(X)\n# define sqlite3AutoincrementEnd(X)\n#endif\nSQLITE_PRIVATE void sqlite3Insert(Parse*, SrcList*, Select*, IdList*, int, Upsert*);\nSQLITE_PRIVATE void *sqlite3ArrayAllocate(sqlite3*,void*,int,int*,int*);\nSQLITE_PRIVATE IdList *sqlite3IdListAppend(Parse*, IdList*, Token*);\nSQLITE_PRIVATE int sqlite3IdListIndex(IdList*,const char*);\nSQLITE_PRIVATE SrcList *sqlite3SrcListEnlarge(Parse*, SrcList*, int, int);\nSQLITE_PRIVATE SrcList *sqlite3SrcListAppend(Parse*, SrcList*, Token*, Token*);\nSQLITE_PRIVATE SrcList *sqlite3SrcListAppendFromTerm(Parse*, SrcList*, Token*, Token*,\n                                      Token*, Select*, Expr*, IdList*);\nSQLITE_PRIVATE void sqlite3SrcListIndexedBy(Parse *, SrcList *, Token *);\nSQLITE_PRIVATE void sqlite3SrcListFuncArgs(Parse*, SrcList*, ExprList*);\nSQLITE_PRIVATE int sqlite3IndexedByLookup(Parse *, struct SrcList_item *);\nSQLITE_PRIVATE void sqlite3SrcListShiftJoinType(SrcList*);\nSQLITE_PRIVATE void sqlite3SrcListAssignCursors(Parse*, SrcList*);\nSQLITE_PRIVATE void sqlite3IdListDelete(sqlite3*, IdList*);\nSQLITE_PRIVATE void sqlite3SrcListDelete(sqlite3*, SrcList*);\nSQLITE_PRIVATE Index *sqlite3AllocateIndexObject(sqlite3*,i16,int,char**);\nSQLITE_PRIVATE void sqlite3CreateIndex(Parse*,Token*,Token*,SrcList*,ExprList*,int,Token*,\n                          Expr*, int, int, u8);\nSQLITE_PRIVATE void sqlite3DropIndex(Parse*, SrcList*, int);\nSQLITE_PRIVATE int sqlite3Select(Parse*, Select*, SelectDest*);\nSQLITE_PRIVATE Select *sqlite3SelectNew(Parse*,ExprList*,SrcList*,Expr*,ExprList*,\n                         Expr*,ExprList*,u32,Expr*);\nSQLITE_PRIVATE void sqlite3SelectDelete(sqlite3*, Select*);\nSQLITE_PRIVATE Table *sqlite3SrcListLookup(Parse*, SrcList*);\nSQLITE_PRIVATE int sqlite3IsReadOnly(Parse*, Table*, int);\nSQLITE_PRIVATE void sqlite3OpenTable(Parse*, int iCur, int iDb, Table*, int);\n#if defined(SQLITE_ENABLE_UPDATE_DELETE_LIMIT) && !defined(SQLITE_OMIT_SUBQUERY)\nSQLITE_PRIVATE Expr *sqlite3LimitWhere(Parse*,SrcList*,Expr*,ExprList*,Expr*,char*);\n#endif\nSQLITE_PRIVATE void sqlite3DeleteFrom(Parse*, SrcList*, Expr*, ExprList*, Expr*);\nSQLITE_PRIVATE void sqlite3Update(Parse*, SrcList*, ExprList*,Expr*,int,ExprList*,Expr*,\n                   Upsert*);\nSQLITE_PRIVATE WhereInfo *sqlite3WhereBegin(Parse*,SrcList*,Expr*,ExprList*,ExprList*,u16,int);\nSQLITE_PRIVATE void sqlite3WhereEnd(WhereInfo*);\nSQLITE_PRIVATE LogEst sqlite3WhereOutputRowCount(WhereInfo*);\nSQLITE_PRIVATE int sqlite3WhereIsDistinct(WhereInfo*);\nSQLITE_PRIVATE int sqlite3WhereIsOrdered(WhereInfo*);\nSQLITE_PRIVATE int sqlite3WhereOrderByLimitOptLabel(WhereInfo*);\nSQLITE_PRIVATE int sqlite3WhereIsSorted(WhereInfo*);\nSQLITE_PRIVATE int sqlite3WhereContinueLabel(WhereInfo*);\nSQLITE_PRIVATE int sqlite3WhereBreakLabel(WhereInfo*);\nSQLITE_PRIVATE int sqlite3WhereOkOnePass(WhereInfo*, int*);\n#define ONEPASS_OFF      0        /* Use of ONEPASS not allowed */\n#define ONEPASS_SINGLE   1        /* ONEPASS valid for a single row update */\n#define ONEPASS_MULTI    2        /* ONEPASS is valid for multiple rows */\nSQLITE_PRIVATE void sqlite3ExprCodeLoadIndexColumn(Parse*, Index*, int, int, int);\nSQLITE_PRIVATE int sqlite3ExprCodeGetColumn(Parse*, Table*, int, int, int, u8);\nSQLITE_PRIVATE void sqlite3ExprCodeGetColumnOfTable(Vdbe*, Table*, int, int, int);\nSQLITE_PRIVATE void sqlite3ExprCodeMove(Parse*, int, int, int);\nSQLITE_PRIVATE void sqlite3ExprCode(Parse*, Expr*, int);\nSQLITE_PRIVATE void sqlite3ExprCodeCopy(Parse*, Expr*, int);\nSQLITE_PRIVATE void sqlite3ExprCodeFactorable(Parse*, Expr*, int);\nSQLITE_PRIVATE int sqlite3ExprCodeAtInit(Parse*, Expr*, int);\nSQLITE_PRIVATE int sqlite3ExprCodeTemp(Parse*, Expr*, int*);\nSQLITE_PRIVATE int sqlite3ExprCodeTarget(Parse*, Expr*, int);\nSQLITE_PRIVATE void sqlite3ExprCodeAndCache(Parse*, Expr*, int);\nSQLITE_PRIVATE int sqlite3ExprCodeExprList(Parse*, ExprList*, int, int, u8);\n#define SQLITE_ECEL_DUP      0x01  /* Deep, not shallow copies */\n#define SQLITE_ECEL_FACTOR   0x02  /* Factor out constant terms */\n#define SQLITE_ECEL_REF      0x04  /* Use ExprList.u.x.iOrderByCol */\n#define SQLITE_ECEL_OMITREF  0x08  /* Omit if ExprList.u.x.iOrderByCol */\nSQLITE_PRIVATE void sqlite3ExprIfTrue(Parse*, Expr*, int, int);\nSQLITE_PRIVATE void sqlite3ExprIfFalse(Parse*, Expr*, int, int);\nSQLITE_PRIVATE void sqlite3ExprIfFalseDup(Parse*, Expr*, int, int);\nSQLITE_PRIVATE Table *sqlite3FindTable(sqlite3*,const char*, const char*);\n#define LOCATE_VIEW    0x01\n#define LOCATE_NOERR   0x02\nSQLITE_PRIVATE Table *sqlite3LocateTable(Parse*,u32 flags,const char*, const char*);\nSQLITE_PRIVATE Table *sqlite3LocateTableItem(Parse*,u32 flags,struct SrcList_item *);\nSQLITE_PRIVATE Index *sqlite3FindIndex(sqlite3*,const char*, const char*);\nSQLITE_PRIVATE void sqlite3UnlinkAndDeleteTable(sqlite3*,int,const char*);\nSQLITE_PRIVATE void sqlite3UnlinkAndDeleteIndex(sqlite3*,int,const char*);\nSQLITE_PRIVATE void sqlite3Vacuum(Parse*,Token*,Expr*);\nSQLITE_PRIVATE int sqlite3RunVacuum(char**, sqlite3*, int, sqlite3_value*);\nSQLITE_PRIVATE char *sqlite3NameFromToken(sqlite3*, Token*);\nSQLITE_PRIVATE int sqlite3ExprCompare(Parse*,Expr*, Expr*, int);\nSQLITE_PRIVATE int sqlite3ExprCompareSkip(Expr*, Expr*, int);\nSQLITE_PRIVATE int sqlite3ExprListCompare(ExprList*, ExprList*, int);\nSQLITE_PRIVATE int sqlite3ExprImpliesExpr(Parse*,Expr*, Expr*, int);\nSQLITE_PRIVATE int sqlite3ExprImpliesNonNullRow(Expr*,int);\nSQLITE_PRIVATE void sqlite3ExprAnalyzeAggregates(NameContext*, Expr*);\nSQLITE_PRIVATE void sqlite3ExprAnalyzeAggList(NameContext*,ExprList*);\nSQLITE_PRIVATE int sqlite3ExprCoveredByIndex(Expr*, int iCur, Index *pIdx);\nSQLITE_PRIVATE int sqlite3FunctionUsesThisSrc(Expr*, SrcList*);\nSQLITE_PRIVATE Vdbe *sqlite3GetVdbe(Parse*);\n#ifndef SQLITE_UNTESTABLE\nSQLITE_PRIVATE void sqlite3PrngSaveState(void);\nSQLITE_PRIVATE void sqlite3PrngRestoreState(void);\n#endif\nSQLITE_PRIVATE void sqlite3RollbackAll(sqlite3*,int);\nSQLITE_PRIVATE void sqlite3CodeVerifySchema(Parse*, int);\nSQLITE_PRIVATE void sqlite3CodeVerifyNamedSchema(Parse*, const char *zDb);\nSQLITE_PRIVATE void sqlite3BeginTransaction(Parse*, int);\nSQLITE_PRIVATE void sqlite3EndTransaction(Parse*,int);\nSQLITE_PRIVATE void sqlite3Savepoint(Parse*, int, Token*);\nSQLITE_PRIVATE void sqlite3CloseSavepoints(sqlite3 *);\nSQLITE_PRIVATE void sqlite3LeaveMutexAndCloseZombie(sqlite3*);\nSQLITE_PRIVATE int sqlite3ExprIdToTrueFalse(Expr*);\nSQLITE_PRIVATE int sqlite3ExprTruthValue(const Expr*);\nSQLITE_PRIVATE int sqlite3ExprIsConstant(Expr*);\nSQLITE_PRIVATE int sqlite3ExprIsConstantNotJoin(Expr*);\nSQLITE_PRIVATE int sqlite3ExprIsConstantOrFunction(Expr*, u8);\nSQLITE_PRIVATE int sqlite3ExprIsConstantOrGroupBy(Parse*, Expr*, ExprList*);\nSQLITE_PRIVATE int sqlite3ExprIsTableConstant(Expr*,int);\n#ifdef SQLITE_ENABLE_CURSOR_HINTS\nSQLITE_PRIVATE int sqlite3ExprContainsSubquery(Expr*);\n#endif\nSQLITE_PRIVATE int sqlite3ExprIsInteger(Expr*, int*);\nSQLITE_PRIVATE int sqlite3ExprCanBeNull(const Expr*);\nSQLITE_PRIVATE int sqlite3ExprNeedsNoAffinityChange(const Expr*, char);\nSQLITE_PRIVATE int sqlite3IsRowid(const char*);\nSQLITE_PRIVATE void sqlite3GenerateRowDelete(\n    Parse*,Table*,Trigger*,int,int,int,i16,u8,u8,u8,int);\nSQLITE_PRIVATE void sqlite3GenerateRowIndexDelete(Parse*, Table*, int, int, int*, int);\nSQLITE_PRIVATE int sqlite3GenerateIndexKey(Parse*, Index*, int, int, int, int*,Index*,int);\nSQLITE_PRIVATE void sqlite3ResolvePartIdxLabel(Parse*,int);\nSQLITE_PRIVATE int sqlite3ExprReferencesUpdatedColumn(Expr*,int*,int);\nSQLITE_PRIVATE void sqlite3GenerateConstraintChecks(Parse*,Table*,int*,int,int,int,int,\n                                     u8,u8,int,int*,int*,Upsert*);\n#ifdef SQLITE_ENABLE_NULL_TRIM\nSQLITE_PRIVATE   void sqlite3SetMakeRecordP5(Vdbe*,Table*);\n#else\n# define sqlite3SetMakeRecordP5(A,B)\n#endif\nSQLITE_PRIVATE void sqlite3CompleteInsertion(Parse*,Table*,int,int,int,int*,int,int,int);\nSQLITE_PRIVATE int sqlite3OpenTableAndIndices(Parse*, Table*, int, u8, int, u8*, int*, int*);\nSQLITE_PRIVATE void sqlite3BeginWriteOperation(Parse*, int, int);\nSQLITE_PRIVATE void sqlite3MultiWrite(Parse*);\nSQLITE_PRIVATE void sqlite3MayAbort(Parse*);\nSQLITE_PRIVATE void sqlite3HaltConstraint(Parse*, int, int, char*, i8, u8);\nSQLITE_PRIVATE void sqlite3UniqueConstraint(Parse*, int, Index*);\nSQLITE_PRIVATE void sqlite3RowidConstraint(Parse*, int, Table*);\nSQLITE_PRIVATE Expr *sqlite3ExprDup(sqlite3*,Expr*,int);\nSQLITE_PRIVATE ExprList *sqlite3ExprListDup(sqlite3*,ExprList*,int);\nSQLITE_PRIVATE SrcList *sqlite3SrcListDup(sqlite3*,SrcList*,int);\nSQLITE_PRIVATE IdList *sqlite3IdListDup(sqlite3*,IdList*);\nSQLITE_PRIVATE Select *sqlite3SelectDup(sqlite3*,Select*,int);\nSQLITE_PRIVATE FuncDef *sqlite3FunctionSearch(int,const char*);\nSQLITE_PRIVATE void sqlite3InsertBuiltinFuncs(FuncDef*,int);\nSQLITE_PRIVATE FuncDef *sqlite3FindFunction(sqlite3*,const char*,int,u8,u8);\nSQLITE_PRIVATE void sqlite3RegisterBuiltinFunctions(void);\nSQLITE_PRIVATE void sqlite3RegisterDateTimeFunctions(void);\nSQLITE_PRIVATE void sqlite3RegisterPerConnectionBuiltinFunctions(sqlite3*);\nSQLITE_PRIVATE int sqlite3SafetyCheckOk(sqlite3*);\nSQLITE_PRIVATE int sqlite3SafetyCheckSickOrOk(sqlite3*);\nSQLITE_PRIVATE void sqlite3ChangeCookie(Parse*, int);\n\n#if !defined(SQLITE_OMIT_VIEW) && !defined(SQLITE_OMIT_TRIGGER)\nSQLITE_PRIVATE void sqlite3MaterializeView(Parse*, Table*, Expr*, ExprList*,Expr*,int);\n#endif\n\n#ifndef SQLITE_OMIT_TRIGGER\nSQLITE_PRIVATE   void sqlite3BeginTrigger(Parse*, Token*,Token*,int,int,IdList*,SrcList*,\n                           Expr*,int, int);\nSQLITE_PRIVATE   void sqlite3FinishTrigger(Parse*, TriggerStep*, Token*);\nSQLITE_PRIVATE   void sqlite3DropTrigger(Parse*, SrcList*, int);\nSQLITE_PRIVATE   void sqlite3DropTriggerPtr(Parse*, Trigger*);\nSQLITE_PRIVATE   Trigger *sqlite3TriggersExist(Parse *, Table*, int, ExprList*, int *pMask);\nSQLITE_PRIVATE   Trigger *sqlite3TriggerList(Parse *, Table *);\nSQLITE_PRIVATE   void sqlite3CodeRowTrigger(Parse*, Trigger *, int, ExprList*, int, Table *,\n                            int, int, int);\nSQLITE_PRIVATE   void sqlite3CodeRowTriggerDirect(Parse *, Trigger *, Table *, int, int, int);\n  void sqliteViewTriggers(Parse*, Table*, Expr*, int, ExprList*);\nSQLITE_PRIVATE   void sqlite3DeleteTriggerStep(sqlite3*, TriggerStep*);\nSQLITE_PRIVATE   TriggerStep *sqlite3TriggerSelectStep(sqlite3*,Select*,\n                                        const char*,const char*);\nSQLITE_PRIVATE   TriggerStep *sqlite3TriggerInsertStep(Parse*,Token*, IdList*,\n                                        Select*,u8,Upsert*,\n                                        const char*,const char*);\nSQLITE_PRIVATE   TriggerStep *sqlite3TriggerUpdateStep(Parse*,Token*,ExprList*, Expr*, u8,\n                                        const char*,const char*);\nSQLITE_PRIVATE   TriggerStep *sqlite3TriggerDeleteStep(Parse*,Token*, Expr*,\n                                        const char*,const char*);\nSQLITE_PRIVATE   void sqlite3DeleteTrigger(sqlite3*, Trigger*);\nSQLITE_PRIVATE   void sqlite3UnlinkAndDeleteTrigger(sqlite3*,int,const char*);\nSQLITE_PRIVATE   u32 sqlite3TriggerColmask(Parse*,Trigger*,ExprList*,int,int,Table*,int);\n# define sqlite3ParseToplevel(p) ((p)->pToplevel ? (p)->pToplevel : (p))\n# define sqlite3IsToplevel(p) ((p)->pToplevel==0)\n#else\n# define sqlite3TriggersExist(B,C,D,E,F) 0\n# define sqlite3DeleteTrigger(A,B)\n# define sqlite3DropTriggerPtr(A,B)\n# define sqlite3UnlinkAndDeleteTrigger(A,B,C)\n# define sqlite3CodeRowTrigger(A,B,C,D,E,F,G,H,I)\n# define sqlite3CodeRowTriggerDirect(A,B,C,D,E,F)\n# define sqlite3TriggerList(X, Y) 0\n# define sqlite3ParseToplevel(p) p\n# define sqlite3IsToplevel(p) 1\n# define sqlite3TriggerColmask(A,B,C,D,E,F,G) 0\n#endif\n\nSQLITE_PRIVATE int sqlite3JoinType(Parse*, Token*, Token*, Token*);\nSQLITE_PRIVATE void sqlite3CreateForeignKey(Parse*, ExprList*, Token*, ExprList*, int);\nSQLITE_PRIVATE void sqlite3DeferForeignKey(Parse*, int);\n#ifndef SQLITE_OMIT_AUTHORIZATION\nSQLITE_PRIVATE   void sqlite3AuthRead(Parse*,Expr*,Schema*,SrcList*);\nSQLITE_PRIVATE   int sqlite3AuthCheck(Parse*,int, const char*, const char*, const char*);\nSQLITE_PRIVATE   void sqlite3AuthContextPush(Parse*, AuthContext*, const char*);\nSQLITE_PRIVATE   void sqlite3AuthContextPop(AuthContext*);\nSQLITE_PRIVATE   int sqlite3AuthReadCol(Parse*, const char *, const char *, int);\n#else\n# define sqlite3AuthRead(a,b,c,d)\n# define sqlite3AuthCheck(a,b,c,d,e)    SQLITE_OK\n# define sqlite3AuthContextPush(a,b,c)\n# define sqlite3AuthContextPop(a)  ((void)(a))\n#endif\nSQLITE_PRIVATE void sqlite3Attach(Parse*, Expr*, Expr*, Expr*);\nSQLITE_PRIVATE void sqlite3Detach(Parse*, Expr*);\nSQLITE_PRIVATE void sqlite3FixInit(DbFixer*, Parse*, int, const char*, const Token*);\nSQLITE_PRIVATE int sqlite3FixSrcList(DbFixer*, SrcList*);\nSQLITE_PRIVATE int sqlite3FixSelect(DbFixer*, Select*);\nSQLITE_PRIVATE int sqlite3FixExpr(DbFixer*, Expr*);\nSQLITE_PRIVATE int sqlite3FixExprList(DbFixer*, ExprList*);\nSQLITE_PRIVATE int sqlite3FixTriggerStep(DbFixer*, TriggerStep*);\nSQLITE_PRIVATE int sqlite3AtoF(const char *z, double*, int, u8);\nSQLITE_PRIVATE int sqlite3GetInt32(const char *, int*);\nSQLITE_PRIVATE int sqlite3Atoi(const char*);\n#ifndef SQLITE_OMIT_UTF16\nSQLITE_PRIVATE int sqlite3Utf16ByteLen(const void *pData, int nChar);\n#endif\nSQLITE_PRIVATE int sqlite3Utf8CharLen(const char *pData, int nByte);\nSQLITE_PRIVATE u32 sqlite3Utf8Read(const u8**);\nSQLITE_PRIVATE LogEst sqlite3LogEst(u64);\nSQLITE_PRIVATE LogEst sqlite3LogEstAdd(LogEst,LogEst);\n#ifndef SQLITE_OMIT_VIRTUALTABLE\nSQLITE_PRIVATE LogEst sqlite3LogEstFromDouble(double);\n#endif\n#if defined(SQLITE_ENABLE_STMT_SCANSTATUS) || \\\n    defined(SQLITE_ENABLE_STAT3_OR_STAT4) || \\\n    defined(SQLITE_EXPLAIN_ESTIMATED_ROWS)\nSQLITE_PRIVATE u64 sqlite3LogEstToInt(LogEst);\n#endif\nSQLITE_PRIVATE VList *sqlite3VListAdd(sqlite3*,VList*,const char*,int,int);\nSQLITE_PRIVATE const char *sqlite3VListNumToName(VList*,int);\nSQLITE_PRIVATE int sqlite3VListNameToNum(VList*,const char*,int);\n\n/*\n** Routines to read and write variable-length integers.  These used to\n** be defined locally, but now we use the varint routines in the util.c\n** file.\n*/\nSQLITE_PRIVATE int sqlite3PutVarint(unsigned char*, u64);\nSQLITE_PRIVATE u8 sqlite3GetVarint(const unsigned char *, u64 *);\nSQLITE_PRIVATE u8 sqlite3GetVarint32(const unsigned char *, u32 *);\nSQLITE_PRIVATE int sqlite3VarintLen(u64 v);\n\n/*\n** The common case is for a varint to be a single byte.  They following\n** macros handle the common case without a procedure call, but then call\n** the procedure for larger varints.\n*/\n#define getVarint32(A,B)  \\\n  (u8)((*(A)<(u8)0x80)?((B)=(u32)*(A)),1:sqlite3GetVarint32((A),(u32 *)&(B)))\n#define putVarint32(A,B)  \\\n  (u8)(((u32)(B)<(u32)0x80)?(*(A)=(unsigned char)(B)),1:\\\n  sqlite3PutVarint((A),(B)))\n#define getVarint    sqlite3GetVarint\n#define putVarint    sqlite3PutVarint\n\n\nSQLITE_PRIVATE const char *sqlite3IndexAffinityStr(sqlite3*, Index*);\nSQLITE_PRIVATE void sqlite3TableAffinity(Vdbe*, Table*, int);\nSQLITE_PRIVATE char sqlite3CompareAffinity(Expr *pExpr, char aff2);\nSQLITE_PRIVATE int sqlite3IndexAffinityOk(Expr *pExpr, char idx_affinity);\nSQLITE_PRIVATE char sqlite3TableColumnAffinity(Table*,int);\nSQLITE_PRIVATE char sqlite3ExprAffinity(Expr *pExpr);\nSQLITE_PRIVATE int sqlite3Atoi64(const char*, i64*, int, u8);\nSQLITE_PRIVATE int sqlite3DecOrHexToI64(const char*, i64*);\nSQLITE_PRIVATE void sqlite3ErrorWithMsg(sqlite3*, int, const char*,...);\nSQLITE_PRIVATE void sqlite3Error(sqlite3*,int);\nSQLITE_PRIVATE void sqlite3SystemError(sqlite3*,int);\nSQLITE_PRIVATE void *sqlite3HexToBlob(sqlite3*, const char *z, int n);\nSQLITE_PRIVATE u8 sqlite3HexToInt(int h);\nSQLITE_PRIVATE int sqlite3TwoPartName(Parse *, Token *, Token *, Token **);\n\n#if defined(SQLITE_NEED_ERR_NAME)\nSQLITE_PRIVATE const char *sqlite3ErrName(int);\n#endif\n\n#ifdef SQLITE_ENABLE_DESERIALIZE\nSQLITE_PRIVATE int sqlite3MemdbInit(void);\n#endif\n\nSQLITE_PRIVATE const char *sqlite3ErrStr(int);\nSQLITE_PRIVATE int sqlite3ReadSchema(Parse *pParse);\nSQLITE_PRIVATE CollSeq *sqlite3FindCollSeq(sqlite3*,u8 enc, const char*,int);\nSQLITE_PRIVATE int sqlite3IsBinary(const CollSeq*);\nSQLITE_PRIVATE CollSeq *sqlite3LocateCollSeq(Parse *pParse, const char*zName);\nSQLITE_PRIVATE CollSeq *sqlite3ExprCollSeq(Parse *pParse, Expr *pExpr);\nSQLITE_PRIVATE CollSeq *sqlite3ExprNNCollSeq(Parse *pParse, Expr *pExpr);\nSQLITE_PRIVATE int sqlite3ExprCollSeqMatch(Parse*,Expr*,Expr*);\nSQLITE_PRIVATE Expr *sqlite3ExprAddCollateToken(Parse *pParse, Expr*, const Token*, int);\nSQLITE_PRIVATE Expr *sqlite3ExprAddCollateString(Parse*,Expr*,const char*);\nSQLITE_PRIVATE Expr *sqlite3ExprSkipCollate(Expr*);\nSQLITE_PRIVATE int sqlite3CheckCollSeq(Parse *, CollSeq *);\nSQLITE_PRIVATE int sqlite3WritableSchema(sqlite3*);\nSQLITE_PRIVATE int sqlite3CheckObjectName(Parse *, const char *);\nSQLITE_PRIVATE void sqlite3VdbeSetChanges(sqlite3 *, int);\nSQLITE_PRIVATE int sqlite3AddInt64(i64*,i64);\nSQLITE_PRIVATE int sqlite3SubInt64(i64*,i64);\nSQLITE_PRIVATE int sqlite3MulInt64(i64*,i64);\nSQLITE_PRIVATE int sqlite3AbsInt32(int);\n#ifdef SQLITE_ENABLE_8_3_NAMES\nSQLITE_PRIVATE void sqlite3FileSuffix3(const char*, char*);\n#else\n# define sqlite3FileSuffix3(X,Y)\n#endif\nSQLITE_PRIVATE u8 sqlite3GetBoolean(const char *z,u8);\n\nSQLITE_PRIVATE const void *sqlite3ValueText(sqlite3_value*, u8);\nSQLITE_PRIVATE int sqlite3ValueBytes(sqlite3_value*, u8);\nSQLITE_PRIVATE void sqlite3ValueSetStr(sqlite3_value*, int, const void *,u8,\n                        void(*)(void*));\nSQLITE_PRIVATE void sqlite3ValueSetNull(sqlite3_value*);\nSQLITE_PRIVATE void sqlite3ValueFree(sqlite3_value*);\nSQLITE_PRIVATE sqlite3_value *sqlite3ValueNew(sqlite3 *);\n#ifndef SQLITE_OMIT_UTF16\nSQLITE_PRIVATE char *sqlite3Utf16to8(sqlite3 *, const void*, int, u8);\n#endif\nSQLITE_PRIVATE int sqlite3ValueFromExpr(sqlite3 *, Expr *, u8, u8, sqlite3_value **);\nSQLITE_PRIVATE void sqlite3ValueApplyAffinity(sqlite3_value *, u8, u8);\n#ifndef SQLITE_AMALGAMATION\nSQLITE_PRIVATE const unsigned char sqlite3OpcodeProperty[];\nSQLITE_PRIVATE const char sqlite3StrBINARY[];\nSQLITE_PRIVATE const unsigned char sqlite3UpperToLower[];\nSQLITE_PRIVATE const unsigned char sqlite3CtypeMap[];\nSQLITE_PRIVATE const Token sqlite3IntTokens[];\nSQLITE_PRIVATE SQLITE_WSD struct Sqlite3Config sqlite3Config;\nSQLITE_PRIVATE FuncDefHash sqlite3BuiltinFunctions;\n#ifndef SQLITE_OMIT_WSD\nSQLITE_PRIVATE int sqlite3PendingByte;\n#endif\n#endif\n#ifdef VDBE_PROFILE\nSQLITE_PRIVATE sqlite3_uint64 sqlite3NProfileCnt;\n#endif\nSQLITE_PRIVATE void sqlite3RootPageMoved(sqlite3*, int, int, int);\nSQLITE_PRIVATE void sqlite3Reindex(Parse*, Token*, Token*);\nSQLITE_PRIVATE void sqlite3AlterFunctions(void);\nSQLITE_PRIVATE void sqlite3AlterRenameTable(Parse*, SrcList*, Token*);\nSQLITE_PRIVATE void sqlite3AlterRenameColumn(Parse*, SrcList*, Token*, Token*);\nSQLITE_PRIVATE int sqlite3GetToken(const unsigned char *, int *);\nSQLITE_PRIVATE void sqlite3NestedParse(Parse*, const char*, ...);\nSQLITE_PRIVATE void sqlite3ExpirePreparedStatements(sqlite3*, int);\nSQLITE_PRIVATE void sqlite3CodeRhsOfIN(Parse*, Expr*, int);\nSQLITE_PRIVATE int sqlite3CodeSubselect(Parse*, Expr*);\nSQLITE_PRIVATE void sqlite3SelectPrep(Parse*, Select*, NameContext*);\nSQLITE_PRIVATE void sqlite3SelectWrongNumTermsError(Parse *pParse, Select *p);\nSQLITE_PRIVATE int sqlite3MatchSpanName(const char*, const char*, const char*, const char*);\nSQLITE_PRIVATE int sqlite3ResolveExprNames(NameContext*, Expr*);\nSQLITE_PRIVATE int sqlite3ResolveExprListNames(NameContext*, ExprList*);\nSQLITE_PRIVATE void sqlite3ResolveSelectNames(Parse*, Select*, NameContext*);\nSQLITE_PRIVATE int sqlite3ResolveSelfReference(Parse*,Table*,int,Expr*,ExprList*);\nSQLITE_PRIVATE int sqlite3ResolveOrderGroupBy(Parse*, Select*, ExprList*, const char*);\nSQLITE_PRIVATE void sqlite3ColumnDefault(Vdbe *, Table *, int, int);\nSQLITE_PRIVATE void sqlite3AlterFinishAddColumn(Parse *, Token *);\nSQLITE_PRIVATE void sqlite3AlterBeginAddColumn(Parse *, SrcList *);\nSQLITE_PRIVATE void *sqlite3RenameTokenMap(Parse*, void*, Token*);\nSQLITE_PRIVATE void sqlite3RenameTokenRemap(Parse*, void *pTo, void *pFrom);\nSQLITE_PRIVATE void sqlite3RenameExprUnmap(Parse*, Expr*);\nSQLITE_PRIVATE void sqlite3RenameExprlistUnmap(Parse*, ExprList*);\nSQLITE_PRIVATE CollSeq *sqlite3GetCollSeq(Parse*, u8, CollSeq *, const char*);\nSQLITE_PRIVATE char sqlite3AffinityType(const char*, Column*);\nSQLITE_PRIVATE void sqlite3Analyze(Parse*, Token*, Token*);\nSQLITE_PRIVATE int sqlite3InvokeBusyHandler(BusyHandler*, sqlite3_file*);\nSQLITE_PRIVATE int sqlite3FindDb(sqlite3*, Token*);\nSQLITE_PRIVATE int sqlite3FindDbName(sqlite3 *, const char *);\nSQLITE_PRIVATE int sqlite3AnalysisLoad(sqlite3*,int iDB);\nSQLITE_PRIVATE void sqlite3DeleteIndexSamples(sqlite3*,Index*);\nSQLITE_PRIVATE void sqlite3DefaultRowEst(Index*);\nSQLITE_PRIVATE void sqlite3RegisterLikeFunctions(sqlite3*, int);\nSQLITE_PRIVATE int sqlite3IsLikeFunction(sqlite3*,Expr*,int*,char*);\nSQLITE_PRIVATE void sqlite3SchemaClear(void *);\nSQLITE_PRIVATE Schema *sqlite3SchemaGet(sqlite3 *, Btree *);\nSQLITE_PRIVATE int sqlite3SchemaToIndex(sqlite3 *db, Schema *);\nSQLITE_PRIVATE KeyInfo *sqlite3KeyInfoAlloc(sqlite3*,int,int);\nSQLITE_PRIVATE void sqlite3KeyInfoUnref(KeyInfo*);\nSQLITE_PRIVATE KeyInfo *sqlite3KeyInfoRef(KeyInfo*);\nSQLITE_PRIVATE KeyInfo *sqlite3KeyInfoOfIndex(Parse*, Index*);\nSQLITE_PRIVATE KeyInfo *sqlite3KeyInfoFromExprList(Parse*, ExprList*, int, int);\n\n#ifdef SQLITE_DEBUG\nSQLITE_PRIVATE int sqlite3KeyInfoIsWriteable(KeyInfo*);\n#endif\nSQLITE_PRIVATE int sqlite3CreateFunc(sqlite3 *, const char *, int, int, void *,\n  void (*)(sqlite3_context*,int,sqlite3_value **),\n  void (*)(sqlite3_context*,int,sqlite3_value **), \n  void (*)(sqlite3_context*),\n  void (*)(sqlite3_context*),\n  void (*)(sqlite3_context*,int,sqlite3_value **), \n  FuncDestructor *pDestructor\n);\nSQLITE_PRIVATE void sqlite3NoopDestructor(void*);\nSQLITE_PRIVATE void sqlite3OomFault(sqlite3*);\nSQLITE_PRIVATE void sqlite3OomClear(sqlite3*);\nSQLITE_PRIVATE int sqlite3ApiExit(sqlite3 *db, int);\nSQLITE_PRIVATE int sqlite3OpenTempDatabase(Parse *);\n\nSQLITE_PRIVATE void sqlite3StrAccumInit(StrAccum*, sqlite3*, char*, int, int);\nSQLITE_PRIVATE char *sqlite3StrAccumFinish(StrAccum*);\nSQLITE_PRIVATE void sqlite3SelectDestInit(SelectDest*,int,int);\nSQLITE_PRIVATE Expr *sqlite3CreateColumnExpr(sqlite3 *, SrcList *, int, int);\n\nSQLITE_PRIVATE void sqlite3BackupRestart(sqlite3_backup *);\nSQLITE_PRIVATE void sqlite3BackupUpdate(sqlite3_backup *, Pgno, const u8 *);\n\n#ifndef SQLITE_OMIT_SUBQUERY\nSQLITE_PRIVATE int sqlite3ExprCheckIN(Parse*, Expr*);\n#else\n# define sqlite3ExprCheckIN(x,y) SQLITE_OK\n#endif\n\n#ifdef SQLITE_ENABLE_STAT3_OR_STAT4\nSQLITE_PRIVATE void sqlite3AnalyzeFunctions(void);\nSQLITE_PRIVATE int sqlite3Stat4ProbeSetValue(\n    Parse*,Index*,UnpackedRecord**,Expr*,int,int,int*);\nSQLITE_PRIVATE int sqlite3Stat4ValueFromExpr(Parse*, Expr*, u8, sqlite3_value**);\nSQLITE_PRIVATE void sqlite3Stat4ProbeFree(UnpackedRecord*);\nSQLITE_PRIVATE int sqlite3Stat4Column(sqlite3*, const void*, int, int, sqlite3_value**);\nSQLITE_PRIVATE char sqlite3IndexColumnAffinity(sqlite3*, Index*, int);\n#endif\n\n/*\n** The interface to the LEMON-generated parser\n*/\n#ifndef SQLITE_AMALGAMATION\nSQLITE_PRIVATE   void *sqlite3ParserAlloc(void*(*)(u64), Parse*);\nSQLITE_PRIVATE   void sqlite3ParserFree(void*, void(*)(void*));\n#endif\nSQLITE_PRIVATE void sqlite3Parser(void*, int, Token);\nSQLITE_PRIVATE int sqlite3ParserFallback(int);\n#ifdef YYTRACKMAXSTACKDEPTH\nSQLITE_PRIVATE   int sqlite3ParserStackPeak(void*);\n#endif\n\nSQLITE_PRIVATE void sqlite3AutoLoadExtensions(sqlite3*);\n#ifndef SQLITE_OMIT_LOAD_EXTENSION\nSQLITE_PRIVATE   void sqlite3CloseExtensions(sqlite3*);\n#else\n# define sqlite3CloseExtensions(X)\n#endif\n\n#ifndef SQLITE_OMIT_SHARED_CACHE\nSQLITE_PRIVATE   void sqlite3TableLock(Parse *, int, int, u8, const char *);\n#else\n  #define sqlite3TableLock(v,w,x,y,z)\n#endif\n\n#ifdef SQLITE_TEST\nSQLITE_PRIVATE   int sqlite3Utf8To8(unsigned char*);\n#endif\n\n#ifdef SQLITE_OMIT_VIRTUALTABLE\n#  define sqlite3VtabClear(Y)\n#  define sqlite3VtabSync(X,Y) SQLITE_OK\n#  define sqlite3VtabRollback(X)\n#  define sqlite3VtabCommit(X)\n#  define sqlite3VtabInSync(db) 0\n#  define sqlite3VtabLock(X)\n#  define sqlite3VtabUnlock(X)\n#  define sqlite3VtabUnlockList(X)\n#  define sqlite3VtabSavepoint(X, Y, Z) SQLITE_OK\n#  define sqlite3GetVTable(X,Y)  ((VTable*)0)\n#else\nSQLITE_PRIVATE    void sqlite3VtabClear(sqlite3 *db, Table*);\nSQLITE_PRIVATE    void sqlite3VtabDisconnect(sqlite3 *db, Table *p);\nSQLITE_PRIVATE    int sqlite3VtabSync(sqlite3 *db, Vdbe*);\nSQLITE_PRIVATE    int sqlite3VtabRollback(sqlite3 *db);\nSQLITE_PRIVATE    int sqlite3VtabCommit(sqlite3 *db);\nSQLITE_PRIVATE    void sqlite3VtabLock(VTable *);\nSQLITE_PRIVATE    void sqlite3VtabUnlock(VTable *);\nSQLITE_PRIVATE    void sqlite3VtabUnlockList(sqlite3*);\nSQLITE_PRIVATE    int sqlite3VtabSavepoint(sqlite3 *, int, int);\nSQLITE_PRIVATE    void sqlite3VtabImportErrmsg(Vdbe*, sqlite3_vtab*);\nSQLITE_PRIVATE    VTable *sqlite3GetVTable(sqlite3*, Table*);\nSQLITE_PRIVATE    Module *sqlite3VtabCreateModule(\n     sqlite3*,\n     const char*,\n     const sqlite3_module*,\n     void*,\n     void(*)(void*)\n   );\n#  define sqlite3VtabInSync(db) ((db)->nVTrans>0 && (db)->aVTrans==0)\n#endif\nSQLITE_PRIVATE int sqlite3VtabEponymousTableInit(Parse*,Module*);\nSQLITE_PRIVATE void sqlite3VtabEponymousTableClear(sqlite3*,Module*);\nSQLITE_PRIVATE void sqlite3VtabMakeWritable(Parse*,Table*);\nSQLITE_PRIVATE void sqlite3VtabBeginParse(Parse*, Token*, Token*, Token*, int);\nSQLITE_PRIVATE void sqlite3VtabFinishParse(Parse*, Token*);\nSQLITE_PRIVATE void sqlite3VtabArgInit(Parse*);\nSQLITE_PRIVATE void sqlite3VtabArgExtend(Parse*, Token*);\nSQLITE_PRIVATE int sqlite3VtabCallCreate(sqlite3*, int, const char *, char **);\nSQLITE_PRIVATE int sqlite3VtabCallConnect(Parse*, Table*);\nSQLITE_PRIVATE int sqlite3VtabCallDestroy(sqlite3*, int, const char *);\nSQLITE_PRIVATE int sqlite3VtabBegin(sqlite3 *, VTable *);\nSQLITE_PRIVATE FuncDef *sqlite3VtabOverloadFunction(sqlite3 *,FuncDef*, int nArg, Expr*);\nSQLITE_PRIVATE sqlite3_int64 sqlite3StmtCurrentTime(sqlite3_context*);\nSQLITE_PRIVATE int sqlite3VdbeParameterIndex(Vdbe*, const char*, int);\nSQLITE_PRIVATE int sqlite3TransferBindings(sqlite3_stmt *, sqlite3_stmt *);\nSQLITE_PRIVATE void sqlite3ParserReset(Parse*);\n#ifdef SQLITE_ENABLE_NORMALIZE\nSQLITE_PRIVATE char *sqlite3Normalize(Vdbe*, const char*);\n#endif\nSQLITE_PRIVATE int sqlite3Reprepare(Vdbe*);\nSQLITE_PRIVATE void sqlite3ExprListCheckLength(Parse*, ExprList*, const char*);\nSQLITE_PRIVATE CollSeq *sqlite3BinaryCompareCollSeq(Parse *, Expr *, Expr *);\nSQLITE_PRIVATE int sqlite3TempInMemory(const sqlite3*);\nSQLITE_PRIVATE const char *sqlite3JournalModename(int);\n#ifndef SQLITE_OMIT_WAL\nSQLITE_PRIVATE   int sqlite3Checkpoint(sqlite3*, int, int, int*, int*);\nSQLITE_PRIVATE   int sqlite3WalDefaultHook(void*,sqlite3*,const char*,int);\n#endif\n#ifndef SQLITE_OMIT_CTE\nSQLITE_PRIVATE   With *sqlite3WithAdd(Parse*,With*,Token*,ExprList*,Select*);\nSQLITE_PRIVATE   void sqlite3WithDelete(sqlite3*,With*);\nSQLITE_PRIVATE   void sqlite3WithPush(Parse*, With*, u8);\n#else\n#define sqlite3WithPush(x,y,z)\n#define sqlite3WithDelete(x,y)\n#endif\n#ifndef SQLITE_OMIT_UPSERT\nSQLITE_PRIVATE   Upsert *sqlite3UpsertNew(sqlite3*,ExprList*,Expr*,ExprList*,Expr*);\nSQLITE_PRIVATE   void sqlite3UpsertDelete(sqlite3*,Upsert*);\nSQLITE_PRIVATE   Upsert *sqlite3UpsertDup(sqlite3*,Upsert*);\nSQLITE_PRIVATE   int sqlite3UpsertAnalyzeTarget(Parse*,SrcList*,Upsert*);\nSQLITE_PRIVATE   void sqlite3UpsertDoUpdate(Parse*,Upsert*,Table*,Index*,int);\n#else\n#define sqlite3UpsertNew(v,w,x,y,z) ((Upsert*)0)\n#define sqlite3UpsertDelete(x,y)\n#define sqlite3UpsertDup(x,y)       ((Upsert*)0)\n#endif\n\n\n/* Declarations for functions in fkey.c. All of these are replaced by\n** no-op macros if OMIT_FOREIGN_KEY is defined. In this case no foreign\n** key functionality is available. If OMIT_TRIGGER is defined but\n** OMIT_FOREIGN_KEY is not, only some of the functions are no-oped. In\n** this case foreign keys are parsed, but no other functionality is\n** provided (enforcement of FK constraints requires the triggers sub-system).\n*/\n#if !defined(SQLITE_OMIT_FOREIGN_KEY) && !defined(SQLITE_OMIT_TRIGGER)\nSQLITE_PRIVATE   void sqlite3FkCheck(Parse*, Table*, int, int, int*, int);\nSQLITE_PRIVATE   void sqlite3FkDropTable(Parse*, SrcList *, Table*);\nSQLITE_PRIVATE   void sqlite3FkActions(Parse*, Table*, ExprList*, int, int*, int);\nSQLITE_PRIVATE   int sqlite3FkRequired(Parse*, Table*, int*, int);\nSQLITE_PRIVATE   u32 sqlite3FkOldmask(Parse*, Table*);\nSQLITE_PRIVATE   FKey *sqlite3FkReferences(Table *);\n#else\n  #define sqlite3FkActions(a,b,c,d,e,f)\n  #define sqlite3FkCheck(a,b,c,d,e,f)\n  #define sqlite3FkDropTable(a,b,c)\n  #define sqlite3FkOldmask(a,b)         0\n  #define sqlite3FkRequired(a,b,c,d)    0\n  #define sqlite3FkReferences(a)        0\n#endif\n#ifndef SQLITE_OMIT_FOREIGN_KEY\nSQLITE_PRIVATE   void sqlite3FkDelete(sqlite3 *, Table*);\nSQLITE_PRIVATE   int sqlite3FkLocateIndex(Parse*,Table*,FKey*,Index**,int**);\n#else\n  #define sqlite3FkDelete(a,b)\n  #define sqlite3FkLocateIndex(a,b,c,d,e)\n#endif\n\n\n/*\n** Available fault injectors.  Should be numbered beginning with 0.\n*/\n#define SQLITE_FAULTINJECTOR_MALLOC     0\n#define SQLITE_FAULTINJECTOR_COUNT      1\n\n/*\n** The interface to the code in fault.c used for identifying \"benign\"\n** malloc failures. This is only present if SQLITE_UNTESTABLE\n** is not defined.\n*/\n#ifndef SQLITE_UNTESTABLE\nSQLITE_PRIVATE   void sqlite3BeginBenignMalloc(void);\nSQLITE_PRIVATE   void sqlite3EndBenignMalloc(void);\n#else\n  #define sqlite3BeginBenignMalloc()\n  #define sqlite3EndBenignMalloc()\n#endif\n\n/*\n** Allowed return values from sqlite3FindInIndex()\n*/\n#define IN_INDEX_ROWID        1   /* Search the rowid of the table */\n#define IN_INDEX_EPH          2   /* Search an ephemeral b-tree */\n#define IN_INDEX_INDEX_ASC    3   /* Existing index ASCENDING */\n#define IN_INDEX_INDEX_DESC   4   /* Existing index DESCENDING */\n#define IN_INDEX_NOOP         5   /* No table available. Use comparisons */\n/*\n** Allowed flags for the 3rd parameter to sqlite3FindInIndex().\n*/\n#define IN_INDEX_NOOP_OK     0x0001  /* OK to return IN_INDEX_NOOP */\n#define IN_INDEX_MEMBERSHIP  0x0002  /* IN operator used for membership test */\n#define IN_INDEX_LOOP        0x0004  /* IN operator used as a loop */\nSQLITE_PRIVATE int sqlite3FindInIndex(Parse *, Expr *, u32, int*, int*, int*);\n\nSQLITE_PRIVATE int sqlite3JournalOpen(sqlite3_vfs *, const char *, sqlite3_file *, int, int);\nSQLITE_PRIVATE int sqlite3JournalSize(sqlite3_vfs *);\n#if defined(SQLITE_ENABLE_ATOMIC_WRITE) \\\n || defined(SQLITE_ENABLE_BATCH_ATOMIC_WRITE)\nSQLITE_PRIVATE   int sqlite3JournalCreate(sqlite3_file *);\n#endif\n\nSQLITE_PRIVATE int sqlite3JournalIsInMemory(sqlite3_file *p);\nSQLITE_PRIVATE void sqlite3MemJournalOpen(sqlite3_file *);\n\nSQLITE_PRIVATE void sqlite3ExprSetHeightAndFlags(Parse *pParse, Expr *p);\n#if SQLITE_MAX_EXPR_DEPTH>0\nSQLITE_PRIVATE   int sqlite3SelectExprHeight(Select *);\nSQLITE_PRIVATE   int sqlite3ExprCheckHeight(Parse*, int);\n#else\n  #define sqlite3SelectExprHeight(x) 0\n  #define sqlite3ExprCheckHeight(x,y)\n#endif\n\nSQLITE_PRIVATE u32 sqlite3Get4byte(const u8*);\nSQLITE_PRIVATE void sqlite3Put4byte(u8*, u32);\n\n#ifdef SQLITE_ENABLE_UNLOCK_NOTIFY\nSQLITE_PRIVATE   void sqlite3ConnectionBlocked(sqlite3 *, sqlite3 *);\nSQLITE_PRIVATE   void sqlite3ConnectionUnlocked(sqlite3 *db);\nSQLITE_PRIVATE   void sqlite3ConnectionClosed(sqlite3 *db);\n#else\n  #define sqlite3ConnectionBlocked(x,y)\n  #define sqlite3ConnectionUnlocked(x)\n  #define sqlite3ConnectionClosed(x)\n#endif\n\n#ifdef SQLITE_DEBUG\nSQLITE_PRIVATE   void sqlite3ParserTrace(FILE*, char *);\n#endif\n#if defined(YYCOVERAGE)\nSQLITE_PRIVATE   int sqlite3ParserCoverage(FILE*);\n#endif\n\n/*\n** If the SQLITE_ENABLE IOTRACE exists then the global variable\n** sqlite3IoTrace is a pointer to a printf-like routine used to\n** print I/O tracing messages.\n*/\n#ifdef SQLITE_ENABLE_IOTRACE\n# define IOTRACE(A)  if( sqlite3IoTrace ){ sqlite3IoTrace A; }\nSQLITE_PRIVATE   void sqlite3VdbeIOTraceSql(Vdbe*);\nSQLITE_API SQLITE_EXTERN void (SQLITE_CDECL *sqlite3IoTrace)(const char*,...);\n#else\n# define IOTRACE(A)\n# define sqlite3VdbeIOTraceSql(X)\n#endif\n\n/*\n** These routines are available for the mem2.c debugging memory allocator\n** only.  They are used to verify that different \"types\" of memory\n** allocations are properly tracked by the system.\n**\n** sqlite3MemdebugSetType() sets the \"type\" of an allocation to one of\n** the MEMTYPE_* macros defined below.  The type must be a bitmask with\n** a single bit set.\n**\n** sqlite3MemdebugHasType() returns true if any of the bits in its second\n** argument match the type set by the previous sqlite3MemdebugSetType().\n** sqlite3MemdebugHasType() is intended for use inside assert() statements.\n**\n** sqlite3MemdebugNoType() returns true if none of the bits in its second\n** argument match the type set by the previous sqlite3MemdebugSetType().\n**\n** Perhaps the most important point is the difference between MEMTYPE_HEAP\n** and MEMTYPE_LOOKASIDE.  If an allocation is MEMTYPE_LOOKASIDE, that means\n** it might have been allocated by lookaside, except the allocation was\n** too large or lookaside was already full.  It is important to verify\n** that allocations that might have been satisfied by lookaside are not\n** passed back to non-lookaside free() routines.  Asserts such as the\n** example above are placed on the non-lookaside free() routines to verify\n** this constraint.\n**\n** All of this is no-op for a production build.  It only comes into\n** play when the SQLITE_MEMDEBUG compile-time option is used.\n*/\n#ifdef SQLITE_MEMDEBUG\nSQLITE_PRIVATE   void sqlite3MemdebugSetType(void*,u8);\nSQLITE_PRIVATE   int sqlite3MemdebugHasType(void*,u8);\nSQLITE_PRIVATE   int sqlite3MemdebugNoType(void*,u8);\n#else\n# define sqlite3MemdebugSetType(X,Y)  /* no-op */\n# define sqlite3MemdebugHasType(X,Y)  1\n# define sqlite3MemdebugNoType(X,Y)   1\n#endif\n#define MEMTYPE_HEAP       0x01  /* General heap allocations */\n#define MEMTYPE_LOOKASIDE  0x02  /* Heap that might have been lookaside */\n#define MEMTYPE_PCACHE     0x04  /* Page cache allocations */\n\n/*\n** Threading interface\n*/\n#if SQLITE_MAX_WORKER_THREADS>0\nSQLITE_PRIVATE int sqlite3ThreadCreate(SQLiteThread**,void*(*)(void*),void*);\nSQLITE_PRIVATE int sqlite3ThreadJoin(SQLiteThread*, void**);\n#endif\n\n#if defined(SQLITE_ENABLE_DBPAGE_VTAB) || defined(SQLITE_TEST)\nSQLITE_PRIVATE int sqlite3DbpageRegister(sqlite3*);\n#endif\n#if defined(SQLITE_ENABLE_DBSTAT_VTAB) || defined(SQLITE_TEST)\nSQLITE_PRIVATE int sqlite3DbstatRegister(sqlite3*);\n#endif\n\nSQLITE_PRIVATE int sqlite3ExprVectorSize(Expr *pExpr);\nSQLITE_PRIVATE int sqlite3ExprIsVector(Expr *pExpr);\nSQLITE_PRIVATE Expr *sqlite3VectorFieldSubexpr(Expr*, int);\nSQLITE_PRIVATE Expr *sqlite3ExprForVectorField(Parse*,Expr*,int);\nSQLITE_PRIVATE void sqlite3VectorErrorMsg(Parse*, Expr*);\n\n#ifndef SQLITE_OMIT_COMPILEOPTION_DIAGS\nSQLITE_PRIVATE const char **sqlite3CompileOptions(int *pnOpt);\n#endif\n\n#endif /* SQLITEINT_H */\n\n/************** End of sqliteInt.h *******************************************/\n/************** Begin file crypto.c ******************************************/\n/* \n** SQLCipher\n** http://sqlcipher.net\n** \n** Copyright (c) 2008 - 2013, ZETETIC LLC\n** All rights reserved.\n** \n** Redistribution and use in source and binary forms, with or without\n** modification, are permitted provided that the following conditions are met:\n**     * Redistributions of source code must retain the above copyright\n**       notice, this list of conditions and the following disclaimer.\n**     * Redistributions in binary form must reproduce the above copyright\n**       notice, this list of conditions and the following disclaimer in the\n**       documentation and/or other materials provided with the distribution.\n**     * Neither the name of the ZETETIC LLC nor the\n**       names of its contributors may be used to endorse or promote products\n**       derived from this software without specific prior written permission.\n** \n** THIS SOFTWARE IS PROVIDED BY ZETETIC LLC ''AS IS'' AND ANY\n** EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n** DISCLAIMED. IN NO EVENT SHALL ZETETIC LLC BE LIABLE FOR ANY\n** DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n** (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n** LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n** ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n**  \n*/\n/* BEGIN SQLCIPHER */\n#ifdef SQLITE_HAS_CODEC\n\n/* #include <assert.h> */\n/************** Include sqlcipher.h in the middle of crypto.c ****************/\n/************** Begin file sqlcipher.h ***************************************/\n/* \n** SQLCipher\n** sqlcipher.h developed by Stephen Lombardo (Zetetic LLC) \n** sjlombardo at zetetic dot net\n** http://zetetic.net\n** \n** Copyright (c) 2008, ZETETIC LLC\n** All rights reserved.\n** \n** Redistribution and use in source and binary forms, with or without\n** modification, are permitted provided that the following conditions are met:\n**     * Redistributions of source code must retain the above copyright\n**       notice, this list of conditions and the following disclaimer.\n**     * Redistributions in binary form must reproduce the above copyright\n**       notice, this list of conditions and the following disclaimer in the\n**       documentation and/or other materials provided with the distribution.\n**     * Neither the name of the ZETETIC LLC nor the\n**       names of its contributors may be used to endorse or promote products\n**       derived from this software without specific prior written permission.\n** \n** THIS SOFTWARE IS PROVIDED BY ZETETIC LLC ''AS IS'' AND ANY\n** EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n** DISCLAIMED. IN NO EVENT SHALL ZETETIC LLC BE LIABLE FOR ANY\n** DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n** (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n** LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n** ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n**  \n*/\n/* BEGIN SQLCIPHER */\n#ifdef SQLITE_HAS_CODEC\n#ifndef SQLCIPHER_H\n#define SQLCIPHER_H\n\n#define SQLCIPHER_HMAC_SHA1 0\n#define SQLCIPHER_HMAC_SHA1_LABEL \"HMAC_SHA1\"\n#define SQLCIPHER_HMAC_SHA256 1\n#define SQLCIPHER_HMAC_SHA256_LABEL \"HMAC_SHA256\"\n#define SQLCIPHER_HMAC_SHA512 2\n#define SQLCIPHER_HMAC_SHA512_LABEL \"HMAC_SHA512\"\n\n\n#define SQLCIPHER_PBKDF2_HMAC_SHA1 0\n#define SQLCIPHER_PBKDF2_HMAC_SHA1_LABEL \"PBKDF2_HMAC_SHA1\"\n#define SQLCIPHER_PBKDF2_HMAC_SHA256 1\n#define SQLCIPHER_PBKDF2_HMAC_SHA256_LABEL \"PBKDF2_HMAC_SHA256\"\n#define SQLCIPHER_PBKDF2_HMAC_SHA512 2\n#define SQLCIPHER_PBKDF2_HMAC_SHA512_LABEL \"PBKDF2_HMAC_SHA512\"\n\n\ntypedef struct {\n  int (*activate)(void *ctx);\n  int (*deactivate)(void *ctx);\n  const char* (*get_provider_name)(void *ctx);\n  int (*add_random)(void *ctx, void *buffer, int length);\n  int (*random)(void *ctx, void *buffer, int length);\n  int (*hmac)(void *ctx, int algorithm, unsigned char *hmac_key, int key_sz, unsigned char *in, int in_sz, unsigned char *in2, int in2_sz, unsigned char *out);\n  int (*kdf)(void *ctx, int algorithm, const unsigned char *pass, int pass_sz, unsigned char* salt, int salt_sz, int workfactor, int key_sz, unsigned char *key);\n  int (*cipher)(void *ctx, int mode, unsigned char *key, int key_sz, unsigned char *iv, unsigned char *in, int in_sz, unsigned char *out);\n  const char* (*get_cipher)(void *ctx);\n  int (*get_key_sz)(void *ctx);\n  int (*get_iv_sz)(void *ctx);\n  int (*get_block_sz)(void *ctx);\n  int (*get_hmac_sz)(void *ctx, int algorithm);\n  int (*ctx_copy)(void *target_ctx, void *source_ctx);\n  int (*ctx_cmp)(void *c1, void *c2);\n  int (*ctx_init)(void **ctx);\n  int (*ctx_free)(void **ctx);\n  int (*fips_status)(void *ctx);\n  const char* (*get_provider_version)(void *ctx);\n} sqlcipher_provider;\n\n/* provider interfaces */\nint sqlcipher_register_provider(sqlcipher_provider *p);\nsqlcipher_provider* sqlcipher_get_provider();\n\n#endif\n#endif\n/* END SQLCIPHER */\n\n\n/************** End of sqlcipher.h *******************************************/\n/************** Continuing where we left off in crypto.c *********************/\n/************** Include crypto.h in the middle of crypto.c *******************/\n/************** Begin file crypto.h ******************************************/\n/* \n** SQLCipher\n** crypto.h developed by Stephen Lombardo (Zetetic LLC) \n** sjlombardo at zetetic dot net\n** http://zetetic.net\n** \n** Copyright (c) 2008, ZETETIC LLC\n** All rights reserved.\n** \n** Redistribution and use in source and binary forms, with or without\n** modification, are permitted provided that the following conditions are met:\n**     * Redistributions of source code must retain the above copyright\n**       notice, this list of conditions and the following disclaimer.\n**     * Redistributions in binary form must reproduce the above copyright\n**       notice, this list of conditions and the following disclaimer in the\n**       documentation and/or other materials provided with the distribution.\n**     * Neither the name of the ZETETIC LLC nor the\n**       names of its contributors may be used to endorse or promote products\n**       derived from this software without specific prior written permission.\n** \n** THIS SOFTWARE IS PROVIDED BY ZETETIC LLC ''AS IS'' AND ANY\n** EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n** DISCLAIMED. IN NO EVENT SHALL ZETETIC LLC BE LIABLE FOR ANY\n** DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n** (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n** LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n** ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n**  \n*/\n/* BEGIN SQLCIPHER */\n#ifdef SQLITE_HAS_CODEC\n#ifndef CRYPTO_H\n#define CRYPTO_H\n\n/* #include \"sqliteInt.h\" */\n/************** Include btreeInt.h in the middle of crypto.h *****************/\n/************** Begin file btreeInt.h ****************************************/\n/*\n** 2004 April 6\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This file implements an external (disk-based) database using BTrees.\n** For a detailed discussion of BTrees, refer to\n**\n**     Donald E. Knuth, THE ART OF COMPUTER PROGRAMMING, Volume 3:\n**     \"Sorting And Searching\", pages 473-480. Addison-Wesley\n**     Publishing Company, Reading, Massachusetts.\n**\n** The basic idea is that each page of the file contains N database\n** entries and N+1 pointers to subpages.\n**\n**   ----------------------------------------------------------------\n**   |  Ptr(0) | Key(0) | Ptr(1) | Key(1) | ... | Key(N-1) | Ptr(N) |\n**   ----------------------------------------------------------------\n**\n** All of the keys on the page that Ptr(0) points to have values less\n** than Key(0).  All of the keys on page Ptr(1) and its subpages have\n** values greater than Key(0) and less than Key(1).  All of the keys\n** on Ptr(N) and its subpages have values greater than Key(N-1).  And\n** so forth.\n**\n** Finding a particular key requires reading O(log(M)) pages from the \n** disk where M is the number of entries in the tree.\n**\n** In this implementation, a single file can hold one or more separate \n** BTrees.  Each BTree is identified by the index of its root page.  The\n** key and data for any entry are combined to form the \"payload\".  A\n** fixed amount of payload can be carried directly on the database\n** page.  If the payload is larger than the preset amount then surplus\n** bytes are stored on overflow pages.  The payload for an entry\n** and the preceding pointer are combined to form a \"Cell\".  Each \n** page has a small header which contains the Ptr(N) pointer and other\n** information such as the size of key and data.\n**\n** FORMAT DETAILS\n**\n** The file is divided into pages.  The first page is called page 1,\n** the second is page 2, and so forth.  A page number of zero indicates\n** \"no such page\".  The page size can be any power of 2 between 512 and 65536.\n** Each page can be either a btree page, a freelist page, an overflow\n** page, or a pointer-map page.\n**\n** The first page is always a btree page.  The first 100 bytes of the first\n** page contain a special header (the \"file header\") that describes the file.\n** The format of the file header is as follows:\n**\n**   OFFSET   SIZE    DESCRIPTION\n**      0      16     Header string: \"SQLite format 3\\000\"\n**     16       2     Page size in bytes.  (1 means 65536)\n**     18       1     File format write version\n**     19       1     File format read version\n**     20       1     Bytes of unused space at the end of each page\n**     21       1     Max embedded payload fraction (must be 64)\n**     22       1     Min embedded payload fraction (must be 32)\n**     23       1     Min leaf payload fraction (must be 32)\n**     24       4     File change counter\n**     28       4     Reserved for future use\n**     32       4     First freelist page\n**     36       4     Number of freelist pages in the file\n**     40      60     15 4-byte meta values passed to higher layers\n**\n**     40       4     Schema cookie\n**     44       4     File format of schema layer\n**     48       4     Size of page cache\n**     52       4     Largest root-page (auto/incr_vacuum)\n**     56       4     1=UTF-8 2=UTF16le 3=UTF16be\n**     60       4     User version\n**     64       4     Incremental vacuum mode\n**     68       4     Application-ID\n**     72      20     unused\n**     92       4     The version-valid-for number\n**     96       4     SQLITE_VERSION_NUMBER\n**\n** All of the integer values are big-endian (most significant byte first).\n**\n** The file change counter is incremented when the database is changed\n** This counter allows other processes to know when the file has changed\n** and thus when they need to flush their cache.\n**\n** The max embedded payload fraction is the amount of the total usable\n** space in a page that can be consumed by a single cell for standard\n** B-tree (non-LEAFDATA) tables.  A value of 255 means 100%.  The default\n** is to limit the maximum cell size so that at least 4 cells will fit\n** on one page.  Thus the default max embedded payload fraction is 64.\n**\n** If the payload for a cell is larger than the max payload, then extra\n** payload is spilled to overflow pages.  Once an overflow page is allocated,\n** as many bytes as possible are moved into the overflow pages without letting\n** the cell size drop below the min embedded payload fraction.\n**\n** The min leaf payload fraction is like the min embedded payload fraction\n** except that it applies to leaf nodes in a LEAFDATA tree.  The maximum\n** payload fraction for a LEAFDATA tree is always 100% (or 255) and it\n** not specified in the header.\n**\n** Each btree pages is divided into three sections:  The header, the\n** cell pointer array, and the cell content area.  Page 1 also has a 100-byte\n** file header that occurs before the page header.\n**\n**      |----------------|\n**      | file header    |   100 bytes.  Page 1 only.\n**      |----------------|\n**      | page header    |   8 bytes for leaves.  12 bytes for interior nodes\n**      |----------------|\n**      | cell pointer   |   |  2 bytes per cell.  Sorted order.\n**      | array          |   |  Grows downward\n**      |                |   v\n**      |----------------|\n**      | unallocated    |\n**      | space          |\n**      |----------------|   ^  Grows upwards\n**      | cell content   |   |  Arbitrary order interspersed with freeblocks.\n**      | area           |   |  and free space fragments.\n**      |----------------|\n**\n** The page headers looks like this:\n**\n**   OFFSET   SIZE     DESCRIPTION\n**      0       1      Flags. 1: intkey, 2: zerodata, 4: leafdata, 8: leaf\n**      1       2      byte offset to the first freeblock\n**      3       2      number of cells on this page\n**      5       2      first byte of the cell content area\n**      7       1      number of fragmented free bytes\n**      8       4      Right child (the Ptr(N) value).  Omitted on leaves.\n**\n** The flags define the format of this btree page.  The leaf flag means that\n** this page has no children.  The zerodata flag means that this page carries\n** only keys and no data.  The intkey flag means that the key is an integer\n** which is stored in the key size entry of the cell header rather than in\n** the payload area.\n**\n** The cell pointer array begins on the first byte after the page header.\n** The cell pointer array contains zero or more 2-byte numbers which are\n** offsets from the beginning of the page to the cell content in the cell\n** content area.  The cell pointers occur in sorted order.  The system strives\n** to keep free space after the last cell pointer so that new cells can\n** be easily added without having to defragment the page.\n**\n** Cell content is stored at the very end of the page and grows toward the\n** beginning of the page.\n**\n** Unused space within the cell content area is collected into a linked list of\n** freeblocks.  Each freeblock is at least 4 bytes in size.  The byte offset\n** to the first freeblock is given in the header.  Freeblocks occur in\n** increasing order.  Because a freeblock must be at least 4 bytes in size,\n** any group of 3 or fewer unused bytes in the cell content area cannot\n** exist on the freeblock chain.  A group of 3 or fewer free bytes is called\n** a fragment.  The total number of bytes in all fragments is recorded.\n** in the page header at offset 7.\n**\n**    SIZE    DESCRIPTION\n**      2     Byte offset of the next freeblock\n**      2     Bytes in this freeblock\n**\n** Cells are of variable length.  Cells are stored in the cell content area at\n** the end of the page.  Pointers to the cells are in the cell pointer array\n** that immediately follows the page header.  Cells is not necessarily\n** contiguous or in order, but cell pointers are contiguous and in order.\n**\n** Cell content makes use of variable length integers.  A variable\n** length integer is 1 to 9 bytes where the lower 7 bits of each \n** byte are used.  The integer consists of all bytes that have bit 8 set and\n** the first byte with bit 8 clear.  The most significant byte of the integer\n** appears first.  A variable-length integer may not be more than 9 bytes long.\n** As a special case, all 8 bytes of the 9th byte are used as data.  This\n** allows a 64-bit integer to be encoded in 9 bytes.\n**\n**    0x00                      becomes  0x00000000\n**    0x7f                      becomes  0x0000007f\n**    0x81 0x00                 becomes  0x00000080\n**    0x82 0x00                 becomes  0x00000100\n**    0x80 0x7f                 becomes  0x0000007f\n**    0x8a 0x91 0xd1 0xac 0x78  becomes  0x12345678\n**    0x81 0x81 0x81 0x81 0x01  becomes  0x10204081\n**\n** Variable length integers are used for rowids and to hold the number of\n** bytes of key and data in a btree cell.\n**\n** The content of a cell looks like this:\n**\n**    SIZE    DESCRIPTION\n**      4     Page number of the left child. Omitted if leaf flag is set.\n**     var    Number of bytes of data. Omitted if the zerodata flag is set.\n**     var    Number of bytes of key. Or the key itself if intkey flag is set.\n**      *     Payload\n**      4     First page of the overflow chain.  Omitted if no overflow\n**\n** Overflow pages form a linked list.  Each page except the last is completely\n** filled with data (pagesize - 4 bytes).  The last page can have as little\n** as 1 byte of data.\n**\n**    SIZE    DESCRIPTION\n**      4     Page number of next overflow page\n**      *     Data\n**\n** Freelist pages come in two subtypes: trunk pages and leaf pages.  The\n** file header points to the first in a linked list of trunk page.  Each trunk\n** page points to multiple leaf pages.  The content of a leaf page is\n** unspecified.  A trunk page looks like this:\n**\n**    SIZE    DESCRIPTION\n**      4     Page number of next trunk page\n**      4     Number of leaf pointers on this page\n**      *     zero or more pages numbers of leaves\n*/\n/* #include \"sqliteInt.h\" */\n\n\n/* The following value is the maximum cell size assuming a maximum page\n** size give above.\n*/\n#define MX_CELL_SIZE(pBt)  ((int)(pBt->pageSize-8))\n\n/* The maximum number of cells on a single page of the database.  This\n** assumes a minimum cell size of 6 bytes  (4 bytes for the cell itself\n** plus 2 bytes for the index to the cell in the page header).  Such\n** small cells will be rare, but they are possible.\n*/\n#define MX_CELL(pBt) ((pBt->pageSize-8)/6)\n\n/* Forward declarations */\ntypedef struct MemPage MemPage;\ntypedef struct BtLock BtLock;\ntypedef struct CellInfo CellInfo;\n\n/*\n** This is a magic string that appears at the beginning of every\n** SQLite database in order to identify the file as a real database.\n**\n** You can change this value at compile-time by specifying a\n** -DSQLITE_FILE_HEADER=\"...\" on the compiler command-line.  The\n** header must be exactly 16 bytes including the zero-terminator so\n** the string itself should be 15 characters long.  If you change\n** the header, then your custom library will not be able to read \n** databases generated by the standard tools and the standard tools\n** will not be able to read databases created by your custom library.\n*/\n#ifndef SQLITE_FILE_HEADER /* 123456789 123456 */\n#  define SQLITE_FILE_HEADER \"SQLite format 3\"\n#endif\n\n/*\n** Page type flags.  An ORed combination of these flags appear as the\n** first byte of on-disk image of every BTree page.\n*/\n#define PTF_INTKEY    0x01\n#define PTF_ZERODATA  0x02\n#define PTF_LEAFDATA  0x04\n#define PTF_LEAF      0x08\n\n/*\n** An instance of this object stores information about each a single database\n** page that has been loaded into memory.  The information in this object\n** is derived from the raw on-disk page content.\n**\n** As each database page is loaded into memory, the pager allocats an\n** instance of this object and zeros the first 8 bytes.  (This is the\n** \"extra\" information associated with each page of the pager.)\n**\n** Access to all fields of this structure is controlled by the mutex\n** stored in MemPage.pBt->mutex.\n*/\nstruct MemPage {\n  u8 isInit;           /* True if previously initialized. MUST BE FIRST! */\n  u8 bBusy;            /* Prevent endless loops on corrupt database files */\n  u8 intKey;           /* True if table b-trees.  False for index b-trees */\n  u8 intKeyLeaf;       /* True if the leaf of an intKey table */\n  Pgno pgno;           /* Page number for this page */\n  /* Only the first 8 bytes (above) are zeroed by pager.c when a new page\n  ** is allocated. All fields that follow must be initialized before use */\n  u8 leaf;             /* True if a leaf page */\n  u8 hdrOffset;        /* 100 for page 1.  0 otherwise */\n  u8 childPtrSize;     /* 0 if leaf==1.  4 if leaf==0 */\n  u8 max1bytePayload;  /* min(maxLocal,127) */\n  u8 nOverflow;        /* Number of overflow cell bodies in aCell[] */\n  u16 maxLocal;        /* Copy of BtShared.maxLocal or BtShared.maxLeaf */\n  u16 minLocal;        /* Copy of BtShared.minLocal or BtShared.minLeaf */\n  u16 cellOffset;      /* Index in aData of first cell pointer */\n  u16 nFree;           /* Number of free bytes on the page */\n  u16 nCell;           /* Number of cells on this page, local and ovfl */\n  u16 maskPage;        /* Mask for page offset */\n  u16 aiOvfl[4];       /* Insert the i-th overflow cell before the aiOvfl-th\n                       ** non-overflow cell */\n  u8 *apOvfl[4];       /* Pointers to the body of overflow cells */\n  BtShared *pBt;       /* Pointer to BtShared that this page is part of */\n  u8 *aData;           /* Pointer to disk image of the page data */\n  u8 *aDataEnd;        /* One byte past the end of usable data */\n  u8 *aCellIdx;        /* The cell index area */\n  u8 *aDataOfst;       /* Same as aData for leaves.  aData+4 for interior */\n  DbPage *pDbPage;     /* Pager page handle */\n  u16 (*xCellSize)(MemPage*,u8*);             /* cellSizePtr method */\n  void (*xParseCell)(MemPage*,u8*,CellInfo*); /* btreeParseCell method */\n};\n\n/*\n** A linked list of the following structures is stored at BtShared.pLock.\n** Locks are added (or upgraded from READ_LOCK to WRITE_LOCK) when a cursor \n** is opened on the table with root page BtShared.iTable. Locks are removed\n** from this list when a transaction is committed or rolled back, or when\n** a btree handle is closed.\n*/\nstruct BtLock {\n  Btree *pBtree;        /* Btree handle holding this lock */\n  Pgno iTable;          /* Root page of table */\n  u8 eLock;             /* READ_LOCK or WRITE_LOCK */\n  BtLock *pNext;        /* Next in BtShared.pLock list */\n};\n\n/* Candidate values for BtLock.eLock */\n#define READ_LOCK     1\n#define WRITE_LOCK    2\n\n/* A Btree handle\n**\n** A database connection contains a pointer to an instance of\n** this object for every database file that it has open.  This structure\n** is opaque to the database connection.  The database connection cannot\n** see the internals of this structure and only deals with pointers to\n** this structure.\n**\n** For some database files, the same underlying database cache might be \n** shared between multiple connections.  In that case, each connection\n** has it own instance of this object.  But each instance of this object\n** points to the same BtShared object.  The database cache and the\n** schema associated with the database file are all contained within\n** the BtShared object.\n**\n** All fields in this structure are accessed under sqlite3.mutex.\n** The pBt pointer itself may not be changed while there exists cursors \n** in the referenced BtShared that point back to this Btree since those\n** cursors have to go through this Btree to find their BtShared and\n** they often do so without holding sqlite3.mutex.\n*/\nstruct Btree {\n  sqlite3 *db;       /* The database connection holding this btree */\n  BtShared *pBt;     /* Sharable content of this btree */\n  u8 inTrans;        /* TRANS_NONE, TRANS_READ or TRANS_WRITE */\n  u8 sharable;       /* True if we can share pBt with another db */\n  u8 locked;         /* True if db currently has pBt locked */\n  u8 hasIncrblobCur; /* True if there are one or more Incrblob cursors */\n  int wantToLock;    /* Number of nested calls to sqlite3BtreeEnter() */\n  int nBackup;       /* Number of backup operations reading this btree */\n  u32 iDataVersion;  /* Combines with pBt->pPager->iDataVersion */\n  Btree *pNext;      /* List of other sharable Btrees from the same db */\n  Btree *pPrev;      /* Back pointer of the same list */\n#ifndef SQLITE_OMIT_SHARED_CACHE\n  BtLock lock;       /* Object used to lock page 1 */\n#endif\n};\n\n/*\n** Btree.inTrans may take one of the following values.\n**\n** If the shared-data extension is enabled, there may be multiple users\n** of the Btree structure. At most one of these may open a write transaction,\n** but any number may have active read transactions.\n*/\n#define TRANS_NONE  0\n#define TRANS_READ  1\n#define TRANS_WRITE 2\n\n/*\n** An instance of this object represents a single database file.\n** \n** A single database file can be in use at the same time by two\n** or more database connections.  When two or more connections are\n** sharing the same database file, each connection has it own\n** private Btree object for the file and each of those Btrees points\n** to this one BtShared object.  BtShared.nRef is the number of\n** connections currently sharing this database file.\n**\n** Fields in this structure are accessed under the BtShared.mutex\n** mutex, except for nRef and pNext which are accessed under the\n** global SQLITE_MUTEX_STATIC_MASTER mutex.  The pPager field\n** may not be modified once it is initially set as long as nRef>0.\n** The pSchema field may be set once under BtShared.mutex and\n** thereafter is unchanged as long as nRef>0.\n**\n** isPending:\n**\n**   If a BtShared client fails to obtain a write-lock on a database\n**   table (because there exists one or more read-locks on the table),\n**   the shared-cache enters 'pending-lock' state and isPending is\n**   set to true.\n**\n**   The shared-cache leaves the 'pending lock' state when either of\n**   the following occur:\n**\n**     1) The current writer (BtShared.pWriter) concludes its transaction, OR\n**     2) The number of locks held by other connections drops to zero.\n**\n**   while in the 'pending-lock' state, no connection may start a new\n**   transaction.\n**\n**   This feature is included to help prevent writer-starvation.\n*/\nstruct BtShared {\n  Pager *pPager;        /* The page cache */\n  sqlite3 *db;          /* Database connection currently using this Btree */\n  BtCursor *pCursor;    /* A list of all open cursors */\n  MemPage *pPage1;      /* First page of the database */\n  u8 openFlags;         /* Flags to sqlite3BtreeOpen() */\n#ifndef SQLITE_OMIT_AUTOVACUUM\n  u8 autoVacuum;        /* True if auto-vacuum is enabled */\n  u8 incrVacuum;        /* True if incr-vacuum is enabled */\n  u8 bDoTruncate;       /* True to truncate db on commit */\n#endif\n  u8 inTransaction;     /* Transaction state */\n  u8 max1bytePayload;   /* Maximum first byte of cell for a 1-byte payload */\n#ifdef SQLITE_HAS_CODEC\n  u8 optimalReserve;    /* Desired amount of reserved space per page */\n#endif\n  u16 btsFlags;         /* Boolean parameters.  See BTS_* macros below */\n  u16 maxLocal;         /* Maximum local payload in non-LEAFDATA tables */\n  u16 minLocal;         /* Minimum local payload in non-LEAFDATA tables */\n  u16 maxLeaf;          /* Maximum local payload in a LEAFDATA table */\n  u16 minLeaf;          /* Minimum local payload in a LEAFDATA table */\n  u32 pageSize;         /* Total number of bytes on a page */\n  u32 usableSize;       /* Number of usable bytes on each page */\n  int nTransaction;     /* Number of open transactions (read + write) */\n  u32 nPage;            /* Number of pages in the database */\n  void *pSchema;        /* Pointer to space allocated by sqlite3BtreeSchema() */\n  void (*xFreeSchema)(void*);  /* Destructor for BtShared.pSchema */\n  sqlite3_mutex *mutex; /* Non-recursive mutex required to access this object */\n  Bitvec *pHasContent;  /* Set of pages moved to free-list this transaction */\n#ifndef SQLITE_OMIT_SHARED_CACHE\n  int nRef;             /* Number of references to this structure */\n  BtShared *pNext;      /* Next on a list of sharable BtShared structs */\n  BtLock *pLock;        /* List of locks held on this shared-btree struct */\n  Btree *pWriter;       /* Btree with currently open write transaction */\n#endif\n  u8 *pTmpSpace;        /* Temp space sufficient to hold a single cell */\n};\n\n/*\n** Allowed values for BtShared.btsFlags\n*/\n#define BTS_READ_ONLY        0x0001   /* Underlying file is readonly */\n#define BTS_PAGESIZE_FIXED   0x0002   /* Page size can no longer be changed */\n#define BTS_SECURE_DELETE    0x0004   /* PRAGMA secure_delete is enabled */\n#define BTS_OVERWRITE        0x0008   /* Overwrite deleted content with zeros */\n#define BTS_FAST_SECURE      0x000c   /* Combination of the previous two */\n#define BTS_INITIALLY_EMPTY  0x0010   /* Database was empty at trans start */\n#define BTS_NO_WAL           0x0020   /* Do not open write-ahead-log files */\n#define BTS_EXCLUSIVE        0x0040   /* pWriter has an exclusive lock */\n#define BTS_PENDING          0x0080   /* Waiting for read-locks to clear */\n\n/*\n** An instance of the following structure is used to hold information\n** about a cell.  The parseCellPtr() function fills in this structure\n** based on information extract from the raw disk page.\n*/\nstruct CellInfo {\n  i64 nKey;      /* The key for INTKEY tables, or nPayload otherwise */\n  u8 *pPayload;  /* Pointer to the start of payload */\n  u32 nPayload;  /* Bytes of payload */\n  u16 nLocal;    /* Amount of payload held locally, not on overflow */\n  u16 nSize;     /* Size of the cell content on the main b-tree page */\n};\n\n/*\n** Maximum depth of an SQLite B-Tree structure. Any B-Tree deeper than\n** this will be declared corrupt. This value is calculated based on a\n** maximum database size of 2^31 pages a minimum fanout of 2 for a\n** root-node and 3 for all other internal nodes.\n**\n** If a tree that appears to be taller than this is encountered, it is\n** assumed that the database is corrupt.\n*/\n#define BTCURSOR_MAX_DEPTH 20\n\n/*\n** A cursor is a pointer to a particular entry within a particular\n** b-tree within a database file.\n**\n** The entry is identified by its MemPage and the index in\n** MemPage.aCell[] of the entry.\n**\n** A single database file can be shared by two more database connections,\n** but cursors cannot be shared.  Each cursor is associated with a\n** particular database connection identified BtCursor.pBtree.db.\n**\n** Fields in this structure are accessed under the BtShared.mutex\n** found at self->pBt->mutex. \n**\n** skipNext meaning:\n** The meaning of skipNext depends on the value of eState:\n**\n**   eState            Meaning of skipNext\n**   VALID             skipNext is meaningless and is ignored\n**   INVALID           skipNext is meaningless and is ignored\n**   SKIPNEXT          sqlite3BtreeNext() is a no-op if skipNext>0 and\n**                     sqlite3BtreePrevious() is no-op if skipNext<0.\n**   REQUIRESEEK       restoreCursorPosition() restores the cursor to\n**                     eState=SKIPNEXT if skipNext!=0\n**   FAULT             skipNext holds the cursor fault error code.\n*/\nstruct BtCursor {\n  u8 eState;                /* One of the CURSOR_XXX constants (see below) */\n  u8 curFlags;              /* zero or more BTCF_* flags defined below */\n  u8 curPagerFlags;         /* Flags to send to sqlite3PagerGet() */\n  u8 hints;                 /* As configured by CursorSetHints() */\n  int skipNext;    /* Prev() is noop if negative. Next() is noop if positive.\n                   ** Error code if eState==CURSOR_FAULT */\n  Btree *pBtree;            /* The Btree to which this cursor belongs */\n  Pgno *aOverflow;          /* Cache of overflow page locations */\n  void *pKey;               /* Saved key that was cursor last known position */\n  /* All fields above are zeroed when the cursor is allocated.  See\n  ** sqlite3BtreeCursorZero().  Fields that follow must be manually\n  ** initialized. */\n#define BTCURSOR_FIRST_UNINIT pBt   /* Name of first uninitialized field */\n  BtShared *pBt;            /* The BtShared this cursor points to */\n  BtCursor *pNext;          /* Forms a linked list of all cursors */\n  CellInfo info;            /* A parse of the cell we are pointing at */\n  i64 nKey;                 /* Size of pKey, or last integer key */\n  Pgno pgnoRoot;            /* The root page of this tree */\n  i8 iPage;                 /* Index of current page in apPage */\n  u8 curIntKey;             /* Value of apPage[0]->intKey */\n  u16 ix;                   /* Current index for apPage[iPage] */\n  u16 aiIdx[BTCURSOR_MAX_DEPTH-1];     /* Current index in apPage[i] */\n  struct KeyInfo *pKeyInfo;            /* Arg passed to comparison function */\n  MemPage *pPage;                        /* Current page */\n  MemPage *apPage[BTCURSOR_MAX_DEPTH-1]; /* Stack of parents of current page */\n};\n\n/*\n** Legal values for BtCursor.curFlags\n*/\n#define BTCF_WriteFlag    0x01   /* True if a write cursor */\n#define BTCF_ValidNKey    0x02   /* True if info.nKey is valid */\n#define BTCF_ValidOvfl    0x04   /* True if aOverflow is valid */\n#define BTCF_AtLast       0x08   /* Cursor is pointing ot the last entry */\n#define BTCF_Incrblob     0x10   /* True if an incremental I/O handle */\n#define BTCF_Multiple     0x20   /* Maybe another cursor on the same btree */\n\n/*\n** Potential values for BtCursor.eState.\n**\n** CURSOR_INVALID:\n**   Cursor does not point to a valid entry. This can happen (for example) \n**   because the table is empty or because BtreeCursorFirst() has not been\n**   called.\n**\n** CURSOR_VALID:\n**   Cursor points to a valid entry. getPayload() etc. may be called.\n**\n** CURSOR_SKIPNEXT:\n**   Cursor is valid except that the Cursor.skipNext field is non-zero\n**   indicating that the next sqlite3BtreeNext() or sqlite3BtreePrevious()\n**   operation should be a no-op.\n**\n** CURSOR_REQUIRESEEK:\n**   The table that this cursor was opened on still exists, but has been \n**   modified since the cursor was last used. The cursor position is saved\n**   in variables BtCursor.pKey and BtCursor.nKey. When a cursor is in \n**   this state, restoreCursorPosition() can be called to attempt to\n**   seek the cursor to the saved position.\n**\n** CURSOR_FAULT:\n**   An unrecoverable error (an I/O error or a malloc failure) has occurred\n**   on a different connection that shares the BtShared cache with this\n**   cursor.  The error has left the cache in an inconsistent state.\n**   Do nothing else with this cursor.  Any attempt to use the cursor\n**   should return the error code stored in BtCursor.skipNext\n*/\n#define CURSOR_VALID             0\n#define CURSOR_INVALID           1\n#define CURSOR_SKIPNEXT          2\n#define CURSOR_REQUIRESEEK       3\n#define CURSOR_FAULT             4\n\n/* \n** The database page the PENDING_BYTE occupies. This page is never used.\n*/\n# define PENDING_BYTE_PAGE(pBt) PAGER_MJ_PGNO(pBt)\n\n/*\n** These macros define the location of the pointer-map entry for a \n** database page. The first argument to each is the number of usable\n** bytes on each page of the database (often 1024). The second is the\n** page number to look up in the pointer map.\n**\n** PTRMAP_PAGENO returns the database page number of the pointer-map\n** page that stores the required pointer. PTRMAP_PTROFFSET returns\n** the offset of the requested map entry.\n**\n** If the pgno argument passed to PTRMAP_PAGENO is a pointer-map page,\n** then pgno is returned. So (pgno==PTRMAP_PAGENO(pgsz, pgno)) can be\n** used to test if pgno is a pointer-map page. PTRMAP_ISPAGE implements\n** this test.\n*/\n#define PTRMAP_PAGENO(pBt, pgno) ptrmapPageno(pBt, pgno)\n#define PTRMAP_PTROFFSET(pgptrmap, pgno) (5*(pgno-pgptrmap-1))\n#define PTRMAP_ISPAGE(pBt, pgno) (PTRMAP_PAGENO((pBt),(pgno))==(pgno))\n\n/*\n** The pointer map is a lookup table that identifies the parent page for\n** each child page in the database file.  The parent page is the page that\n** contains a pointer to the child.  Every page in the database contains\n** 0 or 1 parent pages.  (In this context 'database page' refers\n** to any page that is not part of the pointer map itself.)  Each pointer map\n** entry consists of a single byte 'type' and a 4 byte parent page number.\n** The PTRMAP_XXX identifiers below are the valid types.\n**\n** The purpose of the pointer map is to facility moving pages from one\n** position in the file to another as part of autovacuum.  When a page\n** is moved, the pointer in its parent must be updated to point to the\n** new location.  The pointer map is used to locate the parent page quickly.\n**\n** PTRMAP_ROOTPAGE: The database page is a root-page. The page-number is not\n**                  used in this case.\n**\n** PTRMAP_FREEPAGE: The database page is an unused (free) page. The page-number \n**                  is not used in this case.\n**\n** PTRMAP_OVERFLOW1: The database page is the first page in a list of \n**                   overflow pages. The page number identifies the page that\n**                   contains the cell with a pointer to this overflow page.\n**\n** PTRMAP_OVERFLOW2: The database page is the second or later page in a list of\n**                   overflow pages. The page-number identifies the previous\n**                   page in the overflow page list.\n**\n** PTRMAP_BTREE: The database page is a non-root btree page. The page number\n**               identifies the parent page in the btree.\n*/\n#define PTRMAP_ROOTPAGE 1\n#define PTRMAP_FREEPAGE 2\n#define PTRMAP_OVERFLOW1 3\n#define PTRMAP_OVERFLOW2 4\n#define PTRMAP_BTREE 5\n\n/* A bunch of assert() statements to check the transaction state variables\n** of handle p (type Btree*) are internally consistent.\n*/\n#define btreeIntegrity(p) \\\n  assert( p->pBt->inTransaction!=TRANS_NONE || p->pBt->nTransaction==0 ); \\\n  assert( p->pBt->inTransaction>=p->inTrans ); \n\n\n/*\n** The ISAUTOVACUUM macro is used within balance_nonroot() to determine\n** if the database supports auto-vacuum or not. Because it is used\n** within an expression that is an argument to another macro \n** (sqliteMallocRaw), it is not possible to use conditional compilation.\n** So, this macro is defined instead.\n*/\n#ifndef SQLITE_OMIT_AUTOVACUUM\n#define ISAUTOVACUUM (pBt->autoVacuum)\n#else\n#define ISAUTOVACUUM 0\n#endif\n\n\n/*\n** This structure is passed around through all the sanity checking routines\n** in order to keep track of some global state information.\n**\n** The aRef[] array is allocated so that there is 1 bit for each page in\n** the database. As the integrity-check proceeds, for each page used in\n** the database the corresponding bit is set. This allows integrity-check to \n** detect pages that are used twice and orphaned pages (both of which \n** indicate corruption).\n*/\ntypedef struct IntegrityCk IntegrityCk;\nstruct IntegrityCk {\n  BtShared *pBt;    /* The tree being checked out */\n  Pager *pPager;    /* The associated pager.  Also accessible by pBt->pPager */\n  u8 *aPgRef;       /* 1 bit per page in the db (see above) */\n  Pgno nPage;       /* Number of pages in the database */\n  int mxErr;        /* Stop accumulating errors when this reaches zero */\n  int nErr;         /* Number of messages written to zErrMsg so far */\n  int mallocFailed; /* A memory allocation error has occurred */\n  const char *zPfx; /* Error message prefix */\n  int v1, v2;       /* Values for up to two %d fields in zPfx */\n  StrAccum errMsg;  /* Accumulate the error message text here */\n  u32 *heap;        /* Min-heap used for analyzing cell coverage */\n};\n\n/*\n** Routines to read or write a two- and four-byte big-endian integer values.\n*/\n#define get2byte(x)   ((x)[0]<<8 | (x)[1])\n#define put2byte(p,v) ((p)[0] = (u8)((v)>>8), (p)[1] = (u8)(v))\n#define get4byte sqlite3Get4byte\n#define put4byte sqlite3Put4byte\n\n/*\n** get2byteAligned(), unlike get2byte(), requires that its argument point to a\n** two-byte aligned address.  get2bytea() is only used for accessing the\n** cell addresses in a btree header.\n*/\n#if SQLITE_BYTEORDER==4321\n# define get2byteAligned(x)  (*(u16*)(x))\n#elif SQLITE_BYTEORDER==1234 && GCC_VERSION>=4008000\n# define get2byteAligned(x)  __builtin_bswap16(*(u16*)(x))\n#elif SQLITE_BYTEORDER==1234 && MSVC_VERSION>=1300\n# define get2byteAligned(x)  _byteswap_ushort(*(u16*)(x))\n#else\n# define get2byteAligned(x)  ((x)[0]<<8 | (x)[1])\n#endif\n\n/************** End of btreeInt.h ********************************************/\n/************** Continuing where we left off in crypto.h *********************/\n/* #include \"pager.h\" */\n\n/* extensions defined in pager.c */ \nSQLITE_PRIVATE void *sqlite3PagerGetCodec(Pager*);\nSQLITE_PRIVATE void sqlite3PagerSetCodec(Pager*, void *(*)(void*,void*,Pgno,int),  void (*)(void*,int,int),  void (*)(void*), void *);\nSQLITE_API int sqlite3pager_is_mj_pgno(Pager*, Pgno);\nSQLITE_API void sqlite3pager_error(Pager*, int);\nSQLITE_API void sqlite3pager_reset(Pager *pPager);\n\n#if !defined (SQLCIPHER_CRYPTO_CC) \\\n   && !defined (SQLCIPHER_CRYPTO_LIBTOMCRYPT) \\\n   && !defined (SQLCIPHER_CRYPTO_OPENSSL)\n#define SQLCIPHER_CRYPTO_OPENSSL\n#endif\n\n#if defined (SQLCIPHER_PREPROCESSED)\n/* #include \"sqliteInt.h\" */\n#endif /* SQLCIPHER_PREPROCESSED */\n\n#define FILE_HEADER_SZ 16\n\n#define CIPHER_XSTR(s) CIPHER_STR(s)\n#define CIPHER_STR(s) #s\n\n#ifndef CIPHER_VERSION_NUMBER\n#define CIPHER_VERSION_NUMBER 4.1.0\n#endif\n\n#ifndef CIPHER_VERSION_BUILD\n#define CIPHER_VERSION_BUILD community\n#endif\n\n#define CIPHER_DECRYPT 0\n#define CIPHER_ENCRYPT 1\n\n#define CIPHER_READ_CTX 0\n#define CIPHER_WRITE_CTX 1\n#define CIPHER_READWRITE_CTX 2\n\n#ifndef PBKDF2_ITER\n#define PBKDF2_ITER 256000\n#endif\n\n/* possible flags for cipher_ctx->flags */\n#define CIPHER_FLAG_HMAC          0x01\n#define CIPHER_FLAG_LE_PGNO       0x02\n#define CIPHER_FLAG_BE_PGNO       0x04\n\n#ifndef DEFAULT_CIPHER_FLAGS\n#define DEFAULT_CIPHER_FLAGS CIPHER_FLAG_HMAC | CIPHER_FLAG_LE_PGNO\n#endif\n\n\n/* by default, sqlcipher will use a reduced number of iterations to generate\n   the HMAC key / or transform a raw cipher key \n   */\n#ifndef FAST_PBKDF2_ITER\n#define FAST_PBKDF2_ITER 2\n#endif\n\n/* this if a fixed random array that will be xor'd with the database salt to ensure that the\n   salt passed to the HMAC key derivation function is not the same as that used to derive\n   the encryption key. This can be overridden at compile time but it will make the resulting\n   binary incompatible with the default builds when using HMAC. A future version of SQLcipher\n   will likely allow this to be defined at runtime via pragma */ \n#ifndef HMAC_SALT_MASK\n#define HMAC_SALT_MASK 0x3a\n#endif\n\n#ifndef CIPHER_MAX_IV_SZ\n#define CIPHER_MAX_IV_SZ 16\n#endif\n\n#ifndef CIPHER_MAX_KEY_SZ\n#define CIPHER_MAX_KEY_SZ 64\n#endif\n\n#ifdef __ANDROID__\n#include <android/log.h>\n#endif\n\n#ifdef CODEC_DEBUG_MUTEX\n#ifdef __ANDROID__\n#define CODEC_TRACE_MUTEX(...) {__android_log_print(ANDROID_LOG_DEBUG, \"sqlcipher\", __VA_ARGS__);}\n#else\n#define CODEC_TRACE_MUTEX(...)  {fprintf(stderr, __VA_ARGS__);fflush(stderr);}\n#endif\n#else\n#define CODEC_TRACE_MUTEX(...)\n#endif\n\n#ifdef CODEC_DEBUG\n#ifdef __ANDROID__\n#define CODEC_TRACE(...) {__android_log_print(ANDROID_LOG_DEBUG, \"sqlcipher\", __VA_ARGS__);}\n#else\n#define CODEC_TRACE(...)  {fprintf(stderr, __VA_ARGS__);fflush(stderr);}\n#endif\n#else\n#define CODEC_TRACE(...)\n#endif\n\n#ifdef CODEC_DEBUG_PAGEDATA\n#define CODEC_HEXDUMP(DESC,BUFFER,LEN)  \\\n  { \\\n    int __pctr; \\\n    printf(DESC); \\\n    for(__pctr=0; __pctr < LEN; __pctr++) { \\\n      if(__pctr % 16 == 0) printf(\"\\n%05x: \",__pctr); \\\n      printf(\"%02x \",((unsigned char*) BUFFER)[__pctr]); \\\n    } \\\n    printf(\"\\n\"); \\\n    fflush(stdout); \\\n  }\n#else\n#define CODEC_HEXDUMP(DESC,BUFFER,LEN)\n#endif\n\n/* utility functions */\nvoid sqlcipher_free(void *, int);\nvoid* sqlcipher_malloc(int);\nvoid sqlcipher_mlock(void *, int);\nvoid sqlcipher_munlock(void *, int);\nvoid* sqlcipher_memset(void *, unsigned char, int);\nint sqlcipher_ismemset(const void *, unsigned char, int);\nint sqlcipher_memcmp(const void *, const void *, int);\n \n/*\n**  Simple shared routines for converting hex char strings to binary data\n */\nstatic int cipher_hex2int(char c) {\n  return (c>='0' && c<='9') ? (c)-'0' :\n         (c>='A' && c<='F') ? (c)-'A'+10 :\n         (c>='a' && c<='f') ? (c)-'a'+10 : 0;\n}\n\n#if defined (SQLCIPHER_PREPROCESSED)\nvoid cipher_hex2bin(const unsigned char *hex, int sz, unsigned char *out);\n#else /* SQLCIPHER_PREPROCESSED */\nstatic void cipher_hex2bin(const unsigned char *hex, int sz, unsigned char *out){\n  int i;\n  for(i = 0; i < sz; i += 2){\n    out[i/2] = (cipher_hex2int(hex[i])<<4) | cipher_hex2int(hex[i+1]);\n  }\n}\n#endif /* SQLCIPHER_PREPROCESSED */\n\n#if defined (SQLCIPHER_PREPROCESSED)\nvoid cipher_bin2hex(const unsigned char* in, int sz, char *out);\n#else /* SQLCIPHER_PREPROCESSED */\nstatic void cipher_bin2hex(const unsigned char* in, int sz, char *out) {\n    int i;\n    for(i=0; i < sz; i++) {\n      sqlite3_snprintf(3, out + (i*2), \"%02x \", in[i]);\n    } \n}\n#endif /* SQLCIPHER_PREPROCESSED */\n\n#if defined (SQLCIPHER_PREPROCESSED)\nint cipher_isHex(const unsigned char *hex, int sz);\n#else /* SQLCIPHER_PREPROCESSED */\nstatic int cipher_isHex(const unsigned char *hex, int sz){\n  int i;\n  for(i = 0; i < sz; i++) {\n    unsigned char c = hex[i];\n    if ((c < '0' || c > '9') &&\n        (c < 'A' || c > 'F') &&\n        (c < 'a' || c > 'f')) {\n      return 0;\n    }\n  }\n  return 1;\n}\n#endif /* SQLCIPHER_PREPROCESSED */\n\n/* extensions defined in crypto_impl.c */\ntypedef struct codec_ctx codec_ctx;\n\n/* crypto.c functions */\nint sqlcipher_codec_pragma(sqlite3*, int, Parse*, const char *, const char*);\nSQLITE_PRIVATE int sqlite3CodecAttach(sqlite3*, int, const void *, int);\nSQLITE_PRIVATE void sqlite3CodecGetKey(sqlite3*, int, void**, int*);\nvoid sqlcipher_exportFunc(sqlite3_context *, int, sqlite3_value **);\n\n/* crypto_impl.c functions */\n\nvoid sqlcipher_init_memmethods(void);\n\n/* activation and initialization */\nvoid sqlcipher_activate(void);\nvoid sqlcipher_deactivate(void);\n\nint sqlcipher_codec_ctx_init(codec_ctx **, Db *, Pager *, const void *, int);\nvoid sqlcipher_codec_ctx_free(codec_ctx **);\nint sqlcipher_codec_key_derive(codec_ctx *);\nint sqlcipher_codec_key_copy(codec_ctx *, int);\n\n/* page cipher implementation */\nint sqlcipher_page_cipher(codec_ctx *, int, Pgno, int, int, unsigned char *, unsigned char *);\n\n/* context setters & getters */\nvoid sqlcipher_codec_ctx_set_error(codec_ctx *, int);\n\nvoid sqlcipher_codec_get_pass(codec_ctx *, void **, int *);\nint sqlcipher_codec_ctx_set_pass(codec_ctx *, const void *, int, int);\nvoid sqlcipher_codec_get_keyspec(codec_ctx *, void **zKey, int *nKey);\n\nint sqlcipher_codec_ctx_set_pagesize(codec_ctx *, int);\nint sqlcipher_codec_ctx_get_pagesize(codec_ctx *);\nint sqlcipher_codec_ctx_get_reservesize(codec_ctx *);\n\nvoid sqlcipher_set_default_pagesize(int page_size);\nint sqlcipher_get_default_pagesize(void);\n\nvoid sqlcipher_set_default_kdf_iter(int iter);\nint sqlcipher_get_default_kdf_iter(void);\nint sqlcipher_codec_ctx_set_kdf_iter(codec_ctx *, int);\nint sqlcipher_codec_ctx_get_kdf_iter(codec_ctx *ctx);\n\nint sqlcipher_codec_ctx_set_kdf_salt(codec_ctx *ctx, unsigned char *salt, int sz);\nint sqlcipher_codec_ctx_get_kdf_salt(codec_ctx *ctx, void **salt);\n\nint sqlcipher_codec_ctx_set_fast_kdf_iter(codec_ctx *, int);\nint sqlcipher_codec_ctx_get_fast_kdf_iter(codec_ctx *);\n\nconst char* sqlcipher_codec_ctx_get_cipher(codec_ctx *ctx);\n\nvoid* sqlcipher_codec_ctx_get_data(codec_ctx *);\n\nvoid sqlcipher_set_default_use_hmac(int use);\nint sqlcipher_get_default_use_hmac(void);\n\nvoid sqlcipher_set_hmac_salt_mask(unsigned char mask);\nunsigned char sqlcipher_get_hmac_salt_mask(void);\n\nint sqlcipher_codec_ctx_set_use_hmac(codec_ctx *ctx, int use);\nint sqlcipher_codec_ctx_get_use_hmac(codec_ctx *ctx);\n\nint sqlcipher_codec_ctx_set_flag(codec_ctx *ctx, unsigned int flag);\nint sqlcipher_codec_ctx_unset_flag(codec_ctx *ctx, unsigned int flag);\nint sqlcipher_codec_ctx_get_flag(codec_ctx *ctx, unsigned int flag);\n\nconst char* sqlcipher_codec_get_cipher_provider(codec_ctx *ctx);\nint sqlcipher_codec_ctx_migrate(codec_ctx *ctx);\nint sqlcipher_codec_add_random(codec_ctx *ctx, const char *data, int random_sz);\nint sqlcipher_codec_get_store_pass(codec_ctx *ctx);\nvoid sqlcipher_codec_get_pass(codec_ctx *ctx, void **zKey, int *nKey);\nvoid sqlcipher_codec_set_store_pass(codec_ctx *ctx, int value);\nint sqlcipher_codec_fips_status(codec_ctx *ctx);\nconst char* sqlcipher_codec_get_provider_version(codec_ctx *ctx);\n\nint sqlcipher_codec_hmac_sha1(const codec_ctx *ctx, const unsigned char *hmac_key, int key_sz,\n                         unsigned char* in, int in_sz, unsigned char *in2, int in2_sz,\n                         unsigned char *out);\n\nint sqlcipher_set_default_plaintext_header_size(int size);\nint sqlcipher_get_default_plaintext_header_size(void);\nint sqlcipher_codec_ctx_set_plaintext_header_size(codec_ctx *ctx, int size);\nint sqlcipher_codec_ctx_get_plaintext_header_size(codec_ctx *ctx);\n\nint sqlcipher_set_default_hmac_algorithm(int algorithm);\nint sqlcipher_get_default_hmac_algorithm(void);\nint sqlcipher_codec_ctx_set_hmac_algorithm(codec_ctx *ctx, int algorithm);\nint sqlcipher_codec_ctx_get_hmac_algorithm(codec_ctx *ctx);\n\nint sqlcipher_set_default_kdf_algorithm(int algorithm);\nint sqlcipher_get_default_kdf_algorithm(void);\nint sqlcipher_codec_ctx_set_kdf_algorithm(codec_ctx *ctx, int algorithm);\nint sqlcipher_codec_ctx_get_kdf_algorithm(codec_ctx *ctx);\n\nvoid sqlcipher_set_mem_security(int);\nint sqlcipher_get_mem_security(void);\n\nint sqlcipher_find_db_index(sqlite3 *db, const char *zDb);\n\n#endif\n#endif\n/* END SQLCIPHER */\n\n/************** End of crypto.h **********************************************/\n/************** Continuing where we left off in crypto.c *********************/\n\n#ifdef SQLCIPHER_LICENSE\n#include \"sqlcipher-license.h\"\n#endif\n\n/* Generate code to return a string value */\nstatic void codec_vdbe_return_string(Parse *pParse, const char *zLabel, const char *value, int value_type){\n  Vdbe *v = sqlite3GetVdbe(pParse);\n  sqlite3VdbeSetNumCols(v, 1);\n  sqlite3VdbeSetColName(v, 0, COLNAME_NAME, zLabel, SQLITE_STATIC);\n  sqlite3VdbeAddOp4(v, OP_String8, 0, 1, 0, value, value_type);\n  sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 1);\n}\n\nstatic int codec_set_btree_to_codec_pagesize(sqlite3 *db, Db *pDb, codec_ctx *ctx) {\n  int rc, page_sz, reserve_sz; \n\n  page_sz = sqlcipher_codec_ctx_get_pagesize(ctx);\n  reserve_sz = sqlcipher_codec_ctx_get_reservesize(ctx);\n\n  CODEC_TRACE(\"codec_set_btree_to_codec_pagesize: sqlite3BtreeSetPageSize() size=%d reserve=%d\\n\", page_sz, reserve_sz);\n\n  CODEC_TRACE_MUTEX(\"codec_set_btree_to_codec_pagesize: entering database mutex %p\\n\", db->mutex);\n  sqlite3_mutex_enter(db->mutex);\n  CODEC_TRACE_MUTEX(\"codec_set_btree_to_codec_pagesize: entered database mutex %p\\n\", db->mutex);\n  db->nextPagesize = page_sz; \n\n  /* before forcing the page size we need to unset the BTS_PAGESIZE_FIXED flag, else  \n     sqliteBtreeSetPageSize will block the change  */\n  pDb->pBt->pBt->btsFlags &= ~BTS_PAGESIZE_FIXED;\n  rc = sqlite3BtreeSetPageSize(pDb->pBt, page_sz, reserve_sz, 0);\n\n  CODEC_TRACE(\"codec_set_btree_to_codec_pagesize: sqlite3BtreeSetPageSize returned %d\\n\", rc);\n\n  CODEC_TRACE_MUTEX(\"codec_set_btree_to_codec_pagesize: leaving database mutex %p\\n\", db->mutex);\n  sqlite3_mutex_leave(db->mutex);\n  CODEC_TRACE_MUTEX(\"codec_set_btree_to_codec_pagesize: left database mutex %p\\n\", db->mutex);\n\n  return rc;\n}\n\nstatic int codec_set_pass_key(sqlite3* db, int nDb, const void *zKey, int nKey, int for_ctx) {\n  struct Db *pDb = &db->aDb[nDb];\n  CODEC_TRACE(\"codec_set_pass_key: entered db=%p nDb=%d zKey=%s nKey=%d for_ctx=%d\\n\", db, nDb, (char *)zKey, nKey, for_ctx);\n  if(pDb->pBt) {\n    codec_ctx *ctx = (codec_ctx*) sqlite3PagerGetCodec(pDb->pBt->pBt->pPager);\n\n    if(ctx) return sqlcipher_codec_ctx_set_pass(ctx, zKey, nKey, for_ctx);\n  }\n  return SQLITE_ERROR;\n} \n\nint sqlcipher_codec_pragma(sqlite3* db, int iDb, Parse *pParse, const char *zLeft, const char *zRight) {\n  struct Db *pDb = &db->aDb[iDb];\n  codec_ctx *ctx = NULL;\n  int rc;\n\n  if(pDb->pBt) {\n    ctx = (codec_ctx*) sqlite3PagerGetCodec(pDb->pBt->pBt->pPager);\n  }\n\n  CODEC_TRACE(\"sqlcipher_codec_pragma: entered db=%p iDb=%d pParse=%p zLeft=%s zRight=%s ctx=%p\\n\", db, iDb, pParse, zLeft, zRight, ctx);\n  \n#ifdef SQLCIPHER_LICENSE\n  if( sqlite3StrICmp(zLeft, \"cipher_license\")==0 && zRight ){\n    char *license_result = sqlite3_mprintf(\"%d\", sqlcipher_license_key(zRight));\n    codec_vdbe_return_string(pParse, \"cipher_license\", license_result, P4_DYNAMIC);\n  } else\n    if( sqlite3StrICmp(zLeft, \"cipher_license\")==0 && !zRight ){\n      if(ctx) {\n        char *license_result = sqlite3_mprintf(\"%d\", ctx\n                                               ? sqlcipher_license_key_status(ctx)\n                                               : SQLITE_ERROR);\n        codec_vdbe_return_string(pParse, \"cipher_license\", license_result, P4_DYNAMIC);\n      }\n  } else\n#endif\n  if( sqlite3StrICmp(zLeft, \"cipher_fips_status\")== 0 && !zRight ){\n    if(ctx) {\n      char *fips_mode_status = sqlite3_mprintf(\"%d\", sqlcipher_codec_fips_status(ctx));\n      codec_vdbe_return_string(pParse, \"cipher_fips_status\", fips_mode_status, P4_DYNAMIC);\n    }\n  } else\n  if( sqlite3StrICmp(zLeft, \"cipher_store_pass\")==0 && zRight ) {\n    if(ctx) {\n      sqlcipher_codec_set_store_pass(ctx, sqlite3GetBoolean(zRight, 1));\n    }\n  } else\n  if( sqlite3StrICmp(zLeft, \"cipher_store_pass\")==0 && !zRight ) {\n    if(ctx){\n      char *store_pass_value = sqlite3_mprintf(\"%d\", sqlcipher_codec_get_store_pass(ctx));\n      codec_vdbe_return_string(pParse, \"cipher_store_pass\", store_pass_value, P4_DYNAMIC);\n    }\n  } else\n  if( sqlite3StrICmp(zLeft, \"cipher_add_random\")==0 && zRight ){\n    if(ctx) {\n      char *add_random_status = sqlite3_mprintf(\"%d\", sqlcipher_codec_add_random(ctx, zRight, sqlite3Strlen30(zRight)));\n      codec_vdbe_return_string(pParse, \"cipher_add_random\", add_random_status, P4_DYNAMIC);\n    }\n  } else\n  if( sqlite3StrICmp(zLeft, \"cipher_migrate\")==0 && !zRight ){\n    if(ctx){\n      char *migrate_status = sqlite3_mprintf(\"%d\", sqlcipher_codec_ctx_migrate(ctx));\n      codec_vdbe_return_string(pParse, \"cipher_migrate\", migrate_status, P4_DYNAMIC);\n    }\n  } else\n  if( sqlite3StrICmp(zLeft, \"cipher_provider\")==0 && !zRight ){\n    if(ctx) { codec_vdbe_return_string(pParse, \"cipher_provider\",\n                                              sqlcipher_codec_get_cipher_provider(ctx), P4_TRANSIENT);\n    }\n  } else\n  if( sqlite3StrICmp(zLeft, \"cipher_provider_version\")==0 && !zRight){\n    if(ctx) { codec_vdbe_return_string(pParse, \"cipher_provider_version\",\n                                              sqlcipher_codec_get_provider_version(ctx), P4_TRANSIENT);\n    }\n  } else\n  if( sqlite3StrICmp(zLeft, \"cipher_version\")==0 && !zRight ){\n#ifdef CIPHER_VERSION_QUALIFIER\n    char *version = sqlite3_mprintf(\"%s %s %s\", CIPHER_XSTR(CIPHER_VERSION_NUMBER), CIPHER_XSTR(CIPHER_VERSION_QUALIFIER), CIPHER_XSTR(CIPHER_VERSION_BUILD));\n#else\n    char *version = sqlite3_mprintf(\"%s %s\", CIPHER_XSTR(CIPHER_VERSION_NUMBER), CIPHER_XSTR(CIPHER_VERSION_BUILD));\n#endif\n    codec_vdbe_return_string(pParse, \"cipher_version\", version, P4_DYNAMIC);\n  } else\n  if( sqlite3StrICmp(zLeft, \"cipher\")==0 ){\n    if(ctx) {\n      if( zRight ) {\n        const char* message = \"PRAGMA cipher is no longer supported.\";\n        codec_vdbe_return_string(pParse, \"cipher\", message, P4_TRANSIENT);\n        sqlite3_log(SQLITE_WARNING, message);\n      }else {\n        codec_vdbe_return_string(pParse, \"cipher\", sqlcipher_codec_ctx_get_cipher(ctx), P4_TRANSIENT); \n      }\n    }\n  } else\n  if( sqlite3StrICmp(zLeft, \"rekey_cipher\")==0 && zRight ){\n    const char* message = \"PRAGMA rekey_cipher is no longer supported.\";\n    codec_vdbe_return_string(pParse, \"rekey_cipher\", message, P4_TRANSIENT);\n    sqlite3_log(SQLITE_WARNING, message);\n  } else\n  if( sqlite3StrICmp(zLeft,\"cipher_default_kdf_iter\")==0 ){\n    if( zRight ) {\n      sqlcipher_set_default_kdf_iter(atoi(zRight)); /* change default KDF iterations */\n    } else {\n      char *kdf_iter = sqlite3_mprintf(\"%d\", sqlcipher_get_default_kdf_iter());\n      codec_vdbe_return_string(pParse, \"cipher_default_kdf_iter\", kdf_iter, P4_DYNAMIC);\n    }\n  }else\n  if( sqlite3StrICmp(zLeft, \"kdf_iter\")==0 ){\n    if(ctx) {\n      if( zRight ) {\n        sqlcipher_codec_ctx_set_kdf_iter(ctx, atoi(zRight)); /* change of RW PBKDF2 iteration */\n      } else {\n        char *kdf_iter = sqlite3_mprintf(\"%d\", sqlcipher_codec_ctx_get_kdf_iter(ctx));\n        codec_vdbe_return_string(pParse, \"kdf_iter\", kdf_iter, P4_DYNAMIC);\n      }\n    }\n  }else\n  if( sqlite3StrICmp(zLeft, \"fast_kdf_iter\")==0){\n    if(ctx) {\n      if( zRight ) {\n        char *deprecation = \"PRAGMA fast_kdf_iter is deprecated, please remove from use\";\n        sqlcipher_codec_ctx_set_fast_kdf_iter(ctx, atoi(zRight)); /* change of RW PBKDF2 iteration */\n        codec_vdbe_return_string(pParse, \"fast_kdf_iter\", deprecation, P4_TRANSIENT);\n        sqlite3_log(SQLITE_WARNING, deprecation);\n      } else {\n        char *fast_kdf_iter = sqlite3_mprintf(\"%d\", sqlcipher_codec_ctx_get_fast_kdf_iter(ctx));\n        codec_vdbe_return_string(pParse, \"fast_kdf_iter\", fast_kdf_iter, P4_DYNAMIC);\n      }\n    }\n  }else\n  if( sqlite3StrICmp(zLeft, \"rekey_kdf_iter\")==0 && zRight ){\n    const char* message = \"PRAGMA rekey_kdf_iter is no longer supported.\";\n    codec_vdbe_return_string(pParse, \"rekey_kdf_iter\", message, P4_TRANSIENT);\n    sqlite3_log(SQLITE_WARNING, message);\n  }else\n  if( sqlite3StrICmp(zLeft,\"cipher_page_size\")==0 ){\n    if(ctx) {\n      if( zRight ) {\n        int size = atoi(zRight);\n        rc = sqlcipher_codec_ctx_set_pagesize(ctx, size);\n        if(rc != SQLITE_OK) sqlcipher_codec_ctx_set_error(ctx, rc);\n        rc = codec_set_btree_to_codec_pagesize(db, pDb, ctx);\n        if(rc != SQLITE_OK) sqlcipher_codec_ctx_set_error(ctx, rc);\n      } else {\n        char * page_size = sqlite3_mprintf(\"%d\", sqlcipher_codec_ctx_get_pagesize(ctx));\n        codec_vdbe_return_string(pParse, \"cipher_page_size\", page_size, P4_DYNAMIC);\n      }\n    }\n  }else\n  if( sqlite3StrICmp(zLeft,\"cipher_default_page_size\")==0 ){\n    if( zRight ) {\n      sqlcipher_set_default_pagesize(atoi(zRight));\n    } else {\n      char *default_page_size = sqlite3_mprintf(\"%d\", sqlcipher_get_default_pagesize());\n      codec_vdbe_return_string(pParse, \"cipher_default_page_size\", default_page_size, P4_DYNAMIC);\n    }\n  }else\n  if( sqlite3StrICmp(zLeft,\"cipher_default_use_hmac\")==0 ){\n    if( zRight ) {\n      sqlcipher_set_default_use_hmac(sqlite3GetBoolean(zRight,1));\n    } else {\n      char *default_use_hmac = sqlite3_mprintf(\"%d\", sqlcipher_get_default_use_hmac());\n      codec_vdbe_return_string(pParse, \"cipher_default_use_hmac\", default_use_hmac, P4_DYNAMIC);\n    }\n  }else\n  if( sqlite3StrICmp(zLeft,\"cipher_use_hmac\")==0 ){\n    if(ctx) {\n      if( zRight ) {\n        rc = sqlcipher_codec_ctx_set_use_hmac(ctx, sqlite3GetBoolean(zRight,1));\n        if(rc != SQLITE_OK) sqlcipher_codec_ctx_set_error(ctx, rc);\n        /* since the use of hmac has changed, the page size may also change */\n        rc = codec_set_btree_to_codec_pagesize(db, pDb, ctx);\n        if(rc != SQLITE_OK) sqlcipher_codec_ctx_set_error(ctx, rc);\n      } else {\n        char *hmac_flag = sqlite3_mprintf(\"%d\", sqlcipher_codec_ctx_get_use_hmac(ctx));\n        codec_vdbe_return_string(pParse, \"cipher_use_hmac\", hmac_flag, P4_DYNAMIC);\n      }\n    }\n  }else\n  if( sqlite3StrICmp(zLeft,\"cipher_hmac_pgno\")==0 ){\n    if(ctx) {\n      if(zRight) {\n        char *deprecation = \"PRAGMA cipher_hmac_pgno is deprecated, please remove from use\";\n        /* clear both pgno endian flags */\n        if(sqlite3StrICmp(zRight, \"le\") == 0) {\n          sqlcipher_codec_ctx_unset_flag(ctx, CIPHER_FLAG_BE_PGNO);\n          sqlcipher_codec_ctx_set_flag(ctx, CIPHER_FLAG_LE_PGNO);\n        } else if(sqlite3StrICmp(zRight, \"be\") == 0) {\n          sqlcipher_codec_ctx_unset_flag(ctx, CIPHER_FLAG_LE_PGNO);\n          sqlcipher_codec_ctx_set_flag(ctx, CIPHER_FLAG_BE_PGNO);\n        } else if(sqlite3StrICmp(zRight, \"native\") == 0) {\n          sqlcipher_codec_ctx_unset_flag(ctx, CIPHER_FLAG_LE_PGNO);\n          sqlcipher_codec_ctx_unset_flag(ctx, CIPHER_FLAG_BE_PGNO);\n        }\n        codec_vdbe_return_string(pParse, \"cipher_hmac_pgno\", deprecation, P4_TRANSIENT);\n        sqlite3_log(SQLITE_WARNING, deprecation);\n \n      } else {\n        if(sqlcipher_codec_ctx_get_flag(ctx, CIPHER_FLAG_LE_PGNO)) {\n          codec_vdbe_return_string(pParse, \"cipher_hmac_pgno\", \"le\", P4_TRANSIENT);\n        } else if(sqlcipher_codec_ctx_get_flag(ctx, CIPHER_FLAG_BE_PGNO)) {\n          codec_vdbe_return_string(pParse, \"cipher_hmac_pgno\", \"be\", P4_TRANSIENT);\n        } else {\n          codec_vdbe_return_string(pParse, \"cipher_hmac_pgno\", \"native\", P4_TRANSIENT);\n        }\n      }\n    }\n  }else\n  if( sqlite3StrICmp(zLeft,\"cipher_hmac_salt_mask\")==0 ){\n    if(ctx) {\n      if(zRight) {\n        char *deprecation = \"PRAGMA cipher_hmac_salt_mask is deprecated, please remove from use\";\n        if (sqlite3StrNICmp(zRight ,\"x'\", 2) == 0 && sqlite3Strlen30(zRight) == 5) {\n          unsigned char mask = 0;\n          const unsigned char *hex = (const unsigned char *)zRight+2;\n          cipher_hex2bin(hex,2,&mask);\n          sqlcipher_set_hmac_salt_mask(mask);\n        }\n        codec_vdbe_return_string(pParse, \"cipher_hmac_salt_mask\", deprecation, P4_TRANSIENT);\n        sqlite3_log(SQLITE_WARNING, deprecation);\n      } else {\n        char *hmac_salt_mask = sqlite3_mprintf(\"%02x\", sqlcipher_get_hmac_salt_mask());\n        codec_vdbe_return_string(pParse, \"cipher_hmac_salt_mask\", hmac_salt_mask, P4_DYNAMIC);\n      }\n    }\n  }else \n  if( sqlite3StrICmp(zLeft,\"cipher_plaintext_header_size\")==0 ){\n    if(ctx) {\n      if( zRight ) {\n        int size = atoi(zRight);\n        if((rc = sqlcipher_codec_ctx_set_plaintext_header_size(ctx, size)) != SQLITE_OK)\n          sqlcipher_codec_ctx_set_error(ctx, SQLITE_ERROR); \n      } else {\n        char *size = sqlite3_mprintf(\"%d\", sqlcipher_codec_ctx_get_plaintext_header_size(ctx));\n        codec_vdbe_return_string(pParse, \"cipher_plaintext_header_size\", size, P4_DYNAMIC);\n      }\n    }\n  }else \n  if( sqlite3StrICmp(zLeft,\"cipher_default_plaintext_header_size\")==0 ){\n    if( zRight ) {\n      sqlcipher_set_default_plaintext_header_size(atoi(zRight));\n    } else {\n      char *size = sqlite3_mprintf(\"%d\", sqlcipher_get_default_plaintext_header_size());\n      codec_vdbe_return_string(pParse, \"cipher_default_plaintext_header_size\", size, P4_DYNAMIC);\n      sqlite3_free(size);\n    }\n  }else\n  if( sqlite3StrICmp(zLeft,\"cipher_salt\")==0 ){\n    if(ctx) {\n      if(zRight) {\n        if (sqlite3StrNICmp(zRight ,\"x'\", 2) == 0 && sqlite3Strlen30(zRight) == (FILE_HEADER_SZ*2)+3) {\n          unsigned char *salt = (unsigned char*) sqlite3_malloc(FILE_HEADER_SZ);\n          const unsigned char *hex = (const unsigned char *)zRight+2;\n          cipher_hex2bin(hex,FILE_HEADER_SZ*2,salt);\n          sqlcipher_codec_ctx_set_kdf_salt(ctx, salt, FILE_HEADER_SZ);\n          sqlite3_free(salt);\n        }\n      } else {\n        void *salt;\n        char *hexsalt = (char*) sqlite3_malloc((FILE_HEADER_SZ*2)+1);\n        if((rc = sqlcipher_codec_ctx_get_kdf_salt(ctx, &salt)) == SQLITE_OK) {\n          cipher_bin2hex(salt, FILE_HEADER_SZ, hexsalt);\n          codec_vdbe_return_string(pParse, \"cipher_salt\", hexsalt, P4_DYNAMIC);\n        } else {\n          sqlite3_free(hexsalt);\n          sqlcipher_codec_ctx_set_error(ctx, rc);\n        }\n      }\n    }\n  }else\n  if( sqlite3StrICmp(zLeft,\"cipher_hmac_algorithm\")==0 ){\n    if(ctx) {\n      if(zRight) {\n        rc = SQLITE_ERROR;\n        if(sqlite3StrICmp(zRight, SQLCIPHER_HMAC_SHA1_LABEL) == 0) {\n          rc = sqlcipher_codec_ctx_set_hmac_algorithm(ctx, SQLCIPHER_HMAC_SHA1);\n        } else if(sqlite3StrICmp(zRight, SQLCIPHER_HMAC_SHA256_LABEL) == 0) {\n          rc = sqlcipher_codec_ctx_set_hmac_algorithm(ctx, SQLCIPHER_HMAC_SHA256);\n        } else if(sqlite3StrICmp(zRight, SQLCIPHER_HMAC_SHA512_LABEL) == 0) {\n          rc = sqlcipher_codec_ctx_set_hmac_algorithm(ctx, SQLCIPHER_HMAC_SHA512);\n        }\n        if (rc != SQLITE_OK) sqlcipher_codec_ctx_set_error(ctx, SQLITE_ERROR);\n        rc = codec_set_btree_to_codec_pagesize(db, pDb, ctx);\n        if (rc != SQLITE_OK) sqlcipher_codec_ctx_set_error(ctx, SQLITE_ERROR);\n      } else {\n        int algorithm = sqlcipher_codec_ctx_get_hmac_algorithm(ctx);\n        if(algorithm == SQLCIPHER_HMAC_SHA1) {\n          codec_vdbe_return_string(pParse, \"cipher_hmac_algorithm\", SQLCIPHER_HMAC_SHA1_LABEL, P4_TRANSIENT);\n        } else if(algorithm == SQLCIPHER_HMAC_SHA256) {\n          codec_vdbe_return_string(pParse, \"cipher_hmac_algorithm\", SQLCIPHER_HMAC_SHA256_LABEL, P4_TRANSIENT);\n        } else if(algorithm == SQLCIPHER_HMAC_SHA512) {\n          codec_vdbe_return_string(pParse, \"cipher_hmac_algorithm\", SQLCIPHER_HMAC_SHA512_LABEL, P4_TRANSIENT);\n        }\n      }\n    }\n  }else \n  if( sqlite3StrICmp(zLeft,\"cipher_default_hmac_algorithm\")==0 ){\n    if(zRight) {\n      rc = SQLITE_ERROR;\n      if(sqlite3StrICmp(zRight, SQLCIPHER_HMAC_SHA1_LABEL) == 0) {\n        rc = sqlcipher_set_default_hmac_algorithm(SQLCIPHER_HMAC_SHA1);\n      } else if(sqlite3StrICmp(zRight, SQLCIPHER_HMAC_SHA256_LABEL) == 0) {\n        rc = sqlcipher_set_default_hmac_algorithm(SQLCIPHER_HMAC_SHA256);\n      } else if(sqlite3StrICmp(zRight, SQLCIPHER_HMAC_SHA512_LABEL) == 0) {\n        rc = sqlcipher_set_default_hmac_algorithm(SQLCIPHER_HMAC_SHA512);\n      }\n    } else {\n      int algorithm = sqlcipher_get_default_hmac_algorithm();\n      if(algorithm == SQLCIPHER_HMAC_SHA1) {\n        codec_vdbe_return_string(pParse, \"cipher_default_hmac_algorithm\", SQLCIPHER_HMAC_SHA1_LABEL, P4_TRANSIENT);\n      } else if(algorithm == SQLCIPHER_HMAC_SHA256) {\n        codec_vdbe_return_string(pParse, \"cipher_default_hmac_algorithm\", SQLCIPHER_HMAC_SHA256_LABEL, P4_TRANSIENT);\n      } else if(algorithm == SQLCIPHER_HMAC_SHA512) {\n        codec_vdbe_return_string(pParse, \"cipher_default_hmac_algorithm\", SQLCIPHER_HMAC_SHA512_LABEL, P4_TRANSIENT);\n      }\n    }\n  }else \n  if( sqlite3StrICmp(zLeft,\"cipher_kdf_algorithm\")==0 ){\n    if(ctx) {\n      if(zRight) {\n        rc = SQLITE_ERROR;\n        if(sqlite3StrICmp(zRight, SQLCIPHER_PBKDF2_HMAC_SHA1_LABEL) == 0) {\n          rc = sqlcipher_codec_ctx_set_kdf_algorithm(ctx, SQLCIPHER_PBKDF2_HMAC_SHA1);\n        } else if(sqlite3StrICmp(zRight, SQLCIPHER_PBKDF2_HMAC_SHA256_LABEL) == 0) {\n          rc = sqlcipher_codec_ctx_set_kdf_algorithm(ctx, SQLCIPHER_PBKDF2_HMAC_SHA256);\n        } else if(sqlite3StrICmp(zRight, SQLCIPHER_PBKDF2_HMAC_SHA512_LABEL) == 0) {\n          rc = sqlcipher_codec_ctx_set_kdf_algorithm(ctx, SQLCIPHER_PBKDF2_HMAC_SHA512);\n        }\n        if (rc != SQLITE_OK) sqlcipher_codec_ctx_set_error(ctx, SQLITE_ERROR);\n      } else {\n        int algorithm = sqlcipher_codec_ctx_get_kdf_algorithm(ctx);\n        if(algorithm == SQLCIPHER_PBKDF2_HMAC_SHA1) {\n          codec_vdbe_return_string(pParse, \"cipher_kdf_algorithm\", SQLCIPHER_PBKDF2_HMAC_SHA1_LABEL, P4_TRANSIENT);\n        } else if(algorithm == SQLCIPHER_PBKDF2_HMAC_SHA256) {\n          codec_vdbe_return_string(pParse, \"cipher_kdf_algorithm\", SQLCIPHER_PBKDF2_HMAC_SHA256_LABEL, P4_TRANSIENT);\n        } else if(algorithm == SQLCIPHER_PBKDF2_HMAC_SHA512) {\n          codec_vdbe_return_string(pParse, \"cipher_kdf_algorithm\", SQLCIPHER_PBKDF2_HMAC_SHA512_LABEL, P4_TRANSIENT);\n        }\n      }\n    }\n  }else \n  if( sqlite3StrICmp(zLeft,\"cipher_default_kdf_algorithm\")==0 ){\n    if(zRight) {\n      rc = SQLITE_ERROR;\n      if(sqlite3StrICmp(zRight, SQLCIPHER_PBKDF2_HMAC_SHA1_LABEL) == 0) {\n        rc = sqlcipher_set_default_kdf_algorithm(SQLCIPHER_PBKDF2_HMAC_SHA1);\n      } else if(sqlite3StrICmp(zRight, SQLCIPHER_PBKDF2_HMAC_SHA256_LABEL) == 0) {\n        rc = sqlcipher_set_default_kdf_algorithm(SQLCIPHER_PBKDF2_HMAC_SHA256);\n      } else if(sqlite3StrICmp(zRight, SQLCIPHER_PBKDF2_HMAC_SHA512_LABEL) == 0) {\n        rc = sqlcipher_set_default_kdf_algorithm(SQLCIPHER_PBKDF2_HMAC_SHA512);\n      }\n    } else {\n      int algorithm = sqlcipher_get_default_kdf_algorithm();\n      if(algorithm == SQLCIPHER_PBKDF2_HMAC_SHA1) {\n        codec_vdbe_return_string(pParse, \"cipher_default_kdf_algorithm\", SQLCIPHER_PBKDF2_HMAC_SHA1_LABEL, P4_TRANSIENT);\n      } else if(algorithm == SQLCIPHER_PBKDF2_HMAC_SHA256) {\n        codec_vdbe_return_string(pParse, \"cipher_default_kdf_algorithm\", SQLCIPHER_PBKDF2_HMAC_SHA256_LABEL, P4_TRANSIENT);\n      } else if(algorithm == SQLCIPHER_PBKDF2_HMAC_SHA512) {\n        codec_vdbe_return_string(pParse, \"cipher_default_kdf_algorithm\", SQLCIPHER_PBKDF2_HMAC_SHA512_LABEL, P4_TRANSIENT);\n      }\n    }\n  }else\n  if( sqlite3StrICmp(zLeft,\"cipher_compatibility\")==0 ){\n    if(ctx) {\n      if(zRight) {\n        int version = atoi(zRight); \n\n        switch(version) {\n          case 1: \n            rc = sqlcipher_codec_ctx_set_pagesize(ctx, 1024);\n            if (rc != SQLITE_OK) sqlcipher_codec_ctx_set_error(ctx, SQLITE_ERROR);\n            rc = sqlcipher_codec_ctx_set_hmac_algorithm(ctx, SQLCIPHER_HMAC_SHA1);\n            if (rc != SQLITE_OK) sqlcipher_codec_ctx_set_error(ctx, SQLITE_ERROR);\n            rc = sqlcipher_codec_ctx_set_kdf_algorithm(ctx, SQLCIPHER_PBKDF2_HMAC_SHA1);\n            if (rc != SQLITE_OK) sqlcipher_codec_ctx_set_error(ctx, SQLITE_ERROR);\n            rc = sqlcipher_codec_ctx_set_kdf_iter(ctx, 4000); \n            if (rc != SQLITE_OK) sqlcipher_codec_ctx_set_error(ctx, SQLITE_ERROR);\n            rc = sqlcipher_codec_ctx_set_use_hmac(ctx, 0);\n            if (rc != SQLITE_OK) sqlcipher_codec_ctx_set_error(ctx, SQLITE_ERROR);\n            break;\n\n          case 2: \n            rc = sqlcipher_codec_ctx_set_pagesize(ctx, 1024);\n            if (rc != SQLITE_OK) sqlcipher_codec_ctx_set_error(ctx, SQLITE_ERROR);\n            rc = sqlcipher_codec_ctx_set_hmac_algorithm(ctx, SQLCIPHER_HMAC_SHA1);\n            if (rc != SQLITE_OK) sqlcipher_codec_ctx_set_error(ctx, SQLITE_ERROR);\n            rc = sqlcipher_codec_ctx_set_kdf_algorithm(ctx, SQLCIPHER_PBKDF2_HMAC_SHA1);\n            if (rc != SQLITE_OK) sqlcipher_codec_ctx_set_error(ctx, SQLITE_ERROR);\n            rc = sqlcipher_codec_ctx_set_kdf_iter(ctx, 4000); \n            if (rc != SQLITE_OK) sqlcipher_codec_ctx_set_error(ctx, SQLITE_ERROR);\n            rc = sqlcipher_codec_ctx_set_use_hmac(ctx, 1);\n            if (rc != SQLITE_OK) sqlcipher_codec_ctx_set_error(ctx, SQLITE_ERROR);\n            break;\n\n          case 3:\n            rc = sqlcipher_codec_ctx_set_pagesize(ctx, 1024);\n            if (rc != SQLITE_OK) sqlcipher_codec_ctx_set_error(ctx, SQLITE_ERROR);\n            rc = sqlcipher_codec_ctx_set_hmac_algorithm(ctx, SQLCIPHER_HMAC_SHA1);\n            if (rc != SQLITE_OK) sqlcipher_codec_ctx_set_error(ctx, SQLITE_ERROR);\n            rc = sqlcipher_codec_ctx_set_kdf_algorithm(ctx, SQLCIPHER_PBKDF2_HMAC_SHA1);\n            if (rc != SQLITE_OK) sqlcipher_codec_ctx_set_error(ctx, SQLITE_ERROR);\n            rc = sqlcipher_codec_ctx_set_kdf_iter(ctx, 64000); \n            if (rc != SQLITE_OK) sqlcipher_codec_ctx_set_error(ctx, SQLITE_ERROR);\n            rc = sqlcipher_codec_ctx_set_use_hmac(ctx, 1);\n            if (rc != SQLITE_OK) sqlcipher_codec_ctx_set_error(ctx, SQLITE_ERROR);\n            break;\n\n          default:\n            rc = sqlcipher_codec_ctx_set_pagesize(ctx, 4096);\n            if (rc != SQLITE_OK) sqlcipher_codec_ctx_set_error(ctx, SQLITE_ERROR);\n            rc = sqlcipher_codec_ctx_set_hmac_algorithm(ctx, SQLCIPHER_HMAC_SHA512);\n            if (rc != SQLITE_OK) sqlcipher_codec_ctx_set_error(ctx, SQLITE_ERROR);\n            rc = sqlcipher_codec_ctx_set_kdf_algorithm(ctx, SQLCIPHER_PBKDF2_HMAC_SHA512);\n            if (rc != SQLITE_OK) sqlcipher_codec_ctx_set_error(ctx, SQLITE_ERROR);\n            rc = sqlcipher_codec_ctx_set_kdf_iter(ctx, 256000); \n            if (rc != SQLITE_OK) sqlcipher_codec_ctx_set_error(ctx, SQLITE_ERROR);\n            rc = sqlcipher_codec_ctx_set_use_hmac(ctx, 1);\n            if (rc != SQLITE_OK) sqlcipher_codec_ctx_set_error(ctx, SQLITE_ERROR);\n            break;\n        }  \n\n        rc = codec_set_btree_to_codec_pagesize(db, pDb, ctx);\n        if (rc != SQLITE_OK) sqlcipher_codec_ctx_set_error(ctx, SQLITE_ERROR);\n      } \n    }\n  }else \n  if( sqlite3StrICmp(zLeft,\"cipher_default_compatibility\")==0 ){\n    if(zRight) {\n      int version = atoi(zRight); \n      switch(version) {\n        case 1: \n          sqlcipher_set_default_pagesize(1024);\n          sqlcipher_set_default_hmac_algorithm(SQLCIPHER_HMAC_SHA1);\n          sqlcipher_set_default_kdf_algorithm(SQLCIPHER_PBKDF2_HMAC_SHA1);\n          sqlcipher_set_default_kdf_iter(4000);\n          sqlcipher_set_default_use_hmac(0);\n          break;\n\n        case 2: \n          sqlcipher_set_default_pagesize(1024);\n          sqlcipher_set_default_hmac_algorithm(SQLCIPHER_HMAC_SHA1);\n          sqlcipher_set_default_kdf_algorithm(SQLCIPHER_PBKDF2_HMAC_SHA1);\n          sqlcipher_set_default_kdf_iter(4000);\n          sqlcipher_set_default_use_hmac(1);\n          break;\n\n        case 3:\n          sqlcipher_set_default_pagesize(1024);\n          sqlcipher_set_default_hmac_algorithm(SQLCIPHER_HMAC_SHA1);\n          sqlcipher_set_default_kdf_algorithm(SQLCIPHER_PBKDF2_HMAC_SHA1);\n          sqlcipher_set_default_kdf_iter(64000);\n          sqlcipher_set_default_use_hmac(1);\n          break;\n\n        default:\n          sqlcipher_set_default_pagesize(4096);\n          sqlcipher_set_default_hmac_algorithm(SQLCIPHER_HMAC_SHA512);\n          sqlcipher_set_default_kdf_algorithm(SQLCIPHER_PBKDF2_HMAC_SHA512);\n          sqlcipher_set_default_kdf_iter(256000);\n          sqlcipher_set_default_use_hmac(1);\n          break;\n      }  \n    } \n  }else \n  if( sqlite3StrICmp(zLeft,\"cipher_memory_security\")==0 ){\n    if( zRight ) {\n      sqlcipher_set_mem_security(sqlite3GetBoolean(zRight,1));\n    } else {\n      char *on = sqlite3_mprintf(\"%d\", sqlcipher_get_mem_security());\n      codec_vdbe_return_string(pParse, \"cipher_memory_security\", on, P4_DYNAMIC);\n    }\n  }else\n  if( sqlite3StrICmp(zLeft,\"cipher_settings\")==0 ){\n    if(ctx) {\n      int algorithm;\n      char *pragma;\n\n      pragma = sqlite3_mprintf(\"PRAGMA kdf_iter = %d;\", sqlcipher_codec_ctx_get_kdf_iter(ctx));\n      codec_vdbe_return_string(pParse, \"pragma\", pragma, P4_DYNAMIC);\n\n      pragma = sqlite3_mprintf(\"PRAGMA cipher_page_size = %d;\", sqlcipher_codec_ctx_get_pagesize(ctx));\n      codec_vdbe_return_string(pParse, \"pragma\", pragma, P4_DYNAMIC);\n\n      pragma = sqlite3_mprintf(\"PRAGMA cipher_use_hmac = %d;\", sqlcipher_codec_ctx_get_use_hmac(ctx));\n      codec_vdbe_return_string(pParse, \"pragma\", pragma, P4_DYNAMIC);\n\n      pragma = sqlite3_mprintf(\"PRAGMA cipher_plaintext_header_size = %d;\", sqlcipher_codec_ctx_get_plaintext_header_size(ctx));\n      codec_vdbe_return_string(pParse, \"pragma\", pragma, P4_DYNAMIC);\n\n      algorithm = sqlcipher_codec_ctx_get_hmac_algorithm(ctx);\n      pragma = NULL;\n      if(algorithm == SQLCIPHER_HMAC_SHA1) {\n        pragma = sqlite3_mprintf(\"PRAGMA cipher_hmac_algorithm = %s;\", SQLCIPHER_HMAC_SHA1_LABEL);\n      } else if(algorithm == SQLCIPHER_HMAC_SHA256) {\n        pragma = sqlite3_mprintf(\"PRAGMA cipher_hmac_algorithm = %s;\", SQLCIPHER_HMAC_SHA256_LABEL);\n      } else if(algorithm == SQLCIPHER_HMAC_SHA512) {\n        pragma = sqlite3_mprintf(\"PRAGMA cipher_hmac_algorithm = %s;\", SQLCIPHER_HMAC_SHA512_LABEL);\n      }\n      codec_vdbe_return_string(pParse, \"pragma\", pragma, P4_DYNAMIC);\n\n      algorithm = sqlcipher_codec_ctx_get_kdf_algorithm(ctx);\n      pragma = NULL;\n      if(algorithm == SQLCIPHER_PBKDF2_HMAC_SHA1) {\n        pragma = sqlite3_mprintf(\"PRAGMA cipher_kdf_algorithm = %s;\", SQLCIPHER_PBKDF2_HMAC_SHA1_LABEL);\n      } else if(algorithm == SQLCIPHER_PBKDF2_HMAC_SHA256) {\n        pragma = sqlite3_mprintf(\"PRAGMA cipher_kdf_algorithm = %s;\", SQLCIPHER_PBKDF2_HMAC_SHA256_LABEL);\n      } else if(algorithm == SQLCIPHER_PBKDF2_HMAC_SHA512) {\n        pragma = sqlite3_mprintf(\"PRAGMA cipher_kdf_algorithm = %s;\", SQLCIPHER_PBKDF2_HMAC_SHA512_LABEL);\n      }\n      codec_vdbe_return_string(pParse, \"pragma\", pragma, P4_DYNAMIC);\n\n    }\n  }else\n  if( sqlite3StrICmp(zLeft,\"cipher_default_settings\")==0 ){\n    int algorithm;\n    char *pragma;\n\n    pragma = sqlite3_mprintf(\"PRAGMA cipher_default_kdf_iter = %d;\", sqlcipher_get_default_kdf_iter());\n    codec_vdbe_return_string(pParse, \"pragma\", pragma, P4_DYNAMIC);\n\n    pragma = sqlite3_mprintf(\"PRAGMA cipher_default_page_size = %d;\", sqlcipher_get_default_pagesize());\n    codec_vdbe_return_string(pParse, \"pragma\", pragma, P4_DYNAMIC);\n\n    pragma = sqlite3_mprintf(\"PRAGMA cipher_default_use_hmac = %d;\", sqlcipher_get_default_use_hmac());\n    codec_vdbe_return_string(pParse, \"pragma\", pragma, P4_DYNAMIC);\n\n    pragma = sqlite3_mprintf(\"PRAGMA cipher_default_plaintext_header_size = %d;\", sqlcipher_get_default_plaintext_header_size());\n    codec_vdbe_return_string(pParse, \"pragma\", pragma, P4_DYNAMIC);\n\n    algorithm = sqlcipher_get_default_hmac_algorithm();\n    pragma = NULL;\n    if(algorithm == SQLCIPHER_HMAC_SHA1) {\n      pragma = sqlite3_mprintf(\"PRAGMA cipher_default_hmac_algorithm = %s;\", SQLCIPHER_HMAC_SHA1_LABEL);\n    } else if(algorithm == SQLCIPHER_HMAC_SHA256) {\n      pragma = sqlite3_mprintf(\"PRAGMA cipher_default_hmac_algorithm = %s;\", SQLCIPHER_HMAC_SHA256_LABEL);\n    } else if(algorithm == SQLCIPHER_HMAC_SHA512) {\n      pragma = sqlite3_mprintf(\"PRAGMA cipher_default_hmac_algorithm = %s;\", SQLCIPHER_HMAC_SHA512_LABEL);\n    }\n    codec_vdbe_return_string(pParse, \"pragma\", pragma, P4_DYNAMIC);\n\n    algorithm = sqlcipher_get_default_kdf_algorithm();\n    pragma = NULL;\n    if(algorithm == SQLCIPHER_PBKDF2_HMAC_SHA1) {\n      pragma = sqlite3_mprintf(\"PRAGMA cipher_default_kdf_algorithm = %s;\", SQLCIPHER_PBKDF2_HMAC_SHA1_LABEL);\n    } else if(algorithm == SQLCIPHER_PBKDF2_HMAC_SHA256) {\n      pragma = sqlite3_mprintf(\"PRAGMA cipher_default_kdf_algorithm = %s;\", SQLCIPHER_PBKDF2_HMAC_SHA256_LABEL);\n    } else if(algorithm == SQLCIPHER_PBKDF2_HMAC_SHA512) {\n      pragma = sqlite3_mprintf(\"PRAGMA cipher_default_kdf_algorithm = %s;\", SQLCIPHER_PBKDF2_HMAC_SHA512_LABEL);\n    }\n    codec_vdbe_return_string(pParse, \"pragma\", pragma, P4_DYNAMIC);\n  }else {\n    return 0;\n  }\n  return 1;\n}\n\n/* these constants are used internally within SQLite's pager.c to differentiate between\n   operations on the main database or journal pages. This is important in the context\n   of a rekey operations, where the journal must be written using the original key \n   material (to allow a transactional rollback), while the new database pages are being\n   written with the new key material*/\n#define CODEC_READ_OP 3\n#define CODEC_WRITE_OP 6\n#define CODEC_JOURNAL_OP 7\n#ifdef SQLITE_WCDB\n#define CODEC_WCDB_READ_OP 4\n#endif\n\n/*\n * sqlite3Codec can be called in multiple modes.\n * encrypt mode - expected to return a pointer to the \n *   encrypted data without altering pData.\n * decrypt mode - expected to return a pointer to pData, with\n *   the data decrypted in the input buffer\n */\n\nvoid* sqlite3Codec(void *iCtx, void *data, Pgno pgno, int mode) {\n  codec_ctx *ctx = (codec_ctx *) iCtx;\n  int offset = 0, rc = 0;\n  int page_sz = sqlcipher_codec_ctx_get_pagesize(ctx); \n  unsigned char *pData = (unsigned char *) data;\n  void *buffer = sqlcipher_codec_ctx_get_data(ctx);\n  int plaintext_header_sz = sqlcipher_codec_ctx_get_plaintext_header_size(ctx);\n  int cctx = CIPHER_READ_CTX;\n\n  CODEC_TRACE(\"sqlite3Codec: entered pgno=%d, mode=%d, page_sz=%d\\n\", pgno, mode, page_sz);\n\n#ifdef SQLCIPHER_LICENSE\n  if(sqlcipher_license_check(ctx) != SQLITE_OK) return NULL;\n#endif\n\n  /* call to derive keys if not present yet */\n  if((rc = sqlcipher_codec_key_derive(ctx)) != SQLITE_OK) {\n#ifdef SQLITE_WCDB\n   if(mode == CODEC_WCDB_READ_OP) {\n     return NULL;\n   }\n#endif\n   sqlcipher_codec_ctx_set_error(ctx, rc); \n   return NULL;\n  }\n\n  if(pgno == 1) /* adjust starting pointers in data page for header offset on first page*/   \n    offset = plaintext_header_sz ? plaintext_header_sz : FILE_HEADER_SZ; \n  \n\n  CODEC_TRACE(\"sqlite3Codec: switch mode=%d offset=%d\\n\",  mode, offset);\n  switch(mode) {\n    case CODEC_READ_OP: /* decrypt */\n#ifdef SQLITE_WCDB\n    case CODEC_WCDB_READ_OP: /* decrypt data from WCDB*/\n#endif\n      if(pgno == 1) /* copy initial part of file header or SQLite magic to buffer */ \n        memcpy(buffer, plaintext_header_sz ? pData : (void *) SQLITE_FILE_HEADER, offset); \n\n      rc = sqlcipher_page_cipher(ctx, cctx, pgno, CIPHER_DECRYPT, page_sz - offset, pData + offset, (unsigned char*)buffer + offset);\n      if(rc != SQLITE_OK) { /* clear results of failed cipher operation and set error */\n        sqlcipher_memset((unsigned char*) buffer+offset, 0, page_sz-offset);\n#ifdef SQLITE_WCDB\n        if(mode == CODEC_WCDB_READ_OP) {\n          return NULL;\n        }\n#endif\n        sqlcipher_codec_ctx_set_error(ctx, rc);\n      }\n#ifdef SQLITE_WCDB\n      if(mode == CODEC_WCDB_READ_OP) {\n        return buffer;\n      }\n#endif\n      memcpy(pData, buffer, page_sz); /* copy buffer data back to pData and return */\n      return pData;\n      break;\n\n    case CODEC_WRITE_OP: /* encrypt database page, operate on write context and fall through to case 7, so the write context is used*/\n      cctx = CIPHER_WRITE_CTX; \n\n    case CODEC_JOURNAL_OP: /* encrypt journal page, operate on read context use to get the original page data from the database */ \n      if(pgno == 1) { /* copy initial part of file header or salt to buffer */ \n        void *kdf_salt = NULL; \n        /* retrieve the kdf salt */\n        if((rc = sqlcipher_codec_ctx_get_kdf_salt(ctx, &kdf_salt)) != SQLITE_OK) {\n          sqlcipher_codec_ctx_set_error(ctx, rc); \n          return NULL;\n        }\n        memcpy(buffer, plaintext_header_sz ? pData : kdf_salt, offset); \n      }\n      rc = sqlcipher_page_cipher(ctx, cctx, pgno, CIPHER_ENCRYPT, page_sz - offset, pData + offset, (unsigned char*)buffer + offset);\n      if(rc != SQLITE_OK) { /* clear results of failed cipher operation and set error */\n        sqlcipher_memset((unsigned char*)buffer+offset, 0, page_sz-offset);\n        sqlcipher_codec_ctx_set_error(ctx, rc);\n      }\n      return buffer; /* return persistent buffer data, pData remains intact */\n      break;\n\n    default:\n      sqlcipher_codec_ctx_set_error(ctx, SQLITE_ERROR); /* unsupported mode, set error */\n      return pData;\n      break;\n  }\n}\n\n#ifdef SQLITE_WCDB\n\nvoid* sqlite3_getCipherContext(sqlite3 *db, const char* schema) {\n  int index = sqlcipher_find_db_index(db, schema);\n  struct Db *pDb = &db->aDb[index];\n  return sqlite3PagerGetCodec(pDb->pBt->pBt->pPager);\n}\n\n#endif\n\nstatic void sqlite3FreeCodecArg(void *pCodecArg) {\n  codec_ctx *ctx = (codec_ctx *) pCodecArg;\n  if(pCodecArg == NULL) return;\n  sqlcipher_codec_ctx_free(&ctx); /* wipe and free allocated memory for the context */\n  sqlcipher_deactivate(); /* cleanup related structures, OpenSSL etc, when codec is detatched */\n}\n\nSQLITE_PRIVATE int sqlite3CodecAttach(sqlite3* db, int nDb, const void *zKey, int nKey) {\n  struct Db *pDb = &db->aDb[nDb];\n\n  CODEC_TRACE(\"sqlite3CodecAttach: entered db=%p, nDb=%d zKey=%s, nKey=%d\\n\", db, nDb, (char *)zKey, nKey);\n\n\n  if(nKey && zKey && pDb->pBt) {\n    int rc;\n    Pager *pPager = pDb->pBt->pBt->pPager;\n    sqlite3_file *fd;\n    codec_ctx *ctx;\n\n    /* check if the sqlite3_file is open, and if not force handle to NULL */ \n    if((fd = sqlite3PagerFile(pPager))->pMethods == 0) fd = NULL; \n\n    CODEC_TRACE(\"sqlite3CodecAttach: calling sqlcipher_activate()\\n\");\n    sqlcipher_activate(); /* perform internal initialization for sqlcipher */\n\n    CODEC_TRACE_MUTEX(\"sqlite3CodecAttach: entering database mutex %p\\n\", db->mutex);\n    sqlite3_mutex_enter(db->mutex);\n    CODEC_TRACE_MUTEX(\"sqlite3CodecAttach: entered database mutex %p\\n\", db->mutex);\n\n#ifdef SQLCIPHER_LICENSE\n    if((rc = sqlite3_set_authorizer(db, sqlcipher_license_authorizer, db)) != SQLITE_OK) {\n      sqlite3_mutex_leave(db->mutex);\n      return rc;\n    }\n#endif\n\n    /* point the internal codec argument against the contet to be prepared */\n    CODEC_TRACE(\"sqlite3CodecAttach: calling sqlcipher_codec_ctx_init()\\n\");\n    rc = sqlcipher_codec_ctx_init(&ctx, pDb, pDb->pBt->pBt->pPager, zKey, nKey);\n\n    if(rc != SQLITE_OK) {\n      /* initialization failed, do not attach potentially corrupted context */\n      CODEC_TRACE(\"sqlite3CodecAttach: context initialization failed with rc=%d\\n\", rc);\n      CODEC_TRACE_MUTEX(\"sqlite3CodecAttach: leaving database mutex %p (early return on rc=%d)\\n\", db->mutex, rc);\n      sqlite3_mutex_leave(db->mutex);\n      CODEC_TRACE_MUTEX(\"sqlite3CodecAttach: left database mutex %p (early return on rc=%d)\\n\", db->mutex, rc);\n      return rc;\n    }\n\n    CODEC_TRACE(\"sqlite3CodecAttach: calling sqlite3PagerSetCodec()\\n\");\n    sqlite3PagerSetCodec(sqlite3BtreePager(pDb->pBt), sqlite3Codec, NULL, sqlite3FreeCodecArg, (void *) ctx);\n\n    CODEC_TRACE(\"sqlite3CodecAttach: calling codec_set_btree_to_codec_pagesize()\\n\");\n    codec_set_btree_to_codec_pagesize(db, pDb, ctx);\n\n    /* force secure delete. This has the benefit of wiping internal data when deleted\n       and also ensures that all pages are written to disk (i.e. not skipped by\n       sqlite3PagerDontWrite optimizations) */ \n    CODEC_TRACE(\"sqlite3CodecAttach: calling sqlite3BtreeSecureDelete()\\n\");\n    sqlite3BtreeSecureDelete(pDb->pBt, 1); \n\n    /* if fd is null, then this is an in-memory database and\n       we dont' want to overwrite the AutoVacuum settings\n       if not null, then set to the default */\n    if(fd != NULL) { \n      CODEC_TRACE(\"sqlite3CodecAttach: calling sqlite3BtreeSetAutoVacuum()\\n\");\n      sqlite3BtreeSetAutoVacuum(pDb->pBt, SQLITE_DEFAULT_AUTOVACUUM);\n    }\n    CODEC_TRACE_MUTEX(\"sqlite3CodecAttach: leaving database mutex %p\\n\", db->mutex);\n    sqlite3_mutex_leave(db->mutex);\n    CODEC_TRACE_MUTEX(\"sqlite3CodecAttach: left database mutex %p\\n\", db->mutex);\n  }\n  return SQLITE_OK;\n}\n\nint sqlcipher_find_db_index(sqlite3 *db, const char *zDb) {\n  int db_index;\n  if(zDb == NULL){\n    return 0;\n  }\n  for(db_index = 0; db_index < db->nDb; db_index++) {\n    struct Db *pDb = &db->aDb[db_index];\n    if(strcmp(pDb->zDbSName, zDb) == 0) {\n      return db_index;\n    }\n  }\n  return 0;\n}\n\nSQLITE_API void sqlite3_activate_see(const char* in) {\n  /* do nothing, security enhancements are always active */\n}\n\nSQLITE_API int sqlite3_key(sqlite3 *db, const void *pKey, int nKey) {\n  CODEC_TRACE(\"sqlite3_key entered: db=%p pKey=%s nKey=%d\\n\", db, (char *)pKey, nKey);\n  return sqlite3_key_v2(db, \"main\", pKey, nKey);\n}\n\nSQLITE_API int sqlite3_key_v2(sqlite3 *db, const char *zDb, const void *pKey, int nKey) {\n  CODEC_TRACE(\"sqlite3_key_v2: entered db=%p zDb=%s pKey=%s nKey=%d\\n\", db, zDb, (char *)pKey, nKey);\n  /* attach key if db and pKey are not null and nKey is > 0 */\n  if(db && pKey && nKey) {\n    int db_index = sqlcipher_find_db_index(db, zDb);\n    return sqlite3CodecAttach(db, db_index, pKey, nKey); \n  }\n  return SQLITE_ERROR;\n}\n\nSQLITE_API int sqlite3_rekey(sqlite3 *db, const void *pKey, int nKey) {\n  CODEC_TRACE(\"sqlite3_rekey entered: db=%p pKey=%s nKey=%d\\n\", db, (char *)pKey, nKey);\n  return sqlite3_rekey_v2(db, \"main\", pKey, nKey);\n}\n\n/* sqlite3_rekey_v2\n** Given a database, this will reencrypt the database using a new key.\n** There is only one possible modes of operation - to encrypt a database\n** that is already encrpyted. If the database is not already encrypted\n** this should do nothing\n** The proposed logic for this function follows:\n** 1. Determine if the database is already encryptped\n** 2. If there is NOT already a key present do nothing\n** 3. If there is a key present, re-encrypt the database with the new key\n*/\nSQLITE_API int sqlite3_rekey_v2(sqlite3 *db, const char *zDb, const void *pKey, int nKey) {\n  CODEC_TRACE(\"sqlite3_rekey_v2: entered db=%p zDb=%s pKey=%s, nKey=%d\\n\", db, zDb, (char *)pKey, nKey);\n  if(db && pKey && nKey) {\n    int db_index = sqlcipher_find_db_index(db, zDb);\n    struct Db *pDb = &db->aDb[db_index];\n    CODEC_TRACE(\"sqlite3_rekey_v2: database pDb=%p db_index:%d\\n\", pDb, db_index);\n    if(pDb->pBt) {\n      codec_ctx *ctx;\n      int rc, page_count;\n      Pgno pgno;\n      PgHdr *page;\n      Pager *pPager = pDb->pBt->pBt->pPager;\n\n      ctx = (codec_ctx*) sqlite3PagerGetCodec(pDb->pBt->pBt->pPager);\n     \n      if(ctx == NULL) { \n        /* there was no codec attached to this database, so this should do nothing! */ \n        CODEC_TRACE(\"sqlite3_rekey_v2: no codec attached to db, exiting\\n\");\n        return SQLITE_OK;\n      }\n\n      CODEC_TRACE_MUTEX(\"sqlite3_rekey_v2: entering database mutex %p\\n\", db->mutex);\n      sqlite3_mutex_enter(db->mutex);\n      CODEC_TRACE_MUTEX(\"sqlite3_rekey_v2: entered database mutex %p\\n\", db->mutex);\n\n      codec_set_pass_key(db, db_index, pKey, nKey, CIPHER_WRITE_CTX);\n    \n      /* do stuff here to rewrite the database \n      ** 1. Create a transaction on the database\n      ** 2. Iterate through each page, reading it and then writing it.\n      ** 3. If that goes ok then commit and put ctx->rekey into ctx->key\n      **    note: don't deallocate rekey since it may be used in a subsequent iteration \n      */\n      rc = sqlite3BtreeBeginTrans(pDb->pBt, 1, 0); /* begin write transaction */\n      sqlite3PagerPagecount(pPager, &page_count);\n      for(pgno = 1; rc == SQLITE_OK && pgno <= (unsigned int)page_count; pgno++) { /* pgno's start at 1 see pager.c:pagerAcquire */\n        if(!sqlite3pager_is_mj_pgno(pPager, pgno)) { /* skip this page (see pager.c:pagerAcquire for reasoning) */\n          rc = sqlite3PagerGet(pPager, pgno, &page, 0);\n          if(rc == SQLITE_OK) { /* write page see pager_incr_changecounter for example */\n            rc = sqlite3PagerWrite(page);\n            if(rc == SQLITE_OK) {\n              sqlite3PagerUnref(page);\n            } else {\n             CODEC_TRACE(\"sqlite3_rekey_v2: error %d occurred writing page %d\\n\", rc, pgno);  \n            }\n          } else {\n             CODEC_TRACE(\"sqlite3_rekey_v2: error %d occurred getting page %d\\n\", rc, pgno);  \n          }\n        } \n      }\n\n      /* if commit was successful commit and copy the rekey data to current key, else rollback to release locks */\n      if(rc == SQLITE_OK) { \n        CODEC_TRACE(\"sqlite3_rekey_v2: committing\\n\");\n        rc = sqlite3BtreeCommit(pDb->pBt); \n        sqlcipher_codec_key_copy(ctx, CIPHER_WRITE_CTX);\n      } else {\n        CODEC_TRACE(\"sqlite3_rekey_v2: rollback\\n\");\n        sqlite3BtreeRollback(pDb->pBt, SQLITE_ABORT_ROLLBACK, 0);\n      }\n\n      CODEC_TRACE_MUTEX(\"sqlite3_rekey_v2: leaving database mutex %p\\n\", db->mutex);\n      sqlite3_mutex_leave(db->mutex);\n      CODEC_TRACE_MUTEX(\"sqlite3_rekey_v2: left database mutex %p\\n\", db->mutex);\n    }\n    return SQLITE_OK;\n  }\n  return SQLITE_ERROR;\n}\n\nSQLITE_PRIVATE void sqlite3CodecGetKey(sqlite3* db, int nDb, void **zKey, int *nKey) {\n  struct Db *pDb = &db->aDb[nDb];\n  CODEC_TRACE(\"sqlite3CodecGetKey: entered db=%p, nDb=%d\\n\", db, nDb);\n  if( pDb->pBt ) {\n    codec_ctx *ctx = (codec_ctx*) sqlite3PagerGetCodec(pDb->pBt->pBt->pPager);\n    \n    if(ctx) {\n      /* pass back the keyspec from the codec, unless PRAGMA cipher_store_pass\n         is set or keyspec has not yet been derived, in which case pass\n         back the password key material */\n      sqlcipher_codec_get_keyspec(ctx, zKey, nKey);\n      if(sqlcipher_codec_get_store_pass(ctx) == 1 || *zKey == NULL) {\n        sqlcipher_codec_get_pass(ctx, zKey, nKey);\n      }\n    } else {\n      *zKey = NULL;\n      *nKey = 0;\n    }\n  }\n}\n\n#if defined (SQLCIPHER_PREPROCESSED)\nvoid cipher_hex2bin(const unsigned char *hex, int sz, unsigned char *out){\n    int i;\n    for(i = 0; i < sz; i += 2){\n        out[i/2] = (cipher_hex2int(hex[i])<<4) | cipher_hex2int(hex[i+1]);\n    }\n}\n#endif /* SQLCIPHER_PREPROCESSED */\n\n#if defined (SQLCIPHER_PREPROCESSED)\nvoid cipher_bin2hex(const unsigned char* in, int sz, char *out) {\n    int i;\n    for(i=0; i < sz; i++) {\n        sqlite3_snprintf(3, out + (i*2), \"%02x \", in[i]);\n    }\n}\n#endif /* SQLCIPHER_PREPROCESSED */\n\n#if defined (SQLCIPHER_PREPROCESSED)\nint cipher_isHex(const unsigned char *hex, int sz){\n    int i;\n    for(i = 0; i < sz; i++) {\n        unsigned char c = hex[i];\n        if ((c < '0' || c > '9') &&\n            (c < 'A' || c > 'F') &&\n            (c < 'a' || c > 'f')) {\n            return 0;\n        }\n    }\n    return 1;\n}\n#endif /* SQLCIPHER_PREPROCESSED */\n\n\n#ifndef OMIT_EXPORT\n\n/*\n * Implementation of an \"export\" function that allows a caller\n * to duplicate the main database to an attached database. This is intended\n * as a conveneince for users who need to:\n * \n *   1. migrate from an non-encrypted database to an encrypted database\n *   2. move from an encrypted database to a non-encrypted database\n *   3. convert beween the various flavors of encrypted databases.  \n *\n * This implementation is based heavily on the procedure and code used\n * in vacuum.c, but is exposed as a function that allows export to any\n * named attached database.\n */\n\n/*\n** Finalize a prepared statement.  If there was an error, store the\n** text of the error message in *pzErrMsg.  Return the result code.\n** \n** Based on vacuumFinalize from vacuum.c\n*/\nstatic int sqlcipher_finalize(sqlite3 *db, sqlite3_stmt *pStmt, char **pzErrMsg){\n  int rc;\n  rc = sqlite3VdbeFinalize((Vdbe*)pStmt);\n  if( rc ){\n    sqlite3SetString(pzErrMsg, db, sqlite3_errmsg(db));\n  }\n  return rc;\n}\n\n/*\n** Execute zSql on database db. Return an error code.\n** \n** Based on execSql from vacuum.c\n*/\nstatic int sqlcipher_execSql(sqlite3 *db, char **pzErrMsg, const char *zSql){\n  sqlite3_stmt *pStmt;\n  VVA_ONLY( int rc; )\n  if( !zSql ){\n    return SQLITE_NOMEM;\n  }\n  if( SQLITE_OK!=sqlite3_prepare(db, zSql, -1, &pStmt, 0) ){\n    sqlite3SetString(pzErrMsg, db, sqlite3_errmsg(db));\n    return sqlite3_errcode(db);\n  }\n  VVA_ONLY( rc = ) sqlite3_step(pStmt);\n  assert( rc!=SQLITE_ROW );\n  return sqlcipher_finalize(db, pStmt, pzErrMsg);\n}\n\n/*\n** Execute zSql on database db. The statement returns exactly\n** one column. Execute this as SQL on the same database.\n** \n** Based on execExecSql from vacuum.c\n*/\nstatic int sqlcipher_execExecSql(sqlite3 *db, char **pzErrMsg, const char *zSql){\n  sqlite3_stmt *pStmt;\n  int rc;\n\n  rc = sqlite3_prepare(db, zSql, -1, &pStmt, 0);\n  if( rc!=SQLITE_OK ) return rc;\n\n  while( SQLITE_ROW==sqlite3_step(pStmt) ){\n    rc = sqlcipher_execSql(db, pzErrMsg, (char*)sqlite3_column_text(pStmt, 0));\n    if( rc!=SQLITE_OK ){\n      sqlcipher_finalize(db, pStmt, pzErrMsg);\n      return rc;\n    }\n  }\n\n  return sqlcipher_finalize(db, pStmt, pzErrMsg);\n}\n\n/*\n * copy database and schema from the main database to an attached database\n * \n * Based on sqlite3RunVacuum from vacuum.c\n*/\nvoid sqlcipher_exportFunc(sqlite3_context *context, int argc, sqlite3_value **argv) {\n  sqlite3 *db = sqlite3_context_db_handle(context);\n  const char* targetDb, *sourceDb; \n  int targetDb_idx = 0;\n  u64 saved_flags = db->flags;        /* Saved value of the db->flags */\n  u32 saved_mDbFlags = db->mDbFlags;        /* Saved value of the db->mDbFlags */\n  int saved_nChange = db->nChange;      /* Saved value of db->nChange */\n  int saved_nTotalChange = db->nTotalChange; /* Saved value of db->nTotalChange */\n  u8 saved_mTrace = db->mTrace;        /* Saved value of db->mTrace */\n  int (*saved_xTrace)(u32,void*,void*,void*) = db->xTrace; /* Saved db->xTrace */\n  int rc = SQLITE_OK;     /* Return code from service routines */\n  char *zSql = NULL;         /* SQL statements */\n  char *pzErrMsg = NULL;\n\n  if(argc != 1 && argc != 2) {\n    rc = SQLITE_ERROR;\n    pzErrMsg = sqlite3_mprintf(\"invalid number of arguments (%d) passed to sqlcipher_export\", argc);\n    goto end_of_export;\n  }\n\n  targetDb = (const char*) sqlite3_value_text(argv[0]);\n  sourceDb = (argc == 2) ? (char *) sqlite3_value_text(argv[1]) : \"main\";\n\n  /* if the name of the target is not main, but the index returned is zero \n     there is a mismatch and we should not proceed */\n  targetDb_idx =  sqlcipher_find_db_index(db, targetDb);\n  if(targetDb_idx == 0 && sqlite3StrICmp(\"main\", targetDb) != 0) {\n    rc = SQLITE_ERROR;\n    pzErrMsg = sqlite3_mprintf(\"unknown database %s\", targetDb);\n    goto end_of_export;\n  }\n  db->init.iDb = targetDb_idx;\n\n  db->flags |= SQLITE_WriteSchema | SQLITE_IgnoreChecks; \n  db->mDbFlags |= DBFLAG_PreferBuiltin | DBFLAG_Vacuum;\n  db->flags &= ~(u64)(SQLITE_ForeignKeys | SQLITE_ReverseOrder | SQLITE_Defensive | SQLITE_CountRows); \n  db->xTrace = 0;\n  db->mTrace = 0;\n\n  /* Query the schema of the main database. Create a mirror schema\n  ** in the temporary database.\n  */\n  zSql = sqlite3_mprintf(\n    \"SELECT sql \"\n    \"  FROM %s.sqlite_master WHERE type='table' AND name!='sqlite_sequence'\"\n    \"   AND rootpage>0\"\n  , sourceDb);\n  rc = (zSql == NULL) ? SQLITE_NOMEM : sqlcipher_execExecSql(db, &pzErrMsg, zSql); \n  if( rc!=SQLITE_OK ) goto end_of_export;\n  sqlite3_free(zSql);\n\n  zSql = sqlite3_mprintf(\n    \"SELECT sql \"\n    \"  FROM %s.sqlite_master WHERE sql LIKE 'CREATE INDEX %%' \"\n  , sourceDb);\n  rc = (zSql == NULL) ? SQLITE_NOMEM : sqlcipher_execExecSql(db, &pzErrMsg, zSql); \n  if( rc!=SQLITE_OK ) goto end_of_export;\n  sqlite3_free(zSql);\n\n  zSql = sqlite3_mprintf(\n    \"SELECT sql \"\n    \"  FROM %s.sqlite_master WHERE sql LIKE 'CREATE UNIQUE INDEX %%'\"\n  , sourceDb);\n  rc = (zSql == NULL) ? SQLITE_NOMEM : sqlcipher_execExecSql(db, &pzErrMsg, zSql); \n  if( rc!=SQLITE_OK ) goto end_of_export;\n  sqlite3_free(zSql);\n\n  /* Loop through the tables in the main database. For each, do\n  ** an \"INSERT INTO rekey_db.xxx SELECT * FROM main.xxx;\" to copy\n  ** the contents to the temporary database.\n  */\n  zSql = sqlite3_mprintf(\n    \"SELECT 'INSERT INTO %s.' || quote(name) \"\n    \"|| ' SELECT * FROM %s.' || quote(name) || ';'\"\n    \"FROM %s.sqlite_master \"\n    \"WHERE type = 'table' AND name!='sqlite_sequence' \"\n    \"  AND rootpage>0\"\n  , targetDb, sourceDb, sourceDb);\n  rc = (zSql == NULL) ? SQLITE_NOMEM : sqlcipher_execExecSql(db, &pzErrMsg, zSql); \n  if( rc!=SQLITE_OK ) goto end_of_export;\n  sqlite3_free(zSql);\n\n  /* Copy over the contents of the sequence table\n  */\n  zSql = sqlite3_mprintf(\n    \"SELECT 'INSERT INTO %s.' || quote(name) \"\n    \"|| ' SELECT * FROM %s.' || quote(name) || ';' \"\n    \"FROM %s.sqlite_master WHERE name=='sqlite_sequence';\"\n  , targetDb, sourceDb, targetDb);\n  rc = (zSql == NULL) ? SQLITE_NOMEM : sqlcipher_execExecSql(db, &pzErrMsg, zSql); \n  if( rc!=SQLITE_OK ) goto end_of_export;\n  sqlite3_free(zSql);\n\n  /* Copy the triggers, views, and virtual tables from the main database\n  ** over to the temporary database.  None of these objects has any\n  ** associated storage, so all we have to do is copy their entries\n  ** from the SQLITE_MASTER table.\n  */\n  zSql = sqlite3_mprintf(\n    \"INSERT INTO %s.sqlite_master \"\n    \"  SELECT type, name, tbl_name, rootpage, sql\"\n    \"    FROM %s.sqlite_master\"\n    \"   WHERE type='view' OR type='trigger'\"\n    \"      OR (type='table' AND rootpage=0)\"\n  , targetDb, sourceDb);\n  rc = (zSql == NULL) ? SQLITE_NOMEM : sqlcipher_execSql(db, &pzErrMsg, zSql); \n  if( rc!=SQLITE_OK ) goto end_of_export;\n  sqlite3_free(zSql);\n\n  zSql = NULL;\nend_of_export:\n  db->init.iDb = 0;\n  db->flags = saved_flags;\n  db->mDbFlags = saved_mDbFlags;\n  db->nChange = saved_nChange;\n  db->nTotalChange = saved_nTotalChange;\n  db->xTrace = saved_xTrace;\n  db->mTrace = saved_mTrace;\n\n  if(zSql) sqlite3_free(zSql);\n\n  if(rc) {\n    if(pzErrMsg != NULL) {\n      sqlite3_result_error(context, pzErrMsg, -1);\n      sqlite3DbFree(db, pzErrMsg);\n    } else {\n      sqlite3_result_error(context, sqlite3ErrStr(rc), -1);\n    }\n  }\n}\n\n#endif\n\n/* END SQLCIPHER */\n#endif\n\n/************** End of crypto.c **********************************************/\n/************** Begin file crypto_impl.c *************************************/\n/* \n** SQLCipher\n** http://sqlcipher.net\n** \n** Copyright (c) 2008 - 2013, ZETETIC LLC\n** All rights reserved.\n** \n** Redistribution and use in source and binary forms, with or without\n** modification, are permitted provided that the following conditions are met:\n**     * Redistributions of source code must retain the above copyright\n**       notice, this list of conditions and the following disclaimer.\n**     * Redistributions in binary form must reproduce the above copyright\n**       notice, this list of conditions and the following disclaimer in the\n**       documentation and/or other materials provided with the distribution.\n**     * Neither the name of the ZETETIC LLC nor the\n**       names of its contributors may be used to endorse or promote products\n**       derived from this software without specific prior written permission.\n** \n** THIS SOFTWARE IS PROVIDED BY ZETETIC LLC ''AS IS'' AND ANY\n** EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n** DISCLAIMED. IN NO EVENT SHALL ZETETIC LLC BE LIABLE FOR ANY\n** DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n** (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n** LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n** ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n**  \n*/\n/* BEGIN SQLCIPHER */\n#ifdef SQLITE_HAS_CODEC\n\n/* #include \"sqlcipher.h\" */\n/* #include \"crypto.h\" */\n#if defined(__unix__) || defined(__APPLE__) || defined(_AIX)\n#include <errno.h>\n#include <unistd.h>\n#include <sys/resource.h>\n#include <sys/mman.h>\n#elif defined(_WIN32)\n#include <windows.h>\n#endif\n\nstatic volatile unsigned int default_flags = DEFAULT_CIPHER_FLAGS;\nstatic volatile unsigned char hmac_salt_mask = HMAC_SALT_MASK;\nstatic volatile int default_kdf_iter = PBKDF2_ITER;\nstatic volatile int default_page_size = 4096;\nstatic volatile int default_plaintext_header_sz = 0;\nstatic volatile int default_hmac_algorithm = SQLCIPHER_HMAC_SHA512;\nstatic volatile int default_kdf_algorithm = SQLCIPHER_PBKDF2_HMAC_SHA512;\n#ifndef OMIT_MEM_SECURITY\nstatic volatile int mem_security_on = 1;\nstatic volatile int mem_security_initialized = 0;\nstatic volatile int mem_security_activated = 0;\n#endif\nstatic volatile unsigned int sqlcipher_activate_count = 0;\nstatic volatile sqlite3_mem_methods default_mem_methods;\nstatic sqlite3_mutex* sqlcipher_provider_mutex = NULL;\nstatic sqlcipher_provider *default_provider = NULL;\n\n/* the default implementation of SQLCipher uses a cipher_ctx\n   to keep track of read / write state separately. The following\n   struct and associated functions are defined here */\ntypedef struct {\n  int derive_key; \n  int pass_sz;\n  unsigned char *key;\n  unsigned char *hmac_key;\n  unsigned char *pass;\n  char *keyspec;\n} cipher_ctx;\n\n\nstruct codec_ctx {\n  int store_pass; \n  int kdf_iter; \n  int fast_kdf_iter; \n  int kdf_salt_sz;\n  int key_sz; \n  int iv_sz;\n  int block_sz;\n  int page_sz;\n  int keyspec_sz; \n  int reserve_sz;\n  int hmac_sz;\n  int plaintext_header_sz;\n  int hmac_algorithm;\n  int kdf_algorithm;\n  unsigned int skip_read_hmac;\n  unsigned int need_kdf_salt;\n  unsigned int flags;\n  unsigned char *kdf_salt;\n  unsigned char *hmac_kdf_salt;\n  unsigned char *buffer;\n  Btree *pBt;\n  cipher_ctx *read_ctx;\n  cipher_ctx *write_ctx;\n  sqlcipher_provider *provider;\n  void *provider_ctx;\n};\n\n#ifndef OMIT_MEM_SECURITY\nstatic int sqlcipher_mem_init(void *pAppData) {\n  return default_mem_methods.xInit(pAppData);\n}\nstatic void sqlcipher_mem_shutdown(void *pAppData) {\n  default_mem_methods.xShutdown(pAppData);\n}\nstatic void *sqlcipher_mem_malloc(int n) {\n  void *ptr = default_mem_methods.xMalloc(n);\n  if(mem_security_on) {\n    CODEC_TRACE(\"sqlcipher_mem_malloc: calling sqlcipher_mlock(%p,%d)\\n\", ptr, n);\n    sqlcipher_mlock(ptr, n); \n    if(!mem_security_activated) mem_security_activated = 1;\n  }\n  return ptr;\n}\nstatic int sqlcipher_mem_size(void *p) {\n  return default_mem_methods.xSize(p);\n}\nstatic void sqlcipher_mem_free(void *p) {\n  int sz;\n  if(mem_security_on) {\n    sz = sqlcipher_mem_size(p);\n    CODEC_TRACE(\"sqlcipher_mem_free: calling sqlcipher_memset(%p,0,%d) and sqlcipher_munlock(%p, %d) \\n\", p, sz, p, sz);\n    sqlcipher_memset(p, 0, sz);\n    sqlcipher_munlock(p, sz);\n    if(!mem_security_activated) mem_security_activated = 1;\n  }\n  default_mem_methods.xFree(p);\n}\nstatic void *sqlcipher_mem_realloc(void *p, int n) {\n  return default_mem_methods.xRealloc(p, n);\n}\nstatic int sqlcipher_mem_roundup(int n) {\n  return default_mem_methods.xRoundup(n);\n}\n\nstatic sqlite3_mem_methods sqlcipher_mem_methods = {\n  sqlcipher_mem_malloc,\n  sqlcipher_mem_free,\n  sqlcipher_mem_realloc,\n  sqlcipher_mem_size,\n  sqlcipher_mem_roundup,\n  sqlcipher_mem_init,\n  sqlcipher_mem_shutdown,\n  0\n};\n\nvoid sqlcipher_init_memmethods() {\n  if(mem_security_initialized) return;\n  if(sqlite3_config(SQLITE_CONFIG_GETMALLOC, &default_mem_methods) != SQLITE_OK ||\n     sqlite3_config(SQLITE_CONFIG_MALLOC, &sqlcipher_mem_methods)  != SQLITE_OK) {\n    mem_security_on = mem_security_activated = 0;\n  }\n  mem_security_initialized = 1;\n}\n#endif /* OMIT_MEM_SECURITY */\n\nint sqlcipher_register_provider(sqlcipher_provider *p) {\n  CODEC_TRACE_MUTEX(\"sqlcipher_register_provider: entering sqlcipher provider mutex %p\\n\", sqlcipher_provider_mutex);\n  sqlite3_mutex_enter(sqlcipher_provider_mutex);\n  CODEC_TRACE_MUTEX(\"sqlcipher_register_provider: entered sqlcipher provider mutex %p\\n\", sqlcipher_provider_mutex);\n\n  if(default_provider != NULL && default_provider != p) {\n    /* only free the current registerd provider if it has been initialized\n       and it isn't a pointer to the same provider passed to the function\n       (i.e. protect against a caller calling register twice for the same provider) */\n    sqlcipher_free(default_provider, sizeof(sqlcipher_provider));\n  }\n  default_provider = p;   \n  CODEC_TRACE_MUTEX(\"sqlcipher_register_provider: leaving sqlcipher provider mutex %p\\n\", sqlcipher_provider_mutex);\n  sqlite3_mutex_leave(sqlcipher_provider_mutex);\n  CODEC_TRACE_MUTEX(\"sqlcipher_register_provider: left sqlcipher provider mutex %p\\n\", sqlcipher_provider_mutex);\n\n  return SQLITE_OK;\n}\n\n/* return a pointer to the currently registered provider. This will\n   allow an application to fetch the current registered provider and\n   make minor changes to it */\nsqlcipher_provider* sqlcipher_get_provider() {\n  return default_provider;\n}\n\nvoid sqlcipher_activate() {\n  CODEC_TRACE_MUTEX(\"sqlcipher_activate: entering static master mutex\\n\");\n  sqlite3_mutex_enter(sqlite3_mutex_alloc(SQLITE_MUTEX_STATIC_MASTER));\n  CODEC_TRACE_MUTEX(\"sqlcipher_activate: entered static master mutex\\n\");\n\n  if(sqlcipher_provider_mutex == NULL) {\n    /* allocate a new mutex to guard access to the provider */\n    CODEC_TRACE_MUTEX(\"sqlcipher_activate: allocating sqlcipher provider mutex\\n\");\n    sqlcipher_provider_mutex = sqlite3_mutex_alloc(SQLITE_MUTEX_FAST);\n    CODEC_TRACE_MUTEX(\"sqlcipher_activate: allocated sqlcipher provider mutex %p\\n\", sqlcipher_provider_mutex);\n  }\n\n  /* check to see if there is a provider registered at this point\n     if there no provider registered at this point, register the \n     default provider */\n  if(sqlcipher_get_provider() == NULL) {\n    sqlcipher_provider *p = sqlcipher_malloc(sizeof(sqlcipher_provider)); \n\n#if defined(SQLCIPHER_CRYPTO_CUSTOM)\n    extern int sqlcipher_custom_setup(sqlcipher_provider *p);\n    sqlcipher_custom_setup(p);\n#elif defined (SQLCIPHER_CRYPTO_CC)\n    extern int sqlcipher_cc_setup(sqlcipher_provider *p);\n    sqlcipher_cc_setup(p);\n#elif defined (SQLCIPHER_CRYPTO_LIBTOMCRYPT)\n    extern int sqlcipher_ltc_setup(sqlcipher_provider *p);\n    sqlcipher_ltc_setup(p);\n#elif defined (SQLCIPHER_CRYPTO_OPENSSL)\n    extern int sqlcipher_openssl_setup(sqlcipher_provider *p);\n    sqlcipher_openssl_setup(p);\n#else\n#error \"NO DEFAULT SQLCIPHER CRYPTO PROVIDER DEFINED\"\n#endif\n    CODEC_TRACE(\"sqlcipher_activate: calling sqlcipher_register_provider(%p)\\n\", p);\n    sqlcipher_register_provider(p);\n    CODEC_TRACE(\"sqlcipher_activate: called sqlcipher_register_provider(%p)\\n\",p);\n  }\n\n  sqlcipher_activate_count++; /* increment activation count */\n\n  CODEC_TRACE_MUTEX(\"sqlcipher_activate: leaving static master mutex\\n\");\n  sqlite3_mutex_leave(sqlite3_mutex_alloc(SQLITE_MUTEX_STATIC_MASTER));\n  CODEC_TRACE_MUTEX(\"sqlcipher_activate: left static master mutex\\n\");\n}\n\nvoid sqlcipher_deactivate() {\n  CODEC_TRACE_MUTEX(\"sqlcipher_deactivate: entering static master mutex\\n\");\n  sqlite3_mutex_enter(sqlite3_mutex_alloc(SQLITE_MUTEX_STATIC_MASTER));\n  CODEC_TRACE_MUTEX(\"sqlcipher_deactivate: entered static master mutex\\n\");\n\n  sqlcipher_activate_count--;\n  /* if no connections are using sqlcipher, cleanup globals */\n  if(sqlcipher_activate_count < 1) {\n    CODEC_TRACE_MUTEX(\"sqlcipher_deactivate: entering sqlcipher provider mutex %p\\n\", sqlcipher_provider_mutex);\n    sqlite3_mutex_enter(sqlcipher_provider_mutex);\n    CODEC_TRACE_MUTEX(\"sqlcipher_deactivate: entered sqlcipher provider mutex %p\\n\", sqlcipher_provider_mutex);\n\n    if(default_provider != NULL) {\n      sqlcipher_free(default_provider, sizeof(sqlcipher_provider));\n      default_provider = NULL;\n    }\n\n    CODEC_TRACE_MUTEX(\"sqlcipher_deactivate: leaving sqlcipher provider mutex %p\\n\", sqlcipher_provider_mutex);\n    sqlite3_mutex_leave(sqlcipher_provider_mutex);\n    CODEC_TRACE_MUTEX(\"sqlcipher_deactivate: left sqlcipher provider mutex %p\\n\", sqlcipher_provider_mutex);\n    \n    /* last connection closed, free provider mutex*/\n    CODEC_TRACE_MUTEX(\"sqlcipher_deactivate: freeing sqlcipher provider mutex %p\\n\", sqlcipher_provider_mutex);\n    sqlite3_mutex_free(sqlcipher_provider_mutex); \n    CODEC_TRACE_MUTEX(\"sqlcipher_deactivate: freed sqlcipher provider mutex %p\\n\", sqlcipher_provider_mutex);\n\n    sqlcipher_provider_mutex = NULL;\n\n    sqlcipher_activate_count = 0; /* reset activation count */\n  }\n\n  CODEC_TRACE_MUTEX(\"sqlcipher_deactivate: leaving static master mutex\\n\");\n  sqlite3_mutex_leave(sqlite3_mutex_alloc(SQLITE_MUTEX_STATIC_MASTER));\n  CODEC_TRACE_MUTEX(\"sqlcipher_deactivate: left static master mutex\\n\");\n}\n\n/* constant time memset using volitile to avoid having the memset\n   optimized out by the compiler. \n   Note: As suggested by Joachim Schipper (joachim.schipper@fox-it.com)\n*/\nvoid* sqlcipher_memset(void *v, unsigned char value, int len) {\n#ifndef OMIT_MEM_SECURITY\n  if (v == NULL) return v;\n\n  unsigned long val = 0;\n  int i;\n  for (i = 0; i < sizeof(unsigned long); i++) {\n    val = (val << 8) | (value & 0xff);\n  }\n  int len2 = len % sizeof(unsigned long);\n  len = len / sizeof(unsigned long);\n\n  volatile unsigned long *aa = (unsigned long *) v;\n  for (i = 0; i < len; i++) {\n    *aa++ = val;\n  }\n  volatile unsigned char *a = (unsigned char *) aa;\n  for (i = 0; i < len2; i++) {\n    *a++ = value;\n  }\n\n  return v;\n#else\n  return memset(v, value, len);\n#endif\n}\n\n/* constant time memory check tests every position of a memory segement\n   matches a single value (i.e. the memory is all zeros)\n   returns 0 if match, 1 of no match */\nint sqlcipher_ismemset(const void *v, unsigned char value, int len) {\n  unsigned long val = 0;\n  int i;\n  for (i = 0; i < sizeof(unsigned long); i++) {\n    val = (val << 8) | (value & 0xff);\n  }\n  int len2 = len % sizeof(unsigned long);\n  len = len / sizeof(unsigned long);\n\n#ifndef OMIT_MEM_SECURITY\n  int result = 0;\n  const unsigned long *aa = (const unsigned long *) v;\n  for (i = 0; i < len; i++) {\n    result |= *aa++ ^ val;\n  }\n  const unsigned char *a = (const unsigned char *) aa;\n  for (i = 0; i < len2; i++) {\n    result |= *a++ ^ value;\n  }\n\n  return (result != 0);\n#else\n  const unsigned long *aa = (const unsigned long *) v;\n  for (i = 0; i < len; i++) {\n    if (*aa++ != val) return 1;\n  }\n  const unsigned char *a = (const unsigned char *) aa;\n  for (i = 0; i < len2; i++) {\n    if (*a++ != value) return 1;\n  }\n\n  return 0;\n#endif\n}\n\n/* constant time memory comparison routine. \n   returns 0 if match, 1 if no match */\nint sqlcipher_memcmp(const void *v0, const void *v1, int len) {\n#ifndef OMIT_MEM_SECURITY\n  int len2 = len % sizeof(unsigned long);\n  len = len / sizeof(unsigned long);\n  int i, result = 0;\n\n  const unsigned long *aa0 = (const unsigned long *) v0;\n  const unsigned long *aa1 = (const unsigned long *) v1;\n  for (i = 0; i < len; i++) {\n    result |= *aa0++ ^ *aa1++;\n  }\n  const unsigned char *a0 = (const unsigned char *) aa0;\n  const unsigned char *a1 = (const unsigned char *) aa1;\n  for (i = 0; i < len2; i++) {\n    result |= *a0++ ^ *a1++;\n  }\n  \n  return (result != 0);\n#else\n  return memcmp(v0, v1, len);\n#endif\n}\n\nvoid sqlcipher_mlock(void *ptr, int sz) {\n#ifndef OMIT_MEMLOCK\n#if defined(__unix__) || defined(__APPLE__) \n  int rc;\n  unsigned long pagesize = sysconf(_SC_PAGESIZE);\n  unsigned long offset = (unsigned long) ptr % pagesize;\n\n  if(ptr == NULL || sz == 0) return;\n\n  CODEC_TRACE(\"sqlcipher_mem_lock: calling mlock(%p,%lu); _SC_PAGESIZE=%lu\\n\", ptr - offset, sz + offset, pagesize);\n  rc = mlock(ptr - offset, sz + offset);\n  if(rc!=0) {\n    CODEC_TRACE(\"sqlcipher_mem_lock: mlock(%p,%lu) returned %d errno=%d\\n\", ptr - offset, sz + offset, rc, errno);\n  }\n#elif defined(_WIN32)\n#if !(defined(WINAPI_FAMILY) && (WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP || WINAPI_FAMILY == WINAPI_FAMILY_APP))\n  int rc;\n  CODEC_TRACE(\"sqlcipher_mem_lock: calling VirtualLock(%p,%d)\\n\", ptr, sz);\n  rc = VirtualLock(ptr, sz);\n  if(rc==0) {\n    CODEC_TRACE(\"sqlcipher_mem_lock: VirtualLock(%p,%d) returned %d LastError=%d\\n\", ptr, sz, rc, GetLastError());\n  }\n#endif\n#endif\n#endif\n}\n\nvoid sqlcipher_munlock(void *ptr, int sz) {\n#ifndef OMIT_MEMLOCK\n#if defined(__unix__) || defined(__APPLE__) \n  int rc;\n  unsigned long pagesize = sysconf(_SC_PAGESIZE);\n  unsigned long offset = (unsigned long) ptr % pagesize;\n\n  if(ptr == NULL || sz == 0) return;\n\n  CODEC_TRACE(\"sqlcipher_mem_unlock: calling munlock(%p,%lu)\\n\", ptr - offset, sz + offset);\n  rc = munlock(ptr - offset, sz + offset);\n  if(rc!=0) {\n    CODEC_TRACE(\"sqlcipher_mem_unlock: munlock(%p,%lu) returned %d errno=%d\\n\", ptr - offset, sz + offset, rc, errno);\n  }\n#elif defined(_WIN32)\n#if !(defined(WINAPI_FAMILY) && (WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP || WINAPI_FAMILY == WINAPI_FAMILY_APP))\n  int rc;\n  CODEC_TRACE(\"sqlcipher_mem_lock: calling VirtualUnlock(%p,%d)\\n\", ptr, sz);\n  rc = VirtualUnlock(ptr, sz);\n  if(!rc) {\n    CODEC_TRACE(\"sqlcipher_mem_unlock: VirtualUnlock(%p,%d) returned %d LastError=%d\\n\", ptr, sz, rc, GetLastError());\n  }\n#endif\n#endif\n#endif\n}\n\n/**\n  * Free and wipe memory. Uses SQLites internal sqlite3_free so that memory\n  * can be countend and memory leak detection works in the test suite. \n  * If ptr is not null memory will be freed. \n  * If sz is greater than zero, the memory will be overwritten with zero before it is freed\n  * If sz is > 0, and not compiled with OMIT_MEMLOCK, system will attempt to unlock the\n  * memory segment so it can be paged\n  */\nvoid sqlcipher_free(void *ptr, int sz) {\n#ifndef OMIT_MEM_SECURITY\n  if(ptr) {\n    CODEC_TRACE(\"sqlcipher_free: calling sqlcipher_memset(%p,0,%d)\\n\", ptr, sz);\n    sqlcipher_memset(ptr, 0, sz);\n    sqlcipher_munlock(ptr, sz);\n  }\n#endif\n  sqlite3_free(ptr);\n}\n\n/**\n  * allocate memory. Uses sqlite's internall malloc wrapper so memory can be \n  * reference counted and leak detection works. Unless compiled with OMIT_MEMLOCK\n  * attempts to lock the memory pages so sensitive information won't be swapped\n  */\nvoid* sqlcipher_malloc(int sz) {\n  void *ptr;\n  CODEC_TRACE(\"sqlcipher_malloc: calling sqlite3Malloc(%d)\\n\", sz);\n  ptr = sqlite3Malloc(sz);\n  CODEC_TRACE(\"sqlcipher_malloc: calling sqlcipher_memset(%p,0,%d)\\n\", ptr, sz);\n  sqlcipher_memset(ptr, 0, sz);\n#ifndef OMIT_MEM_SECURITY\n  sqlcipher_mlock(ptr, sz);\n#endif\n  return ptr;\n}\n\n/**\n  * Initialize new cipher_ctx struct. This function will allocate memory\n  * for the cipher context and for the key\n  * \n  * returns SQLITE_OK if initialization was successful\n  * returns SQLITE_NOMEM if an error occured allocating memory\n  */\nstatic int sqlcipher_cipher_ctx_init(codec_ctx *ctx, cipher_ctx **iCtx) {\n  cipher_ctx *c_ctx;\n  CODEC_TRACE(\"sqlcipher_cipher_ctx_init: allocating context\\n\");\n  *iCtx = (cipher_ctx *) sqlcipher_malloc(sizeof(cipher_ctx));\n  c_ctx = *iCtx;\n  if(c_ctx == NULL) return SQLITE_NOMEM;\n\n  CODEC_TRACE(\"sqlcipher_cipher_ctx_init: allocating key\\n\");\n  c_ctx->key = (unsigned char *) sqlcipher_malloc(ctx->key_sz);\n\n  CODEC_TRACE(\"sqlcipher_cipher_ctx_init: allocating hmac_key\\n\");\n  c_ctx->hmac_key = (unsigned char *) sqlcipher_malloc(ctx->key_sz);\n\n  if(c_ctx->key == NULL) return SQLITE_NOMEM;\n  if(c_ctx->hmac_key == NULL) return SQLITE_NOMEM;\n\n  return SQLITE_OK;\n}\n\n/**\n  * Free and wipe memory associated with a cipher_ctx\n  */\nstatic void sqlcipher_cipher_ctx_free(codec_ctx* ctx, cipher_ctx **iCtx) {\n  cipher_ctx *c_ctx = *iCtx;\n  CODEC_TRACE(\"cipher_ctx_free: entered iCtx=%p\\n\", iCtx);\n  sqlcipher_free(c_ctx->key, ctx->key_sz);\n  sqlcipher_free(c_ctx->hmac_key, ctx->key_sz);\n  sqlcipher_free(c_ctx->pass, c_ctx->pass_sz);\n  sqlcipher_free(c_ctx->keyspec, ctx->keyspec_sz);\n  sqlcipher_free(c_ctx, sizeof(cipher_ctx)); \n}\n\nstatic int sqlcipher_codec_ctx_reserve_setup(codec_ctx *ctx) {\n  int base_reserve = ctx->iv_sz; /* base reserve size will be IV only */ \n  int reserve = base_reserve;\n\n  ctx->hmac_sz = ctx->provider->get_hmac_sz(ctx->provider_ctx, ctx->hmac_algorithm); \n\n  if(sqlcipher_codec_ctx_get_use_hmac(ctx))\n    reserve += ctx->hmac_sz; /* if reserve will include hmac, update that size */\n\n  /* calculate the amount of reserve needed in even increments of the cipher block size */\n  reserve = ((reserve % ctx->block_sz) == 0) ? reserve :\n               ((reserve / ctx->block_sz) + 1) * ctx->block_sz;  \n\n  CODEC_TRACE(\"sqlcipher_codec_ctx_reserve_setup: base_reserve=%d block_sz=%d md_size=%d reserve=%d\\n\", \n                base_reserve, ctx->block_sz, ctx->hmac_sz, reserve); \n\n  ctx->reserve_sz = reserve;\n\n  return SQLITE_OK;\n}\n\n/**\n  * Compare one cipher_ctx to another.\n  *\n  * returns 0 if all the parameters (except the derived key data) are the same\n  * returns 1 otherwise\n  */\nstatic int sqlcipher_cipher_ctx_cmp(cipher_ctx *c1, cipher_ctx *c2) {\n  int are_equal = (\n    c1->pass_sz == c2->pass_sz\n    && (\n      c1->pass == c2->pass\n      || !sqlcipher_memcmp((const unsigned char*)c1->pass,\n                           (const unsigned char*)c2->pass,\n                           c1->pass_sz)\n    ));\n\n  CODEC_TRACE(\"sqlcipher_cipher_ctx_cmp: entered \\\n                  c1=%p c2=%p \\\n                  c1->pass_sz=%d c2->pass_sz=%d \\\n                  c1->pass=%p c2->pass=%p \\\n                  c1->pass=%s c2->pass=%s \\\n                  sqlcipher_memcmp=%d \\\n                  are_equal=%d \\\n                   \\n\", \n                  c1, c2,\n                  c1->pass_sz, c2->pass_sz,\n                  c1->pass, c2->pass,\n                  c1->pass, c2->pass,\n                  (c1->pass == NULL || c2->pass == NULL) \n                    ? -1 : sqlcipher_memcmp(\n                      (const unsigned char*)c1->pass,\n                      (const unsigned char*)c2->pass,\n                      c1->pass_sz),\n                  are_equal\n                  );\n\n  return !are_equal; /* return 0 if they are the same, 1 otherwise */\n}\n\n/**\n  * Copy one cipher_ctx to another. For instance, assuming that read_ctx is a \n  * fully initialized context, you could copy it to write_ctx and all yet data\n  * and pass information across\n  *\n  * returns SQLITE_OK if initialization was successful\n  * returns SQLITE_NOMEM if an error occured allocating memory\n  */\nstatic int sqlcipher_cipher_ctx_copy(codec_ctx *ctx, cipher_ctx *target, cipher_ctx *source) {\n  void *key = target->key; \n  void *hmac_key = target->hmac_key; \n\n  CODEC_TRACE(\"sqlcipher_cipher_ctx_copy: entered target=%p, source=%p\\n\", target, source);\n  sqlcipher_free(target->pass, target->pass_sz); \n  sqlcipher_free(target->keyspec, ctx->keyspec_sz); \n  memcpy(target, source, sizeof(cipher_ctx));\n\n  target->key = key; /* restore pointer to previously allocated key data */\n  memcpy(target->key, source->key, ctx->key_sz);\n\n  target->hmac_key = hmac_key; /* restore pointer to previously allocated hmac key data */\n  memcpy(target->hmac_key, source->hmac_key, ctx->key_sz);\n\n  if(source->pass && source->pass_sz) {\n    target->pass = sqlcipher_malloc(source->pass_sz);\n    if(target->pass == NULL) return SQLITE_NOMEM;\n    memcpy(target->pass, source->pass, source->pass_sz);\n  }\n  if(source->keyspec) {\n    target->keyspec = sqlcipher_malloc(ctx->keyspec_sz);\n    if(target->keyspec == NULL) return SQLITE_NOMEM;\n    memcpy(target->keyspec, source->keyspec, ctx->keyspec_sz);\n  }\n  return SQLITE_OK;\n}\n\n/**\n  * Set the keyspec for the cipher_ctx\n  * \n  * returns SQLITE_OK if assignment was successfull\n  * returns SQLITE_NOMEM if an error occured allocating memory\n  */\nstatic int sqlcipher_cipher_ctx_set_keyspec(codec_ctx *ctx, cipher_ctx *c_ctx, const unsigned char *key) {\n  /* free, zero existing pointers and size */\n  sqlcipher_free(c_ctx->keyspec, ctx->keyspec_sz);\n  c_ctx->keyspec = NULL;\n\n  c_ctx->keyspec = sqlcipher_malloc(ctx->keyspec_sz);\n  if(c_ctx->keyspec == NULL) return SQLITE_NOMEM;\n\n  c_ctx->keyspec[0] = 'x';\n  c_ctx->keyspec[1] = '\\'';\n  cipher_bin2hex(key, ctx->key_sz, c_ctx->keyspec + 2);\n  cipher_bin2hex(ctx->kdf_salt, ctx->kdf_salt_sz, c_ctx->keyspec + (ctx->key_sz * 2) + 2);\n  c_ctx->keyspec[ctx->keyspec_sz - 1] = '\\'';\n  return SQLITE_OK;\n}\n\nint sqlcipher_codec_get_store_pass(codec_ctx *ctx) {\n  return ctx->store_pass;\n}\n\nvoid sqlcipher_codec_set_store_pass(codec_ctx *ctx, int value) {\n  ctx->store_pass = value;\n}\n\nvoid sqlcipher_codec_get_pass(codec_ctx *ctx, void **zKey, int *nKey) {\n  *zKey = ctx->read_ctx->pass;\n  *nKey = ctx->read_ctx->pass_sz;\n}\n\nstatic void sqlcipher_set_derive_key(codec_ctx *ctx, int derive) {\n  if(ctx->read_ctx != NULL) ctx->read_ctx->derive_key = 1;\n  if(ctx->write_ctx != NULL) ctx->write_ctx->derive_key = 1;\n}\n\n/**\n  * Set the passphrase for the cipher_ctx\n  * \n  * returns SQLITE_OK if assignment was successfull\n  * returns SQLITE_NOMEM if an error occured allocating memory\n  */\nstatic int sqlcipher_cipher_ctx_set_pass(cipher_ctx *ctx, const void *zKey, int nKey) {\n  /* free, zero existing pointers and size */\n  sqlcipher_free(ctx->pass, ctx->pass_sz);\n  ctx->pass = NULL;\n  ctx->pass_sz = 0;\n\n  if(zKey && nKey) { /* if new password is provided, copy it */\n    ctx->pass_sz = nKey;\n    ctx->pass = sqlcipher_malloc(nKey);\n    if(ctx->pass == NULL) return SQLITE_NOMEM;\n    memcpy(ctx->pass, zKey, nKey);\n  } \n  return SQLITE_OK;\n}\n\nint sqlcipher_codec_ctx_set_pass(codec_ctx *ctx, const void *zKey, int nKey, int for_ctx) {\n  cipher_ctx *c_ctx = for_ctx ? ctx->write_ctx : ctx->read_ctx;\n  int rc;\n\n  if((rc = sqlcipher_cipher_ctx_set_pass(c_ctx, zKey, nKey)) != SQLITE_OK) return rc; \n  c_ctx->derive_key = 1;\n\n  if(for_ctx == 2)\n    if((rc = sqlcipher_cipher_ctx_copy(ctx, for_ctx ? ctx->read_ctx : ctx->write_ctx, c_ctx)) != SQLITE_OK) \n      return rc; \n\n  return SQLITE_OK;\n} \n\nconst char* sqlcipher_codec_ctx_get_cipher(codec_ctx *ctx) {\n  return ctx->provider->get_cipher(ctx->provider_ctx);\n}\n\n/* set the global default KDF iteration */\nvoid sqlcipher_set_default_kdf_iter(int iter) {\n  default_kdf_iter = iter; \n}\n\nint sqlcipher_get_default_kdf_iter() {\n  return default_kdf_iter;\n}\n\nint sqlcipher_codec_ctx_set_kdf_iter(codec_ctx *ctx, int kdf_iter) {\n  ctx->kdf_iter = kdf_iter;\n  sqlcipher_set_derive_key(ctx, 1);\n  return SQLITE_OK;\n}\n\nint sqlcipher_codec_ctx_get_kdf_iter(codec_ctx *ctx) {\n  return ctx->kdf_iter;\n}\n\nint sqlcipher_codec_ctx_set_fast_kdf_iter(codec_ctx *ctx, int fast_kdf_iter) {\n  ctx->fast_kdf_iter = fast_kdf_iter;\n  sqlcipher_set_derive_key(ctx, 1);\n  return SQLITE_OK;\n}\n\nint sqlcipher_codec_ctx_get_fast_kdf_iter(codec_ctx *ctx) {\n  return ctx->fast_kdf_iter;\n}\n\n/* set the global default flag for HMAC */\nvoid sqlcipher_set_default_use_hmac(int use) {\n  if(use) default_flags |= CIPHER_FLAG_HMAC; \n  else default_flags &= ~CIPHER_FLAG_HMAC; \n}\n\nint sqlcipher_get_default_use_hmac() {\n  return (default_flags & CIPHER_FLAG_HMAC) != 0;\n}\n\nvoid sqlcipher_set_hmac_salt_mask(unsigned char mask) {\n  hmac_salt_mask = mask;\n}\n\nunsigned char sqlcipher_get_hmac_salt_mask() {\n  return hmac_salt_mask;\n}\n\n/* set the codec flag for whether this individual database should be using hmac */\nint sqlcipher_codec_ctx_set_use_hmac(codec_ctx *ctx, int use) {\n  if(use) {\n    sqlcipher_codec_ctx_set_flag(ctx, CIPHER_FLAG_HMAC);\n  } else {\n    sqlcipher_codec_ctx_unset_flag(ctx, CIPHER_FLAG_HMAC);\n  } \n\n  return sqlcipher_codec_ctx_reserve_setup(ctx);\n}\n\nint sqlcipher_codec_ctx_get_use_hmac(codec_ctx *ctx) {\n  return (ctx->flags & CIPHER_FLAG_HMAC) != 0;\n}\n\n/* the length of plaintext header size must be:\n * 1. greater than or equal to zero\n * 2. a multiple of the cipher block size\n * 3. less than the usable size of the first database page\n */\nint sqlcipher_set_default_plaintext_header_size(int size) {\n  default_plaintext_header_sz = size;\n  return SQLITE_OK;\n}\n\nint sqlcipher_codec_ctx_set_plaintext_header_size(codec_ctx *ctx, int size) {\n  if(size >= 0 && (size % ctx->block_sz) == 0 && size < (ctx->page_sz - ctx->reserve_sz)) {\n    ctx->plaintext_header_sz = size;\n    return SQLITE_OK;\n  }\n  return SQLITE_ERROR;\n} \n\nint sqlcipher_get_default_plaintext_header_size() {\n  return default_plaintext_header_sz;\n}\n\nint sqlcipher_codec_ctx_get_plaintext_header_size(codec_ctx *ctx) {\n  return ctx->plaintext_header_sz;\n}\n\n/* manipulate HMAC algorithm */\nint sqlcipher_set_default_hmac_algorithm(int algorithm) {\n  default_hmac_algorithm = algorithm;\n  return SQLITE_OK;\n}\n\nint sqlcipher_codec_ctx_set_hmac_algorithm(codec_ctx *ctx, int algorithm) {\n  ctx->hmac_algorithm = algorithm;\n  return sqlcipher_codec_ctx_reserve_setup(ctx);\n} \n\nint sqlcipher_get_default_hmac_algorithm() {\n  return default_hmac_algorithm;\n}\n\nint sqlcipher_codec_ctx_get_hmac_algorithm(codec_ctx *ctx) {\n  return ctx->hmac_algorithm;\n}\n\n/* manipulate KDF algorithm */\nint sqlcipher_set_default_kdf_algorithm(int algorithm) {\n  default_kdf_algorithm = algorithm;\n  return SQLITE_OK;\n}\n\nint sqlcipher_codec_ctx_set_kdf_algorithm(codec_ctx *ctx, int algorithm) {\n  ctx->kdf_algorithm = algorithm;\n  return SQLITE_OK;\n} \n\nint sqlcipher_get_default_kdf_algorithm() {\n  return default_kdf_algorithm;\n}\n\nint sqlcipher_codec_ctx_get_kdf_algorithm(codec_ctx *ctx) {\n  return ctx->kdf_algorithm;\n}\n\nint sqlcipher_codec_ctx_set_flag(codec_ctx *ctx, unsigned int flag) {\n  ctx->flags |= flag;\n  return SQLITE_OK;\n}\n\nint sqlcipher_codec_ctx_unset_flag(codec_ctx *ctx, unsigned int flag) {\n  ctx->flags &= ~flag;\n  return SQLITE_OK;\n}\n\nint sqlcipher_codec_ctx_get_flag(codec_ctx *ctx, unsigned int flag) {\n  return (ctx->flags & flag) != 0;\n}\n\nvoid sqlcipher_codec_ctx_set_error(codec_ctx *ctx, int error) {\n  CODEC_TRACE(\"sqlcipher_codec_ctx_set_error: ctx=%p, error=%d\\n\", ctx, error);\n  sqlite3pager_error(ctx->pBt->pBt->pPager, error);\n  ctx->pBt->pBt->db->errCode = error;\n}\n\nint sqlcipher_codec_ctx_get_reservesize(codec_ctx *ctx) {\n  return ctx->reserve_sz;\n}\n\nvoid* sqlcipher_codec_ctx_get_data(codec_ctx *ctx) {\n  return ctx->buffer;\n}\n\nstatic int sqlcipher_codec_ctx_init_kdf_salt(codec_ctx *ctx) {\n  sqlite3_file *fd = sqlite3PagerFile(ctx->pBt->pBt->pPager);\n\n  if(!ctx->need_kdf_salt) {\n    return SQLITE_OK; /* don't reload salt when not needed */\n  }\n\n  /* read salt from header, if present, otherwise generate a new random salt */\n  CODEC_TRACE(\"sqlcipher_codec_ctx_init_kdf_salt: obtaining salt\\n\");\n  if(fd == NULL || fd->pMethods == 0 || sqlite3OsRead(fd, ctx->kdf_salt, ctx->kdf_salt_sz, 0) != SQLITE_OK) {\n    CODEC_TRACE(\"sqlcipher_codec_ctx_init_kdf_salt: unable to read salt from file header, generating random\\n\");\n    if(ctx->provider->random(ctx->provider_ctx, ctx->kdf_salt, ctx->kdf_salt_sz) != SQLITE_OK) return SQLITE_ERROR;\n  }\n  ctx->need_kdf_salt = 0;\n  return SQLITE_OK; \n}\n\nint sqlcipher_codec_ctx_set_kdf_salt(codec_ctx *ctx, unsigned char *salt, int size) {\n  if(size >= ctx->kdf_salt_sz) {\n    memcpy(ctx->kdf_salt, salt, ctx->kdf_salt_sz);\n    ctx->need_kdf_salt = 0;\n    return SQLITE_OK;\n  }\n  return SQLITE_ERROR;\n}\n\nint sqlcipher_codec_ctx_get_kdf_salt(codec_ctx *ctx, void** salt) {\n  int rc = SQLITE_OK;\n  if(ctx->need_kdf_salt) {\n    rc = sqlcipher_codec_ctx_init_kdf_salt(ctx);\n  }\n  *salt = ctx->kdf_salt;\n  return rc;\n}\n\nvoid sqlcipher_codec_get_keyspec(codec_ctx *ctx, void **zKey, int *nKey) {\n  *zKey = ctx->read_ctx->keyspec;\n  *nKey = ctx->keyspec_sz;\n}\n\nint sqlcipher_codec_ctx_set_pagesize(codec_ctx *ctx, int size) {\n  if(!((size != 0) && ((size & (size - 1)) == 0)) || size < 512 || size > 65536) {\n    CODEC_TRACE((\"cipher_page_size not a power of 2 and between 512 and 65536 inclusive\\n\"));\n    return SQLITE_ERROR;\n  }\n  /* attempt to free the existing page buffer */\n  sqlcipher_free(ctx->buffer,ctx->page_sz);\n  ctx->page_sz = size;\n\n  /* pre-allocate a page buffer of PageSize bytes. This will\n     be used as a persistent buffer for encryption and decryption \n     operations to avoid overhead of multiple memory allocations*/\n  ctx->buffer = sqlcipher_malloc(size);\n  if(ctx->buffer == NULL) return SQLITE_NOMEM;\n\n  return SQLITE_OK;\n}\n\nint sqlcipher_codec_ctx_get_pagesize(codec_ctx *ctx) {\n  return ctx->page_sz;\n}\n\nvoid sqlcipher_set_default_pagesize(int page_size) {\n  default_page_size = page_size;\n}\n\nint sqlcipher_get_default_pagesize() {\n  return default_page_size;\n}\n\nvoid sqlcipher_set_mem_security(int on) {\n#ifndef OMIT_MEM_SECURITY\n  mem_security_on = on;\n  mem_security_activated = 0;\n#endif\n}\n\nint sqlcipher_get_mem_security() {\n#ifndef OMIT_MEM_SECURITY\n  return mem_security_on && mem_security_activated;\n#else\n  return 0;\n#endif\n}\n\n\nint sqlcipher_codec_ctx_init(codec_ctx **iCtx, Db *pDb, Pager *pPager, const void *zKey, int nKey) {\n  int rc;\n  codec_ctx *ctx;\n\n  CODEC_TRACE(\"sqlcipher_codec_ctx_init: allocating context\\n\");\n\n  *iCtx = sqlcipher_malloc(sizeof(codec_ctx));\n  ctx = *iCtx;\n\n  if(ctx == NULL) return SQLITE_NOMEM;\n\n  ctx->pBt = pDb->pBt; /* assign pointer to database btree structure */\n\n  /* allocate space for salt data. Then read the first 16 bytes \n       directly off the database file. This is the salt for the\n       key derivation function. If we get a short read allocate\n       a new random salt value */\n  CODEC_TRACE(\"sqlcipher_codec_ctx_init: allocating kdf_salt\\n\");\n  ctx->kdf_salt_sz = FILE_HEADER_SZ;\n  ctx->kdf_salt = sqlcipher_malloc(ctx->kdf_salt_sz);\n  if(ctx->kdf_salt == NULL) return SQLITE_NOMEM;\n\n  /* allocate space for separate hmac salt data. We want the\n     HMAC derivation salt to be different than the encryption\n     key derivation salt */\n  CODEC_TRACE(\"sqlcipher_codec_ctx_init: allocating hmac_kdf_salt\\n\");\n  ctx->hmac_kdf_salt = sqlcipher_malloc(ctx->kdf_salt_sz);\n  if(ctx->hmac_kdf_salt == NULL) return SQLITE_NOMEM;\n\n  /* setup default flags */\n  ctx->flags = default_flags;\n\n  /* defer attempt to read KDF salt until first use */\n  ctx->need_kdf_salt = 1;\n\n  /* setup the crypto provider  */\n  CODEC_TRACE(\"sqlcipher_codec_ctx_init: allocating provider\\n\");\n  ctx->provider = (sqlcipher_provider *) sqlcipher_malloc(sizeof(sqlcipher_provider));\n  if(ctx->provider == NULL) return SQLITE_NOMEM;\n\n  /* make a copy of the provider to be used for the duration of the context */\n  CODEC_TRACE_MUTEX(\"sqlcipher_codec_ctx_init: entering sqlcipher provider mutex %p\\n\", sqlcipher_provider_mutex);\n  sqlite3_mutex_enter(sqlcipher_provider_mutex);\n  CODEC_TRACE_MUTEX(\"sqlcipher_codec_ctx_init: entered sqlcipher provider mutex %p\\n\", sqlcipher_provider_mutex);\n\n  memcpy(ctx->provider, default_provider, sizeof(sqlcipher_provider));\n\n  CODEC_TRACE_MUTEX(\"sqlcipher_codec_ctx_init: leaving sqlcipher provider mutex %p\\n\", sqlcipher_provider_mutex);\n  sqlite3_mutex_leave(sqlcipher_provider_mutex);\n  CODEC_TRACE_MUTEX(\"sqlcipher_codec_ctx_init: left sqlcipher provider mutex %p\\n\", sqlcipher_provider_mutex);\n\n  CODEC_TRACE(\"sqlcipher_codec_ctx_init: calling provider ctx_init\\n\");\n  if((rc = ctx->provider->ctx_init(&ctx->provider_ctx)) != SQLITE_OK) return rc;\n\n  ctx->key_sz = ctx->provider->get_key_sz(ctx->provider_ctx);\n  ctx->iv_sz = ctx->provider->get_iv_sz(ctx->provider_ctx);\n  ctx->block_sz = ctx->provider->get_block_sz(ctx->provider_ctx);\n\n  /* establic the size for a hex-formated key specification, containing the \n     raw encryption key and the salt used to generate it format. will be x'hexkey...hexsalt'\n     so oversize by 3 bytes */ \n  ctx->keyspec_sz = ((ctx->key_sz + ctx->kdf_salt_sz) * 2) + 3;\n\n  /*\n     Always overwrite page size and set to the default because the first page of the database\n     in encrypted and thus sqlite can't effectively determine the pagesize. this causes an issue in \n     cases where bytes 16 & 17 of the page header are a power of 2 as reported by John Lehman\n  */\n  CODEC_TRACE(\"sqlcipher_codec_ctx_init: calling sqlcipher_codec_ctx_set_pagesize with %d\\n\", default_page_size);\n  if((rc = sqlcipher_codec_ctx_set_pagesize(ctx, default_page_size)) != SQLITE_OK) return rc;\n\n  /* establish settings for the KDF iterations and fast (HMAC) KDF iterations */\n  CODEC_TRACE(\"sqlcipher_codec_ctx_init: setting default_kdf_iter\\n\");\n  if((rc = sqlcipher_codec_ctx_set_kdf_iter(ctx, default_kdf_iter)) != SQLITE_OK) return rc;\n\n  CODEC_TRACE(\"sqlcipher_codec_ctx_init: setting fast_kdf_iter\\n\");\n  if((rc = sqlcipher_codec_ctx_set_fast_kdf_iter(ctx, FAST_PBKDF2_ITER)) != SQLITE_OK) return rc;\n\n  /* set the default HMAC and KDF algorithms which will determine the reserve size */\n  CODEC_TRACE(\"sqlcipher_codec_ctx_init: calling sqlcipher_codec_ctx_set_hmac_algorithm with %d\\n\", default_hmac_algorithm);\n  if((rc = sqlcipher_codec_ctx_set_hmac_algorithm(ctx, default_hmac_algorithm)) != SQLITE_OK) return rc;\n\n  /* Note that use_hmac is a special case that requires recalculation of page size\n     so we call set_use_hmac to perform setup */\n  CODEC_TRACE(\"sqlcipher_codec_ctx_init: setting use_hmac\\n\");\n  if((rc = sqlcipher_codec_ctx_set_use_hmac(ctx, default_flags & CIPHER_FLAG_HMAC)) != SQLITE_OK) return rc;\n\n  CODEC_TRACE(\"sqlcipher_codec_ctx_init: calling sqlcipher_codec_ctx_set_kdf_algorithm with %d\\n\", default_kdf_algorithm);\n  if((rc = sqlcipher_codec_ctx_set_kdf_algorithm(ctx, default_kdf_algorithm)) != SQLITE_OK) return rc;\n\n  /* setup the default plaintext header size */\n  CODEC_TRACE(\"sqlcipher_codec_ctx_init: calling sqlcipher_codec_ctx_set_plaintext_header_size with %d\\n\", default_plaintext_header_sz);\n  if((rc = sqlcipher_codec_ctx_set_plaintext_header_size(ctx, default_plaintext_header_sz)) != SQLITE_OK) return rc;\n\n  /* initialize the read and write sub-contexts. this must happen after key_sz is established  */\n  CODEC_TRACE(\"sqlcipher_codec_ctx_init: initializing read_ctx\\n\");\n  if((rc = sqlcipher_cipher_ctx_init(ctx, &ctx->read_ctx)) != SQLITE_OK) return rc; \n\n  CODEC_TRACE(\"sqlcipher_codec_ctx_init: initializing write_ctx\\n\");\n  if((rc = sqlcipher_cipher_ctx_init(ctx, &ctx->write_ctx)) != SQLITE_OK) return rc; \n\n  /* set the key material on one of the sub cipher contexts and sync them up */\n  CODEC_TRACE(\"sqlcipher_codec_ctx_init: setting pass key\\n\");\n  if((rc = sqlcipher_codec_ctx_set_pass(ctx, zKey, nKey, 0)) != SQLITE_OK) return rc;\n\n  CODEC_TRACE(\"sqlcipher_codec_ctx_init: copying write_ctx to read_ctx\\n\");\n  if((rc = sqlcipher_cipher_ctx_copy(ctx, ctx->write_ctx, ctx->read_ctx)) != SQLITE_OK) return rc;\n\n  return SQLITE_OK;\n}\n\n/**\n  * Free and wipe memory associated with a cipher_ctx, including the allocated\n  * read_ctx and write_ctx.\n  */\nvoid sqlcipher_codec_ctx_free(codec_ctx **iCtx) {\n  codec_ctx *ctx = *iCtx;\n  CODEC_TRACE(\"codec_ctx_free: entered iCtx=%p\\n\", iCtx);\n  sqlcipher_free(ctx->kdf_salt, ctx->kdf_salt_sz);\n  sqlcipher_free(ctx->hmac_kdf_salt, ctx->kdf_salt_sz);\n  sqlcipher_free(ctx->buffer, 0);\n\n  ctx->provider->ctx_free(&ctx->provider_ctx);\n  sqlcipher_free(ctx->provider, sizeof(sqlcipher_provider)); \n\n  sqlcipher_cipher_ctx_free(ctx, &ctx->read_ctx);\n  sqlcipher_cipher_ctx_free(ctx, &ctx->write_ctx);\n  sqlcipher_free(ctx, sizeof(codec_ctx)); \n}\n\n/** convert a 32bit unsigned integer to little endian byte ordering */\nstatic void sqlcipher_put4byte_le(unsigned char *p, u32 v) { \n  p[0] = (u8)v;\n  p[1] = (u8)(v>>8);\n  p[2] = (u8)(v>>16);\n  p[3] = (u8)(v>>24);\n}\n\nstatic int sqlcipher_page_hmac(codec_ctx *ctx, cipher_ctx *c_ctx, Pgno pgno, unsigned char *in, int in_sz, unsigned char *out) {\n  unsigned char pgno_raw[sizeof(pgno)];\n  /* we may convert page number to consistent representation before calculating MAC for\n     compatibility across big-endian and little-endian platforms. \n\n     Note: The public release of sqlcipher 2.0.0 to 2.0.6 had a bug where the bytes of pgno \n     were used directly in the MAC. SQLCipher convert's to little endian by default to preserve\n     backwards compatibility on the most popular platforms, but can optionally be configured\n     to use either big endian or native byte ordering via pragma. */\n\n  if(ctx->flags & CIPHER_FLAG_LE_PGNO) { /* compute hmac using little endian pgno*/\n    sqlcipher_put4byte_le(pgno_raw, pgno);\n  } else if(ctx->flags & CIPHER_FLAG_BE_PGNO) { /* compute hmac using big endian pgno */\n    sqlite3Put4byte(pgno_raw, pgno); /* sqlite3Put4byte converts 32bit uint to big endian  */\n  } else { /* use native byte ordering */\n    memcpy(pgno_raw, &pgno, sizeof(pgno));\n  }\n\n  /* include the encrypted page data,  initialization vector, and page number in HMAC. This will \n     prevent both tampering with the ciphertext, manipulation of the IV, or resequencing otherwise\n     valid pages out of order in a database */ \n  return ctx->provider->hmac(\n    ctx->provider_ctx, ctx->hmac_algorithm, c_ctx->hmac_key,\n    ctx->key_sz, in,\n    in_sz, (unsigned char*) &pgno_raw,\n    sizeof(pgno), out);\n}\n\n/*\n * ctx - codec context\n * pgno - page number in database\n * size - size in bytes of input and output buffers\n * mode - 1 to encrypt, 0 to decrypt\n * in - pointer to input bytes\n * out - pouter to output bytes\n */\nint sqlcipher_page_cipher(codec_ctx *ctx, int for_ctx, Pgno pgno, int mode, int page_sz, unsigned char *in, unsigned char *out) {\n  cipher_ctx *c_ctx = for_ctx ? ctx->write_ctx : ctx->read_ctx;\n  unsigned char *iv_in, *iv_out, *hmac_in, *hmac_out, *out_start;\n  int size;\n\n  /* calculate some required positions into various buffers */\n  size = page_sz - ctx->reserve_sz; /* adjust size to useable size and memset reserve at end of page */\n  iv_out = out + size;\n  iv_in = in + size;\n\n  /* hmac will be written immediately after the initialization vector. the remainder of the page reserve will contain\n     random bytes. note, these pointers are only valid when using hmac */\n  hmac_in = in + size + ctx->iv_sz; \n  hmac_out = out + size + ctx->iv_sz;\n  out_start = out; /* note the original position of the output buffer pointer, as out will be rewritten during encryption */\n\n  CODEC_TRACE(\"codec_cipher:entered pgno=%d, mode=%d, size=%d\\n\", pgno, mode, size);\n  CODEC_HEXDUMP(\"codec_cipher: input page data\", in, page_sz);\n\n  /* the key size should never be zero. If it is, error out. */\n  if(ctx->key_sz == 0) {\n    CODEC_TRACE(\"codec_cipher: error possible context corruption, key_sz is zero for pgno=%d\\n\", pgno);\n    goto error;\n  } \n\n  if(mode == CIPHER_ENCRYPT) {\n    /* start at front of the reserve block, write random data to the end */\n    if(ctx->provider->random(ctx->provider_ctx, iv_out, ctx->reserve_sz) != SQLITE_OK) goto error;\n  } else { /* CIPHER_DECRYPT */\n    memcpy(iv_out, iv_in, ctx->iv_sz); /* copy the iv from the input to output buffer */\n  } \n\n  if((ctx->flags & CIPHER_FLAG_HMAC) && (mode == CIPHER_DECRYPT) && !ctx->skip_read_hmac) {\n    if(sqlcipher_page_hmac(ctx, c_ctx, pgno, in, size + ctx->iv_sz, hmac_out) != SQLITE_OK) {\n      CODEC_TRACE(\"codec_cipher: hmac operation on decrypt failed for pgno=%d\\n\", pgno);\n      goto error;\n    }\n\n    CODEC_TRACE(\"codec_cipher: comparing hmac on in=%p out=%p hmac_sz=%d\\n\", hmac_in, hmac_out, ctx->hmac_sz);\n    if(sqlcipher_memcmp(hmac_in, hmac_out, ctx->hmac_sz) != 0) { /* the hmac check failed */ \n      if(sqlcipher_ismemset(in, 0, page_sz) == 0) {\n        /* first check if the entire contents of the page is zeros. If so, this page \n           resulted from a short read (i.e. sqlite attempted to pull a page after the end of the file. these \n           short read failures must be ignored for autovaccum mode to work so wipe the output buffer \n           and return SQLITE_OK to skip the decryption step. */\n        CODEC_TRACE(\"codec_cipher: zeroed page (short read) for pgno %d, encryption but returning SQLITE_OK\\n\", pgno);\n        sqlcipher_memset(out, 0, page_sz); \n        return SQLITE_OK;\n      } else {\n        /* if the page memory is not all zeros, it means the there was data and a hmac on the page. \n           since the check failed, the page was either tampered with or corrupted. wipe the output buffer,\n           and return SQLITE_ERROR to the caller */\n        CODEC_TRACE(\"codec_cipher: hmac check failed for pgno=%d returning SQLITE_ERROR\\n\", pgno);\n        goto error;\n      }\n    }\n  } \n  \n  if(ctx->provider->cipher(ctx->provider_ctx, mode, c_ctx->key, ctx->key_sz, iv_out, in, size, out) != SQLITE_OK) {\n    CODEC_TRACE(\"codec_cipher: cipher operation mode=%d failed for pgno=%d returning SQLITE_ERROR\\n\", mode, pgno);\n    goto error;\n  };\n\n  if((ctx->flags & CIPHER_FLAG_HMAC) && (mode == CIPHER_ENCRYPT)) {\n    if(sqlcipher_page_hmac(ctx, c_ctx, pgno, out_start, size + ctx->iv_sz, hmac_out) != SQLITE_OK) {\n      CODEC_TRACE(\"codec_cipher: hmac operation on encrypt failed for pgno=%d\\n\", pgno);\n      goto error;\n    }; \n  }\n\n  CODEC_HEXDUMP(\"codec_cipher: output page data\", out_start, page_sz);\n\n  return SQLITE_OK;\nerror:\n  sqlcipher_memset(out, 0, page_sz); \n  return SQLITE_ERROR;\n}\n\n/**\n  * Derive an encryption key for a cipher contex key based on the raw password.\n  *\n  * If the raw key data is formated as x'hex' and there are exactly enough hex chars to fill\n  * the key (i.e 64 hex chars for a 256 bit key) then the key data will be used directly. \n\n  * Else, if the raw key data is formated as x'hex' and there are exactly enough hex chars to fill\n  * the key and the salt (i.e 92 hex chars for a 256 bit key and 16 byte salt) then it will be unpacked\n  * as the key followed by the salt.\n  * \n  * Otherwise, a key data will be derived using PBKDF2\n  * \n  * returns SQLITE_OK if initialization was successful\n  * returns SQLITE_ERROR if the key could't be derived (for instance if pass is NULL or pass_sz is 0)\n  */\nstatic int sqlcipher_cipher_ctx_key_derive(codec_ctx *ctx, cipher_ctx *c_ctx) {\n  int rc;\n  CODEC_TRACE(\"cipher_ctx_key_derive: entered c_ctx->pass=%s, c_ctx->pass_sz=%d \\\n                ctx->kdf_salt=%p ctx->kdf_salt_sz=%d ctx->kdf_iter=%d \\\n                ctx->hmac_kdf_salt=%p, ctx->fast_kdf_iter=%d ctx->key_sz=%d\\n\",\n                c_ctx->pass, c_ctx->pass_sz, ctx->kdf_salt, ctx->kdf_salt_sz, ctx->kdf_iter,\n                ctx->hmac_kdf_salt, ctx->fast_kdf_iter, ctx->key_sz);\n                \n  \n  if(c_ctx->pass && c_ctx->pass_sz) {  /* if key material is present on the context for derivation */ \n   \n    /* if necessary, initialize the salt from the header or random source */\n    if(ctx->need_kdf_salt) {\n      if((rc = sqlcipher_codec_ctx_init_kdf_salt(ctx)) != SQLITE_OK) return rc;\n    }\n \n    if (c_ctx->pass_sz == ((ctx->key_sz * 2) + 3) && sqlite3StrNICmp((const char *)c_ctx->pass ,\"x'\", 2) == 0 && cipher_isHex(c_ctx->pass + 2, ctx->key_sz * 2)) { \n      int n = c_ctx->pass_sz - 3; /* adjust for leading x' and tailing ' */\n      const unsigned char *z = c_ctx->pass + 2; /* adjust lead offset of x' */\n      CODEC_TRACE(\"cipher_ctx_key_derive: using raw key from hex\\n\");\n      cipher_hex2bin(z, n, c_ctx->key);\n    } else if (c_ctx->pass_sz == (((ctx->key_sz + ctx->kdf_salt_sz) * 2) + 3) && sqlite3StrNICmp((const char *)c_ctx->pass ,\"x'\", 2) == 0 && cipher_isHex(c_ctx->pass + 2, (ctx->key_sz + ctx->kdf_salt_sz) * 2)) { \n      const unsigned char *z = c_ctx->pass + 2; /* adjust lead offset of x' */\n      CODEC_TRACE(\"cipher_ctx_key_derive: using raw key from hex\\n\"); \n      cipher_hex2bin(z, (ctx->key_sz * 2), c_ctx->key);\n      cipher_hex2bin(z + (ctx->key_sz * 2), (ctx->kdf_salt_sz * 2), ctx->kdf_salt);\n    } else { \n      CODEC_TRACE(\"cipher_ctx_key_derive: deriving key using full PBKDF2 with %d iterations\\n\", ctx->kdf_iter);\n      if(ctx->provider->kdf(ctx->provider_ctx, ctx->kdf_algorithm, c_ctx->pass, c_ctx->pass_sz, \n                    ctx->kdf_salt, ctx->kdf_salt_sz, ctx->kdf_iter,\n                    ctx->key_sz, c_ctx->key) != SQLITE_OK) return SQLITE_ERROR;\n    }\n\n    /* set the context \"keyspec\" containing the hex-formatted key and salt to be used when attaching databases */\n    if((rc = sqlcipher_cipher_ctx_set_keyspec(ctx, c_ctx, c_ctx->key)) != SQLITE_OK) return rc;\n\n    /* if this context is setup to use hmac checks, generate a seperate and different \n       key for HMAC. In this case, we use the output of the previous KDF as the input to \n       this KDF run. This ensures a distinct but predictable HMAC key. */\n    if(ctx->flags & CIPHER_FLAG_HMAC) {\n      int i;\n\n      /* start by copying the kdf key into the hmac salt slot\n         then XOR it with the fixed hmac salt defined at compile time\n         this ensures that the salt passed in to derive the hmac key, while \n         easy to derive and publically known, is not the same as the salt used \n         to generate the encryption key */ \n      memcpy(ctx->hmac_kdf_salt, ctx->kdf_salt, ctx->kdf_salt_sz);\n      for(i = 0; i < ctx->kdf_salt_sz; i++) {\n        ctx->hmac_kdf_salt[i] ^= hmac_salt_mask;\n      } \n\n      CODEC_TRACE(\"cipher_ctx_key_derive: deriving hmac key from encryption key using PBKDF2 with %d iterations\\n\", \n        ctx->fast_kdf_iter);\n\n      \n      if(ctx->provider->kdf(ctx->provider_ctx, ctx->kdf_algorithm, c_ctx->key, ctx->key_sz, \n                    ctx->hmac_kdf_salt, ctx->kdf_salt_sz, ctx->fast_kdf_iter,\n                    ctx->key_sz, c_ctx->hmac_key) != SQLITE_OK) return SQLITE_ERROR;\n    }\n\n    c_ctx->derive_key = 0;\n    return SQLITE_OK;\n  };\n  return SQLITE_ERROR;\n}\n\nint sqlcipher_codec_key_derive(codec_ctx *ctx) {\n  /* derive key on first use if necessary */\n  if(ctx->read_ctx->derive_key) {\n    if(sqlcipher_cipher_ctx_key_derive(ctx, ctx->read_ctx) != SQLITE_OK) return SQLITE_ERROR;\n  }\n\n  if(ctx->write_ctx->derive_key) {\n    if(sqlcipher_cipher_ctx_cmp(ctx->write_ctx, ctx->read_ctx) == 0) {\n      /* the relevant parameters are the same, just copy read key */\n      if(sqlcipher_cipher_ctx_copy(ctx, ctx->write_ctx, ctx->read_ctx) != SQLITE_OK) return SQLITE_ERROR;\n    } else {\n      if(sqlcipher_cipher_ctx_key_derive(ctx, ctx->write_ctx) != SQLITE_OK) return SQLITE_ERROR;\n    }\n  }\n\n  /* TODO: wipe and free passphrase after key derivation */\n  if(ctx->store_pass  != 1) {\n    sqlcipher_cipher_ctx_set_pass(ctx->read_ctx, NULL, 0);\n    sqlcipher_cipher_ctx_set_pass(ctx->write_ctx, NULL, 0);\n  }\n\n  return SQLITE_OK; \n}\n\nint sqlcipher_codec_key_copy(codec_ctx *ctx, int source) {\n  if(source == CIPHER_READ_CTX) { \n      return sqlcipher_cipher_ctx_copy(ctx, ctx->write_ctx, ctx->read_ctx); \n  } else {\n      return sqlcipher_cipher_ctx_copy(ctx, ctx->read_ctx, ctx->write_ctx); \n  }\n}\n\nconst char* sqlcipher_codec_get_cipher_provider(codec_ctx *ctx) {\n  return ctx->provider->get_provider_name(ctx->provider_ctx);\n}\n\n\nstatic int sqlcipher_check_connection(const char *filename, char *key, int key_sz, char *sql, int *user_version, char** journal_mode) {\n  int rc;\n  sqlite3 *db = NULL;\n  sqlite3_stmt *statement = NULL;\n  char *query_journal_mode = \"PRAGMA journal_mode;\";\n  char *query_user_version = \"PRAGMA user_version;\";\n \n  rc = sqlite3_open(filename, &db);\n  if(rc != SQLITE_OK) goto cleanup; \n    \n  rc = sqlite3_key(db, key, key_sz);\n  if(rc != SQLITE_OK) goto cleanup; \n    \n  rc = sqlite3_exec(db, sql, NULL, NULL, NULL);\n  if(rc != SQLITE_OK) goto cleanup; \n\n  /* start by querying the user version. \n     this will fail if the key is incorrect */\n  rc = sqlite3_prepare(db, query_user_version, -1, &statement, NULL);\n  if(rc != SQLITE_OK) goto cleanup; \n    \n  rc = sqlite3_step(statement);\n  if(rc == SQLITE_ROW) {\n    *user_version = sqlite3_column_int(statement, 0);\n  } else {\n    goto cleanup;\n  }\n  sqlite3_finalize(statement); \n\n  rc = sqlite3_prepare(db, query_journal_mode, -1, &statement, NULL);\n  if(rc != SQLITE_OK) goto cleanup; \n    \n  rc = sqlite3_step(statement);\n  if(rc == SQLITE_ROW) {\n    *journal_mode = sqlite3_mprintf(\"%s\", sqlite3_column_text(statement, 0)); \n  } else {\n    goto cleanup; \n  }\n  rc = SQLITE_OK;\n  /* cleanup will finalize open statement */\n  \ncleanup:\n  if(statement) sqlite3_finalize(statement); \n  if(db) sqlite3_close(db); \n  return rc;\n}\n\nint sqlcipher_codec_ctx_migrate(codec_ctx *ctx) {\n  int i, pass_sz, keyspec_sz, nRes, user_version, rc, oflags;\n  Db *pDb = 0;\n  sqlite3 *db = ctx->pBt->db;\n  const char *db_filename = sqlite3_db_filename(db, \"main\");\n  char *set_user_version = NULL, *pass = NULL, *attach_command = NULL, *migrated_db_filename = NULL, *keyspec = NULL, *temp = NULL, *journal_mode = NULL, *set_journal_mode = NULL, *pragma_compat = NULL;\n  Btree *pDest = NULL, *pSrc = NULL;\n  const char* commands[5];\n  sqlite3_file *srcfile, *destfile;\n#if defined(_WIN32) || defined(SQLITE_OS_WINRT)\n  LPWSTR w_db_filename = NULL, w_migrated_db_filename = NULL;\n  int w_db_filename_sz = 0, w_migrated_db_filename_sz = 0;\n#endif\n  pass_sz = keyspec_sz = rc = user_version = 0;\n\n  if(!db_filename || sqlite3Strlen30(db_filename) < 1) \n    goto cleanup; /* exit immediately if this is an in memory database */ \n  \n  /* pull the provided password / key material off the current codec context */\n  pass_sz = ctx->read_ctx->pass_sz;\n  pass = sqlcipher_malloc(pass_sz+1);\n  memset(pass, 0, pass_sz+1);\n  memcpy(pass, ctx->read_ctx->pass, pass_sz);\n                                            \n  /* Version 4 - current, no upgrade required, so exit immediately */\n  rc = sqlcipher_check_connection(db_filename, pass, pass_sz, \"\", &user_version, &journal_mode);\n  if(rc == SQLITE_OK){\n    printf(\"No upgrade required - exiting\\n\");\n    goto cleanup;\n  }\n\n  for(i = 3; i > 0; i--) {\n    pragma_compat = sqlite3_mprintf(\"PRAGMA cipher_compatibility = %d;\", i);\n    rc = sqlcipher_check_connection(db_filename, pass, pass_sz, pragma_compat, &user_version, &journal_mode);\n    if(rc == SQLITE_OK) {\n      CODEC_TRACE(\"Version %d format found\\n\", i);\n      goto migrate;\n    }\n    if(pragma_compat) sqlcipher_free(pragma_compat, sqlite3Strlen30(pragma_compat)); \n    pragma_compat = NULL;\n  }\n  /* if we exit the loop normally we failed to determine the version, this is an error */\n  CODEC_TRACE(\"Upgrade format not determined\\n\");\n  goto handle_error;\n\nmigrate:\n\n  temp = sqlite3_mprintf(\"%s-migrated\", db_filename);\n  /* overallocate migrated_db_filename, because sqlite3OsOpen will read past the null terminator\n   * to determine whether the filename was URI formatted */\n  migrated_db_filename = sqlcipher_malloc(sqlite3Strlen30(temp)+2); \n  memcpy(migrated_db_filename, temp, sqlite3Strlen30(temp));\n  sqlcipher_free(temp, sqlite3Strlen30(temp));\n\n  attach_command = sqlite3_mprintf(\"ATTACH DATABASE '%s' as migrate KEY '%q';\", migrated_db_filename, pass); \n  set_user_version = sqlite3_mprintf(\"PRAGMA migrate.user_version = %d;\", user_version);\n\n  commands[0] = pragma_compat;\n  commands[1] = \"PRAGMA journal_mode = delete;\"; /* force journal mode to DELETE, we will set it back later if different */\n  commands[2] = attach_command;\n  commands[3] = \"SELECT sqlcipher_export('migrate');\";\n  commands[4] = set_user_version;\n\n  for(i = 0; i < ArraySize(commands); i++){\n    rc = sqlite3_exec(db, commands[i], NULL, NULL, NULL);\n    if(rc != SQLITE_OK){\n      CODEC_TRACE(\"migration step %d failed error code %d\\n\", i, rc);\n      goto handle_error;\n    }\n  }\n    \n  if( !db->autoCommit ){\n    CODEC_TRACE(\"cannot migrate from within a transaction\");\n    goto handle_error;\n  }\n  if( db->nVdbeActive>1 ){\n    CODEC_TRACE(\"cannot migrate - SQL statements in progress\");\n    goto handle_error;\n  }\n\n  pDest = db->aDb[0].pBt;\n  pDb = &(db->aDb[db->nDb-1]);\n  pSrc = pDb->pBt;\n\n  nRes = sqlite3BtreeGetOptimalReserve(pSrc); \n  /* unset the BTS_PAGESIZE_FIXED flag to avoid SQLITE_READONLY */\n  pDest->pBt->btsFlags &= ~BTS_PAGESIZE_FIXED; \n  rc = sqlite3BtreeSetPageSize(pDest, default_page_size, nRes, 0);\n  CODEC_TRACE(\"set btree page size to %d res %d rc %d\\n\", default_page_size, nRes, rc);\n  if( rc!=SQLITE_OK ) goto handle_error;\n#if defined (SQLCIPHER_PREPROCESSED)\n        extern int sqlite3CodecAttach(sqlite3*, int, const void*, int);\n        extern void sqlite3CodecGetKey(sqlite3*, int, void**, int*);\n#endif /* SQLCIPHER_PREPROCESSED */\n  sqlite3CodecGetKey(db, db->nDb - 1, (void**)&keyspec, &keyspec_sz);\n  sqlite3CodecAttach(db, 0, keyspec, keyspec_sz);\n  \n  srcfile = sqlite3PagerFile(pSrc->pBt->pPager);\n  destfile = sqlite3PagerFile(pDest->pBt->pPager);\n\n  sqlite3OsClose(srcfile);\n  sqlite3OsClose(destfile); \n\n#if defined(_WIN32) || defined(SQLITE_OS_WINRT)\n  CODEC_TRACE(\"performing windows MoveFileExA\\n\");\n\n  w_db_filename_sz = MultiByteToWideChar(CP_UTF8, 0, (LPCCH) db_filename, -1, NULL, 0);\n  w_db_filename = sqlcipher_malloc(w_db_filename_sz * sizeof(wchar_t));\n  w_db_filename_sz = MultiByteToWideChar(CP_UTF8, 0, (LPCCH) db_filename, -1, (const LPWSTR) w_db_filename, w_db_filename_sz);\n\n  w_migrated_db_filename_sz = MultiByteToWideChar(CP_UTF8, 0, (LPCCH) migrated_db_filename, -1, NULL, 0);\n  w_migrated_db_filename = sqlcipher_malloc(w_migrated_db_filename_sz * sizeof(wchar_t));\n  w_migrated_db_filename_sz = MultiByteToWideChar(CP_UTF8, 0, (LPCCH) migrated_db_filename, -1, (const LPWSTR) w_migrated_db_filename, w_migrated_db_filename_sz);\n\n  if(!MoveFileExW(w_migrated_db_filename, w_db_filename, MOVEFILE_REPLACE_EXISTING)) {\n    CODEC_TRACE(\"move error\");\n    rc = SQLITE_ERROR;\n    CODEC_TRACE(\"error occurred while renaming %d\\n\", rc);\n    goto handle_error;\n  }\n#else\n  CODEC_TRACE(\"performing POSIX rename\\n\");\n  if ((rc = rename(migrated_db_filename, db_filename)) != 0) {\n    CODEC_TRACE(\"error occurred while renaming %d\\n\", rc);\n    goto handle_error;\n  }\n#endif    \n  CODEC_TRACE(\"renamed migration database %s to main database %s: %d\\n\", migrated_db_filename, db_filename, rc);\n\n  rc = sqlite3OsOpen(db->pVfs, migrated_db_filename, srcfile, SQLITE_OPEN_READWRITE|SQLITE_OPEN_CREATE|SQLITE_OPEN_MAIN_DB, &oflags);\n  CODEC_TRACE(\"reopened migration database: %d\\n\", rc);\n  if( rc!=SQLITE_OK ) goto handle_error;\n\n  rc = sqlite3OsOpen(db->pVfs, db_filename, destfile, SQLITE_OPEN_READWRITE|SQLITE_OPEN_CREATE|SQLITE_OPEN_MAIN_DB, &oflags);\n  CODEC_TRACE(\"reopened main database: %d\\n\", rc);\n  if( rc!=SQLITE_OK ) goto handle_error;\n\n  sqlite3pager_reset(pDest->pBt->pPager);\n  CODEC_TRACE(\"reset pager\\n\");\n\n  rc = sqlite3_exec(db, \"DETACH DATABASE migrate;\", NULL, NULL, NULL);\n  CODEC_TRACE(\"DETACH DATABASE called %d\\n\", rc);\n  if(rc != SQLITE_OK) goto cleanup; \n\n  rc = sqlite3OsDelete(db->pVfs, migrated_db_filename, 0);\n  CODEC_TRACE(\"deleted migration database: %d\\n\", rc);\n  if( rc!=SQLITE_OK ) goto handle_error;\n\n  sqlite3ResetAllSchemasOfConnection(db);\n  CODEC_TRACE(\"reset all schemas\\n\");\n\n  set_journal_mode = sqlite3_mprintf(\"PRAGMA journal_mode = %s;\", journal_mode);\n  rc = sqlite3_exec(db, set_journal_mode, NULL, NULL, NULL); \n  CODEC_TRACE(\"%s: %d\\n\", set_journal_mode, rc);\n  if( rc!=SQLITE_OK ) goto handle_error;\n\n  goto cleanup;\n\nhandle_error:\n  CODEC_TRACE(\"An error occurred attempting to migrate the database - last error %d\\n\", rc);\n  rc = SQLITE_ERROR;\n\ncleanup:\n  if(pass) sqlcipher_free(pass, pass_sz);\n  if(attach_command) sqlcipher_free(attach_command, sqlite3Strlen30(attach_command)); \n  if(migrated_db_filename) sqlcipher_free(migrated_db_filename, sqlite3Strlen30(migrated_db_filename)); \n  if(set_user_version) sqlcipher_free(set_user_version, sqlite3Strlen30(set_user_version)); \n  if(set_journal_mode) sqlcipher_free(set_journal_mode, sqlite3Strlen30(set_journal_mode)); \n  if(journal_mode) sqlcipher_free(journal_mode, sqlite3Strlen30(journal_mode)); \n  if(pragma_compat) sqlcipher_free(pragma_compat, sqlite3Strlen30(pragma_compat)); \n#if defined(_WIN32) || defined(SQLITE_OS_WINRT)\n  if(w_db_filename) sqlcipher_free(w_db_filename, w_db_filename_sz);\n  if(w_migrated_db_filename) sqlcipher_free(w_migrated_db_filename, w_migrated_db_filename_sz);\n#endif\n  return rc;\n}\n\nint sqlcipher_codec_add_random(codec_ctx *ctx, const char *zRight, int random_sz){\n  const char *suffix = &zRight[random_sz-1];\n  int n = random_sz - 3; /* adjust for leading x' and tailing ' */\n  if (n > 0 &&\n      sqlite3StrNICmp((const char *)zRight ,\"x'\", 2) == 0 &&\n      sqlite3StrNICmp(suffix, \"'\", 1) == 0 &&\n      n % 2 == 0) {\n    int rc = 0;\n    int buffer_sz = n / 2;\n    unsigned char *random;\n    const unsigned char *z = (const unsigned char *)zRight + 2; /* adjust lead offset of x' */\n    CODEC_TRACE(\"sqlcipher_codec_add_random: using raw random blob from hex\\n\");\n    random = sqlcipher_malloc(buffer_sz);\n    memset(random, 0, buffer_sz);\n    cipher_hex2bin(z, n, random);\n    rc = ctx->provider->add_random(ctx->provider_ctx, random, buffer_sz);\n    sqlcipher_free(random, buffer_sz);\n    return rc;\n  }\n  return SQLITE_ERROR;\n}\n\nint sqlcipher_codec_fips_status(codec_ctx *ctx) {\n  return ctx->provider->fips_status(ctx->provider_ctx);\n}\n\nconst char* sqlcipher_codec_get_provider_version(codec_ctx *ctx) {\n  return ctx->provider->get_provider_version(ctx->provider_ctx);\n}\n\nint sqlcipher_codec_hmac_sha1(const codec_ctx *ctx, const unsigned char *hmac_key, int key_sz,\n                         unsigned char* in, int in_sz, unsigned char *in2, int in2_sz,\n                         unsigned char *out) {\n  return ctx->provider->hmac(ctx->provider_ctx, SQLCIPHER_HMAC_SHA1, (unsigned char *)hmac_key, key_sz, in, in_sz, in2, in2_sz, out);\n}\n\n\n#endif\n/* END SQLCIPHER */\n\n/************** End of crypto_impl.c *****************************************/\n/************** Begin file crypto_libtomcrypt.c ******************************/\n/*\n** SQLCipher\n** http://sqlcipher.net\n**\n** Copyright (c) 2008 - 2013, ZETETIC LLC\n** All rights reserved.\n**\n** Redistribution and use in source and binary forms, with or without\n** modification, are permitted provided that the following conditions are met:\n**     * Redistributions of source code must retain the above copyright\n**       notice, this list of conditions and the following disclaimer.\n**     * Redistributions in binary form must reproduce the above copyright\n**       notice, this list of conditions and the following disclaimer in the\n**       documentation and/or other materials provided with the distribution.\n**     * Neither the name of the ZETETIC LLC nor the\n**       names of its contributors may be used to endorse or promote products\n**       derived from this software without specific prior written permission.\n**\n** THIS SOFTWARE IS PROVIDED BY ZETETIC LLC ''AS IS'' AND ANY\n** EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n** DISCLAIMED. IN NO EVENT SHALL ZETETIC LLC BE LIABLE FOR ANY\n** DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n** (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n** LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n** ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n**\n*/\n/* BEGIN SQLCIPHER */\n#ifdef SQLITE_HAS_CODEC\n#ifdef SQLCIPHER_CRYPTO_LIBTOMCRYPT\n/* #include \"sqliteInt.h\" */\n/* #include \"sqlcipher.h\" */\n#include <tomcrypt.h>\n\n#define FORTUNA_MAX_SZ 32\nstatic prng_state prng;\nstatic volatile unsigned int ltc_init = 0;\nstatic volatile unsigned int ltc_ref_count = 0;\nstatic sqlite3_mutex* ltc_rand_mutex = NULL;\n\n#define LTC_CIPHER \"rijndael\"\n\nstatic int sqlcipher_ltc_add_random(void *ctx, void *buffer, int length) {\n  int rc = 0;\n  int data_to_read = length;\n  int block_sz = data_to_read < FORTUNA_MAX_SZ ? data_to_read : FORTUNA_MAX_SZ;\n  const unsigned char * data = (const unsigned char *)buffer;\n#ifndef SQLCIPHER_LTC_NO_MUTEX_RAND\n  sqlite3_mutex_enter(ltc_rand_mutex);\n#endif\n    while(data_to_read > 0){\n      rc = fortuna_add_entropy(data, block_sz, &prng);\n      rc = rc != CRYPT_OK ? SQLITE_ERROR : SQLITE_OK;\n      if(rc != SQLITE_OK){\n        break;\n      }\n      data_to_read -= block_sz;\n      data += block_sz;\n      block_sz = data_to_read < FORTUNA_MAX_SZ ? data_to_read : FORTUNA_MAX_SZ;\n    }\n    fortuna_ready(&prng);\n#ifndef SQLCIPHER_LTC_NO_MUTEX_RAND\n  sqlite3_mutex_leave(ltc_rand_mutex);\n#endif\n  return rc;\n}\n\nstatic int sqlcipher_ltc_activate(void *ctx) {\n  unsigned char random_buffer[FORTUNA_MAX_SZ];\n#ifndef SQLCIPHER_LTC_NO_MUTEX_RAND\n  if(ltc_rand_mutex == NULL){\n    ltc_rand_mutex = sqlite3_mutex_alloc(SQLITE_MUTEX_FAST);\n  }\n  sqlite3_mutex_enter(ltc_rand_mutex);\n#endif\n  sqlcipher_memset(random_buffer, 0, FORTUNA_MAX_SZ);\n  if(ltc_init == 0) {\n    if(register_prng(&fortuna_desc) < 0) return SQLITE_ERROR;\n    if(register_cipher(&rijndael_desc) < 0) return SQLITE_ERROR;\n    if(register_hash(&sha512_desc) < 0) return SQLITE_ERROR;\n    if(register_hash(&sha256_desc) < 0) return SQLITE_ERROR;\n    if(register_hash(&sha1_desc) < 0) return SQLITE_ERROR;\n    if(fortuna_start(&prng) != CRYPT_OK) {\n      return SQLITE_ERROR;\n    }\n    ltc_init = 1;\n  }\n  ltc_ref_count++;\n#ifndef SQLCIPHER_TEST\n  sqlite3_randomness(FORTUNA_MAX_SZ, random_buffer);\n#endif\n#ifndef SQLCIPHER_LTC_NO_MUTEX_RAND\n  sqlite3_mutex_leave(ltc_rand_mutex);\n#endif\n  if(sqlcipher_ltc_add_random(ctx, random_buffer, FORTUNA_MAX_SZ) != SQLITE_OK) {\n    return SQLITE_ERROR;\n  }\n  sqlcipher_memset(random_buffer, 0, FORTUNA_MAX_SZ);\n  return SQLITE_OK;\n}\n\nstatic int sqlcipher_ltc_deactivate(void *ctx) {\n#ifndef SQLCIPHER_LTC_NO_MUTEX_RAND\n  sqlite3_mutex_enter(ltc_rand_mutex);\n#endif\n  ltc_ref_count--;\n  if(ltc_ref_count == 0){\n    fortuna_done(&prng);\n    sqlcipher_memset((void *)&prng, 0, sizeof(prng));\n#ifndef SQLCIPHER_LTC_NO_MUTEX_RAND\n    sqlite3_mutex_leave(ltc_rand_mutex);\n    sqlite3_mutex_free(ltc_rand_mutex);\n    ltc_rand_mutex = NULL;\n#endif\n  }\n#ifndef SQLCIPHER_LTC_NO_MUTEX_RAND\n  else {\n    sqlite3_mutex_leave(ltc_rand_mutex);\n  }\n#endif    \n  return SQLITE_OK;\n}\n\nstatic const char* sqlcipher_ltc_get_provider_name(void *ctx) {\n  return \"libtomcrypt\";\n}\n\nstatic const char* sqlcipher_ltc_get_provider_version(void *ctx) {\n  return SCRYPT;\n}\n\nstatic int sqlcipher_ltc_random(void *ctx, void *buffer, int length) {\n#ifndef SQLCIPHER_LTC_NO_MUTEX_RAND\n  sqlite3_mutex_enter(ltc_rand_mutex);\n#endif\n  fortuna_read(buffer, length, &prng);\n#ifndef SQLCIPHER_LTC_NO_MUTEX_RAND\n  sqlite3_mutex_leave(ltc_rand_mutex);\n#endif\n  return SQLITE_OK;\n}\n\nstatic int sqlcipher_ltc_hmac(void *ctx, int algorithm, unsigned char *hmac_key, int key_sz, unsigned char *in, int in_sz, unsigned char *in2, int in2_sz, unsigned char *out) {\n  int rc, hash_idx;\n  hmac_state hmac;\n  unsigned long outlen;\n  switch(algorithm) {\n    case SQLCIPHER_HMAC_SHA1:\n      hash_idx = find_hash(\"sha1\");\n      break;\n    case SQLCIPHER_HMAC_SHA256:\n      hash_idx = find_hash(\"sha256\");\n      break;\n    case SQLCIPHER_HMAC_SHA512:\n      hash_idx = find_hash(\"sha512\");\n      break;\n    default:\n      return SQLITE_ERROR;\n  }\n\n  if(hash_idx < 0) return SQLITE_ERROR;\n  outlen = hash_descriptor[hash_idx].hashsize;\n\n  if(in == NULL) return SQLITE_ERROR;\n  if((rc = hmac_init(&hmac, hash_idx, hmac_key, key_sz)) != CRYPT_OK) return SQLITE_ERROR;\n  if((rc = hmac_process(&hmac, in, in_sz)) != CRYPT_OK) return SQLITE_ERROR;\n  if(in2 != NULL && (rc = hmac_process(&hmac, in2, in2_sz)) != CRYPT_OK) return SQLITE_ERROR;\n  if((rc = hmac_done(&hmac, out, &outlen)) != CRYPT_OK) return SQLITE_ERROR;\n  return SQLITE_OK;\n}\n\nstatic int sqlcipher_ltc_kdf(void *ctx, int algorithm, const unsigned char *pass, int pass_sz, unsigned char* salt, int salt_sz, int workfactor, int key_sz, unsigned char *key) {\n  int rc, hash_idx;\n  unsigned long outlen = key_sz;\n\n  switch(algorithm) {\n    case SQLCIPHER_HMAC_SHA1:\n      hash_idx = find_hash(\"sha1\");\n      break;\n    case SQLCIPHER_HMAC_SHA256:\n      hash_idx = find_hash(\"sha256\");\n      break;\n    case SQLCIPHER_HMAC_SHA512:\n      hash_idx = find_hash(\"sha512\");\n      break;\n    default:\n      return SQLITE_ERROR;\n  }\n  if(hash_idx < 0) return SQLITE_ERROR;\n\n  if((rc = pkcs_5_alg2(pass, pass_sz, salt, salt_sz,\n                       workfactor, hash_idx, key, &outlen)) != CRYPT_OK) {\n    return SQLITE_ERROR;\n  }\n  return SQLITE_OK;\n}\n\nstatic const char* sqlcipher_ltc_get_cipher(void *ctx) {\n  return \"aes-256-cbc\";\n}\n\nstatic int sqlcipher_ltc_cipher(void *ctx, int mode, unsigned char *key, int key_sz, unsigned char *iv, unsigned char *in, int in_sz, unsigned char *out) {\n  int rc, cipher_idx;\n  symmetric_CBC cbc;\n\n  if((cipher_idx = find_cipher(LTC_CIPHER)) == -1) return SQLITE_ERROR;\n  if((rc = cbc_start(cipher_idx, iv, key, key_sz, 0, &cbc)) != CRYPT_OK) return SQLITE_ERROR;\n  rc = mode == 1 ? cbc_encrypt(in, out, in_sz, &cbc) : cbc_decrypt(in, out, in_sz, &cbc);\n  if(rc != CRYPT_OK) return SQLITE_ERROR;\n  cbc_done(&cbc);\n  return SQLITE_OK;\n}\n\nstatic int sqlcipher_ltc_get_key_sz(void *ctx) {\n  int cipher_idx = find_cipher(LTC_CIPHER);\n  return cipher_descriptor[cipher_idx].max_key_length;\n}\n\nstatic int sqlcipher_ltc_get_iv_sz(void *ctx) {\n  int cipher_idx = find_cipher(LTC_CIPHER);\n  return cipher_descriptor[cipher_idx].block_length;\n}\n\nstatic int sqlcipher_ltc_get_block_sz(void *ctx) {\n  int cipher_idx = find_cipher(LTC_CIPHER);\n  return cipher_descriptor[cipher_idx].block_length;\n}\n\nstatic int sqlcipher_ltc_get_hmac_sz(void *ctx, int algorithm) {\n  int hash_idx;\n  switch(algorithm) {\n    case SQLCIPHER_HMAC_SHA1:\n      hash_idx = find_hash(\"sha1\");\n      break;\n    case SQLCIPHER_HMAC_SHA256:\n      hash_idx = find_hash(\"sha256\");\n      break;\n    case SQLCIPHER_HMAC_SHA512:\n      hash_idx = find_hash(\"sha512\");\n      break;\n    default:\n      return 0;\n  }\n\n  if(hash_idx < 0) return 0;\n\n  return hash_descriptor[hash_idx].hashsize;\n}\n\nstatic int sqlcipher_ltc_ctx_copy(void *target_ctx, void *source_ctx) {\n  return SQLITE_OK;\n}\n\nstatic int sqlcipher_ltc_ctx_cmp(void *c1, void *c2) {\n  return 1;\n}\n\nstatic int sqlcipher_ltc_ctx_init(void **ctx) {\n  sqlcipher_ltc_activate(NULL);\n  return SQLITE_OK;\n}\n\nstatic int sqlcipher_ltc_ctx_free(void **ctx) {\n  sqlcipher_ltc_deactivate(&ctx);\n  return SQLITE_OK;\n}\n\nstatic int sqlcipher_ltc_fips_status(void *ctx) {\n  return 0;\n}\n\nint sqlcipher_ltc_setup(sqlcipher_provider *p) {\n  p->activate = sqlcipher_ltc_activate;\n  p->deactivate = sqlcipher_ltc_deactivate;\n  p->get_provider_name = sqlcipher_ltc_get_provider_name;\n  p->random = sqlcipher_ltc_random;\n  p->hmac = sqlcipher_ltc_hmac;\n  p->kdf = sqlcipher_ltc_kdf;\n  p->cipher = sqlcipher_ltc_cipher;\n  p->get_cipher = sqlcipher_ltc_get_cipher;\n  p->get_key_sz = sqlcipher_ltc_get_key_sz;\n  p->get_iv_sz = sqlcipher_ltc_get_iv_sz;\n  p->get_block_sz = sqlcipher_ltc_get_block_sz;\n  p->get_hmac_sz = sqlcipher_ltc_get_hmac_sz;\n  p->ctx_copy = sqlcipher_ltc_ctx_copy;\n  p->ctx_cmp = sqlcipher_ltc_ctx_cmp;\n  p->ctx_init = sqlcipher_ltc_ctx_init;\n  p->ctx_free = sqlcipher_ltc_ctx_free;\n  p->add_random = sqlcipher_ltc_add_random;\n  p->fips_status = sqlcipher_ltc_fips_status;\n  p->get_provider_version = sqlcipher_ltc_get_provider_version;\n  return SQLITE_OK;\n}\n\n#endif\n#endif\n/* END SQLCIPHER */\n\n/************** End of crypto_libtomcrypt.c **********************************/\n/************** Begin file crypto_openssl.c **********************************/\n/*\n** SQLCipher\n** http://sqlcipher.net\n**\n** Copyright (c) 2008 - 2013, ZETETIC LLC\n** All rights reserved.\n**\n** Redistribution and use in source and binary forms, with or without\n** modification, are permitted provided that the following conditions are met:\n**     * Redistributions of source code must retain the above copyright\n**       notice, this list of conditions and the following disclaimer.\n**     * Redistributions in binary form must reproduce the above copyright\n**       notice, this list of conditions and the following disclaimer in the\n**       documentation and/or other materials provided with the distribution.\n**     * Neither the name of the ZETETIC LLC nor the\n**       names of its contributors may be used to endorse or promote products\n**       derived from this software without specific prior written permission.\n**\n** THIS SOFTWARE IS PROVIDED BY ZETETIC LLC ''AS IS'' AND ANY\n** EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n** DISCLAIMED. IN NO EVENT SHALL ZETETIC LLC BE LIABLE FOR ANY\n** DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n** (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n** LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n** ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n**\n*/\n/* BEGIN SQLCIPHER */\n#ifdef SQLITE_HAS_CODEC\n#ifdef SQLCIPHER_CRYPTO_OPENSSL\n/* #include \"sqliteInt.h\" */\n/* #include \"crypto.h\" */\n/* #include \"sqlcipher.h\" */\n#include <openssl/rand.h>\n#include <openssl/evp.h>\n#include <openssl/hmac.h>\n#include <openssl/err.h>\n\ntypedef struct {\n  EVP_CIPHER *evp_cipher;\n} openssl_ctx;\n\nstatic unsigned int openssl_external_init = 0;\nstatic unsigned int openssl_init_count = 0;\nstatic sqlite3_mutex* openssl_rand_mutex = NULL;\n\n#if (defined(OPENSSL_VERSION_NUMBER) && OPENSSL_VERSION_NUMBER < 0x10100000L) || (defined(LIBRESSL_VERSION_NUMBER) && LIBRESSL_VERSION_NUMBER < 0x20700000L)\nstatic HMAC_CTX *HMAC_CTX_new(void)\n{\n  HMAC_CTX *ctx = OPENSSL_malloc(sizeof(*ctx));\n  if (ctx != NULL) {\n    HMAC_CTX_init(ctx);\n  }\n  return ctx;\n}\n\n/* Per 1.1.0 (https://wiki.openssl.org/index.php/1.1_API_Changes)\n   HMAC_CTX_free should call HMAC_CTX_cleanup, then EVP_MD_CTX_Cleanup.\n   HMAC_CTX_cleanup internally calls EVP_MD_CTX_cleanup so these\n   calls are not needed. */\nstatic void HMAC_CTX_free(HMAC_CTX *ctx)\n{\n  if (ctx != NULL) {\n    HMAC_CTX_cleanup(ctx);\n    OPENSSL_free(ctx);\n  }\n}\n#endif\n\nstatic int sqlcipher_openssl_add_random(void *ctx, void *buffer, int length) {\n#ifndef SQLCIPHER_OPENSSL_NO_MUTEX_RAND\n  CODEC_TRACE_MUTEX(\"sqlcipher_openssl_add_random: entering openssl_rand_mutex %p\\n\", openssl_rand_mutex);\n  sqlite3_mutex_enter(openssl_rand_mutex);\n  CODEC_TRACE_MUTEX(\"sqlcipher_openssl_add_random: entered openssl_rand_mutex %p\\n\", openssl_rand_mutex);\n#endif\n  RAND_add(buffer, length, 0);\n#ifndef SQLCIPHER_OPENSSL_NO_MUTEX_RAND\n  CODEC_TRACE_MUTEX(\"sqlcipher_openssl_add_random: leaving openssl_rand_mutex %p\\n\", openssl_rand_mutex);\n  sqlite3_mutex_leave(openssl_rand_mutex);\n  CODEC_TRACE_MUTEX(\"sqlcipher_openssl_add_random: left openssl_rand_mutex %p\\n\", openssl_rand_mutex);\n#endif\n  return SQLITE_OK;\n}\n\n#define OPENSSL_CIPHER \"aes-256-cbc\"\n\n\n/* activate and initialize sqlcipher. Most importantly, this will automatically\n   intialize OpenSSL's EVP system if it hasn't already be externally. Note that \n   this function may be called multiple times as new codecs are intiialized. \n   Thus it performs some basic counting to ensure that only the last and final\n   sqlcipher_openssl_deactivate() will free the EVP structures. \n*/\nstatic int sqlcipher_openssl_activate(void *ctx) {\n  /* initialize openssl and increment the internal init counter\n     but only if it hasn't been initalized outside of SQLCipher by this program \n     e.g. on startup */\n  CODEC_TRACE_MUTEX(\"sqlcipher_openssl_activate: entering static master mutex\");\n  sqlite3_mutex_enter(sqlite3_mutex_alloc(SQLITE_MUTEX_STATIC_MASTER));\n  CODEC_TRACE_MUTEX(\"sqlcipher_openssl_activate: entered static master mutex\");\n\n  if(openssl_init_count == 0 && EVP_get_cipherbyname(OPENSSL_CIPHER) != NULL) {\n    /* if openssl has not yet been initialized by this library, but \n       a call to get_cipherbyname works, then the openssl library\n       has been initialized externally already. */\n    openssl_external_init = 1;\n  }\n\n#ifdef SQLCIPHER_FIPS\n  if(!FIPS_mode()){\n    if(!FIPS_mode_set(1)){\n      ERR_load_crypto_strings();\n      ERR_print_errors_fp(stderr);\n    }\n  }\n#endif\n\n  if(openssl_init_count == 0 && openssl_external_init == 0)  {\n    /* if the library was not externally initialized, then should be now */\n#if (defined(OPENSSL_VERSION_NUMBER) && OPENSSL_VERSION_NUMBER < 0x10100000L) || (defined(LIBRESSL_VERSION_NUMBER) && LIBRESSL_VERSION_NUMBER < 0x20700000L)\n    OpenSSL_add_all_algorithms();\n#endif\n  } \n\n#ifndef SQLCIPHER_OPENSSL_NO_MUTEX_RAND\n  if(openssl_rand_mutex == NULL) {\n    /* allocate a mutex to guard against concurrent calls to RAND_bytes() */\n    CODEC_TRACE_MUTEX(\"sqlcipher_openssl_activate: allocating openssl_rand_mutex\");\n    openssl_rand_mutex = sqlite3_mutex_alloc(SQLITE_MUTEX_FAST);\n    CODEC_TRACE_MUTEX(\"sqlcipher_openssl_activate: allocated openssl_rand_mutex %p\", openssl_rand_mutex);\n  }\n#endif\n\n  openssl_init_count++; \n  CODEC_TRACE_MUTEX(\"sqlcipher_openssl_activate: leaving static master mutex\");\n  sqlite3_mutex_leave(sqlite3_mutex_alloc(SQLITE_MUTEX_STATIC_MASTER));\n  CODEC_TRACE_MUTEX(\"sqlcipher_openssl_activate: left static master mutex\");\n  return SQLITE_OK;\n}\n\n/* deactivate SQLCipher, most imporantly decremeting the activation count and\n   freeing the EVP structures on the final deactivation to ensure that \n   OpenSSL memory is cleaned up */\nstatic int sqlcipher_openssl_deactivate(void *ctx) {\n  CODEC_TRACE_MUTEX(\"sqlcipher_openssl_deactivate: entering static master mutex\");\n  sqlite3_mutex_enter(sqlite3_mutex_alloc(SQLITE_MUTEX_STATIC_MASTER));\n  CODEC_TRACE_MUTEX(\"sqlcipher_openssl_deactivate: entered static master mutex\");\n  openssl_init_count--;\n\n  if(openssl_init_count == 0) {\n    if(openssl_external_init == 0) {\n    /* if OpenSSL hasn't be initialized externally, and the counter reaches zero \n       after it's decremented, release EVP memory\n       Note: this code will only be reached if OpensSSL_add_all_algorithms()\n       is called by SQLCipher internally. This should prevent SQLCipher from \n       \"cleaning up\" openssl when it was initialized externally by the program */\n#if (defined(OPENSSL_VERSION_NUMBER) && OPENSSL_VERSION_NUMBER < 0x10100000L) || (defined(LIBRESSL_VERSION_NUMBER) && LIBRESSL_VERSION_NUMBER < 0x20700000L)\n      EVP_cleanup();\n#endif\n    } else {\n      openssl_external_init = 0;\n    }\n#ifndef SQLCIPHER_OPENSSL_NO_MUTEX_RAND\n    CODEC_TRACE_MUTEX(\"sqlcipher_openssl_deactivate: freeing openssl_rand_mutex %p\", openssl_rand_mutex);\n    sqlite3_mutex_free(openssl_rand_mutex);\n    CODEC_TRACE_MUTEX(\"sqlcipher_openssl_deactivate: freed openssl_rand_mutex %p\", openssl_rand_mutex);\n    openssl_rand_mutex = NULL;\n#endif\n  }\n  CODEC_TRACE_MUTEX(\"sqlcipher_openssl_deactivate: leaving static master mutex\");\n  sqlite3_mutex_leave(sqlite3_mutex_alloc(SQLITE_MUTEX_STATIC_MASTER));\n  CODEC_TRACE_MUTEX(\"sqlcipher_openssl_deactivate: left static master mutex\");\n  return SQLITE_OK;\n}\n\nstatic const char* sqlcipher_openssl_get_provider_name(void *ctx) {\n  return \"openssl\";\n}\n\nstatic const char* sqlcipher_openssl_get_provider_version(void *ctx) {\n  return OPENSSL_VERSION_TEXT;\n}\n\n/* generate a defined number of random bytes */\nstatic int sqlcipher_openssl_random (void *ctx, void *buffer, int length) {\n  int rc = 0;\n  /* concurrent calls to RAND_bytes can cause a crash under some openssl versions when a \n     naive application doesn't use CRYPTO_set_locking_callback and\n     CRYPTO_THREADID_set_callback to ensure openssl thread safety. \n     This is simple workaround to prevent this common crash\n     but a more proper solution is that applications setup platform-appropriate\n     thread saftey in openssl externally */\n#ifndef SQLCIPHER_OPENSSL_NO_MUTEX_RAND\n  CODEC_TRACE_MUTEX(\"sqlcipher_openssl_random: entering openssl_rand_mutex %p\", openssl_rand_mutex);\n  sqlite3_mutex_enter(openssl_rand_mutex);\n  CODEC_TRACE_MUTEX(\"sqlcipher_openssl_random: entered openssl_rand_mutex %p\", openssl_rand_mutex);\n#endif\n  rc = RAND_bytes((unsigned char *)buffer, length);\n#ifndef SQLCIPHER_OPENSSL_NO_MUTEX_RAND\n  CODEC_TRACE_MUTEX(\"sqlcipher_openssl_random: leaving openssl_rand_mutex %p\", openssl_rand_mutex);\n  sqlite3_mutex_leave(openssl_rand_mutex);\n  CODEC_TRACE_MUTEX(\"sqlcipher_openssl_random: left openssl_rand_mutex %p\", openssl_rand_mutex);\n#endif\n  return (rc == 1) ? SQLITE_OK : SQLITE_ERROR;\n}\n\nstatic int sqlcipher_openssl_hmac(void *ctx, int algorithm, unsigned char *hmac_key, int key_sz, unsigned char *in, int in_sz, unsigned char *in2, int in2_sz, unsigned char *out) {\n  unsigned int outlen;\n  int rc = SQLITE_OK;\n  HMAC_CTX* hctx = NULL;\n\n  if(in == NULL) goto error;\n\n  hctx = HMAC_CTX_new();\n  if(hctx == NULL) goto error;\n\n  switch(algorithm) {\n    case SQLCIPHER_HMAC_SHA1:\n      if(!HMAC_Init_ex(hctx, hmac_key, key_sz, EVP_sha1(), NULL)) goto error;\n      break;\n    case SQLCIPHER_HMAC_SHA256:\n      if(!HMAC_Init_ex(hctx, hmac_key, key_sz, EVP_sha256(), NULL)) goto error;\n      break;\n    case SQLCIPHER_HMAC_SHA512:\n      if(!HMAC_Init_ex(hctx, hmac_key, key_sz, EVP_sha512(), NULL)) goto error;\n      break;\n    default:\n      goto error;\n  }\n\n  if(!HMAC_Update(hctx, in, in_sz)) goto error;\n  if(in2 != NULL) {\n    if(!HMAC_Update(hctx, in2, in2_sz)) goto error;\n  }\n  if(!HMAC_Final(hctx, out, &outlen)) goto error;\n  \n  goto cleanup;\nerror:\n  rc = SQLITE_ERROR;\ncleanup:\n  if(hctx) HMAC_CTX_free(hctx);\n  return rc;\n}\n\nstatic int sqlcipher_openssl_kdf(void *ctx, int algorithm, const unsigned char *pass, int pass_sz, unsigned char* salt, int salt_sz, int workfactor, int key_sz, unsigned char *key) {\n  int rc = SQLITE_OK; \n\n  switch(algorithm) {\n    case SQLCIPHER_HMAC_SHA1:\n      if(!PKCS5_PBKDF2_HMAC((const char *)pass, pass_sz, salt, salt_sz, workfactor, EVP_sha1(), key_sz, key)) goto error;\n      break;\n    case SQLCIPHER_HMAC_SHA256:\n      if(!PKCS5_PBKDF2_HMAC((const char *)pass, pass_sz, salt, salt_sz, workfactor, EVP_sha256(), key_sz, key)) goto error;\n      break;\n    case SQLCIPHER_HMAC_SHA512:\n      if(!PKCS5_PBKDF2_HMAC((const char *)pass, pass_sz, salt, salt_sz, workfactor, EVP_sha512(), key_sz, key)) goto error;\n      break;\n    default:\n      return SQLITE_ERROR;\n  }\n\n  goto cleanup;\nerror:\n  rc = SQLITE_ERROR;\ncleanup:\n  return rc;\n}\n\nstatic int sqlcipher_openssl_cipher(void *ctx, int mode, unsigned char *key, int key_sz, unsigned char *iv, unsigned char *in, int in_sz, unsigned char *out) {\n  int tmp_csz, csz, rc = SQLITE_OK;\n  EVP_CIPHER_CTX* ectx = EVP_CIPHER_CTX_new();\n  if(ectx == NULL) goto error;\n  if(!EVP_CipherInit_ex(ectx, ((openssl_ctx *)ctx)->evp_cipher, NULL, NULL, NULL, mode)) goto error; \n  if(!EVP_CIPHER_CTX_set_padding(ectx, 0)) goto error; /* no padding */\n  if(!EVP_CipherInit_ex(ectx, NULL, NULL, key, iv, mode)) goto error;\n  if(!EVP_CipherUpdate(ectx, out, &tmp_csz, in, in_sz)) goto error;\n  csz = tmp_csz;  \n  out += tmp_csz;\n  if(!EVP_CipherFinal_ex(ectx, out, &tmp_csz)) goto error;\n  csz += tmp_csz;\n  assert(in_sz == csz);\n\n  goto cleanup;\nerror:\n  rc = SQLITE_ERROR;\ncleanup:\n  if(ectx) EVP_CIPHER_CTX_free(ectx);\n  return rc; \n}\n\nstatic const char* sqlcipher_openssl_get_cipher(void *ctx) {\n  return EVP_CIPHER_name(((openssl_ctx *)ctx)->evp_cipher);\n}\n\nstatic int sqlcipher_openssl_get_key_sz(void *ctx) {\n  return EVP_CIPHER_key_length(((openssl_ctx *)ctx)->evp_cipher);\n}\n\nstatic int sqlcipher_openssl_get_iv_sz(void *ctx) {\n  return EVP_CIPHER_iv_length(((openssl_ctx *)ctx)->evp_cipher);\n}\n\nstatic int sqlcipher_openssl_get_block_sz(void *ctx) {\n  return EVP_CIPHER_block_size(((openssl_ctx *)ctx)->evp_cipher);\n}\n\nstatic int sqlcipher_openssl_get_hmac_sz(void *ctx, int algorithm) {\n  switch(algorithm) {\n    case SQLCIPHER_HMAC_SHA1:\n      return EVP_MD_size(EVP_sha1());\n      break;\n    case SQLCIPHER_HMAC_SHA256:\n      return EVP_MD_size(EVP_sha256());\n      break;\n    case SQLCIPHER_HMAC_SHA512:\n      return EVP_MD_size(EVP_sha512());\n      break;\n    default:\n      return 0;\n  }\n}\n\nstatic int sqlcipher_openssl_ctx_copy(void *target_ctx, void *source_ctx) {\n  memcpy(target_ctx, source_ctx, sizeof(openssl_ctx));\n  return SQLITE_OK;\n}\n\nstatic int sqlcipher_openssl_ctx_cmp(void *c1, void *c2) {\n  return ((openssl_ctx *)c1)->evp_cipher == ((openssl_ctx *)c2)->evp_cipher;\n}\n\nstatic int sqlcipher_openssl_ctx_init(void **ctx) {\n  openssl_ctx *o_ctx;\n\n  *ctx = sqlcipher_malloc(sizeof(openssl_ctx));\n  if(*ctx == NULL) return SQLITE_NOMEM;\n  sqlcipher_openssl_activate(*ctx);\n  \n  o_ctx = (openssl_ctx *)*ctx;\n  o_ctx->evp_cipher = (EVP_CIPHER *) EVP_get_cipherbyname(OPENSSL_CIPHER);\n  return o_ctx->evp_cipher != NULL ? SQLITE_OK : SQLITE_ERROR;\n}\n\nstatic int sqlcipher_openssl_ctx_free(void **ctx) {\n  sqlcipher_openssl_deactivate(*ctx);\n  sqlcipher_free(*ctx, sizeof(openssl_ctx));\n  return SQLITE_OK;\n}\n\nstatic int sqlcipher_openssl_fips_status(void *ctx) {\n#ifdef SQLCIPHER_FIPS  \n  return FIPS_mode();\n#else\n  return 0;\n#endif\n}\n\nint sqlcipher_openssl_setup(sqlcipher_provider *p) {\n  p->activate = sqlcipher_openssl_activate;  \n  p->deactivate = sqlcipher_openssl_deactivate;\n  p->get_provider_name = sqlcipher_openssl_get_provider_name;\n  p->random = sqlcipher_openssl_random;\n  p->hmac = sqlcipher_openssl_hmac;\n  p->kdf = sqlcipher_openssl_kdf;\n  p->cipher = sqlcipher_openssl_cipher;\n  p->get_cipher = sqlcipher_openssl_get_cipher;\n  p->get_key_sz = sqlcipher_openssl_get_key_sz;\n  p->get_iv_sz = sqlcipher_openssl_get_iv_sz;\n  p->get_block_sz = sqlcipher_openssl_get_block_sz;\n  p->get_hmac_sz = sqlcipher_openssl_get_hmac_sz;\n  p->ctx_copy = sqlcipher_openssl_ctx_copy;\n  p->ctx_cmp = sqlcipher_openssl_ctx_cmp;\n  p->ctx_init = sqlcipher_openssl_ctx_init;\n  p->ctx_free = sqlcipher_openssl_ctx_free;\n  p->add_random = sqlcipher_openssl_add_random;\n  p->fips_status = sqlcipher_openssl_fips_status;\n  p->get_provider_version = sqlcipher_openssl_get_provider_version;\n  return SQLITE_OK;\n}\n\n#endif\n#endif\n/* END SQLCIPHER */\n\n/************** End of crypto_openssl.c **************************************/\n/************** Begin file crypto_cc.c ***************************************/\n/*\n** SQLCipher\n** http://sqlcipher.net\n**\n** Copyright (c) 2008 - 2013, ZETETIC LLC\n** All rights reserved.\n**\n** Redistribution and use in source and binary forms, with or without\n** modification, are permitted provided that the following conditions are met:\n**     * Redistributions of source code must retain the above copyright\n**       notice, this list of conditions and the following disclaimer.\n**     * Redistributions in binary form must reproduce the above copyright\n**       notice, this list of conditions and the following disclaimer in the\n**       documentation and/or other materials provided with the distribution.\n**     * Neither the name of the ZETETIC LLC nor the\n**       names of its contributors may be used to endorse or promote products\n**       derived from this software without specific prior written permission.\n**\n** THIS SOFTWARE IS PROVIDED BY ZETETIC LLC ''AS IS'' AND ANY\n** EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n** DISCLAIMED. IN NO EVENT SHALL ZETETIC LLC BE LIABLE FOR ANY\n** DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n** (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n** LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n** ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n**\n*/\n/* BEGIN SQLCIPHER */\n#ifdef SQLITE_HAS_CODEC\n#ifdef SQLCIPHER_CRYPTO_CC\n/* #include \"crypto.h\" */\n/* #include \"sqlcipher.h\" */\n#include <CommonCrypto/CommonCrypto.h>\n#include <Security/SecRandom.h>\n#include <CoreFoundation/CoreFoundation.h>\n\nint sqlcipher_cc_setup(sqlcipher_provider *p);\n\nstatic int sqlcipher_cc_add_random(void *ctx, void *buffer, int length) {\n  return SQLITE_OK;\n}\n\n/* generate a defined number of random bytes */\nstatic int sqlcipher_cc_random (void *ctx, void *buffer, int length) {\n  return (SecRandomCopyBytes(kSecRandomDefault, length, (uint8_t *)buffer) == kCCSuccess) ? SQLITE_OK : SQLITE_ERROR;\n}\n\nstatic const char* sqlcipher_cc_get_provider_name(void *ctx) {\n  return \"commoncrypto\";\n}\n\nstatic const char* sqlcipher_cc_get_provider_version(void *ctx) {\n#if TARGET_OS_MAC\n  CFTypeRef version;\n  CFBundleRef bundle = CFBundleGetBundleWithIdentifier(CFSTR(\"com.apple.security\"));\n  if(bundle == NULL) {\n    return \"unknown\";\n  }\n  version = CFBundleGetValueForInfoDictionaryKey(bundle, CFSTR(\"CFBundleShortVersionString\"));\n  return CFStringGetCStringPtr(version, kCFStringEncodingUTF8);\n#else\n  return \"unknown\";\n#endif\n}\n\nstatic int sqlcipher_cc_hmac(void *ctx, int algorithm, unsigned char *hmac_key, int key_sz, unsigned char *in, int in_sz, unsigned char *in2, int in2_sz, unsigned char *out) {\n  CCHmacContext hmac_context;\n  if(in == NULL) return SQLITE_ERROR;\n  switch(algorithm) {\n    case SQLCIPHER_HMAC_SHA1:\n      CCHmacInit(&hmac_context, kCCHmacAlgSHA1, hmac_key, key_sz);\n      break;\n    case SQLCIPHER_HMAC_SHA256:\n      CCHmacInit(&hmac_context, kCCHmacAlgSHA256, hmac_key, key_sz);\n      break;\n    case SQLCIPHER_HMAC_SHA512:\n      CCHmacInit(&hmac_context, kCCHmacAlgSHA512, hmac_key, key_sz);\n      break;\n    default:\n      return SQLITE_ERROR;\n  }\n  CCHmacUpdate(&hmac_context, in, in_sz);\n  if(in2 != NULL) CCHmacUpdate(&hmac_context, in2, in2_sz);\n  CCHmacFinal(&hmac_context, out);\n  return SQLITE_OK; \n}\n\nstatic int sqlcipher_cc_kdf(void *ctx, int algorithm, const unsigned char *pass, int pass_sz, unsigned char* salt, int salt_sz, int workfactor, int key_sz, unsigned char *key) {\n  switch(algorithm) {\n    case SQLCIPHER_HMAC_SHA1:\n      if(CCKeyDerivationPBKDF(kCCPBKDF2, (const char *)pass, pass_sz, salt, salt_sz, kCCPRFHmacAlgSHA1, workfactor, key, key_sz) != kCCSuccess) return SQLITE_ERROR;\n      break;\n    case SQLCIPHER_HMAC_SHA256:\n      if(CCKeyDerivationPBKDF(kCCPBKDF2, (const char *)pass, pass_sz, salt, salt_sz, kCCPRFHmacAlgSHA256, workfactor, key, key_sz) != kCCSuccess) return SQLITE_ERROR;\n      break;\n    case SQLCIPHER_HMAC_SHA512:\n      if(CCKeyDerivationPBKDF(kCCPBKDF2, (const char *)pass, pass_sz, salt, salt_sz, kCCPRFHmacAlgSHA512, workfactor, key, key_sz) != kCCSuccess) return SQLITE_ERROR;\n      break;\n    default:\n      return SQLITE_ERROR;\n  }\n  return SQLITE_OK; \n}\n\nstatic int sqlcipher_cc_cipher(void *ctx, int mode, unsigned char *key, int key_sz, unsigned char *iv, unsigned char *in, int in_sz, unsigned char *out) {\n  CCCryptorRef cryptor;\n  size_t tmp_csz, csz;\n  CCOperation op = mode == CIPHER_ENCRYPT ? kCCEncrypt : kCCDecrypt;\n\n  if(CCCryptorCreate(op, kCCAlgorithmAES128, 0, key, kCCKeySizeAES256, iv, &cryptor) != kCCSuccess) return SQLITE_ERROR;\n  if(CCCryptorUpdate(cryptor, in, in_sz, out, in_sz, &tmp_csz) != kCCSuccess) return SQLITE_ERROR;\n  csz = tmp_csz;\n  out += tmp_csz;\n  if(CCCryptorFinal(cryptor, out, in_sz - csz, &tmp_csz) != kCCSuccess) return SQLITE_ERROR;\n  csz += tmp_csz;\n  if(CCCryptorRelease(cryptor) != kCCSuccess) return SQLITE_ERROR;\n  assert(in_sz == csz);\n\n  return SQLITE_OK; \n}\n\nstatic const char* sqlcipher_cc_get_cipher(void *ctx) {\n  return \"aes-256-cbc\";\n}\n\nstatic int sqlcipher_cc_get_key_sz(void *ctx) {\n  return kCCKeySizeAES256;\n}\n\nstatic int sqlcipher_cc_get_iv_sz(void *ctx) {\n  return kCCBlockSizeAES128;\n}\n\nstatic int sqlcipher_cc_get_block_sz(void *ctx) {\n  return kCCBlockSizeAES128;\n}\n\nstatic int sqlcipher_cc_get_hmac_sz(void *ctx, int algorithm) {\n  switch(algorithm) {\n    case SQLCIPHER_HMAC_SHA1:\n      return CC_SHA1_DIGEST_LENGTH;\n      break;\n    case SQLCIPHER_HMAC_SHA256:\n      return CC_SHA256_DIGEST_LENGTH;\n      break;\n    case SQLCIPHER_HMAC_SHA512:\n      return CC_SHA512_DIGEST_LENGTH;\n      break;\n    default:\n      return 0;\n  }\n}\n\nstatic int sqlcipher_cc_ctx_copy(void *target_ctx, void *source_ctx) {\n  return SQLITE_OK;\n}\n\nstatic int sqlcipher_cc_ctx_cmp(void *c1, void *c2) {\n  return 1; /* always indicate contexts are the same */\n}\n\nstatic int sqlcipher_cc_ctx_init(void **ctx) {\n  return SQLITE_OK;\n}\n\nstatic int sqlcipher_cc_ctx_free(void **ctx) {\n  return SQLITE_OK;\n}\n\nstatic int sqlcipher_cc_fips_status(void *ctx) {\n  return 0;\n}\n\nint sqlcipher_cc_setup(sqlcipher_provider *p) {\n  p->random = sqlcipher_cc_random;\n  p->get_provider_name = sqlcipher_cc_get_provider_name;\n  p->hmac = sqlcipher_cc_hmac;\n  p->kdf = sqlcipher_cc_kdf;\n  p->cipher = sqlcipher_cc_cipher;\n  p->get_cipher = sqlcipher_cc_get_cipher;\n  p->get_key_sz = sqlcipher_cc_get_key_sz;\n  p->get_iv_sz = sqlcipher_cc_get_iv_sz;\n  p->get_block_sz = sqlcipher_cc_get_block_sz;\n  p->get_hmac_sz = sqlcipher_cc_get_hmac_sz;\n  p->ctx_copy = sqlcipher_cc_ctx_copy;\n  p->ctx_cmp = sqlcipher_cc_ctx_cmp;\n  p->ctx_init = sqlcipher_cc_ctx_init;\n  p->ctx_free = sqlcipher_cc_ctx_free;\n  p->add_random = sqlcipher_cc_add_random;\n  p->fips_status = sqlcipher_cc_fips_status;\n  p->get_provider_version = sqlcipher_cc_get_provider_version;\n  return SQLITE_OK;\n}\n\n#endif\n#endif\n/* END SQLCIPHER */\n\n/************** End of crypto_cc.c *******************************************/\n/************** Begin file global.c ******************************************/\n/*\n** 2008 June 13\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n**\n** This file contains definitions of global variables and constants.\n*/\n/* #include \"sqliteInt.h\" */\n\n/* An array to map all upper-case characters into their corresponding\n** lower-case character. \n**\n** SQLite only considers US-ASCII (or EBCDIC) characters.  We do not\n** handle case conversions for the UTF character set since the tables\n** involved are nearly as big or bigger than SQLite itself.\n*/\nSQLITE_PRIVATE const unsigned char sqlite3UpperToLower[] = {\n#ifdef SQLITE_ASCII\n      0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 14, 15, 16, 17,\n     18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,\n     36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53,\n     54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 97, 98, 99,100,101,102,103,\n    104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,\n    122, 91, 92, 93, 94, 95, 96, 97, 98, 99,100,101,102,103,104,105,106,107,\n    108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,\n    126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,\n    144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,\n    162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,\n    180,181,182,183,184,185,186,187,188,189,190,191,192,193,194,195,196,197,\n    198,199,200,201,202,203,204,205,206,207,208,209,210,211,212,213,214,215,\n    216,217,218,219,220,221,222,223,224,225,226,227,228,229,230,231,232,233,\n    234,235,236,237,238,239,240,241,242,243,244,245,246,247,248,249,250,251,\n    252,253,254,255\n#endif\n#ifdef SQLITE_EBCDIC\n      0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 14, 15, /* 0x */\n     16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, /* 1x */\n     32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, /* 2x */\n     48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, /* 3x */\n     64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, /* 4x */\n     80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, /* 5x */\n     96, 97, 98, 99,100,101,102,103,104,105,106,107,108,109,110,111, /* 6x */\n    112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127, /* 7x */\n    128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143, /* 8x */\n    144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159, /* 9x */\n    160,161,162,163,164,165,166,167,168,169,170,171,140,141,142,175, /* Ax */\n    176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191, /* Bx */\n    192,129,130,131,132,133,134,135,136,137,202,203,204,205,206,207, /* Cx */\n    208,145,146,147,148,149,150,151,152,153,218,219,220,221,222,223, /* Dx */\n    224,225,162,163,164,165,166,167,168,169,234,235,236,237,238,239, /* Ex */\n    240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255, /* Fx */\n#endif\n};\n\n/*\n** The following 256 byte lookup table is used to support SQLites built-in\n** equivalents to the following standard library functions:\n**\n**   isspace()                        0x01\n**   isalpha()                        0x02\n**   isdigit()                        0x04\n**   isalnum()                        0x06\n**   isxdigit()                       0x08\n**   toupper()                        0x20\n**   SQLite identifier character      0x40\n**   Quote character                  0x80\n**\n** Bit 0x20 is set if the mapped character requires translation to upper\n** case. i.e. if the character is a lower-case ASCII character.\n** If x is a lower-case ASCII character, then its upper-case equivalent\n** is (x - 0x20). Therefore toupper() can be implemented as:\n**\n**   (x & ~(map[x]&0x20))\n**\n** The equivalent of tolower() is implemented using the sqlite3UpperToLower[]\n** array. tolower() is used more often than toupper() by SQLite.\n**\n** Bit 0x40 is set if the character is non-alphanumeric and can be used in an \n** SQLite identifier.  Identifiers are alphanumerics, \"_\", \"$\", and any\n** non-ASCII UTF character. Hence the test for whether or not a character is\n** part of an identifier is 0x46.\n*/\n#ifdef SQLITE_ASCII\nSQLITE_PRIVATE const unsigned char sqlite3CtypeMap[256] = {\n  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,  /* 00..07    ........ */\n  0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00,  /* 08..0f    ........ */\n  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,  /* 10..17    ........ */\n  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,  /* 18..1f    ........ */\n  0x01, 0x00, 0x80, 0x00, 0x40, 0x00, 0x00, 0x80,  /* 20..27     !\"#$%&' */\n  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,  /* 28..2f    ()*+,-./ */\n  0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c,  /* 30..37    01234567 */\n  0x0c, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,  /* 38..3f    89:;<=>? */\n\n  0x00, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x02,  /* 40..47    @ABCDEFG */\n  0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02,  /* 48..4f    HIJKLMNO */\n  0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02,  /* 50..57    PQRSTUVW */\n  0x02, 0x02, 0x02, 0x80, 0x00, 0x00, 0x00, 0x40,  /* 58..5f    XYZ[\\]^_ */\n  0x80, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x22,  /* 60..67    `abcdefg */\n  0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22,  /* 68..6f    hijklmno */\n  0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22,  /* 70..77    pqrstuvw */\n  0x22, 0x22, 0x22, 0x00, 0x00, 0x00, 0x00, 0x00,  /* 78..7f    xyz{|}~. */\n\n  0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40,  /* 80..87    ........ */\n  0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40,  /* 88..8f    ........ */\n  0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40,  /* 90..97    ........ */\n  0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40,  /* 98..9f    ........ */\n  0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40,  /* a0..a7    ........ */\n  0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40,  /* a8..af    ........ */\n  0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40,  /* b0..b7    ........ */\n  0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40,  /* b8..bf    ........ */\n\n  0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40,  /* c0..c7    ........ */\n  0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40,  /* c8..cf    ........ */\n  0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40,  /* d0..d7    ........ */\n  0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40,  /* d8..df    ........ */\n  0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40,  /* e0..e7    ........ */\n  0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40,  /* e8..ef    ........ */\n  0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40,  /* f0..f7    ........ */\n  0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40   /* f8..ff    ........ */\n};\n#endif\n\n/* EVIDENCE-OF: R-02982-34736 In order to maintain full backwards\n** compatibility for legacy applications, the URI filename capability is\n** disabled by default.\n**\n** EVIDENCE-OF: R-38799-08373 URI filenames can be enabled or disabled\n** using the SQLITE_USE_URI=1 or SQLITE_USE_URI=0 compile-time options.\n**\n** EVIDENCE-OF: R-43642-56306 By default, URI handling is globally\n** disabled. The default value may be changed by compiling with the\n** SQLITE_USE_URI symbol defined.\n**\n** URI filenames are enabled by default if SQLITE_HAS_CODEC is\n** enabled.\n*/\n#ifndef SQLITE_USE_URI\n# ifdef SQLITE_HAS_CODEC\n#  define SQLITE_USE_URI 1\n# else\n#  define SQLITE_USE_URI 0\n# endif\n#endif\n\n/* EVIDENCE-OF: R-38720-18127 The default setting is determined by the\n** SQLITE_ALLOW_COVERING_INDEX_SCAN compile-time option, or is \"on\" if\n** that compile-time option is omitted.\n*/\n#ifndef SQLITE_ALLOW_COVERING_INDEX_SCAN\n# define SQLITE_ALLOW_COVERING_INDEX_SCAN 1\n#endif\n\n/* The minimum PMA size is set to this value multiplied by the database\n** page size in bytes.\n*/\n#ifndef SQLITE_SORTER_PMASZ\n# define SQLITE_SORTER_PMASZ 250\n#endif\n\n/* Statement journals spill to disk when their size exceeds the following\n** threshold (in bytes). 0 means that statement journals are created and\n** written to disk immediately (the default behavior for SQLite versions\n** before 3.12.0).  -1 means always keep the entire statement journal in\n** memory.  (The statement journal is also always held entirely in memory\n** if journal_mode=MEMORY or if temp_store=MEMORY, regardless of this\n** setting.)\n*/\n#ifndef SQLITE_STMTJRNL_SPILL \n# define SQLITE_STMTJRNL_SPILL (64*1024)\n#endif\n\n/*\n** The default lookaside-configuration, the format \"SZ,N\".  SZ is the\n** number of bytes in each lookaside slot (should be a multiple of 8)\n** and N is the number of slots.  The lookaside-configuration can be\n** changed as start-time using sqlite3_config(SQLITE_CONFIG_LOOKASIDE)\n** or at run-time for an individual database connection using\n** sqlite3_db_config(db, SQLITE_DBCONFIG_LOOKASIDE);\n*/\n#ifndef SQLITE_DEFAULT_LOOKASIDE\n# define SQLITE_DEFAULT_LOOKASIDE 1200,100\n#endif\n\n\n/* The default maximum size of an in-memory database created using\n** sqlite3_deserialize()\n*/\n#ifndef SQLITE_MEMDB_DEFAULT_MAXSIZE\n# define SQLITE_MEMDB_DEFAULT_MAXSIZE 1073741824\n#endif\n\n/*\n** The following singleton contains the global configuration for\n** the SQLite library.\n*/\nSQLITE_PRIVATE SQLITE_WSD struct Sqlite3Config sqlite3Config = {\n   SQLITE_DEFAULT_MEMSTATUS,  /* bMemstat */\n   1,                         /* bCoreMutex */\n   SQLITE_THREADSAFE==1,      /* bFullMutex */\n   SQLITE_USE_URI,            /* bOpenUri */\n   SQLITE_ALLOW_COVERING_INDEX_SCAN,   /* bUseCis */\n   0,                         /* bSmallMalloc */\n   0x7ffffffe,                /* mxStrlen */\n   0,                         /* neverCorrupt */\n   SQLITE_DEFAULT_LOOKASIDE,  /* szLookaside, nLookaside */\n   SQLITE_STMTJRNL_SPILL,     /* nStmtSpill */\n   {0,0,0,0,0,0,0,0},         /* m */\n   {0,0,0,0,0,0,0,0,0},       /* mutex */\n   {0,0,0,0,0,0,0,0,0,0,0,0,0},/* pcache2 */\n   (void*)0,                  /* pHeap */\n   0,                         /* nHeap */\n   0, 0,                      /* mnHeap, mxHeap */\n   SQLITE_DEFAULT_MMAP_SIZE,  /* szMmap */\n   SQLITE_MAX_MMAP_SIZE,      /* mxMmap */\n   (void*)0,                  /* pPage */\n   0,                         /* szPage */\n   SQLITE_DEFAULT_PCACHE_INITSZ, /* nPage */\n   0,                         /* mxParserStack */\n   0,                         /* sharedCacheEnabled */\n   SQLITE_SORTER_PMASZ,       /* szPma */\n   /* All the rest should always be initialized to zero */\n   0,                         /* isInit */\n   0,                         /* inProgress */\n   0,                         /* isMutexInit */\n   0,                         /* isMallocInit */\n   0,                         /* isPCacheInit */\n   0,                         /* nRefInitMutex */\n   0,                         /* pInitMutex */\n   0,                         /* xLog */\n   0,                         /* pLogArg */\n#ifdef SQLITE_ENABLE_SQLLOG\n   0,                         /* xSqllog */\n   0,                         /* pSqllogArg */\n#endif\n#ifdef SQLITE_VDBE_COVERAGE\n   0,                         /* xVdbeBranch */\n   0,                         /* pVbeBranchArg */\n#endif\n#ifdef SQLITE_ENABLE_DESERIALIZE\n   SQLITE_MEMDB_DEFAULT_MAXSIZE,   /* mxMemdbSize */\n#endif\n#ifndef SQLITE_UNTESTABLE\n   0,                         /* xTestCallback */\n#endif\n   0,                         /* bLocaltimeFault */\n   0,                         /* bInternalFunctions */\n   0x7ffffffe,                /* iOnceResetThreshold */\n   SQLITE_DEFAULT_SORTERREF_SIZE,   /* szSorterRef */\n};\n\n/*\n** Hash table for global functions - functions common to all\n** database connections.  After initialization, this table is\n** read-only.\n*/\nSQLITE_PRIVATE FuncDefHash sqlite3BuiltinFunctions;\n\n/*\n** Constant tokens for values 0 and 1.\n*/\nSQLITE_PRIVATE const Token sqlite3IntTokens[] = {\n   { \"0\", 1 },\n   { \"1\", 1 }\n};\n\n#ifdef VDBE_PROFILE\n/*\n** The following performance counter can be used in place of\n** sqlite3Hwtime() for profiling.  This is a no-op on standard builds.\n*/\nSQLITE_PRIVATE sqlite3_uint64 sqlite3NProfileCnt = 0;\n#endif\n\n/*\n** The value of the \"pending\" byte must be 0x40000000 (1 byte past the\n** 1-gibabyte boundary) in a compatible database.  SQLite never uses\n** the database page that contains the pending byte.  It never attempts\n** to read or write that page.  The pending byte page is set aside\n** for use by the VFS layers as space for managing file locks.\n**\n** During testing, it is often desirable to move the pending byte to\n** a different position in the file.  This allows code that has to\n** deal with the pending byte to run on files that are much smaller\n** than 1 GiB.  The sqlite3_test_control() interface can be used to\n** move the pending byte.\n**\n** IMPORTANT:  Changing the pending byte to any value other than\n** 0x40000000 results in an incompatible database file format!\n** Changing the pending byte during operation will result in undefined\n** and incorrect behavior.\n*/\n#ifndef SQLITE_OMIT_WSD\nSQLITE_PRIVATE int sqlite3PendingByte = 0x40000000;\n#endif\n\n/* #include \"opcodes.h\" */\n/*\n** Properties of opcodes.  The OPFLG_INITIALIZER macro is\n** created by mkopcodeh.awk during compilation.  Data is obtained\n** from the comments following the \"case OP_xxxx:\" statements in\n** the vdbe.c file.  \n*/\nSQLITE_PRIVATE const unsigned char sqlite3OpcodeProperty[] = OPFLG_INITIALIZER;\n\n/*\n** Name of the default collating sequence\n*/\nSQLITE_PRIVATE const char sqlite3StrBINARY[] = \"BINARY\";\n\n/************** End of global.c **********************************************/\n/************** Begin file status.c ******************************************/\n/*\n** 2008 June 18\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n**\n** This module implements the sqlite3_status() interface and related\n** functionality.\n*/\n/* #include \"sqliteInt.h\" */\n/************** Include vdbeInt.h in the middle of status.c ******************/\n/************** Begin file vdbeInt.h *****************************************/\n/*\n** 2003 September 6\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This is the header file for information that is private to the\n** VDBE.  This information used to all be at the top of the single\n** source code file \"vdbe.c\".  When that file became too big (over\n** 6000 lines long) it was split up into several smaller files and\n** this header information was factored out.\n*/\n#ifndef SQLITE_VDBEINT_H\n#define SQLITE_VDBEINT_H\n\n/*\n** The maximum number of times that a statement will try to reparse\n** itself before giving up and returning SQLITE_SCHEMA.\n*/\n#ifndef SQLITE_MAX_SCHEMA_RETRY\n# define SQLITE_MAX_SCHEMA_RETRY 50\n#endif\n\n/*\n** VDBE_DISPLAY_P4 is true or false depending on whether or not the\n** \"explain\" P4 display logic is enabled.\n*/\n#if !defined(SQLITE_OMIT_EXPLAIN) || !defined(NDEBUG) \\\n     || defined(VDBE_PROFILE) || defined(SQLITE_DEBUG)\n# define VDBE_DISPLAY_P4 1\n#else\n# define VDBE_DISPLAY_P4 0\n#endif\n\n/*\n** SQL is translated into a sequence of instructions to be\n** executed by a virtual machine.  Each instruction is an instance\n** of the following structure.\n*/\ntypedef struct VdbeOp Op;\n\n/*\n** Boolean values\n*/\ntypedef unsigned Bool;\n\n/* Opaque type used by code in vdbesort.c */\ntypedef struct VdbeSorter VdbeSorter;\n\n/* Elements of the linked list at Vdbe.pAuxData */\ntypedef struct AuxData AuxData;\n\n/* Types of VDBE cursors */\n#define CURTYPE_BTREE       0\n#define CURTYPE_SORTER      1\n#define CURTYPE_VTAB        2\n#define CURTYPE_PSEUDO      3\n\n/*\n** A VdbeCursor is an superclass (a wrapper) for various cursor objects:\n**\n**      * A b-tree cursor\n**          -  In the main database or in an ephemeral database\n**          -  On either an index or a table\n**      * A sorter\n**      * A virtual table\n**      * A one-row \"pseudotable\" stored in a single register\n*/\ntypedef struct VdbeCursor VdbeCursor;\nstruct VdbeCursor {\n  u8 eCurType;            /* One of the CURTYPE_* values above */\n  i8 iDb;                 /* Index of cursor database in db->aDb[] (or -1) */\n  u8 nullRow;             /* True if pointing to a row with no data */\n  u8 deferredMoveto;      /* A call to sqlite3BtreeMoveto() is needed */\n  u8 isTable;             /* True for rowid tables.  False for indexes */\n#ifdef SQLITE_DEBUG\n  u8 seekOp;              /* Most recent seek operation on this cursor */\n  u8 wrFlag;              /* The wrFlag argument to sqlite3BtreeCursor() */\n#endif\n  Bool isEphemeral:1;     /* True for an ephemeral table */\n  Bool useRandomRowid:1;  /* Generate new record numbers semi-randomly */\n  Bool isOrdered:1;       /* True if the table is not BTREE_UNORDERED */\n  Bool seekHit:1;         /* See the OP_SeekHit and OP_IfNoHope opcodes */\n  Btree *pBtx;            /* Separate file holding temporary table */\n  i64 seqCount;           /* Sequence counter */\n  int *aAltMap;           /* Mapping from table to index column numbers */\n\n  /* Cached OP_Column parse information is only valid if cacheStatus matches\n  ** Vdbe.cacheCtr.  Vdbe.cacheCtr will never take on the value of\n  ** CACHE_STALE (0) and so setting cacheStatus=CACHE_STALE guarantees that\n  ** the cache is out of date. */\n  u32 cacheStatus;        /* Cache is valid if this matches Vdbe.cacheCtr */\n  int seekResult;         /* Result of previous sqlite3BtreeMoveto() or 0\n                          ** if there have been no prior seeks on the cursor. */\n  /* seekResult does not distinguish between \"no seeks have ever occurred\n  ** on this cursor\" and \"the most recent seek was an exact match\".\n  ** For CURTYPE_PSEUDO, seekResult is the register holding the record */\n\n  /* When a new VdbeCursor is allocated, only the fields above are zeroed.\n  ** The fields that follow are uninitialized, and must be individually\n  ** initialized prior to first use. */\n  VdbeCursor *pAltCursor; /* Associated index cursor from which to read */\n  union {\n    BtCursor *pCursor;          /* CURTYPE_BTREE or _PSEUDO.  Btree cursor */\n    sqlite3_vtab_cursor *pVCur; /* CURTYPE_VTAB.              Vtab cursor */\n    VdbeSorter *pSorter;        /* CURTYPE_SORTER.            Sorter object */\n  } uc;\n  KeyInfo *pKeyInfo;      /* Info about index keys needed by index cursors */\n  u32 iHdrOffset;         /* Offset to next unparsed byte of the header */\n  Pgno pgnoRoot;          /* Root page of the open btree cursor */\n  i16 nField;             /* Number of fields in the header */\n  u16 nHdrParsed;         /* Number of header fields parsed so far */\n  i64 movetoTarget;       /* Argument to the deferred sqlite3BtreeMoveto() */\n  u32 *aOffset;           /* Pointer to aType[nField] */\n  const u8 *aRow;         /* Data for the current row, if all on one page */\n  u32 payloadSize;        /* Total number of bytes in the record */\n  u32 szRow;              /* Byte available in aRow */\n#ifdef SQLITE_ENABLE_COLUMN_USED_MASK\n  u64 maskUsed;           /* Mask of columns used by this cursor */\n#endif\n\n  /* 2*nField extra array elements allocated for aType[], beyond the one\n  ** static element declared in the structure.  nField total array slots for\n  ** aType[] and nField+1 array slots for aOffset[] */\n  u32 aType[1];           /* Type values record decode.  MUST BE LAST */\n};\n\n\n/*\n** A value for VdbeCursor.cacheStatus that means the cache is always invalid.\n*/\n#define CACHE_STALE 0\n\n/*\n** When a sub-program is executed (OP_Program), a structure of this type\n** is allocated to store the current value of the program counter, as\n** well as the current memory cell array and various other frame specific\n** values stored in the Vdbe struct. When the sub-program is finished, \n** these values are copied back to the Vdbe from the VdbeFrame structure,\n** restoring the state of the VM to as it was before the sub-program\n** began executing.\n**\n** The memory for a VdbeFrame object is allocated and managed by a memory\n** cell in the parent (calling) frame. When the memory cell is deleted or\n** overwritten, the VdbeFrame object is not freed immediately. Instead, it\n** is linked into the Vdbe.pDelFrame list. The contents of the Vdbe.pDelFrame\n** list is deleted when the VM is reset in VdbeHalt(). The reason for doing\n** this instead of deleting the VdbeFrame immediately is to avoid recursive\n** calls to sqlite3VdbeMemRelease() when the memory cells belonging to the\n** child frame are released.\n**\n** The currently executing frame is stored in Vdbe.pFrame. Vdbe.pFrame is\n** set to NULL if the currently executing frame is the main program.\n*/\ntypedef struct VdbeFrame VdbeFrame;\nstruct VdbeFrame {\n  Vdbe *v;                /* VM this frame belongs to */\n  VdbeFrame *pParent;     /* Parent of this frame, or NULL if parent is main */\n  Op *aOp;                /* Program instructions for parent frame */\n  i64 *anExec;            /* Event counters from parent frame */\n  Mem *aMem;              /* Array of memory cells for parent frame */\n  VdbeCursor **apCsr;     /* Array of Vdbe cursors for parent frame */\n  u8 *aOnce;              /* Bitmask used by OP_Once */\n  void *token;            /* Copy of SubProgram.token */\n  i64 lastRowid;          /* Last insert rowid (sqlite3.lastRowid) */\n  AuxData *pAuxData;      /* Linked list of auxdata allocations */\n#if SQLITE_DEBUG\n  u32 iFrameMagic;        /* magic number for sanity checking */\n#endif\n  int nCursor;            /* Number of entries in apCsr */\n  int pc;                 /* Program Counter in parent (calling) frame */\n  int nOp;                /* Size of aOp array */\n  int nMem;               /* Number of entries in aMem */\n  int nChildMem;          /* Number of memory cells for child frame */\n  int nChildCsr;          /* Number of cursors for child frame */\n  int nChange;            /* Statement changes (Vdbe.nChange)     */\n  int nDbChange;          /* Value of db->nChange */\n};\n\n/* Magic number for sanity checking on VdbeFrame objects */\n#define SQLITE_FRAME_MAGIC 0x879fb71e\n\n/*\n** Return a pointer to the array of registers allocated for use\n** by a VdbeFrame.\n*/\n#define VdbeFrameMem(p) ((Mem *)&((u8 *)p)[ROUND8(sizeof(VdbeFrame))])\n\n/*\n** Internally, the vdbe manipulates nearly all SQL values as Mem\n** structures. Each Mem struct may cache multiple representations (string,\n** integer etc.) of the same value.\n*/\nstruct sqlite3_value {\n  union MemValue {\n    double r;           /* Real value used when MEM_Real is set in flags */\n    i64 i;              /* Integer value used when MEM_Int is set in flags */\n    int nZero;          /* Extra zero bytes when MEM_Zero and MEM_Blob set */\n    const char *zPType; /* Pointer type when MEM_Term|MEM_Subtype|MEM_Null */\n    FuncDef *pDef;      /* Used only when flags==MEM_Agg */\n  } u;\n  u16 flags;          /* Some combination of MEM_Null, MEM_Str, MEM_Dyn, etc. */\n  u8  enc;            /* SQLITE_UTF8, SQLITE_UTF16BE, SQLITE_UTF16LE */\n  u8  eSubtype;       /* Subtype for this value */\n  int n;              /* Number of characters in string value, excluding '\\0' */\n  char *z;            /* String or BLOB value */\n  /* ShallowCopy only needs to copy the information above */\n  char *zMalloc;      /* Space to hold MEM_Str or MEM_Blob if szMalloc>0 */\n  int szMalloc;       /* Size of the zMalloc allocation */\n  u32 uTemp;          /* Transient storage for serial_type in OP_MakeRecord */\n  sqlite3 *db;        /* The associated database connection */\n  void (*xDel)(void*);/* Destructor for Mem.z - only valid if MEM_Dyn */\n#ifdef SQLITE_DEBUG\n  Mem *pScopyFrom;    /* This Mem is a shallow copy of pScopyFrom */\n  u16 mScopyFlags;    /* flags value immediately after the shallow copy */\n#endif\n};\n\n/*\n** Size of struct Mem not including the Mem.zMalloc member or anything that\n** follows.\n*/\n#define MEMCELLSIZE offsetof(Mem,zMalloc)\n\n/* One or more of the following flags are set to indicate the validOK\n** representations of the value stored in the Mem struct.\n**\n** If the MEM_Null flag is set, then the value is an SQL NULL value.\n** For a pointer type created using sqlite3_bind_pointer() or\n** sqlite3_result_pointer() the MEM_Term and MEM_Subtype flags are also set.\n**\n** If the MEM_Str flag is set then Mem.z points at a string representation.\n** Usually this is encoded in the same unicode encoding as the main\n** database (see below for exceptions). If the MEM_Term flag is also\n** set, then the string is nul terminated. The MEM_Int and MEM_Real \n** flags may coexist with the MEM_Str flag.\n*/\n#define MEM_Null      0x0001   /* Value is NULL (or a pointer) */\n#define MEM_Str       0x0002   /* Value is a string */\n#define MEM_Int       0x0004   /* Value is an integer */\n#define MEM_Real      0x0008   /* Value is a real number */\n#define MEM_Blob      0x0010   /* Value is a BLOB */\n#define MEM_AffMask   0x001f   /* Mask of affinity bits */\n/* Available          0x0020   */\n/* Available          0x0040   */\n#define MEM_Undefined 0x0080   /* Value is undefined */\n#define MEM_Cleared   0x0100   /* NULL set by OP_Null, not from data */\n#define MEM_TypeMask  0xc1ff   /* Mask of type bits */\n\n\n/* Whenever Mem contains a valid string or blob representation, one of\n** the following flags must be set to determine the memory management\n** policy for Mem.z.  The MEM_Term flag tells us whether or not the\n** string is \\000 or \\u0000 terminated\n*/\n#define MEM_Term      0x0200   /* String in Mem.z is zero terminated */\n#define MEM_Dyn       0x0400   /* Need to call Mem.xDel() on Mem.z */\n#define MEM_Static    0x0800   /* Mem.z points to a static string */\n#define MEM_Ephem     0x1000   /* Mem.z points to an ephemeral string */\n#define MEM_Agg       0x2000   /* Mem.z points to an agg function context */\n#define MEM_Zero      0x4000   /* Mem.i contains count of 0s appended to blob */\n#define MEM_Subtype   0x8000   /* Mem.eSubtype is valid */\n#ifdef SQLITE_OMIT_INCRBLOB\n  #undef MEM_Zero\n  #define MEM_Zero 0x0000\n#endif\n\n/* Return TRUE if Mem X contains dynamically allocated content - anything\n** that needs to be deallocated to avoid a leak.\n*/\n#define VdbeMemDynamic(X)  \\\n  (((X)->flags&(MEM_Agg|MEM_Dyn))!=0)\n\n/*\n** Clear any existing type flags from a Mem and replace them with f\n*/\n#define MemSetTypeFlag(p, f) \\\n   ((p)->flags = ((p)->flags&~(MEM_TypeMask|MEM_Zero))|f)\n\n/*\n** Return true if a memory cell is not marked as invalid.  This macro\n** is for use inside assert() statements only.\n*/\n#ifdef SQLITE_DEBUG\n#define memIsValid(M)  ((M)->flags & MEM_Undefined)==0\n#endif\n\n/*\n** Each auxiliary data pointer stored by a user defined function \n** implementation calling sqlite3_set_auxdata() is stored in an instance\n** of this structure. All such structures associated with a single VM\n** are stored in a linked list headed at Vdbe.pAuxData. All are destroyed\n** when the VM is halted (if not before).\n*/\nstruct AuxData {\n  int iAuxOp;                     /* Instruction number of OP_Function opcode */\n  int iAuxArg;                    /* Index of function argument. */\n  void *pAux;                     /* Aux data pointer */\n  void (*xDeleteAux)(void*);      /* Destructor for the aux data */\n  AuxData *pNextAux;              /* Next element in list */\n};\n\n/*\n** The \"context\" argument for an installable function.  A pointer to an\n** instance of this structure is the first argument to the routines used\n** implement the SQL functions.\n**\n** There is a typedef for this structure in sqlite.h.  So all routines,\n** even the public interface to SQLite, can use a pointer to this structure.\n** But this file is the only place where the internal details of this\n** structure are known.\n**\n** This structure is defined inside of vdbeInt.h because it uses substructures\n** (Mem) which are only defined there.\n*/\nstruct sqlite3_context {\n  Mem *pOut;              /* The return value is stored here */\n  FuncDef *pFunc;         /* Pointer to function information */\n  Mem *pMem;              /* Memory cell used to store aggregate context */\n  Vdbe *pVdbe;            /* The VM that owns this context */\n  int iOp;                /* Instruction number of OP_Function */\n  int isError;            /* Error code returned by the function. */\n  u8 skipFlag;            /* Skip accumulator loading if true */\n  u8 argc;                /* Number of arguments */\n  sqlite3_value *argv[1]; /* Argument set */\n};\n\n/* A bitfield type for use inside of structures.  Always follow with :N where\n** N is the number of bits.\n*/\ntypedef unsigned bft;  /* Bit Field Type */\n\n/* The ScanStatus object holds a single value for the\n** sqlite3_stmt_scanstatus() interface.\n*/\ntypedef struct ScanStatus ScanStatus;\nstruct ScanStatus {\n  int addrExplain;                /* OP_Explain for loop */\n  int addrLoop;                   /* Address of \"loops\" counter */\n  int addrVisit;                  /* Address of \"rows visited\" counter */\n  int iSelectID;                  /* The \"Select-ID\" for this loop */\n  LogEst nEst;                    /* Estimated output rows per loop */\n  char *zName;                    /* Name of table or index */\n};\n\n/* The DblquoteStr object holds the text of a double-quoted\n** string for a prepared statement.  A linked list of these objects\n** is constructed during statement parsing and is held on Vdbe.pDblStr.\n** When computing a normalized SQL statement for an SQL statement, that\n** list is consulted for each double-quoted identifier to see if the\n** identifier should really be a string literal.\n*/\ntypedef struct DblquoteStr DblquoteStr;\nstruct DblquoteStr {\n  DblquoteStr *pNextStr;   /* Next string literal in the list */\n  char z[8];               /* Dequoted value for the string */\n};\n\n/*\n** An instance of the virtual machine.  This structure contains the complete\n** state of the virtual machine.\n**\n** The \"sqlite3_stmt\" structure pointer that is returned by sqlite3_prepare()\n** is really a pointer to an instance of this structure.\n*/\nstruct Vdbe {\n  sqlite3 *db;            /* The database connection that owns this statement */\n  Vdbe *pPrev,*pNext;     /* Linked list of VDBEs with the same Vdbe.db */\n  Parse *pParse;          /* Parsing context used to create this Vdbe */\n  ynVar nVar;             /* Number of entries in aVar[] */\n  u32 magic;              /* Magic number for sanity checking */\n  int nMem;               /* Number of memory locations currently allocated */\n  int nCursor;            /* Number of slots in apCsr[] */\n  u32 cacheCtr;           /* VdbeCursor row cache generation counter */\n  int pc;                 /* The program counter */\n  int rc;                 /* Value to return */\n  int nChange;            /* Number of db changes made since last reset */\n  int iStatement;         /* Statement number (or 0 if has no opened stmt) */\n  i64 iCurrentTime;       /* Value of julianday('now') for this statement */\n  i64 nFkConstraint;      /* Number of imm. FK constraints this VM */\n  i64 nStmtDefCons;       /* Number of def. constraints when stmt started */\n  i64 nStmtDefImmCons;    /* Number of def. imm constraints when stmt started */\n  Mem *aMem;              /* The memory locations */\n  Mem **apArg;            /* Arguments to currently executing user function */\n  VdbeCursor **apCsr;     /* One element of this array for each open cursor */\n  Mem *aVar;              /* Values for the OP_Variable opcode. */\n\n  /* When allocating a new Vdbe object, all of the fields below should be\n  ** initialized to zero or NULL */\n\n  Op *aOp;                /* Space to hold the virtual machine's program */\n  int nOp;                /* Number of instructions in the program */\n  int nOpAlloc;           /* Slots allocated for aOp[] */\n  Mem *aColName;          /* Column names to return */\n  Mem *pResultSet;        /* Pointer to an array of results */\n  char *zErrMsg;          /* Error message written here */\n  VList *pVList;          /* Name of variables */\n#ifndef SQLITE_OMIT_TRACE\n  i64 startTime;          /* Time when query started - used for profiling */\n#endif\n#ifdef SQLITE_DEBUG\n  int rcApp;              /* errcode set by sqlite3_result_error_code() */\n  u32 nWrite;             /* Number of write operations that have occurred */\n#endif\n  u16 nResColumn;         /* Number of columns in one row of the result set */\n  u8 errorAction;         /* Recovery action to do in case of an error */\n  u8 minWriteFileFormat;  /* Minimum file format for writable database files */\n  u8 prepFlags;           /* SQLITE_PREPARE_* flags */\n  bft expired:2;          /* 1: recompile VM immediately  2: when convenient */\n  bft explain:2;          /* True if EXPLAIN present on SQL command */\n  bft doingRerun:1;       /* True if rerunning after an auto-reprepare */\n  bft changeCntOn:1;      /* True to update the change-counter */\n  bft runOnlyOnce:1;      /* Automatically expire on reset */\n  bft usesStmtJournal:1;  /* True if uses a statement journal */\n  bft readOnly:1;         /* True for statements that do not write */\n  bft bIsReader:1;        /* True for statements that read */\n  yDbMask btreeMask;      /* Bitmask of db->aDb[] entries referenced */\n  yDbMask lockMask;       /* Subset of btreeMask that requires a lock */\n  u32 aCounter[7];        /* Counters used by sqlite3_stmt_status() */\n  char *zSql;             /* Text of the SQL statement that generated this */\n#ifdef SQLITE_ENABLE_NORMALIZE\n  char *zNormSql;         /* Normalization of the associated SQL statement */\n  DblquoteStr *pDblStr;   /* List of double-quoted string literals */\n#endif\n  void *pFree;            /* Free this when deleting the vdbe */\n  VdbeFrame *pFrame;      /* Parent frame */\n  VdbeFrame *pDelFrame;   /* List of frame objects to free on VM reset */\n  int nFrame;             /* Number of frames in pFrame list */\n  u32 expmask;            /* Binding to these vars invalidates VM */\n  SubProgram *pProgram;   /* Linked list of all sub-programs used by VM */\n  AuxData *pAuxData;      /* Linked list of auxdata allocations */\n#ifdef SQLITE_ENABLE_STMT_SCANSTATUS\n  i64 *anExec;            /* Number of times each op has been executed */\n  int nScan;              /* Entries in aScan[] */\n  ScanStatus *aScan;      /* Scan definitions for sqlite3_stmt_scanstatus() */\n#endif\n};\n\n/*\n** The following are allowed values for Vdbe.magic\n*/\n#define VDBE_MAGIC_INIT     0x16bceaa5    /* Building a VDBE program */\n#define VDBE_MAGIC_RUN      0x2df20da3    /* VDBE is ready to execute */\n#define VDBE_MAGIC_HALT     0x319c2973    /* VDBE has completed execution */\n#define VDBE_MAGIC_RESET    0x48fa9f76    /* Reset and ready to run again */\n#define VDBE_MAGIC_DEAD     0x5606c3c8    /* The VDBE has been deallocated */\n\n/*\n** Structure used to store the context required by the \n** sqlite3_preupdate_*() API functions.\n*/\nstruct PreUpdate {\n  Vdbe *v;\n  VdbeCursor *pCsr;               /* Cursor to read old values from */\n  int op;                         /* One of SQLITE_INSERT, UPDATE, DELETE */\n  u8 *aRecord;                    /* old.* database record */\n  KeyInfo keyinfo;\n  UnpackedRecord *pUnpacked;      /* Unpacked version of aRecord[] */\n  UnpackedRecord *pNewUnpacked;   /* Unpacked version of new.* record */\n  int iNewReg;                    /* Register for new.* values */\n  i64 iKey1;                      /* First key value passed to hook */\n  i64 iKey2;                      /* Second key value passed to hook */\n  Mem *aNew;                      /* Array of new.* values */\n  Table *pTab;                    /* Schema object being upated */          \n  Index *pPk;                     /* PK index if pTab is WITHOUT ROWID */\n};\n\n/*\n** Function prototypes\n*/\nSQLITE_PRIVATE void sqlite3VdbeError(Vdbe*, const char *, ...);\nSQLITE_PRIVATE void sqlite3VdbeFreeCursor(Vdbe *, VdbeCursor*);\nvoid sqliteVdbePopStack(Vdbe*,int);\nSQLITE_PRIVATE int sqlite3VdbeCursorMoveto(VdbeCursor**, int*);\nSQLITE_PRIVATE int sqlite3VdbeCursorRestore(VdbeCursor*);\nSQLITE_PRIVATE u32 sqlite3VdbeSerialTypeLen(u32);\nSQLITE_PRIVATE u8 sqlite3VdbeOneByteSerialTypeLen(u8);\nSQLITE_PRIVATE u32 sqlite3VdbeSerialType(Mem*, int, u32*);\nSQLITE_PRIVATE u32 sqlite3VdbeSerialPut(unsigned char*, Mem*, u32);\nSQLITE_PRIVATE u32 sqlite3VdbeSerialGet(const unsigned char*, u32, Mem*);\nSQLITE_PRIVATE void sqlite3VdbeDeleteAuxData(sqlite3*, AuxData**, int, int);\n\nint sqlite2BtreeKeyCompare(BtCursor *, const void *, int, int, int *);\nSQLITE_PRIVATE int sqlite3VdbeIdxKeyCompare(sqlite3*,VdbeCursor*,UnpackedRecord*,int*);\nSQLITE_PRIVATE int sqlite3VdbeIdxRowid(sqlite3*, BtCursor*, i64*);\nSQLITE_PRIVATE int sqlite3VdbeExec(Vdbe*);\n#ifndef SQLITE_OMIT_EXPLAIN\nSQLITE_PRIVATE int sqlite3VdbeList(Vdbe*);\n#endif\nSQLITE_PRIVATE int sqlite3VdbeHalt(Vdbe*);\nSQLITE_PRIVATE int sqlite3VdbeChangeEncoding(Mem *, int);\nSQLITE_PRIVATE int sqlite3VdbeMemTooBig(Mem*);\nSQLITE_PRIVATE int sqlite3VdbeMemCopy(Mem*, const Mem*);\nSQLITE_PRIVATE void sqlite3VdbeMemShallowCopy(Mem*, const Mem*, int);\nSQLITE_PRIVATE void sqlite3VdbeMemMove(Mem*, Mem*);\nSQLITE_PRIVATE int sqlite3VdbeMemNulTerminate(Mem*);\nSQLITE_PRIVATE int sqlite3VdbeMemSetStr(Mem*, const char*, int, u8, void(*)(void*));\nSQLITE_PRIVATE void sqlite3VdbeMemSetInt64(Mem*, i64);\n#ifdef SQLITE_OMIT_FLOATING_POINT\n# define sqlite3VdbeMemSetDouble sqlite3VdbeMemSetInt64\n#else\nSQLITE_PRIVATE   void sqlite3VdbeMemSetDouble(Mem*, double);\n#endif\nSQLITE_PRIVATE void sqlite3VdbeMemSetPointer(Mem*, void*, const char*, void(*)(void*));\nSQLITE_PRIVATE void sqlite3VdbeMemInit(Mem*,sqlite3*,u16);\nSQLITE_PRIVATE void sqlite3VdbeMemSetNull(Mem*);\nSQLITE_PRIVATE void sqlite3VdbeMemSetZeroBlob(Mem*,int);\n#ifdef SQLITE_DEBUG\nSQLITE_PRIVATE int sqlite3VdbeMemIsRowSet(const Mem*);\n#endif\nSQLITE_PRIVATE int sqlite3VdbeMemSetRowSet(Mem*);\nSQLITE_PRIVATE int sqlite3VdbeMemMakeWriteable(Mem*);\nSQLITE_PRIVATE int sqlite3VdbeMemStringify(Mem*, u8, u8);\nSQLITE_PRIVATE i64 sqlite3VdbeIntValue(Mem*);\nSQLITE_PRIVATE int sqlite3VdbeMemIntegerify(Mem*);\nSQLITE_PRIVATE double sqlite3VdbeRealValue(Mem*);\nSQLITE_PRIVATE int sqlite3VdbeBooleanValue(Mem*, int ifNull);\nSQLITE_PRIVATE void sqlite3VdbeIntegerAffinity(Mem*);\nSQLITE_PRIVATE int sqlite3VdbeMemRealify(Mem*);\nSQLITE_PRIVATE int sqlite3VdbeMemNumerify(Mem*);\nSQLITE_PRIVATE void sqlite3VdbeMemCast(Mem*,u8,u8);\nSQLITE_PRIVATE int sqlite3VdbeMemFromBtree(BtCursor*,u32,u32,Mem*);\nSQLITE_PRIVATE void sqlite3VdbeMemRelease(Mem *p);\nSQLITE_PRIVATE int sqlite3VdbeMemFinalize(Mem*, FuncDef*);\n#ifndef SQLITE_OMIT_WINDOWFUNC\nSQLITE_PRIVATE int sqlite3VdbeMemAggValue(Mem*, Mem*, FuncDef*);\n#endif\n#ifndef SQLITE_OMIT_EXPLAIN\nSQLITE_PRIVATE const char *sqlite3OpcodeName(int);\n#endif\nSQLITE_PRIVATE int sqlite3VdbeMemGrow(Mem *pMem, int n, int preserve);\nSQLITE_PRIVATE int sqlite3VdbeMemClearAndResize(Mem *pMem, int n);\nSQLITE_PRIVATE int sqlite3VdbeCloseStatement(Vdbe *, int);\n#ifdef SQLITE_DEBUG\nSQLITE_PRIVATE int sqlite3VdbeFrameIsValid(VdbeFrame*);\n#endif\nSQLITE_PRIVATE void sqlite3VdbeFrameMemDel(void*);      /* Destructor on Mem */\nSQLITE_PRIVATE void sqlite3VdbeFrameDelete(VdbeFrame*); /* Actually deletes the Frame */\nSQLITE_PRIVATE int sqlite3VdbeFrameRestore(VdbeFrame *);\n#ifdef SQLITE_ENABLE_PREUPDATE_HOOK\nSQLITE_PRIVATE void sqlite3VdbePreUpdateHook(Vdbe*,VdbeCursor*,int,const char*,Table*,i64,int);\n#endif\nSQLITE_PRIVATE int sqlite3VdbeTransferError(Vdbe *p);\n\nSQLITE_PRIVATE int sqlite3VdbeSorterInit(sqlite3 *, int, VdbeCursor *);\nSQLITE_PRIVATE void sqlite3VdbeSorterReset(sqlite3 *, VdbeSorter *);\nSQLITE_PRIVATE void sqlite3VdbeSorterClose(sqlite3 *, VdbeCursor *);\nSQLITE_PRIVATE int sqlite3VdbeSorterRowkey(const VdbeCursor *, Mem *);\nSQLITE_PRIVATE int sqlite3VdbeSorterNext(sqlite3 *, const VdbeCursor *);\nSQLITE_PRIVATE int sqlite3VdbeSorterRewind(const VdbeCursor *, int *);\nSQLITE_PRIVATE int sqlite3VdbeSorterWrite(const VdbeCursor *, Mem *);\nSQLITE_PRIVATE int sqlite3VdbeSorterCompare(const VdbeCursor *, Mem *, int, int *);\n\n#ifdef SQLITE_DEBUG\nSQLITE_PRIVATE   void sqlite3VdbeIncrWriteCounter(Vdbe*, VdbeCursor*);\nSQLITE_PRIVATE   void sqlite3VdbeAssertAbortable(Vdbe*);\n#else\n# define sqlite3VdbeIncrWriteCounter(V,C)\n# define sqlite3VdbeAssertAbortable(V)\n#endif\n\n#if !defined(SQLITE_OMIT_SHARED_CACHE) \nSQLITE_PRIVATE   void sqlite3VdbeEnter(Vdbe*);\n#else\n# define sqlite3VdbeEnter(X)\n#endif\n\n#if !defined(SQLITE_OMIT_SHARED_CACHE) && SQLITE_THREADSAFE>0\nSQLITE_PRIVATE   void sqlite3VdbeLeave(Vdbe*);\n#else\n# define sqlite3VdbeLeave(X)\n#endif\n\n#ifdef SQLITE_DEBUG\nSQLITE_PRIVATE void sqlite3VdbeMemAboutToChange(Vdbe*,Mem*);\nSQLITE_PRIVATE int sqlite3VdbeCheckMemInvariants(Mem*);\n#endif\n\n#ifndef SQLITE_OMIT_FOREIGN_KEY\nSQLITE_PRIVATE int sqlite3VdbeCheckFk(Vdbe *, int);\n#else\n# define sqlite3VdbeCheckFk(p,i) 0\n#endif\n\n#ifdef SQLITE_DEBUG\nSQLITE_PRIVATE   void sqlite3VdbePrintSql(Vdbe*);\nSQLITE_PRIVATE   void sqlite3VdbeMemPrettyPrint(Mem *pMem, char *zBuf);\n#endif\n#ifndef SQLITE_OMIT_UTF16\nSQLITE_PRIVATE   int sqlite3VdbeMemTranslate(Mem*, u8);\nSQLITE_PRIVATE   int sqlite3VdbeMemHandleBom(Mem *pMem);\n#endif\n\n#ifndef SQLITE_OMIT_INCRBLOB\nSQLITE_PRIVATE   int sqlite3VdbeMemExpandBlob(Mem *);\n  #define ExpandBlob(P) (((P)->flags&MEM_Zero)?sqlite3VdbeMemExpandBlob(P):0)\n#else\n  #define sqlite3VdbeMemExpandBlob(x) SQLITE_OK\n  #define ExpandBlob(P) SQLITE_OK\n#endif\n\n#endif /* !defined(SQLITE_VDBEINT_H) */\n\n/************** End of vdbeInt.h *********************************************/\n/************** Continuing where we left off in status.c *********************/\n\n/*\n** Variables in which to record status information.\n*/\n#if SQLITE_PTRSIZE>4\ntypedef sqlite3_int64 sqlite3StatValueType;\n#else\ntypedef u32 sqlite3StatValueType;\n#endif\ntypedef struct sqlite3StatType sqlite3StatType;\nstatic SQLITE_WSD struct sqlite3StatType {\n  sqlite3StatValueType nowValue[10];  /* Current value */\n  sqlite3StatValueType mxValue[10];   /* Maximum value */\n} sqlite3Stat = { {0,}, {0,} };\n\n/*\n** Elements of sqlite3Stat[] are protected by either the memory allocator\n** mutex, or by the pcache1 mutex.  The following array determines which.\n*/\nstatic const char statMutex[] = {\n  0,  /* SQLITE_STATUS_MEMORY_USED */\n  1,  /* SQLITE_STATUS_PAGECACHE_USED */\n  1,  /* SQLITE_STATUS_PAGECACHE_OVERFLOW */\n  0,  /* SQLITE_STATUS_SCRATCH_USED */\n  0,  /* SQLITE_STATUS_SCRATCH_OVERFLOW */\n  0,  /* SQLITE_STATUS_MALLOC_SIZE */\n  0,  /* SQLITE_STATUS_PARSER_STACK */\n  1,  /* SQLITE_STATUS_PAGECACHE_SIZE */\n  0,  /* SQLITE_STATUS_SCRATCH_SIZE */\n  0,  /* SQLITE_STATUS_MALLOC_COUNT */\n};\n\n\n/* The \"wsdStat\" macro will resolve to the status information\n** state vector.  If writable static data is unsupported on the target,\n** we have to locate the state vector at run-time.  In the more common\n** case where writable static data is supported, wsdStat can refer directly\n** to the \"sqlite3Stat\" state vector declared above.\n*/\n#ifdef SQLITE_OMIT_WSD\n# define wsdStatInit  sqlite3StatType *x = &GLOBAL(sqlite3StatType,sqlite3Stat)\n# define wsdStat x[0]\n#else\n# define wsdStatInit\n# define wsdStat sqlite3Stat\n#endif\n\n/*\n** Return the current value of a status parameter.  The caller must\n** be holding the appropriate mutex.\n*/\nSQLITE_PRIVATE sqlite3_int64 sqlite3StatusValue(int op){\n  wsdStatInit;\n  assert( op>=0 && op<ArraySize(wsdStat.nowValue) );\n  assert( op>=0 && op<ArraySize(statMutex) );\n  assert( sqlite3_mutex_held(statMutex[op] ? sqlite3Pcache1Mutex()\n                                           : sqlite3MallocMutex()) );\n  return wsdStat.nowValue[op];\n}\n\n/*\n** Add N to the value of a status record.  The caller must hold the\n** appropriate mutex.  (Locking is checked by assert()).\n**\n** The StatusUp() routine can accept positive or negative values for N.\n** The value of N is added to the current status value and the high-water\n** mark is adjusted if necessary.\n**\n** The StatusDown() routine lowers the current value by N.  The highwater\n** mark is unchanged.  N must be non-negative for StatusDown().\n*/\nSQLITE_PRIVATE void sqlite3StatusUp(int op, int N){\n  wsdStatInit;\n  assert( op>=0 && op<ArraySize(wsdStat.nowValue) );\n  assert( op>=0 && op<ArraySize(statMutex) );\n  assert( sqlite3_mutex_held(statMutex[op] ? sqlite3Pcache1Mutex()\n                                           : sqlite3MallocMutex()) );\n  wsdStat.nowValue[op] += N;\n  if( wsdStat.nowValue[op]>wsdStat.mxValue[op] ){\n    wsdStat.mxValue[op] = wsdStat.nowValue[op];\n  }\n}\nSQLITE_PRIVATE void sqlite3StatusDown(int op, int N){\n  wsdStatInit;\n  assert( N>=0 );\n  assert( op>=0 && op<ArraySize(statMutex) );\n  assert( sqlite3_mutex_held(statMutex[op] ? sqlite3Pcache1Mutex()\n                                           : sqlite3MallocMutex()) );\n  assert( op>=0 && op<ArraySize(wsdStat.nowValue) );\n  wsdStat.nowValue[op] -= N;\n}\n\n/*\n** Adjust the highwater mark if necessary.\n** The caller must hold the appropriate mutex.\n*/\nSQLITE_PRIVATE void sqlite3StatusHighwater(int op, int X){\n  sqlite3StatValueType newValue;\n  wsdStatInit;\n  assert( X>=0 );\n  newValue = (sqlite3StatValueType)X;\n  assert( op>=0 && op<ArraySize(wsdStat.nowValue) );\n  assert( op>=0 && op<ArraySize(statMutex) );\n  assert( sqlite3_mutex_held(statMutex[op] ? sqlite3Pcache1Mutex()\n                                           : sqlite3MallocMutex()) );\n  assert( op==SQLITE_STATUS_MALLOC_SIZE\n          || op==SQLITE_STATUS_PAGECACHE_SIZE\n          || op==SQLITE_STATUS_PARSER_STACK );\n  if( newValue>wsdStat.mxValue[op] ){\n    wsdStat.mxValue[op] = newValue;\n  }\n}\n\n/*\n** Query status information.\n*/\nSQLITE_API int sqlite3_status64(\n  int op,\n  sqlite3_int64 *pCurrent,\n  sqlite3_int64 *pHighwater,\n  int resetFlag\n){\n  sqlite3_mutex *pMutex;\n  wsdStatInit;\n  if( op<0 || op>=ArraySize(wsdStat.nowValue) ){\n    return SQLITE_MISUSE_BKPT;\n  }\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( pCurrent==0 || pHighwater==0 ) return SQLITE_MISUSE_BKPT;\n#endif\n  pMutex = statMutex[op] ? sqlite3Pcache1Mutex() : sqlite3MallocMutex();\n  sqlite3_mutex_enter(pMutex);\n  *pCurrent = wsdStat.nowValue[op];\n  *pHighwater = wsdStat.mxValue[op];\n  if( resetFlag ){\n    wsdStat.mxValue[op] = wsdStat.nowValue[op];\n  }\n  sqlite3_mutex_leave(pMutex);\n  (void)pMutex;  /* Prevent warning when SQLITE_THREADSAFE=0 */\n  return SQLITE_OK;\n}\nSQLITE_API int sqlite3_status(int op, int *pCurrent, int *pHighwater, int resetFlag){\n  sqlite3_int64 iCur = 0, iHwtr = 0;\n  int rc;\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( pCurrent==0 || pHighwater==0 ) return SQLITE_MISUSE_BKPT;\n#endif\n  rc = sqlite3_status64(op, &iCur, &iHwtr, resetFlag);\n  if( rc==0 ){\n    *pCurrent = (int)iCur;\n    *pHighwater = (int)iHwtr;\n  }\n  return rc;\n}\n\n/*\n** Return the number of LookasideSlot elements on the linked list\n*/\nstatic u32 countLookasideSlots(LookasideSlot *p){\n  u32 cnt = 0;\n  while( p ){\n    p = p->pNext;\n    cnt++;\n  }\n  return cnt;\n}\n\n/*\n** Count the number of slots of lookaside memory that are outstanding\n*/\nSQLITE_PRIVATE int sqlite3LookasideUsed(sqlite3 *db, int *pHighwater){\n  u32 nInit = countLookasideSlots(db->lookaside.pInit);\n  u32 nFree = countLookasideSlots(db->lookaside.pFree);\n  if( pHighwater ) *pHighwater = db->lookaside.nSlot - nInit;\n  return db->lookaside.nSlot - (nInit+nFree);\n}\n\n/*\n** Query status information for a single database connection\n*/\nSQLITE_API int sqlite3_db_status(\n  sqlite3 *db,          /* The database connection whose status is desired */\n  int op,               /* Status verb */\n  int *pCurrent,        /* Write current value here */\n  int *pHighwater,      /* Write high-water mark here */\n  int resetFlag         /* Reset high-water mark if true */\n){\n  int rc = SQLITE_OK;   /* Return code */\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( !sqlite3SafetyCheckOk(db) || pCurrent==0|| pHighwater==0 ){\n    return SQLITE_MISUSE_BKPT;\n  }\n#endif\n  sqlite3_mutex_enter(db->mutex);\n  switch( op ){\n    case SQLITE_DBSTATUS_LOOKASIDE_USED: {\n      *pCurrent = sqlite3LookasideUsed(db, pHighwater);\n      if( resetFlag ){\n        LookasideSlot *p = db->lookaside.pFree;\n        if( p ){\n          while( p->pNext ) p = p->pNext;\n          p->pNext = db->lookaside.pInit;\n          db->lookaside.pInit = db->lookaside.pFree;\n          db->lookaside.pFree = 0;\n        }\n      }\n      break;\n    }\n\n    case SQLITE_DBSTATUS_LOOKASIDE_HIT:\n    case SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE:\n    case SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL: {\n      testcase( op==SQLITE_DBSTATUS_LOOKASIDE_HIT );\n      testcase( op==SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE );\n      testcase( op==SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL );\n      assert( (op-SQLITE_DBSTATUS_LOOKASIDE_HIT)>=0 );\n      assert( (op-SQLITE_DBSTATUS_LOOKASIDE_HIT)<3 );\n      *pCurrent = 0;\n      *pHighwater = db->lookaside.anStat[op - SQLITE_DBSTATUS_LOOKASIDE_HIT];\n      if( resetFlag ){\n        db->lookaside.anStat[op - SQLITE_DBSTATUS_LOOKASIDE_HIT] = 0;\n      }\n      break;\n    }\n\n    /* \n    ** Return an approximation for the amount of memory currently used\n    ** by all pagers associated with the given database connection.  The\n    ** highwater mark is meaningless and is returned as zero.\n    */\n    case SQLITE_DBSTATUS_CACHE_USED_SHARED:\n    case SQLITE_DBSTATUS_CACHE_USED: {\n      int totalUsed = 0;\n      int i;\n      sqlite3BtreeEnterAll(db);\n      for(i=0; i<db->nDb; i++){\n        Btree *pBt = db->aDb[i].pBt;\n        if( pBt ){\n          Pager *pPager = sqlite3BtreePager(pBt);\n          int nByte = sqlite3PagerMemUsed(pPager);\n          if( op==SQLITE_DBSTATUS_CACHE_USED_SHARED ){\n            nByte = nByte / sqlite3BtreeConnectionCount(pBt);\n          }\n          totalUsed += nByte;\n        }\n      }\n      sqlite3BtreeLeaveAll(db);\n      *pCurrent = totalUsed;\n      *pHighwater = 0;\n      break;\n    }\n\n    /*\n    ** *pCurrent gets an accurate estimate of the amount of memory used\n    ** to store the schema for all databases (main, temp, and any ATTACHed\n    ** databases.  *pHighwater is set to zero.\n    */\n    case SQLITE_DBSTATUS_SCHEMA_USED: {\n      int i;                      /* Used to iterate through schemas */\n      int nByte = 0;              /* Used to accumulate return value */\n\n      sqlite3BtreeEnterAll(db);\n      db->pnBytesFreed = &nByte;\n      for(i=0; i<db->nDb; i++){\n        Schema *pSchema = db->aDb[i].pSchema;\n        if( ALWAYS(pSchema!=0) ){\n          HashElem *p;\n\n          nByte += sqlite3GlobalConfig.m.xRoundup(sizeof(HashElem)) * (\n              pSchema->tblHash.count \n            + pSchema->trigHash.count\n            + pSchema->idxHash.count\n            + pSchema->fkeyHash.count\n          );\n          nByte += sqlite3_msize(pSchema->tblHash.ht);\n          nByte += sqlite3_msize(pSchema->trigHash.ht);\n          nByte += sqlite3_msize(pSchema->idxHash.ht);\n          nByte += sqlite3_msize(pSchema->fkeyHash.ht);\n\n          for(p=sqliteHashFirst(&pSchema->trigHash); p; p=sqliteHashNext(p)){\n            sqlite3DeleteTrigger(db, (Trigger*)sqliteHashData(p));\n          }\n          for(p=sqliteHashFirst(&pSchema->tblHash); p; p=sqliteHashNext(p)){\n            sqlite3DeleteTable(db, (Table *)sqliteHashData(p));\n          }\n        }\n      }\n      db->pnBytesFreed = 0;\n      sqlite3BtreeLeaveAll(db);\n\n      *pHighwater = 0;\n      *pCurrent = nByte;\n      break;\n    }\n\n    /*\n    ** *pCurrent gets an accurate estimate of the amount of memory used\n    ** to store all prepared statements.\n    ** *pHighwater is set to zero.\n    */\n    case SQLITE_DBSTATUS_STMT_USED: {\n      struct Vdbe *pVdbe;         /* Used to iterate through VMs */\n      int nByte = 0;              /* Used to accumulate return value */\n\n      db->pnBytesFreed = &nByte;\n      for(pVdbe=db->pVdbe; pVdbe; pVdbe=pVdbe->pNext){\n        sqlite3VdbeClearObject(db, pVdbe);\n        sqlite3DbFree(db, pVdbe);\n      }\n      db->pnBytesFreed = 0;\n\n      *pHighwater = 0;  /* IMP: R-64479-57858 */\n      *pCurrent = nByte;\n\n      break;\n    }\n\n    /*\n    ** Set *pCurrent to the total cache hits or misses encountered by all\n    ** pagers the database handle is connected to. *pHighwater is always set \n    ** to zero.\n    */\n    case SQLITE_DBSTATUS_CACHE_SPILL:\n      op = SQLITE_DBSTATUS_CACHE_WRITE+1;\n      /* Fall through into the next case */\n    case SQLITE_DBSTATUS_CACHE_HIT:\n    case SQLITE_DBSTATUS_CACHE_MISS:\n    case SQLITE_DBSTATUS_CACHE_WRITE:{\n      int i;\n      int nRet = 0;\n      assert( SQLITE_DBSTATUS_CACHE_MISS==SQLITE_DBSTATUS_CACHE_HIT+1 );\n      assert( SQLITE_DBSTATUS_CACHE_WRITE==SQLITE_DBSTATUS_CACHE_HIT+2 );\n\n      for(i=0; i<db->nDb; i++){\n        if( db->aDb[i].pBt ){\n          Pager *pPager = sqlite3BtreePager(db->aDb[i].pBt);\n          sqlite3PagerCacheStat(pPager, op, resetFlag, &nRet);\n        }\n      }\n      *pHighwater = 0; /* IMP: R-42420-56072 */\n                       /* IMP: R-54100-20147 */\n                       /* IMP: R-29431-39229 */\n      *pCurrent = nRet;\n      break;\n    }\n\n    /* Set *pCurrent to non-zero if there are unresolved deferred foreign\n    ** key constraints.  Set *pCurrent to zero if all foreign key constraints\n    ** have been satisfied.  The *pHighwater is always set to zero.\n    */\n    case SQLITE_DBSTATUS_DEFERRED_FKS: {\n      *pHighwater = 0;  /* IMP: R-11967-56545 */\n      *pCurrent = db->nDeferredImmCons>0 || db->nDeferredCons>0;\n      break;\n    }\n\n    default: {\n      rc = SQLITE_ERROR;\n    }\n  }\n  sqlite3_mutex_leave(db->mutex);\n  return rc;\n}\n\n/************** End of status.c **********************************************/\n/************** Begin file date.c ********************************************/\n/*\n** 2003 October 31\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This file contains the C functions that implement date and time\n** functions for SQLite.  \n**\n** There is only one exported symbol in this file - the function\n** sqlite3RegisterDateTimeFunctions() found at the bottom of the file.\n** All other code has file scope.\n**\n** SQLite processes all times and dates as julian day numbers.  The\n** dates and times are stored as the number of days since noon\n** in Greenwich on November 24, 4714 B.C. according to the Gregorian\n** calendar system. \n**\n** 1970-01-01 00:00:00 is JD 2440587.5\n** 2000-01-01 00:00:00 is JD 2451544.5\n**\n** This implementation requires years to be expressed as a 4-digit number\n** which means that only dates between 0000-01-01 and 9999-12-31 can\n** be represented, even though julian day numbers allow a much wider\n** range of dates.\n**\n** The Gregorian calendar system is used for all dates and times,\n** even those that predate the Gregorian calendar.  Historians usually\n** use the julian calendar for dates prior to 1582-10-15 and for some\n** dates afterwards, depending on locale.  Beware of this difference.\n**\n** The conversion algorithms are implemented based on descriptions\n** in the following text:\n**\n**      Jean Meeus\n**      Astronomical Algorithms, 2nd Edition, 1998\n**      ISBN 0-943396-61-1\n**      Willmann-Bell, Inc\n**      Richmond, Virginia (USA)\n*/\n/* #include \"sqliteInt.h\" */\n/* #include <stdlib.h> */\n/* #include <assert.h> */\n#include <time.h>\n\n#ifndef SQLITE_OMIT_DATETIME_FUNCS\n\n/*\n** The MSVC CRT on Windows CE may not have a localtime() function.\n** So declare a substitute.  The substitute function itself is\n** defined in \"os_win.c\".\n*/\n#if !defined(SQLITE_OMIT_LOCALTIME) && defined(_WIN32_WCE) && \\\n    (!defined(SQLITE_MSVC_LOCALTIME_API) || !SQLITE_MSVC_LOCALTIME_API)\nstruct tm *__cdecl localtime(const time_t *);\n#endif\n\n/*\n** A structure for holding a single date and time.\n*/\ntypedef struct DateTime DateTime;\nstruct DateTime {\n  sqlite3_int64 iJD;  /* The julian day number times 86400000 */\n  int Y, M, D;        /* Year, month, and day */\n  int h, m;           /* Hour and minutes */\n  int tz;             /* Timezone offset in minutes */\n  double s;           /* Seconds */\n  char validJD;       /* True (1) if iJD is valid */\n  char rawS;          /* Raw numeric value stored in s */\n  char validYMD;      /* True (1) if Y,M,D are valid */\n  char validHMS;      /* True (1) if h,m,s are valid */\n  char validTZ;       /* True (1) if tz is valid */\n  char tzSet;         /* Timezone was set explicitly */\n  char isError;       /* An overflow has occurred */\n};\n\n\n/*\n** Convert zDate into one or more integers according to the conversion\n** specifier zFormat.\n**\n** zFormat[] contains 4 characters for each integer converted, except for\n** the last integer which is specified by three characters.  The meaning\n** of a four-character format specifiers ABCD is:\n**\n**    A:   number of digits to convert.  Always \"2\" or \"4\".\n**    B:   minimum value.  Always \"0\" or \"1\".\n**    C:   maximum value, decoded as:\n**           a:  12\n**           b:  14\n**           c:  24\n**           d:  31\n**           e:  59\n**           f:  9999\n**    D:   the separator character, or \\000 to indicate this is the\n**         last number to convert.\n**\n** Example:  To translate an ISO-8601 date YYYY-MM-DD, the format would\n** be \"40f-21a-20c\".  The \"40f-\" indicates the 4-digit year followed by \"-\".\n** The \"21a-\" indicates the 2-digit month followed by \"-\".  The \"20c\" indicates\n** the 2-digit day which is the last integer in the set.\n**\n** The function returns the number of successful conversions.\n*/\nstatic int getDigits(const char *zDate, const char *zFormat, ...){\n  /* The aMx[] array translates the 3rd character of each format\n  ** spec into a max size:    a   b   c   d   e     f */\n  static const u16 aMx[] = { 12, 14, 24, 31, 59, 9999 };\n  va_list ap;\n  int cnt = 0;\n  char nextC;\n  va_start(ap, zFormat);\n  do{\n    char N = zFormat[0] - '0';\n    char min = zFormat[1] - '0';\n    int val = 0;\n    u16 max;\n\n    assert( zFormat[2]>='a' && zFormat[2]<='f' );\n    max = aMx[zFormat[2] - 'a'];\n    nextC = zFormat[3];\n    val = 0;\n    while( N-- ){\n      if( !sqlite3Isdigit(*zDate) ){\n        goto end_getDigits;\n      }\n      val = val*10 + *zDate - '0';\n      zDate++;\n    }\n    if( val<(int)min || val>(int)max || (nextC!=0 && nextC!=*zDate) ){\n      goto end_getDigits;\n    }\n    *va_arg(ap,int*) = val;\n    zDate++;\n    cnt++;\n    zFormat += 4;\n  }while( nextC );\nend_getDigits:\n  va_end(ap);\n  return cnt;\n}\n\n/*\n** Parse a timezone extension on the end of a date-time.\n** The extension is of the form:\n**\n**        (+/-)HH:MM\n**\n** Or the \"zulu\" notation:\n**\n**        Z\n**\n** If the parse is successful, write the number of minutes\n** of change in p->tz and return 0.  If a parser error occurs,\n** return non-zero.\n**\n** A missing specifier is not considered an error.\n*/\nstatic int parseTimezone(const char *zDate, DateTime *p){\n  int sgn = 0;\n  int nHr, nMn;\n  int c;\n  while( sqlite3Isspace(*zDate) ){ zDate++; }\n  p->tz = 0;\n  c = *zDate;\n  if( c=='-' ){\n    sgn = -1;\n  }else if( c=='+' ){\n    sgn = +1;\n  }else if( c=='Z' || c=='z' ){\n    zDate++;\n    goto zulu_time;\n  }else{\n    return c!=0;\n  }\n  zDate++;\n  if( getDigits(zDate, \"20b:20e\", &nHr, &nMn)!=2 ){\n    return 1;\n  }\n  zDate += 5;\n  p->tz = sgn*(nMn + nHr*60);\nzulu_time:\n  while( sqlite3Isspace(*zDate) ){ zDate++; }\n  p->tzSet = 1;\n  return *zDate!=0;\n}\n\n/*\n** Parse times of the form HH:MM or HH:MM:SS or HH:MM:SS.FFFF.\n** The HH, MM, and SS must each be exactly 2 digits.  The\n** fractional seconds FFFF can be one or more digits.\n**\n** Return 1 if there is a parsing error and 0 on success.\n*/\nstatic int parseHhMmSs(const char *zDate, DateTime *p){\n  int h, m, s;\n  double ms = 0.0;\n  if( getDigits(zDate, \"20c:20e\", &h, &m)!=2 ){\n    return 1;\n  }\n  zDate += 5;\n  if( *zDate==':' ){\n    zDate++;\n    if( getDigits(zDate, \"20e\", &s)!=1 ){\n      return 1;\n    }\n    zDate += 2;\n    if( *zDate=='.' && sqlite3Isdigit(zDate[1]) ){\n      double rScale = 1.0;\n      zDate++;\n      while( sqlite3Isdigit(*zDate) ){\n        ms = ms*10.0 + *zDate - '0';\n        rScale *= 10.0;\n        zDate++;\n      }\n      ms /= rScale;\n    }\n  }else{\n    s = 0;\n  }\n  p->validJD = 0;\n  p->rawS = 0;\n  p->validHMS = 1;\n  p->h = h;\n  p->m = m;\n  p->s = s + ms;\n  if( parseTimezone(zDate, p) ) return 1;\n  p->validTZ = (p->tz!=0)?1:0;\n  return 0;\n}\n\n/*\n** Put the DateTime object into its error state.\n*/\nstatic void datetimeError(DateTime *p){\n  memset(p, 0, sizeof(*p));\n  p->isError = 1;\n}\n\n/*\n** Convert from YYYY-MM-DD HH:MM:SS to julian day.  We always assume\n** that the YYYY-MM-DD is according to the Gregorian calendar.\n**\n** Reference:  Meeus page 61\n*/\nstatic void computeJD(DateTime *p){\n  int Y, M, D, A, B, X1, X2;\n\n  if( p->validJD ) return;\n  if( p->validYMD ){\n    Y = p->Y;\n    M = p->M;\n    D = p->D;\n  }else{\n    Y = 2000;  /* If no YMD specified, assume 2000-Jan-01 */\n    M = 1;\n    D = 1;\n  }\n  if( Y<-4713 || Y>9999 || p->rawS ){\n    datetimeError(p);\n    return;\n  }\n  if( M<=2 ){\n    Y--;\n    M += 12;\n  }\n  A = Y/100;\n  B = 2 - A + (A/4);\n  X1 = 36525*(Y+4716)/100;\n  X2 = 306001*(M+1)/10000;\n  p->iJD = (sqlite3_int64)((X1 + X2 + D + B - 1524.5 ) * 86400000);\n  p->validJD = 1;\n  if( p->validHMS ){\n    p->iJD += p->h*3600000 + p->m*60000 + (sqlite3_int64)(p->s*1000);\n    if( p->validTZ ){\n      p->iJD -= p->tz*60000;\n      p->validYMD = 0;\n      p->validHMS = 0;\n      p->validTZ = 0;\n    }\n  }\n}\n\n/*\n** Parse dates of the form\n**\n**     YYYY-MM-DD HH:MM:SS.FFF\n**     YYYY-MM-DD HH:MM:SS\n**     YYYY-MM-DD HH:MM\n**     YYYY-MM-DD\n**\n** Write the result into the DateTime structure and return 0\n** on success and 1 if the input string is not a well-formed\n** date.\n*/\nstatic int parseYyyyMmDd(const char *zDate, DateTime *p){\n  int Y, M, D, neg;\n\n  if( zDate[0]=='-' ){\n    zDate++;\n    neg = 1;\n  }else{\n    neg = 0;\n  }\n  if( getDigits(zDate, \"40f-21a-21d\", &Y, &M, &D)!=3 ){\n    return 1;\n  }\n  zDate += 10;\n  while( sqlite3Isspace(*zDate) || 'T'==*(u8*)zDate ){ zDate++; }\n  if( parseHhMmSs(zDate, p)==0 ){\n    /* We got the time */\n  }else if( *zDate==0 ){\n    p->validHMS = 0;\n  }else{\n    return 1;\n  }\n  p->validJD = 0;\n  p->validYMD = 1;\n  p->Y = neg ? -Y : Y;\n  p->M = M;\n  p->D = D;\n  if( p->validTZ ){\n    computeJD(p);\n  }\n  return 0;\n}\n\n/*\n** Set the time to the current time reported by the VFS.\n**\n** Return the number of errors.\n*/\nstatic int setDateTimeToCurrent(sqlite3_context *context, DateTime *p){\n  p->iJD = sqlite3StmtCurrentTime(context);\n  if( p->iJD>0 ){\n    p->validJD = 1;\n    return 0;\n  }else{\n    return 1;\n  }\n}\n\n/*\n** Input \"r\" is a numeric quantity which might be a julian day number,\n** or the number of seconds since 1970.  If the value if r is within\n** range of a julian day number, install it as such and set validJD.\n** If the value is a valid unix timestamp, put it in p->s and set p->rawS.\n*/\nstatic void setRawDateNumber(DateTime *p, double r){\n  p->s = r;\n  p->rawS = 1;\n  if( r>=0.0 && r<5373484.5 ){\n    p->iJD = (sqlite3_int64)(r*86400000.0 + 0.5);\n    p->validJD = 1;\n  }\n}\n\n/*\n** Attempt to parse the given string into a julian day number.  Return\n** the number of errors.\n**\n** The following are acceptable forms for the input string:\n**\n**      YYYY-MM-DD HH:MM:SS.FFF  +/-HH:MM\n**      DDDD.DD \n**      now\n**\n** In the first form, the +/-HH:MM is always optional.  The fractional\n** seconds extension (the \".FFF\") is optional.  The seconds portion\n** (\":SS.FFF\") is option.  The year and date can be omitted as long\n** as there is a time string.  The time string can be omitted as long\n** as there is a year and date.\n*/\nstatic int parseDateOrTime(\n  sqlite3_context *context, \n  const char *zDate, \n  DateTime *p\n){\n  double r;\n  if( parseYyyyMmDd(zDate,p)==0 ){\n    return 0;\n  }else if( parseHhMmSs(zDate, p)==0 ){\n    return 0;\n  }else if( sqlite3StrICmp(zDate,\"now\")==0 && sqlite3NotPureFunc(context) ){\n    return setDateTimeToCurrent(context, p);\n  }else if( sqlite3AtoF(zDate, &r, sqlite3Strlen30(zDate), SQLITE_UTF8) ){\n    setRawDateNumber(p, r);\n    return 0;\n  }\n  return 1;\n}\n\n/* The julian day number for 9999-12-31 23:59:59.999 is 5373484.4999999.\n** Multiplying this by 86400000 gives 464269060799999 as the maximum value\n** for DateTime.iJD.\n**\n** But some older compilers (ex: gcc 4.2.1 on older Macs) cannot deal with \n** such a large integer literal, so we have to encode it.\n*/\n#define INT_464269060799999  ((((i64)0x1a640)<<32)|0x1072fdff)\n\n/*\n** Return TRUE if the given julian day number is within range.\n**\n** The input is the JulianDay times 86400000.\n*/\nstatic int validJulianDay(sqlite3_int64 iJD){\n  return iJD>=0 && iJD<=INT_464269060799999;\n}\n\n/*\n** Compute the Year, Month, and Day from the julian day number.\n*/\nstatic void computeYMD(DateTime *p){\n  int Z, A, B, C, D, E, X1;\n  if( p->validYMD ) return;\n  if( !p->validJD ){\n    p->Y = 2000;\n    p->M = 1;\n    p->D = 1;\n  }else if( !validJulianDay(p->iJD) ){\n    datetimeError(p);\n    return;\n  }else{\n    Z = (int)((p->iJD + 43200000)/86400000);\n    A = (int)((Z - 1867216.25)/36524.25);\n    A = Z + 1 + A - (A/4);\n    B = A + 1524;\n    C = (int)((B - 122.1)/365.25);\n    D = (36525*(C&32767))/100;\n    E = (int)((B-D)/30.6001);\n    X1 = (int)(30.6001*E);\n    p->D = B - D - X1;\n    p->M = E<14 ? E-1 : E-13;\n    p->Y = p->M>2 ? C - 4716 : C - 4715;\n  }\n  p->validYMD = 1;\n}\n\n/*\n** Compute the Hour, Minute, and Seconds from the julian day number.\n*/\nstatic void computeHMS(DateTime *p){\n  int s;\n  if( p->validHMS ) return;\n  computeJD(p);\n  s = (int)((p->iJD + 43200000) % 86400000);\n  p->s = s/1000.0;\n  s = (int)p->s;\n  p->s -= s;\n  p->h = s/3600;\n  s -= p->h*3600;\n  p->m = s/60;\n  p->s += s - p->m*60;\n  p->rawS = 0;\n  p->validHMS = 1;\n}\n\n/*\n** Compute both YMD and HMS\n*/\nstatic void computeYMD_HMS(DateTime *p){\n  computeYMD(p);\n  computeHMS(p);\n}\n\n/*\n** Clear the YMD and HMS and the TZ\n*/\nstatic void clearYMD_HMS_TZ(DateTime *p){\n  p->validYMD = 0;\n  p->validHMS = 0;\n  p->validTZ = 0;\n}\n\n#ifndef SQLITE_OMIT_LOCALTIME\n/*\n** On recent Windows platforms, the localtime_s() function is available\n** as part of the \"Secure CRT\". It is essentially equivalent to \n** localtime_r() available under most POSIX platforms, except that the \n** order of the parameters is reversed.\n**\n** See http://msdn.microsoft.com/en-us/library/a442x3ye(VS.80).aspx.\n**\n** If the user has not indicated to use localtime_r() or localtime_s()\n** already, check for an MSVC build environment that provides \n** localtime_s().\n*/\n#if !HAVE_LOCALTIME_R && !HAVE_LOCALTIME_S \\\n    && defined(_MSC_VER) && defined(_CRT_INSECURE_DEPRECATE)\n#undef  HAVE_LOCALTIME_S\n#define HAVE_LOCALTIME_S 1\n#endif\n\n/*\n** The following routine implements the rough equivalent of localtime_r()\n** using whatever operating-system specific localtime facility that\n** is available.  This routine returns 0 on success and\n** non-zero on any kind of error.\n**\n** If the sqlite3GlobalConfig.bLocaltimeFault variable is true then this\n** routine will always fail.\n**\n** EVIDENCE-OF: R-62172-00036 In this implementation, the standard C\n** library function localtime_r() is used to assist in the calculation of\n** local time.\n*/\nstatic int osLocaltime(time_t *t, struct tm *pTm){\n  int rc;\n#if !HAVE_LOCALTIME_R && !HAVE_LOCALTIME_S\n  struct tm *pX;\n#if SQLITE_THREADSAFE>0\n  sqlite3_mutex *mutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER);\n#endif\n  sqlite3_mutex_enter(mutex);\n  pX = localtime(t);\n#ifndef SQLITE_UNTESTABLE\n  if( sqlite3GlobalConfig.bLocaltimeFault ) pX = 0;\n#endif\n  if( pX ) *pTm = *pX;\n  sqlite3_mutex_leave(mutex);\n  rc = pX==0;\n#else\n#ifndef SQLITE_UNTESTABLE\n  if( sqlite3GlobalConfig.bLocaltimeFault ) return 1;\n#endif\n#if HAVE_LOCALTIME_R\n  rc = localtime_r(t, pTm)==0;\n#else\n  rc = localtime_s(pTm, t);\n#endif /* HAVE_LOCALTIME_R */\n#endif /* HAVE_LOCALTIME_R || HAVE_LOCALTIME_S */\n  return rc;\n}\n#endif /* SQLITE_OMIT_LOCALTIME */\n\n\n#ifndef SQLITE_OMIT_LOCALTIME\n/*\n** Compute the difference (in milliseconds) between localtime and UTC\n** (a.k.a. GMT) for the time value p where p is in UTC. If no error occurs,\n** return this value and set *pRc to SQLITE_OK. \n**\n** Or, if an error does occur, set *pRc to SQLITE_ERROR. The returned value\n** is undefined in this case.\n*/\nstatic sqlite3_int64 localtimeOffset(\n  DateTime *p,                    /* Date at which to calculate offset */\n  sqlite3_context *pCtx,          /* Write error here if one occurs */\n  int *pRc                        /* OUT: Error code. SQLITE_OK or ERROR */\n){\n  DateTime x, y;\n  time_t t;\n  struct tm sLocal;\n\n  /* Initialize the contents of sLocal to avoid a compiler warning. */\n  memset(&sLocal, 0, sizeof(sLocal));\n\n  x = *p;\n  computeYMD_HMS(&x);\n  if( x.Y<1971 || x.Y>=2038 ){\n    /* EVIDENCE-OF: R-55269-29598 The localtime_r() C function normally only\n    ** works for years between 1970 and 2037. For dates outside this range,\n    ** SQLite attempts to map the year into an equivalent year within this\n    ** range, do the calculation, then map the year back.\n    */\n    x.Y = 2000;\n    x.M = 1;\n    x.D = 1;\n    x.h = 0;\n    x.m = 0;\n    x.s = 0.0;\n  } else {\n    int s = (int)(x.s + 0.5);\n    x.s = s;\n  }\n  x.tz = 0;\n  x.validJD = 0;\n  computeJD(&x);\n  t = (time_t)(x.iJD/1000 - 21086676*(i64)10000);\n  if( osLocaltime(&t, &sLocal) ){\n    sqlite3_result_error(pCtx, \"local time unavailable\", -1);\n    *pRc = SQLITE_ERROR;\n    return 0;\n  }\n  y.Y = sLocal.tm_year + 1900;\n  y.M = sLocal.tm_mon + 1;\n  y.D = sLocal.tm_mday;\n  y.h = sLocal.tm_hour;\n  y.m = sLocal.tm_min;\n  y.s = sLocal.tm_sec;\n  y.validYMD = 1;\n  y.validHMS = 1;\n  y.validJD = 0;\n  y.rawS = 0;\n  y.validTZ = 0;\n  y.isError = 0;\n  computeJD(&y);\n  *pRc = SQLITE_OK;\n  return y.iJD - x.iJD;\n}\n#endif /* SQLITE_OMIT_LOCALTIME */\n\n/*\n** The following table defines various date transformations of the form\n**\n**            'NNN days'\n**\n** Where NNN is an arbitrary floating-point number and \"days\" can be one\n** of several units of time.\n*/\nstatic const struct {\n  u8 eType;           /* Transformation type code */\n  u8 nName;           /* Length of th name */\n  char *zName;        /* Name of the transformation */\n  double rLimit;      /* Maximum NNN value for this transform */\n  double rXform;      /* Constant used for this transform */\n} aXformType[] = {\n  { 0, 6, \"second\", 464269060800.0, 86400000.0/(24.0*60.0*60.0) },\n  { 0, 6, \"minute\", 7737817680.0,   86400000.0/(24.0*60.0)      },\n  { 0, 4, \"hour\",   128963628.0,    86400000.0/24.0             },\n  { 0, 3, \"day\",    5373485.0,      86400000.0                  },\n  { 1, 5, \"month\",  176546.0,       30.0*86400000.0             },\n  { 2, 4, \"year\",   14713.0,        365.0*86400000.0            },\n};\n\n/*\n** Process a modifier to a date-time stamp.  The modifiers are\n** as follows:\n**\n**     NNN days\n**     NNN hours\n**     NNN minutes\n**     NNN.NNNN seconds\n**     NNN months\n**     NNN years\n**     start of month\n**     start of year\n**     start of week\n**     start of day\n**     weekday N\n**     unixepoch\n**     localtime\n**     utc\n**\n** Return 0 on success and 1 if there is any kind of error. If the error\n** is in a system call (i.e. localtime()), then an error message is written\n** to context pCtx. If the error is an unrecognized modifier, no error is\n** written to pCtx.\n*/\nstatic int parseModifier(\n  sqlite3_context *pCtx,      /* Function context */\n  const char *z,              /* The text of the modifier */\n  int n,                      /* Length of zMod in bytes */\n  DateTime *p                 /* The date/time value to be modified */\n){\n  int rc = 1;\n  double r;\n  switch(sqlite3UpperToLower[(u8)z[0]] ){\n#ifndef SQLITE_OMIT_LOCALTIME\n    case 'l': {\n      /*    localtime\n      **\n      ** Assuming the current time value is UTC (a.k.a. GMT), shift it to\n      ** show local time.\n      */\n      if( sqlite3_stricmp(z, \"localtime\")==0 && sqlite3NotPureFunc(pCtx) ){\n        computeJD(p);\n        p->iJD += localtimeOffset(p, pCtx, &rc);\n        clearYMD_HMS_TZ(p);\n      }\n      break;\n    }\n#endif\n    case 'u': {\n      /*\n      **    unixepoch\n      **\n      ** Treat the current value of p->s as the number of\n      ** seconds since 1970.  Convert to a real julian day number.\n      */\n      if( sqlite3_stricmp(z, \"unixepoch\")==0 && p->rawS ){\n        r = p->s*1000.0 + 210866760000000.0;\n        if( r>=0.0 && r<464269060800000.0 ){\n          clearYMD_HMS_TZ(p);\n          p->iJD = (sqlite3_int64)r;\n          p->validJD = 1;\n          p->rawS = 0;\n          rc = 0;\n        }\n      }\n#ifndef SQLITE_OMIT_LOCALTIME\n      else if( sqlite3_stricmp(z, \"utc\")==0 && sqlite3NotPureFunc(pCtx) ){\n        if( p->tzSet==0 ){\n          sqlite3_int64 c1;\n          computeJD(p);\n          c1 = localtimeOffset(p, pCtx, &rc);\n          if( rc==SQLITE_OK ){\n            p->iJD -= c1;\n            clearYMD_HMS_TZ(p);\n            p->iJD += c1 - localtimeOffset(p, pCtx, &rc);\n          }\n          p->tzSet = 1;\n        }else{\n          rc = SQLITE_OK;\n        }\n      }\n#endif\n      break;\n    }\n    case 'w': {\n      /*\n      **    weekday N\n      **\n      ** Move the date to the same time on the next occurrence of\n      ** weekday N where 0==Sunday, 1==Monday, and so forth.  If the\n      ** date is already on the appropriate weekday, this is a no-op.\n      */\n      if( sqlite3_strnicmp(z, \"weekday \", 8)==0\n               && sqlite3AtoF(&z[8], &r, sqlite3Strlen30(&z[8]), SQLITE_UTF8)\n               && (n=(int)r)==r && n>=0 && r<7 ){\n        sqlite3_int64 Z;\n        computeYMD_HMS(p);\n        p->validTZ = 0;\n        p->validJD = 0;\n        computeJD(p);\n        Z = ((p->iJD + 129600000)/86400000) % 7;\n        if( Z>n ) Z -= 7;\n        p->iJD += (n - Z)*86400000;\n        clearYMD_HMS_TZ(p);\n        rc = 0;\n      }\n      break;\n    }\n    case 's': {\n      /*\n      **    start of TTTTT\n      **\n      ** Move the date backwards to the beginning of the current day,\n      ** or month or year.\n      */\n      if( sqlite3_strnicmp(z, \"start of \", 9)!=0 ) break;\n      if( !p->validJD && !p->validYMD && !p->validHMS ) break;\n      z += 9;\n      computeYMD(p);\n      p->validHMS = 1;\n      p->h = p->m = 0;\n      p->s = 0.0;\n      p->rawS = 0;\n      p->validTZ = 0;\n      p->validJD = 0;\n      if( sqlite3_stricmp(z,\"month\")==0 ){\n        p->D = 1;\n        rc = 0;\n      }else if( sqlite3_stricmp(z,\"year\")==0 ){\n        p->M = 1;\n        p->D = 1;\n        rc = 0;\n      }else if( sqlite3_stricmp(z,\"day\")==0 ){\n        rc = 0;\n      }\n      break;\n    }\n    case '+':\n    case '-':\n    case '0':\n    case '1':\n    case '2':\n    case '3':\n    case '4':\n    case '5':\n    case '6':\n    case '7':\n    case '8':\n    case '9': {\n      double rRounder;\n      int i;\n      for(n=1; z[n] && z[n]!=':' && !sqlite3Isspace(z[n]); n++){}\n      if( !sqlite3AtoF(z, &r, n, SQLITE_UTF8) ){\n        rc = 1;\n        break;\n      }\n      if( z[n]==':' ){\n        /* A modifier of the form (+|-)HH:MM:SS.FFF adds (or subtracts) the\n        ** specified number of hours, minutes, seconds, and fractional seconds\n        ** to the time.  The \".FFF\" may be omitted.  The \":SS.FFF\" may be\n        ** omitted.\n        */\n        const char *z2 = z;\n        DateTime tx;\n        sqlite3_int64 day;\n        if( !sqlite3Isdigit(*z2) ) z2++;\n        memset(&tx, 0, sizeof(tx));\n        if( parseHhMmSs(z2, &tx) ) break;\n        computeJD(&tx);\n        tx.iJD -= 43200000;\n        day = tx.iJD/86400000;\n        tx.iJD -= day*86400000;\n        if( z[0]=='-' ) tx.iJD = -tx.iJD;\n        computeJD(p);\n        clearYMD_HMS_TZ(p);\n        p->iJD += tx.iJD;\n        rc = 0;\n        break;\n      }\n\n      /* If control reaches this point, it means the transformation is\n      ** one of the forms like \"+NNN days\".  */\n      z += n;\n      while( sqlite3Isspace(*z) ) z++;\n      n = sqlite3Strlen30(z);\n      if( n>10 || n<3 ) break;\n      if( sqlite3UpperToLower[(u8)z[n-1]]=='s' ) n--;\n      computeJD(p);\n      rc = 1;\n      rRounder = r<0 ? -0.5 : +0.5;\n      for(i=0; i<ArraySize(aXformType); i++){\n        if( aXformType[i].nName==n\n         && sqlite3_strnicmp(aXformType[i].zName, z, n)==0\n         && r>-aXformType[i].rLimit && r<aXformType[i].rLimit\n        ){\n          switch( aXformType[i].eType ){\n            case 1: { /* Special processing to add months */\n              int x;\n              computeYMD_HMS(p);\n              p->M += (int)r;\n              x = p->M>0 ? (p->M-1)/12 : (p->M-12)/12;\n              p->Y += x;\n              p->M -= x*12;\n              p->validJD = 0;\n              r -= (int)r;\n              break;\n            }\n            case 2: { /* Special processing to add years */\n              int y = (int)r;\n              computeYMD_HMS(p);\n              p->Y += y;\n              p->validJD = 0;\n              r -= (int)r;\n              break;\n            }\n          }\n          computeJD(p);\n          p->iJD += (sqlite3_int64)(r*aXformType[i].rXform + rRounder);\n          rc = 0;\n          break;\n        }\n      }\n      clearYMD_HMS_TZ(p);\n      break;\n    }\n    default: {\n      break;\n    }\n  }\n  return rc;\n}\n\n/*\n** Process time function arguments.  argv[0] is a date-time stamp.\n** argv[1] and following are modifiers.  Parse them all and write\n** the resulting time into the DateTime structure p.  Return 0\n** on success and 1 if there are any errors.\n**\n** If there are zero parameters (if even argv[0] is undefined)\n** then assume a default value of \"now\" for argv[0].\n*/\nstatic int isDate(\n  sqlite3_context *context, \n  int argc, \n  sqlite3_value **argv, \n  DateTime *p\n){\n  int i, n;\n  const unsigned char *z;\n  int eType;\n  memset(p, 0, sizeof(*p));\n  if( argc==0 ){\n    return setDateTimeToCurrent(context, p);\n  }\n  if( (eType = sqlite3_value_type(argv[0]))==SQLITE_FLOAT\n                   || eType==SQLITE_INTEGER ){\n    setRawDateNumber(p, sqlite3_value_double(argv[0]));\n  }else{\n    z = sqlite3_value_text(argv[0]);\n    if( !z || parseDateOrTime(context, (char*)z, p) ){\n      return 1;\n    }\n  }\n  for(i=1; i<argc; i++){\n    z = sqlite3_value_text(argv[i]);\n    n = sqlite3_value_bytes(argv[i]);\n    if( z==0 || parseModifier(context, (char*)z, n, p) ) return 1;\n  }\n  computeJD(p);\n  if( p->isError || !validJulianDay(p->iJD) ) return 1;\n  return 0;\n}\n\n\n/*\n** The following routines implement the various date and time functions\n** of SQLite.\n*/\n\n/*\n**    julianday( TIMESTRING, MOD, MOD, ...)\n**\n** Return the julian day number of the date specified in the arguments\n*/\nstatic void juliandayFunc(\n  sqlite3_context *context,\n  int argc,\n  sqlite3_value **argv\n){\n  DateTime x;\n  if( isDate(context, argc, argv, &x)==0 ){\n    computeJD(&x);\n    sqlite3_result_double(context, x.iJD/86400000.0);\n  }\n}\n\n/*\n**    datetime( TIMESTRING, MOD, MOD, ...)\n**\n** Return YYYY-MM-DD HH:MM:SS\n*/\nstatic void datetimeFunc(\n  sqlite3_context *context,\n  int argc,\n  sqlite3_value **argv\n){\n  DateTime x;\n  if( isDate(context, argc, argv, &x)==0 ){\n    char zBuf[100];\n    computeYMD_HMS(&x);\n    sqlite3_snprintf(sizeof(zBuf), zBuf, \"%04d-%02d-%02d %02d:%02d:%02d\",\n                     x.Y, x.M, x.D, x.h, x.m, (int)(x.s));\n    sqlite3_result_text(context, zBuf, -1, SQLITE_TRANSIENT);\n  }\n}\n\n/*\n**    time( TIMESTRING, MOD, MOD, ...)\n**\n** Return HH:MM:SS\n*/\nstatic void timeFunc(\n  sqlite3_context *context,\n  int argc,\n  sqlite3_value **argv\n){\n  DateTime x;\n  if( isDate(context, argc, argv, &x)==0 ){\n    char zBuf[100];\n    computeHMS(&x);\n    sqlite3_snprintf(sizeof(zBuf), zBuf, \"%02d:%02d:%02d\", x.h, x.m, (int)x.s);\n    sqlite3_result_text(context, zBuf, -1, SQLITE_TRANSIENT);\n  }\n}\n\n/*\n**    date( TIMESTRING, MOD, MOD, ...)\n**\n** Return YYYY-MM-DD\n*/\nstatic void dateFunc(\n  sqlite3_context *context,\n  int argc,\n  sqlite3_value **argv\n){\n  DateTime x;\n  if( isDate(context, argc, argv, &x)==0 ){\n    char zBuf[100];\n    computeYMD(&x);\n    sqlite3_snprintf(sizeof(zBuf), zBuf, \"%04d-%02d-%02d\", x.Y, x.M, x.D);\n    sqlite3_result_text(context, zBuf, -1, SQLITE_TRANSIENT);\n  }\n}\n\n/*\n**    strftime( FORMAT, TIMESTRING, MOD, MOD, ...)\n**\n** Return a string described by FORMAT.  Conversions as follows:\n**\n**   %d  day of month\n**   %f  ** fractional seconds  SS.SSS\n**   %H  hour 00-24\n**   %j  day of year 000-366\n**   %J  ** julian day number\n**   %m  month 01-12\n**   %M  minute 00-59\n**   %s  seconds since 1970-01-01\n**   %S  seconds 00-59\n**   %w  day of week 0-6  sunday==0\n**   %W  week of year 00-53\n**   %Y  year 0000-9999\n**   %%  %\n*/\nstatic void strftimeFunc(\n  sqlite3_context *context,\n  int argc,\n  sqlite3_value **argv\n){\n  DateTime x;\n  u64 n;\n  size_t i,j;\n  char *z;\n  sqlite3 *db;\n  const char *zFmt;\n  char zBuf[100];\n  if( argc==0 ) return;\n  zFmt = (const char*)sqlite3_value_text(argv[0]);\n  if( zFmt==0 || isDate(context, argc-1, argv+1, &x) ) return;\n  db = sqlite3_context_db_handle(context);\n  for(i=0, n=1; zFmt[i]; i++, n++){\n    if( zFmt[i]=='%' ){\n      switch( zFmt[i+1] ){\n        case 'd':\n        case 'H':\n        case 'm':\n        case 'M':\n        case 'S':\n        case 'W':\n          n++;\n          /* fall thru */\n        case 'w':\n        case '%':\n          break;\n        case 'f':\n          n += 8;\n          break;\n        case 'j':\n          n += 3;\n          break;\n        case 'Y':\n          n += 8;\n          break;\n        case 's':\n        case 'J':\n          n += 50;\n          break;\n        default:\n          return;  /* ERROR.  return a NULL */\n      }\n      i++;\n    }\n  }\n  testcase( n==sizeof(zBuf)-1 );\n  testcase( n==sizeof(zBuf) );\n  testcase( n==(u64)db->aLimit[SQLITE_LIMIT_LENGTH]+1 );\n  testcase( n==(u64)db->aLimit[SQLITE_LIMIT_LENGTH] );\n  if( n<sizeof(zBuf) ){\n    z = zBuf;\n  }else if( n>(u64)db->aLimit[SQLITE_LIMIT_LENGTH] ){\n    sqlite3_result_error_toobig(context);\n    return;\n  }else{\n    z = sqlite3DbMallocRawNN(db, (int)n);\n    if( z==0 ){\n      sqlite3_result_error_nomem(context);\n      return;\n    }\n  }\n  computeJD(&x);\n  computeYMD_HMS(&x);\n  for(i=j=0; zFmt[i]; i++){\n    if( zFmt[i]!='%' ){\n      z[j++] = zFmt[i];\n    }else{\n      i++;\n      switch( zFmt[i] ){\n        case 'd':  sqlite3_snprintf(3, &z[j],\"%02d\",x.D); j+=2; break;\n        case 'f': {\n          double s = x.s;\n          if( s>59.999 ) s = 59.999;\n          sqlite3_snprintf(7, &z[j],\"%06.3f\", s);\n          j += sqlite3Strlen30(&z[j]);\n          break;\n        }\n        case 'H':  sqlite3_snprintf(3, &z[j],\"%02d\",x.h); j+=2; break;\n        case 'W': /* Fall thru */\n        case 'j': {\n          int nDay;             /* Number of days since 1st day of year */\n          DateTime y = x;\n          y.validJD = 0;\n          y.M = 1;\n          y.D = 1;\n          computeJD(&y);\n          nDay = (int)((x.iJD-y.iJD+43200000)/86400000);\n          if( zFmt[i]=='W' ){\n            int wd;   /* 0=Monday, 1=Tuesday, ... 6=Sunday */\n            wd = (int)(((x.iJD+43200000)/86400000)%7);\n            sqlite3_snprintf(3, &z[j],\"%02d\",(nDay+7-wd)/7);\n            j += 2;\n          }else{\n            sqlite3_snprintf(4, &z[j],\"%03d\",nDay+1);\n            j += 3;\n          }\n          break;\n        }\n        case 'J': {\n          sqlite3_snprintf(20, &z[j],\"%.16g\",x.iJD/86400000.0);\n          j+=sqlite3Strlen30(&z[j]);\n          break;\n        }\n        case 'm':  sqlite3_snprintf(3, &z[j],\"%02d\",x.M); j+=2; break;\n        case 'M':  sqlite3_snprintf(3, &z[j],\"%02d\",x.m); j+=2; break;\n        case 's': {\n          sqlite3_snprintf(30,&z[j],\"%lld\",\n                           (i64)(x.iJD/1000 - 21086676*(i64)10000));\n          j += sqlite3Strlen30(&z[j]);\n          break;\n        }\n        case 'S':  sqlite3_snprintf(3,&z[j],\"%02d\",(int)x.s); j+=2; break;\n        case 'w': {\n          z[j++] = (char)(((x.iJD+129600000)/86400000) % 7) + '0';\n          break;\n        }\n        case 'Y': {\n          sqlite3_snprintf(5,&z[j],\"%04d\",x.Y); j+=sqlite3Strlen30(&z[j]);\n          break;\n        }\n        default:   z[j++] = '%'; break;\n      }\n    }\n  }\n  z[j] = 0;\n  sqlite3_result_text(context, z, -1,\n                      z==zBuf ? SQLITE_TRANSIENT : SQLITE_DYNAMIC);\n}\n\n/*\n** current_time()\n**\n** This function returns the same value as time('now').\n*/\nstatic void ctimeFunc(\n  sqlite3_context *context,\n  int NotUsed,\n  sqlite3_value **NotUsed2\n){\n  UNUSED_PARAMETER2(NotUsed, NotUsed2);\n  timeFunc(context, 0, 0);\n}\n\n/*\n** current_date()\n**\n** This function returns the same value as date('now').\n*/\nstatic void cdateFunc(\n  sqlite3_context *context,\n  int NotUsed,\n  sqlite3_value **NotUsed2\n){\n  UNUSED_PARAMETER2(NotUsed, NotUsed2);\n  dateFunc(context, 0, 0);\n}\n\n/*\n** current_timestamp()\n**\n** This function returns the same value as datetime('now').\n*/\nstatic void ctimestampFunc(\n  sqlite3_context *context,\n  int NotUsed,\n  sqlite3_value **NotUsed2\n){\n  UNUSED_PARAMETER2(NotUsed, NotUsed2);\n  datetimeFunc(context, 0, 0);\n}\n#endif /* !defined(SQLITE_OMIT_DATETIME_FUNCS) */\n\n#ifdef SQLITE_OMIT_DATETIME_FUNCS\n/*\n** If the library is compiled to omit the full-scale date and time\n** handling (to get a smaller binary), the following minimal version\n** of the functions current_time(), current_date() and current_timestamp()\n** are included instead. This is to support column declarations that\n** include \"DEFAULT CURRENT_TIME\" etc.\n**\n** This function uses the C-library functions time(), gmtime()\n** and strftime(). The format string to pass to strftime() is supplied\n** as the user-data for the function.\n*/\nstatic void currentTimeFunc(\n  sqlite3_context *context,\n  int argc,\n  sqlite3_value **argv\n){\n  time_t t;\n  char *zFormat = (char *)sqlite3_user_data(context);\n  sqlite3_int64 iT;\n  struct tm *pTm;\n  struct tm sNow;\n  char zBuf[20];\n\n  UNUSED_PARAMETER(argc);\n  UNUSED_PARAMETER(argv);\n\n  iT = sqlite3StmtCurrentTime(context);\n  if( iT<=0 ) return;\n  t = iT/1000 - 10000*(sqlite3_int64)21086676;\n#if HAVE_GMTIME_R\n  pTm = gmtime_r(&t, &sNow);\n#else\n  sqlite3_mutex_enter(sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER));\n  pTm = gmtime(&t);\n  if( pTm ) memcpy(&sNow, pTm, sizeof(sNow));\n  sqlite3_mutex_leave(sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER));\n#endif\n  if( pTm ){\n    strftime(zBuf, 20, zFormat, &sNow);\n    sqlite3_result_text(context, zBuf, -1, SQLITE_TRANSIENT);\n  }\n}\n#endif\n\n/*\n** This function registered all of the above C functions as SQL\n** functions.  This should be the only routine in this file with\n** external linkage.\n*/\nSQLITE_PRIVATE void sqlite3RegisterDateTimeFunctions(void){\n  static FuncDef aDateTimeFuncs[] = {\n#ifndef SQLITE_OMIT_DATETIME_FUNCS\n    PURE_DATE(julianday,        -1, 0, 0, juliandayFunc ),\n    PURE_DATE(date,             -1, 0, 0, dateFunc      ),\n    PURE_DATE(time,             -1, 0, 0, timeFunc      ),\n    PURE_DATE(datetime,         -1, 0, 0, datetimeFunc  ),\n    PURE_DATE(strftime,         -1, 0, 0, strftimeFunc  ),\n    DFUNCTION(current_time,      0, 0, 0, ctimeFunc     ),\n    DFUNCTION(current_timestamp, 0, 0, 0, ctimestampFunc),\n    DFUNCTION(current_date,      0, 0, 0, cdateFunc     ),\n#else\n    STR_FUNCTION(current_time,      0, \"%H:%M:%S\",          0, currentTimeFunc),\n    STR_FUNCTION(current_date,      0, \"%Y-%m-%d\",          0, currentTimeFunc),\n    STR_FUNCTION(current_timestamp, 0, \"%Y-%m-%d %H:%M:%S\", 0, currentTimeFunc),\n#endif\n  };\n  sqlite3InsertBuiltinFuncs(aDateTimeFuncs, ArraySize(aDateTimeFuncs));\n}\n\n/************** End of date.c ************************************************/\n/************** Begin file os.c **********************************************/\n/*\n** 2005 November 29\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n******************************************************************************\n**\n** This file contains OS interface code that is common to all\n** architectures.\n*/\n/* #include \"sqliteInt.h\" */\n\n/*\n** If we compile with the SQLITE_TEST macro set, then the following block\n** of code will give us the ability to simulate a disk I/O error.  This\n** is used for testing the I/O recovery logic.\n*/\n#if defined(SQLITE_TEST)\nSQLITE_API int sqlite3_io_error_hit = 0;            /* Total number of I/O Errors */\nSQLITE_API int sqlite3_io_error_hardhit = 0;        /* Number of non-benign errors */\nSQLITE_API int sqlite3_io_error_pending = 0;        /* Count down to first I/O error */\nSQLITE_API int sqlite3_io_error_persist = 0;        /* True if I/O errors persist */\nSQLITE_API int sqlite3_io_error_benign = 0;         /* True if errors are benign */\nSQLITE_API int sqlite3_diskfull_pending = 0;\nSQLITE_API int sqlite3_diskfull = 0;\n#endif /* defined(SQLITE_TEST) */\n\n/*\n** When testing, also keep a count of the number of open files.\n*/\n#if defined(SQLITE_TEST)\nSQLITE_API int sqlite3_open_file_count = 0;\n#endif /* defined(SQLITE_TEST) */\n\n/*\n** The default SQLite sqlite3_vfs implementations do not allocate\n** memory (actually, os_unix.c allocates a small amount of memory\n** from within OsOpen()), but some third-party implementations may.\n** So we test the effects of a malloc() failing and the sqlite3OsXXX()\n** function returning SQLITE_IOERR_NOMEM using the DO_OS_MALLOC_TEST macro.\n**\n** The following functions are instrumented for malloc() failure\n** testing:\n**\n**     sqlite3OsRead()\n**     sqlite3OsWrite()\n**     sqlite3OsSync()\n**     sqlite3OsFileSize()\n**     sqlite3OsLock()\n**     sqlite3OsCheckReservedLock()\n**     sqlite3OsFileControl()\n**     sqlite3OsShmMap()\n**     sqlite3OsOpen()\n**     sqlite3OsDelete()\n**     sqlite3OsAccess()\n**     sqlite3OsFullPathname()\n**\n*/\n#if defined(SQLITE_TEST)\nSQLITE_API int sqlite3_memdebug_vfs_oom_test = 1;\n  #define DO_OS_MALLOC_TEST(x)                                       \\\n  if (sqlite3_memdebug_vfs_oom_test && (!x || !sqlite3JournalIsInMemory(x))) { \\\n    void *pTstAlloc = sqlite3Malloc(10);                             \\\n    if (!pTstAlloc) return SQLITE_IOERR_NOMEM_BKPT;                  \\\n    sqlite3_free(pTstAlloc);                                         \\\n  }\n#else\n  #define DO_OS_MALLOC_TEST(x)\n#endif\n\n/*\n** The following routines are convenience wrappers around methods\n** of the sqlite3_file object.  This is mostly just syntactic sugar. All\n** of this would be completely automatic if SQLite were coded using\n** C++ instead of plain old C.\n*/\nSQLITE_PRIVATE void sqlite3OsClose(sqlite3_file *pId){\n  if( pId->pMethods ){\n    pId->pMethods->xClose(pId);\n    pId->pMethods = 0;\n  }\n}\nSQLITE_PRIVATE int sqlite3OsRead(sqlite3_file *id, void *pBuf, int amt, i64 offset){\n  DO_OS_MALLOC_TEST(id);\n  return id->pMethods->xRead(id, pBuf, amt, offset);\n}\nSQLITE_PRIVATE int sqlite3OsWrite(sqlite3_file *id, const void *pBuf, int amt, i64 offset){\n  DO_OS_MALLOC_TEST(id);\n  return id->pMethods->xWrite(id, pBuf, amt, offset);\n}\nSQLITE_PRIVATE int sqlite3OsTruncate(sqlite3_file *id, i64 size){\n  return id->pMethods->xTruncate(id, size);\n}\nSQLITE_PRIVATE int sqlite3OsSync(sqlite3_file *id, int flags){\n  DO_OS_MALLOC_TEST(id);\n  return flags ? id->pMethods->xSync(id, flags) : SQLITE_OK;\n}\nSQLITE_PRIVATE int sqlite3OsFileSize(sqlite3_file *id, i64 *pSize){\n  DO_OS_MALLOC_TEST(id);\n  return id->pMethods->xFileSize(id, pSize);\n}\nSQLITE_PRIVATE int sqlite3OsLock(sqlite3_file *id, int lockType){\n  DO_OS_MALLOC_TEST(id);\n  return id->pMethods->xLock(id, lockType);\n}\nSQLITE_PRIVATE int sqlite3OsUnlock(sqlite3_file *id, int lockType){\n  return id->pMethods->xUnlock(id, lockType);\n}\nSQLITE_PRIVATE int sqlite3OsCheckReservedLock(sqlite3_file *id, int *pResOut){\n  DO_OS_MALLOC_TEST(id);\n  return id->pMethods->xCheckReservedLock(id, pResOut);\n}\n\n/*\n** Use sqlite3OsFileControl() when we are doing something that might fail\n** and we need to know about the failures.  Use sqlite3OsFileControlHint()\n** when simply tossing information over the wall to the VFS and we do not\n** really care if the VFS receives and understands the information since it\n** is only a hint and can be safely ignored.  The sqlite3OsFileControlHint()\n** routine has no return value since the return value would be meaningless.\n*/\nSQLITE_PRIVATE int sqlite3OsFileControl(sqlite3_file *id, int op, void *pArg){\n  if( id->pMethods==0 ) return SQLITE_NOTFOUND;\n#ifdef SQLITE_TEST\n  if( op!=SQLITE_FCNTL_COMMIT_PHASETWO\n   && op!=SQLITE_FCNTL_LOCK_TIMEOUT\n  ){\n    /* Faults are not injected into COMMIT_PHASETWO because, assuming SQLite\n    ** is using a regular VFS, it is called after the corresponding\n    ** transaction has been committed. Injecting a fault at this point\n    ** confuses the test scripts - the COMMIT comand returns SQLITE_NOMEM\n    ** but the transaction is committed anyway.\n    **\n    ** The core must call OsFileControl() though, not OsFileControlHint(),\n    ** as if a custom VFS (e.g. zipvfs) returns an error here, it probably\n    ** means the commit really has failed and an error should be returned\n    ** to the user.  */\n    DO_OS_MALLOC_TEST(id);\n  }\n#endif\n  return id->pMethods->xFileControl(id, op, pArg);\n}\nSQLITE_PRIVATE void sqlite3OsFileControlHint(sqlite3_file *id, int op, void *pArg){\n  if( id->pMethods ) (void)id->pMethods->xFileControl(id, op, pArg);\n}\n\nSQLITE_PRIVATE int sqlite3OsSectorSize(sqlite3_file *id){\n  int (*xSectorSize)(sqlite3_file*) = id->pMethods->xSectorSize;\n  return (xSectorSize ? xSectorSize(id) : SQLITE_DEFAULT_SECTOR_SIZE);\n}\nSQLITE_PRIVATE int sqlite3OsDeviceCharacteristics(sqlite3_file *id){\n  return id->pMethods->xDeviceCharacteristics(id);\n}\n#ifndef SQLITE_OMIT_WAL\nSQLITE_PRIVATE int sqlite3OsShmLock(sqlite3_file *id, int offset, int n, int flags){\n  return id->pMethods->xShmLock(id, offset, n, flags);\n}\nSQLITE_PRIVATE void sqlite3OsShmBarrier(sqlite3_file *id){\n  id->pMethods->xShmBarrier(id);\n}\nSQLITE_PRIVATE int sqlite3OsShmUnmap(sqlite3_file *id, int deleteFlag){\n  return id->pMethods->xShmUnmap(id, deleteFlag);\n}\nSQLITE_PRIVATE int sqlite3OsShmMap(\n  sqlite3_file *id,               /* Database file handle */\n  int iPage,\n  int pgsz,\n  int bExtend,                    /* True to extend file if necessary */\n  void volatile **pp              /* OUT: Pointer to mapping */\n){\n  DO_OS_MALLOC_TEST(id);\n  return id->pMethods->xShmMap(id, iPage, pgsz, bExtend, pp);\n}\n#endif /* SQLITE_OMIT_WAL */\n\n#if SQLITE_MAX_MMAP_SIZE>0\n/* The real implementation of xFetch and xUnfetch */\nSQLITE_PRIVATE int sqlite3OsFetch(sqlite3_file *id, i64 iOff, int iAmt, void **pp){\n  DO_OS_MALLOC_TEST(id);\n  return id->pMethods->xFetch(id, iOff, iAmt, pp);\n}\nSQLITE_PRIVATE int sqlite3OsUnfetch(sqlite3_file *id, i64 iOff, void *p){\n  return id->pMethods->xUnfetch(id, iOff, p);\n}\n#else\n/* No-op stubs to use when memory-mapped I/O is disabled */\nSQLITE_PRIVATE int sqlite3OsFetch(sqlite3_file *id, i64 iOff, int iAmt, void **pp){\n  *pp = 0;\n  return SQLITE_OK;\n}\nSQLITE_PRIVATE int sqlite3OsUnfetch(sqlite3_file *id, i64 iOff, void *p){\n  return SQLITE_OK;\n}\n#endif\n\n/*\n** The next group of routines are convenience wrappers around the\n** VFS methods.\n*/\nSQLITE_PRIVATE int sqlite3OsOpen(\n  sqlite3_vfs *pVfs,\n  const char *zPath,\n  sqlite3_file *pFile,\n  int flags,\n  int *pFlagsOut\n){\n  int rc;\n  DO_OS_MALLOC_TEST(0);\n  /* 0x87f7f is a mask of SQLITE_OPEN_ flags that are valid to be passed\n  ** down into the VFS layer.  Some SQLITE_OPEN_ flags (for example,\n  ** SQLITE_OPEN_FULLMUTEX or SQLITE_OPEN_SHAREDCACHE) are blocked before\n  ** reaching the VFS. */\n  rc = pVfs->xOpen(pVfs, zPath, pFile, flags & 0x187f7f, pFlagsOut);\n  assert( rc==SQLITE_OK || pFile->pMethods==0 );\n  return rc;\n}\nSQLITE_PRIVATE int sqlite3OsDelete(sqlite3_vfs *pVfs, const char *zPath, int dirSync){\n  DO_OS_MALLOC_TEST(0);\n  assert( dirSync==0 || dirSync==1 );\n  return pVfs->xDelete(pVfs, zPath, dirSync);\n}\nSQLITE_PRIVATE int sqlite3OsAccess(\n  sqlite3_vfs *pVfs,\n  const char *zPath,\n  int flags,\n  int *pResOut\n){\n  DO_OS_MALLOC_TEST(0);\n  return pVfs->xAccess(pVfs, zPath, flags, pResOut);\n}\nSQLITE_PRIVATE int sqlite3OsFullPathname(\n  sqlite3_vfs *pVfs,\n  const char *zPath,\n  int nPathOut,\n  char *zPathOut\n){\n  DO_OS_MALLOC_TEST(0);\n  zPathOut[0] = 0;\n  return pVfs->xFullPathname(pVfs, zPath, nPathOut, zPathOut);\n}\n#ifndef SQLITE_OMIT_LOAD_EXTENSION\nSQLITE_PRIVATE void *sqlite3OsDlOpen(sqlite3_vfs *pVfs, const char *zPath){\n  return pVfs->xDlOpen(pVfs, zPath);\n}\nSQLITE_PRIVATE void sqlite3OsDlError(sqlite3_vfs *pVfs, int nByte, char *zBufOut){\n  pVfs->xDlError(pVfs, nByte, zBufOut);\n}\nSQLITE_PRIVATE void (*sqlite3OsDlSym(sqlite3_vfs *pVfs, void *pHdle, const char *zSym))(void){\n  return pVfs->xDlSym(pVfs, pHdle, zSym);\n}\nSQLITE_PRIVATE void sqlite3OsDlClose(sqlite3_vfs *pVfs, void *pHandle){\n  pVfs->xDlClose(pVfs, pHandle);\n}\n#endif /* SQLITE_OMIT_LOAD_EXTENSION */\nSQLITE_PRIVATE int sqlite3OsRandomness(sqlite3_vfs *pVfs, int nByte, char *zBufOut){\n  return pVfs->xRandomness(pVfs, nByte, zBufOut);\n}\nSQLITE_PRIVATE int sqlite3OsSleep(sqlite3_vfs *pVfs, int nMicro){\n  return pVfs->xSleep(pVfs, nMicro);\n}\nSQLITE_PRIVATE int sqlite3OsGetLastError(sqlite3_vfs *pVfs){\n  return pVfs->xGetLastError ? pVfs->xGetLastError(pVfs, 0, 0) : 0;\n}\nSQLITE_PRIVATE int sqlite3OsCurrentTimeInt64(sqlite3_vfs *pVfs, sqlite3_int64 *pTimeOut){\n  int rc;\n  /* IMPLEMENTATION-OF: R-49045-42493 SQLite will use the xCurrentTimeInt64()\n  ** method to get the current date and time if that method is available\n  ** (if iVersion is 2 or greater and the function pointer is not NULL) and\n  ** will fall back to xCurrentTime() if xCurrentTimeInt64() is\n  ** unavailable.\n  */\n  if( pVfs->iVersion>=2 && pVfs->xCurrentTimeInt64 ){\n    rc = pVfs->xCurrentTimeInt64(pVfs, pTimeOut);\n  }else{\n    double r;\n    rc = pVfs->xCurrentTime(pVfs, &r);\n    *pTimeOut = (sqlite3_int64)(r*86400000.0);\n  }\n  return rc;\n}\n\nSQLITE_PRIVATE int sqlite3OsOpenMalloc(\n  sqlite3_vfs *pVfs,\n  const char *zFile,\n  sqlite3_file **ppFile,\n  int flags,\n  int *pOutFlags\n){\n  int rc;\n  sqlite3_file *pFile;\n  pFile = (sqlite3_file *)sqlite3MallocZero(pVfs->szOsFile);\n  if( pFile ){\n    rc = sqlite3OsOpen(pVfs, zFile, pFile, flags, pOutFlags);\n    if( rc!=SQLITE_OK ){\n      sqlite3_free(pFile);\n    }else{\n      *ppFile = pFile;\n    }\n  }else{\n    rc = SQLITE_NOMEM_BKPT;\n  }\n  return rc;\n}\nSQLITE_PRIVATE void sqlite3OsCloseFree(sqlite3_file *pFile){\n  assert( pFile );\n  sqlite3OsClose(pFile);\n  sqlite3_free(pFile);\n}\n\n/*\n** This function is a wrapper around the OS specific implementation of\n** sqlite3_os_init(). The purpose of the wrapper is to provide the\n** ability to simulate a malloc failure, so that the handling of an\n** error in sqlite3_os_init() by the upper layers can be tested.\n*/\nSQLITE_PRIVATE int sqlite3OsInit(void){\n  void *p = sqlite3_malloc(10);\n  if( p==0 ) return SQLITE_NOMEM_BKPT;\n  sqlite3_free(p);\n  return sqlite3_os_init();\n}\n\n/*\n** The list of all registered VFS implementations.\n*/\nstatic sqlite3_vfs * SQLITE_WSD vfsList = 0;\n#define vfsList GLOBAL(sqlite3_vfs *, vfsList)\n\n/*\n** Locate a VFS by name.  If no name is given, simply return the\n** first VFS on the list.\n*/\nSQLITE_API sqlite3_vfs *sqlite3_vfs_find(const char *zVfs){\n  sqlite3_vfs *pVfs = 0;\n#if SQLITE_THREADSAFE\n  sqlite3_mutex *mutex;\n#endif\n#ifndef SQLITE_OMIT_AUTOINIT\n  int rc = sqlite3_initialize();\n  if( rc ) return 0;\n#endif\n#if SQLITE_THREADSAFE\n  mutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER);\n#endif\n  sqlite3_mutex_enter(mutex);\n  for(pVfs = vfsList; pVfs; pVfs=pVfs->pNext){\n    if( zVfs==0 ) break;\n    if( strcmp(zVfs, pVfs->zName)==0 ) break;\n  }\n  sqlite3_mutex_leave(mutex);\n  return pVfs;\n}\n\n/*\n** Unlink a VFS from the linked list\n*/\nstatic void vfsUnlink(sqlite3_vfs *pVfs){\n  assert( sqlite3_mutex_held(sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER)) );\n  if( pVfs==0 ){\n    /* No-op */\n  }else if( vfsList==pVfs ){\n    vfsList = pVfs->pNext;\n  }else if( vfsList ){\n    sqlite3_vfs *p = vfsList;\n    while( p->pNext && p->pNext!=pVfs ){\n      p = p->pNext;\n    }\n    if( p->pNext==pVfs ){\n      p->pNext = pVfs->pNext;\n    }\n  }\n}\n\n/*\n** Register a VFS with the system.  It is harmless to register the same\n** VFS multiple times.  The new VFS becomes the default if makeDflt is\n** true.\n*/\nSQLITE_API int sqlite3_vfs_register(sqlite3_vfs *pVfs, int makeDflt){\n  MUTEX_LOGIC(sqlite3_mutex *mutex;)\n#ifndef SQLITE_OMIT_AUTOINIT\n  int rc = sqlite3_initialize();\n  if( rc ) return rc;\n#endif\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( pVfs==0 ) return SQLITE_MISUSE_BKPT;\n#endif\n\n  MUTEX_LOGIC( mutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER); )\n  sqlite3_mutex_enter(mutex);\n  vfsUnlink(pVfs);\n  if( makeDflt || vfsList==0 ){\n    pVfs->pNext = vfsList;\n    vfsList = pVfs;\n  }else{\n    pVfs->pNext = vfsList->pNext;\n    vfsList->pNext = pVfs;\n  }\n  assert(vfsList);\n  sqlite3_mutex_leave(mutex);\n  return SQLITE_OK;\n}\n\n/*\n** Unregister a VFS so that it is no longer accessible.\n*/\nSQLITE_API int sqlite3_vfs_unregister(sqlite3_vfs *pVfs){\n  MUTEX_LOGIC(sqlite3_mutex *mutex;)\n#ifndef SQLITE_OMIT_AUTOINIT\n  int rc = sqlite3_initialize();\n  if( rc ) return rc;\n#endif\n  MUTEX_LOGIC( mutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER); )\n  sqlite3_mutex_enter(mutex);\n  vfsUnlink(pVfs);\n  sqlite3_mutex_leave(mutex);\n  return SQLITE_OK;\n}\n\n/************** End of os.c **************************************************/\n/************** Begin file fault.c *******************************************/\n/*\n** 2008 Jan 22\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n**\n** This file contains code to support the concept of \"benign\" \n** malloc failures (when the xMalloc() or xRealloc() method of the\n** sqlite3_mem_methods structure fails to allocate a block of memory\n** and returns 0). \n**\n** Most malloc failures are non-benign. After they occur, SQLite\n** abandons the current operation and returns an error code (usually\n** SQLITE_NOMEM) to the user. However, sometimes a fault is not necessarily\n** fatal. For example, if a malloc fails while resizing a hash table, this \n** is completely recoverable simply by not carrying out the resize. The \n** hash table will continue to function normally.  So a malloc failure \n** during a hash table resize is a benign fault.\n*/\n\n/* #include \"sqliteInt.h\" */\n\n#ifndef SQLITE_UNTESTABLE\n\n/*\n** Global variables.\n*/\ntypedef struct BenignMallocHooks BenignMallocHooks;\nstatic SQLITE_WSD struct BenignMallocHooks {\n  void (*xBenignBegin)(void);\n  void (*xBenignEnd)(void);\n} sqlite3Hooks = { 0, 0 };\n\n/* The \"wsdHooks\" macro will resolve to the appropriate BenignMallocHooks\n** structure.  If writable static data is unsupported on the target,\n** we have to locate the state vector at run-time.  In the more common\n** case where writable static data is supported, wsdHooks can refer directly\n** to the \"sqlite3Hooks\" state vector declared above.\n*/\n#ifdef SQLITE_OMIT_WSD\n# define wsdHooksInit \\\n  BenignMallocHooks *x = &GLOBAL(BenignMallocHooks,sqlite3Hooks)\n# define wsdHooks x[0]\n#else\n# define wsdHooksInit\n# define wsdHooks sqlite3Hooks\n#endif\n\n\n/*\n** Register hooks to call when sqlite3BeginBenignMalloc() and\n** sqlite3EndBenignMalloc() are called, respectively.\n*/\nSQLITE_PRIVATE void sqlite3BenignMallocHooks(\n  void (*xBenignBegin)(void),\n  void (*xBenignEnd)(void)\n){\n  wsdHooksInit;\n  wsdHooks.xBenignBegin = xBenignBegin;\n  wsdHooks.xBenignEnd = xBenignEnd;\n}\n\n/*\n** This (sqlite3EndBenignMalloc()) is called by SQLite code to indicate that\n** subsequent malloc failures are benign. A call to sqlite3EndBenignMalloc()\n** indicates that subsequent malloc failures are non-benign.\n*/\nSQLITE_PRIVATE void sqlite3BeginBenignMalloc(void){\n  wsdHooksInit;\n  if( wsdHooks.xBenignBegin ){\n    wsdHooks.xBenignBegin();\n  }\n}\nSQLITE_PRIVATE void sqlite3EndBenignMalloc(void){\n  wsdHooksInit;\n  if( wsdHooks.xBenignEnd ){\n    wsdHooks.xBenignEnd();\n  }\n}\n\n#endif   /* #ifndef SQLITE_UNTESTABLE */\n\n/************** End of fault.c ***********************************************/\n/************** Begin file mem0.c ********************************************/\n/*\n** 2008 October 28\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n**\n** This file contains a no-op memory allocation drivers for use when\n** SQLITE_ZERO_MALLOC is defined.  The allocation drivers implemented\n** here always fail.  SQLite will not operate with these drivers.  These\n** are merely placeholders.  Real drivers must be substituted using\n** sqlite3_config() before SQLite will operate.\n*/\n/* #include \"sqliteInt.h\" */\n\n/*\n** This version of the memory allocator is the default.  It is\n** used when no other memory allocator is specified using compile-time\n** macros.\n*/\n#ifdef SQLITE_ZERO_MALLOC\n\n/*\n** No-op versions of all memory allocation routines\n*/\nstatic void *sqlite3MemMalloc(int nByte){ return 0; }\nstatic void sqlite3MemFree(void *pPrior){ return; }\nstatic void *sqlite3MemRealloc(void *pPrior, int nByte){ return 0; }\nstatic int sqlite3MemSize(void *pPrior){ return 0; }\nstatic int sqlite3MemRoundup(int n){ return n; }\nstatic int sqlite3MemInit(void *NotUsed){ return SQLITE_OK; }\nstatic void sqlite3MemShutdown(void *NotUsed){ return; }\n\n/*\n** This routine is the only routine in this file with external linkage.\n**\n** Populate the low-level memory allocation function pointers in\n** sqlite3GlobalConfig.m with pointers to the routines in this file.\n*/\nSQLITE_PRIVATE void sqlite3MemSetDefault(void){\n  static const sqlite3_mem_methods defaultMethods = {\n     sqlite3MemMalloc,\n     sqlite3MemFree,\n     sqlite3MemRealloc,\n     sqlite3MemSize,\n     sqlite3MemRoundup,\n     sqlite3MemInit,\n     sqlite3MemShutdown,\n     0\n  };\n  sqlite3_config(SQLITE_CONFIG_MALLOC, &defaultMethods);\n}\n\n#endif /* SQLITE_ZERO_MALLOC */\n\n/************** End of mem0.c ************************************************/\n/************** Begin file mem1.c ********************************************/\n/*\n** 2007 August 14\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n**\n** This file contains low-level memory allocation drivers for when\n** SQLite will use the standard C-library malloc/realloc/free interface\n** to obtain the memory it needs.\n**\n** This file contains implementations of the low-level memory allocation\n** routines specified in the sqlite3_mem_methods object.  The content of\n** this file is only used if SQLITE_SYSTEM_MALLOC is defined.  The\n** SQLITE_SYSTEM_MALLOC macro is defined automatically if neither the\n** SQLITE_MEMDEBUG nor the SQLITE_WIN32_MALLOC macros are defined.  The\n** default configuration is to use memory allocation routines in this\n** file.\n**\n** C-preprocessor macro summary:\n**\n**    HAVE_MALLOC_USABLE_SIZE     The configure script sets this symbol if\n**                                the malloc_usable_size() interface exists\n**                                on the target platform.  Or, this symbol\n**                                can be set manually, if desired.\n**                                If an equivalent interface exists by\n**                                a different name, using a separate -D\n**                                option to rename it.\n**\n**    SQLITE_WITHOUT_ZONEMALLOC   Some older macs lack support for the zone\n**                                memory allocator.  Set this symbol to enable\n**                                building on older macs.\n**\n**    SQLITE_WITHOUT_MSIZE        Set this symbol to disable the use of\n**                                _msize() on windows systems.  This might\n**                                be necessary when compiling for Delphi,\n**                                for example.\n*/\n/* #include \"sqliteInt.h\" */\n\n/*\n** This version of the memory allocator is the default.  It is\n** used when no other memory allocator is specified using compile-time\n** macros.\n*/\n#ifdef SQLITE_SYSTEM_MALLOC\n#if defined(__APPLE__) && !defined(SQLITE_WITHOUT_ZONEMALLOC)\n\n/*\n** Use the zone allocator available on apple products unless the\n** SQLITE_WITHOUT_ZONEMALLOC symbol is defined.\n*/\n#include <sys/sysctl.h>\n#include <malloc/malloc.h>\n#ifdef SQLITE_MIGHT_BE_SINGLE_CORE\n#include <libkern/OSAtomic.h>\n#endif /* SQLITE_MIGHT_BE_SINGLE_CORE */\nstatic malloc_zone_t* _sqliteZone_;\n#define SQLITE_MALLOC(x) malloc_zone_malloc(_sqliteZone_, (x))\n#define SQLITE_FREE(x) malloc_zone_free(_sqliteZone_, (x));\n#define SQLITE_REALLOC(x,y) malloc_zone_realloc(_sqliteZone_, (x), (y))\n#define SQLITE_MALLOCSIZE(x) \\\n        (_sqliteZone_ ? _sqliteZone_->size(_sqliteZone_,x) : malloc_size(x))\n\n#else /* if not __APPLE__ */\n\n/*\n** Use standard C library malloc and free on non-Apple systems.  \n** Also used by Apple systems if SQLITE_WITHOUT_ZONEMALLOC is defined.\n*/\n#define SQLITE_MALLOC(x)             malloc(x)\n#define SQLITE_FREE(x)               free(x)\n#define SQLITE_REALLOC(x,y)          realloc((x),(y))\n\n/*\n** The malloc.h header file is needed for malloc_usable_size() function\n** on some systems (e.g. Linux).\n*/\n#if HAVE_MALLOC_H && HAVE_MALLOC_USABLE_SIZE\n#  define SQLITE_USE_MALLOC_H 1\n#  define SQLITE_USE_MALLOC_USABLE_SIZE 1\n/*\n** The MSVCRT has malloc_usable_size(), but it is called _msize().  The\n** use of _msize() is automatic, but can be disabled by compiling with\n** -DSQLITE_WITHOUT_MSIZE.  Using the _msize() function also requires\n** the malloc.h header file.\n*/\n#elif defined(_MSC_VER) && !defined(SQLITE_WITHOUT_MSIZE)\n#  define SQLITE_USE_MALLOC_H\n#  define SQLITE_USE_MSIZE\n#endif\n\n/*\n** Include the malloc.h header file, if necessary.  Also set define macro\n** SQLITE_MALLOCSIZE to the appropriate function name, which is _msize()\n** for MSVC and malloc_usable_size() for most other systems (e.g. Linux).\n** The memory size function can always be overridden manually by defining\n** the macro SQLITE_MALLOCSIZE to the desired function name.\n*/\n#if defined(SQLITE_USE_MALLOC_H)\n#  include <malloc.h>\n#  if defined(SQLITE_USE_MALLOC_USABLE_SIZE)\n#    if !defined(SQLITE_MALLOCSIZE)\n#      define SQLITE_MALLOCSIZE(x)   malloc_usable_size(x)\n#    endif\n#  elif defined(SQLITE_USE_MSIZE)\n#    if !defined(SQLITE_MALLOCSIZE)\n#      define SQLITE_MALLOCSIZE      _msize\n#    endif\n#  endif\n#endif /* defined(SQLITE_USE_MALLOC_H) */\n\n#endif /* __APPLE__ or not __APPLE__ */\n\n/*\n** Like malloc(), but remember the size of the allocation\n** so that we can find it later using sqlite3MemSize().\n**\n** For this low-level routine, we are guaranteed that nByte>0 because\n** cases of nByte<=0 will be intercepted and dealt with by higher level\n** routines.\n*/\nstatic void *sqlite3MemMalloc(int nByte){\n#ifdef SQLITE_MALLOCSIZE\n  void *p;\n  testcase( ROUND8(nByte)==nByte );\n  p = SQLITE_MALLOC( nByte );\n  if( p==0 ){\n    testcase( sqlite3GlobalConfig.xLog!=0 );\n    sqlite3_log(SQLITE_NOMEM, \"failed to allocate %u bytes of memory\", nByte);\n  }\n  return p;\n#else\n  sqlite3_int64 *p;\n  assert( nByte>0 );\n  testcase( ROUND8(nByte)!=nByte );\n  p = SQLITE_MALLOC( nByte+8 );\n  if( p ){\n    p[0] = nByte;\n    p++;\n  }else{\n    testcase( sqlite3GlobalConfig.xLog!=0 );\n    sqlite3_log(SQLITE_NOMEM, \"failed to allocate %u bytes of memory\", nByte);\n  }\n  return (void *)p;\n#endif\n}\n\n/*\n** Like free() but works for allocations obtained from sqlite3MemMalloc()\n** or sqlite3MemRealloc().\n**\n** For this low-level routine, we already know that pPrior!=0 since\n** cases where pPrior==0 will have been intecepted and dealt with\n** by higher-level routines.\n*/\nstatic void sqlite3MemFree(void *pPrior){\n#ifdef SQLITE_MALLOCSIZE\n  SQLITE_FREE(pPrior);\n#else\n  sqlite3_int64 *p = (sqlite3_int64*)pPrior;\n  assert( pPrior!=0 );\n  p--;\n  SQLITE_FREE(p);\n#endif\n}\n\n/*\n** Report the allocated size of a prior return from xMalloc()\n** or xRealloc().\n*/\nstatic int sqlite3MemSize(void *pPrior){\n#ifdef SQLITE_MALLOCSIZE\n  assert( pPrior!=0 );\n  return (int)SQLITE_MALLOCSIZE(pPrior);\n#else\n  sqlite3_int64 *p;\n  assert( pPrior!=0 );\n  p = (sqlite3_int64*)pPrior;\n  p--;\n  return (int)p[0];\n#endif\n}\n\n/*\n** Like realloc().  Resize an allocation previously obtained from\n** sqlite3MemMalloc().\n**\n** For this low-level interface, we know that pPrior!=0.  Cases where\n** pPrior==0 while have been intercepted by higher-level routine and\n** redirected to xMalloc.  Similarly, we know that nByte>0 because\n** cases where nByte<=0 will have been intercepted by higher-level\n** routines and redirected to xFree.\n*/\nstatic void *sqlite3MemRealloc(void *pPrior, int nByte){\n#ifdef SQLITE_MALLOCSIZE\n  void *p = SQLITE_REALLOC(pPrior, nByte);\n  if( p==0 ){\n    testcase( sqlite3GlobalConfig.xLog!=0 );\n    sqlite3_log(SQLITE_NOMEM,\n      \"failed memory resize %u to %u bytes\",\n      SQLITE_MALLOCSIZE(pPrior), nByte);\n  }\n  return p;\n#else\n  sqlite3_int64 *p = (sqlite3_int64*)pPrior;\n  assert( pPrior!=0 && nByte>0 );\n  assert( nByte==ROUND8(nByte) ); /* EV: R-46199-30249 */\n  p--;\n  p = SQLITE_REALLOC(p, nByte+8 );\n  if( p ){\n    p[0] = nByte;\n    p++;\n  }else{\n    testcase( sqlite3GlobalConfig.xLog!=0 );\n    sqlite3_log(SQLITE_NOMEM,\n      \"failed memory resize %u to %u bytes\",\n      sqlite3MemSize(pPrior), nByte);\n  }\n  return (void*)p;\n#endif\n}\n\n/*\n** Round up a request size to the next valid allocation size.\n*/\nstatic int sqlite3MemRoundup(int n){\n  return ROUND8(n);\n}\n\n/*\n** Initialize this module.\n*/\nstatic int sqlite3MemInit(void *NotUsed){\n#if defined(__APPLE__) && !defined(SQLITE_WITHOUT_ZONEMALLOC)\n  int cpuCount;\n  size_t len;\n  if( _sqliteZone_ ){\n    return SQLITE_OK;\n  }\n  len = sizeof(cpuCount);\n  /* One usually wants to use hw.acctivecpu for MT decisions, but not here */\n  sysctlbyname(\"hw.ncpu\", &cpuCount, &len, NULL, 0);\n  if( cpuCount>1 ){\n    /* defer MT decisions to system malloc */\n    _sqliteZone_ = malloc_default_zone();\n  }else{\n    /* only 1 core, use our own zone to contention over global locks, \n    ** e.g. we have our own dedicated locks */\n    _sqliteZone_ = malloc_create_zone(4096, 0);\n    malloc_set_zone_name(_sqliteZone_, \"Sqlite_Heap\");\n  }\n#endif /*  defined(__APPLE__) && !defined(SQLITE_WITHOUT_ZONEMALLOC) */\n  UNUSED_PARAMETER(NotUsed);\n  return SQLITE_OK;\n}\n\n/*\n** Deinitialize this module.\n*/\nstatic void sqlite3MemShutdown(void *NotUsed){\n  UNUSED_PARAMETER(NotUsed);\n  return;\n}\n\n/*\n** This routine is the only routine in this file with external linkage.\n**\n** Populate the low-level memory allocation function pointers in\n** sqlite3GlobalConfig.m with pointers to the routines in this file.\n*/\nSQLITE_PRIVATE void sqlite3MemSetDefault(void){\n  static const sqlite3_mem_methods defaultMethods = {\n     sqlite3MemMalloc,\n     sqlite3MemFree,\n     sqlite3MemRealloc,\n     sqlite3MemSize,\n     sqlite3MemRoundup,\n     sqlite3MemInit,\n     sqlite3MemShutdown,\n     0\n  };\n  sqlite3_config(SQLITE_CONFIG_MALLOC, &defaultMethods);\n}\n\n#endif /* SQLITE_SYSTEM_MALLOC */\n\n/************** End of mem1.c ************************************************/\n/************** Begin file mem2.c ********************************************/\n/*\n** 2007 August 15\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n**\n** This file contains low-level memory allocation drivers for when\n** SQLite will use the standard C-library malloc/realloc/free interface\n** to obtain the memory it needs while adding lots of additional debugging\n** information to each allocation in order to help detect and fix memory\n** leaks and memory usage errors.\n**\n** This file contains implementations of the low-level memory allocation\n** routines specified in the sqlite3_mem_methods object.\n*/\n/* #include \"sqliteInt.h\" */\n\n/*\n** This version of the memory allocator is used only if the\n** SQLITE_MEMDEBUG macro is defined\n*/\n#ifdef SQLITE_MEMDEBUG\n\n/*\n** The backtrace functionality is only available with GLIBC\n*/\n#ifdef __GLIBC__\n  extern int backtrace(void**,int);\n  extern void backtrace_symbols_fd(void*const*,int,int);\n#else\n# define backtrace(A,B) 1\n# define backtrace_symbols_fd(A,B,C)\n#endif\n/* #include <stdio.h> */\n\n/*\n** Each memory allocation looks like this:\n**\n**  ------------------------------------------------------------------------\n**  | Title |  backtrace pointers |  MemBlockHdr |  allocation |  EndGuard |\n**  ------------------------------------------------------------------------\n**\n** The application code sees only a pointer to the allocation.  We have\n** to back up from the allocation pointer to find the MemBlockHdr.  The\n** MemBlockHdr tells us the size of the allocation and the number of\n** backtrace pointers.  There is also a guard word at the end of the\n** MemBlockHdr.\n*/\nstruct MemBlockHdr {\n  i64 iSize;                          /* Size of this allocation */\n  struct MemBlockHdr *pNext, *pPrev;  /* Linked list of all unfreed memory */\n  char nBacktrace;                    /* Number of backtraces on this alloc */\n  char nBacktraceSlots;               /* Available backtrace slots */\n  u8 nTitle;                          /* Bytes of title; includes '\\0' */\n  u8 eType;                           /* Allocation type code */\n  int iForeGuard;                     /* Guard word for sanity */\n};\n\n/*\n** Guard words\n*/\n#define FOREGUARD 0x80F5E153\n#define REARGUARD 0xE4676B53\n\n/*\n** Number of malloc size increments to track.\n*/\n#define NCSIZE  1000\n\n/*\n** All of the static variables used by this module are collected\n** into a single structure named \"mem\".  This is to keep the\n** static variables organized and to reduce namespace pollution\n** when this module is combined with other in the amalgamation.\n*/\nstatic struct {\n  \n  /*\n  ** Mutex to control access to the memory allocation subsystem.\n  */\n  sqlite3_mutex *mutex;\n\n  /*\n  ** Head and tail of a linked list of all outstanding allocations\n  */\n  struct MemBlockHdr *pFirst;\n  struct MemBlockHdr *pLast;\n  \n  /*\n  ** The number of levels of backtrace to save in new allocations.\n  */\n  int nBacktrace;\n  void (*xBacktrace)(int, int, void **);\n\n  /*\n  ** Title text to insert in front of each block\n  */\n  int nTitle;        /* Bytes of zTitle to save.  Includes '\\0' and padding */\n  char zTitle[100];  /* The title text */\n\n  /* \n  ** sqlite3MallocDisallow() increments the following counter.\n  ** sqlite3MallocAllow() decrements it.\n  */\n  int disallow; /* Do not allow memory allocation */\n\n  /*\n  ** Gather statistics on the sizes of memory allocations.\n  ** nAlloc[i] is the number of allocation attempts of i*8\n  ** bytes.  i==NCSIZE is the number of allocation attempts for\n  ** sizes more than NCSIZE*8 bytes.\n  */\n  int nAlloc[NCSIZE];      /* Total number of allocations */\n  int nCurrent[NCSIZE];    /* Current number of allocations */\n  int mxCurrent[NCSIZE];   /* Highwater mark for nCurrent */\n\n} mem;\n\n\n/*\n** Adjust memory usage statistics\n*/\nstatic void adjustStats(int iSize, int increment){\n  int i = ROUND8(iSize)/8;\n  if( i>NCSIZE-1 ){\n    i = NCSIZE - 1;\n  }\n  if( increment>0 ){\n    mem.nAlloc[i]++;\n    mem.nCurrent[i]++;\n    if( mem.nCurrent[i]>mem.mxCurrent[i] ){\n      mem.mxCurrent[i] = mem.nCurrent[i];\n    }\n  }else{\n    mem.nCurrent[i]--;\n    assert( mem.nCurrent[i]>=0 );\n  }\n}\n\n/*\n** Given an allocation, find the MemBlockHdr for that allocation.\n**\n** This routine checks the guards at either end of the allocation and\n** if they are incorrect it asserts.\n*/\nstatic struct MemBlockHdr *sqlite3MemsysGetHeader(void *pAllocation){\n  struct MemBlockHdr *p;\n  int *pInt;\n  u8 *pU8;\n  int nReserve;\n\n  p = (struct MemBlockHdr*)pAllocation;\n  p--;\n  assert( p->iForeGuard==(int)FOREGUARD );\n  nReserve = ROUND8(p->iSize);\n  pInt = (int*)pAllocation;\n  pU8 = (u8*)pAllocation;\n  assert( pInt[nReserve/sizeof(int)]==(int)REARGUARD );\n  /* This checks any of the \"extra\" bytes allocated due\n  ** to rounding up to an 8 byte boundary to ensure \n  ** they haven't been overwritten.\n  */\n  while( nReserve-- > p->iSize ) assert( pU8[nReserve]==0x65 );\n  return p;\n}\n\n/*\n** Return the number of bytes currently allocated at address p.\n*/\nstatic int sqlite3MemSize(void *p){\n  struct MemBlockHdr *pHdr;\n  if( !p ){\n    return 0;\n  }\n  pHdr = sqlite3MemsysGetHeader(p);\n  return (int)pHdr->iSize;\n}\n\n/*\n** Initialize the memory allocation subsystem.\n*/\nstatic int sqlite3MemInit(void *NotUsed){\n  UNUSED_PARAMETER(NotUsed);\n  assert( (sizeof(struct MemBlockHdr)&7) == 0 );\n  if( !sqlite3GlobalConfig.bMemstat ){\n    /* If memory status is enabled, then the malloc.c wrapper will already\n    ** hold the STATIC_MEM mutex when the routines here are invoked. */\n    mem.mutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MEM);\n  }\n  return SQLITE_OK;\n}\n\n/*\n** Deinitialize the memory allocation subsystem.\n*/\nstatic void sqlite3MemShutdown(void *NotUsed){\n  UNUSED_PARAMETER(NotUsed);\n  mem.mutex = 0;\n}\n\n/*\n** Round up a request size to the next valid allocation size.\n*/\nstatic int sqlite3MemRoundup(int n){\n  return ROUND8(n);\n}\n\n/*\n** Fill a buffer with pseudo-random bytes.  This is used to preset\n** the content of a new memory allocation to unpredictable values and\n** to clear the content of a freed allocation to unpredictable values.\n*/\nstatic void randomFill(char *pBuf, int nByte){\n  unsigned int x, y, r;\n  x = SQLITE_PTR_TO_INT(pBuf);\n  y = nByte | 1;\n  while( nByte >= 4 ){\n    x = (x>>1) ^ (-(int)(x&1) & 0xd0000001);\n    y = y*1103515245 + 12345;\n    r = x ^ y;\n    *(int*)pBuf = r;\n    pBuf += 4;\n    nByte -= 4;\n  }\n  while( nByte-- > 0 ){\n    x = (x>>1) ^ (-(int)(x&1) & 0xd0000001);\n    y = y*1103515245 + 12345;\n    r = x ^ y;\n    *(pBuf++) = r & 0xff;\n  }\n}\n\n/*\n** Allocate nByte bytes of memory.\n*/\nstatic void *sqlite3MemMalloc(int nByte){\n  struct MemBlockHdr *pHdr;\n  void **pBt;\n  char *z;\n  int *pInt;\n  void *p = 0;\n  int totalSize;\n  int nReserve;\n  sqlite3_mutex_enter(mem.mutex);\n  assert( mem.disallow==0 );\n  nReserve = ROUND8(nByte);\n  totalSize = nReserve + sizeof(*pHdr) + sizeof(int) +\n               mem.nBacktrace*sizeof(void*) + mem.nTitle;\n  p = malloc(totalSize);\n  if( p ){\n    z = p;\n    pBt = (void**)&z[mem.nTitle];\n    pHdr = (struct MemBlockHdr*)&pBt[mem.nBacktrace];\n    pHdr->pNext = 0;\n    pHdr->pPrev = mem.pLast;\n    if( mem.pLast ){\n      mem.pLast->pNext = pHdr;\n    }else{\n      mem.pFirst = pHdr;\n    }\n    mem.pLast = pHdr;\n    pHdr->iForeGuard = FOREGUARD;\n    pHdr->eType = MEMTYPE_HEAP;\n    pHdr->nBacktraceSlots = mem.nBacktrace;\n    pHdr->nTitle = mem.nTitle;\n    if( mem.nBacktrace ){\n      void *aAddr[40];\n      pHdr->nBacktrace = backtrace(aAddr, mem.nBacktrace+1)-1;\n      memcpy(pBt, &aAddr[1], pHdr->nBacktrace*sizeof(void*));\n      assert(pBt[0]);\n      if( mem.xBacktrace ){\n        mem.xBacktrace(nByte, pHdr->nBacktrace-1, &aAddr[1]);\n      }\n    }else{\n      pHdr->nBacktrace = 0;\n    }\n    if( mem.nTitle ){\n      memcpy(z, mem.zTitle, mem.nTitle);\n    }\n    pHdr->iSize = nByte;\n    adjustStats(nByte, +1);\n    pInt = (int*)&pHdr[1];\n    pInt[nReserve/sizeof(int)] = REARGUARD;\n    randomFill((char*)pInt, nByte);\n    memset(((char*)pInt)+nByte, 0x65, nReserve-nByte);\n    p = (void*)pInt;\n  }\n  sqlite3_mutex_leave(mem.mutex);\n  return p; \n}\n\n/*\n** Free memory.\n*/\nstatic void sqlite3MemFree(void *pPrior){\n  struct MemBlockHdr *pHdr;\n  void **pBt;\n  char *z;\n  assert( sqlite3GlobalConfig.bMemstat || sqlite3GlobalConfig.bCoreMutex==0 \n       || mem.mutex!=0 );\n  pHdr = sqlite3MemsysGetHeader(pPrior);\n  pBt = (void**)pHdr;\n  pBt -= pHdr->nBacktraceSlots;\n  sqlite3_mutex_enter(mem.mutex);\n  if( pHdr->pPrev ){\n    assert( pHdr->pPrev->pNext==pHdr );\n    pHdr->pPrev->pNext = pHdr->pNext;\n  }else{\n    assert( mem.pFirst==pHdr );\n    mem.pFirst = pHdr->pNext;\n  }\n  if( pHdr->pNext ){\n    assert( pHdr->pNext->pPrev==pHdr );\n    pHdr->pNext->pPrev = pHdr->pPrev;\n  }else{\n    assert( mem.pLast==pHdr );\n    mem.pLast = pHdr->pPrev;\n  }\n  z = (char*)pBt;\n  z -= pHdr->nTitle;\n  adjustStats((int)pHdr->iSize, -1);\n  randomFill(z, sizeof(void*)*pHdr->nBacktraceSlots + sizeof(*pHdr) +\n                (int)pHdr->iSize + sizeof(int) + pHdr->nTitle);\n  free(z);\n  sqlite3_mutex_leave(mem.mutex);  \n}\n\n/*\n** Change the size of an existing memory allocation.\n**\n** For this debugging implementation, we *always* make a copy of the\n** allocation into a new place in memory.  In this way, if the \n** higher level code is using pointer to the old allocation, it is \n** much more likely to break and we are much more liking to find\n** the error.\n*/\nstatic void *sqlite3MemRealloc(void *pPrior, int nByte){\n  struct MemBlockHdr *pOldHdr;\n  void *pNew;\n  assert( mem.disallow==0 );\n  assert( (nByte & 7)==0 );     /* EV: R-46199-30249 */\n  pOldHdr = sqlite3MemsysGetHeader(pPrior);\n  pNew = sqlite3MemMalloc(nByte);\n  if( pNew ){\n    memcpy(pNew, pPrior, (int)(nByte<pOldHdr->iSize ? nByte : pOldHdr->iSize));\n    if( nByte>pOldHdr->iSize ){\n      randomFill(&((char*)pNew)[pOldHdr->iSize], nByte - (int)pOldHdr->iSize);\n    }\n    sqlite3MemFree(pPrior);\n  }\n  return pNew;\n}\n\n/*\n** Populate the low-level memory allocation function pointers in\n** sqlite3GlobalConfig.m with pointers to the routines in this file.\n*/\nSQLITE_PRIVATE void sqlite3MemSetDefault(void){\n  static const sqlite3_mem_methods defaultMethods = {\n     sqlite3MemMalloc,\n     sqlite3MemFree,\n     sqlite3MemRealloc,\n     sqlite3MemSize,\n     sqlite3MemRoundup,\n     sqlite3MemInit,\n     sqlite3MemShutdown,\n     0\n  };\n  sqlite3_config(SQLITE_CONFIG_MALLOC, &defaultMethods);\n}\n\n/*\n** Set the \"type\" of an allocation.\n*/\nSQLITE_PRIVATE void sqlite3MemdebugSetType(void *p, u8 eType){\n  if( p && sqlite3GlobalConfig.m.xMalloc==sqlite3MemMalloc ){\n    struct MemBlockHdr *pHdr;\n    pHdr = sqlite3MemsysGetHeader(p);\n    assert( pHdr->iForeGuard==FOREGUARD );\n    pHdr->eType = eType;\n  }\n}\n\n/*\n** Return TRUE if the mask of type in eType matches the type of the\n** allocation p.  Also return true if p==NULL.\n**\n** This routine is designed for use within an assert() statement, to\n** verify the type of an allocation.  For example:\n**\n**     assert( sqlite3MemdebugHasType(p, MEMTYPE_HEAP) );\n*/\nSQLITE_PRIVATE int sqlite3MemdebugHasType(void *p, u8 eType){\n  int rc = 1;\n  if( p && sqlite3GlobalConfig.m.xMalloc==sqlite3MemMalloc ){\n    struct MemBlockHdr *pHdr;\n    pHdr = sqlite3MemsysGetHeader(p);\n    assert( pHdr->iForeGuard==FOREGUARD );         /* Allocation is valid */\n    if( (pHdr->eType&eType)==0 ){\n      rc = 0;\n    }\n  }\n  return rc;\n}\n\n/*\n** Return TRUE if the mask of type in eType matches no bits of the type of the\n** allocation p.  Also return true if p==NULL.\n**\n** This routine is designed for use within an assert() statement, to\n** verify the type of an allocation.  For example:\n**\n**     assert( sqlite3MemdebugNoType(p, MEMTYPE_LOOKASIDE) );\n*/\nSQLITE_PRIVATE int sqlite3MemdebugNoType(void *p, u8 eType){\n  int rc = 1;\n  if( p && sqlite3GlobalConfig.m.xMalloc==sqlite3MemMalloc ){\n    struct MemBlockHdr *pHdr;\n    pHdr = sqlite3MemsysGetHeader(p);\n    assert( pHdr->iForeGuard==FOREGUARD );         /* Allocation is valid */\n    if( (pHdr->eType&eType)!=0 ){\n      rc = 0;\n    }\n  }\n  return rc;\n}\n\n/*\n** Set the number of backtrace levels kept for each allocation.\n** A value of zero turns off backtracing.  The number is always rounded\n** up to a multiple of 2.\n*/\nSQLITE_PRIVATE void sqlite3MemdebugBacktrace(int depth){\n  if( depth<0 ){ depth = 0; }\n  if( depth>20 ){ depth = 20; }\n  depth = (depth+1)&0xfe;\n  mem.nBacktrace = depth;\n}\n\nSQLITE_PRIVATE void sqlite3MemdebugBacktraceCallback(void (*xBacktrace)(int, int, void **)){\n  mem.xBacktrace = xBacktrace;\n}\n\n/*\n** Set the title string for subsequent allocations.\n*/\nSQLITE_PRIVATE void sqlite3MemdebugSettitle(const char *zTitle){\n  unsigned int n = sqlite3Strlen30(zTitle) + 1;\n  sqlite3_mutex_enter(mem.mutex);\n  if( n>=sizeof(mem.zTitle) ) n = sizeof(mem.zTitle)-1;\n  memcpy(mem.zTitle, zTitle, n);\n  mem.zTitle[n] = 0;\n  mem.nTitle = ROUND8(n);\n  sqlite3_mutex_leave(mem.mutex);\n}\n\nSQLITE_PRIVATE void sqlite3MemdebugSync(){\n  struct MemBlockHdr *pHdr;\n  for(pHdr=mem.pFirst; pHdr; pHdr=pHdr->pNext){\n    void **pBt = (void**)pHdr;\n    pBt -= pHdr->nBacktraceSlots;\n    mem.xBacktrace((int)pHdr->iSize, pHdr->nBacktrace-1, &pBt[1]);\n  }\n}\n\n/*\n** Open the file indicated and write a log of all unfreed memory \n** allocations into that log.\n*/\nSQLITE_PRIVATE void sqlite3MemdebugDump(const char *zFilename){\n  FILE *out;\n  struct MemBlockHdr *pHdr;\n  void **pBt;\n  int i;\n  out = fopen(zFilename, \"w\");\n  if( out==0 ){\n    fprintf(stderr, \"** Unable to output memory debug output log: %s **\\n\",\n                    zFilename);\n    return;\n  }\n  for(pHdr=mem.pFirst; pHdr; pHdr=pHdr->pNext){\n    char *z = (char*)pHdr;\n    z -= pHdr->nBacktraceSlots*sizeof(void*) + pHdr->nTitle;\n    fprintf(out, \"**** %lld bytes at %p from %s ****\\n\", \n            pHdr->iSize, &pHdr[1], pHdr->nTitle ? z : \"???\");\n    if( pHdr->nBacktrace ){\n      fflush(out);\n      pBt = (void**)pHdr;\n      pBt -= pHdr->nBacktraceSlots;\n      backtrace_symbols_fd(pBt, pHdr->nBacktrace, fileno(out));\n      fprintf(out, \"\\n\");\n    }\n  }\n  fprintf(out, \"COUNTS:\\n\");\n  for(i=0; i<NCSIZE-1; i++){\n    if( mem.nAlloc[i] ){\n      fprintf(out, \"   %5d: %10d %10d %10d\\n\", \n            i*8, mem.nAlloc[i], mem.nCurrent[i], mem.mxCurrent[i]);\n    }\n  }\n  if( mem.nAlloc[NCSIZE-1] ){\n    fprintf(out, \"   %5d: %10d %10d %10d\\n\",\n             NCSIZE*8-8, mem.nAlloc[NCSIZE-1],\n             mem.nCurrent[NCSIZE-1], mem.mxCurrent[NCSIZE-1]);\n  }\n  fclose(out);\n}\n\n/*\n** Return the number of times sqlite3MemMalloc() has been called.\n*/\nSQLITE_PRIVATE int sqlite3MemdebugMallocCount(){\n  int i;\n  int nTotal = 0;\n  for(i=0; i<NCSIZE; i++){\n    nTotal += mem.nAlloc[i];\n  }\n  return nTotal;\n}\n\n\n#endif /* SQLITE_MEMDEBUG */\n\n/************** End of mem2.c ************************************************/\n/************** Begin file mem3.c ********************************************/\n/*\n** 2007 October 14\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This file contains the C functions that implement a memory\n** allocation subsystem for use by SQLite. \n**\n** This version of the memory allocation subsystem omits all\n** use of malloc(). The SQLite user supplies a block of memory\n** before calling sqlite3_initialize() from which allocations\n** are made and returned by the xMalloc() and xRealloc() \n** implementations. Once sqlite3_initialize() has been called,\n** the amount of memory available to SQLite is fixed and cannot\n** be changed.\n**\n** This version of the memory allocation subsystem is included\n** in the build only if SQLITE_ENABLE_MEMSYS3 is defined.\n*/\n/* #include \"sqliteInt.h\" */\n\n/*\n** This version of the memory allocator is only built into the library\n** SQLITE_ENABLE_MEMSYS3 is defined. Defining this symbol does not\n** mean that the library will use a memory-pool by default, just that\n** it is available. The mempool allocator is activated by calling\n** sqlite3_config().\n*/\n#ifdef SQLITE_ENABLE_MEMSYS3\n\n/*\n** Maximum size (in Mem3Blocks) of a \"small\" chunk.\n*/\n#define MX_SMALL 10\n\n\n/*\n** Number of freelist hash slots\n*/\n#define N_HASH  61\n\n/*\n** A memory allocation (also called a \"chunk\") consists of two or \n** more blocks where each block is 8 bytes.  The first 8 bytes are \n** a header that is not returned to the user.\n**\n** A chunk is two or more blocks that is either checked out or\n** free.  The first block has format u.hdr.  u.hdr.size4x is 4 times the\n** size of the allocation in blocks if the allocation is free.\n** The u.hdr.size4x&1 bit is true if the chunk is checked out and\n** false if the chunk is on the freelist.  The u.hdr.size4x&2 bit\n** is true if the previous chunk is checked out and false if the\n** previous chunk is free.  The u.hdr.prevSize field is the size of\n** the previous chunk in blocks if the previous chunk is on the\n** freelist. If the previous chunk is checked out, then\n** u.hdr.prevSize can be part of the data for that chunk and should\n** not be read or written.\n**\n** We often identify a chunk by its index in mem3.aPool[].  When\n** this is done, the chunk index refers to the second block of\n** the chunk.  In this way, the first chunk has an index of 1.\n** A chunk index of 0 means \"no such chunk\" and is the equivalent\n** of a NULL pointer.\n**\n** The second block of free chunks is of the form u.list.  The\n** two fields form a double-linked list of chunks of related sizes.\n** Pointers to the head of the list are stored in mem3.aiSmall[] \n** for smaller chunks and mem3.aiHash[] for larger chunks.\n**\n** The second block of a chunk is user data if the chunk is checked \n** out.  If a chunk is checked out, the user data may extend into\n** the u.hdr.prevSize value of the following chunk.\n*/\ntypedef struct Mem3Block Mem3Block;\nstruct Mem3Block {\n  union {\n    struct {\n      u32 prevSize;   /* Size of previous chunk in Mem3Block elements */\n      u32 size4x;     /* 4x the size of current chunk in Mem3Block elements */\n    } hdr;\n    struct {\n      u32 next;       /* Index in mem3.aPool[] of next free chunk */\n      u32 prev;       /* Index in mem3.aPool[] of previous free chunk */\n    } list;\n  } u;\n};\n\n/*\n** All of the static variables used by this module are collected\n** into a single structure named \"mem3\".  This is to keep the\n** static variables organized and to reduce namespace pollution\n** when this module is combined with other in the amalgamation.\n*/\nstatic SQLITE_WSD struct Mem3Global {\n  /*\n  ** Memory available for allocation. nPool is the size of the array\n  ** (in Mem3Blocks) pointed to by aPool less 2.\n  */\n  u32 nPool;\n  Mem3Block *aPool;\n\n  /*\n  ** True if we are evaluating an out-of-memory callback.\n  */\n  int alarmBusy;\n  \n  /*\n  ** Mutex to control access to the memory allocation subsystem.\n  */\n  sqlite3_mutex *mutex;\n  \n  /*\n  ** The minimum amount of free space that we have seen.\n  */\n  u32 mnMaster;\n\n  /*\n  ** iMaster is the index of the master chunk.  Most new allocations\n  ** occur off of this chunk.  szMaster is the size (in Mem3Blocks)\n  ** of the current master.  iMaster is 0 if there is not master chunk.\n  ** The master chunk is not in either the aiHash[] or aiSmall[].\n  */\n  u32 iMaster;\n  u32 szMaster;\n\n  /*\n  ** Array of lists of free blocks according to the block size \n  ** for smaller chunks, or a hash on the block size for larger\n  ** chunks.\n  */\n  u32 aiSmall[MX_SMALL-1];   /* For sizes 2 through MX_SMALL, inclusive */\n  u32 aiHash[N_HASH];        /* For sizes MX_SMALL+1 and larger */\n} mem3 = { 97535575 };\n\n#define mem3 GLOBAL(struct Mem3Global, mem3)\n\n/*\n** Unlink the chunk at mem3.aPool[i] from list it is currently\n** on.  *pRoot is the list that i is a member of.\n*/\nstatic void memsys3UnlinkFromList(u32 i, u32 *pRoot){\n  u32 next = mem3.aPool[i].u.list.next;\n  u32 prev = mem3.aPool[i].u.list.prev;\n  assert( sqlite3_mutex_held(mem3.mutex) );\n  if( prev==0 ){\n    *pRoot = next;\n  }else{\n    mem3.aPool[prev].u.list.next = next;\n  }\n  if( next ){\n    mem3.aPool[next].u.list.prev = prev;\n  }\n  mem3.aPool[i].u.list.next = 0;\n  mem3.aPool[i].u.list.prev = 0;\n}\n\n/*\n** Unlink the chunk at index i from \n** whatever list is currently a member of.\n*/\nstatic void memsys3Unlink(u32 i){\n  u32 size, hash;\n  assert( sqlite3_mutex_held(mem3.mutex) );\n  assert( (mem3.aPool[i-1].u.hdr.size4x & 1)==0 );\n  assert( i>=1 );\n  size = mem3.aPool[i-1].u.hdr.size4x/4;\n  assert( size==mem3.aPool[i+size-1].u.hdr.prevSize );\n  assert( size>=2 );\n  if( size <= MX_SMALL ){\n    memsys3UnlinkFromList(i, &mem3.aiSmall[size-2]);\n  }else{\n    hash = size % N_HASH;\n    memsys3UnlinkFromList(i, &mem3.aiHash[hash]);\n  }\n}\n\n/*\n** Link the chunk at mem3.aPool[i] so that is on the list rooted\n** at *pRoot.\n*/\nstatic void memsys3LinkIntoList(u32 i, u32 *pRoot){\n  assert( sqlite3_mutex_held(mem3.mutex) );\n  mem3.aPool[i].u.list.next = *pRoot;\n  mem3.aPool[i].u.list.prev = 0;\n  if( *pRoot ){\n    mem3.aPool[*pRoot].u.list.prev = i;\n  }\n  *pRoot = i;\n}\n\n/*\n** Link the chunk at index i into either the appropriate\n** small chunk list, or into the large chunk hash table.\n*/\nstatic void memsys3Link(u32 i){\n  u32 size, hash;\n  assert( sqlite3_mutex_held(mem3.mutex) );\n  assert( i>=1 );\n  assert( (mem3.aPool[i-1].u.hdr.size4x & 1)==0 );\n  size = mem3.aPool[i-1].u.hdr.size4x/4;\n  assert( size==mem3.aPool[i+size-1].u.hdr.prevSize );\n  assert( size>=2 );\n  if( size <= MX_SMALL ){\n    memsys3LinkIntoList(i, &mem3.aiSmall[size-2]);\n  }else{\n    hash = size % N_HASH;\n    memsys3LinkIntoList(i, &mem3.aiHash[hash]);\n  }\n}\n\n/*\n** If the STATIC_MEM mutex is not already held, obtain it now. The mutex\n** will already be held (obtained by code in malloc.c) if\n** sqlite3GlobalConfig.bMemStat is true.\n*/\nstatic void memsys3Enter(void){\n  if( sqlite3GlobalConfig.bMemstat==0 && mem3.mutex==0 ){\n    mem3.mutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MEM);\n  }\n  sqlite3_mutex_enter(mem3.mutex);\n}\nstatic void memsys3Leave(void){\n  sqlite3_mutex_leave(mem3.mutex);\n}\n\n/*\n** Called when we are unable to satisfy an allocation of nBytes.\n*/\nstatic void memsys3OutOfMemory(int nByte){\n  if( !mem3.alarmBusy ){\n    mem3.alarmBusy = 1;\n    assert( sqlite3_mutex_held(mem3.mutex) );\n    sqlite3_mutex_leave(mem3.mutex);\n    sqlite3_release_memory(nByte);\n    sqlite3_mutex_enter(mem3.mutex);\n    mem3.alarmBusy = 0;\n  }\n}\n\n\n/*\n** Chunk i is a free chunk that has been unlinked.  Adjust its \n** size parameters for check-out and return a pointer to the \n** user portion of the chunk.\n*/\nstatic void *memsys3Checkout(u32 i, u32 nBlock){\n  u32 x;\n  assert( sqlite3_mutex_held(mem3.mutex) );\n  assert( i>=1 );\n  assert( mem3.aPool[i-1].u.hdr.size4x/4==nBlock );\n  assert( mem3.aPool[i+nBlock-1].u.hdr.prevSize==nBlock );\n  x = mem3.aPool[i-1].u.hdr.size4x;\n  mem3.aPool[i-1].u.hdr.size4x = nBlock*4 | 1 | (x&2);\n  mem3.aPool[i+nBlock-1].u.hdr.prevSize = nBlock;\n  mem3.aPool[i+nBlock-1].u.hdr.size4x |= 2;\n  return &mem3.aPool[i];\n}\n\n/*\n** Carve a piece off of the end of the mem3.iMaster free chunk.\n** Return a pointer to the new allocation.  Or, if the master chunk\n** is not large enough, return 0.\n*/\nstatic void *memsys3FromMaster(u32 nBlock){\n  assert( sqlite3_mutex_held(mem3.mutex) );\n  assert( mem3.szMaster>=nBlock );\n  if( nBlock>=mem3.szMaster-1 ){\n    /* Use the entire master */\n    void *p = memsys3Checkout(mem3.iMaster, mem3.szMaster);\n    mem3.iMaster = 0;\n    mem3.szMaster = 0;\n    mem3.mnMaster = 0;\n    return p;\n  }else{\n    /* Split the master block.  Return the tail. */\n    u32 newi, x;\n    newi = mem3.iMaster + mem3.szMaster - nBlock;\n    assert( newi > mem3.iMaster+1 );\n    mem3.aPool[mem3.iMaster+mem3.szMaster-1].u.hdr.prevSize = nBlock;\n    mem3.aPool[mem3.iMaster+mem3.szMaster-1].u.hdr.size4x |= 2;\n    mem3.aPool[newi-1].u.hdr.size4x = nBlock*4 + 1;\n    mem3.szMaster -= nBlock;\n    mem3.aPool[newi-1].u.hdr.prevSize = mem3.szMaster;\n    x = mem3.aPool[mem3.iMaster-1].u.hdr.size4x & 2;\n    mem3.aPool[mem3.iMaster-1].u.hdr.size4x = mem3.szMaster*4 | x;\n    if( mem3.szMaster < mem3.mnMaster ){\n      mem3.mnMaster = mem3.szMaster;\n    }\n    return (void*)&mem3.aPool[newi];\n  }\n}\n\n/*\n** *pRoot is the head of a list of free chunks of the same size\n** or same size hash.  In other words, *pRoot is an entry in either\n** mem3.aiSmall[] or mem3.aiHash[].  \n**\n** This routine examines all entries on the given list and tries\n** to coalesce each entries with adjacent free chunks.  \n**\n** If it sees a chunk that is larger than mem3.iMaster, it replaces \n** the current mem3.iMaster with the new larger chunk.  In order for\n** this mem3.iMaster replacement to work, the master chunk must be\n** linked into the hash tables.  That is not the normal state of\n** affairs, of course.  The calling routine must link the master\n** chunk before invoking this routine, then must unlink the (possibly\n** changed) master chunk once this routine has finished.\n*/\nstatic void memsys3Merge(u32 *pRoot){\n  u32 iNext, prev, size, i, x;\n\n  assert( sqlite3_mutex_held(mem3.mutex) );\n  for(i=*pRoot; i>0; i=iNext){\n    iNext = mem3.aPool[i].u.list.next;\n    size = mem3.aPool[i-1].u.hdr.size4x;\n    assert( (size&1)==0 );\n    if( (size&2)==0 ){\n      memsys3UnlinkFromList(i, pRoot);\n      assert( i > mem3.aPool[i-1].u.hdr.prevSize );\n      prev = i - mem3.aPool[i-1].u.hdr.prevSize;\n      if( prev==iNext ){\n        iNext = mem3.aPool[prev].u.list.next;\n      }\n      memsys3Unlink(prev);\n      size = i + size/4 - prev;\n      x = mem3.aPool[prev-1].u.hdr.size4x & 2;\n      mem3.aPool[prev-1].u.hdr.size4x = size*4 | x;\n      mem3.aPool[prev+size-1].u.hdr.prevSize = size;\n      memsys3Link(prev);\n      i = prev;\n    }else{\n      size /= 4;\n    }\n    if( size>mem3.szMaster ){\n      mem3.iMaster = i;\n      mem3.szMaster = size;\n    }\n  }\n}\n\n/*\n** Return a block of memory of at least nBytes in size.\n** Return NULL if unable.\n**\n** This function assumes that the necessary mutexes, if any, are\n** already held by the caller. Hence \"Unsafe\".\n*/\nstatic void *memsys3MallocUnsafe(int nByte){\n  u32 i;\n  u32 nBlock;\n  u32 toFree;\n\n  assert( sqlite3_mutex_held(mem3.mutex) );\n  assert( sizeof(Mem3Block)==8 );\n  if( nByte<=12 ){\n    nBlock = 2;\n  }else{\n    nBlock = (nByte + 11)/8;\n  }\n  assert( nBlock>=2 );\n\n  /* STEP 1:\n  ** Look for an entry of the correct size in either the small\n  ** chunk table or in the large chunk hash table.  This is\n  ** successful most of the time (about 9 times out of 10).\n  */\n  if( nBlock <= MX_SMALL ){\n    i = mem3.aiSmall[nBlock-2];\n    if( i>0 ){\n      memsys3UnlinkFromList(i, &mem3.aiSmall[nBlock-2]);\n      return memsys3Checkout(i, nBlock);\n    }\n  }else{\n    int hash = nBlock % N_HASH;\n    for(i=mem3.aiHash[hash]; i>0; i=mem3.aPool[i].u.list.next){\n      if( mem3.aPool[i-1].u.hdr.size4x/4==nBlock ){\n        memsys3UnlinkFromList(i, &mem3.aiHash[hash]);\n        return memsys3Checkout(i, nBlock);\n      }\n    }\n  }\n\n  /* STEP 2:\n  ** Try to satisfy the allocation by carving a piece off of the end\n  ** of the master chunk.  This step usually works if step 1 fails.\n  */\n  if( mem3.szMaster>=nBlock ){\n    return memsys3FromMaster(nBlock);\n  }\n\n\n  /* STEP 3:  \n  ** Loop through the entire memory pool.  Coalesce adjacent free\n  ** chunks.  Recompute the master chunk as the largest free chunk.\n  ** Then try again to satisfy the allocation by carving a piece off\n  ** of the end of the master chunk.  This step happens very\n  ** rarely (we hope!)\n  */\n  for(toFree=nBlock*16; toFree<(mem3.nPool*16); toFree *= 2){\n    memsys3OutOfMemory(toFree);\n    if( mem3.iMaster ){\n      memsys3Link(mem3.iMaster);\n      mem3.iMaster = 0;\n      mem3.szMaster = 0;\n    }\n    for(i=0; i<N_HASH; i++){\n      memsys3Merge(&mem3.aiHash[i]);\n    }\n    for(i=0; i<MX_SMALL-1; i++){\n      memsys3Merge(&mem3.aiSmall[i]);\n    }\n    if( mem3.szMaster ){\n      memsys3Unlink(mem3.iMaster);\n      if( mem3.szMaster>=nBlock ){\n        return memsys3FromMaster(nBlock);\n      }\n    }\n  }\n\n  /* If none of the above worked, then we fail. */\n  return 0;\n}\n\n/*\n** Free an outstanding memory allocation.\n**\n** This function assumes that the necessary mutexes, if any, are\n** already held by the caller. Hence \"Unsafe\".\n*/\nstatic void memsys3FreeUnsafe(void *pOld){\n  Mem3Block *p = (Mem3Block*)pOld;\n  int i;\n  u32 size, x;\n  assert( sqlite3_mutex_held(mem3.mutex) );\n  assert( p>mem3.aPool && p<&mem3.aPool[mem3.nPool] );\n  i = p - mem3.aPool;\n  assert( (mem3.aPool[i-1].u.hdr.size4x&1)==1 );\n  size = mem3.aPool[i-1].u.hdr.size4x/4;\n  assert( i+size<=mem3.nPool+1 );\n  mem3.aPool[i-1].u.hdr.size4x &= ~1;\n  mem3.aPool[i+size-1].u.hdr.prevSize = size;\n  mem3.aPool[i+size-1].u.hdr.size4x &= ~2;\n  memsys3Link(i);\n\n  /* Try to expand the master using the newly freed chunk */\n  if( mem3.iMaster ){\n    while( (mem3.aPool[mem3.iMaster-1].u.hdr.size4x&2)==0 ){\n      size = mem3.aPool[mem3.iMaster-1].u.hdr.prevSize;\n      mem3.iMaster -= size;\n      mem3.szMaster += size;\n      memsys3Unlink(mem3.iMaster);\n      x = mem3.aPool[mem3.iMaster-1].u.hdr.size4x & 2;\n      mem3.aPool[mem3.iMaster-1].u.hdr.size4x = mem3.szMaster*4 | x;\n      mem3.aPool[mem3.iMaster+mem3.szMaster-1].u.hdr.prevSize = mem3.szMaster;\n    }\n    x = mem3.aPool[mem3.iMaster-1].u.hdr.size4x & 2;\n    while( (mem3.aPool[mem3.iMaster+mem3.szMaster-1].u.hdr.size4x&1)==0 ){\n      memsys3Unlink(mem3.iMaster+mem3.szMaster);\n      mem3.szMaster += mem3.aPool[mem3.iMaster+mem3.szMaster-1].u.hdr.size4x/4;\n      mem3.aPool[mem3.iMaster-1].u.hdr.size4x = mem3.szMaster*4 | x;\n      mem3.aPool[mem3.iMaster+mem3.szMaster-1].u.hdr.prevSize = mem3.szMaster;\n    }\n  }\n}\n\n/*\n** Return the size of an outstanding allocation, in bytes.  The\n** size returned omits the 8-byte header overhead.  This only\n** works for chunks that are currently checked out.\n*/\nstatic int memsys3Size(void *p){\n  Mem3Block *pBlock;\n  assert( p!=0 );\n  pBlock = (Mem3Block*)p;\n  assert( (pBlock[-1].u.hdr.size4x&1)!=0 );\n  return (pBlock[-1].u.hdr.size4x&~3)*2 - 4;\n}\n\n/*\n** Round up a request size to the next valid allocation size.\n*/\nstatic int memsys3Roundup(int n){\n  if( n<=12 ){\n    return 12;\n  }else{\n    return ((n+11)&~7) - 4;\n  }\n}\n\n/*\n** Allocate nBytes of memory.\n*/\nstatic void *memsys3Malloc(int nBytes){\n  sqlite3_int64 *p;\n  assert( nBytes>0 );          /* malloc.c filters out 0 byte requests */\n  memsys3Enter();\n  p = memsys3MallocUnsafe(nBytes);\n  memsys3Leave();\n  return (void*)p; \n}\n\n/*\n** Free memory.\n*/\nstatic void memsys3Free(void *pPrior){\n  assert( pPrior );\n  memsys3Enter();\n  memsys3FreeUnsafe(pPrior);\n  memsys3Leave();\n}\n\n/*\n** Change the size of an existing memory allocation\n*/\nstatic void *memsys3Realloc(void *pPrior, int nBytes){\n  int nOld;\n  void *p;\n  if( pPrior==0 ){\n    return sqlite3_malloc(nBytes);\n  }\n  if( nBytes<=0 ){\n    sqlite3_free(pPrior);\n    return 0;\n  }\n  nOld = memsys3Size(pPrior);\n  if( nBytes<=nOld && nBytes>=nOld-128 ){\n    return pPrior;\n  }\n  memsys3Enter();\n  p = memsys3MallocUnsafe(nBytes);\n  if( p ){\n    if( nOld<nBytes ){\n      memcpy(p, pPrior, nOld);\n    }else{\n      memcpy(p, pPrior, nBytes);\n    }\n    memsys3FreeUnsafe(pPrior);\n  }\n  memsys3Leave();\n  return p;\n}\n\n/*\n** Initialize this module.\n*/\nstatic int memsys3Init(void *NotUsed){\n  UNUSED_PARAMETER(NotUsed);\n  if( !sqlite3GlobalConfig.pHeap ){\n    return SQLITE_ERROR;\n  }\n\n  /* Store a pointer to the memory block in global structure mem3. */\n  assert( sizeof(Mem3Block)==8 );\n  mem3.aPool = (Mem3Block *)sqlite3GlobalConfig.pHeap;\n  mem3.nPool = (sqlite3GlobalConfig.nHeap / sizeof(Mem3Block)) - 2;\n\n  /* Initialize the master block. */\n  mem3.szMaster = mem3.nPool;\n  mem3.mnMaster = mem3.szMaster;\n  mem3.iMaster = 1;\n  mem3.aPool[0].u.hdr.size4x = (mem3.szMaster<<2) + 2;\n  mem3.aPool[mem3.nPool].u.hdr.prevSize = mem3.nPool;\n  mem3.aPool[mem3.nPool].u.hdr.size4x = 1;\n\n  return SQLITE_OK;\n}\n\n/*\n** Deinitialize this module.\n*/\nstatic void memsys3Shutdown(void *NotUsed){\n  UNUSED_PARAMETER(NotUsed);\n  mem3.mutex = 0;\n  return;\n}\n\n\n\n/*\n** Open the file indicated and write a log of all unfreed memory \n** allocations into that log.\n*/\nSQLITE_PRIVATE void sqlite3Memsys3Dump(const char *zFilename){\n#ifdef SQLITE_DEBUG\n  FILE *out;\n  u32 i, j;\n  u32 size;\n  if( zFilename==0 || zFilename[0]==0 ){\n    out = stdout;\n  }else{\n    out = fopen(zFilename, \"w\");\n    if( out==0 ){\n      fprintf(stderr, \"** Unable to output memory debug output log: %s **\\n\",\n                      zFilename);\n      return;\n    }\n  }\n  memsys3Enter();\n  fprintf(out, \"CHUNKS:\\n\");\n  for(i=1; i<=mem3.nPool; i+=size/4){\n    size = mem3.aPool[i-1].u.hdr.size4x;\n    if( size/4<=1 ){\n      fprintf(out, \"%p size error\\n\", &mem3.aPool[i]);\n      assert( 0 );\n      break;\n    }\n    if( (size&1)==0 && mem3.aPool[i+size/4-1].u.hdr.prevSize!=size/4 ){\n      fprintf(out, \"%p tail size does not match\\n\", &mem3.aPool[i]);\n      assert( 0 );\n      break;\n    }\n    if( ((mem3.aPool[i+size/4-1].u.hdr.size4x&2)>>1)!=(size&1) ){\n      fprintf(out, \"%p tail checkout bit is incorrect\\n\", &mem3.aPool[i]);\n      assert( 0 );\n      break;\n    }\n    if( size&1 ){\n      fprintf(out, \"%p %6d bytes checked out\\n\", &mem3.aPool[i], (size/4)*8-8);\n    }else{\n      fprintf(out, \"%p %6d bytes free%s\\n\", &mem3.aPool[i], (size/4)*8-8,\n                  i==mem3.iMaster ? \" **master**\" : \"\");\n    }\n  }\n  for(i=0; i<MX_SMALL-1; i++){\n    if( mem3.aiSmall[i]==0 ) continue;\n    fprintf(out, \"small(%2d):\", i);\n    for(j = mem3.aiSmall[i]; j>0; j=mem3.aPool[j].u.list.next){\n      fprintf(out, \" %p(%d)\", &mem3.aPool[j],\n              (mem3.aPool[j-1].u.hdr.size4x/4)*8-8);\n    }\n    fprintf(out, \"\\n\"); \n  }\n  for(i=0; i<N_HASH; i++){\n    if( mem3.aiHash[i]==0 ) continue;\n    fprintf(out, \"hash(%2d):\", i);\n    for(j = mem3.aiHash[i]; j>0; j=mem3.aPool[j].u.list.next){\n      fprintf(out, \" %p(%d)\", &mem3.aPool[j],\n              (mem3.aPool[j-1].u.hdr.size4x/4)*8-8);\n    }\n    fprintf(out, \"\\n\"); \n  }\n  fprintf(out, \"master=%d\\n\", mem3.iMaster);\n  fprintf(out, \"nowUsed=%d\\n\", mem3.nPool*8 - mem3.szMaster*8);\n  fprintf(out, \"mxUsed=%d\\n\", mem3.nPool*8 - mem3.mnMaster*8);\n  sqlite3_mutex_leave(mem3.mutex);\n  if( out==stdout ){\n    fflush(stdout);\n  }else{\n    fclose(out);\n  }\n#else\n  UNUSED_PARAMETER(zFilename);\n#endif\n}\n\n/*\n** This routine is the only routine in this file with external \n** linkage.\n**\n** Populate the low-level memory allocation function pointers in\n** sqlite3GlobalConfig.m with pointers to the routines in this file. The\n** arguments specify the block of memory to manage.\n**\n** This routine is only called by sqlite3_config(), and therefore\n** is not required to be threadsafe (it is not).\n*/\nSQLITE_PRIVATE const sqlite3_mem_methods *sqlite3MemGetMemsys3(void){\n  static const sqlite3_mem_methods mempoolMethods = {\n     memsys3Malloc,\n     memsys3Free,\n     memsys3Realloc,\n     memsys3Size,\n     memsys3Roundup,\n     memsys3Init,\n     memsys3Shutdown,\n     0\n  };\n  return &mempoolMethods;\n}\n\n#endif /* SQLITE_ENABLE_MEMSYS3 */\n\n/************** End of mem3.c ************************************************/\n/************** Begin file mem5.c ********************************************/\n/*\n** 2007 October 14\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This file contains the C functions that implement a memory\n** allocation subsystem for use by SQLite. \n**\n** This version of the memory allocation subsystem omits all\n** use of malloc(). The application gives SQLite a block of memory\n** before calling sqlite3_initialize() from which allocations\n** are made and returned by the xMalloc() and xRealloc() \n** implementations. Once sqlite3_initialize() has been called,\n** the amount of memory available to SQLite is fixed and cannot\n** be changed.\n**\n** This version of the memory allocation subsystem is included\n** in the build only if SQLITE_ENABLE_MEMSYS5 is defined.\n**\n** This memory allocator uses the following algorithm:\n**\n**   1.  All memory allocation sizes are rounded up to a power of 2.\n**\n**   2.  If two adjacent free blocks are the halves of a larger block,\n**       then the two blocks are coalesced into the single larger block.\n**\n**   3.  New memory is allocated from the first available free block.\n**\n** This algorithm is described in: J. M. Robson. \"Bounds for Some Functions\n** Concerning Dynamic Storage Allocation\". Journal of the Association for\n** Computing Machinery, Volume 21, Number 8, July 1974, pages 491-499.\n** \n** Let n be the size of the largest allocation divided by the minimum\n** allocation size (after rounding all sizes up to a power of 2.)  Let M\n** be the maximum amount of memory ever outstanding at one time.  Let\n** N be the total amount of memory available for allocation.  Robson\n** proved that this memory allocator will never breakdown due to \n** fragmentation as long as the following constraint holds:\n**\n**      N >=  M*(1 + log2(n)/2) - n + 1\n**\n** The sqlite3_status() logic tracks the maximum values of n and M so\n** that an application can, at any time, verify this constraint.\n*/\n/* #include \"sqliteInt.h\" */\n\n/*\n** This version of the memory allocator is used only when \n** SQLITE_ENABLE_MEMSYS5 is defined.\n*/\n#ifdef SQLITE_ENABLE_MEMSYS5\n\n/*\n** A minimum allocation is an instance of the following structure.\n** Larger allocations are an array of these structures where the\n** size of the array is a power of 2.\n**\n** The size of this object must be a power of two.  That fact is\n** verified in memsys5Init().\n*/\ntypedef struct Mem5Link Mem5Link;\nstruct Mem5Link {\n  int next;       /* Index of next free chunk */\n  int prev;       /* Index of previous free chunk */\n};\n\n/*\n** Maximum size of any allocation is ((1<<LOGMAX)*mem5.szAtom). Since\n** mem5.szAtom is always at least 8 and 32-bit integers are used,\n** it is not actually possible to reach this limit.\n*/\n#define LOGMAX 30\n\n/*\n** Masks used for mem5.aCtrl[] elements.\n*/\n#define CTRL_LOGSIZE  0x1f    /* Log2 Size of this block */\n#define CTRL_FREE     0x20    /* True if not checked out */\n\n/*\n** All of the static variables used by this module are collected\n** into a single structure named \"mem5\".  This is to keep the\n** static variables organized and to reduce namespace pollution\n** when this module is combined with other in the amalgamation.\n*/\nstatic SQLITE_WSD struct Mem5Global {\n  /*\n  ** Memory available for allocation\n  */\n  int szAtom;      /* Smallest possible allocation in bytes */\n  int nBlock;      /* Number of szAtom sized blocks in zPool */\n  u8 *zPool;       /* Memory available to be allocated */\n  \n  /*\n  ** Mutex to control access to the memory allocation subsystem.\n  */\n  sqlite3_mutex *mutex;\n\n#if defined(SQLITE_DEBUG) || defined(SQLITE_TEST)\n  /*\n  ** Performance statistics\n  */\n  u64 nAlloc;         /* Total number of calls to malloc */\n  u64 totalAlloc;     /* Total of all malloc calls - includes internal frag */\n  u64 totalExcess;    /* Total internal fragmentation */\n  u32 currentOut;     /* Current checkout, including internal fragmentation */\n  u32 currentCount;   /* Current number of distinct checkouts */\n  u32 maxOut;         /* Maximum instantaneous currentOut */\n  u32 maxCount;       /* Maximum instantaneous currentCount */\n  u32 maxRequest;     /* Largest allocation (exclusive of internal frag) */\n#endif\n  \n  /*\n  ** Lists of free blocks.  aiFreelist[0] is a list of free blocks of\n  ** size mem5.szAtom.  aiFreelist[1] holds blocks of size szAtom*2.\n  ** aiFreelist[2] holds free blocks of size szAtom*4.  And so forth.\n  */\n  int aiFreelist[LOGMAX+1];\n\n  /*\n  ** Space for tracking which blocks are checked out and the size\n  ** of each block.  One byte per block.\n  */\n  u8 *aCtrl;\n\n} mem5;\n\n/*\n** Access the static variable through a macro for SQLITE_OMIT_WSD.\n*/\n#define mem5 GLOBAL(struct Mem5Global, mem5)\n\n/*\n** Assuming mem5.zPool is divided up into an array of Mem5Link\n** structures, return a pointer to the idx-th such link.\n*/\n#define MEM5LINK(idx) ((Mem5Link *)(&mem5.zPool[(idx)*mem5.szAtom]))\n\n/*\n** Unlink the chunk at mem5.aPool[i] from list it is currently\n** on.  It should be found on mem5.aiFreelist[iLogsize].\n*/\nstatic void memsys5Unlink(int i, int iLogsize){\n  int next, prev;\n  assert( i>=0 && i<mem5.nBlock );\n  assert( iLogsize>=0 && iLogsize<=LOGMAX );\n  assert( (mem5.aCtrl[i] & CTRL_LOGSIZE)==iLogsize );\n\n  next = MEM5LINK(i)->next;\n  prev = MEM5LINK(i)->prev;\n  if( prev<0 ){\n    mem5.aiFreelist[iLogsize] = next;\n  }else{\n    MEM5LINK(prev)->next = next;\n  }\n  if( next>=0 ){\n    MEM5LINK(next)->prev = prev;\n  }\n}\n\n/*\n** Link the chunk at mem5.aPool[i] so that is on the iLogsize\n** free list.\n*/\nstatic void memsys5Link(int i, int iLogsize){\n  int x;\n  assert( sqlite3_mutex_held(mem5.mutex) );\n  assert( i>=0 && i<mem5.nBlock );\n  assert( iLogsize>=0 && iLogsize<=LOGMAX );\n  assert( (mem5.aCtrl[i] & CTRL_LOGSIZE)==iLogsize );\n\n  x = MEM5LINK(i)->next = mem5.aiFreelist[iLogsize];\n  MEM5LINK(i)->prev = -1;\n  if( x>=0 ){\n    assert( x<mem5.nBlock );\n    MEM5LINK(x)->prev = i;\n  }\n  mem5.aiFreelist[iLogsize] = i;\n}\n\n/*\n** Obtain or release the mutex needed to access global data structures.\n*/\nstatic void memsys5Enter(void){\n  sqlite3_mutex_enter(mem5.mutex);\n}\nstatic void memsys5Leave(void){\n  sqlite3_mutex_leave(mem5.mutex);\n}\n\n/*\n** Return the size of an outstanding allocation, in bytes.\n** This only works for chunks that are currently checked out.\n*/\nstatic int memsys5Size(void *p){\n  int iSize, i;\n  assert( p!=0 );\n  i = (int)(((u8 *)p-mem5.zPool)/mem5.szAtom);\n  assert( i>=0 && i<mem5.nBlock );\n  iSize = mem5.szAtom * (1 << (mem5.aCtrl[i]&CTRL_LOGSIZE));\n  return iSize;\n}\n\n/*\n** Return a block of memory of at least nBytes in size.\n** Return NULL if unable.  Return NULL if nBytes==0.\n**\n** The caller guarantees that nByte is positive.\n**\n** The caller has obtained a mutex prior to invoking this\n** routine so there is never any chance that two or more\n** threads can be in this routine at the same time.\n*/\nstatic void *memsys5MallocUnsafe(int nByte){\n  int i;           /* Index of a mem5.aPool[] slot */\n  int iBin;        /* Index into mem5.aiFreelist[] */\n  int iFullSz;     /* Size of allocation rounded up to power of 2 */\n  int iLogsize;    /* Log2 of iFullSz/POW2_MIN */\n\n  /* nByte must be a positive */\n  assert( nByte>0 );\n\n  /* No more than 1GiB per allocation */\n  if( nByte > 0x40000000 ) return 0;\n\n#if defined(SQLITE_DEBUG) || defined(SQLITE_TEST)\n  /* Keep track of the maximum allocation request.  Even unfulfilled\n  ** requests are counted */\n  if( (u32)nByte>mem5.maxRequest ){\n    mem5.maxRequest = nByte;\n  }\n#endif\n\n\n  /* Round nByte up to the next valid power of two */\n  for(iFullSz=mem5.szAtom,iLogsize=0; iFullSz<nByte; iFullSz*=2,iLogsize++){}\n\n  /* Make sure mem5.aiFreelist[iLogsize] contains at least one free\n  ** block.  If not, then split a block of the next larger power of\n  ** two in order to create a new free block of size iLogsize.\n  */\n  for(iBin=iLogsize; iBin<=LOGMAX && mem5.aiFreelist[iBin]<0; iBin++){}\n  if( iBin>LOGMAX ){\n    testcase( sqlite3GlobalConfig.xLog!=0 );\n    sqlite3_log(SQLITE_NOMEM, \"failed to allocate %u bytes\", nByte);\n    return 0;\n  }\n  i = mem5.aiFreelist[iBin];\n  memsys5Unlink(i, iBin);\n  while( iBin>iLogsize ){\n    int newSize;\n\n    iBin--;\n    newSize = 1 << iBin;\n    mem5.aCtrl[i+newSize] = CTRL_FREE | iBin;\n    memsys5Link(i+newSize, iBin);\n  }\n  mem5.aCtrl[i] = iLogsize;\n\n#if defined(SQLITE_DEBUG) || defined(SQLITE_TEST)\n  /* Update allocator performance statistics. */\n  mem5.nAlloc++;\n  mem5.totalAlloc += iFullSz;\n  mem5.totalExcess += iFullSz - nByte;\n  mem5.currentCount++;\n  mem5.currentOut += iFullSz;\n  if( mem5.maxCount<mem5.currentCount ) mem5.maxCount = mem5.currentCount;\n  if( mem5.maxOut<mem5.currentOut ) mem5.maxOut = mem5.currentOut;\n#endif\n\n#ifdef SQLITE_DEBUG\n  /* Make sure the allocated memory does not assume that it is set to zero\n  ** or retains a value from a previous allocation */\n  memset(&mem5.zPool[i*mem5.szAtom], 0xAA, iFullSz);\n#endif\n\n  /* Return a pointer to the allocated memory. */\n  return (void*)&mem5.zPool[i*mem5.szAtom];\n}\n\n/*\n** Free an outstanding memory allocation.\n*/\nstatic void memsys5FreeUnsafe(void *pOld){\n  u32 size, iLogsize;\n  int iBlock;\n\n  /* Set iBlock to the index of the block pointed to by pOld in \n  ** the array of mem5.szAtom byte blocks pointed to by mem5.zPool.\n  */\n  iBlock = (int)(((u8 *)pOld-mem5.zPool)/mem5.szAtom);\n\n  /* Check that the pointer pOld points to a valid, non-free block. */\n  assert( iBlock>=0 && iBlock<mem5.nBlock );\n  assert( ((u8 *)pOld-mem5.zPool)%mem5.szAtom==0 );\n  assert( (mem5.aCtrl[iBlock] & CTRL_FREE)==0 );\n\n  iLogsize = mem5.aCtrl[iBlock] & CTRL_LOGSIZE;\n  size = 1<<iLogsize;\n  assert( iBlock+size-1<(u32)mem5.nBlock );\n\n  mem5.aCtrl[iBlock] |= CTRL_FREE;\n  mem5.aCtrl[iBlock+size-1] |= CTRL_FREE;\n\n#if defined(SQLITE_DEBUG) || defined(SQLITE_TEST)\n  assert( mem5.currentCount>0 );\n  assert( mem5.currentOut>=(size*mem5.szAtom) );\n  mem5.currentCount--;\n  mem5.currentOut -= size*mem5.szAtom;\n  assert( mem5.currentOut>0 || mem5.currentCount==0 );\n  assert( mem5.currentCount>0 || mem5.currentOut==0 );\n#endif\n\n  mem5.aCtrl[iBlock] = CTRL_FREE | iLogsize;\n  while( ALWAYS(iLogsize<LOGMAX) ){\n    int iBuddy;\n    if( (iBlock>>iLogsize) & 1 ){\n      iBuddy = iBlock - size;\n      assert( iBuddy>=0 );\n    }else{\n      iBuddy = iBlock + size;\n      if( iBuddy>=mem5.nBlock ) break;\n    }\n    if( mem5.aCtrl[iBuddy]!=(CTRL_FREE | iLogsize) ) break;\n    memsys5Unlink(iBuddy, iLogsize);\n    iLogsize++;\n    if( iBuddy<iBlock ){\n      mem5.aCtrl[iBuddy] = CTRL_FREE | iLogsize;\n      mem5.aCtrl[iBlock] = 0;\n      iBlock = iBuddy;\n    }else{\n      mem5.aCtrl[iBlock] = CTRL_FREE | iLogsize;\n      mem5.aCtrl[iBuddy] = 0;\n    }\n    size *= 2;\n  }\n\n#ifdef SQLITE_DEBUG\n  /* Overwrite freed memory with the 0x55 bit pattern to verify that it is\n  ** not used after being freed */\n  memset(&mem5.zPool[iBlock*mem5.szAtom], 0x55, size);\n#endif\n\n  memsys5Link(iBlock, iLogsize);\n}\n\n/*\n** Allocate nBytes of memory.\n*/\nstatic void *memsys5Malloc(int nBytes){\n  sqlite3_int64 *p = 0;\n  if( nBytes>0 ){\n    memsys5Enter();\n    p = memsys5MallocUnsafe(nBytes);\n    memsys5Leave();\n  }\n  return (void*)p; \n}\n\n/*\n** Free memory.\n**\n** The outer layer memory allocator prevents this routine from\n** being called with pPrior==0.\n*/\nstatic void memsys5Free(void *pPrior){\n  assert( pPrior!=0 );\n  memsys5Enter();\n  memsys5FreeUnsafe(pPrior);\n  memsys5Leave();  \n}\n\n/*\n** Change the size of an existing memory allocation.\n**\n** The outer layer memory allocator prevents this routine from\n** being called with pPrior==0.  \n**\n** nBytes is always a value obtained from a prior call to\n** memsys5Round().  Hence nBytes is always a non-negative power\n** of two.  If nBytes==0 that means that an oversize allocation\n** (an allocation larger than 0x40000000) was requested and this\n** routine should return 0 without freeing pPrior.\n*/\nstatic void *memsys5Realloc(void *pPrior, int nBytes){\n  int nOld;\n  void *p;\n  assert( pPrior!=0 );\n  assert( (nBytes&(nBytes-1))==0 );  /* EV: R-46199-30249 */\n  assert( nBytes>=0 );\n  if( nBytes==0 ){\n    return 0;\n  }\n  nOld = memsys5Size(pPrior);\n  if( nBytes<=nOld ){\n    return pPrior;\n  }\n  p = memsys5Malloc(nBytes);\n  if( p ){\n    memcpy(p, pPrior, nOld);\n    memsys5Free(pPrior);\n  }\n  return p;\n}\n\n/*\n** Round up a request size to the next valid allocation size.  If\n** the allocation is too large to be handled by this allocation system,\n** return 0.\n**\n** All allocations must be a power of two and must be expressed by a\n** 32-bit signed integer.  Hence the largest allocation is 0x40000000\n** or 1073741824 bytes.\n*/\nstatic int memsys5Roundup(int n){\n  int iFullSz;\n  if( n > 0x40000000 ) return 0;\n  for(iFullSz=mem5.szAtom; iFullSz<n; iFullSz *= 2);\n  return iFullSz;\n}\n\n/*\n** Return the ceiling of the logarithm base 2 of iValue.\n**\n** Examples:   memsys5Log(1) -> 0\n**             memsys5Log(2) -> 1\n**             memsys5Log(4) -> 2\n**             memsys5Log(5) -> 3\n**             memsys5Log(8) -> 3\n**             memsys5Log(9) -> 4\n*/\nstatic int memsys5Log(int iValue){\n  int iLog;\n  for(iLog=0; (iLog<(int)((sizeof(int)*8)-1)) && (1<<iLog)<iValue; iLog++);\n  return iLog;\n}\n\n/*\n** Initialize the memory allocator.\n**\n** This routine is not threadsafe.  The caller must be holding a mutex\n** to prevent multiple threads from entering at the same time.\n*/\nstatic int memsys5Init(void *NotUsed){\n  int ii;            /* Loop counter */\n  int nByte;         /* Number of bytes of memory available to this allocator */\n  u8 *zByte;         /* Memory usable by this allocator */\n  int nMinLog;       /* Log base 2 of minimum allocation size in bytes */\n  int iOffset;       /* An offset into mem5.aCtrl[] */\n\n  UNUSED_PARAMETER(NotUsed);\n\n  /* For the purposes of this routine, disable the mutex */\n  mem5.mutex = 0;\n\n  /* The size of a Mem5Link object must be a power of two.  Verify that\n  ** this is case.\n  */\n  assert( (sizeof(Mem5Link)&(sizeof(Mem5Link)-1))==0 );\n\n  nByte = sqlite3GlobalConfig.nHeap;\n  zByte = (u8*)sqlite3GlobalConfig.pHeap;\n  assert( zByte!=0 );  /* sqlite3_config() does not allow otherwise */\n\n  /* boundaries on sqlite3GlobalConfig.mnReq are enforced in sqlite3_config() */\n  nMinLog = memsys5Log(sqlite3GlobalConfig.mnReq);\n  mem5.szAtom = (1<<nMinLog);\n  while( (int)sizeof(Mem5Link)>mem5.szAtom ){\n    mem5.szAtom = mem5.szAtom << 1;\n  }\n\n  mem5.nBlock = (nByte / (mem5.szAtom+sizeof(u8)));\n  mem5.zPool = zByte;\n  mem5.aCtrl = (u8 *)&mem5.zPool[mem5.nBlock*mem5.szAtom];\n\n  for(ii=0; ii<=LOGMAX; ii++){\n    mem5.aiFreelist[ii] = -1;\n  }\n\n  iOffset = 0;\n  for(ii=LOGMAX; ii>=0; ii--){\n    int nAlloc = (1<<ii);\n    if( (iOffset+nAlloc)<=mem5.nBlock ){\n      mem5.aCtrl[iOffset] = ii | CTRL_FREE;\n      memsys5Link(iOffset, ii);\n      iOffset += nAlloc;\n    }\n    assert((iOffset+nAlloc)>mem5.nBlock);\n  }\n\n  /* If a mutex is required for normal operation, allocate one */\n  if( sqlite3GlobalConfig.bMemstat==0 ){\n    mem5.mutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MEM);\n  }\n\n  return SQLITE_OK;\n}\n\n/*\n** Deinitialize this module.\n*/\nstatic void memsys5Shutdown(void *NotUsed){\n  UNUSED_PARAMETER(NotUsed);\n  mem5.mutex = 0;\n  return;\n}\n\n#ifdef SQLITE_TEST\n/*\n** Open the file indicated and write a log of all unfreed memory \n** allocations into that log.\n*/\nSQLITE_PRIVATE void sqlite3Memsys5Dump(const char *zFilename){\n  FILE *out;\n  int i, j, n;\n  int nMinLog;\n\n  if( zFilename==0 || zFilename[0]==0 ){\n    out = stdout;\n  }else{\n    out = fopen(zFilename, \"w\");\n    if( out==0 ){\n      fprintf(stderr, \"** Unable to output memory debug output log: %s **\\n\",\n                      zFilename);\n      return;\n    }\n  }\n  memsys5Enter();\n  nMinLog = memsys5Log(mem5.szAtom);\n  for(i=0; i<=LOGMAX && i+nMinLog<32; i++){\n    for(n=0, j=mem5.aiFreelist[i]; j>=0; j = MEM5LINK(j)->next, n++){}\n    fprintf(out, \"freelist items of size %d: %d\\n\", mem5.szAtom << i, n);\n  }\n  fprintf(out, \"mem5.nAlloc       = %llu\\n\", mem5.nAlloc);\n  fprintf(out, \"mem5.totalAlloc   = %llu\\n\", mem5.totalAlloc);\n  fprintf(out, \"mem5.totalExcess  = %llu\\n\", mem5.totalExcess);\n  fprintf(out, \"mem5.currentOut   = %u\\n\", mem5.currentOut);\n  fprintf(out, \"mem5.currentCount = %u\\n\", mem5.currentCount);\n  fprintf(out, \"mem5.maxOut       = %u\\n\", mem5.maxOut);\n  fprintf(out, \"mem5.maxCount     = %u\\n\", mem5.maxCount);\n  fprintf(out, \"mem5.maxRequest   = %u\\n\", mem5.maxRequest);\n  memsys5Leave();\n  if( out==stdout ){\n    fflush(stdout);\n  }else{\n    fclose(out);\n  }\n}\n#endif\n\n/*\n** This routine is the only routine in this file with external \n** linkage. It returns a pointer to a static sqlite3_mem_methods\n** struct populated with the memsys5 methods.\n*/\nSQLITE_PRIVATE const sqlite3_mem_methods *sqlite3MemGetMemsys5(void){\n  static const sqlite3_mem_methods memsys5Methods = {\n     memsys5Malloc,\n     memsys5Free,\n     memsys5Realloc,\n     memsys5Size,\n     memsys5Roundup,\n     memsys5Init,\n     memsys5Shutdown,\n     0\n  };\n  return &memsys5Methods;\n}\n\n#endif /* SQLITE_ENABLE_MEMSYS5 */\n\n/************** End of mem5.c ************************************************/\n/************** Begin file mutex.c *******************************************/\n/*\n** 2007 August 14\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This file contains the C functions that implement mutexes.\n**\n** This file contains code that is common across all mutex implementations.\n*/\n/* #include \"sqliteInt.h\" */\n\n#if defined(SQLITE_DEBUG) && !defined(SQLITE_MUTEX_OMIT)\n/*\n** For debugging purposes, record when the mutex subsystem is initialized\n** and uninitialized so that we can assert() if there is an attempt to\n** allocate a mutex while the system is uninitialized.\n*/\nstatic SQLITE_WSD int mutexIsInit = 0;\n#endif /* SQLITE_DEBUG && !defined(SQLITE_MUTEX_OMIT) */\n\n\n#ifndef SQLITE_MUTEX_OMIT\n\n#ifdef SQLITE_ENABLE_MULTITHREADED_CHECKS\n/*\n** This block (enclosed by SQLITE_ENABLE_MULTITHREADED_CHECKS) contains\n** the implementation of a wrapper around the system default mutex\n** implementation (sqlite3DefaultMutex()). \n**\n** Most calls are passed directly through to the underlying default\n** mutex implementation. Except, if a mutex is configured by calling\n** sqlite3MutexWarnOnContention() on it, then if contention is ever\n** encountered within xMutexEnter() a warning is emitted via sqlite3_log().\n**\n** This type of mutex is used as the database handle mutex when testing\n** apps that usually use SQLITE_CONFIG_MULTITHREAD mode.\n*/\n\n/* \n** Type for all mutexes used when SQLITE_ENABLE_MULTITHREADED_CHECKS\n** is defined. Variable CheckMutex.mutex is a pointer to the real mutex\n** allocated by the system mutex implementation. Variable iType is usually set\n** to the type of mutex requested - SQLITE_MUTEX_RECURSIVE, SQLITE_MUTEX_FAST\n** or one of the static mutex identifiers. Or, if this is a recursive mutex\n** that has been configured using sqlite3MutexWarnOnContention(), it is\n** set to SQLITE_MUTEX_WARNONCONTENTION.\n*/\ntypedef struct CheckMutex CheckMutex;\nstruct CheckMutex {\n  int iType;\n  sqlite3_mutex *mutex;\n};\n\n#define SQLITE_MUTEX_WARNONCONTENTION  (-1)\n\n/* \n** Pointer to real mutex methods object used by the CheckMutex\n** implementation. Set by checkMutexInit(). \n*/\nstatic SQLITE_WSD const sqlite3_mutex_methods *pGlobalMutexMethods;\n\n#ifdef SQLITE_DEBUG\nstatic int checkMutexHeld(sqlite3_mutex *p){\n  return pGlobalMutexMethods->xMutexHeld(((CheckMutex*)p)->mutex);\n}\nstatic int checkMutexNotheld(sqlite3_mutex *p){\n  return pGlobalMutexMethods->xMutexNotheld(((CheckMutex*)p)->mutex);\n}\n#endif\n\n/*\n** Initialize and deinitialize the mutex subsystem.\n*/\nstatic int checkMutexInit(void){ \n  pGlobalMutexMethods = sqlite3DefaultMutex();\n  return SQLITE_OK; \n}\nstatic int checkMutexEnd(void){ \n  pGlobalMutexMethods = 0;\n  return SQLITE_OK; \n}\n\n/*\n** Allocate a mutex.\n*/\nstatic sqlite3_mutex *checkMutexAlloc(int iType){\n  static CheckMutex staticMutexes[] = {\n    {2, 0}, {3, 0}, {4, 0}, {5, 0},\n    {6, 0}, {7, 0}, {8, 0}, {9, 0},\n    {10, 0}, {11, 0}, {12, 0}, {13, 0}\n  };\n  CheckMutex *p = 0;\n\n  assert( SQLITE_MUTEX_RECURSIVE==1 && SQLITE_MUTEX_FAST==0 );\n  if( iType<2 ){\n    p = sqlite3MallocZero(sizeof(CheckMutex));\n    if( p==0 ) return 0;\n    p->iType = iType;\n  }else{\n#ifdef SQLITE_ENABLE_API_ARMOR\n    if( iType-2>=ArraySize(staticMutexes) ){\n      (void)SQLITE_MISUSE_BKPT;\n      return 0;\n    }\n#endif\n    p = &staticMutexes[iType-2];\n  }\n\n  if( p->mutex==0 ){\n    p->mutex = pGlobalMutexMethods->xMutexAlloc(iType);\n    if( p->mutex==0 ){\n      if( iType<2 ){\n        sqlite3_free(p);\n      }\n      p = 0;\n    }\n  }\n\n  return (sqlite3_mutex*)p;\n}\n\n/*\n** Free a mutex.\n*/\nstatic void checkMutexFree(sqlite3_mutex *p){\n  assert( SQLITE_MUTEX_RECURSIVE<2 );\n  assert( SQLITE_MUTEX_FAST<2 );\n  assert( SQLITE_MUTEX_WARNONCONTENTION<2 );\n\n#if SQLITE_ENABLE_API_ARMOR\n  if( ((CheckMutex*)p)->iType<2 )\n#endif\n  {\n    CheckMutex *pCheck = (CheckMutex*)p;\n    pGlobalMutexMethods->xMutexFree(pCheck->mutex);\n    sqlite3_free(pCheck);\n  }\n#ifdef SQLITE_ENABLE_API_ARMOR\n  else{\n    (void)SQLITE_MISUSE_BKPT;\n  }\n#endif\n}\n\n/*\n** Enter the mutex.\n*/\nstatic void checkMutexEnter(sqlite3_mutex *p){\n  CheckMutex *pCheck = (CheckMutex*)p;\n  if( pCheck->iType==SQLITE_MUTEX_WARNONCONTENTION ){\n    if( SQLITE_OK==pGlobalMutexMethods->xMutexTry(pCheck->mutex) ){\n      return;\n    }\n    sqlite3_log(SQLITE_MISUSE, \n        \"illegal multi-threaded access to database connection\"\n    );\n  }\n  pGlobalMutexMethods->xMutexEnter(pCheck->mutex);\n}\n\n/*\n** Enter the mutex (do not block).\n*/\nstatic int checkMutexTry(sqlite3_mutex *p){\n  CheckMutex *pCheck = (CheckMutex*)p;\n  return pGlobalMutexMethods->xMutexTry(pCheck->mutex);\n}\n\n/*\n** Leave the mutex.\n*/\nstatic void checkMutexLeave(sqlite3_mutex *p){\n  CheckMutex *pCheck = (CheckMutex*)p;\n  pGlobalMutexMethods->xMutexLeave(pCheck->mutex);\n}\n\nsqlite3_mutex_methods const *multiThreadedCheckMutex(void){\n  static const sqlite3_mutex_methods sMutex = {\n    checkMutexInit,\n    checkMutexEnd,\n    checkMutexAlloc,\n    checkMutexFree,\n    checkMutexEnter,\n    checkMutexTry,\n    checkMutexLeave,\n#ifdef SQLITE_DEBUG\n    checkMutexHeld,\n    checkMutexNotheld\n#else\n    0,\n    0\n#endif\n  };\n  return &sMutex;\n}\n\n/*\n** Mark the SQLITE_MUTEX_RECURSIVE mutex passed as the only argument as\n** one on which there should be no contention.\n*/\nSQLITE_PRIVATE void sqlite3MutexWarnOnContention(sqlite3_mutex *p){\n  if( sqlite3GlobalConfig.mutex.xMutexAlloc==checkMutexAlloc ){\n    CheckMutex *pCheck = (CheckMutex*)p;\n    assert( pCheck->iType==SQLITE_MUTEX_RECURSIVE );\n    pCheck->iType = SQLITE_MUTEX_WARNONCONTENTION;\n  }\n}\n#endif   /* ifdef SQLITE_ENABLE_MULTITHREADED_CHECKS */\n\n/*\n** Initialize the mutex system.\n*/\nSQLITE_PRIVATE int sqlite3MutexInit(void){ \n  int rc = SQLITE_OK;\n  if( !sqlite3GlobalConfig.mutex.xMutexAlloc ){\n    /* If the xMutexAlloc method has not been set, then the user did not\n    ** install a mutex implementation via sqlite3_config() prior to \n    ** sqlite3_initialize() being called. This block copies pointers to\n    ** the default implementation into the sqlite3GlobalConfig structure.\n    */\n    sqlite3_mutex_methods const *pFrom;\n    sqlite3_mutex_methods *pTo = &sqlite3GlobalConfig.mutex;\n\n    if( sqlite3GlobalConfig.bCoreMutex ){\n#ifdef SQLITE_ENABLE_MULTITHREADED_CHECKS\n      pFrom = multiThreadedCheckMutex();\n#else\n      pFrom = sqlite3DefaultMutex();\n#endif\n    }else{\n      pFrom = sqlite3NoopMutex();\n    }\n    pTo->xMutexInit = pFrom->xMutexInit;\n    pTo->xMutexEnd = pFrom->xMutexEnd;\n    pTo->xMutexFree = pFrom->xMutexFree;\n    pTo->xMutexEnter = pFrom->xMutexEnter;\n    pTo->xMutexTry = pFrom->xMutexTry;\n    pTo->xMutexLeave = pFrom->xMutexLeave;\n    pTo->xMutexHeld = pFrom->xMutexHeld;\n    pTo->xMutexNotheld = pFrom->xMutexNotheld;\n    sqlite3MemoryBarrier();\n    pTo->xMutexAlloc = pFrom->xMutexAlloc;\n  }\n  assert( sqlite3GlobalConfig.mutex.xMutexInit );\n  rc = sqlite3GlobalConfig.mutex.xMutexInit();\n\n#ifdef SQLITE_DEBUG\n  GLOBAL(int, mutexIsInit) = 1;\n#endif\n\n  return rc;\n}\n\n/*\n** Shutdown the mutex system. This call frees resources allocated by\n** sqlite3MutexInit().\n*/\nSQLITE_PRIVATE int sqlite3MutexEnd(void){\n  int rc = SQLITE_OK;\n  if( sqlite3GlobalConfig.mutex.xMutexEnd ){\n    rc = sqlite3GlobalConfig.mutex.xMutexEnd();\n  }\n\n#ifdef SQLITE_DEBUG\n  GLOBAL(int, mutexIsInit) = 0;\n#endif\n\n  return rc;\n}\n\n/*\n** Retrieve a pointer to a static mutex or allocate a new dynamic one.\n*/\nSQLITE_API sqlite3_mutex *sqlite3_mutex_alloc(int id){\n#ifndef SQLITE_OMIT_AUTOINIT\n  if( id<=SQLITE_MUTEX_RECURSIVE && sqlite3_initialize() ) return 0;\n  if( id>SQLITE_MUTEX_RECURSIVE && sqlite3MutexInit() ) return 0;\n#endif\n  assert( sqlite3GlobalConfig.mutex.xMutexAlloc );\n  return sqlite3GlobalConfig.mutex.xMutexAlloc(id);\n}\n\nSQLITE_PRIVATE sqlite3_mutex *sqlite3MutexAlloc(int id){\n  if( !sqlite3GlobalConfig.bCoreMutex ){\n    return 0;\n  }\n  assert( GLOBAL(int, mutexIsInit) );\n  assert( sqlite3GlobalConfig.mutex.xMutexAlloc );\n  return sqlite3GlobalConfig.mutex.xMutexAlloc(id);\n}\n\n/*\n** Free a dynamic mutex.\n*/\nSQLITE_API void sqlite3_mutex_free(sqlite3_mutex *p){\n  if( p ){\n    assert( sqlite3GlobalConfig.mutex.xMutexFree );\n    sqlite3GlobalConfig.mutex.xMutexFree(p);\n  }\n}\n\n/*\n** Obtain the mutex p. If some other thread already has the mutex, block\n** until it can be obtained.\n*/\nSQLITE_API void sqlite3_mutex_enter(sqlite3_mutex *p){\n  if( p ){\n    assert( sqlite3GlobalConfig.mutex.xMutexEnter );\n    sqlite3GlobalConfig.mutex.xMutexEnter(p);\n  }\n}\n\n/*\n** Obtain the mutex p. If successful, return SQLITE_OK. Otherwise, if another\n** thread holds the mutex and it cannot be obtained, return SQLITE_BUSY.\n*/\nSQLITE_API int sqlite3_mutex_try(sqlite3_mutex *p){\n  int rc = SQLITE_OK;\n  if( p ){\n    assert( sqlite3GlobalConfig.mutex.xMutexTry );\n    return sqlite3GlobalConfig.mutex.xMutexTry(p);\n  }\n  return rc;\n}\n\n/*\n** The sqlite3_mutex_leave() routine exits a mutex that was previously\n** entered by the same thread.  The behavior is undefined if the mutex \n** is not currently entered. If a NULL pointer is passed as an argument\n** this function is a no-op.\n*/\nSQLITE_API void sqlite3_mutex_leave(sqlite3_mutex *p){\n  if( p ){\n    assert( sqlite3GlobalConfig.mutex.xMutexLeave );\n    sqlite3GlobalConfig.mutex.xMutexLeave(p);\n  }\n}\n\n#ifndef NDEBUG\n/*\n** The sqlite3_mutex_held() and sqlite3_mutex_notheld() routine are\n** intended for use inside assert() statements.\n*/\nSQLITE_API int sqlite3_mutex_held(sqlite3_mutex *p){\n  assert( p==0 || sqlite3GlobalConfig.mutex.xMutexHeld );\n  return p==0 || sqlite3GlobalConfig.mutex.xMutexHeld(p);\n}\nSQLITE_API int sqlite3_mutex_notheld(sqlite3_mutex *p){\n  assert( p==0 || sqlite3GlobalConfig.mutex.xMutexNotheld );\n  return p==0 || sqlite3GlobalConfig.mutex.xMutexNotheld(p);\n}\n#endif\n\n#endif /* !defined(SQLITE_MUTEX_OMIT) */\n\n/************** End of mutex.c ***********************************************/\n/************** Begin file mutex_noop.c **************************************/\n/*\n** 2008 October 07\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This file contains the C functions that implement mutexes.\n**\n** This implementation in this file does not provide any mutual\n** exclusion and is thus suitable for use only in applications\n** that use SQLite in a single thread.  The routines defined\n** here are place-holders.  Applications can substitute working\n** mutex routines at start-time using the\n**\n**     sqlite3_config(SQLITE_CONFIG_MUTEX,...)\n**\n** interface.\n**\n** If compiled with SQLITE_DEBUG, then additional logic is inserted\n** that does error checking on mutexes to make sure they are being\n** called correctly.\n*/\n/* #include \"sqliteInt.h\" */\n\n#ifndef SQLITE_MUTEX_OMIT\n\n#ifndef SQLITE_DEBUG\n/*\n** Stub routines for all mutex methods.\n**\n** This routines provide no mutual exclusion or error checking.\n*/\nstatic int noopMutexInit(void){ return SQLITE_OK; }\nstatic int noopMutexEnd(void){ return SQLITE_OK; }\nstatic sqlite3_mutex *noopMutexAlloc(int id){ \n  UNUSED_PARAMETER(id);\n  return (sqlite3_mutex*)8; \n}\nstatic void noopMutexFree(sqlite3_mutex *p){ UNUSED_PARAMETER(p); return; }\nstatic void noopMutexEnter(sqlite3_mutex *p){ UNUSED_PARAMETER(p); return; }\nstatic int noopMutexTry(sqlite3_mutex *p){\n  UNUSED_PARAMETER(p);\n  return SQLITE_OK;\n}\nstatic void noopMutexLeave(sqlite3_mutex *p){ UNUSED_PARAMETER(p); return; }\n\nSQLITE_PRIVATE sqlite3_mutex_methods const *sqlite3NoopMutex(void){\n  static const sqlite3_mutex_methods sMutex = {\n    noopMutexInit,\n    noopMutexEnd,\n    noopMutexAlloc,\n    noopMutexFree,\n    noopMutexEnter,\n    noopMutexTry,\n    noopMutexLeave,\n\n    0,\n    0,\n  };\n\n  return &sMutex;\n}\n#endif /* !SQLITE_DEBUG */\n\n#ifdef SQLITE_DEBUG\n/*\n** In this implementation, error checking is provided for testing\n** and debugging purposes.  The mutexes still do not provide any\n** mutual exclusion.\n*/\n\n/*\n** The mutex object\n*/\ntypedef struct sqlite3_debug_mutex {\n  int id;     /* The mutex type */\n  int cnt;    /* Number of entries without a matching leave */\n} sqlite3_debug_mutex;\n\n/*\n** The sqlite3_mutex_held() and sqlite3_mutex_notheld() routine are\n** intended for use inside assert() statements.\n*/\nstatic int debugMutexHeld(sqlite3_mutex *pX){\n  sqlite3_debug_mutex *p = (sqlite3_debug_mutex*)pX;\n  return p==0 || p->cnt>0;\n}\nstatic int debugMutexNotheld(sqlite3_mutex *pX){\n  sqlite3_debug_mutex *p = (sqlite3_debug_mutex*)pX;\n  return p==0 || p->cnt==0;\n}\n\n/*\n** Initialize and deinitialize the mutex subsystem.\n*/\nstatic int debugMutexInit(void){ return SQLITE_OK; }\nstatic int debugMutexEnd(void){ return SQLITE_OK; }\n\n/*\n** The sqlite3_mutex_alloc() routine allocates a new\n** mutex and returns a pointer to it.  If it returns NULL\n** that means that a mutex could not be allocated. \n*/\nstatic sqlite3_mutex *debugMutexAlloc(int id){\n  static sqlite3_debug_mutex aStatic[SQLITE_MUTEX_STATIC_VFS3 - 1];\n  sqlite3_debug_mutex *pNew = 0;\n  switch( id ){\n    case SQLITE_MUTEX_FAST:\n    case SQLITE_MUTEX_RECURSIVE: {\n      pNew = sqlite3Malloc(sizeof(*pNew));\n      if( pNew ){\n        pNew->id = id;\n        pNew->cnt = 0;\n      }\n      break;\n    }\n    default: {\n#ifdef SQLITE_ENABLE_API_ARMOR\n      if( id-2<0 || id-2>=ArraySize(aStatic) ){\n        (void)SQLITE_MISUSE_BKPT;\n        return 0;\n      }\n#endif\n      pNew = &aStatic[id-2];\n      pNew->id = id;\n      break;\n    }\n  }\n  return (sqlite3_mutex*)pNew;\n}\n\n/*\n** This routine deallocates a previously allocated mutex.\n*/\nstatic void debugMutexFree(sqlite3_mutex *pX){\n  sqlite3_debug_mutex *p = (sqlite3_debug_mutex*)pX;\n  assert( p->cnt==0 );\n  if( p->id==SQLITE_MUTEX_RECURSIVE || p->id==SQLITE_MUTEX_FAST ){\n    sqlite3_free(p);\n  }else{\n#ifdef SQLITE_ENABLE_API_ARMOR\n    (void)SQLITE_MISUSE_BKPT;\n#endif\n  }\n}\n\n/*\n** The sqlite3_mutex_enter() and sqlite3_mutex_try() routines attempt\n** to enter a mutex.  If another thread is already within the mutex,\n** sqlite3_mutex_enter() will block and sqlite3_mutex_try() will return\n** SQLITE_BUSY.  The sqlite3_mutex_try() interface returns SQLITE_OK\n** upon successful entry.  Mutexes created using SQLITE_MUTEX_RECURSIVE can\n** be entered multiple times by the same thread.  In such cases the,\n** mutex must be exited an equal number of times before another thread\n** can enter.  If the same thread tries to enter any other kind of mutex\n** more than once, the behavior is undefined.\n*/\nstatic void debugMutexEnter(sqlite3_mutex *pX){\n  sqlite3_debug_mutex *p = (sqlite3_debug_mutex*)pX;\n  assert( p->id==SQLITE_MUTEX_RECURSIVE || debugMutexNotheld(pX) );\n  p->cnt++;\n}\nstatic int debugMutexTry(sqlite3_mutex *pX){\n  sqlite3_debug_mutex *p = (sqlite3_debug_mutex*)pX;\n  assert( p->id==SQLITE_MUTEX_RECURSIVE || debugMutexNotheld(pX) );\n  p->cnt++;\n  return SQLITE_OK;\n}\n\n/*\n** The sqlite3_mutex_leave() routine exits a mutex that was\n** previously entered by the same thread.  The behavior\n** is undefined if the mutex is not currently entered or\n** is not currently allocated.  SQLite will never do either.\n*/\nstatic void debugMutexLeave(sqlite3_mutex *pX){\n  sqlite3_debug_mutex *p = (sqlite3_debug_mutex*)pX;\n  assert( debugMutexHeld(pX) );\n  p->cnt--;\n  assert( p->id==SQLITE_MUTEX_RECURSIVE || debugMutexNotheld(pX) );\n}\n\nSQLITE_PRIVATE sqlite3_mutex_methods const *sqlite3NoopMutex(void){\n  static const sqlite3_mutex_methods sMutex = {\n    debugMutexInit,\n    debugMutexEnd,\n    debugMutexAlloc,\n    debugMutexFree,\n    debugMutexEnter,\n    debugMutexTry,\n    debugMutexLeave,\n\n    debugMutexHeld,\n    debugMutexNotheld\n  };\n\n  return &sMutex;\n}\n#endif /* SQLITE_DEBUG */\n\n/*\n** If compiled with SQLITE_MUTEX_NOOP, then the no-op mutex implementation\n** is used regardless of the run-time threadsafety setting.\n*/\n#ifdef SQLITE_MUTEX_NOOP\nSQLITE_PRIVATE sqlite3_mutex_methods const *sqlite3DefaultMutex(void){\n  return sqlite3NoopMutex();\n}\n#endif /* defined(SQLITE_MUTEX_NOOP) */\n#endif /* !defined(SQLITE_MUTEX_OMIT) */\n\n/************** End of mutex_noop.c ******************************************/\n/************** Begin file mutex_unix.c **************************************/\n/*\n** 2007 August 28\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This file contains the C functions that implement mutexes for pthreads\n*/\n/* #include \"sqliteInt.h\" */\n\n/*\n** The code in this file is only used if we are compiling threadsafe\n** under unix with pthreads.\n**\n** Note that this implementation requires a version of pthreads that\n** supports recursive mutexes.\n*/\n#ifdef SQLITE_MUTEX_PTHREADS\n\n#include <pthread.h>\n\n/*\n** The sqlite3_mutex.id, sqlite3_mutex.nRef, and sqlite3_mutex.owner fields\n** are necessary under two condidtions:  (1) Debug builds and (2) using\n** home-grown mutexes.  Encapsulate these conditions into a single #define.\n*/\n#if defined(SQLITE_DEBUG) || defined(SQLITE_HOMEGROWN_RECURSIVE_MUTEX)\n# define SQLITE_MUTEX_NREF 1\n#else\n# define SQLITE_MUTEX_NREF 0\n#endif\n\n/*\n** Each recursive mutex is an instance of the following structure.\n*/\nstruct sqlite3_mutex {\n  pthread_mutex_t mutex;     /* Mutex controlling the lock */\n#if SQLITE_MUTEX_NREF || defined(SQLITE_ENABLE_API_ARMOR)\n  int id;                    /* Mutex type */\n#endif\n#if SQLITE_MUTEX_NREF\n  volatile int nRef;         /* Number of entrances */\n  volatile pthread_t owner;  /* Thread that is within this mutex */\n  int trace;                 /* True to trace changes */\n#endif\n};\n#if SQLITE_MUTEX_NREF\n# define SQLITE3_MUTEX_INITIALIZER(id) \\\n     {PTHREAD_MUTEX_INITIALIZER,id,0,(pthread_t)0,0}\n#elif defined(SQLITE_ENABLE_API_ARMOR)\n# define SQLITE3_MUTEX_INITIALIZER(id) { PTHREAD_MUTEX_INITIALIZER, id }\n#else\n#define SQLITE3_MUTEX_INITIALIZER(id) { PTHREAD_MUTEX_INITIALIZER }\n#endif\n\n/*\n** The sqlite3_mutex_held() and sqlite3_mutex_notheld() routine are\n** intended for use only inside assert() statements.  On some platforms,\n** there might be race conditions that can cause these routines to\n** deliver incorrect results.  In particular, if pthread_equal() is\n** not an atomic operation, then these routines might delivery\n** incorrect results.  On most platforms, pthread_equal() is a \n** comparison of two integers and is therefore atomic.  But we are\n** told that HPUX is not such a platform.  If so, then these routines\n** will not always work correctly on HPUX.\n**\n** On those platforms where pthread_equal() is not atomic, SQLite\n** should be compiled without -DSQLITE_DEBUG and with -DNDEBUG to\n** make sure no assert() statements are evaluated and hence these\n** routines are never called.\n*/\n#if !defined(NDEBUG) || defined(SQLITE_DEBUG)\nstatic int pthreadMutexHeld(sqlite3_mutex *p){\n  return (p->nRef!=0 && pthread_equal(p->owner, pthread_self()));\n}\nstatic int pthreadMutexNotheld(sqlite3_mutex *p){\n  return p->nRef==0 || pthread_equal(p->owner, pthread_self())==0;\n}\n#endif\n\n/*\n** Try to provide a memory barrier operation, needed for initialization\n** and also for the implementation of xShmBarrier in the VFS in cases\n** where SQLite is compiled without mutexes.\n*/\nSQLITE_PRIVATE void sqlite3MemoryBarrier(void){\n#if defined(SQLITE_MEMORY_BARRIER)\n  SQLITE_MEMORY_BARRIER;\n#elif defined(__GNUC__) && GCC_VERSION>=4001000\n  __sync_synchronize();\n#endif\n}\n\n/*\n** Initialize and deinitialize the mutex subsystem.\n*/\nstatic int pthreadMutexInit(void){ return SQLITE_OK; }\nstatic int pthreadMutexEnd(void){ return SQLITE_OK; }\n\n/*\n** The sqlite3_mutex_alloc() routine allocates a new\n** mutex and returns a pointer to it.  If it returns NULL\n** that means that a mutex could not be allocated.  SQLite\n** will unwind its stack and return an error.  The argument\n** to sqlite3_mutex_alloc() is one of these integer constants:\n**\n** <ul>\n** <li>  SQLITE_MUTEX_FAST\n** <li>  SQLITE_MUTEX_RECURSIVE\n** <li>  SQLITE_MUTEX_STATIC_MASTER\n** <li>  SQLITE_MUTEX_STATIC_MEM\n** <li>  SQLITE_MUTEX_STATIC_OPEN\n** <li>  SQLITE_MUTEX_STATIC_PRNG\n** <li>  SQLITE_MUTEX_STATIC_LRU\n** <li>  SQLITE_MUTEX_STATIC_PMEM\n** <li>  SQLITE_MUTEX_STATIC_APP1\n** <li>  SQLITE_MUTEX_STATIC_APP2\n** <li>  SQLITE_MUTEX_STATIC_APP3\n** <li>  SQLITE_MUTEX_STATIC_VFS1\n** <li>  SQLITE_MUTEX_STATIC_VFS2\n** <li>  SQLITE_MUTEX_STATIC_VFS3\n** </ul>\n**\n** The first two constants cause sqlite3_mutex_alloc() to create\n** a new mutex.  The new mutex is recursive when SQLITE_MUTEX_RECURSIVE\n** is used but not necessarily so when SQLITE_MUTEX_FAST is used.\n** The mutex implementation does not need to make a distinction\n** between SQLITE_MUTEX_RECURSIVE and SQLITE_MUTEX_FAST if it does\n** not want to.  But SQLite will only request a recursive mutex in\n** cases where it really needs one.  If a faster non-recursive mutex\n** implementation is available on the host platform, the mutex subsystem\n** might return such a mutex in response to SQLITE_MUTEX_FAST.\n**\n** The other allowed parameters to sqlite3_mutex_alloc() each return\n** a pointer to a static preexisting mutex.  Six static mutexes are\n** used by the current version of SQLite.  Future versions of SQLite\n** may add additional static mutexes.  Static mutexes are for internal\n** use by SQLite only.  Applications that use SQLite mutexes should\n** use only the dynamic mutexes returned by SQLITE_MUTEX_FAST or\n** SQLITE_MUTEX_RECURSIVE.\n**\n** Note that if one of the dynamic mutex parameters (SQLITE_MUTEX_FAST\n** or SQLITE_MUTEX_RECURSIVE) is used then sqlite3_mutex_alloc()\n** returns a different mutex on every call.  But for the static \n** mutex types, the same mutex is returned on every call that has\n** the same type number.\n*/\nstatic sqlite3_mutex *pthreadMutexAlloc(int iType){\n  static sqlite3_mutex staticMutexes[] = {\n    SQLITE3_MUTEX_INITIALIZER(2),\n    SQLITE3_MUTEX_INITIALIZER(3),\n    SQLITE3_MUTEX_INITIALIZER(4),\n    SQLITE3_MUTEX_INITIALIZER(5),\n    SQLITE3_MUTEX_INITIALIZER(6),\n    SQLITE3_MUTEX_INITIALIZER(7),\n    SQLITE3_MUTEX_INITIALIZER(8),\n    SQLITE3_MUTEX_INITIALIZER(9),\n    SQLITE3_MUTEX_INITIALIZER(10),\n    SQLITE3_MUTEX_INITIALIZER(11),\n    SQLITE3_MUTEX_INITIALIZER(12),\n    SQLITE3_MUTEX_INITIALIZER(13)\n  };\n  sqlite3_mutex *p;\n  switch( iType ){\n    case SQLITE_MUTEX_RECURSIVE: {\n      p = sqlite3MallocZero( sizeof(*p) );\n      if( p ){\n#ifdef SQLITE_HOMEGROWN_RECURSIVE_MUTEX\n        /* If recursive mutexes are not available, we will have to\n        ** build our own.  See below. */\n        pthread_mutex_init(&p->mutex, 0);\n#else\n        /* Use a recursive mutex if it is available */\n        pthread_mutexattr_t recursiveAttr;\n        pthread_mutexattr_init(&recursiveAttr);\n        pthread_mutexattr_settype(&recursiveAttr, PTHREAD_MUTEX_RECURSIVE);\n        pthread_mutex_init(&p->mutex, &recursiveAttr);\n        pthread_mutexattr_destroy(&recursiveAttr);\n#endif\n#if SQLITE_MUTEX_NREF || defined(SQLITE_ENABLE_API_ARMOR)\n        p->id = SQLITE_MUTEX_RECURSIVE;\n#endif\n      }\n      break;\n    }\n    case SQLITE_MUTEX_FAST: {\n      p = sqlite3MallocZero( sizeof(*p) );\n      if( p ){\n        pthread_mutex_init(&p->mutex, 0);\n#if SQLITE_MUTEX_NREF || defined(SQLITE_ENABLE_API_ARMOR)\n        p->id = SQLITE_MUTEX_FAST;\n#endif\n      }\n      break;\n    }\n    default: {\n#ifdef SQLITE_ENABLE_API_ARMOR\n      if( iType-2<0 || iType-2>=ArraySize(staticMutexes) ){\n        (void)SQLITE_MISUSE_BKPT;\n        return 0;\n      }\n#endif\n      p = &staticMutexes[iType-2];\n      break;\n    }\n  }\n#if SQLITE_MUTEX_NREF || defined(SQLITE_ENABLE_API_ARMOR)\n  assert( p==0 || p->id==iType );\n#endif\n  return p;\n}\n\n\n/*\n** This routine deallocates a previously\n** allocated mutex.  SQLite is careful to deallocate every\n** mutex that it allocates.\n*/\nstatic void pthreadMutexFree(sqlite3_mutex *p){\n  assert( p->nRef==0 );\n#if SQLITE_ENABLE_API_ARMOR\n  if( p->id==SQLITE_MUTEX_FAST || p->id==SQLITE_MUTEX_RECURSIVE )\n#endif\n  {\n    pthread_mutex_destroy(&p->mutex);\n    sqlite3_free(p);\n  }\n#ifdef SQLITE_ENABLE_API_ARMOR\n  else{\n    (void)SQLITE_MISUSE_BKPT;\n  }\n#endif\n}\n\n/*\n** The sqlite3_mutex_enter() and sqlite3_mutex_try() routines attempt\n** to enter a mutex.  If another thread is already within the mutex,\n** sqlite3_mutex_enter() will block and sqlite3_mutex_try() will return\n** SQLITE_BUSY.  The sqlite3_mutex_try() interface returns SQLITE_OK\n** upon successful entry.  Mutexes created using SQLITE_MUTEX_RECURSIVE can\n** be entered multiple times by the same thread.  In such cases the,\n** mutex must be exited an equal number of times before another thread\n** can enter.  If the same thread tries to enter any other kind of mutex\n** more than once, the behavior is undefined.\n*/\nstatic void pthreadMutexEnter(sqlite3_mutex *p){\n  assert( p->id==SQLITE_MUTEX_RECURSIVE || pthreadMutexNotheld(p) );\n\n#ifdef SQLITE_HOMEGROWN_RECURSIVE_MUTEX\n  /* If recursive mutexes are not available, then we have to grow\n  ** our own.  This implementation assumes that pthread_equal()\n  ** is atomic - that it cannot be deceived into thinking self\n  ** and p->owner are equal if p->owner changes between two values\n  ** that are not equal to self while the comparison is taking place.\n  ** This implementation also assumes a coherent cache - that \n  ** separate processes cannot read different values from the same\n  ** address at the same time.  If either of these two conditions\n  ** are not met, then the mutexes will fail and problems will result.\n  */\n  {\n    pthread_t self = pthread_self();\n    if( p->nRef>0 && pthread_equal(p->owner, self) ){\n      p->nRef++;\n    }else{\n      pthread_mutex_lock(&p->mutex);\n      assert( p->nRef==0 );\n      p->owner = self;\n      p->nRef = 1;\n    }\n  }\n#else\n  /* Use the built-in recursive mutexes if they are available.\n  */\n  pthread_mutex_lock(&p->mutex);\n#if SQLITE_MUTEX_NREF\n  assert( p->nRef>0 || p->owner==0 );\n  p->owner = pthread_self();\n  p->nRef++;\n#endif\n#endif\n\n#ifdef SQLITE_DEBUG\n  if( p->trace ){\n    printf(\"enter mutex %p (%d) with nRef=%d\\n\", p, p->trace, p->nRef);\n  }\n#endif\n}\nstatic int pthreadMutexTry(sqlite3_mutex *p){\n  int rc;\n  assert( p->id==SQLITE_MUTEX_RECURSIVE || pthreadMutexNotheld(p) );\n\n#ifdef SQLITE_HOMEGROWN_RECURSIVE_MUTEX\n  /* If recursive mutexes are not available, then we have to grow\n  ** our own.  This implementation assumes that pthread_equal()\n  ** is atomic - that it cannot be deceived into thinking self\n  ** and p->owner are equal if p->owner changes between two values\n  ** that are not equal to self while the comparison is taking place.\n  ** This implementation also assumes a coherent cache - that \n  ** separate processes cannot read different values from the same\n  ** address at the same time.  If either of these two conditions\n  ** are not met, then the mutexes will fail and problems will result.\n  */\n  {\n    pthread_t self = pthread_self();\n    if( p->nRef>0 && pthread_equal(p->owner, self) ){\n      p->nRef++;\n      rc = SQLITE_OK;\n    }else if( pthread_mutex_trylock(&p->mutex)==0 ){\n      assert( p->nRef==0 );\n      p->owner = self;\n      p->nRef = 1;\n      rc = SQLITE_OK;\n    }else{\n      rc = SQLITE_BUSY;\n    }\n  }\n#else\n  /* Use the built-in recursive mutexes if they are available.\n  */\n  if( pthread_mutex_trylock(&p->mutex)==0 ){\n#if SQLITE_MUTEX_NREF\n    p->owner = pthread_self();\n    p->nRef++;\n#endif\n    rc = SQLITE_OK;\n  }else{\n    rc = SQLITE_BUSY;\n  }\n#endif\n\n#ifdef SQLITE_DEBUG\n  if( rc==SQLITE_OK && p->trace ){\n    printf(\"enter mutex %p (%d) with nRef=%d\\n\", p, p->trace, p->nRef);\n  }\n#endif\n  return rc;\n}\n\n/*\n** The sqlite3_mutex_leave() routine exits a mutex that was\n** previously entered by the same thread.  The behavior\n** is undefined if the mutex is not currently entered or\n** is not currently allocated.  SQLite will never do either.\n*/\nstatic void pthreadMutexLeave(sqlite3_mutex *p){\n  assert( pthreadMutexHeld(p) );\n#if SQLITE_MUTEX_NREF\n  p->nRef--;\n  if( p->nRef==0 ) p->owner = 0;\n#endif\n  assert( p->nRef==0 || p->id==SQLITE_MUTEX_RECURSIVE );\n\n#ifdef SQLITE_HOMEGROWN_RECURSIVE_MUTEX\n  if( p->nRef==0 ){\n    pthread_mutex_unlock(&p->mutex);\n  }\n#else\n  pthread_mutex_unlock(&p->mutex);\n#endif\n\n#ifdef SQLITE_DEBUG\n  if( p->trace ){\n    printf(\"leave mutex %p (%d) with nRef=%d\\n\", p, p->trace, p->nRef);\n  }\n#endif\n}\n\nSQLITE_PRIVATE sqlite3_mutex_methods const *sqlite3DefaultMutex(void){\n  static const sqlite3_mutex_methods sMutex = {\n    pthreadMutexInit,\n    pthreadMutexEnd,\n    pthreadMutexAlloc,\n    pthreadMutexFree,\n    pthreadMutexEnter,\n    pthreadMutexTry,\n    pthreadMutexLeave,\n#ifdef SQLITE_DEBUG\n    pthreadMutexHeld,\n    pthreadMutexNotheld\n#else\n    0,\n    0\n#endif\n  };\n\n  return &sMutex;\n}\n\n#endif /* SQLITE_MUTEX_PTHREADS */\n\n/************** End of mutex_unix.c ******************************************/\n/************** Begin file mutex_w32.c ***************************************/\n/*\n** 2007 August 14\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This file contains the C functions that implement mutexes for Win32.\n*/\n/* #include \"sqliteInt.h\" */\n\n#if SQLITE_OS_WIN\n/*\n** Include code that is common to all os_*.c files\n*/\n/************** Include os_common.h in the middle of mutex_w32.c *************/\n/************** Begin file os_common.h ***************************************/\n/*\n** 2004 May 22\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n******************************************************************************\n**\n** This file contains macros and a little bit of code that is common to\n** all of the platform-specific files (os_*.c) and is #included into those\n** files.\n**\n** This file should be #included by the os_*.c files only.  It is not a\n** general purpose header file.\n*/\n#ifndef _OS_COMMON_H_\n#define _OS_COMMON_H_\n\n/*\n** At least two bugs have slipped in because we changed the MEMORY_DEBUG\n** macro to SQLITE_DEBUG and some older makefiles have not yet made the\n** switch.  The following code should catch this problem at compile-time.\n*/\n#ifdef MEMORY_DEBUG\n# error \"The MEMORY_DEBUG macro is obsolete.  Use SQLITE_DEBUG instead.\"\n#endif\n\n/*\n** Macros for performance tracing.  Normally turned off.  Only works\n** on i486 hardware.\n*/\n#ifdef SQLITE_PERFORMANCE_TRACE\n\n/*\n** hwtime.h contains inline assembler code for implementing\n** high-performance timing routines.\n*/\n/************** Include hwtime.h in the middle of os_common.h ****************/\n/************** Begin file hwtime.h ******************************************/\n/*\n** 2008 May 27\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n******************************************************************************\n**\n** This file contains inline asm code for retrieving \"high-performance\"\n** counters for x86 class CPUs.\n*/\n#ifndef SQLITE_HWTIME_H\n#define SQLITE_HWTIME_H\n\n/*\n** The following routine only works on pentium-class (or newer) processors.\n** It uses the RDTSC opcode to read the cycle count value out of the\n** processor and returns that value.  This can be used for high-res\n** profiling.\n*/\n#if (defined(__GNUC__) || defined(_MSC_VER)) && \\\n      (defined(i386) || defined(__i386__) || defined(_M_IX86))\n\n  #if defined(__GNUC__)\n\n  __inline__ sqlite_uint64 sqlite3Hwtime(void){\n     unsigned int lo, hi;\n     __asm__ __volatile__ (\"rdtsc\" : \"=a\" (lo), \"=d\" (hi));\n     return (sqlite_uint64)hi << 32 | lo;\n  }\n\n  #elif defined(_MSC_VER)\n\n  __declspec(naked) __inline sqlite_uint64 __cdecl sqlite3Hwtime(void){\n     __asm {\n        rdtsc\n        ret       ; return value at EDX:EAX\n     }\n  }\n\n  #endif\n\n#elif (defined(__GNUC__) && defined(__x86_64__))\n\n  __inline__ sqlite_uint64 sqlite3Hwtime(void){\n      unsigned long val;\n      __asm__ __volatile__ (\"rdtsc\" : \"=A\" (val));\n      return val;\n  }\n \n#elif (defined(__GNUC__) && defined(__ppc__))\n\n  __inline__ sqlite_uint64 sqlite3Hwtime(void){\n      unsigned long long retval;\n      unsigned long junk;\n      __asm__ __volatile__ (\"\\n\\\n          1:      mftbu   %1\\n\\\n                  mftb    %L0\\n\\\n                  mftbu   %0\\n\\\n                  cmpw    %0,%1\\n\\\n                  bne     1b\"\n                  : \"=r\" (retval), \"=r\" (junk));\n      return retval;\n  }\n\n#else\n\n  #error Need implementation of sqlite3Hwtime() for your platform.\n\n  /*\n  ** To compile without implementing sqlite3Hwtime() for your platform,\n  ** you can remove the above #error and use the following\n  ** stub function.  You will lose timing support for many\n  ** of the debugging and testing utilities, but it should at\n  ** least compile and run.\n  */\nSQLITE_PRIVATE   sqlite_uint64 sqlite3Hwtime(void){ return ((sqlite_uint64)0); }\n\n#endif\n\n#endif /* !defined(SQLITE_HWTIME_H) */\n\n/************** End of hwtime.h **********************************************/\n/************** Continuing where we left off in os_common.h ******************/\n\nstatic sqlite_uint64 g_start;\nstatic sqlite_uint64 g_elapsed;\n#define TIMER_START       g_start=sqlite3Hwtime()\n#define TIMER_END         g_elapsed=sqlite3Hwtime()-g_start\n#define TIMER_ELAPSED     g_elapsed\n#else\n#define TIMER_START\n#define TIMER_END\n#define TIMER_ELAPSED     ((sqlite_uint64)0)\n#endif\n\n/*\n** If we compile with the SQLITE_TEST macro set, then the following block\n** of code will give us the ability to simulate a disk I/O error.  This\n** is used for testing the I/O recovery logic.\n*/\n#if defined(SQLITE_TEST)\nSQLITE_API extern int sqlite3_io_error_hit;\nSQLITE_API extern int sqlite3_io_error_hardhit;\nSQLITE_API extern int sqlite3_io_error_pending;\nSQLITE_API extern int sqlite3_io_error_persist;\nSQLITE_API extern int sqlite3_io_error_benign;\nSQLITE_API extern int sqlite3_diskfull_pending;\nSQLITE_API extern int sqlite3_diskfull;\n#define SimulateIOErrorBenign(X) sqlite3_io_error_benign=(X)\n#define SimulateIOError(CODE)  \\\n  if( (sqlite3_io_error_persist && sqlite3_io_error_hit) \\\n       || sqlite3_io_error_pending-- == 1 )  \\\n              { local_ioerr(); CODE; }\nstatic void local_ioerr(){\n  IOTRACE((\"IOERR\\n\"));\n  sqlite3_io_error_hit++;\n  if( !sqlite3_io_error_benign ) sqlite3_io_error_hardhit++;\n}\n#define SimulateDiskfullError(CODE) \\\n   if( sqlite3_diskfull_pending ){ \\\n     if( sqlite3_diskfull_pending == 1 ){ \\\n       local_ioerr(); \\\n       sqlite3_diskfull = 1; \\\n       sqlite3_io_error_hit = 1; \\\n       CODE; \\\n     }else{ \\\n       sqlite3_diskfull_pending--; \\\n     } \\\n   }\n#else\n#define SimulateIOErrorBenign(X)\n#define SimulateIOError(A)\n#define SimulateDiskfullError(A)\n#endif /* defined(SQLITE_TEST) */\n\n/*\n** When testing, keep a count of the number of open files.\n*/\n#if defined(SQLITE_TEST)\nSQLITE_API extern int sqlite3_open_file_count;\n#define OpenCounter(X)  sqlite3_open_file_count+=(X)\n#else\n#define OpenCounter(X)\n#endif /* defined(SQLITE_TEST) */\n\n#endif /* !defined(_OS_COMMON_H_) */\n\n/************** End of os_common.h *******************************************/\n/************** Continuing where we left off in mutex_w32.c ******************/\n\n/*\n** Include the header file for the Windows VFS.\n*/\n/************** Include os_win.h in the middle of mutex_w32.c ****************/\n/************** Begin file os_win.h ******************************************/\n/*\n** 2013 November 25\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n******************************************************************************\n**\n** This file contains code that is specific to Windows.\n*/\n#ifndef SQLITE_OS_WIN_H\n#define SQLITE_OS_WIN_H\n\n/*\n** Include the primary Windows SDK header file.\n*/\n/* #include \"windows.h\" */\n\n#ifdef __CYGWIN__\n# include <sys/cygwin.h>\n/* # include <errno.h> ** amalgamator: dontcache ** */\n#endif\n\n/*\n** Determine if we are dealing with Windows NT.\n**\n** We ought to be able to determine if we are compiling for Windows 9x or\n** Windows NT using the _WIN32_WINNT macro as follows:\n**\n** #if defined(_WIN32_WINNT)\n** # define SQLITE_OS_WINNT 1\n** #else\n** # define SQLITE_OS_WINNT 0\n** #endif\n**\n** However, Visual Studio 2005 does not set _WIN32_WINNT by default, as\n** it ought to, so the above test does not work.  We'll just assume that\n** everything is Windows NT unless the programmer explicitly says otherwise\n** by setting SQLITE_OS_WINNT to 0.\n*/\n#if SQLITE_OS_WIN && !defined(SQLITE_OS_WINNT)\n# define SQLITE_OS_WINNT 1\n#endif\n\n/*\n** Determine if we are dealing with Windows CE - which has a much reduced\n** API.\n*/\n#if defined(_WIN32_WCE)\n# define SQLITE_OS_WINCE 1\n#else\n# define SQLITE_OS_WINCE 0\n#endif\n\n/*\n** Determine if we are dealing with WinRT, which provides only a subset of\n** the full Win32 API.\n*/\n#if !defined(SQLITE_OS_WINRT)\n# define SQLITE_OS_WINRT 0\n#endif\n\n/*\n** For WinCE, some API function parameters do not appear to be declared as\n** volatile.\n*/\n#if SQLITE_OS_WINCE\n# define SQLITE_WIN32_VOLATILE\n#else\n# define SQLITE_WIN32_VOLATILE volatile\n#endif\n\n/*\n** For some Windows sub-platforms, the _beginthreadex() / _endthreadex()\n** functions are not available (e.g. those not using MSVC, Cygwin, etc).\n*/\n#if SQLITE_OS_WIN && !SQLITE_OS_WINCE && !SQLITE_OS_WINRT && \\\n    SQLITE_THREADSAFE>0 && !defined(__CYGWIN__)\n# define SQLITE_OS_WIN_THREADS 1\n#else\n# define SQLITE_OS_WIN_THREADS 0\n#endif\n\n#endif /* SQLITE_OS_WIN_H */\n\n/************** End of os_win.h **********************************************/\n/************** Continuing where we left off in mutex_w32.c ******************/\n#endif\n\n/*\n** The code in this file is only used if we are compiling multithreaded\n** on a Win32 system.\n*/\n#ifdef SQLITE_MUTEX_W32\n\n/*\n** Each recursive mutex is an instance of the following structure.\n*/\nstruct sqlite3_mutex {\n  CRITICAL_SECTION mutex;    /* Mutex controlling the lock */\n  int id;                    /* Mutex type */\n#ifdef SQLITE_DEBUG\n  volatile int nRef;         /* Number of enterances */\n  volatile DWORD owner;      /* Thread holding this mutex */\n  volatile LONG trace;       /* True to trace changes */\n#endif\n};\n\n/*\n** These are the initializer values used when declaring a \"static\" mutex\n** on Win32.  It should be noted that all mutexes require initialization\n** on the Win32 platform.\n*/\n#define SQLITE_W32_MUTEX_INITIALIZER { 0 }\n\n#ifdef SQLITE_DEBUG\n#define SQLITE3_MUTEX_INITIALIZER(id) { SQLITE_W32_MUTEX_INITIALIZER, id, \\\n                                    0L, (DWORD)0, 0 }\n#else\n#define SQLITE3_MUTEX_INITIALIZER(id) { SQLITE_W32_MUTEX_INITIALIZER, id }\n#endif\n\n#ifdef SQLITE_DEBUG\n/*\n** The sqlite3_mutex_held() and sqlite3_mutex_notheld() routine are\n** intended for use only inside assert() statements.\n*/\nstatic int winMutexHeld(sqlite3_mutex *p){\n  return p->nRef!=0 && p->owner==GetCurrentThreadId();\n}\n\nstatic int winMutexNotheld2(sqlite3_mutex *p, DWORD tid){\n  return p->nRef==0 || p->owner!=tid;\n}\n\nstatic int winMutexNotheld(sqlite3_mutex *p){\n  DWORD tid = GetCurrentThreadId();\n  return winMutexNotheld2(p, tid);\n}\n#endif\n\n/*\n** Try to provide a memory barrier operation, needed for initialization\n** and also for the xShmBarrier method of the VFS in cases when SQLite is\n** compiled without mutexes (SQLITE_THREADSAFE=0).\n*/\nSQLITE_PRIVATE void sqlite3MemoryBarrier(void){\n#if defined(SQLITE_MEMORY_BARRIER)\n  SQLITE_MEMORY_BARRIER;\n#elif defined(__GNUC__)\n  __sync_synchronize();\n#elif MSVC_VERSION>=1300\n  _ReadWriteBarrier();\n#elif defined(MemoryBarrier)\n  MemoryBarrier();\n#endif\n}\n\n/*\n** Initialize and deinitialize the mutex subsystem.\n*/\nstatic sqlite3_mutex winMutex_staticMutexes[] = {\n  SQLITE3_MUTEX_INITIALIZER(2),\n  SQLITE3_MUTEX_INITIALIZER(3),\n  SQLITE3_MUTEX_INITIALIZER(4),\n  SQLITE3_MUTEX_INITIALIZER(5),\n  SQLITE3_MUTEX_INITIALIZER(6),\n  SQLITE3_MUTEX_INITIALIZER(7),\n  SQLITE3_MUTEX_INITIALIZER(8),\n  SQLITE3_MUTEX_INITIALIZER(9),\n  SQLITE3_MUTEX_INITIALIZER(10),\n  SQLITE3_MUTEX_INITIALIZER(11),\n  SQLITE3_MUTEX_INITIALIZER(12),\n  SQLITE3_MUTEX_INITIALIZER(13)\n};\n\nstatic int winMutex_isInit = 0;\nstatic int winMutex_isNt = -1; /* <0 means \"need to query\" */\n\n/* As the winMutexInit() and winMutexEnd() functions are called as part\n** of the sqlite3_initialize() and sqlite3_shutdown() processing, the\n** \"interlocked\" magic used here is probably not strictly necessary.\n*/\nstatic LONG SQLITE_WIN32_VOLATILE winMutex_lock = 0;\n\nSQLITE_API int sqlite3_win32_is_nt(void); /* os_win.c */\nSQLITE_API void sqlite3_win32_sleep(DWORD milliseconds); /* os_win.c */\n\nstatic int winMutexInit(void){\n  /* The first to increment to 1 does actual initialization */\n  if( InterlockedCompareExchange(&winMutex_lock, 1, 0)==0 ){\n    int i;\n    for(i=0; i<ArraySize(winMutex_staticMutexes); i++){\n#if SQLITE_OS_WINRT\n      InitializeCriticalSectionEx(&winMutex_staticMutexes[i].mutex, 0, 0);\n#else\n      InitializeCriticalSection(&winMutex_staticMutexes[i].mutex);\n#endif\n    }\n    winMutex_isInit = 1;\n  }else{\n    /* Another thread is (in the process of) initializing the static\n    ** mutexes */\n    while( !winMutex_isInit ){\n      sqlite3_win32_sleep(1);\n    }\n  }\n  return SQLITE_OK;\n}\n\nstatic int winMutexEnd(void){\n  /* The first to decrement to 0 does actual shutdown\n  ** (which should be the last to shutdown.) */\n  if( InterlockedCompareExchange(&winMutex_lock, 0, 1)==1 ){\n    if( winMutex_isInit==1 ){\n      int i;\n      for(i=0; i<ArraySize(winMutex_staticMutexes); i++){\n        DeleteCriticalSection(&winMutex_staticMutexes[i].mutex);\n      }\n      winMutex_isInit = 0;\n    }\n  }\n  return SQLITE_OK;\n}\n\n/*\n** The sqlite3_mutex_alloc() routine allocates a new\n** mutex and returns a pointer to it.  If it returns NULL\n** that means that a mutex could not be allocated.  SQLite\n** will unwind its stack and return an error.  The argument\n** to sqlite3_mutex_alloc() is one of these integer constants:\n**\n** <ul>\n** <li>  SQLITE_MUTEX_FAST\n** <li>  SQLITE_MUTEX_RECURSIVE\n** <li>  SQLITE_MUTEX_STATIC_MASTER\n** <li>  SQLITE_MUTEX_STATIC_MEM\n** <li>  SQLITE_MUTEX_STATIC_OPEN\n** <li>  SQLITE_MUTEX_STATIC_PRNG\n** <li>  SQLITE_MUTEX_STATIC_LRU\n** <li>  SQLITE_MUTEX_STATIC_PMEM\n** <li>  SQLITE_MUTEX_STATIC_APP1\n** <li>  SQLITE_MUTEX_STATIC_APP2\n** <li>  SQLITE_MUTEX_STATIC_APP3\n** <li>  SQLITE_MUTEX_STATIC_VFS1\n** <li>  SQLITE_MUTEX_STATIC_VFS2\n** <li>  SQLITE_MUTEX_STATIC_VFS3\n** </ul>\n**\n** The first two constants cause sqlite3_mutex_alloc() to create\n** a new mutex.  The new mutex is recursive when SQLITE_MUTEX_RECURSIVE\n** is used but not necessarily so when SQLITE_MUTEX_FAST is used.\n** The mutex implementation does not need to make a distinction\n** between SQLITE_MUTEX_RECURSIVE and SQLITE_MUTEX_FAST if it does\n** not want to.  But SQLite will only request a recursive mutex in\n** cases where it really needs one.  If a faster non-recursive mutex\n** implementation is available on the host platform, the mutex subsystem\n** might return such a mutex in response to SQLITE_MUTEX_FAST.\n**\n** The other allowed parameters to sqlite3_mutex_alloc() each return\n** a pointer to a static preexisting mutex.  Six static mutexes are\n** used by the current version of SQLite.  Future versions of SQLite\n** may add additional static mutexes.  Static mutexes are for internal\n** use by SQLite only.  Applications that use SQLite mutexes should\n** use only the dynamic mutexes returned by SQLITE_MUTEX_FAST or\n** SQLITE_MUTEX_RECURSIVE.\n**\n** Note that if one of the dynamic mutex parameters (SQLITE_MUTEX_FAST\n** or SQLITE_MUTEX_RECURSIVE) is used then sqlite3_mutex_alloc()\n** returns a different mutex on every call.  But for the static\n** mutex types, the same mutex is returned on every call that has\n** the same type number.\n*/\nstatic sqlite3_mutex *winMutexAlloc(int iType){\n  sqlite3_mutex *p;\n\n  switch( iType ){\n    case SQLITE_MUTEX_FAST:\n    case SQLITE_MUTEX_RECURSIVE: {\n      p = sqlite3MallocZero( sizeof(*p) );\n      if( p ){\n        p->id = iType;\n#ifdef SQLITE_DEBUG\n#ifdef SQLITE_WIN32_MUTEX_TRACE_DYNAMIC\n        p->trace = 1;\n#endif\n#endif\n#if SQLITE_OS_WINRT\n        InitializeCriticalSectionEx(&p->mutex, 0, 0);\n#else\n        InitializeCriticalSection(&p->mutex);\n#endif\n      }\n      break;\n    }\n    default: {\n#ifdef SQLITE_ENABLE_API_ARMOR\n      if( iType-2<0 || iType-2>=ArraySize(winMutex_staticMutexes) ){\n        (void)SQLITE_MISUSE_BKPT;\n        return 0;\n      }\n#endif\n      p = &winMutex_staticMutexes[iType-2];\n#ifdef SQLITE_DEBUG\n#ifdef SQLITE_WIN32_MUTEX_TRACE_STATIC\n      InterlockedCompareExchange(&p->trace, 1, 0);\n#endif\n#endif\n      break;\n    }\n  }\n  assert( p==0 || p->id==iType );\n  return p;\n}\n\n\n/*\n** This routine deallocates a previously\n** allocated mutex.  SQLite is careful to deallocate every\n** mutex that it allocates.\n*/\nstatic void winMutexFree(sqlite3_mutex *p){\n  assert( p );\n  assert( p->nRef==0 && p->owner==0 );\n  if( p->id==SQLITE_MUTEX_FAST || p->id==SQLITE_MUTEX_RECURSIVE ){\n    DeleteCriticalSection(&p->mutex);\n    sqlite3_free(p);\n  }else{\n#ifdef SQLITE_ENABLE_API_ARMOR\n    (void)SQLITE_MISUSE_BKPT;\n#endif\n  }\n}\n\n/*\n** The sqlite3_mutex_enter() and sqlite3_mutex_try() routines attempt\n** to enter a mutex.  If another thread is already within the mutex,\n** sqlite3_mutex_enter() will block and sqlite3_mutex_try() will return\n** SQLITE_BUSY.  The sqlite3_mutex_try() interface returns SQLITE_OK\n** upon successful entry.  Mutexes created using SQLITE_MUTEX_RECURSIVE can\n** be entered multiple times by the same thread.  In such cases the,\n** mutex must be exited an equal number of times before another thread\n** can enter.  If the same thread tries to enter any other kind of mutex\n** more than once, the behavior is undefined.\n*/\nstatic void winMutexEnter(sqlite3_mutex *p){\n#if defined(SQLITE_DEBUG) || defined(SQLITE_TEST)\n  DWORD tid = GetCurrentThreadId();\n#endif\n#ifdef SQLITE_DEBUG\n  assert( p );\n  assert( p->id==SQLITE_MUTEX_RECURSIVE || winMutexNotheld2(p, tid) );\n#else\n  assert( p );\n#endif\n  assert( winMutex_isInit==1 );\n  EnterCriticalSection(&p->mutex);\n#ifdef SQLITE_DEBUG\n  assert( p->nRef>0 || p->owner==0 );\n  p->owner = tid;\n  p->nRef++;\n  if( p->trace ){\n    OSTRACE((\"ENTER-MUTEX tid=%lu, mutex(%d)=%p (%d), nRef=%d\\n\",\n             tid, p->id, p, p->trace, p->nRef));\n  }\n#endif\n}\n\nstatic int winMutexTry(sqlite3_mutex *p){\n#if defined(SQLITE_DEBUG) || defined(SQLITE_TEST)\n  DWORD tid = GetCurrentThreadId();\n#endif\n  int rc = SQLITE_BUSY;\n  assert( p );\n  assert( p->id==SQLITE_MUTEX_RECURSIVE || winMutexNotheld2(p, tid) );\n  /*\n  ** The sqlite3_mutex_try() routine is very rarely used, and when it\n  ** is used it is merely an optimization.  So it is OK for it to always\n  ** fail.\n  **\n  ** The TryEnterCriticalSection() interface is only available on WinNT.\n  ** And some windows compilers complain if you try to use it without\n  ** first doing some #defines that prevent SQLite from building on Win98.\n  ** For that reason, we will omit this optimization for now.  See\n  ** ticket #2685.\n  */\n#if defined(_WIN32_WINNT) && _WIN32_WINNT >= 0x0400\n  assert( winMutex_isInit==1 );\n  assert( winMutex_isNt>=-1 && winMutex_isNt<=1 );\n  if( winMutex_isNt<0 ){\n    winMutex_isNt = sqlite3_win32_is_nt();\n  }\n  assert( winMutex_isNt==0 || winMutex_isNt==1 );\n  if( winMutex_isNt && TryEnterCriticalSection(&p->mutex) ){\n#ifdef SQLITE_DEBUG\n    p->owner = tid;\n    p->nRef++;\n#endif\n    rc = SQLITE_OK;\n  }\n#else\n  UNUSED_PARAMETER(p);\n#endif\n#ifdef SQLITE_DEBUG\n  if( p->trace ){\n    OSTRACE((\"TRY-MUTEX tid=%lu, mutex(%d)=%p (%d), owner=%lu, nRef=%d, rc=%s\\n\",\n             tid, p->id, p, p->trace, p->owner, p->nRef, sqlite3ErrName(rc)));\n  }\n#endif\n  return rc;\n}\n\n/*\n** The sqlite3_mutex_leave() routine exits a mutex that was\n** previously entered by the same thread.  The behavior\n** is undefined if the mutex is not currently entered or\n** is not currently allocated.  SQLite will never do either.\n*/\nstatic void winMutexLeave(sqlite3_mutex *p){\n#if defined(SQLITE_DEBUG) || defined(SQLITE_TEST)\n  DWORD tid = GetCurrentThreadId();\n#endif\n  assert( p );\n#ifdef SQLITE_DEBUG\n  assert( p->nRef>0 );\n  assert( p->owner==tid );\n  p->nRef--;\n  if( p->nRef==0 ) p->owner = 0;\n  assert( p->nRef==0 || p->id==SQLITE_MUTEX_RECURSIVE );\n#endif\n  assert( winMutex_isInit==1 );\n  LeaveCriticalSection(&p->mutex);\n#ifdef SQLITE_DEBUG\n  if( p->trace ){\n    OSTRACE((\"LEAVE-MUTEX tid=%lu, mutex(%d)=%p (%d), nRef=%d\\n\",\n             tid, p->id, p, p->trace, p->nRef));\n  }\n#endif\n}\n\nSQLITE_PRIVATE sqlite3_mutex_methods const *sqlite3DefaultMutex(void){\n  static const sqlite3_mutex_methods sMutex = {\n    winMutexInit,\n    winMutexEnd,\n    winMutexAlloc,\n    winMutexFree,\n    winMutexEnter,\n    winMutexTry,\n    winMutexLeave,\n#ifdef SQLITE_DEBUG\n    winMutexHeld,\n    winMutexNotheld\n#else\n    0,\n    0\n#endif\n  };\n  return &sMutex;\n}\n\n#endif /* SQLITE_MUTEX_W32 */\n\n/************** End of mutex_w32.c *******************************************/\n/************** Begin file malloc.c ******************************************/\n/*\n** 2001 September 15\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n**\n** Memory allocation functions used throughout sqlite.\n*/\n/* #include \"sqliteInt.h\" */\n/* #include <stdarg.h> */\n\n/*\n** Attempt to release up to n bytes of non-essential memory currently\n** held by SQLite. An example of non-essential memory is memory used to\n** cache database pages that are not currently in use.\n*/\nSQLITE_API int sqlite3_release_memory(int n){\n#ifdef SQLITE_ENABLE_MEMORY_MANAGEMENT\n  return sqlite3PcacheReleaseMemory(n);\n#else\n  /* IMPLEMENTATION-OF: R-34391-24921 The sqlite3_release_memory() routine\n  ** is a no-op returning zero if SQLite is not compiled with\n  ** SQLITE_ENABLE_MEMORY_MANAGEMENT. */\n  UNUSED_PARAMETER(n);\n  return 0;\n#endif\n}\n\n/*\n** State information local to the memory allocation subsystem.\n*/\nstatic SQLITE_WSD struct Mem0Global {\n  sqlite3_mutex *mutex;         /* Mutex to serialize access */\n  sqlite3_int64 alarmThreshold; /* The soft heap limit */\n\n  /*\n  ** True if heap is nearly \"full\" where \"full\" is defined by the\n  ** sqlite3_soft_heap_limit() setting.\n  */\n  int nearlyFull;\n} mem0 = { 0, 0, 0 };\n\n#define mem0 GLOBAL(struct Mem0Global, mem0)\n\n/*\n** Return the memory allocator mutex. sqlite3_status() needs it.\n*/\nSQLITE_PRIVATE sqlite3_mutex *sqlite3MallocMutex(void){\n  return mem0.mutex;\n}\n\n#ifndef SQLITE_OMIT_DEPRECATED\n/*\n** Deprecated external interface.  It used to set an alarm callback\n** that was invoked when memory usage grew too large.  Now it is a\n** no-op.\n*/\nSQLITE_API int sqlite3_memory_alarm(\n  void(*xCallback)(void *pArg, sqlite3_int64 used,int N),\n  void *pArg,\n  sqlite3_int64 iThreshold\n){\n  (void)xCallback;\n  (void)pArg;\n  (void)iThreshold;\n  return SQLITE_OK;\n}\n#endif\n\n/*\n** Set the soft heap-size limit for the library. Passing a zero or \n** negative value indicates no limit.\n*/\nSQLITE_API sqlite3_int64 sqlite3_soft_heap_limit64(sqlite3_int64 n){\n  sqlite3_int64 priorLimit;\n  sqlite3_int64 excess;\n  sqlite3_int64 nUsed;\n#ifndef SQLITE_OMIT_AUTOINIT\n  int rc = sqlite3_initialize();\n  if( rc ) return -1;\n#endif\n  sqlite3_mutex_enter(mem0.mutex);\n  priorLimit = mem0.alarmThreshold;\n  if( n<0 ){\n    sqlite3_mutex_leave(mem0.mutex);\n    return priorLimit;\n  }\n  mem0.alarmThreshold = n;\n  nUsed = sqlite3StatusValue(SQLITE_STATUS_MEMORY_USED);\n  mem0.nearlyFull = (n>0 && n<=nUsed);\n  sqlite3_mutex_leave(mem0.mutex);\n  excess = sqlite3_memory_used() - n;\n  if( excess>0 ) sqlite3_release_memory((int)(excess & 0x7fffffff));\n  return priorLimit;\n}\nSQLITE_API void sqlite3_soft_heap_limit(int n){\n  if( n<0 ) n = 0;\n  sqlite3_soft_heap_limit64(n);\n}\n\n/*\n** Initialize the memory allocation subsystem.\n*/\nSQLITE_PRIVATE int sqlite3MallocInit(void){\n  int rc;\n  if( sqlite3GlobalConfig.m.xMalloc==0 ){\n    sqlite3MemSetDefault();\n  }\n  memset(&mem0, 0, sizeof(mem0));\n  mem0.mutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MEM);\n  if( sqlite3GlobalConfig.pPage==0 || sqlite3GlobalConfig.szPage<512\n      || sqlite3GlobalConfig.nPage<=0 ){\n    sqlite3GlobalConfig.pPage = 0;\n    sqlite3GlobalConfig.szPage = 0;\n  }\n  rc = sqlite3GlobalConfig.m.xInit(sqlite3GlobalConfig.m.pAppData);\n  if( rc!=SQLITE_OK ) memset(&mem0, 0, sizeof(mem0));\n/* BEGIN SQLCIPHER */\n#if defined(SQLITE_HAS_CODEC) && !defined(OMIT_MEM_SECURITY)\n  /* install wrapping functions for memory management\n     that will wipe all memory allocated by SQLite\n     when freed */\n  if( rc==SQLITE_OK ) {\n    extern void sqlcipher_init_memmethods(void);\n    sqlcipher_init_memmethods();\n  }\n#endif\n/* END SQLCIPHER */\n  return rc;\n}\n\n/*\n** Return true if the heap is currently under memory pressure - in other\n** words if the amount of heap used is close to the limit set by\n** sqlite3_soft_heap_limit().\n*/\nSQLITE_PRIVATE int sqlite3HeapNearlyFull(void){\n  return mem0.nearlyFull;\n}\n\n/*\n** Deinitialize the memory allocation subsystem.\n*/\nSQLITE_PRIVATE void sqlite3MallocEnd(void){\n  if( sqlite3GlobalConfig.m.xShutdown ){\n    sqlite3GlobalConfig.m.xShutdown(sqlite3GlobalConfig.m.pAppData);\n  }\n  memset(&mem0, 0, sizeof(mem0));\n}\n\n/*\n** Return the amount of memory currently checked out.\n*/\nSQLITE_API sqlite3_int64 sqlite3_memory_used(void){\n  sqlite3_int64 res, mx;\n  sqlite3_status64(SQLITE_STATUS_MEMORY_USED, &res, &mx, 0);\n  return res;\n}\n\n/*\n** Return the maximum amount of memory that has ever been\n** checked out since either the beginning of this process\n** or since the most recent reset.\n*/\nSQLITE_API sqlite3_int64 sqlite3_memory_highwater(int resetFlag){\n  sqlite3_int64 res, mx;\n  sqlite3_status64(SQLITE_STATUS_MEMORY_USED, &res, &mx, resetFlag);\n  return mx;\n}\n\n/*\n** Trigger the alarm \n*/\nstatic void sqlite3MallocAlarm(int nByte){\n  if( mem0.alarmThreshold<=0 ) return;\n  sqlite3_mutex_leave(mem0.mutex);\n  sqlite3_release_memory(nByte);\n  sqlite3_mutex_enter(mem0.mutex);\n}\n\n/*\n** Do a memory allocation with statistics and alarms.  Assume the\n** lock is already held.\n*/\nstatic void mallocWithAlarm(int n, void **pp){\n  void *p;\n  int nFull;\n  assert( sqlite3_mutex_held(mem0.mutex) );\n  assert( n>0 );\n\n  /* In Firefox (circa 2017-02-08), xRoundup() is remapped to an internal\n  ** implementation of malloc_good_size(), which must be called in debug\n  ** mode and specifically when the DMD \"Dark Matter Detector\" is enabled\n  ** or else a crash results.  Hence, do not attempt to optimize out the\n  ** following xRoundup() call. */\n  nFull = sqlite3GlobalConfig.m.xRoundup(n);\n\n#ifdef SQLITE_MAX_MEMORY\n  if( sqlite3StatusValue(SQLITE_STATUS_MEMORY_USED)+nFull>SQLITE_MAX_MEMORY ){\n    *pp = 0;\n    return;\n  }\n#endif\n\n  sqlite3StatusHighwater(SQLITE_STATUS_MALLOC_SIZE, n);\n  if( mem0.alarmThreshold>0 ){\n    sqlite3_int64 nUsed = sqlite3StatusValue(SQLITE_STATUS_MEMORY_USED);\n    if( nUsed >= mem0.alarmThreshold - nFull ){\n      mem0.nearlyFull = 1;\n      sqlite3MallocAlarm(nFull);\n    }else{\n      mem0.nearlyFull = 0;\n    }\n  }\n  p = sqlite3GlobalConfig.m.xMalloc(nFull);\n#ifdef SQLITE_ENABLE_MEMORY_MANAGEMENT\n  if( p==0 && mem0.alarmThreshold>0 ){\n    sqlite3MallocAlarm(nFull);\n    p = sqlite3GlobalConfig.m.xMalloc(nFull);\n  }\n#endif\n  if( p ){\n    nFull = sqlite3MallocSize(p);\n    sqlite3StatusUp(SQLITE_STATUS_MEMORY_USED, nFull);\n    sqlite3StatusUp(SQLITE_STATUS_MALLOC_COUNT, 1);\n  }\n  *pp = p;\n}\n\n/*\n** Allocate memory.  This routine is like sqlite3_malloc() except that it\n** assumes the memory subsystem has already been initialized.\n*/\nSQLITE_PRIVATE void *sqlite3Malloc(u64 n){\n  void *p;\n  if( n==0 || n>=0x7fffff00 ){\n    /* A memory allocation of a number of bytes which is near the maximum\n    ** signed integer value might cause an integer overflow inside of the\n    ** xMalloc().  Hence we limit the maximum size to 0x7fffff00, giving\n    ** 255 bytes of overhead.  SQLite itself will never use anything near\n    ** this amount.  The only way to reach the limit is with sqlite3_malloc() */\n    p = 0;\n  }else if( sqlite3GlobalConfig.bMemstat ){\n    sqlite3_mutex_enter(mem0.mutex);\n    mallocWithAlarm((int)n, &p);\n    sqlite3_mutex_leave(mem0.mutex);\n  }else{\n    p = sqlite3GlobalConfig.m.xMalloc((int)n);\n  }\n  assert( EIGHT_BYTE_ALIGNMENT(p) );  /* IMP: R-11148-40995 */\n  return p;\n}\n\n/*\n** This version of the memory allocation is for use by the application.\n** First make sure the memory subsystem is initialized, then do the\n** allocation.\n*/\nSQLITE_API void *sqlite3_malloc(int n){\n#ifndef SQLITE_OMIT_AUTOINIT\n  if( sqlite3_initialize() ) return 0;\n#endif\n  return n<=0 ? 0 : sqlite3Malloc(n);\n}\nSQLITE_API void *sqlite3_malloc64(sqlite3_uint64 n){\n#ifndef SQLITE_OMIT_AUTOINIT\n  if( sqlite3_initialize() ) return 0;\n#endif\n  return sqlite3Malloc(n);\n}\n\n/*\n** TRUE if p is a lookaside memory allocation from db\n*/\n#ifndef SQLITE_OMIT_LOOKASIDE\nstatic int isLookaside(sqlite3 *db, void *p){\n  return SQLITE_WITHIN(p, db->lookaside.pStart, db->lookaside.pEnd);\n}\n#else\n#define isLookaside(A,B) 0\n#endif\n\n/*\n** Return the size of a memory allocation previously obtained from\n** sqlite3Malloc() or sqlite3_malloc().\n*/\nSQLITE_PRIVATE int sqlite3MallocSize(void *p){\n  assert( sqlite3MemdebugHasType(p, MEMTYPE_HEAP) );\n  return sqlite3GlobalConfig.m.xSize(p);\n}\nSQLITE_PRIVATE int sqlite3DbMallocSize(sqlite3 *db, void *p){\n  assert( p!=0 );\n  if( db==0 || !isLookaside(db,p) ){\n#ifdef SQLITE_DEBUG\n    if( db==0 ){\n      assert( sqlite3MemdebugNoType(p, (u8)~MEMTYPE_HEAP) );\n      assert( sqlite3MemdebugHasType(p, MEMTYPE_HEAP) );\n    }else{\n      assert( sqlite3MemdebugHasType(p, (MEMTYPE_LOOKASIDE|MEMTYPE_HEAP)) );\n      assert( sqlite3MemdebugNoType(p, (u8)~(MEMTYPE_LOOKASIDE|MEMTYPE_HEAP)) );\n    }\n#endif\n    return sqlite3GlobalConfig.m.xSize(p);\n  }else{\n    assert( sqlite3_mutex_held(db->mutex) );\n    return db->lookaside.sz;\n  }\n}\nSQLITE_API sqlite3_uint64 sqlite3_msize(void *p){\n  assert( sqlite3MemdebugNoType(p, (u8)~MEMTYPE_HEAP) );\n  assert( sqlite3MemdebugHasType(p, MEMTYPE_HEAP) );\n  return p ? sqlite3GlobalConfig.m.xSize(p) : 0;\n}\n\n/*\n** Free memory previously obtained from sqlite3Malloc().\n*/\nSQLITE_API void sqlite3_free(void *p){\n  if( p==0 ) return;  /* IMP: R-49053-54554 */\n  assert( sqlite3MemdebugHasType(p, MEMTYPE_HEAP) );\n  assert( sqlite3MemdebugNoType(p, (u8)~MEMTYPE_HEAP) );\n  if( sqlite3GlobalConfig.bMemstat ){\n    sqlite3_mutex_enter(mem0.mutex);\n    sqlite3StatusDown(SQLITE_STATUS_MEMORY_USED, sqlite3MallocSize(p));\n    sqlite3StatusDown(SQLITE_STATUS_MALLOC_COUNT, 1);\n    sqlite3GlobalConfig.m.xFree(p);\n    sqlite3_mutex_leave(mem0.mutex);\n  }else{\n    sqlite3GlobalConfig.m.xFree(p);\n  }\n}\n\n/*\n** Add the size of memory allocation \"p\" to the count in\n** *db->pnBytesFreed.\n*/\nstatic SQLITE_NOINLINE void measureAllocationSize(sqlite3 *db, void *p){\n  *db->pnBytesFreed += sqlite3DbMallocSize(db,p);\n}\n\n/*\n** Free memory that might be associated with a particular database\n** connection.  Calling sqlite3DbFree(D,X) for X==0 is a harmless no-op.\n** The sqlite3DbFreeNN(D,X) version requires that X be non-NULL.\n*/\nSQLITE_PRIVATE void sqlite3DbFreeNN(sqlite3 *db, void *p){\n  assert( db==0 || sqlite3_mutex_held(db->mutex) );\n  assert( p!=0 );\n  if( db ){\n    if( db->pnBytesFreed ){\n      measureAllocationSize(db, p);\n      return;\n    }\n    if( isLookaside(db, p) ){\n      LookasideSlot *pBuf = (LookasideSlot*)p;\n#ifdef SQLITE_DEBUG\n      /* Trash all content in the buffer being freed */\n      memset(p, 0xaa, db->lookaside.sz);\n#endif\n      pBuf->pNext = db->lookaside.pFree;\n      db->lookaside.pFree = pBuf;\n      return;\n    }\n  }\n  assert( sqlite3MemdebugHasType(p, (MEMTYPE_LOOKASIDE|MEMTYPE_HEAP)) );\n  assert( sqlite3MemdebugNoType(p, (u8)~(MEMTYPE_LOOKASIDE|MEMTYPE_HEAP)) );\n  assert( db!=0 || sqlite3MemdebugNoType(p, MEMTYPE_LOOKASIDE) );\n  sqlite3MemdebugSetType(p, MEMTYPE_HEAP);\n  sqlite3_free(p);\n}\nSQLITE_PRIVATE void sqlite3DbFree(sqlite3 *db, void *p){\n  assert( db==0 || sqlite3_mutex_held(db->mutex) );\n  if( p ) sqlite3DbFreeNN(db, p);\n}\n\n/*\n** Change the size of an existing memory allocation\n*/\nSQLITE_PRIVATE void *sqlite3Realloc(void *pOld, u64 nBytes){\n  int nOld, nNew, nDiff;\n  void *pNew;\n  assert( sqlite3MemdebugHasType(pOld, MEMTYPE_HEAP) );\n  assert( sqlite3MemdebugNoType(pOld, (u8)~MEMTYPE_HEAP) );\n  if( pOld==0 ){\n    return sqlite3Malloc(nBytes); /* IMP: R-04300-56712 */\n  }\n  if( nBytes==0 ){\n    sqlite3_free(pOld); /* IMP: R-26507-47431 */\n    return 0;\n  }\n  if( nBytes>=0x7fffff00 ){\n    /* The 0x7ffff00 limit term is explained in comments on sqlite3Malloc() */\n    return 0;\n  }\n  nOld = sqlite3MallocSize(pOld);\n  /* IMPLEMENTATION-OF: R-46199-30249 SQLite guarantees that the second\n  ** argument to xRealloc is always a value returned by a prior call to\n  ** xRoundup. */\n  nNew = sqlite3GlobalConfig.m.xRoundup((int)nBytes);\n  if( nOld==nNew ){\n    pNew = pOld;\n  }else if( sqlite3GlobalConfig.bMemstat ){\n    sqlite3_mutex_enter(mem0.mutex);\n    sqlite3StatusHighwater(SQLITE_STATUS_MALLOC_SIZE, (int)nBytes);\n    nDiff = nNew - nOld;\n    if( nDiff>0 && sqlite3StatusValue(SQLITE_STATUS_MEMORY_USED) >= \n          mem0.alarmThreshold-nDiff ){\n      sqlite3MallocAlarm(nDiff);\n    }\n    pNew = sqlite3GlobalConfig.m.xRealloc(pOld, nNew);\n    if( pNew==0 && mem0.alarmThreshold>0 ){\n      sqlite3MallocAlarm((int)nBytes);\n      pNew = sqlite3GlobalConfig.m.xRealloc(pOld, nNew);\n    }\n    if( pNew ){\n      nNew = sqlite3MallocSize(pNew);\n      sqlite3StatusUp(SQLITE_STATUS_MEMORY_USED, nNew-nOld);\n    }\n    sqlite3_mutex_leave(mem0.mutex);\n  }else{\n    pNew = sqlite3GlobalConfig.m.xRealloc(pOld, nNew);\n  }\n  assert( EIGHT_BYTE_ALIGNMENT(pNew) ); /* IMP: R-11148-40995 */\n  return pNew;\n}\n\n/*\n** The public interface to sqlite3Realloc.  Make sure that the memory\n** subsystem is initialized prior to invoking sqliteRealloc.\n*/\nSQLITE_API void *sqlite3_realloc(void *pOld, int n){\n#ifndef SQLITE_OMIT_AUTOINIT\n  if( sqlite3_initialize() ) return 0;\n#endif\n  if( n<0 ) n = 0;  /* IMP: R-26507-47431 */\n  return sqlite3Realloc(pOld, n);\n}\nSQLITE_API void *sqlite3_realloc64(void *pOld, sqlite3_uint64 n){\n#ifndef SQLITE_OMIT_AUTOINIT\n  if( sqlite3_initialize() ) return 0;\n#endif\n  return sqlite3Realloc(pOld, n);\n}\n\n\n/*\n** Allocate and zero memory.\n*/ \nSQLITE_PRIVATE void *sqlite3MallocZero(u64 n){\n  void *p = sqlite3Malloc(n);\n  if( p ){\n    memset(p, 0, (size_t)n);\n  }\n  return p;\n}\n\n/*\n** Allocate and zero memory.  If the allocation fails, make\n** the mallocFailed flag in the connection pointer.\n*/\nSQLITE_PRIVATE void *sqlite3DbMallocZero(sqlite3 *db, u64 n){\n  void *p;\n  testcase( db==0 );\n  p = sqlite3DbMallocRaw(db, n);\n  if( p ) memset(p, 0, (size_t)n);\n  return p;\n}\n\n\n/* Finish the work of sqlite3DbMallocRawNN for the unusual and\n** slower case when the allocation cannot be fulfilled using lookaside.\n*/\nstatic SQLITE_NOINLINE void *dbMallocRawFinish(sqlite3 *db, u64 n){\n  void *p;\n  assert( db!=0 );\n  p = sqlite3Malloc(n);\n  if( !p ) sqlite3OomFault(db);\n  sqlite3MemdebugSetType(p, \n         (db->lookaside.bDisable==0) ? MEMTYPE_LOOKASIDE : MEMTYPE_HEAP);\n  return p;\n}\n\n/*\n** Allocate memory, either lookaside (if possible) or heap.  \n** If the allocation fails, set the mallocFailed flag in\n** the connection pointer.\n**\n** If db!=0 and db->mallocFailed is true (indicating a prior malloc\n** failure on the same database connection) then always return 0.\n** Hence for a particular database connection, once malloc starts\n** failing, it fails consistently until mallocFailed is reset.\n** This is an important assumption.  There are many places in the\n** code that do things like this:\n**\n**         int *a = (int*)sqlite3DbMallocRaw(db, 100);\n**         int *b = (int*)sqlite3DbMallocRaw(db, 200);\n**         if( b ) a[10] = 9;\n**\n** In other words, if a subsequent malloc (ex: \"b\") worked, it is assumed\n** that all prior mallocs (ex: \"a\") worked too.\n**\n** The sqlite3MallocRawNN() variant guarantees that the \"db\" parameter is\n** not a NULL pointer.\n*/\nSQLITE_PRIVATE void *sqlite3DbMallocRaw(sqlite3 *db, u64 n){\n  void *p;\n  if( db ) return sqlite3DbMallocRawNN(db, n);\n  p = sqlite3Malloc(n);\n  sqlite3MemdebugSetType(p, MEMTYPE_HEAP);\n  return p;\n}\nSQLITE_PRIVATE void *sqlite3DbMallocRawNN(sqlite3 *db, u64 n){\n#ifndef SQLITE_OMIT_LOOKASIDE\n  LookasideSlot *pBuf;\n  assert( db!=0 );\n  assert( sqlite3_mutex_held(db->mutex) );\n  assert( db->pnBytesFreed==0 );\n  if( db->lookaside.bDisable==0 ){\n    assert( db->mallocFailed==0 );\n    if( n>db->lookaside.sz ){\n      db->lookaside.anStat[1]++;\n    }else if( (pBuf = db->lookaside.pFree)!=0 ){\n      db->lookaside.pFree = pBuf->pNext;\n      db->lookaside.anStat[0]++;\n      return (void*)pBuf;\n    }else if( (pBuf = db->lookaside.pInit)!=0 ){\n      db->lookaside.pInit = pBuf->pNext;\n      db->lookaside.anStat[0]++;\n      return (void*)pBuf;\n    }else{\n      db->lookaside.anStat[2]++;\n    }\n  }else if( db->mallocFailed ){\n    return 0;\n  }\n#else\n  assert( db!=0 );\n  assert( sqlite3_mutex_held(db->mutex) );\n  assert( db->pnBytesFreed==0 );\n  if( db->mallocFailed ){\n    return 0;\n  }\n#endif\n  return dbMallocRawFinish(db, n);\n}\n\n/* Forward declaration */\nstatic SQLITE_NOINLINE void *dbReallocFinish(sqlite3 *db, void *p, u64 n);\n\n/*\n** Resize the block of memory pointed to by p to n bytes. If the\n** resize fails, set the mallocFailed flag in the connection object.\n*/\nSQLITE_PRIVATE void *sqlite3DbRealloc(sqlite3 *db, void *p, u64 n){\n  assert( db!=0 );\n  if( p==0 ) return sqlite3DbMallocRawNN(db, n);\n  assert( sqlite3_mutex_held(db->mutex) );\n  if( isLookaside(db,p) && n<=db->lookaside.sz ) return p;\n  return dbReallocFinish(db, p, n);\n}\nstatic SQLITE_NOINLINE void *dbReallocFinish(sqlite3 *db, void *p, u64 n){\n  void *pNew = 0;\n  assert( db!=0 );\n  assert( p!=0 );\n  if( db->mallocFailed==0 ){\n    if( isLookaside(db, p) ){\n      pNew = sqlite3DbMallocRawNN(db, n);\n      if( pNew ){\n        memcpy(pNew, p, db->lookaside.sz);\n        sqlite3DbFree(db, p);\n      }\n    }else{\n      assert( sqlite3MemdebugHasType(p, (MEMTYPE_LOOKASIDE|MEMTYPE_HEAP)) );\n      assert( sqlite3MemdebugNoType(p, (u8)~(MEMTYPE_LOOKASIDE|MEMTYPE_HEAP)) );\n      sqlite3MemdebugSetType(p, MEMTYPE_HEAP);\n      pNew = sqlite3_realloc64(p, n);\n      if( !pNew ){\n        sqlite3OomFault(db);\n      }\n      sqlite3MemdebugSetType(pNew,\n            (db->lookaside.bDisable==0 ? MEMTYPE_LOOKASIDE : MEMTYPE_HEAP));\n    }\n  }\n  return pNew;\n}\n\n/*\n** Attempt to reallocate p.  If the reallocation fails, then free p\n** and set the mallocFailed flag in the database connection.\n*/\nSQLITE_PRIVATE void *sqlite3DbReallocOrFree(sqlite3 *db, void *p, u64 n){\n  void *pNew;\n  pNew = sqlite3DbRealloc(db, p, n);\n  if( !pNew ){\n    sqlite3DbFree(db, p);\n  }\n  return pNew;\n}\n\n/*\n** Make a copy of a string in memory obtained from sqliteMalloc(). These \n** functions call sqlite3MallocRaw() directly instead of sqliteMalloc(). This\n** is because when memory debugging is turned on, these two functions are \n** called via macros that record the current file and line number in the\n** ThreadData structure.\n*/\nSQLITE_PRIVATE char *sqlite3DbStrDup(sqlite3 *db, const char *z){\n  char *zNew;\n  size_t n;\n  if( z==0 ){\n    return 0;\n  }\n  n = strlen(z) + 1;\n  zNew = sqlite3DbMallocRaw(db, n);\n  if( zNew ){\n    memcpy(zNew, z, n);\n  }\n  return zNew;\n}\nSQLITE_PRIVATE char *sqlite3DbStrNDup(sqlite3 *db, const char *z, u64 n){\n  char *zNew;\n  assert( db!=0 );\n  if( z==0 ){\n    return 0;\n  }\n  assert( (n&0x7fffffff)==n );\n  zNew = sqlite3DbMallocRawNN(db, n+1);\n  if( zNew ){\n    memcpy(zNew, z, (size_t)n);\n    zNew[n] = 0;\n  }\n  return zNew;\n}\n\n/*\n** The text between zStart and zEnd represents a phrase within a larger\n** SQL statement.  Make a copy of this phrase in space obtained form\n** sqlite3DbMalloc().  Omit leading and trailing whitespace.\n*/\nSQLITE_PRIVATE char *sqlite3DbSpanDup(sqlite3 *db, const char *zStart, const char *zEnd){\n  int n;\n  while( sqlite3Isspace(zStart[0]) ) zStart++;\n  n = (int)(zEnd - zStart);\n  while( ALWAYS(n>0) && sqlite3Isspace(zStart[n-1]) ) n--;\n  return sqlite3DbStrNDup(db, zStart, n);\n}\n\n/*\n** Free any prior content in *pz and replace it with a copy of zNew.\n*/\nSQLITE_PRIVATE void sqlite3SetString(char **pz, sqlite3 *db, const char *zNew){\n  sqlite3DbFree(db, *pz);\n  *pz = sqlite3DbStrDup(db, zNew);\n}\n\n/*\n** Call this routine to record the fact that an OOM (out-of-memory) error\n** has happened.  This routine will set db->mallocFailed, and also\n** temporarily disable the lookaside memory allocator and interrupt\n** any running VDBEs.\n*/\nSQLITE_PRIVATE void sqlite3OomFault(sqlite3 *db){\n  if( db->mallocFailed==0 && db->bBenignMalloc==0 ){\n    db->mallocFailed = 1;\n    if( db->nVdbeExec>0 ){\n      db->u1.isInterrupted = 1;\n    }\n    db->lookaside.bDisable++;\n  }\n}\n\n/*\n** This routine reactivates the memory allocator and clears the\n** db->mallocFailed flag as necessary.\n**\n** The memory allocator is not restarted if there are running\n** VDBEs.\n*/\nSQLITE_PRIVATE void sqlite3OomClear(sqlite3 *db){\n  if( db->mallocFailed && db->nVdbeExec==0 ){\n    db->mallocFailed = 0;\n    db->u1.isInterrupted = 0;\n    assert( db->lookaside.bDisable>0 );\n    db->lookaside.bDisable--;\n  }\n}\n\n/*\n** Take actions at the end of an API call to indicate an OOM error\n*/\nstatic SQLITE_NOINLINE int apiOomError(sqlite3 *db){\n  sqlite3OomClear(db);\n  sqlite3Error(db, SQLITE_NOMEM);\n  return SQLITE_NOMEM_BKPT;\n}\n\n/*\n** This function must be called before exiting any API function (i.e. \n** returning control to the user) that has called sqlite3_malloc or\n** sqlite3_realloc.\n**\n** The returned value is normally a copy of the second argument to this\n** function. However, if a malloc() failure has occurred since the previous\n** invocation SQLITE_NOMEM is returned instead. \n**\n** If an OOM as occurred, then the connection error-code (the value\n** returned by sqlite3_errcode()) is set to SQLITE_NOMEM.\n*/\nSQLITE_PRIVATE int sqlite3ApiExit(sqlite3* db, int rc){\n  /* If the db handle must hold the connection handle mutex here.\n  ** Otherwise the read (and possible write) of db->mallocFailed \n  ** is unsafe, as is the call to sqlite3Error().\n  */\n  assert( db!=0 );\n  assert( sqlite3_mutex_held(db->mutex) );\n  if( db->mallocFailed || rc==SQLITE_IOERR_NOMEM ){\n    return apiOomError(db);\n  }\n  return rc & db->errMask;\n}\n\n/************** End of malloc.c **********************************************/\n/************** Begin file printf.c ******************************************/\n/*\n** The \"printf\" code that follows dates from the 1980's.  It is in\n** the public domain. \n**\n**************************************************************************\n**\n** This file contains code for a set of \"printf\"-like routines.  These\n** routines format strings much like the printf() from the standard C\n** library, though the implementation here has enhancements to support\n** SQLite.\n*/\n/* #include \"sqliteInt.h\" */\n\n/*\n** Conversion types fall into various categories as defined by the\n** following enumeration.\n*/\n#define etRADIX       0 /* non-decimal integer types.  %x %o */\n#define etFLOAT       1 /* Floating point.  %f */\n#define etEXP         2 /* Exponentional notation. %e and %E */\n#define etGENERIC     3 /* Floating or exponential, depending on exponent. %g */\n#define etSIZE        4 /* Return number of characters processed so far. %n */\n#define etSTRING      5 /* Strings. %s */\n#define etDYNSTRING   6 /* Dynamically allocated strings. %z */\n#define etPERCENT     7 /* Percent symbol. %% */\n#define etCHARX       8 /* Characters. %c */\n/* The rest are extensions, not normally found in printf() */\n#define etSQLESCAPE   9 /* Strings with '\\'' doubled.  %q */\n#define etSQLESCAPE2 10 /* Strings with '\\'' doubled and enclosed in '',\n                          NULL pointers replaced by SQL NULL.  %Q */\n#define etTOKEN      11 /* a pointer to a Token structure */\n#define etSRCLIST    12 /* a pointer to a SrcList */\n#define etPOINTER    13 /* The %p conversion */\n#define etSQLESCAPE3 14 /* %w -> Strings with '\\\"' doubled */\n#define etORDINAL    15 /* %r -> 1st, 2nd, 3rd, 4th, etc.  English only */\n#define etDECIMAL    16 /* %d or %u, but not %x, %o */\n\n#define etINVALID    17 /* Any unrecognized conversion type */\n\n\n/*\n** An \"etByte\" is an 8-bit unsigned value.\n*/\ntypedef unsigned char etByte;\n\n/*\n** Each builtin conversion character (ex: the 'd' in \"%d\") is described\n** by an instance of the following structure\n*/\ntypedef struct et_info {   /* Information about each format field */\n  char fmttype;            /* The format field code letter */\n  etByte base;             /* The base for radix conversion */\n  etByte flags;            /* One or more of FLAG_ constants below */\n  etByte type;             /* Conversion paradigm */\n  etByte charset;          /* Offset into aDigits[] of the digits string */\n  etByte prefix;           /* Offset into aPrefix[] of the prefix string */\n} et_info;\n\n/*\n** Allowed values for et_info.flags\n*/\n#define FLAG_SIGNED    1     /* True if the value to convert is signed */\n#define FLAG_STRING    4     /* Allow infinite precision */\n\n\n/*\n** The following table is searched linearly, so it is good to put the\n** most frequently used conversion types first.\n*/\nstatic const char aDigits[] = \"0123456789ABCDEF0123456789abcdef\";\nstatic const char aPrefix[] = \"-x0\\000X0\";\nstatic const et_info fmtinfo[] = {\n  {  'd', 10, 1, etDECIMAL,    0,  0 },\n  {  's',  0, 4, etSTRING,     0,  0 },\n  {  'g',  0, 1, etGENERIC,    30, 0 },\n  {  'z',  0, 4, etDYNSTRING,  0,  0 },\n  {  'q',  0, 4, etSQLESCAPE,  0,  0 },\n  {  'Q',  0, 4, etSQLESCAPE2, 0,  0 },\n  {  'w',  0, 4, etSQLESCAPE3, 0,  0 },\n  {  'c',  0, 0, etCHARX,      0,  0 },\n  {  'o',  8, 0, etRADIX,      0,  2 },\n  {  'u', 10, 0, etDECIMAL,    0,  0 },\n  {  'x', 16, 0, etRADIX,      16, 1 },\n  {  'X', 16, 0, etRADIX,      0,  4 },\n#ifndef SQLITE_OMIT_FLOATING_POINT\n  {  'f',  0, 1, etFLOAT,      0,  0 },\n  {  'e',  0, 1, etEXP,        30, 0 },\n  {  'E',  0, 1, etEXP,        14, 0 },\n  {  'G',  0, 1, etGENERIC,    14, 0 },\n#endif\n  {  'i', 10, 1, etDECIMAL,    0,  0 },\n  {  'n',  0, 0, etSIZE,       0,  0 },\n  {  '%',  0, 0, etPERCENT,    0,  0 },\n  {  'p', 16, 0, etPOINTER,    0,  1 },\n\n  /* All the rest are undocumented and are for internal use only */\n  {  'T',  0, 0, etTOKEN,      0,  0 },\n  {  'S',  0, 0, etSRCLIST,    0,  0 },\n  {  'r', 10, 1, etORDINAL,    0,  0 },\n};\n\n/*\n** If SQLITE_OMIT_FLOATING_POINT is defined, then none of the floating point\n** conversions will work.\n*/\n#ifndef SQLITE_OMIT_FLOATING_POINT\n/*\n** \"*val\" is a double such that 0.1 <= *val < 10.0\n** Return the ascii code for the leading digit of *val, then\n** multiply \"*val\" by 10.0 to renormalize.\n**\n** Example:\n**     input:     *val = 3.14159\n**     output:    *val = 1.4159    function return = '3'\n**\n** The counter *cnt is incremented each time.  After counter exceeds\n** 16 (the number of significant digits in a 64-bit float) '0' is\n** always returned.\n*/\nstatic char et_getdigit(LONGDOUBLE_TYPE *val, int *cnt){\n  int digit;\n  LONGDOUBLE_TYPE d;\n  if( (*cnt)<=0 ) return '0';\n  (*cnt)--;\n  digit = (int)*val;\n  d = digit;\n  digit += '0';\n  *val = (*val - d)*10.0;\n  return (char)digit;\n}\n#endif /* SQLITE_OMIT_FLOATING_POINT */\n\n/*\n** Set the StrAccum object to an error mode.\n*/\nstatic void setStrAccumError(StrAccum *p, u8 eError){\n  assert( eError==SQLITE_NOMEM || eError==SQLITE_TOOBIG );\n  p->accError = eError;\n  p->nAlloc = 0;\n}\n\n/*\n** Extra argument values from a PrintfArguments object\n*/\nstatic sqlite3_int64 getIntArg(PrintfArguments *p){\n  if( p->nArg<=p->nUsed ) return 0;\n  return sqlite3_value_int64(p->apArg[p->nUsed++]);\n}\nstatic double getDoubleArg(PrintfArguments *p){\n  if( p->nArg<=p->nUsed ) return 0.0;\n  return sqlite3_value_double(p->apArg[p->nUsed++]);\n}\nstatic char *getTextArg(PrintfArguments *p){\n  if( p->nArg<=p->nUsed ) return 0;\n  return (char*)sqlite3_value_text(p->apArg[p->nUsed++]);\n}\n\n/*\n** Allocate memory for a temporary buffer needed for printf rendering.\n**\n** If the requested size of the temp buffer is larger than the size\n** of the output buffer in pAccum, then cause an SQLITE_TOOBIG error.\n** Do the size check before the memory allocation to prevent rogue\n** SQL from requesting large allocations using the precision or width\n** field of the printf() function.\n*/\nstatic char *printfTempBuf(sqlite3_str *pAccum, sqlite3_int64 n){\n  char *z;\n  if( n>pAccum->nAlloc && n>pAccum->mxAlloc ){\n    setStrAccumError(pAccum, SQLITE_TOOBIG);\n    return 0;\n  }\n  z = sqlite3DbMallocRaw(pAccum->db, n);\n  if( z==0 ){\n    setStrAccumError(pAccum, SQLITE_NOMEM);\n  }\n  return z;\n}\n\n/*\n** On machines with a small stack size, you can redefine the\n** SQLITE_PRINT_BUF_SIZE to be something smaller, if desired.\n*/\n#ifndef SQLITE_PRINT_BUF_SIZE\n# define SQLITE_PRINT_BUF_SIZE 70\n#endif\n#define etBUFSIZE SQLITE_PRINT_BUF_SIZE  /* Size of the output buffer */\n\n/*\n** Render a string given by \"fmt\" into the StrAccum object.\n*/\nSQLITE_API void sqlite3_str_vappendf(\n  sqlite3_str *pAccum,       /* Accumulate results here */\n  const char *fmt,           /* Format string */\n  va_list ap                 /* arguments */\n){\n  int c;                     /* Next character in the format string */\n  char *bufpt;               /* Pointer to the conversion buffer */\n  int precision;             /* Precision of the current field */\n  int length;                /* Length of the field */\n  int idx;                   /* A general purpose loop counter */\n  int width;                 /* Width of the current field */\n  etByte flag_leftjustify;   /* True if \"-\" flag is present */\n  etByte flag_prefix;        /* '+' or ' ' or 0 for prefix */\n  etByte flag_alternateform; /* True if \"#\" flag is present */\n  etByte flag_altform2;      /* True if \"!\" flag is present */\n  etByte flag_zeropad;       /* True if field width constant starts with zero */\n  etByte flag_long;          /* 1 for the \"l\" flag, 2 for \"ll\", 0 by default */\n  etByte done;               /* Loop termination flag */\n  etByte cThousand;          /* Thousands separator for %d and %u */\n  etByte xtype = etINVALID;  /* Conversion paradigm */\n  u8 bArgList;               /* True for SQLITE_PRINTF_SQLFUNC */\n  char prefix;               /* Prefix character.  \"+\" or \"-\" or \" \" or '\\0'. */\n  sqlite_uint64 longvalue;   /* Value for integer types */\n  LONGDOUBLE_TYPE realvalue; /* Value for real types */\n  const et_info *infop;      /* Pointer to the appropriate info structure */\n  char *zOut;                /* Rendering buffer */\n  int nOut;                  /* Size of the rendering buffer */\n  char *zExtra = 0;          /* Malloced memory used by some conversion */\n#ifndef SQLITE_OMIT_FLOATING_POINT\n  int  exp, e2;              /* exponent of real numbers */\n  int nsd;                   /* Number of significant digits returned */\n  double rounder;            /* Used for rounding floating point values */\n  etByte flag_dp;            /* True if decimal point should be shown */\n  etByte flag_rtz;           /* True if trailing zeros should be removed */\n#endif\n  PrintfArguments *pArgList = 0; /* Arguments for SQLITE_PRINTF_SQLFUNC */\n  char buf[etBUFSIZE];       /* Conversion buffer */\n\n  /* pAccum never starts out with an empty buffer that was obtained from \n  ** malloc().  This precondition is required by the mprintf(\"%z...\")\n  ** optimization. */\n  assert( pAccum->nChar>0 || (pAccum->printfFlags&SQLITE_PRINTF_MALLOCED)==0 );\n\n  bufpt = 0;\n  if( (pAccum->printfFlags & SQLITE_PRINTF_SQLFUNC)!=0 ){\n    pArgList = va_arg(ap, PrintfArguments*);\n    bArgList = 1;\n  }else{\n    bArgList = 0;\n  }\n  for(; (c=(*fmt))!=0; ++fmt){\n    if( c!='%' ){\n      bufpt = (char *)fmt;\n#if HAVE_STRCHRNUL\n      fmt = strchrnul(fmt, '%');\n#else\n      do{ fmt++; }while( *fmt && *fmt != '%' );\n#endif\n      sqlite3_str_append(pAccum, bufpt, (int)(fmt - bufpt));\n      if( *fmt==0 ) break;\n    }\n    if( (c=(*++fmt))==0 ){\n      sqlite3_str_append(pAccum, \"%\", 1);\n      break;\n    }\n    /* Find out what flags are present */\n    flag_leftjustify = flag_prefix = cThousand =\n     flag_alternateform = flag_altform2 = flag_zeropad = 0;\n    done = 0;\n    width = 0;\n    flag_long = 0;\n    precision = -1;\n    do{\n      switch( c ){\n        case '-':   flag_leftjustify = 1;     break;\n        case '+':   flag_prefix = '+';        break;\n        case ' ':   flag_prefix = ' ';        break;\n        case '#':   flag_alternateform = 1;   break;\n        case '!':   flag_altform2 = 1;        break;\n        case '0':   flag_zeropad = 1;         break;\n        case ',':   cThousand = ',';          break;\n        default:    done = 1;                 break;\n        case 'l': {\n          flag_long = 1;\n          c = *++fmt;\n          if( c=='l' ){\n            c = *++fmt;\n            flag_long = 2;\n          }\n          done = 1;\n          break;\n        }\n        case '1': case '2': case '3': case '4': case '5':\n        case '6': case '7': case '8': case '9': {\n          unsigned wx = c - '0';\n          while( (c = *++fmt)>='0' && c<='9' ){\n            wx = wx*10 + c - '0';\n          }\n          testcase( wx>0x7fffffff );\n          width = wx & 0x7fffffff;\n#ifdef SQLITE_PRINTF_PRECISION_LIMIT\n          if( width>SQLITE_PRINTF_PRECISION_LIMIT ){\n            width = SQLITE_PRINTF_PRECISION_LIMIT;\n          }\n#endif\n          if( c!='.' && c!='l' ){\n            done = 1;\n          }else{\n            fmt--;\n          }\n          break;\n        }\n        case '*': {\n          if( bArgList ){\n            width = (int)getIntArg(pArgList);\n          }else{\n            width = va_arg(ap,int);\n          }\n          if( width<0 ){\n            flag_leftjustify = 1;\n            width = width >= -2147483647 ? -width : 0;\n          }\n#ifdef SQLITE_PRINTF_PRECISION_LIMIT\n          if( width>SQLITE_PRINTF_PRECISION_LIMIT ){\n            width = SQLITE_PRINTF_PRECISION_LIMIT;\n          }\n#endif\n          if( (c = fmt[1])!='.' && c!='l' ){\n            c = *++fmt;\n            done = 1;\n          }\n          break;\n        }\n        case '.': {\n          c = *++fmt;\n          if( c=='*' ){\n            if( bArgList ){\n              precision = (int)getIntArg(pArgList);\n            }else{\n              precision = va_arg(ap,int);\n            }\n            if( precision<0 ){\n              precision = precision >= -2147483647 ? -precision : -1;\n            }\n            c = *++fmt;\n          }else{\n            unsigned px = 0;\n            while( c>='0' && c<='9' ){\n              px = px*10 + c - '0';\n              c = *++fmt;\n            }\n            testcase( px>0x7fffffff );\n            precision = px & 0x7fffffff;\n          }\n#ifdef SQLITE_PRINTF_PRECISION_LIMIT\n          if( precision>SQLITE_PRINTF_PRECISION_LIMIT ){\n            precision = SQLITE_PRINTF_PRECISION_LIMIT;\n          }\n#endif\n          if( c=='l' ){\n            --fmt;\n          }else{\n            done = 1;\n          }\n          break;\n        }\n      }\n    }while( !done && (c=(*++fmt))!=0 );\n\n    /* Fetch the info entry for the field */\n    infop = &fmtinfo[0];\n    xtype = etINVALID;\n    for(idx=0; idx<ArraySize(fmtinfo); idx++){\n      if( c==fmtinfo[idx].fmttype ){\n        infop = &fmtinfo[idx];\n        xtype = infop->type;\n        break;\n      }\n    }\n\n    /*\n    ** At this point, variables are initialized as follows:\n    **\n    **   flag_alternateform          TRUE if a '#' is present.\n    **   flag_altform2               TRUE if a '!' is present.\n    **   flag_prefix                 '+' or ' ' or zero\n    **   flag_leftjustify            TRUE if a '-' is present or if the\n    **                               field width was negative.\n    **   flag_zeropad                TRUE if the width began with 0.\n    **   flag_long                   1 for \"l\", 2 for \"ll\"\n    **   width                       The specified field width.  This is\n    **                               always non-negative.  Zero is the default.\n    **   precision                   The specified precision.  The default\n    **                               is -1.\n    **   xtype                       The class of the conversion.\n    **   infop                       Pointer to the appropriate info struct.\n    */\n    switch( xtype ){\n      case etPOINTER:\n        flag_long = sizeof(char*)==sizeof(i64) ? 2 :\n                     sizeof(char*)==sizeof(long int) ? 1 : 0;\n        /* Fall through into the next case */\n      case etORDINAL:\n      case etRADIX:      \n        cThousand = 0;\n        /* Fall through into the next case */\n      case etDECIMAL:\n        if( infop->flags & FLAG_SIGNED ){\n          i64 v;\n          if( bArgList ){\n            v = getIntArg(pArgList);\n          }else if( flag_long ){\n            if( flag_long==2 ){\n              v = va_arg(ap,i64) ;\n            }else{\n              v = va_arg(ap,long int);\n            }\n          }else{\n            v = va_arg(ap,int);\n          }\n          if( v<0 ){\n            if( v==SMALLEST_INT64 ){\n              longvalue = ((u64)1)<<63;\n            }else{\n              longvalue = -v;\n            }\n            prefix = '-';\n          }else{\n            longvalue = v;\n            prefix = flag_prefix;\n          }\n        }else{\n          if( bArgList ){\n            longvalue = (u64)getIntArg(pArgList);\n          }else if( flag_long ){\n            if( flag_long==2 ){\n              longvalue = va_arg(ap,u64);\n            }else{\n              longvalue = va_arg(ap,unsigned long int);\n            }\n          }else{\n            longvalue = va_arg(ap,unsigned int);\n          }\n          prefix = 0;\n        }\n        if( longvalue==0 ) flag_alternateform = 0;\n        if( flag_zeropad && precision<width-(prefix!=0) ){\n          precision = width-(prefix!=0);\n        }\n        if( precision<etBUFSIZE-10-etBUFSIZE/3 ){\n          nOut = etBUFSIZE;\n          zOut = buf;\n        }else{\n          u64 n;\n          n = (u64)precision + 10;\n          if( cThousand ) n += precision/3;\n          zOut = zExtra = printfTempBuf(pAccum, n);\n          if( zOut==0 ) return;\n          nOut = (int)n;\n        }\n        bufpt = &zOut[nOut-1];\n        if( xtype==etORDINAL ){\n          static const char zOrd[] = \"thstndrd\";\n          int x = (int)(longvalue % 10);\n          if( x>=4 || (longvalue/10)%10==1 ){\n            x = 0;\n          }\n          *(--bufpt) = zOrd[x*2+1];\n          *(--bufpt) = zOrd[x*2];\n        }\n        {\n          const char *cset = &aDigits[infop->charset];\n          u8 base = infop->base;\n          do{                                           /* Convert to ascii */\n            *(--bufpt) = cset[longvalue%base];\n            longvalue = longvalue/base;\n          }while( longvalue>0 );\n        }\n        length = (int)(&zOut[nOut-1]-bufpt);\n        while( precision>length ){\n          *(--bufpt) = '0';                             /* Zero pad */\n          length++;\n        }\n        if( cThousand ){\n          int nn = (length - 1)/3;  /* Number of \",\" to insert */\n          int ix = (length - 1)%3 + 1;\n          bufpt -= nn;\n          for(idx=0; nn>0; idx++){\n            bufpt[idx] = bufpt[idx+nn];\n            ix--;\n            if( ix==0 ){\n              bufpt[++idx] = cThousand;\n              nn--;\n              ix = 3;\n            }\n          }\n        }\n        if( prefix ) *(--bufpt) = prefix;               /* Add sign */\n        if( flag_alternateform && infop->prefix ){      /* Add \"0\" or \"0x\" */\n          const char *pre;\n          char x;\n          pre = &aPrefix[infop->prefix];\n          for(; (x=(*pre))!=0; pre++) *(--bufpt) = x;\n        }\n        length = (int)(&zOut[nOut-1]-bufpt);\n        break;\n      case etFLOAT:\n      case etEXP:\n      case etGENERIC:\n        if( bArgList ){\n          realvalue = getDoubleArg(pArgList);\n        }else{\n          realvalue = va_arg(ap,double);\n        }\n#ifdef SQLITE_OMIT_FLOATING_POINT\n        length = 0;\n#else\n        if( precision<0 ) precision = 6;         /* Set default precision */\n        if( realvalue<0.0 ){\n          realvalue = -realvalue;\n          prefix = '-';\n        }else{\n          prefix = flag_prefix;\n        }\n        if( xtype==etGENERIC && precision>0 ) precision--;\n        testcase( precision>0xfff );\n        for(idx=precision&0xfff, rounder=0.5; idx>0; idx--, rounder*=0.1){}\n        if( xtype==etFLOAT ) realvalue += rounder;\n        /* Normalize realvalue to within 10.0 > realvalue >= 1.0 */\n        exp = 0;\n        if( sqlite3IsNaN((double)realvalue) ){\n          bufpt = \"NaN\";\n          length = 3;\n          break;\n        }\n        if( realvalue>0.0 ){\n          LONGDOUBLE_TYPE scale = 1.0;\n          while( realvalue>=1e100*scale && exp<=350 ){ scale *= 1e100;exp+=100;}\n          while( realvalue>=1e10*scale && exp<=350 ){ scale *= 1e10; exp+=10; }\n          while( realvalue>=10.0*scale && exp<=350 ){ scale *= 10.0; exp++; }\n          realvalue /= scale;\n          while( realvalue<1e-8 ){ realvalue *= 1e8; exp-=8; }\n          while( realvalue<1.0 ){ realvalue *= 10.0; exp--; }\n          if( exp>350 ){\n            bufpt = buf;\n            buf[0] = prefix;\n            memcpy(buf+(prefix!=0),\"Inf\",4);\n            length = 3+(prefix!=0);\n            break;\n          }\n        }\n        bufpt = buf;\n        /*\n        ** If the field type is etGENERIC, then convert to either etEXP\n        ** or etFLOAT, as appropriate.\n        */\n        if( xtype!=etFLOAT ){\n          realvalue += rounder;\n          if( realvalue>=10.0 ){ realvalue *= 0.1; exp++; }\n        }\n        if( xtype==etGENERIC ){\n          flag_rtz = !flag_alternateform;\n          if( exp<-4 || exp>precision ){\n            xtype = etEXP;\n          }else{\n            precision = precision - exp;\n            xtype = etFLOAT;\n          }\n        }else{\n          flag_rtz = flag_altform2;\n        }\n        if( xtype==etEXP ){\n          e2 = 0;\n        }else{\n          e2 = exp;\n        }\n        {\n          i64 szBufNeeded;           /* Size of a temporary buffer needed */\n          szBufNeeded = MAX(e2,0)+(i64)precision+(i64)width+15;\n          if( szBufNeeded > etBUFSIZE ){\n            bufpt = zExtra = printfTempBuf(pAccum, szBufNeeded);\n            if( bufpt==0 ) return;\n          }\n        }\n        zOut = bufpt;\n        nsd = 16 + flag_altform2*10;\n        flag_dp = (precision>0 ?1:0) | flag_alternateform | flag_altform2;\n        /* The sign in front of the number */\n        if( prefix ){\n          *(bufpt++) = prefix;\n        }\n        /* Digits prior to the decimal point */\n        if( e2<0 ){\n          *(bufpt++) = '0';\n        }else{\n          for(; e2>=0; e2--){\n            *(bufpt++) = et_getdigit(&realvalue,&nsd);\n          }\n        }\n        /* The decimal point */\n        if( flag_dp ){\n          *(bufpt++) = '.';\n        }\n        /* \"0\" digits after the decimal point but before the first\n        ** significant digit of the number */\n        for(e2++; e2<0; precision--, e2++){\n          assert( precision>0 );\n          *(bufpt++) = '0';\n        }\n        /* Significant digits after the decimal point */\n        while( (precision--)>0 ){\n          *(bufpt++) = et_getdigit(&realvalue,&nsd);\n        }\n        /* Remove trailing zeros and the \".\" if no digits follow the \".\" */\n        if( flag_rtz && flag_dp ){\n          while( bufpt[-1]=='0' ) *(--bufpt) = 0;\n          assert( bufpt>zOut );\n          if( bufpt[-1]=='.' ){\n            if( flag_altform2 ){\n              *(bufpt++) = '0';\n            }else{\n              *(--bufpt) = 0;\n            }\n          }\n        }\n        /* Add the \"eNNN\" suffix */\n        if( xtype==etEXP ){\n          *(bufpt++) = aDigits[infop->charset];\n          if( exp<0 ){\n            *(bufpt++) = '-'; exp = -exp;\n          }else{\n            *(bufpt++) = '+';\n          }\n          if( exp>=100 ){\n            *(bufpt++) = (char)((exp/100)+'0');        /* 100's digit */\n            exp %= 100;\n          }\n          *(bufpt++) = (char)(exp/10+'0');             /* 10's digit */\n          *(bufpt++) = (char)(exp%10+'0');             /* 1's digit */\n        }\n        *bufpt = 0;\n\n        /* The converted number is in buf[] and zero terminated. Output it.\n        ** Note that the number is in the usual order, not reversed as with\n        ** integer conversions. */\n        length = (int)(bufpt-zOut);\n        bufpt = zOut;\n\n        /* Special case:  Add leading zeros if the flag_zeropad flag is\n        ** set and we are not left justified */\n        if( flag_zeropad && !flag_leftjustify && length < width){\n          int i;\n          int nPad = width - length;\n          for(i=width; i>=nPad; i--){\n            bufpt[i] = bufpt[i-nPad];\n          }\n          i = prefix!=0;\n          while( nPad-- ) bufpt[i++] = '0';\n          length = width;\n        }\n#endif /* !defined(SQLITE_OMIT_FLOATING_POINT) */\n        break;\n      case etSIZE:\n        if( !bArgList ){\n          *(va_arg(ap,int*)) = pAccum->nChar;\n        }\n        length = width = 0;\n        break;\n      case etPERCENT:\n        buf[0] = '%';\n        bufpt = buf;\n        length = 1;\n        break;\n      case etCHARX:\n        if( bArgList ){\n          bufpt = getTextArg(pArgList);\n          length = 1;\n          if( bufpt ){\n            buf[0] = c = *(bufpt++);\n            if( (c&0xc0)==0xc0 ){\n              while( length<4 && (bufpt[0]&0xc0)==0x80 ){\n                buf[length++] = *(bufpt++);\n              }\n            }\n          }else{\n            buf[0] = 0;\n          }\n        }else{\n          unsigned int ch = va_arg(ap,unsigned int);\n          if( ch<0x00080 ){\n            buf[0] = ch & 0xff;\n            length = 1;\n          }else if( ch<0x00800 ){\n            buf[0] = 0xc0 + (u8)((ch>>6)&0x1f);\n            buf[1] = 0x80 + (u8)(ch & 0x3f);\n            length = 2;\n          }else if( ch<0x10000 ){\n            buf[0] = 0xe0 + (u8)((ch>>12)&0x0f);\n            buf[1] = 0x80 + (u8)((ch>>6) & 0x3f);\n            buf[2] = 0x80 + (u8)(ch & 0x3f);\n            length = 3;\n          }else{\n            buf[0] = 0xf0 + (u8)((ch>>18) & 0x07);\n            buf[1] = 0x80 + (u8)((ch>>12) & 0x3f);\n            buf[2] = 0x80 + (u8)((ch>>6) & 0x3f);\n            buf[3] = 0x80 + (u8)(ch & 0x3f);\n            length = 4;\n          }\n        }\n        if( precision>1 ){\n          width -= precision-1;\n          if( width>1 && !flag_leftjustify ){\n            sqlite3_str_appendchar(pAccum, width-1, ' ');\n            width = 0;\n          }\n          while( precision-- > 1 ){\n            sqlite3_str_append(pAccum, buf, length);\n          }\n        }\n        bufpt = buf;\n        flag_altform2 = 1;\n        goto adjust_width_for_utf8;\n      case etSTRING:\n      case etDYNSTRING:\n        if( bArgList ){\n          bufpt = getTextArg(pArgList);\n          xtype = etSTRING;\n        }else{\n          bufpt = va_arg(ap,char*);\n        }\n        if( bufpt==0 ){\n          bufpt = \"\";\n        }else if( xtype==etDYNSTRING ){\n          if( pAccum->nChar==0\n           && pAccum->mxAlloc\n           && width==0\n           && precision<0\n           && pAccum->accError==0\n          ){\n            /* Special optimization for sqlite3_mprintf(\"%z...\"):\n            ** Extend an existing memory allocation rather than creating\n            ** a new one. */\n            assert( (pAccum->printfFlags&SQLITE_PRINTF_MALLOCED)==0 );\n            pAccum->zText = bufpt;\n            pAccum->nAlloc = sqlite3DbMallocSize(pAccum->db, bufpt);\n            pAccum->nChar = 0x7fffffff & (int)strlen(bufpt);\n            pAccum->printfFlags |= SQLITE_PRINTF_MALLOCED;\n            length = 0;\n            break;\n          }\n          zExtra = bufpt;\n        }\n        if( precision>=0 ){\n          if( flag_altform2 ){\n            /* Set length to the number of bytes needed in order to display\n            ** precision characters */\n            unsigned char *z = (unsigned char*)bufpt;\n            while( precision-- > 0 && z[0] ){\n              SQLITE_SKIP_UTF8(z);\n            }\n            length = (int)(z - (unsigned char*)bufpt);\n          }else{\n            for(length=0; length<precision && bufpt[length]; length++){}\n          }\n        }else{\n          length = 0x7fffffff & (int)strlen(bufpt);\n        }\n      adjust_width_for_utf8:\n        if( flag_altform2 && width>0 ){\n          /* Adjust width to account for extra bytes in UTF-8 characters */\n          int ii = length - 1;\n          while( ii>=0 ) if( (bufpt[ii--] & 0xc0)==0x80 ) width++;\n        }\n        break;\n      case etSQLESCAPE:           /* %q: Escape ' characters */\n      case etSQLESCAPE2:          /* %Q: Escape ' and enclose in '...' */\n      case etSQLESCAPE3: {        /* %w: Escape \" characters */\n        int i, j, k, n, isnull;\n        int needQuote;\n        char ch;\n        char q = ((xtype==etSQLESCAPE3)?'\"':'\\'');   /* Quote character */\n        char *escarg;\n\n        if( bArgList ){\n          escarg = getTextArg(pArgList);\n        }else{\n          escarg = va_arg(ap,char*);\n        }\n        isnull = escarg==0;\n        if( isnull ) escarg = (xtype==etSQLESCAPE2 ? \"NULL\" : \"(NULL)\");\n        /* For %q, %Q, and %w, the precision is the number of byte (or\n        ** characters if the ! flags is present) to use from the input.\n        ** Because of the extra quoting characters inserted, the number\n        ** of output characters may be larger than the precision.\n        */\n        k = precision;\n        for(i=n=0; k!=0 && (ch=escarg[i])!=0; i++, k--){\n          if( ch==q )  n++;\n          if( flag_altform2 && (ch&0xc0)==0xc0 ){\n            while( (escarg[i+1]&0xc0)==0x80 ){ i++; }\n          }\n        }\n        needQuote = !isnull && xtype==etSQLESCAPE2;\n        n += i + 3;\n        if( n>etBUFSIZE ){\n          bufpt = zExtra = printfTempBuf(pAccum, n);\n          if( bufpt==0 ) return;\n        }else{\n          bufpt = buf;\n        }\n        j = 0;\n        if( needQuote ) bufpt[j++] = q;\n        k = i;\n        for(i=0; i<k; i++){\n          bufpt[j++] = ch = escarg[i];\n          if( ch==q ) bufpt[j++] = ch;\n        }\n        if( needQuote ) bufpt[j++] = q;\n        bufpt[j] = 0;\n        length = j;\n        goto adjust_width_for_utf8;\n      }\n      case etTOKEN: {\n        Token *pToken;\n        if( (pAccum->printfFlags & SQLITE_PRINTF_INTERNAL)==0 ) return;\n        pToken = va_arg(ap, Token*);\n        assert( bArgList==0 );\n        if( pToken && pToken->n ){\n          sqlite3_str_append(pAccum, (const char*)pToken->z, pToken->n);\n        }\n        length = width = 0;\n        break;\n      }\n      case etSRCLIST: {\n        SrcList *pSrc;\n        int k;\n        struct SrcList_item *pItem;\n        if( (pAccum->printfFlags & SQLITE_PRINTF_INTERNAL)==0 ) return;\n        pSrc = va_arg(ap, SrcList*);\n        k = va_arg(ap, int);\n        pItem = &pSrc->a[k];\n        assert( bArgList==0 );\n        assert( k>=0 && k<pSrc->nSrc );\n        if( pItem->zDatabase ){\n          sqlite3_str_appendall(pAccum, pItem->zDatabase);\n          sqlite3_str_append(pAccum, \".\", 1);\n        }\n        sqlite3_str_appendall(pAccum, pItem->zName);\n        length = width = 0;\n        break;\n      }\n      default: {\n        assert( xtype==etINVALID );\n        return;\n      }\n    }/* End switch over the format type */\n    /*\n    ** The text of the conversion is pointed to by \"bufpt\" and is\n    ** \"length\" characters long.  The field width is \"width\".  Do\n    ** the output.  Both length and width are in bytes, not characters,\n    ** at this point.  If the \"!\" flag was present on string conversions\n    ** indicating that width and precision should be expressed in characters,\n    ** then the values have been translated prior to reaching this point.\n    */\n    width -= length;\n    if( width>0 ){\n      if( !flag_leftjustify ) sqlite3_str_appendchar(pAccum, width, ' ');\n      sqlite3_str_append(pAccum, bufpt, length);\n      if( flag_leftjustify ) sqlite3_str_appendchar(pAccum, width, ' ');\n    }else{\n      sqlite3_str_append(pAccum, bufpt, length);\n    }\n\n    if( zExtra ){\n      sqlite3DbFree(pAccum->db, zExtra);\n      zExtra = 0;\n    }\n  }/* End for loop over the format string */\n} /* End of function */\n\n/*\n** Enlarge the memory allocation on a StrAccum object so that it is\n** able to accept at least N more bytes of text.\n**\n** Return the number of bytes of text that StrAccum is able to accept\n** after the attempted enlargement.  The value returned might be zero.\n*/\nstatic int sqlite3StrAccumEnlarge(StrAccum *p, int N){\n  char *zNew;\n  assert( p->nChar+(i64)N >= p->nAlloc ); /* Only called if really needed */\n  if( p->accError ){\n    testcase(p->accError==SQLITE_TOOBIG);\n    testcase(p->accError==SQLITE_NOMEM);\n    return 0;\n  }\n  if( p->mxAlloc==0 ){\n    N = p->nAlloc - p->nChar - 1;\n    setStrAccumError(p, SQLITE_TOOBIG);\n    return N;\n  }else{\n    char *zOld = isMalloced(p) ? p->zText : 0;\n    i64 szNew = p->nChar;\n    szNew += N + 1;\n    if( szNew+p->nChar<=p->mxAlloc ){\n      /* Force exponential buffer size growth as long as it does not overflow,\n      ** to avoid having to call this routine too often */\n      szNew += p->nChar;\n    }\n    if( szNew > p->mxAlloc ){\n      sqlite3_str_reset(p);\n      setStrAccumError(p, SQLITE_TOOBIG);\n      return 0;\n    }else{\n      p->nAlloc = (int)szNew;\n    }\n    if( p->db ){\n      zNew = sqlite3DbRealloc(p->db, zOld, p->nAlloc);\n    }else{\n      zNew = sqlite3_realloc64(zOld, p->nAlloc);\n    }\n    if( zNew ){\n      assert( p->zText!=0 || p->nChar==0 );\n      if( !isMalloced(p) && p->nChar>0 ) memcpy(zNew, p->zText, p->nChar);\n      p->zText = zNew;\n      p->nAlloc = sqlite3DbMallocSize(p->db, zNew);\n      p->printfFlags |= SQLITE_PRINTF_MALLOCED;\n    }else{\n      sqlite3_str_reset(p);\n      setStrAccumError(p, SQLITE_NOMEM);\n      return 0;\n    }\n  }\n  return N;\n}\n\n/*\n** Append N copies of character c to the given string buffer.\n*/\nSQLITE_API void sqlite3_str_appendchar(sqlite3_str *p, int N, char c){\n  testcase( p->nChar + (i64)N > 0x7fffffff );\n  if( p->nChar+(i64)N >= p->nAlloc && (N = sqlite3StrAccumEnlarge(p, N))<=0 ){\n    return;\n  }\n  while( (N--)>0 ) p->zText[p->nChar++] = c;\n}\n\n/*\n** The StrAccum \"p\" is not large enough to accept N new bytes of z[].\n** So enlarge if first, then do the append.\n**\n** This is a helper routine to sqlite3_str_append() that does special-case\n** work (enlarging the buffer) using tail recursion, so that the\n** sqlite3_str_append() routine can use fast calling semantics.\n*/\nstatic void SQLITE_NOINLINE enlargeAndAppend(StrAccum *p, const char *z, int N){\n  N = sqlite3StrAccumEnlarge(p, N);\n  if( N>0 ){\n    memcpy(&p->zText[p->nChar], z, N);\n    p->nChar += N;\n  }\n}\n\n/*\n** Append N bytes of text from z to the StrAccum object.  Increase the\n** size of the memory allocation for StrAccum if necessary.\n*/\nSQLITE_API void sqlite3_str_append(sqlite3_str *p, const char *z, int N){\n  assert( z!=0 || N==0 );\n  assert( p->zText!=0 || p->nChar==0 || p->accError );\n  assert( N>=0 );\n  assert( p->accError==0 || p->nAlloc==0 );\n  if( p->nChar+N >= p->nAlloc ){\n    enlargeAndAppend(p,z,N);\n  }else if( N ){\n    assert( p->zText );\n    p->nChar += N;\n    memcpy(&p->zText[p->nChar-N], z, N);\n  }\n}\n\n/*\n** Append the complete text of zero-terminated string z[] to the p string.\n*/\nSQLITE_API void sqlite3_str_appendall(sqlite3_str *p, const char *z){\n  sqlite3_str_append(p, z, sqlite3Strlen30(z));\n}\n\n\n/*\n** Finish off a string by making sure it is zero-terminated.\n** Return a pointer to the resulting string.  Return a NULL\n** pointer if any kind of error was encountered.\n*/\nstatic SQLITE_NOINLINE char *strAccumFinishRealloc(StrAccum *p){\n  char *zText;\n  assert( p->mxAlloc>0 && !isMalloced(p) );\n  zText = sqlite3DbMallocRaw(p->db, p->nChar+1 );\n  if( zText ){\n    memcpy(zText, p->zText, p->nChar+1);\n    p->printfFlags |= SQLITE_PRINTF_MALLOCED;\n  }else{\n    setStrAccumError(p, SQLITE_NOMEM);\n  }\n  p->zText = zText;\n  return zText;\n}\nSQLITE_PRIVATE char *sqlite3StrAccumFinish(StrAccum *p){\n  if( p->zText ){\n    p->zText[p->nChar] = 0;\n    if( p->mxAlloc>0 && !isMalloced(p) ){\n      return strAccumFinishRealloc(p);\n    }\n  }\n  return p->zText;\n}\n\n/*\n** This singleton is an sqlite3_str object that is returned if\n** sqlite3_malloc() fails to provide space for a real one.  This\n** sqlite3_str object accepts no new text and always returns\n** an SQLITE_NOMEM error.\n*/\nstatic sqlite3_str sqlite3OomStr = {\n   0, 0, 0, 0, 0, SQLITE_NOMEM, 0\n};\n\n/* Finalize a string created using sqlite3_str_new().\n*/\nSQLITE_API char *sqlite3_str_finish(sqlite3_str *p){\n  char *z;\n  if( p!=0 && p!=&sqlite3OomStr ){\n    z = sqlite3StrAccumFinish(p);\n    sqlite3_free(p);\n  }else{\n    z = 0;\n  }\n  return z;\n}\n\n/* Return any error code associated with p */\nSQLITE_API int sqlite3_str_errcode(sqlite3_str *p){\n  return p ? p->accError : SQLITE_NOMEM;\n}\n\n/* Return the current length of p in bytes */\nSQLITE_API int sqlite3_str_length(sqlite3_str *p){\n  return p ? p->nChar : 0;\n}\n\n/* Return the current value for p */\nSQLITE_API char *sqlite3_str_value(sqlite3_str *p){\n  if( p==0 || p->nChar==0 ) return 0;\n  p->zText[p->nChar] = 0;\n  return p->zText;\n}\n\n/*\n** Reset an StrAccum string.  Reclaim all malloced memory.\n*/\nSQLITE_API void sqlite3_str_reset(StrAccum *p){\n  if( isMalloced(p) ){\n    sqlite3DbFree(p->db, p->zText);\n    p->printfFlags &= ~SQLITE_PRINTF_MALLOCED;\n  }\n  p->nAlloc = 0;\n  p->nChar = 0;\n  p->zText = 0;\n}\n\n/*\n** Initialize a string accumulator.\n**\n** p:     The accumulator to be initialized.\n** db:    Pointer to a database connection.  May be NULL.  Lookaside\n**        memory is used if not NULL. db->mallocFailed is set appropriately\n**        when not NULL.\n** zBase: An initial buffer.  May be NULL in which case the initial buffer\n**        is malloced.\n** n:     Size of zBase in bytes.  If total space requirements never exceed\n**        n then no memory allocations ever occur.\n** mx:    Maximum number of bytes to accumulate.  If mx==0 then no memory\n**        allocations will ever occur.\n*/\nSQLITE_PRIVATE void sqlite3StrAccumInit(StrAccum *p, sqlite3 *db, char *zBase, int n, int mx){\n  p->zText = zBase;\n  p->db = db;\n  p->nAlloc = n;\n  p->mxAlloc = mx;\n  p->nChar = 0;\n  p->accError = 0;\n  p->printfFlags = 0;\n}\n\n/* Allocate and initialize a new dynamic string object */\nSQLITE_API sqlite3_str *sqlite3_str_new(sqlite3 *db){\n  sqlite3_str *p = sqlite3_malloc64(sizeof(*p));\n  if( p ){\n    sqlite3StrAccumInit(p, 0, 0, 0,\n            db ? db->aLimit[SQLITE_LIMIT_LENGTH] : SQLITE_MAX_LENGTH);\n  }else{\n    p = &sqlite3OomStr;\n  }\n  return p;\n}\n\n/*\n** Print into memory obtained from sqliteMalloc().  Use the internal\n** %-conversion extensions.\n*/\nSQLITE_PRIVATE char *sqlite3VMPrintf(sqlite3 *db, const char *zFormat, va_list ap){\n  char *z;\n  char zBase[SQLITE_PRINT_BUF_SIZE];\n  StrAccum acc;\n  assert( db!=0 );\n  sqlite3StrAccumInit(&acc, db, zBase, sizeof(zBase),\n                      db->aLimit[SQLITE_LIMIT_LENGTH]);\n  acc.printfFlags = SQLITE_PRINTF_INTERNAL;\n  sqlite3_str_vappendf(&acc, zFormat, ap);\n  z = sqlite3StrAccumFinish(&acc);\n  if( acc.accError==SQLITE_NOMEM ){\n    sqlite3OomFault(db);\n  }\n  return z;\n}\n\n/*\n** Print into memory obtained from sqliteMalloc().  Use the internal\n** %-conversion extensions.\n*/\nSQLITE_PRIVATE char *sqlite3MPrintf(sqlite3 *db, const char *zFormat, ...){\n  va_list ap;\n  char *z;\n  va_start(ap, zFormat);\n  z = sqlite3VMPrintf(db, zFormat, ap);\n  va_end(ap);\n  return z;\n}\n\n/*\n** Print into memory obtained from sqlite3_malloc().  Omit the internal\n** %-conversion extensions.\n*/\nSQLITE_API char *sqlite3_vmprintf(const char *zFormat, va_list ap){\n  char *z;\n  char zBase[SQLITE_PRINT_BUF_SIZE];\n  StrAccum acc;\n\n#ifdef SQLITE_ENABLE_API_ARMOR  \n  if( zFormat==0 ){\n    (void)SQLITE_MISUSE_BKPT;\n    return 0;\n  }\n#endif\n#ifndef SQLITE_OMIT_AUTOINIT\n  if( sqlite3_initialize() ) return 0;\n#endif\n  sqlite3StrAccumInit(&acc, 0, zBase, sizeof(zBase), SQLITE_MAX_LENGTH);\n  sqlite3_str_vappendf(&acc, zFormat, ap);\n  z = sqlite3StrAccumFinish(&acc);\n  return z;\n}\n\n/*\n** Print into memory obtained from sqlite3_malloc()().  Omit the internal\n** %-conversion extensions.\n*/\nSQLITE_API char *sqlite3_mprintf(const char *zFormat, ...){\n  va_list ap;\n  char *z;\n#ifndef SQLITE_OMIT_AUTOINIT\n  if( sqlite3_initialize() ) return 0;\n#endif\n  va_start(ap, zFormat);\n  z = sqlite3_vmprintf(zFormat, ap);\n  va_end(ap);\n  return z;\n}\n\n/*\n** sqlite3_snprintf() works like snprintf() except that it ignores the\n** current locale settings.  This is important for SQLite because we\n** are not able to use a \",\" as the decimal point in place of \".\" as\n** specified by some locales.\n**\n** Oops:  The first two arguments of sqlite3_snprintf() are backwards\n** from the snprintf() standard.  Unfortunately, it is too late to change\n** this without breaking compatibility, so we just have to live with the\n** mistake.\n**\n** sqlite3_vsnprintf() is the varargs version.\n*/\nSQLITE_API char *sqlite3_vsnprintf(int n, char *zBuf, const char *zFormat, va_list ap){\n  StrAccum acc;\n  if( n<=0 ) return zBuf;\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( zBuf==0 || zFormat==0 ) {\n    (void)SQLITE_MISUSE_BKPT;\n    if( zBuf ) zBuf[0] = 0;\n    return zBuf;\n  }\n#endif\n  sqlite3StrAccumInit(&acc, 0, zBuf, n, 0);\n  sqlite3_str_vappendf(&acc, zFormat, ap);\n  zBuf[acc.nChar] = 0;\n  return zBuf;\n}\nSQLITE_API char *sqlite3_snprintf(int n, char *zBuf, const char *zFormat, ...){\n  char *z;\n  va_list ap;\n  va_start(ap,zFormat);\n  z = sqlite3_vsnprintf(n, zBuf, zFormat, ap);\n  va_end(ap);\n  return z;\n}\n\n/*\n** This is the routine that actually formats the sqlite3_log() message.\n** We house it in a separate routine from sqlite3_log() to avoid using\n** stack space on small-stack systems when logging is disabled.\n**\n** sqlite3_log() must render into a static buffer.  It cannot dynamically\n** allocate memory because it might be called while the memory allocator\n** mutex is held.\n**\n** sqlite3_str_vappendf() might ask for *temporary* memory allocations for\n** certain format characters (%q) or for very large precisions or widths.\n** Care must be taken that any sqlite3_log() calls that occur while the\n** memory mutex is held do not use these mechanisms.\n*/\nstatic void renderLogMsg(int iErrCode, const char *zFormat, va_list ap){\n  StrAccum acc;                          /* String accumulator */\n  char zMsg[SQLITE_PRINT_BUF_SIZE*3];    /* Complete log message */\n\n  sqlite3StrAccumInit(&acc, 0, zMsg, sizeof(zMsg), 0);\n  sqlite3_str_vappendf(&acc, zFormat, ap);\n  sqlite3GlobalConfig.xLog(sqlite3GlobalConfig.pLogArg, iErrCode,\n                           sqlite3StrAccumFinish(&acc));\n}\n\n/*\n** Format and write a message to the log if logging is enabled.\n*/\nSQLITE_API void sqlite3_log(int iErrCode, const char *zFormat, ...){\n  va_list ap;                             /* Vararg list */\n  if( sqlite3GlobalConfig.xLog ){\n    va_start(ap, zFormat);\n    renderLogMsg(iErrCode, zFormat, ap);\n    va_end(ap);\n  }\n}\n\n#if defined(SQLITE_DEBUG) || defined(SQLITE_HAVE_OS_TRACE)\n/*\n** A version of printf() that understands %lld.  Used for debugging.\n** The printf() built into some versions of windows does not understand %lld\n** and segfaults if you give it a long long int.\n*/\nSQLITE_PRIVATE void sqlite3DebugPrintf(const char *zFormat, ...){\n  va_list ap;\n  StrAccum acc;\n  char zBuf[500];\n  sqlite3StrAccumInit(&acc, 0, zBuf, sizeof(zBuf), 0);\n  va_start(ap,zFormat);\n  sqlite3_str_vappendf(&acc, zFormat, ap);\n  va_end(ap);\n  sqlite3StrAccumFinish(&acc);\n#ifdef SQLITE_OS_TRACE_PROC\n  {\n    extern void SQLITE_OS_TRACE_PROC(const char *zBuf, int nBuf);\n    SQLITE_OS_TRACE_PROC(zBuf, sizeof(zBuf));\n  }\n#else\n  fprintf(stdout,\"%s\", zBuf);\n  fflush(stdout);\n#endif\n}\n#endif\n\n\n/*\n** variable-argument wrapper around sqlite3_str_vappendf(). The bFlags argument\n** can contain the bit SQLITE_PRINTF_INTERNAL enable internal formats.\n*/\nSQLITE_API void sqlite3_str_appendf(StrAccum *p, const char *zFormat, ...){\n  va_list ap;\n  va_start(ap,zFormat);\n  sqlite3_str_vappendf(p, zFormat, ap);\n  va_end(ap);\n}\n\n/************** End of printf.c **********************************************/\n/************** Begin file treeview.c ****************************************/\n/*\n** 2015-06-08\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n**\n** This file contains C code to implement the TreeView debugging routines.\n** These routines print a parse tree to standard output for debugging and\n** analysis. \n**\n** The interfaces in this file is only available when compiling\n** with SQLITE_DEBUG.\n*/\n/* #include \"sqliteInt.h\" */\n#ifdef SQLITE_DEBUG\n\n/*\n** Add a new subitem to the tree.  The moreToFollow flag indicates that this\n** is not the last item in the tree.\n*/\nstatic TreeView *sqlite3TreeViewPush(TreeView *p, u8 moreToFollow){\n  if( p==0 ){\n    p = sqlite3_malloc64( sizeof(*p) );\n    if( p==0 ) return 0;\n    memset(p, 0, sizeof(*p));\n  }else{\n    p->iLevel++;\n  }\n  assert( moreToFollow==0 || moreToFollow==1 );\n  if( p->iLevel<sizeof(p->bLine) ) p->bLine[p->iLevel] = moreToFollow;\n  return p;\n}\n\n/*\n** Finished with one layer of the tree\n*/\nstatic void sqlite3TreeViewPop(TreeView *p){\n  if( p==0 ) return;\n  p->iLevel--;\n  if( p->iLevel<0 ) sqlite3_free(p);\n}\n\n/*\n** Generate a single line of output for the tree, with a prefix that contains\n** all the appropriate tree lines\n*/\nstatic void sqlite3TreeViewLine(TreeView *p, const char *zFormat, ...){\n  va_list ap;\n  int i;\n  StrAccum acc;\n  char zBuf[500];\n  sqlite3StrAccumInit(&acc, 0, zBuf, sizeof(zBuf), 0);\n  if( p ){\n    for(i=0; i<p->iLevel && i<sizeof(p->bLine)-1; i++){\n      sqlite3_str_append(&acc, p->bLine[i] ? \"|   \" : \"    \", 4);\n    }\n    sqlite3_str_append(&acc, p->bLine[i] ? \"|-- \" : \"'-- \", 4);\n  }\n  if( zFormat!=0 ){\n    va_start(ap, zFormat);\n    sqlite3_str_vappendf(&acc, zFormat, ap);\n    va_end(ap);\n    assert( acc.nChar>0 );\n    sqlite3_str_append(&acc, \"\\n\", 1);\n  }\n  sqlite3StrAccumFinish(&acc);\n  fprintf(stdout,\"%s\", zBuf);\n  fflush(stdout);\n}\n\n/*\n** Shorthand for starting a new tree item that consists of a single label\n*/\nstatic void sqlite3TreeViewItem(TreeView *p, const char *zLabel,u8 moreFollows){\n  p = sqlite3TreeViewPush(p, moreFollows);\n  sqlite3TreeViewLine(p, \"%s\", zLabel);\n}\n\n/*\n** Generate a human-readable description of a WITH clause.\n*/\nSQLITE_PRIVATE void sqlite3TreeViewWith(TreeView *pView, const With *pWith, u8 moreToFollow){\n  int i;\n  if( pWith==0 ) return;\n  if( pWith->nCte==0 ) return;\n  if( pWith->pOuter ){\n    sqlite3TreeViewLine(pView, \"WITH (0x%p, pOuter=0x%p)\",pWith,pWith->pOuter);\n  }else{\n    sqlite3TreeViewLine(pView, \"WITH (0x%p)\", pWith);\n  }\n  if( pWith->nCte>0 ){\n    pView = sqlite3TreeViewPush(pView, 1);\n    for(i=0; i<pWith->nCte; i++){\n      StrAccum x;\n      char zLine[1000];\n      const struct Cte *pCte = &pWith->a[i];\n      sqlite3StrAccumInit(&x, 0, zLine, sizeof(zLine), 0);\n      sqlite3_str_appendf(&x, \"%s\", pCte->zName);\n      if( pCte->pCols && pCte->pCols->nExpr>0 ){\n        char cSep = '(';\n        int j;\n        for(j=0; j<pCte->pCols->nExpr; j++){\n          sqlite3_str_appendf(&x, \"%c%s\", cSep, pCte->pCols->a[j].zName);\n          cSep = ',';\n        }\n        sqlite3_str_appendf(&x, \")\");\n      }\n      sqlite3_str_appendf(&x, \" AS\");\n      sqlite3StrAccumFinish(&x);\n      sqlite3TreeViewItem(pView, zLine, i<pWith->nCte-1);\n      sqlite3TreeViewSelect(pView, pCte->pSelect, 0);\n      sqlite3TreeViewPop(pView);\n    }\n    sqlite3TreeViewPop(pView);\n  }\n}\n\n/*\n** Generate a human-readable description of a SrcList object.\n*/\nSQLITE_PRIVATE void sqlite3TreeViewSrcList(TreeView *pView, const SrcList *pSrc){\n  int i;\n  for(i=0; i<pSrc->nSrc; i++){\n    const struct SrcList_item *pItem = &pSrc->a[i];\n    StrAccum x;\n    char zLine[100];\n    sqlite3StrAccumInit(&x, 0, zLine, sizeof(zLine), 0);\n    sqlite3_str_appendf(&x, \"{%d,*}\", pItem->iCursor);\n    if( pItem->zDatabase ){\n      sqlite3_str_appendf(&x, \" %s.%s\", pItem->zDatabase, pItem->zName);\n    }else if( pItem->zName ){\n      sqlite3_str_appendf(&x, \" %s\", pItem->zName);\n    }\n    if( pItem->pTab ){\n      sqlite3_str_appendf(&x, \" tab=%Q nCol=%d ptr=%p\",\n           pItem->pTab->zName, pItem->pTab->nCol, pItem->pTab);\n    }\n    if( pItem->zAlias ){\n      sqlite3_str_appendf(&x, \" (AS %s)\", pItem->zAlias);\n    }\n    if( pItem->fg.jointype & JT_LEFT ){\n      sqlite3_str_appendf(&x, \" LEFT-JOIN\");\n    }\n    sqlite3StrAccumFinish(&x);\n    sqlite3TreeViewItem(pView, zLine, i<pSrc->nSrc-1); \n    if( pItem->pSelect ){\n      sqlite3TreeViewSelect(pView, pItem->pSelect, 0);\n    }\n    if( pItem->fg.isTabFunc ){\n      sqlite3TreeViewExprList(pView, pItem->u1.pFuncArg, 0, \"func-args:\");\n    }\n    sqlite3TreeViewPop(pView);\n  }\n}\n\n/*\n** Generate a human-readable description of a Select object.\n*/\nSQLITE_PRIVATE void sqlite3TreeViewSelect(TreeView *pView, const Select *p, u8 moreToFollow){\n  int n = 0;\n  int cnt = 0;\n  if( p==0 ){\n    sqlite3TreeViewLine(pView, \"nil-SELECT\");\n    return;\n  } \n  pView = sqlite3TreeViewPush(pView, moreToFollow);\n  if( p->pWith ){\n    sqlite3TreeViewWith(pView, p->pWith, 1);\n    cnt = 1;\n    sqlite3TreeViewPush(pView, 1);\n  }\n  do{\n    sqlite3TreeViewLine(pView,\n      \"SELECT%s%s (%u/%p) selFlags=0x%x nSelectRow=%d\",\n      ((p->selFlags & SF_Distinct) ? \" DISTINCT\" : \"\"),\n      ((p->selFlags & SF_Aggregate) ? \" agg_flag\" : \"\"),\n      p->selId, p, p->selFlags,\n      (int)p->nSelectRow\n    );\n    if( cnt++ ) sqlite3TreeViewPop(pView);\n    if( p->pPrior ){\n      n = 1000;\n    }else{\n      n = 0;\n      if( p->pSrc && p->pSrc->nSrc ) n++;\n      if( p->pWhere ) n++;\n      if( p->pGroupBy ) n++;\n      if( p->pHaving ) n++;\n      if( p->pOrderBy ) n++;\n      if( p->pLimit ) n++;\n#ifndef SQLITE_OMIT_WINDOWFUNC\n      if( p->pWin ) n++;\n      if( p->pWinDefn ) n++;\n#endif\n    }\n    sqlite3TreeViewExprList(pView, p->pEList, (n--)>0, \"result-set\");\n#ifndef SQLITE_OMIT_WINDOWFUNC\n    if( p->pWin ){\n      Window *pX;\n      pView = sqlite3TreeViewPush(pView, (n--)>0);\n      sqlite3TreeViewLine(pView, \"window-functions\");\n      for(pX=p->pWin; pX; pX=pX->pNextWin){\n        sqlite3TreeViewWinFunc(pView, pX, pX->pNextWin!=0);\n      }\n      sqlite3TreeViewPop(pView);\n    }\n#endif\n    if( p->pSrc && p->pSrc->nSrc ){\n      pView = sqlite3TreeViewPush(pView, (n--)>0);\n      sqlite3TreeViewLine(pView, \"FROM\");\n      sqlite3TreeViewSrcList(pView, p->pSrc);\n      sqlite3TreeViewPop(pView);\n    }\n    if( p->pWhere ){\n      sqlite3TreeViewItem(pView, \"WHERE\", (n--)>0);\n      sqlite3TreeViewExpr(pView, p->pWhere, 0);\n      sqlite3TreeViewPop(pView);\n    }\n    if( p->pGroupBy ){\n      sqlite3TreeViewExprList(pView, p->pGroupBy, (n--)>0, \"GROUPBY\");\n    }\n    if( p->pHaving ){\n      sqlite3TreeViewItem(pView, \"HAVING\", (n--)>0);\n      sqlite3TreeViewExpr(pView, p->pHaving, 0);\n      sqlite3TreeViewPop(pView);\n    }\n#ifndef SQLITE_OMIT_WINDOWFUNC\n    if( p->pWinDefn ){\n      Window *pX;\n      sqlite3TreeViewItem(pView, \"WINDOW\", (n--)>0);\n      for(pX=p->pWinDefn; pX; pX=pX->pNextWin){\n        sqlite3TreeViewWindow(pView, pX, pX->pNextWin!=0);\n      }\n      sqlite3TreeViewPop(pView);\n    }\n#endif\n    if( p->pOrderBy ){\n      sqlite3TreeViewExprList(pView, p->pOrderBy, (n--)>0, \"ORDERBY\");\n    }\n    if( p->pLimit ){\n      sqlite3TreeViewItem(pView, \"LIMIT\", (n--)>0);\n      sqlite3TreeViewExpr(pView, p->pLimit->pLeft, p->pLimit->pRight!=0);\n      if( p->pLimit->pRight ){\n        sqlite3TreeViewItem(pView, \"OFFSET\", (n--)>0);\n        sqlite3TreeViewExpr(pView, p->pLimit->pRight, 0);\n        sqlite3TreeViewPop(pView);\n      }\n      sqlite3TreeViewPop(pView);\n    }\n    if( p->pPrior ){\n      const char *zOp = \"UNION\";\n      switch( p->op ){\n        case TK_ALL:         zOp = \"UNION ALL\";  break;\n        case TK_INTERSECT:   zOp = \"INTERSECT\";  break;\n        case TK_EXCEPT:      zOp = \"EXCEPT\";     break;\n      }\n      sqlite3TreeViewItem(pView, zOp, 1);\n    }\n    p = p->pPrior;\n  }while( p!=0 );\n  sqlite3TreeViewPop(pView);\n}\n\n#ifndef SQLITE_OMIT_WINDOWFUNC\n/*\n** Generate a description of starting or stopping bounds\n*/\nSQLITE_PRIVATE void sqlite3TreeViewBound(\n  TreeView *pView,        /* View context */\n  u8 eBound,              /* UNBOUNDED, CURRENT, PRECEDING, FOLLOWING */\n  Expr *pExpr,            /* Value for PRECEDING or FOLLOWING */\n  u8 moreToFollow         /* True if more to follow */\n){\n  switch( eBound ){\n    case TK_UNBOUNDED: {\n      sqlite3TreeViewItem(pView, \"UNBOUNDED\", moreToFollow);\n      sqlite3TreeViewPop(pView);\n      break;\n    }\n    case TK_CURRENT: {\n      sqlite3TreeViewItem(pView, \"CURRENT\", moreToFollow);\n      sqlite3TreeViewPop(pView);\n      break;\n    }\n    case TK_PRECEDING: {\n      sqlite3TreeViewItem(pView, \"PRECEDING\", moreToFollow);\n      sqlite3TreeViewExpr(pView, pExpr, 0);\n      sqlite3TreeViewPop(pView);\n      break;\n    }\n    case TK_FOLLOWING: {\n      sqlite3TreeViewItem(pView, \"FOLLOWING\", moreToFollow);\n      sqlite3TreeViewExpr(pView, pExpr, 0);\n      sqlite3TreeViewPop(pView);\n      break;\n    }\n  }\n}\n#endif /* SQLITE_OMIT_WINDOWFUNC */\n\n#ifndef SQLITE_OMIT_WINDOWFUNC\n/*\n** Generate a human-readable explanation for a Window object\n*/\nSQLITE_PRIVATE void sqlite3TreeViewWindow(TreeView *pView, const Window *pWin, u8 more){\n  pView = sqlite3TreeViewPush(pView, more);\n  if( pWin->zName ){\n    sqlite3TreeViewLine(pView, \"OVER %s\", pWin->zName);\n  }else{\n    sqlite3TreeViewLine(pView, \"OVER\");\n  }\n  if( pWin->pPartition ){\n    sqlite3TreeViewExprList(pView, pWin->pPartition, 1, \"PARTITION-BY\");\n  }\n  if( pWin->pOrderBy ){\n    sqlite3TreeViewExprList(pView, pWin->pOrderBy, 1, \"ORDER-BY\");\n  }\n  if( pWin->eType ){\n    sqlite3TreeViewItem(pView, pWin->eType==TK_RANGE ? \"RANGE\" : \"ROWS\", 0);\n    sqlite3TreeViewBound(pView, pWin->eStart, pWin->pStart, 1);\n    sqlite3TreeViewBound(pView, pWin->eEnd, pWin->pEnd, 0);\n    sqlite3TreeViewPop(pView);\n  }\n  sqlite3TreeViewPop(pView);\n}\n#endif /* SQLITE_OMIT_WINDOWFUNC */\n\n#ifndef SQLITE_OMIT_WINDOWFUNC\n/*\n** Generate a human-readable explanation for a Window Function object\n*/\nSQLITE_PRIVATE void sqlite3TreeViewWinFunc(TreeView *pView, const Window *pWin, u8 more){\n  pView = sqlite3TreeViewPush(pView, more);\n  sqlite3TreeViewLine(pView, \"WINFUNC %s(%d)\",\n                       pWin->pFunc->zName, pWin->pFunc->nArg);\n  sqlite3TreeViewWindow(pView, pWin, 0);\n  sqlite3TreeViewPop(pView);\n}\n#endif /* SQLITE_OMIT_WINDOWFUNC */\n\n/*\n** Generate a human-readable explanation of an expression tree.\n*/\nSQLITE_PRIVATE void sqlite3TreeViewExpr(TreeView *pView, const Expr *pExpr, u8 moreToFollow){\n  const char *zBinOp = 0;   /* Binary operator */\n  const char *zUniOp = 0;   /* Unary operator */\n  char zFlgs[60];\n  pView = sqlite3TreeViewPush(pView, moreToFollow);\n  if( pExpr==0 ){\n    sqlite3TreeViewLine(pView, \"nil\");\n    sqlite3TreeViewPop(pView);\n    return;\n  }\n  if( pExpr->flags ){\n    if( ExprHasProperty(pExpr, EP_FromJoin) ){\n      sqlite3_snprintf(sizeof(zFlgs),zFlgs,\"  flags=0x%x iRJT=%d\",\n                       pExpr->flags, pExpr->iRightJoinTable);\n    }else{\n      sqlite3_snprintf(sizeof(zFlgs),zFlgs,\"  flags=0x%x\",pExpr->flags);\n    }\n  }else{\n    zFlgs[0] = 0;\n  }\n  switch( pExpr->op ){\n    case TK_AGG_COLUMN: {\n      sqlite3TreeViewLine(pView, \"AGG{%d:%d}%s\",\n            pExpr->iTable, pExpr->iColumn, zFlgs);\n      break;\n    }\n    case TK_COLUMN: {\n      if( pExpr->iTable<0 ){\n        /* This only happens when coding check constraints */\n        sqlite3TreeViewLine(pView, \"COLUMN(%d)%s\", pExpr->iColumn, zFlgs);\n      }else{\n        sqlite3TreeViewLine(pView, \"{%d:%d}%s\",\n                             pExpr->iTable, pExpr->iColumn, zFlgs);\n      }\n      if( ExprHasProperty(pExpr, EP_FixedCol) ){\n        sqlite3TreeViewExpr(pView, pExpr->pLeft, 0);\n      }\n      break;\n    }\n    case TK_INTEGER: {\n      if( pExpr->flags & EP_IntValue ){\n        sqlite3TreeViewLine(pView, \"%d\", pExpr->u.iValue);\n      }else{\n        sqlite3TreeViewLine(pView, \"%s\", pExpr->u.zToken);\n      }\n      break;\n    }\n#ifndef SQLITE_OMIT_FLOATING_POINT\n    case TK_FLOAT: {\n      sqlite3TreeViewLine(pView,\"%s\", pExpr->u.zToken);\n      break;\n    }\n#endif\n    case TK_STRING: {\n      sqlite3TreeViewLine(pView,\"%Q\", pExpr->u.zToken);\n      break;\n    }\n    case TK_NULL: {\n      sqlite3TreeViewLine(pView,\"NULL\");\n      break;\n    }\n    case TK_TRUEFALSE: {\n      sqlite3TreeViewLine(pView,\n         sqlite3ExprTruthValue(pExpr) ? \"TRUE\" : \"FALSE\");\n      break;\n    }\n#ifndef SQLITE_OMIT_BLOB_LITERAL\n    case TK_BLOB: {\n      sqlite3TreeViewLine(pView,\"%s\", pExpr->u.zToken);\n      break;\n    }\n#endif\n    case TK_VARIABLE: {\n      sqlite3TreeViewLine(pView,\"VARIABLE(%s,%d)\",\n                          pExpr->u.zToken, pExpr->iColumn);\n      break;\n    }\n    case TK_REGISTER: {\n      sqlite3TreeViewLine(pView,\"REGISTER(%d)\", pExpr->iTable);\n      break;\n    }\n    case TK_ID: {\n      sqlite3TreeViewLine(pView,\"ID \\\"%w\\\"\", pExpr->u.zToken);\n      break;\n    }\n#ifndef SQLITE_OMIT_CAST\n    case TK_CAST: {\n      /* Expressions of the form:   CAST(pLeft AS token) */\n      sqlite3TreeViewLine(pView,\"CAST %Q\", pExpr->u.zToken);\n      sqlite3TreeViewExpr(pView, pExpr->pLeft, 0);\n      break;\n    }\n#endif /* SQLITE_OMIT_CAST */\n    case TK_LT:      zBinOp = \"LT\";     break;\n    case TK_LE:      zBinOp = \"LE\";     break;\n    case TK_GT:      zBinOp = \"GT\";     break;\n    case TK_GE:      zBinOp = \"GE\";     break;\n    case TK_NE:      zBinOp = \"NE\";     break;\n    case TK_EQ:      zBinOp = \"EQ\";     break;\n    case TK_IS:      zBinOp = \"IS\";     break;\n    case TK_ISNOT:   zBinOp = \"ISNOT\";  break;\n    case TK_AND:     zBinOp = \"AND\";    break;\n    case TK_OR:      zBinOp = \"OR\";     break;\n    case TK_PLUS:    zBinOp = \"ADD\";    break;\n    case TK_STAR:    zBinOp = \"MUL\";    break;\n    case TK_MINUS:   zBinOp = \"SUB\";    break;\n    case TK_REM:     zBinOp = \"REM\";    break;\n    case TK_BITAND:  zBinOp = \"BITAND\"; break;\n    case TK_BITOR:   zBinOp = \"BITOR\";  break;\n    case TK_SLASH:   zBinOp = \"DIV\";    break;\n    case TK_LSHIFT:  zBinOp = \"LSHIFT\"; break;\n    case TK_RSHIFT:  zBinOp = \"RSHIFT\"; break;\n    case TK_CONCAT:  zBinOp = \"CONCAT\"; break;\n    case TK_DOT:     zBinOp = \"DOT\";    break;\n\n    case TK_UMINUS:  zUniOp = \"UMINUS\"; break;\n    case TK_UPLUS:   zUniOp = \"UPLUS\";  break;\n    case TK_BITNOT:  zUniOp = \"BITNOT\"; break;\n    case TK_NOT:     zUniOp = \"NOT\";    break;\n    case TK_ISNULL:  zUniOp = \"ISNULL\"; break;\n    case TK_NOTNULL: zUniOp = \"NOTNULL\"; break;\n\n    case TK_TRUTH: {\n      int x;\n      const char *azOp[] = {\n         \"IS-FALSE\", \"IS-TRUE\", \"IS-NOT-FALSE\", \"IS-NOT-TRUE\"\n      };\n      assert( pExpr->op2==TK_IS || pExpr->op2==TK_ISNOT );\n      assert( pExpr->pRight );\n      assert( pExpr->pRight->op==TK_TRUEFALSE );\n      x = (pExpr->op2==TK_ISNOT)*2 + sqlite3ExprTruthValue(pExpr->pRight);\n      zUniOp = azOp[x];\n      break;\n    }\n\n    case TK_SPAN: {\n      sqlite3TreeViewLine(pView, \"SPAN %Q\", pExpr->u.zToken);\n      sqlite3TreeViewExpr(pView, pExpr->pLeft, 0);\n      break;\n    }\n\n    case TK_COLLATE: {\n      sqlite3TreeViewLine(pView, \"COLLATE %Q\", pExpr->u.zToken);\n      sqlite3TreeViewExpr(pView, pExpr->pLeft, 0);\n      break;\n    }\n\n    case TK_AGG_FUNCTION:\n    case TK_FUNCTION: {\n      ExprList *pFarg;       /* List of function arguments */\n      Window *pWin;\n      if( ExprHasProperty(pExpr, EP_TokenOnly) ){\n        pFarg = 0;\n        pWin = 0;\n      }else{\n        pFarg = pExpr->x.pList;\n#ifndef SQLITE_OMIT_WINDOWFUNC\n        pWin = pExpr->y.pWin;\n#else\n        pWin = 0;\n#endif \n      }\n      if( pExpr->op==TK_AGG_FUNCTION ){\n        sqlite3TreeViewLine(pView, \"AGG_FUNCTION%d %Q\",\n                             pExpr->op2, pExpr->u.zToken);\n      }else{\n        sqlite3TreeViewLine(pView, \"FUNCTION %Q\", pExpr->u.zToken);\n      }\n      if( pFarg ){\n        sqlite3TreeViewExprList(pView, pFarg, pWin!=0, 0);\n      }\n#ifndef SQLITE_OMIT_WINDOWFUNC\n      if( pWin ){\n        sqlite3TreeViewWindow(pView, pWin, 0);\n      }\n#endif\n      break;\n    }\n#ifndef SQLITE_OMIT_SUBQUERY\n    case TK_EXISTS: {\n      sqlite3TreeViewLine(pView, \"EXISTS-expr flags=0x%x\", pExpr->flags);\n      sqlite3TreeViewSelect(pView, pExpr->x.pSelect, 0);\n      break;\n    }\n    case TK_SELECT: {\n      sqlite3TreeViewLine(pView, \"SELECT-expr flags=0x%x\", pExpr->flags);\n      sqlite3TreeViewSelect(pView, pExpr->x.pSelect, 0);\n      break;\n    }\n    case TK_IN: {\n      sqlite3TreeViewLine(pView, \"IN flags=0x%x\", pExpr->flags);\n      sqlite3TreeViewExpr(pView, pExpr->pLeft, 1);\n      if( ExprHasProperty(pExpr, EP_xIsSelect) ){\n        sqlite3TreeViewSelect(pView, pExpr->x.pSelect, 0);\n      }else{\n        sqlite3TreeViewExprList(pView, pExpr->x.pList, 0, 0);\n      }\n      break;\n    }\n#endif /* SQLITE_OMIT_SUBQUERY */\n\n    /*\n    **    x BETWEEN y AND z\n    **\n    ** This is equivalent to\n    **\n    **    x>=y AND x<=z\n    **\n    ** X is stored in pExpr->pLeft.\n    ** Y is stored in pExpr->pList->a[0].pExpr.\n    ** Z is stored in pExpr->pList->a[1].pExpr.\n    */\n    case TK_BETWEEN: {\n      Expr *pX = pExpr->pLeft;\n      Expr *pY = pExpr->x.pList->a[0].pExpr;\n      Expr *pZ = pExpr->x.pList->a[1].pExpr;\n      sqlite3TreeViewLine(pView, \"BETWEEN\");\n      sqlite3TreeViewExpr(pView, pX, 1);\n      sqlite3TreeViewExpr(pView, pY, 1);\n      sqlite3TreeViewExpr(pView, pZ, 0);\n      break;\n    }\n    case TK_TRIGGER: {\n      /* If the opcode is TK_TRIGGER, then the expression is a reference\n      ** to a column in the new.* or old.* pseudo-tables available to\n      ** trigger programs. In this case Expr.iTable is set to 1 for the\n      ** new.* pseudo-table, or 0 for the old.* pseudo-table. Expr.iColumn\n      ** is set to the column of the pseudo-table to read, or to -1 to\n      ** read the rowid field.\n      */\n      sqlite3TreeViewLine(pView, \"%s(%d)\", \n          pExpr->iTable ? \"NEW\" : \"OLD\", pExpr->iColumn);\n      break;\n    }\n    case TK_CASE: {\n      sqlite3TreeViewLine(pView, \"CASE\");\n      sqlite3TreeViewExpr(pView, pExpr->pLeft, 1);\n      sqlite3TreeViewExprList(pView, pExpr->x.pList, 0, 0);\n      break;\n    }\n#ifndef SQLITE_OMIT_TRIGGER\n    case TK_RAISE: {\n      const char *zType = \"unk\";\n      switch( pExpr->affinity ){\n        case OE_Rollback:   zType = \"rollback\";  break;\n        case OE_Abort:      zType = \"abort\";     break;\n        case OE_Fail:       zType = \"fail\";      break;\n        case OE_Ignore:     zType = \"ignore\";    break;\n      }\n      sqlite3TreeViewLine(pView, \"RAISE %s(%Q)\", zType, pExpr->u.zToken);\n      break;\n    }\n#endif\n    case TK_MATCH: {\n      sqlite3TreeViewLine(pView, \"MATCH {%d:%d}%s\",\n                          pExpr->iTable, pExpr->iColumn, zFlgs);\n      sqlite3TreeViewExpr(pView, pExpr->pRight, 0);\n      break;\n    }\n    case TK_VECTOR: {\n      sqlite3TreeViewBareExprList(pView, pExpr->x.pList, \"VECTOR\");\n      break;\n    }\n    case TK_SELECT_COLUMN: {\n      sqlite3TreeViewLine(pView, \"SELECT-COLUMN %d\", pExpr->iColumn);\n      sqlite3TreeViewSelect(pView, pExpr->pLeft->x.pSelect, 0);\n      break;\n    }\n    case TK_IF_NULL_ROW: {\n      sqlite3TreeViewLine(pView, \"IF-NULL-ROW %d\", pExpr->iTable);\n      sqlite3TreeViewExpr(pView, pExpr->pLeft, 0);\n      break;\n    }\n    default: {\n      sqlite3TreeViewLine(pView, \"op=%d\", pExpr->op);\n      break;\n    }\n  }\n  if( zBinOp ){\n    sqlite3TreeViewLine(pView, \"%s%s\", zBinOp, zFlgs);\n    sqlite3TreeViewExpr(pView, pExpr->pLeft, 1);\n    sqlite3TreeViewExpr(pView, pExpr->pRight, 0);\n  }else if( zUniOp ){\n    sqlite3TreeViewLine(pView, \"%s%s\", zUniOp, zFlgs);\n    sqlite3TreeViewExpr(pView, pExpr->pLeft, 0);\n  }\n  sqlite3TreeViewPop(pView);\n}\n\n\n/*\n** Generate a human-readable explanation of an expression list.\n*/\nSQLITE_PRIVATE void sqlite3TreeViewBareExprList(\n  TreeView *pView,\n  const ExprList *pList,\n  const char *zLabel\n){\n  if( zLabel==0 || zLabel[0]==0 ) zLabel = \"LIST\";\n  if( pList==0 ){\n    sqlite3TreeViewLine(pView, \"%s (empty)\", zLabel);\n  }else{\n    int i;\n    sqlite3TreeViewLine(pView, \"%s\", zLabel);\n    for(i=0; i<pList->nExpr; i++){\n      int j = pList->a[i].u.x.iOrderByCol;\n      char *zName = pList->a[i].zName;\n      int moreToFollow = i<pList->nExpr - 1;\n      if( j || zName ){\n        sqlite3TreeViewPush(pView, moreToFollow);\n        moreToFollow = 0;\n        sqlite3TreeViewLine(pView, 0);\n        if( zName ){\n          fprintf(stdout, \"AS %s \", zName);\n        }\n        if( j ){\n          fprintf(stdout, \"iOrderByCol=%d\", j);\n        }\n        fprintf(stdout, \"\\n\");\n        fflush(stdout);\n      }\n      sqlite3TreeViewExpr(pView, pList->a[i].pExpr, moreToFollow);\n      if( j || zName ){\n        sqlite3TreeViewPop(pView);\n      }\n    }\n  }\n}\nSQLITE_PRIVATE void sqlite3TreeViewExprList(\n  TreeView *pView,\n  const ExprList *pList,\n  u8 moreToFollow,\n  const char *zLabel\n){\n  pView = sqlite3TreeViewPush(pView, moreToFollow);\n  sqlite3TreeViewBareExprList(pView, pList, zLabel);\n  sqlite3TreeViewPop(pView);\n}\n\n#endif /* SQLITE_DEBUG */\n\n/************** End of treeview.c ********************************************/\n/************** Begin file random.c ******************************************/\n/*\n** 2001 September 15\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This file contains code to implement a pseudo-random number\n** generator (PRNG) for SQLite.\n**\n** Random numbers are used by some of the database backends in order\n** to generate random integer keys for tables or random filenames.\n*/\n/* #include \"sqliteInt.h\" */\n\n\n/* All threads share a single random number generator.\n** This structure is the current state of the generator.\n*/\nstatic SQLITE_WSD struct sqlite3PrngType {\n  unsigned char isInit;          /* True if initialized */\n  unsigned char i, j;            /* State variables */\n  unsigned char s[256];          /* State variables */\n} sqlite3Prng;\n\n/*\n** Return N random bytes.\n*/\nSQLITE_API void sqlite3_randomness(int N, void *pBuf){\n  unsigned char t;\n  unsigned char *zBuf = pBuf;\n\n  /* The \"wsdPrng\" macro will resolve to the pseudo-random number generator\n  ** state vector.  If writable static data is unsupported on the target,\n  ** we have to locate the state vector at run-time.  In the more common\n  ** case where writable static data is supported, wsdPrng can refer directly\n  ** to the \"sqlite3Prng\" state vector declared above.\n  */\n#ifdef SQLITE_OMIT_WSD\n  struct sqlite3PrngType *p = &GLOBAL(struct sqlite3PrngType, sqlite3Prng);\n# define wsdPrng p[0]\n#else\n# define wsdPrng sqlite3Prng\n#endif\n\n#if SQLITE_THREADSAFE\n  sqlite3_mutex *mutex;\n#endif\n\n#ifndef SQLITE_OMIT_AUTOINIT\n  if( sqlite3_initialize() ) return;\n#endif\n\n#if SQLITE_THREADSAFE\n  mutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_PRNG);\n#endif\n\n  sqlite3_mutex_enter(mutex);\n  if( N<=0 || pBuf==0 ){\n    wsdPrng.isInit = 0;\n    sqlite3_mutex_leave(mutex);\n    return;\n  }\n\n  /* Initialize the state of the random number generator once,\n  ** the first time this routine is called.  The seed value does\n  ** not need to contain a lot of randomness since we are not\n  ** trying to do secure encryption or anything like that...\n  **\n  ** Nothing in this file or anywhere else in SQLite does any kind of\n  ** encryption.  The RC4 algorithm is being used as a PRNG (pseudo-random\n  ** number generator) not as an encryption device.\n  */\n  if( !wsdPrng.isInit ){\n    int i;\n    char k[256];\n    wsdPrng.j = 0;\n    wsdPrng.i = 0;\n    sqlite3OsRandomness(sqlite3_vfs_find(0), 256, k);\n    for(i=0; i<256; i++){\n      wsdPrng.s[i] = (u8)i;\n    }\n    for(i=0; i<256; i++){\n      wsdPrng.j += wsdPrng.s[i] + k[i];\n      t = wsdPrng.s[wsdPrng.j];\n      wsdPrng.s[wsdPrng.j] = wsdPrng.s[i];\n      wsdPrng.s[i] = t;\n    }\n    wsdPrng.isInit = 1;\n  }\n\n  assert( N>0 );\n  do{\n    wsdPrng.i++;\n    t = wsdPrng.s[wsdPrng.i];\n    wsdPrng.j += t;\n    wsdPrng.s[wsdPrng.i] = wsdPrng.s[wsdPrng.j];\n    wsdPrng.s[wsdPrng.j] = t;\n    t += wsdPrng.s[wsdPrng.i];\n    *(zBuf++) = wsdPrng.s[t];\n  }while( --N );\n  sqlite3_mutex_leave(mutex);\n}\n\n#ifndef SQLITE_UNTESTABLE\n/*\n** For testing purposes, we sometimes want to preserve the state of\n** PRNG and restore the PRNG to its saved state at a later time, or\n** to reset the PRNG to its initial state.  These routines accomplish\n** those tasks.\n**\n** The sqlite3_test_control() interface calls these routines to\n** control the PRNG.\n*/\nstatic SQLITE_WSD struct sqlite3PrngType sqlite3SavedPrng;\nSQLITE_PRIVATE void sqlite3PrngSaveState(void){\n  memcpy(\n    &GLOBAL(struct sqlite3PrngType, sqlite3SavedPrng),\n    &GLOBAL(struct sqlite3PrngType, sqlite3Prng),\n    sizeof(sqlite3Prng)\n  );\n}\nSQLITE_PRIVATE void sqlite3PrngRestoreState(void){\n  memcpy(\n    &GLOBAL(struct sqlite3PrngType, sqlite3Prng),\n    &GLOBAL(struct sqlite3PrngType, sqlite3SavedPrng),\n    sizeof(sqlite3Prng)\n  );\n}\n#endif /* SQLITE_UNTESTABLE */\n\n/************** End of random.c **********************************************/\n/************** Begin file threads.c *****************************************/\n/*\n** 2012 July 21\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n******************************************************************************\n**\n** This file presents a simple cross-platform threading interface for\n** use internally by SQLite.\n**\n** A \"thread\" can be created using sqlite3ThreadCreate().  This thread\n** runs independently of its creator until it is joined using\n** sqlite3ThreadJoin(), at which point it terminates.\n**\n** Threads do not have to be real.  It could be that the work of the\n** \"thread\" is done by the main thread at either the sqlite3ThreadCreate()\n** or sqlite3ThreadJoin() call.  This is, in fact, what happens in\n** single threaded systems.  Nothing in SQLite requires multiple threads.\n** This interface exists so that applications that want to take advantage\n** of multiple cores can do so, while also allowing applications to stay\n** single-threaded if desired.\n*/\n/* #include \"sqliteInt.h\" */\n#if SQLITE_OS_WIN\n/* #  include \"os_win.h\" */\n#endif\n\n#if SQLITE_MAX_WORKER_THREADS>0\n\n/********************************* Unix Pthreads ****************************/\n#if SQLITE_OS_UNIX && defined(SQLITE_MUTEX_PTHREADS) && SQLITE_THREADSAFE>0\n\n#define SQLITE_THREADS_IMPLEMENTED 1  /* Prevent the single-thread code below */\n/* #include <pthread.h> */\n\n/* A running thread */\nstruct SQLiteThread {\n  pthread_t tid;                 /* Thread ID */\n  int done;                      /* Set to true when thread finishes */\n  void *pOut;                    /* Result returned by the thread */\n  void *(*xTask)(void*);         /* The thread routine */\n  void *pIn;                     /* Argument to the thread */\n};\n\n/* Create a new thread */\nSQLITE_PRIVATE int sqlite3ThreadCreate(\n  SQLiteThread **ppThread,  /* OUT: Write the thread object here */\n  void *(*xTask)(void*),    /* Routine to run in a separate thread */\n  void *pIn                 /* Argument passed into xTask() */\n){\n  SQLiteThread *p;\n  int rc;\n\n  assert( ppThread!=0 );\n  assert( xTask!=0 );\n  /* This routine is never used in single-threaded mode */\n  assert( sqlite3GlobalConfig.bCoreMutex!=0 );\n\n  *ppThread = 0;\n  p = sqlite3Malloc(sizeof(*p));\n  if( p==0 ) return SQLITE_NOMEM_BKPT;\n  memset(p, 0, sizeof(*p));\n  p->xTask = xTask;\n  p->pIn = pIn;\n  /* If the SQLITE_TESTCTRL_FAULT_INSTALL callback is registered to a \n  ** function that returns SQLITE_ERROR when passed the argument 200, that\n  ** forces worker threads to run sequentially and deterministically \n  ** for testing purposes. */\n  if( sqlite3FaultSim(200) ){\n    rc = 1;\n  }else{    \n    rc = pthread_create(&p->tid, 0, xTask, pIn);\n  }\n  if( rc ){\n    p->done = 1;\n    p->pOut = xTask(pIn);\n  }\n  *ppThread = p;\n  return SQLITE_OK;\n}\n\n/* Get the results of the thread */\nSQLITE_PRIVATE int sqlite3ThreadJoin(SQLiteThread *p, void **ppOut){\n  int rc;\n\n  assert( ppOut!=0 );\n  if( NEVER(p==0) ) return SQLITE_NOMEM_BKPT;\n  if( p->done ){\n    *ppOut = p->pOut;\n    rc = SQLITE_OK;\n  }else{\n    rc = pthread_join(p->tid, ppOut) ? SQLITE_ERROR : SQLITE_OK;\n  }\n  sqlite3_free(p);\n  return rc;\n}\n\n#endif /* SQLITE_OS_UNIX && defined(SQLITE_MUTEX_PTHREADS) */\n/******************************** End Unix Pthreads *************************/\n\n\n/********************************* Win32 Threads ****************************/\n#if SQLITE_OS_WIN_THREADS\n\n#define SQLITE_THREADS_IMPLEMENTED 1  /* Prevent the single-thread code below */\n#include <process.h>\n\n/* A running thread */\nstruct SQLiteThread {\n  void *tid;               /* The thread handle */\n  unsigned id;             /* The thread identifier */\n  void *(*xTask)(void*);   /* The routine to run as a thread */\n  void *pIn;               /* Argument to xTask */\n  void *pResult;           /* Result of xTask */\n};\n\n/* Thread procedure Win32 compatibility shim */\nstatic unsigned __stdcall sqlite3ThreadProc(\n  void *pArg  /* IN: Pointer to the SQLiteThread structure */\n){\n  SQLiteThread *p = (SQLiteThread *)pArg;\n\n  assert( p!=0 );\n#if 0\n  /*\n  ** This assert appears to trigger spuriously on certain\n  ** versions of Windows, possibly due to _beginthreadex()\n  ** and/or CreateThread() not fully setting their thread\n  ** ID parameter before starting the thread.\n  */\n  assert( p->id==GetCurrentThreadId() );\n#endif\n  assert( p->xTask!=0 );\n  p->pResult = p->xTask(p->pIn);\n\n  _endthreadex(0);\n  return 0; /* NOT REACHED */\n}\n\n/* Create a new thread */\nSQLITE_PRIVATE int sqlite3ThreadCreate(\n  SQLiteThread **ppThread,  /* OUT: Write the thread object here */\n  void *(*xTask)(void*),    /* Routine to run in a separate thread */\n  void *pIn                 /* Argument passed into xTask() */\n){\n  SQLiteThread *p;\n\n  assert( ppThread!=0 );\n  assert( xTask!=0 );\n  *ppThread = 0;\n  p = sqlite3Malloc(sizeof(*p));\n  if( p==0 ) return SQLITE_NOMEM_BKPT;\n  /* If the SQLITE_TESTCTRL_FAULT_INSTALL callback is registered to a \n  ** function that returns SQLITE_ERROR when passed the argument 200, that\n  ** forces worker threads to run sequentially and deterministically \n  ** (via the sqlite3FaultSim() term of the conditional) for testing\n  ** purposes. */\n  if( sqlite3GlobalConfig.bCoreMutex==0 || sqlite3FaultSim(200) ){\n    memset(p, 0, sizeof(*p));\n  }else{\n    p->xTask = xTask;\n    p->pIn = pIn;\n    p->tid = (void*)_beginthreadex(0, 0, sqlite3ThreadProc, p, 0, &p->id);\n    if( p->tid==0 ){\n      memset(p, 0, sizeof(*p));\n    }\n  }\n  if( p->xTask==0 ){\n    p->id = GetCurrentThreadId();\n    p->pResult = xTask(pIn);\n  }\n  *ppThread = p;\n  return SQLITE_OK;\n}\n\nSQLITE_PRIVATE DWORD sqlite3Win32Wait(HANDLE hObject); /* os_win.c */\n\n/* Get the results of the thread */\nSQLITE_PRIVATE int sqlite3ThreadJoin(SQLiteThread *p, void **ppOut){\n  DWORD rc;\n  BOOL bRc;\n\n  assert( ppOut!=0 );\n  if( NEVER(p==0) ) return SQLITE_NOMEM_BKPT;\n  if( p->xTask==0 ){\n    /* assert( p->id==GetCurrentThreadId() ); */\n    rc = WAIT_OBJECT_0;\n    assert( p->tid==0 );\n  }else{\n    assert( p->id!=0 && p->id!=GetCurrentThreadId() );\n    rc = sqlite3Win32Wait((HANDLE)p->tid);\n    assert( rc!=WAIT_IO_COMPLETION );\n    bRc = CloseHandle((HANDLE)p->tid);\n    assert( bRc );\n  }\n  if( rc==WAIT_OBJECT_0 ) *ppOut = p->pResult;\n  sqlite3_free(p);\n  return (rc==WAIT_OBJECT_0) ? SQLITE_OK : SQLITE_ERROR;\n}\n\n#endif /* SQLITE_OS_WIN_THREADS */\n/******************************** End Win32 Threads *************************/\n\n\n/********************************* Single-Threaded **************************/\n#ifndef SQLITE_THREADS_IMPLEMENTED\n/*\n** This implementation does not actually create a new thread.  It does the\n** work of the thread in the main thread, when either the thread is created\n** or when it is joined\n*/\n\n/* A running thread */\nstruct SQLiteThread {\n  void *(*xTask)(void*);   /* The routine to run as a thread */\n  void *pIn;               /* Argument to xTask */\n  void *pResult;           /* Result of xTask */\n};\n\n/* Create a new thread */\nSQLITE_PRIVATE int sqlite3ThreadCreate(\n  SQLiteThread **ppThread,  /* OUT: Write the thread object here */\n  void *(*xTask)(void*),    /* Routine to run in a separate thread */\n  void *pIn                 /* Argument passed into xTask() */\n){\n  SQLiteThread *p;\n\n  assert( ppThread!=0 );\n  assert( xTask!=0 );\n  *ppThread = 0;\n  p = sqlite3Malloc(sizeof(*p));\n  if( p==0 ) return SQLITE_NOMEM_BKPT;\n  if( (SQLITE_PTR_TO_INT(p)/17)&1 ){\n    p->xTask = xTask;\n    p->pIn = pIn;\n  }else{\n    p->xTask = 0;\n    p->pResult = xTask(pIn);\n  }\n  *ppThread = p;\n  return SQLITE_OK;\n}\n\n/* Get the results of the thread */\nSQLITE_PRIVATE int sqlite3ThreadJoin(SQLiteThread *p, void **ppOut){\n\n  assert( ppOut!=0 );\n  if( NEVER(p==0) ) return SQLITE_NOMEM_BKPT;\n  if( p->xTask ){\n    *ppOut = p->xTask(p->pIn);\n  }else{\n    *ppOut = p->pResult;\n  }\n  sqlite3_free(p);\n\n#if defined(SQLITE_TEST)\n  {\n    void *pTstAlloc = sqlite3Malloc(10);\n    if (!pTstAlloc) return SQLITE_NOMEM_BKPT;\n    sqlite3_free(pTstAlloc);\n  }\n#endif\n\n  return SQLITE_OK;\n}\n\n#endif /* !defined(SQLITE_THREADS_IMPLEMENTED) */\n/****************************** End Single-Threaded *************************/\n#endif /* SQLITE_MAX_WORKER_THREADS>0 */\n\n/************** End of threads.c *********************************************/\n/************** Begin file utf.c *********************************************/\n/*\n** 2004 April 13\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This file contains routines used to translate between UTF-8, \n** UTF-16, UTF-16BE, and UTF-16LE.\n**\n** Notes on UTF-8:\n**\n**   Byte-0    Byte-1    Byte-2    Byte-3    Value\n**  0xxxxxxx                                 00000000 00000000 0xxxxxxx\n**  110yyyyy  10xxxxxx                       00000000 00000yyy yyxxxxxx\n**  1110zzzz  10yyyyyy  10xxxxxx             00000000 zzzzyyyy yyxxxxxx\n**  11110uuu  10uuzzzz  10yyyyyy  10xxxxxx   000uuuuu zzzzyyyy yyxxxxxx\n**\n**\n** Notes on UTF-16:  (with wwww+1==uuuuu)\n**\n**      Word-0               Word-1          Value\n**  110110ww wwzzzzyy   110111yy yyxxxxxx    000uuuuu zzzzyyyy yyxxxxxx\n**  zzzzyyyy yyxxxxxx                        00000000 zzzzyyyy yyxxxxxx\n**\n**\n** BOM or Byte Order Mark:\n**     0xff 0xfe   little-endian utf-16 follows\n**     0xfe 0xff   big-endian utf-16 follows\n**\n*/\n/* #include \"sqliteInt.h\" */\n/* #include <assert.h> */\n/* #include \"vdbeInt.h\" */\n\n#if !defined(SQLITE_AMALGAMATION) && SQLITE_BYTEORDER==0\n/*\n** The following constant value is used by the SQLITE_BIGENDIAN and\n** SQLITE_LITTLEENDIAN macros.\n*/\nSQLITE_PRIVATE const int sqlite3one = 1;\n#endif /* SQLITE_AMALGAMATION && SQLITE_BYTEORDER==0 */\n\n/*\n** This lookup table is used to help decode the first byte of\n** a multi-byte UTF8 character.\n*/\nstatic const unsigned char sqlite3Utf8Trans1[] = {\n  0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,\n  0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,\n  0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,\n  0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,\n  0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,\n  0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,\n  0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,\n  0x00, 0x01, 0x02, 0x03, 0x00, 0x01, 0x00, 0x00,\n};\n\n\n#define WRITE_UTF8(zOut, c) {                          \\\n  if( c<0x00080 ){                                     \\\n    *zOut++ = (u8)(c&0xFF);                            \\\n  }                                                    \\\n  else if( c<0x00800 ){                                \\\n    *zOut++ = 0xC0 + (u8)((c>>6)&0x1F);                \\\n    *zOut++ = 0x80 + (u8)(c & 0x3F);                   \\\n  }                                                    \\\n  else if( c<0x10000 ){                                \\\n    *zOut++ = 0xE0 + (u8)((c>>12)&0x0F);               \\\n    *zOut++ = 0x80 + (u8)((c>>6) & 0x3F);              \\\n    *zOut++ = 0x80 + (u8)(c & 0x3F);                   \\\n  }else{                                               \\\n    *zOut++ = 0xF0 + (u8)((c>>18) & 0x07);             \\\n    *zOut++ = 0x80 + (u8)((c>>12) & 0x3F);             \\\n    *zOut++ = 0x80 + (u8)((c>>6) & 0x3F);              \\\n    *zOut++ = 0x80 + (u8)(c & 0x3F);                   \\\n  }                                                    \\\n}\n\n#define WRITE_UTF16LE(zOut, c) {                                    \\\n  if( c<=0xFFFF ){                                                  \\\n    *zOut++ = (u8)(c&0x00FF);                                       \\\n    *zOut++ = (u8)((c>>8)&0x00FF);                                  \\\n  }else{                                                            \\\n    *zOut++ = (u8)(((c>>10)&0x003F) + (((c-0x10000)>>10)&0x00C0));  \\\n    *zOut++ = (u8)(0x00D8 + (((c-0x10000)>>18)&0x03));              \\\n    *zOut++ = (u8)(c&0x00FF);                                       \\\n    *zOut++ = (u8)(0x00DC + ((c>>8)&0x03));                         \\\n  }                                                                 \\\n}\n\n#define WRITE_UTF16BE(zOut, c) {                                    \\\n  if( c<=0xFFFF ){                                                  \\\n    *zOut++ = (u8)((c>>8)&0x00FF);                                  \\\n    *zOut++ = (u8)(c&0x00FF);                                       \\\n  }else{                                                            \\\n    *zOut++ = (u8)(0x00D8 + (((c-0x10000)>>18)&0x03));              \\\n    *zOut++ = (u8)(((c>>10)&0x003F) + (((c-0x10000)>>10)&0x00C0));  \\\n    *zOut++ = (u8)(0x00DC + ((c>>8)&0x03));                         \\\n    *zOut++ = (u8)(c&0x00FF);                                       \\\n  }                                                                 \\\n}\n\n#define READ_UTF16LE(zIn, TERM, c){                                   \\\n  c = (*zIn++);                                                       \\\n  c += ((*zIn++)<<8);                                                 \\\n  if( c>=0xD800 && c<0xE000 && TERM ){                                \\\n    int c2 = (*zIn++);                                                \\\n    c2 += ((*zIn++)<<8);                                              \\\n    c = (c2&0x03FF) + ((c&0x003F)<<10) + (((c&0x03C0)+0x0040)<<10);   \\\n  }                                                                   \\\n}\n\n#define READ_UTF16BE(zIn, TERM, c){                                   \\\n  c = ((*zIn++)<<8);                                                  \\\n  c += (*zIn++);                                                      \\\n  if( c>=0xD800 && c<0xE000 && TERM ){                                \\\n    int c2 = ((*zIn++)<<8);                                           \\\n    c2 += (*zIn++);                                                   \\\n    c = (c2&0x03FF) + ((c&0x003F)<<10) + (((c&0x03C0)+0x0040)<<10);   \\\n  }                                                                   \\\n}\n\n/*\n** Translate a single UTF-8 character.  Return the unicode value.\n**\n** During translation, assume that the byte that zTerm points\n** is a 0x00.\n**\n** Write a pointer to the next unread byte back into *pzNext.\n**\n** Notes On Invalid UTF-8:\n**\n**  *  This routine never allows a 7-bit character (0x00 through 0x7f) to\n**     be encoded as a multi-byte character.  Any multi-byte character that\n**     attempts to encode a value between 0x00 and 0x7f is rendered as 0xfffd.\n**\n**  *  This routine never allows a UTF16 surrogate value to be encoded.\n**     If a multi-byte character attempts to encode a value between\n**     0xd800 and 0xe000 then it is rendered as 0xfffd.\n**\n**  *  Bytes in the range of 0x80 through 0xbf which occur as the first\n**     byte of a character are interpreted as single-byte characters\n**     and rendered as themselves even though they are technically\n**     invalid characters.\n**\n**  *  This routine accepts over-length UTF8 encodings\n**     for unicode values 0x80 and greater.  It does not change over-length\n**     encodings to 0xfffd as some systems recommend.\n*/\n#define READ_UTF8(zIn, zTerm, c)                           \\\n  c = *(zIn++);                                            \\\n  if( c>=0xc0 ){                                           \\\n    c = sqlite3Utf8Trans1[c-0xc0];                         \\\n    while( zIn!=zTerm && (*zIn & 0xc0)==0x80 ){            \\\n      c = (c<<6) + (0x3f & *(zIn++));                      \\\n    }                                                      \\\n    if( c<0x80                                             \\\n        || (c&0xFFFFF800)==0xD800                          \\\n        || (c&0xFFFFFFFE)==0xFFFE ){  c = 0xFFFD; }        \\\n  }\nSQLITE_PRIVATE u32 sqlite3Utf8Read(\n  const unsigned char **pz    /* Pointer to string from which to read char */\n){\n  unsigned int c;\n\n  /* Same as READ_UTF8() above but without the zTerm parameter.\n  ** For this routine, we assume the UTF8 string is always zero-terminated.\n  */\n  c = *((*pz)++);\n  if( c>=0xc0 ){\n    c = sqlite3Utf8Trans1[c-0xc0];\n    while( (*(*pz) & 0xc0)==0x80 ){\n      c = (c<<6) + (0x3f & *((*pz)++));\n    }\n    if( c<0x80\n        || (c&0xFFFFF800)==0xD800\n        || (c&0xFFFFFFFE)==0xFFFE ){  c = 0xFFFD; }\n  }\n  return c;\n}\n\n\n\n\n/*\n** If the TRANSLATE_TRACE macro is defined, the value of each Mem is\n** printed on stderr on the way into and out of sqlite3VdbeMemTranslate().\n*/ \n/* #define TRANSLATE_TRACE 1 */\n\n#ifndef SQLITE_OMIT_UTF16\n/*\n** This routine transforms the internal text encoding used by pMem to\n** desiredEnc. It is an error if the string is already of the desired\n** encoding, or if *pMem does not contain a string value.\n*/\nSQLITE_PRIVATE SQLITE_NOINLINE int sqlite3VdbeMemTranslate(Mem *pMem, u8 desiredEnc){\n  int len;                    /* Maximum length of output string in bytes */\n  unsigned char *zOut;                  /* Output buffer */\n  unsigned char *zIn;                   /* Input iterator */\n  unsigned char *zTerm;                 /* End of input */\n  unsigned char *z;                     /* Output iterator */\n  unsigned int c;\n\n  assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) );\n  assert( pMem->flags&MEM_Str );\n  assert( pMem->enc!=desiredEnc );\n  assert( pMem->enc!=0 );\n  assert( pMem->n>=0 );\n\n#if defined(TRANSLATE_TRACE) && defined(SQLITE_DEBUG)\n  {\n    char zBuf[100];\n    sqlite3VdbeMemPrettyPrint(pMem, zBuf);\n    fprintf(stderr, \"INPUT:  %s\\n\", zBuf);\n  }\n#endif\n\n  /* If the translation is between UTF-16 little and big endian, then \n  ** all that is required is to swap the byte order. This case is handled\n  ** differently from the others.\n  */\n  if( pMem->enc!=SQLITE_UTF8 && desiredEnc!=SQLITE_UTF8 ){\n    u8 temp;\n    int rc;\n    rc = sqlite3VdbeMemMakeWriteable(pMem);\n    if( rc!=SQLITE_OK ){\n      assert( rc==SQLITE_NOMEM );\n      return SQLITE_NOMEM_BKPT;\n    }\n    zIn = (u8*)pMem->z;\n    zTerm = &zIn[pMem->n&~1];\n    while( zIn<zTerm ){\n      temp = *zIn;\n      *zIn = *(zIn+1);\n      zIn++;\n      *zIn++ = temp;\n    }\n    pMem->enc = desiredEnc;\n    goto translate_out;\n  }\n\n  /* Set len to the maximum number of bytes required in the output buffer. */\n  if( desiredEnc==SQLITE_UTF8 ){\n    /* When converting from UTF-16, the maximum growth results from\n    ** translating a 2-byte character to a 4-byte UTF-8 character.\n    ** A single byte is required for the output string\n    ** nul-terminator.\n    */\n    pMem->n &= ~1;\n    len = pMem->n * 2 + 1;\n  }else{\n    /* When converting from UTF-8 to UTF-16 the maximum growth is caused\n    ** when a 1-byte UTF-8 character is translated into a 2-byte UTF-16\n    ** character. Two bytes are required in the output buffer for the\n    ** nul-terminator.\n    */\n    len = pMem->n * 2 + 2;\n  }\n\n  /* Set zIn to point at the start of the input buffer and zTerm to point 1\n  ** byte past the end.\n  **\n  ** Variable zOut is set to point at the output buffer, space obtained\n  ** from sqlite3_malloc().\n  */\n  zIn = (u8*)pMem->z;\n  zTerm = &zIn[pMem->n];\n  zOut = sqlite3DbMallocRaw(pMem->db, len);\n  if( !zOut ){\n    return SQLITE_NOMEM_BKPT;\n  }\n  z = zOut;\n\n  if( pMem->enc==SQLITE_UTF8 ){\n    if( desiredEnc==SQLITE_UTF16LE ){\n      /* UTF-8 -> UTF-16 Little-endian */\n      while( zIn<zTerm ){\n        READ_UTF8(zIn, zTerm, c);\n        WRITE_UTF16LE(z, c);\n      }\n    }else{\n      assert( desiredEnc==SQLITE_UTF16BE );\n      /* UTF-8 -> UTF-16 Big-endian */\n      while( zIn<zTerm ){\n        READ_UTF8(zIn, zTerm, c);\n        WRITE_UTF16BE(z, c);\n      }\n    }\n    pMem->n = (int)(z - zOut);\n    *z++ = 0;\n  }else{\n    assert( desiredEnc==SQLITE_UTF8 );\n    if( pMem->enc==SQLITE_UTF16LE ){\n      /* UTF-16 Little-endian -> UTF-8 */\n      while( zIn<zTerm ){\n        READ_UTF16LE(zIn, zIn<zTerm, c); \n        WRITE_UTF8(z, c);\n      }\n    }else{\n      /* UTF-16 Big-endian -> UTF-8 */\n      while( zIn<zTerm ){\n        READ_UTF16BE(zIn, zIn<zTerm, c); \n        WRITE_UTF8(z, c);\n      }\n    }\n    pMem->n = (int)(z - zOut);\n  }\n  *z = 0;\n  assert( (pMem->n+(desiredEnc==SQLITE_UTF8?1:2))<=len );\n\n  c = pMem->flags;\n  sqlite3VdbeMemRelease(pMem);\n  pMem->flags = MEM_Str|MEM_Term|(c&(MEM_AffMask|MEM_Subtype));\n  pMem->enc = desiredEnc;\n  pMem->z = (char*)zOut;\n  pMem->zMalloc = pMem->z;\n  pMem->szMalloc = sqlite3DbMallocSize(pMem->db, pMem->z);\n\ntranslate_out:\n#if defined(TRANSLATE_TRACE) && defined(SQLITE_DEBUG)\n  {\n    char zBuf[100];\n    sqlite3VdbeMemPrettyPrint(pMem, zBuf);\n    fprintf(stderr, \"OUTPUT: %s\\n\", zBuf);\n  }\n#endif\n  return SQLITE_OK;\n}\n#endif /* SQLITE_OMIT_UTF16 */\n\n#ifndef SQLITE_OMIT_UTF16\n/*\n** This routine checks for a byte-order mark at the beginning of the \n** UTF-16 string stored in *pMem. If one is present, it is removed and\n** the encoding of the Mem adjusted. This routine does not do any\n** byte-swapping, it just sets Mem.enc appropriately.\n**\n** The allocation (static, dynamic etc.) and encoding of the Mem may be\n** changed by this function.\n*/\nSQLITE_PRIVATE int sqlite3VdbeMemHandleBom(Mem *pMem){\n  int rc = SQLITE_OK;\n  u8 bom = 0;\n\n  assert( pMem->n>=0 );\n  if( pMem->n>1 ){\n    u8 b1 = *(u8 *)pMem->z;\n    u8 b2 = *(((u8 *)pMem->z) + 1);\n    if( b1==0xFE && b2==0xFF ){\n      bom = SQLITE_UTF16BE;\n    }\n    if( b1==0xFF && b2==0xFE ){\n      bom = SQLITE_UTF16LE;\n    }\n  }\n  \n  if( bom ){\n    rc = sqlite3VdbeMemMakeWriteable(pMem);\n    if( rc==SQLITE_OK ){\n      pMem->n -= 2;\n      memmove(pMem->z, &pMem->z[2], pMem->n);\n      pMem->z[pMem->n] = '\\0';\n      pMem->z[pMem->n+1] = '\\0';\n      pMem->flags |= MEM_Term;\n      pMem->enc = bom;\n    }\n  }\n  return rc;\n}\n#endif /* SQLITE_OMIT_UTF16 */\n\n/*\n** pZ is a UTF-8 encoded unicode string. If nByte is less than zero,\n** return the number of unicode characters in pZ up to (but not including)\n** the first 0x00 byte. If nByte is not less than zero, return the\n** number of unicode characters in the first nByte of pZ (or up to \n** the first 0x00, whichever comes first).\n*/\nSQLITE_PRIVATE int sqlite3Utf8CharLen(const char *zIn, int nByte){\n  int r = 0;\n  const u8 *z = (const u8*)zIn;\n  const u8 *zTerm;\n  if( nByte>=0 ){\n    zTerm = &z[nByte];\n  }else{\n    zTerm = (const u8*)(-1);\n  }\n  assert( z<=zTerm );\n  while( *z!=0 && z<zTerm ){\n    SQLITE_SKIP_UTF8(z);\n    r++;\n  }\n  return r;\n}\n\n/* This test function is not currently used by the automated test-suite. \n** Hence it is only available in debug builds.\n*/\n#if defined(SQLITE_TEST) && defined(SQLITE_DEBUG)\n/*\n** Translate UTF-8 to UTF-8.\n**\n** This has the effect of making sure that the string is well-formed\n** UTF-8.  Miscoded characters are removed.\n**\n** The translation is done in-place and aborted if the output\n** overruns the input.\n*/\nSQLITE_PRIVATE int sqlite3Utf8To8(unsigned char *zIn){\n  unsigned char *zOut = zIn;\n  unsigned char *zStart = zIn;\n  u32 c;\n\n  while( zIn[0] && zOut<=zIn ){\n    c = sqlite3Utf8Read((const u8**)&zIn);\n    if( c!=0xfffd ){\n      WRITE_UTF8(zOut, c);\n    }\n  }\n  *zOut = 0;\n  return (int)(zOut - zStart);\n}\n#endif\n\n#ifndef SQLITE_OMIT_UTF16\n/*\n** Convert a UTF-16 string in the native encoding into a UTF-8 string.\n** Memory to hold the UTF-8 string is obtained from sqlite3_malloc and must\n** be freed by the calling function.\n**\n** NULL is returned if there is an allocation error.\n*/\nSQLITE_PRIVATE char *sqlite3Utf16to8(sqlite3 *db, const void *z, int nByte, u8 enc){\n  Mem m;\n  memset(&m, 0, sizeof(m));\n  m.db = db;\n  sqlite3VdbeMemSetStr(&m, z, nByte, enc, SQLITE_STATIC);\n  sqlite3VdbeChangeEncoding(&m, SQLITE_UTF8);\n  if( db->mallocFailed ){\n    sqlite3VdbeMemRelease(&m);\n    m.z = 0;\n  }\n  assert( (m.flags & MEM_Term)!=0 || db->mallocFailed );\n  assert( (m.flags & MEM_Str)!=0 || db->mallocFailed );\n  assert( m.z || db->mallocFailed );\n  return m.z;\n}\n\n/*\n** zIn is a UTF-16 encoded unicode string at least nChar characters long.\n** Return the number of bytes in the first nChar unicode characters\n** in pZ.  nChar must be non-negative.\n*/\nSQLITE_PRIVATE int sqlite3Utf16ByteLen(const void *zIn, int nChar){\n  int c;\n  unsigned char const *z = zIn;\n  int n = 0;\n  \n  if( SQLITE_UTF16NATIVE==SQLITE_UTF16BE ){\n    while( n<nChar ){\n      READ_UTF16BE(z, 1, c);\n      n++;\n    }\n  }else{\n    while( n<nChar ){\n      READ_UTF16LE(z, 1, c);\n      n++;\n    }\n  }\n  return (int)(z-(unsigned char const *)zIn);\n}\n\n#if defined(SQLITE_TEST)\n/*\n** This routine is called from the TCL test function \"translate_selftest\".\n** It checks that the primitives for serializing and deserializing\n** characters in each encoding are inverses of each other.\n*/\nSQLITE_PRIVATE void sqlite3UtfSelfTest(void){\n  unsigned int i, t;\n  unsigned char zBuf[20];\n  unsigned char *z;\n  int n;\n  unsigned int c;\n\n  for(i=0; i<0x00110000; i++){\n    z = zBuf;\n    WRITE_UTF8(z, i);\n    n = (int)(z-zBuf);\n    assert( n>0 && n<=4 );\n    z[0] = 0;\n    z = zBuf;\n    c = sqlite3Utf8Read((const u8**)&z);\n    t = i;\n    if( i>=0xD800 && i<=0xDFFF ) t = 0xFFFD;\n    if( (i&0xFFFFFFFE)==0xFFFE ) t = 0xFFFD;\n    assert( c==t );\n    assert( (z-zBuf)==n );\n  }\n  for(i=0; i<0x00110000; i++){\n    if( i>=0xD800 && i<0xE000 ) continue;\n    z = zBuf;\n    WRITE_UTF16LE(z, i);\n    n = (int)(z-zBuf);\n    assert( n>0 && n<=4 );\n    z[0] = 0;\n    z = zBuf;\n    READ_UTF16LE(z, 1, c);\n    assert( c==i );\n    assert( (z-zBuf)==n );\n  }\n  for(i=0; i<0x00110000; i++){\n    if( i>=0xD800 && i<0xE000 ) continue;\n    z = zBuf;\n    WRITE_UTF16BE(z, i);\n    n = (int)(z-zBuf);\n    assert( n>0 && n<=4 );\n    z[0] = 0;\n    z = zBuf;\n    READ_UTF16BE(z, 1, c);\n    assert( c==i );\n    assert( (z-zBuf)==n );\n  }\n}\n#endif /* SQLITE_TEST */\n#endif /* SQLITE_OMIT_UTF16 */\n\n/************** End of utf.c *************************************************/\n/************** Begin file util.c ********************************************/\n/*\n** 2001 September 15\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** Utility functions used throughout sqlite.\n**\n** This file contains functions for allocating memory, comparing\n** strings, and stuff like that.\n**\n*/\n/* #include \"sqliteInt.h\" */\n/* #include <stdarg.h> */\n#if HAVE_ISNAN || SQLITE_HAVE_ISNAN\n# include <math.h>\n#endif\n\n/*\n** Routine needed to support the testcase() macro.\n*/\n#ifdef SQLITE_COVERAGE_TEST\nSQLITE_PRIVATE void sqlite3Coverage(int x){\n  static unsigned dummy = 0;\n  dummy += (unsigned)x;\n}\n#endif\n\n/*\n** Give a callback to the test harness that can be used to simulate faults\n** in places where it is difficult or expensive to do so purely by means\n** of inputs.\n**\n** The intent of the integer argument is to let the fault simulator know\n** which of multiple sqlite3FaultSim() calls has been hit.\n**\n** Return whatever integer value the test callback returns, or return\n** SQLITE_OK if no test callback is installed.\n*/\n#ifndef SQLITE_UNTESTABLE\nSQLITE_PRIVATE int sqlite3FaultSim(int iTest){\n  int (*xCallback)(int) = sqlite3GlobalConfig.xTestCallback;\n  return xCallback ? xCallback(iTest) : SQLITE_OK;\n}\n#endif\n\n#ifndef SQLITE_OMIT_FLOATING_POINT\n/*\n** Return true if the floating point value is Not a Number (NaN).\n**\n** Use the math library isnan() function if compiled with SQLITE_HAVE_ISNAN.\n** Otherwise, we have our own implementation that works on most systems.\n*/\nSQLITE_PRIVATE int sqlite3IsNaN(double x){\n  int rc;   /* The value return */\n#if !SQLITE_HAVE_ISNAN && !HAVE_ISNAN\n  /*\n  ** Systems that support the isnan() library function should probably\n  ** make use of it by compiling with -DSQLITE_HAVE_ISNAN.  But we have\n  ** found that many systems do not have a working isnan() function so\n  ** this implementation is provided as an alternative.\n  **\n  ** This NaN test sometimes fails if compiled on GCC with -ffast-math.\n  ** On the other hand, the use of -ffast-math comes with the following\n  ** warning:\n  **\n  **      This option [-ffast-math] should never be turned on by any\n  **      -O option since it can result in incorrect output for programs\n  **      which depend on an exact implementation of IEEE or ISO \n  **      rules/specifications for math functions.\n  **\n  ** Under MSVC, this NaN test may fail if compiled with a floating-\n  ** point precision mode other than /fp:precise.  From the MSDN \n  ** documentation:\n  **\n  **      The compiler [with /fp:precise] will properly handle comparisons \n  **      involving NaN. For example, x != x evaluates to true if x is NaN \n  **      ...\n  */\n#ifdef __FAST_MATH__\n# error SQLite will not work correctly with the -ffast-math option of GCC.\n#endif\n  volatile double y = x;\n  volatile double z = y;\n  rc = (y!=z);\n#else  /* if HAVE_ISNAN */\n  rc = isnan(x);\n#endif /* HAVE_ISNAN */\n  testcase( rc );\n  return rc;\n}\n#endif /* SQLITE_OMIT_FLOATING_POINT */\n\n/*\n** Compute a string length that is limited to what can be stored in\n** lower 30 bits of a 32-bit signed integer.\n**\n** The value returned will never be negative.  Nor will it ever be greater\n** than the actual length of the string.  For very long strings (greater\n** than 1GiB) the value returned might be less than the true string length.\n*/\nSQLITE_PRIVATE int sqlite3Strlen30(const char *z){\n  if( z==0 ) return 0;\n  return 0x3fffffff & (int)strlen(z);\n}\n\n/*\n** Return the declared type of a column.  Or return zDflt if the column \n** has no declared type.\n**\n** The column type is an extra string stored after the zero-terminator on\n** the column name if and only if the COLFLAG_HASTYPE flag is set.\n*/\nSQLITE_PRIVATE char *sqlite3ColumnType(Column *pCol, char *zDflt){\n  if( (pCol->colFlags & COLFLAG_HASTYPE)==0 ) return zDflt;\n  return pCol->zName + strlen(pCol->zName) + 1;\n}\n\n/*\n** Helper function for sqlite3Error() - called rarely.  Broken out into\n** a separate routine to avoid unnecessary register saves on entry to\n** sqlite3Error().\n*/\nstatic SQLITE_NOINLINE void  sqlite3ErrorFinish(sqlite3 *db, int err_code){\n  if( db->pErr ) sqlite3ValueSetNull(db->pErr);\n  sqlite3SystemError(db, err_code);\n}\n\n/*\n** Set the current error code to err_code and clear any prior error message.\n** Also set iSysErrno (by calling sqlite3System) if the err_code indicates\n** that would be appropriate.\n*/\nSQLITE_PRIVATE void sqlite3Error(sqlite3 *db, int err_code){\n  assert( db!=0 );\n  db->errCode = err_code;\n  if( err_code || db->pErr ) sqlite3ErrorFinish(db, err_code);\n}\n\n/*\n** Load the sqlite3.iSysErrno field if that is an appropriate thing\n** to do based on the SQLite error code in rc.\n*/\nSQLITE_PRIVATE void sqlite3SystemError(sqlite3 *db, int rc){\n  if( rc==SQLITE_IOERR_NOMEM ) return;\n  rc &= 0xff;\n  if( rc==SQLITE_CANTOPEN || rc==SQLITE_IOERR ){\n    db->iSysErrno = sqlite3OsGetLastError(db->pVfs);\n  }\n}\n\n/*\n** Set the most recent error code and error string for the sqlite\n** handle \"db\". The error code is set to \"err_code\".\n**\n** If it is not NULL, string zFormat specifies the format of the\n** error string in the style of the printf functions: The following\n** format characters are allowed:\n**\n**      %s      Insert a string\n**      %z      A string that should be freed after use\n**      %d      Insert an integer\n**      %T      Insert a token\n**      %S      Insert the first element of a SrcList\n**\n** zFormat and any string tokens that follow it are assumed to be\n** encoded in UTF-8.\n**\n** To clear the most recent error for sqlite handle \"db\", sqlite3Error\n** should be called with err_code set to SQLITE_OK and zFormat set\n** to NULL.\n*/\nSQLITE_PRIVATE void sqlite3ErrorWithMsg(sqlite3 *db, int err_code, const char *zFormat, ...){\n  assert( db!=0 );\n  db->errCode = err_code;\n  sqlite3SystemError(db, err_code);\n  if( zFormat==0 ){\n    sqlite3Error(db, err_code);\n  }else if( db->pErr || (db->pErr = sqlite3ValueNew(db))!=0 ){\n    char *z;\n    va_list ap;\n    va_start(ap, zFormat);\n    z = sqlite3VMPrintf(db, zFormat, ap);\n    va_end(ap);\n    sqlite3ValueSetStr(db->pErr, -1, z, SQLITE_UTF8, SQLITE_DYNAMIC);\n  }\n}\n\n/*\n** Add an error message to pParse->zErrMsg and increment pParse->nErr.\n** The following formatting characters are allowed:\n**\n**      %s      Insert a string\n**      %z      A string that should be freed after use\n**      %d      Insert an integer\n**      %T      Insert a token\n**      %S      Insert the first element of a SrcList\n**\n** This function should be used to report any error that occurs while\n** compiling an SQL statement (i.e. within sqlite3_prepare()). The\n** last thing the sqlite3_prepare() function does is copy the error\n** stored by this function into the database handle using sqlite3Error().\n** Functions sqlite3Error() or sqlite3ErrorWithMsg() should be used\n** during statement execution (sqlite3_step() etc.).\n*/\nSQLITE_PRIVATE void sqlite3ErrorMsg(Parse *pParse, const char *zFormat, ...){\n  char *zMsg;\n  va_list ap;\n  sqlite3 *db = pParse->db;\n  va_start(ap, zFormat);\n  zMsg = sqlite3VMPrintf(db, zFormat, ap);\n  va_end(ap);\n  if( db->suppressErr ){\n    sqlite3DbFree(db, zMsg);\n  }else{\n    pParse->nErr++;\n    sqlite3DbFree(db, pParse->zErrMsg);\n    pParse->zErrMsg = zMsg;\n    pParse->rc = SQLITE_ERROR;\n  }\n}\n\n/*\n** Convert an SQL-style quoted string into a normal string by removing\n** the quote characters.  The conversion is done in-place.  If the\n** input does not begin with a quote character, then this routine\n** is a no-op.\n**\n** The input string must be zero-terminated.  A new zero-terminator\n** is added to the dequoted string.\n**\n** The return value is -1 if no dequoting occurs or the length of the\n** dequoted string, exclusive of the zero terminator, if dequoting does\n** occur.\n**\n** 2002-02-14: This routine is extended to remove MS-Access style\n** brackets from around identifiers.  For example:  \"[a-b-c]\" becomes\n** \"a-b-c\".\n*/\nSQLITE_PRIVATE void sqlite3Dequote(char *z){\n  char quote;\n  int i, j;\n  if( z==0 ) return;\n  quote = z[0];\n  if( !sqlite3Isquote(quote) ) return;\n  if( quote=='[' ) quote = ']';\n  for(i=1, j=0;; i++){\n    assert( z[i] );\n    if( z[i]==quote ){\n      if( z[i+1]==quote ){\n        z[j++] = quote;\n        i++;\n      }else{\n        break;\n      }\n    }else{\n      z[j++] = z[i];\n    }\n  }\n  z[j] = 0;\n}\nSQLITE_PRIVATE void sqlite3DequoteExpr(Expr *p){\n  assert( sqlite3Isquote(p->u.zToken[0]) );\n  p->flags |= p->u.zToken[0]=='\"' ? EP_Quoted|EP_DblQuoted : EP_Quoted;\n  sqlite3Dequote(p->u.zToken);\n}\n\n/*\n** Generate a Token object from a string\n*/\nSQLITE_PRIVATE void sqlite3TokenInit(Token *p, char *z){\n  p->z = z;\n  p->n = sqlite3Strlen30(z);\n}\n\n/* Convenient short-hand */\n#define UpperToLower sqlite3UpperToLower\n\n/*\n** Some systems have stricmp().  Others have strcasecmp().  Because\n** there is no consistency, we will define our own.\n**\n** IMPLEMENTATION-OF: R-30243-02494 The sqlite3_stricmp() and\n** sqlite3_strnicmp() APIs allow applications and extensions to compare\n** the contents of two buffers containing UTF-8 strings in a\n** case-independent fashion, using the same definition of \"case\n** independence\" that SQLite uses internally when comparing identifiers.\n*/\nSQLITE_API int sqlite3_stricmp(const char *zLeft, const char *zRight){\n  if( zLeft==0 ){\n    return zRight ? -1 : 0;\n  }else if( zRight==0 ){\n    return 1;\n  }\n  return sqlite3StrICmp(zLeft, zRight);\n}\nSQLITE_PRIVATE int sqlite3StrICmp(const char *zLeft, const char *zRight){\n  unsigned char *a, *b;\n  int c;\n  a = (unsigned char *)zLeft;\n  b = (unsigned char *)zRight;\n  for(;;){\n    c = (int)UpperToLower[*a] - (int)UpperToLower[*b];\n    if( c || *a==0 ) break;\n    a++;\n    b++;\n  }\n  return c;\n}\nSQLITE_API int sqlite3_strnicmp(const char *zLeft, const char *zRight, int N){\n  register unsigned char *a, *b;\n  if( zLeft==0 ){\n    return zRight ? -1 : 0;\n  }else if( zRight==0 ){\n    return 1;\n  }\n  a = (unsigned char *)zLeft;\n  b = (unsigned char *)zRight;\n  while( N-- > 0 && *a!=0 && UpperToLower[*a]==UpperToLower[*b]){ a++; b++; }\n  return N<0 ? 0 : UpperToLower[*a] - UpperToLower[*b];\n}\n\n/*\n** Compute 10 to the E-th power.  Examples:  E==1 results in 10.\n** E==2 results in 100.  E==50 results in 1.0e50.\n**\n** This routine only works for values of E between 1 and 341.\n*/\nstatic LONGDOUBLE_TYPE sqlite3Pow10(int E){\n#if defined(_MSC_VER)\n  static const LONGDOUBLE_TYPE x[] = {\n    1.0e+001,\n    1.0e+002,\n    1.0e+004,\n    1.0e+008,\n    1.0e+016,\n    1.0e+032,\n    1.0e+064,\n    1.0e+128,\n    1.0e+256\n  };\n  LONGDOUBLE_TYPE r = 1.0;\n  int i;\n  assert( E>=0 && E<=307 );\n  for(i=0; E!=0; i++, E >>=1){\n    if( E & 1 ) r *= x[i];\n  }\n  return r;\n#else\n  LONGDOUBLE_TYPE x = 10.0;\n  LONGDOUBLE_TYPE r = 1.0;\n  while(1){\n    if( E & 1 ) r *= x;\n    E >>= 1;\n    if( E==0 ) break;\n    x *= x;\n  }\n  return r; \n#endif\n}\n\n/*\n** The string z[] is an text representation of a real number.\n** Convert this string to a double and write it into *pResult.\n**\n** The string z[] is length bytes in length (bytes, not characters) and\n** uses the encoding enc.  The string is not necessarily zero-terminated.\n**\n** Return TRUE if the result is a valid real number (or integer) and FALSE\n** if the string is empty or contains extraneous text.  Valid numbers\n** are in one of these formats:\n**\n**    [+-]digits[E[+-]digits]\n**    [+-]digits.[digits][E[+-]digits]\n**    [+-].digits[E[+-]digits]\n**\n** Leading and trailing whitespace is ignored for the purpose of determining\n** validity.\n**\n** If some prefix of the input string is a valid number, this routine\n** returns FALSE but it still converts the prefix and writes the result\n** into *pResult.\n*/\nSQLITE_PRIVATE int sqlite3AtoF(const char *z, double *pResult, int length, u8 enc){\n#ifndef SQLITE_OMIT_FLOATING_POINT\n  int incr;\n  const char *zEnd = z + length;\n  /* sign * significand * (10 ^ (esign * exponent)) */\n  int sign = 1;    /* sign of significand */\n  i64 s = 0;       /* significand */\n  int d = 0;       /* adjust exponent for shifting decimal point */\n  int esign = 1;   /* sign of exponent */\n  int e = 0;       /* exponent */\n  int eValid = 1;  /* True exponent is either not used or is well-formed */\n  double result;\n  int nDigits = 0;\n  int nonNum = 0;  /* True if input contains UTF16 with high byte non-zero */\n\n  assert( enc==SQLITE_UTF8 || enc==SQLITE_UTF16LE || enc==SQLITE_UTF16BE );\n  *pResult = 0.0;   /* Default return value, in case of an error */\n\n  if( enc==SQLITE_UTF8 ){\n    incr = 1;\n  }else{\n    int i;\n    incr = 2;\n    assert( SQLITE_UTF16LE==2 && SQLITE_UTF16BE==3 );\n    for(i=3-enc; i<length && z[i]==0; i+=2){}\n    nonNum = i<length;\n    zEnd = &z[i^1];\n    z += (enc&1);\n  }\n\n  /* skip leading spaces */\n  while( z<zEnd && sqlite3Isspace(*z) ) z+=incr;\n  if( z>=zEnd ) return 0;\n\n  /* get sign of significand */\n  if( *z=='-' ){\n    sign = -1;\n    z+=incr;\n  }else if( *z=='+' ){\n    z+=incr;\n  }\n\n  /* copy max significant digits to significand */\n  while( z<zEnd && sqlite3Isdigit(*z) && s<((LARGEST_INT64-9)/10) ){\n    s = s*10 + (*z - '0');\n    z+=incr; nDigits++;\n  }\n\n  /* skip non-significant significand digits\n  ** (increase exponent by d to shift decimal left) */\n  while( z<zEnd && sqlite3Isdigit(*z) ){ z+=incr; nDigits++; d++; }\n  if( z>=zEnd ) goto do_atof_calc;\n\n  /* if decimal point is present */\n  if( *z=='.' ){\n    z+=incr;\n    /* copy digits from after decimal to significand\n    ** (decrease exponent by d to shift decimal right) */\n    while( z<zEnd && sqlite3Isdigit(*z) ){\n      if( s<((LARGEST_INT64-9)/10) ){\n        s = s*10 + (*z - '0');\n        d--;\n      }\n      z+=incr; nDigits++;\n    }\n  }\n  if( z>=zEnd ) goto do_atof_calc;\n\n  /* if exponent is present */\n  if( *z=='e' || *z=='E' ){\n    z+=incr;\n    eValid = 0;\n\n    /* This branch is needed to avoid a (harmless) buffer overread.  The \n    ** special comment alerts the mutation tester that the correct answer\n    ** is obtained even if the branch is omitted */\n    if( z>=zEnd ) goto do_atof_calc;              /*PREVENTS-HARMLESS-OVERREAD*/\n\n    /* get sign of exponent */\n    if( *z=='-' ){\n      esign = -1;\n      z+=incr;\n    }else if( *z=='+' ){\n      z+=incr;\n    }\n    /* copy digits to exponent */\n    while( z<zEnd && sqlite3Isdigit(*z) ){\n      e = e<10000 ? (e*10 + (*z - '0')) : 10000;\n      z+=incr;\n      eValid = 1;\n    }\n  }\n\n  /* skip trailing spaces */\n  while( z<zEnd && sqlite3Isspace(*z) ) z+=incr;\n\ndo_atof_calc:\n  /* adjust exponent by d, and update sign */\n  e = (e*esign) + d;\n  if( e<0 ) {\n    esign = -1;\n    e *= -1;\n  } else {\n    esign = 1;\n  }\n\n  if( s==0 ) {\n    /* In the IEEE 754 standard, zero is signed. */\n    result = sign<0 ? -(double)0 : (double)0;\n  } else {\n    /* Attempt to reduce exponent.\n    **\n    ** Branches that are not required for the correct answer but which only\n    ** help to obtain the correct answer faster are marked with special\n    ** comments, as a hint to the mutation tester.\n    */\n    while( e>0 ){                                       /*OPTIMIZATION-IF-TRUE*/\n      if( esign>0 ){\n        if( s>=(LARGEST_INT64/10) ) break;             /*OPTIMIZATION-IF-FALSE*/\n        s *= 10;\n      }else{\n        if( s%10!=0 ) break;                           /*OPTIMIZATION-IF-FALSE*/\n        s /= 10;\n      }\n      e--;\n    }\n\n    /* adjust the sign of significand */\n    s = sign<0 ? -s : s;\n\n    if( e==0 ){                                         /*OPTIMIZATION-IF-TRUE*/\n      result = (double)s;\n    }else{\n      /* attempt to handle extremely small/large numbers better */\n      if( e>307 ){                                      /*OPTIMIZATION-IF-TRUE*/\n        if( e<342 ){                                    /*OPTIMIZATION-IF-TRUE*/\n          LONGDOUBLE_TYPE scale = sqlite3Pow10(e-308);\n          if( esign<0 ){\n            result = s / scale;\n            result /= 1.0e+308;\n          }else{\n            result = s * scale;\n            result *= 1.0e+308;\n          }\n        }else{ assert( e>=342 );\n          if( esign<0 ){\n            result = 0.0*s;\n          }else{\n#ifdef INFINITY\n            result = INFINITY*s;\n#else\n            result = 1e308*1e308*s;  /* Infinity */\n#endif\n          }\n        }\n      }else{\n        LONGDOUBLE_TYPE scale = sqlite3Pow10(e);\n        if( esign<0 ){\n          result = s / scale;\n        }else{\n          result = s * scale;\n        }\n      }\n    }\n  }\n\n  /* store the result */\n  *pResult = result;\n\n  /* return true if number and no extra non-whitespace chracters after */\n  return z==zEnd && nDigits>0 && eValid && nonNum==0;\n#else\n  return !sqlite3Atoi64(z, pResult, length, enc);\n#endif /* SQLITE_OMIT_FLOATING_POINT */\n}\n\n/*\n** Compare the 19-character string zNum against the text representation\n** value 2^63:  9223372036854775808.  Return negative, zero, or positive\n** if zNum is less than, equal to, or greater than the string.\n** Note that zNum must contain exactly 19 characters.\n**\n** Unlike memcmp() this routine is guaranteed to return the difference\n** in the values of the last digit if the only difference is in the\n** last digit.  So, for example,\n**\n**      compare2pow63(\"9223372036854775800\", 1)\n**\n** will return -8.\n*/\nstatic int compare2pow63(const char *zNum, int incr){\n  int c = 0;\n  int i;\n                    /* 012345678901234567 */\n  const char *pow63 = \"922337203685477580\";\n  for(i=0; c==0 && i<18; i++){\n    c = (zNum[i*incr]-pow63[i])*10;\n  }\n  if( c==0 ){\n    c = zNum[18*incr] - '8';\n    testcase( c==(-1) );\n    testcase( c==0 );\n    testcase( c==(+1) );\n  }\n  return c;\n}\n\n/*\n** Convert zNum to a 64-bit signed integer.  zNum must be decimal. This\n** routine does *not* accept hexadecimal notation.\n**\n** Returns:\n**\n**     0    Successful transformation.  Fits in a 64-bit signed integer.\n**     1    Excess non-space text after the integer value\n**     2    Integer too large for a 64-bit signed integer or is malformed\n**     3    Special case of 9223372036854775808\n**\n** length is the number of bytes in the string (bytes, not characters).\n** The string is not necessarily zero-terminated.  The encoding is\n** given by enc.\n*/\nSQLITE_PRIVATE int sqlite3Atoi64(const char *zNum, i64 *pNum, int length, u8 enc){\n  int incr;\n  u64 u = 0;\n  int neg = 0; /* assume positive */\n  int i;\n  int c = 0;\n  int nonNum = 0;  /* True if input contains UTF16 with high byte non-zero */\n  int rc;          /* Baseline return code */\n  const char *zStart;\n  const char *zEnd = zNum + length;\n  assert( enc==SQLITE_UTF8 || enc==SQLITE_UTF16LE || enc==SQLITE_UTF16BE );\n  if( enc==SQLITE_UTF8 ){\n    incr = 1;\n  }else{\n    incr = 2;\n    assert( SQLITE_UTF16LE==2 && SQLITE_UTF16BE==3 );\n    for(i=3-enc; i<length && zNum[i]==0; i+=2){}\n    nonNum = i<length;\n    zEnd = &zNum[i^1];\n    zNum += (enc&1);\n  }\n  while( zNum<zEnd && sqlite3Isspace(*zNum) ) zNum+=incr;\n  if( zNum<zEnd ){\n    if( *zNum=='-' ){\n      neg = 1;\n      zNum+=incr;\n    }else if( *zNum=='+' ){\n      zNum+=incr;\n    }\n  }\n  zStart = zNum;\n  while( zNum<zEnd && zNum[0]=='0' ){ zNum+=incr; } /* Skip leading zeros. */\n  for(i=0; &zNum[i]<zEnd && (c=zNum[i])>='0' && c<='9'; i+=incr){\n    u = u*10 + c - '0';\n  }\n  testcase( i==18*incr );\n  testcase( i==19*incr );\n  testcase( i==20*incr );\n  if( u>LARGEST_INT64 ){\n    /* This test and assignment is needed only to suppress UB warnings\n    ** from clang and -fsanitize=undefined.  This test and assignment make\n    ** the code a little larger and slower, and no harm comes from omitting\n    ** them, but we must appaise the undefined-behavior pharisees. */\n    *pNum = neg ? SMALLEST_INT64 : LARGEST_INT64;\n  }else if( neg ){\n    *pNum = -(i64)u;\n  }else{\n    *pNum = (i64)u;\n  }\n  rc = 0;\n  if( (i==0 && zStart==zNum)     /* No digits */\n   || nonNum                     /* UTF16 with high-order bytes non-zero */\n  ){\n    rc = 1;\n  }else if( &zNum[i]<zEnd ){     /* Extra bytes at the end */\n    int jj = i;\n    do{\n      if( !sqlite3Isspace(zNum[jj]) ){\n        rc = 1;          /* Extra non-space text after the integer */\n        break;\n      }\n      jj += incr;\n    }while( &zNum[jj]<zEnd );\n  }\n  if( i<19*incr ){\n    /* Less than 19 digits, so we know that it fits in 64 bits */\n    assert( u<=LARGEST_INT64 );\n    return rc;\n  }else{\n    /* zNum is a 19-digit numbers.  Compare it against 9223372036854775808. */\n    c = i>19*incr ? 1 : compare2pow63(zNum, incr);\n    if( c<0 ){\n      /* zNum is less than 9223372036854775808 so it fits */\n      assert( u<=LARGEST_INT64 );\n      return rc;\n    }else{\n      *pNum = neg ? SMALLEST_INT64 : LARGEST_INT64;\n      if( c>0 ){\n        /* zNum is greater than 9223372036854775808 so it overflows */\n        return 2;\n      }else{\n        /* zNum is exactly 9223372036854775808.  Fits if negative.  The\n        ** special case 2 overflow if positive */\n        assert( u-1==LARGEST_INT64 );\n        return neg ? rc : 3;\n      }\n    }\n  }\n}\n\n/*\n** Transform a UTF-8 integer literal, in either decimal or hexadecimal,\n** into a 64-bit signed integer.  This routine accepts hexadecimal literals,\n** whereas sqlite3Atoi64() does not.\n**\n** Returns:\n**\n**     0    Successful transformation.  Fits in a 64-bit signed integer.\n**     1    Excess text after the integer value\n**     2    Integer too large for a 64-bit signed integer or is malformed\n**     3    Special case of 9223372036854775808\n*/\nSQLITE_PRIVATE int sqlite3DecOrHexToI64(const char *z, i64 *pOut){\n#ifndef SQLITE_OMIT_HEX_INTEGER\n  if( z[0]=='0'\n   && (z[1]=='x' || z[1]=='X')\n  ){\n    u64 u = 0;\n    int i, k;\n    for(i=2; z[i]=='0'; i++){}\n    for(k=i; sqlite3Isxdigit(z[k]); k++){\n      u = u*16 + sqlite3HexToInt(z[k]);\n    }\n    memcpy(pOut, &u, 8);\n    return (z[k]==0 && k-i<=16) ? 0 : 2;\n  }else\n#endif /* SQLITE_OMIT_HEX_INTEGER */\n  {\n    return sqlite3Atoi64(z, pOut, sqlite3Strlen30(z), SQLITE_UTF8);\n  }\n}\n\n/*\n** If zNum represents an integer that will fit in 32-bits, then set\n** *pValue to that integer and return true.  Otherwise return false.\n**\n** This routine accepts both decimal and hexadecimal notation for integers.\n**\n** Any non-numeric characters that following zNum are ignored.\n** This is different from sqlite3Atoi64() which requires the\n** input number to be zero-terminated.\n*/\nSQLITE_PRIVATE int sqlite3GetInt32(const char *zNum, int *pValue){\n  sqlite_int64 v = 0;\n  int i, c;\n  int neg = 0;\n  if( zNum[0]=='-' ){\n    neg = 1;\n    zNum++;\n  }else if( zNum[0]=='+' ){\n    zNum++;\n  }\n#ifndef SQLITE_OMIT_HEX_INTEGER\n  else if( zNum[0]=='0'\n        && (zNum[1]=='x' || zNum[1]=='X')\n        && sqlite3Isxdigit(zNum[2])\n  ){\n    u32 u = 0;\n    zNum += 2;\n    while( zNum[0]=='0' ) zNum++;\n    for(i=0; sqlite3Isxdigit(zNum[i]) && i<8; i++){\n      u = u*16 + sqlite3HexToInt(zNum[i]);\n    }\n    if( (u&0x80000000)==0 && sqlite3Isxdigit(zNum[i])==0 ){\n      memcpy(pValue, &u, 4);\n      return 1;\n    }else{\n      return 0;\n    }\n  }\n#endif\n  if( !sqlite3Isdigit(zNum[0]) ) return 0;\n  while( zNum[0]=='0' ) zNum++;\n  for(i=0; i<11 && (c = zNum[i] - '0')>=0 && c<=9; i++){\n    v = v*10 + c;\n  }\n\n  /* The longest decimal representation of a 32 bit integer is 10 digits:\n  **\n  **             1234567890\n  **     2^31 -> 2147483648\n  */\n  testcase( i==10 );\n  if( i>10 ){\n    return 0;\n  }\n  testcase( v-neg==2147483647 );\n  if( v-neg>2147483647 ){\n    return 0;\n  }\n  if( neg ){\n    v = -v;\n  }\n  *pValue = (int)v;\n  return 1;\n}\n\n/*\n** Return a 32-bit integer value extracted from a string.  If the\n** string is not an integer, just return 0.\n*/\nSQLITE_PRIVATE int sqlite3Atoi(const char *z){\n  int x = 0;\n  if( z ) sqlite3GetInt32(z, &x);\n  return x;\n}\n\n/*\n** The variable-length integer encoding is as follows:\n**\n** KEY:\n**         A = 0xxxxxxx    7 bits of data and one flag bit\n**         B = 1xxxxxxx    7 bits of data and one flag bit\n**         C = xxxxxxxx    8 bits of data\n**\n**  7 bits - A\n** 14 bits - BA\n** 21 bits - BBA\n** 28 bits - BBBA\n** 35 bits - BBBBA\n** 42 bits - BBBBBA\n** 49 bits - BBBBBBA\n** 56 bits - BBBBBBBA\n** 64 bits - BBBBBBBBC\n*/\n\n/*\n** Write a 64-bit variable-length integer to memory starting at p[0].\n** The length of data write will be between 1 and 9 bytes.  The number\n** of bytes written is returned.\n**\n** A variable-length integer consists of the lower 7 bits of each byte\n** for all bytes that have the 8th bit set and one byte with the 8th\n** bit clear.  Except, if we get to the 9th byte, it stores the full\n** 8 bits and is the last byte.\n*/\nstatic int SQLITE_NOINLINE putVarint64(unsigned char *p, u64 v){\n  int i, j, n;\n  u8 buf[10];\n  if( v & (((u64)0xff000000)<<32) ){\n    p[8] = (u8)v;\n    v >>= 8;\n    for(i=7; i>=0; i--){\n      p[i] = (u8)((v & 0x7f) | 0x80);\n      v >>= 7;\n    }\n    return 9;\n  }    \n  n = 0;\n  do{\n    buf[n++] = (u8)((v & 0x7f) | 0x80);\n    v >>= 7;\n  }while( v!=0 );\n  buf[0] &= 0x7f;\n  assert( n<=9 );\n  for(i=0, j=n-1; j>=0; j--, i++){\n    p[i] = buf[j];\n  }\n  return n;\n}\nSQLITE_PRIVATE int sqlite3PutVarint(unsigned char *p, u64 v){\n  if( v<=0x7f ){\n    p[0] = v&0x7f;\n    return 1;\n  }\n  if( v<=0x3fff ){\n    p[0] = ((v>>7)&0x7f)|0x80;\n    p[1] = v&0x7f;\n    return 2;\n  }\n  return putVarint64(p,v);\n}\n\n/*\n** Bitmasks used by sqlite3GetVarint().  These precomputed constants\n** are defined here rather than simply putting the constant expressions\n** inline in order to work around bugs in the RVT compiler.\n**\n** SLOT_2_0     A mask for  (0x7f<<14) | 0x7f\n**\n** SLOT_4_2_0   A mask for  (0x7f<<28) | SLOT_2_0\n*/\n#define SLOT_2_0     0x001fc07f\n#define SLOT_4_2_0   0xf01fc07f\n\n\n/*\n** Read a 64-bit variable-length integer from memory starting at p[0].\n** Return the number of bytes read.  The value is stored in *v.\n*/\nSQLITE_PRIVATE u8 sqlite3GetVarint(const unsigned char *p, u64 *v){\n  u32 a,b,s;\n\n  a = *p;\n  /* a: p0 (unmasked) */\n  if (!(a&0x80))\n  {\n    *v = a;\n    return 1;\n  }\n\n  p++;\n  b = *p;\n  /* b: p1 (unmasked) */\n  if (!(b&0x80))\n  {\n    a &= 0x7f;\n    a = a<<7;\n    a |= b;\n    *v = a;\n    return 2;\n  }\n\n  /* Verify that constants are precomputed correctly */\n  assert( SLOT_2_0 == ((0x7f<<14) | (0x7f)) );\n  assert( SLOT_4_2_0 == ((0xfU<<28) | (0x7f<<14) | (0x7f)) );\n\n  p++;\n  a = a<<14;\n  a |= *p;\n  /* a: p0<<14 | p2 (unmasked) */\n  if (!(a&0x80))\n  {\n    a &= SLOT_2_0;\n    b &= 0x7f;\n    b = b<<7;\n    a |= b;\n    *v = a;\n    return 3;\n  }\n\n  /* CSE1 from below */\n  a &= SLOT_2_0;\n  p++;\n  b = b<<14;\n  b |= *p;\n  /* b: p1<<14 | p3 (unmasked) */\n  if (!(b&0x80))\n  {\n    b &= SLOT_2_0;\n    /* moved CSE1 up */\n    /* a &= (0x7f<<14)|(0x7f); */\n    a = a<<7;\n    a |= b;\n    *v = a;\n    return 4;\n  }\n\n  /* a: p0<<14 | p2 (masked) */\n  /* b: p1<<14 | p3 (unmasked) */\n  /* 1:save off p0<<21 | p1<<14 | p2<<7 | p3 (masked) */\n  /* moved CSE1 up */\n  /* a &= (0x7f<<14)|(0x7f); */\n  b &= SLOT_2_0;\n  s = a;\n  /* s: p0<<14 | p2 (masked) */\n\n  p++;\n  a = a<<14;\n  a |= *p;\n  /* a: p0<<28 | p2<<14 | p4 (unmasked) */\n  if (!(a&0x80))\n  {\n    /* we can skip these cause they were (effectively) done above\n    ** while calculating s */\n    /* a &= (0x7f<<28)|(0x7f<<14)|(0x7f); */\n    /* b &= (0x7f<<14)|(0x7f); */\n    b = b<<7;\n    a |= b;\n    s = s>>18;\n    *v = ((u64)s)<<32 | a;\n    return 5;\n  }\n\n  /* 2:save off p0<<21 | p1<<14 | p2<<7 | p3 (masked) */\n  s = s<<7;\n  s |= b;\n  /* s: p0<<21 | p1<<14 | p2<<7 | p3 (masked) */\n\n  p++;\n  b = b<<14;\n  b |= *p;\n  /* b: p1<<28 | p3<<14 | p5 (unmasked) */\n  if (!(b&0x80))\n  {\n    /* we can skip this cause it was (effectively) done above in calc'ing s */\n    /* b &= (0x7f<<28)|(0x7f<<14)|(0x7f); */\n    a &= SLOT_2_0;\n    a = a<<7;\n    a |= b;\n    s = s>>18;\n    *v = ((u64)s)<<32 | a;\n    return 6;\n  }\n\n  p++;\n  a = a<<14;\n  a |= *p;\n  /* a: p2<<28 | p4<<14 | p6 (unmasked) */\n  if (!(a&0x80))\n  {\n    a &= SLOT_4_2_0;\n    b &= SLOT_2_0;\n    b = b<<7;\n    a |= b;\n    s = s>>11;\n    *v = ((u64)s)<<32 | a;\n    return 7;\n  }\n\n  /* CSE2 from below */\n  a &= SLOT_2_0;\n  p++;\n  b = b<<14;\n  b |= *p;\n  /* b: p3<<28 | p5<<14 | p7 (unmasked) */\n  if (!(b&0x80))\n  {\n    b &= SLOT_4_2_0;\n    /* moved CSE2 up */\n    /* a &= (0x7f<<14)|(0x7f); */\n    a = a<<7;\n    a |= b;\n    s = s>>4;\n    *v = ((u64)s)<<32 | a;\n    return 8;\n  }\n\n  p++;\n  a = a<<15;\n  a |= *p;\n  /* a: p4<<29 | p6<<15 | p8 (unmasked) */\n\n  /* moved CSE2 up */\n  /* a &= (0x7f<<29)|(0x7f<<15)|(0xff); */\n  b &= SLOT_2_0;\n  b = b<<8;\n  a |= b;\n\n  s = s<<4;\n  b = p[-4];\n  b &= 0x7f;\n  b = b>>3;\n  s |= b;\n\n  *v = ((u64)s)<<32 | a;\n\n  return 9;\n}\n\n/*\n** Read a 32-bit variable-length integer from memory starting at p[0].\n** Return the number of bytes read.  The value is stored in *v.\n**\n** If the varint stored in p[0] is larger than can fit in a 32-bit unsigned\n** integer, then set *v to 0xffffffff.\n**\n** A MACRO version, getVarint32, is provided which inlines the \n** single-byte case.  All code should use the MACRO version as \n** this function assumes the single-byte case has already been handled.\n*/\nSQLITE_PRIVATE u8 sqlite3GetVarint32(const unsigned char *p, u32 *v){\n  u32 a,b;\n\n  /* The 1-byte case.  Overwhelmingly the most common.  Handled inline\n  ** by the getVarin32() macro */\n  a = *p;\n  /* a: p0 (unmasked) */\n#ifndef getVarint32\n  if (!(a&0x80))\n  {\n    /* Values between 0 and 127 */\n    *v = a;\n    return 1;\n  }\n#endif\n\n  /* The 2-byte case */\n  p++;\n  b = *p;\n  /* b: p1 (unmasked) */\n  if (!(b&0x80))\n  {\n    /* Values between 128 and 16383 */\n    a &= 0x7f;\n    a = a<<7;\n    *v = a | b;\n    return 2;\n  }\n\n  /* The 3-byte case */\n  p++;\n  a = a<<14;\n  a |= *p;\n  /* a: p0<<14 | p2 (unmasked) */\n  if (!(a&0x80))\n  {\n    /* Values between 16384 and 2097151 */\n    a &= (0x7f<<14)|(0x7f);\n    b &= 0x7f;\n    b = b<<7;\n    *v = a | b;\n    return 3;\n  }\n\n  /* A 32-bit varint is used to store size information in btrees.\n  ** Objects are rarely larger than 2MiB limit of a 3-byte varint.\n  ** A 3-byte varint is sufficient, for example, to record the size\n  ** of a 1048569-byte BLOB or string.\n  **\n  ** We only unroll the first 1-, 2-, and 3- byte cases.  The very\n  ** rare larger cases can be handled by the slower 64-bit varint\n  ** routine.\n  */\n#if 1\n  {\n    u64 v64;\n    u8 n;\n\n    p -= 2;\n    n = sqlite3GetVarint(p, &v64);\n    assert( n>3 && n<=9 );\n    if( (v64 & SQLITE_MAX_U32)!=v64 ){\n      *v = 0xffffffff;\n    }else{\n      *v = (u32)v64;\n    }\n    return n;\n  }\n\n#else\n  /* For following code (kept for historical record only) shows an\n  ** unrolling for the 3- and 4-byte varint cases.  This code is\n  ** slightly faster, but it is also larger and much harder to test.\n  */\n  p++;\n  b = b<<14;\n  b |= *p;\n  /* b: p1<<14 | p3 (unmasked) */\n  if (!(b&0x80))\n  {\n    /* Values between 2097152 and 268435455 */\n    b &= (0x7f<<14)|(0x7f);\n    a &= (0x7f<<14)|(0x7f);\n    a = a<<7;\n    *v = a | b;\n    return 4;\n  }\n\n  p++;\n  a = a<<14;\n  a |= *p;\n  /* a: p0<<28 | p2<<14 | p4 (unmasked) */\n  if (!(a&0x80))\n  {\n    /* Values  between 268435456 and 34359738367 */\n    a &= SLOT_4_2_0;\n    b &= SLOT_4_2_0;\n    b = b<<7;\n    *v = a | b;\n    return 5;\n  }\n\n  /* We can only reach this point when reading a corrupt database\n  ** file.  In that case we are not in any hurry.  Use the (relatively\n  ** slow) general-purpose sqlite3GetVarint() routine to extract the\n  ** value. */\n  {\n    u64 v64;\n    u8 n;\n\n    p -= 4;\n    n = sqlite3GetVarint(p, &v64);\n    assert( n>5 && n<=9 );\n    *v = (u32)v64;\n    return n;\n  }\n#endif\n}\n\n/*\n** Return the number of bytes that will be needed to store the given\n** 64-bit integer.\n*/\nSQLITE_PRIVATE int sqlite3VarintLen(u64 v){\n  int i;\n  for(i=1; (v >>= 7)!=0; i++){ assert( i<10 ); }\n  return i;\n}\n\n\n/*\n** Read or write a four-byte big-endian integer value.\n*/\nSQLITE_PRIVATE u32 sqlite3Get4byte(const u8 *p){\n#if SQLITE_BYTEORDER==4321\n  u32 x;\n  memcpy(&x,p,4);\n  return x;\n#elif SQLITE_BYTEORDER==1234 && GCC_VERSION>=4003000\n  u32 x;\n  memcpy(&x,p,4);\n  return __builtin_bswap32(x);\n#elif SQLITE_BYTEORDER==1234 && MSVC_VERSION>=1300\n  u32 x;\n  memcpy(&x,p,4);\n  return _byteswap_ulong(x);\n#else\n  testcase( p[0]&0x80 );\n  return ((unsigned)p[0]<<24) | (p[1]<<16) | (p[2]<<8) | p[3];\n#endif\n}\nSQLITE_PRIVATE void sqlite3Put4byte(unsigned char *p, u32 v){\n#if SQLITE_BYTEORDER==4321\n  memcpy(p,&v,4);\n#elif SQLITE_BYTEORDER==1234 && GCC_VERSION>=4003000\n  u32 x = __builtin_bswap32(v);\n  memcpy(p,&x,4);\n#elif SQLITE_BYTEORDER==1234 && MSVC_VERSION>=1300\n  u32 x = _byteswap_ulong(v);\n  memcpy(p,&x,4);\n#else\n  p[0] = (u8)(v>>24);\n  p[1] = (u8)(v>>16);\n  p[2] = (u8)(v>>8);\n  p[3] = (u8)v;\n#endif\n}\n\n\n\n/*\n** Translate a single byte of Hex into an integer.\n** This routine only works if h really is a valid hexadecimal\n** character:  0..9a..fA..F\n*/\nSQLITE_PRIVATE u8 sqlite3HexToInt(int h){\n  assert( (h>='0' && h<='9') ||  (h>='a' && h<='f') ||  (h>='A' && h<='F') );\n#ifdef SQLITE_ASCII\n  h += 9*(1&(h>>6));\n#endif\n#ifdef SQLITE_EBCDIC\n  h += 9*(1&~(h>>4));\n#endif\n  return (u8)(h & 0xf);\n}\n\n#if !defined(SQLITE_OMIT_BLOB_LITERAL) || defined(SQLITE_HAS_CODEC)\n/*\n** Convert a BLOB literal of the form \"x'hhhhhh'\" into its binary\n** value.  Return a pointer to its binary value.  Space to hold the\n** binary value has been obtained from malloc and must be freed by\n** the calling routine.\n*/\nSQLITE_PRIVATE void *sqlite3HexToBlob(sqlite3 *db, const char *z, int n){\n  char *zBlob;\n  int i;\n\n  zBlob = (char *)sqlite3DbMallocRawNN(db, n/2 + 1);\n  n--;\n  if( zBlob ){\n    for(i=0; i<n; i+=2){\n      zBlob[i/2] = (sqlite3HexToInt(z[i])<<4) | sqlite3HexToInt(z[i+1]);\n    }\n    zBlob[i/2] = 0;\n  }\n  return zBlob;\n}\n#endif /* !SQLITE_OMIT_BLOB_LITERAL || SQLITE_HAS_CODEC */\n\n/*\n** Log an error that is an API call on a connection pointer that should\n** not have been used.  The \"type\" of connection pointer is given as the\n** argument.  The zType is a word like \"NULL\" or \"closed\" or \"invalid\".\n*/\nstatic void logBadConnection(const char *zType){\n  sqlite3_log(SQLITE_MISUSE, \n     \"API call with %s database connection pointer\",\n     zType\n  );\n}\n\n/*\n** Check to make sure we have a valid db pointer.  This test is not\n** foolproof but it does provide some measure of protection against\n** misuse of the interface such as passing in db pointers that are\n** NULL or which have been previously closed.  If this routine returns\n** 1 it means that the db pointer is valid and 0 if it should not be\n** dereferenced for any reason.  The calling function should invoke\n** SQLITE_MISUSE immediately.\n**\n** sqlite3SafetyCheckOk() requires that the db pointer be valid for\n** use.  sqlite3SafetyCheckSickOrOk() allows a db pointer that failed to\n** open properly and is not fit for general use but which can be\n** used as an argument to sqlite3_errmsg() or sqlite3_close().\n*/\nSQLITE_PRIVATE int sqlite3SafetyCheckOk(sqlite3 *db){\n  u32 magic;\n  if( db==0 ){\n    logBadConnection(\"NULL\");\n    return 0;\n  }\n  magic = db->magic;\n  if( magic!=SQLITE_MAGIC_OPEN ){\n    if( sqlite3SafetyCheckSickOrOk(db) ){\n      testcase( sqlite3GlobalConfig.xLog!=0 );\n      logBadConnection(\"unopened\");\n    }\n    return 0;\n  }else{\n    return 1;\n  }\n}\nSQLITE_PRIVATE int sqlite3SafetyCheckSickOrOk(sqlite3 *db){\n  u32 magic;\n  magic = db->magic;\n  if( magic!=SQLITE_MAGIC_SICK &&\n      magic!=SQLITE_MAGIC_OPEN &&\n      magic!=SQLITE_MAGIC_BUSY ){\n    testcase( sqlite3GlobalConfig.xLog!=0 );\n    logBadConnection(\"invalid\");\n    return 0;\n  }else{\n    return 1;\n  }\n}\n\n/*\n** Attempt to add, substract, or multiply the 64-bit signed value iB against\n** the other 64-bit signed integer at *pA and store the result in *pA.\n** Return 0 on success.  Or if the operation would have resulted in an\n** overflow, leave *pA unchanged and return 1.\n*/\nSQLITE_PRIVATE int sqlite3AddInt64(i64 *pA, i64 iB){\n#if GCC_VERSION>=5004000 && !defined(__INTEL_COMPILER)\n  return __builtin_add_overflow(*pA, iB, pA);\n#else\n  i64 iA = *pA;\n  testcase( iA==0 ); testcase( iA==1 );\n  testcase( iB==-1 ); testcase( iB==0 );\n  if( iB>=0 ){\n    testcase( iA>0 && LARGEST_INT64 - iA == iB );\n    testcase( iA>0 && LARGEST_INT64 - iA == iB - 1 );\n    if( iA>0 && LARGEST_INT64 - iA < iB ) return 1;\n  }else{\n    testcase( iA<0 && -(iA + LARGEST_INT64) == iB + 1 );\n    testcase( iA<0 && -(iA + LARGEST_INT64) == iB + 2 );\n    if( iA<0 && -(iA + LARGEST_INT64) > iB + 1 ) return 1;\n  }\n  *pA += iB;\n  return 0; \n#endif\n}\nSQLITE_PRIVATE int sqlite3SubInt64(i64 *pA, i64 iB){\n#if GCC_VERSION>=5004000 && !defined(__INTEL_COMPILER)\n  return __builtin_sub_overflow(*pA, iB, pA);\n#else\n  testcase( iB==SMALLEST_INT64+1 );\n  if( iB==SMALLEST_INT64 ){\n    testcase( (*pA)==(-1) ); testcase( (*pA)==0 );\n    if( (*pA)>=0 ) return 1;\n    *pA -= iB;\n    return 0;\n  }else{\n    return sqlite3AddInt64(pA, -iB);\n  }\n#endif\n}\nSQLITE_PRIVATE int sqlite3MulInt64(i64 *pA, i64 iB){\n#if GCC_VERSION>=5004000 && !defined(__INTEL_COMPILER)\n  return __builtin_mul_overflow(*pA, iB, pA);\n#else\n  i64 iA = *pA;\n  if( iB>0 ){\n    if( iA>LARGEST_INT64/iB ) return 1;\n    if( iA<SMALLEST_INT64/iB ) return 1;\n  }else if( iB<0 ){\n    if( iA>0 ){\n      if( iB<SMALLEST_INT64/iA ) return 1;\n    }else if( iA<0 ){\n      if( iB==SMALLEST_INT64 ) return 1;\n      if( iA==SMALLEST_INT64 ) return 1;\n      if( -iA>LARGEST_INT64/-iB ) return 1;\n    }\n  }\n  *pA = iA*iB;\n  return 0;\n#endif\n}\n\n/*\n** Compute the absolute value of a 32-bit signed integer, of possible.  Or \n** if the integer has a value of -2147483648, return +2147483647\n*/\nSQLITE_PRIVATE int sqlite3AbsInt32(int x){\n  if( x>=0 ) return x;\n  if( x==(int)0x80000000 ) return 0x7fffffff;\n  return -x;\n}\n\n#ifdef SQLITE_ENABLE_8_3_NAMES\n/*\n** If SQLITE_ENABLE_8_3_NAMES is set at compile-time and if the database\n** filename in zBaseFilename is a URI with the \"8_3_names=1\" parameter and\n** if filename in z[] has a suffix (a.k.a. \"extension\") that is longer than\n** three characters, then shorten the suffix on z[] to be the last three\n** characters of the original suffix.\n**\n** If SQLITE_ENABLE_8_3_NAMES is set to 2 at compile-time, then always\n** do the suffix shortening regardless of URI parameter.\n**\n** Examples:\n**\n**     test.db-journal    =>   test.nal\n**     test.db-wal        =>   test.wal\n**     test.db-shm        =>   test.shm\n**     test.db-mj7f3319fa =>   test.9fa\n*/\nSQLITE_PRIVATE void sqlite3FileSuffix3(const char *zBaseFilename, char *z){\n#if SQLITE_ENABLE_8_3_NAMES<2\n  if( sqlite3_uri_boolean(zBaseFilename, \"8_3_names\", 0) )\n#endif\n  {\n    int i, sz;\n    sz = sqlite3Strlen30(z);\n    for(i=sz-1; i>0 && z[i]!='/' && z[i]!='.'; i--){}\n    if( z[i]=='.' && ALWAYS(sz>i+4) ) memmove(&z[i+1], &z[sz-3], 4);\n  }\n}\n#endif\n\n/* \n** Find (an approximate) sum of two LogEst values.  This computation is\n** not a simple \"+\" operator because LogEst is stored as a logarithmic\n** value.\n** \n*/\nSQLITE_PRIVATE LogEst sqlite3LogEstAdd(LogEst a, LogEst b){\n  static const unsigned char x[] = {\n     10, 10,                         /* 0,1 */\n      9, 9,                          /* 2,3 */\n      8, 8,                          /* 4,5 */\n      7, 7, 7,                       /* 6,7,8 */\n      6, 6, 6,                       /* 9,10,11 */\n      5, 5, 5,                       /* 12-14 */\n      4, 4, 4, 4,                    /* 15-18 */\n      3, 3, 3, 3, 3, 3,              /* 19-24 */\n      2, 2, 2, 2, 2, 2, 2,           /* 25-31 */\n  };\n  if( a>=b ){\n    if( a>b+49 ) return a;\n    if( a>b+31 ) return a+1;\n    return a+x[a-b];\n  }else{\n    if( b>a+49 ) return b;\n    if( b>a+31 ) return b+1;\n    return b+x[b-a];\n  }\n}\n\n/*\n** Convert an integer into a LogEst.  In other words, compute an\n** approximation for 10*log2(x).\n*/\nSQLITE_PRIVATE LogEst sqlite3LogEst(u64 x){\n  static LogEst a[] = { 0, 2, 3, 5, 6, 7, 8, 9 };\n  LogEst y = 40;\n  if( x<8 ){\n    if( x<2 ) return 0;\n    while( x<8 ){  y -= 10; x <<= 1; }\n  }else{\n#if GCC_VERSION>=5004000\n    int i = 60 - __builtin_clzll(x);\n    y += i*10;\n    x >>= i;\n#else\n    while( x>255 ){ y += 40; x >>= 4; }  /*OPTIMIZATION-IF-TRUE*/\n    while( x>15 ){  y += 10; x >>= 1; }\n#endif\n  }\n  return a[x&7] + y - 10;\n}\n\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n/*\n** Convert a double into a LogEst\n** In other words, compute an approximation for 10*log2(x).\n*/\nSQLITE_PRIVATE LogEst sqlite3LogEstFromDouble(double x){\n  u64 a;\n  LogEst e;\n  assert( sizeof(x)==8 && sizeof(a)==8 );\n  if( x<=1 ) return 0;\n  if( x<=2000000000 ) return sqlite3LogEst((u64)x);\n  memcpy(&a, &x, 8);\n  e = (a>>52) - 1022;\n  return e*10;\n}\n#endif /* SQLITE_OMIT_VIRTUALTABLE */\n\n#if defined(SQLITE_ENABLE_STMT_SCANSTATUS) || \\\n    defined(SQLITE_ENABLE_STAT3_OR_STAT4) || \\\n    defined(SQLITE_EXPLAIN_ESTIMATED_ROWS)\n/*\n** Convert a LogEst into an integer.\n**\n** Note that this routine is only used when one or more of various\n** non-standard compile-time options is enabled.\n*/\nSQLITE_PRIVATE u64 sqlite3LogEstToInt(LogEst x){\n  u64 n;\n  n = x%10;\n  x /= 10;\n  if( n>=5 ) n -= 2;\n  else if( n>=1 ) n -= 1;\n#if defined(SQLITE_ENABLE_STMT_SCANSTATUS) || \\\n    defined(SQLITE_EXPLAIN_ESTIMATED_ROWS)\n  if( x>60 ) return (u64)LARGEST_INT64;\n#else\n  /* If only SQLITE_ENABLE_STAT3_OR_STAT4 is on, then the largest input\n  ** possible to this routine is 310, resulting in a maximum x of 31 */\n  assert( x<=60 );\n#endif\n  return x>=3 ? (n+8)<<(x-3) : (n+8)>>(3-x);\n}\n#endif /* defined SCANSTAT or STAT4 or ESTIMATED_ROWS */\n\n/*\n** Add a new name/number pair to a VList.  This might require that the\n** VList object be reallocated, so return the new VList.  If an OOM\n** error occurs, the original VList returned and the\n** db->mallocFailed flag is set.\n**\n** A VList is really just an array of integers.  To destroy a VList,\n** simply pass it to sqlite3DbFree().\n**\n** The first integer is the number of integers allocated for the whole\n** VList.  The second integer is the number of integers actually used.\n** Each name/number pair is encoded by subsequent groups of 3 or more\n** integers.\n**\n** Each name/number pair starts with two integers which are the numeric\n** value for the pair and the size of the name/number pair, respectively.\n** The text name overlays one or more following integers.  The text name\n** is always zero-terminated.\n**\n** Conceptually:\n**\n**    struct VList {\n**      int nAlloc;   // Number of allocated slots \n**      int nUsed;    // Number of used slots \n**      struct VListEntry {\n**        int iValue;    // Value for this entry\n**        int nSlot;     // Slots used by this entry\n**        // ... variable name goes here\n**      } a[0];\n**    }\n**\n** During code generation, pointers to the variable names within the\n** VList are taken.  When that happens, nAlloc is set to zero as an \n** indication that the VList may never again be enlarged, since the\n** accompanying realloc() would invalidate the pointers.\n*/\nSQLITE_PRIVATE VList *sqlite3VListAdd(\n  sqlite3 *db,           /* The database connection used for malloc() */\n  VList *pIn,            /* The input VList.  Might be NULL */\n  const char *zName,     /* Name of symbol to add */\n  int nName,             /* Bytes of text in zName */\n  int iVal               /* Value to associate with zName */\n){\n  int nInt;              /* number of sizeof(int) objects needed for zName */\n  char *z;               /* Pointer to where zName will be stored */\n  int i;                 /* Index in pIn[] where zName is stored */\n\n  nInt = nName/4 + 3;\n  assert( pIn==0 || pIn[0]>=3 );  /* Verify ok to add new elements */\n  if( pIn==0 || pIn[1]+nInt > pIn[0] ){\n    /* Enlarge the allocation */\n    int nAlloc = (pIn ? pIn[0]*2 : 10) + nInt;\n    VList *pOut = sqlite3DbRealloc(db, pIn, nAlloc*sizeof(int));\n    if( pOut==0 ) return pIn;\n    if( pIn==0 ) pOut[1] = 2;\n    pIn = pOut;\n    pIn[0] = nAlloc;\n  }\n  i = pIn[1];\n  pIn[i] = iVal;\n  pIn[i+1] = nInt;\n  z = (char*)&pIn[i+2];\n  pIn[1] = i+nInt;\n  assert( pIn[1]<=pIn[0] );\n  memcpy(z, zName, nName);\n  z[nName] = 0;\n  return pIn;\n}\n\n/*\n** Return a pointer to the name of a variable in the given VList that\n** has the value iVal.  Or return a NULL if there is no such variable in\n** the list\n*/\nSQLITE_PRIVATE const char *sqlite3VListNumToName(VList *pIn, int iVal){\n  int i, mx;\n  if( pIn==0 ) return 0;\n  mx = pIn[1];\n  i = 2;\n  do{\n    if( pIn[i]==iVal ) return (char*)&pIn[i+2];\n    i += pIn[i+1];\n  }while( i<mx );\n  return 0;\n}\n\n/*\n** Return the number of the variable named zName, if it is in VList.\n** or return 0 if there is no such variable.\n*/\nSQLITE_PRIVATE int sqlite3VListNameToNum(VList *pIn, const char *zName, int nName){\n  int i, mx;\n  if( pIn==0 ) return 0;\n  mx = pIn[1];\n  i = 2;\n  do{\n    const char *z = (const char*)&pIn[i+2];\n    if( strncmp(z,zName,nName)==0 && z[nName]==0 ) return pIn[i];\n    i += pIn[i+1];\n  }while( i<mx );\n  return 0;\n}\n\n/************** End of util.c ************************************************/\n/************** Begin file hash.c ********************************************/\n/*\n** 2001 September 22\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This is the implementation of generic hash-tables\n** used in SQLite.\n*/\n/* #include \"sqliteInt.h\" */\n/* #include <assert.h> */\n\n/* Turn bulk memory into a hash table object by initializing the\n** fields of the Hash structure.\n**\n** \"pNew\" is a pointer to the hash table that is to be initialized.\n*/\nSQLITE_PRIVATE void sqlite3HashInit(Hash *pNew){\n  assert( pNew!=0 );\n  pNew->first = 0;\n  pNew->count = 0;\n  pNew->htsize = 0;\n  pNew->ht = 0;\n}\n\n/* Remove all entries from a hash table.  Reclaim all memory.\n** Call this routine to delete a hash table or to reset a hash table\n** to the empty state.\n*/\nSQLITE_PRIVATE void sqlite3HashClear(Hash *pH){\n  HashElem *elem;         /* For looping over all elements of the table */\n\n  assert( pH!=0 );\n  elem = pH->first;\n  pH->first = 0;\n  sqlite3_free(pH->ht);\n  pH->ht = 0;\n  pH->htsize = 0;\n  while( elem ){\n    HashElem *next_elem = elem->next;\n    sqlite3_free(elem);\n    elem = next_elem;\n  }\n  pH->count = 0;\n}\n\n/*\n** The hashing function.\n*/\nstatic unsigned int strHash(const char *z){\n  unsigned int h = 0;\n  unsigned char c;\n  while( (c = (unsigned char)*z++)!=0 ){     /*OPTIMIZATION-IF-TRUE*/\n    /* Knuth multiplicative hashing.  (Sorting & Searching, p. 510).\n    ** 0x9e3779b1 is 2654435761 which is the closest prime number to\n    ** (2**32)*golden_ratio, where golden_ratio = (sqrt(5) - 1)/2. */\n    h += sqlite3UpperToLower[c];\n    h *= 0x9e3779b1;\n  }\n  return h;\n}\n\n\n/* Link pNew element into the hash table pH.  If pEntry!=0 then also\n** insert pNew into the pEntry hash bucket.\n*/\nstatic void insertElement(\n  Hash *pH,              /* The complete hash table */\n  struct _ht *pEntry,    /* The entry into which pNew is inserted */\n  HashElem *pNew         /* The element to be inserted */\n){\n  HashElem *pHead;       /* First element already in pEntry */\n  if( pEntry ){\n    pHead = pEntry->count ? pEntry->chain : 0;\n    pEntry->count++;\n    pEntry->chain = pNew;\n  }else{\n    pHead = 0;\n  }\n  if( pHead ){\n    pNew->next = pHead;\n    pNew->prev = pHead->prev;\n    if( pHead->prev ){ pHead->prev->next = pNew; }\n    else             { pH->first = pNew; }\n    pHead->prev = pNew;\n  }else{\n    pNew->next = pH->first;\n    if( pH->first ){ pH->first->prev = pNew; }\n    pNew->prev = 0;\n    pH->first = pNew;\n  }\n}\n\n\n/* Resize the hash table so that it cantains \"new_size\" buckets.\n**\n** The hash table might fail to resize if sqlite3_malloc() fails or\n** if the new size is the same as the prior size.\n** Return TRUE if the resize occurs and false if not.\n*/\nstatic int rehash(Hash *pH, unsigned int new_size){\n  struct _ht *new_ht;            /* The new hash table */\n  HashElem *elem, *next_elem;    /* For looping over existing elements */\n\n#if SQLITE_MALLOC_SOFT_LIMIT>0\n  if( new_size*sizeof(struct _ht)>SQLITE_MALLOC_SOFT_LIMIT ){\n    new_size = SQLITE_MALLOC_SOFT_LIMIT/sizeof(struct _ht);\n  }\n  if( new_size==pH->htsize ) return 0;\n#endif\n\n  /* The inability to allocates space for a larger hash table is\n  ** a performance hit but it is not a fatal error.  So mark the\n  ** allocation as a benign. Use sqlite3Malloc()/memset(0) instead of \n  ** sqlite3MallocZero() to make the allocation, as sqlite3MallocZero()\n  ** only zeroes the requested number of bytes whereas this module will\n  ** use the actual amount of space allocated for the hash table (which\n  ** may be larger than the requested amount).\n  */\n  sqlite3BeginBenignMalloc();\n  new_ht = (struct _ht *)sqlite3Malloc( new_size*sizeof(struct _ht) );\n  sqlite3EndBenignMalloc();\n\n  if( new_ht==0 ) return 0;\n  sqlite3_free(pH->ht);\n  pH->ht = new_ht;\n  pH->htsize = new_size = sqlite3MallocSize(new_ht)/sizeof(struct _ht);\n  memset(new_ht, 0, new_size*sizeof(struct _ht));\n  for(elem=pH->first, pH->first=0; elem; elem = next_elem){\n    unsigned int h = strHash(elem->pKey) % new_size;\n    next_elem = elem->next;\n    insertElement(pH, &new_ht[h], elem);\n  }\n  return 1;\n}\n\n/* This function (for internal use only) locates an element in an\n** hash table that matches the given key.  If no element is found,\n** a pointer to a static null element with HashElem.data==0 is returned.\n** If pH is not NULL, then the hash for this key is written to *pH.\n*/\nstatic HashElem *findElementWithHash(\n  const Hash *pH,     /* The pH to be searched */\n  const char *pKey,   /* The key we are searching for */\n  unsigned int *pHash /* Write the hash value here */\n){\n  HashElem *elem;                /* Used to loop thru the element list */\n  int count;                     /* Number of elements left to test */\n  unsigned int h;                /* The computed hash */\n  static HashElem nullElement = { 0, 0, 0, 0 };\n\n  if( pH->ht ){   /*OPTIMIZATION-IF-TRUE*/\n    struct _ht *pEntry;\n    h = strHash(pKey) % pH->htsize;\n    pEntry = &pH->ht[h];\n    elem = pEntry->chain;\n    count = pEntry->count;\n  }else{\n    h = 0;\n    elem = pH->first;\n    count = pH->count;\n  }\n  if( pHash ) *pHash = h;\n  while( count-- ){\n    assert( elem!=0 );\n    if( sqlite3StrICmp(elem->pKey,pKey)==0 ){ \n      return elem;\n    }\n    elem = elem->next;\n  }\n  return &nullElement;\n}\n\n/* Remove a single entry from the hash table given a pointer to that\n** element and a hash on the element's key.\n*/\nstatic void removeElementGivenHash(\n  Hash *pH,         /* The pH containing \"elem\" */\n  HashElem* elem,   /* The element to be removed from the pH */\n  unsigned int h    /* Hash value for the element */\n){\n  struct _ht *pEntry;\n  if( elem->prev ){\n    elem->prev->next = elem->next; \n  }else{\n    pH->first = elem->next;\n  }\n  if( elem->next ){\n    elem->next->prev = elem->prev;\n  }\n  if( pH->ht ){\n    pEntry = &pH->ht[h];\n    if( pEntry->chain==elem ){\n      pEntry->chain = elem->next;\n    }\n    pEntry->count--;\n    assert( pEntry->count>=0 );\n  }\n  sqlite3_free( elem );\n  pH->count--;\n  if( pH->count==0 ){\n    assert( pH->first==0 );\n    assert( pH->count==0 );\n    sqlite3HashClear(pH);\n  }\n}\n\n/* Attempt to locate an element of the hash table pH with a key\n** that matches pKey.  Return the data for this element if it is\n** found, or NULL if there is no match.\n*/\nSQLITE_PRIVATE void *sqlite3HashFind(const Hash *pH, const char *pKey){\n  assert( pH!=0 );\n  assert( pKey!=0 );\n  return findElementWithHash(pH, pKey, 0)->data;\n}\n\n/* Insert an element into the hash table pH.  The key is pKey\n** and the data is \"data\".\n**\n** If no element exists with a matching key, then a new\n** element is created and NULL is returned.\n**\n** If another element already exists with the same key, then the\n** new data replaces the old data and the old data is returned.\n** The key is not copied in this instance.  If a malloc fails, then\n** the new data is returned and the hash table is unchanged.\n**\n** If the \"data\" parameter to this function is NULL, then the\n** element corresponding to \"key\" is removed from the hash table.\n*/\nSQLITE_PRIVATE void *sqlite3HashInsert(Hash *pH, const char *pKey, void *data){\n  unsigned int h;       /* the hash of the key modulo hash table size */\n  HashElem *elem;       /* Used to loop thru the element list */\n  HashElem *new_elem;   /* New element added to the pH */\n\n  assert( pH!=0 );\n  assert( pKey!=0 );\n  elem = findElementWithHash(pH,pKey,&h);\n  if( elem->data ){\n    void *old_data = elem->data;\n    if( data==0 ){\n      removeElementGivenHash(pH,elem,h);\n    }else{\n      elem->data = data;\n      elem->pKey = pKey;\n    }\n    return old_data;\n  }\n  if( data==0 ) return 0;\n  new_elem = (HashElem*)sqlite3Malloc( sizeof(HashElem) );\n  if( new_elem==0 ) return data;\n  new_elem->pKey = pKey;\n  new_elem->data = data;\n  pH->count++;\n  if( pH->count>=10 && pH->count > 2*pH->htsize ){\n    if( rehash(pH, pH->count*2) ){\n      assert( pH->htsize>0 );\n      h = strHash(pKey) % pH->htsize;\n    }\n  }\n  insertElement(pH, pH->ht ? &pH->ht[h] : 0, new_elem);\n  return 0;\n}\n\n/************** End of hash.c ************************************************/\n/************** Begin file opcodes.c *****************************************/\n/* Automatically generated.  Do not edit */\n/* See the tool/mkopcodec.tcl script for details. */\n#if !defined(SQLITE_OMIT_EXPLAIN) \\\n || defined(VDBE_PROFILE) \\\n || defined(SQLITE_DEBUG)\n#if defined(SQLITE_ENABLE_EXPLAIN_COMMENTS) || defined(SQLITE_DEBUG)\n# define OpHelp(X) \"\\0\" X\n#else\n# define OpHelp(X)\n#endif\nSQLITE_PRIVATE const char *sqlite3OpcodeName(int i){\n static const char *const azName[] = {\n    /*   0 */ \"Savepoint\"        OpHelp(\"\"),\n    /*   1 */ \"AutoCommit\"       OpHelp(\"\"),\n    /*   2 */ \"Transaction\"      OpHelp(\"\"),\n    /*   3 */ \"SorterNext\"       OpHelp(\"\"),\n    /*   4 */ \"Prev\"             OpHelp(\"\"),\n    /*   5 */ \"Next\"             OpHelp(\"\"),\n    /*   6 */ \"Checkpoint\"       OpHelp(\"\"),\n    /*   7 */ \"JournalMode\"      OpHelp(\"\"),\n    /*   8 */ \"Vacuum\"           OpHelp(\"\"),\n    /*   9 */ \"VFilter\"          OpHelp(\"iplan=r[P3] zplan='P4'\"),\n    /*  10 */ \"VUpdate\"          OpHelp(\"data=r[P3@P2]\"),\n    /*  11 */ \"Goto\"             OpHelp(\"\"),\n    /*  12 */ \"Gosub\"            OpHelp(\"\"),\n    /*  13 */ \"InitCoroutine\"    OpHelp(\"\"),\n    /*  14 */ \"Yield\"            OpHelp(\"\"),\n    /*  15 */ \"MustBeInt\"        OpHelp(\"\"),\n    /*  16 */ \"Jump\"             OpHelp(\"\"),\n    /*  17 */ \"Once\"             OpHelp(\"\"),\n    /*  18 */ \"If\"               OpHelp(\"\"),\n    /*  19 */ \"Not\"              OpHelp(\"r[P2]= !r[P1]\"),\n    /*  20 */ \"IfNot\"            OpHelp(\"\"),\n    /*  21 */ \"IfNullRow\"        OpHelp(\"if P1.nullRow then r[P3]=NULL, goto P2\"),\n    /*  22 */ \"SeekLT\"           OpHelp(\"key=r[P3@P4]\"),\n    /*  23 */ \"SeekLE\"           OpHelp(\"key=r[P3@P4]\"),\n    /*  24 */ \"SeekGE\"           OpHelp(\"key=r[P3@P4]\"),\n    /*  25 */ \"SeekGT\"           OpHelp(\"key=r[P3@P4]\"),\n    /*  26 */ \"IfNoHope\"         OpHelp(\"key=r[P3@P4]\"),\n    /*  27 */ \"NoConflict\"       OpHelp(\"key=r[P3@P4]\"),\n    /*  28 */ \"NotFound\"         OpHelp(\"key=r[P3@P4]\"),\n    /*  29 */ \"Found\"            OpHelp(\"key=r[P3@P4]\"),\n    /*  30 */ \"SeekRowid\"        OpHelp(\"intkey=r[P3]\"),\n    /*  31 */ \"NotExists\"        OpHelp(\"intkey=r[P3]\"),\n    /*  32 */ \"Last\"             OpHelp(\"\"),\n    /*  33 */ \"IfSmaller\"        OpHelp(\"\"),\n    /*  34 */ \"SorterSort\"       OpHelp(\"\"),\n    /*  35 */ \"Sort\"             OpHelp(\"\"),\n    /*  36 */ \"Rewind\"           OpHelp(\"\"),\n    /*  37 */ \"IdxLE\"            OpHelp(\"key=r[P3@P4]\"),\n    /*  38 */ \"IdxGT\"            OpHelp(\"key=r[P3@P4]\"),\n    /*  39 */ \"IdxLT\"            OpHelp(\"key=r[P3@P4]\"),\n    /*  40 */ \"IdxGE\"            OpHelp(\"key=r[P3@P4]\"),\n    /*  41 */ \"RowSetRead\"       OpHelp(\"r[P3]=rowset(P1)\"),\n    /*  42 */ \"RowSetTest\"       OpHelp(\"if r[P3] in rowset(P1) goto P2\"),\n    /*  43 */ \"Or\"               OpHelp(\"r[P3]=(r[P1] || r[P2])\"),\n    /*  44 */ \"And\"              OpHelp(\"r[P3]=(r[P1] && r[P2])\"),\n    /*  45 */ \"Program\"          OpHelp(\"\"),\n    /*  46 */ \"FkIfZero\"         OpHelp(\"if fkctr[P1]==0 goto P2\"),\n    /*  47 */ \"IfPos\"            OpHelp(\"if r[P1]>0 then r[P1]-=P3, goto P2\"),\n    /*  48 */ \"IfNotZero\"        OpHelp(\"if r[P1]!=0 then r[P1]--, goto P2\"),\n    /*  49 */ \"DecrJumpZero\"     OpHelp(\"if (--r[P1])==0 goto P2\"),\n    /*  50 */ \"IsNull\"           OpHelp(\"if r[P1]==NULL goto P2\"),\n    /*  51 */ \"NotNull\"          OpHelp(\"if r[P1]!=NULL goto P2\"),\n    /*  52 */ \"Ne\"               OpHelp(\"IF r[P3]!=r[P1]\"),\n    /*  53 */ \"Eq\"               OpHelp(\"IF r[P3]==r[P1]\"),\n    /*  54 */ \"Gt\"               OpHelp(\"IF r[P3]>r[P1]\"),\n    /*  55 */ \"Le\"               OpHelp(\"IF r[P3]<=r[P1]\"),\n    /*  56 */ \"Lt\"               OpHelp(\"IF r[P3]<r[P1]\"),\n    /*  57 */ \"Ge\"               OpHelp(\"IF r[P3]>=r[P1]\"),\n    /*  58 */ \"ElseNotEq\"        OpHelp(\"\"),\n    /*  59 */ \"IncrVacuum\"       OpHelp(\"\"),\n    /*  60 */ \"VNext\"            OpHelp(\"\"),\n    /*  61 */ \"Init\"             OpHelp(\"Start at P2\"),\n    /*  62 */ \"PureFunc0\"        OpHelp(\"\"),\n    /*  63 */ \"Function0\"        OpHelp(\"r[P3]=func(r[P2@P5])\"),\n    /*  64 */ \"PureFunc\"         OpHelp(\"\"),\n    /*  65 */ \"Function\"         OpHelp(\"r[P3]=func(r[P2@P5])\"),\n    /*  66 */ \"Return\"           OpHelp(\"\"),\n    /*  67 */ \"EndCoroutine\"     OpHelp(\"\"),\n    /*  68 */ \"HaltIfNull\"       OpHelp(\"if r[P3]=null halt\"),\n    /*  69 */ \"Halt\"             OpHelp(\"\"),\n    /*  70 */ \"Integer\"          OpHelp(\"r[P2]=P1\"),\n    /*  71 */ \"Int64\"            OpHelp(\"r[P2]=P4\"),\n    /*  72 */ \"String\"           OpHelp(\"r[P2]='P4' (len=P1)\"),\n    /*  73 */ \"Null\"             OpHelp(\"r[P2..P3]=NULL\"),\n    /*  74 */ \"SoftNull\"         OpHelp(\"r[P1]=NULL\"),\n    /*  75 */ \"Blob\"             OpHelp(\"r[P2]=P4 (len=P1)\"),\n    /*  76 */ \"Variable\"         OpHelp(\"r[P2]=parameter(P1,P4)\"),\n    /*  77 */ \"Move\"             OpHelp(\"r[P2@P3]=r[P1@P3]\"),\n    /*  78 */ \"Copy\"             OpHelp(\"r[P2@P3+1]=r[P1@P3+1]\"),\n    /*  79 */ \"SCopy\"            OpHelp(\"r[P2]=r[P1]\"),\n    /*  80 */ \"IntCopy\"          OpHelp(\"r[P2]=r[P1]\"),\n    /*  81 */ \"ResultRow\"        OpHelp(\"output=r[P1@P2]\"),\n    /*  82 */ \"CollSeq\"          OpHelp(\"\"),\n    /*  83 */ \"AddImm\"           OpHelp(\"r[P1]=r[P1]+P2\"),\n    /*  84 */ \"RealAffinity\"     OpHelp(\"\"),\n    /*  85 */ \"Cast\"             OpHelp(\"affinity(r[P1])\"),\n    /*  86 */ \"Permutation\"      OpHelp(\"\"),\n    /*  87 */ \"Compare\"          OpHelp(\"r[P1@P3] <-> r[P2@P3]\"),\n    /*  88 */ \"IsTrue\"           OpHelp(\"r[P2] = coalesce(r[P1]==TRUE,P3) ^ P4\"),\n    /*  89 */ \"Offset\"           OpHelp(\"r[P3] = sqlite_offset(P1)\"),\n    /*  90 */ \"Column\"           OpHelp(\"r[P3]=PX\"),\n    /*  91 */ \"Affinity\"         OpHelp(\"affinity(r[P1@P2])\"),\n    /*  92 */ \"BitAnd\"           OpHelp(\"r[P3]=r[P1]&r[P2]\"),\n    /*  93 */ \"BitOr\"            OpHelp(\"r[P3]=r[P1]|r[P2]\"),\n    /*  94 */ \"ShiftLeft\"        OpHelp(\"r[P3]=r[P2]<<r[P1]\"),\n    /*  95 */ \"ShiftRight\"       OpHelp(\"r[P3]=r[P2]>>r[P1]\"),\n    /*  96 */ \"Add\"              OpHelp(\"r[P3]=r[P1]+r[P2]\"),\n    /*  97 */ \"Subtract\"         OpHelp(\"r[P3]=r[P2]-r[P1]\"),\n    /*  98 */ \"Multiply\"         OpHelp(\"r[P3]=r[P1]*r[P2]\"),\n    /*  99 */ \"Divide\"           OpHelp(\"r[P3]=r[P2]/r[P1]\"),\n    /* 100 */ \"Remainder\"        OpHelp(\"r[P3]=r[P2]%r[P1]\"),\n    /* 101 */ \"Concat\"           OpHelp(\"r[P3]=r[P2]+r[P1]\"),\n    /* 102 */ \"MakeRecord\"       OpHelp(\"r[P3]=mkrec(r[P1@P2])\"),\n    /* 103 */ \"BitNot\"           OpHelp(\"r[P2]= ~r[P1]\"),\n    /* 104 */ \"Count\"            OpHelp(\"r[P2]=count()\"),\n    /* 105 */ \"ReadCookie\"       OpHelp(\"\"),\n    /* 106 */ \"String8\"          OpHelp(\"r[P2]='P4'\"),\n    /* 107 */ \"SetCookie\"        OpHelp(\"\"),\n    /* 108 */ \"ReopenIdx\"        OpHelp(\"root=P2 iDb=P3\"),\n    /* 109 */ \"OpenRead\"         OpHelp(\"root=P2 iDb=P3\"),\n    /* 110 */ \"OpenWrite\"        OpHelp(\"root=P2 iDb=P3\"),\n    /* 111 */ \"OpenDup\"          OpHelp(\"\"),\n    /* 112 */ \"OpenAutoindex\"    OpHelp(\"nColumn=P2\"),\n    /* 113 */ \"OpenEphemeral\"    OpHelp(\"nColumn=P2\"),\n    /* 114 */ \"SorterOpen\"       OpHelp(\"\"),\n    /* 115 */ \"SequenceTest\"     OpHelp(\"if( cursor[P1].ctr++ ) pc = P2\"),\n    /* 116 */ \"OpenPseudo\"       OpHelp(\"P3 columns in r[P2]\"),\n    /* 117 */ \"Close\"            OpHelp(\"\"),\n    /* 118 */ \"ColumnsUsed\"      OpHelp(\"\"),\n    /* 119 */ \"SeekHit\"          OpHelp(\"seekHit=P2\"),\n    /* 120 */ \"Sequence\"         OpHelp(\"r[P2]=cursor[P1].ctr++\"),\n    /* 121 */ \"NewRowid\"         OpHelp(\"r[P2]=rowid\"),\n    /* 122 */ \"Insert\"           OpHelp(\"intkey=r[P3] data=r[P2]\"),\n    /* 123 */ \"Delete\"           OpHelp(\"\"),\n    /* 124 */ \"ResetCount\"       OpHelp(\"\"),\n    /* 125 */ \"SorterCompare\"    OpHelp(\"if key(P1)!=trim(r[P3],P4) goto P2\"),\n    /* 126 */ \"SorterData\"       OpHelp(\"r[P2]=data\"),\n    /* 127 */ \"RowData\"          OpHelp(\"r[P2]=data\"),\n    /* 128 */ \"Rowid\"            OpHelp(\"r[P2]=rowid\"),\n    /* 129 */ \"NullRow\"          OpHelp(\"\"),\n    /* 130 */ \"SeekEnd\"          OpHelp(\"\"),\n    /* 131 */ \"SorterInsert\"     OpHelp(\"key=r[P2]\"),\n    /* 132 */ \"IdxInsert\"        OpHelp(\"key=r[P2]\"),\n    /* 133 */ \"IdxDelete\"        OpHelp(\"key=r[P2@P3]\"),\n    /* 134 */ \"DeferredSeek\"     OpHelp(\"Move P3 to P1.rowid if needed\"),\n    /* 135 */ \"IdxRowid\"         OpHelp(\"r[P2]=rowid\"),\n    /* 136 */ \"Destroy\"          OpHelp(\"\"),\n    /* 137 */ \"Clear\"            OpHelp(\"\"),\n    /* 138 */ \"ResetSorter\"      OpHelp(\"\"),\n    /* 139 */ \"CreateBtree\"      OpHelp(\"r[P2]=root iDb=P1 flags=P3\"),\n    /* 140 */ \"SqlExec\"          OpHelp(\"\"),\n    /* 141 */ \"Real\"             OpHelp(\"r[P2]=P4\"),\n    /* 142 */ \"ParseSchema\"      OpHelp(\"\"),\n    /* 143 */ \"LoadAnalysis\"     OpHelp(\"\"),\n    /* 144 */ \"DropTable\"        OpHelp(\"\"),\n    /* 145 */ \"DropIndex\"        OpHelp(\"\"),\n    /* 146 */ \"DropTrigger\"      OpHelp(\"\"),\n    /* 147 */ \"IntegrityCk\"      OpHelp(\"\"),\n    /* 148 */ \"RowSetAdd\"        OpHelp(\"rowset(P1)=r[P2]\"),\n    /* 149 */ \"Param\"            OpHelp(\"\"),\n    /* 150 */ \"FkCounter\"        OpHelp(\"fkctr[P1]+=P2\"),\n    /* 151 */ \"MemMax\"           OpHelp(\"r[P1]=max(r[P1],r[P2])\"),\n    /* 152 */ \"OffsetLimit\"      OpHelp(\"if r[P1]>0 then r[P2]=r[P1]+max(0,r[P3]) else r[P2]=(-1)\"),\n    /* 153 */ \"AggInverse\"       OpHelp(\"accum=r[P3] inverse(r[P2@P5])\"),\n    /* 154 */ \"AggStep\"          OpHelp(\"accum=r[P3] step(r[P2@P5])\"),\n    /* 155 */ \"AggStep1\"         OpHelp(\"accum=r[P3] step(r[P2@P5])\"),\n    /* 156 */ \"AggValue\"         OpHelp(\"r[P3]=value N=P2\"),\n    /* 157 */ \"AggFinal\"         OpHelp(\"accum=r[P1] N=P2\"),\n    /* 158 */ \"Expire\"           OpHelp(\"\"),\n    /* 159 */ \"TableLock\"        OpHelp(\"iDb=P1 root=P2 write=P3\"),\n    /* 160 */ \"VBegin\"           OpHelp(\"\"),\n    /* 161 */ \"VCreate\"          OpHelp(\"\"),\n    /* 162 */ \"VDestroy\"         OpHelp(\"\"),\n    /* 163 */ \"VOpen\"            OpHelp(\"\"),\n    /* 164 */ \"VColumn\"          OpHelp(\"r[P3]=vcolumn(P2)\"),\n    /* 165 */ \"VRename\"          OpHelp(\"\"),\n    /* 166 */ \"Pagecount\"        OpHelp(\"\"),\n    /* 167 */ \"MaxPgcnt\"         OpHelp(\"\"),\n    /* 168 */ \"Trace\"            OpHelp(\"\"),\n    /* 169 */ \"CursorHint\"       OpHelp(\"\"),\n    /* 170 */ \"Noop\"             OpHelp(\"\"),\n    /* 171 */ \"Explain\"          OpHelp(\"\"),\n    /* 172 */ \"Abortable\"        OpHelp(\"\"),\n  };\n  return azName[i];\n}\n#endif\n\n/************** End of opcodes.c *********************************************/\n/************** Begin file os_unix.c *****************************************/\n/*\n** 2004 May 22\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n******************************************************************************\n**\n** This file contains the VFS implementation for unix-like operating systems\n** include Linux, MacOSX, *BSD, QNX, VxWorks, AIX, HPUX, and others.\n**\n** There are actually several different VFS implementations in this file.\n** The differences are in the way that file locking is done.  The default\n** implementation uses Posix Advisory Locks.  Alternative implementations\n** use flock(), dot-files, various proprietary locking schemas, or simply\n** skip locking all together.\n**\n** This source file is organized into divisions where the logic for various\n** subfunctions is contained within the appropriate division.  PLEASE\n** KEEP THE STRUCTURE OF THIS FILE INTACT.  New code should be placed\n** in the correct division and should be clearly labeled.\n**\n** The layout of divisions is as follows:\n**\n**   *  General-purpose declarations and utility functions.\n**   *  Unique file ID logic used by VxWorks.\n**   *  Various locking primitive implementations (all except proxy locking):\n**      + for Posix Advisory Locks\n**      + for no-op locks\n**      + for dot-file locks\n**      + for flock() locking\n**      + for named semaphore locks (VxWorks only)\n**      + for AFP filesystem locks (MacOSX only)\n**   *  sqlite3_file methods not associated with locking.\n**   *  Definitions of sqlite3_io_methods objects for all locking\n**      methods plus \"finder\" functions for each locking method.\n**   *  sqlite3_vfs method implementations.\n**   *  Locking primitives for the proxy uber-locking-method. (MacOSX only)\n**   *  Definitions of sqlite3_vfs objects for all locking methods\n**      plus implementations of sqlite3_os_init() and sqlite3_os_end().\n*/\n/* #include \"sqliteInt.h\" */\n#if SQLITE_OS_UNIX              /* This file is used on unix only */\n\n/*\n** There are various methods for file locking used for concurrency\n** control:\n**\n**   1. POSIX locking (the default),\n**   2. No locking,\n**   3. Dot-file locking,\n**   4. flock() locking,\n**   5. AFP locking (OSX only),\n**   6. Named POSIX semaphores (VXWorks only),\n**   7. proxy locking. (OSX only)\n**\n** Styles 4, 5, and 7 are only available of SQLITE_ENABLE_LOCKING_STYLE\n** is defined to 1.  The SQLITE_ENABLE_LOCKING_STYLE also enables automatic\n** selection of the appropriate locking style based on the filesystem\n** where the database is located.  \n*/\n#if !defined(SQLITE_ENABLE_LOCKING_STYLE)\n#  if defined(__APPLE__)\n#    define SQLITE_ENABLE_LOCKING_STYLE 1\n#  else\n#    define SQLITE_ENABLE_LOCKING_STYLE 0\n#  endif\n#endif\n\n/* Use pread() and pwrite() if they are available */\n#if defined(__APPLE__)\n# define HAVE_PREAD 1\n# define HAVE_PWRITE 1\n#endif\n#if defined(HAVE_PREAD64) && defined(HAVE_PWRITE64)\n# undef USE_PREAD\n# define USE_PREAD64 1\n#elif defined(HAVE_PREAD) && defined(HAVE_PWRITE)\n# undef USE_PREAD64\n# define USE_PREAD 1\n#endif\n\n/*\n** standard include files.\n*/\n#include <sys/types.h>\n#include <sys/stat.h>\n#include <fcntl.h>\n#include <sys/ioctl.h>\n/* #include <unistd.h> */\n/* #include <time.h> */\n#include <sys/time.h>\n/* #include <errno.h> */\n#if !defined(SQLITE_OMIT_WAL) || SQLITE_MAX_MMAP_SIZE>0\n/* # include <sys/mman.h> */\n#endif\n\n#if SQLITE_ENABLE_LOCKING_STYLE\n/* # include <sys/ioctl.h> */\n# include <sys/file.h>\n# include <sys/param.h>\n#endif /* SQLITE_ENABLE_LOCKING_STYLE */\n\n#if defined(__APPLE__) && ((__MAC_OS_X_VERSION_MIN_REQUIRED > 1050) || \\\n                           (__IPHONE_OS_VERSION_MIN_REQUIRED > 2000))\n#  if (!defined(TARGET_OS_EMBEDDED) || (TARGET_OS_EMBEDDED==0)) \\\n       && (!defined(TARGET_IPHONE_SIMULATOR) || (TARGET_IPHONE_SIMULATOR==0))\n#    define HAVE_GETHOSTUUID 1\n#  else\n#    if !TARGET_OS_IPHONE || TARGET_OS_WATCH\n#    warning \"gethostuuid() is disabled.\"\n#    endif\n#  endif\n#endif\n\n\n#if OS_VXWORKS\n/* # include <sys/ioctl.h> */\n# include <semaphore.h>\n# include <limits.h>\n#endif /* OS_VXWORKS */\n\n#if defined(__APPLE__) || SQLITE_ENABLE_LOCKING_STYLE\n# include <sys/mount.h>\n#endif\n\n#ifdef HAVE_UTIME\n# include <utime.h>\n#endif\n\n/*\n** Allowed values of unixFile.fsFlags\n*/\n#define SQLITE_FSFLAGS_IS_MSDOS     0x1\n\n/*\n** If we are to be thread-safe, include the pthreads header.\n*/\n#if SQLITE_THREADSAFE\n/* # include <pthread.h> */\n#endif\n\n/*\n** Default permissions when creating a new file\n*/\n#ifndef SQLITE_DEFAULT_FILE_PERMISSIONS\n# define SQLITE_DEFAULT_FILE_PERMISSIONS 0644\n#endif\n\n/*\n** Default permissions when creating auto proxy dir\n*/\n#ifndef SQLITE_DEFAULT_PROXYDIR_PERMISSIONS\n# define SQLITE_DEFAULT_PROXYDIR_PERMISSIONS 0755\n#endif\n\n/*\n** Maximum supported path-length.\n*/\n#define MAX_PATHNAME 512\n\n/*\n** Maximum supported symbolic links\n*/\n#define SQLITE_MAX_SYMLINKS 100\n\n/* Always cast the getpid() return type for compatibility with\n** kernel modules in VxWorks. */\n#define osGetpid(X) (pid_t)getpid()\n\n/*\n** Only set the lastErrno if the error code is a real error and not \n** a normal expected return code of SQLITE_BUSY or SQLITE_OK\n*/\n#define IS_LOCK_ERROR(x)  ((x != SQLITE_OK) && (x != SQLITE_BUSY))\n\n#ifdef SQLITE_WCDB_LOCK_HOOK\nstruct UnixLockHook {\n  void (*xWillLock)(void *parameter, const char* path, int lock);\n  void (*xLockDidChange)(void *parameter, const char* path, int lock);\n  void (*xWillShmLock)(void *parameter, const char* path, int flags, int mask);\n  void (*xShmLockDidChange)(void *parameter, const char* path, void* id, int sharedMask, int exclMask);\n  void *pArg;\n};\ntypedef struct UnixLockHook UnixLockHook;\n\nSQLITE_WSD static UnixLockHook unixLockHook = { 0 };\n#define unixLockHook GLOBAL(UnixLockHook *, unixLockHook)\n\nSQLITE_API int sqlite3_lock_hook(void (*xWillLock)(void *pArg, const char* zPath, int eLock),\n                      void (*xLockDidChange)(void *pArg, const char* zPath, int eLock),\n                      void (*xWillShmLock)(void *pArg, const char* zPath, int flags, int mask),\n                      void (*xShmLockDidChange)(void *pArg, const char* zPath, void* id, int sharedMask, int exclMask),\n                      void *pArg) {\n  if( sqlite3GlobalConfig.isInit ) return SQLITE_MISUSE_BKPT;\n  unixLockHook.xWillLock = xWillLock;\n  unixLockHook.xLockDidChange = xLockDidChange;\n  unixLockHook.xWillShmLock = xWillShmLock;\n  unixLockHook.xShmLockDidChange = xShmLockDidChange;\n  unixLockHook.pArg = pArg;\n  return SQLITE_OK;\n}\n#endif\n\n/* Forward references */\ntypedef struct unixShm unixShm;               /* Connection shared memory */\ntypedef struct unixShmNode unixShmNode;       /* Shared memory instance */\ntypedef struct unixInodeInfo unixInodeInfo;   /* An i-node */\ntypedef struct UnixUnusedFd UnixUnusedFd;     /* An unused file descriptor */\n\n/*\n** Sometimes, after a file handle is closed by SQLite, the file descriptor\n** cannot be closed immediately. In these cases, instances of the following\n** structure are used to store the file descriptor while waiting for an\n** opportunity to either close or reuse it.\n*/\nstruct UnixUnusedFd {\n  int fd;                   /* File descriptor to close */\n  int flags;                /* Flags this file descriptor was opened with */\n  UnixUnusedFd *pNext;      /* Next unused file descriptor on same file */\n};\n\n/*\n** The unixFile structure is subclass of sqlite3_file specific to the unix\n** VFS implementations.\n*/\ntypedef struct unixFile unixFile;\nstruct unixFile {\n  sqlite3_io_methods const *pMethod;  /* Always the first entry */\n  sqlite3_vfs *pVfs;                  /* The VFS that created this unixFile */\n  unixInodeInfo *pInode;              /* Info about locks on this inode */\n  int h;                              /* The file descriptor */\n  unsigned char eFileLock;            /* The type of lock held on this fd */\n  unsigned short int ctrlFlags;       /* Behavioral bits.  UNIXFILE_* flags */\n  int lastErrno;                      /* The unix errno from last I/O error */\n  void *lockingContext;               /* Locking style specific state */\n  UnixUnusedFd *pPreallocatedUnused;  /* Pre-allocated UnixUnusedFd */\n  const char *zPath;                  /* Name of the file */\n  unixShm *pShm;                      /* Shared memory segment information */\n  int szChunk;                        /* Configured by FCNTL_CHUNK_SIZE */\n#if SQLITE_MAX_MMAP_SIZE>0\n  int nFetchOut;                      /* Number of outstanding xFetch refs */\n  sqlite3_int64 mmapSize;             /* Usable size of mapping at pMapRegion */\n  sqlite3_int64 mmapSizeActual;       /* Actual size of mapping at pMapRegion */\n  sqlite3_int64 mmapSizeMax;          /* Configured FCNTL_MMAP_SIZE value */\n  void *pMapRegion;                   /* Memory mapped region */\n#endif\n  int sectorSize;                     /* Device sector size */\n  int deviceCharacteristics;          /* Precomputed device characteristics */\n#if SQLITE_ENABLE_LOCKING_STYLE\n  int openFlags;                      /* The flags specified at open() */\n#endif\n#if SQLITE_ENABLE_LOCKING_STYLE || defined(__APPLE__)\n  unsigned fsFlags;                   /* cached details from statfs() */\n#endif\n#ifdef SQLITE_ENABLE_SETLK_TIMEOUT\n  unsigned iBusyTimeout;              /* Wait this many millisec on locks */\n#endif\n#if OS_VXWORKS\n  struct vxworksFileId *pId;          /* Unique file ID */\n#endif\n#ifdef SQLITE_DEBUG\n  /* The next group of variables are used to track whether or not the\n  ** transaction counter in bytes 24-27 of database files are updated\n  ** whenever any part of the database changes.  An assertion fault will\n  ** occur if a file is updated without also updating the transaction\n  ** counter.  This test is made to avoid new problems similar to the\n  ** one described by ticket #3584. \n  */\n  unsigned char transCntrChng;   /* True if the transaction counter changed */\n  unsigned char dbUpdate;        /* True if any part of database file changed */\n  unsigned char inNormalWrite;   /* True if in a normal write operation */\n\n#endif\n\n#ifdef SQLITE_TEST\n  /* In test mode, increase the size of this structure a bit so that \n  ** it is larger than the struct CrashFile defined in test6.c.\n  */\n  char aPadding[32];\n#endif\n};\n\n/* This variable holds the process id (pid) from when the xRandomness()\n** method was called.  If xOpen() is called from a different process id,\n** indicating that a fork() has occurred, the PRNG will be reset.\n*/\nstatic pid_t randomnessPid = 0;\n\n/*\n** Allowed values for the unixFile.ctrlFlags bitmask:\n*/\n#define UNIXFILE_EXCL        0x01     /* Connections from one process only */\n#define UNIXFILE_RDONLY      0x02     /* Connection is read only */\n#define UNIXFILE_PERSIST_WAL 0x04     /* Persistent WAL mode */\n#ifndef SQLITE_DISABLE_DIRSYNC\n# define UNIXFILE_DIRSYNC    0x08     /* Directory sync needed */\n#else\n# define UNIXFILE_DIRSYNC    0x00\n#endif\n#define UNIXFILE_PSOW        0x10     /* SQLITE_IOCAP_POWERSAFE_OVERWRITE */\n#define UNIXFILE_DELETE      0x20     /* Delete on close */\n#define UNIXFILE_URI         0x40     /* Filename might have query parameters */\n#define UNIXFILE_NOLOCK      0x80     /* Do no file locking */\n\n/*\n** Include code that is common to all os_*.c files\n*/\n/************** Include os_common.h in the middle of os_unix.c ***************/\n/************** Begin file os_common.h ***************************************/\n/*\n** 2004 May 22\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n******************************************************************************\n**\n** This file contains macros and a little bit of code that is common to\n** all of the platform-specific files (os_*.c) and is #included into those\n** files.\n**\n** This file should be #included by the os_*.c files only.  It is not a\n** general purpose header file.\n*/\n#ifndef _OS_COMMON_H_\n#define _OS_COMMON_H_\n\n/*\n** At least two bugs have slipped in because we changed the MEMORY_DEBUG\n** macro to SQLITE_DEBUG and some older makefiles have not yet made the\n** switch.  The following code should catch this problem at compile-time.\n*/\n#ifdef MEMORY_DEBUG\n# error \"The MEMORY_DEBUG macro is obsolete.  Use SQLITE_DEBUG instead.\"\n#endif\n\n/*\n** Macros for performance tracing.  Normally turned off.  Only works\n** on i486 hardware.\n*/\n#ifdef SQLITE_PERFORMANCE_TRACE\n\n/*\n** hwtime.h contains inline assembler code for implementing\n** high-performance timing routines.\n*/\n/************** Include hwtime.h in the middle of os_common.h ****************/\n/************** Begin file hwtime.h ******************************************/\n/*\n** 2008 May 27\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n******************************************************************************\n**\n** This file contains inline asm code for retrieving \"high-performance\"\n** counters for x86 class CPUs.\n*/\n#ifndef SQLITE_HWTIME_H\n#define SQLITE_HWTIME_H\n\n/*\n** The following routine only works on pentium-class (or newer) processors.\n** It uses the RDTSC opcode to read the cycle count value out of the\n** processor and returns that value.  This can be used for high-res\n** profiling.\n*/\n#if (defined(__GNUC__) || defined(_MSC_VER)) && \\\n      (defined(i386) || defined(__i386__) || defined(_M_IX86))\n\n  #if defined(__GNUC__)\n\n  __inline__ sqlite_uint64 sqlite3Hwtime(void){\n     unsigned int lo, hi;\n     __asm__ __volatile__ (\"rdtsc\" : \"=a\" (lo), \"=d\" (hi));\n     return (sqlite_uint64)hi << 32 | lo;\n  }\n\n  #elif defined(_MSC_VER)\n\n  __declspec(naked) __inline sqlite_uint64 __cdecl sqlite3Hwtime(void){\n     __asm {\n        rdtsc\n        ret       ; return value at EDX:EAX\n     }\n  }\n\n  #endif\n\n#elif (defined(__GNUC__) && defined(__x86_64__))\n\n  __inline__ sqlite_uint64 sqlite3Hwtime(void){\n      unsigned long val;\n      __asm__ __volatile__ (\"rdtsc\" : \"=A\" (val));\n      return val;\n  }\n \n#elif (defined(__GNUC__) && defined(__ppc__))\n\n  __inline__ sqlite_uint64 sqlite3Hwtime(void){\n      unsigned long long retval;\n      unsigned long junk;\n      __asm__ __volatile__ (\"\\n\\\n          1:      mftbu   %1\\n\\\n                  mftb    %L0\\n\\\n                  mftbu   %0\\n\\\n                  cmpw    %0,%1\\n\\\n                  bne     1b\"\n                  : \"=r\" (retval), \"=r\" (junk));\n      return retval;\n  }\n\n#else\n\n  #error Need implementation of sqlite3Hwtime() for your platform.\n\n  /*\n  ** To compile without implementing sqlite3Hwtime() for your platform,\n  ** you can remove the above #error and use the following\n  ** stub function.  You will lose timing support for many\n  ** of the debugging and testing utilities, but it should at\n  ** least compile and run.\n  */\nSQLITE_PRIVATE   sqlite_uint64 sqlite3Hwtime(void){ return ((sqlite_uint64)0); }\n\n#endif\n\n#endif /* !defined(SQLITE_HWTIME_H) */\n\n/************** End of hwtime.h **********************************************/\n/************** Continuing where we left off in os_common.h ******************/\n\nstatic sqlite_uint64 g_start;\nstatic sqlite_uint64 g_elapsed;\n#define TIMER_START       g_start=sqlite3Hwtime()\n#define TIMER_END         g_elapsed=sqlite3Hwtime()-g_start\n#define TIMER_ELAPSED     g_elapsed\n#else\n#define TIMER_START\n#define TIMER_END\n#define TIMER_ELAPSED     ((sqlite_uint64)0)\n#endif\n\n/*\n** If we compile with the SQLITE_TEST macro set, then the following block\n** of code will give us the ability to simulate a disk I/O error.  This\n** is used for testing the I/O recovery logic.\n*/\n#if defined(SQLITE_TEST)\nSQLITE_API extern int sqlite3_io_error_hit;\nSQLITE_API extern int sqlite3_io_error_hardhit;\nSQLITE_API extern int sqlite3_io_error_pending;\nSQLITE_API extern int sqlite3_io_error_persist;\nSQLITE_API extern int sqlite3_io_error_benign;\nSQLITE_API extern int sqlite3_diskfull_pending;\nSQLITE_API extern int sqlite3_diskfull;\n#define SimulateIOErrorBenign(X) sqlite3_io_error_benign=(X)\n#define SimulateIOError(CODE)  \\\n  if( (sqlite3_io_error_persist && sqlite3_io_error_hit) \\\n       || sqlite3_io_error_pending-- == 1 )  \\\n              { local_ioerr(); CODE; }\nstatic void local_ioerr(){\n  IOTRACE((\"IOERR\\n\"));\n  sqlite3_io_error_hit++;\n  if( !sqlite3_io_error_benign ) sqlite3_io_error_hardhit++;\n}\n#define SimulateDiskfullError(CODE) \\\n   if( sqlite3_diskfull_pending ){ \\\n     if( sqlite3_diskfull_pending == 1 ){ \\\n       local_ioerr(); \\\n       sqlite3_diskfull = 1; \\\n       sqlite3_io_error_hit = 1; \\\n       CODE; \\\n     }else{ \\\n       sqlite3_diskfull_pending--; \\\n     } \\\n   }\n#else\n#define SimulateIOErrorBenign(X)\n#define SimulateIOError(A)\n#define SimulateDiskfullError(A)\n#endif /* defined(SQLITE_TEST) */\n\n/*\n** When testing, keep a count of the number of open files.\n*/\n#if defined(SQLITE_TEST)\nSQLITE_API extern int sqlite3_open_file_count;\n#define OpenCounter(X)  sqlite3_open_file_count+=(X)\n#else\n#define OpenCounter(X)\n#endif /* defined(SQLITE_TEST) */\n\n#endif /* !defined(_OS_COMMON_H_) */\n\n/************** End of os_common.h *******************************************/\n/************** Continuing where we left off in os_unix.c ********************/\n\n/*\n** Define various macros that are missing from some systems.\n*/\n#ifndef O_LARGEFILE\n# define O_LARGEFILE 0\n#endif\n#ifdef SQLITE_DISABLE_LFS\n# undef O_LARGEFILE\n# define O_LARGEFILE 0\n#endif\n#ifndef O_NOFOLLOW\n# define O_NOFOLLOW 0\n#endif\n#ifndef O_BINARY\n# define O_BINARY 0\n#endif\n\n/*\n** The threadid macro resolves to the thread-id or to 0.  Used for\n** testing and debugging only.\n*/\n#if SQLITE_THREADSAFE\n#define threadid pthread_self()\n#else\n#define threadid 0\n#endif\n\n/*\n** HAVE_MREMAP defaults to true on Linux and false everywhere else.\n*/\n#if !defined(HAVE_MREMAP)\n# if defined(__linux__) && defined(_GNU_SOURCE)\n#  define HAVE_MREMAP 1\n# else\n#  define HAVE_MREMAP 0\n# endif\n#endif\n\n/*\n** Explicitly call the 64-bit version of lseek() on Android. Otherwise, lseek()\n** is the 32-bit version, even if _FILE_OFFSET_BITS=64 is defined.\n*/\n#ifdef __ANDROID__\n\n# include <android/api-level.h>\n# if __ANDROID_API__ < 12\n/* Android API < 12 lacks ftruncate64 implementation. */\n# include <sys/syscall.h>\nstatic int ftruncate64(int fd, off64_t size) {\n  return syscall(__NR_ftruncate64, fd, 0, size & 0xFFFFFFFF, size >> 32);\n}\n# endif\n\n# define lseek lseek64\n#endif\n\n#ifdef __linux__\n/*\n** Linux-specific IOCTL magic numbers used for controlling F2FS\n*/\n#define F2FS_IOCTL_MAGIC        0xf5\n#define F2FS_IOC_START_ATOMIC_WRITE     _IO(F2FS_IOCTL_MAGIC, 1)\n#define F2FS_IOC_COMMIT_ATOMIC_WRITE    _IO(F2FS_IOCTL_MAGIC, 2)\n#define F2FS_IOC_START_VOLATILE_WRITE   _IO(F2FS_IOCTL_MAGIC, 3)\n#define F2FS_IOC_ABORT_VOLATILE_WRITE   _IO(F2FS_IOCTL_MAGIC, 5)\n#define F2FS_IOC_GET_FEATURES           _IOR(F2FS_IOCTL_MAGIC, 12, u32)\n#define F2FS_FEATURE_ATOMIC_WRITE 0x0004\n#endif /* __linux__ */\n\n\n/*\n** Different Unix systems declare open() in different ways.  Same use\n** open(const char*,int,mode_t).  Others use open(const char*,int,...).\n** The difference is important when using a pointer to the function.\n**\n** The safest way to deal with the problem is to always use this wrapper\n** which always has the same well-defined interface.\n*/\nstatic int posixOpen(const char *zFile, int flags, int mode){\n  return open(zFile, flags, mode);\n}\n\n/*\n** Some hook mechanisms will change the address of these functions at runtime.\n** Using wrapper function can enable these functions to support hook.\n*/\nstatic int posixClose(int fd){\n    return close(fd);\n}\n\nstatic size_t posixWrite(int fd, const void* buf,size_t nbyte){\n  return write(fd, buf, nbyte);\n}\n\nstatic size_t posixPWrite(int fd, const void * buf, size_t nbyte, off_t offset){\n  return pwrite(fd, buf, nbyte, offset);\n}\n\nstatic void* posixMMap(void *p, size_t size, int srcMode, int option, int srcFD, off_t offset){\n  return mmap(p, size, srcMode, option, srcFD, offset);\n}\n\nstatic int posixMunmap(void *p, size_t size){\n    return munmap(p, size);\n}\n\n/* Forward reference */\nstatic int openDirectory(const char*, int*);\nstatic int unixGetpagesize(void);\n\n/*\n** Many system calls are accessed through pointer-to-functions so that\n** they may be overridden at runtime to facilitate fault injection during\n** testing and sandboxing.  The following array holds the names and pointers\n** to all overrideable system calls.\n*/\nstatic struct unix_syscall {\n  const char *zName;            /* Name of the system call */\n  sqlite3_syscall_ptr pCurrent; /* Current value of the system call */\n  sqlite3_syscall_ptr pDefault; /* Default value */\n} aSyscall[] = {\n  { \"open\",         (sqlite3_syscall_ptr)posixOpen,  0  },\n#define osOpen      ((int(*)(const char*,int,int))aSyscall[0].pCurrent)\n\n  { \"close\",        (sqlite3_syscall_ptr)posixClose,      0  },\n#define osClose     ((int(*)(int))aSyscall[1].pCurrent)\n\n  { \"access\",       (sqlite3_syscall_ptr)access,     0  },\n#define osAccess    ((int(*)(const char*,int))aSyscall[2].pCurrent)\n\n  { \"getcwd\",       (sqlite3_syscall_ptr)getcwd,     0  },\n#define osGetcwd    ((char*(*)(char*,size_t))aSyscall[3].pCurrent)\n\n  { \"stat\",         (sqlite3_syscall_ptr)stat,       0  },\n#define osStat      ((int(*)(const char*,struct stat*))aSyscall[4].pCurrent)\n\n/*\n** The DJGPP compiler environment looks mostly like Unix, but it\n** lacks the fcntl() system call.  So redefine fcntl() to be something\n** that always succeeds.  This means that locking does not occur under\n** DJGPP.  But it is DOS - what did you expect?\n*/\n#ifdef __DJGPP__\n  { \"fstat\",        0,                 0  },\n#define osFstat(a,b,c)    0\n#else     \n  { \"fstat\",        (sqlite3_syscall_ptr)fstat,      0  },\n#define osFstat     ((int(*)(int,struct stat*))aSyscall[5].pCurrent)\n#endif\n\n#if defined(__ANDROID__)\n  { \"ftruncate\",    (sqlite3_syscall_ptr)ftruncate64, 0 },\n# define osFtruncate ((int(*)(int,off64_t))aSyscall[6].pCurrent)\n#else\n  { \"ftruncate\",    (sqlite3_syscall_ptr)ftruncate,  0  },\n# define osFtruncate ((int(*)(int,off_t))aSyscall[6].pCurrent)\n#endif\n\n  { \"fcntl\",        (sqlite3_syscall_ptr)fcntl,      0  },\n#define osFcntl     ((int(*)(int,int,...))aSyscall[7].pCurrent)\n\n  { \"read\",         (sqlite3_syscall_ptr)read,       0  },\n#define osRead      ((ssize_t(*)(int,void*,size_t))aSyscall[8].pCurrent)\n\n#if defined(USE_PREAD) || SQLITE_ENABLE_LOCKING_STYLE\n  { \"pread\",        (sqlite3_syscall_ptr)pread,      0  },\n#else\n  { \"pread\",        (sqlite3_syscall_ptr)0,          0  },\n#endif\n#define osPread     ((ssize_t(*)(int,void*,size_t,off_t))aSyscall[9].pCurrent)\n\n#if defined(USE_PREAD64)\n  { \"pread64\",      (sqlite3_syscall_ptr)pread64,    0  },\n#else\n  { \"pread64\",      (sqlite3_syscall_ptr)0,          0  },\n#endif\n#define osPread64 ((ssize_t(*)(int,void*,size_t,off64_t))aSyscall[10].pCurrent)\n\n  { \"write\",        (sqlite3_syscall_ptr)posixWrite, 0  },\n#define osWrite     ((ssize_t(*)(int,const void*,size_t))aSyscall[11].pCurrent)\n\n#if defined(USE_PREAD) || SQLITE_ENABLE_LOCKING_STYLE\n  { \"pwrite\",       (sqlite3_syscall_ptr)posixPWrite,0  },\n#else\n  { \"pwrite\",       (sqlite3_syscall_ptr)0,          0  },\n#endif\n#define osPwrite    ((ssize_t(*)(int,const void*,size_t,off_t))\\\n                    aSyscall[12].pCurrent)\n\n#if defined(USE_PREAD64)\n  { \"pwrite64\",     (sqlite3_syscall_ptr)pwrite64,   0  },\n#else\n  { \"pwrite64\",     (sqlite3_syscall_ptr)0,          0  },\n#endif\n#define osPwrite64  ((ssize_t(*)(int,const void*,size_t,off64_t))\\\n                    aSyscall[13].pCurrent)\n\n  { \"fchmod\",       (sqlite3_syscall_ptr)fchmod,          0  },\n#define osFchmod    ((int(*)(int,mode_t))aSyscall[14].pCurrent)\n\n#if defined(HAVE_POSIX_FALLOCATE) && HAVE_POSIX_FALLOCATE\n  { \"fallocate\",    (sqlite3_syscall_ptr)posix_fallocate,  0 },\n#else\n  { \"fallocate\",    (sqlite3_syscall_ptr)0,                0 },\n#endif\n#define osFallocate ((int(*)(int,off_t,off_t))aSyscall[15].pCurrent)\n\n  { \"unlink\",       (sqlite3_syscall_ptr)unlink,           0 },\n#define osUnlink    ((int(*)(const char*))aSyscall[16].pCurrent)\n\n  { \"openDirectory\",    (sqlite3_syscall_ptr)openDirectory,      0 },\n#define osOpenDirectory ((int(*)(const char*,int*))aSyscall[17].pCurrent)\n\n  { \"mkdir\",        (sqlite3_syscall_ptr)mkdir,           0 },\n#define osMkdir     ((int(*)(const char*,mode_t))aSyscall[18].pCurrent)\n\n  { \"rmdir\",        (sqlite3_syscall_ptr)rmdir,           0 },\n#define osRmdir     ((int(*)(const char*))aSyscall[19].pCurrent)\n\n#if defined(HAVE_FCHOWN)\n  { \"fchown\",       (sqlite3_syscall_ptr)fchown,          0 },\n#else\n  { \"fchown\",       (sqlite3_syscall_ptr)0,               0 },\n#endif\n#define osFchown    ((int(*)(int,uid_t,gid_t))aSyscall[20].pCurrent)\n\n#if defined(HAVE_FCHOWN)\n  { \"geteuid\",      (sqlite3_syscall_ptr)geteuid,         0 },\n#else\n  { \"geteuid\",      (sqlite3_syscall_ptr)0,               0 },\n#endif\n#define osGeteuid   ((uid_t(*)(void))aSyscall[21].pCurrent)\n\n#if !defined(SQLITE_OMIT_WAL) || SQLITE_MAX_MMAP_SIZE>0\n  { \"mmap\",         (sqlite3_syscall_ptr)posixMMap,       0 },\n#else\n  { \"mmap\",         (sqlite3_syscall_ptr)0,               0 },\n#endif\n#define osMmap ((void*(*)(void*,size_t,int,int,int,off_t))aSyscall[22].pCurrent)\n\n#if !defined(SQLITE_OMIT_WAL) || SQLITE_MAX_MMAP_SIZE>0\n  { \"munmap\",       (sqlite3_syscall_ptr)posixMunmap,     0 },\n#else\n  { \"munmap\",       (sqlite3_syscall_ptr)0,               0 },\n#endif\n#define osMunmap ((int(*)(void*,size_t))aSyscall[23].pCurrent)\n\n#if HAVE_MREMAP && (!defined(SQLITE_OMIT_WAL) || SQLITE_MAX_MMAP_SIZE>0)\n  { \"mremap\",       (sqlite3_syscall_ptr)mremap,          0 },\n#else\n  { \"mremap\",       (sqlite3_syscall_ptr)0,               0 },\n#endif\n#define osMremap ((void*(*)(void*,size_t,size_t,int,...))aSyscall[24].pCurrent)\n\n#if !defined(SQLITE_OMIT_WAL) || SQLITE_MAX_MMAP_SIZE>0\n  { \"getpagesize\",  (sqlite3_syscall_ptr)unixGetpagesize, 0 },\n#else\n  { \"getpagesize\",  (sqlite3_syscall_ptr)0,               0 },\n#endif\n#define osGetpagesize ((int(*)(void))aSyscall[25].pCurrent)\n\n#if defined(HAVE_READLINK)\n  { \"readlink\",     (sqlite3_syscall_ptr)readlink,        0 },\n#else\n  { \"readlink\",     (sqlite3_syscall_ptr)0,               0 },\n#endif\n#define osReadlink ((ssize_t(*)(const char*,char*,size_t))aSyscall[26].pCurrent)\n\n#if defined(HAVE_LSTAT)\n  { \"lstat\",         (sqlite3_syscall_ptr)lstat,          0 },\n#else\n  { \"lstat\",         (sqlite3_syscall_ptr)0,              0 },\n#endif\n#define osLstat      ((int(*)(const char*,struct stat*))aSyscall[27].pCurrent)\n\n#if defined(__linux__) && defined(SQLITE_ENABLE_BATCH_ATOMIC_WRITE)\n# ifdef __ANDROID__\n  { \"ioctl\", (sqlite3_syscall_ptr)(int(*)(int, int, ...))ioctl, 0 },\n# else\n  { \"ioctl\",         (sqlite3_syscall_ptr)ioctl,          0 },\n# endif\n#else\n  { \"ioctl\",         (sqlite3_syscall_ptr)0,              0 },\n#endif\n#define osIoctl ((int(*)(int,int,...))aSyscall[28].pCurrent)\n\n}; /* End of the overrideable system calls */\n\n\n/*\n** On some systems, calls to fchown() will trigger a message in a security\n** log if they come from non-root processes.  So avoid calling fchown() if\n** we are not running as root.\n*/\nstatic int robustFchown(int fd, uid_t uid, gid_t gid){\n#if defined(HAVE_FCHOWN)\n  return osGeteuid() ? 0 : osFchown(fd,uid,gid);\n#else\n  return 0;\n#endif\n}\n\n/*\n** This is the xSetSystemCall() method of sqlite3_vfs for all of the\n** \"unix\" VFSes.  Return SQLITE_OK opon successfully updating the\n** system call pointer, or SQLITE_NOTFOUND if there is no configurable\n** system call named zName.\n*/\nstatic int unixSetSystemCall(\n  sqlite3_vfs *pNotUsed,        /* The VFS pointer.  Not used */\n  const char *zName,            /* Name of system call to override */\n  sqlite3_syscall_ptr pNewFunc  /* Pointer to new system call value */\n){\n  unsigned int i;\n  int rc = SQLITE_NOTFOUND;\n\n  UNUSED_PARAMETER(pNotUsed);\n  if( zName==0 ){\n    /* If no zName is given, restore all system calls to their default\n    ** settings and return NULL\n    */\n    rc = SQLITE_OK;\n    for(i=0; i<sizeof(aSyscall)/sizeof(aSyscall[0]); i++){\n      if( aSyscall[i].pDefault ){\n        aSyscall[i].pCurrent = aSyscall[i].pDefault;\n      }\n    }\n  }else{\n    /* If zName is specified, operate on only the one system call\n    ** specified.\n    */\n    for(i=0; i<sizeof(aSyscall)/sizeof(aSyscall[0]); i++){\n      if( strcmp(zName, aSyscall[i].zName)==0 ){\n        if( aSyscall[i].pDefault==0 ){\n          aSyscall[i].pDefault = aSyscall[i].pCurrent;\n        }\n        rc = SQLITE_OK;\n        if( pNewFunc==0 ) pNewFunc = aSyscall[i].pDefault;\n        aSyscall[i].pCurrent = pNewFunc;\n        break;\n      }\n    }\n  }\n  return rc;\n}\n\n/*\n** Return the value of a system call.  Return NULL if zName is not a\n** recognized system call name.  NULL is also returned if the system call\n** is currently undefined.\n*/\nstatic sqlite3_syscall_ptr unixGetSystemCall(\n  sqlite3_vfs *pNotUsed,\n  const char *zName\n){\n  unsigned int i;\n\n  UNUSED_PARAMETER(pNotUsed);\n  for(i=0; i<sizeof(aSyscall)/sizeof(aSyscall[0]); i++){\n    if( strcmp(zName, aSyscall[i].zName)==0 ) return aSyscall[i].pCurrent;\n  }\n  return 0;\n}\n\n/*\n** Return the name of the first system call after zName.  If zName==NULL\n** then return the name of the first system call.  Return NULL if zName\n** is the last system call or if zName is not the name of a valid\n** system call.\n*/\nstatic const char *unixNextSystemCall(sqlite3_vfs *p, const char *zName){\n  int i = -1;\n\n  UNUSED_PARAMETER(p);\n  if( zName ){\n    for(i=0; i<ArraySize(aSyscall)-1; i++){\n      if( strcmp(zName, aSyscall[i].zName)==0 ) break;\n    }\n  }\n  for(i++; i<ArraySize(aSyscall); i++){\n    if( aSyscall[i].pCurrent!=0 ) return aSyscall[i].zName;\n  }\n  return 0;\n}\n\n/*\n** Do not accept any file descriptor less than this value, in order to avoid\n** opening database file using file descriptors that are commonly used for \n** standard input, output, and error.\n*/\n#ifndef SQLITE_MINIMUM_FILE_DESCRIPTOR\n# define SQLITE_MINIMUM_FILE_DESCRIPTOR 3\n#endif\n\n/*\n** Invoke open().  Do so multiple times, until it either succeeds or\n** fails for some reason other than EINTR.\n**\n** If the file creation mode \"m\" is 0 then set it to the default for\n** SQLite.  The default is SQLITE_DEFAULT_FILE_PERMISSIONS (normally\n** 0644) as modified by the system umask.  If m is not 0, then\n** make the file creation mode be exactly m ignoring the umask.\n**\n** The m parameter will be non-zero only when creating -wal, -journal,\n** and -shm files.  We want those files to have *exactly* the same\n** permissions as their original database, unadulterated by the umask.\n** In that way, if a database file is -rw-rw-rw or -rw-rw-r-, and a\n** transaction crashes and leaves behind hot journals, then any\n** process that is able to write to the database will also be able to\n** recover the hot journals.\n*/\nstatic int robust_open(const char *z, int f, mode_t m){\n  int fd;\n  mode_t m2 = m ? m : SQLITE_DEFAULT_FILE_PERMISSIONS;\n  while(1){\n#if defined(O_CLOEXEC)\n    fd = osOpen(z,f|O_CLOEXEC,m2);\n#else\n    fd = osOpen(z,f,m2);\n#endif\n    if( fd<0 ){\n      if( errno==EINTR ) continue;\n      break;\n    }\n    if( fd>=SQLITE_MINIMUM_FILE_DESCRIPTOR ) break;\n    osClose(fd);\n    sqlite3_log(SQLITE_WARNING, \n                \"attempt to open \\\"%s\\\" as file descriptor %d\", z, fd);\n    fd = -1;\n    if( osOpen(\"/dev/null\", f, m)<0 ) break;\n  }\n  if( fd>=0 ){\n    if( m!=0 ){\n      struct stat statbuf;\n      if( osFstat(fd, &statbuf)==0 \n       && statbuf.st_size==0\n       && (statbuf.st_mode&0777)!=m \n      ){\n        osFchmod(fd, m);\n      }\n    }\n#if defined(FD_CLOEXEC) && (!defined(O_CLOEXEC) || O_CLOEXEC==0)\n    osFcntl(fd, F_SETFD, osFcntl(fd, F_GETFD, 0) | FD_CLOEXEC);\n#endif\n  }\n  return fd;\n}\n\n/*\n** Helper functions to obtain and relinquish the global mutex. The\n** global mutex is used to protect the unixInodeInfo and\n** vxworksFileId objects used by this file, all of which may be \n** shared by multiple threads.\n**\n** Function unixMutexHeld() is used to assert() that the global mutex \n** is held when required. This function is only used as part of assert() \n** statements. e.g.\n**\n**   unixEnterMutex()\n**     assert( unixMutexHeld() );\n**   unixEnterLeave()\n**\n** To prevent deadlock, the global unixBigLock must must be acquired\n** before the unixInodeInfo.pLockMutex mutex, if both are held.  It is\n** OK to get the pLockMutex without holding unixBigLock first, but if\n** that happens, the unixBigLock mutex must not be acquired until after\n** pLockMutex is released.\n**\n**      OK:     enter(unixBigLock),  enter(pLockInfo)\n**      OK:     enter(unixBigLock)\n**      OK:     enter(pLockInfo)\n**   ERROR:     enter(pLockInfo), enter(unixBigLock)\n*/\nstatic sqlite3_mutex *unixBigLock = 0;\nstatic void unixEnterMutex(void){\n  assert( sqlite3_mutex_notheld(unixBigLock) );  /* Not a recursive mutex */\n  sqlite3_mutex_enter(unixBigLock);\n}\nstatic void unixLeaveMutex(void){\n  assert( sqlite3_mutex_held(unixBigLock) );\n  sqlite3_mutex_leave(unixBigLock);\n}\n#ifdef SQLITE_DEBUG\nstatic int unixMutexHeld(void) {\n  return sqlite3_mutex_held(unixBigLock);\n}\n#endif\n\n\n#ifdef SQLITE_HAVE_OS_TRACE\n/*\n** Helper function for printing out trace information from debugging\n** binaries. This returns the string representation of the supplied\n** integer lock-type.\n*/\nstatic const char *azFileLock(int eFileLock){\n  switch( eFileLock ){\n    case NO_LOCK: return \"NONE\";\n    case SHARED_LOCK: return \"SHARED\";\n    case RESERVED_LOCK: return \"RESERVED\";\n    case PENDING_LOCK: return \"PENDING\";\n    case EXCLUSIVE_LOCK: return \"EXCLUSIVE\";\n  }\n  return \"ERROR\";\n}\n#endif\n\n#ifdef SQLITE_LOCK_TRACE\n/*\n** Print out information about all locking operations.\n**\n** This routine is used for troubleshooting locks on multithreaded\n** platforms.  Enable by compiling with the -DSQLITE_LOCK_TRACE\n** command-line option on the compiler.  This code is normally\n** turned off.\n*/\nstatic int lockTrace(int fd, int op, struct flock *p){\n  char *zOpName, *zType;\n  int s;\n  int savedErrno;\n  if( op==F_GETLK ){\n    zOpName = \"GETLK\";\n  }else if( op==F_SETLK ){\n    zOpName = \"SETLK\";\n  }else{\n    s = osFcntl(fd, op, p);\n    sqlite3DebugPrintf(\"fcntl unknown %d %d %d\\n\", fd, op, s);\n    return s;\n  }\n  if( p->l_type==F_RDLCK ){\n    zType = \"RDLCK\";\n  }else if( p->l_type==F_WRLCK ){\n    zType = \"WRLCK\";\n  }else if( p->l_type==F_UNLCK ){\n    zType = \"UNLCK\";\n  }else{\n    assert( 0 );\n  }\n  assert( p->l_whence==SEEK_SET );\n  s = osFcntl(fd, op, p);\n  savedErrno = errno;\n  sqlite3DebugPrintf(\"fcntl %d %d %s %s %d %d %d %d\\n\",\n     threadid, fd, zOpName, zType, (int)p->l_start, (int)p->l_len,\n     (int)p->l_pid, s);\n  if( s==(-1) && op==F_SETLK && (p->l_type==F_RDLCK || p->l_type==F_WRLCK) ){\n    struct flock l2;\n    l2 = *p;\n    osFcntl(fd, F_GETLK, &l2);\n    if( l2.l_type==F_RDLCK ){\n      zType = \"RDLCK\";\n    }else if( l2.l_type==F_WRLCK ){\n      zType = \"WRLCK\";\n    }else if( l2.l_type==F_UNLCK ){\n      zType = \"UNLCK\";\n    }else{\n      assert( 0 );\n    }\n    sqlite3DebugPrintf(\"fcntl-failure-reason: %s %d %d %d\\n\",\n       zType, (int)l2.l_start, (int)l2.l_len, (int)l2.l_pid);\n  }\n  errno = savedErrno;\n  return s;\n}\n#undef osFcntl\n#define osFcntl lockTrace\n#endif /* SQLITE_LOCK_TRACE */\n\n/*\n** Retry ftruncate() calls that fail due to EINTR\n**\n** All calls to ftruncate() within this file should be made through\n** this wrapper.  On the Android platform, bypassing the logic below\n** could lead to a corrupt database.\n*/\nstatic int robust_ftruncate(int h, sqlite3_int64 sz){\n  int rc;\n  do{ rc = osFtruncate(h,sz); }while( rc<0 && errno==EINTR );\n  return rc;\n}\n\n/*\n** This routine translates a standard POSIX errno code into something\n** useful to the clients of the sqlite3 functions.  Specifically, it is\n** intended to translate a variety of \"try again\" errors into SQLITE_BUSY\n** and a variety of \"please close the file descriptor NOW\" errors into \n** SQLITE_IOERR\n** \n** Errors during initialization of locks, or file system support for locks,\n** should handle ENOLCK, ENOTSUP, EOPNOTSUPP separately.\n*/\nstatic int sqliteErrorFromPosixError(int posixError, int sqliteIOErr) {\n  assert( (sqliteIOErr == SQLITE_IOERR_LOCK) || \n          (sqliteIOErr == SQLITE_IOERR_UNLOCK) || \n          (sqliteIOErr == SQLITE_IOERR_RDLOCK) ||\n          (sqliteIOErr == SQLITE_IOERR_CHECKRESERVEDLOCK) );\n  switch (posixError) {\n  case EACCES: \n  case EAGAIN:\n  case ETIMEDOUT:\n  case EBUSY:\n  case EINTR:\n  case ENOLCK:  \n    /* random NFS retry error, unless during file system support \n     * introspection, in which it actually means what it says */\n    return SQLITE_BUSY;\n    \n  case EPERM: \n    return SQLITE_PERM;\n    \n  default: \n    return sqliteIOErr;\n  }\n}\n\n\n/******************************************************************************\n****************** Begin Unique File ID Utility Used By VxWorks ***************\n**\n** On most versions of unix, we can get a unique ID for a file by concatenating\n** the device number and the inode number.  But this does not work on VxWorks.\n** On VxWorks, a unique file id must be based on the canonical filename.\n**\n** A pointer to an instance of the following structure can be used as a\n** unique file ID in VxWorks.  Each instance of this structure contains\n** a copy of the canonical filename.  There is also a reference count.  \n** The structure is reclaimed when the number of pointers to it drops to\n** zero.\n**\n** There are never very many files open at one time and lookups are not\n** a performance-critical path, so it is sufficient to put these\n** structures on a linked list.\n*/\nstruct vxworksFileId {\n  struct vxworksFileId *pNext;  /* Next in a list of them all */\n  int nRef;                     /* Number of references to this one */\n  int nName;                    /* Length of the zCanonicalName[] string */\n  char *zCanonicalName;         /* Canonical filename */\n};\n\n#if OS_VXWORKS\n/* \n** All unique filenames are held on a linked list headed by this\n** variable:\n*/\nstatic struct vxworksFileId *vxworksFileList = 0;\n\n/*\n** Simplify a filename into its canonical form\n** by making the following changes:\n**\n**  * removing any trailing and duplicate /\n**  * convert /./ into just /\n**  * convert /A/../ where A is any simple name into just /\n**\n** Changes are made in-place.  Return the new name length.\n**\n** The original filename is in z[0..n-1].  Return the number of\n** characters in the simplified name.\n*/\nstatic int vxworksSimplifyName(char *z, int n){\n  int i, j;\n  while( n>1 && z[n-1]=='/' ){ n--; }\n  for(i=j=0; i<n; i++){\n    if( z[i]=='/' ){\n      if( z[i+1]=='/' ) continue;\n      if( z[i+1]=='.' && i+2<n && z[i+2]=='/' ){\n        i += 1;\n        continue;\n      }\n      if( z[i+1]=='.' && i+3<n && z[i+2]=='.' && z[i+3]=='/' ){\n        while( j>0 && z[j-1]!='/' ){ j--; }\n        if( j>0 ){ j--; }\n        i += 2;\n        continue;\n      }\n    }\n    z[j++] = z[i];\n  }\n  z[j] = 0;\n  return j;\n}\n\n/*\n** Find a unique file ID for the given absolute pathname.  Return\n** a pointer to the vxworksFileId object.  This pointer is the unique\n** file ID.\n**\n** The nRef field of the vxworksFileId object is incremented before\n** the object is returned.  A new vxworksFileId object is created\n** and added to the global list if necessary.\n**\n** If a memory allocation error occurs, return NULL.\n*/\nstatic struct vxworksFileId *vxworksFindFileId(const char *zAbsoluteName){\n  struct vxworksFileId *pNew;         /* search key and new file ID */\n  struct vxworksFileId *pCandidate;   /* For looping over existing file IDs */\n  int n;                              /* Length of zAbsoluteName string */\n\n  assert( zAbsoluteName[0]=='/' );\n  n = (int)strlen(zAbsoluteName);\n  pNew = sqlite3_malloc64( sizeof(*pNew) + (n+1) );\n  if( pNew==0 ) return 0;\n  pNew->zCanonicalName = (char*)&pNew[1];\n  memcpy(pNew->zCanonicalName, zAbsoluteName, n+1);\n  n = vxworksSimplifyName(pNew->zCanonicalName, n);\n\n  /* Search for an existing entry that matching the canonical name.\n  ** If found, increment the reference count and return a pointer to\n  ** the existing file ID.\n  */\n  unixEnterMutex();\n  for(pCandidate=vxworksFileList; pCandidate; pCandidate=pCandidate->pNext){\n    if( pCandidate->nName==n \n     && memcmp(pCandidate->zCanonicalName, pNew->zCanonicalName, n)==0\n    ){\n       sqlite3_free(pNew);\n       pCandidate->nRef++;\n       unixLeaveMutex();\n       return pCandidate;\n    }\n  }\n\n  /* No match was found.  We will make a new file ID */\n  pNew->nRef = 1;\n  pNew->nName = n;\n  pNew->pNext = vxworksFileList;\n  vxworksFileList = pNew;\n  unixLeaveMutex();\n  return pNew;\n}\n\n/*\n** Decrement the reference count on a vxworksFileId object.  Free\n** the object when the reference count reaches zero.\n*/\nstatic void vxworksReleaseFileId(struct vxworksFileId *pId){\n  unixEnterMutex();\n  assert( pId->nRef>0 );\n  pId->nRef--;\n  if( pId->nRef==0 ){\n    struct vxworksFileId **pp;\n    for(pp=&vxworksFileList; *pp && *pp!=pId; pp = &((*pp)->pNext)){}\n    assert( *pp==pId );\n    *pp = pId->pNext;\n    sqlite3_free(pId);\n  }\n  unixLeaveMutex();\n}\n#endif /* OS_VXWORKS */\n/*************** End of Unique File ID Utility Used By VxWorks ****************\n******************************************************************************/\n\n\n/******************************************************************************\n*************************** Posix Advisory Locking ****************************\n**\n** POSIX advisory locks are broken by design.  ANSI STD 1003.1 (1996)\n** section 6.5.2.2 lines 483 through 490 specify that when a process\n** sets or clears a lock, that operation overrides any prior locks set\n** by the same process.  It does not explicitly say so, but this implies\n** that it overrides locks set by the same process using a different\n** file descriptor.  Consider this test case:\n**\n**       int fd1 = open(\"./file1\", O_RDWR|O_CREAT, 0644);\n**       int fd2 = open(\"./file2\", O_RDWR|O_CREAT, 0644);\n**\n** Suppose ./file1 and ./file2 are really the same file (because\n** one is a hard or symbolic link to the other) then if you set\n** an exclusive lock on fd1, then try to get an exclusive lock\n** on fd2, it works.  I would have expected the second lock to\n** fail since there was already a lock on the file due to fd1.\n** But not so.  Since both locks came from the same process, the\n** second overrides the first, even though they were on different\n** file descriptors opened on different file names.\n**\n** This means that we cannot use POSIX locks to synchronize file access\n** among competing threads of the same process.  POSIX locks will work fine\n** to synchronize access for threads in separate processes, but not\n** threads within the same process.\n**\n** To work around the problem, SQLite has to manage file locks internally\n** on its own.  Whenever a new database is opened, we have to find the\n** specific inode of the database file (the inode is determined by the\n** st_dev and st_ino fields of the stat structure that fstat() fills in)\n** and check for locks already existing on that inode.  When locks are\n** created or removed, we have to look at our own internal record of the\n** locks to see if another thread has previously set a lock on that same\n** inode.\n**\n** (Aside: The use of inode numbers as unique IDs does not work on VxWorks.\n** For VxWorks, we have to use the alternative unique ID system based on\n** canonical filename and implemented in the previous division.)\n**\n** The sqlite3_file structure for POSIX is no longer just an integer file\n** descriptor.  It is now a structure that holds the integer file\n** descriptor and a pointer to a structure that describes the internal\n** locks on the corresponding inode.  There is one locking structure\n** per inode, so if the same inode is opened twice, both unixFile structures\n** point to the same locking structure.  The locking structure keeps\n** a reference count (so we will know when to delete it) and a \"cnt\"\n** field that tells us its internal lock status.  cnt==0 means the\n** file is unlocked.  cnt==-1 means the file has an exclusive lock.\n** cnt>0 means there are cnt shared locks on the file.\n**\n** Any attempt to lock or unlock a file first checks the locking\n** structure.  The fcntl() system call is only invoked to set a \n** POSIX lock if the internal lock structure transitions between\n** a locked and an unlocked state.\n**\n** But wait:  there are yet more problems with POSIX advisory locks.\n**\n** If you close a file descriptor that points to a file that has locks,\n** all locks on that file that are owned by the current process are\n** released.  To work around this problem, each unixInodeInfo object\n** maintains a count of the number of pending locks on tha inode.\n** When an attempt is made to close an unixFile, if there are\n** other unixFile open on the same inode that are holding locks, the call\n** to close() the file descriptor is deferred until all of the locks clear.\n** The unixInodeInfo structure keeps a list of file descriptors that need to\n** be closed and that list is walked (and cleared) when the last lock\n** clears.\n**\n** Yet another problem:  LinuxThreads do not play well with posix locks.\n**\n** Many older versions of linux use the LinuxThreads library which is\n** not posix compliant.  Under LinuxThreads, a lock created by thread\n** A cannot be modified or overridden by a different thread B.\n** Only thread A can modify the lock.  Locking behavior is correct\n** if the appliation uses the newer Native Posix Thread Library (NPTL)\n** on linux - with NPTL a lock created by thread A can override locks\n** in thread B.  But there is no way to know at compile-time which\n** threading library is being used.  So there is no way to know at\n** compile-time whether or not thread A can override locks on thread B.\n** One has to do a run-time check to discover the behavior of the\n** current process.\n**\n** SQLite used to support LinuxThreads.  But support for LinuxThreads\n** was dropped beginning with version 3.7.0.  SQLite will still work with\n** LinuxThreads provided that (1) there is no more than one connection \n** per database file in the same process and (2) database connections\n** do not move across threads.\n*/\n\n/*\n** An instance of the following structure serves as the key used\n** to locate a particular unixInodeInfo object.\n*/\nstruct unixFileId {\n  dev_t dev;                  /* Device number */\n#if OS_VXWORKS\n  struct vxworksFileId *pId;  /* Unique file ID for vxworks. */\n#else\n  /* We are told that some versions of Android contain a bug that\n  ** sizes ino_t at only 32-bits instead of 64-bits. (See\n  ** https://android-review.googlesource.com/#/c/115351/3/dist/sqlite3.c)\n  ** To work around this, always allocate 64-bits for the inode number.  \n  ** On small machines that only have 32-bit inodes, this wastes 4 bytes,\n  ** but that should not be a big deal. */\n  /* WAS:  ino_t ino;   */\n  u64 ino;                   /* Inode number */\n#endif\n};\n\n/*\n** An instance of the following structure is allocated for each open\n** inode.\n**\n** A single inode can have multiple file descriptors, so each unixFile\n** structure contains a pointer to an instance of this object and this\n** object keeps a count of the number of unixFile pointing to it.\n**\n** Mutex rules:\n**\n**  (1) Only the pLockMutex mutex must be held in order to read or write\n**      any of the locking fields:\n**          nShared, nLock, eFileLock, bProcessLock, pUnused\n**\n**  (2) When nRef>0, then the following fields are unchanging and can\n**      be read (but not written) without holding any mutex:\n**          fileId, pLockMutex\n**\n**  (3) With the exceptions above, all the fields may only be read\n**      or written while holding the global unixBigLock mutex.\n**\n** Deadlock prevention:  The global unixBigLock mutex may not\n** be acquired while holding the pLockMutex mutex.  If both unixBigLock\n** and pLockMutex are needed, then unixBigLock must be acquired first.\n*/\nstruct unixInodeInfo {\n  struct unixFileId fileId;       /* The lookup key */\n  sqlite3_mutex *pLockMutex;      /* Hold this mutex for... */\n  int nShared;                      /* Number of SHARED locks held */\n  int nLock;                        /* Number of outstanding file locks */\n  unsigned char eFileLock;          /* One of SHARED_LOCK, RESERVED_LOCK etc. */\n  unsigned char bProcessLock;       /* An exclusive process lock is held */\n  UnixUnusedFd *pUnused;            /* Unused file descriptors to close */\n  int nRef;                       /* Number of pointers to this structure */\n  unixShmNode *pShmNode;          /* Shared memory associated with this inode */\n  unixInodeInfo *pNext;           /* List of all unixInodeInfo objects */\n  unixInodeInfo *pPrev;           /*    .... doubly linked */\n#if SQLITE_ENABLE_LOCKING_STYLE\n  unsigned long long sharedByte;  /* for AFP simulated shared lock */\n#endif\n#if OS_VXWORKS\n  sem_t *pSem;                    /* Named POSIX semaphore */\n  char aSemName[MAX_PATHNAME+2];  /* Name of that semaphore */\n#endif\n};\n\n/*\n** A lists of all unixInodeInfo objects.\n**\n** Must hold unixBigLock in order to read or write this variable.\n*/\nstatic unixInodeInfo *inodeList = 0;  /* All unixInodeInfo objects */\n\n#ifdef SQLITE_DEBUG\n/*\n** True if the inode mutex (on the unixFile.pFileMutex field) is held, or not.\n** This routine is used only within assert() to help verify correct mutex\n** usage.\n*/\nint unixFileMutexHeld(unixFile *pFile){\n  assert( pFile->pInode );\n  return sqlite3_mutex_held(pFile->pInode->pLockMutex);\n}\nint unixFileMutexNotheld(unixFile *pFile){\n  assert( pFile->pInode );\n  return sqlite3_mutex_notheld(pFile->pInode->pLockMutex);\n}\n#endif\n\n/*\n**\n** This function - unixLogErrorAtLine(), is only ever called via the macro\n** unixLogError().\n**\n** It is invoked after an error occurs in an OS function and errno has been\n** set. It logs a message using sqlite3_log() containing the current value of\n** errno and, if possible, the human-readable equivalent from strerror() or\n** strerror_r().\n**\n** The first argument passed to the macro should be the error code that\n** will be returned to SQLite (e.g. SQLITE_IOERR_DELETE, SQLITE_CANTOPEN). \n** The two subsequent arguments should be the name of the OS function that\n** failed (e.g. \"unlink\", \"open\") and the associated file-system path,\n** if any.\n*/\n#define unixLogError(a,b,c)     unixLogErrorAtLine(a,b,c,__LINE__)\nstatic int unixLogErrorAtLine(\n  int errcode,                    /* SQLite error code */\n  const char *zFunc,              /* Name of OS function that failed */\n  const char *zPath,              /* File path associated with error */\n  int iLine                       /* Source line number where error occurred */\n){\n  char *zErr;                     /* Message from strerror() or equivalent */\n  int iErrno = errno;             /* Saved syscall error number */\n\n  /* If this is not a threadsafe build (SQLITE_THREADSAFE==0), then use\n  ** the strerror() function to obtain the human-readable error message\n  ** equivalent to errno. Otherwise, use strerror_r().\n  */ \n#if SQLITE_THREADSAFE && defined(HAVE_STRERROR_R)\n  char aErr[80];\n  memset(aErr, 0, sizeof(aErr));\n  zErr = aErr;\n\n  /* If STRERROR_R_CHAR_P (set by autoconf scripts) or __USE_GNU is defined,\n  ** assume that the system provides the GNU version of strerror_r() that\n  ** returns a pointer to a buffer containing the error message. That pointer \n  ** may point to aErr[], or it may point to some static storage somewhere. \n  ** Otherwise, assume that the system provides the POSIX version of \n  ** strerror_r(), which always writes an error message into aErr[].\n  **\n  ** If the code incorrectly assumes that it is the POSIX version that is\n  ** available, the error message will often be an empty string. Not a\n  ** huge problem. Incorrectly concluding that the GNU version is available \n  ** could lead to a segfault though.\n  */\n#if defined(STRERROR_R_CHAR_P) || defined(__USE_GNU)\n  zErr = \n# endif\n  strerror_r(iErrno, aErr, sizeof(aErr)-1);\n\n#elif SQLITE_THREADSAFE\n  /* This is a threadsafe build, but strerror_r() is not available. */\n  zErr = \"\";\n#else\n  /* Non-threadsafe build, use strerror(). */\n  zErr = strerror(iErrno);\n#endif\n\n  if( zPath==0 ) zPath = \"\";\n  sqlite3_log(errcode,\n      \"os_unix.c:%d: (%d) %s(%s) - %s\",\n      iLine, iErrno, zFunc, zPath, zErr\n  );\n\n  return errcode;\n}\n\n/*\n** Close a file descriptor.\n**\n** We assume that close() almost always works, since it is only in a\n** very sick application or on a very sick platform that it might fail.\n** If it does fail, simply leak the file descriptor, but do log the\n** error.\n**\n** Note that it is not safe to retry close() after EINTR since the\n** file descriptor might have already been reused by another thread.\n** So we don't even try to recover from an EINTR.  Just log the error\n** and move on.\n*/\nstatic void robust_close(unixFile *pFile, int h, int lineno){\n  if( osClose(h) ){\n    unixLogErrorAtLine(SQLITE_IOERR_CLOSE, \"close\",\n                       pFile ? pFile->zPath : 0, lineno);\n  }\n}\n\n/*\n** Set the pFile->lastErrno.  Do this in a subroutine as that provides\n** a convenient place to set a breakpoint.\n*/\nstatic void storeLastErrno(unixFile *pFile, int error){\n  pFile->lastErrno = error;\n}\n\n/*\n** Close all file descriptors accumuated in the unixInodeInfo->pUnused list.\n*/ \nstatic void closePendingFds(unixFile *pFile){\n  unixInodeInfo *pInode = pFile->pInode;\n  UnixUnusedFd *p;\n  UnixUnusedFd *pNext;\n  assert( unixFileMutexHeld(pFile) );\n  for(p=pInode->pUnused; p; p=pNext){\n    pNext = p->pNext;\n    robust_close(pFile, p->fd, __LINE__);\n    sqlite3_free(p);\n  }\n  pInode->pUnused = 0;\n}\n\n/*\n** Release a unixInodeInfo structure previously allocated by findInodeInfo().\n**\n** The global mutex must be held when this routine is called, but the mutex\n** on the inode being deleted must NOT be held.\n*/\nstatic void releaseInodeInfo(unixFile *pFile){\n  unixInodeInfo *pInode = pFile->pInode;\n  assert( unixMutexHeld() );\n  assert( unixFileMutexNotheld(pFile) );\n  if( ALWAYS(pInode) ){\n    pInode->nRef--;\n    if( pInode->nRef==0 ){\n      assert( pInode->pShmNode==0 );\n      sqlite3_mutex_enter(pInode->pLockMutex);\n      closePendingFds(pFile);\n      sqlite3_mutex_leave(pInode->pLockMutex);\n      if( pInode->pPrev ){\n        assert( pInode->pPrev->pNext==pInode );\n        pInode->pPrev->pNext = pInode->pNext;\n      }else{\n        assert( inodeList==pInode );\n        inodeList = pInode->pNext;\n      }\n      if( pInode->pNext ){\n        assert( pInode->pNext->pPrev==pInode );\n        pInode->pNext->pPrev = pInode->pPrev;\n      }\n#ifdef SQLITE_WCDB_LOCK_HOOK\n      if (unixLockHook.xLockDidChange != NULL) {\n        unixLockHook.xLockDidChange(unixLockHook.pArg, pFile->zPath, NO_LOCK);\n      }\n#endif\n      sqlite3_mutex_free(pInode->pLockMutex);\n      sqlite3_free(pInode);\n    }\n  }\n}\n\n/*\n** Given a file descriptor, locate the unixInodeInfo object that\n** describes that file descriptor.  Create a new one if necessary.  The\n** return value might be uninitialized if an error occurs.\n**\n** The global mutex must held when calling this routine.\n**\n** Return an appropriate error code.\n*/\nstatic int findInodeInfo(\n  unixFile *pFile,               /* Unix file with file desc used in the key */\n  unixInodeInfo **ppInode        /* Return the unixInodeInfo object here */\n){\n  int rc;                        /* System call return code */\n  int fd;                        /* The file descriptor for pFile */\n  struct unixFileId fileId;      /* Lookup key for the unixInodeInfo */\n  struct stat statbuf;           /* Low-level file information */\n  unixInodeInfo *pInode = 0;     /* Candidate unixInodeInfo object */\n\n  assert( unixMutexHeld() );\n\n  /* Get low-level information about the file that we can used to\n  ** create a unique name for the file.\n  */\n  fd = pFile->h;\n  rc = osFstat(fd, &statbuf);\n  if( rc!=0 ){\n    storeLastErrno(pFile, errno);\n#if defined(EOVERFLOW) && defined(SQLITE_DISABLE_LFS)\n    if( pFile->lastErrno==EOVERFLOW ) return SQLITE_NOLFS;\n#endif\n    return SQLITE_IOERR;\n  }\n\n#ifdef __APPLE__\n  /* On OS X on an msdos filesystem, the inode number is reported\n  ** incorrectly for zero-size files.  See ticket #3260.  To work\n  ** around this problem (we consider it a bug in OS X, not SQLite)\n  ** we always increase the file size to 1 by writing a single byte\n  ** prior to accessing the inode number.  The one byte written is\n  ** an ASCII 'S' character which also happens to be the first byte\n  ** in the header of every SQLite database.  In this way, if there\n  ** is a race condition such that another thread has already populated\n  ** the first page of the database, no damage is done.\n  */\n  if( statbuf.st_size==0 && (pFile->fsFlags & SQLITE_FSFLAGS_IS_MSDOS)!=0 ){\n    do{ rc = osWrite(fd, \"S\", 1); }while( rc<0 && errno==EINTR );\n    if( rc!=1 ){\n      storeLastErrno(pFile, errno);\n      return SQLITE_IOERR;\n    }\n    rc = osFstat(fd, &statbuf);\n    if( rc!=0 ){\n      storeLastErrno(pFile, errno);\n      return SQLITE_IOERR;\n    }\n  }\n#endif\n\n  memset(&fileId, 0, sizeof(fileId));\n  fileId.dev = statbuf.st_dev;\n#if OS_VXWORKS\n  fileId.pId = pFile->pId;\n#else\n  fileId.ino = (u64)statbuf.st_ino;\n#endif\n  assert( unixMutexHeld() );\n  pInode = inodeList;\n  while( pInode && memcmp(&fileId, &pInode->fileId, sizeof(fileId)) ){\n    pInode = pInode->pNext;\n  }\n  if( pInode==0 ){\n    pInode = sqlite3_malloc64( sizeof(*pInode) );\n    if( pInode==0 ){\n      return SQLITE_NOMEM_BKPT;\n    }\n    memset(pInode, 0, sizeof(*pInode));\n    memcpy(&pInode->fileId, &fileId, sizeof(fileId));\n    if( sqlite3GlobalConfig.bCoreMutex ){\n      pInode->pLockMutex = sqlite3_mutex_alloc(SQLITE_MUTEX_FAST);\n      if( pInode->pLockMutex==0 ){\n        sqlite3_free(pInode);\n        return SQLITE_NOMEM_BKPT;\n      }\n    }\n    pInode->nRef = 1;\n    assert( unixMutexHeld() );\n    pInode->pNext = inodeList;\n    pInode->pPrev = 0;\n    if( inodeList ) inodeList->pPrev = pInode;\n    inodeList = pInode;\n  }else{\n    pInode->nRef++;\n  }\n  *ppInode = pInode;\n  return SQLITE_OK;\n}\n\n/*\n** Return TRUE if pFile has been renamed or unlinked since it was first opened.\n*/\nstatic int fileHasMoved(unixFile *pFile){\n#if OS_VXWORKS\n  return pFile->pInode!=0 && pFile->pId!=pFile->pInode->fileId.pId;\n#else\n  struct stat buf;\n  return pFile->pInode!=0 &&\n      (osStat(pFile->zPath, &buf)!=0 \n         || (u64)buf.st_ino!=pFile->pInode->fileId.ino);\n#endif\n}\n\n\n/*\n** Check a unixFile that is a database.  Verify the following:\n**\n** (1) There is exactly one hard link on the file\n** (2) The file is not a symbolic link\n** (3) The file has not been renamed or unlinked\n**\n** Issue sqlite3_log(SQLITE_WARNING,...) messages if anything is not right.\n*/\nstatic void verifyDbFile(unixFile *pFile){\n  struct stat buf;\n  int rc;\n\n  /* These verifications occurs for the main database only */\n  if( pFile->ctrlFlags & UNIXFILE_NOLOCK ) return;\n\n  rc = osFstat(pFile->h, &buf);\n  if( rc!=0 ){\n    sqlite3_log(SQLITE_WARNING, \"cannot fstat db file %s\", pFile->zPath);\n    return;\n  }\n  if( buf.st_nlink==0 ){\n    sqlite3_log(SQLITE_WARNING, \"file unlinked while open: %s\", pFile->zPath);\n    return;\n  }\n  if( buf.st_nlink>1 ){\n    sqlite3_log(SQLITE_WARNING, \"multiple links to file: %s\", pFile->zPath);\n    return;\n  }\n  if( fileHasMoved(pFile) ){\n    sqlite3_log(SQLITE_WARNING, \"file renamed while open: %s\", pFile->zPath);\n    return;\n  }\n}\n\n\n/*\n** This routine checks if there is a RESERVED lock held on the specified\n** file by this or any other process. If such a lock is held, set *pResOut\n** to a non-zero value otherwise *pResOut is set to zero.  The return value\n** is set to SQLITE_OK unless an I/O error occurs during lock checking.\n*/\nstatic int unixCheckReservedLock(sqlite3_file *id, int *pResOut){\n  int rc = SQLITE_OK;\n  int reserved = 0;\n  unixFile *pFile = (unixFile*)id;\n\n  SimulateIOError( return SQLITE_IOERR_CHECKRESERVEDLOCK; );\n\n  assert( pFile );\n  assert( pFile->eFileLock<=SHARED_LOCK );\n  sqlite3_mutex_enter(pFile->pInode->pLockMutex);\n\n  /* Check if a thread in this process holds such a lock */\n  if( pFile->pInode->eFileLock>SHARED_LOCK ){\n    reserved = 1;\n  }\n\n  /* Otherwise see if some other process holds it.\n  */\n#ifndef __DJGPP__\n  if( !reserved && !pFile->pInode->bProcessLock ){\n    struct flock lock;\n    lock.l_whence = SEEK_SET;\n    lock.l_start = RESERVED_BYTE;\n    lock.l_len = 1;\n    lock.l_type = F_WRLCK;\n    if( osFcntl(pFile->h, F_GETLK, &lock) ){\n      rc = SQLITE_IOERR_CHECKRESERVEDLOCK;\n      storeLastErrno(pFile, errno);\n    } else if( lock.l_type!=F_UNLCK ){\n      reserved = 1;\n    }\n  }\n#endif\n  \n  sqlite3_mutex_leave(pFile->pInode->pLockMutex);\n  OSTRACE((\"TEST WR-LOCK %d %d %d (unix)\\n\", pFile->h, rc, reserved));\n\n  *pResOut = reserved;\n  return rc;\n}\n\n/*\n** Set a posix-advisory-lock.\n**\n** There are two versions of this routine.  If compiled with\n** SQLITE_ENABLE_SETLK_TIMEOUT then the routine has an extra parameter\n** which is a pointer to a unixFile.  If the unixFile->iBusyTimeout\n** value is set, then it is the number of milliseconds to wait before\n** failing the lock.  The iBusyTimeout value is always reset back to\n** zero on each call.\n**\n** If SQLITE_ENABLE_SETLK_TIMEOUT is not defined, then do a non-blocking\n** attempt to set the lock.\n*/\n#ifndef SQLITE_ENABLE_SETLK_TIMEOUT\n# define osSetPosixAdvisoryLock(h,x,t) osFcntl(h,F_SETLK,x)\n#else\nstatic int osSetPosixAdvisoryLock(\n  int h,                /* The file descriptor on which to take the lock */\n  struct flock *pLock,  /* The description of the lock */\n  unixFile *pFile       /* Structure holding timeout value */\n){\n  int rc = osFcntl(h,F_SETLK,pLock);\n  while( rc<0 && pFile->iBusyTimeout>0 ){\n    /* On systems that support some kind of blocking file lock with a timeout,\n    ** make appropriate changes here to invoke that blocking file lock.  On\n    ** generic posix, however, there is no such API.  So we simply try the\n    ** lock once every millisecond until either the timeout expires, or until\n    ** the lock is obtained. */\n    usleep(1000);\n    rc = osFcntl(h,F_SETLK,pLock);\n    pFile->iBusyTimeout--;\n  }\n  return rc;\n}\n#endif /* SQLITE_ENABLE_SETLK_TIMEOUT */\n\n\n/*\n** Attempt to set a system-lock on the file pFile.  The lock is \n** described by pLock.\n**\n** If the pFile was opened read/write from unix-excl, then the only lock\n** ever obtained is an exclusive lock, and it is obtained exactly once\n** the first time any lock is attempted.  All subsequent system locking\n** operations become no-ops.  Locking operations still happen internally,\n** in order to coordinate access between separate database connections\n** within this process, but all of that is handled in memory and the\n** operating system does not participate.\n**\n** This function is a pass-through to fcntl(F_SETLK) if pFile is using\n** any VFS other than \"unix-excl\" or if pFile is opened on \"unix-excl\"\n** and is read-only.\n**\n** Zero is returned if the call completes successfully, or -1 if a call\n** to fcntl() fails. In this case, errno is set appropriately (by fcntl()).\n*/\nstatic int unixFileLock(unixFile *pFile, struct flock *pLock){\n  int rc;\n  unixInodeInfo *pInode = pFile->pInode;\n  assert( pInode!=0 );\n  assert( sqlite3_mutex_held(pInode->pLockMutex) );\n  if( (pFile->ctrlFlags & (UNIXFILE_EXCL|UNIXFILE_RDONLY))==UNIXFILE_EXCL ){\n    if( pInode->bProcessLock==0 ){\n      struct flock lock;\n      assert( pInode->nLock==0 );\n      lock.l_whence = SEEK_SET;\n      lock.l_start = SHARED_FIRST;\n      lock.l_len = SHARED_SIZE;\n      lock.l_type = F_WRLCK;\n      rc = osSetPosixAdvisoryLock(pFile->h, &lock, pFile);\n      if( rc<0 ) return rc;\n      pInode->bProcessLock = 1;\n      pInode->nLock++;\n    }else{\n      rc = 0;\n    }\n  }else{\n    rc = osSetPosixAdvisoryLock(pFile->h, pLock, pFile);\n  }\n  return rc;\n}\n\n/*\n** Lock the file with the lock specified by parameter eFileLock - one\n** of the following:\n**\n**     (1) SHARED_LOCK\n**     (2) RESERVED_LOCK\n**     (3) PENDING_LOCK\n**     (4) EXCLUSIVE_LOCK\n**\n** Sometimes when requesting one lock state, additional lock states\n** are inserted in between.  The locking might fail on one of the later\n** transitions leaving the lock state different from what it started but\n** still short of its goal.  The following chart shows the allowed\n** transitions and the inserted intermediate states:\n**\n**    UNLOCKED -> SHARED\n**    SHARED -> RESERVED\n**    SHARED -> (PENDING) -> EXCLUSIVE\n**    RESERVED -> (PENDING) -> EXCLUSIVE\n**    PENDING -> EXCLUSIVE\n**\n** This routine will only increase a lock.  Use the sqlite3OsUnlock()\n** routine to lower a locking level.\n*/\nstatic int unixLock(sqlite3_file *id, int eFileLock){\n  /* The following describes the implementation of the various locks and\n  ** lock transitions in terms of the POSIX advisory shared and exclusive\n  ** lock primitives (called read-locks and write-locks below, to avoid\n  ** confusion with SQLite lock names). The algorithms are complicated\n  ** slightly in order to be compatible with Windows95 systems simultaneously\n  ** accessing the same database file, in case that is ever required.\n  **\n  ** Symbols defined in os.h indentify the 'pending byte' and the 'reserved\n  ** byte', each single bytes at well known offsets, and the 'shared byte\n  ** range', a range of 510 bytes at a well known offset.\n  **\n  ** To obtain a SHARED lock, a read-lock is obtained on the 'pending\n  ** byte'.  If this is successful, 'shared byte range' is read-locked\n  ** and the lock on the 'pending byte' released.  (Legacy note:  When\n  ** SQLite was first developed, Windows95 systems were still very common,\n  ** and Widnows95 lacks a shared-lock capability.  So on Windows95, a\n  ** single randomly selected by from the 'shared byte range' is locked.\n  ** Windows95 is now pretty much extinct, but this work-around for the\n  ** lack of shared-locks on Windows95 lives on, for backwards\n  ** compatibility.)\n  **\n  ** A process may only obtain a RESERVED lock after it has a SHARED lock.\n  ** A RESERVED lock is implemented by grabbing a write-lock on the\n  ** 'reserved byte'. \n  **\n  ** A process may only obtain a PENDING lock after it has obtained a\n  ** SHARED lock. A PENDING lock is implemented by obtaining a write-lock\n  ** on the 'pending byte'. This ensures that no new SHARED locks can be\n  ** obtained, but existing SHARED locks are allowed to persist. A process\n  ** does not have to obtain a RESERVED lock on the way to a PENDING lock.\n  ** This property is used by the algorithm for rolling back a journal file\n  ** after a crash.\n  **\n  ** An EXCLUSIVE lock, obtained after a PENDING lock is held, is\n  ** implemented by obtaining a write-lock on the entire 'shared byte\n  ** range'. Since all other locks require a read-lock on one of the bytes\n  ** within this range, this ensures that no other locks are held on the\n  ** database. \n  */\n  int rc = SQLITE_OK;\n  unixFile *pFile = (unixFile*)id;\n  unixInodeInfo *pInode;\n  struct flock lock;\n  int tErrno = 0;\n\n  assert( pFile );\n  OSTRACE((\"LOCK    %d %s was %s(%s,%d) pid=%d (unix)\\n\", pFile->h,\n      azFileLock(eFileLock), azFileLock(pFile->eFileLock),\n      azFileLock(pFile->pInode->eFileLock), pFile->pInode->nShared,\n      osGetpid(0)));\n\n  /* If there is already a lock of this type or more restrictive on the\n  ** unixFile, do nothing. Don't use the end_lock: exit path, as\n  ** unixEnterMutex() hasn't been called yet.\n  */\n  if( pFile->eFileLock>=eFileLock ){\n    OSTRACE((\"LOCK    %d %s ok (already held) (unix)\\n\", pFile->h,\n            azFileLock(eFileLock)));\n    return SQLITE_OK;\n  }\n\n  /* Make sure the locking sequence is correct.\n  **  (1) We never move from unlocked to anything higher than shared lock.\n  **  (2) SQLite never explicitly requests a pendig lock.\n  **  (3) A shared lock is always held when a reserve lock is requested.\n  */\n  assert( pFile->eFileLock!=NO_LOCK || eFileLock==SHARED_LOCK );\n  assert( eFileLock!=PENDING_LOCK );\n  assert( eFileLock!=RESERVED_LOCK || pFile->eFileLock==SHARED_LOCK );\n\n#ifdef SQLITE_WCDB_LOCK_HOOK\n  if (unixLockHook.xWillLock != NULL) {\n    unixLockHook.xWillLock(unixLockHook.pArg, pFile->zPath, eFileLock);\n  }\n#endif\n    \n  /* This mutex is needed because pFile->pInode is shared across threads\n  */\n  pInode = pFile->pInode;\n  sqlite3_mutex_enter(pInode->pLockMutex);\n\n  /* If some thread using this PID has a lock via a different unixFile*\n  ** handle that precludes the requested lock, return BUSY.\n  */\n  if( (pFile->eFileLock!=pInode->eFileLock && \n          (pInode->eFileLock>=PENDING_LOCK || eFileLock>SHARED_LOCK))\n  ){\n    rc = SQLITE_BUSY;\n    goto end_lock;\n  }\n\n  /* If a SHARED lock is requested, and some thread using this PID already\n  ** has a SHARED or RESERVED lock, then increment reference counts and\n  ** return SQLITE_OK.\n  */\n  if( eFileLock==SHARED_LOCK && \n      (pInode->eFileLock==SHARED_LOCK || pInode->eFileLock==RESERVED_LOCK) ){\n    assert( eFileLock==SHARED_LOCK );\n    assert( pFile->eFileLock==0 );\n    assert( pInode->nShared>0 );\n    pFile->eFileLock = SHARED_LOCK;\n    pInode->nShared++;\n    pInode->nLock++;\n    goto end_lock;\n  }\n\n\n  /* A PENDING lock is needed before acquiring a SHARED lock and before\n  ** acquiring an EXCLUSIVE lock.  For the SHARED lock, the PENDING will\n  ** be released.\n  */\n  lock.l_len = 1L;\n  lock.l_whence = SEEK_SET;\n  if( eFileLock==SHARED_LOCK \n      || (eFileLock==EXCLUSIVE_LOCK && pFile->eFileLock<PENDING_LOCK)\n  ){\n    lock.l_type = (eFileLock==SHARED_LOCK?F_RDLCK:F_WRLCK);\n    lock.l_start = PENDING_BYTE;\n    if( unixFileLock(pFile, &lock) ){\n      tErrno = errno;\n      rc = sqliteErrorFromPosixError(tErrno, SQLITE_IOERR_LOCK);\n      if( rc!=SQLITE_BUSY ){\n        storeLastErrno(pFile, tErrno);\n      }\n      goto end_lock;\n    }\n  }\n\n\n  /* If control gets to this point, then actually go ahead and make\n  ** operating system calls for the specified lock.\n  */\n  if( eFileLock==SHARED_LOCK ){\n    assert( pInode->nShared==0 );\n    assert( pInode->eFileLock==0 );\n    assert( rc==SQLITE_OK );\n\n    /* Now get the read-lock */\n    lock.l_start = SHARED_FIRST;\n    lock.l_len = SHARED_SIZE;\n    if( unixFileLock(pFile, &lock) ){\n      tErrno = errno;\n      rc = sqliteErrorFromPosixError(tErrno, SQLITE_IOERR_LOCK);\n    }\n\n    /* Drop the temporary PENDING lock */\n    lock.l_start = PENDING_BYTE;\n    lock.l_len = 1L;\n    lock.l_type = F_UNLCK;\n    if( unixFileLock(pFile, &lock) && rc==SQLITE_OK ){\n      /* This could happen with a network mount */\n      tErrno = errno;\n      rc = SQLITE_IOERR_UNLOCK; \n    }\n\n    if( rc ){\n      if( rc!=SQLITE_BUSY ){\n        storeLastErrno(pFile, tErrno);\n      }\n      goto end_lock;\n    }else{\n      pFile->eFileLock = SHARED_LOCK;\n      pInode->nLock++;\n      pInode->nShared = 1;\n    }\n  }else if( eFileLock==EXCLUSIVE_LOCK && pInode->nShared>1 ){\n    /* We are trying for an exclusive lock but another thread in this\n    ** same process is still holding a shared lock. */\n    rc = SQLITE_BUSY;\n  }else{\n    /* The request was for a RESERVED or EXCLUSIVE lock.  It is\n    ** assumed that there is a SHARED or greater lock on the file\n    ** already.\n    */\n    assert( 0!=pFile->eFileLock );\n    lock.l_type = F_WRLCK;\n\n    assert( eFileLock==RESERVED_LOCK || eFileLock==EXCLUSIVE_LOCK );\n    if( eFileLock==RESERVED_LOCK ){\n      lock.l_start = RESERVED_BYTE;\n      lock.l_len = 1L;\n    }else{\n      lock.l_start = SHARED_FIRST;\n      lock.l_len = SHARED_SIZE;\n    }\n\n    if( unixFileLock(pFile, &lock) ){\n      tErrno = errno;\n      rc = sqliteErrorFromPosixError(tErrno, SQLITE_IOERR_LOCK);\n      if( rc!=SQLITE_BUSY ){\n        storeLastErrno(pFile, tErrno);\n      }\n    }\n  }\n  \n\n#ifdef SQLITE_DEBUG\n  /* Set up the transaction-counter change checking flags when\n  ** transitioning from a SHARED to a RESERVED lock.  The change\n  ** from SHARED to RESERVED marks the beginning of a normal\n  ** write operation (not a hot journal rollback).\n  */\n  if( rc==SQLITE_OK\n   && pFile->eFileLock<=SHARED_LOCK\n   && eFileLock==RESERVED_LOCK\n  ){\n    pFile->transCntrChng = 0;\n    pFile->dbUpdate = 0;\n    pFile->inNormalWrite = 1;\n  }\n#endif\n\n\n  if( rc==SQLITE_OK ){\n    pFile->eFileLock = eFileLock;\n    pInode->eFileLock = eFileLock;\n#ifdef SQLITE_WCDB_LOCK_HOOK\n    if (unixLockHook.xLockDidChange != NULL) {\n      unixLockHook.xLockDidChange(unixLockHook.pArg, pFile->zPath, pInode->eFileLock);\n    }\n#endif\n  }else if( eFileLock==EXCLUSIVE_LOCK ){\n    pFile->eFileLock = PENDING_LOCK;\n    pInode->eFileLock = PENDING_LOCK;\n#ifdef SQLITE_WCDB_LOCK_HOOK\n    if (unixLockHook.xLockDidChange != NULL) {\n      unixLockHook.xLockDidChange(unixLockHook.pArg, pFile->zPath, pInode->eFileLock);\n    }\n#endif\n  }\n\nend_lock:\n  sqlite3_mutex_leave(pInode->pLockMutex);\n  OSTRACE((\"LOCK    %d %s %s (unix)\\n\", pFile->h, azFileLock(eFileLock), \n      rc==SQLITE_OK ? \"ok\" : \"failed\"));\n  return rc;\n}\n\n/*\n** Add the file descriptor used by file handle pFile to the corresponding\n** pUnused list.\n*/\nstatic void setPendingFd(unixFile *pFile){\n  unixInodeInfo *pInode = pFile->pInode;\n  UnixUnusedFd *p = pFile->pPreallocatedUnused;\n  assert( unixFileMutexHeld(pFile) );\n  p->pNext = pInode->pUnused;\n  pInode->pUnused = p;\n  pFile->h = -1;\n  pFile->pPreallocatedUnused = 0;\n}\n\n/*\n** Lower the locking level on file descriptor pFile to eFileLock.  eFileLock\n** must be either NO_LOCK or SHARED_LOCK.\n**\n** If the locking level of the file descriptor is already at or below\n** the requested locking level, this routine is a no-op.\n** \n** If handleNFSUnlock is true, then on downgrading an EXCLUSIVE_LOCK to SHARED\n** the byte range is divided into 2 parts and the first part is unlocked then\n** set to a read lock, then the other part is simply unlocked.  This works \n** around a bug in BSD NFS lockd (also seen on MacOSX 10.3+) that fails to \n** remove the write lock on a region when a read lock is set.\n*/\nstatic int posixUnlock(sqlite3_file *id, int eFileLock, int handleNFSUnlock){\n  unixFile *pFile = (unixFile*)id;\n  unixInodeInfo *pInode;\n  struct flock lock;\n  int rc = SQLITE_OK;\n\n  assert( pFile );\n  OSTRACE((\"UNLOCK  %d %d was %d(%d,%d) pid=%d (unix)\\n\", pFile->h, eFileLock,\n      pFile->eFileLock, pFile->pInode->eFileLock, pFile->pInode->nShared,\n      osGetpid(0)));\n\n  assert( eFileLock<=SHARED_LOCK );\n  if( pFile->eFileLock<=eFileLock ){\n    return SQLITE_OK;\n  }\n  pInode = pFile->pInode;\n  sqlite3_mutex_enter(pInode->pLockMutex);\n  assert( pInode->nShared!=0 );\n  if( pFile->eFileLock>SHARED_LOCK ){\n    assert( pInode->eFileLock==pFile->eFileLock );\n\n#ifdef SQLITE_DEBUG\n    /* When reducing a lock such that other processes can start\n    ** reading the database file again, make sure that the\n    ** transaction counter was updated if any part of the database\n    ** file changed.  If the transaction counter is not updated,\n    ** other connections to the same file might not realize that\n    ** the file has changed and hence might not know to flush their\n    ** cache.  The use of a stale cache can lead to database corruption.\n    */\n    pFile->inNormalWrite = 0;\n#endif\n\n    /* downgrading to a shared lock on NFS involves clearing the write lock\n    ** before establishing the readlock - to avoid a race condition we downgrade\n    ** the lock in 2 blocks, so that part of the range will be covered by a \n    ** write lock until the rest is covered by a read lock:\n    **  1:   [WWWWW]\n    **  2:   [....W]\n    **  3:   [RRRRW]\n    **  4:   [RRRR.]\n    */\n    if( eFileLock==SHARED_LOCK ){\n#if !defined(__APPLE__) || !SQLITE_ENABLE_LOCKING_STYLE\n      (void)handleNFSUnlock;\n      assert( handleNFSUnlock==0 );\n#endif\n#if defined(__APPLE__) && SQLITE_ENABLE_LOCKING_STYLE\n      if( handleNFSUnlock ){\n        int tErrno;               /* Error code from system call errors */\n        off_t divSize = SHARED_SIZE - 1;\n        \n        lock.l_type = F_UNLCK;\n        lock.l_whence = SEEK_SET;\n        lock.l_start = SHARED_FIRST;\n        lock.l_len = divSize;\n        if( unixFileLock(pFile, &lock)==(-1) ){\n          tErrno = errno;\n          rc = SQLITE_IOERR_UNLOCK;\n          storeLastErrno(pFile, tErrno);\n          goto end_unlock;\n        }\n        lock.l_type = F_RDLCK;\n        lock.l_whence = SEEK_SET;\n        lock.l_start = SHARED_FIRST;\n        lock.l_len = divSize;\n        if( unixFileLock(pFile, &lock)==(-1) ){\n          tErrno = errno;\n          rc = sqliteErrorFromPosixError(tErrno, SQLITE_IOERR_RDLOCK);\n          if( IS_LOCK_ERROR(rc) ){\n            storeLastErrno(pFile, tErrno);\n          }\n          goto end_unlock;\n        }\n        lock.l_type = F_UNLCK;\n        lock.l_whence = SEEK_SET;\n        lock.l_start = SHARED_FIRST+divSize;\n        lock.l_len = SHARED_SIZE-divSize;\n        if( unixFileLock(pFile, &lock)==(-1) ){\n          tErrno = errno;\n          rc = SQLITE_IOERR_UNLOCK;\n          storeLastErrno(pFile, tErrno);\n          goto end_unlock;\n        }\n      }else\n#endif /* defined(__APPLE__) && SQLITE_ENABLE_LOCKING_STYLE */\n      {\n        lock.l_type = F_RDLCK;\n        lock.l_whence = SEEK_SET;\n        lock.l_start = SHARED_FIRST;\n        lock.l_len = SHARED_SIZE;\n        if( unixFileLock(pFile, &lock) ){\n          /* In theory, the call to unixFileLock() cannot fail because another\n          ** process is holding an incompatible lock. If it does, this \n          ** indicates that the other process is not following the locking\n          ** protocol. If this happens, return SQLITE_IOERR_RDLOCK. Returning\n          ** SQLITE_BUSY would confuse the upper layer (in practice it causes \n          ** an assert to fail). */ \n          rc = SQLITE_IOERR_RDLOCK;\n          storeLastErrno(pFile, errno);\n          goto end_unlock;\n        }\n      }\n    }\n    lock.l_type = F_UNLCK;\n    lock.l_whence = SEEK_SET;\n    lock.l_start = PENDING_BYTE;\n    lock.l_len = 2L;  assert( PENDING_BYTE+1==RESERVED_BYTE );\n    if( unixFileLock(pFile, &lock)==0 ){\n      pInode->eFileLock = SHARED_LOCK;\n#ifdef SQLITE_WCDB_LOCK_HOOK\n      if (unixLockHook.xLockDidChange != NULL) {\n        unixLockHook.xLockDidChange(unixLockHook.pArg, pFile->zPath, pInode->eFileLock);\n      }\n#endif\n    }else{\n      rc = SQLITE_IOERR_UNLOCK;\n      storeLastErrno(pFile, errno);\n      goto end_unlock;\n    }\n  }\n  if( eFileLock==NO_LOCK ){\n    /* Decrement the shared lock counter.  Release the lock using an\n    ** OS call only when all threads in this same process have released\n    ** the lock.\n    */\n    pInode->nShared--;\n    if( pInode->nShared==0 ){\n      lock.l_type = F_UNLCK;\n      lock.l_whence = SEEK_SET;\n      lock.l_start = lock.l_len = 0L;\n      if( unixFileLock(pFile, &lock)==0 ){\n        pInode->eFileLock = NO_LOCK;\n#ifdef SQLITE_WCDB_LOCK_HOOK\n        if (unixLockHook.xLockDidChange != NULL) {\n          unixLockHook.xLockDidChange(unixLockHook.pArg, pFile->zPath, pInode->eFileLock);\n        }\n#endif\n      }else{\n        rc = SQLITE_IOERR_UNLOCK;\n        storeLastErrno(pFile, errno);\n        pInode->eFileLock = NO_LOCK;\n        pFile->eFileLock = NO_LOCK;\n#ifdef SQLITE_WCDB_LOCK_HOOK\n        if (unixLockHook.xLockDidChange != NULL) {\n          unixLockHook.xLockDidChange(unixLockHook.pArg, pFile->zPath, pInode->eFileLock);\n        }\n#endif\n      }\n    }\n\n    /* Decrement the count of locks against this same file.  When the\n    ** count reaches zero, close any other file descriptors whose close\n    ** was deferred because of outstanding locks.\n    */\n    pInode->nLock--;\n    assert( pInode->nLock>=0 );\n    if( pInode->nLock==0 ) closePendingFds(pFile);\n  }\n  \nend_unlock:\n  sqlite3_mutex_leave(pInode->pLockMutex);\n  if( rc==SQLITE_OK ){\n    pFile->eFileLock = eFileLock;\n  }\n  return rc;\n}\n\n/*\n** Lower the locking level on file descriptor pFile to eFileLock.  eFileLock\n** must be either NO_LOCK or SHARED_LOCK.\n**\n** If the locking level of the file descriptor is already at or below\n** the requested locking level, this routine is a no-op.\n*/\nstatic int unixUnlock(sqlite3_file *id, int eFileLock){\n#if SQLITE_MAX_MMAP_SIZE>0\n  assert( eFileLock==SHARED_LOCK || ((unixFile *)id)->nFetchOut==0 );\n#endif\n  return posixUnlock(id, eFileLock, 0);\n}\n\n#if SQLITE_MAX_MMAP_SIZE>0\nstatic int unixMapfile(unixFile *pFd, i64 nByte);\nstatic void unixUnmapfile(unixFile *pFd);\n#endif\n\n/*\n** This function performs the parts of the \"close file\" operation \n** common to all locking schemes. It closes the directory and file\n** handles, if they are valid, and sets all fields of the unixFile\n** structure to 0.\n**\n** It is *not* necessary to hold the mutex when this routine is called,\n** even on VxWorks.  A mutex will be acquired on VxWorks by the\n** vxworksReleaseFileId() routine.\n*/\nstatic int closeUnixFile(sqlite3_file *id){\n  unixFile *pFile = (unixFile*)id;\n#if SQLITE_MAX_MMAP_SIZE>0\n  unixUnmapfile(pFile);\n#endif\n  if( pFile->h>=0 ){\n    robust_close(pFile, pFile->h, __LINE__);\n    pFile->h = -1;\n  }\n#if OS_VXWORKS\n  if( pFile->pId ){\n    if( pFile->ctrlFlags & UNIXFILE_DELETE ){\n      osUnlink(pFile->pId->zCanonicalName);\n    }\n    vxworksReleaseFileId(pFile->pId);\n    pFile->pId = 0;\n  }\n#endif\n#ifdef SQLITE_UNLINK_AFTER_CLOSE\n  if( pFile->ctrlFlags & UNIXFILE_DELETE ){\n    osUnlink(pFile->zPath);\n    sqlite3_free(*(char**)&pFile->zPath);\n    pFile->zPath = 0;\n  }\n#endif\n  OSTRACE((\"CLOSE   %-3d\\n\", pFile->h));\n  OpenCounter(-1);\n  sqlite3_free(pFile->pPreallocatedUnused);\n  memset(pFile, 0, sizeof(unixFile));\n  return SQLITE_OK;\n}\n\n/*\n** Close a file.\n*/\nstatic int unixClose(sqlite3_file *id){\n  int rc = SQLITE_OK;\n  unixFile *pFile = (unixFile *)id;\n  unixInodeInfo *pInode = pFile->pInode;\n\n  assert( pInode!=0 );\n  verifyDbFile(pFile);\n  unixUnlock(id, NO_LOCK);\n  assert( unixFileMutexNotheld(pFile) );\n  unixEnterMutex();\n\n  /* unixFile.pInode is always valid here. Otherwise, a different close\n  ** routine (e.g. nolockClose()) would be called instead.\n  */\n  assert( pFile->pInode->nLock>0 || pFile->pInode->bProcessLock==0 );\n  sqlite3_mutex_enter(pInode->pLockMutex);\n  if( pInode->nLock ){\n    /* If there are outstanding locks, do not actually close the file just\n    ** yet because that would clear those locks.  Instead, add the file\n    ** descriptor to pInode->pUnused list.  It will be automatically closed \n    ** when the last lock is cleared.\n    */\n    setPendingFd(pFile);\n  }\n  sqlite3_mutex_leave(pInode->pLockMutex);\n  releaseInodeInfo(pFile);\n  rc = closeUnixFile(id);\n  unixLeaveMutex();\n  return rc;\n}\n\n/************** End of the posix advisory lock implementation *****************\n******************************************************************************/\n\n/******************************************************************************\n****************************** No-op Locking **********************************\n**\n** Of the various locking implementations available, this is by far the\n** simplest:  locking is ignored.  No attempt is made to lock the database\n** file for reading or writing.\n**\n** This locking mode is appropriate for use on read-only databases\n** (ex: databases that are burned into CD-ROM, for example.)  It can\n** also be used if the application employs some external mechanism to\n** prevent simultaneous access of the same database by two or more\n** database connections.  But there is a serious risk of database\n** corruption if this locking mode is used in situations where multiple\n** database connections are accessing the same database file at the same\n** time and one or more of those connections are writing.\n*/\n\nstatic int nolockCheckReservedLock(sqlite3_file *NotUsed, int *pResOut){\n  UNUSED_PARAMETER(NotUsed);\n  *pResOut = 0;\n  return SQLITE_OK;\n}\nstatic int nolockLock(sqlite3_file *NotUsed, int NotUsed2){\n  UNUSED_PARAMETER2(NotUsed, NotUsed2);\n  return SQLITE_OK;\n}\nstatic int nolockUnlock(sqlite3_file *NotUsed, int NotUsed2){\n  UNUSED_PARAMETER2(NotUsed, NotUsed2);\n  return SQLITE_OK;\n}\n\n/*\n** Close the file.\n*/\nstatic int nolockClose(sqlite3_file *id) {\n  return closeUnixFile(id);\n}\n\n/******************* End of the no-op lock implementation *********************\n******************************************************************************/\n\n/******************************************************************************\n************************* Begin dot-file Locking ******************************\n**\n** The dotfile locking implementation uses the existence of separate lock\n** files (really a directory) to control access to the database.  This works\n** on just about every filesystem imaginable.  But there are serious downsides:\n**\n**    (1)  There is zero concurrency.  A single reader blocks all other\n**         connections from reading or writing the database.\n**\n**    (2)  An application crash or power loss can leave stale lock files\n**         sitting around that need to be cleared manually.\n**\n** Nevertheless, a dotlock is an appropriate locking mode for use if no\n** other locking strategy is available.\n**\n** Dotfile locking works by creating a subdirectory in the same directory as\n** the database and with the same name but with a \".lock\" extension added.\n** The existence of a lock directory implies an EXCLUSIVE lock.  All other\n** lock types (SHARED, RESERVED, PENDING) are mapped into EXCLUSIVE.\n*/\n\n/*\n** The file suffix added to the data base filename in order to create the\n** lock directory.\n*/\n#define DOTLOCK_SUFFIX \".lock\"\n\n/*\n** This routine checks if there is a RESERVED lock held on the specified\n** file by this or any other process. If such a lock is held, set *pResOut\n** to a non-zero value otherwise *pResOut is set to zero.  The return value\n** is set to SQLITE_OK unless an I/O error occurs during lock checking.\n**\n** In dotfile locking, either a lock exists or it does not.  So in this\n** variation of CheckReservedLock(), *pResOut is set to true if any lock\n** is held on the file and false if the file is unlocked.\n*/\nstatic int dotlockCheckReservedLock(sqlite3_file *id, int *pResOut) {\n  int rc = SQLITE_OK;\n  int reserved = 0;\n  unixFile *pFile = (unixFile*)id;\n\n  SimulateIOError( return SQLITE_IOERR_CHECKRESERVEDLOCK; );\n  \n  assert( pFile );\n  reserved = osAccess((const char*)pFile->lockingContext, 0)==0;\n  OSTRACE((\"TEST WR-LOCK %d %d %d (dotlock)\\n\", pFile->h, rc, reserved));\n  *pResOut = reserved;\n  return rc;\n}\n\n/*\n** Lock the file with the lock specified by parameter eFileLock - one\n** of the following:\n**\n**     (1) SHARED_LOCK\n**     (2) RESERVED_LOCK\n**     (3) PENDING_LOCK\n**     (4) EXCLUSIVE_LOCK\n**\n** Sometimes when requesting one lock state, additional lock states\n** are inserted in between.  The locking might fail on one of the later\n** transitions leaving the lock state different from what it started but\n** still short of its goal.  The following chart shows the allowed\n** transitions and the inserted intermediate states:\n**\n**    UNLOCKED -> SHARED\n**    SHARED -> RESERVED\n**    SHARED -> (PENDING) -> EXCLUSIVE\n**    RESERVED -> (PENDING) -> EXCLUSIVE\n**    PENDING -> EXCLUSIVE\n**\n** This routine will only increase a lock.  Use the sqlite3OsUnlock()\n** routine to lower a locking level.\n**\n** With dotfile locking, we really only support state (4): EXCLUSIVE.\n** But we track the other locking levels internally.\n*/\nstatic int dotlockLock(sqlite3_file *id, int eFileLock) {\n  unixFile *pFile = (unixFile*)id;\n  char *zLockFile = (char *)pFile->lockingContext;\n  int rc = SQLITE_OK;\n\n\n  /* If we have any lock, then the lock file already exists.  All we have\n  ** to do is adjust our internal record of the lock level.\n  */\n  if( pFile->eFileLock > NO_LOCK ){\n    pFile->eFileLock = eFileLock;\n    /* Always update the timestamp on the old file */\n#ifdef HAVE_UTIME\n    utime(zLockFile, NULL);\n#else\n    utimes(zLockFile, NULL);\n#endif\n    return SQLITE_OK;\n  }\n  \n  /* grab an exclusive lock */\n  rc = osMkdir(zLockFile, 0777);\n  if( rc<0 ){\n    /* failed to open/create the lock directory */\n    int tErrno = errno;\n    if( EEXIST == tErrno ){\n      rc = SQLITE_BUSY;\n    } else {\n      rc = sqliteErrorFromPosixError(tErrno, SQLITE_IOERR_LOCK);\n      if( rc!=SQLITE_BUSY ){\n        storeLastErrno(pFile, tErrno);\n      }\n    }\n    return rc;\n  } \n  \n  /* got it, set the type and return ok */\n  pFile->eFileLock = eFileLock;\n  return rc;\n}\n\n/*\n** Lower the locking level on file descriptor pFile to eFileLock.  eFileLock\n** must be either NO_LOCK or SHARED_LOCK.\n**\n** If the locking level of the file descriptor is already at or below\n** the requested locking level, this routine is a no-op.\n**\n** When the locking level reaches NO_LOCK, delete the lock file.\n*/\nstatic int dotlockUnlock(sqlite3_file *id, int eFileLock) {\n  unixFile *pFile = (unixFile*)id;\n  char *zLockFile = (char *)pFile->lockingContext;\n  int rc;\n\n  assert( pFile );\n  OSTRACE((\"UNLOCK  %d %d was %d pid=%d (dotlock)\\n\", pFile->h, eFileLock,\n           pFile->eFileLock, osGetpid(0)));\n  assert( eFileLock<=SHARED_LOCK );\n  \n  /* no-op if possible */\n  if( pFile->eFileLock==eFileLock ){\n    return SQLITE_OK;\n  }\n\n  /* To downgrade to shared, simply update our internal notion of the\n  ** lock state.  No need to mess with the file on disk.\n  */\n  if( eFileLock==SHARED_LOCK ){\n    pFile->eFileLock = SHARED_LOCK;\n    return SQLITE_OK;\n  }\n  \n  /* To fully unlock the database, delete the lock file */\n  assert( eFileLock==NO_LOCK );\n  rc = osRmdir(zLockFile);\n  if( rc<0 ){\n    int tErrno = errno;\n    if( tErrno==ENOENT ){\n      rc = SQLITE_OK;\n    }else{\n      rc = SQLITE_IOERR_UNLOCK;\n      storeLastErrno(pFile, tErrno);\n    }\n    return rc; \n  }\n  pFile->eFileLock = NO_LOCK;\n  return SQLITE_OK;\n}\n\n/*\n** Close a file.  Make sure the lock has been released before closing.\n*/\nstatic int dotlockClose(sqlite3_file *id) {\n  unixFile *pFile = (unixFile*)id;\n  assert( id!=0 );\n  dotlockUnlock(id, NO_LOCK);\n  sqlite3_free(pFile->lockingContext);\n  return closeUnixFile(id);\n}\n/****************** End of the dot-file lock implementation *******************\n******************************************************************************/\n\n/******************************************************************************\n************************** Begin flock Locking ********************************\n**\n** Use the flock() system call to do file locking.\n**\n** flock() locking is like dot-file locking in that the various\n** fine-grain locking levels supported by SQLite are collapsed into\n** a single exclusive lock.  In other words, SHARED, RESERVED, and\n** PENDING locks are the same thing as an EXCLUSIVE lock.  SQLite\n** still works when you do this, but concurrency is reduced since\n** only a single process can be reading the database at a time.\n**\n** Omit this section if SQLITE_ENABLE_LOCKING_STYLE is turned off\n*/\n#if SQLITE_ENABLE_LOCKING_STYLE\n\n/*\n** Retry flock() calls that fail with EINTR\n*/\n#ifdef EINTR\nstatic int robust_flock(int fd, int op){\n  int rc;\n  do{ rc = flock(fd,op); }while( rc<0 && errno==EINTR );\n  return rc;\n}\n#else\n# define robust_flock(a,b) flock(a,b)\n#endif\n     \n\n/*\n** This routine checks if there is a RESERVED lock held on the specified\n** file by this or any other process. If such a lock is held, set *pResOut\n** to a non-zero value otherwise *pResOut is set to zero.  The return value\n** is set to SQLITE_OK unless an I/O error occurs during lock checking.\n*/\nstatic int flockCheckReservedLock(sqlite3_file *id, int *pResOut){\n  int rc = SQLITE_OK;\n  int reserved = 0;\n  unixFile *pFile = (unixFile*)id;\n  \n  SimulateIOError( return SQLITE_IOERR_CHECKRESERVEDLOCK; );\n  \n  assert( pFile );\n  \n  /* Check if a thread in this process holds such a lock */\n  if( pFile->eFileLock>SHARED_LOCK ){\n    reserved = 1;\n  }\n  \n  /* Otherwise see if some other process holds it. */\n  if( !reserved ){\n    /* attempt to get the lock */\n    int lrc = robust_flock(pFile->h, LOCK_EX | LOCK_NB);\n    if( !lrc ){\n      /* got the lock, unlock it */\n      lrc = robust_flock(pFile->h, LOCK_UN);\n      if ( lrc ) {\n        int tErrno = errno;\n        /* unlock failed with an error */\n        lrc = SQLITE_IOERR_UNLOCK; \n        storeLastErrno(pFile, tErrno);\n        rc = lrc;\n      }\n    } else {\n      int tErrno = errno;\n      reserved = 1;\n      /* someone else might have it reserved */\n      lrc = sqliteErrorFromPosixError(tErrno, SQLITE_IOERR_LOCK); \n      if( IS_LOCK_ERROR(lrc) ){\n        storeLastErrno(pFile, tErrno);\n        rc = lrc;\n      }\n    }\n  }\n  OSTRACE((\"TEST WR-LOCK %d %d %d (flock)\\n\", pFile->h, rc, reserved));\n\n#ifdef SQLITE_IGNORE_FLOCK_LOCK_ERRORS\n  if( (rc & 0xff) == SQLITE_IOERR ){\n    rc = SQLITE_OK;\n    reserved=1;\n  }\n#endif /* SQLITE_IGNORE_FLOCK_LOCK_ERRORS */\n  *pResOut = reserved;\n  return rc;\n}\n\n/*\n** Lock the file with the lock specified by parameter eFileLock - one\n** of the following:\n**\n**     (1) SHARED_LOCK\n**     (2) RESERVED_LOCK\n**     (3) PENDING_LOCK\n**     (4) EXCLUSIVE_LOCK\n**\n** Sometimes when requesting one lock state, additional lock states\n** are inserted in between.  The locking might fail on one of the later\n** transitions leaving the lock state different from what it started but\n** still short of its goal.  The following chart shows the allowed\n** transitions and the inserted intermediate states:\n**\n**    UNLOCKED -> SHARED\n**    SHARED -> RESERVED\n**    SHARED -> (PENDING) -> EXCLUSIVE\n**    RESERVED -> (PENDING) -> EXCLUSIVE\n**    PENDING -> EXCLUSIVE\n**\n** flock() only really support EXCLUSIVE locks.  We track intermediate\n** lock states in the sqlite3_file structure, but all locks SHARED or\n** above are really EXCLUSIVE locks and exclude all other processes from\n** access the file.\n**\n** This routine will only increase a lock.  Use the sqlite3OsUnlock()\n** routine to lower a locking level.\n*/\nstatic int flockLock(sqlite3_file *id, int eFileLock) {\n  int rc = SQLITE_OK;\n  unixFile *pFile = (unixFile*)id;\n\n  assert( pFile );\n\n  /* if we already have a lock, it is exclusive.  \n  ** Just adjust level and punt on outta here. */\n  if (pFile->eFileLock > NO_LOCK) {\n    pFile->eFileLock = eFileLock;\n    return SQLITE_OK;\n  }\n  \n  /* grab an exclusive lock */\n  \n  if (robust_flock(pFile->h, LOCK_EX | LOCK_NB)) {\n    int tErrno = errno;\n    /* didn't get, must be busy */\n    rc = sqliteErrorFromPosixError(tErrno, SQLITE_IOERR_LOCK);\n    if( IS_LOCK_ERROR(rc) ){\n      storeLastErrno(pFile, tErrno);\n    }\n  } else {\n    /* got it, set the type and return ok */\n    pFile->eFileLock = eFileLock;\n  }\n  OSTRACE((\"LOCK    %d %s %s (flock)\\n\", pFile->h, azFileLock(eFileLock), \n           rc==SQLITE_OK ? \"ok\" : \"failed\"));\n#ifdef SQLITE_IGNORE_FLOCK_LOCK_ERRORS\n  if( (rc & 0xff) == SQLITE_IOERR ){\n    rc = SQLITE_BUSY;\n  }\n#endif /* SQLITE_IGNORE_FLOCK_LOCK_ERRORS */\n  return rc;\n}\n\n\n/*\n** Lower the locking level on file descriptor pFile to eFileLock.  eFileLock\n** must be either NO_LOCK or SHARED_LOCK.\n**\n** If the locking level of the file descriptor is already at or below\n** the requested locking level, this routine is a no-op.\n*/\nstatic int flockUnlock(sqlite3_file *id, int eFileLock) {\n  unixFile *pFile = (unixFile*)id;\n  \n  assert( pFile );\n  OSTRACE((\"UNLOCK  %d %d was %d pid=%d (flock)\\n\", pFile->h, eFileLock,\n           pFile->eFileLock, osGetpid(0)));\n  assert( eFileLock<=SHARED_LOCK );\n  \n  /* no-op if possible */\n  if( pFile->eFileLock==eFileLock ){\n    return SQLITE_OK;\n  }\n  \n  /* shared can just be set because we always have an exclusive */\n  if (eFileLock==SHARED_LOCK) {\n    pFile->eFileLock = eFileLock;\n    return SQLITE_OK;\n  }\n  \n  /* no, really, unlock. */\n  if( robust_flock(pFile->h, LOCK_UN) ){\n#ifdef SQLITE_IGNORE_FLOCK_LOCK_ERRORS\n    return SQLITE_OK;\n#endif /* SQLITE_IGNORE_FLOCK_LOCK_ERRORS */\n    return SQLITE_IOERR_UNLOCK;\n  }else{\n    pFile->eFileLock = NO_LOCK;\n    return SQLITE_OK;\n  }\n}\n\n/*\n** Close a file.\n*/\nstatic int flockClose(sqlite3_file *id) {\n  assert( id!=0 );\n  flockUnlock(id, NO_LOCK);\n  return closeUnixFile(id);\n}\n\n#endif /* SQLITE_ENABLE_LOCKING_STYLE && !OS_VXWORK */\n\n/******************* End of the flock lock implementation *********************\n******************************************************************************/\n\n/******************************************************************************\n************************ Begin Named Semaphore Locking ************************\n**\n** Named semaphore locking is only supported on VxWorks.\n**\n** Semaphore locking is like dot-lock and flock in that it really only\n** supports EXCLUSIVE locking.  Only a single process can read or write\n** the database file at a time.  This reduces potential concurrency, but\n** makes the lock implementation much easier.\n*/\n#if OS_VXWORKS\n\n/*\n** This routine checks if there is a RESERVED lock held on the specified\n** file by this or any other process. If such a lock is held, set *pResOut\n** to a non-zero value otherwise *pResOut is set to zero.  The return value\n** is set to SQLITE_OK unless an I/O error occurs during lock checking.\n*/\nstatic int semXCheckReservedLock(sqlite3_file *id, int *pResOut) {\n  int rc = SQLITE_OK;\n  int reserved = 0;\n  unixFile *pFile = (unixFile*)id;\n\n  SimulateIOError( return SQLITE_IOERR_CHECKRESERVEDLOCK; );\n  \n  assert( pFile );\n\n  /* Check if a thread in this process holds such a lock */\n  if( pFile->eFileLock>SHARED_LOCK ){\n    reserved = 1;\n  }\n  \n  /* Otherwise see if some other process holds it. */\n  if( !reserved ){\n    sem_t *pSem = pFile->pInode->pSem;\n\n    if( sem_trywait(pSem)==-1 ){\n      int tErrno = errno;\n      if( EAGAIN != tErrno ){\n        rc = sqliteErrorFromPosixError(tErrno, SQLITE_IOERR_CHECKRESERVEDLOCK);\n        storeLastErrno(pFile, tErrno);\n      } else {\n        /* someone else has the lock when we are in NO_LOCK */\n        reserved = (pFile->eFileLock < SHARED_LOCK);\n      }\n    }else{\n      /* we could have it if we want it */\n      sem_post(pSem);\n    }\n  }\n  OSTRACE((\"TEST WR-LOCK %d %d %d (sem)\\n\", pFile->h, rc, reserved));\n\n  *pResOut = reserved;\n  return rc;\n}\n\n/*\n** Lock the file with the lock specified by parameter eFileLock - one\n** of the following:\n**\n**     (1) SHARED_LOCK\n**     (2) RESERVED_LOCK\n**     (3) PENDING_LOCK\n**     (4) EXCLUSIVE_LOCK\n**\n** Sometimes when requesting one lock state, additional lock states\n** are inserted in between.  The locking might fail on one of the later\n** transitions leaving the lock state different from what it started but\n** still short of its goal.  The following chart shows the allowed\n** transitions and the inserted intermediate states:\n**\n**    UNLOCKED -> SHARED\n**    SHARED -> RESERVED\n**    SHARED -> (PENDING) -> EXCLUSIVE\n**    RESERVED -> (PENDING) -> EXCLUSIVE\n**    PENDING -> EXCLUSIVE\n**\n** Semaphore locks only really support EXCLUSIVE locks.  We track intermediate\n** lock states in the sqlite3_file structure, but all locks SHARED or\n** above are really EXCLUSIVE locks and exclude all other processes from\n** access the file.\n**\n** This routine will only increase a lock.  Use the sqlite3OsUnlock()\n** routine to lower a locking level.\n*/\nstatic int semXLock(sqlite3_file *id, int eFileLock) {\n  unixFile *pFile = (unixFile*)id;\n  sem_t *pSem = pFile->pInode->pSem;\n  int rc = SQLITE_OK;\n\n  /* if we already have a lock, it is exclusive.  \n  ** Just adjust level and punt on outta here. */\n  if (pFile->eFileLock > NO_LOCK) {\n    pFile->eFileLock = eFileLock;\n    rc = SQLITE_OK;\n    goto sem_end_lock;\n  }\n  \n  /* lock semaphore now but bail out when already locked. */\n  if( sem_trywait(pSem)==-1 ){\n    rc = SQLITE_BUSY;\n    goto sem_end_lock;\n  }\n\n  /* got it, set the type and return ok */\n  pFile->eFileLock = eFileLock;\n\n sem_end_lock:\n  return rc;\n}\n\n/*\n** Lower the locking level on file descriptor pFile to eFileLock.  eFileLock\n** must be either NO_LOCK or SHARED_LOCK.\n**\n** If the locking level of the file descriptor is already at or below\n** the requested locking level, this routine is a no-op.\n*/\nstatic int semXUnlock(sqlite3_file *id, int eFileLock) {\n  unixFile *pFile = (unixFile*)id;\n  sem_t *pSem = pFile->pInode->pSem;\n\n  assert( pFile );\n  assert( pSem );\n  OSTRACE((\"UNLOCK  %d %d was %d pid=%d (sem)\\n\", pFile->h, eFileLock,\n           pFile->eFileLock, osGetpid(0)));\n  assert( eFileLock<=SHARED_LOCK );\n  \n  /* no-op if possible */\n  if( pFile->eFileLock==eFileLock ){\n    return SQLITE_OK;\n  }\n  \n  /* shared can just be set because we always have an exclusive */\n  if (eFileLock==SHARED_LOCK) {\n    pFile->eFileLock = eFileLock;\n    return SQLITE_OK;\n  }\n  \n  /* no, really unlock. */\n  if ( sem_post(pSem)==-1 ) {\n    int rc, tErrno = errno;\n    rc = sqliteErrorFromPosixError(tErrno, SQLITE_IOERR_UNLOCK);\n    if( IS_LOCK_ERROR(rc) ){\n      storeLastErrno(pFile, tErrno);\n    }\n    return rc; \n  }\n  pFile->eFileLock = NO_LOCK;\n  return SQLITE_OK;\n}\n\n/*\n ** Close a file.\n */\nstatic int semXClose(sqlite3_file *id) {\n  if( id ){\n    unixFile *pFile = (unixFile*)id;\n    semXUnlock(id, NO_LOCK);\n    assert( pFile );\n    assert( unixFileMutexNotheld(pFile) );\n    unixEnterMutex();\n    releaseInodeInfo(pFile);\n    unixLeaveMutex();\n    closeUnixFile(id);\n  }\n  return SQLITE_OK;\n}\n\n#endif /* OS_VXWORKS */\n/*\n** Named semaphore locking is only available on VxWorks.\n**\n*************** End of the named semaphore lock implementation ****************\n******************************************************************************/\n\n\n/******************************************************************************\n*************************** Begin AFP Locking *********************************\n**\n** AFP is the Apple Filing Protocol.  AFP is a network filesystem found\n** on Apple Macintosh computers - both OS9 and OSX.\n**\n** Third-party implementations of AFP are available.  But this code here\n** only works on OSX.\n*/\n\n#if defined(__APPLE__) && SQLITE_ENABLE_LOCKING_STYLE\n/*\n** The afpLockingContext structure contains all afp lock specific state\n*/\ntypedef struct afpLockingContext afpLockingContext;\nstruct afpLockingContext {\n  int reserved;\n  const char *dbPath;             /* Name of the open file */\n};\n\nstruct ByteRangeLockPB2\n{\n  unsigned long long offset;        /* offset to first byte to lock */\n  unsigned long long length;        /* nbr of bytes to lock */\n  unsigned long long retRangeStart; /* nbr of 1st byte locked if successful */\n  unsigned char unLockFlag;         /* 1 = unlock, 0 = lock */\n  unsigned char startEndFlag;       /* 1=rel to end of fork, 0=rel to start */\n  int fd;                           /* file desc to assoc this lock with */\n};\n\n#define afpfsByteRangeLock2FSCTL        _IOWR('z', 23, struct ByteRangeLockPB2)\n\n/*\n** This is a utility for setting or clearing a bit-range lock on an\n** AFP filesystem.\n** \n** Return SQLITE_OK on success, SQLITE_BUSY on failure.\n*/\nstatic int afpSetLock(\n  const char *path,              /* Name of the file to be locked or unlocked */\n  unixFile *pFile,               /* Open file descriptor on path */\n  unsigned long long offset,     /* First byte to be locked */\n  unsigned long long length,     /* Number of bytes to lock */\n  int setLockFlag                /* True to set lock.  False to clear lock */\n){\n  struct ByteRangeLockPB2 pb;\n  int err;\n  \n  pb.unLockFlag = setLockFlag ? 0 : 1;\n  pb.startEndFlag = 0;\n  pb.offset = offset;\n  pb.length = length; \n  pb.fd = pFile->h;\n  \n  OSTRACE((\"AFPSETLOCK [%s] for %d%s in range %llx:%llx\\n\", \n    (setLockFlag?\"ON\":\"OFF\"), pFile->h, (pb.fd==-1?\"[testval-1]\":\"\"),\n    offset, length));\n  err = fsctl(path, afpfsByteRangeLock2FSCTL, &pb, 0);\n  if ( err==-1 ) {\n    int rc;\n    int tErrno = errno;\n    OSTRACE((\"AFPSETLOCK failed to fsctl() '%s' %d %s\\n\",\n             path, tErrno, strerror(tErrno)));\n#ifdef SQLITE_IGNORE_AFP_LOCK_ERRORS\n    rc = SQLITE_BUSY;\n#else\n    rc = sqliteErrorFromPosixError(tErrno,\n                    setLockFlag ? SQLITE_IOERR_LOCK : SQLITE_IOERR_UNLOCK);\n#endif /* SQLITE_IGNORE_AFP_LOCK_ERRORS */\n    if( IS_LOCK_ERROR(rc) ){\n      storeLastErrno(pFile, tErrno);\n    }\n    return rc;\n  } else {\n    return SQLITE_OK;\n  }\n}\n\n/*\n** This routine checks if there is a RESERVED lock held on the specified\n** file by this or any other process. If such a lock is held, set *pResOut\n** to a non-zero value otherwise *pResOut is set to zero.  The return value\n** is set to SQLITE_OK unless an I/O error occurs during lock checking.\n*/\nstatic int afpCheckReservedLock(sqlite3_file *id, int *pResOut){\n  int rc = SQLITE_OK;\n  int reserved = 0;\n  unixFile *pFile = (unixFile*)id;\n  afpLockingContext *context;\n  \n  SimulateIOError( return SQLITE_IOERR_CHECKRESERVEDLOCK; );\n  \n  assert( pFile );\n  context = (afpLockingContext *) pFile->lockingContext;\n  if( context->reserved ){\n    *pResOut = 1;\n    return SQLITE_OK;\n  }\n  sqlite3_mutex_enter(pFile->pInode->pLockMutex);\n  /* Check if a thread in this process holds such a lock */\n  if( pFile->pInode->eFileLock>SHARED_LOCK ){\n    reserved = 1;\n  }\n  \n  /* Otherwise see if some other process holds it.\n   */\n  if( !reserved ){\n    /* lock the RESERVED byte */\n    int lrc = afpSetLock(context->dbPath, pFile, RESERVED_BYTE, 1,1);  \n    if( SQLITE_OK==lrc ){\n      /* if we succeeded in taking the reserved lock, unlock it to restore\n      ** the original state */\n      lrc = afpSetLock(context->dbPath, pFile, RESERVED_BYTE, 1, 0);\n    } else {\n      /* if we failed to get the lock then someone else must have it */\n      reserved = 1;\n    }\n    if( IS_LOCK_ERROR(lrc) ){\n      rc=lrc;\n    }\n  }\n  \n  sqlite3_mutex_leave(pFile->pInode->pLockMutex);\n  OSTRACE((\"TEST WR-LOCK %d %d %d (afp)\\n\", pFile->h, rc, reserved));\n  \n  *pResOut = reserved;\n  return rc;\n}\n\n/*\n** Lock the file with the lock specified by parameter eFileLock - one\n** of the following:\n**\n**     (1) SHARED_LOCK\n**     (2) RESERVED_LOCK\n**     (3) PENDING_LOCK\n**     (4) EXCLUSIVE_LOCK\n**\n** Sometimes when requesting one lock state, additional lock states\n** are inserted in between.  The locking might fail on one of the later\n** transitions leaving the lock state different from what it started but\n** still short of its goal.  The following chart shows the allowed\n** transitions and the inserted intermediate states:\n**\n**    UNLOCKED -> SHARED\n**    SHARED -> RESERVED\n**    SHARED -> (PENDING) -> EXCLUSIVE\n**    RESERVED -> (PENDING) -> EXCLUSIVE\n**    PENDING -> EXCLUSIVE\n**\n** This routine will only increase a lock.  Use the sqlite3OsUnlock()\n** routine to lower a locking level.\n*/\nstatic int afpLock(sqlite3_file *id, int eFileLock){\n  int rc = SQLITE_OK;\n  unixFile *pFile = (unixFile*)id;\n  unixInodeInfo *pInode = pFile->pInode;\n  afpLockingContext *context = (afpLockingContext *) pFile->lockingContext;\n  \n  assert( pFile );\n  OSTRACE((\"LOCK    %d %s was %s(%s,%d) pid=%d (afp)\\n\", pFile->h,\n           azFileLock(eFileLock), azFileLock(pFile->eFileLock),\n           azFileLock(pInode->eFileLock), pInode->nShared , osGetpid(0)));\n\n  /* If there is already a lock of this type or more restrictive on the\n  ** unixFile, do nothing. Don't use the afp_end_lock: exit path, as\n  ** unixEnterMutex() hasn't been called yet.\n  */\n  if( pFile->eFileLock>=eFileLock ){\n    OSTRACE((\"LOCK    %d %s ok (already held) (afp)\\n\", pFile->h,\n           azFileLock(eFileLock)));\n    return SQLITE_OK;\n  }\n\n  /* Make sure the locking sequence is correct\n  **  (1) We never move from unlocked to anything higher than shared lock.\n  **  (2) SQLite never explicitly requests a pendig lock.\n  **  (3) A shared lock is always held when a reserve lock is requested.\n  */\n  assert( pFile->eFileLock!=NO_LOCK || eFileLock==SHARED_LOCK );\n  assert( eFileLock!=PENDING_LOCK );\n  assert( eFileLock!=RESERVED_LOCK || pFile->eFileLock==SHARED_LOCK );\n  \n#ifdef SQLITE_WCDB_LOCK_HOOK\n  if (unixLockHook.xWillLock != NULL) {\n    unixLockHook.xWillLock(unixLockHook.pArg, pFile->zPath, eFileLock);\n  }\n#endif\n\n  /* This mutex is needed because pFile->pInode is shared across threads\n  */\n  pInode = pFile->pInode;\n  sqlite3_mutex_enter(pInode->pLockMutex);\n\n  /* If some thread using this PID has a lock via a different unixFile*\n  ** handle that precludes the requested lock, return BUSY.\n  */\n  if( (pFile->eFileLock!=pInode->eFileLock && \n       (pInode->eFileLock>=PENDING_LOCK || eFileLock>SHARED_LOCK))\n     ){\n    rc = SQLITE_BUSY;\n    goto afp_end_lock;\n  }\n  \n  /* If a SHARED lock is requested, and some thread using this PID already\n  ** has a SHARED or RESERVED lock, then increment reference counts and\n  ** return SQLITE_OK.\n  */\n  if( eFileLock==SHARED_LOCK && \n     (pInode->eFileLock==SHARED_LOCK || pInode->eFileLock==RESERVED_LOCK) ){\n    assert( eFileLock==SHARED_LOCK );\n    assert( pFile->eFileLock==0 );\n    assert( pInode->nShared>0 );\n    pFile->eFileLock = SHARED_LOCK;\n    pInode->nShared++;\n    pInode->nLock++;\n    goto afp_end_lock;\n  }\n    \n  /* A PENDING lock is needed before acquiring a SHARED lock and before\n  ** acquiring an EXCLUSIVE lock.  For the SHARED lock, the PENDING will\n  ** be released.\n  */\n  if( eFileLock==SHARED_LOCK \n      || (eFileLock==EXCLUSIVE_LOCK && pFile->eFileLock<PENDING_LOCK)\n  ){\n    int failed;\n    failed = afpSetLock(context->dbPath, pFile, PENDING_BYTE, 1, 1);\n    if (failed) {\n      rc = failed;\n      goto afp_end_lock;\n    }\n  }\n  \n  /* If control gets to this point, then actually go ahead and make\n  ** operating system calls for the specified lock.\n  */\n  if( eFileLock==SHARED_LOCK ){\n    int lrc1, lrc2, lrc1Errno = 0;\n    long lk, mask;\n    \n    assert( pInode->nShared==0 );\n    assert( pInode->eFileLock==0 );\n        \n    mask = (sizeof(long)==8) ? LARGEST_INT64 : 0x7fffffff;\n    /* Now get the read-lock SHARED_LOCK */\n    /* note that the quality of the randomness doesn't matter that much */\n    lk = random(); \n    pInode->sharedByte = (lk & mask)%(SHARED_SIZE - 1);\n    lrc1 = afpSetLock(context->dbPath, pFile, \n          SHARED_FIRST+pInode->sharedByte, 1, 1);\n    if( IS_LOCK_ERROR(lrc1) ){\n      lrc1Errno = pFile->lastErrno;\n    }\n    /* Drop the temporary PENDING lock */\n    lrc2 = afpSetLock(context->dbPath, pFile, PENDING_BYTE, 1, 0);\n    \n    if( IS_LOCK_ERROR(lrc1) ) {\n      storeLastErrno(pFile, lrc1Errno);\n      rc = lrc1;\n      goto afp_end_lock;\n    } else if( IS_LOCK_ERROR(lrc2) ){\n      rc = lrc2;\n      goto afp_end_lock;\n    } else if( lrc1 != SQLITE_OK ) {\n      rc = lrc1;\n    } else {\n      pFile->eFileLock = SHARED_LOCK;\n      pInode->nLock++;\n      pInode->nShared = 1;\n    }\n  }else if( eFileLock==EXCLUSIVE_LOCK && pInode->nShared>1 ){\n    /* We are trying for an exclusive lock but another thread in this\n     ** same process is still holding a shared lock. */\n    rc = SQLITE_BUSY;\n  }else{\n    /* The request was for a RESERVED or EXCLUSIVE lock.  It is\n    ** assumed that there is a SHARED or greater lock on the file\n    ** already.\n    */\n    int failed = 0;\n    assert( 0!=pFile->eFileLock );\n    if (eFileLock >= RESERVED_LOCK && pFile->eFileLock < RESERVED_LOCK) {\n        /* Acquire a RESERVED lock */\n        failed = afpSetLock(context->dbPath, pFile, RESERVED_BYTE, 1,1);\n      if( !failed ){\n        context->reserved = 1;\n      }\n    }\n    if (!failed && eFileLock == EXCLUSIVE_LOCK) {\n      /* Acquire an EXCLUSIVE lock */\n        \n      /* Remove the shared lock before trying the range.  we'll need to \n      ** reestablish the shared lock if we can't get the  afpUnlock\n      */\n      if( !(failed = afpSetLock(context->dbPath, pFile, SHARED_FIRST +\n                         pInode->sharedByte, 1, 0)) ){\n        int failed2 = SQLITE_OK;\n        /* now attemmpt to get the exclusive lock range */\n        failed = afpSetLock(context->dbPath, pFile, SHARED_FIRST, \n                               SHARED_SIZE, 1);\n        if( failed && (failed2 = afpSetLock(context->dbPath, pFile, \n                       SHARED_FIRST + pInode->sharedByte, 1, 1)) ){\n          /* Can't reestablish the shared lock.  Sqlite can't deal, this is\n          ** a critical I/O error\n          */\n          rc = ((failed & 0xff) == SQLITE_IOERR) ? failed2 : \n               SQLITE_IOERR_LOCK;\n          goto afp_end_lock;\n        } \n      }else{\n        rc = failed; \n      }\n    }\n    if( failed ){\n      rc = failed;\n    }\n  }\n  \n  if( rc==SQLITE_OK ){\n    pFile->eFileLock = eFileLock;\n    pInode->eFileLock = eFileLock;\n#ifdef SQLITE_WCDB_LOCK_HOOK\n    if (unixLockHook.xLockDidChange != NULL) {\n      unixLockHook.xLockDidChange(unixLockHook.pArg, pFile->zPath, pInode->eFileLock);\n    }\n#endif\n  }else if( eFileLock==EXCLUSIVE_LOCK ){\n    pFile->eFileLock = PENDING_LOCK;\n    pInode->eFileLock = PENDING_LOCK;\n#ifdef SQLITE_WCDB_LOCK_HOOK\n    if (unixLockHook.xLockDidChange != NULL) {\n      unixLockHook.xLockDidChange(unixLockHook.pArg, pFile->zPath, pInode->eFileLock);\n    }\n#endif\n  }\n  \nafp_end_lock:\n  sqlite3_mutex_leave(pInode->pLockMutex);\n  OSTRACE((\"LOCK    %d %s %s (afp)\\n\", pFile->h, azFileLock(eFileLock), \n         rc==SQLITE_OK ? \"ok\" : \"failed\"));\n  return rc;\n}\n\n/*\n** Lower the locking level on file descriptor pFile to eFileLock.  eFileLock\n** must be either NO_LOCK or SHARED_LOCK.\n**\n** If the locking level of the file descriptor is already at or below\n** the requested locking level, this routine is a no-op.\n*/\nstatic int afpUnlock(sqlite3_file *id, int eFileLock) {\n  int rc = SQLITE_OK;\n  unixFile *pFile = (unixFile*)id;\n  unixInodeInfo *pInode;\n  afpLockingContext *context = (afpLockingContext *) pFile->lockingContext;\n  int skipShared = 0;\n#ifdef SQLITE_TEST\n  int h = pFile->h;\n#endif\n\n  assert( pFile );\n  OSTRACE((\"UNLOCK  %d %d was %d(%d,%d) pid=%d (afp)\\n\", pFile->h, eFileLock,\n           pFile->eFileLock, pFile->pInode->eFileLock, pFile->pInode->nShared,\n           osGetpid(0)));\n\n  assert( eFileLock<=SHARED_LOCK );\n  if( pFile->eFileLock<=eFileLock ){\n    return SQLITE_OK;\n  }\n  pInode = pFile->pInode;\n  sqlite3_mutex_enter(pInode->pLockMutex);\n  assert( pInode->nShared!=0 );\n  if( pFile->eFileLock>SHARED_LOCK ){\n    assert( pInode->eFileLock==pFile->eFileLock );\n    SimulateIOErrorBenign(1);\n    SimulateIOError( h=(-1) )\n    SimulateIOErrorBenign(0);\n    \n#ifdef SQLITE_DEBUG\n    /* When reducing a lock such that other processes can start\n    ** reading the database file again, make sure that the\n    ** transaction counter was updated if any part of the database\n    ** file changed.  If the transaction counter is not updated,\n    ** other connections to the same file might not realize that\n    ** the file has changed and hence might not know to flush their\n    ** cache.  The use of a stale cache can lead to database corruption.\n    */\n    assert( pFile->inNormalWrite==0\n           || pFile->dbUpdate==0\n           || pFile->transCntrChng==1 );\n    pFile->inNormalWrite = 0;\n#endif\n    \n    if( pFile->eFileLock==EXCLUSIVE_LOCK ){\n      rc = afpSetLock(context->dbPath, pFile, SHARED_FIRST, SHARED_SIZE, 0);\n      if( rc==SQLITE_OK && (eFileLock==SHARED_LOCK || pInode->nShared>1) ){\n        /* only re-establish the shared lock if necessary */\n        int sharedLockByte = SHARED_FIRST+pInode->sharedByte;\n        rc = afpSetLock(context->dbPath, pFile, sharedLockByte, 1, 1);\n      } else {\n        skipShared = 1;\n      }\n    }\n    if( rc==SQLITE_OK && pFile->eFileLock>=PENDING_LOCK ){\n      rc = afpSetLock(context->dbPath, pFile, PENDING_BYTE, 1, 0);\n    } \n    if( rc==SQLITE_OK && pFile->eFileLock>=RESERVED_LOCK && context->reserved ){\n      rc = afpSetLock(context->dbPath, pFile, RESERVED_BYTE, 1, 0);\n      if( !rc ){ \n        context->reserved = 0; \n      }\n    }\n    if( rc==SQLITE_OK && (eFileLock==SHARED_LOCK || pInode->nShared>1)){\n      pInode->eFileLock = SHARED_LOCK;\n#ifdef SQLITE_WCDB_LOCK_HOOK\n      if (unixLockHook.xLockDidChange != NULL) {\n        unixLockHook.xLockDidChange(unixLockHook.pArg, pFile->zPath, pInode->eFileLock);\n      }\n#endif\n    }\n  }\n  if( rc==SQLITE_OK && eFileLock==NO_LOCK ){\n\n    /* Decrement the shared lock counter.  Release the lock using an\n    ** OS call only when all threads in this same process have released\n    ** the lock.\n    */\n    unsigned long long sharedLockByte = SHARED_FIRST+pInode->sharedByte;\n    pInode->nShared--;\n    if( pInode->nShared==0 ){\n      SimulateIOErrorBenign(1);\n      SimulateIOError( h=(-1) )\n      SimulateIOErrorBenign(0);\n      if( !skipShared ){\n        rc = afpSetLock(context->dbPath, pFile, sharedLockByte, 1, 0);\n      }\n      if( !rc ){\n        pInode->eFileLock = NO_LOCK;\n        pFile->eFileLock = NO_LOCK;\n#ifdef SQLITE_WCDB_LOCK_HOOK\n        if (unixLockHook.xLockDidChange != NULL) {\n          unixLockHook.xLockDidChange(unixLockHook.pArg, pFile->zPath, pInode->eFileLock);\n        }\n#endif\n      }\n    }\n    if( rc==SQLITE_OK ){\n      pInode->nLock--;\n      assert( pInode->nLock>=0 );\n      if( pInode->nLock==0 ) closePendingFds(pFile);\n    }\n  }\n  \n  sqlite3_mutex_leave(pInode->pLockMutex);\n  if( rc==SQLITE_OK ){\n    pFile->eFileLock = eFileLock;\n  }\n  return rc;\n}\n\n/*\n** Close a file & cleanup AFP specific locking context \n*/\nstatic int afpClose(sqlite3_file *id) {\n  int rc = SQLITE_OK;\n  unixFile *pFile = (unixFile*)id;\n  assert( id!=0 );\n  afpUnlock(id, NO_LOCK);\n  assert( unixFileMutexNotheld(pFile) );\n  unixEnterMutex();\n  if( pFile->pInode ){\n    unixInodeInfo *pInode = pFile->pInode;\n    sqlite3_mutex_enter(pInode->pLockMutex);\n    if( pInode->nLock ){\n      /* If there are outstanding locks, do not actually close the file just\n      ** yet because that would clear those locks.  Instead, add the file\n      ** descriptor to pInode->aPending.  It will be automatically closed when\n      ** the last lock is cleared.\n      */\n      setPendingFd(pFile);\n    }\n    sqlite3_mutex_leave(pInode->pLockMutex);\n  }\n  releaseInodeInfo(pFile);\n  sqlite3_free(pFile->lockingContext);\n  rc = closeUnixFile(id);\n  unixLeaveMutex();\n  return rc;\n}\n\n#endif /* defined(__APPLE__) && SQLITE_ENABLE_LOCKING_STYLE */\n/*\n** The code above is the AFP lock implementation.  The code is specific\n** to MacOSX and does not work on other unix platforms.  No alternative\n** is available.  If you don't compile for a mac, then the \"unix-afp\"\n** VFS is not available.\n**\n********************* End of the AFP lock implementation **********************\n******************************************************************************/\n\n/******************************************************************************\n*************************** Begin NFS Locking ********************************/\n\n#if defined(__APPLE__) && SQLITE_ENABLE_LOCKING_STYLE\n/*\n ** Lower the locking level on file descriptor pFile to eFileLock.  eFileLock\n ** must be either NO_LOCK or SHARED_LOCK.\n **\n ** If the locking level of the file descriptor is already at or below\n ** the requested locking level, this routine is a no-op.\n */\nstatic int nfsUnlock(sqlite3_file *id, int eFileLock){\n  return posixUnlock(id, eFileLock, 1);\n}\n\n#endif /* defined(__APPLE__) && SQLITE_ENABLE_LOCKING_STYLE */\n/*\n** The code above is the NFS lock implementation.  The code is specific\n** to MacOSX and does not work on other unix platforms.  No alternative\n** is available.  \n**\n********************* End of the NFS lock implementation **********************\n******************************************************************************/\n\n/******************************************************************************\n**************** Non-locking sqlite3_file methods *****************************\n**\n** The next division contains implementations for all methods of the \n** sqlite3_file object other than the locking methods.  The locking\n** methods were defined in divisions above (one locking method per\n** division).  Those methods that are common to all locking modes\n** are gather together into this division.\n*/\n\n/*\n** Seek to the offset passed as the second argument, then read cnt \n** bytes into pBuf. Return the number of bytes actually read.\n**\n** NB:  If you define USE_PREAD or USE_PREAD64, then it might also\n** be necessary to define _XOPEN_SOURCE to be 500.  This varies from\n** one system to another.  Since SQLite does not define USE_PREAD\n** in any form by default, we will not attempt to define _XOPEN_SOURCE.\n** See tickets #2741 and #2681.\n**\n** To avoid stomping the errno value on a failed read the lastErrno value\n** is set before returning.\n*/\nstatic int seekAndRead(unixFile *id, sqlite3_int64 offset, void *pBuf, int cnt){\n  int got;\n  int prior = 0;\n#if (!defined(USE_PREAD) && !defined(USE_PREAD64))\n  i64 newOffset;\n#endif\n  TIMER_START;\n  assert( cnt==(cnt&0x1ffff) );\n  assert( id->h>2 );\n  do{\n#if defined(USE_PREAD)\n    got = osPread(id->h, pBuf, cnt, offset);\n    SimulateIOError( got = -1 );\n#elif defined(USE_PREAD64)\n    got = osPread64(id->h, pBuf, cnt, offset);\n    SimulateIOError( got = -1 );\n#else\n    newOffset = lseek(id->h, offset, SEEK_SET);\n    SimulateIOError( newOffset = -1 );\n    if( newOffset<0 ){\n      storeLastErrno((unixFile*)id, errno);\n      return -1;\n    }\n    got = osRead(id->h, pBuf, cnt);\n#endif\n    if( got==cnt ) break;\n    if( got<0 ){\n      if( errno==EINTR ){ got = 1; continue; }\n      prior = 0;\n      storeLastErrno((unixFile*)id,  errno);\n      break;\n    }else if( got>0 ){\n      cnt -= got;\n      offset += got;\n      prior += got;\n      pBuf = (void*)(got + (char*)pBuf);\n    }\n  }while( got>0 );\n  TIMER_END;\n  OSTRACE((\"READ    %-3d %5d %7lld %llu\\n\",\n            id->h, got+prior, offset-prior, TIMER_ELAPSED));\n  return got+prior;\n}\n\n/*\n** Read data from a file into a buffer.  Return SQLITE_OK if all\n** bytes were read successfully and SQLITE_IOERR if anything goes\n** wrong.\n*/\nstatic int unixRead(\n  sqlite3_file *id, \n  void *pBuf, \n  int amt,\n  sqlite3_int64 offset\n){\n  unixFile *pFile = (unixFile *)id;\n  int got;\n  assert( id );\n  assert( offset>=0 );\n  assert( amt>0 );\n\n  /* If this is a database file (not a journal, master-journal or temp\n  ** file), the bytes in the locking range should never be read or written. */\n#if 0\n  assert( pFile->pPreallocatedUnused==0\n       || offset>=PENDING_BYTE+512\n       || offset+amt<=PENDING_BYTE \n  );\n#endif\n\n#if SQLITE_MAX_MMAP_SIZE>0\n  /* Deal with as much of this read request as possible by transfering\n  ** data from the memory mapping using memcpy().  */\n  if( offset<pFile->mmapSize ){\n    if( offset+amt <= pFile->mmapSize ){\n      memcpy(pBuf, &((u8 *)(pFile->pMapRegion))[offset], amt);\n      return SQLITE_OK;\n    }else{\n      int nCopy = pFile->mmapSize - offset;\n      memcpy(pBuf, &((u8 *)(pFile->pMapRegion))[offset], nCopy);\n      pBuf = &((u8 *)pBuf)[nCopy];\n      amt -= nCopy;\n      offset += nCopy;\n    }\n  }\n#endif\n\n  got = seekAndRead(pFile, offset, pBuf, amt);\n  if( got==amt ){\n    return SQLITE_OK;\n  }else if( got<0 ){\n    /* lastErrno set by seekAndRead */\n    return SQLITE_IOERR_READ;\n  }else{\n    storeLastErrno(pFile, 0);   /* not a system error */\n    /* Unread parts of the buffer must be zero-filled */\n    memset(&((char*)pBuf)[got], 0, amt-got);\n    return SQLITE_IOERR_SHORT_READ;\n  }\n}\n\n/*\n** Attempt to seek the file-descriptor passed as the first argument to\n** absolute offset iOff, then attempt to write nBuf bytes of data from\n** pBuf to it. If an error occurs, return -1 and set *piErrno. Otherwise, \n** return the actual number of bytes written (which may be less than\n** nBuf).\n*/\nstatic int seekAndWriteFd(\n  int fd,                         /* File descriptor to write to */\n  i64 iOff,                       /* File offset to begin writing at */\n  const void *pBuf,               /* Copy data from this buffer to the file */\n  int nBuf,                       /* Size of buffer pBuf in bytes */\n  int *piErrno                    /* OUT: Error number if error occurs */\n){\n  int rc = 0;                     /* Value returned by system call */\n\n  assert( nBuf==(nBuf&0x1ffff) );\n  assert( fd>2 );\n  assert( piErrno!=0 );\n  nBuf &= 0x1ffff;\n  TIMER_START;\n\n#if defined(USE_PREAD)\n  do{ rc = (int)osPwrite(fd, pBuf, nBuf, iOff); }while( rc<0 && errno==EINTR );\n#elif defined(USE_PREAD64)\n  do{ rc = (int)osPwrite64(fd, pBuf, nBuf, iOff);}while( rc<0 && errno==EINTR);\n#else\n  do{\n    i64 iSeek = lseek(fd, iOff, SEEK_SET);\n    SimulateIOError( iSeek = -1 );\n    if( iSeek<0 ){\n      rc = -1;\n      break;\n    }\n    rc = osWrite(fd, pBuf, nBuf);\n  }while( rc<0 && errno==EINTR );\n#endif\n\n  TIMER_END;\n  OSTRACE((\"WRITE   %-3d %5d %7lld %llu\\n\", fd, rc, iOff, TIMER_ELAPSED));\n\n  if( rc<0 ) *piErrno = errno;\n  return rc;\n}\n\n\n/*\n** Seek to the offset in id->offset then read cnt bytes into pBuf.\n** Return the number of bytes actually read.  Update the offset.\n**\n** To avoid stomping the errno value on a failed write the lastErrno value\n** is set before returning.\n*/\nstatic int seekAndWrite(unixFile *id, i64 offset, const void *pBuf, int cnt){\n  return seekAndWriteFd(id->h, offset, pBuf, cnt, &id->lastErrno);\n}\n\n\n/*\n** Write data from a buffer into a file.  Return SQLITE_OK on success\n** or some other error code on failure.\n*/\nstatic int unixWrite(\n  sqlite3_file *id, \n  const void *pBuf, \n  int amt,\n  sqlite3_int64 offset \n){\n  unixFile *pFile = (unixFile*)id;\n  int wrote = 0;\n  assert( id );\n  assert( amt>0 );\n\n  /* If this is a database file (not a journal, master-journal or temp\n  ** file), the bytes in the locking range should never be read or written. */\n#if 0\n  assert( pFile->pPreallocatedUnused==0\n       || offset>=PENDING_BYTE+512\n       || offset+amt<=PENDING_BYTE \n  );\n#endif\n\n#ifdef SQLITE_DEBUG\n  /* If we are doing a normal write to a database file (as opposed to\n  ** doing a hot-journal rollback or a write to some file other than a\n  ** normal database file) then record the fact that the database\n  ** has changed.  If the transaction counter is modified, record that\n  ** fact too.\n  */\n  if( pFile->inNormalWrite ){\n    pFile->dbUpdate = 1;  /* The database has been modified */\n    if( offset<=24 && offset+amt>=27 ){\n      int rc;\n      char oldCntr[4];\n      SimulateIOErrorBenign(1);\n      rc = seekAndRead(pFile, 24, oldCntr, 4);\n      SimulateIOErrorBenign(0);\n      if( rc!=4 || memcmp(oldCntr, &((char*)pBuf)[24-offset], 4)!=0 ){\n        pFile->transCntrChng = 1;  /* The transaction counter has changed */\n      }\n    }\n  }\n#endif\n\n#if defined(SQLITE_MMAP_READWRITE) && SQLITE_MAX_MMAP_SIZE>0\n  /* Deal with as much of this write request as possible by transfering\n  ** data from the memory mapping using memcpy().  */\n  if( offset<pFile->mmapSize ){\n    if( offset+amt <= pFile->mmapSize ){\n      memcpy(&((u8 *)(pFile->pMapRegion))[offset], pBuf, amt);\n      return SQLITE_OK;\n    }else{\n      int nCopy = pFile->mmapSize - offset;\n      memcpy(&((u8 *)(pFile->pMapRegion))[offset], pBuf, nCopy);\n      pBuf = &((u8 *)pBuf)[nCopy];\n      amt -= nCopy;\n      offset += nCopy;\n    }\n  }\n#endif\n \n  while( (wrote = seekAndWrite(pFile, offset, pBuf, amt))<amt && wrote>0 ){\n    amt -= wrote;\n    offset += wrote;\n    pBuf = &((char*)pBuf)[wrote];\n  }\n  SimulateIOError(( wrote=(-1), amt=1 ));\n  SimulateDiskfullError(( wrote=0, amt=1 ));\n\n  if( amt>wrote ){\n    if( wrote<0 && pFile->lastErrno!=ENOSPC ){\n      /* lastErrno set by seekAndWrite */\n      return SQLITE_IOERR_WRITE;\n    }else{\n      storeLastErrno(pFile, 0); /* not a system error */\n      return SQLITE_FULL;\n    }\n  }\n\n  return SQLITE_OK;\n}\n\n#ifdef SQLITE_TEST\n/*\n** Count the number of fullsyncs and normal syncs.  This is used to test\n** that syncs and fullsyncs are occurring at the right times.\n*/\nSQLITE_API int sqlite3_sync_count = 0;\nSQLITE_API int sqlite3_fullsync_count = 0;\n#endif\n\n/*\n** We do not trust systems to provide a working fdatasync().  Some do.\n** Others do no.  To be safe, we will stick with the (slightly slower)\n** fsync(). If you know that your system does support fdatasync() correctly,\n** then simply compile with -Dfdatasync=fdatasync or -DHAVE_FDATASYNC\n*/\n#if !defined(fdatasync) && !HAVE_FDATASYNC\n# define fdatasync fsync\n#endif\n\n/*\n** Define HAVE_FULLFSYNC to 0 or 1 depending on whether or not\n** the F_FULLFSYNC macro is defined.  F_FULLFSYNC is currently\n** only available on Mac OS X.  But that could change.\n*/\n#ifdef F_FULLFSYNC\n# define HAVE_FULLFSYNC 1\n#else\n# define HAVE_FULLFSYNC 0\n#endif\n\n\n/*\n** The fsync() system call does not work as advertised on many\n** unix systems.  The following procedure is an attempt to make\n** it work better.\n**\n** The SQLITE_NO_SYNC macro disables all fsync()s.  This is useful\n** for testing when we want to run through the test suite quickly.\n** You are strongly advised *not* to deploy with SQLITE_NO_SYNC\n** enabled, however, since with SQLITE_NO_SYNC enabled, an OS crash\n** or power failure will likely corrupt the database file.\n**\n** SQLite sets the dataOnly flag if the size of the file is unchanged.\n** The idea behind dataOnly is that it should only write the file content\n** to disk, not the inode.  We only set dataOnly if the file size is \n** unchanged since the file size is part of the inode.  However, \n** Ted Ts'o tells us that fdatasync() will also write the inode if the\n** file size has changed.  The only real difference between fdatasync()\n** and fsync(), Ted tells us, is that fdatasync() will not flush the\n** inode if the mtime or owner or other inode attributes have changed.\n** We only care about the file size, not the other file attributes, so\n** as far as SQLite is concerned, an fdatasync() is always adequate.\n** So, we always use fdatasync() if it is available, regardless of\n** the value of the dataOnly flag.\n*/\nstatic int full_fsync(int fd, int fullSync, int dataOnly){\n  int rc;\n\n  /* The following \"ifdef/elif/else/\" block has the same structure as\n  ** the one below. It is replicated here solely to avoid cluttering \n  ** up the real code with the UNUSED_PARAMETER() macros.\n  */\n#ifdef SQLITE_NO_SYNC\n  UNUSED_PARAMETER(fd);\n  UNUSED_PARAMETER(fullSync);\n  UNUSED_PARAMETER(dataOnly);\n#elif HAVE_FULLFSYNC\n  UNUSED_PARAMETER(dataOnly);\n#else\n  UNUSED_PARAMETER(fullSync);\n  UNUSED_PARAMETER(dataOnly);\n#endif\n\n  /* Record the number of times that we do a normal fsync() and \n  ** FULLSYNC.  This is used during testing to verify that this procedure\n  ** gets called with the correct arguments.\n  */\n#ifdef SQLITE_TEST\n  if( fullSync ) sqlite3_fullsync_count++;\n  sqlite3_sync_count++;\n#endif\n\n  /* If we compiled with the SQLITE_NO_SYNC flag, then syncing is a\n  ** no-op.  But go ahead and call fstat() to validate the file\n  ** descriptor as we need a method to provoke a failure during\n  ** coverate testing.\n  */\n#ifdef SQLITE_NO_SYNC\n  {\n    struct stat buf;\n    rc = osFstat(fd, &buf);\n  }\n#elif HAVE_FULLFSYNC\n  if( fullSync ){\n    rc = osFcntl(fd, F_FULLFSYNC, 0);\n  }else{\n    rc = 1;\n  }\n  /* If the FULLFSYNC failed, fall back to attempting an fsync().\n  ** It shouldn't be possible for fullfsync to fail on the local \n  ** file system (on OSX), so failure indicates that FULLFSYNC\n  ** isn't supported for this file system. So, attempt an fsync \n  ** and (for now) ignore the overhead of a superfluous fcntl call.  \n  ** It'd be better to detect fullfsync support once and avoid \n  ** the fcntl call every time sync is called.\n  */\n  if( rc ) rc = fsync(fd);\n\n#elif defined(__APPLE__)\n  /* fdatasync() on HFS+ doesn't yet flush the file size if it changed correctly\n  ** so currently we default to the macro that redefines fdatasync to fsync\n  */\n  rc = fsync(fd);\n#else \n  rc = fdatasync(fd);\n#if OS_VXWORKS\n  if( rc==-1 && errno==ENOTSUP ){\n    rc = fsync(fd);\n  }\n#endif /* OS_VXWORKS */\n#endif /* ifdef SQLITE_NO_SYNC elif HAVE_FULLFSYNC */\n\n  if( OS_VXWORKS && rc!= -1 ){\n    rc = 0;\n  }\n  return rc;\n}\n\n/*\n** Open a file descriptor to the directory containing file zFilename.\n** If successful, *pFd is set to the opened file descriptor and\n** SQLITE_OK is returned. If an error occurs, either SQLITE_NOMEM\n** or SQLITE_CANTOPEN is returned and *pFd is set to an undefined\n** value.\n**\n** The directory file descriptor is used for only one thing - to\n** fsync() a directory to make sure file creation and deletion events\n** are flushed to disk.  Such fsyncs are not needed on newer\n** journaling filesystems, but are required on older filesystems.\n**\n** This routine can be overridden using the xSetSysCall interface.\n** The ability to override this routine was added in support of the\n** chromium sandbox.  Opening a directory is a security risk (we are\n** told) so making it overrideable allows the chromium sandbox to\n** replace this routine with a harmless no-op.  To make this routine\n** a no-op, replace it with a stub that returns SQLITE_OK but leaves\n** *pFd set to a negative number.\n**\n** If SQLITE_OK is returned, the caller is responsible for closing\n** the file descriptor *pFd using close().\n*/\nstatic int openDirectory(const char *zFilename, int *pFd){\n  int ii;\n  int fd = -1;\n  char zDirname[MAX_PATHNAME+1];\n\n  sqlite3_snprintf(MAX_PATHNAME, zDirname, \"%s\", zFilename);\n  for(ii=(int)strlen(zDirname); ii>0 && zDirname[ii]!='/'; ii--);\n  if( ii>0 ){\n    zDirname[ii] = '\\0';\n  }else{\n    if( zDirname[0]!='/' ) zDirname[0] = '.';\n    zDirname[1] = 0;\n  }\n  fd = robust_open(zDirname, O_RDONLY|O_BINARY, 0);\n  if( fd>=0 ){\n    OSTRACE((\"OPENDIR %-3d %s\\n\", fd, zDirname));\n  }\n  *pFd = fd;\n  if( fd>=0 ) return SQLITE_OK;\n  return unixLogError(SQLITE_CANTOPEN_BKPT, \"openDirectory\", zDirname);\n}\n\n/*\n** Make sure all writes to a particular file are committed to disk.\n**\n** If dataOnly==0 then both the file itself and its metadata (file\n** size, access time, etc) are synced.  If dataOnly!=0 then only the\n** file data is synced.\n**\n** Under Unix, also make sure that the directory entry for the file\n** has been created by fsync-ing the directory that contains the file.\n** If we do not do this and we encounter a power failure, the directory\n** entry for the journal might not exist after we reboot.  The next\n** SQLite to access the file will not know that the journal exists (because\n** the directory entry for the journal was never created) and the transaction\n** will not roll back - possibly leading to database corruption.\n*/\nstatic int unixSync(sqlite3_file *id, int flags){\n  int rc;\n  unixFile *pFile = (unixFile*)id;\n\n  int isDataOnly = (flags&SQLITE_SYNC_DATAONLY);\n  int isFullsync = (flags&0x0F)==SQLITE_SYNC_FULL;\n\n  /* Check that one of SQLITE_SYNC_NORMAL or FULL was passed */\n  assert((flags&0x0F)==SQLITE_SYNC_NORMAL\n      || (flags&0x0F)==SQLITE_SYNC_FULL\n  );\n\n  /* Unix cannot, but some systems may return SQLITE_FULL from here. This\n  ** line is to test that doing so does not cause any problems.\n  */\n  SimulateDiskfullError( return SQLITE_FULL );\n\n  assert( pFile );\n  OSTRACE((\"SYNC    %-3d\\n\", pFile->h));\n  rc = full_fsync(pFile->h, isFullsync, isDataOnly);\n  SimulateIOError( rc=1 );\n  if( rc ){\n    storeLastErrno(pFile, errno);\n    return unixLogError(SQLITE_IOERR_FSYNC, \"full_fsync\", pFile->zPath);\n  }\n\n  /* Also fsync the directory containing the file if the DIRSYNC flag\n  ** is set.  This is a one-time occurrence.  Many systems (examples: AIX)\n  ** are unable to fsync a directory, so ignore errors on the fsync.\n  */\n  if( pFile->ctrlFlags & UNIXFILE_DIRSYNC ){\n    int dirfd;\n    OSTRACE((\"DIRSYNC %s (have_fullfsync=%d fullsync=%d)\\n\", pFile->zPath,\n            HAVE_FULLFSYNC, isFullsync));\n    rc = osOpenDirectory(pFile->zPath, &dirfd);\n    if( rc==SQLITE_OK ){\n      full_fsync(dirfd, 0, 0);\n      robust_close(pFile, dirfd, __LINE__);\n    }else{\n      assert( rc==SQLITE_CANTOPEN );\n      rc = SQLITE_OK;\n    }\n    pFile->ctrlFlags &= ~UNIXFILE_DIRSYNC;\n  }\n  return rc;\n}\n\n/*\n** Truncate an open file to a specified size\n*/\nstatic int unixTruncate(sqlite3_file *id, i64 nByte){\n  unixFile *pFile = (unixFile *)id;\n  int rc;\n  assert( pFile );\n  SimulateIOError( return SQLITE_IOERR_TRUNCATE );\n\n  /* If the user has configured a chunk-size for this file, truncate the\n  ** file so that it consists of an integer number of chunks (i.e. the\n  ** actual file size after the operation may be larger than the requested\n  ** size).\n  */\n  if( pFile->szChunk>0 ){\n    nByte = ((nByte + pFile->szChunk - 1)/pFile->szChunk) * pFile->szChunk;\n  }\n\n  rc = robust_ftruncate(pFile->h, nByte);\n  if( rc ){\n    storeLastErrno(pFile, errno);\n    return unixLogError(SQLITE_IOERR_TRUNCATE, \"ftruncate\", pFile->zPath);\n  }else{\n#ifdef SQLITE_DEBUG\n    /* If we are doing a normal write to a database file (as opposed to\n    ** doing a hot-journal rollback or a write to some file other than a\n    ** normal database file) and we truncate the file to zero length,\n    ** that effectively updates the change counter.  This might happen\n    ** when restoring a database using the backup API from a zero-length\n    ** source.\n    */\n    if( pFile->inNormalWrite && nByte==0 ){\n      pFile->transCntrChng = 1;\n    }\n#endif\n\n#if SQLITE_MAX_MMAP_SIZE>0\n    /* If the file was just truncated to a size smaller than the currently\n    ** mapped region, reduce the effective mapping size as well. SQLite will\n    ** use read() and write() to access data beyond this point from now on.  \n    */\n    if( nByte<pFile->mmapSize ){\n      pFile->mmapSize = nByte;\n    }\n#endif\n\n    return SQLITE_OK;\n  }\n}\n\n/*\n** Determine the current size of a file in bytes\n*/\nstatic int unixFileSize(sqlite3_file *id, i64 *pSize){\n  int rc;\n  struct stat buf;\n  assert( id );\n  rc = osFstat(((unixFile*)id)->h, &buf);\n  SimulateIOError( rc=1 );\n  if( rc!=0 ){\n    storeLastErrno((unixFile*)id, errno);\n    return SQLITE_IOERR_FSTAT;\n  }\n  *pSize = buf.st_size;\n\n  /* When opening a zero-size database, the findInodeInfo() procedure\n  ** writes a single byte into that file in order to work around a bug\n  ** in the OS-X msdos filesystem.  In order to avoid problems with upper\n  ** layers, we need to report this file size as zero even though it is\n  ** really 1.   Ticket #3260.\n  */\n  if( *pSize==1 ) *pSize = 0;\n\n\n  return SQLITE_OK;\n}\n\n#if SQLITE_ENABLE_LOCKING_STYLE && defined(__APPLE__)\n/*\n** Handler for proxy-locking file-control verbs.  Defined below in the\n** proxying locking division.\n*/\nstatic int proxyFileControl(sqlite3_file*,int,void*);\n#endif\n\n/* \n** This function is called to handle the SQLITE_FCNTL_SIZE_HINT \n** file-control operation.  Enlarge the database to nBytes in size\n** (rounded up to the next chunk-size).  If the database is already\n** nBytes or larger, this routine is a no-op.\n*/\nstatic int fcntlSizeHint(unixFile *pFile, i64 nByte){\n  if( pFile->szChunk>0 ){\n    i64 nSize;                    /* Required file size */\n    struct stat buf;              /* Used to hold return values of fstat() */\n   \n    if( osFstat(pFile->h, &buf) ){\n      return SQLITE_IOERR_FSTAT;\n    }\n\n    nSize = ((nByte+pFile->szChunk-1) / pFile->szChunk) * pFile->szChunk;\n    if( nSize>(i64)buf.st_size ){\n\n#if defined(HAVE_POSIX_FALLOCATE) && HAVE_POSIX_FALLOCATE\n      /* The code below is handling the return value of osFallocate() \n      ** correctly. posix_fallocate() is defined to \"returns zero on success, \n      ** or an error number on  failure\". See the manpage for details. */\n      int err;\n      do{\n        err = osFallocate(pFile->h, buf.st_size, nSize-buf.st_size);\n      }while( err==EINTR );\n      if( err && err!=EINVAL ) return SQLITE_IOERR_WRITE;\n#else\n      /* If the OS does not have posix_fallocate(), fake it. Write a \n      ** single byte to the last byte in each block that falls entirely\n      ** within the extended region. Then, if required, a single byte\n      ** at offset (nSize-1), to set the size of the file correctly.\n      ** This is a similar technique to that used by glibc on systems\n      ** that do not have a real fallocate() call.\n      */\n      int nBlk = buf.st_blksize;  /* File-system block size */\n      int nWrite = 0;             /* Number of bytes written by seekAndWrite */\n      i64 iWrite;                 /* Next offset to write to */\n\n      iWrite = (buf.st_size/nBlk)*nBlk + nBlk - 1;\n      assert( iWrite>=buf.st_size );\n      assert( ((iWrite+1)%nBlk)==0 );\n      for(/*no-op*/; iWrite<nSize+nBlk-1; iWrite+=nBlk ){\n        if( iWrite>=nSize ) iWrite = nSize - 1;\n        nWrite = seekAndWrite(pFile, iWrite, \"\", 1);\n        if( nWrite!=1 ) return SQLITE_IOERR_WRITE;\n      }\n#endif\n    }\n  }\n\n#if SQLITE_MAX_MMAP_SIZE>0\n  if( pFile->mmapSizeMax>0 && nByte>pFile->mmapSize ){\n    int rc;\n    if( pFile->szChunk<=0 ){\n      if( robust_ftruncate(pFile->h, nByte) ){\n        storeLastErrno(pFile, errno);\n        return unixLogError(SQLITE_IOERR_TRUNCATE, \"ftruncate\", pFile->zPath);\n      }\n    }\n\n    rc = unixMapfile(pFile, nByte);\n    return rc;\n  }\n#endif\n\n  return SQLITE_OK;\n}\n\n/*\n** If *pArg is initially negative then this is a query.  Set *pArg to\n** 1 or 0 depending on whether or not bit mask of pFile->ctrlFlags is set.\n**\n** If *pArg is 0 or 1, then clear or set the mask bit of pFile->ctrlFlags.\n*/\nstatic void unixModeBit(unixFile *pFile, unsigned char mask, int *pArg){\n  if( *pArg<0 ){\n    *pArg = (pFile->ctrlFlags & mask)!=0;\n  }else if( (*pArg)==0 ){\n    pFile->ctrlFlags &= ~mask;\n  }else{\n    pFile->ctrlFlags |= mask;\n  }\n}\n\n/* Forward declaration */\nstatic int unixGetTempname(int nBuf, char *zBuf);\n\n/*\n** Information and control of an open file handle.\n*/\nstatic int unixFileControl(sqlite3_file *id, int op, void *pArg){\n  unixFile *pFile = (unixFile*)id;\n  switch( op ){\n#if defined(__linux__) && defined(SQLITE_ENABLE_BATCH_ATOMIC_WRITE)\n    case SQLITE_FCNTL_BEGIN_ATOMIC_WRITE: {\n      int rc = osIoctl(pFile->h, F2FS_IOC_START_ATOMIC_WRITE);\n      return rc ? SQLITE_IOERR_BEGIN_ATOMIC : SQLITE_OK;\n    }\n    case SQLITE_FCNTL_COMMIT_ATOMIC_WRITE: {\n      int rc = osIoctl(pFile->h, F2FS_IOC_COMMIT_ATOMIC_WRITE);\n      return rc ? SQLITE_IOERR_COMMIT_ATOMIC : SQLITE_OK;\n    }\n    case SQLITE_FCNTL_ROLLBACK_ATOMIC_WRITE: {\n      int rc = osIoctl(pFile->h, F2FS_IOC_ABORT_VOLATILE_WRITE);\n      return rc ? SQLITE_IOERR_ROLLBACK_ATOMIC : SQLITE_OK;\n    }\n#endif /* __linux__ && SQLITE_ENABLE_BATCH_ATOMIC_WRITE */\n\n    case SQLITE_FCNTL_LOCKSTATE: {\n      *(int*)pArg = pFile->eFileLock;\n      return SQLITE_OK;\n    }\n    case SQLITE_FCNTL_LAST_ERRNO: {\n      *(int*)pArg = pFile->lastErrno;\n      return SQLITE_OK;\n    }\n    case SQLITE_FCNTL_CHUNK_SIZE: {\n      pFile->szChunk = *(int *)pArg;\n      return SQLITE_OK;\n    }\n    case SQLITE_FCNTL_SIZE_HINT: {\n      int rc;\n      SimulateIOErrorBenign(1);\n      rc = fcntlSizeHint(pFile, *(i64 *)pArg);\n      SimulateIOErrorBenign(0);\n      return rc;\n    }\n    case SQLITE_FCNTL_PERSIST_WAL: {\n      unixModeBit(pFile, UNIXFILE_PERSIST_WAL, (int*)pArg);\n      return SQLITE_OK;\n    }\n    case SQLITE_FCNTL_POWERSAFE_OVERWRITE: {\n      unixModeBit(pFile, UNIXFILE_PSOW, (int*)pArg);\n      return SQLITE_OK;\n    }\n    case SQLITE_FCNTL_VFSNAME: {\n      *(char**)pArg = sqlite3_mprintf(\"%s\", pFile->pVfs->zName);\n      return SQLITE_OK;\n    }\n    case SQLITE_FCNTL_TEMPFILENAME: {\n      char *zTFile = sqlite3_malloc64( pFile->pVfs->mxPathname );\n      if( zTFile ){\n        unixGetTempname(pFile->pVfs->mxPathname, zTFile);\n        *(char**)pArg = zTFile;\n      }\n      return SQLITE_OK;\n    }\n    case SQLITE_FCNTL_HAS_MOVED: {\n      *(int*)pArg = fileHasMoved(pFile);\n      return SQLITE_OK;\n    }\n#ifdef SQLITE_ENABLE_SETLK_TIMEOUT\n    case SQLITE_FCNTL_LOCK_TIMEOUT: {\n      pFile->iBusyTimeout = *(int*)pArg;\n      return SQLITE_OK;\n    }\n#endif\n#if SQLITE_MAX_MMAP_SIZE>0\n    case SQLITE_FCNTL_MMAP_SIZE: {\n      i64 newLimit = *(i64*)pArg;\n      int rc = SQLITE_OK;\n      if( newLimit>sqlite3GlobalConfig.mxMmap ){\n        newLimit = sqlite3GlobalConfig.mxMmap;\n      }\n\n      /* The value of newLimit may be eventually cast to (size_t) and passed\n      ** to mmap(). Restrict its value to 2GB if (size_t) is not at least a\n      ** 64-bit type. */\n      if( newLimit>0 && sizeof(size_t)<8 ){\n        newLimit = (newLimit & 0x7FFFFFFF);\n      }\n\n      *(i64*)pArg = pFile->mmapSizeMax;\n      if( newLimit>=0 && newLimit!=pFile->mmapSizeMax && pFile->nFetchOut==0 ){\n        pFile->mmapSizeMax = newLimit;\n        if( pFile->mmapSize>0 ){\n          unixUnmapfile(pFile);\n          rc = unixMapfile(pFile, -1);\n        }\n      }\n      return rc;\n    }\n#endif\n#ifdef SQLITE_DEBUG\n    /* The pager calls this method to signal that it has done\n    ** a rollback and that the database is therefore unchanged and\n    ** it hence it is OK for the transaction change counter to be\n    ** unchanged.\n    */\n    case SQLITE_FCNTL_DB_UNCHANGED: {\n      ((unixFile*)id)->dbUpdate = 0;\n      return SQLITE_OK;\n    }\n#endif\n#if SQLITE_ENABLE_LOCKING_STYLE && defined(__APPLE__)\n    case SQLITE_FCNTL_SET_LOCKPROXYFILE:\n    case SQLITE_FCNTL_GET_LOCKPROXYFILE: {\n      return proxyFileControl(id,op,pArg);\n    }\n#endif /* SQLITE_ENABLE_LOCKING_STYLE && defined(__APPLE__) */\n  }\n  return SQLITE_NOTFOUND;\n}\n\n/*\n** If pFd->sectorSize is non-zero when this function is called, it is a\n** no-op. Otherwise, the values of pFd->sectorSize and \n** pFd->deviceCharacteristics are set according to the file-system \n** characteristics. \n**\n** There are two versions of this function. One for QNX and one for all\n** other systems.\n*/\n#ifndef __QNXNTO__\nstatic void setDeviceCharacteristics(unixFile *pFd){\n  assert( pFd->deviceCharacteristics==0 || pFd->sectorSize!=0 );\n  if( pFd->sectorSize==0 ){\n#if defined(__linux__) && defined(SQLITE_ENABLE_BATCH_ATOMIC_WRITE)\n    int res;\n    u32 f = 0;\n\n    /* Check for support for F2FS atomic batch writes. */\n    res = osIoctl(pFd->h, F2FS_IOC_GET_FEATURES, &f);\n    if( res==0 && (f & F2FS_FEATURE_ATOMIC_WRITE) ){\n      pFd->deviceCharacteristics = SQLITE_IOCAP_BATCH_ATOMIC;\n    }\n#endif /* __linux__ && SQLITE_ENABLE_BATCH_ATOMIC_WRITE */\n\n    /* Set the POWERSAFE_OVERWRITE flag if requested. */\n    if( pFd->ctrlFlags & UNIXFILE_PSOW ){\n      pFd->deviceCharacteristics |= SQLITE_IOCAP_POWERSAFE_OVERWRITE;\n    }\n\n    pFd->sectorSize = SQLITE_DEFAULT_SECTOR_SIZE;\n  }\n}\n#else\n#include <sys/dcmd_blk.h>\n#include <sys/statvfs.h>\nstatic void setDeviceCharacteristics(unixFile *pFile){\n  if( pFile->sectorSize == 0 ){\n    struct statvfs fsInfo;\n       \n    /* Set defaults for non-supported filesystems */\n    pFile->sectorSize = SQLITE_DEFAULT_SECTOR_SIZE;\n    pFile->deviceCharacteristics = 0;\n    if( fstatvfs(pFile->h, &fsInfo) == -1 ) {\n      return;\n    }\n\n    if( !strcmp(fsInfo.f_basetype, \"tmp\") ) {\n      pFile->sectorSize = fsInfo.f_bsize;\n      pFile->deviceCharacteristics =\n        SQLITE_IOCAP_ATOMIC4K |       /* All ram filesystem writes are atomic */\n        SQLITE_IOCAP_SAFE_APPEND |    /* growing the file does not occur until\n                                      ** the write succeeds */\n        SQLITE_IOCAP_SEQUENTIAL |     /* The ram filesystem has no write behind\n                                      ** so it is ordered */\n        0;\n    }else if( strstr(fsInfo.f_basetype, \"etfs\") ){\n      pFile->sectorSize = fsInfo.f_bsize;\n      pFile->deviceCharacteristics =\n        /* etfs cluster size writes are atomic */\n        (pFile->sectorSize / 512 * SQLITE_IOCAP_ATOMIC512) |\n        SQLITE_IOCAP_SAFE_APPEND |    /* growing the file does not occur until\n                                      ** the write succeeds */\n        SQLITE_IOCAP_SEQUENTIAL |     /* The ram filesystem has no write behind\n                                      ** so it is ordered */\n        0;\n    }else if( !strcmp(fsInfo.f_basetype, \"qnx6\") ){\n      pFile->sectorSize = fsInfo.f_bsize;\n      pFile->deviceCharacteristics =\n        SQLITE_IOCAP_ATOMIC |         /* All filesystem writes are atomic */\n        SQLITE_IOCAP_SAFE_APPEND |    /* growing the file does not occur until\n                                      ** the write succeeds */\n        SQLITE_IOCAP_SEQUENTIAL |     /* The ram filesystem has no write behind\n                                      ** so it is ordered */\n        0;\n    }else if( !strcmp(fsInfo.f_basetype, \"qnx4\") ){\n      pFile->sectorSize = fsInfo.f_bsize;\n      pFile->deviceCharacteristics =\n        /* full bitset of atomics from max sector size and smaller */\n        ((pFile->sectorSize / 512 * SQLITE_IOCAP_ATOMIC512) << 1) - 2 |\n        SQLITE_IOCAP_SEQUENTIAL |     /* The ram filesystem has no write behind\n                                      ** so it is ordered */\n        0;\n    }else if( strstr(fsInfo.f_basetype, \"dos\") ){\n      pFile->sectorSize = fsInfo.f_bsize;\n      pFile->deviceCharacteristics =\n        /* full bitset of atomics from max sector size and smaller */\n        ((pFile->sectorSize / 512 * SQLITE_IOCAP_ATOMIC512) << 1) - 2 |\n        SQLITE_IOCAP_SEQUENTIAL |     /* The ram filesystem has no write behind\n                                      ** so it is ordered */\n        0;\n    }else{\n      pFile->deviceCharacteristics =\n        SQLITE_IOCAP_ATOMIC512 |      /* blocks are atomic */\n        SQLITE_IOCAP_SAFE_APPEND |    /* growing the file does not occur until\n                                      ** the write succeeds */\n        0;\n    }\n  }\n  /* Last chance verification.  If the sector size isn't a multiple of 512\n  ** then it isn't valid.*/\n  if( pFile->sectorSize % 512 != 0 ){\n    pFile->deviceCharacteristics = 0;\n    pFile->sectorSize = SQLITE_DEFAULT_SECTOR_SIZE;\n  }\n}\n#endif\n\n/*\n** Return the sector size in bytes of the underlying block device for\n** the specified file. This is almost always 512 bytes, but may be\n** larger for some devices.\n**\n** SQLite code assumes this function cannot fail. It also assumes that\n** if two files are created in the same file-system directory (i.e.\n** a database and its journal file) that the sector size will be the\n** same for both.\n*/\nstatic int unixSectorSize(sqlite3_file *id){\n  unixFile *pFd = (unixFile*)id;\n  setDeviceCharacteristics(pFd);\n  return pFd->sectorSize;\n}\n\n/*\n** Return the device characteristics for the file.\n**\n** This VFS is set up to return SQLITE_IOCAP_POWERSAFE_OVERWRITE by default.\n** However, that choice is controversial since technically the underlying\n** file system does not always provide powersafe overwrites.  (In other\n** words, after a power-loss event, parts of the file that were never\n** written might end up being altered.)  However, non-PSOW behavior is very,\n** very rare.  And asserting PSOW makes a large reduction in the amount\n** of required I/O for journaling, since a lot of padding is eliminated.\n**  Hence, while POWERSAFE_OVERWRITE is on by default, there is a file-control\n** available to turn it off and URI query parameter available to turn it off.\n*/\nstatic int unixDeviceCharacteristics(sqlite3_file *id){\n  unixFile *pFd = (unixFile*)id;\n  setDeviceCharacteristics(pFd);\n  return pFd->deviceCharacteristics;\n}\n\n#if !defined(SQLITE_OMIT_WAL) || SQLITE_MAX_MMAP_SIZE>0\n\n/*\n** Return the system page size.\n**\n** This function should not be called directly by other code in this file. \n** Instead, it should be called via macro osGetpagesize().\n*/\nstatic int unixGetpagesize(void){\n#if OS_VXWORKS\n  return 1024;\n#elif defined(_BSD_SOURCE)\n  return getpagesize();\n#else\n  return (int)sysconf(_SC_PAGESIZE);\n#endif\n}\n\n#endif /* !defined(SQLITE_OMIT_WAL) || SQLITE_MAX_MMAP_SIZE>0 */\n\n#ifndef SQLITE_OMIT_WAL\n\n/*\n** Object used to represent an shared memory buffer.  \n**\n** When multiple threads all reference the same wal-index, each thread\n** has its own unixShm object, but they all point to a single instance\n** of this unixShmNode object.  In other words, each wal-index is opened\n** only once per process.\n**\n** Each unixShmNode object is connected to a single unixInodeInfo object.\n** We could coalesce this object into unixInodeInfo, but that would mean\n** every open file that does not use shared memory (in other words, most\n** open files) would have to carry around this extra information.  So\n** the unixInodeInfo object contains a pointer to this unixShmNode object\n** and the unixShmNode object is created only when needed.\n**\n** unixMutexHeld() must be true when creating or destroying\n** this object or while reading or writing the following fields:\n**\n**      nRef\n**\n** The following fields are read-only after the object is created:\n** \n**      hShm\n**      zFilename\n**\n** Either unixShmNode.pShmMutex must be held or unixShmNode.nRef==0 and\n** unixMutexHeld() is true when reading or writing any other field\n** in this structure.\n*/\nstruct unixShmNode {\n  unixInodeInfo *pInode;     /* unixInodeInfo that owns this SHM node */\n  sqlite3_mutex *pShmMutex;  /* Mutex to access this object */\n  char *zFilename;           /* Name of the mmapped file */\n  int hShm;                  /* Open file descriptor */\n  int szRegion;              /* Size of shared-memory regions */\n  u16 nRegion;               /* Size of array apRegion */\n  u8 isReadonly;             /* True if read-only */\n  u8 isUnlocked;             /* True if no DMS lock held */\n  char **apRegion;           /* Array of mapped shared-memory regions */\n  int nRef;                  /* Number of unixShm objects pointing to this */\n  unixShm *pFirst;           /* All unixShm objects pointing to this */\n#ifdef SQLITE_DEBUG\n  u8 exclMask;               /* Mask of exclusive locks held */\n  u8 sharedMask;             /* Mask of shared locks held */\n  u8 nextShmId;              /* Next available unixShm.id value */\n#endif\n};\n\n/*\n** Structure used internally by this VFS to record the state of an\n** open shared memory connection.\n**\n** The following fields are initialized when this object is created and\n** are read-only thereafter:\n**\n**    unixShm.pShmNode\n**    unixShm.id\n**\n** All other fields are read/write.  The unixShm.pShmNode->pShmMutex must\n** be held while accessing any read/write fields.\n*/\nstruct unixShm {\n  unixShmNode *pShmNode;     /* The underlying unixShmNode object */\n  unixShm *pNext;            /* Next unixShm with the same unixShmNode */\n  u8 hasMutex;               /* True if holding the unixShmNode->pShmMutex */\n  u8 id;                     /* Id of this connection within its unixShmNode */\n  u16 sharedMask;            /* Mask of shared locks held */\n  u16 exclMask;              /* Mask of exclusive locks held */\n};\n\n/*\n** Constants used for locking\n*/\n#define UNIX_SHM_BASE   ((22+SQLITE_SHM_NLOCK)*4)         /* first lock byte */\n#define UNIX_SHM_DMS    (UNIX_SHM_BASE+SQLITE_SHM_NLOCK)  /* deadman switch */\n\n/*\n** Apply posix advisory locks for all bytes from ofst through ofst+n-1.\n**\n** Locks block if the mask is exactly UNIX_SHM_C and are non-blocking\n** otherwise.\n*/\nstatic int unixShmSystemLock(\n  unixFile *pFile,       /* Open connection to the WAL file */\n  int lockType,          /* F_UNLCK, F_RDLCK, or F_WRLCK */\n  int ofst,              /* First byte of the locking range */\n  int n                  /* Number of bytes to lock */\n){\n  unixShmNode *pShmNode; /* Apply locks to this open shared-memory segment */\n  struct flock f;        /* The posix advisory locking structure */\n  int rc = SQLITE_OK;    /* Result code form fcntl() */\n\n  /* Access to the unixShmNode object is serialized by the caller */\n  pShmNode = pFile->pInode->pShmNode;\n  assert( pShmNode->nRef==0 || sqlite3_mutex_held(pShmNode->pShmMutex) );\n  assert( pShmNode->nRef>0 || unixMutexHeld() );\n\n  /* Shared locks never span more than one byte */\n  assert( n==1 || lockType!=F_RDLCK );\n\n  /* Locks are within range */\n  assert( n>=1 && n<=SQLITE_SHM_NLOCK );\n\n  if( pShmNode->hShm>=0 ){\n    /* Initialize the locking parameters */\n    f.l_type = lockType;\n    f.l_whence = SEEK_SET;\n    f.l_start = ofst;\n    f.l_len = n;\n    rc = osSetPosixAdvisoryLock(pShmNode->hShm, &f, pFile);\n    rc = (rc!=(-1)) ? SQLITE_OK : SQLITE_BUSY;\n  }\n\n  /* Update the global lock state and do debug tracing */\n#ifdef SQLITE_DEBUG\n  { u16 mask;\n  OSTRACE((\"SHM-LOCK \"));\n  mask = ofst>31 ? 0xffff : (1<<(ofst+n)) - (1<<ofst);\n  if( rc==SQLITE_OK ){\n    if( lockType==F_UNLCK ){\n      OSTRACE((\"unlock %d ok\", ofst));\n      pShmNode->exclMask &= ~mask;\n      pShmNode->sharedMask &= ~mask;\n    }else if( lockType==F_RDLCK ){\n      OSTRACE((\"read-lock %d ok\", ofst));\n      pShmNode->exclMask &= ~mask;\n      pShmNode->sharedMask |= mask;\n    }else{\n      assert( lockType==F_WRLCK );\n      OSTRACE((\"write-lock %d ok\", ofst));\n      pShmNode->exclMask |= mask;\n      pShmNode->sharedMask &= ~mask;\n    }\n  }else{\n    if( lockType==F_UNLCK ){\n      OSTRACE((\"unlock %d failed\", ofst));\n    }else if( lockType==F_RDLCK ){\n      OSTRACE((\"read-lock failed\"));\n    }else{\n      assert( lockType==F_WRLCK );\n      OSTRACE((\"write-lock %d failed\", ofst));\n    }\n  }\n  OSTRACE((\" - afterwards %03x,%03x\\n\",\n           pShmNode->sharedMask, pShmNode->exclMask));\n  }\n#endif\n\n  return rc;        \n}\n\n/*\n** Return the minimum number of 32KB shm regions that should be mapped at\n** a time, assuming that each mapping must be an integer multiple of the\n** current system page-size.\n**\n** Usually, this is 1. The exception seems to be systems that are configured\n** to use 64KB pages - in this case each mapping must cover at least two\n** shm regions.\n*/\nstatic int unixShmRegionPerMap(void){\n  int shmsz = 32*1024;            /* SHM region size */\n  int pgsz = osGetpagesize();   /* System page size */\n  assert( ((pgsz-1)&pgsz)==0 );   /* Page size must be a power of 2 */\n  if( pgsz<shmsz ) return 1;\n  return pgsz/shmsz;\n}\n\n/*\n** Purge the unixShmNodeList list of all entries with unixShmNode.nRef==0.\n**\n** This is not a VFS shared-memory method; it is a utility function called\n** by VFS shared-memory methods.\n*/\nstatic void unixShmPurge(unixFile *pFd){\n  unixShmNode *p = pFd->pInode->pShmNode;\n  assert( unixMutexHeld() );\n  if( p && ALWAYS(p->nRef==0) ){\n    int nShmPerMap = unixShmRegionPerMap();\n    int i;\n    assert( p->pInode==pFd->pInode );\n    sqlite3_mutex_free(p->pShmMutex);\n    for(i=0; i<p->nRegion; i+=nShmPerMap){\n      if( p->hShm>=0 ){\n        osMunmap(p->apRegion[i], p->szRegion);\n      }else{\n        sqlite3_free(p->apRegion[i]);\n      }\n    }\n    sqlite3_free(p->apRegion);\n    if( p->hShm>=0 ){\n      robust_close(pFd, p->hShm, __LINE__);\n      p->hShm = -1;\n    }\n    p->pInode->pShmNode = 0;\n    sqlite3_free(p);\n  }\n}\n\n/*\n** The DMS lock has not yet been taken on shm file pShmNode. Attempt to\n** take it now. Return SQLITE_OK if successful, or an SQLite error\n** code otherwise.\n**\n** If the DMS cannot be locked because this is a readonly_shm=1 \n** connection and no other process already holds a lock, return\n** SQLITE_READONLY_CANTINIT and set pShmNode->isUnlocked=1.\n*/\nstatic int unixLockSharedMemory(unixFile *pDbFd, unixShmNode *pShmNode){\n  struct flock lock;\n  int rc = SQLITE_OK;\n\n  /* Use F_GETLK to determine the locks other processes are holding\n  ** on the DMS byte. If it indicates that another process is holding\n  ** a SHARED lock, then this process may also take a SHARED lock\n  ** and proceed with opening the *-shm file. \n  **\n  ** Or, if no other process is holding any lock, then this process\n  ** is the first to open it. In this case take an EXCLUSIVE lock on the\n  ** DMS byte and truncate the *-shm file to zero bytes in size. Then\n  ** downgrade to a SHARED lock on the DMS byte.\n  **\n  ** If another process is holding an EXCLUSIVE lock on the DMS byte,\n  ** return SQLITE_BUSY to the caller (it will try again). An earlier\n  ** version of this code attempted the SHARED lock at this point. But\n  ** this introduced a subtle race condition: if the process holding\n  ** EXCLUSIVE failed just before truncating the *-shm file, then this\n  ** process might open and use the *-shm file without truncating it.\n  ** And if the *-shm file has been corrupted by a power failure or\n  ** system crash, the database itself may also become corrupt.  */\n  lock.l_whence = SEEK_SET;\n  lock.l_start = UNIX_SHM_DMS;\n  lock.l_len = 1;\n  lock.l_type = F_WRLCK;\n  if( osFcntl(pShmNode->hShm, F_GETLK, &lock)!=0 ) {\n    rc = SQLITE_IOERR_LOCK;\n  }else if( lock.l_type==F_UNLCK ){\n    if( pShmNode->isReadonly ){\n      pShmNode->isUnlocked = 1;\n      rc = SQLITE_READONLY_CANTINIT;\n    }else{\n      rc = unixShmSystemLock(pDbFd, F_WRLCK, UNIX_SHM_DMS, 1);\n      /* The first connection to attach must truncate the -shm file.  We\n      ** truncate to 3 bytes (an arbitrary small number, less than the\n      ** -shm header size) rather than 0 as a system debugging aid, to\n      ** help detect if a -shm file truncation is legitimate or is the work\n      ** or a rogue process. */\n      if( rc==SQLITE_OK && robust_ftruncate(pShmNode->hShm, 3) ){\n        rc = unixLogError(SQLITE_IOERR_SHMOPEN,\"ftruncate\",pShmNode->zFilename);\n      }\n    }\n  }else if( lock.l_type==F_WRLCK ){\n    rc = SQLITE_BUSY;\n  }\n\n  if( rc==SQLITE_OK ){\n    assert( lock.l_type==F_UNLCK || lock.l_type==F_RDLCK );\n    rc = unixShmSystemLock(pDbFd, F_RDLCK, UNIX_SHM_DMS, 1);\n  }\n  return rc;\n}\n\n/*\n** Open a shared-memory area associated with open database file pDbFd.  \n** This particular implementation uses mmapped files.\n**\n** The file used to implement shared-memory is in the same directory\n** as the open database file and has the same name as the open database\n** file with the \"-shm\" suffix added.  For example, if the database file\n** is \"/home/user1/config.db\" then the file that is created and mmapped\n** for shared memory will be called \"/home/user1/config.db-shm\".  \n**\n** Another approach to is to use files in /dev/shm or /dev/tmp or an\n** some other tmpfs mount. But if a file in a different directory\n** from the database file is used, then differing access permissions\n** or a chroot() might cause two different processes on the same\n** database to end up using different files for shared memory - \n** meaning that their memory would not really be shared - resulting\n** in database corruption.  Nevertheless, this tmpfs file usage\n** can be enabled at compile-time using -DSQLITE_SHM_DIRECTORY=\"/dev/shm\"\n** or the equivalent.  The use of the SQLITE_SHM_DIRECTORY compile-time\n** option results in an incompatible build of SQLite;  builds of SQLite\n** that with differing SQLITE_SHM_DIRECTORY settings attempt to use the\n** same database file at the same time, database corruption will likely\n** result. The SQLITE_SHM_DIRECTORY compile-time option is considered\n** \"unsupported\" and may go away in a future SQLite release.\n**\n** When opening a new shared-memory file, if no other instances of that\n** file are currently open, in this process or in other processes, then\n** the file must be truncated to zero length or have its header cleared.\n**\n** If the original database file (pDbFd) is using the \"unix-excl\" VFS\n** that means that an exclusive lock is held on the database file and\n** that no other processes are able to read or write the database.  In\n** that case, we do not really need shared memory.  No shared memory\n** file is created.  The shared memory will be simulated with heap memory.\n*/\nstatic int unixOpenSharedMemory(unixFile *pDbFd){\n  struct unixShm *p = 0;          /* The connection to be opened */\n  struct unixShmNode *pShmNode;   /* The underlying mmapped file */\n  int rc = SQLITE_OK;             /* Result code */\n  unixInodeInfo *pInode;          /* The inode of fd */\n  char *zShm;             /* Name of the file used for SHM */\n  int nShmFilename;               /* Size of the SHM filename in bytes */\n\n  /* Allocate space for the new unixShm object. */\n  p = sqlite3_malloc64( sizeof(*p) );\n  if( p==0 ) return SQLITE_NOMEM_BKPT;\n  memset(p, 0, sizeof(*p));\n  assert( pDbFd->pShm==0 );\n\n  /* Check to see if a unixShmNode object already exists. Reuse an existing\n  ** one if present. Create a new one if necessary.\n  */\n  assert( unixFileMutexNotheld(pDbFd) );\n  unixEnterMutex();\n  pInode = pDbFd->pInode;\n  pShmNode = pInode->pShmNode;\n  if( pShmNode==0 ){\n    struct stat sStat;                 /* fstat() info for database file */\n#ifndef SQLITE_SHM_DIRECTORY\n    const char *zBasePath = pDbFd->zPath;\n#endif\n\n    /* Call fstat() to figure out the permissions on the database file. If\n    ** a new *-shm file is created, an attempt will be made to create it\n    ** with the same permissions.\n    */\n    if( osFstat(pDbFd->h, &sStat) ){\n      rc = SQLITE_IOERR_FSTAT;\n      goto shm_open_err;\n    }\n\n#ifdef SQLITE_SHM_DIRECTORY\n    nShmFilename = sizeof(SQLITE_SHM_DIRECTORY) + 31;\n#else\n    nShmFilename = 6 + (int)strlen(zBasePath);\n#endif\n    pShmNode = sqlite3_malloc64( sizeof(*pShmNode) + nShmFilename );\n    if( pShmNode==0 ){\n      rc = SQLITE_NOMEM_BKPT;\n      goto shm_open_err;\n    }\n    memset(pShmNode, 0, sizeof(*pShmNode)+nShmFilename);\n    zShm = pShmNode->zFilename = (char*)&pShmNode[1];\n#ifdef SQLITE_SHM_DIRECTORY\n    sqlite3_snprintf(nShmFilename, zShm, \n                     SQLITE_SHM_DIRECTORY \"/sqlite-shm-%x-%x\",\n                     (u32)sStat.st_ino, (u32)sStat.st_dev);\n#else\n    sqlite3_snprintf(nShmFilename, zShm, \"%s-shm\", zBasePath);\n    sqlite3FileSuffix3(pDbFd->zPath, zShm);\n#endif\n    pShmNode->hShm = -1;\n    pDbFd->pInode->pShmNode = pShmNode;\n    pShmNode->pInode = pDbFd->pInode;\n    if( sqlite3GlobalConfig.bCoreMutex ){\n      pShmNode->pShmMutex = sqlite3_mutex_alloc(SQLITE_MUTEX_FAST);\n      if( pShmNode->pShmMutex==0 ){\n        rc = SQLITE_NOMEM_BKPT;\n        goto shm_open_err;\n      }\n    }\n\n    if( pInode->bProcessLock==0 ){\n      if( 0==sqlite3_uri_boolean(pDbFd->zPath, \"readonly_shm\", 0) ){\n        pShmNode->hShm = robust_open(zShm, O_RDWR|O_CREAT,(sStat.st_mode&0777));\n      }\n      if( pShmNode->hShm<0 ){\n        pShmNode->hShm = robust_open(zShm, O_RDONLY, (sStat.st_mode&0777));\n        if( pShmNode->hShm<0 ){\n          rc = unixLogError(SQLITE_CANTOPEN_BKPT, \"open\", zShm);\n          goto shm_open_err;\n        }\n        pShmNode->isReadonly = 1;\n      }\n\n      /* If this process is running as root, make sure that the SHM file\n      ** is owned by the same user that owns the original database.  Otherwise,\n      ** the original owner will not be able to connect.\n      */\n      robustFchown(pShmNode->hShm, sStat.st_uid, sStat.st_gid);\n\n      rc = unixLockSharedMemory(pDbFd, pShmNode);\n      if( rc!=SQLITE_OK && rc!=SQLITE_READONLY_CANTINIT ) goto shm_open_err;\n    }\n  }\n\n  /* Make the new connection a child of the unixShmNode */\n  p->pShmNode = pShmNode;\n#ifdef SQLITE_DEBUG\n  p->id = pShmNode->nextShmId++;\n#endif\n  pShmNode->nRef++;\n  pDbFd->pShm = p;\n  unixLeaveMutex();\n\n  /* The reference count on pShmNode has already been incremented under\n  ** the cover of the unixEnterMutex() mutex and the pointer from the\n  ** new (struct unixShm) object to the pShmNode has been set. All that is\n  ** left to do is to link the new object into the linked list starting\n  ** at pShmNode->pFirst. This must be done while holding the\n  ** pShmNode->pShmMutex.\n  */\n  sqlite3_mutex_enter(pShmNode->pShmMutex);\n  p->pNext = pShmNode->pFirst;\n  pShmNode->pFirst = p;\n  sqlite3_mutex_leave(pShmNode->pShmMutex);\n  return rc;\n\n  /* Jump here on any error */\nshm_open_err:\n  unixShmPurge(pDbFd);       /* This call frees pShmNode if required */\n  sqlite3_free(p);\n  unixLeaveMutex();\n  return rc;\n}\n\n/*\n** This function is called to obtain a pointer to region iRegion of the \n** shared-memory associated with the database file fd. Shared-memory regions \n** are numbered starting from zero. Each shared-memory region is szRegion \n** bytes in size.\n**\n** If an error occurs, an error code is returned and *pp is set to NULL.\n**\n** Otherwise, if the bExtend parameter is 0 and the requested shared-memory\n** region has not been allocated (by any client, including one running in a\n** separate process), then *pp is set to NULL and SQLITE_OK returned. If \n** bExtend is non-zero and the requested shared-memory region has not yet \n** been allocated, it is allocated by this function.\n**\n** If the shared-memory region has already been allocated or is allocated by\n** this call as described above, then it is mapped into this processes \n** address space (if it is not already), *pp is set to point to the mapped \n** memory and SQLITE_OK returned.\n*/\nstatic int unixShmMap(\n  sqlite3_file *fd,               /* Handle open on database file */\n  int iRegion,                    /* Region to retrieve */\n  int szRegion,                   /* Size of regions */\n  int bExtend,                    /* True to extend file if necessary */\n  void volatile **pp              /* OUT: Mapped memory */\n){\n  unixFile *pDbFd = (unixFile*)fd;\n  unixShm *p;\n  unixShmNode *pShmNode;\n  int rc = SQLITE_OK;\n  int nShmPerMap = unixShmRegionPerMap();\n  int nReqRegion;\n\n  /* If the shared-memory file has not yet been opened, open it now. */\n  if( pDbFd->pShm==0 ){\n    rc = unixOpenSharedMemory(pDbFd);\n    if( rc!=SQLITE_OK ) return rc;\n  }\n\n  p = pDbFd->pShm;\n  pShmNode = p->pShmNode;\n  sqlite3_mutex_enter(pShmNode->pShmMutex);\n  if( pShmNode->isUnlocked ){\n    rc = unixLockSharedMemory(pDbFd, pShmNode);\n    if( rc!=SQLITE_OK ) goto shmpage_out;\n    pShmNode->isUnlocked = 0;\n  }\n  assert( szRegion==pShmNode->szRegion || pShmNode->nRegion==0 );\n  assert( pShmNode->pInode==pDbFd->pInode );\n  assert( pShmNode->hShm>=0 || pDbFd->pInode->bProcessLock==1 );\n  assert( pShmNode->hShm<0 || pDbFd->pInode->bProcessLock==0 );\n\n  /* Minimum number of regions required to be mapped. */\n  nReqRegion = ((iRegion+nShmPerMap) / nShmPerMap) * nShmPerMap;\n\n  if( pShmNode->nRegion<nReqRegion ){\n    char **apNew;                      /* New apRegion[] array */\n    int nByte = nReqRegion*szRegion;   /* Minimum required file size */\n    struct stat sStat;                 /* Used by fstat() */\n\n    pShmNode->szRegion = szRegion;\n\n    if( pShmNode->hShm>=0 ){\n      /* The requested region is not mapped into this processes address space.\n      ** Check to see if it has been allocated (i.e. if the wal-index file is\n      ** large enough to contain the requested region).\n      */\n      if( osFstat(pShmNode->hShm, &sStat) ){\n        rc = SQLITE_IOERR_SHMSIZE;\n        goto shmpage_out;\n      }\n  \n      if( sStat.st_size<nByte ){\n        /* The requested memory region does not exist. If bExtend is set to\n        ** false, exit early. *pp will be set to NULL and SQLITE_OK returned.\n        */\n        if( !bExtend ){\n          goto shmpage_out;\n        }\n\n        /* Alternatively, if bExtend is true, extend the file. Do this by\n        ** writing a single byte to the end of each (OS) page being\n        ** allocated or extended. Technically, we need only write to the\n        ** last page in order to extend the file. But writing to all new\n        ** pages forces the OS to allocate them immediately, which reduces\n        ** the chances of SIGBUS while accessing the mapped region later on.\n        */\n        else{\n          static const int pgsz = 4096;\n          int iPg;\n\n          /* Write to the last byte of each newly allocated or extended page */\n          assert( (nByte % pgsz)==0 );\n          for(iPg=(sStat.st_size/pgsz); iPg<(nByte/pgsz); iPg++){\n            int x = 0;\n            if( seekAndWriteFd(pShmNode->hShm, iPg*pgsz + pgsz-1,\"\",1,&x)!=1 ){\n              const char *zFile = pShmNode->zFilename;\n              rc = unixLogError(SQLITE_IOERR_SHMSIZE, \"write\", zFile);\n              goto shmpage_out;\n            }\n          }\n        }\n      }\n    }\n\n    /* Map the requested memory region into this processes address space. */\n    apNew = (char **)sqlite3_realloc(\n        pShmNode->apRegion, nReqRegion*sizeof(char *)\n    );\n    if( !apNew ){\n      rc = SQLITE_IOERR_NOMEM_BKPT;\n      goto shmpage_out;\n    }\n    pShmNode->apRegion = apNew;\n    while( pShmNode->nRegion<nReqRegion ){\n      int nMap = szRegion*nShmPerMap;\n      int i;\n      void *pMem;\n      if( pShmNode->hShm>=0 ){\n        pMem = osMmap(0, nMap,\n            pShmNode->isReadonly ? PROT_READ : PROT_READ|PROT_WRITE, \n            MAP_SHARED, pShmNode->hShm, szRegion*(i64)pShmNode->nRegion\n        );\n        if( pMem==MAP_FAILED ){\n          rc = unixLogError(SQLITE_IOERR_SHMMAP, \"mmap\", pShmNode->zFilename);\n          goto shmpage_out;\n        }\n      }else{\n        pMem = sqlite3_malloc64(nMap);\n        if( pMem==0 ){\n          rc = SQLITE_NOMEM_BKPT;\n          goto shmpage_out;\n        }\n        memset(pMem, 0, nMap);\n      }\n\n      for(i=0; i<nShmPerMap; i++){\n        pShmNode->apRegion[pShmNode->nRegion+i] = &((char*)pMem)[szRegion*i];\n      }\n      pShmNode->nRegion += nShmPerMap;\n    }\n  }\n\nshmpage_out:\n  if( pShmNode->nRegion>iRegion ){\n    *pp = pShmNode->apRegion[iRegion];\n  }else{\n    *pp = 0;\n  }\n  if( pShmNode->isReadonly && rc==SQLITE_OK ) rc = SQLITE_READONLY;\n  sqlite3_mutex_leave(pShmNode->pShmMutex);\n  return rc;\n}\n\n/*\n** Change the lock state for a shared-memory segment.\n**\n** Note that the relationship between SHAREd and EXCLUSIVE locks is a little\n** different here than in posix.  In xShmLock(), one can go from unlocked\n** to shared and back or from unlocked to exclusive and back.  But one may\n** not go from shared to exclusive or from exclusive to shared.\n*/\nstatic int unixShmLock(\n  sqlite3_file *fd,          /* Database file holding the shared memory */\n  int ofst,                  /* First lock to acquire or release */\n  int n,                     /* Number of locks to acquire or release */\n  int flags                  /* What to do with the lock */\n){\n  unixFile *pDbFd = (unixFile*)fd;      /* Connection holding shared memory */\n  unixShm *p = pDbFd->pShm;             /* The shared memory being locked */\n  unixShm *pX;                          /* For looping over all siblings */\n  unixShmNode *pShmNode = p->pShmNode;  /* The underlying file iNode */\n  int rc = SQLITE_OK;                   /* Result code */\n  u16 mask;                             /* Mask of locks to take or release */\n\n  assert( pShmNode==pDbFd->pInode->pShmNode );\n  assert( pShmNode->pInode==pDbFd->pInode );\n  assert( ofst>=0 && ofst+n<=SQLITE_SHM_NLOCK );\n  assert( n>=1 );\n  assert( flags==(SQLITE_SHM_LOCK | SQLITE_SHM_SHARED)\n       || flags==(SQLITE_SHM_LOCK | SQLITE_SHM_EXCLUSIVE)\n       || flags==(SQLITE_SHM_UNLOCK | SQLITE_SHM_SHARED)\n       || flags==(SQLITE_SHM_UNLOCK | SQLITE_SHM_EXCLUSIVE) );\n  assert( n==1 || (flags & SQLITE_SHM_EXCLUSIVE)!=0 );\n  assert( pShmNode->hShm>=0 || pDbFd->pInode->bProcessLock==1 );\n  assert( pShmNode->hShm<0 || pDbFd->pInode->bProcessLock==0 );\n\n  mask = (1<<(ofst+n)) - (1<<ofst);\n  assert( n>1 || mask==(1<<ofst) );\n  \n#ifdef SQLITE_WCDB_LOCK_HOOK\n  if (unixLockHook.xWillShmLock != NULL && (flags & SQLITE_SHM_LOCK) != 0) {\n    unixLockHook.xWillShmLock(unixLockHook.pArg,\n                              pDbFd->zPath,\n                              flags & (SQLITE_SHM_SHARED | SQLITE_SHM_EXCLUSIVE),\n                              mask);\n  }\n#endif\n    \n  sqlite3_mutex_enter(pShmNode->pShmMutex);\n  if( flags & SQLITE_SHM_UNLOCK ){\n    u16 allMask = 0; /* Mask of locks held by siblings */\n\n    /* See if any siblings hold this same lock */\n    for(pX=pShmNode->pFirst; pX; pX=pX->pNext){\n      if( pX==p ) continue;\n      assert( (pX->exclMask & (p->exclMask|p->sharedMask))==0 );\n      allMask |= pX->sharedMask;\n    }\n\n    /* Unlock the system-level locks */\n    if( (mask & allMask)==0 ){\n      rc = unixShmSystemLock(pDbFd, F_UNLCK, ofst+UNIX_SHM_BASE, n);\n    }else{\n      rc = SQLITE_OK;\n    }\n\n    /* Undo the local locks */\n    if( rc==SQLITE_OK ){\n      p->exclMask &= ~mask;\n      p->sharedMask &= ~mask;\n#ifdef SQLITE_WCDB_LOCK_HOOK\n      if (unixLockHook.xShmLockDidChange != NULL) {\n        unixLockHook.xShmLockDidChange(unixLockHook.pArg, pDbFd->zPath, p, p->sharedMask, p->exclMask);\n      }\n#endif\n    }\n  }else if( flags & SQLITE_SHM_SHARED ){\n    u16 allShared = 0;  /* Union of locks held by connections other than \"p\" */\n\n    /* Find out which shared locks are already held by sibling connections.\n    ** If any sibling already holds an exclusive lock, go ahead and return\n    ** SQLITE_BUSY.\n    */\n    for(pX=pShmNode->pFirst; pX; pX=pX->pNext){\n      if( (pX->exclMask & mask)!=0 ){\n        rc = SQLITE_BUSY;\n        break;\n      }\n      allShared |= pX->sharedMask;\n    }\n\n    /* Get shared locks at the system level, if necessary */\n    if( rc==SQLITE_OK ){\n      if( (allShared & mask)==0 ){\n        rc = unixShmSystemLock(pDbFd, F_RDLCK, ofst+UNIX_SHM_BASE, n);\n      }else{\n        rc = SQLITE_OK;\n      }\n    }\n\n    /* Get the local shared locks */\n    if( rc==SQLITE_OK ){\n      p->sharedMask |= mask;\n#ifdef SQLITE_WCDB_LOCK_HOOK\n      if (unixLockHook.xShmLockDidChange != NULL) {\n          unixLockHook.xShmLockDidChange(unixLockHook.pArg, pDbFd->zPath, p, p->sharedMask, p->exclMask);\n      }\n#endif\n    }\n  }else{\n    /* Make sure no sibling connections hold locks that will block this\n    ** lock.  If any do, return SQLITE_BUSY right away.\n    */\n    for(pX=pShmNode->pFirst; pX; pX=pX->pNext){\n      if( (pX->exclMask & mask)!=0 || (pX->sharedMask & mask)!=0 ){\n        rc = SQLITE_BUSY;\n        break;\n      }\n    }\n  \n    /* Get the exclusive locks at the system level.  Then if successful\n    ** also mark the local connection as being locked.\n    */\n    if( rc==SQLITE_OK ){\n      rc = unixShmSystemLock(pDbFd, F_WRLCK, ofst+UNIX_SHM_BASE, n);\n      if( rc==SQLITE_OK ){\n        assert( (p->sharedMask & mask)==0 );\n        p->exclMask |= mask;\n#ifdef SQLITE_WCDB_LOCK_HOOK\n        if (unixLockHook.xShmLockDidChange != NULL) {\n            unixLockHook.xShmLockDidChange(unixLockHook.pArg, pDbFd->zPath, p, p->sharedMask, p->exclMask);\n        }\n#endif\n      }\n    }\n  }\n  sqlite3_mutex_leave(pShmNode->pShmMutex);\n  OSTRACE((\"SHM-LOCK shmid-%d, pid-%d got %03x,%03x\\n\",\n           p->id, osGetpid(0), p->sharedMask, p->exclMask));\n  return rc;\n}\n\n/*\n** Implement a memory barrier or memory fence on shared memory.  \n**\n** All loads and stores begun before the barrier must complete before\n** any load or store begun after the barrier.\n*/\nstatic void unixShmBarrier(\n  sqlite3_file *fd                /* Database file holding the shared memory */\n){\n  UNUSED_PARAMETER(fd);\n  sqlite3MemoryBarrier();         /* compiler-defined memory barrier */\n  assert( fd->pMethods->xLock==nolockLock \n       || unixFileMutexNotheld((unixFile*)fd) \n  );\n  unixEnterMutex();               /* Also mutex, for redundancy */\n  unixLeaveMutex();\n}\n\n/*\n** Close a connection to shared-memory.  Delete the underlying \n** storage if deleteFlag is true.\n**\n** If there is no shared memory associated with the connection then this\n** routine is a harmless no-op.\n*/\nstatic int unixShmUnmap(\n  sqlite3_file *fd,               /* The underlying database file */\n  int deleteFlag                  /* Delete shared-memory if true */\n){\n  unixShm *p;                     /* The connection to be closed */\n  unixShmNode *pShmNode;          /* The underlying shared-memory file */\n  unixShm **pp;                   /* For looping over sibling connections */\n  unixFile *pDbFd;                /* The underlying database file */\n\n  pDbFd = (unixFile*)fd;\n  p = pDbFd->pShm;\n  if( p==0 ) return SQLITE_OK;\n  pShmNode = p->pShmNode;\n\n  assert( pShmNode==pDbFd->pInode->pShmNode );\n  assert( pShmNode->pInode==pDbFd->pInode );\n\n  /* Remove connection p from the set of connections associated\n  ** with pShmNode */\n  sqlite3_mutex_enter(pShmNode->pShmMutex);\n  for(pp=&pShmNode->pFirst; (*pp)!=p; pp = &(*pp)->pNext){}\n  *pp = p->pNext;\n\n  /* Free the connection p */\n#ifdef SQLITE_WCDB_LOCK_HOOK\n  if (unixLockHook.xShmLockDidChange != NULL) {\n    unixLockHook.xShmLockDidChange(unixLockHook.pArg, pDbFd->zPath, p, 0, 0);\n  }\n#endif\n  sqlite3_free(p);\n  pDbFd->pShm = 0;\n  sqlite3_mutex_leave(pShmNode->pShmMutex);\n\n  /* If pShmNode->nRef has reached 0, then close the underlying\n  ** shared-memory file, too */\n  assert( unixFileMutexNotheld(pDbFd) );\n  unixEnterMutex();\n  assert( pShmNode->nRef>0 );\n  pShmNode->nRef--;\n  if( pShmNode->nRef==0 ){\n    if( deleteFlag && pShmNode->hShm>=0 ){\n      osUnlink(pShmNode->zFilename);\n    }\n    unixShmPurge(pDbFd);\n  }\n  unixLeaveMutex();\n\n  return SQLITE_OK;\n}\n\n#ifdef SQLITE_WCDB\nvoid unixCheckOpenShm(sqlite3_file *fd, int *opened)\n{\n  unixFile *file = (unixFile*)fd;\n  if(file->pInode == 0){\n    /*\n    ** pInode should be assigned before the call of this routine.\n    ** Set opened to 1 to avoid further operations.\n     */\n    *opened = 1;\n  }else if(file->pInode->pShmNode){\n    *opened = 1;\n  }else{\n    *opened = 0;\n  }\n}\n\nint unixEnterMutexAndLockShm(sqlite3_file *fd)\n{\n  unixEnterMutex();\n  int shmFd = -1;                    /* File Descriptpr of SHM file */\n  \n  int opened = 0;\n  unixCheckOpenShm(fd, &opened);\n  if(opened){\n    return shmFd;\n  }\n  \n  unixFile *pDbFd = (unixFile*)fd;\n  int nShmFileNameLength;            /* Size of the SHM filename in bytes */\n  char* shmFileName = 0;             /* Path of SHM file*/\n  struct stat sStat;                 /* fstat() info for database file */\n  \n  /* Call fstat() to figure out the permissions on the database file. If\n  ** a new *-shm file is created, an attempt will be made to create it\n  ** with the same permissions.\n  */\n  if(pDbFd->h>=0 && osFstat(pDbFd->h, &sStat) ){\n    goto shm_lock_finish;\n  }\n#ifdef SQLITE_SHM_DIRECTORY\n  nShmFileNameLength = sizeof(SQLITE_SHM_DIRECTORY) + 31;\n#else\n  const char *zBasePath = pDbFd->zPath;\n  nShmFileNameLength = 6 + (int)strlen(zBasePath);\n#endif\n  shmFileName = sqlite3_malloc64(nShmFileNameLength);\n  \n#ifdef SQLITE_SHM_DIRECTORY\n  sqlite3_snprintf(nShmFilename, shmFileName,\n                   SQLITE_SHM_DIRECTORY \"/sqlite-shm-%x-%x\",\n                   (u32)sStat.st_ino, (u32)sStat.st_dev);\n#else\n  sqlite3_snprintf(nShmFileNameLength, shmFileName, \"%s-shm\", zBasePath);\n  sqlite3FileSuffix3(pDbFd->zPath, zShm);\n#endif\n  \n  shmFd = robust_open(shmFileName, O_RDONLY, (sStat.st_mode&0777));\n  if(shmFd<0){\n    goto shm_lock_finish;\n  }\n  /* If this process is running as root, make sure that the SHM file\n  ** is owned by the same user that owns the original database.  Otherwise,\n  ** the original owner will not be able to connect.\n  */\n  robustFchown(shmFd, sStat.st_uid, sStat.st_gid);\n  \n  struct flock f;        /* The posix advisory locking structure */\n  f.l_type = F_WRLCK;\n  f.l_whence = SEEK_SET;\n  f.l_start = UNIX_SHM_DMS;\n  f.l_len = 1;\n  if(osSetPosixAdvisoryLock(shmFd, &f, pFile)!=SQLITE_OK){\n    robust_close(0, shmFd, __LINE__);\n    shmFd = -1;\n  }\n  \nshm_lock_finish:\n  if(shmFileName != 0){\n    sqlite3_free(shmFileName);\n  }\n  return shmFd;\n}\n\nvoid unixLeaveMutexAndUnLockShm(int shmFd)\n{\n  if(shmFd>=0){\n    struct flock f;        /* The posix advisory locking structure */\n    f.l_type = F_UNLCK;\n    f.l_whence = SEEK_SET;\n    f.l_start = UNIX_SHM_DMS;\n    f.l_len = 1;\n    osSetPosixAdvisoryLock(shmFd, &f, pFile);\n    robust_close(0, shmFd, __LINE__);\n    shmFd = -1;\n  }\n  unixLeaveMutex();\n}\n\nint unixReadShmFile(int shmFd, sqlite3_int64 offset, void *pBuf, int cnt)\n{\n  int rc = SQLITE_OK;                /* Result code */\n  struct stat statBuf;\n  rc = osFstat(shmFd, &statBuf);\n  SimulateIOError( rc=1 );\n  if( rc!=0 ){\n    rc = SQLITE_IOERR_FSTAT;\n    goto shm_read_finish;\n  }\n  if(statBuf.st_size == 1 || statBuf.st_size<offset+cnt){\n    rc = SQLITE_IOERR_SHORT_READ;\n    goto shm_read_finish;\n  }\n\n  /* When opening a zero-size database, the findInodeInfo() procedure\n  ** writes a single byte into that file in order to work around a bug\n  ** in the OS-X msdos filesystem.  In o gbzrder to avoid problems with upper\n  ** layers, we need to report this file size as zero even though it is\n  ** really 1.   Ticket #3260.\n  */\n  int got;\n  int prior = 0;\n  int readLength = cnt;\n  char* readBuf = pBuf;\n#if (!defined(USE_PREAD) && !defined(USE_PREAD64))\n  i64 newOffset;\n#endif\n  assert( readLength==(readLength&0x1ffff) );\n  assert( shmFd>2 );\n  do{\n#if defined(USE_PREAD)\n    got = osPread(shmFd, readBuf, readLength, offset);\n    SimulateIOError( got = -1 );\n#elif defined(USE_PREAD64)\n    got = osPread64(shmFd, readBuf, readLength, offset);\n    SimulateIOError( got = -1 );\n#else\n    newOffset = lseek(shmFd, offset, SEEK_SET);\n    SimulateIOError( newOffset = -1 );\n    if( newOffset<0 ){\n      rc = -1;\n      goto shm_read_finish;\n    }\n    got = osRead(shmFd, readBuf, readLength);\n#endif\n    if( got==readLength ) break;\n    if( got<0 ){\n      if( errno==EINTR ){ got = 1; continue; }\n      prior = 0;\n      break;\n    }else if( got>0 ){\n      readLength -= got;\n      offset += got;\n      prior += got;\n      readBuf = (void*)(got + readBuf);\n    }\n  }while( got>0 );\n  if(got+prior == cnt){\n    rc = SQLITE_OK;\n  }else if(got+prior < 0){\n    rc = SQLITE_IOERR_READ;\n  }else{\n    /* Unread parts of the buffer must be zero-filled */\n    memset(&((char*)pBuf)[got+prior], 0, cnt-got-prior);\n    rc = SQLITE_IOERR_SHORT_READ;\n  }\n  \nshm_read_finish:\n  return rc;\n}\n#endif\n\n#else\n# define unixShmMap                   0\n# define unixShmLock                  0\n# define unixShmBarrier               0\n# define unixShmUnmap                 0\n# define unixCheckOpenShm             0\n# define unixEnterMutexAndLockShm     0\n# define unixLeaveMutexAndUnLockShm   0\n# define unixReadShmFile              0\n#endif /* #ifndef SQLITE_OMIT_WAL */\n\n#if SQLITE_MAX_MMAP_SIZE>0\n/*\n** If it is currently memory mapped, unmap file pFd.\n*/\nstatic void unixUnmapfile(unixFile *pFd){\n  assert( pFd->nFetchOut==0 );\n  if( pFd->pMapRegion ){\n    osMunmap(pFd->pMapRegion, pFd->mmapSizeActual);\n    pFd->pMapRegion = 0;\n    pFd->mmapSize = 0;\n    pFd->mmapSizeActual = 0;\n  }\n}\n\n/*\n** Attempt to set the size of the memory mapping maintained by file \n** descriptor pFd to nNew bytes. Any existing mapping is discarded.\n**\n** If successful, this function sets the following variables:\n**\n**       unixFile.pMapRegion\n**       unixFile.mmapSize\n**       unixFile.mmapSizeActual\n**\n** If unsuccessful, an error message is logged via sqlite3_log() and\n** the three variables above are zeroed. In this case SQLite should\n** continue accessing the database using the xRead() and xWrite()\n** methods.\n*/\nstatic void unixRemapfile(\n  unixFile *pFd,                  /* File descriptor object */\n  i64 nNew                        /* Required mapping size */\n){\n  const char *zErr = \"mmap\";\n  int h = pFd->h;                      /* File descriptor open on db file */\n  u8 *pOrig = (u8 *)pFd->pMapRegion;   /* Pointer to current file mapping */\n  i64 nOrig = pFd->mmapSizeActual;     /* Size of pOrig region in bytes */\n  u8 *pNew = 0;                        /* Location of new mapping */\n  int flags = PROT_READ;               /* Flags to pass to mmap() */\n\n  assert( pFd->nFetchOut==0 );\n  assert( nNew>pFd->mmapSize );\n  assert( nNew<=pFd->mmapSizeMax );\n  assert( nNew>0 );\n  assert( pFd->mmapSizeActual>=pFd->mmapSize );\n  assert( MAP_FAILED!=0 );\n\n#ifdef SQLITE_MMAP_READWRITE\n  if( (pFd->ctrlFlags & UNIXFILE_RDONLY)==0 ) flags |= PROT_WRITE;\n#endif\n\n  if( pOrig ){\n#if HAVE_MREMAP\n    i64 nReuse = pFd->mmapSize;\n#else\n    const int szSyspage = osGetpagesize();\n    i64 nReuse = (pFd->mmapSize & ~(szSyspage-1));\n#endif\n    u8 *pReq = &pOrig[nReuse];\n\n    /* Unmap any pages of the existing mapping that cannot be reused. */\n    if( nReuse!=nOrig ){\n      osMunmap(pReq, nOrig-nReuse);\n    }\n\n#if HAVE_MREMAP\n    pNew = osMremap(pOrig, nReuse, nNew, MREMAP_MAYMOVE);\n    zErr = \"mremap\";\n#else\n    pNew = osMmap(pReq, nNew-nReuse, flags, MAP_SHARED, h, nReuse);\n    if( pNew!=MAP_FAILED ){\n      if( pNew!=pReq ){\n        osMunmap(pNew, nNew - nReuse);\n        pNew = 0;\n      }else{\n        pNew = pOrig;\n      }\n    }\n#endif\n\n    /* The attempt to extend the existing mapping failed. Free it. */\n    if( pNew==MAP_FAILED || pNew==0 ){\n      osMunmap(pOrig, nReuse);\n    }\n  }\n\n  /* If pNew is still NULL, try to create an entirely new mapping. */\n  if( pNew==0 ){\n    pNew = osMmap(0, nNew, flags, MAP_SHARED, h, 0);\n  }\n\n  if( pNew==MAP_FAILED ){\n    pNew = 0;\n    nNew = 0;\n    unixLogError(SQLITE_OK, zErr, pFd->zPath);\n\n    /* If the mmap() above failed, assume that all subsequent mmap() calls\n    ** will probably fail too. Fall back to using xRead/xWrite exclusively\n    ** in this case.  */\n    pFd->mmapSizeMax = 0;\n  }\n  pFd->pMapRegion = (void *)pNew;\n  pFd->mmapSize = pFd->mmapSizeActual = nNew;\n}\n\n/*\n** Memory map or remap the file opened by file-descriptor pFd (if the file\n** is already mapped, the existing mapping is replaced by the new). Or, if \n** there already exists a mapping for this file, and there are still \n** outstanding xFetch() references to it, this function is a no-op.\n**\n** If parameter nByte is non-negative, then it is the requested size of \n** the mapping to create. Otherwise, if nByte is less than zero, then the \n** requested size is the size of the file on disk. The actual size of the\n** created mapping is either the requested size or the value configured \n** using SQLITE_FCNTL_MMAP_LIMIT, whichever is smaller.\n**\n** SQLITE_OK is returned if no error occurs (even if the mapping is not\n** recreated as a result of outstanding references) or an SQLite error\n** code otherwise.\n*/\nstatic int unixMapfile(unixFile *pFd, i64 nMap){\n  assert( nMap>=0 || pFd->nFetchOut==0 );\n  assert( nMap>0 || (pFd->mmapSize==0 && pFd->pMapRegion==0) );\n  if( pFd->nFetchOut>0 ) return SQLITE_OK;\n\n  if( nMap<0 ){\n    struct stat statbuf;          /* Low-level file information */\n    if( osFstat(pFd->h, &statbuf) ){\n      return SQLITE_IOERR_FSTAT;\n    }\n    nMap = statbuf.st_size;\n  }\n  if( nMap>pFd->mmapSizeMax ){\n    nMap = pFd->mmapSizeMax;\n  }\n\n  assert( nMap>0 || (pFd->mmapSize==0 && pFd->pMapRegion==0) );\n  if( nMap!=pFd->mmapSize ){\n    unixRemapfile(pFd, nMap);\n  }\n\n  return SQLITE_OK;\n}\n#endif /* SQLITE_MAX_MMAP_SIZE>0 */\n\n/*\n** If possible, return a pointer to a mapping of file fd starting at offset\n** iOff. The mapping must be valid for at least nAmt bytes.\n**\n** If such a pointer can be obtained, store it in *pp and return SQLITE_OK.\n** Or, if one cannot but no error occurs, set *pp to 0 and return SQLITE_OK.\n** Finally, if an error does occur, return an SQLite error code. The final\n** value of *pp is undefined in this case.\n**\n** If this function does return a pointer, the caller must eventually \n** release the reference by calling unixUnfetch().\n*/\nstatic int unixFetch(sqlite3_file *fd, i64 iOff, int nAmt, void **pp){\n#if SQLITE_MAX_MMAP_SIZE>0\n  unixFile *pFd = (unixFile *)fd;   /* The underlying database file */\n#endif\n  *pp = 0;\n\n#if SQLITE_MAX_MMAP_SIZE>0\n  if( pFd->mmapSizeMax>0 ){\n    if( pFd->pMapRegion==0 ){\n      int rc = unixMapfile(pFd, -1);\n      if( rc!=SQLITE_OK ) return rc;\n    }\n    if( pFd->mmapSize >= iOff+nAmt ){\n      *pp = &((u8 *)pFd->pMapRegion)[iOff];\n      pFd->nFetchOut++;\n    }\n  }\n#endif\n  return SQLITE_OK;\n}\n\n/*\n** If the third argument is non-NULL, then this function releases a \n** reference obtained by an earlier call to unixFetch(). The second\n** argument passed to this function must be the same as the corresponding\n** argument that was passed to the unixFetch() invocation. \n**\n** Or, if the third argument is NULL, then this function is being called \n** to inform the VFS layer that, according to POSIX, any existing mapping \n** may now be invalid and should be unmapped.\n*/\nstatic int unixUnfetch(sqlite3_file *fd, i64 iOff, void *p){\n#if SQLITE_MAX_MMAP_SIZE>0\n  unixFile *pFd = (unixFile *)fd;   /* The underlying database file */\n  UNUSED_PARAMETER(iOff);\n\n  /* If p==0 (unmap the entire file) then there must be no outstanding \n  ** xFetch references. Or, if p!=0 (meaning it is an xFetch reference),\n  ** then there must be at least one outstanding.  */\n  assert( (p==0)==(pFd->nFetchOut==0) );\n\n  /* If p!=0, it must match the iOff value. */\n  assert( p==0 || p==&((u8 *)pFd->pMapRegion)[iOff] );\n\n  if( p ){\n    pFd->nFetchOut--;\n  }else{\n    unixUnmapfile(pFd);\n  }\n\n  assert( pFd->nFetchOut>=0 );\n#else\n  UNUSED_PARAMETER(fd);\n  UNUSED_PARAMETER(p);\n  UNUSED_PARAMETER(iOff);\n#endif\n  return SQLITE_OK;\n}\n\n/*\n** Here ends the implementation of all sqlite3_file methods.\n**\n********************** End sqlite3_file Methods *******************************\n******************************************************************************/\n\n/*\n** This division contains definitions of sqlite3_io_methods objects that\n** implement various file locking strategies.  It also contains definitions\n** of \"finder\" functions.  A finder-function is used to locate the appropriate\n** sqlite3_io_methods object for a particular database file.  The pAppData\n** field of the sqlite3_vfs VFS objects are initialized to be pointers to\n** the correct finder-function for that VFS.\n**\n** Most finder functions return a pointer to a fixed sqlite3_io_methods\n** object.  The only interesting finder-function is autolockIoFinder, which\n** looks at the filesystem type and tries to guess the best locking\n** strategy from that.\n**\n** For finder-function F, two objects are created:\n**\n**    (1) The real finder-function named \"FImpt()\".\n**\n**    (2) A constant pointer to this function named just \"F\".\n**\n**\n** A pointer to the F pointer is used as the pAppData value for VFS\n** objects.  We have to do this instead of letting pAppData point\n** directly at the finder-function since C90 rules prevent a void*\n** from be cast into a function pointer.\n**\n**\n** Each instance of this macro generates two objects:\n**\n**   *  A constant sqlite3_io_methods object call METHOD that has locking\n**      methods CLOSE, LOCK, UNLOCK, CKRESLOCK.\n**\n**   *  An I/O method finder function called FINDER that returns a pointer\n**      to the METHOD object in the previous bullet.\n*/\n#define IOMETHODS(FINDER,METHOD,VERSION,CLOSE,LOCK,UNLOCK,CKLOCK,SHMMAP)     \\\nstatic const sqlite3_io_methods METHOD = {                                   \\\n   VERSION,                    /* iVersion */                                \\\n   CLOSE,                      /* xClose */                                  \\\n   unixRead,                   /* xRead */                                   \\\n   unixWrite,                  /* xWrite */                                  \\\n   unixTruncate,               /* xTruncate */                               \\\n   unixSync,                   /* xSync */                                   \\\n   unixFileSize,               /* xFileSize */                               \\\n   LOCK,                       /* xLock */                                   \\\n   UNLOCK,                     /* xUnlock */                                 \\\n   CKLOCK,                     /* xCheckReservedLock */                      \\\n   unixFileControl,            /* xFileControl */                            \\\n   unixSectorSize,             /* xSectorSize */                             \\\n   unixDeviceCharacteristics,  /* xDeviceCapabilities */                     \\\n   SHMMAP,                     /* xShmMap */                                 \\\n   unixShmLock,                /* xShmLock */                                \\\n   unixShmBarrier,             /* xShmBarrier */                             \\\n   unixShmUnmap,               /* xShmUnmap */                               \\\n   unixFetch,                  /* xFetch */                                  \\\n   unixUnfetch,                /* xUnfetch */                                \\\n};                                                                           \\\nstatic const sqlite3_io_methods *FINDER##Impl(const char *z, unixFile *p){   \\\n  UNUSED_PARAMETER(z); UNUSED_PARAMETER(p);                                  \\\n  return &METHOD;                                                            \\\n}                                                                            \\\nstatic const sqlite3_io_methods *(*const FINDER)(const char*,unixFile *p)    \\\n    = FINDER##Impl;\n\n/*\n** Here are all of the sqlite3_io_methods objects for each of the\n** locking strategies.  Functions that return pointers to these methods\n** are also created.\n*/\nIOMETHODS(\n  posixIoFinder,            /* Finder function name */\n  posixIoMethods,           /* sqlite3_io_methods object name */\n  3,                        /* shared memory and mmap are enabled */\n  unixClose,                /* xClose method */\n  unixLock,                 /* xLock method */\n  unixUnlock,               /* xUnlock method */\n  unixCheckReservedLock,    /* xCheckReservedLock method */\n  unixShmMap                /* xShmMap method */\n)\nIOMETHODS(\n  nolockIoFinder,           /* Finder function name */\n  nolockIoMethods,          /* sqlite3_io_methods object name */\n  3,                        /* shared memory and mmap are enabled */\n  nolockClose,              /* xClose method */\n  nolockLock,               /* xLock method */\n  nolockUnlock,             /* xUnlock method */\n  nolockCheckReservedLock,  /* xCheckReservedLock method */\n  0                         /* xShmMap method */\n)\nIOMETHODS(\n  dotlockIoFinder,          /* Finder function name */\n  dotlockIoMethods,         /* sqlite3_io_methods object name */\n  1,                        /* shared memory is disabled */\n  dotlockClose,             /* xClose method */\n  dotlockLock,              /* xLock method */\n  dotlockUnlock,            /* xUnlock method */\n  dotlockCheckReservedLock, /* xCheckReservedLock method */\n  0                         /* xShmMap method */\n)\n\n#if SQLITE_ENABLE_LOCKING_STYLE\nIOMETHODS(\n  flockIoFinder,            /* Finder function name */\n  flockIoMethods,           /* sqlite3_io_methods object name */\n  1,                        /* shared memory is disabled */\n  flockClose,               /* xClose method */\n  flockLock,                /* xLock method */\n  flockUnlock,              /* xUnlock method */\n  flockCheckReservedLock,   /* xCheckReservedLock method */\n  0                         /* xShmMap method */\n)\n#endif\n\n#if OS_VXWORKS\nIOMETHODS(\n  semIoFinder,              /* Finder function name */\n  semIoMethods,             /* sqlite3_io_methods object name */\n  1,                        /* shared memory is disabled */\n  semXClose,                /* xClose method */\n  semXLock,                 /* xLock method */\n  semXUnlock,               /* xUnlock method */\n  semXCheckReservedLock,    /* xCheckReservedLock method */\n  0                         /* xShmMap method */\n)\n#endif\n\n#if defined(__APPLE__) && SQLITE_ENABLE_LOCKING_STYLE\nIOMETHODS(\n  afpIoFinder,              /* Finder function name */\n  afpIoMethods,             /* sqlite3_io_methods object name */\n  1,                        /* shared memory is disabled */\n  afpClose,                 /* xClose method */\n  afpLock,                  /* xLock method */\n  afpUnlock,                /* xUnlock method */\n  afpCheckReservedLock,     /* xCheckReservedLock method */\n  0                         /* xShmMap method */\n)\n#endif\n\n/*\n** The proxy locking method is a \"super-method\" in the sense that it\n** opens secondary file descriptors for the conch and lock files and\n** it uses proxy, dot-file, AFP, and flock() locking methods on those\n** secondary files.  For this reason, the division that implements\n** proxy locking is located much further down in the file.  But we need\n** to go ahead and define the sqlite3_io_methods and finder function\n** for proxy locking here.  So we forward declare the I/O methods.\n*/\n#if defined(__APPLE__) && SQLITE_ENABLE_LOCKING_STYLE\nstatic int proxyClose(sqlite3_file*);\nstatic int proxyLock(sqlite3_file*, int);\nstatic int proxyUnlock(sqlite3_file*, int);\nstatic int proxyCheckReservedLock(sqlite3_file*, int*);\nIOMETHODS(\n  proxyIoFinder,            /* Finder function name */\n  proxyIoMethods,           /* sqlite3_io_methods object name */\n  1,                        /* shared memory is disabled */\n  proxyClose,               /* xClose method */\n  proxyLock,                /* xLock method */\n  proxyUnlock,              /* xUnlock method */\n  proxyCheckReservedLock,   /* xCheckReservedLock method */\n  0                         /* xShmMap method */\n)\n#endif\n\n/* nfs lockd on OSX 10.3+ doesn't clear write locks when a read lock is set */\n#if defined(__APPLE__) && SQLITE_ENABLE_LOCKING_STYLE\nIOMETHODS(\n  nfsIoFinder,               /* Finder function name */\n  nfsIoMethods,              /* sqlite3_io_methods object name */\n  1,                         /* shared memory is disabled */\n  unixClose,                 /* xClose method */\n  unixLock,                  /* xLock method */\n  nfsUnlock,                 /* xUnlock method */\n  unixCheckReservedLock,     /* xCheckReservedLock method */\n  0                          /* xShmMap method */\n)\n#endif\n\n#if defined(__APPLE__) && SQLITE_ENABLE_LOCKING_STYLE\n/* \n** This \"finder\" function attempts to determine the best locking strategy \n** for the database file \"filePath\".  It then returns the sqlite3_io_methods\n** object that implements that strategy.\n**\n** This is for MacOSX only.\n*/\nstatic const sqlite3_io_methods *autolockIoFinderImpl(\n  const char *filePath,    /* name of the database file */\n  unixFile *pNew           /* open file object for the database file */\n){\n  static const struct Mapping {\n    const char *zFilesystem;              /* Filesystem type name */\n    const sqlite3_io_methods *pMethods;   /* Appropriate locking method */\n  } aMap[] = {\n    { \"hfs\",    &posixIoMethods },\n    { \"ufs\",    &posixIoMethods },\n    { \"afpfs\",  &afpIoMethods },\n    { \"smbfs\",  &afpIoMethods },\n    { \"webdav\", &nolockIoMethods },\n    { 0, 0 }\n  };\n  int i;\n  struct statfs fsInfo;\n  struct flock lockInfo;\n\n  if( !filePath ){\n    /* If filePath==NULL that means we are dealing with a transient file\n    ** that does not need to be locked. */\n    return &nolockIoMethods;\n  }\n  if( statfs(filePath, &fsInfo) != -1 ){\n    if( fsInfo.f_flags & MNT_RDONLY ){\n      return &nolockIoMethods;\n    }\n    for(i=0; aMap[i].zFilesystem; i++){\n      if( strcmp(fsInfo.f_fstypename, aMap[i].zFilesystem)==0 ){\n        return aMap[i].pMethods;\n      }\n    }\n  }\n\n  /* Default case. Handles, amongst others, \"nfs\".\n  ** Test byte-range lock using fcntl(). If the call succeeds, \n  ** assume that the file-system supports POSIX style locks. \n  */\n  lockInfo.l_len = 1;\n  lockInfo.l_start = 0;\n  lockInfo.l_whence = SEEK_SET;\n  lockInfo.l_type = F_RDLCK;\n  if( osFcntl(pNew->h, F_GETLK, &lockInfo)!=-1 ) {\n    if( strcmp(fsInfo.f_fstypename, \"nfs\")==0 ){\n      return &nfsIoMethods;\n    } else {\n      return &posixIoMethods;\n    }\n  }else{\n    return &dotlockIoMethods;\n  }\n}\nstatic const sqlite3_io_methods \n  *(*const autolockIoFinder)(const char*,unixFile*) = autolockIoFinderImpl;\n\n#endif /* defined(__APPLE__) && SQLITE_ENABLE_LOCKING_STYLE */\n\n#if OS_VXWORKS\n/*\n** This \"finder\" function for VxWorks checks to see if posix advisory\n** locking works.  If it does, then that is what is used.  If it does not\n** work, then fallback to named semaphore locking.\n*/\nstatic const sqlite3_io_methods *vxworksIoFinderImpl(\n  const char *filePath,    /* name of the database file */\n  unixFile *pNew           /* the open file object */\n){\n  struct flock lockInfo;\n\n  if( !filePath ){\n    /* If filePath==NULL that means we are dealing with a transient file\n    ** that does not need to be locked. */\n    return &nolockIoMethods;\n  }\n\n  /* Test if fcntl() is supported and use POSIX style locks.\n  ** Otherwise fall back to the named semaphore method.\n  */\n  lockInfo.l_len = 1;\n  lockInfo.l_start = 0;\n  lockInfo.l_whence = SEEK_SET;\n  lockInfo.l_type = F_RDLCK;\n  if( osFcntl(pNew->h, F_GETLK, &lockInfo)!=-1 ) {\n    return &posixIoMethods;\n  }else{\n    return &semIoMethods;\n  }\n}\nstatic const sqlite3_io_methods \n  *(*const vxworksIoFinder)(const char*,unixFile*) = vxworksIoFinderImpl;\n\n#endif /* OS_VXWORKS */\n\n/*\n** An abstract type for a pointer to an IO method finder function:\n*/\ntypedef const sqlite3_io_methods *(*finder_type)(const char*,unixFile*);\n\n\n/****************************************************************************\n**************************** sqlite3_vfs methods ****************************\n**\n** This division contains the implementation of methods on the\n** sqlite3_vfs object.\n*/\n\n/*\n** Initialize the contents of the unixFile structure pointed to by pId.\n*/\nstatic int fillInUnixFile(\n  sqlite3_vfs *pVfs,      /* Pointer to vfs object */\n  int h,                  /* Open file descriptor of file being opened */\n  sqlite3_file *pId,      /* Write to the unixFile structure here */\n  const char *zFilename,  /* Name of the file being opened */\n  int ctrlFlags           /* Zero or more UNIXFILE_* values */\n){\n  const sqlite3_io_methods *pLockingStyle;\n  unixFile *pNew = (unixFile *)pId;\n  int rc = SQLITE_OK;\n\n  assert( pNew->pInode==NULL );\n\n  /* No locking occurs in temporary files */\n  assert( zFilename!=0 || (ctrlFlags & UNIXFILE_NOLOCK)!=0 );\n\n  OSTRACE((\"OPEN    %-3d %s\\n\", h, zFilename));\n  pNew->h = h;\n  pNew->pVfs = pVfs;\n  pNew->zPath = zFilename;\n  pNew->ctrlFlags = (u8)ctrlFlags;\n#if SQLITE_MAX_MMAP_SIZE>0\n  pNew->mmapSizeMax = sqlite3GlobalConfig.szMmap;\n#endif\n  if( sqlite3_uri_boolean(((ctrlFlags & UNIXFILE_URI) ? zFilename : 0),\n                           \"psow\", SQLITE_POWERSAFE_OVERWRITE) ){\n    pNew->ctrlFlags |= UNIXFILE_PSOW;\n  }\n  if( strcmp(pVfs->zName,\"unix-excl\")==0 ){\n    pNew->ctrlFlags |= UNIXFILE_EXCL;\n  }\n\n#if OS_VXWORKS\n  pNew->pId = vxworksFindFileId(zFilename);\n  if( pNew->pId==0 ){\n    ctrlFlags |= UNIXFILE_NOLOCK;\n    rc = SQLITE_NOMEM_BKPT;\n  }\n#endif\n\n  if( ctrlFlags & UNIXFILE_NOLOCK ){\n    pLockingStyle = &nolockIoMethods;\n  }else{\n    pLockingStyle = (**(finder_type*)pVfs->pAppData)(zFilename, pNew);\n#if SQLITE_ENABLE_LOCKING_STYLE\n    /* Cache zFilename in the locking context (AFP and dotlock override) for\n    ** proxyLock activation is possible (remote proxy is based on db name)\n    ** zFilename remains valid until file is closed, to support */\n    pNew->lockingContext = (void*)zFilename;\n#endif\n  }\n\n  if( pLockingStyle == &posixIoMethods\n#if defined(__APPLE__) && SQLITE_ENABLE_LOCKING_STYLE\n    || pLockingStyle == &nfsIoMethods\n#endif\n  ){\n    unixEnterMutex();\n    rc = findInodeInfo(pNew, &pNew->pInode);\n    if( rc!=SQLITE_OK ){\n      /* If an error occurred in findInodeInfo(), close the file descriptor\n      ** immediately, before releasing the mutex. findInodeInfo() may fail\n      ** in two scenarios:\n      **\n      **   (a) A call to fstat() failed.\n      **   (b) A malloc failed.\n      **\n      ** Scenario (b) may only occur if the process is holding no other\n      ** file descriptors open on the same file. If there were other file\n      ** descriptors on this file, then no malloc would be required by\n      ** findInodeInfo(). If this is the case, it is quite safe to close\n      ** handle h - as it is guaranteed that no posix locks will be released\n      ** by doing so.\n      **\n      ** If scenario (a) caused the error then things are not so safe. The\n      ** implicit assumption here is that if fstat() fails, things are in\n      ** such bad shape that dropping a lock or two doesn't matter much.\n      */\n      robust_close(pNew, h, __LINE__);\n      h = -1;\n    }\n    unixLeaveMutex();\n  }\n\n#if SQLITE_ENABLE_LOCKING_STYLE && defined(__APPLE__)\n  else if( pLockingStyle == &afpIoMethods ){\n    /* AFP locking uses the file path so it needs to be included in\n    ** the afpLockingContext.\n    */\n    afpLockingContext *pCtx;\n    pNew->lockingContext = pCtx = sqlite3_malloc64( sizeof(*pCtx) );\n    if( pCtx==0 ){\n      rc = SQLITE_NOMEM_BKPT;\n    }else{\n      /* NB: zFilename exists and remains valid until the file is closed\n      ** according to requirement F11141.  So we do not need to make a\n      ** copy of the filename. */\n      pCtx->dbPath = zFilename;\n      pCtx->reserved = 0;\n      srandomdev();\n      unixEnterMutex();\n      rc = findInodeInfo(pNew, &pNew->pInode);\n      if( rc!=SQLITE_OK ){\n        sqlite3_free(pNew->lockingContext);\n        robust_close(pNew, h, __LINE__);\n        h = -1;\n      }\n      unixLeaveMutex();        \n    }\n  }\n#endif\n\n  else if( pLockingStyle == &dotlockIoMethods ){\n    /* Dotfile locking uses the file path so it needs to be included in\n    ** the dotlockLockingContext \n    */\n    char *zLockFile;\n    int nFilename;\n    assert( zFilename!=0 );\n    nFilename = (int)strlen(zFilename) + 6;\n    zLockFile = (char *)sqlite3_malloc64(nFilename);\n    if( zLockFile==0 ){\n      rc = SQLITE_NOMEM_BKPT;\n    }else{\n      sqlite3_snprintf(nFilename, zLockFile, \"%s\" DOTLOCK_SUFFIX, zFilename);\n    }\n    pNew->lockingContext = zLockFile;\n  }\n\n#if OS_VXWORKS\n  else if( pLockingStyle == &semIoMethods ){\n    /* Named semaphore locking uses the file path so it needs to be\n    ** included in the semLockingContext\n    */\n    unixEnterMutex();\n    rc = findInodeInfo(pNew, &pNew->pInode);\n    if( (rc==SQLITE_OK) && (pNew->pInode->pSem==NULL) ){\n      char *zSemName = pNew->pInode->aSemName;\n      int n;\n      sqlite3_snprintf(MAX_PATHNAME, zSemName, \"/%s.sem\",\n                       pNew->pId->zCanonicalName);\n      for( n=1; zSemName[n]; n++ )\n        if( zSemName[n]=='/' ) zSemName[n] = '_';\n      pNew->pInode->pSem = sem_open(zSemName, O_CREAT, 0666, 1);\n      if( pNew->pInode->pSem == SEM_FAILED ){\n        rc = SQLITE_NOMEM_BKPT;\n        pNew->pInode->aSemName[0] = '\\0';\n      }\n    }\n    unixLeaveMutex();\n  }\n#endif\n  \n  storeLastErrno(pNew, 0);\n#if OS_VXWORKS\n  if( rc!=SQLITE_OK ){\n    if( h>=0 ) robust_close(pNew, h, __LINE__);\n    h = -1;\n    osUnlink(zFilename);\n    pNew->ctrlFlags |= UNIXFILE_DELETE;\n  }\n#endif\n  if( rc!=SQLITE_OK ){\n    if( h>=0 ) robust_close(pNew, h, __LINE__);\n  }else{\n    pNew->pMethod = pLockingStyle;\n    OpenCounter(+1);\n    verifyDbFile(pNew);\n  }\n  return rc;\n}\n\n/*\n** Return the name of a directory in which to put temporary files.\n** If no suitable temporary file directory can be found, return NULL.\n*/\nstatic const char *unixTempFileDir(void){\n  static const char *azDirs[] = {\n     0,\n     0,\n     \"/var/tmp\",\n     \"/usr/tmp\",\n     \"/tmp\",\n     \".\"\n  };\n  unsigned int i = 0;\n  struct stat buf;\n  const char *zDir = sqlite3_temp_directory;\n\n  if( !azDirs[0] ) azDirs[0] = getenv(\"SQLITE_TMPDIR\");\n  if( !azDirs[1] ) azDirs[1] = getenv(\"TMPDIR\");\n  while(1){\n    if( zDir!=0\n     && osStat(zDir, &buf)==0\n     && S_ISDIR(buf.st_mode)\n     && osAccess(zDir, 03)==0\n    ){\n      return zDir;\n    }\n    if( i>=sizeof(azDirs)/sizeof(azDirs[0]) ) break;\n    zDir = azDirs[i++];\n  }\n  return 0;\n}\n\n/*\n** Create a temporary file name in zBuf.  zBuf must be allocated\n** by the calling process and must be big enough to hold at least\n** pVfs->mxPathname bytes.\n*/\nstatic int unixGetTempname(int nBuf, char *zBuf){\n  const char *zDir;\n  int iLimit = 0;\n\n  /* It's odd to simulate an io-error here, but really this is just\n  ** using the io-error infrastructure to test that SQLite handles this\n  ** function failing. \n  */\n  zBuf[0] = 0;\n  SimulateIOError( return SQLITE_IOERR );\n\n  zDir = unixTempFileDir();\n  if( zDir==0 ) return SQLITE_IOERR_GETTEMPPATH;\n  do{\n    u64 r;\n    sqlite3_randomness(sizeof(r), &r);\n    assert( nBuf>2 );\n    zBuf[nBuf-2] = 0;\n    sqlite3_snprintf(nBuf, zBuf, \"%s/\"SQLITE_TEMP_FILE_PREFIX\"%llx%c\",\n                     zDir, r, 0);\n    if( zBuf[nBuf-2]!=0 || (iLimit++)>10 ) return SQLITE_ERROR;\n  }while( osAccess(zBuf,0)==0 );\n  return SQLITE_OK;\n}\n\n#if SQLITE_ENABLE_LOCKING_STYLE && defined(__APPLE__)\n/*\n** Routine to transform a unixFile into a proxy-locking unixFile.\n** Implementation in the proxy-lock division, but used by unixOpen()\n** if SQLITE_PREFER_PROXY_LOCKING is defined.\n*/\nstatic int proxyTransformUnixFile(unixFile*, const char*);\n#endif\n\n/*\n** Search for an unused file descriptor that was opened on the database \n** file (not a journal or master-journal file) identified by pathname\n** zPath with SQLITE_OPEN_XXX flags matching those passed as the second\n** argument to this function.\n**\n** Such a file descriptor may exist if a database connection was closed\n** but the associated file descriptor could not be closed because some\n** other file descriptor open on the same file is holding a file-lock.\n** Refer to comments in the unixClose() function and the lengthy comment\n** describing \"Posix Advisory Locking\" at the start of this file for \n** further details. Also, ticket #4018.\n**\n** If a suitable file descriptor is found, then it is returned. If no\n** such file descriptor is located, -1 is returned.\n*/\nstatic UnixUnusedFd *findReusableFd(const char *zPath, int flags){\n  UnixUnusedFd *pUnused = 0;\n\n  /* Do not search for an unused file descriptor on vxworks. Not because\n  ** vxworks would not benefit from the change (it might, we're not sure),\n  ** but because no way to test it is currently available. It is better \n  ** not to risk breaking vxworks support for the sake of such an obscure \n  ** feature.  */\n#if !OS_VXWORKS\n  struct stat sStat;                   /* Results of stat() call */\n\n  unixEnterMutex();\n\n  /* A stat() call may fail for various reasons. If this happens, it is\n  ** almost certain that an open() call on the same path will also fail.\n  ** For this reason, if an error occurs in the stat() call here, it is\n  ** ignored and -1 is returned. The caller will try to open a new file\n  ** descriptor on the same path, fail, and return an error to SQLite.\n  **\n  ** Even if a subsequent open() call does succeed, the consequences of\n  ** not searching for a reusable file descriptor are not dire.  */\n  if( inodeList!=0 && 0==osStat(zPath, &sStat) ){\n    unixInodeInfo *pInode;\n\n    pInode = inodeList;\n    while( pInode && (pInode->fileId.dev!=sStat.st_dev\n                     || pInode->fileId.ino!=(u64)sStat.st_ino) ){\n       pInode = pInode->pNext;\n    }\n    if( pInode ){\n      UnixUnusedFd **pp;\n      assert( sqlite3_mutex_notheld(pInode->pLockMutex) );\n      sqlite3_mutex_enter(pInode->pLockMutex);\n      for(pp=&pInode->pUnused; *pp && (*pp)->flags!=flags; pp=&((*pp)->pNext));\n      pUnused = *pp;\n      if( pUnused ){\n        *pp = pUnused->pNext;\n      }\n      sqlite3_mutex_leave(pInode->pLockMutex);\n    }\n  }\n  unixLeaveMutex();\n#endif    /* if !OS_VXWORKS */\n  return pUnused;\n}\n\n/*\n** Find the mode, uid and gid of file zFile. \n*/\nstatic int getFileMode(\n  const char *zFile,              /* File name */\n  mode_t *pMode,                  /* OUT: Permissions of zFile */\n  uid_t *pUid,                    /* OUT: uid of zFile. */\n  gid_t *pGid                     /* OUT: gid of zFile. */\n){\n  struct stat sStat;              /* Output of stat() on database file */\n  int rc = SQLITE_OK;\n  if( 0==osStat(zFile, &sStat) ){\n    *pMode = sStat.st_mode & 0777;\n    *pUid = sStat.st_uid;\n    *pGid = sStat.st_gid;\n  }else{\n    rc = SQLITE_IOERR_FSTAT;\n  }\n  return rc;\n}\n\n/*\n** This function is called by unixOpen() to determine the unix permissions\n** to create new files with. If no error occurs, then SQLITE_OK is returned\n** and a value suitable for passing as the third argument to open(2) is\n** written to *pMode. If an IO error occurs, an SQLite error code is \n** returned and the value of *pMode is not modified.\n**\n** In most cases, this routine sets *pMode to 0, which will become\n** an indication to robust_open() to create the file using\n** SQLITE_DEFAULT_FILE_PERMISSIONS adjusted by the umask.\n** But if the file being opened is a WAL or regular journal file, then \n** this function queries the file-system for the permissions on the \n** corresponding database file and sets *pMode to this value. Whenever \n** possible, WAL and journal files are created using the same permissions \n** as the associated database file.\n**\n** If the SQLITE_ENABLE_8_3_NAMES option is enabled, then the\n** original filename is unavailable.  But 8_3_NAMES is only used for\n** FAT filesystems and permissions do not matter there, so just use\n** the default permissions.\n*/\nstatic int findCreateFileMode(\n  const char *zPath,              /* Path of file (possibly) being created */\n  int flags,                      /* Flags passed as 4th argument to xOpen() */\n  mode_t *pMode,                  /* OUT: Permissions to open file with */\n  uid_t *pUid,                    /* OUT: uid to set on the file */\n  gid_t *pGid                     /* OUT: gid to set on the file */\n){\n  int rc = SQLITE_OK;             /* Return Code */\n  *pMode = 0;\n  *pUid = 0;\n  *pGid = 0;\n  if( flags & (SQLITE_OPEN_WAL|SQLITE_OPEN_MAIN_JOURNAL) ){\n    char zDb[MAX_PATHNAME+1];     /* Database file path */\n    int nDb;                      /* Number of valid bytes in zDb */\n\n    /* zPath is a path to a WAL or journal file. The following block derives\n    ** the path to the associated database file from zPath. This block handles\n    ** the following naming conventions:\n    **\n    **   \"<path to db>-journal\"\n    **   \"<path to db>-wal\"\n    **   \"<path to db>-journalNN\"\n    **   \"<path to db>-walNN\"\n    **\n    ** where NN is a decimal number. The NN naming schemes are \n    ** used by the test_multiplex.c module.\n    */\n    nDb = sqlite3Strlen30(zPath) - 1; \n    while( zPath[nDb]!='-' ){\n      /* In normal operation, the journal file name will always contain\n      ** a '-' character.  However in 8+3 filename mode, or if a corrupt\n      ** rollback journal specifies a master journal with a goofy name, then\n      ** the '-' might be missing. */\n      if( nDb==0 || zPath[nDb]=='.' ) return SQLITE_OK;\n      nDb--;\n    }\n    memcpy(zDb, zPath, nDb);\n    zDb[nDb] = '\\0';\n\n    rc = getFileMode(zDb, pMode, pUid, pGid);\n  }else if( flags & SQLITE_OPEN_DELETEONCLOSE ){\n    *pMode = 0600;\n  }else if( flags & SQLITE_OPEN_URI ){\n    /* If this is a main database file and the file was opened using a URI\n    ** filename, check for the \"modeof\" parameter. If present, interpret\n    ** its value as a filename and try to copy the mode, uid and gid from\n    ** that file.  */\n    const char *z = sqlite3_uri_parameter(zPath, \"modeof\");\n    if( z ){\n      rc = getFileMode(z, pMode, pUid, pGid);\n  }\n  }\n  return rc;\n}\n\n/*\n** Open the file zPath.\n** \n** Previously, the SQLite OS layer used three functions in place of this\n** one:\n**\n**     sqlite3OsOpenReadWrite();\n**     sqlite3OsOpenReadOnly();\n**     sqlite3OsOpenExclusive();\n**\n** These calls correspond to the following combinations of flags:\n**\n**     ReadWrite() ->     (READWRITE | CREATE)\n**     ReadOnly()  ->     (READONLY) \n**     OpenExclusive() -> (READWRITE | CREATE | EXCLUSIVE)\n**\n** The old OpenExclusive() accepted a boolean argument - \"delFlag\". If\n** true, the file was configured to be automatically deleted when the\n** file handle closed. To achieve the same effect using this new \n** interface, add the DELETEONCLOSE flag to those specified above for \n** OpenExclusive().\n*/\nstatic int unixOpen(\n  sqlite3_vfs *pVfs,           /* The VFS for which this is the xOpen method */\n  const char *zPath,           /* Pathname of file to be opened */\n  sqlite3_file *pFile,         /* The file descriptor to be filled in */\n  int flags,                   /* Input flags to control the opening */\n  int *pOutFlags               /* Output flags returned to SQLite core */\n){\n  unixFile *p = (unixFile *)pFile;\n  int fd = -1;                   /* File descriptor returned by open() */\n  int openFlags = 0;             /* Flags to pass to open() */\n  int eType = flags&0xFFF00;  /* Type of file to open */\n  int noLock;                    /* True to omit locking primitives */\n  int rc = SQLITE_OK;            /* Function Return Code */\n  int ctrlFlags = 0;             /* UNIXFILE_* flags */\n\n  int isExclusive  = (flags & SQLITE_OPEN_EXCLUSIVE);\n  int isDelete     = (flags & SQLITE_OPEN_DELETEONCLOSE);\n  int isCreate     = (flags & SQLITE_OPEN_CREATE);\n  int isReadonly   = (flags & SQLITE_OPEN_READONLY || flags & SQLITE_OPEN_MAINDB_READONLY);\n  int isReadWrite  = (flags & SQLITE_OPEN_READWRITE && !(flags & SQLITE_OPEN_MAINDB_READONLY));\n#if SQLITE_ENABLE_LOCKING_STYLE\n  int isAutoProxy  = (flags & SQLITE_OPEN_AUTOPROXY);\n#endif\n#if defined(__APPLE__) || SQLITE_ENABLE_LOCKING_STYLE\n  struct statfs fsInfo;\n#endif\n\n  /* If creating a master or main-file journal, this function will open\n  ** a file-descriptor on the directory too. The first time unixSync()\n  ** is called the directory file descriptor will be fsync()ed and close()d.\n  */\n  int isNewJrnl = (isCreate && (\n        eType==SQLITE_OPEN_MASTER_JOURNAL \n     || eType==SQLITE_OPEN_MAIN_JOURNAL \n     || eType==SQLITE_OPEN_WAL\n  ));\n\n  /* If argument zPath is a NULL pointer, this function is required to open\n  ** a temporary file. Use this buffer to store the file name in.\n  */\n  char zTmpname[MAX_PATHNAME+2];\n  const char *zName = zPath;\n\n  /* Check the following statements are true: \n  **\n  **   (a) Exactly one of the READWRITE and READONLY flags must be set, and \n  **   (b) if CREATE is set, then READWRITE must also be set, and\n  **   (c) if EXCLUSIVE is set, then CREATE must also be set.\n  **   (d) if DELETEONCLOSE is set, then CREATE must also be set.\n  */\n  assert((isReadonly==0 || isReadWrite==0) && (isReadWrite || isReadonly));\n//  assert(isCreate==0 || isReadWrite);\n  assert(isExclusive==0 || isCreate);\n  assert(isDelete==0 || isCreate);\n\n  /* The main DB, main journal, WAL file and master journal are never \n  ** automatically deleted. Nor are they ever temporary files.  */\n  assert( (!isDelete && zName) || eType!=SQLITE_OPEN_MAIN_DB );\n  assert( (!isDelete && zName) || eType!=SQLITE_OPEN_MAIN_JOURNAL );\n  assert( (!isDelete && zName) || eType!=SQLITE_OPEN_MASTER_JOURNAL );\n  assert( (!isDelete && zName) || eType!=SQLITE_OPEN_WAL );\n\n  /* Assert that the upper layer has set one of the \"file-type\" flags. */\n  assert( eType==SQLITE_OPEN_MAIN_DB      || eType==SQLITE_OPEN_TEMP_DB \n       || eType==SQLITE_OPEN_MAIN_JOURNAL || eType==SQLITE_OPEN_TEMP_JOURNAL \n       || eType==SQLITE_OPEN_SUBJOURNAL   || eType==SQLITE_OPEN_MASTER_JOURNAL \n       || eType==SQLITE_OPEN_TRANSIENT_DB || eType==SQLITE_OPEN_WAL\n  );\n\n  /* Detect a pid change and reset the PRNG.  There is a race condition\n  ** here such that two or more threads all trying to open databases at\n  ** the same instant might all reset the PRNG.  But multiple resets\n  ** are harmless.\n  */\n  unixEnterMutex();\n  if( randomnessPid!=osGetpid(0) ){\n    randomnessPid = osGetpid(0);\n    sqlite3_randomness(0,0);\n  }\n  unixLeaveMutex();\n  memset(p, 0, sizeof(unixFile));\n\n  if( eType==SQLITE_OPEN_MAIN_DB ){\n    UnixUnusedFd *pUnused;\n    pUnused = findReusableFd(zName, flags);\n    if( pUnused ){\n      fd = pUnused->fd;\n    }else{\n      pUnused = sqlite3_malloc64(sizeof(*pUnused));\n      if( !pUnused ){\n        return SQLITE_NOMEM_BKPT;\n      }\n    }\n    p->pPreallocatedUnused = pUnused;\n\n    /* Database filenames are double-zero terminated if they are not\n    ** URIs with parameters.  Hence, they can always be passed into\n    ** sqlite3_uri_parameter(). */\n    assert( (flags & SQLITE_OPEN_URI) || zName[strlen(zName)+1]==0 );\n\n  }else if( !zName ){\n    /* If zName is NULL, the upper layer is requesting a temp file. */\n    assert(isDelete && !isNewJrnl);\n    rc = unixGetTempname(pVfs->mxPathname, zTmpname);\n    if( rc!=SQLITE_OK ){\n      return rc;\n    }\n    zName = zTmpname;\n\n    /* Generated temporary filenames are always double-zero terminated\n    ** for use by sqlite3_uri_parameter(). */\n    assert( zName[strlen(zName)+1]==0 );\n  }\n\n  /* Determine the value of the flags parameter passed to POSIX function\n  ** open(). These must be calculated even if open() is not called, as\n  ** they may be stored as part of the file handle and used by the \n  ** 'conch file' locking functions later on.  */\n  if( isReadonly )  openFlags |= O_RDONLY;\n  if( isReadWrite ) openFlags |= O_RDWR;\n  if( isCreate )    openFlags |= O_CREAT;\n  if( isExclusive ) openFlags |= (O_EXCL|O_NOFOLLOW);\n  openFlags |= (O_LARGEFILE|O_BINARY);\n\n  if( fd<0 ){\n    mode_t openMode;              /* Permissions to create file with */\n    uid_t uid;                    /* Userid for the file */\n    gid_t gid;                    /* Groupid for the file */\n    rc = findCreateFileMode(zName, flags, &openMode, &uid, &gid);\n    if( rc!=SQLITE_OK ){\n      assert( !p->pPreallocatedUnused );\n      assert( eType==SQLITE_OPEN_WAL || eType==SQLITE_OPEN_MAIN_JOURNAL );\n      return rc;\n    }\n    fd = robust_open(zName, openFlags, openMode);\n    OSTRACE((\"OPENX   %-3d %s 0%o\\n\", fd, zName, openFlags));\n    assert( !isExclusive || (openFlags & O_CREAT)!=0 );\n    if( fd<0 ){\n      if( isNewJrnl && errno==EACCES && osAccess(zName, F_OK) ){\n        /* If unable to create a journal because the directory is not\n        ** writable, change the error code to indicate that. */\n        rc = SQLITE_READONLY_DIRECTORY;\n      }else if( errno!=EISDIR && isReadWrite ){\n        /* Failed to open the file for read/write access. Try read-only. */\n        flags &= ~(SQLITE_OPEN_READWRITE|SQLITE_OPEN_CREATE);\n        openFlags &= ~(O_RDWR|O_CREAT);\n        flags |= SQLITE_OPEN_READONLY;\n        openFlags |= O_RDONLY;\n        isReadonly = 1;\n        fd = robust_open(zName, openFlags, openMode);\n      }\n    }\n    if( fd<0 ){\n      int rc2 = unixLogError(SQLITE_CANTOPEN_BKPT, \"open\", zName);\n      if( rc==SQLITE_OK ) rc = rc2;\n      goto open_finished;\n    }\n\n    /* If this process is running as root and if creating a new rollback\n    ** journal or WAL file, set the ownership of the journal or WAL to be\n    ** the same as the original database.\n    */\n    if( flags & (SQLITE_OPEN_WAL|SQLITE_OPEN_MAIN_JOURNAL) ){\n      robustFchown(fd, uid, gid);\n    }\n  }\n  assert( fd>=0 );\n  if( pOutFlags ){\n    *pOutFlags = flags;\n  }\n\n  if( p->pPreallocatedUnused ){\n    p->pPreallocatedUnused->fd = fd;\n    p->pPreallocatedUnused->flags = flags;\n  }\n\n  if( isDelete ){\n#if OS_VXWORKS\n    zPath = zName;\n#elif defined(SQLITE_UNLINK_AFTER_CLOSE)\n    zPath = sqlite3_mprintf(\"%s\", zName);\n    if( zPath==0 ){\n      robust_close(p, fd, __LINE__);\n      return SQLITE_NOMEM_BKPT;\n    }\n#else\n    osUnlink(zName);\n#endif\n  }\n#if SQLITE_ENABLE_LOCKING_STYLE\n  else{\n    p->openFlags = openFlags;\n  }\n#endif\n  \n#if defined(__APPLE__) || SQLITE_ENABLE_LOCKING_STYLE\n  if( fstatfs(fd, &fsInfo) == -1 ){\n    storeLastErrno(p, errno);\n    robust_close(p, fd, __LINE__);\n    return SQLITE_IOERR_ACCESS;\n  }\n  if (0 == strncmp(\"msdos\", fsInfo.f_fstypename, 5)) {\n    ((unixFile*)pFile)->fsFlags |= SQLITE_FSFLAGS_IS_MSDOS;\n  }\n  if (0 == strncmp(\"exfat\", fsInfo.f_fstypename, 5)) {\n    ((unixFile*)pFile)->fsFlags |= SQLITE_FSFLAGS_IS_MSDOS;\n  }\n#endif\n\n  /* Set up appropriate ctrlFlags */\n  if( isDelete )                ctrlFlags |= UNIXFILE_DELETE;\n  if( isReadonly )              ctrlFlags |= UNIXFILE_RDONLY;\n  noLock = eType!=SQLITE_OPEN_MAIN_DB;\n  if( noLock )                  ctrlFlags |= UNIXFILE_NOLOCK;\n  if( isNewJrnl )               ctrlFlags |= UNIXFILE_DIRSYNC;\n  if( flags & SQLITE_OPEN_URI ) ctrlFlags |= UNIXFILE_URI;\n\n#if SQLITE_ENABLE_LOCKING_STYLE\n#if SQLITE_PREFER_PROXY_LOCKING\n  isAutoProxy = 1;\n#endif\n  if( isAutoProxy && (zPath!=NULL) && (!noLock) && pVfs->xOpen ){\n    char *envforce = getenv(\"SQLITE_FORCE_PROXY_LOCKING\");\n    int useProxy = 0;\n\n    /* SQLITE_FORCE_PROXY_LOCKING==1 means force always use proxy, 0 means \n    ** never use proxy, NULL means use proxy for non-local files only.  */\n    if( envforce!=NULL ){\n      useProxy = atoi(envforce)>0;\n    }else{\n      useProxy = !(fsInfo.f_flags&MNT_LOCAL);\n    }\n    if( useProxy ){\n      rc = fillInUnixFile(pVfs, fd, pFile, zPath, ctrlFlags);\n      if( rc==SQLITE_OK ){\n        rc = proxyTransformUnixFile((unixFile*)pFile, \":auto:\");\n        if( rc!=SQLITE_OK ){\n          /* Use unixClose to clean up the resources added in fillInUnixFile \n          ** and clear all the structure's references.  Specifically, \n          ** pFile->pMethods will be NULL so sqlite3OsClose will be a no-op \n          */\n          unixClose(pFile);\n          return rc;\n        }\n      }\n      goto open_finished;\n    }\n  }\n#endif\n  \n  assert( zPath==0 || zPath[0]=='/' \n      || eType==SQLITE_OPEN_MASTER_JOURNAL || eType==SQLITE_OPEN_MAIN_JOURNAL \n  );\n  rc = fillInUnixFile(pVfs, fd, pFile, zPath, ctrlFlags);\n\nopen_finished:\n  if( rc!=SQLITE_OK ){\n    sqlite3_free(p->pPreallocatedUnused);\n  }\n  return rc;\n}\n\n\n/*\n** Delete the file at zPath. If the dirSync argument is true, fsync()\n** the directory after deleting the file.\n*/\nstatic int unixDelete(\n  sqlite3_vfs *NotUsed,     /* VFS containing this as the xDelete method */\n  const char *zPath,        /* Name of file to be deleted */\n  int dirSync               /* If true, fsync() directory after deleting file */\n){\n  int rc = SQLITE_OK;\n  UNUSED_PARAMETER(NotUsed);\n  SimulateIOError(return SQLITE_IOERR_DELETE);\n  if( osUnlink(zPath)==(-1) ){\n    if( errno==ENOENT\n#if OS_VXWORKS\n        || osAccess(zPath,0)!=0\n#endif\n    ){\n      rc = SQLITE_IOERR_DELETE_NOENT;\n    }else{\n      rc = unixLogError(SQLITE_IOERR_DELETE, \"unlink\", zPath);\n    }\n    return rc;\n  }\n#ifndef SQLITE_DISABLE_DIRSYNC\n  if( (dirSync & 1)!=0 ){\n    int fd;\n    rc = osOpenDirectory(zPath, &fd);\n    if( rc==SQLITE_OK ){\n      if( full_fsync(fd,0,0) ){\n        rc = unixLogError(SQLITE_IOERR_DIR_FSYNC, \"fsync\", zPath);\n      }\n      robust_close(0, fd, __LINE__);\n    }else{\n      assert( rc==SQLITE_CANTOPEN );\n      rc = SQLITE_OK;\n    }\n  }\n#endif\n  return rc;\n}\n\n/*\n** Test the existence of or access permissions of file zPath. The\n** test performed depends on the value of flags:\n**\n**     SQLITE_ACCESS_EXISTS: Return 1 if the file exists\n**     SQLITE_ACCESS_READWRITE: Return 1 if the file is read and writable.\n**     SQLITE_ACCESS_READONLY: Return 1 if the file is readable.\n**\n** Otherwise return 0.\n*/\nstatic int unixAccess(\n  sqlite3_vfs *NotUsed,   /* The VFS containing this xAccess method */\n  const char *zPath,      /* Path of the file to examine */\n  int flags,              /* What do we want to learn about the zPath file? */\n  int *pResOut            /* Write result boolean here */\n){\n  UNUSED_PARAMETER(NotUsed);\n  SimulateIOError( return SQLITE_IOERR_ACCESS; );\n  assert( pResOut!=0 );\n\n  /* The spec says there are three possible values for flags.  But only\n  ** two of them are actually used */\n  assert( flags==SQLITE_ACCESS_EXISTS || flags==SQLITE_ACCESS_READWRITE );\n\n  if( flags==SQLITE_ACCESS_EXISTS ){\n    struct stat buf;\n    *pResOut = (0==osStat(zPath, &buf) && buf.st_size>0);\n  }else{\n    *pResOut = osAccess(zPath, W_OK|R_OK)==0;\n  }\n  return SQLITE_OK;\n}\n\n/*\n**\n*/\nstatic int mkFullPathname(\n  const char *zPath,              /* Input path */\n  char *zOut,                     /* Output buffer */\n  int nOut                        /* Allocated size of buffer zOut */\n){\n  int nPath = sqlite3Strlen30(zPath);\n  int iOff = 0;\n  if( zPath[0]!='/' ){\n    if( osGetcwd(zOut, nOut-2)==0 ){\n      return unixLogError(SQLITE_CANTOPEN_BKPT, \"getcwd\", zPath);\n    }\n    iOff = sqlite3Strlen30(zOut);\n    zOut[iOff++] = '/';\n  }\n  if( (iOff+nPath+1)>nOut ){\n    /* SQLite assumes that xFullPathname() nul-terminates the output buffer\n    ** even if it returns an error.  */\n    zOut[iOff] = '\\0';\n    return SQLITE_CANTOPEN_BKPT;\n  }\n  sqlite3_snprintf(nOut-iOff, &zOut[iOff], \"%s\", zPath);\n  return SQLITE_OK;\n}\n\n/*\n** Turn a relative pathname into a full pathname. The relative path\n** is stored as a nul-terminated string in the buffer pointed to by\n** zPath. \n**\n** zOut points to a buffer of at least sqlite3_vfs.mxPathname bytes \n** (in this case, MAX_PATHNAME bytes). The full-path is written to\n** this buffer before returning.\n*/\nstatic int unixFullPathname(\n  sqlite3_vfs *pVfs,            /* Pointer to vfs object */\n  const char *zPath,            /* Possibly relative input path */\n  int nOut,                     /* Size of output buffer in bytes */\n  char *zOut                    /* Output buffer */\n){\n#if !defined(HAVE_READLINK) || !defined(HAVE_LSTAT)\n  return mkFullPathname(zPath, zOut, nOut);\n#else\n  int rc = SQLITE_OK;\n  int nByte;\n  int nLink = 1;                /* Number of symbolic links followed so far */\n  const char *zIn = zPath;      /* Input path for each iteration of loop */\n  char *zDel = 0;\n\n  assert( pVfs->mxPathname==MAX_PATHNAME );\n  UNUSED_PARAMETER(pVfs);\n\n  /* It's odd to simulate an io-error here, but really this is just\n  ** using the io-error infrastructure to test that SQLite handles this\n  ** function failing. This function could fail if, for example, the\n  ** current working directory has been unlinked.\n  */\n  SimulateIOError( return SQLITE_ERROR );\n\n  do {\n\n    /* Call stat() on path zIn. Set bLink to true if the path is a symbolic\n    ** link, or false otherwise.  */\n    int bLink = 0;\n    struct stat buf;\n    if( osLstat(zIn, &buf)!=0 ){\n      if( errno!=ENOENT ){\n        rc = unixLogError(SQLITE_CANTOPEN_BKPT, \"lstat\", zIn);\n      }\n    }else{\n      bLink = S_ISLNK(buf.st_mode);\n    }\n\n    if( bLink ){\n      if( zDel==0 ){\n        zDel = sqlite3_malloc(nOut);\n        if( zDel==0 ) rc = SQLITE_NOMEM_BKPT;\n      }else if( ++nLink>SQLITE_MAX_SYMLINKS ){\n        rc = SQLITE_CANTOPEN_BKPT;\n      }\n\n      if( rc==SQLITE_OK ){\n        nByte = osReadlink(zIn, zDel, nOut-1);\n        if( nByte<0 ){\n          rc = unixLogError(SQLITE_CANTOPEN_BKPT, \"readlink\", zIn);\n        }else{\n          if( zDel[0]!='/' ){\n            int n;\n            for(n = sqlite3Strlen30(zIn); n>0 && zIn[n-1]!='/'; n--);\n            if( nByte+n+1>nOut ){\n              rc = SQLITE_CANTOPEN_BKPT;\n            }else{\n              memmove(&zDel[n], zDel, nByte+1);\n              memcpy(zDel, zIn, n);\n              nByte += n;\n            }\n          }\n          zDel[nByte] = '\\0';\n        }\n      }\n\n      zIn = zDel;\n    }\n\n    assert( rc!=SQLITE_OK || zIn!=zOut || zIn[0]=='/' );\n    if( rc==SQLITE_OK && zIn!=zOut ){\n      rc = mkFullPathname(zIn, zOut, nOut);\n    }\n    if( bLink==0 ) break;\n    zIn = zOut;\n  }while( rc==SQLITE_OK );\n\n  sqlite3_free(zDel);\n  return rc;\n#endif   /* HAVE_READLINK && HAVE_LSTAT */\n}\n\n\n#ifndef SQLITE_OMIT_LOAD_EXTENSION\n/*\n** Interfaces for opening a shared library, finding entry points\n** within the shared library, and closing the shared library.\n*/\n#include <dlfcn.h>\nstatic void *unixDlOpen(sqlite3_vfs *NotUsed, const char *zFilename){\n  UNUSED_PARAMETER(NotUsed);\n  return dlopen(zFilename, RTLD_NOW | RTLD_GLOBAL);\n}\n\n/*\n** SQLite calls this function immediately after a call to unixDlSym() or\n** unixDlOpen() fails (returns a null pointer). If a more detailed error\n** message is available, it is written to zBufOut. If no error message\n** is available, zBufOut is left unmodified and SQLite uses a default\n** error message.\n*/\nstatic void unixDlError(sqlite3_vfs *NotUsed, int nBuf, char *zBufOut){\n  const char *zErr;\n  UNUSED_PARAMETER(NotUsed);\n  unixEnterMutex();\n  zErr = dlerror();\n  if( zErr ){\n    sqlite3_snprintf(nBuf, zBufOut, \"%s\", zErr);\n  }\n  unixLeaveMutex();\n}\nstatic void (*unixDlSym(sqlite3_vfs *NotUsed, void *p, const char*zSym))(void){\n  /* \n  ** GCC with -pedantic-errors says that C90 does not allow a void* to be\n  ** cast into a pointer to a function.  And yet the library dlsym() routine\n  ** returns a void* which is really a pointer to a function.  So how do we\n  ** use dlsym() with -pedantic-errors?\n  **\n  ** Variable x below is defined to be a pointer to a function taking\n  ** parameters void* and const char* and returning a pointer to a function.\n  ** We initialize x by assigning it a pointer to the dlsym() function.\n  ** (That assignment requires a cast.)  Then we call the function that\n  ** x points to.  \n  **\n  ** This work-around is unlikely to work correctly on any system where\n  ** you really cannot cast a function pointer into void*.  But then, on the\n  ** other hand, dlsym() will not work on such a system either, so we have\n  ** not really lost anything.\n  */\n  void (*(*x)(void*,const char*))(void);\n  UNUSED_PARAMETER(NotUsed);\n  x = (void(*(*)(void*,const char*))(void))dlsym;\n  return (*x)(p, zSym);\n}\nstatic void unixDlClose(sqlite3_vfs *NotUsed, void *pHandle){\n  UNUSED_PARAMETER(NotUsed);\n  dlclose(pHandle);\n}\n#else /* if SQLITE_OMIT_LOAD_EXTENSION is defined: */\n  #define unixDlOpen  0\n  #define unixDlError 0\n  #define unixDlSym   0\n  #define unixDlClose 0\n#endif\n\n/*\n** Write nBuf bytes of random data to the supplied buffer zBuf.\n*/\nstatic int unixRandomness(sqlite3_vfs *NotUsed, int nBuf, char *zBuf){\n  UNUSED_PARAMETER(NotUsed);\n  assert((size_t)nBuf>=(sizeof(time_t)+sizeof(int)));\n\n  /* We have to initialize zBuf to prevent valgrind from reporting\n  ** errors.  The reports issued by valgrind are incorrect - we would\n  ** prefer that the randomness be increased by making use of the\n  ** uninitialized space in zBuf - but valgrind errors tend to worry\n  ** some users.  Rather than argue, it seems easier just to initialize\n  ** the whole array and silence valgrind, even if that means less randomness\n  ** in the random seed.\n  **\n  ** When testing, initializing zBuf[] to zero is all we do.  That means\n  ** that we always use the same random number sequence.  This makes the\n  ** tests repeatable.\n  */\n  memset(zBuf, 0, nBuf);\n  unixEnterMutex();\n  randomnessPid = osGetpid(0);\n  unixLeaveMutex();\n#if !defined(SQLITE_TEST) && !defined(SQLITE_OMIT_RANDOMNESS)\n  {\n    int fd, got;\n    fd = robust_open(\"/dev/urandom\", O_RDONLY, 0);\n    if( fd<0 ){\n      time_t t;\n      time(&t);\n      memcpy(zBuf, &t, sizeof(t));\n      unixEnterMutex();\n      memcpy(&zBuf[sizeof(t)], &randomnessPid, sizeof(randomnessPid));\n      assert( sizeof(t)+sizeof(randomnessPid)<=(size_t)nBuf );\n      nBuf = sizeof(t) + sizeof(randomnessPid);\n      unixLeaveMutex();\n    }else{\n      do{ got = osRead(fd, zBuf, nBuf); }while( got<0 && errno==EINTR );\n      robust_close(0, fd, __LINE__);\n    }\n  }\n#endif\n  return nBuf;\n}\n\n\n/*\n** Sleep for a little while.  Return the amount of time slept.\n** The argument is the number of microseconds we want to sleep.\n** The return value is the number of microseconds of sleep actually\n** requested from the underlying operating system, a number which\n** might be greater than or equal to the argument, but not less\n** than the argument.\n*/\nstatic int unixSleep(sqlite3_vfs *NotUsed, int microseconds){\n#if OS_VXWORKS\n  struct timespec sp;\n\n  sp.tv_sec = microseconds / 1000000;\n  sp.tv_nsec = (microseconds % 1000000) * 1000;\n  nanosleep(&sp, NULL);\n  UNUSED_PARAMETER(NotUsed);\n  return microseconds;\n#elif defined(HAVE_USLEEP) && HAVE_USLEEP\n  usleep(microseconds);\n  UNUSED_PARAMETER(NotUsed);\n  return microseconds;\n#else\n  int seconds = (microseconds+999999)/1000000;\n  sleep(seconds);\n  UNUSED_PARAMETER(NotUsed);\n  return seconds*1000000;\n#endif\n}\n\n/*\n** The following variable, if set to a non-zero value, is interpreted as\n** the number of seconds since 1970 and is used to set the result of\n** sqlite3OsCurrentTime() during testing.\n*/\n#ifdef SQLITE_TEST\nSQLITE_API int sqlite3_current_time = 0;  /* Fake system time in seconds since 1970. */\n#endif\n\n/*\n** Find the current time (in Universal Coordinated Time).  Write into *piNow\n** the current time and date as a Julian Day number times 86_400_000.  In\n** other words, write into *piNow the number of milliseconds since the Julian\n** epoch of noon in Greenwich on November 24, 4714 B.C according to the\n** proleptic Gregorian calendar.\n**\n** On success, return SQLITE_OK.  Return SQLITE_ERROR if the time and date \n** cannot be found.\n*/\nstatic int unixCurrentTimeInt64(sqlite3_vfs *NotUsed, sqlite3_int64 *piNow){\n  static const sqlite3_int64 unixEpoch = 24405875*(sqlite3_int64)8640000;\n  int rc = SQLITE_OK;\n#if defined(NO_GETTOD)\n  time_t t;\n  time(&t);\n  *piNow = ((sqlite3_int64)t)*1000 + unixEpoch;\n#elif OS_VXWORKS\n  struct timespec sNow;\n  clock_gettime(CLOCK_REALTIME, &sNow);\n  *piNow = unixEpoch + 1000*(sqlite3_int64)sNow.tv_sec + sNow.tv_nsec/1000000;\n#else\n  struct timeval sNow;\n  (void)gettimeofday(&sNow, 0);  /* Cannot fail given valid arguments */\n  *piNow = unixEpoch + 1000*(sqlite3_int64)sNow.tv_sec + sNow.tv_usec/1000;\n#endif\n\n#ifdef SQLITE_TEST\n  if( sqlite3_current_time ){\n    *piNow = 1000*(sqlite3_int64)sqlite3_current_time + unixEpoch;\n  }\n#endif\n  UNUSED_PARAMETER(NotUsed);\n  return rc;\n}\n\n#ifndef SQLITE_OMIT_DEPRECATED\n/*\n** Find the current time (in Universal Coordinated Time).  Write the\n** current time and date as a Julian Day number into *prNow and\n** return 0.  Return 1 if the time and date cannot be found.\n*/\nstatic int unixCurrentTime(sqlite3_vfs *NotUsed, double *prNow){\n  sqlite3_int64 i = 0;\n  int rc;\n  UNUSED_PARAMETER(NotUsed);\n  rc = unixCurrentTimeInt64(0, &i);\n  *prNow = i/86400000.0;\n  return rc;\n}\n#else\n# define unixCurrentTime 0\n#endif\n\n/*\n** The xGetLastError() method is designed to return a better\n** low-level error message when operating-system problems come up\n** during SQLite operation.  Only the integer return code is currently\n** used.\n*/\nstatic int unixGetLastError(sqlite3_vfs *NotUsed, int NotUsed2, char *NotUsed3){\n  UNUSED_PARAMETER(NotUsed);\n  UNUSED_PARAMETER(NotUsed2);\n  UNUSED_PARAMETER(NotUsed3);\n  return errno;\n}\n\n\n/*\n************************ End of sqlite3_vfs methods ***************************\n******************************************************************************/\n\n/******************************************************************************\n************************** Begin Proxy Locking ********************************\n**\n** Proxy locking is a \"uber-locking-method\" in this sense:  It uses the\n** other locking methods on secondary lock files.  Proxy locking is a\n** meta-layer over top of the primitive locking implemented above.  For\n** this reason, the division that implements of proxy locking is deferred\n** until late in the file (here) after all of the other I/O methods have\n** been defined - so that the primitive locking methods are available\n** as services to help with the implementation of proxy locking.\n**\n****\n**\n** The default locking schemes in SQLite use byte-range locks on the\n** database file to coordinate safe, concurrent access by multiple readers\n** and writers [http://sqlite.org/lockingv3.html].  The five file locking\n** states (UNLOCKED, PENDING, SHARED, RESERVED, EXCLUSIVE) are implemented\n** as POSIX read & write locks over fixed set of locations (via fsctl),\n** on AFP and SMB only exclusive byte-range locks are available via fsctl\n** with _IOWR('z', 23, struct ByteRangeLockPB2) to track the same 5 states.\n** To simulate a F_RDLCK on the shared range, on AFP a randomly selected\n** address in the shared range is taken for a SHARED lock, the entire\n** shared range is taken for an EXCLUSIVE lock):\n**\n**      PENDING_BYTE        0x40000000\n**      RESERVED_BYTE       0x40000001\n**      SHARED_RANGE        0x40000002 -> 0x40000200\n**\n** This works well on the local file system, but shows a nearly 100x\n** slowdown in read performance on AFP because the AFP client disables\n** the read cache when byte-range locks are present.  Enabling the read\n** cache exposes a cache coherency problem that is present on all OS X\n** supported network file systems.  NFS and AFP both observe the\n** close-to-open semantics for ensuring cache coherency\n** [http://nfs.sourceforge.net/#faq_a8], which does not effectively\n** address the requirements for concurrent database access by multiple\n** readers and writers\n** [http://www.nabble.com/SQLite-on-NFS-cache-coherency-td15655701.html].\n**\n** To address the performance and cache coherency issues, proxy file locking\n** changes the way database access is controlled by limiting access to a\n** single host at a time and moving file locks off of the database file\n** and onto a proxy file on the local file system.  \n**\n**\n** Using proxy locks\n** -----------------\n**\n** C APIs\n**\n**  sqlite3_file_control(db, dbname, SQLITE_FCNTL_SET_LOCKPROXYFILE,\n**                       <proxy_path> | \":auto:\");\n**  sqlite3_file_control(db, dbname, SQLITE_FCNTL_GET_LOCKPROXYFILE,\n**                       &<proxy_path>);\n**\n**\n** SQL pragmas\n**\n**  PRAGMA [database.]lock_proxy_file=<proxy_path> | :auto:\n**  PRAGMA [database.]lock_proxy_file\n**\n** Specifying \":auto:\" means that if there is a conch file with a matching\n** host ID in it, the proxy path in the conch file will be used, otherwise\n** a proxy path based on the user's temp dir\n** (via confstr(_CS_DARWIN_USER_TEMP_DIR,...)) will be used and the\n** actual proxy file name is generated from the name and path of the\n** database file.  For example:\n**\n**       For database path \"/Users/me/foo.db\" \n**       The lock path will be \"<tmpdir>/sqliteplocks/_Users_me_foo.db:auto:\")\n**\n** Once a lock proxy is configured for a database connection, it can not\n** be removed, however it may be switched to a different proxy path via\n** the above APIs (assuming the conch file is not being held by another\n** connection or process). \n**\n**\n** How proxy locking works\n** -----------------------\n**\n** Proxy file locking relies primarily on two new supporting files: \n**\n**   *  conch file to limit access to the database file to a single host\n**      at a time\n**\n**   *  proxy file to act as a proxy for the advisory locks normally\n**      taken on the database\n**\n** The conch file - to use a proxy file, sqlite must first \"hold the conch\"\n** by taking an sqlite-style shared lock on the conch file, reading the\n** contents and comparing the host's unique host ID (see below) and lock\n** proxy path against the values stored in the conch.  The conch file is\n** stored in the same directory as the database file and the file name\n** is patterned after the database file name as \".<databasename>-conch\".\n** If the conch file does not exist, or its contents do not match the\n** host ID and/or proxy path, then the lock is escalated to an exclusive\n** lock and the conch file contents is updated with the host ID and proxy\n** path and the lock is downgraded to a shared lock again.  If the conch\n** is held by another process (with a shared lock), the exclusive lock\n** will fail and SQLITE_BUSY is returned.\n**\n** The proxy file - a single-byte file used for all advisory file locks\n** normally taken on the database file.   This allows for safe sharing\n** of the database file for multiple readers and writers on the same\n** host (the conch ensures that they all use the same local lock file).\n**\n** Requesting the lock proxy does not immediately take the conch, it is\n** only taken when the first request to lock database file is made.  \n** This matches the semantics of the traditional locking behavior, where\n** opening a connection to a database file does not take a lock on it.\n** The shared lock and an open file descriptor are maintained until \n** the connection to the database is closed. \n**\n** The proxy file and the lock file are never deleted so they only need\n** to be created the first time they are used.\n**\n** Configuration options\n** ---------------------\n**\n**  SQLITE_PREFER_PROXY_LOCKING\n**\n**       Database files accessed on non-local file systems are\n**       automatically configured for proxy locking, lock files are\n**       named automatically using the same logic as\n**       PRAGMA lock_proxy_file=\":auto:\"\n**    \n**  SQLITE_PROXY_DEBUG\n**\n**       Enables the logging of error messages during host id file\n**       retrieval and creation\n**\n**  LOCKPROXYDIR\n**\n**       Overrides the default directory used for lock proxy files that\n**       are named automatically via the \":auto:\" setting\n**\n**  SQLITE_DEFAULT_PROXYDIR_PERMISSIONS\n**\n**       Permissions to use when creating a directory for storing the\n**       lock proxy files, only used when LOCKPROXYDIR is not set.\n**    \n**    \n** As mentioned above, when compiled with SQLITE_PREFER_PROXY_LOCKING,\n** setting the environment variable SQLITE_FORCE_PROXY_LOCKING to 1 will\n** force proxy locking to be used for every database file opened, and 0\n** will force automatic proxy locking to be disabled for all database\n** files (explicitly calling the SQLITE_FCNTL_SET_LOCKPROXYFILE pragma or\n** sqlite_file_control API is not affected by SQLITE_FORCE_PROXY_LOCKING).\n*/\n\n/*\n** Proxy locking is only available on MacOSX \n*/\n#if defined(__APPLE__) && SQLITE_ENABLE_LOCKING_STYLE\n\n/*\n** The proxyLockingContext has the path and file structures for the remote \n** and local proxy files in it\n*/\ntypedef struct proxyLockingContext proxyLockingContext;\nstruct proxyLockingContext {\n  unixFile *conchFile;         /* Open conch file */\n  char *conchFilePath;         /* Name of the conch file */\n  unixFile *lockProxy;         /* Open proxy lock file */\n  char *lockProxyPath;         /* Name of the proxy lock file */\n  char *dbPath;                /* Name of the open file */\n  int conchHeld;               /* 1 if the conch is held, -1 if lockless */\n  int nFails;                  /* Number of conch taking failures */\n  void *oldLockingContext;     /* Original lockingcontext to restore on close */\n  sqlite3_io_methods const *pOldMethod;     /* Original I/O methods for close */\n};\n\n/* \n** The proxy lock file path for the database at dbPath is written into lPath, \n** which must point to valid, writable memory large enough for a maxLen length\n** file path. \n*/\nstatic int proxyGetLockPath(const char *dbPath, char *lPath, size_t maxLen){\n  int len;\n  int dbLen;\n  int i;\n\n#ifdef LOCKPROXYDIR\n  len = strlcpy(lPath, LOCKPROXYDIR, maxLen);\n#else\n# ifdef _CS_DARWIN_USER_TEMP_DIR\n  {\n    if( !confstr(_CS_DARWIN_USER_TEMP_DIR, lPath, maxLen) ){\n      OSTRACE((\"GETLOCKPATH  failed %s errno=%d pid=%d\\n\",\n               lPath, errno, osGetpid(0)));\n      return SQLITE_IOERR_LOCK;\n    }\n    len = strlcat(lPath, \"sqliteplocks\", maxLen);    \n  }\n# else\n  len = strlcpy(lPath, \"/tmp/\", maxLen);\n# endif\n#endif\n\n  if( lPath[len-1]!='/' ){\n    len = strlcat(lPath, \"/\", maxLen);\n  }\n  \n  /* transform the db path to a unique cache name */\n  dbLen = (int)strlen(dbPath);\n  for( i=0; i<dbLen && (i+len+7)<(int)maxLen; i++){\n    char c = dbPath[i];\n    lPath[i+len] = (c=='/')?'_':c;\n  }\n  lPath[i+len]='\\0';\n  strlcat(lPath, \":auto:\", maxLen);\n  OSTRACE((\"GETLOCKPATH  proxy lock path=%s pid=%d\\n\", lPath, osGetpid(0)));\n  return SQLITE_OK;\n}\n\n/* \n ** Creates the lock file and any missing directories in lockPath\n */\nstatic int proxyCreateLockPath(const char *lockPath){\n  int i, len;\n  char buf[MAXPATHLEN];\n  int start = 0;\n  \n  assert(lockPath!=NULL);\n  /* try to create all the intermediate directories */\n  len = (int)strlen(lockPath);\n  buf[0] = lockPath[0];\n  for( i=1; i<len; i++ ){\n    if( lockPath[i] == '/' && (i - start > 0) ){\n      /* only mkdir if leaf dir != \".\" or \"/\" or \"..\" */\n      if( i-start>2 || (i-start==1 && buf[start] != '.' && buf[start] != '/') \n         || (i-start==2 && buf[start] != '.' && buf[start+1] != '.') ){\n        buf[i]='\\0';\n        if( osMkdir(buf, SQLITE_DEFAULT_PROXYDIR_PERMISSIONS) ){\n          int err=errno;\n          if( err!=EEXIST ) {\n            OSTRACE((\"CREATELOCKPATH  FAILED creating %s, \"\n                     \"'%s' proxy lock path=%s pid=%d\\n\",\n                     buf, strerror(err), lockPath, osGetpid(0)));\n            return err;\n          }\n        }\n      }\n      start=i+1;\n    }\n    buf[i] = lockPath[i];\n  }\n  OSTRACE((\"CREATELOCKPATH  proxy lock path=%s pid=%d\\n\",lockPath,osGetpid(0)));\n  return 0;\n}\n\n/*\n** Create a new VFS file descriptor (stored in memory obtained from\n** sqlite3_malloc) and open the file named \"path\" in the file descriptor.\n**\n** The caller is responsible not only for closing the file descriptor\n** but also for freeing the memory associated with the file descriptor.\n*/\nstatic int proxyCreateUnixFile(\n    const char *path,        /* path for the new unixFile */\n    unixFile **ppFile,       /* unixFile created and returned by ref */\n    int islockfile           /* if non zero missing dirs will be created */\n) {\n  int fd = -1;\n  unixFile *pNew;\n  int rc = SQLITE_OK;\n  int openFlags = O_RDWR | O_CREAT;\n  sqlite3_vfs dummyVfs;\n  int terrno = 0;\n  UnixUnusedFd *pUnused = NULL;\n\n  /* 1. first try to open/create the file\n  ** 2. if that fails, and this is a lock file (not-conch), try creating\n  ** the parent directories and then try again.\n  ** 3. if that fails, try to open the file read-only\n  ** otherwise return BUSY (if lock file) or CANTOPEN for the conch file\n  */\n  pUnused = findReusableFd(path, openFlags);\n  if( pUnused ){\n    fd = pUnused->fd;\n  }else{\n    pUnused = sqlite3_malloc64(sizeof(*pUnused));\n    if( !pUnused ){\n      return SQLITE_NOMEM_BKPT;\n    }\n  }\n  if( fd<0 ){\n    fd = robust_open(path, openFlags, 0);\n    terrno = errno;\n    if( fd<0 && errno==ENOENT && islockfile ){\n      if( proxyCreateLockPath(path) == SQLITE_OK ){\n        fd = robust_open(path, openFlags, 0);\n      }\n    }\n  }\n  if( fd<0 ){\n    openFlags = O_RDONLY;\n    fd = robust_open(path, openFlags, 0);\n    terrno = errno;\n  }\n  if( fd<0 ){\n    if( islockfile ){\n      return SQLITE_BUSY;\n    }\n    switch (terrno) {\n      case EACCES:\n        return SQLITE_PERM;\n      case EIO: \n        return SQLITE_IOERR_LOCK; /* even though it is the conch */\n      default:\n        return SQLITE_CANTOPEN_BKPT;\n    }\n  }\n  \n  pNew = (unixFile *)sqlite3_malloc64(sizeof(*pNew));\n  if( pNew==NULL ){\n    rc = SQLITE_NOMEM_BKPT;\n    goto end_create_proxy;\n  }\n  memset(pNew, 0, sizeof(unixFile));\n  pNew->openFlags = openFlags;\n  memset(&dummyVfs, 0, sizeof(dummyVfs));\n  dummyVfs.pAppData = (void*)&autolockIoFinder;\n  dummyVfs.zName = \"dummy\";\n  pUnused->fd = fd;\n  pUnused->flags = openFlags;\n  pNew->pPreallocatedUnused = pUnused;\n  \n  rc = fillInUnixFile(&dummyVfs, fd, (sqlite3_file*)pNew, path, 0);\n  if( rc==SQLITE_OK ){\n    *ppFile = pNew;\n    return SQLITE_OK;\n  }\nend_create_proxy:    \n  robust_close(pNew, fd, __LINE__);\n  sqlite3_free(pNew);\n  sqlite3_free(pUnused);\n  return rc;\n}\n\n#ifdef SQLITE_TEST\n/* simulate multiple hosts by creating unique hostid file paths */\nSQLITE_API int sqlite3_hostid_num = 0;\n#endif\n\n#define PROXY_HOSTIDLEN    16  /* conch file host id length */\n\n#ifdef HAVE_GETHOSTUUID\n/* Not always defined in the headers as it ought to be */\nextern int gethostuuid(uuid_t id, const struct timespec *wait);\n#endif\n\n/* get the host ID via gethostuuid(), pHostID must point to PROXY_HOSTIDLEN \n** bytes of writable memory.\n*/\nstatic int proxyGetHostID(unsigned char *pHostID, int *pError){\n  assert(PROXY_HOSTIDLEN == sizeof(uuid_t));\n  memset(pHostID, 0, PROXY_HOSTIDLEN);\n#ifdef HAVE_GETHOSTUUID\n  {\n    struct timespec timeout = {1, 0}; /* 1 sec timeout */\n    if( gethostuuid(pHostID, &timeout) ){\n      int err = errno;\n      if( pError ){\n        *pError = err;\n      }\n      return SQLITE_IOERR;\n    }\n  }\n#else\n  UNUSED_PARAMETER(pError);\n#endif\n#ifdef SQLITE_TEST\n  /* simulate multiple hosts by creating unique hostid file paths */\n  if( sqlite3_hostid_num != 0){\n    pHostID[0] = (char)(pHostID[0] + (char)(sqlite3_hostid_num & 0xFF));\n  }\n#endif\n  \n  return SQLITE_OK;\n}\n\n/* The conch file contains the header, host id and lock file path\n */\n#define PROXY_CONCHVERSION 2   /* 1-byte header, 16-byte host id, path */\n#define PROXY_HEADERLEN    1   /* conch file header length */\n#define PROXY_PATHINDEX    (PROXY_HEADERLEN+PROXY_HOSTIDLEN)\n#define PROXY_MAXCONCHLEN  (PROXY_HEADERLEN+PROXY_HOSTIDLEN+MAXPATHLEN)\n\n/* \n** Takes an open conch file, copies the contents to a new path and then moves \n** it back.  The newly created file's file descriptor is assigned to the\n** conch file structure and finally the original conch file descriptor is \n** closed.  Returns zero if successful.\n*/\nstatic int proxyBreakConchLock(unixFile *pFile, uuid_t myHostID){\n  proxyLockingContext *pCtx = (proxyLockingContext *)pFile->lockingContext; \n  unixFile *conchFile = pCtx->conchFile;\n  char tPath[MAXPATHLEN];\n  char buf[PROXY_MAXCONCHLEN];\n  char *cPath = pCtx->conchFilePath;\n  size_t readLen = 0;\n  size_t pathLen = 0;\n  char errmsg[64] = \"\";\n  int fd = -1;\n  int rc = -1;\n  UNUSED_PARAMETER(myHostID);\n\n  /* create a new path by replace the trailing '-conch' with '-break' */\n  pathLen = strlcpy(tPath, cPath, MAXPATHLEN);\n  if( pathLen>MAXPATHLEN || pathLen<6 || \n     (strlcpy(&tPath[pathLen-5], \"break\", 6) != 5) ){\n    sqlite3_snprintf(sizeof(errmsg),errmsg,\"path error (len %d)\",(int)pathLen);\n    goto end_breaklock;\n  }\n  /* read the conch content */\n  readLen = osPread(conchFile->h, buf, PROXY_MAXCONCHLEN, 0);\n  if( readLen<PROXY_PATHINDEX ){\n    sqlite3_snprintf(sizeof(errmsg),errmsg,\"read error (len %d)\",(int)readLen);\n    goto end_breaklock;\n  }\n  /* write it out to the temporary break file */\n  fd = robust_open(tPath, (O_RDWR|O_CREAT|O_EXCL), 0);\n  if( fd<0 ){\n    sqlite3_snprintf(sizeof(errmsg), errmsg, \"create failed (%d)\", errno);\n    goto end_breaklock;\n  }\n  if( osPwrite(fd, buf, readLen, 0) != (ssize_t)readLen ){\n    sqlite3_snprintf(sizeof(errmsg), errmsg, \"write failed (%d)\", errno);\n    goto end_breaklock;\n  }\n  if( rename(tPath, cPath) ){\n    sqlite3_snprintf(sizeof(errmsg), errmsg, \"rename failed (%d)\", errno);\n    goto end_breaklock;\n  }\n  rc = 0;\n  fprintf(stderr, \"broke stale lock on %s\\n\", cPath);\n  robust_close(pFile, conchFile->h, __LINE__);\n  conchFile->h = fd;\n  conchFile->openFlags = O_RDWR | O_CREAT;\n\nend_breaklock:\n  if( rc ){\n    if( fd>=0 ){\n      osUnlink(tPath);\n      robust_close(pFile, fd, __LINE__);\n    }\n    fprintf(stderr, \"failed to break stale lock on %s, %s\\n\", cPath, errmsg);\n  }\n  return rc;\n}\n\n/* Take the requested lock on the conch file and break a stale lock if the \n** host id matches.\n*/\nstatic int proxyConchLock(unixFile *pFile, uuid_t myHostID, int lockType){\n  proxyLockingContext *pCtx = (proxyLockingContext *)pFile->lockingContext; \n  unixFile *conchFile = pCtx->conchFile;\n  int rc = SQLITE_OK;\n  int nTries = 0;\n  struct timespec conchModTime;\n  \n  memset(&conchModTime, 0, sizeof(conchModTime));\n  do {\n    rc = conchFile->pMethod->xLock((sqlite3_file*)conchFile, lockType);\n    nTries ++;\n    if( rc==SQLITE_BUSY ){\n      /* If the lock failed (busy):\n       * 1st try: get the mod time of the conch, wait 0.5s and try again. \n       * 2nd try: fail if the mod time changed or host id is different, wait \n       *           10 sec and try again\n       * 3rd try: break the lock unless the mod time has changed.\n       */\n      struct stat buf;\n      if( osFstat(conchFile->h, &buf) ){\n        storeLastErrno(pFile, errno);\n        return SQLITE_IOERR_LOCK;\n      }\n      \n      if( nTries==1 ){\n        conchModTime = buf.st_mtimespec;\n        usleep(500000); /* wait 0.5 sec and try the lock again*/\n        continue;  \n      }\n\n      assert( nTries>1 );\n      if( conchModTime.tv_sec != buf.st_mtimespec.tv_sec || \n         conchModTime.tv_nsec != buf.st_mtimespec.tv_nsec ){\n        return SQLITE_BUSY;\n      }\n      \n      if( nTries==2 ){  \n        char tBuf[PROXY_MAXCONCHLEN];\n        int len = osPread(conchFile->h, tBuf, PROXY_MAXCONCHLEN, 0);\n        if( len<0 ){\n          storeLastErrno(pFile, errno);\n          return SQLITE_IOERR_LOCK;\n        }\n        if( len>PROXY_PATHINDEX && tBuf[0]==(char)PROXY_CONCHVERSION){\n          /* don't break the lock if the host id doesn't match */\n          if( 0!=memcmp(&tBuf[PROXY_HEADERLEN], myHostID, PROXY_HOSTIDLEN) ){\n            return SQLITE_BUSY;\n          }\n        }else{\n          /* don't break the lock on short read or a version mismatch */\n          return SQLITE_BUSY;\n        }\n        usleep(10000000); /* wait 10 sec and try the lock again */\n        continue; \n      }\n      \n      assert( nTries==3 );\n      if( 0==proxyBreakConchLock(pFile, myHostID) ){\n        rc = SQLITE_OK;\n        if( lockType==EXCLUSIVE_LOCK ){\n          rc = conchFile->pMethod->xLock((sqlite3_file*)conchFile, SHARED_LOCK);\n        }\n        if( !rc ){\n          rc = conchFile->pMethod->xLock((sqlite3_file*)conchFile, lockType);\n        }\n      }\n    }\n  } while( rc==SQLITE_BUSY && nTries<3 );\n  \n  return rc;\n}\n\n/* Takes the conch by taking a shared lock and read the contents conch, if \n** lockPath is non-NULL, the host ID and lock file path must match.  A NULL \n** lockPath means that the lockPath in the conch file will be used if the \n** host IDs match, or a new lock path will be generated automatically \n** and written to the conch file.\n*/\nstatic int proxyTakeConch(unixFile *pFile){\n  proxyLockingContext *pCtx = (proxyLockingContext *)pFile->lockingContext; \n  \n  if( pCtx->conchHeld!=0 ){\n    return SQLITE_OK;\n  }else{\n    unixFile *conchFile = pCtx->conchFile;\n    uuid_t myHostID;\n    int pError = 0;\n    char readBuf[PROXY_MAXCONCHLEN];\n    char lockPath[MAXPATHLEN];\n    char *tempLockPath = NULL;\n    int rc = SQLITE_OK;\n    int createConch = 0;\n    int hostIdMatch = 0;\n    int readLen = 0;\n    int tryOldLockPath = 0;\n    int forceNewLockPath = 0;\n    \n    OSTRACE((\"TAKECONCH  %d for %s pid=%d\\n\", conchFile->h,\n             (pCtx->lockProxyPath ? pCtx->lockProxyPath : \":auto:\"),\n             osGetpid(0)));\n\n    rc = proxyGetHostID(myHostID, &pError);\n    if( (rc&0xff)==SQLITE_IOERR ){\n      storeLastErrno(pFile, pError);\n      goto end_takeconch;\n    }\n    rc = proxyConchLock(pFile, myHostID, SHARED_LOCK);\n    if( rc!=SQLITE_OK ){\n      goto end_takeconch;\n    }\n    /* read the existing conch file */\n    readLen = seekAndRead((unixFile*)conchFile, 0, readBuf, PROXY_MAXCONCHLEN);\n    if( readLen<0 ){\n      /* I/O error: lastErrno set by seekAndRead */\n      storeLastErrno(pFile, conchFile->lastErrno);\n      rc = SQLITE_IOERR_READ;\n      goto end_takeconch;\n    }else if( readLen<=(PROXY_HEADERLEN+PROXY_HOSTIDLEN) || \n             readBuf[0]!=(char)PROXY_CONCHVERSION ){\n      /* a short read or version format mismatch means we need to create a new \n      ** conch file. \n      */\n      createConch = 1;\n    }\n    /* if the host id matches and the lock path already exists in the conch\n    ** we'll try to use the path there, if we can't open that path, we'll \n    ** retry with a new auto-generated path \n    */\n    do { /* in case we need to try again for an :auto: named lock file */\n\n      if( !createConch && !forceNewLockPath ){\n        hostIdMatch = !memcmp(&readBuf[PROXY_HEADERLEN], myHostID, \n                                  PROXY_HOSTIDLEN);\n        /* if the conch has data compare the contents */\n        if( !pCtx->lockProxyPath ){\n          /* for auto-named local lock file, just check the host ID and we'll\n           ** use the local lock file path that's already in there\n           */\n          if( hostIdMatch ){\n            size_t pathLen = (readLen - PROXY_PATHINDEX);\n            \n            if( pathLen>=MAXPATHLEN ){\n              pathLen=MAXPATHLEN-1;\n            }\n            memcpy(lockPath, &readBuf[PROXY_PATHINDEX], pathLen);\n            lockPath[pathLen] = 0;\n            tempLockPath = lockPath;\n            tryOldLockPath = 1;\n            /* create a copy of the lock path if the conch is taken */\n            goto end_takeconch;\n          }\n        }else if( hostIdMatch\n               && !strncmp(pCtx->lockProxyPath, &readBuf[PROXY_PATHINDEX],\n                           readLen-PROXY_PATHINDEX)\n        ){\n          /* conch host and lock path match */\n          goto end_takeconch; \n        }\n      }\n      \n      /* if the conch isn't writable and doesn't match, we can't take it */\n      if( (conchFile->openFlags&O_RDWR) == 0 ){\n        rc = SQLITE_BUSY;\n        goto end_takeconch;\n      }\n      \n      /* either the conch didn't match or we need to create a new one */\n      if( !pCtx->lockProxyPath ){\n        proxyGetLockPath(pCtx->dbPath, lockPath, MAXPATHLEN);\n        tempLockPath = lockPath;\n        /* create a copy of the lock path _only_ if the conch is taken */\n      }\n      \n      /* update conch with host and path (this will fail if other process\n      ** has a shared lock already), if the host id matches, use the big\n      ** stick.\n      */\n      futimes(conchFile->h, NULL);\n      if( hostIdMatch && !createConch ){\n        if( conchFile->pInode && conchFile->pInode->nShared>1 ){\n          /* We are trying for an exclusive lock but another thread in this\n           ** same process is still holding a shared lock. */\n          rc = SQLITE_BUSY;\n        } else {          \n          rc = proxyConchLock(pFile, myHostID, EXCLUSIVE_LOCK);\n        }\n      }else{\n        rc = proxyConchLock(pFile, myHostID, EXCLUSIVE_LOCK);\n      }\n      if( rc==SQLITE_OK ){\n        char writeBuffer[PROXY_MAXCONCHLEN];\n        int writeSize = 0;\n        \n        writeBuffer[0] = (char)PROXY_CONCHVERSION;\n        memcpy(&writeBuffer[PROXY_HEADERLEN], myHostID, PROXY_HOSTIDLEN);\n        if( pCtx->lockProxyPath!=NULL ){\n          strlcpy(&writeBuffer[PROXY_PATHINDEX], pCtx->lockProxyPath,\n                  MAXPATHLEN);\n        }else{\n          strlcpy(&writeBuffer[PROXY_PATHINDEX], tempLockPath, MAXPATHLEN);\n        }\n        writeSize = PROXY_PATHINDEX + strlen(&writeBuffer[PROXY_PATHINDEX]);\n        robust_ftruncate(conchFile->h, writeSize);\n        rc = unixWrite((sqlite3_file *)conchFile, writeBuffer, writeSize, 0);\n        full_fsync(conchFile->h,0,0);\n        /* If we created a new conch file (not just updated the contents of a \n         ** valid conch file), try to match the permissions of the database \n         */\n        if( rc==SQLITE_OK && createConch ){\n          struct stat buf;\n          int err = osFstat(pFile->h, &buf);\n          if( err==0 ){\n            mode_t cmode = buf.st_mode&(S_IRUSR|S_IWUSR | S_IRGRP|S_IWGRP |\n                                        S_IROTH|S_IWOTH);\n            /* try to match the database file R/W permissions, ignore failure */\n#ifndef SQLITE_PROXY_DEBUG\n            osFchmod(conchFile->h, cmode);\n#else\n            do{\n              rc = osFchmod(conchFile->h, cmode);\n            }while( rc==(-1) && errno==EINTR );\n            if( rc!=0 ){\n              int code = errno;\n              fprintf(stderr, \"fchmod %o FAILED with %d %s\\n\",\n                      cmode, code, strerror(code));\n            } else {\n              fprintf(stderr, \"fchmod %o SUCCEDED\\n\",cmode);\n            }\n          }else{\n            int code = errno;\n            fprintf(stderr, \"STAT FAILED[%d] with %d %s\\n\", \n                    err, code, strerror(code));\n#endif\n          }\n        }\n      }\n      conchFile->pMethod->xUnlock((sqlite3_file*)conchFile, SHARED_LOCK);\n      \n    end_takeconch:\n      OSTRACE((\"TRANSPROXY: CLOSE  %d\\n\", pFile->h));\n      if( rc==SQLITE_OK && pFile->openFlags ){\n        int fd;\n        if( pFile->h>=0 ){\n          robust_close(pFile, pFile->h, __LINE__);\n        }\n        pFile->h = -1;\n        fd = robust_open(pCtx->dbPath, pFile->openFlags, 0);\n        OSTRACE((\"TRANSPROXY: OPEN  %d\\n\", fd));\n        if( fd>=0 ){\n          pFile->h = fd;\n        }else{\n          rc=SQLITE_CANTOPEN_BKPT; /* SQLITE_BUSY? proxyTakeConch called\n           during locking */\n        }\n      }\n      if( rc==SQLITE_OK && !pCtx->lockProxy ){\n        char *path = tempLockPath ? tempLockPath : pCtx->lockProxyPath;\n        rc = proxyCreateUnixFile(path, &pCtx->lockProxy, 1);\n        if( rc!=SQLITE_OK && rc!=SQLITE_NOMEM && tryOldLockPath ){\n          /* we couldn't create the proxy lock file with the old lock file path\n           ** so try again via auto-naming \n           */\n          forceNewLockPath = 1;\n          tryOldLockPath = 0;\n          continue; /* go back to the do {} while start point, try again */\n        }\n      }\n      if( rc==SQLITE_OK ){\n        /* Need to make a copy of path if we extracted the value\n         ** from the conch file or the path was allocated on the stack\n         */\n        if( tempLockPath ){\n          pCtx->lockProxyPath = sqlite3DbStrDup(0, tempLockPath);\n          if( !pCtx->lockProxyPath ){\n            rc = SQLITE_NOMEM_BKPT;\n          }\n        }\n      }\n      if( rc==SQLITE_OK ){\n        pCtx->conchHeld = 1;\n        \n        if( pCtx->lockProxy->pMethod == &afpIoMethods ){\n          afpLockingContext *afpCtx;\n          afpCtx = (afpLockingContext *)pCtx->lockProxy->lockingContext;\n          afpCtx->dbPath = pCtx->lockProxyPath;\n        }\n      } else {\n        conchFile->pMethod->xUnlock((sqlite3_file*)conchFile, NO_LOCK);\n      }\n      OSTRACE((\"TAKECONCH  %d %s\\n\", conchFile->h,\n               rc==SQLITE_OK?\"ok\":\"failed\"));\n      return rc;\n    } while (1); /* in case we need to retry the :auto: lock file - \n                 ** we should never get here except via the 'continue' call. */\n  }\n}\n\n/*\n** If pFile holds a lock on a conch file, then release that lock.\n*/\nstatic int proxyReleaseConch(unixFile *pFile){\n  int rc = SQLITE_OK;         /* Subroutine return code */\n  proxyLockingContext *pCtx;  /* The locking context for the proxy lock */\n  unixFile *conchFile;        /* Name of the conch file */\n\n  pCtx = (proxyLockingContext *)pFile->lockingContext;\n  conchFile = pCtx->conchFile;\n  OSTRACE((\"RELEASECONCH  %d for %s pid=%d\\n\", conchFile->h,\n           (pCtx->lockProxyPath ? pCtx->lockProxyPath : \":auto:\"), \n           osGetpid(0)));\n  if( pCtx->conchHeld>0 ){\n    rc = conchFile->pMethod->xUnlock((sqlite3_file*)conchFile, NO_LOCK);\n  }\n  pCtx->conchHeld = 0;\n  OSTRACE((\"RELEASECONCH  %d %s\\n\", conchFile->h,\n           (rc==SQLITE_OK ? \"ok\" : \"failed\")));\n  return rc;\n}\n\n/*\n** Given the name of a database file, compute the name of its conch file.\n** Store the conch filename in memory obtained from sqlite3_malloc64().\n** Make *pConchPath point to the new name.  Return SQLITE_OK on success\n** or SQLITE_NOMEM if unable to obtain memory.\n**\n** The caller is responsible for ensuring that the allocated memory\n** space is eventually freed.\n**\n** *pConchPath is set to NULL if a memory allocation error occurs.\n*/\nstatic int proxyCreateConchPathname(char *dbPath, char **pConchPath){\n  int i;                        /* Loop counter */\n  int len = (int)strlen(dbPath); /* Length of database filename - dbPath */\n  char *conchPath;              /* buffer in which to construct conch name */\n\n  /* Allocate space for the conch filename and initialize the name to\n  ** the name of the original database file. */  \n  *pConchPath = conchPath = (char *)sqlite3_malloc64(len + 8);\n  if( conchPath==0 ){\n    return SQLITE_NOMEM_BKPT;\n  }\n  memcpy(conchPath, dbPath, len+1);\n  \n  /* now insert a \".\" before the last / character */\n  for( i=(len-1); i>=0; i-- ){\n    if( conchPath[i]=='/' ){\n      i++;\n      break;\n    }\n  }\n  conchPath[i]='.';\n  while ( i<len ){\n    conchPath[i+1]=dbPath[i];\n    i++;\n  }\n\n  /* append the \"-conch\" suffix to the file */\n  memcpy(&conchPath[i+1], \"-conch\", 7);\n  assert( (int)strlen(conchPath) == len+7 );\n\n  return SQLITE_OK;\n}\n\n\n/* Takes a fully configured proxy locking-style unix file and switches\n** the local lock file path \n*/\nstatic int switchLockProxyPath(unixFile *pFile, const char *path) {\n  proxyLockingContext *pCtx = (proxyLockingContext*)pFile->lockingContext;\n  char *oldPath = pCtx->lockProxyPath;\n  int rc = SQLITE_OK;\n\n  if( pFile->eFileLock!=NO_LOCK ){\n    return SQLITE_BUSY;\n  }  \n\n  /* nothing to do if the path is NULL, :auto: or matches the existing path */\n  if( !path || path[0]=='\\0' || !strcmp(path, \":auto:\") ||\n    (oldPath && !strncmp(oldPath, path, MAXPATHLEN)) ){\n    return SQLITE_OK;\n  }else{\n    unixFile *lockProxy = pCtx->lockProxy;\n    pCtx->lockProxy=NULL;\n    pCtx->conchHeld = 0;\n    if( lockProxy!=NULL ){\n      rc=lockProxy->pMethod->xClose((sqlite3_file *)lockProxy);\n      if( rc ) return rc;\n      sqlite3_free(lockProxy);\n    }\n    sqlite3_free(oldPath);\n    pCtx->lockProxyPath = sqlite3DbStrDup(0, path);\n  }\n  \n  return rc;\n}\n\n/*\n** pFile is a file that has been opened by a prior xOpen call.  dbPath\n** is a string buffer at least MAXPATHLEN+1 characters in size.\n**\n** This routine find the filename associated with pFile and writes it\n** int dbPath.\n*/\nstatic int proxyGetDbPathForUnixFile(unixFile *pFile, char *dbPath){\n#if defined(__APPLE__)\n  if( pFile->pMethod == &afpIoMethods ){\n    /* afp style keeps a reference to the db path in the filePath field \n    ** of the struct */\n    assert( (int)strlen((char*)pFile->lockingContext)<=MAXPATHLEN );\n    strlcpy(dbPath, ((afpLockingContext *)pFile->lockingContext)->dbPath,\n            MAXPATHLEN);\n  } else\n#endif\n  if( pFile->pMethod == &dotlockIoMethods ){\n    /* dot lock style uses the locking context to store the dot lock\n    ** file path */\n    int len = strlen((char *)pFile->lockingContext) - strlen(DOTLOCK_SUFFIX);\n    memcpy(dbPath, (char *)pFile->lockingContext, len + 1);\n  }else{\n    /* all other styles use the locking context to store the db file path */\n    assert( strlen((char*)pFile->lockingContext)<=MAXPATHLEN );\n    strlcpy(dbPath, (char *)pFile->lockingContext, MAXPATHLEN);\n  }\n  return SQLITE_OK;\n}\n\n/*\n** Takes an already filled in unix file and alters it so all file locking \n** will be performed on the local proxy lock file.  The following fields\n** are preserved in the locking context so that they can be restored and \n** the unix structure properly cleaned up at close time:\n**  ->lockingContext\n**  ->pMethod\n*/\nstatic int proxyTransformUnixFile(unixFile *pFile, const char *path) {\n  proxyLockingContext *pCtx;\n  char dbPath[MAXPATHLEN+1];       /* Name of the database file */\n  char *lockPath=NULL;\n  int rc = SQLITE_OK;\n  \n  if( pFile->eFileLock!=NO_LOCK ){\n    return SQLITE_BUSY;\n  }\n  proxyGetDbPathForUnixFile(pFile, dbPath);\n  if( !path || path[0]=='\\0' || !strcmp(path, \":auto:\") ){\n    lockPath=NULL;\n  }else{\n    lockPath=(char *)path;\n  }\n  \n  OSTRACE((\"TRANSPROXY  %d for %s pid=%d\\n\", pFile->h,\n           (lockPath ? lockPath : \":auto:\"), osGetpid(0)));\n\n  pCtx = sqlite3_malloc64( sizeof(*pCtx) );\n  if( pCtx==0 ){\n    return SQLITE_NOMEM_BKPT;\n  }\n  memset(pCtx, 0, sizeof(*pCtx));\n\n  rc = proxyCreateConchPathname(dbPath, &pCtx->conchFilePath);\n  if( rc==SQLITE_OK ){\n    rc = proxyCreateUnixFile(pCtx->conchFilePath, &pCtx->conchFile, 0);\n    if( rc==SQLITE_CANTOPEN && ((pFile->openFlags&O_RDWR) == 0) ){\n      /* if (a) the open flags are not O_RDWR, (b) the conch isn't there, and\n      ** (c) the file system is read-only, then enable no-locking access.\n      ** Ugh, since O_RDONLY==0x0000 we test for !O_RDWR since unixOpen asserts\n      ** that openFlags will have only one of O_RDONLY or O_RDWR.\n      */\n      struct statfs fsInfo;\n      struct stat conchInfo;\n      int goLockless = 0;\n\n      if( osStat(pCtx->conchFilePath, &conchInfo) == -1 ) {\n        int err = errno;\n        if( (err==ENOENT) && (statfs(dbPath, &fsInfo) != -1) ){\n          goLockless = (fsInfo.f_flags&MNT_RDONLY) == MNT_RDONLY;\n        }\n      }\n      if( goLockless ){\n        pCtx->conchHeld = -1; /* read only FS/ lockless */\n        rc = SQLITE_OK;\n      }\n    }\n  }  \n  if( rc==SQLITE_OK && lockPath ){\n    pCtx->lockProxyPath = sqlite3DbStrDup(0, lockPath);\n  }\n\n  if( rc==SQLITE_OK ){\n    pCtx->dbPath = sqlite3DbStrDup(0, dbPath);\n    if( pCtx->dbPath==NULL ){\n      rc = SQLITE_NOMEM_BKPT;\n    }\n  }\n  if( rc==SQLITE_OK ){\n    /* all memory is allocated, proxys are created and assigned, \n    ** switch the locking context and pMethod then return.\n    */\n    pCtx->oldLockingContext = pFile->lockingContext;\n    pFile->lockingContext = pCtx;\n    pCtx->pOldMethod = pFile->pMethod;\n    pFile->pMethod = &proxyIoMethods;\n  }else{\n    if( pCtx->conchFile ){ \n      pCtx->conchFile->pMethod->xClose((sqlite3_file *)pCtx->conchFile);\n      sqlite3_free(pCtx->conchFile);\n    }\n    sqlite3DbFree(0, pCtx->lockProxyPath);\n    sqlite3_free(pCtx->conchFilePath); \n    sqlite3_free(pCtx);\n  }\n  OSTRACE((\"TRANSPROXY  %d %s\\n\", pFile->h,\n           (rc==SQLITE_OK ? \"ok\" : \"failed\")));\n  return rc;\n}\n\n\n/*\n** This routine handles sqlite3_file_control() calls that are specific\n** to proxy locking.\n*/\nstatic int proxyFileControl(sqlite3_file *id, int op, void *pArg){\n  switch( op ){\n    case SQLITE_FCNTL_GET_LOCKPROXYFILE: {\n      unixFile *pFile = (unixFile*)id;\n      if( pFile->pMethod == &proxyIoMethods ){\n        proxyLockingContext *pCtx = (proxyLockingContext*)pFile->lockingContext;\n        proxyTakeConch(pFile);\n        if( pCtx->lockProxyPath ){\n          *(const char **)pArg = pCtx->lockProxyPath;\n        }else{\n          *(const char **)pArg = \":auto: (not held)\";\n        }\n      } else {\n        *(const char **)pArg = NULL;\n      }\n      return SQLITE_OK;\n    }\n    case SQLITE_FCNTL_SET_LOCKPROXYFILE: {\n      unixFile *pFile = (unixFile*)id;\n      int rc = SQLITE_OK;\n      int isProxyStyle = (pFile->pMethod == &proxyIoMethods);\n      if( pArg==NULL || (const char *)pArg==0 ){\n        if( isProxyStyle ){\n          /* turn off proxy locking - not supported.  If support is added for\n          ** switching proxy locking mode off then it will need to fail if\n          ** the journal mode is WAL mode. \n          */\n          rc = SQLITE_ERROR /*SQLITE_PROTOCOL? SQLITE_MISUSE?*/;\n        }else{\n          /* turn off proxy locking - already off - NOOP */\n          rc = SQLITE_OK;\n        }\n      }else{\n        const char *proxyPath = (const char *)pArg;\n        if( isProxyStyle ){\n          proxyLockingContext *pCtx = \n            (proxyLockingContext*)pFile->lockingContext;\n          if( !strcmp(pArg, \":auto:\") \n           || (pCtx->lockProxyPath &&\n               !strncmp(pCtx->lockProxyPath, proxyPath, MAXPATHLEN))\n          ){\n            rc = SQLITE_OK;\n          }else{\n            rc = switchLockProxyPath(pFile, proxyPath);\n          }\n        }else{\n          /* turn on proxy file locking */\n          rc = proxyTransformUnixFile(pFile, proxyPath);\n        }\n      }\n      return rc;\n    }\n    default: {\n      assert( 0 );  /* The call assures that only valid opcodes are sent */\n    }\n  }\n  /*NOTREACHED*/\n  return SQLITE_ERROR;\n}\n\n/*\n** Within this division (the proxying locking implementation) the procedures\n** above this point are all utilities.  The lock-related methods of the\n** proxy-locking sqlite3_io_method object follow.\n*/\n\n\n/*\n** This routine checks if there is a RESERVED lock held on the specified\n** file by this or any other process. If such a lock is held, set *pResOut\n** to a non-zero value otherwise *pResOut is set to zero.  The return value\n** is set to SQLITE_OK unless an I/O error occurs during lock checking.\n*/\nstatic int proxyCheckReservedLock(sqlite3_file *id, int *pResOut) {\n  unixFile *pFile = (unixFile*)id;\n  int rc = proxyTakeConch(pFile);\n  if( rc==SQLITE_OK ){\n    proxyLockingContext *pCtx = (proxyLockingContext *)pFile->lockingContext;\n    if( pCtx->conchHeld>0 ){\n      unixFile *proxy = pCtx->lockProxy;\n      return proxy->pMethod->xCheckReservedLock((sqlite3_file*)proxy, pResOut);\n    }else{ /* conchHeld < 0 is lockless */\n      pResOut=0;\n    }\n  }\n  return rc;\n}\n\n/*\n** Lock the file with the lock specified by parameter eFileLock - one\n** of the following:\n**\n**     (1) SHARED_LOCK\n**     (2) RESERVED_LOCK\n**     (3) PENDING_LOCK\n**     (4) EXCLUSIVE_LOCK\n**\n** Sometimes when requesting one lock state, additional lock states\n** are inserted in between.  The locking might fail on one of the later\n** transitions leaving the lock state different from what it started but\n** still short of its goal.  The following chart shows the allowed\n** transitions and the inserted intermediate states:\n**\n**    UNLOCKED -> SHARED\n**    SHARED -> RESERVED\n**    SHARED -> (PENDING) -> EXCLUSIVE\n**    RESERVED -> (PENDING) -> EXCLUSIVE\n**    PENDING -> EXCLUSIVE\n**\n** This routine will only increase a lock.  Use the sqlite3OsUnlock()\n** routine to lower a locking level.\n*/\nstatic int proxyLock(sqlite3_file *id, int eFileLock) {\n  unixFile *pFile = (unixFile*)id;\n  int rc = proxyTakeConch(pFile);\n  if( rc==SQLITE_OK ){\n    proxyLockingContext *pCtx = (proxyLockingContext *)pFile->lockingContext;\n    if( pCtx->conchHeld>0 ){\n      unixFile *proxy = pCtx->lockProxy;\n      rc = proxy->pMethod->xLock((sqlite3_file*)proxy, eFileLock);\n      pFile->eFileLock = proxy->eFileLock;\n    }else{\n      /* conchHeld < 0 is lockless */\n    }\n  }\n  return rc;\n}\n\n\n/*\n** Lower the locking level on file descriptor pFile to eFileLock.  eFileLock\n** must be either NO_LOCK or SHARED_LOCK.\n**\n** If the locking level of the file descriptor is already at or below\n** the requested locking level, this routine is a no-op.\n*/\nstatic int proxyUnlock(sqlite3_file *id, int eFileLock) {\n  unixFile *pFile = (unixFile*)id;\n  int rc = proxyTakeConch(pFile);\n  if( rc==SQLITE_OK ){\n    proxyLockingContext *pCtx = (proxyLockingContext *)pFile->lockingContext;\n    if( pCtx->conchHeld>0 ){\n      unixFile *proxy = pCtx->lockProxy;\n      rc = proxy->pMethod->xUnlock((sqlite3_file*)proxy, eFileLock);\n      pFile->eFileLock = proxy->eFileLock;\n    }else{\n      /* conchHeld < 0 is lockless */\n    }\n  }\n  return rc;\n}\n\n/*\n** Close a file that uses proxy locks.\n*/\nstatic int proxyClose(sqlite3_file *id) {\n  if( ALWAYS(id) ){\n    unixFile *pFile = (unixFile*)id;\n    proxyLockingContext *pCtx = (proxyLockingContext *)pFile->lockingContext;\n    unixFile *lockProxy = pCtx->lockProxy;\n    unixFile *conchFile = pCtx->conchFile;\n    int rc = SQLITE_OK;\n    \n    if( lockProxy ){\n      rc = lockProxy->pMethod->xUnlock((sqlite3_file*)lockProxy, NO_LOCK);\n      if( rc ) return rc;\n      rc = lockProxy->pMethod->xClose((sqlite3_file*)lockProxy);\n      if( rc ) return rc;\n      sqlite3_free(lockProxy);\n      pCtx->lockProxy = 0;\n    }\n    if( conchFile ){\n      if( pCtx->conchHeld ){\n        rc = proxyReleaseConch(pFile);\n        if( rc ) return rc;\n      }\n      rc = conchFile->pMethod->xClose((sqlite3_file*)conchFile);\n      if( rc ) return rc;\n      sqlite3_free(conchFile);\n    }\n    sqlite3DbFree(0, pCtx->lockProxyPath);\n    sqlite3_free(pCtx->conchFilePath);\n    sqlite3DbFree(0, pCtx->dbPath);\n    /* restore the original locking context and pMethod then close it */\n    pFile->lockingContext = pCtx->oldLockingContext;\n    pFile->pMethod = pCtx->pOldMethod;\n    sqlite3_free(pCtx);\n    return pFile->pMethod->xClose(id);\n  }\n  return SQLITE_OK;\n}\n\n\n\n#endif /* defined(__APPLE__) && SQLITE_ENABLE_LOCKING_STYLE */\n/*\n** The proxy locking style is intended for use with AFP filesystems.\n** And since AFP is only supported on MacOSX, the proxy locking is also\n** restricted to MacOSX.\n** \n**\n******************* End of the proxy lock implementation **********************\n******************************************************************************/\n\n/*\n** Initialize the operating system interface.\n**\n** This routine registers all VFS implementations for unix-like operating\n** systems.  This routine, and the sqlite3_os_end() routine that follows,\n** should be the only routines in this file that are visible from other\n** files.\n**\n** This routine is called once during SQLite initialization and by a\n** single thread.  The memory allocation and mutex subsystems have not\n** necessarily been initialized when this routine is called, and so they\n** should not be used.\n*/\nSQLITE_API int sqlite3_os_init(void){ \n  /* \n  ** The following macro defines an initializer for an sqlite3_vfs object.\n  ** The name of the VFS is NAME.  The pAppData is a pointer to a pointer\n  ** to the \"finder\" function.  (pAppData is a pointer to a pointer because\n  ** silly C90 rules prohibit a void* from being cast to a function pointer\n  ** and so we have to go through the intermediate pointer to avoid problems\n  ** when compiling with -pedantic-errors on GCC.)\n  **\n  ** The FINDER parameter to this macro is the name of the pointer to the\n  ** finder-function.  The finder-function returns a pointer to the\n  ** sqlite_io_methods object that implements the desired locking\n  ** behaviors.  See the division above that contains the IOMETHODS\n  ** macro for addition information on finder-functions.\n  **\n  ** Most finders simply return a pointer to a fixed sqlite3_io_methods\n  ** object.  But the \"autolockIoFinder\" available on MacOSX does a little\n  ** more than that; it looks at the filesystem type that hosts the \n  ** database file and tries to choose an locking method appropriate for\n  ** that filesystem time.\n  */\n  #define UNIXVFS(VFSNAME, FINDER) {                        \\\n    3,                    /* iVersion */                    \\\n    sizeof(unixFile),     /* szOsFile */                    \\\n    MAX_PATHNAME,         /* mxPathname */                  \\\n    0,                    /* pNext */                       \\\n    VFSNAME,              /* zName */                       \\\n    (void*)&FINDER,       /* pAppData */                    \\\n    unixOpen,             /* xOpen */                       \\\n    unixDelete,           /* xDelete */                     \\\n    unixAccess,           /* xAccess */                     \\\n    unixFullPathname,     /* xFullPathname */               \\\n    unixDlOpen,           /* xDlOpen */                     \\\n    unixDlError,          /* xDlError */                    \\\n    unixDlSym,            /* xDlSym */                      \\\n    unixDlClose,          /* xDlClose */                    \\\n    unixRandomness,       /* xRandomness */                 \\\n    unixSleep,            /* xSleep */                      \\\n    unixCurrentTime,      /* xCurrentTime */                \\\n    unixGetLastError,     /* xGetLastError */               \\\n    unixCurrentTimeInt64, /* xCurrentTimeInt64 */           \\\n    unixSetSystemCall,    /* xSetSystemCall */              \\\n    unixGetSystemCall,    /* xGetSystemCall */              \\\n    unixNextSystemCall,   /* xNextSystemCall */             \\\n  }\n\n  /*\n  ** All default VFSes for unix are contained in the following array.\n  **\n  ** Note that the sqlite3_vfs.pNext field of the VFS object is modified\n  ** by the SQLite core when the VFS is registered.  So the following\n  ** array cannot be const.\n  */\n  static sqlite3_vfs aVfs[] = {\n#if SQLITE_ENABLE_LOCKING_STYLE && defined(__APPLE__)\n    UNIXVFS(\"unix\",          autolockIoFinder ),\n#elif OS_VXWORKS\n    UNIXVFS(\"unix\",          vxworksIoFinder ),\n#else\n    UNIXVFS(\"unix\",          posixIoFinder ),\n#endif\n    UNIXVFS(\"unix-none\",     nolockIoFinder ),\n    UNIXVFS(\"unix-dotfile\",  dotlockIoFinder ),\n    UNIXVFS(\"unix-excl\",     posixIoFinder ),\n#if OS_VXWORKS\n    UNIXVFS(\"unix-namedsem\", semIoFinder ),\n#endif\n#if SQLITE_ENABLE_LOCKING_STYLE || OS_VXWORKS\n    UNIXVFS(\"unix-posix\",    posixIoFinder ),\n#endif\n#if SQLITE_ENABLE_LOCKING_STYLE\n    UNIXVFS(\"unix-flock\",    flockIoFinder ),\n#endif\n#if SQLITE_ENABLE_LOCKING_STYLE && defined(__APPLE__)\n    UNIXVFS(\"unix-afp\",      afpIoFinder ),\n    UNIXVFS(\"unix-nfs\",      nfsIoFinder ),\n    UNIXVFS(\"unix-proxy\",    proxyIoFinder ),\n#endif\n  };\n  unsigned int i;          /* Loop counter */\n\n  /* Double-check that the aSyscall[] array has been constructed\n  ** correctly.  See ticket [bb3a86e890c8e96ab] */\n  assert( ArraySize(aSyscall)==29 );\n\n  /* Register all VFSes defined in the aVfs[] array */\n  for(i=0; i<(sizeof(aVfs)/sizeof(sqlite3_vfs)); i++){\n    sqlite3_vfs_register(&aVfs[i], i==0);\n  }\n  unixBigLock = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_VFS1);\n  return SQLITE_OK; \n}\n\n/*\n** Shutdown the operating system interface.\n**\n** Some operating systems might need to do some cleanup in this routine,\n** to release dynamically allocated objects.  But not on unix.\n** This routine is a no-op for unix.\n*/\nSQLITE_API int sqlite3_os_end(void){ \n  unixBigLock = 0;\n  return SQLITE_OK; \n}\n \n#endif /* SQLITE_OS_UNIX */\n\n/************** End of os_unix.c *********************************************/\n/************** Begin file os_win.c ******************************************/\n/*\n** 2004 May 22\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n******************************************************************************\n**\n** This file contains code that is specific to Windows.\n*/\n/* #include \"sqliteInt.h\" */\n#if SQLITE_OS_WIN               /* This file is used for Windows only */\n\n/*\n** Include code that is common to all os_*.c files\n*/\n/************** Include os_common.h in the middle of os_win.c ****************/\n/************** Begin file os_common.h ***************************************/\n/*\n** 2004 May 22\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n******************************************************************************\n**\n** This file contains macros and a little bit of code that is common to\n** all of the platform-specific files (os_*.c) and is #included into those\n** files.\n**\n** This file should be #included by the os_*.c files only.  It is not a\n** general purpose header file.\n*/\n#ifndef _OS_COMMON_H_\n#define _OS_COMMON_H_\n\n/*\n** At least two bugs have slipped in because we changed the MEMORY_DEBUG\n** macro to SQLITE_DEBUG and some older makefiles have not yet made the\n** switch.  The following code should catch this problem at compile-time.\n*/\n#ifdef MEMORY_DEBUG\n# error \"The MEMORY_DEBUG macro is obsolete.  Use SQLITE_DEBUG instead.\"\n#endif\n\n/*\n** Macros for performance tracing.  Normally turned off.  Only works\n** on i486 hardware.\n*/\n#ifdef SQLITE_PERFORMANCE_TRACE\n\n/*\n** hwtime.h contains inline assembler code for implementing\n** high-performance timing routines.\n*/\n/************** Include hwtime.h in the middle of os_common.h ****************/\n/************** Begin file hwtime.h ******************************************/\n/*\n** 2008 May 27\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n******************************************************************************\n**\n** This file contains inline asm code for retrieving \"high-performance\"\n** counters for x86 class CPUs.\n*/\n#ifndef SQLITE_HWTIME_H\n#define SQLITE_HWTIME_H\n\n/*\n** The following routine only works on pentium-class (or newer) processors.\n** It uses the RDTSC opcode to read the cycle count value out of the\n** processor and returns that value.  This can be used for high-res\n** profiling.\n*/\n#if (defined(__GNUC__) || defined(_MSC_VER)) && \\\n      (defined(i386) || defined(__i386__) || defined(_M_IX86))\n\n  #if defined(__GNUC__)\n\n  __inline__ sqlite_uint64 sqlite3Hwtime(void){\n     unsigned int lo, hi;\n     __asm__ __volatile__ (\"rdtsc\" : \"=a\" (lo), \"=d\" (hi));\n     return (sqlite_uint64)hi << 32 | lo;\n  }\n\n  #elif defined(_MSC_VER)\n\n  __declspec(naked) __inline sqlite_uint64 __cdecl sqlite3Hwtime(void){\n     __asm {\n        rdtsc\n        ret       ; return value at EDX:EAX\n     }\n  }\n\n  #endif\n\n#elif (defined(__GNUC__) && defined(__x86_64__))\n\n  __inline__ sqlite_uint64 sqlite3Hwtime(void){\n      unsigned long val;\n      __asm__ __volatile__ (\"rdtsc\" : \"=A\" (val));\n      return val;\n  }\n \n#elif (defined(__GNUC__) && defined(__ppc__))\n\n  __inline__ sqlite_uint64 sqlite3Hwtime(void){\n      unsigned long long retval;\n      unsigned long junk;\n      __asm__ __volatile__ (\"\\n\\\n          1:      mftbu   %1\\n\\\n                  mftb    %L0\\n\\\n                  mftbu   %0\\n\\\n                  cmpw    %0,%1\\n\\\n                  bne     1b\"\n                  : \"=r\" (retval), \"=r\" (junk));\n      return retval;\n  }\n\n#else\n\n  #error Need implementation of sqlite3Hwtime() for your platform.\n\n  /*\n  ** To compile without implementing sqlite3Hwtime() for your platform,\n  ** you can remove the above #error and use the following\n  ** stub function.  You will lose timing support for many\n  ** of the debugging and testing utilities, but it should at\n  ** least compile and run.\n  */\nSQLITE_PRIVATE   sqlite_uint64 sqlite3Hwtime(void){ return ((sqlite_uint64)0); }\n\n#endif\n\n#endif /* !defined(SQLITE_HWTIME_H) */\n\n/************** End of hwtime.h **********************************************/\n/************** Continuing where we left off in os_common.h ******************/\n\nstatic sqlite_uint64 g_start;\nstatic sqlite_uint64 g_elapsed;\n#define TIMER_START       g_start=sqlite3Hwtime()\n#define TIMER_END         g_elapsed=sqlite3Hwtime()-g_start\n#define TIMER_ELAPSED     g_elapsed\n#else\n#define TIMER_START\n#define TIMER_END\n#define TIMER_ELAPSED     ((sqlite_uint64)0)\n#endif\n\n/*\n** If we compile with the SQLITE_TEST macro set, then the following block\n** of code will give us the ability to simulate a disk I/O error.  This\n** is used for testing the I/O recovery logic.\n*/\n#if defined(SQLITE_TEST)\nSQLITE_API extern int sqlite3_io_error_hit;\nSQLITE_API extern int sqlite3_io_error_hardhit;\nSQLITE_API extern int sqlite3_io_error_pending;\nSQLITE_API extern int sqlite3_io_error_persist;\nSQLITE_API extern int sqlite3_io_error_benign;\nSQLITE_API extern int sqlite3_diskfull_pending;\nSQLITE_API extern int sqlite3_diskfull;\n#define SimulateIOErrorBenign(X) sqlite3_io_error_benign=(X)\n#define SimulateIOError(CODE)  \\\n  if( (sqlite3_io_error_persist && sqlite3_io_error_hit) \\\n       || sqlite3_io_error_pending-- == 1 )  \\\n              { local_ioerr(); CODE; }\nstatic void local_ioerr(){\n  IOTRACE((\"IOERR\\n\"));\n  sqlite3_io_error_hit++;\n  if( !sqlite3_io_error_benign ) sqlite3_io_error_hardhit++;\n}\n#define SimulateDiskfullError(CODE) \\\n   if( sqlite3_diskfull_pending ){ \\\n     if( sqlite3_diskfull_pending == 1 ){ \\\n       local_ioerr(); \\\n       sqlite3_diskfull = 1; \\\n       sqlite3_io_error_hit = 1; \\\n       CODE; \\\n     }else{ \\\n       sqlite3_diskfull_pending--; \\\n     } \\\n   }\n#else\n#define SimulateIOErrorBenign(X)\n#define SimulateIOError(A)\n#define SimulateDiskfullError(A)\n#endif /* defined(SQLITE_TEST) */\n\n/*\n** When testing, keep a count of the number of open files.\n*/\n#if defined(SQLITE_TEST)\nSQLITE_API extern int sqlite3_open_file_count;\n#define OpenCounter(X)  sqlite3_open_file_count+=(X)\n#else\n#define OpenCounter(X)\n#endif /* defined(SQLITE_TEST) */\n\n#endif /* !defined(_OS_COMMON_H_) */\n\n/************** End of os_common.h *******************************************/\n/************** Continuing where we left off in os_win.c *********************/\n\n/*\n** Include the header file for the Windows VFS.\n*/\n/* #include \"os_win.h\" */\n\n/*\n** Compiling and using WAL mode requires several APIs that are only\n** available in Windows platforms based on the NT kernel.\n*/\n#if !SQLITE_OS_WINNT && !defined(SQLITE_OMIT_WAL)\n#  error \"WAL mode requires support from the Windows NT kernel, compile\\\n with SQLITE_OMIT_WAL.\"\n#endif\n\n#if !SQLITE_OS_WINNT && SQLITE_MAX_MMAP_SIZE>0\n#  error \"Memory mapped files require support from the Windows NT kernel,\\\n compile with SQLITE_MAX_MMAP_SIZE=0.\"\n#endif\n\n/*\n** Are most of the Win32 ANSI APIs available (i.e. with certain exceptions\n** based on the sub-platform)?\n*/\n#if !SQLITE_OS_WINCE && !SQLITE_OS_WINRT && !defined(SQLITE_WIN32_NO_ANSI)\n#  define SQLITE_WIN32_HAS_ANSI\n#endif\n\n/*\n** Are most of the Win32 Unicode APIs available (i.e. with certain exceptions\n** based on the sub-platform)?\n*/\n#if (SQLITE_OS_WINCE || SQLITE_OS_WINNT || SQLITE_OS_WINRT) && \\\n    !defined(SQLITE_WIN32_NO_WIDE)\n#  define SQLITE_WIN32_HAS_WIDE\n#endif\n\n/*\n** Make sure at least one set of Win32 APIs is available.\n*/\n#if !defined(SQLITE_WIN32_HAS_ANSI) && !defined(SQLITE_WIN32_HAS_WIDE)\n#  error \"At least one of SQLITE_WIN32_HAS_ANSI and SQLITE_WIN32_HAS_WIDE\\\n must be defined.\"\n#endif\n\n/*\n** Define the required Windows SDK version constants if they are not\n** already available.\n*/\n#ifndef NTDDI_WIN8\n#  define NTDDI_WIN8                        0x06020000\n#endif\n\n#ifndef NTDDI_WINBLUE\n#  define NTDDI_WINBLUE                     0x06030000\n#endif\n\n#ifndef NTDDI_WINTHRESHOLD\n#  define NTDDI_WINTHRESHOLD                0x06040000\n#endif\n\n/*\n** Check to see if the GetVersionEx[AW] functions are deprecated on the\n** target system.  GetVersionEx was first deprecated in Win8.1.\n*/\n#ifndef SQLITE_WIN32_GETVERSIONEX\n#  if defined(NTDDI_VERSION) && NTDDI_VERSION >= NTDDI_WINBLUE\n#    define SQLITE_WIN32_GETVERSIONEX   0   /* GetVersionEx() is deprecated */\n#  else\n#    define SQLITE_WIN32_GETVERSIONEX   1   /* GetVersionEx() is current */\n#  endif\n#endif\n\n/*\n** Check to see if the CreateFileMappingA function is supported on the\n** target system.  It is unavailable when using \"mincore.lib\" on Win10.\n** When compiling for Windows 10, always assume \"mincore.lib\" is in use.\n*/\n#ifndef SQLITE_WIN32_CREATEFILEMAPPINGA\n#  if defined(NTDDI_VERSION) && NTDDI_VERSION >= NTDDI_WINTHRESHOLD\n#    define SQLITE_WIN32_CREATEFILEMAPPINGA   0\n#  else\n#    define SQLITE_WIN32_CREATEFILEMAPPINGA   1\n#  endif\n#endif\n\n/*\n** This constant should already be defined (in the \"WinDef.h\" SDK file).\n*/\n#ifndef MAX_PATH\n#  define MAX_PATH                      (260)\n#endif\n\n/*\n** Maximum pathname length (in chars) for Win32.  This should normally be\n** MAX_PATH.\n*/\n#ifndef SQLITE_WIN32_MAX_PATH_CHARS\n#  define SQLITE_WIN32_MAX_PATH_CHARS   (MAX_PATH)\n#endif\n\n/*\n** This constant should already be defined (in the \"WinNT.h\" SDK file).\n*/\n#ifndef UNICODE_STRING_MAX_CHARS\n#  define UNICODE_STRING_MAX_CHARS      (32767)\n#endif\n\n/*\n** Maximum pathname length (in chars) for WinNT.  This should normally be\n** UNICODE_STRING_MAX_CHARS.\n*/\n#ifndef SQLITE_WINNT_MAX_PATH_CHARS\n#  define SQLITE_WINNT_MAX_PATH_CHARS   (UNICODE_STRING_MAX_CHARS)\n#endif\n\n/*\n** Maximum pathname length (in bytes) for Win32.  The MAX_PATH macro is in\n** characters, so we allocate 4 bytes per character assuming worst-case of\n** 4-bytes-per-character for UTF8.\n*/\n#ifndef SQLITE_WIN32_MAX_PATH_BYTES\n#  define SQLITE_WIN32_MAX_PATH_BYTES   (SQLITE_WIN32_MAX_PATH_CHARS*4)\n#endif\n\n/*\n** Maximum pathname length (in bytes) for WinNT.  This should normally be\n** UNICODE_STRING_MAX_CHARS * sizeof(WCHAR).\n*/\n#ifndef SQLITE_WINNT_MAX_PATH_BYTES\n#  define SQLITE_WINNT_MAX_PATH_BYTES   \\\n                            (sizeof(WCHAR) * SQLITE_WINNT_MAX_PATH_CHARS)\n#endif\n\n/*\n** Maximum error message length (in chars) for WinRT.\n*/\n#ifndef SQLITE_WIN32_MAX_ERRMSG_CHARS\n#  define SQLITE_WIN32_MAX_ERRMSG_CHARS (1024)\n#endif\n\n/*\n** Returns non-zero if the character should be treated as a directory\n** separator.\n*/\n#ifndef winIsDirSep\n#  define winIsDirSep(a)                (((a) == '/') || ((a) == '\\\\'))\n#endif\n\n/*\n** This macro is used when a local variable is set to a value that is\n** [sometimes] not used by the code (e.g. via conditional compilation).\n*/\n#ifndef UNUSED_VARIABLE_VALUE\n#  define UNUSED_VARIABLE_VALUE(x)      (void)(x)\n#endif\n\n/*\n** Returns the character that should be used as the directory separator.\n*/\n#ifndef winGetDirSep\n#  define winGetDirSep()                '\\\\'\n#endif\n\n/*\n** Do we need to manually define the Win32 file mapping APIs for use with WAL\n** mode or memory mapped files (e.g. these APIs are available in the Windows\n** CE SDK; however, they are not present in the header file)?\n*/\n#if SQLITE_WIN32_FILEMAPPING_API && \\\n        (!defined(SQLITE_OMIT_WAL) || SQLITE_MAX_MMAP_SIZE>0)\n/*\n** Two of the file mapping APIs are different under WinRT.  Figure out which\n** set we need.\n*/\n#if SQLITE_OS_WINRT\nWINBASEAPI HANDLE WINAPI CreateFileMappingFromApp(HANDLE, \\\n        LPSECURITY_ATTRIBUTES, ULONG, ULONG64, LPCWSTR);\n\nWINBASEAPI LPVOID WINAPI MapViewOfFileFromApp(HANDLE, ULONG, ULONG64, SIZE_T);\n#else\n#if defined(SQLITE_WIN32_HAS_ANSI)\nWINBASEAPI HANDLE WINAPI CreateFileMappingA(HANDLE, LPSECURITY_ATTRIBUTES, \\\n        DWORD, DWORD, DWORD, LPCSTR);\n#endif /* defined(SQLITE_WIN32_HAS_ANSI) */\n\n#if defined(SQLITE_WIN32_HAS_WIDE)\nWINBASEAPI HANDLE WINAPI CreateFileMappingW(HANDLE, LPSECURITY_ATTRIBUTES, \\\n        DWORD, DWORD, DWORD, LPCWSTR);\n#endif /* defined(SQLITE_WIN32_HAS_WIDE) */\n\nWINBASEAPI LPVOID WINAPI MapViewOfFile(HANDLE, DWORD, DWORD, DWORD, SIZE_T);\n#endif /* SQLITE_OS_WINRT */\n\n/*\n** These file mapping APIs are common to both Win32 and WinRT.\n*/\n\nWINBASEAPI BOOL WINAPI FlushViewOfFile(LPCVOID, SIZE_T);\nWINBASEAPI BOOL WINAPI UnmapViewOfFile(LPCVOID);\n#endif /* SQLITE_WIN32_FILEMAPPING_API */\n\n/*\n** Some Microsoft compilers lack this definition.\n*/\n#ifndef INVALID_FILE_ATTRIBUTES\n# define INVALID_FILE_ATTRIBUTES ((DWORD)-1)\n#endif\n\n#ifndef FILE_FLAG_MASK\n# define FILE_FLAG_MASK          (0xFF3C0000)\n#endif\n\n#ifndef FILE_ATTRIBUTE_MASK\n# define FILE_ATTRIBUTE_MASK     (0x0003FFF7)\n#endif\n\n#ifndef SQLITE_OMIT_WAL\n/* Forward references to structures used for WAL */\ntypedef struct winShm winShm;           /* A connection to shared-memory */\ntypedef struct winShmNode winShmNode;   /* A region of shared-memory */\n#endif\n\n/*\n** WinCE lacks native support for file locking so we have to fake it\n** with some code of our own.\n*/\n#if SQLITE_OS_WINCE\ntypedef struct winceLock {\n  int nReaders;       /* Number of reader locks obtained */\n  BOOL bPending;      /* Indicates a pending lock has been obtained */\n  BOOL bReserved;     /* Indicates a reserved lock has been obtained */\n  BOOL bExclusive;    /* Indicates an exclusive lock has been obtained */\n} winceLock;\n#endif\n\n/*\n** The winFile structure is a subclass of sqlite3_file* specific to the win32\n** portability layer.\n*/\ntypedef struct winFile winFile;\nstruct winFile {\n  const sqlite3_io_methods *pMethod; /*** Must be first ***/\n  sqlite3_vfs *pVfs;      /* The VFS used to open this file */\n  HANDLE h;               /* Handle for accessing the file */\n  u8 locktype;            /* Type of lock currently held on this file */\n  short sharedLockByte;   /* Randomly chosen byte used as a shared lock */\n  u8 ctrlFlags;           /* Flags.  See WINFILE_* below */\n  DWORD lastErrno;        /* The Windows errno from the last I/O error */\n#ifndef SQLITE_OMIT_WAL\n  winShm *pShm;           /* Instance of shared memory on this file */\n#endif\n  const char *zPath;      /* Full pathname of this file */\n  int szChunk;            /* Chunk size configured by FCNTL_CHUNK_SIZE */\n#if SQLITE_OS_WINCE\n  LPWSTR zDeleteOnClose;  /* Name of file to delete when closing */\n  HANDLE hMutex;          /* Mutex used to control access to shared lock */\n  HANDLE hShared;         /* Shared memory segment used for locking */\n  winceLock local;        /* Locks obtained by this instance of winFile */\n  winceLock *shared;      /* Global shared lock memory for the file  */\n#endif\n#if SQLITE_MAX_MMAP_SIZE>0\n  int nFetchOut;                /* Number of outstanding xFetch references */\n  HANDLE hMap;                  /* Handle for accessing memory mapping */\n  void *pMapRegion;             /* Area memory mapped */\n  sqlite3_int64 mmapSize;       /* Size of mapped region */\n  sqlite3_int64 mmapSizeMax;    /* Configured FCNTL_MMAP_SIZE value */\n#endif\n};\n\n/*\n** The winVfsAppData structure is used for the pAppData member for all of the\n** Win32 VFS variants.\n*/\ntypedef struct winVfsAppData winVfsAppData;\nstruct winVfsAppData {\n  const sqlite3_io_methods *pMethod; /* The file I/O methods to use. */\n  void *pAppData;                    /* The extra pAppData, if any. */\n  BOOL bNoLock;                      /* Non-zero if locking is disabled. */\n};\n\n/*\n** Allowed values for winFile.ctrlFlags\n*/\n#define WINFILE_RDONLY          0x02   /* Connection is read only */\n#define WINFILE_PERSIST_WAL     0x04   /* Persistent WAL mode */\n#define WINFILE_PSOW            0x10   /* SQLITE_IOCAP_POWERSAFE_OVERWRITE */\n\n/*\n * The size of the buffer used by sqlite3_win32_write_debug().\n */\n#ifndef SQLITE_WIN32_DBG_BUF_SIZE\n#  define SQLITE_WIN32_DBG_BUF_SIZE   ((int)(4096-sizeof(DWORD)))\n#endif\n\n/*\n * If compiled with SQLITE_WIN32_MALLOC on Windows, we will use the\n * various Win32 API heap functions instead of our own.\n */\n#ifdef SQLITE_WIN32_MALLOC\n\n/*\n * If this is non-zero, an isolated heap will be created by the native Win32\n * allocator subsystem; otherwise, the default process heap will be used.  This\n * setting has no effect when compiling for WinRT.  By default, this is enabled\n * and an isolated heap will be created to store all allocated data.\n *\n ******************************************************************************\n * WARNING: It is important to note that when this setting is non-zero and the\n *          winMemShutdown function is called (e.g. by the sqlite3_shutdown\n *          function), all data that was allocated using the isolated heap will\n *          be freed immediately and any attempt to access any of that freed\n *          data will almost certainly result in an immediate access violation.\n ******************************************************************************\n */\n#ifndef SQLITE_WIN32_HEAP_CREATE\n#  define SQLITE_WIN32_HEAP_CREATE        (TRUE)\n#endif\n\n/*\n * This is the maximum possible initial size of the Win32-specific heap, in\n * bytes.\n */\n#ifndef SQLITE_WIN32_HEAP_MAX_INIT_SIZE\n#  define SQLITE_WIN32_HEAP_MAX_INIT_SIZE (4294967295U)\n#endif\n\n/*\n * This is the extra space for the initial size of the Win32-specific heap,\n * in bytes.  This value may be zero.\n */\n#ifndef SQLITE_WIN32_HEAP_INIT_EXTRA\n#  define SQLITE_WIN32_HEAP_INIT_EXTRA  (4194304)\n#endif\n\n/*\n * Calculate the maximum legal cache size, in pages, based on the maximum\n * possible initial heap size and the default page size, setting aside the\n * needed extra space.\n */\n#ifndef SQLITE_WIN32_MAX_CACHE_SIZE\n#  define SQLITE_WIN32_MAX_CACHE_SIZE   (((SQLITE_WIN32_HEAP_MAX_INIT_SIZE) - \\\n                                          (SQLITE_WIN32_HEAP_INIT_EXTRA)) / \\\n                                         (SQLITE_DEFAULT_PAGE_SIZE))\n#endif\n\n/*\n * This is cache size used in the calculation of the initial size of the\n * Win32-specific heap.  It cannot be negative.\n */\n#ifndef SQLITE_WIN32_CACHE_SIZE\n#  if SQLITE_DEFAULT_CACHE_SIZE>=0\n#    define SQLITE_WIN32_CACHE_SIZE     (SQLITE_DEFAULT_CACHE_SIZE)\n#  else\n#    define SQLITE_WIN32_CACHE_SIZE     (-(SQLITE_DEFAULT_CACHE_SIZE))\n#  endif\n#endif\n\n/*\n * Make sure that the calculated cache size, in pages, cannot cause the\n * initial size of the Win32-specific heap to exceed the maximum amount\n * of memory that can be specified in the call to HeapCreate.\n */\n#if SQLITE_WIN32_CACHE_SIZE>SQLITE_WIN32_MAX_CACHE_SIZE\n#  undef SQLITE_WIN32_CACHE_SIZE\n#  define SQLITE_WIN32_CACHE_SIZE       (2000)\n#endif\n\n/*\n * The initial size of the Win32-specific heap.  This value may be zero.\n */\n#ifndef SQLITE_WIN32_HEAP_INIT_SIZE\n#  define SQLITE_WIN32_HEAP_INIT_SIZE   ((SQLITE_WIN32_CACHE_SIZE) * \\\n                                         (SQLITE_DEFAULT_PAGE_SIZE) + \\\n                                         (SQLITE_WIN32_HEAP_INIT_EXTRA))\n#endif\n\n/*\n * The maximum size of the Win32-specific heap.  This value may be zero.\n */\n#ifndef SQLITE_WIN32_HEAP_MAX_SIZE\n#  define SQLITE_WIN32_HEAP_MAX_SIZE    (0)\n#endif\n\n/*\n * The extra flags to use in calls to the Win32 heap APIs.  This value may be\n * zero for the default behavior.\n */\n#ifndef SQLITE_WIN32_HEAP_FLAGS\n#  define SQLITE_WIN32_HEAP_FLAGS       (0)\n#endif\n\n\n/*\n** The winMemData structure stores information required by the Win32-specific\n** sqlite3_mem_methods implementation.\n*/\ntypedef struct winMemData winMemData;\nstruct winMemData {\n#ifndef NDEBUG\n  u32 magic1;   /* Magic number to detect structure corruption. */\n#endif\n  HANDLE hHeap; /* The handle to our heap. */\n  BOOL bOwned;  /* Do we own the heap (i.e. destroy it on shutdown)? */\n#ifndef NDEBUG\n  u32 magic2;   /* Magic number to detect structure corruption. */\n#endif\n};\n\n#ifndef NDEBUG\n#define WINMEM_MAGIC1     0x42b2830b\n#define WINMEM_MAGIC2     0xbd4d7cf4\n#endif\n\nstatic struct winMemData win_mem_data = {\n#ifndef NDEBUG\n  WINMEM_MAGIC1,\n#endif\n  NULL, FALSE\n#ifndef NDEBUG\n  ,WINMEM_MAGIC2\n#endif\n};\n\n#ifndef NDEBUG\n#define winMemAssertMagic1() assert( win_mem_data.magic1==WINMEM_MAGIC1 )\n#define winMemAssertMagic2() assert( win_mem_data.magic2==WINMEM_MAGIC2 )\n#define winMemAssertMagic()  winMemAssertMagic1(); winMemAssertMagic2();\n#else\n#define winMemAssertMagic()\n#endif\n\n#define winMemGetDataPtr()  &win_mem_data\n#define winMemGetHeap()     win_mem_data.hHeap\n#define winMemGetOwned()    win_mem_data.bOwned\n\nstatic void *winMemMalloc(int nBytes);\nstatic void winMemFree(void *pPrior);\nstatic void *winMemRealloc(void *pPrior, int nBytes);\nstatic int winMemSize(void *p);\nstatic int winMemRoundup(int n);\nstatic int winMemInit(void *pAppData);\nstatic void winMemShutdown(void *pAppData);\n\nSQLITE_PRIVATE const sqlite3_mem_methods *sqlite3MemGetWin32(void);\n#endif /* SQLITE_WIN32_MALLOC */\n\n/*\n** The following variable is (normally) set once and never changes\n** thereafter.  It records whether the operating system is Win9x\n** or WinNT.\n**\n** 0:   Operating system unknown.\n** 1:   Operating system is Win9x.\n** 2:   Operating system is WinNT.\n**\n** In order to facilitate testing on a WinNT system, the test fixture\n** can manually set this value to 1 to emulate Win98 behavior.\n*/\n#ifdef SQLITE_TEST\nSQLITE_API LONG SQLITE_WIN32_VOLATILE sqlite3_os_type = 0;\n#else\nstatic LONG SQLITE_WIN32_VOLATILE sqlite3_os_type = 0;\n#endif\n\n#ifndef SYSCALL\n#  define SYSCALL sqlite3_syscall_ptr\n#endif\n\n/*\n** This function is not available on Windows CE or WinRT.\n */\n\n#if SQLITE_OS_WINCE || SQLITE_OS_WINRT\n#  define osAreFileApisANSI()       1\n#endif\n\n/*\n** Many system calls are accessed through pointer-to-functions so that\n** they may be overridden at runtime to facilitate fault injection during\n** testing and sandboxing.  The following array holds the names and pointers\n** to all overrideable system calls.\n*/\nstatic struct win_syscall {\n  const char *zName;            /* Name of the system call */\n  sqlite3_syscall_ptr pCurrent; /* Current value of the system call */\n  sqlite3_syscall_ptr pDefault; /* Default value */\n} aSyscall[] = {\n#if !SQLITE_OS_WINCE && !SQLITE_OS_WINRT\n  { \"AreFileApisANSI\",         (SYSCALL)AreFileApisANSI,         0 },\n#else\n  { \"AreFileApisANSI\",         (SYSCALL)0,                       0 },\n#endif\n\n#ifndef osAreFileApisANSI\n#define osAreFileApisANSI ((BOOL(WINAPI*)(VOID))aSyscall[0].pCurrent)\n#endif\n\n#if SQLITE_OS_WINCE && defined(SQLITE_WIN32_HAS_WIDE)\n  { \"CharLowerW\",              (SYSCALL)CharLowerW,              0 },\n#else\n  { \"CharLowerW\",              (SYSCALL)0,                       0 },\n#endif\n\n#define osCharLowerW ((LPWSTR(WINAPI*)(LPWSTR))aSyscall[1].pCurrent)\n\n#if SQLITE_OS_WINCE && defined(SQLITE_WIN32_HAS_WIDE)\n  { \"CharUpperW\",              (SYSCALL)CharUpperW,              0 },\n#else\n  { \"CharUpperW\",              (SYSCALL)0,                       0 },\n#endif\n\n#define osCharUpperW ((LPWSTR(WINAPI*)(LPWSTR))aSyscall[2].pCurrent)\n\n  { \"CloseHandle\",             (SYSCALL)CloseHandle,             0 },\n\n#define osCloseHandle ((BOOL(WINAPI*)(HANDLE))aSyscall[3].pCurrent)\n\n#if defined(SQLITE_WIN32_HAS_ANSI)\n  { \"CreateFileA\",             (SYSCALL)CreateFileA,             0 },\n#else\n  { \"CreateFileA\",             (SYSCALL)0,                       0 },\n#endif\n\n#define osCreateFileA ((HANDLE(WINAPI*)(LPCSTR,DWORD,DWORD, \\\n        LPSECURITY_ATTRIBUTES,DWORD,DWORD,HANDLE))aSyscall[4].pCurrent)\n\n#if !SQLITE_OS_WINRT && defined(SQLITE_WIN32_HAS_WIDE)\n  { \"CreateFileW\",             (SYSCALL)CreateFileW,             0 },\n#else\n  { \"CreateFileW\",             (SYSCALL)0,                       0 },\n#endif\n\n#define osCreateFileW ((HANDLE(WINAPI*)(LPCWSTR,DWORD,DWORD, \\\n        LPSECURITY_ATTRIBUTES,DWORD,DWORD,HANDLE))aSyscall[5].pCurrent)\n\n#if !SQLITE_OS_WINRT && defined(SQLITE_WIN32_HAS_ANSI) && \\\n        (!defined(SQLITE_OMIT_WAL) || SQLITE_MAX_MMAP_SIZE>0) && \\\n        SQLITE_WIN32_CREATEFILEMAPPINGA\n  { \"CreateFileMappingA\",      (SYSCALL)CreateFileMappingA,      0 },\n#else\n  { \"CreateFileMappingA\",      (SYSCALL)0,                       0 },\n#endif\n\n#define osCreateFileMappingA ((HANDLE(WINAPI*)(HANDLE,LPSECURITY_ATTRIBUTES, \\\n        DWORD,DWORD,DWORD,LPCSTR))aSyscall[6].pCurrent)\n\n#if SQLITE_OS_WINCE || (!SQLITE_OS_WINRT && defined(SQLITE_WIN32_HAS_WIDE) && \\\n        (!defined(SQLITE_OMIT_WAL) || SQLITE_MAX_MMAP_SIZE>0))\n  { \"CreateFileMappingW\",      (SYSCALL)CreateFileMappingW,      0 },\n#else\n  { \"CreateFileMappingW\",      (SYSCALL)0,                       0 },\n#endif\n\n#define osCreateFileMappingW ((HANDLE(WINAPI*)(HANDLE,LPSECURITY_ATTRIBUTES, \\\n        DWORD,DWORD,DWORD,LPCWSTR))aSyscall[7].pCurrent)\n\n#if !SQLITE_OS_WINRT && defined(SQLITE_WIN32_HAS_WIDE)\n  { \"CreateMutexW\",            (SYSCALL)CreateMutexW,            0 },\n#else\n  { \"CreateMutexW\",            (SYSCALL)0,                       0 },\n#endif\n\n#define osCreateMutexW ((HANDLE(WINAPI*)(LPSECURITY_ATTRIBUTES,BOOL, \\\n        LPCWSTR))aSyscall[8].pCurrent)\n\n#if defined(SQLITE_WIN32_HAS_ANSI)\n  { \"DeleteFileA\",             (SYSCALL)DeleteFileA,             0 },\n#else\n  { \"DeleteFileA\",             (SYSCALL)0,                       0 },\n#endif\n\n#define osDeleteFileA ((BOOL(WINAPI*)(LPCSTR))aSyscall[9].pCurrent)\n\n#if defined(SQLITE_WIN32_HAS_WIDE)\n  { \"DeleteFileW\",             (SYSCALL)DeleteFileW,             0 },\n#else\n  { \"DeleteFileW\",             (SYSCALL)0,                       0 },\n#endif\n\n#define osDeleteFileW ((BOOL(WINAPI*)(LPCWSTR))aSyscall[10].pCurrent)\n\n#if SQLITE_OS_WINCE\n  { \"FileTimeToLocalFileTime\", (SYSCALL)FileTimeToLocalFileTime, 0 },\n#else\n  { \"FileTimeToLocalFileTime\", (SYSCALL)0,                       0 },\n#endif\n\n#define osFileTimeToLocalFileTime ((BOOL(WINAPI*)(CONST FILETIME*, \\\n        LPFILETIME))aSyscall[11].pCurrent)\n\n#if SQLITE_OS_WINCE\n  { \"FileTimeToSystemTime\",    (SYSCALL)FileTimeToSystemTime,    0 },\n#else\n  { \"FileTimeToSystemTime\",    (SYSCALL)0,                       0 },\n#endif\n\n#define osFileTimeToSystemTime ((BOOL(WINAPI*)(CONST FILETIME*, \\\n        LPSYSTEMTIME))aSyscall[12].pCurrent)\n\n  { \"FlushFileBuffers\",        (SYSCALL)FlushFileBuffers,        0 },\n\n#define osFlushFileBuffers ((BOOL(WINAPI*)(HANDLE))aSyscall[13].pCurrent)\n\n#if defined(SQLITE_WIN32_HAS_ANSI)\n  { \"FormatMessageA\",          (SYSCALL)FormatMessageA,          0 },\n#else\n  { \"FormatMessageA\",          (SYSCALL)0,                       0 },\n#endif\n\n#define osFormatMessageA ((DWORD(WINAPI*)(DWORD,LPCVOID,DWORD,DWORD,LPSTR, \\\n        DWORD,va_list*))aSyscall[14].pCurrent)\n\n#if defined(SQLITE_WIN32_HAS_WIDE)\n  { \"FormatMessageW\",          (SYSCALL)FormatMessageW,          0 },\n#else\n  { \"FormatMessageW\",          (SYSCALL)0,                       0 },\n#endif\n\n#define osFormatMessageW ((DWORD(WINAPI*)(DWORD,LPCVOID,DWORD,DWORD,LPWSTR, \\\n        DWORD,va_list*))aSyscall[15].pCurrent)\n\n#if !defined(SQLITE_OMIT_LOAD_EXTENSION)\n  { \"FreeLibrary\",             (SYSCALL)FreeLibrary,             0 },\n#else\n  { \"FreeLibrary\",             (SYSCALL)0,                       0 },\n#endif\n\n#define osFreeLibrary ((BOOL(WINAPI*)(HMODULE))aSyscall[16].pCurrent)\n\n  { \"GetCurrentProcessId\",     (SYSCALL)GetCurrentProcessId,     0 },\n\n#define osGetCurrentProcessId ((DWORD(WINAPI*)(VOID))aSyscall[17].pCurrent)\n\n#if !SQLITE_OS_WINCE && defined(SQLITE_WIN32_HAS_ANSI)\n  { \"GetDiskFreeSpaceA\",       (SYSCALL)GetDiskFreeSpaceA,       0 },\n#else\n  { \"GetDiskFreeSpaceA\",       (SYSCALL)0,                       0 },\n#endif\n\n#define osGetDiskFreeSpaceA ((BOOL(WINAPI*)(LPCSTR,LPDWORD,LPDWORD,LPDWORD, \\\n        LPDWORD))aSyscall[18].pCurrent)\n\n#if !SQLITE_OS_WINCE && !SQLITE_OS_WINRT && defined(SQLITE_WIN32_HAS_WIDE)\n  { \"GetDiskFreeSpaceW\",       (SYSCALL)GetDiskFreeSpaceW,       0 },\n#else\n  { \"GetDiskFreeSpaceW\",       (SYSCALL)0,                       0 },\n#endif\n\n#define osGetDiskFreeSpaceW ((BOOL(WINAPI*)(LPCWSTR,LPDWORD,LPDWORD,LPDWORD, \\\n        LPDWORD))aSyscall[19].pCurrent)\n\n#if defined(SQLITE_WIN32_HAS_ANSI)\n  { \"GetFileAttributesA\",      (SYSCALL)GetFileAttributesA,      0 },\n#else\n  { \"GetFileAttributesA\",      (SYSCALL)0,                       0 },\n#endif\n\n#define osGetFileAttributesA ((DWORD(WINAPI*)(LPCSTR))aSyscall[20].pCurrent)\n\n#if !SQLITE_OS_WINRT && defined(SQLITE_WIN32_HAS_WIDE)\n  { \"GetFileAttributesW\",      (SYSCALL)GetFileAttributesW,      0 },\n#else\n  { \"GetFileAttributesW\",      (SYSCALL)0,                       0 },\n#endif\n\n#define osGetFileAttributesW ((DWORD(WINAPI*)(LPCWSTR))aSyscall[21].pCurrent)\n\n#if defined(SQLITE_WIN32_HAS_WIDE)\n  { \"GetFileAttributesExW\",    (SYSCALL)GetFileAttributesExW,    0 },\n#else\n  { \"GetFileAttributesExW\",    (SYSCALL)0,                       0 },\n#endif\n\n#define osGetFileAttributesExW ((BOOL(WINAPI*)(LPCWSTR,GET_FILEEX_INFO_LEVELS, \\\n        LPVOID))aSyscall[22].pCurrent)\n\n#if !SQLITE_OS_WINRT\n  { \"GetFileSize\",             (SYSCALL)GetFileSize,             0 },\n#else\n  { \"GetFileSize\",             (SYSCALL)0,                       0 },\n#endif\n\n#define osGetFileSize ((DWORD(WINAPI*)(HANDLE,LPDWORD))aSyscall[23].pCurrent)\n\n#if !SQLITE_OS_WINCE && defined(SQLITE_WIN32_HAS_ANSI)\n  { \"GetFullPathNameA\",        (SYSCALL)GetFullPathNameA,        0 },\n#else\n  { \"GetFullPathNameA\",        (SYSCALL)0,                       0 },\n#endif\n\n#define osGetFullPathNameA ((DWORD(WINAPI*)(LPCSTR,DWORD,LPSTR, \\\n        LPSTR*))aSyscall[24].pCurrent)\n\n#if !SQLITE_OS_WINCE && !SQLITE_OS_WINRT && defined(SQLITE_WIN32_HAS_WIDE)\n  { \"GetFullPathNameW\",        (SYSCALL)GetFullPathNameW,        0 },\n#else\n  { \"GetFullPathNameW\",        (SYSCALL)0,                       0 },\n#endif\n\n#define osGetFullPathNameW ((DWORD(WINAPI*)(LPCWSTR,DWORD,LPWSTR, \\\n        LPWSTR*))aSyscall[25].pCurrent)\n\n  { \"GetLastError\",            (SYSCALL)GetLastError,            0 },\n\n#define osGetLastError ((DWORD(WINAPI*)(VOID))aSyscall[26].pCurrent)\n\n#if !defined(SQLITE_OMIT_LOAD_EXTENSION)\n#if SQLITE_OS_WINCE\n  /* The GetProcAddressA() routine is only available on Windows CE. */\n  { \"GetProcAddressA\",         (SYSCALL)GetProcAddressA,         0 },\n#else\n  /* All other Windows platforms expect GetProcAddress() to take\n  ** an ANSI string regardless of the _UNICODE setting */\n  { \"GetProcAddressA\",         (SYSCALL)GetProcAddress,          0 },\n#endif\n#else\n  { \"GetProcAddressA\",         (SYSCALL)0,                       0 },\n#endif\n\n#define osGetProcAddressA ((FARPROC(WINAPI*)(HMODULE, \\\n        LPCSTR))aSyscall[27].pCurrent)\n\n#if !SQLITE_OS_WINRT\n  { \"GetSystemInfo\",           (SYSCALL)GetSystemInfo,           0 },\n#else\n  { \"GetSystemInfo\",           (SYSCALL)0,                       0 },\n#endif\n\n#define osGetSystemInfo ((VOID(WINAPI*)(LPSYSTEM_INFO))aSyscall[28].pCurrent)\n\n  { \"GetSystemTime\",           (SYSCALL)GetSystemTime,           0 },\n\n#define osGetSystemTime ((VOID(WINAPI*)(LPSYSTEMTIME))aSyscall[29].pCurrent)\n\n#if !SQLITE_OS_WINCE\n  { \"GetSystemTimeAsFileTime\", (SYSCALL)GetSystemTimeAsFileTime, 0 },\n#else\n  { \"GetSystemTimeAsFileTime\", (SYSCALL)0,                       0 },\n#endif\n\n#define osGetSystemTimeAsFileTime ((VOID(WINAPI*)( \\\n        LPFILETIME))aSyscall[30].pCurrent)\n\n#if defined(SQLITE_WIN32_HAS_ANSI)\n  { \"GetTempPathA\",            (SYSCALL)GetTempPathA,            0 },\n#else\n  { \"GetTempPathA\",            (SYSCALL)0,                       0 },\n#endif\n\n#define osGetTempPathA ((DWORD(WINAPI*)(DWORD,LPSTR))aSyscall[31].pCurrent)\n\n#if !SQLITE_OS_WINRT && defined(SQLITE_WIN32_HAS_WIDE)\n  { \"GetTempPathW\",            (SYSCALL)GetTempPathW,            0 },\n#else\n  { \"GetTempPathW\",            (SYSCALL)0,                       0 },\n#endif\n\n#define osGetTempPathW ((DWORD(WINAPI*)(DWORD,LPWSTR))aSyscall[32].pCurrent)\n\n#if !SQLITE_OS_WINRT\n  { \"GetTickCount\",            (SYSCALL)GetTickCount,            0 },\n#else\n  { \"GetTickCount\",            (SYSCALL)0,                       0 },\n#endif\n\n#define osGetTickCount ((DWORD(WINAPI*)(VOID))aSyscall[33].pCurrent)\n\n#if defined(SQLITE_WIN32_HAS_ANSI) && SQLITE_WIN32_GETVERSIONEX\n  { \"GetVersionExA\",           (SYSCALL)GetVersionExA,           0 },\n#else\n  { \"GetVersionExA\",           (SYSCALL)0,                       0 },\n#endif\n\n#define osGetVersionExA ((BOOL(WINAPI*)( \\\n        LPOSVERSIONINFOA))aSyscall[34].pCurrent)\n\n#if !SQLITE_OS_WINRT && defined(SQLITE_WIN32_HAS_WIDE) && \\\n        SQLITE_WIN32_GETVERSIONEX\n  { \"GetVersionExW\",           (SYSCALL)GetVersionExW,           0 },\n#else\n  { \"GetVersionExW\",           (SYSCALL)0,                       0 },\n#endif\n\n#define osGetVersionExW ((BOOL(WINAPI*)( \\\n        LPOSVERSIONINFOW))aSyscall[35].pCurrent)\n\n  { \"HeapAlloc\",               (SYSCALL)HeapAlloc,               0 },\n\n#define osHeapAlloc ((LPVOID(WINAPI*)(HANDLE,DWORD, \\\n        SIZE_T))aSyscall[36].pCurrent)\n\n#if !SQLITE_OS_WINRT\n  { \"HeapCreate\",              (SYSCALL)HeapCreate,              0 },\n#else\n  { \"HeapCreate\",              (SYSCALL)0,                       0 },\n#endif\n\n#define osHeapCreate ((HANDLE(WINAPI*)(DWORD,SIZE_T, \\\n        SIZE_T))aSyscall[37].pCurrent)\n\n#if !SQLITE_OS_WINRT\n  { \"HeapDestroy\",             (SYSCALL)HeapDestroy,             0 },\n#else\n  { \"HeapDestroy\",             (SYSCALL)0,                       0 },\n#endif\n\n#define osHeapDestroy ((BOOL(WINAPI*)(HANDLE))aSyscall[38].pCurrent)\n\n  { \"HeapFree\",                (SYSCALL)HeapFree,                0 },\n\n#define osHeapFree ((BOOL(WINAPI*)(HANDLE,DWORD,LPVOID))aSyscall[39].pCurrent)\n\n  { \"HeapReAlloc\",             (SYSCALL)HeapReAlloc,             0 },\n\n#define osHeapReAlloc ((LPVOID(WINAPI*)(HANDLE,DWORD,LPVOID, \\\n        SIZE_T))aSyscall[40].pCurrent)\n\n  { \"HeapSize\",                (SYSCALL)HeapSize,                0 },\n\n#define osHeapSize ((SIZE_T(WINAPI*)(HANDLE,DWORD, \\\n        LPCVOID))aSyscall[41].pCurrent)\n\n#if !SQLITE_OS_WINRT\n  { \"HeapValidate\",            (SYSCALL)HeapValidate,            0 },\n#else\n  { \"HeapValidate\",            (SYSCALL)0,                       0 },\n#endif\n\n#define osHeapValidate ((BOOL(WINAPI*)(HANDLE,DWORD, \\\n        LPCVOID))aSyscall[42].pCurrent)\n\n#if !SQLITE_OS_WINCE && !SQLITE_OS_WINRT\n  { \"HeapCompact\",             (SYSCALL)HeapCompact,             0 },\n#else\n  { \"HeapCompact\",             (SYSCALL)0,                       0 },\n#endif\n\n#define osHeapCompact ((UINT(WINAPI*)(HANDLE,DWORD))aSyscall[43].pCurrent)\n\n#if defined(SQLITE_WIN32_HAS_ANSI) && !defined(SQLITE_OMIT_LOAD_EXTENSION)\n  { \"LoadLibraryA\",            (SYSCALL)LoadLibraryA,            0 },\n#else\n  { \"LoadLibraryA\",            (SYSCALL)0,                       0 },\n#endif\n\n#define osLoadLibraryA ((HMODULE(WINAPI*)(LPCSTR))aSyscall[44].pCurrent)\n\n#if !SQLITE_OS_WINRT && defined(SQLITE_WIN32_HAS_WIDE) && \\\n        !defined(SQLITE_OMIT_LOAD_EXTENSION)\n  { \"LoadLibraryW\",            (SYSCALL)LoadLibraryW,            0 },\n#else\n  { \"LoadLibraryW\",            (SYSCALL)0,                       0 },\n#endif\n\n#define osLoadLibraryW ((HMODULE(WINAPI*)(LPCWSTR))aSyscall[45].pCurrent)\n\n#if !SQLITE_OS_WINRT\n  { \"LocalFree\",               (SYSCALL)LocalFree,               0 },\n#else\n  { \"LocalFree\",               (SYSCALL)0,                       0 },\n#endif\n\n#define osLocalFree ((HLOCAL(WINAPI*)(HLOCAL))aSyscall[46].pCurrent)\n\n#if !SQLITE_OS_WINCE && !SQLITE_OS_WINRT\n  { \"LockFile\",                (SYSCALL)LockFile,                0 },\n#else\n  { \"LockFile\",                (SYSCALL)0,                       0 },\n#endif\n\n#ifndef osLockFile\n#define osLockFile ((BOOL(WINAPI*)(HANDLE,DWORD,DWORD,DWORD, \\\n        DWORD))aSyscall[47].pCurrent)\n#endif\n\n#if !SQLITE_OS_WINCE\n  { \"LockFileEx\",              (SYSCALL)LockFileEx,              0 },\n#else\n  { \"LockFileEx\",              (SYSCALL)0,                       0 },\n#endif\n\n#ifndef osLockFileEx\n#define osLockFileEx ((BOOL(WINAPI*)(HANDLE,DWORD,DWORD,DWORD,DWORD, \\\n        LPOVERLAPPED))aSyscall[48].pCurrent)\n#endif\n\n#if SQLITE_OS_WINCE || (!SQLITE_OS_WINRT && \\\n        (!defined(SQLITE_OMIT_WAL) || SQLITE_MAX_MMAP_SIZE>0))\n  { \"MapViewOfFile\",           (SYSCALL)MapViewOfFile,           0 },\n#else\n  { \"MapViewOfFile\",           (SYSCALL)0,                       0 },\n#endif\n\n#define osMapViewOfFile ((LPVOID(WINAPI*)(HANDLE,DWORD,DWORD,DWORD, \\\n        SIZE_T))aSyscall[49].pCurrent)\n\n  { \"MultiByteToWideChar\",     (SYSCALL)MultiByteToWideChar,     0 },\n\n#define osMultiByteToWideChar ((int(WINAPI*)(UINT,DWORD,LPCSTR,int,LPWSTR, \\\n        int))aSyscall[50].pCurrent)\n\n  { \"QueryPerformanceCounter\", (SYSCALL)QueryPerformanceCounter, 0 },\n\n#define osQueryPerformanceCounter ((BOOL(WINAPI*)( \\\n        LARGE_INTEGER*))aSyscall[51].pCurrent)\n\n  { \"ReadFile\",                (SYSCALL)ReadFile,                0 },\n\n#define osReadFile ((BOOL(WINAPI*)(HANDLE,LPVOID,DWORD,LPDWORD, \\\n        LPOVERLAPPED))aSyscall[52].pCurrent)\n\n  { \"SetEndOfFile\",            (SYSCALL)SetEndOfFile,            0 },\n\n#define osSetEndOfFile ((BOOL(WINAPI*)(HANDLE))aSyscall[53].pCurrent)\n\n#if !SQLITE_OS_WINRT\n  { \"SetFilePointer\",          (SYSCALL)SetFilePointer,          0 },\n#else\n  { \"SetFilePointer\",          (SYSCALL)0,                       0 },\n#endif\n\n#define osSetFilePointer ((DWORD(WINAPI*)(HANDLE,LONG,PLONG, \\\n        DWORD))aSyscall[54].pCurrent)\n\n#if !SQLITE_OS_WINRT\n  { \"Sleep\",                   (SYSCALL)Sleep,                   0 },\n#else\n  { \"Sleep\",                   (SYSCALL)0,                       0 },\n#endif\n\n#define osSleep ((VOID(WINAPI*)(DWORD))aSyscall[55].pCurrent)\n\n  { \"SystemTimeToFileTime\",    (SYSCALL)SystemTimeToFileTime,    0 },\n\n#define osSystemTimeToFileTime ((BOOL(WINAPI*)(CONST SYSTEMTIME*, \\\n        LPFILETIME))aSyscall[56].pCurrent)\n\n#if !SQLITE_OS_WINCE && !SQLITE_OS_WINRT\n  { \"UnlockFile\",              (SYSCALL)UnlockFile,              0 },\n#else\n  { \"UnlockFile\",              (SYSCALL)0,                       0 },\n#endif\n\n#ifndef osUnlockFile\n#define osUnlockFile ((BOOL(WINAPI*)(HANDLE,DWORD,DWORD,DWORD, \\\n        DWORD))aSyscall[57].pCurrent)\n#endif\n\n#if !SQLITE_OS_WINCE\n  { \"UnlockFileEx\",            (SYSCALL)UnlockFileEx,            0 },\n#else\n  { \"UnlockFileEx\",            (SYSCALL)0,                       0 },\n#endif\n\n#define osUnlockFileEx ((BOOL(WINAPI*)(HANDLE,DWORD,DWORD,DWORD, \\\n        LPOVERLAPPED))aSyscall[58].pCurrent)\n\n#if SQLITE_OS_WINCE || !defined(SQLITE_OMIT_WAL) || SQLITE_MAX_MMAP_SIZE>0\n  { \"UnmapViewOfFile\",         (SYSCALL)UnmapViewOfFile,         0 },\n#else\n  { \"UnmapViewOfFile\",         (SYSCALL)0,                       0 },\n#endif\n\n#define osUnmapViewOfFile ((BOOL(WINAPI*)(LPCVOID))aSyscall[59].pCurrent)\n\n  { \"WideCharToMultiByte\",     (SYSCALL)WideCharToMultiByte,     0 },\n\n#define osWideCharToMultiByte ((int(WINAPI*)(UINT,DWORD,LPCWSTR,int,LPSTR,int, \\\n        LPCSTR,LPBOOL))aSyscall[60].pCurrent)\n\n  { \"WriteFile\",               (SYSCALL)WriteFile,               0 },\n\n#define osWriteFile ((BOOL(WINAPI*)(HANDLE,LPCVOID,DWORD,LPDWORD, \\\n        LPOVERLAPPED))aSyscall[61].pCurrent)\n\n#if SQLITE_OS_WINRT\n  { \"CreateEventExW\",          (SYSCALL)CreateEventExW,          0 },\n#else\n  { \"CreateEventExW\",          (SYSCALL)0,                       0 },\n#endif\n\n#define osCreateEventExW ((HANDLE(WINAPI*)(LPSECURITY_ATTRIBUTES,LPCWSTR, \\\n        DWORD,DWORD))aSyscall[62].pCurrent)\n\n#if !SQLITE_OS_WINRT\n  { \"WaitForSingleObject\",     (SYSCALL)WaitForSingleObject,     0 },\n#else\n  { \"WaitForSingleObject\",     (SYSCALL)0,                       0 },\n#endif\n\n#define osWaitForSingleObject ((DWORD(WINAPI*)(HANDLE, \\\n        DWORD))aSyscall[63].pCurrent)\n\n#if !SQLITE_OS_WINCE\n  { \"WaitForSingleObjectEx\",   (SYSCALL)WaitForSingleObjectEx,   0 },\n#else\n  { \"WaitForSingleObjectEx\",   (SYSCALL)0,                       0 },\n#endif\n\n#define osWaitForSingleObjectEx ((DWORD(WINAPI*)(HANDLE,DWORD, \\\n        BOOL))aSyscall[64].pCurrent)\n\n#if SQLITE_OS_WINRT\n  { \"SetFilePointerEx\",        (SYSCALL)SetFilePointerEx,        0 },\n#else\n  { \"SetFilePointerEx\",        (SYSCALL)0,                       0 },\n#endif\n\n#define osSetFilePointerEx ((BOOL(WINAPI*)(HANDLE,LARGE_INTEGER, \\\n        PLARGE_INTEGER,DWORD))aSyscall[65].pCurrent)\n\n#if SQLITE_OS_WINRT\n  { \"GetFileInformationByHandleEx\", (SYSCALL)GetFileInformationByHandleEx, 0 },\n#else\n  { \"GetFileInformationByHandleEx\", (SYSCALL)0,                  0 },\n#endif\n\n#define osGetFileInformationByHandleEx ((BOOL(WINAPI*)(HANDLE, \\\n        FILE_INFO_BY_HANDLE_CLASS,LPVOID,DWORD))aSyscall[66].pCurrent)\n\n#if SQLITE_OS_WINRT && (!defined(SQLITE_OMIT_WAL) || SQLITE_MAX_MMAP_SIZE>0)\n  { \"MapViewOfFileFromApp\",    (SYSCALL)MapViewOfFileFromApp,    0 },\n#else\n  { \"MapViewOfFileFromApp\",    (SYSCALL)0,                       0 },\n#endif\n\n#define osMapViewOfFileFromApp ((LPVOID(WINAPI*)(HANDLE,ULONG,ULONG64, \\\n        SIZE_T))aSyscall[67].pCurrent)\n\n#if SQLITE_OS_WINRT\n  { \"CreateFile2\",             (SYSCALL)CreateFile2,             0 },\n#else\n  { \"CreateFile2\",             (SYSCALL)0,                       0 },\n#endif\n\n#define osCreateFile2 ((HANDLE(WINAPI*)(LPCWSTR,DWORD,DWORD,DWORD, \\\n        LPCREATEFILE2_EXTENDED_PARAMETERS))aSyscall[68].pCurrent)\n\n#if SQLITE_OS_WINRT && !defined(SQLITE_OMIT_LOAD_EXTENSION)\n  { \"LoadPackagedLibrary\",     (SYSCALL)LoadPackagedLibrary,     0 },\n#else\n  { \"LoadPackagedLibrary\",     (SYSCALL)0,                       0 },\n#endif\n\n#define osLoadPackagedLibrary ((HMODULE(WINAPI*)(LPCWSTR, \\\n        DWORD))aSyscall[69].pCurrent)\n\n#if SQLITE_OS_WINRT\n  { \"GetTickCount64\",          (SYSCALL)GetTickCount64,          0 },\n#else\n  { \"GetTickCount64\",          (SYSCALL)0,                       0 },\n#endif\n\n#define osGetTickCount64 ((ULONGLONG(WINAPI*)(VOID))aSyscall[70].pCurrent)\n\n#if SQLITE_OS_WINRT\n  { \"GetNativeSystemInfo\",     (SYSCALL)GetNativeSystemInfo,     0 },\n#else\n  { \"GetNativeSystemInfo\",     (SYSCALL)0,                       0 },\n#endif\n\n#define osGetNativeSystemInfo ((VOID(WINAPI*)( \\\n        LPSYSTEM_INFO))aSyscall[71].pCurrent)\n\n#if defined(SQLITE_WIN32_HAS_ANSI)\n  { \"OutputDebugStringA\",      (SYSCALL)OutputDebugStringA,      0 },\n#else\n  { \"OutputDebugStringA\",      (SYSCALL)0,                       0 },\n#endif\n\n#define osOutputDebugStringA ((VOID(WINAPI*)(LPCSTR))aSyscall[72].pCurrent)\n\n#if defined(SQLITE_WIN32_HAS_WIDE)\n  { \"OutputDebugStringW\",      (SYSCALL)OutputDebugStringW,      0 },\n#else\n  { \"OutputDebugStringW\",      (SYSCALL)0,                       0 },\n#endif\n\n#define osOutputDebugStringW ((VOID(WINAPI*)(LPCWSTR))aSyscall[73].pCurrent)\n\n  { \"GetProcessHeap\",          (SYSCALL)GetProcessHeap,          0 },\n\n#define osGetProcessHeap ((HANDLE(WINAPI*)(VOID))aSyscall[74].pCurrent)\n\n#if SQLITE_OS_WINRT && (!defined(SQLITE_OMIT_WAL) || SQLITE_MAX_MMAP_SIZE>0)\n  { \"CreateFileMappingFromApp\", (SYSCALL)CreateFileMappingFromApp, 0 },\n#else\n  { \"CreateFileMappingFromApp\", (SYSCALL)0,                      0 },\n#endif\n\n#define osCreateFileMappingFromApp ((HANDLE(WINAPI*)(HANDLE, \\\n        LPSECURITY_ATTRIBUTES,ULONG,ULONG64,LPCWSTR))aSyscall[75].pCurrent)\n\n/*\n** NOTE: On some sub-platforms, the InterlockedCompareExchange \"function\"\n**       is really just a macro that uses a compiler intrinsic (e.g. x64).\n**       So do not try to make this is into a redefinable interface.\n*/\n#if defined(InterlockedCompareExchange)\n  { \"InterlockedCompareExchange\", (SYSCALL)0,                    0 },\n\n#define osInterlockedCompareExchange InterlockedCompareExchange\n#else\n  { \"InterlockedCompareExchange\", (SYSCALL)InterlockedCompareExchange, 0 },\n\n#define osInterlockedCompareExchange ((LONG(WINAPI*)(LONG \\\n        SQLITE_WIN32_VOLATILE*, LONG,LONG))aSyscall[76].pCurrent)\n#endif /* defined(InterlockedCompareExchange) */\n\n#if !SQLITE_OS_WINCE && !SQLITE_OS_WINRT && SQLITE_WIN32_USE_UUID\n  { \"UuidCreate\",               (SYSCALL)UuidCreate,             0 },\n#else\n  { \"UuidCreate\",               (SYSCALL)0,                      0 },\n#endif\n\n#define osUuidCreate ((RPC_STATUS(RPC_ENTRY*)(UUID*))aSyscall[77].pCurrent)\n\n#if !SQLITE_OS_WINCE && !SQLITE_OS_WINRT && SQLITE_WIN32_USE_UUID\n  { \"UuidCreateSequential\",     (SYSCALL)UuidCreateSequential,   0 },\n#else\n  { \"UuidCreateSequential\",     (SYSCALL)0,                      0 },\n#endif\n\n#define osUuidCreateSequential \\\n        ((RPC_STATUS(RPC_ENTRY*)(UUID*))aSyscall[78].pCurrent)\n\n#if !defined(SQLITE_NO_SYNC) && SQLITE_MAX_MMAP_SIZE>0\n  { \"FlushViewOfFile\",          (SYSCALL)FlushViewOfFile,        0 },\n#else\n  { \"FlushViewOfFile\",          (SYSCALL)0,                      0 },\n#endif\n\n#define osFlushViewOfFile \\\n        ((BOOL(WINAPI*)(LPCVOID,SIZE_T))aSyscall[79].pCurrent)\n\n}; /* End of the overrideable system calls */\n\n/*\n** This is the xSetSystemCall() method of sqlite3_vfs for all of the\n** \"win32\" VFSes.  Return SQLITE_OK opon successfully updating the\n** system call pointer, or SQLITE_NOTFOUND if there is no configurable\n** system call named zName.\n*/\nstatic int winSetSystemCall(\n  sqlite3_vfs *pNotUsed,        /* The VFS pointer.  Not used */\n  const char *zName,            /* Name of system call to override */\n  sqlite3_syscall_ptr pNewFunc  /* Pointer to new system call value */\n){\n  unsigned int i;\n  int rc = SQLITE_NOTFOUND;\n\n  UNUSED_PARAMETER(pNotUsed);\n  if( zName==0 ){\n    /* If no zName is given, restore all system calls to their default\n    ** settings and return NULL\n    */\n    rc = SQLITE_OK;\n    for(i=0; i<sizeof(aSyscall)/sizeof(aSyscall[0]); i++){\n      if( aSyscall[i].pDefault ){\n        aSyscall[i].pCurrent = aSyscall[i].pDefault;\n      }\n    }\n  }else{\n    /* If zName is specified, operate on only the one system call\n    ** specified.\n    */\n    for(i=0; i<sizeof(aSyscall)/sizeof(aSyscall[0]); i++){\n      if( strcmp(zName, aSyscall[i].zName)==0 ){\n        if( aSyscall[i].pDefault==0 ){\n          aSyscall[i].pDefault = aSyscall[i].pCurrent;\n        }\n        rc = SQLITE_OK;\n        if( pNewFunc==0 ) pNewFunc = aSyscall[i].pDefault;\n        aSyscall[i].pCurrent = pNewFunc;\n        break;\n      }\n    }\n  }\n  return rc;\n}\n\n/*\n** Return the value of a system call.  Return NULL if zName is not a\n** recognized system call name.  NULL is also returned if the system call\n** is currently undefined.\n*/\nstatic sqlite3_syscall_ptr winGetSystemCall(\n  sqlite3_vfs *pNotUsed,\n  const char *zName\n){\n  unsigned int i;\n\n  UNUSED_PARAMETER(pNotUsed);\n  for(i=0; i<sizeof(aSyscall)/sizeof(aSyscall[0]); i++){\n    if( strcmp(zName, aSyscall[i].zName)==0 ) return aSyscall[i].pCurrent;\n  }\n  return 0;\n}\n\n/*\n** Return the name of the first system call after zName.  If zName==NULL\n** then return the name of the first system call.  Return NULL if zName\n** is the last system call or if zName is not the name of a valid\n** system call.\n*/\nstatic const char *winNextSystemCall(sqlite3_vfs *p, const char *zName){\n  int i = -1;\n\n  UNUSED_PARAMETER(p);\n  if( zName ){\n    for(i=0; i<ArraySize(aSyscall)-1; i++){\n      if( strcmp(zName, aSyscall[i].zName)==0 ) break;\n    }\n  }\n  for(i++; i<ArraySize(aSyscall); i++){\n    if( aSyscall[i].pCurrent!=0 ) return aSyscall[i].zName;\n  }\n  return 0;\n}\n\n#ifdef SQLITE_WIN32_MALLOC\n/*\n** If a Win32 native heap has been configured, this function will attempt to\n** compact it.  Upon success, SQLITE_OK will be returned.  Upon failure, one\n** of SQLITE_NOMEM, SQLITE_ERROR, or SQLITE_NOTFOUND will be returned.  The\n** \"pnLargest\" argument, if non-zero, will be used to return the size of the\n** largest committed free block in the heap, in bytes.\n*/\nSQLITE_API int sqlite3_win32_compact_heap(LPUINT pnLargest){\n  int rc = SQLITE_OK;\n  UINT nLargest = 0;\n  HANDLE hHeap;\n\n  winMemAssertMagic();\n  hHeap = winMemGetHeap();\n  assert( hHeap!=0 );\n  assert( hHeap!=INVALID_HANDLE_VALUE );\n#if !SQLITE_OS_WINRT && defined(SQLITE_WIN32_MALLOC_VALIDATE)\n  assert( osHeapValidate(hHeap, SQLITE_WIN32_HEAP_FLAGS, NULL) );\n#endif\n#if !SQLITE_OS_WINCE && !SQLITE_OS_WINRT\n  if( (nLargest=osHeapCompact(hHeap, SQLITE_WIN32_HEAP_FLAGS))==0 ){\n    DWORD lastErrno = osGetLastError();\n    if( lastErrno==NO_ERROR ){\n      sqlite3_log(SQLITE_NOMEM, \"failed to HeapCompact (no space), heap=%p\",\n                  (void*)hHeap);\n      rc = SQLITE_NOMEM_BKPT;\n    }else{\n      sqlite3_log(SQLITE_ERROR, \"failed to HeapCompact (%lu), heap=%p\",\n                  osGetLastError(), (void*)hHeap);\n      rc = SQLITE_ERROR;\n    }\n  }\n#else\n  sqlite3_log(SQLITE_NOTFOUND, \"failed to HeapCompact, heap=%p\",\n              (void*)hHeap);\n  rc = SQLITE_NOTFOUND;\n#endif\n  if( pnLargest ) *pnLargest = nLargest;\n  return rc;\n}\n\n/*\n** If a Win32 native heap has been configured, this function will attempt to\n** destroy and recreate it.  If the Win32 native heap is not isolated and/or\n** the sqlite3_memory_used() function does not return zero, SQLITE_BUSY will\n** be returned and no changes will be made to the Win32 native heap.\n*/\nSQLITE_API int sqlite3_win32_reset_heap(){\n  int rc;\n  MUTEX_LOGIC( sqlite3_mutex *pMaster; ) /* The main static mutex */\n  MUTEX_LOGIC( sqlite3_mutex *pMem; )    /* The memsys static mutex */\n  MUTEX_LOGIC( pMaster = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER); )\n  MUTEX_LOGIC( pMem = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MEM); )\n  sqlite3_mutex_enter(pMaster);\n  sqlite3_mutex_enter(pMem);\n  winMemAssertMagic();\n  if( winMemGetHeap()!=NULL && winMemGetOwned() && sqlite3_memory_used()==0 ){\n    /*\n    ** At this point, there should be no outstanding memory allocations on\n    ** the heap.  Also, since both the master and memsys locks are currently\n    ** being held by us, no other function (i.e. from another thread) should\n    ** be able to even access the heap.  Attempt to destroy and recreate our\n    ** isolated Win32 native heap now.\n    */\n    assert( winMemGetHeap()!=NULL );\n    assert( winMemGetOwned() );\n    assert( sqlite3_memory_used()==0 );\n    winMemShutdown(winMemGetDataPtr());\n    assert( winMemGetHeap()==NULL );\n    assert( !winMemGetOwned() );\n    assert( sqlite3_memory_used()==0 );\n    rc = winMemInit(winMemGetDataPtr());\n    assert( rc!=SQLITE_OK || winMemGetHeap()!=NULL );\n    assert( rc!=SQLITE_OK || winMemGetOwned() );\n    assert( rc!=SQLITE_OK || sqlite3_memory_used()==0 );\n  }else{\n    /*\n    ** The Win32 native heap cannot be modified because it may be in use.\n    */\n    rc = SQLITE_BUSY;\n  }\n  sqlite3_mutex_leave(pMem);\n  sqlite3_mutex_leave(pMaster);\n  return rc;\n}\n#endif /* SQLITE_WIN32_MALLOC */\n\n/*\n** This function outputs the specified (ANSI) string to the Win32 debugger\n** (if available).\n*/\n\nSQLITE_API void sqlite3_win32_write_debug(const char *zBuf, int nBuf){\n  char zDbgBuf[SQLITE_WIN32_DBG_BUF_SIZE];\n  int nMin = MIN(nBuf, (SQLITE_WIN32_DBG_BUF_SIZE - 1)); /* may be negative. */\n  if( nMin<-1 ) nMin = -1; /* all negative values become -1. */\n  assert( nMin==-1 || nMin==0 || nMin<SQLITE_WIN32_DBG_BUF_SIZE );\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( !zBuf ){\n    (void)SQLITE_MISUSE_BKPT;\n    return;\n  }\n#endif\n#if defined(SQLITE_WIN32_HAS_ANSI)\n  if( nMin>0 ){\n    memset(zDbgBuf, 0, SQLITE_WIN32_DBG_BUF_SIZE);\n    memcpy(zDbgBuf, zBuf, nMin);\n    osOutputDebugStringA(zDbgBuf);\n  }else{\n    osOutputDebugStringA(zBuf);\n  }\n#elif defined(SQLITE_WIN32_HAS_WIDE)\n  memset(zDbgBuf, 0, SQLITE_WIN32_DBG_BUF_SIZE);\n  if ( osMultiByteToWideChar(\n          osAreFileApisANSI() ? CP_ACP : CP_OEMCP, 0, zBuf,\n          nMin, (LPWSTR)zDbgBuf, SQLITE_WIN32_DBG_BUF_SIZE/sizeof(WCHAR))<=0 ){\n    return;\n  }\n  osOutputDebugStringW((LPCWSTR)zDbgBuf);\n#else\n  if( nMin>0 ){\n    memset(zDbgBuf, 0, SQLITE_WIN32_DBG_BUF_SIZE);\n    memcpy(zDbgBuf, zBuf, nMin);\n    fprintf(stderr, \"%s\", zDbgBuf);\n  }else{\n    fprintf(stderr, \"%s\", zBuf);\n  }\n#endif\n}\n\n/*\n** The following routine suspends the current thread for at least ms\n** milliseconds.  This is equivalent to the Win32 Sleep() interface.\n*/\n#if SQLITE_OS_WINRT\nstatic HANDLE sleepObj = NULL;\n#endif\n\nSQLITE_API void sqlite3_win32_sleep(DWORD milliseconds){\n#if SQLITE_OS_WINRT\n  if ( sleepObj==NULL ){\n    sleepObj = osCreateEventExW(NULL, NULL, CREATE_EVENT_MANUAL_RESET,\n                                SYNCHRONIZE);\n  }\n  assert( sleepObj!=NULL );\n  osWaitForSingleObjectEx(sleepObj, milliseconds, FALSE);\n#else\n  osSleep(milliseconds);\n#endif\n}\n\n#if SQLITE_MAX_WORKER_THREADS>0 && !SQLITE_OS_WINCE && !SQLITE_OS_WINRT && \\\n        SQLITE_THREADSAFE>0\nSQLITE_PRIVATE DWORD sqlite3Win32Wait(HANDLE hObject){\n  DWORD rc;\n  while( (rc = osWaitForSingleObjectEx(hObject, INFINITE,\n                                       TRUE))==WAIT_IO_COMPLETION ){}\n  return rc;\n}\n#endif\n\n/*\n** Return true (non-zero) if we are running under WinNT, Win2K, WinXP,\n** or WinCE.  Return false (zero) for Win95, Win98, or WinME.\n**\n** Here is an interesting observation:  Win95, Win98, and WinME lack\n** the LockFileEx() API.  But we can still statically link against that\n** API as long as we don't call it when running Win95/98/ME.  A call to\n** this routine is used to determine if the host is Win95/98/ME or\n** WinNT/2K/XP so that we will know whether or not we can safely call\n** the LockFileEx() API.\n*/\n\n#if !SQLITE_WIN32_GETVERSIONEX\n# define osIsNT()  (1)\n#elif SQLITE_OS_WINCE || SQLITE_OS_WINRT || !defined(SQLITE_WIN32_HAS_ANSI)\n# define osIsNT()  (1)\n#elif !defined(SQLITE_WIN32_HAS_WIDE)\n# define osIsNT()  (0)\n#else\n# define osIsNT()  ((sqlite3_os_type==2) || sqlite3_win32_is_nt())\n#endif\n\n/*\n** This function determines if the machine is running a version of Windows\n** based on the NT kernel.\n*/\nSQLITE_API int sqlite3_win32_is_nt(void){\n#if SQLITE_OS_WINRT\n  /*\n  ** NOTE: The WinRT sub-platform is always assumed to be based on the NT\n  **       kernel.\n  */\n  return 1;\n#elif SQLITE_WIN32_GETVERSIONEX\n  if( osInterlockedCompareExchange(&sqlite3_os_type, 0, 0)==0 ){\n#if defined(SQLITE_WIN32_HAS_ANSI)\n    OSVERSIONINFOA sInfo;\n    sInfo.dwOSVersionInfoSize = sizeof(sInfo);\n    osGetVersionExA(&sInfo);\n    osInterlockedCompareExchange(&sqlite3_os_type,\n        (sInfo.dwPlatformId == VER_PLATFORM_WIN32_NT) ? 2 : 1, 0);\n#elif defined(SQLITE_WIN32_HAS_WIDE)\n    OSVERSIONINFOW sInfo;\n    sInfo.dwOSVersionInfoSize = sizeof(sInfo);\n    osGetVersionExW(&sInfo);\n    osInterlockedCompareExchange(&sqlite3_os_type,\n        (sInfo.dwPlatformId == VER_PLATFORM_WIN32_NT) ? 2 : 1, 0);\n#endif\n  }\n  return osInterlockedCompareExchange(&sqlite3_os_type, 2, 2)==2;\n#elif SQLITE_TEST\n  return osInterlockedCompareExchange(&sqlite3_os_type, 2, 2)==2;\n#else\n  /*\n  ** NOTE: All sub-platforms where the GetVersionEx[AW] functions are\n  **       deprecated are always assumed to be based on the NT kernel.\n  */\n  return 1;\n#endif\n}\n\n#ifdef SQLITE_WIN32_MALLOC\n/*\n** Allocate nBytes of memory.\n*/\nstatic void *winMemMalloc(int nBytes){\n  HANDLE hHeap;\n  void *p;\n\n  winMemAssertMagic();\n  hHeap = winMemGetHeap();\n  assert( hHeap!=0 );\n  assert( hHeap!=INVALID_HANDLE_VALUE );\n#if !SQLITE_OS_WINRT && defined(SQLITE_WIN32_MALLOC_VALIDATE)\n  assert( osHeapValidate(hHeap, SQLITE_WIN32_HEAP_FLAGS, NULL) );\n#endif\n  assert( nBytes>=0 );\n  p = osHeapAlloc(hHeap, SQLITE_WIN32_HEAP_FLAGS, (SIZE_T)nBytes);\n  if( !p ){\n    sqlite3_log(SQLITE_NOMEM, \"failed to HeapAlloc %u bytes (%lu), heap=%p\",\n                nBytes, osGetLastError(), (void*)hHeap);\n  }\n  return p;\n}\n\n/*\n** Free memory.\n*/\nstatic void winMemFree(void *pPrior){\n  HANDLE hHeap;\n\n  winMemAssertMagic();\n  hHeap = winMemGetHeap();\n  assert( hHeap!=0 );\n  assert( hHeap!=INVALID_HANDLE_VALUE );\n#if !SQLITE_OS_WINRT && defined(SQLITE_WIN32_MALLOC_VALIDATE)\n  assert( osHeapValidate(hHeap, SQLITE_WIN32_HEAP_FLAGS, pPrior) );\n#endif\n  if( !pPrior ) return; /* Passing NULL to HeapFree is undefined. */\n  if( !osHeapFree(hHeap, SQLITE_WIN32_HEAP_FLAGS, pPrior) ){\n    sqlite3_log(SQLITE_NOMEM, \"failed to HeapFree block %p (%lu), heap=%p\",\n                pPrior, osGetLastError(), (void*)hHeap);\n  }\n}\n\n/*\n** Change the size of an existing memory allocation\n*/\nstatic void *winMemRealloc(void *pPrior, int nBytes){\n  HANDLE hHeap;\n  void *p;\n\n  winMemAssertMagic();\n  hHeap = winMemGetHeap();\n  assert( hHeap!=0 );\n  assert( hHeap!=INVALID_HANDLE_VALUE );\n#if !SQLITE_OS_WINRT && defined(SQLITE_WIN32_MALLOC_VALIDATE)\n  assert( osHeapValidate(hHeap, SQLITE_WIN32_HEAP_FLAGS, pPrior) );\n#endif\n  assert( nBytes>=0 );\n  if( !pPrior ){\n    p = osHeapAlloc(hHeap, SQLITE_WIN32_HEAP_FLAGS, (SIZE_T)nBytes);\n  }else{\n    p = osHeapReAlloc(hHeap, SQLITE_WIN32_HEAP_FLAGS, pPrior, (SIZE_T)nBytes);\n  }\n  if( !p ){\n    sqlite3_log(SQLITE_NOMEM, \"failed to %s %u bytes (%lu), heap=%p\",\n                pPrior ? \"HeapReAlloc\" : \"HeapAlloc\", nBytes, osGetLastError(),\n                (void*)hHeap);\n  }\n  return p;\n}\n\n/*\n** Return the size of an outstanding allocation, in bytes.\n*/\nstatic int winMemSize(void *p){\n  HANDLE hHeap;\n  SIZE_T n;\n\n  winMemAssertMagic();\n  hHeap = winMemGetHeap();\n  assert( hHeap!=0 );\n  assert( hHeap!=INVALID_HANDLE_VALUE );\n#if !SQLITE_OS_WINRT && defined(SQLITE_WIN32_MALLOC_VALIDATE)\n  assert( osHeapValidate(hHeap, SQLITE_WIN32_HEAP_FLAGS, p) );\n#endif\n  if( !p ) return 0;\n  n = osHeapSize(hHeap, SQLITE_WIN32_HEAP_FLAGS, p);\n  if( n==(SIZE_T)-1 ){\n    sqlite3_log(SQLITE_NOMEM, \"failed to HeapSize block %p (%lu), heap=%p\",\n                p, osGetLastError(), (void*)hHeap);\n    return 0;\n  }\n  return (int)n;\n}\n\n/*\n** Round up a request size to the next valid allocation size.\n*/\nstatic int winMemRoundup(int n){\n  return n;\n}\n\n/*\n** Initialize this module.\n*/\nstatic int winMemInit(void *pAppData){\n  winMemData *pWinMemData = (winMemData *)pAppData;\n\n  if( !pWinMemData ) return SQLITE_ERROR;\n  assert( pWinMemData->magic1==WINMEM_MAGIC1 );\n  assert( pWinMemData->magic2==WINMEM_MAGIC2 );\n\n#if !SQLITE_OS_WINRT && SQLITE_WIN32_HEAP_CREATE\n  if( !pWinMemData->hHeap ){\n    DWORD dwInitialSize = SQLITE_WIN32_HEAP_INIT_SIZE;\n    DWORD dwMaximumSize = (DWORD)sqlite3GlobalConfig.nHeap;\n    if( dwMaximumSize==0 ){\n      dwMaximumSize = SQLITE_WIN32_HEAP_MAX_SIZE;\n    }else if( dwInitialSize>dwMaximumSize ){\n      dwInitialSize = dwMaximumSize;\n    }\n    pWinMemData->hHeap = osHeapCreate(SQLITE_WIN32_HEAP_FLAGS,\n                                      dwInitialSize, dwMaximumSize);\n    if( !pWinMemData->hHeap ){\n      sqlite3_log(SQLITE_NOMEM,\n          \"failed to HeapCreate (%lu), flags=%u, initSize=%lu, maxSize=%lu\",\n          osGetLastError(), SQLITE_WIN32_HEAP_FLAGS, dwInitialSize,\n          dwMaximumSize);\n      return SQLITE_NOMEM_BKPT;\n    }\n    pWinMemData->bOwned = TRUE;\n    assert( pWinMemData->bOwned );\n  }\n#else\n  pWinMemData->hHeap = osGetProcessHeap();\n  if( !pWinMemData->hHeap ){\n    sqlite3_log(SQLITE_NOMEM,\n        \"failed to GetProcessHeap (%lu)\", osGetLastError());\n    return SQLITE_NOMEM_BKPT;\n  }\n  pWinMemData->bOwned = FALSE;\n  assert( !pWinMemData->bOwned );\n#endif\n  assert( pWinMemData->hHeap!=0 );\n  assert( pWinMemData->hHeap!=INVALID_HANDLE_VALUE );\n#if !SQLITE_OS_WINRT && defined(SQLITE_WIN32_MALLOC_VALIDATE)\n  assert( osHeapValidate(pWinMemData->hHeap, SQLITE_WIN32_HEAP_FLAGS, NULL) );\n#endif\n  return SQLITE_OK;\n}\n\n/*\n** Deinitialize this module.\n*/\nstatic void winMemShutdown(void *pAppData){\n  winMemData *pWinMemData = (winMemData *)pAppData;\n\n  if( !pWinMemData ) return;\n  assert( pWinMemData->magic1==WINMEM_MAGIC1 );\n  assert( pWinMemData->magic2==WINMEM_MAGIC2 );\n\n  if( pWinMemData->hHeap ){\n    assert( pWinMemData->hHeap!=INVALID_HANDLE_VALUE );\n#if !SQLITE_OS_WINRT && defined(SQLITE_WIN32_MALLOC_VALIDATE)\n    assert( osHeapValidate(pWinMemData->hHeap, SQLITE_WIN32_HEAP_FLAGS, NULL) );\n#endif\n    if( pWinMemData->bOwned ){\n      if( !osHeapDestroy(pWinMemData->hHeap) ){\n        sqlite3_log(SQLITE_NOMEM, \"failed to HeapDestroy (%lu), heap=%p\",\n                    osGetLastError(), (void*)pWinMemData->hHeap);\n      }\n      pWinMemData->bOwned = FALSE;\n    }\n    pWinMemData->hHeap = NULL;\n  }\n}\n\n/*\n** Populate the low-level memory allocation function pointers in\n** sqlite3GlobalConfig.m with pointers to the routines in this file. The\n** arguments specify the block of memory to manage.\n**\n** This routine is only called by sqlite3_config(), and therefore\n** is not required to be threadsafe (it is not).\n*/\nSQLITE_PRIVATE const sqlite3_mem_methods *sqlite3MemGetWin32(void){\n  static const sqlite3_mem_methods winMemMethods = {\n    winMemMalloc,\n    winMemFree,\n    winMemRealloc,\n    winMemSize,\n    winMemRoundup,\n    winMemInit,\n    winMemShutdown,\n    &win_mem_data\n  };\n  return &winMemMethods;\n}\n\nSQLITE_PRIVATE void sqlite3MemSetDefault(void){\n  sqlite3_config(SQLITE_CONFIG_MALLOC, sqlite3MemGetWin32());\n}\n#endif /* SQLITE_WIN32_MALLOC */\n\n/*\n** Convert a UTF-8 string to Microsoft Unicode.\n**\n** Space to hold the returned string is obtained from sqlite3_malloc().\n*/\nstatic LPWSTR winUtf8ToUnicode(const char *zText){\n  int nChar;\n  LPWSTR zWideText;\n\n  nChar = osMultiByteToWideChar(CP_UTF8, 0, zText, -1, NULL, 0);\n  if( nChar==0 ){\n    return 0;\n  }\n  zWideText = sqlite3MallocZero( nChar*sizeof(WCHAR) );\n  if( zWideText==0 ){\n    return 0;\n  }\n  nChar = osMultiByteToWideChar(CP_UTF8, 0, zText, -1, zWideText,\n                                nChar);\n  if( nChar==0 ){\n    sqlite3_free(zWideText);\n    zWideText = 0;\n  }\n  return zWideText;\n}\n\n/*\n** Convert a Microsoft Unicode string to UTF-8.\n**\n** Space to hold the returned string is obtained from sqlite3_malloc().\n*/\nstatic char *winUnicodeToUtf8(LPCWSTR zWideText){\n  int nByte;\n  char *zText;\n\n  nByte = osWideCharToMultiByte(CP_UTF8, 0, zWideText, -1, 0, 0, 0, 0);\n  if( nByte == 0 ){\n    return 0;\n  }\n  zText = sqlite3MallocZero( nByte );\n  if( zText==0 ){\n    return 0;\n  }\n  nByte = osWideCharToMultiByte(CP_UTF8, 0, zWideText, -1, zText, nByte,\n                                0, 0);\n  if( nByte == 0 ){\n    sqlite3_free(zText);\n    zText = 0;\n  }\n  return zText;\n}\n\n/*\n** Convert an ANSI string to Microsoft Unicode, using the ANSI or OEM\n** code page.\n**\n** Space to hold the returned string is obtained from sqlite3_malloc().\n*/\nstatic LPWSTR winMbcsToUnicode(const char *zText, int useAnsi){\n  int nByte;\n  LPWSTR zMbcsText;\n  int codepage = useAnsi ? CP_ACP : CP_OEMCP;\n\n  nByte = osMultiByteToWideChar(codepage, 0, zText, -1, NULL,\n                                0)*sizeof(WCHAR);\n  if( nByte==0 ){\n    return 0;\n  }\n  zMbcsText = sqlite3MallocZero( nByte*sizeof(WCHAR) );\n  if( zMbcsText==0 ){\n    return 0;\n  }\n  nByte = osMultiByteToWideChar(codepage, 0, zText, -1, zMbcsText,\n                                nByte);\n  if( nByte==0 ){\n    sqlite3_free(zMbcsText);\n    zMbcsText = 0;\n  }\n  return zMbcsText;\n}\n\n/*\n** Convert a Microsoft Unicode string to a multi-byte character string,\n** using the ANSI or OEM code page.\n**\n** Space to hold the returned string is obtained from sqlite3_malloc().\n*/\nstatic char *winUnicodeToMbcs(LPCWSTR zWideText, int useAnsi){\n  int nByte;\n  char *zText;\n  int codepage = useAnsi ? CP_ACP : CP_OEMCP;\n\n  nByte = osWideCharToMultiByte(codepage, 0, zWideText, -1, 0, 0, 0, 0);\n  if( nByte == 0 ){\n    return 0;\n  }\n  zText = sqlite3MallocZero( nByte );\n  if( zText==0 ){\n    return 0;\n  }\n  nByte = osWideCharToMultiByte(codepage, 0, zWideText, -1, zText,\n                                nByte, 0, 0);\n  if( nByte == 0 ){\n    sqlite3_free(zText);\n    zText = 0;\n  }\n  return zText;\n}\n\n/*\n** Convert a multi-byte character string to UTF-8.\n**\n** Space to hold the returned string is obtained from sqlite3_malloc().\n*/\nstatic char *winMbcsToUtf8(const char *zText, int useAnsi){\n  char *zTextUtf8;\n  LPWSTR zTmpWide;\n\n  zTmpWide = winMbcsToUnicode(zText, useAnsi);\n  if( zTmpWide==0 ){\n    return 0;\n  }\n  zTextUtf8 = winUnicodeToUtf8(zTmpWide);\n  sqlite3_free(zTmpWide);\n  return zTextUtf8;\n}\n\n/*\n** Convert a UTF-8 string to a multi-byte character string.\n**\n** Space to hold the returned string is obtained from sqlite3_malloc().\n*/\nstatic char *winUtf8ToMbcs(const char *zText, int useAnsi){\n  char *zTextMbcs;\n  LPWSTR zTmpWide;\n\n  zTmpWide = winUtf8ToUnicode(zText);\n  if( zTmpWide==0 ){\n    return 0;\n  }\n  zTextMbcs = winUnicodeToMbcs(zTmpWide, useAnsi);\n  sqlite3_free(zTmpWide);\n  return zTextMbcs;\n}\n\n/*\n** This is a public wrapper for the winUtf8ToUnicode() function.\n*/\nSQLITE_API LPWSTR sqlite3_win32_utf8_to_unicode(const char *zText){\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( !zText ){\n    (void)SQLITE_MISUSE_BKPT;\n    return 0;\n  }\n#endif\n#ifndef SQLITE_OMIT_AUTOINIT\n  if( sqlite3_initialize() ) return 0;\n#endif\n  return winUtf8ToUnicode(zText);\n}\n\n/*\n** This is a public wrapper for the winUnicodeToUtf8() function.\n*/\nSQLITE_API char *sqlite3_win32_unicode_to_utf8(LPCWSTR zWideText){\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( !zWideText ){\n    (void)SQLITE_MISUSE_BKPT;\n    return 0;\n  }\n#endif\n#ifndef SQLITE_OMIT_AUTOINIT\n  if( sqlite3_initialize() ) return 0;\n#endif\n  return winUnicodeToUtf8(zWideText);\n}\n\n/*\n** This is a public wrapper for the winMbcsToUtf8() function.\n*/\nSQLITE_API char *sqlite3_win32_mbcs_to_utf8(const char *zText){\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( !zText ){\n    (void)SQLITE_MISUSE_BKPT;\n    return 0;\n  }\n#endif\n#ifndef SQLITE_OMIT_AUTOINIT\n  if( sqlite3_initialize() ) return 0;\n#endif\n  return winMbcsToUtf8(zText, osAreFileApisANSI());\n}\n\n/*\n** This is a public wrapper for the winMbcsToUtf8() function.\n*/\nSQLITE_API char *sqlite3_win32_mbcs_to_utf8_v2(const char *zText, int useAnsi){\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( !zText ){\n    (void)SQLITE_MISUSE_BKPT;\n    return 0;\n  }\n#endif\n#ifndef SQLITE_OMIT_AUTOINIT\n  if( sqlite3_initialize() ) return 0;\n#endif\n  return winMbcsToUtf8(zText, useAnsi);\n}\n\n/*\n** This is a public wrapper for the winUtf8ToMbcs() function.\n*/\nSQLITE_API char *sqlite3_win32_utf8_to_mbcs(const char *zText){\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( !zText ){\n    (void)SQLITE_MISUSE_BKPT;\n    return 0;\n  }\n#endif\n#ifndef SQLITE_OMIT_AUTOINIT\n  if( sqlite3_initialize() ) return 0;\n#endif\n  return winUtf8ToMbcs(zText, osAreFileApisANSI());\n}\n\n/*\n** This is a public wrapper for the winUtf8ToMbcs() function.\n*/\nSQLITE_API char *sqlite3_win32_utf8_to_mbcs_v2(const char *zText, int useAnsi){\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( !zText ){\n    (void)SQLITE_MISUSE_BKPT;\n    return 0;\n  }\n#endif\n#ifndef SQLITE_OMIT_AUTOINIT\n  if( sqlite3_initialize() ) return 0;\n#endif\n  return winUtf8ToMbcs(zText, useAnsi);\n}\n\n/*\n** This function is the same as sqlite3_win32_set_directory (below); however,\n** it accepts a UTF-8 string.\n*/\nSQLITE_API int sqlite3_win32_set_directory8(\n  unsigned long type, /* Identifier for directory being set or reset */\n  const char *zValue  /* New value for directory being set or reset */\n){\n  char **ppDirectory = 0;\n#ifndef SQLITE_OMIT_AUTOINIT\n  int rc = sqlite3_initialize();\n  if( rc ) return rc;\n#endif\n  if( type==SQLITE_WIN32_DATA_DIRECTORY_TYPE ){\n    ppDirectory = &sqlite3_data_directory;\n  }else if( type==SQLITE_WIN32_TEMP_DIRECTORY_TYPE ){\n    ppDirectory = &sqlite3_temp_directory;\n  }\n  assert( !ppDirectory || type==SQLITE_WIN32_DATA_DIRECTORY_TYPE\n          || type==SQLITE_WIN32_TEMP_DIRECTORY_TYPE\n  );\n  assert( !ppDirectory || sqlite3MemdebugHasType(*ppDirectory, MEMTYPE_HEAP) );\n  if( ppDirectory ){\n    char *zCopy = 0;\n    if( zValue && zValue[0] ){\n      zCopy = sqlite3_mprintf(\"%s\", zValue);\n      if ( zCopy==0 ){\n        return SQLITE_NOMEM_BKPT;\n      }\n    }\n    sqlite3_free(*ppDirectory);\n    *ppDirectory = zCopy;\n    return SQLITE_OK;\n  }\n  return SQLITE_ERROR;\n}\n\n/*\n** This function is the same as sqlite3_win32_set_directory (below); however,\n** it accepts a UTF-16 string.\n*/\nSQLITE_API int sqlite3_win32_set_directory16(\n  unsigned long type, /* Identifier for directory being set or reset */\n  const void *zValue  /* New value for directory being set or reset */\n){\n  int rc;\n  char *zUtf8 = 0;\n  if( zValue ){\n    zUtf8 = sqlite3_win32_unicode_to_utf8(zValue);\n    if( zUtf8==0 ) return SQLITE_NOMEM_BKPT;\n  }\n  rc = sqlite3_win32_set_directory8(type, zUtf8);\n  if( zUtf8 ) sqlite3_free(zUtf8);\n  return rc;\n}\n\n/*\n** This function sets the data directory or the temporary directory based on\n** the provided arguments.  The type argument must be 1 in order to set the\n** data directory or 2 in order to set the temporary directory.  The zValue\n** argument is the name of the directory to use.  The return value will be\n** SQLITE_OK if successful.\n*/\nSQLITE_API int sqlite3_win32_set_directory(\n  unsigned long type, /* Identifier for directory being set or reset */\n  void *zValue        /* New value for directory being set or reset */\n){\n  return sqlite3_win32_set_directory16(type, zValue);\n}\n\n/*\n** The return value of winGetLastErrorMsg\n** is zero if the error message fits in the buffer, or non-zero\n** otherwise (if the message was truncated).\n*/\nstatic int winGetLastErrorMsg(DWORD lastErrno, int nBuf, char *zBuf){\n  /* FormatMessage returns 0 on failure.  Otherwise it\n  ** returns the number of TCHARs written to the output\n  ** buffer, excluding the terminating null char.\n  */\n  DWORD dwLen = 0;\n  char *zOut = 0;\n\n  if( osIsNT() ){\n#if SQLITE_OS_WINRT\n    WCHAR zTempWide[SQLITE_WIN32_MAX_ERRMSG_CHARS+1];\n    dwLen = osFormatMessageW(FORMAT_MESSAGE_FROM_SYSTEM |\n                             FORMAT_MESSAGE_IGNORE_INSERTS,\n                             NULL,\n                             lastErrno,\n                             0,\n                             zTempWide,\n                             SQLITE_WIN32_MAX_ERRMSG_CHARS,\n                             0);\n#else\n    LPWSTR zTempWide = NULL;\n    dwLen = osFormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER |\n                             FORMAT_MESSAGE_FROM_SYSTEM |\n                             FORMAT_MESSAGE_IGNORE_INSERTS,\n                             NULL,\n                             lastErrno,\n                             0,\n                             (LPWSTR) &zTempWide,\n                             0,\n                             0);\n#endif\n    if( dwLen > 0 ){\n      /* allocate a buffer and convert to UTF8 */\n      sqlite3BeginBenignMalloc();\n      zOut = winUnicodeToUtf8(zTempWide);\n      sqlite3EndBenignMalloc();\n#if !SQLITE_OS_WINRT\n      /* free the system buffer allocated by FormatMessage */\n      osLocalFree(zTempWide);\n#endif\n    }\n  }\n#ifdef SQLITE_WIN32_HAS_ANSI\n  else{\n    char *zTemp = NULL;\n    dwLen = osFormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER |\n                             FORMAT_MESSAGE_FROM_SYSTEM |\n                             FORMAT_MESSAGE_IGNORE_INSERTS,\n                             NULL,\n                             lastErrno,\n                             0,\n                             (LPSTR) &zTemp,\n                             0,\n                             0);\n    if( dwLen > 0 ){\n      /* allocate a buffer and convert to UTF8 */\n      sqlite3BeginBenignMalloc();\n      zOut = winMbcsToUtf8(zTemp, osAreFileApisANSI());\n      sqlite3EndBenignMalloc();\n      /* free the system buffer allocated by FormatMessage */\n      osLocalFree(zTemp);\n    }\n  }\n#endif\n  if( 0 == dwLen ){\n    sqlite3_snprintf(nBuf, zBuf, \"OsError 0x%lx (%lu)\", lastErrno, lastErrno);\n  }else{\n    /* copy a maximum of nBuf chars to output buffer */\n    sqlite3_snprintf(nBuf, zBuf, \"%s\", zOut);\n    /* free the UTF8 buffer */\n    sqlite3_free(zOut);\n  }\n  return 0;\n}\n\n/*\n**\n** This function - winLogErrorAtLine() - is only ever called via the macro\n** winLogError().\n**\n** This routine is invoked after an error occurs in an OS function.\n** It logs a message using sqlite3_log() containing the current value of\n** error code and, if possible, the human-readable equivalent from\n** FormatMessage.\n**\n** The first argument passed to the macro should be the error code that\n** will be returned to SQLite (e.g. SQLITE_IOERR_DELETE, SQLITE_CANTOPEN).\n** The two subsequent arguments should be the name of the OS function that\n** failed and the associated file-system path, if any.\n*/\n#define winLogError(a,b,c,d)   winLogErrorAtLine(a,b,c,d,__LINE__)\nstatic int winLogErrorAtLine(\n  int errcode,                    /* SQLite error code */\n  DWORD lastErrno,                /* Win32 last error */\n  const char *zFunc,              /* Name of OS function that failed */\n  const char *zPath,              /* File path associated with error */\n  int iLine                       /* Source line number where error occurred */\n){\n  char zMsg[500];                 /* Human readable error text */\n  int i;                          /* Loop counter */\n\n  zMsg[0] = 0;\n  winGetLastErrorMsg(lastErrno, sizeof(zMsg), zMsg);\n  assert( errcode!=SQLITE_OK );\n  if( zPath==0 ) zPath = \"\";\n  for(i=0; zMsg[i] && zMsg[i]!='\\r' && zMsg[i]!='\\n'; i++){}\n  zMsg[i] = 0;\n  sqlite3_log(errcode,\n      \"os_win.c:%d: (%lu) %s(%s) - %s\",\n      iLine, lastErrno, zFunc, zPath, zMsg\n  );\n\n  return errcode;\n}\n\n/*\n** The number of times that a ReadFile(), WriteFile(), and DeleteFile()\n** will be retried following a locking error - probably caused by\n** antivirus software.  Also the initial delay before the first retry.\n** The delay increases linearly with each retry.\n*/\n#ifndef SQLITE_WIN32_IOERR_RETRY\n# define SQLITE_WIN32_IOERR_RETRY 10\n#endif\n#ifndef SQLITE_WIN32_IOERR_RETRY_DELAY\n# define SQLITE_WIN32_IOERR_RETRY_DELAY 25\n#endif\nstatic int winIoerrRetry = SQLITE_WIN32_IOERR_RETRY;\nstatic int winIoerrRetryDelay = SQLITE_WIN32_IOERR_RETRY_DELAY;\n\n/*\n** The \"winIoerrCanRetry1\" macro is used to determine if a particular I/O\n** error code obtained via GetLastError() is eligible to be retried.  It\n** must accept the error code DWORD as its only argument and should return\n** non-zero if the error code is transient in nature and the operation\n** responsible for generating the original error might succeed upon being\n** retried.  The argument to this macro should be a variable.\n**\n** Additionally, a macro named \"winIoerrCanRetry2\" may be defined.  If it\n** is defined, it will be consulted only when the macro \"winIoerrCanRetry1\"\n** returns zero.  The \"winIoerrCanRetry2\" macro is completely optional and\n** may be used to include additional error codes in the set that should\n** result in the failing I/O operation being retried by the caller.  If\n** defined, the \"winIoerrCanRetry2\" macro must exhibit external semantics\n** identical to those of the \"winIoerrCanRetry1\" macro.\n*/\n#if !defined(winIoerrCanRetry1)\n#define winIoerrCanRetry1(a) (((a)==ERROR_ACCESS_DENIED)        || \\\n                              ((a)==ERROR_SHARING_VIOLATION)    || \\\n                              ((a)==ERROR_LOCK_VIOLATION)       || \\\n                              ((a)==ERROR_DEV_NOT_EXIST)        || \\\n                              ((a)==ERROR_NETNAME_DELETED)      || \\\n                              ((a)==ERROR_SEM_TIMEOUT)          || \\\n                              ((a)==ERROR_NETWORK_UNREACHABLE))\n#endif\n\n/*\n** If a ReadFile() or WriteFile() error occurs, invoke this routine\n** to see if it should be retried.  Return TRUE to retry.  Return FALSE\n** to give up with an error.\n*/\nstatic int winRetryIoerr(int *pnRetry, DWORD *pError){\n  DWORD e = osGetLastError();\n  if( *pnRetry>=winIoerrRetry ){\n    if( pError ){\n      *pError = e;\n    }\n    return 0;\n  }\n  if( winIoerrCanRetry1(e) ){\n    sqlite3_win32_sleep(winIoerrRetryDelay*(1+*pnRetry));\n    ++*pnRetry;\n    return 1;\n  }\n#if defined(winIoerrCanRetry2)\n  else if( winIoerrCanRetry2(e) ){\n    sqlite3_win32_sleep(winIoerrRetryDelay*(1+*pnRetry));\n    ++*pnRetry;\n    return 1;\n  }\n#endif\n  if( pError ){\n    *pError = e;\n  }\n  return 0;\n}\n\n/*\n** Log a I/O error retry episode.\n*/\nstatic void winLogIoerr(int nRetry, int lineno){\n  if( nRetry ){\n    sqlite3_log(SQLITE_NOTICE,\n      \"delayed %dms for lock/sharing conflict at line %d\",\n      winIoerrRetryDelay*nRetry*(nRetry+1)/2, lineno\n    );\n  }\n}\n\n/*\n** This #if does not rely on the SQLITE_OS_WINCE define because the\n** corresponding section in \"date.c\" cannot use it.\n*/\n#if !defined(SQLITE_OMIT_LOCALTIME) && defined(_WIN32_WCE) && \\\n    (!defined(SQLITE_MSVC_LOCALTIME_API) || !SQLITE_MSVC_LOCALTIME_API)\n/*\n** The MSVC CRT on Windows CE may not have a localtime() function.\n** So define a substitute.\n*/\n/* #  include <time.h> */\nstruct tm *__cdecl localtime(const time_t *t)\n{\n  static struct tm y;\n  FILETIME uTm, lTm;\n  SYSTEMTIME pTm;\n  sqlite3_int64 t64;\n  t64 = *t;\n  t64 = (t64 + 11644473600)*10000000;\n  uTm.dwLowDateTime = (DWORD)(t64 & 0xFFFFFFFF);\n  uTm.dwHighDateTime= (DWORD)(t64 >> 32);\n  osFileTimeToLocalFileTime(&uTm,&lTm);\n  osFileTimeToSystemTime(&lTm,&pTm);\n  y.tm_year = pTm.wYear - 1900;\n  y.tm_mon = pTm.wMonth - 1;\n  y.tm_wday = pTm.wDayOfWeek;\n  y.tm_mday = pTm.wDay;\n  y.tm_hour = pTm.wHour;\n  y.tm_min = pTm.wMinute;\n  y.tm_sec = pTm.wSecond;\n  return &y;\n}\n#endif\n\n#if SQLITE_OS_WINCE\n/*************************************************************************\n** This section contains code for WinCE only.\n*/\n#define HANDLE_TO_WINFILE(a) (winFile*)&((char*)a)[-(int)offsetof(winFile,h)]\n\n/*\n** Acquire a lock on the handle h\n*/\nstatic void winceMutexAcquire(HANDLE h){\n   DWORD dwErr;\n   do {\n     dwErr = osWaitForSingleObject(h, INFINITE);\n   } while (dwErr != WAIT_OBJECT_0 && dwErr != WAIT_ABANDONED);\n}\n/*\n** Release a lock acquired by winceMutexAcquire()\n*/\n#define winceMutexRelease(h) ReleaseMutex(h)\n\n/*\n** Create the mutex and shared memory used for locking in the file\n** descriptor pFile\n*/\nstatic int winceCreateLock(const char *zFilename, winFile *pFile){\n  LPWSTR zTok;\n  LPWSTR zName;\n  DWORD lastErrno;\n  BOOL bLogged = FALSE;\n  BOOL bInit = TRUE;\n\n  zName = winUtf8ToUnicode(zFilename);\n  if( zName==0 ){\n    /* out of memory */\n    return SQLITE_IOERR_NOMEM_BKPT;\n  }\n\n  /* Initialize the local lockdata */\n  memset(&pFile->local, 0, sizeof(pFile->local));\n\n  /* Replace the backslashes from the filename and lowercase it\n  ** to derive a mutex name. */\n  zTok = osCharLowerW(zName);\n  for (;*zTok;zTok++){\n    if (*zTok == '\\\\') *zTok = '_';\n  }\n\n  /* Create/open the named mutex */\n  pFile->hMutex = osCreateMutexW(NULL, FALSE, zName);\n  if (!pFile->hMutex){\n    pFile->lastErrno = osGetLastError();\n    sqlite3_free(zName);\n    return winLogError(SQLITE_IOERR, pFile->lastErrno,\n                       \"winceCreateLock1\", zFilename);\n  }\n\n  /* Acquire the mutex before continuing */\n  winceMutexAcquire(pFile->hMutex);\n\n  /* Since the names of named mutexes, semaphores, file mappings etc are\n  ** case-sensitive, take advantage of that by uppercasing the mutex name\n  ** and using that as the shared filemapping name.\n  */\n  osCharUpperW(zName);\n  pFile->hShared = osCreateFileMappingW(INVALID_HANDLE_VALUE, NULL,\n                                        PAGE_READWRITE, 0, sizeof(winceLock),\n                                        zName);\n\n  /* Set a flag that indicates we're the first to create the memory so it\n  ** must be zero-initialized */\n  lastErrno = osGetLastError();\n  if (lastErrno == ERROR_ALREADY_EXISTS){\n    bInit = FALSE;\n  }\n\n  sqlite3_free(zName);\n\n  /* If we succeeded in making the shared memory handle, map it. */\n  if( pFile->hShared ){\n    pFile->shared = (winceLock*)osMapViewOfFile(pFile->hShared,\n             FILE_MAP_READ|FILE_MAP_WRITE, 0, 0, sizeof(winceLock));\n    /* If mapping failed, close the shared memory handle and erase it */\n    if( !pFile->shared ){\n      pFile->lastErrno = osGetLastError();\n      winLogError(SQLITE_IOERR, pFile->lastErrno,\n                  \"winceCreateLock2\", zFilename);\n      bLogged = TRUE;\n      osCloseHandle(pFile->hShared);\n      pFile->hShared = NULL;\n    }\n  }\n\n  /* If shared memory could not be created, then close the mutex and fail */\n  if( pFile->hShared==NULL ){\n    if( !bLogged ){\n      pFile->lastErrno = lastErrno;\n      winLogError(SQLITE_IOERR, pFile->lastErrno,\n                  \"winceCreateLock3\", zFilename);\n      bLogged = TRUE;\n    }\n    winceMutexRelease(pFile->hMutex);\n    osCloseHandle(pFile->hMutex);\n    pFile->hMutex = NULL;\n    return SQLITE_IOERR;\n  }\n\n  /* Initialize the shared memory if we're supposed to */\n  if( bInit ){\n    memset(pFile->shared, 0, sizeof(winceLock));\n  }\n\n  winceMutexRelease(pFile->hMutex);\n  return SQLITE_OK;\n}\n\n/*\n** Destroy the part of winFile that deals with wince locks\n*/\nstatic void winceDestroyLock(winFile *pFile){\n  if (pFile->hMutex){\n    /* Acquire the mutex */\n    winceMutexAcquire(pFile->hMutex);\n\n    /* The following blocks should probably assert in debug mode, but they\n       are to cleanup in case any locks remained open */\n    if (pFile->local.nReaders){\n      pFile->shared->nReaders --;\n    }\n    if (pFile->local.bReserved){\n      pFile->shared->bReserved = FALSE;\n    }\n    if (pFile->local.bPending){\n      pFile->shared->bPending = FALSE;\n    }\n    if (pFile->local.bExclusive){\n      pFile->shared->bExclusive = FALSE;\n    }\n\n    /* De-reference and close our copy of the shared memory handle */\n    osUnmapViewOfFile(pFile->shared);\n    osCloseHandle(pFile->hShared);\n\n    /* Done with the mutex */\n    winceMutexRelease(pFile->hMutex);\n    osCloseHandle(pFile->hMutex);\n    pFile->hMutex = NULL;\n  }\n}\n\n/*\n** An implementation of the LockFile() API of Windows for CE\n*/\nstatic BOOL winceLockFile(\n  LPHANDLE phFile,\n  DWORD dwFileOffsetLow,\n  DWORD dwFileOffsetHigh,\n  DWORD nNumberOfBytesToLockLow,\n  DWORD nNumberOfBytesToLockHigh\n){\n  winFile *pFile = HANDLE_TO_WINFILE(phFile);\n  BOOL bReturn = FALSE;\n\n  UNUSED_PARAMETER(dwFileOffsetHigh);\n  UNUSED_PARAMETER(nNumberOfBytesToLockHigh);\n\n  if (!pFile->hMutex) return TRUE;\n  winceMutexAcquire(pFile->hMutex);\n\n  /* Wanting an exclusive lock? */\n  if (dwFileOffsetLow == (DWORD)SHARED_FIRST\n       && nNumberOfBytesToLockLow == (DWORD)SHARED_SIZE){\n    if (pFile->shared->nReaders == 0 && pFile->shared->bExclusive == 0){\n       pFile->shared->bExclusive = TRUE;\n       pFile->local.bExclusive = TRUE;\n       bReturn = TRUE;\n    }\n  }\n\n  /* Want a read-only lock? */\n  else if (dwFileOffsetLow == (DWORD)SHARED_FIRST &&\n           nNumberOfBytesToLockLow == 1){\n    if (pFile->shared->bExclusive == 0){\n      pFile->local.nReaders ++;\n      if (pFile->local.nReaders == 1){\n        pFile->shared->nReaders ++;\n      }\n      bReturn = TRUE;\n    }\n  }\n\n  /* Want a pending lock? */\n  else if (dwFileOffsetLow == (DWORD)PENDING_BYTE\n           && nNumberOfBytesToLockLow == 1){\n    /* If no pending lock has been acquired, then acquire it */\n    if (pFile->shared->bPending == 0) {\n      pFile->shared->bPending = TRUE;\n      pFile->local.bPending = TRUE;\n      bReturn = TRUE;\n    }\n  }\n\n  /* Want a reserved lock? */\n  else if (dwFileOffsetLow == (DWORD)RESERVED_BYTE\n           && nNumberOfBytesToLockLow == 1){\n    if (pFile->shared->bReserved == 0) {\n      pFile->shared->bReserved = TRUE;\n      pFile->local.bReserved = TRUE;\n      bReturn = TRUE;\n    }\n  }\n\n  winceMutexRelease(pFile->hMutex);\n  return bReturn;\n}\n\n/*\n** An implementation of the UnlockFile API of Windows for CE\n*/\nstatic BOOL winceUnlockFile(\n  LPHANDLE phFile,\n  DWORD dwFileOffsetLow,\n  DWORD dwFileOffsetHigh,\n  DWORD nNumberOfBytesToUnlockLow,\n  DWORD nNumberOfBytesToUnlockHigh\n){\n  winFile *pFile = HANDLE_TO_WINFILE(phFile);\n  BOOL bReturn = FALSE;\n\n  UNUSED_PARAMETER(dwFileOffsetHigh);\n  UNUSED_PARAMETER(nNumberOfBytesToUnlockHigh);\n\n  if (!pFile->hMutex) return TRUE;\n  winceMutexAcquire(pFile->hMutex);\n\n  /* Releasing a reader lock or an exclusive lock */\n  if (dwFileOffsetLow == (DWORD)SHARED_FIRST){\n    /* Did we have an exclusive lock? */\n    if (pFile->local.bExclusive){\n      assert(nNumberOfBytesToUnlockLow == (DWORD)SHARED_SIZE);\n      pFile->local.bExclusive = FALSE;\n      pFile->shared->bExclusive = FALSE;\n      bReturn = TRUE;\n    }\n\n    /* Did we just have a reader lock? */\n    else if (pFile->local.nReaders){\n      assert(nNumberOfBytesToUnlockLow == (DWORD)SHARED_SIZE\n             || nNumberOfBytesToUnlockLow == 1);\n      pFile->local.nReaders --;\n      if (pFile->local.nReaders == 0)\n      {\n        pFile->shared->nReaders --;\n      }\n      bReturn = TRUE;\n    }\n  }\n\n  /* Releasing a pending lock */\n  else if (dwFileOffsetLow == (DWORD)PENDING_BYTE\n           && nNumberOfBytesToUnlockLow == 1){\n    if (pFile->local.bPending){\n      pFile->local.bPending = FALSE;\n      pFile->shared->bPending = FALSE;\n      bReturn = TRUE;\n    }\n  }\n  /* Releasing a reserved lock */\n  else if (dwFileOffsetLow == (DWORD)RESERVED_BYTE\n           && nNumberOfBytesToUnlockLow == 1){\n    if (pFile->local.bReserved) {\n      pFile->local.bReserved = FALSE;\n      pFile->shared->bReserved = FALSE;\n      bReturn = TRUE;\n    }\n  }\n\n  winceMutexRelease(pFile->hMutex);\n  return bReturn;\n}\n/*\n** End of the special code for wince\n*****************************************************************************/\n#endif /* SQLITE_OS_WINCE */\n\n/*\n** Lock a file region.\n*/\nstatic BOOL winLockFile(\n  LPHANDLE phFile,\n  DWORD flags,\n  DWORD offsetLow,\n  DWORD offsetHigh,\n  DWORD numBytesLow,\n  DWORD numBytesHigh\n){\n#if SQLITE_OS_WINCE\n  /*\n  ** NOTE: Windows CE is handled differently here due its lack of the Win32\n  **       API LockFile.\n  */\n  return winceLockFile(phFile, offsetLow, offsetHigh,\n                       numBytesLow, numBytesHigh);\n#else\n  if( osIsNT() ){\n    OVERLAPPED ovlp;\n    memset(&ovlp, 0, sizeof(OVERLAPPED));\n    ovlp.Offset = offsetLow;\n    ovlp.OffsetHigh = offsetHigh;\n    return osLockFileEx(*phFile, flags, 0, numBytesLow, numBytesHigh, &ovlp);\n  }else{\n    return osLockFile(*phFile, offsetLow, offsetHigh, numBytesLow,\n                      numBytesHigh);\n  }\n#endif\n}\n\n/*\n** Unlock a file region.\n */\nstatic BOOL winUnlockFile(\n  LPHANDLE phFile,\n  DWORD offsetLow,\n  DWORD offsetHigh,\n  DWORD numBytesLow,\n  DWORD numBytesHigh\n){\n#if SQLITE_OS_WINCE\n  /*\n  ** NOTE: Windows CE is handled differently here due its lack of the Win32\n  **       API UnlockFile.\n  */\n  return winceUnlockFile(phFile, offsetLow, offsetHigh,\n                         numBytesLow, numBytesHigh);\n#else\n  if( osIsNT() ){\n    OVERLAPPED ovlp;\n    memset(&ovlp, 0, sizeof(OVERLAPPED));\n    ovlp.Offset = offsetLow;\n    ovlp.OffsetHigh = offsetHigh;\n    return osUnlockFileEx(*phFile, 0, numBytesLow, numBytesHigh, &ovlp);\n  }else{\n    return osUnlockFile(*phFile, offsetLow, offsetHigh, numBytesLow,\n                        numBytesHigh);\n  }\n#endif\n}\n\n/*****************************************************************************\n** The next group of routines implement the I/O methods specified\n** by the sqlite3_io_methods object.\n******************************************************************************/\n\n/*\n** Some Microsoft compilers lack this definition.\n*/\n#ifndef INVALID_SET_FILE_POINTER\n# define INVALID_SET_FILE_POINTER ((DWORD)-1)\n#endif\n\n/*\n** Move the current position of the file handle passed as the first\n** argument to offset iOffset within the file. If successful, return 0.\n** Otherwise, set pFile->lastErrno and return non-zero.\n*/\nstatic int winSeekFile(winFile *pFile, sqlite3_int64 iOffset){\n#if !SQLITE_OS_WINRT\n  LONG upperBits;                 /* Most sig. 32 bits of new offset */\n  LONG lowerBits;                 /* Least sig. 32 bits of new offset */\n  DWORD dwRet;                    /* Value returned by SetFilePointer() */\n  DWORD lastErrno;                /* Value returned by GetLastError() */\n\n  OSTRACE((\"SEEK file=%p, offset=%lld\\n\", pFile->h, iOffset));\n\n  upperBits = (LONG)((iOffset>>32) & 0x7fffffff);\n  lowerBits = (LONG)(iOffset & 0xffffffff);\n\n  /* API oddity: If successful, SetFilePointer() returns a dword\n  ** containing the lower 32-bits of the new file-offset. Or, if it fails,\n  ** it returns INVALID_SET_FILE_POINTER. However according to MSDN,\n  ** INVALID_SET_FILE_POINTER may also be a valid new offset. So to determine\n  ** whether an error has actually occurred, it is also necessary to call\n  ** GetLastError().\n  */\n  dwRet = osSetFilePointer(pFile->h, lowerBits, &upperBits, FILE_BEGIN);\n\n  if( (dwRet==INVALID_SET_FILE_POINTER\n      && ((lastErrno = osGetLastError())!=NO_ERROR)) ){\n    pFile->lastErrno = lastErrno;\n    winLogError(SQLITE_IOERR_SEEK, pFile->lastErrno,\n                \"winSeekFile\", pFile->zPath);\n    OSTRACE((\"SEEK file=%p, rc=SQLITE_IOERR_SEEK\\n\", pFile->h));\n    return 1;\n  }\n\n  OSTRACE((\"SEEK file=%p, rc=SQLITE_OK\\n\", pFile->h));\n  return 0;\n#else\n  /*\n  ** Same as above, except that this implementation works for WinRT.\n  */\n\n  LARGE_INTEGER x;                /* The new offset */\n  BOOL bRet;                      /* Value returned by SetFilePointerEx() */\n\n  x.QuadPart = iOffset;\n  bRet = osSetFilePointerEx(pFile->h, x, 0, FILE_BEGIN);\n\n  if(!bRet){\n    pFile->lastErrno = osGetLastError();\n    winLogError(SQLITE_IOERR_SEEK, pFile->lastErrno,\n                \"winSeekFile\", pFile->zPath);\n    OSTRACE((\"SEEK file=%p, rc=SQLITE_IOERR_SEEK\\n\", pFile->h));\n    return 1;\n  }\n\n  OSTRACE((\"SEEK file=%p, rc=SQLITE_OK\\n\", pFile->h));\n  return 0;\n#endif\n}\n\n#if SQLITE_MAX_MMAP_SIZE>0\n/* Forward references to VFS helper methods used for memory mapped files */\nstatic int winMapfile(winFile*, sqlite3_int64);\nstatic int winUnmapfile(winFile*);\n#endif\n\n/*\n** Close a file.\n**\n** It is reported that an attempt to close a handle might sometimes\n** fail.  This is a very unreasonable result, but Windows is notorious\n** for being unreasonable so I do not doubt that it might happen.  If\n** the close fails, we pause for 100 milliseconds and try again.  As\n** many as MX_CLOSE_ATTEMPT attempts to close the handle are made before\n** giving up and returning an error.\n*/\n#define MX_CLOSE_ATTEMPT 3\nstatic int winClose(sqlite3_file *id){\n  int rc, cnt = 0;\n  winFile *pFile = (winFile*)id;\n\n  assert( id!=0 );\n#ifndef SQLITE_OMIT_WAL\n  assert( pFile->pShm==0 );\n#endif\n  assert( pFile->h!=NULL && pFile->h!=INVALID_HANDLE_VALUE );\n  OSTRACE((\"CLOSE pid=%lu, pFile=%p, file=%p\\n\",\n           osGetCurrentProcessId(), pFile, pFile->h));\n\n#if SQLITE_MAX_MMAP_SIZE>0\n  winUnmapfile(pFile);\n#endif\n\n  do{\n    rc = osCloseHandle(pFile->h);\n    /* SimulateIOError( rc=0; cnt=MX_CLOSE_ATTEMPT; ); */\n  }while( rc==0 && ++cnt < MX_CLOSE_ATTEMPT && (sqlite3_win32_sleep(100), 1) );\n#if SQLITE_OS_WINCE\n#define WINCE_DELETION_ATTEMPTS 3\n  {\n    winVfsAppData *pAppData = (winVfsAppData*)pFile->pVfs->pAppData;\n    if( pAppData==NULL || !pAppData->bNoLock ){\n      winceDestroyLock(pFile);\n    }\n  }\n  if( pFile->zDeleteOnClose ){\n    int cnt = 0;\n    while(\n           osDeleteFileW(pFile->zDeleteOnClose)==0\n        && osGetFileAttributesW(pFile->zDeleteOnClose)!=0xffffffff\n        && cnt++ < WINCE_DELETION_ATTEMPTS\n    ){\n       sqlite3_win32_sleep(100);  /* Wait a little before trying again */\n    }\n    sqlite3_free(pFile->zDeleteOnClose);\n  }\n#endif\n  if( rc ){\n    pFile->h = NULL;\n  }\n  OpenCounter(-1);\n  OSTRACE((\"CLOSE pid=%lu, pFile=%p, file=%p, rc=%s\\n\",\n           osGetCurrentProcessId(), pFile, pFile->h, rc ? \"ok\" : \"failed\"));\n  return rc ? SQLITE_OK\n            : winLogError(SQLITE_IOERR_CLOSE, osGetLastError(),\n                          \"winClose\", pFile->zPath);\n}\n\n/*\n** Read data from a file into a buffer.  Return SQLITE_OK if all\n** bytes were read successfully and SQLITE_IOERR if anything goes\n** wrong.\n*/\nstatic int winRead(\n  sqlite3_file *id,          /* File to read from */\n  void *pBuf,                /* Write content into this buffer */\n  int amt,                   /* Number of bytes to read */\n  sqlite3_int64 offset       /* Begin reading at this offset */\n){\n#if !SQLITE_OS_WINCE && !defined(SQLITE_WIN32_NO_OVERLAPPED)\n  OVERLAPPED overlapped;          /* The offset for ReadFile. */\n#endif\n  winFile *pFile = (winFile*)id;  /* file handle */\n  DWORD nRead;                    /* Number of bytes actually read from file */\n  int nRetry = 0;                 /* Number of retrys */\n\n  assert( id!=0 );\n  assert( amt>0 );\n  assert( offset>=0 );\n  SimulateIOError(return SQLITE_IOERR_READ);\n  OSTRACE((\"READ pid=%lu, pFile=%p, file=%p, buffer=%p, amount=%d, \"\n           \"offset=%lld, lock=%d\\n\", osGetCurrentProcessId(), pFile,\n           pFile->h, pBuf, amt, offset, pFile->locktype));\n\n#if SQLITE_MAX_MMAP_SIZE>0\n  /* Deal with as much of this read request as possible by transfering\n  ** data from the memory mapping using memcpy().  */\n  if( offset<pFile->mmapSize ){\n    if( offset+amt <= pFile->mmapSize ){\n      memcpy(pBuf, &((u8 *)(pFile->pMapRegion))[offset], amt);\n      OSTRACE((\"READ-MMAP pid=%lu, pFile=%p, file=%p, rc=SQLITE_OK\\n\",\n               osGetCurrentProcessId(), pFile, pFile->h));\n      return SQLITE_OK;\n    }else{\n      int nCopy = (int)(pFile->mmapSize - offset);\n      memcpy(pBuf, &((u8 *)(pFile->pMapRegion))[offset], nCopy);\n      pBuf = &((u8 *)pBuf)[nCopy];\n      amt -= nCopy;\n      offset += nCopy;\n    }\n  }\n#endif\n\n#if SQLITE_OS_WINCE || defined(SQLITE_WIN32_NO_OVERLAPPED)\n  if( winSeekFile(pFile, offset) ){\n    OSTRACE((\"READ pid=%lu, pFile=%p, file=%p, rc=SQLITE_FULL\\n\",\n             osGetCurrentProcessId(), pFile, pFile->h));\n    return SQLITE_FULL;\n  }\n  while( !osReadFile(pFile->h, pBuf, amt, &nRead, 0) ){\n#else\n  memset(&overlapped, 0, sizeof(OVERLAPPED));\n  overlapped.Offset = (LONG)(offset & 0xffffffff);\n  overlapped.OffsetHigh = (LONG)((offset>>32) & 0x7fffffff);\n  while( !osReadFile(pFile->h, pBuf, amt, &nRead, &overlapped) &&\n         osGetLastError()!=ERROR_HANDLE_EOF ){\n#endif\n    DWORD lastErrno;\n    if( winRetryIoerr(&nRetry, &lastErrno) ) continue;\n    pFile->lastErrno = lastErrno;\n    OSTRACE((\"READ pid=%lu, pFile=%p, file=%p, rc=SQLITE_IOERR_READ\\n\",\n             osGetCurrentProcessId(), pFile, pFile->h));\n    return winLogError(SQLITE_IOERR_READ, pFile->lastErrno,\n                       \"winRead\", pFile->zPath);\n  }\n  winLogIoerr(nRetry, __LINE__);\n  if( nRead<(DWORD)amt ){\n    /* Unread parts of the buffer must be zero-filled */\n    memset(&((char*)pBuf)[nRead], 0, amt-nRead);\n    OSTRACE((\"READ pid=%lu, pFile=%p, file=%p, rc=SQLITE_IOERR_SHORT_READ\\n\",\n             osGetCurrentProcessId(), pFile, pFile->h));\n    return SQLITE_IOERR_SHORT_READ;\n  }\n\n  OSTRACE((\"READ pid=%lu, pFile=%p, file=%p, rc=SQLITE_OK\\n\",\n           osGetCurrentProcessId(), pFile, pFile->h));\n  return SQLITE_OK;\n}\n\n/*\n** Write data from a buffer into a file.  Return SQLITE_OK on success\n** or some other error code on failure.\n*/\nstatic int winWrite(\n  sqlite3_file *id,               /* File to write into */\n  const void *pBuf,               /* The bytes to be written */\n  int amt,                        /* Number of bytes to write */\n  sqlite3_int64 offset            /* Offset into the file to begin writing at */\n){\n  int rc = 0;                     /* True if error has occurred, else false */\n  winFile *pFile = (winFile*)id;  /* File handle */\n  int nRetry = 0;                 /* Number of retries */\n\n  assert( amt>0 );\n  assert( pFile );\n  SimulateIOError(return SQLITE_IOERR_WRITE);\n  SimulateDiskfullError(return SQLITE_FULL);\n\n  OSTRACE((\"WRITE pid=%lu, pFile=%p, file=%p, buffer=%p, amount=%d, \"\n           \"offset=%lld, lock=%d\\n\", osGetCurrentProcessId(), pFile,\n           pFile->h, pBuf, amt, offset, pFile->locktype));\n\n#if defined(SQLITE_MMAP_READWRITE) && SQLITE_MAX_MMAP_SIZE>0\n  /* Deal with as much of this write request as possible by transfering\n  ** data from the memory mapping using memcpy().  */\n  if( offset<pFile->mmapSize ){\n    if( offset+amt <= pFile->mmapSize ){\n      memcpy(&((u8 *)(pFile->pMapRegion))[offset], pBuf, amt);\n      OSTRACE((\"WRITE-MMAP pid=%lu, pFile=%p, file=%p, rc=SQLITE_OK\\n\",\n               osGetCurrentProcessId(), pFile, pFile->h));\n      return SQLITE_OK;\n    }else{\n      int nCopy = (int)(pFile->mmapSize - offset);\n      memcpy(&((u8 *)(pFile->pMapRegion))[offset], pBuf, nCopy);\n      pBuf = &((u8 *)pBuf)[nCopy];\n      amt -= nCopy;\n      offset += nCopy;\n    }\n  }\n#endif\n\n#if SQLITE_OS_WINCE || defined(SQLITE_WIN32_NO_OVERLAPPED)\n  rc = winSeekFile(pFile, offset);\n  if( rc==0 ){\n#else\n  {\n#endif\n#if !SQLITE_OS_WINCE && !defined(SQLITE_WIN32_NO_OVERLAPPED)\n    OVERLAPPED overlapped;        /* The offset for WriteFile. */\n#endif\n    u8 *aRem = (u8 *)pBuf;        /* Data yet to be written */\n    int nRem = amt;               /* Number of bytes yet to be written */\n    DWORD nWrite;                 /* Bytes written by each WriteFile() call */\n    DWORD lastErrno = NO_ERROR;   /* Value returned by GetLastError() */\n\n#if !SQLITE_OS_WINCE && !defined(SQLITE_WIN32_NO_OVERLAPPED)\n    memset(&overlapped, 0, sizeof(OVERLAPPED));\n    overlapped.Offset = (LONG)(offset & 0xffffffff);\n    overlapped.OffsetHigh = (LONG)((offset>>32) & 0x7fffffff);\n#endif\n\n    while( nRem>0 ){\n#if SQLITE_OS_WINCE || defined(SQLITE_WIN32_NO_OVERLAPPED)\n      if( !osWriteFile(pFile->h, aRem, nRem, &nWrite, 0) ){\n#else\n      if( !osWriteFile(pFile->h, aRem, nRem, &nWrite, &overlapped) ){\n#endif\n        if( winRetryIoerr(&nRetry, &lastErrno) ) continue;\n        break;\n      }\n      assert( nWrite==0 || nWrite<=(DWORD)nRem );\n      if( nWrite==0 || nWrite>(DWORD)nRem ){\n        lastErrno = osGetLastError();\n        break;\n      }\n#if !SQLITE_OS_WINCE && !defined(SQLITE_WIN32_NO_OVERLAPPED)\n      offset += nWrite;\n      overlapped.Offset = (LONG)(offset & 0xffffffff);\n      overlapped.OffsetHigh = (LONG)((offset>>32) & 0x7fffffff);\n#endif\n      aRem += nWrite;\n      nRem -= nWrite;\n    }\n    if( nRem>0 ){\n      pFile->lastErrno = lastErrno;\n      rc = 1;\n    }\n  }\n\n  if( rc ){\n    if(   ( pFile->lastErrno==ERROR_HANDLE_DISK_FULL )\n       || ( pFile->lastErrno==ERROR_DISK_FULL )){\n      OSTRACE((\"WRITE pid=%lu, pFile=%p, file=%p, rc=SQLITE_FULL\\n\",\n               osGetCurrentProcessId(), pFile, pFile->h));\n      return winLogError(SQLITE_FULL, pFile->lastErrno,\n                         \"winWrite1\", pFile->zPath);\n    }\n    OSTRACE((\"WRITE pid=%lu, pFile=%p, file=%p, rc=SQLITE_IOERR_WRITE\\n\",\n             osGetCurrentProcessId(), pFile, pFile->h));\n    return winLogError(SQLITE_IOERR_WRITE, pFile->lastErrno,\n                       \"winWrite2\", pFile->zPath);\n  }else{\n    winLogIoerr(nRetry, __LINE__);\n  }\n  OSTRACE((\"WRITE pid=%lu, pFile=%p, file=%p, rc=SQLITE_OK\\n\",\n           osGetCurrentProcessId(), pFile, pFile->h));\n  return SQLITE_OK;\n}\n\n/*\n** Truncate an open file to a specified size\n*/\nstatic int winTruncate(sqlite3_file *id, sqlite3_int64 nByte){\n  winFile *pFile = (winFile*)id;  /* File handle object */\n  int rc = SQLITE_OK;             /* Return code for this function */\n  DWORD lastErrno;\n#if SQLITE_MAX_MMAP_SIZE>0\n  sqlite3_int64 oldMmapSize;\n  if( pFile->nFetchOut>0 ){\n    /* File truncation is a no-op if there are outstanding memory mapped\n    ** pages.  This is because truncating the file means temporarily unmapping\n    ** the file, and that might delete memory out from under existing cursors.\n    **\n    ** This can result in incremental vacuum not truncating the file,\n    ** if there is an active read cursor when the incremental vacuum occurs.\n    ** No real harm comes of this - the database file is not corrupted,\n    ** though some folks might complain that the file is bigger than it\n    ** needs to be.\n    **\n    ** The only feasible work-around is to defer the truncation until after\n    ** all references to memory-mapped content are closed.  That is doable,\n    ** but involves adding a few branches in the common write code path which\n    ** could slow down normal operations slightly.  Hence, we have decided for\n    ** now to simply make trancations a no-op if there are pending reads.  We\n    ** can maybe revisit this decision in the future.\n    */\n    return SQLITE_OK;\n  }\n#endif\n\n  assert( pFile );\n  SimulateIOError(return SQLITE_IOERR_TRUNCATE);\n  OSTRACE((\"TRUNCATE pid=%lu, pFile=%p, file=%p, size=%lld, lock=%d\\n\",\n           osGetCurrentProcessId(), pFile, pFile->h, nByte, pFile->locktype));\n\n  /* If the user has configured a chunk-size for this file, truncate the\n  ** file so that it consists of an integer number of chunks (i.e. the\n  ** actual file size after the operation may be larger than the requested\n  ** size).\n  */\n  if( pFile->szChunk>0 ){\n    nByte = ((nByte + pFile->szChunk - 1)/pFile->szChunk) * pFile->szChunk;\n  }\n\n#if SQLITE_MAX_MMAP_SIZE>0\n  if( pFile->pMapRegion ){\n    oldMmapSize = pFile->mmapSize;\n  }else{\n    oldMmapSize = 0;\n  }\n  winUnmapfile(pFile);\n#endif\n\n  /* SetEndOfFile() returns non-zero when successful, or zero when it fails. */\n  if( winSeekFile(pFile, nByte) ){\n    rc = winLogError(SQLITE_IOERR_TRUNCATE, pFile->lastErrno,\n                     \"winTruncate1\", pFile->zPath);\n  }else if( 0==osSetEndOfFile(pFile->h) &&\n            ((lastErrno = osGetLastError())!=ERROR_USER_MAPPED_FILE) ){\n    pFile->lastErrno = lastErrno;\n    rc = winLogError(SQLITE_IOERR_TRUNCATE, pFile->lastErrno,\n                     \"winTruncate2\", pFile->zPath);\n  }\n\n#if SQLITE_MAX_MMAP_SIZE>0\n  if( rc==SQLITE_OK && oldMmapSize>0 ){\n    if( oldMmapSize>nByte ){\n      winMapfile(pFile, -1);\n    }else{\n      winMapfile(pFile, oldMmapSize);\n    }\n  }\n#endif\n\n  OSTRACE((\"TRUNCATE pid=%lu, pFile=%p, file=%p, rc=%s\\n\",\n           osGetCurrentProcessId(), pFile, pFile->h, sqlite3ErrName(rc)));\n  return rc;\n}\n\n#ifdef SQLITE_TEST\n/*\n** Count the number of fullsyncs and normal syncs.  This is used to test\n** that syncs and fullsyncs are occuring at the right times.\n*/\nSQLITE_API int sqlite3_sync_count = 0;\nSQLITE_API int sqlite3_fullsync_count = 0;\n#endif\n\n/*\n** Make sure all writes to a particular file are committed to disk.\n*/\nstatic int winSync(sqlite3_file *id, int flags){\n#ifndef SQLITE_NO_SYNC\n  /*\n  ** Used only when SQLITE_NO_SYNC is not defined.\n   */\n  BOOL rc;\n#endif\n#if !defined(NDEBUG) || !defined(SQLITE_NO_SYNC) || \\\n    defined(SQLITE_HAVE_OS_TRACE)\n  /*\n  ** Used when SQLITE_NO_SYNC is not defined and by the assert() and/or\n  ** OSTRACE() macros.\n   */\n  winFile *pFile = (winFile*)id;\n#else\n  UNUSED_PARAMETER(id);\n#endif\n\n  assert( pFile );\n  /* Check that one of SQLITE_SYNC_NORMAL or FULL was passed */\n  assert((flags&0x0F)==SQLITE_SYNC_NORMAL\n      || (flags&0x0F)==SQLITE_SYNC_FULL\n  );\n\n  /* Unix cannot, but some systems may return SQLITE_FULL from here. This\n  ** line is to test that doing so does not cause any problems.\n  */\n  SimulateDiskfullError( return SQLITE_FULL );\n\n  OSTRACE((\"SYNC pid=%lu, pFile=%p, file=%p, flags=%x, lock=%d\\n\",\n           osGetCurrentProcessId(), pFile, pFile->h, flags,\n           pFile->locktype));\n\n#ifndef SQLITE_TEST\n  UNUSED_PARAMETER(flags);\n#else\n  if( (flags&0x0F)==SQLITE_SYNC_FULL ){\n    sqlite3_fullsync_count++;\n  }\n  sqlite3_sync_count++;\n#endif\n\n  /* If we compiled with the SQLITE_NO_SYNC flag, then syncing is a\n  ** no-op\n  */\n#ifdef SQLITE_NO_SYNC\n  OSTRACE((\"SYNC-NOP pid=%lu, pFile=%p, file=%p, rc=SQLITE_OK\\n\",\n           osGetCurrentProcessId(), pFile, pFile->h));\n  return SQLITE_OK;\n#else\n#if SQLITE_MAX_MMAP_SIZE>0\n  if( pFile->pMapRegion ){\n    if( osFlushViewOfFile(pFile->pMapRegion, 0) ){\n      OSTRACE((\"SYNC-MMAP pid=%lu, pFile=%p, pMapRegion=%p, \"\n               \"rc=SQLITE_OK\\n\", osGetCurrentProcessId(),\n               pFile, pFile->pMapRegion));\n    }else{\n      pFile->lastErrno = osGetLastError();\n      OSTRACE((\"SYNC-MMAP pid=%lu, pFile=%p, pMapRegion=%p, \"\n               \"rc=SQLITE_IOERR_MMAP\\n\", osGetCurrentProcessId(),\n               pFile, pFile->pMapRegion));\n      return winLogError(SQLITE_IOERR_MMAP, pFile->lastErrno,\n                         \"winSync1\", pFile->zPath);\n    }\n  }\n#endif\n  rc = osFlushFileBuffers(pFile->h);\n  SimulateIOError( rc=FALSE );\n  if( rc ){\n    OSTRACE((\"SYNC pid=%lu, pFile=%p, file=%p, rc=SQLITE_OK\\n\",\n             osGetCurrentProcessId(), pFile, pFile->h));\n    return SQLITE_OK;\n  }else{\n    pFile->lastErrno = osGetLastError();\n    OSTRACE((\"SYNC pid=%lu, pFile=%p, file=%p, rc=SQLITE_IOERR_FSYNC\\n\",\n             osGetCurrentProcessId(), pFile, pFile->h));\n    return winLogError(SQLITE_IOERR_FSYNC, pFile->lastErrno,\n                       \"winSync2\", pFile->zPath);\n  }\n#endif\n}\n\n/*\n** Determine the current size of a file in bytes\n*/\nstatic int winFileSize(sqlite3_file *id, sqlite3_int64 *pSize){\n  winFile *pFile = (winFile*)id;\n  int rc = SQLITE_OK;\n\n  assert( id!=0 );\n  assert( pSize!=0 );\n  SimulateIOError(return SQLITE_IOERR_FSTAT);\n  OSTRACE((\"SIZE file=%p, pSize=%p\\n\", pFile->h, pSize));\n\n#if SQLITE_OS_WINRT\n  {\n    FILE_STANDARD_INFO info;\n    if( osGetFileInformationByHandleEx(pFile->h, FileStandardInfo,\n                                     &info, sizeof(info)) ){\n      *pSize = info.EndOfFile.QuadPart;\n    }else{\n      pFile->lastErrno = osGetLastError();\n      rc = winLogError(SQLITE_IOERR_FSTAT, pFile->lastErrno,\n                       \"winFileSize\", pFile->zPath);\n    }\n  }\n#else\n  {\n    DWORD upperBits;\n    DWORD lowerBits;\n    DWORD lastErrno;\n\n    lowerBits = osGetFileSize(pFile->h, &upperBits);\n    *pSize = (((sqlite3_int64)upperBits)<<32) + lowerBits;\n    if(   (lowerBits == INVALID_FILE_SIZE)\n       && ((lastErrno = osGetLastError())!=NO_ERROR) ){\n      pFile->lastErrno = lastErrno;\n      rc = winLogError(SQLITE_IOERR_FSTAT, pFile->lastErrno,\n                       \"winFileSize\", pFile->zPath);\n    }\n  }\n#endif\n  OSTRACE((\"SIZE file=%p, pSize=%p, *pSize=%lld, rc=%s\\n\",\n           pFile->h, pSize, *pSize, sqlite3ErrName(rc)));\n  return rc;\n}\n\n/*\n** LOCKFILE_FAIL_IMMEDIATELY is undefined on some Windows systems.\n*/\n#ifndef LOCKFILE_FAIL_IMMEDIATELY\n# define LOCKFILE_FAIL_IMMEDIATELY 1\n#endif\n\n#ifndef LOCKFILE_EXCLUSIVE_LOCK\n# define LOCKFILE_EXCLUSIVE_LOCK 2\n#endif\n\n/*\n** Historically, SQLite has used both the LockFile and LockFileEx functions.\n** When the LockFile function was used, it was always expected to fail\n** immediately if the lock could not be obtained.  Also, it always expected to\n** obtain an exclusive lock.  These flags are used with the LockFileEx function\n** and reflect those expectations; therefore, they should not be changed.\n*/\n#ifndef SQLITE_LOCKFILE_FLAGS\n# define SQLITE_LOCKFILE_FLAGS   (LOCKFILE_FAIL_IMMEDIATELY | \\\n                                  LOCKFILE_EXCLUSIVE_LOCK)\n#endif\n\n/*\n** Currently, SQLite never calls the LockFileEx function without wanting the\n** call to fail immediately if the lock cannot be obtained.\n*/\n#ifndef SQLITE_LOCKFILEEX_FLAGS\n# define SQLITE_LOCKFILEEX_FLAGS (LOCKFILE_FAIL_IMMEDIATELY)\n#endif\n\n/*\n** Acquire a reader lock.\n** Different API routines are called depending on whether or not this\n** is Win9x or WinNT.\n*/\nstatic int winGetReadLock(winFile *pFile){\n  int res;\n  OSTRACE((\"READ-LOCK file=%p, lock=%d\\n\", pFile->h, pFile->locktype));\n  if( osIsNT() ){\n#if SQLITE_OS_WINCE\n    /*\n    ** NOTE: Windows CE is handled differently here due its lack of the Win32\n    **       API LockFileEx.\n    */\n    res = winceLockFile(&pFile->h, SHARED_FIRST, 0, 1, 0);\n#else\n    res = winLockFile(&pFile->h, SQLITE_LOCKFILEEX_FLAGS, SHARED_FIRST, 0,\n                      SHARED_SIZE, 0);\n#endif\n  }\n#ifdef SQLITE_WIN32_HAS_ANSI\n  else{\n    int lk;\n    sqlite3_randomness(sizeof(lk), &lk);\n    pFile->sharedLockByte = (short)((lk & 0x7fffffff)%(SHARED_SIZE - 1));\n    res = winLockFile(&pFile->h, SQLITE_LOCKFILE_FLAGS,\n                      SHARED_FIRST+pFile->sharedLockByte, 0, 1, 0);\n  }\n#endif\n  if( res == 0 ){\n    pFile->lastErrno = osGetLastError();\n    /* No need to log a failure to lock */\n  }\n  OSTRACE((\"READ-LOCK file=%p, result=%d\\n\", pFile->h, res));\n  return res;\n}\n\n/*\n** Undo a readlock\n*/\nstatic int winUnlockReadLock(winFile *pFile){\n  int res;\n  DWORD lastErrno;\n  OSTRACE((\"READ-UNLOCK file=%p, lock=%d\\n\", pFile->h, pFile->locktype));\n  if( osIsNT() ){\n    res = winUnlockFile(&pFile->h, SHARED_FIRST, 0, SHARED_SIZE, 0);\n  }\n#ifdef SQLITE_WIN32_HAS_ANSI\n  else{\n    res = winUnlockFile(&pFile->h, SHARED_FIRST+pFile->sharedLockByte, 0, 1, 0);\n  }\n#endif\n  if( res==0 && ((lastErrno = osGetLastError())!=ERROR_NOT_LOCKED) ){\n    pFile->lastErrno = lastErrno;\n    winLogError(SQLITE_IOERR_UNLOCK, pFile->lastErrno,\n                \"winUnlockReadLock\", pFile->zPath);\n  }\n  OSTRACE((\"READ-UNLOCK file=%p, result=%d\\n\", pFile->h, res));\n  return res;\n}\n\n/*\n** Lock the file with the lock specified by parameter locktype - one\n** of the following:\n**\n**     (1) SHARED_LOCK\n**     (2) RESERVED_LOCK\n**     (3) PENDING_LOCK\n**     (4) EXCLUSIVE_LOCK\n**\n** Sometimes when requesting one lock state, additional lock states\n** are inserted in between.  The locking might fail on one of the later\n** transitions leaving the lock state different from what it started but\n** still short of its goal.  The following chart shows the allowed\n** transitions and the inserted intermediate states:\n**\n**    UNLOCKED -> SHARED\n**    SHARED -> RESERVED\n**    SHARED -> (PENDING) -> EXCLUSIVE\n**    RESERVED -> (PENDING) -> EXCLUSIVE\n**    PENDING -> EXCLUSIVE\n**\n** This routine will only increase a lock.  The winUnlock() routine\n** erases all locks at once and returns us immediately to locking level 0.\n** It is not possible to lower the locking level one step at a time.  You\n** must go straight to locking level 0.\n*/\nstatic int winLock(sqlite3_file *id, int locktype){\n  int rc = SQLITE_OK;    /* Return code from subroutines */\n  int res = 1;           /* Result of a Windows lock call */\n  int newLocktype;       /* Set pFile->locktype to this value before exiting */\n  int gotPendingLock = 0;/* True if we acquired a PENDING lock this time */\n  winFile *pFile = (winFile*)id;\n  DWORD lastErrno = NO_ERROR;\n\n  assert( id!=0 );\n  OSTRACE((\"LOCK file=%p, oldLock=%d(%d), newLock=%d\\n\",\n           pFile->h, pFile->locktype, pFile->sharedLockByte, locktype));\n\n  /* If there is already a lock of this type or more restrictive on the\n  ** OsFile, do nothing. Don't use the end_lock: exit path, as\n  ** sqlite3OsEnterMutex() hasn't been called yet.\n  */\n  if( pFile->locktype>=locktype ){\n    OSTRACE((\"LOCK-HELD file=%p, rc=SQLITE_OK\\n\", pFile->h));\n    return SQLITE_OK;\n  }\n\n  /* Do not allow any kind of write-lock on a read-only database\n  */\n  if( (pFile->ctrlFlags & WINFILE_RDONLY)!=0 && locktype>=RESERVED_LOCK ){\n    return SQLITE_IOERR_LOCK;\n  }\n\n  /* Make sure the locking sequence is correct\n  */\n  assert( pFile->locktype!=NO_LOCK || locktype==SHARED_LOCK );\n  assert( locktype!=PENDING_LOCK );\n  assert( locktype!=RESERVED_LOCK || pFile->locktype==SHARED_LOCK );\n\n  /* Lock the PENDING_LOCK byte if we need to acquire a PENDING lock or\n  ** a SHARED lock.  If we are acquiring a SHARED lock, the acquisition of\n  ** the PENDING_LOCK byte is temporary.\n  */\n  newLocktype = pFile->locktype;\n  if( pFile->locktype==NO_LOCK\n   || (locktype==EXCLUSIVE_LOCK && pFile->locktype<=RESERVED_LOCK)\n  ){\n    int cnt = 3;\n    while( cnt-->0 && (res = winLockFile(&pFile->h, SQLITE_LOCKFILE_FLAGS,\n                                         PENDING_BYTE, 0, 1, 0))==0 ){\n      /* Try 3 times to get the pending lock.  This is needed to work\n      ** around problems caused by indexing and/or anti-virus software on\n      ** Windows systems.\n      ** If you are using this code as a model for alternative VFSes, do not\n      ** copy this retry logic.  It is a hack intended for Windows only.\n      */\n      lastErrno = osGetLastError();\n      OSTRACE((\"LOCK-PENDING-FAIL file=%p, count=%d, result=%d\\n\",\n               pFile->h, cnt, res));\n      if( lastErrno==ERROR_INVALID_HANDLE ){\n        pFile->lastErrno = lastErrno;\n        rc = SQLITE_IOERR_LOCK;\n        OSTRACE((\"LOCK-FAIL file=%p, count=%d, rc=%s\\n\",\n                 pFile->h, cnt, sqlite3ErrName(rc)));\n        return rc;\n      }\n      if( cnt ) sqlite3_win32_sleep(1);\n    }\n    gotPendingLock = res;\n    if( !res ){\n      lastErrno = osGetLastError();\n    }\n  }\n\n  /* Acquire a shared lock\n  */\n  if( locktype==SHARED_LOCK && res ){\n    assert( pFile->locktype==NO_LOCK );\n    res = winGetReadLock(pFile);\n    if( res ){\n      newLocktype = SHARED_LOCK;\n    }else{\n      lastErrno = osGetLastError();\n    }\n  }\n\n  /* Acquire a RESERVED lock\n  */\n  if( locktype==RESERVED_LOCK && res ){\n    assert( pFile->locktype==SHARED_LOCK );\n    res = winLockFile(&pFile->h, SQLITE_LOCKFILE_FLAGS, RESERVED_BYTE, 0, 1, 0);\n    if( res ){\n      newLocktype = RESERVED_LOCK;\n    }else{\n      lastErrno = osGetLastError();\n    }\n  }\n\n  /* Acquire a PENDING lock\n  */\n  if( locktype==EXCLUSIVE_LOCK && res ){\n    newLocktype = PENDING_LOCK;\n    gotPendingLock = 0;\n  }\n\n  /* Acquire an EXCLUSIVE lock\n  */\n  if( locktype==EXCLUSIVE_LOCK && res ){\n    assert( pFile->locktype>=SHARED_LOCK );\n    res = winUnlockReadLock(pFile);\n    res = winLockFile(&pFile->h, SQLITE_LOCKFILE_FLAGS, SHARED_FIRST, 0,\n                      SHARED_SIZE, 0);\n    if( res ){\n      newLocktype = EXCLUSIVE_LOCK;\n    }else{\n      lastErrno = osGetLastError();\n      winGetReadLock(pFile);\n    }\n  }\n\n  /* If we are holding a PENDING lock that ought to be released, then\n  ** release it now.\n  */\n  if( gotPendingLock && locktype==SHARED_LOCK ){\n    winUnlockFile(&pFile->h, PENDING_BYTE, 0, 1, 0);\n  }\n\n  /* Update the state of the lock has held in the file descriptor then\n  ** return the appropriate result code.\n  */\n  if( res ){\n    rc = SQLITE_OK;\n  }else{\n    pFile->lastErrno = lastErrno;\n    rc = SQLITE_BUSY;\n    OSTRACE((\"LOCK-FAIL file=%p, wanted=%d, got=%d\\n\",\n             pFile->h, locktype, newLocktype));\n  }\n  pFile->locktype = (u8)newLocktype;\n  OSTRACE((\"LOCK file=%p, lock=%d, rc=%s\\n\",\n           pFile->h, pFile->locktype, sqlite3ErrName(rc)));\n  return rc;\n}\n\n/*\n** This routine checks if there is a RESERVED lock held on the specified\n** file by this or any other process. If such a lock is held, return\n** non-zero, otherwise zero.\n*/\nstatic int winCheckReservedLock(sqlite3_file *id, int *pResOut){\n  int res;\n  winFile *pFile = (winFile*)id;\n\n  SimulateIOError( return SQLITE_IOERR_CHECKRESERVEDLOCK; );\n  OSTRACE((\"TEST-WR-LOCK file=%p, pResOut=%p\\n\", pFile->h, pResOut));\n\n  assert( id!=0 );\n  if( pFile->locktype>=RESERVED_LOCK ){\n    res = 1;\n    OSTRACE((\"TEST-WR-LOCK file=%p, result=%d (local)\\n\", pFile->h, res));\n  }else{\n    res = winLockFile(&pFile->h, SQLITE_LOCKFILEEX_FLAGS,RESERVED_BYTE,0,1,0);\n    if( res ){\n      winUnlockFile(&pFile->h, RESERVED_BYTE, 0, 1, 0);\n    }\n    res = !res;\n    OSTRACE((\"TEST-WR-LOCK file=%p, result=%d (remote)\\n\", pFile->h, res));\n  }\n  *pResOut = res;\n  OSTRACE((\"TEST-WR-LOCK file=%p, pResOut=%p, *pResOut=%d, rc=SQLITE_OK\\n\",\n           pFile->h, pResOut, *pResOut));\n  return SQLITE_OK;\n}\n\n/*\n** Lower the locking level on file descriptor id to locktype.  locktype\n** must be either NO_LOCK or SHARED_LOCK.\n**\n** If the locking level of the file descriptor is already at or below\n** the requested locking level, this routine is a no-op.\n**\n** It is not possible for this routine to fail if the second argument\n** is NO_LOCK.  If the second argument is SHARED_LOCK then this routine\n** might return SQLITE_IOERR;\n*/\nstatic int winUnlock(sqlite3_file *id, int locktype){\n  int type;\n  winFile *pFile = (winFile*)id;\n  int rc = SQLITE_OK;\n  assert( pFile!=0 );\n  assert( locktype<=SHARED_LOCK );\n  OSTRACE((\"UNLOCK file=%p, oldLock=%d(%d), newLock=%d\\n\",\n           pFile->h, pFile->locktype, pFile->sharedLockByte, locktype));\n  type = pFile->locktype;\n  if( type>=EXCLUSIVE_LOCK ){\n    winUnlockFile(&pFile->h, SHARED_FIRST, 0, SHARED_SIZE, 0);\n    if( locktype==SHARED_LOCK && !winGetReadLock(pFile) ){\n      /* This should never happen.  We should always be able to\n      ** reacquire the read lock */\n      rc = winLogError(SQLITE_IOERR_UNLOCK, osGetLastError(),\n                       \"winUnlock\", pFile->zPath);\n    }\n  }\n  if( type>=RESERVED_LOCK ){\n    winUnlockFile(&pFile->h, RESERVED_BYTE, 0, 1, 0);\n  }\n  if( locktype==NO_LOCK && type>=SHARED_LOCK ){\n    winUnlockReadLock(pFile);\n  }\n  if( type>=PENDING_LOCK ){\n    winUnlockFile(&pFile->h, PENDING_BYTE, 0, 1, 0);\n  }\n  pFile->locktype = (u8)locktype;\n  OSTRACE((\"UNLOCK file=%p, lock=%d, rc=%s\\n\",\n           pFile->h, pFile->locktype, sqlite3ErrName(rc)));\n  return rc;\n}\n\n/******************************************************************************\n****************************** No-op Locking **********************************\n**\n** Of the various locking implementations available, this is by far the\n** simplest:  locking is ignored.  No attempt is made to lock the database\n** file for reading or writing.\n**\n** This locking mode is appropriate for use on read-only databases\n** (ex: databases that are burned into CD-ROM, for example.)  It can\n** also be used if the application employs some external mechanism to\n** prevent simultaneous access of the same database by two or more\n** database connections.  But there is a serious risk of database\n** corruption if this locking mode is used in situations where multiple\n** database connections are accessing the same database file at the same\n** time and one or more of those connections are writing.\n*/\n\nstatic int winNolockLock(sqlite3_file *id, int locktype){\n  UNUSED_PARAMETER(id);\n  UNUSED_PARAMETER(locktype);\n  return SQLITE_OK;\n}\n\nstatic int winNolockCheckReservedLock(sqlite3_file *id, int *pResOut){\n  UNUSED_PARAMETER(id);\n  UNUSED_PARAMETER(pResOut);\n  return SQLITE_OK;\n}\n\nstatic int winNolockUnlock(sqlite3_file *id, int locktype){\n  UNUSED_PARAMETER(id);\n  UNUSED_PARAMETER(locktype);\n  return SQLITE_OK;\n}\n\n/******************* End of the no-op lock implementation *********************\n******************************************************************************/\n\n/*\n** If *pArg is initially negative then this is a query.  Set *pArg to\n** 1 or 0 depending on whether or not bit mask of pFile->ctrlFlags is set.\n**\n** If *pArg is 0 or 1, then clear or set the mask bit of pFile->ctrlFlags.\n*/\nstatic void winModeBit(winFile *pFile, unsigned char mask, int *pArg){\n  if( *pArg<0 ){\n    *pArg = (pFile->ctrlFlags & mask)!=0;\n  }else if( (*pArg)==0 ){\n    pFile->ctrlFlags &= ~mask;\n  }else{\n    pFile->ctrlFlags |= mask;\n  }\n}\n\n/* Forward references to VFS helper methods used for temporary files */\nstatic int winGetTempname(sqlite3_vfs *, char **);\nstatic int winIsDir(const void *);\nstatic BOOL winIsDriveLetterAndColon(const char *);\n\n/*\n** Control and query of the open file handle.\n*/\nstatic int winFileControl(sqlite3_file *id, int op, void *pArg){\n  winFile *pFile = (winFile*)id;\n  OSTRACE((\"FCNTL file=%p, op=%d, pArg=%p\\n\", pFile->h, op, pArg));\n  switch( op ){\n    case SQLITE_FCNTL_LOCKSTATE: {\n      *(int*)pArg = pFile->locktype;\n      OSTRACE((\"FCNTL file=%p, rc=SQLITE_OK\\n\", pFile->h));\n      return SQLITE_OK;\n    }\n    case SQLITE_FCNTL_LAST_ERRNO: {\n      *(int*)pArg = (int)pFile->lastErrno;\n      OSTRACE((\"FCNTL file=%p, rc=SQLITE_OK\\n\", pFile->h));\n      return SQLITE_OK;\n    }\n    case SQLITE_FCNTL_CHUNK_SIZE: {\n      pFile->szChunk = *(int *)pArg;\n      OSTRACE((\"FCNTL file=%p, rc=SQLITE_OK\\n\", pFile->h));\n      return SQLITE_OK;\n    }\n    case SQLITE_FCNTL_SIZE_HINT: {\n      if( pFile->szChunk>0 ){\n        sqlite3_int64 oldSz;\n        int rc = winFileSize(id, &oldSz);\n        if( rc==SQLITE_OK ){\n          sqlite3_int64 newSz = *(sqlite3_int64*)pArg;\n          if( newSz>oldSz ){\n            SimulateIOErrorBenign(1);\n            rc = winTruncate(id, newSz);\n            SimulateIOErrorBenign(0);\n          }\n        }\n        OSTRACE((\"FCNTL file=%p, rc=%s\\n\", pFile->h, sqlite3ErrName(rc)));\n        return rc;\n      }\n      OSTRACE((\"FCNTL file=%p, rc=SQLITE_OK\\n\", pFile->h));\n      return SQLITE_OK;\n    }\n    case SQLITE_FCNTL_PERSIST_WAL: {\n      winModeBit(pFile, WINFILE_PERSIST_WAL, (int*)pArg);\n      OSTRACE((\"FCNTL file=%p, rc=SQLITE_OK\\n\", pFile->h));\n      return SQLITE_OK;\n    }\n    case SQLITE_FCNTL_POWERSAFE_OVERWRITE: {\n      winModeBit(pFile, WINFILE_PSOW, (int*)pArg);\n      OSTRACE((\"FCNTL file=%p, rc=SQLITE_OK\\n\", pFile->h));\n      return SQLITE_OK;\n    }\n    case SQLITE_FCNTL_VFSNAME: {\n      *(char**)pArg = sqlite3_mprintf(\"%s\", pFile->pVfs->zName);\n      OSTRACE((\"FCNTL file=%p, rc=SQLITE_OK\\n\", pFile->h));\n      return SQLITE_OK;\n    }\n    case SQLITE_FCNTL_WIN32_AV_RETRY: {\n      int *a = (int*)pArg;\n      if( a[0]>0 ){\n        winIoerrRetry = a[0];\n      }else{\n        a[0] = winIoerrRetry;\n      }\n      if( a[1]>0 ){\n        winIoerrRetryDelay = a[1];\n      }else{\n        a[1] = winIoerrRetryDelay;\n      }\n      OSTRACE((\"FCNTL file=%p, rc=SQLITE_OK\\n\", pFile->h));\n      return SQLITE_OK;\n    }\n    case SQLITE_FCNTL_WIN32_GET_HANDLE: {\n      LPHANDLE phFile = (LPHANDLE)pArg;\n      *phFile = pFile->h;\n      OSTRACE((\"FCNTL file=%p, rc=SQLITE_OK\\n\", pFile->h));\n      return SQLITE_OK;\n    }\n#ifdef SQLITE_TEST\n    case SQLITE_FCNTL_WIN32_SET_HANDLE: {\n      LPHANDLE phFile = (LPHANDLE)pArg;\n      HANDLE hOldFile = pFile->h;\n      pFile->h = *phFile;\n      *phFile = hOldFile;\n      OSTRACE((\"FCNTL oldFile=%p, newFile=%p, rc=SQLITE_OK\\n\",\n               hOldFile, pFile->h));\n      return SQLITE_OK;\n    }\n#endif\n    case SQLITE_FCNTL_TEMPFILENAME: {\n      char *zTFile = 0;\n      int rc = winGetTempname(pFile->pVfs, &zTFile);\n      if( rc==SQLITE_OK ){\n        *(char**)pArg = zTFile;\n      }\n      OSTRACE((\"FCNTL file=%p, rc=%s\\n\", pFile->h, sqlite3ErrName(rc)));\n      return rc;\n    }\n#if SQLITE_MAX_MMAP_SIZE>0\n    case SQLITE_FCNTL_MMAP_SIZE: {\n      i64 newLimit = *(i64*)pArg;\n      int rc = SQLITE_OK;\n      if( newLimit>sqlite3GlobalConfig.mxMmap ){\n        newLimit = sqlite3GlobalConfig.mxMmap;\n      }\n\n      /* The value of newLimit may be eventually cast to (SIZE_T) and passed\n      ** to MapViewOfFile(). Restrict its value to 2GB if (SIZE_T) is not at\n      ** least a 64-bit type. */\n      if( newLimit>0 && sizeof(SIZE_T)<8 ){\n        newLimit = (newLimit & 0x7FFFFFFF);\n      }\n\n      *(i64*)pArg = pFile->mmapSizeMax;\n      if( newLimit>=0 && newLimit!=pFile->mmapSizeMax && pFile->nFetchOut==0 ){\n        pFile->mmapSizeMax = newLimit;\n        if( pFile->mmapSize>0 ){\n          winUnmapfile(pFile);\n          rc = winMapfile(pFile, -1);\n        }\n      }\n      OSTRACE((\"FCNTL file=%p, rc=%s\\n\", pFile->h, sqlite3ErrName(rc)));\n      return rc;\n    }\n#endif\n  }\n  OSTRACE((\"FCNTL file=%p, rc=SQLITE_NOTFOUND\\n\", pFile->h));\n  return SQLITE_NOTFOUND;\n}\n\n/*\n** Return the sector size in bytes of the underlying block device for\n** the specified file. This is almost always 512 bytes, but may be\n** larger for some devices.\n**\n** SQLite code assumes this function cannot fail. It also assumes that\n** if two files are created in the same file-system directory (i.e.\n** a database and its journal file) that the sector size will be the\n** same for both.\n*/\nstatic int winSectorSize(sqlite3_file *id){\n  (void)id;\n  return SQLITE_DEFAULT_SECTOR_SIZE;\n}\n\n/*\n** Return a vector of device characteristics.\n*/\nstatic int winDeviceCharacteristics(sqlite3_file *id){\n  winFile *p = (winFile*)id;\n  return SQLITE_IOCAP_UNDELETABLE_WHEN_OPEN |\n         ((p->ctrlFlags & WINFILE_PSOW)?SQLITE_IOCAP_POWERSAFE_OVERWRITE:0);\n}\n\n/*\n** Windows will only let you create file view mappings\n** on allocation size granularity boundaries.\n** During sqlite3_os_init() we do a GetSystemInfo()\n** to get the granularity size.\n*/\nstatic SYSTEM_INFO winSysInfo;\n\n#ifndef SQLITE_OMIT_WAL\n\n/*\n** Helper functions to obtain and relinquish the global mutex. The\n** global mutex is used to protect the winLockInfo objects used by\n** this file, all of which may be shared by multiple threads.\n**\n** Function winShmMutexHeld() is used to assert() that the global mutex\n** is held when required. This function is only used as part of assert()\n** statements. e.g.\n**\n**   winShmEnterMutex()\n**     assert( winShmMutexHeld() );\n**   winShmLeaveMutex()\n*/\nstatic sqlite3_mutex *winBigLock = 0;\nstatic void winShmEnterMutex(void){\n  sqlite3_mutex_enter(winBigLock);\n}\nstatic void winShmLeaveMutex(void){\n  sqlite3_mutex_leave(winBigLock);\n}\n#ifndef NDEBUG\nstatic int winShmMutexHeld(void) {\n  return sqlite3_mutex_held(winBigLock);\n}\n#endif\n\n/*\n** Object used to represent a single file opened and mmapped to provide\n** shared memory.  When multiple threads all reference the same\n** log-summary, each thread has its own winFile object, but they all\n** point to a single instance of this object.  In other words, each\n** log-summary is opened only once per process.\n**\n** winShmMutexHeld() must be true when creating or destroying\n** this object or while reading or writing the following fields:\n**\n**      nRef\n**      pNext\n**\n** The following fields are read-only after the object is created:\n**\n**      fid\n**      zFilename\n**\n** Either winShmNode.mutex must be held or winShmNode.nRef==0 and\n** winShmMutexHeld() is true when reading or writing any other field\n** in this structure.\n**\n*/\nstruct winShmNode {\n  sqlite3_mutex *mutex;      /* Mutex to access this object */\n  char *zFilename;           /* Name of the file */\n  winFile hFile;             /* File handle from winOpen */\n\n  int szRegion;              /* Size of shared-memory regions */\n  int nRegion;               /* Size of array apRegion */\n  u8 isReadonly;             /* True if read-only */\n  u8 isUnlocked;             /* True if no DMS lock held */\n\n  struct ShmRegion {\n    HANDLE hMap;             /* File handle from CreateFileMapping */\n    void *pMap;\n  } *aRegion;\n  DWORD lastErrno;           /* The Windows errno from the last I/O error */\n\n  int nRef;                  /* Number of winShm objects pointing to this */\n  winShm *pFirst;            /* All winShm objects pointing to this */\n  winShmNode *pNext;         /* Next in list of all winShmNode objects */\n#if defined(SQLITE_DEBUG) || defined(SQLITE_HAVE_OS_TRACE)\n  u8 nextShmId;              /* Next available winShm.id value */\n#endif\n};\n\n/*\n** A global array of all winShmNode objects.\n**\n** The winShmMutexHeld() must be true while reading or writing this list.\n*/\nstatic winShmNode *winShmNodeList = 0;\n\n/*\n** Structure used internally by this VFS to record the state of an\n** open shared memory connection.\n**\n** The following fields are initialized when this object is created and\n** are read-only thereafter:\n**\n**    winShm.pShmNode\n**    winShm.id\n**\n** All other fields are read/write.  The winShm.pShmNode->mutex must be held\n** while accessing any read/write fields.\n*/\nstruct winShm {\n  winShmNode *pShmNode;      /* The underlying winShmNode object */\n  winShm *pNext;             /* Next winShm with the same winShmNode */\n  u8 hasMutex;               /* True if holding the winShmNode mutex */\n  u16 sharedMask;            /* Mask of shared locks held */\n  u16 exclMask;              /* Mask of exclusive locks held */\n#if defined(SQLITE_DEBUG) || defined(SQLITE_HAVE_OS_TRACE)\n  u8 id;                     /* Id of this connection with its winShmNode */\n#endif\n};\n\n/*\n** Constants used for locking\n*/\n#define WIN_SHM_BASE   ((22+SQLITE_SHM_NLOCK)*4)        /* first lock byte */\n#define WIN_SHM_DMS    (WIN_SHM_BASE+SQLITE_SHM_NLOCK)  /* deadman switch */\n\n/*\n** Apply advisory locks for all n bytes beginning at ofst.\n*/\n#define WINSHM_UNLCK  1\n#define WINSHM_RDLCK  2\n#define WINSHM_WRLCK  3\nstatic int winShmSystemLock(\n  winShmNode *pFile,    /* Apply locks to this open shared-memory segment */\n  int lockType,         /* WINSHM_UNLCK, WINSHM_RDLCK, or WINSHM_WRLCK */\n  int ofst,             /* Offset to first byte to be locked/unlocked */\n  int nByte             /* Number of bytes to lock or unlock */\n){\n  int rc = 0;           /* Result code form Lock/UnlockFileEx() */\n\n  /* Access to the winShmNode object is serialized by the caller */\n  assert( pFile->nRef==0 || sqlite3_mutex_held(pFile->mutex) );\n\n  OSTRACE((\"SHM-LOCK file=%p, lock=%d, offset=%d, size=%d\\n\",\n           pFile->hFile.h, lockType, ofst, nByte));\n\n  /* Release/Acquire the system-level lock */\n  if( lockType==WINSHM_UNLCK ){\n    rc = winUnlockFile(&pFile->hFile.h, ofst, 0, nByte, 0);\n  }else{\n    /* Initialize the locking parameters */\n    DWORD dwFlags = LOCKFILE_FAIL_IMMEDIATELY;\n    if( lockType == WINSHM_WRLCK ) dwFlags |= LOCKFILE_EXCLUSIVE_LOCK;\n    rc = winLockFile(&pFile->hFile.h, dwFlags, ofst, 0, nByte, 0);\n  }\n\n  if( rc!= 0 ){\n    rc = SQLITE_OK;\n  }else{\n    pFile->lastErrno =  osGetLastError();\n    rc = SQLITE_BUSY;\n  }\n\n  OSTRACE((\"SHM-LOCK file=%p, func=%s, errno=%lu, rc=%s\\n\",\n           pFile->hFile.h, (lockType == WINSHM_UNLCK) ? \"winUnlockFile\" :\n           \"winLockFile\", pFile->lastErrno, sqlite3ErrName(rc)));\n\n  return rc;\n}\n\n/* Forward references to VFS methods */\nstatic int winOpen(sqlite3_vfs*,const char*,sqlite3_file*,int,int*);\nstatic int winDelete(sqlite3_vfs *,const char*,int);\n\n/*\n** Purge the winShmNodeList list of all entries with winShmNode.nRef==0.\n**\n** This is not a VFS shared-memory method; it is a utility function called\n** by VFS shared-memory methods.\n*/\nstatic void winShmPurge(sqlite3_vfs *pVfs, int deleteFlag){\n  winShmNode **pp;\n  winShmNode *p;\n  assert( winShmMutexHeld() );\n  OSTRACE((\"SHM-PURGE pid=%lu, deleteFlag=%d\\n\",\n           osGetCurrentProcessId(), deleteFlag));\n  pp = &winShmNodeList;\n  while( (p = *pp)!=0 ){\n    if( p->nRef==0 ){\n      int i;\n      if( p->mutex ){ sqlite3_mutex_free(p->mutex); }\n      for(i=0; i<p->nRegion; i++){\n        BOOL bRc = osUnmapViewOfFile(p->aRegion[i].pMap);\n        OSTRACE((\"SHM-PURGE-UNMAP pid=%lu, region=%d, rc=%s\\n\",\n                 osGetCurrentProcessId(), i, bRc ? \"ok\" : \"failed\"));\n        UNUSED_VARIABLE_VALUE(bRc);\n        bRc = osCloseHandle(p->aRegion[i].hMap);\n        OSTRACE((\"SHM-PURGE-CLOSE pid=%lu, region=%d, rc=%s\\n\",\n                 osGetCurrentProcessId(), i, bRc ? \"ok\" : \"failed\"));\n        UNUSED_VARIABLE_VALUE(bRc);\n      }\n      if( p->hFile.h!=NULL && p->hFile.h!=INVALID_HANDLE_VALUE ){\n        SimulateIOErrorBenign(1);\n        winClose((sqlite3_file *)&p->hFile);\n        SimulateIOErrorBenign(0);\n      }\n      if( deleteFlag ){\n        SimulateIOErrorBenign(1);\n        sqlite3BeginBenignMalloc();\n        winDelete(pVfs, p->zFilename, 0);\n        sqlite3EndBenignMalloc();\n        SimulateIOErrorBenign(0);\n      }\n      *pp = p->pNext;\n      sqlite3_free(p->aRegion);\n      sqlite3_free(p);\n    }else{\n      pp = &p->pNext;\n    }\n  }\n}\n\n/*\n** The DMS lock has not yet been taken on shm file pShmNode. Attempt to\n** take it now. Return SQLITE_OK if successful, or an SQLite error\n** code otherwise.\n**\n** If the DMS cannot be locked because this is a readonly_shm=1\n** connection and no other process already holds a lock, return\n** SQLITE_READONLY_CANTINIT and set pShmNode->isUnlocked=1.\n*/\nstatic int winLockSharedMemory(winShmNode *pShmNode){\n  int rc = winShmSystemLock(pShmNode, WINSHM_WRLCK, WIN_SHM_DMS, 1);\n\n  if( rc==SQLITE_OK ){\n    if( pShmNode->isReadonly ){\n      pShmNode->isUnlocked = 1;\n      winShmSystemLock(pShmNode, WINSHM_UNLCK, WIN_SHM_DMS, 1);\n      return SQLITE_READONLY_CANTINIT;\n    }else if( winTruncate((sqlite3_file*)&pShmNode->hFile, 0) ){\n      winShmSystemLock(pShmNode, WINSHM_UNLCK, WIN_SHM_DMS, 1);\n      return winLogError(SQLITE_IOERR_SHMOPEN, osGetLastError(),\n                         \"winLockSharedMemory\", pShmNode->zFilename);\n    }\n  }\n\n  if( rc==SQLITE_OK ){\n    winShmSystemLock(pShmNode, WINSHM_UNLCK, WIN_SHM_DMS, 1);\n  }\n\n  return winShmSystemLock(pShmNode, WINSHM_RDLCK, WIN_SHM_DMS, 1);\n}\n\n/*\n** Open the shared-memory area associated with database file pDbFd.\n**\n** When opening a new shared-memory file, if no other instances of that\n** file are currently open, in this process or in other processes, then\n** the file must be truncated to zero length or have its header cleared.\n*/\nstatic int winOpenSharedMemory(winFile *pDbFd){\n  struct winShm *p;                  /* The connection to be opened */\n  winShmNode *pShmNode = 0;          /* The underlying mmapped file */\n  int rc = SQLITE_OK;                /* Result code */\n  winShmNode *pNew;                  /* Newly allocated winShmNode */\n  int nName;                         /* Size of zName in bytes */\n\n  assert( pDbFd->pShm==0 );    /* Not previously opened */\n\n  /* Allocate space for the new sqlite3_shm object.  Also speculatively\n  ** allocate space for a new winShmNode and filename.\n  */\n  p = sqlite3MallocZero( sizeof(*p) );\n  if( p==0 ) return SQLITE_IOERR_NOMEM_BKPT;\n  nName = sqlite3Strlen30(pDbFd->zPath);\n  pNew = sqlite3MallocZero( sizeof(*pShmNode) + nName + 17 );\n  if( pNew==0 ){\n    sqlite3_free(p);\n    return SQLITE_IOERR_NOMEM_BKPT;\n  }\n  pNew->zFilename = (char*)&pNew[1];\n  sqlite3_snprintf(nName+15, pNew->zFilename, \"%s-shm\", pDbFd->zPath);\n  sqlite3FileSuffix3(pDbFd->zPath, pNew->zFilename);\n\n  /* Look to see if there is an existing winShmNode that can be used.\n  ** If no matching winShmNode currently exists, create a new one.\n  */\n  winShmEnterMutex();\n  for(pShmNode = winShmNodeList; pShmNode; pShmNode=pShmNode->pNext){\n    /* TBD need to come up with better match here.  Perhaps\n    ** use FILE_ID_BOTH_DIR_INFO Structure.\n    */\n    if( sqlite3StrICmp(pShmNode->zFilename, pNew->zFilename)==0 ) break;\n  }\n  if( pShmNode ){\n    sqlite3_free(pNew);\n  }else{\n    int inFlags = SQLITE_OPEN_WAL;\n    int outFlags = 0;\n\n    pShmNode = pNew;\n    pNew = 0;\n    ((winFile*)(&pShmNode->hFile))->h = INVALID_HANDLE_VALUE;\n    pShmNode->pNext = winShmNodeList;\n    winShmNodeList = pShmNode;\n\n    if( sqlite3GlobalConfig.bCoreMutex ){\n      pShmNode->mutex = sqlite3_mutex_alloc(SQLITE_MUTEX_FAST);\n      if( pShmNode->mutex==0 ){\n        rc = SQLITE_IOERR_NOMEM_BKPT;\n        goto shm_open_err;\n      }\n    }\n\n    if( 0==sqlite3_uri_boolean(pDbFd->zPath, \"readonly_shm\", 0) ){\n      inFlags |= SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE;\n    }else{\n      inFlags |= SQLITE_OPEN_READONLY;\n    }\n    rc = winOpen(pDbFd->pVfs, pShmNode->zFilename,\n                 (sqlite3_file*)&pShmNode->hFile,\n                 inFlags, &outFlags);\n    if( rc!=SQLITE_OK ){\n      rc = winLogError(rc, osGetLastError(), \"winOpenShm\",\n                       pShmNode->zFilename);\n      goto shm_open_err;\n    }\n    if( outFlags==SQLITE_OPEN_READONLY ) pShmNode->isReadonly = 1;\n\n    rc = winLockSharedMemory(pShmNode);\n    if( rc!=SQLITE_OK && rc!=SQLITE_READONLY_CANTINIT ) goto shm_open_err;\n  }\n\n  /* Make the new connection a child of the winShmNode */\n  p->pShmNode = pShmNode;\n#if defined(SQLITE_DEBUG) || defined(SQLITE_HAVE_OS_TRACE)\n  p->id = pShmNode->nextShmId++;\n#endif\n  pShmNode->nRef++;\n  pDbFd->pShm = p;\n  winShmLeaveMutex();\n\n  /* The reference count on pShmNode has already been incremented under\n  ** the cover of the winShmEnterMutex() mutex and the pointer from the\n  ** new (struct winShm) object to the pShmNode has been set. All that is\n  ** left to do is to link the new object into the linked list starting\n  ** at pShmNode->pFirst. This must be done while holding the pShmNode->mutex\n  ** mutex.\n  */\n  sqlite3_mutex_enter(pShmNode->mutex);\n  p->pNext = pShmNode->pFirst;\n  pShmNode->pFirst = p;\n  sqlite3_mutex_leave(pShmNode->mutex);\n  return rc;\n\n  /* Jump here on any error */\nshm_open_err:\n  winShmSystemLock(pShmNode, WINSHM_UNLCK, WIN_SHM_DMS, 1);\n  winShmPurge(pDbFd->pVfs, 0);      /* This call frees pShmNode if required */\n  sqlite3_free(p);\n  sqlite3_free(pNew);\n  winShmLeaveMutex();\n  return rc;\n}\n\n/*\n** Close a connection to shared-memory.  Delete the underlying\n** storage if deleteFlag is true.\n*/\nstatic int winShmUnmap(\n  sqlite3_file *fd,          /* Database holding shared memory */\n  int deleteFlag             /* Delete after closing if true */\n){\n  winFile *pDbFd;       /* Database holding shared-memory */\n  winShm *p;            /* The connection to be closed */\n  winShmNode *pShmNode; /* The underlying shared-memory file */\n  winShm **pp;          /* For looping over sibling connections */\n\n  pDbFd = (winFile*)fd;\n  p = pDbFd->pShm;\n  if( p==0 ) return SQLITE_OK;\n  pShmNode = p->pShmNode;\n\n  /* Remove connection p from the set of connections associated\n  ** with pShmNode */\n  sqlite3_mutex_enter(pShmNode->mutex);\n  for(pp=&pShmNode->pFirst; (*pp)!=p; pp = &(*pp)->pNext){}\n  *pp = p->pNext;\n\n  /* Free the connection p */\n  sqlite3_free(p);\n  pDbFd->pShm = 0;\n  sqlite3_mutex_leave(pShmNode->mutex);\n\n  /* If pShmNode->nRef has reached 0, then close the underlying\n  ** shared-memory file, too */\n  winShmEnterMutex();\n  assert( pShmNode->nRef>0 );\n  pShmNode->nRef--;\n  if( pShmNode->nRef==0 ){\n    winShmPurge(pDbFd->pVfs, deleteFlag);\n  }\n  winShmLeaveMutex();\n\n  return SQLITE_OK;\n}\n\n/*\n** Change the lock state for a shared-memory segment.\n*/\nstatic int winShmLock(\n  sqlite3_file *fd,          /* Database file holding the shared memory */\n  int ofst,                  /* First lock to acquire or release */\n  int n,                     /* Number of locks to acquire or release */\n  int flags                  /* What to do with the lock */\n){\n  winFile *pDbFd = (winFile*)fd;        /* Connection holding shared memory */\n  winShm *p = pDbFd->pShm;              /* The shared memory being locked */\n  winShm *pX;                           /* For looping over all siblings */\n  winShmNode *pShmNode = p->pShmNode;\n  int rc = SQLITE_OK;                   /* Result code */\n  u16 mask;                             /* Mask of locks to take or release */\n\n  assert( ofst>=0 && ofst+n<=SQLITE_SHM_NLOCK );\n  assert( n>=1 );\n  assert( flags==(SQLITE_SHM_LOCK | SQLITE_SHM_SHARED)\n       || flags==(SQLITE_SHM_LOCK | SQLITE_SHM_EXCLUSIVE)\n       || flags==(SQLITE_SHM_UNLOCK | SQLITE_SHM_SHARED)\n       || flags==(SQLITE_SHM_UNLOCK | SQLITE_SHM_EXCLUSIVE) );\n  assert( n==1 || (flags & SQLITE_SHM_EXCLUSIVE)!=0 );\n\n  mask = (u16)((1U<<(ofst+n)) - (1U<<ofst));\n  assert( n>1 || mask==(1<<ofst) );\n  sqlite3_mutex_enter(pShmNode->mutex);\n  if( flags & SQLITE_SHM_UNLOCK ){\n    u16 allMask = 0; /* Mask of locks held by siblings */\n\n    /* See if any siblings hold this same lock */\n    for(pX=pShmNode->pFirst; pX; pX=pX->pNext){\n      if( pX==p ) continue;\n      assert( (pX->exclMask & (p->exclMask|p->sharedMask))==0 );\n      allMask |= pX->sharedMask;\n    }\n\n    /* Unlock the system-level locks */\n    if( (mask & allMask)==0 ){\n      rc = winShmSystemLock(pShmNode, WINSHM_UNLCK, ofst+WIN_SHM_BASE, n);\n    }else{\n      rc = SQLITE_OK;\n    }\n\n    /* Undo the local locks */\n    if( rc==SQLITE_OK ){\n      p->exclMask &= ~mask;\n      p->sharedMask &= ~mask;\n    }\n  }else if( flags & SQLITE_SHM_SHARED ){\n    u16 allShared = 0;  /* Union of locks held by connections other than \"p\" */\n\n    /* Find out which shared locks are already held by sibling connections.\n    ** If any sibling already holds an exclusive lock, go ahead and return\n    ** SQLITE_BUSY.\n    */\n    for(pX=pShmNode->pFirst; pX; pX=pX->pNext){\n      if( (pX->exclMask & mask)!=0 ){\n        rc = SQLITE_BUSY;\n        break;\n      }\n      allShared |= pX->sharedMask;\n    }\n\n    /* Get shared locks at the system level, if necessary */\n    if( rc==SQLITE_OK ){\n      if( (allShared & mask)==0 ){\n        rc = winShmSystemLock(pShmNode, WINSHM_RDLCK, ofst+WIN_SHM_BASE, n);\n      }else{\n        rc = SQLITE_OK;\n      }\n    }\n\n    /* Get the local shared locks */\n    if( rc==SQLITE_OK ){\n      p->sharedMask |= mask;\n    }\n  }else{\n    /* Make sure no sibling connections hold locks that will block this\n    ** lock.  If any do, return SQLITE_BUSY right away.\n    */\n    for(pX=pShmNode->pFirst; pX; pX=pX->pNext){\n      if( (pX->exclMask & mask)!=0 || (pX->sharedMask & mask)!=0 ){\n        rc = SQLITE_BUSY;\n        break;\n      }\n    }\n\n    /* Get the exclusive locks at the system level.  Then if successful\n    ** also mark the local connection as being locked.\n    */\n    if( rc==SQLITE_OK ){\n      rc = winShmSystemLock(pShmNode, WINSHM_WRLCK, ofst+WIN_SHM_BASE, n);\n      if( rc==SQLITE_OK ){\n        assert( (p->sharedMask & mask)==0 );\n        p->exclMask |= mask;\n      }\n    }\n  }\n  sqlite3_mutex_leave(pShmNode->mutex);\n  OSTRACE((\"SHM-LOCK pid=%lu, id=%d, sharedMask=%03x, exclMask=%03x, rc=%s\\n\",\n           osGetCurrentProcessId(), p->id, p->sharedMask, p->exclMask,\n           sqlite3ErrName(rc)));\n  return rc;\n}\n\n/*\n** Implement a memory barrier or memory fence on shared memory.\n**\n** All loads and stores begun before the barrier must complete before\n** any load or store begun after the barrier.\n*/\nstatic void winShmBarrier(\n  sqlite3_file *fd          /* Database holding the shared memory */\n){\n  UNUSED_PARAMETER(fd);\n  sqlite3MemoryBarrier();   /* compiler-defined memory barrier */\n  winShmEnterMutex();       /* Also mutex, for redundancy */\n  winShmLeaveMutex();\n}\n\n/*\n** This function is called to obtain a pointer to region iRegion of the\n** shared-memory associated with the database file fd. Shared-memory regions\n** are numbered starting from zero. Each shared-memory region is szRegion\n** bytes in size.\n**\n** If an error occurs, an error code is returned and *pp is set to NULL.\n**\n** Otherwise, if the isWrite parameter is 0 and the requested shared-memory\n** region has not been allocated (by any client, including one running in a\n** separate process), then *pp is set to NULL and SQLITE_OK returned. If\n** isWrite is non-zero and the requested shared-memory region has not yet\n** been allocated, it is allocated by this function.\n**\n** If the shared-memory region has already been allocated or is allocated by\n** this call as described above, then it is mapped into this processes\n** address space (if it is not already), *pp is set to point to the mapped\n** memory and SQLITE_OK returned.\n*/\nstatic int winShmMap(\n  sqlite3_file *fd,               /* Handle open on database file */\n  int iRegion,                    /* Region to retrieve */\n  int szRegion,                   /* Size of regions */\n  int isWrite,                    /* True to extend file if necessary */\n  void volatile **pp              /* OUT: Mapped memory */\n){\n  winFile *pDbFd = (winFile*)fd;\n  winShm *pShm = pDbFd->pShm;\n  winShmNode *pShmNode;\n  DWORD protect = PAGE_READWRITE;\n  DWORD flags = FILE_MAP_WRITE | FILE_MAP_READ;\n  int rc = SQLITE_OK;\n\n  if( !pShm ){\n    rc = winOpenSharedMemory(pDbFd);\n    if( rc!=SQLITE_OK ) return rc;\n    pShm = pDbFd->pShm;\n  }\n  pShmNode = pShm->pShmNode;\n\n  sqlite3_mutex_enter(pShmNode->mutex);\n  if( pShmNode->isUnlocked ){\n    rc = winLockSharedMemory(pShmNode);\n    if( rc!=SQLITE_OK ) goto shmpage_out;\n    pShmNode->isUnlocked = 0;\n  }\n  assert( szRegion==pShmNode->szRegion || pShmNode->nRegion==0 );\n\n  if( pShmNode->nRegion<=iRegion ){\n    struct ShmRegion *apNew;           /* New aRegion[] array */\n    int nByte = (iRegion+1)*szRegion;  /* Minimum required file size */\n    sqlite3_int64 sz;                  /* Current size of wal-index file */\n\n    pShmNode->szRegion = szRegion;\n\n    /* The requested region is not mapped into this processes address space.\n    ** Check to see if it has been allocated (i.e. if the wal-index file is\n    ** large enough to contain the requested region).\n    */\n    rc = winFileSize((sqlite3_file *)&pShmNode->hFile, &sz);\n    if( rc!=SQLITE_OK ){\n      rc = winLogError(SQLITE_IOERR_SHMSIZE, osGetLastError(),\n                       \"winShmMap1\", pDbFd->zPath);\n      goto shmpage_out;\n    }\n\n    if( sz<nByte ){\n      /* The requested memory region does not exist. If isWrite is set to\n      ** zero, exit early. *pp will be set to NULL and SQLITE_OK returned.\n      **\n      ** Alternatively, if isWrite is non-zero, use ftruncate() to allocate\n      ** the requested memory region.\n      */\n      if( !isWrite ) goto shmpage_out;\n      rc = winTruncate((sqlite3_file *)&pShmNode->hFile, nByte);\n      if( rc!=SQLITE_OK ){\n        rc = winLogError(SQLITE_IOERR_SHMSIZE, osGetLastError(),\n                         \"winShmMap2\", pDbFd->zPath);\n        goto shmpage_out;\n      }\n    }\n\n    /* Map the requested memory region into this processes address space. */\n    apNew = (struct ShmRegion *)sqlite3_realloc64(\n        pShmNode->aRegion, (iRegion+1)*sizeof(apNew[0])\n    );\n    if( !apNew ){\n      rc = SQLITE_IOERR_NOMEM_BKPT;\n      goto shmpage_out;\n    }\n    pShmNode->aRegion = apNew;\n\n    if( pShmNode->isReadonly ){\n      protect = PAGE_READONLY;\n      flags = FILE_MAP_READ;\n    }\n\n    while( pShmNode->nRegion<=iRegion ){\n      HANDLE hMap = NULL;         /* file-mapping handle */\n      void *pMap = 0;             /* Mapped memory region */\n\n#if SQLITE_OS_WINRT\n      hMap = osCreateFileMappingFromApp(pShmNode->hFile.h,\n          NULL, protect, nByte, NULL\n      );\n#elif defined(SQLITE_WIN32_HAS_WIDE)\n      hMap = osCreateFileMappingW(pShmNode->hFile.h,\n          NULL, protect, 0, nByte, NULL\n      );\n#elif defined(SQLITE_WIN32_HAS_ANSI) && SQLITE_WIN32_CREATEFILEMAPPINGA\n      hMap = osCreateFileMappingA(pShmNode->hFile.h,\n          NULL, protect, 0, nByte, NULL\n      );\n#endif\n      OSTRACE((\"SHM-MAP-CREATE pid=%lu, region=%d, size=%d, rc=%s\\n\",\n               osGetCurrentProcessId(), pShmNode->nRegion, nByte,\n               hMap ? \"ok\" : \"failed\"));\n      if( hMap ){\n        int iOffset = pShmNode->nRegion*szRegion;\n        int iOffsetShift = iOffset % winSysInfo.dwAllocationGranularity;\n#if SQLITE_OS_WINRT\n        pMap = osMapViewOfFileFromApp(hMap, flags,\n            iOffset - iOffsetShift, szRegion + iOffsetShift\n        );\n#else\n        pMap = osMapViewOfFile(hMap, flags,\n            0, iOffset - iOffsetShift, szRegion + iOffsetShift\n        );\n#endif\n        OSTRACE((\"SHM-MAP-MAP pid=%lu, region=%d, offset=%d, size=%d, rc=%s\\n\",\n                 osGetCurrentProcessId(), pShmNode->nRegion, iOffset,\n                 szRegion, pMap ? \"ok\" : \"failed\"));\n      }\n      if( !pMap ){\n        pShmNode->lastErrno = osGetLastError();\n        rc = winLogError(SQLITE_IOERR_SHMMAP, pShmNode->lastErrno,\n                         \"winShmMap3\", pDbFd->zPath);\n        if( hMap ) osCloseHandle(hMap);\n        goto shmpage_out;\n      }\n\n      pShmNode->aRegion[pShmNode->nRegion].pMap = pMap;\n      pShmNode->aRegion[pShmNode->nRegion].hMap = hMap;\n      pShmNode->nRegion++;\n    }\n  }\n\nshmpage_out:\n  if( pShmNode->nRegion>iRegion ){\n    int iOffset = iRegion*szRegion;\n    int iOffsetShift = iOffset % winSysInfo.dwAllocationGranularity;\n    char *p = (char *)pShmNode->aRegion[iRegion].pMap;\n    *pp = (void *)&p[iOffsetShift];\n  }else{\n    *pp = 0;\n  }\n  if( pShmNode->isReadonly && rc==SQLITE_OK ) rc = SQLITE_READONLY;\n  sqlite3_mutex_leave(pShmNode->mutex);\n  return rc;\n}\n\n#else\n# define winShmMap     0\n# define winShmLock    0\n# define winShmBarrier 0\n# define winShmUnmap   0\n#endif /* #ifndef SQLITE_OMIT_WAL */\n\n/*\n** Cleans up the mapped region of the specified file, if any.\n*/\n#if SQLITE_MAX_MMAP_SIZE>0\nstatic int winUnmapfile(winFile *pFile){\n  assert( pFile!=0 );\n  OSTRACE((\"UNMAP-FILE pid=%lu, pFile=%p, hMap=%p, pMapRegion=%p, \"\n           \"mmapSize=%lld, mmapSizeMax=%lld\\n\",\n           osGetCurrentProcessId(), pFile, pFile->hMap, pFile->pMapRegion,\n           pFile->mmapSize, pFile->mmapSizeMax));\n  if( pFile->pMapRegion ){\n    if( !osUnmapViewOfFile(pFile->pMapRegion) ){\n      pFile->lastErrno = osGetLastError();\n      OSTRACE((\"UNMAP-FILE pid=%lu, pFile=%p, pMapRegion=%p, \"\n               \"rc=SQLITE_IOERR_MMAP\\n\", osGetCurrentProcessId(), pFile,\n               pFile->pMapRegion));\n      return winLogError(SQLITE_IOERR_MMAP, pFile->lastErrno,\n                         \"winUnmapfile1\", pFile->zPath);\n    }\n    pFile->pMapRegion = 0;\n    pFile->mmapSize = 0;\n  }\n  if( pFile->hMap!=NULL ){\n    if( !osCloseHandle(pFile->hMap) ){\n      pFile->lastErrno = osGetLastError();\n      OSTRACE((\"UNMAP-FILE pid=%lu, pFile=%p, hMap=%p, rc=SQLITE_IOERR_MMAP\\n\",\n               osGetCurrentProcessId(), pFile, pFile->hMap));\n      return winLogError(SQLITE_IOERR_MMAP, pFile->lastErrno,\n                         \"winUnmapfile2\", pFile->zPath);\n    }\n    pFile->hMap = NULL;\n  }\n  OSTRACE((\"UNMAP-FILE pid=%lu, pFile=%p, rc=SQLITE_OK\\n\",\n           osGetCurrentProcessId(), pFile));\n  return SQLITE_OK;\n}\n\n/*\n** Memory map or remap the file opened by file-descriptor pFd (if the file\n** is already mapped, the existing mapping is replaced by the new). Or, if\n** there already exists a mapping for this file, and there are still\n** outstanding xFetch() references to it, this function is a no-op.\n**\n** If parameter nByte is non-negative, then it is the requested size of\n** the mapping to create. Otherwise, if nByte is less than zero, then the\n** requested size is the size of the file on disk. The actual size of the\n** created mapping is either the requested size or the value configured\n** using SQLITE_FCNTL_MMAP_SIZE, whichever is smaller.\n**\n** SQLITE_OK is returned if no error occurs (even if the mapping is not\n** recreated as a result of outstanding references) or an SQLite error\n** code otherwise.\n*/\nstatic int winMapfile(winFile *pFd, sqlite3_int64 nByte){\n  sqlite3_int64 nMap = nByte;\n  int rc;\n\n  assert( nMap>=0 || pFd->nFetchOut==0 );\n  OSTRACE((\"MAP-FILE pid=%lu, pFile=%p, size=%lld\\n\",\n           osGetCurrentProcessId(), pFd, nByte));\n\n  if( pFd->nFetchOut>0 ) return SQLITE_OK;\n\n  if( nMap<0 ){\n    rc = winFileSize((sqlite3_file*)pFd, &nMap);\n    if( rc ){\n      OSTRACE((\"MAP-FILE pid=%lu, pFile=%p, rc=SQLITE_IOERR_FSTAT\\n\",\n               osGetCurrentProcessId(), pFd));\n      return SQLITE_IOERR_FSTAT;\n    }\n  }\n  if( nMap>pFd->mmapSizeMax ){\n    nMap = pFd->mmapSizeMax;\n  }\n  nMap &= ~(sqlite3_int64)(winSysInfo.dwPageSize - 1);\n\n  if( nMap==0 && pFd->mmapSize>0 ){\n    winUnmapfile(pFd);\n  }\n  if( nMap!=pFd->mmapSize ){\n    void *pNew = 0;\n    DWORD protect = PAGE_READONLY;\n    DWORD flags = FILE_MAP_READ;\n\n    winUnmapfile(pFd);\n#ifdef SQLITE_MMAP_READWRITE\n    if( (pFd->ctrlFlags & WINFILE_RDONLY)==0 ){\n      protect = PAGE_READWRITE;\n      flags |= FILE_MAP_WRITE;\n    }\n#endif\n#if SQLITE_OS_WINRT\n    pFd->hMap = osCreateFileMappingFromApp(pFd->h, NULL, protect, nMap, NULL);\n#elif defined(SQLITE_WIN32_HAS_WIDE)\n    pFd->hMap = osCreateFileMappingW(pFd->h, NULL, protect,\n                                (DWORD)((nMap>>32) & 0xffffffff),\n                                (DWORD)(nMap & 0xffffffff), NULL);\n#elif defined(SQLITE_WIN32_HAS_ANSI) && SQLITE_WIN32_CREATEFILEMAPPINGA\n    pFd->hMap = osCreateFileMappingA(pFd->h, NULL, protect,\n                                (DWORD)((nMap>>32) & 0xffffffff),\n                                (DWORD)(nMap & 0xffffffff), NULL);\n#endif\n    if( pFd->hMap==NULL ){\n      pFd->lastErrno = osGetLastError();\n      rc = winLogError(SQLITE_IOERR_MMAP, pFd->lastErrno,\n                       \"winMapfile1\", pFd->zPath);\n      /* Log the error, but continue normal operation using xRead/xWrite */\n      OSTRACE((\"MAP-FILE-CREATE pid=%lu, pFile=%p, rc=%s\\n\",\n               osGetCurrentProcessId(), pFd, sqlite3ErrName(rc)));\n      return SQLITE_OK;\n    }\n    assert( (nMap % winSysInfo.dwPageSize)==0 );\n    assert( sizeof(SIZE_T)==sizeof(sqlite3_int64) || nMap<=0xffffffff );\n#if SQLITE_OS_WINRT\n    pNew = osMapViewOfFileFromApp(pFd->hMap, flags, 0, (SIZE_T)nMap);\n#else\n    pNew = osMapViewOfFile(pFd->hMap, flags, 0, 0, (SIZE_T)nMap);\n#endif\n    if( pNew==NULL ){\n      osCloseHandle(pFd->hMap);\n      pFd->hMap = NULL;\n      pFd->lastErrno = osGetLastError();\n      rc = winLogError(SQLITE_IOERR_MMAP, pFd->lastErrno,\n                       \"winMapfile2\", pFd->zPath);\n      /* Log the error, but continue normal operation using xRead/xWrite */\n      OSTRACE((\"MAP-FILE-MAP pid=%lu, pFile=%p, rc=%s\\n\",\n               osGetCurrentProcessId(), pFd, sqlite3ErrName(rc)));\n      return SQLITE_OK;\n    }\n    pFd->pMapRegion = pNew;\n    pFd->mmapSize = nMap;\n  }\n\n  OSTRACE((\"MAP-FILE pid=%lu, pFile=%p, rc=SQLITE_OK\\n\",\n           osGetCurrentProcessId(), pFd));\n  return SQLITE_OK;\n}\n#endif /* SQLITE_MAX_MMAP_SIZE>0 */\n\n/*\n** If possible, return a pointer to a mapping of file fd starting at offset\n** iOff. The mapping must be valid for at least nAmt bytes.\n**\n** If such a pointer can be obtained, store it in *pp and return SQLITE_OK.\n** Or, if one cannot but no error occurs, set *pp to 0 and return SQLITE_OK.\n** Finally, if an error does occur, return an SQLite error code. The final\n** value of *pp is undefined in this case.\n**\n** If this function does return a pointer, the caller must eventually\n** release the reference by calling winUnfetch().\n*/\nstatic int winFetch(sqlite3_file *fd, i64 iOff, int nAmt, void **pp){\n#if SQLITE_MAX_MMAP_SIZE>0\n  winFile *pFd = (winFile*)fd;   /* The underlying database file */\n#endif\n  *pp = 0;\n\n  OSTRACE((\"FETCH pid=%lu, pFile=%p, offset=%lld, amount=%d, pp=%p\\n\",\n           osGetCurrentProcessId(), fd, iOff, nAmt, pp));\n\n#if SQLITE_MAX_MMAP_SIZE>0\n  if( pFd->mmapSizeMax>0 ){\n    if( pFd->pMapRegion==0 ){\n      int rc = winMapfile(pFd, -1);\n      if( rc!=SQLITE_OK ){\n        OSTRACE((\"FETCH pid=%lu, pFile=%p, rc=%s\\n\",\n                 osGetCurrentProcessId(), pFd, sqlite3ErrName(rc)));\n        return rc;\n      }\n    }\n    if( pFd->mmapSize >= iOff+nAmt ){\n      *pp = &((u8 *)pFd->pMapRegion)[iOff];\n      pFd->nFetchOut++;\n    }\n  }\n#endif\n\n  OSTRACE((\"FETCH pid=%lu, pFile=%p, pp=%p, *pp=%p, rc=SQLITE_OK\\n\",\n           osGetCurrentProcessId(), fd, pp, *pp));\n  return SQLITE_OK;\n}\n\n/*\n** If the third argument is non-NULL, then this function releases a\n** reference obtained by an earlier call to winFetch(). The second\n** argument passed to this function must be the same as the corresponding\n** argument that was passed to the winFetch() invocation.\n**\n** Or, if the third argument is NULL, then this function is being called\n** to inform the VFS layer that, according to POSIX, any existing mapping\n** may now be invalid and should be unmapped.\n*/\nstatic int winUnfetch(sqlite3_file *fd, i64 iOff, void *p){\n#if SQLITE_MAX_MMAP_SIZE>0\n  winFile *pFd = (winFile*)fd;   /* The underlying database file */\n\n  /* If p==0 (unmap the entire file) then there must be no outstanding\n  ** xFetch references. Or, if p!=0 (meaning it is an xFetch reference),\n  ** then there must be at least one outstanding.  */\n  assert( (p==0)==(pFd->nFetchOut==0) );\n\n  /* If p!=0, it must match the iOff value. */\n  assert( p==0 || p==&((u8 *)pFd->pMapRegion)[iOff] );\n\n  OSTRACE((\"UNFETCH pid=%lu, pFile=%p, offset=%lld, p=%p\\n\",\n           osGetCurrentProcessId(), pFd, iOff, p));\n\n  if( p ){\n    pFd->nFetchOut--;\n  }else{\n    /* FIXME:  If Windows truly always prevents truncating or deleting a\n    ** file while a mapping is held, then the following winUnmapfile() call\n    ** is unnecessary can be omitted - potentially improving\n    ** performance.  */\n    winUnmapfile(pFd);\n  }\n\n  assert( pFd->nFetchOut>=0 );\n#endif\n\n  OSTRACE((\"UNFETCH pid=%lu, pFile=%p, rc=SQLITE_OK\\n\",\n           osGetCurrentProcessId(), fd));\n  return SQLITE_OK;\n}\n\n/*\n** Here ends the implementation of all sqlite3_file methods.\n**\n********************** End sqlite3_file Methods *******************************\n******************************************************************************/\n\n/*\n** This vector defines all the methods that can operate on an\n** sqlite3_file for win32.\n*/\nstatic const sqlite3_io_methods winIoMethod = {\n  3,                              /* iVersion */\n  winClose,                       /* xClose */\n  winRead,                        /* xRead */\n  winWrite,                       /* xWrite */\n  winTruncate,                    /* xTruncate */\n  winSync,                        /* xSync */\n  winFileSize,                    /* xFileSize */\n  winLock,                        /* xLock */\n  winUnlock,                      /* xUnlock */\n  winCheckReservedLock,           /* xCheckReservedLock */\n  winFileControl,                 /* xFileControl */\n  winSectorSize,                  /* xSectorSize */\n  winDeviceCharacteristics,       /* xDeviceCharacteristics */\n  winShmMap,                      /* xShmMap */\n  winShmLock,                     /* xShmLock */\n  winShmBarrier,                  /* xShmBarrier */\n  winShmUnmap,                    /* xShmUnmap */\n  winFetch,                       /* xFetch */\n  winUnfetch                      /* xUnfetch */\n};\n\n/*\n** This vector defines all the methods that can operate on an\n** sqlite3_file for win32 without performing any locking.\n*/\nstatic const sqlite3_io_methods winIoNolockMethod = {\n  3,                              /* iVersion */\n  winClose,                       /* xClose */\n  winRead,                        /* xRead */\n  winWrite,                       /* xWrite */\n  winTruncate,                    /* xTruncate */\n  winSync,                        /* xSync */\n  winFileSize,                    /* xFileSize */\n  winNolockLock,                  /* xLock */\n  winNolockUnlock,                /* xUnlock */\n  winNolockCheckReservedLock,     /* xCheckReservedLock */\n  winFileControl,                 /* xFileControl */\n  winSectorSize,                  /* xSectorSize */\n  winDeviceCharacteristics,       /* xDeviceCharacteristics */\n  winShmMap,                      /* xShmMap */\n  winShmLock,                     /* xShmLock */\n  winShmBarrier,                  /* xShmBarrier */\n  winShmUnmap,                    /* xShmUnmap */\n  winFetch,                       /* xFetch */\n  winUnfetch                      /* xUnfetch */\n};\n\nstatic winVfsAppData winAppData = {\n  &winIoMethod,       /* pMethod */\n  0,                  /* pAppData */\n  0                   /* bNoLock */\n};\n\nstatic winVfsAppData winNolockAppData = {\n  &winIoNolockMethod, /* pMethod */\n  0,                  /* pAppData */\n  1                   /* bNoLock */\n};\n\n/****************************************************************************\n**************************** sqlite3_vfs methods ****************************\n**\n** This division contains the implementation of methods on the\n** sqlite3_vfs object.\n*/\n\n#if defined(__CYGWIN__)\n/*\n** Convert a filename from whatever the underlying operating system\n** supports for filenames into UTF-8.  Space to hold the result is\n** obtained from malloc and must be freed by the calling function.\n*/\nstatic char *winConvertToUtf8Filename(const void *zFilename){\n  char *zConverted = 0;\n  if( osIsNT() ){\n    zConverted = winUnicodeToUtf8(zFilename);\n  }\n#ifdef SQLITE_WIN32_HAS_ANSI\n  else{\n    zConverted = winMbcsToUtf8(zFilename, osAreFileApisANSI());\n  }\n#endif\n  /* caller will handle out of memory */\n  return zConverted;\n}\n#endif\n\n/*\n** Convert a UTF-8 filename into whatever form the underlying\n** operating system wants filenames in.  Space to hold the result\n** is obtained from malloc and must be freed by the calling\n** function.\n*/\nstatic void *winConvertFromUtf8Filename(const char *zFilename){\n  void *zConverted = 0;\n  if( osIsNT() ){\n    zConverted = winUtf8ToUnicode(zFilename);\n  }\n#ifdef SQLITE_WIN32_HAS_ANSI\n  else{\n    zConverted = winUtf8ToMbcs(zFilename, osAreFileApisANSI());\n  }\n#endif\n  /* caller will handle out of memory */\n  return zConverted;\n}\n\n/*\n** This function returns non-zero if the specified UTF-8 string buffer\n** ends with a directory separator character or one was successfully\n** added to it.\n*/\nstatic int winMakeEndInDirSep(int nBuf, char *zBuf){\n  if( zBuf ){\n    int nLen = sqlite3Strlen30(zBuf);\n    if( nLen>0 ){\n      if( winIsDirSep(zBuf[nLen-1]) ){\n        return 1;\n      }else if( nLen+1<nBuf ){\n        zBuf[nLen] = winGetDirSep();\n        zBuf[nLen+1] = '\\0';\n        return 1;\n      }\n    }\n  }\n  return 0;\n}\n\n/*\n** Create a temporary file name and store the resulting pointer into pzBuf.\n** The pointer returned in pzBuf must be freed via sqlite3_free().\n*/\nstatic int winGetTempname(sqlite3_vfs *pVfs, char **pzBuf){\n  static char zChars[] =\n    \"abcdefghijklmnopqrstuvwxyz\"\n    \"ABCDEFGHIJKLMNOPQRSTUVWXYZ\"\n    \"0123456789\";\n  size_t i, j;\n  int nPre = sqlite3Strlen30(SQLITE_TEMP_FILE_PREFIX);\n  int nMax, nBuf, nDir, nLen;\n  char *zBuf;\n\n  /* It's odd to simulate an io-error here, but really this is just\n  ** using the io-error infrastructure to test that SQLite handles this\n  ** function failing.\n  */\n  SimulateIOError( return SQLITE_IOERR );\n\n  /* Allocate a temporary buffer to store the fully qualified file\n  ** name for the temporary file.  If this fails, we cannot continue.\n  */\n  nMax = pVfs->mxPathname; nBuf = nMax + 2;\n  zBuf = sqlite3MallocZero( nBuf );\n  if( !zBuf ){\n    OSTRACE((\"TEMP-FILENAME rc=SQLITE_IOERR_NOMEM\\n\"));\n    return SQLITE_IOERR_NOMEM_BKPT;\n  }\n\n  /* Figure out the effective temporary directory.  First, check if one\n  ** has been explicitly set by the application; otherwise, use the one\n  ** configured by the operating system.\n  */\n  nDir = nMax - (nPre + 15);\n  assert( nDir>0 );\n  if( sqlite3_temp_directory ){\n    int nDirLen = sqlite3Strlen30(sqlite3_temp_directory);\n    if( nDirLen>0 ){\n      if( !winIsDirSep(sqlite3_temp_directory[nDirLen-1]) ){\n        nDirLen++;\n      }\n      if( nDirLen>nDir ){\n        sqlite3_free(zBuf);\n        OSTRACE((\"TEMP-FILENAME rc=SQLITE_ERROR\\n\"));\n        return winLogError(SQLITE_ERROR, 0, \"winGetTempname1\", 0);\n      }\n      sqlite3_snprintf(nMax, zBuf, \"%s\", sqlite3_temp_directory);\n    }\n  }\n#if defined(__CYGWIN__)\n  else{\n    static const char *azDirs[] = {\n       0, /* getenv(\"SQLITE_TMPDIR\") */\n       0, /* getenv(\"TMPDIR\") */\n       0, /* getenv(\"TMP\") */\n       0, /* getenv(\"TEMP\") */\n       0, /* getenv(\"USERPROFILE\") */\n       \"/var/tmp\",\n       \"/usr/tmp\",\n       \"/tmp\",\n       \".\",\n       0        /* List terminator */\n    };\n    unsigned int i;\n    const char *zDir = 0;\n\n    if( !azDirs[0] ) azDirs[0] = getenv(\"SQLITE_TMPDIR\");\n    if( !azDirs[1] ) azDirs[1] = getenv(\"TMPDIR\");\n    if( !azDirs[2] ) azDirs[2] = getenv(\"TMP\");\n    if( !azDirs[3] ) azDirs[3] = getenv(\"TEMP\");\n    if( !azDirs[4] ) azDirs[4] = getenv(\"USERPROFILE\");\n    for(i=0; i<sizeof(azDirs)/sizeof(azDirs[0]); zDir=azDirs[i++]){\n      void *zConverted;\n      if( zDir==0 ) continue;\n      /* If the path starts with a drive letter followed by the colon\n      ** character, assume it is already a native Win32 path; otherwise,\n      ** it must be converted to a native Win32 path via the Cygwin API\n      ** prior to using it.\n      */\n      if( winIsDriveLetterAndColon(zDir) ){\n        zConverted = winConvertFromUtf8Filename(zDir);\n        if( !zConverted ){\n          sqlite3_free(zBuf);\n          OSTRACE((\"TEMP-FILENAME rc=SQLITE_IOERR_NOMEM\\n\"));\n          return SQLITE_IOERR_NOMEM_BKPT;\n        }\n        if( winIsDir(zConverted) ){\n          sqlite3_snprintf(nMax, zBuf, \"%s\", zDir);\n          sqlite3_free(zConverted);\n          break;\n        }\n        sqlite3_free(zConverted);\n      }else{\n        zConverted = sqlite3MallocZero( nMax+1 );\n        if( !zConverted ){\n          sqlite3_free(zBuf);\n          OSTRACE((\"TEMP-FILENAME rc=SQLITE_IOERR_NOMEM\\n\"));\n          return SQLITE_IOERR_NOMEM_BKPT;\n        }\n        if( cygwin_conv_path(\n                osIsNT() ? CCP_POSIX_TO_WIN_W : CCP_POSIX_TO_WIN_A, zDir,\n                zConverted, nMax+1)<0 ){\n          sqlite3_free(zConverted);\n          sqlite3_free(zBuf);\n          OSTRACE((\"TEMP-FILENAME rc=SQLITE_IOERR_CONVPATH\\n\"));\n          return winLogError(SQLITE_IOERR_CONVPATH, (DWORD)errno,\n                             \"winGetTempname2\", zDir);\n        }\n        if( winIsDir(zConverted) ){\n          /* At this point, we know the candidate directory exists and should\n          ** be used.  However, we may need to convert the string containing\n          ** its name into UTF-8 (i.e. if it is UTF-16 right now).\n          */\n          char *zUtf8 = winConvertToUtf8Filename(zConverted);\n          if( !zUtf8 ){\n            sqlite3_free(zConverted);\n            sqlite3_free(zBuf);\n            OSTRACE((\"TEMP-FILENAME rc=SQLITE_IOERR_NOMEM\\n\"));\n            return SQLITE_IOERR_NOMEM_BKPT;\n          }\n          sqlite3_snprintf(nMax, zBuf, \"%s\", zUtf8);\n          sqlite3_free(zUtf8);\n          sqlite3_free(zConverted);\n          break;\n        }\n        sqlite3_free(zConverted);\n      }\n    }\n  }\n#elif !SQLITE_OS_WINRT && !defined(__CYGWIN__)\n  else if( osIsNT() ){\n    char *zMulti;\n    LPWSTR zWidePath = sqlite3MallocZero( nMax*sizeof(WCHAR) );\n    if( !zWidePath ){\n      sqlite3_free(zBuf);\n      OSTRACE((\"TEMP-FILENAME rc=SQLITE_IOERR_NOMEM\\n\"));\n      return SQLITE_IOERR_NOMEM_BKPT;\n    }\n    if( osGetTempPathW(nMax, zWidePath)==0 ){\n      sqlite3_free(zWidePath);\n      sqlite3_free(zBuf);\n      OSTRACE((\"TEMP-FILENAME rc=SQLITE_IOERR_GETTEMPPATH\\n\"));\n      return winLogError(SQLITE_IOERR_GETTEMPPATH, osGetLastError(),\n                         \"winGetTempname2\", 0);\n    }\n    zMulti = winUnicodeToUtf8(zWidePath);\n    if( zMulti ){\n      sqlite3_snprintf(nMax, zBuf, \"%s\", zMulti);\n      sqlite3_free(zMulti);\n      sqlite3_free(zWidePath);\n    }else{\n      sqlite3_free(zWidePath);\n      sqlite3_free(zBuf);\n      OSTRACE((\"TEMP-FILENAME rc=SQLITE_IOERR_NOMEM\\n\"));\n      return SQLITE_IOERR_NOMEM_BKPT;\n    }\n  }\n#ifdef SQLITE_WIN32_HAS_ANSI\n  else{\n    char *zUtf8;\n    char *zMbcsPath = sqlite3MallocZero( nMax );\n    if( !zMbcsPath ){\n      sqlite3_free(zBuf);\n      OSTRACE((\"TEMP-FILENAME rc=SQLITE_IOERR_NOMEM\\n\"));\n      return SQLITE_IOERR_NOMEM_BKPT;\n    }\n    if( osGetTempPathA(nMax, zMbcsPath)==0 ){\n      sqlite3_free(zBuf);\n      OSTRACE((\"TEMP-FILENAME rc=SQLITE_IOERR_GETTEMPPATH\\n\"));\n      return winLogError(SQLITE_IOERR_GETTEMPPATH, osGetLastError(),\n                         \"winGetTempname3\", 0);\n    }\n    zUtf8 = winMbcsToUtf8(zMbcsPath, osAreFileApisANSI());\n    if( zUtf8 ){\n      sqlite3_snprintf(nMax, zBuf, \"%s\", zUtf8);\n      sqlite3_free(zUtf8);\n    }else{\n      sqlite3_free(zBuf);\n      OSTRACE((\"TEMP-FILENAME rc=SQLITE_IOERR_NOMEM\\n\"));\n      return SQLITE_IOERR_NOMEM_BKPT;\n    }\n  }\n#endif /* SQLITE_WIN32_HAS_ANSI */\n#endif /* !SQLITE_OS_WINRT */\n\n  /*\n  ** Check to make sure the temporary directory ends with an appropriate\n  ** separator.  If it does not and there is not enough space left to add\n  ** one, fail.\n  */\n  if( !winMakeEndInDirSep(nDir+1, zBuf) ){\n    sqlite3_free(zBuf);\n    OSTRACE((\"TEMP-FILENAME rc=SQLITE_ERROR\\n\"));\n    return winLogError(SQLITE_ERROR, 0, \"winGetTempname4\", 0);\n  }\n\n  /*\n  ** Check that the output buffer is large enough for the temporary file\n  ** name in the following format:\n  **\n  **   \"<temporary_directory>/etilqs_XXXXXXXXXXXXXXX\\0\\0\"\n  **\n  ** If not, return SQLITE_ERROR.  The number 17 is used here in order to\n  ** account for the space used by the 15 character random suffix and the\n  ** two trailing NUL characters.  The final directory separator character\n  ** has already added if it was not already present.\n  */\n  nLen = sqlite3Strlen30(zBuf);\n  if( (nLen + nPre + 17) > nBuf ){\n    sqlite3_free(zBuf);\n    OSTRACE((\"TEMP-FILENAME rc=SQLITE_ERROR\\n\"));\n    return winLogError(SQLITE_ERROR, 0, \"winGetTempname5\", 0);\n  }\n\n  sqlite3_snprintf(nBuf-16-nLen, zBuf+nLen, SQLITE_TEMP_FILE_PREFIX);\n\n  j = sqlite3Strlen30(zBuf);\n  sqlite3_randomness(15, &zBuf[j]);\n  for(i=0; i<15; i++, j++){\n    zBuf[j] = (char)zChars[ ((unsigned char)zBuf[j])%(sizeof(zChars)-1) ];\n  }\n  zBuf[j] = 0;\n  zBuf[j+1] = 0;\n  *pzBuf = zBuf;\n\n  OSTRACE((\"TEMP-FILENAME name=%s, rc=SQLITE_OK\\n\", zBuf));\n  return SQLITE_OK;\n}\n\n/*\n** Return TRUE if the named file is really a directory.  Return false if\n** it is something other than a directory, or if there is any kind of memory\n** allocation failure.\n*/\nstatic int winIsDir(const void *zConverted){\n  DWORD attr;\n  int rc = 0;\n  DWORD lastErrno;\n\n  if( osIsNT() ){\n    int cnt = 0;\n    WIN32_FILE_ATTRIBUTE_DATA sAttrData;\n    memset(&sAttrData, 0, sizeof(sAttrData));\n    while( !(rc = osGetFileAttributesExW((LPCWSTR)zConverted,\n                             GetFileExInfoStandard,\n                             &sAttrData)) && winRetryIoerr(&cnt, &lastErrno) ){}\n    if( !rc ){\n      return 0; /* Invalid name? */\n    }\n    attr = sAttrData.dwFileAttributes;\n#if SQLITE_OS_WINCE==0\n  }else{\n    attr = osGetFileAttributesA((char*)zConverted);\n#endif\n  }\n  return (attr!=INVALID_FILE_ATTRIBUTES) && (attr&FILE_ATTRIBUTE_DIRECTORY);\n}\n\n/* forward reference */\nstatic int winAccess(\n  sqlite3_vfs *pVfs,         /* Not used on win32 */\n  const char *zFilename,     /* Name of file to check */\n  int flags,                 /* Type of test to make on this file */\n  int *pResOut               /* OUT: Result */\n);\n\n/*\n** Open a file.\n*/\nstatic int winOpen(\n  sqlite3_vfs *pVfs,        /* Used to get maximum path length and AppData */\n  const char *zName,        /* Name of the file (UTF-8) */\n  sqlite3_file *id,         /* Write the SQLite file handle here */\n  int flags,                /* Open mode flags */\n  int *pOutFlags            /* Status return flags */\n){\n  HANDLE h;\n  DWORD lastErrno = 0;\n  DWORD dwDesiredAccess;\n  DWORD dwShareMode;\n  DWORD dwCreationDisposition;\n  DWORD dwFlagsAndAttributes = 0;\n#if SQLITE_OS_WINCE\n  int isTemp = 0;\n#endif\n  winVfsAppData *pAppData;\n  winFile *pFile = (winFile*)id;\n  void *zConverted;              /* Filename in OS encoding */\n  const char *zUtf8Name = zName; /* Filename in UTF-8 encoding */\n  int cnt = 0;\n\n  /* If argument zPath is a NULL pointer, this function is required to open\n  ** a temporary file. Use this buffer to store the file name in.\n  */\n  char *zTmpname = 0; /* For temporary filename, if necessary. */\n\n  int rc = SQLITE_OK;            /* Function Return Code */\n#if !defined(NDEBUG) || SQLITE_OS_WINCE\n  int eType = flags&0xFFFFFF00;  /* Type of file to open */\n#endif\n\n  int isExclusive  = (flags & SQLITE_OPEN_EXCLUSIVE);\n  int isDelete     = (flags & SQLITE_OPEN_DELETEONCLOSE);\n  int isCreate     = (flags & SQLITE_OPEN_CREATE);\n  int isReadonly   = (flags & SQLITE_OPEN_READONLY);\n  int isReadWrite  = (flags & SQLITE_OPEN_READWRITE);\n\n#ifndef NDEBUG\n  int isOpenJournal = (isCreate && (\n        eType==SQLITE_OPEN_MASTER_JOURNAL\n     || eType==SQLITE_OPEN_MAIN_JOURNAL\n     || eType==SQLITE_OPEN_WAL\n  ));\n#endif\n\n  OSTRACE((\"OPEN name=%s, pFile=%p, flags=%x, pOutFlags=%p\\n\",\n           zUtf8Name, id, flags, pOutFlags));\n\n  /* Check the following statements are true:\n  **\n  **   (a) Exactly one of the READWRITE and READONLY flags must be set, and\n  **   (b) if CREATE is set, then READWRITE must also be set, and\n  **   (c) if EXCLUSIVE is set, then CREATE must also be set.\n  **   (d) if DELETEONCLOSE is set, then CREATE must also be set.\n  */\n  assert((isReadonly==0 || isReadWrite==0) && (isReadWrite || isReadonly));\n  assert(isCreate==0 || isReadWrite);\n  assert(isExclusive==0 || isCreate);\n  assert(isDelete==0 || isCreate);\n\n  /* The main DB, main journal, WAL file and master journal are never\n  ** automatically deleted. Nor are they ever temporary files.  */\n  assert( (!isDelete && zName) || eType!=SQLITE_OPEN_MAIN_DB );\n  assert( (!isDelete && zName) || eType!=SQLITE_OPEN_MAIN_JOURNAL );\n  assert( (!isDelete && zName) || eType!=SQLITE_OPEN_MASTER_JOURNAL );\n  assert( (!isDelete && zName) || eType!=SQLITE_OPEN_WAL );\n\n  /* Assert that the upper layer has set one of the \"file-type\" flags. */\n  assert( eType==SQLITE_OPEN_MAIN_DB      || eType==SQLITE_OPEN_TEMP_DB\n       || eType==SQLITE_OPEN_MAIN_JOURNAL || eType==SQLITE_OPEN_TEMP_JOURNAL\n       || eType==SQLITE_OPEN_SUBJOURNAL   || eType==SQLITE_OPEN_MASTER_JOURNAL\n       || eType==SQLITE_OPEN_TRANSIENT_DB || eType==SQLITE_OPEN_WAL\n  );\n\n  assert( pFile!=0 );\n  memset(pFile, 0, sizeof(winFile));\n  pFile->h = INVALID_HANDLE_VALUE;\n\n#if SQLITE_OS_WINRT\n  if( !zUtf8Name && !sqlite3_temp_directory ){\n    sqlite3_log(SQLITE_ERROR,\n        \"sqlite3_temp_directory variable should be set for WinRT\");\n  }\n#endif\n\n  /* If the second argument to this function is NULL, generate a\n  ** temporary file name to use\n  */\n  if( !zUtf8Name ){\n    assert( isDelete && !isOpenJournal );\n    rc = winGetTempname(pVfs, &zTmpname);\n    if( rc!=SQLITE_OK ){\n      OSTRACE((\"OPEN name=%s, rc=%s\", zUtf8Name, sqlite3ErrName(rc)));\n      return rc;\n    }\n    zUtf8Name = zTmpname;\n  }\n\n  /* Database filenames are double-zero terminated if they are not\n  ** URIs with parameters.  Hence, they can always be passed into\n  ** sqlite3_uri_parameter().\n  */\n  assert( (eType!=SQLITE_OPEN_MAIN_DB) || (flags & SQLITE_OPEN_URI) ||\n       zUtf8Name[sqlite3Strlen30(zUtf8Name)+1]==0 );\n\n  /* Convert the filename to the system encoding. */\n  zConverted = winConvertFromUtf8Filename(zUtf8Name);\n  if( zConverted==0 ){\n    sqlite3_free(zTmpname);\n    OSTRACE((\"OPEN name=%s, rc=SQLITE_IOERR_NOMEM\", zUtf8Name));\n    return SQLITE_IOERR_NOMEM_BKPT;\n  }\n\n  if( winIsDir(zConverted) ){\n    sqlite3_free(zConverted);\n    sqlite3_free(zTmpname);\n    OSTRACE((\"OPEN name=%s, rc=SQLITE_CANTOPEN_ISDIR\", zUtf8Name));\n    return SQLITE_CANTOPEN_ISDIR;\n  }\n\n  if( isReadWrite ){\n    dwDesiredAccess = GENERIC_READ | GENERIC_WRITE;\n  }else{\n    dwDesiredAccess = GENERIC_READ;\n  }\n\n  /* SQLITE_OPEN_EXCLUSIVE is used to make sure that a new file is\n  ** created. SQLite doesn't use it to indicate \"exclusive access\"\n  ** as it is usually understood.\n  */\n  if( isExclusive ){\n    /* Creates a new file, only if it does not already exist. */\n    /* If the file exists, it fails. */\n    dwCreationDisposition = CREATE_NEW;\n  }else if( isCreate ){\n    /* Open existing file, or create if it doesn't exist */\n    dwCreationDisposition = OPEN_ALWAYS;\n  }else{\n    /* Opens a file, only if it exists. */\n    dwCreationDisposition = OPEN_EXISTING;\n  }\n\n  dwShareMode = FILE_SHARE_READ | FILE_SHARE_WRITE;\n\n  if( isDelete ){\n#if SQLITE_OS_WINCE\n    dwFlagsAndAttributes = FILE_ATTRIBUTE_HIDDEN;\n    isTemp = 1;\n#else\n    dwFlagsAndAttributes = FILE_ATTRIBUTE_TEMPORARY\n                               | FILE_ATTRIBUTE_HIDDEN\n                               | FILE_FLAG_DELETE_ON_CLOSE;\n#endif\n  }else{\n    dwFlagsAndAttributes = FILE_ATTRIBUTE_NORMAL;\n  }\n  /* Reports from the internet are that performance is always\n  ** better if FILE_FLAG_RANDOM_ACCESS is used.  Ticket #2699. */\n#if SQLITE_OS_WINCE\n  dwFlagsAndAttributes |= FILE_FLAG_RANDOM_ACCESS;\n#endif\n\n  if( osIsNT() ){\n#if SQLITE_OS_WINRT\n    CREATEFILE2_EXTENDED_PARAMETERS extendedParameters;\n    extendedParameters.dwSize = sizeof(CREATEFILE2_EXTENDED_PARAMETERS);\n    extendedParameters.dwFileAttributes =\n            dwFlagsAndAttributes & FILE_ATTRIBUTE_MASK;\n    extendedParameters.dwFileFlags = dwFlagsAndAttributes & FILE_FLAG_MASK;\n    extendedParameters.dwSecurityQosFlags = SECURITY_ANONYMOUS;\n    extendedParameters.lpSecurityAttributes = NULL;\n    extendedParameters.hTemplateFile = NULL;\n    do{\n      h = osCreateFile2((LPCWSTR)zConverted,\n                        dwDesiredAccess,\n                        dwShareMode,\n                        dwCreationDisposition,\n                        &extendedParameters);\n      if( h!=INVALID_HANDLE_VALUE ) break;\n      if( isReadWrite ){\n        int rc2, isRO = 0;\n        sqlite3BeginBenignMalloc();\n        rc2 = winAccess(pVfs, zName, SQLITE_ACCESS_READ, &isRO);\n        sqlite3EndBenignMalloc();\n        if( rc2==SQLITE_OK && isRO ) break;\n      }\n    }while( winRetryIoerr(&cnt, &lastErrno) );\n#else\n    do{\n      h = osCreateFileW((LPCWSTR)zConverted,\n                        dwDesiredAccess,\n                        dwShareMode, NULL,\n                        dwCreationDisposition,\n                        dwFlagsAndAttributes,\n                        NULL);\n      if( h!=INVALID_HANDLE_VALUE ) break;\n      if( isReadWrite ){\n        int rc2, isRO = 0;\n        sqlite3BeginBenignMalloc();\n        rc2 = winAccess(pVfs, zName, SQLITE_ACCESS_READ, &isRO);\n        sqlite3EndBenignMalloc();\n        if( rc2==SQLITE_OK && isRO ) break;\n      }\n    }while( winRetryIoerr(&cnt, &lastErrno) );\n#endif\n  }\n#ifdef SQLITE_WIN32_HAS_ANSI\n  else{\n    do{\n      h = osCreateFileA((LPCSTR)zConverted,\n                        dwDesiredAccess,\n                        dwShareMode, NULL,\n                        dwCreationDisposition,\n                        dwFlagsAndAttributes,\n                        NULL);\n      if( h!=INVALID_HANDLE_VALUE ) break;\n      if( isReadWrite ){\n        int rc2, isRO = 0;\n        sqlite3BeginBenignMalloc();\n        rc2 = winAccess(pVfs, zName, SQLITE_ACCESS_READ, &isRO);\n        sqlite3EndBenignMalloc();\n        if( rc2==SQLITE_OK && isRO ) break;\n      }\n    }while( winRetryIoerr(&cnt, &lastErrno) );\n  }\n#endif\n  winLogIoerr(cnt, __LINE__);\n\n  OSTRACE((\"OPEN file=%p, name=%s, access=%lx, rc=%s\\n\", h, zUtf8Name,\n           dwDesiredAccess, (h==INVALID_HANDLE_VALUE) ? \"failed\" : \"ok\"));\n\n  if( h==INVALID_HANDLE_VALUE ){\n    sqlite3_free(zConverted);\n    sqlite3_free(zTmpname);\n    if( isReadWrite && !isExclusive ){\n      return winOpen(pVfs, zName, id,\n         ((flags|SQLITE_OPEN_READONLY) &\n                     ~(SQLITE_OPEN_CREATE|SQLITE_OPEN_READWRITE)),\n         pOutFlags);\n    }else{\n      pFile->lastErrno = lastErrno;\n      winLogError(SQLITE_CANTOPEN, pFile->lastErrno, \"winOpen\", zUtf8Name);\n      return SQLITE_CANTOPEN_BKPT;\n    }\n  }\n\n  if( pOutFlags ){\n    if( isReadWrite ){\n      *pOutFlags = SQLITE_OPEN_READWRITE;\n    }else{\n      *pOutFlags = SQLITE_OPEN_READONLY;\n    }\n  }\n\n  OSTRACE((\"OPEN file=%p, name=%s, access=%lx, pOutFlags=%p, *pOutFlags=%d, \"\n           \"rc=%s\\n\", h, zUtf8Name, dwDesiredAccess, pOutFlags, pOutFlags ?\n           *pOutFlags : 0, (h==INVALID_HANDLE_VALUE) ? \"failed\" : \"ok\"));\n\n  pAppData = (winVfsAppData*)pVfs->pAppData;\n\n#if SQLITE_OS_WINCE\n  {\n    if( isReadWrite && eType==SQLITE_OPEN_MAIN_DB\n         && ((pAppData==NULL) || !pAppData->bNoLock)\n         && (rc = winceCreateLock(zName, pFile))!=SQLITE_OK\n    ){\n      osCloseHandle(h);\n      sqlite3_free(zConverted);\n      sqlite3_free(zTmpname);\n      OSTRACE((\"OPEN-CE-LOCK name=%s, rc=%s\\n\", zName, sqlite3ErrName(rc)));\n      return rc;\n    }\n  }\n  if( isTemp ){\n    pFile->zDeleteOnClose = zConverted;\n  }else\n#endif\n  {\n    sqlite3_free(zConverted);\n  }\n\n  sqlite3_free(zTmpname);\n  pFile->pMethod = pAppData ? pAppData->pMethod : &winIoMethod;\n  pFile->pVfs = pVfs;\n  pFile->h = h;\n  if( isReadonly ){\n    pFile->ctrlFlags |= WINFILE_RDONLY;\n  }\n  if( sqlite3_uri_boolean(zName, \"psow\", SQLITE_POWERSAFE_OVERWRITE) ){\n    pFile->ctrlFlags |= WINFILE_PSOW;\n  }\n  pFile->lastErrno = NO_ERROR;\n  pFile->zPath = zName;\n#if SQLITE_MAX_MMAP_SIZE>0\n  pFile->hMap = NULL;\n  pFile->pMapRegion = 0;\n  pFile->mmapSize = 0;\n  pFile->mmapSizeMax = sqlite3GlobalConfig.szMmap;\n#endif\n\n  OpenCounter(+1);\n  return rc;\n}\n\n/*\n** Delete the named file.\n**\n** Note that Windows does not allow a file to be deleted if some other\n** process has it open.  Sometimes a virus scanner or indexing program\n** will open a journal file shortly after it is created in order to do\n** whatever it does.  While this other process is holding the\n** file open, we will be unable to delete it.  To work around this\n** problem, we delay 100 milliseconds and try to delete again.  Up\n** to MX_DELETION_ATTEMPTs deletion attempts are run before giving\n** up and returning an error.\n*/\nstatic int winDelete(\n  sqlite3_vfs *pVfs,          /* Not used on win32 */\n  const char *zFilename,      /* Name of file to delete */\n  int syncDir                 /* Not used on win32 */\n){\n  int cnt = 0;\n  int rc;\n  DWORD attr;\n  DWORD lastErrno = 0;\n  void *zConverted;\n  UNUSED_PARAMETER(pVfs);\n  UNUSED_PARAMETER(syncDir);\n\n  SimulateIOError(return SQLITE_IOERR_DELETE);\n  OSTRACE((\"DELETE name=%s, syncDir=%d\\n\", zFilename, syncDir));\n\n  zConverted = winConvertFromUtf8Filename(zFilename);\n  if( zConverted==0 ){\n    OSTRACE((\"DELETE name=%s, rc=SQLITE_IOERR_NOMEM\\n\", zFilename));\n    return SQLITE_IOERR_NOMEM_BKPT;\n  }\n  if( osIsNT() ){\n    do {\n#if SQLITE_OS_WINRT\n      WIN32_FILE_ATTRIBUTE_DATA sAttrData;\n      memset(&sAttrData, 0, sizeof(sAttrData));\n      if ( osGetFileAttributesExW(zConverted, GetFileExInfoStandard,\n                                  &sAttrData) ){\n        attr = sAttrData.dwFileAttributes;\n      }else{\n        lastErrno = osGetLastError();\n        if( lastErrno==ERROR_FILE_NOT_FOUND\n         || lastErrno==ERROR_PATH_NOT_FOUND ){\n          rc = SQLITE_IOERR_DELETE_NOENT; /* Already gone? */\n        }else{\n          rc = SQLITE_ERROR;\n        }\n        break;\n      }\n#else\n      attr = osGetFileAttributesW(zConverted);\n#endif\n      if ( attr==INVALID_FILE_ATTRIBUTES ){\n        lastErrno = osGetLastError();\n        if( lastErrno==ERROR_FILE_NOT_FOUND\n         || lastErrno==ERROR_PATH_NOT_FOUND ){\n          rc = SQLITE_IOERR_DELETE_NOENT; /* Already gone? */\n        }else{\n          rc = SQLITE_ERROR;\n        }\n        break;\n      }\n      if ( attr&FILE_ATTRIBUTE_DIRECTORY ){\n        rc = SQLITE_ERROR; /* Files only. */\n        break;\n      }\n      if ( osDeleteFileW(zConverted) ){\n        rc = SQLITE_OK; /* Deleted OK. */\n        break;\n      }\n      if ( !winRetryIoerr(&cnt, &lastErrno) ){\n        rc = SQLITE_ERROR; /* No more retries. */\n        break;\n      }\n    } while(1);\n  }\n#ifdef SQLITE_WIN32_HAS_ANSI\n  else{\n    do {\n      attr = osGetFileAttributesA(zConverted);\n      if ( attr==INVALID_FILE_ATTRIBUTES ){\n        lastErrno = osGetLastError();\n        if( lastErrno==ERROR_FILE_NOT_FOUND\n         || lastErrno==ERROR_PATH_NOT_FOUND ){\n          rc = SQLITE_IOERR_DELETE_NOENT; /* Already gone? */\n        }else{\n          rc = SQLITE_ERROR;\n        }\n        break;\n      }\n      if ( attr&FILE_ATTRIBUTE_DIRECTORY ){\n        rc = SQLITE_ERROR; /* Files only. */\n        break;\n      }\n      if ( osDeleteFileA(zConverted) ){\n        rc = SQLITE_OK; /* Deleted OK. */\n        break;\n      }\n      if ( !winRetryIoerr(&cnt, &lastErrno) ){\n        rc = SQLITE_ERROR; /* No more retries. */\n        break;\n      }\n    } while(1);\n  }\n#endif\n  if( rc && rc!=SQLITE_IOERR_DELETE_NOENT ){\n    rc = winLogError(SQLITE_IOERR_DELETE, lastErrno, \"winDelete\", zFilename);\n  }else{\n    winLogIoerr(cnt, __LINE__);\n  }\n  sqlite3_free(zConverted);\n  OSTRACE((\"DELETE name=%s, rc=%s\\n\", zFilename, sqlite3ErrName(rc)));\n  return rc;\n}\n\n/*\n** Check the existence and status of a file.\n*/\nstatic int winAccess(\n  sqlite3_vfs *pVfs,         /* Not used on win32 */\n  const char *zFilename,     /* Name of file to check */\n  int flags,                 /* Type of test to make on this file */\n  int *pResOut               /* OUT: Result */\n){\n  DWORD attr;\n  int rc = 0;\n  DWORD lastErrno = 0;\n  void *zConverted;\n  UNUSED_PARAMETER(pVfs);\n\n  SimulateIOError( return SQLITE_IOERR_ACCESS; );\n  OSTRACE((\"ACCESS name=%s, flags=%x, pResOut=%p\\n\",\n           zFilename, flags, pResOut));\n\n  zConverted = winConvertFromUtf8Filename(zFilename);\n  if( zConverted==0 ){\n    OSTRACE((\"ACCESS name=%s, rc=SQLITE_IOERR_NOMEM\\n\", zFilename));\n    return SQLITE_IOERR_NOMEM_BKPT;\n  }\n  if( osIsNT() ){\n    int cnt = 0;\n    WIN32_FILE_ATTRIBUTE_DATA sAttrData;\n    memset(&sAttrData, 0, sizeof(sAttrData));\n    while( !(rc = osGetFileAttributesExW((LPCWSTR)zConverted,\n                             GetFileExInfoStandard,\n                             &sAttrData)) && winRetryIoerr(&cnt, &lastErrno) ){}\n    if( rc ){\n      /* For an SQLITE_ACCESS_EXISTS query, treat a zero-length file\n      ** as if it does not exist.\n      */\n      if(    flags==SQLITE_ACCESS_EXISTS\n          && sAttrData.nFileSizeHigh==0\n          && sAttrData.nFileSizeLow==0 ){\n        attr = INVALID_FILE_ATTRIBUTES;\n      }else{\n        attr = sAttrData.dwFileAttributes;\n      }\n    }else{\n      winLogIoerr(cnt, __LINE__);\n      if( lastErrno!=ERROR_FILE_NOT_FOUND && lastErrno!=ERROR_PATH_NOT_FOUND ){\n        sqlite3_free(zConverted);\n        return winLogError(SQLITE_IOERR_ACCESS, lastErrno, \"winAccess\",\n                           zFilename);\n      }else{\n        attr = INVALID_FILE_ATTRIBUTES;\n      }\n    }\n  }\n#ifdef SQLITE_WIN32_HAS_ANSI\n  else{\n    attr = osGetFileAttributesA((char*)zConverted);\n  }\n#endif\n  sqlite3_free(zConverted);\n  switch( flags ){\n    case SQLITE_ACCESS_READ:\n    case SQLITE_ACCESS_EXISTS:\n      rc = attr!=INVALID_FILE_ATTRIBUTES;\n      break;\n    case SQLITE_ACCESS_READWRITE:\n      rc = attr!=INVALID_FILE_ATTRIBUTES &&\n             (attr & FILE_ATTRIBUTE_READONLY)==0;\n      break;\n    default:\n      assert(!\"Invalid flags argument\");\n  }\n  *pResOut = rc;\n  OSTRACE((\"ACCESS name=%s, pResOut=%p, *pResOut=%d, rc=SQLITE_OK\\n\",\n           zFilename, pResOut, *pResOut));\n  return SQLITE_OK;\n}\n\n/*\n** Returns non-zero if the specified path name starts with a drive letter\n** followed by a colon character.\n*/\nstatic BOOL winIsDriveLetterAndColon(\n  const char *zPathname\n){\n  return ( sqlite3Isalpha(zPathname[0]) && zPathname[1]==':' );\n}\n\n/*\n** Returns non-zero if the specified path name should be used verbatim.  If\n** non-zero is returned from this function, the calling function must simply\n** use the provided path name verbatim -OR- resolve it into a full path name\n** using the GetFullPathName Win32 API function (if available).\n*/\nstatic BOOL winIsVerbatimPathname(\n  const char *zPathname\n){\n  /*\n  ** If the path name starts with a forward slash or a backslash, it is either\n  ** a legal UNC name, a volume relative path, or an absolute path name in the\n  ** \"Unix\" format on Windows.  There is no easy way to differentiate between\n  ** the final two cases; therefore, we return the safer return value of TRUE\n  ** so that callers of this function will simply use it verbatim.\n  */\n  if ( winIsDirSep(zPathname[0]) ){\n    return TRUE;\n  }\n\n  /*\n  ** If the path name starts with a letter and a colon it is either a volume\n  ** relative path or an absolute path.  Callers of this function must not\n  ** attempt to treat it as a relative path name (i.e. they should simply use\n  ** it verbatim).\n  */\n  if ( winIsDriveLetterAndColon(zPathname) ){\n    return TRUE;\n  }\n\n  /*\n  ** If we get to this point, the path name should almost certainly be a purely\n  ** relative one (i.e. not a UNC name, not absolute, and not volume relative).\n  */\n  return FALSE;\n}\n\n/*\n** Turn a relative pathname into a full pathname.  Write the full\n** pathname into zOut[].  zOut[] will be at least pVfs->mxPathname\n** bytes in size.\n*/\nstatic int winFullPathname(\n  sqlite3_vfs *pVfs,            /* Pointer to vfs object */\n  const char *zRelative,        /* Possibly relative input path */\n  int nFull,                    /* Size of output buffer in bytes */\n  char *zFull                   /* Output buffer */\n){\n#if !SQLITE_OS_WINCE && !SQLITE_OS_WINRT && !defined(__CYGWIN__)\n  DWORD nByte;\n  void *zConverted;\n  char *zOut;\n#endif\n\n  /* If this path name begins with \"/X:\", where \"X\" is any alphabetic\n  ** character, discard the initial \"/\" from the pathname.\n  */\n  if( zRelative[0]=='/' && winIsDriveLetterAndColon(zRelative+1) ){\n    zRelative++;\n  }\n\n#if defined(__CYGWIN__)\n  SimulateIOError( return SQLITE_ERROR );\n  UNUSED_PARAMETER(nFull);\n  assert( nFull>=pVfs->mxPathname );\n  if ( sqlite3_data_directory && !winIsVerbatimPathname(zRelative) ){\n    /*\n    ** NOTE: We are dealing with a relative path name and the data\n    **       directory has been set.  Therefore, use it as the basis\n    **       for converting the relative path name to an absolute\n    **       one by prepending the data directory and a slash.\n    */\n    char *zOut = sqlite3MallocZero( pVfs->mxPathname+1 );\n    if( !zOut ){\n      return SQLITE_IOERR_NOMEM_BKPT;\n    }\n    if( cygwin_conv_path(\n            (osIsNT() ? CCP_POSIX_TO_WIN_W : CCP_POSIX_TO_WIN_A) |\n            CCP_RELATIVE, zRelative, zOut, pVfs->mxPathname+1)<0 ){\n      sqlite3_free(zOut);\n      return winLogError(SQLITE_CANTOPEN_CONVPATH, (DWORD)errno,\n                         \"winFullPathname1\", zRelative);\n    }else{\n      char *zUtf8 = winConvertToUtf8Filename(zOut);\n      if( !zUtf8 ){\n        sqlite3_free(zOut);\n        return SQLITE_IOERR_NOMEM_BKPT;\n      }\n      sqlite3_snprintf(MIN(nFull, pVfs->mxPathname), zFull, \"%s%c%s\",\n                       sqlite3_data_directory, winGetDirSep(), zUtf8);\n      sqlite3_free(zUtf8);\n      sqlite3_free(zOut);\n    }\n  }else{\n    char *zOut = sqlite3MallocZero( pVfs->mxPathname+1 );\n    if( !zOut ){\n      return SQLITE_IOERR_NOMEM_BKPT;\n    }\n    if( cygwin_conv_path(\n            (osIsNT() ? CCP_POSIX_TO_WIN_W : CCP_POSIX_TO_WIN_A),\n            zRelative, zOut, pVfs->mxPathname+1)<0 ){\n      sqlite3_free(zOut);\n      return winLogError(SQLITE_CANTOPEN_CONVPATH, (DWORD)errno,\n                         \"winFullPathname2\", zRelative);\n    }else{\n      char *zUtf8 = winConvertToUtf8Filename(zOut);\n      if( !zUtf8 ){\n        sqlite3_free(zOut);\n        return SQLITE_IOERR_NOMEM_BKPT;\n      }\n      sqlite3_snprintf(MIN(nFull, pVfs->mxPathname), zFull, \"%s\", zUtf8);\n      sqlite3_free(zUtf8);\n      sqlite3_free(zOut);\n    }\n  }\n  return SQLITE_OK;\n#endif\n\n#if (SQLITE_OS_WINCE || SQLITE_OS_WINRT) && !defined(__CYGWIN__)\n  SimulateIOError( return SQLITE_ERROR );\n  /* WinCE has no concept of a relative pathname, or so I am told. */\n  /* WinRT has no way to convert a relative path to an absolute one. */\n  if ( sqlite3_data_directory && !winIsVerbatimPathname(zRelative) ){\n    /*\n    ** NOTE: We are dealing with a relative path name and the data\n    **       directory has been set.  Therefore, use it as the basis\n    **       for converting the relative path name to an absolute\n    **       one by prepending the data directory and a backslash.\n    */\n    sqlite3_snprintf(MIN(nFull, pVfs->mxPathname), zFull, \"%s%c%s\",\n                     sqlite3_data_directory, winGetDirSep(), zRelative);\n  }else{\n    sqlite3_snprintf(MIN(nFull, pVfs->mxPathname), zFull, \"%s\", zRelative);\n  }\n  return SQLITE_OK;\n#endif\n\n#if !SQLITE_OS_WINCE && !SQLITE_OS_WINRT && !defined(__CYGWIN__)\n  /* It's odd to simulate an io-error here, but really this is just\n  ** using the io-error infrastructure to test that SQLite handles this\n  ** function failing. This function could fail if, for example, the\n  ** current working directory has been unlinked.\n  */\n  SimulateIOError( return SQLITE_ERROR );\n  if ( sqlite3_data_directory && !winIsVerbatimPathname(zRelative) ){\n    /*\n    ** NOTE: We are dealing with a relative path name and the data\n    **       directory has been set.  Therefore, use it as the basis\n    **       for converting the relative path name to an absolute\n    **       one by prepending the data directory and a backslash.\n    */\n    sqlite3_snprintf(MIN(nFull, pVfs->mxPathname), zFull, \"%s%c%s\",\n                     sqlite3_data_directory, winGetDirSep(), zRelative);\n    return SQLITE_OK;\n  }\n  zConverted = winConvertFromUtf8Filename(zRelative);\n  if( zConverted==0 ){\n    return SQLITE_IOERR_NOMEM_BKPT;\n  }\n  if( osIsNT() ){\n    LPWSTR zTemp;\n    nByte = osGetFullPathNameW((LPCWSTR)zConverted, 0, 0, 0);\n    if( nByte==0 ){\n      sqlite3_free(zConverted);\n      return winLogError(SQLITE_CANTOPEN_FULLPATH, osGetLastError(),\n                         \"winFullPathname1\", zRelative);\n    }\n    nByte += 3;\n    zTemp = sqlite3MallocZero( nByte*sizeof(zTemp[0]) );\n    if( zTemp==0 ){\n      sqlite3_free(zConverted);\n      return SQLITE_IOERR_NOMEM_BKPT;\n    }\n    nByte = osGetFullPathNameW((LPCWSTR)zConverted, nByte, zTemp, 0);\n    if( nByte==0 ){\n      sqlite3_free(zConverted);\n      sqlite3_free(zTemp);\n      return winLogError(SQLITE_CANTOPEN_FULLPATH, osGetLastError(),\n                         \"winFullPathname2\", zRelative);\n    }\n    sqlite3_free(zConverted);\n    zOut = winUnicodeToUtf8(zTemp);\n    sqlite3_free(zTemp);\n  }\n#ifdef SQLITE_WIN32_HAS_ANSI\n  else{\n    char *zTemp;\n    nByte = osGetFullPathNameA((char*)zConverted, 0, 0, 0);\n    if( nByte==0 ){\n      sqlite3_free(zConverted);\n      return winLogError(SQLITE_CANTOPEN_FULLPATH, osGetLastError(),\n                         \"winFullPathname3\", zRelative);\n    }\n    nByte += 3;\n    zTemp = sqlite3MallocZero( nByte*sizeof(zTemp[0]) );\n    if( zTemp==0 ){\n      sqlite3_free(zConverted);\n      return SQLITE_IOERR_NOMEM_BKPT;\n    }\n    nByte = osGetFullPathNameA((char*)zConverted, nByte, zTemp, 0);\n    if( nByte==0 ){\n      sqlite3_free(zConverted);\n      sqlite3_free(zTemp);\n      return winLogError(SQLITE_CANTOPEN_FULLPATH, osGetLastError(),\n                         \"winFullPathname4\", zRelative);\n    }\n    sqlite3_free(zConverted);\n    zOut = winMbcsToUtf8(zTemp, osAreFileApisANSI());\n    sqlite3_free(zTemp);\n  }\n#endif\n  if( zOut ){\n    sqlite3_snprintf(MIN(nFull, pVfs->mxPathname), zFull, \"%s\", zOut);\n    sqlite3_free(zOut);\n    return SQLITE_OK;\n  }else{\n    return SQLITE_IOERR_NOMEM_BKPT;\n  }\n#endif\n}\n\n#ifndef SQLITE_OMIT_LOAD_EXTENSION\n/*\n** Interfaces for opening a shared library, finding entry points\n** within the shared library, and closing the shared library.\n*/\nstatic void *winDlOpen(sqlite3_vfs *pVfs, const char *zFilename){\n  HANDLE h;\n#if defined(__CYGWIN__)\n  int nFull = pVfs->mxPathname+1;\n  char *zFull = sqlite3MallocZero( nFull );\n  void *zConverted = 0;\n  if( zFull==0 ){\n    OSTRACE((\"DLOPEN name=%s, handle=%p\\n\", zFilename, (void*)0));\n    return 0;\n  }\n  if( winFullPathname(pVfs, zFilename, nFull, zFull)!=SQLITE_OK ){\n    sqlite3_free(zFull);\n    OSTRACE((\"DLOPEN name=%s, handle=%p\\n\", zFilename, (void*)0));\n    return 0;\n  }\n  zConverted = winConvertFromUtf8Filename(zFull);\n  sqlite3_free(zFull);\n#else\n  void *zConverted = winConvertFromUtf8Filename(zFilename);\n  UNUSED_PARAMETER(pVfs);\n#endif\n  if( zConverted==0 ){\n    OSTRACE((\"DLOPEN name=%s, handle=%p\\n\", zFilename, (void*)0));\n    return 0;\n  }\n  if( osIsNT() ){\n#if SQLITE_OS_WINRT\n    h = osLoadPackagedLibrary((LPCWSTR)zConverted, 0);\n#else\n    h = osLoadLibraryW((LPCWSTR)zConverted);\n#endif\n  }\n#ifdef SQLITE_WIN32_HAS_ANSI\n  else{\n    h = osLoadLibraryA((char*)zConverted);\n  }\n#endif\n  OSTRACE((\"DLOPEN name=%s, handle=%p\\n\", zFilename, (void*)h));\n  sqlite3_free(zConverted);\n  return (void*)h;\n}\nstatic void winDlError(sqlite3_vfs *pVfs, int nBuf, char *zBufOut){\n  UNUSED_PARAMETER(pVfs);\n  winGetLastErrorMsg(osGetLastError(), nBuf, zBufOut);\n}\nstatic void (*winDlSym(sqlite3_vfs *pVfs,void *pH,const char *zSym))(void){\n  FARPROC proc;\n  UNUSED_PARAMETER(pVfs);\n  proc = osGetProcAddressA((HANDLE)pH, zSym);\n  OSTRACE((\"DLSYM handle=%p, symbol=%s, address=%p\\n\",\n           (void*)pH, zSym, (void*)proc));\n  return (void(*)(void))proc;\n}\nstatic void winDlClose(sqlite3_vfs *pVfs, void *pHandle){\n  UNUSED_PARAMETER(pVfs);\n  osFreeLibrary((HANDLE)pHandle);\n  OSTRACE((\"DLCLOSE handle=%p\\n\", (void*)pHandle));\n}\n#else /* if SQLITE_OMIT_LOAD_EXTENSION is defined: */\n  #define winDlOpen  0\n  #define winDlError 0\n  #define winDlSym   0\n  #define winDlClose 0\n#endif\n\n/* State information for the randomness gatherer. */\ntypedef struct EntropyGatherer EntropyGatherer;\nstruct EntropyGatherer {\n  unsigned char *a;   /* Gather entropy into this buffer */\n  int na;             /* Size of a[] in bytes */\n  int i;              /* XOR next input into a[i] */\n  int nXor;           /* Number of XOR operations done */\n};\n\n#if !defined(SQLITE_TEST) && !defined(SQLITE_OMIT_RANDOMNESS)\n/* Mix sz bytes of entropy into p. */\nstatic void xorMemory(EntropyGatherer *p, unsigned char *x, int sz){\n  int j, k;\n  for(j=0, k=p->i; j<sz; j++){\n    p->a[k++] ^= x[j];\n    if( k>=p->na ) k = 0;\n  }\n  p->i = k;\n  p->nXor += sz;\n}\n#endif /* !defined(SQLITE_TEST) && !defined(SQLITE_OMIT_RANDOMNESS) */\n\n/*\n** Write up to nBuf bytes of randomness into zBuf.\n*/\nstatic int winRandomness(sqlite3_vfs *pVfs, int nBuf, char *zBuf){\n#if defined(SQLITE_TEST) || defined(SQLITE_OMIT_RANDOMNESS)\n  UNUSED_PARAMETER(pVfs);\n  memset(zBuf, 0, nBuf);\n  return nBuf;\n#else\n  EntropyGatherer e;\n  UNUSED_PARAMETER(pVfs);\n  memset(zBuf, 0, nBuf);\n  e.a = (unsigned char*)zBuf;\n  e.na = nBuf;\n  e.nXor = 0;\n  e.i = 0;\n  {\n    SYSTEMTIME x;\n    osGetSystemTime(&x);\n    xorMemory(&e, (unsigned char*)&x, sizeof(SYSTEMTIME));\n  }\n  {\n    DWORD pid = osGetCurrentProcessId();\n    xorMemory(&e, (unsigned char*)&pid, sizeof(DWORD));\n  }\n#if SQLITE_OS_WINRT\n  {\n    ULONGLONG cnt = osGetTickCount64();\n    xorMemory(&e, (unsigned char*)&cnt, sizeof(ULONGLONG));\n  }\n#else\n  {\n    DWORD cnt = osGetTickCount();\n    xorMemory(&e, (unsigned char*)&cnt, sizeof(DWORD));\n  }\n#endif /* SQLITE_OS_WINRT */\n  {\n    LARGE_INTEGER i;\n    osQueryPerformanceCounter(&i);\n    xorMemory(&e, (unsigned char*)&i, sizeof(LARGE_INTEGER));\n  }\n#if !SQLITE_OS_WINCE && !SQLITE_OS_WINRT && SQLITE_WIN32_USE_UUID\n  {\n    UUID id;\n    memset(&id, 0, sizeof(UUID));\n    osUuidCreate(&id);\n    xorMemory(&e, (unsigned char*)&id, sizeof(UUID));\n    memset(&id, 0, sizeof(UUID));\n    osUuidCreateSequential(&id);\n    xorMemory(&e, (unsigned char*)&id, sizeof(UUID));\n  }\n#endif /* !SQLITE_OS_WINCE && !SQLITE_OS_WINRT && SQLITE_WIN32_USE_UUID */\n  return e.nXor>nBuf ? nBuf : e.nXor;\n#endif /* defined(SQLITE_TEST) || defined(SQLITE_OMIT_RANDOMNESS) */\n}\n\n\n/*\n** Sleep for a little while.  Return the amount of time slept.\n*/\nstatic int winSleep(sqlite3_vfs *pVfs, int microsec){\n  sqlite3_win32_sleep((microsec+999)/1000);\n  UNUSED_PARAMETER(pVfs);\n  return ((microsec+999)/1000)*1000;\n}\n\n/*\n** The following variable, if set to a non-zero value, is interpreted as\n** the number of seconds since 1970 and is used to set the result of\n** sqlite3OsCurrentTime() during testing.\n*/\n#ifdef SQLITE_TEST\nSQLITE_API int sqlite3_current_time = 0;  /* Fake system time in seconds since 1970. */\n#endif\n\n/*\n** Find the current time (in Universal Coordinated Time).  Write into *piNow\n** the current time and date as a Julian Day number times 86_400_000.  In\n** other words, write into *piNow the number of milliseconds since the Julian\n** epoch of noon in Greenwich on November 24, 4714 B.C according to the\n** proleptic Gregorian calendar.\n**\n** On success, return SQLITE_OK.  Return SQLITE_ERROR if the time and date\n** cannot be found.\n*/\nstatic int winCurrentTimeInt64(sqlite3_vfs *pVfs, sqlite3_int64 *piNow){\n  /* FILETIME structure is a 64-bit value representing the number of\n     100-nanosecond intervals since January 1, 1601 (= JD 2305813.5).\n  */\n  FILETIME ft;\n  static const sqlite3_int64 winFiletimeEpoch = 23058135*(sqlite3_int64)8640000;\n#ifdef SQLITE_TEST\n  static const sqlite3_int64 unixEpoch = 24405875*(sqlite3_int64)8640000;\n#endif\n  /* 2^32 - to avoid use of LL and warnings in gcc */\n  static const sqlite3_int64 max32BitValue =\n      (sqlite3_int64)2000000000 + (sqlite3_int64)2000000000 +\n      (sqlite3_int64)294967296;\n\n#if SQLITE_OS_WINCE\n  SYSTEMTIME time;\n  osGetSystemTime(&time);\n  /* if SystemTimeToFileTime() fails, it returns zero. */\n  if (!osSystemTimeToFileTime(&time,&ft)){\n    return SQLITE_ERROR;\n  }\n#else\n  osGetSystemTimeAsFileTime( &ft );\n#endif\n\n  *piNow = winFiletimeEpoch +\n            ((((sqlite3_int64)ft.dwHighDateTime)*max32BitValue) +\n               (sqlite3_int64)ft.dwLowDateTime)/(sqlite3_int64)10000;\n\n#ifdef SQLITE_TEST\n  if( sqlite3_current_time ){\n    *piNow = 1000*(sqlite3_int64)sqlite3_current_time + unixEpoch;\n  }\n#endif\n  UNUSED_PARAMETER(pVfs);\n  return SQLITE_OK;\n}\n\n/*\n** Find the current time (in Universal Coordinated Time).  Write the\n** current time and date as a Julian Day number into *prNow and\n** return 0.  Return 1 if the time and date cannot be found.\n*/\nstatic int winCurrentTime(sqlite3_vfs *pVfs, double *prNow){\n  int rc;\n  sqlite3_int64 i;\n  rc = winCurrentTimeInt64(pVfs, &i);\n  if( !rc ){\n    *prNow = i/86400000.0;\n  }\n  return rc;\n}\n\n/*\n** The idea is that this function works like a combination of\n** GetLastError() and FormatMessage() on Windows (or errno and\n** strerror_r() on Unix). After an error is returned by an OS\n** function, SQLite calls this function with zBuf pointing to\n** a buffer of nBuf bytes. The OS layer should populate the\n** buffer with a nul-terminated UTF-8 encoded error message\n** describing the last IO error to have occurred within the calling\n** thread.\n**\n** If the error message is too large for the supplied buffer,\n** it should be truncated. The return value of xGetLastError\n** is zero if the error message fits in the buffer, or non-zero\n** otherwise (if the message was truncated). If non-zero is returned,\n** then it is not necessary to include the nul-terminator character\n** in the output buffer.\n**\n** Not supplying an error message will have no adverse effect\n** on SQLite. It is fine to have an implementation that never\n** returns an error message:\n**\n**   int xGetLastError(sqlite3_vfs *pVfs, int nBuf, char *zBuf){\n**     assert(zBuf[0]=='\\0');\n**     return 0;\n**   }\n**\n** However if an error message is supplied, it will be incorporated\n** by sqlite into the error message available to the user using\n** sqlite3_errmsg(), possibly making IO errors easier to debug.\n*/\nstatic int winGetLastError(sqlite3_vfs *pVfs, int nBuf, char *zBuf){\n  DWORD e = osGetLastError();\n  UNUSED_PARAMETER(pVfs);\n  if( nBuf>0 ) winGetLastErrorMsg(e, nBuf, zBuf);\n  return e;\n}\n\n/*\n** Initialize and deinitialize the operating system interface.\n*/\nSQLITE_API int sqlite3_os_init(void){\n  static sqlite3_vfs winVfs = {\n    3,                     /* iVersion */\n    sizeof(winFile),       /* szOsFile */\n    SQLITE_WIN32_MAX_PATH_BYTES, /* mxPathname */\n    0,                     /* pNext */\n    \"win32\",               /* zName */\n    &winAppData,           /* pAppData */\n    winOpen,               /* xOpen */\n    winDelete,             /* xDelete */\n    winAccess,             /* xAccess */\n    winFullPathname,       /* xFullPathname */\n    winDlOpen,             /* xDlOpen */\n    winDlError,            /* xDlError */\n    winDlSym,              /* xDlSym */\n    winDlClose,            /* xDlClose */\n    winRandomness,         /* xRandomness */\n    winSleep,              /* xSleep */\n    winCurrentTime,        /* xCurrentTime */\n    winGetLastError,       /* xGetLastError */\n    winCurrentTimeInt64,   /* xCurrentTimeInt64 */\n    winSetSystemCall,      /* xSetSystemCall */\n    winGetSystemCall,      /* xGetSystemCall */\n    winNextSystemCall,     /* xNextSystemCall */\n  };\n#if defined(SQLITE_WIN32_HAS_WIDE)\n  static sqlite3_vfs winLongPathVfs = {\n    3,                     /* iVersion */\n    sizeof(winFile),       /* szOsFile */\n    SQLITE_WINNT_MAX_PATH_BYTES, /* mxPathname */\n    0,                     /* pNext */\n    \"win32-longpath\",      /* zName */\n    &winAppData,           /* pAppData */\n    winOpen,               /* xOpen */\n    winDelete,             /* xDelete */\n    winAccess,             /* xAccess */\n    winFullPathname,       /* xFullPathname */\n    winDlOpen,             /* xDlOpen */\n    winDlError,            /* xDlError */\n    winDlSym,              /* xDlSym */\n    winDlClose,            /* xDlClose */\n    winRandomness,         /* xRandomness */\n    winSleep,              /* xSleep */\n    winCurrentTime,        /* xCurrentTime */\n    winGetLastError,       /* xGetLastError */\n    winCurrentTimeInt64,   /* xCurrentTimeInt64 */\n    winSetSystemCall,      /* xSetSystemCall */\n    winGetSystemCall,      /* xGetSystemCall */\n    winNextSystemCall,     /* xNextSystemCall */\n  };\n#endif\n  static sqlite3_vfs winNolockVfs = {\n    3,                     /* iVersion */\n    sizeof(winFile),       /* szOsFile */\n    SQLITE_WIN32_MAX_PATH_BYTES, /* mxPathname */\n    0,                     /* pNext */\n    \"win32-none\",          /* zName */\n    &winNolockAppData,     /* pAppData */\n    winOpen,               /* xOpen */\n    winDelete,             /* xDelete */\n    winAccess,             /* xAccess */\n    winFullPathname,       /* xFullPathname */\n    winDlOpen,             /* xDlOpen */\n    winDlError,            /* xDlError */\n    winDlSym,              /* xDlSym */\n    winDlClose,            /* xDlClose */\n    winRandomness,         /* xRandomness */\n    winSleep,              /* xSleep */\n    winCurrentTime,        /* xCurrentTime */\n    winGetLastError,       /* xGetLastError */\n    winCurrentTimeInt64,   /* xCurrentTimeInt64 */\n    winSetSystemCall,      /* xSetSystemCall */\n    winGetSystemCall,      /* xGetSystemCall */\n    winNextSystemCall,     /* xNextSystemCall */\n  };\n#if defined(SQLITE_WIN32_HAS_WIDE)\n  static sqlite3_vfs winLongPathNolockVfs = {\n    3,                     /* iVersion */\n    sizeof(winFile),       /* szOsFile */\n    SQLITE_WINNT_MAX_PATH_BYTES, /* mxPathname */\n    0,                     /* pNext */\n    \"win32-longpath-none\", /* zName */\n    &winNolockAppData,     /* pAppData */\n    winOpen,               /* xOpen */\n    winDelete,             /* xDelete */\n    winAccess,             /* xAccess */\n    winFullPathname,       /* xFullPathname */\n    winDlOpen,             /* xDlOpen */\n    winDlError,            /* xDlError */\n    winDlSym,              /* xDlSym */\n    winDlClose,            /* xDlClose */\n    winRandomness,         /* xRandomness */\n    winSleep,              /* xSleep */\n    winCurrentTime,        /* xCurrentTime */\n    winGetLastError,       /* xGetLastError */\n    winCurrentTimeInt64,   /* xCurrentTimeInt64 */\n    winSetSystemCall,      /* xSetSystemCall */\n    winGetSystemCall,      /* xGetSystemCall */\n    winNextSystemCall,     /* xNextSystemCall */\n  };\n#endif\n\n  /* Double-check that the aSyscall[] array has been constructed\n  ** correctly.  See ticket [bb3a86e890c8e96ab] */\n  assert( ArraySize(aSyscall)==80 );\n\n  /* get memory map allocation granularity */\n  memset(&winSysInfo, 0, sizeof(SYSTEM_INFO));\n#if SQLITE_OS_WINRT\n  osGetNativeSystemInfo(&winSysInfo);\n#else\n  osGetSystemInfo(&winSysInfo);\n#endif\n  assert( winSysInfo.dwAllocationGranularity>0 );\n  assert( winSysInfo.dwPageSize>0 );\n\n  sqlite3_vfs_register(&winVfs, 1);\n\n#if defined(SQLITE_WIN32_HAS_WIDE)\n  sqlite3_vfs_register(&winLongPathVfs, 0);\n#endif\n\n  sqlite3_vfs_register(&winNolockVfs, 0);\n\n#if defined(SQLITE_WIN32_HAS_WIDE)\n  sqlite3_vfs_register(&winLongPathNolockVfs, 0);\n#endif\n\n#ifndef SQLITE_OMIT_WAL\n  winBigLock = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_VFS1);\n#endif\n\n  return SQLITE_OK;\n}\n\nSQLITE_API int sqlite3_os_end(void){\n#if SQLITE_OS_WINRT\n  if( sleepObj!=NULL ){\n    osCloseHandle(sleepObj);\n    sleepObj = NULL;\n  }\n#endif\n\n#ifndef SQLITE_OMIT_WAL\n  winBigLock = 0;\n#endif\n\n  return SQLITE_OK;\n}\n\n#endif /* SQLITE_OS_WIN */\n\n/************** End of os_win.c **********************************************/\n/************** Begin file memdb.c *******************************************/\n/*\n** 2016-09-07\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n******************************************************************************\n**\n** This file implements an in-memory VFS. A database is held as a contiguous\n** block of memory.\n**\n** This file also implements interface sqlite3_serialize() and\n** sqlite3_deserialize().\n*/\n/* #include \"sqliteInt.h\" */\n#ifdef SQLITE_ENABLE_DESERIALIZE\n\n/*\n** Forward declaration of objects used by this utility\n*/\ntypedef struct sqlite3_vfs MemVfs;\ntypedef struct MemFile MemFile;\n\n/* Access to a lower-level VFS that (might) implement dynamic loading,\n** access to randomness, etc.\n*/\n#define ORIGVFS(p) ((sqlite3_vfs*)((p)->pAppData))\n\n/* An open file */\nstruct MemFile {\n  sqlite3_file base;              /* IO methods */\n  sqlite3_int64 sz;               /* Size of the file */\n  sqlite3_int64 szAlloc;          /* Space allocated to aData */\n  sqlite3_int64 szMax;            /* Maximum allowed size of the file */\n  unsigned char *aData;           /* content of the file */\n  int nMmap;                      /* Number of memory mapped pages */\n  unsigned mFlags;                /* Flags */\n  int eLock;                      /* Most recent lock against this file */\n};\n\n/*\n** Methods for MemFile\n*/\nstatic int memdbClose(sqlite3_file*);\nstatic int memdbRead(sqlite3_file*, void*, int iAmt, sqlite3_int64 iOfst);\nstatic int memdbWrite(sqlite3_file*,const void*,int iAmt, sqlite3_int64 iOfst);\nstatic int memdbTruncate(sqlite3_file*, sqlite3_int64 size);\nstatic int memdbSync(sqlite3_file*, int flags);\nstatic int memdbFileSize(sqlite3_file*, sqlite3_int64 *pSize);\nstatic int memdbLock(sqlite3_file*, int);\n/* static int memdbCheckReservedLock(sqlite3_file*, int *pResOut);// not used */\nstatic int memdbFileControl(sqlite3_file*, int op, void *pArg);\n/* static int memdbSectorSize(sqlite3_file*); // not used */\nstatic int memdbDeviceCharacteristics(sqlite3_file*);\nstatic int memdbFetch(sqlite3_file*, sqlite3_int64 iOfst, int iAmt, void **pp);\nstatic int memdbUnfetch(sqlite3_file*, sqlite3_int64 iOfst, void *p);\n\n/*\n** Methods for MemVfs\n*/\nstatic int memdbOpen(sqlite3_vfs*, const char *, sqlite3_file*, int , int *);\n/* static int memdbDelete(sqlite3_vfs*, const char *zName, int syncDir); */\nstatic int memdbAccess(sqlite3_vfs*, const char *zName, int flags, int *);\nstatic int memdbFullPathname(sqlite3_vfs*, const char *zName, int, char *zOut);\nstatic void *memdbDlOpen(sqlite3_vfs*, const char *zFilename);\nstatic void memdbDlError(sqlite3_vfs*, int nByte, char *zErrMsg);\nstatic void (*memdbDlSym(sqlite3_vfs *pVfs, void *p, const char*zSym))(void);\nstatic void memdbDlClose(sqlite3_vfs*, void*);\nstatic int memdbRandomness(sqlite3_vfs*, int nByte, char *zOut);\nstatic int memdbSleep(sqlite3_vfs*, int microseconds);\n/* static int memdbCurrentTime(sqlite3_vfs*, double*); */\nstatic int memdbGetLastError(sqlite3_vfs*, int, char *);\nstatic int memdbCurrentTimeInt64(sqlite3_vfs*, sqlite3_int64*);\n\nstatic sqlite3_vfs memdb_vfs = {\n  2,                           /* iVersion */\n  0,                           /* szOsFile (set when registered) */\n  1024,                        /* mxPathname */\n  0,                           /* pNext */\n  \"memdb\",                     /* zName */\n  0,                           /* pAppData (set when registered) */ \n  memdbOpen,                   /* xOpen */\n  0, /* memdbDelete, */        /* xDelete */\n  memdbAccess,                 /* xAccess */\n  memdbFullPathname,           /* xFullPathname */\n  memdbDlOpen,                 /* xDlOpen */\n  memdbDlError,                /* xDlError */\n  memdbDlSym,                  /* xDlSym */\n  memdbDlClose,                /* xDlClose */\n  memdbRandomness,             /* xRandomness */\n  memdbSleep,                  /* xSleep */\n  0, /* memdbCurrentTime, */   /* xCurrentTime */\n  memdbGetLastError,           /* xGetLastError */\n  memdbCurrentTimeInt64        /* xCurrentTimeInt64 */\n};\n\nstatic const sqlite3_io_methods memdb_io_methods = {\n  3,                              /* iVersion */\n  memdbClose,                      /* xClose */\n  memdbRead,                       /* xRead */\n  memdbWrite,                      /* xWrite */\n  memdbTruncate,                   /* xTruncate */\n  memdbSync,                       /* xSync */\n  memdbFileSize,                   /* xFileSize */\n  memdbLock,                       /* xLock */\n  memdbLock,                       /* xUnlock - same as xLock in this case */ \n  0, /* memdbCheckReservedLock, */ /* xCheckReservedLock */\n  memdbFileControl,                /* xFileControl */\n  0, /* memdbSectorSize,*/         /* xSectorSize */\n  memdbDeviceCharacteristics,      /* xDeviceCharacteristics */\n  0,                               /* xShmMap */\n  0,                               /* xShmLock */\n  0,                               /* xShmBarrier */\n  0,                               /* xShmUnmap */\n  memdbFetch,                      /* xFetch */\n  memdbUnfetch                     /* xUnfetch */\n};\n\n\n\n/*\n** Close an memdb-file.\n**\n** The pData pointer is owned by the application, so there is nothing\n** to free.\n*/\nstatic int memdbClose(sqlite3_file *pFile){\n  MemFile *p = (MemFile *)pFile;\n  if( p->mFlags & SQLITE_DESERIALIZE_FREEONCLOSE ) sqlite3_free(p->aData);\n  return SQLITE_OK;\n}\n\n/*\n** Read data from an memdb-file.\n*/\nstatic int memdbRead(\n  sqlite3_file *pFile, \n  void *zBuf, \n  int iAmt, \n  sqlite_int64 iOfst\n){\n  MemFile *p = (MemFile *)pFile;\n  if( iOfst+iAmt>p->sz ){\n    memset(zBuf, 0, iAmt);\n    if( iOfst<p->sz ) memcpy(zBuf, p->aData+iOfst, p->sz - iOfst);\n    return SQLITE_IOERR_SHORT_READ;\n  }\n  memcpy(zBuf, p->aData+iOfst, iAmt);\n  return SQLITE_OK;\n}\n\n/*\n** Try to enlarge the memory allocation to hold at least sz bytes\n*/\nstatic int memdbEnlarge(MemFile *p, sqlite3_int64 newSz){\n  unsigned char *pNew;\n  if( (p->mFlags & SQLITE_DESERIALIZE_RESIZEABLE)==0 || p->nMmap>0 ){\n    return SQLITE_FULL;\n  }\n  if( newSz>p->szMax ){\n    return SQLITE_FULL;\n  }\n  newSz *= 2;\n  if( newSz>p->szMax ) newSz = p->szMax;\n  pNew = sqlite3_realloc64(p->aData, newSz);\n  if( pNew==0 ) return SQLITE_NOMEM;\n  p->aData = pNew;\n  p->szAlloc = newSz;\n  return SQLITE_OK;\n}\n\n/*\n** Write data to an memdb-file.\n*/\nstatic int memdbWrite(\n  sqlite3_file *pFile,\n  const void *z,\n  int iAmt,\n  sqlite_int64 iOfst\n){\n  MemFile *p = (MemFile *)pFile;\n  if( NEVER(p->mFlags & SQLITE_DESERIALIZE_READONLY) ) return SQLITE_READONLY;\n  if( iOfst+iAmt>p->sz ){\n    int rc;\n    if( iOfst+iAmt>p->szAlloc\n     && (rc = memdbEnlarge(p, iOfst+iAmt))!=SQLITE_OK\n    ){\n      return rc;\n    }\n    if( iOfst>p->sz ) memset(p->aData+p->sz, 0, iOfst-p->sz);\n    p->sz = iOfst+iAmt;\n  }\n  memcpy(p->aData+iOfst, z, iAmt);\n  return SQLITE_OK;\n}\n\n/*\n** Truncate an memdb-file.\n**\n** In rollback mode (which is always the case for memdb, as it does not\n** support WAL mode) the truncate() method is only used to reduce\n** the size of a file, never to increase the size.\n*/\nstatic int memdbTruncate(sqlite3_file *pFile, sqlite_int64 size){\n  MemFile *p = (MemFile *)pFile;\n  if( NEVER(size>p->sz) ) return SQLITE_FULL;\n  p->sz = size; \n  return SQLITE_OK;\n}\n\n/*\n** Sync an memdb-file.\n*/\nstatic int memdbSync(sqlite3_file *pFile, int flags){\n  return SQLITE_OK;\n}\n\n/*\n** Return the current file-size of an memdb-file.\n*/\nstatic int memdbFileSize(sqlite3_file *pFile, sqlite_int64 *pSize){\n  MemFile *p = (MemFile *)pFile;\n  *pSize = p->sz;\n  return SQLITE_OK;\n}\n\n/*\n** Lock an memdb-file.\n*/\nstatic int memdbLock(sqlite3_file *pFile, int eLock){\n  MemFile *p = (MemFile *)pFile;\n  if( eLock>SQLITE_LOCK_SHARED \n   && (p->mFlags & SQLITE_DESERIALIZE_READONLY)!=0\n  ){\n    return SQLITE_READONLY;\n  }\n  p->eLock = eLock;\n  return SQLITE_OK;\n}\n\n#if 0 /* Never used because memdbAccess() always returns false */\n/*\n** Check if another file-handle holds a RESERVED lock on an memdb-file.\n*/\nstatic int memdbCheckReservedLock(sqlite3_file *pFile, int *pResOut){\n  *pResOut = 0;\n  return SQLITE_OK;\n}\n#endif\n\n/*\n** File control method. For custom operations on an memdb-file.\n*/\nstatic int memdbFileControl(sqlite3_file *pFile, int op, void *pArg){\n  MemFile *p = (MemFile *)pFile;\n  int rc = SQLITE_NOTFOUND;\n  if( op==SQLITE_FCNTL_VFSNAME ){\n    *(char**)pArg = sqlite3_mprintf(\"memdb(%p,%lld)\", p->aData, p->sz);\n    rc = SQLITE_OK;\n  }\n  if( op==SQLITE_FCNTL_SIZE_LIMIT ){\n    sqlite3_int64 iLimit = *(sqlite3_int64*)pArg;\n    if( iLimit<p->sz ){\n      if( iLimit<0 ){\n        iLimit = p->szMax;\n      }else{\n        iLimit = p->sz;\n      }\n    }\n    p->szMax = iLimit;\n    *(sqlite3_int64*)pArg = iLimit;\n    rc = SQLITE_OK;\n  }\n  return rc;\n}\n\n#if 0  /* Not used because of SQLITE_IOCAP_POWERSAFE_OVERWRITE */\n/*\n** Return the sector-size in bytes for an memdb-file.\n*/\nstatic int memdbSectorSize(sqlite3_file *pFile){\n  return 1024;\n}\n#endif\n\n/*\n** Return the device characteristic flags supported by an memdb-file.\n*/\nstatic int memdbDeviceCharacteristics(sqlite3_file *pFile){\n  return SQLITE_IOCAP_ATOMIC | \n         SQLITE_IOCAP_POWERSAFE_OVERWRITE |\n         SQLITE_IOCAP_SAFE_APPEND |\n         SQLITE_IOCAP_SEQUENTIAL;\n}\n\n/* Fetch a page of a memory-mapped file */\nstatic int memdbFetch(\n  sqlite3_file *pFile,\n  sqlite3_int64 iOfst,\n  int iAmt,\n  void **pp\n){\n  MemFile *p = (MemFile *)pFile;\n  if( iOfst+iAmt>p->sz ){\n    *pp = 0;\n  }else{\n    p->nMmap++;\n    *pp = (void*)(p->aData + iOfst);\n  }\n  return SQLITE_OK;\n}\n\n/* Release a memory-mapped page */\nstatic int memdbUnfetch(sqlite3_file *pFile, sqlite3_int64 iOfst, void *pPage){\n  MemFile *p = (MemFile *)pFile;\n  p->nMmap--;\n  return SQLITE_OK;\n}\n\n/*\n** Open an mem file handle.\n*/\nstatic int memdbOpen(\n  sqlite3_vfs *pVfs,\n  const char *zName,\n  sqlite3_file *pFile,\n  int flags,\n  int *pOutFlags\n){\n  MemFile *p = (MemFile*)pFile;\n  if( (flags & SQLITE_OPEN_MAIN_DB)==0 ){\n    return ORIGVFS(pVfs)->xOpen(ORIGVFS(pVfs), zName, pFile, flags, pOutFlags);\n  }\n  memset(p, 0, sizeof(*p));\n  p->mFlags = SQLITE_DESERIALIZE_RESIZEABLE | SQLITE_DESERIALIZE_FREEONCLOSE;\n  assert( pOutFlags!=0 );  /* True because flags==SQLITE_OPEN_MAIN_DB */\n  *pOutFlags = flags | SQLITE_OPEN_MEMORY;\n  p->base.pMethods = &memdb_io_methods;\n  p->szMax = sqlite3GlobalConfig.mxMemdbSize;\n  return SQLITE_OK;\n}\n\n#if 0 /* Only used to delete rollback journals, master journals, and WAL\n      ** files, none of which exist in memdb.  So this routine is never used */\n/*\n** Delete the file located at zPath. If the dirSync argument is true,\n** ensure the file-system modifications are synced to disk before\n** returning.\n*/\nstatic int memdbDelete(sqlite3_vfs *pVfs, const char *zPath, int dirSync){\n  return SQLITE_IOERR_DELETE;\n}\n#endif\n\n/*\n** Test for access permissions. Return true if the requested permission\n** is available, or false otherwise.\n**\n** With memdb, no files ever exist on disk.  So always return false.\n*/\nstatic int memdbAccess(\n  sqlite3_vfs *pVfs, \n  const char *zPath, \n  int flags, \n  int *pResOut\n){\n  *pResOut = 0;\n  return SQLITE_OK;\n}\n\n/*\n** Populate buffer zOut with the full canonical pathname corresponding\n** to the pathname in zPath. zOut is guaranteed to point to a buffer\n** of at least (INST_MAX_PATHNAME+1) bytes.\n*/\nstatic int memdbFullPathname(\n  sqlite3_vfs *pVfs, \n  const char *zPath, \n  int nOut, \n  char *zOut\n){\n  sqlite3_snprintf(nOut, zOut, \"%s\", zPath);\n  return SQLITE_OK;\n}\n\n/*\n** Open the dynamic library located at zPath and return a handle.\n*/\nstatic void *memdbDlOpen(sqlite3_vfs *pVfs, const char *zPath){\n  return ORIGVFS(pVfs)->xDlOpen(ORIGVFS(pVfs), zPath);\n}\n\n/*\n** Populate the buffer zErrMsg (size nByte bytes) with a human readable\n** utf-8 string describing the most recent error encountered associated \n** with dynamic libraries.\n*/\nstatic void memdbDlError(sqlite3_vfs *pVfs, int nByte, char *zErrMsg){\n  ORIGVFS(pVfs)->xDlError(ORIGVFS(pVfs), nByte, zErrMsg);\n}\n\n/*\n** Return a pointer to the symbol zSymbol in the dynamic library pHandle.\n*/\nstatic void (*memdbDlSym(sqlite3_vfs *pVfs, void *p, const char *zSym))(void){\n  return ORIGVFS(pVfs)->xDlSym(ORIGVFS(pVfs), p, zSym);\n}\n\n/*\n** Close the dynamic library handle pHandle.\n*/\nstatic void memdbDlClose(sqlite3_vfs *pVfs, void *pHandle){\n  ORIGVFS(pVfs)->xDlClose(ORIGVFS(pVfs), pHandle);\n}\n\n/*\n** Populate the buffer pointed to by zBufOut with nByte bytes of \n** random data.\n*/\nstatic int memdbRandomness(sqlite3_vfs *pVfs, int nByte, char *zBufOut){\n  return ORIGVFS(pVfs)->xRandomness(ORIGVFS(pVfs), nByte, zBufOut);\n}\n\n/*\n** Sleep for nMicro microseconds. Return the number of microseconds \n** actually slept.\n*/\nstatic int memdbSleep(sqlite3_vfs *pVfs, int nMicro){\n  return ORIGVFS(pVfs)->xSleep(ORIGVFS(pVfs), nMicro);\n}\n\n#if 0  /* Never used.  Modern cores only call xCurrentTimeInt64() */\n/*\n** Return the current time as a Julian Day number in *pTimeOut.\n*/\nstatic int memdbCurrentTime(sqlite3_vfs *pVfs, double *pTimeOut){\n  return ORIGVFS(pVfs)->xCurrentTime(ORIGVFS(pVfs), pTimeOut);\n}\n#endif\n\nstatic int memdbGetLastError(sqlite3_vfs *pVfs, int a, char *b){\n  return ORIGVFS(pVfs)->xGetLastError(ORIGVFS(pVfs), a, b);\n}\nstatic int memdbCurrentTimeInt64(sqlite3_vfs *pVfs, sqlite3_int64 *p){\n  return ORIGVFS(pVfs)->xCurrentTimeInt64(ORIGVFS(pVfs), p);\n}\n\n/*\n** Translate a database connection pointer and schema name into a\n** MemFile pointer.\n*/\nstatic MemFile *memdbFromDbSchema(sqlite3 *db, const char *zSchema){\n  MemFile *p = 0;\n  int rc = sqlite3_file_control(db, zSchema, SQLITE_FCNTL_FILE_POINTER, &p);\n  if( rc ) return 0;\n  if( p->base.pMethods!=&memdb_io_methods ) return 0;\n  return p;\n}\n\n/*\n** Return the serialization of a database\n*/\nSQLITE_API unsigned char *sqlite3_serialize(\n  sqlite3 *db,              /* The database connection */\n  const char *zSchema,      /* Which database within the connection */\n  sqlite3_int64 *piSize,    /* Write size here, if not NULL */\n  unsigned int mFlags       /* Maybe SQLITE_SERIALIZE_NOCOPY */\n){\n  MemFile *p;\n  int iDb;\n  Btree *pBt;\n  sqlite3_int64 sz;\n  int szPage = 0;\n  sqlite3_stmt *pStmt = 0;\n  unsigned char *pOut;\n  char *zSql;\n  int rc;\n\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( !sqlite3SafetyCheckOk(db) ){\n    (void)SQLITE_MISUSE_BKPT;\n    return 0;\n  }\n#endif\n\n  if( zSchema==0 ) zSchema = db->aDb[0].zDbSName;\n  p = memdbFromDbSchema(db, zSchema);\n  iDb = sqlite3FindDbName(db, zSchema);\n  if( piSize ) *piSize = -1;\n  if( iDb<0 ) return 0;\n  if( p ){\n    if( piSize ) *piSize = p->sz;\n    if( mFlags & SQLITE_SERIALIZE_NOCOPY ){\n      pOut = p->aData;\n    }else{\n      pOut = sqlite3_malloc64( p->sz );\n      if( pOut ) memcpy(pOut, p->aData, p->sz);\n    }\n    return pOut;\n  }\n  pBt = db->aDb[iDb].pBt;\n  if( pBt==0 ) return 0;\n  szPage = sqlite3BtreeGetPageSize(pBt);\n  zSql = sqlite3_mprintf(\"PRAGMA \\\"%w\\\".page_count\", zSchema);\n  rc = zSql ? sqlite3_prepare_v2(db, zSql, -1, &pStmt, 0) : SQLITE_NOMEM;\n  sqlite3_free(zSql);\n  if( rc ) return 0;\n  rc = sqlite3_step(pStmt);\n  if( rc!=SQLITE_ROW ){\n    pOut = 0;\n  }else{\n    sz = sqlite3_column_int64(pStmt, 0)*szPage;\n    if( piSize ) *piSize = sz;\n    if( mFlags & SQLITE_SERIALIZE_NOCOPY ){\n      pOut = 0;\n    }else{\n      pOut = sqlite3_malloc64( sz );\n      if( pOut ){\n        int nPage = sqlite3_column_int(pStmt, 0);\n        Pager *pPager = sqlite3BtreePager(pBt);\n        int pgno;\n        for(pgno=1; pgno<=nPage; pgno++){\n          DbPage *pPage = 0;\n          unsigned char *pTo = pOut + szPage*(sqlite3_int64)(pgno-1);\n          rc = sqlite3PagerGet(pPager, pgno, (DbPage**)&pPage, 0);\n          if( rc==SQLITE_OK ){\n            memcpy(pTo, sqlite3PagerGetData(pPage), szPage);\n          }else{\n            memset(pTo, 0, szPage);\n          }\n          sqlite3PagerUnref(pPage);       \n        }\n      }\n    }\n  }\n  sqlite3_finalize(pStmt);\n  return pOut;\n}\n\n/* Convert zSchema to a MemDB and initialize its content.\n*/\nSQLITE_API int sqlite3_deserialize(\n  sqlite3 *db,            /* The database connection */\n  const char *zSchema,    /* Which DB to reopen with the deserialization */\n  unsigned char *pData,   /* The serialized database content */\n  sqlite3_int64 szDb,     /* Number bytes in the deserialization */\n  sqlite3_int64 szBuf,    /* Total size of buffer pData[] */\n  unsigned mFlags         /* Zero or more SQLITE_DESERIALIZE_* flags */\n){\n  MemFile *p;\n  char *zSql;\n  sqlite3_stmt *pStmt = 0;\n  int rc;\n  int iDb;\n\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( !sqlite3SafetyCheckOk(db) ){\n    return SQLITE_MISUSE_BKPT;\n  }\n  if( szDb<0 ) return SQLITE_MISUSE_BKPT;\n  if( szBuf<0 ) return SQLITE_MISUSE_BKPT;\n#endif\n\n  sqlite3_mutex_enter(db->mutex);\n  if( zSchema==0 ) zSchema = db->aDb[0].zDbSName;\n  iDb = sqlite3FindDbName(db, zSchema);\n  if( iDb<0 ){\n    rc = SQLITE_ERROR;\n    goto end_deserialize;\n  }    \n  zSql = sqlite3_mprintf(\"ATTACH x AS %Q\", zSchema);\n  rc = sqlite3_prepare_v2(db, zSql, -1, &pStmt, 0);\n  sqlite3_free(zSql);\n  if( rc ) goto end_deserialize;\n  db->init.iDb = (u8)iDb;\n  db->init.reopenMemdb = 1;\n  rc = sqlite3_step(pStmt);\n  db->init.reopenMemdb = 0;\n  if( rc!=SQLITE_DONE ){\n    rc = SQLITE_ERROR;\n    goto end_deserialize;\n  }\n  p = memdbFromDbSchema(db, zSchema);\n  if( p==0 ){\n    rc = SQLITE_ERROR;\n  }else{\n    p->aData = pData;\n    p->sz = szDb;\n    p->szAlloc = szBuf;\n    p->szMax = szBuf;\n    if( p->szMax<sqlite3GlobalConfig.mxMemdbSize ){\n      p->szMax = sqlite3GlobalConfig.mxMemdbSize;\n    }\n    p->mFlags = mFlags;\n    rc = SQLITE_OK;\n  }\n\nend_deserialize:\n  sqlite3_finalize(pStmt);\n  sqlite3_mutex_leave(db->mutex);\n  return rc;\n}\n\n/* \n** This routine is called when the extension is loaded.\n** Register the new VFS.\n*/\nSQLITE_PRIVATE int sqlite3MemdbInit(void){\n  sqlite3_vfs *pLower = sqlite3_vfs_find(0);\n  int sz = pLower->szOsFile;\n  memdb_vfs.pAppData = pLower;\n  /* In all known configurations of SQLite, the size of a default\n  ** sqlite3_file is greater than the size of a memdb sqlite3_file.\n  ** Should that ever change, remove the following NEVER() */\n  if( NEVER(sz<sizeof(MemFile)) ) sz = sizeof(MemFile);\n  memdb_vfs.szOsFile = sz;\n  return sqlite3_vfs_register(&memdb_vfs, 0);\n}\n#endif /* SQLITE_ENABLE_DESERIALIZE */\n\n/************** End of memdb.c ***********************************************/\n/************** Begin file bitvec.c ******************************************/\n/*\n** 2008 February 16\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This file implements an object that represents a fixed-length\n** bitmap.  Bits are numbered starting with 1.\n**\n** A bitmap is used to record which pages of a database file have been\n** journalled during a transaction, or which pages have the \"dont-write\"\n** property.  Usually only a few pages are meet either condition.\n** So the bitmap is usually sparse and has low cardinality.\n** But sometimes (for example when during a DROP of a large table) most\n** or all of the pages in a database can get journalled.  In those cases, \n** the bitmap becomes dense with high cardinality.  The algorithm needs \n** to handle both cases well.\n**\n** The size of the bitmap is fixed when the object is created.\n**\n** All bits are clear when the bitmap is created.  Individual bits\n** may be set or cleared one at a time.\n**\n** Test operations are about 100 times more common that set operations.\n** Clear operations are exceedingly rare.  There are usually between\n** 5 and 500 set operations per Bitvec object, though the number of sets can\n** sometimes grow into tens of thousands or larger.  The size of the\n** Bitvec object is the number of pages in the database file at the\n** start of a transaction, and is thus usually less than a few thousand,\n** but can be as large as 2 billion for a really big database.\n*/\n/* #include \"sqliteInt.h\" */\n\n/* Size of the Bitvec structure in bytes. */\n#define BITVEC_SZ        512\n\n/* Round the union size down to the nearest pointer boundary, since that's how \n** it will be aligned within the Bitvec struct. */\n#define BITVEC_USIZE \\\n    (((BITVEC_SZ-(3*sizeof(u32)))/sizeof(Bitvec*))*sizeof(Bitvec*))\n\n/* Type of the array \"element\" for the bitmap representation. \n** Should be a power of 2, and ideally, evenly divide into BITVEC_USIZE. \n** Setting this to the \"natural word\" size of your CPU may improve\n** performance. */\n#define BITVEC_TELEM     u8\n/* Size, in bits, of the bitmap element. */\n#define BITVEC_SZELEM    8\n/* Number of elements in a bitmap array. */\n#define BITVEC_NELEM     (BITVEC_USIZE/sizeof(BITVEC_TELEM))\n/* Number of bits in the bitmap array. */\n#define BITVEC_NBIT      (BITVEC_NELEM*BITVEC_SZELEM)\n\n/* Number of u32 values in hash table. */\n#define BITVEC_NINT      (BITVEC_USIZE/sizeof(u32))\n/* Maximum number of entries in hash table before \n** sub-dividing and re-hashing. */\n#define BITVEC_MXHASH    (BITVEC_NINT/2)\n/* Hashing function for the aHash representation.\n** Empirical testing showed that the *37 multiplier \n** (an arbitrary prime)in the hash function provided \n** no fewer collisions than the no-op *1. */\n#define BITVEC_HASH(X)   (((X)*1)%BITVEC_NINT)\n\n#define BITVEC_NPTR      (BITVEC_USIZE/sizeof(Bitvec *))\n\n\n/*\n** A bitmap is an instance of the following structure.\n**\n** This bitmap records the existence of zero or more bits\n** with values between 1 and iSize, inclusive.\n**\n** There are three possible representations of the bitmap.\n** If iSize<=BITVEC_NBIT, then Bitvec.u.aBitmap[] is a straight\n** bitmap.  The least significant bit is bit 1.\n**\n** If iSize>BITVEC_NBIT and iDivisor==0 then Bitvec.u.aHash[] is\n** a hash table that will hold up to BITVEC_MXHASH distinct values.\n**\n** Otherwise, the value i is redirected into one of BITVEC_NPTR\n** sub-bitmaps pointed to by Bitvec.u.apSub[].  Each subbitmap\n** handles up to iDivisor separate values of i.  apSub[0] holds\n** values between 1 and iDivisor.  apSub[1] holds values between\n** iDivisor+1 and 2*iDivisor.  apSub[N] holds values between\n** N*iDivisor+1 and (N+1)*iDivisor.  Each subbitmap is normalized\n** to hold deal with values between 1 and iDivisor.\n*/\nstruct Bitvec {\n  u32 iSize;      /* Maximum bit index.  Max iSize is 4,294,967,296. */\n  u32 nSet;       /* Number of bits that are set - only valid for aHash\n                  ** element.  Max is BITVEC_NINT.  For BITVEC_SZ of 512,\n                  ** this would be 125. */\n  u32 iDivisor;   /* Number of bits handled by each apSub[] entry. */\n                  /* Should >=0 for apSub element. */\n                  /* Max iDivisor is max(u32) / BITVEC_NPTR + 1.  */\n                  /* For a BITVEC_SZ of 512, this would be 34,359,739. */\n  union {\n    BITVEC_TELEM aBitmap[BITVEC_NELEM];    /* Bitmap representation */\n    u32 aHash[BITVEC_NINT];      /* Hash table representation */\n    Bitvec *apSub[BITVEC_NPTR];  /* Recursive representation */\n  } u;\n};\n\n/*\n** Create a new bitmap object able to handle bits between 0 and iSize,\n** inclusive.  Return a pointer to the new object.  Return NULL if \n** malloc fails.\n*/\nSQLITE_PRIVATE Bitvec *sqlite3BitvecCreate(u32 iSize){\n  Bitvec *p;\n  assert( sizeof(*p)==BITVEC_SZ );\n  p = sqlite3MallocZero( sizeof(*p) );\n  if( p ){\n    p->iSize = iSize;\n  }\n  return p;\n}\n\n/*\n** Check to see if the i-th bit is set.  Return true or false.\n** If p is NULL (if the bitmap has not been created) or if\n** i is out of range, then return false.\n*/\nSQLITE_PRIVATE int sqlite3BitvecTestNotNull(Bitvec *p, u32 i){\n  assert( p!=0 );\n  i--;\n  if( i>=p->iSize ) return 0;\n  while( p->iDivisor ){\n    u32 bin = i/p->iDivisor;\n    i = i%p->iDivisor;\n    p = p->u.apSub[bin];\n    if (!p) {\n      return 0;\n    }\n  }\n  if( p->iSize<=BITVEC_NBIT ){\n    return (p->u.aBitmap[i/BITVEC_SZELEM] & (1<<(i&(BITVEC_SZELEM-1))))!=0;\n  } else{\n    u32 h = BITVEC_HASH(i++);\n    while( p->u.aHash[h] ){\n      if( p->u.aHash[h]==i ) return 1;\n      h = (h+1) % BITVEC_NINT;\n    }\n    return 0;\n  }\n}\nSQLITE_PRIVATE int sqlite3BitvecTest(Bitvec *p, u32 i){\n  return p!=0 && sqlite3BitvecTestNotNull(p,i);\n}\n\n/*\n** Set the i-th bit.  Return 0 on success and an error code if\n** anything goes wrong.\n**\n** This routine might cause sub-bitmaps to be allocated.  Failing\n** to get the memory needed to hold the sub-bitmap is the only\n** that can go wrong with an insert, assuming p and i are valid.\n**\n** The calling function must ensure that p is a valid Bitvec object\n** and that the value for \"i\" is within range of the Bitvec object.\n** Otherwise the behavior is undefined.\n*/\nSQLITE_PRIVATE int sqlite3BitvecSet(Bitvec *p, u32 i){\n  u32 h;\n  if( p==0 ) return SQLITE_OK;\n  assert( i>0 );\n  assert( i<=p->iSize );\n  i--;\n  while((p->iSize > BITVEC_NBIT) && p->iDivisor) {\n    u32 bin = i/p->iDivisor;\n    i = i%p->iDivisor;\n    if( p->u.apSub[bin]==0 ){\n      p->u.apSub[bin] = sqlite3BitvecCreate( p->iDivisor );\n      if( p->u.apSub[bin]==0 ) return SQLITE_NOMEM_BKPT;\n    }\n    p = p->u.apSub[bin];\n  }\n  if( p->iSize<=BITVEC_NBIT ){\n    p->u.aBitmap[i/BITVEC_SZELEM] |= 1 << (i&(BITVEC_SZELEM-1));\n    return SQLITE_OK;\n  }\n  h = BITVEC_HASH(i++);\n  /* if there wasn't a hash collision, and this doesn't */\n  /* completely fill the hash, then just add it without */\n  /* worring about sub-dividing and re-hashing. */\n  if( !p->u.aHash[h] ){\n    if (p->nSet<(BITVEC_NINT-1)) {\n      goto bitvec_set_end;\n    } else {\n      goto bitvec_set_rehash;\n    }\n  }\n  /* there was a collision, check to see if it's already */\n  /* in hash, if not, try to find a spot for it */\n  do {\n    if( p->u.aHash[h]==i ) return SQLITE_OK;\n    h++;\n    if( h>=BITVEC_NINT ) h = 0;\n  } while( p->u.aHash[h] );\n  /* we didn't find it in the hash.  h points to the first */\n  /* available free spot. check to see if this is going to */\n  /* make our hash too \"full\".  */\nbitvec_set_rehash:\n  if( p->nSet>=BITVEC_MXHASH ){\n    unsigned int j;\n    int rc;\n    u32 *aiValues = sqlite3StackAllocRaw(0, sizeof(p->u.aHash));\n    if( aiValues==0 ){\n      return SQLITE_NOMEM_BKPT;\n    }else{\n      memcpy(aiValues, p->u.aHash, sizeof(p->u.aHash));\n      memset(p->u.apSub, 0, sizeof(p->u.apSub));\n      p->iDivisor = (p->iSize + BITVEC_NPTR - 1)/BITVEC_NPTR;\n      rc = sqlite3BitvecSet(p, i);\n      for(j=0; j<BITVEC_NINT; j++){\n        if( aiValues[j] ) rc |= sqlite3BitvecSet(p, aiValues[j]);\n      }\n      sqlite3StackFree(0, aiValues);\n      return rc;\n    }\n  }\nbitvec_set_end:\n  p->nSet++;\n  p->u.aHash[h] = i;\n  return SQLITE_OK;\n}\n\n/*\n** Clear the i-th bit.\n**\n** pBuf must be a pointer to at least BITVEC_SZ bytes of temporary storage\n** that BitvecClear can use to rebuilt its hash table.\n*/\nSQLITE_PRIVATE void sqlite3BitvecClear(Bitvec *p, u32 i, void *pBuf){\n  if( p==0 ) return;\n  assert( i>0 );\n  i--;\n  while( p->iDivisor ){\n    u32 bin = i/p->iDivisor;\n    i = i%p->iDivisor;\n    p = p->u.apSub[bin];\n    if (!p) {\n      return;\n    }\n  }\n  if( p->iSize<=BITVEC_NBIT ){\n    p->u.aBitmap[i/BITVEC_SZELEM] &= ~(1 << (i&(BITVEC_SZELEM-1)));\n  }else{\n    unsigned int j;\n    u32 *aiValues = pBuf;\n    memcpy(aiValues, p->u.aHash, sizeof(p->u.aHash));\n    memset(p->u.aHash, 0, sizeof(p->u.aHash));\n    p->nSet = 0;\n    for(j=0; j<BITVEC_NINT; j++){\n      if( aiValues[j] && aiValues[j]!=(i+1) ){\n        u32 h = BITVEC_HASH(aiValues[j]-1);\n        p->nSet++;\n        while( p->u.aHash[h] ){\n          h++;\n          if( h>=BITVEC_NINT ) h = 0;\n        }\n        p->u.aHash[h] = aiValues[j];\n      }\n    }\n  }\n}\n\n/*\n** Destroy a bitmap object.  Reclaim all memory used.\n*/\nSQLITE_PRIVATE void sqlite3BitvecDestroy(Bitvec *p){\n  if( p==0 ) return;\n  if( p->iDivisor ){\n    unsigned int i;\n    for(i=0; i<BITVEC_NPTR; i++){\n      sqlite3BitvecDestroy(p->u.apSub[i]);\n    }\n  }\n  sqlite3_free(p);\n}\n\n/*\n** Return the value of the iSize parameter specified when Bitvec *p\n** was created.\n*/\nSQLITE_PRIVATE u32 sqlite3BitvecSize(Bitvec *p){\n  return p->iSize;\n}\n\n#ifndef SQLITE_UNTESTABLE\n/*\n** Let V[] be an array of unsigned characters sufficient to hold\n** up to N bits.  Let I be an integer between 0 and N.  0<=I<N.\n** Then the following macros can be used to set, clear, or test\n** individual bits within V.\n*/\n#define SETBIT(V,I)      V[I>>3] |= (1<<(I&7))\n#define CLEARBIT(V,I)    V[I>>3] &= ~(1<<(I&7))\n#define TESTBIT(V,I)     (V[I>>3]&(1<<(I&7)))!=0\n\n/*\n** This routine runs an extensive test of the Bitvec code.\n**\n** The input is an array of integers that acts as a program\n** to test the Bitvec.  The integers are opcodes followed\n** by 0, 1, or 3 operands, depending on the opcode.  Another\n** opcode follows immediately after the last operand.\n**\n** There are 6 opcodes numbered from 0 through 5.  0 is the\n** \"halt\" opcode and causes the test to end.\n**\n**    0          Halt and return the number of errors\n**    1 N S X    Set N bits beginning with S and incrementing by X\n**    2 N S X    Clear N bits beginning with S and incrementing by X\n**    3 N        Set N randomly chosen bits\n**    4 N        Clear N randomly chosen bits\n**    5 N S X    Set N bits from S increment X in array only, not in bitvec\n**\n** The opcodes 1 through 4 perform set and clear operations are performed\n** on both a Bitvec object and on a linear array of bits obtained from malloc.\n** Opcode 5 works on the linear array only, not on the Bitvec.\n** Opcode 5 is used to deliberately induce a fault in order to\n** confirm that error detection works.\n**\n** At the conclusion of the test the linear array is compared\n** against the Bitvec object.  If there are any differences,\n** an error is returned.  If they are the same, zero is returned.\n**\n** If a memory allocation error occurs, return -1.\n*/\nSQLITE_PRIVATE int sqlite3BitvecBuiltinTest(int sz, int *aOp){\n  Bitvec *pBitvec = 0;\n  unsigned char *pV = 0;\n  int rc = -1;\n  int i, nx, pc, op;\n  void *pTmpSpace;\n\n  /* Allocate the Bitvec to be tested and a linear array of\n  ** bits to act as the reference */\n  pBitvec = sqlite3BitvecCreate( sz );\n  pV = sqlite3MallocZero( (sz+7)/8 + 1 );\n  pTmpSpace = sqlite3_malloc64(BITVEC_SZ);\n  if( pBitvec==0 || pV==0 || pTmpSpace==0  ) goto bitvec_end;\n\n  /* NULL pBitvec tests */\n  sqlite3BitvecSet(0, 1);\n  sqlite3BitvecClear(0, 1, pTmpSpace);\n\n  /* Run the program */\n  pc = 0;\n  while( (op = aOp[pc])!=0 ){\n    switch( op ){\n      case 1:\n      case 2:\n      case 5: {\n        nx = 4;\n        i = aOp[pc+2] - 1;\n        aOp[pc+2] += aOp[pc+3];\n        break;\n      }\n      case 3:\n      case 4: \n      default: {\n        nx = 2;\n        sqlite3_randomness(sizeof(i), &i);\n        break;\n      }\n    }\n    if( (--aOp[pc+1]) > 0 ) nx = 0;\n    pc += nx;\n    i = (i & 0x7fffffff)%sz;\n    if( (op & 1)!=0 ){\n      SETBIT(pV, (i+1));\n      if( op!=5 ){\n        if( sqlite3BitvecSet(pBitvec, i+1) ) goto bitvec_end;\n      }\n    }else{\n      CLEARBIT(pV, (i+1));\n      sqlite3BitvecClear(pBitvec, i+1, pTmpSpace);\n    }\n  }\n\n  /* Test to make sure the linear array exactly matches the\n  ** Bitvec object.  Start with the assumption that they do\n  ** match (rc==0).  Change rc to non-zero if a discrepancy\n  ** is found.\n  */\n  rc = sqlite3BitvecTest(0,0) + sqlite3BitvecTest(pBitvec, sz+1)\n          + sqlite3BitvecTest(pBitvec, 0)\n          + (sqlite3BitvecSize(pBitvec) - sz);\n  for(i=1; i<=sz; i++){\n    if(  (TESTBIT(pV,i))!=sqlite3BitvecTest(pBitvec,i) ){\n      rc = i;\n      break;\n    }\n  }\n\n  /* Free allocated structure */\nbitvec_end:\n  sqlite3_free(pTmpSpace);\n  sqlite3_free(pV);\n  sqlite3BitvecDestroy(pBitvec);\n  return rc;\n}\n#endif /* SQLITE_UNTESTABLE */\n\n/************** End of bitvec.c **********************************************/\n/************** Begin file pcache.c ******************************************/\n/*\n** 2008 August 05\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This file implements that page cache.\n*/\n/* #include \"sqliteInt.h\" */\n\n/*\n** A complete page cache is an instance of this structure.  Every\n** entry in the cache holds a single page of the database file.  The\n** btree layer only operates on the cached copy of the database pages.\n**\n** A page cache entry is \"clean\" if it exactly matches what is currently\n** on disk.  A page is \"dirty\" if it has been modified and needs to be\n** persisted to disk.\n**\n** pDirty, pDirtyTail, pSynced:\n**   All dirty pages are linked into the doubly linked list using\n**   PgHdr.pDirtyNext and pDirtyPrev. The list is maintained in LRU order\n**   such that p was added to the list more recently than p->pDirtyNext.\n**   PCache.pDirty points to the first (newest) element in the list and\n**   pDirtyTail to the last (oldest).\n**\n**   The PCache.pSynced variable is used to optimize searching for a dirty\n**   page to eject from the cache mid-transaction. It is better to eject\n**   a page that does not require a journal sync than one that does. \n**   Therefore, pSynced is maintained so that it *almost* always points\n**   to either the oldest page in the pDirty/pDirtyTail list that has a\n**   clear PGHDR_NEED_SYNC flag or to a page that is older than this one\n**   (so that the right page to eject can be found by following pDirtyPrev\n**   pointers).\n*/\nstruct PCache {\n  PgHdr *pDirty, *pDirtyTail;         /* List of dirty pages in LRU order */\n  PgHdr *pSynced;                     /* Last synced page in dirty page list */\n  int nRefSum;                        /* Sum of ref counts over all pages */\n  int szCache;                        /* Configured cache size */\n  int szSpill;                        /* Size before spilling occurs */\n  int szPage;                         /* Size of every page in this cache */\n  int szExtra;                        /* Size of extra space for each page */\n  u8 bPurgeable;                      /* True if pages are on backing store */\n  u8 eCreate;                         /* eCreate value for for xFetch() */\n  int (*xStress)(void*,PgHdr*);       /* Call to try make a page clean */\n  void *pStress;                      /* Argument to xStress */\n  sqlite3_pcache *pCache;             /* Pluggable cache module */\n};\n\n/********************************** Test and Debug Logic **********************/\n/*\n** Debug tracing macros.  Enable by by changing the \"0\" to \"1\" and\n** recompiling.\n**\n** When sqlite3PcacheTrace is 1, single line trace messages are issued.\n** When sqlite3PcacheTrace is 2, a dump of the pcache showing all cache entries\n** is displayed for many operations, resulting in a lot of output.\n*/\n#if defined(SQLITE_DEBUG) && 0\n  int sqlite3PcacheTrace = 2;       /* 0: off  1: simple  2: cache dumps */\n  int sqlite3PcacheMxDump = 9999;   /* Max cache entries for pcacheDump() */\n# define pcacheTrace(X) if(sqlite3PcacheTrace){sqlite3DebugPrintf X;}\n  void pcacheDump(PCache *pCache){\n    int N;\n    int i, j;\n    sqlite3_pcache_page *pLower;\n    PgHdr *pPg;\n    unsigned char *a;\n  \n    if( sqlite3PcacheTrace<2 ) return;\n    if( pCache->pCache==0 ) return;\n    N = sqlite3PcachePagecount(pCache);\n    if( N>sqlite3PcacheMxDump ) N = sqlite3PcacheMxDump;\n    for(i=1; i<=N; i++){\n       pLower = sqlite3GlobalConfig.pcache2.xFetch(pCache->pCache, i, 0);\n       if( pLower==0 ) continue;\n       pPg = (PgHdr*)pLower->pExtra;\n       printf(\"%3d: nRef %2d flgs %02x data \", i, pPg->nRef, pPg->flags);\n       a = (unsigned char *)pLower->pBuf;\n       for(j=0; j<12; j++) printf(\"%02x\", a[j]);\n       printf(\"\\n\");\n       if( pPg->pPage==0 ){\n         sqlite3GlobalConfig.pcache2.xUnpin(pCache->pCache, pLower, 0);\n       }\n    }\n  }\n  #else\n# define pcacheTrace(X)\n# define pcacheDump(X)\n#endif\n\n/*\n** Check invariants on a PgHdr entry.  Return true if everything is OK.\n** Return false if any invariant is violated.\n**\n** This routine is for use inside of assert() statements only.  For\n** example:\n**\n**          assert( sqlite3PcachePageSanity(pPg) );\n*/\n#ifdef SQLITE_DEBUG\nSQLITE_PRIVATE int sqlite3PcachePageSanity(PgHdr *pPg){\n  PCache *pCache;\n  assert( pPg!=0 );\n  assert( pPg->pgno>0 || pPg->pPager==0 );    /* Page number is 1 or more */\n  pCache = pPg->pCache;\n  assert( pCache!=0 );      /* Every page has an associated PCache */\n  if( pPg->flags & PGHDR_CLEAN ){\n    assert( (pPg->flags & PGHDR_DIRTY)==0 );/* Cannot be both CLEAN and DIRTY */\n    assert( pCache->pDirty!=pPg );          /* CLEAN pages not on dirty list */\n    assert( pCache->pDirtyTail!=pPg );\n  }\n  /* WRITEABLE pages must also be DIRTY */\n  if( pPg->flags & PGHDR_WRITEABLE ){\n    assert( pPg->flags & PGHDR_DIRTY );     /* WRITEABLE implies DIRTY */\n  }\n  /* NEED_SYNC can be set independently of WRITEABLE.  This can happen,\n  ** for example, when using the sqlite3PagerDontWrite() optimization:\n  **    (1)  Page X is journalled, and gets WRITEABLE and NEED_SEEK.\n  **    (2)  Page X moved to freelist, WRITEABLE is cleared\n  **    (3)  Page X reused, WRITEABLE is set again\n  ** If NEED_SYNC had been cleared in step 2, then it would not be reset\n  ** in step 3, and page might be written into the database without first\n  ** syncing the rollback journal, which might cause corruption on a power\n  ** loss.\n  **\n  ** Another example is when the database page size is smaller than the\n  ** disk sector size.  When any page of a sector is journalled, all pages\n  ** in that sector are marked NEED_SYNC even if they are still CLEAN, just\n  ** in case they are later modified, since all pages in the same sector\n  ** must be journalled and synced before any of those pages can be safely\n  ** written.\n  */\n  return 1;\n}\n#endif /* SQLITE_DEBUG */\n\n\n/********************************** Linked List Management ********************/\n\n/* Allowed values for second argument to pcacheManageDirtyList() */\n#define PCACHE_DIRTYLIST_REMOVE   1    /* Remove pPage from dirty list */\n#define PCACHE_DIRTYLIST_ADD      2    /* Add pPage to the dirty list */\n#define PCACHE_DIRTYLIST_FRONT    3    /* Move pPage to the front of the list */\n\n/*\n** Manage pPage's participation on the dirty list.  Bits of the addRemove\n** argument determines what operation to do.  The 0x01 bit means first\n** remove pPage from the dirty list.  The 0x02 means add pPage back to\n** the dirty list.  Doing both moves pPage to the front of the dirty list.\n*/\nstatic void pcacheManageDirtyList(PgHdr *pPage, u8 addRemove){\n  PCache *p = pPage->pCache;\n\n  pcacheTrace((\"%p.DIRTYLIST.%s %d\\n\", p,\n                addRemove==1 ? \"REMOVE\" : addRemove==2 ? \"ADD\" : \"FRONT\",\n                pPage->pgno));\n  if( addRemove & PCACHE_DIRTYLIST_REMOVE ){\n    assert( pPage->pDirtyNext || pPage==p->pDirtyTail );\n    assert( pPage->pDirtyPrev || pPage==p->pDirty );\n  \n    /* Update the PCache1.pSynced variable if necessary. */\n    if( p->pSynced==pPage ){\n      p->pSynced = pPage->pDirtyPrev;\n    }\n  \n    if( pPage->pDirtyNext ){\n      pPage->pDirtyNext->pDirtyPrev = pPage->pDirtyPrev;\n    }else{\n      assert( pPage==p->pDirtyTail );\n      p->pDirtyTail = pPage->pDirtyPrev;\n    }\n    if( pPage->pDirtyPrev ){\n      pPage->pDirtyPrev->pDirtyNext = pPage->pDirtyNext;\n    }else{\n      /* If there are now no dirty pages in the cache, set eCreate to 2. \n      ** This is an optimization that allows sqlite3PcacheFetch() to skip\n      ** searching for a dirty page to eject from the cache when it might\n      ** otherwise have to.  */\n      assert( pPage==p->pDirty );\n      p->pDirty = pPage->pDirtyNext;\n      assert( p->bPurgeable || p->eCreate==2 );\n      if( p->pDirty==0 ){         /*OPTIMIZATION-IF-TRUE*/\n        assert( p->bPurgeable==0 || p->eCreate==1 );\n        p->eCreate = 2;\n      }\n    }\n  }\n  if( addRemove & PCACHE_DIRTYLIST_ADD ){\n    pPage->pDirtyPrev = 0;\n    pPage->pDirtyNext = p->pDirty;\n    if( pPage->pDirtyNext ){\n      assert( pPage->pDirtyNext->pDirtyPrev==0 );\n      pPage->pDirtyNext->pDirtyPrev = pPage;\n    }else{\n      p->pDirtyTail = pPage;\n      if( p->bPurgeable ){\n        assert( p->eCreate==2 );\n        p->eCreate = 1;\n      }\n    }\n    p->pDirty = pPage;\n\n    /* If pSynced is NULL and this page has a clear NEED_SYNC flag, set\n    ** pSynced to point to it. Checking the NEED_SYNC flag is an \n    ** optimization, as if pSynced points to a page with the NEED_SYNC\n    ** flag set sqlite3PcacheFetchStress() searches through all newer \n    ** entries of the dirty-list for a page with NEED_SYNC clear anyway.  */\n    if( !p->pSynced \n     && 0==(pPage->flags&PGHDR_NEED_SYNC)   /*OPTIMIZATION-IF-FALSE*/\n    ){\n      p->pSynced = pPage;\n    }\n  }\n  pcacheDump(p);\n}\n\n/*\n** Wrapper around the pluggable caches xUnpin method. If the cache is\n** being used for an in-memory database, this function is a no-op.\n*/\nstatic void pcacheUnpin(PgHdr *p){\n  if( p->pCache->bPurgeable ){\n    pcacheTrace((\"%p.UNPIN %d\\n\", p->pCache, p->pgno));\n    sqlite3GlobalConfig.pcache2.xUnpin(p->pCache->pCache, p->pPage, 0);\n    pcacheDump(p->pCache);\n  }\n}\n\n/*\n** Compute the number of pages of cache requested.   p->szCache is the\n** cache size requested by the \"PRAGMA cache_size\" statement.\n*/\nstatic int numberOfCachePages(PCache *p){\n  if( p->szCache>=0 ){\n    /* IMPLEMENTATION-OF: R-42059-47211 If the argument N is positive then the\n    ** suggested cache size is set to N. */\n    return p->szCache;\n  }else{\n    /* IMPLEMENTATION-OF: R-61436-13639 If the argument N is negative, then\n    ** the number of cache pages is adjusted to use approximately abs(N*1024)\n    ** bytes of memory. */\n    return (int)((-1024*(i64)p->szCache)/(p->szPage+p->szExtra));\n  }\n}\n\n/*************************************************** General Interfaces ******\n**\n** Initialize and shutdown the page cache subsystem. Neither of these \n** functions are threadsafe.\n*/\nSQLITE_PRIVATE int sqlite3PcacheInitialize(void){\n  if( sqlite3GlobalConfig.pcache2.xInit==0 ){\n    /* IMPLEMENTATION-OF: R-26801-64137 If the xInit() method is NULL, then the\n    ** built-in default page cache is used instead of the application defined\n    ** page cache. */\n    sqlite3PCacheSetDefault();\n  }\n  return sqlite3GlobalConfig.pcache2.xInit(sqlite3GlobalConfig.pcache2.pArg);\n}\nSQLITE_PRIVATE void sqlite3PcacheShutdown(void){\n  if( sqlite3GlobalConfig.pcache2.xShutdown ){\n    /* IMPLEMENTATION-OF: R-26000-56589 The xShutdown() method may be NULL. */\n    sqlite3GlobalConfig.pcache2.xShutdown(sqlite3GlobalConfig.pcache2.pArg);\n  }\n}\n\n/*\n** Return the size in bytes of a PCache object.\n*/\nSQLITE_PRIVATE int sqlite3PcacheSize(void){ return sizeof(PCache); }\n\n/*\n** Create a new PCache object. Storage space to hold the object\n** has already been allocated and is passed in as the p pointer. \n** The caller discovers how much space needs to be allocated by \n** calling sqlite3PcacheSize().\n**\n** szExtra is some extra space allocated for each page.  The first\n** 8 bytes of the extra space will be zeroed as the page is allocated,\n** but remaining content will be uninitialized.  Though it is opaque\n** to this module, the extra space really ends up being the MemPage\n** structure in the pager.\n*/\nSQLITE_PRIVATE int sqlite3PcacheOpen(\n  int szPage,                  /* Size of every page */\n  int szExtra,                 /* Extra space associated with each page */\n  int bPurgeable,              /* True if pages are on backing store */\n  int (*xStress)(void*,PgHdr*),/* Call to try to make pages clean */\n  void *pStress,               /* Argument to xStress */\n  PCache *p                    /* Preallocated space for the PCache */\n){\n  memset(p, 0, sizeof(PCache));\n  p->szPage = 1;\n  p->szExtra = szExtra;\n  assert( szExtra>=8 );  /* First 8 bytes will be zeroed */\n  p->bPurgeable = bPurgeable;\n  p->eCreate = 2;\n  p->xStress = xStress;\n  p->pStress = pStress;\n  p->szCache = 100;\n  p->szSpill = 1;\n  pcacheTrace((\"%p.OPEN szPage %d bPurgeable %d\\n\",p,szPage,bPurgeable));\n  return sqlite3PcacheSetPageSize(p, szPage);\n}\n\n/*\n** Change the page size for PCache object. The caller must ensure that there\n** are no outstanding page references when this function is called.\n*/\nSQLITE_PRIVATE int sqlite3PcacheSetPageSize(PCache *pCache, int szPage){\n  assert( pCache->nRefSum==0 && pCache->pDirty==0 );\n  if( pCache->szPage ){\n    sqlite3_pcache *pNew;\n    pNew = sqlite3GlobalConfig.pcache2.xCreate(\n                szPage, pCache->szExtra + ROUND8(sizeof(PgHdr)),\n                pCache->bPurgeable\n    );\n    if( pNew==0 ) return SQLITE_NOMEM_BKPT;\n    sqlite3GlobalConfig.pcache2.xCachesize(pNew, numberOfCachePages(pCache));\n    if( pCache->pCache ){\n      sqlite3GlobalConfig.pcache2.xDestroy(pCache->pCache);\n    }\n    pCache->pCache = pNew;\n    pCache->szPage = szPage;\n    pcacheTrace((\"%p.PAGESIZE %d\\n\",pCache,szPage));\n  }\n  return SQLITE_OK;\n}\n\n/*\n** Try to obtain a page from the cache.\n**\n** This routine returns a pointer to an sqlite3_pcache_page object if\n** such an object is already in cache, or if a new one is created.\n** This routine returns a NULL pointer if the object was not in cache\n** and could not be created.\n**\n** The createFlags should be 0 to check for existing pages and should\n** be 3 (not 1, but 3) to try to create a new page.\n**\n** If the createFlag is 0, then NULL is always returned if the page\n** is not already in the cache.  If createFlag is 1, then a new page\n** is created only if that can be done without spilling dirty pages\n** and without exceeding the cache size limit.\n**\n** The caller needs to invoke sqlite3PcacheFetchFinish() to properly\n** initialize the sqlite3_pcache_page object and convert it into a\n** PgHdr object.  The sqlite3PcacheFetch() and sqlite3PcacheFetchFinish()\n** routines are split this way for performance reasons. When separated\n** they can both (usually) operate without having to push values to\n** the stack on entry and pop them back off on exit, which saves a\n** lot of pushing and popping.\n*/\nSQLITE_PRIVATE sqlite3_pcache_page *sqlite3PcacheFetch(\n  PCache *pCache,       /* Obtain the page from this cache */\n  Pgno pgno,            /* Page number to obtain */\n  int createFlag        /* If true, create page if it does not exist already */\n){\n  int eCreate;\n  sqlite3_pcache_page *pRes;\n\n  assert( pCache!=0 );\n  assert( pCache->pCache!=0 );\n  assert( createFlag==3 || createFlag==0 );\n  assert( pCache->eCreate==((pCache->bPurgeable && pCache->pDirty) ? 1 : 2) );\n\n  /* eCreate defines what to do if the page does not exist.\n  **    0     Do not allocate a new page.  (createFlag==0)\n  **    1     Allocate a new page if doing so is inexpensive.\n  **          (createFlag==1 AND bPurgeable AND pDirty)\n  **    2     Allocate a new page even it doing so is difficult.\n  **          (createFlag==1 AND !(bPurgeable AND pDirty)\n  */\n  eCreate = createFlag & pCache->eCreate;\n  assert( eCreate==0 || eCreate==1 || eCreate==2 );\n  assert( createFlag==0 || pCache->eCreate==eCreate );\n  assert( createFlag==0 || eCreate==1+(!pCache->bPurgeable||!pCache->pDirty) );\n  pRes = sqlite3GlobalConfig.pcache2.xFetch(pCache->pCache, pgno, eCreate);\n  pcacheTrace((\"%p.FETCH %d%s (result: %p)\\n\",pCache,pgno,\n               createFlag?\" create\":\"\",pRes));\n  return pRes;\n}\n\n/*\n** If the sqlite3PcacheFetch() routine is unable to allocate a new\n** page because no clean pages are available for reuse and the cache\n** size limit has been reached, then this routine can be invoked to \n** try harder to allocate a page.  This routine might invoke the stress\n** callback to spill dirty pages to the journal.  It will then try to\n** allocate the new page and will only fail to allocate a new page on\n** an OOM error.\n**\n** This routine should be invoked only after sqlite3PcacheFetch() fails.\n*/\nSQLITE_PRIVATE int sqlite3PcacheFetchStress(\n  PCache *pCache,                 /* Obtain the page from this cache */\n  Pgno pgno,                      /* Page number to obtain */\n  sqlite3_pcache_page **ppPage    /* Write result here */\n){\n  PgHdr *pPg;\n  if( pCache->eCreate==2 ) return 0;\n\n  if( sqlite3PcachePagecount(pCache)>pCache->szSpill ){\n    /* Find a dirty page to write-out and recycle. First try to find a \n    ** page that does not require a journal-sync (one with PGHDR_NEED_SYNC\n    ** cleared), but if that is not possible settle for any other \n    ** unreferenced dirty page.\n    **\n    ** If the LRU page in the dirty list that has a clear PGHDR_NEED_SYNC\n    ** flag is currently referenced, then the following may leave pSynced\n    ** set incorrectly (pointing to other than the LRU page with NEED_SYNC\n    ** cleared). This is Ok, as pSynced is just an optimization.  */\n    for(pPg=pCache->pSynced; \n        pPg && (pPg->nRef || (pPg->flags&PGHDR_NEED_SYNC)); \n        pPg=pPg->pDirtyPrev\n    );\n    pCache->pSynced = pPg;\n    if( !pPg ){\n      for(pPg=pCache->pDirtyTail; pPg && pPg->nRef; pPg=pPg->pDirtyPrev);\n    }\n    if( pPg ){\n      int rc;\n#ifdef SQLITE_LOG_CACHE_SPILL\n      sqlite3_log(SQLITE_FULL, \n                  \"spill page %d making room for %d - cache used: %d/%d\",\n                  pPg->pgno, pgno,\n                  sqlite3GlobalConfig.pcache2.xPagecount(pCache->pCache),\n                numberOfCachePages(pCache));\n#endif\n      pcacheTrace((\"%p.SPILL %d\\n\",pCache,pPg->pgno));\n      rc = pCache->xStress(pCache->pStress, pPg);\n      pcacheDump(pCache);\n      if( rc!=SQLITE_OK && rc!=SQLITE_BUSY ){\n        return rc;\n      }\n    }\n  }\n  *ppPage = sqlite3GlobalConfig.pcache2.xFetch(pCache->pCache, pgno, 2);\n  return *ppPage==0 ? SQLITE_NOMEM_BKPT : SQLITE_OK;\n}\n\n/*\n** This is a helper routine for sqlite3PcacheFetchFinish()\n**\n** In the uncommon case where the page being fetched has not been\n** initialized, this routine is invoked to do the initialization.\n** This routine is broken out into a separate function since it\n** requires extra stack manipulation that can be avoided in the common\n** case.\n*/\nstatic SQLITE_NOINLINE PgHdr *pcacheFetchFinishWithInit(\n  PCache *pCache,             /* Obtain the page from this cache */\n  Pgno pgno,                  /* Page number obtained */\n  sqlite3_pcache_page *pPage  /* Page obtained by prior PcacheFetch() call */\n){\n  PgHdr *pPgHdr;\n  assert( pPage!=0 );\n  pPgHdr = (PgHdr*)pPage->pExtra;\n  assert( pPgHdr->pPage==0 );\n  memset(&pPgHdr->pDirty, 0, sizeof(PgHdr) - offsetof(PgHdr,pDirty));\n  pPgHdr->pPage = pPage;\n  pPgHdr->pData = pPage->pBuf;\n  pPgHdr->pExtra = (void *)&pPgHdr[1];\n  memset(pPgHdr->pExtra, 0, 8);\n  pPgHdr->pCache = pCache;\n  pPgHdr->pgno = pgno;\n  pPgHdr->flags = PGHDR_CLEAN;\n  return sqlite3PcacheFetchFinish(pCache,pgno,pPage);\n}\n\n/*\n** This routine converts the sqlite3_pcache_page object returned by\n** sqlite3PcacheFetch() into an initialized PgHdr object.  This routine\n** must be called after sqlite3PcacheFetch() in order to get a usable\n** result.\n*/\nSQLITE_PRIVATE PgHdr *sqlite3PcacheFetchFinish(\n  PCache *pCache,             /* Obtain the page from this cache */\n  Pgno pgno,                  /* Page number obtained */\n  sqlite3_pcache_page *pPage  /* Page obtained by prior PcacheFetch() call */\n){\n  PgHdr *pPgHdr;\n\n  assert( pPage!=0 );\n  pPgHdr = (PgHdr *)pPage->pExtra;\n\n  if( !pPgHdr->pPage ){\n    return pcacheFetchFinishWithInit(pCache, pgno, pPage);\n  }\n  pCache->nRefSum++;\n  pPgHdr->nRef++;\n  assert( sqlite3PcachePageSanity(pPgHdr) );\n  return pPgHdr;\n}\n\n/*\n** Decrement the reference count on a page. If the page is clean and the\n** reference count drops to 0, then it is made eligible for recycling.\n*/\nSQLITE_PRIVATE void SQLITE_NOINLINE sqlite3PcacheRelease(PgHdr *p){\n  assert( p->nRef>0 );\n  p->pCache->nRefSum--;\n  if( (--p->nRef)==0 ){\n    if( p->flags&PGHDR_CLEAN ){\n      pcacheUnpin(p);\n    }else{\n      pcacheManageDirtyList(p, PCACHE_DIRTYLIST_FRONT);\n    }\n  }\n}\n\n/*\n** Increase the reference count of a supplied page by 1.\n*/\nSQLITE_PRIVATE void sqlite3PcacheRef(PgHdr *p){\n  assert(p->nRef>0);\n  assert( sqlite3PcachePageSanity(p) );\n  p->nRef++;\n  p->pCache->nRefSum++;\n}\n\n/*\n** Drop a page from the cache. There must be exactly one reference to the\n** page. This function deletes that reference, so after it returns the\n** page pointed to by p is invalid.\n*/\nSQLITE_PRIVATE void sqlite3PcacheDrop(PgHdr *p){\n  assert( p->nRef==1 );\n  assert( sqlite3PcachePageSanity(p) );\n  if( p->flags&PGHDR_DIRTY ){\n    pcacheManageDirtyList(p, PCACHE_DIRTYLIST_REMOVE);\n  }\n  p->pCache->nRefSum--;\n  sqlite3GlobalConfig.pcache2.xUnpin(p->pCache->pCache, p->pPage, 1);\n}\n\n/*\n** Make sure the page is marked as dirty. If it isn't dirty already,\n** make it so.\n*/\nSQLITE_PRIVATE void sqlite3PcacheMakeDirty(PgHdr *p){\n  assert( p->nRef>0 );\n  assert( sqlite3PcachePageSanity(p) );\n  if( p->flags & (PGHDR_CLEAN|PGHDR_DONT_WRITE) ){    /*OPTIMIZATION-IF-FALSE*/\n    p->flags &= ~PGHDR_DONT_WRITE;\n    if( p->flags & PGHDR_CLEAN ){\n      p->flags ^= (PGHDR_DIRTY|PGHDR_CLEAN);\n      pcacheTrace((\"%p.DIRTY %d\\n\",p->pCache,p->pgno));\n      assert( (p->flags & (PGHDR_DIRTY|PGHDR_CLEAN))==PGHDR_DIRTY );\n      pcacheManageDirtyList(p, PCACHE_DIRTYLIST_ADD);\n    }\n    assert( sqlite3PcachePageSanity(p) );\n  }\n}\n\n/*\n** Make sure the page is marked as clean. If it isn't clean already,\n** make it so.\n*/\nSQLITE_PRIVATE void sqlite3PcacheMakeClean(PgHdr *p){\n  assert( sqlite3PcachePageSanity(p) );\n  assert( (p->flags & PGHDR_DIRTY)!=0 );\n  assert( (p->flags & PGHDR_CLEAN)==0 );\n  pcacheManageDirtyList(p, PCACHE_DIRTYLIST_REMOVE);\n  p->flags &= ~(PGHDR_DIRTY|PGHDR_NEED_SYNC|PGHDR_WRITEABLE);\n  p->flags |= PGHDR_CLEAN;\n  pcacheTrace((\"%p.CLEAN %d\\n\",p->pCache,p->pgno));\n  assert( sqlite3PcachePageSanity(p) );\n  if( p->nRef==0 ){\n    pcacheUnpin(p);\n  }\n}\n\n/*\n** Make every page in the cache clean.\n*/\nSQLITE_PRIVATE void sqlite3PcacheCleanAll(PCache *pCache){\n  PgHdr *p;\n  pcacheTrace((\"%p.CLEAN-ALL\\n\",pCache));\n  while( (p = pCache->pDirty)!=0 ){\n    sqlite3PcacheMakeClean(p);\n  }\n}\n\n/*\n** Clear the PGHDR_NEED_SYNC and PGHDR_WRITEABLE flag from all dirty pages.\n*/\nSQLITE_PRIVATE void sqlite3PcacheClearWritable(PCache *pCache){\n  PgHdr *p;\n  pcacheTrace((\"%p.CLEAR-WRITEABLE\\n\",pCache));\n  for(p=pCache->pDirty; p; p=p->pDirtyNext){\n    p->flags &= ~(PGHDR_NEED_SYNC|PGHDR_WRITEABLE);\n  }\n  pCache->pSynced = pCache->pDirtyTail;\n}\n\n/*\n** Clear the PGHDR_NEED_SYNC flag from all dirty pages.\n*/\nSQLITE_PRIVATE void sqlite3PcacheClearSyncFlags(PCache *pCache){\n  PgHdr *p;\n  for(p=pCache->pDirty; p; p=p->pDirtyNext){\n    p->flags &= ~PGHDR_NEED_SYNC;\n  }\n  pCache->pSynced = pCache->pDirtyTail;\n}\n\n/*\n** Change the page number of page p to newPgno. \n*/\nSQLITE_PRIVATE void sqlite3PcacheMove(PgHdr *p, Pgno newPgno){\n  PCache *pCache = p->pCache;\n  assert( p->nRef>0 );\n  assert( newPgno>0 );\n  assert( sqlite3PcachePageSanity(p) );\n  pcacheTrace((\"%p.MOVE %d -> %d\\n\",pCache,p->pgno,newPgno));\n  sqlite3GlobalConfig.pcache2.xRekey(pCache->pCache, p->pPage, p->pgno,newPgno);\n  p->pgno = newPgno;\n  if( (p->flags&PGHDR_DIRTY) && (p->flags&PGHDR_NEED_SYNC) ){\n    pcacheManageDirtyList(p, PCACHE_DIRTYLIST_FRONT);\n  }\n}\n\n/*\n** Drop every cache entry whose page number is greater than \"pgno\". The\n** caller must ensure that there are no outstanding references to any pages\n** other than page 1 with a page number greater than pgno.\n**\n** If there is a reference to page 1 and the pgno parameter passed to this\n** function is 0, then the data area associated with page 1 is zeroed, but\n** the page object is not dropped.\n*/\nSQLITE_PRIVATE void sqlite3PcacheTruncate(PCache *pCache, Pgno pgno){\n  if( pCache->pCache ){\n    PgHdr *p;\n    PgHdr *pNext;\n    pcacheTrace((\"%p.TRUNCATE %d\\n\",pCache,pgno));\n    for(p=pCache->pDirty; p; p=pNext){\n      pNext = p->pDirtyNext;\n      /* This routine never gets call with a positive pgno except right\n      ** after sqlite3PcacheCleanAll().  So if there are dirty pages,\n      ** it must be that pgno==0.\n      */\n      assert( p->pgno>0 );\n      if( p->pgno>pgno ){\n        assert( p->flags&PGHDR_DIRTY );\n        sqlite3PcacheMakeClean(p);\n      }\n    }\n    if( pgno==0 && pCache->nRefSum ){\n      sqlite3_pcache_page *pPage1;\n      pPage1 = sqlite3GlobalConfig.pcache2.xFetch(pCache->pCache,1,0);\n      if( ALWAYS(pPage1) ){  /* Page 1 is always available in cache, because\n                             ** pCache->nRefSum>0 */\n        memset(pPage1->pBuf, 0, pCache->szPage);\n        pgno = 1;\n      }\n    }\n    sqlite3GlobalConfig.pcache2.xTruncate(pCache->pCache, pgno+1);\n  }\n}\n\n/*\n** Close a cache.\n*/\nSQLITE_PRIVATE void sqlite3PcacheClose(PCache *pCache){\n  assert( pCache->pCache!=0 );\n  pcacheTrace((\"%p.CLOSE\\n\",pCache));\n  sqlite3GlobalConfig.pcache2.xDestroy(pCache->pCache);\n}\n\n/* \n** Discard the contents of the cache.\n*/\nSQLITE_PRIVATE void sqlite3PcacheClear(PCache *pCache){\n  sqlite3PcacheTruncate(pCache, 0);\n}\n\n/*\n** Merge two lists of pages connected by pDirty and in pgno order.\n** Do not bother fixing the pDirtyPrev pointers.\n*/\nstatic PgHdr *pcacheMergeDirtyList(PgHdr *pA, PgHdr *pB){\n  PgHdr result, *pTail;\n  pTail = &result;\n  assert( pA!=0 && pB!=0 );\n  for(;;){\n    if( pA->pgno<pB->pgno ){\n      pTail->pDirty = pA;\n      pTail = pA;\n      pA = pA->pDirty;\n      if( pA==0 ){\n        pTail->pDirty = pB;\n        break;\n      }\n    }else{\n      pTail->pDirty = pB;\n      pTail = pB;\n      pB = pB->pDirty;\n      if( pB==0 ){\n        pTail->pDirty = pA;\n        break;\n      }\n    }\n  }\n  return result.pDirty;\n}\n\n/*\n** Sort the list of pages in accending order by pgno.  Pages are\n** connected by pDirty pointers.  The pDirtyPrev pointers are\n** corrupted by this sort.\n**\n** Since there cannot be more than 2^31 distinct pages in a database,\n** there cannot be more than 31 buckets required by the merge sorter.\n** One extra bucket is added to catch overflow in case something\n** ever changes to make the previous sentence incorrect.\n*/\n#define N_SORT_BUCKET  32\nstatic PgHdr *pcacheSortDirtyList(PgHdr *pIn){\n  PgHdr *a[N_SORT_BUCKET], *p;\n  int i;\n  memset(a, 0, sizeof(a));\n  while( pIn ){\n    p = pIn;\n    pIn = p->pDirty;\n    p->pDirty = 0;\n    for(i=0; ALWAYS(i<N_SORT_BUCKET-1); i++){\n      if( a[i]==0 ){\n        a[i] = p;\n        break;\n      }else{\n        p = pcacheMergeDirtyList(a[i], p);\n        a[i] = 0;\n      }\n    }\n    if( NEVER(i==N_SORT_BUCKET-1) ){\n      /* To get here, there need to be 2^(N_SORT_BUCKET) elements in\n      ** the input list.  But that is impossible.\n      */\n      a[i] = pcacheMergeDirtyList(a[i], p);\n    }\n  }\n  p = a[0];\n  for(i=1; i<N_SORT_BUCKET; i++){\n    if( a[i]==0 ) continue;\n    p = p ? pcacheMergeDirtyList(p, a[i]) : a[i];\n  }\n  return p;\n}\n\n/*\n** Return a list of all dirty pages in the cache, sorted by page number.\n*/\nSQLITE_PRIVATE PgHdr *sqlite3PcacheDirtyList(PCache *pCache){\n  PgHdr *p;\n  for(p=pCache->pDirty; p; p=p->pDirtyNext){\n    p->pDirty = p->pDirtyNext;\n  }\n  return pcacheSortDirtyList(pCache->pDirty);\n}\n\n/* \n** Return the total number of references to all pages held by the cache.\n**\n** This is not the total number of pages referenced, but the sum of the\n** reference count for all pages.\n*/\nSQLITE_PRIVATE int sqlite3PcacheRefCount(PCache *pCache){\n  return pCache->nRefSum;\n}\n\n/*\n** Return the number of references to the page supplied as an argument.\n*/\nSQLITE_PRIVATE int sqlite3PcachePageRefcount(PgHdr *p){\n  return p->nRef;\n}\n\n/* \n** Return the total number of pages in the cache.\n*/\nSQLITE_PRIVATE int sqlite3PcachePagecount(PCache *pCache){\n  assert( pCache->pCache!=0 );\n  return sqlite3GlobalConfig.pcache2.xPagecount(pCache->pCache);\n}\n\n#ifdef SQLITE_TEST\n/*\n** Get the suggested cache-size value.\n*/\nSQLITE_PRIVATE int sqlite3PcacheGetCachesize(PCache *pCache){\n  return numberOfCachePages(pCache);\n}\n#endif\n\n/*\n** Set the suggested cache-size value.\n*/\nSQLITE_PRIVATE void sqlite3PcacheSetCachesize(PCache *pCache, int mxPage){\n  assert( pCache->pCache!=0 );\n  pCache->szCache = mxPage;\n  sqlite3GlobalConfig.pcache2.xCachesize(pCache->pCache,\n                                         numberOfCachePages(pCache));\n}\n\n/*\n** Set the suggested cache-spill value.  Make no changes if if the\n** argument is zero.  Return the effective cache-spill size, which will\n** be the larger of the szSpill and szCache.\n*/\nSQLITE_PRIVATE int sqlite3PcacheSetSpillsize(PCache *p, int mxPage){\n  int res;\n  assert( p->pCache!=0 );\n  if( mxPage ){\n    if( mxPage<0 ){\n      mxPage = (int)((-1024*(i64)mxPage)/(p->szPage+p->szExtra));\n    }\n    p->szSpill = mxPage;\n  }\n  res = numberOfCachePages(p);\n  if( res<p->szSpill ) res = p->szSpill; \n  return res;\n}\n\n/*\n** Free up as much memory as possible from the page cache.\n*/\nSQLITE_PRIVATE void sqlite3PcacheShrink(PCache *pCache){\n  assert( pCache->pCache!=0 );\n  sqlite3GlobalConfig.pcache2.xShrink(pCache->pCache);\n}\n\n/*\n** Return the size of the header added by this middleware layer\n** in the page-cache hierarchy.\n*/\nSQLITE_PRIVATE int sqlite3HeaderSizePcache(void){ return ROUND8(sizeof(PgHdr)); }\n\n/*\n** Return the number of dirty pages currently in the cache, as a percentage\n** of the configured cache size.\n*/\nSQLITE_PRIVATE int sqlite3PCachePercentDirty(PCache *pCache){\n  PgHdr *pDirty;\n  int nDirty = 0;\n  int nCache = numberOfCachePages(pCache);\n  for(pDirty=pCache->pDirty; pDirty; pDirty=pDirty->pDirtyNext) nDirty++;\n  return nCache ? (int)(((i64)nDirty * 100) / nCache) : 0;\n}\n\n#ifdef SQLITE_DIRECT_OVERFLOW_READ\n/* \n** Return true if there are one or more dirty pages in the cache. Else false.\n*/\nSQLITE_PRIVATE int sqlite3PCacheIsDirty(PCache *pCache){\n  return (pCache->pDirty!=0);\n}\n#endif\n\n#if defined(SQLITE_CHECK_PAGES) || defined(SQLITE_DEBUG)\n/*\n** For all dirty pages currently in the cache, invoke the specified\n** callback. This is only used if the SQLITE_CHECK_PAGES macro is\n** defined.\n*/\nSQLITE_PRIVATE void sqlite3PcacheIterateDirty(PCache *pCache, void (*xIter)(PgHdr *)){\n  PgHdr *pDirty;\n  for(pDirty=pCache->pDirty; pDirty; pDirty=pDirty->pDirtyNext){\n    xIter(pDirty);\n  }\n}\n#endif\n\n/************** End of pcache.c **********************************************/\n/************** Begin file pcache1.c *****************************************/\n/*\n** 2008 November 05\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n**\n** This file implements the default page cache implementation (the\n** sqlite3_pcache interface). It also contains part of the implementation\n** of the SQLITE_CONFIG_PAGECACHE and sqlite3_release_memory() features.\n** If the default page cache implementation is overridden, then neither of\n** these two features are available.\n**\n** A Page cache line looks like this:\n**\n**  -------------------------------------------------------------\n**  |  database page content   |  PgHdr1  |  MemPage  |  PgHdr  |\n**  -------------------------------------------------------------\n**\n** The database page content is up front (so that buffer overreads tend to\n** flow harmlessly into the PgHdr1, MemPage, and PgHdr extensions).   MemPage\n** is the extension added by the btree.c module containing information such\n** as the database page number and how that database page is used.  PgHdr\n** is added by the pcache.c layer and contains information used to keep track\n** of which pages are \"dirty\".  PgHdr1 is an extension added by this\n** module (pcache1.c).  The PgHdr1 header is a subclass of sqlite3_pcache_page.\n** PgHdr1 contains information needed to look up a page by its page number.\n** The superclass sqlite3_pcache_page.pBuf points to the start of the\n** database page content and sqlite3_pcache_page.pExtra points to PgHdr.\n**\n** The size of the extension (MemPage+PgHdr+PgHdr1) can be determined at\n** runtime using sqlite3_config(SQLITE_CONFIG_PCACHE_HDRSZ, &size).  The\n** sizes of the extensions sum to 272 bytes on x64 for 3.8.10, but this\n** size can vary according to architecture, compile-time options, and\n** SQLite library version number.\n**\n** If SQLITE_PCACHE_SEPARATE_HEADER is defined, then the extension is obtained\n** using a separate memory allocation from the database page content.  This\n** seeks to overcome the \"clownshoe\" problem (also called \"internal\n** fragmentation\" in academic literature) of allocating a few bytes more\n** than a power of two with the memory allocator rounding up to the next\n** power of two, and leaving the rounded-up space unused.\n**\n** This module tracks pointers to PgHdr1 objects.  Only pcache.c communicates\n** with this module.  Information is passed back and forth as PgHdr1 pointers.\n**\n** The pcache.c and pager.c modules deal pointers to PgHdr objects.\n** The btree.c module deals with pointers to MemPage objects.\n**\n** SOURCE OF PAGE CACHE MEMORY:\n**\n** Memory for a page might come from any of three sources:\n**\n**    (1)  The general-purpose memory allocator - sqlite3Malloc()\n**    (2)  Global page-cache memory provided using sqlite3_config() with\n**         SQLITE_CONFIG_PAGECACHE.\n**    (3)  PCache-local bulk allocation.\n**\n** The third case is a chunk of heap memory (defaulting to 100 pages worth)\n** that is allocated when the page cache is created.  The size of the local\n** bulk allocation can be adjusted using \n**\n**     sqlite3_config(SQLITE_CONFIG_PAGECACHE, (void*)0, 0, N).\n**\n** If N is positive, then N pages worth of memory are allocated using a single\n** sqlite3Malloc() call and that memory is used for the first N pages allocated.\n** Or if N is negative, then -1024*N bytes of memory are allocated and used\n** for as many pages as can be accomodated.\n**\n** Only one of (2) or (3) can be used.  Once the memory available to (2) or\n** (3) is exhausted, subsequent allocations fail over to the general-purpose\n** memory allocator (1).\n**\n** Earlier versions of SQLite used only methods (1) and (2).  But experiments\n** show that method (3) with N==100 provides about a 5% performance boost for\n** common workloads.\n*/\n/* #include \"sqliteInt.h\" */\n\ntypedef struct PCache1 PCache1;\ntypedef struct PgHdr1 PgHdr1;\ntypedef struct PgFreeslot PgFreeslot;\ntypedef struct PGroup PGroup;\n\n/*\n** Each cache entry is represented by an instance of the following \n** structure. Unless SQLITE_PCACHE_SEPARATE_HEADER is defined, a buffer of\n** PgHdr1.pCache->szPage bytes is allocated directly before this structure \n** in memory.\n**\n** Note: Variables isBulkLocal and isAnchor were once type \"u8\". That works,\n** but causes a 2-byte gap in the structure for most architectures (since \n** pointers must be either 4 or 8-byte aligned). As this structure is located\n** in memory directly after the associated page data, if the database is\n** corrupt, code at the b-tree layer may overread the page buffer and \n** read part of this structure before the corruption is detected. This\n** can cause a valgrind error if the unitialized gap is accessed. Using u16\n** ensures there is no such gap, and therefore no bytes of unitialized memory\n** in the structure.\n*/\nstruct PgHdr1 {\n  sqlite3_pcache_page page;      /* Base class. Must be first. pBuf & pExtra */\n  unsigned int iKey;             /* Key value (page number) */\n  u16 isBulkLocal;               /* This page from bulk local storage */\n  u16 isAnchor;                  /* This is the PGroup.lru element */\n  PgHdr1 *pNext;                 /* Next in hash table chain */\n  PCache1 *pCache;               /* Cache that currently owns this page */\n  PgHdr1 *pLruNext;              /* Next in LRU list of unpinned pages */\n  PgHdr1 *pLruPrev;              /* Previous in LRU list of unpinned pages */\n                                 /* NB: pLruPrev is only valid if pLruNext!=0 */\n};\n\n/*\n** A page is pinned if it is not on the LRU list.  To be \"pinned\" means\n** that the page is in active use and must not be deallocated.\n*/\n#define PAGE_IS_PINNED(p)    ((p)->pLruNext==0)\n#define PAGE_IS_UNPINNED(p)  ((p)->pLruNext!=0)\n\n/* Each page cache (or PCache) belongs to a PGroup.  A PGroup is a set \n** of one or more PCaches that are able to recycle each other's unpinned\n** pages when they are under memory pressure.  A PGroup is an instance of\n** the following object.\n**\n** This page cache implementation works in one of two modes:\n**\n**   (1)  Every PCache is the sole member of its own PGroup.  There is\n**        one PGroup per PCache.\n**\n**   (2)  There is a single global PGroup that all PCaches are a member\n**        of.\n**\n** Mode 1 uses more memory (since PCache instances are not able to rob\n** unused pages from other PCaches) but it also operates without a mutex,\n** and is therefore often faster.  Mode 2 requires a mutex in order to be\n** threadsafe, but recycles pages more efficiently.\n**\n** For mode (1), PGroup.mutex is NULL.  For mode (2) there is only a single\n** PGroup which is the pcache1.grp global variable and its mutex is\n** SQLITE_MUTEX_STATIC_LRU.\n*/\nstruct PGroup {\n  sqlite3_mutex *mutex;          /* MUTEX_STATIC_LRU or NULL */\n  unsigned int nMaxPage;         /* Sum of nMax for purgeable caches */\n  unsigned int nMinPage;         /* Sum of nMin for purgeable caches */\n  unsigned int mxPinned;         /* nMaxpage + 10 - nMinPage */\n  unsigned int nPurgeable;       /* Number of purgeable pages allocated */\n  PgHdr1 lru;                    /* The beginning and end of the LRU list */\n};\n\n/* Each page cache is an instance of the following object.  Every\n** open database file (including each in-memory database and each\n** temporary or transient database) has a single page cache which\n** is an instance of this object.\n**\n** Pointers to structures of this type are cast and returned as \n** opaque sqlite3_pcache* handles.\n*/\nstruct PCache1 {\n  /* Cache configuration parameters. Page size (szPage) and the purgeable\n  ** flag (bPurgeable) and the pnPurgeable pointer are all set when the\n  ** cache is created and are never changed thereafter. nMax may be \n  ** modified at any time by a call to the pcache1Cachesize() method.\n  ** The PGroup mutex must be held when accessing nMax.\n  */\n  PGroup *pGroup;                     /* PGroup this cache belongs to */\n  unsigned int *pnPurgeable;          /* Pointer to pGroup->nPurgeable */\n  int szPage;                         /* Size of database content section */\n  int szExtra;                        /* sizeof(MemPage)+sizeof(PgHdr) */\n  int szAlloc;                        /* Total size of one pcache line */\n  int bPurgeable;                     /* True if cache is purgeable */\n  unsigned int nMin;                  /* Minimum number of pages reserved */\n  unsigned int nMax;                  /* Configured \"cache_size\" value */\n  unsigned int n90pct;                /* nMax*9/10 */\n  unsigned int iMaxKey;               /* Largest key seen since xTruncate() */\n  unsigned int nPurgeableDummy;       /* pnPurgeable points here when not used*/\n\n  /* Hash table of all pages. The following variables may only be accessed\n  ** when the accessor is holding the PGroup mutex.\n  */\n  unsigned int nRecyclable;           /* Number of pages in the LRU list */\n  unsigned int nPage;                 /* Total number of pages in apHash */\n  unsigned int nHash;                 /* Number of slots in apHash[] */\n  PgHdr1 **apHash;                    /* Hash table for fast lookup by key */\n  PgHdr1 *pFree;                      /* List of unused pcache-local pages */\n  void *pBulk;                        /* Bulk memory used by pcache-local */\n};\n\n/*\n** Free slots in the allocator used to divide up the global page cache\n** buffer provided using the SQLITE_CONFIG_PAGECACHE mechanism.\n*/\nstruct PgFreeslot {\n  PgFreeslot *pNext;  /* Next free slot */\n};\n\n/*\n** Global data used by this cache.\n*/\nstatic SQLITE_WSD struct PCacheGlobal {\n  PGroup grp;                    /* The global PGroup for mode (2) */\n\n  /* Variables related to SQLITE_CONFIG_PAGECACHE settings.  The\n  ** szSlot, nSlot, pStart, pEnd, nReserve, and isInit values are all\n  ** fixed at sqlite3_initialize() time and do not require mutex protection.\n  ** The nFreeSlot and pFree values do require mutex protection.\n  */\n  int isInit;                    /* True if initialized */\n  int separateCache;             /* Use a new PGroup for each PCache */\n  int nInitPage;                 /* Initial bulk allocation size */   \n  int szSlot;                    /* Size of each free slot */\n  int nSlot;                     /* The number of pcache slots */\n  int nReserve;                  /* Try to keep nFreeSlot above this */\n  void *pStart, *pEnd;           /* Bounds of global page cache memory */\n  /* Above requires no mutex.  Use mutex below for variable that follow. */\n  sqlite3_mutex *mutex;          /* Mutex for accessing the following: */\n  PgFreeslot *pFree;             /* Free page blocks */\n  int nFreeSlot;                 /* Number of unused pcache slots */\n  /* The following value requires a mutex to change.  We skip the mutex on\n  ** reading because (1) most platforms read a 32-bit integer atomically and\n  ** (2) even if an incorrect value is read, no great harm is done since this\n  ** is really just an optimization. */\n  int bUnderPressure;            /* True if low on PAGECACHE memory */\n} pcache1_g;\n\n/*\n** All code in this file should access the global structure above via the\n** alias \"pcache1\". This ensures that the WSD emulation is used when\n** compiling for systems that do not support real WSD.\n*/\n#define pcache1 (GLOBAL(struct PCacheGlobal, pcache1_g))\n\n/*\n** Macros to enter and leave the PCache LRU mutex.\n*/\n#if !defined(SQLITE_ENABLE_MEMORY_MANAGEMENT) || SQLITE_THREADSAFE==0\n# define pcache1EnterMutex(X)  assert((X)->mutex==0)\n# define pcache1LeaveMutex(X)  assert((X)->mutex==0)\n# define PCACHE1_MIGHT_USE_GROUP_MUTEX 0\n#else\n# define pcache1EnterMutex(X) sqlite3_mutex_enter((X)->mutex)\n# define pcache1LeaveMutex(X) sqlite3_mutex_leave((X)->mutex)\n# define PCACHE1_MIGHT_USE_GROUP_MUTEX 1\n#endif\n\n/******************************************************************************/\n/******** Page Allocation/SQLITE_CONFIG_PCACHE Related Functions **************/\n\n\n/*\n** This function is called during initialization if a static buffer is \n** supplied to use for the page-cache by passing the SQLITE_CONFIG_PAGECACHE\n** verb to sqlite3_config(). Parameter pBuf points to an allocation large\n** enough to contain 'n' buffers of 'sz' bytes each.\n**\n** This routine is called from sqlite3_initialize() and so it is guaranteed\n** to be serialized already.  There is no need for further mutexing.\n*/\nSQLITE_PRIVATE void sqlite3PCacheBufferSetup(void *pBuf, int sz, int n){\n  if( pcache1.isInit ){\n    PgFreeslot *p;\n    if( pBuf==0 ) sz = n = 0;\n    if( n==0 ) sz = 0;\n    sz = ROUNDDOWN8(sz);\n    pcache1.szSlot = sz;\n    pcache1.nSlot = pcache1.nFreeSlot = n;\n    pcache1.nReserve = n>90 ? 10 : (n/10 + 1);\n    pcache1.pStart = pBuf;\n    pcache1.pFree = 0;\n    pcache1.bUnderPressure = 0;\n    while( n-- ){\n      p = (PgFreeslot*)pBuf;\n      p->pNext = pcache1.pFree;\n      pcache1.pFree = p;\n      pBuf = (void*)&((char*)pBuf)[sz];\n    }\n    pcache1.pEnd = pBuf;\n  }\n}\n\n/*\n** Try to initialize the pCache->pFree and pCache->pBulk fields.  Return\n** true if pCache->pFree ends up containing one or more free pages.\n*/\nstatic int pcache1InitBulk(PCache1 *pCache){\n  i64 szBulk;\n  char *zBulk;\n  if( pcache1.nInitPage==0 ) return 0;\n  /* Do not bother with a bulk allocation if the cache size very small */\n  if( pCache->nMax<3 ) return 0;\n  sqlite3BeginBenignMalloc();\n  if( pcache1.nInitPage>0 ){\n    szBulk = pCache->szAlloc * (i64)pcache1.nInitPage;\n  }else{\n    szBulk = -1024 * (i64)pcache1.nInitPage;\n  }\n  if( szBulk > pCache->szAlloc*(i64)pCache->nMax ){\n    szBulk = pCache->szAlloc*(i64)pCache->nMax;\n  }\n  zBulk = pCache->pBulk = sqlite3Malloc( szBulk );\n  sqlite3EndBenignMalloc();\n  if( zBulk ){\n    int nBulk = sqlite3MallocSize(zBulk)/pCache->szAlloc;\n    do{\n      PgHdr1 *pX = (PgHdr1*)&zBulk[pCache->szPage];\n      pX->page.pBuf = zBulk;\n      pX->page.pExtra = &pX[1];\n      pX->isBulkLocal = 1;\n      pX->isAnchor = 0;\n      pX->pNext = pCache->pFree;\n      pX->pLruPrev = 0;           /* Initializing this saves a valgrind error */\n      pCache->pFree = pX;\n      zBulk += pCache->szAlloc;\n    }while( --nBulk );\n  }\n  return pCache->pFree!=0;\n}\n\n/*\n** Malloc function used within this file to allocate space from the buffer\n** configured using sqlite3_config(SQLITE_CONFIG_PAGECACHE) option. If no \n** such buffer exists or there is no space left in it, this function falls \n** back to sqlite3Malloc().\n**\n** Multiple threads can run this routine at the same time.  Global variables\n** in pcache1 need to be protected via mutex.\n*/\nstatic void *pcache1Alloc(int nByte){\n  void *p = 0;\n  assert( sqlite3_mutex_notheld(pcache1.grp.mutex) );\n  if( nByte<=pcache1.szSlot ){\n    sqlite3_mutex_enter(pcache1.mutex);\n    p = (PgHdr1 *)pcache1.pFree;\n    if( p ){\n      pcache1.pFree = pcache1.pFree->pNext;\n      pcache1.nFreeSlot--;\n      pcache1.bUnderPressure = pcache1.nFreeSlot<pcache1.nReserve;\n      assert( pcache1.nFreeSlot>=0 );\n      sqlite3StatusHighwater(SQLITE_STATUS_PAGECACHE_SIZE, nByte);\n      sqlite3StatusUp(SQLITE_STATUS_PAGECACHE_USED, 1);\n    }\n    sqlite3_mutex_leave(pcache1.mutex);\n  }\n  if( p==0 ){\n    /* Memory is not available in the SQLITE_CONFIG_PAGECACHE pool.  Get\n    ** it from sqlite3Malloc instead.\n    */\n    p = sqlite3Malloc(nByte);\n#ifndef SQLITE_DISABLE_PAGECACHE_OVERFLOW_STATS\n    if( p ){\n      int sz = sqlite3MallocSize(p);\n      sqlite3_mutex_enter(pcache1.mutex);\n      sqlite3StatusHighwater(SQLITE_STATUS_PAGECACHE_SIZE, nByte);\n      sqlite3StatusUp(SQLITE_STATUS_PAGECACHE_OVERFLOW, sz);\n      sqlite3_mutex_leave(pcache1.mutex);\n    }\n#endif\n    sqlite3MemdebugSetType(p, MEMTYPE_PCACHE);\n  }\n  return p;\n}\n\n/*\n** Free an allocated buffer obtained from pcache1Alloc().\n*/\nstatic void pcache1Free(void *p){\n  if( p==0 ) return;\n  if( SQLITE_WITHIN(p, pcache1.pStart, pcache1.pEnd) ){\n    PgFreeslot *pSlot;\n    sqlite3_mutex_enter(pcache1.mutex);\n    sqlite3StatusDown(SQLITE_STATUS_PAGECACHE_USED, 1);\n    pSlot = (PgFreeslot*)p;\n    pSlot->pNext = pcache1.pFree;\n    pcache1.pFree = pSlot;\n    pcache1.nFreeSlot++;\n    pcache1.bUnderPressure = pcache1.nFreeSlot<pcache1.nReserve;\n    assert( pcache1.nFreeSlot<=pcache1.nSlot );\n    sqlite3_mutex_leave(pcache1.mutex);\n  }else{\n    assert( sqlite3MemdebugHasType(p, MEMTYPE_PCACHE) );\n    sqlite3MemdebugSetType(p, MEMTYPE_HEAP);\n#ifndef SQLITE_DISABLE_PAGECACHE_OVERFLOW_STATS\n    {\n      int nFreed = 0;\n      nFreed = sqlite3MallocSize(p);\n      sqlite3_mutex_enter(pcache1.mutex);\n      sqlite3StatusDown(SQLITE_STATUS_PAGECACHE_OVERFLOW, nFreed);\n      sqlite3_mutex_leave(pcache1.mutex);\n    }\n#endif\n    sqlite3_free(p);\n  }\n}\n\n#ifdef SQLITE_ENABLE_MEMORY_MANAGEMENT\n/*\n** Return the size of a pcache allocation\n*/\nstatic int pcache1MemSize(void *p){\n  if( p>=pcache1.pStart && p<pcache1.pEnd ){\n    return pcache1.szSlot;\n  }else{\n    int iSize;\n    assert( sqlite3MemdebugHasType(p, MEMTYPE_PCACHE) );\n    sqlite3MemdebugSetType(p, MEMTYPE_HEAP);\n    iSize = sqlite3MallocSize(p);\n    sqlite3MemdebugSetType(p, MEMTYPE_PCACHE);\n    return iSize;\n  }\n}\n#endif /* SQLITE_ENABLE_MEMORY_MANAGEMENT */\n\n/*\n** Allocate a new page object initially associated with cache pCache.\n*/\nstatic PgHdr1 *pcache1AllocPage(PCache1 *pCache, int benignMalloc){\n  PgHdr1 *p = 0;\n  void *pPg;\n\n  assert( sqlite3_mutex_held(pCache->pGroup->mutex) );\n  if( pCache->pFree || (pCache->nPage==0 && pcache1InitBulk(pCache)) ){\n    p = pCache->pFree;\n    pCache->pFree = p->pNext;\n    p->pNext = 0;\n  }else{\n#ifdef SQLITE_ENABLE_MEMORY_MANAGEMENT\n    /* The group mutex must be released before pcache1Alloc() is called. This\n    ** is because it might call sqlite3_release_memory(), which assumes that \n    ** this mutex is not held. */\n    assert( pcache1.separateCache==0 );\n    assert( pCache->pGroup==&pcache1.grp );\n    pcache1LeaveMutex(pCache->pGroup);\n#endif\n    if( benignMalloc ){ sqlite3BeginBenignMalloc(); }\n#ifdef SQLITE_PCACHE_SEPARATE_HEADER\n    pPg = pcache1Alloc(pCache->szPage);\n    p = sqlite3Malloc(sizeof(PgHdr1) + pCache->szExtra);\n    if( !pPg || !p ){\n      pcache1Free(pPg);\n      sqlite3_free(p);\n      pPg = 0;\n    }\n#else\n    pPg = pcache1Alloc(pCache->szAlloc);\n    p = (PgHdr1 *)&((u8 *)pPg)[pCache->szPage];\n#endif\n    if( benignMalloc ){ sqlite3EndBenignMalloc(); }\n#ifdef SQLITE_ENABLE_MEMORY_MANAGEMENT\n    pcache1EnterMutex(pCache->pGroup);\n#endif\n    if( pPg==0 ) return 0;\n    p->page.pBuf = pPg;\n    p->page.pExtra = &p[1];\n    p->isBulkLocal = 0;\n    p->isAnchor = 0;\n  }\n  (*pCache->pnPurgeable)++;\n  return p;\n}\n\n/*\n** Free a page object allocated by pcache1AllocPage().\n*/\nstatic void pcache1FreePage(PgHdr1 *p){\n  PCache1 *pCache;\n  assert( p!=0 );\n  pCache = p->pCache;\n  assert( sqlite3_mutex_held(p->pCache->pGroup->mutex) );\n  if( p->isBulkLocal ){\n    p->pNext = pCache->pFree;\n    pCache->pFree = p;\n  }else{\n    pcache1Free(p->page.pBuf);\n#ifdef SQLITE_PCACHE_SEPARATE_HEADER\n    sqlite3_free(p);\n#endif\n  }\n  (*pCache->pnPurgeable)--;\n}\n\n/*\n** Malloc function used by SQLite to obtain space from the buffer configured\n** using sqlite3_config(SQLITE_CONFIG_PAGECACHE) option. If no such buffer\n** exists, this function falls back to sqlite3Malloc().\n*/\nSQLITE_PRIVATE void *sqlite3PageMalloc(int sz){\n  /* During rebalance operations on a corrupt database file, it is sometimes\n  ** (rarely) possible to overread the temporary page buffer by a few bytes.\n  ** Enlarge the allocation slightly so that this does not cause problems. */\n  return pcache1Alloc(sz);\n}\n\n/*\n** Free an allocated buffer obtained from sqlite3PageMalloc().\n*/\nSQLITE_PRIVATE void sqlite3PageFree(void *p){\n  pcache1Free(p);\n}\n\n\n/*\n** Return true if it desirable to avoid allocating a new page cache\n** entry.\n**\n** If memory was allocated specifically to the page cache using\n** SQLITE_CONFIG_PAGECACHE but that memory has all been used, then\n** it is desirable to avoid allocating a new page cache entry because\n** presumably SQLITE_CONFIG_PAGECACHE was suppose to be sufficient\n** for all page cache needs and we should not need to spill the\n** allocation onto the heap.\n**\n** Or, the heap is used for all page cache memory but the heap is\n** under memory pressure, then again it is desirable to avoid\n** allocating a new page cache entry in order to avoid stressing\n** the heap even further.\n*/\nstatic int pcache1UnderMemoryPressure(PCache1 *pCache){\n  if( pcache1.nSlot && (pCache->szPage+pCache->szExtra)<=pcache1.szSlot ){\n    return pcache1.bUnderPressure;\n  }else{\n    return sqlite3HeapNearlyFull();\n  }\n}\n\n/******************************************************************************/\n/******** General Implementation Functions ************************************/\n\n/*\n** This function is used to resize the hash table used by the cache passed\n** as the first argument.\n**\n** The PCache mutex must be held when this function is called.\n*/\nstatic void pcache1ResizeHash(PCache1 *p){\n  PgHdr1 **apNew;\n  unsigned int nNew;\n  unsigned int i;\n\n  assert( sqlite3_mutex_held(p->pGroup->mutex) );\n\n  nNew = p->nHash*2;\n  if( nNew<256 ){\n    nNew = 256;\n  }\n\n  pcache1LeaveMutex(p->pGroup);\n  if( p->nHash ){ sqlite3BeginBenignMalloc(); }\n  apNew = (PgHdr1 **)sqlite3MallocZero(sizeof(PgHdr1 *)*nNew);\n  if( p->nHash ){ sqlite3EndBenignMalloc(); }\n  pcache1EnterMutex(p->pGroup);\n  if( apNew ){\n    for(i=0; i<p->nHash; i++){\n      PgHdr1 *pPage;\n      PgHdr1 *pNext = p->apHash[i];\n      while( (pPage = pNext)!=0 ){\n        unsigned int h = pPage->iKey % nNew;\n        pNext = pPage->pNext;\n        pPage->pNext = apNew[h];\n        apNew[h] = pPage;\n      }\n    }\n    sqlite3_free(p->apHash);\n    p->apHash = apNew;\n    p->nHash = nNew;\n  }\n}\n\n/*\n** This function is used internally to remove the page pPage from the \n** PGroup LRU list, if is part of it. If pPage is not part of the PGroup\n** LRU list, then this function is a no-op.\n**\n** The PGroup mutex must be held when this function is called.\n*/\nstatic PgHdr1 *pcache1PinPage(PgHdr1 *pPage){\n  assert( pPage!=0 );\n  assert( PAGE_IS_UNPINNED(pPage) );\n  assert( pPage->pLruNext );\n  assert( pPage->pLruPrev );\n  assert( sqlite3_mutex_held(pPage->pCache->pGroup->mutex) );\n  pPage->pLruPrev->pLruNext = pPage->pLruNext;\n  pPage->pLruNext->pLruPrev = pPage->pLruPrev;\n  pPage->pLruNext = 0;\n  /* pPage->pLruPrev = 0;\n  ** No need to clear pLruPrev as it is never accessed if pLruNext is 0 */\n  assert( pPage->isAnchor==0 );\n  assert( pPage->pCache->pGroup->lru.isAnchor==1 );\n  pPage->pCache->nRecyclable--;\n  return pPage;\n}\n\n\n/*\n** Remove the page supplied as an argument from the hash table \n** (PCache1.apHash structure) that it is currently stored in.\n** Also free the page if freePage is true.\n**\n** The PGroup mutex must be held when this function is called.\n*/\nstatic void pcache1RemoveFromHash(PgHdr1 *pPage, int freeFlag){\n  unsigned int h;\n  PCache1 *pCache = pPage->pCache;\n  PgHdr1 **pp;\n\n  assert( sqlite3_mutex_held(pCache->pGroup->mutex) );\n  h = pPage->iKey % pCache->nHash;\n  for(pp=&pCache->apHash[h]; (*pp)!=pPage; pp=&(*pp)->pNext);\n  *pp = (*pp)->pNext;\n\n  pCache->nPage--;\n  if( freeFlag ) pcache1FreePage(pPage);\n}\n\n/*\n** If there are currently more than nMaxPage pages allocated, try\n** to recycle pages to reduce the number allocated to nMaxPage.\n*/\nstatic void pcache1EnforceMaxPage(PCache1 *pCache){\n  PGroup *pGroup = pCache->pGroup;\n  PgHdr1 *p;\n  assert( sqlite3_mutex_held(pGroup->mutex) );\n  while( pGroup->nPurgeable>pGroup->nMaxPage\n      && (p=pGroup->lru.pLruPrev)->isAnchor==0\n  ){\n    assert( p->pCache->pGroup==pGroup );\n    assert( PAGE_IS_UNPINNED(p) );\n    pcache1PinPage(p);\n    pcache1RemoveFromHash(p, 1);\n  }\n  if( pCache->nPage==0 && pCache->pBulk ){\n    sqlite3_free(pCache->pBulk);\n    pCache->pBulk = pCache->pFree = 0;\n  }\n}\n\n/*\n** Discard all pages from cache pCache with a page number (key value) \n** greater than or equal to iLimit. Any pinned pages that meet this \n** criteria are unpinned before they are discarded.\n**\n** The PCache mutex must be held when this function is called.\n*/\nstatic void pcache1TruncateUnsafe(\n  PCache1 *pCache,             /* The cache to truncate */\n  unsigned int iLimit          /* Drop pages with this pgno or larger */\n){\n  TESTONLY( int nPage = 0; )  /* To assert pCache->nPage is correct */\n  unsigned int h, iStop;\n  assert( sqlite3_mutex_held(pCache->pGroup->mutex) );\n  assert( pCache->iMaxKey >= iLimit );\n  assert( pCache->nHash > 0 );\n  if( pCache->iMaxKey - iLimit < pCache->nHash ){\n    /* If we are just shaving the last few pages off the end of the\n    ** cache, then there is no point in scanning the entire hash table.\n    ** Only scan those hash slots that might contain pages that need to\n    ** be removed. */\n    h = iLimit % pCache->nHash;\n    iStop = pCache->iMaxKey % pCache->nHash;\n    TESTONLY( nPage = -10; )  /* Disable the pCache->nPage validity check */\n  }else{\n    /* This is the general case where many pages are being removed.\n    ** It is necessary to scan the entire hash table */\n    h = pCache->nHash/2;\n    iStop = h - 1;\n  }\n  for(;;){\n    PgHdr1 **pp;\n    PgHdr1 *pPage;\n    assert( h<pCache->nHash );\n    pp = &pCache->apHash[h]; \n    while( (pPage = *pp)!=0 ){\n      if( pPage->iKey>=iLimit ){\n        pCache->nPage--;\n        *pp = pPage->pNext;\n        if( PAGE_IS_UNPINNED(pPage) ) pcache1PinPage(pPage);\n        pcache1FreePage(pPage);\n      }else{\n        pp = &pPage->pNext;\n        TESTONLY( if( nPage>=0 ) nPage++; )\n      }\n    }\n    if( h==iStop ) break;\n    h = (h+1) % pCache->nHash;\n  }\n  assert( nPage<0 || pCache->nPage==(unsigned)nPage );\n}\n\n/******************************************************************************/\n/******** sqlite3_pcache Methods **********************************************/\n\n/*\n** Implementation of the sqlite3_pcache.xInit method.\n*/\nstatic int pcache1Init(void *NotUsed){\n  UNUSED_PARAMETER(NotUsed);\n  assert( pcache1.isInit==0 );\n  memset(&pcache1, 0, sizeof(pcache1));\n\n\n  /*\n  ** The pcache1.separateCache variable is true if each PCache has its own\n  ** private PGroup (mode-1).  pcache1.separateCache is false if the single\n  ** PGroup in pcache1.grp is used for all page caches (mode-2).\n  **\n  **   *  Always use a unified cache (mode-2) if ENABLE_MEMORY_MANAGEMENT\n  **\n  **   *  Use a unified cache in single-threaded applications that have\n  **      configured a start-time buffer for use as page-cache memory using\n  **      sqlite3_config(SQLITE_CONFIG_PAGECACHE, pBuf, sz, N) with non-NULL \n  **      pBuf argument.\n  **\n  **   *  Otherwise use separate caches (mode-1)\n  */\n#if defined(SQLITE_ENABLE_MEMORY_MANAGEMENT)\n  pcache1.separateCache = 0;\n#elif SQLITE_THREADSAFE\n  pcache1.separateCache = sqlite3GlobalConfig.pPage==0\n                          || sqlite3GlobalConfig.bCoreMutex>0;\n#else\n  pcache1.separateCache = sqlite3GlobalConfig.pPage==0;\n#endif\n\n#if SQLITE_THREADSAFE\n  if( sqlite3GlobalConfig.bCoreMutex ){\n    pcache1.grp.mutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_LRU);\n    pcache1.mutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_PMEM);\n  }\n#endif\n  if( pcache1.separateCache\n   && sqlite3GlobalConfig.nPage!=0\n   && sqlite3GlobalConfig.pPage==0\n  ){\n    pcache1.nInitPage = sqlite3GlobalConfig.nPage;\n  }else{\n    pcache1.nInitPage = 0;\n  }\n  pcache1.grp.mxPinned = 10;\n  pcache1.isInit = 1;\n  return SQLITE_OK;\n}\n\n/*\n** Implementation of the sqlite3_pcache.xShutdown method.\n** Note that the static mutex allocated in xInit does \n** not need to be freed.\n*/\nstatic void pcache1Shutdown(void *NotUsed){\n  UNUSED_PARAMETER(NotUsed);\n  assert( pcache1.isInit!=0 );\n  memset(&pcache1, 0, sizeof(pcache1));\n}\n\n/* forward declaration */\nstatic void pcache1Destroy(sqlite3_pcache *p);\n\n/*\n** Implementation of the sqlite3_pcache.xCreate method.\n**\n** Allocate a new cache.\n*/\nstatic sqlite3_pcache *pcache1Create(int szPage, int szExtra, int bPurgeable){\n  PCache1 *pCache;      /* The newly created page cache */\n  PGroup *pGroup;       /* The group the new page cache will belong to */\n  int sz;               /* Bytes of memory required to allocate the new cache */\n\n  assert( (szPage & (szPage-1))==0 && szPage>=512 && szPage<=65536 );\n  assert( szExtra < 300 );\n\n  sz = sizeof(PCache1) + sizeof(PGroup)*pcache1.separateCache;\n  pCache = (PCache1 *)sqlite3MallocZero(sz);\n  if( pCache ){\n    if( pcache1.separateCache ){\n      pGroup = (PGroup*)&pCache[1];\n      pGroup->mxPinned = 10;\n    }else{\n      pGroup = &pcache1.grp;\n    }\n    if( pGroup->lru.isAnchor==0 ){\n      pGroup->lru.isAnchor = 1;\n      pGroup->lru.pLruPrev = pGroup->lru.pLruNext = &pGroup->lru;\n    }\n    pCache->pGroup = pGroup;\n    pCache->szPage = szPage;\n    pCache->szExtra = szExtra;\n    pCache->szAlloc = szPage + szExtra + ROUND8(sizeof(PgHdr1));\n    pCache->bPurgeable = (bPurgeable ? 1 : 0);\n    pcache1EnterMutex(pGroup);\n    pcache1ResizeHash(pCache);\n    if( bPurgeable ){\n      pCache->nMin = 10;\n      pGroup->nMinPage += pCache->nMin;\n      pGroup->mxPinned = pGroup->nMaxPage + 10 - pGroup->nMinPage;\n      pCache->pnPurgeable = &pGroup->nPurgeable;\n    }else{\n      pCache->pnPurgeable = &pCache->nPurgeableDummy;\n    }\n    pcache1LeaveMutex(pGroup);\n    if( pCache->nHash==0 ){\n      pcache1Destroy((sqlite3_pcache*)pCache);\n      pCache = 0;\n    }\n  }\n  return (sqlite3_pcache *)pCache;\n}\n\n/*\n** Implementation of the sqlite3_pcache.xCachesize method. \n**\n** Configure the cache_size limit for a cache.\n*/\nstatic void pcache1Cachesize(sqlite3_pcache *p, int nMax){\n  PCache1 *pCache = (PCache1 *)p;\n  if( pCache->bPurgeable ){\n    PGroup *pGroup = pCache->pGroup;\n    pcache1EnterMutex(pGroup);\n    pGroup->nMaxPage += (nMax - pCache->nMax);\n    pGroup->mxPinned = pGroup->nMaxPage + 10 - pGroup->nMinPage;\n    pCache->nMax = nMax;\n    pCache->n90pct = pCache->nMax*9/10;\n    pcache1EnforceMaxPage(pCache);\n    pcache1LeaveMutex(pGroup);\n  }\n}\n\n/*\n** Implementation of the sqlite3_pcache.xShrink method. \n**\n** Free up as much memory as possible.\n*/\nstatic void pcache1Shrink(sqlite3_pcache *p){\n  PCache1 *pCache = (PCache1*)p;\n  if( pCache->bPurgeable ){\n    PGroup *pGroup = pCache->pGroup;\n    int savedMaxPage;\n    pcache1EnterMutex(pGroup);\n    savedMaxPage = pGroup->nMaxPage;\n    pGroup->nMaxPage = 0;\n    pcache1EnforceMaxPage(pCache);\n    pGroup->nMaxPage = savedMaxPage;\n    pcache1LeaveMutex(pGroup);\n  }\n}\n\n/*\n** Implementation of the sqlite3_pcache.xPagecount method. \n*/\nstatic int pcache1Pagecount(sqlite3_pcache *p){\n  int n;\n  PCache1 *pCache = (PCache1*)p;\n  pcache1EnterMutex(pCache->pGroup);\n  n = pCache->nPage;\n  pcache1LeaveMutex(pCache->pGroup);\n  return n;\n}\n\n\n/*\n** Implement steps 3, 4, and 5 of the pcache1Fetch() algorithm described\n** in the header of the pcache1Fetch() procedure.\n**\n** This steps are broken out into a separate procedure because they are\n** usually not needed, and by avoiding the stack initialization required\n** for these steps, the main pcache1Fetch() procedure can run faster.\n*/\nstatic SQLITE_NOINLINE PgHdr1 *pcache1FetchStage2(\n  PCache1 *pCache, \n  unsigned int iKey, \n  int createFlag\n){\n  unsigned int nPinned;\n  PGroup *pGroup = pCache->pGroup;\n  PgHdr1 *pPage = 0;\n\n  /* Step 3: Abort if createFlag is 1 but the cache is nearly full */\n  assert( pCache->nPage >= pCache->nRecyclable );\n  nPinned = pCache->nPage - pCache->nRecyclable;\n  assert( pGroup->mxPinned == pGroup->nMaxPage + 10 - pGroup->nMinPage );\n  assert( pCache->n90pct == pCache->nMax*9/10 );\n  if( createFlag==1 && (\n        nPinned>=pGroup->mxPinned\n     || nPinned>=pCache->n90pct\n     || (pcache1UnderMemoryPressure(pCache) && pCache->nRecyclable<nPinned)\n  )){\n    return 0;\n  }\n\n  if( pCache->nPage>=pCache->nHash ) pcache1ResizeHash(pCache);\n  assert( pCache->nHash>0 && pCache->apHash );\n\n  /* Step 4. Try to recycle a page. */\n  if( pCache->bPurgeable\n   && !pGroup->lru.pLruPrev->isAnchor\n   && ((pCache->nPage+1>=pCache->nMax) || pcache1UnderMemoryPressure(pCache))\n  ){\n    PCache1 *pOther;\n    pPage = pGroup->lru.pLruPrev;\n    assert( PAGE_IS_UNPINNED(pPage) );\n    pcache1RemoveFromHash(pPage, 0);\n    pcache1PinPage(pPage);\n    pOther = pPage->pCache;\n    if( pOther->szAlloc != pCache->szAlloc ){\n      pcache1FreePage(pPage);\n      pPage = 0;\n    }else{\n      pGroup->nPurgeable -= (pOther->bPurgeable - pCache->bPurgeable);\n    }\n  }\n\n  /* Step 5. If a usable page buffer has still not been found, \n  ** attempt to allocate a new one. \n  */\n  if( !pPage ){\n    pPage = pcache1AllocPage(pCache, createFlag==1);\n  }\n\n  if( pPage ){\n    unsigned int h = iKey % pCache->nHash;\n    pCache->nPage++;\n    pPage->iKey = iKey;\n    pPage->pNext = pCache->apHash[h];\n    pPage->pCache = pCache;\n    pPage->pLruNext = 0;\n    /* pPage->pLruPrev = 0;\n    ** No need to clear pLruPrev since it is not accessed when pLruNext==0 */\n    *(void **)pPage->page.pExtra = 0;\n    pCache->apHash[h] = pPage;\n    if( iKey>pCache->iMaxKey ){\n      pCache->iMaxKey = iKey;\n    }\n  }\n  return pPage;\n}\n\n/*\n** Implementation of the sqlite3_pcache.xFetch method. \n**\n** Fetch a page by key value.\n**\n** Whether or not a new page may be allocated by this function depends on\n** the value of the createFlag argument.  0 means do not allocate a new\n** page.  1 means allocate a new page if space is easily available.  2 \n** means to try really hard to allocate a new page.\n**\n** For a non-purgeable cache (a cache used as the storage for an in-memory\n** database) there is really no difference between createFlag 1 and 2.  So\n** the calling function (pcache.c) will never have a createFlag of 1 on\n** a non-purgeable cache.\n**\n** There are three different approaches to obtaining space for a page,\n** depending on the value of parameter createFlag (which may be 0, 1 or 2).\n**\n**   1. Regardless of the value of createFlag, the cache is searched for a \n**      copy of the requested page. If one is found, it is returned.\n**\n**   2. If createFlag==0 and the page is not already in the cache, NULL is\n**      returned.\n**\n**   3. If createFlag is 1, and the page is not already in the cache, then\n**      return NULL (do not allocate a new page) if any of the following\n**      conditions are true:\n**\n**       (a) the number of pages pinned by the cache is greater than\n**           PCache1.nMax, or\n**\n**       (b) the number of pages pinned by the cache is greater than\n**           the sum of nMax for all purgeable caches, less the sum of \n**           nMin for all other purgeable caches, or\n**\n**   4. If none of the first three conditions apply and the cache is marked\n**      as purgeable, and if one of the following is true:\n**\n**       (a) The number of pages allocated for the cache is already \n**           PCache1.nMax, or\n**\n**       (b) The number of pages allocated for all purgeable caches is\n**           already equal to or greater than the sum of nMax for all\n**           purgeable caches,\n**\n**       (c) The system is under memory pressure and wants to avoid\n**           unnecessary pages cache entry allocations\n**\n**      then attempt to recycle a page from the LRU list. If it is the right\n**      size, return the recycled buffer. Otherwise, free the buffer and\n**      proceed to step 5. \n**\n**   5. Otherwise, allocate and return a new page buffer.\n**\n** There are two versions of this routine.  pcache1FetchWithMutex() is\n** the general case.  pcache1FetchNoMutex() is a faster implementation for\n** the common case where pGroup->mutex is NULL.  The pcache1Fetch() wrapper\n** invokes the appropriate routine.\n*/\nstatic PgHdr1 *pcache1FetchNoMutex(\n  sqlite3_pcache *p, \n  unsigned int iKey, \n  int createFlag\n){\n  PCache1 *pCache = (PCache1 *)p;\n  PgHdr1 *pPage = 0;\n\n  /* Step 1: Search the hash table for an existing entry. */\n  pPage = pCache->apHash[iKey % pCache->nHash];\n  while( pPage && pPage->iKey!=iKey ){ pPage = pPage->pNext; }\n\n  /* Step 2: If the page was found in the hash table, then return it.\n  ** If the page was not in the hash table and createFlag is 0, abort.\n  ** Otherwise (page not in hash and createFlag!=0) continue with\n  ** subsequent steps to try to create the page. */\n  if( pPage ){\n    if( PAGE_IS_UNPINNED(pPage) ){\n      return pcache1PinPage(pPage);\n    }else{\n      return pPage;\n    }\n  }else if( createFlag ){\n    /* Steps 3, 4, and 5 implemented by this subroutine */\n    return pcache1FetchStage2(pCache, iKey, createFlag);\n  }else{\n    return 0;\n  }\n}\n#if PCACHE1_MIGHT_USE_GROUP_MUTEX\nstatic PgHdr1 *pcache1FetchWithMutex(\n  sqlite3_pcache *p, \n  unsigned int iKey, \n  int createFlag\n){\n  PCache1 *pCache = (PCache1 *)p;\n  PgHdr1 *pPage;\n\n  pcache1EnterMutex(pCache->pGroup);\n  pPage = pcache1FetchNoMutex(p, iKey, createFlag);\n  assert( pPage==0 || pCache->iMaxKey>=iKey );\n  pcache1LeaveMutex(pCache->pGroup);\n  return pPage;\n}\n#endif\nstatic sqlite3_pcache_page *pcache1Fetch(\n  sqlite3_pcache *p, \n  unsigned int iKey, \n  int createFlag\n){\n#if PCACHE1_MIGHT_USE_GROUP_MUTEX || defined(SQLITE_DEBUG)\n  PCache1 *pCache = (PCache1 *)p;\n#endif\n\n  assert( offsetof(PgHdr1,page)==0 );\n  assert( pCache->bPurgeable || createFlag!=1 );\n  assert( pCache->bPurgeable || pCache->nMin==0 );\n  assert( pCache->bPurgeable==0 || pCache->nMin==10 );\n  assert( pCache->nMin==0 || pCache->bPurgeable );\n  assert( pCache->nHash>0 );\n#if PCACHE1_MIGHT_USE_GROUP_MUTEX\n  if( pCache->pGroup->mutex ){\n    return (sqlite3_pcache_page*)pcache1FetchWithMutex(p, iKey, createFlag);\n  }else\n#endif\n  {\n    return (sqlite3_pcache_page*)pcache1FetchNoMutex(p, iKey, createFlag);\n  }\n}\n\n\n/*\n** Implementation of the sqlite3_pcache.xUnpin method.\n**\n** Mark a page as unpinned (eligible for asynchronous recycling).\n*/\nstatic void pcache1Unpin(\n  sqlite3_pcache *p, \n  sqlite3_pcache_page *pPg, \n  int reuseUnlikely\n){\n  PCache1 *pCache = (PCache1 *)p;\n  PgHdr1 *pPage = (PgHdr1 *)pPg;\n  PGroup *pGroup = pCache->pGroup;\n \n  assert( pPage->pCache==pCache );\n  pcache1EnterMutex(pGroup);\n\n  /* It is an error to call this function if the page is already \n  ** part of the PGroup LRU list.\n  */\n  assert( pPage->pLruNext==0 );\n  assert( PAGE_IS_PINNED(pPage) );\n\n  if( reuseUnlikely || pGroup->nPurgeable>pGroup->nMaxPage ){\n    pcache1RemoveFromHash(pPage, 1);\n  }else{\n    /* Add the page to the PGroup LRU list. */\n    PgHdr1 **ppFirst = &pGroup->lru.pLruNext;\n    pPage->pLruPrev = &pGroup->lru;\n    (pPage->pLruNext = *ppFirst)->pLruPrev = pPage;\n    *ppFirst = pPage;\n    pCache->nRecyclable++;\n  }\n\n  pcache1LeaveMutex(pCache->pGroup);\n}\n\n/*\n** Implementation of the sqlite3_pcache.xRekey method. \n*/\nstatic void pcache1Rekey(\n  sqlite3_pcache *p,\n  sqlite3_pcache_page *pPg,\n  unsigned int iOld,\n  unsigned int iNew\n){\n  PCache1 *pCache = (PCache1 *)p;\n  PgHdr1 *pPage = (PgHdr1 *)pPg;\n  PgHdr1 **pp;\n  unsigned int h; \n  assert( pPage->iKey==iOld );\n  assert( pPage->pCache==pCache );\n\n  pcache1EnterMutex(pCache->pGroup);\n\n  h = iOld%pCache->nHash;\n  pp = &pCache->apHash[h];\n  while( (*pp)!=pPage ){\n    pp = &(*pp)->pNext;\n  }\n  *pp = pPage->pNext;\n\n  h = iNew%pCache->nHash;\n  pPage->iKey = iNew;\n  pPage->pNext = pCache->apHash[h];\n  pCache->apHash[h] = pPage;\n  if( iNew>pCache->iMaxKey ){\n    pCache->iMaxKey = iNew;\n  }\n\n  pcache1LeaveMutex(pCache->pGroup);\n}\n\n/*\n** Implementation of the sqlite3_pcache.xTruncate method. \n**\n** Discard all unpinned pages in the cache with a page number equal to\n** or greater than parameter iLimit. Any pinned pages with a page number\n** equal to or greater than iLimit are implicitly unpinned.\n*/\nstatic void pcache1Truncate(sqlite3_pcache *p, unsigned int iLimit){\n  PCache1 *pCache = (PCache1 *)p;\n  pcache1EnterMutex(pCache->pGroup);\n  if( iLimit<=pCache->iMaxKey ){\n    pcache1TruncateUnsafe(pCache, iLimit);\n    pCache->iMaxKey = iLimit-1;\n  }\n  pcache1LeaveMutex(pCache->pGroup);\n}\n\n/*\n** Implementation of the sqlite3_pcache.xDestroy method. \n**\n** Destroy a cache allocated using pcache1Create().\n*/\nstatic void pcache1Destroy(sqlite3_pcache *p){\n  PCache1 *pCache = (PCache1 *)p;\n  PGroup *pGroup = pCache->pGroup;\n  assert( pCache->bPurgeable || (pCache->nMax==0 && pCache->nMin==0) );\n  pcache1EnterMutex(pGroup);\n  if( pCache->nPage ) pcache1TruncateUnsafe(pCache, 0);\n  assert( pGroup->nMaxPage >= pCache->nMax );\n  pGroup->nMaxPage -= pCache->nMax;\n  assert( pGroup->nMinPage >= pCache->nMin );\n  pGroup->nMinPage -= pCache->nMin;\n  pGroup->mxPinned = pGroup->nMaxPage + 10 - pGroup->nMinPage;\n  pcache1EnforceMaxPage(pCache);\n  pcache1LeaveMutex(pGroup);\n  sqlite3_free(pCache->pBulk);\n  sqlite3_free(pCache->apHash);\n  sqlite3_free(pCache);\n}\n\n/*\n** This function is called during initialization (sqlite3_initialize()) to\n** install the default pluggable cache module, assuming the user has not\n** already provided an alternative.\n*/\nSQLITE_PRIVATE void sqlite3PCacheSetDefault(void){\n  static const sqlite3_pcache_methods2 defaultMethods = {\n    1,                       /* iVersion */\n    0,                       /* pArg */\n    pcache1Init,             /* xInit */\n    pcache1Shutdown,         /* xShutdown */\n    pcache1Create,           /* xCreate */\n    pcache1Cachesize,        /* xCachesize */\n    pcache1Pagecount,        /* xPagecount */\n    pcache1Fetch,            /* xFetch */\n    pcache1Unpin,            /* xUnpin */\n    pcache1Rekey,            /* xRekey */\n    pcache1Truncate,         /* xTruncate */\n    pcache1Destroy,          /* xDestroy */\n    pcache1Shrink            /* xShrink */\n  };\n  sqlite3_config(SQLITE_CONFIG_PCACHE2, &defaultMethods);\n}\n\n/*\n** Return the size of the header on each page of this PCACHE implementation.\n*/\nSQLITE_PRIVATE int sqlite3HeaderSizePcache1(void){ return ROUND8(sizeof(PgHdr1)); }\n\n/*\n** Return the global mutex used by this PCACHE implementation.  The\n** sqlite3_status() routine needs access to this mutex.\n*/\nSQLITE_PRIVATE sqlite3_mutex *sqlite3Pcache1Mutex(void){\n  return pcache1.mutex;\n}\n\n#ifdef SQLITE_ENABLE_MEMORY_MANAGEMENT\n/*\n** This function is called to free superfluous dynamically allocated memory\n** held by the pager system. Memory in use by any SQLite pager allocated\n** by the current thread may be sqlite3_free()ed.\n**\n** nReq is the number of bytes of memory required. Once this much has\n** been released, the function returns. The return value is the total number \n** of bytes of memory released.\n*/\nSQLITE_PRIVATE int sqlite3PcacheReleaseMemory(int nReq){\n  int nFree = 0;\n  assert( sqlite3_mutex_notheld(pcache1.grp.mutex) );\n  assert( sqlite3_mutex_notheld(pcache1.mutex) );\n  if( sqlite3GlobalConfig.pPage==0 ){\n    PgHdr1 *p;\n    pcache1EnterMutex(&pcache1.grp);\n    while( (nReq<0 || nFree<nReq)\n       &&  (p=pcache1.grp.lru.pLruPrev)!=0\n       &&  p->isAnchor==0\n    ){\n      nFree += pcache1MemSize(p->page.pBuf);\n#ifdef SQLITE_PCACHE_SEPARATE_HEADER\n      nFree += sqlite3MemSize(p);\n#endif\n      assert( PAGE_IS_UNPINNED(p) );\n      pcache1PinPage(p);\n      pcache1RemoveFromHash(p, 1);\n    }\n    pcache1LeaveMutex(&pcache1.grp);\n  }\n  return nFree;\n}\n#endif /* SQLITE_ENABLE_MEMORY_MANAGEMENT */\n\n#ifdef SQLITE_TEST\n/*\n** This function is used by test procedures to inspect the internal state\n** of the global cache.\n*/\nSQLITE_PRIVATE void sqlite3PcacheStats(\n  int *pnCurrent,      /* OUT: Total number of pages cached */\n  int *pnMax,          /* OUT: Global maximum cache size */\n  int *pnMin,          /* OUT: Sum of PCache1.nMin for purgeable caches */\n  int *pnRecyclable    /* OUT: Total number of pages available for recycling */\n){\n  PgHdr1 *p;\n  int nRecyclable = 0;\n  for(p=pcache1.grp.lru.pLruNext; p && !p->isAnchor; p=p->pLruNext){\n    assert( PAGE_IS_UNPINNED(p) );\n    nRecyclable++;\n  }\n  *pnCurrent = pcache1.grp.nPurgeable;\n  *pnMax = (int)pcache1.grp.nMaxPage;\n  *pnMin = (int)pcache1.grp.nMinPage;\n  *pnRecyclable = nRecyclable;\n}\n#endif\n\n/************** End of pcache1.c *********************************************/\n/************** Begin file rowset.c ******************************************/\n/*\n** 2008 December 3\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n**\n** This module implements an object we call a \"RowSet\".\n**\n** The RowSet object is a collection of rowids.  Rowids\n** are inserted into the RowSet in an arbitrary order.  Inserts\n** can be intermixed with tests to see if a given rowid has been\n** previously inserted into the RowSet.\n**\n** After all inserts are finished, it is possible to extract the\n** elements of the RowSet in sorted order.  Once this extraction\n** process has started, no new elements may be inserted.\n**\n** Hence, the primitive operations for a RowSet are:\n**\n**    CREATE\n**    INSERT\n**    TEST\n**    SMALLEST\n**    DESTROY\n**\n** The CREATE and DESTROY primitives are the constructor and destructor,\n** obviously.  The INSERT primitive adds a new element to the RowSet.\n** TEST checks to see if an element is already in the RowSet.  SMALLEST\n** extracts the least value from the RowSet.\n**\n** The INSERT primitive might allocate additional memory.  Memory is\n** allocated in chunks so most INSERTs do no allocation.  There is an \n** upper bound on the size of allocated memory.  No memory is freed\n** until DESTROY.\n**\n** The TEST primitive includes a \"batch\" number.  The TEST primitive\n** will only see elements that were inserted before the last change\n** in the batch number.  In other words, if an INSERT occurs between\n** two TESTs where the TESTs have the same batch nubmer, then the\n** value added by the INSERT will not be visible to the second TEST.\n** The initial batch number is zero, so if the very first TEST contains\n** a non-zero batch number, it will see all prior INSERTs.\n**\n** No INSERTs may occurs after a SMALLEST.  An assertion will fail if\n** that is attempted.\n**\n** The cost of an INSERT is roughly constant.  (Sometimes new memory\n** has to be allocated on an INSERT.)  The cost of a TEST with a new\n** batch number is O(NlogN) where N is the number of elements in the RowSet.\n** The cost of a TEST using the same batch number is O(logN).  The cost\n** of the first SMALLEST is O(NlogN).  Second and subsequent SMALLEST\n** primitives are constant time.  The cost of DESTROY is O(N).\n**\n** TEST and SMALLEST may not be used by the same RowSet.  This used to\n** be possible, but the feature was not used, so it was removed in order\n** to simplify the code.\n*/\n/* #include \"sqliteInt.h\" */\n\n\n/*\n** Target size for allocation chunks.\n*/\n#define ROWSET_ALLOCATION_SIZE 1024\n\n/*\n** The number of rowset entries per allocation chunk.\n*/\n#define ROWSET_ENTRY_PER_CHUNK  \\\n                       ((ROWSET_ALLOCATION_SIZE-8)/sizeof(struct RowSetEntry))\n\n/*\n** Each entry in a RowSet is an instance of the following object.\n**\n** This same object is reused to store a linked list of trees of RowSetEntry\n** objects.  In that alternative use, pRight points to the next entry\n** in the list, pLeft points to the tree, and v is unused.  The\n** RowSet.pForest value points to the head of this forest list.\n*/\nstruct RowSetEntry {            \n  i64 v;                        /* ROWID value for this entry */\n  struct RowSetEntry *pRight;   /* Right subtree (larger entries) or list */\n  struct RowSetEntry *pLeft;    /* Left subtree (smaller entries) */\n};\n\n/*\n** RowSetEntry objects are allocated in large chunks (instances of the\n** following structure) to reduce memory allocation overhead.  The\n** chunks are kept on a linked list so that they can be deallocated\n** when the RowSet is destroyed.\n*/\nstruct RowSetChunk {\n  struct RowSetChunk *pNextChunk;        /* Next chunk on list of them all */\n  struct RowSetEntry aEntry[ROWSET_ENTRY_PER_CHUNK]; /* Allocated entries */\n};\n\n/*\n** A RowSet in an instance of the following structure.\n**\n** A typedef of this structure if found in sqliteInt.h.\n*/\nstruct RowSet {\n  struct RowSetChunk *pChunk;    /* List of all chunk allocations */\n  sqlite3 *db;                   /* The database connection */\n  struct RowSetEntry *pEntry;    /* List of entries using pRight */\n  struct RowSetEntry *pLast;     /* Last entry on the pEntry list */\n  struct RowSetEntry *pFresh;    /* Source of new entry objects */\n  struct RowSetEntry *pForest;   /* List of binary trees of entries */\n  u16 nFresh;                    /* Number of objects on pFresh */\n  u16 rsFlags;                   /* Various flags */\n  int iBatch;                    /* Current insert batch */\n};\n\n/*\n** Allowed values for RowSet.rsFlags\n*/\n#define ROWSET_SORTED  0x01   /* True if RowSet.pEntry is sorted */\n#define ROWSET_NEXT    0x02   /* True if sqlite3RowSetNext() has been called */\n\n/*\n** Allocate a RowSet object.  Return NULL if a memory allocation\n** error occurs.\n*/\nSQLITE_PRIVATE RowSet *sqlite3RowSetInit(sqlite3 *db){\n  RowSet *p = sqlite3DbMallocRawNN(db, sizeof(*p));\n  if( p ){\n    int N = sqlite3DbMallocSize(db, p);\n    p->pChunk = 0;\n    p->db = db;\n    p->pEntry = 0;\n    p->pLast = 0;\n    p->pForest = 0;\n    p->pFresh = (struct RowSetEntry*)(ROUND8(sizeof(*p)) + (char*)p);\n    p->nFresh = (u16)((N - ROUND8(sizeof(*p)))/sizeof(struct RowSetEntry));\n    p->rsFlags = ROWSET_SORTED;\n    p->iBatch = 0;\n  }\n  return p;\n}\n\n/*\n** Deallocate all chunks from a RowSet.  This frees all memory that\n** the RowSet has allocated over its lifetime.  This routine is\n** the destructor for the RowSet.\n*/\nSQLITE_PRIVATE void sqlite3RowSetClear(void *pArg){\n  RowSet *p = (RowSet*)pArg;\n  struct RowSetChunk *pChunk, *pNextChunk;\n  for(pChunk=p->pChunk; pChunk; pChunk = pNextChunk){\n    pNextChunk = pChunk->pNextChunk;\n    sqlite3DbFree(p->db, pChunk);\n  }\n  p->pChunk = 0;\n  p->nFresh = 0;\n  p->pEntry = 0;\n  p->pLast = 0;\n  p->pForest = 0;\n  p->rsFlags = ROWSET_SORTED;\n}\n\n/*\n** Deallocate all chunks from a RowSet.  This frees all memory that\n** the RowSet has allocated over its lifetime.  This routine is\n** the destructor for the RowSet.\n*/\nSQLITE_PRIVATE void sqlite3RowSetDelete(void *pArg){\n  sqlite3RowSetClear(pArg);\n  sqlite3DbFree(((RowSet*)pArg)->db, pArg);\n}\n\n/*\n** Allocate a new RowSetEntry object that is associated with the\n** given RowSet.  Return a pointer to the new and completely uninitialized\n** objected.\n**\n** In an OOM situation, the RowSet.db->mallocFailed flag is set and this\n** routine returns NULL.\n*/\nstatic struct RowSetEntry *rowSetEntryAlloc(RowSet *p){\n  assert( p!=0 );\n  if( p->nFresh==0 ){  /*OPTIMIZATION-IF-FALSE*/\n    /* We could allocate a fresh RowSetEntry each time one is needed, but it\n    ** is more efficient to pull a preallocated entry from the pool */\n    struct RowSetChunk *pNew;\n    pNew = sqlite3DbMallocRawNN(p->db, sizeof(*pNew));\n    if( pNew==0 ){\n      return 0;\n    }\n    pNew->pNextChunk = p->pChunk;\n    p->pChunk = pNew;\n    p->pFresh = pNew->aEntry;\n    p->nFresh = ROWSET_ENTRY_PER_CHUNK;\n  }\n  p->nFresh--;\n  return p->pFresh++;\n}\n\n/*\n** Insert a new value into a RowSet.\n**\n** The mallocFailed flag of the database connection is set if a\n** memory allocation fails.\n*/\nSQLITE_PRIVATE void sqlite3RowSetInsert(RowSet *p, i64 rowid){\n  struct RowSetEntry *pEntry;  /* The new entry */\n  struct RowSetEntry *pLast;   /* The last prior entry */\n\n  /* This routine is never called after sqlite3RowSetNext() */\n  assert( p!=0 && (p->rsFlags & ROWSET_NEXT)==0 );\n\n  pEntry = rowSetEntryAlloc(p);\n  if( pEntry==0 ) return;\n  pEntry->v = rowid;\n  pEntry->pRight = 0;\n  pLast = p->pLast;\n  if( pLast ){\n    if( rowid<=pLast->v ){  /*OPTIMIZATION-IF-FALSE*/\n      /* Avoid unnecessary sorts by preserving the ROWSET_SORTED flags\n      ** where possible */\n      p->rsFlags &= ~ROWSET_SORTED;\n    }\n    pLast->pRight = pEntry;\n  }else{\n    p->pEntry = pEntry;\n  }\n  p->pLast = pEntry;\n}\n\n/*\n** Merge two lists of RowSetEntry objects.  Remove duplicates.\n**\n** The input lists are connected via pRight pointers and are \n** assumed to each already be in sorted order.\n*/\nstatic struct RowSetEntry *rowSetEntryMerge(\n  struct RowSetEntry *pA,    /* First sorted list to be merged */\n  struct RowSetEntry *pB     /* Second sorted list to be merged */\n){\n  struct RowSetEntry head;\n  struct RowSetEntry *pTail;\n\n  pTail = &head;\n  assert( pA!=0 && pB!=0 );\n  for(;;){\n    assert( pA->pRight==0 || pA->v<=pA->pRight->v );\n    assert( pB->pRight==0 || pB->v<=pB->pRight->v );\n    if( pA->v<=pB->v ){\n      if( pA->v<pB->v ) pTail = pTail->pRight = pA;\n      pA = pA->pRight;\n      if( pA==0 ){\n        pTail->pRight = pB;\n        break;\n      }\n    }else{\n      pTail = pTail->pRight = pB;\n      pB = pB->pRight;\n      if( pB==0 ){\n        pTail->pRight = pA;\n        break;\n      }\n    }\n  }\n  return head.pRight;\n}\n\n/*\n** Sort all elements on the list of RowSetEntry objects into order of\n** increasing v.\n*/ \nstatic struct RowSetEntry *rowSetEntrySort(struct RowSetEntry *pIn){\n  unsigned int i;\n  struct RowSetEntry *pNext, *aBucket[40];\n\n  memset(aBucket, 0, sizeof(aBucket));\n  while( pIn ){\n    pNext = pIn->pRight;\n    pIn->pRight = 0;\n    for(i=0; aBucket[i]; i++){\n      pIn = rowSetEntryMerge(aBucket[i], pIn);\n      aBucket[i] = 0;\n    }\n    aBucket[i] = pIn;\n    pIn = pNext;\n  }\n  pIn = aBucket[0];\n  for(i=1; i<sizeof(aBucket)/sizeof(aBucket[0]); i++){\n    if( aBucket[i]==0 ) continue;\n    pIn = pIn ? rowSetEntryMerge(pIn, aBucket[i]) : aBucket[i];\n  }\n  return pIn;\n}\n\n\n/*\n** The input, pIn, is a binary tree (or subtree) of RowSetEntry objects.\n** Convert this tree into a linked list connected by the pRight pointers\n** and return pointers to the first and last elements of the new list.\n*/\nstatic void rowSetTreeToList(\n  struct RowSetEntry *pIn,         /* Root of the input tree */\n  struct RowSetEntry **ppFirst,    /* Write head of the output list here */\n  struct RowSetEntry **ppLast      /* Write tail of the output list here */\n){\n  assert( pIn!=0 );\n  if( pIn->pLeft ){\n    struct RowSetEntry *p;\n    rowSetTreeToList(pIn->pLeft, ppFirst, &p);\n    p->pRight = pIn;\n  }else{\n    *ppFirst = pIn;\n  }\n  if( pIn->pRight ){\n    rowSetTreeToList(pIn->pRight, &pIn->pRight, ppLast);\n  }else{\n    *ppLast = pIn;\n  }\n  assert( (*ppLast)->pRight==0 );\n}\n\n\n/*\n** Convert a sorted list of elements (connected by pRight) into a binary\n** tree with depth of iDepth.  A depth of 1 means the tree contains a single\n** node taken from the head of *ppList.  A depth of 2 means a tree with\n** three nodes.  And so forth.\n**\n** Use as many entries from the input list as required and update the\n** *ppList to point to the unused elements of the list.  If the input\n** list contains too few elements, then construct an incomplete tree\n** and leave *ppList set to NULL.\n**\n** Return a pointer to the root of the constructed binary tree.\n*/\nstatic struct RowSetEntry *rowSetNDeepTree(\n  struct RowSetEntry **ppList,\n  int iDepth\n){\n  struct RowSetEntry *p;         /* Root of the new tree */\n  struct RowSetEntry *pLeft;     /* Left subtree */\n  if( *ppList==0 ){ /*OPTIMIZATION-IF-TRUE*/\n    /* Prevent unnecessary deep recursion when we run out of entries */\n    return 0; \n  }\n  if( iDepth>1 ){   /*OPTIMIZATION-IF-TRUE*/\n    /* This branch causes a *balanced* tree to be generated.  A valid tree\n    ** is still generated without this branch, but the tree is wildly\n    ** unbalanced and inefficient. */\n    pLeft = rowSetNDeepTree(ppList, iDepth-1);\n    p = *ppList;\n    if( p==0 ){     /*OPTIMIZATION-IF-FALSE*/\n      /* It is safe to always return here, but the resulting tree\n      ** would be unbalanced */\n      return pLeft;\n    }\n    p->pLeft = pLeft;\n    *ppList = p->pRight;\n    p->pRight = rowSetNDeepTree(ppList, iDepth-1);\n  }else{\n    p = *ppList;\n    *ppList = p->pRight;\n    p->pLeft = p->pRight = 0;\n  }\n  return p;\n}\n\n/*\n** Convert a sorted list of elements into a binary tree. Make the tree\n** as deep as it needs to be in order to contain the entire list.\n*/\nstatic struct RowSetEntry *rowSetListToTree(struct RowSetEntry *pList){\n  int iDepth;           /* Depth of the tree so far */\n  struct RowSetEntry *p;       /* Current tree root */\n  struct RowSetEntry *pLeft;   /* Left subtree */\n\n  assert( pList!=0 );\n  p = pList;\n  pList = p->pRight;\n  p->pLeft = p->pRight = 0;\n  for(iDepth=1; pList; iDepth++){\n    pLeft = p;\n    p = pList;\n    pList = p->pRight;\n    p->pLeft = pLeft;\n    p->pRight = rowSetNDeepTree(&pList, iDepth);\n  }\n  return p;\n}\n\n/*\n** Extract the smallest element from the RowSet.\n** Write the element into *pRowid.  Return 1 on success.  Return\n** 0 if the RowSet is already empty.\n**\n** After this routine has been called, the sqlite3RowSetInsert()\n** routine may not be called again.\n**\n** This routine may not be called after sqlite3RowSetTest() has\n** been used.  Older versions of RowSet allowed that, but as the\n** capability was not used by the code generator, it was removed\n** for code economy.\n*/\nSQLITE_PRIVATE int sqlite3RowSetNext(RowSet *p, i64 *pRowid){\n  assert( p!=0 );\n  assert( p->pForest==0 );  /* Cannot be used with sqlite3RowSetText() */\n\n  /* Merge the forest into a single sorted list on first call */\n  if( (p->rsFlags & ROWSET_NEXT)==0 ){  /*OPTIMIZATION-IF-FALSE*/\n    if( (p->rsFlags & ROWSET_SORTED)==0 ){  /*OPTIMIZATION-IF-FALSE*/\n      p->pEntry = rowSetEntrySort(p->pEntry);\n    }\n    p->rsFlags |= ROWSET_SORTED|ROWSET_NEXT;\n  }\n\n  /* Return the next entry on the list */\n  if( p->pEntry ){\n    *pRowid = p->pEntry->v;\n    p->pEntry = p->pEntry->pRight;\n    if( p->pEntry==0 ){ /*OPTIMIZATION-IF-TRUE*/\n      /* Free memory immediately, rather than waiting on sqlite3_finalize() */\n      sqlite3RowSetClear(p);\n    }\n    return 1;\n  }else{\n    return 0;\n  }\n}\n\n/*\n** Check to see if element iRowid was inserted into the rowset as\n** part of any insert batch prior to iBatch.  Return 1 or 0.\n**\n** If this is the first test of a new batch and if there exist entries\n** on pRowSet->pEntry, then sort those entries into the forest at\n** pRowSet->pForest so that they can be tested.\n*/\nSQLITE_PRIVATE int sqlite3RowSetTest(RowSet *pRowSet, int iBatch, sqlite3_int64 iRowid){\n  struct RowSetEntry *p, *pTree;\n\n  /* This routine is never called after sqlite3RowSetNext() */\n  assert( pRowSet!=0 && (pRowSet->rsFlags & ROWSET_NEXT)==0 );\n\n  /* Sort entries into the forest on the first test of a new batch.\n  ** To save unnecessary work, only do this when the batch number changes.\n  */\n  if( iBatch!=pRowSet->iBatch ){  /*OPTIMIZATION-IF-FALSE*/\n    p = pRowSet->pEntry;\n    if( p ){\n      struct RowSetEntry **ppPrevTree = &pRowSet->pForest;\n      if( (pRowSet->rsFlags & ROWSET_SORTED)==0 ){ /*OPTIMIZATION-IF-FALSE*/\n        /* Only sort the current set of entiries if they need it */\n        p = rowSetEntrySort(p);\n      }\n      for(pTree = pRowSet->pForest; pTree; pTree=pTree->pRight){\n        ppPrevTree = &pTree->pRight;\n        if( pTree->pLeft==0 ){\n          pTree->pLeft = rowSetListToTree(p);\n          break;\n        }else{\n          struct RowSetEntry *pAux, *pTail;\n          rowSetTreeToList(pTree->pLeft, &pAux, &pTail);\n          pTree->pLeft = 0;\n          p = rowSetEntryMerge(pAux, p);\n        }\n      }\n      if( pTree==0 ){\n        *ppPrevTree = pTree = rowSetEntryAlloc(pRowSet);\n        if( pTree ){\n          pTree->v = 0;\n          pTree->pRight = 0;\n          pTree->pLeft = rowSetListToTree(p);\n        }\n      }\n      pRowSet->pEntry = 0;\n      pRowSet->pLast = 0;\n      pRowSet->rsFlags |= ROWSET_SORTED;\n    }\n    pRowSet->iBatch = iBatch;\n  }\n\n  /* Test to see if the iRowid value appears anywhere in the forest.\n  ** Return 1 if it does and 0 if not.\n  */\n  for(pTree = pRowSet->pForest; pTree; pTree=pTree->pRight){\n    p = pTree->pLeft;\n    while( p ){\n      if( p->v<iRowid ){\n        p = p->pRight;\n      }else if( p->v>iRowid ){\n        p = p->pLeft;\n      }else{\n        return 1;\n      }\n    }\n  }\n  return 0;\n}\n\n/************** End of rowset.c **********************************************/\n/************** Begin file pager.c *******************************************/\n/*\n** 2001 September 15\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This is the implementation of the page cache subsystem or \"pager\".\n** \n** The pager is used to access a database disk file.  It implements\n** atomic commit and rollback through the use of a journal file that\n** is separate from the database file.  The pager also implements file\n** locking to prevent two processes from writing the same database\n** file simultaneously, or one process from reading the database while\n** another is writing.\n*/\n#ifndef SQLITE_OMIT_DISKIO\n/* #include \"sqliteInt.h\" */\n/************** Include wal.h in the middle of pager.c ***********************/\n/************** Begin file wal.h *********************************************/\n/*\n** 2010 February 1\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This header file defines the interface to the write-ahead logging \n** system. Refer to the comments below and the header comment attached to \n** the implementation of each function in log.c for further details.\n*/\n\n#ifndef SQLITE_WAL_H\n#define SQLITE_WAL_H\n\n/* #include \"sqliteInt.h\" */\n\n/* Macros for extracting appropriate sync flags for either transaction\n** commits (WAL_SYNC_FLAGS(X)) or for checkpoint ops (CKPT_SYNC_FLAGS(X)):\n*/\n#define WAL_SYNC_FLAGS(X)   ((X)&0x03)\n#define CKPT_SYNC_FLAGS(X)  (((X)>>2)&0x03)\n\n#ifdef SQLITE_OMIT_WAL\n# define sqlite3WalOpen(x,y,z)                   0\n# define sqlite3WalLimit(x,y)\n# define sqlite3WalClose(v,w,x,y,z)              0\n# define sqlite3WalBeginReadTransaction(y,z)     0\n# define sqlite3WalEndReadTransaction(z)\n# define sqlite3WalDbsize(y)                     0\n# define sqlite3WalBeginWriteTransaction(y)      0\n# define sqlite3WalEndWriteTransaction(x)        0\n# define sqlite3WalUndo(x,y,z)                   0\n# define sqlite3WalSavepoint(y,z)\n# define sqlite3WalSavepointUndo(y,z)            0\n# define sqlite3WalFrames(u,v,w,x,y,z)           0\n# define sqlite3WalCheckpoint(q,r,s,t,u,v,w,x,y,z) 0\n# define sqlite3WalCallback(z)                   0\n# define sqlite3WalExclusiveMode(y,z)            0\n# define sqlite3WalHeapMemory(z)                 0\n# define sqlite3WalFramesize(z)                  0\n# define sqlite3WalFindFrame(x,y,z)              0\n# define sqlite3WalFile(x)                       0\n#else\n\n#define WAL_SAVEPOINT_NDATA 4\n\n/* Connection to a write-ahead log (WAL) file. \n** There is one object of this type for each pager. \n*/\ntypedef struct Wal Wal;\n\n/* Open and close a connection to a write-ahead log. */\nSQLITE_PRIVATE int sqlite3WalOpen(sqlite3_vfs*, sqlite3_file*, const char *, int, i64, Wal**);\nSQLITE_PRIVATE int sqlite3WalClose(Wal *pWal, sqlite3*, int sync_flags, int, u8 *);\n\n/* Set the limiting size of a WAL file. */\nSQLITE_PRIVATE void sqlite3WalLimit(Wal*, i64);\n\n/* Used by readers to open (lock) and close (unlock) a snapshot.  A \n** snapshot is like a read-transaction.  It is the state of the database\n** at an instant in time.  sqlite3WalOpenSnapshot gets a read lock and\n** preserves the current state even if the other threads or processes\n** write to or checkpoint the WAL.  sqlite3WalCloseSnapshot() closes the\n** transaction and releases the lock.\n*/\nSQLITE_PRIVATE int sqlite3WalBeginReadTransaction(Wal *pWal, int *);\nSQLITE_PRIVATE void sqlite3WalEndReadTransaction(Wal *pWal);\n\n/* Read a page from the write-ahead log, if it is present. */\nSQLITE_PRIVATE int sqlite3WalFindFrame(Wal *, Pgno, u32 *);\nSQLITE_PRIVATE int sqlite3WalReadFrame(Wal *, u32, int, u8 *);\n\n/* If the WAL is not empty, return the size of the database. */\nSQLITE_PRIVATE Pgno sqlite3WalDbsize(Wal *pWal);\n\n/* Obtain or release the WRITER lock. */\nSQLITE_PRIVATE int sqlite3WalBeginWriteTransaction(Wal *pWal);\nSQLITE_PRIVATE int sqlite3WalEndWriteTransaction(Wal *pWal);\n\n/* Undo any frames written (but not committed) to the log */\nSQLITE_PRIVATE int sqlite3WalUndo(Wal *pWal, int (*xUndo)(void *, Pgno), void *pUndoCtx);\n\n/* Return an integer that records the current (uncommitted) write\n** position in the WAL */\nSQLITE_PRIVATE void sqlite3WalSavepoint(Wal *pWal, u32 *aWalData);\n\n/* Move the write position of the WAL back to iFrame.  Called in\n** response to a ROLLBACK TO command. */\nSQLITE_PRIVATE int sqlite3WalSavepointUndo(Wal *pWal, u32 *aWalData);\n\n/* Write a frame or frames to the log. */\nSQLITE_PRIVATE int sqlite3WalFrames(Wal *pWal, int, PgHdr *, Pgno, int, int);\n\n/* Copy pages from the log to the database file */ \nSQLITE_PRIVATE int sqlite3WalCheckpoint(\n  Wal *pWal,                      /* Write-ahead log connection */\n  sqlite3 *db,                    /* Check this handle's interrupt flag */\n  int eMode,                      /* One of PASSIVE, FULL and RESTART */\n  int (*xBusy)(void*),            /* Function to call when busy */\n  void *pBusyArg,                 /* Context argument for xBusyHandler */\n  int sync_flags,                 /* Flags to sync db file with (or 0) */\n  int nBuf,                       /* Size of buffer nBuf */\n  u8 *zBuf,                       /* Temporary buffer to use */\n  int *pnLog,                     /* OUT: Number of frames in WAL */\n  int *pnCkpt                     /* OUT: Number of backfilled frames in WAL */\n);\n\n/* Return the value to pass to a sqlite3_wal_hook callback, the\n** number of frames in the WAL at the point of the last commit since\n** sqlite3WalCallback() was called.  If no commits have occurred since\n** the last call, then return 0.\n*/\nSQLITE_PRIVATE int sqlite3WalCallback(Wal *pWal);\n\n/* Tell the wal layer that an EXCLUSIVE lock has been obtained (or released)\n** by the pager layer on the database file.\n*/\nSQLITE_PRIVATE int sqlite3WalExclusiveMode(Wal *pWal, int op);\n\n/* Return true if the argument is non-NULL and the WAL module is using\n** heap-memory for the wal-index. Otherwise, if the argument is NULL or the\n** WAL module is using shared-memory, return false. \n*/\nSQLITE_PRIVATE int sqlite3WalHeapMemory(Wal *pWal);\n\n#ifdef SQLITE_ENABLE_SNAPSHOT\nSQLITE_PRIVATE int sqlite3WalSnapshotGet(Wal *pWal, sqlite3_snapshot **ppSnapshot);\nSQLITE_PRIVATE void sqlite3WalSnapshotOpen(Wal *pWal, sqlite3_snapshot *pSnapshot);\nSQLITE_PRIVATE int sqlite3WalSnapshotRecover(Wal *pWal);\nSQLITE_PRIVATE int sqlite3WalSnapshotCheck(Wal *pWal, sqlite3_snapshot *pSnapshot);\nSQLITE_PRIVATE void sqlite3WalSnapshotUnlock(Wal *pWal);\n#endif\n\n#ifdef SQLITE_ENABLE_ZIPVFS\n/* If the WAL file is not empty, return the number of bytes of content\n** stored in each frame (i.e. the db page-size when the WAL was created).\n*/\nSQLITE_PRIVATE int sqlite3WalFramesize(Wal *pWal);\n#endif\n\n/* Return the sqlite3_file object for the WAL file */\nSQLITE_PRIVATE sqlite3_file *sqlite3WalFile(Wal *pWal);\n\n#endif /* ifndef SQLITE_OMIT_WAL */\n#endif /* SQLITE_WAL_H */\n\n/************** End of wal.h *************************************************/\n/************** Continuing where we left off in pager.c **********************/\n\n\n/******************* NOTES ON THE DESIGN OF THE PAGER ************************\n**\n** This comment block describes invariants that hold when using a rollback\n** journal.  These invariants do not apply for journal_mode=WAL,\n** journal_mode=MEMORY, or journal_mode=OFF.\n**\n** Within this comment block, a page is deemed to have been synced\n** automatically as soon as it is written when PRAGMA synchronous=OFF.\n** Otherwise, the page is not synced until the xSync method of the VFS\n** is called successfully on the file containing the page.\n**\n** Definition:  A page of the database file is said to be \"overwriteable\" if\n** one or more of the following are true about the page:\n** \n**     (a)  The original content of the page as it was at the beginning of\n**          the transaction has been written into the rollback journal and\n**          synced.\n** \n**     (b)  The page was a freelist leaf page at the start of the transaction.\n** \n**     (c)  The page number is greater than the largest page that existed in\n**          the database file at the start of the transaction.\n** \n** (1) A page of the database file is never overwritten unless one of the\n**     following are true:\n** \n**     (a) The page and all other pages on the same sector are overwriteable.\n** \n**     (b) The atomic page write optimization is enabled, and the entire\n**         transaction other than the update of the transaction sequence\n**         number consists of a single page change.\n** \n** (2) The content of a page written into the rollback journal exactly matches\n**     both the content in the database when the rollback journal was written\n**     and the content in the database at the beginning of the current\n**     transaction.\n** \n** (3) Writes to the database file are an integer multiple of the page size\n**     in length and are aligned on a page boundary.\n** \n** (4) Reads from the database file are either aligned on a page boundary and\n**     an integer multiple of the page size in length or are taken from the\n**     first 100 bytes of the database file.\n** \n** (5) All writes to the database file are synced prior to the rollback journal\n**     being deleted, truncated, or zeroed.\n** \n** (6) If a master journal file is used, then all writes to the database file\n**     are synced prior to the master journal being deleted.\n** \n** Definition: Two databases (or the same database at two points it time)\n** are said to be \"logically equivalent\" if they give the same answer to\n** all queries.  Note in particular the content of freelist leaf\n** pages can be changed arbitrarily without affecting the logical equivalence\n** of the database.\n** \n** (7) At any time, if any subset, including the empty set and the total set,\n**     of the unsynced changes to a rollback journal are removed and the \n**     journal is rolled back, the resulting database file will be logically\n**     equivalent to the database file at the beginning of the transaction.\n** \n** (8) When a transaction is rolled back, the xTruncate method of the VFS\n**     is called to restore the database file to the same size it was at\n**     the beginning of the transaction.  (In some VFSes, the xTruncate\n**     method is a no-op, but that does not change the fact the SQLite will\n**     invoke it.)\n** \n** (9) Whenever the database file is modified, at least one bit in the range\n**     of bytes from 24 through 39 inclusive will be changed prior to releasing\n**     the EXCLUSIVE lock, thus signaling other connections on the same\n**     database to flush their caches.\n**\n** (10) The pattern of bits in bytes 24 through 39 shall not repeat in less\n**      than one billion transactions.\n**\n** (11) A database file is well-formed at the beginning and at the conclusion\n**      of every transaction.\n**\n** (12) An EXCLUSIVE lock is held on the database file when writing to\n**      the database file.\n**\n** (13) A SHARED lock is held on the database file while reading any\n**      content out of the database file.\n**\n******************************************************************************/\n\n/*\n** Macros for troubleshooting.  Normally turned off\n*/\n#if 0\nint sqlite3PagerTrace=1;  /* True to enable tracing */\n#define sqlite3DebugPrintf printf\n#define PAGERTRACE(X)     if( sqlite3PagerTrace ){ sqlite3DebugPrintf X; }\n#else\n#define PAGERTRACE(X)\n#endif\n\n/*\n** The following two macros are used within the PAGERTRACE() macros above\n** to print out file-descriptors. \n**\n** PAGERID() takes a pointer to a Pager struct as its argument. The\n** associated file-descriptor is returned. FILEHANDLEID() takes an sqlite3_file\n** struct as its argument.\n*/\n#define PAGERID(p) (SQLITE_PTR_TO_INT(p->fd))\n#define FILEHANDLEID(fd) (SQLITE_PTR_TO_INT(fd))\n\n/*\n** The Pager.eState variable stores the current 'state' of a pager. A\n** pager may be in any one of the seven states shown in the following\n** state diagram.\n**\n**                            OPEN <------+------+\n**                              |         |      |\n**                              V         |      |\n**               +---------> READER-------+      |\n**               |              |                |\n**               |              V                |\n**               |<-------WRITER_LOCKED------> ERROR\n**               |              |                ^  \n**               |              V                |\n**               |<------WRITER_CACHEMOD-------->|\n**               |              |                |\n**               |              V                |\n**               |<-------WRITER_DBMOD---------->|\n**               |              |                |\n**               |              V                |\n**               +<------WRITER_FINISHED-------->+\n**\n**\n** List of state transitions and the C [function] that performs each:\n** \n**   OPEN              -> READER              [sqlite3PagerSharedLock]\n**   READER            -> OPEN                [pager_unlock]\n**\n**   READER            -> WRITER_LOCKED       [sqlite3PagerBegin]\n**   WRITER_LOCKED     -> WRITER_CACHEMOD     [pager_open_journal]\n**   WRITER_CACHEMOD   -> WRITER_DBMOD        [syncJournal]\n**   WRITER_DBMOD      -> WRITER_FINISHED     [sqlite3PagerCommitPhaseOne]\n**   WRITER_***        -> READER              [pager_end_transaction]\n**\n**   WRITER_***        -> ERROR               [pager_error]\n**   ERROR             -> OPEN                [pager_unlock]\n** \n**\n**  OPEN:\n**\n**    The pager starts up in this state. Nothing is guaranteed in this\n**    state - the file may or may not be locked and the database size is\n**    unknown. The database may not be read or written.\n**\n**    * No read or write transaction is active.\n**    * Any lock, or no lock at all, may be held on the database file.\n**    * The dbSize, dbOrigSize and dbFileSize variables may not be trusted.\n**\n**  READER:\n**\n**    In this state all the requirements for reading the database in \n**    rollback (non-WAL) mode are met. Unless the pager is (or recently\n**    was) in exclusive-locking mode, a user-level read transaction is \n**    open. The database size is known in this state.\n**\n**    A connection running with locking_mode=normal enters this state when\n**    it opens a read-transaction on the database and returns to state\n**    OPEN after the read-transaction is completed. However a connection\n**    running in locking_mode=exclusive (including temp databases) remains in\n**    this state even after the read-transaction is closed. The only way\n**    a locking_mode=exclusive connection can transition from READER to OPEN\n**    is via the ERROR state (see below).\n** \n**    * A read transaction may be active (but a write-transaction cannot).\n**    * A SHARED or greater lock is held on the database file.\n**    * The dbSize variable may be trusted (even if a user-level read \n**      transaction is not active). The dbOrigSize and dbFileSize variables\n**      may not be trusted at this point.\n**    * If the database is a WAL database, then the WAL connection is open.\n**    * Even if a read-transaction is not open, it is guaranteed that \n**      there is no hot-journal in the file-system.\n**\n**  WRITER_LOCKED:\n**\n**    The pager moves to this state from READER when a write-transaction\n**    is first opened on the database. In WRITER_LOCKED state, all locks \n**    required to start a write-transaction are held, but no actual \n**    modifications to the cache or database have taken place.\n**\n**    In rollback mode, a RESERVED or (if the transaction was opened with \n**    BEGIN EXCLUSIVE) EXCLUSIVE lock is obtained on the database file when\n**    moving to this state, but the journal file is not written to or opened \n**    to in this state. If the transaction is committed or rolled back while \n**    in WRITER_LOCKED state, all that is required is to unlock the database \n**    file.\n**\n**    IN WAL mode, WalBeginWriteTransaction() is called to lock the log file.\n**    If the connection is running with locking_mode=exclusive, an attempt\n**    is made to obtain an EXCLUSIVE lock on the database file.\n**\n**    * A write transaction is active.\n**    * If the connection is open in rollback-mode, a RESERVED or greater \n**      lock is held on the database file.\n**    * If the connection is open in WAL-mode, a WAL write transaction\n**      is open (i.e. sqlite3WalBeginWriteTransaction() has been successfully\n**      called).\n**    * The dbSize, dbOrigSize and dbFileSize variables are all valid.\n**    * The contents of the pager cache have not been modified.\n**    * The journal file may or may not be open.\n**    * Nothing (not even the first header) has been written to the journal.\n**\n**  WRITER_CACHEMOD:\n**\n**    A pager moves from WRITER_LOCKED state to this state when a page is\n**    first modified by the upper layer. In rollback mode the journal file\n**    is opened (if it is not already open) and a header written to the\n**    start of it. The database file on disk has not been modified.\n**\n**    * A write transaction is active.\n**    * A RESERVED or greater lock is held on the database file.\n**    * The journal file is open and the first header has been written \n**      to it, but the header has not been synced to disk.\n**    * The contents of the page cache have been modified.\n**\n**  WRITER_DBMOD:\n**\n**    The pager transitions from WRITER_CACHEMOD into WRITER_DBMOD state\n**    when it modifies the contents of the database file. WAL connections\n**    never enter this state (since they do not modify the database file,\n**    just the log file).\n**\n**    * A write transaction is active.\n**    * An EXCLUSIVE or greater lock is held on the database file.\n**    * The journal file is open and the first header has been written \n**      and synced to disk.\n**    * The contents of the page cache have been modified (and possibly\n**      written to disk).\n**\n**  WRITER_FINISHED:\n**\n**    It is not possible for a WAL connection to enter this state.\n**\n**    A rollback-mode pager changes to WRITER_FINISHED state from WRITER_DBMOD\n**    state after the entire transaction has been successfully written into the\n**    database file. In this state the transaction may be committed simply\n**    by finalizing the journal file. Once in WRITER_FINISHED state, it is \n**    not possible to modify the database further. At this point, the upper \n**    layer must either commit or rollback the transaction.\n**\n**    * A write transaction is active.\n**    * An EXCLUSIVE or greater lock is held on the database file.\n**    * All writing and syncing of journal and database data has finished.\n**      If no error occurred, all that remains is to finalize the journal to\n**      commit the transaction. If an error did occur, the caller will need\n**      to rollback the transaction. \n**\n**  ERROR:\n**\n**    The ERROR state is entered when an IO or disk-full error (including\n**    SQLITE_IOERR_NOMEM) occurs at a point in the code that makes it \n**    difficult to be sure that the in-memory pager state (cache contents, \n**    db size etc.) are consistent with the contents of the file-system.\n**\n**    Temporary pager files may enter the ERROR state, but in-memory pagers\n**    cannot.\n**\n**    For example, if an IO error occurs while performing a rollback, \n**    the contents of the page-cache may be left in an inconsistent state.\n**    At this point it would be dangerous to change back to READER state\n**    (as usually happens after a rollback). Any subsequent readers might\n**    report database corruption (due to the inconsistent cache), and if\n**    they upgrade to writers, they may inadvertently corrupt the database\n**    file. To avoid this hazard, the pager switches into the ERROR state\n**    instead of READER following such an error.\n**\n**    Once it has entered the ERROR state, any attempt to use the pager\n**    to read or write data returns an error. Eventually, once all \n**    outstanding transactions have been abandoned, the pager is able to\n**    transition back to OPEN state, discarding the contents of the \n**    page-cache and any other in-memory state at the same time. Everything\n**    is reloaded from disk (and, if necessary, hot-journal rollback peformed)\n**    when a read-transaction is next opened on the pager (transitioning\n**    the pager into READER state). At that point the system has recovered \n**    from the error.\n**\n**    Specifically, the pager jumps into the ERROR state if:\n**\n**      1. An error occurs while attempting a rollback. This happens in\n**         function sqlite3PagerRollback().\n**\n**      2. An error occurs while attempting to finalize a journal file\n**         following a commit in function sqlite3PagerCommitPhaseTwo().\n**\n**      3. An error occurs while attempting to write to the journal or\n**         database file in function pagerStress() in order to free up\n**         memory.\n**\n**    In other cases, the error is returned to the b-tree layer. The b-tree\n**    layer then attempts a rollback operation. If the error condition \n**    persists, the pager enters the ERROR state via condition (1) above.\n**\n**    Condition (3) is necessary because it can be triggered by a read-only\n**    statement executed within a transaction. In this case, if the error\n**    code were simply returned to the user, the b-tree layer would not\n**    automatically attempt a rollback, as it assumes that an error in a\n**    read-only statement cannot leave the pager in an internally inconsistent \n**    state.\n**\n**    * The Pager.errCode variable is set to something other than SQLITE_OK.\n**    * There are one or more outstanding references to pages (after the\n**      last reference is dropped the pager should move back to OPEN state).\n**    * The pager is not an in-memory pager.\n**    \n**\n** Notes:\n**\n**   * A pager is never in WRITER_DBMOD or WRITER_FINISHED state if the\n**     connection is open in WAL mode. A WAL connection is always in one\n**     of the first four states.\n**\n**   * Normally, a connection open in exclusive mode is never in PAGER_OPEN\n**     state. There are two exceptions: immediately after exclusive-mode has\n**     been turned on (and before any read or write transactions are \n**     executed), and when the pager is leaving the \"error state\".\n**\n**   * See also: assert_pager_state().\n*/\n#define PAGER_OPEN                  0\n#define PAGER_READER                1\n#define PAGER_WRITER_LOCKED         2\n#define PAGER_WRITER_CACHEMOD       3\n#define PAGER_WRITER_DBMOD          4\n#define PAGER_WRITER_FINISHED       5\n#define PAGER_ERROR                 6\n\n/*\n** The Pager.eLock variable is almost always set to one of the \n** following locking-states, according to the lock currently held on\n** the database file: NO_LOCK, SHARED_LOCK, RESERVED_LOCK or EXCLUSIVE_LOCK.\n** This variable is kept up to date as locks are taken and released by\n** the pagerLockDb() and pagerUnlockDb() wrappers.\n**\n** If the VFS xLock() or xUnlock() returns an error other than SQLITE_BUSY\n** (i.e. one of the SQLITE_IOERR subtypes), it is not clear whether or not\n** the operation was successful. In these circumstances pagerLockDb() and\n** pagerUnlockDb() take a conservative approach - eLock is always updated\n** when unlocking the file, and only updated when locking the file if the\n** VFS call is successful. This way, the Pager.eLock variable may be set\n** to a less exclusive (lower) value than the lock that is actually held\n** at the system level, but it is never set to a more exclusive value.\n**\n** This is usually safe. If an xUnlock fails or appears to fail, there may \n** be a few redundant xLock() calls or a lock may be held for longer than\n** required, but nothing really goes wrong.\n**\n** The exception is when the database file is unlocked as the pager moves\n** from ERROR to OPEN state. At this point there may be a hot-journal file \n** in the file-system that needs to be rolled back (as part of an OPEN->SHARED\n** transition, by the same pager or any other). If the call to xUnlock()\n** fails at this point and the pager is left holding an EXCLUSIVE lock, this\n** can confuse the call to xCheckReservedLock() call made later as part\n** of hot-journal detection.\n**\n** xCheckReservedLock() is defined as returning true \"if there is a RESERVED \n** lock held by this process or any others\". So xCheckReservedLock may \n** return true because the caller itself is holding an EXCLUSIVE lock (but\n** doesn't know it because of a previous error in xUnlock). If this happens\n** a hot-journal may be mistaken for a journal being created by an active\n** transaction in another process, causing SQLite to read from the database\n** without rolling it back.\n**\n** To work around this, if a call to xUnlock() fails when unlocking the\n** database in the ERROR state, Pager.eLock is set to UNKNOWN_LOCK. It\n** is only changed back to a real locking state after a successful call\n** to xLock(EXCLUSIVE). Also, the code to do the OPEN->SHARED state transition\n** omits the check for a hot-journal if Pager.eLock is set to UNKNOWN_LOCK \n** lock. Instead, it assumes a hot-journal exists and obtains an EXCLUSIVE\n** lock on the database file before attempting to roll it back. See function\n** PagerSharedLock() for more detail.\n**\n** Pager.eLock may only be set to UNKNOWN_LOCK when the pager is in \n** PAGER_OPEN state.\n*/\n#define UNKNOWN_LOCK                (EXCLUSIVE_LOCK+1)\n\n/*\n** A macro used for invoking the codec if there is one\n*/\n#ifdef SQLITE_HAS_CODEC\n# define CODEC1(P,D,N,X,E) \\\n    if( P->xCodec && P->xCodec(P->pCodec,D,N,X)==0 ){ E; }\n# define CODEC2(P,D,N,X,E,O) \\\n    if( P->xCodec==0 ){ O=(char*)D; }else \\\n    if( (O=(char*)(P->xCodec(P->pCodec,D,N,X)))==0 ){ E; }\n#else\n# define CODEC1(P,D,N,X,E)   /* NO-OP */\n# define CODEC2(P,D,N,X,E,O) O=(char*)D\n#endif\n\n/*\n** The maximum allowed sector size. 64KiB. If the xSectorsize() method \n** returns a value larger than this, then MAX_SECTOR_SIZE is used instead.\n** This could conceivably cause corruption following a power failure on\n** such a system. This is currently an undocumented limit.\n*/\n#define MAX_SECTOR_SIZE 0x10000\n\n\n/*\n** An instance of the following structure is allocated for each active\n** savepoint and statement transaction in the system. All such structures\n** are stored in the Pager.aSavepoint[] array, which is allocated and\n** resized using sqlite3Realloc().\n**\n** When a savepoint is created, the PagerSavepoint.iHdrOffset field is\n** set to 0. If a journal-header is written into the main journal while\n** the savepoint is active, then iHdrOffset is set to the byte offset \n** immediately following the last journal record written into the main\n** journal before the journal-header. This is required during savepoint\n** rollback (see pagerPlaybackSavepoint()).\n*/\ntypedef struct PagerSavepoint PagerSavepoint;\nstruct PagerSavepoint {\n  i64 iOffset;                 /* Starting offset in main journal */\n  i64 iHdrOffset;              /* See above */\n  Bitvec *pInSavepoint;        /* Set of pages in this savepoint */\n  Pgno nOrig;                  /* Original number of pages in file */\n  Pgno iSubRec;                /* Index of first record in sub-journal */\n#ifndef SQLITE_OMIT_WAL\n  u32 aWalData[WAL_SAVEPOINT_NDATA];        /* WAL savepoint context */\n#endif\n};\n\n/*\n** Bits of the Pager.doNotSpill flag.  See further description below.\n*/\n#define SPILLFLAG_OFF         0x01 /* Never spill cache.  Set via pragma */\n#define SPILLFLAG_ROLLBACK    0x02 /* Current rolling back, so do not spill */\n#define SPILLFLAG_NOSYNC      0x04 /* Spill is ok, but do not sync */\n\n/*\n** An open page cache is an instance of struct Pager. A description of\n** some of the more important member variables follows:\n**\n** eState\n**\n**   The current 'state' of the pager object. See the comment and state\n**   diagram above for a description of the pager state.\n**\n** eLock\n**\n**   For a real on-disk database, the current lock held on the database file -\n**   NO_LOCK, SHARED_LOCK, RESERVED_LOCK or EXCLUSIVE_LOCK.\n**\n**   For a temporary or in-memory database (neither of which require any\n**   locks), this variable is always set to EXCLUSIVE_LOCK. Since such\n**   databases always have Pager.exclusiveMode==1, this tricks the pager\n**   logic into thinking that it already has all the locks it will ever\n**   need (and no reason to release them).\n**\n**   In some (obscure) circumstances, this variable may also be set to\n**   UNKNOWN_LOCK. See the comment above the #define of UNKNOWN_LOCK for\n**   details.\n**\n** changeCountDone\n**\n**   This boolean variable is used to make sure that the change-counter \n**   (the 4-byte header field at byte offset 24 of the database file) is \n**   not updated more often than necessary. \n**\n**   It is set to true when the change-counter field is updated, which \n**   can only happen if an exclusive lock is held on the database file.\n**   It is cleared (set to false) whenever an exclusive lock is \n**   relinquished on the database file. Each time a transaction is committed,\n**   The changeCountDone flag is inspected. If it is true, the work of\n**   updating the change-counter is omitted for the current transaction.\n**\n**   This mechanism means that when running in exclusive mode, a connection \n**   need only update the change-counter once, for the first transaction\n**   committed.\n**\n** setMaster\n**\n**   When PagerCommitPhaseOne() is called to commit a transaction, it may\n**   (or may not) specify a master-journal name to be written into the \n**   journal file before it is synced to disk.\n**\n**   Whether or not a journal file contains a master-journal pointer affects \n**   the way in which the journal file is finalized after the transaction is \n**   committed or rolled back when running in \"journal_mode=PERSIST\" mode.\n**   If a journal file does not contain a master-journal pointer, it is\n**   finalized by overwriting the first journal header with zeroes. If\n**   it does contain a master-journal pointer the journal file is finalized \n**   by truncating it to zero bytes, just as if the connection were \n**   running in \"journal_mode=truncate\" mode.\n**\n**   Journal files that contain master journal pointers cannot be finalized\n**   simply by overwriting the first journal-header with zeroes, as the\n**   master journal pointer could interfere with hot-journal rollback of any\n**   subsequently interrupted transaction that reuses the journal file.\n**\n**   The flag is cleared as soon as the journal file is finalized (either\n**   by PagerCommitPhaseTwo or PagerRollback). If an IO error prevents the\n**   journal file from being successfully finalized, the setMaster flag\n**   is cleared anyway (and the pager will move to ERROR state).\n**\n** doNotSpill\n**\n**   This variables control the behavior of cache-spills  (calls made by\n**   the pcache module to the pagerStress() routine to write cached data\n**   to the file-system in order to free up memory).\n**\n**   When bits SPILLFLAG_OFF or SPILLFLAG_ROLLBACK of doNotSpill are set,\n**   writing to the database from pagerStress() is disabled altogether.\n**   The SPILLFLAG_ROLLBACK case is done in a very obscure case that\n**   comes up during savepoint rollback that requires the pcache module\n**   to allocate a new page to prevent the journal file from being written\n**   while it is being traversed by code in pager_playback().  The SPILLFLAG_OFF\n**   case is a user preference.\n** \n**   If the SPILLFLAG_NOSYNC bit is set, writing to the database from\n**   pagerStress() is permitted, but syncing the journal file is not.\n**   This flag is set by sqlite3PagerWrite() when the file-system sector-size\n**   is larger than the database page-size in order to prevent a journal sync\n**   from happening in between the journalling of two pages on the same sector. \n**\n** subjInMemory\n**\n**   This is a boolean variable. If true, then any required sub-journal\n**   is opened as an in-memory journal file. If false, then in-memory\n**   sub-journals are only used for in-memory pager files.\n**\n**   This variable is updated by the upper layer each time a new \n**   write-transaction is opened.\n**\n** dbSize, dbOrigSize, dbFileSize\n**\n**   Variable dbSize is set to the number of pages in the database file.\n**   It is valid in PAGER_READER and higher states (all states except for\n**   OPEN and ERROR). \n**\n**   dbSize is set based on the size of the database file, which may be \n**   larger than the size of the database (the value stored at offset\n**   28 of the database header by the btree). If the size of the file\n**   is not an integer multiple of the page-size, the value stored in\n**   dbSize is rounded down (i.e. a 5KB file with 2K page-size has dbSize==2).\n**   Except, any file that is greater than 0 bytes in size is considered\n**   to have at least one page. (i.e. a 1KB file with 2K page-size leads\n**   to dbSize==1).\n**\n**   During a write-transaction, if pages with page-numbers greater than\n**   dbSize are modified in the cache, dbSize is updated accordingly.\n**   Similarly, if the database is truncated using PagerTruncateImage(), \n**   dbSize is updated.\n**\n**   Variables dbOrigSize and dbFileSize are valid in states \n**   PAGER_WRITER_LOCKED and higher. dbOrigSize is a copy of the dbSize\n**   variable at the start of the transaction. It is used during rollback,\n**   and to determine whether or not pages need to be journalled before\n**   being modified.\n**\n**   Throughout a write-transaction, dbFileSize contains the size of\n**   the file on disk in pages. It is set to a copy of dbSize when the\n**   write-transaction is first opened, and updated when VFS calls are made\n**   to write or truncate the database file on disk. \n**\n**   The only reason the dbFileSize variable is required is to suppress \n**   unnecessary calls to xTruncate() after committing a transaction. If, \n**   when a transaction is committed, the dbFileSize variable indicates \n**   that the database file is larger than the database image (Pager.dbSize), \n**   pager_truncate() is called. The pager_truncate() call uses xFilesize()\n**   to measure the database file on disk, and then truncates it if required.\n**   dbFileSize is not used when rolling back a transaction. In this case\n**   pager_truncate() is called unconditionally (which means there may be\n**   a call to xFilesize() that is not strictly required). In either case,\n**   pager_truncate() may cause the file to become smaller or larger.\n**\n** dbHintSize\n**\n**   The dbHintSize variable is used to limit the number of calls made to\n**   the VFS xFileControl(FCNTL_SIZE_HINT) method. \n**\n**   dbHintSize is set to a copy of the dbSize variable when a\n**   write-transaction is opened (at the same time as dbFileSize and\n**   dbOrigSize). If the xFileControl(FCNTL_SIZE_HINT) method is called,\n**   dbHintSize is increased to the number of pages that correspond to the\n**   size-hint passed to the method call. See pager_write_pagelist() for \n**   details.\n**\n** errCode\n**\n**   The Pager.errCode variable is only ever used in PAGER_ERROR state. It\n**   is set to zero in all other states. In PAGER_ERROR state, Pager.errCode \n**   is always set to SQLITE_FULL, SQLITE_IOERR or one of the SQLITE_IOERR_XXX \n**   sub-codes.\n**\n** syncFlags, walSyncFlags\n**\n**   syncFlags is either SQLITE_SYNC_NORMAL (0x02) or SQLITE_SYNC_FULL (0x03).\n**   syncFlags is used for rollback mode.  walSyncFlags is used for WAL mode\n**   and contains the flags used to sync the checkpoint operations in the\n**   lower two bits, and sync flags used for transaction commits in the WAL\n**   file in bits 0x04 and 0x08.  In other words, to get the correct sync flags\n**   for checkpoint operations, use (walSyncFlags&0x03) and to get the correct\n**   sync flags for transaction commit, use ((walSyncFlags>>2)&0x03).  Note\n**   that with synchronous=NORMAL in WAL mode, transaction commit is not synced\n**   meaning that the 0x04 and 0x08 bits are both zero.\n*/\nstruct Pager {\n  sqlite3_vfs *pVfs;          /* OS functions to use for IO */\n  u8 exclusiveMode;           /* Boolean. True if locking_mode==EXCLUSIVE */\n  u8 journalMode;             /* One of the PAGER_JOURNALMODE_* values */\n  u8 useJournal;              /* Use a rollback journal on this file */\n  u8 noSync;                  /* Do not sync the journal if true */\n  u8 fullSync;                /* Do extra syncs of the journal for robustness */\n  u8 extraSync;               /* sync directory after journal delete */\n  u8 syncFlags;               /* SYNC_NORMAL or SYNC_FULL otherwise */\n  u8 walSyncFlags;            /* See description above */\n  u8 tempFile;                /* zFilename is a temporary or immutable file */\n  u8 noLock;                  /* Do not lock (except in WAL mode) */\n  u8 readOnly;                /* True for a read-only database */\n  u8 memDb;                   /* True to inhibit all file I/O */\n\n  /**************************************************************************\n  ** The following block contains those class members that change during\n  ** routine operation.  Class members not in this block are either fixed\n  ** when the pager is first created or else only change when there is a\n  ** significant mode change (such as changing the page_size, locking_mode,\n  ** or the journal_mode).  From another view, these class members describe\n  ** the \"state\" of the pager, while other class members describe the\n  ** \"configuration\" of the pager.\n  */\n  u8 eState;                  /* Pager state (OPEN, READER, WRITER_LOCKED..) */\n  u8 eLock;                   /* Current lock held on database file */\n  u8 changeCountDone;         /* Set after incrementing the change-counter */\n  u8 setMaster;               /* True if a m-j name has been written to jrnl */\n  u8 doNotSpill;              /* Do not spill the cache when non-zero */\n  u8 subjInMemory;            /* True to use in-memory sub-journals */\n  u8 bUseFetch;               /* True to use xFetch() */\n  u8 hasHeldSharedLock;       /* True if a shared lock has ever been held */\n  Pgno dbSize;                /* Number of pages in the database */\n  Pgno dbOrigSize;            /* dbSize before the current transaction */\n  Pgno dbFileSize;            /* Number of pages in the database file */\n  Pgno dbHintSize;            /* Value passed to FCNTL_SIZE_HINT call */\n  int errCode;                /* One of several kinds of errors */\n  int nRec;                   /* Pages journalled since last j-header written */\n  u32 cksumInit;              /* Quasi-random value added to every checksum */\n  u32 nSubRec;                /* Number of records written to sub-journal */\n  Bitvec *pInJournal;         /* One bit for each page in the database file */\n  sqlite3_file *fd;           /* File descriptor for database */\n  sqlite3_file *jfd;          /* File descriptor for main journal */\n  sqlite3_file *sjfd;         /* File descriptor for sub-journal */\n  i64 journalOff;             /* Current write offset in the journal file */\n  i64 journalHdr;             /* Byte offset to previous journal header */\n  sqlite3_backup *pBackup;    /* Pointer to list of ongoing backup processes */\n  PagerSavepoint *aSavepoint; /* Array of active savepoints */\n  int nSavepoint;             /* Number of elements in aSavepoint[] */\n  u32 iDataVersion;           /* Changes whenever database content changes */\n  char dbFileVers[16];        /* Changes whenever database file changes */\n\n  int nMmapOut;               /* Number of mmap pages currently outstanding */\n  sqlite3_int64 szMmap;       /* Desired maximum mmap size */\n  PgHdr *pMmapFreelist;       /* List of free mmap page headers (pDirty) */\n  /*\n  ** End of the routinely-changing class members\n  ***************************************************************************/\n\n  u16 nExtra;                 /* Add this many bytes to each in-memory page */\n  i16 nReserve;               /* Number of unused bytes at end of each page */\n  u32 vfsFlags;               /* Flags for sqlite3_vfs.xOpen() */\n  u32 sectorSize;             /* Assumed sector size during rollback */\n  int pageSize;               /* Number of bytes in a page */\n  Pgno mxPgno;                /* Maximum allowed size of the database */\n  i64 journalSizeLimit;       /* Size limit for persistent journal files */\n  char *zFilename;            /* Name of the database file */\n  char *zJournal;             /* Name of the journal file */\n  int (*xBusyHandler)(void*); /* Function to call when busy */\n  void *pBusyHandlerArg;      /* Context argument for xBusyHandler */\n  int aStat[4];               /* Total cache hits, misses, writes, spills */\n#ifdef SQLITE_TEST\n  int nRead;                  /* Database pages read */\n#endif\n  void (*xReiniter)(DbPage*); /* Call this routine when reloading pages */\n  int (*xGet)(Pager*,Pgno,DbPage**,int); /* Routine to fetch a patch */\n#ifdef SQLITE_HAS_CODEC\n  void *(*xCodec)(void*,void*,Pgno,int); /* Routine for en/decoding data */\n  void (*xCodecSizeChng)(void*,int,int); /* Notify of page size changes */\n  void (*xCodecFree)(void*);             /* Destructor for the codec */\n  void *pCodec;               /* First argument to xCodec... methods */\n#endif\n  char *pTmpSpace;            /* Pager.pageSize bytes of space for tmp use */\n  PCache *pPCache;            /* Pointer to page cache object */\n#ifndef SQLITE_OMIT_WAL\n  Wal *pWal;                  /* Write-ahead log used by \"journal_mode=wal\" */\n  char *zWal;                 /* File name for write-ahead log */\n#endif\n};\n\n/*\n** Indexes for use with Pager.aStat[]. The Pager.aStat[] array contains\n** the values accessed by passing SQLITE_DBSTATUS_CACHE_HIT, CACHE_MISS \n** or CACHE_WRITE to sqlite3_db_status().\n*/\n#define PAGER_STAT_HIT   0\n#define PAGER_STAT_MISS  1\n#define PAGER_STAT_WRITE 2\n#define PAGER_STAT_SPILL 3\n\n/*\n** The following global variables hold counters used for\n** testing purposes only.  These variables do not exist in\n** a non-testing build.  These variables are not thread-safe.\n*/\n#ifdef SQLITE_TEST\nSQLITE_API int sqlite3_pager_readdb_count = 0;    /* Number of full pages read from DB */\nSQLITE_API int sqlite3_pager_writedb_count = 0;   /* Number of full pages written to DB */\nSQLITE_API int sqlite3_pager_writej_count = 0;    /* Number of pages written to journal */\n# define PAGER_INCR(v)  v++\n#else\n# define PAGER_INCR(v)\n#endif\n\n\n\n/*\n** Journal files begin with the following magic string.  The data\n** was obtained from /dev/random.  It is used only as a sanity check.\n**\n** Since version 2.8.0, the journal format contains additional sanity\n** checking information.  If the power fails while the journal is being\n** written, semi-random garbage data might appear in the journal\n** file after power is restored.  If an attempt is then made\n** to roll the journal back, the database could be corrupted.  The additional\n** sanity checking data is an attempt to discover the garbage in the\n** journal and ignore it.\n**\n** The sanity checking information for the new journal format consists\n** of a 32-bit checksum on each page of data.  The checksum covers both\n** the page number and the pPager->pageSize bytes of data for the page.\n** This cksum is initialized to a 32-bit random value that appears in the\n** journal file right after the header.  The random initializer is important,\n** because garbage data that appears at the end of a journal is likely\n** data that was once in other files that have now been deleted.  If the\n** garbage data came from an obsolete journal file, the checksums might\n** be correct.  But by initializing the checksum to random value which\n** is different for every journal, we minimize that risk.\n*/\nstatic const unsigned char aJournalMagic[] = {\n  0xd9, 0xd5, 0x05, 0xf9, 0x20, 0xa1, 0x63, 0xd7,\n};\n\n/*\n** The size of the of each page record in the journal is given by\n** the following macro.\n*/\n#define JOURNAL_PG_SZ(pPager)  ((pPager->pageSize) + 8)\n\n/*\n** The journal header size for this pager. This is usually the same \n** size as a single disk sector. See also setSectorSize().\n*/\n#define JOURNAL_HDR_SZ(pPager) (pPager->sectorSize)\n\n/*\n** The macro MEMDB is true if we are dealing with an in-memory database.\n** We do this as a macro so that if the SQLITE_OMIT_MEMORYDB macro is set,\n** the value of MEMDB will be a constant and the compiler will optimize\n** out code that would never execute.\n*/\n#ifdef SQLITE_OMIT_MEMORYDB\n# define MEMDB 0\n#else\n# define MEMDB pPager->memDb\n#endif\n\n/*\n** The macro USEFETCH is true if we are allowed to use the xFetch and xUnfetch\n** interfaces to access the database using memory-mapped I/O.\n*/\n#if SQLITE_MAX_MMAP_SIZE>0\n# define USEFETCH(x) ((x)->bUseFetch)\n#else\n# define USEFETCH(x) 0\n#endif\n\n/*\n** The maximum legal page number is (2^31 - 1).\n*/\n#define PAGER_MAX_PGNO 2147483647\n\n/*\n** The argument to this macro is a file descriptor (type sqlite3_file*).\n** Return 0 if it is not open, or non-zero (but not 1) if it is.\n**\n** This is so that expressions can be written as:\n**\n**   if( isOpen(pPager->jfd) ){ ...\n**\n** instead of\n**\n**   if( pPager->jfd->pMethods ){ ...\n*/\n#define isOpen(pFd) ((pFd)->pMethods!=0)\n\n#ifdef SQLITE_DIRECT_OVERFLOW_READ\n/*\n** Return true if page pgno can be read directly from the database file\n** by the b-tree layer. This is the case if:\n**\n**   * the database file is open,\n**   * there are no dirty pages in the cache, and\n**   * the desired page is not currently in the wal file.\n*/\nSQLITE_PRIVATE int sqlite3PagerDirectReadOk(Pager *pPager, Pgno pgno){\n  if( pPager->fd->pMethods==0 ) return 0;\n  if( sqlite3PCacheIsDirty(pPager->pPCache) ) return 0;\n#ifndef SQLITE_OMIT_WAL\n  if( pPager->pWal ){\n    u32 iRead = 0;\n    int rc;\n    rc = sqlite3WalFindFrame(pPager->pWal, pgno, &iRead);\n    return (rc==SQLITE_OK && iRead==0);\n  }\n#endif\n  return 1;\n}\n#endif\n\n#ifndef SQLITE_OMIT_WAL\n# define pagerUseWal(x) ((x)->pWal!=0)\n#else\n# define pagerUseWal(x) 0\n# define pagerRollbackWal(x) 0\n# define pagerWalFrames(v,w,x,y) 0\n# define pagerOpenWalIfPresent(z) SQLITE_OK\n# define pagerBeginReadTransaction(z) SQLITE_OK\n#endif\n\n#ifndef NDEBUG \n/*\n** Usage:\n**\n**   assert( assert_pager_state(pPager) );\n**\n** This function runs many asserts to try to find inconsistencies in\n** the internal state of the Pager object.\n*/\nstatic int assert_pager_state(Pager *p){\n  Pager *pPager = p;\n\n  /* State must be valid. */\n  assert( p->eState==PAGER_OPEN\n       || p->eState==PAGER_READER\n       || p->eState==PAGER_WRITER_LOCKED\n       || p->eState==PAGER_WRITER_CACHEMOD\n       || p->eState==PAGER_WRITER_DBMOD\n       || p->eState==PAGER_WRITER_FINISHED\n       || p->eState==PAGER_ERROR\n  );\n\n  /* Regardless of the current state, a temp-file connection always behaves\n  ** as if it has an exclusive lock on the database file. It never updates\n  ** the change-counter field, so the changeCountDone flag is always set.\n  */\n  assert( p->tempFile==0 || p->eLock==EXCLUSIVE_LOCK );\n  assert( p->tempFile==0 || pPager->changeCountDone );\n\n  /* If the useJournal flag is clear, the journal-mode must be \"OFF\". \n  ** And if the journal-mode is \"OFF\", the journal file must not be open.\n  */\n  assert( p->journalMode==PAGER_JOURNALMODE_OFF || p->useJournal );\n  assert( p->journalMode!=PAGER_JOURNALMODE_OFF || !isOpen(p->jfd) );\n\n  /* Check that MEMDB implies noSync. And an in-memory journal. Since \n  ** this means an in-memory pager performs no IO at all, it cannot encounter \n  ** either SQLITE_IOERR or SQLITE_FULL during rollback or while finalizing \n  ** a journal file. (although the in-memory journal implementation may \n  ** return SQLITE_IOERR_NOMEM while the journal file is being written). It \n  ** is therefore not possible for an in-memory pager to enter the ERROR \n  ** state.\n  */\n  if( MEMDB ){\n    assert( !isOpen(p->fd) );\n    assert( p->noSync );\n    assert( p->journalMode==PAGER_JOURNALMODE_OFF \n         || p->journalMode==PAGER_JOURNALMODE_MEMORY \n    );\n    assert( p->eState!=PAGER_ERROR && p->eState!=PAGER_OPEN );\n    assert( pagerUseWal(p)==0 );\n  }\n\n  /* If changeCountDone is set, a RESERVED lock or greater must be held\n  ** on the file.\n  */\n  assert( pPager->changeCountDone==0 || pPager->eLock>=RESERVED_LOCK );\n  assert( p->eLock!=PENDING_LOCK );\n\n  switch( p->eState ){\n    case PAGER_OPEN:\n      assert( !MEMDB );\n      assert( pPager->errCode==SQLITE_OK );\n      assert( sqlite3PcacheRefCount(pPager->pPCache)==0 || pPager->tempFile );\n      break;\n\n    case PAGER_READER:\n      assert( pPager->errCode==SQLITE_OK );\n      assert( p->eLock!=UNKNOWN_LOCK );\n      assert( p->eLock>=SHARED_LOCK );\n      break;\n\n    case PAGER_WRITER_LOCKED:\n      assert( p->eLock!=UNKNOWN_LOCK );\n      assert( pPager->errCode==SQLITE_OK );\n      if( !pagerUseWal(pPager) ){\n        assert( p->eLock>=RESERVED_LOCK );\n      }\n      assert( pPager->dbSize==pPager->dbOrigSize );\n      assert( pPager->dbOrigSize==pPager->dbFileSize );\n      assert( pPager->dbOrigSize==pPager->dbHintSize );\n      assert( pPager->setMaster==0 );\n      break;\n\n    case PAGER_WRITER_CACHEMOD:\n      assert( p->eLock!=UNKNOWN_LOCK );\n      assert( pPager->errCode==SQLITE_OK );\n      if( !pagerUseWal(pPager) ){\n        /* It is possible that if journal_mode=wal here that neither the\n        ** journal file nor the WAL file are open. This happens during\n        ** a rollback transaction that switches from journal_mode=off\n        ** to journal_mode=wal.\n        */\n        assert( p->eLock>=RESERVED_LOCK );\n        assert( isOpen(p->jfd) \n             || p->journalMode==PAGER_JOURNALMODE_OFF \n             || p->journalMode==PAGER_JOURNALMODE_WAL \n        );\n      }\n      assert( pPager->dbOrigSize==pPager->dbFileSize );\n      assert( pPager->dbOrigSize==pPager->dbHintSize );\n      break;\n\n    case PAGER_WRITER_DBMOD:\n      assert( p->eLock==EXCLUSIVE_LOCK );\n      assert( pPager->errCode==SQLITE_OK );\n      assert( !pagerUseWal(pPager) );\n      assert( p->eLock>=EXCLUSIVE_LOCK );\n      assert( isOpen(p->jfd) \n           || p->journalMode==PAGER_JOURNALMODE_OFF \n           || p->journalMode==PAGER_JOURNALMODE_WAL \n           || (sqlite3OsDeviceCharacteristics(p->fd)&SQLITE_IOCAP_BATCH_ATOMIC)\n      );\n      assert( pPager->dbOrigSize<=pPager->dbHintSize );\n      break;\n\n    case PAGER_WRITER_FINISHED:\n      assert( p->eLock==EXCLUSIVE_LOCK );\n      assert( pPager->errCode==SQLITE_OK );\n      assert( !pagerUseWal(pPager) );\n      assert( isOpen(p->jfd) \n           || p->journalMode==PAGER_JOURNALMODE_OFF \n           || p->journalMode==PAGER_JOURNALMODE_WAL \n           || (sqlite3OsDeviceCharacteristics(p->fd)&SQLITE_IOCAP_BATCH_ATOMIC)\n      );\n      break;\n\n    case PAGER_ERROR:\n      /* There must be at least one outstanding reference to the pager if\n      ** in ERROR state. Otherwise the pager should have already dropped\n      ** back to OPEN state.\n      */\n      assert( pPager->errCode!=SQLITE_OK );\n      assert( sqlite3PcacheRefCount(pPager->pPCache)>0 || pPager->tempFile );\n      break;\n  }\n\n  return 1;\n}\n#endif /* ifndef NDEBUG */\n\n#ifdef SQLITE_DEBUG \n/*\n** Return a pointer to a human readable string in a static buffer\n** containing the state of the Pager object passed as an argument. This\n** is intended to be used within debuggers. For example, as an alternative\n** to \"print *pPager\" in gdb:\n**\n** (gdb) printf \"%s\", print_pager_state(pPager)\n**\n** This routine has external linkage in order to suppress compiler warnings\n** about an unused function.  It is enclosed within SQLITE_DEBUG and so does\n** not appear in normal builds.\n*/\nchar *print_pager_state(Pager *p){\n  static char zRet[1024];\n\n  sqlite3_snprintf(1024, zRet,\n      \"Filename:      %s\\n\"\n      \"State:         %s errCode=%d\\n\"\n      \"Lock:          %s\\n\"\n      \"Locking mode:  locking_mode=%s\\n\"\n      \"Journal mode:  journal_mode=%s\\n\"\n      \"Backing store: tempFile=%d memDb=%d useJournal=%d\\n\"\n      \"Journal:       journalOff=%lld journalHdr=%lld\\n\"\n      \"Size:          dbsize=%d dbOrigSize=%d dbFileSize=%d\\n\"\n      , p->zFilename\n      , p->eState==PAGER_OPEN            ? \"OPEN\" :\n        p->eState==PAGER_READER          ? \"READER\" :\n        p->eState==PAGER_WRITER_LOCKED   ? \"WRITER_LOCKED\" :\n        p->eState==PAGER_WRITER_CACHEMOD ? \"WRITER_CACHEMOD\" :\n        p->eState==PAGER_WRITER_DBMOD    ? \"WRITER_DBMOD\" :\n        p->eState==PAGER_WRITER_FINISHED ? \"WRITER_FINISHED\" :\n        p->eState==PAGER_ERROR           ? \"ERROR\" : \"?error?\"\n      , (int)p->errCode\n      , p->eLock==NO_LOCK         ? \"NO_LOCK\" :\n        p->eLock==RESERVED_LOCK   ? \"RESERVED\" :\n        p->eLock==EXCLUSIVE_LOCK  ? \"EXCLUSIVE\" :\n        p->eLock==SHARED_LOCK     ? \"SHARED\" :\n        p->eLock==UNKNOWN_LOCK    ? \"UNKNOWN\" : \"?error?\"\n      , p->exclusiveMode ? \"exclusive\" : \"normal\"\n      , p->journalMode==PAGER_JOURNALMODE_MEMORY   ? \"memory\" :\n        p->journalMode==PAGER_JOURNALMODE_OFF      ? \"off\" :\n        p->journalMode==PAGER_JOURNALMODE_DELETE   ? \"delete\" :\n        p->journalMode==PAGER_JOURNALMODE_PERSIST  ? \"persist\" :\n        p->journalMode==PAGER_JOURNALMODE_TRUNCATE ? \"truncate\" :\n        p->journalMode==PAGER_JOURNALMODE_WAL      ? \"wal\" : \"?error?\"\n      , (int)p->tempFile, (int)p->memDb, (int)p->useJournal\n      , p->journalOff, p->journalHdr\n      , (int)p->dbSize, (int)p->dbOrigSize, (int)p->dbFileSize\n  );\n\n  return zRet;\n}\n#endif\n\n/* Forward references to the various page getters */\nstatic int getPageNormal(Pager*,Pgno,DbPage**,int);\nstatic int getPageError(Pager*,Pgno,DbPage**,int);\n#if SQLITE_MAX_MMAP_SIZE>0\nstatic int getPageMMap(Pager*,Pgno,DbPage**,int);\n#endif\n\n/*\n** Set the Pager.xGet method for the appropriate routine used to fetch\n** content from the pager.\n*/\nstatic void setGetterMethod(Pager *pPager){\n  if( pPager->errCode ){\n    pPager->xGet = getPageError;\n#if SQLITE_MAX_MMAP_SIZE>0\n  }else if( USEFETCH(pPager)\n#ifdef SQLITE_HAS_CODEC\n   && pPager->xCodec==0\n#endif\n  ){\n    pPager->xGet = getPageMMap;\n#endif /* SQLITE_MAX_MMAP_SIZE>0 */\n  }else{\n    pPager->xGet = getPageNormal;\n  }\n}\n\n/*\n** Return true if it is necessary to write page *pPg into the sub-journal.\n** A page needs to be written into the sub-journal if there exists one\n** or more open savepoints for which:\n**\n**   * The page-number is less than or equal to PagerSavepoint.nOrig, and\n**   * The bit corresponding to the page-number is not set in\n**     PagerSavepoint.pInSavepoint.\n*/\nstatic int subjRequiresPage(PgHdr *pPg){\n  Pager *pPager = pPg->pPager;\n  PagerSavepoint *p;\n  Pgno pgno = pPg->pgno;\n  int i;\n  for(i=0; i<pPager->nSavepoint; i++){\n    p = &pPager->aSavepoint[i];\n    if( p->nOrig>=pgno && 0==sqlite3BitvecTestNotNull(p->pInSavepoint, pgno) ){\n      return 1;\n    }\n  }\n  return 0;\n}\n\n#ifdef SQLITE_DEBUG\n/*\n** Return true if the page is already in the journal file.\n*/\nstatic int pageInJournal(Pager *pPager, PgHdr *pPg){\n  return sqlite3BitvecTest(pPager->pInJournal, pPg->pgno);\n}\n#endif\n\n/*\n** Read a 32-bit integer from the given file descriptor.  Store the integer\n** that is read in *pRes.  Return SQLITE_OK if everything worked, or an\n** error code is something goes wrong.\n**\n** All values are stored on disk as big-endian.\n*/\nstatic int read32bits(sqlite3_file *fd, i64 offset, u32 *pRes){\n  unsigned char ac[4];\n  int rc = sqlite3OsRead(fd, ac, sizeof(ac), offset);\n  if( rc==SQLITE_OK ){\n    *pRes = sqlite3Get4byte(ac);\n  }\n  return rc;\n}\n\n/*\n** Write a 32-bit integer into a string buffer in big-endian byte order.\n*/\n#define put32bits(A,B)  sqlite3Put4byte((u8*)A,B)\n\n\n/*\n** Write a 32-bit integer into the given file descriptor.  Return SQLITE_OK\n** on success or an error code is something goes wrong.\n*/\nstatic int write32bits(sqlite3_file *fd, i64 offset, u32 val){\n  char ac[4];\n  put32bits(ac, val);\n  return sqlite3OsWrite(fd, ac, 4, offset);\n}\n\n/*\n** Unlock the database file to level eLock, which must be either NO_LOCK\n** or SHARED_LOCK. Regardless of whether or not the call to xUnlock()\n** succeeds, set the Pager.eLock variable to match the (attempted) new lock.\n**\n** Except, if Pager.eLock is set to UNKNOWN_LOCK when this function is\n** called, do not modify it. See the comment above the #define of \n** UNKNOWN_LOCK for an explanation of this.\n*/\nstatic int pagerUnlockDb(Pager *pPager, int eLock){\n  int rc = SQLITE_OK;\n\n  assert( !pPager->exclusiveMode || pPager->eLock==eLock );\n  assert( eLock==NO_LOCK || eLock==SHARED_LOCK );\n  assert( eLock!=NO_LOCK || pagerUseWal(pPager)==0 );\n  if( isOpen(pPager->fd) ){\n    assert( pPager->eLock>=eLock );\n    rc = pPager->noLock ? SQLITE_OK : sqlite3OsUnlock(pPager->fd, eLock);\n    if( pPager->eLock!=UNKNOWN_LOCK ){\n      pPager->eLock = (u8)eLock;\n    }\n    IOTRACE((\"UNLOCK %p %d\\n\", pPager, eLock))\n  }\n  return rc;\n}\n\n/*\n** Lock the database file to level eLock, which must be either SHARED_LOCK,\n** RESERVED_LOCK or EXCLUSIVE_LOCK. If the caller is successful, set the\n** Pager.eLock variable to the new locking state. \n**\n** Except, if Pager.eLock is set to UNKNOWN_LOCK when this function is \n** called, do not modify it unless the new locking state is EXCLUSIVE_LOCK. \n** See the comment above the #define of UNKNOWN_LOCK for an explanation \n** of this.\n*/\nstatic int pagerLockDb(Pager *pPager, int eLock){\n  int rc = SQLITE_OK;\n\n  assert( eLock==SHARED_LOCK || eLock==RESERVED_LOCK || eLock==EXCLUSIVE_LOCK );\n  if( pPager->eLock<eLock || pPager->eLock==UNKNOWN_LOCK ){\n    rc = pPager->noLock ? SQLITE_OK : sqlite3OsLock(pPager->fd, eLock);\n    if( rc==SQLITE_OK && (pPager->eLock!=UNKNOWN_LOCK||eLock==EXCLUSIVE_LOCK) ){\n      pPager->eLock = (u8)eLock;\n      IOTRACE((\"LOCK %p %d\\n\", pPager, eLock))\n    }\n  }\n  return rc;\n}\n\n/*\n** This function determines whether or not the atomic-write or\n** atomic-batch-write optimizations can be used with this pager. The\n** atomic-write optimization can be used if:\n**\n**  (a) the value returned by OsDeviceCharacteristics() indicates that\n**      a database page may be written atomically, and\n**  (b) the value returned by OsSectorSize() is less than or equal\n**      to the page size.\n**\n** If it can be used, then the value returned is the size of the journal \n** file when it contains rollback data for exactly one page.\n**\n** The atomic-batch-write optimization can be used if OsDeviceCharacteristics()\n** returns a value with the SQLITE_IOCAP_BATCH_ATOMIC bit set. -1 is\n** returned in this case.\n**\n** If neither optimization can be used, 0 is returned.\n*/\nstatic int jrnlBufferSize(Pager *pPager){\n  assert( !MEMDB );\n\n#if defined(SQLITE_ENABLE_ATOMIC_WRITE) \\\n || defined(SQLITE_ENABLE_BATCH_ATOMIC_WRITE)\n  int dc;                           /* Device characteristics */\n\n  assert( isOpen(pPager->fd) );\n  dc = sqlite3OsDeviceCharacteristics(pPager->fd);\n#else\n  UNUSED_PARAMETER(pPager);\n#endif\n\n#ifdef SQLITE_ENABLE_BATCH_ATOMIC_WRITE\n  if( pPager->dbSize>0 && (dc&SQLITE_IOCAP_BATCH_ATOMIC) ){\n    return -1;\n  }\n#endif\n\n#ifdef SQLITE_ENABLE_ATOMIC_WRITE\n  {\n    int nSector = pPager->sectorSize;\n    int szPage = pPager->pageSize;\n\n    assert(SQLITE_IOCAP_ATOMIC512==(512>>8));\n    assert(SQLITE_IOCAP_ATOMIC64K==(65536>>8));\n    if( 0==(dc&(SQLITE_IOCAP_ATOMIC|(szPage>>8)) || nSector>szPage) ){\n      return 0;\n    }\n  }\n\n  return JOURNAL_HDR_SZ(pPager) + JOURNAL_PG_SZ(pPager);\n#endif\n\n  return 0;\n}\n\n/*\n** If SQLITE_CHECK_PAGES is defined then we do some sanity checking\n** on the cache using a hash function.  This is used for testing\n** and debugging only.\n*/\n#ifdef SQLITE_CHECK_PAGES\n/*\n** Return a 32-bit hash of the page data for pPage.\n*/\nstatic u32 pager_datahash(int nByte, unsigned char *pData){\n  u32 hash = 0;\n  int i;\n  for(i=0; i<nByte; i++){\n    hash = (hash*1039) + pData[i];\n  }\n  return hash;\n}\nstatic u32 pager_pagehash(PgHdr *pPage){\n  return pager_datahash(pPage->pPager->pageSize, (unsigned char *)pPage->pData);\n}\nstatic void pager_set_pagehash(PgHdr *pPage){\n  pPage->pageHash = pager_pagehash(pPage);\n}\n\n/*\n** The CHECK_PAGE macro takes a PgHdr* as an argument. If SQLITE_CHECK_PAGES\n** is defined, and NDEBUG is not defined, an assert() statement checks\n** that the page is either dirty or still matches the calculated page-hash.\n*/\n#define CHECK_PAGE(x) checkPage(x)\nstatic void checkPage(PgHdr *pPg){\n  Pager *pPager = pPg->pPager;\n  assert( pPager->eState!=PAGER_ERROR );\n  assert( (pPg->flags&PGHDR_DIRTY) || pPg->pageHash==pager_pagehash(pPg) );\n}\n\n#else\n#define pager_datahash(X,Y)  0\n#define pager_pagehash(X)  0\n#define pager_set_pagehash(X)\n#define CHECK_PAGE(x)\n#endif  /* SQLITE_CHECK_PAGES */\n\n/*\n** When this is called the journal file for pager pPager must be open.\n** This function attempts to read a master journal file name from the \n** end of the file and, if successful, copies it into memory supplied \n** by the caller. See comments above writeMasterJournal() for the format\n** used to store a master journal file name at the end of a journal file.\n**\n** zMaster must point to a buffer of at least nMaster bytes allocated by\n** the caller. This should be sqlite3_vfs.mxPathname+1 (to ensure there is\n** enough space to write the master journal name). If the master journal\n** name in the journal is longer than nMaster bytes (including a\n** nul-terminator), then this is handled as if no master journal name\n** were present in the journal.\n**\n** If a master journal file name is present at the end of the journal\n** file, then it is copied into the buffer pointed to by zMaster. A\n** nul-terminator byte is appended to the buffer following the master\n** journal file name.\n**\n** If it is determined that no master journal file name is present \n** zMaster[0] is set to 0 and SQLITE_OK returned.\n**\n** If an error occurs while reading from the journal file, an SQLite\n** error code is returned.\n*/\nstatic int readMasterJournal(sqlite3_file *pJrnl, char *zMaster, u32 nMaster){\n  int rc;                    /* Return code */\n  u32 len;                   /* Length in bytes of master journal name */\n  i64 szJ;                   /* Total size in bytes of journal file pJrnl */\n  u32 cksum;                 /* MJ checksum value read from journal */\n  u32 u;                     /* Unsigned loop counter */\n  unsigned char aMagic[8];   /* A buffer to hold the magic header */\n  zMaster[0] = '\\0';\n\n  if( SQLITE_OK!=(rc = sqlite3OsFileSize(pJrnl, &szJ))\n   || szJ<16\n   || SQLITE_OK!=(rc = read32bits(pJrnl, szJ-16, &len))\n   || len>=nMaster \n   || len>szJ-16\n   || len==0 \n   || SQLITE_OK!=(rc = read32bits(pJrnl, szJ-12, &cksum))\n   || SQLITE_OK!=(rc = sqlite3OsRead(pJrnl, aMagic, 8, szJ-8))\n   || memcmp(aMagic, aJournalMagic, 8)\n   || SQLITE_OK!=(rc = sqlite3OsRead(pJrnl, zMaster, len, szJ-16-len))\n  ){\n    return rc;\n  }\n\n  /* See if the checksum matches the master journal name */\n  for(u=0; u<len; u++){\n    cksum -= zMaster[u];\n  }\n  if( cksum ){\n    /* If the checksum doesn't add up, then one or more of the disk sectors\n    ** containing the master journal filename is corrupted. This means\n    ** definitely roll back, so just return SQLITE_OK and report a (nul)\n    ** master-journal filename.\n    */\n    len = 0;\n  }\n  zMaster[len] = '\\0';\n   \n  return SQLITE_OK;\n}\n\n/*\n** Return the offset of the sector boundary at or immediately \n** following the value in pPager->journalOff, assuming a sector \n** size of pPager->sectorSize bytes.\n**\n** i.e for a sector size of 512:\n**\n**   Pager.journalOff          Return value\n**   ---------------------------------------\n**   0                         0\n**   512                       512\n**   100                       512\n**   2000                      2048\n** \n*/\nstatic i64 journalHdrOffset(Pager *pPager){\n  i64 offset = 0;\n  i64 c = pPager->journalOff;\n  if( c ){\n    offset = ((c-1)/JOURNAL_HDR_SZ(pPager) + 1) * JOURNAL_HDR_SZ(pPager);\n  }\n  assert( offset%JOURNAL_HDR_SZ(pPager)==0 );\n  assert( offset>=c );\n  assert( (offset-c)<JOURNAL_HDR_SZ(pPager) );\n  return offset;\n}\n\n/*\n** The journal file must be open when this function is called.\n**\n** This function is a no-op if the journal file has not been written to\n** within the current transaction (i.e. if Pager.journalOff==0).\n**\n** If doTruncate is non-zero or the Pager.journalSizeLimit variable is\n** set to 0, then truncate the journal file to zero bytes in size. Otherwise,\n** zero the 28-byte header at the start of the journal file. In either case, \n** if the pager is not in no-sync mode, sync the journal file immediately \n** after writing or truncating it.\n**\n** If Pager.journalSizeLimit is set to a positive, non-zero value, and\n** following the truncation or zeroing described above the size of the \n** journal file in bytes is larger than this value, then truncate the\n** journal file to Pager.journalSizeLimit bytes. The journal file does\n** not need to be synced following this operation.\n**\n** If an IO error occurs, abandon processing and return the IO error code.\n** Otherwise, return SQLITE_OK.\n*/\nstatic int zeroJournalHdr(Pager *pPager, int doTruncate){\n  int rc = SQLITE_OK;                               /* Return code */\n  assert( isOpen(pPager->jfd) );\n  assert( !sqlite3JournalIsInMemory(pPager->jfd) );\n  if( pPager->journalOff ){\n    const i64 iLimit = pPager->journalSizeLimit;    /* Local cache of jsl */\n\n    IOTRACE((\"JZEROHDR %p\\n\", pPager))\n    if( doTruncate || iLimit==0 ){\n      rc = sqlite3OsTruncate(pPager->jfd, 0);\n    }else{\n      static const char zeroHdr[28] = {0};\n      rc = sqlite3OsWrite(pPager->jfd, zeroHdr, sizeof(zeroHdr), 0);\n    }\n    if( rc==SQLITE_OK && !pPager->noSync ){\n      rc = sqlite3OsSync(pPager->jfd, SQLITE_SYNC_DATAONLY|pPager->syncFlags);\n    }\n\n    /* At this point the transaction is committed but the write lock \n    ** is still held on the file. If there is a size limit configured for \n    ** the persistent journal and the journal file currently consumes more\n    ** space than that limit allows for, truncate it now. There is no need\n    ** to sync the file following this operation.\n    */\n    if( rc==SQLITE_OK && iLimit>0 ){\n      i64 sz;\n      rc = sqlite3OsFileSize(pPager->jfd, &sz);\n      if( rc==SQLITE_OK && sz>iLimit ){\n        rc = sqlite3OsTruncate(pPager->jfd, iLimit);\n      }\n    }\n  }\n  return rc;\n}\n\n/*\n** The journal file must be open when this routine is called. A journal\n** header (JOURNAL_HDR_SZ bytes) is written into the journal file at the\n** current location.\n**\n** The format for the journal header is as follows:\n** - 8 bytes: Magic identifying journal format.\n** - 4 bytes: Number of records in journal, or -1 no-sync mode is on.\n** - 4 bytes: Random number used for page hash.\n** - 4 bytes: Initial database page count.\n** - 4 bytes: Sector size used by the process that wrote this journal.\n** - 4 bytes: Database page size.\n** \n** Followed by (JOURNAL_HDR_SZ - 28) bytes of unused space.\n*/\nstatic int writeJournalHdr(Pager *pPager){\n  int rc = SQLITE_OK;                 /* Return code */\n  char *zHeader = pPager->pTmpSpace;  /* Temporary space used to build header */\n  u32 nHeader = (u32)pPager->pageSize;/* Size of buffer pointed to by zHeader */\n  u32 nWrite;                         /* Bytes of header sector written */\n  int ii;                             /* Loop counter */\n\n  assert( isOpen(pPager->jfd) );      /* Journal file must be open. */\n\n  if( nHeader>JOURNAL_HDR_SZ(pPager) ){\n    nHeader = JOURNAL_HDR_SZ(pPager);\n  }\n\n  /* If there are active savepoints and any of them were created \n  ** since the most recent journal header was written, update the \n  ** PagerSavepoint.iHdrOffset fields now.\n  */\n  for(ii=0; ii<pPager->nSavepoint; ii++){\n    if( pPager->aSavepoint[ii].iHdrOffset==0 ){\n      pPager->aSavepoint[ii].iHdrOffset = pPager->journalOff;\n    }\n  }\n\n  pPager->journalHdr = pPager->journalOff = journalHdrOffset(pPager);\n\n  /* \n  ** Write the nRec Field - the number of page records that follow this\n  ** journal header. Normally, zero is written to this value at this time.\n  ** After the records are added to the journal (and the journal synced, \n  ** if in full-sync mode), the zero is overwritten with the true number\n  ** of records (see syncJournal()).\n  **\n  ** A faster alternative is to write 0xFFFFFFFF to the nRec field. When\n  ** reading the journal this value tells SQLite to assume that the\n  ** rest of the journal file contains valid page records. This assumption\n  ** is dangerous, as if a failure occurred whilst writing to the journal\n  ** file it may contain some garbage data. There are two scenarios\n  ** where this risk can be ignored:\n  **\n  **   * When the pager is in no-sync mode. Corruption can follow a\n  **     power failure in this case anyway.\n  **\n  **   * When the SQLITE_IOCAP_SAFE_APPEND flag is set. This guarantees\n  **     that garbage data is never appended to the journal file.\n  */\n  assert( isOpen(pPager->fd) || pPager->noSync );\n  if( pPager->noSync || (pPager->journalMode==PAGER_JOURNALMODE_MEMORY)\n   || (sqlite3OsDeviceCharacteristics(pPager->fd)&SQLITE_IOCAP_SAFE_APPEND) \n  ){\n    memcpy(zHeader, aJournalMagic, sizeof(aJournalMagic));\n    put32bits(&zHeader[sizeof(aJournalMagic)], 0xffffffff);\n  }else{\n    memset(zHeader, 0, sizeof(aJournalMagic)+4);\n  }\n\n  /* The random check-hash initializer */ \n  sqlite3_randomness(sizeof(pPager->cksumInit), &pPager->cksumInit);\n  put32bits(&zHeader[sizeof(aJournalMagic)+4], pPager->cksumInit);\n  /* The initial database size */\n  put32bits(&zHeader[sizeof(aJournalMagic)+8], pPager->dbOrigSize);\n  /* The assumed sector size for this process */\n  put32bits(&zHeader[sizeof(aJournalMagic)+12], pPager->sectorSize);\n\n  /* The page size */\n  put32bits(&zHeader[sizeof(aJournalMagic)+16], pPager->pageSize);\n\n  /* Initializing the tail of the buffer is not necessary.  Everything\n  ** works find if the following memset() is omitted.  But initializing\n  ** the memory prevents valgrind from complaining, so we are willing to\n  ** take the performance hit.\n  */\n  memset(&zHeader[sizeof(aJournalMagic)+20], 0,\n         nHeader-(sizeof(aJournalMagic)+20));\n\n  /* In theory, it is only necessary to write the 28 bytes that the \n  ** journal header consumes to the journal file here. Then increment the \n  ** Pager.journalOff variable by JOURNAL_HDR_SZ so that the next \n  ** record is written to the following sector (leaving a gap in the file\n  ** that will be implicitly filled in by the OS).\n  **\n  ** However it has been discovered that on some systems this pattern can \n  ** be significantly slower than contiguously writing data to the file,\n  ** even if that means explicitly writing data to the block of \n  ** (JOURNAL_HDR_SZ - 28) bytes that will not be used. So that is what\n  ** is done. \n  **\n  ** The loop is required here in case the sector-size is larger than the \n  ** database page size. Since the zHeader buffer is only Pager.pageSize\n  ** bytes in size, more than one call to sqlite3OsWrite() may be required\n  ** to populate the entire journal header sector.\n  */ \n  for(nWrite=0; rc==SQLITE_OK&&nWrite<JOURNAL_HDR_SZ(pPager); nWrite+=nHeader){\n    IOTRACE((\"JHDR %p %lld %d\\n\", pPager, pPager->journalHdr, nHeader))\n    rc = sqlite3OsWrite(pPager->jfd, zHeader, nHeader, pPager->journalOff);\n    assert( pPager->journalHdr <= pPager->journalOff );\n    pPager->journalOff += nHeader;\n  }\n\n  return rc;\n}\n\n/*\n** The journal file must be open when this is called. A journal header file\n** (JOURNAL_HDR_SZ bytes) is read from the current location in the journal\n** file. The current location in the journal file is given by\n** pPager->journalOff. See comments above function writeJournalHdr() for\n** a description of the journal header format.\n**\n** If the header is read successfully, *pNRec is set to the number of\n** page records following this header and *pDbSize is set to the size of the\n** database before the transaction began, in pages. Also, pPager->cksumInit\n** is set to the value read from the journal header. SQLITE_OK is returned\n** in this case.\n**\n** If the journal header file appears to be corrupted, SQLITE_DONE is\n** returned and *pNRec and *PDbSize are undefined.  If JOURNAL_HDR_SZ bytes\n** cannot be read from the journal file an error code is returned.\n*/\nstatic int readJournalHdr(\n  Pager *pPager,               /* Pager object */\n  int isHot,\n  i64 journalSize,             /* Size of the open journal file in bytes */\n  u32 *pNRec,                  /* OUT: Value read from the nRec field */\n  u32 *pDbSize                 /* OUT: Value of original database size field */\n){\n  int rc;                      /* Return code */\n  unsigned char aMagic[8];     /* A buffer to hold the magic header */\n  i64 iHdrOff;                 /* Offset of journal header being read */\n\n  assert( isOpen(pPager->jfd) );      /* Journal file must be open. */\n\n  /* Advance Pager.journalOff to the start of the next sector. If the\n  ** journal file is too small for there to be a header stored at this\n  ** point, return SQLITE_DONE.\n  */\n  pPager->journalOff = journalHdrOffset(pPager);\n  if( pPager->journalOff+JOURNAL_HDR_SZ(pPager) > journalSize ){\n    return SQLITE_DONE;\n  }\n  iHdrOff = pPager->journalOff;\n\n  /* Read in the first 8 bytes of the journal header. If they do not match\n  ** the  magic string found at the start of each journal header, return\n  ** SQLITE_DONE. If an IO error occurs, return an error code. Otherwise,\n  ** proceed.\n  */\n  if( isHot || iHdrOff!=pPager->journalHdr ){\n    rc = sqlite3OsRead(pPager->jfd, aMagic, sizeof(aMagic), iHdrOff);\n    if( rc ){\n      return rc;\n    }\n    if( memcmp(aMagic, aJournalMagic, sizeof(aMagic))!=0 ){\n      return SQLITE_DONE;\n    }\n  }\n\n  /* Read the first three 32-bit fields of the journal header: The nRec\n  ** field, the checksum-initializer and the database size at the start\n  ** of the transaction. Return an error code if anything goes wrong.\n  */\n  if( SQLITE_OK!=(rc = read32bits(pPager->jfd, iHdrOff+8, pNRec))\n   || SQLITE_OK!=(rc = read32bits(pPager->jfd, iHdrOff+12, &pPager->cksumInit))\n   || SQLITE_OK!=(rc = read32bits(pPager->jfd, iHdrOff+16, pDbSize))\n  ){\n    return rc;\n  }\n\n  if( pPager->journalOff==0 ){\n    u32 iPageSize;               /* Page-size field of journal header */\n    u32 iSectorSize;             /* Sector-size field of journal header */\n\n    /* Read the page-size and sector-size journal header fields. */\n    if( SQLITE_OK!=(rc = read32bits(pPager->jfd, iHdrOff+20, &iSectorSize))\n     || SQLITE_OK!=(rc = read32bits(pPager->jfd, iHdrOff+24, &iPageSize))\n    ){\n      return rc;\n    }\n\n    /* Versions of SQLite prior to 3.5.8 set the page-size field of the\n    ** journal header to zero. In this case, assume that the Pager.pageSize\n    ** variable is already set to the correct page size.\n    */\n    if( iPageSize==0 ){\n      iPageSize = pPager->pageSize;\n    }\n\n    /* Check that the values read from the page-size and sector-size fields\n    ** are within range. To be 'in range', both values need to be a power\n    ** of two greater than or equal to 512 or 32, and not greater than their \n    ** respective compile time maximum limits.\n    */\n    if( iPageSize<512                  || iSectorSize<32\n     || iPageSize>SQLITE_MAX_PAGE_SIZE || iSectorSize>MAX_SECTOR_SIZE\n     || ((iPageSize-1)&iPageSize)!=0   || ((iSectorSize-1)&iSectorSize)!=0 \n    ){\n      /* If the either the page-size or sector-size in the journal-header is \n      ** invalid, then the process that wrote the journal-header must have \n      ** crashed before the header was synced. In this case stop reading \n      ** the journal file here.\n      */\n      return SQLITE_DONE;\n    }\n\n    /* Update the page-size to match the value read from the journal. \n    ** Use a testcase() macro to make sure that malloc failure within \n    ** PagerSetPagesize() is tested.\n    */\n    rc = sqlite3PagerSetPagesize(pPager, &iPageSize, -1);\n    testcase( rc!=SQLITE_OK );\n\n    /* Update the assumed sector-size to match the value used by \n    ** the process that created this journal. If this journal was\n    ** created by a process other than this one, then this routine\n    ** is being called from within pager_playback(). The local value\n    ** of Pager.sectorSize is restored at the end of that routine.\n    */\n    pPager->sectorSize = iSectorSize;\n  }\n\n  pPager->journalOff += JOURNAL_HDR_SZ(pPager);\n  return rc;\n}\n\n\n/*\n** Write the supplied master journal name into the journal file for pager\n** pPager at the current location. The master journal name must be the last\n** thing written to a journal file. If the pager is in full-sync mode, the\n** journal file descriptor is advanced to the next sector boundary before\n** anything is written. The format is:\n**\n**   + 4 bytes: PAGER_MJ_PGNO.\n**   + N bytes: Master journal filename in utf-8.\n**   + 4 bytes: N (length of master journal name in bytes, no nul-terminator).\n**   + 4 bytes: Master journal name checksum.\n**   + 8 bytes: aJournalMagic[].\n**\n** The master journal page checksum is the sum of the bytes in the master\n** journal name, where each byte is interpreted as a signed 8-bit integer.\n**\n** If zMaster is a NULL pointer (occurs for a single database transaction), \n** this call is a no-op.\n*/\nstatic int writeMasterJournal(Pager *pPager, const char *zMaster){\n  int rc;                          /* Return code */\n  int nMaster;                     /* Length of string zMaster */\n  i64 iHdrOff;                     /* Offset of header in journal file */\n  i64 jrnlSize;                    /* Size of journal file on disk */\n  u32 cksum = 0;                   /* Checksum of string zMaster */\n\n  assert( pPager->setMaster==0 );\n  assert( !pagerUseWal(pPager) );\n\n  if( !zMaster \n   || pPager->journalMode==PAGER_JOURNALMODE_MEMORY \n   || !isOpen(pPager->jfd)\n  ){\n    return SQLITE_OK;\n  }\n  pPager->setMaster = 1;\n  assert( pPager->journalHdr <= pPager->journalOff );\n\n  /* Calculate the length in bytes and the checksum of zMaster */\n  for(nMaster=0; zMaster[nMaster]; nMaster++){\n    cksum += zMaster[nMaster];\n  }\n\n  /* If in full-sync mode, advance to the next disk sector before writing\n  ** the master journal name. This is in case the previous page written to\n  ** the journal has already been synced.\n  */\n  if( pPager->fullSync ){\n    pPager->journalOff = journalHdrOffset(pPager);\n  }\n  iHdrOff = pPager->journalOff;\n\n  /* Write the master journal data to the end of the journal file. If\n  ** an error occurs, return the error code to the caller.\n  */\n  if( (0 != (rc = write32bits(pPager->jfd, iHdrOff, PAGER_MJ_PGNO(pPager))))\n   || (0 != (rc = sqlite3OsWrite(pPager->jfd, zMaster, nMaster, iHdrOff+4)))\n   || (0 != (rc = write32bits(pPager->jfd, iHdrOff+4+nMaster, nMaster)))\n   || (0 != (rc = write32bits(pPager->jfd, iHdrOff+4+nMaster+4, cksum)))\n   || (0 != (rc = sqlite3OsWrite(pPager->jfd, aJournalMagic, 8,\n                                 iHdrOff+4+nMaster+8)))\n  ){\n    return rc;\n  }\n  pPager->journalOff += (nMaster+20);\n\n  /* If the pager is in peristent-journal mode, then the physical \n  ** journal-file may extend past the end of the master-journal name\n  ** and 8 bytes of magic data just written to the file. This is \n  ** dangerous because the code to rollback a hot-journal file\n  ** will not be able to find the master-journal name to determine \n  ** whether or not the journal is hot. \n  **\n  ** Easiest thing to do in this scenario is to truncate the journal \n  ** file to the required size.\n  */ \n  if( SQLITE_OK==(rc = sqlite3OsFileSize(pPager->jfd, &jrnlSize))\n   && jrnlSize>pPager->journalOff\n  ){\n    rc = sqlite3OsTruncate(pPager->jfd, pPager->journalOff);\n  }\n  return rc;\n}\n\n/*\n** Discard the entire contents of the in-memory page-cache.\n*/\nstatic void pager_reset(Pager *pPager){\n  pPager->iDataVersion++;\n  sqlite3BackupRestart(pPager->pBackup);\n  sqlite3PcacheClear(pPager->pPCache);\n}\n\n/*\n** Return the pPager->iDataVersion value\n*/\nSQLITE_PRIVATE u32 sqlite3PagerDataVersion(Pager *pPager){\n  return pPager->iDataVersion;\n}\n\n/*\n** Free all structures in the Pager.aSavepoint[] array and set both\n** Pager.aSavepoint and Pager.nSavepoint to zero. Close the sub-journal\n** if it is open and the pager is not in exclusive mode.\n*/\nstatic void releaseAllSavepoints(Pager *pPager){\n  int ii;               /* Iterator for looping through Pager.aSavepoint */\n  for(ii=0; ii<pPager->nSavepoint; ii++){\n    sqlite3BitvecDestroy(pPager->aSavepoint[ii].pInSavepoint);\n  }\n  if( !pPager->exclusiveMode || sqlite3JournalIsInMemory(pPager->sjfd) ){\n    sqlite3OsClose(pPager->sjfd);\n  }\n  sqlite3_free(pPager->aSavepoint);\n  pPager->aSavepoint = 0;\n  pPager->nSavepoint = 0;\n  pPager->nSubRec = 0;\n}\n\n/*\n** Set the bit number pgno in the PagerSavepoint.pInSavepoint \n** bitvecs of all open savepoints. Return SQLITE_OK if successful\n** or SQLITE_NOMEM if a malloc failure occurs.\n*/\nstatic int addToSavepointBitvecs(Pager *pPager, Pgno pgno){\n  int ii;                   /* Loop counter */\n  int rc = SQLITE_OK;       /* Result code */\n\n  for(ii=0; ii<pPager->nSavepoint; ii++){\n    PagerSavepoint *p = &pPager->aSavepoint[ii];\n    if( pgno<=p->nOrig ){\n      rc |= sqlite3BitvecSet(p->pInSavepoint, pgno);\n      testcase( rc==SQLITE_NOMEM );\n      assert( rc==SQLITE_OK || rc==SQLITE_NOMEM );\n    }\n  }\n  return rc;\n}\n\n/*\n** This function is a no-op if the pager is in exclusive mode and not\n** in the ERROR state. Otherwise, it switches the pager to PAGER_OPEN\n** state.\n**\n** If the pager is not in exclusive-access mode, the database file is\n** completely unlocked. If the file is unlocked and the file-system does\n** not exhibit the UNDELETABLE_WHEN_OPEN property, the journal file is\n** closed (if it is open).\n**\n** If the pager is in ERROR state when this function is called, the \n** contents of the pager cache are discarded before switching back to \n** the OPEN state. Regardless of whether the pager is in exclusive-mode\n** or not, any journal file left in the file-system will be treated\n** as a hot-journal and rolled back the next time a read-transaction\n** is opened (by this or by any other connection).\n*/\nstatic void pager_unlock(Pager *pPager){\n\n  assert( pPager->eState==PAGER_READER \n       || pPager->eState==PAGER_OPEN \n       || pPager->eState==PAGER_ERROR \n  );\n\n  sqlite3BitvecDestroy(pPager->pInJournal);\n  pPager->pInJournal = 0;\n  releaseAllSavepoints(pPager);\n\n  if( pagerUseWal(pPager) ){\n    assert( !isOpen(pPager->jfd) );\n    sqlite3WalEndReadTransaction(pPager->pWal);\n    pPager->eState = PAGER_OPEN;\n  }else if( !pPager->exclusiveMode ){\n    int rc;                       /* Error code returned by pagerUnlockDb() */\n    int iDc = isOpen(pPager->fd)?sqlite3OsDeviceCharacteristics(pPager->fd):0;\n\n    /* If the operating system support deletion of open files, then\n    ** close the journal file when dropping the database lock.  Otherwise\n    ** another connection with journal_mode=delete might delete the file\n    ** out from under us.\n    */\n    assert( (PAGER_JOURNALMODE_MEMORY   & 5)!=1 );\n    assert( (PAGER_JOURNALMODE_OFF      & 5)!=1 );\n    assert( (PAGER_JOURNALMODE_WAL      & 5)!=1 );\n    assert( (PAGER_JOURNALMODE_DELETE   & 5)!=1 );\n    assert( (PAGER_JOURNALMODE_TRUNCATE & 5)==1 );\n    assert( (PAGER_JOURNALMODE_PERSIST  & 5)==1 );\n    if( 0==(iDc & SQLITE_IOCAP_UNDELETABLE_WHEN_OPEN)\n     || 1!=(pPager->journalMode & 5)\n    ){\n      sqlite3OsClose(pPager->jfd);\n    }\n\n    /* If the pager is in the ERROR state and the call to unlock the database\n    ** file fails, set the current lock to UNKNOWN_LOCK. See the comment\n    ** above the #define for UNKNOWN_LOCK for an explanation of why this\n    ** is necessary.\n    */\n    rc = pagerUnlockDb(pPager, NO_LOCK);\n    if( rc!=SQLITE_OK && pPager->eState==PAGER_ERROR ){\n      pPager->eLock = UNKNOWN_LOCK;\n    }\n\n    /* The pager state may be changed from PAGER_ERROR to PAGER_OPEN here\n    ** without clearing the error code. This is intentional - the error\n    ** code is cleared and the cache reset in the block below.\n    */\n    assert( pPager->errCode || pPager->eState!=PAGER_ERROR );\n    pPager->changeCountDone = 0;\n    pPager->eState = PAGER_OPEN;\n  }\n\n  /* If Pager.errCode is set, the contents of the pager cache cannot be\n  ** trusted. Now that there are no outstanding references to the pager,\n  ** it can safely move back to PAGER_OPEN state. This happens in both\n  ** normal and exclusive-locking mode.\n  */\n  assert( pPager->errCode==SQLITE_OK || !MEMDB );\n  if( pPager->errCode ){\n    if( pPager->tempFile==0 ){\n      pager_reset(pPager);\n      pPager->changeCountDone = 0;\n      pPager->eState = PAGER_OPEN;\n    }else{\n      pPager->eState = (isOpen(pPager->jfd) ? PAGER_OPEN : PAGER_READER);\n    }\n    if( USEFETCH(pPager) ) sqlite3OsUnfetch(pPager->fd, 0, 0);\n    pPager->errCode = SQLITE_OK;\n    setGetterMethod(pPager);\n  }\n\n  pPager->journalOff = 0;\n  pPager->journalHdr = 0;\n  pPager->setMaster = 0;\n}\n\n/*\n** This function is called whenever an IOERR or FULL error that requires\n** the pager to transition into the ERROR state may ahve occurred.\n** The first argument is a pointer to the pager structure, the second \n** the error-code about to be returned by a pager API function. The \n** value returned is a copy of the second argument to this function. \n**\n** If the second argument is SQLITE_FULL, SQLITE_IOERR or one of the\n** IOERR sub-codes, the pager enters the ERROR state and the error code\n** is stored in Pager.errCode. While the pager remains in the ERROR state,\n** all major API calls on the Pager will immediately return Pager.errCode.\n**\n** The ERROR state indicates that the contents of the pager-cache \n** cannot be trusted. This state can be cleared by completely discarding \n** the contents of the pager-cache. If a transaction was active when\n** the persistent error occurred, then the rollback journal may need\n** to be replayed to restore the contents of the database file (as if\n** it were a hot-journal).\n*/\nstatic int pager_error(Pager *pPager, int rc){\n  int rc2 = rc & 0xff;\n  assert( rc==SQLITE_OK || !MEMDB );\n  assert(\n       pPager->errCode==SQLITE_FULL ||\n       pPager->errCode==SQLITE_OK ||\n       (pPager->errCode & 0xff)==SQLITE_IOERR\n  );\n  if( rc2==SQLITE_FULL || rc2==SQLITE_IOERR ){\n    pPager->errCode = rc;\n    pPager->eState = PAGER_ERROR;\n    setGetterMethod(pPager);\n  }\n  return rc;\n}\n\nstatic int pager_truncate(Pager *pPager, Pgno nPage);\n\n/*\n** The write transaction open on pPager is being committed (bCommit==1)\n** or rolled back (bCommit==0).\n**\n** Return TRUE if and only if all dirty pages should be flushed to disk.\n**\n** Rules:\n**\n**   *  For non-TEMP databases, always sync to disk.  This is necessary\n**      for transactions to be durable.\n**\n**   *  Sync TEMP database only on a COMMIT (not a ROLLBACK) when the backing\n**      file has been created already (via a spill on pagerStress()) and\n**      when the number of dirty pages in memory exceeds 25% of the total\n**      cache size.\n*/\nstatic int pagerFlushOnCommit(Pager *pPager, int bCommit){\n  if( pPager->tempFile==0 ) return 1;\n  if( !bCommit ) return 0;\n  if( !isOpen(pPager->fd) ) return 0;\n  return (sqlite3PCachePercentDirty(pPager->pPCache)>=25);\n}\n\n/*\n** This routine ends a transaction. A transaction is usually ended by \n** either a COMMIT or a ROLLBACK operation. This routine may be called \n** after rollback of a hot-journal, or if an error occurs while opening\n** the journal file or writing the very first journal-header of a\n** database transaction.\n** \n** This routine is never called in PAGER_ERROR state. If it is called\n** in PAGER_NONE or PAGER_SHARED state and the lock held is less\n** exclusive than a RESERVED lock, it is a no-op.\n**\n** Otherwise, any active savepoints are released.\n**\n** If the journal file is open, then it is \"finalized\". Once a journal \n** file has been finalized it is not possible to use it to roll back a \n** transaction. Nor will it be considered to be a hot-journal by this\n** or any other database connection. Exactly how a journal is finalized\n** depends on whether or not the pager is running in exclusive mode and\n** the current journal-mode (Pager.journalMode value), as follows:\n**\n**   journalMode==MEMORY\n**     Journal file descriptor is simply closed. This destroys an \n**     in-memory journal.\n**\n**   journalMode==TRUNCATE\n**     Journal file is truncated to zero bytes in size.\n**\n**   journalMode==PERSIST\n**     The first 28 bytes of the journal file are zeroed. This invalidates\n**     the first journal header in the file, and hence the entire journal\n**     file. An invalid journal file cannot be rolled back.\n**\n**   journalMode==DELETE\n**     The journal file is closed and deleted using sqlite3OsDelete().\n**\n**     If the pager is running in exclusive mode, this method of finalizing\n**     the journal file is never used. Instead, if the journalMode is\n**     DELETE and the pager is in exclusive mode, the method described under\n**     journalMode==PERSIST is used instead.\n**\n** After the journal is finalized, the pager moves to PAGER_READER state.\n** If running in non-exclusive rollback mode, the lock on the file is \n** downgraded to a SHARED_LOCK.\n**\n** SQLITE_OK is returned if no error occurs. If an error occurs during\n** any of the IO operations to finalize the journal file or unlock the\n** database then the IO error code is returned to the user. If the \n** operation to finalize the journal file fails, then the code still\n** tries to unlock the database file if not in exclusive mode. If the\n** unlock operation fails as well, then the first error code related\n** to the first error encountered (the journal finalization one) is\n** returned.\n*/\nstatic int pager_end_transaction(Pager *pPager, int hasMaster, int bCommit){\n  int rc = SQLITE_OK;      /* Error code from journal finalization operation */\n  int rc2 = SQLITE_OK;     /* Error code from db file unlock operation */\n\n  /* Do nothing if the pager does not have an open write transaction\n  ** or at least a RESERVED lock. This function may be called when there\n  ** is no write-transaction active but a RESERVED or greater lock is\n  ** held under two circumstances:\n  **\n  **   1. After a successful hot-journal rollback, it is called with\n  **      eState==PAGER_NONE and eLock==EXCLUSIVE_LOCK.\n  **\n  **   2. If a connection with locking_mode=exclusive holding an EXCLUSIVE \n  **      lock switches back to locking_mode=normal and then executes a\n  **      read-transaction, this function is called with eState==PAGER_READER \n  **      and eLock==EXCLUSIVE_LOCK when the read-transaction is closed.\n  */\n  assert( assert_pager_state(pPager) );\n  assert( pPager->eState!=PAGER_ERROR );\n  if( pPager->eState<PAGER_WRITER_LOCKED && pPager->eLock<RESERVED_LOCK ){\n    return SQLITE_OK;\n  }\n\n  releaseAllSavepoints(pPager);\n  assert( isOpen(pPager->jfd) || pPager->pInJournal==0 \n      || (sqlite3OsDeviceCharacteristics(pPager->fd)&SQLITE_IOCAP_BATCH_ATOMIC)\n  );\n  if( isOpen(pPager->jfd) ){\n    assert( !pagerUseWal(pPager) );\n\n    /* Finalize the journal file. */\n    if( sqlite3JournalIsInMemory(pPager->jfd) ){\n      /* assert( pPager->journalMode==PAGER_JOURNALMODE_MEMORY ); */\n      sqlite3OsClose(pPager->jfd);\n    }else if( pPager->journalMode==PAGER_JOURNALMODE_TRUNCATE ){\n      if( pPager->journalOff==0 ){\n        rc = SQLITE_OK;\n      }else{\n        rc = sqlite3OsTruncate(pPager->jfd, 0);\n        if( rc==SQLITE_OK && pPager->fullSync ){\n          /* Make sure the new file size is written into the inode right away.\n          ** Otherwise the journal might resurrect following a power loss and\n          ** cause the last transaction to roll back.  See\n          ** https://bugzilla.mozilla.org/show_bug.cgi?id=1072773\n          */\n          rc = sqlite3OsSync(pPager->jfd, pPager->syncFlags);\n        }\n      }\n      pPager->journalOff = 0;\n    }else if( pPager->journalMode==PAGER_JOURNALMODE_PERSIST\n      || (pPager->exclusiveMode && pPager->journalMode!=PAGER_JOURNALMODE_WAL)\n    ){\n      rc = zeroJournalHdr(pPager, hasMaster||pPager->tempFile);\n      pPager->journalOff = 0;\n    }else{\n      /* This branch may be executed with Pager.journalMode==MEMORY if\n      ** a hot-journal was just rolled back. In this case the journal\n      ** file should be closed and deleted. If this connection writes to\n      ** the database file, it will do so using an in-memory journal.\n      */\n      int bDelete = !pPager->tempFile;\n      assert( sqlite3JournalIsInMemory(pPager->jfd)==0 );\n      assert( pPager->journalMode==PAGER_JOURNALMODE_DELETE \n           || pPager->journalMode==PAGER_JOURNALMODE_MEMORY \n           || pPager->journalMode==PAGER_JOURNALMODE_WAL \n      );\n      sqlite3OsClose(pPager->jfd);\n      if( bDelete ){\n        rc = sqlite3OsDelete(pPager->pVfs, pPager->zJournal, pPager->extraSync);\n      }\n    }\n  }\n\n#ifdef SQLITE_CHECK_PAGES\n  sqlite3PcacheIterateDirty(pPager->pPCache, pager_set_pagehash);\n  if( pPager->dbSize==0 && sqlite3PcacheRefCount(pPager->pPCache)>0 ){\n    PgHdr *p = sqlite3PagerLookup(pPager, 1);\n    if( p ){\n      p->pageHash = 0;\n      sqlite3PagerUnrefNotNull(p);\n    }\n  }\n#endif\n\n  sqlite3BitvecDestroy(pPager->pInJournal);\n  pPager->pInJournal = 0;\n  pPager->nRec = 0;\n  if( rc==SQLITE_OK ){\n    if( MEMDB || pagerFlushOnCommit(pPager, bCommit) ){\n      sqlite3PcacheCleanAll(pPager->pPCache);\n    }else{\n      sqlite3PcacheClearWritable(pPager->pPCache);\n    }\n    sqlite3PcacheTruncate(pPager->pPCache, pPager->dbSize);\n  }\n\n  if( pagerUseWal(pPager) ){\n    /* Drop the WAL write-lock, if any. Also, if the connection was in \n    ** locking_mode=exclusive mode but is no longer, drop the EXCLUSIVE \n    ** lock held on the database file.\n    */\n    rc2 = sqlite3WalEndWriteTransaction(pPager->pWal);\n    assert( rc2==SQLITE_OK );\n  }else if( rc==SQLITE_OK && bCommit && pPager->dbFileSize>pPager->dbSize ){\n    /* This branch is taken when committing a transaction in rollback-journal\n    ** mode if the database file on disk is larger than the database image.\n    ** At this point the journal has been finalized and the transaction \n    ** successfully committed, but the EXCLUSIVE lock is still held on the\n    ** file. So it is safe to truncate the database file to its minimum\n    ** required size.  */\n    assert( pPager->eLock==EXCLUSIVE_LOCK );\n    rc = pager_truncate(pPager, pPager->dbSize);\n  }\n\n  if( rc==SQLITE_OK && bCommit ){\n    rc = sqlite3OsFileControl(pPager->fd, SQLITE_FCNTL_COMMIT_PHASETWO, 0);\n    if( rc==SQLITE_NOTFOUND ) rc = SQLITE_OK;\n  }\n\n  if( !pPager->exclusiveMode \n   && (!pagerUseWal(pPager) || sqlite3WalExclusiveMode(pPager->pWal, 0))\n  ){\n    rc2 = pagerUnlockDb(pPager, SHARED_LOCK);\n    pPager->changeCountDone = 0;\n  }\n  pPager->eState = PAGER_READER;\n  pPager->setMaster = 0;\n\n  return (rc==SQLITE_OK?rc2:rc);\n}\n\n/*\n** Execute a rollback if a transaction is active and unlock the \n** database file. \n**\n** If the pager has already entered the ERROR state, do not attempt \n** the rollback at this time. Instead, pager_unlock() is called. The\n** call to pager_unlock() will discard all in-memory pages, unlock\n** the database file and move the pager back to OPEN state. If this \n** means that there is a hot-journal left in the file-system, the next \n** connection to obtain a shared lock on the pager (which may be this one) \n** will roll it back.\n**\n** If the pager has not already entered the ERROR state, but an IO or\n** malloc error occurs during a rollback, then this will itself cause \n** the pager to enter the ERROR state. Which will be cleared by the\n** call to pager_unlock(), as described above.\n*/\nstatic void pagerUnlockAndRollback(Pager *pPager){\n  if( pPager->eState!=PAGER_ERROR && pPager->eState!=PAGER_OPEN ){\n    assert( assert_pager_state(pPager) );\n    if( pPager->eState>=PAGER_WRITER_LOCKED ){\n      sqlite3BeginBenignMalloc();\n      sqlite3PagerRollback(pPager);\n      sqlite3EndBenignMalloc();\n    }else if( !pPager->exclusiveMode ){\n      assert( pPager->eState==PAGER_READER );\n      pager_end_transaction(pPager, 0, 0);\n    }\n  }\n  pager_unlock(pPager);\n}\n\n/*\n** Parameter aData must point to a buffer of pPager->pageSize bytes\n** of data. Compute and return a checksum based ont the contents of the \n** page of data and the current value of pPager->cksumInit.\n**\n** This is not a real checksum. It is really just the sum of the \n** random initial value (pPager->cksumInit) and every 200th byte\n** of the page data, starting with byte offset (pPager->pageSize%200).\n** Each byte is interpreted as an 8-bit unsigned integer.\n**\n** Changing the formula used to compute this checksum results in an\n** incompatible journal file format.\n**\n** If journal corruption occurs due to a power failure, the most likely \n** scenario is that one end or the other of the record will be changed. \n** It is much less likely that the two ends of the journal record will be\n** correct and the middle be corrupt.  Thus, this \"checksum\" scheme,\n** though fast and simple, catches the mostly likely kind of corruption.\n*/\nstatic u32 pager_cksum(Pager *pPager, const u8 *aData){\n  u32 cksum = pPager->cksumInit;         /* Checksum value to return */\n  int i = pPager->pageSize-200;          /* Loop counter */\n  while( i>0 ){\n    cksum += aData[i];\n    i -= 200;\n  }\n  return cksum;\n}\n\n/*\n** Report the current page size and number of reserved bytes back\n** to the codec.\n*/\n#ifdef SQLITE_HAS_CODEC\nstatic void pagerReportSize(Pager *pPager){\n  if( pPager->xCodecSizeChng ){\n    pPager->xCodecSizeChng(pPager->pCodec, pPager->pageSize,\n                           (int)pPager->nReserve);\n  }\n}\n#else\n# define pagerReportSize(X)     /* No-op if we do not support a codec */\n#endif\n\n#ifdef SQLITE_HAS_CODEC\n/*\n** Make sure the number of reserved bits is the same in the destination\n** pager as it is in the source.  This comes up when a VACUUM changes the\n** number of reserved bits to the \"optimal\" amount.\n*/\nSQLITE_PRIVATE void sqlite3PagerAlignReserve(Pager *pDest, Pager *pSrc){\n  if( pDest->nReserve!=pSrc->nReserve ){\n    pDest->nReserve = pSrc->nReserve;\n    pagerReportSize(pDest);\n  }\n}\n#endif\n\n/*\n** Read a single page from either the journal file (if isMainJrnl==1) or\n** from the sub-journal (if isMainJrnl==0) and playback that page.\n** The page begins at offset *pOffset into the file. The *pOffset\n** value is increased to the start of the next page in the journal.\n**\n** The main rollback journal uses checksums - the statement journal does \n** not.\n**\n** If the page number of the page record read from the (sub-)journal file\n** is greater than the current value of Pager.dbSize, then playback is\n** skipped and SQLITE_OK is returned.\n**\n** If pDone is not NULL, then it is a record of pages that have already\n** been played back.  If the page at *pOffset has already been played back\n** (if the corresponding pDone bit is set) then skip the playback.\n** Make sure the pDone bit corresponding to the *pOffset page is set\n** prior to returning.\n**\n** If the page record is successfully read from the (sub-)journal file\n** and played back, then SQLITE_OK is returned. If an IO error occurs\n** while reading the record from the (sub-)journal file or while writing\n** to the database file, then the IO error code is returned. If data\n** is successfully read from the (sub-)journal file but appears to be\n** corrupted, SQLITE_DONE is returned. Data is considered corrupted in\n** two circumstances:\n** \n**   * If the record page-number is illegal (0 or PAGER_MJ_PGNO), or\n**   * If the record is being rolled back from the main journal file\n**     and the checksum field does not match the record content.\n**\n** Neither of these two scenarios are possible during a savepoint rollback.\n**\n** If this is a savepoint rollback, then memory may have to be dynamically\n** allocated by this function. If this is the case and an allocation fails,\n** SQLITE_NOMEM is returned.\n*/\nstatic int pager_playback_one_page(\n  Pager *pPager,                /* The pager being played back */\n  i64 *pOffset,                 /* Offset of record to playback */\n  Bitvec *pDone,                /* Bitvec of pages already played back */\n  int isMainJrnl,               /* 1 -> main journal. 0 -> sub-journal. */\n  int isSavepnt                 /* True for a savepoint rollback */\n){\n  int rc;\n  PgHdr *pPg;                   /* An existing page in the cache */\n  Pgno pgno;                    /* The page number of a page in journal */\n  u32 cksum;                    /* Checksum used for sanity checking */\n  char *aData;                  /* Temporary storage for the page */\n  sqlite3_file *jfd;            /* The file descriptor for the journal file */\n  int isSynced;                 /* True if journal page is synced */\n#ifdef SQLITE_HAS_CODEC\n  /* The jrnlEnc flag is true if Journal pages should be passed through\n  ** the codec.  It is false for pure in-memory journals. */\n  const int jrnlEnc = (isMainJrnl || pPager->subjInMemory==0);\n#endif\n\n  assert( (isMainJrnl&~1)==0 );      /* isMainJrnl is 0 or 1 */\n  assert( (isSavepnt&~1)==0 );       /* isSavepnt is 0 or 1 */\n  assert( isMainJrnl || pDone );     /* pDone always used on sub-journals */\n  assert( isSavepnt || pDone==0 );   /* pDone never used on non-savepoint */\n\n  aData = pPager->pTmpSpace;\n  assert( aData );         /* Temp storage must have already been allocated */\n  assert( pagerUseWal(pPager)==0 || (!isMainJrnl && isSavepnt) );\n\n  /* Either the state is greater than PAGER_WRITER_CACHEMOD (a transaction \n  ** or savepoint rollback done at the request of the caller) or this is\n  ** a hot-journal rollback. If it is a hot-journal rollback, the pager\n  ** is in state OPEN and holds an EXCLUSIVE lock. Hot-journal rollback\n  ** only reads from the main journal, not the sub-journal.\n  */\n  assert( pPager->eState>=PAGER_WRITER_CACHEMOD\n       || (pPager->eState==PAGER_OPEN && pPager->eLock==EXCLUSIVE_LOCK)\n  );\n  assert( pPager->eState>=PAGER_WRITER_CACHEMOD || isMainJrnl );\n\n  /* Read the page number and page data from the journal or sub-journal\n  ** file. Return an error code to the caller if an IO error occurs.\n  */\n  jfd = isMainJrnl ? pPager->jfd : pPager->sjfd;\n  rc = read32bits(jfd, *pOffset, &pgno);\n  if( rc!=SQLITE_OK ) return rc;\n  rc = sqlite3OsRead(jfd, (u8*)aData, pPager->pageSize, (*pOffset)+4);\n  if( rc!=SQLITE_OK ) return rc;\n  *pOffset += pPager->pageSize + 4 + isMainJrnl*4;\n\n  /* Sanity checking on the page.  This is more important that I originally\n  ** thought.  If a power failure occurs while the journal is being written,\n  ** it could cause invalid data to be written into the journal.  We need to\n  ** detect this invalid data (with high probability) and ignore it.\n  */\n  if( pgno==0 || pgno==PAGER_MJ_PGNO(pPager) ){\n    assert( !isSavepnt );\n    return SQLITE_DONE;\n  }\n  if( pgno>(Pgno)pPager->dbSize || sqlite3BitvecTest(pDone, pgno) ){\n    return SQLITE_OK;\n  }\n  if( isMainJrnl ){\n    rc = read32bits(jfd, (*pOffset)-4, &cksum);\n    if( rc ) return rc;\n    if( !isSavepnt && pager_cksum(pPager, (u8*)aData)!=cksum ){\n      return SQLITE_DONE;\n    }\n  }\n\n  /* If this page has already been played back before during the current\n  ** rollback, then don't bother to play it back again.\n  */\n  if( pDone && (rc = sqlite3BitvecSet(pDone, pgno))!=SQLITE_OK ){\n    return rc;\n  }\n\n  /* When playing back page 1, restore the nReserve setting\n  */\n  if( pgno==1 && pPager->nReserve!=((u8*)aData)[20] ){\n    pPager->nReserve = ((u8*)aData)[20];\n    pagerReportSize(pPager);\n  }\n\n  /* If the pager is in CACHEMOD state, then there must be a copy of this\n  ** page in the pager cache. In this case just update the pager cache,\n  ** not the database file. The page is left marked dirty in this case.\n  **\n  ** An exception to the above rule: If the database is in no-sync mode\n  ** and a page is moved during an incremental vacuum then the page may\n  ** not be in the pager cache. Later: if a malloc() or IO error occurs\n  ** during a Movepage() call, then the page may not be in the cache\n  ** either. So the condition described in the above paragraph is not\n  ** assert()able.\n  **\n  ** If in WRITER_DBMOD, WRITER_FINISHED or OPEN state, then we update the\n  ** pager cache if it exists and the main file. The page is then marked \n  ** not dirty. Since this code is only executed in PAGER_OPEN state for\n  ** a hot-journal rollback, it is guaranteed that the page-cache is empty\n  ** if the pager is in OPEN state.\n  **\n  ** Ticket #1171:  The statement journal might contain page content that is\n  ** different from the page content at the start of the transaction.\n  ** This occurs when a page is changed prior to the start of a statement\n  ** then changed again within the statement.  When rolling back such a\n  ** statement we must not write to the original database unless we know\n  ** for certain that original page contents are synced into the main rollback\n  ** journal.  Otherwise, a power loss might leave modified data in the\n  ** database file without an entry in the rollback journal that can\n  ** restore the database to its original form.  Two conditions must be\n  ** met before writing to the database files. (1) the database must be\n  ** locked.  (2) we know that the original page content is fully synced\n  ** in the main journal either because the page is not in cache or else\n  ** the page is marked as needSync==0.\n  **\n  ** 2008-04-14:  When attempting to vacuum a corrupt database file, it\n  ** is possible to fail a statement on a database that does not yet exist.\n  ** Do not attempt to write if database file has never been opened.\n  */\n  if( pagerUseWal(pPager) ){\n    pPg = 0;\n  }else{\n    pPg = sqlite3PagerLookup(pPager, pgno);\n  }\n  assert( pPg || !MEMDB );\n  assert( pPager->eState!=PAGER_OPEN || pPg==0 || pPager->tempFile );\n  PAGERTRACE((\"PLAYBACK %d page %d hash(%08x) %s\\n\",\n           PAGERID(pPager), pgno, pager_datahash(pPager->pageSize, (u8*)aData),\n           (isMainJrnl?\"main-journal\":\"sub-journal\")\n  ));\n  if( isMainJrnl ){\n    isSynced = pPager->noSync || (*pOffset <= pPager->journalHdr);\n  }else{\n    isSynced = (pPg==0 || 0==(pPg->flags & PGHDR_NEED_SYNC));\n  }\n  if( isOpen(pPager->fd)\n   && (pPager->eState>=PAGER_WRITER_DBMOD || pPager->eState==PAGER_OPEN)\n   && isSynced\n  ){\n    i64 ofst = (pgno-1)*(i64)pPager->pageSize;\n    testcase( !isSavepnt && pPg!=0 && (pPg->flags&PGHDR_NEED_SYNC)!=0 );\n    assert( !pagerUseWal(pPager) );\n\n    /* Write the data read from the journal back into the database file.\n    ** This is usually safe even for an encrypted database - as the data\n    ** was encrypted before it was written to the journal file. The exception\n    ** is if the data was just read from an in-memory sub-journal. In that\n    ** case it must be encrypted here before it is copied into the database\n    ** file.  */\n#ifdef SQLITE_HAS_CODEC\n    if( !jrnlEnc ){\n      CODEC2(pPager, aData, pgno, 7, rc=SQLITE_NOMEM_BKPT, aData);\n      rc = sqlite3OsWrite(pPager->fd, (u8 *)aData, pPager->pageSize, ofst);\n      CODEC1(pPager, aData, pgno, 3, rc=SQLITE_NOMEM_BKPT);\n    }else\n#endif\n    rc = sqlite3OsWrite(pPager->fd, (u8 *)aData, pPager->pageSize, ofst);\n\n    if( pgno>pPager->dbFileSize ){\n      pPager->dbFileSize = pgno;\n    }\n    if( pPager->pBackup ){\n#ifdef SQLITE_HAS_CODEC\n      if( jrnlEnc ){\n        CODEC1(pPager, aData, pgno, 3, rc=SQLITE_NOMEM_BKPT);\n        sqlite3BackupUpdate(pPager->pBackup, pgno, (u8*)aData);\n        CODEC2(pPager, aData, pgno, 7, rc=SQLITE_NOMEM_BKPT,aData);\n      }else\n#endif\n      sqlite3BackupUpdate(pPager->pBackup, pgno, (u8*)aData);\n    }\n  }else if( !isMainJrnl && pPg==0 ){\n    /* If this is a rollback of a savepoint and data was not written to\n    ** the database and the page is not in-memory, there is a potential\n    ** problem. When the page is next fetched by the b-tree layer, it \n    ** will be read from the database file, which may or may not be \n    ** current. \n    **\n    ** There are a couple of different ways this can happen. All are quite\n    ** obscure. When running in synchronous mode, this can only happen \n    ** if the page is on the free-list at the start of the transaction, then\n    ** populated, then moved using sqlite3PagerMovepage().\n    **\n    ** The solution is to add an in-memory page to the cache containing\n    ** the data just read from the sub-journal. Mark the page as dirty \n    ** and if the pager requires a journal-sync, then mark the page as \n    ** requiring a journal-sync before it is written.\n    */\n    assert( isSavepnt );\n    assert( (pPager->doNotSpill & SPILLFLAG_ROLLBACK)==0 );\n    pPager->doNotSpill |= SPILLFLAG_ROLLBACK;\n    rc = sqlite3PagerGet(pPager, pgno, &pPg, 1);\n    assert( (pPager->doNotSpill & SPILLFLAG_ROLLBACK)!=0 );\n    pPager->doNotSpill &= ~SPILLFLAG_ROLLBACK;\n    if( rc!=SQLITE_OK ) return rc;\n    sqlite3PcacheMakeDirty(pPg);\n  }\n  if( pPg ){\n    /* No page should ever be explicitly rolled back that is in use, except\n    ** for page 1 which is held in use in order to keep the lock on the\n    ** database active. However such a page may be rolled back as a result\n    ** of an internal error resulting in an automatic call to\n    ** sqlite3PagerRollback().\n    */\n    void *pData;\n    pData = pPg->pData;\n    memcpy(pData, (u8*)aData, pPager->pageSize);\n    pPager->xReiniter(pPg);\n    /* It used to be that sqlite3PcacheMakeClean(pPg) was called here.  But\n    ** that call was dangerous and had no detectable benefit since the cache\n    ** is normally cleaned by sqlite3PcacheCleanAll() after rollback and so\n    ** has been removed. */\n    pager_set_pagehash(pPg);\n\n    /* If this was page 1, then restore the value of Pager.dbFileVers.\n    ** Do this before any decoding. */\n    if( pgno==1 ){\n      memcpy(&pPager->dbFileVers, &((u8*)pData)[24],sizeof(pPager->dbFileVers));\n    }\n\n    /* Decode the page just read from disk */\n#if SQLITE_HAS_CODEC\n    if( jrnlEnc ){ CODEC1(pPager, pData, pPg->pgno, 3, rc=SQLITE_NOMEM_BKPT); }\n#endif\n    sqlite3PcacheRelease(pPg);\n  }\n  return rc;\n}\n\n/*\n** Parameter zMaster is the name of a master journal file. A single journal\n** file that referred to the master journal file has just been rolled back.\n** This routine checks if it is possible to delete the master journal file,\n** and does so if it is.\n**\n** Argument zMaster may point to Pager.pTmpSpace. So that buffer is not \n** available for use within this function.\n**\n** When a master journal file is created, it is populated with the names \n** of all of its child journals, one after another, formatted as utf-8 \n** encoded text. The end of each child journal file is marked with a \n** nul-terminator byte (0x00). i.e. the entire contents of a master journal\n** file for a transaction involving two databases might be:\n**\n**   \"/home/bill/a.db-journal\\x00/home/bill/b.db-journal\\x00\"\n**\n** A master journal file may only be deleted once all of its child \n** journals have been rolled back.\n**\n** This function reads the contents of the master-journal file into \n** memory and loops through each of the child journal names. For\n** each child journal, it checks if:\n**\n**   * if the child journal exists, and if so\n**   * if the child journal contains a reference to master journal \n**     file zMaster\n**\n** If a child journal can be found that matches both of the criteria\n** above, this function returns without doing anything. Otherwise, if\n** no such child journal can be found, file zMaster is deleted from\n** the file-system using sqlite3OsDelete().\n**\n** If an IO error within this function, an error code is returned. This\n** function allocates memory by calling sqlite3Malloc(). If an allocation\n** fails, SQLITE_NOMEM is returned. Otherwise, if no IO or malloc errors \n** occur, SQLITE_OK is returned.\n**\n** TODO: This function allocates a single block of memory to load\n** the entire contents of the master journal file. This could be\n** a couple of kilobytes or so - potentially larger than the page \n** size.\n*/\nstatic int pager_delmaster(Pager *pPager, const char *zMaster){\n  sqlite3_vfs *pVfs = pPager->pVfs;\n  int rc;                   /* Return code */\n  sqlite3_file *pMaster;    /* Malloc'd master-journal file descriptor */\n  sqlite3_file *pJournal;   /* Malloc'd child-journal file descriptor */\n  char *zMasterJournal = 0; /* Contents of master journal file */\n  i64 nMasterJournal;       /* Size of master journal file */\n  char *zJournal;           /* Pointer to one journal within MJ file */\n  char *zMasterPtr;         /* Space to hold MJ filename from a journal file */\n  int nMasterPtr;           /* Amount of space allocated to zMasterPtr[] */\n\n  /* Allocate space for both the pJournal and pMaster file descriptors.\n  ** If successful, open the master journal file for reading.\n  */\n  pMaster = (sqlite3_file *)sqlite3MallocZero(pVfs->szOsFile * 2);\n  pJournal = (sqlite3_file *)(((u8 *)pMaster) + pVfs->szOsFile);\n  if( !pMaster ){\n    rc = SQLITE_NOMEM_BKPT;\n  }else{\n    const int flags = (SQLITE_OPEN_READONLY|SQLITE_OPEN_MASTER_JOURNAL);\n    rc = sqlite3OsOpen(pVfs, zMaster, pMaster, flags, 0);\n  }\n  if( rc!=SQLITE_OK ) goto delmaster_out;\n\n  /* Load the entire master journal file into space obtained from\n  ** sqlite3_malloc() and pointed to by zMasterJournal.   Also obtain\n  ** sufficient space (in zMasterPtr) to hold the names of master\n  ** journal files extracted from regular rollback-journals.\n  */\n  rc = sqlite3OsFileSize(pMaster, &nMasterJournal);\n  if( rc!=SQLITE_OK ) goto delmaster_out;\n  nMasterPtr = pVfs->mxPathname+1;\n  zMasterJournal = sqlite3Malloc(nMasterJournal + nMasterPtr + 1);\n  if( !zMasterJournal ){\n    rc = SQLITE_NOMEM_BKPT;\n    goto delmaster_out;\n  }\n  zMasterPtr = &zMasterJournal[nMasterJournal+1];\n  rc = sqlite3OsRead(pMaster, zMasterJournal, (int)nMasterJournal, 0);\n  if( rc!=SQLITE_OK ) goto delmaster_out;\n  zMasterJournal[nMasterJournal] = 0;\n\n  zJournal = zMasterJournal;\n  while( (zJournal-zMasterJournal)<nMasterJournal ){\n    int exists;\n    rc = sqlite3OsAccess(pVfs, zJournal, SQLITE_ACCESS_EXISTS, &exists);\n    if( rc!=SQLITE_OK ){\n      goto delmaster_out;\n    }\n    if( exists ){\n      /* One of the journals pointed to by the master journal exists.\n      ** Open it and check if it points at the master journal. If\n      ** so, return without deleting the master journal file.\n      */\n      int c;\n      int flags = (SQLITE_OPEN_READONLY|SQLITE_OPEN_MAIN_JOURNAL);\n      rc = sqlite3OsOpen(pVfs, zJournal, pJournal, flags, 0);\n      if( rc!=SQLITE_OK ){\n        goto delmaster_out;\n      }\n\n      rc = readMasterJournal(pJournal, zMasterPtr, nMasterPtr);\n      sqlite3OsClose(pJournal);\n      if( rc!=SQLITE_OK ){\n        goto delmaster_out;\n      }\n\n      c = zMasterPtr[0]!=0 && strcmp(zMasterPtr, zMaster)==0;\n      if( c ){\n        /* We have a match. Do not delete the master journal file. */\n        goto delmaster_out;\n      }\n    }\n    zJournal += (sqlite3Strlen30(zJournal)+1);\n  }\n \n  sqlite3OsClose(pMaster);\n  rc = sqlite3OsDelete(pVfs, zMaster, 0);\n\ndelmaster_out:\n  sqlite3_free(zMasterJournal);\n  if( pMaster ){\n    sqlite3OsClose(pMaster);\n    assert( !isOpen(pJournal) );\n    sqlite3_free(pMaster);\n  }\n  return rc;\n}\n\n\n/*\n** This function is used to change the actual size of the database \n** file in the file-system. This only happens when committing a transaction,\n** or rolling back a transaction (including rolling back a hot-journal).\n**\n** If the main database file is not open, or the pager is not in either\n** DBMOD or OPEN state, this function is a no-op. Otherwise, the size \n** of the file is changed to nPage pages (nPage*pPager->pageSize bytes). \n** If the file on disk is currently larger than nPage pages, then use the VFS\n** xTruncate() method to truncate it.\n**\n** Or, it might be the case that the file on disk is smaller than \n** nPage pages. Some operating system implementations can get confused if \n** you try to truncate a file to some size that is larger than it \n** currently is, so detect this case and write a single zero byte to \n** the end of the new file instead.\n**\n** If successful, return SQLITE_OK. If an IO error occurs while modifying\n** the database file, return the error code to the caller.\n*/\nstatic int pager_truncate(Pager *pPager, Pgno nPage){\n  int rc = SQLITE_OK;\n  assert( pPager->eState!=PAGER_ERROR );\n  assert( pPager->eState!=PAGER_READER );\n  \n  if( isOpen(pPager->fd) \n   && (pPager->eState>=PAGER_WRITER_DBMOD || pPager->eState==PAGER_OPEN) \n  ){\n    i64 currentSize, newSize;\n    int szPage = pPager->pageSize;\n    assert( pPager->eLock==EXCLUSIVE_LOCK );\n    /* TODO: Is it safe to use Pager.dbFileSize here? */\n    rc = sqlite3OsFileSize(pPager->fd, &currentSize);\n    newSize = szPage*(i64)nPage;\n    if( rc==SQLITE_OK && currentSize!=newSize ){\n      if( currentSize>newSize ){\n        rc = sqlite3OsTruncate(pPager->fd, newSize);\n      }else if( (currentSize+szPage)<=newSize ){\n        char *pTmp = pPager->pTmpSpace;\n        memset(pTmp, 0, szPage);\n        testcase( (newSize-szPage) == currentSize );\n        testcase( (newSize-szPage) >  currentSize );\n        rc = sqlite3OsWrite(pPager->fd, pTmp, szPage, newSize-szPage);\n      }\n      if( rc==SQLITE_OK ){\n        pPager->dbFileSize = nPage;\n      }\n    }\n  }\n  return rc;\n}\n\n/*\n** Return a sanitized version of the sector-size of OS file pFile. The\n** return value is guaranteed to lie between 32 and MAX_SECTOR_SIZE.\n*/\nSQLITE_PRIVATE int sqlite3SectorSize(sqlite3_file *pFile){\n  int iRet = sqlite3OsSectorSize(pFile);\n  if( iRet<32 ){\n    iRet = 512;\n  }else if( iRet>MAX_SECTOR_SIZE ){\n    assert( MAX_SECTOR_SIZE>=512 );\n    iRet = MAX_SECTOR_SIZE;\n  }\n  return iRet;\n}\n\n/*\n** Set the value of the Pager.sectorSize variable for the given\n** pager based on the value returned by the xSectorSize method\n** of the open database file. The sector size will be used \n** to determine the size and alignment of journal header and \n** master journal pointers within created journal files.\n**\n** For temporary files the effective sector size is always 512 bytes.\n**\n** Otherwise, for non-temporary files, the effective sector size is\n** the value returned by the xSectorSize() method rounded up to 32 if\n** it is less than 32, or rounded down to MAX_SECTOR_SIZE if it\n** is greater than MAX_SECTOR_SIZE.\n**\n** If the file has the SQLITE_IOCAP_POWERSAFE_OVERWRITE property, then set\n** the effective sector size to its minimum value (512).  The purpose of\n** pPager->sectorSize is to define the \"blast radius\" of bytes that\n** might change if a crash occurs while writing to a single byte in\n** that range.  But with POWERSAFE_OVERWRITE, the blast radius is zero\n** (that is what POWERSAFE_OVERWRITE means), so we minimize the sector\n** size.  For backwards compatibility of the rollback journal file format,\n** we cannot reduce the effective sector size below 512.\n*/\nstatic void setSectorSize(Pager *pPager){\n  assert( isOpen(pPager->fd) || pPager->tempFile );\n\n  if( pPager->tempFile\n   || (sqlite3OsDeviceCharacteristics(pPager->fd) & \n              SQLITE_IOCAP_POWERSAFE_OVERWRITE)!=0\n  ){\n    /* Sector size doesn't matter for temporary files. Also, the file\n    ** may not have been opened yet, in which case the OsSectorSize()\n    ** call will segfault. */\n    pPager->sectorSize = 512;\n  }else{\n    pPager->sectorSize = sqlite3SectorSize(pPager->fd);\n  }\n}\n\n/*\n** Playback the journal and thus restore the database file to\n** the state it was in before we started making changes.  \n**\n** The journal file format is as follows: \n**\n**  (1)  8 byte prefix.  A copy of aJournalMagic[].\n**  (2)  4 byte big-endian integer which is the number of valid page records\n**       in the journal.  If this value is 0xffffffff, then compute the\n**       number of page records from the journal size.\n**  (3)  4 byte big-endian integer which is the initial value for the \n**       sanity checksum.\n**  (4)  4 byte integer which is the number of pages to truncate the\n**       database to during a rollback.\n**  (5)  4 byte big-endian integer which is the sector size.  The header\n**       is this many bytes in size.\n**  (6)  4 byte big-endian integer which is the page size.\n**  (7)  zero padding out to the next sector size.\n**  (8)  Zero or more pages instances, each as follows:\n**        +  4 byte page number.\n**        +  pPager->pageSize bytes of data.\n**        +  4 byte checksum\n**\n** When we speak of the journal header, we mean the first 7 items above.\n** Each entry in the journal is an instance of the 8th item.\n**\n** Call the value from the second bullet \"nRec\".  nRec is the number of\n** valid page entries in the journal.  In most cases, you can compute the\n** value of nRec from the size of the journal file.  But if a power\n** failure occurred while the journal was being written, it could be the\n** case that the size of the journal file had already been increased but\n** the extra entries had not yet made it safely to disk.  In such a case,\n** the value of nRec computed from the file size would be too large.  For\n** that reason, we always use the nRec value in the header.\n**\n** If the nRec value is 0xffffffff it means that nRec should be computed\n** from the file size.  This value is used when the user selects the\n** no-sync option for the journal.  A power failure could lead to corruption\n** in this case.  But for things like temporary table (which will be\n** deleted when the power is restored) we don't care.  \n**\n** If the file opened as the journal file is not a well-formed\n** journal file then all pages up to the first corrupted page are rolled\n** back (or no pages if the journal header is corrupted). The journal file\n** is then deleted and SQLITE_OK returned, just as if no corruption had\n** been encountered.\n**\n** If an I/O or malloc() error occurs, the journal-file is not deleted\n** and an error code is returned.\n**\n** The isHot parameter indicates that we are trying to rollback a journal\n** that might be a hot journal.  Or, it could be that the journal is \n** preserved because of JOURNALMODE_PERSIST or JOURNALMODE_TRUNCATE.\n** If the journal really is hot, reset the pager cache prior rolling\n** back any content.  If the journal is merely persistent, no reset is\n** needed.\n*/\nstatic int pager_playback(Pager *pPager, int isHot){\n  sqlite3_vfs *pVfs = pPager->pVfs;\n  i64 szJ;                 /* Size of the journal file in bytes */\n  u32 nRec;                /* Number of Records in the journal */\n  u32 u;                   /* Unsigned loop counter */\n  Pgno mxPg = 0;           /* Size of the original file in pages */\n  int rc;                  /* Result code of a subroutine */\n  int res = 1;             /* Value returned by sqlite3OsAccess() */\n  char *zMaster = 0;       /* Name of master journal file if any */\n  int needPagerReset;      /* True to reset page prior to first page rollback */\n  int nPlayback = 0;       /* Total number of pages restored from journal */\n  u32 savedPageSize = pPager->pageSize;\n\n  /* Figure out how many records are in the journal.  Abort early if\n  ** the journal is empty.\n  */\n  assert( isOpen(pPager->jfd) );\n  rc = sqlite3OsFileSize(pPager->jfd, &szJ);\n  if( rc!=SQLITE_OK ){\n    goto end_playback;\n  }\n\n  /* Read the master journal name from the journal, if it is present.\n  ** If a master journal file name is specified, but the file is not\n  ** present on disk, then the journal is not hot and does not need to be\n  ** played back.\n  **\n  ** TODO: Technically the following is an error because it assumes that\n  ** buffer Pager.pTmpSpace is (mxPathname+1) bytes or larger. i.e. that\n  ** (pPager->pageSize >= pPager->pVfs->mxPathname+1). Using os_unix.c,\n  ** mxPathname is 512, which is the same as the minimum allowable value\n  ** for pageSize.\n  */\n  zMaster = pPager->pTmpSpace;\n  rc = readMasterJournal(pPager->jfd, zMaster, pPager->pVfs->mxPathname+1);\n  if( rc==SQLITE_OK && zMaster[0] ){\n    rc = sqlite3OsAccess(pVfs, zMaster, SQLITE_ACCESS_EXISTS, &res);\n  }\n  zMaster = 0;\n  if( rc!=SQLITE_OK || !res ){\n    goto end_playback;\n  }\n  pPager->journalOff = 0;\n  needPagerReset = isHot;\n\n  /* This loop terminates either when a readJournalHdr() or \n  ** pager_playback_one_page() call returns SQLITE_DONE or an IO error \n  ** occurs. \n  */\n  while( 1 ){\n    /* Read the next journal header from the journal file.  If there are\n    ** not enough bytes left in the journal file for a complete header, or\n    ** it is corrupted, then a process must have failed while writing it.\n    ** This indicates nothing more needs to be rolled back.\n    */\n    rc = readJournalHdr(pPager, isHot, szJ, &nRec, &mxPg);\n    if( rc!=SQLITE_OK ){ \n      if( rc==SQLITE_DONE ){\n        rc = SQLITE_OK;\n      }\n      goto end_playback;\n    }\n\n    /* If nRec is 0xffffffff, then this journal was created by a process\n    ** working in no-sync mode. This means that the rest of the journal\n    ** file consists of pages, there are no more journal headers. Compute\n    ** the value of nRec based on this assumption.\n    */\n    if( nRec==0xffffffff ){\n      assert( pPager->journalOff==JOURNAL_HDR_SZ(pPager) );\n      nRec = (int)((szJ - JOURNAL_HDR_SZ(pPager))/JOURNAL_PG_SZ(pPager));\n    }\n\n    /* If nRec is 0 and this rollback is of a transaction created by this\n    ** process and if this is the final header in the journal, then it means\n    ** that this part of the journal was being filled but has not yet been\n    ** synced to disk.  Compute the number of pages based on the remaining\n    ** size of the file.\n    **\n    ** The third term of the test was added to fix ticket #2565.\n    ** When rolling back a hot journal, nRec==0 always means that the next\n    ** chunk of the journal contains zero pages to be rolled back.  But\n    ** when doing a ROLLBACK and the nRec==0 chunk is the last chunk in\n    ** the journal, it means that the journal might contain additional\n    ** pages that need to be rolled back and that the number of pages \n    ** should be computed based on the journal file size.\n    */\n    if( nRec==0 && !isHot &&\n        pPager->journalHdr+JOURNAL_HDR_SZ(pPager)==pPager->journalOff ){\n      nRec = (int)((szJ - pPager->journalOff) / JOURNAL_PG_SZ(pPager));\n    }\n\n    /* If this is the first header read from the journal, truncate the\n    ** database file back to its original size.\n    */\n    if( pPager->journalOff==JOURNAL_HDR_SZ(pPager) ){\n      rc = pager_truncate(pPager, mxPg);\n      if( rc!=SQLITE_OK ){\n        goto end_playback;\n      }\n      pPager->dbSize = mxPg;\n    }\n\n    /* Copy original pages out of the journal and back into the \n    ** database file and/or page cache.\n    */\n    for(u=0; u<nRec; u++){\n      if( needPagerReset ){\n        pager_reset(pPager);\n        needPagerReset = 0;\n      }\n      rc = pager_playback_one_page(pPager,&pPager->journalOff,0,1,0);\n      if( rc==SQLITE_OK ){\n        nPlayback++;\n      }else{\n        if( rc==SQLITE_DONE ){\n          pPager->journalOff = szJ;\n          break;\n        }else if( rc==SQLITE_IOERR_SHORT_READ ){\n          /* If the journal has been truncated, simply stop reading and\n          ** processing the journal. This might happen if the journal was\n          ** not completely written and synced prior to a crash.  In that\n          ** case, the database should have never been written in the\n          ** first place so it is OK to simply abandon the rollback. */\n          rc = SQLITE_OK;\n          goto end_playback;\n        }else{\n          /* If we are unable to rollback, quit and return the error\n          ** code.  This will cause the pager to enter the error state\n          ** so that no further harm will be done.  Perhaps the next\n          ** process to come along will be able to rollback the database.\n          */\n          goto end_playback;\n        }\n      }\n    }\n  }\n  /*NOTREACHED*/\n  assert( 0 );\n\nend_playback:\n  if( rc==SQLITE_OK ){\n    rc = sqlite3PagerSetPagesize(pPager, &savedPageSize, -1);\n  }\n  /* Following a rollback, the database file should be back in its original\n  ** state prior to the start of the transaction, so invoke the\n  ** SQLITE_FCNTL_DB_UNCHANGED file-control method to disable the\n  ** assertion that the transaction counter was modified.\n  */\n#ifdef SQLITE_DEBUG\n  sqlite3OsFileControlHint(pPager->fd,SQLITE_FCNTL_DB_UNCHANGED,0);\n#endif\n\n  /* If this playback is happening automatically as a result of an IO or \n  ** malloc error that occurred after the change-counter was updated but \n  ** before the transaction was committed, then the change-counter \n  ** modification may just have been reverted. If this happens in exclusive \n  ** mode, then subsequent transactions performed by the connection will not\n  ** update the change-counter at all. This may lead to cache inconsistency\n  ** problems for other processes at some point in the future. So, just\n  ** in case this has happened, clear the changeCountDone flag now.\n  */\n  pPager->changeCountDone = pPager->tempFile;\n\n  if( rc==SQLITE_OK ){\n    zMaster = pPager->pTmpSpace;\n    rc = readMasterJournal(pPager->jfd, zMaster, pPager->pVfs->mxPathname+1);\n    testcase( rc!=SQLITE_OK );\n  }\n  if( rc==SQLITE_OK\n   && (pPager->eState>=PAGER_WRITER_DBMOD || pPager->eState==PAGER_OPEN)\n  ){\n    rc = sqlite3PagerSync(pPager, 0);\n  }\n  if( rc==SQLITE_OK ){\n    rc = pager_end_transaction(pPager, zMaster[0]!='\\0', 0);\n    testcase( rc!=SQLITE_OK );\n  }\n  if( rc==SQLITE_OK && zMaster[0] && res ){\n    /* If there was a master journal and this routine will return success,\n    ** see if it is possible to delete the master journal.\n    */\n    rc = pager_delmaster(pPager, zMaster);\n    testcase( rc!=SQLITE_OK );\n  }\n  if( isHot && nPlayback ){\n    sqlite3_log(SQLITE_NOTICE_RECOVER_ROLLBACK, \"recovered %d pages from %s\",\n                nPlayback, pPager->zJournal);\n  }\n\n  /* The Pager.sectorSize variable may have been updated while rolling\n  ** back a journal created by a process with a different sector size\n  ** value. Reset it to the correct value for this process.\n  */\n  setSectorSize(pPager);\n  return rc;\n}\n\n\n/*\n** Read the content for page pPg out of the database file (or out of\n** the WAL if that is where the most recent copy if found) into \n** pPg->pData. A shared lock or greater must be held on the database\n** file before this function is called.\n**\n** If page 1 is read, then the value of Pager.dbFileVers[] is set to\n** the value read from the database file.\n**\n** If an IO error occurs, then the IO error is returned to the caller.\n** Otherwise, SQLITE_OK is returned.\n*/\nstatic int readDbPage(PgHdr *pPg){\n  Pager *pPager = pPg->pPager; /* Pager object associated with page pPg */\n  int rc = SQLITE_OK;          /* Return code */\n\n#ifndef SQLITE_OMIT_WAL\n  u32 iFrame = 0;              /* Frame of WAL containing pgno */\n\n  assert( pPager->eState>=PAGER_READER && !MEMDB );\n  assert( isOpen(pPager->fd) );\n\n  if( pagerUseWal(pPager) ){\n    rc = sqlite3WalFindFrame(pPager->pWal, pPg->pgno, &iFrame);\n    if( rc ) return rc;\n  }\n  if( iFrame ){\n    rc = sqlite3WalReadFrame(pPager->pWal, iFrame,pPager->pageSize,pPg->pData);\n  }else\n#endif\n  {\n    i64 iOffset = (pPg->pgno-1)*(i64)pPager->pageSize;\n    rc = sqlite3OsRead(pPager->fd, pPg->pData, pPager->pageSize, iOffset);\n    if( rc==SQLITE_IOERR_SHORT_READ ){\n      rc = SQLITE_OK;\n    }\n  }\n\n  if( pPg->pgno==1 ){\n    if( rc ){\n      /* If the read is unsuccessful, set the dbFileVers[] to something\n      ** that will never be a valid file version.  dbFileVers[] is a copy\n      ** of bytes 24..39 of the database.  Bytes 28..31 should always be\n      ** zero or the size of the database in page. Bytes 32..35 and 35..39\n      ** should be page numbers which are never 0xffffffff.  So filling\n      ** pPager->dbFileVers[] with all 0xff bytes should suffice.\n      **\n      ** For an encrypted database, the situation is more complex:  bytes\n      ** 24..39 of the database are white noise.  But the probability of\n      ** white noise equaling 16 bytes of 0xff is vanishingly small so\n      ** we should still be ok.\n      */\n      memset(pPager->dbFileVers, 0xff, sizeof(pPager->dbFileVers));\n    }else{\n      u8 *dbFileVers = &((u8*)pPg->pData)[24];\n      memcpy(&pPager->dbFileVers, dbFileVers, sizeof(pPager->dbFileVers));\n    }\n  }\n  CODEC1(pPager, pPg->pData, pPg->pgno, 3, rc = SQLITE_NOMEM_BKPT);\n\n  PAGER_INCR(sqlite3_pager_readdb_count);\n  PAGER_INCR(pPager->nRead);\n  IOTRACE((\"PGIN %p %d\\n\", pPager, pPg->pgno));\n  PAGERTRACE((\"FETCH %d page %d hash(%08x)\\n\",\n               PAGERID(pPager), pPg->pgno, pager_pagehash(pPg)));\n\n  return rc;\n}\n\n/*\n** Update the value of the change-counter at offsets 24 and 92 in\n** the header and the sqlite version number at offset 96.\n**\n** This is an unconditional update.  See also the pager_incr_changecounter()\n** routine which only updates the change-counter if the update is actually\n** needed, as determined by the pPager->changeCountDone state variable.\n*/\nstatic void pager_write_changecounter(PgHdr *pPg){\n  u32 change_counter;\n\n  /* Increment the value just read and write it back to byte 24. */\n  change_counter = sqlite3Get4byte((u8*)pPg->pPager->dbFileVers)+1;\n  put32bits(((char*)pPg->pData)+24, change_counter);\n\n  /* Also store the SQLite version number in bytes 96..99 and in\n  ** bytes 92..95 store the change counter for which the version number\n  ** is valid. */\n  put32bits(((char*)pPg->pData)+92, change_counter);\n  put32bits(((char*)pPg->pData)+96, SQLITE_VERSION_NUMBER);\n}\n\n#ifndef SQLITE_OMIT_WAL\n/*\n** This function is invoked once for each page that has already been \n** written into the log file when a WAL transaction is rolled back.\n** Parameter iPg is the page number of said page. The pCtx argument \n** is actually a pointer to the Pager structure.\n**\n** If page iPg is present in the cache, and has no outstanding references,\n** it is discarded. Otherwise, if there are one or more outstanding\n** references, the page content is reloaded from the database. If the\n** attempt to reload content from the database is required and fails, \n** return an SQLite error code. Otherwise, SQLITE_OK.\n*/\nstatic int pagerUndoCallback(void *pCtx, Pgno iPg){\n  int rc = SQLITE_OK;\n  Pager *pPager = (Pager *)pCtx;\n  PgHdr *pPg;\n\n  assert( pagerUseWal(pPager) );\n  pPg = sqlite3PagerLookup(pPager, iPg);\n  if( pPg ){\n    if( sqlite3PcachePageRefcount(pPg)==1 ){\n      sqlite3PcacheDrop(pPg);\n    }else{\n      rc = readDbPage(pPg);\n      if( rc==SQLITE_OK ){\n        pPager->xReiniter(pPg);\n      }\n      sqlite3PagerUnrefNotNull(pPg);\n    }\n  }\n\n  /* Normally, if a transaction is rolled back, any backup processes are\n  ** updated as data is copied out of the rollback journal and into the\n  ** database. This is not generally possible with a WAL database, as\n  ** rollback involves simply truncating the log file. Therefore, if one\n  ** or more frames have already been written to the log (and therefore \n  ** also copied into the backup databases) as part of this transaction,\n  ** the backups must be restarted.\n  */\n  sqlite3BackupRestart(pPager->pBackup);\n\n  return rc;\n}\n\n/*\n** This function is called to rollback a transaction on a WAL database.\n*/\nstatic int pagerRollbackWal(Pager *pPager){\n  int rc;                         /* Return Code */\n  PgHdr *pList;                   /* List of dirty pages to revert */\n\n  /* For all pages in the cache that are currently dirty or have already\n  ** been written (but not committed) to the log file, do one of the \n  ** following:\n  **\n  **   + Discard the cached page (if refcount==0), or\n  **   + Reload page content from the database (if refcount>0).\n  */\n  pPager->dbSize = pPager->dbOrigSize;\n  rc = sqlite3WalUndo(pPager->pWal, pagerUndoCallback, (void *)pPager);\n  pList = sqlite3PcacheDirtyList(pPager->pPCache);\n  while( pList && rc==SQLITE_OK ){\n    PgHdr *pNext = pList->pDirty;\n    rc = pagerUndoCallback((void *)pPager, pList->pgno);\n    pList = pNext;\n  }\n\n  return rc;\n}\n\n/*\n** This function is a wrapper around sqlite3WalFrames(). As well as logging\n** the contents of the list of pages headed by pList (connected by pDirty),\n** this function notifies any active backup processes that the pages have\n** changed. \n**\n** The list of pages passed into this routine is always sorted by page number.\n** Hence, if page 1 appears anywhere on the list, it will be the first page.\n*/ \nstatic int pagerWalFrames(\n  Pager *pPager,                  /* Pager object */\n  PgHdr *pList,                   /* List of frames to log */\n  Pgno nTruncate,                 /* Database size after this commit */\n  int isCommit                    /* True if this is a commit */\n){\n  int rc;                         /* Return code */\n  int nList;                      /* Number of pages in pList */\n  PgHdr *p;                       /* For looping over pages */\n\n  assert( pPager->pWal );\n  assert( pList );\n#ifdef SQLITE_DEBUG\n  /* Verify that the page list is in accending order */\n  for(p=pList; p && p->pDirty; p=p->pDirty){\n    assert( p->pgno < p->pDirty->pgno );\n  }\n#endif\n\n  assert( pList->pDirty==0 || isCommit );\n  if( isCommit ){\n    /* If a WAL transaction is being committed, there is no point in writing\n    ** any pages with page numbers greater than nTruncate into the WAL file.\n    ** They will never be read by any client. So remove them from the pDirty\n    ** list here. */\n    PgHdr **ppNext = &pList;\n    nList = 0;\n    for(p=pList; (*ppNext = p)!=0; p=p->pDirty){\n      if( p->pgno<=nTruncate ){\n        ppNext = &p->pDirty;\n        nList++;\n      }\n    }\n    assert( pList );\n  }else{\n    nList = 1;\n  }\n  pPager->aStat[PAGER_STAT_WRITE] += nList;\n\n  if( pList->pgno==1 ) pager_write_changecounter(pList);\n  rc = sqlite3WalFrames(pPager->pWal, \n      pPager->pageSize, pList, nTruncate, isCommit, pPager->walSyncFlags\n  );\n  if( rc==SQLITE_OK && pPager->pBackup ){\n    for(p=pList; p; p=p->pDirty){\n      sqlite3BackupUpdate(pPager->pBackup, p->pgno, (u8 *)p->pData);\n    }\n  }\n\n#ifdef SQLITE_CHECK_PAGES\n  pList = sqlite3PcacheDirtyList(pPager->pPCache);\n  for(p=pList; p; p=p->pDirty){\n    pager_set_pagehash(p);\n  }\n#endif\n\n  return rc;\n}\n\n/*\n** Begin a read transaction on the WAL.\n**\n** This routine used to be called \"pagerOpenSnapshot()\" because it essentially\n** makes a snapshot of the database at the current point in time and preserves\n** that snapshot for use by the reader in spite of concurrently changes by\n** other writers or checkpointers.\n*/\nstatic int pagerBeginReadTransaction(Pager *pPager){\n  int rc;                         /* Return code */\n  int changed = 0;                /* True if cache must be reset */\n\n  assert( pagerUseWal(pPager) );\n  assert( pPager->eState==PAGER_OPEN || pPager->eState==PAGER_READER );\n\n  /* sqlite3WalEndReadTransaction() was not called for the previous\n  ** transaction in locking_mode=EXCLUSIVE.  So call it now.  If we\n  ** are in locking_mode=NORMAL and EndRead() was previously called,\n  ** the duplicate call is harmless.\n  */\n  sqlite3WalEndReadTransaction(pPager->pWal);\n\n  rc = sqlite3WalBeginReadTransaction(pPager->pWal, &changed);\n  if( rc!=SQLITE_OK || changed ){\n    pager_reset(pPager);\n    if( USEFETCH(pPager) ) sqlite3OsUnfetch(pPager->fd, 0, 0);\n  }\n\n  return rc;\n}\n#endif\n\n/*\n** This function is called as part of the transition from PAGER_OPEN\n** to PAGER_READER state to determine the size of the database file\n** in pages (assuming the page size currently stored in Pager.pageSize).\n**\n** If no error occurs, SQLITE_OK is returned and the size of the database\n** in pages is stored in *pnPage. Otherwise, an error code (perhaps\n** SQLITE_IOERR_FSTAT) is returned and *pnPage is left unmodified.\n*/\nstatic int pagerPagecount(Pager *pPager, Pgno *pnPage){\n  Pgno nPage;                     /* Value to return via *pnPage */\n\n  /* Query the WAL sub-system for the database size. The WalDbsize()\n  ** function returns zero if the WAL is not open (i.e. Pager.pWal==0), or\n  ** if the database size is not available. The database size is not\n  ** available from the WAL sub-system if the log file is empty or\n  ** contains no valid committed transactions.\n  */\n  assert( pPager->eState==PAGER_OPEN );\n  assert( pPager->eLock>=SHARED_LOCK );\n  assert( isOpen(pPager->fd) );\n  assert( pPager->tempFile==0 );\n  nPage = sqlite3WalDbsize(pPager->pWal);\n\n  /* If the number of pages in the database is not available from the\n  ** WAL sub-system, determine the page count based on the size of\n  ** the database file.  If the size of the database file is not an\n  ** integer multiple of the page-size, round up the result.\n  */\n  if( nPage==0 && ALWAYS(isOpen(pPager->fd)) ){\n    i64 n = 0;                    /* Size of db file in bytes */\n    int rc = sqlite3OsFileSize(pPager->fd, &n);\n    if( rc!=SQLITE_OK ){\n      return rc;\n    }\n    nPage = (Pgno)((n+pPager->pageSize-1) / pPager->pageSize);\n  }\n\n  /* If the current number of pages in the file is greater than the\n  ** configured maximum pager number, increase the allowed limit so\n  ** that the file can be read.\n  */\n  if( nPage>pPager->mxPgno ){\n    pPager->mxPgno = (Pgno)nPage;\n  }\n\n  *pnPage = nPage;\n  return SQLITE_OK;\n}\n\n#ifndef SQLITE_OMIT_WAL\n/*\n** Check if the *-wal file that corresponds to the database opened by pPager\n** exists if the database is not empy, or verify that the *-wal file does\n** not exist (by deleting it) if the database file is empty.\n**\n** If the database is not empty and the *-wal file exists, open the pager\n** in WAL mode.  If the database is empty or if no *-wal file exists and\n** if no error occurs, make sure Pager.journalMode is not set to\n** PAGER_JOURNALMODE_WAL.\n**\n** Return SQLITE_OK or an error code.\n**\n** The caller must hold a SHARED lock on the database file to call this\n** function. Because an EXCLUSIVE lock on the db file is required to delete \n** a WAL on a none-empty database, this ensures there is no race condition \n** between the xAccess() below and an xDelete() being executed by some \n** other connection.\n*/\nstatic int pagerOpenWalIfPresent(Pager *pPager){\n  int rc = SQLITE_OK;\n  assert( pPager->eState==PAGER_OPEN );\n  assert( pPager->eLock>=SHARED_LOCK );\n\n  if( !pPager->tempFile ){\n    int isWal;                    /* True if WAL file exists */\n    rc = sqlite3OsAccess(\n        pPager->pVfs, pPager->zWal, SQLITE_ACCESS_EXISTS, &isWal\n    );\n    if( rc==SQLITE_OK ){\n      if( isWal ){\n        Pgno nPage;                   /* Size of the database file */\n\n        rc = pagerPagecount(pPager, &nPage);\n        if( rc ) return rc;\n        if( nPage==0 ){\n          rc = sqlite3OsDelete(pPager->pVfs, pPager->zWal, 0);\n        }else{\n          testcase( sqlite3PcachePagecount(pPager->pPCache)==0 );\n          rc = sqlite3PagerOpenWal(pPager, 0);\n        }\n      }else if( pPager->journalMode==PAGER_JOURNALMODE_WAL ){\n        pPager->journalMode = PAGER_JOURNALMODE_DELETE;\n      }\n    }\n  }\n  return rc;\n}\n#endif\n\n/*\n** Playback savepoint pSavepoint. Or, if pSavepoint==NULL, then playback\n** the entire master journal file. The case pSavepoint==NULL occurs when \n** a ROLLBACK TO command is invoked on a SAVEPOINT that is a transaction \n** savepoint.\n**\n** When pSavepoint is not NULL (meaning a non-transaction savepoint is \n** being rolled back), then the rollback consists of up to three stages,\n** performed in the order specified:\n**\n**   * Pages are played back from the main journal starting at byte\n**     offset PagerSavepoint.iOffset and continuing to \n**     PagerSavepoint.iHdrOffset, or to the end of the main journal\n**     file if PagerSavepoint.iHdrOffset is zero.\n**\n**   * If PagerSavepoint.iHdrOffset is not zero, then pages are played\n**     back starting from the journal header immediately following \n**     PagerSavepoint.iHdrOffset to the end of the main journal file.\n**\n**   * Pages are then played back from the sub-journal file, starting\n**     with the PagerSavepoint.iSubRec and continuing to the end of\n**     the journal file.\n**\n** Throughout the rollback process, each time a page is rolled back, the\n** corresponding bit is set in a bitvec structure (variable pDone in the\n** implementation below). This is used to ensure that a page is only\n** rolled back the first time it is encountered in either journal.\n**\n** If pSavepoint is NULL, then pages are only played back from the main\n** journal file. There is no need for a bitvec in this case.\n**\n** In either case, before playback commences the Pager.dbSize variable\n** is reset to the value that it held at the start of the savepoint \n** (or transaction). No page with a page-number greater than this value\n** is played back. If one is encountered it is simply skipped.\n*/\nstatic int pagerPlaybackSavepoint(Pager *pPager, PagerSavepoint *pSavepoint){\n  i64 szJ;                 /* Effective size of the main journal */\n  i64 iHdrOff;             /* End of first segment of main-journal records */\n  int rc = SQLITE_OK;      /* Return code */\n  Bitvec *pDone = 0;       /* Bitvec to ensure pages played back only once */\n\n  assert( pPager->eState!=PAGER_ERROR );\n  assert( pPager->eState>=PAGER_WRITER_LOCKED );\n\n  /* Allocate a bitvec to use to store the set of pages rolled back */\n  if( pSavepoint ){\n    pDone = sqlite3BitvecCreate(pSavepoint->nOrig);\n    if( !pDone ){\n      return SQLITE_NOMEM_BKPT;\n    }\n  }\n\n  /* Set the database size back to the value it was before the savepoint \n  ** being reverted was opened.\n  */\n  pPager->dbSize = pSavepoint ? pSavepoint->nOrig : pPager->dbOrigSize;\n  pPager->changeCountDone = pPager->tempFile;\n\n  if( !pSavepoint && pagerUseWal(pPager) ){\n    return pagerRollbackWal(pPager);\n  }\n\n  /* Use pPager->journalOff as the effective size of the main rollback\n  ** journal.  The actual file might be larger than this in\n  ** PAGER_JOURNALMODE_TRUNCATE or PAGER_JOURNALMODE_PERSIST.  But anything\n  ** past pPager->journalOff is off-limits to us.\n  */\n  szJ = pPager->journalOff;\n  assert( pagerUseWal(pPager)==0 || szJ==0 );\n\n  /* Begin by rolling back records from the main journal starting at\n  ** PagerSavepoint.iOffset and continuing to the next journal header.\n  ** There might be records in the main journal that have a page number\n  ** greater than the current database size (pPager->dbSize) but those\n  ** will be skipped automatically.  Pages are added to pDone as they\n  ** are played back.\n  */\n  if( pSavepoint && !pagerUseWal(pPager) ){\n    iHdrOff = pSavepoint->iHdrOffset ? pSavepoint->iHdrOffset : szJ;\n    pPager->journalOff = pSavepoint->iOffset;\n    while( rc==SQLITE_OK && pPager->journalOff<iHdrOff ){\n      rc = pager_playback_one_page(pPager, &pPager->journalOff, pDone, 1, 1);\n    }\n    assert( rc!=SQLITE_DONE );\n  }else{\n    pPager->journalOff = 0;\n  }\n\n  /* Continue rolling back records out of the main journal starting at\n  ** the first journal header seen and continuing until the effective end\n  ** of the main journal file.  Continue to skip out-of-range pages and\n  ** continue adding pages rolled back to pDone.\n  */\n  while( rc==SQLITE_OK && pPager->journalOff<szJ ){\n    u32 ii;            /* Loop counter */\n    u32 nJRec = 0;     /* Number of Journal Records */\n    u32 dummy;\n    rc = readJournalHdr(pPager, 0, szJ, &nJRec, &dummy);\n    assert( rc!=SQLITE_DONE );\n\n    /*\n    ** The \"pPager->journalHdr+JOURNAL_HDR_SZ(pPager)==pPager->journalOff\"\n    ** test is related to ticket #2565.  See the discussion in the\n    ** pager_playback() function for additional information.\n    */\n    if( nJRec==0 \n     && pPager->journalHdr+JOURNAL_HDR_SZ(pPager)==pPager->journalOff\n    ){\n      nJRec = (u32)((szJ - pPager->journalOff)/JOURNAL_PG_SZ(pPager));\n    }\n    for(ii=0; rc==SQLITE_OK && ii<nJRec && pPager->journalOff<szJ; ii++){\n      rc = pager_playback_one_page(pPager, &pPager->journalOff, pDone, 1, 1);\n    }\n    assert( rc!=SQLITE_DONE );\n  }\n  assert( rc!=SQLITE_OK || pPager->journalOff>=szJ );\n\n  /* Finally,  rollback pages from the sub-journal.  Page that were\n  ** previously rolled back out of the main journal (and are hence in pDone)\n  ** will be skipped.  Out-of-range pages are also skipped.\n  */\n  if( pSavepoint ){\n    u32 ii;            /* Loop counter */\n    i64 offset = (i64)pSavepoint->iSubRec*(4+pPager->pageSize);\n\n    if( pagerUseWal(pPager) ){\n      rc = sqlite3WalSavepointUndo(pPager->pWal, pSavepoint->aWalData);\n    }\n    for(ii=pSavepoint->iSubRec; rc==SQLITE_OK && ii<pPager->nSubRec; ii++){\n      assert( offset==(i64)ii*(4+pPager->pageSize) );\n      rc = pager_playback_one_page(pPager, &offset, pDone, 0, 1);\n    }\n    assert( rc!=SQLITE_DONE );\n  }\n\n  sqlite3BitvecDestroy(pDone);\n  if( rc==SQLITE_OK ){\n    pPager->journalOff = szJ;\n  }\n\n  return rc;\n}\n\n/*\n** Change the maximum number of in-memory pages that are allowed\n** before attempting to recycle clean and unused pages.\n*/\nSQLITE_PRIVATE void sqlite3PagerSetCachesize(Pager *pPager, int mxPage){\n  sqlite3PcacheSetCachesize(pPager->pPCache, mxPage);\n}\n\n/*\n** Change the maximum number of in-memory pages that are allowed\n** before attempting to spill pages to journal.\n*/\nSQLITE_PRIVATE int sqlite3PagerSetSpillsize(Pager *pPager, int mxPage){\n  return sqlite3PcacheSetSpillsize(pPager->pPCache, mxPage);\n}\n\n/*\n** Invoke SQLITE_FCNTL_MMAP_SIZE based on the current value of szMmap.\n*/\nstatic void pagerFixMaplimit(Pager *pPager){\n#if SQLITE_MAX_MMAP_SIZE>0\n  sqlite3_file *fd = pPager->fd;\n  if( isOpen(fd) && fd->pMethods->iVersion>=3 ){\n    sqlite3_int64 sz;\n    sz = pPager->szMmap;\n    pPager->bUseFetch = (sz>0);\n    setGetterMethod(pPager);\n    sqlite3OsFileControlHint(pPager->fd, SQLITE_FCNTL_MMAP_SIZE, &sz);\n  }\n#endif\n}\n\n/*\n** Change the maximum size of any memory mapping made of the database file.\n*/\nSQLITE_PRIVATE void sqlite3PagerSetMmapLimit(Pager *pPager, sqlite3_int64 szMmap){\n  pPager->szMmap = szMmap;\n  pagerFixMaplimit(pPager);\n}\n\n/*\n** Free as much memory as possible from the pager.\n*/\nSQLITE_PRIVATE void sqlite3PagerShrink(Pager *pPager){\n  sqlite3PcacheShrink(pPager->pPCache);\n}\n\n/*\n** Adjust settings of the pager to those specified in the pgFlags parameter.\n**\n** The \"level\" in pgFlags & PAGER_SYNCHRONOUS_MASK sets the robustness\n** of the database to damage due to OS crashes or power failures by\n** changing the number of syncs()s when writing the journals.\n** There are four levels:\n**\n**    OFF       sqlite3OsSync() is never called.  This is the default\n**              for temporary and transient files.\n**\n**    NORMAL    The journal is synced once before writes begin on the\n**              database.  This is normally adequate protection, but\n**              it is theoretically possible, though very unlikely,\n**              that an inopertune power failure could leave the journal\n**              in a state which would cause damage to the database\n**              when it is rolled back.\n**\n**    FULL      The journal is synced twice before writes begin on the\n**              database (with some additional information - the nRec field\n**              of the journal header - being written in between the two\n**              syncs).  If we assume that writing a\n**              single disk sector is atomic, then this mode provides\n**              assurance that the journal will not be corrupted to the\n**              point of causing damage to the database during rollback.\n**\n**    EXTRA     This is like FULL except that is also syncs the directory\n**              that contains the rollback journal after the rollback\n**              journal is unlinked.\n**\n** The above is for a rollback-journal mode.  For WAL mode, OFF continues\n** to mean that no syncs ever occur.  NORMAL means that the WAL is synced\n** prior to the start of checkpoint and that the database file is synced\n** at the conclusion of the checkpoint if the entire content of the WAL\n** was written back into the database.  But no sync operations occur for\n** an ordinary commit in NORMAL mode with WAL.  FULL means that the WAL\n** file is synced following each commit operation, in addition to the\n** syncs associated with NORMAL.  There is no difference between FULL\n** and EXTRA for WAL mode.\n**\n** Do not confuse synchronous=FULL with SQLITE_SYNC_FULL.  The\n** SQLITE_SYNC_FULL macro means to use the MacOSX-style full-fsync\n** using fcntl(F_FULLFSYNC).  SQLITE_SYNC_NORMAL means to do an\n** ordinary fsync() call.  There is no difference between SQLITE_SYNC_FULL\n** and SQLITE_SYNC_NORMAL on platforms other than MacOSX.  But the\n** synchronous=FULL versus synchronous=NORMAL setting determines when\n** the xSync primitive is called and is relevant to all platforms.\n**\n** Numeric values associated with these states are OFF==1, NORMAL=2,\n** and FULL=3.\n*/\n#ifndef SQLITE_OMIT_PAGER_PRAGMAS\nSQLITE_PRIVATE void sqlite3PagerSetFlags(\n  Pager *pPager,        /* The pager to set safety level for */\n  unsigned pgFlags      /* Various flags */\n){\n  unsigned level = pgFlags & PAGER_SYNCHRONOUS_MASK;\n  if( pPager->tempFile ){\n    pPager->noSync = 1;\n    pPager->fullSync = 0;\n    pPager->extraSync = 0;\n  }else{\n    pPager->noSync =  level==PAGER_SYNCHRONOUS_OFF ?1:0;\n    pPager->fullSync = level>=PAGER_SYNCHRONOUS_FULL ?1:0;\n    pPager->extraSync = level==PAGER_SYNCHRONOUS_EXTRA ?1:0;\n  }\n  if( pPager->noSync ){\n    pPager->syncFlags = 0;\n  }else if( pgFlags & PAGER_FULLFSYNC ){\n    pPager->syncFlags = SQLITE_SYNC_FULL;\n  }else{\n    pPager->syncFlags = SQLITE_SYNC_NORMAL;\n  }\n  pPager->walSyncFlags = (pPager->syncFlags<<2);\n  if( pPager->fullSync ){\n    pPager->walSyncFlags |= pPager->syncFlags;\n  }\n  if( (pgFlags & PAGER_CKPT_FULLFSYNC) && !pPager->noSync ){\n    pPager->walSyncFlags |= (SQLITE_SYNC_FULL<<2);\n  }\n  if( pgFlags & PAGER_CACHESPILL ){\n    pPager->doNotSpill &= ~SPILLFLAG_OFF;\n  }else{\n    pPager->doNotSpill |= SPILLFLAG_OFF;\n  }\n}\n#endif\n\n/*\n** The following global variable is incremented whenever the library\n** attempts to open a temporary file.  This information is used for\n** testing and analysis only.  \n*/\n#ifdef SQLITE_TEST\nSQLITE_API int sqlite3_opentemp_count = 0;\n#endif\n\n/*\n** Open a temporary file.\n**\n** Write the file descriptor into *pFile. Return SQLITE_OK on success \n** or some other error code if we fail. The OS will automatically \n** delete the temporary file when it is closed.\n**\n** The flags passed to the VFS layer xOpen() call are those specified\n** by parameter vfsFlags ORed with the following:\n**\n**     SQLITE_OPEN_READWRITE\n**     SQLITE_OPEN_CREATE\n**     SQLITE_OPEN_EXCLUSIVE\n**     SQLITE_OPEN_DELETEONCLOSE\n*/\nstatic int pagerOpentemp(\n  Pager *pPager,        /* The pager object */\n  sqlite3_file *pFile,  /* Write the file descriptor here */\n  int vfsFlags          /* Flags passed through to the VFS */\n){\n  int rc;               /* Return code */\n\n#ifdef SQLITE_TEST\n  sqlite3_opentemp_count++;  /* Used for testing and analysis only */\n#endif\n\n  vfsFlags |=  SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE |\n            SQLITE_OPEN_EXCLUSIVE | SQLITE_OPEN_DELETEONCLOSE;\n  rc = sqlite3OsOpen(pPager->pVfs, 0, pFile, vfsFlags, 0);\n  assert( rc!=SQLITE_OK || isOpen(pFile) );\n  return rc;\n}\n\n/*\n** Set the busy handler function.\n**\n** The pager invokes the busy-handler if sqlite3OsLock() returns \n** SQLITE_BUSY when trying to upgrade from no-lock to a SHARED lock,\n** or when trying to upgrade from a RESERVED lock to an EXCLUSIVE \n** lock. It does *not* invoke the busy handler when upgrading from\n** SHARED to RESERVED, or when upgrading from SHARED to EXCLUSIVE\n** (which occurs during hot-journal rollback). Summary:\n**\n**   Transition                        | Invokes xBusyHandler\n**   --------------------------------------------------------\n**   NO_LOCK       -> SHARED_LOCK      | Yes\n**   SHARED_LOCK   -> RESERVED_LOCK    | No\n**   SHARED_LOCK   -> EXCLUSIVE_LOCK   | No\n**   RESERVED_LOCK -> EXCLUSIVE_LOCK   | Yes\n**\n** If the busy-handler callback returns non-zero, the lock is \n** retried. If it returns zero, then the SQLITE_BUSY error is\n** returned to the caller of the pager API function.\n*/\nSQLITE_PRIVATE void sqlite3PagerSetBusyHandler(\n  Pager *pPager,                       /* Pager object */\n  int (*xBusyHandler)(void *),         /* Pointer to busy-handler function */\n  void *pBusyHandlerArg                /* Argument to pass to xBusyHandler */\n){\n  void **ap;\n  pPager->xBusyHandler = xBusyHandler;\n  pPager->pBusyHandlerArg = pBusyHandlerArg;\n  ap = (void **)&pPager->xBusyHandler;\n  assert( ((int(*)(void *))(ap[0]))==xBusyHandler );\n  assert( ap[1]==pBusyHandlerArg );\n  sqlite3OsFileControlHint(pPager->fd, SQLITE_FCNTL_BUSYHANDLER, (void *)ap);\n}\n\n/*\n** Change the page size used by the Pager object. The new page size \n** is passed in *pPageSize.\n**\n** If the pager is in the error state when this function is called, it\n** is a no-op. The value returned is the error state error code (i.e. \n** one of SQLITE_IOERR, an SQLITE_IOERR_xxx sub-code or SQLITE_FULL).\n**\n** Otherwise, if all of the following are true:\n**\n**   * the new page size (value of *pPageSize) is valid (a power \n**     of two between 512 and SQLITE_MAX_PAGE_SIZE, inclusive), and\n**\n**   * there are no outstanding page references, and\n**\n**   * the database is either not an in-memory database or it is\n**     an in-memory database that currently consists of zero pages.\n**\n** then the pager object page size is set to *pPageSize.\n**\n** If the page size is changed, then this function uses sqlite3PagerMalloc() \n** to obtain a new Pager.pTmpSpace buffer. If this allocation attempt \n** fails, SQLITE_NOMEM is returned and the page size remains unchanged. \n** In all other cases, SQLITE_OK is returned.\n**\n** If the page size is not changed, either because one of the enumerated\n** conditions above is not true, the pager was in error state when this\n** function was called, or because the memory allocation attempt failed, \n** then *pPageSize is set to the old, retained page size before returning.\n*/\nSQLITE_PRIVATE int sqlite3PagerSetPagesize(Pager *pPager, u32 *pPageSize, int nReserve){\n  int rc = SQLITE_OK;\n\n  /* It is not possible to do a full assert_pager_state() here, as this\n  ** function may be called from within PagerOpen(), before the state\n  ** of the Pager object is internally consistent.\n  **\n  ** At one point this function returned an error if the pager was in \n  ** PAGER_ERROR state. But since PAGER_ERROR state guarantees that\n  ** there is at least one outstanding page reference, this function\n  ** is a no-op for that case anyhow.\n  */\n\n  u32 pageSize = *pPageSize;\n  assert( pageSize==0 || (pageSize>=512 && pageSize<=SQLITE_MAX_PAGE_SIZE) );\n  if( (pPager->memDb==0 || pPager->dbSize==0)\n   && sqlite3PcacheRefCount(pPager->pPCache)==0 \n   && pageSize && pageSize!=(u32)pPager->pageSize \n  ){\n    char *pNew = NULL;             /* New temp space */\n    i64 nByte = 0;\n\n    if( pPager->eState>PAGER_OPEN && isOpen(pPager->fd) ){\n      rc = sqlite3OsFileSize(pPager->fd, &nByte);\n    }\n    if( rc==SQLITE_OK ){\n      pNew = (char *)sqlite3PageMalloc(pageSize);\n      if( !pNew ) rc = SQLITE_NOMEM_BKPT;\n    }\n\n    if( rc==SQLITE_OK ){\n      pager_reset(pPager);\n      rc = sqlite3PcacheSetPageSize(pPager->pPCache, pageSize);\n    }\n    if( rc==SQLITE_OK ){\n      sqlite3PageFree(pPager->pTmpSpace);\n      pPager->pTmpSpace = pNew;\n      pPager->dbSize = (Pgno)((nByte+pageSize-1)/pageSize);\n      pPager->pageSize = pageSize;\n    }else{\n      sqlite3PageFree(pNew);\n    }\n  }\n\n  *pPageSize = pPager->pageSize;\n  if( rc==SQLITE_OK ){\n    if( nReserve<0 ) nReserve = pPager->nReserve;\n    assert( nReserve>=0 && nReserve<1000 );\n    pPager->nReserve = (i16)nReserve;\n    pagerReportSize(pPager);\n    pagerFixMaplimit(pPager);\n  }\n  return rc;\n}\n\n/*\n** Return a pointer to the \"temporary page\" buffer held internally\n** by the pager.  This is a buffer that is big enough to hold the\n** entire content of a database page.  This buffer is used internally\n** during rollback and will be overwritten whenever a rollback\n** occurs.  But other modules are free to use it too, as long as\n** no rollbacks are happening.\n*/\nSQLITE_PRIVATE void *sqlite3PagerTempSpace(Pager *pPager){\n  return pPager->pTmpSpace;\n}\n\n/*\n** Attempt to set the maximum database page count if mxPage is positive. \n** Make no changes if mxPage is zero or negative.  And never reduce the\n** maximum page count below the current size of the database.\n**\n** Regardless of mxPage, return the current maximum page count.\n*/\nSQLITE_PRIVATE int sqlite3PagerMaxPageCount(Pager *pPager, int mxPage){\n  if( mxPage>0 ){\n    pPager->mxPgno = mxPage;\n  }\n  assert( pPager->eState!=PAGER_OPEN );      /* Called only by OP_MaxPgcnt */\n  /* assert( pPager->mxPgno>=pPager->dbSize ); */\n  /* OP_MaxPgcnt ensures that the parameter passed to this function is not\n  ** less than the total number of valid pages in the database. But this\n  ** may be less than Pager.dbSize, and so the assert() above is not valid */\n  return pPager->mxPgno;\n}\n\n/*\n** The following set of routines are used to disable the simulated\n** I/O error mechanism.  These routines are used to avoid simulated\n** errors in places where we do not care about errors.\n**\n** Unless -DSQLITE_TEST=1 is used, these routines are all no-ops\n** and generate no code.\n*/\n#ifdef SQLITE_TEST\nSQLITE_API extern int sqlite3_io_error_pending;\nSQLITE_API extern int sqlite3_io_error_hit;\nstatic int saved_cnt;\nvoid disable_simulated_io_errors(void){\n  saved_cnt = sqlite3_io_error_pending;\n  sqlite3_io_error_pending = -1;\n}\nvoid enable_simulated_io_errors(void){\n  sqlite3_io_error_pending = saved_cnt;\n}\n#else\n# define disable_simulated_io_errors()\n# define enable_simulated_io_errors()\n#endif\n\n/*\n** Read the first N bytes from the beginning of the file into memory\n** that pDest points to. \n**\n** If the pager was opened on a transient file (zFilename==\"\"), or\n** opened on a file less than N bytes in size, the output buffer is\n** zeroed and SQLITE_OK returned. The rationale for this is that this \n** function is used to read database headers, and a new transient or\n** zero sized database has a header than consists entirely of zeroes.\n**\n** If any IO error apart from SQLITE_IOERR_SHORT_READ is encountered,\n** the error code is returned to the caller and the contents of the\n** output buffer undefined.\n*/\nSQLITE_PRIVATE int sqlite3PagerReadFileheader(Pager *pPager, int N, unsigned char *pDest){\n  int rc = SQLITE_OK;\n  memset(pDest, 0, N);\n  assert( isOpen(pPager->fd) || pPager->tempFile );\n\n  /* This routine is only called by btree immediately after creating\n  ** the Pager object.  There has not been an opportunity to transition\n  ** to WAL mode yet.\n  */\n  assert( !pagerUseWal(pPager) );\n\n  if( isOpen(pPager->fd) ){\n    IOTRACE((\"DBHDR %p 0 %d\\n\", pPager, N))\n    rc = sqlite3OsRead(pPager->fd, pDest, N, 0);\n    if( rc==SQLITE_IOERR_SHORT_READ ){\n      rc = SQLITE_OK;\n    }\n  }\n  return rc;\n}\n\n/*\n** This function may only be called when a read-transaction is open on\n** the pager. It returns the total number of pages in the database.\n**\n** However, if the file is between 1 and <page-size> bytes in size, then \n** this is considered a 1 page file.\n*/\nSQLITE_PRIVATE void sqlite3PagerPagecount(Pager *pPager, int *pnPage){\n  assert( pPager->eState>=PAGER_READER );\n  assert( pPager->eState!=PAGER_WRITER_FINISHED );\n  *pnPage = (int)pPager->dbSize;\n}\n\n\n/*\n** Try to obtain a lock of type locktype on the database file. If\n** a similar or greater lock is already held, this function is a no-op\n** (returning SQLITE_OK immediately).\n**\n** Otherwise, attempt to obtain the lock using sqlite3OsLock(). Invoke \n** the busy callback if the lock is currently not available. Repeat \n** until the busy callback returns false or until the attempt to \n** obtain the lock succeeds.\n**\n** Return SQLITE_OK on success and an error code if we cannot obtain\n** the lock. If the lock is obtained successfully, set the Pager.state \n** variable to locktype before returning.\n*/\nstatic int pager_wait_on_lock(Pager *pPager, int locktype){\n  int rc;                              /* Return code */\n\n  /* Check that this is either a no-op (because the requested lock is \n  ** already held), or one of the transitions that the busy-handler\n  ** may be invoked during, according to the comment above\n  ** sqlite3PagerSetBusyhandler().\n  */\n  assert( (pPager->eLock>=locktype)\n       || (pPager->eLock==NO_LOCK && locktype==SHARED_LOCK)\n       || (pPager->eLock==RESERVED_LOCK && locktype==EXCLUSIVE_LOCK)\n  );\n\n  do {\n    rc = pagerLockDb(pPager, locktype);\n  }while( rc==SQLITE_BUSY && pPager->xBusyHandler(pPager->pBusyHandlerArg) );\n  return rc;\n}\n\n/*\n** Function assertTruncateConstraint(pPager) checks that one of the \n** following is true for all dirty pages currently in the page-cache:\n**\n**   a) The page number is less than or equal to the size of the \n**      current database image, in pages, OR\n**\n**   b) if the page content were written at this time, it would not\n**      be necessary to write the current content out to the sub-journal\n**      (as determined by function subjRequiresPage()).\n**\n** If the condition asserted by this function were not true, and the\n** dirty page were to be discarded from the cache via the pagerStress()\n** routine, pagerStress() would not write the current page content to\n** the database file. If a savepoint transaction were rolled back after\n** this happened, the correct behavior would be to restore the current\n** content of the page. However, since this content is not present in either\n** the database file or the portion of the rollback journal and \n** sub-journal rolled back the content could not be restored and the\n** database image would become corrupt. It is therefore fortunate that \n** this circumstance cannot arise.\n*/\n#if defined(SQLITE_DEBUG)\nstatic void assertTruncateConstraintCb(PgHdr *pPg){\n  assert( pPg->flags&PGHDR_DIRTY );\n  assert( !subjRequiresPage(pPg) || pPg->pgno<=pPg->pPager->dbSize );\n}\nstatic void assertTruncateConstraint(Pager *pPager){\n  sqlite3PcacheIterateDirty(pPager->pPCache, assertTruncateConstraintCb);\n}\n#else\n# define assertTruncateConstraint(pPager)\n#endif\n\n/*\n** Truncate the in-memory database file image to nPage pages. This \n** function does not actually modify the database file on disk. It \n** just sets the internal state of the pager object so that the \n** truncation will be done when the current transaction is committed.\n**\n** This function is only called right before committing a transaction.\n** Once this function has been called, the transaction must either be\n** rolled back or committed. It is not safe to call this function and\n** then continue writing to the database.\n*/\nSQLITE_PRIVATE void sqlite3PagerTruncateImage(Pager *pPager, Pgno nPage){\n  assert( pPager->dbSize>=nPage );\n  assert( pPager->eState>=PAGER_WRITER_CACHEMOD );\n  pPager->dbSize = nPage;\n\n  /* At one point the code here called assertTruncateConstraint() to\n  ** ensure that all pages being truncated away by this operation are,\n  ** if one or more savepoints are open, present in the savepoint \n  ** journal so that they can be restored if the savepoint is rolled\n  ** back. This is no longer necessary as this function is now only\n  ** called right before committing a transaction. So although the \n  ** Pager object may still have open savepoints (Pager.nSavepoint!=0), \n  ** they cannot be rolled back. So the assertTruncateConstraint() call\n  ** is no longer correct. */\n}\n\n\n/*\n** This function is called before attempting a hot-journal rollback. It\n** syncs the journal file to disk, then sets pPager->journalHdr to the\n** size of the journal file so that the pager_playback() routine knows\n** that the entire journal file has been synced.\n**\n** Syncing a hot-journal to disk before attempting to roll it back ensures \n** that if a power-failure occurs during the rollback, the process that\n** attempts rollback following system recovery sees the same journal\n** content as this process.\n**\n** If everything goes as planned, SQLITE_OK is returned. Otherwise, \n** an SQLite error code.\n*/\nstatic int pagerSyncHotJournal(Pager *pPager){\n  int rc = SQLITE_OK;\n  if( !pPager->noSync ){\n    rc = sqlite3OsSync(pPager->jfd, SQLITE_SYNC_NORMAL);\n  }\n  if( rc==SQLITE_OK ){\n    rc = sqlite3OsFileSize(pPager->jfd, &pPager->journalHdr);\n  }\n  return rc;\n}\n\n#if SQLITE_MAX_MMAP_SIZE>0\n/*\n** Obtain a reference to a memory mapped page object for page number pgno. \n** The new object will use the pointer pData, obtained from xFetch().\n** If successful, set *ppPage to point to the new page reference\n** and return SQLITE_OK. Otherwise, return an SQLite error code and set\n** *ppPage to zero.\n**\n** Page references obtained by calling this function should be released\n** by calling pagerReleaseMapPage().\n*/\nstatic int pagerAcquireMapPage(\n  Pager *pPager,                  /* Pager object */\n  Pgno pgno,                      /* Page number */\n  void *pData,                    /* xFetch()'d data for this page */\n  PgHdr **ppPage                  /* OUT: Acquired page object */\n){\n  PgHdr *p;                       /* Memory mapped page to return */\n  \n  if( pPager->pMmapFreelist ){\n    *ppPage = p = pPager->pMmapFreelist;\n    pPager->pMmapFreelist = p->pDirty;\n    p->pDirty = 0;\n    assert( pPager->nExtra>=8 );\n    memset(p->pExtra, 0, 8);\n  }else{\n    *ppPage = p = (PgHdr *)sqlite3MallocZero(sizeof(PgHdr) + pPager->nExtra);\n    if( p==0 ){\n      sqlite3OsUnfetch(pPager->fd, (i64)(pgno-1) * pPager->pageSize, pData);\n      return SQLITE_NOMEM_BKPT;\n    }\n    p->pExtra = (void *)&p[1];\n    p->flags = PGHDR_MMAP;\n    p->nRef = 1;\n    p->pPager = pPager;\n  }\n\n  assert( p->pExtra==(void *)&p[1] );\n  assert( p->pPage==0 );\n  assert( p->flags==PGHDR_MMAP );\n  assert( p->pPager==pPager );\n  assert( p->nRef==1 );\n\n  p->pgno = pgno;\n  p->pData = pData;\n  pPager->nMmapOut++;\n\n  return SQLITE_OK;\n}\n#endif\n\n/*\n** Release a reference to page pPg. pPg must have been returned by an \n** earlier call to pagerAcquireMapPage().\n*/\nstatic void pagerReleaseMapPage(PgHdr *pPg){\n  Pager *pPager = pPg->pPager;\n  pPager->nMmapOut--;\n  pPg->pDirty = pPager->pMmapFreelist;\n  pPager->pMmapFreelist = pPg;\n\n  assert( pPager->fd->pMethods->iVersion>=3 );\n  sqlite3OsUnfetch(pPager->fd, (i64)(pPg->pgno-1)*pPager->pageSize, pPg->pData);\n}\n\n/*\n** Free all PgHdr objects stored in the Pager.pMmapFreelist list.\n*/\nstatic void pagerFreeMapHdrs(Pager *pPager){\n  PgHdr *p;\n  PgHdr *pNext;\n  for(p=pPager->pMmapFreelist; p; p=pNext){\n    pNext = p->pDirty;\n    sqlite3_free(p);\n  }\n}\n\n/* Verify that the database file has not be deleted or renamed out from\n** under the pager.  Return SQLITE_OK if the database is still where it ought\n** to be on disk.  Return non-zero (SQLITE_READONLY_DBMOVED or some other error\n** code from sqlite3OsAccess()) if the database has gone missing.\n*/\nstatic int databaseIsUnmoved(Pager *pPager){\n  int bHasMoved = 0;\n  int rc;\n\n  if( pPager->tempFile ) return SQLITE_OK;\n  if( pPager->dbSize==0 ) return SQLITE_OK;\n  assert( pPager->zFilename && pPager->zFilename[0] );\n  rc = sqlite3OsFileControl(pPager->fd, SQLITE_FCNTL_HAS_MOVED, &bHasMoved);\n  if( rc==SQLITE_NOTFOUND ){\n    /* If the HAS_MOVED file-control is unimplemented, assume that the file\n    ** has not been moved.  That is the historical behavior of SQLite: prior to\n    ** version 3.8.3, it never checked */\n    rc = SQLITE_OK;\n  }else if( rc==SQLITE_OK && bHasMoved ){\n    rc = SQLITE_READONLY_DBMOVED;\n  }\n  return rc;\n}\n\n\n/*\n** Shutdown the page cache.  Free all memory and close all files.\n**\n** If a transaction was in progress when this routine is called, that\n** transaction is rolled back.  All outstanding pages are invalidated\n** and their memory is freed.  Any attempt to use a page associated\n** with this page cache after this function returns will likely\n** result in a coredump.\n**\n** This function always succeeds. If a transaction is active an attempt\n** is made to roll it back. If an error occurs during the rollback \n** a hot journal may be left in the filesystem but no error is returned\n** to the caller.\n*/\nSQLITE_PRIVATE int sqlite3PagerClose(Pager *pPager, sqlite3 *db){\n  u8 *pTmp = (u8*)pPager->pTmpSpace;\n  assert( db || pagerUseWal(pPager)==0 );\n  assert( assert_pager_state(pPager) );\n  disable_simulated_io_errors();\n  sqlite3BeginBenignMalloc();\n  pagerFreeMapHdrs(pPager);\n  /* pPager->errCode = 0; */\n  pPager->exclusiveMode = 0;\n#ifndef SQLITE_OMIT_WAL\n  {\n    u8 *a = 0;\n    assert( db || pPager->pWal==0 );\n    if( db && 0==(db->flags & SQLITE_NoCkptOnClose) \n     && SQLITE_OK==databaseIsUnmoved(pPager)\n    ){\n      a = pTmp;\n    }\n    sqlite3WalClose(pPager->pWal, db, pPager->walSyncFlags, pPager->pageSize,a);\n    pPager->pWal = 0;\n  }\n#endif\n  pager_reset(pPager);\n  if( MEMDB ){\n    pager_unlock(pPager);\n  }else{\n    /* If it is open, sync the journal file before calling UnlockAndRollback.\n    ** If this is not done, then an unsynced portion of the open journal \n    ** file may be played back into the database. If a power failure occurs \n    ** while this is happening, the database could become corrupt.\n    **\n    ** If an error occurs while trying to sync the journal, shift the pager\n    ** into the ERROR state. This causes UnlockAndRollback to unlock the\n    ** database and close the journal file without attempting to roll it\n    ** back or finalize it. The next database user will have to do hot-journal\n    ** rollback before accessing the database file.\n    */\n    if( isOpen(pPager->jfd) ){\n      pager_error(pPager, pagerSyncHotJournal(pPager));\n    }\n    pagerUnlockAndRollback(pPager);\n  }\n  sqlite3EndBenignMalloc();\n  enable_simulated_io_errors();\n  PAGERTRACE((\"CLOSE %d\\n\", PAGERID(pPager)));\n  IOTRACE((\"CLOSE %p\\n\", pPager))\n  sqlite3OsClose(pPager->jfd);\n  sqlite3OsClose(pPager->fd);\n  sqlite3PageFree(pTmp);\n  sqlite3PcacheClose(pPager->pPCache);\n\n#ifdef SQLITE_HAS_CODEC\n  if( pPager->xCodecFree ) pPager->xCodecFree(pPager->pCodec);\n#endif\n\n  assert( !pPager->aSavepoint && !pPager->pInJournal );\n  assert( !isOpen(pPager->jfd) && !isOpen(pPager->sjfd) );\n\n  sqlite3_free(pPager);\n  return SQLITE_OK;\n}\n\n#if !defined(NDEBUG) || defined(SQLITE_TEST)\n/*\n** Return the page number for page pPg.\n*/\nSQLITE_PRIVATE Pgno sqlite3PagerPagenumber(DbPage *pPg){\n  return pPg->pgno;\n}\n#endif\n\n/*\n** Increment the reference count for page pPg.\n*/\nSQLITE_PRIVATE void sqlite3PagerRef(DbPage *pPg){\n  sqlite3PcacheRef(pPg);\n}\n\n/*\n** Sync the journal. In other words, make sure all the pages that have\n** been written to the journal have actually reached the surface of the\n** disk and can be restored in the event of a hot-journal rollback.\n**\n** If the Pager.noSync flag is set, then this function is a no-op.\n** Otherwise, the actions required depend on the journal-mode and the \n** device characteristics of the file-system, as follows:\n**\n**   * If the journal file is an in-memory journal file, no action need\n**     be taken.\n**\n**   * Otherwise, if the device does not support the SAFE_APPEND property,\n**     then the nRec field of the most recently written journal header\n**     is updated to contain the number of journal records that have\n**     been written following it. If the pager is operating in full-sync\n**     mode, then the journal file is synced before this field is updated.\n**\n**   * If the device does not support the SEQUENTIAL property, then \n**     journal file is synced.\n**\n** Or, in pseudo-code:\n**\n**   if( NOT <in-memory journal> ){\n**     if( NOT SAFE_APPEND ){\n**       if( <full-sync mode> ) xSync(<journal file>);\n**       <update nRec field>\n**     } \n**     if( NOT SEQUENTIAL ) xSync(<journal file>);\n**   }\n**\n** If successful, this routine clears the PGHDR_NEED_SYNC flag of every \n** page currently held in memory before returning SQLITE_OK. If an IO\n** error is encountered, then the IO error code is returned to the caller.\n*/\nstatic int syncJournal(Pager *pPager, int newHdr){\n  int rc;                         /* Return code */\n\n  assert( pPager->eState==PAGER_WRITER_CACHEMOD\n       || pPager->eState==PAGER_WRITER_DBMOD\n  );\n  assert( assert_pager_state(pPager) );\n  assert( !pagerUseWal(pPager) );\n\n  rc = sqlite3PagerExclusiveLock(pPager);\n  if( rc!=SQLITE_OK ) return rc;\n\n  if( !pPager->noSync ){\n    assert( !pPager->tempFile );\n    if( isOpen(pPager->jfd) && pPager->journalMode!=PAGER_JOURNALMODE_MEMORY ){\n      const int iDc = sqlite3OsDeviceCharacteristics(pPager->fd);\n      assert( isOpen(pPager->jfd) );\n\n      if( 0==(iDc&SQLITE_IOCAP_SAFE_APPEND) ){\n        /* This block deals with an obscure problem. If the last connection\n        ** that wrote to this database was operating in persistent-journal\n        ** mode, then the journal file may at this point actually be larger\n        ** than Pager.journalOff bytes. If the next thing in the journal\n        ** file happens to be a journal-header (written as part of the\n        ** previous connection's transaction), and a crash or power-failure \n        ** occurs after nRec is updated but before this connection writes \n        ** anything else to the journal file (or commits/rolls back its \n        ** transaction), then SQLite may become confused when doing the \n        ** hot-journal rollback following recovery. It may roll back all\n        ** of this connections data, then proceed to rolling back the old,\n        ** out-of-date data that follows it. Database corruption.\n        **\n        ** To work around this, if the journal file does appear to contain\n        ** a valid header following Pager.journalOff, then write a 0x00\n        ** byte to the start of it to prevent it from being recognized.\n        **\n        ** Variable iNextHdrOffset is set to the offset at which this\n        ** problematic header will occur, if it exists. aMagic is used \n        ** as a temporary buffer to inspect the first couple of bytes of\n        ** the potential journal header.\n        */\n        i64 iNextHdrOffset;\n        u8 aMagic[8];\n        u8 zHeader[sizeof(aJournalMagic)+4];\n\n        memcpy(zHeader, aJournalMagic, sizeof(aJournalMagic));\n        put32bits(&zHeader[sizeof(aJournalMagic)], pPager->nRec);\n\n        iNextHdrOffset = journalHdrOffset(pPager);\n        rc = sqlite3OsRead(pPager->jfd, aMagic, 8, iNextHdrOffset);\n        if( rc==SQLITE_OK && 0==memcmp(aMagic, aJournalMagic, 8) ){\n          static const u8 zerobyte = 0;\n          rc = sqlite3OsWrite(pPager->jfd, &zerobyte, 1, iNextHdrOffset);\n        }\n        if( rc!=SQLITE_OK && rc!=SQLITE_IOERR_SHORT_READ ){\n          return rc;\n        }\n\n        /* Write the nRec value into the journal file header. If in\n        ** full-synchronous mode, sync the journal first. This ensures that\n        ** all data has really hit the disk before nRec is updated to mark\n        ** it as a candidate for rollback.\n        **\n        ** This is not required if the persistent media supports the\n        ** SAFE_APPEND property. Because in this case it is not possible \n        ** for garbage data to be appended to the file, the nRec field\n        ** is populated with 0xFFFFFFFF when the journal header is written\n        ** and never needs to be updated.\n        */\n        if( pPager->fullSync && 0==(iDc&SQLITE_IOCAP_SEQUENTIAL) ){\n          PAGERTRACE((\"SYNC journal of %d\\n\", PAGERID(pPager)));\n          IOTRACE((\"JSYNC %p\\n\", pPager))\n          rc = sqlite3OsSync(pPager->jfd, pPager->syncFlags);\n          if( rc!=SQLITE_OK ) return rc;\n        }\n        IOTRACE((\"JHDR %p %lld\\n\", pPager, pPager->journalHdr));\n        rc = sqlite3OsWrite(\n            pPager->jfd, zHeader, sizeof(zHeader), pPager->journalHdr\n        );\n        if( rc!=SQLITE_OK ) return rc;\n      }\n      if( 0==(iDc&SQLITE_IOCAP_SEQUENTIAL) ){\n        PAGERTRACE((\"SYNC journal of %d\\n\", PAGERID(pPager)));\n        IOTRACE((\"JSYNC %p\\n\", pPager))\n        rc = sqlite3OsSync(pPager->jfd, pPager->syncFlags| \n          (pPager->syncFlags==SQLITE_SYNC_FULL?SQLITE_SYNC_DATAONLY:0)\n        );\n        if( rc!=SQLITE_OK ) return rc;\n      }\n\n      pPager->journalHdr = pPager->journalOff;\n      if( newHdr && 0==(iDc&SQLITE_IOCAP_SAFE_APPEND) ){\n        pPager->nRec = 0;\n        rc = writeJournalHdr(pPager);\n        if( rc!=SQLITE_OK ) return rc;\n      }\n    }else{\n      pPager->journalHdr = pPager->journalOff;\n    }\n  }\n\n  /* Unless the pager is in noSync mode, the journal file was just \n  ** successfully synced. Either way, clear the PGHDR_NEED_SYNC flag on \n  ** all pages.\n  */\n  sqlite3PcacheClearSyncFlags(pPager->pPCache);\n  pPager->eState = PAGER_WRITER_DBMOD;\n  assert( assert_pager_state(pPager) );\n  return SQLITE_OK;\n}\n\n/*\n** The argument is the first in a linked list of dirty pages connected\n** by the PgHdr.pDirty pointer. This function writes each one of the\n** in-memory pages in the list to the database file. The argument may\n** be NULL, representing an empty list. In this case this function is\n** a no-op.\n**\n** The pager must hold at least a RESERVED lock when this function\n** is called. Before writing anything to the database file, this lock\n** is upgraded to an EXCLUSIVE lock. If the lock cannot be obtained,\n** SQLITE_BUSY is returned and no data is written to the database file.\n** \n** If the pager is a temp-file pager and the actual file-system file\n** is not yet open, it is created and opened before any data is \n** written out.\n**\n** Once the lock has been upgraded and, if necessary, the file opened,\n** the pages are written out to the database file in list order. Writing\n** a page is skipped if it meets either of the following criteria:\n**\n**   * The page number is greater than Pager.dbSize, or\n**   * The PGHDR_DONT_WRITE flag is set on the page.\n**\n** If writing out a page causes the database file to grow, Pager.dbFileSize\n** is updated accordingly. If page 1 is written out, then the value cached\n** in Pager.dbFileVers[] is updated to match the new value stored in\n** the database file.\n**\n** If everything is successful, SQLITE_OK is returned. If an IO error \n** occurs, an IO error code is returned. Or, if the EXCLUSIVE lock cannot\n** be obtained, SQLITE_BUSY is returned.\n*/\nstatic int pager_write_pagelist(Pager *pPager, PgHdr *pList){\n  int rc = SQLITE_OK;                  /* Return code */\n\n  /* This function is only called for rollback pagers in WRITER_DBMOD state. */\n  assert( !pagerUseWal(pPager) );\n  assert( pPager->tempFile || pPager->eState==PAGER_WRITER_DBMOD );\n  assert( pPager->eLock==EXCLUSIVE_LOCK );\n  assert( isOpen(pPager->fd) || pList->pDirty==0 );\n\n  /* If the file is a temp-file has not yet been opened, open it now. It\n  ** is not possible for rc to be other than SQLITE_OK if this branch\n  ** is taken, as pager_wait_on_lock() is a no-op for temp-files.\n  */\n  if( !isOpen(pPager->fd) ){\n    assert( pPager->tempFile && rc==SQLITE_OK );\n    rc = pagerOpentemp(pPager, pPager->fd, pPager->vfsFlags);\n  }\n\n  /* Before the first write, give the VFS a hint of what the final\n  ** file size will be.\n  */\n  assert( rc!=SQLITE_OK || isOpen(pPager->fd) );\n  if( rc==SQLITE_OK \n   && pPager->dbHintSize<pPager->dbSize\n   && (pList->pDirty || pList->pgno>pPager->dbHintSize)\n  ){\n    sqlite3_int64 szFile = pPager->pageSize * (sqlite3_int64)pPager->dbSize;\n    sqlite3OsFileControlHint(pPager->fd, SQLITE_FCNTL_SIZE_HINT, &szFile);\n    pPager->dbHintSize = pPager->dbSize;\n  }\n\n  while( rc==SQLITE_OK && pList ){\n    Pgno pgno = pList->pgno;\n\n    /* If there are dirty pages in the page cache with page numbers greater\n    ** than Pager.dbSize, this means sqlite3PagerTruncateImage() was called to\n    ** make the file smaller (presumably by auto-vacuum code). Do not write\n    ** any such pages to the file.\n    **\n    ** Also, do not write out any page that has the PGHDR_DONT_WRITE flag\n    ** set (set by sqlite3PagerDontWrite()).\n    */\n    if( pgno<=pPager->dbSize && 0==(pList->flags&PGHDR_DONT_WRITE) ){\n      i64 offset = (pgno-1)*(i64)pPager->pageSize;   /* Offset to write */\n      char *pData;                                   /* Data to write */    \n\n      assert( (pList->flags&PGHDR_NEED_SYNC)==0 );\n      if( pList->pgno==1 ) pager_write_changecounter(pList);\n\n      /* Encode the database */\n      CODEC2(pPager, pList->pData, pgno, 6, return SQLITE_NOMEM_BKPT, pData);\n\n      /* Write out the page data. */\n      rc = sqlite3OsWrite(pPager->fd, pData, pPager->pageSize, offset);\n\n      /* If page 1 was just written, update Pager.dbFileVers to match\n      ** the value now stored in the database file. If writing this \n      ** page caused the database file to grow, update dbFileSize. \n      */\n      if( pgno==1 ){\n        memcpy(&pPager->dbFileVers, &pData[24], sizeof(pPager->dbFileVers));\n      }\n      if( pgno>pPager->dbFileSize ){\n        pPager->dbFileSize = pgno;\n      }\n      pPager->aStat[PAGER_STAT_WRITE]++;\n\n      /* Update any backup objects copying the contents of this pager. */\n      sqlite3BackupUpdate(pPager->pBackup, pgno, (u8*)pList->pData);\n\n      PAGERTRACE((\"STORE %d page %d hash(%08x)\\n\",\n                   PAGERID(pPager), pgno, pager_pagehash(pList)));\n      IOTRACE((\"PGOUT %p %d\\n\", pPager, pgno));\n      PAGER_INCR(sqlite3_pager_writedb_count);\n    }else{\n      PAGERTRACE((\"NOSTORE %d page %d\\n\", PAGERID(pPager), pgno));\n    }\n    pager_set_pagehash(pList);\n    pList = pList->pDirty;\n  }\n\n  return rc;\n}\n\n/*\n** Ensure that the sub-journal file is open. If it is already open, this \n** function is a no-op.\n**\n** SQLITE_OK is returned if everything goes according to plan. An \n** SQLITE_IOERR_XXX error code is returned if a call to sqlite3OsOpen() \n** fails.\n*/\nstatic int openSubJournal(Pager *pPager){\n  int rc = SQLITE_OK;\n  if( !isOpen(pPager->sjfd) ){\n    const int flags =  SQLITE_OPEN_SUBJOURNAL | SQLITE_OPEN_READWRITE \n      | SQLITE_OPEN_CREATE | SQLITE_OPEN_EXCLUSIVE \n      | SQLITE_OPEN_DELETEONCLOSE;\n    int nStmtSpill = sqlite3Config.nStmtSpill;\n    if( pPager->journalMode==PAGER_JOURNALMODE_MEMORY || pPager->subjInMemory ){\n      nStmtSpill = -1;\n    }\n    rc = sqlite3JournalOpen(pPager->pVfs, 0, pPager->sjfd, flags, nStmtSpill);\n  }\n  return rc;\n}\n\n/*\n** Append a record of the current state of page pPg to the sub-journal. \n**\n** If successful, set the bit corresponding to pPg->pgno in the bitvecs\n** for all open savepoints before returning.\n**\n** This function returns SQLITE_OK if everything is successful, an IO\n** error code if the attempt to write to the sub-journal fails, or \n** SQLITE_NOMEM if a malloc fails while setting a bit in a savepoint\n** bitvec.\n*/\nstatic int subjournalPage(PgHdr *pPg){\n  int rc = SQLITE_OK;\n  Pager *pPager = pPg->pPager;\n  if( pPager->journalMode!=PAGER_JOURNALMODE_OFF ){\n\n    /* Open the sub-journal, if it has not already been opened */\n    assert( pPager->useJournal );\n    assert( isOpen(pPager->jfd) || pagerUseWal(pPager) );\n    assert( isOpen(pPager->sjfd) || pPager->nSubRec==0 );\n    assert( pagerUseWal(pPager) \n         || pageInJournal(pPager, pPg) \n         || pPg->pgno>pPager->dbOrigSize \n    );\n    rc = openSubJournal(pPager);\n\n    /* If the sub-journal was opened successfully (or was already open),\n    ** write the journal record into the file.  */\n    if( rc==SQLITE_OK ){\n      void *pData = pPg->pData;\n      i64 offset = (i64)pPager->nSubRec*(4+pPager->pageSize);\n      char *pData2;\n\n#if SQLITE_HAS_CODEC   \n      if( !pPager->subjInMemory ){\n        CODEC2(pPager, pData, pPg->pgno, 7, return SQLITE_NOMEM_BKPT, pData2);\n      }else\n#endif\n      pData2 = pData;\n      PAGERTRACE((\"STMT-JOURNAL %d page %d\\n\", PAGERID(pPager), pPg->pgno));\n      rc = write32bits(pPager->sjfd, offset, pPg->pgno);\n      if( rc==SQLITE_OK ){\n        rc = sqlite3OsWrite(pPager->sjfd, pData2, pPager->pageSize, offset+4);\n      }\n    }\n  }\n  if( rc==SQLITE_OK ){\n    pPager->nSubRec++;\n    assert( pPager->nSavepoint>0 );\n    rc = addToSavepointBitvecs(pPager, pPg->pgno);\n  }\n  return rc;\n}\nstatic int subjournalPageIfRequired(PgHdr *pPg){\n  if( subjRequiresPage(pPg) ){\n    return subjournalPage(pPg);\n  }else{\n    return SQLITE_OK;\n  }\n}\n\n/*\n** This function is called by the pcache layer when it has reached some\n** soft memory limit. The first argument is a pointer to a Pager object\n** (cast as a void*). The pager is always 'purgeable' (not an in-memory\n** database). The second argument is a reference to a page that is \n** currently dirty but has no outstanding references. The page\n** is always associated with the Pager object passed as the first \n** argument.\n**\n** The job of this function is to make pPg clean by writing its contents\n** out to the database file, if possible. This may involve syncing the\n** journal file. \n**\n** If successful, sqlite3PcacheMakeClean() is called on the page and\n** SQLITE_OK returned. If an IO error occurs while trying to make the\n** page clean, the IO error code is returned. If the page cannot be\n** made clean for some other reason, but no error occurs, then SQLITE_OK\n** is returned by sqlite3PcacheMakeClean() is not called.\n*/\nstatic int pagerStress(void *p, PgHdr *pPg){\n  Pager *pPager = (Pager *)p;\n  int rc = SQLITE_OK;\n\n  assert( pPg->pPager==pPager );\n  assert( pPg->flags&PGHDR_DIRTY );\n\n  /* The doNotSpill NOSYNC bit is set during times when doing a sync of\n  ** journal (and adding a new header) is not allowed.  This occurs\n  ** during calls to sqlite3PagerWrite() while trying to journal multiple\n  ** pages belonging to the same sector.\n  **\n  ** The doNotSpill ROLLBACK and OFF bits inhibits all cache spilling\n  ** regardless of whether or not a sync is required.  This is set during\n  ** a rollback or by user request, respectively.\n  **\n  ** Spilling is also prohibited when in an error state since that could\n  ** lead to database corruption.   In the current implementation it \n  ** is impossible for sqlite3PcacheFetch() to be called with createFlag==3\n  ** while in the error state, hence it is impossible for this routine to\n  ** be called in the error state.  Nevertheless, we include a NEVER()\n  ** test for the error state as a safeguard against future changes.\n  */\n  if( NEVER(pPager->errCode) ) return SQLITE_OK;\n  testcase( pPager->doNotSpill & SPILLFLAG_ROLLBACK );\n  testcase( pPager->doNotSpill & SPILLFLAG_OFF );\n  testcase( pPager->doNotSpill & SPILLFLAG_NOSYNC );\n  if( pPager->doNotSpill\n   && ((pPager->doNotSpill & (SPILLFLAG_ROLLBACK|SPILLFLAG_OFF))!=0\n      || (pPg->flags & PGHDR_NEED_SYNC)!=0)\n  ){\n    return SQLITE_OK;\n  }\n\n  pPager->aStat[PAGER_STAT_SPILL]++;\n  pPg->pDirty = 0;\n  if( pagerUseWal(pPager) ){\n    /* Write a single frame for this page to the log. */\n    rc = subjournalPageIfRequired(pPg); \n    if( rc==SQLITE_OK ){\n      rc = pagerWalFrames(pPager, pPg, 0, 0);\n    }\n  }else{\n    \n#ifdef SQLITE_ENABLE_BATCH_ATOMIC_WRITE\n    if( pPager->tempFile==0 ){\n      rc = sqlite3JournalCreate(pPager->jfd);\n      if( rc!=SQLITE_OK ) return pager_error(pPager, rc);\n    }\n#endif\n  \n    /* Sync the journal file if required. */\n    if( pPg->flags&PGHDR_NEED_SYNC \n     || pPager->eState==PAGER_WRITER_CACHEMOD\n    ){\n      rc = syncJournal(pPager, 1);\n    }\n  \n    /* Write the contents of the page out to the database file. */\n    if( rc==SQLITE_OK ){\n      assert( (pPg->flags&PGHDR_NEED_SYNC)==0 );\n      rc = pager_write_pagelist(pPager, pPg);\n    }\n  }\n\n  /* Mark the page as clean. */\n  if( rc==SQLITE_OK ){\n    PAGERTRACE((\"STRESS %d page %d\\n\", PAGERID(pPager), pPg->pgno));\n    sqlite3PcacheMakeClean(pPg);\n  }\n\n  return pager_error(pPager, rc); \n}\n\n/*\n** Flush all unreferenced dirty pages to disk.\n*/\nSQLITE_PRIVATE int sqlite3PagerFlush(Pager *pPager){\n  int rc = pPager->errCode;\n  if( !MEMDB ){\n    PgHdr *pList = sqlite3PcacheDirtyList(pPager->pPCache);\n    assert( assert_pager_state(pPager) );\n    while( rc==SQLITE_OK && pList ){\n      PgHdr *pNext = pList->pDirty;\n      if( pList->nRef==0 ){\n        rc = pagerStress((void*)pPager, pList);\n      }\n      pList = pNext;\n    }\n  }\n\n  return rc;\n}\n\n/*\n** Allocate and initialize a new Pager object and put a pointer to it\n** in *ppPager. The pager should eventually be freed by passing it\n** to sqlite3PagerClose().\n**\n** The zFilename argument is the path to the database file to open.\n** If zFilename is NULL then a randomly-named temporary file is created\n** and used as the file to be cached. Temporary files are be deleted\n** automatically when they are closed. If zFilename is \":memory:\" then \n** all information is held in cache. It is never written to disk. \n** This can be used to implement an in-memory database.\n**\n** The nExtra parameter specifies the number of bytes of space allocated\n** along with each page reference. This space is available to the user\n** via the sqlite3PagerGetExtra() API.  When a new page is allocated, the\n** first 8 bytes of this space are zeroed but the remainder is uninitialized.\n** (The extra space is used by btree as the MemPage object.)\n**\n** The flags argument is used to specify properties that affect the\n** operation of the pager. It should be passed some bitwise combination\n** of the PAGER_* flags.\n**\n** The vfsFlags parameter is a bitmask to pass to the flags parameter\n** of the xOpen() method of the supplied VFS when opening files. \n**\n** If the pager object is allocated and the specified file opened \n** successfully, SQLITE_OK is returned and *ppPager set to point to\n** the new pager object. If an error occurs, *ppPager is set to NULL\n** and error code returned. This function may return SQLITE_NOMEM\n** (sqlite3Malloc() is used to allocate memory), SQLITE_CANTOPEN or \n** various SQLITE_IO_XXX errors.\n*/\nSQLITE_PRIVATE int sqlite3PagerOpen(\n  sqlite3_vfs *pVfs,       /* The virtual file system to use */\n  Pager **ppPager,         /* OUT: Return the Pager structure here */\n  const char *zFilename,   /* Name of the database file to open */\n  int nExtra,              /* Extra bytes append to each in-memory page */\n  int flags,               /* flags controlling this file */\n  int vfsFlags,            /* flags passed through to sqlite3_vfs.xOpen() */\n  void (*xReinit)(DbPage*) /* Function to reinitialize pages */\n){\n  u8 *pPtr;\n  Pager *pPager = 0;       /* Pager object to allocate and return */\n  int rc = SQLITE_OK;      /* Return code */\n  int tempFile = 0;        /* True for temp files (incl. in-memory files) */\n  int memDb = 0;           /* True if this is an in-memory file */\n#ifdef SQLITE_ENABLE_DESERIALIZE\n  int memJM = 0;           /* Memory journal mode */\n#else\n# define memJM 0\n#endif\n  int readOnly = 0;        /* True if this is a read-only file */\n  int journalFileSize;     /* Bytes to allocate for each journal fd */\n  char *zPathname = 0;     /* Full path to database file */\n  int nPathname = 0;       /* Number of bytes in zPathname */\n  int useJournal = (flags & PAGER_OMIT_JOURNAL)==0; /* False to omit journal */\n  int pcacheSize = sqlite3PcacheSize();       /* Bytes to allocate for PCache */\n  u32 szPageDflt = SQLITE_DEFAULT_PAGE_SIZE;  /* Default page size */\n  const char *zUri = 0;    /* URI args to copy */\n  int nUri = 0;            /* Number of bytes of URI args at *zUri */\n\n  /* Figure out how much space is required for each journal file-handle\n  ** (there are two of them, the main journal and the sub-journal).  */\n  journalFileSize = ROUND8(sqlite3JournalSize(pVfs));\n\n  /* Set the output variable to NULL in case an error occurs. */\n  *ppPager = 0;\n\n#ifndef SQLITE_OMIT_MEMORYDB\n  if( flags & PAGER_MEMORY ){\n    memDb = 1;\n    if( zFilename && zFilename[0] ){\n      zPathname = sqlite3DbStrDup(0, zFilename);\n      if( zPathname==0  ) return SQLITE_NOMEM_BKPT;\n      nPathname = sqlite3Strlen30(zPathname);\n      zFilename = 0;\n    }\n  }\n#endif\n\n  /* Compute and store the full pathname in an allocated buffer pointed\n  ** to by zPathname, length nPathname. Or, if this is a temporary file,\n  ** leave both nPathname and zPathname set to 0.\n  */\n  if( zFilename && zFilename[0] ){\n    const char *z;\n    nPathname = pVfs->mxPathname+1;\n    zPathname = sqlite3DbMallocRaw(0, nPathname*2);\n    if( zPathname==0 ){\n      return SQLITE_NOMEM_BKPT;\n    }\n    zPathname[0] = 0; /* Make sure initialized even if FullPathname() fails */\n    rc = sqlite3OsFullPathname(pVfs, zFilename, nPathname, zPathname);\n    nPathname = sqlite3Strlen30(zPathname);\n    z = zUri = &zFilename[sqlite3Strlen30(zFilename)+1];\n    while( *z ){\n      z += sqlite3Strlen30(z)+1;\n      z += sqlite3Strlen30(z)+1;\n    }\n    nUri = (int)(&z[1] - zUri);\n    assert( nUri>=0 );\n    if( rc==SQLITE_OK && nPathname+8>pVfs->mxPathname ){\n      /* This branch is taken when the journal path required by\n      ** the database being opened will be more than pVfs->mxPathname\n      ** bytes in length. This means the database cannot be opened,\n      ** as it will not be possible to open the journal file or even\n      ** check for a hot-journal before reading.\n      */\n      rc = SQLITE_CANTOPEN_BKPT;\n    }\n    if( rc!=SQLITE_OK ){\n      sqlite3DbFree(0, zPathname);\n      return rc;\n    }\n  }\n\n  /* Allocate memory for the Pager structure, PCache object, the\n  ** three file descriptors, the database file name and the journal \n  ** file name. The layout in memory is as follows:\n  **\n  **     Pager object                    (sizeof(Pager) bytes)\n  **     PCache object                   (sqlite3PcacheSize() bytes)\n  **     Database file handle            (pVfs->szOsFile bytes)\n  **     Sub-journal file handle         (journalFileSize bytes)\n  **     Main journal file handle        (journalFileSize bytes)\n  **     Database file name              (nPathname+1 bytes)\n  **     Journal file name               (nPathname+8+1 bytes)\n  */\n  pPtr = (u8 *)sqlite3MallocZero(\n    ROUND8(sizeof(*pPager)) +      /* Pager structure */\n    ROUND8(pcacheSize) +           /* PCache object */\n    ROUND8(pVfs->szOsFile) +       /* The main db file */\n    journalFileSize * 2 +          /* The two journal files */ \n    nPathname + 1 + nUri +         /* zFilename */\n    nPathname + 8 + 2              /* zJournal */\n#ifndef SQLITE_OMIT_WAL\n    + nPathname + 4 + 2            /* zWal */\n#endif\n  );\n  assert( EIGHT_BYTE_ALIGNMENT(SQLITE_INT_TO_PTR(journalFileSize)) );\n  if( !pPtr ){\n    sqlite3DbFree(0, zPathname);\n    return SQLITE_NOMEM_BKPT;\n  }\n  pPager =              (Pager*)(pPtr);\n  pPager->pPCache =    (PCache*)(pPtr += ROUND8(sizeof(*pPager)));\n  pPager->fd =   (sqlite3_file*)(pPtr += ROUND8(pcacheSize));\n  pPager->sjfd = (sqlite3_file*)(pPtr += ROUND8(pVfs->szOsFile));\n  pPager->jfd =  (sqlite3_file*)(pPtr += journalFileSize);\n  pPager->zFilename =    (char*)(pPtr += journalFileSize);\n  assert( EIGHT_BYTE_ALIGNMENT(pPager->jfd) );\n\n  /* Fill in the Pager.zFilename and Pager.zJournal buffers, if required. */\n  if( zPathname ){\n    assert( nPathname>0 );\n    pPager->zJournal =   (char*)(pPtr += nPathname + 1 + nUri);\n    memcpy(pPager->zFilename, zPathname, nPathname);\n    if( nUri ) memcpy(&pPager->zFilename[nPathname+1], zUri, nUri);\n    memcpy(pPager->zJournal, zPathname, nPathname);\n    memcpy(&pPager->zJournal[nPathname], \"-journal\\000\", 8+2);\n    sqlite3FileSuffix3(pPager->zFilename, pPager->zJournal);\n#ifndef SQLITE_OMIT_WAL\n    pPager->zWal = &pPager->zJournal[nPathname+8+1];\n    memcpy(pPager->zWal, zPathname, nPathname);\n    memcpy(&pPager->zWal[nPathname], \"-wal\\000\", 4+1);\n    sqlite3FileSuffix3(pPager->zFilename, pPager->zWal);\n#endif\n    sqlite3DbFree(0, zPathname);\n  }\n  pPager->pVfs = pVfs;\n  pPager->vfsFlags = vfsFlags;\n\n  /* Open the pager file.\n  */\n  if( zFilename && zFilename[0] ){\n    int fout = 0;                    /* VFS flags returned by xOpen() */\n    rc = sqlite3OsOpen(pVfs, pPager->zFilename, pPager->fd, vfsFlags, &fout);\n    assert( !memDb );\n#ifdef SQLITE_ENABLE_DESERIALIZE\n    memJM = (fout&SQLITE_OPEN_MEMORY)!=0;\n#endif\n    readOnly = (fout&SQLITE_OPEN_READONLY)!=0;\n\n    /* If the file was successfully opened for read/write access,\n    ** choose a default page size in case we have to create the\n    ** database file. The default page size is the maximum of:\n    **\n    **    + SQLITE_DEFAULT_PAGE_SIZE,\n    **    + The value returned by sqlite3OsSectorSize()\n    **    + The largest page size that can be written atomically.\n    */\n    if( rc==SQLITE_OK ){\n      int iDc = sqlite3OsDeviceCharacteristics(pPager->fd);\n      if( !readOnly ){\n        setSectorSize(pPager);\n        assert(SQLITE_DEFAULT_PAGE_SIZE<=SQLITE_MAX_DEFAULT_PAGE_SIZE);\n        if( szPageDflt<pPager->sectorSize ){\n          if( pPager->sectorSize>SQLITE_MAX_DEFAULT_PAGE_SIZE ){\n            szPageDflt = SQLITE_MAX_DEFAULT_PAGE_SIZE;\n          }else{\n            szPageDflt = (u32)pPager->sectorSize;\n          }\n        }\n#ifdef SQLITE_ENABLE_ATOMIC_WRITE\n        {\n          int ii;\n          assert(SQLITE_IOCAP_ATOMIC512==(512>>8));\n          assert(SQLITE_IOCAP_ATOMIC64K==(65536>>8));\n          assert(SQLITE_MAX_DEFAULT_PAGE_SIZE<=65536);\n          for(ii=szPageDflt; ii<=SQLITE_MAX_DEFAULT_PAGE_SIZE; ii=ii*2){\n            if( iDc&(SQLITE_IOCAP_ATOMIC|(ii>>8)) ){\n              szPageDflt = ii;\n            }\n          }\n        }\n#endif\n      }\n      pPager->noLock = sqlite3_uri_boolean(zFilename, \"nolock\", 0);\n      if( (iDc & SQLITE_IOCAP_IMMUTABLE)!=0\n       || sqlite3_uri_boolean(zFilename, \"immutable\", 0) ){\n          vfsFlags |= SQLITE_OPEN_READONLY;\n          goto act_like_temp_file;\n      }\n    }\n  }else{\n    /* If a temporary file is requested, it is not opened immediately.\n    ** In this case we accept the default page size and delay actually\n    ** opening the file until the first call to OsWrite().\n    **\n    ** This branch is also run for an in-memory database. An in-memory\n    ** database is the same as a temp-file that is never written out to\n    ** disk and uses an in-memory rollback journal.\n    **\n    ** This branch also runs for files marked as immutable.\n    */ \nact_like_temp_file:\n    tempFile = 1;\n    pPager->eState = PAGER_READER;     /* Pretend we already have a lock */\n    pPager->eLock = EXCLUSIVE_LOCK;    /* Pretend we are in EXCLUSIVE mode */\n    pPager->noLock = 1;                /* Do no locking */\n    readOnly = (vfsFlags&SQLITE_OPEN_READONLY);\n  }\n\n  /* The following call to PagerSetPagesize() serves to set the value of \n  ** Pager.pageSize and to allocate the Pager.pTmpSpace buffer.\n  */\n  if( rc==SQLITE_OK ){\n    assert( pPager->memDb==0 );\n    rc = sqlite3PagerSetPagesize(pPager, &szPageDflt, -1);\n    testcase( rc!=SQLITE_OK );\n  }\n\n  /* Initialize the PCache object. */\n  if( rc==SQLITE_OK ){\n    nExtra = ROUND8(nExtra);\n    assert( nExtra>=8 && nExtra<1000 );\n    rc = sqlite3PcacheOpen(szPageDflt, nExtra, !memDb,\n                       !memDb?pagerStress:0, (void *)pPager, pPager->pPCache);\n  }\n\n  /* If an error occurred above, free the  Pager structure and close the file.\n  */\n  if( rc!=SQLITE_OK ){\n    sqlite3OsClose(pPager->fd);\n    sqlite3PageFree(pPager->pTmpSpace);\n    sqlite3_free(pPager);\n    return rc;\n  }\n\n  PAGERTRACE((\"OPEN %d %s\\n\", FILEHANDLEID(pPager->fd), pPager->zFilename));\n  IOTRACE((\"OPEN %p %s\\n\", pPager, pPager->zFilename))\n\n  pPager->useJournal = (u8)useJournal;\n  /* pPager->stmtOpen = 0; */\n  /* pPager->stmtInUse = 0; */\n  /* pPager->nRef = 0; */\n  /* pPager->stmtSize = 0; */\n  /* pPager->stmtJSize = 0; */\n  /* pPager->nPage = 0; */\n  pPager->mxPgno = SQLITE_MAX_PAGE_COUNT;\n  /* pPager->state = PAGER_UNLOCK; */\n  /* pPager->errMask = 0; */\n  pPager->tempFile = (u8)tempFile;\n  assert( tempFile==PAGER_LOCKINGMODE_NORMAL \n          || tempFile==PAGER_LOCKINGMODE_EXCLUSIVE );\n  assert( PAGER_LOCKINGMODE_EXCLUSIVE==1 );\n  pPager->exclusiveMode = (u8)tempFile; \n  pPager->changeCountDone = pPager->tempFile;\n  pPager->memDb = (u8)memDb;\n  pPager->readOnly = (u8)readOnly;\n  assert( useJournal || pPager->tempFile );\n  pPager->noSync = pPager->tempFile;\n  if( pPager->noSync ){\n    assert( pPager->fullSync==0 );\n    assert( pPager->extraSync==0 );\n    assert( pPager->syncFlags==0 );\n    assert( pPager->walSyncFlags==0 );\n  }else{\n    pPager->fullSync = 1;\n    pPager->extraSync = 0;\n    pPager->syncFlags = SQLITE_SYNC_NORMAL;\n    pPager->walSyncFlags = SQLITE_SYNC_NORMAL | (SQLITE_SYNC_NORMAL<<2);\n  }\n  /* pPager->pFirst = 0; */\n  /* pPager->pFirstSynced = 0; */\n  /* pPager->pLast = 0; */\n  pPager->nExtra = (u16)nExtra;\n  pPager->journalSizeLimit = SQLITE_DEFAULT_JOURNAL_SIZE_LIMIT;\n  assert( isOpen(pPager->fd) || tempFile );\n  setSectorSize(pPager);\n  if( !useJournal ){\n    pPager->journalMode = PAGER_JOURNALMODE_OFF;\n  }else if( memDb || memJM ){\n    pPager->journalMode = PAGER_JOURNALMODE_MEMORY;\n  }\n  /* pPager->xBusyHandler = 0; */\n  /* pPager->pBusyHandlerArg = 0; */\n  pPager->xReiniter = xReinit;\n  setGetterMethod(pPager);\n  /* memset(pPager->aHash, 0, sizeof(pPager->aHash)); */\n  /* pPager->szMmap = SQLITE_DEFAULT_MMAP_SIZE // will be set by btree.c */\n\n  *ppPager = pPager;\n  return SQLITE_OK;\n}\n\n\n\n/*\n** This function is called after transitioning from PAGER_UNLOCK to\n** PAGER_SHARED state. It tests if there is a hot journal present in\n** the file-system for the given pager. A hot journal is one that \n** needs to be played back. According to this function, a hot-journal\n** file exists if the following criteria are met:\n**\n**   * The journal file exists in the file system, and\n**   * No process holds a RESERVED or greater lock on the database file, and\n**   * The database file itself is greater than 0 bytes in size, and\n**   * The first byte of the journal file exists and is not 0x00.\n**\n** If the current size of the database file is 0 but a journal file\n** exists, that is probably an old journal left over from a prior\n** database with the same name. In this case the journal file is\n** just deleted using OsDelete, *pExists is set to 0 and SQLITE_OK\n** is returned.\n**\n** This routine does not check if there is a master journal filename\n** at the end of the file. If there is, and that master journal file\n** does not exist, then the journal file is not really hot. In this\n** case this routine will return a false-positive. The pager_playback()\n** routine will discover that the journal file is not really hot and \n** will not roll it back. \n**\n** If a hot-journal file is found to exist, *pExists is set to 1 and \n** SQLITE_OK returned. If no hot-journal file is present, *pExists is\n** set to 0 and SQLITE_OK returned. If an IO error occurs while trying\n** to determine whether or not a hot-journal file exists, the IO error\n** code is returned and the value of *pExists is undefined.\n*/\nstatic int hasHotJournal(Pager *pPager, int *pExists){\n  sqlite3_vfs * const pVfs = pPager->pVfs;\n  int rc = SQLITE_OK;           /* Return code */\n  int exists = 1;               /* True if a journal file is present */\n  int jrnlOpen = !!isOpen(pPager->jfd);\n\n  assert( pPager->useJournal );\n  assert( isOpen(pPager->fd) );\n  assert( pPager->eState==PAGER_OPEN );\n\n  assert( jrnlOpen==0 || ( sqlite3OsDeviceCharacteristics(pPager->jfd) &\n    SQLITE_IOCAP_UNDELETABLE_WHEN_OPEN\n  ));\n\n  *pExists = 0;\n  if( !jrnlOpen ){\n    rc = sqlite3OsAccess(pVfs, pPager->zJournal, SQLITE_ACCESS_EXISTS, &exists);\n  }\n  if( rc==SQLITE_OK && exists ){\n    int locked = 0;             /* True if some process holds a RESERVED lock */\n\n    /* Race condition here:  Another process might have been holding the\n    ** the RESERVED lock and have a journal open at the sqlite3OsAccess() \n    ** call above, but then delete the journal and drop the lock before\n    ** we get to the following sqlite3OsCheckReservedLock() call.  If that\n    ** is the case, this routine might think there is a hot journal when\n    ** in fact there is none.  This results in a false-positive which will\n    ** be dealt with by the playback routine.  Ticket #3883.\n    */\n    rc = sqlite3OsCheckReservedLock(pPager->fd, &locked);\n    if( rc==SQLITE_OK && !locked ){\n      Pgno nPage;                 /* Number of pages in database file */\n\n      assert( pPager->tempFile==0 );\n      rc = pagerPagecount(pPager, &nPage);\n      if( rc==SQLITE_OK ){\n        /* If the database is zero pages in size, that means that either (1) the\n        ** journal is a remnant from a prior database with the same name where\n        ** the database file but not the journal was deleted, or (2) the initial\n        ** transaction that populates a new database is being rolled back.\n        ** In either case, the journal file can be deleted.  However, take care\n        ** not to delete the journal file if it is already open due to\n        ** journal_mode=PERSIST.\n        */\n        if( nPage==0 && !jrnlOpen ){\n          sqlite3BeginBenignMalloc();\n          if( pagerLockDb(pPager, RESERVED_LOCK)==SQLITE_OK ){\n            sqlite3OsDelete(pVfs, pPager->zJournal, 0);\n            if( !pPager->exclusiveMode ) pagerUnlockDb(pPager, SHARED_LOCK);\n          }\n          sqlite3EndBenignMalloc();\n        }else{\n          /* The journal file exists and no other connection has a reserved\n          ** or greater lock on the database file. Now check that there is\n          ** at least one non-zero bytes at the start of the journal file.\n          ** If there is, then we consider this journal to be hot. If not, \n          ** it can be ignored.\n          */\n          if( !jrnlOpen ){\n            int f = SQLITE_OPEN_READONLY|SQLITE_OPEN_MAIN_JOURNAL;\n            rc = sqlite3OsOpen(pVfs, pPager->zJournal, pPager->jfd, f, &f);\n          }\n          if( rc==SQLITE_OK ){\n            u8 first = 0;\n            rc = sqlite3OsRead(pPager->jfd, (void *)&first, 1, 0);\n            if( rc==SQLITE_IOERR_SHORT_READ ){\n              rc = SQLITE_OK;\n            }\n            if( !jrnlOpen ){\n              sqlite3OsClose(pPager->jfd);\n            }\n            *pExists = (first!=0);\n          }else if( rc==SQLITE_CANTOPEN ){\n            /* If we cannot open the rollback journal file in order to see if\n            ** it has a zero header, that might be due to an I/O error, or\n            ** it might be due to the race condition described above and in\n            ** ticket #3883.  Either way, assume that the journal is hot.\n            ** This might be a false positive.  But if it is, then the\n            ** automatic journal playback and recovery mechanism will deal\n            ** with it under an EXCLUSIVE lock where we do not need to\n            ** worry so much with race conditions.\n            */\n            *pExists = 1;\n            rc = SQLITE_OK;\n          }\n        }\n      }\n    }\n  }\n\n  return rc;\n}\n\n/*\n** This function is called to obtain a shared lock on the database file.\n** It is illegal to call sqlite3PagerGet() until after this function\n** has been successfully called. If a shared-lock is already held when\n** this function is called, it is a no-op.\n**\n** The following operations are also performed by this function.\n**\n**   1) If the pager is currently in PAGER_OPEN state (no lock held\n**      on the database file), then an attempt is made to obtain a\n**      SHARED lock on the database file. Immediately after obtaining\n**      the SHARED lock, the file-system is checked for a hot-journal,\n**      which is played back if present. Following any hot-journal \n**      rollback, the contents of the cache are validated by checking\n**      the 'change-counter' field of the database file header and\n**      discarded if they are found to be invalid.\n**\n**   2) If the pager is running in exclusive-mode, and there are currently\n**      no outstanding references to any pages, and is in the error state,\n**      then an attempt is made to clear the error state by discarding\n**      the contents of the page cache and rolling back any open journal\n**      file.\n**\n** If everything is successful, SQLITE_OK is returned. If an IO error \n** occurs while locking the database, checking for a hot-journal file or \n** rolling back a journal file, the IO error code is returned.\n*/\nSQLITE_PRIVATE int sqlite3PagerSharedLock(Pager *pPager){\n  int rc = SQLITE_OK;                /* Return code */\n\n  /* This routine is only called from b-tree and only when there are no\n  ** outstanding pages. This implies that the pager state should either\n  ** be OPEN or READER. READER is only possible if the pager is or was in \n  ** exclusive access mode.  */\n  assert( sqlite3PcacheRefCount(pPager->pPCache)==0 );\n  assert( assert_pager_state(pPager) );\n  assert( pPager->eState==PAGER_OPEN || pPager->eState==PAGER_READER );\n  assert( pPager->errCode==SQLITE_OK );\n\n  if( !pagerUseWal(pPager) && pPager->eState==PAGER_OPEN ){\n    int bHotJournal = 1;          /* True if there exists a hot journal-file */\n\n    assert( !MEMDB );\n    assert( pPager->tempFile==0 || pPager->eLock==EXCLUSIVE_LOCK );\n\n    rc = pager_wait_on_lock(pPager, SHARED_LOCK);\n    if( rc!=SQLITE_OK ){\n      assert( pPager->eLock==NO_LOCK || pPager->eLock==UNKNOWN_LOCK );\n      goto failed;\n    }\n\n    /* If a journal file exists, and there is no RESERVED lock on the\n    ** database file, then it either needs to be played back or deleted.\n    */\n    if( pPager->eLock<=SHARED_LOCK ){\n      rc = hasHotJournal(pPager, &bHotJournal);\n    }\n    if( rc!=SQLITE_OK ){\n      goto failed;\n    }\n    if( bHotJournal ){\n      if( pPager->readOnly ){\n        rc = SQLITE_READONLY_ROLLBACK;\n        goto failed;\n      }\n\n      /* Get an EXCLUSIVE lock on the database file. At this point it is\n      ** important that a RESERVED lock is not obtained on the way to the\n      ** EXCLUSIVE lock. If it were, another process might open the\n      ** database file, detect the RESERVED lock, and conclude that the\n      ** database is safe to read while this process is still rolling the \n      ** hot-journal back.\n      ** \n      ** Because the intermediate RESERVED lock is not requested, any\n      ** other process attempting to access the database file will get to \n      ** this point in the code and fail to obtain its own EXCLUSIVE lock \n      ** on the database file.\n      **\n      ** Unless the pager is in locking_mode=exclusive mode, the lock is\n      ** downgraded to SHARED_LOCK before this function returns.\n      */\n      rc = pagerLockDb(pPager, EXCLUSIVE_LOCK);\n      if( rc!=SQLITE_OK ){\n        goto failed;\n      }\n \n      /* If it is not already open and the file exists on disk, open the \n      ** journal for read/write access. Write access is required because \n      ** in exclusive-access mode the file descriptor will be kept open \n      ** and possibly used for a transaction later on. Also, write-access \n      ** is usually required to finalize the journal in journal_mode=persist \n      ** mode (and also for journal_mode=truncate on some systems).\n      **\n      ** If the journal does not exist, it usually means that some \n      ** other connection managed to get in and roll it back before \n      ** this connection obtained the exclusive lock above. Or, it \n      ** may mean that the pager was in the error-state when this\n      ** function was called and the journal file does not exist.\n      */\n      if( !isOpen(pPager->jfd) ){\n        sqlite3_vfs * const pVfs = pPager->pVfs;\n        int bExists;              /* True if journal file exists */\n        rc = sqlite3OsAccess(\n            pVfs, pPager->zJournal, SQLITE_ACCESS_EXISTS, &bExists);\n        if( rc==SQLITE_OK && bExists ){\n          int fout = 0;\n          int f = SQLITE_OPEN_READWRITE|SQLITE_OPEN_MAIN_JOURNAL;\n          assert( !pPager->tempFile );\n          rc = sqlite3OsOpen(pVfs, pPager->zJournal, pPager->jfd, f, &fout);\n          assert( rc!=SQLITE_OK || isOpen(pPager->jfd) );\n          if( rc==SQLITE_OK && fout&SQLITE_OPEN_READONLY ){\n            rc = SQLITE_CANTOPEN_BKPT;\n            sqlite3OsClose(pPager->jfd);\n          }\n        }\n      }\n \n      /* Playback and delete the journal.  Drop the database write\n      ** lock and reacquire the read lock. Purge the cache before\n      ** playing back the hot-journal so that we don't end up with\n      ** an inconsistent cache.  Sync the hot journal before playing\n      ** it back since the process that crashed and left the hot journal\n      ** probably did not sync it and we are required to always sync\n      ** the journal before playing it back.\n      */\n      if( isOpen(pPager->jfd) ){\n        assert( rc==SQLITE_OK );\n        rc = pagerSyncHotJournal(pPager);\n        if( rc==SQLITE_OK ){\n          rc = pager_playback(pPager, !pPager->tempFile);\n          pPager->eState = PAGER_OPEN;\n        }\n      }else if( !pPager->exclusiveMode ){\n        pagerUnlockDb(pPager, SHARED_LOCK);\n      }\n\n      if( rc!=SQLITE_OK ){\n        /* This branch is taken if an error occurs while trying to open\n        ** or roll back a hot-journal while holding an EXCLUSIVE lock. The\n        ** pager_unlock() routine will be called before returning to unlock\n        ** the file. If the unlock attempt fails, then Pager.eLock must be\n        ** set to UNKNOWN_LOCK (see the comment above the #define for \n        ** UNKNOWN_LOCK above for an explanation). \n        **\n        ** In order to get pager_unlock() to do this, set Pager.eState to\n        ** PAGER_ERROR now. This is not actually counted as a transition\n        ** to ERROR state in the state diagram at the top of this file,\n        ** since we know that the same call to pager_unlock() will very\n        ** shortly transition the pager object to the OPEN state. Calling\n        ** assert_pager_state() would fail now, as it should not be possible\n        ** to be in ERROR state when there are zero outstanding page \n        ** references.\n        */\n        pager_error(pPager, rc);\n        goto failed;\n      }\n\n      assert( pPager->eState==PAGER_OPEN );\n      assert( (pPager->eLock==SHARED_LOCK)\n           || (pPager->exclusiveMode && pPager->eLock>SHARED_LOCK)\n      );\n    }\n\n    if( !pPager->tempFile && pPager->hasHeldSharedLock ){\n      /* The shared-lock has just been acquired then check to\n      ** see if the database has been modified.  If the database has changed,\n      ** flush the cache.  The hasHeldSharedLock flag prevents this from\n      ** occurring on the very first access to a file, in order to save a\n      ** single unnecessary sqlite3OsRead() call at the start-up.\n      **\n      ** Database changes are detected by looking at 15 bytes beginning\n      ** at offset 24 into the file.  The first 4 of these 16 bytes are\n      ** a 32-bit counter that is incremented with each change.  The\n      ** other bytes change randomly with each file change when\n      ** a codec is in use.\n      ** \n      ** There is a vanishingly small chance that a change will not be \n      ** detected.  The chance of an undetected change is so small that\n      ** it can be neglected.\n      */\n      char dbFileVers[sizeof(pPager->dbFileVers)];\n\n      IOTRACE((\"CKVERS %p %d\\n\", pPager, sizeof(dbFileVers)));\n      rc = sqlite3OsRead(pPager->fd, &dbFileVers, sizeof(dbFileVers), 24);\n      if( rc!=SQLITE_OK ){\n        if( rc!=SQLITE_IOERR_SHORT_READ ){\n          goto failed;\n        }\n        memset(dbFileVers, 0, sizeof(dbFileVers));\n      }\n\n      if( memcmp(pPager->dbFileVers, dbFileVers, sizeof(dbFileVers))!=0 ){\n        pager_reset(pPager);\n\n        /* Unmap the database file. It is possible that external processes\n        ** may have truncated the database file and then extended it back\n        ** to its original size while this process was not holding a lock.\n        ** In this case there may exist a Pager.pMap mapping that appears\n        ** to be the right size but is not actually valid. Avoid this\n        ** possibility by unmapping the db here. */\n        if( USEFETCH(pPager) ){\n          sqlite3OsUnfetch(pPager->fd, 0, 0);\n        }\n      }\n    }\n\n    /* If there is a WAL file in the file-system, open this database in WAL\n    ** mode. Otherwise, the following function call is a no-op.\n    */\n    rc = pagerOpenWalIfPresent(pPager);\n#ifndef SQLITE_OMIT_WAL\n    assert( pPager->pWal==0 || rc==SQLITE_OK );\n#endif\n  }\n\n  if( pagerUseWal(pPager) ){\n    assert( rc==SQLITE_OK );\n    rc = pagerBeginReadTransaction(pPager);\n  }\n\n  if( pPager->tempFile==0 && pPager->eState==PAGER_OPEN && rc==SQLITE_OK ){\n    rc = pagerPagecount(pPager, &pPager->dbSize);\n  }\n\n failed:\n  if( rc!=SQLITE_OK ){\n    assert( !MEMDB );\n    pager_unlock(pPager);\n    assert( pPager->eState==PAGER_OPEN );\n  }else{\n    pPager->eState = PAGER_READER;\n    pPager->hasHeldSharedLock = 1;\n  }\n  return rc;\n}\n\n/*\n** If the reference count has reached zero, rollback any active\n** transaction and unlock the pager.\n**\n** Except, in locking_mode=EXCLUSIVE when there is nothing to in\n** the rollback journal, the unlock is not performed and there is\n** nothing to rollback, so this routine is a no-op.\n*/ \nstatic void pagerUnlockIfUnused(Pager *pPager){\n  if( sqlite3PcacheRefCount(pPager->pPCache)==0 ){\n    assert( pPager->nMmapOut==0 ); /* because page1 is never memory mapped */\n    pagerUnlockAndRollback(pPager);\n  }\n}\n\n/*\n** The page getter methods each try to acquire a reference to a\n** page with page number pgno. If the requested reference is \n** successfully obtained, it is copied to *ppPage and SQLITE_OK returned.\n**\n** There are different implementations of the getter method depending\n** on the current state of the pager.\n**\n**     getPageNormal()         --  The normal getter\n**     getPageError()          --  Used if the pager is in an error state\n**     getPageMmap()           --  Used if memory-mapped I/O is enabled\n**\n** If the requested page is already in the cache, it is returned. \n** Otherwise, a new page object is allocated and populated with data\n** read from the database file. In some cases, the pcache module may\n** choose not to allocate a new page object and may reuse an existing\n** object with no outstanding references.\n**\n** The extra data appended to a page is always initialized to zeros the \n** first time a page is loaded into memory. If the page requested is \n** already in the cache when this function is called, then the extra\n** data is left as it was when the page object was last used.\n**\n** If the database image is smaller than the requested page or if \n** the flags parameter contains the PAGER_GET_NOCONTENT bit and the \n** requested page is not already stored in the cache, then no \n** actual disk read occurs. In this case the memory image of the \n** page is initialized to all zeros. \n**\n** If PAGER_GET_NOCONTENT is true, it means that we do not care about\n** the contents of the page. This occurs in two scenarios:\n**\n**   a) When reading a free-list leaf page from the database, and\n**\n**   b) When a savepoint is being rolled back and we need to load\n**      a new page into the cache to be filled with the data read\n**      from the savepoint journal.\n**\n** If PAGER_GET_NOCONTENT is true, then the data returned is zeroed instead\n** of being read from the database. Additionally, the bits corresponding\n** to pgno in Pager.pInJournal (bitvec of pages already written to the\n** journal file) and the PagerSavepoint.pInSavepoint bitvecs of any open\n** savepoints are set. This means if the page is made writable at any\n** point in the future, using a call to sqlite3PagerWrite(), its contents\n** will not be journaled. This saves IO.\n**\n** The acquisition might fail for several reasons.  In all cases,\n** an appropriate error code is returned and *ppPage is set to NULL.\n**\n** See also sqlite3PagerLookup().  Both this routine and Lookup() attempt\n** to find a page in the in-memory cache first.  If the page is not already\n** in memory, this routine goes to disk to read it in whereas Lookup()\n** just returns 0.  This routine acquires a read-lock the first time it\n** has to go to disk, and could also playback an old journal if necessary.\n** Since Lookup() never goes to disk, it never has to deal with locks\n** or journal files.\n*/\nstatic int getPageNormal(\n  Pager *pPager,      /* The pager open on the database file */\n  Pgno pgno,          /* Page number to fetch */\n  DbPage **ppPage,    /* Write a pointer to the page here */\n  int flags           /* PAGER_GET_XXX flags */\n){\n  int rc = SQLITE_OK;\n  PgHdr *pPg;\n  u8 noContent;                   /* True if PAGER_GET_NOCONTENT is set */\n  sqlite3_pcache_page *pBase;\n\n  assert( pPager->errCode==SQLITE_OK );\n  assert( pPager->eState>=PAGER_READER );\n  assert( assert_pager_state(pPager) );\n  assert( pPager->hasHeldSharedLock==1 );\n\n  if( pgno==0 ) return SQLITE_CORRUPT_BKPT;\n  pBase = sqlite3PcacheFetch(pPager->pPCache, pgno, 3);\n  if( pBase==0 ){\n    pPg = 0;\n    rc = sqlite3PcacheFetchStress(pPager->pPCache, pgno, &pBase);\n    if( rc!=SQLITE_OK ) goto pager_acquire_err;\n    if( pBase==0 ){\n      rc = SQLITE_NOMEM_BKPT;\n      goto pager_acquire_err;\n    }\n  }\n  pPg = *ppPage = sqlite3PcacheFetchFinish(pPager->pPCache, pgno, pBase);\n  assert( pPg==(*ppPage) );\n  assert( pPg->pgno==pgno );\n  assert( pPg->pPager==pPager || pPg->pPager==0 );\n\n  noContent = (flags & PAGER_GET_NOCONTENT)!=0;\n  if( pPg->pPager && !noContent ){\n    /* In this case the pcache already contains an initialized copy of\n    ** the page. Return without further ado.  */\n    assert( pgno<=PAGER_MAX_PGNO && pgno!=PAGER_MJ_PGNO(pPager) );\n    pPager->aStat[PAGER_STAT_HIT]++;\n    return SQLITE_OK;\n\n  }else{\n    /* The pager cache has created a new page. Its content needs to \n    ** be initialized. But first some error checks:\n    **\n    ** (1) The maximum page number is 2^31\n    ** (2) Never try to fetch the locking page\n    */\n    if( pgno>PAGER_MAX_PGNO || pgno==PAGER_MJ_PGNO(pPager) ){\n      rc = SQLITE_CORRUPT_BKPT;\n      goto pager_acquire_err;\n    }\n\n    pPg->pPager = pPager;\n\n    assert( !isOpen(pPager->fd) || !MEMDB );\n    if( !isOpen(pPager->fd) || pPager->dbSize<pgno || noContent ){\n      if( pgno>pPager->mxPgno ){\n        rc = SQLITE_FULL;\n        goto pager_acquire_err;\n      }\n      if( noContent ){\n        /* Failure to set the bits in the InJournal bit-vectors is benign.\n        ** It merely means that we might do some extra work to journal a \n        ** page that does not need to be journaled.  Nevertheless, be sure \n        ** to test the case where a malloc error occurs while trying to set \n        ** a bit in a bit vector.\n        */\n        sqlite3BeginBenignMalloc();\n        if( pgno<=pPager->dbOrigSize ){\n          TESTONLY( rc = ) sqlite3BitvecSet(pPager->pInJournal, pgno);\n          testcase( rc==SQLITE_NOMEM );\n        }\n        TESTONLY( rc = ) addToSavepointBitvecs(pPager, pgno);\n        testcase( rc==SQLITE_NOMEM );\n        sqlite3EndBenignMalloc();\n      }\n      memset(pPg->pData, 0, pPager->pageSize);\n      IOTRACE((\"ZERO %p %d\\n\", pPager, pgno));\n    }else{\n      assert( pPg->pPager==pPager );\n      pPager->aStat[PAGER_STAT_MISS]++;\n      rc = readDbPage(pPg);\n      if( rc!=SQLITE_OK ){\n        goto pager_acquire_err;\n      }\n    }\n    pager_set_pagehash(pPg);\n  }\n  return SQLITE_OK;\n\npager_acquire_err:\n  assert( rc!=SQLITE_OK );\n  if( pPg ){\n    sqlite3PcacheDrop(pPg);\n  }\n  pagerUnlockIfUnused(pPager);\n  *ppPage = 0;\n  return rc;\n}\n\n#if SQLITE_MAX_MMAP_SIZE>0\n/* The page getter for when memory-mapped I/O is enabled */\nstatic int getPageMMap(\n  Pager *pPager,      /* The pager open on the database file */\n  Pgno pgno,          /* Page number to fetch */\n  DbPage **ppPage,    /* Write a pointer to the page here */\n  int flags           /* PAGER_GET_XXX flags */\n){\n  int rc = SQLITE_OK;\n  PgHdr *pPg = 0;\n  u32 iFrame = 0;                 /* Frame to read from WAL file */\n\n  /* It is acceptable to use a read-only (mmap) page for any page except\n  ** page 1 if there is no write-transaction open or the ACQUIRE_READONLY\n  ** flag was specified by the caller. And so long as the db is not a \n  ** temporary or in-memory database.  */\n  const int bMmapOk = (pgno>1\n   && (pPager->eState==PAGER_READER || (flags & PAGER_GET_READONLY))\n  );\n\n  assert( USEFETCH(pPager) );\n#ifdef SQLITE_HAS_CODEC\n  assert( pPager->xCodec==0 );\n#endif\n\n  /* Optimization note:  Adding the \"pgno<=1\" term before \"pgno==0\" here\n  ** allows the compiler optimizer to reuse the results of the \"pgno>1\"\n  ** test in the previous statement, and avoid testing pgno==0 in the\n  ** common case where pgno is large. */\n  if( pgno<=1 && pgno==0 ){\n    return SQLITE_CORRUPT_BKPT;\n  }\n  assert( pPager->eState>=PAGER_READER );\n  assert( assert_pager_state(pPager) );\n  assert( pPager->hasHeldSharedLock==1 );\n  assert( pPager->errCode==SQLITE_OK );\n\n  if( bMmapOk && pagerUseWal(pPager) ){\n    rc = sqlite3WalFindFrame(pPager->pWal, pgno, &iFrame);\n    if( rc!=SQLITE_OK ){\n      *ppPage = 0;\n      return rc;\n    }\n  }\n  if( bMmapOk && iFrame==0 ){\n    void *pData = 0;\n    rc = sqlite3OsFetch(pPager->fd, \n        (i64)(pgno-1) * pPager->pageSize, pPager->pageSize, &pData\n    );\n    if( rc==SQLITE_OK && pData ){\n      if( pPager->eState>PAGER_READER || pPager->tempFile ){\n        pPg = sqlite3PagerLookup(pPager, pgno);\n      }\n      if( pPg==0 ){\n        rc = pagerAcquireMapPage(pPager, pgno, pData, &pPg);\n      }else{\n        sqlite3OsUnfetch(pPager->fd, (i64)(pgno-1)*pPager->pageSize, pData);\n      }\n      if( pPg ){\n        assert( rc==SQLITE_OK );\n        *ppPage = pPg;\n        return SQLITE_OK;\n      }\n    }\n    if( rc!=SQLITE_OK ){\n      *ppPage = 0;\n      return rc;\n    }\n  }\n  return getPageNormal(pPager, pgno, ppPage, flags);\n}\n#endif /* SQLITE_MAX_MMAP_SIZE>0 */\n\n/* The page getter method for when the pager is an error state */\nstatic int getPageError(\n  Pager *pPager,      /* The pager open on the database file */\n  Pgno pgno,          /* Page number to fetch */\n  DbPage **ppPage,    /* Write a pointer to the page here */\n  int flags           /* PAGER_GET_XXX flags */\n){\n  UNUSED_PARAMETER(pgno);\n  UNUSED_PARAMETER(flags);\n  assert( pPager->errCode!=SQLITE_OK );\n  *ppPage = 0;\n  return pPager->errCode;\n}\n\n\n/* Dispatch all page fetch requests to the appropriate getter method.\n*/\nSQLITE_PRIVATE int sqlite3PagerGet(\n  Pager *pPager,      /* The pager open on the database file */\n  Pgno pgno,          /* Page number to fetch */\n  DbPage **ppPage,    /* Write a pointer to the page here */\n  int flags           /* PAGER_GET_XXX flags */\n){\n  return pPager->xGet(pPager, pgno, ppPage, flags);\n}\n\n/*\n** Acquire a page if it is already in the in-memory cache.  Do\n** not read the page from disk.  Return a pointer to the page,\n** or 0 if the page is not in cache. \n**\n** See also sqlite3PagerGet().  The difference between this routine\n** and sqlite3PagerGet() is that _get() will go to the disk and read\n** in the page if the page is not already in cache.  This routine\n** returns NULL if the page is not in cache or if a disk I/O error \n** has ever happened.\n*/\nSQLITE_PRIVATE DbPage *sqlite3PagerLookup(Pager *pPager, Pgno pgno){\n  sqlite3_pcache_page *pPage;\n  assert( pPager!=0 );\n  assert( pgno!=0 );\n  assert( pPager->pPCache!=0 );\n  pPage = sqlite3PcacheFetch(pPager->pPCache, pgno, 0);\n  assert( pPage==0 || pPager->hasHeldSharedLock );\n  if( pPage==0 ) return 0;\n  return sqlite3PcacheFetchFinish(pPager->pPCache, pgno, pPage);\n}\n\n/*\n** Release a page reference.\n**\n** The sqlite3PagerUnref() and sqlite3PagerUnrefNotNull() may only be\n** used if we know that the page being released is not the last page.\n** The btree layer always holds page1 open until the end, so these first\n** to routines can be used to release any page other than BtShared.pPage1.\n**\n** Use sqlite3PagerUnrefPageOne() to release page1.  This latter routine\n** checks the total number of outstanding pages and if the number of\n** pages reaches zero it drops the database lock.\n*/\nSQLITE_PRIVATE void sqlite3PagerUnrefNotNull(DbPage *pPg){\n  TESTONLY( Pager *pPager = pPg->pPager; )\n  assert( pPg!=0 );\n  if( pPg->flags & PGHDR_MMAP ){\n    assert( pPg->pgno!=1 );  /* Page1 is never memory mapped */\n    pagerReleaseMapPage(pPg);\n  }else{\n    sqlite3PcacheRelease(pPg);\n  }\n  /* Do not use this routine to release the last reference to page1 */\n  assert( sqlite3PcacheRefCount(pPager->pPCache)>0 );\n}\nSQLITE_PRIVATE void sqlite3PagerUnref(DbPage *pPg){\n  if( pPg ) sqlite3PagerUnrefNotNull(pPg);\n}\nSQLITE_PRIVATE void sqlite3PagerUnrefPageOne(DbPage *pPg){\n  Pager *pPager;\n  assert( pPg!=0 );\n  assert( pPg->pgno==1 );\n  assert( (pPg->flags & PGHDR_MMAP)==0 ); /* Page1 is never memory mapped */\n  pPager = pPg->pPager;\n  sqlite3PagerResetLockTimeout(pPager);\n  sqlite3PcacheRelease(pPg);\n  pagerUnlockIfUnused(pPager);\n}\n\n/*\n** This function is called at the start of every write transaction.\n** There must already be a RESERVED or EXCLUSIVE lock on the database \n** file when this routine is called.\n**\n** Open the journal file for pager pPager and write a journal header\n** to the start of it. If there are active savepoints, open the sub-journal\n** as well. This function is only used when the journal file is being \n** opened to write a rollback log for a transaction. It is not used \n** when opening a hot journal file to roll it back.\n**\n** If the journal file is already open (as it may be in exclusive mode),\n** then this function just writes a journal header to the start of the\n** already open file. \n**\n** Whether or not the journal file is opened by this function, the\n** Pager.pInJournal bitvec structure is allocated.\n**\n** Return SQLITE_OK if everything is successful. Otherwise, return \n** SQLITE_NOMEM if the attempt to allocate Pager.pInJournal fails, or \n** an IO error code if opening or writing the journal file fails.\n*/\nstatic int pager_open_journal(Pager *pPager){\n  int rc = SQLITE_OK;                        /* Return code */\n  sqlite3_vfs * const pVfs = pPager->pVfs;   /* Local cache of vfs pointer */\n\n  assert( pPager->eState==PAGER_WRITER_LOCKED );\n  assert( assert_pager_state(pPager) );\n  assert( pPager->pInJournal==0 );\n  \n  /* If already in the error state, this function is a no-op.  But on\n  ** the other hand, this routine is never called if we are already in\n  ** an error state. */\n  if( NEVER(pPager->errCode) ) return pPager->errCode;\n\n  if( !pagerUseWal(pPager) && pPager->journalMode!=PAGER_JOURNALMODE_OFF ){\n    pPager->pInJournal = sqlite3BitvecCreate(pPager->dbSize);\n    if( pPager->pInJournal==0 ){\n      return SQLITE_NOMEM_BKPT;\n    }\n  \n    /* Open the journal file if it is not already open. */\n    if( !isOpen(pPager->jfd) ){\n      if( pPager->journalMode==PAGER_JOURNALMODE_MEMORY ){\n        sqlite3MemJournalOpen(pPager->jfd);\n      }else{\n        int flags = SQLITE_OPEN_READWRITE|SQLITE_OPEN_CREATE;\n        int nSpill;\n\n        if( pPager->tempFile ){\n          flags |= (SQLITE_OPEN_DELETEONCLOSE|SQLITE_OPEN_TEMP_JOURNAL);\n          nSpill = sqlite3Config.nStmtSpill;\n        }else{\n          flags |= SQLITE_OPEN_MAIN_JOURNAL;\n          nSpill = jrnlBufferSize(pPager);\n        }\n          \n        /* Verify that the database still has the same name as it did when\n        ** it was originally opened. */\n        rc = databaseIsUnmoved(pPager);\n        if( rc==SQLITE_OK ){\n          rc = sqlite3JournalOpen (\n              pVfs, pPager->zJournal, pPager->jfd, flags, nSpill\n          );\n        }\n      }\n      assert( rc!=SQLITE_OK || isOpen(pPager->jfd) );\n    }\n  \n  \n    /* Write the first journal header to the journal file and open \n    ** the sub-journal if necessary.\n    */\n    if( rc==SQLITE_OK ){\n      /* TODO: Check if all of these are really required. */\n      pPager->nRec = 0;\n      pPager->journalOff = 0;\n      pPager->setMaster = 0;\n      pPager->journalHdr = 0;\n      rc = writeJournalHdr(pPager);\n    }\n  }\n\n  if( rc!=SQLITE_OK ){\n    sqlite3BitvecDestroy(pPager->pInJournal);\n    pPager->pInJournal = 0;\n  }else{\n    assert( pPager->eState==PAGER_WRITER_LOCKED );\n    pPager->eState = PAGER_WRITER_CACHEMOD;\n  }\n\n  return rc;\n}\n\n/*\n** Begin a write-transaction on the specified pager object. If a \n** write-transaction has already been opened, this function is a no-op.\n**\n** If the exFlag argument is false, then acquire at least a RESERVED\n** lock on the database file. If exFlag is true, then acquire at least\n** an EXCLUSIVE lock. If such a lock is already held, no locking \n** functions need be called.\n**\n** If the subjInMemory argument is non-zero, then any sub-journal opened\n** within this transaction will be opened as an in-memory file. This\n** has no effect if the sub-journal is already opened (as it may be when\n** running in exclusive mode) or if the transaction does not require a\n** sub-journal. If the subjInMemory argument is zero, then any required\n** sub-journal is implemented in-memory if pPager is an in-memory database, \n** or using a temporary file otherwise.\n*/\nSQLITE_PRIVATE int sqlite3PagerBegin(Pager *pPager, int exFlag, int subjInMemory){\n  int rc = SQLITE_OK;\n\n  if( pPager->errCode ) return pPager->errCode;\n  assert( pPager->eState>=PAGER_READER && pPager->eState<PAGER_ERROR );\n  pPager->subjInMemory = (u8)subjInMemory;\n\n  if( ALWAYS(pPager->eState==PAGER_READER) ){\n    assert( pPager->pInJournal==0 );\n\n    if( pagerUseWal(pPager) ){\n      /* If the pager is configured to use locking_mode=exclusive, and an\n      ** exclusive lock on the database is not already held, obtain it now.\n      */\n      if( pPager->exclusiveMode && sqlite3WalExclusiveMode(pPager->pWal, -1) ){\n        rc = pagerLockDb(pPager, EXCLUSIVE_LOCK);\n        if( rc!=SQLITE_OK ){\n          return rc;\n        }\n        (void)sqlite3WalExclusiveMode(pPager->pWal, 1);\n      }\n\n      /* Grab the write lock on the log file. If successful, upgrade to\n      ** PAGER_RESERVED state. Otherwise, return an error code to the caller.\n      ** The busy-handler is not invoked if another connection already\n      ** holds the write-lock. If possible, the upper layer will call it.\n      */\n      rc = sqlite3WalBeginWriteTransaction(pPager->pWal);\n    }else{\n      /* Obtain a RESERVED lock on the database file. If the exFlag parameter\n      ** is true, then immediately upgrade this to an EXCLUSIVE lock. The\n      ** busy-handler callback can be used when upgrading to the EXCLUSIVE\n      ** lock, but not when obtaining the RESERVED lock.\n      */\n      rc = pagerLockDb(pPager, RESERVED_LOCK);\n      if( rc==SQLITE_OK && exFlag ){\n        rc = pager_wait_on_lock(pPager, EXCLUSIVE_LOCK);\n      }\n    }\n\n    if( rc==SQLITE_OK ){\n      /* Change to WRITER_LOCKED state.\n      **\n      ** WAL mode sets Pager.eState to PAGER_WRITER_LOCKED or CACHEMOD\n      ** when it has an open transaction, but never to DBMOD or FINISHED.\n      ** This is because in those states the code to roll back savepoint \n      ** transactions may copy data from the sub-journal into the database \n      ** file as well as into the page cache. Which would be incorrect in \n      ** WAL mode.\n      */\n      pPager->eState = PAGER_WRITER_LOCKED;\n      pPager->dbHintSize = pPager->dbSize;\n      pPager->dbFileSize = pPager->dbSize;\n      pPager->dbOrigSize = pPager->dbSize;\n      pPager->journalOff = 0;\n    }\n\n    assert( rc==SQLITE_OK || pPager->eState==PAGER_READER );\n    assert( rc!=SQLITE_OK || pPager->eState==PAGER_WRITER_LOCKED );\n    assert( assert_pager_state(pPager) );\n  }\n\n  PAGERTRACE((\"TRANSACTION %d\\n\", PAGERID(pPager)));\n  return rc;\n}\n\n/*\n** Write page pPg onto the end of the rollback journal.\n*/\nstatic SQLITE_NOINLINE int pagerAddPageToRollbackJournal(PgHdr *pPg){\n  Pager *pPager = pPg->pPager;\n  int rc;\n  u32 cksum;\n  char *pData2;\n  i64 iOff = pPager->journalOff;\n\n  /* We should never write to the journal file the page that\n  ** contains the database locks.  The following assert verifies\n  ** that we do not. */\n  assert( pPg->pgno!=PAGER_MJ_PGNO(pPager) );\n\n  assert( pPager->journalHdr<=pPager->journalOff );\n  CODEC2(pPager, pPg->pData, pPg->pgno, 7, return SQLITE_NOMEM_BKPT, pData2);\n  cksum = pager_cksum(pPager, (u8*)pData2);\n\n  /* Even if an IO or diskfull error occurs while journalling the\n  ** page in the block above, set the need-sync flag for the page.\n  ** Otherwise, when the transaction is rolled back, the logic in\n  ** playback_one_page() will think that the page needs to be restored\n  ** in the database file. And if an IO error occurs while doing so,\n  ** then corruption may follow.\n  */\n  pPg->flags |= PGHDR_NEED_SYNC;\n\n  rc = write32bits(pPager->jfd, iOff, pPg->pgno);\n  if( rc!=SQLITE_OK ) return rc;\n  rc = sqlite3OsWrite(pPager->jfd, pData2, pPager->pageSize, iOff+4);\n  if( rc!=SQLITE_OK ) return rc;\n  rc = write32bits(pPager->jfd, iOff+pPager->pageSize+4, cksum);\n  if( rc!=SQLITE_OK ) return rc;\n\n  IOTRACE((\"JOUT %p %d %lld %d\\n\", pPager, pPg->pgno, \n           pPager->journalOff, pPager->pageSize));\n  PAGER_INCR(sqlite3_pager_writej_count);\n  PAGERTRACE((\"JOURNAL %d page %d needSync=%d hash(%08x)\\n\",\n       PAGERID(pPager), pPg->pgno, \n       ((pPg->flags&PGHDR_NEED_SYNC)?1:0), pager_pagehash(pPg)));\n\n  pPager->journalOff += 8 + pPager->pageSize;\n  pPager->nRec++;\n  assert( pPager->pInJournal!=0 );\n  rc = sqlite3BitvecSet(pPager->pInJournal, pPg->pgno);\n  testcase( rc==SQLITE_NOMEM );\n  assert( rc==SQLITE_OK || rc==SQLITE_NOMEM );\n  rc |= addToSavepointBitvecs(pPager, pPg->pgno);\n  assert( rc==SQLITE_OK || rc==SQLITE_NOMEM );\n  return rc;\n}\n\n/*\n** Mark a single data page as writeable. The page is written into the \n** main journal or sub-journal as required. If the page is written into\n** one of the journals, the corresponding bit is set in the \n** Pager.pInJournal bitvec and the PagerSavepoint.pInSavepoint bitvecs\n** of any open savepoints as appropriate.\n*/\nstatic int pager_write(PgHdr *pPg){\n  Pager *pPager = pPg->pPager;\n  int rc = SQLITE_OK;\n\n  /* This routine is not called unless a write-transaction has already \n  ** been started. The journal file may or may not be open at this point.\n  ** It is never called in the ERROR state.\n  */\n  assert( pPager->eState==PAGER_WRITER_LOCKED\n       || pPager->eState==PAGER_WRITER_CACHEMOD\n       || pPager->eState==PAGER_WRITER_DBMOD\n  );\n  assert( assert_pager_state(pPager) );\n  assert( pPager->errCode==0 );\n  assert( pPager->readOnly==0 );\n  CHECK_PAGE(pPg);\n\n  /* The journal file needs to be opened. Higher level routines have already\n  ** obtained the necessary locks to begin the write-transaction, but the\n  ** rollback journal might not yet be open. Open it now if this is the case.\n  **\n  ** This is done before calling sqlite3PcacheMakeDirty() on the page. \n  ** Otherwise, if it were done after calling sqlite3PcacheMakeDirty(), then\n  ** an error might occur and the pager would end up in WRITER_LOCKED state\n  ** with pages marked as dirty in the cache.\n  */\n  if( pPager->eState==PAGER_WRITER_LOCKED ){\n    rc = pager_open_journal(pPager);\n    if( rc!=SQLITE_OK ) return rc;\n  }\n  assert( pPager->eState>=PAGER_WRITER_CACHEMOD );\n  assert( assert_pager_state(pPager) );\n\n  /* Mark the page that is about to be modified as dirty. */\n  sqlite3PcacheMakeDirty(pPg);\n\n  /* If a rollback journal is in use, them make sure the page that is about\n  ** to change is in the rollback journal, or if the page is a new page off\n  ** then end of the file, make sure it is marked as PGHDR_NEED_SYNC.\n  */\n  assert( (pPager->pInJournal!=0) == isOpen(pPager->jfd) );\n  if( pPager->pInJournal!=0\n   && sqlite3BitvecTestNotNull(pPager->pInJournal, pPg->pgno)==0\n  ){\n    assert( pagerUseWal(pPager)==0 );\n    if( pPg->pgno<=pPager->dbOrigSize ){\n      rc = pagerAddPageToRollbackJournal(pPg);\n      if( rc!=SQLITE_OK ){\n        return rc;\n      }\n    }else{\n      if( pPager->eState!=PAGER_WRITER_DBMOD ){\n        pPg->flags |= PGHDR_NEED_SYNC;\n      }\n      PAGERTRACE((\"APPEND %d page %d needSync=%d\\n\",\n              PAGERID(pPager), pPg->pgno,\n             ((pPg->flags&PGHDR_NEED_SYNC)?1:0)));\n    }\n  }\n\n  /* The PGHDR_DIRTY bit is set above when the page was added to the dirty-list\n  ** and before writing the page into the rollback journal.  Wait until now,\n  ** after the page has been successfully journalled, before setting the\n  ** PGHDR_WRITEABLE bit that indicates that the page can be safely modified.\n  */\n  pPg->flags |= PGHDR_WRITEABLE;\n  \n  /* If the statement journal is open and the page is not in it,\n  ** then write the page into the statement journal.\n  */\n  if( pPager->nSavepoint>0 ){\n    rc = subjournalPageIfRequired(pPg);\n  }\n\n  /* Update the database size and return. */\n  if( pPager->dbSize<pPg->pgno ){\n    pPager->dbSize = pPg->pgno;\n  }\n  return rc;\n}\n\n/*\n** This is a variant of sqlite3PagerWrite() that runs when the sector size\n** is larger than the page size.  SQLite makes the (reasonable) assumption that\n** all bytes of a sector are written together by hardware.  Hence, all bytes of\n** a sector need to be journalled in case of a power loss in the middle of\n** a write.\n**\n** Usually, the sector size is less than or equal to the page size, in which\n** case pages can be individually written.  This routine only runs in the\n** exceptional case where the page size is smaller than the sector size.\n*/\nstatic SQLITE_NOINLINE int pagerWriteLargeSector(PgHdr *pPg){\n  int rc = SQLITE_OK;          /* Return code */\n  Pgno nPageCount;             /* Total number of pages in database file */\n  Pgno pg1;                    /* First page of the sector pPg is located on. */\n  int nPage = 0;               /* Number of pages starting at pg1 to journal */\n  int ii;                      /* Loop counter */\n  int needSync = 0;            /* True if any page has PGHDR_NEED_SYNC */\n  Pager *pPager = pPg->pPager; /* The pager that owns pPg */\n  Pgno nPagePerSector = (pPager->sectorSize/pPager->pageSize);\n\n  /* Set the doNotSpill NOSYNC bit to 1. This is because we cannot allow\n  ** a journal header to be written between the pages journaled by\n  ** this function.\n  */\n  assert( !MEMDB );\n  assert( (pPager->doNotSpill & SPILLFLAG_NOSYNC)==0 );\n  pPager->doNotSpill |= SPILLFLAG_NOSYNC;\n\n  /* This trick assumes that both the page-size and sector-size are\n  ** an integer power of 2. It sets variable pg1 to the identifier\n  ** of the first page of the sector pPg is located on.\n  */\n  pg1 = ((pPg->pgno-1) & ~(nPagePerSector-1)) + 1;\n\n  nPageCount = pPager->dbSize;\n  if( pPg->pgno>nPageCount ){\n    nPage = (pPg->pgno - pg1)+1;\n  }else if( (pg1+nPagePerSector-1)>nPageCount ){\n    nPage = nPageCount+1-pg1;\n  }else{\n    nPage = nPagePerSector;\n  }\n  assert(nPage>0);\n  assert(pg1<=pPg->pgno);\n  assert((pg1+nPage)>pPg->pgno);\n\n  for(ii=0; ii<nPage && rc==SQLITE_OK; ii++){\n    Pgno pg = pg1+ii;\n    PgHdr *pPage;\n    if( pg==pPg->pgno || !sqlite3BitvecTest(pPager->pInJournal, pg) ){\n      if( pg!=PAGER_MJ_PGNO(pPager) ){\n        rc = sqlite3PagerGet(pPager, pg, &pPage, 0);\n        if( rc==SQLITE_OK ){\n          rc = pager_write(pPage);\n          if( pPage->flags&PGHDR_NEED_SYNC ){\n            needSync = 1;\n          }\n          sqlite3PagerUnrefNotNull(pPage);\n        }\n      }\n    }else if( (pPage = sqlite3PagerLookup(pPager, pg))!=0 ){\n      if( pPage->flags&PGHDR_NEED_SYNC ){\n        needSync = 1;\n      }\n      sqlite3PagerUnrefNotNull(pPage);\n    }\n  }\n\n  /* If the PGHDR_NEED_SYNC flag is set for any of the nPage pages \n  ** starting at pg1, then it needs to be set for all of them. Because\n  ** writing to any of these nPage pages may damage the others, the\n  ** journal file must contain sync()ed copies of all of them\n  ** before any of them can be written out to the database file.\n  */\n  if( rc==SQLITE_OK && needSync ){\n    assert( !MEMDB );\n    for(ii=0; ii<nPage; ii++){\n      PgHdr *pPage = sqlite3PagerLookup(pPager, pg1+ii);\n      if( pPage ){\n        pPage->flags |= PGHDR_NEED_SYNC;\n        sqlite3PagerUnrefNotNull(pPage);\n      }\n    }\n  }\n\n  assert( (pPager->doNotSpill & SPILLFLAG_NOSYNC)!=0 );\n  pPager->doNotSpill &= ~SPILLFLAG_NOSYNC;\n  return rc;\n}\n\n/*\n** Mark a data page as writeable. This routine must be called before \n** making changes to a page. The caller must check the return value \n** of this function and be careful not to change any page data unless \n** this routine returns SQLITE_OK.\n**\n** The difference between this function and pager_write() is that this\n** function also deals with the special case where 2 or more pages\n** fit on a single disk sector. In this case all co-resident pages\n** must have been written to the journal file before returning.\n**\n** If an error occurs, SQLITE_NOMEM or an IO error code is returned\n** as appropriate. Otherwise, SQLITE_OK.\n*/\nSQLITE_PRIVATE int sqlite3PagerWrite(PgHdr *pPg){\n  Pager *pPager = pPg->pPager;\n  assert( (pPg->flags & PGHDR_MMAP)==0 );\n  assert( pPager->eState>=PAGER_WRITER_LOCKED );\n  assert( assert_pager_state(pPager) );\n  if( (pPg->flags & PGHDR_WRITEABLE)!=0 && pPager->dbSize>=pPg->pgno ){\n    if( pPager->nSavepoint ) return subjournalPageIfRequired(pPg);\n    return SQLITE_OK;\n  }else if( pPager->errCode ){\n    return pPager->errCode;\n  }else if( pPager->sectorSize > (u32)pPager->pageSize ){\n    assert( pPager->tempFile==0 );\n    return pagerWriteLargeSector(pPg);\n  }else{\n    return pager_write(pPg);\n  }\n}\n\n/*\n** Return TRUE if the page given in the argument was previously passed\n** to sqlite3PagerWrite().  In other words, return TRUE if it is ok\n** to change the content of the page.\n*/\n#ifndef NDEBUG\nSQLITE_PRIVATE int sqlite3PagerIswriteable(DbPage *pPg){\n  return pPg->flags & PGHDR_WRITEABLE;\n}\n#endif\n\n/*\n** A call to this routine tells the pager that it is not necessary to\n** write the information on page pPg back to the disk, even though\n** that page might be marked as dirty.  This happens, for example, when\n** the page has been added as a leaf of the freelist and so its\n** content no longer matters.\n**\n** The overlying software layer calls this routine when all of the data\n** on the given page is unused. The pager marks the page as clean so\n** that it does not get written to disk.\n**\n** Tests show that this optimization can quadruple the speed of large \n** DELETE operations.\n**\n** This optimization cannot be used with a temp-file, as the page may\n** have been dirty at the start of the transaction. In that case, if\n** memory pressure forces page pPg out of the cache, the data does need \n** to be written out to disk so that it may be read back in if the \n** current transaction is rolled back.\n*/\nSQLITE_PRIVATE void sqlite3PagerDontWrite(PgHdr *pPg){\n  Pager *pPager = pPg->pPager;\n  if( !pPager->tempFile && (pPg->flags&PGHDR_DIRTY) && pPager->nSavepoint==0 ){\n    PAGERTRACE((\"DONT_WRITE page %d of %d\\n\", pPg->pgno, PAGERID(pPager)));\n    IOTRACE((\"CLEAN %p %d\\n\", pPager, pPg->pgno))\n    pPg->flags |= PGHDR_DONT_WRITE;\n    pPg->flags &= ~PGHDR_WRITEABLE;\n    testcase( pPg->flags & PGHDR_NEED_SYNC );\n    pager_set_pagehash(pPg);\n  }\n}\n\n/*\n** This routine is called to increment the value of the database file \n** change-counter, stored as a 4-byte big-endian integer starting at \n** byte offset 24 of the pager file.  The secondary change counter at\n** 92 is also updated, as is the SQLite version number at offset 96.\n**\n** But this only happens if the pPager->changeCountDone flag is false.\n** To avoid excess churning of page 1, the update only happens once.\n** See also the pager_write_changecounter() routine that does an \n** unconditional update of the change counters.\n**\n** If the isDirectMode flag is zero, then this is done by calling \n** sqlite3PagerWrite() on page 1, then modifying the contents of the\n** page data. In this case the file will be updated when the current\n** transaction is committed.\n**\n** The isDirectMode flag may only be non-zero if the library was compiled\n** with the SQLITE_ENABLE_ATOMIC_WRITE macro defined. In this case,\n** if isDirect is non-zero, then the database file is updated directly\n** by writing an updated version of page 1 using a call to the \n** sqlite3OsWrite() function.\n*/\nstatic int pager_incr_changecounter(Pager *pPager, int isDirectMode){\n  int rc = SQLITE_OK;\n\n  assert( pPager->eState==PAGER_WRITER_CACHEMOD\n       || pPager->eState==PAGER_WRITER_DBMOD\n  );\n  assert( assert_pager_state(pPager) );\n\n  /* Declare and initialize constant integer 'isDirect'. If the\n  ** atomic-write optimization is enabled in this build, then isDirect\n  ** is initialized to the value passed as the isDirectMode parameter\n  ** to this function. Otherwise, it is always set to zero.\n  **\n  ** The idea is that if the atomic-write optimization is not\n  ** enabled at compile time, the compiler can omit the tests of\n  ** 'isDirect' below, as well as the block enclosed in the\n  ** \"if( isDirect )\" condition.\n  */\n#ifndef SQLITE_ENABLE_ATOMIC_WRITE\n# define DIRECT_MODE 0\n  assert( isDirectMode==0 );\n  UNUSED_PARAMETER(isDirectMode);\n#else\n# define DIRECT_MODE isDirectMode\n#endif\n\n  if( !pPager->changeCountDone && ALWAYS(pPager->dbSize>0) ){\n    PgHdr *pPgHdr;                /* Reference to page 1 */\n\n    assert( !pPager->tempFile && isOpen(pPager->fd) );\n\n    /* Open page 1 of the file for writing. */\n    rc = sqlite3PagerGet(pPager, 1, &pPgHdr, 0);\n    assert( pPgHdr==0 || rc==SQLITE_OK );\n\n    /* If page one was fetched successfully, and this function is not\n    ** operating in direct-mode, make page 1 writable.  When not in \n    ** direct mode, page 1 is always held in cache and hence the PagerGet()\n    ** above is always successful - hence the ALWAYS on rc==SQLITE_OK.\n    */\n    if( !DIRECT_MODE && ALWAYS(rc==SQLITE_OK) ){\n      rc = sqlite3PagerWrite(pPgHdr);\n    }\n\n    if( rc==SQLITE_OK ){\n      /* Actually do the update of the change counter */\n      pager_write_changecounter(pPgHdr);\n\n      /* If running in direct mode, write the contents of page 1 to the file. */\n      if( DIRECT_MODE ){\n        const void *zBuf;\n        assert( pPager->dbFileSize>0 );\n        CODEC2(pPager, pPgHdr->pData, 1, 6, rc=SQLITE_NOMEM_BKPT, zBuf);\n        if( rc==SQLITE_OK ){\n          rc = sqlite3OsWrite(pPager->fd, zBuf, pPager->pageSize, 0);\n          pPager->aStat[PAGER_STAT_WRITE]++;\n        }\n        if( rc==SQLITE_OK ){\n          /* Update the pager's copy of the change-counter. Otherwise, the\n          ** next time a read transaction is opened the cache will be\n          ** flushed (as the change-counter values will not match).  */\n          const void *pCopy = (const void *)&((const char *)zBuf)[24];\n          memcpy(&pPager->dbFileVers, pCopy, sizeof(pPager->dbFileVers));\n          pPager->changeCountDone = 1;\n        }\n      }else{\n        pPager->changeCountDone = 1;\n      }\n    }\n\n    /* Release the page reference. */\n    sqlite3PagerUnref(pPgHdr);\n  }\n  return rc;\n}\n\n/*\n** Sync the database file to disk. This is a no-op for in-memory databases\n** or pages with the Pager.noSync flag set.\n**\n** If successful, or if called on a pager for which it is a no-op, this\n** function returns SQLITE_OK. Otherwise, an IO error code is returned.\n*/\nSQLITE_PRIVATE int sqlite3PagerSync(Pager *pPager, const char *zMaster){\n  int rc = SQLITE_OK;\n  void *pArg = (void*)zMaster;\n  rc = sqlite3OsFileControl(pPager->fd, SQLITE_FCNTL_SYNC, pArg);\n  if( rc==SQLITE_NOTFOUND ) rc = SQLITE_OK;\n  if( rc==SQLITE_OK && !pPager->noSync ){\n    assert( !MEMDB );\n    rc = sqlite3OsSync(pPager->fd, pPager->syncFlags);\n  }\n  return rc;\n}\n\n/*\n** This function may only be called while a write-transaction is active in\n** rollback. If the connection is in WAL mode, this call is a no-op. \n** Otherwise, if the connection does not already have an EXCLUSIVE lock on \n** the database file, an attempt is made to obtain one.\n**\n** If the EXCLUSIVE lock is already held or the attempt to obtain it is\n** successful, or the connection is in WAL mode, SQLITE_OK is returned.\n** Otherwise, either SQLITE_BUSY or an SQLITE_IOERR_XXX error code is \n** returned.\n*/\nSQLITE_PRIVATE int sqlite3PagerExclusiveLock(Pager *pPager){\n  int rc = pPager->errCode;\n  assert( assert_pager_state(pPager) );\n  if( rc==SQLITE_OK ){\n    assert( pPager->eState==PAGER_WRITER_CACHEMOD \n         || pPager->eState==PAGER_WRITER_DBMOD \n         || pPager->eState==PAGER_WRITER_LOCKED \n    );\n    assert( assert_pager_state(pPager) );\n    if( 0==pagerUseWal(pPager) ){\n      rc = pager_wait_on_lock(pPager, EXCLUSIVE_LOCK);\n    }\n  }\n  return rc;\n}\n\n/*\n** Sync the database file for the pager pPager. zMaster points to the name\n** of a master journal file that should be written into the individual\n** journal file. zMaster may be NULL, which is interpreted as no master\n** journal (a single database transaction).\n**\n** This routine ensures that:\n**\n**   * The database file change-counter is updated,\n**   * the journal is synced (unless the atomic-write optimization is used),\n**   * all dirty pages are written to the database file, \n**   * the database file is truncated (if required), and\n**   * the database file synced. \n**\n** The only thing that remains to commit the transaction is to finalize \n** (delete, truncate or zero the first part of) the journal file (or \n** delete the master journal file if specified).\n**\n** Note that if zMaster==NULL, this does not overwrite a previous value\n** passed to an sqlite3PagerCommitPhaseOne() call.\n**\n** If the final parameter - noSync - is true, then the database file itself\n** is not synced. The caller must call sqlite3PagerSync() directly to\n** sync the database file before calling CommitPhaseTwo() to delete the\n** journal file in this case.\n*/\nSQLITE_PRIVATE int sqlite3PagerCommitPhaseOne(\n  Pager *pPager,                  /* Pager object */\n  const char *zMaster,            /* If not NULL, the master journal name */\n  int noSync                      /* True to omit the xSync on the db file */\n){\n  int rc = SQLITE_OK;             /* Return code */\n\n  assert( pPager->eState==PAGER_WRITER_LOCKED\n       || pPager->eState==PAGER_WRITER_CACHEMOD\n       || pPager->eState==PAGER_WRITER_DBMOD\n       || pPager->eState==PAGER_ERROR\n  );\n  assert( assert_pager_state(pPager) );\n\n  /* If a prior error occurred, report that error again. */\n  if( NEVER(pPager->errCode) ) return pPager->errCode;\n\n  /* Provide the ability to easily simulate an I/O error during testing */\n  if( sqlite3FaultSim(400) ) return SQLITE_IOERR;\n\n  PAGERTRACE((\"DATABASE SYNC: File=%s zMaster=%s nSize=%d\\n\", \n      pPager->zFilename, zMaster, pPager->dbSize));\n\n  /* If no database changes have been made, return early. */\n  if( pPager->eState<PAGER_WRITER_CACHEMOD ) return SQLITE_OK;\n\n  assert( MEMDB==0 || pPager->tempFile );\n  assert( isOpen(pPager->fd) || pPager->tempFile );\n  if( 0==pagerFlushOnCommit(pPager, 1) ){\n    /* If this is an in-memory db, or no pages have been written to, or this\n    ** function has already been called, it is mostly a no-op.  However, any\n    ** backup in progress needs to be restarted.  */\n    sqlite3BackupRestart(pPager->pBackup);\n  }else{\n    PgHdr *pList;\n    if( pagerUseWal(pPager) ){\n      PgHdr *pPageOne = 0;\n      pList = sqlite3PcacheDirtyList(pPager->pPCache);\n      if( pList==0 ){\n        /* Must have at least one page for the WAL commit flag.\n        ** Ticket [2d1a5c67dfc2363e44f29d9bbd57f] 2011-05-18 */\n        rc = sqlite3PagerGet(pPager, 1, &pPageOne, 0);\n        pList = pPageOne;\n        pList->pDirty = 0;\n      }\n      assert( rc==SQLITE_OK );\n      if( ALWAYS(pList) ){\n        rc = pagerWalFrames(pPager, pList, pPager->dbSize, 1);\n      }\n      sqlite3PagerUnref(pPageOne);\n      if( rc==SQLITE_OK ){\n        sqlite3PcacheCleanAll(pPager->pPCache);\n      }\n    }else{\n      /* The bBatch boolean is true if the batch-atomic-write commit method\n      ** should be used.  No rollback journal is created if batch-atomic-write\n      ** is enabled.\n      */\n#ifdef SQLITE_ENABLE_BATCH_ATOMIC_WRITE\n      sqlite3_file *fd = pPager->fd;\n      int bBatch = zMaster==0    /* An SQLITE_IOCAP_BATCH_ATOMIC commit */\n        && (sqlite3OsDeviceCharacteristics(fd) & SQLITE_IOCAP_BATCH_ATOMIC)\n        && !pPager->noSync\n        && sqlite3JournalIsInMemory(pPager->jfd);\n#else\n#     define bBatch 0\n#endif\n\n#ifdef SQLITE_ENABLE_ATOMIC_WRITE\n      /* The following block updates the change-counter. Exactly how it\n      ** does this depends on whether or not the atomic-update optimization\n      ** was enabled at compile time, and if this transaction meets the \n      ** runtime criteria to use the operation: \n      **\n      **    * The file-system supports the atomic-write property for\n      **      blocks of size page-size, and \n      **    * This commit is not part of a multi-file transaction, and\n      **    * Exactly one page has been modified and store in the journal file.\n      **\n      ** If the optimization was not enabled at compile time, then the\n      ** pager_incr_changecounter() function is called to update the change\n      ** counter in 'indirect-mode'. If the optimization is compiled in but\n      ** is not applicable to this transaction, call sqlite3JournalCreate()\n      ** to make sure the journal file has actually been created, then call\n      ** pager_incr_changecounter() to update the change-counter in indirect\n      ** mode. \n      **\n      ** Otherwise, if the optimization is both enabled and applicable,\n      ** then call pager_incr_changecounter() to update the change-counter\n      ** in 'direct' mode. In this case the journal file will never be\n      ** created for this transaction.\n      */\n      if( bBatch==0 ){\n        PgHdr *pPg;\n        assert( isOpen(pPager->jfd) \n            || pPager->journalMode==PAGER_JOURNALMODE_OFF \n            || pPager->journalMode==PAGER_JOURNALMODE_WAL \n            );\n        if( !zMaster && isOpen(pPager->jfd) \n         && pPager->journalOff==jrnlBufferSize(pPager) \n         && pPager->dbSize>=pPager->dbOrigSize\n         && (!(pPg = sqlite3PcacheDirtyList(pPager->pPCache)) || 0==pPg->pDirty)\n        ){\n          /* Update the db file change counter via the direct-write method. The \n          ** following call will modify the in-memory representation of page 1 \n          ** to include the updated change counter and then write page 1 \n          ** directly to the database file. Because of the atomic-write \n          ** property of the host file-system, this is safe.\n          */\n          rc = pager_incr_changecounter(pPager, 1);\n        }else{\n          rc = sqlite3JournalCreate(pPager->jfd);\n          if( rc==SQLITE_OK ){\n            rc = pager_incr_changecounter(pPager, 0);\n          }\n        }\n      }\n#else  /* SQLITE_ENABLE_ATOMIC_WRITE */\n#ifdef SQLITE_ENABLE_BATCH_ATOMIC_WRITE\n      if( zMaster ){\n        rc = sqlite3JournalCreate(pPager->jfd);\n        if( rc!=SQLITE_OK ) goto commit_phase_one_exit;\n        assert( bBatch==0 );\n      }\n#endif\n      rc = pager_incr_changecounter(pPager, 0);\n#endif /* !SQLITE_ENABLE_ATOMIC_WRITE */\n      if( rc!=SQLITE_OK ) goto commit_phase_one_exit;\n  \n      /* Write the master journal name into the journal file. If a master \n      ** journal file name has already been written to the journal file, \n      ** or if zMaster is NULL (no master journal), then this call is a no-op.\n      */\n      rc = writeMasterJournal(pPager, zMaster);\n      if( rc!=SQLITE_OK ) goto commit_phase_one_exit;\n  \n      /* Sync the journal file and write all dirty pages to the database.\n      ** If the atomic-update optimization is being used, this sync will not \n      ** create the journal file or perform any real IO.\n      **\n      ** Because the change-counter page was just modified, unless the\n      ** atomic-update optimization is used it is almost certain that the\n      ** journal requires a sync here. However, in locking_mode=exclusive\n      ** on a system under memory pressure it is just possible that this is \n      ** not the case. In this case it is likely enough that the redundant\n      ** xSync() call will be changed to a no-op by the OS anyhow. \n      */\n      rc = syncJournal(pPager, 0);\n      if( rc!=SQLITE_OK ) goto commit_phase_one_exit;\n\n      pList = sqlite3PcacheDirtyList(pPager->pPCache);\n#ifdef SQLITE_ENABLE_BATCH_ATOMIC_WRITE\n      if( bBatch ){\n        rc = sqlite3OsFileControl(fd, SQLITE_FCNTL_BEGIN_ATOMIC_WRITE, 0);\n        if( rc==SQLITE_OK ){\n          rc = pager_write_pagelist(pPager, pList);\n          if( rc==SQLITE_OK ){\n            rc = sqlite3OsFileControl(fd, SQLITE_FCNTL_COMMIT_ATOMIC_WRITE, 0);\n          }\n          if( rc!=SQLITE_OK ){\n            sqlite3OsFileControlHint(fd, SQLITE_FCNTL_ROLLBACK_ATOMIC_WRITE, 0);\n          }\n        }\n\n        if( (rc&0xFF)==SQLITE_IOERR && rc!=SQLITE_IOERR_NOMEM ){\n          rc = sqlite3JournalCreate(pPager->jfd);\n          if( rc!=SQLITE_OK ){\n            sqlite3OsClose(pPager->jfd);\n            goto commit_phase_one_exit;\n          }\n          bBatch = 0;\n        }else{\n          sqlite3OsClose(pPager->jfd);\n        }\n      }\n#endif /* SQLITE_ENABLE_BATCH_ATOMIC_WRITE */\n\n      if( bBatch==0 ){\n        rc = pager_write_pagelist(pPager, pList);\n      }\n      if( rc!=SQLITE_OK ){\n        assert( rc!=SQLITE_IOERR_BLOCKED );\n        goto commit_phase_one_exit;\n      }\n      sqlite3PcacheCleanAll(pPager->pPCache);\n\n      /* If the file on disk is smaller than the database image, use \n      ** pager_truncate to grow the file here. This can happen if the database\n      ** image was extended as part of the current transaction and then the\n      ** last page in the db image moved to the free-list. In this case the\n      ** last page is never written out to disk, leaving the database file\n      ** undersized. Fix this now if it is the case.  */\n      if( pPager->dbSize>pPager->dbFileSize ){\n        Pgno nNew = pPager->dbSize - (pPager->dbSize==PAGER_MJ_PGNO(pPager));\n        assert( pPager->eState==PAGER_WRITER_DBMOD );\n        rc = pager_truncate(pPager, nNew);\n        if( rc!=SQLITE_OK ) goto commit_phase_one_exit;\n      }\n  \n      /* Finally, sync the database file. */\n      if( !noSync ){\n        rc = sqlite3PagerSync(pPager, zMaster);\n      }\n      IOTRACE((\"DBSYNC %p\\n\", pPager))\n    }\n  }\n\ncommit_phase_one_exit:\n  if( rc==SQLITE_OK && !pagerUseWal(pPager) ){\n    pPager->eState = PAGER_WRITER_FINISHED;\n  }\n  return rc;\n}\n\n\n/*\n** When this function is called, the database file has been completely\n** updated to reflect the changes made by the current transaction and\n** synced to disk. The journal file still exists in the file-system \n** though, and if a failure occurs at this point it will eventually\n** be used as a hot-journal and the current transaction rolled back.\n**\n** This function finalizes the journal file, either by deleting, \n** truncating or partially zeroing it, so that it cannot be used \n** for hot-journal rollback. Once this is done the transaction is\n** irrevocably committed.\n**\n** If an error occurs, an IO error code is returned and the pager\n** moves into the error state. Otherwise, SQLITE_OK is returned.\n*/\nSQLITE_PRIVATE int sqlite3PagerCommitPhaseTwo(Pager *pPager){\n  int rc = SQLITE_OK;                  /* Return code */\n\n  /* This routine should not be called if a prior error has occurred.\n  ** But if (due to a coding error elsewhere in the system) it does get\n  ** called, just return the same error code without doing anything. */\n  if( NEVER(pPager->errCode) ) return pPager->errCode;\n\n  assert( pPager->eState==PAGER_WRITER_LOCKED\n       || pPager->eState==PAGER_WRITER_FINISHED\n       || (pagerUseWal(pPager) && pPager->eState==PAGER_WRITER_CACHEMOD)\n  );\n  assert( assert_pager_state(pPager) );\n\n  /* An optimization. If the database was not actually modified during\n  ** this transaction, the pager is running in exclusive-mode and is\n  ** using persistent journals, then this function is a no-op.\n  **\n  ** The start of the journal file currently contains a single journal \n  ** header with the nRec field set to 0. If such a journal is used as\n  ** a hot-journal during hot-journal rollback, 0 changes will be made\n  ** to the database file. So there is no need to zero the journal \n  ** header. Since the pager is in exclusive mode, there is no need\n  ** to drop any locks either.\n  */\n  if( pPager->eState==PAGER_WRITER_LOCKED \n   && pPager->exclusiveMode \n   && pPager->journalMode==PAGER_JOURNALMODE_PERSIST\n  ){\n    assert( pPager->journalOff==JOURNAL_HDR_SZ(pPager) || !pPager->journalOff );\n    pPager->eState = PAGER_READER;\n    return SQLITE_OK;\n  }\n\n  PAGERTRACE((\"COMMIT %d\\n\", PAGERID(pPager)));\n  pPager->iDataVersion++;\n  rc = pager_end_transaction(pPager, pPager->setMaster, 1);\n  return pager_error(pPager, rc);\n}\n\n/*\n** If a write transaction is open, then all changes made within the \n** transaction are reverted and the current write-transaction is closed.\n** The pager falls back to PAGER_READER state if successful, or PAGER_ERROR\n** state if an error occurs.\n**\n** If the pager is already in PAGER_ERROR state when this function is called,\n** it returns Pager.errCode immediately. No work is performed in this case.\n**\n** Otherwise, in rollback mode, this function performs two functions:\n**\n**   1) It rolls back the journal file, restoring all database file and \n**      in-memory cache pages to the state they were in when the transaction\n**      was opened, and\n**\n**   2) It finalizes the journal file, so that it is not used for hot\n**      rollback at any point in the future.\n**\n** Finalization of the journal file (task 2) is only performed if the \n** rollback is successful.\n**\n** In WAL mode, all cache-entries containing data modified within the\n** current transaction are either expelled from the cache or reverted to\n** their pre-transaction state by re-reading data from the database or\n** WAL files. The WAL transaction is then closed.\n*/\nSQLITE_PRIVATE int sqlite3PagerRollback(Pager *pPager){\n  int rc = SQLITE_OK;                  /* Return code */\n  PAGERTRACE((\"ROLLBACK %d\\n\", PAGERID(pPager)));\n\n  /* PagerRollback() is a no-op if called in READER or OPEN state. If\n  ** the pager is already in the ERROR state, the rollback is not \n  ** attempted here. Instead, the error code is returned to the caller.\n  */\n  assert( assert_pager_state(pPager) );\n  if( pPager->eState==PAGER_ERROR ) return pPager->errCode;\n  if( pPager->eState<=PAGER_READER ) return SQLITE_OK;\n\n  if( pagerUseWal(pPager) ){\n    int rc2;\n    rc = sqlite3PagerSavepoint(pPager, SAVEPOINT_ROLLBACK, -1);\n    rc2 = pager_end_transaction(pPager, pPager->setMaster, 0);\n    if( rc==SQLITE_OK ) rc = rc2;\n  }else if( !isOpen(pPager->jfd) || pPager->eState==PAGER_WRITER_LOCKED ){\n    int eState = pPager->eState;\n    rc = pager_end_transaction(pPager, 0, 0);\n    if( !MEMDB && eState>PAGER_WRITER_LOCKED ){\n      /* This can happen using journal_mode=off. Move the pager to the error \n      ** state to indicate that the contents of the cache may not be trusted.\n      ** Any active readers will get SQLITE_ABORT.\n      */\n      pPager->errCode = SQLITE_ABORT;\n      pPager->eState = PAGER_ERROR;\n      setGetterMethod(pPager);\n      return rc;\n    }\n  }else{\n    rc = pager_playback(pPager, 0);\n  }\n\n  assert( pPager->eState==PAGER_READER || rc!=SQLITE_OK );\n  assert( rc==SQLITE_OK || rc==SQLITE_FULL || rc==SQLITE_CORRUPT\n          || rc==SQLITE_NOMEM || (rc&0xFF)==SQLITE_IOERR \n          || rc==SQLITE_CANTOPEN\n  );\n\n  /* If an error occurs during a ROLLBACK, we can no longer trust the pager\n  ** cache. So call pager_error() on the way out to make any error persistent.\n  */\n  return pager_error(pPager, rc);\n}\n\n/*\n** Return TRUE if the database file is opened read-only.  Return FALSE\n** if the database is (in theory) writable.\n*/\nSQLITE_PRIVATE u8 sqlite3PagerIsreadonly(Pager *pPager){\n  return pPager->readOnly;\n}\n\n#ifdef SQLITE_DEBUG\n/*\n** Return the sum of the reference counts for all pages held by pPager.\n*/\nSQLITE_PRIVATE int sqlite3PagerRefcount(Pager *pPager){\n  return sqlite3PcacheRefCount(pPager->pPCache);\n}\n#endif\n\n/*\n** Return the approximate number of bytes of memory currently\n** used by the pager and its associated cache.\n*/\nSQLITE_PRIVATE int sqlite3PagerMemUsed(Pager *pPager){\n  int perPageSize = pPager->pageSize + pPager->nExtra + sizeof(PgHdr)\n                                     + 5*sizeof(void*);\n  return perPageSize*sqlite3PcachePagecount(pPager->pPCache)\n           + sqlite3MallocSize(pPager)\n           + pPager->pageSize;\n}\n\n/*\n** Return the number of references to the specified page.\n*/\nSQLITE_PRIVATE int sqlite3PagerPageRefcount(DbPage *pPage){\n  return sqlite3PcachePageRefcount(pPage);\n}\n\n#ifdef SQLITE_TEST\n/*\n** This routine is used for testing and analysis only.\n*/\nSQLITE_PRIVATE int *sqlite3PagerStats(Pager *pPager){\n  static int a[11];\n  a[0] = sqlite3PcacheRefCount(pPager->pPCache);\n  a[1] = sqlite3PcachePagecount(pPager->pPCache);\n  a[2] = sqlite3PcacheGetCachesize(pPager->pPCache);\n  a[3] = pPager->eState==PAGER_OPEN ? -1 : (int) pPager->dbSize;\n  a[4] = pPager->eState;\n  a[5] = pPager->errCode;\n  a[6] = pPager->aStat[PAGER_STAT_HIT];\n  a[7] = pPager->aStat[PAGER_STAT_MISS];\n  a[8] = 0;  /* Used to be pPager->nOvfl */\n  a[9] = pPager->nRead;\n  a[10] = pPager->aStat[PAGER_STAT_WRITE];\n  return a;\n}\n#endif\n\n/*\n** Parameter eStat must be one of SQLITE_DBSTATUS_CACHE_HIT, _MISS, _WRITE,\n** or _WRITE+1.  The SQLITE_DBSTATUS_CACHE_WRITE+1 case is a translation\n** of SQLITE_DBSTATUS_CACHE_SPILL.  The _SPILL case is not contiguous because\n** it was added later.\n**\n** Before returning, *pnVal is incremented by the\n** current cache hit or miss count, according to the value of eStat. If the \n** reset parameter is non-zero, the cache hit or miss count is zeroed before \n** returning.\n*/\nSQLITE_PRIVATE void sqlite3PagerCacheStat(Pager *pPager, int eStat, int reset, int *pnVal){\n\n  assert( eStat==SQLITE_DBSTATUS_CACHE_HIT\n       || eStat==SQLITE_DBSTATUS_CACHE_MISS\n       || eStat==SQLITE_DBSTATUS_CACHE_WRITE\n       || eStat==SQLITE_DBSTATUS_CACHE_WRITE+1\n  );\n\n  assert( SQLITE_DBSTATUS_CACHE_HIT+1==SQLITE_DBSTATUS_CACHE_MISS );\n  assert( SQLITE_DBSTATUS_CACHE_HIT+2==SQLITE_DBSTATUS_CACHE_WRITE );\n  assert( PAGER_STAT_HIT==0 && PAGER_STAT_MISS==1\n           && PAGER_STAT_WRITE==2 && PAGER_STAT_SPILL==3 );\n\n  eStat -= SQLITE_DBSTATUS_CACHE_HIT;\n  *pnVal += pPager->aStat[eStat];\n  if( reset ){\n    pPager->aStat[eStat] = 0;\n  }\n}\n\n/*\n** Return true if this is an in-memory or temp-file backed pager.\n*/\nSQLITE_PRIVATE int sqlite3PagerIsMemdb(Pager *pPager){\n  return pPager->tempFile;\n}\n\n/*\n** Check that there are at least nSavepoint savepoints open. If there are\n** currently less than nSavepoints open, then open one or more savepoints\n** to make up the difference. If the number of savepoints is already\n** equal to nSavepoint, then this function is a no-op.\n**\n** If a memory allocation fails, SQLITE_NOMEM is returned. If an error \n** occurs while opening the sub-journal file, then an IO error code is\n** returned. Otherwise, SQLITE_OK.\n*/\nstatic SQLITE_NOINLINE int pagerOpenSavepoint(Pager *pPager, int nSavepoint){\n  int rc = SQLITE_OK;                       /* Return code */\n  int nCurrent = pPager->nSavepoint;        /* Current number of savepoints */\n  int ii;                                   /* Iterator variable */\n  PagerSavepoint *aNew;                     /* New Pager.aSavepoint array */\n\n  assert( pPager->eState>=PAGER_WRITER_LOCKED );\n  assert( assert_pager_state(pPager) );\n  assert( nSavepoint>nCurrent && pPager->useJournal );\n\n  /* Grow the Pager.aSavepoint array using realloc(). Return SQLITE_NOMEM\n  ** if the allocation fails. Otherwise, zero the new portion in case a \n  ** malloc failure occurs while populating it in the for(...) loop below.\n  */\n  aNew = (PagerSavepoint *)sqlite3Realloc(\n      pPager->aSavepoint, sizeof(PagerSavepoint)*nSavepoint\n  );\n  if( !aNew ){\n    return SQLITE_NOMEM_BKPT;\n  }\n  memset(&aNew[nCurrent], 0, (nSavepoint-nCurrent) * sizeof(PagerSavepoint));\n  pPager->aSavepoint = aNew;\n\n  /* Populate the PagerSavepoint structures just allocated. */\n  for(ii=nCurrent; ii<nSavepoint; ii++){\n    aNew[ii].nOrig = pPager->dbSize;\n    if( isOpen(pPager->jfd) && pPager->journalOff>0 ){\n      aNew[ii].iOffset = pPager->journalOff;\n    }else{\n      aNew[ii].iOffset = JOURNAL_HDR_SZ(pPager);\n    }\n    aNew[ii].iSubRec = pPager->nSubRec;\n    aNew[ii].pInSavepoint = sqlite3BitvecCreate(pPager->dbSize);\n    if( !aNew[ii].pInSavepoint ){\n      return SQLITE_NOMEM_BKPT;\n    }\n    if( pagerUseWal(pPager) ){\n      sqlite3WalSavepoint(pPager->pWal, aNew[ii].aWalData);\n    }\n    pPager->nSavepoint = ii+1;\n  }\n  assert( pPager->nSavepoint==nSavepoint );\n  assertTruncateConstraint(pPager);\n  return rc;\n}\nSQLITE_PRIVATE int sqlite3PagerOpenSavepoint(Pager *pPager, int nSavepoint){\n  assert( pPager->eState>=PAGER_WRITER_LOCKED );\n  assert( assert_pager_state(pPager) );\n\n  if( nSavepoint>pPager->nSavepoint && pPager->useJournal ){\n    return pagerOpenSavepoint(pPager, nSavepoint);\n  }else{\n    return SQLITE_OK;\n  }\n}\n\n\n/*\n** This function is called to rollback or release (commit) a savepoint.\n** The savepoint to release or rollback need not be the most recently \n** created savepoint.\n**\n** Parameter op is always either SAVEPOINT_ROLLBACK or SAVEPOINT_RELEASE.\n** If it is SAVEPOINT_RELEASE, then release and destroy the savepoint with\n** index iSavepoint. If it is SAVEPOINT_ROLLBACK, then rollback all changes\n** that have occurred since the specified savepoint was created.\n**\n** The savepoint to rollback or release is identified by parameter \n** iSavepoint. A value of 0 means to operate on the outermost savepoint\n** (the first created). A value of (Pager.nSavepoint-1) means operate\n** on the most recently created savepoint. If iSavepoint is greater than\n** (Pager.nSavepoint-1), then this function is a no-op.\n**\n** If a negative value is passed to this function, then the current\n** transaction is rolled back. This is different to calling \n** sqlite3PagerRollback() because this function does not terminate\n** the transaction or unlock the database, it just restores the \n** contents of the database to its original state. \n**\n** In any case, all savepoints with an index greater than iSavepoint \n** are destroyed. If this is a release operation (op==SAVEPOINT_RELEASE),\n** then savepoint iSavepoint is also destroyed.\n**\n** This function may return SQLITE_NOMEM if a memory allocation fails,\n** or an IO error code if an IO error occurs while rolling back a \n** savepoint. If no errors occur, SQLITE_OK is returned.\n*/ \nSQLITE_PRIVATE int sqlite3PagerSavepoint(Pager *pPager, int op, int iSavepoint){\n  int rc = pPager->errCode;\n  \n#ifdef SQLITE_ENABLE_ZIPVFS\n  if( op==SAVEPOINT_RELEASE ) rc = SQLITE_OK;\n#endif\n\n  assert( op==SAVEPOINT_RELEASE || op==SAVEPOINT_ROLLBACK );\n  assert( iSavepoint>=0 || op==SAVEPOINT_ROLLBACK );\n\n  if( rc==SQLITE_OK && iSavepoint<pPager->nSavepoint ){\n    int ii;            /* Iterator variable */\n    int nNew;          /* Number of remaining savepoints after this op. */\n\n    /* Figure out how many savepoints will still be active after this\n    ** operation. Store this value in nNew. Then free resources associated \n    ** with any savepoints that are destroyed by this operation.\n    */\n    nNew = iSavepoint + (( op==SAVEPOINT_RELEASE ) ? 0 : 1);\n    for(ii=nNew; ii<pPager->nSavepoint; ii++){\n      sqlite3BitvecDestroy(pPager->aSavepoint[ii].pInSavepoint);\n    }\n    pPager->nSavepoint = nNew;\n\n    /* If this is a release of the outermost savepoint, truncate \n    ** the sub-journal to zero bytes in size. */\n    if( op==SAVEPOINT_RELEASE ){\n      if( nNew==0 && isOpen(pPager->sjfd) ){\n        /* Only truncate if it is an in-memory sub-journal. */\n        if( sqlite3JournalIsInMemory(pPager->sjfd) ){\n          rc = sqlite3OsTruncate(pPager->sjfd, 0);\n          assert( rc==SQLITE_OK );\n        }\n        pPager->nSubRec = 0;\n      }\n    }\n    /* Else this is a rollback operation, playback the specified savepoint.\n    ** If this is a temp-file, it is possible that the journal file has\n    ** not yet been opened. In this case there have been no changes to\n    ** the database file, so the playback operation can be skipped.\n    */\n    else if( pagerUseWal(pPager) || isOpen(pPager->jfd) ){\n      PagerSavepoint *pSavepoint = (nNew==0)?0:&pPager->aSavepoint[nNew-1];\n      rc = pagerPlaybackSavepoint(pPager, pSavepoint);\n      assert(rc!=SQLITE_DONE);\n    }\n    \n#ifdef SQLITE_ENABLE_ZIPVFS\n    /* If the cache has been modified but the savepoint cannot be rolled \n    ** back journal_mode=off, put the pager in the error state. This way,\n    ** if the VFS used by this pager includes ZipVFS, the entire transaction\n    ** can be rolled back at the ZipVFS level.  */\n    else if( \n        pPager->journalMode==PAGER_JOURNALMODE_OFF \n     && pPager->eState>=PAGER_WRITER_CACHEMOD\n    ){\n      pPager->errCode = SQLITE_ABORT;\n      pPager->eState = PAGER_ERROR;\n      setGetterMethod(pPager);\n    }\n#endif\n  }\n\n  return rc;\n}\n\n/*\n** Return the full pathname of the database file.\n**\n** Except, if the pager is in-memory only, then return an empty string if\n** nullIfMemDb is true.  This routine is called with nullIfMemDb==1 when\n** used to report the filename to the user, for compatibility with legacy\n** behavior.  But when the Btree needs to know the filename for matching to\n** shared cache, it uses nullIfMemDb==0 so that in-memory databases can\n** participate in shared-cache.\n*/\nSQLITE_PRIVATE const char *sqlite3PagerFilename(Pager *pPager, int nullIfMemDb){\n  return (nullIfMemDb && pPager->memDb) ? \"\" : pPager->zFilename;\n}\n\n/*\n** Return the VFS structure for the pager.\n*/\nSQLITE_PRIVATE sqlite3_vfs *sqlite3PagerVfs(Pager *pPager){\n  return pPager->pVfs;\n}\n\n/*\n** Return the file handle for the database file associated\n** with the pager.  This might return NULL if the file has\n** not yet been opened.\n*/\nSQLITE_PRIVATE sqlite3_file *sqlite3PagerFile(Pager *pPager){\n  return pPager->fd;\n}\n\n#ifdef SQLITE_ENABLE_SETLK_TIMEOUT\n/*\n** Reset the lock timeout for pager.\n*/\nSQLITE_PRIVATE void sqlite3PagerResetLockTimeout(Pager *pPager){\n  int x = 0;\n  sqlite3OsFileControl(pPager->fd, SQLITE_FCNTL_LOCK_TIMEOUT, &x);\n}\n#endif\n\n/*\n** Return the file handle for the journal file (if it exists).\n** This will be either the rollback journal or the WAL file.\n*/\nSQLITE_PRIVATE sqlite3_file *sqlite3PagerJrnlFile(Pager *pPager){\n#if SQLITE_OMIT_WAL\n  return pPager->jfd;\n#else\n  return pPager->pWal ? sqlite3WalFile(pPager->pWal) : pPager->jfd;\n#endif\n}\n\n/*\n** Return the full pathname of the journal file.\n*/\nSQLITE_PRIVATE const char *sqlite3PagerJournalname(Pager *pPager){\n  return pPager->zJournal;\n}\n\n#ifdef SQLITE_HAS_CODEC\n/*\n** Set or retrieve the codec for this pager\n*/\nSQLITE_PRIVATE void sqlite3PagerSetCodec(\n  Pager *pPager,\n  void *(*xCodec)(void*,void*,Pgno,int),\n  void (*xCodecSizeChng)(void*,int,int),\n  void (*xCodecFree)(void*),\n  void *pCodec\n){\n  if( pPager->xCodecFree ){\n    pPager->xCodecFree(pPager->pCodec);\n  }else{\n    pager_reset(pPager);\n  }\n  pPager->xCodec = pPager->memDb ? 0 : xCodec;\n  pPager->xCodecSizeChng = xCodecSizeChng;\n  pPager->xCodecFree = xCodecFree;\n  pPager->pCodec = pCodec;\n  setGetterMethod(pPager);\n  pagerReportSize(pPager);\n}\nSQLITE_PRIVATE void *sqlite3PagerGetCodec(Pager *pPager){\n  return pPager->pCodec;\n}\n\n/*\n** This function is called by the wal module when writing page content\n** into the log file.\n**\n** This function returns a pointer to a buffer containing the encrypted\n** page content. If a malloc fails, this function may return NULL.\n*/\nSQLITE_PRIVATE void *sqlite3PagerCodec(PgHdr *pPg){\n  void *aData = 0;\n  CODEC2(pPg->pPager, pPg->pData, pPg->pgno, 6, return 0, aData);\n  return aData;\n}\n\n/*\n** Return the current pager state\n*/\nSQLITE_PRIVATE int sqlite3PagerState(Pager *pPager){\n  return pPager->eState;\n}\n#endif /* SQLITE_HAS_CODEC */\n\n#ifndef SQLITE_OMIT_AUTOVACUUM\n/*\n** Move the page pPg to location pgno in the file.\n**\n** There must be no references to the page previously located at\n** pgno (which we call pPgOld) though that page is allowed to be\n** in cache.  If the page previously located at pgno is not already\n** in the rollback journal, it is not put there by by this routine.\n**\n** References to the page pPg remain valid. Updating any\n** meta-data associated with pPg (i.e. data stored in the nExtra bytes\n** allocated along with the page) is the responsibility of the caller.\n**\n** A transaction must be active when this routine is called. It used to be\n** required that a statement transaction was not active, but this restriction\n** has been removed (CREATE INDEX needs to move a page when a statement\n** transaction is active).\n**\n** If the fourth argument, isCommit, is non-zero, then this page is being\n** moved as part of a database reorganization just before the transaction \n** is being committed. In this case, it is guaranteed that the database page \n** pPg refers to will not be written to again within this transaction.\n**\n** This function may return SQLITE_NOMEM or an IO error code if an error\n** occurs. Otherwise, it returns SQLITE_OK.\n*/\nSQLITE_PRIVATE int sqlite3PagerMovepage(Pager *pPager, DbPage *pPg, Pgno pgno, int isCommit){\n  PgHdr *pPgOld;               /* The page being overwritten. */\n  Pgno needSyncPgno = 0;       /* Old value of pPg->pgno, if sync is required */\n  int rc;                      /* Return code */\n  Pgno origPgno;               /* The original page number */\n\n  assert( pPg->nRef>0 );\n  assert( pPager->eState==PAGER_WRITER_CACHEMOD\n       || pPager->eState==PAGER_WRITER_DBMOD\n  );\n  assert( assert_pager_state(pPager) );\n\n  /* In order to be able to rollback, an in-memory database must journal\n  ** the page we are moving from.\n  */\n  assert( pPager->tempFile || !MEMDB );\n  if( pPager->tempFile ){\n    rc = sqlite3PagerWrite(pPg);\n    if( rc ) return rc;\n  }\n\n  /* If the page being moved is dirty and has not been saved by the latest\n  ** savepoint, then save the current contents of the page into the \n  ** sub-journal now. This is required to handle the following scenario:\n  **\n  **   BEGIN;\n  **     <journal page X, then modify it in memory>\n  **     SAVEPOINT one;\n  **       <Move page X to location Y>\n  **     ROLLBACK TO one;\n  **\n  ** If page X were not written to the sub-journal here, it would not\n  ** be possible to restore its contents when the \"ROLLBACK TO one\"\n  ** statement were is processed.\n  **\n  ** subjournalPage() may need to allocate space to store pPg->pgno into\n  ** one or more savepoint bitvecs. This is the reason this function\n  ** may return SQLITE_NOMEM.\n  */\n  if( (pPg->flags & PGHDR_DIRTY)!=0\n   && SQLITE_OK!=(rc = subjournalPageIfRequired(pPg))\n  ){\n    return rc;\n  }\n\n  PAGERTRACE((\"MOVE %d page %d (needSync=%d) moves to %d\\n\", \n      PAGERID(pPager), pPg->pgno, (pPg->flags&PGHDR_NEED_SYNC)?1:0, pgno));\n  IOTRACE((\"MOVE %p %d %d\\n\", pPager, pPg->pgno, pgno))\n\n  /* If the journal needs to be sync()ed before page pPg->pgno can\n  ** be written to, store pPg->pgno in local variable needSyncPgno.\n  **\n  ** If the isCommit flag is set, there is no need to remember that\n  ** the journal needs to be sync()ed before database page pPg->pgno \n  ** can be written to. The caller has already promised not to write to it.\n  */\n  if( (pPg->flags&PGHDR_NEED_SYNC) && !isCommit ){\n    needSyncPgno = pPg->pgno;\n    assert( pPager->journalMode==PAGER_JOURNALMODE_OFF ||\n            pageInJournal(pPager, pPg) || pPg->pgno>pPager->dbOrigSize );\n    assert( pPg->flags&PGHDR_DIRTY );\n  }\n\n  /* If the cache contains a page with page-number pgno, remove it\n  ** from its hash chain. Also, if the PGHDR_NEED_SYNC flag was set for \n  ** page pgno before the 'move' operation, it needs to be retained \n  ** for the page moved there.\n  */\n  pPg->flags &= ~PGHDR_NEED_SYNC;\n  pPgOld = sqlite3PagerLookup(pPager, pgno);\n  assert( !pPgOld || pPgOld->nRef==1 );\n  if( pPgOld ){\n    pPg->flags |= (pPgOld->flags&PGHDR_NEED_SYNC);\n    if( pPager->tempFile ){\n      /* Do not discard pages from an in-memory database since we might\n      ** need to rollback later.  Just move the page out of the way. */\n      sqlite3PcacheMove(pPgOld, pPager->dbSize+1);\n    }else{\n      sqlite3PcacheDrop(pPgOld);\n    }\n  }\n\n  origPgno = pPg->pgno;\n  sqlite3PcacheMove(pPg, pgno);\n  sqlite3PcacheMakeDirty(pPg);\n\n  /* For an in-memory database, make sure the original page continues\n  ** to exist, in case the transaction needs to roll back.  Use pPgOld\n  ** as the original page since it has already been allocated.\n  */\n  if( pPager->tempFile && pPgOld ){\n    sqlite3PcacheMove(pPgOld, origPgno);\n    sqlite3PagerUnrefNotNull(pPgOld);\n  }\n\n  if( needSyncPgno ){\n    /* If needSyncPgno is non-zero, then the journal file needs to be \n    ** sync()ed before any data is written to database file page needSyncPgno.\n    ** Currently, no such page exists in the page-cache and the \n    ** \"is journaled\" bitvec flag has been set. This needs to be remedied by\n    ** loading the page into the pager-cache and setting the PGHDR_NEED_SYNC\n    ** flag.\n    **\n    ** If the attempt to load the page into the page-cache fails, (due\n    ** to a malloc() or IO failure), clear the bit in the pInJournal[]\n    ** array. Otherwise, if the page is loaded and written again in\n    ** this transaction, it may be written to the database file before\n    ** it is synced into the journal file. This way, it may end up in\n    ** the journal file twice, but that is not a problem.\n    */\n    PgHdr *pPgHdr;\n    rc = sqlite3PagerGet(pPager, needSyncPgno, &pPgHdr, 0);\n    if( rc!=SQLITE_OK ){\n      if( needSyncPgno<=pPager->dbOrigSize ){\n        assert( pPager->pTmpSpace!=0 );\n        sqlite3BitvecClear(pPager->pInJournal, needSyncPgno, pPager->pTmpSpace);\n      }\n      return rc;\n    }\n    pPgHdr->flags |= PGHDR_NEED_SYNC;\n    sqlite3PcacheMakeDirty(pPgHdr);\n    sqlite3PagerUnrefNotNull(pPgHdr);\n  }\n\n  return SQLITE_OK;\n}\n#endif\n\n/*\n** The page handle passed as the first argument refers to a dirty page \n** with a page number other than iNew. This function changes the page's \n** page number to iNew and sets the value of the PgHdr.flags field to \n** the value passed as the third parameter.\n*/\nSQLITE_PRIVATE void sqlite3PagerRekey(DbPage *pPg, Pgno iNew, u16 flags){\n  assert( pPg->pgno!=iNew );\n  pPg->flags = flags;\n  sqlite3PcacheMove(pPg, iNew);\n}\n\n/*\n** Return a pointer to the data for the specified page.\n*/\nSQLITE_PRIVATE void *sqlite3PagerGetData(DbPage *pPg){\n  assert( pPg->nRef>0 || pPg->pPager->memDb );\n  return pPg->pData;\n}\n\n/*\n** Return a pointer to the Pager.nExtra bytes of \"extra\" space \n** allocated along with the specified page.\n*/\nSQLITE_PRIVATE void *sqlite3PagerGetExtra(DbPage *pPg){\n  return pPg->pExtra;\n}\n\n/*\n** Get/set the locking-mode for this pager. Parameter eMode must be one\n** of PAGER_LOCKINGMODE_QUERY, PAGER_LOCKINGMODE_NORMAL or \n** PAGER_LOCKINGMODE_EXCLUSIVE. If the parameter is not _QUERY, then\n** the locking-mode is set to the value specified.\n**\n** The returned value is either PAGER_LOCKINGMODE_NORMAL or\n** PAGER_LOCKINGMODE_EXCLUSIVE, indicating the current (possibly updated)\n** locking-mode.\n*/\nSQLITE_PRIVATE int sqlite3PagerLockingMode(Pager *pPager, int eMode){\n  assert( eMode==PAGER_LOCKINGMODE_QUERY\n            || eMode==PAGER_LOCKINGMODE_NORMAL\n            || eMode==PAGER_LOCKINGMODE_EXCLUSIVE );\n  assert( PAGER_LOCKINGMODE_QUERY<0 );\n  assert( PAGER_LOCKINGMODE_NORMAL>=0 && PAGER_LOCKINGMODE_EXCLUSIVE>=0 );\n  assert( pPager->exclusiveMode || 0==sqlite3WalHeapMemory(pPager->pWal) );\n  if( eMode>=0 && !pPager->tempFile && !sqlite3WalHeapMemory(pPager->pWal) ){\n    pPager->exclusiveMode = (u8)eMode;\n  }\n  return (int)pPager->exclusiveMode;\n}\n\n/*\n** Set the journal-mode for this pager. Parameter eMode must be one of:\n**\n**    PAGER_JOURNALMODE_DELETE\n**    PAGER_JOURNALMODE_TRUNCATE\n**    PAGER_JOURNALMODE_PERSIST\n**    PAGER_JOURNALMODE_OFF\n**    PAGER_JOURNALMODE_MEMORY\n**    PAGER_JOURNALMODE_WAL\n**\n** The journalmode is set to the value specified if the change is allowed.\n** The change may be disallowed for the following reasons:\n**\n**   *  An in-memory database can only have its journal_mode set to _OFF\n**      or _MEMORY.\n**\n**   *  Temporary databases cannot have _WAL journalmode.\n**\n** The returned indicate the current (possibly updated) journal-mode.\n*/\nSQLITE_PRIVATE int sqlite3PagerSetJournalMode(Pager *pPager, int eMode){\n  u8 eOld = pPager->journalMode;    /* Prior journalmode */\n\n  /* The eMode parameter is always valid */\n  assert(      eMode==PAGER_JOURNALMODE_DELETE\n            || eMode==PAGER_JOURNALMODE_TRUNCATE\n            || eMode==PAGER_JOURNALMODE_PERSIST\n            || eMode==PAGER_JOURNALMODE_OFF \n            || eMode==PAGER_JOURNALMODE_WAL \n            || eMode==PAGER_JOURNALMODE_MEMORY );\n\n  /* This routine is only called from the OP_JournalMode opcode, and\n  ** the logic there will never allow a temporary file to be changed\n  ** to WAL mode.\n  */\n  assert( pPager->tempFile==0 || eMode!=PAGER_JOURNALMODE_WAL );\n\n  /* Do allow the journalmode of an in-memory database to be set to\n  ** anything other than MEMORY or OFF\n  */\n  if( MEMDB ){\n    assert( eOld==PAGER_JOURNALMODE_MEMORY || eOld==PAGER_JOURNALMODE_OFF );\n    if( eMode!=PAGER_JOURNALMODE_MEMORY && eMode!=PAGER_JOURNALMODE_OFF ){\n      eMode = eOld;\n    }\n  }\n\n  if( eMode!=eOld ){\n\n    /* Change the journal mode. */\n    assert( pPager->eState!=PAGER_ERROR );\n    pPager->journalMode = (u8)eMode;\n\n    /* When transistioning from TRUNCATE or PERSIST to any other journal\n    ** mode except WAL, unless the pager is in locking_mode=exclusive mode,\n    ** delete the journal file.\n    */\n    assert( (PAGER_JOURNALMODE_TRUNCATE & 5)==1 );\n    assert( (PAGER_JOURNALMODE_PERSIST & 5)==1 );\n    assert( (PAGER_JOURNALMODE_DELETE & 5)==0 );\n    assert( (PAGER_JOURNALMODE_MEMORY & 5)==4 );\n    assert( (PAGER_JOURNALMODE_OFF & 5)==0 );\n    assert( (PAGER_JOURNALMODE_WAL & 5)==5 );\n\n    assert( isOpen(pPager->fd) || pPager->exclusiveMode );\n    if( !pPager->exclusiveMode && (eOld & 5)==1 && (eMode & 1)==0 ){\n\n      /* In this case we would like to delete the journal file. If it is\n      ** not possible, then that is not a problem. Deleting the journal file\n      ** here is an optimization only.\n      **\n      ** Before deleting the journal file, obtain a RESERVED lock on the\n      ** database file. This ensures that the journal file is not deleted\n      ** while it is in use by some other client.\n      */\n      sqlite3OsClose(pPager->jfd);\n      if( pPager->eLock>=RESERVED_LOCK ){\n        sqlite3OsDelete(pPager->pVfs, pPager->zJournal, 0);\n      }else{\n        int rc = SQLITE_OK;\n        int state = pPager->eState;\n        assert( state==PAGER_OPEN || state==PAGER_READER );\n        if( state==PAGER_OPEN ){\n          rc = sqlite3PagerSharedLock(pPager);\n        }\n        if( pPager->eState==PAGER_READER ){\n          assert( rc==SQLITE_OK );\n          rc = pagerLockDb(pPager, RESERVED_LOCK);\n        }\n        if( rc==SQLITE_OK ){\n          sqlite3OsDelete(pPager->pVfs, pPager->zJournal, 0);\n        }\n        if( rc==SQLITE_OK && state==PAGER_READER ){\n          pagerUnlockDb(pPager, SHARED_LOCK);\n        }else if( state==PAGER_OPEN ){\n          pager_unlock(pPager);\n        }\n        assert( state==pPager->eState );\n      }\n    }else if( eMode==PAGER_JOURNALMODE_OFF ){\n      sqlite3OsClose(pPager->jfd);\n    }\n  }\n\n  /* Return the new journal mode */\n  return (int)pPager->journalMode;\n}\n\n/*\n** Return the current journal mode.\n*/\nSQLITE_PRIVATE int sqlite3PagerGetJournalMode(Pager *pPager){\n  return (int)pPager->journalMode;\n}\n\n/*\n** Return TRUE if the pager is in a state where it is OK to change the\n** journalmode.  Journalmode changes can only happen when the database\n** is unmodified.\n*/\nSQLITE_PRIVATE int sqlite3PagerOkToChangeJournalMode(Pager *pPager){\n  assert( assert_pager_state(pPager) );\n  if( pPager->eState>=PAGER_WRITER_CACHEMOD ) return 0;\n  if( NEVER(isOpen(pPager->jfd) && pPager->journalOff>0) ) return 0;\n  return 1;\n}\n\n/*\n** Get/set the size-limit used for persistent journal files.\n**\n** Setting the size limit to -1 means no limit is enforced.\n** An attempt to set a limit smaller than -1 is a no-op.\n*/\nSQLITE_PRIVATE i64 sqlite3PagerJournalSizeLimit(Pager *pPager, i64 iLimit){\n  if( iLimit>=-1 ){\n    pPager->journalSizeLimit = iLimit;\n    sqlite3WalLimit(pPager->pWal, iLimit);\n  }\n  return pPager->journalSizeLimit;\n}\n\n/*\n** Return a pointer to the pPager->pBackup variable. The backup module\n** in backup.c maintains the content of this variable. This module\n** uses it opaquely as an argument to sqlite3BackupRestart() and\n** sqlite3BackupUpdate() only.\n*/\nSQLITE_PRIVATE sqlite3_backup **sqlite3PagerBackupPtr(Pager *pPager){\n  return &pPager->pBackup;\n}\n\n#ifndef SQLITE_OMIT_VACUUM\n/*\n** Unless this is an in-memory or temporary database, clear the pager cache.\n*/\nSQLITE_PRIVATE void sqlite3PagerClearCache(Pager *pPager){\n  assert( MEMDB==0 || pPager->tempFile );\n  if( pPager->tempFile==0 ) pager_reset(pPager);\n}\n#endif\n\n#ifndef SQLITE_OMIT_WAL\n/*\n** This function is called when the user invokes \"PRAGMA wal_checkpoint\",\n** \"PRAGMA wal_blocking_checkpoint\" or calls the sqlite3_wal_checkpoint()\n** or wal_blocking_checkpoint() API functions.\n**\n** Parameter eMode is one of SQLITE_CHECKPOINT_PASSIVE, FULL or RESTART.\n*/\nSQLITE_PRIVATE int sqlite3PagerCheckpoint(\n  Pager *pPager,                  /* Checkpoint on this pager */\n  sqlite3 *db,                    /* Db handle used to check for interrupts */\n  int eMode,                      /* Type of checkpoint */\n  int *pnLog,                     /* OUT: Final number of frames in log */\n  int *pnCkpt                     /* OUT: Final number of checkpointed frames */\n){\n  int rc = SQLITE_OK;\n  if( pPager->pWal ){\n    rc = sqlite3WalCheckpoint(pPager->pWal, db, eMode,\n        (eMode==SQLITE_CHECKPOINT_PASSIVE ? 0 : pPager->xBusyHandler),\n        pPager->pBusyHandlerArg,\n        pPager->walSyncFlags, pPager->pageSize, (u8 *)pPager->pTmpSpace,\n        pnLog, pnCkpt\n    );\n    sqlite3PagerResetLockTimeout(pPager);\n  }\n  return rc;\n}\n\nSQLITE_PRIVATE int sqlite3PagerWalCallback(Pager *pPager){\n  return sqlite3WalCallback(pPager->pWal);\n}\n\n/*\n** Return true if the underlying VFS for the given pager supports the\n** primitives necessary for write-ahead logging.\n*/\nSQLITE_PRIVATE int sqlite3PagerWalSupported(Pager *pPager){\n  const sqlite3_io_methods *pMethods = pPager->fd->pMethods;\n  if( pPager->noLock ) return 0;\n  return pPager->exclusiveMode || (pMethods->iVersion>=2 && pMethods->xShmMap);\n}\n\n/*\n** Attempt to take an exclusive lock on the database file. If a PENDING lock\n** is obtained instead, immediately release it.\n*/\nstatic int pagerExclusiveLock(Pager *pPager){\n  int rc;                         /* Return code */\n\n  assert( pPager->eLock==SHARED_LOCK || pPager->eLock==EXCLUSIVE_LOCK );\n  rc = pagerLockDb(pPager, EXCLUSIVE_LOCK);\n  if( rc!=SQLITE_OK ){\n    /* If the attempt to grab the exclusive lock failed, release the \n    ** pending lock that may have been obtained instead.  */\n    pagerUnlockDb(pPager, SHARED_LOCK);\n  }\n\n  return rc;\n}\n\n/*\n** Call sqlite3WalOpen() to open the WAL handle. If the pager is in \n** exclusive-locking mode when this function is called, take an EXCLUSIVE\n** lock on the database file and use heap-memory to store the wal-index\n** in. Otherwise, use the normal shared-memory.\n*/\nstatic int pagerOpenWal(Pager *pPager){\n  int rc = SQLITE_OK;\n\n  assert( pPager->pWal==0 && pPager->tempFile==0 );\n  assert( pPager->eLock==SHARED_LOCK || pPager->eLock==EXCLUSIVE_LOCK );\n\n  /* If the pager is already in exclusive-mode, the WAL module will use \n  ** heap-memory for the wal-index instead of the VFS shared-memory \n  ** implementation. Take the exclusive lock now, before opening the WAL\n  ** file, to make sure this is safe.\n  */\n  if( pPager->exclusiveMode ){\n    rc = pagerExclusiveLock(pPager);\n  }\n\n  /* Open the connection to the log file. If this operation fails, \n  ** (e.g. due to malloc() failure), return an error code.\n  */\n  if( rc==SQLITE_OK ){\n    rc = sqlite3WalOpen(pPager->pVfs,\n        pPager->fd, pPager->zWal, pPager->exclusiveMode,\n        pPager->journalSizeLimit, &pPager->pWal\n    );\n  }\n  pagerFixMaplimit(pPager);\n\n  return rc;\n}\n\n\n/*\n** The caller must be holding a SHARED lock on the database file to call\n** this function.\n**\n** If the pager passed as the first argument is open on a real database\n** file (not a temp file or an in-memory database), and the WAL file\n** is not already open, make an attempt to open it now. If successful,\n** return SQLITE_OK. If an error occurs or the VFS used by the pager does \n** not support the xShmXXX() methods, return an error code. *pbOpen is\n** not modified in either case.\n**\n** If the pager is open on a temp-file (or in-memory database), or if\n** the WAL file is already open, set *pbOpen to 1 and return SQLITE_OK\n** without doing anything.\n*/\nSQLITE_PRIVATE int sqlite3PagerOpenWal(\n  Pager *pPager,                  /* Pager object */\n  int *pbOpen                     /* OUT: Set to true if call is a no-op */\n){\n  int rc = SQLITE_OK;             /* Return code */\n\n  assert( assert_pager_state(pPager) );\n  assert( pPager->eState==PAGER_OPEN   || pbOpen );\n  assert( pPager->eState==PAGER_READER || !pbOpen );\n  assert( pbOpen==0 || *pbOpen==0 );\n  assert( pbOpen!=0 || (!pPager->tempFile && !pPager->pWal) );\n\n  if( !pPager->tempFile && !pPager->pWal ){\n    if( !sqlite3PagerWalSupported(pPager) ) return SQLITE_CANTOPEN;\n\n    /* Close any rollback journal previously open */\n    sqlite3OsClose(pPager->jfd);\n\n    rc = pagerOpenWal(pPager);\n    if( rc==SQLITE_OK ){\n      pPager->journalMode = PAGER_JOURNALMODE_WAL;\n      pPager->eState = PAGER_OPEN;\n    }\n  }else{\n    *pbOpen = 1;\n  }\n\n  return rc;\n}\n\n/*\n** This function is called to close the connection to the log file prior\n** to switching from WAL to rollback mode.\n**\n** Before closing the log file, this function attempts to take an \n** EXCLUSIVE lock on the database file. If this cannot be obtained, an\n** error (SQLITE_BUSY) is returned and the log connection is not closed.\n** If successful, the EXCLUSIVE lock is not released before returning.\n*/\nSQLITE_PRIVATE int sqlite3PagerCloseWal(Pager *pPager, sqlite3 *db){\n  int rc = SQLITE_OK;\n\n  assert( pPager->journalMode==PAGER_JOURNALMODE_WAL );\n\n  /* If the log file is not already open, but does exist in the file-system,\n  ** it may need to be checkpointed before the connection can switch to\n  ** rollback mode. Open it now so this can happen.\n  */\n  if( !pPager->pWal ){\n    int logexists = 0;\n    rc = pagerLockDb(pPager, SHARED_LOCK);\n    if( rc==SQLITE_OK ){\n      rc = sqlite3OsAccess(\n          pPager->pVfs, pPager->zWal, SQLITE_ACCESS_EXISTS, &logexists\n      );\n    }\n    if( rc==SQLITE_OK && logexists ){\n      rc = pagerOpenWal(pPager);\n    }\n  }\n    \n  /* Checkpoint and close the log. Because an EXCLUSIVE lock is held on\n  ** the database file, the log and log-summary files will be deleted.\n  */\n  if( rc==SQLITE_OK && pPager->pWal ){\n    rc = pagerExclusiveLock(pPager);\n    if( rc==SQLITE_OK ){\n      rc = sqlite3WalClose(pPager->pWal, db, pPager->walSyncFlags,\n                           pPager->pageSize, (u8*)pPager->pTmpSpace);\n      pPager->pWal = 0;\n      pagerFixMaplimit(pPager);\n      if( rc && !pPager->exclusiveMode ) pagerUnlockDb(pPager, SHARED_LOCK);\n    }\n  }\n  return rc;\n}\n\n#ifdef SQLITE_ENABLE_SNAPSHOT\n/*\n** If this is a WAL database, obtain a snapshot handle for the snapshot\n** currently open. Otherwise, return an error.\n*/\nSQLITE_PRIVATE int sqlite3PagerSnapshotGet(Pager *pPager, sqlite3_snapshot **ppSnapshot){\n  int rc = SQLITE_ERROR;\n  if( pPager->pWal ){\n    rc = sqlite3WalSnapshotGet(pPager->pWal, ppSnapshot);\n  }\n  return rc;\n}\n\n/*\n** If this is a WAL database, store a pointer to pSnapshot. Next time a\n** read transaction is opened, attempt to read from the snapshot it \n** identifies. If this is not a WAL database, return an error.\n*/\nSQLITE_PRIVATE int sqlite3PagerSnapshotOpen(Pager *pPager, sqlite3_snapshot *pSnapshot){\n  int rc = SQLITE_OK;\n  if( pPager->pWal ){\n    sqlite3WalSnapshotOpen(pPager->pWal, pSnapshot);\n  }else{\n    rc = SQLITE_ERROR;\n  }\n  return rc;\n}\n\n/*\n** If this is a WAL database, call sqlite3WalSnapshotRecover(). If this \n** is not a WAL database, return an error.\n*/\nSQLITE_PRIVATE int sqlite3PagerSnapshotRecover(Pager *pPager){\n  int rc;\n  if( pPager->pWal ){\n    rc = sqlite3WalSnapshotRecover(pPager->pWal);\n  }else{\n    rc = SQLITE_ERROR;\n  }\n  return rc;\n}\n\n/*\n** The caller currently has a read transaction open on the database.\n** If this is not a WAL database, SQLITE_ERROR is returned. Otherwise,\n** this function takes a SHARED lock on the CHECKPOINTER slot and then\n** checks if the snapshot passed as the second argument is still \n** available. If so, SQLITE_OK is returned.\n**\n** If the snapshot is not available, SQLITE_ERROR is returned. Or, if\n** the CHECKPOINTER lock cannot be obtained, SQLITE_BUSY. If any error\n** occurs (any value other than SQLITE_OK is returned), the CHECKPOINTER\n** lock is released before returning.\n*/\nSQLITE_PRIVATE int sqlite3PagerSnapshotCheck(Pager *pPager, sqlite3_snapshot *pSnapshot){\n  int rc;\n  if( pPager->pWal ){\n    rc = sqlite3WalSnapshotCheck(pPager->pWal, pSnapshot);\n  }else{\n    rc = SQLITE_ERROR;\n  }\n  return rc;\n}\n\n/*\n** Release a lock obtained by an earlier successful call to\n** sqlite3PagerSnapshotCheck().\n*/\nSQLITE_PRIVATE void sqlite3PagerSnapshotUnlock(Pager *pPager){\n  assert( pPager->pWal );\n  return sqlite3WalSnapshotUnlock(pPager->pWal);\n}\n\n#endif /* SQLITE_ENABLE_SNAPSHOT */\n#endif /* !SQLITE_OMIT_WAL */\n\n#ifdef SQLITE_ENABLE_ZIPVFS\n/*\n** A read-lock must be held on the pager when this function is called. If\n** the pager is in WAL mode and the WAL file currently contains one or more\n** frames, return the size in bytes of the page images stored within the\n** WAL frames. Otherwise, if this is not a WAL database or the WAL file\n** is empty, return 0.\n*/\nSQLITE_PRIVATE int sqlite3PagerWalFramesize(Pager *pPager){\n  assert( pPager->eState>=PAGER_READER );\n  return sqlite3WalFramesize(pPager->pWal);\n}\n#endif\n\n#endif /* SQLITE_OMIT_DISKIO */\n\n/* BEGIN SQLCIPHER */\n#ifdef SQLITE_HAS_CODEC\n\nSQLITE_API int sqlite3pager_is_mj_pgno(Pager *pPager, Pgno pgno) {\n  return (PAGER_MJ_PGNO(pPager) == pgno) ? 1 : 0;\n}\n\nSQLITE_API void sqlite3pager_error(Pager *pPager, int error) {\n  pPager->errCode = error;\n  pPager->eState = PAGER_ERROR;\n  setGetterMethod(pPager);\n}\n\nSQLITE_API void sqlite3pager_reset(Pager *pPager){\n  pager_reset(pPager);\n}\n\n#endif\n/* END SQLCIPHER */\n\n\n/************** End of pager.c ***********************************************/\n/************** Begin file wal.c *********************************************/\n/*\n** 2010 February 1\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n**\n** This file contains the implementation of a write-ahead log (WAL) used in \n** \"journal_mode=WAL\" mode.\n**\n** WRITE-AHEAD LOG (WAL) FILE FORMAT\n**\n** A WAL file consists of a header followed by zero or more \"frames\".\n** Each frame records the revised content of a single page from the\n** database file.  All changes to the database are recorded by writing\n** frames into the WAL.  Transactions commit when a frame is written that\n** contains a commit marker.  A single WAL can and usually does record \n** multiple transactions.  Periodically, the content of the WAL is\n** transferred back into the database file in an operation called a\n** \"checkpoint\".\n**\n** A single WAL file can be used multiple times.  In other words, the\n** WAL can fill up with frames and then be checkpointed and then new\n** frames can overwrite the old ones.  A WAL always grows from beginning\n** toward the end.  Checksums and counters attached to each frame are\n** used to determine which frames within the WAL are valid and which\n** are leftovers from prior checkpoints.\n**\n** The WAL header is 32 bytes in size and consists of the following eight\n** big-endian 32-bit unsigned integer values:\n**\n**     0: Magic number.  0x377f0682 or 0x377f0683\n**     4: File format version.  Currently 3007000\n**     8: Database page size.  Example: 1024\n**    12: Checkpoint sequence number\n**    16: Salt-1, random integer incremented with each checkpoint\n**    20: Salt-2, a different random integer changing with each ckpt\n**    24: Checksum-1 (first part of checksum for first 24 bytes of header).\n**    28: Checksum-2 (second part of checksum for first 24 bytes of header).\n**\n** Immediately following the wal-header are zero or more frames. Each\n** frame consists of a 24-byte frame-header followed by a <page-size> bytes\n** of page data. The frame-header is six big-endian 32-bit unsigned \n** integer values, as follows:\n**\n**     0: Page number.\n**     4: For commit records, the size of the database image in pages \n**        after the commit. For all other records, zero.\n**     8: Salt-1 (copied from the header)\n**    12: Salt-2 (copied from the header)\n**    16: Checksum-1.\n**    20: Checksum-2.\n**\n** A frame is considered valid if and only if the following conditions are\n** true:\n**\n**    (1) The salt-1 and salt-2 values in the frame-header match\n**        salt values in the wal-header\n**\n**    (2) The checksum values in the final 8 bytes of the frame-header\n**        exactly match the checksum computed consecutively on the\n**        WAL header and the first 8 bytes and the content of all frames\n**        up to and including the current frame.\n**\n** The checksum is computed using 32-bit big-endian integers if the\n** magic number in the first 4 bytes of the WAL is 0x377f0683 and it\n** is computed using little-endian if the magic number is 0x377f0682.\n** The checksum values are always stored in the frame header in a\n** big-endian format regardless of which byte order is used to compute\n** the checksum.  The checksum is computed by interpreting the input as\n** an even number of unsigned 32-bit integers: x[0] through x[N].  The\n** algorithm used for the checksum is as follows:\n** \n**   for i from 0 to n-1 step 2:\n**     s0 += x[i] + s1;\n**     s1 += x[i+1] + s0;\n**   endfor\n**\n** Note that s0 and s1 are both weighted checksums using fibonacci weights\n** in reverse order (the largest fibonacci weight occurs on the first element\n** of the sequence being summed.)  The s1 value spans all 32-bit \n** terms of the sequence whereas s0 omits the final term.\n**\n** On a checkpoint, the WAL is first VFS.xSync-ed, then valid content of the\n** WAL is transferred into the database, then the database is VFS.xSync-ed.\n** The VFS.xSync operations serve as write barriers - all writes launched\n** before the xSync must complete before any write that launches after the\n** xSync begins.\n**\n** After each checkpoint, the salt-1 value is incremented and the salt-2\n** value is randomized.  This prevents old and new frames in the WAL from\n** being considered valid at the same time and being checkpointing together\n** following a crash.\n**\n** READER ALGORITHM\n**\n** To read a page from the database (call it page number P), a reader\n** first checks the WAL to see if it contains page P.  If so, then the\n** last valid instance of page P that is a followed by a commit frame\n** or is a commit frame itself becomes the value read.  If the WAL\n** contains no copies of page P that are valid and which are a commit\n** frame or are followed by a commit frame, then page P is read from\n** the database file.\n**\n** To start a read transaction, the reader records the index of the last\n** valid frame in the WAL.  The reader uses this recorded \"mxFrame\" value\n** for all subsequent read operations.  New transactions can be appended\n** to the WAL, but as long as the reader uses its original mxFrame value\n** and ignores the newly appended content, it will see a consistent snapshot\n** of the database from a single point in time.  This technique allows\n** multiple concurrent readers to view different versions of the database\n** content simultaneously.\n**\n** The reader algorithm in the previous paragraphs works correctly, but \n** because frames for page P can appear anywhere within the WAL, the\n** reader has to scan the entire WAL looking for page P frames.  If the\n** WAL is large (multiple megabytes is typical) that scan can be slow,\n** and read performance suffers.  To overcome this problem, a separate\n** data structure called the wal-index is maintained to expedite the\n** search for frames of a particular page.\n** \n** WAL-INDEX FORMAT\n**\n** Conceptually, the wal-index is shared memory, though VFS implementations\n** might choose to implement the wal-index using a mmapped file.  Because\n** the wal-index is shared memory, SQLite does not support journal_mode=WAL \n** on a network filesystem.  All users of the database must be able to\n** share memory.\n**\n** In the default unix and windows implementation, the wal-index is a mmapped\n** file whose name is the database name with a \"-shm\" suffix added.  For that\n** reason, the wal-index is sometimes called the \"shm\" file.\n**\n** The wal-index is transient.  After a crash, the wal-index can (and should\n** be) reconstructed from the original WAL file.  In fact, the VFS is required\n** to either truncate or zero the header of the wal-index when the last\n** connection to it closes.  Because the wal-index is transient, it can\n** use an architecture-specific format; it does not have to be cross-platform.\n** Hence, unlike the database and WAL file formats which store all values\n** as big endian, the wal-index can store multi-byte values in the native\n** byte order of the host computer.\n**\n** The purpose of the wal-index is to answer this question quickly:  Given\n** a page number P and a maximum frame index M, return the index of the \n** last frame in the wal before frame M for page P in the WAL, or return\n** NULL if there are no frames for page P in the WAL prior to M.\n**\n** The wal-index consists of a header region, followed by an one or\n** more index blocks.  \n**\n** The wal-index header contains the total number of frames within the WAL\n** in the mxFrame field.\n**\n** Each index block except for the first contains information on \n** HASHTABLE_NPAGE frames. The first index block contains information on\n** HASHTABLE_NPAGE_ONE frames. The values of HASHTABLE_NPAGE_ONE and \n** HASHTABLE_NPAGE are selected so that together the wal-index header and\n** first index block are the same size as all other index blocks in the\n** wal-index.\n**\n** Each index block contains two sections, a page-mapping that contains the\n** database page number associated with each wal frame, and a hash-table \n** that allows readers to query an index block for a specific page number.\n** The page-mapping is an array of HASHTABLE_NPAGE (or HASHTABLE_NPAGE_ONE\n** for the first index block) 32-bit page numbers. The first entry in the \n** first index-block contains the database page number corresponding to the\n** first frame in the WAL file. The first entry in the second index block\n** in the WAL file corresponds to the (HASHTABLE_NPAGE_ONE+1)th frame in\n** the log, and so on.\n**\n** The last index block in a wal-index usually contains less than the full\n** complement of HASHTABLE_NPAGE (or HASHTABLE_NPAGE_ONE) page-numbers,\n** depending on the contents of the WAL file. This does not change the\n** allocated size of the page-mapping array - the page-mapping array merely\n** contains unused entries.\n**\n** Even without using the hash table, the last frame for page P\n** can be found by scanning the page-mapping sections of each index block\n** starting with the last index block and moving toward the first, and\n** within each index block, starting at the end and moving toward the\n** beginning.  The first entry that equals P corresponds to the frame\n** holding the content for that page.\n**\n** The hash table consists of HASHTABLE_NSLOT 16-bit unsigned integers.\n** HASHTABLE_NSLOT = 2*HASHTABLE_NPAGE, and there is one entry in the\n** hash table for each page number in the mapping section, so the hash \n** table is never more than half full.  The expected number of collisions \n** prior to finding a match is 1.  Each entry of the hash table is an\n** 1-based index of an entry in the mapping section of the same\n** index block.   Let K be the 1-based index of the largest entry in\n** the mapping section.  (For index blocks other than the last, K will\n** always be exactly HASHTABLE_NPAGE (4096) and for the last index block\n** K will be (mxFrame%HASHTABLE_NPAGE).)  Unused slots of the hash table\n** contain a value of 0.\n**\n** To look for page P in the hash table, first compute a hash iKey on\n** P as follows:\n**\n**      iKey = (P * 383) % HASHTABLE_NSLOT\n**\n** Then start scanning entries of the hash table, starting with iKey\n** (wrapping around to the beginning when the end of the hash table is\n** reached) until an unused hash slot is found. Let the first unused slot\n** be at index iUnused.  (iUnused might be less than iKey if there was\n** wrap-around.) Because the hash table is never more than half full,\n** the search is guaranteed to eventually hit an unused entry.  Let \n** iMax be the value between iKey and iUnused, closest to iUnused,\n** where aHash[iMax]==P.  If there is no iMax entry (if there exists\n** no hash slot such that aHash[i]==p) then page P is not in the\n** current index block.  Otherwise the iMax-th mapping entry of the\n** current index block corresponds to the last entry that references \n** page P.\n**\n** A hash search begins with the last index block and moves toward the\n** first index block, looking for entries corresponding to page P.  On\n** average, only two or three slots in each index block need to be\n** examined in order to either find the last entry for page P, or to\n** establish that no such entry exists in the block.  Each index block\n** holds over 4000 entries.  So two or three index blocks are sufficient\n** to cover a typical 10 megabyte WAL file, assuming 1K pages.  8 or 10\n** comparisons (on average) suffice to either locate a frame in the\n** WAL or to establish that the frame does not exist in the WAL.  This\n** is much faster than scanning the entire 10MB WAL.\n**\n** Note that entries are added in order of increasing K.  Hence, one\n** reader might be using some value K0 and a second reader that started\n** at a later time (after additional transactions were added to the WAL\n** and to the wal-index) might be using a different value K1, where K1>K0.\n** Both readers can use the same hash table and mapping section to get\n** the correct result.  There may be entries in the hash table with\n** K>K0 but to the first reader, those entries will appear to be unused\n** slots in the hash table and so the first reader will get an answer as\n** if no values greater than K0 had ever been inserted into the hash table\n** in the first place - which is what reader one wants.  Meanwhile, the\n** second reader using K1 will see additional values that were inserted\n** later, which is exactly what reader two wants.  \n**\n** When a rollback occurs, the value of K is decreased. Hash table entries\n** that correspond to frames greater than the new K value are removed\n** from the hash table at this point.\n*/\n#ifndef SQLITE_OMIT_WAL\n\n/* #include \"wal.h\" */\n\n/*\n** Trace output macros\n*/\n#if defined(SQLITE_TEST) && defined(SQLITE_DEBUG)\nSQLITE_PRIVATE int sqlite3WalTrace = 0;\n# define WALTRACE(X)  if(sqlite3WalTrace) sqlite3DebugPrintf X\n#else\n# define WALTRACE(X)\n#endif\n\n/*\n** WAL mode depends on atomic aligned 32-bit loads and stores in a few\n** places.  The following macros try to make this explicit.\n*/\n#if GCC_VERSION>=5004000 || defined(SQLITE_HAS_STDATOMIC)\n# define AtomicLoad(PTR)       __atomic_load_n((PTR),__ATOMIC_RELAXED)\n# define AtomicStore(PTR,VAL)  (__atomic_store_n((PTR),(VAL),__ATOMIC_RELAXED), (VAL))\n#else\n# define AtomicLoad(PTR)       (*(PTR))\n# define AtomicStore(PTR,VAL)  (*(PTR) = (VAL))\n#endif\n\n/*\n** The maximum (and only) versions of the wal and wal-index formats\n** that may be interpreted by this version of SQLite.\n**\n** If a client begins recovering a WAL file and finds that (a) the checksum\n** values in the wal-header are correct and (b) the version field is not\n** WAL_MAX_VERSION, recovery fails and SQLite returns SQLITE_CANTOPEN.\n**\n** Similarly, if a client successfully reads a wal-index header (i.e. the \n** checksum test is successful) and finds that the version field is not\n** WALINDEX_MAX_VERSION, then no read-transaction is opened and SQLite\n** returns SQLITE_CANTOPEN.\n*/\n#define WAL_MAX_VERSION      3007000\n#define WALINDEX_MAX_VERSION 3007000\n\n/*\n** Index numbers for various locking bytes.   WAL_NREADER is the number\n** of available reader locks and should be at least 3.  The default\n** is SQLITE_SHM_NLOCK==8 and  WAL_NREADER==5.\n**\n** Technically, the various VFSes are free to implement these locks however\n** they see fit.  However, compatibility is encouraged so that VFSes can\n** interoperate.  The standard implemention used on both unix and windows\n** is for the index number to indicate a byte offset into the\n** WalCkptInfo.aLock[] array in the wal-index header.  In other words, all\n** locks are on the shm file.  The WALINDEX_LOCK_OFFSET constant (which\n** should be 120) is the location in the shm file for the first locking\n** byte.\n*/\n#define WAL_WRITE_LOCK         0\n#define WAL_ALL_BUT_WRITE      1\n#define WAL_CKPT_LOCK          1\n#define WAL_RECOVER_LOCK       2\n#define WAL_READ_LOCK(I)       (3+(I))\n#define WAL_NREADER            (SQLITE_SHM_NLOCK-3)\n\n\n/* Object declarations */\ntypedef struct WalIndexHdr WalIndexHdr;\ntypedef struct WalIterator WalIterator;\ntypedef struct WalCkptInfo WalCkptInfo;\n\n\n/*\n** The following object holds a copy of the wal-index header content.\n**\n** The actual header in the wal-index consists of two copies of this\n** object followed by one instance of the WalCkptInfo object.\n** For all versions of SQLite through 3.10.0 and probably beyond,\n** the locking bytes (WalCkptInfo.aLock) start at offset 120 and\n** the total header size is 136 bytes.\n**\n** The szPage value can be any power of 2 between 512 and 32768, inclusive.\n** Or it can be 1 to represent a 65536-byte page.  The latter case was\n** added in 3.7.1 when support for 64K pages was added.  \n*/\nstruct WalIndexHdr {\n  u32 iVersion;                   /* Wal-index version */\n  u32 unused;                     /* Unused (padding) field */\n  u32 iChange;                    /* Counter incremented each transaction */\n  u8 isInit;                      /* 1 when initialized */\n  u8 bigEndCksum;                 /* True if checksums in WAL are big-endian */\n  u16 szPage;                     /* Database page size in bytes. 1==64K */\n  u32 mxFrame;                    /* Index of last valid frame in the WAL */\n  u32 nPage;                      /* Size of database in pages */\n  u32 aFrameCksum[2];             /* Checksum of last frame in log */\n  u32 aSalt[2];                   /* Two salt values copied from WAL header */\n  u32 aCksum[2];                  /* Checksum over all prior fields */\n};\n\n/*\n** A copy of the following object occurs in the wal-index immediately\n** following the second copy of the WalIndexHdr.  This object stores\n** information used by checkpoint.\n**\n** nBackfill is the number of frames in the WAL that have been written\n** back into the database. (We call the act of moving content from WAL to\n** database \"backfilling\".)  The nBackfill number is never greater than\n** WalIndexHdr.mxFrame.  nBackfill can only be increased by threads\n** holding the WAL_CKPT_LOCK lock (which includes a recovery thread).\n** However, a WAL_WRITE_LOCK thread can move the value of nBackfill from\n** mxFrame back to zero when the WAL is reset.\n**\n** nBackfillAttempted is the largest value of nBackfill that a checkpoint\n** has attempted to achieve.  Normally nBackfill==nBackfillAtempted, however\n** the nBackfillAttempted is set before any backfilling is done and the\n** nBackfill is only set after all backfilling completes.  So if a checkpoint\n** crashes, nBackfillAttempted might be larger than nBackfill.  The\n** WalIndexHdr.mxFrame must never be less than nBackfillAttempted.\n**\n** The aLock[] field is a set of bytes used for locking.  These bytes should\n** never be read or written.\n**\n** There is one entry in aReadMark[] for each reader lock.  If a reader\n** holds read-lock K, then the value in aReadMark[K] is no greater than\n** the mxFrame for that reader.  The value READMARK_NOT_USED (0xffffffff)\n** for any aReadMark[] means that entry is unused.  aReadMark[0] is \n** a special case; its value is never used and it exists as a place-holder\n** to avoid having to offset aReadMark[] indexs by one.  Readers holding\n** WAL_READ_LOCK(0) always ignore the entire WAL and read all content\n** directly from the database.\n**\n** The value of aReadMark[K] may only be changed by a thread that\n** is holding an exclusive lock on WAL_READ_LOCK(K).  Thus, the value of\n** aReadMark[K] cannot changed while there is a reader is using that mark\n** since the reader will be holding a shared lock on WAL_READ_LOCK(K).\n**\n** The checkpointer may only transfer frames from WAL to database where\n** the frame numbers are less than or equal to every aReadMark[] that is\n** in use (that is, every aReadMark[j] for which there is a corresponding\n** WAL_READ_LOCK(j)).  New readers (usually) pick the aReadMark[] with the\n** largest value and will increase an unused aReadMark[] to mxFrame if there\n** is not already an aReadMark[] equal to mxFrame.  The exception to the\n** previous sentence is when nBackfill equals mxFrame (meaning that everything\n** in the WAL has been backfilled into the database) then new readers\n** will choose aReadMark[0] which has value 0 and hence such reader will\n** get all their all content directly from the database file and ignore \n** the WAL.\n**\n** Writers normally append new frames to the end of the WAL.  However,\n** if nBackfill equals mxFrame (meaning that all WAL content has been\n** written back into the database) and if no readers are using the WAL\n** (in other words, if there are no WAL_READ_LOCK(i) where i>0) then\n** the writer will first \"reset\" the WAL back to the beginning and start\n** writing new content beginning at frame 1.\n**\n** We assume that 32-bit loads are atomic and so no locks are needed in\n** order to read from any aReadMark[] entries.\n*/\nstruct WalCkptInfo {\n  u32 nBackfill;                  /* Number of WAL frames backfilled into DB */\n  u32 aReadMark[WAL_NREADER];     /* Reader marks */\n  u8 aLock[SQLITE_SHM_NLOCK];     /* Reserved space for locks */\n  u32 nBackfillAttempted;         /* WAL frames perhaps written, or maybe not */\n  u32 notUsed0;                   /* Available for future enhancements */\n};\n#define READMARK_NOT_USED  0xffffffff\n\n\n/* A block of WALINDEX_LOCK_RESERVED bytes beginning at\n** WALINDEX_LOCK_OFFSET is reserved for locks. Since some systems\n** only support mandatory file-locks, we do not read or write data\n** from the region of the file on which locks are applied.\n*/\n#define WALINDEX_LOCK_OFFSET (sizeof(WalIndexHdr)*2+offsetof(WalCkptInfo,aLock))\n#define WALINDEX_HDR_SIZE    (sizeof(WalIndexHdr)*2+sizeof(WalCkptInfo))\n\n/* Size of header before each frame in wal */\n#define WAL_FRAME_HDRSIZE 24\n\n/* Size of write ahead log header, including checksum. */\n#define WAL_HDRSIZE 32\n\n/* WAL magic value. Either this value, or the same value with the least\n** significant bit also set (WAL_MAGIC | 0x00000001) is stored in 32-bit\n** big-endian format in the first 4 bytes of a WAL file.\n**\n** If the LSB is set, then the checksums for each frame within the WAL\n** file are calculated by treating all data as an array of 32-bit \n** big-endian words. Otherwise, they are calculated by interpreting \n** all data as 32-bit little-endian words.\n*/\n#define WAL_MAGIC 0x377f0682\n\n/*\n** Return the offset of frame iFrame in the write-ahead log file, \n** assuming a database page size of szPage bytes. The offset returned\n** is to the start of the write-ahead log frame-header.\n*/\n#define walFrameOffset(iFrame, szPage) (                               \\\n  WAL_HDRSIZE + ((iFrame)-1)*(i64)((szPage)+WAL_FRAME_HDRSIZE)         \\\n)\n\n/*\n** An open write-ahead log file is represented by an instance of the\n** following object.\n*/\nstruct Wal {\n  sqlite3_vfs *pVfs;         /* The VFS used to create pDbFd */\n  sqlite3_file *pDbFd;       /* File handle for the database file */\n  sqlite3_file *pWalFd;      /* File handle for WAL file */\n  u32 iCallback;             /* Value to pass to log callback (or 0) */\n  i64 mxWalSize;             /* Truncate WAL to this size upon reset */\n  int nWiData;               /* Size of array apWiData */\n  int szFirstBlock;          /* Size of first block written to WAL file */\n  volatile u32 **apWiData;   /* Pointer to wal-index content in memory */\n  u32 szPage;                /* Database page size */\n  i16 readLock;              /* Which read lock is being held.  -1 for none */\n  u8 syncFlags;              /* Flags to use to sync header writes */\n  u8 exclusiveMode;          /* Non-zero if connection is in exclusive mode */\n  u8 writeLock;              /* True if in a write transaction */\n  u8 ckptLock;               /* True if holding a checkpoint lock */\n  u8 readOnly;               /* WAL_RDWR, WAL_RDONLY, or WAL_SHM_RDONLY */\n  u8 truncateOnCommit;       /* True to truncate WAL file on commit */\n  u8 syncHeader;             /* Fsync the WAL header if true */\n  u8 padToSectorBoundary;    /* Pad transactions out to the next sector */\n  u8 bShmUnreliable;         /* SHM content is read-only and unreliable */\n  WalIndexHdr hdr;           /* Wal-index header for current transaction */\n  u32 minFrame;              /* Ignore wal frames before this one */\n  u32 iReCksum;              /* On commit, recalculate checksums from here */\n  const char *zWalName;      /* Name of WAL file */\n  u32 nCkpt;                 /* Checkpoint sequence counter in the wal-header */\n#ifdef SQLITE_DEBUG\n  u8 lockError;              /* True if a locking error has occurred */\n#endif\n#ifdef SQLITE_ENABLE_SNAPSHOT\n  WalIndexHdr *pSnapshot;    /* Start transaction here if not NULL */\n#endif\n};\n\n/*\n** Candidate values for Wal.exclusiveMode.\n*/\n#define WAL_NORMAL_MODE     0\n#define WAL_EXCLUSIVE_MODE  1     \n#define WAL_HEAPMEMORY_MODE 2\n\n/*\n** Possible values for WAL.readOnly\n*/\n#define WAL_RDWR        0    /* Normal read/write connection */\n#define WAL_RDONLY      1    /* The WAL file is readonly */\n#define WAL_SHM_RDONLY  2    /* The SHM file is readonly */\n\n/*\n** Each page of the wal-index mapping contains a hash-table made up of\n** an array of HASHTABLE_NSLOT elements of the following type.\n*/\ntypedef u16 ht_slot;\n\n/*\n** This structure is used to implement an iterator that loops through\n** all frames in the WAL in database page order. Where two or more frames\n** correspond to the same database page, the iterator visits only the \n** frame most recently written to the WAL (in other words, the frame with\n** the largest index).\n**\n** The internals of this structure are only accessed by:\n**\n**   walIteratorInit() - Create a new iterator,\n**   walIteratorNext() - Step an iterator,\n**   walIteratorFree() - Free an iterator.\n**\n** This functionality is used by the checkpoint code (see walCheckpoint()).\n*/\nstruct WalIterator {\n  int iPrior;                     /* Last result returned from the iterator */\n  int nSegment;                   /* Number of entries in aSegment[] */\n  struct WalSegment {\n    int iNext;                    /* Next slot in aIndex[] not yet returned */\n    ht_slot *aIndex;              /* i0, i1, i2... such that aPgno[iN] ascend */\n    u32 *aPgno;                   /* Array of page numbers. */\n    int nEntry;                   /* Nr. of entries in aPgno[] and aIndex[] */\n    int iZero;                    /* Frame number associated with aPgno[0] */\n  } aSegment[1];                  /* One for every 32KB page in the wal-index */\n};\n\n/*\n** Define the parameters of the hash tables in the wal-index file. There\n** is a hash-table following every HASHTABLE_NPAGE page numbers in the\n** wal-index.\n**\n** Changing any of these constants will alter the wal-index format and\n** create incompatibilities.\n*/\n#define HASHTABLE_NPAGE      4096                 /* Must be power of 2 */\n#define HASHTABLE_HASH_1     383                  /* Should be prime */\n#define HASHTABLE_NSLOT      (HASHTABLE_NPAGE*2)  /* Must be a power of 2 */\n\n/* \n** The block of page numbers associated with the first hash-table in a\n** wal-index is smaller than usual. This is so that there is a complete\n** hash-table on each aligned 32KB page of the wal-index.\n*/\n#define HASHTABLE_NPAGE_ONE  (HASHTABLE_NPAGE - (WALINDEX_HDR_SIZE/sizeof(u32)))\n\n/* The wal-index is divided into pages of WALINDEX_PGSZ bytes each. */\n#define WALINDEX_PGSZ   (                                         \\\n    sizeof(ht_slot)*HASHTABLE_NSLOT + HASHTABLE_NPAGE*sizeof(u32) \\\n)\n\n/*\n** Obtain a pointer to the iPage'th page of the wal-index. The wal-index\n** is broken into pages of WALINDEX_PGSZ bytes. Wal-index pages are\n** numbered from zero.\n**\n** If the wal-index is currently smaller the iPage pages then the size\n** of the wal-index might be increased, but only if it is safe to do\n** so.  It is safe to enlarge the wal-index if pWal->writeLock is true\n** or pWal->exclusiveMode==WAL_HEAPMEMORY_MODE.\n**\n** If this call is successful, *ppPage is set to point to the wal-index\n** page and SQLITE_OK is returned. If an error (an OOM or VFS error) occurs,\n** then an SQLite error code is returned and *ppPage is set to 0.\n*/\nstatic SQLITE_NOINLINE int walIndexPageRealloc(\n  Wal *pWal,               /* The WAL context */\n  int iPage,               /* The page we seek */\n  volatile u32 **ppPage    /* Write the page pointer here */\n){\n  int rc = SQLITE_OK;\n\n  /* Enlarge the pWal->apWiData[] array if required */\n  if( pWal->nWiData<=iPage ){\n    int nByte = sizeof(u32*)*(iPage+1);\n    volatile u32 **apNew;\n    apNew = (volatile u32 **)sqlite3_realloc64((void *)pWal->apWiData, nByte);\n    if( !apNew ){\n      *ppPage = 0;\n      return SQLITE_NOMEM_BKPT;\n    }\n    memset((void*)&apNew[pWal->nWiData], 0,\n           sizeof(u32*)*(iPage+1-pWal->nWiData));\n    pWal->apWiData = apNew;\n    pWal->nWiData = iPage+1;\n  }\n\n  /* Request a pointer to the required page from the VFS */\n  assert( pWal->apWiData[iPage]==0 );\n  if( pWal->exclusiveMode==WAL_HEAPMEMORY_MODE ){\n    pWal->apWiData[iPage] = (u32 volatile *)sqlite3MallocZero(WALINDEX_PGSZ);\n    if( !pWal->apWiData[iPage] ) rc = SQLITE_NOMEM_BKPT;\n  }else{\n    rc = sqlite3OsShmMap(pWal->pDbFd, iPage, WALINDEX_PGSZ, \n        pWal->writeLock, (void volatile **)&pWal->apWiData[iPage]\n    );\n    assert( pWal->apWiData[iPage]!=0 || rc!=SQLITE_OK || pWal->writeLock==0 );\n    testcase( pWal->apWiData[iPage]==0 && rc==SQLITE_OK );\n    if( (rc&0xff)==SQLITE_READONLY ){\n      pWal->readOnly |= WAL_SHM_RDONLY;\n      if( rc==SQLITE_READONLY ){\n        rc = SQLITE_OK;\n      }\n    }\n  }\n\n  *ppPage = pWal->apWiData[iPage];\n  assert( iPage==0 || *ppPage || rc!=SQLITE_OK );\n  return rc;\n}\nstatic int walIndexPage(\n  Wal *pWal,               /* The WAL context */\n  int iPage,               /* The page we seek */\n  volatile u32 **ppPage    /* Write the page pointer here */\n){\n  if( pWal->nWiData<=iPage || (*ppPage = pWal->apWiData[iPage])==0 ){\n    return walIndexPageRealloc(pWal, iPage, ppPage);\n  }\n  return SQLITE_OK;\n}\n\n/*\n** Return a pointer to the WalCkptInfo structure in the wal-index.\n*/\nstatic volatile WalCkptInfo *walCkptInfo(Wal *pWal){\n  assert( pWal->nWiData>0 && pWal->apWiData[0] );\n  return (volatile WalCkptInfo*)&(pWal->apWiData[0][sizeof(WalIndexHdr)/2]);\n}\n\n/*\n** Return a pointer to the WalIndexHdr structure in the wal-index.\n*/\nstatic volatile WalIndexHdr *walIndexHdr(Wal *pWal){\n  assert( pWal->nWiData>0 && pWal->apWiData[0] );\n  return (volatile WalIndexHdr*)pWal->apWiData[0];\n}\n\n/*\n** The argument to this macro must be of type u32. On a little-endian\n** architecture, it returns the u32 value that results from interpreting\n** the 4 bytes as a big-endian value. On a big-endian architecture, it\n** returns the value that would be produced by interpreting the 4 bytes\n** of the input value as a little-endian integer.\n*/\n#define BYTESWAP32(x) ( \\\n    (((x)&0x000000FF)<<24) + (((x)&0x0000FF00)<<8)  \\\n  + (((x)&0x00FF0000)>>8)  + (((x)&0xFF000000)>>24) \\\n)\n\n/*\n** Generate or extend an 8 byte checksum based on the data in \n** array aByte[] and the initial values of aIn[0] and aIn[1] (or\n** initial values of 0 and 0 if aIn==NULL).\n**\n** The checksum is written back into aOut[] before returning.\n**\n** nByte must be a positive multiple of 8.\n*/\nstatic void walChecksumBytes(\n  int nativeCksum, /* True for native byte-order, false for non-native */\n  u8 *a,           /* Content to be checksummed */\n  int nByte,       /* Bytes of content in a[].  Must be a multiple of 8. */\n  const u32 *aIn,  /* Initial checksum value input */\n  u32 *aOut        /* OUT: Final checksum value output */\n){\n  u32 s1, s2;\n  u32 *aData = (u32 *)a;\n  u32 *aEnd = (u32 *)&a[nByte];\n\n  if( aIn ){\n    s1 = aIn[0];\n    s2 = aIn[1];\n  }else{\n    s1 = s2 = 0;\n  }\n\n  assert( nByte>=8 );\n  assert( (nByte&0x00000007)==0 );\n\n  if( nativeCksum ){\n    do {\n      s1 += *aData++ + s2;\n      s2 += *aData++ + s1;\n    }while( aData<aEnd );\n  }else{\n    do {\n      s1 += BYTESWAP32(aData[0]) + s2;\n      s2 += BYTESWAP32(aData[1]) + s1;\n      aData += 2;\n    }while( aData<aEnd );\n  }\n\n  aOut[0] = s1;\n  aOut[1] = s2;\n}\n\nstatic void walShmBarrier(Wal *pWal){\n  if( pWal->exclusiveMode!=WAL_HEAPMEMORY_MODE ){\n    sqlite3OsShmBarrier(pWal->pDbFd);\n  }\n}\n\n/*\n** Write the header information in pWal->hdr into the wal-index.\n**\n** The checksum on pWal->hdr is updated before it is written.\n*/\nstatic void walIndexWriteHdr(Wal *pWal){\n  volatile WalIndexHdr *aHdr = walIndexHdr(pWal);\n  const int nCksum = offsetof(WalIndexHdr, aCksum);\n\n  assert( pWal->writeLock );\n  pWal->hdr.isInit = 1;\n  pWal->hdr.iVersion = WALINDEX_MAX_VERSION;\n  walChecksumBytes(1, (u8*)&pWal->hdr, nCksum, 0, pWal->hdr.aCksum);\n  memcpy((void*)&aHdr[1], (const void*)&pWal->hdr, sizeof(WalIndexHdr));\n  walShmBarrier(pWal);\n  memcpy((void*)&aHdr[0], (const void*)&pWal->hdr, sizeof(WalIndexHdr));\n}\n\n/*\n** This function encodes a single frame header and writes it to a buffer\n** supplied by the caller. A frame-header is made up of a series of \n** 4-byte big-endian integers, as follows:\n**\n**     0: Page number.\n**     4: For commit records, the size of the database image in pages \n**        after the commit. For all other records, zero.\n**     8: Salt-1 (copied from the wal-header)\n**    12: Salt-2 (copied from the wal-header)\n**    16: Checksum-1.\n**    20: Checksum-2.\n*/\nstatic void walEncodeFrame(\n  Wal *pWal,                      /* The write-ahead log */\n  u32 iPage,                      /* Database page number for frame */\n  u32 nTruncate,                  /* New db size (or 0 for non-commit frames) */\n  u8 *aData,                      /* Pointer to page data */\n  u8 *aFrame                      /* OUT: Write encoded frame here */\n){\n  int nativeCksum;                /* True for native byte-order checksums */\n  u32 *aCksum = pWal->hdr.aFrameCksum;\n  assert( WAL_FRAME_HDRSIZE==24 );\n  sqlite3Put4byte(&aFrame[0], iPage);\n  sqlite3Put4byte(&aFrame[4], nTruncate);\n  if( pWal->iReCksum==0 ){\n    memcpy(&aFrame[8], pWal->hdr.aSalt, 8);\n\n    nativeCksum = (pWal->hdr.bigEndCksum==SQLITE_BIGENDIAN);\n    walChecksumBytes(nativeCksum, aFrame, 8, aCksum, aCksum);\n    walChecksumBytes(nativeCksum, aData, pWal->szPage, aCksum, aCksum);\n\n    sqlite3Put4byte(&aFrame[16], aCksum[0]);\n    sqlite3Put4byte(&aFrame[20], aCksum[1]);\n  }else{\n    memset(&aFrame[8], 0, 16);\n  }\n}\n\n/*\n** Check to see if the frame with header in aFrame[] and content\n** in aData[] is valid.  If it is a valid frame, fill *piPage and\n** *pnTruncate and return true.  Return if the frame is not valid.\n*/\nstatic int walDecodeFrame(\n  Wal *pWal,                      /* The write-ahead log */\n  u32 *piPage,                    /* OUT: Database page number for frame */\n  u32 *pnTruncate,                /* OUT: New db size (or 0 if not commit) */\n  u8 *aData,                      /* Pointer to page data (for checksum) */\n  u8 *aFrame                      /* Frame data */\n){\n  int nativeCksum;                /* True for native byte-order checksums */\n  u32 *aCksum = pWal->hdr.aFrameCksum;\n  u32 pgno;                       /* Page number of the frame */\n  assert( WAL_FRAME_HDRSIZE==24 );\n\n  /* A frame is only valid if the salt values in the frame-header\n  ** match the salt values in the wal-header. \n  */\n  if( memcmp(&pWal->hdr.aSalt, &aFrame[8], 8)!=0 ){\n    return 0;\n  }\n\n  /* A frame is only valid if the page number is creater than zero.\n  */\n  pgno = sqlite3Get4byte(&aFrame[0]);\n  if( pgno==0 ){\n    return 0;\n  }\n\n  /* A frame is only valid if a checksum of the WAL header,\n  ** all prior frams, the first 16 bytes of this frame-header, \n  ** and the frame-data matches the checksum in the last 8 \n  ** bytes of this frame-header.\n  */\n  nativeCksum = (pWal->hdr.bigEndCksum==SQLITE_BIGENDIAN);\n  walChecksumBytes(nativeCksum, aFrame, 8, aCksum, aCksum);\n  walChecksumBytes(nativeCksum, aData, pWal->szPage, aCksum, aCksum);\n  if( aCksum[0]!=sqlite3Get4byte(&aFrame[16]) \n   || aCksum[1]!=sqlite3Get4byte(&aFrame[20]) \n  ){\n    /* Checksum failed. */\n    return 0;\n  }\n\n  /* If we reach this point, the frame is valid.  Return the page number\n  ** and the new database size.\n  */\n  *piPage = pgno;\n  *pnTruncate = sqlite3Get4byte(&aFrame[4]);\n  return 1;\n}\n\n\n#if defined(SQLITE_TEST) && defined(SQLITE_DEBUG)\n/*\n** Names of locks.  This routine is used to provide debugging output and is not\n** a part of an ordinary build.\n*/\nstatic const char *walLockName(int lockIdx){\n  if( lockIdx==WAL_WRITE_LOCK ){\n    return \"WRITE-LOCK\";\n  }else if( lockIdx==WAL_CKPT_LOCK ){\n    return \"CKPT-LOCK\";\n  }else if( lockIdx==WAL_RECOVER_LOCK ){\n    return \"RECOVER-LOCK\";\n  }else{\n    static char zName[15];\n    sqlite3_snprintf(sizeof(zName), zName, \"READ-LOCK[%d]\",\n                     lockIdx-WAL_READ_LOCK(0));\n    return zName;\n  }\n}\n#endif /*defined(SQLITE_TEST) || defined(SQLITE_DEBUG) */\n    \n\n/*\n** Set or release locks on the WAL.  Locks are either shared or exclusive.\n** A lock cannot be moved directly between shared and exclusive - it must go\n** through the unlocked state first.\n**\n** In locking_mode=EXCLUSIVE, all of these routines become no-ops.\n*/\nstatic int walLockShared(Wal *pWal, int lockIdx){\n  int rc;\n  if( pWal->exclusiveMode ) return SQLITE_OK;\n  rc = sqlite3OsShmLock(pWal->pDbFd, lockIdx, 1,\n                        SQLITE_SHM_LOCK | SQLITE_SHM_SHARED);\n  WALTRACE((\"WAL%p: acquire SHARED-%s %s\\n\", pWal,\n            walLockName(lockIdx), rc ? \"failed\" : \"ok\"));\n  VVA_ONLY( pWal->lockError = (u8)(rc!=SQLITE_OK && rc!=SQLITE_BUSY); )\n  return rc;\n}\nstatic void walUnlockShared(Wal *pWal, int lockIdx){\n  if( pWal->exclusiveMode ) return;\n  (void)sqlite3OsShmLock(pWal->pDbFd, lockIdx, 1,\n                         SQLITE_SHM_UNLOCK | SQLITE_SHM_SHARED);\n  WALTRACE((\"WAL%p: release SHARED-%s\\n\", pWal, walLockName(lockIdx)));\n}\nstatic int walLockExclusive(Wal *pWal, int lockIdx, int n){\n  int rc;\n  if( pWal->exclusiveMode ) return SQLITE_OK;\n  rc = sqlite3OsShmLock(pWal->pDbFd, lockIdx, n,\n                        SQLITE_SHM_LOCK | SQLITE_SHM_EXCLUSIVE);\n  WALTRACE((\"WAL%p: acquire EXCLUSIVE-%s cnt=%d %s\\n\", pWal,\n            walLockName(lockIdx), n, rc ? \"failed\" : \"ok\"));\n  VVA_ONLY( pWal->lockError = (u8)(rc!=SQLITE_OK && rc!=SQLITE_BUSY); )\n  return rc;\n}\nstatic void walUnlockExclusive(Wal *pWal, int lockIdx, int n){\n  if( pWal->exclusiveMode ) return;\n  (void)sqlite3OsShmLock(pWal->pDbFd, lockIdx, n,\n                         SQLITE_SHM_UNLOCK | SQLITE_SHM_EXCLUSIVE);\n  WALTRACE((\"WAL%p: release EXCLUSIVE-%s cnt=%d\\n\", pWal,\n             walLockName(lockIdx), n));\n}\n\n/*\n** Compute a hash on a page number.  The resulting hash value must land\n** between 0 and (HASHTABLE_NSLOT-1).  The walHashNext() function advances\n** the hash to the next value in the event of a collision.\n*/\nstatic int walHash(u32 iPage){\n  assert( iPage>0 );\n  assert( (HASHTABLE_NSLOT & (HASHTABLE_NSLOT-1))==0 );\n  return (iPage*HASHTABLE_HASH_1) & (HASHTABLE_NSLOT-1);\n}\nstatic int walNextHash(int iPriorHash){\n  return (iPriorHash+1)&(HASHTABLE_NSLOT-1);\n}\n\n/*\n** An instance of the WalHashLoc object is used to describe the location\n** of a page hash table in the wal-index.  This becomes the return value\n** from walHashGet().\n*/\ntypedef struct WalHashLoc WalHashLoc;\nstruct WalHashLoc {\n  volatile ht_slot *aHash;  /* Start of the wal-index hash table */\n  volatile u32 *aPgno;      /* aPgno[1] is the page of first frame indexed */\n  u32 iZero;                /* One less than the frame number of first indexed*/\n};\n\n/* \n** Return pointers to the hash table and page number array stored on\n** page iHash of the wal-index. The wal-index is broken into 32KB pages\n** numbered starting from 0.\n**\n** Set output variable pLoc->aHash to point to the start of the hash table\n** in the wal-index file. Set pLoc->iZero to one less than the frame \n** number of the first frame indexed by this hash table. If a\n** slot in the hash table is set to N, it refers to frame number \n** (pLoc->iZero+N) in the log.\n**\n** Finally, set pLoc->aPgno so that pLoc->aPgno[1] is the page number of the\n** first frame indexed by the hash table, frame (pLoc->iZero+1).\n*/\nstatic int walHashGet(\n  Wal *pWal,                      /* WAL handle */\n  int iHash,                      /* Find the iHash'th table */\n  WalHashLoc *pLoc                /* OUT: Hash table location */\n){\n  int rc;                         /* Return code */\n\n  rc = walIndexPage(pWal, iHash, &pLoc->aPgno);\n  assert( rc==SQLITE_OK || iHash>0 );\n\n  if( rc==SQLITE_OK ){\n    pLoc->aHash = (volatile ht_slot *)&pLoc->aPgno[HASHTABLE_NPAGE];\n    if( iHash==0 ){\n      pLoc->aPgno = &pLoc->aPgno[WALINDEX_HDR_SIZE/sizeof(u32)];\n      pLoc->iZero = 0;\n    }else{\n      pLoc->iZero = HASHTABLE_NPAGE_ONE + (iHash-1)*HASHTABLE_NPAGE;\n    }\n    pLoc->aPgno = &pLoc->aPgno[-1];\n  }\n  return rc;\n}\n\n/*\n** Return the number of the wal-index page that contains the hash-table\n** and page-number array that contain entries corresponding to WAL frame\n** iFrame. The wal-index is broken up into 32KB pages. Wal-index pages \n** are numbered starting from 0.\n*/\nstatic int walFramePage(u32 iFrame){\n  int iHash = (iFrame+HASHTABLE_NPAGE-HASHTABLE_NPAGE_ONE-1) / HASHTABLE_NPAGE;\n  assert( (iHash==0 || iFrame>HASHTABLE_NPAGE_ONE)\n       && (iHash>=1 || iFrame<=HASHTABLE_NPAGE_ONE)\n       && (iHash<=1 || iFrame>(HASHTABLE_NPAGE_ONE+HASHTABLE_NPAGE))\n       && (iHash>=2 || iFrame<=HASHTABLE_NPAGE_ONE+HASHTABLE_NPAGE)\n       && (iHash<=2 || iFrame>(HASHTABLE_NPAGE_ONE+2*HASHTABLE_NPAGE))\n  );\n  return iHash;\n}\n\n/*\n** Return the page number associated with frame iFrame in this WAL.\n*/\nstatic u32 walFramePgno(Wal *pWal, u32 iFrame){\n  int iHash = walFramePage(iFrame);\n  if( iHash==0 ){\n    return pWal->apWiData[0][WALINDEX_HDR_SIZE/sizeof(u32) + iFrame - 1];\n  }\n  return pWal->apWiData[iHash][(iFrame-1-HASHTABLE_NPAGE_ONE)%HASHTABLE_NPAGE];\n}\n\n/*\n** Remove entries from the hash table that point to WAL slots greater\n** than pWal->hdr.mxFrame.\n**\n** This function is called whenever pWal->hdr.mxFrame is decreased due\n** to a rollback or savepoint.\n**\n** At most only the hash table containing pWal->hdr.mxFrame needs to be\n** updated.  Any later hash tables will be automatically cleared when\n** pWal->hdr.mxFrame advances to the point where those hash tables are\n** actually needed.\n*/\nstatic void walCleanupHash(Wal *pWal){\n  WalHashLoc sLoc;                /* Hash table location */\n  int iLimit = 0;                 /* Zero values greater than this */\n  int nByte;                      /* Number of bytes to zero in aPgno[] */\n  int i;                          /* Used to iterate through aHash[] */\n\n  assert( pWal->writeLock );\n  testcase( pWal->hdr.mxFrame==HASHTABLE_NPAGE_ONE-1 );\n  testcase( pWal->hdr.mxFrame==HASHTABLE_NPAGE_ONE );\n  testcase( pWal->hdr.mxFrame==HASHTABLE_NPAGE_ONE+1 );\n\n  if( pWal->hdr.mxFrame==0 ) return;\n\n  /* Obtain pointers to the hash-table and page-number array containing \n  ** the entry that corresponds to frame pWal->hdr.mxFrame. It is guaranteed\n  ** that the page said hash-table and array reside on is already mapped.\n  */\n  assert( pWal->nWiData>walFramePage(pWal->hdr.mxFrame) );\n  assert( pWal->apWiData[walFramePage(pWal->hdr.mxFrame)] );\n  walHashGet(pWal, walFramePage(pWal->hdr.mxFrame), &sLoc);\n\n  /* Zero all hash-table entries that correspond to frame numbers greater\n  ** than pWal->hdr.mxFrame.\n  */\n  iLimit = pWal->hdr.mxFrame - sLoc.iZero;\n  assert( iLimit>0 );\n  for(i=0; i<HASHTABLE_NSLOT; i++){\n    if( sLoc.aHash[i]>iLimit ){\n      sLoc.aHash[i] = 0;\n    }\n  }\n  \n  /* Zero the entries in the aPgno array that correspond to frames with\n  ** frame numbers greater than pWal->hdr.mxFrame. \n  */\n  nByte = (int)((char *)sLoc.aHash - (char *)&sLoc.aPgno[iLimit+1]);\n  memset((void *)&sLoc.aPgno[iLimit+1], 0, nByte);\n\n#ifdef SQLITE_ENABLE_EXPENSIVE_ASSERT\n  /* Verify that the every entry in the mapping region is still reachable\n  ** via the hash table even after the cleanup.\n  */\n  if( iLimit ){\n    int j;           /* Loop counter */\n    int iKey;        /* Hash key */\n    for(j=1; j<=iLimit; j++){\n      for(iKey=walHash(sLoc.aPgno[j]);sLoc.aHash[iKey];iKey=walNextHash(iKey)){\n        if( sLoc.aHash[iKey]==j ) break;\n      }\n      assert( sLoc.aHash[iKey]==j );\n    }\n  }\n#endif /* SQLITE_ENABLE_EXPENSIVE_ASSERT */\n}\n\n\n/*\n** Set an entry in the wal-index that will map database page number\n** pPage into WAL frame iFrame.\n*/\nstatic int walIndexAppend(Wal *pWal, u32 iFrame, u32 iPage){\n  int rc;                         /* Return code */\n  WalHashLoc sLoc;                /* Wal-index hash table location */\n\n  rc = walHashGet(pWal, walFramePage(iFrame), &sLoc);\n\n  /* Assuming the wal-index file was successfully mapped, populate the\n  ** page number array and hash table entry.\n  */\n  if( rc==SQLITE_OK ){\n    int iKey;                     /* Hash table key */\n    int idx;                      /* Value to write to hash-table slot */\n    int nCollide;                 /* Number of hash collisions */\n\n    idx = iFrame - sLoc.iZero;\n    assert( idx <= HASHTABLE_NSLOT/2 + 1 );\n    \n    /* If this is the first entry to be added to this hash-table, zero the\n    ** entire hash table and aPgno[] array before proceeding. \n    */\n    if( idx==1 ){\n      int nByte = (int)((u8 *)&sLoc.aHash[HASHTABLE_NSLOT]\n                               - (u8 *)&sLoc.aPgno[1]);\n      memset((void*)&sLoc.aPgno[1], 0, nByte);\n    }\n\n    /* If the entry in aPgno[] is already set, then the previous writer\n    ** must have exited unexpectedly in the middle of a transaction (after\n    ** writing one or more dirty pages to the WAL to free up memory). \n    ** Remove the remnants of that writers uncommitted transaction from \n    ** the hash-table before writing any new entries.\n    */\n    if( sLoc.aPgno[idx] ){\n      walCleanupHash(pWal);\n      assert( !sLoc.aPgno[idx] );\n    }\n\n    /* Write the aPgno[] array entry and the hash-table slot. */\n    nCollide = idx;\n    for(iKey=walHash(iPage); sLoc.aHash[iKey]; iKey=walNextHash(iKey)){\n      if( (nCollide--)==0 ) return SQLITE_CORRUPT_BKPT;\n    }\n    sLoc.aPgno[idx] = iPage;\n    sLoc.aHash[iKey] = (ht_slot)idx;\n\n#ifdef SQLITE_ENABLE_EXPENSIVE_ASSERT\n    /* Verify that the number of entries in the hash table exactly equals\n    ** the number of entries in the mapping region.\n    */\n    {\n      int i;           /* Loop counter */\n      int nEntry = 0;  /* Number of entries in the hash table */\n      for(i=0; i<HASHTABLE_NSLOT; i++){ if( sLoc.aHash[i] ) nEntry++; }\n      assert( nEntry==idx );\n    }\n\n    /* Verify that the every entry in the mapping region is reachable\n    ** via the hash table.  This turns out to be a really, really expensive\n    ** thing to check, so only do this occasionally - not on every\n    ** iteration.\n    */\n    if( (idx&0x3ff)==0 ){\n      int i;           /* Loop counter */\n      for(i=1; i<=idx; i++){\n        for(iKey=walHash(sLoc.aPgno[i]);\n            sLoc.aHash[iKey];\n            iKey=walNextHash(iKey)){\n          if( sLoc.aHash[iKey]==i ) break;\n        }\n        assert( sLoc.aHash[iKey]==i );\n      }\n    }\n#endif /* SQLITE_ENABLE_EXPENSIVE_ASSERT */\n  }\n\n\n  return rc;\n}\n\n\n/*\n** Recover the wal-index by reading the write-ahead log file. \n**\n** This routine first tries to establish an exclusive lock on the\n** wal-index to prevent other threads/processes from doing anything\n** with the WAL or wal-index while recovery is running.  The\n** WAL_RECOVER_LOCK is also held so that other threads will know\n** that this thread is running recovery.  If unable to establish\n** the necessary locks, this routine returns SQLITE_BUSY.\n*/\nstatic int walIndexRecover(Wal *pWal, int nBackFill){\n  int rc;                         /* Return Code */\n  i64 nSize;                      /* Size of log file */\n  u32 aFrameCksum[2] = {0, 0};\n  int iLock;                      /* Lock offset to lock for checkpoint */\n\n  /* Obtain an exclusive lock on all byte in the locking range not already\n  ** locked by the caller. The caller is guaranteed to have locked the\n  ** WAL_WRITE_LOCK byte, and may have also locked the WAL_CKPT_LOCK byte.\n  ** If successful, the same bytes that are locked here are unlocked before\n  ** this function returns.\n  */\n  assert( pWal->ckptLock==1 || pWal->ckptLock==0 );\n  assert( WAL_ALL_BUT_WRITE==WAL_WRITE_LOCK+1 );\n  assert( WAL_CKPT_LOCK==WAL_ALL_BUT_WRITE );\n  assert( pWal->writeLock );\n  iLock = WAL_ALL_BUT_WRITE + pWal->ckptLock;\n  rc = walLockExclusive(pWal, iLock, WAL_READ_LOCK(0)-iLock);\n  if( rc==SQLITE_OK ){\n    rc = walLockExclusive(pWal, WAL_READ_LOCK(1), WAL_NREADER-1);\n    if( rc!=SQLITE_OK ){\n      walUnlockExclusive(pWal, iLock, WAL_READ_LOCK(0)-iLock);\n    }\n  }\n  if( rc ){\n    return rc;\n  }\n\n  WALTRACE((\"WAL%p: recovery begin...\\n\", pWal));\n\n  memset(&pWal->hdr, 0, sizeof(WalIndexHdr));\n\n  rc = sqlite3OsFileSize(pWal->pWalFd, &nSize);\n  if( rc!=SQLITE_OK ){\n    goto recovery_error;\n  }\n\n  if( nSize>WAL_HDRSIZE ){\n    u8 aBuf[WAL_HDRSIZE];         /* Buffer to load WAL header into */\n    u8 *aFrame = 0;               /* Malloc'd buffer to load entire frame */\n    int szFrame;                  /* Number of bytes in buffer aFrame[] */\n    u8 *aData;                    /* Pointer to data part of aFrame buffer */\n    int iFrame;                   /* Index of last frame read */\n    i64 iOffset;                  /* Next offset to read from log file */\n    int szPage;                   /* Page size according to the log */\n    u32 magic;                    /* Magic value read from WAL header */\n    u32 version;                  /* Magic value read from WAL header */\n    int isValid;                  /* True if this frame is valid */\n\n    /* Read in the WAL header. */\n    rc = sqlite3OsRead(pWal->pWalFd, aBuf, WAL_HDRSIZE, 0);\n    if( rc!=SQLITE_OK ){\n      goto recovery_error;\n    }\n\n    /* If the database page size is not a power of two, or is greater than\n    ** SQLITE_MAX_PAGE_SIZE, conclude that the WAL file contains no valid \n    ** data. Similarly, if the 'magic' value is invalid, ignore the whole\n    ** WAL file.\n    */\n    magic = sqlite3Get4byte(&aBuf[0]);\n    szPage = sqlite3Get4byte(&aBuf[8]);\n    if( (magic&0xFFFFFFFE)!=WAL_MAGIC \n     || szPage&(szPage-1) \n     || szPage>SQLITE_MAX_PAGE_SIZE \n     || szPage<512 \n    ){\n      goto finished;\n    }\n    pWal->hdr.bigEndCksum = (u8)(magic&0x00000001);\n    pWal->szPage = szPage;\n    pWal->nCkpt = sqlite3Get4byte(&aBuf[12]);\n    memcpy(&pWal->hdr.aSalt, &aBuf[16], 8);\n\n    /* Verify that the WAL header checksum is correct */\n    walChecksumBytes(pWal->hdr.bigEndCksum==SQLITE_BIGENDIAN, \n        aBuf, WAL_HDRSIZE-2*4, 0, pWal->hdr.aFrameCksum\n    );\n    if( pWal->hdr.aFrameCksum[0]!=sqlite3Get4byte(&aBuf[24])\n     || pWal->hdr.aFrameCksum[1]!=sqlite3Get4byte(&aBuf[28])\n    ){\n      goto finished;\n    }\n#ifdef SQLITE_WCDB\n    aFrameCksum[0] = pWal->hdr.aFrameCksum[0];\n    aFrameCksum[1] = pWal->hdr.aFrameCksum[1];\n#endif\n\n    /* Verify that the version number on the WAL format is one that\n    ** are able to understand */\n    version = sqlite3Get4byte(&aBuf[4]);\n    if( version!=WAL_MAX_VERSION ){\n      rc = SQLITE_CANTOPEN_BKPT;\n      goto finished;\n    }\n\n    /* Malloc a buffer to read frames into. */\n    szFrame = szPage + WAL_FRAME_HDRSIZE;\n    aFrame = (u8 *)sqlite3_malloc64(szFrame);\n    if( !aFrame ){\n      rc = SQLITE_NOMEM_BKPT;\n      goto recovery_error;\n    }\n    aData = &aFrame[WAL_FRAME_HDRSIZE];\n\n    /* Read all frames from the log file. */\n    iFrame = 0;\n    for(iOffset=WAL_HDRSIZE; (iOffset+szFrame)<=nSize; iOffset+=szFrame){\n      u32 pgno;                   /* Database page number for frame */\n      u32 nTruncate;              /* dbsize field from frame header */\n\n      /* Read and decode the next log frame. */\n      iFrame++;\n      rc = sqlite3OsRead(pWal->pWalFd, aFrame, szFrame, iOffset);\n      if( rc!=SQLITE_OK ) break;\n      isValid = walDecodeFrame(pWal, &pgno, &nTruncate, aData, aFrame);\n      if( !isValid ) break;\n      rc = walIndexAppend(pWal, iFrame, pgno);\n      if( rc!=SQLITE_OK ) break;\n\n      /* If nTruncate is non-zero, this is a commit record. */\n      if( nTruncate ){\n        pWal->hdr.mxFrame = iFrame;\n        pWal->hdr.nPage = nTruncate;\n        pWal->hdr.szPage = (u16)((szPage&0xff00) | (szPage>>16));\n        testcase( szPage<=32768 );\n        testcase( szPage>=65536 );\n        aFrameCksum[0] = pWal->hdr.aFrameCksum[0];\n        aFrameCksum[1] = pWal->hdr.aFrameCksum[1];\n      }\n    }\n\n    sqlite3_free(aFrame);\n  }\n\nfinished:\n  if( rc==SQLITE_OK ){\n    volatile WalCkptInfo *pInfo;\n    int i;\n    pWal->hdr.aFrameCksum[0] = aFrameCksum[0];\n    pWal->hdr.aFrameCksum[1] = aFrameCksum[1];\n    walIndexWriteHdr(pWal);\n\n    /* Reset the checkpoint-header. This is safe because this thread is \n    ** currently holding locks that exclude all other readers, writers and\n    ** checkpointers.\n    */\n    pInfo = walCkptInfo(pWal);\n    pInfo->nBackfill = nBackFill <= pWal->hdr.mxFrame ? nBackFill : 0;\n    pInfo->nBackfillAttempted = pWal->hdr.mxFrame;\n    pInfo->aReadMark[0] = 0;\n    for(i=1; i<WAL_NREADER; i++) pInfo->aReadMark[i] = READMARK_NOT_USED;\n    if( pWal->hdr.mxFrame ) pInfo->aReadMark[1] = pWal->hdr.mxFrame;\n\n    /* If more than one frame was recovered from the log file, report an\n    ** event via sqlite3_log(). This is to help with identifying performance\n    ** problems caused by applications routinely shutting down without\n    ** checkpointing the log file.\n    */\n    if( pWal->hdr.nPage ){\n      sqlite3_log(SQLITE_NOTICE_RECOVER_WAL,\n          \"recovered %d frames from WAL file %s\",\n          pWal->hdr.mxFrame, pWal->zWalName\n      );\n    }\n  }\n\nrecovery_error:\n  WALTRACE((\"WAL%p: recovery %s\\n\", pWal, rc ? \"failed\" : \"ok\"));\n  walUnlockExclusive(pWal, iLock, WAL_READ_LOCK(0)-iLock);\n  walUnlockExclusive(pWal, WAL_READ_LOCK(1), WAL_NREADER-1);\n  return rc;\n}\n\n/*\n** Close an open wal-index.\n*/\nstatic void walIndexClose(Wal *pWal, int isDelete){\n  if( pWal->exclusiveMode==WAL_HEAPMEMORY_MODE || pWal->bShmUnreliable ){\n    int i;\n    for(i=0; i<pWal->nWiData; i++){\n      sqlite3_free((void *)pWal->apWiData[i]);\n      pWal->apWiData[i] = 0;\n    }\n  }\n  if( pWal->exclusiveMode!=WAL_HEAPMEMORY_MODE ){\n    sqlite3OsShmUnmap(pWal->pDbFd, isDelete);\n  }\n}\n\n/* \n** Open a connection to the WAL file zWalName. The database file must \n** already be opened on connection pDbFd. The buffer that zWalName points\n** to must remain valid for the lifetime of the returned Wal* handle.\n**\n** A SHARED lock should be held on the database file when this function\n** is called. The purpose of this SHARED lock is to prevent any other\n** client from unlinking the WAL or wal-index file. If another process\n** were to do this just after this client opened one of these files, the\n** system would be badly broken.\n**\n** If the log file is successfully opened, SQLITE_OK is returned and \n** *ppWal is set to point to a new WAL handle. If an error occurs,\n** an SQLite error code is returned and *ppWal is left unmodified.\n*/\nSQLITE_PRIVATE int sqlite3WalOpen(\n  sqlite3_vfs *pVfs,              /* vfs module to open wal and wal-index */\n  sqlite3_file *pDbFd,            /* The open database file */\n  const char *zWalName,           /* Name of the WAL file */\n  int bNoShm,                     /* True to run in heap-memory mode */\n  i64 mxWalSize,                  /* Truncate WAL to this size on reset */\n  Wal **ppWal                     /* OUT: Allocated Wal handle */\n){\n  int rc;                         /* Return Code */\n  Wal *pRet;                      /* Object to allocate and return */\n  int flags;                      /* Flags passed to OsOpen() */\n\n  assert( zWalName && zWalName[0] );\n  assert( pDbFd );\n\n  /* In the amalgamation, the os_unix.c and os_win.c source files come before\n  ** this source file.  Verify that the #defines of the locking byte offsets\n  ** in os_unix.c and os_win.c agree with the WALINDEX_LOCK_OFFSET value.\n  ** For that matter, if the lock offset ever changes from its initial design\n  ** value of 120, we need to know that so there is an assert() to check it.\n  */\n  assert( 120==WALINDEX_LOCK_OFFSET );\n  assert( 136==WALINDEX_HDR_SIZE );\n#ifdef WIN_SHM_BASE\n  assert( WIN_SHM_BASE==WALINDEX_LOCK_OFFSET );\n#endif\n#ifdef UNIX_SHM_BASE\n  assert( UNIX_SHM_BASE==WALINDEX_LOCK_OFFSET );\n#endif\n\n\n  /* Allocate an instance of struct Wal to return. */\n  *ppWal = 0;\n  pRet = (Wal*)sqlite3MallocZero(sizeof(Wal) + pVfs->szOsFile);\n  if( !pRet ){\n    return SQLITE_NOMEM_BKPT;\n  }\n\n  pRet->pVfs = pVfs;\n  pRet->pWalFd = (sqlite3_file *)&pRet[1];\n  pRet->pDbFd = pDbFd;\n  pRet->readLock = -1;\n  pRet->mxWalSize = mxWalSize;\n  pRet->zWalName = zWalName;\n  pRet->syncHeader = 1;\n  pRet->padToSectorBoundary = 1;\n  pRet->exclusiveMode = (bNoShm ? WAL_HEAPMEMORY_MODE: WAL_NORMAL_MODE);\n\n  /* Open file handle on the write-ahead log file. */\n  flags = (SQLITE_OPEN_READWRITE|SQLITE_OPEN_CREATE|SQLITE_OPEN_WAL);\n  rc = sqlite3OsOpen(pVfs, zWalName, pRet->pWalFd, flags, &flags);\n  if( rc==SQLITE_OK && flags&SQLITE_OPEN_READONLY ){\n    pRet->readOnly = WAL_RDONLY;\n  }\n\n  if( rc!=SQLITE_OK ){\n    walIndexClose(pRet, 0);\n    sqlite3OsClose(pRet->pWalFd);\n    sqlite3_free(pRet);\n  }else{\n    int iDC = sqlite3OsDeviceCharacteristics(pDbFd);\n    if( iDC & SQLITE_IOCAP_SEQUENTIAL ){ pRet->syncHeader = 0; }\n    if( iDC & SQLITE_IOCAP_POWERSAFE_OVERWRITE ){\n      pRet->padToSectorBoundary = 0;\n    }\n    *ppWal = pRet;\n    WALTRACE((\"WAL%d: opened\\n\", pRet));\n  }\n  return rc;\n}\n\n/*\n** Change the size to which the WAL file is trucated on each reset.\n*/\nSQLITE_PRIVATE void sqlite3WalLimit(Wal *pWal, i64 iLimit){\n  if( pWal ) pWal->mxWalSize = iLimit;\n}\n\n/*\n** Find the smallest page number out of all pages held in the WAL that\n** has not been returned by any prior invocation of this method on the\n** same WalIterator object.   Write into *piFrame the frame index where\n** that page was last written into the WAL.  Write into *piPage the page\n** number.\n**\n** Return 0 on success.  If there are no pages in the WAL with a page\n** number larger than *piPage, then return 1.\n*/\nstatic int walIteratorNext(\n  WalIterator *p,               /* Iterator */\n  u32 *piPage,                  /* OUT: The page number of the next page */\n  u32 *piFrame                  /* OUT: Wal frame index of next page */\n){\n  u32 iMin;                     /* Result pgno must be greater than iMin */\n  u32 iRet = 0xFFFFFFFF;        /* 0xffffffff is never a valid page number */\n  int i;                        /* For looping through segments */\n\n  iMin = p->iPrior;\n  assert( iMin<0xffffffff );\n  for(i=p->nSegment-1; i>=0; i--){\n    struct WalSegment *pSegment = &p->aSegment[i];\n    while( pSegment->iNext<pSegment->nEntry ){\n      u32 iPg = pSegment->aPgno[pSegment->aIndex[pSegment->iNext]];\n      if( iPg>iMin ){\n        if( iPg<iRet ){\n          iRet = iPg;\n          *piFrame = pSegment->iZero + pSegment->aIndex[pSegment->iNext];\n        }\n        break;\n      }\n      pSegment->iNext++;\n    }\n  }\n\n  *piPage = p->iPrior = iRet;\n  return (iRet==0xFFFFFFFF);\n}\n\n/*\n** This function merges two sorted lists into a single sorted list.\n**\n** aLeft[] and aRight[] are arrays of indices.  The sort key is\n** aContent[aLeft[]] and aContent[aRight[]].  Upon entry, the following\n** is guaranteed for all J<K:\n**\n**        aContent[aLeft[J]] < aContent[aLeft[K]]\n**        aContent[aRight[J]] < aContent[aRight[K]]\n**\n** This routine overwrites aRight[] with a new (probably longer) sequence\n** of indices such that the aRight[] contains every index that appears in\n** either aLeft[] or the old aRight[] and such that the second condition\n** above is still met.\n**\n** The aContent[aLeft[X]] values will be unique for all X.  And the\n** aContent[aRight[X]] values will be unique too.  But there might be\n** one or more combinations of X and Y such that\n**\n**      aLeft[X]!=aRight[Y]  &&  aContent[aLeft[X]] == aContent[aRight[Y]]\n**\n** When that happens, omit the aLeft[X] and use the aRight[Y] index.\n*/\nstatic void walMerge(\n  const u32 *aContent,            /* Pages in wal - keys for the sort */\n  ht_slot *aLeft,                 /* IN: Left hand input list */\n  int nLeft,                      /* IN: Elements in array *paLeft */\n  ht_slot **paRight,              /* IN/OUT: Right hand input list */\n  int *pnRight,                   /* IN/OUT: Elements in *paRight */\n  ht_slot *aTmp                   /* Temporary buffer */\n){\n  int iLeft = 0;                  /* Current index in aLeft */\n  int iRight = 0;                 /* Current index in aRight */\n  int iOut = 0;                   /* Current index in output buffer */\n  int nRight = *pnRight;\n  ht_slot *aRight = *paRight;\n\n  assert( nLeft>0 && nRight>0 );\n  while( iRight<nRight || iLeft<nLeft ){\n    ht_slot logpage;\n    Pgno dbpage;\n\n    if( (iLeft<nLeft) \n     && (iRight>=nRight || aContent[aLeft[iLeft]]<aContent[aRight[iRight]])\n    ){\n      logpage = aLeft[iLeft++];\n    }else{\n      logpage = aRight[iRight++];\n    }\n    dbpage = aContent[logpage];\n\n    aTmp[iOut++] = logpage;\n    if( iLeft<nLeft && aContent[aLeft[iLeft]]==dbpage ) iLeft++;\n\n    assert( iLeft>=nLeft || aContent[aLeft[iLeft]]>dbpage );\n    assert( iRight>=nRight || aContent[aRight[iRight]]>dbpage );\n  }\n\n  *paRight = aLeft;\n  *pnRight = iOut;\n  memcpy(aLeft, aTmp, sizeof(aTmp[0])*iOut);\n}\n\n/*\n** Sort the elements in list aList using aContent[] as the sort key.\n** Remove elements with duplicate keys, preferring to keep the\n** larger aList[] values.\n**\n** The aList[] entries are indices into aContent[].  The values in\n** aList[] are to be sorted so that for all J<K:\n**\n**      aContent[aList[J]] < aContent[aList[K]]\n**\n** For any X and Y such that\n**\n**      aContent[aList[X]] == aContent[aList[Y]]\n**\n** Keep the larger of the two values aList[X] and aList[Y] and discard\n** the smaller.\n*/\nstatic void walMergesort(\n  const u32 *aContent,            /* Pages in wal */\n  ht_slot *aBuffer,               /* Buffer of at least *pnList items to use */\n  ht_slot *aList,                 /* IN/OUT: List to sort */\n  int *pnList                     /* IN/OUT: Number of elements in aList[] */\n){\n  struct Sublist {\n    int nList;                    /* Number of elements in aList */\n    ht_slot *aList;               /* Pointer to sub-list content */\n  };\n\n  const int nList = *pnList;      /* Size of input list */\n  int nMerge = 0;                 /* Number of elements in list aMerge */\n  ht_slot *aMerge = 0;            /* List to be merged */\n  int iList;                      /* Index into input list */\n  u32 iSub = 0;                   /* Index into aSub array */\n  struct Sublist aSub[13];        /* Array of sub-lists */\n\n  memset(aSub, 0, sizeof(aSub));\n  assert( nList<=HASHTABLE_NPAGE && nList>0 );\n  assert( HASHTABLE_NPAGE==(1<<(ArraySize(aSub)-1)) );\n\n  for(iList=0; iList<nList; iList++){\n    nMerge = 1;\n    aMerge = &aList[iList];\n    for(iSub=0; iList & (1<<iSub); iSub++){\n      struct Sublist *p;\n      assert( iSub<ArraySize(aSub) );\n      p = &aSub[iSub];\n      assert( p->aList && p->nList<=(1<<iSub) );\n      assert( p->aList==&aList[iList&~((2<<iSub)-1)] );\n      walMerge(aContent, p->aList, p->nList, &aMerge, &nMerge, aBuffer);\n    }\n    aSub[iSub].aList = aMerge;\n    aSub[iSub].nList = nMerge;\n  }\n\n  for(iSub++; iSub<ArraySize(aSub); iSub++){\n    if( nList & (1<<iSub) ){\n      struct Sublist *p;\n      assert( iSub<ArraySize(aSub) );\n      p = &aSub[iSub];\n      assert( p->nList<=(1<<iSub) );\n      assert( p->aList==&aList[nList&~((2<<iSub)-1)] );\n      walMerge(aContent, p->aList, p->nList, &aMerge, &nMerge, aBuffer);\n    }\n  }\n  assert( aMerge==aList );\n  *pnList = nMerge;\n\n#ifdef SQLITE_DEBUG\n  {\n    int i;\n    for(i=1; i<*pnList; i++){\n      assert( aContent[aList[i]] > aContent[aList[i-1]] );\n    }\n  }\n#endif\n}\n\n/* \n** Free an iterator allocated by walIteratorInit().\n*/\nstatic void walIteratorFree(WalIterator *p){\n  sqlite3_free(p);\n}\n\n/*\n** Construct a WalInterator object that can be used to loop over all \n** pages in the WAL following frame nBackfill in ascending order. Frames\n** nBackfill or earlier may be included - excluding them is an optimization\n** only. The caller must hold the checkpoint lock.\n**\n** On success, make *pp point to the newly allocated WalInterator object\n** return SQLITE_OK. Otherwise, return an error code. If this routine\n** returns an error, the value of *pp is undefined.\n**\n** The calling routine should invoke walIteratorFree() to destroy the\n** WalIterator object when it has finished with it.\n*/\nstatic int walIteratorInit(Wal *pWal, u32 nBackfill, WalIterator **pp){\n  WalIterator *p;                 /* Return value */\n  int nSegment;                   /* Number of segments to merge */\n  u32 iLast;                      /* Last frame in log */\n  int nByte;                      /* Number of bytes to allocate */\n  int i;                          /* Iterator variable */\n  ht_slot *aTmp;                  /* Temp space used by merge-sort */\n  int rc = SQLITE_OK;             /* Return Code */\n\n  /* This routine only runs while holding the checkpoint lock. And\n  ** it only runs if there is actually content in the log (mxFrame>0).\n  */\n  assert( pWal->ckptLock && pWal->hdr.mxFrame>0 );\n  iLast = pWal->hdr.mxFrame;\n\n  /* Allocate space for the WalIterator object. */\n  nSegment = walFramePage(iLast) + 1;\n  nByte = sizeof(WalIterator) \n        + (nSegment-1)*sizeof(struct WalSegment)\n        + iLast*sizeof(ht_slot);\n  p = (WalIterator *)sqlite3_malloc64(nByte);\n  if( !p ){\n    return SQLITE_NOMEM_BKPT;\n  }\n  memset(p, 0, nByte);\n  p->nSegment = nSegment;\n\n  /* Allocate temporary space used by the merge-sort routine. This block\n  ** of memory will be freed before this function returns.\n  */\n  aTmp = (ht_slot *)sqlite3_malloc64(\n      sizeof(ht_slot) * (iLast>HASHTABLE_NPAGE?HASHTABLE_NPAGE:iLast)\n  );\n  if( !aTmp ){\n    rc = SQLITE_NOMEM_BKPT;\n  }\n\n  for(i=walFramePage(nBackfill+1); rc==SQLITE_OK && i<nSegment; i++){\n    WalHashLoc sLoc;\n\n    rc = walHashGet(pWal, i, &sLoc);\n    if( rc==SQLITE_OK ){\n      int j;                      /* Counter variable */\n      int nEntry;                 /* Number of entries in this segment */\n      ht_slot *aIndex;            /* Sorted index for this segment */\n\n      sLoc.aPgno++;\n      if( (i+1)==nSegment ){\n        nEntry = (int)(iLast - sLoc.iZero);\n      }else{\n        nEntry = (int)((u32*)sLoc.aHash - (u32*)sLoc.aPgno);\n      }\n      aIndex = &((ht_slot *)&p->aSegment[p->nSegment])[sLoc.iZero];\n      sLoc.iZero++;\n  \n      for(j=0; j<nEntry; j++){\n        aIndex[j] = (ht_slot)j;\n      }\n      walMergesort((u32 *)sLoc.aPgno, aTmp, aIndex, &nEntry);\n      p->aSegment[i].iZero = sLoc.iZero;\n      p->aSegment[i].nEntry = nEntry;\n      p->aSegment[i].aIndex = aIndex;\n      p->aSegment[i].aPgno = (u32 *)sLoc.aPgno;\n    }\n  }\n  sqlite3_free(aTmp);\n\n  if( rc!=SQLITE_OK ){\n    walIteratorFree(p);\n    p = 0;\n  }\n  *pp = p;\n  return rc;\n}\n\n/*\n** Attempt to obtain the exclusive WAL lock defined by parameters lockIdx and\n** n. If the attempt fails and parameter xBusy is not NULL, then it is a\n** busy-handler function. Invoke it and retry the lock until either the\n** lock is successfully obtained or the busy-handler returns 0.\n*/\nstatic int walBusyLock(\n  Wal *pWal,                      /* WAL connection */\n  int (*xBusy)(void*),            /* Function to call when busy */\n  void *pBusyArg,                 /* Context argument for xBusyHandler */\n  int lockIdx,                    /* Offset of first byte to lock */\n  int n                           /* Number of bytes to lock */\n){\n  int rc;\n  do {\n    rc = walLockExclusive(pWal, lockIdx, n);\n  }while( xBusy && rc==SQLITE_BUSY && xBusy(pBusyArg) );\n  return rc;\n}\n\n/*\n** The cache of the wal-index header must be valid to call this function.\n** Return the page-size in bytes used by the database.\n*/\nstatic int walPagesize(Wal *pWal){\n  return (pWal->hdr.szPage&0xfe00) + ((pWal->hdr.szPage&0x0001)<<16);\n}\n\n/*\n** The following is guaranteed when this function is called:\n**\n**   a) the WRITER lock is held,\n**   b) the entire log file has been checkpointed, and\n**   c) any existing readers are reading exclusively from the database\n**      file - there are no readers that may attempt to read a frame from\n**      the log file.\n**\n** This function updates the shared-memory structures so that the next\n** client to write to the database (which may be this one) does so by\n** writing frames into the start of the log file.\n**\n** The value of parameter salt1 is used as the aSalt[1] value in the \n** new wal-index header. It should be passed a pseudo-random value (i.e. \n** one obtained from sqlite3_randomness()).\n*/\nstatic void walRestartHdr(Wal *pWal, u32 salt1){\n  volatile WalCkptInfo *pInfo = walCkptInfo(pWal);\n  int i;                          /* Loop counter */\n  u32 *aSalt = pWal->hdr.aSalt;   /* Big-endian salt values */\n  pWal->nCkpt++;\n  pWal->hdr.mxFrame = 0;\n  sqlite3Put4byte((u8*)&aSalt[0], 1 + sqlite3Get4byte((u8*)&aSalt[0]));\n  memcpy(&pWal->hdr.aSalt[1], &salt1, 4);\n  walIndexWriteHdr(pWal);\n  pInfo->nBackfill = 0;\n  pInfo->nBackfillAttempted = 0;\n  pInfo->aReadMark[1] = 0;\n  for(i=2; i<WAL_NREADER; i++) pInfo->aReadMark[i] = READMARK_NOT_USED;\n  assert( pInfo->aReadMark[0]==0 );\n}\n\nint walWriteHeader(\n  Wal *pWal,                      /* Wal handle to write to */\n  int szPage,                     /* Database page-size in bytes */\n  int sync_flags                  /* Flags to pass to OsSync() (or 0) */\n){\n  u8 aWalHdr[WAL_HDRSIZE];      /* Buffer to assemble wal-header in */\n  u32 aCksum[2];                /* Checksum for wal-header */\n  int rc;\n\n  sqlite3Put4byte(&aWalHdr[0], (WAL_MAGIC | SQLITE_BIGENDIAN));\n  sqlite3Put4byte(&aWalHdr[4], WAL_MAX_VERSION);\n  sqlite3Put4byte(&aWalHdr[8], szPage);\n  sqlite3Put4byte(&aWalHdr[12], pWal->nCkpt);\n  if( pWal->nCkpt==0 ) sqlite3_randomness(8, pWal->hdr.aSalt);\n  memcpy(&aWalHdr[16], pWal->hdr.aSalt, 8);\n  walChecksumBytes(1, aWalHdr, WAL_HDRSIZE-2*4, 0, aCksum);\n  sqlite3Put4byte(&aWalHdr[24], aCksum[0]);\n  sqlite3Put4byte(&aWalHdr[28], aCksum[1]);\n\n  pWal->szPage = szPage;\n  pWal->hdr.bigEndCksum = SQLITE_BIGENDIAN;\n  pWal->hdr.aFrameCksum[0] = aCksum[0];\n  pWal->hdr.aFrameCksum[1] = aCksum[1];\n\n  rc = sqlite3OsWrite(pWal->pWalFd, aWalHdr, sizeof(aWalHdr), 0);\n  WALTRACE((\"WAL%p: wal-header write %s\\n\", pWal, rc ? \"failed\" : \"ok\"));\n  if( rc!=SQLITE_OK ){\n    return rc;\n  }\n\n  /* Sync the header (unless SQLITE_IOCAP_SEQUENTIAL is true or unless\n  ** all syncing is turned off by PRAGMA synchronous=OFF).  Otherwise\n  ** an out-of-order write following a WAL restart could result in\n  ** database corruption.  See the ticket:\n  **\n  **     https://sqlite.org/src/info/ff5be73dee\n  */\n  if( pWal->syncHeader ){\n    rc = sqlite3OsSync(pWal->pWalFd, CKPT_SYNC_FLAGS(sync_flags));\n  }\n  return rc;\n}\n\nstatic int walIndexReadHdr(Wal *pWal, int *pChanged);\n\n/*\n** Copy as much content as we can from the WAL back into the database file\n** in response to an sqlite3_wal_checkpoint() request or the equivalent.\n**\n** The amount of information copies from WAL to database might be limited\n** by active readers.  This routine will never overwrite a database page\n** that a concurrent reader might be using.\n**\n** All I/O barrier operations (a.k.a fsyncs) occur in this routine when\n** SQLite is in WAL-mode in synchronous=NORMAL.  That means that if \n** checkpoints are always run by a background thread or background \n** process, foreground threads will never block on a lengthy fsync call.\n**\n** Fsync is called on the WAL before writing content out of the WAL and\n** into the database.  This ensures that if the new content is persistent\n** in the WAL and can be recovered following a power-loss or hard reset.\n**\n** Fsync is also called on the database file if (and only if) the entire\n** WAL content is copied into the database file.  This second fsync makes\n** it safe to delete the WAL since the new content will persist in the\n** database file.\n**\n** This routine uses and updates the nBackfill field of the wal-index header.\n** This is the only routine that will increase the value of nBackfill.  \n** (A WAL reset or recovery will revert nBackfill to zero, but not increase\n** its value.)\n**\n** The caller must be holding sufficient locks to ensure that no other\n** checkpoint is running (in any other thread or process) at the same\n** time.\n*/\nstatic int walCheckpoint(\n  Wal *pWal,                      /* Wal connection */\n  sqlite3 *db,                    /* Check for interrupts on this handle */\n  int eMode,                      /* One of PASSIVE, FULL or RESTART */\n  int (*xBusy)(void*),            /* Function to call when busy */\n  void *pBusyArg,                 /* Context argument for xBusyHandler */\n  int sync_flags,                 /* Flags for OsSync() (or 0) */\n  u8 *zBuf                        /* Temporary buffer to use */\n){\n  int rc = SQLITE_OK;             /* Return code */\n  int szPage;                     /* Database page-size */\n  WalIterator *pIter = 0;         /* Wal iterator context */\n  u32 iDbpage = 0;                /* Next database page to write */\n  u32 iFrame = 0;                 /* Wal frame containing data for iDbpage */\n  u32 mxSafeFrame;                /* Max frame that can be backfilled */\n  u32 mxPage;                     /* Max database page to write */\n  int i;                          /* Loop counter */\n  volatile WalCkptInfo *pInfo;    /* The checkpoint status information */\n\n  szPage = walPagesize(pWal);\n  testcase( szPage<=32768 );\n  testcase( szPage>=65536 );\n  pInfo = walCkptInfo(pWal);\n  if( pInfo->nBackfill<pWal->hdr.mxFrame ){\n\n    /* EVIDENCE-OF: R-62920-47450 The busy-handler callback is never invoked\n    ** in the SQLITE_CHECKPOINT_PASSIVE mode. */\n    assert( eMode!=SQLITE_CHECKPOINT_PASSIVE || xBusy==0 );\n\n    /* Compute in mxSafeFrame the index of the last frame of the WAL that is\n    ** safe to write into the database.  Frames beyond mxSafeFrame might\n    ** overwrite database pages that are in use by active readers and thus\n    ** cannot be backfilled from the WAL.\n    */\n    mxSafeFrame = pWal->hdr.mxFrame;\n    mxPage = pWal->hdr.nPage;\n    for(i=1; i<WAL_NREADER; i++){\n      /* Thread-sanitizer reports that the following is an unsafe read,\n      ** as some other thread may be in the process of updating the value\n      ** of the aReadMark[] slot. The assumption here is that if that is\n      ** happening, the other client may only be increasing the value,\n      ** not decreasing it. So assuming either that either the \"old\" or\n      ** \"new\" version of the value is read, and not some arbitrary value\n      ** that would never be written by a real client, things are still \n      ** safe.  */\n      u32 y = pInfo->aReadMark[i];\n      if( mxSafeFrame>y ){\n        assert( y<=pWal->hdr.mxFrame );\n        rc = walBusyLock(pWal, xBusy, pBusyArg, WAL_READ_LOCK(i), 1);\n        if( rc==SQLITE_OK ){\n          pInfo->aReadMark[i] = (i==1 ? mxSafeFrame : READMARK_NOT_USED);\n          walUnlockExclusive(pWal, WAL_READ_LOCK(i), 1);\n        }else if( rc==SQLITE_BUSY ){\n          mxSafeFrame = y;\n          xBusy = 0;\n        }else{\n          goto walcheckpoint_out;\n        }\n      }\n    }\n\n    /* Allocate the iterator */\n    if( pInfo->nBackfill<mxSafeFrame ){\n      rc = walIteratorInit(pWal, pInfo->nBackfill, &pIter);\n      assert( rc==SQLITE_OK || pIter==0 );\n    }\n\n    if( pIter\n     && (rc = walBusyLock(pWal, xBusy, pBusyArg, WAL_READ_LOCK(0),1))==SQLITE_OK\n    ){\n      u32 nBackfill = pInfo->nBackfill;\n\n      pInfo->nBackfillAttempted = mxSafeFrame;\n\n      /* Sync the WAL to disk */\n      rc = sqlite3OsSync(pWal->pWalFd, CKPT_SYNC_FLAGS(sync_flags));\n\n      /* If the database may grow as a result of this checkpoint, hint\n      ** about the eventual size of the db file to the VFS layer.\n      */\n      if( rc==SQLITE_OK ){\n        i64 nReq = ((i64)mxPage * szPage);\n        i64 nSize;                    /* Current size of database file */\n        rc = sqlite3OsFileSize(pWal->pDbFd, &nSize);\n        if( rc==SQLITE_OK && nSize<nReq ){\n          sqlite3OsFileControlHint(pWal->pDbFd, SQLITE_FCNTL_SIZE_HINT, &nReq);\n        }\n      }\n\n\n      /* Iterate through the contents of the WAL, copying data to the db file */\n      while( rc==SQLITE_OK && 0==walIteratorNext(pIter, &iDbpage, &iFrame) ){\n        i64 iOffset;\n        assert( walFramePgno(pWal, iFrame)==iDbpage );\n        if( (db->u1.isInterrupted || db->suspended ) && !db->unimpeded ){\n          rc = db->mallocFailed ? SQLITE_NOMEM_BKPT : SQLITE_INTERRUPT;\n          break;\n        }\n        if( iFrame<=nBackfill || iFrame>mxSafeFrame || iDbpage>mxPage ){\n          continue;\n        }\n        iOffset = walFrameOffset(iFrame, szPage) + WAL_FRAME_HDRSIZE;\n        /* testcase( IS_BIG_INT(iOffset) ); // requires a 4GiB WAL file */\n        rc = sqlite3OsRead(pWal->pWalFd, zBuf, szPage, iOffset);\n        if( rc!=SQLITE_OK ) break;\n        iOffset = (iDbpage-1)*(i64)szPage;\n        testcase( IS_BIG_INT(iOffset) );\n        rc = sqlite3OsWrite(pWal->pDbFd, zBuf, szPage, iOffset);\n        if( rc!=SQLITE_OK ) break;\n      }\n\n      /* If work was actually accomplished... */\n      if( rc==SQLITE_OK ){\n        if( mxSafeFrame==walIndexHdr(pWal)->mxFrame ){\n          i64 szDb = pWal->hdr.nPage*(i64)szPage;\n          testcase( IS_BIG_INT(szDb) );\n          rc = sqlite3OsTruncate(pWal->pDbFd, szDb);\n#ifndef SQLITE_WCDB_IMPROVED_CHECKPOINT\n          if( rc==SQLITE_OK ){\n            rc = sqlite3OsSync(pWal->pDbFd, CKPT_SYNC_FLAGS(sync_flags));\n          }\n#endif\n        }\n#ifdef SQLITE_WCDB_IMPROVED_CHECKPOINT\n        if( rc==SQLITE_OK ){\n          rc = sqlite3OsSync(pWal->pDbFd, CKPT_SYNC_FLAGS(sync_flags));\n        }\n#endif\n        if( rc==SQLITE_OK ){\n          pInfo->nBackfill = mxSafeFrame;\n        }\n      }\n\n      /* Release the reader lock held while backfilling */\n      walUnlockExclusive(pWal, WAL_READ_LOCK(0), 1);\n    }\n\n    if( rc==SQLITE_BUSY ){\n      /* Reset the return code so as not to report a checkpoint failure\n      ** just because there are active readers.  */\n      rc = SQLITE_OK;\n    }\n  }\n\n  /* If this is an SQLITE_CHECKPOINT_RESTART or TRUNCATE operation, and the\n  ** entire wal file has been copied into the database file, then block \n  ** until all readers have finished using the wal file. This ensures that \n  ** the next process to write to the database restarts the wal file.\n  */\n  if( rc==SQLITE_OK && eMode!=SQLITE_CHECKPOINT_PASSIVE ){\n    assert( pWal->writeLock );\n    if( pInfo->nBackfill<pWal->hdr.mxFrame ){\n      rc = SQLITE_BUSY;\n    }else if( eMode>=SQLITE_CHECKPOINT_RESTART ){\n      u32 salt1;\n      sqlite3_randomness(4, &salt1);\n      assert( pInfo->nBackfill==pWal->hdr.mxFrame );\n      rc = walBusyLock(pWal, xBusy, pBusyArg, WAL_READ_LOCK(1), WAL_NREADER-1);\n      if( rc==SQLITE_OK ){\n        if( eMode==SQLITE_CHECKPOINT_TRUNCATE ){\n          /* IMPLEMENTATION-OF: R-44699-57140 This mode works the same way as\n          ** SQLITE_CHECKPOINT_RESTART with the addition that it also\n          ** truncates the log file to zero bytes just prior to a\n          ** successful return.\n          **\n          ** In theory, it might be safe to do this without updating the\n          ** wal-index header in shared memory, as all subsequent reader or\n          ** writer clients should see that the entire log file has been\n          ** checkpointed and behave accordingly. This seems unsafe though,\n          ** as it would leave the system in a state where the contents of\n          ** the wal-index header do not match the contents of the \n          ** file-system. To avoid this, update the wal-index header to\n          ** indicate that the log file contains zero valid frames.  */\n          walRestartHdr(pWal, salt1);\n          rc = sqlite3OsTruncate(pWal->pWalFd, 0);\n        }\n        walUnlockExclusive(pWal, WAL_READ_LOCK(1), WAL_NREADER-1);\n      }\n    }\n  }\n#ifdef SQLITE_WCDB_IMPROVED_CHECKPOINT\n  else if(rc==SQLITE_OK\n            && eMode==SQLITE_CHECKPOINT_PASSIVE\n            && pInfo->nBackfill>0\n            && pInfo->nBackfill==pWal->hdr.mxFrame\n            && pWal->szPage>0){\n    assert( !pWal->writeLock );\n    rc = walLockExclusive(pWal, WAL_WRITE_LOCK, 1);\n    if( rc!=SQLITE_OK){\n      rc = SQLITE_OK;\n      goto walcheckpoint_out;\n    }\n    pWal->writeLock = 1;\n    int isChanged = 0;\n    rc = walIndexReadHdr(pWal, &isChanged);\n    if(rc != SQLITE_OK || pInfo->nBackfill!=pWal->hdr.mxFrame){\n      goto walcheckpoint_out;\n    }\n    u32 salt1;\n    sqlite3_randomness(4, &salt1);\n    rc = walLockExclusive(pWal, WAL_READ_LOCK(1), WAL_NREADER-1);\n    if( rc!=SQLITE_OK){\n      rc = SQLITE_OK;\n      goto walcheckpoint_out;\n    }\n    walRestartHdr(pWal, salt1);\n    rc = walWriteHeader(pWal, pWal->szPage, sync_flags);\n    if( rc==SQLITE_OK ){\n      walIndexWriteHdr(pWal);\n    }\n    walUnlockExclusive(pWal, WAL_READ_LOCK(1), WAL_NREADER-1);\n  }\n#endif\n\n walcheckpoint_out:\n  walIteratorFree(pIter);\n  return rc;\n}\n\n/*\n** If the WAL file is currently larger than nMax bytes in size, truncate\n** it to exactly nMax bytes. If an error occurs while doing so, ignore it.\n*/\nstatic void walLimitSize(Wal *pWal, i64 nMax){\n  i64 sz;\n  int rx;\n  sqlite3BeginBenignMalloc();\n  rx = sqlite3OsFileSize(pWal->pWalFd, &sz);\n  if( rx==SQLITE_OK && (sz > nMax ) ){\n    rx = sqlite3OsTruncate(pWal->pWalFd, nMax);\n  }\n  sqlite3EndBenignMalloc();\n  if( rx ){\n    sqlite3_log(rx, \"cannot limit WAL size: %s\", pWal->zWalName);\n  }\n}\n\n/*\n** Close a connection to a log file.\n*/\nSQLITE_PRIVATE int sqlite3WalClose(\n  Wal *pWal,                      /* Wal to close */\n  sqlite3 *db,                    /* For interrupt flag */\n  int sync_flags,                 /* Flags to pass to OsSync() (or 0) */\n  int nBuf,\n  u8 *zBuf                        /* Buffer of at least nBuf bytes */\n){\n  int rc = SQLITE_OK;\n  if( pWal ){\n    int isDelete = 0;             /* True to unlink wal and wal-index files */\n\n    /* If an EXCLUSIVE lock can be obtained on the database file (using the\n    ** ordinary, rollback-mode locking methods, this guarantees that the\n    ** connection associated with this log file is the only connection to\n    ** the database. In this case checkpoint the database and unlink both\n    ** the wal and wal-index files.\n    **\n    ** The EXCLUSIVE lock is not released before returning.\n    */\n    if( zBuf!=0\n     && SQLITE_OK==(rc = sqlite3OsLock(pWal->pDbFd, SQLITE_LOCK_EXCLUSIVE))\n    ){\n      if( pWal->exclusiveMode==WAL_NORMAL_MODE ){\n        pWal->exclusiveMode = WAL_EXCLUSIVE_MODE;\n      }\n      rc = sqlite3WalCheckpoint(pWal, db, \n          SQLITE_CHECKPOINT_PASSIVE, 0, 0, sync_flags, nBuf, zBuf, 0, 0\n      );\n      if( rc==SQLITE_OK ){\n        int bPersist = -1;\n        sqlite3OsFileControlHint(\n            pWal->pDbFd, SQLITE_FCNTL_PERSIST_WAL, &bPersist\n        );\n        if( bPersist!=1 ){\n          /* Try to delete the WAL file if the checkpoint completed and\n          ** fsyned (rc==SQLITE_OK) and if we are not in persistent-wal\n          ** mode (!bPersist) */\n          isDelete = 1;\n        }else if( pWal->mxWalSize>=0 ){\n          /* Try to truncate the WAL file to zero bytes if the checkpoint\n          ** completed and fsynced (rc==SQLITE_OK) and we are in persistent\n          ** WAL mode (bPersist) and if the PRAGMA journal_size_limit is a\n          ** non-negative value (pWal->mxWalSize>=0).  Note that we truncate\n          ** to zero bytes as truncating to the journal_size_limit might\n          ** leave a corrupt WAL file on disk. */\n          walLimitSize(pWal, 0);\n        }\n      }\n    }\n\n    walIndexClose(pWal, isDelete);\n    sqlite3OsClose(pWal->pWalFd);\n    if( isDelete ){\n      sqlite3BeginBenignMalloc();\n      sqlite3OsDelete(pWal->pVfs, pWal->zWalName, 0);\n      sqlite3EndBenignMalloc();\n    }\n    WALTRACE((\"WAL%p: closed\\n\", pWal));\n    sqlite3_free((void *)pWal->apWiData);\n    sqlite3_free(pWal);\n  }\n  return rc;\n}\n\n/*\n** Try to read the wal-index header.  Return 0 on success and 1 if\n** there is a problem.\n**\n** The wal-index is in shared memory.  Another thread or process might\n** be writing the header at the same time this procedure is trying to\n** read it, which might result in inconsistency.  A dirty read is detected\n** by verifying that both copies of the header are the same and also by\n** a checksum on the header.\n**\n** If and only if the read is consistent and the header is different from\n** pWal->hdr, then pWal->hdr is updated to the content of the new header\n** and *pChanged is set to 1.\n**\n** If the checksum cannot be verified return non-zero. If the header\n** is read successfully and the checksum verified, return zero.\n*/\nstatic int walIndexTryHdr(Wal *pWal, int *pChanged){\n  u32 aCksum[2];                  /* Checksum on the header content */\n  WalIndexHdr h1, h2;             /* Two copies of the header content */\n  WalIndexHdr volatile *aHdr;     /* Header in shared memory */\n\n  /* The first page of the wal-index must be mapped at this point. */\n  assert( pWal->nWiData>0 && pWal->apWiData[0] );\n\n  /* Read the header. This might happen concurrently with a write to the\n  ** same area of shared memory on a different CPU in a SMP,\n  ** meaning it is possible that an inconsistent snapshot is read\n  ** from the file. If this happens, return non-zero.\n  **\n  ** There are two copies of the header at the beginning of the wal-index.\n  ** When reading, read [0] first then [1].  Writes are in the reverse order.\n  ** Memory barriers are used to prevent the compiler or the hardware from\n  ** reordering the reads and writes.\n  */\n  aHdr = walIndexHdr(pWal);\n  memcpy(&h1, (void *)&aHdr[0], sizeof(h1));\n  walShmBarrier(pWal);\n  memcpy(&h2, (void *)&aHdr[1], sizeof(h2));\n\n  if( memcmp(&h1, &h2, sizeof(h1))!=0 ){\n    return 1;   /* Dirty read */\n  }  \n  if( h1.isInit==0 ){\n    return 1;   /* Malformed header - probably all zeros */\n  }\n  walChecksumBytes(1, (u8*)&h1, sizeof(h1)-sizeof(h1.aCksum), 0, aCksum);\n  if( aCksum[0]!=h1.aCksum[0] || aCksum[1]!=h1.aCksum[1] ){\n    return 1;   /* Checksum does not match */\n  }\n\n  if( memcmp(&pWal->hdr, &h1, sizeof(WalIndexHdr)) ){\n    *pChanged = 1;\n    memcpy(&pWal->hdr, &h1, sizeof(WalIndexHdr));\n    pWal->szPage = (pWal->hdr.szPage&0xfe00) + ((pWal->hdr.szPage&0x0001)<<16);\n    testcase( pWal->szPage<=32768 );\n    testcase( pWal->szPage>=65536 );\n  }\n\n  /* The header was successfully read. Return zero. */\n  return 0;\n}\n\n/*\n** This is the value that walTryBeginRead returns when it needs to\n** be retried.\n*/\n#define WAL_RETRY  (-1)\n\n#ifdef SQLITE_WCDB_IMPROVED_CHECKPOINT\nextern void unixCheckOpenShm(sqlite3_file *file, int *opened);\nextern int  unixEnterMutexAndLockShm(sqlite3_file *pDbFd);\nextern void unixLeaveMutexAndUnLockShm(int shmFd);\nextern int  unixReadShmFile(int shmFd, sqlite3_int64 offset, void *pBuf, int cnt);\n\nstatic int tryRecoverBackfill(Wal *pWal)\n{\n  int bPersist = -1;\n  sqlite3OsFileControlHint(\n      pWal->pDbFd, SQLITE_FCNTL_PERSIST_WAL, &bPersist\n  );\n  if( bPersist!=1 ){\n    return 0;\n  }\n  int opened = 0;\n  unixCheckOpenShm(pWal->pDbFd, &opened);\n  if(opened){\n    return 0;\n  }\n  \n  i64 nSize = 0;\n  int rc = sqlite3OsFileSize(pWal->pWalFd, &nSize);\n  if( rc!=SQLITE_OK || nSize < WAL_HDRSIZE){\n    return 0;\n  }\n  \n  int nBackFill = 0;\n  int shmFd = -1;\n  \n  shmFd = unixEnterMutexAndLockShm(pWal->pDbFd);\n  if(shmFd < 0){\n    goto recover_backfill_finish;\n  }\n  \n  u8 shmBuf[WALINDEX_HDR_SIZE];\n  u32 aCksum[2];                  /* Checksum on the header content */\n  WalCkptInfo *pInfo;             /* Checkpoint information in wal-index */\n  int shmHdrSize = sizeof(WalIndexHdr);\n  rc = unixReadShmFile(shmFd, 0, shmBuf, WALINDEX_HDR_SIZE);\n  if(rc != SQLITE_OK){\n    goto recover_backfill_finish;\n  }\n  \n  WalIndexHdr *h1, *h2;             /* Two copies of the header content */\n  h1 = (WalIndexHdr *)shmBuf;\n  h2 = (WalIndexHdr *)&shmBuf[shmHdrSize];\n  if( memcmp(h1, h2, shmHdrSize)!=0 ){\n    goto recover_backfill_finish;   /* Dirty read */\n  }\n  \n  if( h1->isInit==0 || h1->iVersion!=WALINDEX_MAX_VERSION){\n    goto recover_backfill_finish;   /* Malformed header - probably all zeros */\n  }\n  \n  walChecksumBytes(1, (u8*)h1, shmHdrSize-sizeof(h1->aCksum), 0, aCksum);\n  if( aCksum[0]!=h1->aCksum[0] || aCksum[1]!=h1->aCksum[1] ){\n    goto recover_backfill_finish;   /* Checksum does not match */\n  }\n  \n  u8 walBuf[WAL_HDRSIZE];           /* Buffer to load WAL header into */\n  rc = sqlite3OsRead(pWal->pWalFd, walBuf, WAL_HDRSIZE, 0);\n  if( rc!=SQLITE_OK ){\n    goto recover_backfill_finish;\n  }\n  if(memcmp(h1->aSalt, &walBuf[16], 8) ){\n    goto recover_backfill_finish;\n  }\n  \n  pInfo = (WalCkptInfo *)&shmBuf[2*shmHdrSize];\n  if(pInfo->nBackfillAttempted > h1->mxFrame || pInfo->nBackfill >pInfo->nBackfillAttempted){\n    goto recover_backfill_finish; /* Invalid checkpoint info*/\n  }\n  nBackFill = pInfo->nBackfill;\n  \n  recover_backfill_finish:\n  unixLeaveMutexAndUnLockShm(shmFd);\n  return nBackFill;\n}\n#else\n#define tryRecoverBackfill 0;\n#endif\n\n/*\n** Read the wal-index header from the wal-index and into pWal->hdr.\n** If the wal-header appears to be corrupt, try to reconstruct the\n** wal-index from the WAL before returning.\n**\n** Set *pChanged to 1 if the wal-index header value in pWal->hdr is\n** changed by this operation.  If pWal->hdr is unchanged, set *pChanged\n** to 0.\n**\n** If the wal-index header is successfully read, return SQLITE_OK. \n** Otherwise an SQLite error code.\n*/\nstatic int walIndexReadHdr(Wal *pWal, int *pChanged){\n  int rc;                         /* Return code */\n  int badHdr;                     /* True if a header read failed */\n  volatile u32 *page0;            /* Chunk of wal-index containing header */\n\n  /* Ensure that page 0 of the wal-index (the page that contains the \n  ** wal-index header) is mapped. Return early if an error occurs here.\n  */\n#ifdef SQLITE_WCDB_IMPROVED_CHECKPOINT\n  int nBackFill = tryRecoverBackfill(pWal);\n#else\n  int nBackFill = 0;\n#endif\n  assert( pChanged );\n  rc = walIndexPage(pWal, 0, &page0);\n  if( rc!=SQLITE_OK ){\n    assert( rc!=SQLITE_READONLY ); /* READONLY changed to OK in walIndexPage */\n    if( rc==SQLITE_READONLY_CANTINIT ){\n      /* The SQLITE_READONLY_CANTINIT return means that the shared-memory\n      ** was openable but is not writable, and this thread is unable to\n      ** confirm that another write-capable connection has the shared-memory\n      ** open, and hence the content of the shared-memory is unreliable,\n      ** since the shared-memory might be inconsistent with the WAL file\n      ** and there is no writer on hand to fix it. */\n      assert( page0==0 );\n      assert( pWal->writeLock==0 );\n      assert( pWal->readOnly & WAL_SHM_RDONLY );\n      pWal->bShmUnreliable = 1;\n      pWal->exclusiveMode = WAL_HEAPMEMORY_MODE;\n      *pChanged = 1;\n    }else{\n      return rc; /* Any other non-OK return is just an error */\n    }\n  }else{\n    /* page0 can be NULL if the SHM is zero bytes in size and pWal->writeLock\n    ** is zero, which prevents the SHM from growing */\n    testcase( page0!=0 );\n  }\n  assert( page0!=0 || pWal->writeLock==0 );\n\n  /* If the first page of the wal-index has been mapped, try to read the\n  ** wal-index header immediately, without holding any lock. This usually\n  ** works, but may fail if the wal-index header is corrupt or currently \n  ** being modified by another thread or process.\n  */\n  badHdr = (page0 ? walIndexTryHdr(pWal, pChanged) : 1);\n\n  /* If the first attempt failed, it might have been due to a race\n  ** with a writer.  So get a WRITE lock and try again.\n  */\n  assert( badHdr==0 || pWal->writeLock==0 );\n  if( badHdr ){\n    if( pWal->bShmUnreliable==0 && (pWal->readOnly & WAL_SHM_RDONLY) ){\n      if( SQLITE_OK==(rc = walLockShared(pWal, WAL_WRITE_LOCK)) ){\n        walUnlockShared(pWal, WAL_WRITE_LOCK);\n        rc = SQLITE_READONLY_RECOVERY;\n      }\n    }else if( SQLITE_OK==(rc = walLockExclusive(pWal, WAL_WRITE_LOCK, 1)) ){\n      pWal->writeLock = 1;\n      if( SQLITE_OK==(rc = walIndexPage(pWal, 0, &page0)) ){\n        badHdr = walIndexTryHdr(pWal, pChanged);\n        if( badHdr ){\n          /* If the wal-index header is still malformed even while holding\n          ** a WRITE lock, it can only mean that the header is corrupted and\n          ** needs to be reconstructed.  So run recovery to do exactly that.\n          */\n          rc = walIndexRecover(pWal, nBackFill);\n          *pChanged = 1;\n        }\n      }\n      pWal->writeLock = 0;\n      walUnlockExclusive(pWal, WAL_WRITE_LOCK, 1);\n    }\n  }\n\n  /* If the header is read successfully, check the version number to make\n  ** sure the wal-index was not constructed with some future format that\n  ** this version of SQLite cannot understand.\n  */\n  if( badHdr==0 && pWal->hdr.iVersion!=WALINDEX_MAX_VERSION ){\n    rc = SQLITE_CANTOPEN_BKPT;\n  }\n  if( pWal->bShmUnreliable ){\n    if( rc!=SQLITE_OK ){\n      walIndexClose(pWal, 0);\n      pWal->bShmUnreliable = 0;\n      assert( pWal->nWiData>0 && pWal->apWiData[0]==0 );\n      /* walIndexRecover() might have returned SHORT_READ if a concurrent\n      ** writer truncated the WAL out from under it.  If that happens, it\n      ** indicates that a writer has fixed the SHM file for us, so retry */\n      if( rc==SQLITE_IOERR_SHORT_READ ) rc = WAL_RETRY;\n    }\n    pWal->exclusiveMode = WAL_NORMAL_MODE;\n  }\n\n  return rc;\n}\n\n/*\n** Open a transaction in a connection where the shared-memory is read-only\n** and where we cannot verify that there is a separate write-capable connection\n** on hand to keep the shared-memory up-to-date with the WAL file.\n**\n** This can happen, for example, when the shared-memory is implemented by\n** memory-mapping a *-shm file, where a prior writer has shut down and\n** left the *-shm file on disk, and now the present connection is trying\n** to use that database but lacks write permission on the *-shm file.\n** Other scenarios are also possible, depending on the VFS implementation.\n**\n** Precondition:\n**\n**    The *-wal file has been read and an appropriate wal-index has been\n**    constructed in pWal->apWiData[] using heap memory instead of shared\n**    memory. \n**\n** If this function returns SQLITE_OK, then the read transaction has\n** been successfully opened. In this case output variable (*pChanged) \n** is set to true before returning if the caller should discard the\n** contents of the page cache before proceeding. Or, if it returns \n** WAL_RETRY, then the heap memory wal-index has been discarded and \n** the caller should retry opening the read transaction from the \n** beginning (including attempting to map the *-shm file). \n**\n** If an error occurs, an SQLite error code is returned.\n*/\nstatic int walBeginShmUnreliable(Wal *pWal, int *pChanged){\n  i64 szWal;                      /* Size of wal file on disk in bytes */\n  i64 iOffset;                    /* Current offset when reading wal file */\n  u8 aBuf[WAL_HDRSIZE];           /* Buffer to load WAL header into */\n  u8 *aFrame = 0;                 /* Malloc'd buffer to load entire frame */\n  int szFrame;                    /* Number of bytes in buffer aFrame[] */\n  u8 *aData;                      /* Pointer to data part of aFrame buffer */\n  volatile void *pDummy;          /* Dummy argument for xShmMap */\n  int rc;                         /* Return code */\n  u32 aSaveCksum[2];              /* Saved copy of pWal->hdr.aFrameCksum */\n\n  assert( pWal->bShmUnreliable );\n  assert( pWal->readOnly & WAL_SHM_RDONLY );\n  assert( pWal->nWiData>0 && pWal->apWiData[0] );\n\n  /* Take WAL_READ_LOCK(0). This has the effect of preventing any\n  ** writers from running a checkpoint, but does not stop them\n  ** from running recovery.  */\n  rc = walLockShared(pWal, WAL_READ_LOCK(0));\n  if( rc!=SQLITE_OK ){\n    if( rc==SQLITE_BUSY ) rc = WAL_RETRY;\n    goto begin_unreliable_shm_out;\n  }\n  pWal->readLock = 0;\n\n  /* Check to see if a separate writer has attached to the shared-memory area,\n  ** thus making the shared-memory \"reliable\" again.  Do this by invoking\n  ** the xShmMap() routine of the VFS and looking to see if the return\n  ** is SQLITE_READONLY instead of SQLITE_READONLY_CANTINIT.\n  **\n  ** If the shared-memory is now \"reliable\" return WAL_RETRY, which will\n  ** cause the heap-memory WAL-index to be discarded and the actual\n  ** shared memory to be used in its place.\n  **\n  ** This step is important because, even though this connection is holding\n  ** the WAL_READ_LOCK(0) which prevents a checkpoint, a writer might\n  ** have already checkpointed the WAL file and, while the current\n  ** is active, wrap the WAL and start overwriting frames that this\n  ** process wants to use.\n  **\n  ** Once sqlite3OsShmMap() has been called for an sqlite3_file and has\n  ** returned any SQLITE_READONLY value, it must return only SQLITE_READONLY\n  ** or SQLITE_READONLY_CANTINIT or some error for all subsequent invocations,\n  ** even if some external agent does a \"chmod\" to make the shared-memory\n  ** writable by us, until sqlite3OsShmUnmap() has been called.\n  ** This is a requirement on the VFS implementation.\n   */\n  rc = sqlite3OsShmMap(pWal->pDbFd, 0, WALINDEX_PGSZ, 0, &pDummy);\n  assert( rc!=SQLITE_OK ); /* SQLITE_OK not possible for read-only connection */\n  if( rc!=SQLITE_READONLY_CANTINIT ){\n    rc = (rc==SQLITE_READONLY ? WAL_RETRY : rc);\n    goto begin_unreliable_shm_out;\n  }\n\n  /* We reach this point only if the real shared-memory is still unreliable.\n  ** Assume the in-memory WAL-index substitute is correct and load it\n  ** into pWal->hdr.\n  */\n  memcpy(&pWal->hdr, (void*)walIndexHdr(pWal), sizeof(WalIndexHdr));\n\n  /* Make sure some writer hasn't come in and changed the WAL file out\n  ** from under us, then disconnected, while we were not looking.\n  */\n  rc = sqlite3OsFileSize(pWal->pWalFd, &szWal);\n  if( rc!=SQLITE_OK ){\n    goto begin_unreliable_shm_out;\n  }\n  if( szWal<WAL_HDRSIZE ){\n    /* If the wal file is too small to contain a wal-header and the\n    ** wal-index header has mxFrame==0, then it must be safe to proceed\n    ** reading the database file only. However, the page cache cannot\n    ** be trusted, as a read/write connection may have connected, written\n    ** the db, run a checkpoint, truncated the wal file and disconnected\n    ** since this client's last read transaction.  */\n    *pChanged = 1;\n    rc = (pWal->hdr.mxFrame==0 ? SQLITE_OK : WAL_RETRY);\n    goto begin_unreliable_shm_out;\n  }\n\n  /* Check the salt keys at the start of the wal file still match. */\n  rc = sqlite3OsRead(pWal->pWalFd, aBuf, WAL_HDRSIZE, 0);\n  if( rc!=SQLITE_OK ){\n    goto begin_unreliable_shm_out;\n  }\n  if( memcmp(&pWal->hdr.aSalt, &aBuf[16], 8) ){\n    /* Some writer has wrapped the WAL file while we were not looking.\n    ** Return WAL_RETRY which will cause the in-memory WAL-index to be\n    ** rebuilt. */\n    rc = WAL_RETRY;\n    goto begin_unreliable_shm_out;\n  }\n\n  /* Allocate a buffer to read frames into */\n  szFrame = pWal->hdr.szPage + WAL_FRAME_HDRSIZE;\n  aFrame = (u8 *)sqlite3_malloc64(szFrame);\n  if( aFrame==0 ){\n    rc = SQLITE_NOMEM_BKPT;\n    goto begin_unreliable_shm_out;\n  }\n  aData = &aFrame[WAL_FRAME_HDRSIZE];\n\n  /* Check to see if a complete transaction has been appended to the\n  ** wal file since the heap-memory wal-index was created. If so, the\n  ** heap-memory wal-index is discarded and WAL_RETRY returned to\n  ** the caller.  */\n  aSaveCksum[0] = pWal->hdr.aFrameCksum[0];\n  aSaveCksum[1] = pWal->hdr.aFrameCksum[1];\n  for(iOffset=walFrameOffset(pWal->hdr.mxFrame+1, pWal->hdr.szPage); \n      iOffset+szFrame<=szWal; \n      iOffset+=szFrame\n  ){\n    u32 pgno;                   /* Database page number for frame */\n    u32 nTruncate;              /* dbsize field from frame header */\n\n    /* Read and decode the next log frame. */\n    rc = sqlite3OsRead(pWal->pWalFd, aFrame, szFrame, iOffset);\n    if( rc!=SQLITE_OK ) break;\n    if( !walDecodeFrame(pWal, &pgno, &nTruncate, aData, aFrame) ) break;\n\n    /* If nTruncate is non-zero, then a complete transaction has been\n    ** appended to this wal file. Set rc to WAL_RETRY and break out of\n    ** the loop.  */\n    if( nTruncate ){\n      rc = WAL_RETRY;\n      break;\n    }\n  }\n  pWal->hdr.aFrameCksum[0] = aSaveCksum[0];\n  pWal->hdr.aFrameCksum[1] = aSaveCksum[1];\n\n begin_unreliable_shm_out:\n  sqlite3_free(aFrame);\n  if( rc!=SQLITE_OK ){\n    int i;\n    for(i=0; i<pWal->nWiData; i++){\n      sqlite3_free((void*)pWal->apWiData[i]);\n      pWal->apWiData[i] = 0;\n    }\n    pWal->bShmUnreliable = 0;\n    sqlite3WalEndReadTransaction(pWal);\n    *pChanged = 1;\n  }\n  return rc;\n}\n\n/*\n** Attempt to start a read transaction.  This might fail due to a race or\n** other transient condition.  When that happens, it returns WAL_RETRY to\n** indicate to the caller that it is safe to retry immediately.\n**\n** On success return SQLITE_OK.  On a permanent failure (such an\n** I/O error or an SQLITE_BUSY because another process is running\n** recovery) return a positive error code.\n**\n** The useWal parameter is true to force the use of the WAL and disable\n** the case where the WAL is bypassed because it has been completely\n** checkpointed.  If useWal==0 then this routine calls walIndexReadHdr() \n** to make a copy of the wal-index header into pWal->hdr.  If the \n** wal-index header has changed, *pChanged is set to 1 (as an indication \n** to the caller that the local page cache is obsolete and needs to be \n** flushed.)  When useWal==1, the wal-index header is assumed to already\n** be loaded and the pChanged parameter is unused.\n**\n** The caller must set the cnt parameter to the number of prior calls to\n** this routine during the current read attempt that returned WAL_RETRY.\n** This routine will start taking more aggressive measures to clear the\n** race conditions after multiple WAL_RETRY returns, and after an excessive\n** number of errors will ultimately return SQLITE_PROTOCOL.  The\n** SQLITE_PROTOCOL return indicates that some other process has gone rogue\n** and is not honoring the locking protocol.  There is a vanishingly small\n** chance that SQLITE_PROTOCOL could be returned because of a run of really\n** bad luck when there is lots of contention for the wal-index, but that\n** possibility is so small that it can be safely neglected, we believe.\n**\n** On success, this routine obtains a read lock on \n** WAL_READ_LOCK(pWal->readLock).  The pWal->readLock integer is\n** in the range 0 <= pWal->readLock < WAL_NREADER.  If pWal->readLock==(-1)\n** that means the Wal does not hold any read lock.  The reader must not\n** access any database page that is modified by a WAL frame up to and\n** including frame number aReadMark[pWal->readLock].  The reader will\n** use WAL frames up to and including pWal->hdr.mxFrame if pWal->readLock>0\n** Or if pWal->readLock==0, then the reader will ignore the WAL\n** completely and get all content directly from the database file.\n** If the useWal parameter is 1 then the WAL will never be ignored and\n** this routine will always set pWal->readLock>0 on success.\n** When the read transaction is completed, the caller must release the\n** lock on WAL_READ_LOCK(pWal->readLock) and set pWal->readLock to -1.\n**\n** This routine uses the nBackfill and aReadMark[] fields of the header\n** to select a particular WAL_READ_LOCK() that strives to let the\n** checkpoint process do as much work as possible.  This routine might\n** update values of the aReadMark[] array in the header, but if it does\n** so it takes care to hold an exclusive lock on the corresponding\n** WAL_READ_LOCK() while changing values.\n*/\nstatic int walTryBeginRead(Wal *pWal, int *pChanged, int useWal, int cnt){\n  volatile WalCkptInfo *pInfo;    /* Checkpoint information in wal-index */\n  u32 mxReadMark;                 /* Largest aReadMark[] value */\n  int mxI;                        /* Index of largest aReadMark[] value */\n  int i;                          /* Loop counter */\n  int rc = SQLITE_OK;             /* Return code  */\n  u32 mxFrame;                    /* Wal frame to lock to */\n\n  assert( pWal->readLock<0 );     /* Not currently locked */\n\n  /* useWal may only be set for read/write connections */\n  assert( (pWal->readOnly & WAL_SHM_RDONLY)==0 || useWal==0 );\n\n  /* Take steps to avoid spinning forever if there is a protocol error.\n  **\n  ** Circumstances that cause a RETRY should only last for the briefest\n  ** instances of time.  No I/O or other system calls are done while the\n  ** locks are held, so the locks should not be held for very long. But \n  ** if we are unlucky, another process that is holding a lock might get\n  ** paged out or take a page-fault that is time-consuming to resolve, \n  ** during the few nanoseconds that it is holding the lock.  In that case,\n  ** it might take longer than normal for the lock to free.\n  **\n  ** After 5 RETRYs, we begin calling sqlite3OsSleep().  The first few\n  ** calls to sqlite3OsSleep() have a delay of 1 microsecond.  Really this\n  ** is more of a scheduler yield than an actual delay.  But on the 10th\n  ** an subsequent retries, the delays start becoming longer and longer, \n  ** so that on the 100th (and last) RETRY we delay for 323 milliseconds.\n  ** The total delay time before giving up is less than 10 seconds.\n  */\n  if( cnt>5 ){\n    int nDelay = 1;                      /* Pause time in microseconds */\n    if( cnt>100 ){\n      VVA_ONLY( pWal->lockError = 1; )\n      return SQLITE_PROTOCOL;\n    }\n    if( cnt>=10 ) nDelay = (cnt-9)*(cnt-9)*39;\n    sqlite3OsSleep(pWal->pVfs, nDelay);\n  }\n\n  if( !useWal ){\n    assert( rc==SQLITE_OK );\n    if( pWal->bShmUnreliable==0 ){\n      rc = walIndexReadHdr(pWal, pChanged);\n    }\n    if( rc==SQLITE_BUSY ){\n      /* If there is not a recovery running in another thread or process\n      ** then convert BUSY errors to WAL_RETRY.  If recovery is known to\n      ** be running, convert BUSY to BUSY_RECOVERY.  There is a race here\n      ** which might cause WAL_RETRY to be returned even if BUSY_RECOVERY\n      ** would be technically correct.  But the race is benign since with\n      ** WAL_RETRY this routine will be called again and will probably be\n      ** right on the second iteration.\n      */\n      if( pWal->apWiData[0]==0 ){\n        /* This branch is taken when the xShmMap() method returns SQLITE_BUSY.\n        ** We assume this is a transient condition, so return WAL_RETRY. The\n        ** xShmMap() implementation used by the default unix and win32 VFS \n        ** modules may return SQLITE_BUSY due to a race condition in the \n        ** code that determines whether or not the shared-memory region \n        ** must be zeroed before the requested page is returned.\n        */\n        rc = WAL_RETRY;\n      }else if( SQLITE_OK==(rc = walLockShared(pWal, WAL_RECOVER_LOCK)) ){\n        walUnlockShared(pWal, WAL_RECOVER_LOCK);\n        rc = WAL_RETRY;\n      }else if( rc==SQLITE_BUSY ){\n        rc = SQLITE_BUSY_RECOVERY;\n      }\n    }\n    if( rc!=SQLITE_OK ){\n      return rc;\n    }\n    else if( pWal->bShmUnreliable ){\n      return walBeginShmUnreliable(pWal, pChanged);\n    }\n  }\n\n  assert( pWal->nWiData>0 );\n  assert( pWal->apWiData[0]!=0 );\n  pInfo = walCkptInfo(pWal);\n  if( !useWal && pInfo->nBackfill==pWal->hdr.mxFrame\n#ifdef SQLITE_ENABLE_SNAPSHOT\n   && (pWal->pSnapshot==0 || pWal->hdr.mxFrame==0)\n#endif\n  ){\n    /* The WAL has been completely backfilled (or it is empty).\n    ** and can be safely ignored.\n    */\n    rc = walLockShared(pWal, WAL_READ_LOCK(0));\n    walShmBarrier(pWal);\n    if( rc==SQLITE_OK ){\n      if( memcmp((void *)walIndexHdr(pWal), &pWal->hdr, sizeof(WalIndexHdr)) ){\n        /* It is not safe to allow the reader to continue here if frames\n        ** may have been appended to the log before READ_LOCK(0) was obtained.\n        ** When holding READ_LOCK(0), the reader ignores the entire log file,\n        ** which implies that the database file contains a trustworthy\n        ** snapshot. Since holding READ_LOCK(0) prevents a checkpoint from\n        ** happening, this is usually correct.\n        **\n        ** However, if frames have been appended to the log (or if the log \n        ** is wrapped and written for that matter) before the READ_LOCK(0)\n        ** is obtained, that is not necessarily true. A checkpointer may\n        ** have started to backfill the appended frames but crashed before\n        ** it finished. Leaving a corrupt image in the database file.\n        */\n        walUnlockShared(pWal, WAL_READ_LOCK(0));\n        return WAL_RETRY;\n      }\n      pWal->readLock = 0;\n      return SQLITE_OK;\n    }else if( rc!=SQLITE_BUSY ){\n      return rc;\n    }\n  }\n\n  /* If we get this far, it means that the reader will want to use\n  ** the WAL to get at content from recent commits.  The job now is\n  ** to select one of the aReadMark[] entries that is closest to\n  ** but not exceeding pWal->hdr.mxFrame and lock that entry.\n  */\n  mxReadMark = 0;\n  mxI = 0;\n  mxFrame = pWal->hdr.mxFrame;\n#ifdef SQLITE_ENABLE_SNAPSHOT\n  if( pWal->pSnapshot && pWal->pSnapshot->mxFrame<mxFrame ){\n    mxFrame = pWal->pSnapshot->mxFrame;\n  }\n#endif\n  for(i=1; i<WAL_NREADER; i++){\n    u32 thisMark = AtomicLoad(pInfo->aReadMark+i);\n    if( mxReadMark<=thisMark && thisMark<=mxFrame ){\n      assert( thisMark!=READMARK_NOT_USED );\n      mxReadMark = thisMark;\n      mxI = i;\n    }\n  }\n  if( (pWal->readOnly & WAL_SHM_RDONLY)==0\n   && (mxReadMark<mxFrame || mxI==0)\n  ){\n    for(i=1; i<WAL_NREADER; i++){\n      rc = walLockExclusive(pWal, WAL_READ_LOCK(i), 1);\n      if( rc==SQLITE_OK ){\n        mxReadMark = AtomicStore(pInfo->aReadMark+i,mxFrame);\n        mxI = i;\n        walUnlockExclusive(pWal, WAL_READ_LOCK(i), 1);\n        break;\n      }else if( rc!=SQLITE_BUSY ){\n        return rc;\n      }\n    }\n  }\n  if( mxI==0 ){\n    assert( rc==SQLITE_BUSY || (pWal->readOnly & WAL_SHM_RDONLY)!=0 );\n    return rc==SQLITE_BUSY ? WAL_RETRY : SQLITE_READONLY_CANTINIT;\n  }\n\n  rc = walLockShared(pWal, WAL_READ_LOCK(mxI));\n  if( rc ){\n    return rc==SQLITE_BUSY ? WAL_RETRY : rc;\n  }\n  /* Now that the read-lock has been obtained, check that neither the\n  ** value in the aReadMark[] array or the contents of the wal-index\n  ** header have changed.\n  **\n  ** It is necessary to check that the wal-index header did not change\n  ** between the time it was read and when the shared-lock was obtained\n  ** on WAL_READ_LOCK(mxI) was obtained to account for the possibility\n  ** that the log file may have been wrapped by a writer, or that frames\n  ** that occur later in the log than pWal->hdr.mxFrame may have been\n  ** copied into the database by a checkpointer. If either of these things\n  ** happened, then reading the database with the current value of\n  ** pWal->hdr.mxFrame risks reading a corrupted snapshot. So, retry\n  ** instead.\n  **\n  ** Before checking that the live wal-index header has not changed\n  ** since it was read, set Wal.minFrame to the first frame in the wal\n  ** file that has not yet been checkpointed. This client will not need\n  ** to read any frames earlier than minFrame from the wal file - they\n  ** can be safely read directly from the database file.\n  **\n  ** Because a ShmBarrier() call is made between taking the copy of \n  ** nBackfill and checking that the wal-header in shared-memory still\n  ** matches the one cached in pWal->hdr, it is guaranteed that the \n  ** checkpointer that set nBackfill was not working with a wal-index\n  ** header newer than that cached in pWal->hdr. If it were, that could\n  ** cause a problem. The checkpointer could omit to checkpoint\n  ** a version of page X that lies before pWal->minFrame (call that version\n  ** A) on the basis that there is a newer version (version B) of the same\n  ** page later in the wal file. But if version B happens to like past\n  ** frame pWal->hdr.mxFrame - then the client would incorrectly assume\n  ** that it can read version A from the database file. However, since\n  ** we can guarantee that the checkpointer that set nBackfill could not\n  ** see any pages past pWal->hdr.mxFrame, this problem does not come up.\n  */\n  pWal->minFrame = AtomicLoad(&pInfo->nBackfill)+1;\n  walShmBarrier(pWal);\n  if( AtomicLoad(pInfo->aReadMark+mxI)!=mxReadMark\n   || memcmp((void *)walIndexHdr(pWal), &pWal->hdr, sizeof(WalIndexHdr))\n  ){\n    walUnlockShared(pWal, WAL_READ_LOCK(mxI));\n    return WAL_RETRY;\n  }else{\n    assert( mxReadMark<=pWal->hdr.mxFrame );\n    pWal->readLock = (i16)mxI;\n  }\n  return rc;\n}\n\n#ifdef SQLITE_ENABLE_SNAPSHOT\n/*\n** Attempt to reduce the value of the WalCkptInfo.nBackfillAttempted \n** variable so that older snapshots can be accessed. To do this, loop\n** through all wal frames from nBackfillAttempted to (nBackfill+1), \n** comparing their content to the corresponding page with the database\n** file, if any. Set nBackfillAttempted to the frame number of the\n** first frame for which the wal file content matches the db file.\n**\n** This is only really safe if the file-system is such that any page \n** writes made by earlier checkpointers were atomic operations, which \n** is not always true. It is also possible that nBackfillAttempted\n** may be left set to a value larger than expected, if a wal frame\n** contains content that duplicate of an earlier version of the same\n** page.\n**\n** SQLITE_OK is returned if successful, or an SQLite error code if an\n** error occurs. It is not an error if nBackfillAttempted cannot be\n** decreased at all.\n*/\nSQLITE_PRIVATE int sqlite3WalSnapshotRecover(Wal *pWal){\n  int rc;\n\n  assert( pWal->readLock>=0 );\n  rc = walLockExclusive(pWal, WAL_CKPT_LOCK, 1);\n  if( rc==SQLITE_OK ){\n    volatile WalCkptInfo *pInfo = walCkptInfo(pWal);\n    int szPage = (int)pWal->szPage;\n    i64 szDb;                   /* Size of db file in bytes */\n\n    rc = sqlite3OsFileSize(pWal->pDbFd, &szDb);\n    if( rc==SQLITE_OK ){\n      void *pBuf1 = sqlite3_malloc(szPage);\n      void *pBuf2 = sqlite3_malloc(szPage);\n      if( pBuf1==0 || pBuf2==0 ){\n        rc = SQLITE_NOMEM;\n      }else{\n        u32 i = pInfo->nBackfillAttempted;\n        for(i=pInfo->nBackfillAttempted; i>pInfo->nBackfill; i--){\n          WalHashLoc sLoc;          /* Hash table location */\n          u32 pgno;                 /* Page number in db file */\n          i64 iDbOff;               /* Offset of db file entry */\n          i64 iWalOff;              /* Offset of wal file entry */\n\n          rc = walHashGet(pWal, walFramePage(i), &sLoc);\n          if( rc!=SQLITE_OK ) break;\n          pgno = sLoc.aPgno[i-sLoc.iZero];\n          iDbOff = (i64)(pgno-1) * szPage;\n\n          if( iDbOff+szPage<=szDb ){\n            iWalOff = walFrameOffset(i, szPage) + WAL_FRAME_HDRSIZE;\n            rc = sqlite3OsRead(pWal->pWalFd, pBuf1, szPage, iWalOff);\n\n            if( rc==SQLITE_OK ){\n              rc = sqlite3OsRead(pWal->pDbFd, pBuf2, szPage, iDbOff);\n            }\n\n            if( rc!=SQLITE_OK || 0==memcmp(pBuf1, pBuf2, szPage) ){\n              break;\n            }\n          }\n\n          pInfo->nBackfillAttempted = i-1;\n        }\n      }\n\n      sqlite3_free(pBuf1);\n      sqlite3_free(pBuf2);\n    }\n    walUnlockExclusive(pWal, WAL_CKPT_LOCK, 1);\n  }\n\n  return rc;\n}\n#endif /* SQLITE_ENABLE_SNAPSHOT */\n\n/*\n** Begin a read transaction on the database.\n**\n** This routine used to be called sqlite3OpenSnapshot() and with good reason:\n** it takes a snapshot of the state of the WAL and wal-index for the current\n** instant in time.  The current thread will continue to use this snapshot.\n** Other threads might append new content to the WAL and wal-index but\n** that extra content is ignored by the current thread.\n**\n** If the database contents have changes since the previous read\n** transaction, then *pChanged is set to 1 before returning.  The\n** Pager layer will use this to know that its cache is stale and\n** needs to be flushed.\n*/\nSQLITE_PRIVATE int sqlite3WalBeginReadTransaction(Wal *pWal, int *pChanged){\n  int rc;                         /* Return code */\n  int cnt = 0;                    /* Number of TryBeginRead attempts */\n\n#ifdef SQLITE_ENABLE_SNAPSHOT\n  int bChanged = 0;\n  WalIndexHdr *pSnapshot = pWal->pSnapshot;\n  if( pSnapshot && memcmp(pSnapshot, &pWal->hdr, sizeof(WalIndexHdr))!=0 ){\n    bChanged = 1;\n  }\n#endif\n\n  do{\n    rc = walTryBeginRead(pWal, pChanged, 0, ++cnt);\n  }while( rc==WAL_RETRY );\n  testcase( (rc&0xff)==SQLITE_BUSY );\n  testcase( (rc&0xff)==SQLITE_IOERR );\n  testcase( rc==SQLITE_PROTOCOL );\n  testcase( rc==SQLITE_OK );\n\n#ifdef SQLITE_ENABLE_SNAPSHOT\n  if( rc==SQLITE_OK ){\n    if( pSnapshot && memcmp(pSnapshot, &pWal->hdr, sizeof(WalIndexHdr))!=0 ){\n      /* At this point the client has a lock on an aReadMark[] slot holding\n      ** a value equal to or smaller than pSnapshot->mxFrame, but pWal->hdr\n      ** is populated with the wal-index header corresponding to the head\n      ** of the wal file. Verify that pSnapshot is still valid before\n      ** continuing.  Reasons why pSnapshot might no longer be valid:\n      **\n      **    (1)  The WAL file has been reset since the snapshot was taken.\n      **         In this case, the salt will have changed.\n      **\n      **    (2)  A checkpoint as been attempted that wrote frames past\n      **         pSnapshot->mxFrame into the database file.  Note that the\n      **         checkpoint need not have completed for this to cause problems.\n      */\n      volatile WalCkptInfo *pInfo = walCkptInfo(pWal);\n\n      assert( pWal->readLock>0 || pWal->hdr.mxFrame==0 );\n      assert( pInfo->aReadMark[pWal->readLock]<=pSnapshot->mxFrame );\n\n      /* It is possible that there is a checkpointer thread running \n      ** concurrent with this code. If this is the case, it may be that the\n      ** checkpointer has already determined that it will checkpoint \n      ** snapshot X, where X is later in the wal file than pSnapshot, but \n      ** has not yet set the pInfo->nBackfillAttempted variable to indicate \n      ** its intent. To avoid the race condition this leads to, ensure that\n      ** there is no checkpointer process by taking a shared CKPT lock \n      ** before checking pInfo->nBackfillAttempted.  \n      **\n      ** TODO: Does the aReadMark[] lock prevent a checkpointer from doing\n      **       this already?\n      */\n      rc = walLockShared(pWal, WAL_CKPT_LOCK);\n\n      if( rc==SQLITE_OK ){\n        /* Check that the wal file has not been wrapped. Assuming that it has\n        ** not, also check that no checkpointer has attempted to checkpoint any\n        ** frames beyond pSnapshot->mxFrame. If either of these conditions are\n        ** true, return SQLITE_ERROR_SNAPSHOT. Otherwise, overwrite pWal->hdr\n        ** with *pSnapshot and set *pChanged as appropriate for opening the\n        ** snapshot.  */\n        if( !memcmp(pSnapshot->aSalt, pWal->hdr.aSalt, sizeof(pWal->hdr.aSalt))\n         && pSnapshot->mxFrame>=pInfo->nBackfillAttempted\n        ){\n          assert( pWal->readLock>0 );\n          memcpy(&pWal->hdr, pSnapshot, sizeof(WalIndexHdr));\n          *pChanged = bChanged;\n        }else{\n          rc = SQLITE_ERROR_SNAPSHOT;\n        }\n\n        /* Release the shared CKPT lock obtained above. */\n        walUnlockShared(pWal, WAL_CKPT_LOCK);\n        pWal->minFrame = 1;\n      }\n\n\n      if( rc!=SQLITE_OK ){\n        sqlite3WalEndReadTransaction(pWal);\n      }\n    }\n  }\n#endif\n  return rc;\n}\n\n/*\n** Finish with a read transaction.  All this does is release the\n** read-lock.\n*/\nSQLITE_PRIVATE void sqlite3WalEndReadTransaction(Wal *pWal){\n  sqlite3WalEndWriteTransaction(pWal);\n  if( pWal->readLock>=0 ){\n    walUnlockShared(pWal, WAL_READ_LOCK(pWal->readLock));\n    pWal->readLock = -1;\n  }\n}\n\n/*\n** Search the wal file for page pgno. If found, set *piRead to the frame that\n** contains the page. Otherwise, if pgno is not in the wal file, set *piRead\n** to zero.\n**\n** Return SQLITE_OK if successful, or an error code if an error occurs. If an\n** error does occur, the final value of *piRead is undefined.\n*/\nSQLITE_PRIVATE int sqlite3WalFindFrame(\n  Wal *pWal,                      /* WAL handle */\n  Pgno pgno,                      /* Database page number to read data for */\n  u32 *piRead                     /* OUT: Frame number (or zero) */\n){\n  u32 iRead = 0;                  /* If !=0, WAL frame to return data from */\n  u32 iLast = pWal->hdr.mxFrame;  /* Last page in WAL for this reader */\n  int iHash;                      /* Used to loop through N hash tables */\n  int iMinHash;\n\n  /* This routine is only be called from within a read transaction. */\n  assert( pWal->readLock>=0 || pWal->lockError );\n\n  /* If the \"last page\" field of the wal-index header snapshot is 0, then\n  ** no data will be read from the wal under any circumstances. Return early\n  ** in this case as an optimization.  Likewise, if pWal->readLock==0, \n  ** then the WAL is ignored by the reader so return early, as if the \n  ** WAL were empty.\n  */\n  if( iLast==0 || (pWal->readLock==0 && pWal->bShmUnreliable==0) ){\n    *piRead = 0;\n    return SQLITE_OK;\n  }\n\n  /* Search the hash table or tables for an entry matching page number\n  ** pgno. Each iteration of the following for() loop searches one\n  ** hash table (each hash table indexes up to HASHTABLE_NPAGE frames).\n  **\n  ** This code might run concurrently to the code in walIndexAppend()\n  ** that adds entries to the wal-index (and possibly to this hash \n  ** table). This means the value just read from the hash \n  ** slot (aHash[iKey]) may have been added before or after the \n  ** current read transaction was opened. Values added after the\n  ** read transaction was opened may have been written incorrectly -\n  ** i.e. these slots may contain garbage data. However, we assume\n  ** that any slots written before the current read transaction was\n  ** opened remain unmodified.\n  **\n  ** For the reasons above, the if(...) condition featured in the inner\n  ** loop of the following block is more stringent that would be required \n  ** if we had exclusive access to the hash-table:\n  **\n  **   (aPgno[iFrame]==pgno): \n  **     This condition filters out normal hash-table collisions.\n  **\n  **   (iFrame<=iLast): \n  **     This condition filters out entries that were added to the hash\n  **     table after the current read-transaction had started.\n  */\n  iMinHash = walFramePage(pWal->minFrame);\n  for(iHash=walFramePage(iLast); iHash>=iMinHash; iHash--){\n    WalHashLoc sLoc;              /* Hash table location */\n    int iKey;                     /* Hash slot index */\n    int nCollide;                 /* Number of hash collisions remaining */\n    int rc;                       /* Error code */\n\n    rc = walHashGet(pWal, iHash, &sLoc);\n    if( rc!=SQLITE_OK ){\n      return rc;\n    }\n    nCollide = HASHTABLE_NSLOT;\n    for(iKey=walHash(pgno); sLoc.aHash[iKey]; iKey=walNextHash(iKey)){\n      u32 iFrame = sLoc.aHash[iKey] + sLoc.iZero;\n      if( iFrame<=iLast && iFrame>=pWal->minFrame\n       && sLoc.aPgno[sLoc.aHash[iKey]]==pgno ){\n        assert( iFrame>iRead || CORRUPT_DB );\n        iRead = iFrame;\n      }\n      if( (nCollide--)==0 ){\n        return SQLITE_CORRUPT_BKPT;\n      }\n    }\n    if( iRead ) break;\n  }\n\n#ifdef SQLITE_ENABLE_EXPENSIVE_ASSERT\n  /* If expensive assert() statements are available, do a linear search\n  ** of the wal-index file content. Make sure the results agree with the\n  ** result obtained using the hash indexes above.  */\n  {\n    u32 iRead2 = 0;\n    u32 iTest;\n    assert( pWal->bShmUnreliable || pWal->minFrame>0 );\n    for(iTest=iLast; iTest>=pWal->minFrame && iTest>0; iTest--){\n      if( walFramePgno(pWal, iTest)==pgno ){\n        iRead2 = iTest;\n        break;\n      }\n    }\n    assert( iRead==iRead2 );\n  }\n#endif\n\n  *piRead = iRead;\n  return SQLITE_OK;\n}\n\n/*\n** Read the contents of frame iRead from the wal file into buffer pOut\n** (which is nOut bytes in size). Return SQLITE_OK if successful, or an\n** error code otherwise.\n*/\nSQLITE_PRIVATE int sqlite3WalReadFrame(\n  Wal *pWal,                      /* WAL handle */\n  u32 iRead,                      /* Frame to read */\n  int nOut,                       /* Size of buffer pOut in bytes */\n  u8 *pOut                        /* Buffer to write page data to */\n){\n  int sz;\n  i64 iOffset;\n  sz = pWal->hdr.szPage;\n  sz = (sz&0xfe00) + ((sz&0x0001)<<16);\n  testcase( sz<=32768 );\n  testcase( sz>=65536 );\n  iOffset = walFrameOffset(iRead, sz) + WAL_FRAME_HDRSIZE;\n  /* testcase( IS_BIG_INT(iOffset) ); // requires a 4GiB WAL */\n  return sqlite3OsRead(pWal->pWalFd, pOut, (nOut>sz ? sz : nOut), iOffset);\n}\n\n/* \n** Return the size of the database in pages (or zero, if unknown).\n*/\nSQLITE_PRIVATE Pgno sqlite3WalDbsize(Wal *pWal){\n  if( pWal && ALWAYS(pWal->readLock>=0) ){\n    return pWal->hdr.nPage;\n  }\n  return 0;\n}\n\n\n/* \n** This function starts a write transaction on the WAL.\n**\n** A read transaction must have already been started by a prior call\n** to sqlite3WalBeginReadTransaction().\n**\n** If another thread or process has written into the database since\n** the read transaction was started, then it is not possible for this\n** thread to write as doing so would cause a fork.  So this routine\n** returns SQLITE_BUSY in that case and no write transaction is started.\n**\n** There can only be a single writer active at a time.\n*/\nSQLITE_PRIVATE int sqlite3WalBeginWriteTransaction(Wal *pWal){\n  int rc;\n\n  /* Cannot start a write transaction without first holding a read\n  ** transaction. */\n  assert( pWal->readLock>=0 );\n  assert( pWal->writeLock==0 && pWal->iReCksum==0 );\n\n  if( pWal->readOnly ){\n    return SQLITE_READONLY;\n  }\n\n  /* Only one writer allowed at a time.  Get the write lock.  Return\n  ** SQLITE_BUSY if unable.\n  */\n  rc = walLockExclusive(pWal, WAL_WRITE_LOCK, 1);\n  if( rc ){\n    return rc;\n  }\n  pWal->writeLock = 1;\n\n  /* If another connection has written to the database file since the\n  ** time the read transaction on this connection was started, then\n  ** the write is disallowed.\n  */\n  if( memcmp(&pWal->hdr, (void *)walIndexHdr(pWal), sizeof(WalIndexHdr))!=0 ){\n    walUnlockExclusive(pWal, WAL_WRITE_LOCK, 1);\n    pWal->writeLock = 0;\n    rc = SQLITE_BUSY_SNAPSHOT;\n  }\n\n  return rc;\n}\n\n/*\n** End a write transaction.  The commit has already been done.  This\n** routine merely releases the lock.\n*/\nSQLITE_PRIVATE int sqlite3WalEndWriteTransaction(Wal *pWal){\n  if( pWal->writeLock ){\n    walUnlockExclusive(pWal, WAL_WRITE_LOCK, 1);\n    pWal->writeLock = 0;\n    pWal->iReCksum = 0;\n    pWal->truncateOnCommit = 0;\n  }\n  return SQLITE_OK;\n}\n\n/*\n** If any data has been written (but not committed) to the log file, this\n** function moves the write-pointer back to the start of the transaction.\n**\n** Additionally, the callback function is invoked for each frame written\n** to the WAL since the start of the transaction. If the callback returns\n** other than SQLITE_OK, it is not invoked again and the error code is\n** returned to the caller.\n**\n** Otherwise, if the callback function does not return an error, this\n** function returns SQLITE_OK.\n*/\nSQLITE_PRIVATE int sqlite3WalUndo(Wal *pWal, int (*xUndo)(void *, Pgno), void *pUndoCtx){\n  int rc = SQLITE_OK;\n  if( ALWAYS(pWal->writeLock) ){\n    Pgno iMax = pWal->hdr.mxFrame;\n    Pgno iFrame;\n  \n    /* Restore the clients cache of the wal-index header to the state it\n    ** was in before the client began writing to the database. \n    */\n    memcpy(&pWal->hdr, (void *)walIndexHdr(pWal), sizeof(WalIndexHdr));\n\n    for(iFrame=pWal->hdr.mxFrame+1; \n        ALWAYS(rc==SQLITE_OK) && iFrame<=iMax; \n        iFrame++\n    ){\n      /* This call cannot fail. Unless the page for which the page number\n      ** is passed as the second argument is (a) in the cache and \n      ** (b) has an outstanding reference, then xUndo is either a no-op\n      ** (if (a) is false) or simply expels the page from the cache (if (b)\n      ** is false).\n      **\n      ** If the upper layer is doing a rollback, it is guaranteed that there\n      ** are no outstanding references to any page other than page 1. And\n      ** page 1 is never written to the log until the transaction is\n      ** committed. As a result, the call to xUndo may not fail.\n      */\n      assert( walFramePgno(pWal, iFrame)!=1 );\n      rc = xUndo(pUndoCtx, walFramePgno(pWal, iFrame));\n    }\n    if( iMax!=pWal->hdr.mxFrame ) walCleanupHash(pWal);\n  }\n  return rc;\n}\n\n/* \n** Argument aWalData must point to an array of WAL_SAVEPOINT_NDATA u32 \n** values. This function populates the array with values required to \n** \"rollback\" the write position of the WAL handle back to the current \n** point in the event of a savepoint rollback (via WalSavepointUndo()).\n*/\nSQLITE_PRIVATE void sqlite3WalSavepoint(Wal *pWal, u32 *aWalData){\n  assert( pWal->writeLock );\n  aWalData[0] = pWal->hdr.mxFrame;\n  aWalData[1] = pWal->hdr.aFrameCksum[0];\n  aWalData[2] = pWal->hdr.aFrameCksum[1];\n  aWalData[3] = pWal->nCkpt;\n}\n\n/* \n** Move the write position of the WAL back to the point identified by\n** the values in the aWalData[] array. aWalData must point to an array\n** of WAL_SAVEPOINT_NDATA u32 values that has been previously populated\n** by a call to WalSavepoint().\n*/\nSQLITE_PRIVATE int sqlite3WalSavepointUndo(Wal *pWal, u32 *aWalData){\n  int rc = SQLITE_OK;\n\n  assert( pWal->writeLock );\n  assert( aWalData[3]!=pWal->nCkpt || aWalData[0]<=pWal->hdr.mxFrame );\n\n  if( aWalData[3]!=pWal->nCkpt ){\n    /* This savepoint was opened immediately after the write-transaction\n    ** was started. Right after that, the writer decided to wrap around\n    ** to the start of the log. Update the savepoint values to match.\n    */\n    aWalData[0] = 0;\n    aWalData[3] = pWal->nCkpt;\n  }\n\n  if( aWalData[0]<pWal->hdr.mxFrame ){\n    pWal->hdr.mxFrame = aWalData[0];\n    pWal->hdr.aFrameCksum[0] = aWalData[1];\n    pWal->hdr.aFrameCksum[1] = aWalData[2];\n    walCleanupHash(pWal);\n  }\n\n  return rc;\n}\n\n/*\n** This function is called just before writing a set of frames to the log\n** file (see sqlite3WalFrames()). It checks to see if, instead of appending\n** to the current log file, it is possible to overwrite the start of the\n** existing log file with the new frames (i.e. \"reset\" the log). If so,\n** it sets pWal->hdr.mxFrame to 0. Otherwise, pWal->hdr.mxFrame is left\n** unchanged.\n**\n** SQLITE_OK is returned if no error is encountered (regardless of whether\n** or not pWal->hdr.mxFrame is modified). An SQLite error code is returned\n** if an error occurs.\n*/\nstatic int walRestartLog(Wal *pWal, int *pChanged){\n  int rc = SQLITE_OK;\n  int cnt;\n\n  if( pWal->readLock==0 ){\n    volatile WalCkptInfo *pInfo = walCkptInfo(pWal);\n    assert( pInfo->nBackfill==pWal->hdr.mxFrame );\n    if( pInfo->nBackfill>0 ){\n      u32 salt1;\n      sqlite3_randomness(4, &salt1);\n      rc = walLockExclusive(pWal, WAL_READ_LOCK(1), WAL_NREADER-1);\n      if( rc==SQLITE_OK ){\n        /* If all readers are using WAL_READ_LOCK(0) (in other words if no\n        ** readers are currently using the WAL), then the transactions\n        ** frames will overwrite the start of the existing log. Update the\n        ** wal-index header to reflect this.\n        **\n        ** In theory it would be Ok to update the cache of the header only\n        ** at this point. But updating the actual wal-index header is also\n        ** safe and means there is no special case for sqlite3WalUndo()\n        ** to handle if this transaction is rolled back.  */\n        *pChanged = 1;\n        walRestartHdr(pWal, salt1);\n        walUnlockExclusive(pWal, WAL_READ_LOCK(1), WAL_NREADER-1);\n      }else if( rc!=SQLITE_BUSY ){\n        return rc;\n      }\n    }\n    walUnlockShared(pWal, WAL_READ_LOCK(0));\n    pWal->readLock = -1;\n    cnt = 0;\n    do{\n      int notUsed;\n      rc = walTryBeginRead(pWal, &notUsed, 1, ++cnt);\n    }while( rc==WAL_RETRY );\n    assert( (rc&0xff)!=SQLITE_BUSY ); /* BUSY not possible when useWal==1 */\n    testcase( (rc&0xff)==SQLITE_IOERR );\n    testcase( rc==SQLITE_PROTOCOL );\n    testcase( rc==SQLITE_OK );\n  }\n  return rc;\n}\n\n/*\n** Information about the current state of the WAL file and where\n** the next fsync should occur - passed from sqlite3WalFrames() into\n** walWriteToLog().\n*/\ntypedef struct WalWriter {\n  Wal *pWal;                   /* The complete WAL information */\n  sqlite3_file *pFd;           /* The WAL file to which we write */\n  sqlite3_int64 iSyncPoint;    /* Fsync at this offset */\n  int syncFlags;               /* Flags for the fsync */\n  int szPage;                  /* Size of one page */\n} WalWriter;\n\n/*\n** Write iAmt bytes of content into the WAL file beginning at iOffset.\n** Do a sync when crossing the p->iSyncPoint boundary.\n**\n** In other words, if iSyncPoint is in between iOffset and iOffset+iAmt,\n** first write the part before iSyncPoint, then sync, then write the\n** rest.\n*/\nstatic int walWriteToLog(\n  WalWriter *p,              /* WAL to write to */\n  void *pContent,            /* Content to be written */\n  int iAmt,                  /* Number of bytes to write */\n  sqlite3_int64 iOffset      /* Start writing at this offset */\n){\n  int rc;\n  if( iOffset<p->iSyncPoint && iOffset+iAmt>=p->iSyncPoint ){\n    int iFirstAmt = (int)(p->iSyncPoint - iOffset);\n    rc = sqlite3OsWrite(p->pFd, pContent, iFirstAmt, iOffset);\n    if( rc ) return rc;\n    iOffset += iFirstAmt;\n    iAmt -= iFirstAmt;\n    pContent = (void*)(iFirstAmt + (char*)pContent);\n    assert( WAL_SYNC_FLAGS(p->syncFlags)!=0 );\n    rc = sqlite3OsSync(p->pFd, WAL_SYNC_FLAGS(p->syncFlags));\n    if( iAmt==0 || rc ) return rc;\n  }\n  rc = sqlite3OsWrite(p->pFd, pContent, iAmt, iOffset);\n  return rc;\n}\n\n/*\n** Write out a single frame of the WAL\n*/\nstatic int walWriteOneFrame(\n  WalWriter *p,               /* Where to write the frame */\n  PgHdr *pPage,               /* The page of the frame to be written */\n  int nTruncate,              /* The commit flag.  Usually 0.  >0 for commit */\n  sqlite3_int64 iOffset       /* Byte offset at which to write */\n){\n  int rc;                         /* Result code from subfunctions */\n  void *pData;                    /* Data actually written */\n  u8 aFrame[WAL_FRAME_HDRSIZE];   /* Buffer to assemble frame-header in */\n#if defined(SQLITE_HAS_CODEC)\n  if( (pData = sqlite3PagerCodec(pPage))==0 ) return SQLITE_NOMEM_BKPT;\n#else\n  pData = pPage->pData;\n#endif\n  walEncodeFrame(p->pWal, pPage->pgno, nTruncate, pData, aFrame);\n  rc = walWriteToLog(p, aFrame, sizeof(aFrame), iOffset);\n  if( rc ) return rc;\n  /* Write the page data */\n  rc = walWriteToLog(p, pData, p->szPage, iOffset+sizeof(aFrame));\n  return rc;\n}\n\n/*\n** This function is called as part of committing a transaction within which\n** one or more frames have been overwritten. It updates the checksums for\n** all frames written to the wal file by the current transaction starting\n** with the earliest to have been overwritten.\n**\n** SQLITE_OK is returned if successful, or an SQLite error code otherwise.\n*/\nstatic int walRewriteChecksums(Wal *pWal, u32 iLast){\n  const int szPage = pWal->szPage;/* Database page size */\n  int rc = SQLITE_OK;             /* Return code */\n  u8 *aBuf;                       /* Buffer to load data from wal file into */\n  u8 aFrame[WAL_FRAME_HDRSIZE];   /* Buffer to assemble frame-headers in */\n  u32 iRead;                      /* Next frame to read from wal file */\n  i64 iCksumOff;\n\n  aBuf = sqlite3_malloc(szPage + WAL_FRAME_HDRSIZE);\n  if( aBuf==0 ) return SQLITE_NOMEM_BKPT;\n\n  /* Find the checksum values to use as input for the recalculating the\n  ** first checksum. If the first frame is frame 1 (implying that the current\n  ** transaction restarted the wal file), these values must be read from the\n  ** wal-file header. Otherwise, read them from the frame header of the\n  ** previous frame.  */\n  assert( pWal->iReCksum>0 );\n  if( pWal->iReCksum==1 ){\n    iCksumOff = 24;\n  }else{\n    iCksumOff = walFrameOffset(pWal->iReCksum-1, szPage) + 16;\n  }\n  rc = sqlite3OsRead(pWal->pWalFd, aBuf, sizeof(u32)*2, iCksumOff);\n  pWal->hdr.aFrameCksum[0] = sqlite3Get4byte(aBuf);\n  pWal->hdr.aFrameCksum[1] = sqlite3Get4byte(&aBuf[sizeof(u32)]);\n\n  iRead = pWal->iReCksum;\n  pWal->iReCksum = 0;\n  for(; rc==SQLITE_OK && iRead<=iLast; iRead++){\n    i64 iOff = walFrameOffset(iRead, szPage);\n    rc = sqlite3OsRead(pWal->pWalFd, aBuf, szPage+WAL_FRAME_HDRSIZE, iOff);\n    if( rc==SQLITE_OK ){\n      u32 iPgno, nDbSize;\n      iPgno = sqlite3Get4byte(aBuf);\n      nDbSize = sqlite3Get4byte(&aBuf[4]);\n\n      walEncodeFrame(pWal, iPgno, nDbSize, &aBuf[WAL_FRAME_HDRSIZE], aFrame);\n      rc = sqlite3OsWrite(pWal->pWalFd, aFrame, sizeof(aFrame), iOff);\n    }\n  }\n\n  sqlite3_free(aBuf);\n  return rc;\n}\n\n/* \n** Write a set of frames to the log. The caller must hold the write-lock\n** on the log file (obtained using sqlite3WalBeginWriteTransaction()).\n*/\nSQLITE_PRIVATE int sqlite3WalFrames(\n  Wal *pWal,                      /* Wal handle to write to */\n  int szPage,                     /* Database page-size in bytes */\n  PgHdr *pList,                   /* List of dirty pages to write */\n  Pgno nTruncate,                 /* Database size after this commit */\n  int isCommit,                   /* True if this is a commit */\n  int sync_flags                  /* Flags to pass to OsSync() (or 0) */\n){\n  int rc;                         /* Used to catch return codes */\n  u32 iFrame;                     /* Next frame address */\n  PgHdr *p;                       /* Iterator to run through pList with. */\n  PgHdr *pLast = 0;               /* Last frame in list */\n  int nExtra = 0;                 /* Number of extra copies of last page */\n  int szFrame;                    /* The size of a single frame */\n  i64 iOffset;                    /* Next byte to write in WAL file */\n  WalWriter w;                    /* The writer */\n  u32 iFirst = 0;                 /* First frame that may be overwritten */\n  WalIndexHdr *pLive;             /* Pointer to shared header */\n\n  assert( pList );\n  assert( pWal->writeLock );\n\n  /* If this frame set completes a transaction, then nTruncate>0.  If\n  ** nTruncate==0 then this frame set does not complete the transaction. */\n  assert( (isCommit!=0)==(nTruncate!=0) );\n\n#if defined(SQLITE_TEST) && defined(SQLITE_DEBUG)\n  { int cnt; for(cnt=0, p=pList; p; p=p->pDirty, cnt++){}\n    WALTRACE((\"WAL%p: frame write begin. %d frames. mxFrame=%d. %s\\n\",\n              pWal, cnt, pWal->hdr.mxFrame, isCommit ? \"Commit\" : \"Spill\"));\n  }\n#endif\n\n  pLive = (WalIndexHdr*)walIndexHdr(pWal);\n  if( memcmp(&pWal->hdr, (void *)pLive, sizeof(WalIndexHdr))!=0 ){\n    iFirst = pLive->mxFrame+1;\n  }\n\n  /* See if it is possible to write these frames into the start of the\n  ** log file, instead of appending to it at pWal->hdr.mxFrame.\n  */\n  int pChange = 0;\n  if( SQLITE_OK!=(rc = walRestartLog(pWal, &pChange)) ){\n    return rc;\n  }\n\n  /* If this is the first frame written into the log, write the WAL\n  ** header to the start of the WAL file. See comments at the top of\n  ** this source file for a description of the WAL header format.\n  */\n  iFrame = pWal->hdr.mxFrame;\n  if( iFrame==0 ){\n#ifdef SQLITE_WCDB_IMPROVED_CHECKPOINT\n    if( pChange) {\n      rc = walWriteHeader(pWal, szPage, sync_flags);\n    } else {\n      i64 nSize = 0;\n      rc = sqlite3OsFileSize(pWal->pWalFd, &nSize);\n      if( rc==SQLITE_OK && nSize<WAL_HDRSIZE){\n        rc = walWriteHeader(pWal, szPage, sync_flags);\n      } else if (pWal->szPage == 0){\n        pWal->szPage = szPage;\n      }\n    }\n#else\n    rc = walWriteHeader(pWal, szPage, sync_flags);\n#endif\n    if( rc ) return rc;\n  }\n  if( iFrame==0 ) {\n    pWal->truncateOnCommit = 1;\n  }\n  assert( (int)pWal->szPage==szPage );\n\n  /* Setup information needed to write frames into the WAL */\n  w.pWal = pWal;\n  w.pFd = pWal->pWalFd;\n  w.iSyncPoint = 0;\n  w.syncFlags = sync_flags;\n  w.szPage = szPage;\n  iOffset = walFrameOffset(iFrame+1, szPage);\n  szFrame = szPage + WAL_FRAME_HDRSIZE;\n\n  /* Write all frames into the log file exactly once */\n  for(p=pList; p; p=p->pDirty){\n    int nDbSize;   /* 0 normally.  Positive == commit flag */\n\n    /* Check if this page has already been written into the wal file by\n    ** the current transaction. If so, overwrite the existing frame and\n    ** set Wal.writeLock to WAL_WRITELOCK_RECKSUM - indicating that \n    ** checksums must be recomputed when the transaction is committed.  */\n    if( iFirst && (p->pDirty || isCommit==0) ){\n      u32 iWrite = 0;\n      VVA_ONLY(rc =) sqlite3WalFindFrame(pWal, p->pgno, &iWrite);\n      assert( rc==SQLITE_OK || iWrite==0 );\n      if( iWrite>=iFirst ){\n        i64 iOff = walFrameOffset(iWrite, szPage) + WAL_FRAME_HDRSIZE;\n        void *pData;\n        if( pWal->iReCksum==0 || iWrite<pWal->iReCksum ){\n          pWal->iReCksum = iWrite;\n        }\n#if defined(SQLITE_HAS_CODEC)\n        if( (pData = sqlite3PagerCodec(p))==0 ) return SQLITE_NOMEM;\n#else\n        pData = p->pData;\n#endif\n        rc = sqlite3OsWrite(pWal->pWalFd, pData, szPage, iOff);\n        if( rc ) return rc;\n        p->flags &= ~PGHDR_WAL_APPEND;\n        continue;\n      }\n    }\n\n    iFrame++;\n    assert( iOffset==walFrameOffset(iFrame, szPage) );\n    nDbSize = (isCommit && p->pDirty==0) ? nTruncate : 0;\n    rc = walWriteOneFrame(&w, p, nDbSize, iOffset);\n    if( rc ) return rc;\n    pLast = p;\n    iOffset += szFrame;\n    p->flags |= PGHDR_WAL_APPEND;\n  }\n\n  /* Recalculate checksums within the wal file if required. */\n  if( isCommit && pWal->iReCksum ){\n    rc = walRewriteChecksums(pWal, iFrame);\n    if( rc ) return rc;\n  }\n\n  /* If this is the end of a transaction, then we might need to pad\n  ** the transaction and/or sync the WAL file.\n  **\n  ** Padding and syncing only occur if this set of frames complete a\n  ** transaction and if PRAGMA synchronous=FULL.  If synchronous==NORMAL\n  ** or synchronous==OFF, then no padding or syncing are needed.\n  **\n  ** If SQLITE_IOCAP_POWERSAFE_OVERWRITE is defined, then padding is not\n  ** needed and only the sync is done.  If padding is needed, then the\n  ** final frame is repeated (with its commit mark) until the next sector\n  ** boundary is crossed.  Only the part of the WAL prior to the last\n  ** sector boundary is synced; the part of the last frame that extends\n  ** past the sector boundary is written after the sync.\n  */\n  if( isCommit && WAL_SYNC_FLAGS(sync_flags)!=0 ){\n    int bSync = 1;\n    if( pWal->padToSectorBoundary ){\n      int sectorSize = sqlite3SectorSize(pWal->pWalFd);\n      w.iSyncPoint = ((iOffset+sectorSize-1)/sectorSize)*sectorSize;\n      bSync = (w.iSyncPoint==iOffset);\n      testcase( bSync );\n      while( iOffset<w.iSyncPoint ){\n        rc = walWriteOneFrame(&w, pLast, nTruncate, iOffset);\n        if( rc ) return rc;\n        iOffset += szFrame;\n        nExtra++;\n      }\n    }\n    if( bSync ){\n      assert( rc==SQLITE_OK );\n      rc = sqlite3OsSync(w.pFd, WAL_SYNC_FLAGS(sync_flags));\n    }\n  }\n\n  /* If this frame set completes the first transaction in the WAL and\n  ** if PRAGMA journal_size_limit is set, then truncate the WAL to the\n  ** journal size limit, if possible.\n  */\n  if( isCommit && pWal->truncateOnCommit && pWal->mxWalSize>=0 ){\n    i64 sz = pWal->mxWalSize;\n    if( walFrameOffset(iFrame+nExtra+1, szPage)>pWal->mxWalSize ){\n      sz = walFrameOffset(iFrame+nExtra+1, szPage);\n    }\n    walLimitSize(pWal, sz);\n    pWal->truncateOnCommit = 0;\n  }\n\n  /* Append data to the wal-index. It is not necessary to lock the \n  ** wal-index to do this as the SQLITE_SHM_WRITE lock held on the wal-index\n  ** guarantees that there are no other writers, and no data that may\n  ** be in use by existing readers is being overwritten.\n  */\n  iFrame = pWal->hdr.mxFrame;\n  for(p=pList; p && rc==SQLITE_OK; p=p->pDirty){\n    if( (p->flags & PGHDR_WAL_APPEND)==0 ) continue;\n    iFrame++;\n    rc = walIndexAppend(pWal, iFrame, p->pgno);\n  }\n  while( rc==SQLITE_OK && nExtra>0 ){\n    iFrame++;\n    nExtra--;\n    rc = walIndexAppend(pWal, iFrame, pLast->pgno);\n  }\n\n  if( rc==SQLITE_OK ){\n    /* Update the private copy of the header. */\n    pWal->hdr.szPage = (u16)((szPage&0xff00) | (szPage>>16));\n    testcase( szPage<=32768 );\n    testcase( szPage>=65536 );\n    pWal->hdr.mxFrame = iFrame;\n    if( isCommit ){\n      pWal->hdr.iChange++;\n      pWal->hdr.nPage = nTruncate;\n    }\n    /* If this is a commit, update the wal-index header too. */\n    if( isCommit ){\n      walIndexWriteHdr(pWal);\n      pWal->iCallback = iFrame;\n    }\n  }\n\n  WALTRACE((\"WAL%p: frame write %s\\n\", pWal, rc ? \"failed\" : \"ok\"));\n  return rc;\n}\n\n/* \n** This routine is called to implement sqlite3_wal_checkpoint() and\n** related interfaces.\n**\n** Obtain a CHECKPOINT lock and then backfill as much information as\n** we can from WAL into the database.\n**\n** If parameter xBusy is not NULL, it is a pointer to a busy-handler\n** callback. In this case this function runs a blocking checkpoint.\n*/\nSQLITE_PRIVATE int sqlite3WalCheckpoint(\n  Wal *pWal,                      /* Wal connection */\n  sqlite3 *db,                    /* Check this handle's interrupt flag */\n  int eMode,                      /* PASSIVE, FULL, RESTART, or TRUNCATE */\n  int (*xBusy)(void*),            /* Function to call when busy */\n  void *pBusyArg,                 /* Context argument for xBusyHandler */\n  int sync_flags,                 /* Flags to sync db file with (or 0) */\n  int nBuf,                       /* Size of temporary buffer */\n  u8 *zBuf,                       /* Temporary buffer to use */\n  int *pnLog,                     /* OUT: Number of frames in WAL */\n  int *pnCkpt                     /* OUT: Number of backfilled frames in WAL */\n){\n  int rc;                         /* Return code */\n  int isChanged = 0;              /* True if a new wal-index header is loaded */\n  int eMode2 = eMode;             /* Mode to pass to walCheckpoint() */\n  int (*xBusy2)(void*) = xBusy;   /* Busy handler for eMode2 */\n\n  assert( pWal->ckptLock==0 );\n  assert( pWal->writeLock==0 );\n\n  /* EVIDENCE-OF: R-62920-47450 The busy-handler callback is never invoked\n  ** in the SQLITE_CHECKPOINT_PASSIVE mode. */\n  assert( eMode!=SQLITE_CHECKPOINT_PASSIVE || xBusy==0 );\n\n  if( pWal->readOnly ) return SQLITE_READONLY;\n  WALTRACE((\"WAL%p: checkpoint begins\\n\", pWal));\n\n  /* IMPLEMENTATION-OF: R-62028-47212 All calls obtain an exclusive \n  ** \"checkpoint\" lock on the database file. */\n  rc = walLockExclusive(pWal, WAL_CKPT_LOCK, 1);\n  if( rc ){\n    /* EVIDENCE-OF: R-10421-19736 If any other process is running a\n    ** checkpoint operation at the same time, the lock cannot be obtained and\n    ** SQLITE_BUSY is returned.\n    ** EVIDENCE-OF: R-53820-33897 Even if there is a busy-handler configured,\n    ** it will not be invoked in this case.\n    */\n    testcase( rc==SQLITE_BUSY );\n    testcase( xBusy!=0 );\n    return rc;\n  }\n  pWal->ckptLock = 1;\n\n  /* IMPLEMENTATION-OF: R-59782-36818 The SQLITE_CHECKPOINT_FULL, RESTART and\n  ** TRUNCATE modes also obtain the exclusive \"writer\" lock on the database\n  ** file.\n  **\n  ** EVIDENCE-OF: R-60642-04082 If the writer lock cannot be obtained\n  ** immediately, and a busy-handler is configured, it is invoked and the\n  ** writer lock retried until either the busy-handler returns 0 or the\n  ** lock is successfully obtained.\n  */\n  if( eMode!=SQLITE_CHECKPOINT_PASSIVE ){\n    rc = walBusyLock(pWal, xBusy, pBusyArg, WAL_WRITE_LOCK, 1);\n    if( rc==SQLITE_OK ){\n      pWal->writeLock = 1;\n    }else if( rc==SQLITE_BUSY ){\n      eMode2 = SQLITE_CHECKPOINT_PASSIVE;\n      xBusy2 = 0;\n      rc = SQLITE_OK;\n    }\n  }\n\n  /* Read the wal-index header. */\n  if( rc==SQLITE_OK ){\n    rc = walIndexReadHdr(pWal, &isChanged);\n    if( isChanged && pWal->pDbFd->pMethods->iVersion>=3 ){\n      sqlite3OsUnfetch(pWal->pDbFd, 0, 0);\n    }\n  }\n\n  /* Copy data from the log to the database file. */\n  if( rc==SQLITE_OK ){\n\n    if( pWal->hdr.mxFrame && walPagesize(pWal)!=nBuf ){\n      rc = SQLITE_CORRUPT_BKPT;\n    }else{\n      rc = walCheckpoint(pWal, db, eMode2, xBusy2, pBusyArg, sync_flags, zBuf);\n    }\n\n    /* If no error occurred, set the output variables. */\n    if( rc==SQLITE_OK || rc==SQLITE_BUSY ){\n      if( pnLog ) *pnLog = (int)pWal->hdr.mxFrame;\n      if( pnCkpt ) *pnCkpt = (int)(walCkptInfo(pWal)->nBackfill);\n    }\n  }\n\n  if( isChanged ){\n    /* If a new wal-index header was loaded before the checkpoint was \n    ** performed, then the pager-cache associated with pWal is now\n    ** out of date. So zero the cached wal-index header to ensure that\n    ** next time the pager opens a snapshot on this database it knows that\n    ** the cache needs to be reset.\n    */\n    memset(&pWal->hdr, 0, sizeof(WalIndexHdr));\n  }\n\n  /* Release the locks. */\n  sqlite3WalEndWriteTransaction(pWal);\n  walUnlockExclusive(pWal, WAL_CKPT_LOCK, 1);\n  pWal->ckptLock = 0;\n  WALTRACE((\"WAL%p: checkpoint %s\\n\", pWal, rc ? \"failed\" : \"ok\"));\n  return (rc==SQLITE_OK && eMode!=eMode2 ? SQLITE_BUSY : rc);\n}\n\n/* Return the value to pass to a sqlite3_wal_hook callback, the\n** number of frames in the WAL at the point of the last commit since\n** sqlite3WalCallback() was called.  If no commits have occurred since\n** the last call, then return 0.\n*/\nSQLITE_PRIVATE int sqlite3WalCallback(Wal *pWal){\n  u32 ret = 0;\n  if( pWal ){\n    ret = pWal->iCallback;\n    pWal->iCallback = 0;\n  }\n  return (int)ret;\n}\n\n/*\n** This function is called to change the WAL subsystem into or out\n** of locking_mode=EXCLUSIVE.\n**\n** If op is zero, then attempt to change from locking_mode=EXCLUSIVE\n** into locking_mode=NORMAL.  This means that we must acquire a lock\n** on the pWal->readLock byte.  If the WAL is already in locking_mode=NORMAL\n** or if the acquisition of the lock fails, then return 0.  If the\n** transition out of exclusive-mode is successful, return 1.  This\n** operation must occur while the pager is still holding the exclusive\n** lock on the main database file.\n**\n** If op is one, then change from locking_mode=NORMAL into \n** locking_mode=EXCLUSIVE.  This means that the pWal->readLock must\n** be released.  Return 1 if the transition is made and 0 if the\n** WAL is already in exclusive-locking mode - meaning that this\n** routine is a no-op.  The pager must already hold the exclusive lock\n** on the main database file before invoking this operation.\n**\n** If op is negative, then do a dry-run of the op==1 case but do\n** not actually change anything. The pager uses this to see if it\n** should acquire the database exclusive lock prior to invoking\n** the op==1 case.\n*/\nSQLITE_PRIVATE int sqlite3WalExclusiveMode(Wal *pWal, int op){\n  int rc;\n  assert( pWal->writeLock==0 );\n  assert( pWal->exclusiveMode!=WAL_HEAPMEMORY_MODE || op==-1 );\n\n  /* pWal->readLock is usually set, but might be -1 if there was a \n  ** prior error while attempting to acquire are read-lock. This cannot \n  ** happen if the connection is actually in exclusive mode (as no xShmLock\n  ** locks are taken in this case). Nor should the pager attempt to\n  ** upgrade to exclusive-mode following such an error.\n  */\n  assert( pWal->readLock>=0 || pWal->lockError );\n  assert( pWal->readLock>=0 || (op<=0 && pWal->exclusiveMode==0) );\n\n  if( op==0 ){\n    if( pWal->exclusiveMode!=WAL_NORMAL_MODE ){\n      pWal->exclusiveMode = WAL_NORMAL_MODE;\n      if( walLockShared(pWal, WAL_READ_LOCK(pWal->readLock))!=SQLITE_OK ){\n        pWal->exclusiveMode = WAL_EXCLUSIVE_MODE;\n      }\n      rc = pWal->exclusiveMode==WAL_NORMAL_MODE;\n    }else{\n      /* Already in locking_mode=NORMAL */\n      rc = 0;\n    }\n  }else if( op>0 ){\n    assert( pWal->exclusiveMode==WAL_NORMAL_MODE );\n    assert( pWal->readLock>=0 );\n    walUnlockShared(pWal, WAL_READ_LOCK(pWal->readLock));\n    pWal->exclusiveMode = WAL_EXCLUSIVE_MODE;\n    rc = 1;\n  }else{\n    rc = pWal->exclusiveMode==WAL_NORMAL_MODE;\n  }\n  return rc;\n}\n\n/* \n** Return true if the argument is non-NULL and the WAL module is using\n** heap-memory for the wal-index. Otherwise, if the argument is NULL or the\n** WAL module is using shared-memory, return false. \n*/\nSQLITE_PRIVATE int sqlite3WalHeapMemory(Wal *pWal){\n  return (pWal && pWal->exclusiveMode==WAL_HEAPMEMORY_MODE );\n}\n\n#ifdef SQLITE_ENABLE_SNAPSHOT\n/* Create a snapshot object.  The content of a snapshot is opaque to\n** every other subsystem, so the WAL module can put whatever it needs\n** in the object.\n*/\nSQLITE_PRIVATE int sqlite3WalSnapshotGet(Wal *pWal, sqlite3_snapshot **ppSnapshot){\n  int rc = SQLITE_OK;\n  WalIndexHdr *pRet;\n  static const u32 aZero[4] = { 0, 0, 0, 0 };\n\n  assert( pWal->readLock>=0 && pWal->writeLock==0 );\n\n  if( memcmp(&pWal->hdr.aFrameCksum[0],aZero,16)==0 ){\n    *ppSnapshot = 0;\n    return SQLITE_ERROR;\n  }\n  pRet = (WalIndexHdr*)sqlite3_malloc(sizeof(WalIndexHdr));\n  if( pRet==0 ){\n    rc = SQLITE_NOMEM_BKPT;\n  }else{\n    memcpy(pRet, &pWal->hdr, sizeof(WalIndexHdr));\n    *ppSnapshot = (sqlite3_snapshot*)pRet;\n  }\n\n  return rc;\n}\n\n/* Try to open on pSnapshot when the next read-transaction starts\n*/\nSQLITE_PRIVATE void sqlite3WalSnapshotOpen(Wal *pWal, sqlite3_snapshot *pSnapshot){\n  pWal->pSnapshot = (WalIndexHdr*)pSnapshot;\n}\n\n/* \n** Return a +ve value if snapshot p1 is newer than p2. A -ve value if\n** p1 is older than p2 and zero if p1 and p2 are the same snapshot.\n*/\nSQLITE_API int sqlite3_snapshot_cmp(sqlite3_snapshot *p1, sqlite3_snapshot *p2){\n  WalIndexHdr *pHdr1 = (WalIndexHdr*)p1;\n  WalIndexHdr *pHdr2 = (WalIndexHdr*)p2;\n\n  /* aSalt[0] is a copy of the value stored in the wal file header. It\n  ** is incremented each time the wal file is restarted.  */\n  if( pHdr1->aSalt[0]<pHdr2->aSalt[0] ) return -1;\n  if( pHdr1->aSalt[0]>pHdr2->aSalt[0] ) return +1;\n  if( pHdr1->mxFrame<pHdr2->mxFrame ) return -1;\n  if( pHdr1->mxFrame>pHdr2->mxFrame ) return +1;\n  return 0;\n}\n\n/*\n** The caller currently has a read transaction open on the database.\n** This function takes a SHARED lock on the CHECKPOINTER slot and then\n** checks if the snapshot passed as the second argument is still \n** available. If so, SQLITE_OK is returned.\n**\n** If the snapshot is not available, SQLITE_ERROR is returned. Or, if\n** the CHECKPOINTER lock cannot be obtained, SQLITE_BUSY. If any error\n** occurs (any value other than SQLITE_OK is returned), the CHECKPOINTER\n** lock is released before returning.\n*/\nSQLITE_PRIVATE int sqlite3WalSnapshotCheck(Wal *pWal, sqlite3_snapshot *pSnapshot){\n  int rc;\n  rc = walLockShared(pWal, WAL_CKPT_LOCK);\n  if( rc==SQLITE_OK ){\n    WalIndexHdr *pNew = (WalIndexHdr*)pSnapshot;\n    if( memcmp(pNew->aSalt, pWal->hdr.aSalt, sizeof(pWal->hdr.aSalt))\n     || pNew->mxFrame<walCkptInfo(pWal)->nBackfillAttempted\n    ){\n      rc = SQLITE_ERROR_SNAPSHOT;\n      walUnlockShared(pWal, WAL_CKPT_LOCK);\n    }\n  }\n  return rc;\n}\n\n/*\n** Release a lock obtained by an earlier successful call to\n** sqlite3WalSnapshotCheck().\n*/\nSQLITE_PRIVATE void sqlite3WalSnapshotUnlock(Wal *pWal){\n  assert( pWal );\n  walUnlockShared(pWal, WAL_CKPT_LOCK);\n}\n\n\n#endif /* SQLITE_ENABLE_SNAPSHOT */\n\n#ifdef SQLITE_ENABLE_ZIPVFS\n/*\n** If the argument is not NULL, it points to a Wal object that holds a\n** read-lock. This function returns the database page-size if it is known,\n** or zero if it is not (or if pWal is NULL).\n*/\nSQLITE_PRIVATE int sqlite3WalFramesize(Wal *pWal){\n  assert( pWal==0 || pWal->readLock>=0 );\n  return (pWal ? pWal->szPage : 0);\n}\n#endif\n\n/* Return the sqlite3_file object for the WAL file\n*/\nSQLITE_PRIVATE sqlite3_file *sqlite3WalFile(Wal *pWal){\n  return pWal->pWalFd;\n}\n\n#endif /* #ifndef SQLITE_OMIT_WAL */\n\n/************** End of wal.c *************************************************/\n/************** Begin file btmutex.c *****************************************/\n/*\n** 2007 August 27\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n**\n** This file contains code used to implement mutexes on Btree objects.\n** This code really belongs in btree.c.  But btree.c is getting too\n** big and we want to break it down some.  This packaged seemed like\n** a good breakout.\n*/\n/* #include \"btreeInt.h\" */\n#ifndef SQLITE_OMIT_SHARED_CACHE\n#if SQLITE_THREADSAFE\n\n/*\n** Obtain the BtShared mutex associated with B-Tree handle p. Also,\n** set BtShared.db to the database handle associated with p and the\n** p->locked boolean to true.\n*/\nstatic void lockBtreeMutex(Btree *p){\n  assert( p->locked==0 );\n  assert( sqlite3_mutex_notheld(p->pBt->mutex) );\n  assert( sqlite3_mutex_held(p->db->mutex) );\n\n  sqlite3_mutex_enter(p->pBt->mutex);\n  p->pBt->db = p->db;\n  p->locked = 1;\n}\n\n/*\n** Release the BtShared mutex associated with B-Tree handle p and\n** clear the p->locked boolean.\n*/\nstatic void SQLITE_NOINLINE unlockBtreeMutex(Btree *p){\n  BtShared *pBt = p->pBt;\n  assert( p->locked==1 );\n  assert( sqlite3_mutex_held(pBt->mutex) );\n  assert( sqlite3_mutex_held(p->db->mutex) );\n  assert( p->db==pBt->db );\n\n  sqlite3_mutex_leave(pBt->mutex);\n  p->locked = 0;\n}\n\n/* Forward reference */\nstatic void SQLITE_NOINLINE btreeLockCarefully(Btree *p);\n\n/*\n** Enter a mutex on the given BTree object.\n**\n** If the object is not sharable, then no mutex is ever required\n** and this routine is a no-op.  The underlying mutex is non-recursive.\n** But we keep a reference count in Btree.wantToLock so the behavior\n** of this interface is recursive.\n**\n** To avoid deadlocks, multiple Btrees are locked in the same order\n** by all database connections.  The p->pNext is a list of other\n** Btrees belonging to the same database connection as the p Btree\n** which need to be locked after p.  If we cannot get a lock on\n** p, then first unlock all of the others on p->pNext, then wait\n** for the lock to become available on p, then relock all of the\n** subsequent Btrees that desire a lock.\n*/\nSQLITE_PRIVATE void sqlite3BtreeEnter(Btree *p){\n  /* Some basic sanity checking on the Btree.  The list of Btrees\n  ** connected by pNext and pPrev should be in sorted order by\n  ** Btree.pBt value. All elements of the list should belong to\n  ** the same connection. Only shared Btrees are on the list. */\n  assert( p->pNext==0 || p->pNext->pBt>p->pBt );\n  assert( p->pPrev==0 || p->pPrev->pBt<p->pBt );\n  assert( p->pNext==0 || p->pNext->db==p->db );\n  assert( p->pPrev==0 || p->pPrev->db==p->db );\n  assert( p->sharable || (p->pNext==0 && p->pPrev==0) );\n\n  /* Check for locking consistency */\n  assert( !p->locked || p->wantToLock>0 );\n  assert( p->sharable || p->wantToLock==0 );\n\n  /* We should already hold a lock on the database connection */\n  assert( sqlite3_mutex_held(p->db->mutex) );\n\n  /* Unless the database is sharable and unlocked, then BtShared.db\n  ** should already be set correctly. */\n  assert( (p->locked==0 && p->sharable) || p->pBt->db==p->db );\n\n  if( !p->sharable ) return;\n  p->wantToLock++;\n  if( p->locked ) return;\n  btreeLockCarefully(p);\n}\n\n/* This is a helper function for sqlite3BtreeLock(). By moving\n** complex, but seldom used logic, out of sqlite3BtreeLock() and\n** into this routine, we avoid unnecessary stack pointer changes\n** and thus help the sqlite3BtreeLock() routine to run much faster\n** in the common case.\n*/\nstatic void SQLITE_NOINLINE btreeLockCarefully(Btree *p){\n  Btree *pLater;\n\n  /* In most cases, we should be able to acquire the lock we\n  ** want without having to go through the ascending lock\n  ** procedure that follows.  Just be sure not to block.\n  */\n  if( sqlite3_mutex_try(p->pBt->mutex)==SQLITE_OK ){\n    p->pBt->db = p->db;\n    p->locked = 1;\n    return;\n  }\n\n  /* To avoid deadlock, first release all locks with a larger\n  ** BtShared address.  Then acquire our lock.  Then reacquire\n  ** the other BtShared locks that we used to hold in ascending\n  ** order.\n  */\n  for(pLater=p->pNext; pLater; pLater=pLater->pNext){\n    assert( pLater->sharable );\n    assert( pLater->pNext==0 || pLater->pNext->pBt>pLater->pBt );\n    assert( !pLater->locked || pLater->wantToLock>0 );\n    if( pLater->locked ){\n      unlockBtreeMutex(pLater);\n    }\n  }\n  lockBtreeMutex(p);\n  for(pLater=p->pNext; pLater; pLater=pLater->pNext){\n    if( pLater->wantToLock ){\n      lockBtreeMutex(pLater);\n    }\n  }\n}\n\n\n/*\n** Exit the recursive mutex on a Btree.\n*/\nSQLITE_PRIVATE void sqlite3BtreeLeave(Btree *p){\n  assert( sqlite3_mutex_held(p->db->mutex) );\n  if( p->sharable ){\n    assert( p->wantToLock>0 );\n    p->wantToLock--;\n    if( p->wantToLock==0 ){\n      unlockBtreeMutex(p);\n    }\n  }\n}\n\n#ifndef NDEBUG\n/*\n** Return true if the BtShared mutex is held on the btree, or if the\n** B-Tree is not marked as sharable.\n**\n** This routine is used only from within assert() statements.\n*/\nSQLITE_PRIVATE int sqlite3BtreeHoldsMutex(Btree *p){\n  assert( p->sharable==0 || p->locked==0 || p->wantToLock>0 );\n  assert( p->sharable==0 || p->locked==0 || p->db==p->pBt->db );\n  assert( p->sharable==0 || p->locked==0 || sqlite3_mutex_held(p->pBt->mutex) );\n  assert( p->sharable==0 || p->locked==0 || sqlite3_mutex_held(p->db->mutex) );\n\n  return (p->sharable==0 || p->locked);\n}\n#endif\n\n\n/*\n** Enter the mutex on every Btree associated with a database\n** connection.  This is needed (for example) prior to parsing\n** a statement since we will be comparing table and column names\n** against all schemas and we do not want those schemas being\n** reset out from under us.\n**\n** There is a corresponding leave-all procedures.\n**\n** Enter the mutexes in accending order by BtShared pointer address\n** to avoid the possibility of deadlock when two threads with\n** two or more btrees in common both try to lock all their btrees\n** at the same instant.\n*/\nstatic void SQLITE_NOINLINE btreeEnterAll(sqlite3 *db){\n  int i;\n  int skipOk = 1;\n  Btree *p;\n  assert( sqlite3_mutex_held(db->mutex) );\n  for(i=0; i<db->nDb; i++){\n    p = db->aDb[i].pBt;\n    if( p && p->sharable ){\n      sqlite3BtreeEnter(p);\n      skipOk = 0;\n    }\n  }\n  db->noSharedCache = skipOk;\n}\nSQLITE_PRIVATE void sqlite3BtreeEnterAll(sqlite3 *db){\n  if( db->noSharedCache==0 ) btreeEnterAll(db);\n}\nstatic void SQLITE_NOINLINE btreeLeaveAll(sqlite3 *db){\n  int i;\n  Btree *p;\n  assert( sqlite3_mutex_held(db->mutex) );\n  for(i=0; i<db->nDb; i++){\n    p = db->aDb[i].pBt;\n    if( p ) sqlite3BtreeLeave(p);\n  }\n}\nSQLITE_PRIVATE void sqlite3BtreeLeaveAll(sqlite3 *db){\n  if( db->noSharedCache==0 ) btreeLeaveAll(db);\n}\n\n#ifndef NDEBUG\n/*\n** Return true if the current thread holds the database connection\n** mutex and all required BtShared mutexes.\n**\n** This routine is used inside assert() statements only.\n*/\nSQLITE_PRIVATE int sqlite3BtreeHoldsAllMutexes(sqlite3 *db){\n  int i;\n  if( !sqlite3_mutex_held(db->mutex) ){\n    return 0;\n  }\n  for(i=0; i<db->nDb; i++){\n    Btree *p;\n    p = db->aDb[i].pBt;\n    if( p && p->sharable &&\n         (p->wantToLock==0 || !sqlite3_mutex_held(p->pBt->mutex)) ){\n      return 0;\n    }\n  }\n  return 1;\n}\n#endif /* NDEBUG */\n\n#ifndef NDEBUG\n/*\n** Return true if the correct mutexes are held for accessing the\n** db->aDb[iDb].pSchema structure.  The mutexes required for schema\n** access are:\n**\n**   (1) The mutex on db\n**   (2) if iDb!=1, then the mutex on db->aDb[iDb].pBt.\n**\n** If pSchema is not NULL, then iDb is computed from pSchema and\n** db using sqlite3SchemaToIndex().\n*/\nSQLITE_PRIVATE int sqlite3SchemaMutexHeld(sqlite3 *db, int iDb, Schema *pSchema){\n  Btree *p;\n  assert( db!=0 );\n  if( pSchema ) iDb = sqlite3SchemaToIndex(db, pSchema);\n  assert( iDb>=0 && iDb<db->nDb );\n  if( !sqlite3_mutex_held(db->mutex) ) return 0;\n  if( iDb==1 ) return 1;\n  p = db->aDb[iDb].pBt;\n  assert( p!=0 );\n  return p->sharable==0 || p->locked==1;\n}\n#endif /* NDEBUG */\n\n#else /* SQLITE_THREADSAFE>0 above.  SQLITE_THREADSAFE==0 below */\n/*\n** The following are special cases for mutex enter routines for use\n** in single threaded applications that use shared cache.  Except for\n** these two routines, all mutex operations are no-ops in that case and\n** are null #defines in btree.h.\n**\n** If shared cache is disabled, then all btree mutex routines, including\n** the ones below, are no-ops and are null #defines in btree.h.\n*/\n\nSQLITE_PRIVATE void sqlite3BtreeEnter(Btree *p){\n  p->pBt->db = p->db;\n}\nSQLITE_PRIVATE void sqlite3BtreeEnterAll(sqlite3 *db){\n  int i;\n  for(i=0; i<db->nDb; i++){\n    Btree *p = db->aDb[i].pBt;\n    if( p ){\n      p->pBt->db = p->db;\n    }\n  }\n}\n#endif /* if SQLITE_THREADSAFE */\n\n#ifndef SQLITE_OMIT_INCRBLOB\n/*\n** Enter a mutex on a Btree given a cursor owned by that Btree. \n**\n** These entry points are used by incremental I/O only. Enter() is required \n** any time OMIT_SHARED_CACHE is not defined, regardless of whether or not \n** the build is threadsafe. Leave() is only required by threadsafe builds.\n*/\nSQLITE_PRIVATE void sqlite3BtreeEnterCursor(BtCursor *pCur){\n  sqlite3BtreeEnter(pCur->pBtree);\n}\n# if SQLITE_THREADSAFE\nSQLITE_PRIVATE void sqlite3BtreeLeaveCursor(BtCursor *pCur){\n  sqlite3BtreeLeave(pCur->pBtree);\n}\n# endif\n#endif /* ifndef SQLITE_OMIT_INCRBLOB */\n\n#endif /* ifndef SQLITE_OMIT_SHARED_CACHE */\n\n/************** End of btmutex.c *********************************************/\n/************** Begin file btree.c *******************************************/\n/*\n** 2004 April 6\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This file implements an external (disk-based) database using BTrees.\n** See the header comment on \"btreeInt.h\" for additional information.\n** Including a description of file format and an overview of operation.\n*/\n/* #include \"btreeInt.h\" */\n\n/*\n** The header string that appears at the beginning of every\n** SQLite database.\n*/\nstatic const char zMagicHeader[] = SQLITE_FILE_HEADER;\n\n/*\n** Set this global variable to 1 to enable tracing using the TRACE\n** macro.\n*/\n#if 0\nint sqlite3BtreeTrace=1;  /* True to enable tracing */\n# define TRACE(X)  if(sqlite3BtreeTrace){printf X;fflush(stdout);}\n#else\n# define TRACE(X)\n#endif\n\n/*\n** Extract a 2-byte big-endian integer from an array of unsigned bytes.\n** But if the value is zero, make it 65536.\n**\n** This routine is used to extract the \"offset to cell content area\" value\n** from the header of a btree page.  If the page size is 65536 and the page\n** is empty, the offset should be 65536, but the 2-byte value stores zero.\n** This routine makes the necessary adjustment to 65536.\n*/\n#define get2byteNotZero(X)  (((((int)get2byte(X))-1)&0xffff)+1)\n\n/*\n** Values passed as the 5th argument to allocateBtreePage()\n*/\n#define BTALLOC_ANY   0           /* Allocate any page */\n#define BTALLOC_EXACT 1           /* Allocate exact page if possible */\n#define BTALLOC_LE    2           /* Allocate any page <= the parameter */\n\n/*\n** Macro IfNotOmitAV(x) returns (x) if SQLITE_OMIT_AUTOVACUUM is not \n** defined, or 0 if it is. For example:\n**\n**   bIncrVacuum = IfNotOmitAV(pBtShared->incrVacuum);\n*/\n#ifndef SQLITE_OMIT_AUTOVACUUM\n#define IfNotOmitAV(expr) (expr)\n#else\n#define IfNotOmitAV(expr) 0\n#endif\n\n#ifndef SQLITE_OMIT_SHARED_CACHE\n/*\n** A list of BtShared objects that are eligible for participation\n** in shared cache.  This variable has file scope during normal builds,\n** but the test harness needs to access it so we make it global for \n** test builds.\n**\n** Access to this variable is protected by SQLITE_MUTEX_STATIC_MASTER.\n*/\n#ifdef SQLITE_TEST\nSQLITE_PRIVATE BtShared *SQLITE_WSD sqlite3SharedCacheList = 0;\n#else\nstatic BtShared *SQLITE_WSD sqlite3SharedCacheList = 0;\n#endif\n#endif /* SQLITE_OMIT_SHARED_CACHE */\n\n#ifndef SQLITE_OMIT_SHARED_CACHE\n/*\n** Enable or disable the shared pager and schema features.\n**\n** This routine has no effect on existing database connections.\n** The shared cache setting effects only future calls to\n** sqlite3_open(), sqlite3_open16(), or sqlite3_open_v2().\n*/\nSQLITE_API int sqlite3_enable_shared_cache(int enable){\n  sqlite3GlobalConfig.sharedCacheEnabled = enable;\n  return SQLITE_OK;\n}\n#endif\n\n\n\n#ifdef SQLITE_OMIT_SHARED_CACHE\n  /*\n  ** The functions querySharedCacheTableLock(), setSharedCacheTableLock(),\n  ** and clearAllSharedCacheTableLocks()\n  ** manipulate entries in the BtShared.pLock linked list used to store\n  ** shared-cache table level locks. If the library is compiled with the\n  ** shared-cache feature disabled, then there is only ever one user\n  ** of each BtShared structure and so this locking is not necessary. \n  ** So define the lock related functions as no-ops.\n  */\n  #define querySharedCacheTableLock(a,b,c) SQLITE_OK\n  #define setSharedCacheTableLock(a,b,c) SQLITE_OK\n  #define clearAllSharedCacheTableLocks(a)\n  #define downgradeAllSharedCacheTableLocks(a)\n  #define hasSharedCacheTableLock(a,b,c,d) 1\n  #define hasReadConflicts(a, b) 0\n#endif\n\n/*\n** Implementation of the SQLITE_CORRUPT_PAGE() macro. Takes a single\n** (MemPage*) as an argument. The (MemPage*) must not be NULL.\n**\n** If SQLITE_DEBUG is not defined, then this macro is equivalent to\n** SQLITE_CORRUPT_BKPT. Or, if SQLITE_DEBUG is set, then the log message\n** normally produced as a side-effect of SQLITE_CORRUPT_BKPT is augmented\n** with the page number and filename associated with the (MemPage*).\n*/\n#ifdef SQLITE_DEBUG\nint corruptPageError(int lineno, MemPage *p){\n  char *zMsg;\n  sqlite3BeginBenignMalloc();\n  zMsg = sqlite3_mprintf(\"database corruption page %d of %s\",\n      (int)p->pgno, sqlite3PagerFilename(p->pBt->pPager, 0)\n  );\n  sqlite3EndBenignMalloc();\n  if( zMsg ){\n    sqlite3ReportError(SQLITE_CORRUPT, lineno, zMsg);\n  }\n  sqlite3_free(zMsg);\n  return SQLITE_CORRUPT_BKPT;\n}\n# define SQLITE_CORRUPT_PAGE(pMemPage) corruptPageError(__LINE__, pMemPage)\n#else\n# define SQLITE_CORRUPT_PAGE(pMemPage) SQLITE_CORRUPT_PGNO(pMemPage->pgno)\n#endif\n\n#ifndef SQLITE_OMIT_SHARED_CACHE\n\n#ifdef SQLITE_DEBUG\n/*\n**** This function is only used as part of an assert() statement. ***\n**\n** Check to see if pBtree holds the required locks to read or write to the \n** table with root page iRoot.   Return 1 if it does and 0 if not.\n**\n** For example, when writing to a table with root-page iRoot via \n** Btree connection pBtree:\n**\n**    assert( hasSharedCacheTableLock(pBtree, iRoot, 0, WRITE_LOCK) );\n**\n** When writing to an index that resides in a sharable database, the \n** caller should have first obtained a lock specifying the root page of\n** the corresponding table. This makes things a bit more complicated,\n** as this module treats each table as a separate structure. To determine\n** the table corresponding to the index being written, this\n** function has to search through the database schema.\n**\n** Instead of a lock on the table/index rooted at page iRoot, the caller may\n** hold a write-lock on the schema table (root page 1). This is also\n** acceptable.\n*/\nstatic int hasSharedCacheTableLock(\n  Btree *pBtree,         /* Handle that must hold lock */\n  Pgno iRoot,            /* Root page of b-tree */\n  int isIndex,           /* True if iRoot is the root of an index b-tree */\n  int eLockType          /* Required lock type (READ_LOCK or WRITE_LOCK) */\n){\n  Schema *pSchema = (Schema *)pBtree->pBt->pSchema;\n  Pgno iTab = 0;\n  BtLock *pLock;\n\n  /* If this database is not shareable, or if the client is reading\n  ** and has the read-uncommitted flag set, then no lock is required. \n  ** Return true immediately.\n  */\n  if( (pBtree->sharable==0)\n   || (eLockType==READ_LOCK && (pBtree->db->flags & SQLITE_ReadUncommit))\n  ){\n    return 1;\n  }\n\n  /* If the client is reading  or writing an index and the schema is\n  ** not loaded, then it is too difficult to actually check to see if\n  ** the correct locks are held.  So do not bother - just return true.\n  ** This case does not come up very often anyhow.\n  */\n  if( isIndex && (!pSchema || (pSchema->schemaFlags&DB_SchemaLoaded)==0) ){\n    return 1;\n  }\n\n  /* Figure out the root-page that the lock should be held on. For table\n  ** b-trees, this is just the root page of the b-tree being read or\n  ** written. For index b-trees, it is the root page of the associated\n  ** table.  */\n  if( isIndex ){\n    HashElem *p;\n    for(p=sqliteHashFirst(&pSchema->idxHash); p; p=sqliteHashNext(p)){\n      Index *pIdx = (Index *)sqliteHashData(p);\n      if( pIdx->tnum==(int)iRoot ){\n        if( iTab ){\n          /* Two or more indexes share the same root page.  There must\n          ** be imposter tables.  So just return true.  The assert is not\n          ** useful in that case. */\n          return 1;\n        }\n        iTab = pIdx->pTable->tnum;\n      }\n    }\n  }else{\n    iTab = iRoot;\n  }\n\n  /* Search for the required lock. Either a write-lock on root-page iTab, a \n  ** write-lock on the schema table, or (if the client is reading) a\n  ** read-lock on iTab will suffice. Return 1 if any of these are found.  */\n  for(pLock=pBtree->pBt->pLock; pLock; pLock=pLock->pNext){\n    if( pLock->pBtree==pBtree \n     && (pLock->iTable==iTab || (pLock->eLock==WRITE_LOCK && pLock->iTable==1))\n     && pLock->eLock>=eLockType \n    ){\n      return 1;\n    }\n  }\n\n  /* Failed to find the required lock. */\n  return 0;\n}\n#endif /* SQLITE_DEBUG */\n\n#ifdef SQLITE_DEBUG\n/*\n**** This function may be used as part of assert() statements only. ****\n**\n** Return true if it would be illegal for pBtree to write into the\n** table or index rooted at iRoot because other shared connections are\n** simultaneously reading that same table or index.\n**\n** It is illegal for pBtree to write if some other Btree object that\n** shares the same BtShared object is currently reading or writing\n** the iRoot table.  Except, if the other Btree object has the\n** read-uncommitted flag set, then it is OK for the other object to\n** have a read cursor.\n**\n** For example, before writing to any part of the table or index\n** rooted at page iRoot, one should call:\n**\n**    assert( !hasReadConflicts(pBtree, iRoot) );\n*/\nstatic int hasReadConflicts(Btree *pBtree, Pgno iRoot){\n  BtCursor *p;\n  for(p=pBtree->pBt->pCursor; p; p=p->pNext){\n    if( p->pgnoRoot==iRoot \n     && p->pBtree!=pBtree\n     && 0==(p->pBtree->db->flags & SQLITE_ReadUncommit)\n    ){\n      return 1;\n    }\n  }\n  return 0;\n}\n#endif    /* #ifdef SQLITE_DEBUG */\n\n/*\n** Query to see if Btree handle p may obtain a lock of type eLock \n** (READ_LOCK or WRITE_LOCK) on the table with root-page iTab. Return\n** SQLITE_OK if the lock may be obtained (by calling\n** setSharedCacheTableLock()), or SQLITE_LOCKED if not.\n*/\nstatic int querySharedCacheTableLock(Btree *p, Pgno iTab, u8 eLock){\n  BtShared *pBt = p->pBt;\n  BtLock *pIter;\n\n  assert( sqlite3BtreeHoldsMutex(p) );\n  assert( eLock==READ_LOCK || eLock==WRITE_LOCK );\n  assert( p->db!=0 );\n  assert( !(p->db->flags&SQLITE_ReadUncommit)||eLock==WRITE_LOCK||iTab==1 );\n  \n  /* If requesting a write-lock, then the Btree must have an open write\n  ** transaction on this file. And, obviously, for this to be so there \n  ** must be an open write transaction on the file itself.\n  */\n  assert( eLock==READ_LOCK || (p==pBt->pWriter && p->inTrans==TRANS_WRITE) );\n  assert( eLock==READ_LOCK || pBt->inTransaction==TRANS_WRITE );\n  \n  /* This routine is a no-op if the shared-cache is not enabled */\n  if( !p->sharable ){\n    return SQLITE_OK;\n  }\n\n  /* If some other connection is holding an exclusive lock, the\n  ** requested lock may not be obtained.\n  */\n  if( pBt->pWriter!=p && (pBt->btsFlags & BTS_EXCLUSIVE)!=0 ){\n    sqlite3ConnectionBlocked(p->db, pBt->pWriter->db);\n    return SQLITE_LOCKED_SHAREDCACHE;\n  }\n\n  for(pIter=pBt->pLock; pIter; pIter=pIter->pNext){\n    /* The condition (pIter->eLock!=eLock) in the following if(...) \n    ** statement is a simplification of:\n    **\n    **   (eLock==WRITE_LOCK || pIter->eLock==WRITE_LOCK)\n    **\n    ** since we know that if eLock==WRITE_LOCK, then no other connection\n    ** may hold a WRITE_LOCK on any table in this file (since there can\n    ** only be a single writer).\n    */\n    assert( pIter->eLock==READ_LOCK || pIter->eLock==WRITE_LOCK );\n    assert( eLock==READ_LOCK || pIter->pBtree==p || pIter->eLock==READ_LOCK);\n    if( pIter->pBtree!=p && pIter->iTable==iTab && pIter->eLock!=eLock ){\n      sqlite3ConnectionBlocked(p->db, pIter->pBtree->db);\n      if( eLock==WRITE_LOCK ){\n        assert( p==pBt->pWriter );\n        pBt->btsFlags |= BTS_PENDING;\n      }\n      return SQLITE_LOCKED_SHAREDCACHE;\n    }\n  }\n  return SQLITE_OK;\n}\n#endif /* !SQLITE_OMIT_SHARED_CACHE */\n\n#ifndef SQLITE_OMIT_SHARED_CACHE\n/*\n** Add a lock on the table with root-page iTable to the shared-btree used\n** by Btree handle p. Parameter eLock must be either READ_LOCK or \n** WRITE_LOCK.\n**\n** This function assumes the following:\n**\n**   (a) The specified Btree object p is connected to a sharable\n**       database (one with the BtShared.sharable flag set), and\n**\n**   (b) No other Btree objects hold a lock that conflicts\n**       with the requested lock (i.e. querySharedCacheTableLock() has\n**       already been called and returned SQLITE_OK).\n**\n** SQLITE_OK is returned if the lock is added successfully. SQLITE_NOMEM \n** is returned if a malloc attempt fails.\n*/\nstatic int setSharedCacheTableLock(Btree *p, Pgno iTable, u8 eLock){\n  BtShared *pBt = p->pBt;\n  BtLock *pLock = 0;\n  BtLock *pIter;\n\n  assert( sqlite3BtreeHoldsMutex(p) );\n  assert( eLock==READ_LOCK || eLock==WRITE_LOCK );\n  assert( p->db!=0 );\n\n  /* A connection with the read-uncommitted flag set will never try to\n  ** obtain a read-lock using this function. The only read-lock obtained\n  ** by a connection in read-uncommitted mode is on the sqlite_master \n  ** table, and that lock is obtained in BtreeBeginTrans().  */\n  assert( 0==(p->db->flags&SQLITE_ReadUncommit) || eLock==WRITE_LOCK );\n\n  /* This function should only be called on a sharable b-tree after it \n  ** has been determined that no other b-tree holds a conflicting lock.  */\n  assert( p->sharable );\n  assert( SQLITE_OK==querySharedCacheTableLock(p, iTable, eLock) );\n\n  /* First search the list for an existing lock on this table. */\n  for(pIter=pBt->pLock; pIter; pIter=pIter->pNext){\n    if( pIter->iTable==iTable && pIter->pBtree==p ){\n      pLock = pIter;\n      break;\n    }\n  }\n\n  /* If the above search did not find a BtLock struct associating Btree p\n  ** with table iTable, allocate one and link it into the list.\n  */\n  if( !pLock ){\n    pLock = (BtLock *)sqlite3MallocZero(sizeof(BtLock));\n    if( !pLock ){\n      return SQLITE_NOMEM_BKPT;\n    }\n    pLock->iTable = iTable;\n    pLock->pBtree = p;\n    pLock->pNext = pBt->pLock;\n    pBt->pLock = pLock;\n  }\n\n  /* Set the BtLock.eLock variable to the maximum of the current lock\n  ** and the requested lock. This means if a write-lock was already held\n  ** and a read-lock requested, we don't incorrectly downgrade the lock.\n  */\n  assert( WRITE_LOCK>READ_LOCK );\n  if( eLock>pLock->eLock ){\n    pLock->eLock = eLock;\n  }\n\n  return SQLITE_OK;\n}\n#endif /* !SQLITE_OMIT_SHARED_CACHE */\n\n#ifndef SQLITE_OMIT_SHARED_CACHE\n/*\n** Release all the table locks (locks obtained via calls to\n** the setSharedCacheTableLock() procedure) held by Btree object p.\n**\n** This function assumes that Btree p has an open read or write \n** transaction. If it does not, then the BTS_PENDING flag\n** may be incorrectly cleared.\n*/\nstatic void clearAllSharedCacheTableLocks(Btree *p){\n  BtShared *pBt = p->pBt;\n  BtLock **ppIter = &pBt->pLock;\n\n  assert( sqlite3BtreeHoldsMutex(p) );\n  assert( p->sharable || 0==*ppIter );\n  assert( p->inTrans>0 );\n\n  while( *ppIter ){\n    BtLock *pLock = *ppIter;\n    assert( (pBt->btsFlags & BTS_EXCLUSIVE)==0 || pBt->pWriter==pLock->pBtree );\n    assert( pLock->pBtree->inTrans>=pLock->eLock );\n    if( pLock->pBtree==p ){\n      *ppIter = pLock->pNext;\n      assert( pLock->iTable!=1 || pLock==&p->lock );\n      if( pLock->iTable!=1 ){\n        sqlite3_free(pLock);\n      }\n    }else{\n      ppIter = &pLock->pNext;\n    }\n  }\n\n  assert( (pBt->btsFlags & BTS_PENDING)==0 || pBt->pWriter );\n  if( pBt->pWriter==p ){\n    pBt->pWriter = 0;\n    pBt->btsFlags &= ~(BTS_EXCLUSIVE|BTS_PENDING);\n  }else if( pBt->nTransaction==2 ){\n    /* This function is called when Btree p is concluding its \n    ** transaction. If there currently exists a writer, and p is not\n    ** that writer, then the number of locks held by connections other\n    ** than the writer must be about to drop to zero. In this case\n    ** set the BTS_PENDING flag to 0.\n    **\n    ** If there is not currently a writer, then BTS_PENDING must\n    ** be zero already. So this next line is harmless in that case.\n    */\n    pBt->btsFlags &= ~BTS_PENDING;\n  }\n}\n\n/*\n** This function changes all write-locks held by Btree p into read-locks.\n*/\nstatic void downgradeAllSharedCacheTableLocks(Btree *p){\n  BtShared *pBt = p->pBt;\n  if( pBt->pWriter==p ){\n    BtLock *pLock;\n    pBt->pWriter = 0;\n    pBt->btsFlags &= ~(BTS_EXCLUSIVE|BTS_PENDING);\n    for(pLock=pBt->pLock; pLock; pLock=pLock->pNext){\n      assert( pLock->eLock==READ_LOCK || pLock->pBtree==p );\n      pLock->eLock = READ_LOCK;\n    }\n  }\n}\n\n#endif /* SQLITE_OMIT_SHARED_CACHE */\n\nstatic void releasePage(MemPage *pPage);         /* Forward reference */\nstatic void releasePageOne(MemPage *pPage);      /* Forward reference */\nstatic void releasePageNotNull(MemPage *pPage);  /* Forward reference */\n\n/*\n***** This routine is used inside of assert() only ****\n**\n** Verify that the cursor holds the mutex on its BtShared\n*/\n#ifdef SQLITE_DEBUG\nstatic int cursorHoldsMutex(BtCursor *p){\n  return sqlite3_mutex_held(p->pBt->mutex);\n}\n\n/* Verify that the cursor and the BtShared agree about what is the current\n** database connetion. This is important in shared-cache mode. If the database \n** connection pointers get out-of-sync, it is possible for routines like\n** btreeInitPage() to reference an stale connection pointer that references a\n** a connection that has already closed.  This routine is used inside assert()\n** statements only and for the purpose of double-checking that the btree code\n** does keep the database connection pointers up-to-date.\n*/\nstatic int cursorOwnsBtShared(BtCursor *p){\n  assert( cursorHoldsMutex(p) );\n  return (p->pBtree->db==p->pBt->db);\n}\n#endif\n\n/*\n** Invalidate the overflow cache of the cursor passed as the first argument.\n** on the shared btree structure pBt.\n*/\n#define invalidateOverflowCache(pCur) (pCur->curFlags &= ~BTCF_ValidOvfl)\n\n/*\n** Invalidate the overflow page-list cache for all cursors opened\n** on the shared btree structure pBt.\n*/\nstatic void invalidateAllOverflowCache(BtShared *pBt){\n  BtCursor *p;\n  assert( sqlite3_mutex_held(pBt->mutex) );\n  for(p=pBt->pCursor; p; p=p->pNext){\n    invalidateOverflowCache(p);\n  }\n}\n\n#ifndef SQLITE_OMIT_INCRBLOB\n/*\n** This function is called before modifying the contents of a table\n** to invalidate any incrblob cursors that are open on the\n** row or one of the rows being modified.\n**\n** If argument isClearTable is true, then the entire contents of the\n** table is about to be deleted. In this case invalidate all incrblob\n** cursors open on any row within the table with root-page pgnoRoot.\n**\n** Otherwise, if argument isClearTable is false, then the row with\n** rowid iRow is being replaced or deleted. In this case invalidate\n** only those incrblob cursors open on that specific row.\n*/\nstatic void invalidateIncrblobCursors(\n  Btree *pBtree,          /* The database file to check */\n  Pgno pgnoRoot,          /* The table that might be changing */\n  i64 iRow,               /* The rowid that might be changing */\n  int isClearTable        /* True if all rows are being deleted */\n){\n  BtCursor *p;\n  if( pBtree->hasIncrblobCur==0 ) return;\n  assert( sqlite3BtreeHoldsMutex(pBtree) );\n  pBtree->hasIncrblobCur = 0;\n  for(p=pBtree->pBt->pCursor; p; p=p->pNext){\n    if( (p->curFlags & BTCF_Incrblob)!=0 ){\n      pBtree->hasIncrblobCur = 1;\n      if( p->pgnoRoot==pgnoRoot && (isClearTable || p->info.nKey==iRow) ){\n        p->eState = CURSOR_INVALID;\n      }\n    }\n  }\n}\n\n#else\n  /* Stub function when INCRBLOB is omitted */\n  #define invalidateIncrblobCursors(w,x,y,z)\n#endif /* SQLITE_OMIT_INCRBLOB */\n\n/*\n** Set bit pgno of the BtShared.pHasContent bitvec. This is called \n** when a page that previously contained data becomes a free-list leaf \n** page.\n**\n** The BtShared.pHasContent bitvec exists to work around an obscure\n** bug caused by the interaction of two useful IO optimizations surrounding\n** free-list leaf pages:\n**\n**   1) When all data is deleted from a page and the page becomes\n**      a free-list leaf page, the page is not written to the database\n**      (as free-list leaf pages contain no meaningful data). Sometimes\n**      such a page is not even journalled (as it will not be modified,\n**      why bother journalling it?).\n**\n**   2) When a free-list leaf page is reused, its content is not read\n**      from the database or written to the journal file (why should it\n**      be, if it is not at all meaningful?).\n**\n** By themselves, these optimizations work fine and provide a handy\n** performance boost to bulk delete or insert operations. However, if\n** a page is moved to the free-list and then reused within the same\n** transaction, a problem comes up. If the page is not journalled when\n** it is moved to the free-list and it is also not journalled when it\n** is extracted from the free-list and reused, then the original data\n** may be lost. In the event of a rollback, it may not be possible\n** to restore the database to its original configuration.\n**\n** The solution is the BtShared.pHasContent bitvec. Whenever a page is \n** moved to become a free-list leaf page, the corresponding bit is\n** set in the bitvec. Whenever a leaf page is extracted from the free-list,\n** optimization 2 above is omitted if the corresponding bit is already\n** set in BtShared.pHasContent. The contents of the bitvec are cleared\n** at the end of every transaction.\n*/\nstatic int btreeSetHasContent(BtShared *pBt, Pgno pgno){\n  int rc = SQLITE_OK;\n  if( !pBt->pHasContent ){\n    assert( pgno<=pBt->nPage );\n    pBt->pHasContent = sqlite3BitvecCreate(pBt->nPage);\n    if( !pBt->pHasContent ){\n      rc = SQLITE_NOMEM_BKPT;\n    }\n  }\n  if( rc==SQLITE_OK && pgno<=sqlite3BitvecSize(pBt->pHasContent) ){\n    rc = sqlite3BitvecSet(pBt->pHasContent, pgno);\n  }\n  return rc;\n}\n\n/*\n** Query the BtShared.pHasContent vector.\n**\n** This function is called when a free-list leaf page is removed from the\n** free-list for reuse. It returns false if it is safe to retrieve the\n** page from the pager layer with the 'no-content' flag set. True otherwise.\n*/\nstatic int btreeGetHasContent(BtShared *pBt, Pgno pgno){\n  Bitvec *p = pBt->pHasContent;\n  return (p && (pgno>sqlite3BitvecSize(p) || sqlite3BitvecTest(p, pgno)));\n}\n\n/*\n** Clear (destroy) the BtShared.pHasContent bitvec. This should be\n** invoked at the conclusion of each write-transaction.\n*/\nstatic void btreeClearHasContent(BtShared *pBt){\n  sqlite3BitvecDestroy(pBt->pHasContent);\n  pBt->pHasContent = 0;\n}\n\n/*\n** Release all of the apPage[] pages for a cursor.\n*/\nstatic void btreeReleaseAllCursorPages(BtCursor *pCur){\n  int i;\n  if( pCur->iPage>=0 ){\n    for(i=0; i<pCur->iPage; i++){\n      releasePageNotNull(pCur->apPage[i]);\n    }\n    releasePageNotNull(pCur->pPage);\n    pCur->iPage = -1;\n  }\n}\n\n/*\n** The cursor passed as the only argument must point to a valid entry\n** when this function is called (i.e. have eState==CURSOR_VALID). This\n** function saves the current cursor key in variables pCur->nKey and\n** pCur->pKey. SQLITE_OK is returned if successful or an SQLite error \n** code otherwise.\n**\n** If the cursor is open on an intkey table, then the integer key\n** (the rowid) is stored in pCur->nKey and pCur->pKey is left set to\n** NULL. If the cursor is open on a non-intkey table, then pCur->pKey is \n** set to point to a malloced buffer pCur->nKey bytes in size containing \n** the key.\n*/\nstatic int saveCursorKey(BtCursor *pCur){\n  int rc = SQLITE_OK;\n  assert( CURSOR_VALID==pCur->eState );\n  assert( 0==pCur->pKey );\n  assert( cursorHoldsMutex(pCur) );\n\n  if( pCur->curIntKey ){\n    /* Only the rowid is required for a table btree */\n    pCur->nKey = sqlite3BtreeIntegerKey(pCur);\n  }else{\n    /* For an index btree, save the complete key content. It is possible\n    ** that the current key is corrupt. In that case, it is possible that\n    ** the sqlite3VdbeRecordUnpack() function may overread the buffer by\n    ** up to the size of 1 varint plus 1 8-byte value when the cursor \n    ** position is restored. Hence the 17 bytes of padding allocated \n    ** below. */\n    void *pKey;\n    pCur->nKey = sqlite3BtreePayloadSize(pCur);\n    pKey = sqlite3Malloc( pCur->nKey + 9 + 8 );\n    if( pKey ){\n      rc = sqlite3BtreePayload(pCur, 0, (int)pCur->nKey, pKey);\n      if( rc==SQLITE_OK ){\n        memset(((u8*)pKey)+pCur->nKey, 0, 9+8);\n        pCur->pKey = pKey;\n      }else{\n        sqlite3_free(pKey);\n      }\n    }else{\n      rc = SQLITE_NOMEM_BKPT;\n    }\n  }\n  assert( !pCur->curIntKey || !pCur->pKey );\n  return rc;\n}\n\n/*\n** Save the current cursor position in the variables BtCursor.nKey \n** and BtCursor.pKey. The cursor's state is set to CURSOR_REQUIRESEEK.\n**\n** The caller must ensure that the cursor is valid (has eState==CURSOR_VALID)\n** prior to calling this routine.  \n*/\nstatic int saveCursorPosition(BtCursor *pCur){\n  int rc;\n\n  assert( CURSOR_VALID==pCur->eState || CURSOR_SKIPNEXT==pCur->eState );\n  assert( 0==pCur->pKey );\n  assert( cursorHoldsMutex(pCur) );\n\n  if( pCur->eState==CURSOR_SKIPNEXT ){\n    pCur->eState = CURSOR_VALID;\n  }else{\n    pCur->skipNext = 0;\n  }\n\n  rc = saveCursorKey(pCur);\n  if( rc==SQLITE_OK ){\n    btreeReleaseAllCursorPages(pCur);\n    pCur->eState = CURSOR_REQUIRESEEK;\n  }\n\n  pCur->curFlags &= ~(BTCF_ValidNKey|BTCF_ValidOvfl|BTCF_AtLast);\n  return rc;\n}\n\n/* Forward reference */\nstatic int SQLITE_NOINLINE saveCursorsOnList(BtCursor*,Pgno,BtCursor*);\n\n/*\n** Save the positions of all cursors (except pExcept) that are open on\n** the table with root-page iRoot.  \"Saving the cursor position\" means that\n** the location in the btree is remembered in such a way that it can be\n** moved back to the same spot after the btree has been modified.  This\n** routine is called just before cursor pExcept is used to modify the\n** table, for example in BtreeDelete() or BtreeInsert().\n**\n** If there are two or more cursors on the same btree, then all such \n** cursors should have their BTCF_Multiple flag set.  The btreeCursor()\n** routine enforces that rule.  This routine only needs to be called in\n** the uncommon case when pExpect has the BTCF_Multiple flag set.\n**\n** If pExpect!=NULL and if no other cursors are found on the same root-page,\n** then the BTCF_Multiple flag on pExpect is cleared, to avoid another\n** pointless call to this routine.\n**\n** Implementation note:  This routine merely checks to see if any cursors\n** need to be saved.  It calls out to saveCursorsOnList() in the (unusual)\n** event that cursors are in need to being saved.\n*/\nstatic int saveAllCursors(BtShared *pBt, Pgno iRoot, BtCursor *pExcept){\n  BtCursor *p;\n  assert( sqlite3_mutex_held(pBt->mutex) );\n  assert( pExcept==0 || pExcept->pBt==pBt );\n  for(p=pBt->pCursor; p; p=p->pNext){\n    if( p!=pExcept && (0==iRoot || p->pgnoRoot==iRoot) ) break;\n  }\n  if( p ) return saveCursorsOnList(p, iRoot, pExcept);\n  if( pExcept ) pExcept->curFlags &= ~BTCF_Multiple;\n  return SQLITE_OK;\n}\n\n/* This helper routine to saveAllCursors does the actual work of saving\n** the cursors if and when a cursor is found that actually requires saving.\n** The common case is that no cursors need to be saved, so this routine is\n** broken out from its caller to avoid unnecessary stack pointer movement.\n*/\nstatic int SQLITE_NOINLINE saveCursorsOnList(\n  BtCursor *p,         /* The first cursor that needs saving */\n  Pgno iRoot,          /* Only save cursor with this iRoot. Save all if zero */\n  BtCursor *pExcept    /* Do not save this cursor */\n){\n  do{\n    if( p!=pExcept && (0==iRoot || p->pgnoRoot==iRoot) ){\n      if( p->eState==CURSOR_VALID || p->eState==CURSOR_SKIPNEXT ){\n        int rc = saveCursorPosition(p);\n        if( SQLITE_OK!=rc ){\n          return rc;\n        }\n      }else{\n        testcase( p->iPage>=0 );\n        btreeReleaseAllCursorPages(p);\n      }\n    }\n    p = p->pNext;\n  }while( p );\n  return SQLITE_OK;\n}\n\n/*\n** Clear the current cursor position.\n*/\nSQLITE_PRIVATE void sqlite3BtreeClearCursor(BtCursor *pCur){\n  assert( cursorHoldsMutex(pCur) );\n  sqlite3_free(pCur->pKey);\n  pCur->pKey = 0;\n  pCur->eState = CURSOR_INVALID;\n}\n\n/*\n** In this version of BtreeMoveto, pKey is a packed index record\n** such as is generated by the OP_MakeRecord opcode.  Unpack the\n** record and then call BtreeMovetoUnpacked() to do the work.\n*/\nstatic int btreeMoveto(\n  BtCursor *pCur,     /* Cursor open on the btree to be searched */\n  const void *pKey,   /* Packed key if the btree is an index */\n  i64 nKey,           /* Integer key for tables.  Size of pKey for indices */\n  int bias,           /* Bias search to the high end */\n  int *pRes           /* Write search results here */\n){\n  int rc;                    /* Status code */\n  UnpackedRecord *pIdxKey;   /* Unpacked index key */\n\n  if( pKey ){\n    KeyInfo *pKeyInfo = pCur->pKeyInfo;\n    assert( nKey==(i64)(int)nKey );\n    pIdxKey = sqlite3VdbeAllocUnpackedRecord(pKeyInfo);\n    if( pIdxKey==0 ) return SQLITE_NOMEM_BKPT;\n    sqlite3VdbeRecordUnpack(pKeyInfo, (int)nKey, pKey, pIdxKey);\n    if( pIdxKey->nField==0 || pIdxKey->nField>pKeyInfo->nAllField ){\n      rc = SQLITE_CORRUPT_BKPT;\n      goto moveto_done;\n    }\n  }else{\n    pIdxKey = 0;\n  }\n  rc = sqlite3BtreeMovetoUnpacked(pCur, pIdxKey, nKey, bias, pRes);\nmoveto_done:\n  if( pIdxKey ){\n    sqlite3DbFree(pCur->pKeyInfo->db, pIdxKey);\n  }\n  return rc;\n}\n\n/*\n** Restore the cursor to the position it was in (or as close to as possible)\n** when saveCursorPosition() was called. Note that this call deletes the \n** saved position info stored by saveCursorPosition(), so there can be\n** at most one effective restoreCursorPosition() call after each \n** saveCursorPosition().\n*/\nstatic int btreeRestoreCursorPosition(BtCursor *pCur){\n  int rc;\n  int skipNext;\n  assert( cursorOwnsBtShared(pCur) );\n  assert( pCur->eState>=CURSOR_REQUIRESEEK );\n  if( pCur->eState==CURSOR_FAULT ){\n    return pCur->skipNext;\n  }\n  pCur->eState = CURSOR_INVALID;\n  rc = btreeMoveto(pCur, pCur->pKey, pCur->nKey, 0, &skipNext);\n  if( rc==SQLITE_OK ){\n    sqlite3_free(pCur->pKey);\n    pCur->pKey = 0;\n    assert( pCur->eState==CURSOR_VALID || pCur->eState==CURSOR_INVALID );\n    if( skipNext ) pCur->skipNext = skipNext;\n    if( pCur->skipNext && pCur->eState==CURSOR_VALID ){\n      pCur->eState = CURSOR_SKIPNEXT;\n    }\n  }\n  return rc;\n}\n\n#define restoreCursorPosition(p) \\\n  (p->eState>=CURSOR_REQUIRESEEK ? \\\n         btreeRestoreCursorPosition(p) : \\\n         SQLITE_OK)\n\n/*\n** Determine whether or not a cursor has moved from the position where\n** it was last placed, or has been invalidated for any other reason.\n** Cursors can move when the row they are pointing at is deleted out\n** from under them, for example.  Cursor might also move if a btree\n** is rebalanced.\n**\n** Calling this routine with a NULL cursor pointer returns false.\n**\n** Use the separate sqlite3BtreeCursorRestore() routine to restore a cursor\n** back to where it ought to be if this routine returns true.\n*/\nSQLITE_PRIVATE int sqlite3BtreeCursorHasMoved(BtCursor *pCur){\n  assert( EIGHT_BYTE_ALIGNMENT(pCur)\n       || pCur==sqlite3BtreeFakeValidCursor() );\n  assert( offsetof(BtCursor, eState)==0 );\n  assert( sizeof(pCur->eState)==1 );\n  return CURSOR_VALID != *(u8*)pCur;\n}\n\n/*\n** Return a pointer to a fake BtCursor object that will always answer\n** false to the sqlite3BtreeCursorHasMoved() routine above.  The fake\n** cursor returned must not be used with any other Btree interface.\n*/\nSQLITE_PRIVATE BtCursor *sqlite3BtreeFakeValidCursor(void){\n  static u8 fakeCursor = CURSOR_VALID;\n  assert( offsetof(BtCursor, eState)==0 );\n  return (BtCursor*)&fakeCursor;\n}\n\n/*\n** This routine restores a cursor back to its original position after it\n** has been moved by some outside activity (such as a btree rebalance or\n** a row having been deleted out from under the cursor).  \n**\n** On success, the *pDifferentRow parameter is false if the cursor is left\n** pointing at exactly the same row.  *pDifferntRow is the row the cursor\n** was pointing to has been deleted, forcing the cursor to point to some\n** nearby row.\n**\n** This routine should only be called for a cursor that just returned\n** TRUE from sqlite3BtreeCursorHasMoved().\n*/\nSQLITE_PRIVATE int sqlite3BtreeCursorRestore(BtCursor *pCur, int *pDifferentRow){\n  int rc;\n\n  assert( pCur!=0 );\n  assert( pCur->eState!=CURSOR_VALID );\n  rc = restoreCursorPosition(pCur);\n  if( rc ){\n    *pDifferentRow = 1;\n    return rc;\n  }\n  if( pCur->eState!=CURSOR_VALID ){\n    *pDifferentRow = 1;\n  }else{\n    *pDifferentRow = 0;\n  }\n  return SQLITE_OK;\n}\n\n#ifdef SQLITE_ENABLE_CURSOR_HINTS\n/*\n** Provide hints to the cursor.  The particular hint given (and the type\n** and number of the varargs parameters) is determined by the eHintType\n** parameter.  See the definitions of the BTREE_HINT_* macros for details.\n*/\nSQLITE_PRIVATE void sqlite3BtreeCursorHint(BtCursor *pCur, int eHintType, ...){\n  /* Used only by system that substitute their own storage engine */\n}\n#endif\n\n/*\n** Provide flag hints to the cursor.\n*/\nSQLITE_PRIVATE void sqlite3BtreeCursorHintFlags(BtCursor *pCur, unsigned x){\n  assert( x==BTREE_SEEK_EQ || x==BTREE_BULKLOAD || x==0 );\n  pCur->hints = x;\n}\n\n\n#ifndef SQLITE_OMIT_AUTOVACUUM\n/*\n** Given a page number of a regular database page, return the page\n** number for the pointer-map page that contains the entry for the\n** input page number.\n**\n** Return 0 (not a valid page) for pgno==1 since there is\n** no pointer map associated with page 1.  The integrity_check logic\n** requires that ptrmapPageno(*,1)!=1.\n*/\nstatic Pgno ptrmapPageno(BtShared *pBt, Pgno pgno){\n  int nPagesPerMapPage;\n  Pgno iPtrMap, ret;\n  assert( sqlite3_mutex_held(pBt->mutex) );\n  if( pgno<2 ) return 0;\n  nPagesPerMapPage = (pBt->usableSize/5)+1;\n  iPtrMap = (pgno-2)/nPagesPerMapPage;\n  ret = (iPtrMap*nPagesPerMapPage) + 2; \n  if( ret==PENDING_BYTE_PAGE(pBt) ){\n    ret++;\n  }\n  return ret;\n}\n\n/*\n** Write an entry into the pointer map.\n**\n** This routine updates the pointer map entry for page number 'key'\n** so that it maps to type 'eType' and parent page number 'pgno'.\n**\n** If *pRC is initially non-zero (non-SQLITE_OK) then this routine is\n** a no-op.  If an error occurs, the appropriate error code is written\n** into *pRC.\n*/\nstatic void ptrmapPut(BtShared *pBt, Pgno key, u8 eType, Pgno parent, int *pRC){\n  DbPage *pDbPage;  /* The pointer map page */\n  u8 *pPtrmap;      /* The pointer map data */\n  Pgno iPtrmap;     /* The pointer map page number */\n  int offset;       /* Offset in pointer map page */\n  int rc;           /* Return code from subfunctions */\n\n  if( *pRC ) return;\n\n  assert( sqlite3_mutex_held(pBt->mutex) );\n  /* The master-journal page number must never be used as a pointer map page */\n  assert( 0==PTRMAP_ISPAGE(pBt, PENDING_BYTE_PAGE(pBt)) );\n\n  assert( pBt->autoVacuum );\n  if( key==0 ){\n    *pRC = SQLITE_CORRUPT_BKPT;\n    return;\n  }\n  iPtrmap = PTRMAP_PAGENO(pBt, key);\n  rc = sqlite3PagerGet(pBt->pPager, iPtrmap, &pDbPage, 0);\n  if( rc!=SQLITE_OK ){\n    *pRC = rc;\n    return;\n  }\n  if( ((char*)sqlite3PagerGetExtra(pDbPage))[0]!=0 ){\n    /* The first byte of the extra data is the MemPage.isInit byte.\n    ** If that byte is set, it means this page is also being used\n    ** as a btree page. */\n    *pRC = SQLITE_CORRUPT_BKPT;\n    goto ptrmap_exit;\n  }\n  offset = PTRMAP_PTROFFSET(iPtrmap, key);\n  if( offset<0 ){\n    *pRC = SQLITE_CORRUPT_BKPT;\n    goto ptrmap_exit;\n  }\n  assert( offset <= (int)pBt->usableSize-5 );\n  pPtrmap = (u8 *)sqlite3PagerGetData(pDbPage);\n\n  if( eType!=pPtrmap[offset] || get4byte(&pPtrmap[offset+1])!=parent ){\n    TRACE((\"PTRMAP_UPDATE: %d->(%d,%d)\\n\", key, eType, parent));\n    *pRC= rc = sqlite3PagerWrite(pDbPage);\n    if( rc==SQLITE_OK ){\n      pPtrmap[offset] = eType;\n      put4byte(&pPtrmap[offset+1], parent);\n    }\n  }\n\nptrmap_exit:\n  sqlite3PagerUnref(pDbPage);\n}\n\n/*\n** Read an entry from the pointer map.\n**\n** This routine retrieves the pointer map entry for page 'key', writing\n** the type and parent page number to *pEType and *pPgno respectively.\n** An error code is returned if something goes wrong, otherwise SQLITE_OK.\n*/\nstatic int ptrmapGet(BtShared *pBt, Pgno key, u8 *pEType, Pgno *pPgno){\n  DbPage *pDbPage;   /* The pointer map page */\n  int iPtrmap;       /* Pointer map page index */\n  u8 *pPtrmap;       /* Pointer map page data */\n  int offset;        /* Offset of entry in pointer map */\n  int rc;\n\n  assert( sqlite3_mutex_held(pBt->mutex) );\n\n  iPtrmap = PTRMAP_PAGENO(pBt, key);\n  rc = sqlite3PagerGet(pBt->pPager, iPtrmap, &pDbPage, 0);\n  if( rc!=0 ){\n    return rc;\n  }\n  pPtrmap = (u8 *)sqlite3PagerGetData(pDbPage);\n\n  offset = PTRMAP_PTROFFSET(iPtrmap, key);\n  if( offset<0 ){\n    sqlite3PagerUnref(pDbPage);\n    return SQLITE_CORRUPT_BKPT;\n  }\n  assert( offset <= (int)pBt->usableSize-5 );\n  assert( pEType!=0 );\n  *pEType = pPtrmap[offset];\n  if( pPgno ) *pPgno = get4byte(&pPtrmap[offset+1]);\n\n  sqlite3PagerUnref(pDbPage);\n  if( *pEType<1 || *pEType>5 ) return SQLITE_CORRUPT_PGNO(iPtrmap);\n  return SQLITE_OK;\n}\n\n#else /* if defined SQLITE_OMIT_AUTOVACUUM */\n  #define ptrmapPut(w,x,y,z,rc)\n  #define ptrmapGet(w,x,y,z) SQLITE_OK\n  #define ptrmapPutOvflPtr(x, y, z, rc)\n#endif\n\n/*\n** Given a btree page and a cell index (0 means the first cell on\n** the page, 1 means the second cell, and so forth) return a pointer\n** to the cell content.\n**\n** findCellPastPtr() does the same except it skips past the initial\n** 4-byte child pointer found on interior pages, if there is one.\n**\n** This routine works only for pages that do not contain overflow cells.\n*/\n#define findCell(P,I) \\\n  ((P)->aData + ((P)->maskPage & get2byteAligned(&(P)->aCellIdx[2*(I)])))\n#define findCellPastPtr(P,I) \\\n  ((P)->aDataOfst + ((P)->maskPage & get2byteAligned(&(P)->aCellIdx[2*(I)])))\n\n\n/*\n** This is common tail processing for btreeParseCellPtr() and\n** btreeParseCellPtrIndex() for the case when the cell does not fit entirely\n** on a single B-tree page.  Make necessary adjustments to the CellInfo\n** structure.\n*/\nstatic SQLITE_NOINLINE void btreeParseCellAdjustSizeForOverflow(\n  MemPage *pPage,         /* Page containing the cell */\n  u8 *pCell,              /* Pointer to the cell text. */\n  CellInfo *pInfo         /* Fill in this structure */\n){\n  /* If the payload will not fit completely on the local page, we have\n  ** to decide how much to store locally and how much to spill onto\n  ** overflow pages.  The strategy is to minimize the amount of unused\n  ** space on overflow pages while keeping the amount of local storage\n  ** in between minLocal and maxLocal.\n  **\n  ** Warning:  changing the way overflow payload is distributed in any\n  ** way will result in an incompatible file format.\n  */\n  int minLocal;  /* Minimum amount of payload held locally */\n  int maxLocal;  /* Maximum amount of payload held locally */\n  int surplus;   /* Overflow payload available for local storage */\n\n  minLocal = pPage->minLocal;\n  maxLocal = pPage->maxLocal;\n  surplus = minLocal + (pInfo->nPayload - minLocal)%(pPage->pBt->usableSize-4);\n  testcase( surplus==maxLocal );\n  testcase( surplus==maxLocal+1 );\n  if( surplus <= maxLocal ){\n    pInfo->nLocal = (u16)surplus;\n  }else{\n    pInfo->nLocal = (u16)minLocal;\n  }\n  pInfo->nSize = (u16)(&pInfo->pPayload[pInfo->nLocal] - pCell) + 4;\n}\n\n/*\n** The following routines are implementations of the MemPage.xParseCell()\n** method.\n**\n** Parse a cell content block and fill in the CellInfo structure.\n**\n** btreeParseCellPtr()        =>   table btree leaf nodes\n** btreeParseCellNoPayload()  =>   table btree internal nodes\n** btreeParseCellPtrIndex()   =>   index btree nodes\n**\n** There is also a wrapper function btreeParseCell() that works for\n** all MemPage types and that references the cell by index rather than\n** by pointer.\n*/\nstatic void btreeParseCellPtrNoPayload(\n  MemPage *pPage,         /* Page containing the cell */\n  u8 *pCell,              /* Pointer to the cell text. */\n  CellInfo *pInfo         /* Fill in this structure */\n){\n  assert( sqlite3_mutex_held(pPage->pBt->mutex) );\n  assert( pPage->leaf==0 );\n  assert( pPage->childPtrSize==4 );\n#ifndef SQLITE_DEBUG\n  UNUSED_PARAMETER(pPage);\n#endif\n  pInfo->nSize = 4 + getVarint(&pCell[4], (u64*)&pInfo->nKey);\n  pInfo->nPayload = 0;\n  pInfo->nLocal = 0;\n  pInfo->pPayload = 0;\n  return;\n}\nstatic void btreeParseCellPtr(\n  MemPage *pPage,         /* Page containing the cell */\n  u8 *pCell,              /* Pointer to the cell text. */\n  CellInfo *pInfo         /* Fill in this structure */\n){\n  u8 *pIter;              /* For scanning through pCell */\n  u32 nPayload;           /* Number of bytes of cell payload */\n  u64 iKey;               /* Extracted Key value */\n\n  assert( sqlite3_mutex_held(pPage->pBt->mutex) );\n  assert( pPage->leaf==0 || pPage->leaf==1 );\n  assert( pPage->intKeyLeaf );\n  assert( pPage->childPtrSize==0 );\n  pIter = pCell;\n\n  /* The next block of code is equivalent to:\n  **\n  **     pIter += getVarint32(pIter, nPayload);\n  **\n  ** The code is inlined to avoid a function call.\n  */\n  nPayload = *pIter;\n  if( nPayload>=0x80 ){\n    u8 *pEnd = &pIter[8];\n    nPayload &= 0x7f;\n    do{\n      nPayload = (nPayload<<7) | (*++pIter & 0x7f);\n    }while( (*pIter)>=0x80 && pIter<pEnd );\n  }\n  pIter++;\n\n  /* The next block of code is equivalent to:\n  **\n  **     pIter += getVarint(pIter, (u64*)&pInfo->nKey);\n  **\n  ** The code is inlined to avoid a function call.\n  */\n  iKey = *pIter;\n  if( iKey>=0x80 ){\n    u8 *pEnd = &pIter[7];\n    iKey &= 0x7f;\n    while(1){\n      iKey = (iKey<<7) | (*++pIter & 0x7f);\n      if( (*pIter)<0x80 ) break;\n      if( pIter>=pEnd ){\n        iKey = (iKey<<8) | *++pIter;\n        break;\n      }\n    }\n  }\n  pIter++;\n\n  pInfo->nKey = *(i64*)&iKey;\n  pInfo->nPayload = nPayload;\n  pInfo->pPayload = pIter;\n  testcase( nPayload==pPage->maxLocal );\n  testcase( nPayload==pPage->maxLocal+1 );\n  if( nPayload<=pPage->maxLocal ){\n    /* This is the (easy) common case where the entire payload fits\n    ** on the local page.  No overflow is required.\n    */\n    pInfo->nSize = nPayload + (u16)(pIter - pCell);\n    if( pInfo->nSize<4 ) pInfo->nSize = 4;\n    pInfo->nLocal = (u16)nPayload;\n  }else{\n    btreeParseCellAdjustSizeForOverflow(pPage, pCell, pInfo);\n  }\n}\nstatic void btreeParseCellPtrIndex(\n  MemPage *pPage,         /* Page containing the cell */\n  u8 *pCell,              /* Pointer to the cell text. */\n  CellInfo *pInfo         /* Fill in this structure */\n){\n  u8 *pIter;              /* For scanning through pCell */\n  u32 nPayload;           /* Number of bytes of cell payload */\n\n  assert( sqlite3_mutex_held(pPage->pBt->mutex) );\n  assert( pPage->leaf==0 || pPage->leaf==1 );\n  assert( pPage->intKeyLeaf==0 );\n  pIter = pCell + pPage->childPtrSize;\n  nPayload = *pIter;\n  if( nPayload>=0x80 ){\n    u8 *pEnd = &pIter[8];\n    nPayload &= 0x7f;\n    do{\n      nPayload = (nPayload<<7) | (*++pIter & 0x7f);\n    }while( *(pIter)>=0x80 && pIter<pEnd );\n  }\n  pIter++;\n  pInfo->nKey = nPayload;\n  pInfo->nPayload = nPayload;\n  pInfo->pPayload = pIter;\n  testcase( nPayload==pPage->maxLocal );\n  testcase( nPayload==pPage->maxLocal+1 );\n  if( nPayload<=pPage->maxLocal ){\n    /* This is the (easy) common case where the entire payload fits\n    ** on the local page.  No overflow is required.\n    */\n    pInfo->nSize = nPayload + (u16)(pIter - pCell);\n    if( pInfo->nSize<4 ) pInfo->nSize = 4;\n    pInfo->nLocal = (u16)nPayload;\n  }else{\n    btreeParseCellAdjustSizeForOverflow(pPage, pCell, pInfo);\n  }\n}\nstatic void btreeParseCell(\n  MemPage *pPage,         /* Page containing the cell */\n  int iCell,              /* The cell index.  First cell is 0 */\n  CellInfo *pInfo         /* Fill in this structure */\n){\n  pPage->xParseCell(pPage, findCell(pPage, iCell), pInfo);\n}\n\n/*\n** The following routines are implementations of the MemPage.xCellSize\n** method.\n**\n** Compute the total number of bytes that a Cell needs in the cell\n** data area of the btree-page.  The return number includes the cell\n** data header and the local payload, but not any overflow page or\n** the space used by the cell pointer.\n**\n** cellSizePtrNoPayload()    =>   table internal nodes\n** cellSizePtr()             =>   all index nodes & table leaf nodes\n*/\nstatic u16 cellSizePtr(MemPage *pPage, u8 *pCell){\n  u8 *pIter = pCell + pPage->childPtrSize; /* For looping over bytes of pCell */\n  u8 *pEnd;                                /* End mark for a varint */\n  u32 nSize;                               /* Size value to return */\n\n#ifdef SQLITE_DEBUG\n  /* The value returned by this function should always be the same as\n  ** the (CellInfo.nSize) value found by doing a full parse of the\n  ** cell. If SQLITE_DEBUG is defined, an assert() at the bottom of\n  ** this function verifies that this invariant is not violated. */\n  CellInfo debuginfo;\n  pPage->xParseCell(pPage, pCell, &debuginfo);\n#endif\n\n  nSize = *pIter;\n  if( nSize>=0x80 ){\n    pEnd = &pIter[8];\n    nSize &= 0x7f;\n    do{\n      nSize = (nSize<<7) | (*++pIter & 0x7f);\n    }while( *(pIter)>=0x80 && pIter<pEnd );\n  }\n  pIter++;\n  if( pPage->intKey ){\n    /* pIter now points at the 64-bit integer key value, a variable length \n    ** integer. The following block moves pIter to point at the first byte\n    ** past the end of the key value. */\n    pEnd = &pIter[9];\n    while( (*pIter++)&0x80 && pIter<pEnd );\n  }\n  testcase( nSize==pPage->maxLocal );\n  testcase( nSize==pPage->maxLocal+1 );\n  if( nSize<=pPage->maxLocal ){\n    nSize += (u32)(pIter - pCell);\n    if( nSize<4 ) nSize = 4;\n  }else{\n    int minLocal = pPage->minLocal;\n    nSize = minLocal + (nSize - minLocal) % (pPage->pBt->usableSize - 4);\n    testcase( nSize==pPage->maxLocal );\n    testcase( nSize==pPage->maxLocal+1 );\n    if( nSize>pPage->maxLocal ){\n      nSize = minLocal;\n    }\n    nSize += 4 + (u16)(pIter - pCell);\n  }\n  assert( nSize==debuginfo.nSize || CORRUPT_DB );\n  return (u16)nSize;\n}\nstatic u16 cellSizePtrNoPayload(MemPage *pPage, u8 *pCell){\n  u8 *pIter = pCell + 4; /* For looping over bytes of pCell */\n  u8 *pEnd;              /* End mark for a varint */\n\n#ifdef SQLITE_DEBUG\n  /* The value returned by this function should always be the same as\n  ** the (CellInfo.nSize) value found by doing a full parse of the\n  ** cell. If SQLITE_DEBUG is defined, an assert() at the bottom of\n  ** this function verifies that this invariant is not violated. */\n  CellInfo debuginfo;\n  pPage->xParseCell(pPage, pCell, &debuginfo);\n#else\n  UNUSED_PARAMETER(pPage);\n#endif\n\n  assert( pPage->childPtrSize==4 );\n  pEnd = pIter + 9;\n  while( (*pIter++)&0x80 && pIter<pEnd );\n  assert( debuginfo.nSize==(u16)(pIter - pCell) || CORRUPT_DB );\n  return (u16)(pIter - pCell);\n}\n\n\n#ifdef SQLITE_DEBUG\n/* This variation on cellSizePtr() is used inside of assert() statements\n** only. */\nstatic u16 cellSize(MemPage *pPage, int iCell){\n  return pPage->xCellSize(pPage, findCell(pPage, iCell));\n}\n#endif\n\n#ifndef SQLITE_OMIT_AUTOVACUUM\n/*\n** The cell pCell is currently part of page pSrc but will ultimately be part\n** of pPage.  (pSrc and pPager are often the same.)  If pCell contains a\n** pointer to an overflow page, insert an entry into the pointer-map for\n** the overflow page that will be valid after pCell has been moved to pPage.\n*/\nstatic void ptrmapPutOvflPtr(MemPage *pPage, MemPage *pSrc, u8 *pCell,int *pRC){\n  CellInfo info;\n  if( *pRC ) return;\n  assert( pCell!=0 );\n  pPage->xParseCell(pPage, pCell, &info);\n  if( info.nLocal<info.nPayload ){\n    Pgno ovfl;\n    if( SQLITE_WITHIN(pSrc->aDataEnd, pCell, pCell+info.nLocal) ){\n      testcase( pSrc!=pPage );\n      *pRC = SQLITE_CORRUPT_BKPT;\n      return;\n    }\n    ovfl = get4byte(&pCell[info.nSize-4]);\n    ptrmapPut(pPage->pBt, ovfl, PTRMAP_OVERFLOW1, pPage->pgno, pRC);\n  }\n}\n#endif\n\n\n/*\n** Defragment the page given. This routine reorganizes cells within the\n** page so that there are no free-blocks on the free-block list.\n**\n** Parameter nMaxFrag is the maximum amount of fragmented space that may be\n** present in the page after this routine returns.\n**\n** EVIDENCE-OF: R-44582-60138 SQLite may from time to time reorganize a\n** b-tree page so that there are no freeblocks or fragment bytes, all\n** unused bytes are contained in the unallocated space region, and all\n** cells are packed tightly at the end of the page.\n*/\nstatic int defragmentPage(MemPage *pPage, int nMaxFrag){\n  int i;                     /* Loop counter */\n  int pc;                    /* Address of the i-th cell */\n  int hdr;                   /* Offset to the page header */\n  int size;                  /* Size of a cell */\n  int usableSize;            /* Number of usable bytes on a page */\n  int cellOffset;            /* Offset to the cell pointer array */\n  int cbrk;                  /* Offset to the cell content area */\n  int nCell;                 /* Number of cells on the page */\n  unsigned char *data;       /* The page data */\n  unsigned char *temp;       /* Temp area for cell content */\n  unsigned char *src;        /* Source of content */\n  int iCellFirst;            /* First allowable cell index */\n  int iCellLast;             /* Last possible cell index */\n\n  assert( sqlite3PagerIswriteable(pPage->pDbPage) );\n  assert( pPage->pBt!=0 );\n  assert( pPage->pBt->usableSize <= SQLITE_MAX_PAGE_SIZE );\n  assert( pPage->nOverflow==0 );\n  assert( sqlite3_mutex_held(pPage->pBt->mutex) );\n  temp = 0;\n  src = data = pPage->aData;\n  hdr = pPage->hdrOffset;\n  cellOffset = pPage->cellOffset;\n  nCell = pPage->nCell;\n  assert( nCell==get2byte(&data[hdr+3]) );\n  iCellFirst = cellOffset + 2*nCell;\n  usableSize = pPage->pBt->usableSize;\n\n  /* This block handles pages with two or fewer free blocks and nMaxFrag\n  ** or fewer fragmented bytes. In this case it is faster to move the\n  ** two (or one) blocks of cells using memmove() and add the required\n  ** offsets to each pointer in the cell-pointer array than it is to \n  ** reconstruct the entire page.  */\n  if( (int)data[hdr+7]<=nMaxFrag ){\n    int iFree = get2byte(&data[hdr+1]);\n\n    /* If the initial freeblock offset were out of bounds, that would\n    ** have been detected by btreeInitPage() when it was computing the\n    ** number of free bytes on the page. */\n    assert( iFree<=usableSize-4 );\n    if( iFree ){\n      int iFree2 = get2byte(&data[iFree]);\n      if( iFree2>usableSize-4 ) return SQLITE_CORRUPT_PAGE(pPage);\n      if( 0==iFree2 || (data[iFree2]==0 && data[iFree2+1]==0) ){\n        u8 *pEnd = &data[cellOffset + nCell*2];\n        u8 *pAddr;\n        int sz2 = 0;\n        int sz = get2byte(&data[iFree+2]);\n        int top = get2byte(&data[hdr+5]);\n        if( top>=iFree ){\n          return SQLITE_CORRUPT_PAGE(pPage);\n        }\n        if( iFree2 ){\n          if( iFree+sz>iFree2 ) return SQLITE_CORRUPT_PAGE(pPage);\n          sz2 = get2byte(&data[iFree2+2]);\n          if( iFree2+sz2 > usableSize ) return SQLITE_CORRUPT_PAGE(pPage);\n          memmove(&data[iFree+sz+sz2], &data[iFree+sz], iFree2-(iFree+sz));\n          sz += sz2;\n        }\n        cbrk = top+sz;\n        assert( cbrk+(iFree-top) <= usableSize );\n        memmove(&data[cbrk], &data[top], iFree-top);\n        for(pAddr=&data[cellOffset]; pAddr<pEnd; pAddr+=2){\n          pc = get2byte(pAddr);\n          if( pc<iFree ){ put2byte(pAddr, pc+sz); }\n          else if( pc<iFree2 ){ put2byte(pAddr, pc+sz2); }\n        }\n        goto defragment_out;\n      }\n    }\n  }\n\n  cbrk = usableSize;\n  iCellLast = usableSize - 4;\n  for(i=0; i<nCell; i++){\n    u8 *pAddr;     /* The i-th cell pointer */\n    pAddr = &data[cellOffset + i*2];\n    pc = get2byte(pAddr);\n    testcase( pc==iCellFirst );\n    testcase( pc==iCellLast );\n    /* These conditions have already been verified in btreeInitPage()\n    ** if PRAGMA cell_size_check=ON.\n    */\n    if( pc<iCellFirst || pc>iCellLast ){\n      return SQLITE_CORRUPT_PAGE(pPage);\n    }\n    assert( pc>=iCellFirst && pc<=iCellLast );\n    size = pPage->xCellSize(pPage, &src[pc]);\n    cbrk -= size;\n    if( cbrk<iCellFirst || pc+size>usableSize ){\n      return SQLITE_CORRUPT_PAGE(pPage);\n    }\n    assert( cbrk+size<=usableSize && cbrk>=iCellFirst );\n    testcase( cbrk+size==usableSize );\n    testcase( pc+size==usableSize );\n    put2byte(pAddr, cbrk);\n    if( temp==0 ){\n      int x;\n      if( cbrk==pc ) continue;\n      temp = sqlite3PagerTempSpace(pPage->pBt->pPager);\n      x = get2byte(&data[hdr+5]);\n      memcpy(&temp[x], &data[x], (cbrk+size) - x);\n      src = temp;\n    }\n    memcpy(&data[cbrk], &src[pc], size);\n  }\n  data[hdr+7] = 0;\n\n defragment_out:\n  if( data[hdr+7]+cbrk-iCellFirst!=pPage->nFree ){\n    return SQLITE_CORRUPT_PAGE(pPage);\n  }\n  assert( cbrk>=iCellFirst );\n  put2byte(&data[hdr+5], cbrk);\n  data[hdr+1] = 0;\n  data[hdr+2] = 0;\n  memset(&data[iCellFirst], 0, cbrk-iCellFirst);\n  assert( sqlite3PagerIswriteable(pPage->pDbPage) );\n  return SQLITE_OK;\n}\n\n/*\n** Search the free-list on page pPg for space to store a cell nByte bytes in\n** size. If one can be found, return a pointer to the space and remove it\n** from the free-list.\n**\n** If no suitable space can be found on the free-list, return NULL.\n**\n** This function may detect corruption within pPg.  If corruption is\n** detected then *pRc is set to SQLITE_CORRUPT and NULL is returned.\n**\n** Slots on the free list that are between 1 and 3 bytes larger than nByte\n** will be ignored if adding the extra space to the fragmentation count\n** causes the fragmentation count to exceed 60.\n*/\nstatic u8 *pageFindSlot(MemPage *pPg, int nByte, int *pRc){\n  const int hdr = pPg->hdrOffset;\n  u8 * const aData = pPg->aData;\n  int iAddr = hdr + 1;\n  int pc = get2byte(&aData[iAddr]);\n  int x;\n  int usableSize = pPg->pBt->usableSize;\n  int size;            /* Size of the free slot */\n\n  assert( pc>0 );\n  while( pc<=usableSize-4 ){\n    /* EVIDENCE-OF: R-22710-53328 The third and fourth bytes of each\n    ** freeblock form a big-endian integer which is the size of the freeblock\n    ** in bytes, including the 4-byte header. */\n    size = get2byte(&aData[pc+2]);\n    if( (x = size - nByte)>=0 ){\n      testcase( x==4 );\n      testcase( x==3 );\n      if( size+pc > usableSize ){\n        *pRc = SQLITE_CORRUPT_PAGE(pPg);\n        return 0;\n      }else if( x<4 ){\n        /* EVIDENCE-OF: R-11498-58022 In a well-formed b-tree page, the total\n        ** number of bytes in fragments may not exceed 60. */\n        if( aData[hdr+7]>57 ) return 0;\n\n        /* Remove the slot from the free-list. Update the number of\n        ** fragmented bytes within the page. */\n        memcpy(&aData[iAddr], &aData[pc], 2);\n        aData[hdr+7] += (u8)x;\n      }else{\n        /* The slot remains on the free-list. Reduce its size to account\n         ** for the portion used by the new allocation. */\n        put2byte(&aData[pc+2], x);\n      }\n      return &aData[pc + x];\n    }\n    iAddr = pc;\n    pc = get2byte(&aData[pc]);\n    if( pc<iAddr+size ) break;\n  }\n  if( pc ){\n    *pRc = SQLITE_CORRUPT_PAGE(pPg);\n  }\n\n  return 0;\n}\n\n/*\n** Allocate nByte bytes of space from within the B-Tree page passed\n** as the first argument. Write into *pIdx the index into pPage->aData[]\n** of the first byte of allocated space. Return either SQLITE_OK or\n** an error code (usually SQLITE_CORRUPT).\n**\n** The caller guarantees that there is sufficient space to make the\n** allocation.  This routine might need to defragment in order to bring\n** all the space together, however.  This routine will avoid using\n** the first two bytes past the cell pointer area since presumably this\n** allocation is being made in order to insert a new cell, so we will\n** also end up needing a new cell pointer.\n*/\nstatic int allocateSpace(MemPage *pPage, int nByte, int *pIdx){\n  const int hdr = pPage->hdrOffset;    /* Local cache of pPage->hdrOffset */\n  u8 * const data = pPage->aData;      /* Local cache of pPage->aData */\n  int top;                             /* First byte of cell content area */\n  int rc = SQLITE_OK;                  /* Integer return code */\n  int gap;        /* First byte of gap between cell pointers and cell content */\n  \n  assert( sqlite3PagerIswriteable(pPage->pDbPage) );\n  assert( pPage->pBt );\n  assert( sqlite3_mutex_held(pPage->pBt->mutex) );\n  assert( nByte>=0 );  /* Minimum cell size is 4 */\n  assert( pPage->nFree>=nByte );\n  assert( pPage->nOverflow==0 );\n  assert( nByte < (int)(pPage->pBt->usableSize-8) );\n\n  assert( pPage->cellOffset == hdr + 12 - 4*pPage->leaf );\n  gap = pPage->cellOffset + 2*pPage->nCell;\n  assert( gap<=65536 );\n  /* EVIDENCE-OF: R-29356-02391 If the database uses a 65536-byte page size\n  ** and the reserved space is zero (the usual value for reserved space)\n  ** then the cell content offset of an empty page wants to be 65536.\n  ** However, that integer is too large to be stored in a 2-byte unsigned\n  ** integer, so a value of 0 is used in its place. */\n  top = get2byte(&data[hdr+5]);\n  assert( top<=(int)pPage->pBt->usableSize ); /* Prevent by getAndInitPage() */\n  if( gap>top ){\n    if( top==0 && pPage->pBt->usableSize==65536 ){\n      top = 65536;\n    }else{\n      return SQLITE_CORRUPT_PAGE(pPage);\n    }\n  }\n\n  /* If there is enough space between gap and top for one more cell pointer\n  ** array entry offset, and if the freelist is not empty, then search the\n  ** freelist looking for a free slot big enough to satisfy the request.\n  */\n  testcase( gap+2==top );\n  testcase( gap+1==top );\n  testcase( gap==top );\n  if( (data[hdr+2] || data[hdr+1]) && gap+2<=top ){\n    u8 *pSpace = pageFindSlot(pPage, nByte, &rc);\n    if( pSpace ){\n      assert( pSpace>=data && (pSpace - data)<65536 );\n      *pIdx = (int)(pSpace - data);\n      return SQLITE_OK;\n    }else if( rc ){\n      return rc;\n    }\n  }\n\n  /* The request could not be fulfilled using a freelist slot.  Check\n  ** to see if defragmentation is necessary.\n  */\n  testcase( gap+2+nByte==top );\n  if( gap+2+nByte>top ){\n    assert( pPage->nCell>0 || CORRUPT_DB );\n    rc = defragmentPage(pPage, MIN(4, pPage->nFree - (2+nByte)));\n    if( rc ) return rc;\n    top = get2byteNotZero(&data[hdr+5]);\n    assert( gap+2+nByte<=top );\n  }\n\n\n  /* Allocate memory from the gap in between the cell pointer array\n  ** and the cell content area.  The btreeInitPage() call has already\n  ** validated the freelist.  Given that the freelist is valid, there\n  ** is no way that the allocation can extend off the end of the page.\n  ** The assert() below verifies the previous sentence.\n  */\n  top -= nByte;\n  put2byte(&data[hdr+5], top);\n  assert( top+nByte <= (int)pPage->pBt->usableSize );\n  *pIdx = top;\n  return SQLITE_OK;\n}\n\n/*\n** Return a section of the pPage->aData to the freelist.\n** The first byte of the new free block is pPage->aData[iStart]\n** and the size of the block is iSize bytes.\n**\n** Adjacent freeblocks are coalesced.\n**\n** Note that even though the freeblock list was checked by btreeInitPage(),\n** that routine will not detect overlap between cells or freeblocks.  Nor\n** does it detect cells or freeblocks that encrouch into the reserved bytes\n** at the end of the page.  So do additional corruption checks inside this\n** routine and return SQLITE_CORRUPT if any problems are found.\n*/\nstatic int freeSpace(MemPage *pPage, u16 iStart, u16 iSize){\n  u16 iPtr;                             /* Address of ptr to next freeblock */\n  u16 iFreeBlk;                         /* Address of the next freeblock */\n  u8 hdr;                               /* Page header size.  0 or 100 */\n  u8 nFrag = 0;                         /* Reduction in fragmentation */\n  u16 iOrigSize = iSize;                /* Original value of iSize */\n  u16 x;                                /* Offset to cell content area */\n  u32 iEnd = iStart + iSize;            /* First byte past the iStart buffer */\n  unsigned char *data = pPage->aData;   /* Page content */\n\n  assert( pPage->pBt!=0 );\n  assert( sqlite3PagerIswriteable(pPage->pDbPage) );\n  assert( CORRUPT_DB || iStart>=pPage->hdrOffset+6+pPage->childPtrSize );\n  assert( CORRUPT_DB || iEnd <= pPage->pBt->usableSize );\n  assert( sqlite3_mutex_held(pPage->pBt->mutex) );\n  assert( iSize>=4 );   /* Minimum cell size is 4 */\n  assert( iStart<=pPage->pBt->usableSize-4 );\n\n  /* The list of freeblocks must be in ascending order.  Find the \n  ** spot on the list where iStart should be inserted.\n  */\n  hdr = pPage->hdrOffset;\n  iPtr = hdr + 1;\n  if( data[iPtr+1]==0 && data[iPtr]==0 ){\n    iFreeBlk = 0;  /* Shortcut for the case when the freelist is empty */\n  }else{\n    while( (iFreeBlk = get2byte(&data[iPtr]))<iStart ){\n      if( iFreeBlk<iPtr+4 ){\n        if( iFreeBlk==0 ) break;\n        return SQLITE_CORRUPT_PAGE(pPage);\n      }\n      iPtr = iFreeBlk;\n    }\n    if( iFreeBlk>pPage->pBt->usableSize-4 ){\n      return SQLITE_CORRUPT_PAGE(pPage);\n    }\n    assert( iFreeBlk>iPtr || iFreeBlk==0 );\n  \n    /* At this point:\n    **    iFreeBlk:   First freeblock after iStart, or zero if none\n    **    iPtr:       The address of a pointer to iFreeBlk\n    **\n    ** Check to see if iFreeBlk should be coalesced onto the end of iStart.\n    */\n    if( iFreeBlk && iEnd+3>=iFreeBlk ){\n      nFrag = iFreeBlk - iEnd;\n      if( iEnd>iFreeBlk ) return SQLITE_CORRUPT_PAGE(pPage);\n      iEnd = iFreeBlk + get2byte(&data[iFreeBlk+2]);\n      if( iEnd > pPage->pBt->usableSize ){\n        return SQLITE_CORRUPT_PAGE(pPage);\n      }\n      iSize = iEnd - iStart;\n      iFreeBlk = get2byte(&data[iFreeBlk]);\n    }\n  \n    /* If iPtr is another freeblock (that is, if iPtr is not the freelist\n    ** pointer in the page header) then check to see if iStart should be\n    ** coalesced onto the end of iPtr.\n    */\n    if( iPtr>hdr+1 ){\n      int iPtrEnd = iPtr + get2byte(&data[iPtr+2]);\n      if( iPtrEnd+3>=iStart ){\n        if( iPtrEnd>iStart ) return SQLITE_CORRUPT_PAGE(pPage);\n        nFrag += iStart - iPtrEnd;\n        iSize = iEnd - iPtr;\n        iStart = iPtr;\n      }\n    }\n    if( nFrag>data[hdr+7] ) return SQLITE_CORRUPT_PAGE(pPage);\n    data[hdr+7] -= nFrag;\n  }\n  x = get2byte(&data[hdr+5]);\n  if( iStart<=x ){\n    /* The new freeblock is at the beginning of the cell content area,\n    ** so just extend the cell content area rather than create another\n    ** freelist entry */\n    if( iStart<x || iPtr!=hdr+1 ) return SQLITE_CORRUPT_PAGE(pPage);\n    put2byte(&data[hdr+1], iFreeBlk);\n    put2byte(&data[hdr+5], iEnd);\n  }else{\n    /* Insert the new freeblock into the freelist */\n    put2byte(&data[iPtr], iStart);\n  }\n  if( pPage->pBt->btsFlags & BTS_FAST_SECURE ){\n    /* Overwrite deleted information with zeros when the secure_delete\n    ** option is enabled */\n    memset(&data[iStart], 0, iSize);\n  }\n  put2byte(&data[iStart], iFreeBlk);\n  put2byte(&data[iStart+2], iSize);\n  pPage->nFree += iOrigSize;\n  return SQLITE_OK;\n}\n\n/*\n** Decode the flags byte (the first byte of the header) for a page\n** and initialize fields of the MemPage structure accordingly.\n**\n** Only the following combinations are supported.  Anything different\n** indicates a corrupt database files:\n**\n**         PTF_ZERODATA\n**         PTF_ZERODATA | PTF_LEAF\n**         PTF_LEAFDATA | PTF_INTKEY\n**         PTF_LEAFDATA | PTF_INTKEY | PTF_LEAF\n*/\nstatic int decodeFlags(MemPage *pPage, int flagByte){\n  BtShared *pBt;     /* A copy of pPage->pBt */\n\n  assert( pPage->hdrOffset==(pPage->pgno==1 ? 100 : 0) );\n  assert( sqlite3_mutex_held(pPage->pBt->mutex) );\n  pPage->leaf = (u8)(flagByte>>3);  assert( PTF_LEAF == 1<<3 );\n  flagByte &= ~PTF_LEAF;\n  pPage->childPtrSize = 4-4*pPage->leaf;\n  pPage->xCellSize = cellSizePtr;\n  pBt = pPage->pBt;\n  if( flagByte==(PTF_LEAFDATA | PTF_INTKEY) ){\n    /* EVIDENCE-OF: R-07291-35328 A value of 5 (0x05) means the page is an\n    ** interior table b-tree page. */\n    assert( (PTF_LEAFDATA|PTF_INTKEY)==5 );\n    /* EVIDENCE-OF: R-26900-09176 A value of 13 (0x0d) means the page is a\n    ** leaf table b-tree page. */\n    assert( (PTF_LEAFDATA|PTF_INTKEY|PTF_LEAF)==13 );\n    pPage->intKey = 1;\n    if( pPage->leaf ){\n      pPage->intKeyLeaf = 1;\n      pPage->xParseCell = btreeParseCellPtr;\n    }else{\n      pPage->intKeyLeaf = 0;\n      pPage->xCellSize = cellSizePtrNoPayload;\n      pPage->xParseCell = btreeParseCellPtrNoPayload;\n    }\n    pPage->maxLocal = pBt->maxLeaf;\n    pPage->minLocal = pBt->minLeaf;\n  }else if( flagByte==PTF_ZERODATA ){\n    /* EVIDENCE-OF: R-43316-37308 A value of 2 (0x02) means the page is an\n    ** interior index b-tree page. */\n    assert( (PTF_ZERODATA)==2 );\n    /* EVIDENCE-OF: R-59615-42828 A value of 10 (0x0a) means the page is a\n    ** leaf index b-tree page. */\n    assert( (PTF_ZERODATA|PTF_LEAF)==10 );\n    pPage->intKey = 0;\n    pPage->intKeyLeaf = 0;\n    pPage->xParseCell = btreeParseCellPtrIndex;\n    pPage->maxLocal = pBt->maxLocal;\n    pPage->minLocal = pBt->minLocal;\n  }else{\n    /* EVIDENCE-OF: R-47608-56469 Any other value for the b-tree page type is\n    ** an error. */\n    return SQLITE_CORRUPT_PAGE(pPage);\n  }\n  pPage->max1bytePayload = pBt->max1bytePayload;\n  return SQLITE_OK;\n}\n\n/*\n** Initialize the auxiliary information for a disk block.\n**\n** Return SQLITE_OK on success.  If we see that the page does\n** not contain a well-formed database page, then return \n** SQLITE_CORRUPT.  Note that a return of SQLITE_OK does not\n** guarantee that the page is well-formed.  It only shows that\n** we failed to detect any corruption.\n*/\nstatic int btreeInitPage(MemPage *pPage){\n  int pc;            /* Address of a freeblock within pPage->aData[] */\n  u8 hdr;            /* Offset to beginning of page header */\n  u8 *data;          /* Equal to pPage->aData */\n  BtShared *pBt;        /* The main btree structure */\n  int usableSize;    /* Amount of usable space on each page */\n  u16 cellOffset;    /* Offset from start of page to first cell pointer */\n  int nFree;         /* Number of unused bytes on the page */\n  int top;           /* First byte of the cell content area */\n  int iCellFirst;    /* First allowable cell or freeblock offset */\n  int iCellLast;     /* Last possible cell or freeblock offset */\n\n  assert( pPage->pBt!=0 );\n  assert( pPage->pBt->db!=0 );\n  assert( sqlite3_mutex_held(pPage->pBt->mutex) );\n  assert( pPage->pgno==sqlite3PagerPagenumber(pPage->pDbPage) );\n  assert( pPage == sqlite3PagerGetExtra(pPage->pDbPage) );\n  assert( pPage->aData == sqlite3PagerGetData(pPage->pDbPage) );\n  assert( pPage->isInit==0 );\n\n  pBt = pPage->pBt;\n  hdr = pPage->hdrOffset;\n  data = pPage->aData;\n  /* EVIDENCE-OF: R-28594-02890 The one-byte flag at offset 0 indicating\n  ** the b-tree page type. */\n  if( decodeFlags(pPage, data[hdr]) ){\n    return SQLITE_CORRUPT_PAGE(pPage);\n  }\n  assert( pBt->pageSize>=512 && pBt->pageSize<=65536 );\n  pPage->maskPage = (u16)(pBt->pageSize - 1);\n  pPage->nOverflow = 0;\n  usableSize = pBt->usableSize;\n  pPage->cellOffset = cellOffset = hdr + 8 + pPage->childPtrSize;\n  pPage->aDataEnd = &data[usableSize];\n  pPage->aCellIdx = &data[cellOffset];\n  pPage->aDataOfst = &data[pPage->childPtrSize];\n  /* EVIDENCE-OF: R-58015-48175 The two-byte integer at offset 5 designates\n  ** the start of the cell content area. A zero value for this integer is\n  ** interpreted as 65536. */\n  top = get2byteNotZero(&data[hdr+5]);\n  /* EVIDENCE-OF: R-37002-32774 The two-byte integer at offset 3 gives the\n  ** number of cells on the page. */\n  pPage->nCell = get2byte(&data[hdr+3]);\n  if( pPage->nCell>MX_CELL(pBt) ){\n    /* To many cells for a single page.  The page must be corrupt */\n    return SQLITE_CORRUPT_PAGE(pPage);\n  }\n  testcase( pPage->nCell==MX_CELL(pBt) );\n  /* EVIDENCE-OF: R-24089-57979 If a page contains no cells (which is only\n  ** possible for a root page of a table that contains no rows) then the\n  ** offset to the cell content area will equal the page size minus the\n  ** bytes of reserved space. */\n  assert( pPage->nCell>0 || top==usableSize || CORRUPT_DB );\n\n  /* A malformed database page might cause us to read past the end\n  ** of page when parsing a cell.  \n  **\n  ** The following block of code checks early to see if a cell extends\n  ** past the end of a page boundary and causes SQLITE_CORRUPT to be \n  ** returned if it does.\n  */\n  iCellFirst = cellOffset + 2*pPage->nCell;\n  iCellLast = usableSize - 4;\n  if( pBt->db->flags & SQLITE_CellSizeCk ){\n    int i;            /* Index into the cell pointer array */\n    int sz;           /* Size of a cell */\n\n    if( !pPage->leaf ) iCellLast--;\n    for(i=0; i<pPage->nCell; i++){\n      pc = get2byteAligned(&data[cellOffset+i*2]);\n      testcase( pc==iCellFirst );\n      testcase( pc==iCellLast );\n      if( pc<iCellFirst || pc>iCellLast ){\n        return SQLITE_CORRUPT_PAGE(pPage);\n      }\n      sz = pPage->xCellSize(pPage, &data[pc]);\n      testcase( pc+sz==usableSize );\n      if( pc+sz>usableSize ){\n        return SQLITE_CORRUPT_PAGE(pPage);\n      }\n    }\n    if( !pPage->leaf ) iCellLast++;\n  }  \n\n  /* Compute the total free space on the page\n  ** EVIDENCE-OF: R-23588-34450 The two-byte integer at offset 1 gives the\n  ** start of the first freeblock on the page, or is zero if there are no\n  ** freeblocks. */\n  pc = get2byte(&data[hdr+1]);\n  nFree = data[hdr+7] + top;  /* Init nFree to non-freeblock free space */\n  if( pc>0 ){\n    u32 next, size;\n    if( pc<iCellFirst ){\n      /* EVIDENCE-OF: R-55530-52930 In a well-formed b-tree page, there will\n      ** always be at least one cell before the first freeblock.\n      */\n      return SQLITE_CORRUPT_PAGE(pPage); \n    }\n    while( 1 ){\n      if( pc>iCellLast ){\n        /* Freeblock off the end of the page */\n        return SQLITE_CORRUPT_PAGE(pPage);\n      }\n      next = get2byte(&data[pc]);\n      size = get2byte(&data[pc+2]);\n      nFree = nFree + size;\n      if( next<=pc+size+3 ) break;\n      pc = next;\n    }\n    if( next>0 ){\n      /* Freeblock not in ascending order */\n      return SQLITE_CORRUPT_PAGE(pPage);\n    }\n    if( pc+size>(unsigned int)usableSize ){\n      /* Last freeblock extends past page end */\n      return SQLITE_CORRUPT_PAGE(pPage);\n    }\n  }\n\n  /* At this point, nFree contains the sum of the offset to the start\n  ** of the cell-content area plus the number of free bytes within\n  ** the cell-content area. If this is greater than the usable-size\n  ** of the page, then the page must be corrupted. This check also\n  ** serves to verify that the offset to the start of the cell-content\n  ** area, according to the page header, lies within the page.\n  */\n  if( nFree>usableSize ){\n    return SQLITE_CORRUPT_PAGE(pPage);\n  }\n  pPage->nFree = (u16)(nFree - iCellFirst);\n  pPage->isInit = 1;\n  return SQLITE_OK;\n}\n\n/*\n** Set up a raw page so that it looks like a database page holding\n** no entries.\n*/\nstatic void zeroPage(MemPage *pPage, int flags){\n  unsigned char *data = pPage->aData;\n  BtShared *pBt = pPage->pBt;\n  u8 hdr = pPage->hdrOffset;\n  u16 first;\n\n  assert( sqlite3PagerPagenumber(pPage->pDbPage)==pPage->pgno );\n  assert( sqlite3PagerGetExtra(pPage->pDbPage) == (void*)pPage );\n  assert( sqlite3PagerGetData(pPage->pDbPage) == data );\n  assert( sqlite3PagerIswriteable(pPage->pDbPage) );\n  assert( sqlite3_mutex_held(pBt->mutex) );\n  if( pBt->btsFlags & BTS_FAST_SECURE ){\n    memset(&data[hdr], 0, pBt->usableSize - hdr);\n  }\n  data[hdr] = (char)flags;\n  first = hdr + ((flags&PTF_LEAF)==0 ? 12 : 8);\n  memset(&data[hdr+1], 0, 4);\n  data[hdr+7] = 0;\n  put2byte(&data[hdr+5], pBt->usableSize);\n  pPage->nFree = (u16)(pBt->usableSize - first);\n  decodeFlags(pPage, flags);\n  pPage->cellOffset = first;\n  pPage->aDataEnd = &data[pBt->usableSize];\n  pPage->aCellIdx = &data[first];\n  pPage->aDataOfst = &data[pPage->childPtrSize];\n  pPage->nOverflow = 0;\n  assert( pBt->pageSize>=512 && pBt->pageSize<=65536 );\n  pPage->maskPage = (u16)(pBt->pageSize - 1);\n  pPage->nCell = 0;\n  pPage->isInit = 1;\n}\n\n\n/*\n** Convert a DbPage obtained from the pager into a MemPage used by\n** the btree layer.\n*/\nstatic MemPage *btreePageFromDbPage(DbPage *pDbPage, Pgno pgno, BtShared *pBt){\n  MemPage *pPage = (MemPage*)sqlite3PagerGetExtra(pDbPage);\n  if( pgno!=pPage->pgno ){\n    pPage->aData = sqlite3PagerGetData(pDbPage);\n    pPage->pDbPage = pDbPage;\n    pPage->pBt = pBt;\n    pPage->pgno = pgno;\n    pPage->hdrOffset = pgno==1 ? 100 : 0;\n  }\n  assert( pPage->aData==sqlite3PagerGetData(pDbPage) );\n  return pPage; \n}\n\n/*\n** Get a page from the pager.  Initialize the MemPage.pBt and\n** MemPage.aData elements if needed.  See also: btreeGetUnusedPage().\n**\n** If the PAGER_GET_NOCONTENT flag is set, it means that we do not care\n** about the content of the page at this time.  So do not go to the disk\n** to fetch the content.  Just fill in the content with zeros for now.\n** If in the future we call sqlite3PagerWrite() on this page, that\n** means we have started to be concerned about content and the disk\n** read should occur at that point.\n*/\nstatic int btreeGetPage(\n  BtShared *pBt,       /* The btree */\n  Pgno pgno,           /* Number of the page to fetch */\n  MemPage **ppPage,    /* Return the page in this parameter */\n  int flags            /* PAGER_GET_NOCONTENT or PAGER_GET_READONLY */\n){\n  int rc;\n  DbPage *pDbPage;\n\n  assert( flags==0 || flags==PAGER_GET_NOCONTENT || flags==PAGER_GET_READONLY );\n  assert( sqlite3_mutex_held(pBt->mutex) );\n  rc = sqlite3PagerGet(pBt->pPager, pgno, (DbPage**)&pDbPage, flags);\n  if( rc ) return rc;\n  *ppPage = btreePageFromDbPage(pDbPage, pgno, pBt);\n  return SQLITE_OK;\n}\n\n/*\n** Retrieve a page from the pager cache. If the requested page is not\n** already in the pager cache return NULL. Initialize the MemPage.pBt and\n** MemPage.aData elements if needed.\n*/\nstatic MemPage *btreePageLookup(BtShared *pBt, Pgno pgno){\n  DbPage *pDbPage;\n  assert( sqlite3_mutex_held(pBt->mutex) );\n  pDbPage = sqlite3PagerLookup(pBt->pPager, pgno);\n  if( pDbPage ){\n    return btreePageFromDbPage(pDbPage, pgno, pBt);\n  }\n  return 0;\n}\n\n/*\n** Return the size of the database file in pages. If there is any kind of\n** error, return ((unsigned int)-1).\n*/\nstatic Pgno btreePagecount(BtShared *pBt){\n  return pBt->nPage;\n}\nSQLITE_PRIVATE u32 sqlite3BtreeLastPage(Btree *p){\n  assert( sqlite3BtreeHoldsMutex(p) );\n  assert( ((p->pBt->nPage)&0x80000000)==0 );\n  return btreePagecount(p->pBt);\n}\n\n/*\n** Get a page from the pager and initialize it.\n**\n** If pCur!=0 then the page is being fetched as part of a moveToChild()\n** call.  Do additional sanity checking on the page in this case.\n** And if the fetch fails, this routine must decrement pCur->iPage.\n**\n** The page is fetched as read-write unless pCur is not NULL and is\n** a read-only cursor.\n**\n** If an error occurs, then *ppPage is undefined. It\n** may remain unchanged, or it may be set to an invalid value.\n*/\nstatic int getAndInitPage(\n  BtShared *pBt,                  /* The database file */\n  Pgno pgno,                      /* Number of the page to get */\n  MemPage **ppPage,               /* Write the page pointer here */\n  BtCursor *pCur,                 /* Cursor to receive the page, or NULL */\n  int bReadOnly                   /* True for a read-only page */\n){\n  int rc;\n  DbPage *pDbPage;\n  assert( sqlite3_mutex_held(pBt->mutex) );\n  assert( pCur==0 || ppPage==&pCur->pPage );\n  assert( pCur==0 || bReadOnly==pCur->curPagerFlags );\n  assert( pCur==0 || pCur->iPage>0 );\n\n  if( pgno>btreePagecount(pBt) ){\n    rc = SQLITE_CORRUPT_BKPT;\n    goto getAndInitPage_error;\n  }\n  rc = sqlite3PagerGet(pBt->pPager, pgno, (DbPage**)&pDbPage, bReadOnly);\n  if( rc ){\n    goto getAndInitPage_error;\n  }\n  *ppPage = (MemPage*)sqlite3PagerGetExtra(pDbPage);\n  if( (*ppPage)->isInit==0 ){\n    btreePageFromDbPage(pDbPage, pgno, pBt);\n    rc = btreeInitPage(*ppPage);\n    if( rc!=SQLITE_OK ){\n      releasePage(*ppPage);\n      goto getAndInitPage_error;\n    }\n  }\n  assert( (*ppPage)->pgno==pgno );\n  assert( (*ppPage)->aData==sqlite3PagerGetData(pDbPage) );\n\n  /* If obtaining a child page for a cursor, we must verify that the page is\n  ** compatible with the root page. */\n  if( pCur && ((*ppPage)->nCell<1 || (*ppPage)->intKey!=pCur->curIntKey) ){\n    rc = SQLITE_CORRUPT_PGNO(pgno);\n    releasePage(*ppPage);\n    goto getAndInitPage_error;\n  }\n  return SQLITE_OK;\n\ngetAndInitPage_error:\n  if( pCur ){\n    pCur->iPage--;\n    pCur->pPage = pCur->apPage[pCur->iPage];\n  }\n  testcase( pgno==0 );\n  assert( pgno!=0 || rc==SQLITE_CORRUPT );\n  return rc;\n}\n\n/*\n** Release a MemPage.  This should be called once for each prior\n** call to btreeGetPage.\n**\n** Page1 is a special case and must be released using releasePageOne().\n*/\nstatic void releasePageNotNull(MemPage *pPage){\n  assert( pPage->aData );\n  assert( pPage->pBt );\n  assert( pPage->pDbPage!=0 );\n  assert( sqlite3PagerGetExtra(pPage->pDbPage) == (void*)pPage );\n  assert( sqlite3PagerGetData(pPage->pDbPage)==pPage->aData );\n  assert( sqlite3_mutex_held(pPage->pBt->mutex) );\n  sqlite3PagerUnrefNotNull(pPage->pDbPage);\n}\nstatic void releasePage(MemPage *pPage){\n  if( pPage ) releasePageNotNull(pPage);\n}\nstatic void releasePageOne(MemPage *pPage){\n  assert( pPage!=0 );\n  assert( pPage->aData );\n  assert( pPage->pBt );\n  assert( pPage->pDbPage!=0 );\n  assert( sqlite3PagerGetExtra(pPage->pDbPage) == (void*)pPage );\n  assert( sqlite3PagerGetData(pPage->pDbPage)==pPage->aData );\n  assert( sqlite3_mutex_held(pPage->pBt->mutex) );\n  sqlite3PagerUnrefPageOne(pPage->pDbPage);\n}\n\n/*\n** Get an unused page.\n**\n** This works just like btreeGetPage() with the addition:\n**\n**   *  If the page is already in use for some other purpose, immediately\n**      release it and return an SQLITE_CURRUPT error.\n**   *  Make sure the isInit flag is clear\n*/\nstatic int btreeGetUnusedPage(\n  BtShared *pBt,       /* The btree */\n  Pgno pgno,           /* Number of the page to fetch */\n  MemPage **ppPage,    /* Return the page in this parameter */\n  int flags            /* PAGER_GET_NOCONTENT or PAGER_GET_READONLY */\n){\n  int rc = btreeGetPage(pBt, pgno, ppPage, flags);\n  if( rc==SQLITE_OK ){\n    if( sqlite3PagerPageRefcount((*ppPage)->pDbPage)>1 ){\n      releasePage(*ppPage);\n      *ppPage = 0;\n      return SQLITE_CORRUPT_BKPT;\n    }\n    (*ppPage)->isInit = 0;\n  }else{\n    *ppPage = 0;\n  }\n  return rc;\n}\n\n\n/*\n** During a rollback, when the pager reloads information into the cache\n** so that the cache is restored to its original state at the start of\n** the transaction, for each page restored this routine is called.\n**\n** This routine needs to reset the extra data section at the end of the\n** page to agree with the restored data.\n*/\nstatic void pageReinit(DbPage *pData){\n  MemPage *pPage;\n  pPage = (MemPage *)sqlite3PagerGetExtra(pData);\n  assert( sqlite3PagerPageRefcount(pData)>0 );\n  if( pPage->isInit ){\n    assert( sqlite3_mutex_held(pPage->pBt->mutex) );\n    pPage->isInit = 0;\n    if( sqlite3PagerPageRefcount(pData)>1 ){\n      /* pPage might not be a btree page;  it might be an overflow page\n      ** or ptrmap page or a free page.  In those cases, the following\n      ** call to btreeInitPage() will likely return SQLITE_CORRUPT.\n      ** But no harm is done by this.  And it is very important that\n      ** btreeInitPage() be called on every btree page so we make\n      ** the call for every page that comes in for re-initing. */\n      btreeInitPage(pPage);\n    }\n  }\n}\n\n/*\n** Invoke the busy handler for a btree.\n*/\nstatic int btreeInvokeBusyHandler(void *pArg){\n  BtShared *pBt = (BtShared*)pArg;\n  assert( pBt->db );\n  assert( sqlite3_mutex_held(pBt->db->mutex) );\n  return sqlite3InvokeBusyHandler(&pBt->db->busyHandler,\n                                  sqlite3PagerFile(pBt->pPager));\n}\n\n/*\n** Open a database file.\n** \n** zFilename is the name of the database file.  If zFilename is NULL\n** then an ephemeral database is created.  The ephemeral database might\n** be exclusively in memory, or it might use a disk-based memory cache.\n** Either way, the ephemeral database will be automatically deleted \n** when sqlite3BtreeClose() is called.\n**\n** If zFilename is \":memory:\" then an in-memory database is created\n** that is automatically destroyed when it is closed.\n**\n** The \"flags\" parameter is a bitmask that might contain bits like\n** BTREE_OMIT_JOURNAL and/or BTREE_MEMORY.\n**\n** If the database is already opened in the same database connection\n** and we are in shared cache mode, then the open will fail with an\n** SQLITE_CONSTRAINT error.  We cannot allow two or more BtShared\n** objects in the same database connection since doing so will lead\n** to problems with locking.\n*/\nSQLITE_PRIVATE int sqlite3BtreeOpen(\n  sqlite3_vfs *pVfs,      /* VFS to use for this b-tree */\n  const char *zFilename,  /* Name of the file containing the BTree database */\n  sqlite3 *db,            /* Associated database handle */\n  Btree **ppBtree,        /* Pointer to new Btree object written here */\n  int flags,              /* Options */\n  int vfsFlags            /* Flags passed through to sqlite3_vfs.xOpen() */\n){\n  BtShared *pBt = 0;             /* Shared part of btree structure */\n  Btree *p;                      /* Handle to return */\n  sqlite3_mutex *mutexOpen = 0;  /* Prevents a race condition. Ticket #3537 */\n  int rc = SQLITE_OK;            /* Result code from this function */\n  u8 nReserve;                   /* Byte of unused space on each page */\n  unsigned char zDbHeader[100];  /* Database header content */\n\n  /* True if opening an ephemeral, temporary database */\n  const int isTempDb = zFilename==0 || zFilename[0]==0;\n\n  /* Set the variable isMemdb to true for an in-memory database, or \n  ** false for a file-based database.\n  */\n#ifdef SQLITE_OMIT_MEMORYDB\n  const int isMemdb = 0;\n#else\n  const int isMemdb = (zFilename && strcmp(zFilename, \":memory:\")==0)\n                       || (isTempDb && sqlite3TempInMemory(db))\n                       || (vfsFlags & SQLITE_OPEN_MEMORY)!=0;\n#endif\n\n  assert( db!=0 );\n  assert( pVfs!=0 );\n  assert( sqlite3_mutex_held(db->mutex) );\n  assert( (flags&0xff)==flags );   /* flags fit in 8 bits */\n\n  /* Only a BTREE_SINGLE database can be BTREE_UNORDERED */\n  assert( (flags & BTREE_UNORDERED)==0 || (flags & BTREE_SINGLE)!=0 );\n\n  /* A BTREE_SINGLE database is always a temporary and/or ephemeral */\n  assert( (flags & BTREE_SINGLE)==0 || isTempDb );\n\n  if( isMemdb ){\n    flags |= BTREE_MEMORY;\n  }\n  if( (vfsFlags & SQLITE_OPEN_MAIN_DB)!=0 && (isMemdb || isTempDb) ){\n    vfsFlags = (vfsFlags & ~SQLITE_OPEN_MAIN_DB) | SQLITE_OPEN_TEMP_DB;\n  }\n  p = sqlite3MallocZero(sizeof(Btree));\n  if( !p ){\n    return SQLITE_NOMEM_BKPT;\n  }\n  p->inTrans = TRANS_NONE;\n  p->db = db;\n#ifndef SQLITE_OMIT_SHARED_CACHE\n  p->lock.pBtree = p;\n  p->lock.iTable = 1;\n#endif\n\n#if !defined(SQLITE_OMIT_SHARED_CACHE) && !defined(SQLITE_OMIT_DISKIO)\n  /*\n  ** If this Btree is a candidate for shared cache, try to find an\n  ** existing BtShared object that we can share with\n  */\n  if( isTempDb==0 && (isMemdb==0 || (vfsFlags&SQLITE_OPEN_URI)!=0) ){\n    if( vfsFlags & SQLITE_OPEN_SHAREDCACHE ){\n      int nFilename = sqlite3Strlen30(zFilename)+1;\n      int nFullPathname = pVfs->mxPathname+1;\n      char *zFullPathname = sqlite3Malloc(MAX(nFullPathname,nFilename));\n      MUTEX_LOGIC( sqlite3_mutex *mutexShared; )\n\n      p->sharable = 1;\n      if( !zFullPathname ){\n        sqlite3_free(p);\n        return SQLITE_NOMEM_BKPT;\n      }\n      if( isMemdb ){\n        memcpy(zFullPathname, zFilename, nFilename);\n      }else{\n        rc = sqlite3OsFullPathname(pVfs, zFilename,\n                                   nFullPathname, zFullPathname);\n        if( rc ){\n          sqlite3_free(zFullPathname);\n          sqlite3_free(p);\n          return rc;\n        }\n      }\n#if SQLITE_THREADSAFE\n      mutexOpen = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_OPEN);\n      sqlite3_mutex_enter(mutexOpen);\n      mutexShared = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER);\n      sqlite3_mutex_enter(mutexShared);\n#endif\n      for(pBt=GLOBAL(BtShared*,sqlite3SharedCacheList); pBt; pBt=pBt->pNext){\n        assert( pBt->nRef>0 );\n        if( 0==strcmp(zFullPathname, sqlite3PagerFilename(pBt->pPager, 0))\n                 && sqlite3PagerVfs(pBt->pPager)==pVfs ){\n          int iDb;\n          for(iDb=db->nDb-1; iDb>=0; iDb--){\n            Btree *pExisting = db->aDb[iDb].pBt;\n            if( pExisting && pExisting->pBt==pBt ){\n              sqlite3_mutex_leave(mutexShared);\n              sqlite3_mutex_leave(mutexOpen);\n              sqlite3_free(zFullPathname);\n              sqlite3_free(p);\n              return SQLITE_CONSTRAINT;\n            }\n          }\n          p->pBt = pBt;\n          pBt->nRef++;\n          break;\n        }\n      }\n      sqlite3_mutex_leave(mutexShared);\n      sqlite3_free(zFullPathname);\n    }\n#ifdef SQLITE_DEBUG\n    else{\n      /* In debug mode, we mark all persistent databases as sharable\n      ** even when they are not.  This exercises the locking code and\n      ** gives more opportunity for asserts(sqlite3_mutex_held())\n      ** statements to find locking problems.\n      */\n      p->sharable = 1;\n    }\n#endif\n  }\n#endif\n  if( pBt==0 ){\n    /*\n    ** The following asserts make sure that structures used by the btree are\n    ** the right size.  This is to guard against size changes that result\n    ** when compiling on a different architecture.\n    */\n    assert( sizeof(i64)==8 );\n    assert( sizeof(u64)==8 );\n    assert( sizeof(u32)==4 );\n    assert( sizeof(u16)==2 );\n    assert( sizeof(Pgno)==4 );\n  \n    pBt = sqlite3MallocZero( sizeof(*pBt) );\n    if( pBt==0 ){\n      rc = SQLITE_NOMEM_BKPT;\n      goto btree_open_out;\n    }\n    rc = sqlite3PagerOpen(pVfs, &pBt->pPager, zFilename,\n                          sizeof(MemPage), flags, vfsFlags, pageReinit);\n    if( rc==SQLITE_OK ){\n      sqlite3PagerSetMmapLimit(pBt->pPager, db->szMmap);\n      rc = sqlite3PagerReadFileheader(pBt->pPager,sizeof(zDbHeader),zDbHeader);\n    }\n    if( rc!=SQLITE_OK ){\n      goto btree_open_out;\n    }\n    pBt->openFlags = (u8)flags;\n    pBt->db = db;\n    sqlite3PagerSetBusyHandler(pBt->pPager, btreeInvokeBusyHandler, pBt);\n    p->pBt = pBt;\n  \n    pBt->pCursor = 0;\n    pBt->pPage1 = 0;\n    if( sqlite3PagerIsreadonly(pBt->pPager) ) pBt->btsFlags |= BTS_READ_ONLY;\n#if defined(SQLITE_SECURE_DELETE)\n    pBt->btsFlags |= BTS_SECURE_DELETE;\n#elif defined(SQLITE_FAST_SECURE_DELETE)\n    pBt->btsFlags |= BTS_OVERWRITE;\n#endif\n    /* EVIDENCE-OF: R-51873-39618 The page size for a database file is\n    ** determined by the 2-byte integer located at an offset of 16 bytes from\n    ** the beginning of the database file. */\n    pBt->pageSize = (zDbHeader[16]<<8) | (zDbHeader[17]<<16);\n    if( pBt->pageSize<512 || pBt->pageSize>SQLITE_MAX_PAGE_SIZE\n         || ((pBt->pageSize-1)&pBt->pageSize)!=0 ){\n      pBt->pageSize = 0;\n#ifndef SQLITE_OMIT_AUTOVACUUM\n      /* If the magic name \":memory:\" will create an in-memory database, then\n      ** leave the autoVacuum mode at 0 (do not auto-vacuum), even if\n      ** SQLITE_DEFAULT_AUTOVACUUM is true. On the other hand, if\n      ** SQLITE_OMIT_MEMORYDB has been defined, then \":memory:\" is just a\n      ** regular file-name. In this case the auto-vacuum applies as per normal.\n      */\n      if( zFilename && !isMemdb ){\n        pBt->autoVacuum = (SQLITE_DEFAULT_AUTOVACUUM ? 1 : 0);\n        pBt->incrVacuum = (SQLITE_DEFAULT_AUTOVACUUM==2 ? 1 : 0);\n      }\n#endif\n      nReserve = 0;\n    }else{\n      /* EVIDENCE-OF: R-37497-42412 The size of the reserved region is\n      ** determined by the one-byte unsigned integer found at an offset of 20\n      ** into the database file header. */\n      nReserve = zDbHeader[20];\n      pBt->btsFlags |= BTS_PAGESIZE_FIXED;\n#ifndef SQLITE_OMIT_AUTOVACUUM\n      pBt->autoVacuum = (get4byte(&zDbHeader[36 + 4*4])?1:0);\n      pBt->incrVacuum = (get4byte(&zDbHeader[36 + 7*4])?1:0);\n#endif\n    }\n    rc = sqlite3PagerSetPagesize(pBt->pPager, &pBt->pageSize, nReserve);\n    if( rc ) goto btree_open_out;\n    pBt->usableSize = pBt->pageSize - nReserve;\n    assert( (pBt->pageSize & 7)==0 );  /* 8-byte alignment of pageSize */\n   \n#if !defined(SQLITE_OMIT_SHARED_CACHE) && !defined(SQLITE_OMIT_DISKIO)\n    /* Add the new BtShared object to the linked list sharable BtShareds.\n    */\n    pBt->nRef = 1;\n    if( p->sharable ){\n      MUTEX_LOGIC( sqlite3_mutex *mutexShared; )\n      MUTEX_LOGIC( mutexShared = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER);)\n      if( SQLITE_THREADSAFE && sqlite3GlobalConfig.bCoreMutex ){\n        pBt->mutex = sqlite3MutexAlloc(SQLITE_MUTEX_FAST);\n        if( pBt->mutex==0 ){\n          rc = SQLITE_NOMEM_BKPT;\n          goto btree_open_out;\n        }\n      }\n      sqlite3_mutex_enter(mutexShared);\n      pBt->pNext = GLOBAL(BtShared*,sqlite3SharedCacheList);\n      GLOBAL(BtShared*,sqlite3SharedCacheList) = pBt;\n      sqlite3_mutex_leave(mutexShared);\n    }\n#endif\n  }\n\n#if !defined(SQLITE_OMIT_SHARED_CACHE) && !defined(SQLITE_OMIT_DISKIO)\n  /* If the new Btree uses a sharable pBtShared, then link the new\n  ** Btree into the list of all sharable Btrees for the same connection.\n  ** The list is kept in ascending order by pBt address.\n  */\n  if( p->sharable ){\n    int i;\n    Btree *pSib;\n    for(i=0; i<db->nDb; i++){\n      if( (pSib = db->aDb[i].pBt)!=0 && pSib->sharable ){\n        while( pSib->pPrev ){ pSib = pSib->pPrev; }\n        if( (uptr)p->pBt<(uptr)pSib->pBt ){\n          p->pNext = pSib;\n          p->pPrev = 0;\n          pSib->pPrev = p;\n        }else{\n          while( pSib->pNext && (uptr)pSib->pNext->pBt<(uptr)p->pBt ){\n            pSib = pSib->pNext;\n          }\n          p->pNext = pSib->pNext;\n          p->pPrev = pSib;\n          if( p->pNext ){\n            p->pNext->pPrev = p;\n          }\n          pSib->pNext = p;\n        }\n        break;\n      }\n    }\n  }\n#endif\n  *ppBtree = p;\n\nbtree_open_out:\n  if( rc!=SQLITE_OK ){\n    if( pBt && pBt->pPager ){\n      sqlite3PagerClose(pBt->pPager, 0);\n    }\n    sqlite3_free(pBt);\n    sqlite3_free(p);\n    *ppBtree = 0;\n  }else{\n    sqlite3_file *pFile;\n\n    /* If the B-Tree was successfully opened, set the pager-cache size to the\n    ** default value. Except, when opening on an existing shared pager-cache,\n    ** do not change the pager-cache size.\n    */\n    if( sqlite3BtreeSchema(p, 0, 0)==0 ){\n      sqlite3PagerSetCachesize(p->pBt->pPager, SQLITE_DEFAULT_CACHE_SIZE);\n    }\n\n    pFile = sqlite3PagerFile(pBt->pPager);\n    if( pFile->pMethods ){\n      sqlite3OsFileControlHint(pFile, SQLITE_FCNTL_PDB, (void*)&pBt->db);\n    }\n  }\n  if( mutexOpen ){\n    assert( sqlite3_mutex_held(mutexOpen) );\n    sqlite3_mutex_leave(mutexOpen);\n  }\n  assert( rc!=SQLITE_OK || sqlite3BtreeConnectionCount(*ppBtree)>0 );\n  return rc;\n}\n\n/*\n** Decrement the BtShared.nRef counter.  When it reaches zero,\n** remove the BtShared structure from the sharing list.  Return\n** true if the BtShared.nRef counter reaches zero and return\n** false if it is still positive.\n*/\nstatic int removeFromSharingList(BtShared *pBt){\n#ifndef SQLITE_OMIT_SHARED_CACHE\n  MUTEX_LOGIC( sqlite3_mutex *pMaster; )\n  BtShared *pList;\n  int removed = 0;\n\n  assert( sqlite3_mutex_notheld(pBt->mutex) );\n  MUTEX_LOGIC( pMaster = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER); )\n  sqlite3_mutex_enter(pMaster);\n  pBt->nRef--;\n  if( pBt->nRef<=0 ){\n    if( GLOBAL(BtShared*,sqlite3SharedCacheList)==pBt ){\n      GLOBAL(BtShared*,sqlite3SharedCacheList) = pBt->pNext;\n    }else{\n      pList = GLOBAL(BtShared*,sqlite3SharedCacheList);\n      while( ALWAYS(pList) && pList->pNext!=pBt ){\n        pList=pList->pNext;\n      }\n      if( ALWAYS(pList) ){\n        pList->pNext = pBt->pNext;\n      }\n    }\n    if( SQLITE_THREADSAFE ){\n      sqlite3_mutex_free(pBt->mutex);\n    }\n    removed = 1;\n  }\n  sqlite3_mutex_leave(pMaster);\n  return removed;\n#else\n  return 1;\n#endif\n}\n\n/*\n** Make sure pBt->pTmpSpace points to an allocation of \n** MX_CELL_SIZE(pBt) bytes with a 4-byte prefix for a left-child\n** pointer.\n*/\nstatic void allocateTempSpace(BtShared *pBt){\n  if( !pBt->pTmpSpace ){\n    pBt->pTmpSpace = sqlite3PageMalloc( pBt->pageSize );\n\n    /* One of the uses of pBt->pTmpSpace is to format cells before\n    ** inserting them into a leaf page (function fillInCell()). If\n    ** a cell is less than 4 bytes in size, it is rounded up to 4 bytes\n    ** by the various routines that manipulate binary cells. Which\n    ** can mean that fillInCell() only initializes the first 2 or 3\n    ** bytes of pTmpSpace, but that the first 4 bytes are copied from\n    ** it into a database page. This is not actually a problem, but it\n    ** does cause a valgrind error when the 1 or 2 bytes of unitialized \n    ** data is passed to system call write(). So to avoid this error,\n    ** zero the first 4 bytes of temp space here.\n    **\n    ** Also:  Provide four bytes of initialized space before the\n    ** beginning of pTmpSpace as an area available to prepend the\n    ** left-child pointer to the beginning of a cell.\n    */\n    if( pBt->pTmpSpace ){\n      memset(pBt->pTmpSpace, 0, 8);\n      pBt->pTmpSpace += 4;\n    }\n  }\n}\n\n/*\n** Free the pBt->pTmpSpace allocation\n*/\nstatic void freeTempSpace(BtShared *pBt){\n  if( pBt->pTmpSpace ){\n    pBt->pTmpSpace -= 4;\n    sqlite3PageFree(pBt->pTmpSpace);\n    pBt->pTmpSpace = 0;\n  }\n}\n\n/*\n** Close an open database and invalidate all cursors.\n*/\nSQLITE_PRIVATE int sqlite3BtreeClose(Btree *p){\n  BtShared *pBt = p->pBt;\n  BtCursor *pCur;\n\n  /* Close all cursors opened via this handle.  */\n  assert( sqlite3_mutex_held(p->db->mutex) );\n  sqlite3BtreeEnter(p);\n  pCur = pBt->pCursor;\n  while( pCur ){\n    BtCursor *pTmp = pCur;\n    pCur = pCur->pNext;\n    if( pTmp->pBtree==p ){\n      sqlite3BtreeCloseCursor(pTmp);\n    }\n  }\n\n  /* Rollback any active transaction and free the handle structure.\n  ** The call to sqlite3BtreeRollback() drops any table-locks held by\n  ** this handle.\n  */\n  sqlite3BtreeRollback(p, SQLITE_OK, 0);\n  sqlite3BtreeLeave(p);\n\n  /* If there are still other outstanding references to the shared-btree\n  ** structure, return now. The remainder of this procedure cleans \n  ** up the shared-btree.\n  */\n  assert( p->wantToLock==0 && p->locked==0 );\n  if( !p->sharable || removeFromSharingList(pBt) ){\n    /* The pBt is no longer on the sharing list, so we can access\n    ** it without having to hold the mutex.\n    **\n    ** Clean out and delete the BtShared object.\n    */\n    assert( !pBt->pCursor );\n    sqlite3PagerClose(pBt->pPager, p->db);\n    if( pBt->xFreeSchema && pBt->pSchema ){\n      pBt->xFreeSchema(pBt->pSchema);\n    }\n    sqlite3DbFree(0, pBt->pSchema);\n    freeTempSpace(pBt);\n    sqlite3_free(pBt);\n  }\n\n#ifndef SQLITE_OMIT_SHARED_CACHE\n  assert( p->wantToLock==0 );\n  assert( p->locked==0 );\n  if( p->pPrev ) p->pPrev->pNext = p->pNext;\n  if( p->pNext ) p->pNext->pPrev = p->pPrev;\n#endif\n\n  sqlite3_free(p);\n  return SQLITE_OK;\n}\n\n/*\n** Change the \"soft\" limit on the number of pages in the cache.\n** Unused and unmodified pages will be recycled when the number of\n** pages in the cache exceeds this soft limit.  But the size of the\n** cache is allowed to grow larger than this limit if it contains\n** dirty pages or pages still in active use.\n*/\nSQLITE_PRIVATE int sqlite3BtreeSetCacheSize(Btree *p, int mxPage){\n  BtShared *pBt = p->pBt;\n  assert( sqlite3_mutex_held(p->db->mutex) );\n  sqlite3BtreeEnter(p);\n  sqlite3PagerSetCachesize(pBt->pPager, mxPage);\n  sqlite3BtreeLeave(p);\n  return SQLITE_OK;\n}\n\n/*\n** Change the \"spill\" limit on the number of pages in the cache.\n** If the number of pages exceeds this limit during a write transaction,\n** the pager might attempt to \"spill\" pages to the journal early in\n** order to free up memory.\n**\n** The value returned is the current spill size.  If zero is passed\n** as an argument, no changes are made to the spill size setting, so\n** using mxPage of 0 is a way to query the current spill size.\n*/\nSQLITE_PRIVATE int sqlite3BtreeSetSpillSize(Btree *p, int mxPage){\n  BtShared *pBt = p->pBt;\n  int res;\n  assert( sqlite3_mutex_held(p->db->mutex) );\n  sqlite3BtreeEnter(p);\n  res = sqlite3PagerSetSpillsize(pBt->pPager, mxPage);\n  sqlite3BtreeLeave(p);\n  return res;\n}\n\n#if SQLITE_MAX_MMAP_SIZE>0\n/*\n** Change the limit on the amount of the database file that may be\n** memory mapped.\n*/\nSQLITE_PRIVATE int sqlite3BtreeSetMmapLimit(Btree *p, sqlite3_int64 szMmap){\n  BtShared *pBt = p->pBt;\n  assert( sqlite3_mutex_held(p->db->mutex) );\n  sqlite3BtreeEnter(p);\n  sqlite3PagerSetMmapLimit(pBt->pPager, szMmap);\n  sqlite3BtreeLeave(p);\n  return SQLITE_OK;\n}\n#endif /* SQLITE_MAX_MMAP_SIZE>0 */\n\n/*\n** Change the way data is synced to disk in order to increase or decrease\n** how well the database resists damage due to OS crashes and power\n** failures.  Level 1 is the same as asynchronous (no syncs() occur and\n** there is a high probability of damage)  Level 2 is the default.  There\n** is a very low but non-zero probability of damage.  Level 3 reduces the\n** probability of damage to near zero but with a write performance reduction.\n*/\n#ifndef SQLITE_OMIT_PAGER_PRAGMAS\nSQLITE_PRIVATE int sqlite3BtreeSetPagerFlags(\n  Btree *p,              /* The btree to set the safety level on */\n  unsigned pgFlags       /* Various PAGER_* flags */\n){\n  BtShared *pBt = p->pBt;\n  assert( sqlite3_mutex_held(p->db->mutex) );\n  sqlite3BtreeEnter(p);\n  sqlite3PagerSetFlags(pBt->pPager, pgFlags);\n  sqlite3BtreeLeave(p);\n  return SQLITE_OK;\n}\n#endif\n\n/*\n** Change the default pages size and the number of reserved bytes per page.\n** Or, if the page size has already been fixed, return SQLITE_READONLY \n** without changing anything.\n**\n** The page size must be a power of 2 between 512 and 65536.  If the page\n** size supplied does not meet this constraint then the page size is not\n** changed.\n**\n** Page sizes are constrained to be a power of two so that the region\n** of the database file used for locking (beginning at PENDING_BYTE,\n** the first byte past the 1GB boundary, 0x40000000) needs to occur\n** at the beginning of a page.\n**\n** If parameter nReserve is less than zero, then the number of reserved\n** bytes per page is left unchanged.\n**\n** If the iFix!=0 then the BTS_PAGESIZE_FIXED flag is set so that the page size\n** and autovacuum mode can no longer be changed.\n*/\nSQLITE_PRIVATE int sqlite3BtreeSetPageSize(Btree *p, int pageSize, int nReserve, int iFix){\n  int rc = SQLITE_OK;\n  BtShared *pBt = p->pBt;\n  assert( nReserve>=-1 && nReserve<=255 );\n  sqlite3BtreeEnter(p);\n#if SQLITE_HAS_CODEC\n  if( nReserve>pBt->optimalReserve ) pBt->optimalReserve = (u8)nReserve;\n#endif\n  if( pBt->btsFlags & BTS_PAGESIZE_FIXED ){\n    sqlite3BtreeLeave(p);\n    return SQLITE_READONLY;\n  }\n  if( nReserve<0 ){\n    nReserve = pBt->pageSize - pBt->usableSize;\n  }\n  assert( nReserve>=0 && nReserve<=255 );\n  if( pageSize>=512 && pageSize<=SQLITE_MAX_PAGE_SIZE &&\n        ((pageSize-1)&pageSize)==0 ){\n    assert( (pageSize & 7)==0 );\n    assert( !pBt->pCursor );\n    pBt->pageSize = (u32)pageSize;\n    freeTempSpace(pBt);\n  }\n  rc = sqlite3PagerSetPagesize(pBt->pPager, &pBt->pageSize, nReserve);\n  pBt->usableSize = pBt->pageSize - (u16)nReserve;\n  if( iFix ) pBt->btsFlags |= BTS_PAGESIZE_FIXED;\n  sqlite3BtreeLeave(p);\n  return rc;\n}\n\n/*\n** Return the currently defined page size\n*/\nSQLITE_PRIVATE int sqlite3BtreeGetPageSize(Btree *p){\n  return p->pBt->pageSize;\n}\n\n/*\n** This function is similar to sqlite3BtreeGetReserve(), except that it\n** may only be called if it is guaranteed that the b-tree mutex is already\n** held.\n**\n** This is useful in one special case in the backup API code where it is\n** known that the shared b-tree mutex is held, but the mutex on the \n** database handle that owns *p is not. In this case if sqlite3BtreeEnter()\n** were to be called, it might collide with some other operation on the\n** database handle that owns *p, causing undefined behavior.\n*/\nSQLITE_PRIVATE int sqlite3BtreeGetReserveNoMutex(Btree *p){\n  int n;\n  assert( sqlite3_mutex_held(p->pBt->mutex) );\n  n = p->pBt->pageSize - p->pBt->usableSize;\n  return n;\n}\n\n/*\n** Return the number of bytes of space at the end of every page that\n** are intentually left unused.  This is the \"reserved\" space that is\n** sometimes used by extensions.\n**\n** If SQLITE_HAS_MUTEX is defined then the number returned is the\n** greater of the current reserved space and the maximum requested\n** reserve space.\n*/\nSQLITE_PRIVATE int sqlite3BtreeGetOptimalReserve(Btree *p){\n  int n;\n  sqlite3BtreeEnter(p);\n  n = sqlite3BtreeGetReserveNoMutex(p);\n#ifdef SQLITE_HAS_CODEC\n  if( n<p->pBt->optimalReserve ) n = p->pBt->optimalReserve;\n#endif\n  sqlite3BtreeLeave(p);\n  return n;\n}\n\n\n/*\n** Set the maximum page count for a database if mxPage is positive.\n** No changes are made if mxPage is 0 or negative.\n** Regardless of the value of mxPage, return the maximum page count.\n*/\nSQLITE_PRIVATE int sqlite3BtreeMaxPageCount(Btree *p, int mxPage){\n  int n;\n  sqlite3BtreeEnter(p);\n  n = sqlite3PagerMaxPageCount(p->pBt->pPager, mxPage);\n  sqlite3BtreeLeave(p);\n  return n;\n}\n\n/*\n** Change the values for the BTS_SECURE_DELETE and BTS_OVERWRITE flags:\n**\n**    newFlag==0       Both BTS_SECURE_DELETE and BTS_OVERWRITE are cleared\n**    newFlag==1       BTS_SECURE_DELETE set and BTS_OVERWRITE is cleared\n**    newFlag==2       BTS_SECURE_DELETE cleared and BTS_OVERWRITE is set\n**    newFlag==(-1)    No changes\n**\n** This routine acts as a query if newFlag is less than zero\n**\n** With BTS_OVERWRITE set, deleted content is overwritten by zeros, but\n** freelist leaf pages are not written back to the database.  Thus in-page\n** deleted content is cleared, but freelist deleted content is not.\n**\n** With BTS_SECURE_DELETE, operation is like BTS_OVERWRITE with the addition\n** that freelist leaf pages are written back into the database, increasing\n** the amount of disk I/O.\n*/\nSQLITE_PRIVATE int sqlite3BtreeSecureDelete(Btree *p, int newFlag){\n  int b;\n  if( p==0 ) return 0;\n  sqlite3BtreeEnter(p);\n  assert( BTS_OVERWRITE==BTS_SECURE_DELETE*2 );\n  assert( BTS_FAST_SECURE==(BTS_OVERWRITE|BTS_SECURE_DELETE) );\n  if( newFlag>=0 ){\n    p->pBt->btsFlags &= ~BTS_FAST_SECURE;\n    p->pBt->btsFlags |= BTS_SECURE_DELETE*newFlag;\n  }\n  b = (p->pBt->btsFlags & BTS_FAST_SECURE)/BTS_SECURE_DELETE;\n  sqlite3BtreeLeave(p);\n  return b;\n}\n\n/*\n** Change the 'auto-vacuum' property of the database. If the 'autoVacuum'\n** parameter is non-zero, then auto-vacuum mode is enabled. If zero, it\n** is disabled. The default value for the auto-vacuum property is \n** determined by the SQLITE_DEFAULT_AUTOVACUUM macro.\n*/\nSQLITE_PRIVATE int sqlite3BtreeSetAutoVacuum(Btree *p, int autoVacuum){\n#ifdef SQLITE_OMIT_AUTOVACUUM\n  return SQLITE_READONLY;\n#else\n  BtShared *pBt = p->pBt;\n  int rc = SQLITE_OK;\n  u8 av = (u8)autoVacuum;\n\n  sqlite3BtreeEnter(p);\n  if( (pBt->btsFlags & BTS_PAGESIZE_FIXED)!=0 && (av ?1:0)!=pBt->autoVacuum ){\n    rc = SQLITE_READONLY;\n  }else{\n    pBt->autoVacuum = av ?1:0;\n    pBt->incrVacuum = av==2 ?1:0;\n  }\n  sqlite3BtreeLeave(p);\n  return rc;\n#endif\n}\n\n/*\n** Return the value of the 'auto-vacuum' property. If auto-vacuum is \n** enabled 1 is returned. Otherwise 0.\n*/\nSQLITE_PRIVATE int sqlite3BtreeGetAutoVacuum(Btree *p){\n#ifdef SQLITE_OMIT_AUTOVACUUM\n  return BTREE_AUTOVACUUM_NONE;\n#else\n  int rc;\n  sqlite3BtreeEnter(p);\n  rc = (\n    (!p->pBt->autoVacuum)?BTREE_AUTOVACUUM_NONE:\n    (!p->pBt->incrVacuum)?BTREE_AUTOVACUUM_FULL:\n    BTREE_AUTOVACUUM_INCR\n  );\n  sqlite3BtreeLeave(p);\n  return rc;\n#endif\n}\n\n/*\n** If the user has not set the safety-level for this database connection\n** using \"PRAGMA synchronous\", and if the safety-level is not already\n** set to the value passed to this function as the second parameter,\n** set it so.\n*/\n#if SQLITE_DEFAULT_SYNCHRONOUS!=SQLITE_DEFAULT_WAL_SYNCHRONOUS \\\n    && !defined(SQLITE_OMIT_WAL)\nstatic void setDefaultSyncFlag(BtShared *pBt, u8 safety_level){\n  sqlite3 *db;\n  Db *pDb;\n  if( (db=pBt->db)!=0 && (pDb=db->aDb)!=0 ){\n    while( pDb->pBt==0 || pDb->pBt->pBt!=pBt ){ pDb++; }\n    if( pDb->bSyncSet==0 \n     && pDb->safety_level!=safety_level \n     && pDb!=&db->aDb[1] \n    ){\n      pDb->safety_level = safety_level;\n      sqlite3PagerSetFlags(pBt->pPager,\n          pDb->safety_level | (db->flags & PAGER_FLAGS_MASK));\n    }\n  }\n}\n#else\n# define setDefaultSyncFlag(pBt,safety_level)\n#endif\n\n/* Forward declaration */\nstatic int newDatabase(BtShared*);\n\n\n/*\n** Get a reference to pPage1 of the database file.  This will\n** also acquire a readlock on that file.\n**\n** SQLITE_OK is returned on success.  If the file is not a\n** well-formed database file, then SQLITE_CORRUPT is returned.\n** SQLITE_BUSY is returned if the database is locked.  SQLITE_NOMEM\n** is returned if we run out of memory. \n*/\nstatic int lockBtree(BtShared *pBt){\n  int rc;              /* Result code from subfunctions */\n  MemPage *pPage1;     /* Page 1 of the database file */\n  u32 nPage;           /* Number of pages in the database */\n  u32 nPageFile = 0;   /* Number of pages in the database file */\n  u32 nPageHeader;     /* Number of pages in the database according to hdr */\n\n  assert( sqlite3_mutex_held(pBt->mutex) );\n  assert( pBt->pPage1==0 );\n  rc = sqlite3PagerSharedLock(pBt->pPager);\n  if( rc!=SQLITE_OK ) return rc;\n  rc = btreeGetPage(pBt, 1, &pPage1, 0);\n  if( rc!=SQLITE_OK ) return rc;\n\n  /* Do some checking to help insure the file we opened really is\n  ** a valid database file. \n  */\n  nPage = nPageHeader = get4byte(28+(u8*)pPage1->aData);\n  sqlite3PagerPagecount(pBt->pPager, (int*)&nPageFile);\n  if( nPage==0 || memcmp(24+(u8*)pPage1->aData, 92+(u8*)pPage1->aData,4)!=0 ){\n    nPage = nPageFile;\n  }\n  if( (pBt->db->flags & SQLITE_ResetDatabase)!=0 ){\n    nPage = 0;\n  }\n  if( nPage>0 ){\n    u32 pageSize;\n    u32 usableSize;\n    u8 *page1 = pPage1->aData;\n    rc = SQLITE_NOTADB;\n    /* EVIDENCE-OF: R-43737-39999 Every valid SQLite database file begins\n    ** with the following 16 bytes (in hex): 53 51 4c 69 74 65 20 66 6f 72 6d\n    ** 61 74 20 33 00. */\n    if( memcmp(page1, zMagicHeader, 16)!=0 ){\n      goto page1_init_failed;\n    }\n\n#ifdef SQLITE_OMIT_WAL\n    if( page1[18]>1 ){\n      pBt->btsFlags |= BTS_READ_ONLY;\n    }\n    if( page1[19]>1 ){\n      goto page1_init_failed;\n    }\n#else\n    if( page1[18]>2 ){\n      pBt->btsFlags |= BTS_READ_ONLY;\n    }\n    if( page1[19]>2 ){\n      goto page1_init_failed;\n    }\n\n    /* If the write version is set to 2, this database should be accessed\n    ** in WAL mode. If the log is not already open, open it now. Then \n    ** return SQLITE_OK and return without populating BtShared.pPage1.\n    ** The caller detects this and calls this function again. This is\n    ** required as the version of page 1 currently in the page1 buffer\n    ** may not be the latest version - there may be a newer one in the log\n    ** file.\n    */\n    if( page1[19]==2 && (pBt->btsFlags & BTS_NO_WAL)==0 ){\n      int isOpen = 0;\n      rc = sqlite3PagerOpenWal(pBt->pPager, &isOpen);\n      if( rc!=SQLITE_OK ){\n        goto page1_init_failed;\n      }else{\n        setDefaultSyncFlag(pBt, SQLITE_DEFAULT_WAL_SYNCHRONOUS+1);\n        if( isOpen==0 ){\n          releasePageOne(pPage1);\n          return SQLITE_OK;\n        }\n      }\n      rc = SQLITE_NOTADB;\n    }else{\n      setDefaultSyncFlag(pBt, SQLITE_DEFAULT_SYNCHRONOUS+1);\n    }\n#endif\n\n    /* EVIDENCE-OF: R-15465-20813 The maximum and minimum embedded payload\n    ** fractions and the leaf payload fraction values must be 64, 32, and 32.\n    **\n    ** The original design allowed these amounts to vary, but as of\n    ** version 3.6.0, we require them to be fixed.\n    */\n    if( memcmp(&page1[21], \"\\100\\040\\040\",3)!=0 ){\n      goto page1_init_failed;\n    }\n    /* EVIDENCE-OF: R-51873-39618 The page size for a database file is\n    ** determined by the 2-byte integer located at an offset of 16 bytes from\n    ** the beginning of the database file. */\n    pageSize = (page1[16]<<8) | (page1[17]<<16);\n    /* EVIDENCE-OF: R-25008-21688 The size of a page is a power of two\n    ** between 512 and 65536 inclusive. */\n    if( ((pageSize-1)&pageSize)!=0\n     || pageSize>SQLITE_MAX_PAGE_SIZE \n     || pageSize<=256 \n    ){\n      goto page1_init_failed;\n    }\n    pBt->btsFlags |= BTS_PAGESIZE_FIXED;\n    assert( (pageSize & 7)==0 );\n    /* EVIDENCE-OF: R-59310-51205 The \"reserved space\" size in the 1-byte\n    ** integer at offset 20 is the number of bytes of space at the end of\n    ** each page to reserve for extensions. \n    **\n    ** EVIDENCE-OF: R-37497-42412 The size of the reserved region is\n    ** determined by the one-byte unsigned integer found at an offset of 20\n    ** into the database file header. */\n    usableSize = pageSize - page1[20];\n    if( (u32)pageSize!=pBt->pageSize ){\n      /* After reading the first page of the database assuming a page size\n      ** of BtShared.pageSize, we have discovered that the page-size is\n      ** actually pageSize. Unlock the database, leave pBt->pPage1 at\n      ** zero and return SQLITE_OK. The caller will call this function\n      ** again with the correct page-size.\n      */\n      releasePageOne(pPage1);\n      pBt->usableSize = usableSize;\n      pBt->pageSize = pageSize;\n      freeTempSpace(pBt);\n      rc = sqlite3PagerSetPagesize(pBt->pPager, &pBt->pageSize,\n                                   pageSize-usableSize);\n      return rc;\n    }\n    if( sqlite3WritableSchema(pBt->db)==0 && nPage>nPageFile ){\n      rc = SQLITE_CORRUPT_BKPT;\n      goto page1_init_failed;\n    }\n    /* EVIDENCE-OF: R-28312-64704 However, the usable size is not allowed to\n    ** be less than 480. In other words, if the page size is 512, then the\n    ** reserved space size cannot exceed 32. */\n    if( usableSize<480 ){\n      goto page1_init_failed;\n    }\n    pBt->pageSize = pageSize;\n    pBt->usableSize = usableSize;\n#ifndef SQLITE_OMIT_AUTOVACUUM\n    pBt->autoVacuum = (get4byte(&page1[36 + 4*4])?1:0);\n    pBt->incrVacuum = (get4byte(&page1[36 + 7*4])?1:0);\n#endif\n  }\n\n  /* maxLocal is the maximum amount of payload to store locally for\n  ** a cell.  Make sure it is small enough so that at least minFanout\n  ** cells can will fit on one page.  We assume a 10-byte page header.\n  ** Besides the payload, the cell must store:\n  **     2-byte pointer to the cell\n  **     4-byte child pointer\n  **     9-byte nKey value\n  **     4-byte nData value\n  **     4-byte overflow page pointer\n  ** So a cell consists of a 2-byte pointer, a header which is as much as\n  ** 17 bytes long, 0 to N bytes of payload, and an optional 4 byte overflow\n  ** page pointer.\n  */\n  pBt->maxLocal = (u16)((pBt->usableSize-12)*64/255 - 23);\n  pBt->minLocal = (u16)((pBt->usableSize-12)*32/255 - 23);\n  pBt->maxLeaf = (u16)(pBt->usableSize - 35);\n  pBt->minLeaf = (u16)((pBt->usableSize-12)*32/255 - 23);\n  if( pBt->maxLocal>127 ){\n    pBt->max1bytePayload = 127;\n  }else{\n    pBt->max1bytePayload = (u8)pBt->maxLocal;\n  }\n  assert( pBt->maxLeaf + 23 <= MX_CELL_SIZE(pBt) );\n  pBt->pPage1 = pPage1;\n  pBt->nPage = nPage;\n  return SQLITE_OK;\n\npage1_init_failed:\n  releasePageOne(pPage1);\n  pBt->pPage1 = 0;\n  return rc;\n}\n\n#ifndef NDEBUG\n/*\n** Return the number of cursors open on pBt. This is for use\n** in assert() expressions, so it is only compiled if NDEBUG is not\n** defined.\n**\n** Only write cursors are counted if wrOnly is true.  If wrOnly is\n** false then all cursors are counted.\n**\n** For the purposes of this routine, a cursor is any cursor that\n** is capable of reading or writing to the database.  Cursors that\n** have been tripped into the CURSOR_FAULT state are not counted.\n*/\nstatic int countValidCursors(BtShared *pBt, int wrOnly){\n  BtCursor *pCur;\n  int r = 0;\n  for(pCur=pBt->pCursor; pCur; pCur=pCur->pNext){\n    if( (wrOnly==0 || (pCur->curFlags & BTCF_WriteFlag)!=0)\n     && pCur->eState!=CURSOR_FAULT ) r++; \n  }\n  return r;\n}\n#endif\n\n/*\n** If there are no outstanding cursors and we are not in the middle\n** of a transaction but there is a read lock on the database, then\n** this routine unrefs the first page of the database file which \n** has the effect of releasing the read lock.\n**\n** If there is a transaction in progress, this routine is a no-op.\n*/\nstatic void unlockBtreeIfUnused(BtShared *pBt){\n  assert( sqlite3_mutex_held(pBt->mutex) );\n  assert( countValidCursors(pBt,0)==0 || pBt->inTransaction>TRANS_NONE );\n  if( pBt->inTransaction==TRANS_NONE && pBt->pPage1!=0 ){\n    MemPage *pPage1 = pBt->pPage1;\n    assert( pPage1->aData );\n    assert( sqlite3PagerRefcount(pBt->pPager)==1 );\n    pBt->pPage1 = 0;\n    releasePageOne(pPage1);\n  }\n}\n\n/*\n** If pBt points to an empty file then convert that empty file\n** into a new empty database by initializing the first page of\n** the database.\n*/\nstatic int newDatabase(BtShared *pBt){\n  MemPage *pP1;\n  unsigned char *data;\n  int rc;\n\n  assert( sqlite3_mutex_held(pBt->mutex) );\n  if( pBt->nPage>0 ){\n    return SQLITE_OK;\n  }\n  pP1 = pBt->pPage1;\n  assert( pP1!=0 );\n  data = pP1->aData;\n  rc = sqlite3PagerWrite(pP1->pDbPage);\n  if( rc ) return rc;\n  memcpy(data, zMagicHeader, sizeof(zMagicHeader));\n  assert( sizeof(zMagicHeader)==16 );\n  data[16] = (u8)((pBt->pageSize>>8)&0xff);\n  data[17] = (u8)((pBt->pageSize>>16)&0xff);\n  data[18] = 1;\n  data[19] = 1;\n  assert( pBt->usableSize<=pBt->pageSize && pBt->usableSize+255>=pBt->pageSize);\n  data[20] = (u8)(pBt->pageSize - pBt->usableSize);\n  data[21] = 64;\n  data[22] = 32;\n  data[23] = 32;\n  memset(&data[24], 0, 100-24);\n  zeroPage(pP1, PTF_INTKEY|PTF_LEAF|PTF_LEAFDATA );\n  pBt->btsFlags |= BTS_PAGESIZE_FIXED;\n#ifndef SQLITE_OMIT_AUTOVACUUM\n  assert( pBt->autoVacuum==1 || pBt->autoVacuum==0 );\n  assert( pBt->incrVacuum==1 || pBt->incrVacuum==0 );\n  put4byte(&data[36 + 4*4], pBt->autoVacuum);\n  put4byte(&data[36 + 7*4], pBt->incrVacuum);\n#endif\n  pBt->nPage = 1;\n  data[31] = 1;\n  return SQLITE_OK;\n}\n\n/*\n** Initialize the first page of the database file (creating a database\n** consisting of a single page and no schema objects). Return SQLITE_OK\n** if successful, or an SQLite error code otherwise.\n*/\nSQLITE_PRIVATE int sqlite3BtreeNewDb(Btree *p){\n  int rc;\n  sqlite3BtreeEnter(p);\n  p->pBt->nPage = 0;\n  rc = newDatabase(p->pBt);\n  sqlite3BtreeLeave(p);\n  return rc;\n}\n\n/*\n** Attempt to start a new transaction. A write-transaction\n** is started if the second argument is nonzero, otherwise a read-\n** transaction.  If the second argument is 2 or more and exclusive\n** transaction is started, meaning that no other process is allowed\n** to access the database.  A preexisting transaction may not be\n** upgraded to exclusive by calling this routine a second time - the\n** exclusivity flag only works for a new transaction.\n**\n** A write-transaction must be started before attempting any \n** changes to the database.  None of the following routines \n** will work unless a transaction is started first:\n**\n**      sqlite3BtreeCreateTable()\n**      sqlite3BtreeCreateIndex()\n**      sqlite3BtreeClearTable()\n**      sqlite3BtreeDropTable()\n**      sqlite3BtreeInsert()\n**      sqlite3BtreeDelete()\n**      sqlite3BtreeUpdateMeta()\n**\n** If an initial attempt to acquire the lock fails because of lock contention\n** and the database was previously unlocked, then invoke the busy handler\n** if there is one.  But if there was previously a read-lock, do not\n** invoke the busy handler - just return SQLITE_BUSY.  SQLITE_BUSY is \n** returned when there is already a read-lock in order to avoid a deadlock.\n**\n** Suppose there are two processes A and B.  A has a read lock and B has\n** a reserved lock.  B tries to promote to exclusive but is blocked because\n** of A's read lock.  A tries to promote to reserved but is blocked by B.\n** One or the other of the two processes must give way or there can be\n** no progress.  By returning SQLITE_BUSY and not invoking the busy callback\n** when A already has a read lock, we encourage A to give up and let B\n** proceed.\n*/\nSQLITE_PRIVATE int sqlite3BtreeBeginTrans(Btree *p, int wrflag, int *pSchemaVersion){\n  BtShared *pBt = p->pBt;\n  int rc = SQLITE_OK;\n\n  sqlite3BtreeEnter(p);\n  btreeIntegrity(p);\n\n  /* If the btree is already in a write-transaction, or it\n  ** is already in a read-transaction and a read-transaction\n  ** is requested, this is a no-op.\n  */\n  if( p->inTrans==TRANS_WRITE || (p->inTrans==TRANS_READ && !wrflag) ){\n    goto trans_begun;\n  }\n  assert( pBt->inTransaction==TRANS_WRITE || IfNotOmitAV(pBt->bDoTruncate)==0 );\n\n  if( (p->db->flags & SQLITE_ResetDatabase) \n   && sqlite3PagerIsreadonly(pBt->pPager)==0 \n  ){\n    pBt->btsFlags &= ~BTS_READ_ONLY;\n  }\n\n  /* Write transactions are not possible on a read-only database */\n  if( (pBt->btsFlags & BTS_READ_ONLY)!=0 && wrflag ){\n    rc = SQLITE_READONLY;\n    goto trans_begun;\n  }\n\n#ifndef SQLITE_OMIT_SHARED_CACHE\n  {\n    sqlite3 *pBlock = 0;\n    /* If another database handle has already opened a write transaction \n    ** on this shared-btree structure and a second write transaction is\n    ** requested, return SQLITE_LOCKED.\n    */\n    if( (wrflag && pBt->inTransaction==TRANS_WRITE)\n     || (pBt->btsFlags & BTS_PENDING)!=0\n    ){\n      pBlock = pBt->pWriter->db;\n    }else if( wrflag>1 ){\n      BtLock *pIter;\n      for(pIter=pBt->pLock; pIter; pIter=pIter->pNext){\n        if( pIter->pBtree!=p ){\n          pBlock = pIter->pBtree->db;\n          break;\n        }\n      }\n    }\n    if( pBlock ){\n      sqlite3ConnectionBlocked(p->db, pBlock);\n      rc = SQLITE_LOCKED_SHAREDCACHE;\n      goto trans_begun;\n    }\n  }\n#endif\n\n  /* Any read-only or read-write transaction implies a read-lock on \n  ** page 1. So if some other shared-cache client already has a write-lock \n  ** on page 1, the transaction cannot be opened. */\n  rc = querySharedCacheTableLock(p, MASTER_ROOT, READ_LOCK);\n  if( SQLITE_OK!=rc ) goto trans_begun;\n\n  pBt->btsFlags &= ~BTS_INITIALLY_EMPTY;\n  if( pBt->nPage==0 ) pBt->btsFlags |= BTS_INITIALLY_EMPTY;\n  do {\n    /* Call lockBtree() until either pBt->pPage1 is populated or\n    ** lockBtree() returns something other than SQLITE_OK. lockBtree()\n    ** may return SQLITE_OK but leave pBt->pPage1 set to 0 if after\n    ** reading page 1 it discovers that the page-size of the database \n    ** file is not pBt->pageSize. In this case lockBtree() will update\n    ** pBt->pageSize to the page-size of the file on disk.\n    */\n    while( pBt->pPage1==0 && SQLITE_OK==(rc = lockBtree(pBt)) );\n\n    if( rc==SQLITE_OK && wrflag ){\n      if( (pBt->btsFlags & BTS_READ_ONLY)!=0 ){\n        rc = SQLITE_READONLY;\n      }else{\n        rc = sqlite3PagerBegin(pBt->pPager,wrflag>1,sqlite3TempInMemory(p->db));\n        if( rc==SQLITE_OK ){\n          rc = newDatabase(pBt);\n        }else if( rc==SQLITE_BUSY_SNAPSHOT && pBt->inTransaction==TRANS_NONE ){\n          /* if there was no transaction opened when this function was\n          ** called and SQLITE_BUSY_SNAPSHOT is returned, change the error\n          ** code to SQLITE_BUSY. */\n          rc = SQLITE_BUSY;\n        }\n      }\n    }\n  \n    if( rc!=SQLITE_OK ){\n      unlockBtreeIfUnused(pBt);\n    }\n  }while( (rc&0xFF)==SQLITE_BUSY && pBt->inTransaction==TRANS_NONE &&\n          btreeInvokeBusyHandler(pBt) );\n  sqlite3PagerResetLockTimeout(pBt->pPager);\n\n  if( rc==SQLITE_OK ){\n    if( p->inTrans==TRANS_NONE ){\n      pBt->nTransaction++;\n#ifndef SQLITE_OMIT_SHARED_CACHE\n      if( p->sharable ){\n        assert( p->lock.pBtree==p && p->lock.iTable==1 );\n        p->lock.eLock = READ_LOCK;\n        p->lock.pNext = pBt->pLock;\n        pBt->pLock = &p->lock;\n      }\n#endif\n    }\n    p->inTrans = (wrflag?TRANS_WRITE:TRANS_READ);\n    if( p->inTrans>pBt->inTransaction ){\n      pBt->inTransaction = p->inTrans;\n    }\n    if( wrflag ){\n      MemPage *pPage1 = pBt->pPage1;\n#ifndef SQLITE_OMIT_SHARED_CACHE\n      assert( !pBt->pWriter );\n      pBt->pWriter = p;\n      pBt->btsFlags &= ~BTS_EXCLUSIVE;\n      if( wrflag>1 ) pBt->btsFlags |= BTS_EXCLUSIVE;\n#endif\n\n      /* If the db-size header field is incorrect (as it may be if an old\n      ** client has been writing the database file), update it now. Doing\n      ** this sooner rather than later means the database size can safely \n      ** re-read the database size from page 1 if a savepoint or transaction\n      ** rollback occurs within the transaction.\n      */\n      if( pBt->nPage!=get4byte(&pPage1->aData[28]) ){\n        rc = sqlite3PagerWrite(pPage1->pDbPage);\n        if( rc==SQLITE_OK ){\n          put4byte(&pPage1->aData[28], pBt->nPage);\n        }\n      }\n    }\n  }\n\ntrans_begun:\n  if( rc==SQLITE_OK ){\n    if( pSchemaVersion ){\n      *pSchemaVersion = get4byte(&pBt->pPage1->aData[40]);\n    }\n    if( wrflag ){\n      /* This call makes sure that the pager has the correct number of\n      ** open savepoints. If the second parameter is greater than 0 and\n      ** the sub-journal is not already open, then it will be opened here.\n      */\n      rc = sqlite3PagerOpenSavepoint(pBt->pPager, p->db->nSavepoint);\n    }\n  }\n\n  btreeIntegrity(p);\n  sqlite3BtreeLeave(p);\n  return rc;\n}\n\n#ifndef SQLITE_OMIT_AUTOVACUUM\n\n/*\n** Set the pointer-map entries for all children of page pPage. Also, if\n** pPage contains cells that point to overflow pages, set the pointer\n** map entries for the overflow pages as well.\n*/\nstatic int setChildPtrmaps(MemPage *pPage){\n  int i;                             /* Counter variable */\n  int nCell;                         /* Number of cells in page pPage */\n  int rc;                            /* Return code */\n  BtShared *pBt = pPage->pBt;\n  Pgno pgno = pPage->pgno;\n\n  assert( sqlite3_mutex_held(pPage->pBt->mutex) );\n  rc = pPage->isInit ? SQLITE_OK : btreeInitPage(pPage);\n  if( rc!=SQLITE_OK ) return rc;\n  nCell = pPage->nCell;\n\n  for(i=0; i<nCell; i++){\n    u8 *pCell = findCell(pPage, i);\n\n    ptrmapPutOvflPtr(pPage, pPage, pCell, &rc);\n\n    if( !pPage->leaf ){\n      Pgno childPgno = get4byte(pCell);\n      ptrmapPut(pBt, childPgno, PTRMAP_BTREE, pgno, &rc);\n    }\n  }\n\n  if( !pPage->leaf ){\n    Pgno childPgno = get4byte(&pPage->aData[pPage->hdrOffset+8]);\n    ptrmapPut(pBt, childPgno, PTRMAP_BTREE, pgno, &rc);\n  }\n\n  return rc;\n}\n\n/*\n** Somewhere on pPage is a pointer to page iFrom.  Modify this pointer so\n** that it points to iTo. Parameter eType describes the type of pointer to\n** be modified, as  follows:\n**\n** PTRMAP_BTREE:     pPage is a btree-page. The pointer points at a child \n**                   page of pPage.\n**\n** PTRMAP_OVERFLOW1: pPage is a btree-page. The pointer points at an overflow\n**                   page pointed to by one of the cells on pPage.\n**\n** PTRMAP_OVERFLOW2: pPage is an overflow-page. The pointer points at the next\n**                   overflow page in the list.\n*/\nstatic int modifyPagePointer(MemPage *pPage, Pgno iFrom, Pgno iTo, u8 eType){\n  assert( sqlite3_mutex_held(pPage->pBt->mutex) );\n  assert( sqlite3PagerIswriteable(pPage->pDbPage) );\n  if( eType==PTRMAP_OVERFLOW2 ){\n    /* The pointer is always the first 4 bytes of the page in this case.  */\n    if( get4byte(pPage->aData)!=iFrom ){\n      return SQLITE_CORRUPT_PAGE(pPage);\n    }\n    put4byte(pPage->aData, iTo);\n  }else{\n    int i;\n    int nCell;\n    int rc;\n\n    rc = pPage->isInit ? SQLITE_OK : btreeInitPage(pPage);\n    if( rc ) return rc;\n    nCell = pPage->nCell;\n\n    for(i=0; i<nCell; i++){\n      u8 *pCell = findCell(pPage, i);\n      if( eType==PTRMAP_OVERFLOW1 ){\n        CellInfo info;\n        pPage->xParseCell(pPage, pCell, &info);\n        if( info.nLocal<info.nPayload ){\n          if( pCell+info.nSize > pPage->aData+pPage->pBt->usableSize ){\n            return SQLITE_CORRUPT_PAGE(pPage);\n          }\n          if( iFrom==get4byte(pCell+info.nSize-4) ){\n            put4byte(pCell+info.nSize-4, iTo);\n            break;\n          }\n        }\n      }else{\n        if( get4byte(pCell)==iFrom ){\n          put4byte(pCell, iTo);\n          break;\n        }\n      }\n    }\n  \n    if( i==nCell ){\n      if( eType!=PTRMAP_BTREE || \n          get4byte(&pPage->aData[pPage->hdrOffset+8])!=iFrom ){\n        return SQLITE_CORRUPT_PAGE(pPage);\n      }\n      put4byte(&pPage->aData[pPage->hdrOffset+8], iTo);\n    }\n  }\n  return SQLITE_OK;\n}\n\n\n/*\n** Move the open database page pDbPage to location iFreePage in the \n** database. The pDbPage reference remains valid.\n**\n** The isCommit flag indicates that there is no need to remember that\n** the journal needs to be sync()ed before database page pDbPage->pgno \n** can be written to. The caller has already promised not to write to that\n** page.\n*/\nstatic int relocatePage(\n  BtShared *pBt,           /* Btree */\n  MemPage *pDbPage,        /* Open page to move */\n  u8 eType,                /* Pointer map 'type' entry for pDbPage */\n  Pgno iPtrPage,           /* Pointer map 'page-no' entry for pDbPage */\n  Pgno iFreePage,          /* The location to move pDbPage to */\n  int isCommit             /* isCommit flag passed to sqlite3PagerMovepage */\n){\n  MemPage *pPtrPage;   /* The page that contains a pointer to pDbPage */\n  Pgno iDbPage = pDbPage->pgno;\n  Pager *pPager = pBt->pPager;\n  int rc;\n\n  assert( eType==PTRMAP_OVERFLOW2 || eType==PTRMAP_OVERFLOW1 || \n      eType==PTRMAP_BTREE || eType==PTRMAP_ROOTPAGE );\n  assert( sqlite3_mutex_held(pBt->mutex) );\n  assert( pDbPage->pBt==pBt );\n  if( iDbPage<3 ) return SQLITE_CORRUPT_BKPT;\n\n  /* Move page iDbPage from its current location to page number iFreePage */\n  TRACE((\"AUTOVACUUM: Moving %d to free page %d (ptr page %d type %d)\\n\", \n      iDbPage, iFreePage, iPtrPage, eType));\n  rc = sqlite3PagerMovepage(pPager, pDbPage->pDbPage, iFreePage, isCommit);\n  if( rc!=SQLITE_OK ){\n    return rc;\n  }\n  pDbPage->pgno = iFreePage;\n\n  /* If pDbPage was a btree-page, then it may have child pages and/or cells\n  ** that point to overflow pages. The pointer map entries for all these\n  ** pages need to be changed.\n  **\n  ** If pDbPage is an overflow page, then the first 4 bytes may store a\n  ** pointer to a subsequent overflow page. If this is the case, then\n  ** the pointer map needs to be updated for the subsequent overflow page.\n  */\n  if( eType==PTRMAP_BTREE || eType==PTRMAP_ROOTPAGE ){\n    rc = setChildPtrmaps(pDbPage);\n    if( rc!=SQLITE_OK ){\n      return rc;\n    }\n  }else{\n    Pgno nextOvfl = get4byte(pDbPage->aData);\n    if( nextOvfl!=0 ){\n      ptrmapPut(pBt, nextOvfl, PTRMAP_OVERFLOW2, iFreePage, &rc);\n      if( rc!=SQLITE_OK ){\n        return rc;\n      }\n    }\n  }\n\n  /* Fix the database pointer on page iPtrPage that pointed at iDbPage so\n  ** that it points at iFreePage. Also fix the pointer map entry for\n  ** iPtrPage.\n  */\n  if( eType!=PTRMAP_ROOTPAGE ){\n    rc = btreeGetPage(pBt, iPtrPage, &pPtrPage, 0);\n    if( rc!=SQLITE_OK ){\n      return rc;\n    }\n    rc = sqlite3PagerWrite(pPtrPage->pDbPage);\n    if( rc!=SQLITE_OK ){\n      releasePage(pPtrPage);\n      return rc;\n    }\n    rc = modifyPagePointer(pPtrPage, iDbPage, iFreePage, eType);\n    releasePage(pPtrPage);\n    if( rc==SQLITE_OK ){\n      ptrmapPut(pBt, iFreePage, eType, iPtrPage, &rc);\n    }\n  }\n  return rc;\n}\n\n/* Forward declaration required by incrVacuumStep(). */\nstatic int allocateBtreePage(BtShared *, MemPage **, Pgno *, Pgno, u8);\n\n/*\n** Perform a single step of an incremental-vacuum. If successful, return\n** SQLITE_OK. If there is no work to do (and therefore no point in \n** calling this function again), return SQLITE_DONE. Or, if an error \n** occurs, return some other error code.\n**\n** More specifically, this function attempts to re-organize the database so \n** that the last page of the file currently in use is no longer in use.\n**\n** Parameter nFin is the number of pages that this database would contain\n** were this function called until it returns SQLITE_DONE.\n**\n** If the bCommit parameter is non-zero, this function assumes that the \n** caller will keep calling incrVacuumStep() until it returns SQLITE_DONE \n** or an error. bCommit is passed true for an auto-vacuum-on-commit \n** operation, or false for an incremental vacuum.\n*/\nstatic int incrVacuumStep(BtShared *pBt, Pgno nFin, Pgno iLastPg, int bCommit){\n  Pgno nFreeList;           /* Number of pages still on the free-list */\n  int rc;\n\n  assert( sqlite3_mutex_held(pBt->mutex) );\n  assert( iLastPg>nFin );\n\n  if( !PTRMAP_ISPAGE(pBt, iLastPg) && iLastPg!=PENDING_BYTE_PAGE(pBt) ){\n    u8 eType;\n    Pgno iPtrPage;\n\n    nFreeList = get4byte(&pBt->pPage1->aData[36]);\n    if( nFreeList==0 ){\n      return SQLITE_DONE;\n    }\n\n    rc = ptrmapGet(pBt, iLastPg, &eType, &iPtrPage);\n    if( rc!=SQLITE_OK ){\n      return rc;\n    }\n    if( eType==PTRMAP_ROOTPAGE ){\n      return SQLITE_CORRUPT_BKPT;\n    }\n\n    if( eType==PTRMAP_FREEPAGE ){\n      if( bCommit==0 ){\n        /* Remove the page from the files free-list. This is not required\n        ** if bCommit is non-zero. In that case, the free-list will be\n        ** truncated to zero after this function returns, so it doesn't \n        ** matter if it still contains some garbage entries.\n        */\n        Pgno iFreePg;\n        MemPage *pFreePg;\n        rc = allocateBtreePage(pBt, &pFreePg, &iFreePg, iLastPg, BTALLOC_EXACT);\n        if( rc!=SQLITE_OK ){\n          return rc;\n        }\n        assert( iFreePg==iLastPg );\n        releasePage(pFreePg);\n      }\n    } else {\n      Pgno iFreePg;             /* Index of free page to move pLastPg to */\n      MemPage *pLastPg;\n      u8 eMode = BTALLOC_ANY;   /* Mode parameter for allocateBtreePage() */\n      Pgno iNear = 0;           /* nearby parameter for allocateBtreePage() */\n\n      rc = btreeGetPage(pBt, iLastPg, &pLastPg, 0);\n      if( rc!=SQLITE_OK ){\n        return rc;\n      }\n\n      /* If bCommit is zero, this loop runs exactly once and page pLastPg\n      ** is swapped with the first free page pulled off the free list.\n      **\n      ** On the other hand, if bCommit is greater than zero, then keep\n      ** looping until a free-page located within the first nFin pages\n      ** of the file is found.\n      */\n      if( bCommit==0 ){\n        eMode = BTALLOC_LE;\n        iNear = nFin;\n      }\n      do {\n        MemPage *pFreePg;\n        rc = allocateBtreePage(pBt, &pFreePg, &iFreePg, iNear, eMode);\n        if( rc!=SQLITE_OK ){\n          releasePage(pLastPg);\n          return rc;\n        }\n        releasePage(pFreePg);\n      }while( bCommit && iFreePg>nFin );\n      assert( iFreePg<iLastPg );\n      \n      rc = relocatePage(pBt, pLastPg, eType, iPtrPage, iFreePg, bCommit);\n      releasePage(pLastPg);\n      if( rc!=SQLITE_OK ){\n        return rc;\n      }\n    }\n  }\n\n  if( bCommit==0 ){\n    do {\n      iLastPg--;\n    }while( iLastPg==PENDING_BYTE_PAGE(pBt) || PTRMAP_ISPAGE(pBt, iLastPg) );\n    pBt->bDoTruncate = 1;\n    pBt->nPage = iLastPg;\n  }\n  return SQLITE_OK;\n}\n\n/*\n** The database opened by the first argument is an auto-vacuum database\n** nOrig pages in size containing nFree free pages. Return the expected \n** size of the database in pages following an auto-vacuum operation.\n*/\nstatic Pgno finalDbSize(BtShared *pBt, Pgno nOrig, Pgno nFree){\n  int nEntry;                     /* Number of entries on one ptrmap page */\n  Pgno nPtrmap;                   /* Number of PtrMap pages to be freed */\n  Pgno nFin;                      /* Return value */\n\n  nEntry = pBt->usableSize/5;\n  nPtrmap = (nFree-nOrig+PTRMAP_PAGENO(pBt, nOrig)+nEntry)/nEntry;\n  nFin = nOrig - nFree - nPtrmap;\n  if( nOrig>PENDING_BYTE_PAGE(pBt) && nFin<PENDING_BYTE_PAGE(pBt) ){\n    nFin--;\n  }\n  while( PTRMAP_ISPAGE(pBt, nFin) || nFin==PENDING_BYTE_PAGE(pBt) ){\n    nFin--;\n  }\n\n  return nFin;\n}\n\n/*\n** A write-transaction must be opened before calling this function.\n** It performs a single unit of work towards an incremental vacuum.\n**\n** If the incremental vacuum is finished after this function has run,\n** SQLITE_DONE is returned. If it is not finished, but no error occurred,\n** SQLITE_OK is returned. Otherwise an SQLite error code. \n*/\nSQLITE_PRIVATE int sqlite3BtreeIncrVacuum(Btree *p){\n  int rc;\n  BtShared *pBt = p->pBt;\n\n  sqlite3BtreeEnter(p);\n  assert( pBt->inTransaction==TRANS_WRITE && p->inTrans==TRANS_WRITE );\n  if( !pBt->autoVacuum ){\n    rc = SQLITE_DONE;\n  }else{\n    Pgno nOrig = btreePagecount(pBt);\n    Pgno nFree = get4byte(&pBt->pPage1->aData[36]);\n    Pgno nFin = finalDbSize(pBt, nOrig, nFree);\n\n    if( nOrig<nFin ){\n      rc = SQLITE_CORRUPT_BKPT;\n    }else if( nFree>0 ){\n      rc = saveAllCursors(pBt, 0, 0);\n      if( rc==SQLITE_OK ){\n        invalidateAllOverflowCache(pBt);\n        rc = incrVacuumStep(pBt, nFin, nOrig, 0);\n      }\n      if( rc==SQLITE_OK ){\n        rc = sqlite3PagerWrite(pBt->pPage1->pDbPage);\n        put4byte(&pBt->pPage1->aData[28], pBt->nPage);\n      }\n    }else{\n      rc = SQLITE_DONE;\n    }\n  }\n  sqlite3BtreeLeave(p);\n  return rc;\n}\n\n/*\n** This routine is called prior to sqlite3PagerCommit when a transaction\n** is committed for an auto-vacuum database.\n**\n** If SQLITE_OK is returned, then *pnTrunc is set to the number of pages\n** the database file should be truncated to during the commit process. \n** i.e. the database has been reorganized so that only the first *pnTrunc\n** pages are in use.\n*/\nstatic int autoVacuumCommit(BtShared *pBt){\n  int rc = SQLITE_OK;\n  Pager *pPager = pBt->pPager;\n  VVA_ONLY( int nRef = sqlite3PagerRefcount(pPager); )\n\n  assert( sqlite3_mutex_held(pBt->mutex) );\n  invalidateAllOverflowCache(pBt);\n  assert(pBt->autoVacuum);\n  if( !pBt->incrVacuum ){\n    Pgno nFin;         /* Number of pages in database after autovacuuming */\n    Pgno nFree;        /* Number of pages on the freelist initially */\n    Pgno iFree;        /* The next page to be freed */\n    Pgno nOrig;        /* Database size before freeing */\n\n    nOrig = btreePagecount(pBt);\n    if( PTRMAP_ISPAGE(pBt, nOrig) || nOrig==PENDING_BYTE_PAGE(pBt) ){\n      /* It is not possible to create a database for which the final page\n      ** is either a pointer-map page or the pending-byte page. If one\n      ** is encountered, this indicates corruption.\n      */\n      return SQLITE_CORRUPT_BKPT;\n    }\n\n    nFree = get4byte(&pBt->pPage1->aData[36]);\n    nFin = finalDbSize(pBt, nOrig, nFree);\n    if( nFin>nOrig ) return SQLITE_CORRUPT_BKPT;\n    if( nFin<nOrig ){\n      rc = saveAllCursors(pBt, 0, 0);\n    }\n    for(iFree=nOrig; iFree>nFin && rc==SQLITE_OK; iFree--){\n      rc = incrVacuumStep(pBt, nFin, iFree, 1);\n    }\n    if( (rc==SQLITE_DONE || rc==SQLITE_OK) && nFree>0 ){\n      rc = sqlite3PagerWrite(pBt->pPage1->pDbPage);\n      put4byte(&pBt->pPage1->aData[32], 0);\n      put4byte(&pBt->pPage1->aData[36], 0);\n      put4byte(&pBt->pPage1->aData[28], nFin);\n      pBt->bDoTruncate = 1;\n      pBt->nPage = nFin;\n    }\n    if( rc!=SQLITE_OK ){\n      sqlite3PagerRollback(pPager);\n    }\n  }\n\n  assert( nRef>=sqlite3PagerRefcount(pPager) );\n  return rc;\n}\n\n#else /* ifndef SQLITE_OMIT_AUTOVACUUM */\n# define setChildPtrmaps(x) SQLITE_OK\n#endif\n\n/*\n** This routine does the first phase of a two-phase commit.  This routine\n** causes a rollback journal to be created (if it does not already exist)\n** and populated with enough information so that if a power loss occurs\n** the database can be restored to its original state by playing back\n** the journal.  Then the contents of the journal are flushed out to\n** the disk.  After the journal is safely on oxide, the changes to the\n** database are written into the database file and flushed to oxide.\n** At the end of this call, the rollback journal still exists on the\n** disk and we are still holding all locks, so the transaction has not\n** committed.  See sqlite3BtreeCommitPhaseTwo() for the second phase of the\n** commit process.\n**\n** This call is a no-op if no write-transaction is currently active on pBt.\n**\n** Otherwise, sync the database file for the btree pBt. zMaster points to\n** the name of a master journal file that should be written into the\n** individual journal file, or is NULL, indicating no master journal file \n** (single database transaction).\n**\n** When this is called, the master journal should already have been\n** created, populated with this journal pointer and synced to disk.\n**\n** Once this is routine has returned, the only thing required to commit\n** the write-transaction for this database file is to delete the journal.\n*/\nSQLITE_PRIVATE int sqlite3BtreeCommitPhaseOne(Btree *p, const char *zMaster){\n  int rc = SQLITE_OK;\n  if( p->inTrans==TRANS_WRITE ){\n    BtShared *pBt = p->pBt;\n    sqlite3BtreeEnter(p);\n#ifndef SQLITE_OMIT_AUTOVACUUM\n    if( pBt->autoVacuum ){\n      rc = autoVacuumCommit(pBt);\n      if( rc!=SQLITE_OK ){\n        sqlite3BtreeLeave(p);\n        return rc;\n      }\n    }\n    if( pBt->bDoTruncate ){\n      sqlite3PagerTruncateImage(pBt->pPager, pBt->nPage);\n    }\n#endif\n    rc = sqlite3PagerCommitPhaseOne(pBt->pPager, zMaster, 0);\n    sqlite3BtreeLeave(p);\n  }\n  return rc;\n}\n\n/*\n** This function is called from both BtreeCommitPhaseTwo() and BtreeRollback()\n** at the conclusion of a transaction.\n*/\nstatic void btreeEndTransaction(Btree *p){\n  BtShared *pBt = p->pBt;\n  sqlite3 *db = p->db;\n  assert( sqlite3BtreeHoldsMutex(p) );\n\n#ifndef SQLITE_OMIT_AUTOVACUUM\n  pBt->bDoTruncate = 0;\n#endif\n  if( p->inTrans>TRANS_NONE && db->nVdbeRead>1 ){\n    /* If there are other active statements that belong to this database\n    ** handle, downgrade to a read-only transaction. The other statements\n    ** may still be reading from the database.  */\n    downgradeAllSharedCacheTableLocks(p);\n    p->inTrans = TRANS_READ;\n  }else{\n    /* If the handle had any kind of transaction open, decrement the \n    ** transaction count of the shared btree. If the transaction count \n    ** reaches 0, set the shared state to TRANS_NONE. The unlockBtreeIfUnused()\n    ** call below will unlock the pager.  */\n    if( p->inTrans!=TRANS_NONE ){\n      clearAllSharedCacheTableLocks(p);\n      pBt->nTransaction--;\n      if( 0==pBt->nTransaction ){\n        pBt->inTransaction = TRANS_NONE;\n      }\n    }\n\n    /* Set the current transaction state to TRANS_NONE and unlock the \n    ** pager if this call closed the only read or write transaction.  */\n    p->inTrans = TRANS_NONE;\n    unlockBtreeIfUnused(pBt);\n  }\n\n  btreeIntegrity(p);\n}\n\n/*\n** Commit the transaction currently in progress.\n**\n** This routine implements the second phase of a 2-phase commit.  The\n** sqlite3BtreeCommitPhaseOne() routine does the first phase and should\n** be invoked prior to calling this routine.  The sqlite3BtreeCommitPhaseOne()\n** routine did all the work of writing information out to disk and flushing the\n** contents so that they are written onto the disk platter.  All this\n** routine has to do is delete or truncate or zero the header in the\n** the rollback journal (which causes the transaction to commit) and\n** drop locks.\n**\n** Normally, if an error occurs while the pager layer is attempting to \n** finalize the underlying journal file, this function returns an error and\n** the upper layer will attempt a rollback. However, if the second argument\n** is non-zero then this b-tree transaction is part of a multi-file \n** transaction. In this case, the transaction has already been committed \n** (by deleting a master journal file) and the caller will ignore this \n** functions return code. So, even if an error occurs in the pager layer,\n** reset the b-tree objects internal state to indicate that the write\n** transaction has been closed. This is quite safe, as the pager will have\n** transitioned to the error state.\n**\n** This will release the write lock on the database file.  If there\n** are no active cursors, it also releases the read lock.\n*/\nSQLITE_PRIVATE int sqlite3BtreeCommitPhaseTwo(Btree *p, int bCleanup){\n\n  if( p->inTrans==TRANS_NONE ) return SQLITE_OK;\n  sqlite3BtreeEnter(p);\n  btreeIntegrity(p);\n\n  /* If the handle has a write-transaction open, commit the shared-btrees \n  ** transaction and set the shared state to TRANS_READ.\n  */\n  if( p->inTrans==TRANS_WRITE ){\n    int rc;\n    BtShared *pBt = p->pBt;\n    assert( pBt->inTransaction==TRANS_WRITE );\n    assert( pBt->nTransaction>0 );\n    rc = sqlite3PagerCommitPhaseTwo(pBt->pPager);\n    if( rc!=SQLITE_OK && bCleanup==0 ){\n      sqlite3BtreeLeave(p);\n      return rc;\n    }\n    p->iDataVersion--;  /* Compensate for pPager->iDataVersion++; */\n    pBt->inTransaction = TRANS_READ;\n    btreeClearHasContent(pBt);\n  }\n\n  btreeEndTransaction(p);\n  sqlite3BtreeLeave(p);\n  return SQLITE_OK;\n}\n\n/*\n** Do both phases of a commit.\n*/\nSQLITE_PRIVATE int sqlite3BtreeCommit(Btree *p){\n  int rc;\n  sqlite3BtreeEnter(p);\n  rc = sqlite3BtreeCommitPhaseOne(p, 0);\n  if( rc==SQLITE_OK ){\n    rc = sqlite3BtreeCommitPhaseTwo(p, 0);\n  }\n  sqlite3BtreeLeave(p);\n  return rc;\n}\n\n/*\n** This routine sets the state to CURSOR_FAULT and the error\n** code to errCode for every cursor on any BtShared that pBtree\n** references.  Or if the writeOnly flag is set to 1, then only\n** trip write cursors and leave read cursors unchanged.\n**\n** Every cursor is a candidate to be tripped, including cursors\n** that belong to other database connections that happen to be\n** sharing the cache with pBtree.\n**\n** This routine gets called when a rollback occurs. If the writeOnly\n** flag is true, then only write-cursors need be tripped - read-only\n** cursors save their current positions so that they may continue \n** following the rollback. Or, if writeOnly is false, all cursors are \n** tripped. In general, writeOnly is false if the transaction being\n** rolled back modified the database schema. In this case b-tree root\n** pages may be moved or deleted from the database altogether, making\n** it unsafe for read cursors to continue.\n**\n** If the writeOnly flag is true and an error is encountered while \n** saving the current position of a read-only cursor, all cursors, \n** including all read-cursors are tripped.\n**\n** SQLITE_OK is returned if successful, or if an error occurs while\n** saving a cursor position, an SQLite error code.\n*/\nSQLITE_PRIVATE int sqlite3BtreeTripAllCursors(Btree *pBtree, int errCode, int writeOnly){\n  BtCursor *p;\n  int rc = SQLITE_OK;\n\n  assert( (writeOnly==0 || writeOnly==1) && BTCF_WriteFlag==1 );\n  if( pBtree ){\n    sqlite3BtreeEnter(pBtree);\n    for(p=pBtree->pBt->pCursor; p; p=p->pNext){\n      if( writeOnly && (p->curFlags & BTCF_WriteFlag)==0 ){\n        if( p->eState==CURSOR_VALID || p->eState==CURSOR_SKIPNEXT ){\n          rc = saveCursorPosition(p);\n          if( rc!=SQLITE_OK ){\n            (void)sqlite3BtreeTripAllCursors(pBtree, rc, 0);\n            break;\n          }\n        }\n      }else{\n        sqlite3BtreeClearCursor(p);\n        p->eState = CURSOR_FAULT;\n        p->skipNext = errCode;\n      }\n      btreeReleaseAllCursorPages(p);\n    }\n    sqlite3BtreeLeave(pBtree);\n  }\n  return rc;\n}\n\n/*\n** Rollback the transaction in progress.\n**\n** If tripCode is not SQLITE_OK then cursors will be invalidated (tripped).\n** Only write cursors are tripped if writeOnly is true but all cursors are\n** tripped if writeOnly is false.  Any attempt to use\n** a tripped cursor will result in an error.\n**\n** This will release the write lock on the database file.  If there\n** are no active cursors, it also releases the read lock.\n*/\nSQLITE_PRIVATE int sqlite3BtreeRollback(Btree *p, int tripCode, int writeOnly){\n  int rc;\n  BtShared *pBt = p->pBt;\n  MemPage *pPage1;\n\n  assert( writeOnly==1 || writeOnly==0 );\n  assert( tripCode==SQLITE_ABORT_ROLLBACK || tripCode==SQLITE_OK );\n  sqlite3BtreeEnter(p);\n  if( tripCode==SQLITE_OK ){\n    rc = tripCode = saveAllCursors(pBt, 0, 0);\n    if( rc ) writeOnly = 0;\n  }else{\n    rc = SQLITE_OK;\n  }\n  if( tripCode ){\n    int rc2 = sqlite3BtreeTripAllCursors(p, tripCode, writeOnly);\n    assert( rc==SQLITE_OK || (writeOnly==0 && rc2==SQLITE_OK) );\n    if( rc2!=SQLITE_OK ) rc = rc2;\n  }\n  btreeIntegrity(p);\n\n  if( p->inTrans==TRANS_WRITE ){\n    int rc2;\n\n    assert( TRANS_WRITE==pBt->inTransaction );\n    rc2 = sqlite3PagerRollback(pBt->pPager);\n    if( rc2!=SQLITE_OK ){\n      rc = rc2;\n    }\n\n    /* The rollback may have destroyed the pPage1->aData value.  So\n    ** call btreeGetPage() on page 1 again to make\n    ** sure pPage1->aData is set correctly. */\n    if( btreeGetPage(pBt, 1, &pPage1, 0)==SQLITE_OK ){\n      int nPage = get4byte(28+(u8*)pPage1->aData);\n      testcase( nPage==0 );\n      if( nPage==0 ) sqlite3PagerPagecount(pBt->pPager, &nPage);\n      testcase( pBt->nPage!=nPage );\n      pBt->nPage = nPage;\n      releasePageOne(pPage1);\n    }\n    assert( countValidCursors(pBt, 1)==0 );\n    pBt->inTransaction = TRANS_READ;\n    btreeClearHasContent(pBt);\n  }\n\n  btreeEndTransaction(p);\n  sqlite3BtreeLeave(p);\n  return rc;\n}\n\n/*\n** Start a statement subtransaction. The subtransaction can be rolled\n** back independently of the main transaction. You must start a transaction \n** before starting a subtransaction. The subtransaction is ended automatically \n** if the main transaction commits or rolls back.\n**\n** Statement subtransactions are used around individual SQL statements\n** that are contained within a BEGIN...COMMIT block.  If a constraint\n** error occurs within the statement, the effect of that one statement\n** can be rolled back without having to rollback the entire transaction.\n**\n** A statement sub-transaction is implemented as an anonymous savepoint. The\n** value passed as the second parameter is the total number of savepoints,\n** including the new anonymous savepoint, open on the B-Tree. i.e. if there\n** are no active savepoints and no other statement-transactions open,\n** iStatement is 1. This anonymous savepoint can be released or rolled back\n** using the sqlite3BtreeSavepoint() function.\n*/\nSQLITE_PRIVATE int sqlite3BtreeBeginStmt(Btree *p, int iStatement){\n  int rc;\n  BtShared *pBt = p->pBt;\n  sqlite3BtreeEnter(p);\n  assert( p->inTrans==TRANS_WRITE );\n  assert( (pBt->btsFlags & BTS_READ_ONLY)==0 );\n  assert( iStatement>0 );\n  assert( iStatement>p->db->nSavepoint );\n  assert( pBt->inTransaction==TRANS_WRITE );\n  /* At the pager level, a statement transaction is a savepoint with\n  ** an index greater than all savepoints created explicitly using\n  ** SQL statements. It is illegal to open, release or rollback any\n  ** such savepoints while the statement transaction savepoint is active.\n  */\n  rc = sqlite3PagerOpenSavepoint(pBt->pPager, iStatement);\n  sqlite3BtreeLeave(p);\n  return rc;\n}\n\n/*\n** The second argument to this function, op, is always SAVEPOINT_ROLLBACK\n** or SAVEPOINT_RELEASE. This function either releases or rolls back the\n** savepoint identified by parameter iSavepoint, depending on the value \n** of op.\n**\n** Normally, iSavepoint is greater than or equal to zero. However, if op is\n** SAVEPOINT_ROLLBACK, then iSavepoint may also be -1. In this case the \n** contents of the entire transaction are rolled back. This is different\n** from a normal transaction rollback, as no locks are released and the\n** transaction remains open.\n*/\nSQLITE_PRIVATE int sqlite3BtreeSavepoint(Btree *p, int op, int iSavepoint){\n  int rc = SQLITE_OK;\n  if( p && p->inTrans==TRANS_WRITE ){\n    BtShared *pBt = p->pBt;\n    assert( op==SAVEPOINT_RELEASE || op==SAVEPOINT_ROLLBACK );\n    assert( iSavepoint>=0 || (iSavepoint==-1 && op==SAVEPOINT_ROLLBACK) );\n    sqlite3BtreeEnter(p);\n    if( op==SAVEPOINT_ROLLBACK ){\n      rc = saveAllCursors(pBt, 0, 0);\n    }\n    if( rc==SQLITE_OK ){\n      rc = sqlite3PagerSavepoint(pBt->pPager, op, iSavepoint);\n    }\n    if( rc==SQLITE_OK ){\n      if( iSavepoint<0 && (pBt->btsFlags & BTS_INITIALLY_EMPTY)!=0 ){\n        pBt->nPage = 0;\n      }\n      rc = newDatabase(pBt);\n      pBt->nPage = get4byte(28 + pBt->pPage1->aData);\n\n      /* The database size was written into the offset 28 of the header\n      ** when the transaction started, so we know that the value at offset\n      ** 28 is nonzero. */\n      assert( pBt->nPage>0 );\n    }\n    sqlite3BtreeLeave(p);\n  }\n  return rc;\n}\n\n/*\n** Create a new cursor for the BTree whose root is on the page\n** iTable. If a read-only cursor is requested, it is assumed that\n** the caller already has at least a read-only transaction open\n** on the database already. If a write-cursor is requested, then\n** the caller is assumed to have an open write transaction.\n**\n** If the BTREE_WRCSR bit of wrFlag is clear, then the cursor can only\n** be used for reading.  If the BTREE_WRCSR bit is set, then the cursor\n** can be used for reading or for writing if other conditions for writing\n** are also met.  These are the conditions that must be met in order\n** for writing to be allowed:\n**\n** 1:  The cursor must have been opened with wrFlag containing BTREE_WRCSR\n**\n** 2:  Other database connections that share the same pager cache\n**     but which are not in the READ_UNCOMMITTED state may not have\n**     cursors open with wrFlag==0 on the same table.  Otherwise\n**     the changes made by this write cursor would be visible to\n**     the read cursors in the other database connection.\n**\n** 3:  The database must be writable (not on read-only media)\n**\n** 4:  There must be an active transaction.\n**\n** The BTREE_FORDELETE bit of wrFlag may optionally be set if BTREE_WRCSR\n** is set.  If FORDELETE is set, that is a hint to the implementation that\n** this cursor will only be used to seek to and delete entries of an index\n** as part of a larger DELETE statement.  The FORDELETE hint is not used by\n** this implementation.  But in a hypothetical alternative storage engine \n** in which index entries are automatically deleted when corresponding table\n** rows are deleted, the FORDELETE flag is a hint that all SEEK and DELETE\n** operations on this cursor can be no-ops and all READ operations can \n** return a null row (2-bytes: 0x01 0x00).\n**\n** No checking is done to make sure that page iTable really is the\n** root page of a b-tree.  If it is not, then the cursor acquired\n** will not work correctly.\n**\n** It is assumed that the sqlite3BtreeCursorZero() has been called\n** on pCur to initialize the memory space prior to invoking this routine.\n*/\nstatic int btreeCursor(\n  Btree *p,                              /* The btree */\n  int iTable,                            /* Root page of table to open */\n  int wrFlag,                            /* 1 to write. 0 read-only */\n  struct KeyInfo *pKeyInfo,              /* First arg to comparison function */\n  BtCursor *pCur                         /* Space for new cursor */\n){\n  BtShared *pBt = p->pBt;                /* Shared b-tree handle */\n  BtCursor *pX;                          /* Looping over other all cursors */\n\n  assert( sqlite3BtreeHoldsMutex(p) );\n  assert( wrFlag==0 \n       || wrFlag==BTREE_WRCSR \n       || wrFlag==(BTREE_WRCSR|BTREE_FORDELETE) \n  );\n\n  /* The following assert statements verify that if this is a sharable \n  ** b-tree database, the connection is holding the required table locks, \n  ** and that no other connection has any open cursor that conflicts with \n  ** this lock.  */\n  assert( hasSharedCacheTableLock(p, iTable, pKeyInfo!=0, (wrFlag?2:1)) );\n  assert( wrFlag==0 || !hasReadConflicts(p, iTable) );\n\n  /* Assert that the caller has opened the required transaction. */\n  assert( p->inTrans>TRANS_NONE );\n  assert( wrFlag==0 || p->inTrans==TRANS_WRITE );\n  assert( pBt->pPage1 && pBt->pPage1->aData );\n  assert( wrFlag==0 || (pBt->btsFlags & BTS_READ_ONLY)==0 );\n\n  if( wrFlag ){\n    allocateTempSpace(pBt);\n    if( pBt->pTmpSpace==0 ) return SQLITE_NOMEM_BKPT;\n  }\n  if( iTable==1 && btreePagecount(pBt)==0 ){\n    assert( wrFlag==0 );\n    iTable = 0;\n  }\n\n  /* Now that no other errors can occur, finish filling in the BtCursor\n  ** variables and link the cursor into the BtShared list.  */\n  pCur->pgnoRoot = (Pgno)iTable;\n  pCur->iPage = -1;\n  pCur->pKeyInfo = pKeyInfo;\n  pCur->pBtree = p;\n  pCur->pBt = pBt;\n  pCur->curFlags = wrFlag ? BTCF_WriteFlag : 0;\n  pCur->curPagerFlags = wrFlag ? 0 : PAGER_GET_READONLY;\n  /* If there are two or more cursors on the same btree, then all such\n  ** cursors *must* have the BTCF_Multiple flag set. */\n  for(pX=pBt->pCursor; pX; pX=pX->pNext){\n    if( pX->pgnoRoot==(Pgno)iTable ){\n      pX->curFlags |= BTCF_Multiple;\n      pCur->curFlags |= BTCF_Multiple;\n    }\n  }\n  pCur->pNext = pBt->pCursor;\n  pBt->pCursor = pCur;\n  pCur->eState = CURSOR_INVALID;\n  return SQLITE_OK;\n}\nSQLITE_PRIVATE int sqlite3BtreeCursor(\n  Btree *p,                                   /* The btree */\n  int iTable,                                 /* Root page of table to open */\n  int wrFlag,                                 /* 1 to write. 0 read-only */\n  struct KeyInfo *pKeyInfo,                   /* First arg to xCompare() */\n  BtCursor *pCur                              /* Write new cursor here */\n){\n  int rc;\n  if( iTable<1 ){\n    rc = SQLITE_CORRUPT_BKPT;\n  }else{\n    sqlite3BtreeEnter(p);\n    rc = btreeCursor(p, iTable, wrFlag, pKeyInfo, pCur);\n    sqlite3BtreeLeave(p);\n  }\n  return rc;\n}\n\n/*\n** Return the size of a BtCursor object in bytes.\n**\n** This interfaces is needed so that users of cursors can preallocate\n** sufficient storage to hold a cursor.  The BtCursor object is opaque\n** to users so they cannot do the sizeof() themselves - they must call\n** this routine.\n*/\nSQLITE_PRIVATE int sqlite3BtreeCursorSize(void){\n  return ROUND8(sizeof(BtCursor));\n}\n\n/*\n** Initialize memory that will be converted into a BtCursor object.\n**\n** The simple approach here would be to memset() the entire object\n** to zero.  But it turns out that the apPage[] and aiIdx[] arrays\n** do not need to be zeroed and they are large, so we can save a lot\n** of run-time by skipping the initialization of those elements.\n*/\nSQLITE_PRIVATE void sqlite3BtreeCursorZero(BtCursor *p){\n  memset(p, 0, offsetof(BtCursor, BTCURSOR_FIRST_UNINIT));\n}\n\n/*\n** Close a cursor.  The read lock on the database file is released\n** when the last cursor is closed.\n*/\nSQLITE_PRIVATE int sqlite3BtreeCloseCursor(BtCursor *pCur){\n  Btree *pBtree = pCur->pBtree;\n  if( pBtree ){\n    BtShared *pBt = pCur->pBt;\n    sqlite3BtreeEnter(pBtree);\n    assert( pBt->pCursor!=0 );\n    if( pBt->pCursor==pCur ){\n      pBt->pCursor = pCur->pNext;\n    }else{\n      BtCursor *pPrev = pBt->pCursor;\n      do{\n        if( pPrev->pNext==pCur ){\n          pPrev->pNext = pCur->pNext;\n          break;\n        }\n        pPrev = pPrev->pNext;\n      }while( ALWAYS(pPrev) );\n    }\n    btreeReleaseAllCursorPages(pCur);\n    unlockBtreeIfUnused(pBt);\n    sqlite3_free(pCur->aOverflow);\n    sqlite3_free(pCur->pKey);\n    sqlite3BtreeLeave(pBtree);\n    pCur->pBtree = 0;\n  }\n  return SQLITE_OK;\n}\n\n/*\n** Make sure the BtCursor* given in the argument has a valid\n** BtCursor.info structure.  If it is not already valid, call\n** btreeParseCell() to fill it in.\n**\n** BtCursor.info is a cache of the information in the current cell.\n** Using this cache reduces the number of calls to btreeParseCell().\n*/\n#ifndef NDEBUG\n  static int cellInfoEqual(CellInfo *a, CellInfo *b){\n    if( a->nKey!=b->nKey ) return 0;\n    if( a->pPayload!=b->pPayload ) return 0;\n    if( a->nPayload!=b->nPayload ) return 0;\n    if( a->nLocal!=b->nLocal ) return 0;\n    if( a->nSize!=b->nSize ) return 0;\n    return 1;\n  }\n  static void assertCellInfo(BtCursor *pCur){\n    CellInfo info;\n    memset(&info, 0, sizeof(info));\n    btreeParseCell(pCur->pPage, pCur->ix, &info);\n    assert( CORRUPT_DB || cellInfoEqual(&info, &pCur->info) );\n  }\n#else\n  #define assertCellInfo(x)\n#endif\nstatic SQLITE_NOINLINE void getCellInfo(BtCursor *pCur){\n  if( pCur->info.nSize==0 ){\n    pCur->curFlags |= BTCF_ValidNKey;\n    btreeParseCell(pCur->pPage,pCur->ix,&pCur->info);\n  }else{\n    assertCellInfo(pCur);\n  }\n}\n\n#ifndef NDEBUG  /* The next routine used only within assert() statements */\n/*\n** Return true if the given BtCursor is valid.  A valid cursor is one\n** that is currently pointing to a row in a (non-empty) table.\n** This is a verification routine is used only within assert() statements.\n*/\nSQLITE_PRIVATE int sqlite3BtreeCursorIsValid(BtCursor *pCur){\n  return pCur && pCur->eState==CURSOR_VALID;\n}\n#endif /* NDEBUG */\nSQLITE_PRIVATE int sqlite3BtreeCursorIsValidNN(BtCursor *pCur){\n  assert( pCur!=0 );\n  return pCur->eState==CURSOR_VALID;\n}\n\n/*\n** Return the value of the integer key or \"rowid\" for a table btree.\n** This routine is only valid for a cursor that is pointing into a\n** ordinary table btree.  If the cursor points to an index btree or\n** is invalid, the result of this routine is undefined.\n*/\nSQLITE_PRIVATE i64 sqlite3BtreeIntegerKey(BtCursor *pCur){\n  assert( cursorHoldsMutex(pCur) );\n  assert( pCur->eState==CURSOR_VALID );\n  assert( pCur->curIntKey );\n  getCellInfo(pCur);\n  return pCur->info.nKey;\n}\n\n#ifdef SQLITE_ENABLE_OFFSET_SQL_FUNC\n/*\n** Return the offset into the database file for the start of the\n** payload to which the cursor is pointing.\n*/\nSQLITE_PRIVATE i64 sqlite3BtreeOffset(BtCursor *pCur){\n  assert( cursorHoldsMutex(pCur) );\n  assert( pCur->eState==CURSOR_VALID );\n  getCellInfo(pCur);\n  return (i64)pCur->pBt->pageSize*((i64)pCur->pPage->pgno - 1) +\n         (i64)(pCur->info.pPayload - pCur->pPage->aData);\n}\n#endif /* SQLITE_ENABLE_OFFSET_SQL_FUNC */\n\n/*\n** Return the number of bytes of payload for the entry that pCur is\n** currently pointing to.  For table btrees, this will be the amount\n** of data.  For index btrees, this will be the size of the key.\n**\n** The caller must guarantee that the cursor is pointing to a non-NULL\n** valid entry.  In other words, the calling procedure must guarantee\n** that the cursor has Cursor.eState==CURSOR_VALID.\n*/\nSQLITE_PRIVATE u32 sqlite3BtreePayloadSize(BtCursor *pCur){\n  assert( cursorHoldsMutex(pCur) );\n  assert( pCur->eState==CURSOR_VALID );\n  getCellInfo(pCur);\n  return pCur->info.nPayload;\n}\n\n/*\n** Return an upper bound on the size of any record for the table\n** that the cursor is pointing into.\n**\n** This is an optimization.  Everything will still work if this\n** routine always returns 2147483647 (which is the largest record\n** that SQLite can handle) or more.  But returning a smaller value might\n** prevent large memory allocations when trying to interpret a\n** corrupt datrabase.\n**\n** The current implementation merely returns the size of the underlying\n** database file.\n*/\nSQLITE_PRIVATE sqlite3_int64 sqlite3BtreeMaxRecordSize(BtCursor *pCur){\n  assert( cursorHoldsMutex(pCur) );\n  assert( pCur->eState==CURSOR_VALID );\n  return pCur->pBt->pageSize * (sqlite3_int64)pCur->pBt->nPage;\n}\n\n/*\n** Given the page number of an overflow page in the database (parameter\n** ovfl), this function finds the page number of the next page in the \n** linked list of overflow pages. If possible, it uses the auto-vacuum\n** pointer-map data instead of reading the content of page ovfl to do so. \n**\n** If an error occurs an SQLite error code is returned. Otherwise:\n**\n** The page number of the next overflow page in the linked list is \n** written to *pPgnoNext. If page ovfl is the last page in its linked \n** list, *pPgnoNext is set to zero. \n**\n** If ppPage is not NULL, and a reference to the MemPage object corresponding\n** to page number pOvfl was obtained, then *ppPage is set to point to that\n** reference. It is the responsibility of the caller to call releasePage()\n** on *ppPage to free the reference. In no reference was obtained (because\n** the pointer-map was used to obtain the value for *pPgnoNext), then\n** *ppPage is set to zero.\n*/\nstatic int getOverflowPage(\n  BtShared *pBt,               /* The database file */\n  Pgno ovfl,                   /* Current overflow page number */\n  MemPage **ppPage,            /* OUT: MemPage handle (may be NULL) */\n  Pgno *pPgnoNext              /* OUT: Next overflow page number */\n){\n  Pgno next = 0;\n  MemPage *pPage = 0;\n  int rc = SQLITE_OK;\n\n  assert( sqlite3_mutex_held(pBt->mutex) );\n  assert(pPgnoNext);\n\n#ifndef SQLITE_OMIT_AUTOVACUUM\n  /* Try to find the next page in the overflow list using the\n  ** autovacuum pointer-map pages. Guess that the next page in \n  ** the overflow list is page number (ovfl+1). If that guess turns \n  ** out to be wrong, fall back to loading the data of page \n  ** number ovfl to determine the next page number.\n  */\n  if( pBt->autoVacuum ){\n    Pgno pgno;\n    Pgno iGuess = ovfl+1;\n    u8 eType;\n\n    while( PTRMAP_ISPAGE(pBt, iGuess) || iGuess==PENDING_BYTE_PAGE(pBt) ){\n      iGuess++;\n    }\n\n    if( iGuess<=btreePagecount(pBt) ){\n      rc = ptrmapGet(pBt, iGuess, &eType, &pgno);\n      if( rc==SQLITE_OK && eType==PTRMAP_OVERFLOW2 && pgno==ovfl ){\n        next = iGuess;\n        rc = SQLITE_DONE;\n      }\n    }\n  }\n#endif\n\n  assert( next==0 || rc==SQLITE_DONE );\n  if( rc==SQLITE_OK ){\n    rc = btreeGetPage(pBt, ovfl, &pPage, (ppPage==0) ? PAGER_GET_READONLY : 0);\n    assert( rc==SQLITE_OK || pPage==0 );\n    if( rc==SQLITE_OK ){\n      next = get4byte(pPage->aData);\n    }\n  }\n\n  *pPgnoNext = next;\n  if( ppPage ){\n    *ppPage = pPage;\n  }else{\n    releasePage(pPage);\n  }\n  return (rc==SQLITE_DONE ? SQLITE_OK : rc);\n}\n\n/*\n** Copy data from a buffer to a page, or from a page to a buffer.\n**\n** pPayload is a pointer to data stored on database page pDbPage.\n** If argument eOp is false, then nByte bytes of data are copied\n** from pPayload to the buffer pointed at by pBuf. If eOp is true,\n** then sqlite3PagerWrite() is called on pDbPage and nByte bytes\n** of data are copied from the buffer pBuf to pPayload.\n**\n** SQLITE_OK is returned on success, otherwise an error code.\n*/\nstatic int copyPayload(\n  void *pPayload,           /* Pointer to page data */\n  void *pBuf,               /* Pointer to buffer */\n  int nByte,                /* Number of bytes to copy */\n  int eOp,                  /* 0 -> copy from page, 1 -> copy to page */\n  DbPage *pDbPage           /* Page containing pPayload */\n){\n  if( eOp ){\n    /* Copy data from buffer to page (a write operation) */\n    int rc = sqlite3PagerWrite(pDbPage);\n    if( rc!=SQLITE_OK ){\n      return rc;\n    }\n    memcpy(pPayload, pBuf, nByte);\n  }else{\n    /* Copy data from page to buffer (a read operation) */\n    memcpy(pBuf, pPayload, nByte);\n  }\n  return SQLITE_OK;\n}\n\n/*\n** This function is used to read or overwrite payload information\n** for the entry that the pCur cursor is pointing to. The eOp\n** argument is interpreted as follows:\n**\n**   0: The operation is a read. Populate the overflow cache.\n**   1: The operation is a write. Populate the overflow cache.\n**\n** A total of \"amt\" bytes are read or written beginning at \"offset\".\n** Data is read to or from the buffer pBuf.\n**\n** The content being read or written might appear on the main page\n** or be scattered out on multiple overflow pages.\n**\n** If the current cursor entry uses one or more overflow pages\n** this function may allocate space for and lazily populate\n** the overflow page-list cache array (BtCursor.aOverflow). \n** Subsequent calls use this cache to make seeking to the supplied offset \n** more efficient.\n**\n** Once an overflow page-list cache has been allocated, it must be\n** invalidated if some other cursor writes to the same table, or if\n** the cursor is moved to a different row. Additionally, in auto-vacuum\n** mode, the following events may invalidate an overflow page-list cache.\n**\n**   * An incremental vacuum,\n**   * A commit in auto_vacuum=\"full\" mode,\n**   * Creating a table (may require moving an overflow page).\n*/\nstatic int accessPayload(\n  BtCursor *pCur,      /* Cursor pointing to entry to read from */\n  u32 offset,          /* Begin reading this far into payload */\n  u32 amt,             /* Read this many bytes */\n  unsigned char *pBuf, /* Write the bytes into this buffer */ \n  int eOp              /* zero to read. non-zero to write. */\n){\n  unsigned char *aPayload;\n  int rc = SQLITE_OK;\n  int iIdx = 0;\n  MemPage *pPage = pCur->pPage;               /* Btree page of current entry */\n  BtShared *pBt = pCur->pBt;                  /* Btree this cursor belongs to */\n#ifdef SQLITE_DIRECT_OVERFLOW_READ\n  unsigned char * const pBufStart = pBuf;     /* Start of original out buffer */\n#endif\n\n  assert( pPage );\n  assert( eOp==0 || eOp==1 );\n  assert( pCur->eState==CURSOR_VALID );\n  assert( pCur->ix<pPage->nCell );\n  assert( cursorHoldsMutex(pCur) );\n\n  getCellInfo(pCur);\n  aPayload = pCur->info.pPayload;\n  assert( offset+amt <= pCur->info.nPayload );\n\n  assert( aPayload > pPage->aData );\n  if( (uptr)(aPayload - pPage->aData) > (pBt->usableSize - pCur->info.nLocal) ){\n    /* Trying to read or write past the end of the data is an error.  The\n    ** conditional above is really:\n    **    &aPayload[pCur->info.nLocal] > &pPage->aData[pBt->usableSize]\n    ** but is recast into its current form to avoid integer overflow problems\n    */\n    return SQLITE_CORRUPT_PAGE(pPage);\n  }\n\n  /* Check if data must be read/written to/from the btree page itself. */\n  if( offset<pCur->info.nLocal ){\n    int a = amt;\n    if( a+offset>pCur->info.nLocal ){\n      a = pCur->info.nLocal - offset;\n    }\n    rc = copyPayload(&aPayload[offset], pBuf, a, eOp, pPage->pDbPage);\n    offset = 0;\n    pBuf += a;\n    amt -= a;\n  }else{\n    offset -= pCur->info.nLocal;\n  }\n\n\n  if( rc==SQLITE_OK && amt>0 ){\n    const u32 ovflSize = pBt->usableSize - 4;  /* Bytes content per ovfl page */\n    Pgno nextPage;\n\n    nextPage = get4byte(&aPayload[pCur->info.nLocal]);\n\n    /* If the BtCursor.aOverflow[] has not been allocated, allocate it now.\n    **\n    ** The aOverflow[] array is sized at one entry for each overflow page\n    ** in the overflow chain. The page number of the first overflow page is\n    ** stored in aOverflow[0], etc. A value of 0 in the aOverflow[] array\n    ** means \"not yet known\" (the cache is lazily populated).\n    */\n    if( (pCur->curFlags & BTCF_ValidOvfl)==0 ){\n      int nOvfl = (pCur->info.nPayload-pCur->info.nLocal+ovflSize-1)/ovflSize;\n      if( pCur->aOverflow==0\n       || nOvfl*(int)sizeof(Pgno) > sqlite3MallocSize(pCur->aOverflow)\n      ){\n        Pgno *aNew = (Pgno*)sqlite3Realloc(\n            pCur->aOverflow, nOvfl*2*sizeof(Pgno)\n        );\n        if( aNew==0 ){\n          return SQLITE_NOMEM_BKPT;\n        }else{\n          pCur->aOverflow = aNew;\n        }\n      }\n      memset(pCur->aOverflow, 0, nOvfl*sizeof(Pgno));\n      pCur->curFlags |= BTCF_ValidOvfl;\n    }else{\n      /* If the overflow page-list cache has been allocated and the\n      ** entry for the first required overflow page is valid, skip\n      ** directly to it.\n      */\n      if( pCur->aOverflow[offset/ovflSize] ){\n        iIdx = (offset/ovflSize);\n        nextPage = pCur->aOverflow[iIdx];\n        offset = (offset%ovflSize);\n      }\n    }\n\n    assert( rc==SQLITE_OK && amt>0 );\n    while( nextPage ){\n      /* If required, populate the overflow page-list cache. */\n      assert( pCur->aOverflow[iIdx]==0\n              || pCur->aOverflow[iIdx]==nextPage\n              || CORRUPT_DB );\n      pCur->aOverflow[iIdx] = nextPage;\n\n      if( offset>=ovflSize ){\n        /* The only reason to read this page is to obtain the page\n        ** number for the next page in the overflow chain. The page\n        ** data is not required. So first try to lookup the overflow\n        ** page-list cache, if any, then fall back to the getOverflowPage()\n        ** function.\n        */\n        assert( pCur->curFlags & BTCF_ValidOvfl );\n        assert( pCur->pBtree->db==pBt->db );\n        if( pCur->aOverflow[iIdx+1] ){\n          nextPage = pCur->aOverflow[iIdx+1];\n        }else{\n          rc = getOverflowPage(pBt, nextPage, 0, &nextPage);\n        }\n        offset -= ovflSize;\n      }else{\n        /* Need to read this page properly. It contains some of the\n        ** range of data that is being read (eOp==0) or written (eOp!=0).\n        */\n        int a = amt;\n        if( a + offset > ovflSize ){\n          a = ovflSize - offset;\n        }\n\n#ifdef SQLITE_DIRECT_OVERFLOW_READ\n        /* If all the following are true:\n        **\n        **   1) this is a read operation, and \n        **   2) data is required from the start of this overflow page, and\n        **   3) there are no dirty pages in the page-cache\n        **   4) the database is file-backed, and\n        **   5) the page is not in the WAL file\n        **   6) at least 4 bytes have already been read into the output buffer \n        **\n        ** then data can be read directly from the database file into the\n        ** output buffer, bypassing the page-cache altogether. This speeds\n        ** up loading large records that span many overflow pages.\n        */\n        if( eOp==0                                             /* (1) */\n         && offset==0                                          /* (2) */\n         && sqlite3PagerDirectReadOk(pBt->pPager, nextPage)    /* (3,4,5) */\n         && &pBuf[-4]>=pBufStart                               /* (6) */\n        ){\n          sqlite3_file *fd = sqlite3PagerFile(pBt->pPager);\n          u8 aSave[4];\n          u8 *aWrite = &pBuf[-4];\n          assert( aWrite>=pBufStart );                         /* due to (6) */\n          memcpy(aSave, aWrite, 4);\n          rc = sqlite3OsRead(fd, aWrite, a+4, (i64)pBt->pageSize*(nextPage-1));\n          nextPage = get4byte(aWrite);\n          memcpy(aWrite, aSave, 4);\n        }else\n#endif\n\n        {\n          DbPage *pDbPage;\n          rc = sqlite3PagerGet(pBt->pPager, nextPage, &pDbPage,\n              (eOp==0 ? PAGER_GET_READONLY : 0)\n          );\n          if( rc==SQLITE_OK ){\n            aPayload = sqlite3PagerGetData(pDbPage);\n            nextPage = get4byte(aPayload);\n            rc = copyPayload(&aPayload[offset+4], pBuf, a, eOp, pDbPage);\n            sqlite3PagerUnref(pDbPage);\n            offset = 0;\n          }\n        }\n        amt -= a;\n        if( amt==0 ) return rc;\n        pBuf += a;\n      }\n      if( rc ) break;\n      iIdx++;\n    }\n  }\n\n  if( rc==SQLITE_OK && amt>0 ){\n    /* Overflow chain ends prematurely */\n    return SQLITE_CORRUPT_PAGE(pPage);\n  }\n  return rc;\n}\n\n/*\n** Read part of the payload for the row at which that cursor pCur is currently\n** pointing.  \"amt\" bytes will be transferred into pBuf[].  The transfer\n** begins at \"offset\".\n**\n** pCur can be pointing to either a table or an index b-tree.\n** If pointing to a table btree, then the content section is read.  If\n** pCur is pointing to an index b-tree then the key section is read.\n**\n** For sqlite3BtreePayload(), the caller must ensure that pCur is pointing\n** to a valid row in the table.  For sqlite3BtreePayloadChecked(), the\n** cursor might be invalid or might need to be restored before being read.\n**\n** Return SQLITE_OK on success or an error code if anything goes\n** wrong.  An error is returned if \"offset+amt\" is larger than\n** the available payload.\n*/\nSQLITE_PRIVATE int sqlite3BtreePayload(BtCursor *pCur, u32 offset, u32 amt, void *pBuf){\n  assert( cursorHoldsMutex(pCur) );\n  assert( pCur->eState==CURSOR_VALID );\n  assert( pCur->iPage>=0 && pCur->pPage );\n  assert( pCur->ix<pCur->pPage->nCell );\n  return accessPayload(pCur, offset, amt, (unsigned char*)pBuf, 0);\n}\n\n/*\n** This variant of sqlite3BtreePayload() works even if the cursor has not\n** in the CURSOR_VALID state.  It is only used by the sqlite3_blob_read()\n** interface.\n*/\n#ifndef SQLITE_OMIT_INCRBLOB\nstatic SQLITE_NOINLINE int accessPayloadChecked(\n  BtCursor *pCur,\n  u32 offset,\n  u32 amt,\n  void *pBuf\n){\n  int rc;\n  if ( pCur->eState==CURSOR_INVALID ){\n    return SQLITE_ABORT;\n  }\n  assert( cursorOwnsBtShared(pCur) );\n  rc = btreeRestoreCursorPosition(pCur);\n  return rc ? rc : accessPayload(pCur, offset, amt, pBuf, 0);\n}\nSQLITE_PRIVATE int sqlite3BtreePayloadChecked(BtCursor *pCur, u32 offset, u32 amt, void *pBuf){\n  if( pCur->eState==CURSOR_VALID ){\n    assert( cursorOwnsBtShared(pCur) );\n    return accessPayload(pCur, offset, amt, pBuf, 0);\n  }else{\n    return accessPayloadChecked(pCur, offset, amt, pBuf);\n  }\n}\n#endif /* SQLITE_OMIT_INCRBLOB */\n\n/*\n** Return a pointer to payload information from the entry that the \n** pCur cursor is pointing to.  The pointer is to the beginning of\n** the key if index btrees (pPage->intKey==0) and is the data for\n** table btrees (pPage->intKey==1). The number of bytes of available\n** key/data is written into *pAmt.  If *pAmt==0, then the value\n** returned will not be a valid pointer.\n**\n** This routine is an optimization.  It is common for the entire key\n** and data to fit on the local page and for there to be no overflow\n** pages.  When that is so, this routine can be used to access the\n** key and data without making a copy.  If the key and/or data spills\n** onto overflow pages, then accessPayload() must be used to reassemble\n** the key/data and copy it into a preallocated buffer.\n**\n** The pointer returned by this routine looks directly into the cached\n** page of the database.  The data might change or move the next time\n** any btree routine is called.\n*/\nstatic const void *fetchPayload(\n  BtCursor *pCur,      /* Cursor pointing to entry to read from */\n  u32 *pAmt            /* Write the number of available bytes here */\n){\n  int amt;\n  assert( pCur!=0 && pCur->iPage>=0 && pCur->pPage);\n  assert( pCur->eState==CURSOR_VALID );\n  assert( sqlite3_mutex_held(pCur->pBtree->db->mutex) );\n  assert( cursorOwnsBtShared(pCur) );\n  assert( pCur->ix<pCur->pPage->nCell );\n  assert( pCur->info.nSize>0 );\n  assert( pCur->info.pPayload>pCur->pPage->aData || CORRUPT_DB );\n  assert( pCur->info.pPayload<pCur->pPage->aDataEnd ||CORRUPT_DB);\n  amt = pCur->info.nLocal;\n  if( amt>(int)(pCur->pPage->aDataEnd - pCur->info.pPayload) ){\n    /* There is too little space on the page for the expected amount\n    ** of local content. Database must be corrupt. */\n    assert( CORRUPT_DB );\n    amt = MAX(0, (int)(pCur->pPage->aDataEnd - pCur->info.pPayload));\n  }\n  *pAmt = (u32)amt;\n  return (void*)pCur->info.pPayload;\n}\n\n\n/*\n** For the entry that cursor pCur is point to, return as\n** many bytes of the key or data as are available on the local\n** b-tree page.  Write the number of available bytes into *pAmt.\n**\n** The pointer returned is ephemeral.  The key/data may move\n** or be destroyed on the next call to any Btree routine,\n** including calls from other threads against the same cache.\n** Hence, a mutex on the BtShared should be held prior to calling\n** this routine.\n**\n** These routines is used to get quick access to key and data\n** in the common case where no overflow pages are used.\n*/\nSQLITE_PRIVATE const void *sqlite3BtreePayloadFetch(BtCursor *pCur, u32 *pAmt){\n  return fetchPayload(pCur, pAmt);\n}\n\n\n/*\n** Move the cursor down to a new child page.  The newPgno argument is the\n** page number of the child page to move to.\n**\n** This function returns SQLITE_CORRUPT if the page-header flags field of\n** the new child page does not match the flags field of the parent (i.e.\n** if an intkey page appears to be the parent of a non-intkey page, or\n** vice-versa).\n*/\nstatic int moveToChild(BtCursor *pCur, u32 newPgno){\n  BtShared *pBt = pCur->pBt;\n\n  assert( cursorOwnsBtShared(pCur) );\n  assert( pCur->eState==CURSOR_VALID );\n  assert( pCur->iPage<BTCURSOR_MAX_DEPTH );\n  assert( pCur->iPage>=0 );\n  if( pCur->iPage>=(BTCURSOR_MAX_DEPTH-1) ){\n    return SQLITE_CORRUPT_BKPT;\n  }\n  pCur->info.nSize = 0;\n  pCur->curFlags &= ~(BTCF_ValidNKey|BTCF_ValidOvfl);\n  pCur->aiIdx[pCur->iPage] = pCur->ix;\n  pCur->apPage[pCur->iPage] = pCur->pPage;\n  pCur->ix = 0;\n  pCur->iPage++;\n  return getAndInitPage(pBt, newPgno, &pCur->pPage, pCur, pCur->curPagerFlags);\n}\n\n#ifdef SQLITE_DEBUG\n/*\n** Page pParent is an internal (non-leaf) tree page. This function \n** asserts that page number iChild is the left-child if the iIdx'th\n** cell in page pParent. Or, if iIdx is equal to the total number of\n** cells in pParent, that page number iChild is the right-child of\n** the page.\n*/\nstatic void assertParentIndex(MemPage *pParent, int iIdx, Pgno iChild){\n  if( CORRUPT_DB ) return;  /* The conditions tested below might not be true\n                            ** in a corrupt database */\n  assert( iIdx<=pParent->nCell );\n  if( iIdx==pParent->nCell ){\n    assert( get4byte(&pParent->aData[pParent->hdrOffset+8])==iChild );\n  }else{\n    assert( get4byte(findCell(pParent, iIdx))==iChild );\n  }\n}\n#else\n#  define assertParentIndex(x,y,z) \n#endif\n\n/*\n** Move the cursor up to the parent page.\n**\n** pCur->idx is set to the cell index that contains the pointer\n** to the page we are coming from.  If we are coming from the\n** right-most child page then pCur->idx is set to one more than\n** the largest cell index.\n*/\nstatic void moveToParent(BtCursor *pCur){\n  MemPage *pLeaf;\n  assert( cursorOwnsBtShared(pCur) );\n  assert( pCur->eState==CURSOR_VALID );\n  assert( pCur->iPage>0 );\n  assert( pCur->pPage );\n  assertParentIndex(\n    pCur->apPage[pCur->iPage-1], \n    pCur->aiIdx[pCur->iPage-1], \n    pCur->pPage->pgno\n  );\n  testcase( pCur->aiIdx[pCur->iPage-1] > pCur->apPage[pCur->iPage-1]->nCell );\n  pCur->info.nSize = 0;\n  pCur->curFlags &= ~(BTCF_ValidNKey|BTCF_ValidOvfl);\n  pCur->ix = pCur->aiIdx[pCur->iPage-1];\n  pLeaf = pCur->pPage;\n  pCur->pPage = pCur->apPage[--pCur->iPage];\n  releasePageNotNull(pLeaf);\n}\n\n/*\n** Move the cursor to point to the root page of its b-tree structure.\n**\n** If the table has a virtual root page, then the cursor is moved to point\n** to the virtual root page instead of the actual root page. A table has a\n** virtual root page when the actual root page contains no cells and a \n** single child page. This can only happen with the table rooted at page 1.\n**\n** If the b-tree structure is empty, the cursor state is set to \n** CURSOR_INVALID and this routine returns SQLITE_EMPTY. Otherwise,\n** the cursor is set to point to the first cell located on the root\n** (or virtual root) page and the cursor state is set to CURSOR_VALID.\n**\n** If this function returns successfully, it may be assumed that the\n** page-header flags indicate that the [virtual] root-page is the expected \n** kind of b-tree page (i.e. if when opening the cursor the caller did not\n** specify a KeyInfo structure the flags byte is set to 0x05 or 0x0D,\n** indicating a table b-tree, or if the caller did specify a KeyInfo \n** structure the flags byte is set to 0x02 or 0x0A, indicating an index\n** b-tree).\n*/\nstatic int moveToRoot(BtCursor *pCur){\n  MemPage *pRoot;\n  int rc = SQLITE_OK;\n\n  assert( cursorOwnsBtShared(pCur) );\n  assert( CURSOR_INVALID < CURSOR_REQUIRESEEK );\n  assert( CURSOR_VALID   < CURSOR_REQUIRESEEK );\n  assert( CURSOR_FAULT   > CURSOR_REQUIRESEEK );\n  assert( pCur->eState < CURSOR_REQUIRESEEK || pCur->iPage<0 );\n  assert( pCur->pgnoRoot>0 || pCur->iPage<0 );\n\n  if( pCur->iPage>=0 ){\n    if( pCur->iPage ){\n      releasePageNotNull(pCur->pPage);\n      while( --pCur->iPage ){\n        releasePageNotNull(pCur->apPage[pCur->iPage]);\n      }\n      pCur->pPage = pCur->apPage[0];\n      goto skip_init;\n    }\n  }else if( pCur->pgnoRoot==0 ){\n    pCur->eState = CURSOR_INVALID;\n    return SQLITE_EMPTY;\n  }else{\n    assert( pCur->iPage==(-1) );\n    if( pCur->eState>=CURSOR_REQUIRESEEK ){\n      if( pCur->eState==CURSOR_FAULT ){\n        assert( pCur->skipNext!=SQLITE_OK );\n        return pCur->skipNext;\n      }\n      sqlite3BtreeClearCursor(pCur);\n    }\n    rc = getAndInitPage(pCur->pBtree->pBt, pCur->pgnoRoot, &pCur->pPage,\n                        0, pCur->curPagerFlags);\n    if( rc!=SQLITE_OK ){\n      pCur->eState = CURSOR_INVALID;\n      return rc;\n    }\n    pCur->iPage = 0;\n    pCur->curIntKey = pCur->pPage->intKey;\n  }\n  pRoot = pCur->pPage;\n  assert( pRoot->pgno==pCur->pgnoRoot );\n\n  /* If pCur->pKeyInfo is not NULL, then the caller that opened this cursor\n  ** expected to open it on an index b-tree. Otherwise, if pKeyInfo is\n  ** NULL, the caller expects a table b-tree. If this is not the case,\n  ** return an SQLITE_CORRUPT error. \n  **\n  ** Earlier versions of SQLite assumed that this test could not fail\n  ** if the root page was already loaded when this function was called (i.e.\n  ** if pCur->iPage>=0). But this is not so if the database is corrupted \n  ** in such a way that page pRoot is linked into a second b-tree table \n  ** (or the freelist).  */\n  assert( pRoot->intKey==1 || pRoot->intKey==0 );\n  if( pRoot->isInit==0 || (pCur->pKeyInfo==0)!=pRoot->intKey ){\n    return SQLITE_CORRUPT_PAGE(pCur->pPage);\n  }\n\nskip_init:  \n  pCur->ix = 0;\n  pCur->info.nSize = 0;\n  pCur->curFlags &= ~(BTCF_AtLast|BTCF_ValidNKey|BTCF_ValidOvfl);\n\n  pRoot = pCur->pPage;\n  if( pRoot->nCell>0 ){\n    pCur->eState = CURSOR_VALID;\n  }else if( !pRoot->leaf ){\n    Pgno subpage;\n    if( pRoot->pgno!=1 ) return SQLITE_CORRUPT_BKPT;\n    subpage = get4byte(&pRoot->aData[pRoot->hdrOffset+8]);\n    pCur->eState = CURSOR_VALID;\n    rc = moveToChild(pCur, subpage);\n  }else{\n    pCur->eState = CURSOR_INVALID;\n    rc = SQLITE_EMPTY;\n  }\n  return rc;\n}\n\n/*\n** Move the cursor down to the left-most leaf entry beneath the\n** entry to which it is currently pointing.\n**\n** The left-most leaf is the one with the smallest key - the first\n** in ascending order.\n*/\nstatic int moveToLeftmost(BtCursor *pCur){\n  Pgno pgno;\n  int rc = SQLITE_OK;\n  MemPage *pPage;\n\n  assert( cursorOwnsBtShared(pCur) );\n  assert( pCur->eState==CURSOR_VALID );\n  while( rc==SQLITE_OK && !(pPage = pCur->pPage)->leaf ){\n    assert( pCur->ix<pPage->nCell );\n    pgno = get4byte(findCell(pPage, pCur->ix));\n    rc = moveToChild(pCur, pgno);\n  }\n  return rc;\n}\n\n/*\n** Move the cursor down to the right-most leaf entry beneath the\n** page to which it is currently pointing.  Notice the difference\n** between moveToLeftmost() and moveToRightmost().  moveToLeftmost()\n** finds the left-most entry beneath the *entry* whereas moveToRightmost()\n** finds the right-most entry beneath the *page*.\n**\n** The right-most entry is the one with the largest key - the last\n** key in ascending order.\n*/\nstatic int moveToRightmost(BtCursor *pCur){\n  Pgno pgno;\n  int rc = SQLITE_OK;\n  MemPage *pPage = 0;\n\n  assert( cursorOwnsBtShared(pCur) );\n  assert( pCur->eState==CURSOR_VALID );\n  while( !(pPage = pCur->pPage)->leaf ){\n    pgno = get4byte(&pPage->aData[pPage->hdrOffset+8]);\n    pCur->ix = pPage->nCell;\n    rc = moveToChild(pCur, pgno);\n    if( rc ) return rc;\n  }\n  pCur->ix = pPage->nCell-1;\n  assert( pCur->info.nSize==0 );\n  assert( (pCur->curFlags & BTCF_ValidNKey)==0 );\n  return SQLITE_OK;\n}\n\n/* Move the cursor to the first entry in the table.  Return SQLITE_OK\n** on success.  Set *pRes to 0 if the cursor actually points to something\n** or set *pRes to 1 if the table is empty.\n*/\nSQLITE_PRIVATE int sqlite3BtreeFirst(BtCursor *pCur, int *pRes){\n  int rc;\n\n  assert( cursorOwnsBtShared(pCur) );\n  assert( sqlite3_mutex_held(pCur->pBtree->db->mutex) );\n  rc = moveToRoot(pCur);\n  if( rc==SQLITE_OK ){\n    assert( pCur->pPage->nCell>0 );\n    *pRes = 0;\n    rc = moveToLeftmost(pCur);\n  }else if( rc==SQLITE_EMPTY ){\n    assert( pCur->pgnoRoot==0 || pCur->pPage->nCell==0 );\n    *pRes = 1;\n    rc = SQLITE_OK;\n  }\n  return rc;\n}\n\n/*\n** This function is a no-op if cursor pCur does not point to a valid row.\n** Otherwise, if pCur is valid, configure it so that the next call to\n** sqlite3BtreeNext() is a no-op.\n*/\n#ifndef SQLITE_OMIT_WINDOWFUNC\nSQLITE_PRIVATE void sqlite3BtreeSkipNext(BtCursor *pCur){\n  /* We believe that the cursor must always be in the valid state when\n  ** this routine is called, but the proof is difficult, so we add an\n  ** ALWaYS() test just in case we are wrong. */\n  if( ALWAYS(pCur->eState==CURSOR_VALID) ){\n    pCur->eState = CURSOR_SKIPNEXT;\n    pCur->skipNext = 1;\n  }\n}\n#endif /* SQLITE_OMIT_WINDOWFUNC */\n\n/* Move the cursor to the last entry in the table.  Return SQLITE_OK\n** on success.  Set *pRes to 0 if the cursor actually points to something\n** or set *pRes to 1 if the table is empty.\n*/\nSQLITE_PRIVATE int sqlite3BtreeLast(BtCursor *pCur, int *pRes){\n  int rc;\n \n  assert( cursorOwnsBtShared(pCur) );\n  assert( sqlite3_mutex_held(pCur->pBtree->db->mutex) );\n\n  /* If the cursor already points to the last entry, this is a no-op. */\n  if( CURSOR_VALID==pCur->eState && (pCur->curFlags & BTCF_AtLast)!=0 ){\n#ifdef SQLITE_DEBUG\n    /* This block serves to assert() that the cursor really does point \n    ** to the last entry in the b-tree. */\n    int ii;\n    for(ii=0; ii<pCur->iPage; ii++){\n      assert( pCur->aiIdx[ii]==pCur->apPage[ii]->nCell );\n    }\n    assert( pCur->ix==pCur->pPage->nCell-1 );\n    assert( pCur->pPage->leaf );\n#endif\n    return SQLITE_OK;\n  }\n\n  rc = moveToRoot(pCur);\n  if( rc==SQLITE_OK ){\n    assert( pCur->eState==CURSOR_VALID );\n    *pRes = 0;\n    rc = moveToRightmost(pCur);\n    if( rc==SQLITE_OK ){\n      pCur->curFlags |= BTCF_AtLast;\n    }else{\n      pCur->curFlags &= ~BTCF_AtLast;\n    }\n  }else if( rc==SQLITE_EMPTY ){\n    assert( pCur->pgnoRoot==0 || pCur->pPage->nCell==0 );\n    *pRes = 1;\n    rc = SQLITE_OK;\n  }\n  return rc;\n}\n\n/* Move the cursor so that it points to an entry near the key \n** specified by pIdxKey or intKey.   Return a success code.\n**\n** For INTKEY tables, the intKey parameter is used.  pIdxKey \n** must be NULL.  For index tables, pIdxKey is used and intKey\n** is ignored.\n**\n** If an exact match is not found, then the cursor is always\n** left pointing at a leaf page which would hold the entry if it\n** were present.  The cursor might point to an entry that comes\n** before or after the key.\n**\n** An integer is written into *pRes which is the result of\n** comparing the key with the entry to which the cursor is \n** pointing.  The meaning of the integer written into\n** *pRes is as follows:\n**\n**     *pRes<0      The cursor is left pointing at an entry that\n**                  is smaller than intKey/pIdxKey or if the table is empty\n**                  and the cursor is therefore left point to nothing.\n**\n**     *pRes==0     The cursor is left pointing at an entry that\n**                  exactly matches intKey/pIdxKey.\n**\n**     *pRes>0      The cursor is left pointing at an entry that\n**                  is larger than intKey/pIdxKey.\n**\n** For index tables, the pIdxKey->eqSeen field is set to 1 if there\n** exists an entry in the table that exactly matches pIdxKey.  \n*/\nSQLITE_PRIVATE int sqlite3BtreeMovetoUnpacked(\n  BtCursor *pCur,          /* The cursor to be moved */\n  UnpackedRecord *pIdxKey, /* Unpacked index key */\n  i64 intKey,              /* The table key */\n  int biasRight,           /* If true, bias the search to the high end */\n  int *pRes                /* Write search results here */\n){\n  int rc;\n  RecordCompare xRecordCompare;\n\n  assert( cursorOwnsBtShared(pCur) );\n  assert( sqlite3_mutex_held(pCur->pBtree->db->mutex) );\n  assert( pRes );\n  assert( (pIdxKey==0)==(pCur->pKeyInfo==0) );\n  assert( pCur->eState!=CURSOR_VALID || (pIdxKey==0)==(pCur->curIntKey!=0) );\n\n  /* If the cursor is already positioned at the point we are trying\n  ** to move to, then just return without doing any work */\n  if( pIdxKey==0\n   && pCur->eState==CURSOR_VALID && (pCur->curFlags & BTCF_ValidNKey)!=0\n  ){\n    if( pCur->info.nKey==intKey ){\n      *pRes = 0;\n      return SQLITE_OK;\n    }\n    if( pCur->info.nKey<intKey ){\n      if( (pCur->curFlags & BTCF_AtLast)!=0 ){\n        *pRes = -1;\n        return SQLITE_OK;\n      }\n      /* If the requested key is one more than the previous key, then\n      ** try to get there using sqlite3BtreeNext() rather than a full\n      ** binary search.  This is an optimization only.  The correct answer\n      ** is still obtained without this case, only a little more slowely */\n      if( pCur->info.nKey+1==intKey ){\n        *pRes = 0;\n        rc = sqlite3BtreeNext(pCur, 0);\n        if( rc==SQLITE_OK ){\n          getCellInfo(pCur);\n          if( pCur->info.nKey==intKey ){\n            return SQLITE_OK;\n          }\n        }else if( rc==SQLITE_DONE ){\n          rc = SQLITE_OK;\n        }else{\n          return rc;\n        }\n      }\n    }\n  }\n\n  if( pIdxKey ){\n    xRecordCompare = sqlite3VdbeFindCompare(pIdxKey);\n    pIdxKey->errCode = 0;\n    assert( pIdxKey->default_rc==1 \n         || pIdxKey->default_rc==0 \n         || pIdxKey->default_rc==-1\n    );\n  }else{\n    xRecordCompare = 0; /* All keys are integers */\n  }\n\n  rc = moveToRoot(pCur);\n  if( rc ){\n    if( rc==SQLITE_EMPTY ){\n      assert( pCur->pgnoRoot==0 || pCur->pPage->nCell==0 );\n      *pRes = -1;\n      return SQLITE_OK;\n    }\n    return rc;\n  }\n  assert( pCur->pPage );\n  assert( pCur->pPage->isInit );\n  assert( pCur->eState==CURSOR_VALID );\n  assert( pCur->pPage->nCell > 0 );\n  assert( pCur->iPage==0 || pCur->apPage[0]->intKey==pCur->curIntKey );\n  assert( pCur->curIntKey || pIdxKey );\n  for(;;){\n    int lwr, upr, idx, c;\n    Pgno chldPg;\n    MemPage *pPage = pCur->pPage;\n    u8 *pCell;                          /* Pointer to current cell in pPage */\n\n    /* pPage->nCell must be greater than zero. If this is the root-page\n    ** the cursor would have been INVALID above and this for(;;) loop\n    ** not run. If this is not the root-page, then the moveToChild() routine\n    ** would have already detected db corruption. Similarly, pPage must\n    ** be the right kind (index or table) of b-tree page. Otherwise\n    ** a moveToChild() or moveToRoot() call would have detected corruption.  */\n    assert( pPage->nCell>0 );\n    assert( pPage->intKey==(pIdxKey==0) );\n    lwr = 0;\n    upr = pPage->nCell-1;\n    assert( biasRight==0 || biasRight==1 );\n    idx = upr>>(1-biasRight); /* idx = biasRight ? upr : (lwr+upr)/2; */\n    pCur->ix = (u16)idx;\n    if( xRecordCompare==0 ){\n      for(;;){\n        i64 nCellKey;\n        pCell = findCellPastPtr(pPage, idx);\n        if( pPage->intKeyLeaf ){\n          while( 0x80 <= *(pCell++) ){\n            if( pCell>=pPage->aDataEnd ){\n              return SQLITE_CORRUPT_PAGE(pPage);\n            }\n          }\n        }\n        getVarint(pCell, (u64*)&nCellKey);\n        if( nCellKey<intKey ){\n          lwr = idx+1;\n          if( lwr>upr ){ c = -1; break; }\n        }else if( nCellKey>intKey ){\n          upr = idx-1;\n          if( lwr>upr ){ c = +1; break; }\n        }else{\n          assert( nCellKey==intKey );\n          pCur->ix = (u16)idx;\n          if( !pPage->leaf ){\n            lwr = idx;\n            goto moveto_next_layer;\n          }else{\n            pCur->curFlags |= BTCF_ValidNKey;\n            pCur->info.nKey = nCellKey;\n            pCur->info.nSize = 0;\n            *pRes = 0;\n            return SQLITE_OK;\n          }\n        }\n        assert( lwr+upr>=0 );\n        idx = (lwr+upr)>>1;  /* idx = (lwr+upr)/2; */\n      }\n    }else{\n      for(;;){\n        int nCell;  /* Size of the pCell cell in bytes */\n        pCell = findCellPastPtr(pPage, idx);\n\n        /* The maximum supported page-size is 65536 bytes. This means that\n        ** the maximum number of record bytes stored on an index B-Tree\n        ** page is less than 16384 bytes and may be stored as a 2-byte\n        ** varint. This information is used to attempt to avoid parsing \n        ** the entire cell by checking for the cases where the record is \n        ** stored entirely within the b-tree page by inspecting the first \n        ** 2 bytes of the cell.\n        */\n        nCell = pCell[0];\n        if( nCell<=pPage->max1bytePayload ){\n          /* This branch runs if the record-size field of the cell is a\n          ** single byte varint and the record fits entirely on the main\n          ** b-tree page.  */\n          testcase( pCell+nCell+1==pPage->aDataEnd );\n          c = xRecordCompare(nCell, (void*)&pCell[1], pIdxKey);\n        }else if( !(pCell[1] & 0x80) \n          && (nCell = ((nCell&0x7f)<<7) + pCell[1])<=pPage->maxLocal\n        ){\n          /* The record-size field is a 2 byte varint and the record \n          ** fits entirely on the main b-tree page.  */\n          testcase( pCell+nCell+2==pPage->aDataEnd );\n          c = xRecordCompare(nCell, (void*)&pCell[2], pIdxKey);\n        }else{\n          /* The record flows over onto one or more overflow pages. In\n          ** this case the whole cell needs to be parsed, a buffer allocated\n          ** and accessPayload() used to retrieve the record into the\n          ** buffer before VdbeRecordCompare() can be called. \n          **\n          ** If the record is corrupt, the xRecordCompare routine may read\n          ** up to two varints past the end of the buffer. An extra 18 \n          ** bytes of padding is allocated at the end of the buffer in\n          ** case this happens.  */\n          void *pCellKey;\n          u8 * const pCellBody = pCell - pPage->childPtrSize;\n          pPage->xParseCell(pPage, pCellBody, &pCur->info);\n          nCell = (int)pCur->info.nKey;\n          testcase( nCell<0 );   /* True if key size is 2^32 or more */\n          testcase( nCell==0 );  /* Invalid key size:  0x80 0x80 0x00 */\n          testcase( nCell==1 );  /* Invalid key size:  0x80 0x80 0x01 */\n          testcase( nCell==2 );  /* Minimum legal index key size */\n          if( nCell<2 || nCell/pCur->pBt->usableSize>pCur->pBt->nPage ){\n            rc = SQLITE_CORRUPT_PAGE(pPage);\n            goto moveto_finish;\n          }\n          pCellKey = sqlite3Malloc( nCell+18 );\n          if( pCellKey==0 ){\n            rc = SQLITE_NOMEM_BKPT;\n            goto moveto_finish;\n          }\n          pCur->ix = (u16)idx;\n          rc = accessPayload(pCur, 0, nCell, (unsigned char*)pCellKey, 0);\n          pCur->curFlags &= ~BTCF_ValidOvfl;\n          if( rc ){\n            sqlite3_free(pCellKey);\n            goto moveto_finish;\n          }\n          c = xRecordCompare(nCell, pCellKey, pIdxKey);\n          sqlite3_free(pCellKey);\n        }\n        assert( \n            (pIdxKey->errCode!=SQLITE_CORRUPT || c==0)\n         && (pIdxKey->errCode!=SQLITE_NOMEM || pCur->pBtree->db->mallocFailed)\n        );\n        if( c<0 ){\n          lwr = idx+1;\n        }else if( c>0 ){\n          upr = idx-1;\n        }else{\n          assert( c==0 );\n          *pRes = 0;\n          rc = SQLITE_OK;\n          pCur->ix = (u16)idx;\n          if( pIdxKey->errCode ) rc = SQLITE_CORRUPT_BKPT;\n          goto moveto_finish;\n        }\n        if( lwr>upr ) break;\n        assert( lwr+upr>=0 );\n        idx = (lwr+upr)>>1;  /* idx = (lwr+upr)/2 */\n      }\n    }\n    assert( lwr==upr+1 || (pPage->intKey && !pPage->leaf) );\n    assert( pPage->isInit );\n    if( pPage->leaf ){\n      assert( pCur->ix<pCur->pPage->nCell );\n      pCur->ix = (u16)idx;\n      *pRes = c;\n      rc = SQLITE_OK;\n      goto moveto_finish;\n    }\nmoveto_next_layer:\n    if( lwr>=pPage->nCell ){\n      chldPg = get4byte(&pPage->aData[pPage->hdrOffset+8]);\n    }else{\n      chldPg = get4byte(findCell(pPage, lwr));\n    }\n    pCur->ix = (u16)lwr;\n    rc = moveToChild(pCur, chldPg);\n    if( rc ) break;\n  }\nmoveto_finish:\n  pCur->info.nSize = 0;\n  assert( (pCur->curFlags & BTCF_ValidOvfl)==0 );\n  return rc;\n}\n\n\n/*\n** Return TRUE if the cursor is not pointing at an entry of the table.\n**\n** TRUE will be returned after a call to sqlite3BtreeNext() moves\n** past the last entry in the table or sqlite3BtreePrev() moves past\n** the first entry.  TRUE is also returned if the table is empty.\n*/\nSQLITE_PRIVATE int sqlite3BtreeEof(BtCursor *pCur){\n  /* TODO: What if the cursor is in CURSOR_REQUIRESEEK but all table entries\n  ** have been deleted? This API will need to change to return an error code\n  ** as well as the boolean result value.\n  */\n  return (CURSOR_VALID!=pCur->eState);\n}\n\n/*\n** Return an estimate for the number of rows in the table that pCur is\n** pointing to.  Return a negative number if no estimate is currently \n** available.\n*/\nSQLITE_PRIVATE i64 sqlite3BtreeRowCountEst(BtCursor *pCur){\n  i64 n;\n  u8 i;\n\n  assert( cursorOwnsBtShared(pCur) );\n  assert( sqlite3_mutex_held(pCur->pBtree->db->mutex) );\n\n  /* Currently this interface is only called by the OP_IfSmaller\n  ** opcode, and it that case the cursor will always be valid and\n  ** will always point to a leaf node. */\n  if( NEVER(pCur->eState!=CURSOR_VALID) ) return -1;\n  if( NEVER(pCur->pPage->leaf==0) ) return -1;\n\n  n = pCur->pPage->nCell;\n  for(i=0; i<pCur->iPage; i++){\n    n *= pCur->apPage[i]->nCell;\n  }\n  return n;\n}\n\n/*\n** Advance the cursor to the next entry in the database. \n** Return value:\n**\n**    SQLITE_OK        success\n**    SQLITE_DONE      cursor is already pointing at the last element\n**    otherwise        some kind of error occurred\n**\n** The main entry point is sqlite3BtreeNext().  That routine is optimized\n** for the common case of merely incrementing the cell counter BtCursor.aiIdx\n** to the next cell on the current page.  The (slower) btreeNext() helper\n** routine is called when it is necessary to move to a different page or\n** to restore the cursor.\n**\n** If bit 0x01 of the F argument in sqlite3BtreeNext(C,F) is 1, then the\n** cursor corresponds to an SQL index and this routine could have been\n** skipped if the SQL index had been a unique index.  The F argument\n** is a hint to the implement.  SQLite btree implementation does not use\n** this hint, but COMDB2 does.\n*/\nstatic SQLITE_NOINLINE int btreeNext(BtCursor *pCur){\n  int rc;\n  int idx;\n  MemPage *pPage;\n\n  assert( cursorOwnsBtShared(pCur) );\n  if( pCur->eState!=CURSOR_VALID ){\n    assert( (pCur->curFlags & BTCF_ValidOvfl)==0 );\n    rc = restoreCursorPosition(pCur);\n    if( rc!=SQLITE_OK ){\n      return rc;\n    }\n    if( CURSOR_INVALID==pCur->eState ){\n      return SQLITE_DONE;\n    }\n    if( pCur->eState==CURSOR_SKIPNEXT ){\n      pCur->eState = CURSOR_VALID;\n      if( pCur->skipNext>0 ) return SQLITE_OK;\n    }\n  }\n\n  pPage = pCur->pPage;\n  idx = ++pCur->ix;\n  if( !pPage->isInit ){\n    /* The only known way for this to happen is for there to be a\n    ** recursive SQL function that does a DELETE operation as part of a\n    ** SELECT which deletes content out from under an active cursor\n    ** in a corrupt database file where the table being DELETE-ed from\n    ** has pages in common with the table being queried.  See TH3\n    ** module cov1/btree78.test testcase 220 (2018-06-08) for an\n    ** example. */\n    return SQLITE_CORRUPT_BKPT;\n  }\n\n  /* If the database file is corrupt, it is possible for the value of idx \n  ** to be invalid here. This can only occur if a second cursor modifies\n  ** the page while cursor pCur is holding a reference to it. Which can\n  ** only happen if the database is corrupt in such a way as to link the\n  ** page into more than one b-tree structure. */\n  testcase( idx>pPage->nCell );\n\n  if( idx>=pPage->nCell ){\n    if( !pPage->leaf ){\n      rc = moveToChild(pCur, get4byte(&pPage->aData[pPage->hdrOffset+8]));\n      if( rc ) return rc;\n      return moveToLeftmost(pCur);\n    }\n    do{\n      if( pCur->iPage==0 ){\n        pCur->eState = CURSOR_INVALID;\n        return SQLITE_DONE;\n      }\n      moveToParent(pCur);\n      pPage = pCur->pPage;\n    }while( pCur->ix>=pPage->nCell );\n    if( pPage->intKey ){\n      return sqlite3BtreeNext(pCur, 0);\n    }else{\n      return SQLITE_OK;\n    }\n  }\n  if( pPage->leaf ){\n    return SQLITE_OK;\n  }else{\n    return moveToLeftmost(pCur);\n  }\n}\nSQLITE_PRIVATE int sqlite3BtreeNext(BtCursor *pCur, int flags){\n  MemPage *pPage;\n  UNUSED_PARAMETER( flags );  /* Used in COMDB2 but not native SQLite */\n  assert( cursorOwnsBtShared(pCur) );\n  assert( flags==0 || flags==1 );\n  pCur->info.nSize = 0;\n  pCur->curFlags &= ~(BTCF_ValidNKey|BTCF_ValidOvfl);\n  if( pCur->eState!=CURSOR_VALID ) return btreeNext(pCur);\n  pPage = pCur->pPage;\n  if( (++pCur->ix)>=pPage->nCell ){\n    pCur->ix--;\n    return btreeNext(pCur);\n  }\n  if( pPage->leaf ){\n    return SQLITE_OK;\n  }else{\n    return moveToLeftmost(pCur);\n  }\n}\n\n/*\n** Step the cursor to the back to the previous entry in the database.\n** Return values:\n**\n**     SQLITE_OK     success\n**     SQLITE_DONE   the cursor is already on the first element of the table\n**     otherwise     some kind of error occurred\n**\n** The main entry point is sqlite3BtreePrevious().  That routine is optimized\n** for the common case of merely decrementing the cell counter BtCursor.aiIdx\n** to the previous cell on the current page.  The (slower) btreePrevious()\n** helper routine is called when it is necessary to move to a different page\n** or to restore the cursor.\n**\n** If bit 0x01 of the F argument to sqlite3BtreePrevious(C,F) is 1, then\n** the cursor corresponds to an SQL index and this routine could have been\n** skipped if the SQL index had been a unique index.  The F argument is a\n** hint to the implement.  The native SQLite btree implementation does not\n** use this hint, but COMDB2 does.\n*/\nstatic SQLITE_NOINLINE int btreePrevious(BtCursor *pCur){\n  int rc;\n  MemPage *pPage;\n\n  assert( cursorOwnsBtShared(pCur) );\n  assert( (pCur->curFlags & (BTCF_AtLast|BTCF_ValidOvfl|BTCF_ValidNKey))==0 );\n  assert( pCur->info.nSize==0 );\n  if( pCur->eState!=CURSOR_VALID ){\n    rc = restoreCursorPosition(pCur);\n    if( rc!=SQLITE_OK ){\n      return rc;\n    }\n    if( CURSOR_INVALID==pCur->eState ){\n      return SQLITE_DONE;\n    }\n    if( CURSOR_SKIPNEXT==pCur->eState ){\n      pCur->eState = CURSOR_VALID;\n      if( pCur->skipNext<0 ) return SQLITE_OK;\n    }\n  }\n\n  pPage = pCur->pPage;\n  assert( pPage->isInit );\n  if( !pPage->leaf ){\n    int idx = pCur->ix;\n    rc = moveToChild(pCur, get4byte(findCell(pPage, idx)));\n    if( rc ) return rc;\n    rc = moveToRightmost(pCur);\n  }else{\n    while( pCur->ix==0 ){\n      if( pCur->iPage==0 ){\n        pCur->eState = CURSOR_INVALID;\n        return SQLITE_DONE;\n      }\n      moveToParent(pCur);\n    }\n    assert( pCur->info.nSize==0 );\n    assert( (pCur->curFlags & (BTCF_ValidOvfl))==0 );\n\n    pCur->ix--;\n    pPage = pCur->pPage;\n    if( pPage->intKey && !pPage->leaf ){\n      rc = sqlite3BtreePrevious(pCur, 0);\n    }else{\n      rc = SQLITE_OK;\n    }\n  }\n  return rc;\n}\nSQLITE_PRIVATE int sqlite3BtreePrevious(BtCursor *pCur, int flags){\n  assert( cursorOwnsBtShared(pCur) );\n  assert( flags==0 || flags==1 );\n  UNUSED_PARAMETER( flags );  /* Used in COMDB2 but not native SQLite */\n  pCur->curFlags &= ~(BTCF_AtLast|BTCF_ValidOvfl|BTCF_ValidNKey);\n  pCur->info.nSize = 0;\n  if( pCur->eState!=CURSOR_VALID\n   || pCur->ix==0\n   || pCur->pPage->leaf==0\n  ){\n    return btreePrevious(pCur);\n  }\n  pCur->ix--;\n  return SQLITE_OK;\n}\n\n/*\n** Allocate a new page from the database file.\n**\n** The new page is marked as dirty.  (In other words, sqlite3PagerWrite()\n** has already been called on the new page.)  The new page has also\n** been referenced and the calling routine is responsible for calling\n** sqlite3PagerUnref() on the new page when it is done.\n**\n** SQLITE_OK is returned on success.  Any other return value indicates\n** an error.  *ppPage is set to NULL in the event of an error.\n**\n** If the \"nearby\" parameter is not 0, then an effort is made to \n** locate a page close to the page number \"nearby\".  This can be used in an\n** attempt to keep related pages close to each other in the database file,\n** which in turn can make database access faster.\n**\n** If the eMode parameter is BTALLOC_EXACT and the nearby page exists\n** anywhere on the free-list, then it is guaranteed to be returned.  If\n** eMode is BTALLOC_LT then the page returned will be less than or equal\n** to nearby if any such page exists.  If eMode is BTALLOC_ANY then there\n** are no restrictions on which page is returned.\n*/\nstatic int allocateBtreePage(\n  BtShared *pBt,         /* The btree */\n  MemPage **ppPage,      /* Store pointer to the allocated page here */\n  Pgno *pPgno,           /* Store the page number here */\n  Pgno nearby,           /* Search for a page near this one */\n  u8 eMode               /* BTALLOC_EXACT, BTALLOC_LT, or BTALLOC_ANY */\n){\n  MemPage *pPage1;\n  int rc;\n  u32 n;     /* Number of pages on the freelist */\n  u32 k;     /* Number of leaves on the trunk of the freelist */\n  MemPage *pTrunk = 0;\n  MemPage *pPrevTrunk = 0;\n  Pgno mxPage;     /* Total size of the database file */\n\n  assert( sqlite3_mutex_held(pBt->mutex) );\n  assert( eMode==BTALLOC_ANY || (nearby>0 && IfNotOmitAV(pBt->autoVacuum)) );\n  pPage1 = pBt->pPage1;\n  mxPage = btreePagecount(pBt);\n  /* EVIDENCE-OF: R-05119-02637 The 4-byte big-endian integer at offset 36\n  ** stores stores the total number of pages on the freelist. */\n  n = get4byte(&pPage1->aData[36]);\n  testcase( n==mxPage-1 );\n  if( n>=mxPage ){\n    return SQLITE_CORRUPT_BKPT;\n  }\n  if( n>0 ){\n    /* There are pages on the freelist.  Reuse one of those pages. */\n    Pgno iTrunk;\n    u8 searchList = 0; /* If the free-list must be searched for 'nearby' */\n    u32 nSearch = 0;   /* Count of the number of search attempts */\n    \n    /* If eMode==BTALLOC_EXACT and a query of the pointer-map\n    ** shows that the page 'nearby' is somewhere on the free-list, then\n    ** the entire-list will be searched for that page.\n    */\n#ifndef SQLITE_OMIT_AUTOVACUUM\n    if( eMode==BTALLOC_EXACT ){\n      if( nearby<=mxPage ){\n        u8 eType;\n        assert( nearby>0 );\n        assert( pBt->autoVacuum );\n        rc = ptrmapGet(pBt, nearby, &eType, 0);\n        if( rc ) return rc;\n        if( eType==PTRMAP_FREEPAGE ){\n          searchList = 1;\n        }\n      }\n    }else if( eMode==BTALLOC_LE ){\n      searchList = 1;\n    }\n#endif\n\n    /* Decrement the free-list count by 1. Set iTrunk to the index of the\n    ** first free-list trunk page. iPrevTrunk is initially 1.\n    */\n    rc = sqlite3PagerWrite(pPage1->pDbPage);\n    if( rc ) return rc;\n    put4byte(&pPage1->aData[36], n-1);\n\n    /* The code within this loop is run only once if the 'searchList' variable\n    ** is not true. Otherwise, it runs once for each trunk-page on the\n    ** free-list until the page 'nearby' is located (eMode==BTALLOC_EXACT)\n    ** or until a page less than 'nearby' is located (eMode==BTALLOC_LT)\n    */\n    do {\n      pPrevTrunk = pTrunk;\n      if( pPrevTrunk ){\n        /* EVIDENCE-OF: R-01506-11053 The first integer on a freelist trunk page\n        ** is the page number of the next freelist trunk page in the list or\n        ** zero if this is the last freelist trunk page. */\n        iTrunk = get4byte(&pPrevTrunk->aData[0]);\n      }else{\n        /* EVIDENCE-OF: R-59841-13798 The 4-byte big-endian integer at offset 32\n        ** stores the page number of the first page of the freelist, or zero if\n        ** the freelist is empty. */\n        iTrunk = get4byte(&pPage1->aData[32]);\n      }\n      testcase( iTrunk==mxPage );\n      if( iTrunk>mxPage || nSearch++ > n ){\n        rc = SQLITE_CORRUPT_PGNO(pPrevTrunk ? pPrevTrunk->pgno : 1);\n      }else{\n        rc = btreeGetUnusedPage(pBt, iTrunk, &pTrunk, 0);\n      }\n      if( rc ){\n        pTrunk = 0;\n        goto end_allocate_page;\n      }\n      assert( pTrunk!=0 );\n      assert( pTrunk->aData!=0 );\n      /* EVIDENCE-OF: R-13523-04394 The second integer on a freelist trunk page\n      ** is the number of leaf page pointers to follow. */\n      k = get4byte(&pTrunk->aData[4]);\n      if( k==0 && !searchList ){\n        /* The trunk has no leaves and the list is not being searched. \n        ** So extract the trunk page itself and use it as the newly \n        ** allocated page */\n        assert( pPrevTrunk==0 );\n        rc = sqlite3PagerWrite(pTrunk->pDbPage);\n        if( rc ){\n          goto end_allocate_page;\n        }\n        *pPgno = iTrunk;\n        memcpy(&pPage1->aData[32], &pTrunk->aData[0], 4);\n        *ppPage = pTrunk;\n        pTrunk = 0;\n        TRACE((\"ALLOCATE: %d trunk - %d free pages left\\n\", *pPgno, n-1));\n      }else if( k>(u32)(pBt->usableSize/4 - 2) ){\n        /* Value of k is out of range.  Database corruption */\n        rc = SQLITE_CORRUPT_PGNO(iTrunk);\n        goto end_allocate_page;\n#ifndef SQLITE_OMIT_AUTOVACUUM\n      }else if( searchList \n            && (nearby==iTrunk || (iTrunk<nearby && eMode==BTALLOC_LE)) \n      ){\n        /* The list is being searched and this trunk page is the page\n        ** to allocate, regardless of whether it has leaves.\n        */\n        *pPgno = iTrunk;\n        *ppPage = pTrunk;\n        searchList = 0;\n        rc = sqlite3PagerWrite(pTrunk->pDbPage);\n        if( rc ){\n          goto end_allocate_page;\n        }\n        if( k==0 ){\n          if( !pPrevTrunk ){\n            memcpy(&pPage1->aData[32], &pTrunk->aData[0], 4);\n          }else{\n            rc = sqlite3PagerWrite(pPrevTrunk->pDbPage);\n            if( rc!=SQLITE_OK ){\n              goto end_allocate_page;\n            }\n            memcpy(&pPrevTrunk->aData[0], &pTrunk->aData[0], 4);\n          }\n        }else{\n          /* The trunk page is required by the caller but it contains \n          ** pointers to free-list leaves. The first leaf becomes a trunk\n          ** page in this case.\n          */\n          MemPage *pNewTrunk;\n          Pgno iNewTrunk = get4byte(&pTrunk->aData[8]);\n          if( iNewTrunk>mxPage ){ \n            rc = SQLITE_CORRUPT_PGNO(iTrunk);\n            goto end_allocate_page;\n          }\n          testcase( iNewTrunk==mxPage );\n          rc = btreeGetUnusedPage(pBt, iNewTrunk, &pNewTrunk, 0);\n          if( rc!=SQLITE_OK ){\n            goto end_allocate_page;\n          }\n          rc = sqlite3PagerWrite(pNewTrunk->pDbPage);\n          if( rc!=SQLITE_OK ){\n            releasePage(pNewTrunk);\n            goto end_allocate_page;\n          }\n          memcpy(&pNewTrunk->aData[0], &pTrunk->aData[0], 4);\n          put4byte(&pNewTrunk->aData[4], k-1);\n          memcpy(&pNewTrunk->aData[8], &pTrunk->aData[12], (k-1)*4);\n          releasePage(pNewTrunk);\n          if( !pPrevTrunk ){\n            assert( sqlite3PagerIswriteable(pPage1->pDbPage) );\n            put4byte(&pPage1->aData[32], iNewTrunk);\n          }else{\n            rc = sqlite3PagerWrite(pPrevTrunk->pDbPage);\n            if( rc ){\n              goto end_allocate_page;\n            }\n            put4byte(&pPrevTrunk->aData[0], iNewTrunk);\n          }\n        }\n        pTrunk = 0;\n        TRACE((\"ALLOCATE: %d trunk - %d free pages left\\n\", *pPgno, n-1));\n#endif\n      }else if( k>0 ){\n        /* Extract a leaf from the trunk */\n        u32 closest;\n        Pgno iPage;\n        unsigned char *aData = pTrunk->aData;\n        if( nearby>0 ){\n          u32 i;\n          closest = 0;\n          if( eMode==BTALLOC_LE ){\n            for(i=0; i<k; i++){\n              iPage = get4byte(&aData[8+i*4]);\n              if( iPage<=nearby ){\n                closest = i;\n                break;\n              }\n            }\n          }else{\n            int dist;\n            dist = sqlite3AbsInt32(get4byte(&aData[8]) - nearby);\n            for(i=1; i<k; i++){\n              int d2 = sqlite3AbsInt32(get4byte(&aData[8+i*4]) - nearby);\n              if( d2<dist ){\n                closest = i;\n                dist = d2;\n              }\n            }\n          }\n        }else{\n          closest = 0;\n        }\n\n        iPage = get4byte(&aData[8+closest*4]);\n        testcase( iPage==mxPage );\n        if( iPage>mxPage ){\n          rc = SQLITE_CORRUPT_PGNO(iTrunk);\n          goto end_allocate_page;\n        }\n        testcase( iPage==mxPage );\n        if( !searchList \n         || (iPage==nearby || (iPage<nearby && eMode==BTALLOC_LE)) \n        ){\n          int noContent;\n          *pPgno = iPage;\n          TRACE((\"ALLOCATE: %d was leaf %d of %d on trunk %d\"\n                 \": %d more free pages\\n\",\n                 *pPgno, closest+1, k, pTrunk->pgno, n-1));\n          rc = sqlite3PagerWrite(pTrunk->pDbPage);\n          if( rc ) goto end_allocate_page;\n          if( closest<k-1 ){\n            memcpy(&aData[8+closest*4], &aData[4+k*4], 4);\n          }\n          put4byte(&aData[4], k-1);\n          noContent = !btreeGetHasContent(pBt, *pPgno)? PAGER_GET_NOCONTENT : 0;\n          rc = btreeGetUnusedPage(pBt, *pPgno, ppPage, noContent);\n          if( rc==SQLITE_OK ){\n            rc = sqlite3PagerWrite((*ppPage)->pDbPage);\n            if( rc!=SQLITE_OK ){\n              releasePage(*ppPage);\n              *ppPage = 0;\n            }\n          }\n          searchList = 0;\n        }\n      }\n      releasePage(pPrevTrunk);\n      pPrevTrunk = 0;\n    }while( searchList );\n  }else{\n    /* There are no pages on the freelist, so append a new page to the\n    ** database image.\n    **\n    ** Normally, new pages allocated by this block can be requested from the\n    ** pager layer with the 'no-content' flag set. This prevents the pager\n    ** from trying to read the pages content from disk. However, if the\n    ** current transaction has already run one or more incremental-vacuum\n    ** steps, then the page we are about to allocate may contain content\n    ** that is required in the event of a rollback. In this case, do\n    ** not set the no-content flag. This causes the pager to load and journal\n    ** the current page content before overwriting it.\n    **\n    ** Note that the pager will not actually attempt to load or journal \n    ** content for any page that really does lie past the end of the database\n    ** file on disk. So the effects of disabling the no-content optimization\n    ** here are confined to those pages that lie between the end of the\n    ** database image and the end of the database file.\n    */\n    int bNoContent = (0==IfNotOmitAV(pBt->bDoTruncate))? PAGER_GET_NOCONTENT:0;\n\n    rc = sqlite3PagerWrite(pBt->pPage1->pDbPage);\n    if( rc ) return rc;\n    pBt->nPage++;\n    if( pBt->nPage==PENDING_BYTE_PAGE(pBt) ) pBt->nPage++;\n\n#ifndef SQLITE_OMIT_AUTOVACUUM\n    if( pBt->autoVacuum && PTRMAP_ISPAGE(pBt, pBt->nPage) ){\n      /* If *pPgno refers to a pointer-map page, allocate two new pages\n      ** at the end of the file instead of one. The first allocated page\n      ** becomes a new pointer-map page, the second is used by the caller.\n      */\n      MemPage *pPg = 0;\n      TRACE((\"ALLOCATE: %d from end of file (pointer-map page)\\n\", pBt->nPage));\n      assert( pBt->nPage!=PENDING_BYTE_PAGE(pBt) );\n      rc = btreeGetUnusedPage(pBt, pBt->nPage, &pPg, bNoContent);\n      if( rc==SQLITE_OK ){\n        rc = sqlite3PagerWrite(pPg->pDbPage);\n        releasePage(pPg);\n      }\n      if( rc ) return rc;\n      pBt->nPage++;\n      if( pBt->nPage==PENDING_BYTE_PAGE(pBt) ){ pBt->nPage++; }\n    }\n#endif\n    put4byte(28 + (u8*)pBt->pPage1->aData, pBt->nPage);\n    *pPgno = pBt->nPage;\n\n    assert( *pPgno!=PENDING_BYTE_PAGE(pBt) );\n    rc = btreeGetUnusedPage(pBt, *pPgno, ppPage, bNoContent);\n    if( rc ) return rc;\n    rc = sqlite3PagerWrite((*ppPage)->pDbPage);\n    if( rc!=SQLITE_OK ){\n      releasePage(*ppPage);\n      *ppPage = 0;\n    }\n    TRACE((\"ALLOCATE: %d from end of file\\n\", *pPgno));\n  }\n\n  assert( CORRUPT_DB || *pPgno!=PENDING_BYTE_PAGE(pBt) );\n\nend_allocate_page:\n  releasePage(pTrunk);\n  releasePage(pPrevTrunk);\n  assert( rc!=SQLITE_OK || sqlite3PagerPageRefcount((*ppPage)->pDbPage)<=1 );\n  assert( rc!=SQLITE_OK || (*ppPage)->isInit==0 );\n  return rc;\n}\n\n/*\n** This function is used to add page iPage to the database file free-list. \n** It is assumed that the page is not already a part of the free-list.\n**\n** The value passed as the second argument to this function is optional.\n** If the caller happens to have a pointer to the MemPage object \n** corresponding to page iPage handy, it may pass it as the second value. \n** Otherwise, it may pass NULL.\n**\n** If a pointer to a MemPage object is passed as the second argument,\n** its reference count is not altered by this function.\n*/\nstatic int freePage2(BtShared *pBt, MemPage *pMemPage, Pgno iPage){\n  MemPage *pTrunk = 0;                /* Free-list trunk page */\n  Pgno iTrunk = 0;                    /* Page number of free-list trunk page */ \n  MemPage *pPage1 = pBt->pPage1;      /* Local reference to page 1 */\n  MemPage *pPage;                     /* Page being freed. May be NULL. */\n  int rc;                             /* Return Code */\n  int nFree;                          /* Initial number of pages on free-list */\n\n  assert( sqlite3_mutex_held(pBt->mutex) );\n  assert( CORRUPT_DB || iPage>1 );\n  assert( !pMemPage || pMemPage->pgno==iPage );\n\n  if( iPage<2 ) return SQLITE_CORRUPT_BKPT;\n  if( pMemPage ){\n    pPage = pMemPage;\n    sqlite3PagerRef(pPage->pDbPage);\n  }else{\n    pPage = btreePageLookup(pBt, iPage);\n  }\n\n  /* Increment the free page count on pPage1 */\n  rc = sqlite3PagerWrite(pPage1->pDbPage);\n  if( rc ) goto freepage_out;\n  nFree = get4byte(&pPage1->aData[36]);\n  put4byte(&pPage1->aData[36], nFree+1);\n\n  if( pBt->btsFlags & BTS_SECURE_DELETE ){\n    /* If the secure_delete option is enabled, then\n    ** always fully overwrite deleted information with zeros.\n    */\n    if( (!pPage && ((rc = btreeGetPage(pBt, iPage, &pPage, 0))!=0) )\n     ||            ((rc = sqlite3PagerWrite(pPage->pDbPage))!=0)\n    ){\n      goto freepage_out;\n    }\n    memset(pPage->aData, 0, pPage->pBt->pageSize);\n  }\n\n  /* If the database supports auto-vacuum, write an entry in the pointer-map\n  ** to indicate that the page is free.\n  */\n  if( ISAUTOVACUUM ){\n    ptrmapPut(pBt, iPage, PTRMAP_FREEPAGE, 0, &rc);\n    if( rc ) goto freepage_out;\n  }\n\n  /* Now manipulate the actual database free-list structure. There are two\n  ** possibilities. If the free-list is currently empty, or if the first\n  ** trunk page in the free-list is full, then this page will become a\n  ** new free-list trunk page. Otherwise, it will become a leaf of the\n  ** first trunk page in the current free-list. This block tests if it\n  ** is possible to add the page as a new free-list leaf.\n  */\n  if( nFree!=0 ){\n    u32 nLeaf;                /* Initial number of leaf cells on trunk page */\n\n    iTrunk = get4byte(&pPage1->aData[32]);\n    rc = btreeGetPage(pBt, iTrunk, &pTrunk, 0);\n    if( rc!=SQLITE_OK ){\n      goto freepage_out;\n    }\n\n    nLeaf = get4byte(&pTrunk->aData[4]);\n    assert( pBt->usableSize>32 );\n    if( nLeaf > (u32)pBt->usableSize/4 - 2 ){\n      rc = SQLITE_CORRUPT_BKPT;\n      goto freepage_out;\n    }\n    if( nLeaf < (u32)pBt->usableSize/4 - 8 ){\n      /* In this case there is room on the trunk page to insert the page\n      ** being freed as a new leaf.\n      **\n      ** Note that the trunk page is not really full until it contains\n      ** usableSize/4 - 2 entries, not usableSize/4 - 8 entries as we have\n      ** coded.  But due to a coding error in versions of SQLite prior to\n      ** 3.6.0, databases with freelist trunk pages holding more than\n      ** usableSize/4 - 8 entries will be reported as corrupt.  In order\n      ** to maintain backwards compatibility with older versions of SQLite,\n      ** we will continue to restrict the number of entries to usableSize/4 - 8\n      ** for now.  At some point in the future (once everyone has upgraded\n      ** to 3.6.0 or later) we should consider fixing the conditional above\n      ** to read \"usableSize/4-2\" instead of \"usableSize/4-8\".\n      **\n      ** EVIDENCE-OF: R-19920-11576 However, newer versions of SQLite still\n      ** avoid using the last six entries in the freelist trunk page array in\n      ** order that database files created by newer versions of SQLite can be\n      ** read by older versions of SQLite.\n      */\n      rc = sqlite3PagerWrite(pTrunk->pDbPage);\n      if( rc==SQLITE_OK ){\n        put4byte(&pTrunk->aData[4], nLeaf+1);\n        put4byte(&pTrunk->aData[8+nLeaf*4], iPage);\n        if( pPage && (pBt->btsFlags & BTS_SECURE_DELETE)==0 ){\n          sqlite3PagerDontWrite(pPage->pDbPage);\n        }\n        rc = btreeSetHasContent(pBt, iPage);\n      }\n      TRACE((\"FREE-PAGE: %d leaf on trunk page %d\\n\",pPage->pgno,pTrunk->pgno));\n      goto freepage_out;\n    }\n  }\n\n  /* If control flows to this point, then it was not possible to add the\n  ** the page being freed as a leaf page of the first trunk in the free-list.\n  ** Possibly because the free-list is empty, or possibly because the \n  ** first trunk in the free-list is full. Either way, the page being freed\n  ** will become the new first trunk page in the free-list.\n  */\n  if( pPage==0 && SQLITE_OK!=(rc = btreeGetPage(pBt, iPage, &pPage, 0)) ){\n    goto freepage_out;\n  }\n  rc = sqlite3PagerWrite(pPage->pDbPage);\n  if( rc!=SQLITE_OK ){\n    goto freepage_out;\n  }\n  put4byte(pPage->aData, iTrunk);\n  put4byte(&pPage->aData[4], 0);\n  put4byte(&pPage1->aData[32], iPage);\n  TRACE((\"FREE-PAGE: %d new trunk page replacing %d\\n\", pPage->pgno, iTrunk));\n\nfreepage_out:\n  if( pPage ){\n    pPage->isInit = 0;\n  }\n  releasePage(pPage);\n  releasePage(pTrunk);\n  return rc;\n}\nstatic void freePage(MemPage *pPage, int *pRC){\n  if( (*pRC)==SQLITE_OK ){\n    *pRC = freePage2(pPage->pBt, pPage, pPage->pgno);\n  }\n}\n\n/*\n** Free any overflow pages associated with the given Cell.  Store\n** size information about the cell in pInfo.\n*/\nstatic int clearCell(\n  MemPage *pPage,          /* The page that contains the Cell */\n  unsigned char *pCell,    /* First byte of the Cell */\n  CellInfo *pInfo          /* Size information about the cell */\n){\n  BtShared *pBt;\n  Pgno ovflPgno;\n  int rc;\n  int nOvfl;\n  u32 ovflPageSize;\n\n  assert( sqlite3_mutex_held(pPage->pBt->mutex) );\n  pPage->xParseCell(pPage, pCell, pInfo);\n  if( pInfo->nLocal==pInfo->nPayload ){\n    return SQLITE_OK;  /* No overflow pages. Return without doing anything */\n  }\n  testcase( pCell + pInfo->nSize == pPage->aDataEnd );\n  testcase( pCell + (pInfo->nSize-1) == pPage->aDataEnd );\n  if( pCell + pInfo->nSize > pPage->aDataEnd ){\n    /* Cell extends past end of page */\n    return SQLITE_CORRUPT_PAGE(pPage);\n  }\n  ovflPgno = get4byte(pCell + pInfo->nSize - 4);\n  pBt = pPage->pBt;\n  assert( pBt->usableSize > 4 );\n  ovflPageSize = pBt->usableSize - 4;\n  nOvfl = (pInfo->nPayload - pInfo->nLocal + ovflPageSize - 1)/ovflPageSize;\n  assert( nOvfl>0 || \n    (CORRUPT_DB && (pInfo->nPayload + ovflPageSize)<ovflPageSize)\n  );\n  while( nOvfl-- ){\n    Pgno iNext = 0;\n    MemPage *pOvfl = 0;\n    if( ovflPgno<2 || ovflPgno>btreePagecount(pBt) ){\n      /* 0 is not a legal page number and page 1 cannot be an \n      ** overflow page. Therefore if ovflPgno<2 or past the end of the \n      ** file the database must be corrupt. */\n      return SQLITE_CORRUPT_BKPT;\n    }\n    if( nOvfl ){\n      rc = getOverflowPage(pBt, ovflPgno, &pOvfl, &iNext);\n      if( rc ) return rc;\n    }\n\n    if( ( pOvfl || ((pOvfl = btreePageLookup(pBt, ovflPgno))!=0) )\n     && sqlite3PagerPageRefcount(pOvfl->pDbPage)!=1\n    ){\n      /* There is no reason any cursor should have an outstanding reference \n      ** to an overflow page belonging to a cell that is being deleted/updated.\n      ** So if there exists more than one reference to this page, then it \n      ** must not really be an overflow page and the database must be corrupt. \n      ** It is helpful to detect this before calling freePage2(), as \n      ** freePage2() may zero the page contents if secure-delete mode is\n      ** enabled. If this 'overflow' page happens to be a page that the\n      ** caller is iterating through or using in some other way, this\n      ** can be problematic.\n      */\n      rc = SQLITE_CORRUPT_BKPT;\n    }else{\n      rc = freePage2(pBt, pOvfl, ovflPgno);\n    }\n\n    if( pOvfl ){\n      sqlite3PagerUnref(pOvfl->pDbPage);\n    }\n    if( rc ) return rc;\n    ovflPgno = iNext;\n  }\n  return SQLITE_OK;\n}\n\n/*\n** Create the byte sequence used to represent a cell on page pPage\n** and write that byte sequence into pCell[].  Overflow pages are\n** allocated and filled in as necessary.  The calling procedure\n** is responsible for making sure sufficient space has been allocated\n** for pCell[].\n**\n** Note that pCell does not necessary need to point to the pPage->aData\n** area.  pCell might point to some temporary storage.  The cell will\n** be constructed in this temporary area then copied into pPage->aData\n** later.\n*/\nstatic int fillInCell(\n  MemPage *pPage,                /* The page that contains the cell */\n  unsigned char *pCell,          /* Complete text of the cell */\n  const BtreePayload *pX,        /* Payload with which to construct the cell */\n  int *pnSize                    /* Write cell size here */\n){\n  int nPayload;\n  const u8 *pSrc;\n  int nSrc, n, rc, mn;\n  int spaceLeft;\n  MemPage *pToRelease;\n  unsigned char *pPrior;\n  unsigned char *pPayload;\n  BtShared *pBt;\n  Pgno pgnoOvfl;\n  int nHeader;\n\n  assert( sqlite3_mutex_held(pPage->pBt->mutex) );\n\n  /* pPage is not necessarily writeable since pCell might be auxiliary\n  ** buffer space that is separate from the pPage buffer area */\n  assert( pCell<pPage->aData || pCell>=&pPage->aData[pPage->pBt->pageSize]\n            || sqlite3PagerIswriteable(pPage->pDbPage) );\n\n  /* Fill in the header. */\n  nHeader = pPage->childPtrSize;\n  if( pPage->intKey ){\n    nPayload = pX->nData + pX->nZero;\n    pSrc = pX->pData;\n    nSrc = pX->nData;\n    assert( pPage->intKeyLeaf ); /* fillInCell() only called for leaves */\n    nHeader += putVarint32(&pCell[nHeader], nPayload);\n    nHeader += putVarint(&pCell[nHeader], *(u64*)&pX->nKey);\n  }else{\n    assert( pX->nKey<=0x7fffffff && pX->pKey!=0 );\n    nSrc = nPayload = (int)pX->nKey;\n    pSrc = pX->pKey;\n    nHeader += putVarint32(&pCell[nHeader], nPayload);\n  }\n  \n  /* Fill in the payload */\n  pPayload = &pCell[nHeader];\n  if( nPayload<=pPage->maxLocal ){\n    /* This is the common case where everything fits on the btree page\n    ** and no overflow pages are required. */\n    n = nHeader + nPayload;\n    testcase( n==3 );\n    testcase( n==4 );\n    if( n<4 ) n = 4;\n    *pnSize = n;\n    assert( nSrc<=nPayload );\n    testcase( nSrc<nPayload );\n    memcpy(pPayload, pSrc, nSrc);\n    memset(pPayload+nSrc, 0, nPayload-nSrc);\n    return SQLITE_OK;\n  }\n\n  /* If we reach this point, it means that some of the content will need\n  ** to spill onto overflow pages.\n  */\n  mn = pPage->minLocal;\n  n = mn + (nPayload - mn) % (pPage->pBt->usableSize - 4);\n  testcase( n==pPage->maxLocal );\n  testcase( n==pPage->maxLocal+1 );\n  if( n > pPage->maxLocal ) n = mn;\n  spaceLeft = n;\n  *pnSize = n + nHeader + 4;\n  pPrior = &pCell[nHeader+n];\n  pToRelease = 0;\n  pgnoOvfl = 0;\n  pBt = pPage->pBt;\n\n  /* At this point variables should be set as follows:\n  **\n  **   nPayload           Total payload size in bytes\n  **   pPayload           Begin writing payload here\n  **   spaceLeft          Space available at pPayload.  If nPayload>spaceLeft,\n  **                      that means content must spill into overflow pages.\n  **   *pnSize            Size of the local cell (not counting overflow pages)\n  **   pPrior             Where to write the pgno of the first overflow page\n  **\n  ** Use a call to btreeParseCellPtr() to verify that the values above\n  ** were computed correctly.\n  */\n#ifdef SQLITE_DEBUG\n  {\n    CellInfo info;\n    pPage->xParseCell(pPage, pCell, &info);\n    assert( nHeader==(int)(info.pPayload - pCell) );\n    assert( info.nKey==pX->nKey );\n    assert( *pnSize == info.nSize );\n    assert( spaceLeft == info.nLocal );\n  }\n#endif\n\n  /* Write the payload into the local Cell and any extra into overflow pages */\n  while( 1 ){\n    n = nPayload;\n    if( n>spaceLeft ) n = spaceLeft;\n\n    /* If pToRelease is not zero than pPayload points into the data area\n    ** of pToRelease.  Make sure pToRelease is still writeable. */\n    assert( pToRelease==0 || sqlite3PagerIswriteable(pToRelease->pDbPage) );\n\n    /* If pPayload is part of the data area of pPage, then make sure pPage\n    ** is still writeable */\n    assert( pPayload<pPage->aData || pPayload>=&pPage->aData[pBt->pageSize]\n            || sqlite3PagerIswriteable(pPage->pDbPage) );\n\n    if( nSrc>=n ){\n      memcpy(pPayload, pSrc, n);\n    }else if( nSrc>0 ){\n      n = nSrc;\n      memcpy(pPayload, pSrc, n);\n    }else{\n      memset(pPayload, 0, n);\n    }\n    nPayload -= n;\n    if( nPayload<=0 ) break;\n    pPayload += n;\n    pSrc += n;\n    nSrc -= n;\n    spaceLeft -= n;\n    if( spaceLeft==0 ){\n      MemPage *pOvfl = 0;\n#ifndef SQLITE_OMIT_AUTOVACUUM\n      Pgno pgnoPtrmap = pgnoOvfl; /* Overflow page pointer-map entry page */\n      if( pBt->autoVacuum ){\n        do{\n          pgnoOvfl++;\n        } while( \n          PTRMAP_ISPAGE(pBt, pgnoOvfl) || pgnoOvfl==PENDING_BYTE_PAGE(pBt) \n        );\n      }\n#endif\n      rc = allocateBtreePage(pBt, &pOvfl, &pgnoOvfl, pgnoOvfl, 0);\n#ifndef SQLITE_OMIT_AUTOVACUUM\n      /* If the database supports auto-vacuum, and the second or subsequent\n      ** overflow page is being allocated, add an entry to the pointer-map\n      ** for that page now. \n      **\n      ** If this is the first overflow page, then write a partial entry \n      ** to the pointer-map. If we write nothing to this pointer-map slot,\n      ** then the optimistic overflow chain processing in clearCell()\n      ** may misinterpret the uninitialized values and delete the\n      ** wrong pages from the database.\n      */\n      if( pBt->autoVacuum && rc==SQLITE_OK ){\n        u8 eType = (pgnoPtrmap?PTRMAP_OVERFLOW2:PTRMAP_OVERFLOW1);\n        ptrmapPut(pBt, pgnoOvfl, eType, pgnoPtrmap, &rc);\n        if( rc ){\n          releasePage(pOvfl);\n        }\n      }\n#endif\n      if( rc ){\n        releasePage(pToRelease);\n        return rc;\n      }\n\n      /* If pToRelease is not zero than pPrior points into the data area\n      ** of pToRelease.  Make sure pToRelease is still writeable. */\n      assert( pToRelease==0 || sqlite3PagerIswriteable(pToRelease->pDbPage) );\n\n      /* If pPrior is part of the data area of pPage, then make sure pPage\n      ** is still writeable */\n      assert( pPrior<pPage->aData || pPrior>=&pPage->aData[pBt->pageSize]\n            || sqlite3PagerIswriteable(pPage->pDbPage) );\n\n      put4byte(pPrior, pgnoOvfl);\n      releasePage(pToRelease);\n      pToRelease = pOvfl;\n      pPrior = pOvfl->aData;\n      put4byte(pPrior, 0);\n      pPayload = &pOvfl->aData[4];\n      spaceLeft = pBt->usableSize - 4;\n    }\n  }\n  releasePage(pToRelease);\n  return SQLITE_OK;\n}\n\n/*\n** Remove the i-th cell from pPage.  This routine effects pPage only.\n** The cell content is not freed or deallocated.  It is assumed that\n** the cell content has been copied someplace else.  This routine just\n** removes the reference to the cell from pPage.\n**\n** \"sz\" must be the number of bytes in the cell.\n*/\nstatic void dropCell(MemPage *pPage, int idx, int sz, int *pRC){\n  u32 pc;         /* Offset to cell content of cell being deleted */\n  u8 *data;       /* pPage->aData */\n  u8 *ptr;        /* Used to move bytes around within data[] */\n  int rc;         /* The return code */\n  int hdr;        /* Beginning of the header.  0 most pages.  100 page 1 */\n\n  if( *pRC ) return;\n  assert( idx>=0 && idx<pPage->nCell );\n  assert( CORRUPT_DB || sz==cellSize(pPage, idx) );\n  assert( sqlite3PagerIswriteable(pPage->pDbPage) );\n  assert( sqlite3_mutex_held(pPage->pBt->mutex) );\n  data = pPage->aData;\n  ptr = &pPage->aCellIdx[2*idx];\n  pc = get2byte(ptr);\n  hdr = pPage->hdrOffset;\n  testcase( pc==get2byte(&data[hdr+5]) );\n  testcase( pc+sz==pPage->pBt->usableSize );\n  if( pc+sz > pPage->pBt->usableSize ){\n    *pRC = SQLITE_CORRUPT_BKPT;\n    return;\n  }\n  rc = freeSpace(pPage, pc, sz);\n  if( rc ){\n    *pRC = rc;\n    return;\n  }\n  pPage->nCell--;\n  if( pPage->nCell==0 ){\n    memset(&data[hdr+1], 0, 4);\n    data[hdr+7] = 0;\n    put2byte(&data[hdr+5], pPage->pBt->usableSize);\n    pPage->nFree = pPage->pBt->usableSize - pPage->hdrOffset\n                       - pPage->childPtrSize - 8;\n  }else{\n    memmove(ptr, ptr+2, 2*(pPage->nCell - idx));\n    put2byte(&data[hdr+3], pPage->nCell);\n    pPage->nFree += 2;\n  }\n}\n\n/*\n** Insert a new cell on pPage at cell index \"i\".  pCell points to the\n** content of the cell.\n**\n** If the cell content will fit on the page, then put it there.  If it\n** will not fit, then make a copy of the cell content into pTemp if\n** pTemp is not null.  Regardless of pTemp, allocate a new entry\n** in pPage->apOvfl[] and make it point to the cell content (either\n** in pTemp or the original pCell) and also record its index. \n** Allocating a new entry in pPage->aCell[] implies that \n** pPage->nOverflow is incremented.\n**\n** *pRC must be SQLITE_OK when this routine is called.\n*/\nstatic void insertCell(\n  MemPage *pPage,   /* Page into which we are copying */\n  int i,            /* New cell becomes the i-th cell of the page */\n  u8 *pCell,        /* Content of the new cell */\n  int sz,           /* Bytes of content in pCell */\n  u8 *pTemp,        /* Temp storage space for pCell, if needed */\n  Pgno iChild,      /* If non-zero, replace first 4 bytes with this value */\n  int *pRC          /* Read and write return code from here */\n){\n  int idx = 0;      /* Where to write new cell content in data[] */\n  int j;            /* Loop counter */\n  u8 *data;         /* The content of the whole page */\n  u8 *pIns;         /* The point in pPage->aCellIdx[] where no cell inserted */\n\n  assert( *pRC==SQLITE_OK );\n  assert( i>=0 && i<=pPage->nCell+pPage->nOverflow );\n  assert( MX_CELL(pPage->pBt)<=10921 );\n  assert( pPage->nCell<=MX_CELL(pPage->pBt) || CORRUPT_DB );\n  assert( pPage->nOverflow<=ArraySize(pPage->apOvfl) );\n  assert( ArraySize(pPage->apOvfl)==ArraySize(pPage->aiOvfl) );\n  assert( sqlite3_mutex_held(pPage->pBt->mutex) );\n  /* The cell should normally be sized correctly.  However, when moving a\n  ** malformed cell from a leaf page to an interior page, if the cell size\n  ** wanted to be less than 4 but got rounded up to 4 on the leaf, then size\n  ** might be less than 8 (leaf-size + pointer) on the interior node.  Hence\n  ** the term after the || in the following assert(). */\n  assert( sz==pPage->xCellSize(pPage, pCell) || (sz==8 && iChild>0) );\n  if( pPage->nOverflow || sz+2>pPage->nFree ){\n    if( pTemp ){\n      memcpy(pTemp, pCell, sz);\n      pCell = pTemp;\n    }\n    if( iChild ){\n      put4byte(pCell, iChild);\n    }\n    j = pPage->nOverflow++;\n    /* Comparison against ArraySize-1 since we hold back one extra slot\n    ** as a contingency.  In other words, never need more than 3 overflow\n    ** slots but 4 are allocated, just to be safe. */\n    assert( j < ArraySize(pPage->apOvfl)-1 );\n    pPage->apOvfl[j] = pCell;\n    pPage->aiOvfl[j] = (u16)i;\n\n    /* When multiple overflows occur, they are always sequential and in\n    ** sorted order.  This invariants arise because multiple overflows can\n    ** only occur when inserting divider cells into the parent page during\n    ** balancing, and the dividers are adjacent and sorted.\n    */\n    assert( j==0 || pPage->aiOvfl[j-1]<(u16)i ); /* Overflows in sorted order */\n    assert( j==0 || i==pPage->aiOvfl[j-1]+1 );   /* Overflows are sequential */\n  }else{\n    int rc = sqlite3PagerWrite(pPage->pDbPage);\n    if( rc!=SQLITE_OK ){\n      *pRC = rc;\n      return;\n    }\n    assert( sqlite3PagerIswriteable(pPage->pDbPage) );\n    data = pPage->aData;\n    assert( &data[pPage->cellOffset]==pPage->aCellIdx );\n    rc = allocateSpace(pPage, sz, &idx);\n    if( rc ){ *pRC = rc; return; }\n    /* The allocateSpace() routine guarantees the following properties\n    ** if it returns successfully */\n    assert( idx >= 0 );\n    assert( idx >= pPage->cellOffset+2*pPage->nCell+2 || CORRUPT_DB );\n    assert( idx+sz <= (int)pPage->pBt->usableSize );\n    pPage->nFree -= (u16)(2 + sz);\n    if( iChild ){\n      /* In a corrupt database where an entry in the cell index section of\n      ** a btree page has a value of 3 or less, the pCell value might point\n      ** as many as 4 bytes in front of the start of the aData buffer for\n      ** the source page.  Make sure this does not cause problems by not\n      ** reading the first 4 bytes */\n      memcpy(&data[idx+4], pCell+4, sz-4);\n      put4byte(&data[idx], iChild);\n    }else{\n      memcpy(&data[idx], pCell, sz);\n    }\n    pIns = pPage->aCellIdx + i*2;\n    memmove(pIns+2, pIns, 2*(pPage->nCell - i));\n    put2byte(pIns, idx);\n    pPage->nCell++;\n    /* increment the cell count */\n    if( (++data[pPage->hdrOffset+4])==0 ) data[pPage->hdrOffset+3]++;\n    assert( get2byte(&data[pPage->hdrOffset+3])==pPage->nCell );\n#ifndef SQLITE_OMIT_AUTOVACUUM\n    if( pPage->pBt->autoVacuum ){\n      /* The cell may contain a pointer to an overflow page. If so, write\n      ** the entry for the overflow page into the pointer map.\n      */\n      ptrmapPutOvflPtr(pPage, pPage, pCell, pRC);\n    }\n#endif\n  }\n}\n\n/*\n** The following parameters determine how many adjacent pages get involved\n** in a balancing operation.  NN is the number of neighbors on either side\n** of the page that participate in the balancing operation.  NB is the\n** total number of pages that participate, including the target page and\n** NN neighbors on either side.\n**\n** The minimum value of NN is 1 (of course).  Increasing NN above 1\n** (to 2 or 3) gives a modest improvement in SELECT and DELETE performance\n** in exchange for a larger degradation in INSERT and UPDATE performance.\n** The value of NN appears to give the best results overall.\n**\n** (Later:) The description above makes it seem as if these values are\n** tunable - as if you could change them and recompile and it would all work.\n** But that is unlikely.  NB has been 3 since the inception of SQLite and\n** we have never tested any other value.\n*/\n#define NN 1             /* Number of neighbors on either side of pPage */\n#define NB 3             /* (NN*2+1): Total pages involved in the balance */\n\n/*\n** A CellArray object contains a cache of pointers and sizes for a\n** consecutive sequence of cells that might be held on multiple pages.\n**\n** The cells in this array are the divider cell or cells from the pParent\n** page plus up to three child pages.  There are a total of nCell cells.\n**\n** pRef is a pointer to one of the pages that contributes cells.  This is\n** used to access information such as MemPage.intKey and MemPage.pBt->pageSize\n** which should be common to all pages that contribute cells to this array.\n**\n** apCell[] and szCell[] hold, respectively, pointers to the start of each\n** cell and the size of each cell.  Some of the apCell[] pointers might refer\n** to overflow cells.  In other words, some apCel[] pointers might not point\n** to content area of the pages.\n**\n** A szCell[] of zero means the size of that cell has not yet been computed.\n**\n** The cells come from as many as four different pages:\n**\n**             -----------\n**             | Parent  |\n**             -----------\n**            /     |     \\\n**           /      |      \\\n**  ---------   ---------   ---------\n**  |Child-1|   |Child-2|   |Child-3|\n**  ---------   ---------   ---------\n**\n** The order of cells is in the array is for an index btree is:\n**\n**       1.  All cells from Child-1 in order\n**       2.  The first divider cell from Parent\n**       3.  All cells from Child-2 in order\n**       4.  The second divider cell from Parent\n**       5.  All cells from Child-3 in order\n**\n** For a table-btree (with rowids) the items 2 and 4 are empty because\n** content exists only in leaves and there are no divider cells.\n**\n** For an index btree, the apEnd[] array holds pointer to the end of page\n** for Child-1, the Parent, Child-2, the Parent (again), and Child-3,\n** respectively. The ixNx[] array holds the number of cells contained in\n** each of these 5 stages, and all stages to the left.  Hence:\n**\n**    ixNx[0] = Number of cells in Child-1.\n**    ixNx[1] = Number of cells in Child-1 plus 1 for first divider.\n**    ixNx[2] = Number of cells in Child-1 and Child-2 + 1 for 1st divider.\n**    ixNx[3] = Number of cells in Child-1 and Child-2 + both divider cells\n**    ixNx[4] = Total number of cells.\n**\n** For a table-btree, the concept is similar, except only apEnd[0]..apEnd[2]\n** are used and they point to the leaf pages only, and the ixNx value are:\n**\n**    ixNx[0] = Number of cells in Child-1.\n**    ixNx[1] = Number of cells in Child-1 and Child-2 + 1 for 1st divider.\n**    ixNx[2] = Number of cells in Child-1 and Child-2 + both divider cells\n*/\ntypedef struct CellArray CellArray;\nstruct CellArray {\n  int nCell;              /* Number of cells in apCell[] */\n  MemPage *pRef;          /* Reference page */\n  u8 **apCell;            /* All cells begin balanced */\n  u16 *szCell;            /* Local size of all cells in apCell[] */\n  u8 *apEnd[NB*2];        /* MemPage.aDataEnd values */\n  int ixNx[NB*2];         /* Index of at which we move to the next apEnd[] */\n};\n\n/*\n** Make sure the cell sizes at idx, idx+1, ..., idx+N-1 have been\n** computed.\n*/\nstatic void populateCellCache(CellArray *p, int idx, int N){\n  assert( idx>=0 && idx+N<=p->nCell );\n  while( N>0 ){\n    assert( p->apCell[idx]!=0 );\n    if( p->szCell[idx]==0 ){\n      p->szCell[idx] = p->pRef->xCellSize(p->pRef, p->apCell[idx]);\n    }else{\n      assert( CORRUPT_DB ||\n              p->szCell[idx]==p->pRef->xCellSize(p->pRef, p->apCell[idx]) );\n    }\n    idx++;\n    N--;\n  }\n}\n\n/*\n** Return the size of the Nth element of the cell array\n*/\nstatic SQLITE_NOINLINE u16 computeCellSize(CellArray *p, int N){\n  assert( N>=0 && N<p->nCell );\n  assert( p->szCell[N]==0 );\n  p->szCell[N] = p->pRef->xCellSize(p->pRef, p->apCell[N]);\n  return p->szCell[N];\n}\nstatic u16 cachedCellSize(CellArray *p, int N){\n  assert( N>=0 && N<p->nCell );\n  if( p->szCell[N] ) return p->szCell[N];\n  return computeCellSize(p, N);\n}\n\n/*\n** Array apCell[] contains pointers to nCell b-tree page cells. The \n** szCell[] array contains the size in bytes of each cell. This function\n** replaces the current contents of page pPg with the contents of the cell\n** array.\n**\n** Some of the cells in apCell[] may currently be stored in pPg. This\n** function works around problems caused by this by making a copy of any \n** such cells before overwriting the page data.\n**\n** The MemPage.nFree field is invalidated by this function. It is the \n** responsibility of the caller to set it correctly.\n*/\nstatic int rebuildPage(\n  CellArray *pCArray,             /* Content to be added to page pPg */\n  int iFirst,                     /* First cell in pCArray to use */\n  int nCell,                      /* Final number of cells on page */\n  MemPage *pPg                    /* The page to be reconstructed */\n){\n  const int hdr = pPg->hdrOffset;          /* Offset of header on pPg */\n  u8 * const aData = pPg->aData;           /* Pointer to data for pPg */\n  const int usableSize = pPg->pBt->usableSize;\n  u8 * const pEnd = &aData[usableSize];\n  int i = iFirst;                 /* Which cell to copy from pCArray*/\n  u32 j;                          /* Start of cell content area */\n  int iEnd = i+nCell;             /* Loop terminator */\n  u8 *pCellptr = pPg->aCellIdx;\n  u8 *pTmp = sqlite3PagerTempSpace(pPg->pBt->pPager);\n  u8 *pData;\n  int k;                          /* Current slot in pCArray->apEnd[] */\n  u8 *pSrcEnd;                    /* Current pCArray->apEnd[k] value */\n\n  assert( i<iEnd );\n  j = get2byte(&aData[hdr+5]);\n  if( NEVER(j>(u32)usableSize) ){ j = 0; }\n  memcpy(&pTmp[j], &aData[j], usableSize - j);\n\n  for(k=0; pCArray->ixNx[k]<=i && ALWAYS(k<NB*2); k++){}\n  pSrcEnd = pCArray->apEnd[k];\n\n  pData = pEnd;\n  while( 1/*exit by break*/ ){\n    u8 *pCell = pCArray->apCell[i];\n    u16 sz = pCArray->szCell[i];\n    assert( sz>0 );\n    if( SQLITE_WITHIN(pCell,aData,pEnd) ){\n      if( ((uptr)(pCell+sz))>(uptr)pEnd ) return SQLITE_CORRUPT_BKPT;\n      pCell = &pTmp[pCell - aData];\n    }else if( (uptr)(pCell+sz)>(uptr)pSrcEnd\n           && (uptr)(pCell)<(uptr)pSrcEnd\n    ){\n      return SQLITE_CORRUPT_BKPT;\n    }\n\n    pData -= sz;\n    put2byte(pCellptr, (pData - aData));\n    pCellptr += 2;\n    if( pData < pCellptr ) return SQLITE_CORRUPT_BKPT;\n    memcpy(pData, pCell, sz);\n    assert( sz==pPg->xCellSize(pPg, pCell) || CORRUPT_DB );\n    testcase( sz!=pPg->xCellSize(pPg,pCell) );\n    i++;\n    if( i>=iEnd ) break;\n    if( pCArray->ixNx[k]<=i ){\n      k++;\n      pSrcEnd = pCArray->apEnd[k];\n    }\n  }\n\n  /* The pPg->nFree field is now set incorrectly. The caller will fix it. */\n  pPg->nCell = nCell;\n  pPg->nOverflow = 0;\n\n  put2byte(&aData[hdr+1], 0);\n  put2byte(&aData[hdr+3], pPg->nCell);\n  put2byte(&aData[hdr+5], pData - aData);\n  aData[hdr+7] = 0x00;\n  return SQLITE_OK;\n}\n\n/*\n** The pCArray objects contains pointers to b-tree cells and the cell sizes.\n** This function attempts to add the cells stored in the array to page pPg.\n** If it cannot (because the page needs to be defragmented before the cells\n** will fit), non-zero is returned. Otherwise, if the cells are added\n** successfully, zero is returned.\n**\n** Argument pCellptr points to the first entry in the cell-pointer array\n** (part of page pPg) to populate. After cell apCell[0] is written to the\n** page body, a 16-bit offset is written to pCellptr. And so on, for each\n** cell in the array. It is the responsibility of the caller to ensure\n** that it is safe to overwrite this part of the cell-pointer array.\n**\n** When this function is called, *ppData points to the start of the \n** content area on page pPg. If the size of the content area is extended,\n** *ppData is updated to point to the new start of the content area\n** before returning.\n**\n** Finally, argument pBegin points to the byte immediately following the\n** end of the space required by this page for the cell-pointer area (for\n** all cells - not just those inserted by the current call). If the content\n** area must be extended to before this point in order to accomodate all\n** cells in apCell[], then the cells do not fit and non-zero is returned.\n*/\nstatic int pageInsertArray(\n  MemPage *pPg,                   /* Page to add cells to */\n  u8 *pBegin,                     /* End of cell-pointer array */\n  u8 **ppData,                    /* IN/OUT: Page content-area pointer */\n  u8 *pCellptr,                   /* Pointer to cell-pointer area */\n  int iFirst,                     /* Index of first cell to add */\n  int nCell,                      /* Number of cells to add to pPg */\n  CellArray *pCArray              /* Array of cells */\n){\n  int i = iFirst;                 /* Loop counter - cell index to insert */\n  u8 *aData = pPg->aData;         /* Complete page */\n  u8 *pData = *ppData;            /* Content area.  A subset of aData[] */\n  int iEnd = iFirst + nCell;      /* End of loop. One past last cell to ins */\n  int k;                          /* Current slot in pCArray->apEnd[] */\n  u8 *pEnd;                       /* Maximum extent of cell data */\n  assert( CORRUPT_DB || pPg->hdrOffset==0 );    /* Never called on page 1 */\n  if( iEnd<=iFirst ) return 0;\n  for(k=0; pCArray->ixNx[k]<=i && ALWAYS(k<NB*2); k++){}\n  pEnd = pCArray->apEnd[k];\n  while( 1 /*Exit by break*/ ){\n    int sz, rc;\n    u8 *pSlot;\n    sz = cachedCellSize(pCArray, i);\n    if( (aData[1]==0 && aData[2]==0) || (pSlot = pageFindSlot(pPg,sz,&rc))==0 ){\n      if( (pData - pBegin)<sz ) return 1;\n      pData -= sz;\n      pSlot = pData;\n    }\n    /* pSlot and pCArray->apCell[i] will never overlap on a well-formed\n    ** database.  But they might for a corrupt database.  Hence use memmove()\n    ** since memcpy() sends SIGABORT with overlapping buffers on OpenBSD */\n    assert( (pSlot+sz)<=pCArray->apCell[i]\n         || pSlot>=(pCArray->apCell[i]+sz)\n         || CORRUPT_DB );\n    if( (uptr)(pCArray->apCell[i]+sz)>(uptr)pEnd\n     && (uptr)(pCArray->apCell[i])<(uptr)pEnd\n    ){\n      assert( CORRUPT_DB );\n      (void)SQLITE_CORRUPT_BKPT;\n      return 1;\n    }\n    memmove(pSlot, pCArray->apCell[i], sz);\n    put2byte(pCellptr, (pSlot - aData));\n    pCellptr += 2;\n    i++;\n    if( i>=iEnd ) break;\n    if( pCArray->ixNx[k]<=i ){\n      k++;\n      pEnd = pCArray->apEnd[k];\n    }\n  }\n  *ppData = pData;\n  return 0;\n}\n\n/*\n** The pCArray object contains pointers to b-tree cells and their sizes.\n**\n** This function adds the space associated with each cell in the array\n** that is currently stored within the body of pPg to the pPg free-list.\n** The cell-pointers and other fields of the page are not updated.\n**\n** This function returns the total number of cells added to the free-list.\n*/\nstatic int pageFreeArray(\n  MemPage *pPg,                   /* Page to edit */\n  int iFirst,                     /* First cell to delete */\n  int nCell,                      /* Cells to delete */\n  CellArray *pCArray              /* Array of cells */\n){\n  u8 * const aData = pPg->aData;\n  u8 * const pEnd = &aData[pPg->pBt->usableSize];\n  u8 * const pStart = &aData[pPg->hdrOffset + 8 + pPg->childPtrSize];\n  int nRet = 0;\n  int i;\n  int iEnd = iFirst + nCell;\n  u8 *pFree = 0;\n  int szFree = 0;\n\n  for(i=iFirst; i<iEnd; i++){\n    u8 *pCell = pCArray->apCell[i];\n    if( SQLITE_WITHIN(pCell, pStart, pEnd) ){\n      int sz;\n      /* No need to use cachedCellSize() here.  The sizes of all cells that\n      ** are to be freed have already been computing while deciding which\n      ** cells need freeing */\n      sz = pCArray->szCell[i];  assert( sz>0 );\n      if( pFree!=(pCell + sz) ){\n        if( pFree ){\n          assert( pFree>aData && (pFree - aData)<65536 );\n          freeSpace(pPg, (u16)(pFree - aData), szFree);\n        }\n        pFree = pCell;\n        szFree = sz;\n        if( pFree+sz>pEnd ) return 0;\n      }else{\n        pFree = pCell;\n        szFree += sz;\n      }\n      nRet++;\n    }\n  }\n  if( pFree ){\n    assert( pFree>aData && (pFree - aData)<65536 );\n    freeSpace(pPg, (u16)(pFree - aData), szFree);\n  }\n  return nRet;\n}\n\n/*\n** pCArray contains pointers to and sizes of all cells in the page being\n** balanced.  The current page, pPg, has pPg->nCell cells starting with\n** pCArray->apCell[iOld].  After balancing, this page should hold nNew cells\n** starting at apCell[iNew].\n**\n** This routine makes the necessary adjustments to pPg so that it contains\n** the correct cells after being balanced.\n**\n** The pPg->nFree field is invalid when this function returns. It is the\n** responsibility of the caller to set it correctly.\n*/\nstatic int editPage(\n  MemPage *pPg,                   /* Edit this page */\n  int iOld,                       /* Index of first cell currently on page */\n  int iNew,                       /* Index of new first cell on page */\n  int nNew,                       /* Final number of cells on page */\n  CellArray *pCArray              /* Array of cells and sizes */\n){\n  u8 * const aData = pPg->aData;\n  const int hdr = pPg->hdrOffset;\n  u8 *pBegin = &pPg->aCellIdx[nNew * 2];\n  int nCell = pPg->nCell;       /* Cells stored on pPg */\n  u8 *pData;\n  u8 *pCellptr;\n  int i;\n  int iOldEnd = iOld + pPg->nCell + pPg->nOverflow;\n  int iNewEnd = iNew + nNew;\n\n#ifdef SQLITE_DEBUG\n  u8 *pTmp = sqlite3PagerTempSpace(pPg->pBt->pPager);\n  memcpy(pTmp, aData, pPg->pBt->usableSize);\n#endif\n\n  /* Remove cells from the start and end of the page */\n  assert( nCell>=0 );\n  if( iOld<iNew ){\n    int nShift = pageFreeArray(pPg, iOld, iNew-iOld, pCArray);\n    if( nShift>nCell ) return SQLITE_CORRUPT_BKPT;\n    memmove(pPg->aCellIdx, &pPg->aCellIdx[nShift*2], nCell*2);\n    nCell -= nShift;\n  }\n  if( iNewEnd < iOldEnd ){\n    int nTail = pageFreeArray(pPg, iNewEnd, iOldEnd - iNewEnd, pCArray);\n    assert( nCell>=nTail );\n    nCell -= nTail;\n  }\n\n  pData = &aData[get2byteNotZero(&aData[hdr+5])];\n  if( pData<pBegin ) goto editpage_fail;\n\n  /* Add cells to the start of the page */\n  if( iNew<iOld ){\n    int nAdd = MIN(nNew,iOld-iNew);\n    assert( (iOld-iNew)<nNew || nCell==0 || CORRUPT_DB );\n    assert( nAdd>=0 );\n    pCellptr = pPg->aCellIdx;\n    memmove(&pCellptr[nAdd*2], pCellptr, nCell*2);\n    if( pageInsertArray(\n          pPg, pBegin, &pData, pCellptr,\n          iNew, nAdd, pCArray\n    ) ) goto editpage_fail;\n    nCell += nAdd;\n  }\n\n  /* Add any overflow cells */\n  for(i=0; i<pPg->nOverflow; i++){\n    int iCell = (iOld + pPg->aiOvfl[i]) - iNew;\n    if( iCell>=0 && iCell<nNew ){\n      pCellptr = &pPg->aCellIdx[iCell * 2];\n      assert( nCell>=iCell );\n      memmove(&pCellptr[2], pCellptr, (nCell - iCell) * 2);\n      nCell++;\n      if( pageInsertArray(\n            pPg, pBegin, &pData, pCellptr,\n            iCell+iNew, 1, pCArray\n      ) ) goto editpage_fail;\n    }\n  }\n\n  /* Append cells to the end of the page */\n  assert( nCell>=0 );\n  pCellptr = &pPg->aCellIdx[nCell*2];\n  if( pageInsertArray(\n        pPg, pBegin, &pData, pCellptr,\n        iNew+nCell, nNew-nCell, pCArray\n  ) ) goto editpage_fail;\n\n  pPg->nCell = nNew;\n  pPg->nOverflow = 0;\n\n  put2byte(&aData[hdr+3], pPg->nCell);\n  put2byte(&aData[hdr+5], pData - aData);\n\n#ifdef SQLITE_DEBUG\n  for(i=0; i<nNew && !CORRUPT_DB; i++){\n    u8 *pCell = pCArray->apCell[i+iNew];\n    int iOff = get2byteAligned(&pPg->aCellIdx[i*2]);\n    if( SQLITE_WITHIN(pCell, aData, &aData[pPg->pBt->usableSize]) ){\n      pCell = &pTmp[pCell - aData];\n    }\n    assert( 0==memcmp(pCell, &aData[iOff],\n            pCArray->pRef->xCellSize(pCArray->pRef, pCArray->apCell[i+iNew])) );\n  }\n#endif\n\n  return SQLITE_OK;\n editpage_fail:\n  /* Unable to edit this page. Rebuild it from scratch instead. */\n  populateCellCache(pCArray, iNew, nNew);\n  return rebuildPage(pCArray, iNew, nNew, pPg);\n}\n\n\n#ifndef SQLITE_OMIT_QUICKBALANCE\n/*\n** This version of balance() handles the common special case where\n** a new entry is being inserted on the extreme right-end of the\n** tree, in other words, when the new entry will become the largest\n** entry in the tree.\n**\n** Instead of trying to balance the 3 right-most leaf pages, just add\n** a new page to the right-hand side and put the one new entry in\n** that page.  This leaves the right side of the tree somewhat\n** unbalanced.  But odds are that we will be inserting new entries\n** at the end soon afterwards so the nearly empty page will quickly\n** fill up.  On average.\n**\n** pPage is the leaf page which is the right-most page in the tree.\n** pParent is its parent.  pPage must have a single overflow entry\n** which is also the right-most entry on the page.\n**\n** The pSpace buffer is used to store a temporary copy of the divider\n** cell that will be inserted into pParent. Such a cell consists of a 4\n** byte page number followed by a variable length integer. In other\n** words, at most 13 bytes. Hence the pSpace buffer must be at\n** least 13 bytes in size.\n*/\nstatic int balance_quick(MemPage *pParent, MemPage *pPage, u8 *pSpace){\n  BtShared *const pBt = pPage->pBt;    /* B-Tree Database */\n  MemPage *pNew;                       /* Newly allocated page */\n  int rc;                              /* Return Code */\n  Pgno pgnoNew;                        /* Page number of pNew */\n\n  assert( sqlite3_mutex_held(pPage->pBt->mutex) );\n  assert( sqlite3PagerIswriteable(pParent->pDbPage) );\n  assert( pPage->nOverflow==1 );\n\n  if( pPage->nCell==0 ) return SQLITE_CORRUPT_BKPT;  /* dbfuzz001.test */\n\n  /* Allocate a new page. This page will become the right-sibling of \n  ** pPage. Make the parent page writable, so that the new divider cell\n  ** may be inserted. If both these operations are successful, proceed.\n  */\n  rc = allocateBtreePage(pBt, &pNew, &pgnoNew, 0, 0);\n\n  if( rc==SQLITE_OK ){\n\n    u8 *pOut = &pSpace[4];\n    u8 *pCell = pPage->apOvfl[0];\n    u16 szCell = pPage->xCellSize(pPage, pCell);\n    u8 *pStop;\n    CellArray b;\n\n    assert( sqlite3PagerIswriteable(pNew->pDbPage) );\n    assert( CORRUPT_DB || pPage->aData[0]==(PTF_INTKEY|PTF_LEAFDATA|PTF_LEAF) );\n    zeroPage(pNew, PTF_INTKEY|PTF_LEAFDATA|PTF_LEAF);\n    b.nCell = 1;\n    b.pRef = pPage;\n    b.apCell = &pCell;\n    b.szCell = &szCell;\n    b.apEnd[0] = pPage->aDataEnd;\n    b.ixNx[0] = 2;\n    rc = rebuildPage(&b, 0, 1, pNew);\n    if( NEVER(rc) ){\n      releasePage(pNew);\n      return rc;\n    }\n    pNew->nFree = pBt->usableSize - pNew->cellOffset - 2 - szCell;\n\n    /* If this is an auto-vacuum database, update the pointer map\n    ** with entries for the new page, and any pointer from the \n    ** cell on the page to an overflow page. If either of these\n    ** operations fails, the return code is set, but the contents\n    ** of the parent page are still manipulated by thh code below.\n    ** That is Ok, at this point the parent page is guaranteed to\n    ** be marked as dirty. Returning an error code will cause a\n    ** rollback, undoing any changes made to the parent page.\n    */\n    if( ISAUTOVACUUM ){\n      ptrmapPut(pBt, pgnoNew, PTRMAP_BTREE, pParent->pgno, &rc);\n      if( szCell>pNew->minLocal ){\n        ptrmapPutOvflPtr(pNew, pNew, pCell, &rc);\n      }\n    }\n  \n    /* Create a divider cell to insert into pParent. The divider cell\n    ** consists of a 4-byte page number (the page number of pPage) and\n    ** a variable length key value (which must be the same value as the\n    ** largest key on pPage).\n    **\n    ** To find the largest key value on pPage, first find the right-most \n    ** cell on pPage. The first two fields of this cell are the \n    ** record-length (a variable length integer at most 32-bits in size)\n    ** and the key value (a variable length integer, may have any value).\n    ** The first of the while(...) loops below skips over the record-length\n    ** field. The second while(...) loop copies the key value from the\n    ** cell on pPage into the pSpace buffer.\n    */\n    pCell = findCell(pPage, pPage->nCell-1);\n    pStop = &pCell[9];\n    while( (*(pCell++)&0x80) && pCell<pStop );\n    pStop = &pCell[9];\n    while( ((*(pOut++) = *(pCell++))&0x80) && pCell<pStop );\n\n    /* Insert the new divider cell into pParent. */\n    if( rc==SQLITE_OK ){\n      insertCell(pParent, pParent->nCell, pSpace, (int)(pOut-pSpace),\n                   0, pPage->pgno, &rc);\n    }\n\n    /* Set the right-child pointer of pParent to point to the new page. */\n    put4byte(&pParent->aData[pParent->hdrOffset+8], pgnoNew);\n  \n    /* Release the reference to the new page. */\n    releasePage(pNew);\n  }\n\n  return rc;\n}\n#endif /* SQLITE_OMIT_QUICKBALANCE */\n\n#if 0\n/*\n** This function does not contribute anything to the operation of SQLite.\n** it is sometimes activated temporarily while debugging code responsible \n** for setting pointer-map entries.\n*/\nstatic int ptrmapCheckPages(MemPage **apPage, int nPage){\n  int i, j;\n  for(i=0; i<nPage; i++){\n    Pgno n;\n    u8 e;\n    MemPage *pPage = apPage[i];\n    BtShared *pBt = pPage->pBt;\n    assert( pPage->isInit );\n\n    for(j=0; j<pPage->nCell; j++){\n      CellInfo info;\n      u8 *z;\n     \n      z = findCell(pPage, j);\n      pPage->xParseCell(pPage, z, &info);\n      if( info.nLocal<info.nPayload ){\n        Pgno ovfl = get4byte(&z[info.nSize-4]);\n        ptrmapGet(pBt, ovfl, &e, &n);\n        assert( n==pPage->pgno && e==PTRMAP_OVERFLOW1 );\n      }\n      if( !pPage->leaf ){\n        Pgno child = get4byte(z);\n        ptrmapGet(pBt, child, &e, &n);\n        assert( n==pPage->pgno && e==PTRMAP_BTREE );\n      }\n    }\n    if( !pPage->leaf ){\n      Pgno child = get4byte(&pPage->aData[pPage->hdrOffset+8]);\n      ptrmapGet(pBt, child, &e, &n);\n      assert( n==pPage->pgno && e==PTRMAP_BTREE );\n    }\n  }\n  return 1;\n}\n#endif\n\n/*\n** This function is used to copy the contents of the b-tree node stored \n** on page pFrom to page pTo. If page pFrom was not a leaf page, then\n** the pointer-map entries for each child page are updated so that the\n** parent page stored in the pointer map is page pTo. If pFrom contained\n** any cells with overflow page pointers, then the corresponding pointer\n** map entries are also updated so that the parent page is page pTo.\n**\n** If pFrom is currently carrying any overflow cells (entries in the\n** MemPage.apOvfl[] array), they are not copied to pTo. \n**\n** Before returning, page pTo is reinitialized using btreeInitPage().\n**\n** The performance of this function is not critical. It is only used by \n** the balance_shallower() and balance_deeper() procedures, neither of\n** which are called often under normal circumstances.\n*/\nstatic void copyNodeContent(MemPage *pFrom, MemPage *pTo, int *pRC){\n  if( (*pRC)==SQLITE_OK ){\n    BtShared * const pBt = pFrom->pBt;\n    u8 * const aFrom = pFrom->aData;\n    u8 * const aTo = pTo->aData;\n    int const iFromHdr = pFrom->hdrOffset;\n    int const iToHdr = ((pTo->pgno==1) ? 100 : 0);\n    int rc;\n    int iData;\n  \n  \n    assert( pFrom->isInit );\n    assert( pFrom->nFree>=iToHdr );\n    assert( get2byte(&aFrom[iFromHdr+5]) <= (int)pBt->usableSize );\n  \n    /* Copy the b-tree node content from page pFrom to page pTo. */\n    iData = get2byte(&aFrom[iFromHdr+5]);\n    memcpy(&aTo[iData], &aFrom[iData], pBt->usableSize-iData);\n    memcpy(&aTo[iToHdr], &aFrom[iFromHdr], pFrom->cellOffset + 2*pFrom->nCell);\n  \n    /* Reinitialize page pTo so that the contents of the MemPage structure\n    ** match the new data. The initialization of pTo can actually fail under\n    ** fairly obscure circumstances, even though it is a copy of initialized \n    ** page pFrom.\n    */\n    pTo->isInit = 0;\n    rc = btreeInitPage(pTo);\n    if( rc!=SQLITE_OK ){\n      *pRC = rc;\n      return;\n    }\n  \n    /* If this is an auto-vacuum database, update the pointer-map entries\n    ** for any b-tree or overflow pages that pTo now contains the pointers to.\n    */\n    if( ISAUTOVACUUM ){\n      *pRC = setChildPtrmaps(pTo);\n    }\n  }\n}\n\n/*\n** This routine redistributes cells on the iParentIdx'th child of pParent\n** (hereafter \"the page\") and up to 2 siblings so that all pages have about the\n** same amount of free space. Usually a single sibling on either side of the\n** page are used in the balancing, though both siblings might come from one\n** side if the page is the first or last child of its parent. If the page \n** has fewer than 2 siblings (something which can only happen if the page\n** is a root page or a child of a root page) then all available siblings\n** participate in the balancing.\n**\n** The number of siblings of the page might be increased or decreased by \n** one or two in an effort to keep pages nearly full but not over full. \n**\n** Note that when this routine is called, some of the cells on the page\n** might not actually be stored in MemPage.aData[]. This can happen\n** if the page is overfull. This routine ensures that all cells allocated\n** to the page and its siblings fit into MemPage.aData[] before returning.\n**\n** In the course of balancing the page and its siblings, cells may be\n** inserted into or removed from the parent page (pParent). Doing so\n** may cause the parent page to become overfull or underfull. If this\n** happens, it is the responsibility of the caller to invoke the correct\n** balancing routine to fix this problem (see the balance() routine). \n**\n** If this routine fails for any reason, it might leave the database\n** in a corrupted state. So if this routine fails, the database should\n** be rolled back.\n**\n** The third argument to this function, aOvflSpace, is a pointer to a\n** buffer big enough to hold one page. If while inserting cells into the parent\n** page (pParent) the parent page becomes overfull, this buffer is\n** used to store the parent's overflow cells. Because this function inserts\n** a maximum of four divider cells into the parent page, and the maximum\n** size of a cell stored within an internal node is always less than 1/4\n** of the page-size, the aOvflSpace[] buffer is guaranteed to be large\n** enough for all overflow cells.\n**\n** If aOvflSpace is set to a null pointer, this function returns \n** SQLITE_NOMEM.\n*/\nstatic int balance_nonroot(\n  MemPage *pParent,               /* Parent page of siblings being balanced */\n  int iParentIdx,                 /* Index of \"the page\" in pParent */\n  u8 *aOvflSpace,                 /* page-size bytes of space for parent ovfl */\n  int isRoot,                     /* True if pParent is a root-page */\n  int bBulk                       /* True if this call is part of a bulk load */\n){\n  BtShared *pBt;               /* The whole database */\n  int nMaxCells = 0;           /* Allocated size of apCell, szCell, aFrom. */\n  int nNew = 0;                /* Number of pages in apNew[] */\n  int nOld;                    /* Number of pages in apOld[] */\n  int i, j, k;                 /* Loop counters */\n  int nxDiv;                   /* Next divider slot in pParent->aCell[] */\n  int rc = SQLITE_OK;          /* The return code */\n  u16 leafCorrection;          /* 4 if pPage is a leaf.  0 if not */\n  int leafData;                /* True if pPage is a leaf of a LEAFDATA tree */\n  int usableSpace;             /* Bytes in pPage beyond the header */\n  int pageFlags;               /* Value of pPage->aData[0] */\n  int iSpace1 = 0;             /* First unused byte of aSpace1[] */\n  int iOvflSpace = 0;          /* First unused byte of aOvflSpace[] */\n  int szScratch;               /* Size of scratch memory requested */\n  MemPage *apOld[NB];          /* pPage and up to two siblings */\n  MemPage *apNew[NB+2];        /* pPage and up to NB siblings after balancing */\n  u8 *pRight;                  /* Location in parent of right-sibling pointer */\n  u8 *apDiv[NB-1];             /* Divider cells in pParent */\n  int cntNew[NB+2];            /* Index in b.paCell[] of cell after i-th page */\n  int cntOld[NB+2];            /* Old index in b.apCell[] */\n  int szNew[NB+2];             /* Combined size of cells placed on i-th page */\n  u8 *aSpace1;                 /* Space for copies of dividers cells */\n  Pgno pgno;                   /* Temp var to store a page number in */\n  u8 abDone[NB+2];             /* True after i'th new page is populated */\n  Pgno aPgno[NB+2];            /* Page numbers of new pages before shuffling */\n  Pgno aPgOrder[NB+2];         /* Copy of aPgno[] used for sorting pages */\n  u16 aPgFlags[NB+2];          /* flags field of new pages before shuffling */\n  CellArray b;                  /* Parsed information on cells being balanced */\n\n  memset(abDone, 0, sizeof(abDone));\n  b.nCell = 0;\n  b.apCell = 0;\n  pBt = pParent->pBt;\n  assert( sqlite3_mutex_held(pBt->mutex) );\n  assert( sqlite3PagerIswriteable(pParent->pDbPage) );\n\n  /* At this point pParent may have at most one overflow cell. And if\n  ** this overflow cell is present, it must be the cell with \n  ** index iParentIdx. This scenario comes about when this function\n  ** is called (indirectly) from sqlite3BtreeDelete().\n  */\n  assert( pParent->nOverflow==0 || pParent->nOverflow==1 );\n  assert( pParent->nOverflow==0 || pParent->aiOvfl[0]==iParentIdx );\n\n  if( !aOvflSpace ){\n    return SQLITE_NOMEM_BKPT;\n  }\n\n  /* Find the sibling pages to balance. Also locate the cells in pParent \n  ** that divide the siblings. An attempt is made to find NN siblings on \n  ** either side of pPage. More siblings are taken from one side, however, \n  ** if there are fewer than NN siblings on the other side. If pParent\n  ** has NB or fewer children then all children of pParent are taken.  \n  **\n  ** This loop also drops the divider cells from the parent page. This\n  ** way, the remainder of the function does not have to deal with any\n  ** overflow cells in the parent page, since if any existed they will\n  ** have already been removed.\n  */\n  i = pParent->nOverflow + pParent->nCell;\n  if( i<2 ){\n    nxDiv = 0;\n  }else{\n    assert( bBulk==0 || bBulk==1 );\n    if( iParentIdx==0 ){                 \n      nxDiv = 0;\n    }else if( iParentIdx==i ){\n      nxDiv = i-2+bBulk;\n    }else{\n      nxDiv = iParentIdx-1;\n    }\n    i = 2-bBulk;\n  }\n  nOld = i+1;\n  if( (i+nxDiv-pParent->nOverflow)==pParent->nCell ){\n    pRight = &pParent->aData[pParent->hdrOffset+8];\n  }else{\n    pRight = findCell(pParent, i+nxDiv-pParent->nOverflow);\n  }\n  pgno = get4byte(pRight);\n  while( 1 ){\n    rc = getAndInitPage(pBt, pgno, &apOld[i], 0, 0);\n    if( rc ){\n      memset(apOld, 0, (i+1)*sizeof(MemPage*));\n      goto balance_cleanup;\n    }\n    nMaxCells += 1+apOld[i]->nCell+apOld[i]->nOverflow;\n    if( (i--)==0 ) break;\n\n    if( pParent->nOverflow && i+nxDiv==pParent->aiOvfl[0] ){\n      apDiv[i] = pParent->apOvfl[0];\n      pgno = get4byte(apDiv[i]);\n      szNew[i] = pParent->xCellSize(pParent, apDiv[i]);\n      pParent->nOverflow = 0;\n    }else{\n      apDiv[i] = findCell(pParent, i+nxDiv-pParent->nOverflow);\n      pgno = get4byte(apDiv[i]);\n      szNew[i] = pParent->xCellSize(pParent, apDiv[i]);\n\n      /* Drop the cell from the parent page. apDiv[i] still points to\n      ** the cell within the parent, even though it has been dropped.\n      ** This is safe because dropping a cell only overwrites the first\n      ** four bytes of it, and this function does not need the first\n      ** four bytes of the divider cell. So the pointer is safe to use\n      ** later on.  \n      **\n      ** But not if we are in secure-delete mode. In secure-delete mode,\n      ** the dropCell() routine will overwrite the entire cell with zeroes.\n      ** In this case, temporarily copy the cell into the aOvflSpace[]\n      ** buffer. It will be copied out again as soon as the aSpace[] buffer\n      ** is allocated.  */\n      if( pBt->btsFlags & BTS_FAST_SECURE ){\n        int iOff;\n\n        iOff = SQLITE_PTR_TO_INT(apDiv[i]) - SQLITE_PTR_TO_INT(pParent->aData);\n        if( (iOff+szNew[i])>(int)pBt->usableSize ){\n          rc = SQLITE_CORRUPT_BKPT;\n          memset(apOld, 0, (i+1)*sizeof(MemPage*));\n          goto balance_cleanup;\n        }else{\n          memcpy(&aOvflSpace[iOff], apDiv[i], szNew[i]);\n          apDiv[i] = &aOvflSpace[apDiv[i]-pParent->aData];\n        }\n      }\n      dropCell(pParent, i+nxDiv-pParent->nOverflow, szNew[i], &rc);\n    }\n  }\n\n  /* Make nMaxCells a multiple of 4 in order to preserve 8-byte\n  ** alignment */\n  nMaxCells = (nMaxCells + 3)&~3;\n\n  /*\n  ** Allocate space for memory structures\n  */\n  szScratch =\n       nMaxCells*sizeof(u8*)                       /* b.apCell */\n     + nMaxCells*sizeof(u16)                       /* b.szCell */\n     + pBt->pageSize;                              /* aSpace1 */\n\n  assert( szScratch<=6*(int)pBt->pageSize );\n  b.apCell = sqlite3StackAllocRaw(0, szScratch );\n  if( b.apCell==0 ){\n    rc = SQLITE_NOMEM_BKPT;\n    goto balance_cleanup;\n  }\n  b.szCell = (u16*)&b.apCell[nMaxCells];\n  aSpace1 = (u8*)&b.szCell[nMaxCells];\n  assert( EIGHT_BYTE_ALIGNMENT(aSpace1) );\n\n  /*\n  ** Load pointers to all cells on sibling pages and the divider cells\n  ** into the local b.apCell[] array.  Make copies of the divider cells\n  ** into space obtained from aSpace1[]. The divider cells have already\n  ** been removed from pParent.\n  **\n  ** If the siblings are on leaf pages, then the child pointers of the\n  ** divider cells are stripped from the cells before they are copied\n  ** into aSpace1[].  In this way, all cells in b.apCell[] are without\n  ** child pointers.  If siblings are not leaves, then all cell in\n  ** b.apCell[] include child pointers.  Either way, all cells in b.apCell[]\n  ** are alike.\n  **\n  ** leafCorrection:  4 if pPage is a leaf.  0 if pPage is not a leaf.\n  **       leafData:  1 if pPage holds key+data and pParent holds only keys.\n  */\n  b.pRef = apOld[0];\n  leafCorrection = b.pRef->leaf*4;\n  leafData = b.pRef->intKeyLeaf;\n  for(i=0; i<nOld; i++){\n    MemPage *pOld = apOld[i];\n    int limit = pOld->nCell;\n    u8 *aData = pOld->aData;\n    u16 maskPage = pOld->maskPage;\n    u8 *piCell = aData + pOld->cellOffset;\n    u8 *piEnd;\n\n    /* Verify that all sibling pages are of the same \"type\" (table-leaf,\n    ** table-interior, index-leaf, or index-interior).\n    */\n    if( pOld->aData[0]!=apOld[0]->aData[0] ){\n      rc = SQLITE_CORRUPT_BKPT;\n      goto balance_cleanup;\n    }\n\n    /* Load b.apCell[] with pointers to all cells in pOld.  If pOld\n    ** contains overflow cells, include them in the b.apCell[] array\n    ** in the correct spot.\n    **\n    ** Note that when there are multiple overflow cells, it is always the\n    ** case that they are sequential and adjacent.  This invariant arises\n    ** because multiple overflows can only occurs when inserting divider\n    ** cells into a parent on a prior balance, and divider cells are always\n    ** adjacent and are inserted in order.  There is an assert() tagged\n    ** with \"NOTE 1\" in the overflow cell insertion loop to prove this\n    ** invariant.\n    **\n    ** This must be done in advance.  Once the balance starts, the cell\n    ** offset section of the btree page will be overwritten and we will no\n    ** long be able to find the cells if a pointer to each cell is not saved\n    ** first.\n    */\n    memset(&b.szCell[b.nCell], 0, sizeof(b.szCell[0])*(limit+pOld->nOverflow));\n    if( pOld->nOverflow>0 ){\n      limit = pOld->aiOvfl[0];\n      for(j=0; j<limit; j++){\n        b.apCell[b.nCell] = aData + (maskPage & get2byteAligned(piCell));\n        piCell += 2;\n        b.nCell++;\n      }\n      for(k=0; k<pOld->nOverflow; k++){\n        assert( k==0 || pOld->aiOvfl[k-1]+1==pOld->aiOvfl[k] );/* NOTE 1 */\n        b.apCell[b.nCell] = pOld->apOvfl[k];\n        b.nCell++;\n      }\n    }\n    piEnd = aData + pOld->cellOffset + 2*pOld->nCell;\n    while( piCell<piEnd ){\n      assert( b.nCell<nMaxCells );\n      b.apCell[b.nCell] = aData + (maskPage & get2byteAligned(piCell));\n      piCell += 2;\n      b.nCell++;\n    }\n\n    cntOld[i] = b.nCell;\n    if( i<nOld-1 && !leafData){\n      u16 sz = (u16)szNew[i];\n      u8 *pTemp;\n      assert( b.nCell<nMaxCells );\n      b.szCell[b.nCell] = sz;\n      pTemp = &aSpace1[iSpace1];\n      iSpace1 += sz;\n      assert( sz<=pBt->maxLocal+23 );\n      assert( iSpace1 <= (int)pBt->pageSize );\n      memcpy(pTemp, apDiv[i], sz);\n      b.apCell[b.nCell] = pTemp+leafCorrection;\n      assert( leafCorrection==0 || leafCorrection==4 );\n      b.szCell[b.nCell] = b.szCell[b.nCell] - leafCorrection;\n      if( !pOld->leaf ){\n        assert( leafCorrection==0 );\n        assert( pOld->hdrOffset==0 );\n        /* The right pointer of the child page pOld becomes the left\n        ** pointer of the divider cell */\n        memcpy(b.apCell[b.nCell], &pOld->aData[8], 4);\n      }else{\n        assert( leafCorrection==4 );\n        while( b.szCell[b.nCell]<4 ){\n          /* Do not allow any cells smaller than 4 bytes. If a smaller cell\n          ** does exist, pad it with 0x00 bytes. */\n          assert( b.szCell[b.nCell]==3 || CORRUPT_DB );\n          assert( b.apCell[b.nCell]==&aSpace1[iSpace1-3] || CORRUPT_DB );\n          aSpace1[iSpace1++] = 0x00;\n          b.szCell[b.nCell]++;\n        }\n      }\n      b.nCell++;\n    }\n  }\n\n  /*\n  ** Figure out the number of pages needed to hold all b.nCell cells.\n  ** Store this number in \"k\".  Also compute szNew[] which is the total\n  ** size of all cells on the i-th page and cntNew[] which is the index\n  ** in b.apCell[] of the cell that divides page i from page i+1.  \n  ** cntNew[k] should equal b.nCell.\n  **\n  ** Values computed by this block:\n  **\n  **           k: The total number of sibling pages\n  **    szNew[i]: Spaced used on the i-th sibling page.\n  **   cntNew[i]: Index in b.apCell[] and b.szCell[] for the first cell to\n  **              the right of the i-th sibling page.\n  ** usableSpace: Number of bytes of space available on each sibling.\n  ** \n  */\n  usableSpace = pBt->usableSize - 12 + leafCorrection;\n  for(i=k=0; i<nOld; i++, k++){\n    MemPage *p = apOld[i];\n    b.apEnd[k] = p->aDataEnd;\n    b.ixNx[k] = cntOld[i];\n    if( !leafData ){\n      k++;\n      b.apEnd[k] = pParent->aDataEnd;\n      b.ixNx[k] = cntOld[i]+1;\n    }\n    szNew[i] = usableSpace - p->nFree;\n    for(j=0; j<p->nOverflow; j++){\n      szNew[i] += 2 + p->xCellSize(p, p->apOvfl[j]);\n    }\n    cntNew[i] = cntOld[i];\n  }\n  k = nOld;\n  for(i=0; i<k; i++){\n    int sz;\n    while( szNew[i]>usableSpace ){\n      if( i+1>=k ){\n        k = i+2;\n        if( k>NB+2 ){ rc = SQLITE_CORRUPT_BKPT; goto balance_cleanup; }\n        szNew[k-1] = 0;\n        cntNew[k-1] = b.nCell;\n      }\n      sz = 2 + cachedCellSize(&b, cntNew[i]-1);\n      szNew[i] -= sz;\n      if( !leafData ){\n        if( cntNew[i]<b.nCell ){\n          sz = 2 + cachedCellSize(&b, cntNew[i]);\n        }else{\n          sz = 0;\n        }\n      }\n      szNew[i+1] += sz;\n      cntNew[i]--;\n    }\n    while( cntNew[i]<b.nCell ){\n      sz = 2 + cachedCellSize(&b, cntNew[i]);\n      if( szNew[i]+sz>usableSpace ) break;\n      szNew[i] += sz;\n      cntNew[i]++;\n      if( !leafData ){\n        if( cntNew[i]<b.nCell ){\n          sz = 2 + cachedCellSize(&b, cntNew[i]);\n        }else{\n          sz = 0;\n        }\n      }\n      szNew[i+1] -= sz;\n    }\n    if( cntNew[i]>=b.nCell ){\n      k = i+1;\n    }else if( cntNew[i] <= (i>0 ? cntNew[i-1] : 0) ){\n      rc = SQLITE_CORRUPT_BKPT;\n      goto balance_cleanup;\n    }\n  }\n\n  /*\n  ** The packing computed by the previous block is biased toward the siblings\n  ** on the left side (siblings with smaller keys). The left siblings are\n  ** always nearly full, while the right-most sibling might be nearly empty.\n  ** The next block of code attempts to adjust the packing of siblings to\n  ** get a better balance.\n  **\n  ** This adjustment is more than an optimization.  The packing above might\n  ** be so out of balance as to be illegal.  For example, the right-most\n  ** sibling might be completely empty.  This adjustment is not optional.\n  */\n  for(i=k-1; i>0; i--){\n    int szRight = szNew[i];  /* Size of sibling on the right */\n    int szLeft = szNew[i-1]; /* Size of sibling on the left */\n    int r;              /* Index of right-most cell in left sibling */\n    int d;              /* Index of first cell to the left of right sibling */\n\n    r = cntNew[i-1] - 1;\n    d = r + 1 - leafData;\n    (void)cachedCellSize(&b, d);\n    do{\n      assert( d<nMaxCells );\n      assert( r<nMaxCells );\n      (void)cachedCellSize(&b, r);\n      if( szRight!=0\n       && (bBulk || szRight+b.szCell[d]+2 > szLeft-(b.szCell[r]+(i==k-1?0:2)))){\n        break;\n      }\n      szRight += b.szCell[d] + 2;\n      szLeft -= b.szCell[r] + 2;\n      cntNew[i-1] = r;\n      r--;\n      d--;\n    }while( r>=0 );\n    szNew[i] = szRight;\n    szNew[i-1] = szLeft;\n    if( cntNew[i-1] <= (i>1 ? cntNew[i-2] : 0) ){\n      rc = SQLITE_CORRUPT_BKPT;\n      goto balance_cleanup;\n    }\n  }\n\n  /* Sanity check:  For a non-corrupt database file one of the follwing\n  ** must be true:\n  **    (1) We found one or more cells (cntNew[0])>0), or\n  **    (2) pPage is a virtual root page.  A virtual root page is when\n  **        the real root page is page 1 and we are the only child of\n  **        that page.\n  */\n  assert( cntNew[0]>0 || (pParent->pgno==1 && pParent->nCell==0) || CORRUPT_DB);\n  TRACE((\"BALANCE: old: %d(nc=%d) %d(nc=%d) %d(nc=%d)\\n\",\n    apOld[0]->pgno, apOld[0]->nCell,\n    nOld>=2 ? apOld[1]->pgno : 0, nOld>=2 ? apOld[1]->nCell : 0,\n    nOld>=3 ? apOld[2]->pgno : 0, nOld>=3 ? apOld[2]->nCell : 0\n  ));\n\n  /*\n  ** Allocate k new pages.  Reuse old pages where possible.\n  */\n  pageFlags = apOld[0]->aData[0];\n  for(i=0; i<k; i++){\n    MemPage *pNew;\n    if( i<nOld ){\n      pNew = apNew[i] = apOld[i];\n      apOld[i] = 0;\n      rc = sqlite3PagerWrite(pNew->pDbPage);\n      nNew++;\n      if( rc ) goto balance_cleanup;\n    }else{\n      assert( i>0 );\n      rc = allocateBtreePage(pBt, &pNew, &pgno, (bBulk ? 1 : pgno), 0);\n      if( rc ) goto balance_cleanup;\n      zeroPage(pNew, pageFlags);\n      apNew[i] = pNew;\n      nNew++;\n      cntOld[i] = b.nCell;\n\n      /* Set the pointer-map entry for the new sibling page. */\n      if( ISAUTOVACUUM ){\n        ptrmapPut(pBt, pNew->pgno, PTRMAP_BTREE, pParent->pgno, &rc);\n        if( rc!=SQLITE_OK ){\n          goto balance_cleanup;\n        }\n      }\n    }\n  }\n\n  /*\n  ** Reassign page numbers so that the new pages are in ascending order. \n  ** This helps to keep entries in the disk file in order so that a scan\n  ** of the table is closer to a linear scan through the file. That in turn \n  ** helps the operating system to deliver pages from the disk more rapidly.\n  **\n  ** An O(n^2) insertion sort algorithm is used, but since n is never more \n  ** than (NB+2) (a small constant), that should not be a problem.\n  **\n  ** When NB==3, this one optimization makes the database about 25% faster \n  ** for large insertions and deletions.\n  */\n  for(i=0; i<nNew; i++){\n    aPgOrder[i] = aPgno[i] = apNew[i]->pgno;\n    aPgFlags[i] = apNew[i]->pDbPage->flags;\n    for(j=0; j<i; j++){\n      if( aPgno[j]==aPgno[i] ){\n        /* This branch is taken if the set of sibling pages somehow contains\n        ** duplicate entries. This can happen if the database is corrupt. \n        ** It would be simpler to detect this as part of the loop below, but\n        ** we do the detection here in order to avoid populating the pager\n        ** cache with two separate objects associated with the same\n        ** page number.  */\n        assert( CORRUPT_DB );\n        rc = SQLITE_CORRUPT_BKPT;\n        goto balance_cleanup;\n      }\n    }\n  }\n  for(i=0; i<nNew; i++){\n    int iBest = 0;                /* aPgno[] index of page number to use */\n    for(j=1; j<nNew; j++){\n      if( aPgOrder[j]<aPgOrder[iBest] ) iBest = j;\n    }\n    pgno = aPgOrder[iBest];\n    aPgOrder[iBest] = 0xffffffff;\n    if( iBest!=i ){\n      if( iBest>i ){\n        sqlite3PagerRekey(apNew[iBest]->pDbPage, pBt->nPage+iBest+1, 0);\n      }\n      sqlite3PagerRekey(apNew[i]->pDbPage, pgno, aPgFlags[iBest]);\n      apNew[i]->pgno = pgno;\n    }\n  }\n\n  TRACE((\"BALANCE: new: %d(%d nc=%d) %d(%d nc=%d) %d(%d nc=%d) \"\n         \"%d(%d nc=%d) %d(%d nc=%d)\\n\",\n    apNew[0]->pgno, szNew[0], cntNew[0],\n    nNew>=2 ? apNew[1]->pgno : 0, nNew>=2 ? szNew[1] : 0,\n    nNew>=2 ? cntNew[1] - cntNew[0] - !leafData : 0,\n    nNew>=3 ? apNew[2]->pgno : 0, nNew>=3 ? szNew[2] : 0,\n    nNew>=3 ? cntNew[2] - cntNew[1] - !leafData : 0,\n    nNew>=4 ? apNew[3]->pgno : 0, nNew>=4 ? szNew[3] : 0,\n    nNew>=4 ? cntNew[3] - cntNew[2] - !leafData : 0,\n    nNew>=5 ? apNew[4]->pgno : 0, nNew>=5 ? szNew[4] : 0,\n    nNew>=5 ? cntNew[4] - cntNew[3] - !leafData : 0\n  ));\n\n  assert( sqlite3PagerIswriteable(pParent->pDbPage) );\n  put4byte(pRight, apNew[nNew-1]->pgno);\n\n  /* If the sibling pages are not leaves, ensure that the right-child pointer\n  ** of the right-most new sibling page is set to the value that was \n  ** originally in the same field of the right-most old sibling page. */\n  if( (pageFlags & PTF_LEAF)==0 && nOld!=nNew ){\n    MemPage *pOld = (nNew>nOld ? apNew : apOld)[nOld-1];\n    memcpy(&apNew[nNew-1]->aData[8], &pOld->aData[8], 4);\n  }\n\n  /* Make any required updates to pointer map entries associated with \n  ** cells stored on sibling pages following the balance operation. Pointer\n  ** map entries associated with divider cells are set by the insertCell()\n  ** routine. The associated pointer map entries are:\n  **\n  **   a) if the cell contains a reference to an overflow chain, the\n  **      entry associated with the first page in the overflow chain, and\n  **\n  **   b) if the sibling pages are not leaves, the child page associated\n  **      with the cell.\n  **\n  ** If the sibling pages are not leaves, then the pointer map entry \n  ** associated with the right-child of each sibling may also need to be \n  ** updated. This happens below, after the sibling pages have been \n  ** populated, not here.\n  */\n  if( ISAUTOVACUUM ){\n    MemPage *pOld;\n    MemPage *pNew = pOld = apNew[0];\n    u8 *aOld = pNew->aData;\n    int cntOldNext = pNew->nCell + pNew->nOverflow;\n    int usableSize = pBt->usableSize;\n    int iNew = 0;\n    int iOld = 0;\n\n    for(i=0; i<b.nCell; i++){\n      u8 *pCell = b.apCell[i];\n      if( i==cntOldNext ){\n        pOld = (++iOld)<nNew ? apNew[iOld] : apOld[iOld];\n        cntOldNext += pOld->nCell + pOld->nOverflow + !leafData;\n        aOld = pOld->aData;\n      }\n      if( i==cntNew[iNew] ){\n        pNew = apNew[++iNew];\n        if( !leafData ) continue;\n      }\n\n      /* Cell pCell is destined for new sibling page pNew. Originally, it\n      ** was either part of sibling page iOld (possibly an overflow cell), \n      ** or else the divider cell to the left of sibling page iOld. So,\n      ** if sibling page iOld had the same page number as pNew, and if\n      ** pCell really was a part of sibling page iOld (not a divider or\n      ** overflow cell), we can skip updating the pointer map entries.  */\n      if( iOld>=nNew\n       || pNew->pgno!=aPgno[iOld]\n       || !SQLITE_WITHIN(pCell,aOld,&aOld[usableSize])\n      ){\n        if( !leafCorrection ){\n          ptrmapPut(pBt, get4byte(pCell), PTRMAP_BTREE, pNew->pgno, &rc);\n        }\n        if( cachedCellSize(&b,i)>pNew->minLocal ){\n          ptrmapPutOvflPtr(pNew, pOld, pCell, &rc);\n        }\n        if( rc ) goto balance_cleanup;\n      }\n    }\n  }\n\n  /* Insert new divider cells into pParent. */\n  for(i=0; i<nNew-1; i++){\n    u8 *pCell;\n    u8 *pTemp;\n    int sz;\n    MemPage *pNew = apNew[i];\n    j = cntNew[i];\n\n    assert( j<nMaxCells );\n    assert( b.apCell[j]!=0 );\n    pCell = b.apCell[j];\n    sz = b.szCell[j] + leafCorrection;\n    pTemp = &aOvflSpace[iOvflSpace];\n    if( !pNew->leaf ){\n      memcpy(&pNew->aData[8], pCell, 4);\n    }else if( leafData ){\n      /* If the tree is a leaf-data tree, and the siblings are leaves, \n      ** then there is no divider cell in b.apCell[]. Instead, the divider \n      ** cell consists of the integer key for the right-most cell of \n      ** the sibling-page assembled above only.\n      */\n      CellInfo info;\n      j--;\n      pNew->xParseCell(pNew, b.apCell[j], &info);\n      pCell = pTemp;\n      sz = 4 + putVarint(&pCell[4], info.nKey);\n      pTemp = 0;\n    }else{\n      pCell -= 4;\n      /* Obscure case for non-leaf-data trees: If the cell at pCell was\n      ** previously stored on a leaf node, and its reported size was 4\n      ** bytes, then it may actually be smaller than this \n      ** (see btreeParseCellPtr(), 4 bytes is the minimum size of\n      ** any cell). But it is important to pass the correct size to \n      ** insertCell(), so reparse the cell now.\n      **\n      ** This can only happen for b-trees used to evaluate \"IN (SELECT ...)\"\n      ** and WITHOUT ROWID tables with exactly one column which is the\n      ** primary key.\n      */\n      if( b.szCell[j]==4 ){\n        assert(leafCorrection==4);\n        sz = pParent->xCellSize(pParent, pCell);\n      }\n    }\n    iOvflSpace += sz;\n    assert( sz<=pBt->maxLocal+23 );\n    assert( iOvflSpace <= (int)pBt->pageSize );\n    insertCell(pParent, nxDiv+i, pCell, sz, pTemp, pNew->pgno, &rc);\n    if( rc!=SQLITE_OK ) goto balance_cleanup;\n    assert( sqlite3PagerIswriteable(pParent->pDbPage) );\n  }\n\n  /* Now update the actual sibling pages. The order in which they are updated\n  ** is important, as this code needs to avoid disrupting any page from which\n  ** cells may still to be read. In practice, this means:\n  **\n  **  (1) If cells are moving left (from apNew[iPg] to apNew[iPg-1])\n  **      then it is not safe to update page apNew[iPg] until after\n  **      the left-hand sibling apNew[iPg-1] has been updated.\n  **\n  **  (2) If cells are moving right (from apNew[iPg] to apNew[iPg+1])\n  **      then it is not safe to update page apNew[iPg] until after\n  **      the right-hand sibling apNew[iPg+1] has been updated.\n  **\n  ** If neither of the above apply, the page is safe to update.\n  **\n  ** The iPg value in the following loop starts at nNew-1 goes down\n  ** to 0, then back up to nNew-1 again, thus making two passes over\n  ** the pages.  On the initial downward pass, only condition (1) above\n  ** needs to be tested because (2) will always be true from the previous\n  ** step.  On the upward pass, both conditions are always true, so the\n  ** upwards pass simply processes pages that were missed on the downward\n  ** pass.\n  */\n  for(i=1-nNew; i<nNew; i++){\n    int iPg = i<0 ? -i : i;\n    assert( iPg>=0 && iPg<nNew );\n    if( abDone[iPg] ) continue;         /* Skip pages already processed */\n    if( i>=0                            /* On the upwards pass, or... */\n     || cntOld[iPg-1]>=cntNew[iPg-1]    /* Condition (1) is true */\n    ){\n      int iNew;\n      int iOld;\n      int nNewCell;\n\n      /* Verify condition (1):  If cells are moving left, update iPg\n      ** only after iPg-1 has already been updated. */\n      assert( iPg==0 || cntOld[iPg-1]>=cntNew[iPg-1] || abDone[iPg-1] );\n\n      /* Verify condition (2):  If cells are moving right, update iPg\n      ** only after iPg+1 has already been updated. */\n      assert( cntNew[iPg]>=cntOld[iPg] || abDone[iPg+1] );\n\n      if( iPg==0 ){\n        iNew = iOld = 0;\n        nNewCell = cntNew[0];\n      }else{\n        iOld = iPg<nOld ? (cntOld[iPg-1] + !leafData) : b.nCell;\n        iNew = cntNew[iPg-1] + !leafData;\n        nNewCell = cntNew[iPg] - iNew;\n      }\n\n      rc = editPage(apNew[iPg], iOld, iNew, nNewCell, &b);\n      if( rc ) goto balance_cleanup;\n      abDone[iPg]++;\n      apNew[iPg]->nFree = usableSpace-szNew[iPg];\n      assert( apNew[iPg]->nOverflow==0 );\n      assert( apNew[iPg]->nCell==nNewCell );\n    }\n  }\n\n  /* All pages have been processed exactly once */\n  assert( memcmp(abDone, \"\\01\\01\\01\\01\\01\", nNew)==0 );\n\n  assert( nOld>0 );\n  assert( nNew>0 );\n\n  if( isRoot && pParent->nCell==0 && pParent->hdrOffset<=apNew[0]->nFree ){\n    /* The root page of the b-tree now contains no cells. The only sibling\n    ** page is the right-child of the parent. Copy the contents of the\n    ** child page into the parent, decreasing the overall height of the\n    ** b-tree structure by one. This is described as the \"balance-shallower\"\n    ** sub-algorithm in some documentation.\n    **\n    ** If this is an auto-vacuum database, the call to copyNodeContent() \n    ** sets all pointer-map entries corresponding to database image pages \n    ** for which the pointer is stored within the content being copied.\n    **\n    ** It is critical that the child page be defragmented before being\n    ** copied into the parent, because if the parent is page 1 then it will\n    ** by smaller than the child due to the database header, and so all the\n    ** free space needs to be up front.\n    */\n    assert( nNew==1 || CORRUPT_DB );\n    rc = defragmentPage(apNew[0], -1);\n    testcase( rc!=SQLITE_OK );\n    assert( apNew[0]->nFree == \n        (get2byte(&apNew[0]->aData[5])-apNew[0]->cellOffset-apNew[0]->nCell*2)\n      || rc!=SQLITE_OK\n    );\n    copyNodeContent(apNew[0], pParent, &rc);\n    freePage(apNew[0], &rc);\n  }else if( ISAUTOVACUUM && !leafCorrection ){\n    /* Fix the pointer map entries associated with the right-child of each\n    ** sibling page. All other pointer map entries have already been taken\n    ** care of.  */\n    for(i=0; i<nNew; i++){\n      u32 key = get4byte(&apNew[i]->aData[8]);\n      ptrmapPut(pBt, key, PTRMAP_BTREE, apNew[i]->pgno, &rc);\n    }\n  }\n\n  assert( pParent->isInit );\n  TRACE((\"BALANCE: finished: old=%d new=%d cells=%d\\n\",\n          nOld, nNew, b.nCell));\n\n  /* Free any old pages that were not reused as new pages.\n  */\n  for(i=nNew; i<nOld; i++){\n    freePage(apOld[i], &rc);\n  }\n\n#if 0\n  if( ISAUTOVACUUM && rc==SQLITE_OK && apNew[0]->isInit ){\n    /* The ptrmapCheckPages() contains assert() statements that verify that\n    ** all pointer map pages are set correctly. This is helpful while \n    ** debugging. This is usually disabled because a corrupt database may\n    ** cause an assert() statement to fail.  */\n    ptrmapCheckPages(apNew, nNew);\n    ptrmapCheckPages(&pParent, 1);\n  }\n#endif\n\n  /*\n  ** Cleanup before returning.\n  */\nbalance_cleanup:\n  sqlite3StackFree(0, b.apCell);\n  for(i=0; i<nOld; i++){\n    releasePage(apOld[i]);\n  }\n  for(i=0; i<nNew; i++){\n    releasePage(apNew[i]);\n  }\n\n  return rc;\n}\n\n\n/*\n** This function is called when the root page of a b-tree structure is\n** overfull (has one or more overflow pages).\n**\n** A new child page is allocated and the contents of the current root\n** page, including overflow cells, are copied into the child. The root\n** page is then overwritten to make it an empty page with the right-child \n** pointer pointing to the new page.\n**\n** Before returning, all pointer-map entries corresponding to pages \n** that the new child-page now contains pointers to are updated. The\n** entry corresponding to the new right-child pointer of the root\n** page is also updated.\n**\n** If successful, *ppChild is set to contain a reference to the child \n** page and SQLITE_OK is returned. In this case the caller is required\n** to call releasePage() on *ppChild exactly once. If an error occurs,\n** an error code is returned and *ppChild is set to 0.\n*/\nstatic int balance_deeper(MemPage *pRoot, MemPage **ppChild){\n  int rc;                        /* Return value from subprocedures */\n  MemPage *pChild = 0;           /* Pointer to a new child page */\n  Pgno pgnoChild = 0;            /* Page number of the new child page */\n  BtShared *pBt = pRoot->pBt;    /* The BTree */\n\n  assert( pRoot->nOverflow>0 );\n  assert( sqlite3_mutex_held(pBt->mutex) );\n\n  /* Make pRoot, the root page of the b-tree, writable. Allocate a new \n  ** page that will become the new right-child of pPage. Copy the contents\n  ** of the node stored on pRoot into the new child page.\n  */\n  rc = sqlite3PagerWrite(pRoot->pDbPage);\n  if( rc==SQLITE_OK ){\n    rc = allocateBtreePage(pBt,&pChild,&pgnoChild,pRoot->pgno,0);\n    copyNodeContent(pRoot, pChild, &rc);\n    if( ISAUTOVACUUM ){\n      ptrmapPut(pBt, pgnoChild, PTRMAP_BTREE, pRoot->pgno, &rc);\n    }\n  }\n  if( rc ){\n    *ppChild = 0;\n    releasePage(pChild);\n    return rc;\n  }\n  assert( sqlite3PagerIswriteable(pChild->pDbPage) );\n  assert( sqlite3PagerIswriteable(pRoot->pDbPage) );\n  assert( pChild->nCell==pRoot->nCell );\n\n  TRACE((\"BALANCE: copy root %d into %d\\n\", pRoot->pgno, pChild->pgno));\n\n  /* Copy the overflow cells from pRoot to pChild */\n  memcpy(pChild->aiOvfl, pRoot->aiOvfl,\n         pRoot->nOverflow*sizeof(pRoot->aiOvfl[0]));\n  memcpy(pChild->apOvfl, pRoot->apOvfl,\n         pRoot->nOverflow*sizeof(pRoot->apOvfl[0]));\n  pChild->nOverflow = pRoot->nOverflow;\n\n  /* Zero the contents of pRoot. Then install pChild as the right-child. */\n  zeroPage(pRoot, pChild->aData[0] & ~PTF_LEAF);\n  put4byte(&pRoot->aData[pRoot->hdrOffset+8], pgnoChild);\n\n  *ppChild = pChild;\n  return SQLITE_OK;\n}\n\n/*\n** The page that pCur currently points to has just been modified in\n** some way. This function figures out if this modification means the\n** tree needs to be balanced, and if so calls the appropriate balancing \n** routine. Balancing routines are:\n**\n**   balance_quick()\n**   balance_deeper()\n**   balance_nonroot()\n*/\nstatic int balance(BtCursor *pCur){\n  int rc = SQLITE_OK;\n  const int nMin = pCur->pBt->usableSize * 2 / 3;\n  u8 aBalanceQuickSpace[13];\n  u8 *pFree = 0;\n\n  VVA_ONLY( int balance_quick_called = 0 );\n  VVA_ONLY( int balance_deeper_called = 0 );\n\n  do {\n    int iPage = pCur->iPage;\n    MemPage *pPage = pCur->pPage;\n\n    if( iPage==0 ){\n      if( pPage->nOverflow ){\n        /* The root page of the b-tree is overfull. In this case call the\n        ** balance_deeper() function to create a new child for the root-page\n        ** and copy the current contents of the root-page to it. The\n        ** next iteration of the do-loop will balance the child page.\n        */ \n        assert( balance_deeper_called==0 );\n        VVA_ONLY( balance_deeper_called++ );\n        rc = balance_deeper(pPage, &pCur->apPage[1]);\n        if( rc==SQLITE_OK ){\n          pCur->iPage = 1;\n          pCur->ix = 0;\n          pCur->aiIdx[0] = 0;\n          pCur->apPage[0] = pPage;\n          pCur->pPage = pCur->apPage[1];\n          assert( pCur->pPage->nOverflow );\n        }\n      }else{\n        break;\n      }\n    }else if( pPage->nOverflow==0 && pPage->nFree<=nMin ){\n      break;\n    }else{\n      MemPage * const pParent = pCur->apPage[iPage-1];\n      int const iIdx = pCur->aiIdx[iPage-1];\n\n      rc = sqlite3PagerWrite(pParent->pDbPage);\n      if( rc==SQLITE_OK ){\n#ifndef SQLITE_OMIT_QUICKBALANCE\n        if( pPage->intKeyLeaf\n         && pPage->nOverflow==1\n         && pPage->aiOvfl[0]==pPage->nCell\n         && pParent->pgno!=1\n         && pParent->nCell==iIdx\n        ){\n          /* Call balance_quick() to create a new sibling of pPage on which\n          ** to store the overflow cell. balance_quick() inserts a new cell\n          ** into pParent, which may cause pParent overflow. If this\n          ** happens, the next iteration of the do-loop will balance pParent \n          ** use either balance_nonroot() or balance_deeper(). Until this\n          ** happens, the overflow cell is stored in the aBalanceQuickSpace[]\n          ** buffer. \n          **\n          ** The purpose of the following assert() is to check that only a\n          ** single call to balance_quick() is made for each call to this\n          ** function. If this were not verified, a subtle bug involving reuse\n          ** of the aBalanceQuickSpace[] might sneak in.\n          */\n          assert( balance_quick_called==0 ); \n          VVA_ONLY( balance_quick_called++ );\n          rc = balance_quick(pParent, pPage, aBalanceQuickSpace);\n        }else\n#endif\n        {\n          /* In this case, call balance_nonroot() to redistribute cells\n          ** between pPage and up to 2 of its sibling pages. This involves\n          ** modifying the contents of pParent, which may cause pParent to\n          ** become overfull or underfull. The next iteration of the do-loop\n          ** will balance the parent page to correct this.\n          ** \n          ** If the parent page becomes overfull, the overflow cell or cells\n          ** are stored in the pSpace buffer allocated immediately below. \n          ** A subsequent iteration of the do-loop will deal with this by\n          ** calling balance_nonroot() (balance_deeper() may be called first,\n          ** but it doesn't deal with overflow cells - just moves them to a\n          ** different page). Once this subsequent call to balance_nonroot() \n          ** has completed, it is safe to release the pSpace buffer used by\n          ** the previous call, as the overflow cell data will have been \n          ** copied either into the body of a database page or into the new\n          ** pSpace buffer passed to the latter call to balance_nonroot().\n          */\n          u8 *pSpace = sqlite3PageMalloc(pCur->pBt->pageSize);\n          rc = balance_nonroot(pParent, iIdx, pSpace, iPage==1,\n                               pCur->hints&BTREE_BULKLOAD);\n          if( pFree ){\n            /* If pFree is not NULL, it points to the pSpace buffer used \n            ** by a previous call to balance_nonroot(). Its contents are\n            ** now stored either on real database pages or within the \n            ** new pSpace buffer, so it may be safely freed here. */\n            sqlite3PageFree(pFree);\n          }\n\n          /* The pSpace buffer will be freed after the next call to\n          ** balance_nonroot(), or just before this function returns, whichever\n          ** comes first. */\n          pFree = pSpace;\n        }\n      }\n\n      pPage->nOverflow = 0;\n\n      /* The next iteration of the do-loop balances the parent page. */\n      releasePage(pPage);\n      pCur->iPage--;\n      assert( pCur->iPage>=0 );\n      pCur->pPage = pCur->apPage[pCur->iPage];\n    }\n  }while( rc==SQLITE_OK );\n\n  if( pFree ){\n    sqlite3PageFree(pFree);\n  }\n  return rc;\n}\n\n/* Overwrite content from pX into pDest.  Only do the write if the\n** content is different from what is already there.\n*/\nstatic int btreeOverwriteContent(\n  MemPage *pPage,           /* MemPage on which writing will occur */\n  u8 *pDest,                /* Pointer to the place to start writing */\n  const BtreePayload *pX,   /* Source of data to write */\n  int iOffset,              /* Offset of first byte to write */\n  int iAmt                  /* Number of bytes to be written */\n){\n  int nData = pX->nData - iOffset;\n  if( nData<=0 ){\n    /* Overwritting with zeros */\n    int i;\n    for(i=0; i<iAmt && pDest[i]==0; i++){}\n    if( i<iAmt ){\n      int rc = sqlite3PagerWrite(pPage->pDbPage);\n      if( rc ) return rc;\n      memset(pDest + i, 0, iAmt - i);\n    }\n  }else{\n    if( nData<iAmt ){\n      /* Mixed read data and zeros at the end.  Make a recursive call\n      ** to write the zeros then fall through to write the real data */\n      int rc = btreeOverwriteContent(pPage, pDest+nData, pX, iOffset+nData,\n                                 iAmt-nData);\n      if( rc ) return rc;\n      iAmt = nData;\n    }\n    if( memcmp(pDest, ((u8*)pX->pData) + iOffset, iAmt)!=0 ){\n      int rc = sqlite3PagerWrite(pPage->pDbPage);\n      if( rc ) return rc;\n      /* In a corrupt database, it is possible for the source and destination\n      ** buffers to overlap.  This is harmless since the database is already\n      ** corrupt but it does cause valgrind and ASAN warnings.  So use\n      ** memmove(). */\n      memmove(pDest, ((u8*)pX->pData) + iOffset, iAmt);\n    }\n  }\n  return SQLITE_OK;\n}\n\n/*\n** Overwrite the cell that cursor pCur is pointing to with fresh content\n** contained in pX.\n*/\nstatic int btreeOverwriteCell(BtCursor *pCur, const BtreePayload *pX){\n  int iOffset;                        /* Next byte of pX->pData to write */\n  int nTotal = pX->nData + pX->nZero; /* Total bytes of to write */\n  int rc;                             /* Return code */\n  MemPage *pPage = pCur->pPage;       /* Page being written */\n  BtShared *pBt;                      /* Btree */\n  Pgno ovflPgno;                      /* Next overflow page to write */\n  u32 ovflPageSize;                   /* Size to write on overflow page */\n\n  if( pCur->info.pPayload + pCur->info.nLocal > pPage->aDataEnd ){\n    return SQLITE_CORRUPT_BKPT;\n  }\n  /* Overwrite the local portion first */\n  rc = btreeOverwriteContent(pPage, pCur->info.pPayload, pX,\n                             0, pCur->info.nLocal);\n  if( rc ) return rc;\n  if( pCur->info.nLocal==nTotal ) return SQLITE_OK;\n\n  /* Now overwrite the overflow pages */\n  iOffset = pCur->info.nLocal;\n  assert( nTotal>=0 );\n  assert( iOffset>=0 );\n  ovflPgno = get4byte(pCur->info.pPayload + iOffset);\n  pBt = pPage->pBt;\n  ovflPageSize = pBt->usableSize - 4;\n  do{\n    rc = btreeGetPage(pBt, ovflPgno, &pPage, 0);\n    if( rc ) return rc;\n    if( sqlite3PagerPageRefcount(pPage->pDbPage)!=1 ){\n      rc = SQLITE_CORRUPT_BKPT;\n    }else{\n      if( iOffset+ovflPageSize<(u32)nTotal ){\n        ovflPgno = get4byte(pPage->aData);\n      }else{\n        ovflPageSize = nTotal - iOffset;\n      }\n      rc = btreeOverwriteContent(pPage, pPage->aData+4, pX,\n                                 iOffset, ovflPageSize);\n    }\n    sqlite3PagerUnref(pPage->pDbPage);\n    if( rc ) return rc;\n    iOffset += ovflPageSize;\n  }while( iOffset<nTotal );\n  return SQLITE_OK;    \n}\n\n\n/*\n** Insert a new record into the BTree.  The content of the new record\n** is described by the pX object.  The pCur cursor is used only to\n** define what table the record should be inserted into, and is left\n** pointing at a random location.\n**\n** For a table btree (used for rowid tables), only the pX.nKey value of\n** the key is used. The pX.pKey value must be NULL.  The pX.nKey is the\n** rowid or INTEGER PRIMARY KEY of the row.  The pX.nData,pData,nZero fields\n** hold the content of the row.\n**\n** For an index btree (used for indexes and WITHOUT ROWID tables), the\n** key is an arbitrary byte sequence stored in pX.pKey,nKey.  The \n** pX.pData,nData,nZero fields must be zero.\n**\n** If the seekResult parameter is non-zero, then a successful call to\n** MovetoUnpacked() to seek cursor pCur to (pKey,nKey) has already\n** been performed.  In other words, if seekResult!=0 then the cursor\n** is currently pointing to a cell that will be adjacent to the cell\n** to be inserted.  If seekResult<0 then pCur points to a cell that is\n** smaller then (pKey,nKey).  If seekResult>0 then pCur points to a cell\n** that is larger than (pKey,nKey).\n**\n** If seekResult==0, that means pCur is pointing at some unknown location.\n** In that case, this routine must seek the cursor to the correct insertion\n** point for (pKey,nKey) before doing the insertion.  For index btrees,\n** if pX->nMem is non-zero, then pX->aMem contains pointers to the unpacked\n** key values and pX->aMem can be used instead of pX->pKey to avoid having\n** to decode the key.\n*/\nSQLITE_PRIVATE int sqlite3BtreeInsert(\n  BtCursor *pCur,                /* Insert data into the table of this cursor */\n  const BtreePayload *pX,        /* Content of the row to be inserted */\n  int flags,                     /* True if this is likely an append */\n  int seekResult                 /* Result of prior MovetoUnpacked() call */\n){\n  int rc;\n  int loc = seekResult;          /* -1: before desired location  +1: after */\n  int szNew = 0;\n  int idx;\n  MemPage *pPage;\n  Btree *p = pCur->pBtree;\n  BtShared *pBt = p->pBt;\n  unsigned char *oldCell;\n  unsigned char *newCell = 0;\n\n  assert( (flags & (BTREE_SAVEPOSITION|BTREE_APPEND))==flags );\n\n  if( pCur->eState==CURSOR_FAULT ){\n    assert( pCur->skipNext!=SQLITE_OK );\n    return pCur->skipNext;\n  }\n\n  assert( cursorOwnsBtShared(pCur) );\n  assert( (pCur->curFlags & BTCF_WriteFlag)!=0\n              && pBt->inTransaction==TRANS_WRITE\n              && (pBt->btsFlags & BTS_READ_ONLY)==0 );\n  assert( hasSharedCacheTableLock(p, pCur->pgnoRoot, pCur->pKeyInfo!=0, 2) );\n\n  /* Assert that the caller has been consistent. If this cursor was opened\n  ** expecting an index b-tree, then the caller should be inserting blob\n  ** keys with no associated data. If the cursor was opened expecting an\n  ** intkey table, the caller should be inserting integer keys with a\n  ** blob of associated data.  */\n  assert( (pX->pKey==0)==(pCur->pKeyInfo==0) );\n\n  /* Save the positions of any other cursors open on this table.\n  **\n  ** In some cases, the call to btreeMoveto() below is a no-op. For\n  ** example, when inserting data into a table with auto-generated integer\n  ** keys, the VDBE layer invokes sqlite3BtreeLast() to figure out the \n  ** integer key to use. It then calls this function to actually insert the \n  ** data into the intkey B-Tree. In this case btreeMoveto() recognizes\n  ** that the cursor is already where it needs to be and returns without\n  ** doing any work. To avoid thwarting these optimizations, it is important\n  ** not to clear the cursor here.\n  */\n  if( pCur->curFlags & BTCF_Multiple ){\n    rc = saveAllCursors(pBt, pCur->pgnoRoot, pCur);\n    if( rc ) return rc;\n  }\n\n  if( pCur->pKeyInfo==0 ){\n    assert( pX->pKey==0 );\n    /* If this is an insert into a table b-tree, invalidate any incrblob \n    ** cursors open on the row being replaced */\n    invalidateIncrblobCursors(p, pCur->pgnoRoot, pX->nKey, 0);\n\n    /* If BTREE_SAVEPOSITION is set, the cursor must already be pointing \n    ** to a row with the same key as the new entry being inserted.\n    */\n#ifdef SQLITE_DEBUG\n    if( flags & BTREE_SAVEPOSITION ){\n      assert( pCur->curFlags & BTCF_ValidNKey );\n      assert( pX->nKey==pCur->info.nKey );\n      assert( pCur->info.nSize!=0 );\n      assert( loc==0 );\n    }\n#endif\n\n    /* On the other hand, BTREE_SAVEPOSITION==0 does not imply\n    ** that the cursor is not pointing to a row to be overwritten.\n    ** So do a complete check.\n    */\n    if( (pCur->curFlags&BTCF_ValidNKey)!=0 && pX->nKey==pCur->info.nKey ){\n      /* The cursor is pointing to the entry that is to be\n      ** overwritten */\n      assert( pX->nData>=0 && pX->nZero>=0 );\n      if( pCur->info.nSize!=0\n       && pCur->info.nPayload==(u32)pX->nData+pX->nZero\n      ){\n        /* New entry is the same size as the old.  Do an overwrite */\n        return btreeOverwriteCell(pCur, pX);\n      }\n      assert( loc==0 );\n    }else if( loc==0 ){\n      /* The cursor is *not* pointing to the cell to be overwritten, nor\n      ** to an adjacent cell.  Move the cursor so that it is pointing either\n      ** to the cell to be overwritten or an adjacent cell.\n      */\n      rc = sqlite3BtreeMovetoUnpacked(pCur, 0, pX->nKey, flags!=0, &loc);\n      if( rc ) return rc;\n    }\n  }else{\n    /* This is an index or a WITHOUT ROWID table */\n\n    /* If BTREE_SAVEPOSITION is set, the cursor must already be pointing \n    ** to a row with the same key as the new entry being inserted.\n    */\n    assert( (flags & BTREE_SAVEPOSITION)==0 || loc==0 );\n\n    /* If the cursor is not already pointing either to the cell to be\n    ** overwritten, or if a new cell is being inserted, if the cursor is\n    ** not pointing to an immediately adjacent cell, then move the cursor\n    ** so that it does.\n    */\n    if( loc==0 && (flags & BTREE_SAVEPOSITION)==0 ){\n      if( pX->nMem ){\n        UnpackedRecord r;\n        r.pKeyInfo = pCur->pKeyInfo;\n        r.aMem = pX->aMem;\n        r.nField = pX->nMem;\n        r.default_rc = 0;\n        r.errCode = 0;\n        r.r1 = 0;\n        r.r2 = 0;\n        r.eqSeen = 0;\n        rc = sqlite3BtreeMovetoUnpacked(pCur, &r, 0, flags!=0, &loc);\n      }else{\n        rc = btreeMoveto(pCur, pX->pKey, pX->nKey, flags!=0, &loc);\n      }\n      if( rc ) return rc;\n    }\n\n    /* If the cursor is currently pointing to an entry to be overwritten\n    ** and the new content is the same as as the old, then use the\n    ** overwrite optimization.\n    */\n    if( loc==0 ){\n      getCellInfo(pCur);\n      if( pCur->info.nKey==pX->nKey ){\n        BtreePayload x2;\n        x2.pData = pX->pKey;\n        x2.nData = pX->nKey;\n        x2.nZero = 0;\n        return btreeOverwriteCell(pCur, &x2);\n      }\n    }\n\n  }\n  assert( pCur->eState==CURSOR_VALID || (pCur->eState==CURSOR_INVALID && loc) );\n\n  pPage = pCur->pPage;\n  assert( pPage->intKey || pX->nKey>=0 );\n  assert( pPage->leaf || !pPage->intKey );\n\n  TRACE((\"INSERT: table=%d nkey=%lld ndata=%d page=%d %s\\n\",\n          pCur->pgnoRoot, pX->nKey, pX->nData, pPage->pgno,\n          loc==0 ? \"overwrite\" : \"new entry\"));\n  assert( pPage->isInit );\n  newCell = pBt->pTmpSpace;\n  assert( newCell!=0 );\n  rc = fillInCell(pPage, newCell, pX, &szNew);\n  if( rc ) goto end_insert;\n  assert( szNew==pPage->xCellSize(pPage, newCell) );\n  assert( szNew <= MX_CELL_SIZE(pBt) );\n  idx = pCur->ix;\n  if( loc==0 ){\n    CellInfo info;\n    assert( idx<pPage->nCell );\n    rc = sqlite3PagerWrite(pPage->pDbPage);\n    if( rc ){\n      goto end_insert;\n    }\n    oldCell = findCell(pPage, idx);\n    if( !pPage->leaf ){\n      memcpy(newCell, oldCell, 4);\n    }\n    rc = clearCell(pPage, oldCell, &info);\n    if( info.nSize==szNew && info.nLocal==info.nPayload \n     && (!ISAUTOVACUUM || szNew<pPage->minLocal)\n    ){\n      /* Overwrite the old cell with the new if they are the same size.\n      ** We could also try to do this if the old cell is smaller, then add\n      ** the leftover space to the free list.  But experiments show that\n      ** doing that is no faster then skipping this optimization and just\n      ** calling dropCell() and insertCell(). \n      **\n      ** This optimization cannot be used on an autovacuum database if the\n      ** new entry uses overflow pages, as the insertCell() call below is\n      ** necessary to add the PTRMAP_OVERFLOW1 pointer-map entry.  */\n      assert( rc==SQLITE_OK ); /* clearCell never fails when nLocal==nPayload */\n      if( oldCell+szNew > pPage->aDataEnd ) return SQLITE_CORRUPT_BKPT;\n      memcpy(oldCell, newCell, szNew);\n      return SQLITE_OK;\n    }\n    dropCell(pPage, idx, info.nSize, &rc);\n    if( rc ) goto end_insert;\n  }else if( loc<0 && pPage->nCell>0 ){\n    assert( pPage->leaf );\n    idx = ++pCur->ix;\n    pCur->curFlags &= ~BTCF_ValidNKey;\n  }else{\n    assert( pPage->leaf );\n  }\n  insertCell(pPage, idx, newCell, szNew, 0, 0, &rc);\n  assert( pPage->nOverflow==0 || rc==SQLITE_OK );\n  assert( rc!=SQLITE_OK || pPage->nCell>0 || pPage->nOverflow>0 );\n\n  /* If no error has occurred and pPage has an overflow cell, call balance() \n  ** to redistribute the cells within the tree. Since balance() may move\n  ** the cursor, zero the BtCursor.info.nSize and BTCF_ValidNKey\n  ** variables.\n  **\n  ** Previous versions of SQLite called moveToRoot() to move the cursor\n  ** back to the root page as balance() used to invalidate the contents\n  ** of BtCursor.apPage[] and BtCursor.aiIdx[]. Instead of doing that,\n  ** set the cursor state to \"invalid\". This makes common insert operations\n  ** slightly faster.\n  **\n  ** There is a subtle but important optimization here too. When inserting\n  ** multiple records into an intkey b-tree using a single cursor (as can\n  ** happen while processing an \"INSERT INTO ... SELECT\" statement), it\n  ** is advantageous to leave the cursor pointing to the last entry in\n  ** the b-tree if possible. If the cursor is left pointing to the last\n  ** entry in the table, and the next row inserted has an integer key\n  ** larger than the largest existing key, it is possible to insert the\n  ** row without seeking the cursor. This can be a big performance boost.\n  */\n  pCur->info.nSize = 0;\n  if( pPage->nOverflow ){\n    assert( rc==SQLITE_OK );\n    pCur->curFlags &= ~(BTCF_ValidNKey);\n    rc = balance(pCur);\n\n    /* Must make sure nOverflow is reset to zero even if the balance()\n    ** fails. Internal data structure corruption will result otherwise. \n    ** Also, set the cursor state to invalid. This stops saveCursorPosition()\n    ** from trying to save the current position of the cursor.  */\n    pCur->pPage->nOverflow = 0;\n    pCur->eState = CURSOR_INVALID;\n    if( (flags & BTREE_SAVEPOSITION) && rc==SQLITE_OK ){\n      btreeReleaseAllCursorPages(pCur);\n      if( pCur->pKeyInfo ){\n        assert( pCur->pKey==0 );\n        pCur->pKey = sqlite3Malloc( pX->nKey );\n        if( pCur->pKey==0 ){\n          rc = SQLITE_NOMEM;\n        }else{\n          memcpy(pCur->pKey, pX->pKey, pX->nKey);\n        }\n      }\n      pCur->eState = CURSOR_REQUIRESEEK;\n      pCur->nKey = pX->nKey;\n    }\n  }\n  assert( pCur->iPage<0 || pCur->pPage->nOverflow==0 );\n\nend_insert:\n  return rc;\n}\n\n/*\n** Delete the entry that the cursor is pointing to. \n**\n** If the BTREE_SAVEPOSITION bit of the flags parameter is zero, then\n** the cursor is left pointing at an arbitrary location after the delete.\n** But if that bit is set, then the cursor is left in a state such that\n** the next call to BtreeNext() or BtreePrev() moves it to the same row\n** as it would have been on if the call to BtreeDelete() had been omitted.\n**\n** The BTREE_AUXDELETE bit of flags indicates that is one of several deletes\n** associated with a single table entry and its indexes.  Only one of those\n** deletes is considered the \"primary\" delete.  The primary delete occurs\n** on a cursor that is not a BTREE_FORDELETE cursor.  All but one delete\n** operation on non-FORDELETE cursors is tagged with the AUXDELETE flag.\n** The BTREE_AUXDELETE bit is a hint that is not used by this implementation,\n** but which might be used by alternative storage engines.\n*/\nSQLITE_PRIVATE int sqlite3BtreeDelete(BtCursor *pCur, u8 flags){\n  Btree *p = pCur->pBtree;\n  BtShared *pBt = p->pBt;              \n  int rc;                              /* Return code */\n  MemPage *pPage;                      /* Page to delete cell from */\n  unsigned char *pCell;                /* Pointer to cell to delete */\n  int iCellIdx;                        /* Index of cell to delete */\n  int iCellDepth;                      /* Depth of node containing pCell */ \n  CellInfo info;                       /* Size of the cell being deleted */\n  int bSkipnext = 0;                   /* Leaf cursor in SKIPNEXT state */\n  u8 bPreserve = flags & BTREE_SAVEPOSITION;  /* Keep cursor valid */\n\n  assert( cursorOwnsBtShared(pCur) );\n  assert( pBt->inTransaction==TRANS_WRITE );\n  assert( (pBt->btsFlags & BTS_READ_ONLY)==0 );\n  assert( pCur->curFlags & BTCF_WriteFlag );\n  assert( hasSharedCacheTableLock(p, pCur->pgnoRoot, pCur->pKeyInfo!=0, 2) );\n  assert( !hasReadConflicts(p, pCur->pgnoRoot) );\n  assert( pCur->ix<pCur->pPage->nCell );\n  assert( pCur->eState==CURSOR_VALID );\n  assert( (flags & ~(BTREE_SAVEPOSITION | BTREE_AUXDELETE))==0 );\n\n  iCellDepth = pCur->iPage;\n  iCellIdx = pCur->ix;\n  pPage = pCur->pPage;\n  pCell = findCell(pPage, iCellIdx);\n\n  /* If the bPreserve flag is set to true, then the cursor position must\n  ** be preserved following this delete operation. If the current delete\n  ** will cause a b-tree rebalance, then this is done by saving the cursor\n  ** key and leaving the cursor in CURSOR_REQUIRESEEK state before \n  ** returning. \n  **\n  ** Or, if the current delete will not cause a rebalance, then the cursor\n  ** will be left in CURSOR_SKIPNEXT state pointing to the entry immediately\n  ** before or after the deleted entry. In this case set bSkipnext to true.  */\n  if( bPreserve ){\n    if( !pPage->leaf \n     || (pPage->nFree+cellSizePtr(pPage,pCell)+2)>(int)(pBt->usableSize*2/3)\n     || pPage->nCell==1  /* See dbfuzz001.test for a test case */\n    ){\n      /* A b-tree rebalance will be required after deleting this entry.\n      ** Save the cursor key.  */\n      rc = saveCursorKey(pCur);\n      if( rc ) return rc;\n    }else{\n      bSkipnext = 1;\n    }\n  }\n\n  /* If the page containing the entry to delete is not a leaf page, move\n  ** the cursor to the largest entry in the tree that is smaller than\n  ** the entry being deleted. This cell will replace the cell being deleted\n  ** from the internal node. The 'previous' entry is used for this instead\n  ** of the 'next' entry, as the previous entry is always a part of the\n  ** sub-tree headed by the child page of the cell being deleted. This makes\n  ** balancing the tree following the delete operation easier.  */\n  if( !pPage->leaf ){\n    rc = sqlite3BtreePrevious(pCur, 0);\n    assert( rc!=SQLITE_DONE );\n    if( rc ) return rc;\n  }\n\n  /* Save the positions of any other cursors open on this table before\n  ** making any modifications.  */\n  if( pCur->curFlags & BTCF_Multiple ){\n    rc = saveAllCursors(pBt, pCur->pgnoRoot, pCur);\n    if( rc ) return rc;\n  }\n\n  /* If this is a delete operation to remove a row from a table b-tree,\n  ** invalidate any incrblob cursors open on the row being deleted.  */\n  if( pCur->pKeyInfo==0 ){\n    invalidateIncrblobCursors(p, pCur->pgnoRoot, pCur->info.nKey, 0);\n  }\n\n  /* Make the page containing the entry to be deleted writable. Then free any\n  ** overflow pages associated with the entry and finally remove the cell\n  ** itself from within the page.  */\n  rc = sqlite3PagerWrite(pPage->pDbPage);\n  if( rc ) return rc;\n  rc = clearCell(pPage, pCell, &info);\n  dropCell(pPage, iCellIdx, info.nSize, &rc);\n  if( rc ) return rc;\n\n  /* If the cell deleted was not located on a leaf page, then the cursor\n  ** is currently pointing to the largest entry in the sub-tree headed\n  ** by the child-page of the cell that was just deleted from an internal\n  ** node. The cell from the leaf node needs to be moved to the internal\n  ** node to replace the deleted cell.  */\n  if( !pPage->leaf ){\n    MemPage *pLeaf = pCur->pPage;\n    int nCell;\n    Pgno n;\n    unsigned char *pTmp;\n\n    if( iCellDepth<pCur->iPage-1 ){\n      n = pCur->apPage[iCellDepth+1]->pgno;\n    }else{\n      n = pCur->pPage->pgno;\n    }\n    pCell = findCell(pLeaf, pLeaf->nCell-1);\n    if( pCell<&pLeaf->aData[4] ) return SQLITE_CORRUPT_BKPT;\n    nCell = pLeaf->xCellSize(pLeaf, pCell);\n    assert( MX_CELL_SIZE(pBt) >= nCell );\n    pTmp = pBt->pTmpSpace;\n    assert( pTmp!=0 );\n    rc = sqlite3PagerWrite(pLeaf->pDbPage);\n    if( rc==SQLITE_OK ){\n      insertCell(pPage, iCellIdx, pCell-4, nCell+4, pTmp, n, &rc);\n    }\n    dropCell(pLeaf, pLeaf->nCell-1, nCell, &rc);\n    if( rc ) return rc;\n  }\n\n  /* Balance the tree. If the entry deleted was located on a leaf page,\n  ** then the cursor still points to that page. In this case the first\n  ** call to balance() repairs the tree, and the if(...) condition is\n  ** never true.\n  **\n  ** Otherwise, if the entry deleted was on an internal node page, then\n  ** pCur is pointing to the leaf page from which a cell was removed to\n  ** replace the cell deleted from the internal node. This is slightly\n  ** tricky as the leaf node may be underfull, and the internal node may\n  ** be either under or overfull. In this case run the balancing algorithm\n  ** on the leaf node first. If the balance proceeds far enough up the\n  ** tree that we can be sure that any problem in the internal node has\n  ** been corrected, so be it. Otherwise, after balancing the leaf node,\n  ** walk the cursor up the tree to the internal node and balance it as \n  ** well.  */\n  rc = balance(pCur);\n  if( rc==SQLITE_OK && pCur->iPage>iCellDepth ){\n    releasePageNotNull(pCur->pPage);\n    pCur->iPage--;\n    while( pCur->iPage>iCellDepth ){\n      releasePage(pCur->apPage[pCur->iPage--]);\n    }\n    pCur->pPage = pCur->apPage[pCur->iPage];\n    rc = balance(pCur);\n  }\n\n  if( rc==SQLITE_OK ){\n    if( bSkipnext ){\n      assert( bPreserve && (pCur->iPage==iCellDepth || CORRUPT_DB) );\n      assert( pPage==pCur->pPage || CORRUPT_DB );\n      assert( (pPage->nCell>0 || CORRUPT_DB) && iCellIdx<=pPage->nCell );\n      pCur->eState = CURSOR_SKIPNEXT;\n      if( iCellIdx>=pPage->nCell ){\n        pCur->skipNext = -1;\n        pCur->ix = pPage->nCell-1;\n      }else{\n        pCur->skipNext = 1;\n      }\n    }else{\n      rc = moveToRoot(pCur);\n      if( bPreserve ){\n        btreeReleaseAllCursorPages(pCur);\n        pCur->eState = CURSOR_REQUIRESEEK;\n      }\n      if( rc==SQLITE_EMPTY ) rc = SQLITE_OK;\n    }\n  }\n  return rc;\n}\n\n/*\n** Create a new BTree table.  Write into *piTable the page\n** number for the root page of the new table.\n**\n** The type of type is determined by the flags parameter.  Only the\n** following values of flags are currently in use.  Other values for\n** flags might not work:\n**\n**     BTREE_INTKEY|BTREE_LEAFDATA     Used for SQL tables with rowid keys\n**     BTREE_ZERODATA                  Used for SQL indices\n*/\nstatic int btreeCreateTable(Btree *p, int *piTable, int createTabFlags){\n  BtShared *pBt = p->pBt;\n  MemPage *pRoot;\n  Pgno pgnoRoot;\n  int rc;\n  int ptfFlags;          /* Page-type flage for the root page of new table */\n\n  assert( sqlite3BtreeHoldsMutex(p) );\n  assert( pBt->inTransaction==TRANS_WRITE );\n  assert( (pBt->btsFlags & BTS_READ_ONLY)==0 );\n\n#ifdef SQLITE_OMIT_AUTOVACUUM\n  rc = allocateBtreePage(pBt, &pRoot, &pgnoRoot, 1, 0);\n  if( rc ){\n    return rc;\n  }\n#else\n  if( pBt->autoVacuum ){\n    Pgno pgnoMove;      /* Move a page here to make room for the root-page */\n    MemPage *pPageMove; /* The page to move to. */\n\n    /* Creating a new table may probably require moving an existing database\n    ** to make room for the new tables root page. In case this page turns\n    ** out to be an overflow page, delete all overflow page-map caches\n    ** held by open cursors.\n    */\n    invalidateAllOverflowCache(pBt);\n\n    /* Read the value of meta[3] from the database to determine where the\n    ** root page of the new table should go. meta[3] is the largest root-page\n    ** created so far, so the new root-page is (meta[3]+1).\n    */\n    sqlite3BtreeGetMeta(p, BTREE_LARGEST_ROOT_PAGE, &pgnoRoot);\n    pgnoRoot++;\n\n    /* The new root-page may not be allocated on a pointer-map page, or the\n    ** PENDING_BYTE page.\n    */\n    while( pgnoRoot==PTRMAP_PAGENO(pBt, pgnoRoot) ||\n        pgnoRoot==PENDING_BYTE_PAGE(pBt) ){\n      pgnoRoot++;\n    }\n    assert( pgnoRoot>=3 || CORRUPT_DB );\n    testcase( pgnoRoot<3 );\n\n    /* Allocate a page. The page that currently resides at pgnoRoot will\n    ** be moved to the allocated page (unless the allocated page happens\n    ** to reside at pgnoRoot).\n    */\n    rc = allocateBtreePage(pBt, &pPageMove, &pgnoMove, pgnoRoot, BTALLOC_EXACT);\n    if( rc!=SQLITE_OK ){\n      return rc;\n    }\n\n    if( pgnoMove!=pgnoRoot ){\n      /* pgnoRoot is the page that will be used for the root-page of\n      ** the new table (assuming an error did not occur). But we were\n      ** allocated pgnoMove. If required (i.e. if it was not allocated\n      ** by extending the file), the current page at position pgnoMove\n      ** is already journaled.\n      */\n      u8 eType = 0;\n      Pgno iPtrPage = 0;\n\n      /* Save the positions of any open cursors. This is required in\n      ** case they are holding a reference to an xFetch reference\n      ** corresponding to page pgnoRoot.  */\n      rc = saveAllCursors(pBt, 0, 0);\n      releasePage(pPageMove);\n      if( rc!=SQLITE_OK ){\n        return rc;\n      }\n\n      /* Move the page currently at pgnoRoot to pgnoMove. */\n      rc = btreeGetPage(pBt, pgnoRoot, &pRoot, 0);\n      if( rc!=SQLITE_OK ){\n        return rc;\n      }\n      rc = ptrmapGet(pBt, pgnoRoot, &eType, &iPtrPage);\n      if( eType==PTRMAP_ROOTPAGE || eType==PTRMAP_FREEPAGE ){\n        rc = SQLITE_CORRUPT_BKPT;\n      }\n      if( rc!=SQLITE_OK ){\n        releasePage(pRoot);\n        return rc;\n      }\n      assert( eType!=PTRMAP_ROOTPAGE );\n      assert( eType!=PTRMAP_FREEPAGE );\n      rc = relocatePage(pBt, pRoot, eType, iPtrPage, pgnoMove, 0);\n      releasePage(pRoot);\n\n      /* Obtain the page at pgnoRoot */\n      if( rc!=SQLITE_OK ){\n        return rc;\n      }\n      rc = btreeGetPage(pBt, pgnoRoot, &pRoot, 0);\n      if( rc!=SQLITE_OK ){\n        return rc;\n      }\n      rc = sqlite3PagerWrite(pRoot->pDbPage);\n      if( rc!=SQLITE_OK ){\n        releasePage(pRoot);\n        return rc;\n      }\n    }else{\n      pRoot = pPageMove;\n    } \n\n    /* Update the pointer-map and meta-data with the new root-page number. */\n    ptrmapPut(pBt, pgnoRoot, PTRMAP_ROOTPAGE, 0, &rc);\n    if( rc ){\n      releasePage(pRoot);\n      return rc;\n    }\n\n    /* When the new root page was allocated, page 1 was made writable in\n    ** order either to increase the database filesize, or to decrement the\n    ** freelist count.  Hence, the sqlite3BtreeUpdateMeta() call cannot fail.\n    */\n    assert( sqlite3PagerIswriteable(pBt->pPage1->pDbPage) );\n    rc = sqlite3BtreeUpdateMeta(p, 4, pgnoRoot);\n    if( NEVER(rc) ){\n      releasePage(pRoot);\n      return rc;\n    }\n\n  }else{\n    rc = allocateBtreePage(pBt, &pRoot, &pgnoRoot, 1, 0);\n    if( rc ) return rc;\n  }\n#endif\n  assert( sqlite3PagerIswriteable(pRoot->pDbPage) );\n  if( createTabFlags & BTREE_INTKEY ){\n    ptfFlags = PTF_INTKEY | PTF_LEAFDATA | PTF_LEAF;\n  }else{\n    ptfFlags = PTF_ZERODATA | PTF_LEAF;\n  }\n  zeroPage(pRoot, ptfFlags);\n  sqlite3PagerUnref(pRoot->pDbPage);\n  assert( (pBt->openFlags & BTREE_SINGLE)==0 || pgnoRoot==2 );\n  *piTable = (int)pgnoRoot;\n  return SQLITE_OK;\n}\nSQLITE_PRIVATE int sqlite3BtreeCreateTable(Btree *p, int *piTable, int flags){\n  int rc;\n  sqlite3BtreeEnter(p);\n  rc = btreeCreateTable(p, piTable, flags);\n  sqlite3BtreeLeave(p);\n  return rc;\n}\n\n/*\n** Erase the given database page and all its children.  Return\n** the page to the freelist.\n*/\nstatic int clearDatabasePage(\n  BtShared *pBt,           /* The BTree that contains the table */\n  Pgno pgno,               /* Page number to clear */\n  int freePageFlag,        /* Deallocate page if true */\n  int *pnChange            /* Add number of Cells freed to this counter */\n){\n  MemPage *pPage;\n  int rc;\n  unsigned char *pCell;\n  int i;\n  int hdr;\n  CellInfo info;\n\n  assert( sqlite3_mutex_held(pBt->mutex) );\n  if( pgno>btreePagecount(pBt) ){\n    return SQLITE_CORRUPT_BKPT;\n  }\n  rc = getAndInitPage(pBt, pgno, &pPage, 0, 0);\n  if( rc ) return rc;\n  if( pPage->bBusy ){\n    rc = SQLITE_CORRUPT_BKPT;\n    goto cleardatabasepage_out;\n  }\n  pPage->bBusy = 1;\n  hdr = pPage->hdrOffset;\n  for(i=0; i<pPage->nCell; i++){\n    pCell = findCell(pPage, i);\n    if( !pPage->leaf ){\n      rc = clearDatabasePage(pBt, get4byte(pCell), 1, pnChange);\n      if( rc ) goto cleardatabasepage_out;\n    }\n    rc = clearCell(pPage, pCell, &info);\n    if( rc ) goto cleardatabasepage_out;\n  }\n  if( !pPage->leaf ){\n    rc = clearDatabasePage(pBt, get4byte(&pPage->aData[hdr+8]), 1, pnChange);\n    if( rc ) goto cleardatabasepage_out;\n  }else if( pnChange ){\n    assert( pPage->intKey || CORRUPT_DB );\n    testcase( !pPage->intKey );\n    *pnChange += pPage->nCell;\n  }\n  if( freePageFlag ){\n    freePage(pPage, &rc);\n  }else if( (rc = sqlite3PagerWrite(pPage->pDbPage))==0 ){\n    zeroPage(pPage, pPage->aData[hdr] | PTF_LEAF);\n  }\n\ncleardatabasepage_out:\n  pPage->bBusy = 0;\n  releasePage(pPage);\n  return rc;\n}\n\n/*\n** Delete all information from a single table in the database.  iTable is\n** the page number of the root of the table.  After this routine returns,\n** the root page is empty, but still exists.\n**\n** This routine will fail with SQLITE_LOCKED if there are any open\n** read cursors on the table.  Open write cursors are moved to the\n** root of the table.\n**\n** If pnChange is not NULL, then table iTable must be an intkey table. The\n** integer value pointed to by pnChange is incremented by the number of\n** entries in the table.\n*/\nSQLITE_PRIVATE int sqlite3BtreeClearTable(Btree *p, int iTable, int *pnChange){\n  int rc;\n  BtShared *pBt = p->pBt;\n  sqlite3BtreeEnter(p);\n  assert( p->inTrans==TRANS_WRITE );\n\n  rc = saveAllCursors(pBt, (Pgno)iTable, 0);\n\n  if( SQLITE_OK==rc ){\n    /* Invalidate all incrblob cursors open on table iTable (assuming iTable\n    ** is the root of a table b-tree - if it is not, the following call is\n    ** a no-op).  */\n    invalidateIncrblobCursors(p, (Pgno)iTable, 0, 1);\n    rc = clearDatabasePage(pBt, (Pgno)iTable, 0, pnChange);\n  }\n  sqlite3BtreeLeave(p);\n  return rc;\n}\n\n/*\n** Delete all information from the single table that pCur is open on.\n**\n** This routine only work for pCur on an ephemeral table.\n*/\nSQLITE_PRIVATE int sqlite3BtreeClearTableOfCursor(BtCursor *pCur){\n  return sqlite3BtreeClearTable(pCur->pBtree, pCur->pgnoRoot, 0);\n}\n\n/*\n** Erase all information in a table and add the root of the table to\n** the freelist.  Except, the root of the principle table (the one on\n** page 1) is never added to the freelist.\n**\n** This routine will fail with SQLITE_LOCKED if there are any open\n** cursors on the table.\n**\n** If AUTOVACUUM is enabled and the page at iTable is not the last\n** root page in the database file, then the last root page \n** in the database file is moved into the slot formerly occupied by\n** iTable and that last slot formerly occupied by the last root page\n** is added to the freelist instead of iTable.  In this say, all\n** root pages are kept at the beginning of the database file, which\n** is necessary for AUTOVACUUM to work right.  *piMoved is set to the \n** page number that used to be the last root page in the file before\n** the move.  If no page gets moved, *piMoved is set to 0.\n** The last root page is recorded in meta[3] and the value of\n** meta[3] is updated by this procedure.\n*/\nstatic int btreeDropTable(Btree *p, Pgno iTable, int *piMoved){\n  int rc;\n  MemPage *pPage = 0;\n  BtShared *pBt = p->pBt;\n\n  assert( sqlite3BtreeHoldsMutex(p) );\n  assert( p->inTrans==TRANS_WRITE );\n  assert( iTable>=2 );\n\n  rc = btreeGetPage(pBt, (Pgno)iTable, &pPage, 0);\n  if( rc ) return rc;\n  rc = sqlite3BtreeClearTable(p, iTable, 0);\n  if( rc ){\n    releasePage(pPage);\n    return rc;\n  }\n\n  *piMoved = 0;\n\n#ifdef SQLITE_OMIT_AUTOVACUUM\n  freePage(pPage, &rc);\n  releasePage(pPage);\n#else\n  if( pBt->autoVacuum ){\n    Pgno maxRootPgno;\n    sqlite3BtreeGetMeta(p, BTREE_LARGEST_ROOT_PAGE, &maxRootPgno);\n\n    if( iTable==maxRootPgno ){\n      /* If the table being dropped is the table with the largest root-page\n      ** number in the database, put the root page on the free list. \n      */\n      freePage(pPage, &rc);\n      releasePage(pPage);\n      if( rc!=SQLITE_OK ){\n        return rc;\n      }\n    }else{\n      /* The table being dropped does not have the largest root-page\n      ** number in the database. So move the page that does into the \n      ** gap left by the deleted root-page.\n      */\n      MemPage *pMove;\n      releasePage(pPage);\n      rc = btreeGetPage(pBt, maxRootPgno, &pMove, 0);\n      if( rc!=SQLITE_OK ){\n        return rc;\n      }\n      rc = relocatePage(pBt, pMove, PTRMAP_ROOTPAGE, 0, iTable, 0);\n      releasePage(pMove);\n      if( rc!=SQLITE_OK ){\n        return rc;\n      }\n      pMove = 0;\n      rc = btreeGetPage(pBt, maxRootPgno, &pMove, 0);\n      freePage(pMove, &rc);\n      releasePage(pMove);\n      if( rc!=SQLITE_OK ){\n        return rc;\n      }\n      *piMoved = maxRootPgno;\n    }\n\n    /* Set the new 'max-root-page' value in the database header. This\n    ** is the old value less one, less one more if that happens to\n    ** be a root-page number, less one again if that is the\n    ** PENDING_BYTE_PAGE.\n    */\n    maxRootPgno--;\n    while( maxRootPgno==PENDING_BYTE_PAGE(pBt)\n           || PTRMAP_ISPAGE(pBt, maxRootPgno) ){\n      maxRootPgno--;\n    }\n    assert( maxRootPgno!=PENDING_BYTE_PAGE(pBt) );\n\n    rc = sqlite3BtreeUpdateMeta(p, 4, maxRootPgno);\n  }else{\n    freePage(pPage, &rc);\n    releasePage(pPage);\n  }\n#endif\n  return rc;  \n}\nSQLITE_PRIVATE int sqlite3BtreeDropTable(Btree *p, int iTable, int *piMoved){\n  int rc;\n  sqlite3BtreeEnter(p);\n  rc = btreeDropTable(p, iTable, piMoved);\n  sqlite3BtreeLeave(p);\n  return rc;\n}\n\n\n/*\n** This function may only be called if the b-tree connection already\n** has a read or write transaction open on the database.\n**\n** Read the meta-information out of a database file.  Meta[0]\n** is the number of free pages currently in the database.  Meta[1]\n** through meta[15] are available for use by higher layers.  Meta[0]\n** is read-only, the others are read/write.\n** \n** The schema layer numbers meta values differently.  At the schema\n** layer (and the SetCookie and ReadCookie opcodes) the number of\n** free pages is not visible.  So Cookie[0] is the same as Meta[1].\n**\n** This routine treats Meta[BTREE_DATA_VERSION] as a special case.  Instead\n** of reading the value out of the header, it instead loads the \"DataVersion\"\n** from the pager.  The BTREE_DATA_VERSION value is not actually stored in the\n** database file.  It is a number computed by the pager.  But its access\n** pattern is the same as header meta values, and so it is convenient to\n** read it from this routine.\n*/\nSQLITE_PRIVATE void sqlite3BtreeGetMeta(Btree *p, int idx, u32 *pMeta){\n  BtShared *pBt = p->pBt;\n\n  sqlite3BtreeEnter(p);\n  assert( p->inTrans>TRANS_NONE );\n  assert( SQLITE_OK==querySharedCacheTableLock(p, MASTER_ROOT, READ_LOCK) );\n  assert( pBt->pPage1 );\n  assert( idx>=0 && idx<=15 );\n\n  if( idx==BTREE_DATA_VERSION ){\n    *pMeta = sqlite3PagerDataVersion(pBt->pPager) + p->iDataVersion;\n  }else{\n    *pMeta = get4byte(&pBt->pPage1->aData[36 + idx*4]);\n  }\n\n  /* If auto-vacuum is disabled in this build and this is an auto-vacuum\n  ** database, mark the database as read-only.  */\n#ifdef SQLITE_OMIT_AUTOVACUUM\n  if( idx==BTREE_LARGEST_ROOT_PAGE && *pMeta>0 ){\n    pBt->btsFlags |= BTS_READ_ONLY;\n  }\n#endif\n\n  sqlite3BtreeLeave(p);\n}\n\n/*\n** Write meta-information back into the database.  Meta[0] is\n** read-only and may not be written.\n*/\nSQLITE_PRIVATE int sqlite3BtreeUpdateMeta(Btree *p, int idx, u32 iMeta){\n  BtShared *pBt = p->pBt;\n  unsigned char *pP1;\n  int rc;\n  assert( idx>=1 && idx<=15 );\n  sqlite3BtreeEnter(p);\n  assert( p->inTrans==TRANS_WRITE );\n  assert( pBt->pPage1!=0 );\n  pP1 = pBt->pPage1->aData;\n  rc = sqlite3PagerWrite(pBt->pPage1->pDbPage);\n  if( rc==SQLITE_OK ){\n    put4byte(&pP1[36 + idx*4], iMeta);\n#ifndef SQLITE_OMIT_AUTOVACUUM\n    if( idx==BTREE_INCR_VACUUM ){\n      assert( pBt->autoVacuum || iMeta==0 );\n      assert( iMeta==0 || iMeta==1 );\n      pBt->incrVacuum = (u8)iMeta;\n    }\n#endif\n  }\n  sqlite3BtreeLeave(p);\n  return rc;\n}\n\n#ifndef SQLITE_OMIT_BTREECOUNT\n/*\n** The first argument, pCur, is a cursor opened on some b-tree. Count the\n** number of entries in the b-tree and write the result to *pnEntry.\n**\n** SQLITE_OK is returned if the operation is successfully executed. \n** Otherwise, if an error is encountered (i.e. an IO error or database\n** corruption) an SQLite error code is returned.\n*/\nSQLITE_PRIVATE int sqlite3BtreeCount(BtCursor *pCur, i64 *pnEntry){\n  i64 nEntry = 0;                      /* Value to return in *pnEntry */\n  int rc;                              /* Return code */\n\n  rc = moveToRoot(pCur);\n  if( rc==SQLITE_EMPTY ){\n    *pnEntry = 0;\n    return SQLITE_OK;\n  }\n\n  /* Unless an error occurs, the following loop runs one iteration for each\n  ** page in the B-Tree structure (not including overflow pages). \n  */\n  while( rc==SQLITE_OK ){\n    int iIdx;                          /* Index of child node in parent */\n    MemPage *pPage;                    /* Current page of the b-tree */\n\n    /* If this is a leaf page or the tree is not an int-key tree, then \n    ** this page contains countable entries. Increment the entry counter\n    ** accordingly.\n    */\n    pPage = pCur->pPage;\n    if( pPage->leaf || !pPage->intKey ){\n      nEntry += pPage->nCell;\n    }\n\n    /* pPage is a leaf node. This loop navigates the cursor so that it \n    ** points to the first interior cell that it points to the parent of\n    ** the next page in the tree that has not yet been visited. The\n    ** pCur->aiIdx[pCur->iPage] value is set to the index of the parent cell\n    ** of the page, or to the number of cells in the page if the next page\n    ** to visit is the right-child of its parent.\n    **\n    ** If all pages in the tree have been visited, return SQLITE_OK to the\n    ** caller.\n    */\n    if( pPage->leaf ){\n      do {\n        if( pCur->iPage==0 ){\n          /* All pages of the b-tree have been visited. Return successfully. */\n          *pnEntry = nEntry;\n          return moveToRoot(pCur);\n        }\n        moveToParent(pCur);\n      }while ( pCur->ix>=pCur->pPage->nCell );\n\n      pCur->ix++;\n      pPage = pCur->pPage;\n    }\n\n    /* Descend to the child node of the cell that the cursor currently \n    ** points at. This is the right-child if (iIdx==pPage->nCell).\n    */\n    iIdx = pCur->ix;\n    if( iIdx==pPage->nCell ){\n      rc = moveToChild(pCur, get4byte(&pPage->aData[pPage->hdrOffset+8]));\n    }else{\n      rc = moveToChild(pCur, get4byte(findCell(pPage, iIdx)));\n    }\n  }\n\n  /* An error has occurred. Return an error code. */\n  return rc;\n}\n#endif\n\n/*\n** Return the pager associated with a BTree.  This routine is used for\n** testing and debugging only.\n*/\nSQLITE_PRIVATE Pager *sqlite3BtreePager(Btree *p){\n  return p->pBt->pPager;\n}\n\n#ifndef SQLITE_OMIT_INTEGRITY_CHECK\n/*\n** Append a message to the error message string.\n*/\nstatic void checkAppendMsg(\n  IntegrityCk *pCheck,\n  const char *zFormat,\n  ...\n){\n  va_list ap;\n  if( !pCheck->mxErr ) return;\n  pCheck->mxErr--;\n  pCheck->nErr++;\n  va_start(ap, zFormat);\n  if( pCheck->errMsg.nChar ){\n    sqlite3_str_append(&pCheck->errMsg, \"\\n\", 1);\n  }\n  if( pCheck->zPfx ){\n    sqlite3_str_appendf(&pCheck->errMsg, pCheck->zPfx, pCheck->v1, pCheck->v2);\n  }\n  sqlite3_str_vappendf(&pCheck->errMsg, zFormat, ap);\n  va_end(ap);\n  if( pCheck->errMsg.accError==SQLITE_NOMEM ){\n    pCheck->mallocFailed = 1;\n  }\n}\n#endif /* SQLITE_OMIT_INTEGRITY_CHECK */\n\n#ifndef SQLITE_OMIT_INTEGRITY_CHECK\n\n/*\n** Return non-zero if the bit in the IntegrityCk.aPgRef[] array that\n** corresponds to page iPg is already set.\n*/\nstatic int getPageReferenced(IntegrityCk *pCheck, Pgno iPg){\n  assert( iPg<=pCheck->nPage && sizeof(pCheck->aPgRef[0])==1 );\n  return (pCheck->aPgRef[iPg/8] & (1 << (iPg & 0x07)));\n}\n\n/*\n** Set the bit in the IntegrityCk.aPgRef[] array that corresponds to page iPg.\n*/\nstatic void setPageReferenced(IntegrityCk *pCheck, Pgno iPg){\n  assert( iPg<=pCheck->nPage && sizeof(pCheck->aPgRef[0])==1 );\n  pCheck->aPgRef[iPg/8] |= (1 << (iPg & 0x07));\n}\n\n\n/*\n** Add 1 to the reference count for page iPage.  If this is the second\n** reference to the page, add an error message to pCheck->zErrMsg.\n** Return 1 if there are 2 or more references to the page and 0 if\n** if this is the first reference to the page.\n**\n** Also check that the page number is in bounds.\n*/\nstatic int checkRef(IntegrityCk *pCheck, Pgno iPage){\n  if( iPage>pCheck->nPage || iPage==0 ){\n    checkAppendMsg(pCheck, \"invalid page number %d\", iPage);\n    return 1;\n  }\n  if( getPageReferenced(pCheck, iPage) ){\n    checkAppendMsg(pCheck, \"2nd reference to page %d\", iPage);\n    return 1;\n  }\n  setPageReferenced(pCheck, iPage);\n  return 0;\n}\n\n#ifndef SQLITE_OMIT_AUTOVACUUM\n/*\n** Check that the entry in the pointer-map for page iChild maps to \n** page iParent, pointer type ptrType. If not, append an error message\n** to pCheck.\n*/\nstatic void checkPtrmap(\n  IntegrityCk *pCheck,   /* Integrity check context */\n  Pgno iChild,           /* Child page number */\n  u8 eType,              /* Expected pointer map type */\n  Pgno iParent           /* Expected pointer map parent page number */\n){\n  int rc;\n  u8 ePtrmapType;\n  Pgno iPtrmapParent;\n\n  rc = ptrmapGet(pCheck->pBt, iChild, &ePtrmapType, &iPtrmapParent);\n  if( rc!=SQLITE_OK ){\n    if( rc==SQLITE_NOMEM || rc==SQLITE_IOERR_NOMEM ) pCheck->mallocFailed = 1;\n    checkAppendMsg(pCheck, \"Failed to read ptrmap key=%d\", iChild);\n    return;\n  }\n\n  if( ePtrmapType!=eType || iPtrmapParent!=iParent ){\n    checkAppendMsg(pCheck,\n      \"Bad ptr map entry key=%d expected=(%d,%d) got=(%d,%d)\", \n      iChild, eType, iParent, ePtrmapType, iPtrmapParent);\n  }\n}\n#endif\n\n/*\n** Check the integrity of the freelist or of an overflow page list.\n** Verify that the number of pages on the list is N.\n*/\nstatic void checkList(\n  IntegrityCk *pCheck,  /* Integrity checking context */\n  int isFreeList,       /* True for a freelist.  False for overflow page list */\n  int iPage,            /* Page number for first page in the list */\n  int N                 /* Expected number of pages in the list */\n){\n  int i;\n  int expected = N;\n  int nErrAtStart = pCheck->nErr;\n  while( iPage!=0 && pCheck->mxErr ){\n    DbPage *pOvflPage;\n    unsigned char *pOvflData;\n    if( checkRef(pCheck, iPage) ) break;\n    N--;\n    if( sqlite3PagerGet(pCheck->pPager, (Pgno)iPage, &pOvflPage, 0) ){\n      checkAppendMsg(pCheck, \"failed to get page %d\", iPage);\n      break;\n    }\n    pOvflData = (unsigned char *)sqlite3PagerGetData(pOvflPage);\n    if( isFreeList ){\n      u32 n = (u32)get4byte(&pOvflData[4]);\n#ifndef SQLITE_OMIT_AUTOVACUUM\n      if( pCheck->pBt->autoVacuum ){\n        checkPtrmap(pCheck, iPage, PTRMAP_FREEPAGE, 0);\n      }\n#endif\n      if( n>pCheck->pBt->usableSize/4-2 ){\n        checkAppendMsg(pCheck,\n           \"freelist leaf count too big on page %d\", iPage);\n        N--;\n      }else{\n        for(i=0; i<(int)n; i++){\n          Pgno iFreePage = get4byte(&pOvflData[8+i*4]);\n#ifndef SQLITE_OMIT_AUTOVACUUM\n          if( pCheck->pBt->autoVacuum ){\n            checkPtrmap(pCheck, iFreePage, PTRMAP_FREEPAGE, 0);\n          }\n#endif\n          checkRef(pCheck, iFreePage);\n        }\n        N -= n;\n      }\n    }\n#ifndef SQLITE_OMIT_AUTOVACUUM\n    else{\n      /* If this database supports auto-vacuum and iPage is not the last\n      ** page in this overflow list, check that the pointer-map entry for\n      ** the following page matches iPage.\n      */\n      if( pCheck->pBt->autoVacuum && N>0 ){\n        i = get4byte(pOvflData);\n        checkPtrmap(pCheck, i, PTRMAP_OVERFLOW2, iPage);\n      }\n    }\n#endif\n    iPage = get4byte(pOvflData);\n    sqlite3PagerUnref(pOvflPage);\n  }\n  if( N && nErrAtStart==pCheck->nErr ){\n    checkAppendMsg(pCheck,\n      \"%s is %d but should be %d\",\n      isFreeList ? \"size\" : \"overflow list length\",\n      expected-N, expected);\n  }\n}\n#endif /* SQLITE_OMIT_INTEGRITY_CHECK */\n\n/*\n** An implementation of a min-heap.\n**\n** aHeap[0] is the number of elements on the heap.  aHeap[1] is the\n** root element.  The daughter nodes of aHeap[N] are aHeap[N*2]\n** and aHeap[N*2+1].\n**\n** The heap property is this:  Every node is less than or equal to both\n** of its daughter nodes.  A consequence of the heap property is that the\n** root node aHeap[1] is always the minimum value currently in the heap.\n**\n** The btreeHeapInsert() routine inserts an unsigned 32-bit number onto\n** the heap, preserving the heap property.  The btreeHeapPull() routine\n** removes the root element from the heap (the minimum value in the heap)\n** and then moves other nodes around as necessary to preserve the heap\n** property.\n**\n** This heap is used for cell overlap and coverage testing.  Each u32\n** entry represents the span of a cell or freeblock on a btree page.  \n** The upper 16 bits are the index of the first byte of a range and the\n** lower 16 bits are the index of the last byte of that range.\n*/\nstatic void btreeHeapInsert(u32 *aHeap, u32 x){\n  u32 j, i = ++aHeap[0];\n  aHeap[i] = x;\n  while( (j = i/2)>0 && aHeap[j]>aHeap[i] ){\n    x = aHeap[j];\n    aHeap[j] = aHeap[i];\n    aHeap[i] = x;\n    i = j;\n  }\n}\nstatic int btreeHeapPull(u32 *aHeap, u32 *pOut){\n  u32 j, i, x;\n  if( (x = aHeap[0])==0 ) return 0;\n  *pOut = aHeap[1];\n  aHeap[1] = aHeap[x];\n  aHeap[x] = 0xffffffff;\n  aHeap[0]--;\n  i = 1;\n  while( (j = i*2)<=aHeap[0] ){\n    if( aHeap[j]>aHeap[j+1] ) j++;\n    if( aHeap[i]<aHeap[j] ) break;\n    x = aHeap[i];\n    aHeap[i] = aHeap[j];\n    aHeap[j] = x;\n    i = j;\n  }\n  return 1;  \n}\n\n#ifndef SQLITE_OMIT_INTEGRITY_CHECK\n/*\n** Do various sanity checks on a single page of a tree.  Return\n** the tree depth.  Root pages return 0.  Parents of root pages\n** return 1, and so forth.\n** \n** These checks are done:\n**\n**      1.  Make sure that cells and freeblocks do not overlap\n**          but combine to completely cover the page.\n**      2.  Make sure integer cell keys are in order.\n**      3.  Check the integrity of overflow pages.\n**      4.  Recursively call checkTreePage on all children.\n**      5.  Verify that the depth of all children is the same.\n*/\nstatic int checkTreePage(\n  IntegrityCk *pCheck,  /* Context for the sanity check */\n  int iPage,            /* Page number of the page to check */\n  i64 *piMinKey,        /* Write minimum integer primary key here */\n  i64 maxKey            /* Error if integer primary key greater than this */\n){\n  MemPage *pPage = 0;      /* The page being analyzed */\n  int i;                   /* Loop counter */\n  int rc;                  /* Result code from subroutine call */\n  int depth = -1, d2;      /* Depth of a subtree */\n  int pgno;                /* Page number */\n  int nFrag;               /* Number of fragmented bytes on the page */\n  int hdr;                 /* Offset to the page header */\n  int cellStart;           /* Offset to the start of the cell pointer array */\n  int nCell;               /* Number of cells */\n  int doCoverageCheck = 1; /* True if cell coverage checking should be done */\n  int keyCanBeEqual = 1;   /* True if IPK can be equal to maxKey\n                           ** False if IPK must be strictly less than maxKey */\n  u8 *data;                /* Page content */\n  u8 *pCell;               /* Cell content */\n  u8 *pCellIdx;            /* Next element of the cell pointer array */\n  BtShared *pBt;           /* The BtShared object that owns pPage */\n  u32 pc;                  /* Address of a cell */\n  u32 usableSize;          /* Usable size of the page */\n  u32 contentOffset;       /* Offset to the start of the cell content area */\n  u32 *heap = 0;           /* Min-heap used for checking cell coverage */\n  u32 x, prev = 0;         /* Next and previous entry on the min-heap */\n  const char *saved_zPfx = pCheck->zPfx;\n  int saved_v1 = pCheck->v1;\n  int saved_v2 = pCheck->v2;\n  u8 savedIsInit = 0;\n\n  /* Check that the page exists\n  */\n  pBt = pCheck->pBt;\n  usableSize = pBt->usableSize;\n  if( iPage==0 ) return 0;\n  if( checkRef(pCheck, iPage) ) return 0;\n  pCheck->zPfx = \"Page %d: \";\n  pCheck->v1 = iPage;\n  if( (rc = btreeGetPage(pBt, (Pgno)iPage, &pPage, 0))!=0 ){\n    checkAppendMsg(pCheck,\n       \"unable to get the page. error code=%d\", rc);\n    goto end_of_check;\n  }\n\n  /* Clear MemPage.isInit to make sure the corruption detection code in\n  ** btreeInitPage() is executed.  */\n  savedIsInit = pPage->isInit;\n  pPage->isInit = 0;\n  if( (rc = btreeInitPage(pPage))!=0 ){\n    assert( rc==SQLITE_CORRUPT );  /* The only possible error from InitPage */\n    checkAppendMsg(pCheck,\n                   \"btreeInitPage() returns error code %d\", rc);\n    goto end_of_check;\n  }\n  data = pPage->aData;\n  hdr = pPage->hdrOffset;\n\n  /* Set up for cell analysis */\n  pCheck->zPfx = \"On tree page %d cell %d: \";\n  contentOffset = get2byteNotZero(&data[hdr+5]);\n  assert( contentOffset<=usableSize );  /* Enforced by btreeInitPage() */\n\n  /* EVIDENCE-OF: R-37002-32774 The two-byte integer at offset 3 gives the\n  ** number of cells on the page. */\n  nCell = get2byte(&data[hdr+3]);\n  assert( pPage->nCell==nCell );\n\n  /* EVIDENCE-OF: R-23882-45353 The cell pointer array of a b-tree page\n  ** immediately follows the b-tree page header. */\n  cellStart = hdr + 12 - 4*pPage->leaf;\n  assert( pPage->aCellIdx==&data[cellStart] );\n  pCellIdx = &data[cellStart + 2*(nCell-1)];\n\n  if( !pPage->leaf ){\n    /* Analyze the right-child page of internal pages */\n    pgno = get4byte(&data[hdr+8]);\n#ifndef SQLITE_OMIT_AUTOVACUUM\n    if( pBt->autoVacuum ){\n      pCheck->zPfx = \"On page %d at right child: \";\n      checkPtrmap(pCheck, pgno, PTRMAP_BTREE, iPage);\n    }\n#endif\n    depth = checkTreePage(pCheck, pgno, &maxKey, maxKey);\n    keyCanBeEqual = 0;\n  }else{\n    /* For leaf pages, the coverage check will occur in the same loop\n    ** as the other cell checks, so initialize the heap.  */\n    heap = pCheck->heap;\n    heap[0] = 0;\n  }\n\n  /* EVIDENCE-OF: R-02776-14802 The cell pointer array consists of K 2-byte\n  ** integer offsets to the cell contents. */\n  for(i=nCell-1; i>=0 && pCheck->mxErr; i--){\n    CellInfo info;\n\n    /* Check cell size */\n    pCheck->v2 = i;\n    assert( pCellIdx==&data[cellStart + i*2] );\n    pc = get2byteAligned(pCellIdx);\n    pCellIdx -= 2;\n    if( pc<contentOffset || pc>usableSize-4 ){\n      checkAppendMsg(pCheck, \"Offset %d out of range %d..%d\",\n                             pc, contentOffset, usableSize-4);\n      doCoverageCheck = 0;\n      continue;\n    }\n    pCell = &data[pc];\n    pPage->xParseCell(pPage, pCell, &info);\n    if( pc+info.nSize>usableSize ){\n      checkAppendMsg(pCheck, \"Extends off end of page\");\n      doCoverageCheck = 0;\n      continue;\n    }\n\n    /* Check for integer primary key out of range */\n    if( pPage->intKey ){\n      if( keyCanBeEqual ? (info.nKey > maxKey) : (info.nKey >= maxKey) ){\n        checkAppendMsg(pCheck, \"Rowid %lld out of order\", info.nKey);\n      }\n      maxKey = info.nKey;\n      keyCanBeEqual = 0;     /* Only the first key on the page may ==maxKey */\n    }\n\n    /* Check the content overflow list */\n    if( info.nPayload>info.nLocal ){\n      int nPage;       /* Number of pages on the overflow chain */\n      Pgno pgnoOvfl;   /* First page of the overflow chain */\n      assert( pc + info.nSize - 4 <= usableSize );\n      nPage = (info.nPayload - info.nLocal + usableSize - 5)/(usableSize - 4);\n      pgnoOvfl = get4byte(&pCell[info.nSize - 4]);\n#ifndef SQLITE_OMIT_AUTOVACUUM\n      if( pBt->autoVacuum ){\n        checkPtrmap(pCheck, pgnoOvfl, PTRMAP_OVERFLOW1, iPage);\n      }\n#endif\n      checkList(pCheck, 0, pgnoOvfl, nPage);\n    }\n\n    if( !pPage->leaf ){\n      /* Check sanity of left child page for internal pages */\n      pgno = get4byte(pCell);\n#ifndef SQLITE_OMIT_AUTOVACUUM\n      if( pBt->autoVacuum ){\n        checkPtrmap(pCheck, pgno, PTRMAP_BTREE, iPage);\n      }\n#endif\n      d2 = checkTreePage(pCheck, pgno, &maxKey, maxKey);\n      keyCanBeEqual = 0;\n      if( d2!=depth ){\n        checkAppendMsg(pCheck, \"Child page depth differs\");\n        depth = d2;\n      }\n    }else{\n      /* Populate the coverage-checking heap for leaf pages */\n      btreeHeapInsert(heap, (pc<<16)|(pc+info.nSize-1));\n    }\n  }\n  *piMinKey = maxKey;\n\n  /* Check for complete coverage of the page\n  */\n  pCheck->zPfx = 0;\n  if( doCoverageCheck && pCheck->mxErr>0 ){\n    /* For leaf pages, the min-heap has already been initialized and the\n    ** cells have already been inserted.  But for internal pages, that has\n    ** not yet been done, so do it now */\n    if( !pPage->leaf ){\n      heap = pCheck->heap;\n      heap[0] = 0;\n      for(i=nCell-1; i>=0; i--){\n        u32 size;\n        pc = get2byteAligned(&data[cellStart+i*2]);\n        size = pPage->xCellSize(pPage, &data[pc]);\n        btreeHeapInsert(heap, (pc<<16)|(pc+size-1));\n      }\n    }\n    /* Add the freeblocks to the min-heap\n    **\n    ** EVIDENCE-OF: R-20690-50594 The second field of the b-tree page header\n    ** is the offset of the first freeblock, or zero if there are no\n    ** freeblocks on the page. \n    */\n    i = get2byte(&data[hdr+1]);\n    while( i>0 ){\n      int size, j;\n      assert( (u32)i<=usableSize-4 );     /* Enforced by btreeInitPage() */\n      size = get2byte(&data[i+2]);\n      assert( (u32)(i+size)<=usableSize );  /* Enforced by btreeInitPage() */\n      btreeHeapInsert(heap, (((u32)i)<<16)|(i+size-1));\n      /* EVIDENCE-OF: R-58208-19414 The first 2 bytes of a freeblock are a\n      ** big-endian integer which is the offset in the b-tree page of the next\n      ** freeblock in the chain, or zero if the freeblock is the last on the\n      ** chain. */\n      j = get2byte(&data[i]);\n      /* EVIDENCE-OF: R-06866-39125 Freeblocks are always connected in order of\n      ** increasing offset. */\n      assert( j==0 || j>i+size );  /* Enforced by btreeInitPage() */\n      assert( (u32)j<=usableSize-4 );   /* Enforced by btreeInitPage() */\n      i = j;\n    }\n    /* Analyze the min-heap looking for overlap between cells and/or \n    ** freeblocks, and counting the number of untracked bytes in nFrag.\n    ** \n    ** Each min-heap entry is of the form:    (start_address<<16)|end_address.\n    ** There is an implied first entry the covers the page header, the cell\n    ** pointer index, and the gap between the cell pointer index and the start\n    ** of cell content.  \n    **\n    ** The loop below pulls entries from the min-heap in order and compares\n    ** the start_address against the previous end_address.  If there is an\n    ** overlap, that means bytes are used multiple times.  If there is a gap,\n    ** that gap is added to the fragmentation count.\n    */\n    nFrag = 0;\n    prev = contentOffset - 1;   /* Implied first min-heap entry */\n    while( btreeHeapPull(heap,&x) ){\n      if( (prev&0xffff)>=(x>>16) ){\n        checkAppendMsg(pCheck,\n          \"Multiple uses for byte %u of page %d\", x>>16, iPage);\n        break;\n      }else{\n        nFrag += (x>>16) - (prev&0xffff) - 1;\n        prev = x;\n      }\n    }\n    nFrag += usableSize - (prev&0xffff) - 1;\n    /* EVIDENCE-OF: R-43263-13491 The total number of bytes in all fragments\n    ** is stored in the fifth field of the b-tree page header.\n    ** EVIDENCE-OF: R-07161-27322 The one-byte integer at offset 7 gives the\n    ** number of fragmented free bytes within the cell content area.\n    */\n    if( heap[0]==0 && nFrag!=data[hdr+7] ){\n      checkAppendMsg(pCheck,\n          \"Fragmentation of %d bytes reported as %d on page %d\",\n          nFrag, data[hdr+7], iPage);\n    }\n  }\n\nend_of_check:\n  if( !doCoverageCheck ) pPage->isInit = savedIsInit;\n  releasePage(pPage);\n  pCheck->zPfx = saved_zPfx;\n  pCheck->v1 = saved_v1;\n  pCheck->v2 = saved_v2;\n  return depth+1;\n}\n#endif /* SQLITE_OMIT_INTEGRITY_CHECK */\n\n#ifndef SQLITE_OMIT_INTEGRITY_CHECK\n/*\n** This routine does a complete check of the given BTree file.  aRoot[] is\n** an array of pages numbers were each page number is the root page of\n** a table.  nRoot is the number of entries in aRoot.\n**\n** A read-only or read-write transaction must be opened before calling\n** this function.\n**\n** Write the number of error seen in *pnErr.  Except for some memory\n** allocation errors,  an error message held in memory obtained from\n** malloc is returned if *pnErr is non-zero.  If *pnErr==0 then NULL is\n** returned.  If a memory allocation error occurs, NULL is returned.\n*/\nSQLITE_PRIVATE char *sqlite3BtreeIntegrityCheck(\n  Btree *p,     /* The btree to be checked */\n  int *aRoot,   /* An array of root pages numbers for individual trees */\n  int nRoot,    /* Number of entries in aRoot[] */\n  int mxErr,    /* Stop reporting errors after this many */\n  int *pnErr    /* Write number of errors seen to this variable */\n){\n  Pgno i;\n  IntegrityCk sCheck;\n  BtShared *pBt = p->pBt;\n  u64 savedDbFlags = pBt->db->flags;\n  char zErr[100];\n  VVA_ONLY( int nRef );\n\n  sqlite3BtreeEnter(p);\n  assert( p->inTrans>TRANS_NONE && pBt->inTransaction>TRANS_NONE );\n  VVA_ONLY( nRef = sqlite3PagerRefcount(pBt->pPager) );\n  assert( nRef>=0 );\n  sCheck.pBt = pBt;\n  sCheck.pPager = pBt->pPager;\n  sCheck.nPage = btreePagecount(sCheck.pBt);\n  sCheck.mxErr = mxErr;\n  sCheck.nErr = 0;\n  sCheck.mallocFailed = 0;\n  sCheck.zPfx = 0;\n  sCheck.v1 = 0;\n  sCheck.v2 = 0;\n  sCheck.aPgRef = 0;\n  sCheck.heap = 0;\n  sqlite3StrAccumInit(&sCheck.errMsg, 0, zErr, sizeof(zErr), SQLITE_MAX_LENGTH);\n  sCheck.errMsg.printfFlags = SQLITE_PRINTF_INTERNAL;\n  if( sCheck.nPage==0 ){\n    goto integrity_ck_cleanup;\n  }\n\n  sCheck.aPgRef = sqlite3MallocZero((sCheck.nPage / 8)+ 1);\n  if( !sCheck.aPgRef ){\n    sCheck.mallocFailed = 1;\n    goto integrity_ck_cleanup;\n  }\n  sCheck.heap = (u32*)sqlite3PageMalloc( pBt->pageSize );\n  if( sCheck.heap==0 ){\n    sCheck.mallocFailed = 1;\n    goto integrity_ck_cleanup;\n  }\n\n  i = PENDING_BYTE_PAGE(pBt);\n  if( i<=sCheck.nPage ) setPageReferenced(&sCheck, i);\n\n  /* Check the integrity of the freelist\n  */\n  sCheck.zPfx = \"Main freelist: \";\n  checkList(&sCheck, 1, get4byte(&pBt->pPage1->aData[32]),\n            get4byte(&pBt->pPage1->aData[36]));\n  sCheck.zPfx = 0;\n\n  /* Check all the tables.\n  */\n#ifndef SQLITE_OMIT_AUTOVACUUM\n  if( pBt->autoVacuum ){\n    int mx = 0;\n    int mxInHdr;\n    for(i=0; (int)i<nRoot; i++) if( mx<aRoot[i] ) mx = aRoot[i];\n    mxInHdr = get4byte(&pBt->pPage1->aData[52]);\n    if( mx!=mxInHdr ){\n      checkAppendMsg(&sCheck,\n        \"max rootpage (%d) disagrees with header (%d)\",\n        mx, mxInHdr\n      );\n    }\n  }else if( get4byte(&pBt->pPage1->aData[64])!=0 ){\n    checkAppendMsg(&sCheck,\n      \"incremental_vacuum enabled with a max rootpage of zero\"\n    );\n  }\n#endif\n  testcase( pBt->db->flags & SQLITE_CellSizeCk );\n  pBt->db->flags &= ~(u64)SQLITE_CellSizeCk;\n  for(i=0; (int)i<nRoot && sCheck.mxErr; i++){\n    i64 notUsed;\n    if( aRoot[i]==0 ) continue;\n#ifndef SQLITE_OMIT_AUTOVACUUM\n    if( pBt->autoVacuum && aRoot[i]>1 ){\n      checkPtrmap(&sCheck, aRoot[i], PTRMAP_ROOTPAGE, 0);\n    }\n#endif\n    checkTreePage(&sCheck, aRoot[i], &notUsed, LARGEST_INT64);\n  }\n  pBt->db->flags = savedDbFlags;\n\n  /* Make sure every page in the file is referenced\n  */\n  for(i=1; i<=sCheck.nPage && sCheck.mxErr; i++){\n#ifdef SQLITE_OMIT_AUTOVACUUM\n    if( getPageReferenced(&sCheck, i)==0 ){\n      checkAppendMsg(&sCheck, \"Page %d is never used\", i);\n    }\n#else\n    /* If the database supports auto-vacuum, make sure no tables contain\n    ** references to pointer-map pages.\n    */\n    if( getPageReferenced(&sCheck, i)==0 && \n       (PTRMAP_PAGENO(pBt, i)!=i || !pBt->autoVacuum) ){\n      checkAppendMsg(&sCheck, \"Page %d is never used\", i);\n    }\n    if( getPageReferenced(&sCheck, i)!=0 && \n       (PTRMAP_PAGENO(pBt, i)==i && pBt->autoVacuum) ){\n      checkAppendMsg(&sCheck, \"Pointer map page %d is referenced\", i);\n    }\n#endif\n  }\n\n  /* Clean  up and report errors.\n  */\nintegrity_ck_cleanup:\n  sqlite3PageFree(sCheck.heap);\n  sqlite3_free(sCheck.aPgRef);\n  if( sCheck.mallocFailed ){\n    sqlite3_str_reset(&sCheck.errMsg);\n    sCheck.nErr++;\n  }\n  *pnErr = sCheck.nErr;\n  if( sCheck.nErr==0 ) sqlite3_str_reset(&sCheck.errMsg);\n  /* Make sure this analysis did not leave any unref() pages. */\n  assert( nRef==sqlite3PagerRefcount(pBt->pPager) );\n  sqlite3BtreeLeave(p);\n  return sqlite3StrAccumFinish(&sCheck.errMsg);\n}\n#endif /* SQLITE_OMIT_INTEGRITY_CHECK */\n\n/*\n** Return the full pathname of the underlying database file.  Return\n** an empty string if the database is in-memory or a TEMP database.\n**\n** The pager filename is invariant as long as the pager is\n** open so it is safe to access without the BtShared mutex.\n*/\nSQLITE_PRIVATE const char *sqlite3BtreeGetFilename(Btree *p){\n  assert( p->pBt->pPager!=0 );\n  return sqlite3PagerFilename(p->pBt->pPager, 1);\n}\n\n/*\n** Return the pathname of the journal file for this database. The return\n** value of this routine is the same regardless of whether the journal file\n** has been created or not.\n**\n** The pager journal filename is invariant as long as the pager is\n** open so it is safe to access without the BtShared mutex.\n*/\nSQLITE_PRIVATE const char *sqlite3BtreeGetJournalname(Btree *p){\n  assert( p->pBt->pPager!=0 );\n  return sqlite3PagerJournalname(p->pBt->pPager);\n}\n\n/*\n** Return non-zero if a transaction is active.\n*/\nSQLITE_PRIVATE int sqlite3BtreeIsInTrans(Btree *p){\n  assert( p==0 || sqlite3_mutex_held(p->db->mutex) );\n  return (p && (p->inTrans==TRANS_WRITE));\n}\n\n#ifndef SQLITE_OMIT_WAL\n/*\n** Run a checkpoint on the Btree passed as the first argument.\n**\n** Return SQLITE_LOCKED if this or any other connection has an open \n** transaction on the shared-cache the argument Btree is connected to.\n**\n** Parameter eMode is one of SQLITE_CHECKPOINT_PASSIVE, FULL or RESTART.\n*/\nSQLITE_PRIVATE int sqlite3BtreeCheckpoint(Btree *p, int eMode, int *pnLog, int *pnCkpt){\n  int rc = SQLITE_OK;\n  if( p ){\n    BtShared *pBt = p->pBt;\n    sqlite3BtreeEnter(p);\n    if( pBt->inTransaction!=TRANS_NONE ){\n      rc = SQLITE_LOCKED;\n    }else{\n      rc = sqlite3PagerCheckpoint(pBt->pPager, p->db, eMode, pnLog, pnCkpt);\n    }\n    sqlite3BtreeLeave(p);\n  }\n  return rc;\n}\n\n#endif\n\n/*\n** Return non-zero if a read (or write) transaction is active.\n*/\nSQLITE_PRIVATE int sqlite3BtreeIsInReadTrans(Btree *p){\n  assert( p );\n  assert( sqlite3_mutex_held(p->db->mutex) );\n  return p->inTrans!=TRANS_NONE;\n}\n\nSQLITE_PRIVATE int sqlite3BtreeIsInBackup(Btree *p){\n  assert( p );\n  assert( sqlite3_mutex_held(p->db->mutex) );\n  return p->nBackup!=0;\n}\n\n/*\n** This function returns a pointer to a blob of memory associated with\n** a single shared-btree. The memory is used by client code for its own\n** purposes (for example, to store a high-level schema associated with \n** the shared-btree). The btree layer manages reference counting issues.\n**\n** The first time this is called on a shared-btree, nBytes bytes of memory\n** are allocated, zeroed, and returned to the caller. For each subsequent \n** call the nBytes parameter is ignored and a pointer to the same blob\n** of memory returned. \n**\n** If the nBytes parameter is 0 and the blob of memory has not yet been\n** allocated, a null pointer is returned. If the blob has already been\n** allocated, it is returned as normal.\n**\n** Just before the shared-btree is closed, the function passed as the \n** xFree argument when the memory allocation was made is invoked on the \n** blob of allocated memory. The xFree function should not call sqlite3_free()\n** on the memory, the btree layer does that.\n*/\nSQLITE_PRIVATE void *sqlite3BtreeSchema(Btree *p, int nBytes, void(*xFree)(void *)){\n  BtShared *pBt = p->pBt;\n  sqlite3BtreeEnter(p);\n  if( !pBt->pSchema && nBytes ){\n    pBt->pSchema = sqlite3DbMallocZero(0, nBytes);\n    pBt->xFreeSchema = xFree;\n  }\n  sqlite3BtreeLeave(p);\n  return pBt->pSchema;\n}\n\n/*\n** Return SQLITE_LOCKED_SHAREDCACHE if another user of the same shared \n** btree as the argument handle holds an exclusive lock on the \n** sqlite_master table. Otherwise SQLITE_OK.\n*/\nSQLITE_PRIVATE int sqlite3BtreeSchemaLocked(Btree *p){\n  int rc;\n  assert( sqlite3_mutex_held(p->db->mutex) );\n  sqlite3BtreeEnter(p);\n  rc = querySharedCacheTableLock(p, MASTER_ROOT, READ_LOCK);\n  assert( rc==SQLITE_OK || rc==SQLITE_LOCKED_SHAREDCACHE );\n  sqlite3BtreeLeave(p);\n  return rc;\n}\n\n\n#ifndef SQLITE_OMIT_SHARED_CACHE\n/*\n** Obtain a lock on the table whose root page is iTab.  The\n** lock is a write lock if isWritelock is true or a read lock\n** if it is false.\n*/\nSQLITE_PRIVATE int sqlite3BtreeLockTable(Btree *p, int iTab, u8 isWriteLock){\n  int rc = SQLITE_OK;\n  assert( p->inTrans!=TRANS_NONE );\n  if( p->sharable ){\n    u8 lockType = READ_LOCK + isWriteLock;\n    assert( READ_LOCK+1==WRITE_LOCK );\n    assert( isWriteLock==0 || isWriteLock==1 );\n\n    sqlite3BtreeEnter(p);\n    rc = querySharedCacheTableLock(p, iTab, lockType);\n    if( rc==SQLITE_OK ){\n      rc = setSharedCacheTableLock(p, iTab, lockType);\n    }\n    sqlite3BtreeLeave(p);\n  }\n  return rc;\n}\n#endif\n\n#ifndef SQLITE_OMIT_INCRBLOB\n/*\n** Argument pCsr must be a cursor opened for writing on an \n** INTKEY table currently pointing at a valid table entry. \n** This function modifies the data stored as part of that entry.\n**\n** Only the data content may only be modified, it is not possible to \n** change the length of the data stored. If this function is called with\n** parameters that attempt to write past the end of the existing data,\n** no modifications are made and SQLITE_CORRUPT is returned.\n*/\nSQLITE_PRIVATE int sqlite3BtreePutData(BtCursor *pCsr, u32 offset, u32 amt, void *z){\n  int rc;\n  assert( cursorOwnsBtShared(pCsr) );\n  assert( sqlite3_mutex_held(pCsr->pBtree->db->mutex) );\n  assert( pCsr->curFlags & BTCF_Incrblob );\n\n  rc = restoreCursorPosition(pCsr);\n  if( rc!=SQLITE_OK ){\n    return rc;\n  }\n  assert( pCsr->eState!=CURSOR_REQUIRESEEK );\n  if( pCsr->eState!=CURSOR_VALID ){\n    return SQLITE_ABORT;\n  }\n\n  /* Save the positions of all other cursors open on this table. This is\n  ** required in case any of them are holding references to an xFetch\n  ** version of the b-tree page modified by the accessPayload call below.\n  **\n  ** Note that pCsr must be open on a INTKEY table and saveCursorPosition()\n  ** and hence saveAllCursors() cannot fail on a BTREE_INTKEY table, hence\n  ** saveAllCursors can only return SQLITE_OK.\n  */\n  VVA_ONLY(rc =) saveAllCursors(pCsr->pBt, pCsr->pgnoRoot, pCsr);\n  assert( rc==SQLITE_OK );\n\n  /* Check some assumptions: \n  **   (a) the cursor is open for writing,\n  **   (b) there is a read/write transaction open,\n  **   (c) the connection holds a write-lock on the table (if required),\n  **   (d) there are no conflicting read-locks, and\n  **   (e) the cursor points at a valid row of an intKey table.\n  */\n  if( (pCsr->curFlags & BTCF_WriteFlag)==0 ){\n    return SQLITE_READONLY;\n  }\n  assert( (pCsr->pBt->btsFlags & BTS_READ_ONLY)==0\n              && pCsr->pBt->inTransaction==TRANS_WRITE );\n  assert( hasSharedCacheTableLock(pCsr->pBtree, pCsr->pgnoRoot, 0, 2) );\n  assert( !hasReadConflicts(pCsr->pBtree, pCsr->pgnoRoot) );\n  assert( pCsr->pPage->intKey );\n\n  return accessPayload(pCsr, offset, amt, (unsigned char *)z, 1);\n}\n\n/* \n** Mark this cursor as an incremental blob cursor.\n*/\nSQLITE_PRIVATE void sqlite3BtreeIncrblobCursor(BtCursor *pCur){\n  pCur->curFlags |= BTCF_Incrblob;\n  pCur->pBtree->hasIncrblobCur = 1;\n}\n#endif\n\n/*\n** Set both the \"read version\" (single byte at byte offset 18) and \n** \"write version\" (single byte at byte offset 19) fields in the database\n** header to iVersion.\n*/\nSQLITE_PRIVATE int sqlite3BtreeSetVersion(Btree *pBtree, int iVersion){\n  BtShared *pBt = pBtree->pBt;\n  int rc;                         /* Return code */\n \n  assert( iVersion==1 || iVersion==2 );\n\n  /* If setting the version fields to 1, do not automatically open the\n  ** WAL connection, even if the version fields are currently set to 2.\n  */\n  pBt->btsFlags &= ~BTS_NO_WAL;\n  if( iVersion==1 ) pBt->btsFlags |= BTS_NO_WAL;\n\n  rc = sqlite3BtreeBeginTrans(pBtree, 0, 0);\n  if( rc==SQLITE_OK ){\n    u8 *aData = pBt->pPage1->aData;\n    if( aData[18]!=(u8)iVersion || aData[19]!=(u8)iVersion ){\n      rc = sqlite3BtreeBeginTrans(pBtree, 2, 0);\n      if( rc==SQLITE_OK ){\n        rc = sqlite3PagerWrite(pBt->pPage1->pDbPage);\n        if( rc==SQLITE_OK ){\n          aData[18] = (u8)iVersion;\n          aData[19] = (u8)iVersion;\n        }\n      }\n    }\n  }\n\n  pBt->btsFlags &= ~BTS_NO_WAL;\n  return rc;\n}\n\n/*\n** Return true if the cursor has a hint specified.  This routine is\n** only used from within assert() statements\n*/\nSQLITE_PRIVATE int sqlite3BtreeCursorHasHint(BtCursor *pCsr, unsigned int mask){\n  return (pCsr->hints & mask)!=0;\n}\n\n/*\n** Return true if the given Btree is read-only.\n*/\nSQLITE_PRIVATE int sqlite3BtreeIsReadonly(Btree *p){\n  return (p->pBt->btsFlags & BTS_READ_ONLY)!=0;\n}\n\n/*\n** Return the size of the header added to each page by this module.\n*/\nSQLITE_PRIVATE int sqlite3HeaderSizeBtree(void){ return ROUND8(sizeof(MemPage)); }\n\n#if !defined(SQLITE_OMIT_SHARED_CACHE)\n/*\n** Return true if the Btree passed as the only argument is sharable.\n*/\nSQLITE_PRIVATE int sqlite3BtreeSharable(Btree *p){\n  return p->sharable;\n}\n\n/*\n** Return the number of connections to the BtShared object accessed by\n** the Btree handle passed as the only argument. For private caches \n** this is always 1. For shared caches it may be 1 or greater.\n*/\nSQLITE_PRIVATE int sqlite3BtreeConnectionCount(Btree *p){\n  testcase( p->sharable );\n  return p->pBt->nRef;\n}\n#endif\n\n/************** End of btree.c ***********************************************/\n/************** Begin file backup.c ******************************************/\n/*\n** 2009 January 28\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This file contains the implementation of the sqlite3_backup_XXX() \n** API functions and the related features.\n*/\n/* #include \"sqliteInt.h\" */\n/* #include \"btreeInt.h\" */\n\n/*\n** Structure allocated for each backup operation.\n*/\nstruct sqlite3_backup {\n  sqlite3* pDestDb;        /* Destination database handle */\n  Btree *pDest;            /* Destination b-tree file */\n  u32 iDestSchema;         /* Original schema cookie in destination */\n  int bDestLocked;         /* True once a write-transaction is open on pDest */\n\n  Pgno iNext;              /* Page number of the next source page to copy */\n  sqlite3* pSrcDb;         /* Source database handle */\n  Btree *pSrc;             /* Source b-tree file */\n\n  int rc;                  /* Backup process error code */\n\n  /* These two variables are set by every call to backup_step(). They are\n  ** read by calls to backup_remaining() and backup_pagecount().\n  */\n  Pgno nRemaining;         /* Number of pages left to copy */\n  Pgno nPagecount;         /* Total number of pages to copy */\n\n  int isAttached;          /* True once backup has been registered with pager */\n  sqlite3_backup *pNext;   /* Next backup associated with source pager */\n};\n\n/*\n** THREAD SAFETY NOTES:\n**\n**   Once it has been created using backup_init(), a single sqlite3_backup\n**   structure may be accessed via two groups of thread-safe entry points:\n**\n**     * Via the sqlite3_backup_XXX() API function backup_step() and \n**       backup_finish(). Both these functions obtain the source database\n**       handle mutex and the mutex associated with the source BtShared \n**       structure, in that order.\n**\n**     * Via the BackupUpdate() and BackupRestart() functions, which are\n**       invoked by the pager layer to report various state changes in\n**       the page cache associated with the source database. The mutex\n**       associated with the source database BtShared structure will always \n**       be held when either of these functions are invoked.\n**\n**   The other sqlite3_backup_XXX() API functions, backup_remaining() and\n**   backup_pagecount() are not thread-safe functions. If they are called\n**   while some other thread is calling backup_step() or backup_finish(),\n**   the values returned may be invalid. There is no way for a call to\n**   BackupUpdate() or BackupRestart() to interfere with backup_remaining()\n**   or backup_pagecount().\n**\n**   Depending on the SQLite configuration, the database handles and/or\n**   the Btree objects may have their own mutexes that require locking.\n**   Non-sharable Btrees (in-memory databases for example), do not have\n**   associated mutexes.\n*/\n\n/*\n** Return a pointer corresponding to database zDb (i.e. \"main\", \"temp\")\n** in connection handle pDb. If such a database cannot be found, return\n** a NULL pointer and write an error message to pErrorDb.\n**\n** If the \"temp\" database is requested, it may need to be opened by this \n** function. If an error occurs while doing so, return 0 and write an \n** error message to pErrorDb.\n*/\nstatic Btree *findBtree(sqlite3 *pErrorDb, sqlite3 *pDb, const char *zDb){\n  int i = sqlite3FindDbName(pDb, zDb);\n\n  if( i==1 ){\n    Parse sParse;\n    int rc = 0;\n    memset(&sParse, 0, sizeof(sParse));\n    sParse.db = pDb;\n    if( sqlite3OpenTempDatabase(&sParse) ){\n      sqlite3ErrorWithMsg(pErrorDb, sParse.rc, \"%s\", sParse.zErrMsg);\n      rc = SQLITE_ERROR;\n    }\n    sqlite3DbFree(pErrorDb, sParse.zErrMsg);\n    sqlite3ParserReset(&sParse);\n    if( rc ){\n      return 0;\n    }\n  }\n\n  if( i<0 ){\n    sqlite3ErrorWithMsg(pErrorDb, SQLITE_ERROR, \"unknown database %s\", zDb);\n    return 0;\n  }\n\n  return pDb->aDb[i].pBt;\n}\n\n/*\n** Attempt to set the page size of the destination to match the page size\n** of the source.\n*/\nstatic int setDestPgsz(sqlite3_backup *p){\n  int rc;\n  rc = sqlite3BtreeSetPageSize(p->pDest,sqlite3BtreeGetPageSize(p->pSrc),-1,0);\n  return rc;\n}\n\n/*\n** Check that there is no open read-transaction on the b-tree passed as the\n** second argument. If there is not, return SQLITE_OK. Otherwise, if there\n** is an open read-transaction, return SQLITE_ERROR and leave an error \n** message in database handle db.\n*/\nstatic int checkReadTransaction(sqlite3 *db, Btree *p){\n  if( sqlite3BtreeIsInReadTrans(p) ){\n    sqlite3ErrorWithMsg(db, SQLITE_ERROR, \"destination database is in use\");\n    return SQLITE_ERROR;\n  }\n  return SQLITE_OK;\n}\n\n/*\n** Create an sqlite3_backup process to copy the contents of zSrcDb from\n** connection handle pSrcDb to zDestDb in pDestDb. If successful, return\n** a pointer to the new sqlite3_backup object.\n**\n** If an error occurs, NULL is returned and an error code and error message\n** stored in database handle pDestDb.\n*/\nSQLITE_API sqlite3_backup *sqlite3_backup_init(\n  sqlite3* pDestDb,                     /* Database to write to */\n  const char *zDestDb,                  /* Name of database within pDestDb */\n  sqlite3* pSrcDb,                      /* Database connection to read from */\n  const char *zSrcDb                    /* Name of database within pSrcDb */\n){\n  sqlite3_backup *p;                    /* Value to return */\n\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( !sqlite3SafetyCheckOk(pSrcDb)||!sqlite3SafetyCheckOk(pDestDb) ){\n    (void)SQLITE_MISUSE_BKPT;\n    return 0;\n  }\n#endif\n\n/* BEGIN SQLCIPHER */\n#ifdef SQLITE_HAS_CODEC\n  {\n    extern int sqlcipher_find_db_index(sqlite3*, const char*);\n    extern void sqlite3CodecGetKey(sqlite3*, int, void**, int*);\n    int srcNKey, destNKey;\n    void *zKey;\n\n    sqlite3CodecGetKey(pSrcDb, sqlcipher_find_db_index(pSrcDb, zSrcDb), &zKey, &srcNKey);\n    sqlite3CodecGetKey(pDestDb, sqlcipher_find_db_index(pDestDb, zDestDb), &zKey, &destNKey);\n    zKey = NULL;\n\n    if(srcNKey || destNKey) {\n      sqlite3ErrorWithMsg(pDestDb, SQLITE_ERROR, \"backup is not supported with encrypted databases\");\n      return NULL;\n    }\n  }\n#endif\n/* END SQLCIPHER */\n\n  /* Lock the source database handle. The destination database\n  ** handle is not locked in this routine, but it is locked in\n  ** sqlite3_backup_step(). The user is required to ensure that no\n  ** other thread accesses the destination handle for the duration\n  ** of the backup operation.  Any attempt to use the destination\n  ** database connection while a backup is in progress may cause\n  ** a malfunction or a deadlock.\n  */\n  sqlite3_mutex_enter(pSrcDb->mutex);\n  sqlite3_mutex_enter(pDestDb->mutex);\n\n  if( pSrcDb==pDestDb ){\n    sqlite3ErrorWithMsg(\n        pDestDb, SQLITE_ERROR, \"source and destination must be distinct\"\n    );\n    p = 0;\n  }else {\n    /* Allocate space for a new sqlite3_backup object...\n    ** EVIDENCE-OF: R-64852-21591 The sqlite3_backup object is created by a\n    ** call to sqlite3_backup_init() and is destroyed by a call to\n    ** sqlite3_backup_finish(). */\n    p = (sqlite3_backup *)sqlite3MallocZero(sizeof(sqlite3_backup));\n    if( !p ){\n      sqlite3Error(pDestDb, SQLITE_NOMEM_BKPT);\n    }\n  }\n\n  /* If the allocation succeeded, populate the new object. */\n  if( p ){\n    p->pSrc = findBtree(pDestDb, pSrcDb, zSrcDb);\n    p->pDest = findBtree(pDestDb, pDestDb, zDestDb);\n    p->pDestDb = pDestDb;\n    p->pSrcDb = pSrcDb;\n    p->iNext = 1;\n    p->isAttached = 0;\n\n    if( 0==p->pSrc || 0==p->pDest \n     || checkReadTransaction(pDestDb, p->pDest)!=SQLITE_OK \n     ){\n      /* One (or both) of the named databases did not exist or an OOM\n      ** error was hit. Or there is a transaction open on the destination\n      ** database. The error has already been written into the pDestDb \n      ** handle. All that is left to do here is free the sqlite3_backup \n      ** structure.  */\n      sqlite3_free(p);\n      p = 0;\n    }\n  }\n  if( p ){\n    p->pSrc->nBackup++;\n  }\n\n  sqlite3_mutex_leave(pDestDb->mutex);\n  sqlite3_mutex_leave(pSrcDb->mutex);\n  return p;\n}\n\n/*\n** Argument rc is an SQLite error code. Return true if this error is \n** considered fatal if encountered during a backup operation. All errors\n** are considered fatal except for SQLITE_BUSY and SQLITE_LOCKED.\n*/\nstatic int isFatalError(int rc){\n  return (rc!=SQLITE_OK && rc!=SQLITE_BUSY && ALWAYS(rc!=SQLITE_LOCKED));\n}\n\n/*\n** Parameter zSrcData points to a buffer containing the data for \n** page iSrcPg from the source database. Copy this data into the \n** destination database.\n*/\nstatic int backupOnePage(\n  sqlite3_backup *p,              /* Backup handle */\n  Pgno iSrcPg,                    /* Source database page to backup */\n  const u8 *zSrcData,             /* Source database page data */\n  int bUpdate                     /* True for an update, false otherwise */\n){\n  Pager * const pDestPager = sqlite3BtreePager(p->pDest);\n  const int nSrcPgsz = sqlite3BtreeGetPageSize(p->pSrc);\n  int nDestPgsz = sqlite3BtreeGetPageSize(p->pDest);\n  const int nCopy = MIN(nSrcPgsz, nDestPgsz);\n  const i64 iEnd = (i64)iSrcPg*(i64)nSrcPgsz;\n#ifdef SQLITE_HAS_CODEC\n  /* Use BtreeGetReserveNoMutex() for the source b-tree, as although it is\n  ** guaranteed that the shared-mutex is held by this thread, handle\n  ** p->pSrc may not actually be the owner.  */\n  int nSrcReserve = sqlite3BtreeGetReserveNoMutex(p->pSrc);\n  int nDestReserve = sqlite3BtreeGetOptimalReserve(p->pDest);\n#endif\n  int rc = SQLITE_OK;\n  i64 iOff;\n\n  assert( sqlite3BtreeGetReserveNoMutex(p->pSrc)>=0 );\n  assert( p->bDestLocked );\n  assert( !isFatalError(p->rc) );\n  assert( iSrcPg!=PENDING_BYTE_PAGE(p->pSrc->pBt) );\n  assert( zSrcData );\n\n  /* Catch the case where the destination is an in-memory database and the\n  ** page sizes of the source and destination differ. \n  */\n  if( nSrcPgsz!=nDestPgsz && sqlite3PagerIsMemdb(pDestPager) ){\n    rc = SQLITE_READONLY;\n  }\n\n#ifdef SQLITE_HAS_CODEC\n  /* Backup is not possible if the page size of the destination is changing\n  ** and a codec is in use.\n  */\n#if defined (SQLCIPHER_PREPROCESSED)\n    extern void *sqlite3PagerGetCodec(Pager *pPager);\n#endif /* SQLCIPHER_PREPROCESSED */\n  if( nSrcPgsz!=nDestPgsz && sqlite3PagerGetCodec(pDestPager)!=0 ){\n    rc = SQLITE_READONLY;\n  }\n\n  /* Backup is not possible if the number of bytes of reserve space differ\n  ** between source and destination.  If there is a difference, try to\n  ** fix the destination to agree with the source.  If that is not possible,\n  ** then the backup cannot proceed.\n  */\n  if( nSrcReserve!=nDestReserve ){\n    u32 newPgsz = nSrcPgsz;\n    rc = sqlite3PagerSetPagesize(pDestPager, &newPgsz, nSrcReserve);\n    if( rc==SQLITE_OK && newPgsz!=nSrcPgsz ) rc = SQLITE_READONLY;\n  }\n#endif\n\n  /* This loop runs once for each destination page spanned by the source \n  ** page. For each iteration, variable iOff is set to the byte offset\n  ** of the destination page.\n  */\n  for(iOff=iEnd-(i64)nSrcPgsz; rc==SQLITE_OK && iOff<iEnd; iOff+=nDestPgsz){\n    DbPage *pDestPg = 0;\n    Pgno iDest = (Pgno)(iOff/nDestPgsz)+1;\n    if( iDest==PENDING_BYTE_PAGE(p->pDest->pBt) ) continue;\n    if( SQLITE_OK==(rc = sqlite3PagerGet(pDestPager, iDest, &pDestPg, 0))\n     && SQLITE_OK==(rc = sqlite3PagerWrite(pDestPg))\n    ){\n      const u8 *zIn = &zSrcData[iOff%nSrcPgsz];\n      u8 *zDestData = sqlite3PagerGetData(pDestPg);\n      u8 *zOut = &zDestData[iOff%nDestPgsz];\n\n      /* Copy the data from the source page into the destination page.\n      ** Then clear the Btree layer MemPage.isInit flag. Both this module\n      ** and the pager code use this trick (clearing the first byte\n      ** of the page 'extra' space to invalidate the Btree layers\n      ** cached parse of the page). MemPage.isInit is marked \n      ** \"MUST BE FIRST\" for this purpose.\n      */\n      memcpy(zOut, zIn, nCopy);\n      ((u8 *)sqlite3PagerGetExtra(pDestPg))[0] = 0;\n      if( iOff==0 && bUpdate==0 ){\n        sqlite3Put4byte(&zOut[28], sqlite3BtreeLastPage(p->pSrc));\n      }\n    }\n    sqlite3PagerUnref(pDestPg);\n  }\n\n  return rc;\n}\n\n/*\n** If pFile is currently larger than iSize bytes, then truncate it to\n** exactly iSize bytes. If pFile is not larger than iSize bytes, then\n** this function is a no-op.\n**\n** Return SQLITE_OK if everything is successful, or an SQLite error \n** code if an error occurs.\n*/\nstatic int backupTruncateFile(sqlite3_file *pFile, i64 iSize){\n  i64 iCurrent;\n  int rc = sqlite3OsFileSize(pFile, &iCurrent);\n  if( rc==SQLITE_OK && iCurrent>iSize ){\n    rc = sqlite3OsTruncate(pFile, iSize);\n  }\n  return rc;\n}\n\n/*\n** Register this backup object with the associated source pager for\n** callbacks when pages are changed or the cache invalidated.\n*/\nstatic void attachBackupObject(sqlite3_backup *p){\n  sqlite3_backup **pp;\n  assert( sqlite3BtreeHoldsMutex(p->pSrc) );\n  pp = sqlite3PagerBackupPtr(sqlite3BtreePager(p->pSrc));\n  p->pNext = *pp;\n  *pp = p;\n  p->isAttached = 1;\n}\n\n/*\n** Copy nPage pages from the source b-tree to the destination.\n*/\nSQLITE_API int sqlite3_backup_step(sqlite3_backup *p, int nPage){\n  int rc;\n  int destMode;       /* Destination journal mode */\n  int pgszSrc = 0;    /* Source page size */\n  int pgszDest = 0;   /* Destination page size */\n\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( p==0 ) return SQLITE_MISUSE_BKPT;\n#endif\n  sqlite3_mutex_enter(p->pSrcDb->mutex);\n  sqlite3BtreeEnter(p->pSrc);\n  if( p->pDestDb ){\n    sqlite3_mutex_enter(p->pDestDb->mutex);\n  }\n\n  rc = p->rc;\n  if( !isFatalError(rc) ){\n    Pager * const pSrcPager = sqlite3BtreePager(p->pSrc);     /* Source pager */\n    Pager * const pDestPager = sqlite3BtreePager(p->pDest);   /* Dest pager */\n    int ii;                            /* Iterator variable */\n    int nSrcPage = -1;                 /* Size of source db in pages */\n    int bCloseTrans = 0;               /* True if src db requires unlocking */\n\n    /* If the source pager is currently in a write-transaction, return\n    ** SQLITE_BUSY immediately.\n    */\n    if( p->pDestDb && p->pSrc->pBt->inTransaction==TRANS_WRITE ){\n      rc = SQLITE_BUSY;\n    }else{\n      rc = SQLITE_OK;\n    }\n\n    /* If there is no open read-transaction on the source database, open\n    ** one now. If a transaction is opened here, then it will be closed\n    ** before this function exits.\n    */\n    if( rc==SQLITE_OK && 0==sqlite3BtreeIsInReadTrans(p->pSrc) ){\n      rc = sqlite3BtreeBeginTrans(p->pSrc, 0, 0);\n      bCloseTrans = 1;\n    }\n\n    /* If the destination database has not yet been locked (i.e. if this\n    ** is the first call to backup_step() for the current backup operation),\n    ** try to set its page size to the same as the source database. This\n    ** is especially important on ZipVFS systems, as in that case it is\n    ** not possible to create a database file that uses one page size by\n    ** writing to it with another.  */\n    if( p->bDestLocked==0 && rc==SQLITE_OK && setDestPgsz(p)==SQLITE_NOMEM ){\n      rc = SQLITE_NOMEM;\n    }\n\n    /* Lock the destination database, if it is not locked already. */\n    if( SQLITE_OK==rc && p->bDestLocked==0\n     && SQLITE_OK==(rc = sqlite3BtreeBeginTrans(p->pDest, 2,\n                                                (int*)&p->iDestSchema)) \n    ){\n      p->bDestLocked = 1;\n    }\n\n    /* Do not allow backup if the destination database is in WAL mode\n    ** and the page sizes are different between source and destination */\n    pgszSrc = sqlite3BtreeGetPageSize(p->pSrc);\n    pgszDest = sqlite3BtreeGetPageSize(p->pDest);\n    destMode = sqlite3PagerGetJournalMode(sqlite3BtreePager(p->pDest));\n    if( SQLITE_OK==rc && destMode==PAGER_JOURNALMODE_WAL && pgszSrc!=pgszDest ){\n      rc = SQLITE_READONLY;\n    }\n  \n    /* Now that there is a read-lock on the source database, query the\n    ** source pager for the number of pages in the database.\n    */\n    nSrcPage = (int)sqlite3BtreeLastPage(p->pSrc);\n    assert( nSrcPage>=0 );\n    for(ii=0; (nPage<0 || ii<nPage) && p->iNext<=(Pgno)nSrcPage && !rc; ii++){\n      const Pgno iSrcPg = p->iNext;                 /* Source page number */\n      if( iSrcPg!=PENDING_BYTE_PAGE(p->pSrc->pBt) ){\n        DbPage *pSrcPg;                             /* Source page object */\n        rc = sqlite3PagerGet(pSrcPager, iSrcPg, &pSrcPg,PAGER_GET_READONLY);\n        if( rc==SQLITE_OK ){\n          rc = backupOnePage(p, iSrcPg, sqlite3PagerGetData(pSrcPg), 0);\n          sqlite3PagerUnref(pSrcPg);\n        }\n      }\n      p->iNext++;\n    }\n    if( rc==SQLITE_OK ){\n      p->nPagecount = nSrcPage;\n      p->nRemaining = nSrcPage+1-p->iNext;\n      if( p->iNext>(Pgno)nSrcPage ){\n        rc = SQLITE_DONE;\n      }else if( !p->isAttached ){\n        attachBackupObject(p);\n      }\n    }\n  \n    /* Update the schema version field in the destination database. This\n    ** is to make sure that the schema-version really does change in\n    ** the case where the source and destination databases have the\n    ** same schema version.\n    */\n    if( rc==SQLITE_DONE ){\n      if( nSrcPage==0 ){\n        rc = sqlite3BtreeNewDb(p->pDest);\n        nSrcPage = 1;\n      }\n      if( rc==SQLITE_OK || rc==SQLITE_DONE ){\n        rc = sqlite3BtreeUpdateMeta(p->pDest,1,p->iDestSchema+1);\n      }\n      if( rc==SQLITE_OK ){\n        if( p->pDestDb ){\n          sqlite3ResetAllSchemasOfConnection(p->pDestDb);\n        }\n        if( destMode==PAGER_JOURNALMODE_WAL ){\n          rc = sqlite3BtreeSetVersion(p->pDest, 2);\n        }\n      }\n      if( rc==SQLITE_OK ){\n        int nDestTruncate;\n        /* Set nDestTruncate to the final number of pages in the destination\n        ** database. The complication here is that the destination page\n        ** size may be different to the source page size. \n        **\n        ** If the source page size is smaller than the destination page size, \n        ** round up. In this case the call to sqlite3OsTruncate() below will\n        ** fix the size of the file. However it is important to call\n        ** sqlite3PagerTruncateImage() here so that any pages in the \n        ** destination file that lie beyond the nDestTruncate page mark are\n        ** journalled by PagerCommitPhaseOne() before they are destroyed\n        ** by the file truncation.\n        */\n        assert( pgszSrc==sqlite3BtreeGetPageSize(p->pSrc) );\n        assert( pgszDest==sqlite3BtreeGetPageSize(p->pDest) );\n        if( pgszSrc<pgszDest ){\n          int ratio = pgszDest/pgszSrc;\n          nDestTruncate = (nSrcPage+ratio-1)/ratio;\n          if( nDestTruncate==(int)PENDING_BYTE_PAGE(p->pDest->pBt) ){\n            nDestTruncate--;\n          }\n        }else{\n          nDestTruncate = nSrcPage * (pgszSrc/pgszDest);\n        }\n        assert( nDestTruncate>0 );\n\n        if( pgszSrc<pgszDest ){\n          /* If the source page-size is smaller than the destination page-size,\n          ** two extra things may need to happen:\n          **\n          **   * The destination may need to be truncated, and\n          **\n          **   * Data stored on the pages immediately following the \n          **     pending-byte page in the source database may need to be\n          **     copied into the destination database.\n          */\n          const i64 iSize = (i64)pgszSrc * (i64)nSrcPage;\n          sqlite3_file * const pFile = sqlite3PagerFile(pDestPager);\n          Pgno iPg;\n          int nDstPage;\n          i64 iOff;\n          i64 iEnd;\n\n          assert( pFile );\n          assert( nDestTruncate==0 \n              || (i64)nDestTruncate*(i64)pgszDest >= iSize || (\n                nDestTruncate==(int)(PENDING_BYTE_PAGE(p->pDest->pBt)-1)\n             && iSize>=PENDING_BYTE && iSize<=PENDING_BYTE+pgszDest\n          ));\n\n          /* This block ensures that all data required to recreate the original\n          ** database has been stored in the journal for pDestPager and the\n          ** journal synced to disk. So at this point we may safely modify\n          ** the database file in any way, knowing that if a power failure\n          ** occurs, the original database will be reconstructed from the \n          ** journal file.  */\n          sqlite3PagerPagecount(pDestPager, &nDstPage);\n          for(iPg=nDestTruncate; rc==SQLITE_OK && iPg<=(Pgno)nDstPage; iPg++){\n            if( iPg!=PENDING_BYTE_PAGE(p->pDest->pBt) ){\n              DbPage *pPg;\n              rc = sqlite3PagerGet(pDestPager, iPg, &pPg, 0);\n              if( rc==SQLITE_OK ){\n                rc = sqlite3PagerWrite(pPg);\n                sqlite3PagerUnref(pPg);\n              }\n            }\n          }\n          if( rc==SQLITE_OK ){\n            rc = sqlite3PagerCommitPhaseOne(pDestPager, 0, 1);\n          }\n\n          /* Write the extra pages and truncate the database file as required */\n          iEnd = MIN(PENDING_BYTE + pgszDest, iSize);\n          for(\n            iOff=PENDING_BYTE+pgszSrc; \n            rc==SQLITE_OK && iOff<iEnd; \n            iOff+=pgszSrc\n          ){\n            PgHdr *pSrcPg = 0;\n            const Pgno iSrcPg = (Pgno)((iOff/pgszSrc)+1);\n            rc = sqlite3PagerGet(pSrcPager, iSrcPg, &pSrcPg, 0);\n            if( rc==SQLITE_OK ){\n              u8 *zData = sqlite3PagerGetData(pSrcPg);\n              rc = sqlite3OsWrite(pFile, zData, pgszSrc, iOff);\n            }\n            sqlite3PagerUnref(pSrcPg);\n          }\n          if( rc==SQLITE_OK ){\n            rc = backupTruncateFile(pFile, iSize);\n          }\n\n          /* Sync the database file to disk. */\n          if( rc==SQLITE_OK ){\n            rc = sqlite3PagerSync(pDestPager, 0);\n          }\n        }else{\n          sqlite3PagerTruncateImage(pDestPager, nDestTruncate);\n          rc = sqlite3PagerCommitPhaseOne(pDestPager, 0, 0);\n        }\n    \n        /* Finish committing the transaction to the destination database. */\n        if( SQLITE_OK==rc\n         && SQLITE_OK==(rc = sqlite3BtreeCommitPhaseTwo(p->pDest, 0))\n        ){\n          rc = SQLITE_DONE;\n        }\n      }\n    }\n  \n    /* If bCloseTrans is true, then this function opened a read transaction\n    ** on the source database. Close the read transaction here. There is\n    ** no need to check the return values of the btree methods here, as\n    ** \"committing\" a read-only transaction cannot fail.\n    */\n    if( bCloseTrans ){\n      TESTONLY( int rc2 );\n      TESTONLY( rc2  = ) sqlite3BtreeCommitPhaseOne(p->pSrc, 0);\n      TESTONLY( rc2 |= ) sqlite3BtreeCommitPhaseTwo(p->pSrc, 0);\n      assert( rc2==SQLITE_OK );\n    }\n  \n    if( rc==SQLITE_IOERR_NOMEM ){\n      rc = SQLITE_NOMEM_BKPT;\n    }\n    p->rc = rc;\n  }\n  if( p->pDestDb ){\n    sqlite3_mutex_leave(p->pDestDb->mutex);\n  }\n  sqlite3BtreeLeave(p->pSrc);\n  sqlite3_mutex_leave(p->pSrcDb->mutex);\n  return rc;\n}\n\n/*\n** Release all resources associated with an sqlite3_backup* handle.\n*/\nSQLITE_API int sqlite3_backup_finish(sqlite3_backup *p){\n  sqlite3_backup **pp;                 /* Ptr to head of pagers backup list */\n  sqlite3 *pSrcDb;                     /* Source database connection */\n  int rc;                              /* Value to return */\n\n  /* Enter the mutexes */\n  if( p==0 ) return SQLITE_OK;\n  pSrcDb = p->pSrcDb;\n  sqlite3_mutex_enter(pSrcDb->mutex);\n  sqlite3BtreeEnter(p->pSrc);\n  if( p->pDestDb ){\n    sqlite3_mutex_enter(p->pDestDb->mutex);\n  }\n\n  /* Detach this backup from the source pager. */\n  if( p->pDestDb ){\n    p->pSrc->nBackup--;\n  }\n  if( p->isAttached ){\n    pp = sqlite3PagerBackupPtr(sqlite3BtreePager(p->pSrc));\n    while( *pp!=p ){\n      pp = &(*pp)->pNext;\n    }\n    *pp = p->pNext;\n  }\n\n  /* If a transaction is still open on the Btree, roll it back. */\n  sqlite3BtreeRollback(p->pDest, SQLITE_OK, 0);\n\n  /* Set the error code of the destination database handle. */\n  rc = (p->rc==SQLITE_DONE) ? SQLITE_OK : p->rc;\n  if( p->pDestDb ){\n    sqlite3Error(p->pDestDb, rc);\n\n    /* Exit the mutexes and free the backup context structure. */\n    sqlite3LeaveMutexAndCloseZombie(p->pDestDb);\n  }\n  sqlite3BtreeLeave(p->pSrc);\n  if( p->pDestDb ){\n    /* EVIDENCE-OF: R-64852-21591 The sqlite3_backup object is created by a\n    ** call to sqlite3_backup_init() and is destroyed by a call to\n    ** sqlite3_backup_finish(). */\n    sqlite3_free(p);\n  }\n  sqlite3LeaveMutexAndCloseZombie(pSrcDb);\n  return rc;\n}\n\n/*\n** Return the number of pages still to be backed up as of the most recent\n** call to sqlite3_backup_step().\n*/\nSQLITE_API int sqlite3_backup_remaining(sqlite3_backup *p){\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( p==0 ){\n    (void)SQLITE_MISUSE_BKPT;\n    return 0;\n  }\n#endif\n  return p->nRemaining;\n}\n\n/*\n** Return the total number of pages in the source database as of the most \n** recent call to sqlite3_backup_step().\n*/\nSQLITE_API int sqlite3_backup_pagecount(sqlite3_backup *p){\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( p==0 ){\n    (void)SQLITE_MISUSE_BKPT;\n    return 0;\n  }\n#endif\n  return p->nPagecount;\n}\n\n/*\n** This function is called after the contents of page iPage of the\n** source database have been modified. If page iPage has already been \n** copied into the destination database, then the data written to the\n** destination is now invalidated. The destination copy of iPage needs\n** to be updated with the new data before the backup operation is\n** complete.\n**\n** It is assumed that the mutex associated with the BtShared object\n** corresponding to the source database is held when this function is\n** called.\n*/\nstatic SQLITE_NOINLINE void backupUpdate(\n  sqlite3_backup *p,\n  Pgno iPage,\n  const u8 *aData\n){\n  assert( p!=0 );\n  do{\n    assert( sqlite3_mutex_held(p->pSrc->pBt->mutex) );\n    if( !isFatalError(p->rc) && iPage<p->iNext ){\n      /* The backup process p has already copied page iPage. But now it\n      ** has been modified by a transaction on the source pager. Copy\n      ** the new data into the backup.\n      */\n      int rc;\n      assert( p->pDestDb );\n      sqlite3_mutex_enter(p->pDestDb->mutex);\n      rc = backupOnePage(p, iPage, aData, 1);\n      sqlite3_mutex_leave(p->pDestDb->mutex);\n      assert( rc!=SQLITE_BUSY && rc!=SQLITE_LOCKED );\n      if( rc!=SQLITE_OK ){\n        p->rc = rc;\n      }\n    }\n  }while( (p = p->pNext)!=0 );\n}\nSQLITE_PRIVATE void sqlite3BackupUpdate(sqlite3_backup *pBackup, Pgno iPage, const u8 *aData){\n  if( pBackup ) backupUpdate(pBackup, iPage, aData);\n}\n\n/*\n** Restart the backup process. This is called when the pager layer\n** detects that the database has been modified by an external database\n** connection. In this case there is no way of knowing which of the\n** pages that have been copied into the destination database are still \n** valid and which are not, so the entire process needs to be restarted.\n**\n** It is assumed that the mutex associated with the BtShared object\n** corresponding to the source database is held when this function is\n** called.\n*/\nSQLITE_PRIVATE void sqlite3BackupRestart(sqlite3_backup *pBackup){\n  sqlite3_backup *p;                   /* Iterator variable */\n  for(p=pBackup; p; p=p->pNext){\n    assert( sqlite3_mutex_held(p->pSrc->pBt->mutex) );\n    p->iNext = 1;\n  }\n}\n\n#ifndef SQLITE_OMIT_VACUUM\n/*\n** Copy the complete content of pBtFrom into pBtTo.  A transaction\n** must be active for both files.\n**\n** The size of file pTo may be reduced by this operation. If anything \n** goes wrong, the transaction on pTo is rolled back. If successful, the \n** transaction is committed before returning.\n*/\nSQLITE_PRIVATE int sqlite3BtreeCopyFile(Btree *pTo, Btree *pFrom){\n  int rc;\n  sqlite3_file *pFd;              /* File descriptor for database pTo */\n  sqlite3_backup b;\n  sqlite3BtreeEnter(pTo);\n  sqlite3BtreeEnter(pFrom);\n\n  assert( sqlite3BtreeIsInTrans(pTo) );\n  pFd = sqlite3PagerFile(sqlite3BtreePager(pTo));\n  if( pFd->pMethods ){\n    i64 nByte = sqlite3BtreeGetPageSize(pFrom)*(i64)sqlite3BtreeLastPage(pFrom);\n    rc = sqlite3OsFileControl(pFd, SQLITE_FCNTL_OVERWRITE, &nByte);\n    if( rc==SQLITE_NOTFOUND ) rc = SQLITE_OK;\n    if( rc ) goto copy_finished;\n  }\n\n  /* Set up an sqlite3_backup object. sqlite3_backup.pDestDb must be set\n  ** to 0. This is used by the implementations of sqlite3_backup_step()\n  ** and sqlite3_backup_finish() to detect that they are being called\n  ** from this function, not directly by the user.\n  */\n  memset(&b, 0, sizeof(b));\n  b.pSrcDb = pFrom->db;\n  b.pSrc = pFrom;\n  b.pDest = pTo;\n  b.iNext = 1;\n\n#ifdef SQLITE_HAS_CODEC\n  sqlite3PagerAlignReserve(sqlite3BtreePager(pTo), sqlite3BtreePager(pFrom));\n#endif\n\n  /* 0x7FFFFFFF is the hard limit for the number of pages in a database\n  ** file. By passing this as the number of pages to copy to\n  ** sqlite3_backup_step(), we can guarantee that the copy finishes \n  ** within a single call (unless an error occurs). The assert() statement\n  ** checks this assumption - (p->rc) should be set to either SQLITE_DONE \n  ** or an error code.  */\n  sqlite3_backup_step(&b, 0x7FFFFFFF);\n  assert( b.rc!=SQLITE_OK );\n\n  rc = sqlite3_backup_finish(&b);\n  if( rc==SQLITE_OK ){\n    pTo->pBt->btsFlags &= ~BTS_PAGESIZE_FIXED;\n  }else{\n    sqlite3PagerClearCache(sqlite3BtreePager(b.pDest));\n  }\n\n  assert( sqlite3BtreeIsInTrans(pTo)==0 );\ncopy_finished:\n  sqlite3BtreeLeave(pFrom);\n  sqlite3BtreeLeave(pTo);\n  return rc;\n}\n#endif /* SQLITE_OMIT_VACUUM */\n\n/************** End of backup.c **********************************************/\n/************** Begin file vdbemem.c *****************************************/\n/*\n** 2004 May 26\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n**\n** This file contains code use to manipulate \"Mem\" structure.  A \"Mem\"\n** stores a single value in the VDBE.  Mem is an opaque structure visible\n** only within the VDBE.  Interface routines refer to a Mem using the\n** name sqlite_value\n*/\n/* #include \"sqliteInt.h\" */\n/* #include \"vdbeInt.h\" */\n\n#ifdef SQLITE_DEBUG\n/*\n** Check invariants on a Mem object.\n**\n** This routine is intended for use inside of assert() statements, like\n** this:    assert( sqlite3VdbeCheckMemInvariants(pMem) );\n*/\nSQLITE_PRIVATE int sqlite3VdbeCheckMemInvariants(Mem *p){\n  /* If MEM_Dyn is set then Mem.xDel!=0.  \n  ** Mem.xDel might not be initialized if MEM_Dyn is clear.\n  */\n  assert( (p->flags & MEM_Dyn)==0 || p->xDel!=0 );\n\n  /* MEM_Dyn may only be set if Mem.szMalloc==0.  In this way we\n  ** ensure that if Mem.szMalloc>0 then it is safe to do\n  ** Mem.z = Mem.zMalloc without having to check Mem.flags&MEM_Dyn.\n  ** That saves a few cycles in inner loops. */\n  assert( (p->flags & MEM_Dyn)==0 || p->szMalloc==0 );\n\n  /* Cannot be both MEM_Int and MEM_Real at the same time */\n  assert( (p->flags & (MEM_Int|MEM_Real))!=(MEM_Int|MEM_Real) );\n\n  if( p->flags & MEM_Null ){\n    /* Cannot be both MEM_Null and some other type */\n    assert( (p->flags & (MEM_Int|MEM_Real|MEM_Str|MEM_Blob|MEM_Agg))==0 );\n\n    /* If MEM_Null is set, then either the value is a pure NULL (the usual\n    ** case) or it is a pointer set using sqlite3_bind_pointer() or\n    ** sqlite3_result_pointer().  If a pointer, then MEM_Term must also be\n    ** set.\n    */\n    if( (p->flags & (MEM_Term|MEM_Subtype))==(MEM_Term|MEM_Subtype) ){\n      /* This is a pointer type.  There may be a flag to indicate what to\n      ** do with the pointer. */\n      assert( ((p->flags&MEM_Dyn)!=0 ? 1 : 0) +\n              ((p->flags&MEM_Ephem)!=0 ? 1 : 0) +\n              ((p->flags&MEM_Static)!=0 ? 1 : 0) <= 1 );\n\n      /* No other bits set */\n      assert( (p->flags & ~(MEM_Null|MEM_Term|MEM_Subtype\n                           |MEM_Dyn|MEM_Ephem|MEM_Static))==0 );\n    }else{\n      /* A pure NULL might have other flags, such as MEM_Static, MEM_Dyn,\n      ** MEM_Ephem, MEM_Cleared, or MEM_Subtype */\n    }\n  }else{\n    /* The MEM_Cleared bit is only allowed on NULLs */\n    assert( (p->flags & MEM_Cleared)==0 );\n  }\n\n  /* The szMalloc field holds the correct memory allocation size */\n  assert( p->szMalloc==0\n       || p->szMalloc==sqlite3DbMallocSize(p->db,p->zMalloc) );\n\n  /* If p holds a string or blob, the Mem.z must point to exactly\n  ** one of the following:\n  **\n  **   (1) Memory in Mem.zMalloc and managed by the Mem object\n  **   (2) Memory to be freed using Mem.xDel\n  **   (3) An ephemeral string or blob\n  **   (4) A static string or blob\n  */\n  if( (p->flags & (MEM_Str|MEM_Blob)) && p->n>0 ){\n    assert( \n      ((p->szMalloc>0 && p->z==p->zMalloc)? 1 : 0) +\n      ((p->flags&MEM_Dyn)!=0 ? 1 : 0) +\n      ((p->flags&MEM_Ephem)!=0 ? 1 : 0) +\n      ((p->flags&MEM_Static)!=0 ? 1 : 0) == 1\n    );\n  }\n  return 1;\n}\n#endif\n\n#ifdef SQLITE_DEBUG\n/*\n** Check that string value of pMem agrees with its integer or real value.\n**\n** A single int or real value always converts to the same strings.  But\n** many different strings can be converted into the same int or real.\n** If a table contains a numeric value and an index is based on the\n** corresponding string value, then it is important that the string be\n** derived from the numeric value, not the other way around, to ensure\n** that the index and table are consistent.  See ticket\n** https://www.sqlite.org/src/info/343634942dd54ab (2018-01-31) for\n** an example.\n**\n** This routine looks at pMem to verify that if it has both a numeric\n** representation and a string representation then the string rep has\n** been derived from the numeric and not the other way around.  It returns\n** true if everything is ok and false if there is a problem.\n**\n** This routine is for use inside of assert() statements only.\n*/\nSQLITE_PRIVATE int sqlite3VdbeMemConsistentDualRep(Mem *p){\n  char zBuf[100];\n  char *z;\n  int i, j, incr;\n  if( (p->flags & MEM_Str)==0 ) return 1;\n  if( (p->flags & (MEM_Int|MEM_Real))==0 ) return 1;\n  if( p->flags & MEM_Int ){\n    sqlite3_snprintf(sizeof(zBuf),zBuf,\"%lld\",p->u.i);\n  }else{\n    sqlite3_snprintf(sizeof(zBuf),zBuf,\"%!.17g\",p->u.r);\n  }\n  z = p->z;\n  i = j = 0;\n  incr = 1;\n  if( p->enc!=SQLITE_UTF8 ){\n    incr = 2;\n    if( p->enc==SQLITE_UTF16BE ) z++;\n  }\n  while( zBuf[j] ){\n    if( zBuf[j++]!=z[i] ) return 0;\n    i += incr;\n  }\n  return 1;\n}\n#endif /* SQLITE_DEBUG */\n\n/*\n** If pMem is an object with a valid string representation, this routine\n** ensures the internal encoding for the string representation is\n** 'desiredEnc', one of SQLITE_UTF8, SQLITE_UTF16LE or SQLITE_UTF16BE.\n**\n** If pMem is not a string object, or the encoding of the string\n** representation is already stored using the requested encoding, then this\n** routine is a no-op.\n**\n** SQLITE_OK is returned if the conversion is successful (or not required).\n** SQLITE_NOMEM may be returned if a malloc() fails during conversion\n** between formats.\n*/\nSQLITE_PRIVATE int sqlite3VdbeChangeEncoding(Mem *pMem, int desiredEnc){\n#ifndef SQLITE_OMIT_UTF16\n  int rc;\n#endif\n  assert( !sqlite3VdbeMemIsRowSet(pMem) );\n  assert( desiredEnc==SQLITE_UTF8 || desiredEnc==SQLITE_UTF16LE\n           || desiredEnc==SQLITE_UTF16BE );\n  if( !(pMem->flags&MEM_Str) || pMem->enc==desiredEnc ){\n    return SQLITE_OK;\n  }\n  assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) );\n#ifdef SQLITE_OMIT_UTF16\n  return SQLITE_ERROR;\n#else\n\n  /* MemTranslate() may return SQLITE_OK or SQLITE_NOMEM. If NOMEM is returned,\n  ** then the encoding of the value may not have changed.\n  */\n  rc = sqlite3VdbeMemTranslate(pMem, (u8)desiredEnc);\n  assert(rc==SQLITE_OK    || rc==SQLITE_NOMEM);\n  assert(rc==SQLITE_OK    || pMem->enc!=desiredEnc);\n  assert(rc==SQLITE_NOMEM || pMem->enc==desiredEnc);\n  return rc;\n#endif\n}\n\n/*\n** Make sure pMem->z points to a writable allocation of at least \n** min(n,32) bytes.\n**\n** If the bPreserve argument is true, then copy of the content of\n** pMem->z into the new allocation.  pMem must be either a string or\n** blob if bPreserve is true.  If bPreserve is false, any prior content\n** in pMem->z is discarded.\n*/\nSQLITE_PRIVATE SQLITE_NOINLINE int sqlite3VdbeMemGrow(Mem *pMem, int n, int bPreserve){\n  assert( sqlite3VdbeCheckMemInvariants(pMem) );\n  assert( !sqlite3VdbeMemIsRowSet(pMem) );\n  testcase( pMem->db==0 );\n\n  /* If the bPreserve flag is set to true, then the memory cell must already\n  ** contain a valid string or blob value.  */\n  assert( bPreserve==0 || pMem->flags&(MEM_Blob|MEM_Str) );\n  testcase( bPreserve && pMem->z==0 );\n\n  assert( pMem->szMalloc==0\n       || pMem->szMalloc==sqlite3DbMallocSize(pMem->db, pMem->zMalloc) );\n  if( n<32 ) n = 32;\n  if( pMem->szMalloc>0 && bPreserve && pMem->z==pMem->zMalloc ){\n    pMem->z = pMem->zMalloc = sqlite3DbReallocOrFree(pMem->db, pMem->z, n);\n    bPreserve = 0;\n  }else{\n    if( pMem->szMalloc>0 ) sqlite3DbFreeNN(pMem->db, pMem->zMalloc);\n    pMem->zMalloc = sqlite3DbMallocRaw(pMem->db, n);\n  }\n  if( pMem->zMalloc==0 ){\n    sqlite3VdbeMemSetNull(pMem);\n    pMem->z = 0;\n    pMem->szMalloc = 0;\n    return SQLITE_NOMEM_BKPT;\n  }else{\n    pMem->szMalloc = sqlite3DbMallocSize(pMem->db, pMem->zMalloc);\n  }\n\n  if( bPreserve && pMem->z ){\n    assert( pMem->z!=pMem->zMalloc );\n    memcpy(pMem->zMalloc, pMem->z, pMem->n);\n  }\n  if( (pMem->flags&MEM_Dyn)!=0 ){\n    assert( pMem->xDel!=0 && pMem->xDel!=SQLITE_DYNAMIC );\n    pMem->xDel((void *)(pMem->z));\n  }\n\n  pMem->z = pMem->zMalloc;\n  pMem->flags &= ~(MEM_Dyn|MEM_Ephem|MEM_Static);\n  return SQLITE_OK;\n}\n\n/*\n** Change the pMem->zMalloc allocation to be at least szNew bytes.\n** If pMem->zMalloc already meets or exceeds the requested size, this\n** routine is a no-op.\n**\n** Any prior string or blob content in the pMem object may be discarded.\n** The pMem->xDel destructor is called, if it exists.  Though MEM_Str\n** and MEM_Blob values may be discarded, MEM_Int, MEM_Real, and MEM_Null\n** values are preserved.\n**\n** Return SQLITE_OK on success or an error code (probably SQLITE_NOMEM)\n** if unable to complete the resizing.\n*/\nSQLITE_PRIVATE int sqlite3VdbeMemClearAndResize(Mem *pMem, int szNew){\n  assert( CORRUPT_DB || szNew>0 );\n  assert( (pMem->flags & MEM_Dyn)==0 || pMem->szMalloc==0 );\n  if( pMem->szMalloc<szNew ){\n    return sqlite3VdbeMemGrow(pMem, szNew, 0);\n  }\n  assert( (pMem->flags & MEM_Dyn)==0 );\n  pMem->z = pMem->zMalloc;\n  pMem->flags &= (MEM_Null|MEM_Int|MEM_Real);\n  return SQLITE_OK;\n}\n\n/*\n** It is already known that pMem contains an unterminated string.\n** Add the zero terminator.\n*/\nstatic SQLITE_NOINLINE int vdbeMemAddTerminator(Mem *pMem){\n  if( sqlite3VdbeMemGrow(pMem, pMem->n+2, 1) ){\n    return SQLITE_NOMEM_BKPT;\n  }\n  pMem->z[pMem->n] = 0;\n  pMem->z[pMem->n+1] = 0;\n  pMem->flags |= MEM_Term;\n  return SQLITE_OK;\n}\n\n/*\n** Change pMem so that its MEM_Str or MEM_Blob value is stored in\n** MEM.zMalloc, where it can be safely written.\n**\n** Return SQLITE_OK on success or SQLITE_NOMEM if malloc fails.\n*/\nSQLITE_PRIVATE int sqlite3VdbeMemMakeWriteable(Mem *pMem){\n  assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) );\n  assert( !sqlite3VdbeMemIsRowSet(pMem) );\n  if( (pMem->flags & (MEM_Str|MEM_Blob))!=0 ){\n    if( ExpandBlob(pMem) ) return SQLITE_NOMEM;\n    if( pMem->szMalloc==0 || pMem->z!=pMem->zMalloc ){\n      int rc = vdbeMemAddTerminator(pMem);\n      if( rc ) return rc;\n    }\n  }\n  pMem->flags &= ~MEM_Ephem;\n#ifdef SQLITE_DEBUG\n  pMem->pScopyFrom = 0;\n#endif\n\n  return SQLITE_OK;\n}\n\n/*\n** If the given Mem* has a zero-filled tail, turn it into an ordinary\n** blob stored in dynamically allocated space.\n*/\n#ifndef SQLITE_OMIT_INCRBLOB\nSQLITE_PRIVATE int sqlite3VdbeMemExpandBlob(Mem *pMem){\n  int nByte;\n  assert( pMem->flags & MEM_Zero );\n  assert( pMem->flags&MEM_Blob );\n  assert( !sqlite3VdbeMemIsRowSet(pMem) );\n  assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) );\n\n  /* Set nByte to the number of bytes required to store the expanded blob. */\n  nByte = pMem->n + pMem->u.nZero;\n  if( nByte<=0 ){\n    nByte = 1;\n  }\n  if( sqlite3VdbeMemGrow(pMem, nByte, 1) ){\n    return SQLITE_NOMEM_BKPT;\n  }\n\n  memset(&pMem->z[pMem->n], 0, pMem->u.nZero);\n  pMem->n += pMem->u.nZero;\n  pMem->flags &= ~(MEM_Zero|MEM_Term);\n  return SQLITE_OK;\n}\n#endif\n\n/*\n** Make sure the given Mem is \\u0000 terminated.\n*/\nSQLITE_PRIVATE int sqlite3VdbeMemNulTerminate(Mem *pMem){\n  assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) );\n  testcase( (pMem->flags & (MEM_Term|MEM_Str))==(MEM_Term|MEM_Str) );\n  testcase( (pMem->flags & (MEM_Term|MEM_Str))==0 );\n  if( (pMem->flags & (MEM_Term|MEM_Str))!=MEM_Str ){\n    return SQLITE_OK;   /* Nothing to do */\n  }else{\n    return vdbeMemAddTerminator(pMem);\n  }\n}\n\n/*\n** Add MEM_Str to the set of representations for the given Mem.  Numbers\n** are converted using sqlite3_snprintf().  Converting a BLOB to a string\n** is a no-op.\n**\n** Existing representations MEM_Int and MEM_Real are invalidated if\n** bForce is true but are retained if bForce is false.\n**\n** A MEM_Null value will never be passed to this function. This function is\n** used for converting values to text for returning to the user (i.e. via\n** sqlite3_value_text()), or for ensuring that values to be used as btree\n** keys are strings. In the former case a NULL pointer is returned the\n** user and the latter is an internal programming error.\n*/\nSQLITE_PRIVATE int sqlite3VdbeMemStringify(Mem *pMem, u8 enc, u8 bForce){\n  int fg = pMem->flags;\n  const int nByte = 32;\n\n  assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) );\n  assert( !(fg&MEM_Zero) );\n  assert( !(fg&(MEM_Str|MEM_Blob)) );\n  assert( fg&(MEM_Int|MEM_Real) );\n  assert( !sqlite3VdbeMemIsRowSet(pMem) );\n  assert( EIGHT_BYTE_ALIGNMENT(pMem) );\n\n\n  if( sqlite3VdbeMemClearAndResize(pMem, nByte) ){\n    pMem->enc = 0;\n    return SQLITE_NOMEM_BKPT;\n  }\n\n  /* For a Real or Integer, use sqlite3_snprintf() to produce the UTF-8\n  ** string representation of the value. Then, if the required encoding\n  ** is UTF-16le or UTF-16be do a translation.\n  ** \n  ** FIX ME: It would be better if sqlite3_snprintf() could do UTF-16.\n  */\n  if( fg & MEM_Int ){\n    sqlite3_snprintf(nByte, pMem->z, \"%lld\", pMem->u.i);\n  }else{\n    assert( fg & MEM_Real );\n    sqlite3_snprintf(nByte, pMem->z, \"%!.17g\", pMem->u.r);\n  }\n  assert( pMem->z!=0 );\n  pMem->n = sqlite3Strlen30NN(pMem->z);\n  pMem->enc = SQLITE_UTF8;\n  pMem->flags |= MEM_Str|MEM_Term;\n  if( bForce ) pMem->flags &= ~(MEM_Int|MEM_Real);\n  sqlite3VdbeChangeEncoding(pMem, enc);\n  return SQLITE_OK;\n}\n\n/*\n** Memory cell pMem contains the context of an aggregate function.\n** This routine calls the finalize method for that function.  The\n** result of the aggregate is stored back into pMem.\n**\n** Return SQLITE_ERROR if the finalizer reports an error.  SQLITE_OK\n** otherwise.\n*/\nSQLITE_PRIVATE int sqlite3VdbeMemFinalize(Mem *pMem, FuncDef *pFunc){\n  sqlite3_context ctx;\n  Mem t;\n  assert( pFunc!=0 );\n  assert( pFunc->xFinalize!=0 );\n  assert( (pMem->flags & MEM_Null)!=0 || pFunc==pMem->u.pDef );\n  assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) );\n  memset(&ctx, 0, sizeof(ctx));\n  memset(&t, 0, sizeof(t));\n  t.flags = MEM_Null;\n  t.db = pMem->db;\n  ctx.pOut = &t;\n  ctx.pMem = pMem;\n  ctx.pFunc = pFunc;\n  pFunc->xFinalize(&ctx); /* IMP: R-24505-23230 */\n  assert( (pMem->flags & MEM_Dyn)==0 );\n  if( pMem->szMalloc>0 ) sqlite3DbFreeNN(pMem->db, pMem->zMalloc);\n  memcpy(pMem, &t, sizeof(t));\n  return ctx.isError;\n}\n\n/*\n** Memory cell pAccum contains the context of an aggregate function.\n** This routine calls the xValue method for that function and stores\n** the results in memory cell pMem.\n**\n** SQLITE_ERROR is returned if xValue() reports an error. SQLITE_OK \n** otherwise.\n*/\n#ifndef SQLITE_OMIT_WINDOWFUNC\nSQLITE_PRIVATE int sqlite3VdbeMemAggValue(Mem *pAccum, Mem *pOut, FuncDef *pFunc){\n  sqlite3_context ctx;\n  Mem t;\n  assert( pFunc!=0 );\n  assert( pFunc->xValue!=0 );\n  assert( (pAccum->flags & MEM_Null)!=0 || pFunc==pAccum->u.pDef );\n  assert( pAccum->db==0 || sqlite3_mutex_held(pAccum->db->mutex) );\n  memset(&ctx, 0, sizeof(ctx));\n  memset(&t, 0, sizeof(t));\n  t.flags = MEM_Null;\n  t.db = pAccum->db;\n  sqlite3VdbeMemSetNull(pOut);\n  ctx.pOut = pOut;\n  ctx.pMem = pAccum;\n  ctx.pFunc = pFunc;\n  pFunc->xValue(&ctx);\n  return ctx.isError;\n}\n#endif /* SQLITE_OMIT_WINDOWFUNC */\n\n/*\n** If the memory cell contains a value that must be freed by\n** invoking the external callback in Mem.xDel, then this routine\n** will free that value.  It also sets Mem.flags to MEM_Null.\n**\n** This is a helper routine for sqlite3VdbeMemSetNull() and\n** for sqlite3VdbeMemRelease().  Use those other routines as the\n** entry point for releasing Mem resources.\n*/\nstatic SQLITE_NOINLINE void vdbeMemClearExternAndSetNull(Mem *p){\n  assert( p->db==0 || sqlite3_mutex_held(p->db->mutex) );\n  assert( VdbeMemDynamic(p) );\n  if( p->flags&MEM_Agg ){\n    sqlite3VdbeMemFinalize(p, p->u.pDef);\n    assert( (p->flags & MEM_Agg)==0 );\n    testcase( p->flags & MEM_Dyn );\n  }\n  if( p->flags&MEM_Dyn ){\n    assert( p->xDel!=SQLITE_DYNAMIC && p->xDel!=0 );\n    p->xDel((void *)p->z);\n  }\n  p->flags = MEM_Null;\n}\n\n/*\n** Release memory held by the Mem p, both external memory cleared\n** by p->xDel and memory in p->zMalloc.\n**\n** This is a helper routine invoked by sqlite3VdbeMemRelease() in\n** the unusual case where there really is memory in p that needs\n** to be freed.\n*/\nstatic SQLITE_NOINLINE void vdbeMemClear(Mem *p){\n  if( VdbeMemDynamic(p) ){\n    vdbeMemClearExternAndSetNull(p);\n  }\n  if( p->szMalloc ){\n    sqlite3DbFreeNN(p->db, p->zMalloc);\n    p->szMalloc = 0;\n  }\n  p->z = 0;\n}\n\n/*\n** Release any memory resources held by the Mem.  Both the memory that is\n** free by Mem.xDel and the Mem.zMalloc allocation are freed.\n**\n** Use this routine prior to clean up prior to abandoning a Mem, or to\n** reset a Mem back to its minimum memory utilization.\n**\n** Use sqlite3VdbeMemSetNull() to release just the Mem.xDel space\n** prior to inserting new content into the Mem.\n*/\nSQLITE_PRIVATE void sqlite3VdbeMemRelease(Mem *p){\n  assert( sqlite3VdbeCheckMemInvariants(p) );\n  if( VdbeMemDynamic(p) || p->szMalloc ){\n    vdbeMemClear(p);\n  }\n}\n\n/*\n** Convert a 64-bit IEEE double into a 64-bit signed integer.\n** If the double is out of range of a 64-bit signed integer then\n** return the closest available 64-bit signed integer.\n*/\nstatic SQLITE_NOINLINE i64 doubleToInt64(double r){\n#ifdef SQLITE_OMIT_FLOATING_POINT\n  /* When floating-point is omitted, double and int64 are the same thing */\n  return r;\n#else\n  /*\n  ** Many compilers we encounter do not define constants for the\n  ** minimum and maximum 64-bit integers, or they define them\n  ** inconsistently.  And many do not understand the \"LL\" notation.\n  ** So we define our own static constants here using nothing\n  ** larger than a 32-bit integer constant.\n  */\n  static const i64 maxInt = LARGEST_INT64;\n  static const i64 minInt = SMALLEST_INT64;\n\n  if( r<=(double)minInt ){\n    return minInt;\n  }else if( r>=(double)maxInt ){\n    return maxInt;\n  }else{\n    return (i64)r;\n  }\n#endif\n}\n\n/*\n** Return some kind of integer value which is the best we can do\n** at representing the value that *pMem describes as an integer.\n** If pMem is an integer, then the value is exact.  If pMem is\n** a floating-point then the value returned is the integer part.\n** If pMem is a string or blob, then we make an attempt to convert\n** it into an integer and return that.  If pMem represents an\n** an SQL-NULL value, return 0.\n**\n** If pMem represents a string value, its encoding might be changed.\n*/\nstatic SQLITE_NOINLINE i64 memIntValue(Mem *pMem){\n  i64 value = 0;\n  sqlite3Atoi64(pMem->z, &value, pMem->n, pMem->enc);\n  return value;\n}\nSQLITE_PRIVATE i64 sqlite3VdbeIntValue(Mem *pMem){\n  int flags;\n  assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) );\n  assert( EIGHT_BYTE_ALIGNMENT(pMem) );\n  flags = pMem->flags;\n  if( flags & MEM_Int ){\n    return pMem->u.i;\n  }else if( flags & MEM_Real ){\n    return doubleToInt64(pMem->u.r);\n  }else if( flags & (MEM_Str|MEM_Blob) ){\n    assert( pMem->z || pMem->n==0 );\n    return memIntValue(pMem);\n  }else{\n    return 0;\n  }\n}\n\n/*\n** Return the best representation of pMem that we can get into a\n** double.  If pMem is already a double or an integer, return its\n** value.  If it is a string or blob, try to convert it to a double.\n** If it is a NULL, return 0.0.\n*/\nstatic SQLITE_NOINLINE double memRealValue(Mem *pMem){\n  /* (double)0 In case of SQLITE_OMIT_FLOATING_POINT... */\n  double val = (double)0;\n  sqlite3AtoF(pMem->z, &val, pMem->n, pMem->enc);\n  return val;\n}\nSQLITE_PRIVATE double sqlite3VdbeRealValue(Mem *pMem){\n  assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) );\n  assert( EIGHT_BYTE_ALIGNMENT(pMem) );\n  if( pMem->flags & MEM_Real ){\n    return pMem->u.r;\n  }else if( pMem->flags & MEM_Int ){\n    return (double)pMem->u.i;\n  }else if( pMem->flags & (MEM_Str|MEM_Blob) ){\n    return memRealValue(pMem);\n  }else{\n    /* (double)0 In case of SQLITE_OMIT_FLOATING_POINT... */\n    return (double)0;\n  }\n}\n\n/*\n** Return 1 if pMem represents true, and return 0 if pMem represents false.\n** Return the value ifNull if pMem is NULL.  \n*/\nSQLITE_PRIVATE int sqlite3VdbeBooleanValue(Mem *pMem, int ifNull){\n  if( pMem->flags & MEM_Int ) return pMem->u.i!=0;\n  if( pMem->flags & MEM_Null ) return ifNull;\n  return sqlite3VdbeRealValue(pMem)!=0.0;\n}\n\n/*\n** The MEM structure is already a MEM_Real.  Try to also make it a\n** MEM_Int if we can.\n*/\nSQLITE_PRIVATE void sqlite3VdbeIntegerAffinity(Mem *pMem){\n  i64 ix;\n  assert( pMem->flags & MEM_Real );\n  assert( !sqlite3VdbeMemIsRowSet(pMem) );\n  assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) );\n  assert( EIGHT_BYTE_ALIGNMENT(pMem) );\n\n  ix = doubleToInt64(pMem->u.r);\n\n  /* Only mark the value as an integer if\n  **\n  **    (1) the round-trip conversion real->int->real is a no-op, and\n  **    (2) The integer is neither the largest nor the smallest\n  **        possible integer (ticket #3922)\n  **\n  ** The second and third terms in the following conditional enforces\n  ** the second condition under the assumption that addition overflow causes\n  ** values to wrap around.\n  */\n  if( pMem->u.r==ix && ix>SMALLEST_INT64 && ix<LARGEST_INT64 ){\n    pMem->u.i = ix;\n    MemSetTypeFlag(pMem, MEM_Int);\n  }\n}\n\n/*\n** Convert pMem to type integer.  Invalidate any prior representations.\n*/\nSQLITE_PRIVATE int sqlite3VdbeMemIntegerify(Mem *pMem){\n  assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) );\n  assert( !sqlite3VdbeMemIsRowSet(pMem) );\n  assert( EIGHT_BYTE_ALIGNMENT(pMem) );\n\n  pMem->u.i = sqlite3VdbeIntValue(pMem);\n  MemSetTypeFlag(pMem, MEM_Int);\n  return SQLITE_OK;\n}\n\n/*\n** Convert pMem so that it is of type MEM_Real.\n** Invalidate any prior representations.\n*/\nSQLITE_PRIVATE int sqlite3VdbeMemRealify(Mem *pMem){\n  assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) );\n  assert( EIGHT_BYTE_ALIGNMENT(pMem) );\n\n  pMem->u.r = sqlite3VdbeRealValue(pMem);\n  MemSetTypeFlag(pMem, MEM_Real);\n  return SQLITE_OK;\n}\n\n/* Compare a floating point value to an integer.  Return true if the two\n** values are the same within the precision of the floating point value.\n**\n** For some versions of GCC on 32-bit machines, if you do the more obvious\n** comparison of \"r1==(double)i\" you sometimes get an answer of false even\n** though the r1 and (double)i values are bit-for-bit the same.\n*/\nstatic int sqlite3RealSameAsInt(double r1, sqlite3_int64 i){\n  double r2 = (double)i;\n  return memcmp(&r1, &r2, sizeof(r1))==0;\n}\n\n/*\n** Convert pMem so that it has types MEM_Real or MEM_Int or both.\n** Invalidate any prior representations.\n**\n** Every effort is made to force the conversion, even if the input\n** is a string that does not look completely like a number.  Convert\n** as much of the string as we can and ignore the rest.\n*/\nSQLITE_PRIVATE int sqlite3VdbeMemNumerify(Mem *pMem){\n  if( (pMem->flags & (MEM_Int|MEM_Real|MEM_Null))==0 ){\n    int rc;\n    assert( (pMem->flags & (MEM_Blob|MEM_Str))!=0 );\n    assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) );\n    rc = sqlite3Atoi64(pMem->z, &pMem->u.i, pMem->n, pMem->enc);\n    if( rc==0 ){\n      MemSetTypeFlag(pMem, MEM_Int);\n    }else{\n      i64 i = pMem->u.i;\n      sqlite3AtoF(pMem->z, &pMem->u.r, pMem->n, pMem->enc);\n      if( rc==1 && sqlite3RealSameAsInt(pMem->u.r, i) ){\n        pMem->u.i = i;\n        MemSetTypeFlag(pMem, MEM_Int);\n      }else{\n        MemSetTypeFlag(pMem, MEM_Real);\n      }\n    }\n  }\n  assert( (pMem->flags & (MEM_Int|MEM_Real|MEM_Null))!=0 );\n  pMem->flags &= ~(MEM_Str|MEM_Blob|MEM_Zero);\n  return SQLITE_OK;\n}\n\n/*\n** Cast the datatype of the value in pMem according to the affinity\n** \"aff\".  Casting is different from applying affinity in that a cast\n** is forced.  In other words, the value is converted into the desired\n** affinity even if that results in loss of data.  This routine is\n** used (for example) to implement the SQL \"cast()\" operator.\n*/\nSQLITE_PRIVATE void sqlite3VdbeMemCast(Mem *pMem, u8 aff, u8 encoding){\n  if( pMem->flags & MEM_Null ) return;\n  switch( aff ){\n    case SQLITE_AFF_BLOB: {   /* Really a cast to BLOB */\n      if( (pMem->flags & MEM_Blob)==0 ){\n        sqlite3ValueApplyAffinity(pMem, SQLITE_AFF_TEXT, encoding);\n        assert( pMem->flags & MEM_Str || pMem->db->mallocFailed );\n        if( pMem->flags & MEM_Str ) MemSetTypeFlag(pMem, MEM_Blob);\n      }else{\n        pMem->flags &= ~(MEM_TypeMask&~MEM_Blob);\n      }\n      break;\n    }\n    case SQLITE_AFF_NUMERIC: {\n      sqlite3VdbeMemNumerify(pMem);\n      break;\n    }\n    case SQLITE_AFF_INTEGER: {\n      sqlite3VdbeMemIntegerify(pMem);\n      break;\n    }\n    case SQLITE_AFF_REAL: {\n      sqlite3VdbeMemRealify(pMem);\n      break;\n    }\n    default: {\n      assert( aff==SQLITE_AFF_TEXT );\n      assert( MEM_Str==(MEM_Blob>>3) );\n      pMem->flags |= (pMem->flags&MEM_Blob)>>3;\n      sqlite3ValueApplyAffinity(pMem, SQLITE_AFF_TEXT, encoding);\n      assert( pMem->flags & MEM_Str || pMem->db->mallocFailed );\n      pMem->flags &= ~(MEM_Int|MEM_Real|MEM_Blob|MEM_Zero);\n      break;\n    }\n  }\n}\n\n/*\n** Initialize bulk memory to be a consistent Mem object.\n**\n** The minimum amount of initialization feasible is performed.\n*/\nSQLITE_PRIVATE void sqlite3VdbeMemInit(Mem *pMem, sqlite3 *db, u16 flags){\n  assert( (flags & ~MEM_TypeMask)==0 );\n  pMem->flags = flags;\n  pMem->db = db;\n  pMem->szMalloc = 0;\n}\n\n\n/*\n** Delete any previous value and set the value stored in *pMem to NULL.\n**\n** This routine calls the Mem.xDel destructor to dispose of values that\n** require the destructor.  But it preserves the Mem.zMalloc memory allocation.\n** To free all resources, use sqlite3VdbeMemRelease(), which both calls this\n** routine to invoke the destructor and deallocates Mem.zMalloc.\n**\n** Use this routine to reset the Mem prior to insert a new value.\n**\n** Use sqlite3VdbeMemRelease() to complete erase the Mem prior to abandoning it.\n*/\nSQLITE_PRIVATE void sqlite3VdbeMemSetNull(Mem *pMem){\n  if( VdbeMemDynamic(pMem) ){\n    vdbeMemClearExternAndSetNull(pMem);\n  }else{\n    pMem->flags = MEM_Null;\n  }\n}\nSQLITE_PRIVATE void sqlite3ValueSetNull(sqlite3_value *p){\n  sqlite3VdbeMemSetNull((Mem*)p); \n}\n\n/*\n** Delete any previous value and set the value to be a BLOB of length\n** n containing all zeros.\n*/\nSQLITE_PRIVATE void sqlite3VdbeMemSetZeroBlob(Mem *pMem, int n){\n  sqlite3VdbeMemRelease(pMem);\n  pMem->flags = MEM_Blob|MEM_Zero;\n  pMem->n = 0;\n  if( n<0 ) n = 0;\n  pMem->u.nZero = n;\n  pMem->enc = SQLITE_UTF8;\n  pMem->z = 0;\n}\n\n/*\n** The pMem is known to contain content that needs to be destroyed prior\n** to a value change.  So invoke the destructor, then set the value to\n** a 64-bit integer.\n*/\nstatic SQLITE_NOINLINE void vdbeReleaseAndSetInt64(Mem *pMem, i64 val){\n  sqlite3VdbeMemSetNull(pMem);\n  pMem->u.i = val;\n  pMem->flags = MEM_Int;\n}\n\n/*\n** Delete any previous value and set the value stored in *pMem to val,\n** manifest type INTEGER.\n*/\nSQLITE_PRIVATE void sqlite3VdbeMemSetInt64(Mem *pMem, i64 val){\n  if( VdbeMemDynamic(pMem) ){\n    vdbeReleaseAndSetInt64(pMem, val);\n  }else{\n    pMem->u.i = val;\n    pMem->flags = MEM_Int;\n  }\n}\n\n/* A no-op destructor */\nSQLITE_PRIVATE void sqlite3NoopDestructor(void *p){ UNUSED_PARAMETER(p); }\n\n/*\n** Set the value stored in *pMem should already be a NULL.\n** Also store a pointer to go with it.\n*/\nSQLITE_PRIVATE void sqlite3VdbeMemSetPointer(\n  Mem *pMem,\n  void *pPtr,\n  const char *zPType,\n  void (*xDestructor)(void*)\n){\n  assert( pMem->flags==MEM_Null );\n  pMem->u.zPType = zPType ? zPType : \"\";\n  pMem->z = pPtr;\n  pMem->flags = MEM_Null|MEM_Dyn|MEM_Subtype|MEM_Term;\n  pMem->eSubtype = 'p';\n  pMem->xDel = xDestructor ? xDestructor : sqlite3NoopDestructor;\n}\n\n#ifndef SQLITE_OMIT_FLOATING_POINT\n/*\n** Delete any previous value and set the value stored in *pMem to val,\n** manifest type REAL.\n*/\nSQLITE_PRIVATE void sqlite3VdbeMemSetDouble(Mem *pMem, double val){\n  sqlite3VdbeMemSetNull(pMem);\n  if( !sqlite3IsNaN(val) ){\n    pMem->u.r = val;\n    pMem->flags = MEM_Real;\n  }\n}\n#endif\n\n#ifdef SQLITE_DEBUG\n/*\n** Return true if the Mem holds a RowSet object.  This routine is intended\n** for use inside of assert() statements.\n*/\nSQLITE_PRIVATE int sqlite3VdbeMemIsRowSet(const Mem *pMem){\n  return (pMem->flags&(MEM_Blob|MEM_Dyn))==(MEM_Blob|MEM_Dyn)\n         && pMem->xDel==sqlite3RowSetDelete;\n}\n#endif\n\n/*\n** Delete any previous value and set the value of pMem to be an\n** empty boolean index.\n**\n** Return SQLITE_OK on success and SQLITE_NOMEM if a memory allocation\n** error occurs.\n*/\nSQLITE_PRIVATE int sqlite3VdbeMemSetRowSet(Mem *pMem){\n  sqlite3 *db = pMem->db;\n  RowSet *p;\n  assert( db!=0 );\n  assert( !sqlite3VdbeMemIsRowSet(pMem) );\n  sqlite3VdbeMemRelease(pMem);\n  p = sqlite3RowSetInit(db);\n  if( p==0 ) return SQLITE_NOMEM;\n  pMem->z = (char*)p;\n  pMem->flags = MEM_Blob|MEM_Dyn;\n  pMem->xDel = sqlite3RowSetDelete;\n  return SQLITE_OK;\n}\n\n/*\n** Return true if the Mem object contains a TEXT or BLOB that is\n** too large - whose size exceeds SQLITE_MAX_LENGTH.\n*/\nSQLITE_PRIVATE int sqlite3VdbeMemTooBig(Mem *p){\n  assert( p->db!=0 );\n  if( p->flags & (MEM_Str|MEM_Blob) ){\n    int n = p->n;\n    if( p->flags & MEM_Zero ){\n      n += p->u.nZero;\n    }\n    return n>p->db->aLimit[SQLITE_LIMIT_LENGTH];\n  }\n  return 0; \n}\n\n#ifdef SQLITE_DEBUG\n/*\n** This routine prepares a memory cell for modification by breaking\n** its link to a shallow copy and by marking any current shallow\n** copies of this cell as invalid.\n**\n** This is used for testing and debugging only - to make sure shallow\n** copies are not misused.\n*/\nSQLITE_PRIVATE void sqlite3VdbeMemAboutToChange(Vdbe *pVdbe, Mem *pMem){\n  int i;\n  Mem *pX;\n  for(i=0, pX=pVdbe->aMem; i<pVdbe->nMem; i++, pX++){\n    if( pX->pScopyFrom==pMem ){\n      /* If pX is marked as a shallow copy of pMem, then verify that\n      ** no significant changes have been made to pX since the OP_SCopy.\n      ** A significant change would indicated a missed call to this\n      ** function for pX.  Minor changes, such as adding or removing a\n      ** dual type, are allowed, as long as the underlying value is the\n      ** same. */\n      u16 mFlags = pMem->flags & pX->flags & pX->mScopyFlags;\n      assert( (mFlags&MEM_Int)==0 || pMem->u.i==pX->u.i );\n      assert( (mFlags&MEM_Real)==0 || pMem->u.r==pX->u.r );\n      assert( (mFlags&MEM_Str)==0  || (pMem->n==pX->n && pMem->z==pX->z) );\n      assert( (mFlags&MEM_Blob)==0  || sqlite3BlobCompare(pMem,pX)==0 );\n      \n      /* pMem is the register that is changing.  But also mark pX as\n      ** undefined so that we can quickly detect the shallow-copy error */\n      pX->flags = MEM_Undefined;\n      pX->pScopyFrom = 0;\n    }\n  }\n  pMem->pScopyFrom = 0;\n}\n#endif /* SQLITE_DEBUG */\n\n\n/*\n** Make an shallow copy of pFrom into pTo.  Prior contents of\n** pTo are freed.  The pFrom->z field is not duplicated.  If\n** pFrom->z is used, then pTo->z points to the same thing as pFrom->z\n** and flags gets srcType (either MEM_Ephem or MEM_Static).\n*/\nstatic SQLITE_NOINLINE void vdbeClrCopy(Mem *pTo, const Mem *pFrom, int eType){\n  vdbeMemClearExternAndSetNull(pTo);\n  assert( !VdbeMemDynamic(pTo) );\n  sqlite3VdbeMemShallowCopy(pTo, pFrom, eType);\n}\nSQLITE_PRIVATE void sqlite3VdbeMemShallowCopy(Mem *pTo, const Mem *pFrom, int srcType){\n  assert( !sqlite3VdbeMemIsRowSet(pFrom) );\n  assert( pTo->db==pFrom->db );\n  if( VdbeMemDynamic(pTo) ){ vdbeClrCopy(pTo,pFrom,srcType); return; }\n  memcpy(pTo, pFrom, MEMCELLSIZE);\n  if( (pFrom->flags&MEM_Static)==0 ){\n    pTo->flags &= ~(MEM_Dyn|MEM_Static|MEM_Ephem);\n    assert( srcType==MEM_Ephem || srcType==MEM_Static );\n    pTo->flags |= srcType;\n  }\n}\n\n/*\n** Make a full copy of pFrom into pTo.  Prior contents of pTo are\n** freed before the copy is made.\n*/\nSQLITE_PRIVATE int sqlite3VdbeMemCopy(Mem *pTo, const Mem *pFrom){\n  int rc = SQLITE_OK;\n\n  assert( !sqlite3VdbeMemIsRowSet(pFrom) );\n  if( VdbeMemDynamic(pTo) ) vdbeMemClearExternAndSetNull(pTo);\n  memcpy(pTo, pFrom, MEMCELLSIZE);\n  pTo->flags &= ~MEM_Dyn;\n  if( pTo->flags&(MEM_Str|MEM_Blob) ){\n    if( 0==(pFrom->flags&MEM_Static) ){\n      pTo->flags |= MEM_Ephem;\n      rc = sqlite3VdbeMemMakeWriteable(pTo);\n    }\n  }\n\n  return rc;\n}\n\n/*\n** Transfer the contents of pFrom to pTo. Any existing value in pTo is\n** freed. If pFrom contains ephemeral data, a copy is made.\n**\n** pFrom contains an SQL NULL when this routine returns.\n*/\nSQLITE_PRIVATE void sqlite3VdbeMemMove(Mem *pTo, Mem *pFrom){\n  assert( pFrom->db==0 || sqlite3_mutex_held(pFrom->db->mutex) );\n  assert( pTo->db==0 || sqlite3_mutex_held(pTo->db->mutex) );\n  assert( pFrom->db==0 || pTo->db==0 || pFrom->db==pTo->db );\n\n  sqlite3VdbeMemRelease(pTo);\n  memcpy(pTo, pFrom, sizeof(Mem));\n  pFrom->flags = MEM_Null;\n  pFrom->szMalloc = 0;\n}\n\n/*\n** Change the value of a Mem to be a string or a BLOB.\n**\n** The memory management strategy depends on the value of the xDel\n** parameter. If the value passed is SQLITE_TRANSIENT, then the \n** string is copied into a (possibly existing) buffer managed by the \n** Mem structure. Otherwise, any existing buffer is freed and the\n** pointer copied.\n**\n** If the string is too large (if it exceeds the SQLITE_LIMIT_LENGTH\n** size limit) then no memory allocation occurs.  If the string can be\n** stored without allocating memory, then it is.  If a memory allocation\n** is required to store the string, then value of pMem is unchanged.  In\n** either case, SQLITE_TOOBIG is returned.\n*/\nSQLITE_PRIVATE int sqlite3VdbeMemSetStr(\n  Mem *pMem,          /* Memory cell to set to string value */\n  const char *z,      /* String pointer */\n  int n,              /* Bytes in string, or negative */\n  u8 enc,             /* Encoding of z.  0 for BLOBs */\n  void (*xDel)(void*) /* Destructor function */\n){\n  int nByte = n;      /* New value for pMem->n */\n  int iLimit;         /* Maximum allowed string or blob size */\n  u16 flags = 0;      /* New value for pMem->flags */\n\n  assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) );\n  assert( !sqlite3VdbeMemIsRowSet(pMem) );\n\n  /* If z is a NULL pointer, set pMem to contain an SQL NULL. */\n  if( !z ){\n    sqlite3VdbeMemSetNull(pMem);\n    return SQLITE_OK;\n  }\n\n  if( pMem->db ){\n    iLimit = pMem->db->aLimit[SQLITE_LIMIT_LENGTH];\n  }else{\n    iLimit = SQLITE_MAX_LENGTH;\n  }\n  flags = (enc==0?MEM_Blob:MEM_Str);\n  if( nByte<0 ){\n    assert( enc!=0 );\n    if( enc==SQLITE_UTF8 ){\n      nByte = 0x7fffffff & (int)strlen(z);\n      if( nByte>iLimit ) nByte = iLimit+1;\n    }else{\n      for(nByte=0; nByte<=iLimit && (z[nByte] | z[nByte+1]); nByte+=2){}\n    }\n    flags |= MEM_Term;\n  }\n\n  /* The following block sets the new values of Mem.z and Mem.xDel. It\n  ** also sets a flag in local variable \"flags\" to indicate the memory\n  ** management (one of MEM_Dyn or MEM_Static).\n  */\n  if( xDel==SQLITE_TRANSIENT ){\n    int nAlloc = nByte;\n    if( flags&MEM_Term ){\n      nAlloc += (enc==SQLITE_UTF8?1:2);\n    }\n    if( nByte>iLimit ){\n      return SQLITE_TOOBIG;\n    }\n    testcase( nAlloc==0 );\n    testcase( nAlloc==31 );\n    testcase( nAlloc==32 );\n    if( sqlite3VdbeMemClearAndResize(pMem, MAX(nAlloc,32)) ){\n      return SQLITE_NOMEM_BKPT;\n    }\n    memcpy(pMem->z, z, nAlloc);\n  }else if( xDel==SQLITE_DYNAMIC ){\n    sqlite3VdbeMemRelease(pMem);\n    pMem->zMalloc = pMem->z = (char *)z;\n    pMem->szMalloc = sqlite3DbMallocSize(pMem->db, pMem->zMalloc);\n  }else{\n    sqlite3VdbeMemRelease(pMem);\n    pMem->z = (char *)z;\n    pMem->xDel = xDel;\n    flags |= ((xDel==SQLITE_STATIC)?MEM_Static:MEM_Dyn);\n  }\n\n  pMem->n = nByte;\n  pMem->flags = flags;\n  pMem->enc = (enc==0 ? SQLITE_UTF8 : enc);\n\n#ifndef SQLITE_OMIT_UTF16\n  if( pMem->enc!=SQLITE_UTF8 && sqlite3VdbeMemHandleBom(pMem) ){\n    return SQLITE_NOMEM_BKPT;\n  }\n#endif\n\n  if( nByte>iLimit ){\n    return SQLITE_TOOBIG;\n  }\n\n  return SQLITE_OK;\n}\n\n/*\n** Move data out of a btree key or data field and into a Mem structure.\n** The data is payload from the entry that pCur is currently pointing\n** to.  offset and amt determine what portion of the data or key to retrieve.\n** The result is written into the pMem element.\n**\n** The pMem object must have been initialized.  This routine will use\n** pMem->zMalloc to hold the content from the btree, if possible.  New\n** pMem->zMalloc space will be allocated if necessary.  The calling routine\n** is responsible for making sure that the pMem object is eventually\n** destroyed.\n**\n** If this routine fails for any reason (malloc returns NULL or unable\n** to read from the disk) then the pMem is left in an inconsistent state.\n*/\nstatic SQLITE_NOINLINE int vdbeMemFromBtreeResize(\n  BtCursor *pCur,   /* Cursor pointing at record to retrieve. */\n  u32 offset,       /* Offset from the start of data to return bytes from. */\n  u32 amt,          /* Number of bytes to return. */\n  Mem *pMem         /* OUT: Return data in this Mem structure. */\n){\n  int rc;\n  pMem->flags = MEM_Null;\n  if( sqlite3BtreeMaxRecordSize(pCur)<offset+amt ){\n    return SQLITE_CORRUPT_BKPT;\n  }\n  if( SQLITE_OK==(rc = sqlite3VdbeMemClearAndResize(pMem, amt+1)) ){\n    rc = sqlite3BtreePayload(pCur, offset, amt, pMem->z);\n    if( rc==SQLITE_OK ){\n      pMem->z[amt] = 0;   /* Overrun area used when reading malformed records */\n      pMem->flags = MEM_Blob;\n      pMem->n = (int)amt;\n    }else{\n      sqlite3VdbeMemRelease(pMem);\n    }\n  }\n  return rc;\n}\nSQLITE_PRIVATE int sqlite3VdbeMemFromBtree(\n  BtCursor *pCur,   /* Cursor pointing at record to retrieve. */\n  u32 offset,       /* Offset from the start of data to return bytes from. */\n  u32 amt,          /* Number of bytes to return. */\n  Mem *pMem         /* OUT: Return data in this Mem structure. */\n){\n  char *zData;        /* Data from the btree layer */\n  u32 available = 0;  /* Number of bytes available on the local btree page */\n  int rc = SQLITE_OK; /* Return code */\n\n  assert( sqlite3BtreeCursorIsValid(pCur) );\n  assert( !VdbeMemDynamic(pMem) );\n\n  /* Note: the calls to BtreeKeyFetch() and DataFetch() below assert() \n  ** that both the BtShared and database handle mutexes are held. */\n  assert( !sqlite3VdbeMemIsRowSet(pMem) );\n  zData = (char *)sqlite3BtreePayloadFetch(pCur, &available);\n  assert( zData!=0 );\n\n  if( offset+amt<=available ){\n    pMem->z = &zData[offset];\n    pMem->flags = MEM_Blob|MEM_Ephem;\n    pMem->n = (int)amt;\n  }else{\n    rc = vdbeMemFromBtreeResize(pCur, offset, amt, pMem);\n  }\n\n  return rc;\n}\n\n/*\n** The pVal argument is known to be a value other than NULL.\n** Convert it into a string with encoding enc and return a pointer\n** to a zero-terminated version of that string.\n*/\nstatic SQLITE_NOINLINE const void *valueToText(sqlite3_value* pVal, u8 enc){\n  assert( pVal!=0 );\n  assert( pVal->db==0 || sqlite3_mutex_held(pVal->db->mutex) );\n  assert( (enc&3)==(enc&~SQLITE_UTF16_ALIGNED) );\n  assert( !sqlite3VdbeMemIsRowSet(pVal) );\n  assert( (pVal->flags & (MEM_Null))==0 );\n  if( pVal->flags & (MEM_Blob|MEM_Str) ){\n    if( ExpandBlob(pVal) ) return 0;\n    pVal->flags |= MEM_Str;\n    if( pVal->enc != (enc & ~SQLITE_UTF16_ALIGNED) ){\n      sqlite3VdbeChangeEncoding(pVal, enc & ~SQLITE_UTF16_ALIGNED);\n    }\n    if( (enc & SQLITE_UTF16_ALIGNED)!=0 && 1==(1&SQLITE_PTR_TO_INT(pVal->z)) ){\n      assert( (pVal->flags & (MEM_Ephem|MEM_Static))!=0 );\n      if( sqlite3VdbeMemMakeWriteable(pVal)!=SQLITE_OK ){\n        return 0;\n      }\n    }\n    sqlite3VdbeMemNulTerminate(pVal); /* IMP: R-31275-44060 */\n  }else{\n    sqlite3VdbeMemStringify(pVal, enc, 0);\n    assert( 0==(1&SQLITE_PTR_TO_INT(pVal->z)) );\n  }\n  assert(pVal->enc==(enc & ~SQLITE_UTF16_ALIGNED) || pVal->db==0\n              || pVal->db->mallocFailed );\n  if( pVal->enc==(enc & ~SQLITE_UTF16_ALIGNED) ){\n    assert( sqlite3VdbeMemConsistentDualRep(pVal) );\n    return pVal->z;\n  }else{\n    return 0;\n  }\n}\n\n/* This function is only available internally, it is not part of the\n** external API. It works in a similar way to sqlite3_value_text(),\n** except the data returned is in the encoding specified by the second\n** parameter, which must be one of SQLITE_UTF16BE, SQLITE_UTF16LE or\n** SQLITE_UTF8.\n**\n** (2006-02-16:)  The enc value can be or-ed with SQLITE_UTF16_ALIGNED.\n** If that is the case, then the result must be aligned on an even byte\n** boundary.\n*/\nSQLITE_PRIVATE const void *sqlite3ValueText(sqlite3_value* pVal, u8 enc){\n  if( !pVal ) return 0;\n  assert( pVal->db==0 || sqlite3_mutex_held(pVal->db->mutex) );\n  assert( (enc&3)==(enc&~SQLITE_UTF16_ALIGNED) );\n  assert( !sqlite3VdbeMemIsRowSet(pVal) );\n  if( (pVal->flags&(MEM_Str|MEM_Term))==(MEM_Str|MEM_Term) && pVal->enc==enc ){\n    assert( sqlite3VdbeMemConsistentDualRep(pVal) );\n    return pVal->z;\n  }\n  if( pVal->flags&MEM_Null ){\n    return 0;\n  }\n  return valueToText(pVal, enc);\n}\n\n/*\n** Create a new sqlite3_value object.\n*/\nSQLITE_PRIVATE sqlite3_value *sqlite3ValueNew(sqlite3 *db){\n  Mem *p = sqlite3DbMallocZero(db, sizeof(*p));\n  if( p ){\n    p->flags = MEM_Null;\n    p->db = db;\n  }\n  return p;\n}\n\n/*\n** Context object passed by sqlite3Stat4ProbeSetValue() through to \n** valueNew(). See comments above valueNew() for details.\n*/\nstruct ValueNewStat4Ctx {\n  Parse *pParse;\n  Index *pIdx;\n  UnpackedRecord **ppRec;\n  int iVal;\n};\n\n/*\n** Allocate and return a pointer to a new sqlite3_value object. If\n** the second argument to this function is NULL, the object is allocated\n** by calling sqlite3ValueNew().\n**\n** Otherwise, if the second argument is non-zero, then this function is \n** being called indirectly by sqlite3Stat4ProbeSetValue(). If it has not\n** already been allocated, allocate the UnpackedRecord structure that \n** that function will return to its caller here. Then return a pointer to\n** an sqlite3_value within the UnpackedRecord.a[] array.\n*/\nstatic sqlite3_value *valueNew(sqlite3 *db, struct ValueNewStat4Ctx *p){\n#ifdef SQLITE_ENABLE_STAT3_OR_STAT4\n  if( p ){\n    UnpackedRecord *pRec = p->ppRec[0];\n\n    if( pRec==0 ){\n      Index *pIdx = p->pIdx;      /* Index being probed */\n      int nByte;                  /* Bytes of space to allocate */\n      int i;                      /* Counter variable */\n      int nCol = pIdx->nColumn;   /* Number of index columns including rowid */\n  \n      nByte = sizeof(Mem) * nCol + ROUND8(sizeof(UnpackedRecord));\n      pRec = (UnpackedRecord*)sqlite3DbMallocZero(db, nByte);\n      if( pRec ){\n        pRec->pKeyInfo = sqlite3KeyInfoOfIndex(p->pParse, pIdx);\n        if( pRec->pKeyInfo ){\n          assert( pRec->pKeyInfo->nAllField==nCol );\n          assert( pRec->pKeyInfo->enc==ENC(db) );\n          pRec->aMem = (Mem *)((u8*)pRec + ROUND8(sizeof(UnpackedRecord)));\n          for(i=0; i<nCol; i++){\n            pRec->aMem[i].flags = MEM_Null;\n            pRec->aMem[i].db = db;\n          }\n        }else{\n          sqlite3DbFreeNN(db, pRec);\n          pRec = 0;\n        }\n      }\n      if( pRec==0 ) return 0;\n      p->ppRec[0] = pRec;\n    }\n  \n    pRec->nField = p->iVal+1;\n    return &pRec->aMem[p->iVal];\n  }\n#else\n  UNUSED_PARAMETER(p);\n#endif /* defined(SQLITE_ENABLE_STAT3_OR_STAT4) */\n  return sqlite3ValueNew(db);\n}\n\n/*\n** The expression object indicated by the second argument is guaranteed\n** to be a scalar SQL function. If\n**\n**   * all function arguments are SQL literals,\n**   * one of the SQLITE_FUNC_CONSTANT or _SLOCHNG function flags is set, and\n**   * the SQLITE_FUNC_NEEDCOLL function flag is not set,\n**\n** then this routine attempts to invoke the SQL function. Assuming no\n** error occurs, output parameter (*ppVal) is set to point to a value \n** object containing the result before returning SQLITE_OK.\n**\n** Affinity aff is applied to the result of the function before returning.\n** If the result is a text value, the sqlite3_value object uses encoding \n** enc.\n**\n** If the conditions above are not met, this function returns SQLITE_OK\n** and sets (*ppVal) to NULL. Or, if an error occurs, (*ppVal) is set to\n** NULL and an SQLite error code returned.\n*/\n#ifdef SQLITE_ENABLE_STAT3_OR_STAT4\nstatic int valueFromFunction(\n  sqlite3 *db,                    /* The database connection */\n  Expr *p,                        /* The expression to evaluate */\n  u8 enc,                         /* Encoding to use */\n  u8 aff,                         /* Affinity to use */\n  sqlite3_value **ppVal,          /* Write the new value here */\n  struct ValueNewStat4Ctx *pCtx   /* Second argument for valueNew() */\n){\n  sqlite3_context ctx;            /* Context object for function invocation */\n  sqlite3_value **apVal = 0;      /* Function arguments */\n  int nVal = 0;                   /* Size of apVal[] array */\n  FuncDef *pFunc = 0;             /* Function definition */\n  sqlite3_value *pVal = 0;        /* New value */\n  int rc = SQLITE_OK;             /* Return code */\n  ExprList *pList = 0;            /* Function arguments */\n  int i;                          /* Iterator variable */\n\n  assert( pCtx!=0 );\n  assert( (p->flags & EP_TokenOnly)==0 );\n  pList = p->x.pList;\n  if( pList ) nVal = pList->nExpr;\n  pFunc = sqlite3FindFunction(db, p->u.zToken, nVal, enc, 0);\n  assert( pFunc );\n  if( (pFunc->funcFlags & (SQLITE_FUNC_CONSTANT|SQLITE_FUNC_SLOCHNG))==0 \n   || (pFunc->funcFlags & SQLITE_FUNC_NEEDCOLL)\n  ){\n    return SQLITE_OK;\n  }\n\n  if( pList ){\n    apVal = (sqlite3_value**)sqlite3DbMallocZero(db, sizeof(apVal[0]) * nVal);\n    if( apVal==0 ){\n      rc = SQLITE_NOMEM_BKPT;\n      goto value_from_function_out;\n    }\n    for(i=0; i<nVal; i++){\n      rc = sqlite3ValueFromExpr(db, pList->a[i].pExpr, enc, aff, &apVal[i]);\n      if( apVal[i]==0 || rc!=SQLITE_OK ) goto value_from_function_out;\n    }\n  }\n\n  pVal = valueNew(db, pCtx);\n  if( pVal==0 ){\n    rc = SQLITE_NOMEM_BKPT;\n    goto value_from_function_out;\n  }\n\n  assert( pCtx->pParse->rc==SQLITE_OK );\n  memset(&ctx, 0, sizeof(ctx));\n  ctx.pOut = pVal;\n  ctx.pFunc = pFunc;\n  pFunc->xSFunc(&ctx, nVal, apVal);\n  if( ctx.isError ){\n    rc = ctx.isError;\n    sqlite3ErrorMsg(pCtx->pParse, \"%s\", sqlite3_value_text(pVal));\n  }else{\n    sqlite3ValueApplyAffinity(pVal, aff, SQLITE_UTF8);\n    assert( rc==SQLITE_OK );\n    rc = sqlite3VdbeChangeEncoding(pVal, enc);\n    if( rc==SQLITE_OK && sqlite3VdbeMemTooBig(pVal) ){\n      rc = SQLITE_TOOBIG;\n      pCtx->pParse->nErr++;\n    }\n  }\n  pCtx->pParse->rc = rc;\n\n value_from_function_out:\n  if( rc!=SQLITE_OK ){\n    pVal = 0;\n  }\n  if( apVal ){\n    for(i=0; i<nVal; i++){\n      sqlite3ValueFree(apVal[i]);\n    }\n    sqlite3DbFreeNN(db, apVal);\n  }\n\n  *ppVal = pVal;\n  return rc;\n}\n#else\n# define valueFromFunction(a,b,c,d,e,f) SQLITE_OK\n#endif /* defined(SQLITE_ENABLE_STAT3_OR_STAT4) */\n\n/*\n** Extract a value from the supplied expression in the manner described\n** above sqlite3ValueFromExpr(). Allocate the sqlite3_value object\n** using valueNew().\n**\n** If pCtx is NULL and an error occurs after the sqlite3_value object\n** has been allocated, it is freed before returning. Or, if pCtx is not\n** NULL, it is assumed that the caller will free any allocated object\n** in all cases.\n*/\nstatic int valueFromExpr(\n  sqlite3 *db,                    /* The database connection */\n  Expr *pExpr,                    /* The expression to evaluate */\n  u8 enc,                         /* Encoding to use */\n  u8 affinity,                    /* Affinity to use */\n  sqlite3_value **ppVal,          /* Write the new value here */\n  struct ValueNewStat4Ctx *pCtx   /* Second argument for valueNew() */\n){\n  int op;\n  char *zVal = 0;\n  sqlite3_value *pVal = 0;\n  int negInt = 1;\n  const char *zNeg = \"\";\n  int rc = SQLITE_OK;\n\n  assert( pExpr!=0 );\n  while( (op = pExpr->op)==TK_UPLUS || op==TK_SPAN ) pExpr = pExpr->pLeft;\n#if defined(SQLITE_ENABLE_STAT3_OR_STAT4)\n  if( op==TK_REGISTER ) op = pExpr->op2;\n#else\n  if( NEVER(op==TK_REGISTER) ) op = pExpr->op2;\n#endif\n\n  /* Compressed expressions only appear when parsing the DEFAULT clause\n  ** on a table column definition, and hence only when pCtx==0.  This\n  ** check ensures that an EP_TokenOnly expression is never passed down\n  ** into valueFromFunction(). */\n  assert( (pExpr->flags & EP_TokenOnly)==0 || pCtx==0 );\n\n  if( op==TK_CAST ){\n    u8 aff = sqlite3AffinityType(pExpr->u.zToken,0);\n    rc = valueFromExpr(db, pExpr->pLeft, enc, aff, ppVal, pCtx);\n    testcase( rc!=SQLITE_OK );\n    if( *ppVal ){\n      sqlite3VdbeMemCast(*ppVal, aff, SQLITE_UTF8);\n      sqlite3ValueApplyAffinity(*ppVal, affinity, SQLITE_UTF8);\n    }\n    return rc;\n  }\n\n  /* Handle negative integers in a single step.  This is needed in the\n  ** case when the value is -9223372036854775808.\n  */\n  if( op==TK_UMINUS\n   && (pExpr->pLeft->op==TK_INTEGER || pExpr->pLeft->op==TK_FLOAT) ){\n    pExpr = pExpr->pLeft;\n    op = pExpr->op;\n    negInt = -1;\n    zNeg = \"-\";\n  }\n\n  if( op==TK_STRING || op==TK_FLOAT || op==TK_INTEGER ){\n    pVal = valueNew(db, pCtx);\n    if( pVal==0 ) goto no_mem;\n    if( ExprHasProperty(pExpr, EP_IntValue) ){\n      sqlite3VdbeMemSetInt64(pVal, (i64)pExpr->u.iValue*negInt);\n    }else{\n      zVal = sqlite3MPrintf(db, \"%s%s\", zNeg, pExpr->u.zToken);\n      if( zVal==0 ) goto no_mem;\n      sqlite3ValueSetStr(pVal, -1, zVal, SQLITE_UTF8, SQLITE_DYNAMIC);\n    }\n    if( (op==TK_INTEGER || op==TK_FLOAT ) && affinity==SQLITE_AFF_BLOB ){\n      sqlite3ValueApplyAffinity(pVal, SQLITE_AFF_NUMERIC, SQLITE_UTF8);\n    }else{\n      sqlite3ValueApplyAffinity(pVal, affinity, SQLITE_UTF8);\n    }\n    if( pVal->flags & (MEM_Int|MEM_Real) ) pVal->flags &= ~MEM_Str;\n    if( enc!=SQLITE_UTF8 ){\n      rc = sqlite3VdbeChangeEncoding(pVal, enc);\n    }\n  }else if( op==TK_UMINUS ) {\n    /* This branch happens for multiple negative signs.  Ex: -(-5) */\n    if( SQLITE_OK==valueFromExpr(db,pExpr->pLeft,enc,affinity,&pVal,pCtx) \n     && pVal!=0\n    ){\n      sqlite3VdbeMemNumerify(pVal);\n      if( pVal->flags & MEM_Real ){\n        pVal->u.r = -pVal->u.r;\n      }else if( pVal->u.i==SMALLEST_INT64 ){\n        pVal->u.r = -(double)SMALLEST_INT64;\n        MemSetTypeFlag(pVal, MEM_Real);\n      }else{\n        pVal->u.i = -pVal->u.i;\n      }\n      sqlite3ValueApplyAffinity(pVal, affinity, enc);\n    }\n  }else if( op==TK_NULL ){\n    pVal = valueNew(db, pCtx);\n    if( pVal==0 ) goto no_mem;\n    sqlite3VdbeMemNumerify(pVal);\n  }\n#ifndef SQLITE_OMIT_BLOB_LITERAL\n  else if( op==TK_BLOB ){\n    int nVal;\n    assert( pExpr->u.zToken[0]=='x' || pExpr->u.zToken[0]=='X' );\n    assert( pExpr->u.zToken[1]=='\\'' );\n    pVal = valueNew(db, pCtx);\n    if( !pVal ) goto no_mem;\n    zVal = &pExpr->u.zToken[2];\n    nVal = sqlite3Strlen30(zVal)-1;\n    assert( zVal[nVal]=='\\'' );\n    sqlite3VdbeMemSetStr(pVal, sqlite3HexToBlob(db, zVal, nVal), nVal/2,\n                         0, SQLITE_DYNAMIC);\n  }\n#endif\n#ifdef SQLITE_ENABLE_STAT3_OR_STAT4\n  else if( op==TK_FUNCTION && pCtx!=0 ){\n    rc = valueFromFunction(db, pExpr, enc, affinity, &pVal, pCtx);\n  }\n#endif\n  else if( op==TK_TRUEFALSE ){\n    pVal = valueNew(db, pCtx);\n    if( pVal ){\n      pVal->flags = MEM_Int;\n      pVal->u.i = pExpr->u.zToken[4]==0;\n    }\n  }\n\n  *ppVal = pVal;\n  return rc;\n\nno_mem:\n#ifdef SQLITE_ENABLE_STAT3_OR_STAT4\n  if( pCtx==0 || pCtx->pParse->nErr==0 )\n#endif\n    sqlite3OomFault(db);\n  sqlite3DbFree(db, zVal);\n  assert( *ppVal==0 );\n#ifdef SQLITE_ENABLE_STAT3_OR_STAT4\n  if( pCtx==0 ) sqlite3ValueFree(pVal);\n#else\n  assert( pCtx==0 ); sqlite3ValueFree(pVal);\n#endif\n  return SQLITE_NOMEM_BKPT;\n}\n\n/*\n** Create a new sqlite3_value object, containing the value of pExpr.\n**\n** This only works for very simple expressions that consist of one constant\n** token (i.e. \"5\", \"5.1\", \"'a string'\"). If the expression can\n** be converted directly into a value, then the value is allocated and\n** a pointer written to *ppVal. The caller is responsible for deallocating\n** the value by passing it to sqlite3ValueFree() later on. If the expression\n** cannot be converted to a value, then *ppVal is set to NULL.\n*/\nSQLITE_PRIVATE int sqlite3ValueFromExpr(\n  sqlite3 *db,              /* The database connection */\n  Expr *pExpr,              /* The expression to evaluate */\n  u8 enc,                   /* Encoding to use */\n  u8 affinity,              /* Affinity to use */\n  sqlite3_value **ppVal     /* Write the new value here */\n){\n  return pExpr ? valueFromExpr(db, pExpr, enc, affinity, ppVal, 0) : 0;\n}\n\n#ifdef SQLITE_ENABLE_STAT3_OR_STAT4\n/*\n** The implementation of the sqlite_record() function. This function accepts\n** a single argument of any type. The return value is a formatted database \n** record (a blob) containing the argument value.\n**\n** This is used to convert the value stored in the 'sample' column of the\n** sqlite_stat3 table to the record format SQLite uses internally.\n*/\nstatic void recordFunc(\n  sqlite3_context *context,\n  int argc,\n  sqlite3_value **argv\n){\n  const int file_format = 1;\n  u32 iSerial;                    /* Serial type */\n  int nSerial;                    /* Bytes of space for iSerial as varint */\n  u32 nVal;                       /* Bytes of space required for argv[0] */\n  int nRet;\n  sqlite3 *db;\n  u8 *aRet;\n\n  UNUSED_PARAMETER( argc );\n  iSerial = sqlite3VdbeSerialType(argv[0], file_format, &nVal);\n  nSerial = sqlite3VarintLen(iSerial);\n  db = sqlite3_context_db_handle(context);\n\n  nRet = 1 + nSerial + nVal;\n  aRet = sqlite3DbMallocRawNN(db, nRet);\n  if( aRet==0 ){\n    sqlite3_result_error_nomem(context);\n  }else{\n    aRet[0] = nSerial+1;\n    putVarint32(&aRet[1], iSerial);\n    sqlite3VdbeSerialPut(&aRet[1+nSerial], argv[0], iSerial);\n    sqlite3_result_blob(context, aRet, nRet, SQLITE_TRANSIENT);\n    sqlite3DbFreeNN(db, aRet);\n  }\n}\n\n/*\n** Register built-in functions used to help read ANALYZE data.\n*/\nSQLITE_PRIVATE void sqlite3AnalyzeFunctions(void){\n  static FuncDef aAnalyzeTableFuncs[] = {\n    FUNCTION(sqlite_record,   1, 0, 0, recordFunc),\n  };\n  sqlite3InsertBuiltinFuncs(aAnalyzeTableFuncs, ArraySize(aAnalyzeTableFuncs));\n}\n\n/*\n** Attempt to extract a value from pExpr and use it to construct *ppVal.\n**\n** If pAlloc is not NULL, then an UnpackedRecord object is created for\n** pAlloc if one does not exist and the new value is added to the\n** UnpackedRecord object.\n**\n** A value is extracted in the following cases:\n**\n**  * (pExpr==0). In this case the value is assumed to be an SQL NULL,\n**\n**  * The expression is a bound variable, and this is a reprepare, or\n**\n**  * The expression is a literal value.\n**\n** On success, *ppVal is made to point to the extracted value.  The caller\n** is responsible for ensuring that the value is eventually freed.\n*/\nstatic int stat4ValueFromExpr(\n  Parse *pParse,                  /* Parse context */\n  Expr *pExpr,                    /* The expression to extract a value from */\n  u8 affinity,                    /* Affinity to use */\n  struct ValueNewStat4Ctx *pAlloc,/* How to allocate space.  Or NULL */\n  sqlite3_value **ppVal           /* OUT: New value object (or NULL) */\n){\n  int rc = SQLITE_OK;\n  sqlite3_value *pVal = 0;\n  sqlite3 *db = pParse->db;\n\n  /* Skip over any TK_COLLATE nodes */\n  pExpr = sqlite3ExprSkipCollate(pExpr);\n\n  assert( pExpr==0 || pExpr->op!=TK_REGISTER || pExpr->op2!=TK_VARIABLE );\n  if( !pExpr ){\n    pVal = valueNew(db, pAlloc);\n    if( pVal ){\n      sqlite3VdbeMemSetNull((Mem*)pVal);\n    }\n  }else if( pExpr->op==TK_VARIABLE && (db->flags & SQLITE_EnableQPSG)==0 ){\n    Vdbe *v;\n    int iBindVar = pExpr->iColumn;\n    sqlite3VdbeSetVarmask(pParse->pVdbe, iBindVar);\n    if( (v = pParse->pReprepare)!=0 ){\n      pVal = valueNew(db, pAlloc);\n      if( pVal ){\n        rc = sqlite3VdbeMemCopy((Mem*)pVal, &v->aVar[iBindVar-1]);\n        sqlite3ValueApplyAffinity(pVal, affinity, ENC(db));\n        pVal->db = pParse->db;\n      }\n    }\n  }else{\n    rc = valueFromExpr(db, pExpr, ENC(db), affinity, &pVal, pAlloc);\n  }\n\n  assert( pVal==0 || pVal->db==db );\n  *ppVal = pVal;\n  return rc;\n}\n\n/*\n** This function is used to allocate and populate UnpackedRecord \n** structures intended to be compared against sample index keys stored \n** in the sqlite_stat4 table.\n**\n** A single call to this function populates zero or more fields of the\n** record starting with field iVal (fields are numbered from left to\n** right starting with 0). A single field is populated if:\n**\n**  * (pExpr==0). In this case the value is assumed to be an SQL NULL,\n**\n**  * The expression is a bound variable, and this is a reprepare, or\n**\n**  * The sqlite3ValueFromExpr() function is able to extract a value \n**    from the expression (i.e. the expression is a literal value).\n**\n** Or, if pExpr is a TK_VECTOR, one field is populated for each of the\n** vector components that match either of the two latter criteria listed\n** above.\n**\n** Before any value is appended to the record, the affinity of the \n** corresponding column within index pIdx is applied to it. Before\n** this function returns, output parameter *pnExtract is set to the\n** number of values appended to the record.\n**\n** When this function is called, *ppRec must either point to an object\n** allocated by an earlier call to this function, or must be NULL. If it\n** is NULL and a value can be successfully extracted, a new UnpackedRecord\n** is allocated (and *ppRec set to point to it) before returning.\n**\n** Unless an error is encountered, SQLITE_OK is returned. It is not an\n** error if a value cannot be extracted from pExpr. If an error does\n** occur, an SQLite error code is returned.\n*/\nSQLITE_PRIVATE int sqlite3Stat4ProbeSetValue(\n  Parse *pParse,                  /* Parse context */\n  Index *pIdx,                    /* Index being probed */\n  UnpackedRecord **ppRec,         /* IN/OUT: Probe record */\n  Expr *pExpr,                    /* The expression to extract a value from */\n  int nElem,                      /* Maximum number of values to append */\n  int iVal,                       /* Array element to populate */\n  int *pnExtract                  /* OUT: Values appended to the record */\n){\n  int rc = SQLITE_OK;\n  int nExtract = 0;\n\n  if( pExpr==0 || pExpr->op!=TK_SELECT ){\n    int i;\n    struct ValueNewStat4Ctx alloc;\n\n    alloc.pParse = pParse;\n    alloc.pIdx = pIdx;\n    alloc.ppRec = ppRec;\n\n    for(i=0; i<nElem; i++){\n      sqlite3_value *pVal = 0;\n      Expr *pElem = (pExpr ? sqlite3VectorFieldSubexpr(pExpr, i) : 0);\n      u8 aff = sqlite3IndexColumnAffinity(pParse->db, pIdx, iVal+i);\n      alloc.iVal = iVal+i;\n      rc = stat4ValueFromExpr(pParse, pElem, aff, &alloc, &pVal);\n      if( !pVal ) break;\n      nExtract++;\n    }\n  }\n\n  *pnExtract = nExtract;\n  return rc;\n}\n\n/*\n** Attempt to extract a value from expression pExpr using the methods\n** as described for sqlite3Stat4ProbeSetValue() above. \n**\n** If successful, set *ppVal to point to a new value object and return \n** SQLITE_OK. If no value can be extracted, but no other error occurs\n** (e.g. OOM), return SQLITE_OK and set *ppVal to NULL. Or, if an error\n** does occur, return an SQLite error code. The final value of *ppVal\n** is undefined in this case.\n*/\nSQLITE_PRIVATE int sqlite3Stat4ValueFromExpr(\n  Parse *pParse,                  /* Parse context */\n  Expr *pExpr,                    /* The expression to extract a value from */\n  u8 affinity,                    /* Affinity to use */\n  sqlite3_value **ppVal           /* OUT: New value object (or NULL) */\n){\n  return stat4ValueFromExpr(pParse, pExpr, affinity, 0, ppVal);\n}\n\n/*\n** Extract the iCol-th column from the nRec-byte record in pRec.  Write\n** the column value into *ppVal.  If *ppVal is initially NULL then a new\n** sqlite3_value object is allocated.\n**\n** If *ppVal is initially NULL then the caller is responsible for \n** ensuring that the value written into *ppVal is eventually freed.\n*/\nSQLITE_PRIVATE int sqlite3Stat4Column(\n  sqlite3 *db,                    /* Database handle */\n  const void *pRec,               /* Pointer to buffer containing record */\n  int nRec,                       /* Size of buffer pRec in bytes */\n  int iCol,                       /* Column to extract */\n  sqlite3_value **ppVal           /* OUT: Extracted value */\n){\n  u32 t = 0;                      /* a column type code */\n  int nHdr;                       /* Size of the header in the record */\n  int iHdr;                       /* Next unread header byte */\n  int iField;                     /* Next unread data byte */\n  int szField = 0;                /* Size of the current data field */\n  int i;                          /* Column index */\n  u8 *a = (u8*)pRec;              /* Typecast byte array */\n  Mem *pMem = *ppVal;             /* Write result into this Mem object */\n\n  assert( iCol>0 );\n  iHdr = getVarint32(a, nHdr);\n  if( nHdr>nRec || iHdr>=nHdr ) return SQLITE_CORRUPT_BKPT;\n  iField = nHdr;\n  for(i=0; i<=iCol; i++){\n    iHdr += getVarint32(&a[iHdr], t);\n    testcase( iHdr==nHdr );\n    testcase( iHdr==nHdr+1 );\n    if( iHdr>nHdr ) return SQLITE_CORRUPT_BKPT;\n    szField = sqlite3VdbeSerialTypeLen(t);\n    iField += szField;\n  }\n  testcase( iField==nRec );\n  testcase( iField==nRec+1 );\n  if( iField>nRec ) return SQLITE_CORRUPT_BKPT;\n  if( pMem==0 ){\n    pMem = *ppVal = sqlite3ValueNew(db);\n    if( pMem==0 ) return SQLITE_NOMEM_BKPT;\n  }\n  sqlite3VdbeSerialGet(&a[iField-szField], t, pMem);\n  pMem->enc = ENC(db);\n  return SQLITE_OK;\n}\n\n/*\n** Unless it is NULL, the argument must be an UnpackedRecord object returned\n** by an earlier call to sqlite3Stat4ProbeSetValue(). This call deletes\n** the object.\n*/\nSQLITE_PRIVATE void sqlite3Stat4ProbeFree(UnpackedRecord *pRec){\n  if( pRec ){\n    int i;\n    int nCol = pRec->pKeyInfo->nAllField;\n    Mem *aMem = pRec->aMem;\n    sqlite3 *db = aMem[0].db;\n    for(i=0; i<nCol; i++){\n      sqlite3VdbeMemRelease(&aMem[i]);\n    }\n    sqlite3KeyInfoUnref(pRec->pKeyInfo);\n    sqlite3DbFreeNN(db, pRec);\n  }\n}\n#endif /* ifdef SQLITE_ENABLE_STAT4 */\n\n/*\n** Change the string value of an sqlite3_value object\n*/\nSQLITE_PRIVATE void sqlite3ValueSetStr(\n  sqlite3_value *v,     /* Value to be set */\n  int n,                /* Length of string z */\n  const void *z,        /* Text of the new string */\n  u8 enc,               /* Encoding to use */\n  void (*xDel)(void*)   /* Destructor for the string */\n){\n  if( v ) sqlite3VdbeMemSetStr((Mem *)v, z, n, enc, xDel);\n}\n\n/*\n** Free an sqlite3_value object\n*/\nSQLITE_PRIVATE void sqlite3ValueFree(sqlite3_value *v){\n  if( !v ) return;\n  sqlite3VdbeMemRelease((Mem *)v);\n  sqlite3DbFreeNN(((Mem*)v)->db, v);\n}\n\n/*\n** The sqlite3ValueBytes() routine returns the number of bytes in the\n** sqlite3_value object assuming that it uses the encoding \"enc\".\n** The valueBytes() routine is a helper function.\n*/\nstatic SQLITE_NOINLINE int valueBytes(sqlite3_value *pVal, u8 enc){\n  return valueToText(pVal, enc)!=0 ? pVal->n : 0;\n}\nSQLITE_PRIVATE int sqlite3ValueBytes(sqlite3_value *pVal, u8 enc){\n  Mem *p = (Mem*)pVal;\n  assert( (p->flags & MEM_Null)==0 || (p->flags & (MEM_Str|MEM_Blob))==0 );\n  if( (p->flags & MEM_Str)!=0 && pVal->enc==enc ){\n    return p->n;\n  }\n  if( (p->flags & MEM_Blob)!=0 ){\n    if( p->flags & MEM_Zero ){\n      return p->n + p->u.nZero;\n    }else{\n      return p->n;\n    }\n  }\n  if( p->flags & MEM_Null ) return 0;\n  return valueBytes(pVal, enc);\n}\n\n/************** End of vdbemem.c *********************************************/\n/************** Begin file vdbeaux.c *****************************************/\n/*\n** 2003 September 6\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This file contains code used for creating, destroying, and populating\n** a VDBE (or an \"sqlite3_stmt\" as it is known to the outside world.) \n*/\n/* #include \"sqliteInt.h\" */\n/* #include \"vdbeInt.h\" */\n\n/*\n** Create a new virtual database engine.\n*/\nSQLITE_PRIVATE Vdbe *sqlite3VdbeCreate(Parse *pParse){\n  sqlite3 *db = pParse->db;\n  Vdbe *p;\n  p = sqlite3DbMallocRawNN(db, sizeof(Vdbe) );\n  if( p==0 ) return 0;\n  memset(&p->aOp, 0, sizeof(Vdbe)-offsetof(Vdbe,aOp));\n  p->db = db;\n  if( db->pVdbe ){\n    db->pVdbe->pPrev = p;\n  }\n  p->pNext = db->pVdbe;\n  p->pPrev = 0;\n  db->pVdbe = p;\n  p->magic = VDBE_MAGIC_INIT;\n  p->pParse = pParse;\n  pParse->pVdbe = p;\n  assert( pParse->aLabel==0 );\n  assert( pParse->nLabel==0 );\n  assert( p->nOpAlloc==0 );\n  assert( pParse->szOpAlloc==0 );\n  sqlite3VdbeAddOp2(p, OP_Init, 0, 1);\n  return p;\n}\n\n/*\n** Change the error string stored in Vdbe.zErrMsg\n*/\nSQLITE_PRIVATE void sqlite3VdbeError(Vdbe *p, const char *zFormat, ...){\n  va_list ap;\n  sqlite3DbFree(p->db, p->zErrMsg);\n  va_start(ap, zFormat);\n  p->zErrMsg = sqlite3VMPrintf(p->db, zFormat, ap);\n  va_end(ap);\n}\n\n/*\n** Remember the SQL string for a prepared statement.\n*/\nSQLITE_PRIVATE void sqlite3VdbeSetSql(Vdbe *p, const char *z, int n, u8 prepFlags){\n  if( p==0 ) return;\n  p->prepFlags = prepFlags;\n  if( (prepFlags & SQLITE_PREPARE_SAVESQL)==0 ){\n    p->expmask = 0;\n  }\n  assert( p->zSql==0 );\n  p->zSql = sqlite3DbStrNDup(p->db, z, n);\n}\n\n#ifdef SQLITE_ENABLE_NORMALIZE\n/*\n** Add a new element to the Vdbe->pDblStr list.\n*/\nSQLITE_PRIVATE void sqlite3VdbeAddDblquoteStr(sqlite3 *db, Vdbe *p, const char *z){\n  if( p ){\n    int n = sqlite3Strlen30(z);\n    DblquoteStr *pStr = sqlite3DbMallocRawNN(db,\n                            sizeof(*pStr)+n+1-sizeof(pStr->z));\n    if( pStr ){\n      pStr->pNextStr = p->pDblStr;\n      p->pDblStr = pStr;\n      memcpy(pStr->z, z, n+1);\n    }\n  }\n}\n#endif\n\n#ifdef SQLITE_ENABLE_NORMALIZE\n/*\n** zId of length nId is a double-quoted identifier.  Check to see if\n** that identifier is really used as a string literal.\n*/\nSQLITE_PRIVATE int sqlite3VdbeUsesDoubleQuotedString(\n  Vdbe *pVdbe,            /* The prepared statement */\n  const char *zId         /* The double-quoted identifier, already dequoted */\n){\n  DblquoteStr *pStr;\n  assert( zId!=0 );\n  if( pVdbe->pDblStr==0 ) return 0;\n  for(pStr=pVdbe->pDblStr; pStr; pStr=pStr->pNextStr){\n    if( strcmp(zId, pStr->z)==0 ) return 1;\n  }\n  return 0;\n}\n#endif\n\n/*\n** Swap all content between two VDBE structures.\n*/\nSQLITE_PRIVATE void sqlite3VdbeSwap(Vdbe *pA, Vdbe *pB){\n  Vdbe tmp, *pTmp;\n  char *zTmp;\n  assert( pA->db==pB->db );\n  tmp = *pA;\n  *pA = *pB;\n  *pB = tmp;\n  pTmp = pA->pNext;\n  pA->pNext = pB->pNext;\n  pB->pNext = pTmp;\n  pTmp = pA->pPrev;\n  pA->pPrev = pB->pPrev;\n  pB->pPrev = pTmp;\n  zTmp = pA->zSql;\n  pA->zSql = pB->zSql;\n  pB->zSql = zTmp;\n#if 0\n  zTmp = pA->zNormSql;\n  pA->zNormSql = pB->zNormSql;\n  pB->zNormSql = zTmp;\n#endif\n  pB->expmask = pA->expmask;\n  pB->prepFlags = pA->prepFlags;\n  memcpy(pB->aCounter, pA->aCounter, sizeof(pB->aCounter));\n  pB->aCounter[SQLITE_STMTSTATUS_REPREPARE]++;\n}\n\n/*\n** Resize the Vdbe.aOp array so that it is at least nOp elements larger \n** than its current size. nOp is guaranteed to be less than or equal\n** to 1024/sizeof(Op).\n**\n** If an out-of-memory error occurs while resizing the array, return\n** SQLITE_NOMEM. In this case Vdbe.aOp and Vdbe.nOpAlloc remain \n** unchanged (this is so that any opcodes already allocated can be \n** correctly deallocated along with the rest of the Vdbe).\n*/\nstatic int growOpArray(Vdbe *v, int nOp){\n  VdbeOp *pNew;\n  Parse *p = v->pParse;\n\n  /* The SQLITE_TEST_REALLOC_STRESS compile-time option is designed to force\n  ** more frequent reallocs and hence provide more opportunities for \n  ** simulated OOM faults.  SQLITE_TEST_REALLOC_STRESS is generally used\n  ** during testing only.  With SQLITE_TEST_REALLOC_STRESS grow the op array\n  ** by the minimum* amount required until the size reaches 512.  Normal\n  ** operation (without SQLITE_TEST_REALLOC_STRESS) is to double the current\n  ** size of the op array or add 1KB of space, whichever is smaller. */\n#ifdef SQLITE_TEST_REALLOC_STRESS\n  int nNew = (v->nOpAlloc>=512 ? v->nOpAlloc*2 : v->nOpAlloc+nOp);\n#else\n  int nNew = (v->nOpAlloc ? v->nOpAlloc*2 : (int)(1024/sizeof(Op)));\n  UNUSED_PARAMETER(nOp);\n#endif\n\n  /* Ensure that the size of a VDBE does not grow too large */\n  if( nNew > p->db->aLimit[SQLITE_LIMIT_VDBE_OP] ){\n    sqlite3OomFault(p->db);\n    return SQLITE_NOMEM;\n  }\n\n  assert( nOp<=(1024/sizeof(Op)) );\n  assert( nNew>=(v->nOpAlloc+nOp) );\n  pNew = sqlite3DbRealloc(p->db, v->aOp, nNew*sizeof(Op));\n  if( pNew ){\n    p->szOpAlloc = sqlite3DbMallocSize(p->db, pNew);\n    v->nOpAlloc = p->szOpAlloc/sizeof(Op);\n    v->aOp = pNew;\n  }\n  return (pNew ? SQLITE_OK : SQLITE_NOMEM_BKPT);\n}\n\n#ifdef SQLITE_DEBUG\n/* This routine is just a convenient place to set a breakpoint that will\n** fire after each opcode is inserted and displayed using\n** \"PRAGMA vdbe_addoptrace=on\".\n*/\nstatic void test_addop_breakpoint(void){\n  static int n = 0;\n  n++;\n}\n#endif\n\n/*\n** Add a new instruction to the list of instructions current in the\n** VDBE.  Return the address of the new instruction.\n**\n** Parameters:\n**\n**    p               Pointer to the VDBE\n**\n**    op              The opcode for this instruction\n**\n**    p1, p2, p3      Operands\n**\n** Use the sqlite3VdbeResolveLabel() function to fix an address and\n** the sqlite3VdbeChangeP4() function to change the value of the P4\n** operand.\n*/\nstatic SQLITE_NOINLINE int growOp3(Vdbe *p, int op, int p1, int p2, int p3){\n  assert( p->nOpAlloc<=p->nOp );\n  if( growOpArray(p, 1) ) return 1;\n  assert( p->nOpAlloc>p->nOp );\n  return sqlite3VdbeAddOp3(p, op, p1, p2, p3);\n}\nSQLITE_PRIVATE int sqlite3VdbeAddOp3(Vdbe *p, int op, int p1, int p2, int p3){\n  int i;\n  VdbeOp *pOp;\n\n  i = p->nOp;\n  assert( p->magic==VDBE_MAGIC_INIT );\n  assert( op>=0 && op<0xff );\n  if( p->nOpAlloc<=i ){\n    return growOp3(p, op, p1, p2, p3);\n  }\n  p->nOp++;\n  pOp = &p->aOp[i];\n  pOp->opcode = (u8)op;\n  pOp->p5 = 0;\n  pOp->p1 = p1;\n  pOp->p2 = p2;\n  pOp->p3 = p3;\n  pOp->p4.p = 0;\n  pOp->p4type = P4_NOTUSED;\n#ifdef SQLITE_ENABLE_EXPLAIN_COMMENTS\n  pOp->zComment = 0;\n#endif\n#ifdef SQLITE_DEBUG\n  if( p->db->flags & SQLITE_VdbeAddopTrace ){\n    sqlite3VdbePrintOp(0, i, &p->aOp[i]);\n    test_addop_breakpoint();\n  }\n#endif\n#ifdef VDBE_PROFILE\n  pOp->cycles = 0;\n  pOp->cnt = 0;\n#endif\n#ifdef SQLITE_VDBE_COVERAGE\n  pOp->iSrcLine = 0;\n#endif\n  return i;\n}\nSQLITE_PRIVATE int sqlite3VdbeAddOp0(Vdbe *p, int op){\n  return sqlite3VdbeAddOp3(p, op, 0, 0, 0);\n}\nSQLITE_PRIVATE int sqlite3VdbeAddOp1(Vdbe *p, int op, int p1){\n  return sqlite3VdbeAddOp3(p, op, p1, 0, 0);\n}\nSQLITE_PRIVATE int sqlite3VdbeAddOp2(Vdbe *p, int op, int p1, int p2){\n  return sqlite3VdbeAddOp3(p, op, p1, p2, 0);\n}\n\n/* Generate code for an unconditional jump to instruction iDest\n*/\nSQLITE_PRIVATE int sqlite3VdbeGoto(Vdbe *p, int iDest){\n  return sqlite3VdbeAddOp3(p, OP_Goto, 0, iDest, 0);\n}\n\n/* Generate code to cause the string zStr to be loaded into\n** register iDest\n*/\nSQLITE_PRIVATE int sqlite3VdbeLoadString(Vdbe *p, int iDest, const char *zStr){\n  return sqlite3VdbeAddOp4(p, OP_String8, 0, iDest, 0, zStr, 0);\n}\n\n/*\n** Generate code that initializes multiple registers to string or integer\n** constants.  The registers begin with iDest and increase consecutively.\n** One register is initialized for each characgter in zTypes[].  For each\n** \"s\" character in zTypes[], the register is a string if the argument is\n** not NULL, or OP_Null if the value is a null pointer.  For each \"i\" character\n** in zTypes[], the register is initialized to an integer.\n**\n** If the input string does not end with \"X\" then an OP_ResultRow instruction\n** is generated for the values inserted.\n*/\nSQLITE_PRIVATE void sqlite3VdbeMultiLoad(Vdbe *p, int iDest, const char *zTypes, ...){\n  va_list ap;\n  int i;\n  char c;\n  va_start(ap, zTypes);\n  for(i=0; (c = zTypes[i])!=0; i++){\n    if( c=='s' ){\n      const char *z = va_arg(ap, const char*);\n      sqlite3VdbeAddOp4(p, z==0 ? OP_Null : OP_String8, 0, iDest+i, 0, z, 0);\n    }else if( c=='i' ){\n      sqlite3VdbeAddOp2(p, OP_Integer, va_arg(ap, int), iDest+i);\n    }else{\n      goto skip_op_resultrow;\n    }\n  }\n  sqlite3VdbeAddOp2(p, OP_ResultRow, iDest, i);\nskip_op_resultrow:\n  va_end(ap);\n}\n\n/*\n** Add an opcode that includes the p4 value as a pointer.\n*/\nSQLITE_PRIVATE int sqlite3VdbeAddOp4(\n  Vdbe *p,            /* Add the opcode to this VM */\n  int op,             /* The new opcode */\n  int p1,             /* The P1 operand */\n  int p2,             /* The P2 operand */\n  int p3,             /* The P3 operand */\n  const char *zP4,    /* The P4 operand */\n  int p4type          /* P4 operand type */\n){\n  int addr = sqlite3VdbeAddOp3(p, op, p1, p2, p3);\n  sqlite3VdbeChangeP4(p, addr, zP4, p4type);\n  return addr;\n}\n\n/*\n** Add an opcode that includes the p4 value with a P4_INT64 or\n** P4_REAL type.\n*/\nSQLITE_PRIVATE int sqlite3VdbeAddOp4Dup8(\n  Vdbe *p,            /* Add the opcode to this VM */\n  int op,             /* The new opcode */\n  int p1,             /* The P1 operand */\n  int p2,             /* The P2 operand */\n  int p3,             /* The P3 operand */\n  const u8 *zP4,      /* The P4 operand */\n  int p4type          /* P4 operand type */\n){\n  char *p4copy = sqlite3DbMallocRawNN(sqlite3VdbeDb(p), 8);\n  if( p4copy ) memcpy(p4copy, zP4, 8);\n  return sqlite3VdbeAddOp4(p, op, p1, p2, p3, p4copy, p4type);\n}\n\n#ifndef SQLITE_OMIT_EXPLAIN\n/*\n** Return the address of the current EXPLAIN QUERY PLAN baseline.\n** 0 means \"none\".\n*/\nSQLITE_PRIVATE int sqlite3VdbeExplainParent(Parse *pParse){\n  VdbeOp *pOp;\n  if( pParse->addrExplain==0 ) return 0;\n  pOp = sqlite3VdbeGetOp(pParse->pVdbe, pParse->addrExplain);\n  return pOp->p2;\n}\n\n/*\n** Set a debugger breakpoint on the following routine in order to\n** monitor the EXPLAIN QUERY PLAN code generation.\n*/\n#if defined(SQLITE_DEBUG)\nSQLITE_PRIVATE void sqlite3ExplainBreakpoint(const char *z1, const char *z2){\n  (void)z1;\n  (void)z2;\n}\n#endif\n\n/*\n** Add a new OP_ opcode.\n**\n** If the bPush flag is true, then make this opcode the parent for\n** subsequent Explains until sqlite3VdbeExplainPop() is called.\n*/\nSQLITE_PRIVATE void sqlite3VdbeExplain(Parse *pParse, u8 bPush, const char *zFmt, ...){\n#ifndef SQLITE_DEBUG\n  /* Always include the OP_Explain opcodes if SQLITE_DEBUG is defined.\n  ** But omit them (for performance) during production builds */\n  if( pParse->explain==2 )\n#endif\n  {\n    char *zMsg;\n    Vdbe *v;\n    va_list ap;\n    int iThis;\n    va_start(ap, zFmt);\n    zMsg = sqlite3VMPrintf(pParse->db, zFmt, ap);\n    va_end(ap);\n    v = pParse->pVdbe;\n    iThis = v->nOp;\n    sqlite3VdbeAddOp4(v, OP_Explain, iThis, pParse->addrExplain, 0,\n                      zMsg, P4_DYNAMIC);\n    sqlite3ExplainBreakpoint(bPush?\"PUSH\":\"\", sqlite3VdbeGetOp(v,-1)->p4.z);\n    if( bPush){\n      pParse->addrExplain = iThis;\n    }\n  }\n}\n\n/*\n** Pop the EXPLAIN QUERY PLAN stack one level.\n*/\nSQLITE_PRIVATE void sqlite3VdbeExplainPop(Parse *pParse){\n  sqlite3ExplainBreakpoint(\"POP\", 0);\n  pParse->addrExplain = sqlite3VdbeExplainParent(pParse);\n}\n#endif /* SQLITE_OMIT_EXPLAIN */\n\n/*\n** Add an OP_ParseSchema opcode.  This routine is broken out from\n** sqlite3VdbeAddOp4() since it needs to also needs to mark all btrees\n** as having been used.\n**\n** The zWhere string must have been obtained from sqlite3_malloc().\n** This routine will take ownership of the allocated memory.\n*/\nSQLITE_PRIVATE void sqlite3VdbeAddParseSchemaOp(Vdbe *p, int iDb, char *zWhere){\n  int j;\n  sqlite3VdbeAddOp4(p, OP_ParseSchema, iDb, 0, 0, zWhere, P4_DYNAMIC);\n  for(j=0; j<p->db->nDb; j++) sqlite3VdbeUsesBtree(p, j);\n}\n\n/*\n** Add an opcode that includes the p4 value as an integer.\n*/\nSQLITE_PRIVATE int sqlite3VdbeAddOp4Int(\n  Vdbe *p,            /* Add the opcode to this VM */\n  int op,             /* The new opcode */\n  int p1,             /* The P1 operand */\n  int p2,             /* The P2 operand */\n  int p3,             /* The P3 operand */\n  int p4              /* The P4 operand as an integer */\n){\n  int addr = sqlite3VdbeAddOp3(p, op, p1, p2, p3);\n  if( p->db->mallocFailed==0 ){\n    VdbeOp *pOp = &p->aOp[addr];\n    pOp->p4type = P4_INT32;\n    pOp->p4.i = p4;\n  }\n  return addr;\n}\n\n/* Insert the end of a co-routine\n*/\nSQLITE_PRIVATE void sqlite3VdbeEndCoroutine(Vdbe *v, int regYield){\n  sqlite3VdbeAddOp1(v, OP_EndCoroutine, regYield);\n\n  /* Clear the temporary register cache, thereby ensuring that each\n  ** co-routine has its own independent set of registers, because co-routines\n  ** might expect their registers to be preserved across an OP_Yield, and\n  ** that could cause problems if two or more co-routines are using the same\n  ** temporary register.\n  */\n  v->pParse->nTempReg = 0;\n  v->pParse->nRangeReg = 0;\n}\n\n/*\n** Create a new symbolic label for an instruction that has yet to be\n** coded.  The symbolic label is really just a negative number.  The\n** label can be used as the P2 value of an operation.  Later, when\n** the label is resolved to a specific address, the VDBE will scan\n** through its operation list and change all values of P2 which match\n** the label into the resolved address.\n**\n** The VDBE knows that a P2 value is a label because labels are\n** always negative and P2 values are suppose to be non-negative.\n** Hence, a negative P2 value is a label that has yet to be resolved.\n** (Later:) This is only true for opcodes that have the OPFLG_JUMP\n** property.\n**\n** Variable usage notes:\n**\n**     Parse.aLabel[x]     Stores the address that the x-th label resolves\n**                         into.  For testing (SQLITE_DEBUG), unresolved\n**                         labels stores -1, but that is not required.\n**     Parse.nLabelAlloc   Number of slots allocated to Parse.aLabel[]\n**     Parse.nLabel        The *negative* of the number of labels that have\n**                         been issued.  The negative is stored because\n**                         that gives a performance improvement over storing\n**                         the equivalent positive value.\n*/\nSQLITE_PRIVATE int sqlite3VdbeMakeLabel(Parse *pParse){\n  return --pParse->nLabel;\n}\n\n/*\n** Resolve label \"x\" to be the address of the next instruction to\n** be inserted.  The parameter \"x\" must have been obtained from\n** a prior call to sqlite3VdbeMakeLabel().\n*/\nstatic SQLITE_NOINLINE void resizeResolveLabel(Parse *p, Vdbe *v, int j){\n  int nNewSize = 10 - p->nLabel;\n  p->aLabel = sqlite3DbReallocOrFree(p->db, p->aLabel,\n                     nNewSize*sizeof(p->aLabel[0]));\n  if( p->aLabel==0 ){\n    p->nLabelAlloc = 0;\n  }else{\n#ifdef SQLITE_DEBUG\n    int i;\n    for(i=p->nLabelAlloc; i<nNewSize; i++) p->aLabel[i] = -1;\n#endif\n    p->nLabelAlloc = nNewSize;\n    p->aLabel[j] = v->nOp;\n  }\n}\nSQLITE_PRIVATE void sqlite3VdbeResolveLabel(Vdbe *v, int x){\n  Parse *p = v->pParse;\n  int j = ADDR(x);\n  assert( v->magic==VDBE_MAGIC_INIT );\n  assert( j<-p->nLabel );\n  assert( j>=0 );\n#ifdef SQLITE_DEBUG\n  if( p->db->flags & SQLITE_VdbeAddopTrace ){\n    printf(\"RESOLVE LABEL %d to %d\\n\", x, v->nOp);\n  }\n#endif\n  if( p->nLabelAlloc + p->nLabel < 0 ){\n    resizeResolveLabel(p,v,j);\n  }else{\n    assert( p->aLabel[j]==(-1) ); /* Labels may only be resolved once */\n    p->aLabel[j] = v->nOp;\n  }\n}\n\n/*\n** Mark the VDBE as one that can only be run one time.\n*/\nSQLITE_PRIVATE void sqlite3VdbeRunOnlyOnce(Vdbe *p){\n  p->runOnlyOnce = 1;\n}\n\n/*\n** Mark the VDBE as one that can only be run multiple times.\n*/\nSQLITE_PRIVATE void sqlite3VdbeReusable(Vdbe *p){\n  p->runOnlyOnce = 0;\n}\n\n#ifdef SQLITE_DEBUG /* sqlite3AssertMayAbort() logic */\n\n/*\n** The following type and function are used to iterate through all opcodes\n** in a Vdbe main program and each of the sub-programs (triggers) it may \n** invoke directly or indirectly. It should be used as follows:\n**\n**   Op *pOp;\n**   VdbeOpIter sIter;\n**\n**   memset(&sIter, 0, sizeof(sIter));\n**   sIter.v = v;                            // v is of type Vdbe* \n**   while( (pOp = opIterNext(&sIter)) ){\n**     // Do something with pOp\n**   }\n**   sqlite3DbFree(v->db, sIter.apSub);\n** \n*/\ntypedef struct VdbeOpIter VdbeOpIter;\nstruct VdbeOpIter {\n  Vdbe *v;                   /* Vdbe to iterate through the opcodes of */\n  SubProgram **apSub;        /* Array of subprograms */\n  int nSub;                  /* Number of entries in apSub */\n  int iAddr;                 /* Address of next instruction to return */\n  int iSub;                  /* 0 = main program, 1 = first sub-program etc. */\n};\nstatic Op *opIterNext(VdbeOpIter *p){\n  Vdbe *v = p->v;\n  Op *pRet = 0;\n  Op *aOp;\n  int nOp;\n\n  if( p->iSub<=p->nSub ){\n\n    if( p->iSub==0 ){\n      aOp = v->aOp;\n      nOp = v->nOp;\n    }else{\n      aOp = p->apSub[p->iSub-1]->aOp;\n      nOp = p->apSub[p->iSub-1]->nOp;\n    }\n    assert( p->iAddr<nOp );\n\n    pRet = &aOp[p->iAddr];\n    p->iAddr++;\n    if( p->iAddr==nOp ){\n      p->iSub++;\n      p->iAddr = 0;\n    }\n  \n    if( pRet->p4type==P4_SUBPROGRAM ){\n      int nByte = (p->nSub+1)*sizeof(SubProgram*);\n      int j;\n      for(j=0; j<p->nSub; j++){\n        if( p->apSub[j]==pRet->p4.pProgram ) break;\n      }\n      if( j==p->nSub ){\n        p->apSub = sqlite3DbReallocOrFree(v->db, p->apSub, nByte);\n        if( !p->apSub ){\n          pRet = 0;\n        }else{\n          p->apSub[p->nSub++] = pRet->p4.pProgram;\n        }\n      }\n    }\n  }\n\n  return pRet;\n}\n\n/*\n** Check if the program stored in the VM associated with pParse may\n** throw an ABORT exception (causing the statement, but not entire transaction\n** to be rolled back). This condition is true if the main program or any\n** sub-programs contains any of the following:\n**\n**   *  OP_Halt with P1=SQLITE_CONSTRAINT and P2=OE_Abort.\n**   *  OP_HaltIfNull with P1=SQLITE_CONSTRAINT and P2=OE_Abort.\n**   *  OP_Destroy\n**   *  OP_VUpdate\n**   *  OP_VRename\n**   *  OP_FkCounter with P2==0 (immediate foreign key constraint)\n**   *  OP_CreateBtree/BTREE_INTKEY and OP_InitCoroutine \n**      (for CREATE TABLE AS SELECT ...)\n**\n** Then check that the value of Parse.mayAbort is true if an\n** ABORT may be thrown, or false otherwise. Return true if it does\n** match, or false otherwise. This function is intended to be used as\n** part of an assert statement in the compiler. Similar to:\n**\n**   assert( sqlite3VdbeAssertMayAbort(pParse->pVdbe, pParse->mayAbort) );\n*/\nSQLITE_PRIVATE int sqlite3VdbeAssertMayAbort(Vdbe *v, int mayAbort){\n  int hasAbort = 0;\n  int hasFkCounter = 0;\n  int hasCreateTable = 0;\n  int hasInitCoroutine = 0;\n  Op *pOp;\n  VdbeOpIter sIter;\n  memset(&sIter, 0, sizeof(sIter));\n  sIter.v = v;\n\n  while( (pOp = opIterNext(&sIter))!=0 ){\n    int opcode = pOp->opcode;\n    if( opcode==OP_Destroy || opcode==OP_VUpdate || opcode==OP_VRename \n     || opcode==OP_VDestroy\n     || ((opcode==OP_Halt || opcode==OP_HaltIfNull) \n      && ((pOp->p1)!=SQLITE_OK && pOp->p2==OE_Abort))\n    ){\n      hasAbort = 1;\n      break;\n    }\n    if( opcode==OP_CreateBtree && pOp->p3==BTREE_INTKEY ) hasCreateTable = 1;\n    if( opcode==OP_InitCoroutine ) hasInitCoroutine = 1;\n#ifndef SQLITE_OMIT_FOREIGN_KEY\n    if( opcode==OP_FkCounter && pOp->p1==0 && pOp->p2==1 ){\n      hasFkCounter = 1;\n    }\n#endif\n  }\n  sqlite3DbFree(v->db, sIter.apSub);\n\n  /* Return true if hasAbort==mayAbort. Or if a malloc failure occurred.\n  ** If malloc failed, then the while() loop above may not have iterated\n  ** through all opcodes and hasAbort may be set incorrectly. Return\n  ** true for this case to prevent the assert() in the callers frame\n  ** from failing.  */\n  return ( v->db->mallocFailed || hasAbort==mayAbort || hasFkCounter\n              || (hasCreateTable && hasInitCoroutine) );\n}\n#endif /* SQLITE_DEBUG - the sqlite3AssertMayAbort() function */\n\n#ifdef SQLITE_DEBUG\n/*\n** Increment the nWrite counter in the VDBE if the cursor is not an\n** ephemeral cursor, or if the cursor argument is NULL.\n*/\nSQLITE_PRIVATE void sqlite3VdbeIncrWriteCounter(Vdbe *p, VdbeCursor *pC){\n  if( pC==0\n   || (pC->eCurType!=CURTYPE_SORTER\n       && pC->eCurType!=CURTYPE_PSEUDO\n       && !pC->isEphemeral)\n  ){\n    p->nWrite++;\n  }\n}\n#endif\n\n#ifdef SQLITE_DEBUG\n/*\n** Assert if an Abort at this point in time might result in a corrupt\n** database.\n*/\nSQLITE_PRIVATE void sqlite3VdbeAssertAbortable(Vdbe *p){\n  assert( p->nWrite==0 || p->usesStmtJournal );\n}\n#endif\n\n/*\n** This routine is called after all opcodes have been inserted.  It loops\n** through all the opcodes and fixes up some details.\n**\n** (1) For each jump instruction with a negative P2 value (a label)\n**     resolve the P2 value to an actual address.\n**\n** (2) Compute the maximum number of arguments used by any SQL function\n**     and store that value in *pMaxFuncArgs.\n**\n** (3) Update the Vdbe.readOnly and Vdbe.bIsReader flags to accurately\n**     indicate what the prepared statement actually does.\n**\n** (4) Initialize the p4.xAdvance pointer on opcodes that use it.\n**\n** (5) Reclaim the memory allocated for storing labels.\n**\n** This routine will only function correctly if the mkopcodeh.tcl generator\n** script numbers the opcodes correctly.  Changes to this routine must be\n** coordinated with changes to mkopcodeh.tcl.\n*/\nstatic void resolveP2Values(Vdbe *p, int *pMaxFuncArgs){\n  int nMaxArgs = *pMaxFuncArgs;\n  Op *pOp;\n  Parse *pParse = p->pParse;\n  int *aLabel = pParse->aLabel;\n  p->readOnly = 1;\n  p->bIsReader = 0;\n  pOp = &p->aOp[p->nOp-1];\n  while(1){\n\n    /* Only JUMP opcodes and the short list of special opcodes in the switch\n    ** below need to be considered.  The mkopcodeh.tcl generator script groups\n    ** all these opcodes together near the front of the opcode list.  Skip\n    ** any opcode that does not need processing by virtual of the fact that\n    ** it is larger than SQLITE_MX_JUMP_OPCODE, as a performance optimization.\n    */\n    if( pOp->opcode<=SQLITE_MX_JUMP_OPCODE ){\n      /* NOTE: Be sure to update mkopcodeh.tcl when adding or removing\n      ** cases from this switch! */\n      switch( pOp->opcode ){\n        case OP_Transaction: {\n          if( pOp->p2!=0 ) p->readOnly = 0;\n          /* fall thru */\n        }\n        case OP_AutoCommit:\n        case OP_Savepoint: {\n          p->bIsReader = 1;\n          break;\n        }\n#ifndef SQLITE_OMIT_WAL\n        case OP_Checkpoint:\n#endif\n        case OP_Vacuum:\n        case OP_JournalMode: {\n          p->readOnly = 0;\n          p->bIsReader = 1;\n          break;\n        }\n        case OP_Next:\n        case OP_SorterNext: {\n          pOp->p4.xAdvance = sqlite3BtreeNext;\n          pOp->p4type = P4_ADVANCE;\n          /* The code generator never codes any of these opcodes as a jump\n          ** to a label.  They are always coded as a jump backwards to a \n          ** known address */\n          assert( pOp->p2>=0 );\n          break;\n        }\n        case OP_Prev: {\n          pOp->p4.xAdvance = sqlite3BtreePrevious;\n          pOp->p4type = P4_ADVANCE;\n          /* The code generator never codes any of these opcodes as a jump\n          ** to a label.  They are always coded as a jump backwards to a \n          ** known address */\n          assert( pOp->p2>=0 );\n          break;\n        }\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n        case OP_VUpdate: {\n          if( pOp->p2>nMaxArgs ) nMaxArgs = pOp->p2;\n          break;\n        }\n        case OP_VFilter: {\n          int n;\n          assert( (pOp - p->aOp) >= 3 );\n          assert( pOp[-1].opcode==OP_Integer );\n          n = pOp[-1].p1;\n          if( n>nMaxArgs ) nMaxArgs = n;\n          /* Fall through into the default case */\n        }\n#endif\n        default: {\n          if( pOp->p2<0 ){\n            /* The mkopcodeh.tcl script has so arranged things that the only\n            ** non-jump opcodes less than SQLITE_MX_JUMP_CODE are guaranteed to\n            ** have non-negative values for P2. */\n            assert( (sqlite3OpcodeProperty[pOp->opcode] & OPFLG_JUMP)!=0 );\n            assert( ADDR(pOp->p2)<-pParse->nLabel );\n            pOp->p2 = aLabel[ADDR(pOp->p2)];\n          }\n          break;\n        }\n      }\n      /* The mkopcodeh.tcl script has so arranged things that the only\n      ** non-jump opcodes less than SQLITE_MX_JUMP_CODE are guaranteed to\n      ** have non-negative values for P2. */\n      assert( (sqlite3OpcodeProperty[pOp->opcode]&OPFLG_JUMP)==0 || pOp->p2>=0);\n    }\n    if( pOp==p->aOp ) break;\n    pOp--;\n  }\n  sqlite3DbFree(p->db, pParse->aLabel);\n  pParse->aLabel = 0;\n  pParse->nLabel = 0;\n  *pMaxFuncArgs = nMaxArgs;\n  assert( p->bIsReader!=0 || DbMaskAllZero(p->btreeMask) );\n}\n\n/*\n** Return the address of the next instruction to be inserted.\n*/\nSQLITE_PRIVATE int sqlite3VdbeCurrentAddr(Vdbe *p){\n  assert( p->magic==VDBE_MAGIC_INIT );\n  return p->nOp;\n}\n\n/*\n** Verify that at least N opcode slots are available in p without\n** having to malloc for more space (except when compiled using\n** SQLITE_TEST_REALLOC_STRESS).  This interface is used during testing\n** to verify that certain calls to sqlite3VdbeAddOpList() can never\n** fail due to a OOM fault and hence that the return value from\n** sqlite3VdbeAddOpList() will always be non-NULL.\n*/\n#if defined(SQLITE_DEBUG) && !defined(SQLITE_TEST_REALLOC_STRESS)\nSQLITE_PRIVATE void sqlite3VdbeVerifyNoMallocRequired(Vdbe *p, int N){\n  assert( p->nOp + N <= p->nOpAlloc );\n}\n#endif\n\n/*\n** Verify that the VM passed as the only argument does not contain\n** an OP_ResultRow opcode. Fail an assert() if it does. This is used\n** by code in pragma.c to ensure that the implementation of certain\n** pragmas comports with the flags specified in the mkpragmatab.tcl\n** script.\n*/\n#if defined(SQLITE_DEBUG) && !defined(SQLITE_TEST_REALLOC_STRESS)\nSQLITE_PRIVATE void sqlite3VdbeVerifyNoResultRow(Vdbe *p){\n  int i;\n  for(i=0; i<p->nOp; i++){\n    assert( p->aOp[i].opcode!=OP_ResultRow );\n  }\n}\n#endif\n\n/*\n** Generate code (a single OP_Abortable opcode) that will\n** verify that the VDBE program can safely call Abort in the current\n** context.\n*/\n#if defined(SQLITE_DEBUG)\nSQLITE_PRIVATE void sqlite3VdbeVerifyAbortable(Vdbe *p, int onError){\n  if( onError==OE_Abort ) sqlite3VdbeAddOp0(p, OP_Abortable);\n}\n#endif\n\n/*\n** This function returns a pointer to the array of opcodes associated with\n** the Vdbe passed as the first argument. It is the callers responsibility\n** to arrange for the returned array to be eventually freed using the \n** vdbeFreeOpArray() function.\n**\n** Before returning, *pnOp is set to the number of entries in the returned\n** array. Also, *pnMaxArg is set to the larger of its current value and \n** the number of entries in the Vdbe.apArg[] array required to execute the \n** returned program.\n*/\nSQLITE_PRIVATE VdbeOp *sqlite3VdbeTakeOpArray(Vdbe *p, int *pnOp, int *pnMaxArg){\n  VdbeOp *aOp = p->aOp;\n  assert( aOp && !p->db->mallocFailed );\n\n  /* Check that sqlite3VdbeUsesBtree() was not called on this VM */\n  assert( DbMaskAllZero(p->btreeMask) );\n\n  resolveP2Values(p, pnMaxArg);\n  *pnOp = p->nOp;\n  p->aOp = 0;\n  return aOp;\n}\n\n/*\n** Add a whole list of operations to the operation stack.  Return a\n** pointer to the first operation inserted.\n**\n** Non-zero P2 arguments to jump instructions are automatically adjusted\n** so that the jump target is relative to the first operation inserted.\n*/\nSQLITE_PRIVATE VdbeOp *sqlite3VdbeAddOpList(\n  Vdbe *p,                     /* Add opcodes to the prepared statement */\n  int nOp,                     /* Number of opcodes to add */\n  VdbeOpList const *aOp,       /* The opcodes to be added */\n  int iLineno                  /* Source-file line number of first opcode */\n){\n  int i;\n  VdbeOp *pOut, *pFirst;\n  assert( nOp>0 );\n  assert( p->magic==VDBE_MAGIC_INIT );\n  if( p->nOp + nOp > p->nOpAlloc && growOpArray(p, nOp) ){\n    return 0;\n  }\n  pFirst = pOut = &p->aOp[p->nOp];\n  for(i=0; i<nOp; i++, aOp++, pOut++){\n    pOut->opcode = aOp->opcode;\n    pOut->p1 = aOp->p1;\n    pOut->p2 = aOp->p2;\n    assert( aOp->p2>=0 );\n    if( (sqlite3OpcodeProperty[aOp->opcode] & OPFLG_JUMP)!=0 && aOp->p2>0 ){\n      pOut->p2 += p->nOp;\n    }\n    pOut->p3 = aOp->p3;\n    pOut->p4type = P4_NOTUSED;\n    pOut->p4.p = 0;\n    pOut->p5 = 0;\n#ifdef SQLITE_ENABLE_EXPLAIN_COMMENTS\n    pOut->zComment = 0;\n#endif\n#ifdef SQLITE_VDBE_COVERAGE\n    pOut->iSrcLine = iLineno+i;\n#else\n    (void)iLineno;\n#endif\n#ifdef SQLITE_DEBUG\n    if( p->db->flags & SQLITE_VdbeAddopTrace ){\n      sqlite3VdbePrintOp(0, i+p->nOp, &p->aOp[i+p->nOp]);\n    }\n#endif\n  }\n  p->nOp += nOp;\n  return pFirst;\n}\n\n#if defined(SQLITE_ENABLE_STMT_SCANSTATUS)\n/*\n** Add an entry to the array of counters managed by sqlite3_stmt_scanstatus().\n*/\nSQLITE_PRIVATE void sqlite3VdbeScanStatus(\n  Vdbe *p,                        /* VM to add scanstatus() to */\n  int addrExplain,                /* Address of OP_Explain (or 0) */\n  int addrLoop,                   /* Address of loop counter */ \n  int addrVisit,                  /* Address of rows visited counter */\n  LogEst nEst,                    /* Estimated number of output rows */\n  const char *zName               /* Name of table or index being scanned */\n){\n  int nByte = (p->nScan+1) * sizeof(ScanStatus);\n  ScanStatus *aNew;\n  aNew = (ScanStatus*)sqlite3DbRealloc(p->db, p->aScan, nByte);\n  if( aNew ){\n    ScanStatus *pNew = &aNew[p->nScan++];\n    pNew->addrExplain = addrExplain;\n    pNew->addrLoop = addrLoop;\n    pNew->addrVisit = addrVisit;\n    pNew->nEst = nEst;\n    pNew->zName = sqlite3DbStrDup(p->db, zName);\n    p->aScan = aNew;\n  }\n}\n#endif\n\n\n/*\n** Change the value of the opcode, or P1, P2, P3, or P5 operands\n** for a specific instruction.\n*/\nSQLITE_PRIVATE void sqlite3VdbeChangeOpcode(Vdbe *p, u32 addr, u8 iNewOpcode){\n  sqlite3VdbeGetOp(p,addr)->opcode = iNewOpcode;\n}\nSQLITE_PRIVATE void sqlite3VdbeChangeP1(Vdbe *p, u32 addr, int val){\n  sqlite3VdbeGetOp(p,addr)->p1 = val;\n}\nSQLITE_PRIVATE void sqlite3VdbeChangeP2(Vdbe *p, u32 addr, int val){\n  sqlite3VdbeGetOp(p,addr)->p2 = val;\n}\nSQLITE_PRIVATE void sqlite3VdbeChangeP3(Vdbe *p, u32 addr, int val){\n  sqlite3VdbeGetOp(p,addr)->p3 = val;\n}\nSQLITE_PRIVATE void sqlite3VdbeChangeP5(Vdbe *p, u16 p5){\n  assert( p->nOp>0 || p->db->mallocFailed );\n  if( p->nOp>0 ) p->aOp[p->nOp-1].p5 = p5;\n}\n\n/*\n** Change the P2 operand of instruction addr so that it points to\n** the address of the next instruction to be coded.\n*/\nSQLITE_PRIVATE void sqlite3VdbeJumpHere(Vdbe *p, int addr){\n  sqlite3VdbeChangeP2(p, addr, p->nOp);\n}\n\n\n/*\n** If the input FuncDef structure is ephemeral, then free it.  If\n** the FuncDef is not ephermal, then do nothing.\n*/\nstatic void freeEphemeralFunction(sqlite3 *db, FuncDef *pDef){\n  if( (pDef->funcFlags & SQLITE_FUNC_EPHEM)!=0 ){\n    sqlite3DbFreeNN(db, pDef);\n  }\n}\n\nstatic void vdbeFreeOpArray(sqlite3 *, Op *, int);\n\n/*\n** Delete a P4 value if necessary.\n*/\nstatic SQLITE_NOINLINE void freeP4Mem(sqlite3 *db, Mem *p){\n  if( p->szMalloc ) sqlite3DbFree(db, p->zMalloc);\n  sqlite3DbFreeNN(db, p);\n}\nstatic SQLITE_NOINLINE void freeP4FuncCtx(sqlite3 *db, sqlite3_context *p){\n  freeEphemeralFunction(db, p->pFunc);\n sqlite3DbFreeNN(db, p);\n}\nstatic void freeP4(sqlite3 *db, int p4type, void *p4){\n  assert( db );\n  switch( p4type ){\n    case P4_FUNCCTX: {\n      freeP4FuncCtx(db, (sqlite3_context*)p4);\n      break;\n    }\n    case P4_REAL:\n    case P4_INT64:\n    case P4_DYNAMIC:\n    case P4_DYNBLOB:\n    case P4_INTARRAY: {\n      sqlite3DbFree(db, p4);\n      break;\n    }\n    case P4_KEYINFO: {\n      if( db->pnBytesFreed==0 ) sqlite3KeyInfoUnref((KeyInfo*)p4);\n      break;\n    }\n#ifdef SQLITE_ENABLE_CURSOR_HINTS\n    case P4_EXPR: {\n      sqlite3ExprDelete(db, (Expr*)p4);\n      break;\n    }\n#endif\n    case P4_FUNCDEF: {\n      freeEphemeralFunction(db, (FuncDef*)p4);\n      break;\n    }\n    case P4_MEM: {\n      if( db->pnBytesFreed==0 ){\n        sqlite3ValueFree((sqlite3_value*)p4);\n      }else{\n        freeP4Mem(db, (Mem*)p4);\n      }\n      break;\n    }\n    case P4_VTAB : {\n      if( db->pnBytesFreed==0 ) sqlite3VtabUnlock((VTable *)p4);\n      break;\n    }\n  }\n}\n\n/*\n** Free the space allocated for aOp and any p4 values allocated for the\n** opcodes contained within. If aOp is not NULL it is assumed to contain \n** nOp entries. \n*/\nstatic void vdbeFreeOpArray(sqlite3 *db, Op *aOp, int nOp){\n  if( aOp ){\n    Op *pOp;\n    for(pOp=&aOp[nOp-1]; pOp>=aOp; pOp--){\n      if( pOp->p4type <= P4_FREE_IF_LE ) freeP4(db, pOp->p4type, pOp->p4.p);\n#ifdef SQLITE_ENABLE_EXPLAIN_COMMENTS\n      sqlite3DbFree(db, pOp->zComment);\n#endif     \n    }\n    sqlite3DbFreeNN(db, aOp);\n  }\n}\n\n/*\n** Link the SubProgram object passed as the second argument into the linked\n** list at Vdbe.pSubProgram. This list is used to delete all sub-program\n** objects when the VM is no longer required.\n*/\nSQLITE_PRIVATE void sqlite3VdbeLinkSubProgram(Vdbe *pVdbe, SubProgram *p){\n  p->pNext = pVdbe->pProgram;\n  pVdbe->pProgram = p;\n}\n\n/*\n** Change the opcode at addr into OP_Noop\n*/\nSQLITE_PRIVATE int sqlite3VdbeChangeToNoop(Vdbe *p, int addr){\n  VdbeOp *pOp;\n  if( p->db->mallocFailed ) return 0;\n  assert( addr>=0 && addr<p->nOp );\n  pOp = &p->aOp[addr];\n  freeP4(p->db, pOp->p4type, pOp->p4.p);\n  pOp->p4type = P4_NOTUSED;\n  pOp->p4.z = 0;\n  pOp->opcode = OP_Noop;\n  return 1;\n}\n\n/*\n** If the last opcode is \"op\" and it is not a jump destination,\n** then remove it.  Return true if and only if an opcode was removed.\n*/\nSQLITE_PRIVATE int sqlite3VdbeDeletePriorOpcode(Vdbe *p, u8 op){\n  if( p->nOp>0 && p->aOp[p->nOp-1].opcode==op ){\n    return sqlite3VdbeChangeToNoop(p, p->nOp-1);\n  }else{\n    return 0;\n  }\n}\n\n/*\n** Change the value of the P4 operand for a specific instruction.\n** This routine is useful when a large program is loaded from a\n** static array using sqlite3VdbeAddOpList but we want to make a\n** few minor changes to the program.\n**\n** If n>=0 then the P4 operand is dynamic, meaning that a copy of\n** the string is made into memory obtained from sqlite3_malloc().\n** A value of n==0 means copy bytes of zP4 up to and including the\n** first null byte.  If n>0 then copy n+1 bytes of zP4.\n** \n** Other values of n (P4_STATIC, P4_COLLSEQ etc.) indicate that zP4 points\n** to a string or structure that is guaranteed to exist for the lifetime of\n** the Vdbe. In these cases we can just copy the pointer.\n**\n** If addr<0 then change P4 on the most recently inserted instruction.\n*/\nstatic void SQLITE_NOINLINE vdbeChangeP4Full(\n  Vdbe *p,\n  Op *pOp,\n  const char *zP4,\n  int n\n){\n  if( pOp->p4type ){\n    freeP4(p->db, pOp->p4type, pOp->p4.p);\n    pOp->p4type = 0;\n    pOp->p4.p = 0;\n  }\n  if( n<0 ){\n    sqlite3VdbeChangeP4(p, (int)(pOp - p->aOp), zP4, n);\n  }else{\n    if( n==0 ) n = sqlite3Strlen30(zP4);\n    pOp->p4.z = sqlite3DbStrNDup(p->db, zP4, n);\n    pOp->p4type = P4_DYNAMIC;\n  }\n}\nSQLITE_PRIVATE void sqlite3VdbeChangeP4(Vdbe *p, int addr, const char *zP4, int n){\n  Op *pOp;\n  sqlite3 *db;\n  assert( p!=0 );\n  db = p->db;\n  assert( p->magic==VDBE_MAGIC_INIT );\n  assert( p->aOp!=0 || db->mallocFailed );\n  if( db->mallocFailed ){\n    if( n!=P4_VTAB ) freeP4(db, n, (void*)*(char**)&zP4);\n    return;\n  }\n  assert( p->nOp>0 );\n  assert( addr<p->nOp );\n  if( addr<0 ){\n    addr = p->nOp - 1;\n  }\n  pOp = &p->aOp[addr];\n  if( n>=0 || pOp->p4type ){\n    vdbeChangeP4Full(p, pOp, zP4, n);\n    return;\n  }\n  if( n==P4_INT32 ){\n    /* Note: this cast is safe, because the origin data point was an int\n    ** that was cast to a (const char *). */\n    pOp->p4.i = SQLITE_PTR_TO_INT(zP4);\n    pOp->p4type = P4_INT32;\n  }else if( zP4!=0 ){\n    assert( n<0 );\n    pOp->p4.p = (void*)zP4;\n    pOp->p4type = (signed char)n;\n    if( n==P4_VTAB ) sqlite3VtabLock((VTable*)zP4);\n  }\n}\n\n/*\n** Change the P4 operand of the most recently coded instruction \n** to the value defined by the arguments.  This is a high-speed\n** version of sqlite3VdbeChangeP4().\n**\n** The P4 operand must not have been previously defined.  And the new\n** P4 must not be P4_INT32.  Use sqlite3VdbeChangeP4() in either of\n** those cases.\n*/\nSQLITE_PRIVATE void sqlite3VdbeAppendP4(Vdbe *p, void *pP4, int n){\n  VdbeOp *pOp;\n  assert( n!=P4_INT32 && n!=P4_VTAB );\n  assert( n<=0 );\n  if( p->db->mallocFailed ){\n    freeP4(p->db, n, pP4);\n  }else{\n    assert( pP4!=0 );\n    assert( p->nOp>0 );\n    pOp = &p->aOp[p->nOp-1];\n    assert( pOp->p4type==P4_NOTUSED );\n    pOp->p4type = n;\n    pOp->p4.p = pP4;\n  }\n}\n\n/*\n** Set the P4 on the most recently added opcode to the KeyInfo for the\n** index given.\n*/\nSQLITE_PRIVATE void sqlite3VdbeSetP4KeyInfo(Parse *pParse, Index *pIdx){\n  Vdbe *v = pParse->pVdbe;\n  KeyInfo *pKeyInfo;\n  assert( v!=0 );\n  assert( pIdx!=0 );\n  pKeyInfo = sqlite3KeyInfoOfIndex(pParse, pIdx);\n  if( pKeyInfo ) sqlite3VdbeAppendP4(v, pKeyInfo, P4_KEYINFO);\n}\n\n#ifdef SQLITE_ENABLE_EXPLAIN_COMMENTS\n/*\n** Change the comment on the most recently coded instruction.  Or\n** insert a No-op and add the comment to that new instruction.  This\n** makes the code easier to read during debugging.  None of this happens\n** in a production build.\n*/\nstatic void vdbeVComment(Vdbe *p, const char *zFormat, va_list ap){\n  assert( p->nOp>0 || p->aOp==0 );\n  assert( p->aOp==0 || p->aOp[p->nOp-1].zComment==0 || p->db->mallocFailed );\n  if( p->nOp ){\n    assert( p->aOp );\n    sqlite3DbFree(p->db, p->aOp[p->nOp-1].zComment);\n    p->aOp[p->nOp-1].zComment = sqlite3VMPrintf(p->db, zFormat, ap);\n  }\n}\nSQLITE_PRIVATE void sqlite3VdbeComment(Vdbe *p, const char *zFormat, ...){\n  va_list ap;\n  if( p ){\n    va_start(ap, zFormat);\n    vdbeVComment(p, zFormat, ap);\n    va_end(ap);\n  }\n}\nSQLITE_PRIVATE void sqlite3VdbeNoopComment(Vdbe *p, const char *zFormat, ...){\n  va_list ap;\n  if( p ){\n    sqlite3VdbeAddOp0(p, OP_Noop);\n    va_start(ap, zFormat);\n    vdbeVComment(p, zFormat, ap);\n    va_end(ap);\n  }\n}\n#endif  /* NDEBUG */\n\n#ifdef SQLITE_VDBE_COVERAGE\n/*\n** Set the value if the iSrcLine field for the previously coded instruction.\n*/\nSQLITE_PRIVATE void sqlite3VdbeSetLineNumber(Vdbe *v, int iLine){\n  sqlite3VdbeGetOp(v,-1)->iSrcLine = iLine;\n}\n#endif /* SQLITE_VDBE_COVERAGE */\n\n/*\n** Return the opcode for a given address.  If the address is -1, then\n** return the most recently inserted opcode.\n**\n** If a memory allocation error has occurred prior to the calling of this\n** routine, then a pointer to a dummy VdbeOp will be returned.  That opcode\n** is readable but not writable, though it is cast to a writable value.\n** The return of a dummy opcode allows the call to continue functioning\n** after an OOM fault without having to check to see if the return from \n** this routine is a valid pointer.  But because the dummy.opcode is 0,\n** dummy will never be written to.  This is verified by code inspection and\n** by running with Valgrind.\n*/\nSQLITE_PRIVATE VdbeOp *sqlite3VdbeGetOp(Vdbe *p, int addr){\n  /* C89 specifies that the constant \"dummy\" will be initialized to all\n  ** zeros, which is correct.  MSVC generates a warning, nevertheless. */\n  static VdbeOp dummy;  /* Ignore the MSVC warning about no initializer */\n  assert( p->magic==VDBE_MAGIC_INIT );\n  if( addr<0 ){\n    addr = p->nOp - 1;\n  }\n  assert( (addr>=0 && addr<p->nOp) || p->db->mallocFailed );\n  if( p->db->mallocFailed ){\n    return (VdbeOp*)&dummy;\n  }else{\n    return &p->aOp[addr];\n  }\n}\n\n#if defined(SQLITE_ENABLE_EXPLAIN_COMMENTS)\n/*\n** Return an integer value for one of the parameters to the opcode pOp\n** determined by character c.\n*/\nstatic int translateP(char c, const Op *pOp){\n  if( c=='1' ) return pOp->p1;\n  if( c=='2' ) return pOp->p2;\n  if( c=='3' ) return pOp->p3;\n  if( c=='4' ) return pOp->p4.i;\n  return pOp->p5;\n}\n\n/*\n** Compute a string for the \"comment\" field of a VDBE opcode listing.\n**\n** The Synopsis: field in comments in the vdbe.c source file gets converted\n** to an extra string that is appended to the sqlite3OpcodeName().  In the\n** absence of other comments, this synopsis becomes the comment on the opcode.\n** Some translation occurs:\n**\n**       \"PX\"      ->  \"r[X]\"\n**       \"PX@PY\"   ->  \"r[X..X+Y-1]\"  or \"r[x]\" if y is 0 or 1\n**       \"PX@PY+1\" ->  \"r[X..X+Y]\"    or \"r[x]\" if y is 0\n**       \"PY..PY\"  ->  \"r[X..Y]\"      or \"r[x]\" if y<=x\n*/\nstatic int displayComment(\n  const Op *pOp,     /* The opcode to be commented */\n  const char *zP4,   /* Previously obtained value for P4 */\n  char *zTemp,       /* Write result here */\n  int nTemp          /* Space available in zTemp[] */\n){\n  const char *zOpName;\n  const char *zSynopsis;\n  int nOpName;\n  int ii, jj;\n  char zAlt[50];\n  zOpName = sqlite3OpcodeName(pOp->opcode);\n  nOpName = sqlite3Strlen30(zOpName);\n  if( zOpName[nOpName+1] ){\n    int seenCom = 0;\n    char c;\n    zSynopsis = zOpName += nOpName + 1;\n    if( strncmp(zSynopsis,\"IF \",3)==0 ){\n      if( pOp->p5 & SQLITE_STOREP2 ){\n        sqlite3_snprintf(sizeof(zAlt), zAlt, \"r[P2] = (%s)\", zSynopsis+3);\n      }else{\n        sqlite3_snprintf(sizeof(zAlt), zAlt, \"if %s goto P2\", zSynopsis+3);\n      }\n      zSynopsis = zAlt;\n    }\n    for(ii=jj=0; jj<nTemp-1 && (c = zSynopsis[ii])!=0; ii++){\n      if( c=='P' ){\n        c = zSynopsis[++ii];\n        if( c=='4' ){\n          sqlite3_snprintf(nTemp-jj, zTemp+jj, \"%s\", zP4);\n        }else if( c=='X' ){\n          sqlite3_snprintf(nTemp-jj, zTemp+jj, \"%s\", pOp->zComment);\n          seenCom = 1;\n        }else{\n          int v1 = translateP(c, pOp);\n          int v2;\n          sqlite3_snprintf(nTemp-jj, zTemp+jj, \"%d\", v1);\n          if( strncmp(zSynopsis+ii+1, \"@P\", 2)==0 ){\n            ii += 3;\n            jj += sqlite3Strlen30(zTemp+jj);\n            v2 = translateP(zSynopsis[ii], pOp);\n            if( strncmp(zSynopsis+ii+1,\"+1\",2)==0 ){\n              ii += 2;\n              v2++;\n            }\n            if( v2>1 ){\n              sqlite3_snprintf(nTemp-jj, zTemp+jj, \"..%d\", v1+v2-1);\n            }\n          }else if( strncmp(zSynopsis+ii+1, \"..P3\", 4)==0 && pOp->p3==0 ){\n            ii += 4;\n          }\n        }\n        jj += sqlite3Strlen30(zTemp+jj);\n      }else{\n        zTemp[jj++] = c;\n      }\n    }\n    if( !seenCom && jj<nTemp-5 && pOp->zComment ){\n      sqlite3_snprintf(nTemp-jj, zTemp+jj, \"; %s\", pOp->zComment);\n      jj += sqlite3Strlen30(zTemp+jj);\n    }\n    if( jj<nTemp ) zTemp[jj] = 0;\n  }else if( pOp->zComment ){\n    sqlite3_snprintf(nTemp, zTemp, \"%s\", pOp->zComment);\n    jj = sqlite3Strlen30(zTemp);\n  }else{\n    zTemp[0] = 0;\n    jj = 0;\n  }\n  return jj;\n}\n#endif /* SQLITE_DEBUG */\n\n#if VDBE_DISPLAY_P4 && defined(SQLITE_ENABLE_CURSOR_HINTS)\n/*\n** Translate the P4.pExpr value for an OP_CursorHint opcode into text\n** that can be displayed in the P4 column of EXPLAIN output.\n*/\nstatic void displayP4Expr(StrAccum *p, Expr *pExpr){\n  const char *zOp = 0;\n  switch( pExpr->op ){\n    case TK_STRING:\n      sqlite3_str_appendf(p, \"%Q\", pExpr->u.zToken);\n      break;\n    case TK_INTEGER:\n      sqlite3_str_appendf(p, \"%d\", pExpr->u.iValue);\n      break;\n    case TK_NULL:\n      sqlite3_str_appendf(p, \"NULL\");\n      break;\n    case TK_REGISTER: {\n      sqlite3_str_appendf(p, \"r[%d]\", pExpr->iTable);\n      break;\n    }\n    case TK_COLUMN: {\n      if( pExpr->iColumn<0 ){\n        sqlite3_str_appendf(p, \"rowid\");\n      }else{\n        sqlite3_str_appendf(p, \"c%d\", (int)pExpr->iColumn);\n      }\n      break;\n    }\n    case TK_LT:      zOp = \"LT\";      break;\n    case TK_LE:      zOp = \"LE\";      break;\n    case TK_GT:      zOp = \"GT\";      break;\n    case TK_GE:      zOp = \"GE\";      break;\n    case TK_NE:      zOp = \"NE\";      break;\n    case TK_EQ:      zOp = \"EQ\";      break;\n    case TK_IS:      zOp = \"IS\";      break;\n    case TK_ISNOT:   zOp = \"ISNOT\";   break;\n    case TK_AND:     zOp = \"AND\";     break;\n    case TK_OR:      zOp = \"OR\";      break;\n    case TK_PLUS:    zOp = \"ADD\";     break;\n    case TK_STAR:    zOp = \"MUL\";     break;\n    case TK_MINUS:   zOp = \"SUB\";     break;\n    case TK_REM:     zOp = \"REM\";     break;\n    case TK_BITAND:  zOp = \"BITAND\";  break;\n    case TK_BITOR:   zOp = \"BITOR\";   break;\n    case TK_SLASH:   zOp = \"DIV\";     break;\n    case TK_LSHIFT:  zOp = \"LSHIFT\";  break;\n    case TK_RSHIFT:  zOp = \"RSHIFT\";  break;\n    case TK_CONCAT:  zOp = \"CONCAT\";  break;\n    case TK_UMINUS:  zOp = \"MINUS\";   break;\n    case TK_UPLUS:   zOp = \"PLUS\";    break;\n    case TK_BITNOT:  zOp = \"BITNOT\";  break;\n    case TK_NOT:     zOp = \"NOT\";     break;\n    case TK_ISNULL:  zOp = \"ISNULL\";  break;\n    case TK_NOTNULL: zOp = \"NOTNULL\"; break;\n\n    default:\n      sqlite3_str_appendf(p, \"%s\", \"expr\");\n      break;\n  }\n\n  if( zOp ){\n    sqlite3_str_appendf(p, \"%s(\", zOp);\n    displayP4Expr(p, pExpr->pLeft);\n    if( pExpr->pRight ){\n      sqlite3_str_append(p, \",\", 1);\n      displayP4Expr(p, pExpr->pRight);\n    }\n    sqlite3_str_append(p, \")\", 1);\n  }\n}\n#endif /* VDBE_DISPLAY_P4 && defined(SQLITE_ENABLE_CURSOR_HINTS) */\n\n\n#if VDBE_DISPLAY_P4\n/*\n** Compute a string that describes the P4 parameter for an opcode.\n** Use zTemp for any required temporary buffer space.\n*/\nstatic char *displayP4(Op *pOp, char *zTemp, int nTemp){\n  char *zP4 = zTemp;\n  StrAccum x;\n  assert( nTemp>=20 );\n  sqlite3StrAccumInit(&x, 0, zTemp, nTemp, 0);\n  switch( pOp->p4type ){\n    case P4_KEYINFO: {\n      int j;\n      KeyInfo *pKeyInfo = pOp->p4.pKeyInfo;\n      assert( pKeyInfo->aSortOrder!=0 );\n      sqlite3_str_appendf(&x, \"k(%d\", pKeyInfo->nKeyField);\n      for(j=0; j<pKeyInfo->nKeyField; j++){\n        CollSeq *pColl = pKeyInfo->aColl[j];\n        const char *zColl = pColl ? pColl->zName : \"\";\n        if( strcmp(zColl, \"BINARY\")==0 ) zColl = \"B\";\n        sqlite3_str_appendf(&x, \",%s%s\", \n               pKeyInfo->aSortOrder[j] ? \"-\" : \"\", zColl);\n      }\n      sqlite3_str_append(&x, \")\", 1);\n      break;\n    }\n#ifdef SQLITE_ENABLE_CURSOR_HINTS\n    case P4_EXPR: {\n      displayP4Expr(&x, pOp->p4.pExpr);\n      break;\n    }\n#endif\n    case P4_COLLSEQ: {\n      CollSeq *pColl = pOp->p4.pColl;\n      sqlite3_str_appendf(&x, \"(%.20s)\", pColl->zName);\n      break;\n    }\n    case P4_FUNCDEF: {\n      FuncDef *pDef = pOp->p4.pFunc;\n      sqlite3_str_appendf(&x, \"%s(%d)\", pDef->zName, pDef->nArg);\n      break;\n    }\n#if defined(SQLITE_DEBUG) || defined(VDBE_PROFILE)\n    case P4_FUNCCTX: {\n      FuncDef *pDef = pOp->p4.pCtx->pFunc;\n      sqlite3_str_appendf(&x, \"%s(%d)\", pDef->zName, pDef->nArg);\n      break;\n    }\n#endif\n    case P4_INT64: {\n      sqlite3_str_appendf(&x, \"%lld\", *pOp->p4.pI64);\n      break;\n    }\n    case P4_INT32: {\n      sqlite3_str_appendf(&x, \"%d\", pOp->p4.i);\n      break;\n    }\n    case P4_REAL: {\n      sqlite3_str_appendf(&x, \"%.17g\", *pOp->p4.pReal);\n      break;\n    }\n    case P4_MEM: {\n      Mem *pMem = pOp->p4.pMem;\n      if( pMem->flags & MEM_Str ){\n        zP4 = pMem->z;\n      }else if( pMem->flags & MEM_Int ){\n        sqlite3_str_appendf(&x, \"%lld\", pMem->u.i);\n      }else if( pMem->flags & MEM_Real ){\n        sqlite3_str_appendf(&x, \"%.17g\", pMem->u.r);\n      }else if( pMem->flags & MEM_Null ){\n        zP4 = \"NULL\";\n      }else{\n        assert( pMem->flags & MEM_Blob );\n        zP4 = \"(blob)\";\n      }\n      break;\n    }\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n    case P4_VTAB: {\n      sqlite3_vtab *pVtab = pOp->p4.pVtab->pVtab;\n      sqlite3_str_appendf(&x, \"vtab:%p\", pVtab);\n      break;\n    }\n#endif\n    case P4_INTARRAY: {\n      int i;\n      int *ai = pOp->p4.ai;\n      int n = ai[0];   /* The first element of an INTARRAY is always the\n                       ** count of the number of elements to follow */\n      for(i=1; i<=n; i++){\n        sqlite3_str_appendf(&x, \",%d\", ai[i]);\n      }\n      zTemp[0] = '[';\n      sqlite3_str_append(&x, \"]\", 1);\n      break;\n    }\n    case P4_SUBPROGRAM: {\n      sqlite3_str_appendf(&x, \"program\");\n      break;\n    }\n    case P4_DYNBLOB:\n    case P4_ADVANCE: {\n      zTemp[0] = 0;\n      break;\n    }\n    case P4_TABLE: {\n      sqlite3_str_appendf(&x, \"%s\", pOp->p4.pTab->zName);\n      break;\n    }\n    default: {\n      zP4 = pOp->p4.z;\n      if( zP4==0 ){\n        zP4 = zTemp;\n        zTemp[0] = 0;\n      }\n    }\n  }\n  sqlite3StrAccumFinish(&x);\n  assert( zP4!=0 );\n  return zP4;\n}\n#endif /* VDBE_DISPLAY_P4 */\n\n/*\n** Declare to the Vdbe that the BTree object at db->aDb[i] is used.\n**\n** The prepared statements need to know in advance the complete set of\n** attached databases that will be use.  A mask of these databases\n** is maintained in p->btreeMask.  The p->lockMask value is the subset of\n** p->btreeMask of databases that will require a lock.\n*/\nSQLITE_PRIVATE void sqlite3VdbeUsesBtree(Vdbe *p, int i){\n  assert( i>=0 && i<p->db->nDb && i<(int)sizeof(yDbMask)*8 );\n  assert( i<(int)sizeof(p->btreeMask)*8 );\n  DbMaskSet(p->btreeMask, i);\n  if( i!=1 && sqlite3BtreeSharable(p->db->aDb[i].pBt) ){\n    DbMaskSet(p->lockMask, i);\n  }\n}\n\n#if !defined(SQLITE_OMIT_SHARED_CACHE)\n/*\n** If SQLite is compiled to support shared-cache mode and to be threadsafe,\n** this routine obtains the mutex associated with each BtShared structure\n** that may be accessed by the VM passed as an argument. In doing so it also\n** sets the BtShared.db member of each of the BtShared structures, ensuring\n** that the correct busy-handler callback is invoked if required.\n**\n** If SQLite is not threadsafe but does support shared-cache mode, then\n** sqlite3BtreeEnter() is invoked to set the BtShared.db variables\n** of all of BtShared structures accessible via the database handle \n** associated with the VM.\n**\n** If SQLite is not threadsafe and does not support shared-cache mode, this\n** function is a no-op.\n**\n** The p->btreeMask field is a bitmask of all btrees that the prepared \n** statement p will ever use.  Let N be the number of bits in p->btreeMask\n** corresponding to btrees that use shared cache.  Then the runtime of\n** this routine is N*N.  But as N is rarely more than 1, this should not\n** be a problem.\n*/\nSQLITE_PRIVATE void sqlite3VdbeEnter(Vdbe *p){\n  int i;\n  sqlite3 *db;\n  Db *aDb;\n  int nDb;\n  if( DbMaskAllZero(p->lockMask) ) return;  /* The common case */\n  db = p->db;\n  aDb = db->aDb;\n  nDb = db->nDb;\n  for(i=0; i<nDb; i++){\n    if( i!=1 && DbMaskTest(p->lockMask,i) && ALWAYS(aDb[i].pBt!=0) ){\n      sqlite3BtreeEnter(aDb[i].pBt);\n    }\n  }\n}\n#endif\n\n#if !defined(SQLITE_OMIT_SHARED_CACHE) && SQLITE_THREADSAFE>0\n/*\n** Unlock all of the btrees previously locked by a call to sqlite3VdbeEnter().\n*/\nstatic SQLITE_NOINLINE void vdbeLeave(Vdbe *p){\n  int i;\n  sqlite3 *db;\n  Db *aDb;\n  int nDb;\n  db = p->db;\n  aDb = db->aDb;\n  nDb = db->nDb;\n  for(i=0; i<nDb; i++){\n    if( i!=1 && DbMaskTest(p->lockMask,i) && ALWAYS(aDb[i].pBt!=0) ){\n      sqlite3BtreeLeave(aDb[i].pBt);\n    }\n  }\n}\nSQLITE_PRIVATE void sqlite3VdbeLeave(Vdbe *p){\n  if( DbMaskAllZero(p->lockMask) ) return;  /* The common case */\n  vdbeLeave(p);\n}\n#endif\n\n#if defined(VDBE_PROFILE) || defined(SQLITE_DEBUG)\n/*\n** Print a single opcode.  This routine is used for debugging only.\n*/\nSQLITE_PRIVATE void sqlite3VdbePrintOp(FILE *pOut, int pc, VdbeOp *pOp){\n  char *zP4;\n  char zPtr[50];\n  char zCom[100];\n  static const char *zFormat1 = \"%4d %-13s %4d %4d %4d %-13s %.2X %s\\n\";\n  if( pOut==0 ) pOut = stdout;\n  zP4 = displayP4(pOp, zPtr, sizeof(zPtr));\n#ifdef SQLITE_ENABLE_EXPLAIN_COMMENTS\n  displayComment(pOp, zP4, zCom, sizeof(zCom));\n#else\n  zCom[0] = 0;\n#endif\n  /* NB:  The sqlite3OpcodeName() function is implemented by code created\n  ** by the mkopcodeh.awk and mkopcodec.awk scripts which extract the\n  ** information from the vdbe.c source text */\n  fprintf(pOut, zFormat1, pc, \n      sqlite3OpcodeName(pOp->opcode), pOp->p1, pOp->p2, pOp->p3, zP4, pOp->p5,\n      zCom\n  );\n  fflush(pOut);\n}\n#endif\n\n/*\n** Initialize an array of N Mem element.\n*/\nstatic void initMemArray(Mem *p, int N, sqlite3 *db, u16 flags){\n  while( (N--)>0 ){\n    p->db = db;\n    p->flags = flags;\n    p->szMalloc = 0;\n#ifdef SQLITE_DEBUG\n    p->pScopyFrom = 0;\n#endif\n    p++;\n  }\n}\n\n/*\n** Release an array of N Mem elements\n*/\nstatic void releaseMemArray(Mem *p, int N){\n  if( p && N ){\n    Mem *pEnd = &p[N];\n    sqlite3 *db = p->db;\n    if( db->pnBytesFreed ){\n      do{\n        if( p->szMalloc ) sqlite3DbFree(db, p->zMalloc);\n      }while( (++p)<pEnd );\n      return;\n    }\n    do{\n      assert( (&p[1])==pEnd || p[0].db==p[1].db );\n      assert( sqlite3VdbeCheckMemInvariants(p) );\n\n      /* This block is really an inlined version of sqlite3VdbeMemRelease()\n      ** that takes advantage of the fact that the memory cell value is \n      ** being set to NULL after releasing any dynamic resources.\n      **\n      ** The justification for duplicating code is that according to \n      ** callgrind, this causes a certain test case to hit the CPU 4.7 \n      ** percent less (x86 linux, gcc version 4.1.2, -O6) than if \n      ** sqlite3MemRelease() were called from here. With -O2, this jumps\n      ** to 6.6 percent. The test case is inserting 1000 rows into a table \n      ** with no indexes using a single prepared INSERT statement, bind() \n      ** and reset(). Inserts are grouped into a transaction.\n      */\n      testcase( p->flags & MEM_Agg );\n      testcase( p->flags & MEM_Dyn );\n      testcase( p->xDel==sqlite3VdbeFrameMemDel );\n      if( p->flags&(MEM_Agg|MEM_Dyn) ){\n        sqlite3VdbeMemRelease(p);\n      }else if( p->szMalloc ){\n        sqlite3DbFreeNN(db, p->zMalloc);\n        p->szMalloc = 0;\n      }\n\n      p->flags = MEM_Undefined;\n    }while( (++p)<pEnd );\n  }\n}\n\n#ifdef SQLITE_DEBUG\n/*\n** Verify that pFrame is a valid VdbeFrame pointer.  Return true if it is\n** and false if something is wrong.\n**\n** This routine is intended for use inside of assert() statements only.\n*/\nSQLITE_PRIVATE int sqlite3VdbeFrameIsValid(VdbeFrame *pFrame){\n  if( pFrame->iFrameMagic!=SQLITE_FRAME_MAGIC ) return 0;\n  return 1;\n}\n#endif\n\n\n/*\n** This is a destructor on a Mem object (which is really an sqlite3_value)\n** that deletes the Frame object that is attached to it as a blob.\n**\n** This routine does not delete the Frame right away.  It merely adds the\n** frame to a list of frames to be deleted when the Vdbe halts.\n*/\nSQLITE_PRIVATE void sqlite3VdbeFrameMemDel(void *pArg){\n  VdbeFrame *pFrame = (VdbeFrame*)pArg;\n  assert( sqlite3VdbeFrameIsValid(pFrame) );\n  pFrame->pParent = pFrame->v->pDelFrame;\n  pFrame->v->pDelFrame = pFrame;\n}\n\n\n/*\n** Delete a VdbeFrame object and its contents. VdbeFrame objects are\n** allocated by the OP_Program opcode in sqlite3VdbeExec().\n*/\nSQLITE_PRIVATE void sqlite3VdbeFrameDelete(VdbeFrame *p){\n  int i;\n  Mem *aMem = VdbeFrameMem(p);\n  VdbeCursor **apCsr = (VdbeCursor **)&aMem[p->nChildMem];\n  assert( sqlite3VdbeFrameIsValid(p) );\n  for(i=0; i<p->nChildCsr; i++){\n    sqlite3VdbeFreeCursor(p->v, apCsr[i]);\n  }\n  releaseMemArray(aMem, p->nChildMem);\n  sqlite3VdbeDeleteAuxData(p->v->db, &p->pAuxData, -1, 0);\n  sqlite3DbFree(p->v->db, p);\n}\n\n#ifndef SQLITE_OMIT_EXPLAIN\n/*\n** Give a listing of the program in the virtual machine.\n**\n** The interface is the same as sqlite3VdbeExec().  But instead of\n** running the code, it invokes the callback once for each instruction.\n** This feature is used to implement \"EXPLAIN\".\n**\n** When p->explain==1, each instruction is listed.  When\n** p->explain==2, only OP_Explain instructions are listed and these\n** are shown in a different format.  p->explain==2 is used to implement\n** EXPLAIN QUERY PLAN.\n** 2018-04-24:  In p->explain==2 mode, the OP_Init opcodes of triggers\n** are also shown, so that the boundaries between the main program and\n** each trigger are clear.\n**\n** When p->explain==1, first the main program is listed, then each of\n** the trigger subprograms are listed one by one.\n*/\nSQLITE_PRIVATE int sqlite3VdbeList(\n  Vdbe *p                   /* The VDBE */\n){\n  int nRow;                            /* Stop when row count reaches this */\n  int nSub = 0;                        /* Number of sub-vdbes seen so far */\n  SubProgram **apSub = 0;              /* Array of sub-vdbes */\n  Mem *pSub = 0;                       /* Memory cell hold array of subprogs */\n  sqlite3 *db = p->db;                 /* The database connection */\n  int i;                               /* Loop counter */\n  int rc = SQLITE_OK;                  /* Return code */\n  Mem *pMem = &p->aMem[1];             /* First Mem of result set */\n  int bListSubprogs = (p->explain==1 || (db->flags & SQLITE_TriggerEQP)!=0);\n  Op *pOp = 0;\n\n  assert( p->explain );\n  assert( p->magic==VDBE_MAGIC_RUN );\n  assert( p->rc==SQLITE_OK || p->rc==SQLITE_BUSY || p->rc==SQLITE_NOMEM );\n\n  /* Even though this opcode does not use dynamic strings for\n  ** the result, result columns may become dynamic if the user calls\n  ** sqlite3_column_text16(), causing a translation to UTF-16 encoding.\n  */\n  releaseMemArray(pMem, 8);\n  p->pResultSet = 0;\n\n  if( p->rc==SQLITE_NOMEM ){\n    /* This happens if a malloc() inside a call to sqlite3_column_text() or\n    ** sqlite3_column_text16() failed.  */\n    sqlite3OomFault(db);\n    return SQLITE_ERROR;\n  }\n\n  /* When the number of output rows reaches nRow, that means the\n  ** listing has finished and sqlite3_step() should return SQLITE_DONE.\n  ** nRow is the sum of the number of rows in the main program, plus\n  ** the sum of the number of rows in all trigger subprograms encountered\n  ** so far.  The nRow value will increase as new trigger subprograms are\n  ** encountered, but p->pc will eventually catch up to nRow.\n  */\n  nRow = p->nOp;\n  if( bListSubprogs ){\n    /* The first 8 memory cells are used for the result set.  So we will\n    ** commandeer the 9th cell to use as storage for an array of pointers\n    ** to trigger subprograms.  The VDBE is guaranteed to have at least 9\n    ** cells.  */\n    assert( p->nMem>9 );\n    pSub = &p->aMem[9];\n    if( pSub->flags&MEM_Blob ){\n      /* On the first call to sqlite3_step(), pSub will hold a NULL.  It is\n      ** initialized to a BLOB by the P4_SUBPROGRAM processing logic below */\n      nSub = pSub->n/sizeof(Vdbe*);\n      apSub = (SubProgram **)pSub->z;\n    }\n    for(i=0; i<nSub; i++){\n      nRow += apSub[i]->nOp;\n    }\n  }\n\n  while(1){  /* Loop exits via break */\n    i = p->pc++;\n    if( i>=nRow ){\n      p->rc = SQLITE_OK;\n      rc = SQLITE_DONE;\n      break;\n    }\n    if( i<p->nOp ){\n      /* The output line number is small enough that we are still in the\n      ** main program. */\n      pOp = &p->aOp[i];\n    }else{\n      /* We are currently listing subprograms.  Figure out which one and\n      ** pick up the appropriate opcode. */\n      int j;\n      i -= p->nOp;\n      for(j=0; i>=apSub[j]->nOp; j++){\n        i -= apSub[j]->nOp;\n      }\n      pOp = &apSub[j]->aOp[i];\n    }\n\n    /* When an OP_Program opcode is encounter (the only opcode that has\n    ** a P4_SUBPROGRAM argument), expand the size of the array of subprograms\n    ** kept in p->aMem[9].z to hold the new program - assuming this subprogram\n    ** has not already been seen.\n    */\n    if( bListSubprogs && pOp->p4type==P4_SUBPROGRAM ){\n      int nByte = (nSub+1)*sizeof(SubProgram*);\n      int j;\n      for(j=0; j<nSub; j++){\n        if( apSub[j]==pOp->p4.pProgram ) break;\n      }\n      if( j==nSub ){\n        p->rc = sqlite3VdbeMemGrow(pSub, nByte, nSub!=0);\n        if( p->rc!=SQLITE_OK ){\n          rc = SQLITE_ERROR;\n          break;\n        }\n        apSub = (SubProgram **)pSub->z;\n        apSub[nSub++] = pOp->p4.pProgram;\n        pSub->flags |= MEM_Blob;\n        pSub->n = nSub*sizeof(SubProgram*);\n        nRow += pOp->p4.pProgram->nOp;\n      }\n    }\n    if( p->explain<2 ) break;\n    if( pOp->opcode==OP_Explain ) break;\n    if( pOp->opcode==OP_Init && p->pc>1 ) break;\n  }\n\n  if( rc==SQLITE_OK ){\n    if( (db->u1.isInterrupted || db->suspended) && !db->unimpeded ){\n      p->rc = SQLITE_INTERRUPT;\n      rc = SQLITE_ERROR;\n      sqlite3VdbeError(p, sqlite3ErrStr(p->rc));\n    }else{\n      char *zP4;\n      if( p->explain==1 ){\n        pMem->flags = MEM_Int;\n        pMem->u.i = i;                                /* Program counter */\n        pMem++;\n    \n        pMem->flags = MEM_Static|MEM_Str|MEM_Term;\n        pMem->z = (char*)sqlite3OpcodeName(pOp->opcode); /* Opcode */\n        assert( pMem->z!=0 );\n        pMem->n = sqlite3Strlen30(pMem->z);\n        pMem->enc = SQLITE_UTF8;\n        pMem++;\n      }\n\n      pMem->flags = MEM_Int;\n      pMem->u.i = pOp->p1;                          /* P1 */\n      pMem++;\n\n      pMem->flags = MEM_Int;\n      pMem->u.i = pOp->p2;                          /* P2 */\n      pMem++;\n\n      pMem->flags = MEM_Int;\n      pMem->u.i = pOp->p3;                          /* P3 */\n      pMem++;\n\n      if( sqlite3VdbeMemClearAndResize(pMem, 100) ){ /* P4 */\n        assert( p->db->mallocFailed );\n        return SQLITE_ERROR;\n      }\n      pMem->flags = MEM_Str|MEM_Term;\n      zP4 = displayP4(pOp, pMem->z, pMem->szMalloc);\n      if( zP4!=pMem->z ){\n        pMem->n = 0;\n        sqlite3VdbeMemSetStr(pMem, zP4, -1, SQLITE_UTF8, 0);\n      }else{\n        assert( pMem->z!=0 );\n        pMem->n = sqlite3Strlen30(pMem->z);\n        pMem->enc = SQLITE_UTF8;\n      }\n      pMem++;\n\n      if( p->explain==1 ){\n        if( sqlite3VdbeMemClearAndResize(pMem, 4) ){\n          assert( p->db->mallocFailed );\n          return SQLITE_ERROR;\n        }\n        pMem->flags = MEM_Str|MEM_Term;\n        pMem->n = 2;\n        sqlite3_snprintf(3, pMem->z, \"%.2x\", pOp->p5);   /* P5 */\n        pMem->enc = SQLITE_UTF8;\n        pMem++;\n    \n#ifdef SQLITE_ENABLE_EXPLAIN_COMMENTS\n        if( sqlite3VdbeMemClearAndResize(pMem, 500) ){\n          assert( p->db->mallocFailed );\n          return SQLITE_ERROR;\n        }\n        pMem->flags = MEM_Str|MEM_Term;\n        pMem->n = displayComment(pOp, zP4, pMem->z, 500);\n        pMem->enc = SQLITE_UTF8;\n#else\n        pMem->flags = MEM_Null;                       /* Comment */\n#endif\n      }\n\n      p->nResColumn = 8 - 4*(p->explain-1);\n      p->pResultSet = &p->aMem[1];\n      p->rc = SQLITE_OK;\n      rc = SQLITE_ROW;\n    }\n  }\n  return rc;\n}\n#endif /* SQLITE_OMIT_EXPLAIN */\n\n#ifdef SQLITE_DEBUG\n/*\n** Print the SQL that was used to generate a VDBE program.\n*/\nSQLITE_PRIVATE void sqlite3VdbePrintSql(Vdbe *p){\n  const char *z = 0;\n  if( p->zSql ){\n    z = p->zSql;\n  }else if( p->nOp>=1 ){\n    const VdbeOp *pOp = &p->aOp[0];\n    if( pOp->opcode==OP_Init && pOp->p4.z!=0 ){\n      z = pOp->p4.z;\n      while( sqlite3Isspace(*z) ) z++;\n    }\n  }\n  if( z ) printf(\"SQL: [%s]\\n\", z);\n}\n#endif\n\n#if !defined(SQLITE_OMIT_TRACE) && defined(SQLITE_ENABLE_IOTRACE)\n/*\n** Print an IOTRACE message showing SQL content.\n*/\nSQLITE_PRIVATE void sqlite3VdbeIOTraceSql(Vdbe *p){\n  int nOp = p->nOp;\n  VdbeOp *pOp;\n  if( sqlite3IoTrace==0 ) return;\n  if( nOp<1 ) return;\n  pOp = &p->aOp[0];\n  if( pOp->opcode==OP_Init && pOp->p4.z!=0 ){\n    int i, j;\n    char z[1000];\n    sqlite3_snprintf(sizeof(z), z, \"%s\", pOp->p4.z);\n    for(i=0; sqlite3Isspace(z[i]); i++){}\n    for(j=0; z[i]; i++){\n      if( sqlite3Isspace(z[i]) ){\n        if( z[i-1]!=' ' ){\n          z[j++] = ' ';\n        }\n      }else{\n        z[j++] = z[i];\n      }\n    }\n    z[j] = 0;\n    sqlite3IoTrace(\"SQL %s\\n\", z);\n  }\n}\n#endif /* !SQLITE_OMIT_TRACE && SQLITE_ENABLE_IOTRACE */\n\n/* An instance of this object describes bulk memory available for use\n** by subcomponents of a prepared statement.  Space is allocated out\n** of a ReusableSpace object by the allocSpace() routine below.\n*/\nstruct ReusableSpace {\n  u8 *pSpace;          /* Available memory */\n  int nFree;           /* Bytes of available memory */\n  int nNeeded;         /* Total bytes that could not be allocated */\n};\n\n/* Try to allocate nByte bytes of 8-byte aligned bulk memory for pBuf\n** from the ReusableSpace object.  Return a pointer to the allocated\n** memory on success.  If insufficient memory is available in the\n** ReusableSpace object, increase the ReusableSpace.nNeeded\n** value by the amount needed and return NULL.\n**\n** If pBuf is not initially NULL, that means that the memory has already\n** been allocated by a prior call to this routine, so just return a copy\n** of pBuf and leave ReusableSpace unchanged.\n**\n** This allocator is employed to repurpose unused slots at the end of the\n** opcode array of prepared state for other memory needs of the prepared\n** statement.\n*/\nstatic void *allocSpace(\n  struct ReusableSpace *p,  /* Bulk memory available for allocation */\n  void *pBuf,               /* Pointer to a prior allocation */\n  int nByte                 /* Bytes of memory needed */\n){\n  assert( EIGHT_BYTE_ALIGNMENT(p->pSpace) );\n  if( pBuf==0 ){\n    nByte = ROUND8(nByte);\n    if( nByte <= p->nFree ){\n      p->nFree -= nByte;\n      pBuf = &p->pSpace[p->nFree];\n    }else{\n      p->nNeeded += nByte;\n    }\n  }\n  assert( EIGHT_BYTE_ALIGNMENT(pBuf) );\n  return pBuf;\n}\n\n/*\n** Rewind the VDBE back to the beginning in preparation for\n** running it.\n*/\nSQLITE_PRIVATE void sqlite3VdbeRewind(Vdbe *p){\n#if defined(SQLITE_DEBUG) || defined(VDBE_PROFILE)\n  int i;\n#endif\n  assert( p!=0 );\n  assert( p->magic==VDBE_MAGIC_INIT || p->magic==VDBE_MAGIC_RESET );\n\n  /* There should be at least one opcode.\n  */\n  assert( p->nOp>0 );\n\n  /* Set the magic to VDBE_MAGIC_RUN sooner rather than later. */\n  p->magic = VDBE_MAGIC_RUN;\n\n#ifdef SQLITE_DEBUG\n  for(i=0; i<p->nMem; i++){\n    assert( p->aMem[i].db==p->db );\n  }\n#endif\n  p->pc = -1;\n  p->rc = SQLITE_OK;\n  p->errorAction = OE_Abort;\n  p->nChange = 0;\n  p->cacheCtr = 1;\n  p->minWriteFileFormat = 255;\n  p->iStatement = 0;\n  p->nFkConstraint = 0;\n#ifdef VDBE_PROFILE\n  for(i=0; i<p->nOp; i++){\n    p->aOp[i].cnt = 0;\n    p->aOp[i].cycles = 0;\n  }\n#endif\n}\n\n/*\n** Prepare a virtual machine for execution for the first time after\n** creating the virtual machine.  This involves things such\n** as allocating registers and initializing the program counter.\n** After the VDBE has be prepped, it can be executed by one or more\n** calls to sqlite3VdbeExec().  \n**\n** This function may be called exactly once on each virtual machine.\n** After this routine is called the VM has been \"packaged\" and is ready\n** to run.  After this routine is called, further calls to \n** sqlite3VdbeAddOp() functions are prohibited.  This routine disconnects\n** the Vdbe from the Parse object that helped generate it so that the\n** the Vdbe becomes an independent entity and the Parse object can be\n** destroyed.\n**\n** Use the sqlite3VdbeRewind() procedure to restore a virtual machine back\n** to its initial state after it has been run.\n*/\nSQLITE_PRIVATE void sqlite3VdbeMakeReady(\n  Vdbe *p,                       /* The VDBE */\n  Parse *pParse                  /* Parsing context */\n){\n  sqlite3 *db;                   /* The database connection */\n  int nVar;                      /* Number of parameters */\n  int nMem;                      /* Number of VM memory registers */\n  int nCursor;                   /* Number of cursors required */\n  int nArg;                      /* Number of arguments in subprograms */\n  int n;                         /* Loop counter */\n  struct ReusableSpace x;        /* Reusable bulk memory */\n\n  assert( p!=0 );\n  assert( p->nOp>0 );\n  assert( pParse!=0 );\n  assert( p->magic==VDBE_MAGIC_INIT );\n  assert( pParse==p->pParse );\n  db = p->db;\n  assert( db->mallocFailed==0 );\n  nVar = pParse->nVar;\n  nMem = pParse->nMem;\n  nCursor = pParse->nTab;\n  nArg = pParse->nMaxArg;\n  \n  /* Each cursor uses a memory cell.  The first cursor (cursor 0) can\n  ** use aMem[0] which is not otherwise used by the VDBE program.  Allocate\n  ** space at the end of aMem[] for cursors 1 and greater.\n  ** See also: allocateCursor().\n  */\n  nMem += nCursor;\n  if( nCursor==0 && nMem>0 ) nMem++;  /* Space for aMem[0] even if not used */\n\n  /* Figure out how much reusable memory is available at the end of the\n  ** opcode array.  This extra memory will be reallocated for other elements\n  ** of the prepared statement.\n  */\n  n = ROUND8(sizeof(Op)*p->nOp);              /* Bytes of opcode memory used */\n  x.pSpace = &((u8*)p->aOp)[n];               /* Unused opcode memory */\n  assert( EIGHT_BYTE_ALIGNMENT(x.pSpace) );\n  x.nFree = ROUNDDOWN8(pParse->szOpAlloc - n);  /* Bytes of unused memory */\n  assert( x.nFree>=0 );\n  assert( EIGHT_BYTE_ALIGNMENT(&x.pSpace[x.nFree]) );\n\n  resolveP2Values(p, &nArg);\n  p->usesStmtJournal = (u8)(pParse->isMultiWrite && pParse->mayAbort);\n  if( pParse->explain && nMem<10 ){\n    nMem = 10;\n  }\n  p->expired = 0;\n\n  /* Memory for registers, parameters, cursor, etc, is allocated in one or two\n  ** passes.  On the first pass, we try to reuse unused memory at the \n  ** end of the opcode array.  If we are unable to satisfy all memory\n  ** requirements by reusing the opcode array tail, then the second\n  ** pass will fill in the remainder using a fresh memory allocation.  \n  **\n  ** This two-pass approach that reuses as much memory as possible from\n  ** the leftover memory at the end of the opcode array.  This can significantly\n  ** reduce the amount of memory held by a prepared statement.\n  */\n  x.nNeeded = 0;\n  p->aMem = allocSpace(&x, 0, nMem*sizeof(Mem));\n  p->aVar = allocSpace(&x, 0, nVar*sizeof(Mem));\n  p->apArg = allocSpace(&x, 0, nArg*sizeof(Mem*));\n  p->apCsr = allocSpace(&x, 0, nCursor*sizeof(VdbeCursor*));\n#ifdef SQLITE_ENABLE_STMT_SCANSTATUS\n  p->anExec = allocSpace(&x, 0, p->nOp*sizeof(i64));\n#endif\n  if( x.nNeeded ){\n    x.pSpace = p->pFree = sqlite3DbMallocRawNN(db, x.nNeeded);\n    x.nFree = x.nNeeded;\n    if( !db->mallocFailed ){\n      p->aMem = allocSpace(&x, p->aMem, nMem*sizeof(Mem));\n      p->aVar = allocSpace(&x, p->aVar, nVar*sizeof(Mem));\n      p->apArg = allocSpace(&x, p->apArg, nArg*sizeof(Mem*));\n      p->apCsr = allocSpace(&x, p->apCsr, nCursor*sizeof(VdbeCursor*));\n#ifdef SQLITE_ENABLE_STMT_SCANSTATUS\n      p->anExec = allocSpace(&x, p->anExec, p->nOp*sizeof(i64));\n#endif\n    }\n  }\n\n  p->pVList = pParse->pVList;\n  pParse->pVList =  0;\n  p->explain = pParse->explain;\n  if( db->mallocFailed ){\n    p->nVar = 0;\n    p->nCursor = 0;\n    p->nMem = 0;\n  }else{\n    p->nCursor = nCursor;\n    p->nVar = (ynVar)nVar;\n    initMemArray(p->aVar, nVar, db, MEM_Null);\n    p->nMem = nMem;\n    initMemArray(p->aMem, nMem, db, MEM_Undefined);\n    memset(p->apCsr, 0, nCursor*sizeof(VdbeCursor*));\n#ifdef SQLITE_ENABLE_STMT_SCANSTATUS\n    memset(p->anExec, 0, p->nOp*sizeof(i64));\n#endif\n  }\n  sqlite3VdbeRewind(p);\n}\n\n/*\n** Close a VDBE cursor and release all the resources that cursor \n** happens to hold.\n*/\nSQLITE_PRIVATE void sqlite3VdbeFreeCursor(Vdbe *p, VdbeCursor *pCx){\n  if( pCx==0 ){\n    return;\n  }\n  assert( pCx->pBtx==0 || pCx->eCurType==CURTYPE_BTREE );\n  switch( pCx->eCurType ){\n    case CURTYPE_SORTER: {\n      sqlite3VdbeSorterClose(p->db, pCx);\n      break;\n    }\n    case CURTYPE_BTREE: {\n      if( pCx->isEphemeral ){\n        if( pCx->pBtx ) sqlite3BtreeClose(pCx->pBtx);\n        /* The pCx->pCursor will be close automatically, if it exists, by\n        ** the call above. */\n      }else{\n        assert( pCx->uc.pCursor!=0 );\n        sqlite3BtreeCloseCursor(pCx->uc.pCursor);\n      }\n      break;\n    }\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n    case CURTYPE_VTAB: {\n      sqlite3_vtab_cursor *pVCur = pCx->uc.pVCur;\n      const sqlite3_module *pModule = pVCur->pVtab->pModule;\n      assert( pVCur->pVtab->nRef>0 );\n      pVCur->pVtab->nRef--;\n      pModule->xClose(pVCur);\n      break;\n    }\n#endif\n  }\n}\n\n/*\n** Close all cursors in the current frame.\n*/\nstatic void closeCursorsInFrame(Vdbe *p){\n  if( p->apCsr ){\n    int i;\n    for(i=0; i<p->nCursor; i++){\n      VdbeCursor *pC = p->apCsr[i];\n      if( pC ){\n        sqlite3VdbeFreeCursor(p, pC);\n        p->apCsr[i] = 0;\n      }\n    }\n  }\n}\n\n/*\n** Copy the values stored in the VdbeFrame structure to its Vdbe. This\n** is used, for example, when a trigger sub-program is halted to restore\n** control to the main program.\n*/\nSQLITE_PRIVATE int sqlite3VdbeFrameRestore(VdbeFrame *pFrame){\n  Vdbe *v = pFrame->v;\n  closeCursorsInFrame(v);\n#ifdef SQLITE_ENABLE_STMT_SCANSTATUS\n  v->anExec = pFrame->anExec;\n#endif\n  v->aOp = pFrame->aOp;\n  v->nOp = pFrame->nOp;\n  v->aMem = pFrame->aMem;\n  v->nMem = pFrame->nMem;\n  v->apCsr = pFrame->apCsr;\n  v->nCursor = pFrame->nCursor;\n  v->db->lastRowid = pFrame->lastRowid;\n  v->nChange = pFrame->nChange;\n  v->db->nChange = pFrame->nDbChange;\n  sqlite3VdbeDeleteAuxData(v->db, &v->pAuxData, -1, 0);\n  v->pAuxData = pFrame->pAuxData;\n  pFrame->pAuxData = 0;\n  return pFrame->pc;\n}\n\n/*\n** Close all cursors.\n**\n** Also release any dynamic memory held by the VM in the Vdbe.aMem memory \n** cell array. This is necessary as the memory cell array may contain\n** pointers to VdbeFrame objects, which may in turn contain pointers to\n** open cursors.\n*/\nstatic void closeAllCursors(Vdbe *p){\n  if( p->pFrame ){\n    VdbeFrame *pFrame;\n    for(pFrame=p->pFrame; pFrame->pParent; pFrame=pFrame->pParent);\n    sqlite3VdbeFrameRestore(pFrame);\n    p->pFrame = 0;\n    p->nFrame = 0;\n  }\n  assert( p->nFrame==0 );\n  closeCursorsInFrame(p);\n  if( p->aMem ){\n    releaseMemArray(p->aMem, p->nMem);\n  }\n  while( p->pDelFrame ){\n    VdbeFrame *pDel = p->pDelFrame;\n    p->pDelFrame = pDel->pParent;\n    sqlite3VdbeFrameDelete(pDel);\n  }\n\n  /* Delete any auxdata allocations made by the VM */\n  if( p->pAuxData ) sqlite3VdbeDeleteAuxData(p->db, &p->pAuxData, -1, 0);\n  assert( p->pAuxData==0 );\n}\n\n/*\n** Set the number of result columns that will be returned by this SQL\n** statement. This is now set at compile time, rather than during\n** execution of the vdbe program so that sqlite3_column_count() can\n** be called on an SQL statement before sqlite3_step().\n*/\nSQLITE_PRIVATE void sqlite3VdbeSetNumCols(Vdbe *p, int nResColumn){\n  int n;\n  sqlite3 *db = p->db;\n\n  if( p->nResColumn ){\n    releaseMemArray(p->aColName, p->nResColumn*COLNAME_N);\n    sqlite3DbFree(db, p->aColName);\n  }\n  n = nResColumn*COLNAME_N;\n  p->nResColumn = (u16)nResColumn;\n  p->aColName = (Mem*)sqlite3DbMallocRawNN(db, sizeof(Mem)*n );\n  if( p->aColName==0 ) return;\n  initMemArray(p->aColName, n, db, MEM_Null);\n}\n\n/*\n** Set the name of the idx'th column to be returned by the SQL statement.\n** zName must be a pointer to a nul terminated string.\n**\n** This call must be made after a call to sqlite3VdbeSetNumCols().\n**\n** The final parameter, xDel, must be one of SQLITE_DYNAMIC, SQLITE_STATIC\n** or SQLITE_TRANSIENT. If it is SQLITE_DYNAMIC, then the buffer pointed\n** to by zName will be freed by sqlite3DbFree() when the vdbe is destroyed.\n*/\nSQLITE_PRIVATE int sqlite3VdbeSetColName(\n  Vdbe *p,                         /* Vdbe being configured */\n  int idx,                         /* Index of column zName applies to */\n  int var,                         /* One of the COLNAME_* constants */\n  const char *zName,               /* Pointer to buffer containing name */\n  void (*xDel)(void*)              /* Memory management strategy for zName */\n){\n  int rc;\n  Mem *pColName;\n  assert( idx<p->nResColumn );\n  assert( var<COLNAME_N );\n  if( p->db->mallocFailed ){\n    assert( !zName || xDel!=SQLITE_DYNAMIC );\n    return SQLITE_NOMEM_BKPT;\n  }\n  assert( p->aColName!=0 );\n  pColName = &(p->aColName[idx+var*p->nResColumn]);\n  rc = sqlite3VdbeMemSetStr(pColName, zName, -1, SQLITE_UTF8, xDel);\n  assert( rc!=0 || !zName || (pColName->flags&MEM_Term)!=0 );\n  return rc;\n}\n\n/*\n** A read or write transaction may or may not be active on database handle\n** db. If a transaction is active, commit it. If there is a\n** write-transaction spanning more than one database file, this routine\n** takes care of the master journal trickery.\n*/\nstatic int vdbeCommit(sqlite3 *db, Vdbe *p){\n  int i;\n  int nTrans = 0;  /* Number of databases with an active write-transaction\n                   ** that are candidates for a two-phase commit using a\n                   ** master-journal */\n  int rc = SQLITE_OK;\n  int needXcommit = 0;\n\n#ifdef SQLITE_OMIT_VIRTUALTABLE\n  /* With this option, sqlite3VtabSync() is defined to be simply \n  ** SQLITE_OK so p is not used. \n  */\n  UNUSED_PARAMETER(p);\n#endif\n\n  /* Before doing anything else, call the xSync() callback for any\n  ** virtual module tables written in this transaction. This has to\n  ** be done before determining whether a master journal file is \n  ** required, as an xSync() callback may add an attached database\n  ** to the transaction.\n  */\n  rc = sqlite3VtabSync(db, p);\n\n  /* This loop determines (a) if the commit hook should be invoked and\n  ** (b) how many database files have open write transactions, not \n  ** including the temp database. (b) is important because if more than \n  ** one database file has an open write transaction, a master journal\n  ** file is required for an atomic commit.\n  */ \n  for(i=0; rc==SQLITE_OK && i<db->nDb; i++){ \n    Btree *pBt = db->aDb[i].pBt;\n    if( sqlite3BtreeIsInTrans(pBt) ){\n      /* Whether or not a database might need a master journal depends upon\n      ** its journal mode (among other things).  This matrix determines which\n      ** journal modes use a master journal and which do not */\n      static const u8 aMJNeeded[] = {\n        /* DELETE   */  1,\n        /* PERSIST   */ 1,\n        /* OFF       */ 0,\n        /* TRUNCATE  */ 1,\n        /* MEMORY    */ 0,\n        /* WAL       */ 0\n      };\n      Pager *pPager;   /* Pager associated with pBt */\n      needXcommit = 1;\n      sqlite3BtreeEnter(pBt);\n      pPager = sqlite3BtreePager(pBt);\n      if( db->aDb[i].safety_level!=PAGER_SYNCHRONOUS_OFF\n       && aMJNeeded[sqlite3PagerGetJournalMode(pPager)]\n       && sqlite3PagerIsMemdb(pPager)==0\n      ){ \n        assert( i!=1 );\n        nTrans++;\n      }\n      rc = sqlite3PagerExclusiveLock(pPager);\n      sqlite3BtreeLeave(pBt);\n    }\n  }\n  if( rc!=SQLITE_OK ){\n    return rc;\n  }\n\n  /* If there are any write-transactions at all, invoke the commit hook */\n  if( needXcommit && db->xCommitCallback ){\n    rc = db->xCommitCallback(db->pCommitArg);\n    if( rc ){\n      return SQLITE_CONSTRAINT_COMMITHOOK;\n    }\n  }\n\n  /* The simple case - no more than one database file (not counting the\n  ** TEMP database) has a transaction active.   There is no need for the\n  ** master-journal.\n  **\n  ** If the return value of sqlite3BtreeGetFilename() is a zero length\n  ** string, it means the main database is :memory: or a temp file.  In \n  ** that case we do not support atomic multi-file commits, so use the \n  ** simple case then too.\n  */\n  if( 0==sqlite3Strlen30(sqlite3BtreeGetFilename(db->aDb[0].pBt))\n   || nTrans<=1\n  ){\n#ifdef SQLITE_WCDB\n    if(db->revertCommit){\n      for(i=db->nDb-1; rc==SQLITE_OK && i>=0; i--){\n        Btree *pBt = db->aDb[i].pBt;\n        if( pBt ){\n          rc = sqlite3BtreeCommitPhaseOne(pBt, 0);\n        }\n      }\n      db->revertCommit = 0;\n    }else\n#endif\n    {\n      for(i=0; rc==SQLITE_OK && i<db->nDb; i++){\n        Btree *pBt = db->aDb[i].pBt;\n        if( pBt ){\n          rc = sqlite3BtreeCommitPhaseOne(pBt, 0);\n        }\n      }\n    }\n\n    /* Do the commit only if all databases successfully complete phase 1. \n    ** If one of the BtreeCommitPhaseOne() calls fails, this indicates an\n    ** IO error while deleting or truncating a journal file. It is unlikely,\n    ** but could happen. In this case abandon processing and return the error.\n    */\n    for(i=0; rc==SQLITE_OK && i<db->nDb; i++){\n      Btree *pBt = db->aDb[i].pBt;\n      if( pBt ){\n        rc = sqlite3BtreeCommitPhaseTwo(pBt, 0);\n      }\n    }\n    if( rc==SQLITE_OK ){\n      sqlite3VtabCommit(db);\n    }\n  }\n\n  /* The complex case - There is a multi-file write-transaction active.\n  ** This requires a master journal file to ensure the transaction is\n  ** committed atomically.\n  */\n#ifndef SQLITE_OMIT_DISKIO\n  else{\n    sqlite3_vfs *pVfs = db->pVfs;\n    char *zMaster = 0;   /* File-name for the master journal */\n    char const *zMainFile = sqlite3BtreeGetFilename(db->aDb[0].pBt);\n    sqlite3_file *pMaster = 0;\n    i64 offset = 0;\n    int res;\n    int retryCount = 0;\n    int nMainFile;\n\n    /* Select a master journal file name */\n    nMainFile = sqlite3Strlen30(zMainFile);\n    zMaster = sqlite3MPrintf(db, \"%s-mjXXXXXX9XXz\", zMainFile);\n    if( zMaster==0 ) return SQLITE_NOMEM_BKPT;\n    do {\n      u32 iRandom;\n      if( retryCount ){\n        if( retryCount>100 ){\n          sqlite3_log(SQLITE_FULL, \"MJ delete: %s\", zMaster);\n          sqlite3OsDelete(pVfs, zMaster, 0);\n          break;\n        }else if( retryCount==1 ){\n          sqlite3_log(SQLITE_FULL, \"MJ collide: %s\", zMaster);\n        }\n      }\n      retryCount++;\n      sqlite3_randomness(sizeof(iRandom), &iRandom);\n      sqlite3_snprintf(13, &zMaster[nMainFile], \"-mj%06X9%02X\",\n                               (iRandom>>8)&0xffffff, iRandom&0xff);\n      /* The antipenultimate character of the master journal name must\n      ** be \"9\" to avoid name collisions when using 8+3 filenames. */\n      assert( zMaster[sqlite3Strlen30(zMaster)-3]=='9' );\n      sqlite3FileSuffix3(zMainFile, zMaster);\n      rc = sqlite3OsAccess(pVfs, zMaster, SQLITE_ACCESS_EXISTS, &res);\n    }while( rc==SQLITE_OK && res );\n    if( rc==SQLITE_OK ){\n      /* Open the master journal. */\n      rc = sqlite3OsOpenMalloc(pVfs, zMaster, &pMaster, \n          SQLITE_OPEN_READWRITE|SQLITE_OPEN_CREATE|\n          SQLITE_OPEN_EXCLUSIVE|SQLITE_OPEN_MASTER_JOURNAL, 0\n      );\n    }\n    if( rc!=SQLITE_OK ){\n      sqlite3DbFree(db, zMaster);\n      return rc;\n    }\n \n    /* Write the name of each database file in the transaction into the new\n    ** master journal file. If an error occurs at this point close\n    ** and delete the master journal file. All the individual journal files\n    ** still have 'null' as the master journal pointer, so they will roll\n    ** back independently if a failure occurs.\n    */\n    for(i=0; i<db->nDb; i++){\n      Btree *pBt = db->aDb[i].pBt;\n      if( sqlite3BtreeIsInTrans(pBt) ){\n        char const *zFile = sqlite3BtreeGetJournalname(pBt);\n        if( zFile==0 ){\n          continue;  /* Ignore TEMP and :memory: databases */\n        }\n        assert( zFile[0]!=0 );\n        rc = sqlite3OsWrite(pMaster, zFile, sqlite3Strlen30(zFile)+1, offset);\n        offset += sqlite3Strlen30(zFile)+1;\n        if( rc!=SQLITE_OK ){\n          sqlite3OsCloseFree(pMaster);\n          sqlite3OsDelete(pVfs, zMaster, 0);\n          sqlite3DbFree(db, zMaster);\n          return rc;\n        }\n      }\n    }\n\n    /* Sync the master journal file. If the IOCAP_SEQUENTIAL device\n    ** flag is set this is not required.\n    */\n    if( 0==(sqlite3OsDeviceCharacteristics(pMaster)&SQLITE_IOCAP_SEQUENTIAL)\n     && SQLITE_OK!=(rc = sqlite3OsSync(pMaster, SQLITE_SYNC_NORMAL))\n    ){\n      sqlite3OsCloseFree(pMaster);\n      sqlite3OsDelete(pVfs, zMaster, 0);\n      sqlite3DbFree(db, zMaster);\n      return rc;\n    }\n\n    /* Sync all the db files involved in the transaction. The same call\n    ** sets the master journal pointer in each individual journal. If\n    ** an error occurs here, do not delete the master journal file.\n    **\n    ** If the error occurs during the first call to\n    ** sqlite3BtreeCommitPhaseOne(), then there is a chance that the\n    ** master journal file will be orphaned. But we cannot delete it,\n    ** in case the master journal file name was written into the journal\n    ** file before the failure occurred.\n    */\n    for(i=0; rc==SQLITE_OK && i<db->nDb; i++){ \n      Btree *pBt = db->aDb[i].pBt;\n      if( pBt ){\n        rc = sqlite3BtreeCommitPhaseOne(pBt, zMaster);\n      }\n    }\n    sqlite3OsCloseFree(pMaster);\n    assert( rc!=SQLITE_BUSY );\n    if( rc!=SQLITE_OK ){\n      sqlite3DbFree(db, zMaster);\n      return rc;\n    }\n\n    /* Delete the master journal file. This commits the transaction. After\n    ** doing this the directory is synced again before any individual\n    ** transaction files are deleted.\n    */\n    rc = sqlite3OsDelete(pVfs, zMaster, 1);\n    sqlite3DbFree(db, zMaster);\n    zMaster = 0;\n    if( rc ){\n      return rc;\n    }\n\n    /* All files and directories have already been synced, so the following\n    ** calls to sqlite3BtreeCommitPhaseTwo() are only closing files and\n    ** deleting or truncating journals. If something goes wrong while\n    ** this is happening we don't really care. The integrity of the\n    ** transaction is already guaranteed, but some stray 'cold' journals\n    ** may be lying around. Returning an error code won't help matters.\n    */\n    disable_simulated_io_errors();\n    sqlite3BeginBenignMalloc();\n    for(i=0; i<db->nDb; i++){ \n      Btree *pBt = db->aDb[i].pBt;\n      if( pBt ){\n        sqlite3BtreeCommitPhaseTwo(pBt, 1);\n      }\n    }\n    sqlite3EndBenignMalloc();\n    enable_simulated_io_errors();\n\n    sqlite3VtabCommit(db);\n  }\n#endif\n\n  return rc;\n}\n\n/* \n** This routine checks that the sqlite3.nVdbeActive count variable\n** matches the number of vdbe's in the list sqlite3.pVdbe that are\n** currently active. An assertion fails if the two counts do not match.\n** This is an internal self-check only - it is not an essential processing\n** step.\n**\n** This is a no-op if NDEBUG is defined.\n*/\n#ifndef NDEBUG\nstatic void checkActiveVdbeCnt(sqlite3 *db){\n  Vdbe *p;\n  int cnt = 0;\n  int nWrite = 0;\n  int nRead = 0;\n  p = db->pVdbe;\n  while( p ){\n    if( sqlite3_stmt_busy((sqlite3_stmt*)p) ){\n      cnt++;\n      if( p->readOnly==0 ) nWrite++;\n      if( p->bIsReader ) nRead++;\n    }\n    p = p->pNext;\n  }\n  assert( cnt==db->nVdbeActive );\n  assert( nWrite==db->nVdbeWrite );\n  assert( nRead==db->nVdbeRead );\n}\n#else\n#define checkActiveVdbeCnt(x)\n#endif\n\n/*\n** If the Vdbe passed as the first argument opened a statement-transaction,\n** close it now. Argument eOp must be either SAVEPOINT_ROLLBACK or\n** SAVEPOINT_RELEASE. If it is SAVEPOINT_ROLLBACK, then the statement\n** transaction is rolled back. If eOp is SAVEPOINT_RELEASE, then the \n** statement transaction is committed.\n**\n** If an IO error occurs, an SQLITE_IOERR_XXX error code is returned. \n** Otherwise SQLITE_OK.\n*/\nstatic SQLITE_NOINLINE int vdbeCloseStatement(Vdbe *p, int eOp){\n  sqlite3 *const db = p->db;\n  int rc = SQLITE_OK;\n  int i;\n  const int iSavepoint = p->iStatement-1;\n\n  assert( eOp==SAVEPOINT_ROLLBACK || eOp==SAVEPOINT_RELEASE);\n  assert( db->nStatement>0 );\n  assert( p->iStatement==(db->nStatement+db->nSavepoint) );\n\n  for(i=0; i<db->nDb; i++){ \n    int rc2 = SQLITE_OK;\n    Btree *pBt = db->aDb[i].pBt;\n    if( pBt ){\n      if( eOp==SAVEPOINT_ROLLBACK ){\n        rc2 = sqlite3BtreeSavepoint(pBt, SAVEPOINT_ROLLBACK, iSavepoint);\n      }\n      if( rc2==SQLITE_OK ){\n        rc2 = sqlite3BtreeSavepoint(pBt, SAVEPOINT_RELEASE, iSavepoint);\n      }\n      if( rc==SQLITE_OK ){\n        rc = rc2;\n      }\n    }\n  }\n  db->nStatement--;\n  p->iStatement = 0;\n\n  if( rc==SQLITE_OK ){\n    if( eOp==SAVEPOINT_ROLLBACK ){\n      rc = sqlite3VtabSavepoint(db, SAVEPOINT_ROLLBACK, iSavepoint);\n    }\n    if( rc==SQLITE_OK ){\n      rc = sqlite3VtabSavepoint(db, SAVEPOINT_RELEASE, iSavepoint);\n    }\n  }\n\n  /* If the statement transaction is being rolled back, also restore the \n  ** database handles deferred constraint counter to the value it had when \n  ** the statement transaction was opened.  */\n  if( eOp==SAVEPOINT_ROLLBACK ){\n    db->nDeferredCons = p->nStmtDefCons;\n    db->nDeferredImmCons = p->nStmtDefImmCons;\n  }\n  return rc;\n}\nSQLITE_PRIVATE int sqlite3VdbeCloseStatement(Vdbe *p, int eOp){\n  if( p->db->nStatement && p->iStatement ){\n    return vdbeCloseStatement(p, eOp);\n  }\n  return SQLITE_OK;\n}\n\n\n/*\n** This function is called when a transaction opened by the database \n** handle associated with the VM passed as an argument is about to be \n** committed. If there are outstanding deferred foreign key constraint\n** violations, return SQLITE_ERROR. Otherwise, SQLITE_OK.\n**\n** If there are outstanding FK violations and this function returns \n** SQLITE_ERROR, set the result of the VM to SQLITE_CONSTRAINT_FOREIGNKEY\n** and write an error message to it. Then return SQLITE_ERROR.\n*/\n#ifndef SQLITE_OMIT_FOREIGN_KEY\nSQLITE_PRIVATE int sqlite3VdbeCheckFk(Vdbe *p, int deferred){\n  sqlite3 *db = p->db;\n  if( (deferred && (db->nDeferredCons+db->nDeferredImmCons)>0) \n   || (!deferred && p->nFkConstraint>0) \n  ){\n    p->rc = SQLITE_CONSTRAINT_FOREIGNKEY;\n    p->errorAction = OE_Abort;\n    sqlite3VdbeError(p, \"FOREIGN KEY constraint failed\");\n    return SQLITE_ERROR;\n  }\n  return SQLITE_OK;\n}\n#endif\n\n/*\n** This routine is called the when a VDBE tries to halt.  If the VDBE\n** has made changes and is in autocommit mode, then commit those\n** changes.  If a rollback is needed, then do the rollback.\n**\n** This routine is the only way to move the state of a VM from\n** SQLITE_MAGIC_RUN to SQLITE_MAGIC_HALT.  It is harmless to\n** call this on a VM that is in the SQLITE_MAGIC_HALT state.\n**\n** Return an error code.  If the commit could not complete because of\n** lock contention, return SQLITE_BUSY.  If SQLITE_BUSY is returned, it\n** means the close did not happen and needs to be repeated.\n*/\nSQLITE_PRIVATE int sqlite3VdbeHalt(Vdbe *p){\n  int rc;                         /* Used to store transient return codes */\n  sqlite3 *db = p->db;\n\n  /* This function contains the logic that determines if a statement or\n  ** transaction will be committed or rolled back as a result of the\n  ** execution of this virtual machine. \n  **\n  ** If any of the following errors occur:\n  **\n  **     SQLITE_NOMEM\n  **     SQLITE_IOERR\n  **     SQLITE_FULL\n  **     SQLITE_INTERRUPT\n  **\n  ** Then the internal cache might have been left in an inconsistent\n  ** state.  We need to rollback the statement transaction, if there is\n  ** one, or the complete transaction if there is no statement transaction.\n  */\n\n  if( p->magic!=VDBE_MAGIC_RUN ){\n    return SQLITE_OK;\n  }\n  if( db->mallocFailed ){\n    p->rc = SQLITE_NOMEM_BKPT;\n  }\n  closeAllCursors(p);\n  checkActiveVdbeCnt(db);\n\n  /* No commit or rollback needed if the program never started or if the\n  ** SQL statement does not read or write a database file.  */\n  if( p->pc>=0 && p->bIsReader ){\n    int mrc;   /* Primary error code from p->rc */\n    int eStatementOp = 0;\n    int isSpecialError;            /* Set to true if a 'special' error */\n\n    /* Lock all btrees used by the statement */\n    sqlite3VdbeEnter(p);\n\n    /* Check for one of the special errors */\n    mrc = p->rc & 0xff;\n    isSpecialError = mrc==SQLITE_NOMEM || mrc==SQLITE_IOERR\n                     || mrc==SQLITE_INTERRUPT || mrc==SQLITE_FULL;\n    if( isSpecialError ){\n      /* If the query was read-only and the error code is SQLITE_INTERRUPT, \n      ** no rollback is necessary. Otherwise, at least a savepoint \n      ** transaction must be rolled back to restore the database to a \n      ** consistent state.\n      **\n      ** Even if the statement is read-only, it is important to perform\n      ** a statement or transaction rollback operation. If the error \n      ** occurred while writing to the journal, sub-journal or database\n      ** file as part of an effort to free up cache space (see function\n      ** pagerStress() in pager.c), the rollback is required to restore \n      ** the pager to a consistent state.\n      */\n      if( !p->readOnly || mrc!=SQLITE_INTERRUPT ){\n        if( (mrc==SQLITE_NOMEM || mrc==SQLITE_FULL) && p->usesStmtJournal ){\n          eStatementOp = SAVEPOINT_ROLLBACK;\n        }else{\n          /* We are forced to roll back the active transaction. Before doing\n          ** so, abort any other statements this handle currently has active.\n          */\n          sqlite3RollbackAll(db, SQLITE_ABORT_ROLLBACK);\n          sqlite3CloseSavepoints(db);\n          db->autoCommit = 1;\n          p->nChange = 0;\n        }\n      }\n    }\n\n    /* Check for immediate foreign key violations. */\n    if( p->rc==SQLITE_OK ){\n      sqlite3VdbeCheckFk(p, 0);\n    }\n  \n    /* If the auto-commit flag is set and this is the only active writer \n    ** VM, then we do either a commit or rollback of the current transaction. \n    **\n    ** Note: This block also runs if one of the special errors handled \n    ** above has occurred. \n    */\n    if( !sqlite3VtabInSync(db) \n     && db->autoCommit \n     && db->nVdbeWrite==(p->readOnly==0) \n    ){\n      if( p->rc==SQLITE_OK || (p->errorAction==OE_Fail && !isSpecialError) ){\n        rc = sqlite3VdbeCheckFk(p, 1);\n        if( rc!=SQLITE_OK ){\n          if( NEVER(p->readOnly) ){\n            sqlite3VdbeLeave(p);\n            return SQLITE_ERROR;\n          }\n          rc = SQLITE_CONSTRAINT_FOREIGNKEY;\n        }else{ \n          /* The auto-commit flag is true, the vdbe program was successful \n          ** or hit an 'OR FAIL' constraint and there are no deferred foreign\n          ** key constraints to hold up the transaction. This means a commit \n          ** is required. */\n          rc = vdbeCommit(db, p);\n        }\n        if( rc==SQLITE_BUSY && p->readOnly ){\n          sqlite3VdbeLeave(p);\n          return SQLITE_BUSY;\n        }else if( rc!=SQLITE_OK ){\n          p->rc = rc;\n          sqlite3RollbackAll(db, SQLITE_OK);\n          p->nChange = 0;\n        }else{\n          db->nDeferredCons = 0;\n          db->nDeferredImmCons = 0;\n          db->flags &= ~(u64)SQLITE_DeferFKs;\n          sqlite3CommitInternalChanges(db);\n        }\n      }else{\n        sqlite3RollbackAll(db, SQLITE_OK);\n        p->nChange = 0;\n      }\n      db->nStatement = 0;\n    }else if( eStatementOp==0 ){\n      if( p->rc==SQLITE_OK || p->errorAction==OE_Fail ){\n        eStatementOp = SAVEPOINT_RELEASE;\n      }else if( p->errorAction==OE_Abort ){\n        eStatementOp = SAVEPOINT_ROLLBACK;\n      }else{\n        sqlite3RollbackAll(db, SQLITE_ABORT_ROLLBACK);\n        sqlite3CloseSavepoints(db);\n        db->autoCommit = 1;\n        p->nChange = 0;\n      }\n    }\n  \n    /* If eStatementOp is non-zero, then a statement transaction needs to\n    ** be committed or rolled back. Call sqlite3VdbeCloseStatement() to\n    ** do so. If this operation returns an error, and the current statement\n    ** error code is SQLITE_OK or SQLITE_CONSTRAINT, then promote the\n    ** current statement error code.\n    */\n    if( eStatementOp ){\n      rc = sqlite3VdbeCloseStatement(p, eStatementOp);\n      if( rc ){\n        if( p->rc==SQLITE_OK || (p->rc&0xff)==SQLITE_CONSTRAINT ){\n          p->rc = rc;\n          sqlite3DbFree(db, p->zErrMsg);\n          p->zErrMsg = 0;\n        }\n        sqlite3RollbackAll(db, SQLITE_ABORT_ROLLBACK);\n        sqlite3CloseSavepoints(db);\n        db->autoCommit = 1;\n        p->nChange = 0;\n      }\n    }\n  \n    /* If this was an INSERT, UPDATE or DELETE and no statement transaction\n    ** has been rolled back, update the database connection change-counter. \n    */\n    if( p->changeCntOn ){\n      if( eStatementOp!=SAVEPOINT_ROLLBACK ){\n        sqlite3VdbeSetChanges(db, p->nChange);\n      }else{\n        sqlite3VdbeSetChanges(db, 0);\n      }\n      p->nChange = 0;\n    }\n\n    /* Release the locks */\n    sqlite3VdbeLeave(p);\n  }\n\n  /* We have successfully halted and closed the VM.  Record this fact. */\n  if( p->pc>=0 ){\n    db->nVdbeActive--;\n    if( !p->readOnly ) db->nVdbeWrite--;\n    if( p->bIsReader ) db->nVdbeRead--;\n    assert( db->nVdbeActive>=db->nVdbeRead );\n    assert( db->nVdbeRead>=db->nVdbeWrite );\n    assert( db->nVdbeWrite>=0 );\n  }\n  p->magic = VDBE_MAGIC_HALT;\n  checkActiveVdbeCnt(db);\n  if( db->mallocFailed ){\n    p->rc = SQLITE_NOMEM_BKPT;\n  }\n\n  /* If the auto-commit flag is set to true, then any locks that were held\n  ** by connection db have now been released. Call sqlite3ConnectionUnlocked() \n  ** to invoke any required unlock-notify callbacks.\n  */\n  if( db->autoCommit ){\n    sqlite3ConnectionUnlocked(db);\n  }\n\n  assert( db->nVdbeActive>0 || db->autoCommit==0 || db->nStatement==0 );\n  return (p->rc==SQLITE_BUSY ? SQLITE_BUSY : SQLITE_OK);\n}\n\n\n/*\n** Each VDBE holds the result of the most recent sqlite3_step() call\n** in p->rc.  This routine sets that result back to SQLITE_OK.\n*/\nSQLITE_PRIVATE void sqlite3VdbeResetStepResult(Vdbe *p){\n  p->rc = SQLITE_OK;\n}\n\n/*\n** Copy the error code and error message belonging to the VDBE passed\n** as the first argument to its database handle (so that they will be \n** returned by calls to sqlite3_errcode() and sqlite3_errmsg()).\n**\n** This function does not clear the VDBE error code or message, just\n** copies them to the database handle.\n*/\nSQLITE_PRIVATE int sqlite3VdbeTransferError(Vdbe *p){\n  sqlite3 *db = p->db;\n  int rc = p->rc;\n  if( p->zErrMsg ){\n    db->bBenignMalloc++;\n    sqlite3BeginBenignMalloc();\n    if( db->pErr==0 ) db->pErr = sqlite3ValueNew(db);\n    sqlite3ValueSetStr(db->pErr, -1, p->zErrMsg, SQLITE_UTF8, SQLITE_TRANSIENT);\n    sqlite3EndBenignMalloc();\n    db->bBenignMalloc--;\n  }else if( db->pErr ){\n    sqlite3ValueSetNull(db->pErr);\n  }\n  db->errCode = rc;\n  return rc;\n}\n\n#ifdef SQLITE_ENABLE_SQLLOG\n/*\n** If an SQLITE_CONFIG_SQLLOG hook is registered and the VM has been run, \n** invoke it.\n*/\nstatic void vdbeInvokeSqllog(Vdbe *v){\n  if( sqlite3GlobalConfig.xSqllog && v->rc==SQLITE_OK && v->zSql && v->pc>=0 ){\n    char *zExpanded = sqlite3VdbeExpandSql(v, v->zSql);\n    assert( v->db->init.busy==0 );\n    if( zExpanded ){\n      sqlite3GlobalConfig.xSqllog(\n          sqlite3GlobalConfig.pSqllogArg, v->db, zExpanded, 1\n      );\n      sqlite3DbFree(v->db, zExpanded);\n    }\n  }\n}\n#else\n# define vdbeInvokeSqllog(x)\n#endif\n\n/*\n** Clean up a VDBE after execution but do not delete the VDBE just yet.\n** Write any error messages into *pzErrMsg.  Return the result code.\n**\n** After this routine is run, the VDBE should be ready to be executed\n** again.\n**\n** To look at it another way, this routine resets the state of the\n** virtual machine from VDBE_MAGIC_RUN or VDBE_MAGIC_HALT back to\n** VDBE_MAGIC_INIT.\n*/\nSQLITE_PRIVATE int sqlite3VdbeReset(Vdbe *p){\n#if defined(SQLITE_DEBUG) || defined(VDBE_PROFILE)\n  int i;\n#endif\n\n  sqlite3 *db;\n  db = p->db;\n\n  /* If the VM did not run to completion or if it encountered an\n  ** error, then it might not have been halted properly.  So halt\n  ** it now.\n  */\n  sqlite3VdbeHalt(p);\n\n  /* If the VDBE has been run even partially, then transfer the error code\n  ** and error message from the VDBE into the main database structure.  But\n  ** if the VDBE has just been set to run but has not actually executed any\n  ** instructions yet, leave the main database error information unchanged.\n  */\n  if( p->pc>=0 ){\n    vdbeInvokeSqllog(p);\n    sqlite3VdbeTransferError(p);\n    if( p->runOnlyOnce ) p->expired = 1;\n  }else if( p->rc && p->expired ){\n    /* The expired flag was set on the VDBE before the first call\n    ** to sqlite3_step(). For consistency (since sqlite3_step() was\n    ** called), set the database error in this case as well.\n    */\n    sqlite3ErrorWithMsg(db, p->rc, p->zErrMsg ? \"%s\" : 0, p->zErrMsg);\n  }\n\n  /* Reset register contents and reclaim error message memory.\n  */\n#ifdef SQLITE_DEBUG\n  /* Execute assert() statements to ensure that the Vdbe.apCsr[] and \n  ** Vdbe.aMem[] arrays have already been cleaned up.  */\n  if( p->apCsr ) for(i=0; i<p->nCursor; i++) assert( p->apCsr[i]==0 );\n  if( p->aMem ){\n    for(i=0; i<p->nMem; i++) assert( p->aMem[i].flags==MEM_Undefined );\n  }\n#endif\n  sqlite3DbFree(db, p->zErrMsg);\n  p->zErrMsg = 0;\n  p->pResultSet = 0;\n#ifdef SQLITE_DEBUG\n  p->nWrite = 0;\n#endif\n\n  /* Save profiling information from this VDBE run.\n  */\n#ifdef VDBE_PROFILE\n  {\n    FILE *out = fopen(\"vdbe_profile.out\", \"a\");\n    if( out ){\n      fprintf(out, \"---- \");\n      for(i=0; i<p->nOp; i++){\n        fprintf(out, \"%02x\", p->aOp[i].opcode);\n      }\n      fprintf(out, \"\\n\");\n      if( p->zSql ){\n        char c, pc = 0;\n        fprintf(out, \"-- \");\n        for(i=0; (c = p->zSql[i])!=0; i++){\n          if( pc=='\\n' ) fprintf(out, \"-- \");\n          putc(c, out);\n          pc = c;\n        }\n        if( pc!='\\n' ) fprintf(out, \"\\n\");\n      }\n      for(i=0; i<p->nOp; i++){\n        char zHdr[100];\n        sqlite3_snprintf(sizeof(zHdr), zHdr, \"%6u %12llu %8llu \",\n           p->aOp[i].cnt,\n           p->aOp[i].cycles,\n           p->aOp[i].cnt>0 ? p->aOp[i].cycles/p->aOp[i].cnt : 0\n        );\n        fprintf(out, \"%s\", zHdr);\n        sqlite3VdbePrintOp(out, i, &p->aOp[i]);\n      }\n      fclose(out);\n    }\n  }\n#endif\n  p->magic = VDBE_MAGIC_RESET;\n  return p->rc & db->errMask;\n}\n \n/*\n** Clean up and delete a VDBE after execution.  Return an integer which is\n** the result code.  Write any error message text into *pzErrMsg.\n*/\nSQLITE_PRIVATE int sqlite3VdbeFinalize(Vdbe *p){\n  int rc = SQLITE_OK;\n  if( p->magic==VDBE_MAGIC_RUN || p->magic==VDBE_MAGIC_HALT ){\n    rc = sqlite3VdbeReset(p);\n    assert( (rc & p->db->errMask)==rc );\n  }\n  sqlite3VdbeDelete(p);\n  return rc;\n}\n\n/*\n** If parameter iOp is less than zero, then invoke the destructor for\n** all auxiliary data pointers currently cached by the VM passed as\n** the first argument.\n**\n** Or, if iOp is greater than or equal to zero, then the destructor is\n** only invoked for those auxiliary data pointers created by the user \n** function invoked by the OP_Function opcode at instruction iOp of \n** VM pVdbe, and only then if:\n**\n**    * the associated function parameter is the 32nd or later (counting\n**      from left to right), or\n**\n**    * the corresponding bit in argument mask is clear (where the first\n**      function parameter corresponds to bit 0 etc.).\n*/\nSQLITE_PRIVATE void sqlite3VdbeDeleteAuxData(sqlite3 *db, AuxData **pp, int iOp, int mask){\n  while( *pp ){\n    AuxData *pAux = *pp;\n    if( (iOp<0)\n     || (pAux->iAuxOp==iOp\n          && pAux->iAuxArg>=0\n          && (pAux->iAuxArg>31 || !(mask & MASKBIT32(pAux->iAuxArg))))\n    ){\n      testcase( pAux->iAuxArg==31 );\n      if( pAux->xDeleteAux ){\n        pAux->xDeleteAux(pAux->pAux);\n      }\n      *pp = pAux->pNextAux;\n      sqlite3DbFree(db, pAux);\n    }else{\n      pp= &pAux->pNextAux;\n    }\n  }\n}\n\n/*\n** Free all memory associated with the Vdbe passed as the second argument,\n** except for object itself, which is preserved.\n**\n** The difference between this function and sqlite3VdbeDelete() is that\n** VdbeDelete() also unlinks the Vdbe from the list of VMs associated with\n** the database connection and frees the object itself.\n*/\nSQLITE_PRIVATE void sqlite3VdbeClearObject(sqlite3 *db, Vdbe *p){\n  SubProgram *pSub, *pNext;\n  assert( p->db==0 || p->db==db );\n  releaseMemArray(p->aColName, p->nResColumn*COLNAME_N);\n  for(pSub=p->pProgram; pSub; pSub=pNext){\n    pNext = pSub->pNext;\n    vdbeFreeOpArray(db, pSub->aOp, pSub->nOp);\n    sqlite3DbFree(db, pSub);\n  }\n  if( p->magic!=VDBE_MAGIC_INIT ){\n    releaseMemArray(p->aVar, p->nVar);\n    sqlite3DbFree(db, p->pVList);\n    sqlite3DbFree(db, p->pFree);\n  }\n  vdbeFreeOpArray(db, p->aOp, p->nOp);\n  sqlite3DbFree(db, p->aColName);\n  sqlite3DbFree(db, p->zSql);\n#ifdef SQLITE_ENABLE_NORMALIZE\n  sqlite3DbFree(db, p->zNormSql);\n  {\n    DblquoteStr *pThis, *pNext;\n    for(pThis=p->pDblStr; pThis; pThis=pNext){\n      pNext = pThis->pNextStr;\n      sqlite3DbFree(db, pThis);\n    }\n  }\n#endif\n#ifdef SQLITE_ENABLE_STMT_SCANSTATUS\n  {\n    int i;\n    for(i=0; i<p->nScan; i++){\n      sqlite3DbFree(db, p->aScan[i].zName);\n    }\n    sqlite3DbFree(db, p->aScan);\n  }\n#endif\n}\n\n/*\n** Delete an entire VDBE.\n*/\nSQLITE_PRIVATE void sqlite3VdbeDelete(Vdbe *p){\n  sqlite3 *db;\n\n  assert( p!=0 );\n  db = p->db;\n  assert( sqlite3_mutex_held(db->mutex) );\n  sqlite3VdbeClearObject(db, p);\n  if( p->pPrev ){\n    p->pPrev->pNext = p->pNext;\n  }else{\n    assert( db->pVdbe==p );\n    db->pVdbe = p->pNext;\n  }\n  if( p->pNext ){\n    p->pNext->pPrev = p->pPrev;\n  }\n  p->magic = VDBE_MAGIC_DEAD;\n  p->db = 0;\n  sqlite3DbFreeNN(db, p);\n}\n\n/*\n** The cursor \"p\" has a pending seek operation that has not yet been\n** carried out.  Seek the cursor now.  If an error occurs, return\n** the appropriate error code.\n*/\nstatic int SQLITE_NOINLINE handleDeferredMoveto(VdbeCursor *p){\n  int res, rc;\n#ifdef SQLITE_TEST\n  extern int sqlite3_search_count;\n#endif\n  assert( p->deferredMoveto );\n  assert( p->isTable );\n  assert( p->eCurType==CURTYPE_BTREE );\n  rc = sqlite3BtreeMovetoUnpacked(p->uc.pCursor, 0, p->movetoTarget, 0, &res);\n  if( rc ) return rc;\n  if( res!=0 ) return SQLITE_CORRUPT_BKPT;\n#ifdef SQLITE_TEST\n  sqlite3_search_count++;\n#endif\n  p->deferredMoveto = 0;\n  p->cacheStatus = CACHE_STALE;\n  return SQLITE_OK;\n}\n\n/*\n** Something has moved cursor \"p\" out of place.  Maybe the row it was\n** pointed to was deleted out from under it.  Or maybe the btree was\n** rebalanced.  Whatever the cause, try to restore \"p\" to the place it\n** is supposed to be pointing.  If the row was deleted out from under the\n** cursor, set the cursor to point to a NULL row.\n*/\nstatic int SQLITE_NOINLINE handleMovedCursor(VdbeCursor *p){\n  int isDifferentRow, rc;\n  assert( p->eCurType==CURTYPE_BTREE );\n  assert( p->uc.pCursor!=0 );\n  assert( sqlite3BtreeCursorHasMoved(p->uc.pCursor) );\n  rc = sqlite3BtreeCursorRestore(p->uc.pCursor, &isDifferentRow);\n  p->cacheStatus = CACHE_STALE;\n  if( isDifferentRow ) p->nullRow = 1;\n  return rc;\n}\n\n/*\n** Check to ensure that the cursor is valid.  Restore the cursor\n** if need be.  Return any I/O error from the restore operation.\n*/\nSQLITE_PRIVATE int sqlite3VdbeCursorRestore(VdbeCursor *p){\n  assert( p->eCurType==CURTYPE_BTREE );\n  if( sqlite3BtreeCursorHasMoved(p->uc.pCursor) ){\n    return handleMovedCursor(p);\n  }\n  return SQLITE_OK;\n}\n\n/*\n** Make sure the cursor p is ready to read or write the row to which it\n** was last positioned.  Return an error code if an OOM fault or I/O error\n** prevents us from positioning the cursor to its correct position.\n**\n** If a MoveTo operation is pending on the given cursor, then do that\n** MoveTo now.  If no move is pending, check to see if the row has been\n** deleted out from under the cursor and if it has, mark the row as\n** a NULL row.\n**\n** If the cursor is already pointing to the correct row and that row has\n** not been deleted out from under the cursor, then this routine is a no-op.\n*/\nSQLITE_PRIVATE int sqlite3VdbeCursorMoveto(VdbeCursor **pp, int *piCol){\n  VdbeCursor *p = *pp;\n  assert( p->eCurType==CURTYPE_BTREE || p->eCurType==CURTYPE_PSEUDO );\n  if( p->deferredMoveto ){\n    int iMap;\n    if( p->aAltMap && (iMap = p->aAltMap[1+*piCol])>0 ){\n      *pp = p->pAltCursor;\n      *piCol = iMap - 1;\n      return SQLITE_OK;\n    }\n    return handleDeferredMoveto(p);\n  }\n  if( sqlite3BtreeCursorHasMoved(p->uc.pCursor) ){\n    return handleMovedCursor(p);\n  }\n  return SQLITE_OK;\n}\n\n/*\n** The following functions:\n**\n** sqlite3VdbeSerialType()\n** sqlite3VdbeSerialTypeLen()\n** sqlite3VdbeSerialLen()\n** sqlite3VdbeSerialPut()\n** sqlite3VdbeSerialGet()\n**\n** encapsulate the code that serializes values for storage in SQLite\n** data and index records. Each serialized value consists of a\n** 'serial-type' and a blob of data. The serial type is an 8-byte unsigned\n** integer, stored as a varint.\n**\n** In an SQLite index record, the serial type is stored directly before\n** the blob of data that it corresponds to. In a table record, all serial\n** types are stored at the start of the record, and the blobs of data at\n** the end. Hence these functions allow the caller to handle the\n** serial-type and data blob separately.\n**\n** The following table describes the various storage classes for data:\n**\n**   serial type        bytes of data      type\n**   --------------     ---------------    ---------------\n**      0                     0            NULL\n**      1                     1            signed integer\n**      2                     2            signed integer\n**      3                     3            signed integer\n**      4                     4            signed integer\n**      5                     6            signed integer\n**      6                     8            signed integer\n**      7                     8            IEEE float\n**      8                     0            Integer constant 0\n**      9                     0            Integer constant 1\n**     10,11                               reserved for expansion\n**    N>=12 and even       (N-12)/2        BLOB\n**    N>=13 and odd        (N-13)/2        text\n**\n** The 8 and 9 types were added in 3.3.0, file format 4.  Prior versions\n** of SQLite will not understand those serial types.\n*/\n\n/*\n** Return the serial-type for the value stored in pMem.\n*/\nSQLITE_PRIVATE u32 sqlite3VdbeSerialType(Mem *pMem, int file_format, u32 *pLen){\n  int flags = pMem->flags;\n  u32 n;\n\n  assert( pLen!=0 );\n  if( flags&MEM_Null ){\n    *pLen = 0;\n    return 0;\n  }\n  if( flags&MEM_Int ){\n    /* Figure out whether to use 1, 2, 4, 6 or 8 bytes. */\n#   define MAX_6BYTE ((((i64)0x00008000)<<32)-1)\n    i64 i = pMem->u.i;\n    u64 u;\n    if( i<0 ){\n      u = ~i;\n    }else{\n      u = i;\n    }\n    if( u<=127 ){\n      if( (i&1)==i && file_format>=4 ){\n        *pLen = 0;\n        return 8+(u32)u;\n      }else{\n        *pLen = 1;\n        return 1;\n      }\n    }\n    if( u<=32767 ){ *pLen = 2; return 2; }\n    if( u<=8388607 ){ *pLen = 3; return 3; }\n    if( u<=2147483647 ){ *pLen = 4; return 4; }\n    if( u<=MAX_6BYTE ){ *pLen = 6; return 5; }\n    *pLen = 8;\n    return 6;\n  }\n  if( flags&MEM_Real ){\n    *pLen = 8;\n    return 7;\n  }\n  assert( pMem->db->mallocFailed || flags&(MEM_Str|MEM_Blob) );\n  assert( pMem->n>=0 );\n  n = (u32)pMem->n;\n  if( flags & MEM_Zero ){\n    n += pMem->u.nZero;\n  }\n  *pLen = n;\n  return ((n*2) + 12 + ((flags&MEM_Str)!=0));\n}\n\n/*\n** The sizes for serial types less than 128\n*/\nstatic const u8 sqlite3SmallTypeSizes[] = {\n        /*  0   1   2   3   4   5   6   7   8   9 */   \n/*   0 */   0,  1,  2,  3,  4,  6,  8,  8,  0,  0,\n/*  10 */   0,  0,  0,  0,  1,  1,  2,  2,  3,  3,\n/*  20 */   4,  4,  5,  5,  6,  6,  7,  7,  8,  8,\n/*  30 */   9,  9, 10, 10, 11, 11, 12, 12, 13, 13,\n/*  40 */  14, 14, 15, 15, 16, 16, 17, 17, 18, 18,\n/*  50 */  19, 19, 20, 20, 21, 21, 22, 22, 23, 23,\n/*  60 */  24, 24, 25, 25, 26, 26, 27, 27, 28, 28,\n/*  70 */  29, 29, 30, 30, 31, 31, 32, 32, 33, 33,\n/*  80 */  34, 34, 35, 35, 36, 36, 37, 37, 38, 38,\n/*  90 */  39, 39, 40, 40, 41, 41, 42, 42, 43, 43,\n/* 100 */  44, 44, 45, 45, 46, 46, 47, 47, 48, 48,\n/* 110 */  49, 49, 50, 50, 51, 51, 52, 52, 53, 53,\n/* 120 */  54, 54, 55, 55, 56, 56, 57, 57\n};\n\n/*\n** Return the length of the data corresponding to the supplied serial-type.\n*/\nSQLITE_PRIVATE u32 sqlite3VdbeSerialTypeLen(u32 serial_type){\n  if( serial_type>=128 ){\n    return (serial_type-12)/2;\n  }else{\n    assert( serial_type<12 \n            || sqlite3SmallTypeSizes[serial_type]==(serial_type - 12)/2 );\n    return sqlite3SmallTypeSizes[serial_type];\n  }\n}\nSQLITE_PRIVATE u8 sqlite3VdbeOneByteSerialTypeLen(u8 serial_type){\n  assert( serial_type<128 );\n  return sqlite3SmallTypeSizes[serial_type];  \n}\n\n/*\n** If we are on an architecture with mixed-endian floating \n** points (ex: ARM7) then swap the lower 4 bytes with the \n** upper 4 bytes.  Return the result.\n**\n** For most architectures, this is a no-op.\n**\n** (later):  It is reported to me that the mixed-endian problem\n** on ARM7 is an issue with GCC, not with the ARM7 chip.  It seems\n** that early versions of GCC stored the two words of a 64-bit\n** float in the wrong order.  And that error has been propagated\n** ever since.  The blame is not necessarily with GCC, though.\n** GCC might have just copying the problem from a prior compiler.\n** I am also told that newer versions of GCC that follow a different\n** ABI get the byte order right.\n**\n** Developers using SQLite on an ARM7 should compile and run their\n** application using -DSQLITE_DEBUG=1 at least once.  With DEBUG\n** enabled, some asserts below will ensure that the byte order of\n** floating point values is correct.\n**\n** (2007-08-30)  Frank van Vugt has studied this problem closely\n** and has send his findings to the SQLite developers.  Frank\n** writes that some Linux kernels offer floating point hardware\n** emulation that uses only 32-bit mantissas instead of a full \n** 48-bits as required by the IEEE standard.  (This is the\n** CONFIG_FPE_FASTFPE option.)  On such systems, floating point\n** byte swapping becomes very complicated.  To avoid problems,\n** the necessary byte swapping is carried out using a 64-bit integer\n** rather than a 64-bit float.  Frank assures us that the code here\n** works for him.  We, the developers, have no way to independently\n** verify this, but Frank seems to know what he is talking about\n** so we trust him.\n*/\n#ifdef SQLITE_MIXED_ENDIAN_64BIT_FLOAT\nstatic u64 floatSwap(u64 in){\n  union {\n    u64 r;\n    u32 i[2];\n  } u;\n  u32 t;\n\n  u.r = in;\n  t = u.i[0];\n  u.i[0] = u.i[1];\n  u.i[1] = t;\n  return u.r;\n}\n# define swapMixedEndianFloat(X)  X = floatSwap(X)\n#else\n# define swapMixedEndianFloat(X)\n#endif\n\n/*\n** Write the serialized data blob for the value stored in pMem into \n** buf. It is assumed that the caller has allocated sufficient space.\n** Return the number of bytes written.\n**\n** nBuf is the amount of space left in buf[].  The caller is responsible\n** for allocating enough space to buf[] to hold the entire field, exclusive\n** of the pMem->u.nZero bytes for a MEM_Zero value.\n**\n** Return the number of bytes actually written into buf[].  The number\n** of bytes in the zero-filled tail is included in the return value only\n** if those bytes were zeroed in buf[].\n*/ \nSQLITE_PRIVATE u32 sqlite3VdbeSerialPut(u8 *buf, Mem *pMem, u32 serial_type){\n  u32 len;\n\n  /* Integer and Real */\n  if( serial_type<=7 && serial_type>0 ){\n    u64 v;\n    u32 i;\n    if( serial_type==7 ){\n      assert( sizeof(v)==sizeof(pMem->u.r) );\n      memcpy(&v, &pMem->u.r, sizeof(v));\n      swapMixedEndianFloat(v);\n    }else{\n      v = pMem->u.i;\n    }\n    len = i = sqlite3SmallTypeSizes[serial_type];\n    assert( i>0 );\n    do{\n      buf[--i] = (u8)(v&0xFF);\n      v >>= 8;\n    }while( i );\n    return len;\n  }\n\n  /* String or blob */\n  if( serial_type>=12 ){\n    assert( pMem->n + ((pMem->flags & MEM_Zero)?pMem->u.nZero:0)\n             == (int)sqlite3VdbeSerialTypeLen(serial_type) );\n    len = pMem->n;\n    if( len>0 ) memcpy(buf, pMem->z, len);\n    return len;\n  }\n\n  /* NULL or constants 0 or 1 */\n  return 0;\n}\n\n/* Input \"x\" is a sequence of unsigned characters that represent a\n** big-endian integer.  Return the equivalent native integer\n*/\n#define ONE_BYTE_INT(x)    ((i8)(x)[0])\n#define TWO_BYTE_INT(x)    (256*(i8)((x)[0])|(x)[1])\n#define THREE_BYTE_INT(x)  (65536*(i8)((x)[0])|((x)[1]<<8)|(x)[2])\n#define FOUR_BYTE_UINT(x)  (((u32)(x)[0]<<24)|((x)[1]<<16)|((x)[2]<<8)|(x)[3])\n#define FOUR_BYTE_INT(x) (16777216*(i8)((x)[0])|((x)[1]<<16)|((x)[2]<<8)|(x)[3])\n\n/*\n** Deserialize the data blob pointed to by buf as serial type serial_type\n** and store the result in pMem.  Return the number of bytes read.\n**\n** This function is implemented as two separate routines for performance.\n** The few cases that require local variables are broken out into a separate\n** routine so that in most cases the overhead of moving the stack pointer\n** is avoided.\n*/ \nstatic u32 SQLITE_NOINLINE serialGet(\n  const unsigned char *buf,     /* Buffer to deserialize from */\n  u32 serial_type,              /* Serial type to deserialize */\n  Mem *pMem                     /* Memory cell to write value into */\n){\n  u64 x = FOUR_BYTE_UINT(buf);\n  u32 y = FOUR_BYTE_UINT(buf+4);\n  x = (x<<32) + y;\n  if( serial_type==6 ){\n    /* EVIDENCE-OF: R-29851-52272 Value is a big-endian 64-bit\n    ** twos-complement integer. */\n    pMem->u.i = *(i64*)&x;\n    pMem->flags = MEM_Int;\n    testcase( pMem->u.i<0 );\n  }else{\n    /* EVIDENCE-OF: R-57343-49114 Value is a big-endian IEEE 754-2008 64-bit\n    ** floating point number. */\n#if !defined(NDEBUG) && !defined(SQLITE_OMIT_FLOATING_POINT)\n    /* Verify that integers and floating point values use the same\n    ** byte order.  Or, that if SQLITE_MIXED_ENDIAN_64BIT_FLOAT is\n    ** defined that 64-bit floating point values really are mixed\n    ** endian.\n    */\n    static const u64 t1 = ((u64)0x3ff00000)<<32;\n    static const double r1 = 1.0;\n    u64 t2 = t1;\n    swapMixedEndianFloat(t2);\n    assert( sizeof(r1)==sizeof(t2) && memcmp(&r1, &t2, sizeof(r1))==0 );\n#endif\n    assert( sizeof(x)==8 && sizeof(pMem->u.r)==8 );\n    swapMixedEndianFloat(x);\n    memcpy(&pMem->u.r, &x, sizeof(x));\n    pMem->flags = sqlite3IsNaN(pMem->u.r) ? MEM_Null : MEM_Real;\n  }\n  return 8;\n}\nSQLITE_PRIVATE u32 sqlite3VdbeSerialGet(\n  const unsigned char *buf,     /* Buffer to deserialize from */\n  u32 serial_type,              /* Serial type to deserialize */\n  Mem *pMem                     /* Memory cell to write value into */\n){\n  switch( serial_type ){\n    case 10: { /* Internal use only: NULL with virtual table\n               ** UPDATE no-change flag set */\n      pMem->flags = MEM_Null|MEM_Zero;\n      pMem->n = 0;\n      pMem->u.nZero = 0;\n      break;\n    }\n    case 11:   /* Reserved for future use */\n    case 0: {  /* Null */\n      /* EVIDENCE-OF: R-24078-09375 Value is a NULL. */\n      pMem->flags = MEM_Null;\n      break;\n    }\n    case 1: {\n      /* EVIDENCE-OF: R-44885-25196 Value is an 8-bit twos-complement\n      ** integer. */\n      pMem->u.i = ONE_BYTE_INT(buf);\n      pMem->flags = MEM_Int;\n      testcase( pMem->u.i<0 );\n      return 1;\n    }\n    case 2: { /* 2-byte signed integer */\n      /* EVIDENCE-OF: R-49794-35026 Value is a big-endian 16-bit\n      ** twos-complement integer. */\n      pMem->u.i = TWO_BYTE_INT(buf);\n      pMem->flags = MEM_Int;\n      testcase( pMem->u.i<0 );\n      return 2;\n    }\n    case 3: { /* 3-byte signed integer */\n      /* EVIDENCE-OF: R-37839-54301 Value is a big-endian 24-bit\n      ** twos-complement integer. */\n      pMem->u.i = THREE_BYTE_INT(buf);\n      pMem->flags = MEM_Int;\n      testcase( pMem->u.i<0 );\n      return 3;\n    }\n    case 4: { /* 4-byte signed integer */\n      /* EVIDENCE-OF: R-01849-26079 Value is a big-endian 32-bit\n      ** twos-complement integer. */\n      pMem->u.i = FOUR_BYTE_INT(buf);\n#ifdef __HP_cc \n      /* Work around a sign-extension bug in the HP compiler for HP/UX */\n      if( buf[0]&0x80 ) pMem->u.i |= 0xffffffff80000000LL;\n#endif\n      pMem->flags = MEM_Int;\n      testcase( pMem->u.i<0 );\n      return 4;\n    }\n    case 5: { /* 6-byte signed integer */\n      /* EVIDENCE-OF: R-50385-09674 Value is a big-endian 48-bit\n      ** twos-complement integer. */\n      pMem->u.i = FOUR_BYTE_UINT(buf+2) + (((i64)1)<<32)*TWO_BYTE_INT(buf);\n      pMem->flags = MEM_Int;\n      testcase( pMem->u.i<0 );\n      return 6;\n    }\n    case 6:   /* 8-byte signed integer */\n    case 7: { /* IEEE floating point */\n      /* These use local variables, so do them in a separate routine\n      ** to avoid having to move the frame pointer in the common case */\n      return serialGet(buf,serial_type,pMem);\n    }\n    case 8:    /* Integer 0 */\n    case 9: {  /* Integer 1 */\n      /* EVIDENCE-OF: R-12976-22893 Value is the integer 0. */\n      /* EVIDENCE-OF: R-18143-12121 Value is the integer 1. */\n      pMem->u.i = serial_type-8;\n      pMem->flags = MEM_Int;\n      return 0;\n    }\n    default: {\n      /* EVIDENCE-OF: R-14606-31564 Value is a BLOB that is (N-12)/2 bytes in\n      ** length.\n      ** EVIDENCE-OF: R-28401-00140 Value is a string in the text encoding and\n      ** (N-13)/2 bytes in length. */\n      static const u16 aFlag[] = { MEM_Blob|MEM_Ephem, MEM_Str|MEM_Ephem };\n      pMem->z = (char *)buf;\n      pMem->n = (serial_type-12)/2;\n      pMem->flags = aFlag[serial_type&1];\n      return pMem->n;\n    }\n  }\n  return 0;\n}\n/*\n** This routine is used to allocate sufficient space for an UnpackedRecord\n** structure large enough to be used with sqlite3VdbeRecordUnpack() if\n** the first argument is a pointer to KeyInfo structure pKeyInfo.\n**\n** The space is either allocated using sqlite3DbMallocRaw() or from within\n** the unaligned buffer passed via the second and third arguments (presumably\n** stack space). If the former, then *ppFree is set to a pointer that should\n** be eventually freed by the caller using sqlite3DbFree(). Or, if the \n** allocation comes from the pSpace/szSpace buffer, *ppFree is set to NULL\n** before returning.\n**\n** If an OOM error occurs, NULL is returned.\n*/\nSQLITE_PRIVATE UnpackedRecord *sqlite3VdbeAllocUnpackedRecord(\n  KeyInfo *pKeyInfo               /* Description of the record */\n){\n  UnpackedRecord *p;              /* Unpacked record to return */\n  int nByte;                      /* Number of bytes required for *p */\n  nByte = ROUND8(sizeof(UnpackedRecord)) + sizeof(Mem)*(pKeyInfo->nKeyField+1);\n  p = (UnpackedRecord *)sqlite3DbMallocRaw(pKeyInfo->db, nByte);\n  if( !p ) return 0;\n  p->aMem = (Mem*)&((char*)p)[ROUND8(sizeof(UnpackedRecord))];\n  assert( pKeyInfo->aSortOrder!=0 );\n  p->pKeyInfo = pKeyInfo;\n  p->nField = pKeyInfo->nKeyField + 1;\n  return p;\n}\n\n/*\n** Given the nKey-byte encoding of a record in pKey[], populate the \n** UnpackedRecord structure indicated by the fourth argument with the\n** contents of the decoded record.\n*/ \nSQLITE_PRIVATE void sqlite3VdbeRecordUnpack(\n  KeyInfo *pKeyInfo,     /* Information about the record format */\n  int nKey,              /* Size of the binary record */\n  const void *pKey,      /* The binary record */\n  UnpackedRecord *p      /* Populate this structure before returning. */\n){\n  const unsigned char *aKey = (const unsigned char *)pKey;\n  u32 d; \n  u32 idx;                        /* Offset in aKey[] to read from */\n  u16 u;                          /* Unsigned loop counter */\n  u32 szHdr;\n  Mem *pMem = p->aMem;\n\n  p->default_rc = 0;\n  assert( EIGHT_BYTE_ALIGNMENT(pMem) );\n  idx = getVarint32(aKey, szHdr);\n  d = szHdr;\n  u = 0;\n  while( idx<szHdr && d<=(u32)nKey ){\n    u32 serial_type;\n\n    idx += getVarint32(&aKey[idx], serial_type);\n    pMem->enc = pKeyInfo->enc;\n    pMem->db = pKeyInfo->db;\n    /* pMem->flags = 0; // sqlite3VdbeSerialGet() will set this for us */\n    pMem->szMalloc = 0;\n    pMem->z = 0;\n    d += sqlite3VdbeSerialGet(&aKey[d], serial_type, pMem);\n    pMem++;\n    if( (++u)>=p->nField ) break;\n  }\n  if( d>(u32)nKey && u ){\n    assert( CORRUPT_DB );\n    /* In a corrupt record entry, the last pMem might have been set up using \n    ** uninitialized memory. Overwrite its value with NULL, to prevent\n    ** warnings from MSAN. */\n    sqlite3VdbeMemSetNull(pMem-1);\n  }\n  assert( u<=pKeyInfo->nKeyField + 1 );\n  p->nField = u;\n}\n\n#ifdef SQLITE_DEBUG\n/*\n** This function compares two index or table record keys in the same way\n** as the sqlite3VdbeRecordCompare() routine. Unlike VdbeRecordCompare(),\n** this function deserializes and compares values using the\n** sqlite3VdbeSerialGet() and sqlite3MemCompare() functions. It is used\n** in assert() statements to ensure that the optimized code in\n** sqlite3VdbeRecordCompare() returns results with these two primitives.\n**\n** Return true if the result of comparison is equivalent to desiredResult.\n** Return false if there is a disagreement.\n*/\nstatic int vdbeRecordCompareDebug(\n  int nKey1, const void *pKey1, /* Left key */\n  const UnpackedRecord *pPKey2, /* Right key */\n  int desiredResult             /* Correct answer */\n){\n  u32 d1;            /* Offset into aKey[] of next data element */\n  u32 idx1;          /* Offset into aKey[] of next header element */\n  u32 szHdr1;        /* Number of bytes in header */\n  int i = 0;\n  int rc = 0;\n  const unsigned char *aKey1 = (const unsigned char *)pKey1;\n  KeyInfo *pKeyInfo;\n  Mem mem1;\n\n  pKeyInfo = pPKey2->pKeyInfo;\n  if( pKeyInfo->db==0 ) return 1;\n  mem1.enc = pKeyInfo->enc;\n  mem1.db = pKeyInfo->db;\n  /* mem1.flags = 0;  // Will be initialized by sqlite3VdbeSerialGet() */\n  VVA_ONLY( mem1.szMalloc = 0; ) /* Only needed by assert() statements */\n\n  /* Compilers may complain that mem1.u.i is potentially uninitialized.\n  ** We could initialize it, as shown here, to silence those complaints.\n  ** But in fact, mem1.u.i will never actually be used uninitialized, and doing \n  ** the unnecessary initialization has a measurable negative performance\n  ** impact, since this routine is a very high runner.  And so, we choose\n  ** to ignore the compiler warnings and leave this variable uninitialized.\n  */\n  /*  mem1.u.i = 0;  // not needed, here to silence compiler warning */\n  \n  idx1 = getVarint32(aKey1, szHdr1);\n  if( szHdr1>98307 ) return SQLITE_CORRUPT;\n  d1 = szHdr1;\n  assert( pKeyInfo->nAllField>=pPKey2->nField || CORRUPT_DB );\n  assert( pKeyInfo->aSortOrder!=0 );\n  assert( pKeyInfo->nKeyField>0 );\n  assert( idx1<=szHdr1 || CORRUPT_DB );\n  do{\n    u32 serial_type1;\n\n    /* Read the serial types for the next element in each key. */\n    idx1 += getVarint32( aKey1+idx1, serial_type1 );\n\n    /* Verify that there is enough key space remaining to avoid\n    ** a buffer overread.  The \"d1+serial_type1+2\" subexpression will\n    ** always be greater than or equal to the amount of required key space.\n    ** Use that approximation to avoid the more expensive call to\n    ** sqlite3VdbeSerialTypeLen() in the common case.\n    */\n    if( d1+(u64)serial_type1+2>(u64)nKey1\n     && d1+(u64)sqlite3VdbeSerialTypeLen(serial_type1)>(u64)nKey1 \n    ){\n      break;\n    }\n\n    /* Extract the values to be compared.\n    */\n    d1 += sqlite3VdbeSerialGet(&aKey1[d1], serial_type1, &mem1);\n\n    /* Do the comparison\n    */\n    rc = sqlite3MemCompare(&mem1, &pPKey2->aMem[i],\n                           pKeyInfo->nAllField>i ? pKeyInfo->aColl[i] : 0);\n    if( rc!=0 ){\n      assert( mem1.szMalloc==0 );  /* See comment below */\n      if( pKeyInfo->aSortOrder[i] ){\n        rc = -rc;  /* Invert the result for DESC sort order. */\n      }\n      goto debugCompareEnd;\n    }\n    i++;\n  }while( idx1<szHdr1 && i<pPKey2->nField );\n\n  /* No memory allocation is ever used on mem1.  Prove this using\n  ** the following assert().  If the assert() fails, it indicates a\n  ** memory leak and a need to call sqlite3VdbeMemRelease(&mem1).\n  */\n  assert( mem1.szMalloc==0 );\n\n  /* rc==0 here means that one of the keys ran out of fields and\n  ** all the fields up to that point were equal. Return the default_rc\n  ** value.  */\n  rc = pPKey2->default_rc;\n\ndebugCompareEnd:\n  if( desiredResult==0 && rc==0 ) return 1;\n  if( desiredResult<0 && rc<0 ) return 1;\n  if( desiredResult>0 && rc>0 ) return 1;\n  if( CORRUPT_DB ) return 1;\n  if( pKeyInfo->db->mallocFailed ) return 1;\n  return 0;\n}\n#endif\n\n#ifdef SQLITE_DEBUG\n/*\n** Count the number of fields (a.k.a. columns) in the record given by\n** pKey,nKey.  The verify that this count is less than or equal to the\n** limit given by pKeyInfo->nAllField.\n**\n** If this constraint is not satisfied, it means that the high-speed\n** vdbeRecordCompareInt() and vdbeRecordCompareString() routines will\n** not work correctly.  If this assert() ever fires, it probably means\n** that the KeyInfo.nKeyField or KeyInfo.nAllField values were computed\n** incorrectly.\n*/\nstatic void vdbeAssertFieldCountWithinLimits(\n  int nKey, const void *pKey,   /* The record to verify */ \n  const KeyInfo *pKeyInfo       /* Compare size with this KeyInfo */\n){\n  int nField = 0;\n  u32 szHdr;\n  u32 idx;\n  u32 notUsed;\n  const unsigned char *aKey = (const unsigned char*)pKey;\n\n  if( CORRUPT_DB ) return;\n  idx = getVarint32(aKey, szHdr);\n  assert( nKey>=0 );\n  assert( szHdr<=(u32)nKey );\n  while( idx<szHdr ){\n    idx += getVarint32(aKey+idx, notUsed);\n    nField++;\n  }\n  assert( nField <= pKeyInfo->nAllField );\n}\n#else\n# define vdbeAssertFieldCountWithinLimits(A,B,C)\n#endif\n\n/*\n** Both *pMem1 and *pMem2 contain string values. Compare the two values\n** using the collation sequence pColl. As usual, return a negative , zero\n** or positive value if *pMem1 is less than, equal to or greater than \n** *pMem2, respectively. Similar in spirit to \"rc = (*pMem1) - (*pMem2);\".\n*/\nstatic int vdbeCompareMemString(\n  const Mem *pMem1,\n  const Mem *pMem2,\n  const CollSeq *pColl,\n  u8 *prcErr                      /* If an OOM occurs, set to SQLITE_NOMEM */\n){\n  if( pMem1->enc==pColl->enc ){\n    /* The strings are already in the correct encoding.  Call the\n     ** comparison function directly */\n    return pColl->xCmp(pColl->pUser,pMem1->n,pMem1->z,pMem2->n,pMem2->z);\n  }else{\n    int rc;\n    const void *v1, *v2;\n    Mem c1;\n    Mem c2;\n    sqlite3VdbeMemInit(&c1, pMem1->db, MEM_Null);\n    sqlite3VdbeMemInit(&c2, pMem1->db, MEM_Null);\n    sqlite3VdbeMemShallowCopy(&c1, pMem1, MEM_Ephem);\n    sqlite3VdbeMemShallowCopy(&c2, pMem2, MEM_Ephem);\n    v1 = sqlite3ValueText((sqlite3_value*)&c1, pColl->enc);\n    v2 = sqlite3ValueText((sqlite3_value*)&c2, pColl->enc);\n    if( (v1==0 || v2==0) ){\n      if( prcErr ) *prcErr = SQLITE_NOMEM_BKPT;\n      rc = 0;\n    }else{\n      rc = pColl->xCmp(pColl->pUser, c1.n, v1, c2.n, v2);\n    }\n    sqlite3VdbeMemRelease(&c1);\n    sqlite3VdbeMemRelease(&c2);\n    return rc;\n  }\n}\n\n/*\n** The input pBlob is guaranteed to be a Blob that is not marked\n** with MEM_Zero.  Return true if it could be a zero-blob.\n*/\nstatic int isAllZero(const char *z, int n){\n  int i;\n  for(i=0; i<n; i++){\n    if( z[i] ) return 0;\n  }\n  return 1;\n}\n\n/*\n** Compare two blobs.  Return negative, zero, or positive if the first\n** is less than, equal to, or greater than the second, respectively.\n** If one blob is a prefix of the other, then the shorter is the lessor.\n*/\nSQLITE_PRIVATE SQLITE_NOINLINE int sqlite3BlobCompare(const Mem *pB1, const Mem *pB2){\n  int c;\n  int n1 = pB1->n;\n  int n2 = pB2->n;\n\n  /* It is possible to have a Blob value that has some non-zero content\n  ** followed by zero content.  But that only comes up for Blobs formed\n  ** by the OP_MakeRecord opcode, and such Blobs never get passed into\n  ** sqlite3MemCompare(). */\n  assert( (pB1->flags & MEM_Zero)==0 || n1==0 );\n  assert( (pB2->flags & MEM_Zero)==0 || n2==0 );\n\n  if( (pB1->flags|pB2->flags) & MEM_Zero ){\n    if( pB1->flags & pB2->flags & MEM_Zero ){\n      return pB1->u.nZero - pB2->u.nZero;\n    }else if( pB1->flags & MEM_Zero ){\n      if( !isAllZero(pB2->z, pB2->n) ) return -1;\n      return pB1->u.nZero - n2;\n    }else{\n      if( !isAllZero(pB1->z, pB1->n) ) return +1;\n      return n1 - pB2->u.nZero;\n    }\n  }\n  c = memcmp(pB1->z, pB2->z, n1>n2 ? n2 : n1);\n  if( c ) return c;\n  return n1 - n2;\n}\n\n/*\n** Do a comparison between a 64-bit signed integer and a 64-bit floating-point\n** number.  Return negative, zero, or positive if the first (i64) is less than,\n** equal to, or greater than the second (double).\n*/\nstatic int sqlite3IntFloatCompare(i64 i, double r){\n  if( sizeof(LONGDOUBLE_TYPE)>8 ){\n    LONGDOUBLE_TYPE x = (LONGDOUBLE_TYPE)i;\n    if( x<r ) return -1;\n    if( x>r ) return +1;\n    return 0;\n  }else{\n    i64 y;\n    double s;\n    if( r<-9223372036854775808.0 ) return +1;\n    if( r>=9223372036854775808.0 ) return -1;\n    y = (i64)r;\n    if( i<y ) return -1;\n    if( i>y ) return +1;\n    s = (double)i;\n    if( s<r ) return -1;\n    if( s>r ) return +1;\n    return 0;\n  }\n}\n\n/*\n** Compare the values contained by the two memory cells, returning\n** negative, zero or positive if pMem1 is less than, equal to, or greater\n** than pMem2. Sorting order is NULL's first, followed by numbers (integers\n** and reals) sorted numerically, followed by text ordered by the collating\n** sequence pColl and finally blob's ordered by memcmp().\n**\n** Two NULL values are considered equal by this function.\n*/\nSQLITE_PRIVATE int sqlite3MemCompare(const Mem *pMem1, const Mem *pMem2, const CollSeq *pColl){\n  int f1, f2;\n  int combined_flags;\n\n  f1 = pMem1->flags;\n  f2 = pMem2->flags;\n  combined_flags = f1|f2;\n  assert( !sqlite3VdbeMemIsRowSet(pMem1) && !sqlite3VdbeMemIsRowSet(pMem2) );\n \n  /* If one value is NULL, it is less than the other. If both values\n  ** are NULL, return 0.\n  */\n  if( combined_flags&MEM_Null ){\n    return (f2&MEM_Null) - (f1&MEM_Null);\n  }\n\n  /* At least one of the two values is a number\n  */\n  if( combined_flags&(MEM_Int|MEM_Real) ){\n    if( (f1 & f2 & MEM_Int)!=0 ){\n      if( pMem1->u.i < pMem2->u.i ) return -1;\n      if( pMem1->u.i > pMem2->u.i ) return +1;\n      return 0;\n    }\n    if( (f1 & f2 & MEM_Real)!=0 ){\n      if( pMem1->u.r < pMem2->u.r ) return -1;\n      if( pMem1->u.r > pMem2->u.r ) return +1;\n      return 0;\n    }\n    if( (f1&MEM_Int)!=0 ){\n      if( (f2&MEM_Real)!=0 ){\n        return sqlite3IntFloatCompare(pMem1->u.i, pMem2->u.r);\n      }else{\n        return -1;\n      }\n    }\n    if( (f1&MEM_Real)!=0 ){\n      if( (f2&MEM_Int)!=0 ){\n        return -sqlite3IntFloatCompare(pMem2->u.i, pMem1->u.r);\n      }else{\n        return -1;\n      }\n    }\n    return +1;\n  }\n\n  /* If one value is a string and the other is a blob, the string is less.\n  ** If both are strings, compare using the collating functions.\n  */\n  if( combined_flags&MEM_Str ){\n    if( (f1 & MEM_Str)==0 ){\n      return 1;\n    }\n    if( (f2 & MEM_Str)==0 ){\n      return -1;\n    }\n\n    assert( pMem1->enc==pMem2->enc || pMem1->db->mallocFailed );\n    assert( pMem1->enc==SQLITE_UTF8 || \n            pMem1->enc==SQLITE_UTF16LE || pMem1->enc==SQLITE_UTF16BE );\n\n    /* The collation sequence must be defined at this point, even if\n    ** the user deletes the collation sequence after the vdbe program is\n    ** compiled (this was not always the case).\n    */\n    assert( !pColl || pColl->xCmp );\n\n    if( pColl ){\n      return vdbeCompareMemString(pMem1, pMem2, pColl, 0);\n    }\n    /* If a NULL pointer was passed as the collate function, fall through\n    ** to the blob case and use memcmp().  */\n  }\n \n  /* Both values must be blobs.  Compare using memcmp().  */\n  return sqlite3BlobCompare(pMem1, pMem2);\n}\n\n\n/*\n** The first argument passed to this function is a serial-type that\n** corresponds to an integer - all values between 1 and 9 inclusive \n** except 7. The second points to a buffer containing an integer value\n** serialized according to serial_type. This function deserializes\n** and returns the value.\n*/\nstatic i64 vdbeRecordDecodeInt(u32 serial_type, const u8 *aKey){\n  u32 y;\n  assert( CORRUPT_DB || (serial_type>=1 && serial_type<=9 && serial_type!=7) );\n  switch( serial_type ){\n    case 0:\n    case 1:\n      testcase( aKey[0]&0x80 );\n      return ONE_BYTE_INT(aKey);\n    case 2:\n      testcase( aKey[0]&0x80 );\n      return TWO_BYTE_INT(aKey);\n    case 3:\n      testcase( aKey[0]&0x80 );\n      return THREE_BYTE_INT(aKey);\n    case 4: {\n      testcase( aKey[0]&0x80 );\n      y = FOUR_BYTE_UINT(aKey);\n      return (i64)*(int*)&y;\n    }\n    case 5: {\n      testcase( aKey[0]&0x80 );\n      return FOUR_BYTE_UINT(aKey+2) + (((i64)1)<<32)*TWO_BYTE_INT(aKey);\n    }\n    case 6: {\n      u64 x = FOUR_BYTE_UINT(aKey);\n      testcase( aKey[0]&0x80 );\n      x = (x<<32) | FOUR_BYTE_UINT(aKey+4);\n      return (i64)*(i64*)&x;\n    }\n  }\n\n  return (serial_type - 8);\n}\n\n/*\n** This function compares the two table rows or index records\n** specified by {nKey1, pKey1} and pPKey2.  It returns a negative, zero\n** or positive integer if key1 is less than, equal to or \n** greater than key2.  The {nKey1, pKey1} key must be a blob\n** created by the OP_MakeRecord opcode of the VDBE.  The pPKey2\n** key must be a parsed key such as obtained from\n** sqlite3VdbeParseRecord.\n**\n** If argument bSkip is non-zero, it is assumed that the caller has already\n** determined that the first fields of the keys are equal.\n**\n** Key1 and Key2 do not have to contain the same number of fields. If all \n** fields that appear in both keys are equal, then pPKey2->default_rc is \n** returned.\n**\n** If database corruption is discovered, set pPKey2->errCode to \n** SQLITE_CORRUPT and return 0. If an OOM error is encountered, \n** pPKey2->errCode is set to SQLITE_NOMEM and, if it is not NULL, the\n** malloc-failed flag set on database handle (pPKey2->pKeyInfo->db).\n*/\nSQLITE_PRIVATE int sqlite3VdbeRecordCompareWithSkip(\n  int nKey1, const void *pKey1,   /* Left key */\n  UnpackedRecord *pPKey2,         /* Right key */\n  int bSkip                       /* If true, skip the first field */\n){\n  u32 d1;                         /* Offset into aKey[] of next data element */\n  int i;                          /* Index of next field to compare */\n  u32 szHdr1;                     /* Size of record header in bytes */\n  u32 idx1;                       /* Offset of first type in header */\n  int rc = 0;                     /* Return value */\n  Mem *pRhs = pPKey2->aMem;       /* Next field of pPKey2 to compare */\n  KeyInfo *pKeyInfo;\n  const unsigned char *aKey1 = (const unsigned char *)pKey1;\n  Mem mem1;\n\n  /* If bSkip is true, then the caller has already determined that the first\n  ** two elements in the keys are equal. Fix the various stack variables so\n  ** that this routine begins comparing at the second field. */\n  if( bSkip ){\n    u32 s1;\n    idx1 = 1 + getVarint32(&aKey1[1], s1);\n    szHdr1 = aKey1[0];\n    d1 = szHdr1 + sqlite3VdbeSerialTypeLen(s1);\n    i = 1;\n    pRhs++;\n  }else{\n    idx1 = getVarint32(aKey1, szHdr1);\n    d1 = szHdr1;\n    i = 0;\n  }\n  if( d1>(unsigned)nKey1 ){ \n    pPKey2->errCode = (u8)SQLITE_CORRUPT_BKPT;\n    return 0;  /* Corruption */\n  }\n\n  VVA_ONLY( mem1.szMalloc = 0; ) /* Only needed by assert() statements */\n  assert( pPKey2->pKeyInfo->nAllField>=pPKey2->nField \n       || CORRUPT_DB );\n  assert( pPKey2->pKeyInfo->aSortOrder!=0 );\n  assert( pPKey2->pKeyInfo->nKeyField>0 );\n  assert( idx1<=szHdr1 || CORRUPT_DB );\n  do{\n    u32 serial_type;\n\n    /* RHS is an integer */\n    if( pRhs->flags & MEM_Int ){\n      serial_type = aKey1[idx1];\n      testcase( serial_type==12 );\n      if( serial_type>=10 ){\n        rc = +1;\n      }else if( serial_type==0 ){\n        rc = -1;\n      }else if( serial_type==7 ){\n        sqlite3VdbeSerialGet(&aKey1[d1], serial_type, &mem1);\n        rc = -sqlite3IntFloatCompare(pRhs->u.i, mem1.u.r);\n      }else{\n        i64 lhs = vdbeRecordDecodeInt(serial_type, &aKey1[d1]);\n        i64 rhs = pRhs->u.i;\n        if( lhs<rhs ){\n          rc = -1;\n        }else if( lhs>rhs ){\n          rc = +1;\n        }\n      }\n    }\n\n    /* RHS is real */\n    else if( pRhs->flags & MEM_Real ){\n      serial_type = aKey1[idx1];\n      if( serial_type>=10 ){\n        /* Serial types 12 or greater are strings and blobs (greater than\n        ** numbers). Types 10 and 11 are currently \"reserved for future \n        ** use\", so it doesn't really matter what the results of comparing\n        ** them to numberic values are.  */\n        rc = +1;\n      }else if( serial_type==0 ){\n        rc = -1;\n      }else{\n        sqlite3VdbeSerialGet(&aKey1[d1], serial_type, &mem1);\n        if( serial_type==7 ){\n          if( mem1.u.r<pRhs->u.r ){\n            rc = -1;\n          }else if( mem1.u.r>pRhs->u.r ){\n            rc = +1;\n          }\n        }else{\n          rc = sqlite3IntFloatCompare(mem1.u.i, pRhs->u.r);\n        }\n      }\n    }\n\n    /* RHS is a string */\n    else if( pRhs->flags & MEM_Str ){\n      getVarint32(&aKey1[idx1], serial_type);\n      testcase( serial_type==12 );\n      if( serial_type<12 ){\n        rc = -1;\n      }else if( !(serial_type & 0x01) ){\n        rc = +1;\n      }else{\n        mem1.n = (serial_type - 12) / 2;\n        testcase( (d1+mem1.n)==(unsigned)nKey1 );\n        testcase( (d1+mem1.n+1)==(unsigned)nKey1 );\n        if( (d1+mem1.n) > (unsigned)nKey1\n         || (pKeyInfo = pPKey2->pKeyInfo)->nAllField<=i\n        ){\n          pPKey2->errCode = (u8)SQLITE_CORRUPT_BKPT;\n          return 0;                /* Corruption */\n        }else if( pKeyInfo->aColl[i] ){\n          mem1.enc = pKeyInfo->enc;\n          mem1.db = pKeyInfo->db;\n          mem1.flags = MEM_Str;\n          mem1.z = (char*)&aKey1[d1];\n          rc = vdbeCompareMemString(\n              &mem1, pRhs, pKeyInfo->aColl[i], &pPKey2->errCode\n          );\n        }else{\n          int nCmp = MIN(mem1.n, pRhs->n);\n          rc = memcmp(&aKey1[d1], pRhs->z, nCmp);\n          if( rc==0 ) rc = mem1.n - pRhs->n; \n        }\n      }\n    }\n\n    /* RHS is a blob */\n    else if( pRhs->flags & MEM_Blob ){\n      assert( (pRhs->flags & MEM_Zero)==0 || pRhs->n==0 );\n      getVarint32(&aKey1[idx1], serial_type);\n      testcase( serial_type==12 );\n      if( serial_type<12 || (serial_type & 0x01) ){\n        rc = -1;\n      }else{\n        int nStr = (serial_type - 12) / 2;\n        testcase( (d1+nStr)==(unsigned)nKey1 );\n        testcase( (d1+nStr+1)==(unsigned)nKey1 );\n        if( (d1+nStr) > (unsigned)nKey1 ){\n          pPKey2->errCode = (u8)SQLITE_CORRUPT_BKPT;\n          return 0;                /* Corruption */\n        }else if( pRhs->flags & MEM_Zero ){\n          if( !isAllZero((const char*)&aKey1[d1],nStr) ){\n            rc = 1;\n          }else{\n            rc = nStr - pRhs->u.nZero;\n          }\n        }else{\n          int nCmp = MIN(nStr, pRhs->n);\n          rc = memcmp(&aKey1[d1], pRhs->z, nCmp);\n          if( rc==0 ) rc = nStr - pRhs->n;\n        }\n      }\n    }\n\n    /* RHS is null */\n    else{\n      serial_type = aKey1[idx1];\n      rc = (serial_type!=0);\n    }\n\n    if( rc!=0 ){\n      if( pPKey2->pKeyInfo->aSortOrder[i] ){\n        rc = -rc;\n      }\n      assert( vdbeRecordCompareDebug(nKey1, pKey1, pPKey2, rc) );\n      assert( mem1.szMalloc==0 );  /* See comment below */\n      return rc;\n    }\n\n    i++;\n    if( i==pPKey2->nField ) break;\n    pRhs++;\n    d1 += sqlite3VdbeSerialTypeLen(serial_type);\n    idx1 += sqlite3VarintLen(serial_type);\n  }while( idx1<(unsigned)szHdr1 && d1<=(unsigned)nKey1 );\n\n  /* No memory allocation is ever used on mem1.  Prove this using\n  ** the following assert().  If the assert() fails, it indicates a\n  ** memory leak and a need to call sqlite3VdbeMemRelease(&mem1).  */\n  assert( mem1.szMalloc==0 );\n\n  /* rc==0 here means that one or both of the keys ran out of fields and\n  ** all the fields up to that point were equal. Return the default_rc\n  ** value.  */\n  assert( CORRUPT_DB \n       || vdbeRecordCompareDebug(nKey1, pKey1, pPKey2, pPKey2->default_rc) \n       || pPKey2->pKeyInfo->db->mallocFailed\n  );\n  pPKey2->eqSeen = 1;\n  return pPKey2->default_rc;\n}\nSQLITE_PRIVATE int sqlite3VdbeRecordCompare(\n  int nKey1, const void *pKey1,   /* Left key */\n  UnpackedRecord *pPKey2          /* Right key */\n){\n  return sqlite3VdbeRecordCompareWithSkip(nKey1, pKey1, pPKey2, 0);\n}\n\n\n/*\n** This function is an optimized version of sqlite3VdbeRecordCompare() \n** that (a) the first field of pPKey2 is an integer, and (b) the \n** size-of-header varint at the start of (pKey1/nKey1) fits in a single\n** byte (i.e. is less than 128).\n**\n** To avoid concerns about buffer overreads, this routine is only used\n** on schemas where the maximum valid header size is 63 bytes or less.\n*/\nstatic int vdbeRecordCompareInt(\n  int nKey1, const void *pKey1, /* Left key */\n  UnpackedRecord *pPKey2        /* Right key */\n){\n  const u8 *aKey = &((const u8*)pKey1)[*(const u8*)pKey1 & 0x3F];\n  int serial_type = ((const u8*)pKey1)[1];\n  int res;\n  u32 y;\n  u64 x;\n  i64 v;\n  i64 lhs;\n\n  vdbeAssertFieldCountWithinLimits(nKey1, pKey1, pPKey2->pKeyInfo);\n  assert( (*(u8*)pKey1)<=0x3F || CORRUPT_DB );\n  switch( serial_type ){\n    case 1: { /* 1-byte signed integer */\n      lhs = ONE_BYTE_INT(aKey);\n      testcase( lhs<0 );\n      break;\n    }\n    case 2: { /* 2-byte signed integer */\n      lhs = TWO_BYTE_INT(aKey);\n      testcase( lhs<0 );\n      break;\n    }\n    case 3: { /* 3-byte signed integer */\n      lhs = THREE_BYTE_INT(aKey);\n      testcase( lhs<0 );\n      break;\n    }\n    case 4: { /* 4-byte signed integer */\n      y = FOUR_BYTE_UINT(aKey);\n      lhs = (i64)*(int*)&y;\n      testcase( lhs<0 );\n      break;\n    }\n    case 5: { /* 6-byte signed integer */\n      lhs = FOUR_BYTE_UINT(aKey+2) + (((i64)1)<<32)*TWO_BYTE_INT(aKey);\n      testcase( lhs<0 );\n      break;\n    }\n    case 6: { /* 8-byte signed integer */\n      x = FOUR_BYTE_UINT(aKey);\n      x = (x<<32) | FOUR_BYTE_UINT(aKey+4);\n      lhs = *(i64*)&x;\n      testcase( lhs<0 );\n      break;\n    }\n    case 8: \n      lhs = 0;\n      break;\n    case 9:\n      lhs = 1;\n      break;\n\n    /* This case could be removed without changing the results of running\n    ** this code. Including it causes gcc to generate a faster switch \n    ** statement (since the range of switch targets now starts at zero and\n    ** is contiguous) but does not cause any duplicate code to be generated\n    ** (as gcc is clever enough to combine the two like cases). Other \n    ** compilers might be similar.  */ \n    case 0: case 7:\n      return sqlite3VdbeRecordCompare(nKey1, pKey1, pPKey2);\n\n    default:\n      return sqlite3VdbeRecordCompare(nKey1, pKey1, pPKey2);\n  }\n\n  v = pPKey2->aMem[0].u.i;\n  if( v>lhs ){\n    res = pPKey2->r1;\n  }else if( v<lhs ){\n    res = pPKey2->r2;\n  }else if( pPKey2->nField>1 ){\n    /* The first fields of the two keys are equal. Compare the trailing \n    ** fields.  */\n    res = sqlite3VdbeRecordCompareWithSkip(nKey1, pKey1, pPKey2, 1);\n  }else{\n    /* The first fields of the two keys are equal and there are no trailing\n    ** fields. Return pPKey2->default_rc in this case. */\n    res = pPKey2->default_rc;\n    pPKey2->eqSeen = 1;\n  }\n\n  assert( vdbeRecordCompareDebug(nKey1, pKey1, pPKey2, res) );\n  return res;\n}\n\n/*\n** This function is an optimized version of sqlite3VdbeRecordCompare() \n** that (a) the first field of pPKey2 is a string, that (b) the first field\n** uses the collation sequence BINARY and (c) that the size-of-header varint \n** at the start of (pKey1/nKey1) fits in a single byte.\n*/\nstatic int vdbeRecordCompareString(\n  int nKey1, const void *pKey1, /* Left key */\n  UnpackedRecord *pPKey2        /* Right key */\n){\n  const u8 *aKey1 = (const u8*)pKey1;\n  int serial_type;\n  int res;\n\n  assert( pPKey2->aMem[0].flags & MEM_Str );\n  vdbeAssertFieldCountWithinLimits(nKey1, pKey1, pPKey2->pKeyInfo);\n  getVarint32(&aKey1[1], serial_type);\n  if( serial_type<12 ){\n    res = pPKey2->r1;      /* (pKey1/nKey1) is a number or a null */\n  }else if( !(serial_type & 0x01) ){ \n    res = pPKey2->r2;      /* (pKey1/nKey1) is a blob */\n  }else{\n    int nCmp;\n    int nStr;\n    int szHdr = aKey1[0];\n\n    nStr = (serial_type-12) / 2;\n    if( (szHdr + nStr) > nKey1 ){\n      pPKey2->errCode = (u8)SQLITE_CORRUPT_BKPT;\n      return 0;    /* Corruption */\n    }\n    nCmp = MIN( pPKey2->aMem[0].n, nStr );\n    res = memcmp(&aKey1[szHdr], pPKey2->aMem[0].z, nCmp);\n\n    if( res==0 ){\n      res = nStr - pPKey2->aMem[0].n;\n      if( res==0 ){\n        if( pPKey2->nField>1 ){\n          res = sqlite3VdbeRecordCompareWithSkip(nKey1, pKey1, pPKey2, 1);\n        }else{\n          res = pPKey2->default_rc;\n          pPKey2->eqSeen = 1;\n        }\n      }else if( res>0 ){\n        res = pPKey2->r2;\n      }else{\n        res = pPKey2->r1;\n      }\n    }else if( res>0 ){\n      res = pPKey2->r2;\n    }else{\n      res = pPKey2->r1;\n    }\n  }\n\n  assert( vdbeRecordCompareDebug(nKey1, pKey1, pPKey2, res)\n       || CORRUPT_DB\n       || pPKey2->pKeyInfo->db->mallocFailed\n  );\n  return res;\n}\n\n/*\n** Return a pointer to an sqlite3VdbeRecordCompare() compatible function\n** suitable for comparing serialized records to the unpacked record passed\n** as the only argument.\n*/\nSQLITE_PRIVATE RecordCompare sqlite3VdbeFindCompare(UnpackedRecord *p){\n  /* varintRecordCompareInt() and varintRecordCompareString() both assume\n  ** that the size-of-header varint that occurs at the start of each record\n  ** fits in a single byte (i.e. is 127 or less). varintRecordCompareInt()\n  ** also assumes that it is safe to overread a buffer by at least the \n  ** maximum possible legal header size plus 8 bytes. Because there is\n  ** guaranteed to be at least 74 (but not 136) bytes of padding following each\n  ** buffer passed to varintRecordCompareInt() this makes it convenient to\n  ** limit the size of the header to 64 bytes in cases where the first field\n  ** is an integer.\n  **\n  ** The easiest way to enforce this limit is to consider only records with\n  ** 13 fields or less. If the first field is an integer, the maximum legal\n  ** header size is (12*5 + 1 + 1) bytes.  */\n  if( p->pKeyInfo->nAllField<=13 ){\n    int flags = p->aMem[0].flags;\n    if( p->pKeyInfo->aSortOrder[0] ){\n      p->r1 = 1;\n      p->r2 = -1;\n    }else{\n      p->r1 = -1;\n      p->r2 = 1;\n    }\n    if( (flags & MEM_Int) ){\n      return vdbeRecordCompareInt;\n    }\n    testcase( flags & MEM_Real );\n    testcase( flags & MEM_Null );\n    testcase( flags & MEM_Blob );\n    if( (flags & (MEM_Real|MEM_Null|MEM_Blob))==0 && p->pKeyInfo->aColl[0]==0 ){\n      assert( flags & MEM_Str );\n      return vdbeRecordCompareString;\n    }\n  }\n\n  return sqlite3VdbeRecordCompare;\n}\n\n/*\n** pCur points at an index entry created using the OP_MakeRecord opcode.\n** Read the rowid (the last field in the record) and store it in *rowid.\n** Return SQLITE_OK if everything works, or an error code otherwise.\n**\n** pCur might be pointing to text obtained from a corrupt database file.\n** So the content cannot be trusted.  Do appropriate checks on the content.\n*/\nSQLITE_PRIVATE int sqlite3VdbeIdxRowid(sqlite3 *db, BtCursor *pCur, i64 *rowid){\n  i64 nCellKey = 0;\n  int rc;\n  u32 szHdr;        /* Size of the header */\n  u32 typeRowid;    /* Serial type of the rowid */\n  u32 lenRowid;     /* Size of the rowid */\n  Mem m, v;\n\n  /* Get the size of the index entry.  Only indices entries of less\n  ** than 2GiB are support - anything large must be database corruption.\n  ** Any corruption is detected in sqlite3BtreeParseCellPtr(), though, so\n  ** this code can safely assume that nCellKey is 32-bits  \n  */\n  assert( sqlite3BtreeCursorIsValid(pCur) );\n  nCellKey = sqlite3BtreePayloadSize(pCur);\n  assert( (nCellKey & SQLITE_MAX_U32)==(u64)nCellKey );\n\n  /* Read in the complete content of the index entry */\n  sqlite3VdbeMemInit(&m, db, 0);\n  rc = sqlite3VdbeMemFromBtree(pCur, 0, (u32)nCellKey, &m);\n  if( rc ){\n    return rc;\n  }\n\n  /* The index entry must begin with a header size */\n  (void)getVarint32((u8*)m.z, szHdr);\n  testcase( szHdr==3 );\n  testcase( szHdr==m.n );\n  testcase( szHdr>0x7fffffff );\n  assert( m.n>=0 );\n  if( unlikely(szHdr<3 || szHdr>(unsigned)m.n) ){\n    goto idx_rowid_corruption;\n  }\n\n  /* The last field of the index should be an integer - the ROWID.\n  ** Verify that the last entry really is an integer. */\n  (void)getVarint32((u8*)&m.z[szHdr-1], typeRowid);\n  testcase( typeRowid==1 );\n  testcase( typeRowid==2 );\n  testcase( typeRowid==3 );\n  testcase( typeRowid==4 );\n  testcase( typeRowid==5 );\n  testcase( typeRowid==6 );\n  testcase( typeRowid==8 );\n  testcase( typeRowid==9 );\n  if( unlikely(typeRowid<1 || typeRowid>9 || typeRowid==7) ){\n    goto idx_rowid_corruption;\n  }\n  lenRowid = sqlite3SmallTypeSizes[typeRowid];\n  testcase( (u32)m.n==szHdr+lenRowid );\n  if( unlikely((u32)m.n<szHdr+lenRowid) ){\n    goto idx_rowid_corruption;\n  }\n\n  /* Fetch the integer off the end of the index record */\n  sqlite3VdbeSerialGet((u8*)&m.z[m.n-lenRowid], typeRowid, &v);\n  *rowid = v.u.i;\n  sqlite3VdbeMemRelease(&m);\n  return SQLITE_OK;\n\n  /* Jump here if database corruption is detected after m has been\n  ** allocated.  Free the m object and return SQLITE_CORRUPT. */\nidx_rowid_corruption:\n  testcase( m.szMalloc!=0 );\n  sqlite3VdbeMemRelease(&m);\n  return SQLITE_CORRUPT_BKPT;\n}\n\n/*\n** Compare the key of the index entry that cursor pC is pointing to against\n** the key string in pUnpacked.  Write into *pRes a number\n** that is negative, zero, or positive if pC is less than, equal to,\n** or greater than pUnpacked.  Return SQLITE_OK on success.\n**\n** pUnpacked is either created without a rowid or is truncated so that it\n** omits the rowid at the end.  The rowid at the end of the index entry\n** is ignored as well.  Hence, this routine only compares the prefixes \n** of the keys prior to the final rowid, not the entire key.\n*/\nSQLITE_PRIVATE int sqlite3VdbeIdxKeyCompare(\n  sqlite3 *db,                     /* Database connection */\n  VdbeCursor *pC,                  /* The cursor to compare against */\n  UnpackedRecord *pUnpacked,       /* Unpacked version of key */\n  int *res                         /* Write the comparison result here */\n){\n  i64 nCellKey = 0;\n  int rc;\n  BtCursor *pCur;\n  Mem m;\n\n  assert( pC->eCurType==CURTYPE_BTREE );\n  pCur = pC->uc.pCursor;\n  assert( sqlite3BtreeCursorIsValid(pCur) );\n  nCellKey = sqlite3BtreePayloadSize(pCur);\n  /* nCellKey will always be between 0 and 0xffffffff because of the way\n  ** that btreeParseCellPtr() and sqlite3GetVarint32() are implemented */\n  if( nCellKey<=0 || nCellKey>0x7fffffff ){\n    *res = 0;\n    return SQLITE_CORRUPT_BKPT;\n  }\n  sqlite3VdbeMemInit(&m, db, 0);\n  rc = sqlite3VdbeMemFromBtree(pCur, 0, (u32)nCellKey, &m);\n  if( rc ){\n    return rc;\n  }\n  *res = sqlite3VdbeRecordCompareWithSkip(m.n, m.z, pUnpacked, 0);\n  sqlite3VdbeMemRelease(&m);\n  return SQLITE_OK;\n}\n\n/*\n** This routine sets the value to be returned by subsequent calls to\n** sqlite3_changes() on the database handle 'db'. \n*/\nSQLITE_PRIVATE void sqlite3VdbeSetChanges(sqlite3 *db, int nChange){\n  assert( sqlite3_mutex_held(db->mutex) );\n  db->nChange = nChange;\n  db->nTotalChange += nChange;\n}\n\n/*\n** Set a flag in the vdbe to update the change counter when it is finalised\n** or reset.\n*/\nSQLITE_PRIVATE void sqlite3VdbeCountChanges(Vdbe *v){\n  v->changeCntOn = 1;\n}\n\n/*\n** Mark every prepared statement associated with a database connection\n** as expired.\n**\n** An expired statement means that recompilation of the statement is\n** recommend.  Statements expire when things happen that make their\n** programs obsolete.  Removing user-defined functions or collating\n** sequences, or changing an authorization function are the types of\n** things that make prepared statements obsolete.\n**\n** If iCode is 1, then expiration is advisory.  The statement should\n** be reprepared before being restarted, but if it is already running\n** it is allowed to run to completion.\n**\n** Internally, this function just sets the Vdbe.expired flag on all\n** prepared statements.  The flag is set to 1 for an immediate expiration\n** and set to 2 for an advisory expiration.\n*/\nSQLITE_PRIVATE void sqlite3ExpirePreparedStatements(sqlite3 *db, int iCode){\n  Vdbe *p;\n  for(p = db->pVdbe; p; p=p->pNext){\n    p->expired = iCode+1;\n  }\n}\n\n/*\n** Return the database associated with the Vdbe.\n*/\nSQLITE_PRIVATE sqlite3 *sqlite3VdbeDb(Vdbe *v){\n  return v->db;\n}\n\n/*\n** Return the SQLITE_PREPARE flags for a Vdbe.\n*/\nSQLITE_PRIVATE u8 sqlite3VdbePrepareFlags(Vdbe *v){\n  return v->prepFlags;\n}\n\n/*\n** Return a pointer to an sqlite3_value structure containing the value bound\n** parameter iVar of VM v. Except, if the value is an SQL NULL, return \n** 0 instead. Unless it is NULL, apply affinity aff (one of the SQLITE_AFF_*\n** constants) to the value before returning it.\n**\n** The returned value must be freed by the caller using sqlite3ValueFree().\n*/\nSQLITE_PRIVATE sqlite3_value *sqlite3VdbeGetBoundValue(Vdbe *v, int iVar, u8 aff){\n  assert( iVar>0 );\n  if( v ){\n    Mem *pMem = &v->aVar[iVar-1];\n    assert( (v->db->flags & SQLITE_EnableQPSG)==0 );\n    if( 0==(pMem->flags & MEM_Null) ){\n      sqlite3_value *pRet = sqlite3ValueNew(v->db);\n      if( pRet ){\n        sqlite3VdbeMemCopy((Mem *)pRet, pMem);\n        sqlite3ValueApplyAffinity(pRet, aff, SQLITE_UTF8);\n      }\n      return pRet;\n    }\n  }\n  return 0;\n}\n\n/*\n** Configure SQL variable iVar so that binding a new value to it signals\n** to sqlite3_reoptimize() that re-preparing the statement may result\n** in a better query plan.\n*/\nSQLITE_PRIVATE void sqlite3VdbeSetVarmask(Vdbe *v, int iVar){\n  assert( iVar>0 );\n  assert( (v->db->flags & SQLITE_EnableQPSG)==0 );\n  if( iVar>=32 ){\n    v->expmask |= 0x80000000;\n  }else{\n    v->expmask |= ((u32)1 << (iVar-1));\n  }\n}\n\n/*\n** Cause a function to throw an error if it was call from OP_PureFunc\n** rather than OP_Function.\n**\n** OP_PureFunc means that the function must be deterministic, and should\n** throw an error if it is given inputs that would make it non-deterministic.\n** This routine is invoked by date/time functions that use non-deterministic\n** features such as 'now'.\n*/\nSQLITE_PRIVATE int sqlite3NotPureFunc(sqlite3_context *pCtx){\n#ifdef SQLITE_ENABLE_STAT3_OR_STAT4\n  if( pCtx->pVdbe==0 ) return 1;\n#endif\n  if( pCtx->pVdbe->aOp[pCtx->iOp].opcode==OP_PureFunc ){\n    sqlite3_result_error(pCtx, \n       \"non-deterministic function in index expression or CHECK constraint\",\n       -1);\n    return 0;\n  }\n  return 1;\n}\n\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n/*\n** Transfer error message text from an sqlite3_vtab.zErrMsg (text stored\n** in memory obtained from sqlite3_malloc) into a Vdbe.zErrMsg (text stored\n** in memory obtained from sqlite3DbMalloc).\n*/\nSQLITE_PRIVATE void sqlite3VtabImportErrmsg(Vdbe *p, sqlite3_vtab *pVtab){\n  if( pVtab->zErrMsg ){\n    sqlite3 *db = p->db;\n    sqlite3DbFree(db, p->zErrMsg);\n    p->zErrMsg = sqlite3DbStrDup(db, pVtab->zErrMsg);\n    sqlite3_free(pVtab->zErrMsg);\n    pVtab->zErrMsg = 0;\n  }\n}\n#endif /* SQLITE_OMIT_VIRTUALTABLE */\n\n#ifdef SQLITE_ENABLE_PREUPDATE_HOOK\n\n/*\n** If the second argument is not NULL, release any allocations associated \n** with the memory cells in the p->aMem[] array. Also free the UnpackedRecord\n** structure itself, using sqlite3DbFree().\n**\n** This function is used to free UnpackedRecord structures allocated by\n** the vdbeUnpackRecord() function found in vdbeapi.c.\n*/\nstatic void vdbeFreeUnpacked(sqlite3 *db, int nField, UnpackedRecord *p){\n  if( p ){\n    int i;\n    for(i=0; i<nField; i++){\n      Mem *pMem = &p->aMem[i];\n      if( pMem->zMalloc ) sqlite3VdbeMemRelease(pMem);\n    }\n    sqlite3DbFreeNN(db, p);\n  }\n}\n#endif /* SQLITE_ENABLE_PREUPDATE_HOOK */\n\n#ifdef SQLITE_ENABLE_PREUPDATE_HOOK\n/*\n** Invoke the pre-update hook. If this is an UPDATE or DELETE pre-update call,\n** then cursor passed as the second argument should point to the row about\n** to be update or deleted. If the application calls sqlite3_preupdate_old(),\n** the required value will be read from the row the cursor points to.\n*/\nSQLITE_PRIVATE void sqlite3VdbePreUpdateHook(\n  Vdbe *v,                        /* Vdbe pre-update hook is invoked by */\n  VdbeCursor *pCsr,               /* Cursor to grab old.* values from */\n  int op,                         /* SQLITE_INSERT, UPDATE or DELETE */\n  const char *zDb,                /* Database name */\n  Table *pTab,                    /* Modified table */\n  i64 iKey1,                      /* Initial key value */\n  int iReg                        /* Register for new.* record */\n){\n  sqlite3 *db = v->db;\n  i64 iKey2;\n  PreUpdate preupdate;\n  const char *zTbl = pTab->zName;\n  static const u8 fakeSortOrder = 0;\n\n  assert( db->pPreUpdate==0 );\n  memset(&preupdate, 0, sizeof(PreUpdate));\n  if( HasRowid(pTab)==0 ){\n    iKey1 = iKey2 = 0;\n    preupdate.pPk = sqlite3PrimaryKeyIndex(pTab);\n  }else{\n    if( op==SQLITE_UPDATE ){\n      iKey2 = v->aMem[iReg].u.i;\n    }else{\n      iKey2 = iKey1;\n    }\n  }\n\n  assert( pCsr->nField==pTab->nCol \n       || (pCsr->nField==pTab->nCol+1 && op==SQLITE_DELETE && iReg==-1)\n  );\n\n  preupdate.v = v;\n  preupdate.pCsr = pCsr;\n  preupdate.op = op;\n  preupdate.iNewReg = iReg;\n  preupdate.keyinfo.db = db;\n  preupdate.keyinfo.enc = ENC(db);\n  preupdate.keyinfo.nKeyField = pTab->nCol;\n  preupdate.keyinfo.aSortOrder = (u8*)&fakeSortOrder;\n  preupdate.iKey1 = iKey1;\n  preupdate.iKey2 = iKey2;\n  preupdate.pTab = pTab;\n\n  db->pPreUpdate = &preupdate;\n  db->xPreUpdateCallback(db->pPreUpdateArg, db, op, zDb, zTbl, iKey1, iKey2);\n  db->pPreUpdate = 0;\n  sqlite3DbFree(db, preupdate.aRecord);\n  vdbeFreeUnpacked(db, preupdate.keyinfo.nKeyField+1, preupdate.pUnpacked);\n  vdbeFreeUnpacked(db, preupdate.keyinfo.nKeyField+1, preupdate.pNewUnpacked);\n  if( preupdate.aNew ){\n    int i;\n    for(i=0; i<pCsr->nField; i++){\n      sqlite3VdbeMemRelease(&preupdate.aNew[i]);\n    }\n    sqlite3DbFreeNN(db, preupdate.aNew);\n  }\n}\n#endif /* SQLITE_ENABLE_PREUPDATE_HOOK */\n\n/************** End of vdbeaux.c *********************************************/\n/************** Begin file vdbeapi.c *****************************************/\n/*\n** 2004 May 26\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n**\n** This file contains code use to implement APIs that are part of the\n** VDBE.\n*/\n/* #include \"sqliteInt.h\" */\n/* #include \"vdbeInt.h\" */\n\n#ifndef SQLITE_OMIT_DEPRECATED\n/*\n** Return TRUE (non-zero) of the statement supplied as an argument needs\n** to be recompiled.  A statement needs to be recompiled whenever the\n** execution environment changes in a way that would alter the program\n** that sqlite3_prepare() generates.  For example, if new functions or\n** collating sequences are registered or if an authorizer function is\n** added or changed.\n*/\nSQLITE_API int sqlite3_expired(sqlite3_stmt *pStmt){\n  Vdbe *p = (Vdbe*)pStmt;\n  return p==0 || p->expired;\n}\n#endif\n\n/*\n** Check on a Vdbe to make sure it has not been finalized.  Log\n** an error and return true if it has been finalized (or is otherwise\n** invalid).  Return false if it is ok.\n*/\nstatic int vdbeSafety(Vdbe *p){\n  if( p->db==0 ){\n    sqlite3_log(SQLITE_MISUSE, \"API called with finalized prepared statement\");\n    return 1;\n  }else{\n    return 0;\n  }\n}\nstatic int vdbeSafetyNotNull(Vdbe *p){\n  if( p==0 ){\n    sqlite3_log(SQLITE_MISUSE, \"API called with NULL prepared statement\");\n    return 1;\n  }else{\n    return vdbeSafety(p);\n  }\n}\n\n#ifndef SQLITE_OMIT_TRACE\n/*\n** Invoke the profile callback.  This routine is only called if we already\n** know that the profile callback is defined and needs to be invoked.\n*/\nstatic SQLITE_NOINLINE void invokeProfileCallback(sqlite3 *db, Vdbe *p){\n  sqlite3_int64 iNow;\n  sqlite3_int64 iElapse;\n  assert( p->startTime>0 );\n  assert( (db->mTrace & (SQLITE_TRACE_PROFILE|SQLITE_TRACE_XPROFILE))!=0 );\n  assert( db->init.busy==0 );\n  assert( p->zSql!=0 );\n  sqlite3OsCurrentTimeInt64(db->pVfs, &iNow);\n  iElapse = (iNow - p->startTime)*1000000;\n#ifndef SQLITE_OMIT_DEPRECATED  \t\n  if( db->xProfile ){\n    db->xProfile(db->pProfileArg, p->zSql, iElapse);\n  }\n#endif\n  if( db->mTrace & SQLITE_TRACE_PROFILE ){\n    db->xTrace(SQLITE_TRACE_PROFILE, db->pTraceArg, p, (void*)&iElapse);\n  }\n  p->startTime = 0;\n}\n/*\n** The checkProfileCallback(DB,P) macro checks to see if a profile callback\n** is needed, and it invokes the callback if it is needed.\n*/\n# define checkProfileCallback(DB,P) \\\n   if( ((P)->startTime)>0 ){ invokeProfileCallback(DB,P); }\n#else\n# define checkProfileCallback(DB,P)  /*no-op*/\n#endif\n\n/*\n** The following routine destroys a virtual machine that is created by\n** the sqlite3_compile() routine. The integer returned is an SQLITE_\n** success/failure code that describes the result of executing the virtual\n** machine.\n**\n** This routine sets the error code and string returned by\n** sqlite3_errcode(), sqlite3_errmsg() and sqlite3_errmsg16().\n*/\nSQLITE_API int sqlite3_finalize(sqlite3_stmt *pStmt){\n  int rc;\n  if( pStmt==0 ){\n    /* IMPLEMENTATION-OF: R-57228-12904 Invoking sqlite3_finalize() on a NULL\n    ** pointer is a harmless no-op. */\n    rc = SQLITE_OK;\n  }else{\n    Vdbe *v = (Vdbe*)pStmt;\n    sqlite3 *db = v->db;\n    if( vdbeSafety(v) ) return SQLITE_MISUSE_BKPT;\n    sqlite3_mutex_enter(db->mutex);\n    checkProfileCallback(db, v);\n    rc = sqlite3VdbeFinalize(v);\n    rc = sqlite3ApiExit(db, rc);\n    sqlite3LeaveMutexAndCloseZombie(db);\n  }\n  return rc;\n}\n\n/*\n** Terminate the current execution of an SQL statement and reset it\n** back to its starting state so that it can be reused. A success code from\n** the prior execution is returned.\n**\n** This routine sets the error code and string returned by\n** sqlite3_errcode(), sqlite3_errmsg() and sqlite3_errmsg16().\n*/\nSQLITE_API int sqlite3_reset(sqlite3_stmt *pStmt){\n  int rc;\n  if( pStmt==0 ){\n    rc = SQLITE_OK;\n  }else{\n    Vdbe *v = (Vdbe*)pStmt;\n    sqlite3 *db = v->db;\n    sqlite3_mutex_enter(db->mutex);\n    checkProfileCallback(db, v);\n    rc = sqlite3VdbeReset(v);\n    sqlite3VdbeRewind(v);\n    assert( (rc & (db->errMask))==rc );\n    rc = sqlite3ApiExit(db, rc);\n    sqlite3_mutex_leave(db->mutex);\n  }\n  return rc;\n}\n\n/*\n** Set all the parameters in the compiled SQL statement to NULL.\n*/\nSQLITE_API int sqlite3_clear_bindings(sqlite3_stmt *pStmt){\n  int i;\n  int rc = SQLITE_OK;\n  Vdbe *p = (Vdbe*)pStmt;\n#if SQLITE_THREADSAFE\n  sqlite3_mutex *mutex = ((Vdbe*)pStmt)->db->mutex;\n#endif\n  sqlite3_mutex_enter(mutex);\n  for(i=0; i<p->nVar; i++){\n    sqlite3VdbeMemRelease(&p->aVar[i]);\n    p->aVar[i].flags = MEM_Null;\n  }\n  assert( (p->prepFlags & SQLITE_PREPARE_SAVESQL)!=0 || p->expmask==0 );\n  if( p->expmask ){\n    p->expired = 1;\n  }\n  sqlite3_mutex_leave(mutex);\n  return rc;\n}\n\n\n/**************************** sqlite3_value_  *******************************\n** The following routines extract information from a Mem or sqlite3_value\n** structure.\n*/\nSQLITE_API const void *sqlite3_value_blob(sqlite3_value *pVal){\n  Mem *p = (Mem*)pVal;\n  if( p->flags & (MEM_Blob|MEM_Str) ){\n    if( ExpandBlob(p)!=SQLITE_OK ){\n      assert( p->flags==MEM_Null && p->z==0 );\n      return 0;\n    }\n    p->flags |= MEM_Blob;\n    return p->n ? p->z : 0;\n  }else{\n    return sqlite3_value_text(pVal);\n  }\n}\nSQLITE_API int sqlite3_value_bytes(sqlite3_value *pVal){\n  return sqlite3ValueBytes(pVal, SQLITE_UTF8);\n}\nSQLITE_API int sqlite3_value_bytes16(sqlite3_value *pVal){\n  return sqlite3ValueBytes(pVal, SQLITE_UTF16NATIVE);\n}\nSQLITE_API double sqlite3_value_double(sqlite3_value *pVal){\n  return sqlite3VdbeRealValue((Mem*)pVal);\n}\nSQLITE_API int sqlite3_value_int(sqlite3_value *pVal){\n  return (int)sqlite3VdbeIntValue((Mem*)pVal);\n}\nSQLITE_API sqlite_int64 sqlite3_value_int64(sqlite3_value *pVal){\n  return sqlite3VdbeIntValue((Mem*)pVal);\n}\nSQLITE_API unsigned int sqlite3_value_subtype(sqlite3_value *pVal){\n  Mem *pMem = (Mem*)pVal;\n  return ((pMem->flags & MEM_Subtype) ? pMem->eSubtype : 0);\n}\nSQLITE_API void *sqlite3_value_pointer(sqlite3_value *pVal, const char *zPType){\n  Mem *p = (Mem*)pVal;\n  if( (p->flags&(MEM_TypeMask|MEM_Term|MEM_Subtype)) ==\n                 (MEM_Null|MEM_Term|MEM_Subtype)\n   && zPType!=0\n   && p->eSubtype=='p'\n   && strcmp(p->u.zPType, zPType)==0\n  ){\n    return (void*)p->z;\n  }else{\n    return 0;\n  }\n}\nSQLITE_API const unsigned char *sqlite3_value_text(sqlite3_value *pVal){\n  return (const unsigned char *)sqlite3ValueText(pVal, SQLITE_UTF8);\n}\n#ifndef SQLITE_OMIT_UTF16\nSQLITE_API const void *sqlite3_value_text16(sqlite3_value* pVal){\n  return sqlite3ValueText(pVal, SQLITE_UTF16NATIVE);\n}\nSQLITE_API const void *sqlite3_value_text16be(sqlite3_value *pVal){\n  return sqlite3ValueText(pVal, SQLITE_UTF16BE);\n}\nSQLITE_API const void *sqlite3_value_text16le(sqlite3_value *pVal){\n  return sqlite3ValueText(pVal, SQLITE_UTF16LE);\n}\n#endif /* SQLITE_OMIT_UTF16 */\n/* EVIDENCE-OF: R-12793-43283 Every value in SQLite has one of five\n** fundamental datatypes: 64-bit signed integer 64-bit IEEE floating\n** point number string BLOB NULL\n*/\nSQLITE_API int sqlite3_value_type(sqlite3_value* pVal){\n  static const u8 aType[] = {\n     SQLITE_BLOB,     /* 0x00 */\n     SQLITE_NULL,     /* 0x01 */\n     SQLITE_TEXT,     /* 0x02 */\n     SQLITE_NULL,     /* 0x03 */\n     SQLITE_INTEGER,  /* 0x04 */\n     SQLITE_NULL,     /* 0x05 */\n     SQLITE_INTEGER,  /* 0x06 */\n     SQLITE_NULL,     /* 0x07 */\n     SQLITE_FLOAT,    /* 0x08 */\n     SQLITE_NULL,     /* 0x09 */\n     SQLITE_FLOAT,    /* 0x0a */\n     SQLITE_NULL,     /* 0x0b */\n     SQLITE_INTEGER,  /* 0x0c */\n     SQLITE_NULL,     /* 0x0d */\n     SQLITE_INTEGER,  /* 0x0e */\n     SQLITE_NULL,     /* 0x0f */\n     SQLITE_BLOB,     /* 0x10 */\n     SQLITE_NULL,     /* 0x11 */\n     SQLITE_TEXT,     /* 0x12 */\n     SQLITE_NULL,     /* 0x13 */\n     SQLITE_INTEGER,  /* 0x14 */\n     SQLITE_NULL,     /* 0x15 */\n     SQLITE_INTEGER,  /* 0x16 */\n     SQLITE_NULL,     /* 0x17 */\n     SQLITE_FLOAT,    /* 0x18 */\n     SQLITE_NULL,     /* 0x19 */\n     SQLITE_FLOAT,    /* 0x1a */\n     SQLITE_NULL,     /* 0x1b */\n     SQLITE_INTEGER,  /* 0x1c */\n     SQLITE_NULL,     /* 0x1d */\n     SQLITE_INTEGER,  /* 0x1e */\n     SQLITE_NULL,     /* 0x1f */\n  };\n  return aType[pVal->flags&MEM_AffMask];\n}\n\n/* Return true if a parameter to xUpdate represents an unchanged column */\nSQLITE_API int sqlite3_value_nochange(sqlite3_value *pVal){\n  return (pVal->flags&(MEM_Null|MEM_Zero))==(MEM_Null|MEM_Zero);\n}\n\n/* Make a copy of an sqlite3_value object\n*/\nSQLITE_API sqlite3_value *sqlite3_value_dup(const sqlite3_value *pOrig){\n  sqlite3_value *pNew;\n  if( pOrig==0 ) return 0;\n  pNew = sqlite3_malloc( sizeof(*pNew) );\n  if( pNew==0 ) return 0;\n  memset(pNew, 0, sizeof(*pNew));\n  memcpy(pNew, pOrig, MEMCELLSIZE);\n  pNew->flags &= ~MEM_Dyn;\n  pNew->db = 0;\n  if( pNew->flags&(MEM_Str|MEM_Blob) ){\n    pNew->flags &= ~(MEM_Static|MEM_Dyn);\n    pNew->flags |= MEM_Ephem;\n    if( sqlite3VdbeMemMakeWriteable(pNew)!=SQLITE_OK ){\n      sqlite3ValueFree(pNew);\n      pNew = 0;\n    }\n  }\n  return pNew;\n}\n\n/* Destroy an sqlite3_value object previously obtained from\n** sqlite3_value_dup().\n*/\nSQLITE_API void sqlite3_value_free(sqlite3_value *pOld){\n  sqlite3ValueFree(pOld);\n}\n  \n\n/**************************** sqlite3_result_  *******************************\n** The following routines are used by user-defined functions to specify\n** the function result.\n**\n** The setStrOrError() function calls sqlite3VdbeMemSetStr() to store the\n** result as a string or blob but if the string or blob is too large, it\n** then sets the error code to SQLITE_TOOBIG\n**\n** The invokeValueDestructor(P,X) routine invokes destructor function X()\n** on value P is not going to be used and need to be destroyed.\n*/\nstatic void setResultStrOrError(\n  sqlite3_context *pCtx,  /* Function context */\n  const char *z,          /* String pointer */\n  int n,                  /* Bytes in string, or negative */\n  u8 enc,                 /* Encoding of z.  0 for BLOBs */\n  void (*xDel)(void*)     /* Destructor function */\n){\n  if( sqlite3VdbeMemSetStr(pCtx->pOut, z, n, enc, xDel)==SQLITE_TOOBIG ){\n    sqlite3_result_error_toobig(pCtx);\n  }\n}\nstatic int invokeValueDestructor(\n  const void *p,             /* Value to destroy */\n  void (*xDel)(void*),       /* The destructor */\n  sqlite3_context *pCtx      /* Set a SQLITE_TOOBIG error if no NULL */\n){\n  assert( xDel!=SQLITE_DYNAMIC );\n  if( xDel==0 ){\n    /* noop */\n  }else if( xDel==SQLITE_TRANSIENT ){\n    /* noop */\n  }else{\n    xDel((void*)p);\n  }\n  if( pCtx ) sqlite3_result_error_toobig(pCtx);\n  return SQLITE_TOOBIG;\n}\nSQLITE_API void sqlite3_result_blob(\n  sqlite3_context *pCtx, \n  const void *z, \n  int n, \n  void (*xDel)(void *)\n){\n  assert( n>=0 );\n  assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );\n  setResultStrOrError(pCtx, z, n, 0, xDel);\n}\nSQLITE_API void sqlite3_result_blob64(\n  sqlite3_context *pCtx, \n  const void *z, \n  sqlite3_uint64 n,\n  void (*xDel)(void *)\n){\n  assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );\n  assert( xDel!=SQLITE_DYNAMIC );\n  if( n>0x7fffffff ){\n    (void)invokeValueDestructor(z, xDel, pCtx);\n  }else{\n    setResultStrOrError(pCtx, z, (int)n, 0, xDel);\n  }\n}\nSQLITE_API void sqlite3_result_double(sqlite3_context *pCtx, double rVal){\n  assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );\n  sqlite3VdbeMemSetDouble(pCtx->pOut, rVal);\n}\nSQLITE_API void sqlite3_result_error(sqlite3_context *pCtx, const char *z, int n){\n  assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );\n  pCtx->isError = SQLITE_ERROR;\n  sqlite3VdbeMemSetStr(pCtx->pOut, z, n, SQLITE_UTF8, SQLITE_TRANSIENT);\n}\n#ifndef SQLITE_OMIT_UTF16\nSQLITE_API void sqlite3_result_error16(sqlite3_context *pCtx, const void *z, int n){\n  assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );\n  pCtx->isError = SQLITE_ERROR;\n  sqlite3VdbeMemSetStr(pCtx->pOut, z, n, SQLITE_UTF16NATIVE, SQLITE_TRANSIENT);\n}\n#endif\nSQLITE_API void sqlite3_result_int(sqlite3_context *pCtx, int iVal){\n  assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );\n  sqlite3VdbeMemSetInt64(pCtx->pOut, (i64)iVal);\n}\nSQLITE_API void sqlite3_result_int64(sqlite3_context *pCtx, i64 iVal){\n  assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );\n  sqlite3VdbeMemSetInt64(pCtx->pOut, iVal);\n}\nSQLITE_API void sqlite3_result_null(sqlite3_context *pCtx){\n  assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );\n  sqlite3VdbeMemSetNull(pCtx->pOut);\n}\nSQLITE_API void sqlite3_result_pointer(\n  sqlite3_context *pCtx,\n  void *pPtr,\n  const char *zPType,\n  void (*xDestructor)(void*)\n){\n  Mem *pOut = pCtx->pOut;\n  assert( sqlite3_mutex_held(pOut->db->mutex) );\n  sqlite3VdbeMemRelease(pOut);\n  pOut->flags = MEM_Null;\n  sqlite3VdbeMemSetPointer(pOut, pPtr, zPType, xDestructor);\n}\nSQLITE_API void sqlite3_result_subtype(sqlite3_context *pCtx, unsigned int eSubtype){\n  Mem *pOut = pCtx->pOut;\n  assert( sqlite3_mutex_held(pOut->db->mutex) );\n  pOut->eSubtype = eSubtype & 0xff;\n  pOut->flags |= MEM_Subtype;\n}\nSQLITE_API void sqlite3_result_text(\n  sqlite3_context *pCtx, \n  const char *z, \n  int n,\n  void (*xDel)(void *)\n){\n  assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );\n  setResultStrOrError(pCtx, z, n, SQLITE_UTF8, xDel);\n}\nSQLITE_API void sqlite3_result_text64(\n  sqlite3_context *pCtx, \n  const char *z, \n  sqlite3_uint64 n,\n  void (*xDel)(void *),\n  unsigned char enc\n){\n  assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );\n  assert( xDel!=SQLITE_DYNAMIC );\n  if( enc==SQLITE_UTF16 ) enc = SQLITE_UTF16NATIVE;\n  if( n>0x7fffffff ){\n    (void)invokeValueDestructor(z, xDel, pCtx);\n  }else{\n    setResultStrOrError(pCtx, z, (int)n, enc, xDel);\n  }\n}\n#ifndef SQLITE_OMIT_UTF16\nSQLITE_API void sqlite3_result_text16(\n  sqlite3_context *pCtx, \n  const void *z, \n  int n, \n  void (*xDel)(void *)\n){\n  assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );\n  setResultStrOrError(pCtx, z, n, SQLITE_UTF16NATIVE, xDel);\n}\nSQLITE_API void sqlite3_result_text16be(\n  sqlite3_context *pCtx, \n  const void *z, \n  int n, \n  void (*xDel)(void *)\n){\n  assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );\n  setResultStrOrError(pCtx, z, n, SQLITE_UTF16BE, xDel);\n}\nSQLITE_API void sqlite3_result_text16le(\n  sqlite3_context *pCtx, \n  const void *z, \n  int n, \n  void (*xDel)(void *)\n){\n  assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );\n  setResultStrOrError(pCtx, z, n, SQLITE_UTF16LE, xDel);\n}\n#endif /* SQLITE_OMIT_UTF16 */\nSQLITE_API void sqlite3_result_value(sqlite3_context *pCtx, sqlite3_value *pValue){\n  assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );\n  sqlite3VdbeMemCopy(pCtx->pOut, pValue);\n}\nSQLITE_API void sqlite3_result_zeroblob(sqlite3_context *pCtx, int n){\n  assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );\n  sqlite3VdbeMemSetZeroBlob(pCtx->pOut, n);\n}\nSQLITE_API int sqlite3_result_zeroblob64(sqlite3_context *pCtx, u64 n){\n  Mem *pOut = pCtx->pOut;\n  assert( sqlite3_mutex_held(pOut->db->mutex) );\n  if( n>(u64)pOut->db->aLimit[SQLITE_LIMIT_LENGTH] ){\n    return SQLITE_TOOBIG;\n  }\n  sqlite3VdbeMemSetZeroBlob(pCtx->pOut, (int)n);\n  return SQLITE_OK;\n}\nSQLITE_API void sqlite3_result_error_code(sqlite3_context *pCtx, int errCode){\n  pCtx->isError = errCode ? errCode : -1;\n#ifdef SQLITE_DEBUG\n  if( pCtx->pVdbe ) pCtx->pVdbe->rcApp = errCode;\n#endif\n  if( pCtx->pOut->flags & MEM_Null ){\n    sqlite3VdbeMemSetStr(pCtx->pOut, sqlite3ErrStr(errCode), -1, \n                         SQLITE_UTF8, SQLITE_STATIC);\n  }\n}\n\n/* Force an SQLITE_TOOBIG error. */\nSQLITE_API void sqlite3_result_error_toobig(sqlite3_context *pCtx){\n  assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );\n  pCtx->isError = SQLITE_TOOBIG;\n  sqlite3VdbeMemSetStr(pCtx->pOut, \"string or blob too big\", -1, \n                       SQLITE_UTF8, SQLITE_STATIC);\n}\n\n/* An SQLITE_NOMEM error. */\nSQLITE_API void sqlite3_result_error_nomem(sqlite3_context *pCtx){\n  assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );\n  sqlite3VdbeMemSetNull(pCtx->pOut);\n  pCtx->isError = SQLITE_NOMEM_BKPT;\n  sqlite3OomFault(pCtx->pOut->db);\n}\n\n/*\n** This function is called after a transaction has been committed. It \n** invokes callbacks registered with sqlite3_wal_hook() as required.\n*/\nstatic int doWalCallbacks(sqlite3 *db){\n  int rc = SQLITE_OK;\n#ifndef SQLITE_OMIT_WAL\n  int i;\n  for(i=0; i<db->nDb; i++){\n    Btree *pBt = db->aDb[i].pBt;\n    if( pBt ){\n      int nEntry;\n      sqlite3BtreeEnter(pBt);\n      nEntry = sqlite3PagerWalCallback(sqlite3BtreePager(pBt));\n      sqlite3BtreeLeave(pBt);\n      if( nEntry>0 && db->xWalCallback && rc==SQLITE_OK ){\n        rc = db->xWalCallback(db->pWalArg, db, db->aDb[i].zDbSName, nEntry);\n      }\n    }\n  }\n#endif\n  return rc;\n}\n\n\n/*\n** Execute the statement pStmt, either until a row of data is ready, the\n** statement is completely executed or an error occurs.\n**\n** This routine implements the bulk of the logic behind the sqlite_step()\n** API.  The only thing omitted is the automatic recompile if a \n** schema change has occurred.  That detail is handled by the\n** outer sqlite3_step() wrapper procedure.\n*/\nstatic int sqlite3Step(Vdbe *p){\n  sqlite3 *db;\n  int rc;\n\n  assert(p);\n  if( p->magic!=VDBE_MAGIC_RUN ){\n    /* We used to require that sqlite3_reset() be called before retrying\n    ** sqlite3_step() after any error or after SQLITE_DONE.  But beginning\n    ** with version 3.7.0, we changed this so that sqlite3_reset() would\n    ** be called automatically instead of throwing the SQLITE_MISUSE error.\n    ** This \"automatic-reset\" change is not technically an incompatibility, \n    ** since any application that receives an SQLITE_MISUSE is broken by\n    ** definition.\n    **\n    ** Nevertheless, some published applications that were originally written\n    ** for version 3.6.23 or earlier do in fact depend on SQLITE_MISUSE \n    ** returns, and those were broken by the automatic-reset change.  As a\n    ** a work-around, the SQLITE_OMIT_AUTORESET compile-time restores the\n    ** legacy behavior of returning SQLITE_MISUSE for cases where the \n    ** previous sqlite3_step() returned something other than a SQLITE_LOCKED\n    ** or SQLITE_BUSY error.\n    */\n#ifdef SQLITE_OMIT_AUTORESET\n    if( (rc = p->rc&0xff)==SQLITE_BUSY || rc==SQLITE_LOCKED ){\n      sqlite3_reset((sqlite3_stmt*)p);\n    }else{\n      return SQLITE_MISUSE_BKPT;\n    }\n#else\n    sqlite3_reset((sqlite3_stmt*)p);\n#endif\n  }\n\n  /* Check that malloc() has not failed. If it has, return early. */\n  db = p->db;\n  if( db->mallocFailed ){\n    p->rc = SQLITE_NOMEM;\n    return SQLITE_NOMEM_BKPT;\n  }\n\n  if( p->pc<0 && p->expired ){\n    p->rc = SQLITE_SCHEMA;\n    rc = SQLITE_ERROR;\n    goto end_of_step;\n  }\n  if( p->pc<0 ){\n    /* If there are no other statements currently running, then\n    ** reset the interrupt flag.  This prevents a call to sqlite3_interrupt\n    ** from interrupting a statement that has not yet started.\n    */\n    if( db->nVdbeActive==0 ){\n      db->u1.isInterrupted = 0;\n    }\n\n    assert( db->nVdbeWrite>0 || db->autoCommit==0 \n        || (db->nDeferredCons==0 && db->nDeferredImmCons==0)\n    );\n\n#ifndef SQLITE_OMIT_TRACE\n    if( (db->mTrace & (SQLITE_TRACE_PROFILE|SQLITE_TRACE_XPROFILE))!=0\n        && !db->init.busy && p->zSql ){\n      sqlite3OsCurrentTimeInt64(db->pVfs, &p->startTime);\n    }else{\n      assert( p->startTime==0 );\n    }\n#endif\n\n    db->nVdbeActive++;\n    if( p->readOnly==0 ) db->nVdbeWrite++;\n    if( p->bIsReader ) db->nVdbeRead++;\n    p->pc = 0;\n  }\n#ifdef SQLITE_DEBUG\n  p->rcApp = SQLITE_OK;\n#endif\n#ifndef SQLITE_OMIT_EXPLAIN\n  if( p->explain ){\n    rc = sqlite3VdbeList(p);\n  }else\n#endif /* SQLITE_OMIT_EXPLAIN */\n  {\n    db->nVdbeExec++;\n    rc = sqlite3VdbeExec(p);\n    db->nVdbeExec--;\n  }\n\n  if( rc!=SQLITE_ROW ){\n#ifndef SQLITE_OMIT_TRACE\n    /* If the statement completed successfully, invoke the profile callback */\n    checkProfileCallback(db, p);\n#endif\n\n    if( rc==SQLITE_DONE && db->autoCommit ){\n      assert( p->rc==SQLITE_OK );\n      p->rc = doWalCallbacks(db);\n      if( p->rc!=SQLITE_OK ){\n        rc = SQLITE_ERROR;\n      }\n    }\n  }\n\n  db->errCode = rc;\n  if( SQLITE_NOMEM==sqlite3ApiExit(p->db, p->rc) ){\n    p->rc = SQLITE_NOMEM_BKPT;\n  }\nend_of_step:\n  /* At this point local variable rc holds the value that should be \n  ** returned if this statement was compiled using the legacy \n  ** sqlite3_prepare() interface. According to the docs, this can only\n  ** be one of the values in the first assert() below. Variable p->rc \n  ** contains the value that would be returned if sqlite3_finalize() \n  ** were called on statement p.\n  */\n  assert( rc==SQLITE_ROW  || rc==SQLITE_DONE   || rc==SQLITE_ERROR \n       || (rc&0xff)==SQLITE_BUSY || rc==SQLITE_MISUSE\n  );\n  assert( (p->rc!=SQLITE_ROW && p->rc!=SQLITE_DONE) || p->rc==p->rcApp );\n  if( rc!=SQLITE_ROW \n   && rc!=SQLITE_DONE\n   && (p->prepFlags & SQLITE_PREPARE_SAVESQL)!=0\n  ){\n    /* If this statement was prepared using saved SQL and an \n    ** error has occurred, then return the error code in p->rc to the\n    ** caller. Set the error code in the database handle to the same value.\n    */ \n    rc = sqlite3VdbeTransferError(p);\n  }\n  return (rc&db->errMask);\n}\n\n/*\n** This is the top-level implementation of sqlite3_step().  Call\n** sqlite3Step() to do most of the work.  If a schema error occurs,\n** call sqlite3Reprepare() and try again.\n*/\nSQLITE_API int sqlite3_step(sqlite3_stmt *pStmt){\n  int rc = SQLITE_OK;      /* Result from sqlite3Step() */\n  Vdbe *v = (Vdbe*)pStmt;  /* the prepared statement */\n  int cnt = 0;             /* Counter to prevent infinite loop of reprepares */\n  sqlite3 *db;             /* The database connection */\n\n  if( vdbeSafetyNotNull(v) ){\n    return SQLITE_MISUSE_BKPT;\n  }\n  db = v->db;\n\n  sqlite3_mutex_enter(db->mutex);\n  v->doingRerun = 0;\n  while( (rc = sqlite3Step(v))==SQLITE_SCHEMA\n         && cnt++ < SQLITE_MAX_SCHEMA_RETRY ){\n    int savedPc = v->pc;\n    rc = sqlite3Reprepare(v);\n    if( rc!=SQLITE_OK ){\n      /* This case occurs after failing to recompile an sql statement. \n      ** The error message from the SQL compiler has already been loaded \n      ** into the database handle. This block copies the error message \n      ** from the database handle into the statement and sets the statement\n      ** program counter to 0 to ensure that when the statement is \n      ** finalized or reset the parser error message is available via\n      ** sqlite3_errmsg() and sqlite3_errcode().\n      */\n      const char *zErr = (const char *)sqlite3_value_text(db->pErr); \n      sqlite3DbFree(db, v->zErrMsg);\n      if( !db->mallocFailed ){\n        v->zErrMsg = sqlite3DbStrDup(db, zErr);\n        v->rc = rc = sqlite3ApiExit(db, rc);\n      } else {\n        v->zErrMsg = 0;\n        v->rc = rc = SQLITE_NOMEM_BKPT;\n      }\n      break;\n    }\n    sqlite3_reset(pStmt);\n    if( savedPc>=0 ) v->doingRerun = 1;\n    assert( v->expired==0 );\n  }\n  sqlite3_mutex_leave(db->mutex);\n  return rc;\n}\n\n\n/*\n** Extract the user data from a sqlite3_context structure and return a\n** pointer to it.\n*/\nSQLITE_API void *sqlite3_user_data(sqlite3_context *p){\n  assert( p && p->pFunc );\n  return p->pFunc->pUserData;\n}\n\n/*\n** Extract the user data from a sqlite3_context structure and return a\n** pointer to it.\n**\n** IMPLEMENTATION-OF: R-46798-50301 The sqlite3_context_db_handle() interface\n** returns a copy of the pointer to the database connection (the 1st\n** parameter) of the sqlite3_create_function() and\n** sqlite3_create_function16() routines that originally registered the\n** application defined function.\n*/\nSQLITE_API sqlite3 *sqlite3_context_db_handle(sqlite3_context *p){\n  assert( p && p->pOut );\n  return p->pOut->db;\n}\n\n/*\n** If this routine is invoked from within an xColumn method of a virtual\n** table, then it returns true if and only if the the call is during an\n** UPDATE operation and the value of the column will not be modified\n** by the UPDATE.\n**\n** If this routine is called from any context other than within the\n** xColumn method of a virtual table, then the return value is meaningless\n** and arbitrary.\n**\n** Virtual table implements might use this routine to optimize their\n** performance by substituting a NULL result, or some other light-weight\n** value, as a signal to the xUpdate routine that the column is unchanged.\n*/\nSQLITE_API int sqlite3_vtab_nochange(sqlite3_context *p){\n  assert( p );\n  return sqlite3_value_nochange(p->pOut);\n}\n\n/*\n** Return the current time for a statement.  If the current time\n** is requested more than once within the same run of a single prepared\n** statement, the exact same time is returned for each invocation regardless\n** of the amount of time that elapses between invocations.  In other words,\n** the time returned is always the time of the first call.\n*/\nSQLITE_PRIVATE sqlite3_int64 sqlite3StmtCurrentTime(sqlite3_context *p){\n  int rc;\n#ifndef SQLITE_ENABLE_STAT3_OR_STAT4\n  sqlite3_int64 *piTime = &p->pVdbe->iCurrentTime;\n  assert( p->pVdbe!=0 );\n#else\n  sqlite3_int64 iTime = 0;\n  sqlite3_int64 *piTime = p->pVdbe!=0 ? &p->pVdbe->iCurrentTime : &iTime;\n#endif\n  if( *piTime==0 ){\n    rc = sqlite3OsCurrentTimeInt64(p->pOut->db->pVfs, piTime);\n    if( rc ) *piTime = 0;\n  }\n  return *piTime;\n}\n\n/*\n** Create a new aggregate context for p and return a pointer to\n** its pMem->z element.\n*/\nstatic SQLITE_NOINLINE void *createAggContext(sqlite3_context *p, int nByte){\n  Mem *pMem = p->pMem;\n  assert( (pMem->flags & MEM_Agg)==0 );\n  if( nByte<=0 ){\n    sqlite3VdbeMemSetNull(pMem);\n    pMem->z = 0;\n  }else{\n    sqlite3VdbeMemClearAndResize(pMem, nByte);\n    pMem->flags = MEM_Agg;\n    pMem->u.pDef = p->pFunc;\n    if( pMem->z ){\n      memset(pMem->z, 0, nByte);\n    }\n  }\n  return (void*)pMem->z;\n}\n\n/*\n** Allocate or return the aggregate context for a user function.  A new\n** context is allocated on the first call.  Subsequent calls return the\n** same context that was returned on prior calls.\n*/\nSQLITE_API void *sqlite3_aggregate_context(sqlite3_context *p, int nByte){\n  assert( p && p->pFunc && p->pFunc->xFinalize );\n  assert( sqlite3_mutex_held(p->pOut->db->mutex) );\n  testcase( nByte<0 );\n  if( (p->pMem->flags & MEM_Agg)==0 ){\n    return createAggContext(p, nByte);\n  }else{\n    return (void*)p->pMem->z;\n  }\n}\n\n/*\n** Return the auxiliary data pointer, if any, for the iArg'th argument to\n** the user-function defined by pCtx.\n**\n** The left-most argument is 0.\n**\n** Undocumented behavior:  If iArg is negative then access a cache of\n** auxiliary data pointers that is available to all functions within a\n** single prepared statement.  The iArg values must match.\n*/\nSQLITE_API void *sqlite3_get_auxdata(sqlite3_context *pCtx, int iArg){\n  AuxData *pAuxData;\n\n  assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );\n#if SQLITE_ENABLE_STAT3_OR_STAT4\n  if( pCtx->pVdbe==0 ) return 0;\n#else\n  assert( pCtx->pVdbe!=0 );\n#endif\n  for(pAuxData=pCtx->pVdbe->pAuxData; pAuxData; pAuxData=pAuxData->pNextAux){\n    if(  pAuxData->iAuxArg==iArg && (pAuxData->iAuxOp==pCtx->iOp || iArg<0) ){\n      return pAuxData->pAux;\n    }\n  }\n  return 0;\n}\n\n/*\n** Set the auxiliary data pointer and delete function, for the iArg'th\n** argument to the user-function defined by pCtx. Any previous value is\n** deleted by calling the delete function specified when it was set.\n**\n** The left-most argument is 0.\n**\n** Undocumented behavior:  If iArg is negative then make the data available\n** to all functions within the current prepared statement using iArg as an\n** access code.\n*/\nSQLITE_API void sqlite3_set_auxdata(\n  sqlite3_context *pCtx, \n  int iArg, \n  void *pAux, \n  void (*xDelete)(void*)\n){\n  AuxData *pAuxData;\n  Vdbe *pVdbe = pCtx->pVdbe;\n\n  assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );\n#ifdef SQLITE_ENABLE_STAT3_OR_STAT4\n  if( pVdbe==0 ) goto failed;\n#else\n  assert( pVdbe!=0 );\n#endif\n\n  for(pAuxData=pVdbe->pAuxData; pAuxData; pAuxData=pAuxData->pNextAux){\n    if( pAuxData->iAuxArg==iArg && (pAuxData->iAuxOp==pCtx->iOp || iArg<0) ){\n      break;\n    }\n  }\n  if( pAuxData==0 ){\n    pAuxData = sqlite3DbMallocZero(pVdbe->db, sizeof(AuxData));\n    if( !pAuxData ) goto failed;\n    pAuxData->iAuxOp = pCtx->iOp;\n    pAuxData->iAuxArg = iArg;\n    pAuxData->pNextAux = pVdbe->pAuxData;\n    pVdbe->pAuxData = pAuxData;\n    if( pCtx->isError==0 ) pCtx->isError = -1;\n  }else if( pAuxData->xDeleteAux ){\n    pAuxData->xDeleteAux(pAuxData->pAux);\n  }\n\n  pAuxData->pAux = pAux;\n  pAuxData->xDeleteAux = xDelete;\n  return;\n\nfailed:\n  if( xDelete ){\n    xDelete(pAux);\n  }\n}\n\n#ifndef SQLITE_OMIT_DEPRECATED\n/*\n** Return the number of times the Step function of an aggregate has been \n** called.\n**\n** This function is deprecated.  Do not use it for new code.  It is\n** provide only to avoid breaking legacy code.  New aggregate function\n** implementations should keep their own counts within their aggregate\n** context.\n*/\nSQLITE_API int sqlite3_aggregate_count(sqlite3_context *p){\n  assert( p && p->pMem && p->pFunc && p->pFunc->xFinalize );\n  return p->pMem->n;\n}\n#endif\n\n/*\n** Return the number of columns in the result set for the statement pStmt.\n*/\nSQLITE_API int sqlite3_column_count(sqlite3_stmt *pStmt){\n  Vdbe *pVm = (Vdbe *)pStmt;\n  return pVm ? pVm->nResColumn : 0;\n}\n\n/*\n** Return the number of values available from the current row of the\n** currently executing statement pStmt.\n*/\nSQLITE_API int sqlite3_data_count(sqlite3_stmt *pStmt){\n  Vdbe *pVm = (Vdbe *)pStmt;\n  if( pVm==0 || pVm->pResultSet==0 ) return 0;\n  return pVm->nResColumn;\n}\n\n/*\n** Return a pointer to static memory containing an SQL NULL value.\n*/\nstatic const Mem *columnNullValue(void){\n  /* Even though the Mem structure contains an element\n  ** of type i64, on certain architectures (x86) with certain compiler\n  ** switches (-Os), gcc may align this Mem object on a 4-byte boundary\n  ** instead of an 8-byte one. This all works fine, except that when\n  ** running with SQLITE_DEBUG defined the SQLite code sometimes assert()s\n  ** that a Mem structure is located on an 8-byte boundary. To prevent\n  ** these assert()s from failing, when building with SQLITE_DEBUG defined\n  ** using gcc, we force nullMem to be 8-byte aligned using the magical\n  ** __attribute__((aligned(8))) macro.  */\n  static const Mem nullMem \n#if defined(SQLITE_DEBUG) && defined(__GNUC__)\n    __attribute__((aligned(8))) \n#endif\n    = {\n        /* .u          = */ {0},\n        /* .flags      = */ (u16)MEM_Null,\n        /* .enc        = */ (u8)0,\n        /* .eSubtype   = */ (u8)0,\n        /* .n          = */ (int)0,\n        /* .z          = */ (char*)0,\n        /* .zMalloc    = */ (char*)0,\n        /* .szMalloc   = */ (int)0,\n        /* .uTemp      = */ (u32)0,\n        /* .db         = */ (sqlite3*)0,\n        /* .xDel       = */ (void(*)(void*))0,\n#ifdef SQLITE_DEBUG\n        /* .pScopyFrom = */ (Mem*)0,\n        /* .mScopyFlags= */ 0,\n#endif\n      };\n  return &nullMem;\n}\n\n/*\n** Check to see if column iCol of the given statement is valid.  If\n** it is, return a pointer to the Mem for the value of that column.\n** If iCol is not valid, return a pointer to a Mem which has a value\n** of NULL.\n*/\nstatic Mem *columnMem(sqlite3_stmt *pStmt, int i){\n  Vdbe *pVm;\n  Mem *pOut;\n\n  pVm = (Vdbe *)pStmt;\n  if( pVm==0 ) return (Mem*)columnNullValue();\n  assert( pVm->db );\n  sqlite3_mutex_enter(pVm->db->mutex);\n  if( pVm->pResultSet!=0 && i<pVm->nResColumn && i>=0 ){\n    pOut = &pVm->pResultSet[i];\n  }else{\n    sqlite3Error(pVm->db, SQLITE_RANGE);\n    pOut = (Mem*)columnNullValue();\n  }\n  return pOut;\n}\n\n/*\n** This function is called after invoking an sqlite3_value_XXX function on a \n** column value (i.e. a value returned by evaluating an SQL expression in the\n** select list of a SELECT statement) that may cause a malloc() failure. If \n** malloc() has failed, the threads mallocFailed flag is cleared and the result\n** code of statement pStmt set to SQLITE_NOMEM.\n**\n** Specifically, this is called from within:\n**\n**     sqlite3_column_int()\n**     sqlite3_column_int64()\n**     sqlite3_column_text()\n**     sqlite3_column_text16()\n**     sqlite3_column_real()\n**     sqlite3_column_bytes()\n**     sqlite3_column_bytes16()\n**     sqiite3_column_blob()\n*/\nstatic void columnMallocFailure(sqlite3_stmt *pStmt)\n{\n  /* If malloc() failed during an encoding conversion within an\n  ** sqlite3_column_XXX API, then set the return code of the statement to\n  ** SQLITE_NOMEM. The next call to _step() (if any) will return SQLITE_ERROR\n  ** and _finalize() will return NOMEM.\n  */\n  Vdbe *p = (Vdbe *)pStmt;\n  if( p ){\n    assert( p->db!=0 );\n    assert( sqlite3_mutex_held(p->db->mutex) );\n    p->rc = sqlite3ApiExit(p->db, p->rc);\n    sqlite3_mutex_leave(p->db->mutex);\n  }\n}\n\n/**************************** sqlite3_column_  *******************************\n** The following routines are used to access elements of the current row\n** in the result set.\n*/\nSQLITE_API const void *sqlite3_column_blob(sqlite3_stmt *pStmt, int i){\n  const void *val;\n  val = sqlite3_value_blob( columnMem(pStmt,i) );\n  /* Even though there is no encoding conversion, value_blob() might\n  ** need to call malloc() to expand the result of a zeroblob() \n  ** expression. \n  */\n  columnMallocFailure(pStmt);\n  return val;\n}\nSQLITE_API int sqlite3_column_bytes(sqlite3_stmt *pStmt, int i){\n  int val = sqlite3_value_bytes( columnMem(pStmt,i) );\n  columnMallocFailure(pStmt);\n  return val;\n}\nSQLITE_API int sqlite3_column_bytes16(sqlite3_stmt *pStmt, int i){\n  int val = sqlite3_value_bytes16( columnMem(pStmt,i) );\n  columnMallocFailure(pStmt);\n  return val;\n}\nSQLITE_API double sqlite3_column_double(sqlite3_stmt *pStmt, int i){\n  double val = sqlite3_value_double( columnMem(pStmt,i) );\n  columnMallocFailure(pStmt);\n  return val;\n}\nSQLITE_API int sqlite3_column_int(sqlite3_stmt *pStmt, int i){\n  int val = sqlite3_value_int( columnMem(pStmt,i) );\n  columnMallocFailure(pStmt);\n  return val;\n}\nSQLITE_API sqlite_int64 sqlite3_column_int64(sqlite3_stmt *pStmt, int i){\n  sqlite_int64 val = sqlite3_value_int64( columnMem(pStmt,i) );\n  columnMallocFailure(pStmt);\n  return val;\n}\nSQLITE_API const unsigned char *sqlite3_column_text(sqlite3_stmt *pStmt, int i){\n  const unsigned char *val = sqlite3_value_text( columnMem(pStmt,i) );\n  columnMallocFailure(pStmt);\n  return val;\n}\nSQLITE_API sqlite3_value *sqlite3_column_value(sqlite3_stmt *pStmt, int i){\n  Mem *pOut = columnMem(pStmt, i);\n  if( pOut->flags&MEM_Static ){\n    pOut->flags &= ~MEM_Static;\n    pOut->flags |= MEM_Ephem;\n  }\n  columnMallocFailure(pStmt);\n  return (sqlite3_value *)pOut;\n}\n#ifndef SQLITE_OMIT_UTF16\nSQLITE_API const void *sqlite3_column_text16(sqlite3_stmt *pStmt, int i){\n  const void *val = sqlite3_value_text16( columnMem(pStmt,i) );\n  columnMallocFailure(pStmt);\n  return val;\n}\n#endif /* SQLITE_OMIT_UTF16 */\nSQLITE_API int sqlite3_column_type(sqlite3_stmt *pStmt, int i){\n  int iType = sqlite3_value_type( columnMem(pStmt,i) );\n  columnMallocFailure(pStmt);\n  return iType;\n}\n\n/*\n** Convert the N-th element of pStmt->pColName[] into a string using\n** xFunc() then return that string.  If N is out of range, return 0.\n**\n** There are up to 5 names for each column.  useType determines which\n** name is returned.  Here are the names:\n**\n**    0      The column name as it should be displayed for output\n**    1      The datatype name for the column\n**    2      The name of the database that the column derives from\n**    3      The name of the table that the column derives from\n**    4      The name of the table column that the result column derives from\n**\n** If the result is not a simple column reference (if it is an expression\n** or a constant) then useTypes 2, 3, and 4 return NULL.\n*/\nstatic const void *columnName(\n  sqlite3_stmt *pStmt,\n  int N,\n  const void *(*xFunc)(Mem*),\n  int useType\n){\n  const void *ret;\n  Vdbe *p;\n  int n;\n  sqlite3 *db;\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( pStmt==0 ){\n    (void)SQLITE_MISUSE_BKPT;\n    return 0;\n  }\n#endif\n  ret = 0;\n  p = (Vdbe *)pStmt;\n  db = p->db;\n  assert( db!=0 );\n  n = sqlite3_column_count(pStmt);\n  if( N<n && N>=0 ){\n    N += useType*n;\n    sqlite3_mutex_enter(db->mutex);\n    assert( db->mallocFailed==0 );\n    ret = xFunc(&p->aColName[N]);\n     /* A malloc may have failed inside of the xFunc() call. If this\n    ** is the case, clear the mallocFailed flag and return NULL.\n    */\n    if( db->mallocFailed ){\n      sqlite3OomClear(db);\n      ret = 0;\n    }\n    sqlite3_mutex_leave(db->mutex);\n  }\n  return ret;\n}\n\n/*\n** Return the name of the Nth column of the result set returned by SQL\n** statement pStmt.\n*/\nSQLITE_API const char *sqlite3_column_name(sqlite3_stmt *pStmt, int N){\n  return columnName(\n      pStmt, N, (const void*(*)(Mem*))sqlite3_value_text, COLNAME_NAME);\n}\n#ifndef SQLITE_OMIT_UTF16\nSQLITE_API const void *sqlite3_column_name16(sqlite3_stmt *pStmt, int N){\n  return columnName(\n      pStmt, N, (const void*(*)(Mem*))sqlite3_value_text16, COLNAME_NAME);\n}\n#endif\n\n/*\n** Constraint:  If you have ENABLE_COLUMN_METADATA then you must\n** not define OMIT_DECLTYPE.\n*/\n#if defined(SQLITE_OMIT_DECLTYPE) && defined(SQLITE_ENABLE_COLUMN_METADATA)\n# error \"Must not define both SQLITE_OMIT_DECLTYPE \\\n         and SQLITE_ENABLE_COLUMN_METADATA\"\n#endif\n\n#ifndef SQLITE_OMIT_DECLTYPE\n/*\n** Return the column declaration type (if applicable) of the 'i'th column\n** of the result set of SQL statement pStmt.\n*/\nSQLITE_API const char *sqlite3_column_decltype(sqlite3_stmt *pStmt, int N){\n  return columnName(\n      pStmt, N, (const void*(*)(Mem*))sqlite3_value_text, COLNAME_DECLTYPE);\n}\n#ifndef SQLITE_OMIT_UTF16\nSQLITE_API const void *sqlite3_column_decltype16(sqlite3_stmt *pStmt, int N){\n  return columnName(\n      pStmt, N, (const void*(*)(Mem*))sqlite3_value_text16, COLNAME_DECLTYPE);\n}\n#endif /* SQLITE_OMIT_UTF16 */\n#endif /* SQLITE_OMIT_DECLTYPE */\n\n#ifdef SQLITE_ENABLE_COLUMN_METADATA\n/*\n** Return the name of the database from which a result column derives.\n** NULL is returned if the result column is an expression or constant or\n** anything else which is not an unambiguous reference to a database column.\n*/\nSQLITE_API const char *sqlite3_column_database_name(sqlite3_stmt *pStmt, int N){\n  return columnName(\n      pStmt, N, (const void*(*)(Mem*))sqlite3_value_text, COLNAME_DATABASE);\n}\n#ifndef SQLITE_OMIT_UTF16\nSQLITE_API const void *sqlite3_column_database_name16(sqlite3_stmt *pStmt, int N){\n  return columnName(\n      pStmt, N, (const void*(*)(Mem*))sqlite3_value_text16, COLNAME_DATABASE);\n}\n#endif /* SQLITE_OMIT_UTF16 */\n\n/*\n** Return the name of the table from which a result column derives.\n** NULL is returned if the result column is an expression or constant or\n** anything else which is not an unambiguous reference to a database column.\n*/\nSQLITE_API const char *sqlite3_column_table_name(sqlite3_stmt *pStmt, int N){\n  return columnName(\n      pStmt, N, (const void*(*)(Mem*))sqlite3_value_text, COLNAME_TABLE);\n}\n#ifndef SQLITE_OMIT_UTF16\nSQLITE_API const void *sqlite3_column_table_name16(sqlite3_stmt *pStmt, int N){\n  return columnName(\n      pStmt, N, (const void*(*)(Mem*))sqlite3_value_text16, COLNAME_TABLE);\n}\n#endif /* SQLITE_OMIT_UTF16 */\n\n/*\n** Return the name of the table column from which a result column derives.\n** NULL is returned if the result column is an expression or constant or\n** anything else which is not an unambiguous reference to a database column.\n*/\nSQLITE_API const char *sqlite3_column_origin_name(sqlite3_stmt *pStmt, int N){\n  return columnName(\n      pStmt, N, (const void*(*)(Mem*))sqlite3_value_text, COLNAME_COLUMN);\n}\n#ifndef SQLITE_OMIT_UTF16\nSQLITE_API const void *sqlite3_column_origin_name16(sqlite3_stmt *pStmt, int N){\n  return columnName(\n      pStmt, N, (const void*(*)(Mem*))sqlite3_value_text16, COLNAME_COLUMN);\n}\n#endif /* SQLITE_OMIT_UTF16 */\n#endif /* SQLITE_ENABLE_COLUMN_METADATA */\n\n\n/******************************* sqlite3_bind_  ***************************\n** \n** Routines used to attach values to wildcards in a compiled SQL statement.\n*/\n/*\n** Unbind the value bound to variable i in virtual machine p. This is the \n** the same as binding a NULL value to the column. If the \"i\" parameter is\n** out of range, then SQLITE_RANGE is returned. Othewise SQLITE_OK.\n**\n** A successful evaluation of this routine acquires the mutex on p.\n** the mutex is released if any kind of error occurs.\n**\n** The error code stored in database p->db is overwritten with the return\n** value in any case.\n*/\nstatic int vdbeUnbind(Vdbe *p, int i){\n  Mem *pVar;\n  if( vdbeSafetyNotNull(p) ){\n    return SQLITE_MISUSE_BKPT;\n  }\n  sqlite3_mutex_enter(p->db->mutex);\n  if( p->magic!=VDBE_MAGIC_RUN || p->pc>=0 ){\n    sqlite3Error(p->db, SQLITE_MISUSE);\n    sqlite3_mutex_leave(p->db->mutex);\n    sqlite3_log(SQLITE_MISUSE, \n        \"bind on a busy prepared statement: [%s]\", p->zSql);\n    return SQLITE_MISUSE_BKPT;\n  }\n  if( i<1 || i>p->nVar ){\n    sqlite3Error(p->db, SQLITE_RANGE);\n    sqlite3_mutex_leave(p->db->mutex);\n    return SQLITE_RANGE;\n  }\n  i--;\n  pVar = &p->aVar[i];\n  sqlite3VdbeMemRelease(pVar);\n  pVar->flags = MEM_Null;\n  p->db->errCode = SQLITE_OK;\n\n  /* If the bit corresponding to this variable in Vdbe.expmask is set, then \n  ** binding a new value to this variable invalidates the current query plan.\n  **\n  ** IMPLEMENTATION-OF: R-48440-37595 If the specific value bound to host\n  ** parameter in the WHERE clause might influence the choice of query plan\n  ** for a statement, then the statement will be automatically recompiled,\n  ** as if there had been a schema change, on the first sqlite3_step() call\n  ** following any change to the bindings of that parameter.\n  */\n  assert( (p->prepFlags & SQLITE_PREPARE_SAVESQL)!=0 || p->expmask==0 );\n  if( p->expmask!=0 && (p->expmask & (i>=31 ? 0x80000000 : (u32)1<<i))!=0 ){\n    p->expired = 1;\n  }\n  return SQLITE_OK;\n}\n\n/*\n** Bind a text or BLOB value.\n*/\nstatic int bindText(\n  sqlite3_stmt *pStmt,   /* The statement to bind against */\n  int i,                 /* Index of the parameter to bind */\n  const void *zData,     /* Pointer to the data to be bound */\n  int nData,             /* Number of bytes of data to be bound */\n  void (*xDel)(void*),   /* Destructor for the data */\n  u8 encoding            /* Encoding for the data */\n){\n  Vdbe *p = (Vdbe *)pStmt;\n  Mem *pVar;\n  int rc;\n\n  rc = vdbeUnbind(p, i);\n  if( rc==SQLITE_OK ){\n    if( zData!=0 ){\n      pVar = &p->aVar[i-1];\n      rc = sqlite3VdbeMemSetStr(pVar, zData, nData, encoding, xDel);\n      if( rc==SQLITE_OK && encoding!=0 ){\n        rc = sqlite3VdbeChangeEncoding(pVar, ENC(p->db));\n      }\n      if( rc ){\n        sqlite3Error(p->db, rc);\n        rc = sqlite3ApiExit(p->db, rc);\n      }\n    }\n    sqlite3_mutex_leave(p->db->mutex);\n  }else if( xDel!=SQLITE_STATIC && xDel!=SQLITE_TRANSIENT ){\n    xDel((void*)zData);\n  }\n  return rc;\n}\n\n\n/*\n** Bind a blob value to an SQL statement variable.\n*/\nSQLITE_API int sqlite3_bind_blob(\n  sqlite3_stmt *pStmt, \n  int i, \n  const void *zData, \n  int nData, \n  void (*xDel)(void*)\n){\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( nData<0 ) return SQLITE_MISUSE_BKPT;\n#endif\n  return bindText(pStmt, i, zData, nData, xDel, 0);\n}\nSQLITE_API int sqlite3_bind_blob64(\n  sqlite3_stmt *pStmt, \n  int i, \n  const void *zData, \n  sqlite3_uint64 nData, \n  void (*xDel)(void*)\n){\n  assert( xDel!=SQLITE_DYNAMIC );\n  if( nData>0x7fffffff ){\n    return invokeValueDestructor(zData, xDel, 0);\n  }else{\n    return bindText(pStmt, i, zData, (int)nData, xDel, 0);\n  }\n}\nSQLITE_API int sqlite3_bind_double(sqlite3_stmt *pStmt, int i, double rValue){\n  int rc;\n  Vdbe *p = (Vdbe *)pStmt;\n  rc = vdbeUnbind(p, i);\n  if( rc==SQLITE_OK ){\n    sqlite3VdbeMemSetDouble(&p->aVar[i-1], rValue);\n    sqlite3_mutex_leave(p->db->mutex);\n  }\n  return rc;\n}\nSQLITE_API int sqlite3_bind_int(sqlite3_stmt *p, int i, int iValue){\n  return sqlite3_bind_int64(p, i, (i64)iValue);\n}\nSQLITE_API int sqlite3_bind_int64(sqlite3_stmt *pStmt, int i, sqlite_int64 iValue){\n  int rc;\n  Vdbe *p = (Vdbe *)pStmt;\n  rc = vdbeUnbind(p, i);\n  if( rc==SQLITE_OK ){\n    sqlite3VdbeMemSetInt64(&p->aVar[i-1], iValue);\n    sqlite3_mutex_leave(p->db->mutex);\n  }\n  return rc;\n}\nSQLITE_API int sqlite3_bind_null(sqlite3_stmt *pStmt, int i){\n  int rc;\n  Vdbe *p = (Vdbe*)pStmt;\n  rc = vdbeUnbind(p, i);\n  if( rc==SQLITE_OK ){\n    sqlite3_mutex_leave(p->db->mutex);\n  }\n  return rc;\n}\nSQLITE_API int sqlite3_bind_pointer(\n  sqlite3_stmt *pStmt,\n  int i,\n  void *pPtr,\n  const char *zPTtype,\n  void (*xDestructor)(void*)\n){\n  int rc;\n  Vdbe *p = (Vdbe*)pStmt;\n  rc = vdbeUnbind(p, i);\n  if( rc==SQLITE_OK ){\n    sqlite3VdbeMemSetPointer(&p->aVar[i-1], pPtr, zPTtype, xDestructor);\n    sqlite3_mutex_leave(p->db->mutex);\n  }else if( xDestructor ){\n    xDestructor(pPtr);\n  }\n  return rc;\n}\nSQLITE_API int sqlite3_bind_text( \n  sqlite3_stmt *pStmt, \n  int i, \n  const char *zData, \n  int nData, \n  void (*xDel)(void*)\n){\n  return bindText(pStmt, i, zData, nData, xDel, SQLITE_UTF8);\n}\nSQLITE_API int sqlite3_bind_text64( \n  sqlite3_stmt *pStmt, \n  int i, \n  const char *zData, \n  sqlite3_uint64 nData, \n  void (*xDel)(void*),\n  unsigned char enc\n){\n  assert( xDel!=SQLITE_DYNAMIC );\n  if( nData>0x7fffffff ){\n    return invokeValueDestructor(zData, xDel, 0);\n  }else{\n    if( enc==SQLITE_UTF16 ) enc = SQLITE_UTF16NATIVE;\n    return bindText(pStmt, i, zData, (int)nData, xDel, enc);\n  }\n}\n#ifndef SQLITE_OMIT_UTF16\nSQLITE_API int sqlite3_bind_text16(\n  sqlite3_stmt *pStmt, \n  int i, \n  const void *zData, \n  int nData, \n  void (*xDel)(void*)\n){\n  return bindText(pStmt, i, zData, nData, xDel, SQLITE_UTF16NATIVE);\n}\n#endif /* SQLITE_OMIT_UTF16 */\nSQLITE_API int sqlite3_bind_value(sqlite3_stmt *pStmt, int i, const sqlite3_value *pValue){\n  int rc;\n  switch( sqlite3_value_type((sqlite3_value*)pValue) ){\n    case SQLITE_INTEGER: {\n      rc = sqlite3_bind_int64(pStmt, i, pValue->u.i);\n      break;\n    }\n    case SQLITE_FLOAT: {\n      rc = sqlite3_bind_double(pStmt, i, pValue->u.r);\n      break;\n    }\n    case SQLITE_BLOB: {\n      if( pValue->flags & MEM_Zero ){\n        rc = sqlite3_bind_zeroblob(pStmt, i, pValue->u.nZero);\n      }else{\n        rc = sqlite3_bind_blob(pStmt, i, pValue->z, pValue->n,SQLITE_TRANSIENT);\n      }\n      break;\n    }\n    case SQLITE_TEXT: {\n      rc = bindText(pStmt,i,  pValue->z, pValue->n, SQLITE_TRANSIENT,\n                              pValue->enc);\n      break;\n    }\n    default: {\n      rc = sqlite3_bind_null(pStmt, i);\n      break;\n    }\n  }\n  return rc;\n}\nSQLITE_API int sqlite3_bind_zeroblob(sqlite3_stmt *pStmt, int i, int n){\n  int rc;\n  Vdbe *p = (Vdbe *)pStmt;\n  rc = vdbeUnbind(p, i);\n  if( rc==SQLITE_OK ){\n    sqlite3VdbeMemSetZeroBlob(&p->aVar[i-1], n);\n    sqlite3_mutex_leave(p->db->mutex);\n  }\n  return rc;\n}\nSQLITE_API int sqlite3_bind_zeroblob64(sqlite3_stmt *pStmt, int i, sqlite3_uint64 n){\n  int rc;\n  Vdbe *p = (Vdbe *)pStmt;\n  sqlite3_mutex_enter(p->db->mutex);\n  if( n>(u64)p->db->aLimit[SQLITE_LIMIT_LENGTH] ){\n    rc = SQLITE_TOOBIG;\n  }else{\n    assert( (n & 0x7FFFFFFF)==n );\n    rc = sqlite3_bind_zeroblob(pStmt, i, n);\n  }\n  rc = sqlite3ApiExit(p->db, rc);\n  sqlite3_mutex_leave(p->db->mutex);\n  return rc;\n}\n\n/*\n** Return the number of wildcards that can be potentially bound to.\n** This routine is added to support DBD::SQLite.  \n*/\nSQLITE_API int sqlite3_bind_parameter_count(sqlite3_stmt *pStmt){\n  Vdbe *p = (Vdbe*)pStmt;\n  return p ? p->nVar : 0;\n}\n\n/*\n** Return the name of a wildcard parameter.  Return NULL if the index\n** is out of range or if the wildcard is unnamed.\n**\n** The result is always UTF-8.\n*/\nSQLITE_API const char *sqlite3_bind_parameter_name(sqlite3_stmt *pStmt, int i){\n  Vdbe *p = (Vdbe*)pStmt;\n  if( p==0 ) return 0;\n  return sqlite3VListNumToName(p->pVList, i);\n}\n\n/*\n** Given a wildcard parameter name, return the index of the variable\n** with that name.  If there is no variable with the given name,\n** return 0.\n*/\nSQLITE_PRIVATE int sqlite3VdbeParameterIndex(Vdbe *p, const char *zName, int nName){\n  if( p==0 || zName==0 ) return 0;\n  return sqlite3VListNameToNum(p->pVList, zName, nName);\n}\nSQLITE_API int sqlite3_bind_parameter_index(sqlite3_stmt *pStmt, const char *zName){\n  return sqlite3VdbeParameterIndex((Vdbe*)pStmt, zName, sqlite3Strlen30(zName));\n}\n\n/*\n** Transfer all bindings from the first statement over to the second.\n*/\nSQLITE_PRIVATE int sqlite3TransferBindings(sqlite3_stmt *pFromStmt, sqlite3_stmt *pToStmt){\n  Vdbe *pFrom = (Vdbe*)pFromStmt;\n  Vdbe *pTo = (Vdbe*)pToStmt;\n  int i;\n  assert( pTo->db==pFrom->db );\n  assert( pTo->nVar==pFrom->nVar );\n  sqlite3_mutex_enter(pTo->db->mutex);\n  for(i=0; i<pFrom->nVar; i++){\n    sqlite3VdbeMemMove(&pTo->aVar[i], &pFrom->aVar[i]);\n  }\n  sqlite3_mutex_leave(pTo->db->mutex);\n  return SQLITE_OK;\n}\n\n#ifndef SQLITE_OMIT_DEPRECATED\n/*\n** Deprecated external interface.  Internal/core SQLite code\n** should call sqlite3TransferBindings.\n**\n** It is misuse to call this routine with statements from different\n** database connections.  But as this is a deprecated interface, we\n** will not bother to check for that condition.\n**\n** If the two statements contain a different number of bindings, then\n** an SQLITE_ERROR is returned.  Nothing else can go wrong, so otherwise\n** SQLITE_OK is returned.\n*/\nSQLITE_API int sqlite3_transfer_bindings(sqlite3_stmt *pFromStmt, sqlite3_stmt *pToStmt){\n  Vdbe *pFrom = (Vdbe*)pFromStmt;\n  Vdbe *pTo = (Vdbe*)pToStmt;\n  if( pFrom->nVar!=pTo->nVar ){\n    return SQLITE_ERROR;\n  }\n  assert( (pTo->prepFlags & SQLITE_PREPARE_SAVESQL)!=0 || pTo->expmask==0 );\n  if( pTo->expmask ){\n    pTo->expired = 1;\n  }\n  assert( (pFrom->prepFlags & SQLITE_PREPARE_SAVESQL)!=0 || pFrom->expmask==0 );\n  if( pFrom->expmask ){\n    pFrom->expired = 1;\n  }\n  return sqlite3TransferBindings(pFromStmt, pToStmt);\n}\n#endif\n\n/*\n** Return the sqlite3* database handle to which the prepared statement given\n** in the argument belongs.  This is the same database handle that was\n** the first argument to the sqlite3_prepare() that was used to create\n** the statement in the first place.\n*/\nSQLITE_API sqlite3 *sqlite3_db_handle(sqlite3_stmt *pStmt){\n  return pStmt ? ((Vdbe*)pStmt)->db : 0;\n}\n\n/*\n** Return true if the prepared statement is guaranteed to not modify the\n** database.\n*/\nSQLITE_API int sqlite3_stmt_readonly(sqlite3_stmt *pStmt){\n  return pStmt ? ((Vdbe*)pStmt)->readOnly : 1;\n}\n\n/*\n** Return true if the prepared statement is in need of being reset.\n*/\nSQLITE_API int sqlite3_stmt_busy(sqlite3_stmt *pStmt){\n  Vdbe *v = (Vdbe*)pStmt;\n  return v!=0 && v->magic==VDBE_MAGIC_RUN && v->pc>=0;\n}\n\n/*\n** Return a pointer to the next prepared statement after pStmt associated\n** with database connection pDb.  If pStmt is NULL, return the first\n** prepared statement for the database connection.  Return NULL if there\n** are no more.\n*/\nSQLITE_API sqlite3_stmt *sqlite3_next_stmt(sqlite3 *pDb, sqlite3_stmt *pStmt){\n  sqlite3_stmt *pNext;\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( !sqlite3SafetyCheckOk(pDb) ){\n    (void)SQLITE_MISUSE_BKPT;\n    return 0;\n  }\n#endif\n  sqlite3_mutex_enter(pDb->mutex);\n  if( pStmt==0 ){\n    pNext = (sqlite3_stmt*)pDb->pVdbe;\n  }else{\n    pNext = (sqlite3_stmt*)((Vdbe*)pStmt)->pNext;\n  }\n  sqlite3_mutex_leave(pDb->mutex);\n  return pNext;\n}\n\n/*\n** Return the value of a status counter for a prepared statement\n*/\nSQLITE_API int sqlite3_stmt_status(sqlite3_stmt *pStmt, int op, int resetFlag){\n  Vdbe *pVdbe = (Vdbe*)pStmt;\n  u32 v;\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( !pStmt \n   || (op!=SQLITE_STMTSTATUS_MEMUSED && (op<0||op>=ArraySize(pVdbe->aCounter)))\n  ){\n    (void)SQLITE_MISUSE_BKPT;\n    return 0;\n  }\n#endif\n  if( op==SQLITE_STMTSTATUS_MEMUSED ){\n    sqlite3 *db = pVdbe->db;\n    sqlite3_mutex_enter(db->mutex);\n    v = 0;\n    db->pnBytesFreed = (int*)&v;\n    sqlite3VdbeClearObject(db, pVdbe);\n    sqlite3DbFree(db, pVdbe);\n    db->pnBytesFreed = 0;\n    sqlite3_mutex_leave(db->mutex);\n  }else{\n    v = pVdbe->aCounter[op];\n    if( resetFlag ) pVdbe->aCounter[op] = 0;\n  }\n  return (int)v;\n}\n\n/*\n** Return the SQL associated with a prepared statement\n*/\nSQLITE_API const char *sqlite3_sql(sqlite3_stmt *pStmt){\n  Vdbe *p = (Vdbe *)pStmt;\n  return p ? p->zSql : 0;\n}\n\n/*\n** Return the SQL associated with a prepared statement with\n** bound parameters expanded.  Space to hold the returned string is\n** obtained from sqlite3_malloc().  The caller is responsible for\n** freeing the returned string by passing it to sqlite3_free().\n**\n** The SQLITE_TRACE_SIZE_LIMIT puts an upper bound on the size of\n** expanded bound parameters.\n*/\nSQLITE_API char *sqlite3_expanded_sql(sqlite3_stmt *pStmt){\n#ifdef SQLITE_OMIT_TRACE\n  return 0;\n#else\n  char *z = 0;\n  const char *zSql = sqlite3_sql(pStmt);\n  if( zSql ){\n    Vdbe *p = (Vdbe *)pStmt;\n    sqlite3_mutex_enter(p->db->mutex);\n    z = sqlite3VdbeExpandSql(p, zSql);\n    sqlite3_mutex_leave(p->db->mutex);\n  }\n  return z;\n#endif\n}\n\n#ifdef SQLITE_ENABLE_NORMALIZE\n/*\n** Return the normalized SQL associated with a prepared statement.\n*/\nSQLITE_API const char *sqlite3_normalized_sql(sqlite3_stmt *pStmt){\n  Vdbe *p = (Vdbe *)pStmt;\n  if( p==0 ) return 0;\n  if( p->zNormSql==0 && ALWAYS(p->zSql!=0) ){\n    sqlite3_mutex_enter(p->db->mutex);\n    p->zNormSql = sqlite3Normalize(p, p->zSql);\n    sqlite3_mutex_leave(p->db->mutex);\n  }\n  return p->zNormSql;\n}\n#endif /* SQLITE_ENABLE_NORMALIZE */\n\n#ifdef SQLITE_ENABLE_PREUPDATE_HOOK\n/*\n** Allocate and populate an UnpackedRecord structure based on the serialized\n** record in nKey/pKey. Return a pointer to the new UnpackedRecord structure\n** if successful, or a NULL pointer if an OOM error is encountered.\n*/\nstatic UnpackedRecord *vdbeUnpackRecord(\n  KeyInfo *pKeyInfo, \n  int nKey, \n  const void *pKey\n){\n  UnpackedRecord *pRet;           /* Return value */\n\n  pRet = sqlite3VdbeAllocUnpackedRecord(pKeyInfo);\n  if( pRet ){\n    memset(pRet->aMem, 0, sizeof(Mem)*(pKeyInfo->nKeyField+1));\n    sqlite3VdbeRecordUnpack(pKeyInfo, nKey, pKey, pRet);\n  }\n  return pRet;\n}\n\n/*\n** This function is called from within a pre-update callback to retrieve\n** a field of the row currently being updated or deleted.\n*/\nSQLITE_API int sqlite3_preupdate_old(sqlite3 *db, int iIdx, sqlite3_value **ppValue){\n  PreUpdate *p = db->pPreUpdate;\n  Mem *pMem;\n  int rc = SQLITE_OK;\n\n  /* Test that this call is being made from within an SQLITE_DELETE or\n  ** SQLITE_UPDATE pre-update callback, and that iIdx is within range. */\n  if( !p || p->op==SQLITE_INSERT ){\n    rc = SQLITE_MISUSE_BKPT;\n    goto preupdate_old_out;\n  }\n  if( p->pPk ){\n    iIdx = sqlite3ColumnOfIndex(p->pPk, iIdx);\n  }\n  if( iIdx>=p->pCsr->nField || iIdx<0 ){\n    rc = SQLITE_RANGE;\n    goto preupdate_old_out;\n  }\n\n  /* If the old.* record has not yet been loaded into memory, do so now. */\n  if( p->pUnpacked==0 ){\n    u32 nRec;\n    u8 *aRec;\n\n    nRec = sqlite3BtreePayloadSize(p->pCsr->uc.pCursor);\n    aRec = sqlite3DbMallocRaw(db, nRec);\n    if( !aRec ) goto preupdate_old_out;\n    rc = sqlite3BtreePayload(p->pCsr->uc.pCursor, 0, nRec, aRec);\n    if( rc==SQLITE_OK ){\n      p->pUnpacked = vdbeUnpackRecord(&p->keyinfo, nRec, aRec);\n      if( !p->pUnpacked ) rc = SQLITE_NOMEM;\n    }\n    if( rc!=SQLITE_OK ){\n      sqlite3DbFree(db, aRec);\n      goto preupdate_old_out;\n    }\n    p->aRecord = aRec;\n  }\n\n  pMem = *ppValue = &p->pUnpacked->aMem[iIdx];\n  if( iIdx==p->pTab->iPKey ){\n    sqlite3VdbeMemSetInt64(pMem, p->iKey1);\n  }else if( iIdx>=p->pUnpacked->nField ){\n    *ppValue = (sqlite3_value *)columnNullValue();\n  }else if( p->pTab->aCol[iIdx].affinity==SQLITE_AFF_REAL ){\n    if( pMem->flags & MEM_Int ){\n      sqlite3VdbeMemRealify(pMem);\n    }\n  }\n\n preupdate_old_out:\n  sqlite3Error(db, rc);\n  return sqlite3ApiExit(db, rc);\n}\n#endif /* SQLITE_ENABLE_PREUPDATE_HOOK */\n\n#ifdef SQLITE_ENABLE_PREUPDATE_HOOK\n/*\n** This function is called from within a pre-update callback to retrieve\n** the number of columns in the row being updated, deleted or inserted.\n*/\nSQLITE_API int sqlite3_preupdate_count(sqlite3 *db){\n  PreUpdate *p = db->pPreUpdate;\n  return (p ? p->keyinfo.nKeyField : 0);\n}\n#endif /* SQLITE_ENABLE_PREUPDATE_HOOK */\n\n#ifdef SQLITE_ENABLE_PREUPDATE_HOOK\n/*\n** This function is designed to be called from within a pre-update callback\n** only. It returns zero if the change that caused the callback was made\n** immediately by a user SQL statement. Or, if the change was made by a\n** trigger program, it returns the number of trigger programs currently\n** on the stack (1 for a top-level trigger, 2 for a trigger fired by a \n** top-level trigger etc.).\n**\n** For the purposes of the previous paragraph, a foreign key CASCADE, SET NULL\n** or SET DEFAULT action is considered a trigger.\n*/\nSQLITE_API int sqlite3_preupdate_depth(sqlite3 *db){\n  PreUpdate *p = db->pPreUpdate;\n  return (p ? p->v->nFrame : 0);\n}\n#endif /* SQLITE_ENABLE_PREUPDATE_HOOK */\n\n#ifdef SQLITE_ENABLE_PREUPDATE_HOOK\n/*\n** This function is called from within a pre-update callback to retrieve\n** a field of the row currently being updated or inserted.\n*/\nSQLITE_API int sqlite3_preupdate_new(sqlite3 *db, int iIdx, sqlite3_value **ppValue){\n  PreUpdate *p = db->pPreUpdate;\n  int rc = SQLITE_OK;\n  Mem *pMem;\n\n  if( !p || p->op==SQLITE_DELETE ){\n    rc = SQLITE_MISUSE_BKPT;\n    goto preupdate_new_out;\n  }\n  if( p->pPk && p->op!=SQLITE_UPDATE ){\n    iIdx = sqlite3ColumnOfIndex(p->pPk, iIdx);\n  }\n  if( iIdx>=p->pCsr->nField || iIdx<0 ){\n    rc = SQLITE_RANGE;\n    goto preupdate_new_out;\n  }\n\n  if( p->op==SQLITE_INSERT ){\n    /* For an INSERT, memory cell p->iNewReg contains the serialized record\n    ** that is being inserted. Deserialize it. */\n    UnpackedRecord *pUnpack = p->pNewUnpacked;\n    if( !pUnpack ){\n      Mem *pData = &p->v->aMem[p->iNewReg];\n      rc = ExpandBlob(pData);\n      if( rc!=SQLITE_OK ) goto preupdate_new_out;\n      pUnpack = vdbeUnpackRecord(&p->keyinfo, pData->n, pData->z);\n      if( !pUnpack ){\n        rc = SQLITE_NOMEM;\n        goto preupdate_new_out;\n      }\n      p->pNewUnpacked = pUnpack;\n    }\n    pMem = &pUnpack->aMem[iIdx];\n    if( iIdx==p->pTab->iPKey ){\n      sqlite3VdbeMemSetInt64(pMem, p->iKey2);\n    }else if( iIdx>=pUnpack->nField ){\n      pMem = (sqlite3_value *)columnNullValue();\n    }\n  }else{\n    /* For an UPDATE, memory cell (p->iNewReg+1+iIdx) contains the required\n    ** value. Make a copy of the cell contents and return a pointer to it.\n    ** It is not safe to return a pointer to the memory cell itself as the\n    ** caller may modify the value text encoding.\n    */\n    assert( p->op==SQLITE_UPDATE );\n    if( !p->aNew ){\n      p->aNew = (Mem *)sqlite3DbMallocZero(db, sizeof(Mem) * p->pCsr->nField);\n      if( !p->aNew ){\n        rc = SQLITE_NOMEM;\n        goto preupdate_new_out;\n      }\n    }\n    assert( iIdx>=0 && iIdx<p->pCsr->nField );\n    pMem = &p->aNew[iIdx];\n    if( pMem->flags==0 ){\n      if( iIdx==p->pTab->iPKey ){\n        sqlite3VdbeMemSetInt64(pMem, p->iKey2);\n      }else{\n        rc = sqlite3VdbeMemCopy(pMem, &p->v->aMem[p->iNewReg+1+iIdx]);\n        if( rc!=SQLITE_OK ) goto preupdate_new_out;\n      }\n    }\n  }\n  *ppValue = pMem;\n\n preupdate_new_out:\n  sqlite3Error(db, rc);\n  return sqlite3ApiExit(db, rc);\n}\n#endif /* SQLITE_ENABLE_PREUPDATE_HOOK */\n\n#ifdef SQLITE_ENABLE_STMT_SCANSTATUS\n/*\n** Return status data for a single loop within query pStmt.\n*/\nSQLITE_API int sqlite3_stmt_scanstatus(\n  sqlite3_stmt *pStmt,            /* Prepared statement being queried */\n  int idx,                        /* Index of loop to report on */\n  int iScanStatusOp,              /* Which metric to return */\n  void *pOut                      /* OUT: Write the answer here */\n){\n  Vdbe *p = (Vdbe*)pStmt;\n  ScanStatus *pScan;\n  if( idx<0 || idx>=p->nScan ) return 1;\n  pScan = &p->aScan[idx];\n  switch( iScanStatusOp ){\n    case SQLITE_SCANSTAT_NLOOP: {\n      *(sqlite3_int64*)pOut = p->anExec[pScan->addrLoop];\n      break;\n    }\n    case SQLITE_SCANSTAT_NVISIT: {\n      *(sqlite3_int64*)pOut = p->anExec[pScan->addrVisit];\n      break;\n    }\n    case SQLITE_SCANSTAT_EST: {\n      double r = 1.0;\n      LogEst x = pScan->nEst;\n      while( x<100 ){\n        x += 10;\n        r *= 0.5;\n      }\n      *(double*)pOut = r*sqlite3LogEstToInt(x);\n      break;\n    }\n    case SQLITE_SCANSTAT_NAME: {\n      *(const char**)pOut = pScan->zName;\n      break;\n    }\n    case SQLITE_SCANSTAT_EXPLAIN: {\n      if( pScan->addrExplain ){\n        *(const char**)pOut = p->aOp[ pScan->addrExplain ].p4.z;\n      }else{\n        *(const char**)pOut = 0;\n      }\n      break;\n    }\n    case SQLITE_SCANSTAT_SELECTID: {\n      if( pScan->addrExplain ){\n        *(int*)pOut = p->aOp[ pScan->addrExplain ].p1;\n      }else{\n        *(int*)pOut = -1;\n      }\n      break;\n    }\n    default: {\n      return 1;\n    }\n  }\n  return 0;\n}\n\n/*\n** Zero all counters associated with the sqlite3_stmt_scanstatus() data.\n*/\nSQLITE_API void sqlite3_stmt_scanstatus_reset(sqlite3_stmt *pStmt){\n  Vdbe *p = (Vdbe*)pStmt;\n  memset(p->anExec, 0, p->nOp * sizeof(i64));\n}\n#endif /* SQLITE_ENABLE_STMT_SCANSTATUS */\n\n/************** End of vdbeapi.c *********************************************/\n/************** Begin file vdbetrace.c ***************************************/\n/*\n** 2009 November 25\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n**\n** This file contains code used to insert the values of host parameters\n** (aka \"wildcards\") into the SQL text output by sqlite3_trace().\n**\n** The Vdbe parse-tree explainer is also found here.\n*/\n/* #include \"sqliteInt.h\" */\n/* #include \"vdbeInt.h\" */\n\n#ifndef SQLITE_OMIT_TRACE\n\n/*\n** zSql is a zero-terminated string of UTF-8 SQL text.  Return the number of\n** bytes in this text up to but excluding the first character in\n** a host parameter.  If the text contains no host parameters, return\n** the total number of bytes in the text.\n*/\nstatic int findNextHostParameter(const char *zSql, int *pnToken){\n  int tokenType;\n  int nTotal = 0;\n  int n;\n\n  *pnToken = 0;\n  while( zSql[0] ){\n    n = sqlite3GetToken((u8*)zSql, &tokenType);\n    assert( n>0 && tokenType!=TK_ILLEGAL );\n    if( tokenType==TK_VARIABLE ){\n      *pnToken = n;\n      break;\n    }\n    nTotal += n;\n    zSql += n;\n  }\n  return nTotal;\n}\n\n/*\n** This function returns a pointer to a nul-terminated string in memory\n** obtained from sqlite3DbMalloc(). If sqlite3.nVdbeExec is 1, then the\n** string contains a copy of zRawSql but with host parameters expanded to \n** their current bindings. Or, if sqlite3.nVdbeExec is greater than 1, \n** then the returned string holds a copy of zRawSql with \"-- \" prepended\n** to each line of text.\n**\n** If the SQLITE_TRACE_SIZE_LIMIT macro is defined to an integer, then\n** then long strings and blobs are truncated to that many bytes.  This\n** can be used to prevent unreasonably large trace strings when dealing\n** with large (multi-megabyte) strings and blobs.\n**\n** The calling function is responsible for making sure the memory returned\n** is eventually freed.\n**\n** ALGORITHM:  Scan the input string looking for host parameters in any of\n** these forms:  ?, ?N, $A, @A, :A.  Take care to avoid text within\n** string literals, quoted identifier names, and comments.  For text forms,\n** the host parameter index is found by scanning the prepared\n** statement for the corresponding OP_Variable opcode.  Once the host\n** parameter index is known, locate the value in p->aVar[].  Then render\n** the value as a literal in place of the host parameter name.\n*/\nSQLITE_PRIVATE char *sqlite3VdbeExpandSql(\n  Vdbe *p,                 /* The prepared statement being evaluated */\n  const char *zRawSql      /* Raw text of the SQL statement */\n){\n  sqlite3 *db;             /* The database connection */\n  int idx = 0;             /* Index of a host parameter */\n  int nextIndex = 1;       /* Index of next ? host parameter */\n  int n;                   /* Length of a token prefix */\n  int nToken;              /* Length of the parameter token */\n  int i;                   /* Loop counter */\n  Mem *pVar;               /* Value of a host parameter */\n  StrAccum out;            /* Accumulate the output here */\n#ifndef SQLITE_OMIT_UTF16\n  Mem utf8;                /* Used to convert UTF16 into UTF8 for display */\n#endif\n  char zBase[100];         /* Initial working space */\n\n  db = p->db;\n  sqlite3StrAccumInit(&out, 0, zBase, sizeof(zBase), \n                      db->aLimit[SQLITE_LIMIT_LENGTH]);\n  if( db->nVdbeExec>1 ){\n    while( *zRawSql ){\n      const char *zStart = zRawSql;\n      while( *(zRawSql++)!='\\n' && *zRawSql );\n      sqlite3_str_append(&out, \"-- \", 3);\n      assert( (zRawSql - zStart) > 0 );\n      sqlite3_str_append(&out, zStart, (int)(zRawSql-zStart));\n    }\n  }else if( p->nVar==0 ){\n    sqlite3_str_append(&out, zRawSql, sqlite3Strlen30(zRawSql));\n  }else{\n    while( zRawSql[0] ){\n      n = findNextHostParameter(zRawSql, &nToken);\n      assert( n>0 );\n      sqlite3_str_append(&out, zRawSql, n);\n      zRawSql += n;\n      assert( zRawSql[0] || nToken==0 );\n      if( nToken==0 ) break;\n      if( zRawSql[0]=='?' ){\n        if( nToken>1 ){\n          assert( sqlite3Isdigit(zRawSql[1]) );\n          sqlite3GetInt32(&zRawSql[1], &idx);\n        }else{\n          idx = nextIndex;\n        }\n      }else{\n        assert( zRawSql[0]==':' || zRawSql[0]=='$' ||\n                zRawSql[0]=='@' || zRawSql[0]=='#' );\n        testcase( zRawSql[0]==':' );\n        testcase( zRawSql[0]=='$' );\n        testcase( zRawSql[0]=='@' );\n        testcase( zRawSql[0]=='#' );\n        idx = sqlite3VdbeParameterIndex(p, zRawSql, nToken);\n        assert( idx>0 );\n      }\n      zRawSql += nToken;\n      nextIndex = idx + 1;\n      assert( idx>0 && idx<=p->nVar );\n      pVar = &p->aVar[idx-1];\n      if( pVar->flags & MEM_Null ){\n        sqlite3_str_append(&out, \"NULL\", 4);\n      }else if( pVar->flags & MEM_Int ){\n        sqlite3_str_appendf(&out, \"%lld\", pVar->u.i);\n      }else if( pVar->flags & MEM_Real ){\n        sqlite3_str_appendf(&out, \"%!.17g\", pVar->u.r);\n      }else if( pVar->flags & MEM_Str ){\n        int nOut;  /* Number of bytes of the string text to include in output */\n#ifndef SQLITE_OMIT_UTF16\n        u8 enc = ENC(db);\n        if( enc!=SQLITE_UTF8 ){\n          memset(&utf8, 0, sizeof(utf8));\n          utf8.db = db;\n          sqlite3VdbeMemSetStr(&utf8, pVar->z, pVar->n, enc, SQLITE_STATIC);\n          if( SQLITE_NOMEM==sqlite3VdbeChangeEncoding(&utf8, SQLITE_UTF8) ){\n            out.accError = SQLITE_NOMEM;\n            out.nAlloc = 0;\n          }\n          pVar = &utf8;\n        }\n#endif\n        nOut = pVar->n;\n#ifdef SQLITE_TRACE_SIZE_LIMIT\n        if( nOut>SQLITE_TRACE_SIZE_LIMIT ){\n          nOut = SQLITE_TRACE_SIZE_LIMIT;\n          while( nOut<pVar->n && (pVar->z[nOut]&0xc0)==0x80 ){ nOut++; }\n        }\n#endif    \n        sqlite3_str_appendf(&out, \"'%.*q'\", nOut, pVar->z);\n#ifdef SQLITE_TRACE_SIZE_LIMIT\n        if( nOut<pVar->n ){\n          sqlite3_str_appendf(&out, \"/*+%d bytes*/\", pVar->n-nOut);\n        }\n#endif\n#ifndef SQLITE_OMIT_UTF16\n        if( enc!=SQLITE_UTF8 ) sqlite3VdbeMemRelease(&utf8);\n#endif\n      }else if( pVar->flags & MEM_Zero ){\n        sqlite3_str_appendf(&out, \"zeroblob(%d)\", pVar->u.nZero);\n      }else{\n        int nOut;  /* Number of bytes of the blob to include in output */\n        assert( pVar->flags & MEM_Blob );\n        sqlite3_str_append(&out, \"x'\", 2);\n        nOut = pVar->n;\n#ifdef SQLITE_TRACE_SIZE_LIMIT\n        if( nOut>SQLITE_TRACE_SIZE_LIMIT ) nOut = SQLITE_TRACE_SIZE_LIMIT;\n#endif\n        for(i=0; i<nOut; i++){\n          sqlite3_str_appendf(&out, \"%02x\", pVar->z[i]&0xff);\n        }\n        sqlite3_str_append(&out, \"'\", 1);\n#ifdef SQLITE_TRACE_SIZE_LIMIT\n        if( nOut<pVar->n ){\n          sqlite3_str_appendf(&out, \"/*+%d bytes*/\", pVar->n-nOut);\n        }\n#endif\n      }\n    }\n  }\n  if( out.accError ) sqlite3_str_reset(&out);\n  return sqlite3StrAccumFinish(&out);\n}\n\n#endif /* #ifndef SQLITE_OMIT_TRACE */\n\n/************** End of vdbetrace.c *******************************************/\n/************** Begin file vdbe.c ********************************************/\n/*\n** 2001 September 15\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** The code in this file implements the function that runs the\n** bytecode of a prepared statement.\n**\n** Various scripts scan this source file in order to generate HTML\n** documentation, headers files, or other derived files.  The formatting\n** of the code in this file is, therefore, important.  See other comments\n** in this file for details.  If in doubt, do not deviate from existing\n** commenting and indentation practices when changing or adding code.\n*/\n/* #include \"sqliteInt.h\" */\n/* #include \"vdbeInt.h\" */\n\n/*\n** Invoke this macro on memory cells just prior to changing the\n** value of the cell.  This macro verifies that shallow copies are\n** not misused.  A shallow copy of a string or blob just copies a\n** pointer to the string or blob, not the content.  If the original\n** is changed while the copy is still in use, the string or blob might\n** be changed out from under the copy.  This macro verifies that nothing\n** like that ever happens.\n*/\n#ifdef SQLITE_DEBUG\n# define memAboutToChange(P,M) sqlite3VdbeMemAboutToChange(P,M)\n#else\n# define memAboutToChange(P,M)\n#endif\n\n/*\n** The following global variable is incremented every time a cursor\n** moves, either by the OP_SeekXX, OP_Next, or OP_Prev opcodes.  The test\n** procedures use this information to make sure that indices are\n** working correctly.  This variable has no function other than to\n** help verify the correct operation of the library.\n*/\n#ifdef SQLITE_TEST\nSQLITE_API int sqlite3_search_count = 0;\n#endif\n\n/*\n** When this global variable is positive, it gets decremented once before\n** each instruction in the VDBE.  When it reaches zero, the u1.isInterrupted\n** field of the sqlite3 structure is set in order to simulate an interrupt.\n**\n** This facility is used for testing purposes only.  It does not function\n** in an ordinary build.\n*/\n#ifdef SQLITE_TEST\nSQLITE_API int sqlite3_interrupt_count = 0;\n#endif\n\n/*\n** The next global variable is incremented each type the OP_Sort opcode\n** is executed.  The test procedures use this information to make sure that\n** sorting is occurring or not occurring at appropriate times.   This variable\n** has no function other than to help verify the correct operation of the\n** library.\n*/\n#ifdef SQLITE_TEST\nSQLITE_API int sqlite3_sort_count = 0;\n#endif\n\n/*\n** The next global variable records the size of the largest MEM_Blob\n** or MEM_Str that has been used by a VDBE opcode.  The test procedures\n** use this information to make sure that the zero-blob functionality\n** is working correctly.   This variable has no function other than to\n** help verify the correct operation of the library.\n*/\n#ifdef SQLITE_TEST\nSQLITE_API int sqlite3_max_blobsize = 0;\nstatic void updateMaxBlobsize(Mem *p){\n  if( (p->flags & (MEM_Str|MEM_Blob))!=0 && p->n>sqlite3_max_blobsize ){\n    sqlite3_max_blobsize = p->n;\n  }\n}\n#endif\n\n/*\n** This macro evaluates to true if either the update hook or the preupdate\n** hook are enabled for database connect DB.\n*/\n#ifdef SQLITE_ENABLE_PREUPDATE_HOOK\n# define HAS_UPDATE_HOOK(DB) ((DB)->xPreUpdateCallback||(DB)->xUpdateCallback)\n#else\n# define HAS_UPDATE_HOOK(DB) ((DB)->xUpdateCallback)\n#endif\n\n/*\n** The next global variable is incremented each time the OP_Found opcode\n** is executed. This is used to test whether or not the foreign key\n** operation implemented using OP_FkIsZero is working. This variable\n** has no function other than to help verify the correct operation of the\n** library.\n*/\n#ifdef SQLITE_TEST\nSQLITE_API int sqlite3_found_count = 0;\n#endif\n\n/*\n** Test a register to see if it exceeds the current maximum blob size.\n** If it does, record the new maximum blob size.\n*/\n#if defined(SQLITE_TEST) && !defined(SQLITE_UNTESTABLE)\n# define UPDATE_MAX_BLOBSIZE(P)  updateMaxBlobsize(P)\n#else\n# define UPDATE_MAX_BLOBSIZE(P)\n#endif\n\n/*\n** Invoke the VDBE coverage callback, if that callback is defined.  This\n** feature is used for test suite validation only and does not appear an\n** production builds.\n**\n** M is an integer between 2 and 4.  2 indicates a ordinary two-way\n** branch (I=0 means fall through and I=1 means taken).  3 indicates\n** a 3-way branch where the third way is when one of the operands is\n** NULL.  4 indicates the OP_Jump instruction which has three destinations\n** depending on whether the first operand is less than, equal to, or greater\n** than the second. \n**\n** iSrcLine is the source code line (from the __LINE__ macro) that\n** generated the VDBE instruction combined with flag bits.  The source\n** code line number is in the lower 24 bits of iSrcLine and the upper\n** 8 bytes are flags.  The lower three bits of the flags indicate\n** values for I that should never occur.  For example, if the branch is\n** always taken, the flags should be 0x05 since the fall-through and\n** alternate branch are never taken.  If a branch is never taken then\n** flags should be 0x06 since only the fall-through approach is allowed.\n**\n** Bit 0x04 of the flags indicates an OP_Jump opcode that is only\n** interested in equal or not-equal.  In other words, I==0 and I==2\n** should be treated the same.\n**\n** Since only a line number is retained, not the filename, this macro\n** only works for amalgamation builds.  But that is ok, since these macros\n** should be no-ops except for special builds used to measure test coverage.\n*/\n#if !defined(SQLITE_VDBE_COVERAGE)\n# define VdbeBranchTaken(I,M)\n#else\n# define VdbeBranchTaken(I,M) vdbeTakeBranch(pOp->iSrcLine,I,M)\n  static void vdbeTakeBranch(u32 iSrcLine, u8 I, u8 M){\n    u8 mNever;\n    assert( I<=2 );  /* 0: fall through,  1: taken,  2: alternate taken */\n    assert( M<=4 );  /* 2: two-way branch, 3: three-way branch, 4: OP_Jump */\n    assert( I<M );   /* I can only be 2 if M is 3 or 4 */\n    /* Transform I from a integer [0,1,2] into a bitmask of [1,2,4] */\n    I = 1<<I;\n    /* The upper 8 bits of iSrcLine are flags.  The lower three bits of\n    ** the flags indicate directions that the branch can never go.  If\n    ** a branch really does go in one of those directions, assert right\n    ** away. */\n    mNever = iSrcLine >> 24;\n    assert( (I & mNever)==0 );\n    if( sqlite3GlobalConfig.xVdbeBranch==0 ) return;  /*NO_TEST*/\n    I |= mNever;\n    if( M==2 ) I |= 0x04;\n    if( M==4 ){\n      I |= 0x08;\n      if( (mNever&0x08)!=0 && (I&0x05)!=0) I |= 0x05; /*NO_TEST*/\n    }\n    sqlite3GlobalConfig.xVdbeBranch(sqlite3GlobalConfig.pVdbeBranchArg,\n                                    iSrcLine&0xffffff, I, M);\n  }\n#endif\n\n/*\n** Convert the given register into a string if it isn't one\n** already. Return non-zero if a malloc() fails.\n*/\n#define Stringify(P, enc) \\\n   if(((P)->flags&(MEM_Str|MEM_Blob))==0 && sqlite3VdbeMemStringify(P,enc,0)) \\\n     { goto no_mem; }\n\n/*\n** An ephemeral string value (signified by the MEM_Ephem flag) contains\n** a pointer to a dynamically allocated string where some other entity\n** is responsible for deallocating that string.  Because the register\n** does not control the string, it might be deleted without the register\n** knowing it.\n**\n** This routine converts an ephemeral string into a dynamically allocated\n** string that the register itself controls.  In other words, it\n** converts an MEM_Ephem string into a string with P.z==P.zMalloc.\n*/\n#define Deephemeralize(P) \\\n   if( ((P)->flags&MEM_Ephem)!=0 \\\n       && sqlite3VdbeMemMakeWriteable(P) ){ goto no_mem;}\n\n/* Return true if the cursor was opened using the OP_OpenSorter opcode. */\n#define isSorter(x) ((x)->eCurType==CURTYPE_SORTER)\n\n/*\n** Allocate VdbeCursor number iCur.  Return a pointer to it.  Return NULL\n** if we run out of memory.\n*/\nstatic VdbeCursor *allocateCursor(\n  Vdbe *p,              /* The virtual machine */\n  int iCur,             /* Index of the new VdbeCursor */\n  int nField,           /* Number of fields in the table or index */\n  int iDb,              /* Database the cursor belongs to, or -1 */\n  u8 eCurType           /* Type of the new cursor */\n){\n  /* Find the memory cell that will be used to store the blob of memory\n  ** required for this VdbeCursor structure. It is convenient to use a \n  ** vdbe memory cell to manage the memory allocation required for a\n  ** VdbeCursor structure for the following reasons:\n  **\n  **   * Sometimes cursor numbers are used for a couple of different\n  **     purposes in a vdbe program. The different uses might require\n  **     different sized allocations. Memory cells provide growable\n  **     allocations.\n  **\n  **   * When using ENABLE_MEMORY_MANAGEMENT, memory cell buffers can\n  **     be freed lazily via the sqlite3_release_memory() API. This\n  **     minimizes the number of malloc calls made by the system.\n  **\n  ** The memory cell for cursor 0 is aMem[0]. The rest are allocated from\n  ** the top of the register space.  Cursor 1 is at Mem[p->nMem-1].\n  ** Cursor 2 is at Mem[p->nMem-2]. And so forth.\n  */\n  Mem *pMem = iCur>0 ? &p->aMem[p->nMem-iCur] : p->aMem;\n\n  int nByte;\n  VdbeCursor *pCx = 0;\n  nByte = \n      ROUND8(sizeof(VdbeCursor)) + 2*sizeof(u32)*nField + \n      (eCurType==CURTYPE_BTREE?sqlite3BtreeCursorSize():0);\n\n  assert( iCur>=0 && iCur<p->nCursor );\n  if( p->apCsr[iCur] ){ /*OPTIMIZATION-IF-FALSE*/\n    /* Before calling sqlite3VdbeFreeCursor(), ensure the isEphemeral flag\n    ** is clear. Otherwise, if this is an ephemeral cursor created by \n    ** OP_OpenDup, the cursor will not be closed and will still be part\n    ** of a BtShared.pCursor list.  */\n    p->apCsr[iCur]->isEphemeral = 0;\n    sqlite3VdbeFreeCursor(p, p->apCsr[iCur]);\n    p->apCsr[iCur] = 0;\n  }\n  if( SQLITE_OK==sqlite3VdbeMemClearAndResize(pMem, nByte) ){\n    p->apCsr[iCur] = pCx = (VdbeCursor*)pMem->z;\n    memset(pCx, 0, offsetof(VdbeCursor,pAltCursor));\n    pCx->eCurType = eCurType;\n    pCx->iDb = iDb;\n    pCx->nField = nField;\n    pCx->aOffset = &pCx->aType[nField];\n    if( eCurType==CURTYPE_BTREE ){\n      pCx->uc.pCursor = (BtCursor*)\n          &pMem->z[ROUND8(sizeof(VdbeCursor))+2*sizeof(u32)*nField];\n      sqlite3BtreeCursorZero(pCx->uc.pCursor);\n    }\n  }\n  return pCx;\n}\n\n/*\n** Try to convert a value into a numeric representation if we can\n** do so without loss of information.  In other words, if the string\n** looks like a number, convert it into a number.  If it does not\n** look like a number, leave it alone.\n**\n** If the bTryForInt flag is true, then extra effort is made to give\n** an integer representation.  Strings that look like floating point\n** values but which have no fractional component (example: '48.00')\n** will have a MEM_Int representation when bTryForInt is true.\n**\n** If bTryForInt is false, then if the input string contains a decimal\n** point or exponential notation, the result is only MEM_Real, even\n** if there is an exact integer representation of the quantity.\n*/\nstatic void applyNumericAffinity(Mem *pRec, int bTryForInt){\n  double rValue;\n  i64 iValue;\n  u8 enc = pRec->enc;\n  assert( (pRec->flags & (MEM_Str|MEM_Int|MEM_Real))==MEM_Str );\n  if( sqlite3AtoF(pRec->z, &rValue, pRec->n, enc)==0 ) return;\n  if( 0==sqlite3Atoi64(pRec->z, &iValue, pRec->n, enc) ){\n    pRec->u.i = iValue;\n    pRec->flags |= MEM_Int;\n  }else{\n    pRec->u.r = rValue;\n    pRec->flags |= MEM_Real;\n    if( bTryForInt ) sqlite3VdbeIntegerAffinity(pRec);\n  }\n  /* TEXT->NUMERIC is many->one.  Hence, it is important to invalidate the\n  ** string representation after computing a numeric equivalent, because the\n  ** string representation might not be the canonical representation for the\n  ** numeric value.  Ticket [343634942dd54ab57b7024] 2018-01-31. */\n  pRec->flags &= ~MEM_Str;\n}\n\n/*\n** Processing is determine by the affinity parameter:\n**\n** SQLITE_AFF_INTEGER:\n** SQLITE_AFF_REAL:\n** SQLITE_AFF_NUMERIC:\n**    Try to convert pRec to an integer representation or a \n**    floating-point representation if an integer representation\n**    is not possible.  Note that the integer representation is\n**    always preferred, even if the affinity is REAL, because\n**    an integer representation is more space efficient on disk.\n**\n** SQLITE_AFF_TEXT:\n**    Convert pRec to a text representation.\n**\n** SQLITE_AFF_BLOB:\n**    No-op.  pRec is unchanged.\n*/\nstatic void applyAffinity(\n  Mem *pRec,          /* The value to apply affinity to */\n  char affinity,      /* The affinity to be applied */\n  u8 enc              /* Use this text encoding */\n){\n  if( affinity>=SQLITE_AFF_NUMERIC ){\n    assert( affinity==SQLITE_AFF_INTEGER || affinity==SQLITE_AFF_REAL\n             || affinity==SQLITE_AFF_NUMERIC );\n    if( (pRec->flags & MEM_Int)==0 ){ /*OPTIMIZATION-IF-FALSE*/\n      if( (pRec->flags & MEM_Real)==0 ){\n        if( pRec->flags & MEM_Str ) applyNumericAffinity(pRec,1);\n      }else{\n        sqlite3VdbeIntegerAffinity(pRec);\n      }\n    }\n  }else if( affinity==SQLITE_AFF_TEXT ){\n    /* Only attempt the conversion to TEXT if there is an integer or real\n    ** representation (blob and NULL do not get converted) but no string\n    ** representation.  It would be harmless to repeat the conversion if \n    ** there is already a string rep, but it is pointless to waste those\n    ** CPU cycles. */\n    if( 0==(pRec->flags&MEM_Str) ){ /*OPTIMIZATION-IF-FALSE*/\n      if( (pRec->flags&(MEM_Real|MEM_Int)) ){\n        sqlite3VdbeMemStringify(pRec, enc, 1);\n      }\n    }\n    pRec->flags &= ~(MEM_Real|MEM_Int);\n  }\n}\n\n/*\n** Try to convert the type of a function argument or a result column\n** into a numeric representation.  Use either INTEGER or REAL whichever\n** is appropriate.  But only do the conversion if it is possible without\n** loss of information and return the revised type of the argument.\n*/\nSQLITE_API int sqlite3_value_numeric_type(sqlite3_value *pVal){\n  int eType = sqlite3_value_type(pVal);\n  if( eType==SQLITE_TEXT ){\n    Mem *pMem = (Mem*)pVal;\n    applyNumericAffinity(pMem, 0);\n    eType = sqlite3_value_type(pVal);\n  }\n  return eType;\n}\n\n/*\n** Exported version of applyAffinity(). This one works on sqlite3_value*, \n** not the internal Mem* type.\n*/\nSQLITE_PRIVATE void sqlite3ValueApplyAffinity(\n  sqlite3_value *pVal, \n  u8 affinity, \n  u8 enc\n){\n  applyAffinity((Mem *)pVal, affinity, enc);\n}\n\n/*\n** pMem currently only holds a string type (or maybe a BLOB that we can\n** interpret as a string if we want to).  Compute its corresponding\n** numeric type, if has one.  Set the pMem->u.r and pMem->u.i fields\n** accordingly.\n*/\nstatic u16 SQLITE_NOINLINE computeNumericType(Mem *pMem){\n  assert( (pMem->flags & (MEM_Int|MEM_Real))==0 );\n  assert( (pMem->flags & (MEM_Str|MEM_Blob))!=0 );\n  ExpandBlob(pMem);\n  if( sqlite3AtoF(pMem->z, &pMem->u.r, pMem->n, pMem->enc)==0 ){\n    return 0;\n  }\n  if( sqlite3Atoi64(pMem->z, &pMem->u.i, pMem->n, pMem->enc)==0 ){\n    return MEM_Int;\n  }\n  return MEM_Real;\n}\n\n/*\n** Return the numeric type for pMem, either MEM_Int or MEM_Real or both or\n** none.  \n**\n** Unlike applyNumericAffinity(), this routine does not modify pMem->flags.\n** But it does set pMem->u.r and pMem->u.i appropriately.\n*/\nstatic u16 numericType(Mem *pMem){\n  if( pMem->flags & (MEM_Int|MEM_Real) ){\n    return pMem->flags & (MEM_Int|MEM_Real);\n  }\n  if( pMem->flags & (MEM_Str|MEM_Blob) ){\n    return computeNumericType(pMem);\n  }\n  return 0;\n}\n\n#ifdef SQLITE_DEBUG\n/*\n** Write a nice string representation of the contents of cell pMem\n** into buffer zBuf, length nBuf.\n*/\nSQLITE_PRIVATE void sqlite3VdbeMemPrettyPrint(Mem *pMem, char *zBuf){\n  char *zCsr = zBuf;\n  int f = pMem->flags;\n\n  static const char *const encnames[] = {\"(X)\", \"(8)\", \"(16LE)\", \"(16BE)\"};\n\n  if( f&MEM_Blob ){\n    int i;\n    char c;\n    if( f & MEM_Dyn ){\n      c = 'z';\n      assert( (f & (MEM_Static|MEM_Ephem))==0 );\n    }else if( f & MEM_Static ){\n      c = 't';\n      assert( (f & (MEM_Dyn|MEM_Ephem))==0 );\n    }else if( f & MEM_Ephem ){\n      c = 'e';\n      assert( (f & (MEM_Static|MEM_Dyn))==0 );\n    }else{\n      c = 's';\n    }\n    *(zCsr++) = c;\n    sqlite3_snprintf(100, zCsr, \"%d[\", pMem->n);\n    zCsr += sqlite3Strlen30(zCsr);\n    for(i=0; i<16 && i<pMem->n; i++){\n      sqlite3_snprintf(100, zCsr, \"%02X\", ((int)pMem->z[i] & 0xFF));\n      zCsr += sqlite3Strlen30(zCsr);\n    }\n    for(i=0; i<16 && i<pMem->n; i++){\n      char z = pMem->z[i];\n      if( z<32 || z>126 ) *zCsr++ = '.';\n      else *zCsr++ = z;\n    }\n    *(zCsr++) = ']';\n    if( f & MEM_Zero ){\n      sqlite3_snprintf(100, zCsr,\"+%dz\",pMem->u.nZero);\n      zCsr += sqlite3Strlen30(zCsr);\n    }\n    *zCsr = '\\0';\n  }else if( f & MEM_Str ){\n    int j, k;\n    zBuf[0] = ' ';\n    if( f & MEM_Dyn ){\n      zBuf[1] = 'z';\n      assert( (f & (MEM_Static|MEM_Ephem))==0 );\n    }else if( f & MEM_Static ){\n      zBuf[1] = 't';\n      assert( (f & (MEM_Dyn|MEM_Ephem))==0 );\n    }else if( f & MEM_Ephem ){\n      zBuf[1] = 'e';\n      assert( (f & (MEM_Static|MEM_Dyn))==0 );\n    }else{\n      zBuf[1] = 's';\n    }\n    k = 2;\n    sqlite3_snprintf(100, &zBuf[k], \"%d\", pMem->n);\n    k += sqlite3Strlen30(&zBuf[k]);\n    zBuf[k++] = '[';\n    for(j=0; j<15 && j<pMem->n; j++){\n      u8 c = pMem->z[j];\n      if( c>=0x20 && c<0x7f ){\n        zBuf[k++] = c;\n      }else{\n        zBuf[k++] = '.';\n      }\n    }\n    zBuf[k++] = ']';\n    sqlite3_snprintf(100,&zBuf[k], encnames[pMem->enc]);\n    k += sqlite3Strlen30(&zBuf[k]);\n    zBuf[k++] = 0;\n  }\n}\n#endif\n\n#ifdef SQLITE_DEBUG\n/*\n** Print the value of a register for tracing purposes:\n*/\nstatic void memTracePrint(Mem *p){\n  if( p->flags & MEM_Undefined ){\n    printf(\" undefined\");\n  }else if( p->flags & MEM_Null ){\n    printf(p->flags & MEM_Zero ? \" NULL-nochng\" : \" NULL\");\n  }else if( (p->flags & (MEM_Int|MEM_Str))==(MEM_Int|MEM_Str) ){\n    printf(\" si:%lld\", p->u.i);\n  }else if( p->flags & MEM_Int ){\n    printf(\" i:%lld\", p->u.i);\n#ifndef SQLITE_OMIT_FLOATING_POINT\n  }else if( p->flags & MEM_Real ){\n    printf(\" r:%g\", p->u.r);\n#endif\n  }else if( sqlite3VdbeMemIsRowSet(p) ){\n    printf(\" (rowset)\");\n  }else{\n    char zBuf[200];\n    sqlite3VdbeMemPrettyPrint(p, zBuf);\n    printf(\" %s\", zBuf);\n  }\n  if( p->flags & MEM_Subtype ) printf(\" subtype=0x%02x\", p->eSubtype);\n}\nstatic void registerTrace(int iReg, Mem *p){\n  printf(\"REG[%d] = \", iReg);\n  memTracePrint(p);\n  printf(\"\\n\");\n  sqlite3VdbeCheckMemInvariants(p);\n}\n#endif\n\n#ifdef SQLITE_DEBUG\n#  define REGISTER_TRACE(R,M) if(db->flags&SQLITE_VdbeTrace)registerTrace(R,M)\n#else\n#  define REGISTER_TRACE(R,M)\n#endif\n\n\n#ifdef VDBE_PROFILE\n\n/* \n** hwtime.h contains inline assembler code for implementing \n** high-performance timing routines.\n*/\n/************** Include hwtime.h in the middle of vdbe.c *********************/\n/************** Begin file hwtime.h ******************************************/\n/*\n** 2008 May 27\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n******************************************************************************\n**\n** This file contains inline asm code for retrieving \"high-performance\"\n** counters for x86 class CPUs.\n*/\n#ifndef SQLITE_HWTIME_H\n#define SQLITE_HWTIME_H\n\n/*\n** The following routine only works on pentium-class (or newer) processors.\n** It uses the RDTSC opcode to read the cycle count value out of the\n** processor and returns that value.  This can be used for high-res\n** profiling.\n*/\n#if (defined(__GNUC__) || defined(_MSC_VER)) && \\\n      (defined(i386) || defined(__i386__) || defined(_M_IX86))\n\n  #if defined(__GNUC__)\n\n  __inline__ sqlite_uint64 sqlite3Hwtime(void){\n     unsigned int lo, hi;\n     __asm__ __volatile__ (\"rdtsc\" : \"=a\" (lo), \"=d\" (hi));\n     return (sqlite_uint64)hi << 32 | lo;\n  }\n\n  #elif defined(_MSC_VER)\n\n  __declspec(naked) __inline sqlite_uint64 __cdecl sqlite3Hwtime(void){\n     __asm {\n        rdtsc\n        ret       ; return value at EDX:EAX\n     }\n  }\n\n  #endif\n\n#elif (defined(__GNUC__) && defined(__x86_64__))\n\n  __inline__ sqlite_uint64 sqlite3Hwtime(void){\n      unsigned long val;\n      __asm__ __volatile__ (\"rdtsc\" : \"=A\" (val));\n      return val;\n  }\n \n#elif (defined(__GNUC__) && defined(__ppc__))\n\n  __inline__ sqlite_uint64 sqlite3Hwtime(void){\n      unsigned long long retval;\n      unsigned long junk;\n      __asm__ __volatile__ (\"\\n\\\n          1:      mftbu   %1\\n\\\n                  mftb    %L0\\n\\\n                  mftbu   %0\\n\\\n                  cmpw    %0,%1\\n\\\n                  bne     1b\"\n                  : \"=r\" (retval), \"=r\" (junk));\n      return retval;\n  }\n\n#else\n\n  #error Need implementation of sqlite3Hwtime() for your platform.\n\n  /*\n  ** To compile without implementing sqlite3Hwtime() for your platform,\n  ** you can remove the above #error and use the following\n  ** stub function.  You will lose timing support for many\n  ** of the debugging and testing utilities, but it should at\n  ** least compile and run.\n  */\nSQLITE_PRIVATE   sqlite_uint64 sqlite3Hwtime(void){ return ((sqlite_uint64)0); }\n\n#endif\n\n#endif /* !defined(SQLITE_HWTIME_H) */\n\n/************** End of hwtime.h **********************************************/\n/************** Continuing where we left off in vdbe.c ***********************/\n\n#endif\n\n#ifndef NDEBUG\n/*\n** This function is only called from within an assert() expression. It\n** checks that the sqlite3.nTransaction variable is correctly set to\n** the number of non-transaction savepoints currently in the \n** linked list starting at sqlite3.pSavepoint.\n** \n** Usage:\n**\n**     assert( checkSavepointCount(db) );\n*/\nstatic int checkSavepointCount(sqlite3 *db){\n  int n = 0;\n  Savepoint *p;\n  for(p=db->pSavepoint; p; p=p->pNext) n++;\n  assert( n==(db->nSavepoint + db->isTransactionSavepoint) );\n  return 1;\n}\n#endif\n\n/*\n** Return the register of pOp->p2 after first preparing it to be\n** overwritten with an integer value.\n*/\nstatic SQLITE_NOINLINE Mem *out2PrereleaseWithClear(Mem *pOut){\n  sqlite3VdbeMemSetNull(pOut);\n  pOut->flags = MEM_Int;\n  return pOut;\n}\nstatic Mem *out2Prerelease(Vdbe *p, VdbeOp *pOp){\n  Mem *pOut;\n  assert( pOp->p2>0 );\n  assert( pOp->p2<=(p->nMem+1 - p->nCursor) );\n  pOut = &p->aMem[pOp->p2];\n  memAboutToChange(p, pOut);\n  if( VdbeMemDynamic(pOut) ){ /*OPTIMIZATION-IF-FALSE*/\n    return out2PrereleaseWithClear(pOut);\n  }else{\n    pOut->flags = MEM_Int;\n    return pOut;\n  }\n}\n\n\n/*\n** Execute as much of a VDBE program as we can.\n** This is the core of sqlite3_step().  \n*/\nSQLITE_PRIVATE int sqlite3VdbeExec(\n  Vdbe *p                    /* The VDBE */\n){\n  Op *aOp = p->aOp;          /* Copy of p->aOp */\n  Op *pOp = aOp;             /* Current operation */\n#if defined(SQLITE_DEBUG) || defined(VDBE_PROFILE)\n  Op *pOrigOp;               /* Value of pOp at the top of the loop */\n#endif\n#ifdef SQLITE_DEBUG\n  int nExtraDelete = 0;      /* Verifies FORDELETE and AUXDELETE flags */\n#endif\n  int rc = SQLITE_OK;        /* Value to return */\n  sqlite3 *db = p->db;       /* The database */\n  u8 resetSchemaOnFault = 0; /* Reset schema after an error if positive */\n  u8 encoding = ENC(db);     /* The database encoding */\n  int iCompare = 0;          /* Result of last comparison */\n  unsigned nVmStep = 0;      /* Number of virtual machine steps */\n#ifndef SQLITE_OMIT_PROGRESS_CALLBACK\n  unsigned nProgressLimit;   /* Invoke xProgress() when nVmStep reaches this */\n#endif\n  Mem *aMem = p->aMem;       /* Copy of p->aMem */\n  Mem *pIn1 = 0;             /* 1st input operand */\n  Mem *pIn2 = 0;             /* 2nd input operand */\n  Mem *pIn3 = 0;             /* 3rd input operand */\n  Mem *pOut = 0;             /* Output operand */\n#ifdef VDBE_PROFILE\n  u64 start;                 /* CPU clock count at start of opcode */\n#endif\n  /*** INSERT STACK UNION HERE ***/\n\n  assert( p->magic==VDBE_MAGIC_RUN );  /* sqlite3_step() verifies this */\n  sqlite3VdbeEnter(p);\n  if( p->rc==SQLITE_NOMEM ){\n    /* This happens if a malloc() inside a call to sqlite3_column_text() or\n    ** sqlite3_column_text16() failed.  */\n    goto no_mem;\n  }\n  assert( p->rc==SQLITE_OK || (p->rc&0xff)==SQLITE_BUSY );\n  assert( p->bIsReader || p->readOnly!=0 );\n  p->iCurrentTime = 0;\n  assert( p->explain==0 );\n  p->pResultSet = 0;\n  db->busyHandler.nBusy = 0;\n  if( (db->u1.isInterrupted || db->suspended) && !db->unimpeded ) goto abort_due_to_interrupt;\n  sqlite3VdbeIOTraceSql(p);\n#ifndef SQLITE_OMIT_PROGRESS_CALLBACK\n  if( db->xProgress ){\n    u32 iPrior = p->aCounter[SQLITE_STMTSTATUS_VM_STEP];\n    assert( 0 < db->nProgressOps );\n    nProgressLimit = db->nProgressOps - (iPrior % db->nProgressOps);\n  }else{\n    nProgressLimit = 0xffffffff;\n  }\n#endif\n#ifdef SQLITE_DEBUG\n  sqlite3BeginBenignMalloc();\n  if( p->pc==0\n   && (p->db->flags & (SQLITE_VdbeListing|SQLITE_VdbeEQP|SQLITE_VdbeTrace))!=0\n  ){\n    int i;\n    int once = 1;\n    sqlite3VdbePrintSql(p);\n    if( p->db->flags & SQLITE_VdbeListing ){\n      printf(\"VDBE Program Listing:\\n\");\n      for(i=0; i<p->nOp; i++){\n        sqlite3VdbePrintOp(stdout, i, &aOp[i]);\n      }\n    }\n    if( p->db->flags & SQLITE_VdbeEQP ){\n      for(i=0; i<p->nOp; i++){\n        if( aOp[i].opcode==OP_Explain ){\n          if( once ) printf(\"VDBE Query Plan:\\n\");\n          printf(\"%s\\n\", aOp[i].p4.z);\n          once = 0;\n        }\n      }\n    }\n    if( p->db->flags & SQLITE_VdbeTrace )  printf(\"VDBE Trace:\\n\");\n  }\n  sqlite3EndBenignMalloc();\n#endif\n  for(pOp=&aOp[p->pc]; 1; pOp++){\n    /* Errors are detected by individual opcodes, with an immediate\n    ** jumps to abort_due_to_error. */\n    assert( rc==SQLITE_OK );\n\n    assert( pOp>=aOp && pOp<&aOp[p->nOp]);\n#ifdef VDBE_PROFILE\n    start = sqlite3NProfileCnt ? sqlite3NProfileCnt : sqlite3Hwtime();\n#endif\n    nVmStep++;\n#ifdef SQLITE_ENABLE_STMT_SCANSTATUS\n    if( p->anExec ) p->anExec[(int)(pOp-aOp)]++;\n#endif\n\n    /* Only allow tracing if SQLITE_DEBUG is defined.\n    */\n#ifdef SQLITE_DEBUG\n    if( db->flags & SQLITE_VdbeTrace ){\n      sqlite3VdbePrintOp(stdout, (int)(pOp - aOp), pOp);\n    }\n#endif\n      \n\n    /* Check to see if we need to simulate an interrupt.  This only happens\n    ** if we have a special test build.\n    */\n#ifdef SQLITE_TEST\n    if( sqlite3_interrupt_count>0 ){\n      sqlite3_interrupt_count--;\n      if( sqlite3_interrupt_count==0 ){\n        sqlite3_interrupt(db);\n      }\n    }\n#endif\n\n    /* Sanity checking on other operands */\n#ifdef SQLITE_DEBUG\n    {\n      u8 opProperty = sqlite3OpcodeProperty[pOp->opcode];\n      if( (opProperty & OPFLG_IN1)!=0 ){\n        assert( pOp->p1>0 );\n        assert( pOp->p1<=(p->nMem+1 - p->nCursor) );\n        assert( memIsValid(&aMem[pOp->p1]) );\n        assert( sqlite3VdbeCheckMemInvariants(&aMem[pOp->p1]) );\n        REGISTER_TRACE(pOp->p1, &aMem[pOp->p1]);\n      }\n      if( (opProperty & OPFLG_IN2)!=0 ){\n        assert( pOp->p2>0 );\n        assert( pOp->p2<=(p->nMem+1 - p->nCursor) );\n        assert( memIsValid(&aMem[pOp->p2]) );\n        assert( sqlite3VdbeCheckMemInvariants(&aMem[pOp->p2]) );\n        REGISTER_TRACE(pOp->p2, &aMem[pOp->p2]);\n      }\n      if( (opProperty & OPFLG_IN3)!=0 ){\n        assert( pOp->p3>0 );\n        assert( pOp->p3<=(p->nMem+1 - p->nCursor) );\n        assert( memIsValid(&aMem[pOp->p3]) );\n        assert( sqlite3VdbeCheckMemInvariants(&aMem[pOp->p3]) );\n        REGISTER_TRACE(pOp->p3, &aMem[pOp->p3]);\n      }\n      if( (opProperty & OPFLG_OUT2)!=0 ){\n        assert( pOp->p2>0 );\n        assert( pOp->p2<=(p->nMem+1 - p->nCursor) );\n        memAboutToChange(p, &aMem[pOp->p2]);\n      }\n      if( (opProperty & OPFLG_OUT3)!=0 ){\n        assert( pOp->p3>0 );\n        assert( pOp->p3<=(p->nMem+1 - p->nCursor) );\n        memAboutToChange(p, &aMem[pOp->p3]);\n      }\n    }\n#endif\n#if defined(SQLITE_DEBUG) || defined(VDBE_PROFILE)\n    pOrigOp = pOp;\n#endif\n  \n    switch( pOp->opcode ){\n\n/*****************************************************************************\n** What follows is a massive switch statement where each case implements a\n** separate instruction in the virtual machine.  If we follow the usual\n** indentation conventions, each case should be indented by 6 spaces.  But\n** that is a lot of wasted space on the left margin.  So the code within\n** the switch statement will break with convention and be flush-left. Another\n** big comment (similar to this one) will mark the point in the code where\n** we transition back to normal indentation.\n**\n** The formatting of each case is important.  The makefile for SQLite\n** generates two C files \"opcodes.h\" and \"opcodes.c\" by scanning this\n** file looking for lines that begin with \"case OP_\".  The opcodes.h files\n** will be filled with #defines that give unique integer values to each\n** opcode and the opcodes.c file is filled with an array of strings where\n** each string is the symbolic name for the corresponding opcode.  If the\n** case statement is followed by a comment of the form \"/# same as ... #/\"\n** that comment is used to determine the particular value of the opcode.\n**\n** Other keywords in the comment that follows each case are used to\n** construct the OPFLG_INITIALIZER value that initializes opcodeProperty[].\n** Keywords include: in1, in2, in3, out2, out3.  See\n** the mkopcodeh.awk script for additional information.\n**\n** Documentation about VDBE opcodes is generated by scanning this file\n** for lines of that contain \"Opcode:\".  That line and all subsequent\n** comment lines are used in the generation of the opcode.html documentation\n** file.\n**\n** SUMMARY:\n**\n**     Formatting is important to scripts that scan this file.\n**     Do not deviate from the formatting style currently in use.\n**\n*****************************************************************************/\n\n/* Opcode:  Goto * P2 * * *\n**\n** An unconditional jump to address P2.\n** The next instruction executed will be \n** the one at index P2 from the beginning of\n** the program.\n**\n** The P1 parameter is not actually used by this opcode.  However, it\n** is sometimes set to 1 instead of 0 as a hint to the command-line shell\n** that this Goto is the bottom of a loop and that the lines from P2 down\n** to the current line should be indented for EXPLAIN output.\n*/\ncase OP_Goto: {             /* jump */\njump_to_p2_and_check_for_interrupt:\n  pOp = &aOp[pOp->p2 - 1];\n\n  /* Opcodes that are used as the bottom of a loop (OP_Next, OP_Prev,\n  ** OP_VNext, or OP_SorterNext) all jump here upon\n  ** completion.  Check to see if sqlite3_interrupt() has been called\n  ** or if the progress callback needs to be invoked. \n  **\n  ** This code uses unstructured \"goto\" statements and does not look clean.\n  ** But that is not due to sloppy coding habits. The code is written this\n  ** way for performance, to avoid having to run the interrupt and progress\n  ** checks on every opcode.  This helps sqlite3_step() to run about 1.5%\n  ** faster according to \"valgrind --tool=cachegrind\" */\ncheck_for_interrupt:\n  if( (db->u1.isInterrupted || db->suspended) && !db->unimpeded ) goto abort_due_to_interrupt;\n#ifndef SQLITE_OMIT_PROGRESS_CALLBACK\n  /* Call the progress callback if it is configured and the required number\n  ** of VDBE ops have been executed (either since this invocation of\n  ** sqlite3VdbeExec() or since last time the progress callback was called).\n  ** If the progress callback returns non-zero, exit the virtual machine with\n  ** a return code SQLITE_ABORT.\n  */\n  if( nVmStep>=nProgressLimit && db->xProgress!=0 ){\n    assert( db->nProgressOps!=0 );\n    nProgressLimit = nVmStep + db->nProgressOps - (nVmStep%db->nProgressOps);\n    if( db->xProgress(db->pProgressArg) ){\n      rc = SQLITE_INTERRUPT;\n      goto abort_due_to_error;\n    }\n  }\n#endif\n  \n  break;\n}\n\n/* Opcode:  Gosub P1 P2 * * *\n**\n** Write the current address onto register P1\n** and then jump to address P2.\n*/\ncase OP_Gosub: {            /* jump */\n  assert( pOp->p1>0 && pOp->p1<=(p->nMem+1 - p->nCursor) );\n  pIn1 = &aMem[pOp->p1];\n  assert( VdbeMemDynamic(pIn1)==0 );\n  memAboutToChange(p, pIn1);\n  pIn1->flags = MEM_Int;\n  pIn1->u.i = (int)(pOp-aOp);\n  REGISTER_TRACE(pOp->p1, pIn1);\n\n  /* Most jump operations do a goto to this spot in order to update\n  ** the pOp pointer. */\njump_to_p2:\n  pOp = &aOp[pOp->p2 - 1];\n  break;\n}\n\n/* Opcode:  Return P1 * * * *\n**\n** Jump to the next instruction after the address in register P1.  After\n** the jump, register P1 becomes undefined.\n*/\ncase OP_Return: {           /* in1 */\n  pIn1 = &aMem[pOp->p1];\n  assert( pIn1->flags==MEM_Int );\n  pOp = &aOp[pIn1->u.i];\n  pIn1->flags = MEM_Undefined;\n  break;\n}\n\n/* Opcode: InitCoroutine P1 P2 P3 * *\n**\n** Set up register P1 so that it will Yield to the coroutine\n** located at address P3.\n**\n** If P2!=0 then the coroutine implementation immediately follows\n** this opcode.  So jump over the coroutine implementation to\n** address P2.\n**\n** See also: EndCoroutine\n*/\ncase OP_InitCoroutine: {     /* jump */\n  assert( pOp->p1>0 &&  pOp->p1<=(p->nMem+1 - p->nCursor) );\n  assert( pOp->p2>=0 && pOp->p2<p->nOp );\n  assert( pOp->p3>=0 && pOp->p3<p->nOp );\n  pOut = &aMem[pOp->p1];\n  assert( !VdbeMemDynamic(pOut) );\n  pOut->u.i = pOp->p3 - 1;\n  pOut->flags = MEM_Int;\n  if( pOp->p2 ) goto jump_to_p2;\n  break;\n}\n\n/* Opcode:  EndCoroutine P1 * * * *\n**\n** The instruction at the address in register P1 is a Yield.\n** Jump to the P2 parameter of that Yield.\n** After the jump, register P1 becomes undefined.\n**\n** See also: InitCoroutine\n*/\ncase OP_EndCoroutine: {           /* in1 */\n  VdbeOp *pCaller;\n  pIn1 = &aMem[pOp->p1];\n  assert( pIn1->flags==MEM_Int );\n  assert( pIn1->u.i>=0 && pIn1->u.i<p->nOp );\n  pCaller = &aOp[pIn1->u.i];\n  assert( pCaller->opcode==OP_Yield );\n  assert( pCaller->p2>=0 && pCaller->p2<p->nOp );\n  pOp = &aOp[pCaller->p2 - 1];\n  pIn1->flags = MEM_Undefined;\n  break;\n}\n\n/* Opcode:  Yield P1 P2 * * *\n**\n** Swap the program counter with the value in register P1.  This\n** has the effect of yielding to a coroutine.\n**\n** If the coroutine that is launched by this instruction ends with\n** Yield or Return then continue to the next instruction.  But if\n** the coroutine launched by this instruction ends with\n** EndCoroutine, then jump to P2 rather than continuing with the\n** next instruction.\n**\n** See also: InitCoroutine\n*/\ncase OP_Yield: {            /* in1, jump */\n  int pcDest;\n  pIn1 = &aMem[pOp->p1];\n  assert( VdbeMemDynamic(pIn1)==0 );\n  pIn1->flags = MEM_Int;\n  pcDest = (int)pIn1->u.i;\n  pIn1->u.i = (int)(pOp - aOp);\n  REGISTER_TRACE(pOp->p1, pIn1);\n  pOp = &aOp[pcDest];\n  break;\n}\n\n/* Opcode:  HaltIfNull  P1 P2 P3 P4 P5\n** Synopsis: if r[P3]=null halt\n**\n** Check the value in register P3.  If it is NULL then Halt using\n** parameter P1, P2, and P4 as if this were a Halt instruction.  If the\n** value in register P3 is not NULL, then this routine is a no-op.\n** The P5 parameter should be 1.\n*/\ncase OP_HaltIfNull: {      /* in3 */\n  pIn3 = &aMem[pOp->p3];\n#ifdef SQLITE_DEBUG\n  if( pOp->p2==OE_Abort ){ sqlite3VdbeAssertAbortable(p); }\n#endif\n  if( (pIn3->flags & MEM_Null)==0 ) break;\n  /* Fall through into OP_Halt */\n}\n\n/* Opcode:  Halt P1 P2 * P4 P5\n**\n** Exit immediately.  All open cursors, etc are closed\n** automatically.\n**\n** P1 is the result code returned by sqlite3_exec(), sqlite3_reset(),\n** or sqlite3_finalize().  For a normal halt, this should be SQLITE_OK (0).\n** For errors, it can be some other value.  If P1!=0 then P2 will determine\n** whether or not to rollback the current transaction.  Do not rollback\n** if P2==OE_Fail. Do the rollback if P2==OE_Rollback.  If P2==OE_Abort,\n** then back out all changes that have occurred during this execution of the\n** VDBE, but do not rollback the transaction. \n**\n** If P4 is not null then it is an error message string.\n**\n** P5 is a value between 0 and 4, inclusive, that modifies the P4 string.\n**\n**    0:  (no change)\n**    1:  NOT NULL contraint failed: P4\n**    2:  UNIQUE constraint failed: P4\n**    3:  CHECK constraint failed: P4\n**    4:  FOREIGN KEY constraint failed: P4\n**\n** If P5 is not zero and P4 is NULL, then everything after the \":\" is\n** omitted.\n**\n** There is an implied \"Halt 0 0 0\" instruction inserted at the very end of\n** every program.  So a jump past the last instruction of the program\n** is the same as executing Halt.\n*/\ncase OP_Halt: {\n  VdbeFrame *pFrame;\n  int pcx;\n\n  pcx = (int)(pOp - aOp);\n#ifdef SQLITE_DEBUG\n  if( pOp->p2==OE_Abort ){ sqlite3VdbeAssertAbortable(p); }\n#endif\n  if( pOp->p1==SQLITE_OK && p->pFrame ){\n    /* Halt the sub-program. Return control to the parent frame. */\n    pFrame = p->pFrame;\n    p->pFrame = pFrame->pParent;\n    p->nFrame--;\n    sqlite3VdbeSetChanges(db, p->nChange);\n    pcx = sqlite3VdbeFrameRestore(pFrame);\n    if( pOp->p2==OE_Ignore ){\n      /* Instruction pcx is the OP_Program that invoked the sub-program \n      ** currently being halted. If the p2 instruction of this OP_Halt\n      ** instruction is set to OE_Ignore, then the sub-program is throwing\n      ** an IGNORE exception. In this case jump to the address specified\n      ** as the p2 of the calling OP_Program.  */\n      pcx = p->aOp[pcx].p2-1;\n    }\n    aOp = p->aOp;\n    aMem = p->aMem;\n    pOp = &aOp[pcx];\n    break;\n  }\n  p->rc = pOp->p1;\n  p->errorAction = (u8)pOp->p2;\n  p->pc = pcx;\n  assert( pOp->p5<=4 );\n  if( p->rc ){\n    if( pOp->p5 ){\n      static const char * const azType[] = { \"NOT NULL\", \"UNIQUE\", \"CHECK\",\n                                             \"FOREIGN KEY\" };\n      testcase( pOp->p5==1 );\n      testcase( pOp->p5==2 );\n      testcase( pOp->p5==3 );\n      testcase( pOp->p5==4 );\n      sqlite3VdbeError(p, \"%s constraint failed\", azType[pOp->p5-1]);\n      if( pOp->p4.z ){\n        p->zErrMsg = sqlite3MPrintf(db, \"%z: %s\", p->zErrMsg, pOp->p4.z);\n      }\n    }else{\n      sqlite3VdbeError(p, \"%s\", pOp->p4.z);\n    }\n    sqlite3_log(pOp->p1, \"abort at %d in [%s]: %s\", pcx, p->zSql, p->zErrMsg);\n  }\n  rc = sqlite3VdbeHalt(p);\n  assert( rc==SQLITE_BUSY || rc==SQLITE_OK || rc==SQLITE_ERROR );\n  if( rc==SQLITE_BUSY ){\n    p->rc = SQLITE_BUSY;\n  }else{\n    assert( rc==SQLITE_OK || (p->rc&0xff)==SQLITE_CONSTRAINT );\n    assert( rc==SQLITE_OK || db->nDeferredCons>0 || db->nDeferredImmCons>0 );\n    rc = p->rc ? SQLITE_ERROR : SQLITE_DONE;\n  }\n  goto vdbe_return;\n}\n\n/* Opcode: Integer P1 P2 * * *\n** Synopsis: r[P2]=P1\n**\n** The 32-bit integer value P1 is written into register P2.\n*/\ncase OP_Integer: {         /* out2 */\n  pOut = out2Prerelease(p, pOp);\n  pOut->u.i = pOp->p1;\n  break;\n}\n\n/* Opcode: Int64 * P2 * P4 *\n** Synopsis: r[P2]=P4\n**\n** P4 is a pointer to a 64-bit integer value.\n** Write that value into register P2.\n*/\ncase OP_Int64: {           /* out2 */\n  pOut = out2Prerelease(p, pOp);\n  assert( pOp->p4.pI64!=0 );\n  pOut->u.i = *pOp->p4.pI64;\n  break;\n}\n\n#ifndef SQLITE_OMIT_FLOATING_POINT\n/* Opcode: Real * P2 * P4 *\n** Synopsis: r[P2]=P4\n**\n** P4 is a pointer to a 64-bit floating point value.\n** Write that value into register P2.\n*/\ncase OP_Real: {            /* same as TK_FLOAT, out2 */\n  pOut = out2Prerelease(p, pOp);\n  pOut->flags = MEM_Real;\n  assert( !sqlite3IsNaN(*pOp->p4.pReal) );\n  pOut->u.r = *pOp->p4.pReal;\n  break;\n}\n#endif\n\n/* Opcode: String8 * P2 * P4 *\n** Synopsis: r[P2]='P4'\n**\n** P4 points to a nul terminated UTF-8 string. This opcode is transformed \n** into a String opcode before it is executed for the first time.  During\n** this transformation, the length of string P4 is computed and stored\n** as the P1 parameter.\n*/\ncase OP_String8: {         /* same as TK_STRING, out2 */\n  assert( pOp->p4.z!=0 );\n  pOut = out2Prerelease(p, pOp);\n  pOp->opcode = OP_String;\n  pOp->p1 = sqlite3Strlen30(pOp->p4.z);\n\n#ifndef SQLITE_OMIT_UTF16\n  if( encoding!=SQLITE_UTF8 ){\n    rc = sqlite3VdbeMemSetStr(pOut, pOp->p4.z, -1, SQLITE_UTF8, SQLITE_STATIC);\n    assert( rc==SQLITE_OK || rc==SQLITE_TOOBIG );\n    if( SQLITE_OK!=sqlite3VdbeChangeEncoding(pOut, encoding) ) goto no_mem;\n    assert( pOut->szMalloc>0 && pOut->zMalloc==pOut->z );\n    assert( VdbeMemDynamic(pOut)==0 );\n    pOut->szMalloc = 0;\n    pOut->flags |= MEM_Static;\n    if( pOp->p4type==P4_DYNAMIC ){\n      sqlite3DbFree(db, pOp->p4.z);\n    }\n    pOp->p4type = P4_DYNAMIC;\n    pOp->p4.z = pOut->z;\n    pOp->p1 = pOut->n;\n  }\n  testcase( rc==SQLITE_TOOBIG );\n#endif\n  if( pOp->p1>db->aLimit[SQLITE_LIMIT_LENGTH] ){\n    goto too_big;\n  }\n  assert( rc==SQLITE_OK );\n  /* Fall through to the next case, OP_String */\n}\n  \n/* Opcode: String P1 P2 P3 P4 P5\n** Synopsis: r[P2]='P4' (len=P1)\n**\n** The string value P4 of length P1 (bytes) is stored in register P2.\n**\n** If P3 is not zero and the content of register P3 is equal to P5, then\n** the datatype of the register P2 is converted to BLOB.  The content is\n** the same sequence of bytes, it is merely interpreted as a BLOB instead\n** of a string, as if it had been CAST.  In other words:\n**\n** if( P3!=0 and reg[P3]==P5 ) reg[P2] := CAST(reg[P2] as BLOB)\n*/\ncase OP_String: {          /* out2 */\n  assert( pOp->p4.z!=0 );\n  pOut = out2Prerelease(p, pOp);\n  pOut->flags = MEM_Str|MEM_Static|MEM_Term;\n  pOut->z = pOp->p4.z;\n  pOut->n = pOp->p1;\n  pOut->enc = encoding;\n  UPDATE_MAX_BLOBSIZE(pOut);\n#ifndef SQLITE_LIKE_DOESNT_MATCH_BLOBS\n  if( pOp->p3>0 ){\n    assert( pOp->p3<=(p->nMem+1 - p->nCursor) );\n    pIn3 = &aMem[pOp->p3];\n    assert( pIn3->flags & MEM_Int );\n    if( pIn3->u.i==pOp->p5 ) pOut->flags = MEM_Blob|MEM_Static|MEM_Term;\n  }\n#endif\n  break;\n}\n\n/* Opcode: Null P1 P2 P3 * *\n** Synopsis: r[P2..P3]=NULL\n**\n** Write a NULL into registers P2.  If P3 greater than P2, then also write\n** NULL into register P3 and every register in between P2 and P3.  If P3\n** is less than P2 (typically P3 is zero) then only register P2 is\n** set to NULL.\n**\n** If the P1 value is non-zero, then also set the MEM_Cleared flag so that\n** NULL values will not compare equal even if SQLITE_NULLEQ is set on\n** OP_Ne or OP_Eq.\n*/\ncase OP_Null: {           /* out2 */\n  int cnt;\n  u16 nullFlag;\n  pOut = out2Prerelease(p, pOp);\n  cnt = pOp->p3-pOp->p2;\n  assert( pOp->p3<=(p->nMem+1 - p->nCursor) );\n  pOut->flags = nullFlag = pOp->p1 ? (MEM_Null|MEM_Cleared) : MEM_Null;\n  pOut->n = 0;\n#ifdef SQLITE_DEBUG\n  pOut->uTemp = 0;\n#endif\n  while( cnt>0 ){\n    pOut++;\n    memAboutToChange(p, pOut);\n    sqlite3VdbeMemSetNull(pOut);\n    pOut->flags = nullFlag;\n    pOut->n = 0;\n    cnt--;\n  }\n  break;\n}\n\n/* Opcode: SoftNull P1 * * * *\n** Synopsis: r[P1]=NULL\n**\n** Set register P1 to have the value NULL as seen by the OP_MakeRecord\n** instruction, but do not free any string or blob memory associated with\n** the register, so that if the value was a string or blob that was\n** previously copied using OP_SCopy, the copies will continue to be valid.\n*/\ncase OP_SoftNull: {\n  assert( pOp->p1>0 && pOp->p1<=(p->nMem+1 - p->nCursor) );\n  pOut = &aMem[pOp->p1];\n  pOut->flags = (pOut->flags&~(MEM_Undefined|MEM_AffMask))|MEM_Null;\n  break;\n}\n\n/* Opcode: Blob P1 P2 * P4 *\n** Synopsis: r[P2]=P4 (len=P1)\n**\n** P4 points to a blob of data P1 bytes long.  Store this\n** blob in register P2.\n*/\ncase OP_Blob: {                /* out2 */\n  assert( pOp->p1 <= SQLITE_MAX_LENGTH );\n  pOut = out2Prerelease(p, pOp);\n  sqlite3VdbeMemSetStr(pOut, pOp->p4.z, pOp->p1, 0, 0);\n  pOut->enc = encoding;\n  UPDATE_MAX_BLOBSIZE(pOut);\n  break;\n}\n\n/* Opcode: Variable P1 P2 * P4 *\n** Synopsis: r[P2]=parameter(P1,P4)\n**\n** Transfer the values of bound parameter P1 into register P2\n**\n** If the parameter is named, then its name appears in P4.\n** The P4 value is used by sqlite3_bind_parameter_name().\n*/\ncase OP_Variable: {            /* out2 */\n  Mem *pVar;       /* Value being transferred */\n\n  assert( pOp->p1>0 && pOp->p1<=p->nVar );\n  assert( pOp->p4.z==0 || pOp->p4.z==sqlite3VListNumToName(p->pVList,pOp->p1) );\n  pVar = &p->aVar[pOp->p1 - 1];\n  if( sqlite3VdbeMemTooBig(pVar) ){\n    goto too_big;\n  }\n  pOut = &aMem[pOp->p2];\n  sqlite3VdbeMemShallowCopy(pOut, pVar, MEM_Static);\n  UPDATE_MAX_BLOBSIZE(pOut);\n  break;\n}\n\n/* Opcode: Move P1 P2 P3 * *\n** Synopsis: r[P2@P3]=r[P1@P3]\n**\n** Move the P3 values in register P1..P1+P3-1 over into\n** registers P2..P2+P3-1.  Registers P1..P1+P3-1 are\n** left holding a NULL.  It is an error for register ranges\n** P1..P1+P3-1 and P2..P2+P3-1 to overlap.  It is an error\n** for P3 to be less than 1.\n*/\ncase OP_Move: {\n  int n;           /* Number of registers left to copy */\n  int p1;          /* Register to copy from */\n  int p2;          /* Register to copy to */\n\n  n = pOp->p3;\n  p1 = pOp->p1;\n  p2 = pOp->p2;\n  assert( n>0 && p1>0 && p2>0 );\n  assert( p1+n<=p2 || p2+n<=p1 );\n\n  pIn1 = &aMem[p1];\n  pOut = &aMem[p2];\n  do{\n    assert( pOut<=&aMem[(p->nMem+1 - p->nCursor)] );\n    assert( pIn1<=&aMem[(p->nMem+1 - p->nCursor)] );\n    assert( memIsValid(pIn1) );\n    memAboutToChange(p, pOut);\n    sqlite3VdbeMemMove(pOut, pIn1);\n#ifdef SQLITE_DEBUG\n    if( pOut->pScopyFrom>=&aMem[p1] && pOut->pScopyFrom<pOut ){\n      pOut->pScopyFrom += pOp->p2 - p1;\n    }\n#endif\n    Deephemeralize(pOut);\n    REGISTER_TRACE(p2++, pOut);\n    pIn1++;\n    pOut++;\n  }while( --n );\n  break;\n}\n\n/* Opcode: Copy P1 P2 P3 * *\n** Synopsis: r[P2@P3+1]=r[P1@P3+1]\n**\n** Make a copy of registers P1..P1+P3 into registers P2..P2+P3.\n**\n** This instruction makes a deep copy of the value.  A duplicate\n** is made of any string or blob constant.  See also OP_SCopy.\n*/\ncase OP_Copy: {\n  int n;\n\n  n = pOp->p3;\n  pIn1 = &aMem[pOp->p1];\n  pOut = &aMem[pOp->p2];\n  assert( pOut!=pIn1 );\n  while( 1 ){\n    memAboutToChange(p, pOut);\n    sqlite3VdbeMemShallowCopy(pOut, pIn1, MEM_Ephem);\n    Deephemeralize(pOut);\n#ifdef SQLITE_DEBUG\n    pOut->pScopyFrom = 0;\n#endif\n    REGISTER_TRACE(pOp->p2+pOp->p3-n, pOut);\n    if( (n--)==0 ) break;\n    pOut++;\n    pIn1++;\n  }\n  break;\n}\n\n/* Opcode: SCopy P1 P2 * * *\n** Synopsis: r[P2]=r[P1]\n**\n** Make a shallow copy of register P1 into register P2.\n**\n** This instruction makes a shallow copy of the value.  If the value\n** is a string or blob, then the copy is only a pointer to the\n** original and hence if the original changes so will the copy.\n** Worse, if the original is deallocated, the copy becomes invalid.\n** Thus the program must guarantee that the original will not change\n** during the lifetime of the copy.  Use OP_Copy to make a complete\n** copy.\n*/\ncase OP_SCopy: {            /* out2 */\n  pIn1 = &aMem[pOp->p1];\n  pOut = &aMem[pOp->p2];\n  assert( pOut!=pIn1 );\n  sqlite3VdbeMemShallowCopy(pOut, pIn1, MEM_Ephem);\n#ifdef SQLITE_DEBUG\n  pOut->pScopyFrom = pIn1;\n  pOut->mScopyFlags = pIn1->flags;\n#endif\n  break;\n}\n\n/* Opcode: IntCopy P1 P2 * * *\n** Synopsis: r[P2]=r[P1]\n**\n** Transfer the integer value held in register P1 into register P2.\n**\n** This is an optimized version of SCopy that works only for integer\n** values.\n*/\ncase OP_IntCopy: {            /* out2 */\n  pIn1 = &aMem[pOp->p1];\n  assert( (pIn1->flags & MEM_Int)!=0 );\n  pOut = &aMem[pOp->p2];\n  sqlite3VdbeMemSetInt64(pOut, pIn1->u.i);\n  break;\n}\n\n/* Opcode: ResultRow P1 P2 * * *\n** Synopsis: output=r[P1@P2]\n**\n** The registers P1 through P1+P2-1 contain a single row of\n** results. This opcode causes the sqlite3_step() call to terminate\n** with an SQLITE_ROW return code and it sets up the sqlite3_stmt\n** structure to provide access to the r(P1)..r(P1+P2-1) values as\n** the result row.\n*/\ncase OP_ResultRow: {\n  Mem *pMem;\n  int i;\n  assert( p->nResColumn==pOp->p2 );\n  assert( pOp->p1>0 );\n  assert( pOp->p1+pOp->p2<=(p->nMem+1 - p->nCursor)+1 );\n\n#ifndef SQLITE_OMIT_PROGRESS_CALLBACK\n  /* Run the progress counter just before returning.\n  */\n  if( db->xProgress!=0\n   && nVmStep>=nProgressLimit \n   && db->xProgress(db->pProgressArg)!=0\n  ){\n    rc = SQLITE_INTERRUPT;\n    goto abort_due_to_error;\n  }\n#endif\n\n  /* If this statement has violated immediate foreign key constraints, do\n  ** not return the number of rows modified. And do not RELEASE the statement\n  ** transaction. It needs to be rolled back.  */\n  if( SQLITE_OK!=(rc = sqlite3VdbeCheckFk(p, 0)) ){\n    assert( db->flags&SQLITE_CountRows );\n    assert( p->usesStmtJournal );\n    goto abort_due_to_error;\n  }\n\n  /* If the SQLITE_CountRows flag is set in sqlite3.flags mask, then \n  ** DML statements invoke this opcode to return the number of rows \n  ** modified to the user. This is the only way that a VM that\n  ** opens a statement transaction may invoke this opcode.\n  **\n  ** In case this is such a statement, close any statement transaction\n  ** opened by this VM before returning control to the user. This is to\n  ** ensure that statement-transactions are always nested, not overlapping.\n  ** If the open statement-transaction is not closed here, then the user\n  ** may step another VM that opens its own statement transaction. This\n  ** may lead to overlapping statement transactions.\n  **\n  ** The statement transaction is never a top-level transaction.  Hence\n  ** the RELEASE call below can never fail.\n  */\n  assert( p->iStatement==0 || db->flags&SQLITE_CountRows );\n  rc = sqlite3VdbeCloseStatement(p, SAVEPOINT_RELEASE);\n  assert( rc==SQLITE_OK );\n\n  /* Invalidate all ephemeral cursor row caches */\n  p->cacheCtr = (p->cacheCtr + 2)|1;\n\n  /* Make sure the results of the current row are \\000 terminated\n  ** and have an assigned type.  The results are de-ephemeralized as\n  ** a side effect.\n  */\n  pMem = p->pResultSet = &aMem[pOp->p1];\n  for(i=0; i<pOp->p2; i++){\n    assert( memIsValid(&pMem[i]) );\n    Deephemeralize(&pMem[i]);\n    assert( (pMem[i].flags & MEM_Ephem)==0\n            || (pMem[i].flags & (MEM_Str|MEM_Blob))==0 );\n    sqlite3VdbeMemNulTerminate(&pMem[i]);\n    REGISTER_TRACE(pOp->p1+i, &pMem[i]);\n  }\n  if( db->mallocFailed ) goto no_mem;\n\n  if( db->mTrace & SQLITE_TRACE_ROW ){\n    db->xTrace(SQLITE_TRACE_ROW, db->pTraceArg, p, 0);\n  }\n\n  /* Return SQLITE_ROW\n  */\n  p->pc = (int)(pOp - aOp) + 1;\n  rc = SQLITE_ROW;\n  goto vdbe_return;\n}\n\n/* Opcode: Concat P1 P2 P3 * *\n** Synopsis: r[P3]=r[P2]+r[P1]\n**\n** Add the text in register P1 onto the end of the text in\n** register P2 and store the result in register P3.\n** If either the P1 or P2 text are NULL then store NULL in P3.\n**\n**   P3 = P2 || P1\n**\n** It is illegal for P1 and P3 to be the same register. Sometimes,\n** if P3 is the same register as P2, the implementation is able\n** to avoid a memcpy().\n*/\ncase OP_Concat: {           /* same as TK_CONCAT, in1, in2, out3 */\n  i64 nByte;\n\n  pIn1 = &aMem[pOp->p1];\n  pIn2 = &aMem[pOp->p2];\n  pOut = &aMem[pOp->p3];\n  assert( pIn1!=pOut );\n  if( (pIn1->flags | pIn2->flags) & MEM_Null ){\n    sqlite3VdbeMemSetNull(pOut);\n    break;\n  }\n  if( ExpandBlob(pIn1) || ExpandBlob(pIn2) ) goto no_mem;\n  Stringify(pIn1, encoding);\n  Stringify(pIn2, encoding);\n  nByte = pIn1->n + pIn2->n;\n  if( nByte>db->aLimit[SQLITE_LIMIT_LENGTH] ){\n    goto too_big;\n  }\n  if( sqlite3VdbeMemGrow(pOut, (int)nByte+2, pOut==pIn2) ){\n    goto no_mem;\n  }\n  MemSetTypeFlag(pOut, MEM_Str);\n  if( pOut!=pIn2 ){\n    memcpy(pOut->z, pIn2->z, pIn2->n);\n  }\n  memcpy(&pOut->z[pIn2->n], pIn1->z, pIn1->n);\n  pOut->z[nByte]=0;\n  pOut->z[nByte+1] = 0;\n  pOut->flags |= MEM_Term;\n  pOut->n = (int)nByte;\n  pOut->enc = encoding;\n  UPDATE_MAX_BLOBSIZE(pOut);\n  break;\n}\n\n/* Opcode: Add P1 P2 P3 * *\n** Synopsis: r[P3]=r[P1]+r[P2]\n**\n** Add the value in register P1 to the value in register P2\n** and store the result in register P3.\n** If either input is NULL, the result is NULL.\n*/\n/* Opcode: Multiply P1 P2 P3 * *\n** Synopsis: r[P3]=r[P1]*r[P2]\n**\n**\n** Multiply the value in register P1 by the value in register P2\n** and store the result in register P3.\n** If either input is NULL, the result is NULL.\n*/\n/* Opcode: Subtract P1 P2 P3 * *\n** Synopsis: r[P3]=r[P2]-r[P1]\n**\n** Subtract the value in register P1 from the value in register P2\n** and store the result in register P3.\n** If either input is NULL, the result is NULL.\n*/\n/* Opcode: Divide P1 P2 P3 * *\n** Synopsis: r[P3]=r[P2]/r[P1]\n**\n** Divide the value in register P1 by the value in register P2\n** and store the result in register P3 (P3=P2/P1). If the value in \n** register P1 is zero, then the result is NULL. If either input is \n** NULL, the result is NULL.\n*/\n/* Opcode: Remainder P1 P2 P3 * *\n** Synopsis: r[P3]=r[P2]%r[P1]\n**\n** Compute the remainder after integer register P2 is divided by \n** register P1 and store the result in register P3. \n** If the value in register P1 is zero the result is NULL.\n** If either operand is NULL, the result is NULL.\n*/\ncase OP_Add:                   /* same as TK_PLUS, in1, in2, out3 */\ncase OP_Subtract:              /* same as TK_MINUS, in1, in2, out3 */\ncase OP_Multiply:              /* same as TK_STAR, in1, in2, out3 */\ncase OP_Divide:                /* same as TK_SLASH, in1, in2, out3 */\ncase OP_Remainder: {           /* same as TK_REM, in1, in2, out3 */\n  char bIntint;   /* Started out as two integer operands */\n  u16 flags;      /* Combined MEM_* flags from both inputs */\n  u16 type1;      /* Numeric type of left operand */\n  u16 type2;      /* Numeric type of right operand */\n  i64 iA;         /* Integer value of left operand */\n  i64 iB;         /* Integer value of right operand */\n  double rA;      /* Real value of left operand */\n  double rB;      /* Real value of right operand */\n\n  pIn1 = &aMem[pOp->p1];\n  type1 = numericType(pIn1);\n  pIn2 = &aMem[pOp->p2];\n  type2 = numericType(pIn2);\n  pOut = &aMem[pOp->p3];\n  flags = pIn1->flags | pIn2->flags;\n  if( (type1 & type2 & MEM_Int)!=0 ){\n    iA = pIn1->u.i;\n    iB = pIn2->u.i;\n    bIntint = 1;\n    switch( pOp->opcode ){\n      case OP_Add:       if( sqlite3AddInt64(&iB,iA) ) goto fp_math;  break;\n      case OP_Subtract:  if( sqlite3SubInt64(&iB,iA) ) goto fp_math;  break;\n      case OP_Multiply:  if( sqlite3MulInt64(&iB,iA) ) goto fp_math;  break;\n      case OP_Divide: {\n        if( iA==0 ) goto arithmetic_result_is_null;\n        if( iA==-1 && iB==SMALLEST_INT64 ) goto fp_math;\n        iB /= iA;\n        break;\n      }\n      default: {\n        if( iA==0 ) goto arithmetic_result_is_null;\n        if( iA==-1 ) iA = 1;\n        iB %= iA;\n        break;\n      }\n    }\n    pOut->u.i = iB;\n    MemSetTypeFlag(pOut, MEM_Int);\n  }else if( (flags & MEM_Null)!=0 ){\n    goto arithmetic_result_is_null;\n  }else{\n    bIntint = 0;\nfp_math:\n    rA = sqlite3VdbeRealValue(pIn1);\n    rB = sqlite3VdbeRealValue(pIn2);\n    switch( pOp->opcode ){\n      case OP_Add:         rB += rA;       break;\n      case OP_Subtract:    rB -= rA;       break;\n      case OP_Multiply:    rB *= rA;       break;\n      case OP_Divide: {\n        /* (double)0 In case of SQLITE_OMIT_FLOATING_POINT... */\n        if( rA==(double)0 ) goto arithmetic_result_is_null;\n        rB /= rA;\n        break;\n      }\n      default: {\n        iA = sqlite3VdbeIntValue(pIn1);\n        iB = sqlite3VdbeIntValue(pIn2);\n        if( iA==0 ) goto arithmetic_result_is_null;\n        if( iA==-1 ) iA = 1;\n        rB = (double)(iB % iA);\n        break;\n      }\n    }\n#ifdef SQLITE_OMIT_FLOATING_POINT\n    pOut->u.i = rB;\n    MemSetTypeFlag(pOut, MEM_Int);\n#else\n    if( sqlite3IsNaN(rB) ){\n      goto arithmetic_result_is_null;\n    }\n    pOut->u.r = rB;\n    MemSetTypeFlag(pOut, MEM_Real);\n    if( ((type1|type2)&MEM_Real)==0 && !bIntint ){\n      sqlite3VdbeIntegerAffinity(pOut);\n    }\n#endif\n  }\n  break;\n\narithmetic_result_is_null:\n  sqlite3VdbeMemSetNull(pOut);\n  break;\n}\n\n/* Opcode: CollSeq P1 * * P4\n**\n** P4 is a pointer to a CollSeq object. If the next call to a user function\n** or aggregate calls sqlite3GetFuncCollSeq(), this collation sequence will\n** be returned. This is used by the built-in min(), max() and nullif()\n** functions.\n**\n** If P1 is not zero, then it is a register that a subsequent min() or\n** max() aggregate will set to 1 if the current row is not the minimum or\n** maximum.  The P1 register is initialized to 0 by this instruction.\n**\n** The interface used by the implementation of the aforementioned functions\n** to retrieve the collation sequence set by this opcode is not available\n** publicly.  Only built-in functions have access to this feature.\n*/\ncase OP_CollSeq: {\n  assert( pOp->p4type==P4_COLLSEQ );\n  if( pOp->p1 ){\n    sqlite3VdbeMemSetInt64(&aMem[pOp->p1], 0);\n  }\n  break;\n}\n\n/* Opcode: BitAnd P1 P2 P3 * *\n** Synopsis: r[P3]=r[P1]&r[P2]\n**\n** Take the bit-wise AND of the values in register P1 and P2 and\n** store the result in register P3.\n** If either input is NULL, the result is NULL.\n*/\n/* Opcode: BitOr P1 P2 P3 * *\n** Synopsis: r[P3]=r[P1]|r[P2]\n**\n** Take the bit-wise OR of the values in register P1 and P2 and\n** store the result in register P3.\n** If either input is NULL, the result is NULL.\n*/\n/* Opcode: ShiftLeft P1 P2 P3 * *\n** Synopsis: r[P3]=r[P2]<<r[P1]\n**\n** Shift the integer value in register P2 to the left by the\n** number of bits specified by the integer in register P1.\n** Store the result in register P3.\n** If either input is NULL, the result is NULL.\n*/\n/* Opcode: ShiftRight P1 P2 P3 * *\n** Synopsis: r[P3]=r[P2]>>r[P1]\n**\n** Shift the integer value in register P2 to the right by the\n** number of bits specified by the integer in register P1.\n** Store the result in register P3.\n** If either input is NULL, the result is NULL.\n*/\ncase OP_BitAnd:                 /* same as TK_BITAND, in1, in2, out3 */\ncase OP_BitOr:                  /* same as TK_BITOR, in1, in2, out3 */\ncase OP_ShiftLeft:              /* same as TK_LSHIFT, in1, in2, out3 */\ncase OP_ShiftRight: {           /* same as TK_RSHIFT, in1, in2, out3 */\n  i64 iA;\n  u64 uA;\n  i64 iB;\n  u8 op;\n\n  pIn1 = &aMem[pOp->p1];\n  pIn2 = &aMem[pOp->p2];\n  pOut = &aMem[pOp->p3];\n  if( (pIn1->flags | pIn2->flags) & MEM_Null ){\n    sqlite3VdbeMemSetNull(pOut);\n    break;\n  }\n  iA = sqlite3VdbeIntValue(pIn2);\n  iB = sqlite3VdbeIntValue(pIn1);\n  op = pOp->opcode;\n  if( op==OP_BitAnd ){\n    iA &= iB;\n  }else if( op==OP_BitOr ){\n    iA |= iB;\n  }else if( iB!=0 ){\n    assert( op==OP_ShiftRight || op==OP_ShiftLeft );\n\n    /* If shifting by a negative amount, shift in the other direction */\n    if( iB<0 ){\n      assert( OP_ShiftRight==OP_ShiftLeft+1 );\n      op = 2*OP_ShiftLeft + 1 - op;\n      iB = iB>(-64) ? -iB : 64;\n    }\n\n    if( iB>=64 ){\n      iA = (iA>=0 || op==OP_ShiftLeft) ? 0 : -1;\n    }else{\n      memcpy(&uA, &iA, sizeof(uA));\n      if( op==OP_ShiftLeft ){\n        uA <<= iB;\n      }else{\n        uA >>= iB;\n        /* Sign-extend on a right shift of a negative number */\n        if( iA<0 ) uA |= ((((u64)0xffffffff)<<32)|0xffffffff) << (64-iB);\n      }\n      memcpy(&iA, &uA, sizeof(iA));\n    }\n  }\n  pOut->u.i = iA;\n  MemSetTypeFlag(pOut, MEM_Int);\n  break;\n}\n\n/* Opcode: AddImm  P1 P2 * * *\n** Synopsis: r[P1]=r[P1]+P2\n** \n** Add the constant P2 to the value in register P1.\n** The result is always an integer.\n**\n** To force any register to be an integer, just add 0.\n*/\ncase OP_AddImm: {            /* in1 */\n  pIn1 = &aMem[pOp->p1];\n  memAboutToChange(p, pIn1);\n  sqlite3VdbeMemIntegerify(pIn1);\n  pIn1->u.i += pOp->p2;\n  break;\n}\n\n/* Opcode: MustBeInt P1 P2 * * *\n** \n** Force the value in register P1 to be an integer.  If the value\n** in P1 is not an integer and cannot be converted into an integer\n** without data loss, then jump immediately to P2, or if P2==0\n** raise an SQLITE_MISMATCH exception.\n*/\ncase OP_MustBeInt: {            /* jump, in1 */\n  pIn1 = &aMem[pOp->p1];\n  if( (pIn1->flags & MEM_Int)==0 ){\n    applyAffinity(pIn1, SQLITE_AFF_NUMERIC, encoding);\n    VdbeBranchTaken((pIn1->flags&MEM_Int)==0, 2);\n    if( (pIn1->flags & MEM_Int)==0 ){\n      if( pOp->p2==0 ){\n        rc = SQLITE_MISMATCH;\n        goto abort_due_to_error;\n      }else{\n        goto jump_to_p2;\n      }\n    }\n  }\n  MemSetTypeFlag(pIn1, MEM_Int);\n  break;\n}\n\n#ifndef SQLITE_OMIT_FLOATING_POINT\n/* Opcode: RealAffinity P1 * * * *\n**\n** If register P1 holds an integer convert it to a real value.\n**\n** This opcode is used when extracting information from a column that\n** has REAL affinity.  Such column values may still be stored as\n** integers, for space efficiency, but after extraction we want them\n** to have only a real value.\n*/\ncase OP_RealAffinity: {                  /* in1 */\n  pIn1 = &aMem[pOp->p1];\n  if( pIn1->flags & MEM_Int ){\n    sqlite3VdbeMemRealify(pIn1);\n  }\n  break;\n}\n#endif\n\n#ifndef SQLITE_OMIT_CAST\n/* Opcode: Cast P1 P2 * * *\n** Synopsis: affinity(r[P1])\n**\n** Force the value in register P1 to be the type defined by P2.\n** \n** <ul>\n** <li> P2=='A' &rarr; BLOB\n** <li> P2=='B' &rarr; TEXT\n** <li> P2=='C' &rarr; NUMERIC\n** <li> P2=='D' &rarr; INTEGER\n** <li> P2=='E' &rarr; REAL\n** </ul>\n**\n** A NULL value is not changed by this routine.  It remains NULL.\n*/\ncase OP_Cast: {                  /* in1 */\n  assert( pOp->p2>=SQLITE_AFF_BLOB && pOp->p2<=SQLITE_AFF_REAL );\n  testcase( pOp->p2==SQLITE_AFF_TEXT );\n  testcase( pOp->p2==SQLITE_AFF_BLOB );\n  testcase( pOp->p2==SQLITE_AFF_NUMERIC );\n  testcase( pOp->p2==SQLITE_AFF_INTEGER );\n  testcase( pOp->p2==SQLITE_AFF_REAL );\n  pIn1 = &aMem[pOp->p1];\n  memAboutToChange(p, pIn1);\n  rc = ExpandBlob(pIn1);\n  sqlite3VdbeMemCast(pIn1, pOp->p2, encoding);\n  UPDATE_MAX_BLOBSIZE(pIn1);\n  if( rc ) goto abort_due_to_error;\n  break;\n}\n#endif /* SQLITE_OMIT_CAST */\n\n/* Opcode: Eq P1 P2 P3 P4 P5\n** Synopsis: IF r[P3]==r[P1]\n**\n** Compare the values in register P1 and P3.  If reg(P3)==reg(P1) then\n** jump to address P2.  Or if the SQLITE_STOREP2 flag is set in P5, then\n** store the result of comparison in register P2.\n**\n** The SQLITE_AFF_MASK portion of P5 must be an affinity character -\n** SQLITE_AFF_TEXT, SQLITE_AFF_INTEGER, and so forth. An attempt is made \n** to coerce both inputs according to this affinity before the\n** comparison is made. If the SQLITE_AFF_MASK is 0x00, then numeric\n** affinity is used. Note that the affinity conversions are stored\n** back into the input registers P1 and P3.  So this opcode can cause\n** persistent changes to registers P1 and P3.\n**\n** Once any conversions have taken place, and neither value is NULL, \n** the values are compared. If both values are blobs then memcmp() is\n** used to determine the results of the comparison.  If both values\n** are text, then the appropriate collating function specified in\n** P4 is used to do the comparison.  If P4 is not specified then\n** memcmp() is used to compare text string.  If both values are\n** numeric, then a numeric comparison is used. If the two values\n** are of different types, then numbers are considered less than\n** strings and strings are considered less than blobs.\n**\n** If SQLITE_NULLEQ is set in P5 then the result of comparison is always either\n** true or false and is never NULL.  If both operands are NULL then the result\n** of comparison is true.  If either operand is NULL then the result is false.\n** If neither operand is NULL the result is the same as it would be if\n** the SQLITE_NULLEQ flag were omitted from P5.\n**\n** If both SQLITE_STOREP2 and SQLITE_KEEPNULL flags are set then the\n** content of r[P2] is only changed if the new value is NULL or 0 (false).\n** In other words, a prior r[P2] value will not be overwritten by 1 (true).\n*/\n/* Opcode: Ne P1 P2 P3 P4 P5\n** Synopsis: IF r[P3]!=r[P1]\n**\n** This works just like the Eq opcode except that the jump is taken if\n** the operands in registers P1 and P3 are not equal.  See the Eq opcode for\n** additional information.\n**\n** If both SQLITE_STOREP2 and SQLITE_KEEPNULL flags are set then the\n** content of r[P2] is only changed if the new value is NULL or 1 (true).\n** In other words, a prior r[P2] value will not be overwritten by 0 (false).\n*/\n/* Opcode: Lt P1 P2 P3 P4 P5\n** Synopsis: IF r[P3]<r[P1]\n**\n** Compare the values in register P1 and P3.  If reg(P3)<reg(P1) then\n** jump to address P2.  Or if the SQLITE_STOREP2 flag is set in P5 store\n** the result of comparison (0 or 1 or NULL) into register P2.\n**\n** If the SQLITE_JUMPIFNULL bit of P5 is set and either reg(P1) or\n** reg(P3) is NULL then the take the jump.  If the SQLITE_JUMPIFNULL \n** bit is clear then fall through if either operand is NULL.\n**\n** The SQLITE_AFF_MASK portion of P5 must be an affinity character -\n** SQLITE_AFF_TEXT, SQLITE_AFF_INTEGER, and so forth. An attempt is made \n** to coerce both inputs according to this affinity before the\n** comparison is made. If the SQLITE_AFF_MASK is 0x00, then numeric\n** affinity is used. Note that the affinity conversions are stored\n** back into the input registers P1 and P3.  So this opcode can cause\n** persistent changes to registers P1 and P3.\n**\n** Once any conversions have taken place, and neither value is NULL, \n** the values are compared. If both values are blobs then memcmp() is\n** used to determine the results of the comparison.  If both values\n** are text, then the appropriate collating function specified in\n** P4 is  used to do the comparison.  If P4 is not specified then\n** memcmp() is used to compare text string.  If both values are\n** numeric, then a numeric comparison is used. If the two values\n** are of different types, then numbers are considered less than\n** strings and strings are considered less than blobs.\n*/\n/* Opcode: Le P1 P2 P3 P4 P5\n** Synopsis: IF r[P3]<=r[P1]\n**\n** This works just like the Lt opcode except that the jump is taken if\n** the content of register P3 is less than or equal to the content of\n** register P1.  See the Lt opcode for additional information.\n*/\n/* Opcode: Gt P1 P2 P3 P4 P5\n** Synopsis: IF r[P3]>r[P1]\n**\n** This works just like the Lt opcode except that the jump is taken if\n** the content of register P3 is greater than the content of\n** register P1.  See the Lt opcode for additional information.\n*/\n/* Opcode: Ge P1 P2 P3 P4 P5\n** Synopsis: IF r[P3]>=r[P1]\n**\n** This works just like the Lt opcode except that the jump is taken if\n** the content of register P3 is greater than or equal to the content of\n** register P1.  See the Lt opcode for additional information.\n*/\ncase OP_Eq:               /* same as TK_EQ, jump, in1, in3 */\ncase OP_Ne:               /* same as TK_NE, jump, in1, in3 */\ncase OP_Lt:               /* same as TK_LT, jump, in1, in3 */\ncase OP_Le:               /* same as TK_LE, jump, in1, in3 */\ncase OP_Gt:               /* same as TK_GT, jump, in1, in3 */\ncase OP_Ge: {             /* same as TK_GE, jump, in1, in3 */\n  int res, res2;      /* Result of the comparison of pIn1 against pIn3 */\n  char affinity;      /* Affinity to use for comparison */\n  u16 flags1;         /* Copy of initial value of pIn1->flags */\n  u16 flags3;         /* Copy of initial value of pIn3->flags */\n\n  pIn1 = &aMem[pOp->p1];\n  pIn3 = &aMem[pOp->p3];\n  flags1 = pIn1->flags;\n  flags3 = pIn3->flags;\n  if( (flags1 | flags3)&MEM_Null ){\n    /* One or both operands are NULL */\n    if( pOp->p5 & SQLITE_NULLEQ ){\n      /* If SQLITE_NULLEQ is set (which will only happen if the operator is\n      ** OP_Eq or OP_Ne) then take the jump or not depending on whether\n      ** or not both operands are null.\n      */\n      assert( pOp->opcode==OP_Eq || pOp->opcode==OP_Ne );\n      assert( (flags1 & MEM_Cleared)==0 );\n      assert( (pOp->p5 & SQLITE_JUMPIFNULL)==0 || CORRUPT_DB );\n      testcase( (pOp->p5 & SQLITE_JUMPIFNULL)!=0 );\n      if( (flags1&flags3&MEM_Null)!=0\n       && (flags3&MEM_Cleared)==0\n      ){\n        res = 0;  /* Operands are equal */\n      }else{\n        res = 1;  /* Operands are not equal */\n      }\n    }else{\n      /* SQLITE_NULLEQ is clear and at least one operand is NULL,\n      ** then the result is always NULL.\n      ** The jump is taken if the SQLITE_JUMPIFNULL bit is set.\n      */\n      if( pOp->p5 & SQLITE_STOREP2 ){\n        pOut = &aMem[pOp->p2];\n        iCompare = 1;    /* Operands are not equal */\n        memAboutToChange(p, pOut);\n        MemSetTypeFlag(pOut, MEM_Null);\n        REGISTER_TRACE(pOp->p2, pOut);\n      }else{\n        VdbeBranchTaken(2,3);\n        if( pOp->p5 & SQLITE_JUMPIFNULL ){\n          goto jump_to_p2;\n        }\n      }\n      break;\n    }\n  }else{\n    /* Neither operand is NULL.  Do a comparison. */\n    affinity = pOp->p5 & SQLITE_AFF_MASK;\n    if( affinity>=SQLITE_AFF_NUMERIC ){\n      if( (flags1 | flags3)&MEM_Str ){\n        if( (flags1 & (MEM_Int|MEM_Real|MEM_Str))==MEM_Str ){\n          applyNumericAffinity(pIn1,0);\n          assert( flags3==pIn3->flags );\n          /* testcase( flags3!=pIn3->flags );\n          ** this used to be possible with pIn1==pIn3, but not since\n          ** the column cache was removed.  The following assignment\n          ** is essentially a no-op.  But, it provides defense-in-depth\n          ** in case our analysis is incorrect, so it is left in. */\n          flags3 = pIn3->flags;\n        }\n        if( (flags3 & (MEM_Int|MEM_Real|MEM_Str))==MEM_Str ){\n          applyNumericAffinity(pIn3,0);\n        }\n      }\n      /* Handle the common case of integer comparison here, as an\n      ** optimization, to avoid a call to sqlite3MemCompare() */\n      if( (pIn1->flags & pIn3->flags & MEM_Int)!=0 ){\n        if( pIn3->u.i > pIn1->u.i ){ res = +1; goto compare_op; }\n        if( pIn3->u.i < pIn1->u.i ){ res = -1; goto compare_op; }\n        res = 0;\n        goto compare_op;\n      }\n    }else if( affinity==SQLITE_AFF_TEXT ){\n      if( (flags1 & MEM_Str)==0 && (flags1 & (MEM_Int|MEM_Real))!=0 ){\n        testcase( pIn1->flags & MEM_Int );\n        testcase( pIn1->flags & MEM_Real );\n        sqlite3VdbeMemStringify(pIn1, encoding, 1);\n        testcase( (flags1&MEM_Dyn) != (pIn1->flags&MEM_Dyn) );\n        flags1 = (pIn1->flags & ~MEM_TypeMask) | (flags1 & MEM_TypeMask);\n        assert( pIn1!=pIn3 );\n      }\n      if( (flags3 & MEM_Str)==0 && (flags3 & (MEM_Int|MEM_Real))!=0 ){\n        testcase( pIn3->flags & MEM_Int );\n        testcase( pIn3->flags & MEM_Real );\n        sqlite3VdbeMemStringify(pIn3, encoding, 1);\n        testcase( (flags3&MEM_Dyn) != (pIn3->flags&MEM_Dyn) );\n        flags3 = (pIn3->flags & ~MEM_TypeMask) | (flags3 & MEM_TypeMask);\n      }\n    }\n    assert( pOp->p4type==P4_COLLSEQ || pOp->p4.pColl==0 );\n    res = sqlite3MemCompare(pIn3, pIn1, pOp->p4.pColl);\n  }\ncompare_op:\n  /* At this point, res is negative, zero, or positive if reg[P1] is\n  ** less than, equal to, or greater than reg[P3], respectively.  Compute\n  ** the answer to this operator in res2, depending on what the comparison\n  ** operator actually is.  The next block of code depends on the fact\n  ** that the 6 comparison operators are consecutive integers in this\n  ** order:  NE, EQ, GT, LE, LT, GE */\n  assert( OP_Eq==OP_Ne+1 ); assert( OP_Gt==OP_Ne+2 ); assert( OP_Le==OP_Ne+3 );\n  assert( OP_Lt==OP_Ne+4 ); assert( OP_Ge==OP_Ne+5 );\n  if( res<0 ){                        /* ne, eq, gt, le, lt, ge */\n    static const unsigned char aLTb[] = { 1,  0,  0,  1,  1,  0 };\n    res2 = aLTb[pOp->opcode - OP_Ne];\n  }else if( res==0 ){\n    static const unsigned char aEQb[] = { 0,  1,  0,  1,  0,  1 };\n    res2 = aEQb[pOp->opcode - OP_Ne];\n  }else{\n    static const unsigned char aGTb[] = { 1,  0,  1,  0,  0,  1 };\n    res2 = aGTb[pOp->opcode - OP_Ne];\n  }\n\n  /* Undo any changes made by applyAffinity() to the input registers. */\n  assert( (pIn1->flags & MEM_Dyn) == (flags1 & MEM_Dyn) );\n  pIn1->flags = flags1;\n  assert( (pIn3->flags & MEM_Dyn) == (flags3 & MEM_Dyn) );\n  pIn3->flags = flags3;\n\n  if( pOp->p5 & SQLITE_STOREP2 ){\n    pOut = &aMem[pOp->p2];\n    iCompare = res;\n    if( (pOp->p5 & SQLITE_KEEPNULL)!=0 ){\n      /* The KEEPNULL flag prevents OP_Eq from overwriting a NULL with 1\n      ** and prevents OP_Ne from overwriting NULL with 0.  This flag\n      ** is only used in contexts where either:\n      **   (1) op==OP_Eq && (r[P2]==NULL || r[P2]==0)\n      **   (2) op==OP_Ne && (r[P2]==NULL || r[P2]==1)\n      ** Therefore it is not necessary to check the content of r[P2] for\n      ** NULL. */\n      assert( pOp->opcode==OP_Ne || pOp->opcode==OP_Eq );\n      assert( res2==0 || res2==1 );\n      testcase( res2==0 && pOp->opcode==OP_Eq );\n      testcase( res2==1 && pOp->opcode==OP_Eq );\n      testcase( res2==0 && pOp->opcode==OP_Ne );\n      testcase( res2==1 && pOp->opcode==OP_Ne );\n      if( (pOp->opcode==OP_Eq)==res2 ) break;\n    }\n    memAboutToChange(p, pOut);\n    MemSetTypeFlag(pOut, MEM_Int);\n    pOut->u.i = res2;\n    REGISTER_TRACE(pOp->p2, pOut);\n  }else{\n    VdbeBranchTaken(res!=0, (pOp->p5 & SQLITE_NULLEQ)?2:3);\n    if( res2 ){\n      goto jump_to_p2;\n    }\n  }\n  break;\n}\n\n/* Opcode: ElseNotEq * P2 * * *\n**\n** This opcode must immediately follow an OP_Lt or OP_Gt comparison operator.\n** If result of an OP_Eq comparison on the same two operands\n** would have be NULL or false (0), then then jump to P2. \n** If the result of an OP_Eq comparison on the two previous operands\n** would have been true (1), then fall through.\n*/\ncase OP_ElseNotEq: {       /* same as TK_ESCAPE, jump */\n  assert( pOp>aOp );\n  assert( pOp[-1].opcode==OP_Lt || pOp[-1].opcode==OP_Gt );\n  assert( pOp[-1].p5 & SQLITE_STOREP2 );\n  VdbeBranchTaken(iCompare!=0, 2);\n  if( iCompare!=0 ) goto jump_to_p2;\n  break;\n}\n\n\n/* Opcode: Permutation * * * P4 *\n**\n** Set the permutation used by the OP_Compare operator in the next\n** instruction.  The permutation is stored in the P4 operand.\n**\n** The permutation is only valid until the next OP_Compare that has\n** the OPFLAG_PERMUTE bit set in P5. Typically the OP_Permutation should \n** occur immediately prior to the OP_Compare.\n**\n** The first integer in the P4 integer array is the length of the array\n** and does not become part of the permutation.\n*/\ncase OP_Permutation: {\n  assert( pOp->p4type==P4_INTARRAY );\n  assert( pOp->p4.ai );\n  assert( pOp[1].opcode==OP_Compare );\n  assert( pOp[1].p5 & OPFLAG_PERMUTE );\n  break;\n}\n\n/* Opcode: Compare P1 P2 P3 P4 P5\n** Synopsis: r[P1@P3] <-> r[P2@P3]\n**\n** Compare two vectors of registers in reg(P1)..reg(P1+P3-1) (call this\n** vector \"A\") and in reg(P2)..reg(P2+P3-1) (\"B\").  Save the result of\n** the comparison for use by the next OP_Jump instruct.\n**\n** If P5 has the OPFLAG_PERMUTE bit set, then the order of comparison is\n** determined by the most recent OP_Permutation operator.  If the\n** OPFLAG_PERMUTE bit is clear, then register are compared in sequential\n** order.\n**\n** P4 is a KeyInfo structure that defines collating sequences and sort\n** orders for the comparison.  The permutation applies to registers\n** only.  The KeyInfo elements are used sequentially.\n**\n** The comparison is a sort comparison, so NULLs compare equal,\n** NULLs are less than numbers, numbers are less than strings,\n** and strings are less than blobs.\n*/\ncase OP_Compare: {\n  int n;\n  int i;\n  int p1;\n  int p2;\n  const KeyInfo *pKeyInfo;\n  int idx;\n  CollSeq *pColl;    /* Collating sequence to use on this term */\n  int bRev;          /* True for DESCENDING sort order */\n  int *aPermute;     /* The permutation */\n\n  if( (pOp->p5 & OPFLAG_PERMUTE)==0 ){\n    aPermute = 0;\n  }else{\n    assert( pOp>aOp );\n    assert( pOp[-1].opcode==OP_Permutation );\n    assert( pOp[-1].p4type==P4_INTARRAY );\n    aPermute = pOp[-1].p4.ai + 1;\n    assert( aPermute!=0 );\n  }\n  n = pOp->p3;\n  pKeyInfo = pOp->p4.pKeyInfo;\n  assert( n>0 );\n  assert( pKeyInfo!=0 );\n  p1 = pOp->p1;\n  p2 = pOp->p2;\n#ifdef SQLITE_DEBUG\n  if( aPermute ){\n    int k, mx = 0;\n    for(k=0; k<n; k++) if( aPermute[k]>mx ) mx = aPermute[k];\n    assert( p1>0 && p1+mx<=(p->nMem+1 - p->nCursor)+1 );\n    assert( p2>0 && p2+mx<=(p->nMem+1 - p->nCursor)+1 );\n  }else{\n    assert( p1>0 && p1+n<=(p->nMem+1 - p->nCursor)+1 );\n    assert( p2>0 && p2+n<=(p->nMem+1 - p->nCursor)+1 );\n  }\n#endif /* SQLITE_DEBUG */\n  for(i=0; i<n; i++){\n    idx = aPermute ? aPermute[i] : i;\n    assert( memIsValid(&aMem[p1+idx]) );\n    assert( memIsValid(&aMem[p2+idx]) );\n    REGISTER_TRACE(p1+idx, &aMem[p1+idx]);\n    REGISTER_TRACE(p2+idx, &aMem[p2+idx]);\n    assert( i<pKeyInfo->nKeyField );\n    pColl = pKeyInfo->aColl[i];\n    bRev = pKeyInfo->aSortOrder[i];\n    iCompare = sqlite3MemCompare(&aMem[p1+idx], &aMem[p2+idx], pColl);\n    if( iCompare ){\n      if( bRev ) iCompare = -iCompare;\n      break;\n    }\n  }\n  break;\n}\n\n/* Opcode: Jump P1 P2 P3 * *\n**\n** Jump to the instruction at address P1, P2, or P3 depending on whether\n** in the most recent OP_Compare instruction the P1 vector was less than\n** equal to, or greater than the P2 vector, respectively.\n*/\ncase OP_Jump: {             /* jump */\n  if( iCompare<0 ){\n    VdbeBranchTaken(0,4); pOp = &aOp[pOp->p1 - 1];\n  }else if( iCompare==0 ){\n    VdbeBranchTaken(1,4); pOp = &aOp[pOp->p2 - 1];\n  }else{\n    VdbeBranchTaken(2,4); pOp = &aOp[pOp->p3 - 1];\n  }\n  break;\n}\n\n/* Opcode: And P1 P2 P3 * *\n** Synopsis: r[P3]=(r[P1] && r[P2])\n**\n** Take the logical AND of the values in registers P1 and P2 and\n** write the result into register P3.\n**\n** If either P1 or P2 is 0 (false) then the result is 0 even if\n** the other input is NULL.  A NULL and true or two NULLs give\n** a NULL output.\n*/\n/* Opcode: Or P1 P2 P3 * *\n** Synopsis: r[P3]=(r[P1] || r[P2])\n**\n** Take the logical OR of the values in register P1 and P2 and\n** store the answer in register P3.\n**\n** If either P1 or P2 is nonzero (true) then the result is 1 (true)\n** even if the other input is NULL.  A NULL and false or two NULLs\n** give a NULL output.\n*/\ncase OP_And:              /* same as TK_AND, in1, in2, out3 */\ncase OP_Or: {             /* same as TK_OR, in1, in2, out3 */\n  int v1;    /* Left operand:  0==FALSE, 1==TRUE, 2==UNKNOWN or NULL */\n  int v2;    /* Right operand: 0==FALSE, 1==TRUE, 2==UNKNOWN or NULL */\n\n  v1 = sqlite3VdbeBooleanValue(&aMem[pOp->p1], 2);\n  v2 = sqlite3VdbeBooleanValue(&aMem[pOp->p2], 2);\n  if( pOp->opcode==OP_And ){\n    static const unsigned char and_logic[] = { 0, 0, 0, 0, 1, 2, 0, 2, 2 };\n    v1 = and_logic[v1*3+v2];\n  }else{\n    static const unsigned char or_logic[] = { 0, 1, 2, 1, 1, 1, 2, 1, 2 };\n    v1 = or_logic[v1*3+v2];\n  }\n  pOut = &aMem[pOp->p3];\n  if( v1==2 ){\n    MemSetTypeFlag(pOut, MEM_Null);\n  }else{\n    pOut->u.i = v1;\n    MemSetTypeFlag(pOut, MEM_Int);\n  }\n  break;\n}\n\n/* Opcode: IsTrue P1 P2 P3 P4 *\n** Synopsis: r[P2] = coalesce(r[P1]==TRUE,P3) ^ P4\n**\n** This opcode implements the IS TRUE, IS FALSE, IS NOT TRUE, and\n** IS NOT FALSE operators.\n**\n** Interpret the value in register P1 as a boolean value.  Store that\n** boolean (a 0 or 1) in register P2.  Or if the value in register P1 is \n** NULL, then the P3 is stored in register P2.  Invert the answer if P4\n** is 1.\n**\n** The logic is summarized like this:\n**\n** <ul> \n** <li> If P3==0 and P4==0  then  r[P2] := r[P1] IS TRUE\n** <li> If P3==1 and P4==1  then  r[P2] := r[P1] IS FALSE\n** <li> If P3==0 and P4==1  then  r[P2] := r[P1] IS NOT TRUE\n** <li> If P3==1 and P4==0  then  r[P2] := r[P1] IS NOT FALSE\n** </ul>\n*/\ncase OP_IsTrue: {               /* in1, out2 */\n  assert( pOp->p4type==P4_INT32 );\n  assert( pOp->p4.i==0 || pOp->p4.i==1 );\n  assert( pOp->p3==0 || pOp->p3==1 );\n  sqlite3VdbeMemSetInt64(&aMem[pOp->p2],\n      sqlite3VdbeBooleanValue(&aMem[pOp->p1], pOp->p3) ^ pOp->p4.i);\n  break;\n}\n\n/* Opcode: Not P1 P2 * * *\n** Synopsis: r[P2]= !r[P1]\n**\n** Interpret the value in register P1 as a boolean value.  Store the\n** boolean complement in register P2.  If the value in register P1 is \n** NULL, then a NULL is stored in P2.\n*/\ncase OP_Not: {                /* same as TK_NOT, in1, out2 */\n  pIn1 = &aMem[pOp->p1];\n  pOut = &aMem[pOp->p2];\n  if( (pIn1->flags & MEM_Null)==0 ){\n    sqlite3VdbeMemSetInt64(pOut, !sqlite3VdbeBooleanValue(pIn1,0));\n  }else{\n    sqlite3VdbeMemSetNull(pOut);\n  }\n  break;\n}\n\n/* Opcode: BitNot P1 P2 * * *\n** Synopsis: r[P2]= ~r[P1]\n**\n** Interpret the content of register P1 as an integer.  Store the\n** ones-complement of the P1 value into register P2.  If P1 holds\n** a NULL then store a NULL in P2.\n*/\ncase OP_BitNot: {             /* same as TK_BITNOT, in1, out2 */\n  pIn1 = &aMem[pOp->p1];\n  pOut = &aMem[pOp->p2];\n  sqlite3VdbeMemSetNull(pOut);\n  if( (pIn1->flags & MEM_Null)==0 ){\n    pOut->flags = MEM_Int;\n    pOut->u.i = ~sqlite3VdbeIntValue(pIn1);\n  }\n  break;\n}\n\n/* Opcode: Once P1 P2 * * *\n**\n** Fall through to the next instruction the first time this opcode is\n** encountered on each invocation of the byte-code program.  Jump to P2\n** on the second and all subsequent encounters during the same invocation.\n**\n** Top-level programs determine first invocation by comparing the P1\n** operand against the P1 operand on the OP_Init opcode at the beginning\n** of the program.  If the P1 values differ, then fall through and make\n** the P1 of this opcode equal to the P1 of OP_Init.  If P1 values are\n** the same then take the jump.\n**\n** For subprograms, there is a bitmask in the VdbeFrame that determines\n** whether or not the jump should be taken.  The bitmask is necessary\n** because the self-altering code trick does not work for recursive\n** triggers.\n*/\ncase OP_Once: {             /* jump */\n  u32 iAddr;                /* Address of this instruction */\n  assert( p->aOp[0].opcode==OP_Init );\n  if( p->pFrame ){\n    iAddr = (int)(pOp - p->aOp);\n    if( (p->pFrame->aOnce[iAddr/8] & (1<<(iAddr & 7)))!=0 ){\n      VdbeBranchTaken(1, 2);\n      goto jump_to_p2;\n    }\n    p->pFrame->aOnce[iAddr/8] |= 1<<(iAddr & 7);\n  }else{\n    if( p->aOp[0].p1==pOp->p1 ){\n      VdbeBranchTaken(1, 2);\n      goto jump_to_p2;\n    }\n  }\n  VdbeBranchTaken(0, 2);\n  pOp->p1 = p->aOp[0].p1;\n  break;\n}\n\n/* Opcode: If P1 P2 P3 * *\n**\n** Jump to P2 if the value in register P1 is true.  The value\n** is considered true if it is numeric and non-zero.  If the value\n** in P1 is NULL then take the jump if and only if P3 is non-zero.\n*/\ncase OP_If:  {               /* jump, in1 */\n  int c;\n  c = sqlite3VdbeBooleanValue(&aMem[pOp->p1], pOp->p3);\n  VdbeBranchTaken(c!=0, 2);\n  if( c ) goto jump_to_p2;\n  break;\n}\n\n/* Opcode: IfNot P1 P2 P3 * *\n**\n** Jump to P2 if the value in register P1 is False.  The value\n** is considered false if it has a numeric value of zero.  If the value\n** in P1 is NULL then take the jump if and only if P3 is non-zero.\n*/\ncase OP_IfNot: {            /* jump, in1 */\n  int c;\n  c = !sqlite3VdbeBooleanValue(&aMem[pOp->p1], !pOp->p3);\n  VdbeBranchTaken(c!=0, 2);\n  if( c ) goto jump_to_p2;\n  break;\n}\n\n/* Opcode: IsNull P1 P2 * * *\n** Synopsis: if r[P1]==NULL goto P2\n**\n** Jump to P2 if the value in register P1 is NULL.\n*/\ncase OP_IsNull: {            /* same as TK_ISNULL, jump, in1 */\n  pIn1 = &aMem[pOp->p1];\n  VdbeBranchTaken( (pIn1->flags & MEM_Null)!=0, 2);\n  if( (pIn1->flags & MEM_Null)!=0 ){\n    goto jump_to_p2;\n  }\n  break;\n}\n\n/* Opcode: NotNull P1 P2 * * *\n** Synopsis: if r[P1]!=NULL goto P2\n**\n** Jump to P2 if the value in register P1 is not NULL.  \n*/\ncase OP_NotNull: {            /* same as TK_NOTNULL, jump, in1 */\n  pIn1 = &aMem[pOp->p1];\n  VdbeBranchTaken( (pIn1->flags & MEM_Null)==0, 2);\n  if( (pIn1->flags & MEM_Null)==0 ){\n    goto jump_to_p2;\n  }\n  break;\n}\n\n/* Opcode: IfNullRow P1 P2 P3 * *\n** Synopsis: if P1.nullRow then r[P3]=NULL, goto P2\n**\n** Check the cursor P1 to see if it is currently pointing at a NULL row.\n** If it is, then set register P3 to NULL and jump immediately to P2.\n** If P1 is not on a NULL row, then fall through without making any\n** changes.\n*/\ncase OP_IfNullRow: {         /* jump */\n  assert( pOp->p1>=0 && pOp->p1<p->nCursor );\n  assert( p->apCsr[pOp->p1]!=0 );\n  if( p->apCsr[pOp->p1]->nullRow ){\n    sqlite3VdbeMemSetNull(aMem + pOp->p3);\n    goto jump_to_p2;\n  }\n  break;\n}\n\n#ifdef SQLITE_ENABLE_OFFSET_SQL_FUNC\n/* Opcode: Offset P1 P2 P3 * *\n** Synopsis: r[P3] = sqlite_offset(P1)\n**\n** Store in register r[P3] the byte offset into the database file that is the\n** start of the payload for the record at which that cursor P1 is currently\n** pointing.\n**\n** P2 is the column number for the argument to the sqlite_offset() function.\n** This opcode does not use P2 itself, but the P2 value is used by the\n** code generator.  The P1, P2, and P3 operands to this opcode are the\n** same as for OP_Column.\n**\n** This opcode is only available if SQLite is compiled with the\n** -DSQLITE_ENABLE_OFFSET_SQL_FUNC option.\n*/\ncase OP_Offset: {          /* out3 */\n  VdbeCursor *pC;    /* The VDBE cursor */\n  assert( pOp->p1>=0 && pOp->p1<p->nCursor );\n  pC = p->apCsr[pOp->p1];\n  pOut = &p->aMem[pOp->p3];\n  if( NEVER(pC==0) || pC->eCurType!=CURTYPE_BTREE ){\n    sqlite3VdbeMemSetNull(pOut);\n  }else{\n    sqlite3VdbeMemSetInt64(pOut, sqlite3BtreeOffset(pC->uc.pCursor));\n  }\n  break;\n}\n#endif /* SQLITE_ENABLE_OFFSET_SQL_FUNC */\n\n/* Opcode: Column P1 P2 P3 P4 P5\n** Synopsis: r[P3]=PX\n**\n** Interpret the data that cursor P1 points to as a structure built using\n** the MakeRecord instruction.  (See the MakeRecord opcode for additional\n** information about the format of the data.)  Extract the P2-th column\n** from this record.  If there are less that (P2+1) \n** values in the record, extract a NULL.\n**\n** The value extracted is stored in register P3.\n**\n** If the record contains fewer than P2 fields, then extract a NULL.  Or,\n** if the P4 argument is a P4_MEM use the value of the P4 argument as\n** the result.\n**\n** If the OPFLAG_CLEARCACHE bit is set on P5 and P1 is a pseudo-table cursor,\n** then the cache of the cursor is reset prior to extracting the column.\n** The first OP_Column against a pseudo-table after the value of the content\n** register has changed should have this bit set.\n**\n** If the OPFLAG_LENGTHARG and OPFLAG_TYPEOFARG bits are set on P5 then\n** the result is guaranteed to only be used as the argument of a length()\n** or typeof() function, respectively.  The loading of large blobs can be\n** skipped for length() and all content loading can be skipped for typeof().\n*/\ncase OP_Column: {\n  int p2;            /* column number to retrieve */\n  VdbeCursor *pC;    /* The VDBE cursor */\n  BtCursor *pCrsr;   /* The BTree cursor */\n  u32 *aOffset;      /* aOffset[i] is offset to start of data for i-th column */\n  int len;           /* The length of the serialized data for the column */\n  int i;             /* Loop counter */\n  Mem *pDest;        /* Where to write the extracted value */\n  Mem sMem;          /* For storing the record being decoded */\n  const u8 *zData;   /* Part of the record being decoded */\n  const u8 *zHdr;    /* Next unparsed byte of the header */\n  const u8 *zEndHdr; /* Pointer to first byte after the header */\n  u64 offset64;      /* 64-bit offset */\n  u32 t;             /* A type code from the record header */\n  Mem *pReg;         /* PseudoTable input register */\n\n  pC = p->apCsr[pOp->p1];\n  p2 = pOp->p2;\n\n  /* If the cursor cache is stale (meaning it is not currently point at\n  ** the correct row) then bring it up-to-date by doing the necessary \n  ** B-Tree seek. */\n  rc = sqlite3VdbeCursorMoveto(&pC, &p2);\n  if( rc ) goto abort_due_to_error;\n\n  assert( pOp->p3>0 && pOp->p3<=(p->nMem+1 - p->nCursor) );\n  pDest = &aMem[pOp->p3];\n  memAboutToChange(p, pDest);\n  assert( pOp->p1>=0 && pOp->p1<p->nCursor );\n  assert( pC!=0 );\n  assert( p2<pC->nField );\n  aOffset = pC->aOffset;\n  assert( pC->eCurType!=CURTYPE_VTAB );\n  assert( pC->eCurType!=CURTYPE_PSEUDO || pC->nullRow );\n  assert( pC->eCurType!=CURTYPE_SORTER );\n\n  if( pC->cacheStatus!=p->cacheCtr ){                /*OPTIMIZATION-IF-FALSE*/\n    if( pC->nullRow ){\n      if( pC->eCurType==CURTYPE_PSEUDO ){\n        /* For the special case of as pseudo-cursor, the seekResult field\n        ** identifies the register that holds the record */\n        assert( pC->seekResult>0 );\n        pReg = &aMem[pC->seekResult];\n        assert( pReg->flags & MEM_Blob );\n        assert( memIsValid(pReg) );\n        pC->payloadSize = pC->szRow = pReg->n;\n        pC->aRow = (u8*)pReg->z;\n      }else{\n        sqlite3VdbeMemSetNull(pDest);\n        goto op_column_out;\n      }\n    }else{\n      pCrsr = pC->uc.pCursor;\n      assert( pC->eCurType==CURTYPE_BTREE );\n      assert( pCrsr );\n      assert( sqlite3BtreeCursorIsValid(pCrsr) );\n      pC->payloadSize = sqlite3BtreePayloadSize(pCrsr);\n      pC->aRow = sqlite3BtreePayloadFetch(pCrsr, &pC->szRow);\n      assert( pC->szRow<=pC->payloadSize );\n      assert( pC->szRow<=65536 );  /* Maximum page size is 64KiB */\n      if( pC->payloadSize > (u32)db->aLimit[SQLITE_LIMIT_LENGTH] ){\n        goto too_big;\n      }\n    }\n    pC->cacheStatus = p->cacheCtr;\n    pC->iHdrOffset = getVarint32(pC->aRow, aOffset[0]);\n    pC->nHdrParsed = 0;\n\n\n    if( pC->szRow<aOffset[0] ){      /*OPTIMIZATION-IF-FALSE*/\n      /* pC->aRow does not have to hold the entire row, but it does at least\n      ** need to cover the header of the record.  If pC->aRow does not contain\n      ** the complete header, then set it to zero, forcing the header to be\n      ** dynamically allocated. */\n      pC->aRow = 0;\n      pC->szRow = 0;\n\n      /* Make sure a corrupt database has not given us an oversize header.\n      ** Do this now to avoid an oversize memory allocation.\n      **\n      ** Type entries can be between 1 and 5 bytes each.  But 4 and 5 byte\n      ** types use so much data space that there can only be 4096 and 32 of\n      ** them, respectively.  So the maximum header length results from a\n      ** 3-byte type for each of the maximum of 32768 columns plus three\n      ** extra bytes for the header length itself.  32768*3 + 3 = 98307.\n      */\n      if( aOffset[0] > 98307 || aOffset[0] > pC->payloadSize ){\n        goto op_column_corrupt;\n      }\n    }else{\n      /* This is an optimization.  By skipping over the first few tests\n      ** (ex: pC->nHdrParsed<=p2) in the next section, we achieve a\n      ** measurable performance gain.\n      **\n      ** This branch is taken even if aOffset[0]==0.  Such a record is never\n      ** generated by SQLite, and could be considered corruption, but we\n      ** accept it for historical reasons.  When aOffset[0]==0, the code this\n      ** branch jumps to reads past the end of the record, but never more\n      ** than a few bytes.  Even if the record occurs at the end of the page\n      ** content area, the \"page header\" comes after the page content and so\n      ** this overread is harmless.  Similar overreads can occur for a corrupt\n      ** database file.\n      */\n      zData = pC->aRow;\n      assert( pC->nHdrParsed<=p2 );         /* Conditional skipped */\n      testcase( aOffset[0]==0 );\n      goto op_column_read_header;\n    }\n  }\n\n  /* Make sure at least the first p2+1 entries of the header have been\n  ** parsed and valid information is in aOffset[] and pC->aType[].\n  */\n  if( pC->nHdrParsed<=p2 ){\n    /* If there is more header available for parsing in the record, try\n    ** to extract additional fields up through the p2+1-th field \n    */\n    if( pC->iHdrOffset<aOffset[0] ){\n      /* Make sure zData points to enough of the record to cover the header. */\n      if( pC->aRow==0 ){\n        memset(&sMem, 0, sizeof(sMem));\n        rc = sqlite3VdbeMemFromBtree(pC->uc.pCursor, 0, aOffset[0], &sMem);\n        if( rc!=SQLITE_OK ) goto abort_due_to_error;\n        zData = (u8*)sMem.z;\n      }else{\n        zData = pC->aRow;\n      }\n  \n      /* Fill in pC->aType[i] and aOffset[i] values through the p2-th field. */\n    op_column_read_header:\n      i = pC->nHdrParsed;\n      offset64 = aOffset[i];\n      zHdr = zData + pC->iHdrOffset;\n      zEndHdr = zData + aOffset[0];\n      testcase( zHdr>=zEndHdr );\n      do{\n        if( (t = zHdr[0])<0x80 ){\n          zHdr++;\n          offset64 += sqlite3VdbeOneByteSerialTypeLen(t);\n        }else{\n          zHdr += sqlite3GetVarint32(zHdr, &t);\n          offset64 += sqlite3VdbeSerialTypeLen(t);\n        }\n        pC->aType[i++] = t;\n        aOffset[i] = (u32)(offset64 & 0xffffffff);\n      }while( i<=p2 && zHdr<zEndHdr );\n\n      /* The record is corrupt if any of the following are true:\n      ** (1) the bytes of the header extend past the declared header size\n      ** (2) the entire header was used but not all data was used\n      ** (3) the end of the data extends beyond the end of the record.\n      */\n      if( (zHdr>=zEndHdr && (zHdr>zEndHdr || offset64!=pC->payloadSize))\n       || (offset64 > pC->payloadSize)\n      ){\n        if( aOffset[0]==0 ){\n          i = 0;\n          zHdr = zEndHdr;\n        }else{\n          if( pC->aRow==0 ) sqlite3VdbeMemRelease(&sMem);\n          goto op_column_corrupt;\n        }\n      }\n\n      pC->nHdrParsed = i;\n      pC->iHdrOffset = (u32)(zHdr - zData);\n      if( pC->aRow==0 ) sqlite3VdbeMemRelease(&sMem);\n    }else{\n      t = 0;\n    }\n\n    /* If after trying to extract new entries from the header, nHdrParsed is\n    ** still not up to p2, that means that the record has fewer than p2\n    ** columns.  So the result will be either the default value or a NULL.\n    */\n    if( pC->nHdrParsed<=p2 ){\n      if( pOp->p4type==P4_MEM ){\n        sqlite3VdbeMemShallowCopy(pDest, pOp->p4.pMem, MEM_Static);\n      }else{\n        sqlite3VdbeMemSetNull(pDest);\n      }\n      goto op_column_out;\n    }\n  }else{\n    t = pC->aType[p2];\n  }\n\n  /* Extract the content for the p2+1-th column.  Control can only\n  ** reach this point if aOffset[p2], aOffset[p2+1], and pC->aType[p2] are\n  ** all valid.\n  */\n  assert( p2<pC->nHdrParsed );\n  assert( rc==SQLITE_OK );\n  assert( sqlite3VdbeCheckMemInvariants(pDest) );\n  if( VdbeMemDynamic(pDest) ){\n    sqlite3VdbeMemSetNull(pDest);\n  }\n  assert( t==pC->aType[p2] );\n  if( pC->szRow>=aOffset[p2+1] ){\n    /* This is the common case where the desired content fits on the original\n    ** page - where the content is not on an overflow page */\n    zData = pC->aRow + aOffset[p2];\n    if( t<12 ){\n      sqlite3VdbeSerialGet(zData, t, pDest);\n    }else{\n      /* If the column value is a string, we need a persistent value, not\n      ** a MEM_Ephem value.  This branch is a fast short-cut that is equivalent\n      ** to calling sqlite3VdbeSerialGet() and sqlite3VdbeDeephemeralize().\n      */\n      static const u16 aFlag[] = { MEM_Blob, MEM_Str|MEM_Term };\n      pDest->n = len = (t-12)/2;\n      pDest->enc = encoding;\n      if( pDest->szMalloc < len+2 ){\n        pDest->flags = MEM_Null;\n        if( sqlite3VdbeMemGrow(pDest, len+2, 0) ) goto no_mem;\n      }else{\n        pDest->z = pDest->zMalloc;\n      }\n      memcpy(pDest->z, zData, len);\n      pDest->z[len] = 0;\n      pDest->z[len+1] = 0;\n      pDest->flags = aFlag[t&1];\n    }\n  }else{\n    pDest->enc = encoding;\n    /* This branch happens only when content is on overflow pages */\n    if( ((pOp->p5 & (OPFLAG_LENGTHARG|OPFLAG_TYPEOFARG))!=0\n          && ((t>=12 && (t&1)==0) || (pOp->p5 & OPFLAG_TYPEOFARG)!=0))\n     || (len = sqlite3VdbeSerialTypeLen(t))==0\n    ){\n      /* Content is irrelevant for\n      **    1. the typeof() function,\n      **    2. the length(X) function if X is a blob, and\n      **    3. if the content length is zero.\n      ** So we might as well use bogus content rather than reading\n      ** content from disk. \n      **\n      ** Although sqlite3VdbeSerialGet() may read at most 8 bytes from the\n      ** buffer passed to it, debugging function VdbeMemPrettyPrint() may\n      ** read up to 16. So 16 bytes of bogus content is supplied.\n      */\n      static u8 aZero[16];  /* This is the bogus content */\n      sqlite3VdbeSerialGet(aZero, t, pDest);\n    }else{\n      rc = sqlite3VdbeMemFromBtree(pC->uc.pCursor, aOffset[p2], len, pDest);\n      if( rc!=SQLITE_OK ) goto abort_due_to_error;\n      sqlite3VdbeSerialGet((const u8*)pDest->z, t, pDest);\n      pDest->flags &= ~MEM_Ephem;\n    }\n  }\n\nop_column_out:\n  UPDATE_MAX_BLOBSIZE(pDest);\n  REGISTER_TRACE(pOp->p3, pDest);\n  break;\n\nop_column_corrupt:\n  if( aOp[0].p3>0 ){\n    pOp = &aOp[aOp[0].p3-1];\n    break;\n  }else{\n    rc = SQLITE_CORRUPT_BKPT;\n    goto abort_due_to_error;\n  }\n}\n\n/* Opcode: Affinity P1 P2 * P4 *\n** Synopsis: affinity(r[P1@P2])\n**\n** Apply affinities to a range of P2 registers starting with P1.\n**\n** P4 is a string that is P2 characters long. The N-th character of the\n** string indicates the column affinity that should be used for the N-th\n** memory cell in the range.\n*/\ncase OP_Affinity: {\n  const char *zAffinity;   /* The affinity to be applied */\n\n  zAffinity = pOp->p4.z;\n  assert( zAffinity!=0 );\n  assert( pOp->p2>0 );\n  assert( zAffinity[pOp->p2]==0 );\n  pIn1 = &aMem[pOp->p1];\n  do{\n    assert( pIn1 <= &p->aMem[(p->nMem+1 - p->nCursor)] );\n    assert( memIsValid(pIn1) );\n    applyAffinity(pIn1, *(zAffinity++), encoding);\n    pIn1++;\n  }while( zAffinity[0] );\n  break;\n}\n\n/* Opcode: MakeRecord P1 P2 P3 P4 *\n** Synopsis: r[P3]=mkrec(r[P1@P2])\n**\n** Convert P2 registers beginning with P1 into the [record format]\n** use as a data record in a database table or as a key\n** in an index.  The OP_Column opcode can decode the record later.\n**\n** P4 may be a string that is P2 characters long.  The N-th character of the\n** string indicates the column affinity that should be used for the N-th\n** field of the index key.\n**\n** The mapping from character to affinity is given by the SQLITE_AFF_\n** macros defined in sqliteInt.h.\n**\n** If P4 is NULL then all index fields have the affinity BLOB.\n*/\ncase OP_MakeRecord: {\n  u8 *zNewRecord;        /* A buffer to hold the data for the new record */\n  Mem *pRec;             /* The new record */\n  u64 nData;             /* Number of bytes of data space */\n  int nHdr;              /* Number of bytes of header space */\n  i64 nByte;             /* Data space required for this record */\n  i64 nZero;             /* Number of zero bytes at the end of the record */\n  int nVarint;           /* Number of bytes in a varint */\n  u32 serial_type;       /* Type field */\n  Mem *pData0;           /* First field to be combined into the record */\n  Mem *pLast;            /* Last field of the record */\n  int nField;            /* Number of fields in the record */\n  char *zAffinity;       /* The affinity string for the record */\n  int file_format;       /* File format to use for encoding */\n  int i;                 /* Space used in zNewRecord[] header */\n  int j;                 /* Space used in zNewRecord[] content */\n  u32 len;               /* Length of a field */\n\n  /* Assuming the record contains N fields, the record format looks\n  ** like this:\n  **\n  ** ------------------------------------------------------------------------\n  ** | hdr-size | type 0 | type 1 | ... | type N-1 | data0 | ... | data N-1 | \n  ** ------------------------------------------------------------------------\n  **\n  ** Data(0) is taken from register P1.  Data(1) comes from register P1+1\n  ** and so forth.\n  **\n  ** Each type field is a varint representing the serial type of the \n  ** corresponding data element (see sqlite3VdbeSerialType()). The\n  ** hdr-size field is also a varint which is the offset from the beginning\n  ** of the record to data0.\n  */\n  nData = 0;         /* Number of bytes of data space */\n  nHdr = 0;          /* Number of bytes of header space */\n  nZero = 0;         /* Number of zero bytes at the end of the record */\n  nField = pOp->p1;\n  zAffinity = pOp->p4.z;\n  assert( nField>0 && pOp->p2>0 && pOp->p2+nField<=(p->nMem+1 - p->nCursor)+1 );\n  pData0 = &aMem[nField];\n  nField = pOp->p2;\n  pLast = &pData0[nField-1];\n  file_format = p->minWriteFileFormat;\n\n  /* Identify the output register */\n  assert( pOp->p3<pOp->p1 || pOp->p3>=pOp->p1+pOp->p2 );\n  pOut = &aMem[pOp->p3];\n  memAboutToChange(p, pOut);\n\n  /* Apply the requested affinity to all inputs\n  */\n  assert( pData0<=pLast );\n  if( zAffinity ){\n    pRec = pData0;\n    do{\n      applyAffinity(pRec++, *(zAffinity++), encoding);\n      assert( zAffinity[0]==0 || pRec<=pLast );\n    }while( zAffinity[0] );\n  }\n\n#ifdef SQLITE_ENABLE_NULL_TRIM\n  /* NULLs can be safely trimmed from the end of the record, as long as\n  ** as the schema format is 2 or more and none of the omitted columns\n  ** have a non-NULL default value.  Also, the record must be left with\n  ** at least one field.  If P5>0 then it will be one more than the\n  ** index of the right-most column with a non-NULL default value */\n  if( pOp->p5 ){\n    while( (pLast->flags & MEM_Null)!=0 && nField>pOp->p5 ){\n      pLast--;\n      nField--;\n    }\n  }\n#endif\n\n  /* Loop through the elements that will make up the record to figure\n  ** out how much space is required for the new record.\n  */\n  pRec = pLast;\n  do{\n    assert( memIsValid(pRec) );\n    serial_type = sqlite3VdbeSerialType(pRec, file_format, &len);\n    if( pRec->flags & MEM_Zero ){\n      if( serial_type==0 ){\n        /* Values with MEM_Null and MEM_Zero are created by xColumn virtual\n        ** table methods that never invoke sqlite3_result_xxxxx() while\n        ** computing an unchanging column value in an UPDATE statement.\n        ** Give such values a special internal-use-only serial-type of 10\n        ** so that they can be passed through to xUpdate and have\n        ** a true sqlite3_value_nochange(). */\n        assert( pOp->p5==OPFLAG_NOCHNG_MAGIC || CORRUPT_DB );\n        serial_type = 10;\n      }else if( nData ){\n        if( sqlite3VdbeMemExpandBlob(pRec) ) goto no_mem;\n      }else{\n        nZero += pRec->u.nZero;\n        len -= pRec->u.nZero;\n      }\n    }\n    nData += len;\n    testcase( serial_type==127 );\n    testcase( serial_type==128 );\n    nHdr += serial_type<=127 ? 1 : sqlite3VarintLen(serial_type);\n    pRec->uTemp = serial_type;\n    if( pRec==pData0 ) break;\n    pRec--;\n  }while(1);\n\n  /* EVIDENCE-OF: R-22564-11647 The header begins with a single varint\n  ** which determines the total number of bytes in the header. The varint\n  ** value is the size of the header in bytes including the size varint\n  ** itself. */\n  testcase( nHdr==126 );\n  testcase( nHdr==127 );\n  if( nHdr<=126 ){\n    /* The common case */\n    nHdr += 1;\n  }else{\n    /* Rare case of a really large header */\n    nVarint = sqlite3VarintLen(nHdr);\n    nHdr += nVarint;\n    if( nVarint<sqlite3VarintLen(nHdr) ) nHdr++;\n  }\n  nByte = nHdr+nData;\n\n  /* Make sure the output register has a buffer large enough to store \n  ** the new record. The output register (pOp->p3) is not allowed to\n  ** be one of the input registers (because the following call to\n  ** sqlite3VdbeMemClearAndResize() could clobber the value before it is used).\n  */\n  if( nByte+nZero<=pOut->szMalloc ){\n    /* The output register is already large enough to hold the record.\n    ** No error checks or buffer enlargement is required */\n    pOut->z = pOut->zMalloc;\n  }else{\n    /* Need to make sure that the output is not too big and then enlarge\n    ** the output register to hold the full result */\n    if( nByte+nZero>db->aLimit[SQLITE_LIMIT_LENGTH] ){\n      goto too_big;\n    }\n    if( sqlite3VdbeMemClearAndResize(pOut, (int)nByte) ){\n      goto no_mem;\n    }\n  }\n  zNewRecord = (u8 *)pOut->z;\n\n  /* Write the record */\n  i = putVarint32(zNewRecord, nHdr);\n  j = nHdr;\n  assert( pData0<=pLast );\n  pRec = pData0;\n  do{\n    serial_type = pRec->uTemp;\n    /* EVIDENCE-OF: R-06529-47362 Following the size varint are one or more\n    ** additional varints, one per column. */\n    i += putVarint32(&zNewRecord[i], serial_type);            /* serial type */\n    /* EVIDENCE-OF: R-64536-51728 The values for each column in the record\n    ** immediately follow the header. */\n    j += sqlite3VdbeSerialPut(&zNewRecord[j], pRec, serial_type); /* content */\n  }while( (++pRec)<=pLast );\n  assert( i==nHdr );\n  assert( j==nByte );\n\n  assert( pOp->p3>0 && pOp->p3<=(p->nMem+1 - p->nCursor) );\n  pOut->n = (int)nByte;\n  pOut->flags = MEM_Blob;\n  if( nZero ){\n    pOut->u.nZero = nZero;\n    pOut->flags |= MEM_Zero;\n  }\n  REGISTER_TRACE(pOp->p3, pOut);\n  UPDATE_MAX_BLOBSIZE(pOut);\n  break;\n}\n\n/* Opcode: Count P1 P2 * * *\n** Synopsis: r[P2]=count()\n**\n** Store the number of entries (an integer value) in the table or index \n** opened by cursor P1 in register P2\n*/\n#ifndef SQLITE_OMIT_BTREECOUNT\ncase OP_Count: {         /* out2 */\n  i64 nEntry;\n  BtCursor *pCrsr;\n\n  assert( p->apCsr[pOp->p1]->eCurType==CURTYPE_BTREE );\n  pCrsr = p->apCsr[pOp->p1]->uc.pCursor;\n  assert( pCrsr );\n  nEntry = 0;  /* Not needed.  Only used to silence a warning. */\n  rc = sqlite3BtreeCount(pCrsr, &nEntry);\n  if( rc ) goto abort_due_to_error;\n  pOut = out2Prerelease(p, pOp);\n  pOut->u.i = nEntry;\n  break;\n}\n#endif\n\n/* Opcode: Savepoint P1 * * P4 *\n**\n** Open, release or rollback the savepoint named by parameter P4, depending\n** on the value of P1. To open a new savepoint, P1==0. To release (commit) an\n** existing savepoint, P1==1, or to rollback an existing savepoint P1==2.\n*/\ncase OP_Savepoint: {\n  int p1;                         /* Value of P1 operand */\n  char *zName;                    /* Name of savepoint */\n  int nName;\n  Savepoint *pNew;\n  Savepoint *pSavepoint;\n  Savepoint *pTmp;\n  int iSavepoint;\n  int ii;\n\n  p1 = pOp->p1;\n  zName = pOp->p4.z;\n\n  /* Assert that the p1 parameter is valid. Also that if there is no open\n  ** transaction, then there cannot be any savepoints. \n  */\n  assert( db->pSavepoint==0 || db->autoCommit==0 );\n  assert( p1==SAVEPOINT_BEGIN||p1==SAVEPOINT_RELEASE||p1==SAVEPOINT_ROLLBACK );\n  assert( db->pSavepoint || db->isTransactionSavepoint==0 );\n  assert( checkSavepointCount(db) );\n  assert( p->bIsReader );\n\n  if( p1==SAVEPOINT_BEGIN ){\n    if( db->nVdbeWrite>0 ){\n      /* A new savepoint cannot be created if there are active write \n      ** statements (i.e. open read/write incremental blob handles).\n      */\n      sqlite3VdbeError(p, \"cannot open savepoint - SQL statements in progress\");\n      rc = SQLITE_BUSY;\n    }else{\n      nName = sqlite3Strlen30(zName);\n\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n      /* This call is Ok even if this savepoint is actually a transaction\n      ** savepoint (and therefore should not prompt xSavepoint()) callbacks.\n      ** If this is a transaction savepoint being opened, it is guaranteed\n      ** that the db->aVTrans[] array is empty.  */\n      assert( db->autoCommit==0 || db->nVTrans==0 );\n      rc = sqlite3VtabSavepoint(db, SAVEPOINT_BEGIN,\n                                db->nStatement+db->nSavepoint);\n      if( rc!=SQLITE_OK ) goto abort_due_to_error;\n#endif\n\n      /* Create a new savepoint structure. */\n      pNew = sqlite3DbMallocRawNN(db, sizeof(Savepoint)+nName+1);\n      if( pNew ){\n        pNew->zName = (char *)&pNew[1];\n        memcpy(pNew->zName, zName, nName+1);\n    \n        /* If there is no open transaction, then mark this as a special\n        ** \"transaction savepoint\". */\n        if( db->autoCommit ){\n          db->autoCommit = 0;\n          db->isTransactionSavepoint = 1;\n        }else{\n          db->nSavepoint++;\n        }\n\n        /* Link the new savepoint into the database handle's list. */\n        pNew->pNext = db->pSavepoint;\n        db->pSavepoint = pNew;\n        pNew->nDeferredCons = db->nDeferredCons;\n        pNew->nDeferredImmCons = db->nDeferredImmCons;\n      }\n    }\n  }else{\n    iSavepoint = 0;\n\n    /* Find the named savepoint. If there is no such savepoint, then an\n    ** an error is returned to the user.  */\n    for(\n      pSavepoint = db->pSavepoint; \n      pSavepoint && sqlite3StrICmp(pSavepoint->zName, zName);\n      pSavepoint = pSavepoint->pNext\n    ){\n      iSavepoint++;\n    }\n    if( !pSavepoint ){\n      sqlite3VdbeError(p, \"no such savepoint: %s\", zName);\n      rc = SQLITE_ERROR;\n    }else if( db->nVdbeWrite>0 && p1==SAVEPOINT_RELEASE ){\n      /* It is not possible to release (commit) a savepoint if there are \n      ** active write statements.\n      */\n      sqlite3VdbeError(p, \"cannot release savepoint - \"\n                          \"SQL statements in progress\");\n      rc = SQLITE_BUSY;\n    }else{\n\n      /* Determine whether or not this is a transaction savepoint. If so,\n      ** and this is a RELEASE command, then the current transaction \n      ** is committed. \n      */\n      int isTransaction = pSavepoint->pNext==0 && db->isTransactionSavepoint;\n      if( isTransaction && p1==SAVEPOINT_RELEASE ){\n        if( (rc = sqlite3VdbeCheckFk(p, 1))!=SQLITE_OK ){\n          goto vdbe_return;\n        }\n        db->autoCommit = 1;\n        if( sqlite3VdbeHalt(p)==SQLITE_BUSY ){\n          p->pc = (int)(pOp - aOp);\n          db->autoCommit = 0;\n          p->rc = rc = SQLITE_BUSY;\n          goto vdbe_return;\n        }\n        db->isTransactionSavepoint = 0;\n        rc = p->rc;\n      }else{\n        int isSchemaChange;\n        iSavepoint = db->nSavepoint - iSavepoint - 1;\n        if( p1==SAVEPOINT_ROLLBACK ){\n          isSchemaChange = (db->mDbFlags & DBFLAG_SchemaChange)!=0;\n          for(ii=0; ii<db->nDb; ii++){\n            rc = sqlite3BtreeTripAllCursors(db->aDb[ii].pBt,\n                                       SQLITE_ABORT_ROLLBACK,\n                                       isSchemaChange==0);\n            if( rc!=SQLITE_OK ) goto abort_due_to_error;\n          }\n        }else{\n          isSchemaChange = 0;\n        }\n        for(ii=0; ii<db->nDb; ii++){\n          rc = sqlite3BtreeSavepoint(db->aDb[ii].pBt, p1, iSavepoint);\n          if( rc!=SQLITE_OK ){\n            goto abort_due_to_error;\n          }\n        }\n        if( isSchemaChange ){\n          sqlite3ExpirePreparedStatements(db, 0);\n          sqlite3ResetAllSchemasOfConnection(db);\n          db->mDbFlags |= DBFLAG_SchemaChange;\n        }\n      }\n  \n      /* Regardless of whether this is a RELEASE or ROLLBACK, destroy all \n      ** savepoints nested inside of the savepoint being operated on. */\n      while( db->pSavepoint!=pSavepoint ){\n        pTmp = db->pSavepoint;\n        db->pSavepoint = pTmp->pNext;\n        sqlite3DbFree(db, pTmp);\n        db->nSavepoint--;\n      }\n\n      /* If it is a RELEASE, then destroy the savepoint being operated on \n      ** too. If it is a ROLLBACK TO, then set the number of deferred \n      ** constraint violations present in the database to the value stored\n      ** when the savepoint was created.  */\n      if( p1==SAVEPOINT_RELEASE ){\n        assert( pSavepoint==db->pSavepoint );\n        db->pSavepoint = pSavepoint->pNext;\n        sqlite3DbFree(db, pSavepoint);\n        if( !isTransaction ){\n          db->nSavepoint--;\n        }\n      }else{\n        db->nDeferredCons = pSavepoint->nDeferredCons;\n        db->nDeferredImmCons = pSavepoint->nDeferredImmCons;\n      }\n\n      if( !isTransaction || p1==SAVEPOINT_ROLLBACK ){\n        rc = sqlite3VtabSavepoint(db, p1, iSavepoint);\n        if( rc!=SQLITE_OK ) goto abort_due_to_error;\n      }\n    }\n  }\n  if( rc ) goto abort_due_to_error;\n\n  break;\n}\n\n/* Opcode: AutoCommit P1 P2 * * *\n**\n** Set the database auto-commit flag to P1 (1 or 0). If P2 is true, roll\n** back any currently active btree transactions. If there are any active\n** VMs (apart from this one), then a ROLLBACK fails.  A COMMIT fails if\n** there are active writing VMs or active VMs that use shared cache.\n**\n** This instruction causes the VM to halt.\n*/\ncase OP_AutoCommit: {\n  int desiredAutoCommit;\n  int iRollback;\n\n  desiredAutoCommit = pOp->p1;\n  iRollback = pOp->p2;\n  assert( desiredAutoCommit==1 || desiredAutoCommit==0 );\n  assert( desiredAutoCommit==1 || iRollback==0 );\n  assert( db->nVdbeActive>0 );  /* At least this one VM is active */\n  assert( p->bIsReader );\n\n  if( desiredAutoCommit!=db->autoCommit ){\n    if( iRollback ){\n      assert( desiredAutoCommit==1 );\n      sqlite3RollbackAll(db, SQLITE_ABORT_ROLLBACK);\n      db->autoCommit = 1;\n    }else if( desiredAutoCommit && db->nVdbeWrite>0 ){\n      /* If this instruction implements a COMMIT and other VMs are writing\n      ** return an error indicating that the other VMs must complete first. \n      */\n      sqlite3VdbeError(p, \"cannot commit transaction - \"\n                          \"SQL statements in progress\");\n      rc = SQLITE_BUSY;\n      goto abort_due_to_error;\n    }else if( (rc = sqlite3VdbeCheckFk(p, 1))!=SQLITE_OK ){\n      goto vdbe_return;\n    }else{\n      db->autoCommit = (u8)desiredAutoCommit;\n    }\n    if( sqlite3VdbeHalt(p)==SQLITE_BUSY ){\n      p->pc = (int)(pOp - aOp);\n      db->autoCommit = (u8)(1-desiredAutoCommit);\n      p->rc = rc = SQLITE_BUSY;\n      goto vdbe_return;\n    }\n    assert( db->nStatement==0 );\n    sqlite3CloseSavepoints(db);\n    if( p->rc==SQLITE_OK ){\n      rc = SQLITE_DONE;\n    }else{\n      rc = SQLITE_ERROR;\n    }\n    goto vdbe_return;\n  }else{\n    sqlite3VdbeError(p,\n        (!desiredAutoCommit)?\"cannot start a transaction within a transaction\":(\n        (iRollback)?\"cannot rollback - no transaction is active\":\n                   \"cannot commit - no transaction is active\"));\n         \n    rc = SQLITE_ERROR;\n    goto abort_due_to_error;\n  }\n  break;\n}\n\n/* Opcode: Transaction P1 P2 P3 P4 P5\n**\n** Begin a transaction on database P1 if a transaction is not already\n** active.\n** If P2 is non-zero, then a write-transaction is started, or if a \n** read-transaction is already active, it is upgraded to a write-transaction.\n** If P2 is zero, then a read-transaction is started.\n**\n** P1 is the index of the database file on which the transaction is\n** started.  Index 0 is the main database file and index 1 is the\n** file used for temporary tables.  Indices of 2 or more are used for\n** attached databases.\n**\n** If a write-transaction is started and the Vdbe.usesStmtJournal flag is\n** true (this flag is set if the Vdbe may modify more than one row and may\n** throw an ABORT exception), a statement transaction may also be opened.\n** More specifically, a statement transaction is opened iff the database\n** connection is currently not in autocommit mode, or if there are other\n** active statements. A statement transaction allows the changes made by this\n** VDBE to be rolled back after an error without having to roll back the\n** entire transaction. If no error is encountered, the statement transaction\n** will automatically commit when the VDBE halts.\n**\n** If P5!=0 then this opcode also checks the schema cookie against P3\n** and the schema generation counter against P4.\n** The cookie changes its value whenever the database schema changes.\n** This operation is used to detect when that the cookie has changed\n** and that the current process needs to reread the schema.  If the schema\n** cookie in P3 differs from the schema cookie in the database header or\n** if the schema generation counter in P4 differs from the current\n** generation counter, then an SQLITE_SCHEMA error is raised and execution\n** halts.  The sqlite3_step() wrapper function might then reprepare the\n** statement and rerun it from the beginning.\n*/\ncase OP_Transaction: {\n  Btree *pBt;\n  int iMeta = 0;\n\n  assert( p->bIsReader );\n  assert( p->readOnly==0 || pOp->p2==0 );\n  assert( pOp->p1>=0 && pOp->p1<db->nDb );\n  assert( DbMaskTest(p->btreeMask, pOp->p1) );\n  if( pOp->p2 && (db->flags & SQLITE_QueryOnly)!=0 ){\n    rc = SQLITE_READONLY;\n    goto abort_due_to_error;\n  }\n  pBt = db->aDb[pOp->p1].pBt;\n\n  if( pBt ){\n    rc = sqlite3BtreeBeginTrans(pBt, pOp->p2, &iMeta);\n    testcase( rc==SQLITE_BUSY_SNAPSHOT );\n    testcase( rc==SQLITE_BUSY_RECOVERY );\n    if( rc!=SQLITE_OK ){\n      if( (rc&0xff)==SQLITE_BUSY ){\n        p->pc = (int)(pOp - aOp);\n        p->rc = rc;\n        goto vdbe_return;\n      }\n      goto abort_due_to_error;\n    }\n\n    if( pOp->p2 && p->usesStmtJournal \n     && (db->autoCommit==0 || db->nVdbeRead>1) \n    ){\n      assert( sqlite3BtreeIsInTrans(pBt) );\n      if( p->iStatement==0 ){\n        assert( db->nStatement>=0 && db->nSavepoint>=0 );\n        db->nStatement++; \n        p->iStatement = db->nSavepoint + db->nStatement;\n      }\n\n      rc = sqlite3VtabSavepoint(db, SAVEPOINT_BEGIN, p->iStatement-1);\n      if( rc==SQLITE_OK ){\n        rc = sqlite3BtreeBeginStmt(pBt, p->iStatement);\n      }\n\n      /* Store the current value of the database handles deferred constraint\n      ** counter. If the statement transaction needs to be rolled back,\n      ** the value of this counter needs to be restored too.  */\n      p->nStmtDefCons = db->nDeferredCons;\n      p->nStmtDefImmCons = db->nDeferredImmCons;\n    }\n  }\n  assert( pOp->p5==0 || pOp->p4type==P4_INT32 );\n  if( pOp->p5\n   && (iMeta!=pOp->p3\n      || db->aDb[pOp->p1].pSchema->iGeneration!=pOp->p4.i)\n  ){\n    /*\n    ** IMPLEMENTATION-OF: R-03189-51135 As each SQL statement runs, the schema\n    ** version is checked to ensure that the schema has not changed since the\n    ** SQL statement was prepared.\n    */\n    sqlite3DbFree(db, p->zErrMsg);\n    p->zErrMsg = sqlite3DbStrDup(db, \"database schema has changed\");\n    /* If the schema-cookie from the database file matches the cookie \n    ** stored with the in-memory representation of the schema, do\n    ** not reload the schema from the database file.\n    **\n    ** If virtual-tables are in use, this is not just an optimization.\n    ** Often, v-tables store their data in other SQLite tables, which\n    ** are queried from within xNext() and other v-table methods using\n    ** prepared queries. If such a query is out-of-date, we do not want to\n    ** discard the database schema, as the user code implementing the\n    ** v-table would have to be ready for the sqlite3_vtab structure itself\n    ** to be invalidated whenever sqlite3_step() is called from within \n    ** a v-table method.\n    */\n    if( db->aDb[pOp->p1].pSchema->schema_cookie!=iMeta ){\n      sqlite3ResetOneSchema(db, pOp->p1);\n    }\n    p->expired = 1;\n    rc = SQLITE_SCHEMA;\n  }\n  if( rc ) goto abort_due_to_error;\n  break;\n}\n\n/* Opcode: ReadCookie P1 P2 P3 * *\n**\n** Read cookie number P3 from database P1 and write it into register P2.\n** P3==1 is the schema version.  P3==2 is the database format.\n** P3==3 is the recommended pager cache size, and so forth.  P1==0 is\n** the main database file and P1==1 is the database file used to store\n** temporary tables.\n**\n** There must be a read-lock on the database (either a transaction\n** must be started or there must be an open cursor) before\n** executing this instruction.\n*/\ncase OP_ReadCookie: {               /* out2 */\n  int iMeta;\n  int iDb;\n  int iCookie;\n\n  assert( p->bIsReader );\n  iDb = pOp->p1;\n  iCookie = pOp->p3;\n  assert( pOp->p3<SQLITE_N_BTREE_META );\n  assert( iDb>=0 && iDb<db->nDb );\n  assert( db->aDb[iDb].pBt!=0 );\n  assert( DbMaskTest(p->btreeMask, iDb) );\n\n  sqlite3BtreeGetMeta(db->aDb[iDb].pBt, iCookie, (u32 *)&iMeta);\n  pOut = out2Prerelease(p, pOp);\n  pOut->u.i = iMeta;\n  break;\n}\n\n/* Opcode: SetCookie P1 P2 P3 * *\n**\n** Write the integer value P3 into cookie number P2 of database P1.\n** P2==1 is the schema version.  P2==2 is the database format.\n** P2==3 is the recommended pager cache \n** size, and so forth.  P1==0 is the main database file and P1==1 is the \n** database file used to store temporary tables.\n**\n** A transaction must be started before executing this opcode.\n*/\ncase OP_SetCookie: {\n  Db *pDb;\n\n  sqlite3VdbeIncrWriteCounter(p, 0);\n  assert( pOp->p2<SQLITE_N_BTREE_META );\n  assert( pOp->p1>=0 && pOp->p1<db->nDb );\n  assert( DbMaskTest(p->btreeMask, pOp->p1) );\n  assert( p->readOnly==0 );\n  pDb = &db->aDb[pOp->p1];\n  assert( pDb->pBt!=0 );\n  assert( sqlite3SchemaMutexHeld(db, pOp->p1, 0) );\n  /* See note about index shifting on OP_ReadCookie */\n  rc = sqlite3BtreeUpdateMeta(pDb->pBt, pOp->p2, pOp->p3);\n  if( pOp->p2==BTREE_SCHEMA_VERSION ){\n    /* When the schema cookie changes, record the new cookie internally */\n    pDb->pSchema->schema_cookie = pOp->p3;\n    db->mDbFlags |= DBFLAG_SchemaChange;\n  }else if( pOp->p2==BTREE_FILE_FORMAT ){\n    /* Record changes in the file format */\n    pDb->pSchema->file_format = pOp->p3;\n  }\n  if( pOp->p1==1 ){\n    /* Invalidate all prepared statements whenever the TEMP database\n    ** schema is changed.  Ticket #1644 */\n    sqlite3ExpirePreparedStatements(db, 0);\n    p->expired = 0;\n  }\n  if( rc ) goto abort_due_to_error;\n  break;\n}\n\n/* Opcode: OpenRead P1 P2 P3 P4 P5\n** Synopsis: root=P2 iDb=P3\n**\n** Open a read-only cursor for the database table whose root page is\n** P2 in a database file.  The database file is determined by P3. \n** P3==0 means the main database, P3==1 means the database used for \n** temporary tables, and P3>1 means used the corresponding attached\n** database.  Give the new cursor an identifier of P1.  The P1\n** values need not be contiguous but all P1 values should be small integers.\n** It is an error for P1 to be negative.\n**\n** Allowed P5 bits:\n** <ul>\n** <li>  <b>0x02 OPFLAG_SEEKEQ</b>: This cursor will only be used for\n**       equality lookups (implemented as a pair of opcodes OP_SeekGE/OP_IdxGT\n**       of OP_SeekLE/OP_IdxGT)\n** </ul>\n**\n** The P4 value may be either an integer (P4_INT32) or a pointer to\n** a KeyInfo structure (P4_KEYINFO). If it is a pointer to a KeyInfo \n** object, then table being opened must be an [index b-tree] where the\n** KeyInfo object defines the content and collating \n** sequence of that index b-tree. Otherwise, if P4 is an integer \n** value, then the table being opened must be a [table b-tree] with a\n** number of columns no less than the value of P4.\n**\n** See also: OpenWrite, ReopenIdx\n*/\n/* Opcode: ReopenIdx P1 P2 P3 P4 P5\n** Synopsis: root=P2 iDb=P3\n**\n** The ReopenIdx opcode works like OP_OpenRead except that it first\n** checks to see if the cursor on P1 is already open on the same\n** b-tree and if it is this opcode becomes a no-op.  In other words,\n** if the cursor is already open, do not reopen it.\n**\n** The ReopenIdx opcode may only be used with P5==0 or P5==OPFLAG_SEEKEQ\n** and with P4 being a P4_KEYINFO object.  Furthermore, the P3 value must\n** be the same as every other ReopenIdx or OpenRead for the same cursor\n** number.\n**\n** Allowed P5 bits:\n** <ul>\n** <li>  <b>0x02 OPFLAG_SEEKEQ</b>: This cursor will only be used for\n**       equality lookups (implemented as a pair of opcodes OP_SeekGE/OP_IdxGT\n**       of OP_SeekLE/OP_IdxGT)\n** </ul>\n**\n** See also: OP_OpenRead, OP_OpenWrite\n*/\n/* Opcode: OpenWrite P1 P2 P3 P4 P5\n** Synopsis: root=P2 iDb=P3\n**\n** Open a read/write cursor named P1 on the table or index whose root\n** page is P2 (or whose root page is held in register P2 if the\n** OPFLAG_P2ISREG bit is set in P5 - see below).\n**\n** The P4 value may be either an integer (P4_INT32) or a pointer to\n** a KeyInfo structure (P4_KEYINFO). If it is a pointer to a KeyInfo \n** object, then table being opened must be an [index b-tree] where the\n** KeyInfo object defines the content and collating \n** sequence of that index b-tree. Otherwise, if P4 is an integer \n** value, then the table being opened must be a [table b-tree] with a\n** number of columns no less than the value of P4.\n**\n** Allowed P5 bits:\n** <ul>\n** <li>  <b>0x02 OPFLAG_SEEKEQ</b>: This cursor will only be used for\n**       equality lookups (implemented as a pair of opcodes OP_SeekGE/OP_IdxGT\n**       of OP_SeekLE/OP_IdxGT)\n** <li>  <b>0x08 OPFLAG_FORDELETE</b>: This cursor is used only to seek\n**       and subsequently delete entries in an index btree.  This is a\n**       hint to the storage engine that the storage engine is allowed to\n**       ignore.  The hint is not used by the official SQLite b*tree storage\n**       engine, but is used by COMDB2.\n** <li>  <b>0x10 OPFLAG_P2ISREG</b>: Use the content of register P2\n**       as the root page, not the value of P2 itself.\n** </ul>\n**\n** This instruction works like OpenRead except that it opens the cursor\n** in read/write mode.\n**\n** See also: OP_OpenRead, OP_ReopenIdx\n*/\ncase OP_ReopenIdx: {\n  int nField;\n  KeyInfo *pKeyInfo;\n  int p2;\n  int iDb;\n  int wrFlag;\n  Btree *pX;\n  VdbeCursor *pCur;\n  Db *pDb;\n\n  assert( pOp->p5==0 || pOp->p5==OPFLAG_SEEKEQ );\n  assert( pOp->p4type==P4_KEYINFO );\n  pCur = p->apCsr[pOp->p1];\n  if( pCur && pCur->pgnoRoot==(u32)pOp->p2 ){\n    assert( pCur->iDb==pOp->p3 );      /* Guaranteed by the code generator */\n    goto open_cursor_set_hints;\n  }\n  /* If the cursor is not currently open or is open on a different\n  ** index, then fall through into OP_OpenRead to force a reopen */\ncase OP_OpenRead:\ncase OP_OpenWrite:\n\n  assert( pOp->opcode==OP_OpenWrite || pOp->p5==0 || pOp->p5==OPFLAG_SEEKEQ );\n  assert( p->bIsReader );\n  assert( pOp->opcode==OP_OpenRead || pOp->opcode==OP_ReopenIdx\n          || p->readOnly==0 );\n\n  if( p->expired==1 ){\n    rc = SQLITE_ABORT_ROLLBACK;\n    goto abort_due_to_error;\n  }\n\n  nField = 0;\n  pKeyInfo = 0;\n  p2 = pOp->p2;\n  iDb = pOp->p3;\n  assert( iDb>=0 && iDb<db->nDb );\n  assert( DbMaskTest(p->btreeMask, iDb) );\n  pDb = &db->aDb[iDb];\n  pX = pDb->pBt;\n  assert( pX!=0 );\n  if( pOp->opcode==OP_OpenWrite ){\n    assert( OPFLAG_FORDELETE==BTREE_FORDELETE );\n    wrFlag = BTREE_WRCSR | (pOp->p5 & OPFLAG_FORDELETE);\n    assert( sqlite3SchemaMutexHeld(db, iDb, 0) );\n    if( pDb->pSchema->file_format < p->minWriteFileFormat ){\n      p->minWriteFileFormat = pDb->pSchema->file_format;\n    }\n  }else{\n    wrFlag = 0;\n  }\n  if( pOp->p5 & OPFLAG_P2ISREG ){\n    assert( p2>0 );\n    assert( p2<=(p->nMem+1 - p->nCursor) );\n    assert( pOp->opcode==OP_OpenWrite );\n    pIn2 = &aMem[p2];\n    assert( memIsValid(pIn2) );\n    assert( (pIn2->flags & MEM_Int)!=0 );\n    sqlite3VdbeMemIntegerify(pIn2);\n    p2 = (int)pIn2->u.i;\n    /* The p2 value always comes from a prior OP_CreateBtree opcode and\n    ** that opcode will always set the p2 value to 2 or more or else fail.\n    ** If there were a failure, the prepared statement would have halted\n    ** before reaching this instruction. */\n    assert( p2>=2 );\n  }\n  if( pOp->p4type==P4_KEYINFO ){\n    pKeyInfo = pOp->p4.pKeyInfo;\n    assert( pKeyInfo->enc==ENC(db) );\n    assert( pKeyInfo->db==db );\n    nField = pKeyInfo->nAllField;\n  }else if( pOp->p4type==P4_INT32 ){\n    nField = pOp->p4.i;\n  }\n  assert( pOp->p1>=0 );\n  assert( nField>=0 );\n  testcase( nField==0 );  /* Table with INTEGER PRIMARY KEY and nothing else */\n  pCur = allocateCursor(p, pOp->p1, nField, iDb, CURTYPE_BTREE);\n  if( pCur==0 ) goto no_mem;\n  pCur->nullRow = 1;\n  pCur->isOrdered = 1;\n  pCur->pgnoRoot = p2;\n#ifdef SQLITE_DEBUG\n  pCur->wrFlag = wrFlag;\n#endif\n  rc = sqlite3BtreeCursor(pX, p2, wrFlag, pKeyInfo, pCur->uc.pCursor);\n  pCur->pKeyInfo = pKeyInfo;\n  /* Set the VdbeCursor.isTable variable. Previous versions of\n  ** SQLite used to check if the root-page flags were sane at this point\n  ** and report database corruption if they were not, but this check has\n  ** since moved into the btree layer.  */  \n  pCur->isTable = pOp->p4type!=P4_KEYINFO;\n\nopen_cursor_set_hints:\n  assert( OPFLAG_BULKCSR==BTREE_BULKLOAD );\n  assert( OPFLAG_SEEKEQ==BTREE_SEEK_EQ );\n  testcase( pOp->p5 & OPFLAG_BULKCSR );\n#ifdef SQLITE_ENABLE_CURSOR_HINTS\n  testcase( pOp->p2 & OPFLAG_SEEKEQ );\n#endif\n  sqlite3BtreeCursorHintFlags(pCur->uc.pCursor,\n                               (pOp->p5 & (OPFLAG_BULKCSR|OPFLAG_SEEKEQ)));\n  if( rc ) goto abort_due_to_error;\n  break;\n}\n\n/* Opcode: OpenDup P1 P2 * * *\n**\n** Open a new cursor P1 that points to the same ephemeral table as\n** cursor P2.  The P2 cursor must have been opened by a prior OP_OpenEphemeral\n** opcode.  Only ephemeral cursors may be duplicated.\n**\n** Duplicate ephemeral cursors are used for self-joins of materialized views.\n*/\ncase OP_OpenDup: {\n  VdbeCursor *pOrig;    /* The original cursor to be duplicated */\n  VdbeCursor *pCx;      /* The new cursor */\n\n  pOrig = p->apCsr[pOp->p2];\n  assert( pOrig->pBtx!=0 );  /* Only ephemeral cursors can be duplicated */\n\n  pCx = allocateCursor(p, pOp->p1, pOrig->nField, -1, CURTYPE_BTREE);\n  if( pCx==0 ) goto no_mem;\n  pCx->nullRow = 1;\n  pCx->isEphemeral = 1;\n  pCx->pKeyInfo = pOrig->pKeyInfo;\n  pCx->isTable = pOrig->isTable;\n  pCx->pgnoRoot = pOrig->pgnoRoot;\n  rc = sqlite3BtreeCursor(pOrig->pBtx, pCx->pgnoRoot, BTREE_WRCSR,\n                          pCx->pKeyInfo, pCx->uc.pCursor);\n  /* The sqlite3BtreeCursor() routine can only fail for the first cursor\n  ** opened for a database.  Since there is already an open cursor when this\n  ** opcode is run, the sqlite3BtreeCursor() cannot fail */\n  assert( rc==SQLITE_OK );\n  break;\n}\n\n\n/* Opcode: OpenEphemeral P1 P2 * P4 P5\n** Synopsis: nColumn=P2\n**\n** Open a new cursor P1 to a transient table.\n** The cursor is always opened read/write even if \n** the main database is read-only.  The ephemeral\n** table is deleted automatically when the cursor is closed.\n**\n** If the cursor P1 is already opened on an ephemeral table, the table\n** is cleared (all content is erased).\n**\n** P2 is the number of columns in the ephemeral table.\n** The cursor points to a BTree table if P4==0 and to a BTree index\n** if P4 is not 0.  If P4 is not NULL, it points to a KeyInfo structure\n** that defines the format of keys in the index.\n**\n** The P5 parameter can be a mask of the BTREE_* flags defined\n** in btree.h.  These flags control aspects of the operation of\n** the btree.  The BTREE_OMIT_JOURNAL and BTREE_SINGLE flags are\n** added automatically.\n*/\n/* Opcode: OpenAutoindex P1 P2 * P4 *\n** Synopsis: nColumn=P2\n**\n** This opcode works the same as OP_OpenEphemeral.  It has a\n** different name to distinguish its use.  Tables created using\n** by this opcode will be used for automatically created transient\n** indices in joins.\n*/\ncase OP_OpenAutoindex: \ncase OP_OpenEphemeral: {\n  VdbeCursor *pCx;\n  KeyInfo *pKeyInfo;\n\n  static const int vfsFlags = \n      SQLITE_OPEN_READWRITE |\n      SQLITE_OPEN_CREATE |\n      SQLITE_OPEN_EXCLUSIVE |\n      SQLITE_OPEN_DELETEONCLOSE |\n      SQLITE_OPEN_TRANSIENT_DB;\n  assert( pOp->p1>=0 );\n  assert( pOp->p2>=0 );\n  pCx = p->apCsr[pOp->p1];\n  if( pCx ){\n    /* If the ephermeral table is already open, erase all existing content\n    ** so that the table is empty again, rather than creating a new table. */\n    rc = sqlite3BtreeClearTable(pCx->pBtx, pCx->pgnoRoot, 0);\n  }else{\n    pCx = allocateCursor(p, pOp->p1, pOp->p2, -1, CURTYPE_BTREE);\n    if( pCx==0 ) goto no_mem;\n    pCx->nullRow = 1;\n    pCx->isEphemeral = 1;\n    rc = sqlite3BtreeOpen(db->pVfs, 0, db, &pCx->pBtx, \n                          BTREE_OMIT_JOURNAL | BTREE_SINGLE | pOp->p5,\n                          vfsFlags);\n    if( rc==SQLITE_OK ){\n      rc = sqlite3BtreeBeginTrans(pCx->pBtx, 1, 0);\n    }\n    if( rc==SQLITE_OK ){\n      /* If a transient index is required, create it by calling\n      ** sqlite3BtreeCreateTable() with the BTREE_BLOBKEY flag before\n      ** opening it. If a transient table is required, just use the\n      ** automatically created table with root-page 1 (an BLOB_INTKEY table).\n      */\n      if( (pCx->pKeyInfo = pKeyInfo = pOp->p4.pKeyInfo)!=0 ){\n        assert( pOp->p4type==P4_KEYINFO );\n        rc = sqlite3BtreeCreateTable(pCx->pBtx, (int*)&pCx->pgnoRoot,\n                                     BTREE_BLOBKEY | pOp->p5); \n        if( rc==SQLITE_OK ){\n          assert( pCx->pgnoRoot==MASTER_ROOT+1 );\n          assert( pKeyInfo->db==db );\n          assert( pKeyInfo->enc==ENC(db) );\n          rc = sqlite3BtreeCursor(pCx->pBtx, pCx->pgnoRoot, BTREE_WRCSR,\n                                  pKeyInfo, pCx->uc.pCursor);\n        }\n        pCx->isTable = 0;\n      }else{\n        pCx->pgnoRoot = MASTER_ROOT;\n        rc = sqlite3BtreeCursor(pCx->pBtx, MASTER_ROOT, BTREE_WRCSR,\n                                0, pCx->uc.pCursor);\n        pCx->isTable = 1;\n      }\n    }\n    pCx->isOrdered = (pOp->p5!=BTREE_UNORDERED);\n  }\n  if( rc ) goto abort_due_to_error;\n  break;\n}\n\n/* Opcode: SorterOpen P1 P2 P3 P4 *\n**\n** This opcode works like OP_OpenEphemeral except that it opens\n** a transient index that is specifically designed to sort large\n** tables using an external merge-sort algorithm.\n**\n** If argument P3 is non-zero, then it indicates that the sorter may\n** assume that a stable sort considering the first P3 fields of each\n** key is sufficient to produce the required results.\n*/\ncase OP_SorterOpen: {\n  VdbeCursor *pCx;\n\n  assert( pOp->p1>=0 );\n  assert( pOp->p2>=0 );\n  pCx = allocateCursor(p, pOp->p1, pOp->p2, -1, CURTYPE_SORTER);\n  if( pCx==0 ) goto no_mem;\n  pCx->pKeyInfo = pOp->p4.pKeyInfo;\n  assert( pCx->pKeyInfo->db==db );\n  assert( pCx->pKeyInfo->enc==ENC(db) );\n  rc = sqlite3VdbeSorterInit(db, pOp->p3, pCx);\n  if( rc ) goto abort_due_to_error;\n  break;\n}\n\n/* Opcode: SequenceTest P1 P2 * * *\n** Synopsis: if( cursor[P1].ctr++ ) pc = P2\n**\n** P1 is a sorter cursor. If the sequence counter is currently zero, jump\n** to P2. Regardless of whether or not the jump is taken, increment the\n** the sequence value.\n*/\ncase OP_SequenceTest: {\n  VdbeCursor *pC;\n  assert( pOp->p1>=0 && pOp->p1<p->nCursor );\n  pC = p->apCsr[pOp->p1];\n  assert( isSorter(pC) );\n  if( (pC->seqCount++)==0 ){\n    goto jump_to_p2;\n  }\n  break;\n}\n\n/* Opcode: OpenPseudo P1 P2 P3 * *\n** Synopsis: P3 columns in r[P2]\n**\n** Open a new cursor that points to a fake table that contains a single\n** row of data.  The content of that one row is the content of memory\n** register P2.  In other words, cursor P1 becomes an alias for the \n** MEM_Blob content contained in register P2.\n**\n** A pseudo-table created by this opcode is used to hold a single\n** row output from the sorter so that the row can be decomposed into\n** individual columns using the OP_Column opcode.  The OP_Column opcode\n** is the only cursor opcode that works with a pseudo-table.\n**\n** P3 is the number of fields in the records that will be stored by\n** the pseudo-table.\n*/\ncase OP_OpenPseudo: {\n  VdbeCursor *pCx;\n\n  assert( pOp->p1>=0 );\n  assert( pOp->p3>=0 );\n  pCx = allocateCursor(p, pOp->p1, pOp->p3, -1, CURTYPE_PSEUDO);\n  if( pCx==0 ) goto no_mem;\n  pCx->nullRow = 1;\n  pCx->seekResult = pOp->p2;\n  pCx->isTable = 1;\n  /* Give this pseudo-cursor a fake BtCursor pointer so that pCx\n  ** can be safely passed to sqlite3VdbeCursorMoveto().  This avoids a test\n  ** for pCx->eCurType==CURTYPE_BTREE inside of sqlite3VdbeCursorMoveto()\n  ** which is a performance optimization */\n  pCx->uc.pCursor = sqlite3BtreeFakeValidCursor();\n  assert( pOp->p5==0 );\n  break;\n}\n\n/* Opcode: Close P1 * * * *\n**\n** Close a cursor previously opened as P1.  If P1 is not\n** currently open, this instruction is a no-op.\n*/\ncase OP_Close: {\n  assert( pOp->p1>=0 && pOp->p1<p->nCursor );\n  sqlite3VdbeFreeCursor(p, p->apCsr[pOp->p1]);\n  p->apCsr[pOp->p1] = 0;\n  break;\n}\n\n#ifdef SQLITE_ENABLE_COLUMN_USED_MASK\n/* Opcode: ColumnsUsed P1 * * P4 *\n**\n** This opcode (which only exists if SQLite was compiled with\n** SQLITE_ENABLE_COLUMN_USED_MASK) identifies which columns of the\n** table or index for cursor P1 are used.  P4 is a 64-bit integer\n** (P4_INT64) in which the first 63 bits are one for each of the\n** first 63 columns of the table or index that are actually used\n** by the cursor.  The high-order bit is set if any column after\n** the 64th is used.\n*/\ncase OP_ColumnsUsed: {\n  VdbeCursor *pC;\n  pC = p->apCsr[pOp->p1];\n  assert( pC->eCurType==CURTYPE_BTREE );\n  pC->maskUsed = *(u64*)pOp->p4.pI64;\n  break;\n}\n#endif\n\n/* Opcode: SeekGE P1 P2 P3 P4 *\n** Synopsis: key=r[P3@P4]\n**\n** If cursor P1 refers to an SQL table (B-Tree that uses integer keys), \n** use the value in register P3 as the key.  If cursor P1 refers \n** to an SQL index, then P3 is the first in an array of P4 registers \n** that are used as an unpacked index key. \n**\n** Reposition cursor P1 so that  it points to the smallest entry that \n** is greater than or equal to the key value. If there are no records \n** greater than or equal to the key and P2 is not zero, then jump to P2.\n**\n** If the cursor P1 was opened using the OPFLAG_SEEKEQ flag, then this\n** opcode will always land on a record that equally equals the key, or\n** else jump immediately to P2.  When the cursor is OPFLAG_SEEKEQ, this\n** opcode must be followed by an IdxLE opcode with the same arguments.\n** The IdxLE opcode will be skipped if this opcode succeeds, but the\n** IdxLE opcode will be used on subsequent loop iterations.\n**\n** This opcode leaves the cursor configured to move in forward order,\n** from the beginning toward the end.  In other words, the cursor is\n** configured to use Next, not Prev.\n**\n** See also: Found, NotFound, SeekLt, SeekGt, SeekLe\n*/\n/* Opcode: SeekGT P1 P2 P3 P4 *\n** Synopsis: key=r[P3@P4]\n**\n** If cursor P1 refers to an SQL table (B-Tree that uses integer keys), \n** use the value in register P3 as a key. If cursor P1 refers \n** to an SQL index, then P3 is the first in an array of P4 registers \n** that are used as an unpacked index key. \n**\n** Reposition cursor P1 so that  it points to the smallest entry that \n** is greater than the key value. If there are no records greater than \n** the key and P2 is not zero, then jump to P2.\n**\n** This opcode leaves the cursor configured to move in forward order,\n** from the beginning toward the end.  In other words, the cursor is\n** configured to use Next, not Prev.\n**\n** See also: Found, NotFound, SeekLt, SeekGe, SeekLe\n*/\n/* Opcode: SeekLT P1 P2 P3 P4 * \n** Synopsis: key=r[P3@P4]\n**\n** If cursor P1 refers to an SQL table (B-Tree that uses integer keys), \n** use the value in register P3 as a key. If cursor P1 refers \n** to an SQL index, then P3 is the first in an array of P4 registers \n** that are used as an unpacked index key. \n**\n** Reposition cursor P1 so that  it points to the largest entry that \n** is less than the key value. If there are no records less than \n** the key and P2 is not zero, then jump to P2.\n**\n** This opcode leaves the cursor configured to move in reverse order,\n** from the end toward the beginning.  In other words, the cursor is\n** configured to use Prev, not Next.\n**\n** See also: Found, NotFound, SeekGt, SeekGe, SeekLe\n*/\n/* Opcode: SeekLE P1 P2 P3 P4 *\n** Synopsis: key=r[P3@P4]\n**\n** If cursor P1 refers to an SQL table (B-Tree that uses integer keys), \n** use the value in register P3 as a key. If cursor P1 refers \n** to an SQL index, then P3 is the first in an array of P4 registers \n** that are used as an unpacked index key. \n**\n** Reposition cursor P1 so that it points to the largest entry that \n** is less than or equal to the key value. If there are no records \n** less than or equal to the key and P2 is not zero, then jump to P2.\n**\n** This opcode leaves the cursor configured to move in reverse order,\n** from the end toward the beginning.  In other words, the cursor is\n** configured to use Prev, not Next.\n**\n** If the cursor P1 was opened using the OPFLAG_SEEKEQ flag, then this\n** opcode will always land on a record that equally equals the key, or\n** else jump immediately to P2.  When the cursor is OPFLAG_SEEKEQ, this\n** opcode must be followed by an IdxGE opcode with the same arguments.\n** The IdxGE opcode will be skipped if this opcode succeeds, but the\n** IdxGE opcode will be used on subsequent loop iterations.\n**\n** See also: Found, NotFound, SeekGt, SeekGe, SeekLt\n*/\ncase OP_SeekLT:         /* jump, in3, group */\ncase OP_SeekLE:         /* jump, in3, group */\ncase OP_SeekGE:         /* jump, in3, group */\ncase OP_SeekGT: {       /* jump, in3, group */\n  int res;           /* Comparison result */\n  int oc;            /* Opcode */\n  VdbeCursor *pC;    /* The cursor to seek */\n  UnpackedRecord r;  /* The key to seek for */\n  int nField;        /* Number of columns or fields in the key */\n  i64 iKey;          /* The rowid we are to seek to */\n  int eqOnly;        /* Only interested in == results */\n\n  assert( pOp->p1>=0 && pOp->p1<p->nCursor );\n  assert( pOp->p2!=0 );\n  pC = p->apCsr[pOp->p1];\n  assert( pC!=0 );\n  assert( pC->eCurType==CURTYPE_BTREE );\n  assert( OP_SeekLE == OP_SeekLT+1 );\n  assert( OP_SeekGE == OP_SeekLT+2 );\n  assert( OP_SeekGT == OP_SeekLT+3 );\n  assert( pC->isOrdered );\n  assert( pC->uc.pCursor!=0 );\n  oc = pOp->opcode;\n  eqOnly = 0;\n  pC->nullRow = 0;\n#ifdef SQLITE_DEBUG\n  pC->seekOp = pOp->opcode;\n#endif\n\n  if( pC->isTable ){\n    /* The BTREE_SEEK_EQ flag is only set on index cursors */\n    assert( sqlite3BtreeCursorHasHint(pC->uc.pCursor, BTREE_SEEK_EQ)==0\n              || CORRUPT_DB );\n\n    /* The input value in P3 might be of any type: integer, real, string,\n    ** blob, or NULL.  But it needs to be an integer before we can do\n    ** the seek, so convert it. */\n    pIn3 = &aMem[pOp->p3];\n    if( (pIn3->flags & (MEM_Int|MEM_Real|MEM_Str))==MEM_Str ){\n      applyNumericAffinity(pIn3, 0);\n    }\n    iKey = sqlite3VdbeIntValue(pIn3);\n\n    /* If the P3 value could not be converted into an integer without\n    ** loss of information, then special processing is required... */\n    if( (pIn3->flags & MEM_Int)==0 ){\n      if( (pIn3->flags & MEM_Real)==0 ){\n        /* If the P3 value cannot be converted into any kind of a number,\n        ** then the seek is not possible, so jump to P2 */\n        VdbeBranchTaken(1,2); goto jump_to_p2;\n        break;\n      }\n\n      /* If the approximation iKey is larger than the actual real search\n      ** term, substitute >= for > and < for <=. e.g. if the search term\n      ** is 4.9 and the integer approximation 5:\n      **\n      **        (x >  4.9)    ->     (x >= 5)\n      **        (x <= 4.9)    ->     (x <  5)\n      */\n      if( pIn3->u.r<(double)iKey ){\n        assert( OP_SeekGE==(OP_SeekGT-1) );\n        assert( OP_SeekLT==(OP_SeekLE-1) );\n        assert( (OP_SeekLE & 0x0001)==(OP_SeekGT & 0x0001) );\n        if( (oc & 0x0001)==(OP_SeekGT & 0x0001) ) oc--;\n      }\n\n      /* If the approximation iKey is smaller than the actual real search\n      ** term, substitute <= for < and > for >=.  */\n      else if( pIn3->u.r>(double)iKey ){\n        assert( OP_SeekLE==(OP_SeekLT+1) );\n        assert( OP_SeekGT==(OP_SeekGE+1) );\n        assert( (OP_SeekLT & 0x0001)==(OP_SeekGE & 0x0001) );\n        if( (oc & 0x0001)==(OP_SeekLT & 0x0001) ) oc++;\n      }\n    } \n    rc = sqlite3BtreeMovetoUnpacked(pC->uc.pCursor, 0, (u64)iKey, 0, &res);\n    pC->movetoTarget = iKey;  /* Used by OP_Delete */\n    if( rc!=SQLITE_OK ){\n      goto abort_due_to_error;\n    }\n  }else{\n    /* For a cursor with the BTREE_SEEK_EQ hint, only the OP_SeekGE and\n    ** OP_SeekLE opcodes are allowed, and these must be immediately followed\n    ** by an OP_IdxGT or OP_IdxLT opcode, respectively, with the same key.\n    */\n    if( sqlite3BtreeCursorHasHint(pC->uc.pCursor, BTREE_SEEK_EQ) ){\n      eqOnly = 1;\n      assert( pOp->opcode==OP_SeekGE || pOp->opcode==OP_SeekLE );\n      assert( pOp[1].opcode==OP_IdxLT || pOp[1].opcode==OP_IdxGT );\n      assert( pOp[1].p1==pOp[0].p1 );\n      assert( pOp[1].p2==pOp[0].p2 );\n      assert( pOp[1].p3==pOp[0].p3 );\n      assert( pOp[1].p4.i==pOp[0].p4.i );\n    }\n\n    nField = pOp->p4.i;\n    assert( pOp->p4type==P4_INT32 );\n    assert( nField>0 );\n    r.pKeyInfo = pC->pKeyInfo;\n    r.nField = (u16)nField;\n\n    /* The next line of code computes as follows, only faster:\n    **   if( oc==OP_SeekGT || oc==OP_SeekLE ){\n    **     r.default_rc = -1;\n    **   }else{\n    **     r.default_rc = +1;\n    **   }\n    */\n    r.default_rc = ((1 & (oc - OP_SeekLT)) ? -1 : +1);\n    assert( oc!=OP_SeekGT || r.default_rc==-1 );\n    assert( oc!=OP_SeekLE || r.default_rc==-1 );\n    assert( oc!=OP_SeekGE || r.default_rc==+1 );\n    assert( oc!=OP_SeekLT || r.default_rc==+1 );\n\n    r.aMem = &aMem[pOp->p3];\n#ifdef SQLITE_DEBUG\n    { int i; for(i=0; i<r.nField; i++) assert( memIsValid(&r.aMem[i]) ); }\n#endif\n    r.eqSeen = 0;\n    rc = sqlite3BtreeMovetoUnpacked(pC->uc.pCursor, &r, 0, 0, &res);\n    if( rc!=SQLITE_OK ){\n      goto abort_due_to_error;\n    }\n    if( eqOnly && r.eqSeen==0 ){\n      assert( res!=0 );\n      goto seek_not_found;\n    }\n  }\n  pC->deferredMoveto = 0;\n  pC->cacheStatus = CACHE_STALE;\n#ifdef SQLITE_TEST\n  sqlite3_search_count++;\n#endif\n  if( oc>=OP_SeekGE ){  assert( oc==OP_SeekGE || oc==OP_SeekGT );\n    if( res<0 || (res==0 && oc==OP_SeekGT) ){\n      res = 0;\n      rc = sqlite3BtreeNext(pC->uc.pCursor, 0);\n      if( rc!=SQLITE_OK ){\n        if( rc==SQLITE_DONE ){\n          rc = SQLITE_OK;\n          res = 1;\n        }else{\n          goto abort_due_to_error;\n        }\n      }\n    }else{\n      res = 0;\n    }\n  }else{\n    assert( oc==OP_SeekLT || oc==OP_SeekLE );\n    if( res>0 || (res==0 && oc==OP_SeekLT) ){\n      res = 0;\n      rc = sqlite3BtreePrevious(pC->uc.pCursor, 0);\n      if( rc!=SQLITE_OK ){\n        if( rc==SQLITE_DONE ){\n          rc = SQLITE_OK;\n          res = 1;\n        }else{\n          goto abort_due_to_error;\n        }\n      }\n    }else{\n      /* res might be negative because the table is empty.  Check to\n      ** see if this is the case.\n      */\n      res = sqlite3BtreeEof(pC->uc.pCursor);\n    }\n  }\nseek_not_found:\n  assert( pOp->p2>0 );\n  VdbeBranchTaken(res!=0,2);\n  if( res ){\n    goto jump_to_p2;\n  }else if( eqOnly ){\n    assert( pOp[1].opcode==OP_IdxLT || pOp[1].opcode==OP_IdxGT );\n    pOp++; /* Skip the OP_IdxLt or OP_IdxGT that follows */\n  }\n  break;\n}\n\n/* Opcode: SeekHit P1 P2 * * *\n** Synopsis: seekHit=P2\n**\n** Set the seekHit flag on cursor P1 to the value in P2.\n** The seekHit flag is used by the IfNoHope opcode.\n**\n** P1 must be a valid b-tree cursor.  P2 must be a boolean value,\n** either 0 or 1.\n*/\ncase OP_SeekHit: {\n  VdbeCursor *pC;\n  assert( pOp->p1>=0 && pOp->p1<p->nCursor );\n  pC = p->apCsr[pOp->p1];\n  assert( pC!=0 );\n  assert( pOp->p2==0 || pOp->p2==1 );\n  pC->seekHit = pOp->p2 & 1;\n  break;\n}\n\n/* Opcode: Found P1 P2 P3 P4 *\n** Synopsis: key=r[P3@P4]\n**\n** If P4==0 then register P3 holds a blob constructed by MakeRecord.  If\n** P4>0 then register P3 is the first of P4 registers that form an unpacked\n** record.\n**\n** Cursor P1 is on an index btree.  If the record identified by P3 and P4\n** is a prefix of any entry in P1 then a jump is made to P2 and\n** P1 is left pointing at the matching entry.\n**\n** This operation leaves the cursor in a state where it can be\n** advanced in the forward direction.  The Next instruction will work,\n** but not the Prev instruction.\n**\n** See also: NotFound, NoConflict, NotExists. SeekGe\n*/\n/* Opcode: NotFound P1 P2 P3 P4 *\n** Synopsis: key=r[P3@P4]\n**\n** If P4==0 then register P3 holds a blob constructed by MakeRecord.  If\n** P4>0 then register P3 is the first of P4 registers that form an unpacked\n** record.\n** \n** Cursor P1 is on an index btree.  If the record identified by P3 and P4\n** is not the prefix of any entry in P1 then a jump is made to P2.  If P1 \n** does contain an entry whose prefix matches the P3/P4 record then control\n** falls through to the next instruction and P1 is left pointing at the\n** matching entry.\n**\n** This operation leaves the cursor in a state where it cannot be\n** advanced in either direction.  In other words, the Next and Prev\n** opcodes do not work after this operation.\n**\n** See also: Found, NotExists, NoConflict, IfNoHope\n*/\n/* Opcode: IfNoHope P1 P2 P3 P4 *\n** Synopsis: key=r[P3@P4]\n**\n** Register P3 is the first of P4 registers that form an unpacked\n** record.\n**\n** Cursor P1 is on an index btree.  If the seekHit flag is set on P1, then\n** this opcode is a no-op.  But if the seekHit flag of P1 is clear, then\n** check to see if there is any entry in P1 that matches the\n** prefix identified by P3 and P4.  If no entry matches the prefix,\n** jump to P2.  Otherwise fall through.\n**\n** This opcode behaves like OP_NotFound if the seekHit\n** flag is clear and it behaves like OP_Noop if the seekHit flag is set.\n**\n** This opcode is used in IN clause processing for a multi-column key.\n** If an IN clause is attached to an element of the key other than the\n** left-most element, and if there are no matches on the most recent\n** seek over the whole key, then it might be that one of the key element\n** to the left is prohibiting a match, and hence there is \"no hope\" of\n** any match regardless of how many IN clause elements are checked.\n** In such a case, we abandon the IN clause search early, using this\n** opcode.  The opcode name comes from the fact that the\n** jump is taken if there is \"no hope\" of achieving a match.\n**\n** See also: NotFound, SeekHit\n*/\n/* Opcode: NoConflict P1 P2 P3 P4 *\n** Synopsis: key=r[P3@P4]\n**\n** If P4==0 then register P3 holds a blob constructed by MakeRecord.  If\n** P4>0 then register P3 is the first of P4 registers that form an unpacked\n** record.\n** \n** Cursor P1 is on an index btree.  If the record identified by P3 and P4\n** contains any NULL value, jump immediately to P2.  If all terms of the\n** record are not-NULL then a check is done to determine if any row in the\n** P1 index btree has a matching key prefix.  If there are no matches, jump\n** immediately to P2.  If there is a match, fall through and leave the P1\n** cursor pointing to the matching row.\n**\n** This opcode is similar to OP_NotFound with the exceptions that the\n** branch is always taken if any part of the search key input is NULL.\n**\n** This operation leaves the cursor in a state where it cannot be\n** advanced in either direction.  In other words, the Next and Prev\n** opcodes do not work after this operation.\n**\n** See also: NotFound, Found, NotExists\n*/\ncase OP_IfNoHope: {     /* jump, in3 */\n  VdbeCursor *pC;\n  assert( pOp->p1>=0 && pOp->p1<p->nCursor );\n  pC = p->apCsr[pOp->p1];\n  assert( pC!=0 );\n  if( pC->seekHit ) break;\n  /* Fall through into OP_NotFound */\n}\ncase OP_NoConflict:     /* jump, in3 */\ncase OP_NotFound:       /* jump, in3 */\ncase OP_Found: {        /* jump, in3 */\n  int alreadyExists;\n  int takeJump;\n  int ii;\n  VdbeCursor *pC;\n  int res;\n  UnpackedRecord *pFree;\n  UnpackedRecord *pIdxKey;\n  UnpackedRecord r;\n\n#ifdef SQLITE_TEST\n  if( pOp->opcode!=OP_NoConflict ) sqlite3_found_count++;\n#endif\n\n  assert( pOp->p1>=0 && pOp->p1<p->nCursor );\n  assert( pOp->p4type==P4_INT32 );\n  pC = p->apCsr[pOp->p1];\n  assert( pC!=0 );\n#ifdef SQLITE_DEBUG\n  pC->seekOp = pOp->opcode;\n#endif\n  pIn3 = &aMem[pOp->p3];\n  assert( pC->eCurType==CURTYPE_BTREE );\n  assert( pC->uc.pCursor!=0 );\n  assert( pC->isTable==0 );\n  if( pOp->p4.i>0 ){\n    r.pKeyInfo = pC->pKeyInfo;\n    r.nField = (u16)pOp->p4.i;\n    r.aMem = pIn3;\n#ifdef SQLITE_DEBUG\n    for(ii=0; ii<r.nField; ii++){\n      assert( memIsValid(&r.aMem[ii]) );\n      assert( (r.aMem[ii].flags & MEM_Zero)==0 || r.aMem[ii].n==0 );\n      if( ii ) REGISTER_TRACE(pOp->p3+ii, &r.aMem[ii]);\n    }\n#endif\n    pIdxKey = &r;\n    pFree = 0;\n  }else{\n    assert( pIn3->flags & MEM_Blob );\n    rc = ExpandBlob(pIn3);\n    assert( rc==SQLITE_OK || rc==SQLITE_NOMEM );\n    if( rc ) goto no_mem;\n    pFree = pIdxKey = sqlite3VdbeAllocUnpackedRecord(pC->pKeyInfo);\n    if( pIdxKey==0 ) goto no_mem;\n    sqlite3VdbeRecordUnpack(pC->pKeyInfo, pIn3->n, pIn3->z, pIdxKey);\n  }\n  pIdxKey->default_rc = 0;\n  takeJump = 0;\n  if( pOp->opcode==OP_NoConflict ){\n    /* For the OP_NoConflict opcode, take the jump if any of the\n    ** input fields are NULL, since any key with a NULL will not\n    ** conflict */\n    for(ii=0; ii<pIdxKey->nField; ii++){\n      if( pIdxKey->aMem[ii].flags & MEM_Null ){\n        takeJump = 1;\n        break;\n      }\n    }\n  }\n  rc = sqlite3BtreeMovetoUnpacked(pC->uc.pCursor, pIdxKey, 0, 0, &res);\n  if( pFree ) sqlite3DbFreeNN(db, pFree);\n  if( rc!=SQLITE_OK ){\n    goto abort_due_to_error;\n  }\n  pC->seekResult = res;\n  alreadyExists = (res==0);\n  pC->nullRow = 1-alreadyExists;\n  pC->deferredMoveto = 0;\n  pC->cacheStatus = CACHE_STALE;\n  if( pOp->opcode==OP_Found ){\n    VdbeBranchTaken(alreadyExists!=0,2);\n    if( alreadyExists ) goto jump_to_p2;\n  }else{\n    VdbeBranchTaken(takeJump||alreadyExists==0,2);\n    if( takeJump || !alreadyExists ) goto jump_to_p2;\n  }\n  break;\n}\n\n/* Opcode: SeekRowid P1 P2 P3 * *\n** Synopsis: intkey=r[P3]\n**\n** P1 is the index of a cursor open on an SQL table btree (with integer\n** keys).  If register P3 does not contain an integer or if P1 does not\n** contain a record with rowid P3 then jump immediately to P2.  \n** Or, if P2 is 0, raise an SQLITE_CORRUPT error. If P1 does contain\n** a record with rowid P3 then \n** leave the cursor pointing at that record and fall through to the next\n** instruction.\n**\n** The OP_NotExists opcode performs the same operation, but with OP_NotExists\n** the P3 register must be guaranteed to contain an integer value.  With this\n** opcode, register P3 might not contain an integer.\n**\n** The OP_NotFound opcode performs the same operation on index btrees\n** (with arbitrary multi-value keys).\n**\n** This opcode leaves the cursor in a state where it cannot be advanced\n** in either direction.  In other words, the Next and Prev opcodes will\n** not work following this opcode.\n**\n** See also: Found, NotFound, NoConflict, SeekRowid\n*/\n/* Opcode: NotExists P1 P2 P3 * *\n** Synopsis: intkey=r[P3]\n**\n** P1 is the index of a cursor open on an SQL table btree (with integer\n** keys).  P3 is an integer rowid.  If P1 does not contain a record with\n** rowid P3 then jump immediately to P2.  Or, if P2 is 0, raise an\n** SQLITE_CORRUPT error. If P1 does contain a record with rowid P3 then \n** leave the cursor pointing at that record and fall through to the next\n** instruction.\n**\n** The OP_SeekRowid opcode performs the same operation but also allows the\n** P3 register to contain a non-integer value, in which case the jump is\n** always taken.  This opcode requires that P3 always contain an integer.\n**\n** The OP_NotFound opcode performs the same operation on index btrees\n** (with arbitrary multi-value keys).\n**\n** This opcode leaves the cursor in a state where it cannot be advanced\n** in either direction.  In other words, the Next and Prev opcodes will\n** not work following this opcode.\n**\n** See also: Found, NotFound, NoConflict, SeekRowid\n*/\ncase OP_SeekRowid: {        /* jump, in3 */\n  VdbeCursor *pC;\n  BtCursor *pCrsr;\n  int res;\n  u64 iKey;\n\n  pIn3 = &aMem[pOp->p3];\n  if( (pIn3->flags & MEM_Int)==0 ){\n    /* Make sure pIn3->u.i contains a valid integer representation of\n    ** the key value, but do not change the datatype of the register, as\n    ** other parts of the perpared statement might be depending on the\n    ** current datatype. */\n    u16 origFlags = pIn3->flags;\n    int isNotInt;\n    applyAffinity(pIn3, SQLITE_AFF_NUMERIC, encoding);\n    isNotInt = (pIn3->flags & MEM_Int)==0;\n    pIn3->flags = origFlags;\n    if( isNotInt ) goto jump_to_p2;\n  }\n  /* Fall through into OP_NotExists */\ncase OP_NotExists:          /* jump, in3 */\n  pIn3 = &aMem[pOp->p3];\n  assert( (pIn3->flags & MEM_Int)!=0 || pOp->opcode==OP_SeekRowid );\n  assert( pOp->p1>=0 && pOp->p1<p->nCursor );\n  pC = p->apCsr[pOp->p1];\n  assert( pC!=0 );\n#ifdef SQLITE_DEBUG\n  if( pOp->opcode==OP_SeekRowid ) pC->seekOp = OP_SeekRowid;\n#endif\n  assert( pC->isTable );\n  assert( pC->eCurType==CURTYPE_BTREE );\n  pCrsr = pC->uc.pCursor;\n  assert( pCrsr!=0 );\n  res = 0;\n  iKey = pIn3->u.i;\n  rc = sqlite3BtreeMovetoUnpacked(pCrsr, 0, iKey, 0, &res);\n  assert( rc==SQLITE_OK || res==0 );\n  pC->movetoTarget = iKey;  /* Used by OP_Delete */\n  pC->nullRow = 0;\n  pC->cacheStatus = CACHE_STALE;\n  pC->deferredMoveto = 0;\n  VdbeBranchTaken(res!=0,2);\n  pC->seekResult = res;\n  if( res!=0 ){\n    assert( rc==SQLITE_OK );\n    if( pOp->p2==0 ){\n      rc = SQLITE_CORRUPT_BKPT;\n    }else{\n      goto jump_to_p2;\n    }\n  }\n  if( rc ) goto abort_due_to_error;\n  break;\n}\n\n/* Opcode: Sequence P1 P2 * * *\n** Synopsis: r[P2]=cursor[P1].ctr++\n**\n** Find the next available sequence number for cursor P1.\n** Write the sequence number into register P2.\n** The sequence number on the cursor is incremented after this\n** instruction.  \n*/\ncase OP_Sequence: {           /* out2 */\n  assert( pOp->p1>=0 && pOp->p1<p->nCursor );\n  assert( p->apCsr[pOp->p1]!=0 );\n  assert( p->apCsr[pOp->p1]->eCurType!=CURTYPE_VTAB );\n  pOut = out2Prerelease(p, pOp);\n  pOut->u.i = p->apCsr[pOp->p1]->seqCount++;\n  break;\n}\n\n\n/* Opcode: NewRowid P1 P2 P3 * *\n** Synopsis: r[P2]=rowid\n**\n** Get a new integer record number (a.k.a \"rowid\") used as the key to a table.\n** The record number is not previously used as a key in the database\n** table that cursor P1 points to.  The new record number is written\n** written to register P2.\n**\n** If P3>0 then P3 is a register in the root frame of this VDBE that holds \n** the largest previously generated record number. No new record numbers are\n** allowed to be less than this value. When this value reaches its maximum, \n** an SQLITE_FULL error is generated. The P3 register is updated with the '\n** generated record number. This P3 mechanism is used to help implement the\n** AUTOINCREMENT feature.\n*/\ncase OP_NewRowid: {           /* out2 */\n  i64 v;                 /* The new rowid */\n  VdbeCursor *pC;        /* Cursor of table to get the new rowid */\n  int res;               /* Result of an sqlite3BtreeLast() */\n  int cnt;               /* Counter to limit the number of searches */\n  Mem *pMem;             /* Register holding largest rowid for AUTOINCREMENT */\n  VdbeFrame *pFrame;     /* Root frame of VDBE */\n\n  v = 0;\n  res = 0;\n  pOut = out2Prerelease(p, pOp);\n  assert( pOp->p1>=0 && pOp->p1<p->nCursor );\n  pC = p->apCsr[pOp->p1];\n  assert( pC!=0 );\n  assert( pC->isTable );\n  assert( pC->eCurType==CURTYPE_BTREE );\n  assert( pC->uc.pCursor!=0 );\n  {\n    /* The next rowid or record number (different terms for the same\n    ** thing) is obtained in a two-step algorithm.\n    **\n    ** First we attempt to find the largest existing rowid and add one\n    ** to that.  But if the largest existing rowid is already the maximum\n    ** positive integer, we have to fall through to the second\n    ** probabilistic algorithm\n    **\n    ** The second algorithm is to select a rowid at random and see if\n    ** it already exists in the table.  If it does not exist, we have\n    ** succeeded.  If the random rowid does exist, we select a new one\n    ** and try again, up to 100 times.\n    */\n    assert( pC->isTable );\n\n#ifdef SQLITE_32BIT_ROWID\n#   define MAX_ROWID 0x7fffffff\n#else\n    /* Some compilers complain about constants of the form 0x7fffffffffffffff.\n    ** Others complain about 0x7ffffffffffffffffLL.  The following macro seems\n    ** to provide the constant while making all compilers happy.\n    */\n#   define MAX_ROWID  (i64)( (((u64)0x7fffffff)<<32) | (u64)0xffffffff )\n#endif\n\n    if( !pC->useRandomRowid ){\n      rc = sqlite3BtreeLast(pC->uc.pCursor, &res);\n      if( rc!=SQLITE_OK ){\n        goto abort_due_to_error;\n      }\n      if( res ){\n        v = 1;   /* IMP: R-61914-48074 */\n      }else{\n        assert( sqlite3BtreeCursorIsValid(pC->uc.pCursor) );\n        v = sqlite3BtreeIntegerKey(pC->uc.pCursor);\n        if( v>=MAX_ROWID ){\n          pC->useRandomRowid = 1;\n        }else{\n          v++;   /* IMP: R-29538-34987 */\n        }\n      }\n    }\n\n#ifndef SQLITE_OMIT_AUTOINCREMENT\n    if( pOp->p3 ){\n      /* Assert that P3 is a valid memory cell. */\n      assert( pOp->p3>0 );\n      if( p->pFrame ){\n        for(pFrame=p->pFrame; pFrame->pParent; pFrame=pFrame->pParent);\n        /* Assert that P3 is a valid memory cell. */\n        assert( pOp->p3<=pFrame->nMem );\n        pMem = &pFrame->aMem[pOp->p3];\n      }else{\n        /* Assert that P3 is a valid memory cell. */\n        assert( pOp->p3<=(p->nMem+1 - p->nCursor) );\n        pMem = &aMem[pOp->p3];\n        memAboutToChange(p, pMem);\n      }\n      assert( memIsValid(pMem) );\n\n      REGISTER_TRACE(pOp->p3, pMem);\n      sqlite3VdbeMemIntegerify(pMem);\n      assert( (pMem->flags & MEM_Int)!=0 );  /* mem(P3) holds an integer */\n      if( pMem->u.i==MAX_ROWID || pC->useRandomRowid ){\n        rc = SQLITE_FULL;   /* IMP: R-17817-00630 */\n        goto abort_due_to_error;\n      }\n      if( v<pMem->u.i+1 ){\n        v = pMem->u.i + 1;\n      }\n      pMem->u.i = v;\n    }\n#endif\n    if( pC->useRandomRowid ){\n      /* IMPLEMENTATION-OF: R-07677-41881 If the largest ROWID is equal to the\n      ** largest possible integer (9223372036854775807) then the database\n      ** engine starts picking positive candidate ROWIDs at random until\n      ** it finds one that is not previously used. */\n      assert( pOp->p3==0 );  /* We cannot be in random rowid mode if this is\n                             ** an AUTOINCREMENT table. */\n      cnt = 0;\n      do{\n        sqlite3_randomness(sizeof(v), &v);\n        v &= (MAX_ROWID>>1); v++;  /* Ensure that v is greater than zero */\n      }while(  ((rc = sqlite3BtreeMovetoUnpacked(pC->uc.pCursor, 0, (u64)v,\n                                                 0, &res))==SQLITE_OK)\n            && (res==0)\n            && (++cnt<100));\n      if( rc ) goto abort_due_to_error;\n      if( res==0 ){\n        rc = SQLITE_FULL;   /* IMP: R-38219-53002 */\n        goto abort_due_to_error;\n      }\n      assert( v>0 );  /* EV: R-40812-03570 */\n    }\n    pC->deferredMoveto = 0;\n    pC->cacheStatus = CACHE_STALE;\n  }\n  pOut->u.i = v;\n  break;\n}\n\n/* Opcode: Insert P1 P2 P3 P4 P5\n** Synopsis: intkey=r[P3] data=r[P2]\n**\n** Write an entry into the table of cursor P1.  A new entry is\n** created if it doesn't already exist or the data for an existing\n** entry is overwritten.  The data is the value MEM_Blob stored in register\n** number P2. The key is stored in register P3. The key must\n** be a MEM_Int.\n**\n** If the OPFLAG_NCHANGE flag of P5 is set, then the row change count is\n** incremented (otherwise not).  If the OPFLAG_LASTROWID flag of P5 is set,\n** then rowid is stored for subsequent return by the\n** sqlite3_last_insert_rowid() function (otherwise it is unmodified).\n**\n** If the OPFLAG_USESEEKRESULT flag of P5 is set, the implementation might\n** run faster by avoiding an unnecessary seek on cursor P1.  However,\n** the OPFLAG_USESEEKRESULT flag must only be set if there have been no prior\n** seeks on the cursor or if the most recent seek used a key equal to P3.\n**\n** If the OPFLAG_ISUPDATE flag is set, then this opcode is part of an\n** UPDATE operation.  Otherwise (if the flag is clear) then this opcode\n** is part of an INSERT operation.  The difference is only important to\n** the update hook.\n**\n** Parameter P4 may point to a Table structure, or may be NULL. If it is \n** not NULL, then the update-hook (sqlite3.xUpdateCallback) is invoked \n** following a successful insert.\n**\n** (WARNING/TODO: If P1 is a pseudo-cursor and P2 is dynamically\n** allocated, then ownership of P2 is transferred to the pseudo-cursor\n** and register P2 becomes ephemeral.  If the cursor is changed, the\n** value of register P2 will then change.  Make sure this does not\n** cause any problems.)\n**\n** This instruction only works on tables.  The equivalent instruction\n** for indices is OP_IdxInsert.\n*/\ncase OP_Insert: {\n  Mem *pData;       /* MEM cell holding data for the record to be inserted */\n  Mem *pKey;        /* MEM cell holding key  for the record */\n  VdbeCursor *pC;   /* Cursor to table into which insert is written */\n  int seekResult;   /* Result of prior seek or 0 if no USESEEKRESULT flag */\n  const char *zDb;  /* database name - used by the update hook */\n  Table *pTab;      /* Table structure - used by update and pre-update hooks */\n  BtreePayload x;   /* Payload to be inserted */\n\n  pData = &aMem[pOp->p2];\n  assert( pOp->p1>=0 && pOp->p1<p->nCursor );\n  assert( memIsValid(pData) );\n  pC = p->apCsr[pOp->p1];\n  assert( pC!=0 );\n  assert( pC->eCurType==CURTYPE_BTREE );\n  assert( pC->uc.pCursor!=0 );\n  assert( (pOp->p5 & OPFLAG_ISNOOP) || pC->isTable );\n  assert( pOp->p4type==P4_TABLE || pOp->p4type>=P4_STATIC );\n  REGISTER_TRACE(pOp->p2, pData);\n  sqlite3VdbeIncrWriteCounter(p, pC);\n\n  pKey = &aMem[pOp->p3];\n  assert( pKey->flags & MEM_Int );\n  assert( memIsValid(pKey) );\n  REGISTER_TRACE(pOp->p3, pKey);\n  x.nKey = pKey->u.i;\n\n  if( pOp->p4type==P4_TABLE && HAS_UPDATE_HOOK(db) ){\n    assert( pC->iDb>=0 );\n    zDb = db->aDb[pC->iDb].zDbSName;\n    pTab = pOp->p4.pTab;\n    assert( (pOp->p5 & OPFLAG_ISNOOP) || HasRowid(pTab) );\n  }else{\n    pTab = 0;\n    zDb = 0;  /* Not needed.  Silence a compiler warning. */\n  }\n\n#ifdef SQLITE_ENABLE_PREUPDATE_HOOK\n  /* Invoke the pre-update hook, if any */\n  if( pTab ){\n    if( db->xPreUpdateCallback && !(pOp->p5 & OPFLAG_ISUPDATE) ){\n      sqlite3VdbePreUpdateHook(p, pC, SQLITE_INSERT, zDb, pTab, x.nKey,pOp->p2);\n    }\n    if( db->xUpdateCallback==0 || pTab->aCol==0 ){\n      /* Prevent post-update hook from running in cases when it should not */\n      pTab = 0;\n    }\n  }\n  if( pOp->p5 & OPFLAG_ISNOOP ) break;\n#endif\n\n  if( pOp->p5 & OPFLAG_NCHANGE ) p->nChange++;\n  if( pOp->p5 & OPFLAG_LASTROWID ) db->lastRowid = x.nKey;\n  assert( pData->flags & (MEM_Blob|MEM_Str) );\n  x.pData = pData->z;\n  x.nData = pData->n;\n  seekResult = ((pOp->p5 & OPFLAG_USESEEKRESULT) ? pC->seekResult : 0);\n  if( pData->flags & MEM_Zero ){\n    x.nZero = pData->u.nZero;\n  }else{\n    x.nZero = 0;\n  }\n  x.pKey = 0;\n  rc = sqlite3BtreeInsert(pC->uc.pCursor, &x,\n      (pOp->p5 & (OPFLAG_APPEND|OPFLAG_SAVEPOSITION)), seekResult\n  );\n  pC->deferredMoveto = 0;\n  pC->cacheStatus = CACHE_STALE;\n\n  /* Invoke the update-hook if required. */\n  if( rc ) goto abort_due_to_error;\n  if( pTab ){\n    assert( db->xUpdateCallback!=0 );\n    assert( pTab->aCol!=0 );\n    db->xUpdateCallback(db->pUpdateArg,\n           (pOp->p5 & OPFLAG_ISUPDATE) ? SQLITE_UPDATE : SQLITE_INSERT,\n           zDb, pTab->zName, x.nKey);\n  }\n  break;\n}\n\n/* Opcode: Delete P1 P2 P3 P4 P5\n**\n** Delete the record at which the P1 cursor is currently pointing.\n**\n** If the OPFLAG_SAVEPOSITION bit of the P5 parameter is set, then\n** the cursor will be left pointing at  either the next or the previous\n** record in the table. If it is left pointing at the next record, then\n** the next Next instruction will be a no-op. As a result, in this case\n** it is ok to delete a record from within a Next loop. If \n** OPFLAG_SAVEPOSITION bit of P5 is clear, then the cursor will be\n** left in an undefined state.\n**\n** If the OPFLAG_AUXDELETE bit is set on P5, that indicates that this\n** delete one of several associated with deleting a table row and all its\n** associated index entries.  Exactly one of those deletes is the \"primary\"\n** delete.  The others are all on OPFLAG_FORDELETE cursors or else are\n** marked with the AUXDELETE flag.\n**\n** If the OPFLAG_NCHANGE flag of P2 (NB: P2 not P5) is set, then the row\n** change count is incremented (otherwise not).\n**\n** P1 must not be pseudo-table.  It has to be a real table with\n** multiple rows.\n**\n** If P4 is not NULL then it points to a Table object. In this case either \n** the update or pre-update hook, or both, may be invoked. The P1 cursor must\n** have been positioned using OP_NotFound prior to invoking this opcode in \n** this case. Specifically, if one is configured, the pre-update hook is \n** invoked if P4 is not NULL. The update-hook is invoked if one is configured, \n** P4 is not NULL, and the OPFLAG_NCHANGE flag is set in P2.\n**\n** If the OPFLAG_ISUPDATE flag is set in P2, then P3 contains the address\n** of the memory cell that contains the value that the rowid of the row will\n** be set to by the update.\n*/\ncase OP_Delete: {\n  VdbeCursor *pC;\n  const char *zDb;\n  Table *pTab;\n  int opflags;\n\n  opflags = pOp->p2;\n  assert( pOp->p1>=0 && pOp->p1<p->nCursor );\n  pC = p->apCsr[pOp->p1];\n  assert( pC!=0 );\n  assert( pC->eCurType==CURTYPE_BTREE );\n  assert( pC->uc.pCursor!=0 );\n  assert( pC->deferredMoveto==0 );\n  sqlite3VdbeIncrWriteCounter(p, pC);\n\n#ifdef SQLITE_DEBUG\n  if( pOp->p4type==P4_TABLE && HasRowid(pOp->p4.pTab) && pOp->p5==0 ){\n    /* If p5 is zero, the seek operation that positioned the cursor prior to\n    ** OP_Delete will have also set the pC->movetoTarget field to the rowid of\n    ** the row that is being deleted */\n    i64 iKey = sqlite3BtreeIntegerKey(pC->uc.pCursor);\n    assert( pC->movetoTarget==iKey );\n  }\n#endif\n\n  /* If the update-hook or pre-update-hook will be invoked, set zDb to\n  ** the name of the db to pass as to it. Also set local pTab to a copy\n  ** of p4.pTab. Finally, if p5 is true, indicating that this cursor was\n  ** last moved with OP_Next or OP_Prev, not Seek or NotFound, set \n  ** VdbeCursor.movetoTarget to the current rowid.  */\n  if( pOp->p4type==P4_TABLE && HAS_UPDATE_HOOK(db) ){\n    assert( pC->iDb>=0 );\n    assert( pOp->p4.pTab!=0 );\n    zDb = db->aDb[pC->iDb].zDbSName;\n    pTab = pOp->p4.pTab;\n    if( (pOp->p5 & OPFLAG_SAVEPOSITION)!=0 && pC->isTable ){\n      pC->movetoTarget = sqlite3BtreeIntegerKey(pC->uc.pCursor);\n    }\n  }else{\n    zDb = 0;   /* Not needed.  Silence a compiler warning. */\n    pTab = 0;  /* Not needed.  Silence a compiler warning. */\n  }\n\n#ifdef SQLITE_ENABLE_PREUPDATE_HOOK\n  /* Invoke the pre-update-hook if required. */\n  if( db->xPreUpdateCallback && pOp->p4.pTab ){\n    assert( !(opflags & OPFLAG_ISUPDATE) \n         || HasRowid(pTab)==0 \n         || (aMem[pOp->p3].flags & MEM_Int) \n    );\n    sqlite3VdbePreUpdateHook(p, pC,\n        (opflags & OPFLAG_ISUPDATE) ? SQLITE_UPDATE : SQLITE_DELETE, \n        zDb, pTab, pC->movetoTarget,\n        pOp->p3\n    );\n  }\n  if( opflags & OPFLAG_ISNOOP ) break;\n#endif\n \n  /* Only flags that can be set are SAVEPOISTION and AUXDELETE */ \n  assert( (pOp->p5 & ~(OPFLAG_SAVEPOSITION|OPFLAG_AUXDELETE))==0 );\n  assert( OPFLAG_SAVEPOSITION==BTREE_SAVEPOSITION );\n  assert( OPFLAG_AUXDELETE==BTREE_AUXDELETE );\n\n#ifdef SQLITE_DEBUG\n  if( p->pFrame==0 ){\n    if( pC->isEphemeral==0\n        && (pOp->p5 & OPFLAG_AUXDELETE)==0\n        && (pC->wrFlag & OPFLAG_FORDELETE)==0\n      ){\n      nExtraDelete++;\n    }\n    if( pOp->p2 & OPFLAG_NCHANGE ){\n      nExtraDelete--;\n    }\n  }\n#endif\n\n  rc = sqlite3BtreeDelete(pC->uc.pCursor, pOp->p5);\n  pC->cacheStatus = CACHE_STALE;\n  pC->seekResult = 0;\n  if( rc ) goto abort_due_to_error;\n\n  /* Invoke the update-hook if required. */\n  if( opflags & OPFLAG_NCHANGE ){\n    p->nChange++;\n    if( db->xUpdateCallback && HasRowid(pTab) ){\n      db->xUpdateCallback(db->pUpdateArg, SQLITE_DELETE, zDb, pTab->zName,\n          pC->movetoTarget);\n      assert( pC->iDb>=0 );\n    }\n  }\n\n  break;\n}\n/* Opcode: ResetCount * * * * *\n**\n** The value of the change counter is copied to the database handle\n** change counter (returned by subsequent calls to sqlite3_changes()).\n** Then the VMs internal change counter resets to 0.\n** This is used by trigger programs.\n*/\ncase OP_ResetCount: {\n  sqlite3VdbeSetChanges(db, p->nChange);\n  p->nChange = 0;\n  break;\n}\n\n/* Opcode: SorterCompare P1 P2 P3 P4\n** Synopsis: if key(P1)!=trim(r[P3],P4) goto P2\n**\n** P1 is a sorter cursor. This instruction compares a prefix of the\n** record blob in register P3 against a prefix of the entry that \n** the sorter cursor currently points to.  Only the first P4 fields\n** of r[P3] and the sorter record are compared.\n**\n** If either P3 or the sorter contains a NULL in one of their significant\n** fields (not counting the P4 fields at the end which are ignored) then\n** the comparison is assumed to be equal.\n**\n** Fall through to next instruction if the two records compare equal to\n** each other.  Jump to P2 if they are different.\n*/\ncase OP_SorterCompare: {\n  VdbeCursor *pC;\n  int res;\n  int nKeyCol;\n\n  pC = p->apCsr[pOp->p1];\n  assert( isSorter(pC) );\n  assert( pOp->p4type==P4_INT32 );\n  pIn3 = &aMem[pOp->p3];\n  nKeyCol = pOp->p4.i;\n  res = 0;\n  rc = sqlite3VdbeSorterCompare(pC, pIn3, nKeyCol, &res);\n  VdbeBranchTaken(res!=0,2);\n  if( rc ) goto abort_due_to_error;\n  if( res ) goto jump_to_p2;\n  break;\n};\n\n/* Opcode: SorterData P1 P2 P3 * *\n** Synopsis: r[P2]=data\n**\n** Write into register P2 the current sorter data for sorter cursor P1.\n** Then clear the column header cache on cursor P3.\n**\n** This opcode is normally use to move a record out of the sorter and into\n** a register that is the source for a pseudo-table cursor created using\n** OpenPseudo.  That pseudo-table cursor is the one that is identified by\n** parameter P3.  Clearing the P3 column cache as part of this opcode saves\n** us from having to issue a separate NullRow instruction to clear that cache.\n*/\ncase OP_SorterData: {\n  VdbeCursor *pC;\n\n  pOut = &aMem[pOp->p2];\n  pC = p->apCsr[pOp->p1];\n  assert( isSorter(pC) );\n  rc = sqlite3VdbeSorterRowkey(pC, pOut);\n  assert( rc!=SQLITE_OK || (pOut->flags & MEM_Blob) );\n  assert( pOp->p1>=0 && pOp->p1<p->nCursor );\n  if( rc ) goto abort_due_to_error;\n  p->apCsr[pOp->p3]->cacheStatus = CACHE_STALE;\n  break;\n}\n\n/* Opcode: RowData P1 P2 P3 * *\n** Synopsis: r[P2]=data\n**\n** Write into register P2 the complete row content for the row at \n** which cursor P1 is currently pointing.\n** There is no interpretation of the data.  \n** It is just copied onto the P2 register exactly as \n** it is found in the database file.\n**\n** If cursor P1 is an index, then the content is the key of the row.\n** If cursor P2 is a table, then the content extracted is the data.\n**\n** If the P1 cursor must be pointing to a valid row (not a NULL row)\n** of a real table, not a pseudo-table.\n**\n** If P3!=0 then this opcode is allowed to make an ephemeral pointer\n** into the database page.  That means that the content of the output\n** register will be invalidated as soon as the cursor moves - including\n** moves caused by other cursors that \"save\" the current cursors\n** position in order that they can write to the same table.  If P3==0\n** then a copy of the data is made into memory.  P3!=0 is faster, but\n** P3==0 is safer.\n**\n** If P3!=0 then the content of the P2 register is unsuitable for use\n** in OP_Result and any OP_Result will invalidate the P2 register content.\n** The P2 register content is invalidated by opcodes like OP_Function or\n** by any use of another cursor pointing to the same table.\n*/\ncase OP_RowData: {\n  VdbeCursor *pC;\n  BtCursor *pCrsr;\n  u32 n;\n\n  pOut = out2Prerelease(p, pOp);\n\n  assert( pOp->p1>=0 && pOp->p1<p->nCursor );\n  pC = p->apCsr[pOp->p1];\n  assert( pC!=0 );\n  assert( pC->eCurType==CURTYPE_BTREE );\n  assert( isSorter(pC)==0 );\n  assert( pC->nullRow==0 );\n  assert( pC->uc.pCursor!=0 );\n  pCrsr = pC->uc.pCursor;\n\n  /* The OP_RowData opcodes always follow OP_NotExists or\n  ** OP_SeekRowid or OP_Rewind/Op_Next with no intervening instructions\n  ** that might invalidate the cursor.\n  ** If this where not the case, on of the following assert()s\n  ** would fail.  Should this ever change (because of changes in the code\n  ** generator) then the fix would be to insert a call to\n  ** sqlite3VdbeCursorMoveto().\n  */\n  assert( pC->deferredMoveto==0 );\n  assert( sqlite3BtreeCursorIsValid(pCrsr) );\n#if 0  /* Not required due to the previous to assert() statements */\n  rc = sqlite3VdbeCursorMoveto(pC);\n  if( rc!=SQLITE_OK ) goto abort_due_to_error;\n#endif\n\n  n = sqlite3BtreePayloadSize(pCrsr);\n  if( n>(u32)db->aLimit[SQLITE_LIMIT_LENGTH] ){\n    goto too_big;\n  }\n  testcase( n==0 );\n  rc = sqlite3VdbeMemFromBtree(pCrsr, 0, n, pOut);\n  if( rc ) goto abort_due_to_error;\n  if( !pOp->p3 ) Deephemeralize(pOut);\n  UPDATE_MAX_BLOBSIZE(pOut);\n  REGISTER_TRACE(pOp->p2, pOut);\n  break;\n}\n\n/* Opcode: Rowid P1 P2 * * *\n** Synopsis: r[P2]=rowid\n**\n** Store in register P2 an integer which is the key of the table entry that\n** P1 is currently point to.\n**\n** P1 can be either an ordinary table or a virtual table.  There used to\n** be a separate OP_VRowid opcode for use with virtual tables, but this\n** one opcode now works for both table types.\n*/\ncase OP_Rowid: {                 /* out2 */\n  VdbeCursor *pC;\n  i64 v;\n  sqlite3_vtab *pVtab;\n  const sqlite3_module *pModule;\n\n  pOut = out2Prerelease(p, pOp);\n  assert( pOp->p1>=0 && pOp->p1<p->nCursor );\n  pC = p->apCsr[pOp->p1];\n  assert( pC!=0 );\n  assert( pC->eCurType!=CURTYPE_PSEUDO || pC->nullRow );\n  if( pC->nullRow ){\n    pOut->flags = MEM_Null;\n    break;\n  }else if( pC->deferredMoveto ){\n    v = pC->movetoTarget;\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n  }else if( pC->eCurType==CURTYPE_VTAB ){\n    assert( pC->uc.pVCur!=0 );\n    pVtab = pC->uc.pVCur->pVtab;\n    pModule = pVtab->pModule;\n    assert( pModule->xRowid );\n    rc = pModule->xRowid(pC->uc.pVCur, &v);\n    sqlite3VtabImportErrmsg(p, pVtab);\n    if( rc ) goto abort_due_to_error;\n#endif /* SQLITE_OMIT_VIRTUALTABLE */\n  }else{\n    assert( pC->eCurType==CURTYPE_BTREE );\n    assert( pC->uc.pCursor!=0 );\n    rc = sqlite3VdbeCursorRestore(pC);\n    if( rc ) goto abort_due_to_error;\n    if( pC->nullRow ){\n      pOut->flags = MEM_Null;\n      break;\n    }\n    v = sqlite3BtreeIntegerKey(pC->uc.pCursor);\n  }\n  pOut->u.i = v;\n  break;\n}\n\n/* Opcode: NullRow P1 * * * *\n**\n** Move the cursor P1 to a null row.  Any OP_Column operations\n** that occur while the cursor is on the null row will always\n** write a NULL.\n*/\ncase OP_NullRow: {\n  VdbeCursor *pC;\n\n  assert( pOp->p1>=0 && pOp->p1<p->nCursor );\n  pC = p->apCsr[pOp->p1];\n  assert( pC!=0 );\n  pC->nullRow = 1;\n  pC->cacheStatus = CACHE_STALE;\n  if( pC->eCurType==CURTYPE_BTREE ){\n    assert( pC->uc.pCursor!=0 );\n    sqlite3BtreeClearCursor(pC->uc.pCursor);\n  }\n#ifdef SQLITE_DEBUG\n  if( pC->seekOp==0 ) pC->seekOp = OP_NullRow;\n#endif\n  break;\n}\n\n/* Opcode: SeekEnd P1 * * * *\n**\n** Position cursor P1 at the end of the btree for the purpose of\n** appending a new entry onto the btree.\n**\n** It is assumed that the cursor is used only for appending and so\n** if the cursor is valid, then the cursor must already be pointing\n** at the end of the btree and so no changes are made to\n** the cursor.\n*/\n/* Opcode: Last P1 P2 * * *\n**\n** The next use of the Rowid or Column or Prev instruction for P1 \n** will refer to the last entry in the database table or index.\n** If the table or index is empty and P2>0, then jump immediately to P2.\n** If P2 is 0 or if the table or index is not empty, fall through\n** to the following instruction.\n**\n** This opcode leaves the cursor configured to move in reverse order,\n** from the end toward the beginning.  In other words, the cursor is\n** configured to use Prev, not Next.\n*/\ncase OP_SeekEnd:\ncase OP_Last: {        /* jump */\n  VdbeCursor *pC;\n  BtCursor *pCrsr;\n  int res;\n\n  assert( pOp->p1>=0 && pOp->p1<p->nCursor );\n  pC = p->apCsr[pOp->p1];\n  assert( pC!=0 );\n  assert( pC->eCurType==CURTYPE_BTREE );\n  pCrsr = pC->uc.pCursor;\n  res = 0;\n  assert( pCrsr!=0 );\n#ifdef SQLITE_DEBUG\n  pC->seekOp = pOp->opcode;\n#endif\n  if( pOp->opcode==OP_SeekEnd ){\n    assert( pOp->p2==0 );\n    pC->seekResult = -1;\n    if( sqlite3BtreeCursorIsValidNN(pCrsr) ){\n      break;\n    }\n  }\n  rc = sqlite3BtreeLast(pCrsr, &res);\n  pC->nullRow = (u8)res;\n  pC->deferredMoveto = 0;\n  pC->cacheStatus = CACHE_STALE;\n  if( rc ) goto abort_due_to_error;\n  if( pOp->p2>0 ){\n    VdbeBranchTaken(res!=0,2);\n    if( res ) goto jump_to_p2;\n  }\n  break;\n}\n\n/* Opcode: IfSmaller P1 P2 P3 * *\n**\n** Estimate the number of rows in the table P1.  Jump to P2 if that\n** estimate is less than approximately 2**(0.1*P3).\n*/\ncase OP_IfSmaller: {        /* jump */\n  VdbeCursor *pC;\n  BtCursor *pCrsr;\n  int res;\n  i64 sz;\n\n  assert( pOp->p1>=0 && pOp->p1<p->nCursor );\n  pC = p->apCsr[pOp->p1];\n  assert( pC!=0 );\n  pCrsr = pC->uc.pCursor;\n  assert( pCrsr );\n  rc = sqlite3BtreeFirst(pCrsr, &res);\n  if( rc ) goto abort_due_to_error;\n  if( res==0 ){\n    sz = sqlite3BtreeRowCountEst(pCrsr);\n    if( ALWAYS(sz>=0) && sqlite3LogEst((u64)sz)<pOp->p3 ) res = 1;\n  }\n  VdbeBranchTaken(res!=0,2);\n  if( res ) goto jump_to_p2;\n  break;\n}\n\n\n/* Opcode: SorterSort P1 P2 * * *\n**\n** After all records have been inserted into the Sorter object\n** identified by P1, invoke this opcode to actually do the sorting.\n** Jump to P2 if there are no records to be sorted.\n**\n** This opcode is an alias for OP_Sort and OP_Rewind that is used\n** for Sorter objects.\n*/\n/* Opcode: Sort P1 P2 * * *\n**\n** This opcode does exactly the same thing as OP_Rewind except that\n** it increments an undocumented global variable used for testing.\n**\n** Sorting is accomplished by writing records into a sorting index,\n** then rewinding that index and playing it back from beginning to\n** end.  We use the OP_Sort opcode instead of OP_Rewind to do the\n** rewinding so that the global variable will be incremented and\n** regression tests can determine whether or not the optimizer is\n** correctly optimizing out sorts.\n*/\ncase OP_SorterSort:    /* jump */\ncase OP_Sort: {        /* jump */\n#ifdef SQLITE_TEST\n  sqlite3_sort_count++;\n  sqlite3_search_count--;\n#endif\n  p->aCounter[SQLITE_STMTSTATUS_SORT]++;\n  /* Fall through into OP_Rewind */\n}\n/* Opcode: Rewind P1 P2 * * P5\n**\n** The next use of the Rowid or Column or Next instruction for P1 \n** will refer to the first entry in the database table or index.\n** If the table or index is empty, jump immediately to P2.\n** If the table or index is not empty, fall through to the following \n** instruction.\n**\n** If P5 is non-zero and the table is not empty, then the \"skip-next\"\n** flag is set on the cursor so that the next OP_Next instruction \n** executed on it is a no-op.\n**\n** This opcode leaves the cursor configured to move in forward order,\n** from the beginning toward the end.  In other words, the cursor is\n** configured to use Next, not Prev.\n*/\ncase OP_Rewind: {        /* jump */\n  VdbeCursor *pC;\n  BtCursor *pCrsr;\n  int res;\n\n  assert( pOp->p1>=0 && pOp->p1<p->nCursor );\n  pC = p->apCsr[pOp->p1];\n  assert( pC!=0 );\n  assert( isSorter(pC)==(pOp->opcode==OP_SorterSort) );\n  res = 1;\n#ifdef SQLITE_DEBUG\n  pC->seekOp = OP_Rewind;\n#endif\n  if( isSorter(pC) ){\n    rc = sqlite3VdbeSorterRewind(pC, &res);\n  }else{\n    assert( pC->eCurType==CURTYPE_BTREE );\n    pCrsr = pC->uc.pCursor;\n    assert( pCrsr );\n    rc = sqlite3BtreeFirst(pCrsr, &res);\n#ifndef SQLITE_OMIT_WINDOWFUNC\n    if( pOp->p5 ) sqlite3BtreeSkipNext(pCrsr);\n#endif\n    pC->deferredMoveto = 0;\n    pC->cacheStatus = CACHE_STALE;\n  }\n  if( rc ) goto abort_due_to_error;\n  pC->nullRow = (u8)res;\n  assert( pOp->p2>0 && pOp->p2<p->nOp );\n  VdbeBranchTaken(res!=0,2);\n  if( res ) goto jump_to_p2;\n  break;\n}\n\n/* Opcode: Next P1 P2 P3 P4 P5\n**\n** Advance cursor P1 so that it points to the next key/data pair in its\n** table or index.  If there are no more key/value pairs then fall through\n** to the following instruction.  But if the cursor advance was successful,\n** jump immediately to P2.\n**\n** The Next opcode is only valid following an SeekGT, SeekGE, or\n** OP_Rewind opcode used to position the cursor.  Next is not allowed\n** to follow SeekLT, SeekLE, or OP_Last.\n**\n** The P1 cursor must be for a real table, not a pseudo-table.  P1 must have\n** been opened prior to this opcode or the program will segfault.\n**\n** The P3 value is a hint to the btree implementation. If P3==1, that\n** means P1 is an SQL index and that this instruction could have been\n** omitted if that index had been unique.  P3 is usually 0.  P3 is\n** always either 0 or 1.\n**\n** P4 is always of type P4_ADVANCE. The function pointer points to\n** sqlite3BtreeNext().\n**\n** If P5 is positive and the jump is taken, then event counter\n** number P5-1 in the prepared statement is incremented.\n**\n** See also: Prev\n*/\n/* Opcode: Prev P1 P2 P3 P4 P5\n**\n** Back up cursor P1 so that it points to the previous key/data pair in its\n** table or index.  If there is no previous key/value pairs then fall through\n** to the following instruction.  But if the cursor backup was successful,\n** jump immediately to P2.\n**\n**\n** The Prev opcode is only valid following an SeekLT, SeekLE, or\n** OP_Last opcode used to position the cursor.  Prev is not allowed\n** to follow SeekGT, SeekGE, or OP_Rewind.\n**\n** The P1 cursor must be for a real table, not a pseudo-table.  If P1 is\n** not open then the behavior is undefined.\n**\n** The P3 value is a hint to the btree implementation. If P3==1, that\n** means P1 is an SQL index and that this instruction could have been\n** omitted if that index had been unique.  P3 is usually 0.  P3 is\n** always either 0 or 1.\n**\n** P4 is always of type P4_ADVANCE. The function pointer points to\n** sqlite3BtreePrevious().\n**\n** If P5 is positive and the jump is taken, then event counter\n** number P5-1 in the prepared statement is incremented.\n*/\n/* Opcode: SorterNext P1 P2 * * P5\n**\n** This opcode works just like OP_Next except that P1 must be a\n** sorter object for which the OP_SorterSort opcode has been\n** invoked.  This opcode advances the cursor to the next sorted\n** record, or jumps to P2 if there are no more sorted records.\n*/\ncase OP_SorterNext: {  /* jump */\n  VdbeCursor *pC;\n\n  pC = p->apCsr[pOp->p1];\n  assert( isSorter(pC) );\n  rc = sqlite3VdbeSorterNext(db, pC);\n  goto next_tail;\ncase OP_Prev:          /* jump */\ncase OP_Next:          /* jump */\n  assert( pOp->p1>=0 && pOp->p1<p->nCursor );\n  assert( pOp->p5<ArraySize(p->aCounter) );\n  pC = p->apCsr[pOp->p1];\n  assert( pC!=0 );\n  assert( pC->deferredMoveto==0 );\n  assert( pC->eCurType==CURTYPE_BTREE );\n  assert( pOp->opcode!=OP_Next || pOp->p4.xAdvance==sqlite3BtreeNext );\n  assert( pOp->opcode!=OP_Prev || pOp->p4.xAdvance==sqlite3BtreePrevious );\n\n  /* The Next opcode is only used after SeekGT, SeekGE, Rewind, and Found.\n  ** The Prev opcode is only used after SeekLT, SeekLE, and Last. */\n  assert( pOp->opcode!=OP_Next\n       || pC->seekOp==OP_SeekGT || pC->seekOp==OP_SeekGE\n       || pC->seekOp==OP_Rewind || pC->seekOp==OP_Found \n       || pC->seekOp==OP_NullRow|| pC->seekOp==OP_SeekRowid);\n  assert( pOp->opcode!=OP_Prev\n       || pC->seekOp==OP_SeekLT || pC->seekOp==OP_SeekLE\n       || pC->seekOp==OP_Last \n       || pC->seekOp==OP_NullRow);\n\n  rc = pOp->p4.xAdvance(pC->uc.pCursor, pOp->p3);\nnext_tail:\n  pC->cacheStatus = CACHE_STALE;\n  VdbeBranchTaken(rc==SQLITE_OK,2);\n  if( rc==SQLITE_OK ){\n    pC->nullRow = 0;\n    p->aCounter[pOp->p5]++;\n#ifdef SQLITE_TEST\n    sqlite3_search_count++;\n#endif\n    goto jump_to_p2_and_check_for_interrupt;\n  }\n  if( rc!=SQLITE_DONE ) goto abort_due_to_error;\n  rc = SQLITE_OK;\n  pC->nullRow = 1;\n  goto check_for_interrupt;\n}\n\n/* Opcode: IdxInsert P1 P2 P3 P4 P5\n** Synopsis: key=r[P2]\n**\n** Register P2 holds an SQL index key made using the\n** MakeRecord instructions.  This opcode writes that key\n** into the index P1.  Data for the entry is nil.\n**\n** If P4 is not zero, then it is the number of values in the unpacked\n** key of reg(P2).  In that case, P3 is the index of the first register\n** for the unpacked key.  The availability of the unpacked key can sometimes\n** be an optimization.\n**\n** If P5 has the OPFLAG_APPEND bit set, that is a hint to the b-tree layer\n** that this insert is likely to be an append.\n**\n** If P5 has the OPFLAG_NCHANGE bit set, then the change counter is\n** incremented by this instruction.  If the OPFLAG_NCHANGE bit is clear,\n** then the change counter is unchanged.\n**\n** If the OPFLAG_USESEEKRESULT flag of P5 is set, the implementation might\n** run faster by avoiding an unnecessary seek on cursor P1.  However,\n** the OPFLAG_USESEEKRESULT flag must only be set if there have been no prior\n** seeks on the cursor or if the most recent seek used a key equivalent\n** to P2. \n**\n** This instruction only works for indices.  The equivalent instruction\n** for tables is OP_Insert.\n*/\n/* Opcode: SorterInsert P1 P2 * * *\n** Synopsis: key=r[P2]\n**\n** Register P2 holds an SQL index key made using the\n** MakeRecord instructions.  This opcode writes that key\n** into the sorter P1.  Data for the entry is nil.\n*/\ncase OP_SorterInsert:       /* in2 */\ncase OP_IdxInsert: {        /* in2 */\n  VdbeCursor *pC;\n  BtreePayload x;\n\n  assert( pOp->p1>=0 && pOp->p1<p->nCursor );\n  pC = p->apCsr[pOp->p1];\n  sqlite3VdbeIncrWriteCounter(p, pC);\n  assert( pC!=0 );\n  assert( isSorter(pC)==(pOp->opcode==OP_SorterInsert) );\n  pIn2 = &aMem[pOp->p2];\n  assert( pIn2->flags & MEM_Blob );\n  if( pOp->p5 & OPFLAG_NCHANGE ) p->nChange++;\n  assert( pC->eCurType==CURTYPE_BTREE || pOp->opcode==OP_SorterInsert );\n  assert( pC->isTable==0 );\n  rc = ExpandBlob(pIn2);\n  if( rc ) goto abort_due_to_error;\n  if( pOp->opcode==OP_SorterInsert ){\n    rc = sqlite3VdbeSorterWrite(pC, pIn2);\n  }else{\n    x.nKey = pIn2->n;\n    x.pKey = pIn2->z;\n    x.aMem = aMem + pOp->p3;\n    x.nMem = (u16)pOp->p4.i;\n    rc = sqlite3BtreeInsert(pC->uc.pCursor, &x,\n         (pOp->p5 & (OPFLAG_APPEND|OPFLAG_SAVEPOSITION)), \n        ((pOp->p5 & OPFLAG_USESEEKRESULT) ? pC->seekResult : 0)\n        );\n    assert( pC->deferredMoveto==0 );\n    pC->cacheStatus = CACHE_STALE;\n  }\n  if( rc) goto abort_due_to_error;\n  break;\n}\n\n/* Opcode: IdxDelete P1 P2 P3 * *\n** Synopsis: key=r[P2@P3]\n**\n** The content of P3 registers starting at register P2 form\n** an unpacked index key. This opcode removes that entry from the \n** index opened by cursor P1.\n*/\ncase OP_IdxDelete: {\n  VdbeCursor *pC;\n  BtCursor *pCrsr;\n  int res;\n  UnpackedRecord r;\n\n  assert( pOp->p3>0 );\n  assert( pOp->p2>0 && pOp->p2+pOp->p3<=(p->nMem+1 - p->nCursor)+1 );\n  assert( pOp->p1>=0 && pOp->p1<p->nCursor );\n  pC = p->apCsr[pOp->p1];\n  assert( pC!=0 );\n  assert( pC->eCurType==CURTYPE_BTREE );\n  sqlite3VdbeIncrWriteCounter(p, pC);\n  pCrsr = pC->uc.pCursor;\n  assert( pCrsr!=0 );\n  assert( pOp->p5==0 );\n  r.pKeyInfo = pC->pKeyInfo;\n  r.nField = (u16)pOp->p3;\n  r.default_rc = 0;\n  r.aMem = &aMem[pOp->p2];\n  rc = sqlite3BtreeMovetoUnpacked(pCrsr, &r, 0, 0, &res);\n  if( rc ) goto abort_due_to_error;\n  if( res==0 ){\n    rc = sqlite3BtreeDelete(pCrsr, BTREE_AUXDELETE);\n    if( rc ) goto abort_due_to_error;\n  }\n  assert( pC->deferredMoveto==0 );\n  pC->cacheStatus = CACHE_STALE;\n  pC->seekResult = 0;\n  break;\n}\n\n/* Opcode: DeferredSeek P1 * P3 P4 *\n** Synopsis: Move P3 to P1.rowid if needed\n**\n** P1 is an open index cursor and P3 is a cursor on the corresponding\n** table.  This opcode does a deferred seek of the P3 table cursor\n** to the row that corresponds to the current row of P1.\n**\n** This is a deferred seek.  Nothing actually happens until\n** the cursor is used to read a record.  That way, if no reads\n** occur, no unnecessary I/O happens.\n**\n** P4 may be an array of integers (type P4_INTARRAY) containing\n** one entry for each column in the P3 table.  If array entry a(i)\n** is non-zero, then reading column a(i)-1 from cursor P3 is \n** equivalent to performing the deferred seek and then reading column i \n** from P1.  This information is stored in P3 and used to redirect\n** reads against P3 over to P1, thus possibly avoiding the need to\n** seek and read cursor P3.\n*/\n/* Opcode: IdxRowid P1 P2 * * *\n** Synopsis: r[P2]=rowid\n**\n** Write into register P2 an integer which is the last entry in the record at\n** the end of the index key pointed to by cursor P1.  This integer should be\n** the rowid of the table entry to which this index entry points.\n**\n** See also: Rowid, MakeRecord.\n*/\ncase OP_DeferredSeek:\ncase OP_IdxRowid: {           /* out2 */\n  VdbeCursor *pC;             /* The P1 index cursor */\n  VdbeCursor *pTabCur;        /* The P2 table cursor (OP_DeferredSeek only) */\n  i64 rowid;                  /* Rowid that P1 current points to */\n\n  assert( pOp->p1>=0 && pOp->p1<p->nCursor );\n  pC = p->apCsr[pOp->p1];\n  assert( pC!=0 );\n  assert( pC->eCurType==CURTYPE_BTREE );\n  assert( pC->uc.pCursor!=0 );\n  assert( pC->isTable==0 );\n  assert( pC->deferredMoveto==0 );\n  assert( !pC->nullRow || pOp->opcode==OP_IdxRowid );\n\n  /* The IdxRowid and Seek opcodes are combined because of the commonality\n  ** of sqlite3VdbeCursorRestore() and sqlite3VdbeIdxRowid(). */\n  rc = sqlite3VdbeCursorRestore(pC);\n\n  /* sqlite3VbeCursorRestore() can only fail if the record has been deleted\n  ** out from under the cursor.  That will never happens for an IdxRowid\n  ** or Seek opcode */\n  if( NEVER(rc!=SQLITE_OK) ) goto abort_due_to_error;\n\n  if( !pC->nullRow ){\n    rowid = 0;  /* Not needed.  Only used to silence a warning. */\n    rc = sqlite3VdbeIdxRowid(db, pC->uc.pCursor, &rowid);\n    if( rc!=SQLITE_OK ){\n      goto abort_due_to_error;\n    }\n    if( pOp->opcode==OP_DeferredSeek ){\n      assert( pOp->p3>=0 && pOp->p3<p->nCursor );\n      pTabCur = p->apCsr[pOp->p3];\n      assert( pTabCur!=0 );\n      assert( pTabCur->eCurType==CURTYPE_BTREE );\n      assert( pTabCur->uc.pCursor!=0 );\n      assert( pTabCur->isTable );\n      pTabCur->nullRow = 0;\n      pTabCur->movetoTarget = rowid;\n      pTabCur->deferredMoveto = 1;\n      assert( pOp->p4type==P4_INTARRAY || pOp->p4.ai==0 );\n      pTabCur->aAltMap = pOp->p4.ai;\n      pTabCur->pAltCursor = pC;\n    }else{\n      pOut = out2Prerelease(p, pOp);\n      pOut->u.i = rowid;\n    }\n  }else{\n    assert( pOp->opcode==OP_IdxRowid );\n    sqlite3VdbeMemSetNull(&aMem[pOp->p2]);\n  }\n  break;\n}\n\n/* Opcode: IdxGE P1 P2 P3 P4 P5\n** Synopsis: key=r[P3@P4]\n**\n** The P4 register values beginning with P3 form an unpacked index \n** key that omits the PRIMARY KEY.  Compare this key value against the index \n** that P1 is currently pointing to, ignoring the PRIMARY KEY or ROWID \n** fields at the end.\n**\n** If the P1 index entry is greater than or equal to the key value\n** then jump to P2.  Otherwise fall through to the next instruction.\n*/\n/* Opcode: IdxGT P1 P2 P3 P4 P5\n** Synopsis: key=r[P3@P4]\n**\n** The P4 register values beginning with P3 form an unpacked index \n** key that omits the PRIMARY KEY.  Compare this key value against the index \n** that P1 is currently pointing to, ignoring the PRIMARY KEY or ROWID \n** fields at the end.\n**\n** If the P1 index entry is greater than the key value\n** then jump to P2.  Otherwise fall through to the next instruction.\n*/\n/* Opcode: IdxLT P1 P2 P3 P4 P5\n** Synopsis: key=r[P3@P4]\n**\n** The P4 register values beginning with P3 form an unpacked index \n** key that omits the PRIMARY KEY or ROWID.  Compare this key value against\n** the index that P1 is currently pointing to, ignoring the PRIMARY KEY or\n** ROWID on the P1 index.\n**\n** If the P1 index entry is less than the key value then jump to P2.\n** Otherwise fall through to the next instruction.\n*/\n/* Opcode: IdxLE P1 P2 P3 P4 P5\n** Synopsis: key=r[P3@P4]\n**\n** The P4 register values beginning with P3 form an unpacked index \n** key that omits the PRIMARY KEY or ROWID.  Compare this key value against\n** the index that P1 is currently pointing to, ignoring the PRIMARY KEY or\n** ROWID on the P1 index.\n**\n** If the P1 index entry is less than or equal to the key value then jump\n** to P2. Otherwise fall through to the next instruction.\n*/\ncase OP_IdxLE:          /* jump */\ncase OP_IdxGT:          /* jump */\ncase OP_IdxLT:          /* jump */\ncase OP_IdxGE:  {       /* jump */\n  VdbeCursor *pC;\n  int res;\n  UnpackedRecord r;\n\n  assert( pOp->p1>=0 && pOp->p1<p->nCursor );\n  pC = p->apCsr[pOp->p1];\n  assert( pC!=0 );\n  assert( pC->isOrdered );\n  assert( pC->eCurType==CURTYPE_BTREE );\n  assert( pC->uc.pCursor!=0);\n  assert( pC->deferredMoveto==0 );\n  assert( pOp->p5==0 || pOp->p5==1 );\n  assert( pOp->p4type==P4_INT32 );\n  r.pKeyInfo = pC->pKeyInfo;\n  r.nField = (u16)pOp->p4.i;\n  if( pOp->opcode<OP_IdxLT ){\n    assert( pOp->opcode==OP_IdxLE || pOp->opcode==OP_IdxGT );\n    r.default_rc = -1;\n  }else{\n    assert( pOp->opcode==OP_IdxGE || pOp->opcode==OP_IdxLT );\n    r.default_rc = 0;\n  }\n  r.aMem = &aMem[pOp->p3];\n#ifdef SQLITE_DEBUG\n  {\n    int i;\n    for(i=0; i<r.nField; i++){\n      assert( memIsValid(&r.aMem[i]) );\n      REGISTER_TRACE(pOp->p3+i, &aMem[pOp->p3+i]);\n    }\n  }\n#endif\n  res = 0;  /* Not needed.  Only used to silence a warning. */\n  rc = sqlite3VdbeIdxKeyCompare(db, pC, &r, &res);\n  assert( (OP_IdxLE&1)==(OP_IdxLT&1) && (OP_IdxGE&1)==(OP_IdxGT&1) );\n  if( (pOp->opcode&1)==(OP_IdxLT&1) ){\n    assert( pOp->opcode==OP_IdxLE || pOp->opcode==OP_IdxLT );\n    res = -res;\n  }else{\n    assert( pOp->opcode==OP_IdxGE || pOp->opcode==OP_IdxGT );\n    res++;\n  }\n  VdbeBranchTaken(res>0,2);\n  if( rc ) goto abort_due_to_error;\n  if( res>0 ) goto jump_to_p2;\n  break;\n}\n\n/* Opcode: Destroy P1 P2 P3 * *\n**\n** Delete an entire database table or index whose root page in the database\n** file is given by P1.\n**\n** The table being destroyed is in the main database file if P3==0.  If\n** P3==1 then the table to be clear is in the auxiliary database file\n** that is used to store tables create using CREATE TEMPORARY TABLE.\n**\n** If AUTOVACUUM is enabled then it is possible that another root page\n** might be moved into the newly deleted root page in order to keep all\n** root pages contiguous at the beginning of the database.  The former\n** value of the root page that moved - its value before the move occurred -\n** is stored in register P2. If no page movement was required (because the\n** table being dropped was already the last one in the database) then a \n** zero is stored in register P2.  If AUTOVACUUM is disabled then a zero \n** is stored in register P2.\n**\n** This opcode throws an error if there are any active reader VMs when\n** it is invoked. This is done to avoid the difficulty associated with \n** updating existing cursors when a root page is moved in an AUTOVACUUM \n** database. This error is thrown even if the database is not an AUTOVACUUM \n** db in order to avoid introducing an incompatibility between autovacuum \n** and non-autovacuum modes.\n**\n** See also: Clear\n*/\ncase OP_Destroy: {     /* out2 */\n  int iMoved;\n  int iDb;\n\n  sqlite3VdbeIncrWriteCounter(p, 0);\n  assert( p->readOnly==0 );\n  assert( pOp->p1>1 );\n  pOut = out2Prerelease(p, pOp);\n  pOut->flags = MEM_Null;\n  if( db->nVdbeRead > db->nVDestroy+1 ){\n    rc = SQLITE_LOCKED;\n    p->errorAction = OE_Abort;\n    goto abort_due_to_error;\n  }else{\n    iDb = pOp->p3;\n    assert( DbMaskTest(p->btreeMask, iDb) );\n    iMoved = 0;  /* Not needed.  Only to silence a warning. */\n    rc = sqlite3BtreeDropTable(db->aDb[iDb].pBt, pOp->p1, &iMoved);\n    pOut->flags = MEM_Int;\n    pOut->u.i = iMoved;\n    if( rc ) goto abort_due_to_error;\n#ifndef SQLITE_OMIT_AUTOVACUUM\n    if( iMoved!=0 ){\n      sqlite3RootPageMoved(db, iDb, iMoved, pOp->p1);\n      /* All OP_Destroy operations occur on the same btree */\n      assert( resetSchemaOnFault==0 || resetSchemaOnFault==iDb+1 );\n      resetSchemaOnFault = iDb+1;\n    }\n#endif\n  }\n  break;\n}\n\n/* Opcode: Clear P1 P2 P3\n**\n** Delete all contents of the database table or index whose root page\n** in the database file is given by P1.  But, unlike Destroy, do not\n** remove the table or index from the database file.\n**\n** The table being clear is in the main database file if P2==0.  If\n** P2==1 then the table to be clear is in the auxiliary database file\n** that is used to store tables create using CREATE TEMPORARY TABLE.\n**\n** If the P3 value is non-zero, then the table referred to must be an\n** intkey table (an SQL table, not an index). In this case the row change \n** count is incremented by the number of rows in the table being cleared. \n** If P3 is greater than zero, then the value stored in register P3 is\n** also incremented by the number of rows in the table being cleared.\n**\n** See also: Destroy\n*/\ncase OP_Clear: {\n  int nChange;\n \n  sqlite3VdbeIncrWriteCounter(p, 0);\n  nChange = 0;\n  assert( p->readOnly==0 );\n  assert( DbMaskTest(p->btreeMask, pOp->p2) );\n  rc = sqlite3BtreeClearTable(\n      db->aDb[pOp->p2].pBt, pOp->p1, (pOp->p3 ? &nChange : 0)\n  );\n  if( pOp->p3 ){\n    p->nChange += nChange;\n    if( pOp->p3>0 ){\n      assert( memIsValid(&aMem[pOp->p3]) );\n      memAboutToChange(p, &aMem[pOp->p3]);\n      aMem[pOp->p3].u.i += nChange;\n    }\n  }\n  if( rc ) goto abort_due_to_error;\n  break;\n}\n\n/* Opcode: ResetSorter P1 * * * *\n**\n** Delete all contents from the ephemeral table or sorter\n** that is open on cursor P1.\n**\n** This opcode only works for cursors used for sorting and\n** opened with OP_OpenEphemeral or OP_SorterOpen.\n*/\ncase OP_ResetSorter: {\n  VdbeCursor *pC;\n \n  assert( pOp->p1>=0 && pOp->p1<p->nCursor );\n  pC = p->apCsr[pOp->p1];\n  assert( pC!=0 );\n  if( isSorter(pC) ){\n    sqlite3VdbeSorterReset(db, pC->uc.pSorter);\n  }else{\n    assert( pC->eCurType==CURTYPE_BTREE );\n    assert( pC->isEphemeral );\n    rc = sqlite3BtreeClearTableOfCursor(pC->uc.pCursor);\n    if( rc ) goto abort_due_to_error;\n  }\n  break;\n}\n\n/* Opcode: CreateBtree P1 P2 P3 * *\n** Synopsis: r[P2]=root iDb=P1 flags=P3\n**\n** Allocate a new b-tree in the main database file if P1==0 or in the\n** TEMP database file if P1==1 or in an attached database if\n** P1>1.  The P3 argument must be 1 (BTREE_INTKEY) for a rowid table\n** it must be 2 (BTREE_BLOBKEY) for an index or WITHOUT ROWID table.\n** The root page number of the new b-tree is stored in register P2.\n*/\ncase OP_CreateBtree: {          /* out2 */\n  int pgno;\n  Db *pDb;\n\n  sqlite3VdbeIncrWriteCounter(p, 0);\n  pOut = out2Prerelease(p, pOp);\n  pgno = 0;\n  assert( pOp->p3==BTREE_INTKEY || pOp->p3==BTREE_BLOBKEY );\n  assert( pOp->p1>=0 && pOp->p1<db->nDb );\n  assert( DbMaskTest(p->btreeMask, pOp->p1) );\n  assert( p->readOnly==0 );\n  pDb = &db->aDb[pOp->p1];\n  assert( pDb->pBt!=0 );\n  rc = sqlite3BtreeCreateTable(pDb->pBt, &pgno, pOp->p3);\n  if( rc ) goto abort_due_to_error;\n  pOut->u.i = pgno;\n  break;\n}\n\n/* Opcode: SqlExec * * * P4 *\n**\n** Run the SQL statement or statements specified in the P4 string.\n*/\ncase OP_SqlExec: {\n  sqlite3VdbeIncrWriteCounter(p, 0);\n  db->nSqlExec++;\n  rc = sqlite3_exec(db, pOp->p4.z, 0, 0, 0);\n  db->nSqlExec--;\n  if( rc ) goto abort_due_to_error;\n  break;\n}\n\n/* Opcode: ParseSchema P1 * * P4 *\n**\n** Read and parse all entries from the SQLITE_MASTER table of database P1\n** that match the WHERE clause P4.  If P4 is a NULL pointer, then the\n** entire schema for P1 is reparsed.\n**\n** This opcode invokes the parser to create a new virtual machine,\n** then runs the new virtual machine.  It is thus a re-entrant opcode.\n*/\ncase OP_ParseSchema: {\n  int iDb;\n  const char *zMaster;\n  char *zSql;\n  InitData initData;\n\n  /* Any prepared statement that invokes this opcode will hold mutexes\n  ** on every btree.  This is a prerequisite for invoking \n  ** sqlite3InitCallback().\n  */\n#ifdef SQLITE_DEBUG\n  for(iDb=0; iDb<db->nDb; iDb++){\n    assert( iDb==1 || sqlite3BtreeHoldsMutex(db->aDb[iDb].pBt) );\n  }\n#endif\n\n  iDb = pOp->p1;\n  assert( iDb>=0 && iDb<db->nDb );\n  assert( DbHasProperty(db, iDb, DB_SchemaLoaded) );\n\n#ifndef SQLITE_OMIT_ALTERTABLE\n  if( pOp->p4.z==0 ){\n    sqlite3SchemaClear(db->aDb[iDb].pSchema);\n    db->mDbFlags &= ~DBFLAG_SchemaKnownOk;\n    rc = sqlite3InitOne(db, iDb, &p->zErrMsg, INITFLAG_AlterTable);\n    db->mDbFlags |= DBFLAG_SchemaChange;\n    p->expired = 0;\n  }else\n#endif\n  {\n    zMaster = MASTER_NAME;\n    initData.db = db;\n    initData.iDb = iDb;\n    initData.pzErrMsg = &p->zErrMsg;\n    initData.mInitFlags = 0;\n    zSql = sqlite3MPrintf(db,\n       \"SELECT name, rootpage, sql FROM '%q'.%s WHERE %s ORDER BY rowid\",\n       db->aDb[iDb].zDbSName, zMaster, pOp->p4.z);\n    if( zSql==0 ){\n      rc = SQLITE_NOMEM_BKPT;\n    }else{\n      assert( db->init.busy==0 );\n      db->init.busy = 1;\n      initData.rc = SQLITE_OK;\n      initData.nInitRow = 0;\n      assert( !db->mallocFailed );\n      rc = sqlite3_exec(db, zSql, sqlite3InitCallback, &initData, 0);\n      if( rc==SQLITE_OK ) rc = initData.rc;\n      if( rc==SQLITE_OK && initData.nInitRow==0 ){\n        /* The OP_ParseSchema opcode with a non-NULL P4 argument should parse\n        ** at least one SQL statement. Any less than that indicates that\n        ** the sqlite_master table is corrupt. */\n        rc = SQLITE_CORRUPT_BKPT;\n      }\n      sqlite3DbFreeNN(db, zSql);\n      db->init.busy = 0;\n    }\n  }\n  if( rc ){\n    sqlite3ResetAllSchemasOfConnection(db);\n    if( rc==SQLITE_NOMEM ){\n      goto no_mem;\n    }\n    goto abort_due_to_error;\n  }\n  break;  \n}\n\n#if !defined(SQLITE_OMIT_ANALYZE)\n/* Opcode: LoadAnalysis P1 * * * *\n**\n** Read the sqlite_stat1 table for database P1 and load the content\n** of that table into the internal index hash table.  This will cause\n** the analysis to be used when preparing all subsequent queries.\n*/\ncase OP_LoadAnalysis: {\n  assert( pOp->p1>=0 && pOp->p1<db->nDb );\n  rc = sqlite3AnalysisLoad(db, pOp->p1);\n  if( rc ) goto abort_due_to_error;\n  break;  \n}\n#endif /* !defined(SQLITE_OMIT_ANALYZE) */\n\n/* Opcode: DropTable P1 * * P4 *\n**\n** Remove the internal (in-memory) data structures that describe\n** the table named P4 in database P1.  This is called after a table\n** is dropped from disk (using the Destroy opcode) in order to keep \n** the internal representation of the\n** schema consistent with what is on disk.\n*/\ncase OP_DropTable: {\n  sqlite3VdbeIncrWriteCounter(p, 0);\n  sqlite3UnlinkAndDeleteTable(db, pOp->p1, pOp->p4.z);\n  break;\n}\n\n/* Opcode: DropIndex P1 * * P4 *\n**\n** Remove the internal (in-memory) data structures that describe\n** the index named P4 in database P1.  This is called after an index\n** is dropped from disk (using the Destroy opcode)\n** in order to keep the internal representation of the\n** schema consistent with what is on disk.\n*/\ncase OP_DropIndex: {\n  sqlite3VdbeIncrWriteCounter(p, 0);\n  sqlite3UnlinkAndDeleteIndex(db, pOp->p1, pOp->p4.z);\n  break;\n}\n\n/* Opcode: DropTrigger P1 * * P4 *\n**\n** Remove the internal (in-memory) data structures that describe\n** the trigger named P4 in database P1.  This is called after a trigger\n** is dropped from disk (using the Destroy opcode) in order to keep \n** the internal representation of the\n** schema consistent with what is on disk.\n*/\ncase OP_DropTrigger: {\n  sqlite3VdbeIncrWriteCounter(p, 0);\n  sqlite3UnlinkAndDeleteTrigger(db, pOp->p1, pOp->p4.z);\n  break;\n}\n\n\n#ifndef SQLITE_OMIT_INTEGRITY_CHECK\n/* Opcode: IntegrityCk P1 P2 P3 P4 P5\n**\n** Do an analysis of the currently open database.  Store in\n** register P1 the text of an error message describing any problems.\n** If no problems are found, store a NULL in register P1.\n**\n** The register P3 contains one less than the maximum number of allowed errors.\n** At most reg(P3) errors will be reported.\n** In other words, the analysis stops as soon as reg(P1) errors are \n** seen.  Reg(P1) is updated with the number of errors remaining.\n**\n** The root page numbers of all tables in the database are integers\n** stored in P4_INTARRAY argument.\n**\n** If P5 is not zero, the check is done on the auxiliary database\n** file, not the main database file.\n**\n** This opcode is used to implement the integrity_check pragma.\n*/\ncase OP_IntegrityCk: {\n  int nRoot;      /* Number of tables to check.  (Number of root pages.) */\n  int *aRoot;     /* Array of rootpage numbers for tables to be checked */\n  int nErr;       /* Number of errors reported */\n  char *z;        /* Text of the error report */\n  Mem *pnErr;     /* Register keeping track of errors remaining */\n\n  assert( p->bIsReader );\n  nRoot = pOp->p2;\n  aRoot = pOp->p4.ai;\n  assert( nRoot>0 );\n  assert( aRoot[0]==nRoot );\n  assert( pOp->p3>0 && pOp->p3<=(p->nMem+1 - p->nCursor) );\n  pnErr = &aMem[pOp->p3];\n  assert( (pnErr->flags & MEM_Int)!=0 );\n  assert( (pnErr->flags & (MEM_Str|MEM_Blob))==0 );\n  pIn1 = &aMem[pOp->p1];\n  assert( pOp->p5<db->nDb );\n  assert( DbMaskTest(p->btreeMask, pOp->p5) );\n  z = sqlite3BtreeIntegrityCheck(db->aDb[pOp->p5].pBt, &aRoot[1], nRoot,\n                                 (int)pnErr->u.i+1, &nErr);\n  sqlite3VdbeMemSetNull(pIn1);\n  if( nErr==0 ){\n    assert( z==0 );\n  }else if( z==0 ){\n    goto no_mem;\n  }else{\n    pnErr->u.i -= nErr-1;\n    sqlite3VdbeMemSetStr(pIn1, z, -1, SQLITE_UTF8, sqlite3_free);\n  }\n  UPDATE_MAX_BLOBSIZE(pIn1);\n  sqlite3VdbeChangeEncoding(pIn1, encoding);\n  break;\n}\n#endif /* SQLITE_OMIT_INTEGRITY_CHECK */\n\n/* Opcode: RowSetAdd P1 P2 * * *\n** Synopsis: rowset(P1)=r[P2]\n**\n** Insert the integer value held by register P2 into a RowSet object\n** held in register P1.\n**\n** An assertion fails if P2 is not an integer.\n*/\ncase OP_RowSetAdd: {       /* in1, in2 */\n  pIn1 = &aMem[pOp->p1];\n  pIn2 = &aMem[pOp->p2];\n  assert( (pIn2->flags & MEM_Int)!=0 );\n  if( (pIn1->flags & MEM_Blob)==0 ){\n    if( sqlite3VdbeMemSetRowSet(pIn1) ) goto no_mem;\n  }\n  assert( sqlite3VdbeMemIsRowSet(pIn1) );\n  sqlite3RowSetInsert((RowSet*)pIn1->z, pIn2->u.i);\n  break;\n}\n\n/* Opcode: RowSetRead P1 P2 P3 * *\n** Synopsis: r[P3]=rowset(P1)\n**\n** Extract the smallest value from the RowSet object in P1\n** and put that value into register P3.\n** Or, if RowSet object P1 is initially empty, leave P3\n** unchanged and jump to instruction P2.\n*/\ncase OP_RowSetRead: {       /* jump, in1, out3 */\n  i64 val;\n\n  pIn1 = &aMem[pOp->p1];\n  assert( (pIn1->flags & MEM_Blob)==0 || sqlite3VdbeMemIsRowSet(pIn1) );\n  if( (pIn1->flags & MEM_Blob)==0 \n   || sqlite3RowSetNext((RowSet*)pIn1->z, &val)==0\n  ){\n    /* The boolean index is empty */\n    sqlite3VdbeMemSetNull(pIn1);\n    VdbeBranchTaken(1,2);\n    goto jump_to_p2_and_check_for_interrupt;\n  }else{\n    /* A value was pulled from the index */\n    VdbeBranchTaken(0,2);\n    sqlite3VdbeMemSetInt64(&aMem[pOp->p3], val);\n  }\n  goto check_for_interrupt;\n}\n\n/* Opcode: RowSetTest P1 P2 P3 P4\n** Synopsis: if r[P3] in rowset(P1) goto P2\n**\n** Register P3 is assumed to hold a 64-bit integer value. If register P1\n** contains a RowSet object and that RowSet object contains\n** the value held in P3, jump to register P2. Otherwise, insert the\n** integer in P3 into the RowSet and continue on to the\n** next opcode.\n**\n** The RowSet object is optimized for the case where sets of integers\n** are inserted in distinct phases, which each set contains no duplicates.\n** Each set is identified by a unique P4 value. The first set\n** must have P4==0, the final set must have P4==-1, and for all other sets\n** must have P4>0.\n**\n** This allows optimizations: (a) when P4==0 there is no need to test\n** the RowSet object for P3, as it is guaranteed not to contain it,\n** (b) when P4==-1 there is no need to insert the value, as it will\n** never be tested for, and (c) when a value that is part of set X is\n** inserted, there is no need to search to see if the same value was\n** previously inserted as part of set X (only if it was previously\n** inserted as part of some other set).\n*/\ncase OP_RowSetTest: {                     /* jump, in1, in3 */\n  int iSet;\n  int exists;\n\n  pIn1 = &aMem[pOp->p1];\n  pIn3 = &aMem[pOp->p3];\n  iSet = pOp->p4.i;\n  assert( pIn3->flags&MEM_Int );\n\n  /* If there is anything other than a rowset object in memory cell P1,\n  ** delete it now and initialize P1 with an empty rowset\n  */\n  if( (pIn1->flags & MEM_Blob)==0 ){\n    if( sqlite3VdbeMemSetRowSet(pIn1) ) goto no_mem;\n  }\n  assert( sqlite3VdbeMemIsRowSet(pIn1) );\n  assert( pOp->p4type==P4_INT32 );\n  assert( iSet==-1 || iSet>=0 );\n  if( iSet ){\n    exists = sqlite3RowSetTest((RowSet*)pIn1->z, iSet, pIn3->u.i);\n    VdbeBranchTaken(exists!=0,2);\n    if( exists ) goto jump_to_p2;\n  }\n  if( iSet>=0 ){\n    sqlite3RowSetInsert((RowSet*)pIn1->z, pIn3->u.i);\n  }\n  break;\n}\n\n\n#ifndef SQLITE_OMIT_TRIGGER\n\n/* Opcode: Program P1 P2 P3 P4 P5\n**\n** Execute the trigger program passed as P4 (type P4_SUBPROGRAM). \n**\n** P1 contains the address of the memory cell that contains the first memory \n** cell in an array of values used as arguments to the sub-program. P2 \n** contains the address to jump to if the sub-program throws an IGNORE \n** exception using the RAISE() function. Register P3 contains the address \n** of a memory cell in this (the parent) VM that is used to allocate the \n** memory required by the sub-vdbe at runtime.\n**\n** P4 is a pointer to the VM containing the trigger program.\n**\n** If P5 is non-zero, then recursive program invocation is enabled.\n*/\ncase OP_Program: {        /* jump */\n  int nMem;               /* Number of memory registers for sub-program */\n  int nByte;              /* Bytes of runtime space required for sub-program */\n  Mem *pRt;               /* Register to allocate runtime space */\n  Mem *pMem;              /* Used to iterate through memory cells */\n  Mem *pEnd;              /* Last memory cell in new array */\n  VdbeFrame *pFrame;      /* New vdbe frame to execute in */\n  SubProgram *pProgram;   /* Sub-program to execute */\n  void *t;                /* Token identifying trigger */\n\n  pProgram = pOp->p4.pProgram;\n  pRt = &aMem[pOp->p3];\n  assert( pProgram->nOp>0 );\n  \n  /* If the p5 flag is clear, then recursive invocation of triggers is \n  ** disabled for backwards compatibility (p5 is set if this sub-program\n  ** is really a trigger, not a foreign key action, and the flag set\n  ** and cleared by the \"PRAGMA recursive_triggers\" command is clear).\n  ** \n  ** It is recursive invocation of triggers, at the SQL level, that is \n  ** disabled. In some cases a single trigger may generate more than one \n  ** SubProgram (if the trigger may be executed with more than one different \n  ** ON CONFLICT algorithm). SubProgram structures associated with a\n  ** single trigger all have the same value for the SubProgram.token \n  ** variable.  */\n  if( pOp->p5 ){\n    t = pProgram->token;\n    for(pFrame=p->pFrame; pFrame && pFrame->token!=t; pFrame=pFrame->pParent);\n    if( pFrame ) break;\n  }\n\n  if( p->nFrame>=db->aLimit[SQLITE_LIMIT_TRIGGER_DEPTH] ){\n    rc = SQLITE_ERROR;\n    sqlite3VdbeError(p, \"too many levels of trigger recursion\");\n    goto abort_due_to_error;\n  }\n\n  /* Register pRt is used to store the memory required to save the state\n  ** of the current program, and the memory required at runtime to execute\n  ** the trigger program. If this trigger has been fired before, then pRt \n  ** is already allocated. Otherwise, it must be initialized.  */\n  if( (pRt->flags&MEM_Blob)==0 ){\n    /* SubProgram.nMem is set to the number of memory cells used by the \n    ** program stored in SubProgram.aOp. As well as these, one memory\n    ** cell is required for each cursor used by the program. Set local\n    ** variable nMem (and later, VdbeFrame.nChildMem) to this value.\n    */\n    nMem = pProgram->nMem + pProgram->nCsr;\n    assert( nMem>0 );\n    if( pProgram->nCsr==0 ) nMem++;\n    nByte = ROUND8(sizeof(VdbeFrame))\n              + nMem * sizeof(Mem)\n              + pProgram->nCsr * sizeof(VdbeCursor*)\n              + (pProgram->nOp + 7)/8;\n    pFrame = sqlite3DbMallocZero(db, nByte);\n    if( !pFrame ){\n      goto no_mem;\n    }\n    sqlite3VdbeMemRelease(pRt);\n    pRt->flags = MEM_Blob|MEM_Dyn;\n    pRt->z = (char*)pFrame;\n    pRt->n = nByte;\n    pRt->xDel = sqlite3VdbeFrameMemDel;\n\n    pFrame->v = p;\n    pFrame->nChildMem = nMem;\n    pFrame->nChildCsr = pProgram->nCsr;\n    pFrame->pc = (int)(pOp - aOp);\n    pFrame->aMem = p->aMem;\n    pFrame->nMem = p->nMem;\n    pFrame->apCsr = p->apCsr;\n    pFrame->nCursor = p->nCursor;\n    pFrame->aOp = p->aOp;\n    pFrame->nOp = p->nOp;\n    pFrame->token = pProgram->token;\n#ifdef SQLITE_ENABLE_STMT_SCANSTATUS\n    pFrame->anExec = p->anExec;\n#endif\n#ifdef SQLITE_DEBUG\n    pFrame->iFrameMagic = SQLITE_FRAME_MAGIC;\n#endif\n\n    pEnd = &VdbeFrameMem(pFrame)[pFrame->nChildMem];\n    for(pMem=VdbeFrameMem(pFrame); pMem!=pEnd; pMem++){\n      pMem->flags = MEM_Undefined;\n      pMem->db = db;\n    }\n  }else{\n    pFrame = (VdbeFrame*)pRt->z;\n    assert( pRt->xDel==sqlite3VdbeFrameMemDel );\n    assert( pProgram->nMem+pProgram->nCsr==pFrame->nChildMem \n        || (pProgram->nCsr==0 && pProgram->nMem+1==pFrame->nChildMem) );\n    assert( pProgram->nCsr==pFrame->nChildCsr );\n    assert( (int)(pOp - aOp)==pFrame->pc );\n  }\n\n  p->nFrame++;\n  pFrame->pParent = p->pFrame;\n  pFrame->lastRowid = db->lastRowid;\n  pFrame->nChange = p->nChange;\n  pFrame->nDbChange = p->db->nChange;\n  assert( pFrame->pAuxData==0 );\n  pFrame->pAuxData = p->pAuxData;\n  p->pAuxData = 0;\n  p->nChange = 0;\n  p->pFrame = pFrame;\n  p->aMem = aMem = VdbeFrameMem(pFrame);\n  p->nMem = pFrame->nChildMem;\n  p->nCursor = (u16)pFrame->nChildCsr;\n  p->apCsr = (VdbeCursor **)&aMem[p->nMem];\n  pFrame->aOnce = (u8*)&p->apCsr[pProgram->nCsr];\n  memset(pFrame->aOnce, 0, (pProgram->nOp + 7)/8);\n  p->aOp = aOp = pProgram->aOp;\n  p->nOp = pProgram->nOp;\n#ifdef SQLITE_ENABLE_STMT_SCANSTATUS\n  p->anExec = 0;\n#endif\n#ifdef SQLITE_DEBUG\n  /* Verify that second and subsequent executions of the same trigger do not\n  ** try to reuse register values from the first use. */\n  {\n    int i;\n    for(i=0; i<p->nMem; i++){\n      aMem[i].pScopyFrom = 0;  /* Prevent false-positive AboutToChange() errs */\n      aMem[i].flags |= MEM_Undefined; /* Cause a fault if this reg is reused */\n    }\n  }\n#endif\n  pOp = &aOp[-1];\n\n  break;\n}\n\n/* Opcode: Param P1 P2 * * *\n**\n** This opcode is only ever present in sub-programs called via the \n** OP_Program instruction. Copy a value currently stored in a memory \n** cell of the calling (parent) frame to cell P2 in the current frames \n** address space. This is used by trigger programs to access the new.* \n** and old.* values.\n**\n** The address of the cell in the parent frame is determined by adding\n** the value of the P1 argument to the value of the P1 argument to the\n** calling OP_Program instruction.\n*/\ncase OP_Param: {           /* out2 */\n  VdbeFrame *pFrame;\n  Mem *pIn;\n  pOut = out2Prerelease(p, pOp);\n  pFrame = p->pFrame;\n  pIn = &pFrame->aMem[pOp->p1 + pFrame->aOp[pFrame->pc].p1];   \n  sqlite3VdbeMemShallowCopy(pOut, pIn, MEM_Ephem);\n  break;\n}\n\n#endif /* #ifndef SQLITE_OMIT_TRIGGER */\n\n#ifndef SQLITE_OMIT_FOREIGN_KEY\n/* Opcode: FkCounter P1 P2 * * *\n** Synopsis: fkctr[P1]+=P2\n**\n** Increment a \"constraint counter\" by P2 (P2 may be negative or positive).\n** If P1 is non-zero, the database constraint counter is incremented \n** (deferred foreign key constraints). Otherwise, if P1 is zero, the \n** statement counter is incremented (immediate foreign key constraints).\n*/\ncase OP_FkCounter: {\n  if( db->flags & SQLITE_DeferFKs ){\n    db->nDeferredImmCons += pOp->p2;\n  }else if( pOp->p1 ){\n    db->nDeferredCons += pOp->p2;\n  }else{\n    p->nFkConstraint += pOp->p2;\n  }\n  break;\n}\n\n/* Opcode: FkIfZero P1 P2 * * *\n** Synopsis: if fkctr[P1]==0 goto P2\n**\n** This opcode tests if a foreign key constraint-counter is currently zero.\n** If so, jump to instruction P2. Otherwise, fall through to the next \n** instruction.\n**\n** If P1 is non-zero, then the jump is taken if the database constraint-counter\n** is zero (the one that counts deferred constraint violations). If P1 is\n** zero, the jump is taken if the statement constraint-counter is zero\n** (immediate foreign key constraint violations).\n*/\ncase OP_FkIfZero: {         /* jump */\n  if( pOp->p1 ){\n    VdbeBranchTaken(db->nDeferredCons==0 && db->nDeferredImmCons==0, 2);\n    if( db->nDeferredCons==0 && db->nDeferredImmCons==0 ) goto jump_to_p2;\n  }else{\n    VdbeBranchTaken(p->nFkConstraint==0 && db->nDeferredImmCons==0, 2);\n    if( p->nFkConstraint==0 && db->nDeferredImmCons==0 ) goto jump_to_p2;\n  }\n  break;\n}\n#endif /* #ifndef SQLITE_OMIT_FOREIGN_KEY */\n\n#ifndef SQLITE_OMIT_AUTOINCREMENT\n/* Opcode: MemMax P1 P2 * * *\n** Synopsis: r[P1]=max(r[P1],r[P2])\n**\n** P1 is a register in the root frame of this VM (the root frame is\n** different from the current frame if this instruction is being executed\n** within a sub-program). Set the value of register P1 to the maximum of \n** its current value and the value in register P2.\n**\n** This instruction throws an error if the memory cell is not initially\n** an integer.\n*/\ncase OP_MemMax: {        /* in2 */\n  VdbeFrame *pFrame;\n  if( p->pFrame ){\n    for(pFrame=p->pFrame; pFrame->pParent; pFrame=pFrame->pParent);\n    pIn1 = &pFrame->aMem[pOp->p1];\n  }else{\n    pIn1 = &aMem[pOp->p1];\n  }\n  assert( memIsValid(pIn1) );\n  sqlite3VdbeMemIntegerify(pIn1);\n  pIn2 = &aMem[pOp->p2];\n  sqlite3VdbeMemIntegerify(pIn2);\n  if( pIn1->u.i<pIn2->u.i){\n    pIn1->u.i = pIn2->u.i;\n  }\n  break;\n}\n#endif /* SQLITE_OMIT_AUTOINCREMENT */\n\n/* Opcode: IfPos P1 P2 P3 * *\n** Synopsis: if r[P1]>0 then r[P1]-=P3, goto P2\n**\n** Register P1 must contain an integer.\n** If the value of register P1 is 1 or greater, subtract P3 from the\n** value in P1 and jump to P2.\n**\n** If the initial value of register P1 is less than 1, then the\n** value is unchanged and control passes through to the next instruction.\n*/\ncase OP_IfPos: {        /* jump, in1 */\n  pIn1 = &aMem[pOp->p1];\n  assert( pIn1->flags&MEM_Int );\n  VdbeBranchTaken( pIn1->u.i>0, 2);\n  if( pIn1->u.i>0 ){\n    pIn1->u.i -= pOp->p3;\n    goto jump_to_p2;\n  }\n  break;\n}\n\n/* Opcode: OffsetLimit P1 P2 P3 * *\n** Synopsis: if r[P1]>0 then r[P2]=r[P1]+max(0,r[P3]) else r[P2]=(-1)\n**\n** This opcode performs a commonly used computation associated with\n** LIMIT and OFFSET process.  r[P1] holds the limit counter.  r[P3]\n** holds the offset counter.  The opcode computes the combined value\n** of the LIMIT and OFFSET and stores that value in r[P2].  The r[P2]\n** value computed is the total number of rows that will need to be\n** visited in order to complete the query.\n**\n** If r[P3] is zero or negative, that means there is no OFFSET\n** and r[P2] is set to be the value of the LIMIT, r[P1].\n**\n** if r[P1] is zero or negative, that means there is no LIMIT\n** and r[P2] is set to -1. \n**\n** Otherwise, r[P2] is set to the sum of r[P1] and r[P3].\n*/\ncase OP_OffsetLimit: {    /* in1, out2, in3 */\n  i64 x;\n  pIn1 = &aMem[pOp->p1];\n  pIn3 = &aMem[pOp->p3];\n  pOut = out2Prerelease(p, pOp);\n  assert( pIn1->flags & MEM_Int );\n  assert( pIn3->flags & MEM_Int );\n  x = pIn1->u.i;\n  if( x<=0 || sqlite3AddInt64(&x, pIn3->u.i>0?pIn3->u.i:0) ){\n    /* If the LIMIT is less than or equal to zero, loop forever.  This\n    ** is documented.  But also, if the LIMIT+OFFSET exceeds 2^63 then\n    ** also loop forever.  This is undocumented.  In fact, one could argue\n    ** that the loop should terminate.  But assuming 1 billion iterations\n    ** per second (far exceeding the capabilities of any current hardware)\n    ** it would take nearly 300 years to actually reach the limit.  So\n    ** looping forever is a reasonable approximation. */\n    pOut->u.i = -1;\n  }else{\n    pOut->u.i = x;\n  }\n  break;\n}\n\n/* Opcode: IfNotZero P1 P2 * * *\n** Synopsis: if r[P1]!=0 then r[P1]--, goto P2\n**\n** Register P1 must contain an integer.  If the content of register P1 is\n** initially greater than zero, then decrement the value in register P1.\n** If it is non-zero (negative or positive) and then also jump to P2.  \n** If register P1 is initially zero, leave it unchanged and fall through.\n*/\ncase OP_IfNotZero: {        /* jump, in1 */\n  pIn1 = &aMem[pOp->p1];\n  assert( pIn1->flags&MEM_Int );\n  VdbeBranchTaken(pIn1->u.i<0, 2);\n  if( pIn1->u.i ){\n     if( pIn1->u.i>0 ) pIn1->u.i--;\n     goto jump_to_p2;\n  }\n  break;\n}\n\n/* Opcode: DecrJumpZero P1 P2 * * *\n** Synopsis: if (--r[P1])==0 goto P2\n**\n** Register P1 must hold an integer.  Decrement the value in P1\n** and jump to P2 if the new value is exactly zero.\n*/\ncase OP_DecrJumpZero: {      /* jump, in1 */\n  pIn1 = &aMem[pOp->p1];\n  assert( pIn1->flags&MEM_Int );\n  if( pIn1->u.i>SMALLEST_INT64 ) pIn1->u.i--;\n  VdbeBranchTaken(pIn1->u.i==0, 2);\n  if( pIn1->u.i==0 ) goto jump_to_p2;\n  break;\n}\n\n\n/* Opcode: AggStep * P2 P3 P4 P5\n** Synopsis: accum=r[P3] step(r[P2@P5])\n**\n** Execute the xStep function for an aggregate.\n** The function has P5 arguments.  P4 is a pointer to the \n** FuncDef structure that specifies the function.  Register P3 is the\n** accumulator.\n**\n** The P5 arguments are taken from register P2 and its\n** successors.\n*/\n/* Opcode: AggInverse * P2 P3 P4 P5\n** Synopsis: accum=r[P3] inverse(r[P2@P5])\n**\n** Execute the xInverse function for an aggregate.\n** The function has P5 arguments.  P4 is a pointer to the \n** FuncDef structure that specifies the function.  Register P3 is the\n** accumulator.\n**\n** The P5 arguments are taken from register P2 and its\n** successors.\n*/\n/* Opcode: AggStep1 P1 P2 P3 P4 P5\n** Synopsis: accum=r[P3] step(r[P2@P5])\n**\n** Execute the xStep (if P1==0) or xInverse (if P1!=0) function for an\n** aggregate.  The function has P5 arguments.  P4 is a pointer to the \n** FuncDef structure that specifies the function.  Register P3 is the\n** accumulator.\n**\n** The P5 arguments are taken from register P2 and its\n** successors.\n**\n** This opcode is initially coded as OP_AggStep0.  On first evaluation,\n** the FuncDef stored in P4 is converted into an sqlite3_context and\n** the opcode is changed.  In this way, the initialization of the\n** sqlite3_context only happens once, instead of on each call to the\n** step function.\n*/\ncase OP_AggInverse:\ncase OP_AggStep: {\n  int n;\n  sqlite3_context *pCtx;\n\n  assert( pOp->p4type==P4_FUNCDEF );\n  n = pOp->p5;\n  assert( pOp->p3>0 && pOp->p3<=(p->nMem+1 - p->nCursor) );\n  assert( n==0 || (pOp->p2>0 && pOp->p2+n<=(p->nMem+1 - p->nCursor)+1) );\n  assert( pOp->p3<pOp->p2 || pOp->p3>=pOp->p2+n );\n  pCtx = sqlite3DbMallocRawNN(db, n*sizeof(sqlite3_value*) +\n               (sizeof(pCtx[0]) + sizeof(Mem) - sizeof(sqlite3_value*)));\n  if( pCtx==0 ) goto no_mem;\n  pCtx->pMem = 0;\n  pCtx->pOut = (Mem*)&(pCtx->argv[n]);\n  sqlite3VdbeMemInit(pCtx->pOut, db, MEM_Null);\n  pCtx->pFunc = pOp->p4.pFunc;\n  pCtx->iOp = (int)(pOp - aOp);\n  pCtx->pVdbe = p;\n  pCtx->skipFlag = 0;\n  pCtx->isError = 0;\n  pCtx->argc = n;\n  pOp->p4type = P4_FUNCCTX;\n  pOp->p4.pCtx = pCtx;\n\n  /* OP_AggInverse must have P1==1 and OP_AggStep must have P1==0 */\n  assert( pOp->p1==(pOp->opcode==OP_AggInverse) );\n\n  pOp->opcode = OP_AggStep1;\n  /* Fall through into OP_AggStep */\n}\ncase OP_AggStep1: {\n  int i;\n  sqlite3_context *pCtx;\n  Mem *pMem;\n\n  assert( pOp->p4type==P4_FUNCCTX );\n  pCtx = pOp->p4.pCtx;\n  pMem = &aMem[pOp->p3];\n\n#ifdef SQLITE_DEBUG\n  if( pOp->p1 ){\n    /* This is an OP_AggInverse call.  Verify that xStep has always\n    ** been called at least once prior to any xInverse call. */\n    assert( pMem->uTemp==0x1122e0e3 );\n  }else{\n    /* This is an OP_AggStep call.  Mark it as such. */\n    pMem->uTemp = 0x1122e0e3;\n  }\n#endif\n\n  /* If this function is inside of a trigger, the register array in aMem[]\n  ** might change from one evaluation to the next.  The next block of code\n  ** checks to see if the register array has changed, and if so it\n  ** reinitializes the relavant parts of the sqlite3_context object */\n  if( pCtx->pMem != pMem ){\n    pCtx->pMem = pMem;\n    for(i=pCtx->argc-1; i>=0; i--) pCtx->argv[i] = &aMem[pOp->p2+i];\n  }\n\n#ifdef SQLITE_DEBUG\n  for(i=0; i<pCtx->argc; i++){\n    assert( memIsValid(pCtx->argv[i]) );\n    REGISTER_TRACE(pOp->p2+i, pCtx->argv[i]);\n  }\n#endif\n\n  pMem->n++;\n  assert( pCtx->pOut->flags==MEM_Null );\n  assert( pCtx->isError==0 );\n  assert( pCtx->skipFlag==0 );\n#ifndef SQLITE_OMIT_WINDOWFUNC\n  if( pOp->p1 ){\n    (pCtx->pFunc->xInverse)(pCtx,pCtx->argc,pCtx->argv);\n  }else\n#endif\n  (pCtx->pFunc->xSFunc)(pCtx,pCtx->argc,pCtx->argv); /* IMP: R-24505-23230 */\n\n  if( pCtx->isError ){\n    if( pCtx->isError>0 ){\n      sqlite3VdbeError(p, \"%s\", sqlite3_value_text(pCtx->pOut));\n      rc = pCtx->isError;\n    }\n    if( pCtx->skipFlag ){\n      assert( pOp[-1].opcode==OP_CollSeq );\n      i = pOp[-1].p1;\n      if( i ) sqlite3VdbeMemSetInt64(&aMem[i], 1);\n      pCtx->skipFlag = 0;\n    }\n    sqlite3VdbeMemRelease(pCtx->pOut);\n    pCtx->pOut->flags = MEM_Null;\n    pCtx->isError = 0;\n    if( rc ) goto abort_due_to_error;\n  }\n  assert( pCtx->pOut->flags==MEM_Null );\n  assert( pCtx->skipFlag==0 );\n  break;\n}\n\n/* Opcode: AggFinal P1 P2 * P4 *\n** Synopsis: accum=r[P1] N=P2\n**\n** P1 is the memory location that is the accumulator for an aggregate\n** or window function.  Execute the finalizer function \n** for an aggregate and store the result in P1.\n**\n** P2 is the number of arguments that the step function takes and\n** P4 is a pointer to the FuncDef for this function.  The P2\n** argument is not used by this opcode.  It is only there to disambiguate\n** functions that can take varying numbers of arguments.  The\n** P4 argument is only needed for the case where\n** the step function was not previously called.\n*/\n/* Opcode: AggValue * P2 P3 P4 *\n** Synopsis: r[P3]=value N=P2\n**\n** Invoke the xValue() function and store the result in register P3.\n**\n** P2 is the number of arguments that the step function takes and\n** P4 is a pointer to the FuncDef for this function.  The P2\n** argument is not used by this opcode.  It is only there to disambiguate\n** functions that can take varying numbers of arguments.  The\n** P4 argument is only needed for the case where\n** the step function was not previously called.\n*/\ncase OP_AggValue:\ncase OP_AggFinal: {\n  Mem *pMem;\n  assert( pOp->p1>0 && pOp->p1<=(p->nMem+1 - p->nCursor) );\n  assert( pOp->p3==0 || pOp->opcode==OP_AggValue );\n  pMem = &aMem[pOp->p1];\n  assert( (pMem->flags & ~(MEM_Null|MEM_Agg))==0 );\n#ifndef SQLITE_OMIT_WINDOWFUNC\n  if( pOp->p3 ){\n    rc = sqlite3VdbeMemAggValue(pMem, &aMem[pOp->p3], pOp->p4.pFunc);\n    pMem = &aMem[pOp->p3];\n  }else\n#endif\n  {\n    rc = sqlite3VdbeMemFinalize(pMem, pOp->p4.pFunc);\n  }\n  \n  if( rc ){\n    sqlite3VdbeError(p, \"%s\", sqlite3_value_text(pMem));\n    goto abort_due_to_error;\n  }\n  sqlite3VdbeChangeEncoding(pMem, encoding);\n  UPDATE_MAX_BLOBSIZE(pMem);\n  if( sqlite3VdbeMemTooBig(pMem) ){\n    goto too_big;\n  }\n  break;\n}\n\n#ifndef SQLITE_OMIT_WAL\n/* Opcode: Checkpoint P1 P2 P3 * *\n**\n** Checkpoint database P1. This is a no-op if P1 is not currently in\n** WAL mode. Parameter P2 is one of SQLITE_CHECKPOINT_PASSIVE, FULL,\n** RESTART, or TRUNCATE.  Write 1 or 0 into mem[P3] if the checkpoint returns\n** SQLITE_BUSY or not, respectively.  Write the number of pages in the\n** WAL after the checkpoint into mem[P3+1] and the number of pages\n** in the WAL that have been checkpointed after the checkpoint\n** completes into mem[P3+2].  However on an error, mem[P3+1] and\n** mem[P3+2] are initialized to -1.\n*/\ncase OP_Checkpoint: {\n  int i;                          /* Loop counter */\n  int aRes[3];                    /* Results */\n  Mem *pMem;                      /* Write results here */\n\n  assert( p->readOnly==0 );\n  aRes[0] = 0;\n  aRes[1] = aRes[2] = -1;\n  assert( pOp->p2==SQLITE_CHECKPOINT_PASSIVE\n       || pOp->p2==SQLITE_CHECKPOINT_FULL\n       || pOp->p2==SQLITE_CHECKPOINT_RESTART\n       || pOp->p2==SQLITE_CHECKPOINT_TRUNCATE\n  );\n  rc = sqlite3Checkpoint(db, pOp->p1, pOp->p2, &aRes[1], &aRes[2]);\n  if( rc ){\n    if( rc!=SQLITE_BUSY ) goto abort_due_to_error;\n    rc = SQLITE_OK;\n    aRes[0] = 1;\n  }\n  for(i=0, pMem = &aMem[pOp->p3]; i<3; i++, pMem++){\n    sqlite3VdbeMemSetInt64(pMem, (i64)aRes[i]);\n  }    \n  break;\n};  \n#endif\n\n#ifndef SQLITE_OMIT_PRAGMA\n/* Opcode: JournalMode P1 P2 P3 * *\n**\n** Change the journal mode of database P1 to P3. P3 must be one of the\n** PAGER_JOURNALMODE_XXX values. If changing between the various rollback\n** modes (delete, truncate, persist, off and memory), this is a simple\n** operation. No IO is required.\n**\n** If changing into or out of WAL mode the procedure is more complicated.\n**\n** Write a string containing the final journal-mode to register P2.\n*/\ncase OP_JournalMode: {    /* out2 */\n  Btree *pBt;                     /* Btree to change journal mode of */\n  Pager *pPager;                  /* Pager associated with pBt */\n  int eNew;                       /* New journal mode */\n  int eOld;                       /* The old journal mode */\n#ifndef SQLITE_OMIT_WAL\n  const char *zFilename;          /* Name of database file for pPager */\n#endif\n\n  pOut = out2Prerelease(p, pOp);\n  eNew = pOp->p3;\n  assert( eNew==PAGER_JOURNALMODE_DELETE \n       || eNew==PAGER_JOURNALMODE_TRUNCATE \n       || eNew==PAGER_JOURNALMODE_PERSIST \n       || eNew==PAGER_JOURNALMODE_OFF\n       || eNew==PAGER_JOURNALMODE_MEMORY\n       || eNew==PAGER_JOURNALMODE_WAL\n       || eNew==PAGER_JOURNALMODE_QUERY\n  );\n  assert( pOp->p1>=0 && pOp->p1<db->nDb );\n  assert( p->readOnly==0 );\n\n  pBt = db->aDb[pOp->p1].pBt;\n  pPager = sqlite3BtreePager(pBt);\n  eOld = sqlite3PagerGetJournalMode(pPager);\n  if( eNew==PAGER_JOURNALMODE_QUERY ) eNew = eOld;\n  if( !sqlite3PagerOkToChangeJournalMode(pPager) ) eNew = eOld;\n\n#ifndef SQLITE_OMIT_WAL\n  zFilename = sqlite3PagerFilename(pPager, 1);\n\n  /* Do not allow a transition to journal_mode=WAL for a database\n  ** in temporary storage or if the VFS does not support shared memory \n  */\n  if( eNew==PAGER_JOURNALMODE_WAL\n   && (sqlite3Strlen30(zFilename)==0           /* Temp file */\n       || !sqlite3PagerWalSupported(pPager))   /* No shared-memory support */\n  ){\n    eNew = eOld;\n  }\n\n  if( (eNew!=eOld)\n   && (eOld==PAGER_JOURNALMODE_WAL || eNew==PAGER_JOURNALMODE_WAL)\n  ){\n    if( !db->autoCommit || db->nVdbeRead>1 ){\n      rc = SQLITE_ERROR;\n      sqlite3VdbeError(p,\n          \"cannot change %s wal mode from within a transaction\",\n          (eNew==PAGER_JOURNALMODE_WAL ? \"into\" : \"out of\")\n      );\n      goto abort_due_to_error;\n    }else{\n \n      if( eOld==PAGER_JOURNALMODE_WAL ){\n        /* If leaving WAL mode, close the log file. If successful, the call\n        ** to PagerCloseWal() checkpoints and deletes the write-ahead-log \n        ** file. An EXCLUSIVE lock may still be held on the database file \n        ** after a successful return. \n        */\n        rc = sqlite3PagerCloseWal(pPager, db);\n        if( rc==SQLITE_OK ){\n          sqlite3PagerSetJournalMode(pPager, eNew);\n        }\n      }else if( eOld==PAGER_JOURNALMODE_MEMORY ){\n        /* Cannot transition directly from MEMORY to WAL.  Use mode OFF\n        ** as an intermediate */\n        sqlite3PagerSetJournalMode(pPager, PAGER_JOURNALMODE_OFF);\n      }\n  \n      /* Open a transaction on the database file. Regardless of the journal\n      ** mode, this transaction always uses a rollback journal.\n      */\n      assert( sqlite3BtreeIsInTrans(pBt)==0 );\n      if( rc==SQLITE_OK ){\n        rc = sqlite3BtreeSetVersion(pBt, (eNew==PAGER_JOURNALMODE_WAL ? 2 : 1));\n      }\n    }\n  }\n#endif /* ifndef SQLITE_OMIT_WAL */\n\n  if( rc ) eNew = eOld;\n  eNew = sqlite3PagerSetJournalMode(pPager, eNew);\n\n  pOut->flags = MEM_Str|MEM_Static|MEM_Term;\n  pOut->z = (char *)sqlite3JournalModename(eNew);\n  pOut->n = sqlite3Strlen30(pOut->z);\n  pOut->enc = SQLITE_UTF8;\n  sqlite3VdbeChangeEncoding(pOut, encoding);\n  if( rc ) goto abort_due_to_error;\n  break;\n};\n#endif /* SQLITE_OMIT_PRAGMA */\n\n#if !defined(SQLITE_OMIT_VACUUM) && !defined(SQLITE_OMIT_ATTACH)\n/* Opcode: Vacuum P1 P2 * * *\n**\n** Vacuum the entire database P1.  P1 is 0 for \"main\", and 2 or more\n** for an attached database.  The \"temp\" database may not be vacuumed.\n**\n** If P2 is not zero, then it is a register holding a string which is\n** the file into which the result of vacuum should be written.  When\n** P2 is zero, the vacuum overwrites the original database.\n*/\ncase OP_Vacuum: {\n  assert( p->readOnly==0 );\n  rc = sqlite3RunVacuum(&p->zErrMsg, db, pOp->p1,\n                        pOp->p2 ? &aMem[pOp->p2] : 0);\n  if( rc ) goto abort_due_to_error;\n  break;\n}\n#endif\n\n#if !defined(SQLITE_OMIT_AUTOVACUUM)\n/* Opcode: IncrVacuum P1 P2 * * *\n**\n** Perform a single step of the incremental vacuum procedure on\n** the P1 database. If the vacuum has finished, jump to instruction\n** P2. Otherwise, fall through to the next instruction.\n*/\ncase OP_IncrVacuum: {        /* jump */\n  Btree *pBt;\n\n  assert( pOp->p1>=0 && pOp->p1<db->nDb );\n  assert( DbMaskTest(p->btreeMask, pOp->p1) );\n  assert( p->readOnly==0 );\n  pBt = db->aDb[pOp->p1].pBt;\n  rc = sqlite3BtreeIncrVacuum(pBt);\n  VdbeBranchTaken(rc==SQLITE_DONE,2);\n  if( rc ){\n    if( rc!=SQLITE_DONE ) goto abort_due_to_error;\n    rc = SQLITE_OK;\n    goto jump_to_p2;\n  }\n  break;\n}\n#endif\n\n/* Opcode: Expire P1 P2 * * *\n**\n** Cause precompiled statements to expire.  When an expired statement\n** is executed using sqlite3_step() it will either automatically\n** reprepare itself (if it was originally created using sqlite3_prepare_v2())\n** or it will fail with SQLITE_SCHEMA.\n** \n** If P1 is 0, then all SQL statements become expired. If P1 is non-zero,\n** then only the currently executing statement is expired.\n**\n** If P2 is 0, then SQL statements are expired immediately.  If P2 is 1,\n** then running SQL statements are allowed to continue to run to completion.\n** The P2==1 case occurs when a CREATE INDEX or similar schema change happens\n** that might help the statement run faster but which does not affect the\n** correctness of operation.\n*/\ncase OP_Expire: {\n  assert( pOp->p2==0 || pOp->p2==1 );\n  if( !pOp->p1 ){\n    sqlite3ExpirePreparedStatements(db, pOp->p2);\n  }else{\n    p->expired = pOp->p2+1;\n  }\n  break;\n}\n\n#ifndef SQLITE_OMIT_SHARED_CACHE\n/* Opcode: TableLock P1 P2 P3 P4 *\n** Synopsis: iDb=P1 root=P2 write=P3\n**\n** Obtain a lock on a particular table. This instruction is only used when\n** the shared-cache feature is enabled. \n**\n** P1 is the index of the database in sqlite3.aDb[] of the database\n** on which the lock is acquired.  A readlock is obtained if P3==0 or\n** a write lock if P3==1.\n**\n** P2 contains the root-page of the table to lock.\n**\n** P4 contains a pointer to the name of the table being locked. This is only\n** used to generate an error message if the lock cannot be obtained.\n*/\ncase OP_TableLock: {\n  u8 isWriteLock = (u8)pOp->p3;\n  if( isWriteLock || 0==(db->flags&SQLITE_ReadUncommit) ){\n    int p1 = pOp->p1; \n    assert( p1>=0 && p1<db->nDb );\n    assert( DbMaskTest(p->btreeMask, p1) );\n    assert( isWriteLock==0 || isWriteLock==1 );\n    rc = sqlite3BtreeLockTable(db->aDb[p1].pBt, pOp->p2, isWriteLock);\n    if( rc ){\n      if( (rc&0xFF)==SQLITE_LOCKED ){\n        const char *z = pOp->p4.z;\n        sqlite3VdbeError(p, \"database table is locked: %s\", z);\n      }\n      goto abort_due_to_error;\n    }\n  }\n  break;\n}\n#endif /* SQLITE_OMIT_SHARED_CACHE */\n\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n/* Opcode: VBegin * * * P4 *\n**\n** P4 may be a pointer to an sqlite3_vtab structure. If so, call the \n** xBegin method for that table.\n**\n** Also, whether or not P4 is set, check that this is not being called from\n** within a callback to a virtual table xSync() method. If it is, the error\n** code will be set to SQLITE_LOCKED.\n*/\ncase OP_VBegin: {\n  VTable *pVTab;\n  pVTab = pOp->p4.pVtab;\n  rc = sqlite3VtabBegin(db, pVTab);\n  if( pVTab ) sqlite3VtabImportErrmsg(p, pVTab->pVtab);\n  if( rc ) goto abort_due_to_error;\n  break;\n}\n#endif /* SQLITE_OMIT_VIRTUALTABLE */\n\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n/* Opcode: VCreate P1 P2 * * *\n**\n** P2 is a register that holds the name of a virtual table in database \n** P1. Call the xCreate method for that table.\n*/\ncase OP_VCreate: {\n  Mem sMem;          /* For storing the record being decoded */\n  const char *zTab;  /* Name of the virtual table */\n\n  memset(&sMem, 0, sizeof(sMem));\n  sMem.db = db;\n  /* Because P2 is always a static string, it is impossible for the\n  ** sqlite3VdbeMemCopy() to fail */\n  assert( (aMem[pOp->p2].flags & MEM_Str)!=0 );\n  assert( (aMem[pOp->p2].flags & MEM_Static)!=0 );\n  rc = sqlite3VdbeMemCopy(&sMem, &aMem[pOp->p2]);\n  assert( rc==SQLITE_OK );\n  zTab = (const char*)sqlite3_value_text(&sMem);\n  assert( zTab || db->mallocFailed );\n  if( zTab ){\n    rc = sqlite3VtabCallCreate(db, pOp->p1, zTab, &p->zErrMsg);\n  }\n  sqlite3VdbeMemRelease(&sMem);\n  if( rc ) goto abort_due_to_error;\n  break;\n}\n#endif /* SQLITE_OMIT_VIRTUALTABLE */\n\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n/* Opcode: VDestroy P1 * * P4 *\n**\n** P4 is the name of a virtual table in database P1.  Call the xDestroy method\n** of that table.\n*/\ncase OP_VDestroy: {\n  db->nVDestroy++;\n  rc = sqlite3VtabCallDestroy(db, pOp->p1, pOp->p4.z);\n  db->nVDestroy--;\n  assert( p->errorAction==OE_Abort && p->usesStmtJournal );\n  if( rc ) goto abort_due_to_error;\n  break;\n}\n#endif /* SQLITE_OMIT_VIRTUALTABLE */\n\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n/* Opcode: VOpen P1 * * P4 *\n**\n** P4 is a pointer to a virtual table object, an sqlite3_vtab structure.\n** P1 is a cursor number.  This opcode opens a cursor to the virtual\n** table and stores that cursor in P1.\n*/\ncase OP_VOpen: {\n  VdbeCursor *pCur;\n  sqlite3_vtab_cursor *pVCur;\n  sqlite3_vtab *pVtab;\n  const sqlite3_module *pModule;\n\n  assert( p->bIsReader );\n  pCur = 0;\n  pVCur = 0;\n  pVtab = pOp->p4.pVtab->pVtab;\n  if( pVtab==0 || NEVER(pVtab->pModule==0) ){\n    rc = SQLITE_LOCKED;\n    goto abort_due_to_error;\n  }\n  pModule = pVtab->pModule;\n  rc = pModule->xOpen(pVtab, &pVCur);\n  sqlite3VtabImportErrmsg(p, pVtab);\n  if( rc ) goto abort_due_to_error;\n\n  /* Initialize sqlite3_vtab_cursor base class */\n  pVCur->pVtab = pVtab;\n\n  /* Initialize vdbe cursor object */\n  pCur = allocateCursor(p, pOp->p1, 0, -1, CURTYPE_VTAB);\n  if( pCur ){\n    pCur->uc.pVCur = pVCur;\n    pVtab->nRef++;\n  }else{\n    assert( db->mallocFailed );\n    pModule->xClose(pVCur);\n    goto no_mem;\n  }\n  break;\n}\n#endif /* SQLITE_OMIT_VIRTUALTABLE */\n\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n/* Opcode: VFilter P1 P2 P3 P4 *\n** Synopsis: iplan=r[P3] zplan='P4'\n**\n** P1 is a cursor opened using VOpen.  P2 is an address to jump to if\n** the filtered result set is empty.\n**\n** P4 is either NULL or a string that was generated by the xBestIndex\n** method of the module.  The interpretation of the P4 string is left\n** to the module implementation.\n**\n** This opcode invokes the xFilter method on the virtual table specified\n** by P1.  The integer query plan parameter to xFilter is stored in register\n** P3. Register P3+1 stores the argc parameter to be passed to the\n** xFilter method. Registers P3+2..P3+1+argc are the argc\n** additional parameters which are passed to\n** xFilter as argv. Register P3+2 becomes argv[0] when passed to xFilter.\n**\n** A jump is made to P2 if the result set after filtering would be empty.\n*/\ncase OP_VFilter: {   /* jump */\n  int nArg;\n  int iQuery;\n  const sqlite3_module *pModule;\n  Mem *pQuery;\n  Mem *pArgc;\n  sqlite3_vtab_cursor *pVCur;\n  sqlite3_vtab *pVtab;\n  VdbeCursor *pCur;\n  int res;\n  int i;\n  Mem **apArg;\n\n  pQuery = &aMem[pOp->p3];\n  pArgc = &pQuery[1];\n  pCur = p->apCsr[pOp->p1];\n  assert( memIsValid(pQuery) );\n  REGISTER_TRACE(pOp->p3, pQuery);\n  assert( pCur->eCurType==CURTYPE_VTAB );\n  pVCur = pCur->uc.pVCur;\n  pVtab = pVCur->pVtab;\n  pModule = pVtab->pModule;\n\n  /* Grab the index number and argc parameters */\n  assert( (pQuery->flags&MEM_Int)!=0 && pArgc->flags==MEM_Int );\n  nArg = (int)pArgc->u.i;\n  iQuery = (int)pQuery->u.i;\n\n  /* Invoke the xFilter method */\n  res = 0;\n  apArg = p->apArg;\n  for(i = 0; i<nArg; i++){\n    apArg[i] = &pArgc[i+1];\n  }\n  rc = pModule->xFilter(pVCur, iQuery, pOp->p4.z, nArg, apArg);\n  sqlite3VtabImportErrmsg(p, pVtab);\n  if( rc ) goto abort_due_to_error;\n  res = pModule->xEof(pVCur);\n  pCur->nullRow = 0;\n  VdbeBranchTaken(res!=0,2);\n  if( res ) goto jump_to_p2;\n  break;\n}\n#endif /* SQLITE_OMIT_VIRTUALTABLE */\n\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n/* Opcode: VColumn P1 P2 P3 * P5\n** Synopsis: r[P3]=vcolumn(P2)\n**\n** Store in register P3 the value of the P2-th column of\n** the current row of the virtual-table of cursor P1.\n**\n** If the VColumn opcode is being used to fetch the value of\n** an unchanging column during an UPDATE operation, then the P5\n** value is OPFLAG_NOCHNG.  This will cause the sqlite3_vtab_nochange()\n** function to return true inside the xColumn method of the virtual\n** table implementation.  The P5 column might also contain other\n** bits (OPFLAG_LENGTHARG or OPFLAG_TYPEOFARG) but those bits are\n** unused by OP_VColumn.\n*/\ncase OP_VColumn: {\n  sqlite3_vtab *pVtab;\n  const sqlite3_module *pModule;\n  Mem *pDest;\n  sqlite3_context sContext;\n\n  VdbeCursor *pCur = p->apCsr[pOp->p1];\n  assert( pCur->eCurType==CURTYPE_VTAB );\n  assert( pOp->p3>0 && pOp->p3<=(p->nMem+1 - p->nCursor) );\n  pDest = &aMem[pOp->p3];\n  memAboutToChange(p, pDest);\n  if( pCur->nullRow ){\n    sqlite3VdbeMemSetNull(pDest);\n    break;\n  }\n  pVtab = pCur->uc.pVCur->pVtab;\n  pModule = pVtab->pModule;\n  assert( pModule->xColumn );\n  memset(&sContext, 0, sizeof(sContext));\n  sContext.pOut = pDest;\n  testcase( (pOp->p5 & OPFLAG_NOCHNG)==0 && pOp->p5!=0 );\n  if( pOp->p5 & OPFLAG_NOCHNG ){\n    sqlite3VdbeMemSetNull(pDest);\n    pDest->flags = MEM_Null|MEM_Zero;\n    pDest->u.nZero = 0;\n  }else{\n    MemSetTypeFlag(pDest, MEM_Null);\n  }\n  rc = pModule->xColumn(pCur->uc.pVCur, &sContext, pOp->p2);\n  sqlite3VtabImportErrmsg(p, pVtab);\n  if( sContext.isError>0 ){\n    sqlite3VdbeError(p, \"%s\", sqlite3_value_text(pDest));\n    rc = sContext.isError;\n  }\n  sqlite3VdbeChangeEncoding(pDest, encoding);\n  REGISTER_TRACE(pOp->p3, pDest);\n  UPDATE_MAX_BLOBSIZE(pDest);\n\n  if( sqlite3VdbeMemTooBig(pDest) ){\n    goto too_big;\n  }\n  if( rc ) goto abort_due_to_error;\n  break;\n}\n#endif /* SQLITE_OMIT_VIRTUALTABLE */\n\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n/* Opcode: VNext P1 P2 * * *\n**\n** Advance virtual table P1 to the next row in its result set and\n** jump to instruction P2.  Or, if the virtual table has reached\n** the end of its result set, then fall through to the next instruction.\n*/\ncase OP_VNext: {   /* jump */\n  sqlite3_vtab *pVtab;\n  const sqlite3_module *pModule;\n  int res;\n  VdbeCursor *pCur;\n\n  res = 0;\n  pCur = p->apCsr[pOp->p1];\n  assert( pCur->eCurType==CURTYPE_VTAB );\n  if( pCur->nullRow ){\n    break;\n  }\n  pVtab = pCur->uc.pVCur->pVtab;\n  pModule = pVtab->pModule;\n  assert( pModule->xNext );\n\n  /* Invoke the xNext() method of the module. There is no way for the\n  ** underlying implementation to return an error if one occurs during\n  ** xNext(). Instead, if an error occurs, true is returned (indicating that \n  ** data is available) and the error code returned when xColumn or\n  ** some other method is next invoked on the save virtual table cursor.\n  */\n  rc = pModule->xNext(pCur->uc.pVCur);\n  sqlite3VtabImportErrmsg(p, pVtab);\n  if( rc ) goto abort_due_to_error;\n  res = pModule->xEof(pCur->uc.pVCur);\n  VdbeBranchTaken(!res,2);\n  if( !res ){\n    /* If there is data, jump to P2 */\n    goto jump_to_p2_and_check_for_interrupt;\n  }\n  goto check_for_interrupt;\n}\n#endif /* SQLITE_OMIT_VIRTUALTABLE */\n\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n/* Opcode: VRename P1 * * P4 *\n**\n** P4 is a pointer to a virtual table object, an sqlite3_vtab structure.\n** This opcode invokes the corresponding xRename method. The value\n** in register P1 is passed as the zName argument to the xRename method.\n*/\ncase OP_VRename: {\n  sqlite3_vtab *pVtab;\n  Mem *pName;\n  int isLegacy;\n  \n  isLegacy = (db->flags & SQLITE_LegacyAlter);\n  db->flags |= SQLITE_LegacyAlter;\n  pVtab = pOp->p4.pVtab->pVtab;\n  pName = &aMem[pOp->p1];\n  assert( pVtab->pModule->xRename );\n  assert( memIsValid(pName) );\n  assert( p->readOnly==0 );\n  REGISTER_TRACE(pOp->p1, pName);\n  assert( pName->flags & MEM_Str );\n  testcase( pName->enc==SQLITE_UTF8 );\n  testcase( pName->enc==SQLITE_UTF16BE );\n  testcase( pName->enc==SQLITE_UTF16LE );\n  rc = sqlite3VdbeChangeEncoding(pName, SQLITE_UTF8);\n  if( rc ) goto abort_due_to_error;\n  rc = pVtab->pModule->xRename(pVtab, pName->z);\n  if( isLegacy==0 ) db->flags &= ~(u64)SQLITE_LegacyAlter;\n  sqlite3VtabImportErrmsg(p, pVtab);\n  p->expired = 0;\n  if( rc ) goto abort_due_to_error;\n  break;\n}\n#endif\n\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n/* Opcode: VUpdate P1 P2 P3 P4 P5\n** Synopsis: data=r[P3@P2]\n**\n** P4 is a pointer to a virtual table object, an sqlite3_vtab structure.\n** This opcode invokes the corresponding xUpdate method. P2 values\n** are contiguous memory cells starting at P3 to pass to the xUpdate \n** invocation. The value in register (P3+P2-1) corresponds to the \n** p2th element of the argv array passed to xUpdate.\n**\n** The xUpdate method will do a DELETE or an INSERT or both.\n** The argv[0] element (which corresponds to memory cell P3)\n** is the rowid of a row to delete.  If argv[0] is NULL then no \n** deletion occurs.  The argv[1] element is the rowid of the new \n** row.  This can be NULL to have the virtual table select the new \n** rowid for itself.  The subsequent elements in the array are \n** the values of columns in the new row.\n**\n** If P2==1 then no insert is performed.  argv[0] is the rowid of\n** a row to delete.\n**\n** P1 is a boolean flag. If it is set to true and the xUpdate call\n** is successful, then the value returned by sqlite3_last_insert_rowid() \n** is set to the value of the rowid for the row just inserted.\n**\n** P5 is the error actions (OE_Replace, OE_Fail, OE_Ignore, etc) to\n** apply in the case of a constraint failure on an insert or update.\n*/\ncase OP_VUpdate: {\n  sqlite3_vtab *pVtab;\n  const sqlite3_module *pModule;\n  int nArg;\n  int i;\n  sqlite_int64 rowid;\n  Mem **apArg;\n  Mem *pX;\n\n  assert( pOp->p2==1        || pOp->p5==OE_Fail   || pOp->p5==OE_Rollback \n       || pOp->p5==OE_Abort || pOp->p5==OE_Ignore || pOp->p5==OE_Replace\n  );\n  assert( p->readOnly==0 );\n  if( db->mallocFailed ) goto no_mem;\n  sqlite3VdbeIncrWriteCounter(p, 0);\n  pVtab = pOp->p4.pVtab->pVtab;\n  if( pVtab==0 || NEVER(pVtab->pModule==0) ){\n    rc = SQLITE_LOCKED;\n    goto abort_due_to_error;\n  }\n  pModule = pVtab->pModule;\n  nArg = pOp->p2;\n  assert( pOp->p4type==P4_VTAB );\n  if( ALWAYS(pModule->xUpdate) ){\n    u8 vtabOnConflict = db->vtabOnConflict;\n    apArg = p->apArg;\n    pX = &aMem[pOp->p3];\n    for(i=0; i<nArg; i++){\n      assert( memIsValid(pX) );\n      memAboutToChange(p, pX);\n      apArg[i] = pX;\n      pX++;\n    }\n    db->vtabOnConflict = pOp->p5;\n    rc = pModule->xUpdate(pVtab, nArg, apArg, &rowid);\n    db->vtabOnConflict = vtabOnConflict;\n    sqlite3VtabImportErrmsg(p, pVtab);\n    if( rc==SQLITE_OK && pOp->p1 ){\n      assert( nArg>1 && apArg[0] && (apArg[0]->flags&MEM_Null) );\n      db->lastRowid = rowid;\n    }\n    if( (rc&0xff)==SQLITE_CONSTRAINT && pOp->p4.pVtab->bConstraint ){\n      if( pOp->p5==OE_Ignore ){\n        rc = SQLITE_OK;\n      }else{\n        p->errorAction = ((pOp->p5==OE_Replace) ? OE_Abort : pOp->p5);\n      }\n    }else{\n      p->nChange++;\n    }\n    if( rc ) goto abort_due_to_error;\n  }\n  break;\n}\n#endif /* SQLITE_OMIT_VIRTUALTABLE */\n\n#ifndef  SQLITE_OMIT_PAGER_PRAGMAS\n/* Opcode: Pagecount P1 P2 * * *\n**\n** Write the current number of pages in database P1 to memory cell P2.\n*/\ncase OP_Pagecount: {            /* out2 */\n  pOut = out2Prerelease(p, pOp);\n  pOut->u.i = sqlite3BtreeLastPage(db->aDb[pOp->p1].pBt);\n  break;\n}\n#endif\n\n\n#ifndef  SQLITE_OMIT_PAGER_PRAGMAS\n/* Opcode: MaxPgcnt P1 P2 P3 * *\n**\n** Try to set the maximum page count for database P1 to the value in P3.\n** Do not let the maximum page count fall below the current page count and\n** do not change the maximum page count value if P3==0.\n**\n** Store the maximum page count after the change in register P2.\n*/\ncase OP_MaxPgcnt: {            /* out2 */\n  unsigned int newMax;\n  Btree *pBt;\n\n  pOut = out2Prerelease(p, pOp);\n  pBt = db->aDb[pOp->p1].pBt;\n  newMax = 0;\n  if( pOp->p3 ){\n    newMax = sqlite3BtreeLastPage(pBt);\n    if( newMax < (unsigned)pOp->p3 ) newMax = (unsigned)pOp->p3;\n  }\n  pOut->u.i = sqlite3BtreeMaxPageCount(pBt, newMax);\n  break;\n}\n#endif\n\n/* Opcode: Function0 P1 P2 P3 P4 P5\n** Synopsis: r[P3]=func(r[P2@P5])\n**\n** Invoke a user function (P4 is a pointer to a FuncDef object that\n** defines the function) with P5 arguments taken from register P2 and\n** successors.  The result of the function is stored in register P3.\n** Register P3 must not be one of the function inputs.\n**\n** P1 is a 32-bit bitmask indicating whether or not each argument to the \n** function was determined to be constant at compile time. If the first\n** argument was constant then bit 0 of P1 is set. This is used to determine\n** whether meta data associated with a user function argument using the\n** sqlite3_set_auxdata() API may be safely retained until the next\n** invocation of this opcode.\n**\n** See also: Function, AggStep, AggFinal\n*/\n/* Opcode: Function P1 P2 P3 P4 P5\n** Synopsis: r[P3]=func(r[P2@P5])\n**\n** Invoke a user function (P4 is a pointer to an sqlite3_context object that\n** contains a pointer to the function to be run) with P5 arguments taken\n** from register P2 and successors.  The result of the function is stored\n** in register P3.  Register P3 must not be one of the function inputs.\n**\n** P1 is a 32-bit bitmask indicating whether or not each argument to the \n** function was determined to be constant at compile time. If the first\n** argument was constant then bit 0 of P1 is set. This is used to determine\n** whether meta data associated with a user function argument using the\n** sqlite3_set_auxdata() API may be safely retained until the next\n** invocation of this opcode.\n**\n** SQL functions are initially coded as OP_Function0 with P4 pointing\n** to a FuncDef object.  But on first evaluation, the P4 operand is\n** automatically converted into an sqlite3_context object and the operation\n** changed to this OP_Function opcode.  In this way, the initialization of\n** the sqlite3_context object occurs only once, rather than once for each\n** evaluation of the function.\n**\n** See also: Function0, AggStep, AggFinal\n*/\ncase OP_PureFunc0:              /* group */\ncase OP_Function0: {            /* group */\n  int n;\n  sqlite3_context *pCtx;\n\n  assert( pOp->p4type==P4_FUNCDEF );\n  n = pOp->p5;\n  assert( pOp->p3>0 && pOp->p3<=(p->nMem+1 - p->nCursor) );\n  assert( n==0 || (pOp->p2>0 && pOp->p2+n<=(p->nMem+1 - p->nCursor)+1) );\n  assert( pOp->p3<pOp->p2 || pOp->p3>=pOp->p2+n );\n  pCtx = sqlite3DbMallocRawNN(db, sizeof(*pCtx) + (n-1)*sizeof(sqlite3_value*));\n  if( pCtx==0 ) goto no_mem;\n  pCtx->pOut = 0;\n  pCtx->pFunc = pOp->p4.pFunc;\n  pCtx->iOp = (int)(pOp - aOp);\n  pCtx->pVdbe = p;\n  pCtx->isError = 0;\n  pCtx->argc = n;\n  pOp->p4type = P4_FUNCCTX;\n  pOp->p4.pCtx = pCtx;\n  assert( OP_PureFunc == OP_PureFunc0+2 );\n  assert( OP_Function == OP_Function0+2 );\n  pOp->opcode += 2;\n  /* Fall through into OP_Function */\n}\ncase OP_PureFunc:              /* group */\ncase OP_Function: {            /* group */\n  int i;\n  sqlite3_context *pCtx;\n\n  assert( pOp->p4type==P4_FUNCCTX );\n  pCtx = pOp->p4.pCtx;\n\n  /* If this function is inside of a trigger, the register array in aMem[]\n  ** might change from one evaluation to the next.  The next block of code\n  ** checks to see if the register array has changed, and if so it\n  ** reinitializes the relavant parts of the sqlite3_context object */\n  pOut = &aMem[pOp->p3];\n  if( pCtx->pOut != pOut ){\n    pCtx->pOut = pOut;\n    for(i=pCtx->argc-1; i>=0; i--) pCtx->argv[i] = &aMem[pOp->p2+i];\n  }\n\n  memAboutToChange(p, pOut);\n#ifdef SQLITE_DEBUG\n  for(i=0; i<pCtx->argc; i++){\n    assert( memIsValid(pCtx->argv[i]) );\n    REGISTER_TRACE(pOp->p2+i, pCtx->argv[i]);\n  }\n#endif\n  MemSetTypeFlag(pOut, MEM_Null);\n  assert( pCtx->isError==0 );\n  (*pCtx->pFunc->xSFunc)(pCtx, pCtx->argc, pCtx->argv);/* IMP: R-24505-23230 */\n\n  /* If the function returned an error, throw an exception */\n  if( pCtx->isError ){\n    if( pCtx->isError>0 ){\n      sqlite3VdbeError(p, \"%s\", sqlite3_value_text(pOut));\n      rc = pCtx->isError;\n    }\n    sqlite3VdbeDeleteAuxData(db, &p->pAuxData, pCtx->iOp, pOp->p1);\n    pCtx->isError = 0;\n    if( rc ) goto abort_due_to_error;\n  }\n\n  /* Copy the result of the function into register P3 */\n  if( pOut->flags & (MEM_Str|MEM_Blob) ){\n    sqlite3VdbeChangeEncoding(pOut, encoding);\n    if( sqlite3VdbeMemTooBig(pOut) ) goto too_big;\n  }\n\n  REGISTER_TRACE(pOp->p3, pOut);\n  UPDATE_MAX_BLOBSIZE(pOut);\n  break;\n}\n\n/* Opcode: Trace P1 P2 * P4 *\n**\n** Write P4 on the statement trace output if statement tracing is\n** enabled.\n**\n** Operand P1 must be 0x7fffffff and P2 must positive.\n*/\n/* Opcode: Init P1 P2 P3 P4 *\n** Synopsis: Start at P2\n**\n** Programs contain a single instance of this opcode as the very first\n** opcode.\n**\n** If tracing is enabled (by the sqlite3_trace()) interface, then\n** the UTF-8 string contained in P4 is emitted on the trace callback.\n** Or if P4 is blank, use the string returned by sqlite3_sql().\n**\n** If P2 is not zero, jump to instruction P2.\n**\n** Increment the value of P1 so that OP_Once opcodes will jump the\n** first time they are evaluated for this run.\n**\n** If P3 is not zero, then it is an address to jump to if an SQLITE_CORRUPT\n** error is encountered.\n*/\ncase OP_Trace:\ncase OP_Init: {          /* jump */\n  int i;\n#ifndef SQLITE_OMIT_TRACE\n  char *zTrace;\n#endif\n\n  /* If the P4 argument is not NULL, then it must be an SQL comment string.\n  ** The \"--\" string is broken up to prevent false-positives with srcck1.c.\n  **\n  ** This assert() provides evidence for:\n  ** EVIDENCE-OF: R-50676-09860 The callback can compute the same text that\n  ** would have been returned by the legacy sqlite3_trace() interface by\n  ** using the X argument when X begins with \"--\" and invoking\n  ** sqlite3_expanded_sql(P) otherwise.\n  */\n  assert( pOp->p4.z==0 || strncmp(pOp->p4.z, \"-\" \"- \", 3)==0 );\n\n  /* OP_Init is always instruction 0 */\n  assert( pOp==p->aOp || pOp->opcode==OP_Trace );\n\n#ifndef SQLITE_OMIT_TRACE\n  if( (db->mTrace & (SQLITE_TRACE_STMT|SQLITE_TRACE_LEGACY))!=0\n   && !p->doingRerun\n   && (zTrace = (pOp->p4.z ? pOp->p4.z : p->zSql))!=0\n  ){\n#ifndef SQLITE_OMIT_DEPRECATED\n    if( db->mTrace & SQLITE_TRACE_LEGACY ){\n      void (*x)(void*,const char*) = (void(*)(void*,const char*))db->xTrace;\n      char *z = sqlite3VdbeExpandSql(p, zTrace);\n      x(db->pTraceArg, z);\n      sqlite3_free(z);\n    }else\n#endif\n    if( db->nVdbeExec>1 ){\n      char *z = sqlite3MPrintf(db, \"-- %s\", zTrace);\n      (void)db->xTrace(SQLITE_TRACE_STMT, db->pTraceArg, p, z);\n      sqlite3DbFree(db, z);\n    }else{\n      (void)db->xTrace(SQLITE_TRACE_STMT, db->pTraceArg, p, zTrace);\n    }\n  }\n#ifdef SQLITE_USE_FCNTL_TRACE\n  zTrace = (pOp->p4.z ? pOp->p4.z : p->zSql);\n  if( zTrace ){\n    int j;\n    for(j=0; j<db->nDb; j++){\n      if( DbMaskTest(p->btreeMask, j)==0 ) continue;\n      sqlite3_file_control(db, db->aDb[j].zDbSName, SQLITE_FCNTL_TRACE, zTrace);\n    }\n  }\n#endif /* SQLITE_USE_FCNTL_TRACE */\n#ifdef SQLITE_DEBUG\n  if( (db->flags & SQLITE_SqlTrace)!=0\n   && (zTrace = (pOp->p4.z ? pOp->p4.z : p->zSql))!=0\n  ){\n    sqlite3DebugPrintf(\"SQL-trace: %s\\n\", zTrace);\n  }\n#endif /* SQLITE_DEBUG */\n#endif /* SQLITE_OMIT_TRACE */\n  assert( pOp->p2>0 );\n  if( pOp->p1>=sqlite3GlobalConfig.iOnceResetThreshold ){\n    if( pOp->opcode==OP_Trace ) break;\n    for(i=1; i<p->nOp; i++){\n      if( p->aOp[i].opcode==OP_Once ) p->aOp[i].p1 = 0;\n    }\n    pOp->p1 = 0;\n  }\n  pOp->p1++;\n  p->aCounter[SQLITE_STMTSTATUS_RUN]++;\n  goto jump_to_p2;\n}\n\n#ifdef SQLITE_ENABLE_CURSOR_HINTS\n/* Opcode: CursorHint P1 * * P4 *\n**\n** Provide a hint to cursor P1 that it only needs to return rows that\n** satisfy the Expr in P4.  TK_REGISTER terms in the P4 expression refer\n** to values currently held in registers.  TK_COLUMN terms in the P4\n** expression refer to columns in the b-tree to which cursor P1 is pointing.\n*/\ncase OP_CursorHint: {\n  VdbeCursor *pC;\n\n  assert( pOp->p1>=0 && pOp->p1<p->nCursor );\n  assert( pOp->p4type==P4_EXPR );\n  pC = p->apCsr[pOp->p1];\n  if( pC ){\n    assert( pC->eCurType==CURTYPE_BTREE );\n    sqlite3BtreeCursorHint(pC->uc.pCursor, BTREE_HINT_RANGE,\n                           pOp->p4.pExpr, aMem);\n  }\n  break;\n}\n#endif /* SQLITE_ENABLE_CURSOR_HINTS */\n\n#ifdef SQLITE_DEBUG\n/* Opcode:  Abortable   * * * * *\n**\n** Verify that an Abort can happen.  Assert if an Abort at this point\n** might cause database corruption.  This opcode only appears in debugging\n** builds.\n**\n** An Abort is safe if either there have been no writes, or if there is\n** an active statement journal.\n*/\ncase OP_Abortable: {\n  sqlite3VdbeAssertAbortable(p);\n  break;\n}\n#endif\n\n/* Opcode: Noop * * * * *\n**\n** Do nothing.  This instruction is often useful as a jump\n** destination.\n*/\n/*\n** The magic Explain opcode are only inserted when explain==2 (which\n** is to say when the EXPLAIN QUERY PLAN syntax is used.)\n** This opcode records information from the optimizer.  It is the\n** the same as a no-op.  This opcodesnever appears in a real VM program.\n*/\ndefault: {          /* This is really OP_Noop, OP_Explain */\n  assert( pOp->opcode==OP_Noop || pOp->opcode==OP_Explain );\n\n  break;\n}\n\n/*****************************************************************************\n** The cases of the switch statement above this line should all be indented\n** by 6 spaces.  But the left-most 6 spaces have been removed to improve the\n** readability.  From this point on down, the normal indentation rules are\n** restored.\n*****************************************************************************/\n    }\n\n#ifdef VDBE_PROFILE\n    {\n      u64 endTime = sqlite3NProfileCnt ? sqlite3NProfileCnt : sqlite3Hwtime();\n      if( endTime>start ) pOrigOp->cycles += endTime - start;\n      pOrigOp->cnt++;\n    }\n#endif\n\n    /* The following code adds nothing to the actual functionality\n    ** of the program.  It is only here for testing and debugging.\n    ** On the other hand, it does burn CPU cycles every time through\n    ** the evaluator loop.  So we can leave it out when NDEBUG is defined.\n    */\n#ifndef NDEBUG\n    assert( pOp>=&aOp[-1] && pOp<&aOp[p->nOp-1] );\n\n#ifdef SQLITE_DEBUG\n    if( db->flags & SQLITE_VdbeTrace ){\n      u8 opProperty = sqlite3OpcodeProperty[pOrigOp->opcode];\n      if( rc!=0 ) printf(\"rc=%d\\n\",rc);\n      if( opProperty & (OPFLG_OUT2) ){\n        registerTrace(pOrigOp->p2, &aMem[pOrigOp->p2]);\n      }\n      if( opProperty & OPFLG_OUT3 ){\n        registerTrace(pOrigOp->p3, &aMem[pOrigOp->p3]);\n      }\n    }\n#endif  /* SQLITE_DEBUG */\n#endif  /* NDEBUG */\n  }  /* The end of the for(;;) loop the loops through opcodes */\n\n  /* If we reach this point, it means that execution is finished with\n  ** an error of some kind.\n  */\nabort_due_to_error:\n  if( db->mallocFailed ) rc = SQLITE_NOMEM_BKPT;\n  assert( rc );\n  if( p->zErrMsg==0 && rc!=SQLITE_IOERR_NOMEM ){\n    sqlite3VdbeError(p, \"%s\", sqlite3ErrStr(rc));\n  }\n  p->rc = rc;\n  sqlite3SystemError(db, rc);\n  testcase( sqlite3GlobalConfig.xLog!=0 );\n  sqlite3_log(rc, \"statement aborts at %d: [%s] %s\", \n                   (int)(pOp - aOp), p->zSql, p->zErrMsg);\n  sqlite3VdbeHalt(p);\n  if( rc==SQLITE_IOERR_NOMEM ) sqlite3OomFault(db);\n  rc = SQLITE_ERROR;\n  if( resetSchemaOnFault>0 ){\n    sqlite3ResetOneSchema(db, resetSchemaOnFault-1);\n  }\n\n  /* This is the only way out of this procedure.  We have to\n  ** release the mutexes on btrees that were acquired at the\n  ** top. */\nvdbe_return:\n  testcase( nVmStep>0 );\n  p->aCounter[SQLITE_STMTSTATUS_VM_STEP] += (int)nVmStep;\n  sqlite3VdbeLeave(p);\n  assert( rc!=SQLITE_OK || nExtraDelete==0 \n       || sqlite3_strlike(\"DELETE%\",p->zSql,0)!=0 \n  );\n  return rc;\n\n  /* Jump to here if a string or blob larger than SQLITE_MAX_LENGTH\n  ** is encountered.\n  */\ntoo_big:\n  sqlite3VdbeError(p, \"string or blob too big\");\n  rc = SQLITE_TOOBIG;\n  goto abort_due_to_error;\n\n  /* Jump to here if a malloc() fails.\n  */\nno_mem:\n  sqlite3OomFault(db);\n  sqlite3VdbeError(p, \"out of memory\");\n  rc = SQLITE_NOMEM_BKPT;\n  goto abort_due_to_error;\n\n  /* Jump to here if the sqlite3_interrupt() API sets the interrupt\n  ** flag.\n  */\nabort_due_to_interrupt:\n  assert( (db->u1.isInterrupted || db->suspended) && !db->unimpeded );\n  rc = db->mallocFailed ? SQLITE_NOMEM_BKPT : SQLITE_INTERRUPT;\n  p->rc = rc;\n  sqlite3VdbeError(p, \"%s\", sqlite3ErrStr(rc));\n  goto abort_due_to_error;\n}\n\n\n/************** End of vdbe.c ************************************************/\n/************** Begin file vdbeblob.c ****************************************/\n/*\n** 2007 May 1\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n**\n** This file contains code used to implement incremental BLOB I/O.\n*/\n\n/* #include \"sqliteInt.h\" */\n/* #include \"vdbeInt.h\" */\n\n#ifndef SQLITE_OMIT_INCRBLOB\n\n/*\n** Valid sqlite3_blob* handles point to Incrblob structures.\n*/\ntypedef struct Incrblob Incrblob;\nstruct Incrblob {\n  int nByte;              /* Size of open blob, in bytes */\n  int iOffset;            /* Byte offset of blob in cursor data */\n  u16 iCol;               /* Table column this handle is open on */\n  BtCursor *pCsr;         /* Cursor pointing at blob row */\n  sqlite3_stmt *pStmt;    /* Statement holding cursor open */\n  sqlite3 *db;            /* The associated database */\n  char *zDb;              /* Database name */\n  Table *pTab;            /* Table object */\n};\n\n\n/*\n** This function is used by both blob_open() and blob_reopen(). It seeks\n** the b-tree cursor associated with blob handle p to point to row iRow.\n** If successful, SQLITE_OK is returned and subsequent calls to\n** sqlite3_blob_read() or sqlite3_blob_write() access the specified row.\n**\n** If an error occurs, or if the specified row does not exist or does not\n** contain a value of type TEXT or BLOB in the column nominated when the\n** blob handle was opened, then an error code is returned and *pzErr may\n** be set to point to a buffer containing an error message. It is the\n** responsibility of the caller to free the error message buffer using\n** sqlite3DbFree().\n**\n** If an error does occur, then the b-tree cursor is closed. All subsequent\n** calls to sqlite3_blob_read(), blob_write() or blob_reopen() will \n** immediately return SQLITE_ABORT.\n*/\nstatic int blobSeekToRow(Incrblob *p, sqlite3_int64 iRow, char **pzErr){\n  int rc;                         /* Error code */\n  char *zErr = 0;                 /* Error message */\n  Vdbe *v = (Vdbe *)p->pStmt;\n\n  /* Set the value of register r[1] in the SQL statement to integer iRow. \n  ** This is done directly as a performance optimization\n  */\n  v->aMem[1].flags = MEM_Int;\n  v->aMem[1].u.i = iRow;\n\n  /* If the statement has been run before (and is paused at the OP_ResultRow)\n  ** then back it up to the point where it does the OP_NotExists.  This could\n  ** have been down with an extra OP_Goto, but simply setting the program\n  ** counter is faster. */\n  if( v->pc>4 ){\n    v->pc = 4;\n    assert( v->aOp[v->pc].opcode==OP_NotExists );\n    rc = sqlite3VdbeExec(v);\n  }else{\n    rc = sqlite3_step(p->pStmt);\n  }\n  if( rc==SQLITE_ROW ){\n    VdbeCursor *pC = v->apCsr[0];\n    u32 type = pC->nHdrParsed>p->iCol ? pC->aType[p->iCol] : 0;\n    testcase( pC->nHdrParsed==p->iCol );\n    testcase( pC->nHdrParsed==p->iCol+1 );\n    if( type<12 ){\n      zErr = sqlite3MPrintf(p->db, \"cannot open value of type %s\",\n          type==0?\"null\": type==7?\"real\": \"integer\"\n      );\n      rc = SQLITE_ERROR;\n      sqlite3_finalize(p->pStmt);\n      p->pStmt = 0;\n    }else{\n      p->iOffset = pC->aType[p->iCol + pC->nField];\n      p->nByte = sqlite3VdbeSerialTypeLen(type);\n      p->pCsr =  pC->uc.pCursor;\n      sqlite3BtreeIncrblobCursor(p->pCsr);\n    }\n  }\n\n  if( rc==SQLITE_ROW ){\n    rc = SQLITE_OK;\n  }else if( p->pStmt ){\n    rc = sqlite3_finalize(p->pStmt);\n    p->pStmt = 0;\n    if( rc==SQLITE_OK ){\n      zErr = sqlite3MPrintf(p->db, \"no such rowid: %lld\", iRow);\n      rc = SQLITE_ERROR;\n    }else{\n      zErr = sqlite3MPrintf(p->db, \"%s\", sqlite3_errmsg(p->db));\n    }\n  }\n\n  assert( rc!=SQLITE_OK || zErr==0 );\n  assert( rc!=SQLITE_ROW && rc!=SQLITE_DONE );\n\n  *pzErr = zErr;\n  return rc;\n}\n\n/*\n** Open a blob handle.\n*/\nSQLITE_API int sqlite3_blob_open(\n  sqlite3* db,            /* The database connection */\n  const char *zDb,        /* The attached database containing the blob */\n  const char *zTable,     /* The table containing the blob */\n  const char *zColumn,    /* The column containing the blob */\n  sqlite_int64 iRow,      /* The row containing the glob */\n  int wrFlag,             /* True -> read/write access, false -> read-only */\n  sqlite3_blob **ppBlob   /* Handle for accessing the blob returned here */\n){\n  int nAttempt = 0;\n  int iCol;               /* Index of zColumn in row-record */\n  int rc = SQLITE_OK;\n  char *zErr = 0;\n  Table *pTab;\n  Incrblob *pBlob = 0;\n  Parse sParse;\n\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( ppBlob==0 ){\n    return SQLITE_MISUSE_BKPT;\n  }\n#endif\n  *ppBlob = 0;\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( !sqlite3SafetyCheckOk(db) || zTable==0 ){\n    return SQLITE_MISUSE_BKPT;\n  }\n#endif\n  wrFlag = !!wrFlag;                /* wrFlag = (wrFlag ? 1 : 0); */\n\n  sqlite3_mutex_enter(db->mutex);\n\n  pBlob = (Incrblob *)sqlite3DbMallocZero(db, sizeof(Incrblob));\n  do {\n    memset(&sParse, 0, sizeof(Parse));\n    if( !pBlob ) goto blob_open_out;\n    sParse.db = db;\n    sqlite3DbFree(db, zErr);\n    zErr = 0;\n\n    sqlite3BtreeEnterAll(db);\n    pTab = sqlite3LocateTable(&sParse, 0, zTable, zDb);\n    if( pTab && IsVirtual(pTab) ){\n      pTab = 0;\n      sqlite3ErrorMsg(&sParse, \"cannot open virtual table: %s\", zTable);\n    }\n    if( pTab && !HasRowid(pTab) ){\n      pTab = 0;\n      sqlite3ErrorMsg(&sParse, \"cannot open table without rowid: %s\", zTable);\n    }\n#ifndef SQLITE_OMIT_VIEW\n    if( pTab && pTab->pSelect ){\n      pTab = 0;\n      sqlite3ErrorMsg(&sParse, \"cannot open view: %s\", zTable);\n    }\n#endif\n    if( !pTab ){\n      if( sParse.zErrMsg ){\n        sqlite3DbFree(db, zErr);\n        zErr = sParse.zErrMsg;\n        sParse.zErrMsg = 0;\n      }\n      rc = SQLITE_ERROR;\n      sqlite3BtreeLeaveAll(db);\n      goto blob_open_out;\n    }\n    pBlob->pTab = pTab;\n    pBlob->zDb = db->aDb[sqlite3SchemaToIndex(db, pTab->pSchema)].zDbSName;\n\n    /* Now search pTab for the exact column. */\n    for(iCol=0; iCol<pTab->nCol; iCol++) {\n      if( sqlite3StrICmp(pTab->aCol[iCol].zName, zColumn)==0 ){\n        break;\n      }\n    }\n    if( iCol==pTab->nCol ){\n      sqlite3DbFree(db, zErr);\n      zErr = sqlite3MPrintf(db, \"no such column: \\\"%s\\\"\", zColumn);\n      rc = SQLITE_ERROR;\n      sqlite3BtreeLeaveAll(db);\n      goto blob_open_out;\n    }\n\n    /* If the value is being opened for writing, check that the\n    ** column is not indexed, and that it is not part of a foreign key. \n    */\n    if( wrFlag ){\n      const char *zFault = 0;\n      Index *pIdx;\n#ifndef SQLITE_OMIT_FOREIGN_KEY\n      if( db->flags&SQLITE_ForeignKeys ){\n        /* Check that the column is not part of an FK child key definition. It\n        ** is not necessary to check if it is part of a parent key, as parent\n        ** key columns must be indexed. The check below will pick up this \n        ** case.  */\n        FKey *pFKey;\n        for(pFKey=pTab->pFKey; pFKey; pFKey=pFKey->pNextFrom){\n          int j;\n          for(j=0; j<pFKey->nCol; j++){\n            if( pFKey->aCol[j].iFrom==iCol ){\n              zFault = \"foreign key\";\n            }\n          }\n        }\n      }\n#endif\n      for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){\n        int j;\n        for(j=0; j<pIdx->nKeyCol; j++){\n          /* FIXME: Be smarter about indexes that use expressions */\n          if( pIdx->aiColumn[j]==iCol || pIdx->aiColumn[j]==XN_EXPR ){\n            zFault = \"indexed\";\n          }\n        }\n      }\n      if( zFault ){\n        sqlite3DbFree(db, zErr);\n        zErr = sqlite3MPrintf(db, \"cannot open %s column for writing\", zFault);\n        rc = SQLITE_ERROR;\n        sqlite3BtreeLeaveAll(db);\n        goto blob_open_out;\n      }\n    }\n\n    pBlob->pStmt = (sqlite3_stmt *)sqlite3VdbeCreate(&sParse);\n    assert( pBlob->pStmt || db->mallocFailed );\n    if( pBlob->pStmt ){\n      \n      /* This VDBE program seeks a btree cursor to the identified \n      ** db/table/row entry. The reason for using a vdbe program instead\n      ** of writing code to use the b-tree layer directly is that the\n      ** vdbe program will take advantage of the various transaction,\n      ** locking and error handling infrastructure built into the vdbe.\n      **\n      ** After seeking the cursor, the vdbe executes an OP_ResultRow.\n      ** Code external to the Vdbe then \"borrows\" the b-tree cursor and\n      ** uses it to implement the blob_read(), blob_write() and \n      ** blob_bytes() functions.\n      **\n      ** The sqlite3_blob_close() function finalizes the vdbe program,\n      ** which closes the b-tree cursor and (possibly) commits the \n      ** transaction.\n      */\n      static const int iLn = VDBE_OFFSET_LINENO(2);\n      static const VdbeOpList openBlob[] = {\n        {OP_TableLock,      0, 0, 0},  /* 0: Acquire a read or write lock */\n        {OP_OpenRead,       0, 0, 0},  /* 1: Open a cursor */\n        /* blobSeekToRow() will initialize r[1] to the desired rowid */\n        {OP_NotExists,      0, 5, 1},  /* 2: Seek the cursor to rowid=r[1] */\n        {OP_Column,         0, 0, 1},  /* 3  */\n        {OP_ResultRow,      1, 0, 0},  /* 4  */\n        {OP_Halt,           0, 0, 0},  /* 5  */\n      };\n      Vdbe *v = (Vdbe *)pBlob->pStmt;\n      int iDb = sqlite3SchemaToIndex(db, pTab->pSchema);\n      VdbeOp *aOp;\n\n      sqlite3VdbeAddOp4Int(v, OP_Transaction, iDb, wrFlag, \n                           pTab->pSchema->schema_cookie,\n                           pTab->pSchema->iGeneration);\n      sqlite3VdbeChangeP5(v, 1);\n      assert( sqlite3VdbeCurrentAddr(v)==2 || db->mallocFailed );\n      aOp = sqlite3VdbeAddOpList(v, ArraySize(openBlob), openBlob, iLn);\n\n      /* Make sure a mutex is held on the table to be accessed */\n      sqlite3VdbeUsesBtree(v, iDb); \n\n      if( db->mallocFailed==0 ){\n        assert( aOp!=0 );\n        /* Configure the OP_TableLock instruction */\n#ifdef SQLITE_OMIT_SHARED_CACHE\n        aOp[0].opcode = OP_Noop;\n#else\n        aOp[0].p1 = iDb;\n        aOp[0].p2 = pTab->tnum;\n        aOp[0].p3 = wrFlag;\n        sqlite3VdbeChangeP4(v, 2, pTab->zName, P4_TRANSIENT);\n      }\n      if( db->mallocFailed==0 ){\n#endif\n\n        /* Remove either the OP_OpenWrite or OpenRead. Set the P2 \n        ** parameter of the other to pTab->tnum.  */\n        if( wrFlag ) aOp[1].opcode = OP_OpenWrite;\n        aOp[1].p2 = pTab->tnum;\n        aOp[1].p3 = iDb;   \n\n        /* Configure the number of columns. Configure the cursor to\n        ** think that the table has one more column than it really\n        ** does. An OP_Column to retrieve this imaginary column will\n        ** always return an SQL NULL. This is useful because it means\n        ** we can invoke OP_Column to fill in the vdbe cursors type \n        ** and offset cache without causing any IO.\n        */\n        aOp[1].p4type = P4_INT32;\n        aOp[1].p4.i = pTab->nCol+1;\n        aOp[3].p2 = pTab->nCol;\n\n        sParse.nVar = 0;\n        sParse.nMem = 1;\n        sParse.nTab = 1;\n        sqlite3VdbeMakeReady(v, &sParse);\n      }\n    }\n   \n    pBlob->iCol = iCol;\n    pBlob->db = db;\n    sqlite3BtreeLeaveAll(db);\n    if( db->mallocFailed ){\n      goto blob_open_out;\n    }\n    rc = blobSeekToRow(pBlob, iRow, &zErr);\n  } while( (++nAttempt)<SQLITE_MAX_SCHEMA_RETRY && rc==SQLITE_SCHEMA );\n\nblob_open_out:\n  if( rc==SQLITE_OK && db->mallocFailed==0 ){\n    *ppBlob = (sqlite3_blob *)pBlob;\n  }else{\n    if( pBlob && pBlob->pStmt ) sqlite3VdbeFinalize((Vdbe *)pBlob->pStmt);\n    sqlite3DbFree(db, pBlob);\n  }\n  sqlite3ErrorWithMsg(db, rc, (zErr ? \"%s\" : 0), zErr);\n  sqlite3DbFree(db, zErr);\n  sqlite3ParserReset(&sParse);\n  rc = sqlite3ApiExit(db, rc);\n  sqlite3_mutex_leave(db->mutex);\n  return rc;\n}\n\n/*\n** Close a blob handle that was previously created using\n** sqlite3_blob_open().\n*/\nSQLITE_API int sqlite3_blob_close(sqlite3_blob *pBlob){\n  Incrblob *p = (Incrblob *)pBlob;\n  int rc;\n  sqlite3 *db;\n\n  if( p ){\n    db = p->db;\n    sqlite3_mutex_enter(db->mutex);\n    rc = sqlite3_finalize(p->pStmt);\n    sqlite3DbFree(db, p);\n    sqlite3_mutex_leave(db->mutex);\n  }else{\n    rc = SQLITE_OK;\n  }\n  return rc;\n}\n\n/*\n** Perform a read or write operation on a blob\n*/\nstatic int blobReadWrite(\n  sqlite3_blob *pBlob, \n  void *z, \n  int n, \n  int iOffset, \n  int (*xCall)(BtCursor*, u32, u32, void*)\n){\n  int rc;\n  Incrblob *p = (Incrblob *)pBlob;\n  Vdbe *v;\n  sqlite3 *db;\n\n  if( p==0 ) return SQLITE_MISUSE_BKPT;\n  db = p->db;\n  sqlite3_mutex_enter(db->mutex);\n  v = (Vdbe*)p->pStmt;\n\n  if( n<0 || iOffset<0 || ((sqlite3_int64)iOffset+n)>p->nByte ){\n    /* Request is out of range. Return a transient error. */\n    rc = SQLITE_ERROR;\n  }else if( v==0 ){\n    /* If there is no statement handle, then the blob-handle has\n    ** already been invalidated. Return SQLITE_ABORT in this case.\n    */\n    rc = SQLITE_ABORT;\n  }else{\n    /* Call either BtreeData() or BtreePutData(). If SQLITE_ABORT is\n    ** returned, clean-up the statement handle.\n    */\n    assert( db == v->db );\n    sqlite3BtreeEnterCursor(p->pCsr);\n\n#ifdef SQLITE_ENABLE_PREUPDATE_HOOK\n    if( xCall==sqlite3BtreePutData && db->xPreUpdateCallback ){\n      /* If a pre-update hook is registered and this is a write cursor, \n      ** invoke it here. \n      ** \n      ** TODO: The preupdate-hook is passed SQLITE_DELETE, even though this\n      ** operation should really be an SQLITE_UPDATE. This is probably\n      ** incorrect, but is convenient because at this point the new.* values \n      ** are not easily obtainable. And for the sessions module, an \n      ** SQLITE_UPDATE where the PK columns do not change is handled in the \n      ** same way as an SQLITE_DELETE (the SQLITE_DELETE code is actually\n      ** slightly more efficient). Since you cannot write to a PK column\n      ** using the incremental-blob API, this works. For the sessions module\n      ** anyhow.\n      */\n      sqlite3_int64 iKey;\n      iKey = sqlite3BtreeIntegerKey(p->pCsr);\n      sqlite3VdbePreUpdateHook(\n          v, v->apCsr[0], SQLITE_DELETE, p->zDb, p->pTab, iKey, -1\n      );\n    }\n#endif\n\n    rc = xCall(p->pCsr, iOffset+p->iOffset, n, z);\n    sqlite3BtreeLeaveCursor(p->pCsr);\n    if( rc==SQLITE_ABORT ){\n      sqlite3VdbeFinalize(v);\n      p->pStmt = 0;\n    }else{\n      v->rc = rc;\n    }\n  }\n  sqlite3Error(db, rc);\n  rc = sqlite3ApiExit(db, rc);\n  sqlite3_mutex_leave(db->mutex);\n  return rc;\n}\n\n/*\n** Read data from a blob handle.\n*/\nSQLITE_API int sqlite3_blob_read(sqlite3_blob *pBlob, void *z, int n, int iOffset){\n  return blobReadWrite(pBlob, z, n, iOffset, sqlite3BtreePayloadChecked);\n}\n\n/*\n** Write data to a blob handle.\n*/\nSQLITE_API int sqlite3_blob_write(sqlite3_blob *pBlob, const void *z, int n, int iOffset){\n  return blobReadWrite(pBlob, (void *)z, n, iOffset, sqlite3BtreePutData);\n}\n\n/*\n** Query a blob handle for the size of the data.\n**\n** The Incrblob.nByte field is fixed for the lifetime of the Incrblob\n** so no mutex is required for access.\n*/\nSQLITE_API int sqlite3_blob_bytes(sqlite3_blob *pBlob){\n  Incrblob *p = (Incrblob *)pBlob;\n  return (p && p->pStmt) ? p->nByte : 0;\n}\n\n/*\n** Move an existing blob handle to point to a different row of the same\n** database table.\n**\n** If an error occurs, or if the specified row does not exist or does not\n** contain a blob or text value, then an error code is returned and the\n** database handle error code and message set. If this happens, then all \n** subsequent calls to sqlite3_blob_xxx() functions (except blob_close()) \n** immediately return SQLITE_ABORT.\n*/\nSQLITE_API int sqlite3_blob_reopen(sqlite3_blob *pBlob, sqlite3_int64 iRow){\n  int rc;\n  Incrblob *p = (Incrblob *)pBlob;\n  sqlite3 *db;\n\n  if( p==0 ) return SQLITE_MISUSE_BKPT;\n  db = p->db;\n  sqlite3_mutex_enter(db->mutex);\n\n  if( p->pStmt==0 ){\n    /* If there is no statement handle, then the blob-handle has\n    ** already been invalidated. Return SQLITE_ABORT in this case.\n    */\n    rc = SQLITE_ABORT;\n  }else{\n    char *zErr;\n    rc = blobSeekToRow(p, iRow, &zErr);\n    if( rc!=SQLITE_OK ){\n      sqlite3ErrorWithMsg(db, rc, (zErr ? \"%s\" : 0), zErr);\n      sqlite3DbFree(db, zErr);\n    }\n    assert( rc!=SQLITE_SCHEMA );\n  }\n\n  rc = sqlite3ApiExit(db, rc);\n  assert( rc==SQLITE_OK || p->pStmt==0 );\n  sqlite3_mutex_leave(db->mutex);\n  return rc;\n}\n\n#endif /* #ifndef SQLITE_OMIT_INCRBLOB */\n\n/************** End of vdbeblob.c ********************************************/\n/************** Begin file vdbesort.c ****************************************/\n/*\n** 2011-07-09\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This file contains code for the VdbeSorter object, used in concert with\n** a VdbeCursor to sort large numbers of keys for CREATE INDEX statements\n** or by SELECT statements with ORDER BY clauses that cannot be satisfied\n** using indexes and without LIMIT clauses.\n**\n** The VdbeSorter object implements a multi-threaded external merge sort\n** algorithm that is efficient even if the number of elements being sorted\n** exceeds the available memory.\n**\n** Here is the (internal, non-API) interface between this module and the\n** rest of the SQLite system:\n**\n**    sqlite3VdbeSorterInit()       Create a new VdbeSorter object.\n**\n**    sqlite3VdbeSorterWrite()      Add a single new row to the VdbeSorter\n**                                  object.  The row is a binary blob in the\n**                                  OP_MakeRecord format that contains both\n**                                  the ORDER BY key columns and result columns\n**                                  in the case of a SELECT w/ ORDER BY, or\n**                                  the complete record for an index entry\n**                                  in the case of a CREATE INDEX.\n**\n**    sqlite3VdbeSorterRewind()     Sort all content previously added.\n**                                  Position the read cursor on the\n**                                  first sorted element.\n**\n**    sqlite3VdbeSorterNext()       Advance the read cursor to the next sorted\n**                                  element.\n**\n**    sqlite3VdbeSorterRowkey()     Return the complete binary blob for the\n**                                  row currently under the read cursor.\n**\n**    sqlite3VdbeSorterCompare()    Compare the binary blob for the row\n**                                  currently under the read cursor against\n**                                  another binary blob X and report if\n**                                  X is strictly less than the read cursor.\n**                                  Used to enforce uniqueness in a\n**                                  CREATE UNIQUE INDEX statement.\n**\n**    sqlite3VdbeSorterClose()      Close the VdbeSorter object and reclaim\n**                                  all resources.\n**\n**    sqlite3VdbeSorterReset()      Refurbish the VdbeSorter for reuse.  This\n**                                  is like Close() followed by Init() only\n**                                  much faster.\n**\n** The interfaces above must be called in a particular order.  Write() can \n** only occur in between Init()/Reset() and Rewind().  Next(), Rowkey(), and\n** Compare() can only occur in between Rewind() and Close()/Reset(). i.e.\n**\n**   Init()\n**   for each record: Write()\n**   Rewind()\n**     Rowkey()/Compare()\n**   Next() \n**   Close()\n**\n** Algorithm:\n**\n** Records passed to the sorter via calls to Write() are initially held \n** unsorted in main memory. Assuming the amount of memory used never exceeds\n** a threshold, when Rewind() is called the set of records is sorted using\n** an in-memory merge sort. In this case, no temporary files are required\n** and subsequent calls to Rowkey(), Next() and Compare() read records \n** directly from main memory.\n**\n** If the amount of space used to store records in main memory exceeds the\n** threshold, then the set of records currently in memory are sorted and\n** written to a temporary file in \"Packed Memory Array\" (PMA) format.\n** A PMA created at this point is known as a \"level-0 PMA\". Higher levels\n** of PMAs may be created by merging existing PMAs together - for example\n** merging two or more level-0 PMAs together creates a level-1 PMA.\n**\n** The threshold for the amount of main memory to use before flushing \n** records to a PMA is roughly the same as the limit configured for the\n** page-cache of the main database. Specifically, the threshold is set to \n** the value returned by \"PRAGMA main.page_size\" multipled by \n** that returned by \"PRAGMA main.cache_size\", in bytes.\n**\n** If the sorter is running in single-threaded mode, then all PMAs generated\n** are appended to a single temporary file. Or, if the sorter is running in\n** multi-threaded mode then up to (N+1) temporary files may be opened, where\n** N is the configured number of worker threads. In this case, instead of\n** sorting the records and writing the PMA to a temporary file itself, the\n** calling thread usually launches a worker thread to do so. Except, if\n** there are already N worker threads running, the main thread does the work\n** itself.\n**\n** The sorter is running in multi-threaded mode if (a) the library was built\n** with pre-processor symbol SQLITE_MAX_WORKER_THREADS set to a value greater\n** than zero, and (b) worker threads have been enabled at runtime by calling\n** \"PRAGMA threads=N\" with some value of N greater than 0.\n**\n** When Rewind() is called, any data remaining in memory is flushed to a \n** final PMA. So at this point the data is stored in some number of sorted\n** PMAs within temporary files on disk.\n**\n** If there are fewer than SORTER_MAX_MERGE_COUNT PMAs in total and the\n** sorter is running in single-threaded mode, then these PMAs are merged\n** incrementally as keys are retreived from the sorter by the VDBE.  The\n** MergeEngine object, described in further detail below, performs this\n** merge.\n**\n** Or, if running in multi-threaded mode, then a background thread is\n** launched to merge the existing PMAs. Once the background thread has\n** merged T bytes of data into a single sorted PMA, the main thread \n** begins reading keys from that PMA while the background thread proceeds\n** with merging the next T bytes of data. And so on.\n**\n** Parameter T is set to half the value of the memory threshold used \n** by Write() above to determine when to create a new PMA.\n**\n** If there are more than SORTER_MAX_MERGE_COUNT PMAs in total when \n** Rewind() is called, then a hierarchy of incremental-merges is used. \n** First, T bytes of data from the first SORTER_MAX_MERGE_COUNT PMAs on \n** disk are merged together. Then T bytes of data from the second set, and\n** so on, such that no operation ever merges more than SORTER_MAX_MERGE_COUNT\n** PMAs at a time. This done is to improve locality.\n**\n** If running in multi-threaded mode and there are more than\n** SORTER_MAX_MERGE_COUNT PMAs on disk when Rewind() is called, then more\n** than one background thread may be created. Specifically, there may be\n** one background thread for each temporary file on disk, and one background\n** thread to merge the output of each of the others to a single PMA for\n** the main thread to read from.\n*/\n/* #include \"sqliteInt.h\" */\n/* #include \"vdbeInt.h\" */\n\n/* \n** If SQLITE_DEBUG_SORTER_THREADS is defined, this module outputs various\n** messages to stderr that may be helpful in understanding the performance\n** characteristics of the sorter in multi-threaded mode.\n*/\n#if 0\n# define SQLITE_DEBUG_SORTER_THREADS 1\n#endif\n\n/*\n** Hard-coded maximum amount of data to accumulate in memory before flushing\n** to a level 0 PMA. The purpose of this limit is to prevent various integer\n** overflows. 512MiB.\n*/\n#define SQLITE_MAX_PMASZ    (1<<29)\n\n/*\n** Private objects used by the sorter\n*/\ntypedef struct MergeEngine MergeEngine;     /* Merge PMAs together */\ntypedef struct PmaReader PmaReader;         /* Incrementally read one PMA */\ntypedef struct PmaWriter PmaWriter;         /* Incrementally write one PMA */\ntypedef struct SorterRecord SorterRecord;   /* A record being sorted */\ntypedef struct SortSubtask SortSubtask;     /* A sub-task in the sort process */\ntypedef struct SorterFile SorterFile;       /* Temporary file object wrapper */\ntypedef struct SorterList SorterList;       /* In-memory list of records */\ntypedef struct IncrMerger IncrMerger;       /* Read & merge multiple PMAs */\n\n/*\n** A container for a temp file handle and the current amount of data \n** stored in the file.\n*/\nstruct SorterFile {\n  sqlite3_file *pFd;              /* File handle */\n  i64 iEof;                       /* Bytes of data stored in pFd */\n};\n\n/*\n** An in-memory list of objects to be sorted.\n**\n** If aMemory==0 then each object is allocated separately and the objects\n** are connected using SorterRecord.u.pNext.  If aMemory!=0 then all objects\n** are stored in the aMemory[] bulk memory, one right after the other, and\n** are connected using SorterRecord.u.iNext.\n*/\nstruct SorterList {\n  SorterRecord *pList;            /* Linked list of records */\n  u8 *aMemory;                    /* If non-NULL, bulk memory to hold pList */\n  int szPMA;                      /* Size of pList as PMA in bytes */\n};\n\n/*\n** The MergeEngine object is used to combine two or more smaller PMAs into\n** one big PMA using a merge operation.  Separate PMAs all need to be\n** combined into one big PMA in order to be able to step through the sorted\n** records in order.\n**\n** The aReadr[] array contains a PmaReader object for each of the PMAs being\n** merged.  An aReadr[] object either points to a valid key or else is at EOF.\n** (\"EOF\" means \"End Of File\".  When aReadr[] is at EOF there is no more data.)\n** For the purposes of the paragraphs below, we assume that the array is\n** actually N elements in size, where N is the smallest power of 2 greater\n** to or equal to the number of PMAs being merged. The extra aReadr[] elements\n** are treated as if they are empty (always at EOF).\n**\n** The aTree[] array is also N elements in size. The value of N is stored in\n** the MergeEngine.nTree variable.\n**\n** The final (N/2) elements of aTree[] contain the results of comparing\n** pairs of PMA keys together. Element i contains the result of \n** comparing aReadr[2*i-N] and aReadr[2*i-N+1]. Whichever key is smaller, the\n** aTree element is set to the index of it. \n**\n** For the purposes of this comparison, EOF is considered greater than any\n** other key value. If the keys are equal (only possible with two EOF\n** values), it doesn't matter which index is stored.\n**\n** The (N/4) elements of aTree[] that precede the final (N/2) described \n** above contains the index of the smallest of each block of 4 PmaReaders\n** And so on. So that aTree[1] contains the index of the PmaReader that \n** currently points to the smallest key value. aTree[0] is unused.\n**\n** Example:\n**\n**     aReadr[0] -> Banana\n**     aReadr[1] -> Feijoa\n**     aReadr[2] -> Elderberry\n**     aReadr[3] -> Currant\n**     aReadr[4] -> Grapefruit\n**     aReadr[5] -> Apple\n**     aReadr[6] -> Durian\n**     aReadr[7] -> EOF\n**\n**     aTree[] = { X, 5   0, 5    0, 3, 5, 6 }\n**\n** The current element is \"Apple\" (the value of the key indicated by \n** PmaReader 5). When the Next() operation is invoked, PmaReader 5 will\n** be advanced to the next key in its segment. Say the next key is\n** \"Eggplant\":\n**\n**     aReadr[5] -> Eggplant\n**\n** The contents of aTree[] are updated first by comparing the new PmaReader\n** 5 key to the current key of PmaReader 4 (still \"Grapefruit\"). The PmaReader\n** 5 value is still smaller, so aTree[6] is set to 5. And so on up the tree.\n** The value of PmaReader 6 - \"Durian\" - is now smaller than that of PmaReader\n** 5, so aTree[3] is set to 6. Key 0 is smaller than key 6 (Banana<Durian),\n** so the value written into element 1 of the array is 0. As follows:\n**\n**     aTree[] = { X, 0   0, 6    0, 3, 5, 6 }\n**\n** In other words, each time we advance to the next sorter element, log2(N)\n** key comparison operations are required, where N is the number of segments\n** being merged (rounded up to the next power of 2).\n*/\nstruct MergeEngine {\n  int nTree;                 /* Used size of aTree/aReadr (power of 2) */\n  SortSubtask *pTask;        /* Used by this thread only */\n  int *aTree;                /* Current state of incremental merge */\n  PmaReader *aReadr;         /* Array of PmaReaders to merge data from */\n};\n\n/*\n** This object represents a single thread of control in a sort operation.\n** Exactly VdbeSorter.nTask instances of this object are allocated\n** as part of each VdbeSorter object. Instances are never allocated any\n** other way. VdbeSorter.nTask is set to the number of worker threads allowed\n** (see SQLITE_CONFIG_WORKER_THREADS) plus one (the main thread).  Thus for\n** single-threaded operation, there is exactly one instance of this object\n** and for multi-threaded operation there are two or more instances.\n**\n** Essentially, this structure contains all those fields of the VdbeSorter\n** structure for which each thread requires a separate instance. For example,\n** each thread requries its own UnpackedRecord object to unpack records in\n** as part of comparison operations.\n**\n** Before a background thread is launched, variable bDone is set to 0. Then, \n** right before it exits, the thread itself sets bDone to 1. This is used for \n** two purposes:\n**\n**   1. When flushing the contents of memory to a level-0 PMA on disk, to\n**      attempt to select a SortSubtask for which there is not already an\n**      active background thread (since doing so causes the main thread\n**      to block until it finishes).\n**\n**   2. If SQLITE_DEBUG_SORTER_THREADS is defined, to determine if a call\n**      to sqlite3ThreadJoin() is likely to block. Cases that are likely to\n**      block provoke debugging output.\n**\n** In both cases, the effects of the main thread seeing (bDone==0) even\n** after the thread has finished are not dire. So we don't worry about\n** memory barriers and such here.\n*/\ntypedef int (*SorterCompare)(SortSubtask*,int*,const void*,int,const void*,int);\nstruct SortSubtask {\n  SQLiteThread *pThread;          /* Background thread, if any */\n  int bDone;                      /* Set if thread is finished but not joined */\n  VdbeSorter *pSorter;            /* Sorter that owns this sub-task */\n  UnpackedRecord *pUnpacked;      /* Space to unpack a record */\n  SorterList list;                /* List for thread to write to a PMA */\n  int nPMA;                       /* Number of PMAs currently in file */\n  SorterCompare xCompare;         /* Compare function to use */\n  SorterFile file;                /* Temp file for level-0 PMAs */\n  SorterFile file2;               /* Space for other PMAs */\n};\n\n\n/*\n** Main sorter structure. A single instance of this is allocated for each \n** sorter cursor created by the VDBE.\n**\n** mxKeysize:\n**   As records are added to the sorter by calls to sqlite3VdbeSorterWrite(),\n**   this variable is updated so as to be set to the size on disk of the\n**   largest record in the sorter.\n*/\nstruct VdbeSorter {\n  int mnPmaSize;                  /* Minimum PMA size, in bytes */\n  int mxPmaSize;                  /* Maximum PMA size, in bytes.  0==no limit */\n  int mxKeysize;                  /* Largest serialized key seen so far */\n  int pgsz;                       /* Main database page size */\n  PmaReader *pReader;             /* Readr data from here after Rewind() */\n  MergeEngine *pMerger;           /* Or here, if bUseThreads==0 */\n  sqlite3 *db;                    /* Database connection */\n  KeyInfo *pKeyInfo;              /* How to compare records */\n  UnpackedRecord *pUnpacked;      /* Used by VdbeSorterCompare() */\n  SorterList list;                /* List of in-memory records */\n  int iMemory;                    /* Offset of free space in list.aMemory */\n  int nMemory;                    /* Size of list.aMemory allocation in bytes */\n  u8 bUsePMA;                     /* True if one or more PMAs created */\n  u8 bUseThreads;                 /* True to use background threads */\n  u8 iPrev;                       /* Previous thread used to flush PMA */\n  u8 nTask;                       /* Size of aTask[] array */\n  u8 typeMask;\n  SortSubtask aTask[1];           /* One or more subtasks */\n};\n\n#define SORTER_TYPE_INTEGER 0x01\n#define SORTER_TYPE_TEXT    0x02\n\n/*\n** An instance of the following object is used to read records out of a\n** PMA, in sorted order.  The next key to be read is cached in nKey/aKey.\n** aKey might point into aMap or into aBuffer.  If neither of those locations\n** contain a contiguous representation of the key, then aAlloc is allocated\n** and the key is copied into aAlloc and aKey is made to poitn to aAlloc.\n**\n** pFd==0 at EOF.\n*/\nstruct PmaReader {\n  i64 iReadOff;               /* Current read offset */\n  i64 iEof;                   /* 1 byte past EOF for this PmaReader */\n  int nAlloc;                 /* Bytes of space at aAlloc */\n  int nKey;                   /* Number of bytes in key */\n  sqlite3_file *pFd;          /* File handle we are reading from */\n  u8 *aAlloc;                 /* Space for aKey if aBuffer and pMap wont work */\n  u8 *aKey;                   /* Pointer to current key */\n  u8 *aBuffer;                /* Current read buffer */\n  int nBuffer;                /* Size of read buffer in bytes */\n  u8 *aMap;                   /* Pointer to mapping of entire file */\n  IncrMerger *pIncr;          /* Incremental merger */\n};\n\n/*\n** Normally, a PmaReader object iterates through an existing PMA stored \n** within a temp file. However, if the PmaReader.pIncr variable points to\n** an object of the following type, it may be used to iterate/merge through\n** multiple PMAs simultaneously.\n**\n** There are two types of IncrMerger object - single (bUseThread==0) and \n** multi-threaded (bUseThread==1). \n**\n** A multi-threaded IncrMerger object uses two temporary files - aFile[0] \n** and aFile[1]. Neither file is allowed to grow to more than mxSz bytes in \n** size. When the IncrMerger is initialized, it reads enough data from \n** pMerger to populate aFile[0]. It then sets variables within the \n** corresponding PmaReader object to read from that file and kicks off \n** a background thread to populate aFile[1] with the next mxSz bytes of \n** sorted record data from pMerger. \n**\n** When the PmaReader reaches the end of aFile[0], it blocks until the\n** background thread has finished populating aFile[1]. It then exchanges\n** the contents of the aFile[0] and aFile[1] variables within this structure,\n** sets the PmaReader fields to read from the new aFile[0] and kicks off\n** another background thread to populate the new aFile[1]. And so on, until\n** the contents of pMerger are exhausted.\n**\n** A single-threaded IncrMerger does not open any temporary files of its\n** own. Instead, it has exclusive access to mxSz bytes of space beginning\n** at offset iStartOff of file pTask->file2. And instead of using a \n** background thread to prepare data for the PmaReader, with a single\n** threaded IncrMerger the allocate part of pTask->file2 is \"refilled\" with\n** keys from pMerger by the calling thread whenever the PmaReader runs out\n** of data.\n*/\nstruct IncrMerger {\n  SortSubtask *pTask;             /* Task that owns this merger */\n  MergeEngine *pMerger;           /* Merge engine thread reads data from */\n  i64 iStartOff;                  /* Offset to start writing file at */\n  int mxSz;                       /* Maximum bytes of data to store */\n  int bEof;                       /* Set to true when merge is finished */\n  int bUseThread;                 /* True to use a bg thread for this object */\n  SorterFile aFile[2];            /* aFile[0] for reading, [1] for writing */\n};\n\n/*\n** An instance of this object is used for writing a PMA.\n**\n** The PMA is written one record at a time.  Each record is of an arbitrary\n** size.  But I/O is more efficient if it occurs in page-sized blocks where\n** each block is aligned on a page boundary.  This object caches writes to\n** the PMA so that aligned, page-size blocks are written.\n*/\nstruct PmaWriter {\n  int eFWErr;                     /* Non-zero if in an error state */\n  u8 *aBuffer;                    /* Pointer to write buffer */\n  int nBuffer;                    /* Size of write buffer in bytes */\n  int iBufStart;                  /* First byte of buffer to write */\n  int iBufEnd;                    /* Last byte of buffer to write */\n  i64 iWriteOff;                  /* Offset of start of buffer in file */\n  sqlite3_file *pFd;              /* File handle to write to */\n};\n\n/*\n** This object is the header on a single record while that record is being\n** held in memory and prior to being written out as part of a PMA.\n**\n** How the linked list is connected depends on how memory is being managed\n** by this module. If using a separate allocation for each in-memory record\n** (VdbeSorter.list.aMemory==0), then the list is always connected using the\n** SorterRecord.u.pNext pointers.\n**\n** Or, if using the single large allocation method (VdbeSorter.list.aMemory!=0),\n** then while records are being accumulated the list is linked using the\n** SorterRecord.u.iNext offset. This is because the aMemory[] array may\n** be sqlite3Realloc()ed while records are being accumulated. Once the VM\n** has finished passing records to the sorter, or when the in-memory buffer\n** is full, the list is sorted. As part of the sorting process, it is\n** converted to use the SorterRecord.u.pNext pointers. See function\n** vdbeSorterSort() for details.\n*/\nstruct SorterRecord {\n  int nVal;                       /* Size of the record in bytes */\n  union {\n    SorterRecord *pNext;          /* Pointer to next record in list */\n    int iNext;                    /* Offset within aMemory of next record */\n  } u;\n  /* The data for the record immediately follows this header */\n};\n\n/* Return a pointer to the buffer containing the record data for SorterRecord\n** object p. Should be used as if:\n**\n**   void *SRVAL(SorterRecord *p) { return (void*)&p[1]; }\n*/\n#define SRVAL(p) ((void*)((SorterRecord*)(p) + 1))\n\n\n/* Maximum number of PMAs that a single MergeEngine can merge */\n#define SORTER_MAX_MERGE_COUNT 16\n\nstatic int vdbeIncrSwap(IncrMerger*);\nstatic void vdbeIncrFree(IncrMerger *);\n\n/*\n** Free all memory belonging to the PmaReader object passed as the\n** argument. All structure fields are set to zero before returning.\n*/\nstatic void vdbePmaReaderClear(PmaReader *pReadr){\n  sqlite3_free(pReadr->aAlloc);\n  sqlite3_free(pReadr->aBuffer);\n  if( pReadr->aMap ) sqlite3OsUnfetch(pReadr->pFd, 0, pReadr->aMap);\n  vdbeIncrFree(pReadr->pIncr);\n  memset(pReadr, 0, sizeof(PmaReader));\n}\n\n/*\n** Read the next nByte bytes of data from the PMA p.\n** If successful, set *ppOut to point to a buffer containing the data\n** and return SQLITE_OK. Otherwise, if an error occurs, return an SQLite\n** error code.\n**\n** The buffer returned in *ppOut is only valid until the\n** next call to this function.\n*/\nstatic int vdbePmaReadBlob(\n  PmaReader *p,                   /* PmaReader from which to take the blob */\n  int nByte,                      /* Bytes of data to read */\n  u8 **ppOut                      /* OUT: Pointer to buffer containing data */\n){\n  int iBuf;                       /* Offset within buffer to read from */\n  int nAvail;                     /* Bytes of data available in buffer */\n\n  if( p->aMap ){\n    *ppOut = &p->aMap[p->iReadOff];\n    p->iReadOff += nByte;\n    return SQLITE_OK;\n  }\n\n  assert( p->aBuffer );\n\n  /* If there is no more data to be read from the buffer, read the next \n  ** p->nBuffer bytes of data from the file into it. Or, if there are less\n  ** than p->nBuffer bytes remaining in the PMA, read all remaining data.  */\n  iBuf = p->iReadOff % p->nBuffer;\n  if( iBuf==0 ){\n    int nRead;                    /* Bytes to read from disk */\n    int rc;                       /* sqlite3OsRead() return code */\n\n    /* Determine how many bytes of data to read. */\n    if( (p->iEof - p->iReadOff) > (i64)p->nBuffer ){\n      nRead = p->nBuffer;\n    }else{\n      nRead = (int)(p->iEof - p->iReadOff);\n    }\n    assert( nRead>0 );\n\n    /* Readr data from the file. Return early if an error occurs. */\n    rc = sqlite3OsRead(p->pFd, p->aBuffer, nRead, p->iReadOff);\n    assert( rc!=SQLITE_IOERR_SHORT_READ );\n    if( rc!=SQLITE_OK ) return rc;\n  }\n  nAvail = p->nBuffer - iBuf; \n\n  if( nByte<=nAvail ){\n    /* The requested data is available in the in-memory buffer. In this\n    ** case there is no need to make a copy of the data, just return a \n    ** pointer into the buffer to the caller.  */\n    *ppOut = &p->aBuffer[iBuf];\n    p->iReadOff += nByte;\n  }else{\n    /* The requested data is not all available in the in-memory buffer.\n    ** In this case, allocate space at p->aAlloc[] to copy the requested\n    ** range into. Then return a copy of pointer p->aAlloc to the caller.  */\n    int nRem;                     /* Bytes remaining to copy */\n\n    /* Extend the p->aAlloc[] allocation if required. */\n    if( p->nAlloc<nByte ){\n      u8 *aNew;\n      int nNew = MAX(128, p->nAlloc*2);\n      while( nByte>nNew ) nNew = nNew*2;\n      aNew = sqlite3Realloc(p->aAlloc, nNew);\n      if( !aNew ) return SQLITE_NOMEM_BKPT;\n      p->nAlloc = nNew;\n      p->aAlloc = aNew;\n    }\n\n    /* Copy as much data as is available in the buffer into the start of\n    ** p->aAlloc[].  */\n    memcpy(p->aAlloc, &p->aBuffer[iBuf], nAvail);\n    p->iReadOff += nAvail;\n    nRem = nByte - nAvail;\n\n    /* The following loop copies up to p->nBuffer bytes per iteration into\n    ** the p->aAlloc[] buffer.  */\n    while( nRem>0 ){\n      int rc;                     /* vdbePmaReadBlob() return code */\n      int nCopy;                  /* Number of bytes to copy */\n      u8 *aNext;                  /* Pointer to buffer to copy data from */\n\n      nCopy = nRem;\n      if( nRem>p->nBuffer ) nCopy = p->nBuffer;\n      rc = vdbePmaReadBlob(p, nCopy, &aNext);\n      if( rc!=SQLITE_OK ) return rc;\n      assert( aNext!=p->aAlloc );\n      memcpy(&p->aAlloc[nByte - nRem], aNext, nCopy);\n      nRem -= nCopy;\n    }\n\n    *ppOut = p->aAlloc;\n  }\n\n  return SQLITE_OK;\n}\n\n/*\n** Read a varint from the stream of data accessed by p. Set *pnOut to\n** the value read.\n*/\nstatic int vdbePmaReadVarint(PmaReader *p, u64 *pnOut){\n  int iBuf;\n\n  if( p->aMap ){\n    p->iReadOff += sqlite3GetVarint(&p->aMap[p->iReadOff], pnOut);\n  }else{\n    iBuf = p->iReadOff % p->nBuffer;\n    if( iBuf && (p->nBuffer-iBuf)>=9 ){\n      p->iReadOff += sqlite3GetVarint(&p->aBuffer[iBuf], pnOut);\n    }else{\n      u8 aVarint[16], *a;\n      int i = 0, rc;\n      do{\n        rc = vdbePmaReadBlob(p, 1, &a);\n        if( rc ) return rc;\n        aVarint[(i++)&0xf] = a[0];\n      }while( (a[0]&0x80)!=0 );\n      sqlite3GetVarint(aVarint, pnOut);\n    }\n  }\n\n  return SQLITE_OK;\n}\n\n/*\n** Attempt to memory map file pFile. If successful, set *pp to point to the\n** new mapping and return SQLITE_OK. If the mapping is not attempted \n** (because the file is too large or the VFS layer is configured not to use\n** mmap), return SQLITE_OK and set *pp to NULL.\n**\n** Or, if an error occurs, return an SQLite error code. The final value of\n** *pp is undefined in this case.\n*/\nstatic int vdbeSorterMapFile(SortSubtask *pTask, SorterFile *pFile, u8 **pp){\n  int rc = SQLITE_OK;\n  if( pFile->iEof<=(i64)(pTask->pSorter->db->nMaxSorterMmap) ){\n    sqlite3_file *pFd = pFile->pFd;\n    if( pFd->pMethods->iVersion>=3 ){\n      rc = sqlite3OsFetch(pFd, 0, (int)pFile->iEof, (void**)pp);\n      testcase( rc!=SQLITE_OK );\n    }\n  }\n  return rc;\n}\n\n/*\n** Attach PmaReader pReadr to file pFile (if it is not already attached to\n** that file) and seek it to offset iOff within the file.  Return SQLITE_OK \n** if successful, or an SQLite error code if an error occurs.\n*/\nstatic int vdbePmaReaderSeek(\n  SortSubtask *pTask,             /* Task context */\n  PmaReader *pReadr,              /* Reader whose cursor is to be moved */\n  SorterFile *pFile,              /* Sorter file to read from */\n  i64 iOff                        /* Offset in pFile */\n){\n  int rc = SQLITE_OK;\n\n  assert( pReadr->pIncr==0 || pReadr->pIncr->bEof==0 );\n\n  if( sqlite3FaultSim(201) ) return SQLITE_IOERR_READ;\n  if( pReadr->aMap ){\n    sqlite3OsUnfetch(pReadr->pFd, 0, pReadr->aMap);\n    pReadr->aMap = 0;\n  }\n  pReadr->iReadOff = iOff;\n  pReadr->iEof = pFile->iEof;\n  pReadr->pFd = pFile->pFd;\n\n  rc = vdbeSorterMapFile(pTask, pFile, &pReadr->aMap);\n  if( rc==SQLITE_OK && pReadr->aMap==0 ){\n    int pgsz = pTask->pSorter->pgsz;\n    int iBuf = pReadr->iReadOff % pgsz;\n    if( pReadr->aBuffer==0 ){\n      pReadr->aBuffer = (u8*)sqlite3Malloc(pgsz);\n      if( pReadr->aBuffer==0 ) rc = SQLITE_NOMEM_BKPT;\n      pReadr->nBuffer = pgsz;\n    }\n    if( rc==SQLITE_OK && iBuf ){\n      int nRead = pgsz - iBuf;\n      if( (pReadr->iReadOff + nRead) > pReadr->iEof ){\n        nRead = (int)(pReadr->iEof - pReadr->iReadOff);\n      }\n      rc = sqlite3OsRead(\n          pReadr->pFd, &pReadr->aBuffer[iBuf], nRead, pReadr->iReadOff\n      );\n      testcase( rc!=SQLITE_OK );\n    }\n  }\n\n  return rc;\n}\n\n/*\n** Advance PmaReader pReadr to the next key in its PMA. Return SQLITE_OK if\n** no error occurs, or an SQLite error code if one does.\n*/\nstatic int vdbePmaReaderNext(PmaReader *pReadr){\n  int rc = SQLITE_OK;             /* Return Code */\n  u64 nRec = 0;                   /* Size of record in bytes */\n\n\n  if( pReadr->iReadOff>=pReadr->iEof ){\n    IncrMerger *pIncr = pReadr->pIncr;\n    int bEof = 1;\n    if( pIncr ){\n      rc = vdbeIncrSwap(pIncr);\n      if( rc==SQLITE_OK && pIncr->bEof==0 ){\n        rc = vdbePmaReaderSeek(\n            pIncr->pTask, pReadr, &pIncr->aFile[0], pIncr->iStartOff\n        );\n        bEof = 0;\n      }\n    }\n\n    if( bEof ){\n      /* This is an EOF condition */\n      vdbePmaReaderClear(pReadr);\n      testcase( rc!=SQLITE_OK );\n      return rc;\n    }\n  }\n\n  if( rc==SQLITE_OK ){\n    rc = vdbePmaReadVarint(pReadr, &nRec);\n  }\n  if( rc==SQLITE_OK ){\n    pReadr->nKey = (int)nRec;\n    rc = vdbePmaReadBlob(pReadr, (int)nRec, &pReadr->aKey);\n    testcase( rc!=SQLITE_OK );\n  }\n\n  return rc;\n}\n\n/*\n** Initialize PmaReader pReadr to scan through the PMA stored in file pFile\n** starting at offset iStart and ending at offset iEof-1. This function \n** leaves the PmaReader pointing to the first key in the PMA (or EOF if the \n** PMA is empty).\n**\n** If the pnByte parameter is NULL, then it is assumed that the file \n** contains a single PMA, and that that PMA omits the initial length varint.\n*/\nstatic int vdbePmaReaderInit(\n  SortSubtask *pTask,             /* Task context */\n  SorterFile *pFile,              /* Sorter file to read from */\n  i64 iStart,                     /* Start offset in pFile */\n  PmaReader *pReadr,              /* PmaReader to populate */\n  i64 *pnByte                     /* IN/OUT: Increment this value by PMA size */\n){\n  int rc;\n\n  assert( pFile->iEof>iStart );\n  assert( pReadr->aAlloc==0 && pReadr->nAlloc==0 );\n  assert( pReadr->aBuffer==0 );\n  assert( pReadr->aMap==0 );\n\n  rc = vdbePmaReaderSeek(pTask, pReadr, pFile, iStart);\n  if( rc==SQLITE_OK ){\n    u64 nByte = 0;                 /* Size of PMA in bytes */\n    rc = vdbePmaReadVarint(pReadr, &nByte);\n    pReadr->iEof = pReadr->iReadOff + nByte;\n    *pnByte += nByte;\n  }\n\n  if( rc==SQLITE_OK ){\n    rc = vdbePmaReaderNext(pReadr);\n  }\n  return rc;\n}\n\n/*\n** A version of vdbeSorterCompare() that assumes that it has already been\n** determined that the first field of key1 is equal to the first field of \n** key2.\n*/\nstatic int vdbeSorterCompareTail(\n  SortSubtask *pTask,             /* Subtask context (for pKeyInfo) */\n  int *pbKey2Cached,              /* True if pTask->pUnpacked is pKey2 */\n  const void *pKey1, int nKey1,   /* Left side of comparison */\n  const void *pKey2, int nKey2    /* Right side of comparison */\n){\n  UnpackedRecord *r2 = pTask->pUnpacked;\n  if( *pbKey2Cached==0 ){\n    sqlite3VdbeRecordUnpack(pTask->pSorter->pKeyInfo, nKey2, pKey2, r2);\n    *pbKey2Cached = 1;\n  }\n  return sqlite3VdbeRecordCompareWithSkip(nKey1, pKey1, r2, 1);\n}\n\n/*\n** Compare key1 (buffer pKey1, size nKey1 bytes) with key2 (buffer pKey2, \n** size nKey2 bytes). Use (pTask->pKeyInfo) for the collation sequences\n** used by the comparison. Return the result of the comparison.\n**\n** If IN/OUT parameter *pbKey2Cached is true when this function is called,\n** it is assumed that (pTask->pUnpacked) contains the unpacked version\n** of key2. If it is false, (pTask->pUnpacked) is populated with the unpacked\n** version of key2 and *pbKey2Cached set to true before returning.\n**\n** If an OOM error is encountered, (pTask->pUnpacked->error_rc) is set\n** to SQLITE_NOMEM.\n*/\nstatic int vdbeSorterCompare(\n  SortSubtask *pTask,             /* Subtask context (for pKeyInfo) */\n  int *pbKey2Cached,              /* True if pTask->pUnpacked is pKey2 */\n  const void *pKey1, int nKey1,   /* Left side of comparison */\n  const void *pKey2, int nKey2    /* Right side of comparison */\n){\n  UnpackedRecord *r2 = pTask->pUnpacked;\n  if( !*pbKey2Cached ){\n    sqlite3VdbeRecordUnpack(pTask->pSorter->pKeyInfo, nKey2, pKey2, r2);\n    *pbKey2Cached = 1;\n  }\n  return sqlite3VdbeRecordCompare(nKey1, pKey1, r2);\n}\n\n/*\n** A specially optimized version of vdbeSorterCompare() that assumes that\n** the first field of each key is a TEXT value and that the collation\n** sequence to compare them with is BINARY.\n*/\nstatic int vdbeSorterCompareText(\n  SortSubtask *pTask,             /* Subtask context (for pKeyInfo) */\n  int *pbKey2Cached,              /* True if pTask->pUnpacked is pKey2 */\n  const void *pKey1, int nKey1,   /* Left side of comparison */\n  const void *pKey2, int nKey2    /* Right side of comparison */\n){\n  const u8 * const p1 = (const u8 * const)pKey1;\n  const u8 * const p2 = (const u8 * const)pKey2;\n  const u8 * const v1 = &p1[ p1[0] ];   /* Pointer to value 1 */\n  const u8 * const v2 = &p2[ p2[0] ];   /* Pointer to value 2 */\n\n  int n1;\n  int n2;\n  int res;\n\n  getVarint32(&p1[1], n1);\n  getVarint32(&p2[1], n2);\n  res = memcmp(v1, v2, (MIN(n1, n2) - 13)/2);\n  if( res==0 ){\n    res = n1 - n2;\n  }\n\n  if( res==0 ){\n    if( pTask->pSorter->pKeyInfo->nKeyField>1 ){\n      res = vdbeSorterCompareTail(\n          pTask, pbKey2Cached, pKey1, nKey1, pKey2, nKey2\n      );\n    }\n  }else{\n    if( pTask->pSorter->pKeyInfo->aSortOrder[0] ){\n      res = res * -1;\n    }\n  }\n\n  return res;\n}\n\n/*\n** A specially optimized version of vdbeSorterCompare() that assumes that\n** the first field of each key is an INTEGER value.\n*/\nstatic int vdbeSorterCompareInt(\n  SortSubtask *pTask,             /* Subtask context (for pKeyInfo) */\n  int *pbKey2Cached,              /* True if pTask->pUnpacked is pKey2 */\n  const void *pKey1, int nKey1,   /* Left side of comparison */\n  const void *pKey2, int nKey2    /* Right side of comparison */\n){\n  const u8 * const p1 = (const u8 * const)pKey1;\n  const u8 * const p2 = (const u8 * const)pKey2;\n  const int s1 = p1[1];                 /* Left hand serial type */\n  const int s2 = p2[1];                 /* Right hand serial type */\n  const u8 * const v1 = &p1[ p1[0] ];   /* Pointer to value 1 */\n  const u8 * const v2 = &p2[ p2[0] ];   /* Pointer to value 2 */\n  int res;                              /* Return value */\n\n  assert( (s1>0 && s1<7) || s1==8 || s1==9 );\n  assert( (s2>0 && s2<7) || s2==8 || s2==9 );\n\n  if( s1==s2 ){\n    /* The two values have the same sign. Compare using memcmp(). */\n    static const u8 aLen[] = {0, 1, 2, 3, 4, 6, 8, 0, 0, 0 };\n    const u8 n = aLen[s1];\n    int i;\n    res = 0;\n    for(i=0; i<n; i++){\n      if( (res = v1[i] - v2[i])!=0 ){\n        if( ((v1[0] ^ v2[0]) & 0x80)!=0 ){\n          res = v1[0] & 0x80 ? -1 : +1;\n        }\n        break;\n      }\n    }\n  }else if( s1>7 && s2>7 ){\n    res = s1 - s2;\n  }else{\n    if( s2>7 ){\n      res = +1;\n    }else if( s1>7 ){\n      res = -1;\n    }else{\n      res = s1 - s2;\n    }\n    assert( res!=0 );\n\n    if( res>0 ){\n      if( *v1 & 0x80 ) res = -1;\n    }else{\n      if( *v2 & 0x80 ) res = +1;\n    }\n  }\n\n  if( res==0 ){\n    if( pTask->pSorter->pKeyInfo->nKeyField>1 ){\n      res = vdbeSorterCompareTail(\n          pTask, pbKey2Cached, pKey1, nKey1, pKey2, nKey2\n      );\n    }\n  }else if( pTask->pSorter->pKeyInfo->aSortOrder[0] ){\n    res = res * -1;\n  }\n\n  return res;\n}\n\n/*\n** Initialize the temporary index cursor just opened as a sorter cursor.\n**\n** Usually, the sorter module uses the value of (pCsr->pKeyInfo->nKeyField)\n** to determine the number of fields that should be compared from the\n** records being sorted. However, if the value passed as argument nField\n** is non-zero and the sorter is able to guarantee a stable sort, nField\n** is used instead. This is used when sorting records for a CREATE INDEX\n** statement. In this case, keys are always delivered to the sorter in\n** order of the primary key, which happens to be make up the final part \n** of the records being sorted. So if the sort is stable, there is never\n** any reason to compare PK fields and they can be ignored for a small\n** performance boost.\n**\n** The sorter can guarantee a stable sort when running in single-threaded\n** mode, but not in multi-threaded mode.\n**\n** SQLITE_OK is returned if successful, or an SQLite error code otherwise.\n*/\nSQLITE_PRIVATE int sqlite3VdbeSorterInit(\n  sqlite3 *db,                    /* Database connection (for malloc()) */\n  int nField,                     /* Number of key fields in each record */\n  VdbeCursor *pCsr                /* Cursor that holds the new sorter */\n){\n  int pgsz;                       /* Page size of main database */\n  int i;                          /* Used to iterate through aTask[] */\n  VdbeSorter *pSorter;            /* The new sorter */\n  KeyInfo *pKeyInfo;              /* Copy of pCsr->pKeyInfo with db==0 */\n  int szKeyInfo;                  /* Size of pCsr->pKeyInfo in bytes */\n  int sz;                         /* Size of pSorter in bytes */\n  int rc = SQLITE_OK;\n#if SQLITE_MAX_WORKER_THREADS==0\n# define nWorker 0\n#else\n  int nWorker;\n#endif\n\n  /* Initialize the upper limit on the number of worker threads */\n#if SQLITE_MAX_WORKER_THREADS>0\n  if( sqlite3TempInMemory(db) || sqlite3GlobalConfig.bCoreMutex==0 ){\n    nWorker = 0;\n  }else{\n    nWorker = db->aLimit[SQLITE_LIMIT_WORKER_THREADS];\n  }\n#endif\n\n  /* Do not allow the total number of threads (main thread + all workers)\n  ** to exceed the maximum merge count */\n#if SQLITE_MAX_WORKER_THREADS>=SORTER_MAX_MERGE_COUNT\n  if( nWorker>=SORTER_MAX_MERGE_COUNT ){\n    nWorker = SORTER_MAX_MERGE_COUNT-1;\n  }\n#endif\n\n  assert( pCsr->pKeyInfo && pCsr->pBtx==0 );\n  assert( pCsr->eCurType==CURTYPE_SORTER );\n  szKeyInfo = sizeof(KeyInfo) + (pCsr->pKeyInfo->nKeyField-1)*sizeof(CollSeq*);\n  sz = sizeof(VdbeSorter) + nWorker * sizeof(SortSubtask);\n\n  pSorter = (VdbeSorter*)sqlite3DbMallocZero(db, sz + szKeyInfo);\n  pCsr->uc.pSorter = pSorter;\n  if( pSorter==0 ){\n    rc = SQLITE_NOMEM_BKPT;\n  }else{\n    pSorter->pKeyInfo = pKeyInfo = (KeyInfo*)((u8*)pSorter + sz);\n    memcpy(pKeyInfo, pCsr->pKeyInfo, szKeyInfo);\n    pKeyInfo->db = 0;\n    if( nField && nWorker==0 ){\n      pKeyInfo->nKeyField = nField;\n    }\n    pSorter->pgsz = pgsz = sqlite3BtreeGetPageSize(db->aDb[0].pBt);\n    pSorter->nTask = nWorker + 1;\n    pSorter->iPrev = (u8)(nWorker - 1);\n    pSorter->bUseThreads = (pSorter->nTask>1);\n    pSorter->db = db;\n    for(i=0; i<pSorter->nTask; i++){\n      SortSubtask *pTask = &pSorter->aTask[i];\n      pTask->pSorter = pSorter;\n    }\n\n    if( !sqlite3TempInMemory(db) ){\n      i64 mxCache;                /* Cache size in bytes*/\n      u32 szPma = sqlite3GlobalConfig.szPma;\n      pSorter->mnPmaSize = szPma * pgsz;\n\n      mxCache = db->aDb[0].pSchema->cache_size;\n      if( mxCache<0 ){\n        /* A negative cache-size value C indicates that the cache is abs(C)\n        ** KiB in size.  */\n        mxCache = mxCache * -1024;\n      }else{\n        mxCache = mxCache * pgsz;\n      }\n      mxCache = MIN(mxCache, SQLITE_MAX_PMASZ);\n      pSorter->mxPmaSize = MAX(pSorter->mnPmaSize, (int)mxCache);\n\n      /* Avoid large memory allocations if the application has requested\n      ** SQLITE_CONFIG_SMALL_MALLOC. */\n      if( sqlite3GlobalConfig.bSmallMalloc==0 ){\n        assert( pSorter->iMemory==0 );\n        pSorter->nMemory = pgsz;\n        pSorter->list.aMemory = (u8*)sqlite3Malloc(pgsz);\n        if( !pSorter->list.aMemory ) rc = SQLITE_NOMEM_BKPT;\n      }\n    }\n\n    if( pKeyInfo->nAllField<13 \n     && (pKeyInfo->aColl[0]==0 || pKeyInfo->aColl[0]==db->pDfltColl)\n    ){\n      pSorter->typeMask = SORTER_TYPE_INTEGER | SORTER_TYPE_TEXT;\n    }\n  }\n\n  return rc;\n}\n#undef nWorker   /* Defined at the top of this function */\n\n/*\n** Free the list of sorted records starting at pRecord.\n*/\nstatic void vdbeSorterRecordFree(sqlite3 *db, SorterRecord *pRecord){\n  SorterRecord *p;\n  SorterRecord *pNext;\n  for(p=pRecord; p; p=pNext){\n    pNext = p->u.pNext;\n    sqlite3DbFree(db, p);\n  }\n}\n\n/*\n** Free all resources owned by the object indicated by argument pTask. All \n** fields of *pTask are zeroed before returning.\n*/\nstatic void vdbeSortSubtaskCleanup(sqlite3 *db, SortSubtask *pTask){\n  sqlite3DbFree(db, pTask->pUnpacked);\n#if SQLITE_MAX_WORKER_THREADS>0\n  /* pTask->list.aMemory can only be non-zero if it was handed memory\n  ** from the main thread.  That only occurs SQLITE_MAX_WORKER_THREADS>0 */\n  if( pTask->list.aMemory ){\n    sqlite3_free(pTask->list.aMemory);\n  }else\n#endif\n  {\n    assert( pTask->list.aMemory==0 );\n    vdbeSorterRecordFree(0, pTask->list.pList);\n  }\n  if( pTask->file.pFd ){\n    sqlite3OsCloseFree(pTask->file.pFd);\n  }\n  if( pTask->file2.pFd ){\n    sqlite3OsCloseFree(pTask->file2.pFd);\n  }\n  memset(pTask, 0, sizeof(SortSubtask));\n}\n\n#ifdef SQLITE_DEBUG_SORTER_THREADS\nstatic void vdbeSorterWorkDebug(SortSubtask *pTask, const char *zEvent){\n  i64 t;\n  int iTask = (pTask - pTask->pSorter->aTask);\n  sqlite3OsCurrentTimeInt64(pTask->pSorter->db->pVfs, &t);\n  fprintf(stderr, \"%lld:%d %s\\n\", t, iTask, zEvent);\n}\nstatic void vdbeSorterRewindDebug(const char *zEvent){\n  i64 t;\n  sqlite3OsCurrentTimeInt64(sqlite3_vfs_find(0), &t);\n  fprintf(stderr, \"%lld:X %s\\n\", t, zEvent);\n}\nstatic void vdbeSorterPopulateDebug(\n  SortSubtask *pTask,\n  const char *zEvent\n){\n  i64 t;\n  int iTask = (pTask - pTask->pSorter->aTask);\n  sqlite3OsCurrentTimeInt64(pTask->pSorter->db->pVfs, &t);\n  fprintf(stderr, \"%lld:bg%d %s\\n\", t, iTask, zEvent);\n}\nstatic void vdbeSorterBlockDebug(\n  SortSubtask *pTask,\n  int bBlocked,\n  const char *zEvent\n){\n  if( bBlocked ){\n    i64 t;\n    sqlite3OsCurrentTimeInt64(pTask->pSorter->db->pVfs, &t);\n    fprintf(stderr, \"%lld:main %s\\n\", t, zEvent);\n  }\n}\n#else\n# define vdbeSorterWorkDebug(x,y)\n# define vdbeSorterRewindDebug(y)\n# define vdbeSorterPopulateDebug(x,y)\n# define vdbeSorterBlockDebug(x,y,z)\n#endif\n\n#if SQLITE_MAX_WORKER_THREADS>0\n/*\n** Join thread pTask->thread.\n*/\nstatic int vdbeSorterJoinThread(SortSubtask *pTask){\n  int rc = SQLITE_OK;\n  if( pTask->pThread ){\n#ifdef SQLITE_DEBUG_SORTER_THREADS\n    int bDone = pTask->bDone;\n#endif\n    void *pRet = SQLITE_INT_TO_PTR(SQLITE_ERROR);\n    vdbeSorterBlockDebug(pTask, !bDone, \"enter\");\n    (void)sqlite3ThreadJoin(pTask->pThread, &pRet);\n    vdbeSorterBlockDebug(pTask, !bDone, \"exit\");\n    rc = SQLITE_PTR_TO_INT(pRet);\n    assert( pTask->bDone==1 );\n    pTask->bDone = 0;\n    pTask->pThread = 0;\n  }\n  return rc;\n}\n\n/*\n** Launch a background thread to run xTask(pIn).\n*/\nstatic int vdbeSorterCreateThread(\n  SortSubtask *pTask,             /* Thread will use this task object */\n  void *(*xTask)(void*),          /* Routine to run in a separate thread */\n  void *pIn                       /* Argument passed into xTask() */\n){\n  assert( pTask->pThread==0 && pTask->bDone==0 );\n  return sqlite3ThreadCreate(&pTask->pThread, xTask, pIn);\n}\n\n/*\n** Join all outstanding threads launched by SorterWrite() to create \n** level-0 PMAs.\n*/\nstatic int vdbeSorterJoinAll(VdbeSorter *pSorter, int rcin){\n  int rc = rcin;\n  int i;\n\n  /* This function is always called by the main user thread.\n  **\n  ** If this function is being called after SorterRewind() has been called, \n  ** it is possible that thread pSorter->aTask[pSorter->nTask-1].pThread\n  ** is currently attempt to join one of the other threads. To avoid a race\n  ** condition where this thread also attempts to join the same object, join \n  ** thread pSorter->aTask[pSorter->nTask-1].pThread first. */\n  for(i=pSorter->nTask-1; i>=0; i--){\n    SortSubtask *pTask = &pSorter->aTask[i];\n    int rc2 = vdbeSorterJoinThread(pTask);\n    if( rc==SQLITE_OK ) rc = rc2;\n  }\n  return rc;\n}\n#else\n# define vdbeSorterJoinAll(x,rcin) (rcin)\n# define vdbeSorterJoinThread(pTask) SQLITE_OK\n#endif\n\n/*\n** Allocate a new MergeEngine object capable of handling up to\n** nReader PmaReader inputs.\n**\n** nReader is automatically rounded up to the next power of two.\n** nReader may not exceed SORTER_MAX_MERGE_COUNT even after rounding up.\n*/\nstatic MergeEngine *vdbeMergeEngineNew(int nReader){\n  int N = 2;                      /* Smallest power of two >= nReader */\n  int nByte;                      /* Total bytes of space to allocate */\n  MergeEngine *pNew;              /* Pointer to allocated object to return */\n\n  assert( nReader<=SORTER_MAX_MERGE_COUNT );\n\n  while( N<nReader ) N += N;\n  nByte = sizeof(MergeEngine) + N * (sizeof(int) + sizeof(PmaReader));\n\n  pNew = sqlite3FaultSim(100) ? 0 : (MergeEngine*)sqlite3MallocZero(nByte);\n  if( pNew ){\n    pNew->nTree = N;\n    pNew->pTask = 0;\n    pNew->aReadr = (PmaReader*)&pNew[1];\n    pNew->aTree = (int*)&pNew->aReadr[N];\n  }\n  return pNew;\n}\n\n/*\n** Free the MergeEngine object passed as the only argument.\n*/\nstatic void vdbeMergeEngineFree(MergeEngine *pMerger){\n  int i;\n  if( pMerger ){\n    for(i=0; i<pMerger->nTree; i++){\n      vdbePmaReaderClear(&pMerger->aReadr[i]);\n    }\n  }\n  sqlite3_free(pMerger);\n}\n\n/*\n** Free all resources associated with the IncrMerger object indicated by\n** the first argument.\n*/\nstatic void vdbeIncrFree(IncrMerger *pIncr){\n  if( pIncr ){\n#if SQLITE_MAX_WORKER_THREADS>0\n    if( pIncr->bUseThread ){\n      vdbeSorterJoinThread(pIncr->pTask);\n      if( pIncr->aFile[0].pFd ) sqlite3OsCloseFree(pIncr->aFile[0].pFd);\n      if( pIncr->aFile[1].pFd ) sqlite3OsCloseFree(pIncr->aFile[1].pFd);\n    }\n#endif\n    vdbeMergeEngineFree(pIncr->pMerger);\n    sqlite3_free(pIncr);\n  }\n}\n\n/*\n** Reset a sorting cursor back to its original empty state.\n*/\nSQLITE_PRIVATE void sqlite3VdbeSorterReset(sqlite3 *db, VdbeSorter *pSorter){\n  int i;\n  (void)vdbeSorterJoinAll(pSorter, SQLITE_OK);\n  assert( pSorter->bUseThreads || pSorter->pReader==0 );\n#if SQLITE_MAX_WORKER_THREADS>0\n  if( pSorter->pReader ){\n    vdbePmaReaderClear(pSorter->pReader);\n    sqlite3DbFree(db, pSorter->pReader);\n    pSorter->pReader = 0;\n  }\n#endif\n  vdbeMergeEngineFree(pSorter->pMerger);\n  pSorter->pMerger = 0;\n  for(i=0; i<pSorter->nTask; i++){\n    SortSubtask *pTask = &pSorter->aTask[i];\n    vdbeSortSubtaskCleanup(db, pTask);\n    pTask->pSorter = pSorter;\n  }\n  if( pSorter->list.aMemory==0 ){\n    vdbeSorterRecordFree(0, pSorter->list.pList);\n  }\n  pSorter->list.pList = 0;\n  pSorter->list.szPMA = 0;\n  pSorter->bUsePMA = 0;\n  pSorter->iMemory = 0;\n  pSorter->mxKeysize = 0;\n  sqlite3DbFree(db, pSorter->pUnpacked);\n  pSorter->pUnpacked = 0;\n}\n\n/*\n** Free any cursor components allocated by sqlite3VdbeSorterXXX routines.\n*/\nSQLITE_PRIVATE void sqlite3VdbeSorterClose(sqlite3 *db, VdbeCursor *pCsr){\n  VdbeSorter *pSorter;\n  assert( pCsr->eCurType==CURTYPE_SORTER );\n  pSorter = pCsr->uc.pSorter;\n  if( pSorter ){\n    sqlite3VdbeSorterReset(db, pSorter);\n    sqlite3_free(pSorter->list.aMemory);\n    sqlite3DbFree(db, pSorter);\n    pCsr->uc.pSorter = 0;\n  }\n}\n\n#if SQLITE_MAX_MMAP_SIZE>0\n/*\n** The first argument is a file-handle open on a temporary file. The file\n** is guaranteed to be nByte bytes or smaller in size. This function\n** attempts to extend the file to nByte bytes in size and to ensure that\n** the VFS has memory mapped it.\n**\n** Whether or not the file does end up memory mapped of course depends on\n** the specific VFS implementation.\n*/\nstatic void vdbeSorterExtendFile(sqlite3 *db, sqlite3_file *pFd, i64 nByte){\n  if( nByte<=(i64)(db->nMaxSorterMmap) && pFd->pMethods->iVersion>=3 ){\n    void *p = 0;\n    int chunksize = 4*1024;\n    sqlite3OsFileControlHint(pFd, SQLITE_FCNTL_CHUNK_SIZE, &chunksize);\n    sqlite3OsFileControlHint(pFd, SQLITE_FCNTL_SIZE_HINT, &nByte);\n    sqlite3OsFetch(pFd, 0, (int)nByte, &p);\n    sqlite3OsUnfetch(pFd, 0, p);\n  }\n}\n#else\n# define vdbeSorterExtendFile(x,y,z)\n#endif\n\n/*\n** Allocate space for a file-handle and open a temporary file. If successful,\n** set *ppFd to point to the malloc'd file-handle and return SQLITE_OK.\n** Otherwise, set *ppFd to 0 and return an SQLite error code.\n*/\nstatic int vdbeSorterOpenTempFile(\n  sqlite3 *db,                    /* Database handle doing sort */\n  i64 nExtend,                    /* Attempt to extend file to this size */\n  sqlite3_file **ppFd\n){\n  int rc;\n  if( sqlite3FaultSim(202) ) return SQLITE_IOERR_ACCESS;\n  rc = sqlite3OsOpenMalloc(db->pVfs, 0, ppFd,\n      SQLITE_OPEN_TEMP_JOURNAL |\n      SQLITE_OPEN_READWRITE    | SQLITE_OPEN_CREATE |\n      SQLITE_OPEN_EXCLUSIVE    | SQLITE_OPEN_DELETEONCLOSE, &rc\n  );\n  if( rc==SQLITE_OK ){\n    i64 max = SQLITE_MAX_MMAP_SIZE;\n    sqlite3OsFileControlHint(*ppFd, SQLITE_FCNTL_MMAP_SIZE, (void*)&max);\n    if( nExtend>0 ){\n      vdbeSorterExtendFile(db, *ppFd, nExtend);\n    }\n  }\n  return rc;\n}\n\n/*\n** If it has not already been allocated, allocate the UnpackedRecord \n** structure at pTask->pUnpacked. Return SQLITE_OK if successful (or \n** if no allocation was required), or SQLITE_NOMEM otherwise.\n*/\nstatic int vdbeSortAllocUnpacked(SortSubtask *pTask){\n  if( pTask->pUnpacked==0 ){\n    pTask->pUnpacked = sqlite3VdbeAllocUnpackedRecord(pTask->pSorter->pKeyInfo);\n    if( pTask->pUnpacked==0 ) return SQLITE_NOMEM_BKPT;\n    pTask->pUnpacked->nField = pTask->pSorter->pKeyInfo->nKeyField;\n    pTask->pUnpacked->errCode = 0;\n  }\n  return SQLITE_OK;\n}\n\n\n/*\n** Merge the two sorted lists p1 and p2 into a single list.\n*/\nstatic SorterRecord *vdbeSorterMerge(\n  SortSubtask *pTask,             /* Calling thread context */\n  SorterRecord *p1,               /* First list to merge */\n  SorterRecord *p2                /* Second list to merge */\n){\n  SorterRecord *pFinal = 0;\n  SorterRecord **pp = &pFinal;\n  int bCached = 0;\n\n  assert( p1!=0 && p2!=0 );\n  for(;;){\n    int res;\n    res = pTask->xCompare(\n        pTask, &bCached, SRVAL(p1), p1->nVal, SRVAL(p2), p2->nVal\n    );\n\n    if( res<=0 ){\n      *pp = p1;\n      pp = &p1->u.pNext;\n      p1 = p1->u.pNext;\n      if( p1==0 ){\n        *pp = p2;\n        break;\n      }\n    }else{\n      *pp = p2;\n      pp = &p2->u.pNext;\n      p2 = p2->u.pNext;\n      bCached = 0;\n      if( p2==0 ){\n        *pp = p1;\n        break;\n      }\n    }\n  }\n  return pFinal;\n}\n\n/*\n** Return the SorterCompare function to compare values collected by the\n** sorter object passed as the only argument.\n*/\nstatic SorterCompare vdbeSorterGetCompare(VdbeSorter *p){\n  if( p->typeMask==SORTER_TYPE_INTEGER ){\n    return vdbeSorterCompareInt;\n  }else if( p->typeMask==SORTER_TYPE_TEXT ){\n    return vdbeSorterCompareText; \n  }\n  return vdbeSorterCompare;\n}\n\n/*\n** Sort the linked list of records headed at pTask->pList. Return \n** SQLITE_OK if successful, or an SQLite error code (i.e. SQLITE_NOMEM) if \n** an error occurs.\n*/\nstatic int vdbeSorterSort(SortSubtask *pTask, SorterList *pList){\n  int i;\n  SorterRecord **aSlot;\n  SorterRecord *p;\n  int rc;\n\n  rc = vdbeSortAllocUnpacked(pTask);\n  if( rc!=SQLITE_OK ) return rc;\n\n  p = pList->pList;\n  pTask->xCompare = vdbeSorterGetCompare(pTask->pSorter);\n\n  aSlot = (SorterRecord **)sqlite3MallocZero(64 * sizeof(SorterRecord *));\n  if( !aSlot ){\n    return SQLITE_NOMEM_BKPT;\n  }\n\n  while( p ){\n    SorterRecord *pNext;\n    if( pList->aMemory ){\n      if( (u8*)p==pList->aMemory ){\n        pNext = 0;\n      }else{\n        assert( p->u.iNext<sqlite3MallocSize(pList->aMemory) );\n        pNext = (SorterRecord*)&pList->aMemory[p->u.iNext];\n      }\n    }else{\n      pNext = p->u.pNext;\n    }\n\n    p->u.pNext = 0;\n    for(i=0; aSlot[i]; i++){\n      p = vdbeSorterMerge(pTask, p, aSlot[i]);\n      aSlot[i] = 0;\n    }\n    aSlot[i] = p;\n    p = pNext;\n  }\n\n  p = 0;\n  for(i=0; i<64; i++){\n    if( aSlot[i]==0 ) continue;\n    p = p ? vdbeSorterMerge(pTask, p, aSlot[i]) : aSlot[i];\n  }\n  pList->pList = p;\n\n  sqlite3_free(aSlot);\n  assert( pTask->pUnpacked->errCode==SQLITE_OK \n       || pTask->pUnpacked->errCode==SQLITE_NOMEM \n  );\n  return pTask->pUnpacked->errCode;\n}\n\n/*\n** Initialize a PMA-writer object.\n*/\nstatic void vdbePmaWriterInit(\n  sqlite3_file *pFd,              /* File handle to write to */\n  PmaWriter *p,                   /* Object to populate */\n  int nBuf,                       /* Buffer size */\n  i64 iStart                      /* Offset of pFd to begin writing at */\n){\n  memset(p, 0, sizeof(PmaWriter));\n  p->aBuffer = (u8*)sqlite3Malloc(nBuf);\n  if( !p->aBuffer ){\n    p->eFWErr = SQLITE_NOMEM_BKPT;\n  }else{\n    p->iBufEnd = p->iBufStart = (iStart % nBuf);\n    p->iWriteOff = iStart - p->iBufStart;\n    p->nBuffer = nBuf;\n    p->pFd = pFd;\n  }\n}\n\n/*\n** Write nData bytes of data to the PMA. Return SQLITE_OK\n** if successful, or an SQLite error code if an error occurs.\n*/\nstatic void vdbePmaWriteBlob(PmaWriter *p, u8 *pData, int nData){\n  int nRem = nData;\n  while( nRem>0 && p->eFWErr==0 ){\n    int nCopy = nRem;\n    if( nCopy>(p->nBuffer - p->iBufEnd) ){\n      nCopy = p->nBuffer - p->iBufEnd;\n    }\n\n    memcpy(&p->aBuffer[p->iBufEnd], &pData[nData-nRem], nCopy);\n    p->iBufEnd += nCopy;\n    if( p->iBufEnd==p->nBuffer ){\n      p->eFWErr = sqlite3OsWrite(p->pFd, \n          &p->aBuffer[p->iBufStart], p->iBufEnd - p->iBufStart, \n          p->iWriteOff + p->iBufStart\n      );\n      p->iBufStart = p->iBufEnd = 0;\n      p->iWriteOff += p->nBuffer;\n    }\n    assert( p->iBufEnd<p->nBuffer );\n\n    nRem -= nCopy;\n  }\n}\n\n/*\n** Flush any buffered data to disk and clean up the PMA-writer object.\n** The results of using the PMA-writer after this call are undefined.\n** Return SQLITE_OK if flushing the buffered data succeeds or is not \n** required. Otherwise, return an SQLite error code.\n**\n** Before returning, set *piEof to the offset immediately following the\n** last byte written to the file.\n*/\nstatic int vdbePmaWriterFinish(PmaWriter *p, i64 *piEof){\n  int rc;\n  if( p->eFWErr==0 && ALWAYS(p->aBuffer) && p->iBufEnd>p->iBufStart ){\n    p->eFWErr = sqlite3OsWrite(p->pFd, \n        &p->aBuffer[p->iBufStart], p->iBufEnd - p->iBufStart, \n        p->iWriteOff + p->iBufStart\n    );\n  }\n  *piEof = (p->iWriteOff + p->iBufEnd);\n  sqlite3_free(p->aBuffer);\n  rc = p->eFWErr;\n  memset(p, 0, sizeof(PmaWriter));\n  return rc;\n}\n\n/*\n** Write value iVal encoded as a varint to the PMA. Return \n** SQLITE_OK if successful, or an SQLite error code if an error occurs.\n*/\nstatic void vdbePmaWriteVarint(PmaWriter *p, u64 iVal){\n  int nByte; \n  u8 aByte[10];\n  nByte = sqlite3PutVarint(aByte, iVal);\n  vdbePmaWriteBlob(p, aByte, nByte);\n}\n\n/*\n** Write the current contents of in-memory linked-list pList to a level-0\n** PMA in the temp file belonging to sub-task pTask. Return SQLITE_OK if \n** successful, or an SQLite error code otherwise.\n**\n** The format of a PMA is:\n**\n**     * A varint. This varint contains the total number of bytes of content\n**       in the PMA (not including the varint itself).\n**\n**     * One or more records packed end-to-end in order of ascending keys. \n**       Each record consists of a varint followed by a blob of data (the \n**       key). The varint is the number of bytes in the blob of data.\n*/\nstatic int vdbeSorterListToPMA(SortSubtask *pTask, SorterList *pList){\n  sqlite3 *db = pTask->pSorter->db;\n  int rc = SQLITE_OK;             /* Return code */\n  PmaWriter writer;               /* Object used to write to the file */\n\n#ifdef SQLITE_DEBUG\n  /* Set iSz to the expected size of file pTask->file after writing the PMA. \n  ** This is used by an assert() statement at the end of this function.  */\n  i64 iSz = pList->szPMA + sqlite3VarintLen(pList->szPMA) + pTask->file.iEof;\n#endif\n\n  vdbeSorterWorkDebug(pTask, \"enter\");\n  memset(&writer, 0, sizeof(PmaWriter));\n  assert( pList->szPMA>0 );\n\n  /* If the first temporary PMA file has not been opened, open it now. */\n  if( pTask->file.pFd==0 ){\n    rc = vdbeSorterOpenTempFile(db, 0, &pTask->file.pFd);\n    assert( rc!=SQLITE_OK || pTask->file.pFd );\n    assert( pTask->file.iEof==0 );\n    assert( pTask->nPMA==0 );\n  }\n\n  /* Try to get the file to memory map */\n  if( rc==SQLITE_OK ){\n    vdbeSorterExtendFile(db, pTask->file.pFd, pTask->file.iEof+pList->szPMA+9);\n  }\n\n  /* Sort the list */\n  if( rc==SQLITE_OK ){\n    rc = vdbeSorterSort(pTask, pList);\n  }\n\n  if( rc==SQLITE_OK ){\n    SorterRecord *p;\n    SorterRecord *pNext = 0;\n\n    vdbePmaWriterInit(pTask->file.pFd, &writer, pTask->pSorter->pgsz,\n                      pTask->file.iEof);\n    pTask->nPMA++;\n    vdbePmaWriteVarint(&writer, pList->szPMA);\n    for(p=pList->pList; p; p=pNext){\n      pNext = p->u.pNext;\n      vdbePmaWriteVarint(&writer, p->nVal);\n      vdbePmaWriteBlob(&writer, SRVAL(p), p->nVal);\n      if( pList->aMemory==0 ) sqlite3_free(p);\n    }\n    pList->pList = p;\n    rc = vdbePmaWriterFinish(&writer, &pTask->file.iEof);\n  }\n\n  vdbeSorterWorkDebug(pTask, \"exit\");\n  assert( rc!=SQLITE_OK || pList->pList==0 );\n  assert( rc!=SQLITE_OK || pTask->file.iEof==iSz );\n  return rc;\n}\n\n/*\n** Advance the MergeEngine to its next entry.\n** Set *pbEof to true there is no next entry because\n** the MergeEngine has reached the end of all its inputs.\n**\n** Return SQLITE_OK if successful or an error code if an error occurs.\n*/\nstatic int vdbeMergeEngineStep(\n  MergeEngine *pMerger,      /* The merge engine to advance to the next row */\n  int *pbEof                 /* Set TRUE at EOF.  Set false for more content */\n){\n  int rc;\n  int iPrev = pMerger->aTree[1];/* Index of PmaReader to advance */\n  SortSubtask *pTask = pMerger->pTask;\n\n  /* Advance the current PmaReader */\n  rc = vdbePmaReaderNext(&pMerger->aReadr[iPrev]);\n\n  /* Update contents of aTree[] */\n  if( rc==SQLITE_OK ){\n    int i;                      /* Index of aTree[] to recalculate */\n    PmaReader *pReadr1;         /* First PmaReader to compare */\n    PmaReader *pReadr2;         /* Second PmaReader to compare */\n    int bCached = 0;\n\n    /* Find the first two PmaReaders to compare. The one that was just\n    ** advanced (iPrev) and the one next to it in the array.  */\n    pReadr1 = &pMerger->aReadr[(iPrev & 0xFFFE)];\n    pReadr2 = &pMerger->aReadr[(iPrev | 0x0001)];\n\n    for(i=(pMerger->nTree+iPrev)/2; i>0; i=i/2){\n      /* Compare pReadr1 and pReadr2. Store the result in variable iRes. */\n      int iRes;\n      if( pReadr1->pFd==0 ){\n        iRes = +1;\n      }else if( pReadr2->pFd==0 ){\n        iRes = -1;\n      }else{\n        iRes = pTask->xCompare(pTask, &bCached,\n            pReadr1->aKey, pReadr1->nKey, pReadr2->aKey, pReadr2->nKey\n        );\n      }\n\n      /* If pReadr1 contained the smaller value, set aTree[i] to its index.\n      ** Then set pReadr2 to the next PmaReader to compare to pReadr1. In this\n      ** case there is no cache of pReadr2 in pTask->pUnpacked, so set\n      ** pKey2 to point to the record belonging to pReadr2.\n      **\n      ** Alternatively, if pReadr2 contains the smaller of the two values,\n      ** set aTree[i] to its index and update pReadr1. If vdbeSorterCompare()\n      ** was actually called above, then pTask->pUnpacked now contains\n      ** a value equivalent to pReadr2. So set pKey2 to NULL to prevent\n      ** vdbeSorterCompare() from decoding pReadr2 again.\n      **\n      ** If the two values were equal, then the value from the oldest\n      ** PMA should be considered smaller. The VdbeSorter.aReadr[] array\n      ** is sorted from oldest to newest, so pReadr1 contains older values\n      ** than pReadr2 iff (pReadr1<pReadr2).  */\n      if( iRes<0 || (iRes==0 && pReadr1<pReadr2) ){\n        pMerger->aTree[i] = (int)(pReadr1 - pMerger->aReadr);\n        pReadr2 = &pMerger->aReadr[ pMerger->aTree[i ^ 0x0001] ];\n        bCached = 0;\n      }else{\n        if( pReadr1->pFd ) bCached = 0;\n        pMerger->aTree[i] = (int)(pReadr2 - pMerger->aReadr);\n        pReadr1 = &pMerger->aReadr[ pMerger->aTree[i ^ 0x0001] ];\n      }\n    }\n    *pbEof = (pMerger->aReadr[pMerger->aTree[1]].pFd==0);\n  }\n\n  return (rc==SQLITE_OK ? pTask->pUnpacked->errCode : rc);\n}\n\n#if SQLITE_MAX_WORKER_THREADS>0\n/*\n** The main routine for background threads that write level-0 PMAs.\n*/\nstatic void *vdbeSorterFlushThread(void *pCtx){\n  SortSubtask *pTask = (SortSubtask*)pCtx;\n  int rc;                         /* Return code */\n  assert( pTask->bDone==0 );\n  rc = vdbeSorterListToPMA(pTask, &pTask->list);\n  pTask->bDone = 1;\n  return SQLITE_INT_TO_PTR(rc);\n}\n#endif /* SQLITE_MAX_WORKER_THREADS>0 */\n\n/*\n** Flush the current contents of VdbeSorter.list to a new PMA, possibly\n** using a background thread.\n*/\nstatic int vdbeSorterFlushPMA(VdbeSorter *pSorter){\n#if SQLITE_MAX_WORKER_THREADS==0\n  pSorter->bUsePMA = 1;\n  return vdbeSorterListToPMA(&pSorter->aTask[0], &pSorter->list);\n#else\n  int rc = SQLITE_OK;\n  int i;\n  SortSubtask *pTask = 0;    /* Thread context used to create new PMA */\n  int nWorker = (pSorter->nTask-1);\n\n  /* Set the flag to indicate that at least one PMA has been written. \n  ** Or will be, anyhow.  */\n  pSorter->bUsePMA = 1;\n\n  /* Select a sub-task to sort and flush the current list of in-memory\n  ** records to disk. If the sorter is running in multi-threaded mode,\n  ** round-robin between the first (pSorter->nTask-1) tasks. Except, if\n  ** the background thread from a sub-tasks previous turn is still running,\n  ** skip it. If the first (pSorter->nTask-1) sub-tasks are all still busy,\n  ** fall back to using the final sub-task. The first (pSorter->nTask-1)\n  ** sub-tasks are prefered as they use background threads - the final \n  ** sub-task uses the main thread. */\n  for(i=0; i<nWorker; i++){\n    int iTest = (pSorter->iPrev + i + 1) % nWorker;\n    pTask = &pSorter->aTask[iTest];\n    if( pTask->bDone ){\n      rc = vdbeSorterJoinThread(pTask);\n    }\n    if( rc!=SQLITE_OK || pTask->pThread==0 ) break;\n  }\n\n  if( rc==SQLITE_OK ){\n    if( i==nWorker ){\n      /* Use the foreground thread for this operation */\n      rc = vdbeSorterListToPMA(&pSorter->aTask[nWorker], &pSorter->list);\n    }else{\n      /* Launch a background thread for this operation */\n      u8 *aMem = pTask->list.aMemory;\n      void *pCtx = (void*)pTask;\n\n      assert( pTask->pThread==0 && pTask->bDone==0 );\n      assert( pTask->list.pList==0 );\n      assert( pTask->list.aMemory==0 || pSorter->list.aMemory!=0 );\n\n      pSorter->iPrev = (u8)(pTask - pSorter->aTask);\n      pTask->list = pSorter->list;\n      pSorter->list.pList = 0;\n      pSorter->list.szPMA = 0;\n      if( aMem ){\n        pSorter->list.aMemory = aMem;\n        pSorter->nMemory = sqlite3MallocSize(aMem);\n      }else if( pSorter->list.aMemory ){\n        pSorter->list.aMemory = sqlite3Malloc(pSorter->nMemory);\n        if( !pSorter->list.aMemory ) return SQLITE_NOMEM_BKPT;\n      }\n\n      rc = vdbeSorterCreateThread(pTask, vdbeSorterFlushThread, pCtx);\n    }\n  }\n\n  return rc;\n#endif /* SQLITE_MAX_WORKER_THREADS!=0 */\n}\n\n/*\n** Add a record to the sorter.\n*/\nSQLITE_PRIVATE int sqlite3VdbeSorterWrite(\n  const VdbeCursor *pCsr,         /* Sorter cursor */\n  Mem *pVal                       /* Memory cell containing record */\n){\n  VdbeSorter *pSorter;\n  int rc = SQLITE_OK;             /* Return Code */\n  SorterRecord *pNew;             /* New list element */\n  int bFlush;                     /* True to flush contents of memory to PMA */\n  int nReq;                       /* Bytes of memory required */\n  int nPMA;                       /* Bytes of PMA space required */\n  int t;                          /* serial type of first record field */\n\n  assert( pCsr->eCurType==CURTYPE_SORTER );\n  pSorter = pCsr->uc.pSorter;\n  getVarint32((const u8*)&pVal->z[1], t);\n  if( t>0 && t<10 && t!=7 ){\n    pSorter->typeMask &= SORTER_TYPE_INTEGER;\n  }else if( t>10 && (t & 0x01) ){\n    pSorter->typeMask &= SORTER_TYPE_TEXT;\n  }else{\n    pSorter->typeMask = 0;\n  }\n\n  assert( pSorter );\n\n  /* Figure out whether or not the current contents of memory should be\n  ** flushed to a PMA before continuing. If so, do so.\n  **\n  ** If using the single large allocation mode (pSorter->aMemory!=0), then\n  ** flush the contents of memory to a new PMA if (a) at least one value is\n  ** already in memory and (b) the new value will not fit in memory.\n  ** \n  ** Or, if using separate allocations for each record, flush the contents\n  ** of memory to a PMA if either of the following are true:\n  **\n  **   * The total memory allocated for the in-memory list is greater \n  **     than (page-size * cache-size), or\n  **\n  **   * The total memory allocated for the in-memory list is greater \n  **     than (page-size * 10) and sqlite3HeapNearlyFull() returns true.\n  */\n  nReq = pVal->n + sizeof(SorterRecord);\n  nPMA = pVal->n + sqlite3VarintLen(pVal->n);\n  if( pSorter->mxPmaSize ){\n    if( pSorter->list.aMemory ){\n      bFlush = pSorter->iMemory && (pSorter->iMemory+nReq) > pSorter->mxPmaSize;\n    }else{\n      bFlush = (\n          (pSorter->list.szPMA > pSorter->mxPmaSize)\n       || (pSorter->list.szPMA > pSorter->mnPmaSize && sqlite3HeapNearlyFull())\n      );\n    }\n    if( bFlush ){\n      rc = vdbeSorterFlushPMA(pSorter);\n      pSorter->list.szPMA = 0;\n      pSorter->iMemory = 0;\n      assert( rc!=SQLITE_OK || pSorter->list.pList==0 );\n    }\n  }\n\n  pSorter->list.szPMA += nPMA;\n  if( nPMA>pSorter->mxKeysize ){\n    pSorter->mxKeysize = nPMA;\n  }\n\n  if( pSorter->list.aMemory ){\n    int nMin = pSorter->iMemory + nReq;\n\n    if( nMin>pSorter->nMemory ){\n      u8 *aNew;\n      int iListOff = (u8*)pSorter->list.pList - pSorter->list.aMemory;\n      int nNew = pSorter->nMemory * 2;\n      while( nNew < nMin ) nNew = nNew*2;\n      if( nNew > pSorter->mxPmaSize ) nNew = pSorter->mxPmaSize;\n      if( nNew < nMin ) nNew = nMin;\n\n      aNew = sqlite3Realloc(pSorter->list.aMemory, nNew);\n      if( !aNew ) return SQLITE_NOMEM_BKPT;\n      pSorter->list.pList = (SorterRecord*)&aNew[iListOff];\n      pSorter->list.aMemory = aNew;\n      pSorter->nMemory = nNew;\n    }\n\n    pNew = (SorterRecord*)&pSorter->list.aMemory[pSorter->iMemory];\n    pSorter->iMemory += ROUND8(nReq);\n    if( pSorter->list.pList ){\n      pNew->u.iNext = (int)((u8*)(pSorter->list.pList) - pSorter->list.aMemory);\n    }\n  }else{\n    pNew = (SorterRecord *)sqlite3Malloc(nReq);\n    if( pNew==0 ){\n      return SQLITE_NOMEM_BKPT;\n    }\n    pNew->u.pNext = pSorter->list.pList;\n  }\n\n  memcpy(SRVAL(pNew), pVal->z, pVal->n);\n  pNew->nVal = pVal->n;\n  pSorter->list.pList = pNew;\n\n  return rc;\n}\n\n/*\n** Read keys from pIncr->pMerger and populate pIncr->aFile[1]. The format\n** of the data stored in aFile[1] is the same as that used by regular PMAs,\n** except that the number-of-bytes varint is omitted from the start.\n*/\nstatic int vdbeIncrPopulate(IncrMerger *pIncr){\n  int rc = SQLITE_OK;\n  int rc2;\n  i64 iStart = pIncr->iStartOff;\n  SorterFile *pOut = &pIncr->aFile[1];\n  SortSubtask *pTask = pIncr->pTask;\n  MergeEngine *pMerger = pIncr->pMerger;\n  PmaWriter writer;\n  assert( pIncr->bEof==0 );\n\n  vdbeSorterPopulateDebug(pTask, \"enter\");\n\n  vdbePmaWriterInit(pOut->pFd, &writer, pTask->pSorter->pgsz, iStart);\n  while( rc==SQLITE_OK ){\n    int dummy;\n    PmaReader *pReader = &pMerger->aReadr[ pMerger->aTree[1] ];\n    int nKey = pReader->nKey;\n    i64 iEof = writer.iWriteOff + writer.iBufEnd;\n\n    /* Check if the output file is full or if the input has been exhausted.\n    ** In either case exit the loop. */\n    if( pReader->pFd==0 ) break;\n    if( (iEof + nKey + sqlite3VarintLen(nKey))>(iStart + pIncr->mxSz) ) break;\n\n    /* Write the next key to the output. */\n    vdbePmaWriteVarint(&writer, nKey);\n    vdbePmaWriteBlob(&writer, pReader->aKey, nKey);\n    assert( pIncr->pMerger->pTask==pTask );\n    rc = vdbeMergeEngineStep(pIncr->pMerger, &dummy);\n  }\n\n  rc2 = vdbePmaWriterFinish(&writer, &pOut->iEof);\n  if( rc==SQLITE_OK ) rc = rc2;\n  vdbeSorterPopulateDebug(pTask, \"exit\");\n  return rc;\n}\n\n#if SQLITE_MAX_WORKER_THREADS>0\n/*\n** The main routine for background threads that populate aFile[1] of\n** multi-threaded IncrMerger objects.\n*/\nstatic void *vdbeIncrPopulateThread(void *pCtx){\n  IncrMerger *pIncr = (IncrMerger*)pCtx;\n  void *pRet = SQLITE_INT_TO_PTR( vdbeIncrPopulate(pIncr) );\n  pIncr->pTask->bDone = 1;\n  return pRet;\n}\n\n/*\n** Launch a background thread to populate aFile[1] of pIncr.\n*/\nstatic int vdbeIncrBgPopulate(IncrMerger *pIncr){\n  void *p = (void*)pIncr;\n  assert( pIncr->bUseThread );\n  return vdbeSorterCreateThread(pIncr->pTask, vdbeIncrPopulateThread, p);\n}\n#endif\n\n/*\n** This function is called when the PmaReader corresponding to pIncr has\n** finished reading the contents of aFile[0]. Its purpose is to \"refill\"\n** aFile[0] such that the PmaReader should start rereading it from the\n** beginning.\n**\n** For single-threaded objects, this is accomplished by literally reading \n** keys from pIncr->pMerger and repopulating aFile[0]. \n**\n** For multi-threaded objects, all that is required is to wait until the \n** background thread is finished (if it is not already) and then swap \n** aFile[0] and aFile[1] in place. If the contents of pMerger have not\n** been exhausted, this function also launches a new background thread\n** to populate the new aFile[1].\n**\n** SQLITE_OK is returned on success, or an SQLite error code otherwise.\n*/\nstatic int vdbeIncrSwap(IncrMerger *pIncr){\n  int rc = SQLITE_OK;\n\n#if SQLITE_MAX_WORKER_THREADS>0\n  if( pIncr->bUseThread ){\n    rc = vdbeSorterJoinThread(pIncr->pTask);\n\n    if( rc==SQLITE_OK ){\n      SorterFile f0 = pIncr->aFile[0];\n      pIncr->aFile[0] = pIncr->aFile[1];\n      pIncr->aFile[1] = f0;\n    }\n\n    if( rc==SQLITE_OK ){\n      if( pIncr->aFile[0].iEof==pIncr->iStartOff ){\n        pIncr->bEof = 1;\n      }else{\n        rc = vdbeIncrBgPopulate(pIncr);\n      }\n    }\n  }else\n#endif\n  {\n    rc = vdbeIncrPopulate(pIncr);\n    pIncr->aFile[0] = pIncr->aFile[1];\n    if( pIncr->aFile[0].iEof==pIncr->iStartOff ){\n      pIncr->bEof = 1;\n    }\n  }\n\n  return rc;\n}\n\n/*\n** Allocate and return a new IncrMerger object to read data from pMerger.\n**\n** If an OOM condition is encountered, return NULL. In this case free the\n** pMerger argument before returning.\n*/\nstatic int vdbeIncrMergerNew(\n  SortSubtask *pTask,     /* The thread that will be using the new IncrMerger */\n  MergeEngine *pMerger,   /* The MergeEngine that the IncrMerger will control */\n  IncrMerger **ppOut      /* Write the new IncrMerger here */\n){\n  int rc = SQLITE_OK;\n  IncrMerger *pIncr = *ppOut = (IncrMerger*)\n       (sqlite3FaultSim(100) ? 0 : sqlite3MallocZero(sizeof(*pIncr)));\n  if( pIncr ){\n    pIncr->pMerger = pMerger;\n    pIncr->pTask = pTask;\n    pIncr->mxSz = MAX(pTask->pSorter->mxKeysize+9,pTask->pSorter->mxPmaSize/2);\n    pTask->file2.iEof += pIncr->mxSz;\n  }else{\n    vdbeMergeEngineFree(pMerger);\n    rc = SQLITE_NOMEM_BKPT;\n  }\n  return rc;\n}\n\n#if SQLITE_MAX_WORKER_THREADS>0\n/*\n** Set the \"use-threads\" flag on object pIncr.\n*/\nstatic void vdbeIncrMergerSetThreads(IncrMerger *pIncr){\n  pIncr->bUseThread = 1;\n  pIncr->pTask->file2.iEof -= pIncr->mxSz;\n}\n#endif /* SQLITE_MAX_WORKER_THREADS>0 */\n\n\n\n/*\n** Recompute pMerger->aTree[iOut] by comparing the next keys on the\n** two PmaReaders that feed that entry.  Neither of the PmaReaders\n** are advanced.  This routine merely does the comparison.\n*/\nstatic void vdbeMergeEngineCompare(\n  MergeEngine *pMerger,  /* Merge engine containing PmaReaders to compare */\n  int iOut               /* Store the result in pMerger->aTree[iOut] */\n){\n  int i1;\n  int i2;\n  int iRes;\n  PmaReader *p1;\n  PmaReader *p2;\n\n  assert( iOut<pMerger->nTree && iOut>0 );\n\n  if( iOut>=(pMerger->nTree/2) ){\n    i1 = (iOut - pMerger->nTree/2) * 2;\n    i2 = i1 + 1;\n  }else{\n    i1 = pMerger->aTree[iOut*2];\n    i2 = pMerger->aTree[iOut*2+1];\n  }\n\n  p1 = &pMerger->aReadr[i1];\n  p2 = &pMerger->aReadr[i2];\n\n  if( p1->pFd==0 ){\n    iRes = i2;\n  }else if( p2->pFd==0 ){\n    iRes = i1;\n  }else{\n    SortSubtask *pTask = pMerger->pTask;\n    int bCached = 0;\n    int res;\n    assert( pTask->pUnpacked!=0 );  /* from vdbeSortSubtaskMain() */\n    res = pTask->xCompare(\n        pTask, &bCached, p1->aKey, p1->nKey, p2->aKey, p2->nKey\n    );\n    if( res<=0 ){\n      iRes = i1;\n    }else{\n      iRes = i2;\n    }\n  }\n\n  pMerger->aTree[iOut] = iRes;\n}\n\n/*\n** Allowed values for the eMode parameter to vdbeMergeEngineInit()\n** and vdbePmaReaderIncrMergeInit().\n**\n** Only INCRINIT_NORMAL is valid in single-threaded builds (when\n** SQLITE_MAX_WORKER_THREADS==0).  The other values are only used\n** when there exists one or more separate worker threads.\n*/\n#define INCRINIT_NORMAL 0\n#define INCRINIT_TASK   1\n#define INCRINIT_ROOT   2\n\n/* \n** Forward reference required as the vdbeIncrMergeInit() and\n** vdbePmaReaderIncrInit() routines are called mutually recursively when\n** building a merge tree.\n*/\nstatic int vdbePmaReaderIncrInit(PmaReader *pReadr, int eMode);\n\n/*\n** Initialize the MergeEngine object passed as the second argument. Once this\n** function returns, the first key of merged data may be read from the \n** MergeEngine object in the usual fashion.\n**\n** If argument eMode is INCRINIT_ROOT, then it is assumed that any IncrMerge\n** objects attached to the PmaReader objects that the merger reads from have\n** already been populated, but that they have not yet populated aFile[0] and\n** set the PmaReader objects up to read from it. In this case all that is\n** required is to call vdbePmaReaderNext() on each PmaReader to point it at\n** its first key.\n**\n** Otherwise, if eMode is any value other than INCRINIT_ROOT, then use \n** vdbePmaReaderIncrMergeInit() to initialize each PmaReader that feeds data \n** to pMerger.\n**\n** SQLITE_OK is returned if successful, or an SQLite error code otherwise.\n*/\nstatic int vdbeMergeEngineInit(\n  SortSubtask *pTask,             /* Thread that will run pMerger */\n  MergeEngine *pMerger,           /* MergeEngine to initialize */\n  int eMode                       /* One of the INCRINIT_XXX constants */\n){\n  int rc = SQLITE_OK;             /* Return code */\n  int i;                          /* For looping over PmaReader objects */\n  int nTree;                      /* Number of subtrees to merge */\n\n  /* Failure to allocate the merge would have been detected prior to\n  ** invoking this routine */\n  assert( pMerger!=0 );\n\n  /* eMode is always INCRINIT_NORMAL in single-threaded mode */\n  assert( SQLITE_MAX_WORKER_THREADS>0 || eMode==INCRINIT_NORMAL );\n\n  /* Verify that the MergeEngine is assigned to a single thread */\n  assert( pMerger->pTask==0 );\n  pMerger->pTask = pTask;\n\n  nTree = pMerger->nTree;\n  for(i=0; i<nTree; i++){\n    if( SQLITE_MAX_WORKER_THREADS>0 && eMode==INCRINIT_ROOT ){\n      /* PmaReaders should be normally initialized in order, as if they are\n      ** reading from the same temp file this makes for more linear file IO.\n      ** However, in the INCRINIT_ROOT case, if PmaReader aReadr[nTask-1] is\n      ** in use it will block the vdbePmaReaderNext() call while it uses\n      ** the main thread to fill its buffer. So calling PmaReaderNext()\n      ** on this PmaReader before any of the multi-threaded PmaReaders takes\n      ** better advantage of multi-processor hardware. */\n      rc = vdbePmaReaderNext(&pMerger->aReadr[nTree-i-1]);\n    }else{\n      rc = vdbePmaReaderIncrInit(&pMerger->aReadr[i], INCRINIT_NORMAL);\n    }\n    if( rc!=SQLITE_OK ) return rc;\n  }\n\n  for(i=pMerger->nTree-1; i>0; i--){\n    vdbeMergeEngineCompare(pMerger, i);\n  }\n  return pTask->pUnpacked->errCode;\n}\n\n/*\n** The PmaReader passed as the first argument is guaranteed to be an\n** incremental-reader (pReadr->pIncr!=0). This function serves to open\n** and/or initialize the temp file related fields of the IncrMerge\n** object at (pReadr->pIncr).\n**\n** If argument eMode is set to INCRINIT_NORMAL, then all PmaReaders\n** in the sub-tree headed by pReadr are also initialized. Data is then \n** loaded into the buffers belonging to pReadr and it is set to point to \n** the first key in its range.\n**\n** If argument eMode is set to INCRINIT_TASK, then pReadr is guaranteed\n** to be a multi-threaded PmaReader and this function is being called in a\n** background thread. In this case all PmaReaders in the sub-tree are \n** initialized as for INCRINIT_NORMAL and the aFile[1] buffer belonging to\n** pReadr is populated. However, pReadr itself is not set up to point\n** to its first key. A call to vdbePmaReaderNext() is still required to do\n** that. \n**\n** The reason this function does not call vdbePmaReaderNext() immediately \n** in the INCRINIT_TASK case is that vdbePmaReaderNext() assumes that it has\n** to block on thread (pTask->thread) before accessing aFile[1]. But, since\n** this entire function is being run by thread (pTask->thread), that will\n** lead to the current background thread attempting to join itself.\n**\n** Finally, if argument eMode is set to INCRINIT_ROOT, it may be assumed\n** that pReadr->pIncr is a multi-threaded IncrMerge objects, and that all\n** child-trees have already been initialized using IncrInit(INCRINIT_TASK).\n** In this case vdbePmaReaderNext() is called on all child PmaReaders and\n** the current PmaReader set to point to the first key in its range.\n**\n** SQLITE_OK is returned if successful, or an SQLite error code otherwise.\n*/\nstatic int vdbePmaReaderIncrMergeInit(PmaReader *pReadr, int eMode){\n  int rc = SQLITE_OK;\n  IncrMerger *pIncr = pReadr->pIncr;\n  SortSubtask *pTask = pIncr->pTask;\n  sqlite3 *db = pTask->pSorter->db;\n\n  /* eMode is always INCRINIT_NORMAL in single-threaded mode */\n  assert( SQLITE_MAX_WORKER_THREADS>0 || eMode==INCRINIT_NORMAL );\n\n  rc = vdbeMergeEngineInit(pTask, pIncr->pMerger, eMode);\n\n  /* Set up the required files for pIncr. A multi-theaded IncrMerge object\n  ** requires two temp files to itself, whereas a single-threaded object\n  ** only requires a region of pTask->file2. */\n  if( rc==SQLITE_OK ){\n    int mxSz = pIncr->mxSz;\n#if SQLITE_MAX_WORKER_THREADS>0\n    if( pIncr->bUseThread ){\n      rc = vdbeSorterOpenTempFile(db, mxSz, &pIncr->aFile[0].pFd);\n      if( rc==SQLITE_OK ){\n        rc = vdbeSorterOpenTempFile(db, mxSz, &pIncr->aFile[1].pFd);\n      }\n    }else\n#endif\n    /*if( !pIncr->bUseThread )*/{\n      if( pTask->file2.pFd==0 ){\n        assert( pTask->file2.iEof>0 );\n        rc = vdbeSorterOpenTempFile(db, pTask->file2.iEof, &pTask->file2.pFd);\n        pTask->file2.iEof = 0;\n      }\n      if( rc==SQLITE_OK ){\n        pIncr->aFile[1].pFd = pTask->file2.pFd;\n        pIncr->iStartOff = pTask->file2.iEof;\n        pTask->file2.iEof += mxSz;\n      }\n    }\n  }\n\n#if SQLITE_MAX_WORKER_THREADS>0\n  if( rc==SQLITE_OK && pIncr->bUseThread ){\n    /* Use the current thread to populate aFile[1], even though this\n    ** PmaReader is multi-threaded. If this is an INCRINIT_TASK object,\n    ** then this function is already running in background thread \n    ** pIncr->pTask->thread. \n    **\n    ** If this is the INCRINIT_ROOT object, then it is running in the \n    ** main VDBE thread. But that is Ok, as that thread cannot return\n    ** control to the VDBE or proceed with anything useful until the \n    ** first results are ready from this merger object anyway.\n    */\n    assert( eMode==INCRINIT_ROOT || eMode==INCRINIT_TASK );\n    rc = vdbeIncrPopulate(pIncr);\n  }\n#endif\n\n  if( rc==SQLITE_OK && (SQLITE_MAX_WORKER_THREADS==0 || eMode!=INCRINIT_TASK) ){\n    rc = vdbePmaReaderNext(pReadr);\n  }\n\n  return rc;\n}\n\n#if SQLITE_MAX_WORKER_THREADS>0\n/*\n** The main routine for vdbePmaReaderIncrMergeInit() operations run in \n** background threads.\n*/\nstatic void *vdbePmaReaderBgIncrInit(void *pCtx){\n  PmaReader *pReader = (PmaReader*)pCtx;\n  void *pRet = SQLITE_INT_TO_PTR(\n                  vdbePmaReaderIncrMergeInit(pReader,INCRINIT_TASK)\n               );\n  pReader->pIncr->pTask->bDone = 1;\n  return pRet;\n}\n#endif\n\n/*\n** If the PmaReader passed as the first argument is not an incremental-reader\n** (if pReadr->pIncr==0), then this function is a no-op. Otherwise, it invokes\n** the vdbePmaReaderIncrMergeInit() function with the parameters passed to\n** this routine to initialize the incremental merge.\n** \n** If the IncrMerger object is multi-threaded (IncrMerger.bUseThread==1), \n** then a background thread is launched to call vdbePmaReaderIncrMergeInit().\n** Or, if the IncrMerger is single threaded, the same function is called\n** using the current thread.\n*/\nstatic int vdbePmaReaderIncrInit(PmaReader *pReadr, int eMode){\n  IncrMerger *pIncr = pReadr->pIncr;   /* Incremental merger */\n  int rc = SQLITE_OK;                  /* Return code */\n  if( pIncr ){\n#if SQLITE_MAX_WORKER_THREADS>0\n    assert( pIncr->bUseThread==0 || eMode==INCRINIT_TASK );\n    if( pIncr->bUseThread ){\n      void *pCtx = (void*)pReadr;\n      rc = vdbeSorterCreateThread(pIncr->pTask, vdbePmaReaderBgIncrInit, pCtx);\n    }else\n#endif\n    {\n      rc = vdbePmaReaderIncrMergeInit(pReadr, eMode);\n    }\n  }\n  return rc;\n}\n\n/*\n** Allocate a new MergeEngine object to merge the contents of nPMA level-0\n** PMAs from pTask->file. If no error occurs, set *ppOut to point to\n** the new object and return SQLITE_OK. Or, if an error does occur, set *ppOut\n** to NULL and return an SQLite error code.\n**\n** When this function is called, *piOffset is set to the offset of the\n** first PMA to read from pTask->file. Assuming no error occurs, it is \n** set to the offset immediately following the last byte of the last\n** PMA before returning. If an error does occur, then the final value of\n** *piOffset is undefined.\n*/\nstatic int vdbeMergeEngineLevel0(\n  SortSubtask *pTask,             /* Sorter task to read from */\n  int nPMA,                       /* Number of PMAs to read */\n  i64 *piOffset,                  /* IN/OUT: Readr offset in pTask->file */\n  MergeEngine **ppOut             /* OUT: New merge-engine */\n){\n  MergeEngine *pNew;              /* Merge engine to return */\n  i64 iOff = *piOffset;\n  int i;\n  int rc = SQLITE_OK;\n\n  *ppOut = pNew = vdbeMergeEngineNew(nPMA);\n  if( pNew==0 ) rc = SQLITE_NOMEM_BKPT;\n\n  for(i=0; i<nPMA && rc==SQLITE_OK; i++){\n    i64 nDummy = 0;\n    PmaReader *pReadr = &pNew->aReadr[i];\n    rc = vdbePmaReaderInit(pTask, &pTask->file, iOff, pReadr, &nDummy);\n    iOff = pReadr->iEof;\n  }\n\n  if( rc!=SQLITE_OK ){\n    vdbeMergeEngineFree(pNew);\n    *ppOut = 0;\n  }\n  *piOffset = iOff;\n  return rc;\n}\n\n/*\n** Return the depth of a tree comprising nPMA PMAs, assuming a fanout of\n** SORTER_MAX_MERGE_COUNT. The returned value does not include leaf nodes.\n**\n** i.e.\n**\n**   nPMA<=16    -> TreeDepth() == 0\n**   nPMA<=256   -> TreeDepth() == 1\n**   nPMA<=65536 -> TreeDepth() == 2\n*/\nstatic int vdbeSorterTreeDepth(int nPMA){\n  int nDepth = 0;\n  i64 nDiv = SORTER_MAX_MERGE_COUNT;\n  while( nDiv < (i64)nPMA ){\n    nDiv = nDiv * SORTER_MAX_MERGE_COUNT;\n    nDepth++;\n  }\n  return nDepth;\n}\n\n/*\n** pRoot is the root of an incremental merge-tree with depth nDepth (according\n** to vdbeSorterTreeDepth()). pLeaf is the iSeq'th leaf to be added to the\n** tree, counting from zero. This function adds pLeaf to the tree.\n**\n** If successful, SQLITE_OK is returned. If an error occurs, an SQLite error\n** code is returned and pLeaf is freed.\n*/\nstatic int vdbeSorterAddToTree(\n  SortSubtask *pTask,             /* Task context */\n  int nDepth,                     /* Depth of tree according to TreeDepth() */\n  int iSeq,                       /* Sequence number of leaf within tree */\n  MergeEngine *pRoot,             /* Root of tree */\n  MergeEngine *pLeaf              /* Leaf to add to tree */\n){\n  int rc = SQLITE_OK;\n  int nDiv = 1;\n  int i;\n  MergeEngine *p = pRoot;\n  IncrMerger *pIncr;\n\n  rc = vdbeIncrMergerNew(pTask, pLeaf, &pIncr);\n\n  for(i=1; i<nDepth; i++){\n    nDiv = nDiv * SORTER_MAX_MERGE_COUNT;\n  }\n\n  for(i=1; i<nDepth && rc==SQLITE_OK; i++){\n    int iIter = (iSeq / nDiv) % SORTER_MAX_MERGE_COUNT;\n    PmaReader *pReadr = &p->aReadr[iIter];\n\n    if( pReadr->pIncr==0 ){\n      MergeEngine *pNew = vdbeMergeEngineNew(SORTER_MAX_MERGE_COUNT);\n      if( pNew==0 ){\n        rc = SQLITE_NOMEM_BKPT;\n      }else{\n        rc = vdbeIncrMergerNew(pTask, pNew, &pReadr->pIncr);\n      }\n    }\n    if( rc==SQLITE_OK ){\n      p = pReadr->pIncr->pMerger;\n      nDiv = nDiv / SORTER_MAX_MERGE_COUNT;\n    }\n  }\n\n  if( rc==SQLITE_OK ){\n    p->aReadr[iSeq % SORTER_MAX_MERGE_COUNT].pIncr = pIncr;\n  }else{\n    vdbeIncrFree(pIncr);\n  }\n  return rc;\n}\n\n/*\n** This function is called as part of a SorterRewind() operation on a sorter\n** that has already written two or more level-0 PMAs to one or more temp\n** files. It builds a tree of MergeEngine/IncrMerger/PmaReader objects that \n** can be used to incrementally merge all PMAs on disk.\n**\n** If successful, SQLITE_OK is returned and *ppOut set to point to the\n** MergeEngine object at the root of the tree before returning. Or, if an\n** error occurs, an SQLite error code is returned and the final value \n** of *ppOut is undefined.\n*/\nstatic int vdbeSorterMergeTreeBuild(\n  VdbeSorter *pSorter,       /* The VDBE cursor that implements the sort */\n  MergeEngine **ppOut        /* Write the MergeEngine here */\n){\n  MergeEngine *pMain = 0;\n  int rc = SQLITE_OK;\n  int iTask;\n\n#if SQLITE_MAX_WORKER_THREADS>0\n  /* If the sorter uses more than one task, then create the top-level \n  ** MergeEngine here. This MergeEngine will read data from exactly \n  ** one PmaReader per sub-task.  */\n  assert( pSorter->bUseThreads || pSorter->nTask==1 );\n  if( pSorter->nTask>1 ){\n    pMain = vdbeMergeEngineNew(pSorter->nTask);\n    if( pMain==0 ) rc = SQLITE_NOMEM_BKPT;\n  }\n#endif\n\n  for(iTask=0; rc==SQLITE_OK && iTask<pSorter->nTask; iTask++){\n    SortSubtask *pTask = &pSorter->aTask[iTask];\n    assert( pTask->nPMA>0 || SQLITE_MAX_WORKER_THREADS>0 );\n    if( SQLITE_MAX_WORKER_THREADS==0 || pTask->nPMA ){\n      MergeEngine *pRoot = 0;     /* Root node of tree for this task */\n      int nDepth = vdbeSorterTreeDepth(pTask->nPMA);\n      i64 iReadOff = 0;\n\n      if( pTask->nPMA<=SORTER_MAX_MERGE_COUNT ){\n        rc = vdbeMergeEngineLevel0(pTask, pTask->nPMA, &iReadOff, &pRoot);\n      }else{\n        int i;\n        int iSeq = 0;\n        pRoot = vdbeMergeEngineNew(SORTER_MAX_MERGE_COUNT);\n        if( pRoot==0 ) rc = SQLITE_NOMEM_BKPT;\n        for(i=0; i<pTask->nPMA && rc==SQLITE_OK; i += SORTER_MAX_MERGE_COUNT){\n          MergeEngine *pMerger = 0; /* New level-0 PMA merger */\n          int nReader;              /* Number of level-0 PMAs to merge */\n\n          nReader = MIN(pTask->nPMA - i, SORTER_MAX_MERGE_COUNT);\n          rc = vdbeMergeEngineLevel0(pTask, nReader, &iReadOff, &pMerger);\n          if( rc==SQLITE_OK ){\n            rc = vdbeSorterAddToTree(pTask, nDepth, iSeq++, pRoot, pMerger);\n          }\n        }\n      }\n\n      if( rc==SQLITE_OK ){\n#if SQLITE_MAX_WORKER_THREADS>0\n        if( pMain!=0 ){\n          rc = vdbeIncrMergerNew(pTask, pRoot, &pMain->aReadr[iTask].pIncr);\n        }else\n#endif\n        {\n          assert( pMain==0 );\n          pMain = pRoot;\n        }\n      }else{\n        vdbeMergeEngineFree(pRoot);\n      }\n    }\n  }\n\n  if( rc!=SQLITE_OK ){\n    vdbeMergeEngineFree(pMain);\n    pMain = 0;\n  }\n  *ppOut = pMain;\n  return rc;\n}\n\n/*\n** This function is called as part of an sqlite3VdbeSorterRewind() operation\n** on a sorter that has written two or more PMAs to temporary files. It sets\n** up either VdbeSorter.pMerger (for single threaded sorters) or pReader\n** (for multi-threaded sorters) so that it can be used to iterate through\n** all records stored in the sorter.\n**\n** SQLITE_OK is returned if successful, or an SQLite error code otherwise.\n*/\nstatic int vdbeSorterSetupMerge(VdbeSorter *pSorter){\n  int rc;                         /* Return code */\n  SortSubtask *pTask0 = &pSorter->aTask[0];\n  MergeEngine *pMain = 0;\n#if SQLITE_MAX_WORKER_THREADS\n  sqlite3 *db = pTask0->pSorter->db;\n  int i;\n  SorterCompare xCompare = vdbeSorterGetCompare(pSorter);\n  for(i=0; i<pSorter->nTask; i++){\n    pSorter->aTask[i].xCompare = xCompare;\n  }\n#endif\n\n  rc = vdbeSorterMergeTreeBuild(pSorter, &pMain);\n  if( rc==SQLITE_OK ){\n#if SQLITE_MAX_WORKER_THREADS\n    assert( pSorter->bUseThreads==0 || pSorter->nTask>1 );\n    if( pSorter->bUseThreads ){\n      int iTask;\n      PmaReader *pReadr = 0;\n      SortSubtask *pLast = &pSorter->aTask[pSorter->nTask-1];\n      rc = vdbeSortAllocUnpacked(pLast);\n      if( rc==SQLITE_OK ){\n        pReadr = (PmaReader*)sqlite3DbMallocZero(db, sizeof(PmaReader));\n        pSorter->pReader = pReadr;\n        if( pReadr==0 ) rc = SQLITE_NOMEM_BKPT;\n      }\n      if( rc==SQLITE_OK ){\n        rc = vdbeIncrMergerNew(pLast, pMain, &pReadr->pIncr);\n        if( rc==SQLITE_OK ){\n          vdbeIncrMergerSetThreads(pReadr->pIncr);\n          for(iTask=0; iTask<(pSorter->nTask-1); iTask++){\n            IncrMerger *pIncr;\n            if( (pIncr = pMain->aReadr[iTask].pIncr) ){\n              vdbeIncrMergerSetThreads(pIncr);\n              assert( pIncr->pTask!=pLast );\n            }\n          }\n          for(iTask=0; rc==SQLITE_OK && iTask<pSorter->nTask; iTask++){\n            /* Check that:\n            **   \n            **   a) The incremental merge object is configured to use the\n            **      right task, and\n            **   b) If it is using task (nTask-1), it is configured to run\n            **      in single-threaded mode. This is important, as the\n            **      root merge (INCRINIT_ROOT) will be using the same task\n            **      object.\n            */\n            PmaReader *p = &pMain->aReadr[iTask];\n            assert( p->pIncr==0 || (\n                (p->pIncr->pTask==&pSorter->aTask[iTask])             /* a */\n             && (iTask!=pSorter->nTask-1 || p->pIncr->bUseThread==0)  /* b */\n            ));\n            rc = vdbePmaReaderIncrInit(p, INCRINIT_TASK);\n          }\n        }\n        pMain = 0;\n      }\n      if( rc==SQLITE_OK ){\n        rc = vdbePmaReaderIncrMergeInit(pReadr, INCRINIT_ROOT);\n      }\n    }else\n#endif\n    {\n      rc = vdbeMergeEngineInit(pTask0, pMain, INCRINIT_NORMAL);\n      pSorter->pMerger = pMain;\n      pMain = 0;\n    }\n  }\n\n  if( rc!=SQLITE_OK ){\n    vdbeMergeEngineFree(pMain);\n  }\n  return rc;\n}\n\n\n/*\n** Once the sorter has been populated by calls to sqlite3VdbeSorterWrite,\n** this function is called to prepare for iterating through the records\n** in sorted order.\n*/\nSQLITE_PRIVATE int sqlite3VdbeSorterRewind(const VdbeCursor *pCsr, int *pbEof){\n  VdbeSorter *pSorter;\n  int rc = SQLITE_OK;             /* Return code */\n\n  assert( pCsr->eCurType==CURTYPE_SORTER );\n  pSorter = pCsr->uc.pSorter;\n  assert( pSorter );\n\n  /* If no data has been written to disk, then do not do so now. Instead,\n  ** sort the VdbeSorter.pRecord list. The vdbe layer will read data directly\n  ** from the in-memory list.  */\n  if( pSorter->bUsePMA==0 ){\n    if( pSorter->list.pList ){\n      *pbEof = 0;\n      rc = vdbeSorterSort(&pSorter->aTask[0], &pSorter->list);\n    }else{\n      *pbEof = 1;\n    }\n    return rc;\n  }\n\n  /* Write the current in-memory list to a PMA. When the VdbeSorterWrite() \n  ** function flushes the contents of memory to disk, it immediately always\n  ** creates a new list consisting of a single key immediately afterwards.\n  ** So the list is never empty at this point.  */\n  assert( pSorter->list.pList );\n  rc = vdbeSorterFlushPMA(pSorter);\n\n  /* Join all threads */\n  rc = vdbeSorterJoinAll(pSorter, rc);\n\n  vdbeSorterRewindDebug(\"rewind\");\n\n  /* Assuming no errors have occurred, set up a merger structure to \n  ** incrementally read and merge all remaining PMAs.  */\n  assert( pSorter->pReader==0 );\n  if( rc==SQLITE_OK ){\n    rc = vdbeSorterSetupMerge(pSorter);\n    *pbEof = 0;\n  }\n\n  vdbeSorterRewindDebug(\"rewinddone\");\n  return rc;\n}\n\n/*\n** Advance to the next element in the sorter.  Return value:\n**\n**    SQLITE_OK     success\n**    SQLITE_DONE   end of data\n**    otherwise     some kind of error.\n*/\nSQLITE_PRIVATE int sqlite3VdbeSorterNext(sqlite3 *db, const VdbeCursor *pCsr){\n  VdbeSorter *pSorter;\n  int rc;                         /* Return code */\n\n  assert( pCsr->eCurType==CURTYPE_SORTER );\n  pSorter = pCsr->uc.pSorter;\n  assert( pSorter->bUsePMA || (pSorter->pReader==0 && pSorter->pMerger==0) );\n  if( pSorter->bUsePMA ){\n    assert( pSorter->pReader==0 || pSorter->pMerger==0 );\n    assert( pSorter->bUseThreads==0 || pSorter->pReader );\n    assert( pSorter->bUseThreads==1 || pSorter->pMerger );\n#if SQLITE_MAX_WORKER_THREADS>0\n    if( pSorter->bUseThreads ){\n      rc = vdbePmaReaderNext(pSorter->pReader);\n      if( rc==SQLITE_OK && pSorter->pReader->pFd==0 ) rc = SQLITE_DONE;\n    }else\n#endif\n    /*if( !pSorter->bUseThreads )*/ {\n      int res = 0;\n      assert( pSorter->pMerger!=0 );\n      assert( pSorter->pMerger->pTask==(&pSorter->aTask[0]) );\n      rc = vdbeMergeEngineStep(pSorter->pMerger, &res);\n      if( rc==SQLITE_OK && res ) rc = SQLITE_DONE;\n    }\n  }else{\n    SorterRecord *pFree = pSorter->list.pList;\n    pSorter->list.pList = pFree->u.pNext;\n    pFree->u.pNext = 0;\n    if( pSorter->list.aMemory==0 ) vdbeSorterRecordFree(db, pFree);\n    rc = pSorter->list.pList ? SQLITE_OK : SQLITE_DONE;\n  }\n  return rc;\n}\n\n/*\n** Return a pointer to a buffer owned by the sorter that contains the \n** current key.\n*/\nstatic void *vdbeSorterRowkey(\n  const VdbeSorter *pSorter,      /* Sorter object */\n  int *pnKey                      /* OUT: Size of current key in bytes */\n){\n  void *pKey;\n  if( pSorter->bUsePMA ){\n    PmaReader *pReader;\n#if SQLITE_MAX_WORKER_THREADS>0\n    if( pSorter->bUseThreads ){\n      pReader = pSorter->pReader;\n    }else\n#endif\n    /*if( !pSorter->bUseThreads )*/{\n      pReader = &pSorter->pMerger->aReadr[pSorter->pMerger->aTree[1]];\n    }\n    *pnKey = pReader->nKey;\n    pKey = pReader->aKey;\n  }else{\n    *pnKey = pSorter->list.pList->nVal;\n    pKey = SRVAL(pSorter->list.pList);\n  }\n  return pKey;\n}\n\n/*\n** Copy the current sorter key into the memory cell pOut.\n*/\nSQLITE_PRIVATE int sqlite3VdbeSorterRowkey(const VdbeCursor *pCsr, Mem *pOut){\n  VdbeSorter *pSorter;\n  void *pKey; int nKey;           /* Sorter key to copy into pOut */\n\n  assert( pCsr->eCurType==CURTYPE_SORTER );\n  pSorter = pCsr->uc.pSorter;\n  pKey = vdbeSorterRowkey(pSorter, &nKey);\n  if( sqlite3VdbeMemClearAndResize(pOut, nKey) ){\n    return SQLITE_NOMEM_BKPT;\n  }\n  pOut->n = nKey;\n  MemSetTypeFlag(pOut, MEM_Blob);\n  memcpy(pOut->z, pKey, nKey);\n\n  return SQLITE_OK;\n}\n\n/*\n** Compare the key in memory cell pVal with the key that the sorter cursor\n** passed as the first argument currently points to. For the purposes of\n** the comparison, ignore the rowid field at the end of each record.\n**\n** If the sorter cursor key contains any NULL values, consider it to be\n** less than pVal. Even if pVal also contains NULL values.\n**\n** If an error occurs, return an SQLite error code (i.e. SQLITE_NOMEM).\n** Otherwise, set *pRes to a negative, zero or positive value if the\n** key in pVal is smaller than, equal to or larger than the current sorter\n** key.\n**\n** This routine forms the core of the OP_SorterCompare opcode, which in\n** turn is used to verify uniqueness when constructing a UNIQUE INDEX.\n*/\nSQLITE_PRIVATE int sqlite3VdbeSorterCompare(\n  const VdbeCursor *pCsr,         /* Sorter cursor */\n  Mem *pVal,                      /* Value to compare to current sorter key */\n  int nKeyCol,                    /* Compare this many columns */\n  int *pRes                       /* OUT: Result of comparison */\n){\n  VdbeSorter *pSorter;\n  UnpackedRecord *r2;\n  KeyInfo *pKeyInfo;\n  int i;\n  void *pKey; int nKey;           /* Sorter key to compare pVal with */\n\n  assert( pCsr->eCurType==CURTYPE_SORTER );\n  pSorter = pCsr->uc.pSorter;\n  r2 = pSorter->pUnpacked;\n  pKeyInfo = pCsr->pKeyInfo;\n  if( r2==0 ){\n    r2 = pSorter->pUnpacked = sqlite3VdbeAllocUnpackedRecord(pKeyInfo);\n    if( r2==0 ) return SQLITE_NOMEM_BKPT;\n    r2->nField = nKeyCol;\n  }\n  assert( r2->nField==nKeyCol );\n\n  pKey = vdbeSorterRowkey(pSorter, &nKey);\n  sqlite3VdbeRecordUnpack(pKeyInfo, nKey, pKey, r2);\n  for(i=0; i<nKeyCol; i++){\n    if( r2->aMem[i].flags & MEM_Null ){\n      *pRes = -1;\n      return SQLITE_OK;\n    }\n  }\n\n  *pRes = sqlite3VdbeRecordCompare(pVal->n, pVal->z, r2);\n  return SQLITE_OK;\n}\n\n/************** End of vdbesort.c ********************************************/\n/************** Begin file memjournal.c **************************************/\n/*\n** 2008 October 7\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n**\n** This file contains code use to implement an in-memory rollback journal.\n** The in-memory rollback journal is used to journal transactions for\n** \":memory:\" databases and when the journal_mode=MEMORY pragma is used.\n**\n** Update:  The in-memory journal is also used to temporarily cache\n** smaller journals that are not critical for power-loss recovery.\n** For example, statement journals that are not too big will be held\n** entirely in memory, thus reducing the number of file I/O calls, and\n** more importantly, reducing temporary file creation events.  If these\n** journals become too large for memory, they are spilled to disk.  But\n** in the common case, they are usually small and no file I/O needs to\n** occur.\n*/\n/* #include \"sqliteInt.h\" */\n\n/* Forward references to internal structures */\ntypedef struct MemJournal MemJournal;\ntypedef struct FilePoint FilePoint;\ntypedef struct FileChunk FileChunk;\n\n/*\n** The rollback journal is composed of a linked list of these structures.\n**\n** The zChunk array is always at least 8 bytes in size - usually much more.\n** Its actual size is stored in the MemJournal.nChunkSize variable.\n*/\nstruct FileChunk {\n  FileChunk *pNext;               /* Next chunk in the journal */\n  u8 zChunk[8];                   /* Content of this chunk */\n};\n\n/*\n** By default, allocate this many bytes of memory for each FileChunk object.\n*/\n#define MEMJOURNAL_DFLT_FILECHUNKSIZE 1024\n\n/*\n** For chunk size nChunkSize, return the number of bytes that should\n** be allocated for each FileChunk structure.\n*/\n#define fileChunkSize(nChunkSize) (sizeof(FileChunk) + ((nChunkSize)-8))\n\n/*\n** An instance of this object serves as a cursor into the rollback journal.\n** The cursor can be either for reading or writing.\n*/\nstruct FilePoint {\n  sqlite3_int64 iOffset;          /* Offset from the beginning of the file */\n  FileChunk *pChunk;              /* Specific chunk into which cursor points */\n};\n\n/*\n** This structure is a subclass of sqlite3_file. Each open memory-journal\n** is an instance of this class.\n*/\nstruct MemJournal {\n  const sqlite3_io_methods *pMethod; /* Parent class. MUST BE FIRST */\n  int nChunkSize;                 /* In-memory chunk-size */\n\n  int nSpill;                     /* Bytes of data before flushing */\n  int nSize;                      /* Bytes of data currently in memory */\n  FileChunk *pFirst;              /* Head of in-memory chunk-list */\n  FilePoint endpoint;             /* Pointer to the end of the file */\n  FilePoint readpoint;            /* Pointer to the end of the last xRead() */\n\n  int flags;                      /* xOpen flags */\n  sqlite3_vfs *pVfs;              /* The \"real\" underlying VFS */\n  const char *zJournal;           /* Name of the journal file */\n};\n\n/*\n** Read data from the in-memory journal file.  This is the implementation\n** of the sqlite3_vfs.xRead method.\n*/\nstatic int memjrnlRead(\n  sqlite3_file *pJfd,    /* The journal file from which to read */\n  void *zBuf,            /* Put the results here */\n  int iAmt,              /* Number of bytes to read */\n  sqlite_int64 iOfst     /* Begin reading at this offset */\n){\n  MemJournal *p = (MemJournal *)pJfd;\n  u8 *zOut = zBuf;\n  int nRead = iAmt;\n  int iChunkOffset;\n  FileChunk *pChunk;\n\n#if defined(SQLITE_ENABLE_ATOMIC_WRITE) \\\n || defined(SQLITE_ENABLE_BATCH_ATOMIC_WRITE)\n  if( (iAmt+iOfst)>p->endpoint.iOffset ){\n    return SQLITE_IOERR_SHORT_READ;\n  }\n#endif\n\n  assert( (iAmt+iOfst)<=p->endpoint.iOffset );\n  assert( p->readpoint.iOffset==0 || p->readpoint.pChunk!=0 );\n  if( p->readpoint.iOffset!=iOfst || iOfst==0 ){\n    sqlite3_int64 iOff = 0;\n    for(pChunk=p->pFirst; \n        ALWAYS(pChunk) && (iOff+p->nChunkSize)<=iOfst;\n        pChunk=pChunk->pNext\n    ){\n      iOff += p->nChunkSize;\n    }\n  }else{\n    pChunk = p->readpoint.pChunk;\n    assert( pChunk!=0 );\n  }\n\n  iChunkOffset = (int)(iOfst%p->nChunkSize);\n  do {\n    int iSpace = p->nChunkSize - iChunkOffset;\n    int nCopy = MIN(nRead, (p->nChunkSize - iChunkOffset));\n    memcpy(zOut, (u8*)pChunk->zChunk + iChunkOffset, nCopy);\n    zOut += nCopy;\n    nRead -= iSpace;\n    iChunkOffset = 0;\n  } while( nRead>=0 && (pChunk=pChunk->pNext)!=0 && nRead>0 );\n  p->readpoint.iOffset = pChunk ? iOfst+iAmt : 0;\n  p->readpoint.pChunk = pChunk;\n\n  return SQLITE_OK;\n}\n\n/*\n** Free the list of FileChunk structures headed at MemJournal.pFirst.\n*/\nstatic void memjrnlFreeChunks(MemJournal *p){\n  FileChunk *pIter;\n  FileChunk *pNext;\n  for(pIter=p->pFirst; pIter; pIter=pNext){\n    pNext = pIter->pNext;\n    sqlite3_free(pIter);\n  } \n  p->pFirst = 0;\n}\n\n/*\n** Flush the contents of memory to a real file on disk.\n*/\nstatic int memjrnlCreateFile(MemJournal *p){\n  int rc;\n  sqlite3_file *pReal = (sqlite3_file*)p;\n  MemJournal copy = *p;\n\n  memset(p, 0, sizeof(MemJournal));\n  rc = sqlite3OsOpen(copy.pVfs, copy.zJournal, pReal, copy.flags, 0);\n  if( rc==SQLITE_OK ){\n    int nChunk = copy.nChunkSize;\n    i64 iOff = 0;\n    FileChunk *pIter;\n    for(pIter=copy.pFirst; pIter; pIter=pIter->pNext){\n      if( iOff + nChunk > copy.endpoint.iOffset ){\n        nChunk = copy.endpoint.iOffset - iOff;\n      }\n      rc = sqlite3OsWrite(pReal, (u8*)pIter->zChunk, nChunk, iOff);\n      if( rc ) break;\n      iOff += nChunk;\n    }\n    if( rc==SQLITE_OK ){\n      /* No error has occurred. Free the in-memory buffers. */\n      memjrnlFreeChunks(&copy);\n    }\n  }\n  if( rc!=SQLITE_OK ){\n    /* If an error occurred while creating or writing to the file, restore\n    ** the original before returning. This way, SQLite uses the in-memory\n    ** journal data to roll back changes made to the internal page-cache\n    ** before this function was called.  */\n    sqlite3OsClose(pReal);\n    *p = copy;\n  }\n  return rc;\n}\n\n\n/*\n** Write data to the file.\n*/\nstatic int memjrnlWrite(\n  sqlite3_file *pJfd,    /* The journal file into which to write */\n  const void *zBuf,      /* Take data to be written from here */\n  int iAmt,              /* Number of bytes to write */\n  sqlite_int64 iOfst     /* Begin writing at this offset into the file */\n){\n  MemJournal *p = (MemJournal *)pJfd;\n  int nWrite = iAmt;\n  u8 *zWrite = (u8 *)zBuf;\n\n  /* If the file should be created now, create it and write the new data\n  ** into the file on disk. */\n  if( p->nSpill>0 && (iAmt+iOfst)>p->nSpill ){\n    int rc = memjrnlCreateFile(p);\n    if( rc==SQLITE_OK ){\n      rc = sqlite3OsWrite(pJfd, zBuf, iAmt, iOfst);\n    }\n    return rc;\n  }\n\n  /* If the contents of this write should be stored in memory */\n  else{\n    /* An in-memory journal file should only ever be appended to. Random\n    ** access writes are not required. The only exception to this is when\n    ** the in-memory journal is being used by a connection using the\n    ** atomic-write optimization. In this case the first 28 bytes of the\n    ** journal file may be written as part of committing the transaction. */ \n    assert( iOfst==p->endpoint.iOffset || iOfst==0 );\n#if defined(SQLITE_ENABLE_ATOMIC_WRITE) \\\n || defined(SQLITE_ENABLE_BATCH_ATOMIC_WRITE)\n    if( iOfst==0 && p->pFirst ){\n      assert( p->nChunkSize>iAmt );\n      memcpy((u8*)p->pFirst->zChunk, zBuf, iAmt);\n    }else\n#else\n    assert( iOfst>0 || p->pFirst==0 );\n#endif\n    {\n      while( nWrite>0 ){\n        FileChunk *pChunk = p->endpoint.pChunk;\n        int iChunkOffset = (int)(p->endpoint.iOffset%p->nChunkSize);\n        int iSpace = MIN(nWrite, p->nChunkSize - iChunkOffset);\n\n        if( iChunkOffset==0 ){\n          /* New chunk is required to extend the file. */\n          FileChunk *pNew = sqlite3_malloc(fileChunkSize(p->nChunkSize));\n          if( !pNew ){\n            return SQLITE_IOERR_NOMEM_BKPT;\n          }\n          pNew->pNext = 0;\n          if( pChunk ){\n            assert( p->pFirst );\n            pChunk->pNext = pNew;\n          }else{\n            assert( !p->pFirst );\n            p->pFirst = pNew;\n          }\n          p->endpoint.pChunk = pNew;\n        }\n\n        memcpy((u8*)p->endpoint.pChunk->zChunk + iChunkOffset, zWrite, iSpace);\n        zWrite += iSpace;\n        nWrite -= iSpace;\n        p->endpoint.iOffset += iSpace;\n      }\n      p->nSize = iAmt + iOfst;\n    }\n  }\n\n  return SQLITE_OK;\n}\n\n/*\n** Truncate the file.\n**\n** If the journal file is already on disk, truncate it there. Or, if it\n** is still in main memory but is being truncated to zero bytes in size,\n** ignore \n*/\nstatic int memjrnlTruncate(sqlite3_file *pJfd, sqlite_int64 size){\n  MemJournal *p = (MemJournal *)pJfd;\n  if( ALWAYS(size==0) ){\n    memjrnlFreeChunks(p);\n    p->nSize = 0;\n    p->endpoint.pChunk = 0;\n    p->endpoint.iOffset = 0;\n    p->readpoint.pChunk = 0;\n    p->readpoint.iOffset = 0;\n  }\n  return SQLITE_OK;\n}\n\n/*\n** Close the file.\n*/\nstatic int memjrnlClose(sqlite3_file *pJfd){\n  MemJournal *p = (MemJournal *)pJfd;\n  memjrnlFreeChunks(p);\n  return SQLITE_OK;\n}\n\n/*\n** Sync the file.\n**\n** If the real file has been created, call its xSync method. Otherwise, \n** syncing an in-memory journal is a no-op. \n*/\nstatic int memjrnlSync(sqlite3_file *pJfd, int flags){\n  UNUSED_PARAMETER2(pJfd, flags);\n  return SQLITE_OK;\n}\n\n/*\n** Query the size of the file in bytes.\n*/\nstatic int memjrnlFileSize(sqlite3_file *pJfd, sqlite_int64 *pSize){\n  MemJournal *p = (MemJournal *)pJfd;\n  *pSize = (sqlite_int64) p->endpoint.iOffset;\n  return SQLITE_OK;\n}\n\n/*\n** Table of methods for MemJournal sqlite3_file object.\n*/\nstatic const struct sqlite3_io_methods MemJournalMethods = {\n  1,                /* iVersion */\n  memjrnlClose,     /* xClose */\n  memjrnlRead,      /* xRead */\n  memjrnlWrite,     /* xWrite */\n  memjrnlTruncate,  /* xTruncate */\n  memjrnlSync,      /* xSync */\n  memjrnlFileSize,  /* xFileSize */\n  0,                /* xLock */\n  0,                /* xUnlock */\n  0,                /* xCheckReservedLock */\n  0,                /* xFileControl */\n  0,                /* xSectorSize */\n  0,                /* xDeviceCharacteristics */\n  0,                /* xShmMap */\n  0,                /* xShmLock */\n  0,                /* xShmBarrier */\n  0,                /* xShmUnmap */\n  0,                /* xFetch */\n  0                 /* xUnfetch */\n};\n\n/* \n** Open a journal file. \n**\n** The behaviour of the journal file depends on the value of parameter \n** nSpill. If nSpill is 0, then the journal file is always create and \n** accessed using the underlying VFS. If nSpill is less than zero, then\n** all content is always stored in main-memory. Finally, if nSpill is a\n** positive value, then the journal file is initially created in-memory\n** but may be flushed to disk later on. In this case the journal file is\n** flushed to disk either when it grows larger than nSpill bytes in size,\n** or when sqlite3JournalCreate() is called.\n*/\nSQLITE_PRIVATE int sqlite3JournalOpen(\n  sqlite3_vfs *pVfs,         /* The VFS to use for actual file I/O */\n  const char *zName,         /* Name of the journal file */\n  sqlite3_file *pJfd,        /* Preallocated, blank file handle */\n  int flags,                 /* Opening flags */\n  int nSpill                 /* Bytes buffered before opening the file */\n){\n  MemJournal *p = (MemJournal*)pJfd;\n\n  /* Zero the file-handle object. If nSpill was passed zero, initialize\n  ** it using the sqlite3OsOpen() function of the underlying VFS. In this\n  ** case none of the code in this module is executed as a result of calls\n  ** made on the journal file-handle.  */\n  memset(p, 0, sizeof(MemJournal));\n  if( nSpill==0 ){\n    return sqlite3OsOpen(pVfs, zName, pJfd, flags, 0);\n  }\n\n  if( nSpill>0 ){\n    p->nChunkSize = nSpill;\n  }else{\n    p->nChunkSize = 8 + MEMJOURNAL_DFLT_FILECHUNKSIZE - sizeof(FileChunk);\n    assert( MEMJOURNAL_DFLT_FILECHUNKSIZE==fileChunkSize(p->nChunkSize) );\n  }\n\n  p->pMethod = (const sqlite3_io_methods*)&MemJournalMethods;\n  p->nSpill = nSpill;\n  p->flags = flags;\n  p->zJournal = zName;\n  p->pVfs = pVfs;\n  return SQLITE_OK;\n}\n\n/*\n** Open an in-memory journal file.\n*/\nSQLITE_PRIVATE void sqlite3MemJournalOpen(sqlite3_file *pJfd){\n  sqlite3JournalOpen(0, 0, pJfd, 0, -1);\n}\n\n#if defined(SQLITE_ENABLE_ATOMIC_WRITE) \\\n || defined(SQLITE_ENABLE_BATCH_ATOMIC_WRITE)\n/*\n** If the argument p points to a MemJournal structure that is not an \n** in-memory-only journal file (i.e. is one that was opened with a +ve\n** nSpill parameter or as SQLITE_OPEN_MAIN_JOURNAL), and the underlying \n** file has not yet been created, create it now.\n*/\nSQLITE_PRIVATE int sqlite3JournalCreate(sqlite3_file *pJfd){\n  int rc = SQLITE_OK;\n  MemJournal *p = (MemJournal*)pJfd;\n  if( p->pMethod==&MemJournalMethods && (\n#ifdef SQLITE_ENABLE_ATOMIC_WRITE\n     p->nSpill>0\n#else\n     /* While this appears to not be possible without ATOMIC_WRITE, the\n     ** paths are complex, so it seems prudent to leave the test in as\n     ** a NEVER(), in case our analysis is subtly flawed. */\n     NEVER(p->nSpill>0)\n#endif\n#ifdef SQLITE_ENABLE_BATCH_ATOMIC_WRITE\n     || (p->flags & SQLITE_OPEN_MAIN_JOURNAL)\n#endif\n  )){\n    rc = memjrnlCreateFile(p);\n  }\n  return rc;\n}\n#endif\n\n/*\n** The file-handle passed as the only argument is open on a journal file.\n** Return true if this \"journal file\" is currently stored in heap memory,\n** or false otherwise.\n*/\nSQLITE_PRIVATE int sqlite3JournalIsInMemory(sqlite3_file *p){\n  return p->pMethods==&MemJournalMethods;\n}\n\n/* \n** Return the number of bytes required to store a JournalFile that uses vfs\n** pVfs to create the underlying on-disk files.\n*/\nSQLITE_PRIVATE int sqlite3JournalSize(sqlite3_vfs *pVfs){\n  return MAX(pVfs->szOsFile, (int)sizeof(MemJournal));\n}\n\n/************** End of memjournal.c ******************************************/\n/************** Begin file walker.c ******************************************/\n/*\n** 2008 August 16\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This file contains routines used for walking the parser tree for\n** an SQL statement.\n*/\n/* #include \"sqliteInt.h\" */\n/* #include <stdlib.h> */\n/* #include <string.h> */\n\n\n#if !defined(SQLITE_OMIT_WINDOWFUNC)\n/*\n** Walk all expressions linked into the list of Window objects passed\n** as the second argument.\n*/\nstatic int walkWindowList(Walker *pWalker, Window *pList){\n  Window *pWin;\n  for(pWin=pList; pWin; pWin=pWin->pNextWin){\n    if( sqlite3WalkExprList(pWalker, pWin->pOrderBy) ) return WRC_Abort;\n    if( sqlite3WalkExprList(pWalker, pWin->pPartition) ) return WRC_Abort;\n    if( sqlite3WalkExpr(pWalker, pWin->pFilter) ) return WRC_Abort;\n  }\n  return WRC_Continue;\n}\n#endif\n\n/*\n** Walk an expression tree.  Invoke the callback once for each node\n** of the expression, while descending.  (In other words, the callback\n** is invoked before visiting children.)\n**\n** The return value from the callback should be one of the WRC_*\n** constants to specify how to proceed with the walk.\n**\n**    WRC_Continue      Continue descending down the tree.\n**\n**    WRC_Prune         Do not descend into child nodes, but allow\n**                      the walk to continue with sibling nodes.\n**\n**    WRC_Abort         Do no more callbacks.  Unwind the stack and\n**                      return from the top-level walk call.\n**\n** The return value from this routine is WRC_Abort to abandon the tree walk\n** and WRC_Continue to continue.\n*/\nstatic SQLITE_NOINLINE int walkExpr(Walker *pWalker, Expr *pExpr){\n  int rc;\n  testcase( ExprHasProperty(pExpr, EP_TokenOnly) );\n  testcase( ExprHasProperty(pExpr, EP_Reduced) );\n  while(1){\n    rc = pWalker->xExprCallback(pWalker, pExpr);\n    if( rc ) return rc & WRC_Abort;\n    if( !ExprHasProperty(pExpr,(EP_TokenOnly|EP_Leaf)) ){\n      if( pExpr->pLeft && walkExpr(pWalker, pExpr->pLeft) ) return WRC_Abort;\n       assert( pExpr->x.pList==0 || pExpr->pRight==0 );\n      if( pExpr->pRight ){\n        pExpr = pExpr->pRight;\n        continue;\n      }else if( ExprHasProperty(pExpr, EP_xIsSelect) ){\n        if( sqlite3WalkSelect(pWalker, pExpr->x.pSelect) ) return WRC_Abort;\n      }else if( pExpr->x.pList ){\n        if( sqlite3WalkExprList(pWalker, pExpr->x.pList) ) return WRC_Abort;\n      }\n#ifndef SQLITE_OMIT_WINDOWFUNC\n      if( ExprHasProperty(pExpr, EP_WinFunc) ){\n        if( walkWindowList(pWalker, pExpr->y.pWin) ) return WRC_Abort;\n      }\n#endif\n    }\n    break;\n  }\n  return WRC_Continue;\n}\nSQLITE_PRIVATE int sqlite3WalkExpr(Walker *pWalker, Expr *pExpr){\n  return pExpr ? walkExpr(pWalker,pExpr) : WRC_Continue;\n}\n\n/*\n** Call sqlite3WalkExpr() for every expression in list p or until\n** an abort request is seen.\n*/\nSQLITE_PRIVATE int sqlite3WalkExprList(Walker *pWalker, ExprList *p){\n  int i;\n  struct ExprList_item *pItem;\n  if( p ){\n    for(i=p->nExpr, pItem=p->a; i>0; i--, pItem++){\n      if( sqlite3WalkExpr(pWalker, pItem->pExpr) ) return WRC_Abort;\n    }\n  }\n  return WRC_Continue;\n}\n\n/*\n** Walk all expressions associated with SELECT statement p.  Do\n** not invoke the SELECT callback on p, but do (of course) invoke\n** any expr callbacks and SELECT callbacks that come from subqueries.\n** Return WRC_Abort or WRC_Continue.\n*/\nSQLITE_PRIVATE int sqlite3WalkSelectExpr(Walker *pWalker, Select *p){\n  if( sqlite3WalkExprList(pWalker, p->pEList) ) return WRC_Abort;\n  if( sqlite3WalkExpr(pWalker, p->pWhere) ) return WRC_Abort;\n  if( sqlite3WalkExprList(pWalker, p->pGroupBy) ) return WRC_Abort;\n  if( sqlite3WalkExpr(pWalker, p->pHaving) ) return WRC_Abort;\n  if( sqlite3WalkExprList(pWalker, p->pOrderBy) ) return WRC_Abort;\n  if( sqlite3WalkExpr(pWalker, p->pLimit) ) return WRC_Abort;\n#if !defined(SQLITE_OMIT_WINDOWFUNC) && !defined(SQLITE_OMIT_ALTERTABLE)\n  {\n    Parse *pParse = pWalker->pParse;\n    if( pParse && IN_RENAME_OBJECT ){\n      int rc = walkWindowList(pWalker, p->pWinDefn);\n      assert( rc==WRC_Continue );\n      return rc;\n    }\n  }\n#endif\n  return WRC_Continue;\n}\n\n/*\n** Walk the parse trees associated with all subqueries in the\n** FROM clause of SELECT statement p.  Do not invoke the select\n** callback on p, but do invoke it on each FROM clause subquery\n** and on any subqueries further down in the tree.  Return \n** WRC_Abort or WRC_Continue;\n*/\nSQLITE_PRIVATE int sqlite3WalkSelectFrom(Walker *pWalker, Select *p){\n  SrcList *pSrc;\n  int i;\n  struct SrcList_item *pItem;\n\n  pSrc = p->pSrc;\n  assert( pSrc!=0 );\n  for(i=pSrc->nSrc, pItem=pSrc->a; i>0; i--, pItem++){\n    if( pItem->pSelect && sqlite3WalkSelect(pWalker, pItem->pSelect) ){\n      return WRC_Abort;\n    }\n    if( pItem->fg.isTabFunc\n     && sqlite3WalkExprList(pWalker, pItem->u1.pFuncArg)\n    ){\n      return WRC_Abort;\n    }\n  }\n  return WRC_Continue;\n} \n\n/*\n** Call sqlite3WalkExpr() for every expression in Select statement p.\n** Invoke sqlite3WalkSelect() for subqueries in the FROM clause and\n** on the compound select chain, p->pPrior. \n**\n** If it is not NULL, the xSelectCallback() callback is invoked before\n** the walk of the expressions and FROM clause. The xSelectCallback2()\n** method is invoked following the walk of the expressions and FROM clause,\n** but only if both xSelectCallback and xSelectCallback2 are both non-NULL\n** and if the expressions and FROM clause both return WRC_Continue;\n**\n** Return WRC_Continue under normal conditions.  Return WRC_Abort if\n** there is an abort request.\n**\n** If the Walker does not have an xSelectCallback() then this routine\n** is a no-op returning WRC_Continue.\n*/\nSQLITE_PRIVATE int sqlite3WalkSelect(Walker *pWalker, Select *p){\n  int rc;\n  if( p==0 ) return WRC_Continue;\n  if( pWalker->xSelectCallback==0 ) return WRC_Continue;\n  do{\n    rc = pWalker->xSelectCallback(pWalker, p);\n    if( rc ) return rc & WRC_Abort;\n    if( sqlite3WalkSelectExpr(pWalker, p)\n     || sqlite3WalkSelectFrom(pWalker, p)\n    ){\n      return WRC_Abort;\n    }\n    if( pWalker->xSelectCallback2 ){\n      pWalker->xSelectCallback2(pWalker, p);\n    }\n    p = p->pPrior;\n  }while( p!=0 );\n  return WRC_Continue;\n}\n\n/************** End of walker.c **********************************************/\n/************** Begin file resolve.c *****************************************/\n/*\n** 2008 August 18\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n**\n** This file contains routines used for walking the parser tree and\n** resolve all identifiers by associating them with a particular\n** table and column.\n*/\n/* #include \"sqliteInt.h\" */\n\n/*\n** Walk the expression tree pExpr and increase the aggregate function\n** depth (the Expr.op2 field) by N on every TK_AGG_FUNCTION node.\n** This needs to occur when copying a TK_AGG_FUNCTION node from an\n** outer query into an inner subquery.\n**\n** incrAggFunctionDepth(pExpr,n) is the main routine.  incrAggDepth(..)\n** is a helper function - a callback for the tree walker.\n*/\nstatic int incrAggDepth(Walker *pWalker, Expr *pExpr){\n  if( pExpr->op==TK_AGG_FUNCTION ) pExpr->op2 += pWalker->u.n;\n  return WRC_Continue;\n}\nstatic void incrAggFunctionDepth(Expr *pExpr, int N){\n  if( N>0 ){\n    Walker w;\n    memset(&w, 0, sizeof(w));\n    w.xExprCallback = incrAggDepth;\n    w.u.n = N;\n    sqlite3WalkExpr(&w, pExpr);\n  }\n}\n\n/*\n** Turn the pExpr expression into an alias for the iCol-th column of the\n** result set in pEList.\n**\n** If the reference is followed by a COLLATE operator, then make sure\n** the COLLATE operator is preserved.  For example:\n**\n**     SELECT a+b, c+d FROM t1 ORDER BY 1 COLLATE nocase;\n**\n** Should be transformed into:\n**\n**     SELECT a+b, c+d FROM t1 ORDER BY (a+b) COLLATE nocase;\n**\n** The nSubquery parameter specifies how many levels of subquery the\n** alias is removed from the original expression.  The usual value is\n** zero but it might be more if the alias is contained within a subquery\n** of the original expression.  The Expr.op2 field of TK_AGG_FUNCTION\n** structures must be increased by the nSubquery amount.\n*/\nstatic void resolveAlias(\n  Parse *pParse,         /* Parsing context */\n  ExprList *pEList,      /* A result set */\n  int iCol,              /* A column in the result set.  0..pEList->nExpr-1 */\n  Expr *pExpr,           /* Transform this into an alias to the result set */\n  const char *zType,     /* \"GROUP\" or \"ORDER\" or \"\" */\n  int nSubquery          /* Number of subqueries that the label is moving */\n){\n  Expr *pOrig;           /* The iCol-th column of the result set */\n  Expr *pDup;            /* Copy of pOrig */\n  sqlite3 *db;           /* The database connection */\n\n  assert( iCol>=0 && iCol<pEList->nExpr );\n  pOrig = pEList->a[iCol].pExpr;\n  assert( pOrig!=0 );\n  db = pParse->db;\n  pDup = sqlite3ExprDup(db, pOrig, 0);\n  if( pDup!=0 ){\n    if( zType[0]!='G' ) incrAggFunctionDepth(pDup, nSubquery);\n    if( pExpr->op==TK_COLLATE ){\n      pDup = sqlite3ExprAddCollateString(pParse, pDup, pExpr->u.zToken);\n    }\n\n    /* Before calling sqlite3ExprDelete(), set the EP_Static flag. This \n    ** prevents ExprDelete() from deleting the Expr structure itself,\n    ** allowing it to be repopulated by the memcpy() on the following line.\n    ** The pExpr->u.zToken might point into memory that will be freed by the\n    ** sqlite3DbFree(db, pDup) on the last line of this block, so be sure to\n    ** make a copy of the token before doing the sqlite3DbFree().\n    */\n    ExprSetProperty(pExpr, EP_Static);\n    sqlite3ExprDelete(db, pExpr);\n    memcpy(pExpr, pDup, sizeof(*pExpr));\n    if( !ExprHasProperty(pExpr, EP_IntValue) && pExpr->u.zToken!=0 ){\n      assert( (pExpr->flags & (EP_Reduced|EP_TokenOnly))==0 );\n      pExpr->u.zToken = sqlite3DbStrDup(db, pExpr->u.zToken);\n      pExpr->flags |= EP_MemToken;\n    }\n    sqlite3DbFree(db, pDup);\n  }\n  ExprSetProperty(pExpr, EP_Alias);\n}\n\n\n/*\n** Return TRUE if the name zCol occurs anywhere in the USING clause.\n**\n** Return FALSE if the USING clause is NULL or if it does not contain\n** zCol.\n*/\nstatic int nameInUsingClause(IdList *pUsing, const char *zCol){\n  if( pUsing ){\n    int k;\n    for(k=0; k<pUsing->nId; k++){\n      if( sqlite3StrICmp(pUsing->a[k].zName, zCol)==0 ) return 1;\n    }\n  }\n  return 0;\n}\n\n/*\n** Subqueries stores the original database, table and column names for their\n** result sets in ExprList.a[].zSpan, in the form \"DATABASE.TABLE.COLUMN\".\n** Check to see if the zSpan given to this routine matches the zDb, zTab,\n** and zCol.  If any of zDb, zTab, and zCol are NULL then those fields will\n** match anything.\n*/\nSQLITE_PRIVATE int sqlite3MatchSpanName(\n  const char *zSpan,\n  const char *zCol,\n  const char *zTab,\n  const char *zDb\n){\n  int n;\n  for(n=0; ALWAYS(zSpan[n]) && zSpan[n]!='.'; n++){}\n  if( zDb && (sqlite3StrNICmp(zSpan, zDb, n)!=0 || zDb[n]!=0) ){\n    return 0;\n  }\n  zSpan += n+1;\n  for(n=0; ALWAYS(zSpan[n]) && zSpan[n]!='.'; n++){}\n  if( zTab && (sqlite3StrNICmp(zSpan, zTab, n)!=0 || zTab[n]!=0) ){\n    return 0;\n  }\n  zSpan += n+1;\n  if( zCol && sqlite3StrICmp(zSpan, zCol)!=0 ){\n    return 0;\n  }\n  return 1;\n}\n\n/*\n** Given the name of a column of the form X.Y.Z or Y.Z or just Z, look up\n** that name in the set of source tables in pSrcList and make the pExpr \n** expression node refer back to that source column.  The following changes\n** are made to pExpr:\n**\n**    pExpr->iDb           Set the index in db->aDb[] of the database X\n**                         (even if X is implied).\n**    pExpr->iTable        Set to the cursor number for the table obtained\n**                         from pSrcList.\n**    pExpr->y.pTab        Points to the Table structure of X.Y (even if\n**                         X and/or Y are implied.)\n**    pExpr->iColumn       Set to the column number within the table.\n**    pExpr->op            Set to TK_COLUMN.\n**    pExpr->pLeft         Any expression this points to is deleted\n**    pExpr->pRight        Any expression this points to is deleted.\n**\n** The zDb variable is the name of the database (the \"X\").  This value may be\n** NULL meaning that name is of the form Y.Z or Z.  Any available database\n** can be used.  The zTable variable is the name of the table (the \"Y\").  This\n** value can be NULL if zDb is also NULL.  If zTable is NULL it\n** means that the form of the name is Z and that columns from any table\n** can be used.\n**\n** If the name cannot be resolved unambiguously, leave an error message\n** in pParse and return WRC_Abort.  Return WRC_Prune on success.\n*/\nstatic int lookupName(\n  Parse *pParse,       /* The parsing context */\n  const char *zDb,     /* Name of the database containing table, or NULL */\n  const char *zTab,    /* Name of table containing column, or NULL */\n  const char *zCol,    /* Name of the column. */\n  NameContext *pNC,    /* The name context used to resolve the name */\n  Expr *pExpr          /* Make this EXPR node point to the selected column */\n){\n  int i, j;                         /* Loop counters */\n  int cnt = 0;                      /* Number of matching column names */\n  int cntTab = 0;                   /* Number of matching table names */\n  int nSubquery = 0;                /* How many levels of subquery */\n  sqlite3 *db = pParse->db;         /* The database connection */\n  struct SrcList_item *pItem;       /* Use for looping over pSrcList items */\n  struct SrcList_item *pMatch = 0;  /* The matching pSrcList item */\n  NameContext *pTopNC = pNC;        /* First namecontext in the list */\n  Schema *pSchema = 0;              /* Schema of the expression */\n  int eNewExprOp = TK_COLUMN;       /* New value for pExpr->op on success */\n  Table *pTab = 0;                  /* Table hold the row */\n  Column *pCol;                     /* A column of pTab */\n\n  assert( pNC );     /* the name context cannot be NULL. */\n  assert( zCol );    /* The Z in X.Y.Z cannot be NULL */\n  assert( !ExprHasProperty(pExpr, EP_TokenOnly|EP_Reduced) );\n\n  /* Initialize the node to no-match */\n  pExpr->iTable = -1;\n  ExprSetVVAProperty(pExpr, EP_NoReduce);\n\n  /* Translate the schema name in zDb into a pointer to the corresponding\n  ** schema.  If not found, pSchema will remain NULL and nothing will match\n  ** resulting in an appropriate error message toward the end of this routine\n  */\n  if( zDb ){\n    testcase( pNC->ncFlags & NC_PartIdx );\n    testcase( pNC->ncFlags & NC_IsCheck );\n    if( (pNC->ncFlags & (NC_PartIdx|NC_IsCheck))!=0 ){\n      /* Silently ignore database qualifiers inside CHECK constraints and\n      ** partial indices.  Do not raise errors because that might break\n      ** legacy and because it does not hurt anything to just ignore the\n      ** database name. */\n      zDb = 0;\n    }else{\n      for(i=0; i<db->nDb; i++){\n        assert( db->aDb[i].zDbSName );\n        if( sqlite3StrICmp(db->aDb[i].zDbSName,zDb)==0 ){\n          pSchema = db->aDb[i].pSchema;\n          break;\n        }\n      }\n    }\n  }\n\n  /* Start at the inner-most context and move outward until a match is found */\n  assert( pNC && cnt==0 );\n  do{\n    ExprList *pEList;\n    SrcList *pSrcList = pNC->pSrcList;\n\n    if( pSrcList ){\n      for(i=0, pItem=pSrcList->a; i<pSrcList->nSrc; i++, pItem++){\n        pTab = pItem->pTab;\n        assert( pTab!=0 && pTab->zName!=0 );\n        assert( pTab->nCol>0 );\n        if( pItem->pSelect && (pItem->pSelect->selFlags & SF_NestedFrom)!=0 ){\n          int hit = 0;\n          pEList = pItem->pSelect->pEList;\n          for(j=0; j<pEList->nExpr; j++){\n            if( sqlite3MatchSpanName(pEList->a[j].zSpan, zCol, zTab, zDb) ){\n              cnt++;\n              cntTab = 2;\n              pMatch = pItem;\n              pExpr->iColumn = j;\n              hit = 1;\n            }\n          }\n          if( hit || zTab==0 ) continue;\n        }\n        if( zDb && pTab->pSchema!=pSchema ){\n          continue;\n        }\n        if( zTab ){\n          const char *zTabName = pItem->zAlias ? pItem->zAlias : pTab->zName;\n          assert( zTabName!=0 );\n          if( sqlite3StrICmp(zTabName, zTab)!=0 ){\n            continue;\n          }\n          if( IN_RENAME_OBJECT && pItem->zAlias ){\n            sqlite3RenameTokenRemap(pParse, 0, (void*)&pExpr->y.pTab);\n          }\n        }\n        if( 0==(cntTab++) ){\n          pMatch = pItem;\n        }\n        for(j=0, pCol=pTab->aCol; j<pTab->nCol; j++, pCol++){\n          if( sqlite3StrICmp(pCol->zName, zCol)==0 ){\n            /* If there has been exactly one prior match and this match\n            ** is for the right-hand table of a NATURAL JOIN or is in a \n            ** USING clause, then skip this match.\n            */\n            if( cnt==1 ){\n              if( pItem->fg.jointype & JT_NATURAL ) continue;\n              if( nameInUsingClause(pItem->pUsing, zCol) ) continue;\n            }\n            cnt++;\n            pMatch = pItem;\n            /* Substitute the rowid (column -1) for the INTEGER PRIMARY KEY */\n            pExpr->iColumn = j==pTab->iPKey ? -1 : (i16)j;\n            break;\n          }\n        }\n      }\n      if( pMatch ){\n        pExpr->iTable = pMatch->iCursor;\n        pExpr->y.pTab = pMatch->pTab;\n        /* RIGHT JOIN not (yet) supported */\n        assert( (pMatch->fg.jointype & JT_RIGHT)==0 );\n        if( (pMatch->fg.jointype & JT_LEFT)!=0 ){\n          ExprSetProperty(pExpr, EP_CanBeNull);\n        }\n        pSchema = pExpr->y.pTab->pSchema;\n      }\n    } /* if( pSrcList ) */\n\n#if !defined(SQLITE_OMIT_TRIGGER) || !defined(SQLITE_OMIT_UPSERT)\n    /* If we have not already resolved the name, then maybe \n    ** it is a new.* or old.* trigger argument reference.  Or\n    ** maybe it is an excluded.* from an upsert.\n    */\n    if( zDb==0 && zTab!=0 && cntTab==0 ){\n      pTab = 0;\n#ifndef SQLITE_OMIT_TRIGGER\n      if( pParse->pTriggerTab!=0 ){\n        int op = pParse->eTriggerOp;\n        assert( op==TK_DELETE || op==TK_UPDATE || op==TK_INSERT );\n        if( op!=TK_DELETE && sqlite3StrICmp(\"new\",zTab) == 0 ){\n          pExpr->iTable = 1;\n          pTab = pParse->pTriggerTab;\n        }else if( op!=TK_INSERT && sqlite3StrICmp(\"old\",zTab)==0 ){\n          pExpr->iTable = 0;\n          pTab = pParse->pTriggerTab;\n        }\n      }\n#endif /* SQLITE_OMIT_TRIGGER */\n#ifndef SQLITE_OMIT_UPSERT\n      if( (pNC->ncFlags & NC_UUpsert)!=0 ){\n        Upsert *pUpsert = pNC->uNC.pUpsert;\n        if( pUpsert && sqlite3StrICmp(\"excluded\",zTab)==0 ){\n          pTab = pUpsert->pUpsertSrc->a[0].pTab;\n          pExpr->iTable = 2;\n        }\n      }\n#endif /* SQLITE_OMIT_UPSERT */\n\n      if( pTab ){ \n        int iCol;\n        pSchema = pTab->pSchema;\n        cntTab++;\n        for(iCol=0, pCol=pTab->aCol; iCol<pTab->nCol; iCol++, pCol++){\n          if( sqlite3StrICmp(pCol->zName, zCol)==0 ){\n            if( iCol==pTab->iPKey ){\n              iCol = -1;\n            }\n            break;\n          }\n        }\n        if( iCol>=pTab->nCol && sqlite3IsRowid(zCol) && VisibleRowid(pTab) ){\n          /* IMP: R-51414-32910 */\n          iCol = -1;\n        }\n        if( iCol<pTab->nCol ){\n          cnt++;\n#ifndef SQLITE_OMIT_UPSERT\n          if( pExpr->iTable==2 ){\n            testcase( iCol==(-1) );\n            if( IN_RENAME_OBJECT ){\n              pExpr->iColumn = iCol;\n              pExpr->y.pTab = pTab;\n              eNewExprOp = TK_COLUMN;\n            }else{\n              pExpr->iTable = pNC->uNC.pUpsert->regData + iCol;\n              eNewExprOp = TK_REGISTER;\n              ExprSetProperty(pExpr, EP_Alias);\n            }\n          }else\n#endif /* SQLITE_OMIT_UPSERT */\n          {\n#ifndef SQLITE_OMIT_TRIGGER\n            if( iCol<0 ){\n              pExpr->affinity = SQLITE_AFF_INTEGER;\n            }else if( pExpr->iTable==0 ){\n              testcase( iCol==31 );\n              testcase( iCol==32 );\n              pParse->oldmask |= (iCol>=32 ? 0xffffffff : (((u32)1)<<iCol));\n            }else{\n              testcase( iCol==31 );\n              testcase( iCol==32 );\n              pParse->newmask |= (iCol>=32 ? 0xffffffff : (((u32)1)<<iCol));\n            }\n            pExpr->y.pTab = pTab;\n            pExpr->iColumn = (i16)iCol;\n            eNewExprOp = TK_TRIGGER;\n#endif /* SQLITE_OMIT_TRIGGER */\n          }\n        }\n      }\n    }\n#endif /* !defined(SQLITE_OMIT_TRIGGER) || !defined(SQLITE_OMIT_UPSERT) */\n\n    /*\n    ** Perhaps the name is a reference to the ROWID\n    */\n    if( cnt==0\n     && cntTab==1\n     && pMatch\n     && (pNC->ncFlags & NC_IdxExpr)==0\n     && sqlite3IsRowid(zCol)\n     && VisibleRowid(pMatch->pTab)\n    ){\n      cnt = 1;\n      pExpr->iColumn = -1;\n      pExpr->affinity = SQLITE_AFF_INTEGER;\n    }\n\n    /*\n    ** If the input is of the form Z (not Y.Z or X.Y.Z) then the name Z\n    ** might refer to an result-set alias.  This happens, for example, when\n    ** we are resolving names in the WHERE clause of the following command:\n    **\n    **     SELECT a+b AS x FROM table WHERE x<10;\n    **\n    ** In cases like this, replace pExpr with a copy of the expression that\n    ** forms the result set entry (\"a+b\" in the example) and return immediately.\n    ** Note that the expression in the result set should have already been\n    ** resolved by the time the WHERE clause is resolved.\n    **\n    ** The ability to use an output result-set column in the WHERE, GROUP BY,\n    ** or HAVING clauses, or as part of a larger expression in the ORDER BY\n    ** clause is not standard SQL.  This is a (goofy) SQLite extension, that\n    ** is supported for backwards compatibility only. Hence, we issue a warning\n    ** on sqlite3_log() whenever the capability is used.\n    */\n    if( (pNC->ncFlags & NC_UEList)!=0\n     && cnt==0\n     && zTab==0\n    ){\n      pEList = pNC->uNC.pEList;\n      assert( pEList!=0 );\n      for(j=0; j<pEList->nExpr; j++){\n        char *zAs = pEList->a[j].zName;\n        if( zAs!=0 && sqlite3StrICmp(zAs, zCol)==0 ){\n          Expr *pOrig;\n          assert( pExpr->pLeft==0 && pExpr->pRight==0 );\n          assert( pExpr->x.pList==0 );\n          assert( pExpr->x.pSelect==0 );\n          pOrig = pEList->a[j].pExpr;\n          if( (pNC->ncFlags&NC_AllowAgg)==0 && ExprHasProperty(pOrig, EP_Agg) ){\n            sqlite3ErrorMsg(pParse, \"misuse of aliased aggregate %s\", zAs);\n            return WRC_Abort;\n          }\n          if( sqlite3ExprVectorSize(pOrig)!=1 ){\n            sqlite3ErrorMsg(pParse, \"row value misused\");\n            return WRC_Abort;\n          }\n          resolveAlias(pParse, pEList, j, pExpr, \"\", nSubquery);\n          cnt = 1;\n          pMatch = 0;\n          assert( zTab==0 && zDb==0 );\n          if( IN_RENAME_OBJECT ){\n            sqlite3RenameTokenRemap(pParse, 0, (void*)pExpr);\n          }\n          goto lookupname_end;\n        }\n      } \n    }\n\n    /* Advance to the next name context.  The loop will exit when either\n    ** we have a match (cnt>0) or when we run out of name contexts.\n    */\n    if( cnt ) break;\n    pNC = pNC->pNext;\n    nSubquery++;\n  }while( pNC );\n\n\n  /*\n  ** If X and Y are NULL (in other words if only the column name Z is\n  ** supplied) and the value of Z is enclosed in double-quotes, then\n  ** Z is a string literal if it doesn't match any column names.  In that\n  ** case, we need to return right away and not make any changes to\n  ** pExpr.\n  **\n  ** Because no reference was made to outer contexts, the pNC->nRef\n  ** fields are not changed in any context.\n  */\n  if( cnt==0 && zTab==0 ){\n    assert( pExpr->op==TK_ID );\n    if( ExprHasProperty(pExpr,EP_DblQuoted) ){\n      /* If a double-quoted identifier does not match any known column name,\n      ** then treat it as a string.\n      **\n      ** This hack was added in the early days of SQLite in a misguided attempt\n      ** to be compatible with MySQL 3.x, which used double-quotes for strings.\n      ** I now sorely regret putting in this hack. The effect of this hack is\n      ** that misspelled identifier names are silently converted into strings\n      ** rather than causing an error, to the frustration of countless\n      ** programmers. To all those frustrated programmers, my apologies.\n      **\n      ** Someday, I hope to get rid of this hack. Unfortunately there is\n      ** a huge amount of legacy SQL that uses it. So for now, we just\n      ** issue a warning.\n      */\n      sqlite3_log(SQLITE_WARNING,\n        \"double-quoted string literal: \\\"%w\\\"\", zCol);\n#ifdef SQLITE_ENABLE_NORMALIZE\n      sqlite3VdbeAddDblquoteStr(db, pParse->pVdbe, zCol);\n#endif\n      pExpr->op = TK_STRING;\n      pExpr->y.pTab = 0;\n      return WRC_Prune;\n    }\n    if( sqlite3ExprIdToTrueFalse(pExpr) ){\n      return WRC_Prune;\n    }\n  }\n\n  /*\n  ** cnt==0 means there was not match.  cnt>1 means there were two or\n  ** more matches.  Either way, we have an error.\n  */\n  if( cnt!=1 ){\n    const char *zErr;\n    zErr = cnt==0 ? \"no such column\" : \"ambiguous column name\";\n    if( zDb ){\n      sqlite3ErrorMsg(pParse, \"%s: %s.%s.%s\", zErr, zDb, zTab, zCol);\n    }else if( zTab ){\n      sqlite3ErrorMsg(pParse, \"%s: %s.%s\", zErr, zTab, zCol);\n    }else{\n      sqlite3ErrorMsg(pParse, \"%s: %s\", zErr, zCol);\n    }\n    pParse->checkSchema = 1;\n    pTopNC->nErr++;\n  }\n\n  /* If a column from a table in pSrcList is referenced, then record\n  ** this fact in the pSrcList.a[].colUsed bitmask.  Column 0 causes\n  ** bit 0 to be set.  Column 1 sets bit 1.  And so forth.  If the\n  ** column number is greater than the number of bits in the bitmask\n  ** then set the high-order bit of the bitmask.\n  */\n  if( pExpr->iColumn>=0 && pMatch!=0 ){\n    int n = pExpr->iColumn;\n    testcase( n==BMS-1 );\n    if( n>=BMS ){\n      n = BMS-1;\n    }\n    assert( pMatch->iCursor==pExpr->iTable );\n    pMatch->colUsed |= ((Bitmask)1)<<n;\n  }\n\n  /* Clean up and return\n  */\n  sqlite3ExprDelete(db, pExpr->pLeft);\n  pExpr->pLeft = 0;\n  sqlite3ExprDelete(db, pExpr->pRight);\n  pExpr->pRight = 0;\n  pExpr->op = eNewExprOp;\n  ExprSetProperty(pExpr, EP_Leaf);\nlookupname_end:\n  if( cnt==1 ){\n    assert( pNC!=0 );\n    if( !ExprHasProperty(pExpr, EP_Alias) ){\n      sqlite3AuthRead(pParse, pExpr, pSchema, pNC->pSrcList);\n    }\n    /* Increment the nRef value on all name contexts from TopNC up to\n    ** the point where the name matched. */\n    for(;;){\n      assert( pTopNC!=0 );\n      pTopNC->nRef++;\n      if( pTopNC==pNC ) break;\n      pTopNC = pTopNC->pNext;\n    }\n    return WRC_Prune;\n  } else {\n    return WRC_Abort;\n  }\n}\n\n/*\n** Allocate and return a pointer to an expression to load the column iCol\n** from datasource iSrc in SrcList pSrc.\n*/\nSQLITE_PRIVATE Expr *sqlite3CreateColumnExpr(sqlite3 *db, SrcList *pSrc, int iSrc, int iCol){\n  Expr *p = sqlite3ExprAlloc(db, TK_COLUMN, 0, 0);\n  if( p ){\n    struct SrcList_item *pItem = &pSrc->a[iSrc];\n    p->y.pTab = pItem->pTab;\n    p->iTable = pItem->iCursor;\n    if( p->y.pTab->iPKey==iCol ){\n      p->iColumn = -1;\n    }else{\n      p->iColumn = (ynVar)iCol;\n      testcase( iCol==BMS );\n      testcase( iCol==BMS-1 );\n      pItem->colUsed |= ((Bitmask)1)<<(iCol>=BMS ? BMS-1 : iCol);\n    }\n  }\n  return p;\n}\n\n/*\n** Report an error that an expression is not valid for some set of\n** pNC->ncFlags values determined by validMask.\n*/\nstatic void notValid(\n  Parse *pParse,       /* Leave error message here */\n  NameContext *pNC,    /* The name context */\n  const char *zMsg,    /* Type of error */\n  int validMask        /* Set of contexts for which prohibited */\n){\n  assert( (validMask&~(NC_IsCheck|NC_PartIdx|NC_IdxExpr))==0 );\n  if( (pNC->ncFlags & validMask)!=0 ){\n    const char *zIn = \"partial index WHERE clauses\";\n    if( pNC->ncFlags & NC_IdxExpr )      zIn = \"index expressions\";\n#ifndef SQLITE_OMIT_CHECK\n    else if( pNC->ncFlags & NC_IsCheck ) zIn = \"CHECK constraints\";\n#endif\n    sqlite3ErrorMsg(pParse, \"%s prohibited in %s\", zMsg, zIn);\n  }\n}\n\n/*\n** Expression p should encode a floating point value between 1.0 and 0.0.\n** Return 1024 times this value.  Or return -1 if p is not a floating point\n** value between 1.0 and 0.0.\n*/\nstatic int exprProbability(Expr *p){\n  double r = -1.0;\n  if( p->op!=TK_FLOAT ) return -1;\n  sqlite3AtoF(p->u.zToken, &r, sqlite3Strlen30(p->u.zToken), SQLITE_UTF8);\n  assert( r>=0.0 );\n  if( r>1.0 ) return -1;\n  return (int)(r*134217728.0);\n}\n\n/*\n** This routine is callback for sqlite3WalkExpr().\n**\n** Resolve symbolic names into TK_COLUMN operators for the current\n** node in the expression tree.  Return 0 to continue the search down\n** the tree or 2 to abort the tree walk.\n**\n** This routine also does error checking and name resolution for\n** function names.  The operator for aggregate functions is changed\n** to TK_AGG_FUNCTION.\n*/\nstatic int resolveExprStep(Walker *pWalker, Expr *pExpr){\n  NameContext *pNC;\n  Parse *pParse;\n\n  pNC = pWalker->u.pNC;\n  assert( pNC!=0 );\n  pParse = pNC->pParse;\n  assert( pParse==pWalker->pParse );\n\n#ifndef NDEBUG\n  if( pNC->pSrcList && pNC->pSrcList->nAlloc>0 ){\n    SrcList *pSrcList = pNC->pSrcList;\n    int i;\n    for(i=0; i<pNC->pSrcList->nSrc; i++){\n      assert( pSrcList->a[i].iCursor>=0 && pSrcList->a[i].iCursor<pParse->nTab);\n    }\n  }\n#endif\n  switch( pExpr->op ){\n\n#if defined(SQLITE_ENABLE_UPDATE_DELETE_LIMIT) && !defined(SQLITE_OMIT_SUBQUERY)\n    /* The special operator TK_ROW means use the rowid for the first\n    ** column in the FROM clause.  This is used by the LIMIT and ORDER BY\n    ** clause processing on UPDATE and DELETE statements.\n    */\n    case TK_ROW: {\n      SrcList *pSrcList = pNC->pSrcList;\n      struct SrcList_item *pItem;\n      assert( pSrcList && pSrcList->nSrc==1 );\n      pItem = pSrcList->a;\n      assert( HasRowid(pItem->pTab) && pItem->pTab->pSelect==0 );\n      pExpr->op = TK_COLUMN;\n      pExpr->y.pTab = pItem->pTab;\n      pExpr->iTable = pItem->iCursor;\n      pExpr->iColumn = -1;\n      pExpr->affinity = SQLITE_AFF_INTEGER;\n      break;\n    }\n#endif /* defined(SQLITE_ENABLE_UPDATE_DELETE_LIMIT)\n          && !defined(SQLITE_OMIT_SUBQUERY) */\n\n    /* A column name:                    ID\n    ** Or table name and column name:    ID.ID\n    ** Or a database, table and column:  ID.ID.ID\n    **\n    ** The TK_ID and TK_OUT cases are combined so that there will only\n    ** be one call to lookupName().  Then the compiler will in-line \n    ** lookupName() for a size reduction and performance increase.\n    */\n    case TK_ID:\n    case TK_DOT: {\n      const char *zColumn;\n      const char *zTable;\n      const char *zDb;\n      Expr *pRight;\n\n      if( pExpr->op==TK_ID ){\n        zDb = 0;\n        zTable = 0;\n        zColumn = pExpr->u.zToken;\n      }else{\n        Expr *pLeft = pExpr->pLeft;\n        notValid(pParse, pNC, \"the \\\".\\\" operator\", NC_IdxExpr);\n        pRight = pExpr->pRight;\n        if( pRight->op==TK_ID ){\n          zDb = 0;\n        }else{\n          assert( pRight->op==TK_DOT );\n          zDb = pLeft->u.zToken;\n          pLeft = pRight->pLeft;\n          pRight = pRight->pRight;\n        }\n        zTable = pLeft->u.zToken;\n        zColumn = pRight->u.zToken;\n        if( IN_RENAME_OBJECT ){\n          sqlite3RenameTokenRemap(pParse, (void*)pExpr, (void*)pRight);\n          sqlite3RenameTokenRemap(pParse, (void*)&pExpr->y.pTab, (void*)pLeft);\n        }\n      }\n      return lookupName(pParse, zDb, zTable, zColumn, pNC, pExpr);\n    }\n\n    /* Resolve function names\n    */\n    case TK_FUNCTION: {\n      ExprList *pList = pExpr->x.pList;    /* The argument list */\n      int n = pList ? pList->nExpr : 0;    /* Number of arguments */\n      int no_such_func = 0;       /* True if no such function exists */\n      int wrong_num_args = 0;     /* True if wrong number of arguments */\n      int is_agg = 0;             /* True if is an aggregate function */\n      int nId;                    /* Number of characters in function name */\n      const char *zId;            /* The function name. */\n      FuncDef *pDef;              /* Information about the function */\n      u8 enc = ENC(pParse->db);   /* The database encoding */\n\n      assert( !ExprHasProperty(pExpr, EP_xIsSelect) );\n      zId = pExpr->u.zToken;\n      nId = sqlite3Strlen30(zId);\n      pDef = sqlite3FindFunction(pParse->db, zId, n, enc, 0);\n      if( pDef==0 ){\n        pDef = sqlite3FindFunction(pParse->db, zId, -2, enc, 0);\n        if( pDef==0 ){\n          no_such_func = 1;\n        }else{\n          wrong_num_args = 1;\n        }\n      }else{\n        is_agg = pDef->xFinalize!=0;\n        if( pDef->funcFlags & SQLITE_FUNC_UNLIKELY ){\n          ExprSetProperty(pExpr, EP_Unlikely|EP_Skip);\n          if( n==2 ){\n            pExpr->iTable = exprProbability(pList->a[1].pExpr);\n            if( pExpr->iTable<0 ){\n              sqlite3ErrorMsg(pParse,\n                \"second argument to likelihood() must be a \"\n                \"constant between 0.0 and 1.0\");\n              pNC->nErr++;\n            }\n          }else{\n            /* EVIDENCE-OF: R-61304-29449 The unlikely(X) function is\n            ** equivalent to likelihood(X, 0.0625).\n            ** EVIDENCE-OF: R-01283-11636 The unlikely(X) function is\n            ** short-hand for likelihood(X,0.0625).\n            ** EVIDENCE-OF: R-36850-34127 The likely(X) function is short-hand\n            ** for likelihood(X,0.9375).\n            ** EVIDENCE-OF: R-53436-40973 The likely(X) function is equivalent\n            ** to likelihood(X,0.9375). */\n            /* TUNING: unlikely() probability is 0.0625.  likely() is 0.9375 */\n            pExpr->iTable = pDef->zName[0]=='u' ? 8388608 : 125829120;\n          }             \n        }\n#ifndef SQLITE_OMIT_AUTHORIZATION\n        {\n          int auth = sqlite3AuthCheck(pParse, SQLITE_FUNCTION, 0,pDef->zName,0);\n          if( auth!=SQLITE_OK ){\n            if( auth==SQLITE_DENY ){\n              sqlite3ErrorMsg(pParse, \"not authorized to use function: %s\",\n                                      pDef->zName);\n              pNC->nErr++;\n            }\n            pExpr->op = TK_NULL;\n            return WRC_Prune;\n          }\n        }\n#endif\n        if( pDef->funcFlags & (SQLITE_FUNC_CONSTANT|SQLITE_FUNC_SLOCHNG) ){\n          /* For the purposes of the EP_ConstFunc flag, date and time\n          ** functions and other functions that change slowly are considered\n          ** constant because they are constant for the duration of one query */\n          ExprSetProperty(pExpr,EP_ConstFunc);\n        }\n        if( (pDef->funcFlags & SQLITE_FUNC_CONSTANT)==0 ){\n          /* Date/time functions that use 'now', and other functions like\n          ** sqlite_version() that might change over time cannot be used\n          ** in an index. */\n          notValid(pParse, pNC, \"non-deterministic functions\",\n                   NC_IdxExpr|NC_PartIdx);\n        }\n        if( (pDef->funcFlags & SQLITE_FUNC_INTERNAL)!=0\n         && pParse->nested==0\n         && sqlite3Config.bInternalFunctions==0\n        ){\n          /* Internal-use-only functions are disallowed unless the\n          ** SQL is being compiled using sqlite3NestedParse() */\n          no_such_func = 1;\n          pDef = 0;\n        }\n      }\n\n      if( 0==IN_RENAME_OBJECT ){\n#ifndef SQLITE_OMIT_WINDOWFUNC\n        assert( is_agg==0 || (pDef->funcFlags & SQLITE_FUNC_MINMAX)\n          || (pDef->xValue==0 && pDef->xInverse==0)\n          || (pDef->xValue && pDef->xInverse && pDef->xSFunc && pDef->xFinalize)\n        );\n        if( pDef && pDef->xValue==0 && ExprHasProperty(pExpr, EP_WinFunc) ){\n          sqlite3ErrorMsg(pParse, \n              \"%.*s() may not be used as a window function\", nId, zId\n          );\n          pNC->nErr++;\n        }else if( \n              (is_agg && (pNC->ncFlags & NC_AllowAgg)==0)\n           || (is_agg && (pDef->funcFlags&SQLITE_FUNC_WINDOW) && !pExpr->y.pWin)\n           || (is_agg && pExpr->y.pWin && (pNC->ncFlags & NC_AllowWin)==0)\n        ){\n          const char *zType;\n          if( (pDef->funcFlags & SQLITE_FUNC_WINDOW) || pExpr->y.pWin ){\n            zType = \"window\";\n          }else{\n            zType = \"aggregate\";\n          }\n          sqlite3ErrorMsg(pParse, \"misuse of %s function %.*s()\",zType,nId,zId);\n          pNC->nErr++;\n          is_agg = 0;\n        }\n#else\n        if( (is_agg && (pNC->ncFlags & NC_AllowAgg)==0) ){\n          sqlite3ErrorMsg(pParse,\"misuse of aggregate function %.*s()\",nId,zId);\n          pNC->nErr++;\n          is_agg = 0;\n        }\n#endif\n        else if( no_such_func && pParse->db->init.busy==0\n#ifdef SQLITE_ENABLE_UNKNOWN_SQL_FUNCTION\n                  && pParse->explain==0\n#endif\n        ){\n          sqlite3ErrorMsg(pParse, \"no such function: %.*s\", nId, zId);\n          pNC->nErr++;\n        }else if( wrong_num_args ){\n          sqlite3ErrorMsg(pParse,\"wrong number of arguments to function %.*s()\",\n               nId, zId);\n          pNC->nErr++;\n        }\n        if( is_agg ){\n#ifndef SQLITE_OMIT_WINDOWFUNC\n          pNC->ncFlags &= ~(pExpr->y.pWin ? NC_AllowWin : NC_AllowAgg);\n#else\n          pNC->ncFlags &= ~NC_AllowAgg;\n#endif\n        }\n      }\n      sqlite3WalkExprList(pWalker, pList);\n      if( is_agg ){\n#ifndef SQLITE_OMIT_WINDOWFUNC\n        if( pExpr->y.pWin ){\n          Select *pSel = pNC->pWinSelect;\n          sqlite3WindowUpdate(pParse, pSel->pWinDefn, pExpr->y.pWin, pDef);\n          sqlite3WalkExprList(pWalker, pExpr->y.pWin->pPartition);\n          sqlite3WalkExprList(pWalker, pExpr->y.pWin->pOrderBy);\n          sqlite3WalkExpr(pWalker, pExpr->y.pWin->pFilter);\n          if( 0==pSel->pWin \n           || 0==sqlite3WindowCompare(pParse, pSel->pWin, pExpr->y.pWin) \n          ){\n            pExpr->y.pWin->pNextWin = pSel->pWin;\n            pSel->pWin = pExpr->y.pWin;\n          }\n          pNC->ncFlags |= NC_AllowWin;\n        }else\n#endif /* SQLITE_OMIT_WINDOWFUNC */\n        {\n          NameContext *pNC2 = pNC;\n          pExpr->op = TK_AGG_FUNCTION;\n          pExpr->op2 = 0;\n          while( pNC2 && !sqlite3FunctionUsesThisSrc(pExpr, pNC2->pSrcList) ){\n            pExpr->op2++;\n            pNC2 = pNC2->pNext;\n          }\n          assert( pDef!=0 );\n          if( pNC2 ){\n            assert( SQLITE_FUNC_MINMAX==NC_MinMaxAgg );\n            testcase( (pDef->funcFlags & SQLITE_FUNC_MINMAX)!=0 );\n            pNC2->ncFlags |= NC_HasAgg | (pDef->funcFlags & SQLITE_FUNC_MINMAX);\n\n          }\n          pNC->ncFlags |= NC_AllowAgg;\n        }\n      }\n      /* FIX ME:  Compute pExpr->affinity based on the expected return\n      ** type of the function \n      */\n      return WRC_Prune;\n    }\n#ifndef SQLITE_OMIT_SUBQUERY\n    case TK_SELECT:\n    case TK_EXISTS:  testcase( pExpr->op==TK_EXISTS );\n#endif\n    case TK_IN: {\n      testcase( pExpr->op==TK_IN );\n      if( ExprHasProperty(pExpr, EP_xIsSelect) ){\n        int nRef = pNC->nRef;\n        notValid(pParse, pNC, \"subqueries\", NC_IsCheck|NC_PartIdx|NC_IdxExpr);\n        sqlite3WalkSelect(pWalker, pExpr->x.pSelect);\n        assert( pNC->nRef>=nRef );\n        if( nRef!=pNC->nRef ){\n          ExprSetProperty(pExpr, EP_VarSelect);\n          pNC->ncFlags |= NC_VarSelect;\n        }\n      }\n      break;\n    }\n    case TK_VARIABLE: {\n      notValid(pParse, pNC, \"parameters\", NC_IsCheck|NC_PartIdx|NC_IdxExpr);\n      break;\n    }\n    case TK_IS:\n    case TK_ISNOT: {\n      Expr *pRight;\n      assert( !ExprHasProperty(pExpr, EP_Reduced) );\n      /* Handle special cases of \"x IS TRUE\", \"x IS FALSE\", \"x IS NOT TRUE\",\n      ** and \"x IS NOT FALSE\". */\n      if( (pRight = pExpr->pRight)->op==TK_ID ){\n        int rc = resolveExprStep(pWalker, pRight);\n        if( rc==WRC_Abort ) return WRC_Abort;\n        if( pRight->op==TK_TRUEFALSE ){\n          pExpr->op2 = pExpr->op;\n          pExpr->op = TK_TRUTH;\n          return WRC_Continue;\n        }\n      }\n      /* Fall thru */\n    }\n    case TK_BETWEEN:\n    case TK_EQ:\n    case TK_NE:\n    case TK_LT:\n    case TK_LE:\n    case TK_GT:\n    case TK_GE: {\n      int nLeft, nRight;\n      if( pParse->db->mallocFailed ) break;\n      assert( pExpr->pLeft!=0 );\n      nLeft = sqlite3ExprVectorSize(pExpr->pLeft);\n      if( pExpr->op==TK_BETWEEN ){\n        nRight = sqlite3ExprVectorSize(pExpr->x.pList->a[0].pExpr);\n        if( nRight==nLeft ){\n          nRight = sqlite3ExprVectorSize(pExpr->x.pList->a[1].pExpr);\n        }\n      }else{\n        assert( pExpr->pRight!=0 );\n        nRight = sqlite3ExprVectorSize(pExpr->pRight);\n      }\n      if( nLeft!=nRight ){\n        testcase( pExpr->op==TK_EQ );\n        testcase( pExpr->op==TK_NE );\n        testcase( pExpr->op==TK_LT );\n        testcase( pExpr->op==TK_LE );\n        testcase( pExpr->op==TK_GT );\n        testcase( pExpr->op==TK_GE );\n        testcase( pExpr->op==TK_IS );\n        testcase( pExpr->op==TK_ISNOT );\n        testcase( pExpr->op==TK_BETWEEN );\n        sqlite3ErrorMsg(pParse, \"row value misused\");\n      }\n      break; \n    }\n  }\n  return (pParse->nErr || pParse->db->mallocFailed) ? WRC_Abort : WRC_Continue;\n}\n\n/*\n** pEList is a list of expressions which are really the result set of the\n** a SELECT statement.  pE is a term in an ORDER BY or GROUP BY clause.\n** This routine checks to see if pE is a simple identifier which corresponds\n** to the AS-name of one of the terms of the expression list.  If it is,\n** this routine return an integer between 1 and N where N is the number of\n** elements in pEList, corresponding to the matching entry.  If there is\n** no match, or if pE is not a simple identifier, then this routine\n** return 0.\n**\n** pEList has been resolved.  pE has not.\n*/\nstatic int resolveAsName(\n  Parse *pParse,     /* Parsing context for error messages */\n  ExprList *pEList,  /* List of expressions to scan */\n  Expr *pE           /* Expression we are trying to match */\n){\n  int i;             /* Loop counter */\n\n  UNUSED_PARAMETER(pParse);\n\n  if( pE->op==TK_ID ){\n    char *zCol = pE->u.zToken;\n    for(i=0; i<pEList->nExpr; i++){\n      char *zAs = pEList->a[i].zName;\n      if( zAs!=0 && sqlite3StrICmp(zAs, zCol)==0 ){\n        return i+1;\n      }\n    }\n  }\n  return 0;\n}\n\n/*\n** pE is a pointer to an expression which is a single term in the\n** ORDER BY of a compound SELECT.  The expression has not been\n** name resolved.\n**\n** At the point this routine is called, we already know that the\n** ORDER BY term is not an integer index into the result set.  That\n** case is handled by the calling routine.\n**\n** Attempt to match pE against result set columns in the left-most\n** SELECT statement.  Return the index i of the matching column,\n** as an indication to the caller that it should sort by the i-th column.\n** The left-most column is 1.  In other words, the value returned is the\n** same integer value that would be used in the SQL statement to indicate\n** the column.\n**\n** If there is no match, return 0.  Return -1 if an error occurs.\n*/\nstatic int resolveOrderByTermToExprList(\n  Parse *pParse,     /* Parsing context for error messages */\n  Select *pSelect,   /* The SELECT statement with the ORDER BY clause */\n  Expr *pE           /* The specific ORDER BY term */\n){\n  int i;             /* Loop counter */\n  ExprList *pEList;  /* The columns of the result set */\n  NameContext nc;    /* Name context for resolving pE */\n  sqlite3 *db;       /* Database connection */\n  int rc;            /* Return code from subprocedures */\n  u8 savedSuppErr;   /* Saved value of db->suppressErr */\n\n  assert( sqlite3ExprIsInteger(pE, &i)==0 );\n  pEList = pSelect->pEList;\n\n  /* Resolve all names in the ORDER BY term expression\n  */\n  memset(&nc, 0, sizeof(nc));\n  nc.pParse = pParse;\n  nc.pSrcList = pSelect->pSrc;\n  nc.uNC.pEList = pEList;\n  nc.ncFlags = NC_AllowAgg|NC_UEList;\n  nc.nErr = 0;\n  db = pParse->db;\n  savedSuppErr = db->suppressErr;\n  db->suppressErr = 1;\n  rc = sqlite3ResolveExprNames(&nc, pE);\n  db->suppressErr = savedSuppErr;\n  if( rc ) return 0;\n\n  /* Try to match the ORDER BY expression against an expression\n  ** in the result set.  Return an 1-based index of the matching\n  ** result-set entry.\n  */\n  for(i=0; i<pEList->nExpr; i++){\n    if( sqlite3ExprCompare(0, pEList->a[i].pExpr, pE, -1)<2 ){\n      return i+1;\n    }\n  }\n\n  /* If no match, return 0. */\n  return 0;\n}\n\n/*\n** Generate an ORDER BY or GROUP BY term out-of-range error.\n*/\nstatic void resolveOutOfRangeError(\n  Parse *pParse,         /* The error context into which to write the error */\n  const char *zType,     /* \"ORDER\" or \"GROUP\" */\n  int i,                 /* The index (1-based) of the term out of range */\n  int mx                 /* Largest permissible value of i */\n){\n  sqlite3ErrorMsg(pParse, \n    \"%r %s BY term out of range - should be \"\n    \"between 1 and %d\", i, zType, mx);\n}\n\n/*\n** Analyze the ORDER BY clause in a compound SELECT statement.   Modify\n** each term of the ORDER BY clause is a constant integer between 1\n** and N where N is the number of columns in the compound SELECT.\n**\n** ORDER BY terms that are already an integer between 1 and N are\n** unmodified.  ORDER BY terms that are integers outside the range of\n** 1 through N generate an error.  ORDER BY terms that are expressions\n** are matched against result set expressions of compound SELECT\n** beginning with the left-most SELECT and working toward the right.\n** At the first match, the ORDER BY expression is transformed into\n** the integer column number.\n**\n** Return the number of errors seen.\n*/\nstatic int resolveCompoundOrderBy(\n  Parse *pParse,        /* Parsing context.  Leave error messages here */\n  Select *pSelect       /* The SELECT statement containing the ORDER BY */\n){\n  int i;\n  ExprList *pOrderBy;\n  ExprList *pEList;\n  sqlite3 *db;\n  int moreToDo = 1;\n\n  pOrderBy = pSelect->pOrderBy;\n  if( pOrderBy==0 ) return 0;\n  db = pParse->db;\n  if( pOrderBy->nExpr>db->aLimit[SQLITE_LIMIT_COLUMN] ){\n    sqlite3ErrorMsg(pParse, \"too many terms in ORDER BY clause\");\n    return 1;\n  }\n  for(i=0; i<pOrderBy->nExpr; i++){\n    pOrderBy->a[i].done = 0;\n  }\n  pSelect->pNext = 0;\n  while( pSelect->pPrior ){\n    pSelect->pPrior->pNext = pSelect;\n    pSelect = pSelect->pPrior;\n  }\n  while( pSelect && moreToDo ){\n    struct ExprList_item *pItem;\n    moreToDo = 0;\n    pEList = pSelect->pEList;\n    assert( pEList!=0 );\n    for(i=0, pItem=pOrderBy->a; i<pOrderBy->nExpr; i++, pItem++){\n      int iCol = -1;\n      Expr *pE, *pDup;\n      if( pItem->done ) continue;\n      pE = sqlite3ExprSkipCollate(pItem->pExpr);\n      if( sqlite3ExprIsInteger(pE, &iCol) ){\n        if( iCol<=0 || iCol>pEList->nExpr ){\n          resolveOutOfRangeError(pParse, \"ORDER\", i+1, pEList->nExpr);\n          return 1;\n        }\n      }else{\n        iCol = resolveAsName(pParse, pEList, pE);\n        if( iCol==0 ){\n          /* Now test if expression pE matches one of the values returned\n          ** by pSelect. In the usual case this is done by duplicating the \n          ** expression, resolving any symbols in it, and then comparing\n          ** it against each expression returned by the SELECT statement.\n          ** Once the comparisons are finished, the duplicate expression\n          ** is deleted.\n          **\n          ** Or, if this is running as part of an ALTER TABLE operation,\n          ** resolve the symbols in the actual expression, not a duplicate.\n          ** And, if one of the comparisons is successful, leave the expression\n          ** as is instead of transforming it to an integer as in the usual\n          ** case. This allows the code in alter.c to modify column\n          ** refererences within the ORDER BY expression as required.  */\n          if( IN_RENAME_OBJECT ){\n            pDup = pE;\n          }else{\n            pDup = sqlite3ExprDup(db, pE, 0);\n          }\n          if( !db->mallocFailed ){\n            assert(pDup);\n            iCol = resolveOrderByTermToExprList(pParse, pSelect, pDup);\n          }\n          if( !IN_RENAME_OBJECT ){\n            sqlite3ExprDelete(db, pDup);\n          }\n        }\n      }\n      if( iCol>0 ){\n        /* Convert the ORDER BY term into an integer column number iCol,\n        ** taking care to preserve the COLLATE clause if it exists */\n        if( !IN_RENAME_OBJECT ){\n          Expr *pNew = sqlite3Expr(db, TK_INTEGER, 0);\n          if( pNew==0 ) return 1;\n          pNew->flags |= EP_IntValue;\n          pNew->u.iValue = iCol;\n          if( pItem->pExpr==pE ){\n            pItem->pExpr = pNew;\n          }else{\n            Expr *pParent = pItem->pExpr;\n            assert( pParent->op==TK_COLLATE );\n            while( pParent->pLeft->op==TK_COLLATE ) pParent = pParent->pLeft;\n            assert( pParent->pLeft==pE );\n            pParent->pLeft = pNew;\n          }\n          sqlite3ExprDelete(db, pE);\n          pItem->u.x.iOrderByCol = (u16)iCol;\n        }\n        pItem->done = 1;\n      }else{\n        moreToDo = 1;\n      }\n    }\n    pSelect = pSelect->pNext;\n  }\n  for(i=0; i<pOrderBy->nExpr; i++){\n    if( pOrderBy->a[i].done==0 ){\n      sqlite3ErrorMsg(pParse, \"%r ORDER BY term does not match any \"\n            \"column in the result set\", i+1);\n      return 1;\n    }\n  }\n  return 0;\n}\n\n/*\n** Check every term in the ORDER BY or GROUP BY clause pOrderBy of\n** the SELECT statement pSelect.  If any term is reference to a\n** result set expression (as determined by the ExprList.a.u.x.iOrderByCol\n** field) then convert that term into a copy of the corresponding result set\n** column.\n**\n** If any errors are detected, add an error message to pParse and\n** return non-zero.  Return zero if no errors are seen.\n*/\nSQLITE_PRIVATE int sqlite3ResolveOrderGroupBy(\n  Parse *pParse,        /* Parsing context.  Leave error messages here */\n  Select *pSelect,      /* The SELECT statement containing the clause */\n  ExprList *pOrderBy,   /* The ORDER BY or GROUP BY clause to be processed */\n  const char *zType     /* \"ORDER\" or \"GROUP\" */\n){\n  int i;\n  sqlite3 *db = pParse->db;\n  ExprList *pEList;\n  struct ExprList_item *pItem;\n\n  if( pOrderBy==0 || pParse->db->mallocFailed ) return 0;\n  if( pOrderBy->nExpr>db->aLimit[SQLITE_LIMIT_COLUMN] ){\n    sqlite3ErrorMsg(pParse, \"too many terms in %s BY clause\", zType);\n    return 1;\n  }\n  pEList = pSelect->pEList;\n  assert( pEList!=0 );  /* sqlite3SelectNew() guarantees this */\n  for(i=0, pItem=pOrderBy->a; i<pOrderBy->nExpr; i++, pItem++){\n    if( pItem->u.x.iOrderByCol ){\n      if( pItem->u.x.iOrderByCol>pEList->nExpr ){\n        resolveOutOfRangeError(pParse, zType, i+1, pEList->nExpr);\n        return 1;\n      }\n      resolveAlias(pParse, pEList, pItem->u.x.iOrderByCol-1, pItem->pExpr,\n                   zType,0);\n    }\n  }\n  return 0;\n}\n\n#ifndef SQLITE_OMIT_WINDOWFUNC\n/*\n** Walker callback for resolveRemoveWindows().\n*/\nstatic int resolveRemoveWindowsCb(Walker *pWalker, Expr *pExpr){\n  if( ExprHasProperty(pExpr, EP_WinFunc) ){\n    Window **pp;\n    for(pp=&pWalker->u.pSelect->pWin; *pp; pp=&(*pp)->pNextWin){\n      if( *pp==pExpr->y.pWin ){\n        *pp = (*pp)->pNextWin;\n        break;\n      }    \n    }\n  }\n  return WRC_Continue;\n}\n\n/*\n** Remove any Window objects owned by the expression pExpr from the\n** Select.pWin list of Select object pSelect.\n*/\nstatic void resolveRemoveWindows(Select *pSelect, Expr *pExpr){\n  Walker sWalker;\n  memset(&sWalker, 0, sizeof(Walker));\n  sWalker.xExprCallback = resolveRemoveWindowsCb;\n  sWalker.u.pSelect = pSelect;\n  sqlite3WalkExpr(&sWalker, pExpr);\n}\n#else\n# define resolveRemoveWindows(x,y)\n#endif\n\n/*\n** pOrderBy is an ORDER BY or GROUP BY clause in SELECT statement pSelect.\n** The Name context of the SELECT statement is pNC.  zType is either\n** \"ORDER\" or \"GROUP\" depending on which type of clause pOrderBy is.\n**\n** This routine resolves each term of the clause into an expression.\n** If the order-by term is an integer I between 1 and N (where N is the\n** number of columns in the result set of the SELECT) then the expression\n** in the resolution is a copy of the I-th result-set expression.  If\n** the order-by term is an identifier that corresponds to the AS-name of\n** a result-set expression, then the term resolves to a copy of the\n** result-set expression.  Otherwise, the expression is resolved in\n** the usual way - using sqlite3ResolveExprNames().\n**\n** This routine returns the number of errors.  If errors occur, then\n** an appropriate error message might be left in pParse.  (OOM errors\n** excepted.)\n*/\nstatic int resolveOrderGroupBy(\n  NameContext *pNC,     /* The name context of the SELECT statement */\n  Select *pSelect,      /* The SELECT statement holding pOrderBy */\n  ExprList *pOrderBy,   /* An ORDER BY or GROUP BY clause to resolve */\n  const char *zType     /* Either \"ORDER\" or \"GROUP\", as appropriate */\n){\n  int i, j;                      /* Loop counters */\n  int iCol;                      /* Column number */\n  struct ExprList_item *pItem;   /* A term of the ORDER BY clause */\n  Parse *pParse;                 /* Parsing context */\n  int nResult;                   /* Number of terms in the result set */\n\n  if( pOrderBy==0 ) return 0;\n  nResult = pSelect->pEList->nExpr;\n  pParse = pNC->pParse;\n  for(i=0, pItem=pOrderBy->a; i<pOrderBy->nExpr; i++, pItem++){\n    Expr *pE = pItem->pExpr;\n    Expr *pE2 = sqlite3ExprSkipCollate(pE);\n    if( zType[0]!='G' ){\n      iCol = resolveAsName(pParse, pSelect->pEList, pE2);\n      if( iCol>0 ){\n        /* If an AS-name match is found, mark this ORDER BY column as being\n        ** a copy of the iCol-th result-set column.  The subsequent call to\n        ** sqlite3ResolveOrderGroupBy() will convert the expression to a\n        ** copy of the iCol-th result-set expression. */\n        pItem->u.x.iOrderByCol = (u16)iCol;\n        continue;\n      }\n    }\n    if( sqlite3ExprIsInteger(pE2, &iCol) ){\n      /* The ORDER BY term is an integer constant.  Again, set the column\n      ** number so that sqlite3ResolveOrderGroupBy() will convert the\n      ** order-by term to a copy of the result-set expression */\n      if( iCol<1 || iCol>0xffff ){\n        resolveOutOfRangeError(pParse, zType, i+1, nResult);\n        return 1;\n      }\n      pItem->u.x.iOrderByCol = (u16)iCol;\n      continue;\n    }\n\n    /* Otherwise, treat the ORDER BY term as an ordinary expression */\n    pItem->u.x.iOrderByCol = 0;\n    if( sqlite3ResolveExprNames(pNC, pE) ){\n      return 1;\n    }\n    for(j=0; j<pSelect->pEList->nExpr; j++){\n      if( sqlite3ExprCompare(0, pE, pSelect->pEList->a[j].pExpr, -1)==0 ){\n        /* Since this expresion is being changed into a reference\n        ** to an identical expression in the result set, remove all Window\n        ** objects belonging to the expression from the Select.pWin list. */\n        resolveRemoveWindows(pSelect, pE);\n        pItem->u.x.iOrderByCol = j+1;\n      }\n    }\n  }\n  return sqlite3ResolveOrderGroupBy(pParse, pSelect, pOrderBy, zType);\n}\n\n/*\n** Resolve names in the SELECT statement p and all of its descendants.\n*/\nstatic int resolveSelectStep(Walker *pWalker, Select *p){\n  NameContext *pOuterNC;  /* Context that contains this SELECT */\n  NameContext sNC;        /* Name context of this SELECT */\n  int isCompound;         /* True if p is a compound select */\n  int nCompound;          /* Number of compound terms processed so far */\n  Parse *pParse;          /* Parsing context */\n  int i;                  /* Loop counter */\n  ExprList *pGroupBy;     /* The GROUP BY clause */\n  Select *pLeftmost;      /* Left-most of SELECT of a compound */\n  sqlite3 *db;            /* Database connection */\n  \n\n  assert( p!=0 );\n  if( p->selFlags & SF_Resolved ){\n    return WRC_Prune;\n  }\n  pOuterNC = pWalker->u.pNC;\n  pParse = pWalker->pParse;\n  db = pParse->db;\n\n  /* Normally sqlite3SelectExpand() will be called first and will have\n  ** already expanded this SELECT.  However, if this is a subquery within\n  ** an expression, sqlite3ResolveExprNames() will be called without a\n  ** prior call to sqlite3SelectExpand().  When that happens, let\n  ** sqlite3SelectPrep() do all of the processing for this SELECT.\n  ** sqlite3SelectPrep() will invoke both sqlite3SelectExpand() and\n  ** this routine in the correct order.\n  */\n  if( (p->selFlags & SF_Expanded)==0 ){\n    sqlite3SelectPrep(pParse, p, pOuterNC);\n    return (pParse->nErr || db->mallocFailed) ? WRC_Abort : WRC_Prune;\n  }\n\n  isCompound = p->pPrior!=0;\n  nCompound = 0;\n  pLeftmost = p;\n  while( p ){\n    assert( (p->selFlags & SF_Expanded)!=0 );\n    assert( (p->selFlags & SF_Resolved)==0 );\n    p->selFlags |= SF_Resolved;\n\n    /* Resolve the expressions in the LIMIT and OFFSET clauses. These\n    ** are not allowed to refer to any names, so pass an empty NameContext.\n    */\n    memset(&sNC, 0, sizeof(sNC));\n    sNC.pParse = pParse;\n    sNC.pWinSelect = p;\n    if( sqlite3ResolveExprNames(&sNC, p->pLimit) ){\n      return WRC_Abort;\n    }\n\n    /* If the SF_Converted flags is set, then this Select object was\n    ** was created by the convertCompoundSelectToSubquery() function.\n    ** In this case the ORDER BY clause (p->pOrderBy) should be resolved\n    ** as if it were part of the sub-query, not the parent. This block\n    ** moves the pOrderBy down to the sub-query. It will be moved back\n    ** after the names have been resolved.  */\n    if( p->selFlags & SF_Converted ){\n      Select *pSub = p->pSrc->a[0].pSelect;\n      assert( p->pSrc->nSrc==1 && p->pOrderBy );\n      assert( pSub->pPrior && pSub->pOrderBy==0 );\n      pSub->pOrderBy = p->pOrderBy;\n      p->pOrderBy = 0;\n    }\n  \n    /* Recursively resolve names in all subqueries\n    */\n    for(i=0; i<p->pSrc->nSrc; i++){\n      struct SrcList_item *pItem = &p->pSrc->a[i];\n      if( pItem->pSelect ){\n        NameContext *pNC;         /* Used to iterate name contexts */\n        int nRef = 0;             /* Refcount for pOuterNC and outer contexts */\n        const char *zSavedContext = pParse->zAuthContext;\n\n        /* Count the total number of references to pOuterNC and all of its\n        ** parent contexts. After resolving references to expressions in\n        ** pItem->pSelect, check if this value has changed. If so, then\n        ** SELECT statement pItem->pSelect must be correlated. Set the\n        ** pItem->fg.isCorrelated flag if this is the case. */\n        for(pNC=pOuterNC; pNC; pNC=pNC->pNext) nRef += pNC->nRef;\n\n        if( pItem->zName ) pParse->zAuthContext = pItem->zName;\n        sqlite3ResolveSelectNames(pParse, pItem->pSelect, pOuterNC);\n        pParse->zAuthContext = zSavedContext;\n        if( pParse->nErr || db->mallocFailed ) return WRC_Abort;\n\n        for(pNC=pOuterNC; pNC; pNC=pNC->pNext) nRef -= pNC->nRef;\n        assert( pItem->fg.isCorrelated==0 && nRef<=0 );\n        pItem->fg.isCorrelated = (nRef!=0);\n      }\n    }\n  \n    /* Set up the local name-context to pass to sqlite3ResolveExprNames() to\n    ** resolve the result-set expression list.\n    */\n    sNC.ncFlags = NC_AllowAgg|NC_AllowWin;\n    sNC.pSrcList = p->pSrc;\n    sNC.pNext = pOuterNC;\n  \n    /* Resolve names in the result set. */\n    if( sqlite3ResolveExprListNames(&sNC, p->pEList) ) return WRC_Abort;\n    sNC.ncFlags &= ~NC_AllowWin;\n  \n    /* If there are no aggregate functions in the result-set, and no GROUP BY \n    ** expression, do not allow aggregates in any of the other expressions.\n    */\n    assert( (p->selFlags & SF_Aggregate)==0 );\n    pGroupBy = p->pGroupBy;\n    if( pGroupBy || (sNC.ncFlags & NC_HasAgg)!=0 ){\n      assert( NC_MinMaxAgg==SF_MinMaxAgg );\n      p->selFlags |= SF_Aggregate | (sNC.ncFlags&NC_MinMaxAgg);\n    }else{\n      sNC.ncFlags &= ~NC_AllowAgg;\n    }\n  \n    /* If a HAVING clause is present, then there must be a GROUP BY clause.\n    */\n    if( p->pHaving && !pGroupBy ){\n      sqlite3ErrorMsg(pParse, \"a GROUP BY clause is required before HAVING\");\n      return WRC_Abort;\n    }\n  \n    /* Add the output column list to the name-context before parsing the\n    ** other expressions in the SELECT statement. This is so that\n    ** expressions in the WHERE clause (etc.) can refer to expressions by\n    ** aliases in the result set.\n    **\n    ** Minor point: If this is the case, then the expression will be\n    ** re-evaluated for each reference to it.\n    */\n    assert( (sNC.ncFlags & (NC_UAggInfo|NC_UUpsert))==0 );\n    sNC.uNC.pEList = p->pEList;\n    sNC.ncFlags |= NC_UEList;\n    if( sqlite3ResolveExprNames(&sNC, p->pHaving) ) return WRC_Abort;\n    if( sqlite3ResolveExprNames(&sNC, p->pWhere) ) return WRC_Abort;\n\n    /* Resolve names in table-valued-function arguments */\n    for(i=0; i<p->pSrc->nSrc; i++){\n      struct SrcList_item *pItem = &p->pSrc->a[i];\n      if( pItem->fg.isTabFunc\n       && sqlite3ResolveExprListNames(&sNC, pItem->u1.pFuncArg) \n      ){\n        return WRC_Abort;\n      }\n    }\n\n    /* The ORDER BY and GROUP BY clauses may not refer to terms in\n    ** outer queries \n    */\n    sNC.pNext = 0;\n    sNC.ncFlags |= NC_AllowAgg|NC_AllowWin;\n\n    /* If this is a converted compound query, move the ORDER BY clause from \n    ** the sub-query back to the parent query. At this point each term\n    ** within the ORDER BY clause has been transformed to an integer value.\n    ** These integers will be replaced by copies of the corresponding result\n    ** set expressions by the call to resolveOrderGroupBy() below.  */\n    if( p->selFlags & SF_Converted ){\n      Select *pSub = p->pSrc->a[0].pSelect;\n      p->pOrderBy = pSub->pOrderBy;\n      pSub->pOrderBy = 0;\n    }\n\n    /* Process the ORDER BY clause for singleton SELECT statements.\n    ** The ORDER BY clause for compounds SELECT statements is handled\n    ** below, after all of the result-sets for all of the elements of\n    ** the compound have been resolved.\n    **\n    ** If there is an ORDER BY clause on a term of a compound-select other\n    ** than the right-most term, then that is a syntax error.  But the error\n    ** is not detected until much later, and so we need to go ahead and\n    ** resolve those symbols on the incorrect ORDER BY for consistency.\n    */\n    if( isCompound<=nCompound  /* Defer right-most ORDER BY of a compound */\n     && resolveOrderGroupBy(&sNC, p, p->pOrderBy, \"ORDER\")\n    ){\n      return WRC_Abort;\n    }\n    if( db->mallocFailed ){\n      return WRC_Abort;\n    }\n    sNC.ncFlags &= ~NC_AllowWin;\n  \n    /* Resolve the GROUP BY clause.  At the same time, make sure \n    ** the GROUP BY clause does not contain aggregate functions.\n    */\n    if( pGroupBy ){\n      struct ExprList_item *pItem;\n    \n      if( resolveOrderGroupBy(&sNC, p, pGroupBy, \"GROUP\") || db->mallocFailed ){\n        return WRC_Abort;\n      }\n      for(i=0, pItem=pGroupBy->a; i<pGroupBy->nExpr; i++, pItem++){\n        if( ExprHasProperty(pItem->pExpr, EP_Agg) ){\n          sqlite3ErrorMsg(pParse, \"aggregate functions are not allowed in \"\n              \"the GROUP BY clause\");\n          return WRC_Abort;\n        }\n      }\n    }\n\n    if( IN_RENAME_OBJECT ){\n      Window *pWin;\n      for(pWin=p->pWinDefn; pWin; pWin=pWin->pNextWin){\n        if( sqlite3ResolveExprListNames(&sNC, pWin->pOrderBy)\n         || sqlite3ResolveExprListNames(&sNC, pWin->pPartition)\n        ){\n          return WRC_Abort;\n        }\n      }\n    }\n\n    /* If this is part of a compound SELECT, check that it has the right\n    ** number of expressions in the select list. */\n    if( p->pNext && p->pEList->nExpr!=p->pNext->pEList->nExpr ){\n      sqlite3SelectWrongNumTermsError(pParse, p->pNext);\n      return WRC_Abort;\n    }\n\n    /* Advance to the next term of the compound\n    */\n    p = p->pPrior;\n    nCompound++;\n  }\n\n  /* Resolve the ORDER BY on a compound SELECT after all terms of\n  ** the compound have been resolved.\n  */\n  if( isCompound && resolveCompoundOrderBy(pParse, pLeftmost) ){\n    return WRC_Abort;\n  }\n\n  return WRC_Prune;\n}\n\n/*\n** This routine walks an expression tree and resolves references to\n** table columns and result-set columns.  At the same time, do error\n** checking on function usage and set a flag if any aggregate functions\n** are seen.\n**\n** To resolve table columns references we look for nodes (or subtrees) of the \n** form X.Y.Z or Y.Z or just Z where\n**\n**      X:   The name of a database.  Ex:  \"main\" or \"temp\" or\n**           the symbolic name assigned to an ATTACH-ed database.\n**\n**      Y:   The name of a table in a FROM clause.  Or in a trigger\n**           one of the special names \"old\" or \"new\".\n**\n**      Z:   The name of a column in table Y.\n**\n** The node at the root of the subtree is modified as follows:\n**\n**    Expr.op        Changed to TK_COLUMN\n**    Expr.pTab      Points to the Table object for X.Y\n**    Expr.iColumn   The column index in X.Y.  -1 for the rowid.\n**    Expr.iTable    The VDBE cursor number for X.Y\n**\n**\n** To resolve result-set references, look for expression nodes of the\n** form Z (with no X and Y prefix) where the Z matches the right-hand\n** size of an AS clause in the result-set of a SELECT.  The Z expression\n** is replaced by a copy of the left-hand side of the result-set expression.\n** Table-name and function resolution occurs on the substituted expression\n** tree.  For example, in:\n**\n**      SELECT a+b AS x, c+d AS y FROM t1 ORDER BY x;\n**\n** The \"x\" term of the order by is replaced by \"a+b\" to render:\n**\n**      SELECT a+b AS x, c+d AS y FROM t1 ORDER BY a+b;\n**\n** Function calls are checked to make sure that the function is \n** defined and that the correct number of arguments are specified.\n** If the function is an aggregate function, then the NC_HasAgg flag is\n** set and the opcode is changed from TK_FUNCTION to TK_AGG_FUNCTION.\n** If an expression contains aggregate functions then the EP_Agg\n** property on the expression is set.\n**\n** An error message is left in pParse if anything is amiss.  The number\n** if errors is returned.\n*/\nSQLITE_PRIVATE int sqlite3ResolveExprNames( \n  NameContext *pNC,       /* Namespace to resolve expressions in. */\n  Expr *pExpr             /* The expression to be analyzed. */\n){\n  u16 savedHasAgg;\n  Walker w;\n\n  if( pExpr==0 ) return SQLITE_OK;\n  savedHasAgg = pNC->ncFlags & (NC_HasAgg|NC_MinMaxAgg);\n  pNC->ncFlags &= ~(NC_HasAgg|NC_MinMaxAgg);\n  w.pParse = pNC->pParse;\n  w.xExprCallback = resolveExprStep;\n  w.xSelectCallback = resolveSelectStep;\n  w.xSelectCallback2 = 0;\n  w.u.pNC = pNC;\n#if SQLITE_MAX_EXPR_DEPTH>0\n  w.pParse->nHeight += pExpr->nHeight;\n  if( sqlite3ExprCheckHeight(w.pParse, w.pParse->nHeight) ){\n    return SQLITE_ERROR;\n  }\n#endif\n  sqlite3WalkExpr(&w, pExpr);\n#if SQLITE_MAX_EXPR_DEPTH>0\n  w.pParse->nHeight -= pExpr->nHeight;\n#endif\n  if( pNC->ncFlags & NC_HasAgg ){\n    ExprSetProperty(pExpr, EP_Agg);\n  }\n  pNC->ncFlags |= savedHasAgg;\n  return pNC->nErr>0 || w.pParse->nErr>0;\n}\n\n/*\n** Resolve all names for all expression in an expression list.  This is\n** just like sqlite3ResolveExprNames() except that it works for an expression\n** list rather than a single expression.\n*/\nSQLITE_PRIVATE int sqlite3ResolveExprListNames( \n  NameContext *pNC,       /* Namespace to resolve expressions in. */\n  ExprList *pList         /* The expression list to be analyzed. */\n){\n  int i;\n  if( pList ){\n    for(i=0; i<pList->nExpr; i++){\n      if( sqlite3ResolveExprNames(pNC, pList->a[i].pExpr) ) return WRC_Abort;\n    }\n  }\n  return WRC_Continue;\n}\n\n/*\n** Resolve all names in all expressions of a SELECT and in all\n** decendents of the SELECT, including compounds off of p->pPrior,\n** subqueries in expressions, and subqueries used as FROM clause\n** terms.\n**\n** See sqlite3ResolveExprNames() for a description of the kinds of\n** transformations that occur.\n**\n** All SELECT statements should have been expanded using\n** sqlite3SelectExpand() prior to invoking this routine.\n*/\nSQLITE_PRIVATE void sqlite3ResolveSelectNames(\n  Parse *pParse,         /* The parser context */\n  Select *p,             /* The SELECT statement being coded. */\n  NameContext *pOuterNC  /* Name context for parent SELECT statement */\n){\n  Walker w;\n\n  assert( p!=0 );\n  w.xExprCallback = resolveExprStep;\n  w.xSelectCallback = resolveSelectStep;\n  w.xSelectCallback2 = 0;\n  w.pParse = pParse;\n  w.u.pNC = pOuterNC;\n  sqlite3WalkSelect(&w, p);\n}\n\n/*\n** Resolve names in expressions that can only reference a single table\n** or which cannot reference any tables at all.  Examples:\n**\n**    (1)   CHECK constraints\n**    (2)   WHERE clauses on partial indices\n**    (3)   Expressions in indexes on expressions\n**    (4)   Expression arguments to VACUUM INTO.\n**\n** In all cases except (4), the Expr.iTable value for Expr.op==TK_COLUMN\n** nodes of the expression is set to -1 and the Expr.iColumn value is\n** set to the column number.  In case (4), TK_COLUMN nodes cause an error.\n**\n** Any errors cause an error message to be set in pParse.\n*/\nSQLITE_PRIVATE int sqlite3ResolveSelfReference(\n  Parse *pParse,      /* Parsing context */\n  Table *pTab,        /* The table being referenced, or NULL */\n  int type,           /* NC_IsCheck or NC_PartIdx or NC_IdxExpr, or 0 */\n  Expr *pExpr,        /* Expression to resolve.  May be NULL. */\n  ExprList *pList     /* Expression list to resolve.  May be NULL. */\n){\n  SrcList sSrc;                   /* Fake SrcList for pParse->pNewTable */\n  NameContext sNC;                /* Name context for pParse->pNewTable */\n  int rc;\n\n  assert( type==0 || pTab!=0 );\n  assert( type==NC_IsCheck || type==NC_PartIdx || type==NC_IdxExpr || pTab==0 );\n  memset(&sNC, 0, sizeof(sNC));\n  memset(&sSrc, 0, sizeof(sSrc));\n  if( pTab ){\n    sSrc.nSrc = 1;\n    sSrc.a[0].zName = pTab->zName;\n    sSrc.a[0].pTab = pTab;\n    sSrc.a[0].iCursor = -1;\n  }\n  sNC.pParse = pParse;\n  sNC.pSrcList = &sSrc;\n  sNC.ncFlags = type;\n  if( (rc = sqlite3ResolveExprNames(&sNC, pExpr))!=SQLITE_OK ) return rc;\n  if( pList ) rc = sqlite3ResolveExprListNames(&sNC, pList);\n  return rc;\n}\n\n/************** End of resolve.c *********************************************/\n/************** Begin file expr.c ********************************************/\n/*\n** 2001 September 15\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This file contains routines used for analyzing expressions and\n** for generating VDBE code that evaluates expressions in SQLite.\n*/\n/* #include \"sqliteInt.h\" */\n\n/* Forward declarations */\nstatic void exprCodeBetween(Parse*,Expr*,int,void(*)(Parse*,Expr*,int,int),int);\nstatic int exprCodeVector(Parse *pParse, Expr *p, int *piToFree);\n\n/*\n** Return the affinity character for a single column of a table.\n*/\nSQLITE_PRIVATE char sqlite3TableColumnAffinity(Table *pTab, int iCol){\n  assert( iCol<pTab->nCol );\n  return iCol>=0 ? pTab->aCol[iCol].affinity : SQLITE_AFF_INTEGER;\n}\n\n/*\n** Return the 'affinity' of the expression pExpr if any.\n**\n** If pExpr is a column, a reference to a column via an 'AS' alias,\n** or a sub-select with a column as the return value, then the \n** affinity of that column is returned. Otherwise, 0x00 is returned,\n** indicating no affinity for the expression.\n**\n** i.e. the WHERE clause expressions in the following statements all\n** have an affinity:\n**\n** CREATE TABLE t1(a);\n** SELECT * FROM t1 WHERE a;\n** SELECT a AS b FROM t1 WHERE b;\n** SELECT * FROM t1 WHERE (select a from t1);\n*/\nSQLITE_PRIVATE char sqlite3ExprAffinity(Expr *pExpr){\n  int op;\n  pExpr = sqlite3ExprSkipCollate(pExpr);\n  if( pExpr->flags & EP_Generic ) return 0;\n  op = pExpr->op;\n  if( op==TK_SELECT ){\n    assert( pExpr->flags&EP_xIsSelect );\n    return sqlite3ExprAffinity(pExpr->x.pSelect->pEList->a[0].pExpr);\n  }\n  if( op==TK_REGISTER ) op = pExpr->op2;\n#ifndef SQLITE_OMIT_CAST\n  if( op==TK_CAST ){\n    assert( !ExprHasProperty(pExpr, EP_IntValue) );\n    return sqlite3AffinityType(pExpr->u.zToken, 0);\n  }\n#endif\n  if( (op==TK_AGG_COLUMN || op==TK_COLUMN) && pExpr->y.pTab ){\n    return sqlite3TableColumnAffinity(pExpr->y.pTab, pExpr->iColumn);\n  }\n  if( op==TK_SELECT_COLUMN ){\n    assert( pExpr->pLeft->flags&EP_xIsSelect );\n    return sqlite3ExprAffinity(\n        pExpr->pLeft->x.pSelect->pEList->a[pExpr->iColumn].pExpr\n    );\n  }\n  return pExpr->affinity;\n}\n\n/*\n** Set the collating sequence for expression pExpr to be the collating\n** sequence named by pToken.   Return a pointer to a new Expr node that\n** implements the COLLATE operator.\n**\n** If a memory allocation error occurs, that fact is recorded in pParse->db\n** and the pExpr parameter is returned unchanged.\n*/\nSQLITE_PRIVATE Expr *sqlite3ExprAddCollateToken(\n  Parse *pParse,           /* Parsing context */\n  Expr *pExpr,             /* Add the \"COLLATE\" clause to this expression */\n  const Token *pCollName,  /* Name of collating sequence */\n  int dequote              /* True to dequote pCollName */\n){\n  if( pCollName->n>0 ){\n    Expr *pNew = sqlite3ExprAlloc(pParse->db, TK_COLLATE, pCollName, dequote);\n    if( pNew ){\n      pNew->pLeft = pExpr;\n      pNew->flags |= EP_Collate|EP_Skip;\n      pExpr = pNew;\n    }\n  }\n  return pExpr;\n}\nSQLITE_PRIVATE Expr *sqlite3ExprAddCollateString(Parse *pParse, Expr *pExpr, const char *zC){\n  Token s;\n  assert( zC!=0 );\n  sqlite3TokenInit(&s, (char*)zC);\n  return sqlite3ExprAddCollateToken(pParse, pExpr, &s, 0);\n}\n\n/*\n** Skip over any TK_COLLATE operators and any unlikely()\n** or likelihood() function at the root of an expression.\n*/\nSQLITE_PRIVATE Expr *sqlite3ExprSkipCollate(Expr *pExpr){\n  while( pExpr && ExprHasProperty(pExpr, EP_Skip) ){\n    if( ExprHasProperty(pExpr, EP_Unlikely) ){\n      assert( !ExprHasProperty(pExpr, EP_xIsSelect) );\n      assert( pExpr->x.pList->nExpr>0 );\n      assert( pExpr->op==TK_FUNCTION );\n      pExpr = pExpr->x.pList->a[0].pExpr;\n    }else{\n      assert( pExpr->op==TK_COLLATE );\n      pExpr = pExpr->pLeft;\n    }\n  }   \n  return pExpr;\n}\n\n/*\n** Return the collation sequence for the expression pExpr. If\n** there is no defined collating sequence, return NULL.\n**\n** See also: sqlite3ExprNNCollSeq()\n**\n** The sqlite3ExprNNCollSeq() works the same exact that it returns the\n** default collation if pExpr has no defined collation.\n**\n** The collating sequence might be determined by a COLLATE operator\n** or by the presence of a column with a defined collating sequence.\n** COLLATE operators take first precedence.  Left operands take\n** precedence over right operands.\n*/\nSQLITE_PRIVATE CollSeq *sqlite3ExprCollSeq(Parse *pParse, Expr *pExpr){\n  sqlite3 *db = pParse->db;\n  CollSeq *pColl = 0;\n  Expr *p = pExpr;\n  while( p ){\n    int op = p->op;\n    if( p->flags & EP_Generic ) break;\n    if( op==TK_REGISTER ) op = p->op2;\n    if( (op==TK_AGG_COLUMN || op==TK_COLUMN || op==TK_TRIGGER)\n     && p->y.pTab!=0\n    ){\n      /* op==TK_REGISTER && p->y.pTab!=0 happens when pExpr was originally\n      ** a TK_COLUMN but was previously evaluated and cached in a register */\n      int j = p->iColumn;\n      if( j>=0 ){\n        const char *zColl = p->y.pTab->aCol[j].zColl;\n        pColl = sqlite3FindCollSeq(db, ENC(db), zColl, 0);\n      }\n      break;\n    }\n    if( op==TK_CAST || op==TK_UPLUS ){\n      p = p->pLeft;\n      continue;\n    }\n    if( op==TK_COLLATE ){\n      pColl = sqlite3GetCollSeq(pParse, ENC(db), 0, p->u.zToken);\n      break;\n    }\n    if( p->flags & EP_Collate ){\n      if( p->pLeft && (p->pLeft->flags & EP_Collate)!=0 ){\n        p = p->pLeft;\n      }else{\n        Expr *pNext  = p->pRight;\n        /* The Expr.x union is never used at the same time as Expr.pRight */\n        assert( p->x.pList==0 || p->pRight==0 );\n        /* p->flags holds EP_Collate and p->pLeft->flags does not.  And\n        ** p->x.pSelect cannot.  So if p->x.pLeft exists, it must hold at\n        ** least one EP_Collate. Thus the following two ALWAYS. */\n        if( p->x.pList!=0 && ALWAYS(!ExprHasProperty(p, EP_xIsSelect)) ){\n          int i;\n          for(i=0; ALWAYS(i<p->x.pList->nExpr); i++){\n            if( ExprHasProperty(p->x.pList->a[i].pExpr, EP_Collate) ){\n              pNext = p->x.pList->a[i].pExpr;\n              break;\n            }\n          }\n        }\n        p = pNext;\n      }\n    }else{\n      break;\n    }\n  }\n  if( sqlite3CheckCollSeq(pParse, pColl) ){ \n    pColl = 0;\n  }\n  return pColl;\n}\n\n/*\n** Return the collation sequence for the expression pExpr. If\n** there is no defined collating sequence, return a pointer to the\n** defautl collation sequence.\n**\n** See also: sqlite3ExprCollSeq()\n**\n** The sqlite3ExprCollSeq() routine works the same except that it\n** returns NULL if there is no defined collation.\n*/\nSQLITE_PRIVATE CollSeq *sqlite3ExprNNCollSeq(Parse *pParse, Expr *pExpr){\n  CollSeq *p = sqlite3ExprCollSeq(pParse, pExpr);\n  if( p==0 ) p = pParse->db->pDfltColl;\n  assert( p!=0 );\n  return p;\n}\n\n/*\n** Return TRUE if the two expressions have equivalent collating sequences.\n*/\nSQLITE_PRIVATE int sqlite3ExprCollSeqMatch(Parse *pParse, Expr *pE1, Expr *pE2){\n  CollSeq *pColl1 = sqlite3ExprNNCollSeq(pParse, pE1);\n  CollSeq *pColl2 = sqlite3ExprNNCollSeq(pParse, pE2);\n  return sqlite3StrICmp(pColl1->zName, pColl2->zName)==0;\n}\n\n/*\n** pExpr is an operand of a comparison operator.  aff2 is the\n** type affinity of the other operand.  This routine returns the\n** type affinity that should be used for the comparison operator.\n*/\nSQLITE_PRIVATE char sqlite3CompareAffinity(Expr *pExpr, char aff2){\n  char aff1 = sqlite3ExprAffinity(pExpr);\n  if( aff1 && aff2 ){\n    /* Both sides of the comparison are columns. If one has numeric\n    ** affinity, use that. Otherwise use no affinity.\n    */\n    if( sqlite3IsNumericAffinity(aff1) || sqlite3IsNumericAffinity(aff2) ){\n      return SQLITE_AFF_NUMERIC;\n    }else{\n      return SQLITE_AFF_BLOB;\n    }\n  }else if( !aff1 && !aff2 ){\n    /* Neither side of the comparison is a column.  Compare the\n    ** results directly.\n    */\n    return SQLITE_AFF_BLOB;\n  }else{\n    /* One side is a column, the other is not. Use the columns affinity. */\n    assert( aff1==0 || aff2==0 );\n    return (aff1 + aff2);\n  }\n}\n\n/*\n** pExpr is a comparison operator.  Return the type affinity that should\n** be applied to both operands prior to doing the comparison.\n*/\nstatic char comparisonAffinity(Expr *pExpr){\n  char aff;\n  assert( pExpr->op==TK_EQ || pExpr->op==TK_IN || pExpr->op==TK_LT ||\n          pExpr->op==TK_GT || pExpr->op==TK_GE || pExpr->op==TK_LE ||\n          pExpr->op==TK_NE || pExpr->op==TK_IS || pExpr->op==TK_ISNOT );\n  assert( pExpr->pLeft );\n  aff = sqlite3ExprAffinity(pExpr->pLeft);\n  if( pExpr->pRight ){\n    aff = sqlite3CompareAffinity(pExpr->pRight, aff);\n  }else if( ExprHasProperty(pExpr, EP_xIsSelect) ){\n    aff = sqlite3CompareAffinity(pExpr->x.pSelect->pEList->a[0].pExpr, aff);\n  }else if( aff==0 ){\n    aff = SQLITE_AFF_BLOB;\n  }\n  return aff;\n}\n\n/*\n** pExpr is a comparison expression, eg. '=', '<', IN(...) etc.\n** idx_affinity is the affinity of an indexed column. Return true\n** if the index with affinity idx_affinity may be used to implement\n** the comparison in pExpr.\n*/\nSQLITE_PRIVATE int sqlite3IndexAffinityOk(Expr *pExpr, char idx_affinity){\n  char aff = comparisonAffinity(pExpr);\n  switch( aff ){\n    case SQLITE_AFF_BLOB:\n      return 1;\n    case SQLITE_AFF_TEXT:\n      return idx_affinity==SQLITE_AFF_TEXT;\n    default:\n      return sqlite3IsNumericAffinity(idx_affinity);\n  }\n}\n\n/*\n** Return the P5 value that should be used for a binary comparison\n** opcode (OP_Eq, OP_Ge etc.) used to compare pExpr1 and pExpr2.\n*/\nstatic u8 binaryCompareP5(Expr *pExpr1, Expr *pExpr2, int jumpIfNull){\n  u8 aff = (char)sqlite3ExprAffinity(pExpr2);\n  aff = (u8)sqlite3CompareAffinity(pExpr1, aff) | (u8)jumpIfNull;\n  return aff;\n}\n\n/*\n** Return a pointer to the collation sequence that should be used by\n** a binary comparison operator comparing pLeft and pRight.\n**\n** If the left hand expression has a collating sequence type, then it is\n** used. Otherwise the collation sequence for the right hand expression\n** is used, or the default (BINARY) if neither expression has a collating\n** type.\n**\n** Argument pRight (but not pLeft) may be a null pointer. In this case,\n** it is not considered.\n*/\nSQLITE_PRIVATE CollSeq *sqlite3BinaryCompareCollSeq(\n  Parse *pParse, \n  Expr *pLeft, \n  Expr *pRight\n){\n  CollSeq *pColl;\n  assert( pLeft );\n  if( pLeft->flags & EP_Collate ){\n    pColl = sqlite3ExprCollSeq(pParse, pLeft);\n  }else if( pRight && (pRight->flags & EP_Collate)!=0 ){\n    pColl = sqlite3ExprCollSeq(pParse, pRight);\n  }else{\n    pColl = sqlite3ExprCollSeq(pParse, pLeft);\n    if( !pColl ){\n      pColl = sqlite3ExprCollSeq(pParse, pRight);\n    }\n  }\n  return pColl;\n}\n\n/*\n** Generate code for a comparison operator.\n*/\nstatic int codeCompare(\n  Parse *pParse,    /* The parsing (and code generating) context */\n  Expr *pLeft,      /* The left operand */\n  Expr *pRight,     /* The right operand */\n  int opcode,       /* The comparison opcode */\n  int in1, int in2, /* Register holding operands */\n  int dest,         /* Jump here if true.  */\n  int jumpIfNull    /* If true, jump if either operand is NULL */\n){\n  int p5;\n  int addr;\n  CollSeq *p4;\n\n  p4 = sqlite3BinaryCompareCollSeq(pParse, pLeft, pRight);\n  p5 = binaryCompareP5(pLeft, pRight, jumpIfNull);\n  addr = sqlite3VdbeAddOp4(pParse->pVdbe, opcode, in2, dest, in1,\n                           (void*)p4, P4_COLLSEQ);\n  sqlite3VdbeChangeP5(pParse->pVdbe, (u8)p5);\n  return addr;\n}\n\n/*\n** Return true if expression pExpr is a vector, or false otherwise.\n**\n** A vector is defined as any expression that results in two or more\n** columns of result.  Every TK_VECTOR node is an vector because the\n** parser will not generate a TK_VECTOR with fewer than two entries.\n** But a TK_SELECT might be either a vector or a scalar. It is only\n** considered a vector if it has two or more result columns.\n*/\nSQLITE_PRIVATE int sqlite3ExprIsVector(Expr *pExpr){\n  return sqlite3ExprVectorSize(pExpr)>1;\n}\n\n/*\n** If the expression passed as the only argument is of type TK_VECTOR \n** return the number of expressions in the vector. Or, if the expression\n** is a sub-select, return the number of columns in the sub-select. For\n** any other type of expression, return 1.\n*/\nSQLITE_PRIVATE int sqlite3ExprVectorSize(Expr *pExpr){\n  u8 op = pExpr->op;\n  if( op==TK_REGISTER ) op = pExpr->op2;\n  if( op==TK_VECTOR ){\n    return pExpr->x.pList->nExpr;\n  }else if( op==TK_SELECT ){\n    return pExpr->x.pSelect->pEList->nExpr;\n  }else{\n    return 1;\n  }\n}\n\n/*\n** Return a pointer to a subexpression of pVector that is the i-th\n** column of the vector (numbered starting with 0).  The caller must\n** ensure that i is within range.\n**\n** If pVector is really a scalar (and \"scalar\" here includes subqueries\n** that return a single column!) then return pVector unmodified.\n**\n** pVector retains ownership of the returned subexpression.\n**\n** If the vector is a (SELECT ...) then the expression returned is\n** just the expression for the i-th term of the result set, and may\n** not be ready for evaluation because the table cursor has not yet\n** been positioned.\n*/\nSQLITE_PRIVATE Expr *sqlite3VectorFieldSubexpr(Expr *pVector, int i){\n  assert( i<sqlite3ExprVectorSize(pVector) );\n  if( sqlite3ExprIsVector(pVector) ){\n    assert( pVector->op2==0 || pVector->op==TK_REGISTER );\n    if( pVector->op==TK_SELECT || pVector->op2==TK_SELECT ){\n      return pVector->x.pSelect->pEList->a[i].pExpr;\n    }else{\n      return pVector->x.pList->a[i].pExpr;\n    }\n  }\n  return pVector;\n}\n\n/*\n** Compute and return a new Expr object which when passed to\n** sqlite3ExprCode() will generate all necessary code to compute\n** the iField-th column of the vector expression pVector.\n**\n** It is ok for pVector to be a scalar (as long as iField==0).  \n** In that case, this routine works like sqlite3ExprDup().\n**\n** The caller owns the returned Expr object and is responsible for\n** ensuring that the returned value eventually gets freed.\n**\n** The caller retains ownership of pVector.  If pVector is a TK_SELECT,\n** then the returned object will reference pVector and so pVector must remain\n** valid for the life of the returned object.  If pVector is a TK_VECTOR\n** or a scalar expression, then it can be deleted as soon as this routine\n** returns.\n**\n** A trick to cause a TK_SELECT pVector to be deleted together with\n** the returned Expr object is to attach the pVector to the pRight field\n** of the returned TK_SELECT_COLUMN Expr object.\n*/\nSQLITE_PRIVATE Expr *sqlite3ExprForVectorField(\n  Parse *pParse,       /* Parsing context */\n  Expr *pVector,       /* The vector.  List of expressions or a sub-SELECT */\n  int iField           /* Which column of the vector to return */\n){\n  Expr *pRet;\n  if( pVector->op==TK_SELECT ){\n    assert( pVector->flags & EP_xIsSelect );\n    /* The TK_SELECT_COLUMN Expr node:\n    **\n    ** pLeft:           pVector containing TK_SELECT.  Not deleted.\n    ** pRight:          not used.  But recursively deleted.\n    ** iColumn:         Index of a column in pVector\n    ** iTable:          0 or the number of columns on the LHS of an assignment\n    ** pLeft->iTable:   First in an array of register holding result, or 0\n    **                  if the result is not yet computed.\n    **\n    ** sqlite3ExprDelete() specifically skips the recursive delete of\n    ** pLeft on TK_SELECT_COLUMN nodes.  But pRight is followed, so pVector\n    ** can be attached to pRight to cause this node to take ownership of\n    ** pVector.  Typically there will be multiple TK_SELECT_COLUMN nodes\n    ** with the same pLeft pointer to the pVector, but only one of them\n    ** will own the pVector.\n    */\n    pRet = sqlite3PExpr(pParse, TK_SELECT_COLUMN, 0, 0);\n    if( pRet ){\n      pRet->iColumn = iField;\n      pRet->pLeft = pVector;\n    }\n    assert( pRet==0 || pRet->iTable==0 );\n  }else{\n    if( pVector->op==TK_VECTOR ) pVector = pVector->x.pList->a[iField].pExpr;\n    pRet = sqlite3ExprDup(pParse->db, pVector, 0);\n    sqlite3RenameTokenRemap(pParse, pRet, pVector);\n  }\n  return pRet;\n}\n\n/*\n** If expression pExpr is of type TK_SELECT, generate code to evaluate\n** it. Return the register in which the result is stored (or, if the \n** sub-select returns more than one column, the first in an array\n** of registers in which the result is stored).\n**\n** If pExpr is not a TK_SELECT expression, return 0.\n*/\nstatic int exprCodeSubselect(Parse *pParse, Expr *pExpr){\n  int reg = 0;\n#ifndef SQLITE_OMIT_SUBQUERY\n  if( pExpr->op==TK_SELECT ){\n    reg = sqlite3CodeSubselect(pParse, pExpr);\n  }\n#endif\n  return reg;\n}\n\n/*\n** Argument pVector points to a vector expression - either a TK_VECTOR\n** or TK_SELECT that returns more than one column. This function returns\n** the register number of a register that contains the value of\n** element iField of the vector.\n**\n** If pVector is a TK_SELECT expression, then code for it must have \n** already been generated using the exprCodeSubselect() routine. In this\n** case parameter regSelect should be the first in an array of registers\n** containing the results of the sub-select. \n**\n** If pVector is of type TK_VECTOR, then code for the requested field\n** is generated. In this case (*pRegFree) may be set to the number of\n** a temporary register to be freed by the caller before returning.\n**\n** Before returning, output parameter (*ppExpr) is set to point to the\n** Expr object corresponding to element iElem of the vector.\n*/\nstatic int exprVectorRegister(\n  Parse *pParse,                  /* Parse context */\n  Expr *pVector,                  /* Vector to extract element from */\n  int iField,                     /* Field to extract from pVector */\n  int regSelect,                  /* First in array of registers */\n  Expr **ppExpr,                  /* OUT: Expression element */\n  int *pRegFree                   /* OUT: Temp register to free */\n){\n  u8 op = pVector->op;\n  assert( op==TK_VECTOR || op==TK_REGISTER || op==TK_SELECT );\n  if( op==TK_REGISTER ){\n    *ppExpr = sqlite3VectorFieldSubexpr(pVector, iField);\n    return pVector->iTable+iField;\n  }\n  if( op==TK_SELECT ){\n    *ppExpr = pVector->x.pSelect->pEList->a[iField].pExpr;\n     return regSelect+iField;\n  }\n  *ppExpr = pVector->x.pList->a[iField].pExpr;\n  return sqlite3ExprCodeTemp(pParse, *ppExpr, pRegFree);\n}\n\n/*\n** Expression pExpr is a comparison between two vector values. Compute\n** the result of the comparison (1, 0, or NULL) and write that\n** result into register dest.\n**\n** The caller must satisfy the following preconditions:\n**\n**    if pExpr->op==TK_IS:      op==TK_EQ and p5==SQLITE_NULLEQ\n**    if pExpr->op==TK_ISNOT:   op==TK_NE and p5==SQLITE_NULLEQ\n**    otherwise:                op==pExpr->op and p5==0\n*/\nstatic void codeVectorCompare(\n  Parse *pParse,        /* Code generator context */\n  Expr *pExpr,          /* The comparison operation */\n  int dest,             /* Write results into this register */\n  u8 op,                /* Comparison operator */\n  u8 p5                 /* SQLITE_NULLEQ or zero */\n){\n  Vdbe *v = pParse->pVdbe;\n  Expr *pLeft = pExpr->pLeft;\n  Expr *pRight = pExpr->pRight;\n  int nLeft = sqlite3ExprVectorSize(pLeft);\n  int i;\n  int regLeft = 0;\n  int regRight = 0;\n  u8 opx = op;\n  int addrDone = sqlite3VdbeMakeLabel(pParse);\n\n  if( nLeft!=sqlite3ExprVectorSize(pRight) ){\n    sqlite3ErrorMsg(pParse, \"row value misused\");\n    return;\n  }\n  assert( pExpr->op==TK_EQ || pExpr->op==TK_NE \n       || pExpr->op==TK_IS || pExpr->op==TK_ISNOT \n       || pExpr->op==TK_LT || pExpr->op==TK_GT \n       || pExpr->op==TK_LE || pExpr->op==TK_GE \n  );\n  assert( pExpr->op==op || (pExpr->op==TK_IS && op==TK_EQ)\n            || (pExpr->op==TK_ISNOT && op==TK_NE) );\n  assert( p5==0 || pExpr->op!=op );\n  assert( p5==SQLITE_NULLEQ || pExpr->op==op );\n\n  p5 |= SQLITE_STOREP2;\n  if( opx==TK_LE ) opx = TK_LT;\n  if( opx==TK_GE ) opx = TK_GT;\n\n  regLeft = exprCodeSubselect(pParse, pLeft);\n  regRight = exprCodeSubselect(pParse, pRight);\n\n  for(i=0; 1 /*Loop exits by \"break\"*/; i++){\n    int regFree1 = 0, regFree2 = 0;\n    Expr *pL, *pR; \n    int r1, r2;\n    assert( i>=0 && i<nLeft );\n    r1 = exprVectorRegister(pParse, pLeft, i, regLeft, &pL, &regFree1);\n    r2 = exprVectorRegister(pParse, pRight, i, regRight, &pR, &regFree2);\n    codeCompare(pParse, pL, pR, opx, r1, r2, dest, p5);\n    testcase(op==OP_Lt); VdbeCoverageIf(v,op==OP_Lt);\n    testcase(op==OP_Le); VdbeCoverageIf(v,op==OP_Le);\n    testcase(op==OP_Gt); VdbeCoverageIf(v,op==OP_Gt);\n    testcase(op==OP_Ge); VdbeCoverageIf(v,op==OP_Ge);\n    testcase(op==OP_Eq); VdbeCoverageIf(v,op==OP_Eq);\n    testcase(op==OP_Ne); VdbeCoverageIf(v,op==OP_Ne);\n    sqlite3ReleaseTempReg(pParse, regFree1);\n    sqlite3ReleaseTempReg(pParse, regFree2);\n    if( i==nLeft-1 ){\n      break;\n    }\n    if( opx==TK_EQ ){\n      sqlite3VdbeAddOp2(v, OP_IfNot, dest, addrDone); VdbeCoverage(v);\n      p5 |= SQLITE_KEEPNULL;\n    }else if( opx==TK_NE ){\n      sqlite3VdbeAddOp2(v, OP_If, dest, addrDone); VdbeCoverage(v);\n      p5 |= SQLITE_KEEPNULL;\n    }else{\n      assert( op==TK_LT || op==TK_GT || op==TK_LE || op==TK_GE );\n      sqlite3VdbeAddOp2(v, OP_ElseNotEq, 0, addrDone);\n      VdbeCoverageIf(v, op==TK_LT);\n      VdbeCoverageIf(v, op==TK_GT);\n      VdbeCoverageIf(v, op==TK_LE);\n      VdbeCoverageIf(v, op==TK_GE);\n      if( i==nLeft-2 ) opx = op;\n    }\n  }\n  sqlite3VdbeResolveLabel(v, addrDone);\n}\n\n#if SQLITE_MAX_EXPR_DEPTH>0\n/*\n** Check that argument nHeight is less than or equal to the maximum\n** expression depth allowed. If it is not, leave an error message in\n** pParse.\n*/\nSQLITE_PRIVATE int sqlite3ExprCheckHeight(Parse *pParse, int nHeight){\n  int rc = SQLITE_OK;\n  int mxHeight = pParse->db->aLimit[SQLITE_LIMIT_EXPR_DEPTH];\n  if( nHeight>mxHeight ){\n    sqlite3ErrorMsg(pParse, \n       \"Expression tree is too large (maximum depth %d)\", mxHeight\n    );\n    rc = SQLITE_ERROR;\n  }\n  return rc;\n}\n\n/* The following three functions, heightOfExpr(), heightOfExprList()\n** and heightOfSelect(), are used to determine the maximum height\n** of any expression tree referenced by the structure passed as the\n** first argument.\n**\n** If this maximum height is greater than the current value pointed\n** to by pnHeight, the second parameter, then set *pnHeight to that\n** value.\n*/\nstatic void heightOfExpr(Expr *p, int *pnHeight){\n  if( p ){\n    if( p->nHeight>*pnHeight ){\n      *pnHeight = p->nHeight;\n    }\n  }\n}\nstatic void heightOfExprList(ExprList *p, int *pnHeight){\n  if( p ){\n    int i;\n    for(i=0; i<p->nExpr; i++){\n      heightOfExpr(p->a[i].pExpr, pnHeight);\n    }\n  }\n}\nstatic void heightOfSelect(Select *pSelect, int *pnHeight){\n  Select *p;\n  for(p=pSelect; p; p=p->pPrior){\n    heightOfExpr(p->pWhere, pnHeight);\n    heightOfExpr(p->pHaving, pnHeight);\n    heightOfExpr(p->pLimit, pnHeight);\n    heightOfExprList(p->pEList, pnHeight);\n    heightOfExprList(p->pGroupBy, pnHeight);\n    heightOfExprList(p->pOrderBy, pnHeight);\n  }\n}\n\n/*\n** Set the Expr.nHeight variable in the structure passed as an \n** argument. An expression with no children, Expr.pList or \n** Expr.pSelect member has a height of 1. Any other expression\n** has a height equal to the maximum height of any other \n** referenced Expr plus one.\n**\n** Also propagate EP_Propagate flags up from Expr.x.pList to Expr.flags,\n** if appropriate.\n*/\nstatic void exprSetHeight(Expr *p){\n  int nHeight = 0;\n  heightOfExpr(p->pLeft, &nHeight);\n  heightOfExpr(p->pRight, &nHeight);\n  if( ExprHasProperty(p, EP_xIsSelect) ){\n    heightOfSelect(p->x.pSelect, &nHeight);\n  }else if( p->x.pList ){\n    heightOfExprList(p->x.pList, &nHeight);\n    p->flags |= EP_Propagate & sqlite3ExprListFlags(p->x.pList);\n  }\n  p->nHeight = nHeight + 1;\n}\n\n/*\n** Set the Expr.nHeight variable using the exprSetHeight() function. If\n** the height is greater than the maximum allowed expression depth,\n** leave an error in pParse.\n**\n** Also propagate all EP_Propagate flags from the Expr.x.pList into\n** Expr.flags. \n*/\nSQLITE_PRIVATE void sqlite3ExprSetHeightAndFlags(Parse *pParse, Expr *p){\n  if( pParse->nErr ) return;\n  exprSetHeight(p);\n  sqlite3ExprCheckHeight(pParse, p->nHeight);\n}\n\n/*\n** Return the maximum height of any expression tree referenced\n** by the select statement passed as an argument.\n*/\nSQLITE_PRIVATE int sqlite3SelectExprHeight(Select *p){\n  int nHeight = 0;\n  heightOfSelect(p, &nHeight);\n  return nHeight;\n}\n#else /* ABOVE:  Height enforcement enabled.  BELOW: Height enforcement off */\n/*\n** Propagate all EP_Propagate flags from the Expr.x.pList into\n** Expr.flags. \n*/\nSQLITE_PRIVATE void sqlite3ExprSetHeightAndFlags(Parse *pParse, Expr *p){\n  if( p && p->x.pList && !ExprHasProperty(p, EP_xIsSelect) ){\n    p->flags |= EP_Propagate & sqlite3ExprListFlags(p->x.pList);\n  }\n}\n#define exprSetHeight(y)\n#endif /* SQLITE_MAX_EXPR_DEPTH>0 */\n\n/*\n** This routine is the core allocator for Expr nodes.\n**\n** Construct a new expression node and return a pointer to it.  Memory\n** for this node and for the pToken argument is a single allocation\n** obtained from sqlite3DbMalloc().  The calling function\n** is responsible for making sure the node eventually gets freed.\n**\n** If dequote is true, then the token (if it exists) is dequoted.\n** If dequote is false, no dequoting is performed.  The deQuote\n** parameter is ignored if pToken is NULL or if the token does not\n** appear to be quoted.  If the quotes were of the form \"...\" (double-quotes)\n** then the EP_DblQuoted flag is set on the expression node.\n**\n** Special case:  If op==TK_INTEGER and pToken points to a string that\n** can be translated into a 32-bit integer, then the token is not\n** stored in u.zToken.  Instead, the integer values is written\n** into u.iValue and the EP_IntValue flag is set.  No extra storage\n** is allocated to hold the integer text and the dequote flag is ignored.\n*/\nSQLITE_PRIVATE Expr *sqlite3ExprAlloc(\n  sqlite3 *db,            /* Handle for sqlite3DbMallocRawNN() */\n  int op,                 /* Expression opcode */\n  const Token *pToken,    /* Token argument.  Might be NULL */\n  int dequote             /* True to dequote */\n){\n  Expr *pNew;\n  int nExtra = 0;\n  int iValue = 0;\n\n  assert( db!=0 );\n  if( pToken ){\n    if( op!=TK_INTEGER || pToken->z==0\n          || sqlite3GetInt32(pToken->z, &iValue)==0 ){\n      nExtra = pToken->n+1;\n      assert( iValue>=0 );\n    }\n  }\n  pNew = sqlite3DbMallocRawNN(db, sizeof(Expr)+nExtra);\n  if( pNew ){\n    memset(pNew, 0, sizeof(Expr));\n    pNew->op = (u8)op;\n    pNew->iAgg = -1;\n    if( pToken ){\n      if( nExtra==0 ){\n        pNew->flags |= EP_IntValue|EP_Leaf;\n        pNew->u.iValue = iValue;\n      }else{\n        pNew->u.zToken = (char*)&pNew[1];\n        assert( pToken->z!=0 || pToken->n==0 );\n        if( pToken->n ) memcpy(pNew->u.zToken, pToken->z, pToken->n);\n        pNew->u.zToken[pToken->n] = 0;\n        if( dequote && sqlite3Isquote(pNew->u.zToken[0]) ){\n          sqlite3DequoteExpr(pNew);\n        }\n      }\n    }\n#if SQLITE_MAX_EXPR_DEPTH>0\n    pNew->nHeight = 1;\n#endif  \n  }\n  return pNew;\n}\n\n/*\n** Allocate a new expression node from a zero-terminated token that has\n** already been dequoted.\n*/\nSQLITE_PRIVATE Expr *sqlite3Expr(\n  sqlite3 *db,            /* Handle for sqlite3DbMallocZero() (may be null) */\n  int op,                 /* Expression opcode */\n  const char *zToken      /* Token argument.  Might be NULL */\n){\n  Token x;\n  x.z = zToken;\n  x.n = sqlite3Strlen30(zToken);\n  return sqlite3ExprAlloc(db, op, &x, 0);\n}\n\n/*\n** Attach subtrees pLeft and pRight to the Expr node pRoot.\n**\n** If pRoot==NULL that means that a memory allocation error has occurred.\n** In that case, delete the subtrees pLeft and pRight.\n*/\nSQLITE_PRIVATE void sqlite3ExprAttachSubtrees(\n  sqlite3 *db,\n  Expr *pRoot,\n  Expr *pLeft,\n  Expr *pRight\n){\n  if( pRoot==0 ){\n    assert( db->mallocFailed );\n    sqlite3ExprDelete(db, pLeft);\n    sqlite3ExprDelete(db, pRight);\n  }else{\n    if( pRight ){\n      pRoot->pRight = pRight;\n      pRoot->flags |= EP_Propagate & pRight->flags;\n    }\n    if( pLeft ){\n      pRoot->pLeft = pLeft;\n      pRoot->flags |= EP_Propagate & pLeft->flags;\n    }\n    exprSetHeight(pRoot);\n  }\n}\n\n/*\n** Allocate an Expr node which joins as many as two subtrees.\n**\n** One or both of the subtrees can be NULL.  Return a pointer to the new\n** Expr node.  Or, if an OOM error occurs, set pParse->db->mallocFailed,\n** free the subtrees and return NULL.\n*/\nSQLITE_PRIVATE Expr *sqlite3PExpr(\n  Parse *pParse,          /* Parsing context */\n  int op,                 /* Expression opcode */\n  Expr *pLeft,            /* Left operand */\n  Expr *pRight            /* Right operand */\n){\n  Expr *p;\n  if( op==TK_AND && pParse->nErr==0 && !IN_RENAME_OBJECT ){\n    /* Take advantage of short-circuit false optimization for AND */\n    p = sqlite3ExprAnd(pParse->db, pLeft, pRight);\n  }else{\n    p = sqlite3DbMallocRawNN(pParse->db, sizeof(Expr));\n    if( p ){\n      memset(p, 0, sizeof(Expr));\n      p->op = op & TKFLG_MASK;\n      p->iAgg = -1;\n    }\n    sqlite3ExprAttachSubtrees(pParse->db, p, pLeft, pRight);\n  }\n  if( p ) {\n    sqlite3ExprCheckHeight(pParse, p->nHeight);\n  }\n  return p;\n}\n\n/*\n** Add pSelect to the Expr.x.pSelect field.  Or, if pExpr is NULL (due\n** do a memory allocation failure) then delete the pSelect object.\n*/\nSQLITE_PRIVATE void sqlite3PExprAddSelect(Parse *pParse, Expr *pExpr, Select *pSelect){\n  if( pExpr ){\n    pExpr->x.pSelect = pSelect;\n    ExprSetProperty(pExpr, EP_xIsSelect|EP_Subquery);\n    sqlite3ExprSetHeightAndFlags(pParse, pExpr);\n  }else{\n    assert( pParse->db->mallocFailed );\n    sqlite3SelectDelete(pParse->db, pSelect);\n  }\n}\n\n\n/*\n** If the expression is always either TRUE or FALSE (respectively),\n** then return 1.  If one cannot determine the truth value of the\n** expression at compile-time return 0.\n**\n** This is an optimization.  If is OK to return 0 here even if\n** the expression really is always false or false (a false negative).\n** But it is a bug to return 1 if the expression might have different\n** boolean values in different circumstances (a false positive.)\n**\n** Note that if the expression is part of conditional for a\n** LEFT JOIN, then we cannot determine at compile-time whether or not\n** is it true or false, so always return 0.\n*/\nstatic int exprAlwaysTrue(Expr *p){\n  int v = 0;\n  if( ExprHasProperty(p, EP_FromJoin) ) return 0;\n  if( !sqlite3ExprIsInteger(p, &v) ) return 0;\n  return v!=0;\n}\nstatic int exprAlwaysFalse(Expr *p){\n  int v = 0;\n  if( ExprHasProperty(p, EP_FromJoin) ) return 0;\n  if( !sqlite3ExprIsInteger(p, &v) ) return 0;\n  return v==0;\n}\n\n/*\n** Join two expressions using an AND operator.  If either expression is\n** NULL, then just return the other expression.\n**\n** If one side or the other of the AND is known to be false, then instead\n** of returning an AND expression, just return a constant expression with\n** a value of false.\n*/\nSQLITE_PRIVATE Expr *sqlite3ExprAnd(sqlite3 *db, Expr *pLeft, Expr *pRight){\n  if( pLeft==0 ){\n    return pRight;\n  }else if( pRight==0 ){\n    return pLeft;\n  }else if( exprAlwaysFalse(pLeft) || exprAlwaysFalse(pRight) ){\n    sqlite3ExprDelete(db, pLeft);\n    sqlite3ExprDelete(db, pRight);\n    return sqlite3ExprAlloc(db, TK_INTEGER, &sqlite3IntTokens[0], 0);\n  }else{\n    Expr *pNew = sqlite3ExprAlloc(db, TK_AND, 0, 0);\n    sqlite3ExprAttachSubtrees(db, pNew, pLeft, pRight);\n    return pNew;\n  }\n}\n\n/*\n** Construct a new expression node for a function with multiple\n** arguments.\n*/\nSQLITE_PRIVATE Expr *sqlite3ExprFunction(\n  Parse *pParse,        /* Parsing context */\n  ExprList *pList,      /* Argument list */\n  Token *pToken,        /* Name of the function */\n  int eDistinct         /* SF_Distinct or SF_ALL or 0 */\n){\n  Expr *pNew;\n  sqlite3 *db = pParse->db;\n  assert( pToken );\n  pNew = sqlite3ExprAlloc(db, TK_FUNCTION, pToken, 1);\n  if( pNew==0 ){\n    sqlite3ExprListDelete(db, pList); /* Avoid memory leak when malloc fails */\n    return 0;\n  }\n  if( pList && pList->nExpr > pParse->db->aLimit[SQLITE_LIMIT_FUNCTION_ARG] ){\n    sqlite3ErrorMsg(pParse, \"too many arguments on function %T\", pToken);\n  }\n  pNew->x.pList = pList;\n  ExprSetProperty(pNew, EP_HasFunc);\n  assert( !ExprHasProperty(pNew, EP_xIsSelect) );\n  sqlite3ExprSetHeightAndFlags(pParse, pNew);\n  if( eDistinct==SF_Distinct ) ExprSetProperty(pNew, EP_Distinct);\n  return pNew;\n}\n\n/*\n** Assign a variable number to an expression that encodes a wildcard\n** in the original SQL statement.  \n**\n** Wildcards consisting of a single \"?\" are assigned the next sequential\n** variable number.\n**\n** Wildcards of the form \"?nnn\" are assigned the number \"nnn\".  We make\n** sure \"nnn\" is not too big to avoid a denial of service attack when\n** the SQL statement comes from an external source.\n**\n** Wildcards of the form \":aaa\", \"@aaa\", or \"$aaa\" are assigned the same number\n** as the previous instance of the same wildcard.  Or if this is the first\n** instance of the wildcard, the next sequential variable number is\n** assigned.\n*/\nSQLITE_PRIVATE void sqlite3ExprAssignVarNumber(Parse *pParse, Expr *pExpr, u32 n){\n  sqlite3 *db = pParse->db;\n  const char *z;\n  ynVar x;\n\n  if( pExpr==0 ) return;\n  assert( !ExprHasProperty(pExpr, EP_IntValue|EP_Reduced|EP_TokenOnly) );\n  z = pExpr->u.zToken;\n  assert( z!=0 );\n  assert( z[0]!=0 );\n  assert( n==(u32)sqlite3Strlen30(z) );\n  if( z[1]==0 ){\n    /* Wildcard of the form \"?\".  Assign the next variable number */\n    assert( z[0]=='?' );\n    x = (ynVar)(++pParse->nVar);\n  }else{\n    int doAdd = 0;\n    if( z[0]=='?' ){\n      /* Wildcard of the form \"?nnn\".  Convert \"nnn\" to an integer and\n      ** use it as the variable number */\n      i64 i;\n      int bOk;\n      if( n==2 ){ /*OPTIMIZATION-IF-TRUE*/\n        i = z[1]-'0';  /* The common case of ?N for a single digit N */\n        bOk = 1;\n      }else{\n        bOk = 0==sqlite3Atoi64(&z[1], &i, n-1, SQLITE_UTF8);\n      }\n      testcase( i==0 );\n      testcase( i==1 );\n      testcase( i==db->aLimit[SQLITE_LIMIT_VARIABLE_NUMBER]-1 );\n      testcase( i==db->aLimit[SQLITE_LIMIT_VARIABLE_NUMBER] );\n      if( bOk==0 || i<1 || i>db->aLimit[SQLITE_LIMIT_VARIABLE_NUMBER] ){\n        sqlite3ErrorMsg(pParse, \"variable number must be between ?1 and ?%d\",\n            db->aLimit[SQLITE_LIMIT_VARIABLE_NUMBER]);\n        return;\n      }\n      x = (ynVar)i;\n      if( x>pParse->nVar ){\n        pParse->nVar = (int)x;\n        doAdd = 1;\n      }else if( sqlite3VListNumToName(pParse->pVList, x)==0 ){\n        doAdd = 1;\n      }\n    }else{\n      /* Wildcards like \":aaa\", \"$aaa\" or \"@aaa\".  Reuse the same variable\n      ** number as the prior appearance of the same name, or if the name\n      ** has never appeared before, reuse the same variable number\n      */\n      x = (ynVar)sqlite3VListNameToNum(pParse->pVList, z, n);\n      if( x==0 ){\n        x = (ynVar)(++pParse->nVar);\n        doAdd = 1;\n      }\n    }\n    if( doAdd ){\n      pParse->pVList = sqlite3VListAdd(db, pParse->pVList, z, n, x);\n    }\n  }\n  pExpr->iColumn = x;\n  if( x>db->aLimit[SQLITE_LIMIT_VARIABLE_NUMBER] ){\n    sqlite3ErrorMsg(pParse, \"too many SQL variables\");\n  }\n}\n\n/*\n** Recursively delete an expression tree.\n*/\nstatic SQLITE_NOINLINE void sqlite3ExprDeleteNN(sqlite3 *db, Expr *p){\n  assert( p!=0 );\n  /* Sanity check: Assert that the IntValue is non-negative if it exists */\n  assert( !ExprHasProperty(p, EP_IntValue) || p->u.iValue>=0 );\n\n  assert( !ExprHasProperty(p, EP_WinFunc) || p->y.pWin!=0 || db->mallocFailed );\n  assert( p->op!=TK_FUNCTION || ExprHasProperty(p, EP_TokenOnly|EP_Reduced)\n          || p->y.pWin==0 || ExprHasProperty(p, EP_WinFunc) );\n#ifdef SQLITE_DEBUG\n  if( ExprHasProperty(p, EP_Leaf) && !ExprHasProperty(p, EP_TokenOnly) ){\n    assert( p->pLeft==0 );\n    assert( p->pRight==0 );\n    assert( p->x.pSelect==0 );\n  }\n#endif\n  if( !ExprHasProperty(p, (EP_TokenOnly|EP_Leaf)) ){\n    /* The Expr.x union is never used at the same time as Expr.pRight */\n    assert( p->x.pList==0 || p->pRight==0 );\n    if( p->pLeft && p->op!=TK_SELECT_COLUMN ) sqlite3ExprDeleteNN(db, p->pLeft);\n    if( p->pRight ){\n      sqlite3ExprDeleteNN(db, p->pRight);\n    }else if( ExprHasProperty(p, EP_xIsSelect) ){\n      sqlite3SelectDelete(db, p->x.pSelect);\n    }else{\n      sqlite3ExprListDelete(db, p->x.pList);\n    }\n    if( ExprHasProperty(p, EP_WinFunc) ){\n      assert( p->op==TK_FUNCTION );\n      sqlite3WindowDelete(db, p->y.pWin);\n    }\n  }\n  if( ExprHasProperty(p, EP_MemToken) ) sqlite3DbFree(db, p->u.zToken);\n  if( !ExprHasProperty(p, EP_Static) ){\n    sqlite3DbFreeNN(db, p);\n  }\n}\nSQLITE_PRIVATE void sqlite3ExprDelete(sqlite3 *db, Expr *p){\n  if( p ) sqlite3ExprDeleteNN(db, p);\n}\n\n/*\n** Return the number of bytes allocated for the expression structure \n** passed as the first argument. This is always one of EXPR_FULLSIZE,\n** EXPR_REDUCEDSIZE or EXPR_TOKENONLYSIZE.\n*/\nstatic int exprStructSize(Expr *p){\n  if( ExprHasProperty(p, EP_TokenOnly) ) return EXPR_TOKENONLYSIZE;\n  if( ExprHasProperty(p, EP_Reduced) ) return EXPR_REDUCEDSIZE;\n  return EXPR_FULLSIZE;\n}\n\n/*\n** Copy the complete content of an Expr node, taking care not to read\n** past the end of the structure for a reduced-size version of the source\n** Expr.\n*/\nstatic void exprNodeCopy(Expr *pDest, Expr *pSrc){\n  memset(pDest, 0, sizeof(Expr));\n  memcpy(pDest, pSrc, exprStructSize(pSrc));\n}\n\n/*\n** The dupedExpr*Size() routines each return the number of bytes required\n** to store a copy of an expression or expression tree.  They differ in\n** how much of the tree is measured.\n**\n**     dupedExprStructSize()     Size of only the Expr structure \n**     dupedExprNodeSize()       Size of Expr + space for token\n**     dupedExprSize()           Expr + token + subtree components\n**\n***************************************************************************\n**\n** The dupedExprStructSize() function returns two values OR-ed together:  \n** (1) the space required for a copy of the Expr structure only and \n** (2) the EP_xxx flags that indicate what the structure size should be.\n** The return values is always one of:\n**\n**      EXPR_FULLSIZE\n**      EXPR_REDUCEDSIZE   | EP_Reduced\n**      EXPR_TOKENONLYSIZE | EP_TokenOnly\n**\n** The size of the structure can be found by masking the return value\n** of this routine with 0xfff.  The flags can be found by masking the\n** return value with EP_Reduced|EP_TokenOnly.\n**\n** Note that with flags==EXPRDUP_REDUCE, this routines works on full-size\n** (unreduced) Expr objects as they or originally constructed by the parser.\n** During expression analysis, extra information is computed and moved into\n** later parts of the Expr object and that extra information might get chopped\n** off if the expression is reduced.  Note also that it does not work to\n** make an EXPRDUP_REDUCE copy of a reduced expression.  It is only legal\n** to reduce a pristine expression tree from the parser.  The implementation\n** of dupedExprStructSize() contain multiple assert() statements that attempt\n** to enforce this constraint.\n*/\nstatic int dupedExprStructSize(Expr *p, int flags){\n  int nSize;\n  assert( flags==EXPRDUP_REDUCE || flags==0 ); /* Only one flag value allowed */\n  assert( EXPR_FULLSIZE<=0xfff );\n  assert( (0xfff & (EP_Reduced|EP_TokenOnly))==0 );\n  if( 0==flags || p->op==TK_SELECT_COLUMN \n#ifndef SQLITE_OMIT_WINDOWFUNC\n   || ExprHasProperty(p, EP_WinFunc)\n#endif\n  ){\n    nSize = EXPR_FULLSIZE;\n  }else{\n    assert( !ExprHasProperty(p, EP_TokenOnly|EP_Reduced) );\n    assert( !ExprHasProperty(p, EP_FromJoin) ); \n    assert( !ExprHasProperty(p, EP_MemToken) );\n    assert( !ExprHasProperty(p, EP_NoReduce) );\n    if( p->pLeft || p->x.pList ){\n      nSize = EXPR_REDUCEDSIZE | EP_Reduced;\n    }else{\n      assert( p->pRight==0 );\n      nSize = EXPR_TOKENONLYSIZE | EP_TokenOnly;\n    }\n  }\n  return nSize;\n}\n\n/*\n** This function returns the space in bytes required to store the copy \n** of the Expr structure and a copy of the Expr.u.zToken string (if that\n** string is defined.)\n*/\nstatic int dupedExprNodeSize(Expr *p, int flags){\n  int nByte = dupedExprStructSize(p, flags) & 0xfff;\n  if( !ExprHasProperty(p, EP_IntValue) && p->u.zToken ){\n    nByte += sqlite3Strlen30NN(p->u.zToken)+1;\n  }\n  return ROUND8(nByte);\n}\n\n/*\n** Return the number of bytes required to create a duplicate of the \n** expression passed as the first argument. The second argument is a\n** mask containing EXPRDUP_XXX flags.\n**\n** The value returned includes space to create a copy of the Expr struct\n** itself and the buffer referred to by Expr.u.zToken, if any.\n**\n** If the EXPRDUP_REDUCE flag is set, then the return value includes \n** space to duplicate all Expr nodes in the tree formed by Expr.pLeft \n** and Expr.pRight variables (but not for any structures pointed to or \n** descended from the Expr.x.pList or Expr.x.pSelect variables).\n*/\nstatic int dupedExprSize(Expr *p, int flags){\n  int nByte = 0;\n  if( p ){\n    nByte = dupedExprNodeSize(p, flags);\n    if( flags&EXPRDUP_REDUCE ){\n      nByte += dupedExprSize(p->pLeft, flags) + dupedExprSize(p->pRight, flags);\n    }\n  }\n  return nByte;\n}\n\n/*\n** This function is similar to sqlite3ExprDup(), except that if pzBuffer \n** is not NULL then *pzBuffer is assumed to point to a buffer large enough \n** to store the copy of expression p, the copies of p->u.zToken\n** (if applicable), and the copies of the p->pLeft and p->pRight expressions,\n** if any. Before returning, *pzBuffer is set to the first byte past the\n** portion of the buffer copied into by this function.\n*/\nstatic Expr *exprDup(sqlite3 *db, Expr *p, int dupFlags, u8 **pzBuffer){\n  Expr *pNew;           /* Value to return */\n  u8 *zAlloc;           /* Memory space from which to build Expr object */\n  u32 staticFlag;       /* EP_Static if space not obtained from malloc */\n\n  assert( db!=0 );\n  assert( p );\n  assert( dupFlags==0 || dupFlags==EXPRDUP_REDUCE );\n  assert( pzBuffer==0 || dupFlags==EXPRDUP_REDUCE );\n\n  /* Figure out where to write the new Expr structure. */\n  if( pzBuffer ){\n    zAlloc = *pzBuffer;\n    staticFlag = EP_Static;\n  }else{\n    zAlloc = sqlite3DbMallocRawNN(db, dupedExprSize(p, dupFlags));\n    staticFlag = 0;\n  }\n  pNew = (Expr *)zAlloc;\n\n  if( pNew ){\n    /* Set nNewSize to the size allocated for the structure pointed to\n    ** by pNew. This is either EXPR_FULLSIZE, EXPR_REDUCEDSIZE or\n    ** EXPR_TOKENONLYSIZE. nToken is set to the number of bytes consumed\n    ** by the copy of the p->u.zToken string (if any).\n    */\n    const unsigned nStructSize = dupedExprStructSize(p, dupFlags);\n    const int nNewSize = nStructSize & 0xfff;\n    int nToken;\n    if( !ExprHasProperty(p, EP_IntValue) && p->u.zToken ){\n      nToken = sqlite3Strlen30(p->u.zToken) + 1;\n    }else{\n      nToken = 0;\n    }\n    if( dupFlags ){\n      assert( ExprHasProperty(p, EP_Reduced)==0 );\n      memcpy(zAlloc, p, nNewSize);\n    }else{\n      u32 nSize = (u32)exprStructSize(p);\n      memcpy(zAlloc, p, nSize);\n      if( nSize<EXPR_FULLSIZE ){ \n        memset(&zAlloc[nSize], 0, EXPR_FULLSIZE-nSize);\n      }\n    }\n\n    /* Set the EP_Reduced, EP_TokenOnly, and EP_Static flags appropriately. */\n    pNew->flags &= ~(EP_Reduced|EP_TokenOnly|EP_Static|EP_MemToken);\n    pNew->flags |= nStructSize & (EP_Reduced|EP_TokenOnly);\n    pNew->flags |= staticFlag;\n\n    /* Copy the p->u.zToken string, if any. */\n    if( nToken ){\n      char *zToken = pNew->u.zToken = (char*)&zAlloc[nNewSize];\n      memcpy(zToken, p->u.zToken, nToken);\n    }\n\n    if( 0==((p->flags|pNew->flags) & (EP_TokenOnly|EP_Leaf)) ){\n      /* Fill in the pNew->x.pSelect or pNew->x.pList member. */\n      if( ExprHasProperty(p, EP_xIsSelect) ){\n        pNew->x.pSelect = sqlite3SelectDup(db, p->x.pSelect, dupFlags);\n      }else{\n        pNew->x.pList = sqlite3ExprListDup(db, p->x.pList, dupFlags);\n      }\n    }\n\n    /* Fill in pNew->pLeft and pNew->pRight. */\n    if( ExprHasProperty(pNew, EP_Reduced|EP_TokenOnly|EP_WinFunc) ){\n      zAlloc += dupedExprNodeSize(p, dupFlags);\n      if( !ExprHasProperty(pNew, EP_TokenOnly|EP_Leaf) ){\n        pNew->pLeft = p->pLeft ?\n                      exprDup(db, p->pLeft, EXPRDUP_REDUCE, &zAlloc) : 0;\n        pNew->pRight = p->pRight ?\n                       exprDup(db, p->pRight, EXPRDUP_REDUCE, &zAlloc) : 0;\n      }\n#ifndef SQLITE_OMIT_WINDOWFUNC\n      if( ExprHasProperty(p, EP_WinFunc) ){\n        pNew->y.pWin = sqlite3WindowDup(db, pNew, p->y.pWin);\n        assert( ExprHasProperty(pNew, EP_WinFunc) );\n      }\n#endif /* SQLITE_OMIT_WINDOWFUNC */\n      if( pzBuffer ){\n        *pzBuffer = zAlloc;\n      }\n    }else{\n      if( !ExprHasProperty(p, EP_TokenOnly|EP_Leaf) ){\n        if( pNew->op==TK_SELECT_COLUMN ){\n          pNew->pLeft = p->pLeft;\n          assert( p->iColumn==0 || p->pRight==0 );\n          assert( p->pRight==0  || p->pRight==p->pLeft );\n        }else{\n          pNew->pLeft = sqlite3ExprDup(db, p->pLeft, 0);\n        }\n        pNew->pRight = sqlite3ExprDup(db, p->pRight, 0);\n      }\n    }\n  }\n  return pNew;\n}\n\n/*\n** Create and return a deep copy of the object passed as the second \n** argument. If an OOM condition is encountered, NULL is returned\n** and the db->mallocFailed flag set.\n*/\n#ifndef SQLITE_OMIT_CTE\nstatic With *withDup(sqlite3 *db, With *p){\n  With *pRet = 0;\n  if( p ){\n    int nByte = sizeof(*p) + sizeof(p->a[0]) * (p->nCte-1);\n    pRet = sqlite3DbMallocZero(db, nByte);\n    if( pRet ){\n      int i;\n      pRet->nCte = p->nCte;\n      for(i=0; i<p->nCte; i++){\n        pRet->a[i].pSelect = sqlite3SelectDup(db, p->a[i].pSelect, 0);\n        pRet->a[i].pCols = sqlite3ExprListDup(db, p->a[i].pCols, 0);\n        pRet->a[i].zName = sqlite3DbStrDup(db, p->a[i].zName);\n      }\n    }\n  }\n  return pRet;\n}\n#else\n# define withDup(x,y) 0\n#endif\n\n#ifndef SQLITE_OMIT_WINDOWFUNC\n/*\n** The gatherSelectWindows() procedure and its helper routine\n** gatherSelectWindowsCallback() are used to scan all the expressions\n** an a newly duplicated SELECT statement and gather all of the Window\n** objects found there, assembling them onto the linked list at Select->pWin.\n*/\nstatic int gatherSelectWindowsCallback(Walker *pWalker, Expr *pExpr){\n  if( pExpr->op==TK_FUNCTION && pExpr->y.pWin!=0 ){\n    assert( ExprHasProperty(pExpr, EP_WinFunc) );\n    pExpr->y.pWin->pNextWin = pWalker->u.pSelect->pWin;\n    pWalker->u.pSelect->pWin = pExpr->y.pWin;\n  }\n  return WRC_Continue;\n}\nstatic int gatherSelectWindowsSelectCallback(Walker *pWalker, Select *p){\n  return p==pWalker->u.pSelect ? WRC_Continue : WRC_Prune;\n}\nstatic void gatherSelectWindows(Select *p){\n  Walker w;\n  w.xExprCallback = gatherSelectWindowsCallback;\n  w.xSelectCallback = gatherSelectWindowsSelectCallback;\n  w.xSelectCallback2 = 0;\n  w.pParse = 0;\n  w.u.pSelect = p;\n  sqlite3WalkSelect(&w, p);\n}\n#endif\n\n\n/*\n** The following group of routines make deep copies of expressions,\n** expression lists, ID lists, and select statements.  The copies can\n** be deleted (by being passed to their respective ...Delete() routines)\n** without effecting the originals.\n**\n** The expression list, ID, and source lists return by sqlite3ExprListDup(),\n** sqlite3IdListDup(), and sqlite3SrcListDup() can not be further expanded \n** by subsequent calls to sqlite*ListAppend() routines.\n**\n** Any tables that the SrcList might point to are not duplicated.\n**\n** The flags parameter contains a combination of the EXPRDUP_XXX flags.\n** If the EXPRDUP_REDUCE flag is set, then the structure returned is a\n** truncated version of the usual Expr structure that will be stored as\n** part of the in-memory representation of the database schema.\n*/\nSQLITE_PRIVATE Expr *sqlite3ExprDup(sqlite3 *db, Expr *p, int flags){\n  assert( flags==0 || flags==EXPRDUP_REDUCE );\n  return p ? exprDup(db, p, flags, 0) : 0;\n}\nSQLITE_PRIVATE ExprList *sqlite3ExprListDup(sqlite3 *db, ExprList *p, int flags){\n  ExprList *pNew;\n  struct ExprList_item *pItem, *pOldItem;\n  int i;\n  Expr *pPriorSelectCol = 0;\n  assert( db!=0 );\n  if( p==0 ) return 0;\n  pNew = sqlite3DbMallocRawNN(db, sqlite3DbMallocSize(db, p));\n  if( pNew==0 ) return 0;\n  pNew->nExpr = p->nExpr;\n  pItem = pNew->a;\n  pOldItem = p->a;\n  for(i=0; i<p->nExpr; i++, pItem++, pOldItem++){\n    Expr *pOldExpr = pOldItem->pExpr;\n    Expr *pNewExpr;\n    pItem->pExpr = sqlite3ExprDup(db, pOldExpr, flags);\n    if( pOldExpr \n     && pOldExpr->op==TK_SELECT_COLUMN\n     && (pNewExpr = pItem->pExpr)!=0 \n    ){\n      assert( pNewExpr->iColumn==0 || i>0 );\n      if( pNewExpr->iColumn==0 ){\n        assert( pOldExpr->pLeft==pOldExpr->pRight );\n        pPriorSelectCol = pNewExpr->pLeft = pNewExpr->pRight;\n      }else{\n        assert( i>0 );\n        assert( pItem[-1].pExpr!=0 );\n        assert( pNewExpr->iColumn==pItem[-1].pExpr->iColumn+1 );\n        assert( pPriorSelectCol==pItem[-1].pExpr->pLeft );\n        pNewExpr->pLeft = pPriorSelectCol;\n      }\n    }\n    pItem->zName = sqlite3DbStrDup(db, pOldItem->zName);\n    pItem->zSpan = sqlite3DbStrDup(db, pOldItem->zSpan);\n    pItem->sortOrder = pOldItem->sortOrder;\n    pItem->done = 0;\n    pItem->bSpanIsTab = pOldItem->bSpanIsTab;\n    pItem->bSorterRef = pOldItem->bSorterRef;\n    pItem->u = pOldItem->u;\n  }\n  return pNew;\n}\n\n/*\n** If cursors, triggers, views and subqueries are all omitted from\n** the build, then none of the following routines, except for \n** sqlite3SelectDup(), can be called. sqlite3SelectDup() is sometimes\n** called with a NULL argument.\n*/\n#if !defined(SQLITE_OMIT_VIEW) || !defined(SQLITE_OMIT_TRIGGER) \\\n || !defined(SQLITE_OMIT_SUBQUERY)\nSQLITE_PRIVATE SrcList *sqlite3SrcListDup(sqlite3 *db, SrcList *p, int flags){\n  SrcList *pNew;\n  int i;\n  int nByte;\n  assert( db!=0 );\n  if( p==0 ) return 0;\n  nByte = sizeof(*p) + (p->nSrc>0 ? sizeof(p->a[0]) * (p->nSrc-1) : 0);\n  pNew = sqlite3DbMallocRawNN(db, nByte );\n  if( pNew==0 ) return 0;\n  pNew->nSrc = pNew->nAlloc = p->nSrc;\n  for(i=0; i<p->nSrc; i++){\n    struct SrcList_item *pNewItem = &pNew->a[i];\n    struct SrcList_item *pOldItem = &p->a[i];\n    Table *pTab;\n    pNewItem->pSchema = pOldItem->pSchema;\n    pNewItem->zDatabase = sqlite3DbStrDup(db, pOldItem->zDatabase);\n    pNewItem->zName = sqlite3DbStrDup(db, pOldItem->zName);\n    pNewItem->zAlias = sqlite3DbStrDup(db, pOldItem->zAlias);\n    pNewItem->fg = pOldItem->fg;\n    pNewItem->iCursor = pOldItem->iCursor;\n    pNewItem->addrFillSub = pOldItem->addrFillSub;\n    pNewItem->regReturn = pOldItem->regReturn;\n    if( pNewItem->fg.isIndexedBy ){\n      pNewItem->u1.zIndexedBy = sqlite3DbStrDup(db, pOldItem->u1.zIndexedBy);\n    }\n    pNewItem->pIBIndex = pOldItem->pIBIndex;\n    if( pNewItem->fg.isTabFunc ){\n      pNewItem->u1.pFuncArg = \n          sqlite3ExprListDup(db, pOldItem->u1.pFuncArg, flags);\n    }\n    pTab = pNewItem->pTab = pOldItem->pTab;\n    if( pTab ){\n      pTab->nTabRef++;\n    }\n    pNewItem->pSelect = sqlite3SelectDup(db, pOldItem->pSelect, flags);\n    pNewItem->pOn = sqlite3ExprDup(db, pOldItem->pOn, flags);\n    pNewItem->pUsing = sqlite3IdListDup(db, pOldItem->pUsing);\n    pNewItem->colUsed = pOldItem->colUsed;\n  }\n  return pNew;\n}\nSQLITE_PRIVATE IdList *sqlite3IdListDup(sqlite3 *db, IdList *p){\n  IdList *pNew;\n  int i;\n  assert( db!=0 );\n  if( p==0 ) return 0;\n  pNew = sqlite3DbMallocRawNN(db, sizeof(*pNew) );\n  if( pNew==0 ) return 0;\n  pNew->nId = p->nId;\n  pNew->a = sqlite3DbMallocRawNN(db, p->nId*sizeof(p->a[0]) );\n  if( pNew->a==0 ){\n    sqlite3DbFreeNN(db, pNew);\n    return 0;\n  }\n  /* Note that because the size of the allocation for p->a[] is not\n  ** necessarily a power of two, sqlite3IdListAppend() may not be called\n  ** on the duplicate created by this function. */\n  for(i=0; i<p->nId; i++){\n    struct IdList_item *pNewItem = &pNew->a[i];\n    struct IdList_item *pOldItem = &p->a[i];\n    pNewItem->zName = sqlite3DbStrDup(db, pOldItem->zName);\n    pNewItem->idx = pOldItem->idx;\n  }\n  return pNew;\n}\nSQLITE_PRIVATE Select *sqlite3SelectDup(sqlite3 *db, Select *pDup, int flags){\n  Select *pRet = 0;\n  Select *pNext = 0;\n  Select **pp = &pRet;\n  Select *p;\n\n  assert( db!=0 );\n  for(p=pDup; p; p=p->pPrior){\n    Select *pNew = sqlite3DbMallocRawNN(db, sizeof(*p) );\n    if( pNew==0 ) break;\n    pNew->pEList = sqlite3ExprListDup(db, p->pEList, flags);\n    pNew->pSrc = sqlite3SrcListDup(db, p->pSrc, flags);\n    pNew->pWhere = sqlite3ExprDup(db, p->pWhere, flags);\n    pNew->pGroupBy = sqlite3ExprListDup(db, p->pGroupBy, flags);\n    pNew->pHaving = sqlite3ExprDup(db, p->pHaving, flags);\n    pNew->pOrderBy = sqlite3ExprListDup(db, p->pOrderBy, flags);\n    pNew->op = p->op;\n    pNew->pNext = pNext;\n    pNew->pPrior = 0;\n    pNew->pLimit = sqlite3ExprDup(db, p->pLimit, flags);\n    pNew->iLimit = 0;\n    pNew->iOffset = 0;\n    pNew->selFlags = p->selFlags & ~SF_UsesEphemeral;\n    pNew->addrOpenEphm[0] = -1;\n    pNew->addrOpenEphm[1] = -1;\n    pNew->nSelectRow = p->nSelectRow;\n    pNew->pWith = withDup(db, p->pWith);\n#ifndef SQLITE_OMIT_WINDOWFUNC\n    pNew->pWin = 0;\n    pNew->pWinDefn = sqlite3WindowListDup(db, p->pWinDefn);\n    if( p->pWin ) gatherSelectWindows(pNew);\n#endif\n    pNew->selId = p->selId;\n    *pp = pNew;\n    pp = &pNew->pPrior;\n    pNext = pNew;\n  }\n\n  return pRet;\n}\n#else\nSQLITE_PRIVATE Select *sqlite3SelectDup(sqlite3 *db, Select *p, int flags){\n  assert( p==0 );\n  return 0;\n}\n#endif\n\n\n/*\n** Add a new element to the end of an expression list.  If pList is\n** initially NULL, then create a new expression list.\n**\n** The pList argument must be either NULL or a pointer to an ExprList\n** obtained from a prior call to sqlite3ExprListAppend().  This routine\n** may not be used with an ExprList obtained from sqlite3ExprListDup().\n** Reason:  This routine assumes that the number of slots in pList->a[]\n** is a power of two.  That is true for sqlite3ExprListAppend() returns\n** but is not necessarily true from the return value of sqlite3ExprListDup().\n**\n** If a memory allocation error occurs, the entire list is freed and\n** NULL is returned.  If non-NULL is returned, then it is guaranteed\n** that the new entry was successfully appended.\n*/\nSQLITE_PRIVATE ExprList *sqlite3ExprListAppend(\n  Parse *pParse,          /* Parsing context */\n  ExprList *pList,        /* List to which to append. Might be NULL */\n  Expr *pExpr             /* Expression to be appended. Might be NULL */\n){\n  struct ExprList_item *pItem;\n  sqlite3 *db = pParse->db;\n  assert( db!=0 );\n  if( pList==0 ){\n    pList = sqlite3DbMallocRawNN(db, sizeof(ExprList) );\n    if( pList==0 ){\n      goto no_mem;\n    }\n    pList->nExpr = 0;\n  }else if( (pList->nExpr & (pList->nExpr-1))==0 ){\n    ExprList *pNew;\n    pNew = sqlite3DbRealloc(db, pList, \n             sizeof(*pList)+(2*pList->nExpr - 1)*sizeof(pList->a[0]));\n    if( pNew==0 ){\n      goto no_mem;\n    }\n    pList = pNew;\n  }\n  pItem = &pList->a[pList->nExpr++];\n  assert( offsetof(struct ExprList_item,zName)==sizeof(pItem->pExpr) );\n  assert( offsetof(struct ExprList_item,pExpr)==0 );\n  memset(&pItem->zName,0,sizeof(*pItem)-offsetof(struct ExprList_item,zName));\n  pItem->pExpr = pExpr;\n  return pList;\n\nno_mem:     \n  /* Avoid leaking memory if malloc has failed. */\n  sqlite3ExprDelete(db, pExpr);\n  sqlite3ExprListDelete(db, pList);\n  return 0;\n}\n\n/*\n** pColumns and pExpr form a vector assignment which is part of the SET\n** clause of an UPDATE statement.  Like this:\n**\n**        (a,b,c) = (expr1,expr2,expr3)\n** Or:    (a,b,c) = (SELECT x,y,z FROM ....)\n**\n** For each term of the vector assignment, append new entries to the\n** expression list pList.  In the case of a subquery on the RHS, append\n** TK_SELECT_COLUMN expressions.\n*/\nSQLITE_PRIVATE ExprList *sqlite3ExprListAppendVector(\n  Parse *pParse,         /* Parsing context */\n  ExprList *pList,       /* List to which to append. Might be NULL */\n  IdList *pColumns,      /* List of names of LHS of the assignment */\n  Expr *pExpr            /* Vector expression to be appended. Might be NULL */\n){\n  sqlite3 *db = pParse->db;\n  int n;\n  int i;\n  int iFirst = pList ? pList->nExpr : 0;\n  /* pColumns can only be NULL due to an OOM but an OOM will cause an\n  ** exit prior to this routine being invoked */\n  if( NEVER(pColumns==0) ) goto vector_append_error;\n  if( pExpr==0 ) goto vector_append_error;\n\n  /* If the RHS is a vector, then we can immediately check to see that \n  ** the size of the RHS and LHS match.  But if the RHS is a SELECT, \n  ** wildcards (\"*\") in the result set of the SELECT must be expanded before\n  ** we can do the size check, so defer the size check until code generation.\n  */\n  if( pExpr->op!=TK_SELECT && pColumns->nId!=(n=sqlite3ExprVectorSize(pExpr)) ){\n    sqlite3ErrorMsg(pParse, \"%d columns assigned %d values\",\n                    pColumns->nId, n);\n    goto vector_append_error;\n  }\n\n  for(i=0; i<pColumns->nId; i++){\n    Expr *pSubExpr = sqlite3ExprForVectorField(pParse, pExpr, i);\n    pList = sqlite3ExprListAppend(pParse, pList, pSubExpr);\n    if( pList ){\n      assert( pList->nExpr==iFirst+i+1 );\n      pList->a[pList->nExpr-1].zName = pColumns->a[i].zName;\n      pColumns->a[i].zName = 0;\n    }\n  }\n\n  if( !db->mallocFailed && pExpr->op==TK_SELECT && ALWAYS(pList!=0) ){\n    Expr *pFirst = pList->a[iFirst].pExpr;\n    assert( pFirst!=0 );\n    assert( pFirst->op==TK_SELECT_COLUMN );\n     \n    /* Store the SELECT statement in pRight so it will be deleted when\n    ** sqlite3ExprListDelete() is called */\n    pFirst->pRight = pExpr;\n    pExpr = 0;\n\n    /* Remember the size of the LHS in iTable so that we can check that\n    ** the RHS and LHS sizes match during code generation. */\n    pFirst->iTable = pColumns->nId;\n  }\n\nvector_append_error:\n  if( IN_RENAME_OBJECT ){\n    sqlite3RenameExprUnmap(pParse, pExpr);\n  }\n  sqlite3ExprDelete(db, pExpr);\n  sqlite3IdListDelete(db, pColumns);\n  return pList;\n}\n\n/*\n** Set the sort order for the last element on the given ExprList.\n*/\nSQLITE_PRIVATE void sqlite3ExprListSetSortOrder(ExprList *p, int iSortOrder){\n  if( p==0 ) return;\n  assert( SQLITE_SO_UNDEFINED<0 && SQLITE_SO_ASC>=0 && SQLITE_SO_DESC>0 );\n  assert( p->nExpr>0 );\n  if( iSortOrder<0 ){\n    assert( p->a[p->nExpr-1].sortOrder==SQLITE_SO_ASC );\n    return;\n  }\n  p->a[p->nExpr-1].sortOrder = (u8)iSortOrder;\n}\n\n/*\n** Set the ExprList.a[].zName element of the most recently added item\n** on the expression list.\n**\n** pList might be NULL following an OOM error.  But pName should never be\n** NULL.  If a memory allocation fails, the pParse->db->mallocFailed flag\n** is set.\n*/\nSQLITE_PRIVATE void sqlite3ExprListSetName(\n  Parse *pParse,          /* Parsing context */\n  ExprList *pList,        /* List to which to add the span. */\n  Token *pName,           /* Name to be added */\n  int dequote             /* True to cause the name to be dequoted */\n){\n  assert( pList!=0 || pParse->db->mallocFailed!=0 );\n  if( pList ){\n    struct ExprList_item *pItem;\n    assert( pList->nExpr>0 );\n    pItem = &pList->a[pList->nExpr-1];\n    assert( pItem->zName==0 );\n    pItem->zName = sqlite3DbStrNDup(pParse->db, pName->z, pName->n);\n    if( dequote ) sqlite3Dequote(pItem->zName);\n    if( IN_RENAME_OBJECT ){\n      sqlite3RenameTokenMap(pParse, (void*)pItem->zName, pName);\n    }\n  }\n}\n\n/*\n** Set the ExprList.a[].zSpan element of the most recently added item\n** on the expression list.\n**\n** pList might be NULL following an OOM error.  But pSpan should never be\n** NULL.  If a memory allocation fails, the pParse->db->mallocFailed flag\n** is set.\n*/\nSQLITE_PRIVATE void sqlite3ExprListSetSpan(\n  Parse *pParse,          /* Parsing context */\n  ExprList *pList,        /* List to which to add the span. */\n  const char *zStart,     /* Start of the span */\n  const char *zEnd        /* End of the span */\n){\n  sqlite3 *db = pParse->db;\n  assert( pList!=0 || db->mallocFailed!=0 );\n  if( pList ){\n    struct ExprList_item *pItem = &pList->a[pList->nExpr-1];\n    assert( pList->nExpr>0 );\n    sqlite3DbFree(db, pItem->zSpan);\n    pItem->zSpan = sqlite3DbSpanDup(db, zStart, zEnd);\n  }\n}\n\n/*\n** If the expression list pEList contains more than iLimit elements,\n** leave an error message in pParse.\n*/\nSQLITE_PRIVATE void sqlite3ExprListCheckLength(\n  Parse *pParse,\n  ExprList *pEList,\n  const char *zObject\n){\n  int mx = pParse->db->aLimit[SQLITE_LIMIT_COLUMN];\n  testcase( pEList && pEList->nExpr==mx );\n  testcase( pEList && pEList->nExpr==mx+1 );\n  if( pEList && pEList->nExpr>mx ){\n    sqlite3ErrorMsg(pParse, \"too many columns in %s\", zObject);\n  }\n}\n\n/*\n** Delete an entire expression list.\n*/\nstatic SQLITE_NOINLINE void exprListDeleteNN(sqlite3 *db, ExprList *pList){\n  int i = pList->nExpr;\n  struct ExprList_item *pItem =  pList->a;\n  assert( pList->nExpr>0 );\n  do{\n    sqlite3ExprDelete(db, pItem->pExpr);\n    sqlite3DbFree(db, pItem->zName);\n    sqlite3DbFree(db, pItem->zSpan);\n    pItem++;\n  }while( --i>0 );\n  sqlite3DbFreeNN(db, pList);\n}\nSQLITE_PRIVATE void sqlite3ExprListDelete(sqlite3 *db, ExprList *pList){\n  if( pList ) exprListDeleteNN(db, pList);\n}\n\n/*\n** Return the bitwise-OR of all Expr.flags fields in the given\n** ExprList.\n*/\nSQLITE_PRIVATE u32 sqlite3ExprListFlags(const ExprList *pList){\n  int i;\n  u32 m = 0;\n  assert( pList!=0 );\n  for(i=0; i<pList->nExpr; i++){\n     Expr *pExpr = pList->a[i].pExpr;\n     assert( pExpr!=0 );\n     m |= pExpr->flags;\n  }\n  return m;\n}\n\n/*\n** This is a SELECT-node callback for the expression walker that\n** always \"fails\".  By \"fail\" in this case, we mean set\n** pWalker->eCode to zero and abort.\n**\n** This callback is used by multiple expression walkers.\n*/\nSQLITE_PRIVATE int sqlite3SelectWalkFail(Walker *pWalker, Select *NotUsed){\n  UNUSED_PARAMETER(NotUsed);\n  pWalker->eCode = 0;\n  return WRC_Abort;\n}\n\n/*\n** If the input expression is an ID with the name \"true\" or \"false\"\n** then convert it into an TK_TRUEFALSE term.  Return non-zero if\n** the conversion happened, and zero if the expression is unaltered.\n*/\nSQLITE_PRIVATE int sqlite3ExprIdToTrueFalse(Expr *pExpr){\n  assert( pExpr->op==TK_ID || pExpr->op==TK_STRING );\n  if( !ExprHasProperty(pExpr, EP_Quoted)\n   && (sqlite3StrICmp(pExpr->u.zToken, \"true\")==0\n       || sqlite3StrICmp(pExpr->u.zToken, \"false\")==0)\n  ){\n    pExpr->op = TK_TRUEFALSE;\n    return 1;\n  }\n  return 0;\n}\n\n/*\n** The argument must be a TK_TRUEFALSE Expr node.  Return 1 if it is TRUE\n** and 0 if it is FALSE.\n*/\nSQLITE_PRIVATE int sqlite3ExprTruthValue(const Expr *pExpr){\n  assert( pExpr->op==TK_TRUEFALSE );\n  assert( sqlite3StrICmp(pExpr->u.zToken,\"true\")==0\n       || sqlite3StrICmp(pExpr->u.zToken,\"false\")==0 );\n  return pExpr->u.zToken[4]==0;\n}\n\n\n/*\n** These routines are Walker callbacks used to check expressions to\n** see if they are \"constant\" for some definition of constant.  The\n** Walker.eCode value determines the type of \"constant\" we are looking\n** for.\n**\n** These callback routines are used to implement the following:\n**\n**     sqlite3ExprIsConstant()                  pWalker->eCode==1\n**     sqlite3ExprIsConstantNotJoin()           pWalker->eCode==2\n**     sqlite3ExprIsTableConstant()             pWalker->eCode==3\n**     sqlite3ExprIsConstantOrFunction()        pWalker->eCode==4 or 5\n**\n** In all cases, the callbacks set Walker.eCode=0 and abort if the expression\n** is found to not be a constant.\n**\n** The sqlite3ExprIsConstantOrFunction() is used for evaluating expressions\n** in a CREATE TABLE statement.  The Walker.eCode value is 5 when parsing\n** an existing schema and 4 when processing a new statement.  A bound\n** parameter raises an error for new statements, but is silently converted\n** to NULL for existing schemas.  This allows sqlite_master tables that \n** contain a bound parameter because they were generated by older versions\n** of SQLite to be parsed by newer versions of SQLite without raising a\n** malformed schema error.\n*/\nstatic int exprNodeIsConstant(Walker *pWalker, Expr *pExpr){\n\n  /* If pWalker->eCode is 2 then any term of the expression that comes from\n  ** the ON or USING clauses of a left join disqualifies the expression\n  ** from being considered constant. */\n  if( pWalker->eCode==2 && ExprHasProperty(pExpr, EP_FromJoin) ){\n    pWalker->eCode = 0;\n    return WRC_Abort;\n  }\n\n  switch( pExpr->op ){\n    /* Consider functions to be constant if all their arguments are constant\n    ** and either pWalker->eCode==4 or 5 or the function has the\n    ** SQLITE_FUNC_CONST flag. */\n    case TK_FUNCTION:\n      if( pWalker->eCode>=4 || ExprHasProperty(pExpr,EP_ConstFunc) ){\n        return WRC_Continue;\n      }else{\n        pWalker->eCode = 0;\n        return WRC_Abort;\n      }\n    case TK_ID:\n      /* Convert \"true\" or \"false\" in a DEFAULT clause into the\n      ** appropriate TK_TRUEFALSE operator */\n      if( sqlite3ExprIdToTrueFalse(pExpr) ){\n        return WRC_Prune;\n      }\n      /* Fall thru */\n    case TK_COLUMN:\n    case TK_AGG_FUNCTION:\n    case TK_AGG_COLUMN:\n      testcase( pExpr->op==TK_ID );\n      testcase( pExpr->op==TK_COLUMN );\n      testcase( pExpr->op==TK_AGG_FUNCTION );\n      testcase( pExpr->op==TK_AGG_COLUMN );\n      if( ExprHasProperty(pExpr, EP_FixedCol) && pWalker->eCode!=2 ){\n        return WRC_Continue;\n      }\n      if( pWalker->eCode==3 && pExpr->iTable==pWalker->u.iCur ){\n        return WRC_Continue;\n      }\n      /* Fall through */\n    case TK_IF_NULL_ROW:\n    case TK_REGISTER:\n      testcase( pExpr->op==TK_REGISTER );\n      testcase( pExpr->op==TK_IF_NULL_ROW );\n      pWalker->eCode = 0;\n      return WRC_Abort;\n    case TK_VARIABLE:\n      if( pWalker->eCode==5 ){\n        /* Silently convert bound parameters that appear inside of CREATE\n        ** statements into a NULL when parsing the CREATE statement text out\n        ** of the sqlite_master table */\n        pExpr->op = TK_NULL;\n      }else if( pWalker->eCode==4 ){\n        /* A bound parameter in a CREATE statement that originates from\n        ** sqlite3_prepare() causes an error */\n        pWalker->eCode = 0;\n        return WRC_Abort;\n      }\n      /* Fall through */\n    default:\n      testcase( pExpr->op==TK_SELECT ); /* sqlite3SelectWalkFail() disallows */\n      testcase( pExpr->op==TK_EXISTS ); /* sqlite3SelectWalkFail() disallows */\n      return WRC_Continue;\n  }\n}\nstatic int exprIsConst(Expr *p, int initFlag, int iCur){\n  Walker w;\n  w.eCode = initFlag;\n  w.xExprCallback = exprNodeIsConstant;\n  w.xSelectCallback = sqlite3SelectWalkFail;\n#ifdef SQLITE_DEBUG\n  w.xSelectCallback2 = sqlite3SelectWalkAssert2;\n#endif\n  w.u.iCur = iCur;\n  sqlite3WalkExpr(&w, p);\n  return w.eCode;\n}\n\n/*\n** Walk an expression tree.  Return non-zero if the expression is constant\n** and 0 if it involves variables or function calls.\n**\n** For the purposes of this function, a double-quoted string (ex: \"abc\")\n** is considered a variable but a single-quoted string (ex: 'abc') is\n** a constant.\n*/\nSQLITE_PRIVATE int sqlite3ExprIsConstant(Expr *p){\n  return exprIsConst(p, 1, 0);\n}\n\n/*\n** Walk an expression tree.  Return non-zero if\n**\n**   (1) the expression is constant, and\n**   (2) the expression does originate in the ON or USING clause\n**       of a LEFT JOIN, and\n**   (3) the expression does not contain any EP_FixedCol TK_COLUMN\n**       operands created by the constant propagation optimization.\n**\n** When this routine returns true, it indicates that the expression\n** can be added to the pParse->pConstExpr list and evaluated once when\n** the prepared statement starts up.  See sqlite3ExprCodeAtInit().\n*/\nSQLITE_PRIVATE int sqlite3ExprIsConstantNotJoin(Expr *p){\n  return exprIsConst(p, 2, 0);\n}\n\n/*\n** Walk an expression tree.  Return non-zero if the expression is constant\n** for any single row of the table with cursor iCur.  In other words, the\n** expression must not refer to any non-deterministic function nor any\n** table other than iCur.\n*/\nSQLITE_PRIVATE int sqlite3ExprIsTableConstant(Expr *p, int iCur){\n  return exprIsConst(p, 3, iCur);\n}\n\n\n/*\n** sqlite3WalkExpr() callback used by sqlite3ExprIsConstantOrGroupBy().\n*/\nstatic int exprNodeIsConstantOrGroupBy(Walker *pWalker, Expr *pExpr){\n  ExprList *pGroupBy = pWalker->u.pGroupBy;\n  int i;\n\n  /* Check if pExpr is identical to any GROUP BY term. If so, consider\n  ** it constant.  */\n  for(i=0; i<pGroupBy->nExpr; i++){\n    Expr *p = pGroupBy->a[i].pExpr;\n    if( sqlite3ExprCompare(0, pExpr, p, -1)<2 ){\n      CollSeq *pColl = sqlite3ExprNNCollSeq(pWalker->pParse, p);\n      if( sqlite3IsBinary(pColl) ){\n        return WRC_Prune;\n      }\n    }\n  }\n\n  /* Check if pExpr is a sub-select. If so, consider it variable. */\n  if( ExprHasProperty(pExpr, EP_xIsSelect) ){\n    pWalker->eCode = 0;\n    return WRC_Abort;\n  }\n\n  return exprNodeIsConstant(pWalker, pExpr);\n}\n\n/*\n** Walk the expression tree passed as the first argument. Return non-zero\n** if the expression consists entirely of constants or copies of terms \n** in pGroupBy that sort with the BINARY collation sequence.\n**\n** This routine is used to determine if a term of the HAVING clause can\n** be promoted into the WHERE clause.  In order for such a promotion to work,\n** the value of the HAVING clause term must be the same for all members of\n** a \"group\".  The requirement that the GROUP BY term must be BINARY\n** assumes that no other collating sequence will have a finer-grained\n** grouping than binary.  In other words (A=B COLLATE binary) implies\n** A=B in every other collating sequence.  The requirement that the\n** GROUP BY be BINARY is stricter than necessary.  It would also work\n** to promote HAVING clauses that use the same alternative collating\n** sequence as the GROUP BY term, but that is much harder to check,\n** alternative collating sequences are uncommon, and this is only an\n** optimization, so we take the easy way out and simply require the\n** GROUP BY to use the BINARY collating sequence.\n*/\nSQLITE_PRIVATE int sqlite3ExprIsConstantOrGroupBy(Parse *pParse, Expr *p, ExprList *pGroupBy){\n  Walker w;\n  w.eCode = 1;\n  w.xExprCallback = exprNodeIsConstantOrGroupBy;\n  w.xSelectCallback = 0;\n  w.u.pGroupBy = pGroupBy;\n  w.pParse = pParse;\n  sqlite3WalkExpr(&w, p);\n  return w.eCode;\n}\n\n/*\n** Walk an expression tree.  Return non-zero if the expression is constant\n** or a function call with constant arguments.  Return and 0 if there\n** are any variables.\n**\n** For the purposes of this function, a double-quoted string (ex: \"abc\")\n** is considered a variable but a single-quoted string (ex: 'abc') is\n** a constant.\n*/\nSQLITE_PRIVATE int sqlite3ExprIsConstantOrFunction(Expr *p, u8 isInit){\n  assert( isInit==0 || isInit==1 );\n  return exprIsConst(p, 4+isInit, 0);\n}\n\n#ifdef SQLITE_ENABLE_CURSOR_HINTS\n/*\n** Walk an expression tree.  Return 1 if the expression contains a\n** subquery of some kind.  Return 0 if there are no subqueries.\n*/\nSQLITE_PRIVATE int sqlite3ExprContainsSubquery(Expr *p){\n  Walker w;\n  w.eCode = 1;\n  w.xExprCallback = sqlite3ExprWalkNoop;\n  w.xSelectCallback = sqlite3SelectWalkFail;\n#ifdef SQLITE_DEBUG\n  w.xSelectCallback2 = sqlite3SelectWalkAssert2;\n#endif\n  sqlite3WalkExpr(&w, p);\n  return w.eCode==0;\n}\n#endif\n\n/*\n** If the expression p codes a constant integer that is small enough\n** to fit in a 32-bit integer, return 1 and put the value of the integer\n** in *pValue.  If the expression is not an integer or if it is too big\n** to fit in a signed 32-bit integer, return 0 and leave *pValue unchanged.\n*/\nSQLITE_PRIVATE int sqlite3ExprIsInteger(Expr *p, int *pValue){\n  int rc = 0;\n  if( p==0 ) return 0;  /* Can only happen following on OOM */\n\n  /* If an expression is an integer literal that fits in a signed 32-bit\n  ** integer, then the EP_IntValue flag will have already been set */\n  assert( p->op!=TK_INTEGER || (p->flags & EP_IntValue)!=0\n           || sqlite3GetInt32(p->u.zToken, &rc)==0 );\n\n  if( p->flags & EP_IntValue ){\n    *pValue = p->u.iValue;\n    return 1;\n  }\n  switch( p->op ){\n    case TK_UPLUS: {\n      rc = sqlite3ExprIsInteger(p->pLeft, pValue);\n      break;\n    }\n    case TK_UMINUS: {\n      int v;\n      if( sqlite3ExprIsInteger(p->pLeft, &v) ){\n        assert( v!=(-2147483647-1) );\n        *pValue = -v;\n        rc = 1;\n      }\n      break;\n    }\n    default: break;\n  }\n  return rc;\n}\n\n/*\n** Return FALSE if there is no chance that the expression can be NULL.\n**\n** If the expression might be NULL or if the expression is too complex\n** to tell return TRUE.  \n**\n** This routine is used as an optimization, to skip OP_IsNull opcodes\n** when we know that a value cannot be NULL.  Hence, a false positive\n** (returning TRUE when in fact the expression can never be NULL) might\n** be a small performance hit but is otherwise harmless.  On the other\n** hand, a false negative (returning FALSE when the result could be NULL)\n** will likely result in an incorrect answer.  So when in doubt, return\n** TRUE.\n*/\nSQLITE_PRIVATE int sqlite3ExprCanBeNull(const Expr *p){\n  u8 op;\n  while( p->op==TK_UPLUS || p->op==TK_UMINUS ){\n    p = p->pLeft;\n  }\n  op = p->op;\n  if( op==TK_REGISTER ) op = p->op2;\n  switch( op ){\n    case TK_INTEGER:\n    case TK_STRING:\n    case TK_FLOAT:\n    case TK_BLOB:\n      return 0;\n    case TK_COLUMN:\n      return ExprHasProperty(p, EP_CanBeNull) ||\n             p->y.pTab==0 ||  /* Reference to column of index on expression */\n             (p->iColumn>=0 && p->y.pTab->aCol[p->iColumn].notNull==0);\n    default:\n      return 1;\n  }\n}\n\n/*\n** Return TRUE if the given expression is a constant which would be\n** unchanged by OP_Affinity with the affinity given in the second\n** argument.\n**\n** This routine is used to determine if the OP_Affinity operation\n** can be omitted.  When in doubt return FALSE.  A false negative\n** is harmless.  A false positive, however, can result in the wrong\n** answer.\n*/\nSQLITE_PRIVATE int sqlite3ExprNeedsNoAffinityChange(const Expr *p, char aff){\n  u8 op;\n  if( aff==SQLITE_AFF_BLOB ) return 1;\n  while( p->op==TK_UPLUS || p->op==TK_UMINUS ){ p = p->pLeft; }\n  op = p->op;\n  if( op==TK_REGISTER ) op = p->op2;\n  switch( op ){\n    case TK_INTEGER: {\n      return aff==SQLITE_AFF_INTEGER || aff==SQLITE_AFF_NUMERIC;\n    }\n    case TK_FLOAT: {\n      return aff==SQLITE_AFF_REAL || aff==SQLITE_AFF_NUMERIC;\n    }\n    case TK_STRING: {\n      return aff==SQLITE_AFF_TEXT;\n    }\n    case TK_BLOB: {\n      return 1;\n    }\n    case TK_COLUMN: {\n      assert( p->iTable>=0 );  /* p cannot be part of a CHECK constraint */\n      return p->iColumn<0\n          && (aff==SQLITE_AFF_INTEGER || aff==SQLITE_AFF_NUMERIC);\n    }\n    default: {\n      return 0;\n    }\n  }\n}\n\n/*\n** Return TRUE if the given string is a row-id column name.\n*/\nSQLITE_PRIVATE int sqlite3IsRowid(const char *z){\n  if( sqlite3StrICmp(z, \"_ROWID_\")==0 ) return 1;\n  if( sqlite3StrICmp(z, \"ROWID\")==0 ) return 1;\n  if( sqlite3StrICmp(z, \"OID\")==0 ) return 1;\n  return 0;\n}\n\n/*\n** pX is the RHS of an IN operator.  If pX is a SELECT statement \n** that can be simplified to a direct table access, then return\n** a pointer to the SELECT statement.  If pX is not a SELECT statement,\n** or if the SELECT statement needs to be manifested into a transient\n** table, then return NULL.\n*/\n#ifndef SQLITE_OMIT_SUBQUERY\nstatic Select *isCandidateForInOpt(Expr *pX){\n  Select *p;\n  SrcList *pSrc;\n  ExprList *pEList;\n  Table *pTab;\n  int i;\n  if( !ExprHasProperty(pX, EP_xIsSelect) ) return 0;  /* Not a subquery */\n  if( ExprHasProperty(pX, EP_VarSelect)  ) return 0;  /* Correlated subq */\n  p = pX->x.pSelect;\n  if( p->pPrior ) return 0;              /* Not a compound SELECT */\n  if( p->selFlags & (SF_Distinct|SF_Aggregate) ){\n    testcase( (p->selFlags & (SF_Distinct|SF_Aggregate))==SF_Distinct );\n    testcase( (p->selFlags & (SF_Distinct|SF_Aggregate))==SF_Aggregate );\n    return 0; /* No DISTINCT keyword and no aggregate functions */\n  }\n  assert( p->pGroupBy==0 );              /* Has no GROUP BY clause */\n  if( p->pLimit ) return 0;              /* Has no LIMIT clause */\n  if( p->pWhere ) return 0;              /* Has no WHERE clause */\n  pSrc = p->pSrc;\n  assert( pSrc!=0 );\n  if( pSrc->nSrc!=1 ) return 0;          /* Single term in FROM clause */\n  if( pSrc->a[0].pSelect ) return 0;     /* FROM is not a subquery or view */\n  pTab = pSrc->a[0].pTab;\n  assert( pTab!=0 );\n  assert( pTab->pSelect==0 );            /* FROM clause is not a view */\n  if( IsVirtual(pTab) ) return 0;        /* FROM clause not a virtual table */\n  pEList = p->pEList;\n  assert( pEList!=0 );\n  /* All SELECT results must be columns. */\n  for(i=0; i<pEList->nExpr; i++){\n    Expr *pRes = pEList->a[i].pExpr;\n    if( pRes->op!=TK_COLUMN ) return 0;\n    assert( pRes->iTable==pSrc->a[0].iCursor );  /* Not a correlated subquery */\n  }\n  return p;\n}\n#endif /* SQLITE_OMIT_SUBQUERY */\n\n#ifndef SQLITE_OMIT_SUBQUERY\n/*\n** Generate code that checks the left-most column of index table iCur to see if\n** it contains any NULL entries.  Cause the register at regHasNull to be set\n** to a non-NULL value if iCur contains no NULLs.  Cause register regHasNull\n** to be set to NULL if iCur contains one or more NULL values.\n*/\nstatic void sqlite3SetHasNullFlag(Vdbe *v, int iCur, int regHasNull){\n  int addr1;\n  sqlite3VdbeAddOp2(v, OP_Integer, 0, regHasNull);\n  addr1 = sqlite3VdbeAddOp1(v, OP_Rewind, iCur); VdbeCoverage(v);\n  sqlite3VdbeAddOp3(v, OP_Column, iCur, 0, regHasNull);\n  sqlite3VdbeChangeP5(v, OPFLAG_TYPEOFARG);\n  VdbeComment((v, \"first_entry_in(%d)\", iCur));\n  sqlite3VdbeJumpHere(v, addr1);\n}\n#endif\n\n\n#ifndef SQLITE_OMIT_SUBQUERY\n/*\n** The argument is an IN operator with a list (not a subquery) on the \n** right-hand side.  Return TRUE if that list is constant.\n*/\nstatic int sqlite3InRhsIsConstant(Expr *pIn){\n  Expr *pLHS;\n  int res;\n  assert( !ExprHasProperty(pIn, EP_xIsSelect) );\n  pLHS = pIn->pLeft;\n  pIn->pLeft = 0;\n  res = sqlite3ExprIsConstant(pIn);\n  pIn->pLeft = pLHS;\n  return res;\n}\n#endif\n\n/*\n** This function is used by the implementation of the IN (...) operator.\n** The pX parameter is the expression on the RHS of the IN operator, which\n** might be either a list of expressions or a subquery.\n**\n** The job of this routine is to find or create a b-tree object that can\n** be used either to test for membership in the RHS set or to iterate through\n** all members of the RHS set, skipping duplicates.\n**\n** A cursor is opened on the b-tree object that is the RHS of the IN operator\n** and pX->iTable is set to the index of that cursor.\n**\n** The returned value of this function indicates the b-tree type, as follows:\n**\n**   IN_INDEX_ROWID      - The cursor was opened on a database table.\n**   IN_INDEX_INDEX_ASC  - The cursor was opened on an ascending index.\n**   IN_INDEX_INDEX_DESC - The cursor was opened on a descending index.\n**   IN_INDEX_EPH        - The cursor was opened on a specially created and\n**                         populated epheremal table.\n**   IN_INDEX_NOOP       - No cursor was allocated.  The IN operator must be\n**                         implemented as a sequence of comparisons.\n**\n** An existing b-tree might be used if the RHS expression pX is a simple\n** subquery such as:\n**\n**     SELECT <column1>, <column2>... FROM <table>\n**\n** If the RHS of the IN operator is a list or a more complex subquery, then\n** an ephemeral table might need to be generated from the RHS and then\n** pX->iTable made to point to the ephemeral table instead of an\n** existing table.\n**\n** The inFlags parameter must contain, at a minimum, one of the bits\n** IN_INDEX_MEMBERSHIP or IN_INDEX_LOOP but not both.  If inFlags contains\n** IN_INDEX_MEMBERSHIP, then the generated table will be used for a fast\n** membership test.  When the IN_INDEX_LOOP bit is set, the IN index will\n** be used to loop over all values of the RHS of the IN operator.\n**\n** When IN_INDEX_LOOP is used (and the b-tree will be used to iterate\n** through the set members) then the b-tree must not contain duplicates.\n** An epheremal table will be created unless the selected columns are guaranteed\n** to be unique - either because it is an INTEGER PRIMARY KEY or due to\n** a UNIQUE constraint or index.\n**\n** When IN_INDEX_MEMBERSHIP is used (and the b-tree will be used \n** for fast set membership tests) then an epheremal table must \n** be used unless <columns> is a single INTEGER PRIMARY KEY column or an \n** index can be found with the specified <columns> as its left-most.\n**\n** If the IN_INDEX_NOOP_OK and IN_INDEX_MEMBERSHIP are both set and\n** if the RHS of the IN operator is a list (not a subquery) then this\n** routine might decide that creating an ephemeral b-tree for membership\n** testing is too expensive and return IN_INDEX_NOOP.  In that case, the\n** calling routine should implement the IN operator using a sequence\n** of Eq or Ne comparison operations.\n**\n** When the b-tree is being used for membership tests, the calling function\n** might need to know whether or not the RHS side of the IN operator\n** contains a NULL.  If prRhsHasNull is not a NULL pointer and \n** if there is any chance that the (...) might contain a NULL value at\n** runtime, then a register is allocated and the register number written\n** to *prRhsHasNull. If there is no chance that the (...) contains a\n** NULL value, then *prRhsHasNull is left unchanged.\n**\n** If a register is allocated and its location stored in *prRhsHasNull, then\n** the value in that register will be NULL if the b-tree contains one or more\n** NULL values, and it will be some non-NULL value if the b-tree contains no\n** NULL values.\n**\n** If the aiMap parameter is not NULL, it must point to an array containing\n** one element for each column returned by the SELECT statement on the RHS\n** of the IN(...) operator. The i'th entry of the array is populated with the\n** offset of the index column that matches the i'th column returned by the\n** SELECT. For example, if the expression and selected index are:\n**\n**   (?,?,?) IN (SELECT a, b, c FROM t1)\n**   CREATE INDEX i1 ON t1(b, c, a);\n**\n** then aiMap[] is populated with {2, 0, 1}.\n*/\n#ifndef SQLITE_OMIT_SUBQUERY\nSQLITE_PRIVATE int sqlite3FindInIndex(\n  Parse *pParse,             /* Parsing context */\n  Expr *pX,                  /* The right-hand side (RHS) of the IN operator */\n  u32 inFlags,               /* IN_INDEX_LOOP, _MEMBERSHIP, and/or _NOOP_OK */\n  int *prRhsHasNull,         /* Register holding NULL status.  See notes */\n  int *aiMap,                /* Mapping from Index fields to RHS fields */\n  int *piTab                 /* OUT: index to use */\n){\n  Select *p;                            /* SELECT to the right of IN operator */\n  int eType = 0;                        /* Type of RHS table. IN_INDEX_* */\n  int iTab = pParse->nTab++;            /* Cursor of the RHS table */\n  int mustBeUnique;                     /* True if RHS must be unique */\n  Vdbe *v = sqlite3GetVdbe(pParse);     /* Virtual machine being coded */\n\n  assert( pX->op==TK_IN );\n  mustBeUnique = (inFlags & IN_INDEX_LOOP)!=0;\n\n  /* If the RHS of this IN(...) operator is a SELECT, and if it matters \n  ** whether or not the SELECT result contains NULL values, check whether\n  ** or not NULL is actually possible (it may not be, for example, due \n  ** to NOT NULL constraints in the schema). If no NULL values are possible,\n  ** set prRhsHasNull to 0 before continuing.  */\n  if( prRhsHasNull && (pX->flags & EP_xIsSelect) ){\n    int i;\n    ExprList *pEList = pX->x.pSelect->pEList;\n    for(i=0; i<pEList->nExpr; i++){\n      if( sqlite3ExprCanBeNull(pEList->a[i].pExpr) ) break;\n    }\n    if( i==pEList->nExpr ){\n      prRhsHasNull = 0;\n    }\n  }\n\n  /* Check to see if an existing table or index can be used to\n  ** satisfy the query.  This is preferable to generating a new \n  ** ephemeral table.  */\n  if( pParse->nErr==0 && (p = isCandidateForInOpt(pX))!=0 ){\n    sqlite3 *db = pParse->db;              /* Database connection */\n    Table *pTab;                           /* Table <table>. */\n    i16 iDb;                               /* Database idx for pTab */\n    ExprList *pEList = p->pEList;\n    int nExpr = pEList->nExpr;\n\n    assert( p->pEList!=0 );             /* Because of isCandidateForInOpt(p) */\n    assert( p->pEList->a[0].pExpr!=0 ); /* Because of isCandidateForInOpt(p) */\n    assert( p->pSrc!=0 );               /* Because of isCandidateForInOpt(p) */\n    pTab = p->pSrc->a[0].pTab;\n\n    /* Code an OP_Transaction and OP_TableLock for <table>. */\n    iDb = sqlite3SchemaToIndex(db, pTab->pSchema);\n    sqlite3CodeVerifySchema(pParse, iDb);\n    sqlite3TableLock(pParse, iDb, pTab->tnum, 0, pTab->zName);\n\n    assert(v);  /* sqlite3GetVdbe() has always been previously called */\n    if( nExpr==1 && pEList->a[0].pExpr->iColumn<0 ){\n      /* The \"x IN (SELECT rowid FROM table)\" case */\n      int iAddr = sqlite3VdbeAddOp0(v, OP_Once);\n      VdbeCoverage(v);\n\n      sqlite3OpenTable(pParse, iTab, iDb, pTab, OP_OpenRead);\n      eType = IN_INDEX_ROWID;\n      ExplainQueryPlan((pParse, 0,\n            \"USING ROWID SEARCH ON TABLE %s FOR IN-OPERATOR\",pTab->zName));\n      sqlite3VdbeJumpHere(v, iAddr);\n    }else{\n      Index *pIdx;                         /* Iterator variable */\n      int affinity_ok = 1;\n      int i;\n\n      /* Check that the affinity that will be used to perform each \n      ** comparison is the same as the affinity of each column in table\n      ** on the RHS of the IN operator.  If it not, it is not possible to\n      ** use any index of the RHS table.  */\n      for(i=0; i<nExpr && affinity_ok; i++){\n        Expr *pLhs = sqlite3VectorFieldSubexpr(pX->pLeft, i);\n        int iCol = pEList->a[i].pExpr->iColumn;\n        char idxaff = sqlite3TableColumnAffinity(pTab,iCol); /* RHS table */\n        char cmpaff = sqlite3CompareAffinity(pLhs, idxaff);\n        testcase( cmpaff==SQLITE_AFF_BLOB );\n        testcase( cmpaff==SQLITE_AFF_TEXT );\n        switch( cmpaff ){\n          case SQLITE_AFF_BLOB:\n            break;\n          case SQLITE_AFF_TEXT:\n            /* sqlite3CompareAffinity() only returns TEXT if one side or the\n            ** other has no affinity and the other side is TEXT.  Hence,\n            ** the only way for cmpaff to be TEXT is for idxaff to be TEXT\n            ** and for the term on the LHS of the IN to have no affinity. */\n            assert( idxaff==SQLITE_AFF_TEXT );\n            break;\n          default:\n            affinity_ok = sqlite3IsNumericAffinity(idxaff);\n        }\n      }\n\n      if( affinity_ok ){\n        /* Search for an existing index that will work for this IN operator */\n        for(pIdx=pTab->pIndex; pIdx && eType==0; pIdx=pIdx->pNext){\n          Bitmask colUsed;      /* Columns of the index used */\n          Bitmask mCol;         /* Mask for the current column */\n          if( pIdx->nColumn<nExpr ) continue;\n          if( pIdx->pPartIdxWhere!=0 ) continue;\n          /* Maximum nColumn is BMS-2, not BMS-1, so that we can compute\n          ** BITMASK(nExpr) without overflowing */\n          testcase( pIdx->nColumn==BMS-2 );\n          testcase( pIdx->nColumn==BMS-1 );\n          if( pIdx->nColumn>=BMS-1 ) continue;\n          if( mustBeUnique ){\n            if( pIdx->nKeyCol>nExpr\n             ||(pIdx->nColumn>nExpr && !IsUniqueIndex(pIdx))\n            ){\n              continue;  /* This index is not unique over the IN RHS columns */\n            }\n          }\n  \n          colUsed = 0;   /* Columns of index used so far */\n          for(i=0; i<nExpr; i++){\n            Expr *pLhs = sqlite3VectorFieldSubexpr(pX->pLeft, i);\n            Expr *pRhs = pEList->a[i].pExpr;\n            CollSeq *pReq = sqlite3BinaryCompareCollSeq(pParse, pLhs, pRhs);\n            int j;\n  \n            assert( pReq!=0 || pRhs->iColumn==XN_ROWID || pParse->nErr );\n            for(j=0; j<nExpr; j++){\n              if( pIdx->aiColumn[j]!=pRhs->iColumn ) continue;\n              assert( pIdx->azColl[j] );\n              if( pReq!=0 && sqlite3StrICmp(pReq->zName, pIdx->azColl[j])!=0 ){\n                continue;\n              }\n              break;\n            }\n            if( j==nExpr ) break;\n            mCol = MASKBIT(j);\n            if( mCol & colUsed ) break; /* Each column used only once */\n            colUsed |= mCol;\n            if( aiMap ) aiMap[i] = j;\n          }\n  \n          assert( i==nExpr || colUsed!=(MASKBIT(nExpr)-1) );\n          if( colUsed==(MASKBIT(nExpr)-1) ){\n            /* If we reach this point, that means the index pIdx is usable */\n            int iAddr = sqlite3VdbeAddOp0(v, OP_Once); VdbeCoverage(v);\n            ExplainQueryPlan((pParse, 0,\n                              \"USING INDEX %s FOR IN-OPERATOR\",pIdx->zName));\n            sqlite3VdbeAddOp3(v, OP_OpenRead, iTab, pIdx->tnum, iDb);\n            sqlite3VdbeSetP4KeyInfo(pParse, pIdx);\n            VdbeComment((v, \"%s\", pIdx->zName));\n            assert( IN_INDEX_INDEX_DESC == IN_INDEX_INDEX_ASC+1 );\n            eType = IN_INDEX_INDEX_ASC + pIdx->aSortOrder[0];\n  \n            if( prRhsHasNull ){\n#ifdef SQLITE_ENABLE_COLUMN_USED_MASK\n              i64 mask = (1<<nExpr)-1;\n              sqlite3VdbeAddOp4Dup8(v, OP_ColumnsUsed, \n                  iTab, 0, 0, (u8*)&mask, P4_INT64);\n#endif\n              *prRhsHasNull = ++pParse->nMem;\n              if( nExpr==1 ){\n                sqlite3SetHasNullFlag(v, iTab, *prRhsHasNull);\n              }\n            }\n            sqlite3VdbeJumpHere(v, iAddr);\n          }\n        } /* End loop over indexes */\n      } /* End if( affinity_ok ) */\n    } /* End if not an rowid index */\n  } /* End attempt to optimize using an index */\n\n  /* If no preexisting index is available for the IN clause\n  ** and IN_INDEX_NOOP is an allowed reply\n  ** and the RHS of the IN operator is a list, not a subquery\n  ** and the RHS is not constant or has two or fewer terms,\n  ** then it is not worth creating an ephemeral table to evaluate\n  ** the IN operator so return IN_INDEX_NOOP.\n  */\n  if( eType==0\n   && (inFlags & IN_INDEX_NOOP_OK)\n   && !ExprHasProperty(pX, EP_xIsSelect)\n   && (!sqlite3InRhsIsConstant(pX) || pX->x.pList->nExpr<=2)\n  ){\n    eType = IN_INDEX_NOOP;\n  }\n\n  if( eType==0 ){\n    /* Could not find an existing table or index to use as the RHS b-tree.\n    ** We will have to generate an ephemeral table to do the job.\n    */\n    u32 savedNQueryLoop = pParse->nQueryLoop;\n    int rMayHaveNull = 0;\n    eType = IN_INDEX_EPH;\n    if( inFlags & IN_INDEX_LOOP ){\n      pParse->nQueryLoop = 0;\n    }else if( prRhsHasNull ){\n      *prRhsHasNull = rMayHaveNull = ++pParse->nMem;\n    }\n    assert( pX->op==TK_IN );\n    sqlite3CodeRhsOfIN(pParse, pX, iTab);\n    if( rMayHaveNull ){\n      sqlite3SetHasNullFlag(v, iTab, rMayHaveNull);\n    }\n    pParse->nQueryLoop = savedNQueryLoop;\n  }\n\n  if( aiMap && eType!=IN_INDEX_INDEX_ASC && eType!=IN_INDEX_INDEX_DESC ){\n    int i, n;\n    n = sqlite3ExprVectorSize(pX->pLeft);\n    for(i=0; i<n; i++) aiMap[i] = i;\n  }\n  *piTab = iTab;\n  return eType;\n}\n#endif\n\n#ifndef SQLITE_OMIT_SUBQUERY\n/*\n** Argument pExpr is an (?, ?...) IN(...) expression. This \n** function allocates and returns a nul-terminated string containing \n** the affinities to be used for each column of the comparison.\n**\n** It is the responsibility of the caller to ensure that the returned\n** string is eventually freed using sqlite3DbFree().\n*/\nstatic char *exprINAffinity(Parse *pParse, Expr *pExpr){\n  Expr *pLeft = pExpr->pLeft;\n  int nVal = sqlite3ExprVectorSize(pLeft);\n  Select *pSelect = (pExpr->flags & EP_xIsSelect) ? pExpr->x.pSelect : 0;\n  char *zRet;\n\n  assert( pExpr->op==TK_IN );\n  zRet = sqlite3DbMallocRaw(pParse->db, nVal+1);\n  if( zRet ){\n    int i;\n    for(i=0; i<nVal; i++){\n      Expr *pA = sqlite3VectorFieldSubexpr(pLeft, i);\n      char a = sqlite3ExprAffinity(pA);\n      if( pSelect ){\n        zRet[i] = sqlite3CompareAffinity(pSelect->pEList->a[i].pExpr, a);\n      }else{\n        zRet[i] = a;\n      }\n    }\n    zRet[nVal] = '\\0';\n  }\n  return zRet;\n}\n#endif\n\n#ifndef SQLITE_OMIT_SUBQUERY\n/*\n** Load the Parse object passed as the first argument with an error \n** message of the form:\n**\n**   \"sub-select returns N columns - expected M\"\n*/   \nSQLITE_PRIVATE void sqlite3SubselectError(Parse *pParse, int nActual, int nExpect){\n  const char *zFmt = \"sub-select returns %d columns - expected %d\";\n  sqlite3ErrorMsg(pParse, zFmt, nActual, nExpect);\n}\n#endif\n\n/*\n** Expression pExpr is a vector that has been used in a context where\n** it is not permitted. If pExpr is a sub-select vector, this routine \n** loads the Parse object with a message of the form:\n**\n**   \"sub-select returns N columns - expected 1\"\n**\n** Or, if it is a regular scalar vector:\n**\n**   \"row value misused\"\n*/   \nSQLITE_PRIVATE void sqlite3VectorErrorMsg(Parse *pParse, Expr *pExpr){\n#ifndef SQLITE_OMIT_SUBQUERY\n  if( pExpr->flags & EP_xIsSelect ){\n    sqlite3SubselectError(pParse, pExpr->x.pSelect->pEList->nExpr, 1);\n  }else\n#endif\n  {\n    sqlite3ErrorMsg(pParse, \"row value misused\");\n  }\n}\n\n#ifndef SQLITE_OMIT_SUBQUERY\n/*\n** Generate code that will construct an ephemeral table containing all terms\n** in the RHS of an IN operator.  The IN operator can be in either of two\n** forms:\n**\n**     x IN (4,5,11)              -- IN operator with list on right-hand side\n**     x IN (SELECT a FROM b)     -- IN operator with subquery on the right\n**\n** The pExpr parameter is the IN operator.  The cursor number for the\n** constructed ephermeral table is returned.  The first time the ephemeral\n** table is computed, the cursor number is also stored in pExpr->iTable,\n** however the cursor number returned might not be the same, as it might\n** have been duplicated using OP_OpenDup.\n**\n** If the LHS expression (\"x\" in the examples) is a column value, or\n** the SELECT statement returns a column value, then the affinity of that\n** column is used to build the index keys. If both 'x' and the\n** SELECT... statement are columns, then numeric affinity is used\n** if either column has NUMERIC or INTEGER affinity. If neither\n** 'x' nor the SELECT... statement are columns, then numeric affinity\n** is used.\n*/\nSQLITE_PRIVATE void sqlite3CodeRhsOfIN(\n  Parse *pParse,          /* Parsing context */\n  Expr *pExpr,            /* The IN operator */\n  int iTab                /* Use this cursor number */\n){\n  int addrOnce = 0;           /* Address of the OP_Once instruction at top */\n  int addr;                   /* Address of OP_OpenEphemeral instruction */\n  Expr *pLeft;                /* the LHS of the IN operator */\n  KeyInfo *pKeyInfo = 0;      /* Key information */\n  int nVal;                   /* Size of vector pLeft */\n  Vdbe *v;                    /* The prepared statement under construction */\n\n  v = pParse->pVdbe;\n  assert( v!=0 );\n\n  /* The evaluation of the IN must be repeated every time it\n  ** is encountered if any of the following is true:\n  **\n  **    *  The right-hand side is a correlated subquery\n  **    *  The right-hand side is an expression list containing variables\n  **    *  We are inside a trigger\n  **\n  ** If all of the above are false, then we can compute the RHS just once\n  ** and reuse it many names.\n  */\n  if( !ExprHasProperty(pExpr, EP_VarSelect) && pParse->iSelfTab==0 ){\n    /* Reuse of the RHS is allowed */\n    /* If this routine has already been coded, but the previous code\n    ** might not have been invoked yet, so invoke it now as a subroutine. \n    */\n    if( ExprHasProperty(pExpr, EP_Subrtn) ){\n      addrOnce = sqlite3VdbeAddOp0(v, OP_Once); VdbeCoverage(v);\n      if( ExprHasProperty(pExpr, EP_xIsSelect) ){\n        ExplainQueryPlan((pParse, 0, \"REUSE LIST SUBQUERY %d\",\n              pExpr->x.pSelect->selId));\n      }\n      sqlite3VdbeAddOp2(v, OP_Gosub, pExpr->y.sub.regReturn,\n                        pExpr->y.sub.iAddr);\n      sqlite3VdbeAddOp2(v, OP_OpenDup, iTab, pExpr->iTable);\n      sqlite3VdbeJumpHere(v, addrOnce);\n      return;\n    }\n\n    /* Begin coding the subroutine */\n    ExprSetProperty(pExpr, EP_Subrtn);\n    pExpr->y.sub.regReturn = ++pParse->nMem;\n    pExpr->y.sub.iAddr =\n      sqlite3VdbeAddOp2(v, OP_Integer, 0, pExpr->y.sub.regReturn) + 1;\n    VdbeComment((v, \"return address\"));\n\n    addrOnce = sqlite3VdbeAddOp0(v, OP_Once); VdbeCoverage(v);\n  }\n\n  /* Check to see if this is a vector IN operator */\n  pLeft = pExpr->pLeft;\n  nVal = sqlite3ExprVectorSize(pLeft);\n\n  /* Construct the ephemeral table that will contain the content of\n  ** RHS of the IN operator.\n  */\n  pExpr->iTable = iTab;\n  addr = sqlite3VdbeAddOp2(v, OP_OpenEphemeral, pExpr->iTable, nVal);\n#ifdef SQLITE_ENABLE_EXPLAIN_COMMENTS\n  if( ExprHasProperty(pExpr, EP_xIsSelect) ){\n    VdbeComment((v, \"Result of SELECT %u\", pExpr->x.pSelect->selId));\n  }else{\n    VdbeComment((v, \"RHS of IN operator\"));\n  }\n#endif\n  pKeyInfo = sqlite3KeyInfoAlloc(pParse->db, nVal, 1);\n\n  if( ExprHasProperty(pExpr, EP_xIsSelect) ){\n    /* Case 1:     expr IN (SELECT ...)\n    **\n    ** Generate code to write the results of the select into the temporary\n    ** table allocated and opened above.\n    */\n    Select *pSelect = pExpr->x.pSelect;\n    ExprList *pEList = pSelect->pEList;\n\n    ExplainQueryPlan((pParse, 1, \"%sLIST SUBQUERY %d\",\n        addrOnce?\"\":\"CORRELATED \", pSelect->selId\n    ));\n    /* If the LHS and RHS of the IN operator do not match, that\n    ** error will have been caught long before we reach this point. */\n    if( ALWAYS(pEList->nExpr==nVal) ){\n      SelectDest dest;\n      int i;\n      sqlite3SelectDestInit(&dest, SRT_Set, iTab);\n      dest.zAffSdst = exprINAffinity(pParse, pExpr);\n      pSelect->iLimit = 0;\n      testcase( pSelect->selFlags & SF_Distinct );\n      testcase( pKeyInfo==0 ); /* Caused by OOM in sqlite3KeyInfoAlloc() */\n      if( sqlite3Select(pParse, pSelect, &dest) ){\n        sqlite3DbFree(pParse->db, dest.zAffSdst);\n        sqlite3KeyInfoUnref(pKeyInfo);\n        return;\n      }\n      sqlite3DbFree(pParse->db, dest.zAffSdst);\n      assert( pKeyInfo!=0 ); /* OOM will cause exit after sqlite3Select() */\n      assert( pEList!=0 );\n      assert( pEList->nExpr>0 );\n      assert( sqlite3KeyInfoIsWriteable(pKeyInfo) );\n      for(i=0; i<nVal; i++){\n        Expr *p = sqlite3VectorFieldSubexpr(pLeft, i);\n        pKeyInfo->aColl[i] = sqlite3BinaryCompareCollSeq(\n            pParse, p, pEList->a[i].pExpr\n        );\n      }\n    }\n  }else if( ALWAYS(pExpr->x.pList!=0) ){\n    /* Case 2:     expr IN (exprlist)\n    **\n    ** For each expression, build an index key from the evaluation and\n    ** store it in the temporary table. If <expr> is a column, then use\n    ** that columns affinity when building index keys. If <expr> is not\n    ** a column, use numeric affinity.\n    */\n    char affinity;            /* Affinity of the LHS of the IN */\n    int i;\n    ExprList *pList = pExpr->x.pList;\n    struct ExprList_item *pItem;\n    int r1, r2, r3;\n    affinity = sqlite3ExprAffinity(pLeft);\n    if( !affinity ){\n      affinity = SQLITE_AFF_BLOB;\n    }\n    if( pKeyInfo ){\n      assert( sqlite3KeyInfoIsWriteable(pKeyInfo) );\n      pKeyInfo->aColl[0] = sqlite3ExprCollSeq(pParse, pExpr->pLeft);\n    }\n\n    /* Loop through each expression in <exprlist>. */\n    r1 = sqlite3GetTempReg(pParse);\n    r2 = sqlite3GetTempReg(pParse);\n    for(i=pList->nExpr, pItem=pList->a; i>0; i--, pItem++){\n      Expr *pE2 = pItem->pExpr;\n\n      /* If the expression is not constant then we will need to\n      ** disable the test that was generated above that makes sure\n      ** this code only executes once.  Because for a non-constant\n      ** expression we need to rerun this code each time.\n      */\n      if( addrOnce && !sqlite3ExprIsConstant(pE2) ){\n        sqlite3VdbeChangeToNoop(v, addrOnce);\n        addrOnce = 0;\n      }\n\n      /* Evaluate the expression and insert it into the temp table */\n      r3 = sqlite3ExprCodeTarget(pParse, pE2, r1);\n      sqlite3VdbeAddOp4(v, OP_MakeRecord, r3, 1, r2, &affinity, 1);\n      sqlite3VdbeAddOp4Int(v, OP_IdxInsert, iTab, r2, r3, 1);\n    }\n    sqlite3ReleaseTempReg(pParse, r1);\n    sqlite3ReleaseTempReg(pParse, r2);\n  }\n  if( pKeyInfo ){\n    sqlite3VdbeChangeP4(v, addr, (void *)pKeyInfo, P4_KEYINFO);\n  }\n  if( addrOnce ){\n    sqlite3VdbeJumpHere(v, addrOnce);\n    /* Subroutine return */\n    sqlite3VdbeAddOp1(v, OP_Return, pExpr->y.sub.regReturn);\n    sqlite3VdbeChangeP1(v, pExpr->y.sub.iAddr-1, sqlite3VdbeCurrentAddr(v)-1);\n  }\n}\n#endif /* SQLITE_OMIT_SUBQUERY */\n\n/*\n** Generate code for scalar subqueries used as a subquery expression\n** or EXISTS operator:\n**\n**     (SELECT a FROM b)          -- subquery\n**     EXISTS (SELECT a FROM b)   -- EXISTS subquery\n**\n** The pExpr parameter is the SELECT or EXISTS operator to be coded.\n**\n** The register that holds the result.  For a multi-column SELECT, \n** the result is stored in a contiguous array of registers and the\n** return value is the register of the left-most result column.\n** Return 0 if an error occurs.\n*/\n#ifndef SQLITE_OMIT_SUBQUERY\nSQLITE_PRIVATE int sqlite3CodeSubselect(Parse *pParse, Expr *pExpr){\n  int addrOnce = 0;           /* Address of OP_Once at top of subroutine */\n  int rReg = 0;               /* Register storing resulting */\n  Select *pSel;               /* SELECT statement to encode */\n  SelectDest dest;            /* How to deal with SELECT result */\n  int nReg;                   /* Registers to allocate */\n  Expr *pLimit;               /* New limit expression */\n\n  Vdbe *v = pParse->pVdbe;\n  assert( v!=0 );\n  testcase( pExpr->op==TK_EXISTS );\n  testcase( pExpr->op==TK_SELECT );\n  assert( pExpr->op==TK_EXISTS || pExpr->op==TK_SELECT );\n  assert( ExprHasProperty(pExpr, EP_xIsSelect) );\n  pSel = pExpr->x.pSelect;\n\n  /* The evaluation of the EXISTS/SELECT must be repeated every time it\n  ** is encountered if any of the following is true:\n  **\n  **    *  The right-hand side is a correlated subquery\n  **    *  The right-hand side is an expression list containing variables\n  **    *  We are inside a trigger\n  **\n  ** If all of the above are false, then we can run this code just once\n  ** save the results, and reuse the same result on subsequent invocations.\n  */\n  if( !ExprHasProperty(pExpr, EP_VarSelect) ){\n    /* If this routine has already been coded, then invoke it as a\n    ** subroutine. */\n    if( ExprHasProperty(pExpr, EP_Subrtn) ){\n      ExplainQueryPlan((pParse, 0, \"REUSE SUBQUERY %d\", pSel->selId));\n      sqlite3VdbeAddOp2(v, OP_Gosub, pExpr->y.sub.regReturn,\n                        pExpr->y.sub.iAddr);\n      return pExpr->iTable;\n    }\n\n    /* Begin coding the subroutine */\n    ExprSetProperty(pExpr, EP_Subrtn);\n    pExpr->y.sub.regReturn = ++pParse->nMem;\n    pExpr->y.sub.iAddr =\n      sqlite3VdbeAddOp2(v, OP_Integer, 0, pExpr->y.sub.regReturn) + 1;\n    VdbeComment((v, \"return address\"));\n\n    addrOnce = sqlite3VdbeAddOp0(v, OP_Once); VdbeCoverage(v);\n  }\n  \n  /* For a SELECT, generate code to put the values for all columns of\n  ** the first row into an array of registers and return the index of\n  ** the first register.\n  **\n  ** If this is an EXISTS, write an integer 0 (not exists) or 1 (exists)\n  ** into a register and return that register number.\n  **\n  ** In both cases, the query is augmented with \"LIMIT 1\".  Any \n  ** preexisting limit is discarded in place of the new LIMIT 1.\n  */\n  ExplainQueryPlan((pParse, 1, \"%sSCALAR SUBQUERY %d\",\n        addrOnce?\"\":\"CORRELATED \", pSel->selId));\n  nReg = pExpr->op==TK_SELECT ? pSel->pEList->nExpr : 1;\n  sqlite3SelectDestInit(&dest, 0, pParse->nMem+1);\n  pParse->nMem += nReg;\n  if( pExpr->op==TK_SELECT ){\n    dest.eDest = SRT_Mem;\n    dest.iSdst = dest.iSDParm;\n    dest.nSdst = nReg;\n    sqlite3VdbeAddOp3(v, OP_Null, 0, dest.iSDParm, dest.iSDParm+nReg-1);\n    VdbeComment((v, \"Init subquery result\"));\n  }else{\n    dest.eDest = SRT_Exists;\n    sqlite3VdbeAddOp2(v, OP_Integer, 0, dest.iSDParm);\n    VdbeComment((v, \"Init EXISTS result\"));\n  }\n  pLimit = sqlite3ExprAlloc(pParse->db, TK_INTEGER,&sqlite3IntTokens[1], 0);\n  if( pSel->pLimit ){\n    sqlite3ExprDelete(pParse->db, pSel->pLimit->pLeft);\n    pSel->pLimit->pLeft = pLimit;\n  }else{\n    pSel->pLimit = sqlite3PExpr(pParse, TK_LIMIT, pLimit, 0);\n  }\n  pSel->iLimit = 0;\n  if( sqlite3Select(pParse, pSel, &dest) ){\n    return 0;\n  }\n  pExpr->iTable = rReg = dest.iSDParm;\n  ExprSetVVAProperty(pExpr, EP_NoReduce);\n  if( addrOnce ){\n    sqlite3VdbeJumpHere(v, addrOnce);\n\n    /* Subroutine return */\n    sqlite3VdbeAddOp1(v, OP_Return, pExpr->y.sub.regReturn);\n    sqlite3VdbeChangeP1(v, pExpr->y.sub.iAddr-1, sqlite3VdbeCurrentAddr(v)-1);\n  }\n\n  return rReg;\n}\n#endif /* SQLITE_OMIT_SUBQUERY */\n\n#ifndef SQLITE_OMIT_SUBQUERY\n/*\n** Expr pIn is an IN(...) expression. This function checks that the \n** sub-select on the RHS of the IN() operator has the same number of \n** columns as the vector on the LHS. Or, if the RHS of the IN() is not \n** a sub-query, that the LHS is a vector of size 1.\n*/\nSQLITE_PRIVATE int sqlite3ExprCheckIN(Parse *pParse, Expr *pIn){\n  int nVector = sqlite3ExprVectorSize(pIn->pLeft);\n  if( (pIn->flags & EP_xIsSelect) ){\n    if( nVector!=pIn->x.pSelect->pEList->nExpr ){\n      sqlite3SubselectError(pParse, pIn->x.pSelect->pEList->nExpr, nVector);\n      return 1;\n    }\n  }else if( nVector!=1 ){\n    sqlite3VectorErrorMsg(pParse, pIn->pLeft);\n    return 1;\n  }\n  return 0;\n}\n#endif\n\n#ifndef SQLITE_OMIT_SUBQUERY\n/*\n** Generate code for an IN expression.\n**\n**      x IN (SELECT ...)\n**      x IN (value, value, ...)\n**\n** The left-hand side (LHS) is a scalar or vector expression.  The \n** right-hand side (RHS) is an array of zero or more scalar values, or a\n** subquery.  If the RHS is a subquery, the number of result columns must\n** match the number of columns in the vector on the LHS.  If the RHS is\n** a list of values, the LHS must be a scalar. \n**\n** The IN operator is true if the LHS value is contained within the RHS.\n** The result is false if the LHS is definitely not in the RHS.  The \n** result is NULL if the presence of the LHS in the RHS cannot be \n** determined due to NULLs.\n**\n** This routine generates code that jumps to destIfFalse if the LHS is not \n** contained within the RHS.  If due to NULLs we cannot determine if the LHS\n** is contained in the RHS then jump to destIfNull.  If the LHS is contained\n** within the RHS then fall through.\n**\n** See the separate in-operator.md documentation file in the canonical\n** SQLite source tree for additional information.\n*/\nstatic void sqlite3ExprCodeIN(\n  Parse *pParse,        /* Parsing and code generating context */\n  Expr *pExpr,          /* The IN expression */\n  int destIfFalse,      /* Jump here if LHS is not contained in the RHS */\n  int destIfNull        /* Jump here if the results are unknown due to NULLs */\n){\n  int rRhsHasNull = 0;  /* Register that is true if RHS contains NULL values */\n  int eType;            /* Type of the RHS */\n  int rLhs;             /* Register(s) holding the LHS values */\n  int rLhsOrig;         /* LHS values prior to reordering by aiMap[] */\n  Vdbe *v;              /* Statement under construction */\n  int *aiMap = 0;       /* Map from vector field to index column */\n  char *zAff = 0;       /* Affinity string for comparisons */\n  int nVector;          /* Size of vectors for this IN operator */\n  int iDummy;           /* Dummy parameter to exprCodeVector() */\n  Expr *pLeft;          /* The LHS of the IN operator */\n  int i;                /* loop counter */\n  int destStep2;        /* Where to jump when NULLs seen in step 2 */\n  int destStep6 = 0;    /* Start of code for Step 6 */\n  int addrTruthOp;      /* Address of opcode that determines the IN is true */\n  int destNotNull;      /* Jump here if a comparison is not true in step 6 */\n  int addrTop;          /* Top of the step-6 loop */ \n  int iTab = 0;         /* Index to use */\n\n  pLeft = pExpr->pLeft;\n  if( sqlite3ExprCheckIN(pParse, pExpr) ) return;\n  zAff = exprINAffinity(pParse, pExpr);\n  nVector = sqlite3ExprVectorSize(pExpr->pLeft);\n  aiMap = (int*)sqlite3DbMallocZero(\n      pParse->db, nVector*(sizeof(int) + sizeof(char)) + 1\n  );\n  if( pParse->db->mallocFailed ) goto sqlite3ExprCodeIN_oom_error;\n\n  /* Attempt to compute the RHS. After this step, if anything other than\n  ** IN_INDEX_NOOP is returned, the table opened with cursor iTab\n  ** contains the values that make up the RHS. If IN_INDEX_NOOP is returned,\n  ** the RHS has not yet been coded.  */\n  v = pParse->pVdbe;\n  assert( v!=0 );       /* OOM detected prior to this routine */\n  VdbeNoopComment((v, \"begin IN expr\"));\n  eType = sqlite3FindInIndex(pParse, pExpr,\n                             IN_INDEX_MEMBERSHIP | IN_INDEX_NOOP_OK,\n                             destIfFalse==destIfNull ? 0 : &rRhsHasNull,\n                             aiMap, &iTab);\n\n  assert( pParse->nErr || nVector==1 || eType==IN_INDEX_EPH\n       || eType==IN_INDEX_INDEX_ASC || eType==IN_INDEX_INDEX_DESC \n  );\n#ifdef SQLITE_DEBUG\n  /* Confirm that aiMap[] contains nVector integer values between 0 and\n  ** nVector-1. */\n  for(i=0; i<nVector; i++){\n    int j, cnt;\n    for(cnt=j=0; j<nVector; j++) if( aiMap[j]==i ) cnt++;\n    assert( cnt==1 );\n  }\n#endif\n\n  /* Code the LHS, the <expr> from \"<expr> IN (...)\". If the LHS is a \n  ** vector, then it is stored in an array of nVector registers starting \n  ** at r1.\n  **\n  ** sqlite3FindInIndex() might have reordered the fields of the LHS vector\n  ** so that the fields are in the same order as an existing index.   The\n  ** aiMap[] array contains a mapping from the original LHS field order to\n  ** the field order that matches the RHS index.\n  */\n  rLhsOrig = exprCodeVector(pParse, pLeft, &iDummy);\n  for(i=0; i<nVector && aiMap[i]==i; i++){} /* Are LHS fields reordered? */\n  if( i==nVector ){\n    /* LHS fields are not reordered */\n    rLhs = rLhsOrig;\n  }else{\n    /* Need to reorder the LHS fields according to aiMap */\n    rLhs = sqlite3GetTempRange(pParse, nVector);\n    for(i=0; i<nVector; i++){\n      sqlite3VdbeAddOp3(v, OP_Copy, rLhsOrig+i, rLhs+aiMap[i], 0);\n    }\n  }\n\n  /* If sqlite3FindInIndex() did not find or create an index that is\n  ** suitable for evaluating the IN operator, then evaluate using a\n  ** sequence of comparisons.\n  **\n  ** This is step (1) in the in-operator.md optimized algorithm.\n  */\n  if( eType==IN_INDEX_NOOP ){\n    ExprList *pList = pExpr->x.pList;\n    CollSeq *pColl = sqlite3ExprCollSeq(pParse, pExpr->pLeft);\n    int labelOk = sqlite3VdbeMakeLabel(pParse);\n    int r2, regToFree;\n    int regCkNull = 0;\n    int ii;\n    assert( !ExprHasProperty(pExpr, EP_xIsSelect) );\n    if( destIfNull!=destIfFalse ){\n      regCkNull = sqlite3GetTempReg(pParse);\n      sqlite3VdbeAddOp3(v, OP_BitAnd, rLhs, rLhs, regCkNull);\n    }\n    for(ii=0; ii<pList->nExpr; ii++){\n      r2 = sqlite3ExprCodeTemp(pParse, pList->a[ii].pExpr, &regToFree);\n      if( regCkNull && sqlite3ExprCanBeNull(pList->a[ii].pExpr) ){\n        sqlite3VdbeAddOp3(v, OP_BitAnd, regCkNull, r2, regCkNull);\n      }\n      if( ii<pList->nExpr-1 || destIfNull!=destIfFalse ){\n        sqlite3VdbeAddOp4(v, OP_Eq, rLhs, labelOk, r2,\n                          (void*)pColl, P4_COLLSEQ);\n        VdbeCoverageIf(v, ii<pList->nExpr-1);\n        VdbeCoverageIf(v, ii==pList->nExpr-1);\n        sqlite3VdbeChangeP5(v, zAff[0]);\n      }else{\n        assert( destIfNull==destIfFalse );\n        sqlite3VdbeAddOp4(v, OP_Ne, rLhs, destIfFalse, r2,\n                          (void*)pColl, P4_COLLSEQ); VdbeCoverage(v);\n        sqlite3VdbeChangeP5(v, zAff[0] | SQLITE_JUMPIFNULL);\n      }\n      sqlite3ReleaseTempReg(pParse, regToFree);\n    }\n    if( regCkNull ){\n      sqlite3VdbeAddOp2(v, OP_IsNull, regCkNull, destIfNull); VdbeCoverage(v);\n      sqlite3VdbeGoto(v, destIfFalse);\n    }\n    sqlite3VdbeResolveLabel(v, labelOk);\n    sqlite3ReleaseTempReg(pParse, regCkNull);\n    goto sqlite3ExprCodeIN_finished;\n  }\n\n  /* Step 2: Check to see if the LHS contains any NULL columns.  If the\n  ** LHS does contain NULLs then the result must be either FALSE or NULL.\n  ** We will then skip the binary search of the RHS.\n  */\n  if( destIfNull==destIfFalse ){\n    destStep2 = destIfFalse;\n  }else{\n    destStep2 = destStep6 = sqlite3VdbeMakeLabel(pParse);\n  }\n  for(i=0; i<nVector; i++){\n    Expr *p = sqlite3VectorFieldSubexpr(pExpr->pLeft, i);\n    if( sqlite3ExprCanBeNull(p) ){\n      sqlite3VdbeAddOp2(v, OP_IsNull, rLhs+i, destStep2);\n      VdbeCoverage(v);\n    }\n  }\n\n  /* Step 3.  The LHS is now known to be non-NULL.  Do the binary search\n  ** of the RHS using the LHS as a probe.  If found, the result is\n  ** true.\n  */\n  if( eType==IN_INDEX_ROWID ){\n    /* In this case, the RHS is the ROWID of table b-tree and so we also\n    ** know that the RHS is non-NULL.  Hence, we combine steps 3 and 4\n    ** into a single opcode. */\n    sqlite3VdbeAddOp3(v, OP_SeekRowid, iTab, destIfFalse, rLhs);\n    VdbeCoverage(v);\n    addrTruthOp = sqlite3VdbeAddOp0(v, OP_Goto);  /* Return True */\n  }else{\n    sqlite3VdbeAddOp4(v, OP_Affinity, rLhs, nVector, 0, zAff, nVector);\n    if( destIfFalse==destIfNull ){\n      /* Combine Step 3 and Step 5 into a single opcode */\n      sqlite3VdbeAddOp4Int(v, OP_NotFound, iTab, destIfFalse,\n                           rLhs, nVector); VdbeCoverage(v);\n      goto sqlite3ExprCodeIN_finished;\n    }\n    /* Ordinary Step 3, for the case where FALSE and NULL are distinct */\n    addrTruthOp = sqlite3VdbeAddOp4Int(v, OP_Found, iTab, 0,\n                                      rLhs, nVector); VdbeCoverage(v);\n  }\n\n  /* Step 4.  If the RHS is known to be non-NULL and we did not find\n  ** an match on the search above, then the result must be FALSE.\n  */\n  if( rRhsHasNull && nVector==1 ){\n    sqlite3VdbeAddOp2(v, OP_NotNull, rRhsHasNull, destIfFalse);\n    VdbeCoverage(v);\n  }\n\n  /* Step 5.  If we do not care about the difference between NULL and\n  ** FALSE, then just return false. \n  */\n  if( destIfFalse==destIfNull ) sqlite3VdbeGoto(v, destIfFalse);\n\n  /* Step 6: Loop through rows of the RHS.  Compare each row to the LHS.\n  ** If any comparison is NULL, then the result is NULL.  If all\n  ** comparisons are FALSE then the final result is FALSE.\n  **\n  ** For a scalar LHS, it is sufficient to check just the first row\n  ** of the RHS.\n  */\n  if( destStep6 ) sqlite3VdbeResolveLabel(v, destStep6);\n  addrTop = sqlite3VdbeAddOp2(v, OP_Rewind, iTab, destIfFalse);\n  VdbeCoverage(v);\n  if( nVector>1 ){\n    destNotNull = sqlite3VdbeMakeLabel(pParse);\n  }else{\n    /* For nVector==1, combine steps 6 and 7 by immediately returning\n    ** FALSE if the first comparison is not NULL */\n    destNotNull = destIfFalse;\n  }\n  for(i=0; i<nVector; i++){\n    Expr *p;\n    CollSeq *pColl;\n    int r3 = sqlite3GetTempReg(pParse);\n    p = sqlite3VectorFieldSubexpr(pLeft, i);\n    pColl = sqlite3ExprCollSeq(pParse, p);\n    sqlite3VdbeAddOp3(v, OP_Column, iTab, i, r3);\n    sqlite3VdbeAddOp4(v, OP_Ne, rLhs+i, destNotNull, r3,\n                      (void*)pColl, P4_COLLSEQ);\n    VdbeCoverage(v);\n    sqlite3ReleaseTempReg(pParse, r3);\n  }\n  sqlite3VdbeAddOp2(v, OP_Goto, 0, destIfNull);\n  if( nVector>1 ){\n    sqlite3VdbeResolveLabel(v, destNotNull);\n    sqlite3VdbeAddOp2(v, OP_Next, iTab, addrTop+1);\n    VdbeCoverage(v);\n\n    /* Step 7:  If we reach this point, we know that the result must\n    ** be false. */\n    sqlite3VdbeAddOp2(v, OP_Goto, 0, destIfFalse);\n  }\n\n  /* Jumps here in order to return true. */\n  sqlite3VdbeJumpHere(v, addrTruthOp);\n\nsqlite3ExprCodeIN_finished:\n  if( rLhs!=rLhsOrig ) sqlite3ReleaseTempReg(pParse, rLhs);\n  VdbeComment((v, \"end IN expr\"));\nsqlite3ExprCodeIN_oom_error:\n  sqlite3DbFree(pParse->db, aiMap);\n  sqlite3DbFree(pParse->db, zAff);\n}\n#endif /* SQLITE_OMIT_SUBQUERY */\n\n#ifndef SQLITE_OMIT_FLOATING_POINT\n/*\n** Generate an instruction that will put the floating point\n** value described by z[0..n-1] into register iMem.\n**\n** The z[] string will probably not be zero-terminated.  But the \n** z[n] character is guaranteed to be something that does not look\n** like the continuation of the number.\n*/\nstatic void codeReal(Vdbe *v, const char *z, int negateFlag, int iMem){\n  if( ALWAYS(z!=0) ){\n    double value;\n    sqlite3AtoF(z, &value, sqlite3Strlen30(z), SQLITE_UTF8);\n    assert( !sqlite3IsNaN(value) ); /* The new AtoF never returns NaN */\n    if( negateFlag ) value = -value;\n    sqlite3VdbeAddOp4Dup8(v, OP_Real, 0, iMem, 0, (u8*)&value, P4_REAL);\n  }\n}\n#endif\n\n\n/*\n** Generate an instruction that will put the integer describe by\n** text z[0..n-1] into register iMem.\n**\n** Expr.u.zToken is always UTF8 and zero-terminated.\n*/\nstatic void codeInteger(Parse *pParse, Expr *pExpr, int negFlag, int iMem){\n  Vdbe *v = pParse->pVdbe;\n  if( pExpr->flags & EP_IntValue ){\n    int i = pExpr->u.iValue;\n    assert( i>=0 );\n    if( negFlag ) i = -i;\n    sqlite3VdbeAddOp2(v, OP_Integer, i, iMem);\n  }else{\n    int c;\n    i64 value;\n    const char *z = pExpr->u.zToken;\n    assert( z!=0 );\n    c = sqlite3DecOrHexToI64(z, &value);\n    if( (c==3 && !negFlag) || (c==2) || (negFlag && value==SMALLEST_INT64)){\n#ifdef SQLITE_OMIT_FLOATING_POINT\n      sqlite3ErrorMsg(pParse, \"oversized integer: %s%s\", negFlag ? \"-\" : \"\", z);\n#else\n#ifndef SQLITE_OMIT_HEX_INTEGER\n      if( sqlite3_strnicmp(z,\"0x\",2)==0 ){\n        sqlite3ErrorMsg(pParse, \"hex literal too big: %s%s\", negFlag?\"-\":\"\",z);\n      }else\n#endif\n      {\n        codeReal(v, z, negFlag, iMem);\n      }\n#endif\n    }else{\n      if( negFlag ){ value = c==3 ? SMALLEST_INT64 : -value; }\n      sqlite3VdbeAddOp4Dup8(v, OP_Int64, 0, iMem, 0, (u8*)&value, P4_INT64);\n    }\n  }\n}\n\n\n/* Generate code that will load into register regOut a value that is\n** appropriate for the iIdxCol-th column of index pIdx.\n*/\nSQLITE_PRIVATE void sqlite3ExprCodeLoadIndexColumn(\n  Parse *pParse,  /* The parsing context */\n  Index *pIdx,    /* The index whose column is to be loaded */\n  int iTabCur,    /* Cursor pointing to a table row */\n  int iIdxCol,    /* The column of the index to be loaded */\n  int regOut      /* Store the index column value in this register */\n){\n  i16 iTabCol = pIdx->aiColumn[iIdxCol];\n  if( iTabCol==XN_EXPR ){\n    assert( pIdx->aColExpr );\n    assert( pIdx->aColExpr->nExpr>iIdxCol );\n    pParse->iSelfTab = iTabCur + 1;\n    sqlite3ExprCodeCopy(pParse, pIdx->aColExpr->a[iIdxCol].pExpr, regOut);\n    pParse->iSelfTab = 0;\n  }else{\n    sqlite3ExprCodeGetColumnOfTable(pParse->pVdbe, pIdx->pTable, iTabCur,\n                                    iTabCol, regOut);\n  }\n}\n\n/*\n** Generate code to extract the value of the iCol-th column of a table.\n*/\nSQLITE_PRIVATE void sqlite3ExprCodeGetColumnOfTable(\n  Vdbe *v,        /* The VDBE under construction */\n  Table *pTab,    /* The table containing the value */\n  int iTabCur,    /* The table cursor.  Or the PK cursor for WITHOUT ROWID */\n  int iCol,       /* Index of the column to extract */\n  int regOut      /* Extract the value into this register */\n){\n  if( pTab==0 ){\n    sqlite3VdbeAddOp3(v, OP_Column, iTabCur, iCol, regOut);\n    return;\n  }\n  if( iCol<0 || iCol==pTab->iPKey ){\n    sqlite3VdbeAddOp2(v, OP_Rowid, iTabCur, regOut);\n  }else{\n    int op = IsVirtual(pTab) ? OP_VColumn : OP_Column;\n    int x = iCol;\n    if( !HasRowid(pTab) && !IsVirtual(pTab) ){\n      x = sqlite3ColumnOfIndex(sqlite3PrimaryKeyIndex(pTab), iCol);\n    }\n    sqlite3VdbeAddOp3(v, op, iTabCur, x, regOut);\n  }\n  if( iCol>=0 ){\n    sqlite3ColumnDefault(v, pTab, iCol, regOut);\n  }\n}\n\n/*\n** Generate code that will extract the iColumn-th column from\n** table pTab and store the column value in register iReg. \n**\n** There must be an open cursor to pTab in iTable when this routine\n** is called.  If iColumn<0 then code is generated that extracts the rowid.\n*/\nSQLITE_PRIVATE int sqlite3ExprCodeGetColumn(\n  Parse *pParse,   /* Parsing and code generating context */\n  Table *pTab,     /* Description of the table we are reading from */\n  int iColumn,     /* Index of the table column */\n  int iTable,      /* The cursor pointing to the table */\n  int iReg,        /* Store results here */\n  u8 p5            /* P5 value for OP_Column + FLAGS */\n){\n  Vdbe *v = pParse->pVdbe;\n  assert( v!=0 );\n  sqlite3ExprCodeGetColumnOfTable(v, pTab, iTable, iColumn, iReg);\n  if( p5 ){\n    sqlite3VdbeChangeP5(v, p5);\n  }\n  return iReg;\n}\n\n/*\n** Generate code to move content from registers iFrom...iFrom+nReg-1\n** over to iTo..iTo+nReg-1.\n*/\nSQLITE_PRIVATE void sqlite3ExprCodeMove(Parse *pParse, int iFrom, int iTo, int nReg){\n  assert( iFrom>=iTo+nReg || iFrom+nReg<=iTo );\n  sqlite3VdbeAddOp3(pParse->pVdbe, OP_Move, iFrom, iTo, nReg);\n}\n\n/*\n** Convert a scalar expression node to a TK_REGISTER referencing\n** register iReg.  The caller must ensure that iReg already contains\n** the correct value for the expression.\n*/\nstatic void exprToRegister(Expr *p, int iReg){\n  p->op2 = p->op;\n  p->op = TK_REGISTER;\n  p->iTable = iReg;\n  ExprClearProperty(p, EP_Skip);\n}\n\n/*\n** Evaluate an expression (either a vector or a scalar expression) and store\n** the result in continguous temporary registers.  Return the index of\n** the first register used to store the result.\n**\n** If the returned result register is a temporary scalar, then also write\n** that register number into *piFreeable.  If the returned result register\n** is not a temporary or if the expression is a vector set *piFreeable\n** to 0.\n*/\nstatic int exprCodeVector(Parse *pParse, Expr *p, int *piFreeable){\n  int iResult;\n  int nResult = sqlite3ExprVectorSize(p);\n  if( nResult==1 ){\n    iResult = sqlite3ExprCodeTemp(pParse, p, piFreeable);\n  }else{\n    *piFreeable = 0;\n    if( p->op==TK_SELECT ){\n#if SQLITE_OMIT_SUBQUERY\n      iResult = 0;\n#else\n      iResult = sqlite3CodeSubselect(pParse, p);\n#endif\n    }else{\n      int i;\n      iResult = pParse->nMem+1;\n      pParse->nMem += nResult;\n      for(i=0; i<nResult; i++){\n        sqlite3ExprCodeFactorable(pParse, p->x.pList->a[i].pExpr, i+iResult);\n      }\n    }\n  }\n  return iResult;\n}\n\n\n/*\n** Generate code into the current Vdbe to evaluate the given\n** expression.  Attempt to store the results in register \"target\".\n** Return the register where results are stored.\n**\n** With this routine, there is no guarantee that results will\n** be stored in target.  The result might be stored in some other\n** register if it is convenient to do so.  The calling function\n** must check the return code and move the results to the desired\n** register.\n*/\nSQLITE_PRIVATE int sqlite3ExprCodeTarget(Parse *pParse, Expr *pExpr, int target){\n  Vdbe *v = pParse->pVdbe;  /* The VM under construction */\n  int op;                   /* The opcode being coded */\n  int inReg = target;       /* Results stored in register inReg */\n  int regFree1 = 0;         /* If non-zero free this temporary register */\n  int regFree2 = 0;         /* If non-zero free this temporary register */\n  int r1, r2;               /* Various register numbers */\n  Expr tempX;               /* Temporary expression node */\n  int p5 = 0;\n\n  assert( target>0 && target<=pParse->nMem );\n  if( v==0 ){\n    assert( pParse->db->mallocFailed );\n    return 0;\n  }\n\nexpr_code_doover:\n  if( pExpr==0 ){\n    op = TK_NULL;\n  }else{\n    op = pExpr->op;\n  }\n  switch( op ){\n    case TK_AGG_COLUMN: {\n      AggInfo *pAggInfo = pExpr->pAggInfo;\n      struct AggInfo_col *pCol = &pAggInfo->aCol[pExpr->iAgg];\n      if( !pAggInfo->directMode ){\n        assert( pCol->iMem>0 );\n        return pCol->iMem;\n      }else if( pAggInfo->useSortingIdx ){\n        sqlite3VdbeAddOp3(v, OP_Column, pAggInfo->sortingIdxPTab,\n                              pCol->iSorterColumn, target);\n        return target;\n      }\n      /* Otherwise, fall thru into the TK_COLUMN case */\n    }\n    case TK_COLUMN: {\n      int iTab = pExpr->iTable;\n      if( ExprHasProperty(pExpr, EP_FixedCol) ){\n        /* This COLUMN expression is really a constant due to WHERE clause\n        ** constraints, and that constant is coded by the pExpr->pLeft\n        ** expresssion.  However, make sure the constant has the correct\n        ** datatype by applying the Affinity of the table column to the\n        ** constant.\n        */\n        int iReg = sqlite3ExprCodeTarget(pParse, pExpr->pLeft,target);\n        int aff = sqlite3TableColumnAffinity(pExpr->y.pTab, pExpr->iColumn);\n        if( aff!=SQLITE_AFF_BLOB ){\n          static const char zAff[] = \"B\\000C\\000D\\000E\";\n          assert( SQLITE_AFF_BLOB=='A' );\n          assert( SQLITE_AFF_TEXT=='B' );\n          if( iReg!=target ){\n            sqlite3VdbeAddOp2(v, OP_SCopy, iReg, target);\n            iReg = target;\n          }\n          sqlite3VdbeAddOp4(v, OP_Affinity, iReg, 1, 0,\n                            &zAff[(aff-'B')*2], P4_STATIC);\n        }\n        return iReg;\n      }\n      if( iTab<0 ){\n        if( pParse->iSelfTab<0 ){\n          /* Generating CHECK constraints or inserting into partial index */\n          return pExpr->iColumn - pParse->iSelfTab;\n        }else{\n          /* Coding an expression that is part of an index where column names\n          ** in the index refer to the table to which the index belongs */\n          iTab = pParse->iSelfTab - 1;\n        }\n      }\n      return sqlite3ExprCodeGetColumn(pParse, pExpr->y.pTab,\n                               pExpr->iColumn, iTab, target,\n                               pExpr->op2);\n    }\n    case TK_INTEGER: {\n      codeInteger(pParse, pExpr, 0, target);\n      return target;\n    }\n    case TK_TRUEFALSE: {\n      sqlite3VdbeAddOp2(v, OP_Integer, sqlite3ExprTruthValue(pExpr), target);\n      return target;\n    }\n#ifndef SQLITE_OMIT_FLOATING_POINT\n    case TK_FLOAT: {\n      assert( !ExprHasProperty(pExpr, EP_IntValue) );\n      codeReal(v, pExpr->u.zToken, 0, target);\n      return target;\n    }\n#endif\n    case TK_STRING: {\n      assert( !ExprHasProperty(pExpr, EP_IntValue) );\n      sqlite3VdbeLoadString(v, target, pExpr->u.zToken);\n      return target;\n    }\n    case TK_NULL: {\n      sqlite3VdbeAddOp2(v, OP_Null, 0, target);\n      return target;\n    }\n#ifndef SQLITE_OMIT_BLOB_LITERAL\n    case TK_BLOB: {\n      int n;\n      const char *z;\n      char *zBlob;\n      assert( !ExprHasProperty(pExpr, EP_IntValue) );\n      assert( pExpr->u.zToken[0]=='x' || pExpr->u.zToken[0]=='X' );\n      assert( pExpr->u.zToken[1]=='\\'' );\n      z = &pExpr->u.zToken[2];\n      n = sqlite3Strlen30(z) - 1;\n      assert( z[n]=='\\'' );\n      zBlob = sqlite3HexToBlob(sqlite3VdbeDb(v), z, n);\n      sqlite3VdbeAddOp4(v, OP_Blob, n/2, target, 0, zBlob, P4_DYNAMIC);\n      return target;\n    }\n#endif\n    case TK_VARIABLE: {\n      assert( !ExprHasProperty(pExpr, EP_IntValue) );\n      assert( pExpr->u.zToken!=0 );\n      assert( pExpr->u.zToken[0]!=0 );\n      sqlite3VdbeAddOp2(v, OP_Variable, pExpr->iColumn, target);\n      if( pExpr->u.zToken[1]!=0 ){\n        const char *z = sqlite3VListNumToName(pParse->pVList, pExpr->iColumn);\n        assert( pExpr->u.zToken[0]=='?' || strcmp(pExpr->u.zToken, z)==0 );\n        pParse->pVList[0] = 0; /* Indicate VList may no longer be enlarged */\n        sqlite3VdbeAppendP4(v, (char*)z, P4_STATIC);\n      }\n      return target;\n    }\n    case TK_REGISTER: {\n      return pExpr->iTable;\n    }\n#ifndef SQLITE_OMIT_CAST\n    case TK_CAST: {\n      /* Expressions of the form:   CAST(pLeft AS token) */\n      inReg = sqlite3ExprCodeTarget(pParse, pExpr->pLeft, target);\n      if( inReg!=target ){\n        sqlite3VdbeAddOp2(v, OP_SCopy, inReg, target);\n        inReg = target;\n      }\n      sqlite3VdbeAddOp2(v, OP_Cast, target,\n                        sqlite3AffinityType(pExpr->u.zToken, 0));\n      return inReg;\n    }\n#endif /* SQLITE_OMIT_CAST */\n    case TK_IS:\n    case TK_ISNOT:\n      op = (op==TK_IS) ? TK_EQ : TK_NE;\n      p5 = SQLITE_NULLEQ;\n      /* fall-through */\n    case TK_LT:\n    case TK_LE:\n    case TK_GT:\n    case TK_GE:\n    case TK_NE:\n    case TK_EQ: {\n      Expr *pLeft = pExpr->pLeft;\n      if( sqlite3ExprIsVector(pLeft) ){\n        codeVectorCompare(pParse, pExpr, target, op, p5);\n      }else{\n        r1 = sqlite3ExprCodeTemp(pParse, pLeft, &regFree1);\n        r2 = sqlite3ExprCodeTemp(pParse, pExpr->pRight, &regFree2);\n        codeCompare(pParse, pLeft, pExpr->pRight, op,\n            r1, r2, inReg, SQLITE_STOREP2 | p5);\n        assert(TK_LT==OP_Lt); testcase(op==OP_Lt); VdbeCoverageIf(v,op==OP_Lt);\n        assert(TK_LE==OP_Le); testcase(op==OP_Le); VdbeCoverageIf(v,op==OP_Le);\n        assert(TK_GT==OP_Gt); testcase(op==OP_Gt); VdbeCoverageIf(v,op==OP_Gt);\n        assert(TK_GE==OP_Ge); testcase(op==OP_Ge); VdbeCoverageIf(v,op==OP_Ge);\n        assert(TK_EQ==OP_Eq); testcase(op==OP_Eq); VdbeCoverageIf(v,op==OP_Eq);\n        assert(TK_NE==OP_Ne); testcase(op==OP_Ne); VdbeCoverageIf(v,op==OP_Ne);\n        testcase( regFree1==0 );\n        testcase( regFree2==0 );\n      }\n      break;\n    }\n    case TK_AND:\n    case TK_OR:\n    case TK_PLUS:\n    case TK_STAR:\n    case TK_MINUS:\n    case TK_REM:\n    case TK_BITAND:\n    case TK_BITOR:\n    case TK_SLASH:\n    case TK_LSHIFT:\n    case TK_RSHIFT: \n    case TK_CONCAT: {\n      assert( TK_AND==OP_And );            testcase( op==TK_AND );\n      assert( TK_OR==OP_Or );              testcase( op==TK_OR );\n      assert( TK_PLUS==OP_Add );           testcase( op==TK_PLUS );\n      assert( TK_MINUS==OP_Subtract );     testcase( op==TK_MINUS );\n      assert( TK_REM==OP_Remainder );      testcase( op==TK_REM );\n      assert( TK_BITAND==OP_BitAnd );      testcase( op==TK_BITAND );\n      assert( TK_BITOR==OP_BitOr );        testcase( op==TK_BITOR );\n      assert( TK_SLASH==OP_Divide );       testcase( op==TK_SLASH );\n      assert( TK_LSHIFT==OP_ShiftLeft );   testcase( op==TK_LSHIFT );\n      assert( TK_RSHIFT==OP_ShiftRight );  testcase( op==TK_RSHIFT );\n      assert( TK_CONCAT==OP_Concat );      testcase( op==TK_CONCAT );\n      r1 = sqlite3ExprCodeTemp(pParse, pExpr->pLeft, &regFree1);\n      r2 = sqlite3ExprCodeTemp(pParse, pExpr->pRight, &regFree2);\n      sqlite3VdbeAddOp3(v, op, r2, r1, target);\n      testcase( regFree1==0 );\n      testcase( regFree2==0 );\n      break;\n    }\n    case TK_UMINUS: {\n      Expr *pLeft = pExpr->pLeft;\n      assert( pLeft );\n      if( pLeft->op==TK_INTEGER ){\n        codeInteger(pParse, pLeft, 1, target);\n        return target;\n#ifndef SQLITE_OMIT_FLOATING_POINT\n      }else if( pLeft->op==TK_FLOAT ){\n        assert( !ExprHasProperty(pExpr, EP_IntValue) );\n        codeReal(v, pLeft->u.zToken, 1, target);\n        return target;\n#endif\n      }else{\n        tempX.op = TK_INTEGER;\n        tempX.flags = EP_IntValue|EP_TokenOnly;\n        tempX.u.iValue = 0;\n        r1 = sqlite3ExprCodeTemp(pParse, &tempX, &regFree1);\n        r2 = sqlite3ExprCodeTemp(pParse, pExpr->pLeft, &regFree2);\n        sqlite3VdbeAddOp3(v, OP_Subtract, r2, r1, target);\n        testcase( regFree2==0 );\n      }\n      break;\n    }\n    case TK_BITNOT:\n    case TK_NOT: {\n      assert( TK_BITNOT==OP_BitNot );   testcase( op==TK_BITNOT );\n      assert( TK_NOT==OP_Not );         testcase( op==TK_NOT );\n      r1 = sqlite3ExprCodeTemp(pParse, pExpr->pLeft, &regFree1);\n      testcase( regFree1==0 );\n      sqlite3VdbeAddOp2(v, op, r1, inReg);\n      break;\n    }\n    case TK_TRUTH: {\n      int isTrue;    /* IS TRUE or IS NOT TRUE */\n      int bNormal;   /* IS TRUE or IS FALSE */\n      r1 = sqlite3ExprCodeTemp(pParse, pExpr->pLeft, &regFree1);\n      testcase( regFree1==0 );\n      isTrue = sqlite3ExprTruthValue(pExpr->pRight);\n      bNormal = pExpr->op2==TK_IS;\n      testcase( isTrue && bNormal);\n      testcase( !isTrue && bNormal);\n      sqlite3VdbeAddOp4Int(v, OP_IsTrue, r1, inReg, !isTrue, isTrue ^ bNormal);\n      break;\n    }\n    case TK_ISNULL:\n    case TK_NOTNULL: {\n      int addr;\n      assert( TK_ISNULL==OP_IsNull );   testcase( op==TK_ISNULL );\n      assert( TK_NOTNULL==OP_NotNull ); testcase( op==TK_NOTNULL );\n      sqlite3VdbeAddOp2(v, OP_Integer, 1, target);\n      r1 = sqlite3ExprCodeTemp(pParse, pExpr->pLeft, &regFree1);\n      testcase( regFree1==0 );\n      addr = sqlite3VdbeAddOp1(v, op, r1);\n      VdbeCoverageIf(v, op==TK_ISNULL);\n      VdbeCoverageIf(v, op==TK_NOTNULL);\n      sqlite3VdbeAddOp2(v, OP_Integer, 0, target);\n      sqlite3VdbeJumpHere(v, addr);\n      break;\n    }\n    case TK_AGG_FUNCTION: {\n      AggInfo *pInfo = pExpr->pAggInfo;\n      if( pInfo==0 ){\n        assert( !ExprHasProperty(pExpr, EP_IntValue) );\n        sqlite3ErrorMsg(pParse, \"misuse of aggregate: %s()\", pExpr->u.zToken);\n      }else{\n        return pInfo->aFunc[pExpr->iAgg].iMem;\n      }\n      break;\n    }\n    case TK_FUNCTION: {\n      ExprList *pFarg;       /* List of function arguments */\n      int nFarg;             /* Number of function arguments */\n      FuncDef *pDef;         /* The function definition object */\n      const char *zId;       /* The function name */\n      u32 constMask = 0;     /* Mask of function arguments that are constant */\n      int i;                 /* Loop counter */\n      sqlite3 *db = pParse->db;  /* The database connection */\n      u8 enc = ENC(db);      /* The text encoding used by this database */\n      CollSeq *pColl = 0;    /* A collating sequence */\n\n#ifndef SQLITE_OMIT_WINDOWFUNC\n      if( ExprHasProperty(pExpr, EP_WinFunc) ){\n        return pExpr->y.pWin->regResult;\n      }\n#endif\n\n      if( ConstFactorOk(pParse) && sqlite3ExprIsConstantNotJoin(pExpr) ){\n        /* SQL functions can be expensive. So try to move constant functions\n        ** out of the inner loop, even if that means an extra OP_Copy. */\n        return sqlite3ExprCodeAtInit(pParse, pExpr, -1);\n      }\n      assert( !ExprHasProperty(pExpr, EP_xIsSelect) );\n      if( ExprHasProperty(pExpr, EP_TokenOnly) ){\n        pFarg = 0;\n      }else{\n        pFarg = pExpr->x.pList;\n      }\n      nFarg = pFarg ? pFarg->nExpr : 0;\n      assert( !ExprHasProperty(pExpr, EP_IntValue) );\n      zId = pExpr->u.zToken;\n      pDef = sqlite3FindFunction(db, zId, nFarg, enc, 0);\n#ifdef SQLITE_ENABLE_UNKNOWN_SQL_FUNCTION\n      if( pDef==0 && pParse->explain ){\n        pDef = sqlite3FindFunction(db, \"unknown\", nFarg, enc, 0);\n      }\n#endif\n      if( pDef==0 || pDef->xFinalize!=0 ){\n        sqlite3ErrorMsg(pParse, \"unknown function: %s()\", zId);\n        break;\n      }\n\n      /* Attempt a direct implementation of the built-in COALESCE() and\n      ** IFNULL() functions.  This avoids unnecessary evaluation of\n      ** arguments past the first non-NULL argument.\n      */\n      if( pDef->funcFlags & SQLITE_FUNC_COALESCE ){\n        int endCoalesce = sqlite3VdbeMakeLabel(pParse);\n        assert( nFarg>=2 );\n        sqlite3ExprCode(pParse, pFarg->a[0].pExpr, target);\n        for(i=1; i<nFarg; i++){\n          sqlite3VdbeAddOp2(v, OP_NotNull, target, endCoalesce);\n          VdbeCoverage(v);\n          sqlite3ExprCode(pParse, pFarg->a[i].pExpr, target);\n        }\n        sqlite3VdbeResolveLabel(v, endCoalesce);\n        break;\n      }\n\n      /* The UNLIKELY() function is a no-op.  The result is the value\n      ** of the first argument.\n      */\n      if( pDef->funcFlags & SQLITE_FUNC_UNLIKELY ){\n        assert( nFarg>=1 );\n        return sqlite3ExprCodeTarget(pParse, pFarg->a[0].pExpr, target);\n      }\n\n#ifdef SQLITE_DEBUG\n      /* The AFFINITY() function evaluates to a string that describes\n      ** the type affinity of the argument.  This is used for testing of\n      ** the SQLite type logic.\n      */\n      if( pDef->funcFlags & SQLITE_FUNC_AFFINITY ){\n        const char *azAff[] = { \"blob\", \"text\", \"numeric\", \"integer\", \"real\" };\n        char aff;\n        assert( nFarg==1 );\n        aff = sqlite3ExprAffinity(pFarg->a[0].pExpr);\n        sqlite3VdbeLoadString(v, target, \n                              aff ? azAff[aff-SQLITE_AFF_BLOB] : \"none\");\n        return target;\n      }\n#endif\n\n      for(i=0; i<nFarg; i++){\n        if( i<32 && sqlite3ExprIsConstant(pFarg->a[i].pExpr) ){\n          testcase( i==31 );\n          constMask |= MASKBIT32(i);\n        }\n        if( (pDef->funcFlags & SQLITE_FUNC_NEEDCOLL)!=0 && !pColl ){\n          pColl = sqlite3ExprCollSeq(pParse, pFarg->a[i].pExpr);\n        }\n      }\n      if( pFarg ){\n        if( constMask ){\n          r1 = pParse->nMem+1;\n          pParse->nMem += nFarg;\n        }else{\n          r1 = sqlite3GetTempRange(pParse, nFarg);\n        }\n\n        /* For length() and typeof() functions with a column argument,\n        ** set the P5 parameter to the OP_Column opcode to OPFLAG_LENGTHARG\n        ** or OPFLAG_TYPEOFARG respectively, to avoid unnecessary data\n        ** loading.\n        */\n        if( (pDef->funcFlags & (SQLITE_FUNC_LENGTH|SQLITE_FUNC_TYPEOF))!=0 ){\n          u8 exprOp;\n          assert( nFarg==1 );\n          assert( pFarg->a[0].pExpr!=0 );\n          exprOp = pFarg->a[0].pExpr->op;\n          if( exprOp==TK_COLUMN || exprOp==TK_AGG_COLUMN ){\n            assert( SQLITE_FUNC_LENGTH==OPFLAG_LENGTHARG );\n            assert( SQLITE_FUNC_TYPEOF==OPFLAG_TYPEOFARG );\n            testcase( pDef->funcFlags & OPFLAG_LENGTHARG );\n            pFarg->a[0].pExpr->op2 = \n                  pDef->funcFlags & (OPFLAG_LENGTHARG|OPFLAG_TYPEOFARG);\n          }\n        }\n\n        sqlite3ExprCodeExprList(pParse, pFarg, r1, 0,\n                                SQLITE_ECEL_DUP|SQLITE_ECEL_FACTOR);\n      }else{\n        r1 = 0;\n      }\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n      /* Possibly overload the function if the first argument is\n      ** a virtual table column.\n      **\n      ** For infix functions (LIKE, GLOB, REGEXP, and MATCH) use the\n      ** second argument, not the first, as the argument to test to\n      ** see if it is a column in a virtual table.  This is done because\n      ** the left operand of infix functions (the operand we want to\n      ** control overloading) ends up as the second argument to the\n      ** function.  The expression \"A glob B\" is equivalent to \n      ** \"glob(B,A).  We want to use the A in \"A glob B\" to test\n      ** for function overloading.  But we use the B term in \"glob(B,A)\".\n      */\n      if( nFarg>=2 && ExprHasProperty(pExpr, EP_InfixFunc) ){\n        pDef = sqlite3VtabOverloadFunction(db, pDef, nFarg, pFarg->a[1].pExpr);\n      }else if( nFarg>0 ){\n        pDef = sqlite3VtabOverloadFunction(db, pDef, nFarg, pFarg->a[0].pExpr);\n      }\n#endif\n      if( pDef->funcFlags & SQLITE_FUNC_NEEDCOLL ){\n        if( !pColl ) pColl = db->pDfltColl; \n        sqlite3VdbeAddOp4(v, OP_CollSeq, 0, 0, 0, (char *)pColl, P4_COLLSEQ);\n      }\n#ifdef SQLITE_ENABLE_OFFSET_SQL_FUNC\n      if( pDef->funcFlags & SQLITE_FUNC_OFFSET ){\n        Expr *pArg = pFarg->a[0].pExpr;\n        if( pArg->op==TK_COLUMN ){\n          sqlite3VdbeAddOp3(v, OP_Offset, pArg->iTable, pArg->iColumn, target);\n        }else{\n          sqlite3VdbeAddOp2(v, OP_Null, 0, target);\n        }\n      }else\n#endif\n      {\n        sqlite3VdbeAddOp4(v, pParse->iSelfTab ? OP_PureFunc0 : OP_Function0,\n                          constMask, r1, target, (char*)pDef, P4_FUNCDEF);\n        sqlite3VdbeChangeP5(v, (u8)nFarg);\n      }\n      if( nFarg && constMask==0 ){\n        sqlite3ReleaseTempRange(pParse, r1, nFarg);\n      }\n      return target;\n    }\n#ifndef SQLITE_OMIT_SUBQUERY\n    case TK_EXISTS:\n    case TK_SELECT: {\n      int nCol;\n      testcase( op==TK_EXISTS );\n      testcase( op==TK_SELECT );\n      if( op==TK_SELECT && (nCol = pExpr->x.pSelect->pEList->nExpr)!=1 ){\n        sqlite3SubselectError(pParse, nCol, 1);\n      }else{\n        return sqlite3CodeSubselect(pParse, pExpr);\n      }\n      break;\n    }\n    case TK_SELECT_COLUMN: {\n      int n;\n      if( pExpr->pLeft->iTable==0 ){\n        pExpr->pLeft->iTable = sqlite3CodeSubselect(pParse, pExpr->pLeft);\n      }\n      assert( pExpr->iTable==0 || pExpr->pLeft->op==TK_SELECT );\n      if( pExpr->iTable\n       && pExpr->iTable!=(n = sqlite3ExprVectorSize(pExpr->pLeft)) \n      ){\n        sqlite3ErrorMsg(pParse, \"%d columns assigned %d values\",\n                                pExpr->iTable, n);\n      }\n      return pExpr->pLeft->iTable + pExpr->iColumn;\n    }\n    case TK_IN: {\n      int destIfFalse = sqlite3VdbeMakeLabel(pParse);\n      int destIfNull = sqlite3VdbeMakeLabel(pParse);\n      sqlite3VdbeAddOp2(v, OP_Null, 0, target);\n      sqlite3ExprCodeIN(pParse, pExpr, destIfFalse, destIfNull);\n      sqlite3VdbeAddOp2(v, OP_Integer, 1, target);\n      sqlite3VdbeResolveLabel(v, destIfFalse);\n      sqlite3VdbeAddOp2(v, OP_AddImm, target, 0);\n      sqlite3VdbeResolveLabel(v, destIfNull);\n      return target;\n    }\n#endif /* SQLITE_OMIT_SUBQUERY */\n\n\n    /*\n    **    x BETWEEN y AND z\n    **\n    ** This is equivalent to\n    **\n    **    x>=y AND x<=z\n    **\n    ** X is stored in pExpr->pLeft.\n    ** Y is stored in pExpr->pList->a[0].pExpr.\n    ** Z is stored in pExpr->pList->a[1].pExpr.\n    */\n    case TK_BETWEEN: {\n      exprCodeBetween(pParse, pExpr, target, 0, 0);\n      return target;\n    }\n    case TK_SPAN:\n    case TK_COLLATE: \n    case TK_UPLUS: {\n      pExpr = pExpr->pLeft;\n      goto expr_code_doover; /* 2018-04-28: Prevent deep recursion. OSSFuzz. */\n    }\n\n    case TK_TRIGGER: {\n      /* If the opcode is TK_TRIGGER, then the expression is a reference\n      ** to a column in the new.* or old.* pseudo-tables available to\n      ** trigger programs. In this case Expr.iTable is set to 1 for the\n      ** new.* pseudo-table, or 0 for the old.* pseudo-table. Expr.iColumn\n      ** is set to the column of the pseudo-table to read, or to -1 to\n      ** read the rowid field.\n      **\n      ** The expression is implemented using an OP_Param opcode. The p1\n      ** parameter is set to 0 for an old.rowid reference, or to (i+1)\n      ** to reference another column of the old.* pseudo-table, where \n      ** i is the index of the column. For a new.rowid reference, p1 is\n      ** set to (n+1), where n is the number of columns in each pseudo-table.\n      ** For a reference to any other column in the new.* pseudo-table, p1\n      ** is set to (n+2+i), where n and i are as defined previously. For\n      ** example, if the table on which triggers are being fired is\n      ** declared as:\n      **\n      **   CREATE TABLE t1(a, b);\n      **\n      ** Then p1 is interpreted as follows:\n      **\n      **   p1==0   ->    old.rowid     p1==3   ->    new.rowid\n      **   p1==1   ->    old.a         p1==4   ->    new.a\n      **   p1==2   ->    old.b         p1==5   ->    new.b       \n      */\n      Table *pTab = pExpr->y.pTab;\n      int p1 = pExpr->iTable * (pTab->nCol+1) + 1 + pExpr->iColumn;\n\n      assert( pExpr->iTable==0 || pExpr->iTable==1 );\n      assert( pExpr->iColumn>=-1 && pExpr->iColumn<pTab->nCol );\n      assert( pTab->iPKey<0 || pExpr->iColumn!=pTab->iPKey );\n      assert( p1>=0 && p1<(pTab->nCol*2+2) );\n\n      sqlite3VdbeAddOp2(v, OP_Param, p1, target);\n      VdbeComment((v, \"r[%d]=%s.%s\", target,\n        (pExpr->iTable ? \"new\" : \"old\"),\n        (pExpr->iColumn<0 ? \"rowid\" : pExpr->y.pTab->aCol[pExpr->iColumn].zName)\n      ));\n\n#ifndef SQLITE_OMIT_FLOATING_POINT\n      /* If the column has REAL affinity, it may currently be stored as an\n      ** integer. Use OP_RealAffinity to make sure it is really real.\n      **\n      ** EVIDENCE-OF: R-60985-57662 SQLite will convert the value back to\n      ** floating point when extracting it from the record.  */\n      if( pExpr->iColumn>=0 \n       && pTab->aCol[pExpr->iColumn].affinity==SQLITE_AFF_REAL\n      ){\n        sqlite3VdbeAddOp1(v, OP_RealAffinity, target);\n      }\n#endif\n      break;\n    }\n\n    case TK_VECTOR: {\n      sqlite3ErrorMsg(pParse, \"row value misused\");\n      break;\n    }\n\n    case TK_IF_NULL_ROW: {\n      int addrINR;\n      addrINR = sqlite3VdbeAddOp1(v, OP_IfNullRow, pExpr->iTable);\n      inReg = sqlite3ExprCodeTarget(pParse, pExpr->pLeft, target);\n      sqlite3VdbeJumpHere(v, addrINR);\n      sqlite3VdbeChangeP3(v, addrINR, inReg);\n      break;\n    }\n\n    /*\n    ** Form A:\n    **   CASE x WHEN e1 THEN r1 WHEN e2 THEN r2 ... WHEN eN THEN rN ELSE y END\n    **\n    ** Form B:\n    **   CASE WHEN e1 THEN r1 WHEN e2 THEN r2 ... WHEN eN THEN rN ELSE y END\n    **\n    ** Form A is can be transformed into the equivalent form B as follows:\n    **   CASE WHEN x=e1 THEN r1 WHEN x=e2 THEN r2 ...\n    **        WHEN x=eN THEN rN ELSE y END\n    **\n    ** X (if it exists) is in pExpr->pLeft.\n    ** Y is in the last element of pExpr->x.pList if pExpr->x.pList->nExpr is\n    ** odd.  The Y is also optional.  If the number of elements in x.pList\n    ** is even, then Y is omitted and the \"otherwise\" result is NULL.\n    ** Ei is in pExpr->pList->a[i*2] and Ri is pExpr->pList->a[i*2+1].\n    **\n    ** The result of the expression is the Ri for the first matching Ei,\n    ** or if there is no matching Ei, the ELSE term Y, or if there is\n    ** no ELSE term, NULL.\n    */\n    default: assert( op==TK_CASE ); {\n      int endLabel;                     /* GOTO label for end of CASE stmt */\n      int nextCase;                     /* GOTO label for next WHEN clause */\n      int nExpr;                        /* 2x number of WHEN terms */\n      int i;                            /* Loop counter */\n      ExprList *pEList;                 /* List of WHEN terms */\n      struct ExprList_item *aListelem;  /* Array of WHEN terms */\n      Expr opCompare;                   /* The X==Ei expression */\n      Expr *pX;                         /* The X expression */\n      Expr *pTest = 0;                  /* X==Ei (form A) or just Ei (form B) */\n\n      assert( !ExprHasProperty(pExpr, EP_xIsSelect) && pExpr->x.pList );\n      assert(pExpr->x.pList->nExpr > 0);\n      pEList = pExpr->x.pList;\n      aListelem = pEList->a;\n      nExpr = pEList->nExpr;\n      endLabel = sqlite3VdbeMakeLabel(pParse);\n      if( (pX = pExpr->pLeft)!=0 ){\n        exprNodeCopy(&tempX, pX);\n        testcase( pX->op==TK_COLUMN );\n        exprToRegister(&tempX, exprCodeVector(pParse, &tempX, &regFree1));\n        testcase( regFree1==0 );\n        memset(&opCompare, 0, sizeof(opCompare));\n        opCompare.op = TK_EQ;\n        opCompare.pLeft = &tempX;\n        pTest = &opCompare;\n        /* Ticket b351d95f9cd5ef17e9d9dbae18f5ca8611190001:\n        ** The value in regFree1 might get SCopy-ed into the file result.\n        ** So make sure that the regFree1 register is not reused for other\n        ** purposes and possibly overwritten.  */\n        regFree1 = 0;\n      }\n      for(i=0; i<nExpr-1; i=i+2){\n        if( pX ){\n          assert( pTest!=0 );\n          opCompare.pRight = aListelem[i].pExpr;\n        }else{\n          pTest = aListelem[i].pExpr;\n        }\n        nextCase = sqlite3VdbeMakeLabel(pParse);\n        testcase( pTest->op==TK_COLUMN );\n        sqlite3ExprIfFalse(pParse, pTest, nextCase, SQLITE_JUMPIFNULL);\n        testcase( aListelem[i+1].pExpr->op==TK_COLUMN );\n        sqlite3ExprCode(pParse, aListelem[i+1].pExpr, target);\n        sqlite3VdbeGoto(v, endLabel);\n        sqlite3VdbeResolveLabel(v, nextCase);\n      }\n      if( (nExpr&1)!=0 ){\n        sqlite3ExprCode(pParse, pEList->a[nExpr-1].pExpr, target);\n      }else{\n        sqlite3VdbeAddOp2(v, OP_Null, 0, target);\n      }\n      sqlite3VdbeResolveLabel(v, endLabel);\n      break;\n    }\n#ifndef SQLITE_OMIT_TRIGGER\n    case TK_RAISE: {\n      assert( pExpr->affinity==OE_Rollback \n           || pExpr->affinity==OE_Abort\n           || pExpr->affinity==OE_Fail\n           || pExpr->affinity==OE_Ignore\n      );\n      if( !pParse->pTriggerTab ){\n        sqlite3ErrorMsg(pParse,\n                       \"RAISE() may only be used within a trigger-program\");\n        return 0;\n      }\n      if( pExpr->affinity==OE_Abort ){\n        sqlite3MayAbort(pParse);\n      }\n      assert( !ExprHasProperty(pExpr, EP_IntValue) );\n      if( pExpr->affinity==OE_Ignore ){\n        sqlite3VdbeAddOp4(\n            v, OP_Halt, SQLITE_OK, OE_Ignore, 0, pExpr->u.zToken,0);\n        VdbeCoverage(v);\n      }else{\n        sqlite3HaltConstraint(pParse, SQLITE_CONSTRAINT_TRIGGER,\n                              pExpr->affinity, pExpr->u.zToken, 0, 0);\n      }\n\n      break;\n    }\n#endif\n  }\n  sqlite3ReleaseTempReg(pParse, regFree1);\n  sqlite3ReleaseTempReg(pParse, regFree2);\n  return inReg;\n}\n\n/*\n** Factor out the code of the given expression to initialization time.\n**\n** If regDest>=0 then the result is always stored in that register and the\n** result is not reusable.  If regDest<0 then this routine is free to \n** store the value whereever it wants.  The register where the expression \n** is stored is returned.  When regDest<0, two identical expressions will\n** code to the same register.\n*/\nSQLITE_PRIVATE int sqlite3ExprCodeAtInit(\n  Parse *pParse,    /* Parsing context */\n  Expr *pExpr,      /* The expression to code when the VDBE initializes */\n  int regDest       /* Store the value in this register */\n){\n  ExprList *p;\n  assert( ConstFactorOk(pParse) );\n  p = pParse->pConstExpr;\n  if( regDest<0 && p ){\n    struct ExprList_item *pItem;\n    int i;\n    for(pItem=p->a, i=p->nExpr; i>0; pItem++, i--){\n      if( pItem->reusable && sqlite3ExprCompare(0,pItem->pExpr,pExpr,-1)==0 ){\n        return pItem->u.iConstExprReg;\n      }\n    }\n  }\n  pExpr = sqlite3ExprDup(pParse->db, pExpr, 0);\n  p = sqlite3ExprListAppend(pParse, p, pExpr);\n  if( p ){\n     struct ExprList_item *pItem = &p->a[p->nExpr-1];\n     pItem->reusable = regDest<0;\n     if( regDest<0 ) regDest = ++pParse->nMem;\n     pItem->u.iConstExprReg = regDest;\n  }\n  pParse->pConstExpr = p;\n  return regDest;\n}\n\n/*\n** Generate code to evaluate an expression and store the results\n** into a register.  Return the register number where the results\n** are stored.\n**\n** If the register is a temporary register that can be deallocated,\n** then write its number into *pReg.  If the result register is not\n** a temporary, then set *pReg to zero.\n**\n** If pExpr is a constant, then this routine might generate this\n** code to fill the register in the initialization section of the\n** VDBE program, in order to factor it out of the evaluation loop.\n*/\nSQLITE_PRIVATE int sqlite3ExprCodeTemp(Parse *pParse, Expr *pExpr, int *pReg){\n  int r2;\n  pExpr = sqlite3ExprSkipCollate(pExpr);\n  if( ConstFactorOk(pParse)\n   && pExpr->op!=TK_REGISTER\n   && sqlite3ExprIsConstantNotJoin(pExpr)\n  ){\n    *pReg  = 0;\n    r2 = sqlite3ExprCodeAtInit(pParse, pExpr, -1);\n  }else{\n    int r1 = sqlite3GetTempReg(pParse);\n    r2 = sqlite3ExprCodeTarget(pParse, pExpr, r1);\n    if( r2==r1 ){\n      *pReg = r1;\n    }else{\n      sqlite3ReleaseTempReg(pParse, r1);\n      *pReg = 0;\n    }\n  }\n  return r2;\n}\n\n/*\n** Generate code that will evaluate expression pExpr and store the\n** results in register target.  The results are guaranteed to appear\n** in register target.\n*/\nSQLITE_PRIVATE void sqlite3ExprCode(Parse *pParse, Expr *pExpr, int target){\n  int inReg;\n\n  assert( target>0 && target<=pParse->nMem );\n  if( pExpr && pExpr->op==TK_REGISTER ){\n    sqlite3VdbeAddOp2(pParse->pVdbe, OP_Copy, pExpr->iTable, target);\n  }else{\n    inReg = sqlite3ExprCodeTarget(pParse, pExpr, target);\n    assert( pParse->pVdbe!=0 || pParse->db->mallocFailed );\n    if( inReg!=target && pParse->pVdbe ){\n      sqlite3VdbeAddOp2(pParse->pVdbe, OP_SCopy, inReg, target);\n    }\n  }\n}\n\n/*\n** Make a transient copy of expression pExpr and then code it using\n** sqlite3ExprCode().  This routine works just like sqlite3ExprCode()\n** except that the input expression is guaranteed to be unchanged.\n*/\nSQLITE_PRIVATE void sqlite3ExprCodeCopy(Parse *pParse, Expr *pExpr, int target){\n  sqlite3 *db = pParse->db;\n  pExpr = sqlite3ExprDup(db, pExpr, 0);\n  if( !db->mallocFailed ) sqlite3ExprCode(pParse, pExpr, target);\n  sqlite3ExprDelete(db, pExpr);\n}\n\n/*\n** Generate code that will evaluate expression pExpr and store the\n** results in register target.  The results are guaranteed to appear\n** in register target.  If the expression is constant, then this routine\n** might choose to code the expression at initialization time.\n*/\nSQLITE_PRIVATE void sqlite3ExprCodeFactorable(Parse *pParse, Expr *pExpr, int target){\n  if( pParse->okConstFactor && sqlite3ExprIsConstantNotJoin(pExpr) ){\n    sqlite3ExprCodeAtInit(pParse, pExpr, target);\n  }else{\n    sqlite3ExprCode(pParse, pExpr, target);\n  }\n}\n\n/*\n** Generate code that evaluates the given expression and puts the result\n** in register target.\n**\n** Also make a copy of the expression results into another \"cache\" register\n** and modify the expression so that the next time it is evaluated,\n** the result is a copy of the cache register.\n**\n** This routine is used for expressions that are used multiple \n** times.  They are evaluated once and the results of the expression\n** are reused.\n*/\nSQLITE_PRIVATE void sqlite3ExprCodeAndCache(Parse *pParse, Expr *pExpr, int target){\n  Vdbe *v = pParse->pVdbe;\n  int iMem;\n\n  assert( target>0 );\n  assert( pExpr->op!=TK_REGISTER );\n  sqlite3ExprCode(pParse, pExpr, target);\n  iMem = ++pParse->nMem;\n  sqlite3VdbeAddOp2(v, OP_Copy, target, iMem);\n  exprToRegister(pExpr, iMem);\n}\n\n/*\n** Generate code that pushes the value of every element of the given\n** expression list into a sequence of registers beginning at target.\n**\n** Return the number of elements evaluated.  The number returned will\n** usually be pList->nExpr but might be reduced if SQLITE_ECEL_OMITREF\n** is defined.\n**\n** The SQLITE_ECEL_DUP flag prevents the arguments from being\n** filled using OP_SCopy.  OP_Copy must be used instead.\n**\n** The SQLITE_ECEL_FACTOR argument allows constant arguments to be\n** factored out into initialization code.\n**\n** The SQLITE_ECEL_REF flag means that expressions in the list with\n** ExprList.a[].u.x.iOrderByCol>0 have already been evaluated and stored\n** in registers at srcReg, and so the value can be copied from there.\n** If SQLITE_ECEL_OMITREF is also set, then the values with u.x.iOrderByCol>0\n** are simply omitted rather than being copied from srcReg.\n*/\nSQLITE_PRIVATE int sqlite3ExprCodeExprList(\n  Parse *pParse,     /* Parsing context */\n  ExprList *pList,   /* The expression list to be coded */\n  int target,        /* Where to write results */\n  int srcReg,        /* Source registers if SQLITE_ECEL_REF */\n  u8 flags           /* SQLITE_ECEL_* flags */\n){\n  struct ExprList_item *pItem;\n  int i, j, n;\n  u8 copyOp = (flags & SQLITE_ECEL_DUP) ? OP_Copy : OP_SCopy;\n  Vdbe *v = pParse->pVdbe;\n  assert( pList!=0 );\n  assert( target>0 );\n  assert( pParse->pVdbe!=0 );  /* Never gets this far otherwise */\n  n = pList->nExpr;\n  if( !ConstFactorOk(pParse) ) flags &= ~SQLITE_ECEL_FACTOR;\n  for(pItem=pList->a, i=0; i<n; i++, pItem++){\n    Expr *pExpr = pItem->pExpr;\n#ifdef SQLITE_ENABLE_SORTER_REFERENCES\n    if( pItem->bSorterRef ){\n      i--;\n      n--;\n    }else\n#endif\n    if( (flags & SQLITE_ECEL_REF)!=0 && (j = pItem->u.x.iOrderByCol)>0 ){\n      if( flags & SQLITE_ECEL_OMITREF ){\n        i--;\n        n--;\n      }else{\n        sqlite3VdbeAddOp2(v, copyOp, j+srcReg-1, target+i);\n      }\n    }else if( (flags & SQLITE_ECEL_FACTOR)!=0\n           && sqlite3ExprIsConstantNotJoin(pExpr)\n    ){\n      sqlite3ExprCodeAtInit(pParse, pExpr, target+i);\n    }else{\n      int inReg = sqlite3ExprCodeTarget(pParse, pExpr, target+i);\n      if( inReg!=target+i ){\n        VdbeOp *pOp;\n        if( copyOp==OP_Copy\n         && (pOp=sqlite3VdbeGetOp(v, -1))->opcode==OP_Copy\n         && pOp->p1+pOp->p3+1==inReg\n         && pOp->p2+pOp->p3+1==target+i\n        ){\n          pOp->p3++;\n        }else{\n          sqlite3VdbeAddOp2(v, copyOp, inReg, target+i);\n        }\n      }\n    }\n  }\n  return n;\n}\n\n/*\n** Generate code for a BETWEEN operator.\n**\n**    x BETWEEN y AND z\n**\n** The above is equivalent to \n**\n**    x>=y AND x<=z\n**\n** Code it as such, taking care to do the common subexpression\n** elimination of x.\n**\n** The xJumpIf parameter determines details:\n**\n**    NULL:                   Store the boolean result in reg[dest]\n**    sqlite3ExprIfTrue:      Jump to dest if true\n**    sqlite3ExprIfFalse:     Jump to dest if false\n**\n** The jumpIfNull parameter is ignored if xJumpIf is NULL.\n*/\nstatic void exprCodeBetween(\n  Parse *pParse,    /* Parsing and code generating context */\n  Expr *pExpr,      /* The BETWEEN expression */\n  int dest,         /* Jump destination or storage location */\n  void (*xJump)(Parse*,Expr*,int,int), /* Action to take */\n  int jumpIfNull    /* Take the jump if the BETWEEN is NULL */\n){\n Expr exprAnd;     /* The AND operator in  x>=y AND x<=z  */\n  Expr compLeft;    /* The  x>=y  term */\n  Expr compRight;   /* The  x<=z  term */\n  Expr exprX;       /* The  x  subexpression */\n  int regFree1 = 0; /* Temporary use register */\n\n  memset(&compLeft, 0, sizeof(Expr));\n  memset(&compRight, 0, sizeof(Expr));\n  memset(&exprAnd, 0, sizeof(Expr));\n\n  assert( !ExprHasProperty(pExpr, EP_xIsSelect) );\n  exprNodeCopy(&exprX, pExpr->pLeft);\n  exprAnd.op = TK_AND;\n  exprAnd.pLeft = &compLeft;\n  exprAnd.pRight = &compRight;\n  compLeft.op = TK_GE;\n  compLeft.pLeft = &exprX;\n  compLeft.pRight = pExpr->x.pList->a[0].pExpr;\n  compRight.op = TK_LE;\n  compRight.pLeft = &exprX;\n  compRight.pRight = pExpr->x.pList->a[1].pExpr;\n  exprToRegister(&exprX, exprCodeVector(pParse, &exprX, &regFree1));\n  if( xJump ){\n    xJump(pParse, &exprAnd, dest, jumpIfNull);\n  }else{\n    /* Mark the expression is being from the ON or USING clause of a join\n    ** so that the sqlite3ExprCodeTarget() routine will not attempt to move\n    ** it into the Parse.pConstExpr list.  We should use a new bit for this,\n    ** for clarity, but we are out of bits in the Expr.flags field so we\n    ** have to reuse the EP_FromJoin bit.  Bummer. */\n    exprX.flags |= EP_FromJoin;\n    sqlite3ExprCodeTarget(pParse, &exprAnd, dest);\n  }\n  sqlite3ReleaseTempReg(pParse, regFree1);\n\n  /* Ensure adequate test coverage */\n  testcase( xJump==sqlite3ExprIfTrue  && jumpIfNull==0 && regFree1==0 );\n  testcase( xJump==sqlite3ExprIfTrue  && jumpIfNull==0 && regFree1!=0 );\n  testcase( xJump==sqlite3ExprIfTrue  && jumpIfNull!=0 && regFree1==0 );\n  testcase( xJump==sqlite3ExprIfTrue  && jumpIfNull!=0 && regFree1!=0 );\n  testcase( xJump==sqlite3ExprIfFalse && jumpIfNull==0 && regFree1==0 );\n  testcase( xJump==sqlite3ExprIfFalse && jumpIfNull==0 && regFree1!=0 );\n  testcase( xJump==sqlite3ExprIfFalse && jumpIfNull!=0 && regFree1==0 );\n  testcase( xJump==sqlite3ExprIfFalse && jumpIfNull!=0 && regFree1!=0 );\n  testcase( xJump==0 );\n}\n\n/*\n** Generate code for a boolean expression such that a jump is made\n** to the label \"dest\" if the expression is true but execution\n** continues straight thru if the expression is false.\n**\n** If the expression evaluates to NULL (neither true nor false), then\n** take the jump if the jumpIfNull flag is SQLITE_JUMPIFNULL.\n**\n** This code depends on the fact that certain token values (ex: TK_EQ)\n** are the same as opcode values (ex: OP_Eq) that implement the corresponding\n** operation.  Special comments in vdbe.c and the mkopcodeh.awk script in\n** the make process cause these values to align.  Assert()s in the code\n** below verify that the numbers are aligned correctly.\n*/\nSQLITE_PRIVATE void sqlite3ExprIfTrue(Parse *pParse, Expr *pExpr, int dest, int jumpIfNull){\n  Vdbe *v = pParse->pVdbe;\n  int op = 0;\n  int regFree1 = 0;\n  int regFree2 = 0;\n  int r1, r2;\n\n  assert( jumpIfNull==SQLITE_JUMPIFNULL || jumpIfNull==0 );\n  if( NEVER(v==0) )     return;  /* Existence of VDBE checked by caller */\n  if( NEVER(pExpr==0) ) return;  /* No way this can happen */\n  op = pExpr->op;\n  switch( op ){\n    case TK_AND: {\n      int d2 = sqlite3VdbeMakeLabel(pParse);\n      testcase( jumpIfNull==0 );\n      sqlite3ExprIfFalse(pParse, pExpr->pLeft, d2,jumpIfNull^SQLITE_JUMPIFNULL);\n      sqlite3ExprIfTrue(pParse, pExpr->pRight, dest, jumpIfNull);\n      sqlite3VdbeResolveLabel(v, d2);\n      break;\n    }\n    case TK_OR: {\n      testcase( jumpIfNull==0 );\n      sqlite3ExprIfTrue(pParse, pExpr->pLeft, dest, jumpIfNull);\n      sqlite3ExprIfTrue(pParse, pExpr->pRight, dest, jumpIfNull);\n      break;\n    }\n    case TK_NOT: {\n      testcase( jumpIfNull==0 );\n      sqlite3ExprIfFalse(pParse, pExpr->pLeft, dest, jumpIfNull);\n      break;\n    }\n    case TK_TRUTH: {\n      int isNot;      /* IS NOT TRUE or IS NOT FALSE */\n      int isTrue;     /* IS TRUE or IS NOT TRUE */\n      testcase( jumpIfNull==0 );\n      isNot = pExpr->op2==TK_ISNOT;\n      isTrue = sqlite3ExprTruthValue(pExpr->pRight);\n      testcase( isTrue && isNot );\n      testcase( !isTrue && isNot );\n      if( isTrue ^ isNot ){\n        sqlite3ExprIfTrue(pParse, pExpr->pLeft, dest,\n                          isNot ? SQLITE_JUMPIFNULL : 0);\n      }else{\n        sqlite3ExprIfFalse(pParse, pExpr->pLeft, dest,\n                           isNot ? SQLITE_JUMPIFNULL : 0);\n      }\n      break;\n    }\n    case TK_IS:\n    case TK_ISNOT:\n      testcase( op==TK_IS );\n      testcase( op==TK_ISNOT );\n      op = (op==TK_IS) ? TK_EQ : TK_NE;\n      jumpIfNull = SQLITE_NULLEQ;\n      /* Fall thru */\n    case TK_LT:\n    case TK_LE:\n    case TK_GT:\n    case TK_GE:\n    case TK_NE:\n    case TK_EQ: {\n      if( sqlite3ExprIsVector(pExpr->pLeft) ) goto default_expr;\n      testcase( jumpIfNull==0 );\n      r1 = sqlite3ExprCodeTemp(pParse, pExpr->pLeft, &regFree1);\n      r2 = sqlite3ExprCodeTemp(pParse, pExpr->pRight, &regFree2);\n      codeCompare(pParse, pExpr->pLeft, pExpr->pRight, op,\n                  r1, r2, dest, jumpIfNull);\n      assert(TK_LT==OP_Lt); testcase(op==OP_Lt); VdbeCoverageIf(v,op==OP_Lt);\n      assert(TK_LE==OP_Le); testcase(op==OP_Le); VdbeCoverageIf(v,op==OP_Le);\n      assert(TK_GT==OP_Gt); testcase(op==OP_Gt); VdbeCoverageIf(v,op==OP_Gt);\n      assert(TK_GE==OP_Ge); testcase(op==OP_Ge); VdbeCoverageIf(v,op==OP_Ge);\n      assert(TK_EQ==OP_Eq); testcase(op==OP_Eq);\n      VdbeCoverageIf(v, op==OP_Eq && jumpIfNull==SQLITE_NULLEQ);\n      VdbeCoverageIf(v, op==OP_Eq && jumpIfNull!=SQLITE_NULLEQ);\n      assert(TK_NE==OP_Ne); testcase(op==OP_Ne);\n      VdbeCoverageIf(v, op==OP_Ne && jumpIfNull==SQLITE_NULLEQ);\n      VdbeCoverageIf(v, op==OP_Ne && jumpIfNull!=SQLITE_NULLEQ);\n      testcase( regFree1==0 );\n      testcase( regFree2==0 );\n      break;\n    }\n    case TK_ISNULL:\n    case TK_NOTNULL: {\n      assert( TK_ISNULL==OP_IsNull );   testcase( op==TK_ISNULL );\n      assert( TK_NOTNULL==OP_NotNull ); testcase( op==TK_NOTNULL );\n      r1 = sqlite3ExprCodeTemp(pParse, pExpr->pLeft, &regFree1);\n      sqlite3VdbeAddOp2(v, op, r1, dest);\n      VdbeCoverageIf(v, op==TK_ISNULL);\n      VdbeCoverageIf(v, op==TK_NOTNULL);\n      testcase( regFree1==0 );\n      break;\n    }\n    case TK_BETWEEN: {\n      testcase( jumpIfNull==0 );\n      exprCodeBetween(pParse, pExpr, dest, sqlite3ExprIfTrue, jumpIfNull);\n      break;\n    }\n#ifndef SQLITE_OMIT_SUBQUERY\n    case TK_IN: {\n      int destIfFalse = sqlite3VdbeMakeLabel(pParse);\n      int destIfNull = jumpIfNull ? dest : destIfFalse;\n      sqlite3ExprCodeIN(pParse, pExpr, destIfFalse, destIfNull);\n      sqlite3VdbeGoto(v, dest);\n      sqlite3VdbeResolveLabel(v, destIfFalse);\n      break;\n    }\n#endif\n    default: {\n    default_expr:\n      if( exprAlwaysTrue(pExpr) ){\n        sqlite3VdbeGoto(v, dest);\n      }else if( exprAlwaysFalse(pExpr) ){\n        /* No-op */\n      }else{\n        r1 = sqlite3ExprCodeTemp(pParse, pExpr, &regFree1);\n        sqlite3VdbeAddOp3(v, OP_If, r1, dest, jumpIfNull!=0);\n        VdbeCoverage(v);\n        testcase( regFree1==0 );\n        testcase( jumpIfNull==0 );\n      }\n      break;\n    }\n  }\n  sqlite3ReleaseTempReg(pParse, regFree1);\n  sqlite3ReleaseTempReg(pParse, regFree2);  \n}\n\n/*\n** Generate code for a boolean expression such that a jump is made\n** to the label \"dest\" if the expression is false but execution\n** continues straight thru if the expression is true.\n**\n** If the expression evaluates to NULL (neither true nor false) then\n** jump if jumpIfNull is SQLITE_JUMPIFNULL or fall through if jumpIfNull\n** is 0.\n*/\nSQLITE_PRIVATE void sqlite3ExprIfFalse(Parse *pParse, Expr *pExpr, int dest, int jumpIfNull){\n  Vdbe *v = pParse->pVdbe;\n  int op = 0;\n  int regFree1 = 0;\n  int regFree2 = 0;\n  int r1, r2;\n\n  assert( jumpIfNull==SQLITE_JUMPIFNULL || jumpIfNull==0 );\n  if( NEVER(v==0) ) return; /* Existence of VDBE checked by caller */\n  if( pExpr==0 )    return;\n\n  /* The value of pExpr->op and op are related as follows:\n  **\n  **       pExpr->op            op\n  **       ---------          ----------\n  **       TK_ISNULL          OP_NotNull\n  **       TK_NOTNULL         OP_IsNull\n  **       TK_NE              OP_Eq\n  **       TK_EQ              OP_Ne\n  **       TK_GT              OP_Le\n  **       TK_LE              OP_Gt\n  **       TK_GE              OP_Lt\n  **       TK_LT              OP_Ge\n  **\n  ** For other values of pExpr->op, op is undefined and unused.\n  ** The value of TK_ and OP_ constants are arranged such that we\n  ** can compute the mapping above using the following expression.\n  ** Assert()s verify that the computation is correct.\n  */\n  op = ((pExpr->op+(TK_ISNULL&1))^1)-(TK_ISNULL&1);\n\n  /* Verify correct alignment of TK_ and OP_ constants\n  */\n  assert( pExpr->op!=TK_ISNULL || op==OP_NotNull );\n  assert( pExpr->op!=TK_NOTNULL || op==OP_IsNull );\n  assert( pExpr->op!=TK_NE || op==OP_Eq );\n  assert( pExpr->op!=TK_EQ || op==OP_Ne );\n  assert( pExpr->op!=TK_LT || op==OP_Ge );\n  assert( pExpr->op!=TK_LE || op==OP_Gt );\n  assert( pExpr->op!=TK_GT || op==OP_Le );\n  assert( pExpr->op!=TK_GE || op==OP_Lt );\n\n  switch( pExpr->op ){\n    case TK_AND: {\n      testcase( jumpIfNull==0 );\n      sqlite3ExprIfFalse(pParse, pExpr->pLeft, dest, jumpIfNull);\n      sqlite3ExprIfFalse(pParse, pExpr->pRight, dest, jumpIfNull);\n      break;\n    }\n    case TK_OR: {\n      int d2 = sqlite3VdbeMakeLabel(pParse);\n      testcase( jumpIfNull==0 );\n      sqlite3ExprIfTrue(pParse, pExpr->pLeft, d2, jumpIfNull^SQLITE_JUMPIFNULL);\n      sqlite3ExprIfFalse(pParse, pExpr->pRight, dest, jumpIfNull);\n      sqlite3VdbeResolveLabel(v, d2);\n      break;\n    }\n    case TK_NOT: {\n      testcase( jumpIfNull==0 );\n      sqlite3ExprIfTrue(pParse, pExpr->pLeft, dest, jumpIfNull);\n      break;\n    }\n    case TK_TRUTH: {\n      int isNot;   /* IS NOT TRUE or IS NOT FALSE */\n      int isTrue;  /* IS TRUE or IS NOT TRUE */\n      testcase( jumpIfNull==0 );\n      isNot = pExpr->op2==TK_ISNOT;\n      isTrue = sqlite3ExprTruthValue(pExpr->pRight);\n      testcase( isTrue && isNot );\n      testcase( !isTrue && isNot );\n      if( isTrue ^ isNot ){\n        /* IS TRUE and IS NOT FALSE */\n        sqlite3ExprIfFalse(pParse, pExpr->pLeft, dest,\n                           isNot ? 0 : SQLITE_JUMPIFNULL);\n\n      }else{\n        /* IS FALSE and IS NOT TRUE */\n        sqlite3ExprIfTrue(pParse, pExpr->pLeft, dest,\n                          isNot ? 0 : SQLITE_JUMPIFNULL);\n      }\n      break;\n    }\n    case TK_IS:\n    case TK_ISNOT:\n      testcase( pExpr->op==TK_IS );\n      testcase( pExpr->op==TK_ISNOT );\n      op = (pExpr->op==TK_IS) ? TK_NE : TK_EQ;\n      jumpIfNull = SQLITE_NULLEQ;\n      /* Fall thru */\n    case TK_LT:\n    case TK_LE:\n    case TK_GT:\n    case TK_GE:\n    case TK_NE:\n    case TK_EQ: {\n      if( sqlite3ExprIsVector(pExpr->pLeft) ) goto default_expr;\n      testcase( jumpIfNull==0 );\n      r1 = sqlite3ExprCodeTemp(pParse, pExpr->pLeft, &regFree1);\n      r2 = sqlite3ExprCodeTemp(pParse, pExpr->pRight, &regFree2);\n      codeCompare(pParse, pExpr->pLeft, pExpr->pRight, op,\n                  r1, r2, dest, jumpIfNull);\n      assert(TK_LT==OP_Lt); testcase(op==OP_Lt); VdbeCoverageIf(v,op==OP_Lt);\n      assert(TK_LE==OP_Le); testcase(op==OP_Le); VdbeCoverageIf(v,op==OP_Le);\n      assert(TK_GT==OP_Gt); testcase(op==OP_Gt); VdbeCoverageIf(v,op==OP_Gt);\n      assert(TK_GE==OP_Ge); testcase(op==OP_Ge); VdbeCoverageIf(v,op==OP_Ge);\n      assert(TK_EQ==OP_Eq); testcase(op==OP_Eq);\n      VdbeCoverageIf(v, op==OP_Eq && jumpIfNull!=SQLITE_NULLEQ);\n      VdbeCoverageIf(v, op==OP_Eq && jumpIfNull==SQLITE_NULLEQ);\n      assert(TK_NE==OP_Ne); testcase(op==OP_Ne);\n      VdbeCoverageIf(v, op==OP_Ne && jumpIfNull!=SQLITE_NULLEQ);\n      VdbeCoverageIf(v, op==OP_Ne && jumpIfNull==SQLITE_NULLEQ);\n      testcase( regFree1==0 );\n      testcase( regFree2==0 );\n      break;\n    }\n    case TK_ISNULL:\n    case TK_NOTNULL: {\n      r1 = sqlite3ExprCodeTemp(pParse, pExpr->pLeft, &regFree1);\n      sqlite3VdbeAddOp2(v, op, r1, dest);\n      testcase( op==TK_ISNULL );   VdbeCoverageIf(v, op==TK_ISNULL);\n      testcase( op==TK_NOTNULL );  VdbeCoverageIf(v, op==TK_NOTNULL);\n      testcase( regFree1==0 );\n      break;\n    }\n    case TK_BETWEEN: {\n      testcase( jumpIfNull==0 );\n      exprCodeBetween(pParse, pExpr, dest, sqlite3ExprIfFalse, jumpIfNull);\n      break;\n    }\n#ifndef SQLITE_OMIT_SUBQUERY\n    case TK_IN: {\n      if( jumpIfNull ){\n        sqlite3ExprCodeIN(pParse, pExpr, dest, dest);\n      }else{\n        int destIfNull = sqlite3VdbeMakeLabel(pParse);\n        sqlite3ExprCodeIN(pParse, pExpr, dest, destIfNull);\n        sqlite3VdbeResolveLabel(v, destIfNull);\n      }\n      break;\n    }\n#endif\n    default: {\n    default_expr: \n      if( exprAlwaysFalse(pExpr) ){\n        sqlite3VdbeGoto(v, dest);\n      }else if( exprAlwaysTrue(pExpr) ){\n        /* no-op */\n      }else{\n        r1 = sqlite3ExprCodeTemp(pParse, pExpr, &regFree1);\n        sqlite3VdbeAddOp3(v, OP_IfNot, r1, dest, jumpIfNull!=0);\n        VdbeCoverage(v);\n        testcase( regFree1==0 );\n        testcase( jumpIfNull==0 );\n      }\n      break;\n    }\n  }\n  sqlite3ReleaseTempReg(pParse, regFree1);\n  sqlite3ReleaseTempReg(pParse, regFree2);\n}\n\n/*\n** Like sqlite3ExprIfFalse() except that a copy is made of pExpr before\n** code generation, and that copy is deleted after code generation. This\n** ensures that the original pExpr is unchanged.\n*/\nSQLITE_PRIVATE void sqlite3ExprIfFalseDup(Parse *pParse, Expr *pExpr, int dest,int jumpIfNull){\n  sqlite3 *db = pParse->db;\n  Expr *pCopy = sqlite3ExprDup(db, pExpr, 0);\n  if( db->mallocFailed==0 ){\n    sqlite3ExprIfFalse(pParse, pCopy, dest, jumpIfNull);\n  }\n  sqlite3ExprDelete(db, pCopy);\n}\n\n/*\n** Expression pVar is guaranteed to be an SQL variable. pExpr may be any\n** type of expression.\n**\n** If pExpr is a simple SQL value - an integer, real, string, blob\n** or NULL value - then the VDBE currently being prepared is configured\n** to re-prepare each time a new value is bound to variable pVar.\n**\n** Additionally, if pExpr is a simple SQL value and the value is the\n** same as that currently bound to variable pVar, non-zero is returned.\n** Otherwise, if the values are not the same or if pExpr is not a simple\n** SQL value, zero is returned.\n*/\nstatic int exprCompareVariable(Parse *pParse, Expr *pVar, Expr *pExpr){\n  int res = 0;\n  int iVar;\n  sqlite3_value *pL, *pR = 0;\n  \n  sqlite3ValueFromExpr(pParse->db, pExpr, SQLITE_UTF8, SQLITE_AFF_BLOB, &pR);\n  if( pR ){\n    iVar = pVar->iColumn;\n    sqlite3VdbeSetVarmask(pParse->pVdbe, iVar);\n    pL = sqlite3VdbeGetBoundValue(pParse->pReprepare, iVar, SQLITE_AFF_BLOB);\n    if( pL ){\n      if( sqlite3_value_type(pL)==SQLITE_TEXT ){\n        sqlite3_value_text(pL); /* Make sure the encoding is UTF-8 */\n      }\n      res =  0==sqlite3MemCompare(pL, pR, 0);\n    }\n    sqlite3ValueFree(pR);\n    sqlite3ValueFree(pL);\n  }\n\n  return res;\n}\n\n/*\n** Do a deep comparison of two expression trees.  Return 0 if the two\n** expressions are completely identical.  Return 1 if they differ only\n** by a COLLATE operator at the top level.  Return 2 if there are differences\n** other than the top-level COLLATE operator.\n**\n** If any subelement of pB has Expr.iTable==(-1) then it is allowed\n** to compare equal to an equivalent element in pA with Expr.iTable==iTab.\n**\n** The pA side might be using TK_REGISTER.  If that is the case and pB is\n** not using TK_REGISTER but is otherwise equivalent, then still return 0.\n**\n** Sometimes this routine will return 2 even if the two expressions\n** really are equivalent.  If we cannot prove that the expressions are\n** identical, we return 2 just to be safe.  So if this routine\n** returns 2, then you do not really know for certain if the two\n** expressions are the same.  But if you get a 0 or 1 return, then you\n** can be sure the expressions are the same.  In the places where\n** this routine is used, it does not hurt to get an extra 2 - that\n** just might result in some slightly slower code.  But returning\n** an incorrect 0 or 1 could lead to a malfunction.\n**\n** If pParse is not NULL then TK_VARIABLE terms in pA with bindings in\n** pParse->pReprepare can be matched against literals in pB.  The \n** pParse->pVdbe->expmask bitmask is updated for each variable referenced.\n** If pParse is NULL (the normal case) then any TK_VARIABLE term in \n** Argument pParse should normally be NULL. If it is not NULL and pA or\n** pB causes a return value of 2.\n*/\nSQLITE_PRIVATE int sqlite3ExprCompare(Parse *pParse, Expr *pA, Expr *pB, int iTab){\n  u32 combinedFlags;\n  if( pA==0 || pB==0 ){\n    return pB==pA ? 0 : 2;\n  }\n  if( pParse && pA->op==TK_VARIABLE && exprCompareVariable(pParse, pA, pB) ){\n    return 0;\n  }\n  combinedFlags = pA->flags | pB->flags;\n  if( combinedFlags & EP_IntValue ){\n    if( (pA->flags&pB->flags&EP_IntValue)!=0 && pA->u.iValue==pB->u.iValue ){\n      return 0;\n    }\n    return 2;\n  }\n  if( pA->op!=pB->op || pA->op==TK_RAISE ){\n    if( pA->op==TK_COLLATE && sqlite3ExprCompare(pParse, pA->pLeft,pB,iTab)<2 ){\n      return 1;\n    }\n    if( pB->op==TK_COLLATE && sqlite3ExprCompare(pParse, pA,pB->pLeft,iTab)<2 ){\n      return 1;\n    }\n    return 2;\n  }\n  if( pA->op!=TK_COLUMN && pA->op!=TK_AGG_COLUMN && pA->u.zToken ){\n    if( pA->op==TK_FUNCTION ){\n      if( sqlite3StrICmp(pA->u.zToken,pB->u.zToken)!=0 ) return 2;\n#ifndef SQLITE_OMIT_WINDOWFUNC\n      /* Justification for the assert():\n      ** window functions have p->op==TK_FUNCTION but aggregate functions\n      ** have p->op==TK_AGG_FUNCTION.  So any comparison between an aggregate\n      ** function and a window function should have failed before reaching\n      ** this point.  And, it is not possible to have a window function and\n      ** a scalar function with the same name and number of arguments.  So\n      ** if we reach this point, either A and B both window functions or\n      ** neither are a window functions. */\n      assert( ExprHasProperty(pA,EP_WinFunc)==ExprHasProperty(pB,EP_WinFunc) );\n      if( ExprHasProperty(pA,EP_WinFunc) ){\n        if( sqlite3WindowCompare(pParse,pA->y.pWin,pB->y.pWin)!=0 ) return 2;\n      }\n#endif\n    }else if( pA->op==TK_NULL ){\n      return 0;\n    }else if( pA->op==TK_COLLATE ){\n      if( sqlite3_stricmp(pA->u.zToken,pB->u.zToken)!=0 ) return 2;\n    }else if( ALWAYS(pB->u.zToken!=0) && strcmp(pA->u.zToken,pB->u.zToken)!=0 ){\n      return 2;\n    }\n  }\n  if( (pA->flags & EP_Distinct)!=(pB->flags & EP_Distinct) ) return 2;\n  if( (combinedFlags & EP_TokenOnly)==0 ){\n    if( combinedFlags & EP_xIsSelect ) return 2;\n    if( (combinedFlags & EP_FixedCol)==0\n     && sqlite3ExprCompare(pParse, pA->pLeft, pB->pLeft, iTab) ) return 2;\n    if( sqlite3ExprCompare(pParse, pA->pRight, pB->pRight, iTab) ) return 2;\n    if( sqlite3ExprListCompare(pA->x.pList, pB->x.pList, iTab) ) return 2;\n    if( pA->op!=TK_STRING\n     && pA->op!=TK_TRUEFALSE\n     && (combinedFlags & EP_Reduced)==0\n    ){\n      if( pA->iColumn!=pB->iColumn ) return 2;\n      if( pA->iTable!=pB->iTable \n       && (pA->iTable!=iTab || NEVER(pB->iTable>=0)) ) return 2;\n    }\n  }\n  return 0;\n}\n\n/*\n** Compare two ExprList objects.  Return 0 if they are identical and \n** non-zero if they differ in any way.\n**\n** If any subelement of pB has Expr.iTable==(-1) then it is allowed\n** to compare equal to an equivalent element in pA with Expr.iTable==iTab.\n**\n** This routine might return non-zero for equivalent ExprLists.  The\n** only consequence will be disabled optimizations.  But this routine\n** must never return 0 if the two ExprList objects are different, or\n** a malfunction will result.\n**\n** Two NULL pointers are considered to be the same.  But a NULL pointer\n** always differs from a non-NULL pointer.\n*/\nSQLITE_PRIVATE int sqlite3ExprListCompare(ExprList *pA, ExprList *pB, int iTab){\n  int i;\n  if( pA==0 && pB==0 ) return 0;\n  if( pA==0 || pB==0 ) return 1;\n  if( pA->nExpr!=pB->nExpr ) return 1;\n  for(i=0; i<pA->nExpr; i++){\n    Expr *pExprA = pA->a[i].pExpr;\n    Expr *pExprB = pB->a[i].pExpr;\n    if( pA->a[i].sortOrder!=pB->a[i].sortOrder ) return 1;\n    if( sqlite3ExprCompare(0, pExprA, pExprB, iTab) ) return 1;\n  }\n  return 0;\n}\n\n/*\n** Like sqlite3ExprCompare() except COLLATE operators at the top-level\n** are ignored.\n*/\nSQLITE_PRIVATE int sqlite3ExprCompareSkip(Expr *pA, Expr *pB, int iTab){\n  return sqlite3ExprCompare(0,\n             sqlite3ExprSkipCollate(pA),\n             sqlite3ExprSkipCollate(pB),\n             iTab);\n}\n\n/*\n** Return true if we can prove the pE2 will always be true if pE1 is\n** true.  Return false if we cannot complete the proof or if pE2 might\n** be false.  Examples:\n**\n**     pE1: x==5       pE2: x==5             Result: true\n**     pE1: x>0        pE2: x==5             Result: false\n**     pE1: x=21       pE2: x=21 OR y=43     Result: true\n**     pE1: x!=123     pE2: x IS NOT NULL    Result: true\n**     pE1: x!=?1      pE2: x IS NOT NULL    Result: true\n**     pE1: x IS NULL  pE2: x IS NOT NULL    Result: false\n**     pE1: x IS ?2    pE2: x IS NOT NULL    Reuslt: false\n**\n** When comparing TK_COLUMN nodes between pE1 and pE2, if pE2 has\n** Expr.iTable<0 then assume a table number given by iTab.\n**\n** If pParse is not NULL, then the values of bound variables in pE1 are \n** compared against literal values in pE2 and pParse->pVdbe->expmask is\n** modified to record which bound variables are referenced.  If pParse \n** is NULL, then false will be returned if pE1 contains any bound variables.\n**\n** When in doubt, return false.  Returning true might give a performance\n** improvement.  Returning false might cause a performance reduction, but\n** it will always give the correct answer and is hence always safe.\n*/\nSQLITE_PRIVATE int sqlite3ExprImpliesExpr(Parse *pParse, Expr *pE1, Expr *pE2, int iTab){\n  if( sqlite3ExprCompare(pParse, pE1, pE2, iTab)==0 ){\n    return 1;\n  }\n  if( pE2->op==TK_OR\n   && (sqlite3ExprImpliesExpr(pParse, pE1, pE2->pLeft, iTab)\n             || sqlite3ExprImpliesExpr(pParse, pE1, pE2->pRight, iTab) )\n  ){\n    return 1;\n  }\n  if( pE2->op==TK_NOTNULL && pE1->op!=TK_ISNULL && pE1->op!=TK_IS ){\n    Expr *pX = sqlite3ExprSkipCollate(pE1->pLeft);\n    testcase( pX!=pE1->pLeft );\n    if( sqlite3ExprCompare(pParse, pX, pE2->pLeft, iTab)==0 ) return 1;\n  }\n  return 0;\n}\n\n/*\n** This is the Expr node callback for sqlite3ExprImpliesNotNullRow().\n** If the expression node requires that the table at pWalker->iCur\n** have one or more non-NULL column, then set pWalker->eCode to 1 and abort.\n**\n** This routine controls an optimization.  False positives (setting\n** pWalker->eCode to 1 when it should not be) are deadly, but false-negatives\n** (never setting pWalker->eCode) is a harmless missed optimization.\n*/\nstatic int impliesNotNullRow(Walker *pWalker, Expr *pExpr){\n  testcase( pExpr->op==TK_AGG_COLUMN );\n  testcase( pExpr->op==TK_AGG_FUNCTION );\n  if( ExprHasProperty(pExpr, EP_FromJoin) ) return WRC_Prune;\n  switch( pExpr->op ){\n    case TK_ISNOT:\n    case TK_NOT:\n    case TK_ISNULL:\n    case TK_NOTNULL:\n    case TK_IS:\n    case TK_OR:\n    case TK_CASE:\n    case TK_IN:\n    case TK_FUNCTION:\n      testcase( pExpr->op==TK_ISNOT );\n      testcase( pExpr->op==TK_NOT );\n      testcase( pExpr->op==TK_ISNULL );\n      testcase( pExpr->op==TK_NOTNULL );\n      testcase( pExpr->op==TK_IS );\n      testcase( pExpr->op==TK_OR );\n      testcase( pExpr->op==TK_CASE );\n      testcase( pExpr->op==TK_IN );\n      testcase( pExpr->op==TK_FUNCTION );\n      return WRC_Prune;\n    case TK_COLUMN:\n      if( pWalker->u.iCur==pExpr->iTable ){\n        pWalker->eCode = 1;\n        return WRC_Abort;\n      }\n      return WRC_Prune;\n\n    /* Virtual tables are allowed to use constraints like x=NULL.  So\n    ** a term of the form x=y does not prove that y is not null if x\n    ** is the column of a virtual table */\n    case TK_EQ:\n    case TK_NE:\n    case TK_LT:\n    case TK_LE:\n    case TK_GT:\n    case TK_GE:\n      testcase( pExpr->op==TK_EQ );\n      testcase( pExpr->op==TK_NE );\n      testcase( pExpr->op==TK_LT );\n      testcase( pExpr->op==TK_LE );\n      testcase( pExpr->op==TK_GT );\n      testcase( pExpr->op==TK_GE );\n      if( (pExpr->pLeft->op==TK_COLUMN && IsVirtual(pExpr->pLeft->y.pTab))\n       || (pExpr->pRight->op==TK_COLUMN && IsVirtual(pExpr->pRight->y.pTab))\n      ){\n       return WRC_Prune;\n      }\n    default:\n      return WRC_Continue;\n  }\n}\n\n/*\n** Return true (non-zero) if expression p can only be true if at least\n** one column of table iTab is non-null.  In other words, return true\n** if expression p will always be NULL or false if every column of iTab\n** is NULL.\n**\n** False negatives are acceptable.  In other words, it is ok to return\n** zero even if expression p will never be true of every column of iTab\n** is NULL.  A false negative is merely a missed optimization opportunity.\n**\n** False positives are not allowed, however.  A false positive may result\n** in an incorrect answer.\n**\n** Terms of p that are marked with EP_FromJoin (and hence that come from\n** the ON or USING clauses of LEFT JOINS) are excluded from the analysis.\n**\n** This routine is used to check if a LEFT JOIN can be converted into\n** an ordinary JOIN.  The p argument is the WHERE clause.  If the WHERE\n** clause requires that some column of the right table of the LEFT JOIN\n** be non-NULL, then the LEFT JOIN can be safely converted into an\n** ordinary join.\n*/\nSQLITE_PRIVATE int sqlite3ExprImpliesNonNullRow(Expr *p, int iTab){\n  Walker w;\n  w.xExprCallback = impliesNotNullRow;\n  w.xSelectCallback = 0;\n  w.xSelectCallback2 = 0;\n  w.eCode = 0;\n  w.u.iCur = iTab;\n  sqlite3WalkExpr(&w, p);\n  return w.eCode;\n}\n\n/*\n** An instance of the following structure is used by the tree walker\n** to determine if an expression can be evaluated by reference to the\n** index only, without having to do a search for the corresponding\n** table entry.  The IdxCover.pIdx field is the index.  IdxCover.iCur\n** is the cursor for the table.\n*/\nstruct IdxCover {\n  Index *pIdx;     /* The index to be tested for coverage */\n  int iCur;        /* Cursor number for the table corresponding to the index */\n};\n\n/*\n** Check to see if there are references to columns in table \n** pWalker->u.pIdxCover->iCur can be satisfied using the index\n** pWalker->u.pIdxCover->pIdx.\n*/\nstatic int exprIdxCover(Walker *pWalker, Expr *pExpr){\n  if( pExpr->op==TK_COLUMN\n   && pExpr->iTable==pWalker->u.pIdxCover->iCur\n   && sqlite3ColumnOfIndex(pWalker->u.pIdxCover->pIdx, pExpr->iColumn)<0\n  ){\n    pWalker->eCode = 1;\n    return WRC_Abort;\n  }\n  return WRC_Continue;\n}\n\n/*\n** Determine if an index pIdx on table with cursor iCur contains will\n** the expression pExpr.  Return true if the index does cover the\n** expression and false if the pExpr expression references table columns\n** that are not found in the index pIdx.\n**\n** An index covering an expression means that the expression can be\n** evaluated using only the index and without having to lookup the\n** corresponding table entry.\n*/\nSQLITE_PRIVATE int sqlite3ExprCoveredByIndex(\n  Expr *pExpr,        /* The index to be tested */\n  int iCur,           /* The cursor number for the corresponding table */\n  Index *pIdx         /* The index that might be used for coverage */\n){\n  Walker w;\n  struct IdxCover xcov;\n  memset(&w, 0, sizeof(w));\n  xcov.iCur = iCur;\n  xcov.pIdx = pIdx;\n  w.xExprCallback = exprIdxCover;\n  w.u.pIdxCover = &xcov;\n  sqlite3WalkExpr(&w, pExpr);\n  return !w.eCode;\n}\n\n\n/*\n** An instance of the following structure is used by the tree walker\n** to count references to table columns in the arguments of an \n** aggregate function, in order to implement the\n** sqlite3FunctionThisSrc() routine.\n*/\nstruct SrcCount {\n  SrcList *pSrc;   /* One particular FROM clause in a nested query */\n  int nThis;       /* Number of references to columns in pSrcList */\n  int nOther;      /* Number of references to columns in other FROM clauses */\n};\n\n/*\n** Count the number of references to columns.\n*/\nstatic int exprSrcCount(Walker *pWalker, Expr *pExpr){\n  /* The NEVER() on the second term is because sqlite3FunctionUsesThisSrc()\n  ** is always called before sqlite3ExprAnalyzeAggregates() and so the\n  ** TK_COLUMNs have not yet been converted into TK_AGG_COLUMN.  If\n  ** sqlite3FunctionUsesThisSrc() is used differently in the future, the\n  ** NEVER() will need to be removed. */\n  if( pExpr->op==TK_COLUMN || NEVER(pExpr->op==TK_AGG_COLUMN) ){\n    int i;\n    struct SrcCount *p = pWalker->u.pSrcCount;\n    SrcList *pSrc = p->pSrc;\n    int nSrc = pSrc ? pSrc->nSrc : 0;\n    for(i=0; i<nSrc; i++){\n      if( pExpr->iTable==pSrc->a[i].iCursor ) break;\n    }\n    if( i<nSrc ){\n      p->nThis++;\n    }else{\n      p->nOther++;\n    }\n  }\n  return WRC_Continue;\n}\n\n/*\n** Determine if any of the arguments to the pExpr Function reference\n** pSrcList.  Return true if they do.  Also return true if the function\n** has no arguments or has only constant arguments.  Return false if pExpr\n** references columns but not columns of tables found in pSrcList.\n*/\nSQLITE_PRIVATE int sqlite3FunctionUsesThisSrc(Expr *pExpr, SrcList *pSrcList){\n  Walker w;\n  struct SrcCount cnt;\n  assert( pExpr->op==TK_AGG_FUNCTION );\n  w.xExprCallback = exprSrcCount;\n  w.xSelectCallback = 0;\n  w.u.pSrcCount = &cnt;\n  cnt.pSrc = pSrcList;\n  cnt.nThis = 0;\n  cnt.nOther = 0;\n  sqlite3WalkExprList(&w, pExpr->x.pList);\n  return cnt.nThis>0 || cnt.nOther==0;\n}\n\n/*\n** Add a new element to the pAggInfo->aCol[] array.  Return the index of\n** the new element.  Return a negative number if malloc fails.\n*/\nstatic int addAggInfoColumn(sqlite3 *db, AggInfo *pInfo){\n  int i;\n  pInfo->aCol = sqlite3ArrayAllocate(\n       db,\n       pInfo->aCol,\n       sizeof(pInfo->aCol[0]),\n       &pInfo->nColumn,\n       &i\n  );\n  return i;\n}    \n\n/*\n** Add a new element to the pAggInfo->aFunc[] array.  Return the index of\n** the new element.  Return a negative number if malloc fails.\n*/\nstatic int addAggInfoFunc(sqlite3 *db, AggInfo *pInfo){\n  int i;\n  pInfo->aFunc = sqlite3ArrayAllocate(\n       db, \n       pInfo->aFunc,\n       sizeof(pInfo->aFunc[0]),\n       &pInfo->nFunc,\n       &i\n  );\n  return i;\n}    \n\n/*\n** This is the xExprCallback for a tree walker.  It is used to\n** implement sqlite3ExprAnalyzeAggregates().  See sqlite3ExprAnalyzeAggregates\n** for additional information.\n*/\nstatic int analyzeAggregate(Walker *pWalker, Expr *pExpr){\n  int i;\n  NameContext *pNC = pWalker->u.pNC;\n  Parse *pParse = pNC->pParse;\n  SrcList *pSrcList = pNC->pSrcList;\n  AggInfo *pAggInfo = pNC->uNC.pAggInfo;\n\n  assert( pNC->ncFlags & NC_UAggInfo );\n  switch( pExpr->op ){\n    case TK_AGG_COLUMN:\n    case TK_COLUMN: {\n      testcase( pExpr->op==TK_AGG_COLUMN );\n      testcase( pExpr->op==TK_COLUMN );\n      /* Check to see if the column is in one of the tables in the FROM\n      ** clause of the aggregate query */\n      if( ALWAYS(pSrcList!=0) ){\n        struct SrcList_item *pItem = pSrcList->a;\n        for(i=0; i<pSrcList->nSrc; i++, pItem++){\n          struct AggInfo_col *pCol;\n          assert( !ExprHasProperty(pExpr, EP_TokenOnly|EP_Reduced) );\n          if( pExpr->iTable==pItem->iCursor ){\n            /* If we reach this point, it means that pExpr refers to a table\n            ** that is in the FROM clause of the aggregate query.  \n            **\n            ** Make an entry for the column in pAggInfo->aCol[] if there\n            ** is not an entry there already.\n            */\n            int k;\n            pCol = pAggInfo->aCol;\n            for(k=0; k<pAggInfo->nColumn; k++, pCol++){\n              if( pCol->iTable==pExpr->iTable &&\n                  pCol->iColumn==pExpr->iColumn ){\n                break;\n              }\n            }\n            if( (k>=pAggInfo->nColumn)\n             && (k = addAggInfoColumn(pParse->db, pAggInfo))>=0 \n            ){\n              pCol = &pAggInfo->aCol[k];\n              pCol->pTab = pExpr->y.pTab;\n              pCol->iTable = pExpr->iTable;\n              pCol->iColumn = pExpr->iColumn;\n              pCol->iMem = ++pParse->nMem;\n              pCol->iSorterColumn = -1;\n              pCol->pExpr = pExpr;\n              if( pAggInfo->pGroupBy ){\n                int j, n;\n                ExprList *pGB = pAggInfo->pGroupBy;\n                struct ExprList_item *pTerm = pGB->a;\n                n = pGB->nExpr;\n                for(j=0; j<n; j++, pTerm++){\n                  Expr *pE = pTerm->pExpr;\n                  if( pE->op==TK_COLUMN && pE->iTable==pExpr->iTable &&\n                      pE->iColumn==pExpr->iColumn ){\n                    pCol->iSorterColumn = j;\n                    break;\n                  }\n                }\n              }\n              if( pCol->iSorterColumn<0 ){\n                pCol->iSorterColumn = pAggInfo->nSortingColumn++;\n              }\n            }\n            /* There is now an entry for pExpr in pAggInfo->aCol[] (either\n            ** because it was there before or because we just created it).\n            ** Convert the pExpr to be a TK_AGG_COLUMN referring to that\n            ** pAggInfo->aCol[] entry.\n            */\n            ExprSetVVAProperty(pExpr, EP_NoReduce);\n            pExpr->pAggInfo = pAggInfo;\n            pExpr->op = TK_AGG_COLUMN;\n            pExpr->iAgg = (i16)k;\n            break;\n          } /* endif pExpr->iTable==pItem->iCursor */\n        } /* end loop over pSrcList */\n      }\n      return WRC_Prune;\n    }\n    case TK_AGG_FUNCTION: {\n      if( (pNC->ncFlags & NC_InAggFunc)==0\n       && pWalker->walkerDepth==pExpr->op2\n      ){\n        /* Check to see if pExpr is a duplicate of another aggregate \n        ** function that is already in the pAggInfo structure\n        */\n        struct AggInfo_func *pItem = pAggInfo->aFunc;\n        for(i=0; i<pAggInfo->nFunc; i++, pItem++){\n          if( sqlite3ExprCompare(0, pItem->pExpr, pExpr, -1)==0 ){\n            break;\n          }\n        }\n        if( i>=pAggInfo->nFunc ){\n          /* pExpr is original.  Make a new entry in pAggInfo->aFunc[]\n          */\n          u8 enc = ENC(pParse->db);\n          i = addAggInfoFunc(pParse->db, pAggInfo);\n          if( i>=0 ){\n            assert( !ExprHasProperty(pExpr, EP_xIsSelect) );\n            pItem = &pAggInfo->aFunc[i];\n            pItem->pExpr = pExpr;\n            pItem->iMem = ++pParse->nMem;\n            assert( !ExprHasProperty(pExpr, EP_IntValue) );\n            pItem->pFunc = sqlite3FindFunction(pParse->db,\n                   pExpr->u.zToken, \n                   pExpr->x.pList ? pExpr->x.pList->nExpr : 0, enc, 0);\n            if( pExpr->flags & EP_Distinct ){\n              pItem->iDistinct = pParse->nTab++;\n            }else{\n              pItem->iDistinct = -1;\n            }\n          }\n        }\n        /* Make pExpr point to the appropriate pAggInfo->aFunc[] entry\n        */\n        assert( !ExprHasProperty(pExpr, EP_TokenOnly|EP_Reduced) );\n        ExprSetVVAProperty(pExpr, EP_NoReduce);\n        pExpr->iAgg = (i16)i;\n        pExpr->pAggInfo = pAggInfo;\n        return WRC_Prune;\n      }else{\n        return WRC_Continue;\n      }\n    }\n  }\n  return WRC_Continue;\n}\nstatic int analyzeAggregatesInSelect(Walker *pWalker, Select *pSelect){\n  UNUSED_PARAMETER(pSelect);\n  pWalker->walkerDepth++;\n  return WRC_Continue;\n}\nstatic void analyzeAggregatesInSelectEnd(Walker *pWalker, Select *pSelect){\n  UNUSED_PARAMETER(pSelect);\n  pWalker->walkerDepth--;\n}\n\n/*\n** Analyze the pExpr expression looking for aggregate functions and\n** for variables that need to be added to AggInfo object that pNC->pAggInfo\n** points to.  Additional entries are made on the AggInfo object as\n** necessary.\n**\n** This routine should only be called after the expression has been\n** analyzed by sqlite3ResolveExprNames().\n*/\nSQLITE_PRIVATE void sqlite3ExprAnalyzeAggregates(NameContext *pNC, Expr *pExpr){\n  Walker w;\n  w.xExprCallback = analyzeAggregate;\n  w.xSelectCallback = analyzeAggregatesInSelect;\n  w.xSelectCallback2 = analyzeAggregatesInSelectEnd;\n  w.walkerDepth = 0;\n  w.u.pNC = pNC;\n  w.pParse = 0;\n  assert( pNC->pSrcList!=0 );\n  sqlite3WalkExpr(&w, pExpr);\n}\n\n/*\n** Call sqlite3ExprAnalyzeAggregates() for every expression in an\n** expression list.  Return the number of errors.\n**\n** If an error is found, the analysis is cut short.\n*/\nSQLITE_PRIVATE void sqlite3ExprAnalyzeAggList(NameContext *pNC, ExprList *pList){\n  struct ExprList_item *pItem;\n  int i;\n  if( pList ){\n    for(pItem=pList->a, i=0; i<pList->nExpr; i++, pItem++){\n      sqlite3ExprAnalyzeAggregates(pNC, pItem->pExpr);\n    }\n  }\n}\n\n/*\n** Allocate a single new register for use to hold some intermediate result.\n*/\nSQLITE_PRIVATE int sqlite3GetTempReg(Parse *pParse){\n  if( pParse->nTempReg==0 ){\n    return ++pParse->nMem;\n  }\n  return pParse->aTempReg[--pParse->nTempReg];\n}\n\n/*\n** Deallocate a register, making available for reuse for some other\n** purpose.\n*/\nSQLITE_PRIVATE void sqlite3ReleaseTempReg(Parse *pParse, int iReg){\n  if( iReg && pParse->nTempReg<ArraySize(pParse->aTempReg) ){\n    pParse->aTempReg[pParse->nTempReg++] = iReg;\n  }\n}\n\n/*\n** Allocate or deallocate a block of nReg consecutive registers.\n*/\nSQLITE_PRIVATE int sqlite3GetTempRange(Parse *pParse, int nReg){\n  int i, n;\n  if( nReg==1 ) return sqlite3GetTempReg(pParse);\n  i = pParse->iRangeReg;\n  n = pParse->nRangeReg;\n  if( nReg<=n ){\n    pParse->iRangeReg += nReg;\n    pParse->nRangeReg -= nReg;\n  }else{\n    i = pParse->nMem+1;\n    pParse->nMem += nReg;\n  }\n  return i;\n}\nSQLITE_PRIVATE void sqlite3ReleaseTempRange(Parse *pParse, int iReg, int nReg){\n  if( nReg==1 ){\n    sqlite3ReleaseTempReg(pParse, iReg);\n    return;\n  }\n  if( nReg>pParse->nRangeReg ){\n    pParse->nRangeReg = nReg;\n    pParse->iRangeReg = iReg;\n  }\n}\n\n/*\n** Mark all temporary registers as being unavailable for reuse.\n*/\nSQLITE_PRIVATE void sqlite3ClearTempRegCache(Parse *pParse){\n  pParse->nTempReg = 0;\n  pParse->nRangeReg = 0;\n}\n\n/*\n** Validate that no temporary register falls within the range of\n** iFirst..iLast, inclusive.  This routine is only call from within assert()\n** statements.\n*/\n#ifdef SQLITE_DEBUG\nSQLITE_PRIVATE int sqlite3NoTempsInRange(Parse *pParse, int iFirst, int iLast){\n  int i;\n  if( pParse->nRangeReg>0\n   && pParse->iRangeReg+pParse->nRangeReg > iFirst\n   && pParse->iRangeReg <= iLast\n  ){\n     return 0;\n  }\n  for(i=0; i<pParse->nTempReg; i++){\n    if( pParse->aTempReg[i]>=iFirst && pParse->aTempReg[i]<=iLast ){\n      return 0;\n    }\n  }\n  return 1;\n}\n#endif /* SQLITE_DEBUG */\n\n/************** End of expr.c ************************************************/\n/************** Begin file alter.c *******************************************/\n/*\n** 2005 February 15\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This file contains C code routines that used to generate VDBE code\n** that implements the ALTER TABLE command.\n*/\n/* #include \"sqliteInt.h\" */\n\n/*\n** The code in this file only exists if we are not omitting the\n** ALTER TABLE logic from the build.\n*/\n#ifndef SQLITE_OMIT_ALTERTABLE\n\n/*\n** Parameter zName is the name of a table that is about to be altered\n** (either with ALTER TABLE ... RENAME TO or ALTER TABLE ... ADD COLUMN).\n** If the table is a system table, this function leaves an error message\n** in pParse->zErr (system tables may not be altered) and returns non-zero.\n**\n** Or, if zName is not a system table, zero is returned.\n*/\nstatic int isAlterableTable(Parse *pParse, Table *pTab){\n  if( 0==sqlite3StrNICmp(pTab->zName, \"sqlite_\", 7) \n#ifndef SQLITE_OMIT_VIRTUALTABLE\n   || ( (pTab->tabFlags & TF_Shadow) \n     && (pParse->db->flags & SQLITE_Defensive)\n     && pParse->db->nVdbeExec==0\n   )\n#endif\n  ){\n    sqlite3ErrorMsg(pParse, \"table %s may not be altered\", pTab->zName);\n    return 1;\n  }\n  return 0;\n}\n\n/*\n** Generate code to verify that the schemas of database zDb and, if\n** bTemp is not true, database \"temp\", can still be parsed. This is\n** called at the end of the generation of an ALTER TABLE ... RENAME ...\n** statement to ensure that the operation has not rendered any schema\n** objects unusable.\n*/\nstatic void renameTestSchema(Parse *pParse, const char *zDb, int bTemp){\n  sqlite3NestedParse(pParse, \n      \"SELECT 1 \"\n      \"FROM \\\"%w\\\".%s \"\n      \"WHERE name NOT LIKE 'sqlite_%%'\"\n      \" AND sql NOT LIKE 'create virtual%%'\"\n      \" AND sqlite_rename_test(%Q, sql, type, name, %d)=NULL \",\n      zDb, MASTER_NAME, \n      zDb, bTemp\n  );\n\n  if( bTemp==0 ){\n    sqlite3NestedParse(pParse, \n        \"SELECT 1 \"\n        \"FROM temp.%s \"\n        \"WHERE name NOT LIKE 'sqlite_%%'\"\n        \" AND sql NOT LIKE 'create virtual%%'\"\n        \" AND sqlite_rename_test(%Q, sql, type, name, 1)=NULL \",\n        MASTER_NAME, zDb \n    );\n  }\n}\n\n/*\n** Generate code to reload the schema for database iDb. And, if iDb!=1, for\n** the temp database as well.\n*/\nstatic void renameReloadSchema(Parse *pParse, int iDb){\n  Vdbe *v = pParse->pVdbe;\n  if( v ){\n    sqlite3ChangeCookie(pParse, iDb);\n    sqlite3VdbeAddParseSchemaOp(pParse->pVdbe, iDb, 0);\n    if( iDb!=1 ) sqlite3VdbeAddParseSchemaOp(pParse->pVdbe, 1, 0);\n  }\n}\n\n/*\n** Generate code to implement the \"ALTER TABLE xxx RENAME TO yyy\" \n** command. \n*/\nSQLITE_PRIVATE void sqlite3AlterRenameTable(\n  Parse *pParse,            /* Parser context. */\n  SrcList *pSrc,            /* The table to rename. */\n  Token *pName              /* The new table name. */\n){\n  int iDb;                  /* Database that contains the table */\n  char *zDb;                /* Name of database iDb */\n  Table *pTab;              /* Table being renamed */\n  char *zName = 0;          /* NULL-terminated version of pName */ \n  sqlite3 *db = pParse->db; /* Database connection */\n  int nTabName;             /* Number of UTF-8 characters in zTabName */\n  const char *zTabName;     /* Original name of the table */\n  Vdbe *v;\n  VTable *pVTab = 0;        /* Non-zero if this is a v-tab with an xRename() */\n  u32 savedDbFlags;         /* Saved value of db->mDbFlags */\n\n  savedDbFlags = db->mDbFlags;  \n  if( NEVER(db->mallocFailed) ) goto exit_rename_table;\n  assert( pSrc->nSrc==1 );\n  assert( sqlite3BtreeHoldsAllMutexes(pParse->db) );\n\n  pTab = sqlite3LocateTableItem(pParse, 0, &pSrc->a[0]);\n  if( !pTab ) goto exit_rename_table;\n  iDb = sqlite3SchemaToIndex(pParse->db, pTab->pSchema);\n  zDb = db->aDb[iDb].zDbSName;\n  db->mDbFlags |= DBFLAG_PreferBuiltin;\n\n  /* Get a NULL terminated version of the new table name. */\n  zName = sqlite3NameFromToken(db, pName);\n  if( !zName ) goto exit_rename_table;\n\n  /* Check that a table or index named 'zName' does not already exist\n  ** in database iDb. If so, this is an error.\n  */\n  if( sqlite3FindTable(db, zName, zDb) || sqlite3FindIndex(db, zName, zDb) ){\n    sqlite3ErrorMsg(pParse, \n        \"there is already another table or index with this name: %s\", zName);\n    goto exit_rename_table;\n  }\n\n  /* Make sure it is not a system table being altered, or a reserved name\n  ** that the table is being renamed to.\n  */\n  if( SQLITE_OK!=isAlterableTable(pParse, pTab) ){\n    goto exit_rename_table;\n  }\n  if( SQLITE_OK!=sqlite3CheckObjectName(pParse, zName) ){ goto\n    exit_rename_table;\n  }\n\n#ifndef SQLITE_OMIT_VIEW\n  if( pTab->pSelect ){\n    sqlite3ErrorMsg(pParse, \"view %s may not be altered\", pTab->zName);\n    goto exit_rename_table;\n  }\n#endif\n\n#ifndef SQLITE_OMIT_AUTHORIZATION\n  /* Invoke the authorization callback. */\n  if( sqlite3AuthCheck(pParse, SQLITE_ALTER_TABLE, zDb, pTab->zName, 0) ){\n    goto exit_rename_table;\n  }\n#endif\n\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n  if( sqlite3ViewGetColumnNames(pParse, pTab) ){\n    goto exit_rename_table;\n  }\n  if( IsVirtual(pTab) ){\n    pVTab = sqlite3GetVTable(db, pTab);\n    if( pVTab->pVtab->pModule->xRename==0 ){\n      pVTab = 0;\n    }\n  }\n#endif\n\n  /* Begin a transaction for database iDb. \n  ** Then modify the schema cookie (since the ALTER TABLE modifies the\n  ** schema). Open a statement transaction if the table is a virtual\n  ** table.\n  */\n  v = sqlite3GetVdbe(pParse);\n  if( v==0 ){\n    goto exit_rename_table;\n  }\n\n  /* figure out how many UTF-8 characters are in zName */\n  zTabName = pTab->zName;\n  nTabName = sqlite3Utf8CharLen(zTabName, -1);\n\n  /* Rewrite all CREATE TABLE, INDEX, TRIGGER or VIEW statements in\n  ** the schema to use the new table name.  */\n  sqlite3NestedParse(pParse, \n      \"UPDATE \\\"%w\\\".%s SET \"\n      \"sql = sqlite_rename_table(%Q, type, name, sql, %Q, %Q, %d) \"\n      \"WHERE (type!='index' OR tbl_name=%Q COLLATE nocase)\"\n      \"AND   name NOT LIKE 'sqlite_%%'\"\n      , zDb, MASTER_NAME, zDb, zTabName, zName, (iDb==1), zTabName\n  );\n\n  /* Update the tbl_name and name columns of the sqlite_master table\n  ** as required.  */\n  sqlite3NestedParse(pParse,\n      \"UPDATE %Q.%s SET \"\n          \"tbl_name = %Q, \"\n          \"name = CASE \"\n            \"WHEN type='table' THEN %Q \"\n            \"WHEN name LIKE 'sqlite_autoindex%%' AND type='index' THEN \"\n             \"'sqlite_autoindex_' || %Q || substr(name,%d+18) \"\n            \"ELSE name END \"\n      \"WHERE tbl_name=%Q COLLATE nocase AND \"\n          \"(type='table' OR type='index' OR type='trigger');\", \n      zDb, MASTER_NAME, \n      zName, zName, zName, \n      nTabName, zTabName\n  );\n\n#ifndef SQLITE_OMIT_AUTOINCREMENT\n  /* If the sqlite_sequence table exists in this database, then update \n  ** it with the new table name.\n  */\n  if( sqlite3FindTable(db, \"sqlite_sequence\", zDb) ){\n    sqlite3NestedParse(pParse,\n        \"UPDATE \\\"%w\\\".sqlite_sequence set name = %Q WHERE name = %Q\",\n        zDb, zName, pTab->zName);\n  }\n#endif\n\n  /* If the table being renamed is not itself part of the temp database,\n  ** edit view and trigger definitions within the temp database \n  ** as required.  */\n  if( iDb!=1 ){\n    sqlite3NestedParse(pParse, \n        \"UPDATE sqlite_temp_master SET \"\n            \"sql = sqlite_rename_table(%Q, type, name, sql, %Q, %Q, 1), \"\n            \"tbl_name = \"\n              \"CASE WHEN tbl_name=%Q COLLATE nocase AND \"\n              \"          sqlite_rename_test(%Q, sql, type, name, 1) \"\n              \"THEN %Q ELSE tbl_name END \"\n            \"WHERE type IN ('view', 'trigger')\"\n        , zDb, zTabName, zName, zTabName, zDb, zName);\n  }\n\n  /* If this is a virtual table, invoke the xRename() function if\n  ** one is defined. The xRename() callback will modify the names\n  ** of any resources used by the v-table implementation (including other\n  ** SQLite tables) that are identified by the name of the virtual table.\n  */\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n  if( pVTab ){\n    int i = ++pParse->nMem;\n    sqlite3VdbeLoadString(v, i, zName);\n    sqlite3VdbeAddOp4(v, OP_VRename, i, 0, 0,(const char*)pVTab, P4_VTAB);\n    sqlite3MayAbort(pParse);\n  }\n#endif\n\n  renameReloadSchema(pParse, iDb);\n  renameTestSchema(pParse, zDb, iDb==1);\n\nexit_rename_table:\n  sqlite3SrcListDelete(db, pSrc);\n  sqlite3DbFree(db, zName);\n  db->mDbFlags = savedDbFlags;\n}\n\n/*\n** This function is called after an \"ALTER TABLE ... ADD\" statement\n** has been parsed. Argument pColDef contains the text of the new\n** column definition.\n**\n** The Table structure pParse->pNewTable was extended to include\n** the new column during parsing.\n*/\nSQLITE_PRIVATE void sqlite3AlterFinishAddColumn(Parse *pParse, Token *pColDef){\n  Table *pNew;              /* Copy of pParse->pNewTable */\n  Table *pTab;              /* Table being altered */\n  int iDb;                  /* Database number */\n  const char *zDb;          /* Database name */\n  const char *zTab;         /* Table name */\n  char *zCol;               /* Null-terminated column definition */\n  Column *pCol;             /* The new column */\n  Expr *pDflt;              /* Default value for the new column */\n  sqlite3 *db;              /* The database connection; */\n  Vdbe *v;                  /* The prepared statement under construction */\n  int r1;                   /* Temporary registers */\n\n  db = pParse->db;\n  if( pParse->nErr || db->mallocFailed ) return;\n  pNew = pParse->pNewTable;\n  assert( pNew );\n\n  assert( sqlite3BtreeHoldsAllMutexes(db) );\n  iDb = sqlite3SchemaToIndex(db, pNew->pSchema);\n  zDb = db->aDb[iDb].zDbSName;\n  zTab = &pNew->zName[16];  /* Skip the \"sqlite_altertab_\" prefix on the name */\n  pCol = &pNew->aCol[pNew->nCol-1];\n  pDflt = pCol->pDflt;\n  pTab = sqlite3FindTable(db, zTab, zDb);\n  assert( pTab );\n\n#ifndef SQLITE_OMIT_AUTHORIZATION\n  /* Invoke the authorization callback. */\n  if( sqlite3AuthCheck(pParse, SQLITE_ALTER_TABLE, zDb, pTab->zName, 0) ){\n    return;\n  }\n#endif\n\n  /* If the default value for the new column was specified with a \n  ** literal NULL, then set pDflt to 0. This simplifies checking\n  ** for an SQL NULL default below.\n  */\n  assert( pDflt==0 || pDflt->op==TK_SPAN );\n  if( pDflt && pDflt->pLeft->op==TK_NULL ){\n    pDflt = 0;\n  }\n\n  /* Check that the new column is not specified as PRIMARY KEY or UNIQUE.\n  ** If there is a NOT NULL constraint, then the default value for the\n  ** column must not be NULL.\n  */\n  if( pCol->colFlags & COLFLAG_PRIMKEY ){\n    sqlite3ErrorMsg(pParse, \"Cannot add a PRIMARY KEY column\");\n    return;\n  }\n  if( pNew->pIndex ){\n    sqlite3ErrorMsg(pParse, \"Cannot add a UNIQUE column\");\n    return;\n  }\n  if( (db->flags&SQLITE_ForeignKeys) && pNew->pFKey && pDflt ){\n    sqlite3ErrorMsg(pParse, \n        \"Cannot add a REFERENCES column with non-NULL default value\");\n    return;\n  }\n  if( pCol->notNull && !pDflt ){\n    sqlite3ErrorMsg(pParse, \n        \"Cannot add a NOT NULL column with default value NULL\");\n    return;\n  }\n\n  /* Ensure the default expression is something that sqlite3ValueFromExpr()\n  ** can handle (i.e. not CURRENT_TIME etc.)\n  */\n  if( pDflt ){\n    sqlite3_value *pVal = 0;\n    int rc;\n    rc = sqlite3ValueFromExpr(db, pDflt, SQLITE_UTF8, SQLITE_AFF_BLOB, &pVal);\n    assert( rc==SQLITE_OK || rc==SQLITE_NOMEM );\n    if( rc!=SQLITE_OK ){\n      assert( db->mallocFailed == 1 );\n      return;\n    }\n    if( !pVal ){\n      sqlite3ErrorMsg(pParse, \"Cannot add a column with non-constant default\");\n      return;\n    }\n    sqlite3ValueFree(pVal);\n  }\n\n  /* Modify the CREATE TABLE statement. */\n  zCol = sqlite3DbStrNDup(db, (char*)pColDef->z, pColDef->n);\n  if( zCol ){\n    char *zEnd = &zCol[pColDef->n-1];\n    u32 savedDbFlags = db->mDbFlags;\n    while( zEnd>zCol && (*zEnd==';' || sqlite3Isspace(*zEnd)) ){\n      *zEnd-- = '\\0';\n    }\n    db->mDbFlags |= DBFLAG_PreferBuiltin;\n    sqlite3NestedParse(pParse, \n        \"UPDATE \\\"%w\\\".%s SET \"\n          \"sql = substr(sql,1,%d) || ', ' || %Q || substr(sql,%d) \"\n        \"WHERE type = 'table' AND name = %Q\", \n      zDb, MASTER_NAME, pNew->addColOffset, zCol, pNew->addColOffset+1,\n      zTab\n    );\n    sqlite3DbFree(db, zCol);\n    db->mDbFlags = savedDbFlags;\n  }\n\n  /* Make sure the schema version is at least 3.  But do not upgrade\n  ** from less than 3 to 4, as that will corrupt any preexisting DESC\n  ** index.\n  */\n  v = sqlite3GetVdbe(pParse);\n  if( v ){\n    r1 = sqlite3GetTempReg(pParse);\n    sqlite3VdbeAddOp3(v, OP_ReadCookie, iDb, r1, BTREE_FILE_FORMAT);\n    sqlite3VdbeUsesBtree(v, iDb);\n    sqlite3VdbeAddOp2(v, OP_AddImm, r1, -2);\n    sqlite3VdbeAddOp2(v, OP_IfPos, r1, sqlite3VdbeCurrentAddr(v)+2);\n    VdbeCoverage(v);\n    sqlite3VdbeAddOp3(v, OP_SetCookie, iDb, BTREE_FILE_FORMAT, 3);\n    sqlite3ReleaseTempReg(pParse, r1);\n  }\n\n  /* Reload the table definition */\n  renameReloadSchema(pParse, iDb);\n}\n\n/*\n** This function is called by the parser after the table-name in\n** an \"ALTER TABLE <table-name> ADD\" statement is parsed. Argument \n** pSrc is the full-name of the table being altered.\n**\n** This routine makes a (partial) copy of the Table structure\n** for the table being altered and sets Parse.pNewTable to point\n** to it. Routines called by the parser as the column definition\n** is parsed (i.e. sqlite3AddColumn()) add the new Column data to \n** the copy. The copy of the Table structure is deleted by tokenize.c \n** after parsing is finished.\n**\n** Routine sqlite3AlterFinishAddColumn() will be called to complete\n** coding the \"ALTER TABLE ... ADD\" statement.\n*/\nSQLITE_PRIVATE void sqlite3AlterBeginAddColumn(Parse *pParse, SrcList *pSrc){\n  Table *pNew;\n  Table *pTab;\n  int iDb;\n  int i;\n  int nAlloc;\n  sqlite3 *db = pParse->db;\n\n  /* Look up the table being altered. */\n  assert( pParse->pNewTable==0 );\n  assert( sqlite3BtreeHoldsAllMutexes(db) );\n  if( db->mallocFailed ) goto exit_begin_add_column;\n  pTab = sqlite3LocateTableItem(pParse, 0, &pSrc->a[0]);\n  if( !pTab ) goto exit_begin_add_column;\n\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n  if( IsVirtual(pTab) ){\n    sqlite3ErrorMsg(pParse, \"virtual tables may not be altered\");\n    goto exit_begin_add_column;\n  }\n#endif\n\n  /* Make sure this is not an attempt to ALTER a view. */\n  if( pTab->pSelect ){\n    sqlite3ErrorMsg(pParse, \"Cannot add a column to a view\");\n    goto exit_begin_add_column;\n  }\n  if( SQLITE_OK!=isAlterableTable(pParse, pTab) ){\n    goto exit_begin_add_column;\n  }\n\n  assert( pTab->addColOffset>0 );\n  iDb = sqlite3SchemaToIndex(db, pTab->pSchema);\n\n  /* Put a copy of the Table struct in Parse.pNewTable for the\n  ** sqlite3AddColumn() function and friends to modify.  But modify\n  ** the name by adding an \"sqlite_altertab_\" prefix.  By adding this\n  ** prefix, we insure that the name will not collide with an existing\n  ** table because user table are not allowed to have the \"sqlite_\"\n  ** prefix on their name.\n  */\n  pNew = (Table*)sqlite3DbMallocZero(db, sizeof(Table));\n  if( !pNew ) goto exit_begin_add_column;\n  pParse->pNewTable = pNew;\n  pNew->nTabRef = 1;\n  pNew->nCol = pTab->nCol;\n  assert( pNew->nCol>0 );\n  nAlloc = (((pNew->nCol-1)/8)*8)+8;\n  assert( nAlloc>=pNew->nCol && nAlloc%8==0 && nAlloc-pNew->nCol<8 );\n  pNew->aCol = (Column*)sqlite3DbMallocZero(db, sizeof(Column)*nAlloc);\n  pNew->zName = sqlite3MPrintf(db, \"sqlite_altertab_%s\", pTab->zName);\n  if( !pNew->aCol || !pNew->zName ){\n    assert( db->mallocFailed );\n    goto exit_begin_add_column;\n  }\n  memcpy(pNew->aCol, pTab->aCol, sizeof(Column)*pNew->nCol);\n  for(i=0; i<pNew->nCol; i++){\n    Column *pCol = &pNew->aCol[i];\n    pCol->zName = sqlite3DbStrDup(db, pCol->zName);\n    pCol->zColl = 0;\n    pCol->pDflt = 0;\n  }\n  pNew->pSchema = db->aDb[iDb].pSchema;\n  pNew->addColOffset = pTab->addColOffset;\n  pNew->nTabRef = 1;\n\nexit_begin_add_column:\n  sqlite3SrcListDelete(db, pSrc);\n  return;\n}\n\n/*\n** Parameter pTab is the subject of an ALTER TABLE ... RENAME COLUMN\n** command. This function checks if the table is a view or virtual\n** table (columns of views or virtual tables may not be renamed). If so,\n** it loads an error message into pParse and returns non-zero.\n**\n** Or, if pTab is not a view or virtual table, zero is returned.\n*/\n#if !defined(SQLITE_OMIT_VIEW) || !defined(SQLITE_OMIT_VIRTUALTABLE)\nstatic int isRealTable(Parse *pParse, Table *pTab){\n  const char *zType = 0;\n#ifndef SQLITE_OMIT_VIEW\n  if( pTab->pSelect ){\n    zType = \"view\";\n  }\n#endif\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n  if( IsVirtual(pTab) ){\n    zType = \"virtual table\";\n  }\n#endif\n  if( zType ){\n    sqlite3ErrorMsg(\n        pParse, \"cannot rename columns of %s \\\"%s\\\"\", zType, pTab->zName\n    );\n    return 1;\n  }\n  return 0;\n}\n#else /* !defined(SQLITE_OMIT_VIEW) || !defined(SQLITE_OMIT_VIRTUALTABLE) */\n# define isRealTable(x,y) (0)\n#endif\n\n/*\n** Handles the following parser reduction:\n**\n**  cmd ::= ALTER TABLE pSrc RENAME COLUMN pOld TO pNew\n*/\nSQLITE_PRIVATE void sqlite3AlterRenameColumn(\n  Parse *pParse,                  /* Parsing context */\n  SrcList *pSrc,                  /* Table being altered.  pSrc->nSrc==1 */\n  Token *pOld,                    /* Name of column being changed */\n  Token *pNew                     /* New column name */\n){\n  sqlite3 *db = pParse->db;       /* Database connection */\n  Table *pTab;                    /* Table being updated */\n  int iCol;                       /* Index of column being renamed */\n  char *zOld = 0;                 /* Old column name */\n  char *zNew = 0;                 /* New column name */\n  const char *zDb;                /* Name of schema containing the table */\n  int iSchema;                    /* Index of the schema */\n  int bQuote;                     /* True to quote the new name */\n\n  /* Locate the table to be altered */\n  pTab = sqlite3LocateTableItem(pParse, 0, &pSrc->a[0]);\n  if( !pTab ) goto exit_rename_column;\n\n  /* Cannot alter a system table */\n  if( SQLITE_OK!=isAlterableTable(pParse, pTab) ) goto exit_rename_column;\n  if( SQLITE_OK!=isRealTable(pParse, pTab) ) goto exit_rename_column;\n\n  /* Which schema holds the table to be altered */  \n  iSchema = sqlite3SchemaToIndex(db, pTab->pSchema);\n  assert( iSchema>=0 );\n  zDb = db->aDb[iSchema].zDbSName;\n\n#ifndef SQLITE_OMIT_AUTHORIZATION\n  /* Invoke the authorization callback. */\n  if( sqlite3AuthCheck(pParse, SQLITE_ALTER_TABLE, zDb, pTab->zName, 0) ){\n    goto exit_rename_column;\n  }\n#endif\n\n  /* Make sure the old name really is a column name in the table to be\n  ** altered.  Set iCol to be the index of the column being renamed */\n  zOld = sqlite3NameFromToken(db, pOld);\n  if( !zOld ) goto exit_rename_column;\n  for(iCol=0; iCol<pTab->nCol; iCol++){\n    if( 0==sqlite3StrICmp(pTab->aCol[iCol].zName, zOld) ) break;\n  }\n  if( iCol==pTab->nCol ){\n    sqlite3ErrorMsg(pParse, \"no such column: \\\"%s\\\"\", zOld);\n    goto exit_rename_column;\n  }\n\n  /* Do the rename operation using a recursive UPDATE statement that\n  ** uses the sqlite_rename_column() SQL function to compute the new\n  ** CREATE statement text for the sqlite_master table.\n  */\n  zNew = sqlite3NameFromToken(db, pNew);\n  if( !zNew ) goto exit_rename_column;\n  assert( pNew->n>0 );\n  bQuote = sqlite3Isquote(pNew->z[0]);\n  sqlite3NestedParse(pParse, \n      \"UPDATE \\\"%w\\\".%s SET \"\n      \"sql = sqlite_rename_column(sql, type, name, %Q, %Q, %d, %Q, %d, %d) \"\n      \"WHERE name NOT LIKE 'sqlite_%%' AND (type != 'index' OR tbl_name = %Q)\"\n      \" AND sql NOT LIKE 'create virtual%%'\",\n      zDb, MASTER_NAME, \n      zDb, pTab->zName, iCol, zNew, bQuote, iSchema==1,\n      pTab->zName\n  );\n\n  sqlite3NestedParse(pParse, \n      \"UPDATE temp.%s SET \"\n      \"sql = sqlite_rename_column(sql, type, name, %Q, %Q, %d, %Q, %d, 1) \"\n      \"WHERE type IN ('trigger', 'view')\",\n      MASTER_NAME, \n      zDb, pTab->zName, iCol, zNew, bQuote\n  );\n\n  /* Drop and reload the database schema. */\n  renameReloadSchema(pParse, iSchema);\n  renameTestSchema(pParse, zDb, iSchema==1);\n\n exit_rename_column:\n  sqlite3SrcListDelete(db, pSrc);\n  sqlite3DbFree(db, zOld);\n  sqlite3DbFree(db, zNew);\n  return;\n}\n\n/*\n** Each RenameToken object maps an element of the parse tree into\n** the token that generated that element.  The parse tree element\n** might be one of:\n**\n**     *  A pointer to an Expr that represents an ID\n**     *  The name of a table column in Column.zName\n**\n** A list of RenameToken objects can be constructed during parsing.\n** Each new object is created by sqlite3RenameTokenMap().\n** As the parse tree is transformed, the sqlite3RenameTokenRemap()\n** routine is used to keep the mapping current.\n**\n** After the parse finishes, renameTokenFind() routine can be used\n** to look up the actual token value that created some element in\n** the parse tree.\n*/\nstruct RenameToken {\n  void *p;               /* Parse tree element created by token t */\n  Token t;               /* The token that created parse tree element p */\n  RenameToken *pNext;    /* Next is a list of all RenameToken objects */\n};\n\n/*\n** The context of an ALTER TABLE RENAME COLUMN operation that gets passed\n** down into the Walker.\n*/\ntypedef struct RenameCtx RenameCtx;\nstruct RenameCtx {\n  RenameToken *pList;             /* List of tokens to overwrite */\n  int nList;                      /* Number of tokens in pList */\n  int iCol;                       /* Index of column being renamed */\n  Table *pTab;                    /* Table being ALTERed */ \n  const char *zOld;               /* Old column name */\n};\n\n#ifdef SQLITE_DEBUG\n/*\n** This function is only for debugging. It performs two tasks:\n**\n**   1. Checks that pointer pPtr does not already appear in the \n**      rename-token list.\n**\n**   2. Dereferences each pointer in the rename-token list.\n**\n** The second is most effective when debugging under valgrind or\n** address-sanitizer or similar. If any of these pointers no longer \n** point to valid objects, an exception is raised by the memory-checking \n** tool.\n**\n** The point of this is to prevent comparisons of invalid pointer values.\n** Even though this always seems to work, it is undefined according to the\n** C standard. Example of undefined comparison:\n**\n**     sqlite3_free(x);\n**     if( x==y ) ...\n**\n** Technically, as x no longer points into a valid object or to the byte\n** following a valid object, it may not be used in comparison operations.\n*/\nstatic void renameTokenCheckAll(Parse *pParse, void *pPtr){\n  if( pParse->nErr==0 && pParse->db->mallocFailed==0 ){\n    RenameToken *p;\n    u8 i = 0;\n    for(p=pParse->pRename; p; p=p->pNext){\n      if( p->p ){\n        assert( p->p!=pPtr );\n        i += *(u8*)(p->p);\n      }\n    }\n  }\n}\n#else\n# define renameTokenCheckAll(x,y)\n#endif\n\n/*\n** Remember that the parser tree element pPtr was created using\n** the token pToken.\n**\n** In other words, construct a new RenameToken object and add it\n** to the list of RenameToken objects currently being built up\n** in pParse->pRename.\n**\n** The pPtr argument is returned so that this routine can be used\n** with tail recursion in tokenExpr() routine, for a small performance\n** improvement.\n*/\nSQLITE_PRIVATE void *sqlite3RenameTokenMap(Parse *pParse, void *pPtr, Token *pToken){\n  RenameToken *pNew;\n  assert( pPtr || pParse->db->mallocFailed );\n  renameTokenCheckAll(pParse, pPtr);\n  pNew = sqlite3DbMallocZero(pParse->db, sizeof(RenameToken));\n  if( pNew ){\n    pNew->p = pPtr;\n    pNew->t = *pToken;\n    pNew->pNext = pParse->pRename;\n    pParse->pRename = pNew;\n  }\n\n  return pPtr;\n}\n\n/*\n** It is assumed that there is already a RenameToken object associated\n** with parse tree element pFrom. This function remaps the associated token\n** to parse tree element pTo.\n*/\nSQLITE_PRIVATE void sqlite3RenameTokenRemap(Parse *pParse, void *pTo, void *pFrom){\n  RenameToken *p;\n  renameTokenCheckAll(pParse, pTo);\n  for(p=pParse->pRename; p; p=p->pNext){\n    if( p->p==pFrom ){\n      p->p = pTo;\n      break;\n    }\n  }\n}\n\n/*\n** Walker callback used by sqlite3RenameExprUnmap().\n*/\nstatic int renameUnmapExprCb(Walker *pWalker, Expr *pExpr){\n  Parse *pParse = pWalker->pParse;\n  sqlite3RenameTokenRemap(pParse, 0, (void*)pExpr);\n  return WRC_Continue;\n}\n\n/*\n** Remove all nodes that are part of expression pExpr from the rename list.\n*/\nSQLITE_PRIVATE void sqlite3RenameExprUnmap(Parse *pParse, Expr *pExpr){\n  Walker sWalker;\n  memset(&sWalker, 0, sizeof(Walker));\n  sWalker.pParse = pParse;\n  sWalker.xExprCallback = renameUnmapExprCb;\n  sqlite3WalkExpr(&sWalker, pExpr);\n}\n\n/*\n** Remove all nodes that are part of expression-list pEList from the \n** rename list.\n*/\nSQLITE_PRIVATE void sqlite3RenameExprlistUnmap(Parse *pParse, ExprList *pEList){\n  if( pEList ){\n    int i;\n    Walker sWalker;\n    memset(&sWalker, 0, sizeof(Walker));\n    sWalker.pParse = pParse;\n    sWalker.xExprCallback = renameUnmapExprCb;\n    sqlite3WalkExprList(&sWalker, pEList);\n    for(i=0; i<pEList->nExpr; i++){\n      sqlite3RenameTokenRemap(pParse, 0, (void*)pEList->a[i].zName);\n    }\n  }\n}\n\n/*\n** Free the list of RenameToken objects given in the second argument\n*/\nstatic void renameTokenFree(sqlite3 *db, RenameToken *pToken){\n  RenameToken *pNext;\n  RenameToken *p;\n  for(p=pToken; p; p=pNext){\n    pNext = p->pNext;\n    sqlite3DbFree(db, p);\n  }\n}\n\n/*\n** Search the Parse object passed as the first argument for a RenameToken\n** object associated with parse tree element pPtr. If found, remove it\n** from the Parse object and add it to the list maintained by the\n** RenameCtx object passed as the second argument.\n*/\nstatic void renameTokenFind(Parse *pParse, struct RenameCtx *pCtx, void *pPtr){\n  RenameToken **pp;\n  assert( pPtr!=0 );\n  for(pp=&pParse->pRename; (*pp); pp=&(*pp)->pNext){\n    if( (*pp)->p==pPtr ){\n      RenameToken *pToken = *pp;\n      *pp = pToken->pNext;\n      pToken->pNext = pCtx->pList;\n      pCtx->pList = pToken;\n      pCtx->nList++;\n      break;\n    }\n  }\n}\n\n/*\n** Iterate through the Select objects that are part of WITH clauses attached\n** to select statement pSelect.\n*/\nstatic void renameWalkWith(Walker *pWalker, Select *pSelect){\n  if( pSelect->pWith ){\n    int i;\n    for(i=0; i<pSelect->pWith->nCte; i++){\n      Select *p = pSelect->pWith->a[i].pSelect;\n      NameContext sNC;\n      memset(&sNC, 0, sizeof(sNC));\n      sNC.pParse = pWalker->pParse;\n      sqlite3SelectPrep(sNC.pParse, p, &sNC);\n      sqlite3WalkSelect(pWalker, p);\n    }\n  }\n}\n\n/*\n** This is a Walker select callback. It does nothing. It is only required\n** because without a dummy callback, sqlite3WalkExpr() and similar do not\n** descend into sub-select statements.\n*/\nstatic int renameColumnSelectCb(Walker *pWalker, Select *p){\n  renameWalkWith(pWalker, p);\n  return WRC_Continue;\n}\n\n/*\n** This is a Walker expression callback.\n**\n** For every TK_COLUMN node in the expression tree, search to see\n** if the column being references is the column being renamed by an\n** ALTER TABLE statement.  If it is, then attach its associated\n** RenameToken object to the list of RenameToken objects being\n** constructed in RenameCtx object at pWalker->u.pRename.\n*/\nstatic int renameColumnExprCb(Walker *pWalker, Expr *pExpr){\n  RenameCtx *p = pWalker->u.pRename;\n  if( pExpr->op==TK_TRIGGER \n   && pExpr->iColumn==p->iCol \n   && pWalker->pParse->pTriggerTab==p->pTab\n  ){\n    renameTokenFind(pWalker->pParse, p, (void*)pExpr);\n  }else if( pExpr->op==TK_COLUMN \n   && pExpr->iColumn==p->iCol \n   && p->pTab==pExpr->y.pTab\n  ){\n    renameTokenFind(pWalker->pParse, p, (void*)pExpr);\n  }\n  return WRC_Continue;\n}\n\n/*\n** The RenameCtx contains a list of tokens that reference a column that\n** is being renamed by an ALTER TABLE statement.  Return the \"last\"\n** RenameToken in the RenameCtx and remove that RenameToken from the\n** RenameContext.  \"Last\" means the last RenameToken encountered when\n** the input SQL is parsed from left to right.  Repeated calls to this routine\n** return all column name tokens in the order that they are encountered\n** in the SQL statement.\n*/\nstatic RenameToken *renameColumnTokenNext(RenameCtx *pCtx){\n  RenameToken *pBest = pCtx->pList;\n  RenameToken *pToken;\n  RenameToken **pp;\n\n  for(pToken=pBest->pNext; pToken; pToken=pToken->pNext){\n    if( pToken->t.z>pBest->t.z ) pBest = pToken;\n  }\n  for(pp=&pCtx->pList; *pp!=pBest; pp=&(*pp)->pNext);\n  *pp = pBest->pNext;\n\n  return pBest;\n}\n\n/*\n** An error occured while parsing or otherwise processing a database\n** object (either pParse->pNewTable, pNewIndex or pNewTrigger) as part of an\n** ALTER TABLE RENAME COLUMN program. The error message emitted by the\n** sub-routine is currently stored in pParse->zErrMsg. This function\n** adds context to the error message and then stores it in pCtx.\n*/\nstatic void renameColumnParseError(\n  sqlite3_context *pCtx, \n  int bPost,\n  sqlite3_value *pType,\n  sqlite3_value *pObject,\n  Parse *pParse\n){\n  const char *zT = (const char*)sqlite3_value_text(pType);\n  const char *zN = (const char*)sqlite3_value_text(pObject);\n  char *zErr;\n\n  zErr = sqlite3_mprintf(\"error in %s %s%s: %s\", \n      zT, zN, (bPost ? \" after rename\" : \"\"),\n      pParse->zErrMsg\n  );\n  sqlite3_result_error(pCtx, zErr, -1);\n  sqlite3_free(zErr);\n}\n\n/*\n** For each name in the the expression-list pEList (i.e. each\n** pEList->a[i].zName) that matches the string in zOld, extract the \n** corresponding rename-token from Parse object pParse and add it\n** to the RenameCtx pCtx.\n*/\nstatic void renameColumnElistNames(\n  Parse *pParse, \n  RenameCtx *pCtx, \n  ExprList *pEList, \n  const char *zOld\n){\n  if( pEList ){\n    int i;\n    for(i=0; i<pEList->nExpr; i++){\n      char *zName = pEList->a[i].zName;\n      if( 0==sqlite3_stricmp(zName, zOld) ){\n        renameTokenFind(pParse, pCtx, (void*)zName);\n      }\n    }\n  }\n}\n\n/*\n** For each name in the the id-list pIdList (i.e. each pIdList->a[i].zName) \n** that matches the string in zOld, extract the corresponding rename-token \n** from Parse object pParse and add it to the RenameCtx pCtx.\n*/\nstatic void renameColumnIdlistNames(\n  Parse *pParse, \n  RenameCtx *pCtx, \n  IdList *pIdList, \n  const char *zOld\n){\n  if( pIdList ){\n    int i;\n    for(i=0; i<pIdList->nId; i++){\n      char *zName = pIdList->a[i].zName;\n      if( 0==sqlite3_stricmp(zName, zOld) ){\n        renameTokenFind(pParse, pCtx, (void*)zName);\n      }\n    }\n  }\n}\n\n/*\n** Parse the SQL statement zSql using Parse object (*p). The Parse object\n** is initialized by this function before it is used.\n*/\nstatic int renameParseSql(\n  Parse *p,                       /* Memory to use for Parse object */\n  const char *zDb,                /* Name of schema SQL belongs to */\n  int bTable,                     /* 1 -> RENAME TABLE, 0 -> RENAME COLUMN */\n  sqlite3 *db,                    /* Database handle */\n  const char *zSql,               /* SQL to parse */\n  int bTemp                       /* True if SQL is from temp schema */\n){\n  int rc;\n  char *zErr = 0;\n\n  db->init.iDb = bTemp ? 1 : sqlite3FindDbName(db, zDb);\n\n  /* Parse the SQL statement passed as the first argument. If no error\n  ** occurs and the parse does not result in a new table, index or\n  ** trigger object, the database must be corrupt. */\n  memset(p, 0, sizeof(Parse));\n  p->eParseMode = (bTable ? PARSE_MODE_RENAME_TABLE : PARSE_MODE_RENAME_COLUMN);\n  p->db = db;\n  p->nQueryLoop = 1;\n  rc = sqlite3RunParser(p, zSql, &zErr);\n  assert( p->zErrMsg==0 );\n  assert( rc!=SQLITE_OK || zErr==0 );\n  p->zErrMsg = zErr;\n  if( db->mallocFailed ) rc = SQLITE_NOMEM;\n  if( rc==SQLITE_OK \n   && p->pNewTable==0 && p->pNewIndex==0 && p->pNewTrigger==0 \n  ){\n    rc = SQLITE_CORRUPT_BKPT;\n  }\n\n#ifdef SQLITE_DEBUG\n  /* Ensure that all mappings in the Parse.pRename list really do map to\n  ** a part of the input string.  */\n  if( rc==SQLITE_OK ){\n    int nSql = sqlite3Strlen30(zSql);\n    RenameToken *pToken;\n    for(pToken=p->pRename; pToken; pToken=pToken->pNext){\n      assert( pToken->t.z>=zSql && &pToken->t.z[pToken->t.n]<=&zSql[nSql] );\n    }\n  }\n#endif\n\n  db->init.iDb = 0;\n  return rc;\n}\n\n/*\n** This function edits SQL statement zSql, replacing each token identified\n** by the linked list pRename with the text of zNew. If argument bQuote is\n** true, then zNew is always quoted first. If no error occurs, the result\n** is loaded into context object pCtx as the result.\n**\n** Or, if an error occurs (i.e. an OOM condition), an error is left in\n** pCtx and an SQLite error code returned.\n*/\nstatic int renameEditSql(\n  sqlite3_context *pCtx,          /* Return result here */\n  RenameCtx *pRename,             /* Rename context */\n  const char *zSql,               /* SQL statement to edit */\n  const char *zNew,               /* New token text */\n  int bQuote                      /* True to always quote token */\n){\n  int nNew = sqlite3Strlen30(zNew);\n  int nSql = sqlite3Strlen30(zSql);\n  sqlite3 *db = sqlite3_context_db_handle(pCtx);\n  int rc = SQLITE_OK;\n  char *zQuot;\n  char *zOut;\n  int nQuot;\n\n  /* Set zQuot to point to a buffer containing a quoted copy of the \n  ** identifier zNew. If the corresponding identifier in the original \n  ** ALTER TABLE statement was quoted (bQuote==1), then set zNew to\n  ** point to zQuot so that all substitutions are made using the\n  ** quoted version of the new column name.  */\n  zQuot = sqlite3MPrintf(db, \"\\\"%w\\\"\", zNew);\n  if( zQuot==0 ){\n    return SQLITE_NOMEM;\n  }else{\n    nQuot = sqlite3Strlen30(zQuot);\n  }\n  if( bQuote ){\n    zNew = zQuot;\n    nNew = nQuot;\n  }\n\n  /* At this point pRename->pList contains a list of RenameToken objects\n  ** corresponding to all tokens in the input SQL that must be replaced\n  ** with the new column name. All that remains is to construct and\n  ** return the edited SQL string. */\n  assert( nQuot>=nNew );\n  zOut = sqlite3DbMallocZero(db, nSql + pRename->nList*nQuot + 1);\n  if( zOut ){\n    int nOut = nSql;\n    memcpy(zOut, zSql, nSql);\n    while( pRename->pList ){\n      int iOff;                   /* Offset of token to replace in zOut */\n      RenameToken *pBest = renameColumnTokenNext(pRename);\n\n      u32 nReplace;\n      const char *zReplace;\n      if( sqlite3IsIdChar(*pBest->t.z) ){\n        nReplace = nNew;\n        zReplace = zNew;\n      }else{\n        nReplace = nQuot;\n        zReplace = zQuot;\n      }\n\n      iOff = pBest->t.z - zSql;\n      if( pBest->t.n!=nReplace ){\n        memmove(&zOut[iOff + nReplace], &zOut[iOff + pBest->t.n], \n            nOut - (iOff + pBest->t.n)\n        );\n        nOut += nReplace - pBest->t.n;\n        zOut[nOut] = '\\0';\n      }\n      memcpy(&zOut[iOff], zReplace, nReplace);\n      sqlite3DbFree(db, pBest);\n    }\n\n    sqlite3_result_text(pCtx, zOut, -1, SQLITE_TRANSIENT);\n    sqlite3DbFree(db, zOut);\n  }else{\n    rc = SQLITE_NOMEM;\n  }\n\n  sqlite3_free(zQuot);\n  return rc;\n}\n\n/*\n** Resolve all symbols in the trigger at pParse->pNewTrigger, assuming\n** it was read from the schema of database zDb. Return SQLITE_OK if \n** successful. Otherwise, return an SQLite error code and leave an error\n** message in the Parse object.\n*/\nstatic int renameResolveTrigger(Parse *pParse, const char *zDb){\n  sqlite3 *db = pParse->db;\n  Trigger *pNew = pParse->pNewTrigger;\n  TriggerStep *pStep;\n  NameContext sNC;\n  int rc = SQLITE_OK;\n\n  memset(&sNC, 0, sizeof(sNC));\n  sNC.pParse = pParse;\n  assert( pNew->pTabSchema );\n  pParse->pTriggerTab = sqlite3FindTable(db, pNew->table, \n      db->aDb[sqlite3SchemaToIndex(db, pNew->pTabSchema)].zDbSName\n  );\n  pParse->eTriggerOp = pNew->op;\n  /* ALWAYS() because if the table of the trigger does not exist, the\n  ** error would have been hit before this point */\n  if( ALWAYS(pParse->pTriggerTab) ){\n    rc = sqlite3ViewGetColumnNames(pParse, pParse->pTriggerTab);\n  }\n\n  /* Resolve symbols in WHEN clause */\n  if( rc==SQLITE_OK && pNew->pWhen ){\n    rc = sqlite3ResolveExprNames(&sNC, pNew->pWhen);\n  }\n\n  for(pStep=pNew->step_list; rc==SQLITE_OK && pStep; pStep=pStep->pNext){\n    if( pStep->pSelect ){\n      sqlite3SelectPrep(pParse, pStep->pSelect, &sNC);\n      if( pParse->nErr ) rc = pParse->rc;\n    }\n    if( rc==SQLITE_OK && pStep->zTarget ){\n      Table *pTarget = sqlite3LocateTable(pParse, 0, pStep->zTarget, zDb);\n      if( pTarget==0 ){\n        rc = SQLITE_ERROR;\n      }else if( SQLITE_OK==(rc = sqlite3ViewGetColumnNames(pParse, pTarget)) ){\n        SrcList sSrc;\n        memset(&sSrc, 0, sizeof(sSrc));\n        sSrc.nSrc = 1;\n        sSrc.a[0].zName = pStep->zTarget;\n        sSrc.a[0].pTab = pTarget;\n        sNC.pSrcList = &sSrc;\n        if( pStep->pWhere ){\n          rc = sqlite3ResolveExprNames(&sNC, pStep->pWhere);\n        }\n        if( rc==SQLITE_OK ){\n          rc = sqlite3ResolveExprListNames(&sNC, pStep->pExprList);\n        }\n        assert( !pStep->pUpsert || (!pStep->pWhere && !pStep->pExprList) );\n        if( pStep->pUpsert ){\n          Upsert *pUpsert = pStep->pUpsert;\n          assert( rc==SQLITE_OK );\n          pUpsert->pUpsertSrc = &sSrc;\n          sNC.uNC.pUpsert = pUpsert;\n          sNC.ncFlags = NC_UUpsert;\n          rc = sqlite3ResolveExprListNames(&sNC, pUpsert->pUpsertTarget);\n          if( rc==SQLITE_OK ){\n            ExprList *pUpsertSet = pUpsert->pUpsertSet;\n            rc = sqlite3ResolveExprListNames(&sNC, pUpsertSet);\n          }\n          if( rc==SQLITE_OK ){\n            rc = sqlite3ResolveExprNames(&sNC, pUpsert->pUpsertWhere);\n          }\n          if( rc==SQLITE_OK ){\n            rc = sqlite3ResolveExprNames(&sNC, pUpsert->pUpsertTargetWhere);\n          }\n          sNC.ncFlags = 0;\n        }\n        sNC.pSrcList = 0;\n      }\n    }\n  }\n  return rc;\n}\n\n/*\n** Invoke sqlite3WalkExpr() or sqlite3WalkSelect() on all Select or Expr\n** objects that are part of the trigger passed as the second argument.\n*/\nstatic void renameWalkTrigger(Walker *pWalker, Trigger *pTrigger){\n  TriggerStep *pStep;\n\n  /* Find tokens to edit in WHEN clause */\n  sqlite3WalkExpr(pWalker, pTrigger->pWhen);\n\n  /* Find tokens to edit in trigger steps */\n  for(pStep=pTrigger->step_list; pStep; pStep=pStep->pNext){\n    sqlite3WalkSelect(pWalker, pStep->pSelect);\n    sqlite3WalkExpr(pWalker, pStep->pWhere);\n    sqlite3WalkExprList(pWalker, pStep->pExprList);\n    if( pStep->pUpsert ){\n      Upsert *pUpsert = pStep->pUpsert;\n      sqlite3WalkExprList(pWalker, pUpsert->pUpsertTarget);\n      sqlite3WalkExprList(pWalker, pUpsert->pUpsertSet);\n      sqlite3WalkExpr(pWalker, pUpsert->pUpsertWhere);\n      sqlite3WalkExpr(pWalker, pUpsert->pUpsertTargetWhere);\n    }\n  }\n}\n\n/*\n** Free the contents of Parse object (*pParse). Do not free the memory\n** occupied by the Parse object itself.\n*/\nstatic void renameParseCleanup(Parse *pParse){\n  sqlite3 *db = pParse->db;\n  Index *pIdx;\n  if( pParse->pVdbe ){\n    sqlite3VdbeFinalize(pParse->pVdbe);\n  }\n  sqlite3DeleteTable(db, pParse->pNewTable);\n  while( (pIdx = pParse->pNewIndex)!=0 ){\n    pParse->pNewIndex = pIdx->pNext;\n    sqlite3FreeIndex(db, pIdx);\n  }\n  sqlite3DeleteTrigger(db, pParse->pNewTrigger);\n  sqlite3DbFree(db, pParse->zErrMsg);\n  renameTokenFree(db, pParse->pRename);\n  sqlite3ParserReset(pParse);\n}\n\n/*\n** SQL function:\n**\n**     sqlite_rename_column(zSql, iCol, bQuote, zNew, zTable, zOld)\n**\n**   0. zSql:     SQL statement to rewrite\n**   1. type:     Type of object (\"table\", \"view\" etc.)\n**   2. object:   Name of object\n**   3. Database: Database name (e.g. \"main\")\n**   4. Table:    Table name\n**   5. iCol:     Index of column to rename\n**   6. zNew:     New column name\n**   7. bQuote:   Non-zero if the new column name should be quoted.\n**   8. bTemp:    True if zSql comes from temp schema\n**\n** Do a column rename operation on the CREATE statement given in zSql.\n** The iCol-th column (left-most is 0) of table zTable is renamed from zCol\n** into zNew.  The name should be quoted if bQuote is true.\n**\n** This function is used internally by the ALTER TABLE RENAME COLUMN command.\n** It is only accessible to SQL created using sqlite3NestedParse().  It is\n** not reachable from ordinary SQL passed into sqlite3_prepare().\n*/\nstatic void renameColumnFunc(\n  sqlite3_context *context,\n  int NotUsed,\n  sqlite3_value **argv\n){\n  sqlite3 *db = sqlite3_context_db_handle(context);\n  RenameCtx sCtx;\n  const char *zSql = (const char*)sqlite3_value_text(argv[0]);\n  const char *zDb = (const char*)sqlite3_value_text(argv[3]);\n  const char *zTable = (const char*)sqlite3_value_text(argv[4]);\n  int iCol = sqlite3_value_int(argv[5]);\n  const char *zNew = (const char*)sqlite3_value_text(argv[6]);\n  int bQuote = sqlite3_value_int(argv[7]);\n  int bTemp = sqlite3_value_int(argv[8]);\n  const char *zOld;\n  int rc;\n  Parse sParse;\n  Walker sWalker;\n  Index *pIdx;\n  int i;\n  Table *pTab;\n#ifndef SQLITE_OMIT_AUTHORIZATION\n  sqlite3_xauth xAuth = db->xAuth;\n#endif\n\n  UNUSED_PARAMETER(NotUsed);\n  if( zSql==0 ) return;\n  if( zTable==0 ) return;\n  if( zNew==0 ) return;\n  if( iCol<0 ) return;\n  sqlite3BtreeEnterAll(db);\n  pTab = sqlite3FindTable(db, zTable, zDb);\n  if( pTab==0 || iCol>=pTab->nCol ){\n    sqlite3BtreeLeaveAll(db);\n    return;\n  }\n  zOld = pTab->aCol[iCol].zName;\n  memset(&sCtx, 0, sizeof(sCtx));\n  sCtx.iCol = ((iCol==pTab->iPKey) ? -1 : iCol);\n\n#ifndef SQLITE_OMIT_AUTHORIZATION\n  db->xAuth = 0;\n#endif\n  rc = renameParseSql(&sParse, zDb, 0, db, zSql, bTemp);\n\n  /* Find tokens that need to be replaced. */\n  memset(&sWalker, 0, sizeof(Walker));\n  sWalker.pParse = &sParse;\n  sWalker.xExprCallback = renameColumnExprCb;\n  sWalker.xSelectCallback = renameColumnSelectCb;\n  sWalker.u.pRename = &sCtx;\n\n  sCtx.pTab = pTab;\n  if( rc!=SQLITE_OK ) goto renameColumnFunc_done;\n  if( sParse.pNewTable ){\n    Select *pSelect = sParse.pNewTable->pSelect;\n    if( pSelect ){\n      sParse.rc = SQLITE_OK;\n      sqlite3SelectPrep(&sParse, sParse.pNewTable->pSelect, 0);\n      rc = (db->mallocFailed ? SQLITE_NOMEM : sParse.rc);\n      if( rc==SQLITE_OK ){\n        sqlite3WalkSelect(&sWalker, pSelect);\n      }\n      if( rc!=SQLITE_OK ) goto renameColumnFunc_done;\n    }else{\n      /* A regular table */\n      int bFKOnly = sqlite3_stricmp(zTable, sParse.pNewTable->zName);\n      FKey *pFKey;\n      assert( sParse.pNewTable->pSelect==0 );\n      sCtx.pTab = sParse.pNewTable;\n      if( bFKOnly==0 ){\n        renameTokenFind(\n            &sParse, &sCtx, (void*)sParse.pNewTable->aCol[iCol].zName\n        );\n        if( sCtx.iCol<0 ){\n          renameTokenFind(&sParse, &sCtx, (void*)&sParse.pNewTable->iPKey);\n        }\n        sqlite3WalkExprList(&sWalker, sParse.pNewTable->pCheck);\n        for(pIdx=sParse.pNewTable->pIndex; pIdx; pIdx=pIdx->pNext){\n          sqlite3WalkExprList(&sWalker, pIdx->aColExpr);\n        }\n        for(pIdx=sParse.pNewIndex; pIdx; pIdx=pIdx->pNext){\n          sqlite3WalkExprList(&sWalker, pIdx->aColExpr);\n        }\n      }\n\n      for(pFKey=sParse.pNewTable->pFKey; pFKey; pFKey=pFKey->pNextFrom){\n        for(i=0; i<pFKey->nCol; i++){\n          if( bFKOnly==0 && pFKey->aCol[i].iFrom==iCol ){\n            renameTokenFind(&sParse, &sCtx, (void*)&pFKey->aCol[i]);\n          }\n          if( 0==sqlite3_stricmp(pFKey->zTo, zTable)\n           && 0==sqlite3_stricmp(pFKey->aCol[i].zCol, zOld)\n          ){\n            renameTokenFind(&sParse, &sCtx, (void*)pFKey->aCol[i].zCol);\n          }\n        }\n      }\n    }\n  }else if( sParse.pNewIndex ){\n    sqlite3WalkExprList(&sWalker, sParse.pNewIndex->aColExpr);\n    sqlite3WalkExpr(&sWalker, sParse.pNewIndex->pPartIdxWhere);\n  }else{\n    /* A trigger */\n    TriggerStep *pStep;\n    rc = renameResolveTrigger(&sParse, (bTemp ? 0 : zDb));\n    if( rc!=SQLITE_OK ) goto renameColumnFunc_done;\n\n    for(pStep=sParse.pNewTrigger->step_list; pStep; pStep=pStep->pNext){\n      if( pStep->zTarget ){ \n        Table *pTarget = sqlite3LocateTable(&sParse, 0, pStep->zTarget, zDb);\n        if( pTarget==pTab ){\n          if( pStep->pUpsert ){\n            ExprList *pUpsertSet = pStep->pUpsert->pUpsertSet;\n            renameColumnElistNames(&sParse, &sCtx, pUpsertSet, zOld);\n          }\n          renameColumnIdlistNames(&sParse, &sCtx, pStep->pIdList, zOld);\n          renameColumnElistNames(&sParse, &sCtx, pStep->pExprList, zOld);\n        }\n      }\n    }\n\n\n    /* Find tokens to edit in UPDATE OF clause */\n    if( sParse.pTriggerTab==pTab ){\n      renameColumnIdlistNames(&sParse, &sCtx,sParse.pNewTrigger->pColumns,zOld);\n    }\n\n    /* Find tokens to edit in various expressions and selects */\n    renameWalkTrigger(&sWalker, sParse.pNewTrigger);\n  }\n\n  assert( rc==SQLITE_OK );\n  rc = renameEditSql(context, &sCtx, zSql, zNew, bQuote);\n\nrenameColumnFunc_done:\n  if( rc!=SQLITE_OK ){\n    if( sParse.zErrMsg ){\n      renameColumnParseError(context, 0, argv[1], argv[2], &sParse);\n    }else{\n      sqlite3_result_error_code(context, rc);\n    }\n  }\n\n  renameParseCleanup(&sParse);\n  renameTokenFree(db, sCtx.pList);\n#ifndef SQLITE_OMIT_AUTHORIZATION\n  db->xAuth = xAuth;\n#endif\n  sqlite3BtreeLeaveAll(db);\n}\n\n/*\n** Walker expression callback used by \"RENAME TABLE\". \n*/\nstatic int renameTableExprCb(Walker *pWalker, Expr *pExpr){\n  RenameCtx *p = pWalker->u.pRename;\n  if( pExpr->op==TK_COLUMN && p->pTab==pExpr->y.pTab ){\n    renameTokenFind(pWalker->pParse, p, (void*)&pExpr->y.pTab);\n  }\n  return WRC_Continue;\n}\n\n/*\n** Walker select callback used by \"RENAME TABLE\". \n*/\nstatic int renameTableSelectCb(Walker *pWalker, Select *pSelect){\n  int i;\n  RenameCtx *p = pWalker->u.pRename;\n  SrcList *pSrc = pSelect->pSrc;\n  if( pSrc==0 ){\n    assert( pWalker->pParse->db->mallocFailed );\n    return WRC_Abort;\n  }\n  for(i=0; i<pSrc->nSrc; i++){\n    struct SrcList_item *pItem = &pSrc->a[i];\n    if( pItem->pTab==p->pTab ){\n      renameTokenFind(pWalker->pParse, p, pItem->zName);\n    }\n  }\n  renameWalkWith(pWalker, pSelect);\n\n  return WRC_Continue;\n}\n\n\n/*\n** This C function implements an SQL user function that is used by SQL code\n** generated by the ALTER TABLE ... RENAME command to modify the definition\n** of any foreign key constraints that use the table being renamed as the \n** parent table. It is passed three arguments:\n**\n**   0: The database containing the table being renamed.\n**   1. type:     Type of object (\"table\", \"view\" etc.)\n**   2. object:   Name of object\n**   3: The complete text of the schema statement being modified,\n**   4: The old name of the table being renamed, and\n**   5: The new name of the table being renamed.\n**   6: True if the schema statement comes from the temp db.\n**\n** It returns the new schema statement. For example:\n**\n** sqlite_rename_table('main', 'CREATE TABLE t1(a REFERENCES t2)','t2','t3',0)\n**       -> 'CREATE TABLE t1(a REFERENCES t3)'\n*/\nstatic void renameTableFunc(\n  sqlite3_context *context,\n  int NotUsed,\n  sqlite3_value **argv\n){\n  sqlite3 *db = sqlite3_context_db_handle(context);\n  const char *zDb = (const char*)sqlite3_value_text(argv[0]);\n  const char *zInput = (const char*)sqlite3_value_text(argv[3]);\n  const char *zOld = (const char*)sqlite3_value_text(argv[4]);\n  const char *zNew = (const char*)sqlite3_value_text(argv[5]);\n  int bTemp = sqlite3_value_int(argv[6]);\n  UNUSED_PARAMETER(NotUsed);\n\n  if( zInput && zOld && zNew ){\n    Parse sParse;\n    int rc;\n    int bQuote = 1;\n    RenameCtx sCtx;\n    Walker sWalker;\n\n#ifndef SQLITE_OMIT_AUTHORIZATION\n    sqlite3_xauth xAuth = db->xAuth;\n    db->xAuth = 0;\n#endif\n\n    sqlite3BtreeEnterAll(db);\n\n    memset(&sCtx, 0, sizeof(RenameCtx));\n    sCtx.pTab = sqlite3FindTable(db, zOld, zDb);\n    memset(&sWalker, 0, sizeof(Walker));\n    sWalker.pParse = &sParse;\n    sWalker.xExprCallback = renameTableExprCb;\n    sWalker.xSelectCallback = renameTableSelectCb;\n    sWalker.u.pRename = &sCtx;\n\n    rc = renameParseSql(&sParse, zDb, 1, db, zInput, bTemp);\n\n    if( rc==SQLITE_OK ){\n      int isLegacy = (db->flags & SQLITE_LegacyAlter);\n      if( sParse.pNewTable ){\n        Table *pTab = sParse.pNewTable;\n\n        if( pTab->pSelect ){\n          if( isLegacy==0 ){\n            NameContext sNC;\n            memset(&sNC, 0, sizeof(sNC));\n            sNC.pParse = &sParse;\n\n            sqlite3SelectPrep(&sParse, pTab->pSelect, &sNC);\n            if( sParse.nErr ) rc = sParse.rc;\n            sqlite3WalkSelect(&sWalker, pTab->pSelect);\n          }\n        }else{\n          /* Modify any FK definitions to point to the new table. */\n#ifndef SQLITE_OMIT_FOREIGN_KEY\n          if( isLegacy==0 || (db->flags & SQLITE_ForeignKeys) ){\n            FKey *pFKey;\n            for(pFKey=pTab->pFKey; pFKey; pFKey=pFKey->pNextFrom){\n              if( sqlite3_stricmp(pFKey->zTo, zOld)==0 ){\n                renameTokenFind(&sParse, &sCtx, (void*)pFKey->zTo);\n              }\n            }\n          }\n#endif\n\n          /* If this is the table being altered, fix any table refs in CHECK\n          ** expressions. Also update the name that appears right after the\n          ** \"CREATE [VIRTUAL] TABLE\" bit. */\n          if( sqlite3_stricmp(zOld, pTab->zName)==0 ){\n            sCtx.pTab = pTab;\n            if( isLegacy==0 ){\n              sqlite3WalkExprList(&sWalker, pTab->pCheck);\n            }\n            renameTokenFind(&sParse, &sCtx, pTab->zName);\n          }\n        }\n      }\n\n      else if( sParse.pNewIndex ){\n        renameTokenFind(&sParse, &sCtx, sParse.pNewIndex->zName);\n        if( isLegacy==0 ){\n          sqlite3WalkExpr(&sWalker, sParse.pNewIndex->pPartIdxWhere);\n        }\n      }\n\n#ifndef SQLITE_OMIT_TRIGGER\n      else{\n        Trigger *pTrigger = sParse.pNewTrigger;\n        TriggerStep *pStep;\n        if( 0==sqlite3_stricmp(sParse.pNewTrigger->table, zOld) \n            && sCtx.pTab->pSchema==pTrigger->pTabSchema\n          ){\n          renameTokenFind(&sParse, &sCtx, sParse.pNewTrigger->table);\n        }\n\n        if( isLegacy==0 ){\n          rc = renameResolveTrigger(&sParse, bTemp ? 0 : zDb);\n          if( rc==SQLITE_OK ){\n            renameWalkTrigger(&sWalker, pTrigger);\n            for(pStep=pTrigger->step_list; pStep; pStep=pStep->pNext){\n              if( pStep->zTarget && 0==sqlite3_stricmp(pStep->zTarget, zOld) ){\n                renameTokenFind(&sParse, &sCtx, pStep->zTarget);\n              }\n            }\n          }\n        }\n      }\n#endif\n    }\n\n    if( rc==SQLITE_OK ){\n      rc = renameEditSql(context, &sCtx, zInput, zNew, bQuote);\n    }\n    if( rc!=SQLITE_OK ){\n      if( sParse.zErrMsg ){\n        renameColumnParseError(context, 0, argv[1], argv[2], &sParse);\n      }else{\n        sqlite3_result_error_code(context, rc);\n      }\n    }\n\n    renameParseCleanup(&sParse);\n    renameTokenFree(db, sCtx.pList);\n    sqlite3BtreeLeaveAll(db);\n#ifndef SQLITE_OMIT_AUTHORIZATION\n    db->xAuth = xAuth;\n#endif\n  }\n\n  return;\n}\n\n/*\n** An SQL user function that checks that there are no parse or symbol\n** resolution problems in a CREATE TRIGGER|TABLE|VIEW|INDEX statement.\n** After an ALTER TABLE .. RENAME operation is performed and the schema\n** reloaded, this function is called on each SQL statement in the schema\n** to ensure that it is still usable.\n**\n**   0: Database name (\"main\", \"temp\" etc.).\n**   1: SQL statement.\n**   2: Object type (\"view\", \"table\", \"trigger\" or \"index\").\n**   3: Object name.\n**   4: True if object is from temp schema.\n**\n** Unless it finds an error, this function normally returns NULL. However, it\n** returns integer value 1 if:\n**\n**   * the SQL argument creates a trigger, and\n**   * the table that the trigger is attached to is in database zDb.\n*/\nstatic void renameTableTest(\n  sqlite3_context *context,\n  int NotUsed,\n  sqlite3_value **argv\n){\n  sqlite3 *db = sqlite3_context_db_handle(context);\n  char const *zDb = (const char*)sqlite3_value_text(argv[0]);\n  char const *zInput = (const char*)sqlite3_value_text(argv[1]);\n  int bTemp = sqlite3_value_int(argv[4]);\n  int isLegacy = (db->flags & SQLITE_LegacyAlter);\n\n#ifndef SQLITE_OMIT_AUTHORIZATION\n  sqlite3_xauth xAuth = db->xAuth;\n  db->xAuth = 0;\n#endif\n\n  UNUSED_PARAMETER(NotUsed);\n  if( zDb && zInput ){\n    int rc;\n    Parse sParse;\n    rc = renameParseSql(&sParse, zDb, 1, db, zInput, bTemp);\n    if( rc==SQLITE_OK ){\n      if( isLegacy==0 && sParse.pNewTable && sParse.pNewTable->pSelect ){\n        NameContext sNC;\n        memset(&sNC, 0, sizeof(sNC));\n        sNC.pParse = &sParse;\n        sqlite3SelectPrep(&sParse, sParse.pNewTable->pSelect, &sNC);\n        if( sParse.nErr ) rc = sParse.rc;\n      }\n\n      else if( sParse.pNewTrigger ){\n        if( isLegacy==0 ){\n          rc = renameResolveTrigger(&sParse, bTemp ? 0 : zDb);\n        }\n        if( rc==SQLITE_OK ){\n          int i1 = sqlite3SchemaToIndex(db, sParse.pNewTrigger->pTabSchema);\n          int i2 = sqlite3FindDbName(db, zDb);\n          if( i1==i2 ) sqlite3_result_int(context, 1);\n        }\n      }\n    }\n\n    if( rc!=SQLITE_OK ){\n      renameColumnParseError(context, 1, argv[2], argv[3], &sParse);\n    }\n    renameParseCleanup(&sParse);\n  }\n\n#ifndef SQLITE_OMIT_AUTHORIZATION\n  db->xAuth = xAuth;\n#endif\n}\n\n/*\n** Register built-in functions used to help implement ALTER TABLE\n*/\nSQLITE_PRIVATE void sqlite3AlterFunctions(void){\n  static FuncDef aAlterTableFuncs[] = {\n    INTERNAL_FUNCTION(sqlite_rename_column, 9, renameColumnFunc),\n    INTERNAL_FUNCTION(sqlite_rename_table,  7, renameTableFunc),\n    INTERNAL_FUNCTION(sqlite_rename_test,   5, renameTableTest),\n  };\n  sqlite3InsertBuiltinFuncs(aAlterTableFuncs, ArraySize(aAlterTableFuncs));\n}\n#endif  /* SQLITE_ALTER_TABLE */\n\n/************** End of alter.c ***********************************************/\n/************** Begin file analyze.c *****************************************/\n/*\n** 2005-07-08\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This file contains code associated with the ANALYZE command.\n**\n** The ANALYZE command gather statistics about the content of tables\n** and indices.  These statistics are made available to the query planner\n** to help it make better decisions about how to perform queries.\n**\n** The following system tables are or have been supported:\n**\n**    CREATE TABLE sqlite_stat1(tbl, idx, stat);\n**    CREATE TABLE sqlite_stat2(tbl, idx, sampleno, sample);\n**    CREATE TABLE sqlite_stat3(tbl, idx, nEq, nLt, nDLt, sample);\n**    CREATE TABLE sqlite_stat4(tbl, idx, nEq, nLt, nDLt, sample);\n**\n** Additional tables might be added in future releases of SQLite.\n** The sqlite_stat2 table is not created or used unless the SQLite version\n** is between 3.6.18 and 3.7.8, inclusive, and unless SQLite is compiled\n** with SQLITE_ENABLE_STAT2.  The sqlite_stat2 table is deprecated.\n** The sqlite_stat2 table is superseded by sqlite_stat3, which is only\n** created and used by SQLite versions 3.7.9 and later and with\n** SQLITE_ENABLE_STAT3 defined.  The functionality of sqlite_stat3\n** is a superset of sqlite_stat2.  The sqlite_stat4 is an enhanced\n** version of sqlite_stat3 and is only available when compiled with\n** SQLITE_ENABLE_STAT4 and in SQLite versions 3.8.1 and later.  It is\n** not possible to enable both STAT3 and STAT4 at the same time.  If they\n** are both enabled, then STAT4 takes precedence.\n**\n** For most applications, sqlite_stat1 provides all the statistics required\n** for the query planner to make good choices.\n**\n** Format of sqlite_stat1:\n**\n** There is normally one row per index, with the index identified by the\n** name in the idx column.  The tbl column is the name of the table to\n** which the index belongs.  In each such row, the stat column will be\n** a string consisting of a list of integers.  The first integer in this\n** list is the number of rows in the index.  (This is the same as the\n** number of rows in the table, except for partial indices.)  The second\n** integer is the average number of rows in the index that have the same\n** value in the first column of the index.  The third integer is the average\n** number of rows in the index that have the same value for the first two\n** columns.  The N-th integer (for N>1) is the average number of rows in \n** the index which have the same value for the first N-1 columns.  For\n** a K-column index, there will be K+1 integers in the stat column.  If\n** the index is unique, then the last integer will be 1.\n**\n** The list of integers in the stat column can optionally be followed\n** by the keyword \"unordered\".  The \"unordered\" keyword, if it is present,\n** must be separated from the last integer by a single space.  If the\n** \"unordered\" keyword is present, then the query planner assumes that\n** the index is unordered and will not use the index for a range query.\n** \n** If the sqlite_stat1.idx column is NULL, then the sqlite_stat1.stat\n** column contains a single integer which is the (estimated) number of\n** rows in the table identified by sqlite_stat1.tbl.\n**\n** Format of sqlite_stat2:\n**\n** The sqlite_stat2 is only created and is only used if SQLite is compiled\n** with SQLITE_ENABLE_STAT2 and if the SQLite version number is between\n** 3.6.18 and 3.7.8.  The \"stat2\" table contains additional information\n** about the distribution of keys within an index.  The index is identified by\n** the \"idx\" column and the \"tbl\" column is the name of the table to which\n** the index belongs.  There are usually 10 rows in the sqlite_stat2\n** table for each index.\n**\n** The sqlite_stat2 entries for an index that have sampleno between 0 and 9\n** inclusive are samples of the left-most key value in the index taken at\n** evenly spaced points along the index.  Let the number of samples be S\n** (10 in the standard build) and let C be the number of rows in the index.\n** Then the sampled rows are given by:\n**\n**     rownumber = (i*C*2 + C)/(S*2)\n**\n** For i between 0 and S-1.  Conceptually, the index space is divided into\n** S uniform buckets and the samples are the middle row from each bucket.\n**\n** The format for sqlite_stat2 is recorded here for legacy reference.  This\n** version of SQLite does not support sqlite_stat2.  It neither reads nor\n** writes the sqlite_stat2 table.  This version of SQLite only supports\n** sqlite_stat3.\n**\n** Format for sqlite_stat3:\n**\n** The sqlite_stat3 format is a subset of sqlite_stat4.  Hence, the\n** sqlite_stat4 format will be described first.  Further information\n** about sqlite_stat3 follows the sqlite_stat4 description.\n**\n** Format for sqlite_stat4:\n**\n** As with sqlite_stat2, the sqlite_stat4 table contains histogram data\n** to aid the query planner in choosing good indices based on the values\n** that indexed columns are compared against in the WHERE clauses of\n** queries.\n**\n** The sqlite_stat4 table contains multiple entries for each index.\n** The idx column names the index and the tbl column is the table of the\n** index.  If the idx and tbl columns are the same, then the sample is\n** of the INTEGER PRIMARY KEY.  The sample column is a blob which is the\n** binary encoding of a key from the index.  The nEq column is a\n** list of integers.  The first integer is the approximate number\n** of entries in the index whose left-most column exactly matches\n** the left-most column of the sample.  The second integer in nEq\n** is the approximate number of entries in the index where the\n** first two columns match the first two columns of the sample.\n** And so forth.  nLt is another list of integers that show the approximate\n** number of entries that are strictly less than the sample.  The first\n** integer in nLt contains the number of entries in the index where the\n** left-most column is less than the left-most column of the sample.\n** The K-th integer in the nLt entry is the number of index entries \n** where the first K columns are less than the first K columns of the\n** sample.  The nDLt column is like nLt except that it contains the \n** number of distinct entries in the index that are less than the\n** sample.\n**\n** There can be an arbitrary number of sqlite_stat4 entries per index.\n** The ANALYZE command will typically generate sqlite_stat4 tables\n** that contain between 10 and 40 samples which are distributed across\n** the key space, though not uniformly, and which include samples with\n** large nEq values.\n**\n** Format for sqlite_stat3 redux:\n**\n** The sqlite_stat3 table is like sqlite_stat4 except that it only\n** looks at the left-most column of the index.  The sqlite_stat3.sample\n** column contains the actual value of the left-most column instead\n** of a blob encoding of the complete index key as is found in\n** sqlite_stat4.sample.  The nEq, nLt, and nDLt entries of sqlite_stat3\n** all contain just a single integer which is the same as the first\n** integer in the equivalent columns in sqlite_stat4.\n*/\n#ifndef SQLITE_OMIT_ANALYZE\n/* #include \"sqliteInt.h\" */\n\n#if defined(SQLITE_ENABLE_STAT4)\n# define IsStat4     1\n# define IsStat3     0\n#elif defined(SQLITE_ENABLE_STAT3)\n# define IsStat4     0\n# define IsStat3     1\n#else\n# define IsStat4     0\n# define IsStat3     0\n# undef SQLITE_STAT4_SAMPLES\n# define SQLITE_STAT4_SAMPLES 1\n#endif\n#define IsStat34    (IsStat3+IsStat4)  /* 1 for STAT3 or STAT4. 0 otherwise */\n\n/*\n** This routine generates code that opens the sqlite_statN tables.\n** The sqlite_stat1 table is always relevant.  sqlite_stat2 is now\n** obsolete.  sqlite_stat3 and sqlite_stat4 are only opened when\n** appropriate compile-time options are provided.\n**\n** If the sqlite_statN tables do not previously exist, it is created.\n**\n** Argument zWhere may be a pointer to a buffer containing a table name,\n** or it may be a NULL pointer. If it is not NULL, then all entries in\n** the sqlite_statN tables associated with the named table are deleted.\n** If zWhere==0, then code is generated to delete all stat table entries.\n*/\nstatic void openStatTable(\n  Parse *pParse,          /* Parsing context */\n  int iDb,                /* The database we are looking in */\n  int iStatCur,           /* Open the sqlite_stat1 table on this cursor */\n  const char *zWhere,     /* Delete entries for this table or index */\n  const char *zWhereType  /* Either \"tbl\" or \"idx\" */\n){\n  static const struct {\n    const char *zName;\n    const char *zCols;\n  } aTable[] = {\n    { \"sqlite_stat1\", \"tbl,idx,stat\" },\n#if defined(SQLITE_ENABLE_STAT4)\n    { \"sqlite_stat4\", \"tbl,idx,neq,nlt,ndlt,sample\" },\n    { \"sqlite_stat3\", 0 },\n#elif defined(SQLITE_ENABLE_STAT3)\n    { \"sqlite_stat3\", \"tbl,idx,neq,nlt,ndlt,sample\" },\n    { \"sqlite_stat4\", 0 },\n#else\n    { \"sqlite_stat3\", 0 },\n    { \"sqlite_stat4\", 0 },\n#endif\n  };\n  int i;\n  sqlite3 *db = pParse->db;\n  Db *pDb;\n  Vdbe *v = sqlite3GetVdbe(pParse);\n  int aRoot[ArraySize(aTable)];\n  u8 aCreateTbl[ArraySize(aTable)];\n\n  if( v==0 ) return;\n  assert( sqlite3BtreeHoldsAllMutexes(db) );\n  assert( sqlite3VdbeDb(v)==db );\n  pDb = &db->aDb[iDb];\n\n  /* Create new statistic tables if they do not exist, or clear them\n  ** if they do already exist.\n  */\n  for(i=0; i<ArraySize(aTable); i++){\n    const char *zTab = aTable[i].zName;\n    Table *pStat;\n    if( (pStat = sqlite3FindTable(db, zTab, pDb->zDbSName))==0 ){\n      if( aTable[i].zCols ){\n        /* The sqlite_statN table does not exist. Create it. Note that a \n        ** side-effect of the CREATE TABLE statement is to leave the rootpage \n        ** of the new table in register pParse->regRoot. This is important \n        ** because the OpenWrite opcode below will be needing it. */\n        sqlite3NestedParse(pParse,\n            \"CREATE TABLE %Q.%s(%s)\", pDb->zDbSName, zTab, aTable[i].zCols\n        );\n        aRoot[i] = pParse->regRoot;\n        aCreateTbl[i] = OPFLAG_P2ISREG;\n      }\n    }else{\n      /* The table already exists. If zWhere is not NULL, delete all entries \n      ** associated with the table zWhere. If zWhere is NULL, delete the\n      ** entire contents of the table. */\n      aRoot[i] = pStat->tnum;\n      aCreateTbl[i] = 0;\n      sqlite3TableLock(pParse, iDb, aRoot[i], 1, zTab);\n      if( zWhere ){\n        sqlite3NestedParse(pParse,\n           \"DELETE FROM %Q.%s WHERE %s=%Q\",\n           pDb->zDbSName, zTab, zWhereType, zWhere\n        );\n#ifdef SQLITE_ENABLE_PREUPDATE_HOOK\n      }else if( db->xPreUpdateCallback ){\n        sqlite3NestedParse(pParse, \"DELETE FROM %Q.%s\", pDb->zDbSName, zTab);\n#endif\n      }else{\n        /* The sqlite_stat[134] table already exists.  Delete all rows. */\n        sqlite3VdbeAddOp2(v, OP_Clear, aRoot[i], iDb);\n      }\n    }\n  }\n\n  /* Open the sqlite_stat[134] tables for writing. */\n  for(i=0; aTable[i].zCols; i++){\n    assert( i<ArraySize(aTable) );\n    sqlite3VdbeAddOp4Int(v, OP_OpenWrite, iStatCur+i, aRoot[i], iDb, 3);\n    sqlite3VdbeChangeP5(v, aCreateTbl[i]);\n    VdbeComment((v, aTable[i].zName));\n  }\n}\n\n/*\n** Recommended number of samples for sqlite_stat4\n*/\n#ifndef SQLITE_STAT4_SAMPLES\n# define SQLITE_STAT4_SAMPLES 24\n#endif\n\n/*\n** Three SQL functions - stat_init(), stat_push(), and stat_get() -\n** share an instance of the following structure to hold their state\n** information.\n*/\ntypedef struct Stat4Accum Stat4Accum;\ntypedef struct Stat4Sample Stat4Sample;\nstruct Stat4Sample {\n  tRowcnt *anEq;                  /* sqlite_stat4.nEq */\n  tRowcnt *anDLt;                 /* sqlite_stat4.nDLt */\n#ifdef SQLITE_ENABLE_STAT3_OR_STAT4\n  tRowcnt *anLt;                  /* sqlite_stat4.nLt */\n  union {\n    i64 iRowid;                     /* Rowid in main table of the key */\n    u8 *aRowid;                     /* Key for WITHOUT ROWID tables */\n  } u;\n  u32 nRowid;                     /* Sizeof aRowid[] */\n  u8 isPSample;                   /* True if a periodic sample */\n  int iCol;                       /* If !isPSample, the reason for inclusion */\n  u32 iHash;                      /* Tiebreaker hash */\n#endif\n};                                                    \nstruct Stat4Accum {\n  tRowcnt nRow;             /* Number of rows in the entire table */\n  tRowcnt nPSample;         /* How often to do a periodic sample */\n  int nCol;                 /* Number of columns in index + pk/rowid */\n  int nKeyCol;              /* Number of index columns w/o the pk/rowid */\n  int mxSample;             /* Maximum number of samples to accumulate */\n  Stat4Sample current;      /* Current row as a Stat4Sample */\n  u32 iPrn;                 /* Pseudo-random number used for sampling */\n  Stat4Sample *aBest;       /* Array of nCol best samples */\n  int iMin;                 /* Index in a[] of entry with minimum score */\n  int nSample;              /* Current number of samples */\n  int nMaxEqZero;           /* Max leading 0 in anEq[] for any a[] entry */\n  int iGet;                 /* Index of current sample accessed by stat_get() */\n  Stat4Sample *a;           /* Array of mxSample Stat4Sample objects */\n  sqlite3 *db;              /* Database connection, for malloc() */\n};\n\n/* Reclaim memory used by a Stat4Sample\n*/\n#ifdef SQLITE_ENABLE_STAT3_OR_STAT4\nstatic void sampleClear(sqlite3 *db, Stat4Sample *p){\n  assert( db!=0 );\n  if( p->nRowid ){\n    sqlite3DbFree(db, p->u.aRowid);\n    p->nRowid = 0;\n  }\n}\n#endif\n\n/* Initialize the BLOB value of a ROWID\n*/\n#ifdef SQLITE_ENABLE_STAT3_OR_STAT4\nstatic void sampleSetRowid(sqlite3 *db, Stat4Sample *p, int n, const u8 *pData){\n  assert( db!=0 );\n  if( p->nRowid ) sqlite3DbFree(db, p->u.aRowid);\n  p->u.aRowid = sqlite3DbMallocRawNN(db, n);\n  if( p->u.aRowid ){\n    p->nRowid = n;\n    memcpy(p->u.aRowid, pData, n);\n  }else{\n    p->nRowid = 0;\n  }\n}\n#endif\n\n/* Initialize the INTEGER value of a ROWID.\n*/\n#ifdef SQLITE_ENABLE_STAT3_OR_STAT4\nstatic void sampleSetRowidInt64(sqlite3 *db, Stat4Sample *p, i64 iRowid){\n  assert( db!=0 );\n  if( p->nRowid ) sqlite3DbFree(db, p->u.aRowid);\n  p->nRowid = 0;\n  p->u.iRowid = iRowid;\n}\n#endif\n\n\n/*\n** Copy the contents of object (*pFrom) into (*pTo).\n*/\n#ifdef SQLITE_ENABLE_STAT3_OR_STAT4\nstatic void sampleCopy(Stat4Accum *p, Stat4Sample *pTo, Stat4Sample *pFrom){\n  pTo->isPSample = pFrom->isPSample;\n  pTo->iCol = pFrom->iCol;\n  pTo->iHash = pFrom->iHash;\n  memcpy(pTo->anEq, pFrom->anEq, sizeof(tRowcnt)*p->nCol);\n  memcpy(pTo->anLt, pFrom->anLt, sizeof(tRowcnt)*p->nCol);\n  memcpy(pTo->anDLt, pFrom->anDLt, sizeof(tRowcnt)*p->nCol);\n  if( pFrom->nRowid ){\n    sampleSetRowid(p->db, pTo, pFrom->nRowid, pFrom->u.aRowid);\n  }else{\n    sampleSetRowidInt64(p->db, pTo, pFrom->u.iRowid);\n  }\n}\n#endif\n\n/*\n** Reclaim all memory of a Stat4Accum structure.\n*/\nstatic void stat4Destructor(void *pOld){\n  Stat4Accum *p = (Stat4Accum*)pOld;\n#ifdef SQLITE_ENABLE_STAT3_OR_STAT4\n  int i;\n  for(i=0; i<p->nCol; i++) sampleClear(p->db, p->aBest+i);\n  for(i=0; i<p->mxSample; i++) sampleClear(p->db, p->a+i);\n  sampleClear(p->db, &p->current);\n#endif\n  sqlite3DbFree(p->db, p);\n}\n\n/*\n** Implementation of the stat_init(N,K,C) SQL function. The three parameters\n** are:\n**     N:    The number of columns in the index including the rowid/pk (note 1)\n**     K:    The number of columns in the index excluding the rowid/pk.\n**     C:    The number of rows in the index (note 2)\n**\n** Note 1:  In the special case of the covering index that implements a\n** WITHOUT ROWID table, N is the number of PRIMARY KEY columns, not the\n** total number of columns in the table.\n**\n** Note 2:  C is only used for STAT3 and STAT4.\n**\n** For indexes on ordinary rowid tables, N==K+1.  But for indexes on\n** WITHOUT ROWID tables, N=K+P where P is the number of columns in the\n** PRIMARY KEY of the table.  The covering index that implements the\n** original WITHOUT ROWID table as N==K as a special case.\n**\n** This routine allocates the Stat4Accum object in heap memory. The return \n** value is a pointer to the Stat4Accum object.  The datatype of the\n** return value is BLOB, but it is really just a pointer to the Stat4Accum\n** object.\n*/\nstatic void statInit(\n  sqlite3_context *context,\n  int argc,\n  sqlite3_value **argv\n){\n  Stat4Accum *p;\n  int nCol;                       /* Number of columns in index being sampled */\n  int nKeyCol;                    /* Number of key columns */\n  int nColUp;                     /* nCol rounded up for alignment */\n  int n;                          /* Bytes of space to allocate */\n  sqlite3 *db;                    /* Database connection */\n#ifdef SQLITE_ENABLE_STAT3_OR_STAT4\n  int mxSample = SQLITE_STAT4_SAMPLES;\n#endif\n\n  /* Decode the three function arguments */\n  UNUSED_PARAMETER(argc);\n  nCol = sqlite3_value_int(argv[0]);\n  assert( nCol>0 );\n  nColUp = sizeof(tRowcnt)<8 ? (nCol+1)&~1 : nCol;\n  nKeyCol = sqlite3_value_int(argv[1]);\n  assert( nKeyCol<=nCol );\n  assert( nKeyCol>0 );\n\n  /* Allocate the space required for the Stat4Accum object */\n  n = sizeof(*p) \n    + sizeof(tRowcnt)*nColUp                  /* Stat4Accum.anEq */\n    + sizeof(tRowcnt)*nColUp                  /* Stat4Accum.anDLt */\n#ifdef SQLITE_ENABLE_STAT3_OR_STAT4\n    + sizeof(tRowcnt)*nColUp                  /* Stat4Accum.anLt */\n    + sizeof(Stat4Sample)*(nCol+mxSample)     /* Stat4Accum.aBest[], a[] */\n    + sizeof(tRowcnt)*3*nColUp*(nCol+mxSample)\n#endif\n  ;\n  db = sqlite3_context_db_handle(context);\n  p = sqlite3DbMallocZero(db, n);\n  if( p==0 ){\n    sqlite3_result_error_nomem(context);\n    return;\n  }\n\n  p->db = db;\n  p->nRow = 0;\n  p->nCol = nCol;\n  p->nKeyCol = nKeyCol;\n  p->current.anDLt = (tRowcnt*)&p[1];\n  p->current.anEq = &p->current.anDLt[nColUp];\n\n#ifdef SQLITE_ENABLE_STAT3_OR_STAT4\n  {\n    u8 *pSpace;                     /* Allocated space not yet assigned */\n    int i;                          /* Used to iterate through p->aSample[] */\n\n    p->iGet = -1;\n    p->mxSample = mxSample;\n    p->nPSample = (tRowcnt)(sqlite3_value_int64(argv[2])/(mxSample/3+1) + 1);\n    p->current.anLt = &p->current.anEq[nColUp];\n    p->iPrn = 0x689e962d*(u32)nCol ^ 0xd0944565*(u32)sqlite3_value_int(argv[2]);\n  \n    /* Set up the Stat4Accum.a[] and aBest[] arrays */\n    p->a = (struct Stat4Sample*)&p->current.anLt[nColUp];\n    p->aBest = &p->a[mxSample];\n    pSpace = (u8*)(&p->a[mxSample+nCol]);\n    for(i=0; i<(mxSample+nCol); i++){\n      p->a[i].anEq = (tRowcnt *)pSpace; pSpace += (sizeof(tRowcnt) * nColUp);\n      p->a[i].anLt = (tRowcnt *)pSpace; pSpace += (sizeof(tRowcnt) * nColUp);\n      p->a[i].anDLt = (tRowcnt *)pSpace; pSpace += (sizeof(tRowcnt) * nColUp);\n    }\n    assert( (pSpace - (u8*)p)==n );\n  \n    for(i=0; i<nCol; i++){\n      p->aBest[i].iCol = i;\n    }\n  }\n#endif\n\n  /* Return a pointer to the allocated object to the caller.  Note that\n  ** only the pointer (the 2nd parameter) matters.  The size of the object\n  ** (given by the 3rd parameter) is never used and can be any positive\n  ** value. */\n  sqlite3_result_blob(context, p, sizeof(*p), stat4Destructor);\n}\nstatic const FuncDef statInitFuncdef = {\n  2+IsStat34,      /* nArg */\n  SQLITE_UTF8,     /* funcFlags */\n  0,               /* pUserData */\n  0,               /* pNext */\n  statInit,        /* xSFunc */\n  0,               /* xFinalize */\n  0, 0,            /* xValue, xInverse */\n  \"stat_init\",     /* zName */\n  {0}\n};\n\n#ifdef SQLITE_ENABLE_STAT4\n/*\n** pNew and pOld are both candidate non-periodic samples selected for \n** the same column (pNew->iCol==pOld->iCol). Ignoring this column and \n** considering only any trailing columns and the sample hash value, this\n** function returns true if sample pNew is to be preferred over pOld.\n** In other words, if we assume that the cardinalities of the selected\n** column for pNew and pOld are equal, is pNew to be preferred over pOld.\n**\n** This function assumes that for each argument sample, the contents of\n** the anEq[] array from pSample->anEq[pSample->iCol+1] onwards are valid. \n*/\nstatic int sampleIsBetterPost(\n  Stat4Accum *pAccum, \n  Stat4Sample *pNew, \n  Stat4Sample *pOld\n){\n  int nCol = pAccum->nCol;\n  int i;\n  assert( pNew->iCol==pOld->iCol );\n  for(i=pNew->iCol+1; i<nCol; i++){\n    if( pNew->anEq[i]>pOld->anEq[i] ) return 1;\n    if( pNew->anEq[i]<pOld->anEq[i] ) return 0;\n  }\n  if( pNew->iHash>pOld->iHash ) return 1;\n  return 0;\n}\n#endif\n\n#ifdef SQLITE_ENABLE_STAT3_OR_STAT4\n/*\n** Return true if pNew is to be preferred over pOld.\n**\n** This function assumes that for each argument sample, the contents of\n** the anEq[] array from pSample->anEq[pSample->iCol] onwards are valid. \n*/\nstatic int sampleIsBetter(\n  Stat4Accum *pAccum, \n  Stat4Sample *pNew, \n  Stat4Sample *pOld\n){\n  tRowcnt nEqNew = pNew->anEq[pNew->iCol];\n  tRowcnt nEqOld = pOld->anEq[pOld->iCol];\n\n  assert( pOld->isPSample==0 && pNew->isPSample==0 );\n  assert( IsStat4 || (pNew->iCol==0 && pOld->iCol==0) );\n\n  if( (nEqNew>nEqOld) ) return 1;\n#ifdef SQLITE_ENABLE_STAT4\n  if( nEqNew==nEqOld ){\n    if( pNew->iCol<pOld->iCol ) return 1;\n    return (pNew->iCol==pOld->iCol && sampleIsBetterPost(pAccum, pNew, pOld));\n  }\n  return 0;\n#else\n  return (nEqNew==nEqOld && pNew->iHash>pOld->iHash);\n#endif\n}\n\n/*\n** Copy the contents of sample *pNew into the p->a[] array. If necessary,\n** remove the least desirable sample from p->a[] to make room.\n*/\nstatic void sampleInsert(Stat4Accum *p, Stat4Sample *pNew, int nEqZero){\n  Stat4Sample *pSample = 0;\n  int i;\n\n  assert( IsStat4 || nEqZero==0 );\n\n#ifdef SQLITE_ENABLE_STAT4\n  /* Stat4Accum.nMaxEqZero is set to the maximum number of leading 0\n  ** values in the anEq[] array of any sample in Stat4Accum.a[]. In\n  ** other words, if nMaxEqZero is n, then it is guaranteed that there\n  ** are no samples with Stat4Sample.anEq[m]==0 for (m>=n). */\n  if( nEqZero>p->nMaxEqZero ){\n    p->nMaxEqZero = nEqZero;\n  }\n  if( pNew->isPSample==0 ){\n    Stat4Sample *pUpgrade = 0;\n    assert( pNew->anEq[pNew->iCol]>0 );\n\n    /* This sample is being added because the prefix that ends in column \n    ** iCol occurs many times in the table. However, if we have already\n    ** added a sample that shares this prefix, there is no need to add\n    ** this one. Instead, upgrade the priority of the highest priority\n    ** existing sample that shares this prefix.  */\n    for(i=p->nSample-1; i>=0; i--){\n      Stat4Sample *pOld = &p->a[i];\n      if( pOld->anEq[pNew->iCol]==0 ){\n        if( pOld->isPSample ) return;\n        assert( pOld->iCol>pNew->iCol );\n        assert( sampleIsBetter(p, pNew, pOld) );\n        if( pUpgrade==0 || sampleIsBetter(p, pOld, pUpgrade) ){\n          pUpgrade = pOld;\n        }\n      }\n    }\n    if( pUpgrade ){\n      pUpgrade->iCol = pNew->iCol;\n      pUpgrade->anEq[pUpgrade->iCol] = pNew->anEq[pUpgrade->iCol];\n      goto find_new_min;\n    }\n  }\n#endif\n\n  /* If necessary, remove sample iMin to make room for the new sample. */\n  if( p->nSample>=p->mxSample ){\n    Stat4Sample *pMin = &p->a[p->iMin];\n    tRowcnt *anEq = pMin->anEq;\n    tRowcnt *anLt = pMin->anLt;\n    tRowcnt *anDLt = pMin->anDLt;\n    sampleClear(p->db, pMin);\n    memmove(pMin, &pMin[1], sizeof(p->a[0])*(p->nSample-p->iMin-1));\n    pSample = &p->a[p->nSample-1];\n    pSample->nRowid = 0;\n    pSample->anEq = anEq;\n    pSample->anDLt = anDLt;\n    pSample->anLt = anLt;\n    p->nSample = p->mxSample-1;\n  }\n\n  /* The \"rows less-than\" for the rowid column must be greater than that\n  ** for the last sample in the p->a[] array. Otherwise, the samples would\n  ** be out of order. */\n#ifdef SQLITE_ENABLE_STAT4\n  assert( p->nSample==0 \n       || pNew->anLt[p->nCol-1] > p->a[p->nSample-1].anLt[p->nCol-1] );\n#endif\n\n  /* Insert the new sample */\n  pSample = &p->a[p->nSample];\n  sampleCopy(p, pSample, pNew);\n  p->nSample++;\n\n  /* Zero the first nEqZero entries in the anEq[] array. */\n  memset(pSample->anEq, 0, sizeof(tRowcnt)*nEqZero);\n\n#ifdef SQLITE_ENABLE_STAT4\n find_new_min:\n#endif\n  if( p->nSample>=p->mxSample ){\n    int iMin = -1;\n    for(i=0; i<p->mxSample; i++){\n      if( p->a[i].isPSample ) continue;\n      if( iMin<0 || sampleIsBetter(p, &p->a[iMin], &p->a[i]) ){\n        iMin = i;\n      }\n    }\n    assert( iMin>=0 );\n    p->iMin = iMin;\n  }\n}\n#endif /* SQLITE_ENABLE_STAT3_OR_STAT4 */\n\n/*\n** Field iChng of the index being scanned has changed. So at this point\n** p->current contains a sample that reflects the previous row of the\n** index. The value of anEq[iChng] and subsequent anEq[] elements are\n** correct at this point.\n*/\nstatic void samplePushPrevious(Stat4Accum *p, int iChng){\n#ifdef SQLITE_ENABLE_STAT4\n  int i;\n\n  /* Check if any samples from the aBest[] array should be pushed\n  ** into IndexSample.a[] at this point.  */\n  for(i=(p->nCol-2); i>=iChng; i--){\n    Stat4Sample *pBest = &p->aBest[i];\n    pBest->anEq[i] = p->current.anEq[i];\n    if( p->nSample<p->mxSample || sampleIsBetter(p, pBest, &p->a[p->iMin]) ){\n      sampleInsert(p, pBest, i);\n    }\n  }\n\n  /* Check that no sample contains an anEq[] entry with an index of\n  ** p->nMaxEqZero or greater set to zero. */\n  for(i=p->nSample-1; i>=0; i--){\n    int j;\n    for(j=p->nMaxEqZero; j<p->nCol; j++) assert( p->a[i].anEq[j]>0 );\n  }\n\n  /* Update the anEq[] fields of any samples already collected. */\n  if( iChng<p->nMaxEqZero ){\n    for(i=p->nSample-1; i>=0; i--){\n      int j;\n      for(j=iChng; j<p->nCol; j++){\n        if( p->a[i].anEq[j]==0 ) p->a[i].anEq[j] = p->current.anEq[j];\n      }\n    }\n    p->nMaxEqZero = iChng;\n  }\n#endif\n\n#if defined(SQLITE_ENABLE_STAT3) && !defined(SQLITE_ENABLE_STAT4)\n  if( iChng==0 ){\n    tRowcnt nLt = p->current.anLt[0];\n    tRowcnt nEq = p->current.anEq[0];\n\n    /* Check if this is to be a periodic sample. If so, add it. */\n    if( (nLt/p->nPSample)!=(nLt+nEq)/p->nPSample ){\n      p->current.isPSample = 1;\n      sampleInsert(p, &p->current, 0);\n      p->current.isPSample = 0;\n    }else \n\n    /* Or if it is a non-periodic sample. Add it in this case too. */\n    if( p->nSample<p->mxSample \n     || sampleIsBetter(p, &p->current, &p->a[p->iMin]) \n    ){\n      sampleInsert(p, &p->current, 0);\n    }\n  }\n#endif\n\n#ifndef SQLITE_ENABLE_STAT3_OR_STAT4\n  UNUSED_PARAMETER( p );\n  UNUSED_PARAMETER( iChng );\n#endif\n}\n\n/*\n** Implementation of the stat_push SQL function:  stat_push(P,C,R)\n** Arguments:\n**\n**    P     Pointer to the Stat4Accum object created by stat_init()\n**    C     Index of left-most column to differ from previous row\n**    R     Rowid for the current row.  Might be a key record for\n**          WITHOUT ROWID tables.\n**\n** This SQL function always returns NULL.  It's purpose it to accumulate\n** statistical data and/or samples in the Stat4Accum object about the\n** index being analyzed.  The stat_get() SQL function will later be used to\n** extract relevant information for constructing the sqlite_statN tables.\n**\n** The R parameter is only used for STAT3 and STAT4\n*/\nstatic void statPush(\n  sqlite3_context *context,\n  int argc,\n  sqlite3_value **argv\n){\n  int i;\n\n  /* The three function arguments */\n  Stat4Accum *p = (Stat4Accum*)sqlite3_value_blob(argv[0]);\n  int iChng = sqlite3_value_int(argv[1]);\n\n  UNUSED_PARAMETER( argc );\n  UNUSED_PARAMETER( context );\n  assert( p->nCol>0 );\n  assert( iChng<p->nCol );\n\n  if( p->nRow==0 ){\n    /* This is the first call to this function. Do initialization. */\n    for(i=0; i<p->nCol; i++) p->current.anEq[i] = 1;\n  }else{\n    /* Second and subsequent calls get processed here */\n    samplePushPrevious(p, iChng);\n\n    /* Update anDLt[], anLt[] and anEq[] to reflect the values that apply\n    ** to the current row of the index. */\n    for(i=0; i<iChng; i++){\n      p->current.anEq[i]++;\n    }\n    for(i=iChng; i<p->nCol; i++){\n      p->current.anDLt[i]++;\n#ifdef SQLITE_ENABLE_STAT3_OR_STAT4\n      p->current.anLt[i] += p->current.anEq[i];\n#endif\n      p->current.anEq[i] = 1;\n    }\n  }\n  p->nRow++;\n#ifdef SQLITE_ENABLE_STAT3_OR_STAT4\n  if( sqlite3_value_type(argv[2])==SQLITE_INTEGER ){\n    sampleSetRowidInt64(p->db, &p->current, sqlite3_value_int64(argv[2]));\n  }else{\n    sampleSetRowid(p->db, &p->current, sqlite3_value_bytes(argv[2]),\n                                       sqlite3_value_blob(argv[2]));\n  }\n  p->current.iHash = p->iPrn = p->iPrn*1103515245 + 12345;\n#endif\n\n#ifdef SQLITE_ENABLE_STAT4\n  {\n    tRowcnt nLt = p->current.anLt[p->nCol-1];\n\n    /* Check if this is to be a periodic sample. If so, add it. */\n    if( (nLt/p->nPSample)!=(nLt+1)/p->nPSample ){\n      p->current.isPSample = 1;\n      p->current.iCol = 0;\n      sampleInsert(p, &p->current, p->nCol-1);\n      p->current.isPSample = 0;\n    }\n\n    /* Update the aBest[] array. */\n    for(i=0; i<(p->nCol-1); i++){\n      p->current.iCol = i;\n      if( i>=iChng || sampleIsBetterPost(p, &p->current, &p->aBest[i]) ){\n        sampleCopy(p, &p->aBest[i], &p->current);\n      }\n    }\n  }\n#endif\n}\nstatic const FuncDef statPushFuncdef = {\n  2+IsStat34,      /* nArg */\n  SQLITE_UTF8,     /* funcFlags */\n  0,               /* pUserData */\n  0,               /* pNext */\n  statPush,        /* xSFunc */\n  0,               /* xFinalize */\n  0, 0,            /* xValue, xInverse */\n  \"stat_push\",     /* zName */\n  {0}\n};\n\n#define STAT_GET_STAT1 0          /* \"stat\" column of stat1 table */\n#define STAT_GET_ROWID 1          /* \"rowid\" column of stat[34] entry */\n#define STAT_GET_NEQ   2          /* \"neq\" column of stat[34] entry */\n#define STAT_GET_NLT   3          /* \"nlt\" column of stat[34] entry */\n#define STAT_GET_NDLT  4          /* \"ndlt\" column of stat[34] entry */\n\n/*\n** Implementation of the stat_get(P,J) SQL function.  This routine is\n** used to query statistical information that has been gathered into\n** the Stat4Accum object by prior calls to stat_push().  The P parameter\n** has type BLOB but it is really just a pointer to the Stat4Accum object.\n** The content to returned is determined by the parameter J\n** which is one of the STAT_GET_xxxx values defined above.\n**\n** The stat_get(P,J) function is not available to generic SQL.  It is\n** inserted as part of a manually constructed bytecode program.  (See\n** the callStatGet() routine below.)  It is guaranteed that the P\n** parameter will always be a poiner to a Stat4Accum object, never a\n** NULL.\n**\n** If neither STAT3 nor STAT4 are enabled, then J is always\n** STAT_GET_STAT1 and is hence omitted and this routine becomes\n** a one-parameter function, stat_get(P), that always returns the\n** stat1 table entry information.\n*/\nstatic void statGet(\n  sqlite3_context *context,\n  int argc,\n  sqlite3_value **argv\n){\n  Stat4Accum *p = (Stat4Accum*)sqlite3_value_blob(argv[0]);\n#ifdef SQLITE_ENABLE_STAT3_OR_STAT4\n  /* STAT3 and STAT4 have a parameter on this routine. */\n  int eCall = sqlite3_value_int(argv[1]);\n  assert( argc==2 );\n  assert( eCall==STAT_GET_STAT1 || eCall==STAT_GET_NEQ \n       || eCall==STAT_GET_ROWID || eCall==STAT_GET_NLT\n       || eCall==STAT_GET_NDLT \n  );\n  if( eCall==STAT_GET_STAT1 )\n#else\n  assert( argc==1 );\n#endif\n  {\n    /* Return the value to store in the \"stat\" column of the sqlite_stat1\n    ** table for this index.\n    **\n    ** The value is a string composed of a list of integers describing \n    ** the index. The first integer in the list is the total number of \n    ** entries in the index. There is one additional integer in the list \n    ** for each indexed column. This additional integer is an estimate of\n    ** the number of rows matched by a stabbing query on the index using\n    ** a key with the corresponding number of fields. In other words,\n    ** if the index is on columns (a,b) and the sqlite_stat1 value is \n    ** \"100 10 2\", then SQLite estimates that:\n    **\n    **   * the index contains 100 rows,\n    **   * \"WHERE a=?\" matches 10 rows, and\n    **   * \"WHERE a=? AND b=?\" matches 2 rows.\n    **\n    ** If D is the count of distinct values and K is the total number of \n    ** rows, then each estimate is computed as:\n    **\n    **        I = (K+D-1)/D\n    */\n    char *z;\n    int i;\n\n    char *zRet = sqlite3MallocZero( (p->nKeyCol+1)*25 );\n    if( zRet==0 ){\n      sqlite3_result_error_nomem(context);\n      return;\n    }\n\n    sqlite3_snprintf(24, zRet, \"%llu\", (u64)p->nRow);\n    z = zRet + sqlite3Strlen30(zRet);\n    for(i=0; i<p->nKeyCol; i++){\n      u64 nDistinct = p->current.anDLt[i] + 1;\n      u64 iVal = (p->nRow + nDistinct - 1) / nDistinct;\n      sqlite3_snprintf(24, z, \" %llu\", iVal);\n      z += sqlite3Strlen30(z);\n      assert( p->current.anEq[i] );\n    }\n    assert( z[0]=='\\0' && z>zRet );\n\n    sqlite3_result_text(context, zRet, -1, sqlite3_free);\n  }\n#ifdef SQLITE_ENABLE_STAT3_OR_STAT4\n  else if( eCall==STAT_GET_ROWID ){\n    if( p->iGet<0 ){\n      samplePushPrevious(p, 0);\n      p->iGet = 0;\n    }\n    if( p->iGet<p->nSample ){\n      Stat4Sample *pS = p->a + p->iGet;\n      if( pS->nRowid==0 ){\n        sqlite3_result_int64(context, pS->u.iRowid);\n      }else{\n        sqlite3_result_blob(context, pS->u.aRowid, pS->nRowid,\n                            SQLITE_TRANSIENT);\n      }\n    }\n  }else{\n    tRowcnt *aCnt = 0;\n\n    assert( p->iGet<p->nSample );\n    switch( eCall ){\n      case STAT_GET_NEQ:  aCnt = p->a[p->iGet].anEq; break;\n      case STAT_GET_NLT:  aCnt = p->a[p->iGet].anLt; break;\n      default: {\n        aCnt = p->a[p->iGet].anDLt; \n        p->iGet++;\n        break;\n      }\n    }\n\n    if( IsStat3 ){\n      sqlite3_result_int64(context, (i64)aCnt[0]);\n    }else{\n      char *zRet = sqlite3MallocZero(p->nCol * 25);\n      if( zRet==0 ){\n        sqlite3_result_error_nomem(context);\n      }else{\n        int i;\n        char *z = zRet;\n        for(i=0; i<p->nCol; i++){\n          sqlite3_snprintf(24, z, \"%llu \", (u64)aCnt[i]);\n          z += sqlite3Strlen30(z);\n        }\n        assert( z[0]=='\\0' && z>zRet );\n        z[-1] = '\\0';\n        sqlite3_result_text(context, zRet, -1, sqlite3_free);\n      }\n    }\n  }\n#endif /* SQLITE_ENABLE_STAT3_OR_STAT4 */\n#ifndef SQLITE_DEBUG\n  UNUSED_PARAMETER( argc );\n#endif\n}\nstatic const FuncDef statGetFuncdef = {\n  1+IsStat34,      /* nArg */\n  SQLITE_UTF8,     /* funcFlags */\n  0,               /* pUserData */\n  0,               /* pNext */\n  statGet,         /* xSFunc */\n  0,               /* xFinalize */\n  0, 0,            /* xValue, xInverse */\n  \"stat_get\",      /* zName */\n  {0}\n};\n\nstatic void callStatGet(Vdbe *v, int regStat4, int iParam, int regOut){\n  assert( regOut!=regStat4 && regOut!=regStat4+1 );\n#ifdef SQLITE_ENABLE_STAT3_OR_STAT4\n  sqlite3VdbeAddOp2(v, OP_Integer, iParam, regStat4+1);\n#elif SQLITE_DEBUG\n  assert( iParam==STAT_GET_STAT1 );\n#else\n  UNUSED_PARAMETER( iParam );\n#endif\n  sqlite3VdbeAddOp4(v, OP_Function0, 0, regStat4, regOut,\n                    (char*)&statGetFuncdef, P4_FUNCDEF);\n  sqlite3VdbeChangeP5(v, 1 + IsStat34);\n}\n\n/*\n** Generate code to do an analysis of all indices associated with\n** a single table.\n*/\nstatic void analyzeOneTable(\n  Parse *pParse,   /* Parser context */\n  Table *pTab,     /* Table whose indices are to be analyzed */\n  Index *pOnlyIdx, /* If not NULL, only analyze this one index */\n  int iStatCur,    /* Index of VdbeCursor that writes the sqlite_stat1 table */\n  int iMem,        /* Available memory locations begin here */\n  int iTab         /* Next available cursor */\n){\n  sqlite3 *db = pParse->db;    /* Database handle */\n  Index *pIdx;                 /* An index to being analyzed */\n  int iIdxCur;                 /* Cursor open on index being analyzed */\n  int iTabCur;                 /* Table cursor */\n  Vdbe *v;                     /* The virtual machine being built up */\n  int i;                       /* Loop counter */\n  int jZeroRows = -1;          /* Jump from here if number of rows is zero */\n  int iDb;                     /* Index of database containing pTab */\n  u8 needTableCnt = 1;         /* True to count the table */\n  int regNewRowid = iMem++;    /* Rowid for the inserted record */\n  int regStat4 = iMem++;       /* Register to hold Stat4Accum object */\n  int regChng = iMem++;        /* Index of changed index field */\n#ifdef SQLITE_ENABLE_STAT3_OR_STAT4\n  int regRowid = iMem++;       /* Rowid argument passed to stat_push() */\n#endif\n  int regTemp = iMem++;        /* Temporary use register */\n  int regTabname = iMem++;     /* Register containing table name */\n  int regIdxname = iMem++;     /* Register containing index name */\n  int regStat1 = iMem++;       /* Value for the stat column of sqlite_stat1 */\n  int regPrev = iMem;          /* MUST BE LAST (see below) */\n#ifdef SQLITE_ENABLE_PREUPDATE_HOOK\n  Table *pStat1 = 0; \n#endif\n\n  pParse->nMem = MAX(pParse->nMem, iMem);\n  v = sqlite3GetVdbe(pParse);\n  if( v==0 || NEVER(pTab==0) ){\n    return;\n  }\n  if( pTab->tnum==0 ){\n    /* Do not gather statistics on views or virtual tables */\n    return;\n  }\n  if( sqlite3_strlike(\"sqlite\\\\_%\", pTab->zName, '\\\\')==0 ){\n    /* Do not gather statistics on system tables */\n    return;\n  }\n  assert( sqlite3BtreeHoldsAllMutexes(db) );\n  iDb = sqlite3SchemaToIndex(db, pTab->pSchema);\n  assert( iDb>=0 );\n  assert( sqlite3SchemaMutexHeld(db, iDb, 0) );\n#ifndef SQLITE_OMIT_AUTHORIZATION\n  if( sqlite3AuthCheck(pParse, SQLITE_ANALYZE, pTab->zName, 0,\n      db->aDb[iDb].zDbSName ) ){\n    return;\n  }\n#endif\n\n#ifdef SQLITE_ENABLE_PREUPDATE_HOOK\n  if( db->xPreUpdateCallback ){\n    pStat1 = (Table*)sqlite3DbMallocZero(db, sizeof(Table) + 13);\n    if( pStat1==0 ) return;\n    pStat1->zName = (char*)&pStat1[1];\n    memcpy(pStat1->zName, \"sqlite_stat1\", 13);\n    pStat1->nCol = 3;\n    pStat1->iPKey = -1;\n    sqlite3VdbeAddOp4(pParse->pVdbe, OP_Noop, 0, 0, 0,(char*)pStat1,P4_DYNBLOB);\n  }\n#endif\n\n  /* Establish a read-lock on the table at the shared-cache level. \n  ** Open a read-only cursor on the table. Also allocate a cursor number\n  ** to use for scanning indexes (iIdxCur). No index cursor is opened at\n  ** this time though.  */\n  sqlite3TableLock(pParse, iDb, pTab->tnum, 0, pTab->zName);\n  iTabCur = iTab++;\n  iIdxCur = iTab++;\n  pParse->nTab = MAX(pParse->nTab, iTab);\n  sqlite3OpenTable(pParse, iTabCur, iDb, pTab, OP_OpenRead);\n  sqlite3VdbeLoadString(v, regTabname, pTab->zName);\n\n  for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){\n    int nCol;                     /* Number of columns in pIdx. \"N\" */\n    int addrRewind;               /* Address of \"OP_Rewind iIdxCur\" */\n    int addrNextRow;              /* Address of \"next_row:\" */\n    const char *zIdxName;         /* Name of the index */\n    int nColTest;                 /* Number of columns to test for changes */\n\n    if( pOnlyIdx && pOnlyIdx!=pIdx ) continue;\n    if( pIdx->pPartIdxWhere==0 ) needTableCnt = 0;\n    if( !HasRowid(pTab) && IsPrimaryKeyIndex(pIdx) ){\n      nCol = pIdx->nKeyCol;\n      zIdxName = pTab->zName;\n      nColTest = nCol - 1;\n    }else{\n      nCol = pIdx->nColumn;\n      zIdxName = pIdx->zName;\n      nColTest = pIdx->uniqNotNull ? pIdx->nKeyCol-1 : nCol-1;\n    }\n\n    /* Populate the register containing the index name. */\n    sqlite3VdbeLoadString(v, regIdxname, zIdxName);\n    VdbeComment((v, \"Analysis for %s.%s\", pTab->zName, zIdxName));\n\n    /*\n    ** Pseudo-code for loop that calls stat_push():\n    **\n    **   Rewind csr\n    **   if eof(csr) goto end_of_scan;\n    **   regChng = 0\n    **   goto chng_addr_0;\n    **\n    **  next_row:\n    **   regChng = 0\n    **   if( idx(0) != regPrev(0) ) goto chng_addr_0\n    **   regChng = 1\n    **   if( idx(1) != regPrev(1) ) goto chng_addr_1\n    **   ...\n    **   regChng = N\n    **   goto chng_addr_N\n    **\n    **  chng_addr_0:\n    **   regPrev(0) = idx(0)\n    **  chng_addr_1:\n    **   regPrev(1) = idx(1)\n    **  ...\n    **\n    **  endDistinctTest:\n    **   regRowid = idx(rowid)\n    **   stat_push(P, regChng, regRowid)\n    **   Next csr\n    **   if !eof(csr) goto next_row;\n    **\n    **  end_of_scan:\n    */\n\n    /* Make sure there are enough memory cells allocated to accommodate \n    ** the regPrev array and a trailing rowid (the rowid slot is required\n    ** when building a record to insert into the sample column of \n    ** the sqlite_stat4 table.  */\n    pParse->nMem = MAX(pParse->nMem, regPrev+nColTest);\n\n    /* Open a read-only cursor on the index being analyzed. */\n    assert( iDb==sqlite3SchemaToIndex(db, pIdx->pSchema) );\n    sqlite3VdbeAddOp3(v, OP_OpenRead, iIdxCur, pIdx->tnum, iDb);\n    sqlite3VdbeSetP4KeyInfo(pParse, pIdx);\n    VdbeComment((v, \"%s\", pIdx->zName));\n\n    /* Invoke the stat_init() function. The arguments are:\n    ** \n    **    (1) the number of columns in the index including the rowid\n    **        (or for a WITHOUT ROWID table, the number of PK columns),\n    **    (2) the number of columns in the key without the rowid/pk\n    **    (3) the number of rows in the index,\n    **\n    **\n    ** The third argument is only used for STAT3 and STAT4\n    */\n#ifdef SQLITE_ENABLE_STAT3_OR_STAT4\n    sqlite3VdbeAddOp2(v, OP_Count, iIdxCur, regStat4+3);\n#endif\n    sqlite3VdbeAddOp2(v, OP_Integer, nCol, regStat4+1);\n    sqlite3VdbeAddOp2(v, OP_Integer, pIdx->nKeyCol, regStat4+2);\n    sqlite3VdbeAddOp4(v, OP_Function0, 0, regStat4+1, regStat4,\n                     (char*)&statInitFuncdef, P4_FUNCDEF);\n    sqlite3VdbeChangeP5(v, 2+IsStat34);\n\n    /* Implementation of the following:\n    **\n    **   Rewind csr\n    **   if eof(csr) goto end_of_scan;\n    **   regChng = 0\n    **   goto next_push_0;\n    **\n    */\n    addrRewind = sqlite3VdbeAddOp1(v, OP_Rewind, iIdxCur);\n    VdbeCoverage(v);\n    sqlite3VdbeAddOp2(v, OP_Integer, 0, regChng);\n    addrNextRow = sqlite3VdbeCurrentAddr(v);\n\n    if( nColTest>0 ){\n      int endDistinctTest = sqlite3VdbeMakeLabel(pParse);\n      int *aGotoChng;               /* Array of jump instruction addresses */\n      aGotoChng = sqlite3DbMallocRawNN(db, sizeof(int)*nColTest);\n      if( aGotoChng==0 ) continue;\n\n      /*\n      **  next_row:\n      **   regChng = 0\n      **   if( idx(0) != regPrev(0) ) goto chng_addr_0\n      **   regChng = 1\n      **   if( idx(1) != regPrev(1) ) goto chng_addr_1\n      **   ...\n      **   regChng = N\n      **   goto endDistinctTest\n      */\n      sqlite3VdbeAddOp0(v, OP_Goto);\n      addrNextRow = sqlite3VdbeCurrentAddr(v);\n      if( nColTest==1 && pIdx->nKeyCol==1 && IsUniqueIndex(pIdx) ){\n        /* For a single-column UNIQUE index, once we have found a non-NULL\n        ** row, we know that all the rest will be distinct, so skip \n        ** subsequent distinctness tests. */\n        sqlite3VdbeAddOp2(v, OP_NotNull, regPrev, endDistinctTest);\n        VdbeCoverage(v);\n      }\n      for(i=0; i<nColTest; i++){\n        char *pColl = (char*)sqlite3LocateCollSeq(pParse, pIdx->azColl[i]);\n        sqlite3VdbeAddOp2(v, OP_Integer, i, regChng);\n        sqlite3VdbeAddOp3(v, OP_Column, iIdxCur, i, regTemp);\n        aGotoChng[i] = \n        sqlite3VdbeAddOp4(v, OP_Ne, regTemp, 0, regPrev+i, pColl, P4_COLLSEQ);\n        sqlite3VdbeChangeP5(v, SQLITE_NULLEQ);\n        VdbeCoverage(v);\n      }\n      sqlite3VdbeAddOp2(v, OP_Integer, nColTest, regChng);\n      sqlite3VdbeGoto(v, endDistinctTest);\n  \n  \n      /*\n      **  chng_addr_0:\n      **   regPrev(0) = idx(0)\n      **  chng_addr_1:\n      **   regPrev(1) = idx(1)\n      **  ...\n      */\n      sqlite3VdbeJumpHere(v, addrNextRow-1);\n      for(i=0; i<nColTest; i++){\n        sqlite3VdbeJumpHere(v, aGotoChng[i]);\n        sqlite3VdbeAddOp3(v, OP_Column, iIdxCur, i, regPrev+i);\n      }\n      sqlite3VdbeResolveLabel(v, endDistinctTest);\n      sqlite3DbFree(db, aGotoChng);\n    }\n  \n    /*\n    **  chng_addr_N:\n    **   regRowid = idx(rowid)            // STAT34 only\n    **   stat_push(P, regChng, regRowid)  // 3rd parameter STAT34 only\n    **   Next csr\n    **   if !eof(csr) goto next_row;\n    */\n#ifdef SQLITE_ENABLE_STAT3_OR_STAT4\n    assert( regRowid==(regStat4+2) );\n    if( HasRowid(pTab) ){\n      sqlite3VdbeAddOp2(v, OP_IdxRowid, iIdxCur, regRowid);\n    }else{\n      Index *pPk = sqlite3PrimaryKeyIndex(pIdx->pTable);\n      int j, k, regKey;\n      regKey = sqlite3GetTempRange(pParse, pPk->nKeyCol);\n      for(j=0; j<pPk->nKeyCol; j++){\n        k = sqlite3ColumnOfIndex(pIdx, pPk->aiColumn[j]);\n        assert( k>=0 && k<pIdx->nColumn );\n        sqlite3VdbeAddOp3(v, OP_Column, iIdxCur, k, regKey+j);\n        VdbeComment((v, \"%s\", pTab->aCol[pPk->aiColumn[j]].zName));\n      }\n      sqlite3VdbeAddOp3(v, OP_MakeRecord, regKey, pPk->nKeyCol, regRowid);\n      sqlite3ReleaseTempRange(pParse, regKey, pPk->nKeyCol);\n    }\n#endif\n    assert( regChng==(regStat4+1) );\n    sqlite3VdbeAddOp4(v, OP_Function0, 1, regStat4, regTemp,\n                     (char*)&statPushFuncdef, P4_FUNCDEF);\n    sqlite3VdbeChangeP5(v, 2+IsStat34);\n    sqlite3VdbeAddOp2(v, OP_Next, iIdxCur, addrNextRow); VdbeCoverage(v);\n\n    /* Add the entry to the stat1 table. */\n    callStatGet(v, regStat4, STAT_GET_STAT1, regStat1);\n    assert( \"BBB\"[0]==SQLITE_AFF_TEXT );\n    sqlite3VdbeAddOp4(v, OP_MakeRecord, regTabname, 3, regTemp, \"BBB\", 0);\n    sqlite3VdbeAddOp2(v, OP_NewRowid, iStatCur, regNewRowid);\n    sqlite3VdbeAddOp3(v, OP_Insert, iStatCur, regTemp, regNewRowid);\n#ifdef SQLITE_ENABLE_PREUPDATE_HOOK\n    sqlite3VdbeChangeP4(v, -1, (char*)pStat1, P4_TABLE);\n#endif\n    sqlite3VdbeChangeP5(v, OPFLAG_APPEND);\n\n    /* Add the entries to the stat3 or stat4 table. */\n#ifdef SQLITE_ENABLE_STAT3_OR_STAT4\n    {\n      int regEq = regStat1;\n      int regLt = regStat1+1;\n      int regDLt = regStat1+2;\n      int regSample = regStat1+3;\n      int regCol = regStat1+4;\n      int regSampleRowid = regCol + nCol;\n      int addrNext;\n      int addrIsNull;\n      u8 seekOp = HasRowid(pTab) ? OP_NotExists : OP_NotFound;\n\n      pParse->nMem = MAX(pParse->nMem, regCol+nCol);\n\n      addrNext = sqlite3VdbeCurrentAddr(v);\n      callStatGet(v, regStat4, STAT_GET_ROWID, regSampleRowid);\n      addrIsNull = sqlite3VdbeAddOp1(v, OP_IsNull, regSampleRowid);\n      VdbeCoverage(v);\n      callStatGet(v, regStat4, STAT_GET_NEQ, regEq);\n      callStatGet(v, regStat4, STAT_GET_NLT, regLt);\n      callStatGet(v, regStat4, STAT_GET_NDLT, regDLt);\n      sqlite3VdbeAddOp4Int(v, seekOp, iTabCur, addrNext, regSampleRowid, 0);\n      VdbeCoverage(v);\n#ifdef SQLITE_ENABLE_STAT3\n      sqlite3ExprCodeLoadIndexColumn(pParse, pIdx, iTabCur, 0, regSample);\n#else\n      for(i=0; i<nCol; i++){\n        sqlite3ExprCodeLoadIndexColumn(pParse, pIdx, iTabCur, i, regCol+i);\n      }\n      sqlite3VdbeAddOp3(v, OP_MakeRecord, regCol, nCol, regSample);\n#endif\n      sqlite3VdbeAddOp3(v, OP_MakeRecord, regTabname, 6, regTemp);\n      sqlite3VdbeAddOp2(v, OP_NewRowid, iStatCur+1, regNewRowid);\n      sqlite3VdbeAddOp3(v, OP_Insert, iStatCur+1, regTemp, regNewRowid);\n      sqlite3VdbeAddOp2(v, OP_Goto, 1, addrNext); /* P1==1 for end-of-loop */\n      sqlite3VdbeJumpHere(v, addrIsNull);\n    }\n#endif /* SQLITE_ENABLE_STAT3_OR_STAT4 */\n\n    /* End of analysis */\n    sqlite3VdbeJumpHere(v, addrRewind);\n  }\n\n\n  /* Create a single sqlite_stat1 entry containing NULL as the index\n  ** name and the row count as the content.\n  */\n  if( pOnlyIdx==0 && needTableCnt ){\n    VdbeComment((v, \"%s\", pTab->zName));\n    sqlite3VdbeAddOp2(v, OP_Count, iTabCur, regStat1);\n    jZeroRows = sqlite3VdbeAddOp1(v, OP_IfNot, regStat1); VdbeCoverage(v);\n    sqlite3VdbeAddOp2(v, OP_Null, 0, regIdxname);\n    assert( \"BBB\"[0]==SQLITE_AFF_TEXT );\n    sqlite3VdbeAddOp4(v, OP_MakeRecord, regTabname, 3, regTemp, \"BBB\", 0);\n    sqlite3VdbeAddOp2(v, OP_NewRowid, iStatCur, regNewRowid);\n    sqlite3VdbeAddOp3(v, OP_Insert, iStatCur, regTemp, regNewRowid);\n    sqlite3VdbeChangeP5(v, OPFLAG_APPEND);\n#ifdef SQLITE_ENABLE_PREUPDATE_HOOK\n    sqlite3VdbeChangeP4(v, -1, (char*)pStat1, P4_TABLE);\n#endif\n    sqlite3VdbeJumpHere(v, jZeroRows);\n  }\n}\n\n\n/*\n** Generate code that will cause the most recent index analysis to\n** be loaded into internal hash tables where is can be used.\n*/\nstatic void loadAnalysis(Parse *pParse, int iDb){\n  Vdbe *v = sqlite3GetVdbe(pParse);\n  if( v ){\n    sqlite3VdbeAddOp1(v, OP_LoadAnalysis, iDb);\n  }\n}\n\n/*\n** Generate code that will do an analysis of an entire database\n*/\nstatic void analyzeDatabase(Parse *pParse, int iDb){\n  sqlite3 *db = pParse->db;\n  Schema *pSchema = db->aDb[iDb].pSchema;    /* Schema of database iDb */\n  HashElem *k;\n  int iStatCur;\n  int iMem;\n  int iTab;\n\n  sqlite3BeginWriteOperation(pParse, 0, iDb);\n  iStatCur = pParse->nTab;\n  pParse->nTab += 3;\n  openStatTable(pParse, iDb, iStatCur, 0, 0);\n  iMem = pParse->nMem+1;\n  iTab = pParse->nTab;\n  assert( sqlite3SchemaMutexHeld(db, iDb, 0) );\n  for(k=sqliteHashFirst(&pSchema->tblHash); k; k=sqliteHashNext(k)){\n    Table *pTab = (Table*)sqliteHashData(k);\n    analyzeOneTable(pParse, pTab, 0, iStatCur, iMem, iTab);\n  }\n  loadAnalysis(pParse, iDb);\n}\n\n/*\n** Generate code that will do an analysis of a single table in\n** a database.  If pOnlyIdx is not NULL then it is a single index\n** in pTab that should be analyzed.\n*/\nstatic void analyzeTable(Parse *pParse, Table *pTab, Index *pOnlyIdx){\n  int iDb;\n  int iStatCur;\n\n  assert( pTab!=0 );\n  assert( sqlite3BtreeHoldsAllMutexes(pParse->db) );\n  iDb = sqlite3SchemaToIndex(pParse->db, pTab->pSchema);\n  sqlite3BeginWriteOperation(pParse, 0, iDb);\n  iStatCur = pParse->nTab;\n  pParse->nTab += 3;\n  if( pOnlyIdx ){\n    openStatTable(pParse, iDb, iStatCur, pOnlyIdx->zName, \"idx\");\n  }else{\n    openStatTable(pParse, iDb, iStatCur, pTab->zName, \"tbl\");\n  }\n  analyzeOneTable(pParse, pTab, pOnlyIdx, iStatCur,pParse->nMem+1,pParse->nTab);\n  loadAnalysis(pParse, iDb);\n}\n\n/*\n** Generate code for the ANALYZE command.  The parser calls this routine\n** when it recognizes an ANALYZE command.\n**\n**        ANALYZE                            -- 1\n**        ANALYZE  <database>                -- 2\n**        ANALYZE  ?<database>.?<tablename>  -- 3\n**\n** Form 1 causes all indices in all attached databases to be analyzed.\n** Form 2 analyzes all indices the single database named.\n** Form 3 analyzes all indices associated with the named table.\n*/\nSQLITE_PRIVATE void sqlite3Analyze(Parse *pParse, Token *pName1, Token *pName2){\n  sqlite3 *db = pParse->db;\n  int iDb;\n  int i;\n  char *z, *zDb;\n  Table *pTab;\n  Index *pIdx;\n  Token *pTableName;\n  Vdbe *v;\n\n  /* Read the database schema. If an error occurs, leave an error message\n  ** and code in pParse and return NULL. */\n  assert( sqlite3BtreeHoldsAllMutexes(pParse->db) );\n  if( SQLITE_OK!=sqlite3ReadSchema(pParse) ){\n    return;\n  }\n\n  assert( pName2!=0 || pName1==0 );\n  if( pName1==0 ){\n    /* Form 1:  Analyze everything */\n    for(i=0; i<db->nDb; i++){\n      if( i==1 ) continue;  /* Do not analyze the TEMP database */\n      analyzeDatabase(pParse, i);\n    }\n  }else if( pName2->n==0 && (iDb = sqlite3FindDb(db, pName1))>=0 ){\n    /* Analyze the schema named as the argument */\n    analyzeDatabase(pParse, iDb);\n  }else{\n    /* Form 3: Analyze the table or index named as an argument */\n    iDb = sqlite3TwoPartName(pParse, pName1, pName2, &pTableName);\n    if( iDb>=0 ){\n      zDb = pName2->n ? db->aDb[iDb].zDbSName : 0;\n      z = sqlite3NameFromToken(db, pTableName);\n      if( z ){\n        if( (pIdx = sqlite3FindIndex(db, z, zDb))!=0 ){\n          analyzeTable(pParse, pIdx->pTable, pIdx);\n        }else if( (pTab = sqlite3LocateTable(pParse, 0, z, zDb))!=0 ){\n          analyzeTable(pParse, pTab, 0);\n        }\n        sqlite3DbFree(db, z);\n      }\n    }\n  }\n  if( db->nSqlExec==0 && (v = sqlite3GetVdbe(pParse))!=0 ){\n    sqlite3VdbeAddOp0(v, OP_Expire);\n  }\n}\n\n/*\n** Used to pass information from the analyzer reader through to the\n** callback routine.\n*/\ntypedef struct analysisInfo analysisInfo;\nstruct analysisInfo {\n  sqlite3 *db;\n  const char *zDatabase;\n};\n\n/*\n** The first argument points to a nul-terminated string containing a\n** list of space separated integers. Read the first nOut of these into\n** the array aOut[].\n*/\nstatic void decodeIntArray(\n  char *zIntArray,       /* String containing int array to decode */\n  int nOut,              /* Number of slots in aOut[] */\n  tRowcnt *aOut,         /* Store integers here */\n  LogEst *aLog,          /* Or, if aOut==0, here */\n  Index *pIndex          /* Handle extra flags for this index, if not NULL */\n){\n  char *z = zIntArray;\n  int c;\n  int i;\n  tRowcnt v;\n\n#ifdef SQLITE_ENABLE_STAT3_OR_STAT4\n  if( z==0 ) z = \"\";\n#else\n  assert( z!=0 );\n#endif\n  for(i=0; *z && i<nOut; i++){\n    v = 0;\n    while( (c=z[0])>='0' && c<='9' ){\n      v = v*10 + c - '0';\n      z++;\n    }\n#ifdef SQLITE_ENABLE_STAT3_OR_STAT4\n    if( aOut ) aOut[i] = v;\n    if( aLog ) aLog[i] = sqlite3LogEst(v);\n#else\n    assert( aOut==0 );\n    UNUSED_PARAMETER(aOut);\n    assert( aLog!=0 );\n    aLog[i] = sqlite3LogEst(v);\n#endif\n    if( *z==' ' ) z++;\n  }\n#ifndef SQLITE_ENABLE_STAT3_OR_STAT4\n  assert( pIndex!=0 ); {\n#else\n  if( pIndex ){\n#endif\n    pIndex->bUnordered = 0;\n    pIndex->noSkipScan = 0;\n    while( z[0] ){\n      if( sqlite3_strglob(\"unordered*\", z)==0 ){\n        pIndex->bUnordered = 1;\n      }else if( sqlite3_strglob(\"sz=[0-9]*\", z)==0 ){\n        pIndex->szIdxRow = sqlite3LogEst(sqlite3Atoi(z+3));\n      }else if( sqlite3_strglob(\"noskipscan*\", z)==0 ){\n        pIndex->noSkipScan = 1;\n      }\n#ifdef SQLITE_ENABLE_COSTMULT\n      else if( sqlite3_strglob(\"costmult=[0-9]*\",z)==0 ){\n        pIndex->pTable->costMult = sqlite3LogEst(sqlite3Atoi(z+9));\n      }\n#endif\n      while( z[0]!=0 && z[0]!=' ' ) z++;\n      while( z[0]==' ' ) z++;\n    }\n  }\n}\n\n/*\n** This callback is invoked once for each index when reading the\n** sqlite_stat1 table.  \n**\n**     argv[0] = name of the table\n**     argv[1] = name of the index (might be NULL)\n**     argv[2] = results of analysis - on integer for each column\n**\n** Entries for which argv[1]==NULL simply record the number of rows in\n** the table.\n*/\nstatic int analysisLoader(void *pData, int argc, char **argv, char **NotUsed){\n  analysisInfo *pInfo = (analysisInfo*)pData;\n  Index *pIndex;\n  Table *pTable;\n  const char *z;\n\n  assert( argc==3 );\n  UNUSED_PARAMETER2(NotUsed, argc);\n\n  if( argv==0 || argv[0]==0 || argv[2]==0 ){\n    return 0;\n  }\n  pTable = sqlite3FindTable(pInfo->db, argv[0], pInfo->zDatabase);\n  if( pTable==0 ){\n    return 0;\n  }\n  if( argv[1]==0 ){\n    pIndex = 0;\n  }else if( sqlite3_stricmp(argv[0],argv[1])==0 ){\n    pIndex = sqlite3PrimaryKeyIndex(pTable);\n  }else{\n    pIndex = sqlite3FindIndex(pInfo->db, argv[1], pInfo->zDatabase);\n  }\n  z = argv[2];\n\n  if( pIndex ){\n    tRowcnt *aiRowEst = 0;\n    int nCol = pIndex->nKeyCol+1;\n#ifdef SQLITE_ENABLE_STAT3_OR_STAT4\n    /* Index.aiRowEst may already be set here if there are duplicate \n    ** sqlite_stat1 entries for this index. In that case just clobber\n    ** the old data with the new instead of allocating a new array.  */\n    if( pIndex->aiRowEst==0 ){\n      pIndex->aiRowEst = (tRowcnt*)sqlite3MallocZero(sizeof(tRowcnt) * nCol);\n      if( pIndex->aiRowEst==0 ) sqlite3OomFault(pInfo->db);\n    }\n    aiRowEst = pIndex->aiRowEst;\n#endif\n    pIndex->bUnordered = 0;\n    decodeIntArray((char*)z, nCol, aiRowEst, pIndex->aiRowLogEst, pIndex);\n    pIndex->hasStat1 = 1;\n    if( pIndex->pPartIdxWhere==0 ){\n      pTable->nRowLogEst = pIndex->aiRowLogEst[0];\n      pTable->tabFlags |= TF_HasStat1;\n    }\n  }else{\n    Index fakeIdx;\n    fakeIdx.szIdxRow = pTable->szTabRow;\n#ifdef SQLITE_ENABLE_COSTMULT\n    fakeIdx.pTable = pTable;\n#endif\n    decodeIntArray((char*)z, 1, 0, &pTable->nRowLogEst, &fakeIdx);\n    pTable->szTabRow = fakeIdx.szIdxRow;\n    pTable->tabFlags |= TF_HasStat1;\n  }\n\n  return 0;\n}\n\n/*\n** If the Index.aSample variable is not NULL, delete the aSample[] array\n** and its contents.\n*/\nSQLITE_PRIVATE void sqlite3DeleteIndexSamples(sqlite3 *db, Index *pIdx){\n#ifdef SQLITE_ENABLE_STAT3_OR_STAT4\n  if( pIdx->aSample ){\n    int j;\n    for(j=0; j<pIdx->nSample; j++){\n      IndexSample *p = &pIdx->aSample[j];\n      sqlite3DbFree(db, p->p);\n    }\n    sqlite3DbFree(db, pIdx->aSample);\n  }\n  if( db && db->pnBytesFreed==0 ){\n    pIdx->nSample = 0;\n    pIdx->aSample = 0;\n  }\n#else\n  UNUSED_PARAMETER(db);\n  UNUSED_PARAMETER(pIdx);\n#endif /* SQLITE_ENABLE_STAT3_OR_STAT4 */\n}\n\n#ifdef SQLITE_ENABLE_STAT3_OR_STAT4\n/*\n** Populate the pIdx->aAvgEq[] array based on the samples currently\n** stored in pIdx->aSample[]. \n*/\nstatic void initAvgEq(Index *pIdx){\n  if( pIdx ){\n    IndexSample *aSample = pIdx->aSample;\n    IndexSample *pFinal = &aSample[pIdx->nSample-1];\n    int iCol;\n    int nCol = 1;\n    if( pIdx->nSampleCol>1 ){\n      /* If this is stat4 data, then calculate aAvgEq[] values for all\n      ** sample columns except the last. The last is always set to 1, as\n      ** once the trailing PK fields are considered all index keys are\n      ** unique.  */\n      nCol = pIdx->nSampleCol-1;\n      pIdx->aAvgEq[nCol] = 1;\n    }\n    for(iCol=0; iCol<nCol; iCol++){\n      int nSample = pIdx->nSample;\n      int i;                    /* Used to iterate through samples */\n      tRowcnt sumEq = 0;        /* Sum of the nEq values */\n      tRowcnt avgEq = 0;\n      tRowcnt nRow;             /* Number of rows in index */\n      i64 nSum100 = 0;          /* Number of terms contributing to sumEq */\n      i64 nDist100;             /* Number of distinct values in index */\n\n      if( !pIdx->aiRowEst || iCol>=pIdx->nKeyCol || pIdx->aiRowEst[iCol+1]==0 ){\n        nRow = pFinal->anLt[iCol];\n        nDist100 = (i64)100 * pFinal->anDLt[iCol];\n        nSample--;\n      }else{\n        nRow = pIdx->aiRowEst[0];\n        nDist100 = ((i64)100 * pIdx->aiRowEst[0]) / pIdx->aiRowEst[iCol+1];\n      }\n      pIdx->nRowEst0 = nRow;\n\n      /* Set nSum to the number of distinct (iCol+1) field prefixes that\n      ** occur in the stat4 table for this index. Set sumEq to the sum of \n      ** the nEq values for column iCol for the same set (adding the value \n      ** only once where there exist duplicate prefixes).  */\n      for(i=0; i<nSample; i++){\n        if( i==(pIdx->nSample-1)\n         || aSample[i].anDLt[iCol]!=aSample[i+1].anDLt[iCol] \n        ){\n          sumEq += aSample[i].anEq[iCol];\n          nSum100 += 100;\n        }\n      }\n\n      if( nDist100>nSum100 && sumEq<nRow ){\n        avgEq = ((i64)100 * (nRow - sumEq))/(nDist100 - nSum100);\n      }\n      if( avgEq==0 ) avgEq = 1;\n      pIdx->aAvgEq[iCol] = avgEq;\n    }\n  }\n}\n\n/*\n** Look up an index by name.  Or, if the name of a WITHOUT ROWID table\n** is supplied instead, find the PRIMARY KEY index for that table.\n*/\nstatic Index *findIndexOrPrimaryKey(\n  sqlite3 *db,\n  const char *zName,\n  const char *zDb\n){\n  Index *pIdx = sqlite3FindIndex(db, zName, zDb);\n  if( pIdx==0 ){\n    Table *pTab = sqlite3FindTable(db, zName, zDb);\n    if( pTab && !HasRowid(pTab) ) pIdx = sqlite3PrimaryKeyIndex(pTab);\n  }\n  return pIdx;\n}\n\n/*\n** Load the content from either the sqlite_stat4 or sqlite_stat3 table \n** into the relevant Index.aSample[] arrays.\n**\n** Arguments zSql1 and zSql2 must point to SQL statements that return\n** data equivalent to the following (statements are different for stat3,\n** see the caller of this function for details):\n**\n**    zSql1: SELECT idx,count(*) FROM %Q.sqlite_stat4 GROUP BY idx\n**    zSql2: SELECT idx,neq,nlt,ndlt,sample FROM %Q.sqlite_stat4\n**\n** where %Q is replaced with the database name before the SQL is executed.\n*/\nstatic int loadStatTbl(\n  sqlite3 *db,                  /* Database handle */\n  int bStat3,                   /* Assume single column records only */\n  const char *zSql1,            /* SQL statement 1 (see above) */\n  const char *zSql2,            /* SQL statement 2 (see above) */\n  const char *zDb               /* Database name (e.g. \"main\") */\n){\n  int rc;                       /* Result codes from subroutines */\n  sqlite3_stmt *pStmt = 0;      /* An SQL statement being run */\n  char *zSql;                   /* Text of the SQL statement */\n  Index *pPrevIdx = 0;          /* Previous index in the loop */\n  IndexSample *pSample;         /* A slot in pIdx->aSample[] */\n\n  assert( db->lookaside.bDisable );\n  zSql = sqlite3MPrintf(db, zSql1, zDb);\n  if( !zSql ){\n    return SQLITE_NOMEM_BKPT;\n  }\n  rc = sqlite3_prepare(db, zSql, -1, &pStmt, 0);\n  sqlite3DbFree(db, zSql);\n  if( rc ) return rc;\n\n  while( sqlite3_step(pStmt)==SQLITE_ROW ){\n    int nIdxCol = 1;              /* Number of columns in stat4 records */\n\n    char *zIndex;   /* Index name */\n    Index *pIdx;    /* Pointer to the index object */\n    int nSample;    /* Number of samples */\n    int nByte;      /* Bytes of space required */\n    int i;          /* Bytes of space required */\n    tRowcnt *pSpace;\n\n    zIndex = (char *)sqlite3_column_text(pStmt, 0);\n    if( zIndex==0 ) continue;\n    nSample = sqlite3_column_int(pStmt, 1);\n    pIdx = findIndexOrPrimaryKey(db, zIndex, zDb);\n    assert( pIdx==0 || bStat3 || pIdx->nSample==0 );\n    /* Index.nSample is non-zero at this point if data has already been\n    ** loaded from the stat4 table. In this case ignore stat3 data.  */\n    if( pIdx==0 || pIdx->nSample ) continue;\n    if( bStat3==0 ){\n      assert( !HasRowid(pIdx->pTable) || pIdx->nColumn==pIdx->nKeyCol+1 );\n      if( !HasRowid(pIdx->pTable) && IsPrimaryKeyIndex(pIdx) ){\n        nIdxCol = pIdx->nKeyCol;\n      }else{\n        nIdxCol = pIdx->nColumn;\n      }\n    }\n    pIdx->nSampleCol = nIdxCol;\n    nByte = sizeof(IndexSample) * nSample;\n    nByte += sizeof(tRowcnt) * nIdxCol * 3 * nSample;\n    nByte += nIdxCol * sizeof(tRowcnt);     /* Space for Index.aAvgEq[] */\n\n    pIdx->aSample = sqlite3DbMallocZero(db, nByte);\n    if( pIdx->aSample==0 ){\n      sqlite3_finalize(pStmt);\n      return SQLITE_NOMEM_BKPT;\n    }\n    pSpace = (tRowcnt*)&pIdx->aSample[nSample];\n    pIdx->aAvgEq = pSpace; pSpace += nIdxCol;\n    for(i=0; i<nSample; i++){\n      pIdx->aSample[i].anEq = pSpace; pSpace += nIdxCol;\n      pIdx->aSample[i].anLt = pSpace; pSpace += nIdxCol;\n      pIdx->aSample[i].anDLt = pSpace; pSpace += nIdxCol;\n    }\n    assert( ((u8*)pSpace)-nByte==(u8*)(pIdx->aSample) );\n  }\n  rc = sqlite3_finalize(pStmt);\n  if( rc ) return rc;\n\n  zSql = sqlite3MPrintf(db, zSql2, zDb);\n  if( !zSql ){\n    return SQLITE_NOMEM_BKPT;\n  }\n  rc = sqlite3_prepare(db, zSql, -1, &pStmt, 0);\n  sqlite3DbFree(db, zSql);\n  if( rc ) return rc;\n\n  while( sqlite3_step(pStmt)==SQLITE_ROW ){\n    char *zIndex;                 /* Index name */\n    Index *pIdx;                  /* Pointer to the index object */\n    int nCol = 1;                 /* Number of columns in index */\n\n    zIndex = (char *)sqlite3_column_text(pStmt, 0);\n    if( zIndex==0 ) continue;\n    pIdx = findIndexOrPrimaryKey(db, zIndex, zDb);\n    if( pIdx==0 ) continue;\n    /* This next condition is true if data has already been loaded from \n    ** the sqlite_stat4 table. In this case ignore stat3 data.  */\n    nCol = pIdx->nSampleCol;\n    if( bStat3 && nCol>1 ) continue;\n    if( pIdx!=pPrevIdx ){\n      initAvgEq(pPrevIdx);\n      pPrevIdx = pIdx;\n    }\n    pSample = &pIdx->aSample[pIdx->nSample];\n    decodeIntArray((char*)sqlite3_column_text(pStmt,1),nCol,pSample->anEq,0,0);\n    decodeIntArray((char*)sqlite3_column_text(pStmt,2),nCol,pSample->anLt,0,0);\n    decodeIntArray((char*)sqlite3_column_text(pStmt,3),nCol,pSample->anDLt,0,0);\n\n    /* Take a copy of the sample. Add two 0x00 bytes the end of the buffer.\n    ** This is in case the sample record is corrupted. In that case, the\n    ** sqlite3VdbeRecordCompare() may read up to two varints past the\n    ** end of the allocated buffer before it realizes it is dealing with\n    ** a corrupt record. Adding the two 0x00 bytes prevents this from causing\n    ** a buffer overread.  */\n    pSample->n = sqlite3_column_bytes(pStmt, 4);\n    pSample->p = sqlite3DbMallocZero(db, pSample->n + 2);\n    if( pSample->p==0 ){\n      sqlite3_finalize(pStmt);\n      return SQLITE_NOMEM_BKPT;\n    }\n    if( pSample->n ){\n      memcpy(pSample->p, sqlite3_column_blob(pStmt, 4), pSample->n);\n    }\n    pIdx->nSample++;\n  }\n  rc = sqlite3_finalize(pStmt);\n  if( rc==SQLITE_OK ) initAvgEq(pPrevIdx);\n  return rc;\n}\n\n/*\n** Load content from the sqlite_stat4 and sqlite_stat3 tables into \n** the Index.aSample[] arrays of all indices.\n*/\nstatic int loadStat4(sqlite3 *db, const char *zDb){\n  int rc = SQLITE_OK;             /* Result codes from subroutines */\n\n  assert( db->lookaside.bDisable );\n  if( sqlite3FindTable(db, \"sqlite_stat4\", zDb) ){\n    rc = loadStatTbl(db, 0,\n      \"SELECT idx,count(*) FROM %Q.sqlite_stat4 GROUP BY idx\", \n      \"SELECT idx,neq,nlt,ndlt,sample FROM %Q.sqlite_stat4\",\n      zDb\n    );\n  }\n\n  if( rc==SQLITE_OK && sqlite3FindTable(db, \"sqlite_stat3\", zDb) ){\n    rc = loadStatTbl(db, 1,\n      \"SELECT idx,count(*) FROM %Q.sqlite_stat3 GROUP BY idx\", \n      \"SELECT idx,neq,nlt,ndlt,sqlite_record(sample) FROM %Q.sqlite_stat3\",\n      zDb\n    );\n  }\n\n  return rc;\n}\n#endif /* SQLITE_ENABLE_STAT3_OR_STAT4 */\n\n/*\n** Load the content of the sqlite_stat1 and sqlite_stat3/4 tables. The\n** contents of sqlite_stat1 are used to populate the Index.aiRowEst[]\n** arrays. The contents of sqlite_stat3/4 are used to populate the\n** Index.aSample[] arrays.\n**\n** If the sqlite_stat1 table is not present in the database, SQLITE_ERROR\n** is returned. In this case, even if SQLITE_ENABLE_STAT3/4 was defined \n** during compilation and the sqlite_stat3/4 table is present, no data is \n** read from it.\n**\n** If SQLITE_ENABLE_STAT3/4 was defined during compilation and the \n** sqlite_stat4 table is not present in the database, SQLITE_ERROR is\n** returned. However, in this case, data is read from the sqlite_stat1\n** table (if it is present) before returning.\n**\n** If an OOM error occurs, this function always sets db->mallocFailed.\n** This means if the caller does not care about other errors, the return\n** code may be ignored.\n*/\nSQLITE_PRIVATE int sqlite3AnalysisLoad(sqlite3 *db, int iDb){\n  analysisInfo sInfo;\n  HashElem *i;\n  char *zSql;\n  int rc = SQLITE_OK;\n  Schema *pSchema = db->aDb[iDb].pSchema;\n\n  assert( iDb>=0 && iDb<db->nDb );\n  assert( db->aDb[iDb].pBt!=0 );\n\n  /* Clear any prior statistics */\n  assert( sqlite3SchemaMutexHeld(db, iDb, 0) );\n  for(i=sqliteHashFirst(&pSchema->tblHash); i; i=sqliteHashNext(i)){\n    Table *pTab = sqliteHashData(i);\n    pTab->tabFlags &= ~TF_HasStat1;\n  }\n  for(i=sqliteHashFirst(&pSchema->idxHash); i; i=sqliteHashNext(i)){\n    Index *pIdx = sqliteHashData(i);\n    pIdx->hasStat1 = 0;\n#ifdef SQLITE_ENABLE_STAT3_OR_STAT4\n    sqlite3DeleteIndexSamples(db, pIdx);\n    pIdx->aSample = 0;\n#endif\n  }\n\n  /* Load new statistics out of the sqlite_stat1 table */\n  sInfo.db = db;\n  sInfo.zDatabase = db->aDb[iDb].zDbSName;\n  if( sqlite3FindTable(db, \"sqlite_stat1\", sInfo.zDatabase)!=0 ){\n    zSql = sqlite3MPrintf(db, \n        \"SELECT tbl,idx,stat FROM %Q.sqlite_stat1\", sInfo.zDatabase);\n    if( zSql==0 ){\n      rc = SQLITE_NOMEM_BKPT;\n    }else{\n      rc = sqlite3_exec(db, zSql, analysisLoader, &sInfo, 0);\n      sqlite3DbFree(db, zSql);\n    }\n  }\n\n  /* Set appropriate defaults on all indexes not in the sqlite_stat1 table */\n  assert( sqlite3SchemaMutexHeld(db, iDb, 0) );\n  for(i=sqliteHashFirst(&pSchema->idxHash); i; i=sqliteHashNext(i)){\n    Index *pIdx = sqliteHashData(i);\n    if( !pIdx->hasStat1 ) sqlite3DefaultRowEst(pIdx);\n  }\n\n  /* Load the statistics from the sqlite_stat4 table. */\n#ifdef SQLITE_ENABLE_STAT3_OR_STAT4\n  if( rc==SQLITE_OK ){\n    db->lookaside.bDisable++;\n    rc = loadStat4(db, sInfo.zDatabase);\n    db->lookaside.bDisable--;\n  }\n  for(i=sqliteHashFirst(&pSchema->idxHash); i; i=sqliteHashNext(i)){\n    Index *pIdx = sqliteHashData(i);\n    sqlite3_free(pIdx->aiRowEst);\n    pIdx->aiRowEst = 0;\n  }\n#endif\n\n  if( rc==SQLITE_NOMEM ){\n    sqlite3OomFault(db);\n  }\n  return rc;\n}\n\n\n#endif /* SQLITE_OMIT_ANALYZE */\n\n/************** End of analyze.c *********************************************/\n/************** Begin file attach.c ******************************************/\n/*\n** 2003 April 6\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This file contains code used to implement the ATTACH and DETACH commands.\n*/\n/* #include \"sqliteInt.h\" */\n\n#ifndef SQLITE_OMIT_ATTACH\n/*\n** Resolve an expression that was part of an ATTACH or DETACH statement. This\n** is slightly different from resolving a normal SQL expression, because simple\n** identifiers are treated as strings, not possible column names or aliases.\n**\n** i.e. if the parser sees:\n**\n**     ATTACH DATABASE abc AS def\n**\n** it treats the two expressions as literal strings 'abc' and 'def' instead of\n** looking for columns of the same name.\n**\n** This only applies to the root node of pExpr, so the statement:\n**\n**     ATTACH DATABASE abc||def AS 'db2'\n**\n** will fail because neither abc or def can be resolved.\n*/\nstatic int resolveAttachExpr(NameContext *pName, Expr *pExpr)\n{\n  int rc = SQLITE_OK;\n  if( pExpr ){\n    if( pExpr->op!=TK_ID ){\n      rc = sqlite3ResolveExprNames(pName, pExpr);\n    }else{\n      pExpr->op = TK_STRING;\n    }\n  }\n  return rc;\n}\n\n/*\n** An SQL user-function registered to do the work of an ATTACH statement. The\n** three arguments to the function come directly from an attach statement:\n**\n**     ATTACH DATABASE x AS y KEY z\n**\n**     SELECT sqlite_attach(x, y, z)\n**\n** If the optional \"KEY z\" syntax is omitted, an SQL NULL is passed as the\n** third argument.\n**\n** If the db->init.reopenMemdb flags is set, then instead of attaching a\n** new database, close the database on db->init.iDb and reopen it as an\n** empty MemDB.\n*/\nstatic void attachFunc(\n  sqlite3_context *context,\n  int NotUsed,\n  sqlite3_value **argv\n){\n  int i;\n  int rc = 0;\n  sqlite3 *db = sqlite3_context_db_handle(context);\n  const char *zName;\n  const char *zFile;\n  char *zPath = 0;\n  char *zErr = 0;\n  unsigned int flags;\n  Db *aNew;                 /* New array of Db pointers */\n  Db *pNew;                 /* Db object for the newly attached database */\n  char *zErrDyn = 0;\n  sqlite3_vfs *pVfs;\n\n  UNUSED_PARAMETER(NotUsed);\n  zFile = (const char *)sqlite3_value_text(argv[0]);\n  zName = (const char *)sqlite3_value_text(argv[1]);\n  if( zFile==0 ) zFile = \"\";\n  if( zName==0 ) zName = \"\";\n\n#ifdef SQLITE_ENABLE_DESERIALIZE\n# define REOPEN_AS_MEMDB(db)  (db->init.reopenMemdb)\n#else\n# define REOPEN_AS_MEMDB(db)  (0)\n#endif\n\n  if( REOPEN_AS_MEMDB(db) ){\n    /* This is not a real ATTACH.  Instead, this routine is being called\n    ** from sqlite3_deserialize() to close database db->init.iDb and\n    ** reopen it as a MemDB */\n    pVfs = sqlite3_vfs_find(\"memdb\");\n    if( pVfs==0 ) return;\n    pNew = &db->aDb[db->init.iDb];\n    if( pNew->pBt ) sqlite3BtreeClose(pNew->pBt);\n    pNew->pBt = 0;\n    pNew->pSchema = 0;\n    rc = sqlite3BtreeOpen(pVfs, \"x\\0\", db, &pNew->pBt, 0, SQLITE_OPEN_MAIN_DB);\n  }else{\n    /* This is a real ATTACH\n    **\n    ** Check for the following errors:\n    **\n    **     * Too many attached databases,\n    **     * Transaction currently open\n    **     * Specified database name already being used.\n    */\n    if( db->nDb>=db->aLimit[SQLITE_LIMIT_ATTACHED]+2 ){\n      zErrDyn = sqlite3MPrintf(db, \"too many attached databases - max %d\", \n        db->aLimit[SQLITE_LIMIT_ATTACHED]\n      );\n      goto attach_error;\n    }\n    for(i=0; i<db->nDb; i++){\n      char *z = db->aDb[i].zDbSName;\n      assert( z && zName );\n      if( sqlite3StrICmp(z, zName)==0 ){\n        zErrDyn = sqlite3MPrintf(db, \"database %s is already in use\", zName);\n        goto attach_error;\n      }\n    }\n  \n    /* Allocate the new entry in the db->aDb[] array and initialize the schema\n    ** hash tables.\n    */\n    if( db->aDb==db->aDbStatic ){\n      aNew = sqlite3DbMallocRawNN(db, sizeof(db->aDb[0])*3 );\n      if( aNew==0 ) return;\n      memcpy(aNew, db->aDb, sizeof(db->aDb[0])*2);\n    }else{\n      aNew = sqlite3DbRealloc(db, db->aDb, sizeof(db->aDb[0])*(db->nDb+1) );\n      if( aNew==0 ) return;\n    }\n    db->aDb = aNew;\n    pNew = &db->aDb[db->nDb];\n    memset(pNew, 0, sizeof(*pNew));\n  \n    /* Open the database file. If the btree is successfully opened, use\n    ** it to obtain the database schema. At this point the schema may\n    ** or may not be initialized.\n    */\n    flags = db->openFlags;\n    rc = sqlite3ParseUri(db->pVfs->zName, zFile, &flags, &pVfs, &zPath, &zErr);\n    if( rc!=SQLITE_OK ){\n      if( rc==SQLITE_NOMEM ) sqlite3OomFault(db);\n      sqlite3_result_error(context, zErr, -1);\n      sqlite3_free(zErr);\n      return;\n    }\n    assert( pVfs );\n    flags |= SQLITE_OPEN_MAIN_DB;\n    rc = sqlite3BtreeOpen(pVfs, zPath, db, &pNew->pBt, 0, flags);\n    db->nDb++;\n    pNew->zDbSName = sqlite3DbStrDup(db, zName);\n  }\n  db->noSharedCache = 0;\n  if( rc==SQLITE_CONSTRAINT ){\n    rc = SQLITE_ERROR;\n    zErrDyn = sqlite3MPrintf(db, \"database is already attached\");\n  }else if( rc==SQLITE_OK ){\n    Pager *pPager;\n    pNew->pSchema = sqlite3SchemaGet(db, pNew->pBt);\n    if( !pNew->pSchema ){\n      rc = SQLITE_NOMEM_BKPT;\n    }else if( pNew->pSchema->file_format && pNew->pSchema->enc!=ENC(db) ){\n      zErrDyn = sqlite3MPrintf(db, \n        \"attached databases must use the same text encoding as main database\");\n      rc = SQLITE_ERROR;\n    }\n    sqlite3BtreeEnter(pNew->pBt);\n    pPager = sqlite3BtreePager(pNew->pBt);\n    sqlite3PagerLockingMode(pPager, db->dfltLockMode);\n    sqlite3BtreeSecureDelete(pNew->pBt,\n                             sqlite3BtreeSecureDelete(db->aDb[0].pBt,-1) );\n#ifndef SQLITE_OMIT_PAGER_PRAGMAS\n    sqlite3BtreeSetPagerFlags(pNew->pBt, (db->flags & PAGER_FLAGS_MASK));\n#endif\n    sqlite3BtreeLeave(pNew->pBt);\n  }\n  pNew->safety_level = SQLITE_DEFAULT_SYNCHRONOUS+1;\n  if( rc==SQLITE_OK && pNew->zDbSName==0 ){\n    rc = SQLITE_NOMEM_BKPT;\n  }\n\n\n#ifdef SQLITE_HAS_CODEC\n  if( rc==SQLITE_OK ){\n    extern int sqlite3CodecAttach(sqlite3*, int, const void*, int);\n    extern void sqlite3CodecGetKey(sqlite3*, int, void**, int*);\n    int nKey;\n    char *zKey;\n    int t = sqlite3_value_type(argv[2]);\n    switch( t ){\n      case SQLITE_INTEGER:\n      case SQLITE_FLOAT:\n        zErrDyn = sqlite3DbStrDup(db, \"Invalid key value\");\n        rc = SQLITE_ERROR;\n        break;\n        \n      case SQLITE_TEXT:\n      case SQLITE_BLOB:\n        nKey = sqlite3_value_bytes(argv[2]);\n        zKey = (char *)sqlite3_value_blob(argv[2]);\n        rc = sqlite3CodecAttach(db, db->nDb-1, zKey, nKey);\n        break;\n\n      case SQLITE_NULL:\n        /* No key specified.  Use the key from URI filename, or if none,\n        ** use the key from the main database. */\n        if( sqlite3CodecQueryParameters(db, zName, zPath)==0 ){\n          sqlite3CodecGetKey(db, 0, (void**)&zKey, &nKey);\n          if( nKey || sqlite3BtreeGetOptimalReserve(db->aDb[0].pBt)>0 ){\n            rc = sqlite3CodecAttach(db, db->nDb-1, zKey, nKey);\n          }\n        }\n        break;\n    }\n  }\n#endif\n  sqlite3_free( zPath );\n\n  /* If the file was opened successfully, read the schema for the new database.\n  ** If this fails, or if opening the file failed, then close the file and \n  ** remove the entry from the db->aDb[] array. i.e. put everything back the\n  ** way we found it.\n  */\n  if( rc==SQLITE_OK ){\n    sqlite3BtreeEnterAll(db);\n    db->init.iDb = 0;\n    db->mDbFlags &= ~(DBFLAG_SchemaKnownOk);\n    rc = sqlite3Init(db, &zErrDyn);\n    sqlite3BtreeLeaveAll(db);\n    assert( zErrDyn==0 || rc!=SQLITE_OK );\n  }\n#ifdef SQLITE_USER_AUTHENTICATION\n  if( rc==SQLITE_OK ){\n    u8 newAuth = 0;\n    rc = sqlite3UserAuthCheckLogin(db, zName, &newAuth);\n    if( newAuth<db->auth.authLevel ){\n      rc = SQLITE_AUTH_USER;\n    }\n  }\n#endif\n  if( rc ){\n    if( !REOPEN_AS_MEMDB(db) ){\n      int iDb = db->nDb - 1;\n      assert( iDb>=2 );\n      if( db->aDb[iDb].pBt ){\n        sqlite3BtreeClose(db->aDb[iDb].pBt);\n        db->aDb[iDb].pBt = 0;\n        db->aDb[iDb].pSchema = 0;\n      }\n      sqlite3ResetAllSchemasOfConnection(db);\n      db->nDb = iDb;\n      if( rc==SQLITE_NOMEM || rc==SQLITE_IOERR_NOMEM ){\n        sqlite3OomFault(db);\n        sqlite3DbFree(db, zErrDyn);\n        zErrDyn = sqlite3MPrintf(db, \"out of memory\");\n      }else if( zErrDyn==0 ){\n        zErrDyn = sqlite3MPrintf(db, \"unable to open database: %s\", zFile);\n      }\n    }\n    goto attach_error;\n  }\n  \n  return;\n\nattach_error:\n  /* Return an error if we get here */\n  if( zErrDyn ){\n    sqlite3_result_error(context, zErrDyn, -1);\n    sqlite3DbFree(db, zErrDyn);\n  }\n  if( rc ) sqlite3_result_error_code(context, rc);\n}\n\n/*\n** An SQL user-function registered to do the work of an DETACH statement. The\n** three arguments to the function come directly from a detach statement:\n**\n**     DETACH DATABASE x\n**\n**     SELECT sqlite_detach(x)\n*/\nstatic void detachFunc(\n  sqlite3_context *context,\n  int NotUsed,\n  sqlite3_value **argv\n){\n  const char *zName = (const char *)sqlite3_value_text(argv[0]);\n  sqlite3 *db = sqlite3_context_db_handle(context);\n  int i;\n  Db *pDb = 0;\n  char zErr[128];\n\n  UNUSED_PARAMETER(NotUsed);\n\n  if( zName==0 ) zName = \"\";\n  for(i=0; i<db->nDb; i++){\n    pDb = &db->aDb[i];\n    if( pDb->pBt==0 ) continue;\n    if( sqlite3StrICmp(pDb->zDbSName, zName)==0 ) break;\n  }\n\n  if( i>=db->nDb ){\n    sqlite3_snprintf(sizeof(zErr),zErr, \"no such database: %s\", zName);\n    goto detach_error;\n  }\n  if( i<2 ){\n    sqlite3_snprintf(sizeof(zErr),zErr, \"cannot detach database %s\", zName);\n    goto detach_error;\n  }\n  if( sqlite3BtreeIsInReadTrans(pDb->pBt) || sqlite3BtreeIsInBackup(pDb->pBt) ){\n    sqlite3_snprintf(sizeof(zErr),zErr, \"database %s is locked\", zName);\n    goto detach_error;\n  }\n\n  sqlite3BtreeClose(pDb->pBt);\n  pDb->pBt = 0;\n  pDb->pSchema = 0;\n  sqlite3CollapseDatabaseArray(db);\n  return;\n\ndetach_error:\n  sqlite3_result_error(context, zErr, -1);\n}\n\n/*\n** This procedure generates VDBE code for a single invocation of either the\n** sqlite_detach() or sqlite_attach() SQL user functions.\n*/\nstatic void codeAttach(\n  Parse *pParse,       /* The parser context */\n  int type,            /* Either SQLITE_ATTACH or SQLITE_DETACH */\n  FuncDef const *pFunc,/* FuncDef wrapper for detachFunc() or attachFunc() */\n  Expr *pAuthArg,      /* Expression to pass to authorization callback */\n  Expr *pFilename,     /* Name of database file */\n  Expr *pDbname,       /* Name of the database to use internally */\n  Expr *pKey           /* Database key for encryption extension */\n){\n  int rc;\n  NameContext sName;\n  Vdbe *v;\n  sqlite3* db = pParse->db;\n  int regArgs;\n\n  if( pParse->nErr ) goto attach_end;\n  memset(&sName, 0, sizeof(NameContext));\n  sName.pParse = pParse;\n\n  if( \n      SQLITE_OK!=(rc = resolveAttachExpr(&sName, pFilename)) ||\n      SQLITE_OK!=(rc = resolveAttachExpr(&sName, pDbname)) ||\n      SQLITE_OK!=(rc = resolveAttachExpr(&sName, pKey))\n  ){\n    goto attach_end;\n  }\n\n#ifndef SQLITE_OMIT_AUTHORIZATION\n  if( pAuthArg ){\n    char *zAuthArg;\n    if( pAuthArg->op==TK_STRING ){\n      zAuthArg = pAuthArg->u.zToken;\n    }else{\n      zAuthArg = 0;\n    }\n    rc = sqlite3AuthCheck(pParse, type, zAuthArg, 0, 0);\n    if(rc!=SQLITE_OK ){\n      goto attach_end;\n    }\n  }\n#endif /* SQLITE_OMIT_AUTHORIZATION */\n\n\n  v = sqlite3GetVdbe(pParse);\n  regArgs = sqlite3GetTempRange(pParse, 4);\n  sqlite3ExprCode(pParse, pFilename, regArgs);\n  sqlite3ExprCode(pParse, pDbname, regArgs+1);\n  sqlite3ExprCode(pParse, pKey, regArgs+2);\n\n  assert( v || db->mallocFailed );\n  if( v ){\n    sqlite3VdbeAddOp4(v, OP_Function0, 0, regArgs+3-pFunc->nArg, regArgs+3,\n                      (char *)pFunc, P4_FUNCDEF);\n    assert( pFunc->nArg==-1 || (pFunc->nArg&0xff)==pFunc->nArg );\n    sqlite3VdbeChangeP5(v, (u8)(pFunc->nArg));\n \n    /* Code an OP_Expire. For an ATTACH statement, set P1 to true (expire this\n    ** statement only). For DETACH, set it to false (expire all existing\n    ** statements).\n    */\n    sqlite3VdbeAddOp1(v, OP_Expire, (type==SQLITE_ATTACH));\n  }\n  \nattach_end:\n  sqlite3ExprDelete(db, pFilename);\n  sqlite3ExprDelete(db, pDbname);\n  sqlite3ExprDelete(db, pKey);\n}\n\n/*\n** Called by the parser to compile a DETACH statement.\n**\n**     DETACH pDbname\n*/\nSQLITE_PRIVATE void sqlite3Detach(Parse *pParse, Expr *pDbname){\n  static const FuncDef detach_func = {\n    1,                /* nArg */\n    SQLITE_UTF8,      /* funcFlags */\n    0,                /* pUserData */\n    0,                /* pNext */\n    detachFunc,       /* xSFunc */\n    0,                /* xFinalize */\n    0, 0,             /* xValue, xInverse */\n    \"sqlite_detach\",  /* zName */\n    {0}\n  };\n  codeAttach(pParse, SQLITE_DETACH, &detach_func, pDbname, 0, 0, pDbname);\n}\n\n/*\n** Called by the parser to compile an ATTACH statement.\n**\n**     ATTACH p AS pDbname KEY pKey\n*/\nSQLITE_PRIVATE void sqlite3Attach(Parse *pParse, Expr *p, Expr *pDbname, Expr *pKey){\n  static const FuncDef attach_func = {\n    3,                /* nArg */\n    SQLITE_UTF8,      /* funcFlags */\n    0,                /* pUserData */\n    0,                /* pNext */\n    attachFunc,       /* xSFunc */\n    0,                /* xFinalize */\n    0, 0,             /* xValue, xInverse */\n    \"sqlite_attach\",  /* zName */\n    {0}\n  };\n  codeAttach(pParse, SQLITE_ATTACH, &attach_func, p, p, pDbname, pKey);\n}\n#endif /* SQLITE_OMIT_ATTACH */\n\n/*\n** Initialize a DbFixer structure.  This routine must be called prior\n** to passing the structure to one of the sqliteFixAAAA() routines below.\n*/\nSQLITE_PRIVATE void sqlite3FixInit(\n  DbFixer *pFix,      /* The fixer to be initialized */\n  Parse *pParse,      /* Error messages will be written here */\n  int iDb,            /* This is the database that must be used */\n  const char *zType,  /* \"view\", \"trigger\", or \"index\" */\n  const Token *pName  /* Name of the view, trigger, or index */\n){\n  sqlite3 *db;\n\n  db = pParse->db;\n  assert( db->nDb>iDb );\n  pFix->pParse = pParse;\n  pFix->zDb = db->aDb[iDb].zDbSName;\n  pFix->pSchema = db->aDb[iDb].pSchema;\n  pFix->zType = zType;\n  pFix->pName = pName;\n  pFix->bVarOnly = (iDb==1);\n}\n\n/*\n** The following set of routines walk through the parse tree and assign\n** a specific database to all table references where the database name\n** was left unspecified in the original SQL statement.  The pFix structure\n** must have been initialized by a prior call to sqlite3FixInit().\n**\n** These routines are used to make sure that an index, trigger, or\n** view in one database does not refer to objects in a different database.\n** (Exception: indices, triggers, and views in the TEMP database are\n** allowed to refer to anything.)  If a reference is explicitly made\n** to an object in a different database, an error message is added to\n** pParse->zErrMsg and these routines return non-zero.  If everything\n** checks out, these routines return 0.\n*/\nSQLITE_PRIVATE int sqlite3FixSrcList(\n  DbFixer *pFix,       /* Context of the fixation */\n  SrcList *pList       /* The Source list to check and modify */\n){\n  int i;\n  const char *zDb;\n  struct SrcList_item *pItem;\n\n  if( NEVER(pList==0) ) return 0;\n  zDb = pFix->zDb;\n  for(i=0, pItem=pList->a; i<pList->nSrc; i++, pItem++){\n    if( pFix->bVarOnly==0 ){\n      if( pItem->zDatabase && sqlite3StrICmp(pItem->zDatabase, zDb) ){\n        sqlite3ErrorMsg(pFix->pParse,\n            \"%s %T cannot reference objects in database %s\",\n            pFix->zType, pFix->pName, pItem->zDatabase);\n        return 1;\n      }\n      sqlite3DbFree(pFix->pParse->db, pItem->zDatabase);\n      pItem->zDatabase = 0;\n      pItem->pSchema = pFix->pSchema;\n    }\n#if !defined(SQLITE_OMIT_VIEW) || !defined(SQLITE_OMIT_TRIGGER)\n    if( sqlite3FixSelect(pFix, pItem->pSelect) ) return 1;\n    if( sqlite3FixExpr(pFix, pItem->pOn) ) return 1;\n#endif\n    if( pItem->fg.isTabFunc && sqlite3FixExprList(pFix, pItem->u1.pFuncArg) ){\n      return 1;\n    }\n  }\n  return 0;\n}\n#if !defined(SQLITE_OMIT_VIEW) || !defined(SQLITE_OMIT_TRIGGER)\nSQLITE_PRIVATE int sqlite3FixSelect(\n  DbFixer *pFix,       /* Context of the fixation */\n  Select *pSelect      /* The SELECT statement to be fixed to one database */\n){\n  while( pSelect ){\n    if( sqlite3FixExprList(pFix, pSelect->pEList) ){\n      return 1;\n    }\n    if( sqlite3FixSrcList(pFix, pSelect->pSrc) ){\n      return 1;\n    }\n    if( sqlite3FixExpr(pFix, pSelect->pWhere) ){\n      return 1;\n    }\n    if( sqlite3FixExprList(pFix, pSelect->pGroupBy) ){\n      return 1;\n    }\n    if( sqlite3FixExpr(pFix, pSelect->pHaving) ){\n      return 1;\n    }\n    if( sqlite3FixExprList(pFix, pSelect->pOrderBy) ){\n      return 1;\n    }\n    if( sqlite3FixExpr(pFix, pSelect->pLimit) ){\n      return 1;\n    }\n    if( pSelect->pWith ){\n      int i;\n      for(i=0; i<pSelect->pWith->nCte; i++){\n        if( sqlite3FixSelect(pFix, pSelect->pWith->a[i].pSelect) ){\n          return 1;\n        }\n      }\n    }\n    pSelect = pSelect->pPrior;\n  }\n  return 0;\n}\nSQLITE_PRIVATE int sqlite3FixExpr(\n  DbFixer *pFix,     /* Context of the fixation */\n  Expr *pExpr        /* The expression to be fixed to one database */\n){\n  while( pExpr ){\n    if( pExpr->op==TK_VARIABLE ){\n      if( pFix->pParse->db->init.busy ){\n        pExpr->op = TK_NULL;\n      }else{\n        sqlite3ErrorMsg(pFix->pParse, \"%s cannot use variables\", pFix->zType);\n        return 1;\n      }\n    }\n    if( ExprHasProperty(pExpr, EP_TokenOnly|EP_Leaf) ) break;\n    if( ExprHasProperty(pExpr, EP_xIsSelect) ){\n      if( sqlite3FixSelect(pFix, pExpr->x.pSelect) ) return 1;\n    }else{\n      if( sqlite3FixExprList(pFix, pExpr->x.pList) ) return 1;\n    }\n    if( sqlite3FixExpr(pFix, pExpr->pRight) ){\n      return 1;\n    }\n    pExpr = pExpr->pLeft;\n  }\n  return 0;\n}\nSQLITE_PRIVATE int sqlite3FixExprList(\n  DbFixer *pFix,     /* Context of the fixation */\n  ExprList *pList    /* The expression to be fixed to one database */\n){\n  int i;\n  struct ExprList_item *pItem;\n  if( pList==0 ) return 0;\n  for(i=0, pItem=pList->a; i<pList->nExpr; i++, pItem++){\n    if( sqlite3FixExpr(pFix, pItem->pExpr) ){\n      return 1;\n    }\n  }\n  return 0;\n}\n#endif\n\n#ifndef SQLITE_OMIT_TRIGGER\nSQLITE_PRIVATE int sqlite3FixTriggerStep(\n  DbFixer *pFix,     /* Context of the fixation */\n  TriggerStep *pStep /* The trigger step be fixed to one database */\n){\n  while( pStep ){\n    if( sqlite3FixSelect(pFix, pStep->pSelect) ){\n      return 1;\n    }\n    if( sqlite3FixExpr(pFix, pStep->pWhere) ){\n      return 1;\n    }\n    if( sqlite3FixExprList(pFix, pStep->pExprList) ){\n      return 1;\n    }\n#ifndef SQLITE_OMIT_UPSERT\n    if( pStep->pUpsert ){\n      Upsert *pUp = pStep->pUpsert;\n      if( sqlite3FixExprList(pFix, pUp->pUpsertTarget)\n       || sqlite3FixExpr(pFix, pUp->pUpsertTargetWhere)\n       || sqlite3FixExprList(pFix, pUp->pUpsertSet)\n       || sqlite3FixExpr(pFix, pUp->pUpsertWhere)\n      ){\n        return 1;\n      }\n    }\n#endif\n    pStep = pStep->pNext;\n  }\n  return 0;\n}\n#endif\n\n/************** End of attach.c **********************************************/\n/************** Begin file auth.c ********************************************/\n/*\n** 2003 January 11\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This file contains code used to implement the sqlite3_set_authorizer()\n** API.  This facility is an optional feature of the library.  Embedded\n** systems that do not need this facility may omit it by recompiling\n** the library with -DSQLITE_OMIT_AUTHORIZATION=1\n*/\n/* #include \"sqliteInt.h\" */\n\n/*\n** All of the code in this file may be omitted by defining a single\n** macro.\n*/\n#ifndef SQLITE_OMIT_AUTHORIZATION\n\n/*\n** Set or clear the access authorization function.\n**\n** The access authorization function is be called during the compilation\n** phase to verify that the user has read and/or write access permission on\n** various fields of the database.  The first argument to the auth function\n** is a copy of the 3rd argument to this routine.  The second argument\n** to the auth function is one of these constants:\n**\n**       SQLITE_CREATE_INDEX\n**       SQLITE_CREATE_TABLE\n**       SQLITE_CREATE_TEMP_INDEX\n**       SQLITE_CREATE_TEMP_TABLE\n**       SQLITE_CREATE_TEMP_TRIGGER\n**       SQLITE_CREATE_TEMP_VIEW\n**       SQLITE_CREATE_TRIGGER\n**       SQLITE_CREATE_VIEW\n**       SQLITE_DELETE\n**       SQLITE_DROP_INDEX\n**       SQLITE_DROP_TABLE\n**       SQLITE_DROP_TEMP_INDEX\n**       SQLITE_DROP_TEMP_TABLE\n**       SQLITE_DROP_TEMP_TRIGGER\n**       SQLITE_DROP_TEMP_VIEW\n**       SQLITE_DROP_TRIGGER\n**       SQLITE_DROP_VIEW\n**       SQLITE_INSERT\n**       SQLITE_PRAGMA\n**       SQLITE_READ\n**       SQLITE_SELECT\n**       SQLITE_TRANSACTION\n**       SQLITE_UPDATE\n**\n** The third and fourth arguments to the auth function are the name of\n** the table and the column that are being accessed.  The auth function\n** should return either SQLITE_OK, SQLITE_DENY, or SQLITE_IGNORE.  If\n** SQLITE_OK is returned, it means that access is allowed.  SQLITE_DENY\n** means that the SQL statement will never-run - the sqlite3_exec() call\n** will return with an error.  SQLITE_IGNORE means that the SQL statement\n** should run but attempts to read the specified column will return NULL\n** and attempts to write the column will be ignored.\n**\n** Setting the auth function to NULL disables this hook.  The default\n** setting of the auth function is NULL.\n*/\nSQLITE_API int sqlite3_set_authorizer(\n  sqlite3 *db,\n  int (*xAuth)(void*,int,const char*,const char*,const char*,const char*),\n  void *pArg\n){\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( !sqlite3SafetyCheckOk(db) ) return SQLITE_MISUSE_BKPT;\n#endif\n  sqlite3_mutex_enter(db->mutex);\n  db->xAuth = (sqlite3_xauth)xAuth;\n  db->pAuthArg = pArg;\n  sqlite3ExpirePreparedStatements(db, 0);\n  sqlite3_mutex_leave(db->mutex);\n  return SQLITE_OK;\n}\n\n/*\n** Write an error message into pParse->zErrMsg that explains that the\n** user-supplied authorization function returned an illegal value.\n*/\nstatic void sqliteAuthBadReturnCode(Parse *pParse){\n  sqlite3ErrorMsg(pParse, \"authorizer malfunction\");\n  pParse->rc = SQLITE_ERROR;\n}\n\n/*\n** Invoke the authorization callback for permission to read column zCol from\n** table zTab in database zDb. This function assumes that an authorization\n** callback has been registered (i.e. that sqlite3.xAuth is not NULL).\n**\n** If SQLITE_IGNORE is returned and pExpr is not NULL, then pExpr is changed\n** to an SQL NULL expression. Otherwise, if pExpr is NULL, then SQLITE_IGNORE\n** is treated as SQLITE_DENY. In this case an error is left in pParse.\n*/\nSQLITE_PRIVATE int sqlite3AuthReadCol(\n  Parse *pParse,                  /* The parser context */\n  const char *zTab,               /* Table name */\n  const char *zCol,               /* Column name */\n  int iDb                         /* Index of containing database. */\n){\n  sqlite3 *db = pParse->db;          /* Database handle */\n  char *zDb = db->aDb[iDb].zDbSName; /* Schema name of attached database */\n  int rc;                            /* Auth callback return code */\n\n  if( db->init.busy ) return SQLITE_OK;\n  rc = db->xAuth(db->pAuthArg, SQLITE_READ, zTab,zCol,zDb,pParse->zAuthContext\n#ifdef SQLITE_USER_AUTHENTICATION\n                 ,db->auth.zAuthUser\n#endif\n                );\n  if( rc==SQLITE_DENY ){\n    char *z = sqlite3_mprintf(\"%s.%s\", zTab, zCol);\n    if( db->nDb>2 || iDb!=0 ) z = sqlite3_mprintf(\"%s.%z\", zDb, z);\n    sqlite3ErrorMsg(pParse, \"access to %z is prohibited\", z);\n    pParse->rc = SQLITE_AUTH;\n  }else if( rc!=SQLITE_IGNORE && rc!=SQLITE_OK ){\n    sqliteAuthBadReturnCode(pParse);\n  }\n  return rc;\n}\n\n/*\n** The pExpr should be a TK_COLUMN expression.  The table referred to\n** is in pTabList or else it is the NEW or OLD table of a trigger.  \n** Check to see if it is OK to read this particular column.\n**\n** If the auth function returns SQLITE_IGNORE, change the TK_COLUMN \n** instruction into a TK_NULL.  If the auth function returns SQLITE_DENY,\n** then generate an error.\n*/\nSQLITE_PRIVATE void sqlite3AuthRead(\n  Parse *pParse,        /* The parser context */\n  Expr *pExpr,          /* The expression to check authorization on */\n  Schema *pSchema,      /* The schema of the expression */\n  SrcList *pTabList     /* All table that pExpr might refer to */\n){\n  sqlite3 *db = pParse->db;\n  Table *pTab = 0;      /* The table being read */\n  const char *zCol;     /* Name of the column of the table */\n  int iSrc;             /* Index in pTabList->a[] of table being read */\n  int iDb;              /* The index of the database the expression refers to */\n  int iCol;             /* Index of column in table */\n\n  assert( pExpr->op==TK_COLUMN || pExpr->op==TK_TRIGGER );\n  assert( !IN_RENAME_OBJECT || db->xAuth==0 );\n  if( db->xAuth==0 ) return;\n  iDb = sqlite3SchemaToIndex(pParse->db, pSchema);\n  if( iDb<0 ){\n    /* An attempt to read a column out of a subquery or other\n    ** temporary table. */\n    return;\n  }\n\n  if( pExpr->op==TK_TRIGGER ){\n    pTab = pParse->pTriggerTab;\n  }else{\n    assert( pTabList );\n    for(iSrc=0; ALWAYS(iSrc<pTabList->nSrc); iSrc++){\n      if( pExpr->iTable==pTabList->a[iSrc].iCursor ){\n        pTab = pTabList->a[iSrc].pTab;\n        break;\n      }\n    }\n  }\n  iCol = pExpr->iColumn;\n  if( NEVER(pTab==0) ) return;\n\n  if( iCol>=0 ){\n    assert( iCol<pTab->nCol );\n    zCol = pTab->aCol[iCol].zName;\n  }else if( pTab->iPKey>=0 ){\n    assert( pTab->iPKey<pTab->nCol );\n    zCol = pTab->aCol[pTab->iPKey].zName;\n  }else{\n    zCol = \"ROWID\";\n  }\n  assert( iDb>=0 && iDb<db->nDb );\n  if( SQLITE_IGNORE==sqlite3AuthReadCol(pParse, pTab->zName, zCol, iDb) ){\n    pExpr->op = TK_NULL;\n  }\n}\n\n/*\n** Do an authorization check using the code and arguments given.  Return\n** either SQLITE_OK (zero) or SQLITE_IGNORE or SQLITE_DENY.  If SQLITE_DENY\n** is returned, then the error count and error message in pParse are\n** modified appropriately.\n*/\nSQLITE_PRIVATE int sqlite3AuthCheck(\n  Parse *pParse,\n  int code,\n  const char *zArg1,\n  const char *zArg2,\n  const char *zArg3\n){\n  sqlite3 *db = pParse->db;\n  int rc;\n\n  /* Don't do any authorization checks if the database is initialising\n  ** or if the parser is being invoked from within sqlite3_declare_vtab.\n  */\n  assert( !IN_RENAME_OBJECT || db->xAuth==0 );\n  if( db->init.busy || IN_SPECIAL_PARSE ){\n    return SQLITE_OK;\n  }\n\n  if( db->xAuth==0 ){\n    return SQLITE_OK;\n  }\n\n  /* EVIDENCE-OF: R-43249-19882 The third through sixth parameters to the\n  ** callback are either NULL pointers or zero-terminated strings that\n  ** contain additional details about the action to be authorized.\n  **\n  ** The following testcase() macros show that any of the 3rd through 6th\n  ** parameters can be either NULL or a string. */\n  testcase( zArg1==0 );\n  testcase( zArg2==0 );\n  testcase( zArg3==0 );\n  testcase( pParse->zAuthContext==0 );\n\n  rc = db->xAuth(db->pAuthArg, code, zArg1, zArg2, zArg3, pParse->zAuthContext\n#ifdef SQLITE_USER_AUTHENTICATION\n                 ,db->auth.zAuthUser\n#endif\n                );\n  if( rc==SQLITE_DENY ){\n    sqlite3ErrorMsg(pParse, \"not authorized\");\n    pParse->rc = SQLITE_AUTH;\n  }else if( rc!=SQLITE_OK && rc!=SQLITE_IGNORE ){\n    rc = SQLITE_DENY;\n    sqliteAuthBadReturnCode(pParse);\n  }\n  return rc;\n}\n\n/*\n** Push an authorization context.  After this routine is called, the\n** zArg3 argument to authorization callbacks will be zContext until\n** popped.  Or if pParse==0, this routine is a no-op.\n*/\nSQLITE_PRIVATE void sqlite3AuthContextPush(\n  Parse *pParse,\n  AuthContext *pContext, \n  const char *zContext\n){\n  assert( pParse );\n  pContext->pParse = pParse;\n  pContext->zAuthContext = pParse->zAuthContext;\n  pParse->zAuthContext = zContext;\n}\n\n/*\n** Pop an authorization context that was previously pushed\n** by sqlite3AuthContextPush\n*/\nSQLITE_PRIVATE void sqlite3AuthContextPop(AuthContext *pContext){\n  if( pContext->pParse ){\n    pContext->pParse->zAuthContext = pContext->zAuthContext;\n    pContext->pParse = 0;\n  }\n}\n\n#endif /* SQLITE_OMIT_AUTHORIZATION */\n\n/************** End of auth.c ************************************************/\n/************** Begin file build.c *******************************************/\n/*\n** 2001 September 15\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This file contains C code routines that are called by the SQLite parser\n** when syntax rules are reduced.  The routines in this file handle the\n** following kinds of SQL syntax:\n**\n**     CREATE TABLE\n**     DROP TABLE\n**     CREATE INDEX\n**     DROP INDEX\n**     creating ID lists\n**     BEGIN TRANSACTION\n**     COMMIT\n**     ROLLBACK\n*/\n/* #include \"sqliteInt.h\" */\n\n#ifndef SQLITE_OMIT_SHARED_CACHE\n/*\n** The TableLock structure is only used by the sqlite3TableLock() and\n** codeTableLocks() functions.\n*/\nstruct TableLock {\n  int iDb;               /* The database containing the table to be locked */\n  int iTab;              /* The root page of the table to be locked */\n  u8 isWriteLock;        /* True for write lock.  False for a read lock */\n  const char *zLockName; /* Name of the table */\n};\n\n/*\n** Record the fact that we want to lock a table at run-time.  \n**\n** The table to be locked has root page iTab and is found in database iDb.\n** A read or a write lock can be taken depending on isWritelock.\n**\n** This routine just records the fact that the lock is desired.  The\n** code to make the lock occur is generated by a later call to\n** codeTableLocks() which occurs during sqlite3FinishCoding().\n*/\nSQLITE_PRIVATE void sqlite3TableLock(\n  Parse *pParse,     /* Parsing context */\n  int iDb,           /* Index of the database containing the table to lock */\n  int iTab,          /* Root page number of the table to be locked */\n  u8 isWriteLock,    /* True for a write lock */\n  const char *zName  /* Name of the table to be locked */\n){\n  Parse *pToplevel = sqlite3ParseToplevel(pParse);\n  int i;\n  int nBytes;\n  TableLock *p;\n  assert( iDb>=0 );\n\n  if( iDb==1 ) return;\n  if( !sqlite3BtreeSharable(pParse->db->aDb[iDb].pBt) ) return;\n  for(i=0; i<pToplevel->nTableLock; i++){\n    p = &pToplevel->aTableLock[i];\n    if( p->iDb==iDb && p->iTab==iTab ){\n      p->isWriteLock = (p->isWriteLock || isWriteLock);\n      return;\n    }\n  }\n\n  nBytes = sizeof(TableLock) * (pToplevel->nTableLock+1);\n  pToplevel->aTableLock =\n      sqlite3DbReallocOrFree(pToplevel->db, pToplevel->aTableLock, nBytes);\n  if( pToplevel->aTableLock ){\n    p = &pToplevel->aTableLock[pToplevel->nTableLock++];\n    p->iDb = iDb;\n    p->iTab = iTab;\n    p->isWriteLock = isWriteLock;\n    p->zLockName = zName;\n  }else{\n    pToplevel->nTableLock = 0;\n    sqlite3OomFault(pToplevel->db);\n  }\n}\n\n/*\n** Code an OP_TableLock instruction for each table locked by the\n** statement (configured by calls to sqlite3TableLock()).\n*/\nstatic void codeTableLocks(Parse *pParse){\n  int i;\n  Vdbe *pVdbe; \n\n  pVdbe = sqlite3GetVdbe(pParse);\n  assert( pVdbe!=0 ); /* sqlite3GetVdbe cannot fail: VDBE already allocated */\n\n  for(i=0; i<pParse->nTableLock; i++){\n    TableLock *p = &pParse->aTableLock[i];\n    int p1 = p->iDb;\n    sqlite3VdbeAddOp4(pVdbe, OP_TableLock, p1, p->iTab, p->isWriteLock,\n                      p->zLockName, P4_STATIC);\n  }\n}\n#else\n  #define codeTableLocks(x)\n#endif\n\n/*\n** Return TRUE if the given yDbMask object is empty - if it contains no\n** 1 bits.  This routine is used by the DbMaskAllZero() and DbMaskNotZero()\n** macros when SQLITE_MAX_ATTACHED is greater than 30.\n*/\n#if SQLITE_MAX_ATTACHED>30\nSQLITE_PRIVATE int sqlite3DbMaskAllZero(yDbMask m){\n  int i;\n  for(i=0; i<sizeof(yDbMask); i++) if( m[i] ) return 0;\n  return 1;\n}\n#endif\n\n/*\n** This routine is called after a single SQL statement has been\n** parsed and a VDBE program to execute that statement has been\n** prepared.  This routine puts the finishing touches on the\n** VDBE program and resets the pParse structure for the next\n** parse.\n**\n** Note that if an error occurred, it might be the case that\n** no VDBE code was generated.\n*/\nSQLITE_PRIVATE void sqlite3FinishCoding(Parse *pParse){\n  sqlite3 *db;\n  Vdbe *v;\n\n  assert( pParse->pToplevel==0 );\n  db = pParse->db;\n  if( pParse->nested ) return;\n  if( db->mallocFailed || pParse->nErr ){\n    if( pParse->rc==SQLITE_OK ) pParse->rc = SQLITE_ERROR;\n    return;\n  }\n\n  /* Begin by generating some termination code at the end of the\n  ** vdbe program\n  */\n  v = sqlite3GetVdbe(pParse);\n  assert( !pParse->isMultiWrite \n       || sqlite3VdbeAssertMayAbort(v, pParse->mayAbort));\n  if( v ){\n    sqlite3VdbeAddOp0(v, OP_Halt);\n\n#if SQLITE_USER_AUTHENTICATION\n    if( pParse->nTableLock>0 && db->init.busy==0 ){\n      sqlite3UserAuthInit(db);\n      if( db->auth.authLevel<UAUTH_User ){\n        sqlite3ErrorMsg(pParse, \"user not authenticated\");\n        pParse->rc = SQLITE_AUTH_USER;\n        return;\n      }\n    }\n#endif\n\n    /* The cookie mask contains one bit for each database file open.\n    ** (Bit 0 is for main, bit 1 is for temp, and so forth.)  Bits are\n    ** set for each database that is used.  Generate code to start a\n    ** transaction on each used database and to verify the schema cookie\n    ** on each used database.\n    */\n    if( db->mallocFailed==0 \n     && (DbMaskNonZero(pParse->cookieMask) || pParse->pConstExpr)\n    ){\n      int iDb, i;\n      assert( sqlite3VdbeGetOp(v, 0)->opcode==OP_Init );\n      sqlite3VdbeJumpHere(v, 0);\n      for(iDb=0; iDb<db->nDb; iDb++){\n        Schema *pSchema;\n        if( DbMaskTest(pParse->cookieMask, iDb)==0 ) continue;\n        sqlite3VdbeUsesBtree(v, iDb);\n        pSchema = db->aDb[iDb].pSchema;\n        sqlite3VdbeAddOp4Int(v,\n          OP_Transaction,                    /* Opcode */\n          iDb,                               /* P1 */\n          DbMaskTest(pParse->writeMask,iDb), /* P2 */\n          pSchema->schema_cookie,            /* P3 */\n          pSchema->iGeneration               /* P4 */\n        );\n        if( db->init.busy==0 ) sqlite3VdbeChangeP5(v, 1);\n        VdbeComment((v,\n              \"usesStmtJournal=%d\", pParse->mayAbort && pParse->isMultiWrite));\n      }\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n      for(i=0; i<pParse->nVtabLock; i++){\n        char *vtab = (char *)sqlite3GetVTable(db, pParse->apVtabLock[i]);\n        sqlite3VdbeAddOp4(v, OP_VBegin, 0, 0, 0, vtab, P4_VTAB);\n      }\n      pParse->nVtabLock = 0;\n#endif\n\n      /* Once all the cookies have been verified and transactions opened, \n      ** obtain the required table-locks. This is a no-op unless the \n      ** shared-cache feature is enabled.\n      */\n      codeTableLocks(pParse);\n\n      /* Initialize any AUTOINCREMENT data structures required.\n      */\n      sqlite3AutoincrementBegin(pParse);\n\n      /* Code constant expressions that where factored out of inner loops */\n      if( pParse->pConstExpr ){\n        ExprList *pEL = pParse->pConstExpr;\n        pParse->okConstFactor = 0;\n        for(i=0; i<pEL->nExpr; i++){\n          sqlite3ExprCode(pParse, pEL->a[i].pExpr, pEL->a[i].u.iConstExprReg);\n        }\n      }\n\n      /* Finally, jump back to the beginning of the executable code. */\n      sqlite3VdbeGoto(v, 1);\n    }\n  }\n\n\n  /* Get the VDBE program ready for execution\n  */\n  if( v && pParse->nErr==0 && !db->mallocFailed ){\n    /* A minimum of one cursor is required if autoincrement is used\n    *  See ticket [a696379c1f08866] */\n    assert( pParse->pAinc==0 || pParse->nTab>0 );\n    sqlite3VdbeMakeReady(v, pParse);\n    pParse->rc = SQLITE_DONE;\n  }else{\n    pParse->rc = SQLITE_ERROR;\n  }\n}\n\n/*\n** Run the parser and code generator recursively in order to generate\n** code for the SQL statement given onto the end of the pParse context\n** currently under construction.  When the parser is run recursively\n** this way, the final OP_Halt is not appended and other initialization\n** and finalization steps are omitted because those are handling by the\n** outermost parser.\n**\n** Not everything is nestable.  This facility is designed to permit\n** INSERT, UPDATE, and DELETE operations against SQLITE_MASTER.  Use\n** care if you decide to try to use this routine for some other purposes.\n*/\nSQLITE_PRIVATE void sqlite3NestedParse(Parse *pParse, const char *zFormat, ...){\n  va_list ap;\n  char *zSql;\n  char *zErrMsg = 0;\n  sqlite3 *db = pParse->db;\n  char saveBuf[PARSE_TAIL_SZ];\n\n  if( pParse->nErr ) return;\n  assert( pParse->nested<10 );  /* Nesting should only be of limited depth */\n  va_start(ap, zFormat);\n  zSql = sqlite3VMPrintf(db, zFormat, ap);\n  va_end(ap);\n  if( zSql==0 ){\n    return;   /* A malloc must have failed */\n  }\n  pParse->nested++;\n  memcpy(saveBuf, PARSE_TAIL(pParse), PARSE_TAIL_SZ);\n  memset(PARSE_TAIL(pParse), 0, PARSE_TAIL_SZ);\n  sqlite3RunParser(pParse, zSql, &zErrMsg);\n  sqlite3DbFree(db, zErrMsg);\n  sqlite3DbFree(db, zSql);\n  memcpy(PARSE_TAIL(pParse), saveBuf, PARSE_TAIL_SZ);\n  pParse->nested--;\n}\n\n#if SQLITE_USER_AUTHENTICATION\n/*\n** Return TRUE if zTable is the name of the system table that stores the\n** list of users and their access credentials.\n*/\nSQLITE_PRIVATE int sqlite3UserAuthTable(const char *zTable){\n  return sqlite3_stricmp(zTable, \"sqlite_user\")==0;\n}\n#endif\n\n/*\n** Locate the in-memory structure that describes a particular database\n** table given the name of that table and (optionally) the name of the\n** database containing the table.  Return NULL if not found.\n**\n** If zDatabase is 0, all databases are searched for the table and the\n** first matching table is returned.  (No checking for duplicate table\n** names is done.)  The search order is TEMP first, then MAIN, then any\n** auxiliary databases added using the ATTACH command.\n**\n** See also sqlite3LocateTable().\n*/\nSQLITE_PRIVATE Table *sqlite3FindTable(sqlite3 *db, const char *zName, const char *zDatabase){\n  Table *p = 0;\n  int i;\n\n  /* All mutexes are required for schema access.  Make sure we hold them. */\n  assert( zDatabase!=0 || sqlite3BtreeHoldsAllMutexes(db) );\n#if SQLITE_USER_AUTHENTICATION\n  /* Only the admin user is allowed to know that the sqlite_user table\n  ** exists */\n  if( db->auth.authLevel<UAUTH_Admin && sqlite3UserAuthTable(zName)!=0 ){\n    return 0;\n  }\n#endif\n  while(1){\n    for(i=OMIT_TEMPDB; i<db->nDb; i++){\n      int j = (i<2) ? i^1 : i;   /* Search TEMP before MAIN */\n      if( zDatabase==0 || sqlite3StrICmp(zDatabase, db->aDb[j].zDbSName)==0 ){\n        assert( sqlite3SchemaMutexHeld(db, j, 0) );\n        p = sqlite3HashFind(&db->aDb[j].pSchema->tblHash, zName);\n        if( p ) return p;\n      }\n    }\n    /* Not found.  If the name we were looking for was temp.sqlite_master\n    ** then change the name to sqlite_temp_master and try again. */\n    if( sqlite3StrICmp(zName, MASTER_NAME)!=0 ) break;\n    if( sqlite3_stricmp(zDatabase, db->aDb[1].zDbSName)!=0 ) break;\n    zName = TEMP_MASTER_NAME;\n  }\n  return 0;\n}\n\n/*\n** Locate the in-memory structure that describes a particular database\n** table given the name of that table and (optionally) the name of the\n** database containing the table.  Return NULL if not found.  Also leave an\n** error message in pParse->zErrMsg.\n**\n** The difference between this routine and sqlite3FindTable() is that this\n** routine leaves an error message in pParse->zErrMsg where\n** sqlite3FindTable() does not.\n*/\nSQLITE_PRIVATE Table *sqlite3LocateTable(\n  Parse *pParse,         /* context in which to report errors */\n  u32 flags,             /* LOCATE_VIEW or LOCATE_NOERR */\n  const char *zName,     /* Name of the table we are looking for */\n  const char *zDbase     /* Name of the database.  Might be NULL */\n){\n  Table *p;\n  sqlite3 *db = pParse->db;\n\n  /* Read the database schema. If an error occurs, leave an error message\n  ** and code in pParse and return NULL. */\n  if( (db->mDbFlags & DBFLAG_SchemaKnownOk)==0 \n   && SQLITE_OK!=sqlite3ReadSchema(pParse)\n  ){\n    return 0;\n  }\n\n  p = sqlite3FindTable(db, zName, zDbase);\n  if( p==0 ){\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n    /* If zName is the not the name of a table in the schema created using\n    ** CREATE, then check to see if it is the name of an virtual table that\n    ** can be an eponymous virtual table. */\n    if( pParse->disableVtab==0 ){\n      Module *pMod = (Module*)sqlite3HashFind(&db->aModule, zName);\n      if( pMod==0 && sqlite3_strnicmp(zName, \"pragma_\", 7)==0 ){\n        pMod = sqlite3PragmaVtabRegister(db, zName);\n      }\n      if( pMod && sqlite3VtabEponymousTableInit(pParse, pMod) ){\n        return pMod->pEpoTab;\n      }\n    }\n#endif\n    if( flags & LOCATE_NOERR ) return 0;\n    pParse->checkSchema = 1;\n  }else if( IsVirtual(p) && pParse->disableVtab ){\n    p = 0;\n  }\n\n  if( p==0 ){\n    const char *zMsg = flags & LOCATE_VIEW ? \"no such view\" : \"no such table\";\n    if( zDbase ){\n      sqlite3ErrorMsg(pParse, \"%s: %s.%s\", zMsg, zDbase, zName);\n    }else{\n      sqlite3ErrorMsg(pParse, \"%s: %s\", zMsg, zName);\n    }\n  }\n\n  return p;\n}\n\n/*\n** Locate the table identified by *p.\n**\n** This is a wrapper around sqlite3LocateTable(). The difference between\n** sqlite3LocateTable() and this function is that this function restricts\n** the search to schema (p->pSchema) if it is not NULL. p->pSchema may be\n** non-NULL if it is part of a view or trigger program definition. See\n** sqlite3FixSrcList() for details.\n*/\nSQLITE_PRIVATE Table *sqlite3LocateTableItem(\n  Parse *pParse, \n  u32 flags,\n  struct SrcList_item *p\n){\n  const char *zDb;\n  assert( p->pSchema==0 || p->zDatabase==0 );\n  if( p->pSchema ){\n    int iDb = sqlite3SchemaToIndex(pParse->db, p->pSchema);\n    zDb = pParse->db->aDb[iDb].zDbSName;\n  }else{\n    zDb = p->zDatabase;\n  }\n  return sqlite3LocateTable(pParse, flags, p->zName, zDb);\n}\n\n/*\n** Locate the in-memory structure that describes \n** a particular index given the name of that index\n** and the name of the database that contains the index.\n** Return NULL if not found.\n**\n** If zDatabase is 0, all databases are searched for the\n** table and the first matching index is returned.  (No checking\n** for duplicate index names is done.)  The search order is\n** TEMP first, then MAIN, then any auxiliary databases added\n** using the ATTACH command.\n*/\nSQLITE_PRIVATE Index *sqlite3FindIndex(sqlite3 *db, const char *zName, const char *zDb){\n  Index *p = 0;\n  int i;\n  /* All mutexes are required for schema access.  Make sure we hold them. */\n  assert( zDb!=0 || sqlite3BtreeHoldsAllMutexes(db) );\n  for(i=OMIT_TEMPDB; i<db->nDb; i++){\n    int j = (i<2) ? i^1 : i;  /* Search TEMP before MAIN */\n    Schema *pSchema = db->aDb[j].pSchema;\n    assert( pSchema );\n    if( zDb && sqlite3StrICmp(zDb, db->aDb[j].zDbSName) ) continue;\n    assert( sqlite3SchemaMutexHeld(db, j, 0) );\n    p = sqlite3HashFind(&pSchema->idxHash, zName);\n    if( p ) break;\n  }\n  return p;\n}\n\n/*\n** Reclaim the memory used by an index\n*/\nSQLITE_PRIVATE void sqlite3FreeIndex(sqlite3 *db, Index *p){\n#ifndef SQLITE_OMIT_ANALYZE\n  sqlite3DeleteIndexSamples(db, p);\n#endif\n  sqlite3ExprDelete(db, p->pPartIdxWhere);\n  sqlite3ExprListDelete(db, p->aColExpr);\n  sqlite3DbFree(db, p->zColAff);\n  if( p->isResized ) sqlite3DbFree(db, (void *)p->azColl);\n#ifdef SQLITE_ENABLE_STAT3_OR_STAT4\n  sqlite3_free(p->aiRowEst);\n#endif\n  sqlite3DbFree(db, p);\n}\n\n/*\n** For the index called zIdxName which is found in the database iDb,\n** unlike that index from its Table then remove the index from\n** the index hash table and free all memory structures associated\n** with the index.\n*/\nSQLITE_PRIVATE void sqlite3UnlinkAndDeleteIndex(sqlite3 *db, int iDb, const char *zIdxName){\n  Index *pIndex;\n  Hash *pHash;\n\n  assert( sqlite3SchemaMutexHeld(db, iDb, 0) );\n  pHash = &db->aDb[iDb].pSchema->idxHash;\n  pIndex = sqlite3HashInsert(pHash, zIdxName, 0);\n  if( ALWAYS(pIndex) ){\n    if( pIndex->pTable->pIndex==pIndex ){\n      pIndex->pTable->pIndex = pIndex->pNext;\n    }else{\n      Index *p;\n      /* Justification of ALWAYS();  The index must be on the list of\n      ** indices. */\n      p = pIndex->pTable->pIndex;\n      while( ALWAYS(p) && p->pNext!=pIndex ){ p = p->pNext; }\n      if( ALWAYS(p && p->pNext==pIndex) ){\n        p->pNext = pIndex->pNext;\n      }\n    }\n    sqlite3FreeIndex(db, pIndex);\n  }\n  db->mDbFlags |= DBFLAG_SchemaChange;\n}\n\n/*\n** Look through the list of open database files in db->aDb[] and if\n** any have been closed, remove them from the list.  Reallocate the\n** db->aDb[] structure to a smaller size, if possible.\n**\n** Entry 0 (the \"main\" database) and entry 1 (the \"temp\" database)\n** are never candidates for being collapsed.\n*/\nSQLITE_PRIVATE void sqlite3CollapseDatabaseArray(sqlite3 *db){\n  int i, j;\n  for(i=j=2; i<db->nDb; i++){\n    struct Db *pDb = &db->aDb[i];\n    if( pDb->pBt==0 ){\n      sqlite3DbFree(db, pDb->zDbSName);\n      pDb->zDbSName = 0;\n      continue;\n    }\n    if( j<i ){\n      db->aDb[j] = db->aDb[i];\n    }\n    j++;\n  }\n  db->nDb = j;\n  if( db->nDb<=2 && db->aDb!=db->aDbStatic ){\n    memcpy(db->aDbStatic, db->aDb, 2*sizeof(db->aDb[0]));\n    sqlite3DbFree(db, db->aDb);\n    db->aDb = db->aDbStatic;\n  }\n}\n\n/*\n** Reset the schema for the database at index iDb.  Also reset the\n** TEMP schema.  The reset is deferred if db->nSchemaLock is not zero.\n** Deferred resets may be run by calling with iDb<0.\n*/\nSQLITE_PRIVATE void sqlite3ResetOneSchema(sqlite3 *db, int iDb){\n  int i;\n  assert( iDb<db->nDb );\n\n  if( iDb>=0 ){\n    assert( sqlite3SchemaMutexHeld(db, iDb, 0) );\n    DbSetProperty(db, iDb, DB_ResetWanted);\n    DbSetProperty(db, 1, DB_ResetWanted);\n    db->mDbFlags &= ~DBFLAG_SchemaKnownOk;\n  }\n\n  if( db->nSchemaLock==0 ){\n    for(i=0; i<db->nDb; i++){\n      if( DbHasProperty(db, i, DB_ResetWanted) ){\n        sqlite3SchemaClear(db->aDb[i].pSchema);\n      }\n    }\n  }\n}\n\n/*\n** Erase all schema information from all attached databases (including\n** \"main\" and \"temp\") for a single database connection.\n*/\nSQLITE_PRIVATE void sqlite3ResetAllSchemasOfConnection(sqlite3 *db){\n  int i;\n  sqlite3BtreeEnterAll(db);\n  for(i=0; i<db->nDb; i++){\n    Db *pDb = &db->aDb[i];\n    if( pDb->pSchema ){\n      if( db->nSchemaLock==0 ){\n        sqlite3SchemaClear(pDb->pSchema);\n      }else{\n        DbSetProperty(db, i, DB_ResetWanted);\n      }\n    }\n  }\n  db->mDbFlags &= ~(DBFLAG_SchemaChange|DBFLAG_SchemaKnownOk);\n  sqlite3VtabUnlockList(db);\n  sqlite3BtreeLeaveAll(db);\n  if( db->nSchemaLock==0 ){\n    sqlite3CollapseDatabaseArray(db);\n  }\n}\n\n/*\n** This routine is called when a commit occurs.\n*/\nSQLITE_PRIVATE void sqlite3CommitInternalChanges(sqlite3 *db){\n  db->mDbFlags &= ~DBFLAG_SchemaChange;\n}\n\n/*\n** Delete memory allocated for the column names of a table or view (the\n** Table.aCol[] array).\n*/\nSQLITE_PRIVATE void sqlite3DeleteColumnNames(sqlite3 *db, Table *pTable){\n  int i;\n  Column *pCol;\n  assert( pTable!=0 );\n  if( (pCol = pTable->aCol)!=0 ){\n    for(i=0; i<pTable->nCol; i++, pCol++){\n      sqlite3DbFree(db, pCol->zName);\n      sqlite3ExprDelete(db, pCol->pDflt);\n      sqlite3DbFree(db, pCol->zColl);\n    }\n    sqlite3DbFree(db, pTable->aCol);\n  }\n}\n\n/*\n** Remove the memory data structures associated with the given\n** Table.  No changes are made to disk by this routine.\n**\n** This routine just deletes the data structure.  It does not unlink\n** the table data structure from the hash table.  But it does destroy\n** memory structures of the indices and foreign keys associated with \n** the table.\n**\n** The db parameter is optional.  It is needed if the Table object \n** contains lookaside memory.  (Table objects in the schema do not use\n** lookaside memory, but some ephemeral Table objects do.)  Or the\n** db parameter can be used with db->pnBytesFreed to measure the memory\n** used by the Table object.\n*/\nstatic void SQLITE_NOINLINE deleteTable(sqlite3 *db, Table *pTable){\n  Index *pIndex, *pNext;\n\n#ifdef SQLITE_DEBUG\n  /* Record the number of outstanding lookaside allocations in schema Tables\n  ** prior to doing any free() operations.  Since schema Tables do not use\n  ** lookaside, this number should not change. */\n  int nLookaside = 0;\n  if( db && (pTable->tabFlags & TF_Ephemeral)==0 ){\n    nLookaside = sqlite3LookasideUsed(db, 0);\n  }\n#endif\n\n  /* Delete all indices associated with this table. */\n  for(pIndex = pTable->pIndex; pIndex; pIndex=pNext){\n    pNext = pIndex->pNext;\n    assert( pIndex->pSchema==pTable->pSchema\n         || (IsVirtual(pTable) && pIndex->idxType!=SQLITE_IDXTYPE_APPDEF) );\n    if( (db==0 || db->pnBytesFreed==0) && !IsVirtual(pTable) ){\n      char *zName = pIndex->zName; \n      TESTONLY ( Index *pOld = ) sqlite3HashInsert(\n         &pIndex->pSchema->idxHash, zName, 0\n      );\n      assert( db==0 || sqlite3SchemaMutexHeld(db, 0, pIndex->pSchema) );\n      assert( pOld==pIndex || pOld==0 );\n    }\n    sqlite3FreeIndex(db, pIndex);\n  }\n\n  /* Delete any foreign keys attached to this table. */\n  sqlite3FkDelete(db, pTable);\n\n  /* Delete the Table structure itself.\n  */\n  sqlite3DeleteColumnNames(db, pTable);\n  sqlite3DbFree(db, pTable->zName);\n  sqlite3DbFree(db, pTable->zColAff);\n  sqlite3SelectDelete(db, pTable->pSelect);\n  sqlite3ExprListDelete(db, pTable->pCheck);\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n  sqlite3VtabClear(db, pTable);\n#endif\n  sqlite3DbFree(db, pTable);\n\n  /* Verify that no lookaside memory was used by schema tables */\n  assert( nLookaside==0 || nLookaside==sqlite3LookasideUsed(db,0) );\n}\nSQLITE_PRIVATE void sqlite3DeleteTable(sqlite3 *db, Table *pTable){\n  /* Do not delete the table until the reference count reaches zero. */\n  if( !pTable ) return;\n  if( ((!db || db->pnBytesFreed==0) && (--pTable->nTabRef)>0) ) return;\n  deleteTable(db, pTable);\n}\n\n\n/*\n** Unlink the given table from the hash tables and the delete the\n** table structure with all its indices and foreign keys.\n*/\nSQLITE_PRIVATE void sqlite3UnlinkAndDeleteTable(sqlite3 *db, int iDb, const char *zTabName){\n  Table *p;\n  Db *pDb;\n\n  assert( db!=0 );\n  assert( iDb>=0 && iDb<db->nDb );\n  assert( zTabName );\n  assert( sqlite3SchemaMutexHeld(db, iDb, 0) );\n  testcase( zTabName[0]==0 );  /* Zero-length table names are allowed */\n  pDb = &db->aDb[iDb];\n  p = sqlite3HashInsert(&pDb->pSchema->tblHash, zTabName, 0);\n  sqlite3DeleteTable(db, p);\n  db->mDbFlags |= DBFLAG_SchemaChange;\n}\n\n/*\n** Given a token, return a string that consists of the text of that\n** token.  Space to hold the returned string\n** is obtained from sqliteMalloc() and must be freed by the calling\n** function.\n**\n** Any quotation marks (ex:  \"name\", 'name', [name], or `name`) that\n** surround the body of the token are removed.\n**\n** Tokens are often just pointers into the original SQL text and so\n** are not \\000 terminated and are not persistent.  The returned string\n** is \\000 terminated and is persistent.\n*/\nSQLITE_PRIVATE char *sqlite3NameFromToken(sqlite3 *db, Token *pName){\n  char *zName;\n  if( pName ){\n    zName = sqlite3DbStrNDup(db, (char*)pName->z, pName->n);\n    sqlite3Dequote(zName);\n  }else{\n    zName = 0;\n  }\n  return zName;\n}\n\n/*\n** Open the sqlite_master table stored in database number iDb for\n** writing. The table is opened using cursor 0.\n*/\nSQLITE_PRIVATE void sqlite3OpenMasterTable(Parse *p, int iDb){\n  Vdbe *v = sqlite3GetVdbe(p);\n  sqlite3TableLock(p, iDb, MASTER_ROOT, 1, MASTER_NAME);\n  sqlite3VdbeAddOp4Int(v, OP_OpenWrite, 0, MASTER_ROOT, iDb, 5);\n  if( p->nTab==0 ){\n    p->nTab = 1;\n  }\n}\n\n/*\n** Parameter zName points to a nul-terminated buffer containing the name\n** of a database (\"main\", \"temp\" or the name of an attached db). This\n** function returns the index of the named database in db->aDb[], or\n** -1 if the named db cannot be found.\n*/\nSQLITE_PRIVATE int sqlite3FindDbName(sqlite3 *db, const char *zName){\n  int i = -1;         /* Database number */\n  if( zName ){\n    Db *pDb;\n    for(i=(db->nDb-1), pDb=&db->aDb[i]; i>=0; i--, pDb--){\n      if( 0==sqlite3_stricmp(pDb->zDbSName, zName) ) break;\n      /* \"main\" is always an acceptable alias for the primary database\n      ** even if it has been renamed using SQLITE_DBCONFIG_MAINDBNAME. */\n      if( i==0 && 0==sqlite3_stricmp(\"main\", zName) ) break;\n    }\n  }\n  return i;\n}\n\n/*\n** The token *pName contains the name of a database (either \"main\" or\n** \"temp\" or the name of an attached db). This routine returns the\n** index of the named database in db->aDb[], or -1 if the named db \n** does not exist.\n*/\nSQLITE_PRIVATE int sqlite3FindDb(sqlite3 *db, Token *pName){\n  int i;                               /* Database number */\n  char *zName;                         /* Name we are searching for */\n  zName = sqlite3NameFromToken(db, pName);\n  i = sqlite3FindDbName(db, zName);\n  sqlite3DbFree(db, zName);\n  return i;\n}\n\n/* The table or view or trigger name is passed to this routine via tokens\n** pName1 and pName2. If the table name was fully qualified, for example:\n**\n** CREATE TABLE xxx.yyy (...);\n** \n** Then pName1 is set to \"xxx\" and pName2 \"yyy\". On the other hand if\n** the table name is not fully qualified, i.e.:\n**\n** CREATE TABLE yyy(...);\n**\n** Then pName1 is set to \"yyy\" and pName2 is \"\".\n**\n** This routine sets the *ppUnqual pointer to point at the token (pName1 or\n** pName2) that stores the unqualified table name.  The index of the\n** database \"xxx\" is returned.\n*/\nSQLITE_PRIVATE int sqlite3TwoPartName(\n  Parse *pParse,      /* Parsing and code generating context */\n  Token *pName1,      /* The \"xxx\" in the name \"xxx.yyy\" or \"xxx\" */\n  Token *pName2,      /* The \"yyy\" in the name \"xxx.yyy\" */\n  Token **pUnqual     /* Write the unqualified object name here */\n){\n  int iDb;                    /* Database holding the object */\n  sqlite3 *db = pParse->db;\n\n  assert( pName2!=0 );\n  if( pName2->n>0 ){\n    if( db->init.busy ) {\n      sqlite3ErrorMsg(pParse, \"corrupt database\");\n      return -1;\n    }\n    *pUnqual = pName2;\n    iDb = sqlite3FindDb(db, pName1);\n    if( iDb<0 ){\n      sqlite3ErrorMsg(pParse, \"unknown database %T\", pName1);\n      return -1;\n    }\n  }else{\n    assert( db->init.iDb==0 || db->init.busy || IN_RENAME_OBJECT\n             || (db->mDbFlags & DBFLAG_Vacuum)!=0);\n    iDb = db->init.iDb;\n    *pUnqual = pName1;\n  }\n  return iDb;\n}\n\n/*\n** True if PRAGMA writable_schema is ON\n*/\nSQLITE_PRIVATE int sqlite3WritableSchema(sqlite3 *db){\n  testcase( (db->flags&(SQLITE_WriteSchema|SQLITE_Defensive))==0 );\n  testcase( (db->flags&(SQLITE_WriteSchema|SQLITE_Defensive))==\n               SQLITE_WriteSchema );\n  testcase( (db->flags&(SQLITE_WriteSchema|SQLITE_Defensive))==\n               SQLITE_Defensive );\n  testcase( (db->flags&(SQLITE_WriteSchema|SQLITE_Defensive))==\n               (SQLITE_WriteSchema|SQLITE_Defensive) );\n  return (db->flags&(SQLITE_WriteSchema|SQLITE_Defensive))==SQLITE_WriteSchema;\n}\n\n/*\n** This routine is used to check if the UTF-8 string zName is a legal\n** unqualified name for a new schema object (table, index, view or\n** trigger). All names are legal except those that begin with the string\n** \"sqlite_\" (in upper, lower or mixed case). This portion of the namespace\n** is reserved for internal use.\n*/\nSQLITE_PRIVATE int sqlite3CheckObjectName(Parse *pParse, const char *zName){\n  if( !pParse->db->init.busy && pParse->nested==0 \n          && sqlite3WritableSchema(pParse->db)==0\n          && 0==sqlite3StrNICmp(zName, \"sqlite_\", 7) ){\n    sqlite3ErrorMsg(pParse, \"object name reserved for internal use: %s\", zName);\n    return SQLITE_ERROR;\n  }\n  return SQLITE_OK;\n}\n\n/*\n** Return the PRIMARY KEY index of a table\n*/\nSQLITE_PRIVATE Index *sqlite3PrimaryKeyIndex(Table *pTab){\n  Index *p;\n  for(p=pTab->pIndex; p && !IsPrimaryKeyIndex(p); p=p->pNext){}\n  return p;\n}\n\n/*\n** Return the column of index pIdx that corresponds to table\n** column iCol.  Return -1 if not found.\n*/\nSQLITE_PRIVATE i16 sqlite3ColumnOfIndex(Index *pIdx, i16 iCol){\n  int i;\n  for(i=0; i<pIdx->nColumn; i++){\n    if( iCol==pIdx->aiColumn[i] ) return i;\n  }\n  return -1;\n}\n\n/*\n** Begin constructing a new table representation in memory.  This is\n** the first of several action routines that get called in response\n** to a CREATE TABLE statement.  In particular, this routine is called\n** after seeing tokens \"CREATE\" and \"TABLE\" and the table name. The isTemp\n** flag is true if the table should be stored in the auxiliary database\n** file instead of in the main database file.  This is normally the case\n** when the \"TEMP\" or \"TEMPORARY\" keyword occurs in between\n** CREATE and TABLE.\n**\n** The new table record is initialized and put in pParse->pNewTable.\n** As more of the CREATE TABLE statement is parsed, additional action\n** routines will be called to add more information to this record.\n** At the end of the CREATE TABLE statement, the sqlite3EndTable() routine\n** is called to complete the construction of the new table record.\n*/\nSQLITE_PRIVATE void sqlite3StartTable(\n  Parse *pParse,   /* Parser context */\n  Token *pName1,   /* First part of the name of the table or view */\n  Token *pName2,   /* Second part of the name of the table or view */\n  int isTemp,      /* True if this is a TEMP table */\n  int isView,      /* True if this is a VIEW */\n  int isVirtual,   /* True if this is a VIRTUAL table */\n  int noErr        /* Do nothing if table already exists */\n){\n  Table *pTable;\n  char *zName = 0; /* The name of the new table */\n  sqlite3 *db = pParse->db;\n  Vdbe *v;\n  int iDb;         /* Database number to create the table in */\n  Token *pName;    /* Unqualified name of the table to create */\n\n  if( db->init.busy && db->init.newTnum==1 ){\n    /* Special case:  Parsing the sqlite_master or sqlite_temp_master schema */\n    iDb = db->init.iDb;\n    zName = sqlite3DbStrDup(db, SCHEMA_TABLE(iDb));\n    pName = pName1;\n  }else{\n    /* The common case */\n    iDb = sqlite3TwoPartName(pParse, pName1, pName2, &pName);\n    if( iDb<0 ) return;\n    if( !OMIT_TEMPDB && isTemp && pName2->n>0 && iDb!=1 ){\n      /* If creating a temp table, the name may not be qualified. Unless \n      ** the database name is \"temp\" anyway.  */\n      sqlite3ErrorMsg(pParse, \"temporary table name must be unqualified\");\n      return;\n    }\n    if( !OMIT_TEMPDB && isTemp ) iDb = 1;\n    zName = sqlite3NameFromToken(db, pName);\n    if( IN_RENAME_OBJECT ){\n      sqlite3RenameTokenMap(pParse, (void*)zName, pName);\n    }\n  }\n  pParse->sNameToken = *pName;\n  if( zName==0 ) return;\n  if( SQLITE_OK!=sqlite3CheckObjectName(pParse, zName) ){\n    goto begin_table_error;\n  }\n  if( db->init.iDb==1 ) isTemp = 1;\n#ifndef SQLITE_OMIT_AUTHORIZATION\n  assert( isTemp==0 || isTemp==1 );\n  assert( isView==0 || isView==1 );\n  {\n    static const u8 aCode[] = {\n       SQLITE_CREATE_TABLE,\n       SQLITE_CREATE_TEMP_TABLE,\n       SQLITE_CREATE_VIEW,\n       SQLITE_CREATE_TEMP_VIEW\n    };\n    char *zDb = db->aDb[iDb].zDbSName;\n    if( sqlite3AuthCheck(pParse, SQLITE_INSERT, SCHEMA_TABLE(isTemp), 0, zDb) ){\n      goto begin_table_error;\n    }\n    if( !isVirtual && sqlite3AuthCheck(pParse, (int)aCode[isTemp+2*isView],\n                                       zName, 0, zDb) ){\n      goto begin_table_error;\n    }\n  }\n#endif\n\n  /* Make sure the new table name does not collide with an existing\n  ** index or table name in the same database.  Issue an error message if\n  ** it does. The exception is if the statement being parsed was passed\n  ** to an sqlite3_declare_vtab() call. In that case only the column names\n  ** and types will be used, so there is no need to test for namespace\n  ** collisions.\n  */\n  if( !IN_SPECIAL_PARSE ){\n    char *zDb = db->aDb[iDb].zDbSName;\n    if( SQLITE_OK!=sqlite3ReadSchema(pParse) ){\n      goto begin_table_error;\n    }\n    pTable = sqlite3FindTable(db, zName, zDb);\n    if( pTable ){\n      if( !noErr ){\n        sqlite3ErrorMsg(pParse, \"table %T already exists\", pName);\n      }else{\n        assert( !db->init.busy || CORRUPT_DB );\n        sqlite3CodeVerifySchema(pParse, iDb);\n      }\n      goto begin_table_error;\n    }\n    if( sqlite3FindIndex(db, zName, zDb)!=0 ){\n      sqlite3ErrorMsg(pParse, \"there is already an index named %s\", zName);\n      goto begin_table_error;\n    }\n  }\n\n  pTable = sqlite3DbMallocZero(db, sizeof(Table));\n  if( pTable==0 ){\n    assert( db->mallocFailed );\n    pParse->rc = SQLITE_NOMEM_BKPT;\n    pParse->nErr++;\n    goto begin_table_error;\n  }\n  pTable->zName = zName;\n  pTable->iPKey = -1;\n  pTable->pSchema = db->aDb[iDb].pSchema;\n  pTable->nTabRef = 1;\n#ifdef SQLITE_DEFAULT_ROWEST\n  pTable->nRowLogEst = sqlite3LogEst(SQLITE_DEFAULT_ROWEST);\n#else\n  pTable->nRowLogEst = 200; assert( 200==sqlite3LogEst(1048576) );\n#endif\n  assert( pParse->pNewTable==0 );\n  pParse->pNewTable = pTable;\n\n  /* If this is the magic sqlite_sequence table used by autoincrement,\n  ** then record a pointer to this table in the main database structure\n  ** so that INSERT can find the table easily.\n  */\n#ifndef SQLITE_OMIT_AUTOINCREMENT\n  if( !pParse->nested && strcmp(zName, \"sqlite_sequence\")==0 ){\n    assert( sqlite3SchemaMutexHeld(db, iDb, 0) );\n    pTable->pSchema->pSeqTab = pTable;\n  }\n#endif\n\n  /* Begin generating the code that will insert the table record into\n  ** the SQLITE_MASTER table.  Note in particular that we must go ahead\n  ** and allocate the record number for the table entry now.  Before any\n  ** PRIMARY KEY or UNIQUE keywords are parsed.  Those keywords will cause\n  ** indices to be created and the table record must come before the \n  ** indices.  Hence, the record number for the table must be allocated\n  ** now.\n  */\n  if( !db->init.busy && (v = sqlite3GetVdbe(pParse))!=0 ){\n    int addr1;\n    int fileFormat;\n    int reg1, reg2, reg3;\n    /* nullRow[] is an OP_Record encoding of a row containing 5 NULLs */\n    static const char nullRow[] = { 6, 0, 0, 0, 0, 0 };\n    sqlite3BeginWriteOperation(pParse, 1, iDb);\n\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n    if( isVirtual ){\n      sqlite3VdbeAddOp0(v, OP_VBegin);\n    }\n#endif\n\n    /* If the file format and encoding in the database have not been set, \n    ** set them now.\n    */\n    reg1 = pParse->regRowid = ++pParse->nMem;\n    reg2 = pParse->regRoot = ++pParse->nMem;\n    reg3 = ++pParse->nMem;\n    sqlite3VdbeAddOp3(v, OP_ReadCookie, iDb, reg3, BTREE_FILE_FORMAT);\n    sqlite3VdbeUsesBtree(v, iDb);\n    addr1 = sqlite3VdbeAddOp1(v, OP_If, reg3); VdbeCoverage(v);\n    fileFormat = (db->flags & SQLITE_LegacyFileFmt)!=0 ?\n                  1 : SQLITE_MAX_FILE_FORMAT;\n    sqlite3VdbeAddOp3(v, OP_SetCookie, iDb, BTREE_FILE_FORMAT, fileFormat);\n    sqlite3VdbeAddOp3(v, OP_SetCookie, iDb, BTREE_TEXT_ENCODING, ENC(db));\n    sqlite3VdbeJumpHere(v, addr1);\n\n    /* This just creates a place-holder record in the sqlite_master table.\n    ** The record created does not contain anything yet.  It will be replaced\n    ** by the real entry in code generated at sqlite3EndTable().\n    **\n    ** The rowid for the new entry is left in register pParse->regRowid.\n    ** The root page number of the new table is left in reg pParse->regRoot.\n    ** The rowid and root page number values are needed by the code that\n    ** sqlite3EndTable will generate.\n    */\n#if !defined(SQLITE_OMIT_VIEW) || !defined(SQLITE_OMIT_VIRTUALTABLE)\n    if( isView || isVirtual ){\n      sqlite3VdbeAddOp2(v, OP_Integer, 0, reg2);\n    }else\n#endif\n    {\n      pParse->addrCrTab =\n         sqlite3VdbeAddOp3(v, OP_CreateBtree, iDb, reg2, BTREE_INTKEY);\n    }\n    sqlite3OpenMasterTable(pParse, iDb);\n    sqlite3VdbeAddOp2(v, OP_NewRowid, 0, reg1);\n    sqlite3VdbeAddOp4(v, OP_Blob, 6, reg3, 0, nullRow, P4_STATIC);\n    sqlite3VdbeAddOp3(v, OP_Insert, 0, reg3, reg1);\n    sqlite3VdbeChangeP5(v, OPFLAG_APPEND);\n    sqlite3VdbeAddOp0(v, OP_Close);\n  }\n\n  /* Normal (non-error) return. */\n  return;\n\n  /* If an error occurs, we jump here */\nbegin_table_error:\n  sqlite3DbFree(db, zName);\n  return;\n}\n\n/* Set properties of a table column based on the (magical)\n** name of the column.\n*/\n#if SQLITE_ENABLE_HIDDEN_COLUMNS\nSQLITE_PRIVATE void sqlite3ColumnPropertiesFromName(Table *pTab, Column *pCol){\n  if( sqlite3_strnicmp(pCol->zName, \"__hidden__\", 10)==0 ){\n    pCol->colFlags |= COLFLAG_HIDDEN;\n  }else if( pTab && pCol!=pTab->aCol && (pCol[-1].colFlags & COLFLAG_HIDDEN) ){\n    pTab->tabFlags |= TF_OOOHidden;\n  }\n}\n#endif\n\n\n/*\n** Add a new column to the table currently being constructed.\n**\n** The parser calls this routine once for each column declaration\n** in a CREATE TABLE statement.  sqlite3StartTable() gets called\n** first to get things going.  Then this routine is called for each\n** column.\n*/\nSQLITE_PRIVATE void sqlite3AddColumn(Parse *pParse, Token *pName, Token *pType){\n  Table *p;\n  int i;\n  char *z;\n  char *zType;\n  Column *pCol;\n  sqlite3 *db = pParse->db;\n  if( (p = pParse->pNewTable)==0 ) return;\n  if( p->nCol+1>db->aLimit[SQLITE_LIMIT_COLUMN] ){\n    sqlite3ErrorMsg(pParse, \"too many columns on %s\", p->zName);\n    return;\n  }\n  z = sqlite3DbMallocRaw(db, pName->n + pType->n + 2);\n  if( z==0 ) return;\n  if( IN_RENAME_OBJECT ) sqlite3RenameTokenMap(pParse, (void*)z, pName);\n  memcpy(z, pName->z, pName->n);\n  z[pName->n] = 0;\n  sqlite3Dequote(z);\n  for(i=0; i<p->nCol; i++){\n    if( sqlite3_stricmp(z, p->aCol[i].zName)==0 ){\n      sqlite3ErrorMsg(pParse, \"duplicate column name: %s\", z);\n      sqlite3DbFree(db, z);\n      return;\n    }\n  }\n  if( (p->nCol & 0x7)==0 ){\n    Column *aNew;\n    aNew = sqlite3DbRealloc(db,p->aCol,(p->nCol+8)*sizeof(p->aCol[0]));\n    if( aNew==0 ){\n      sqlite3DbFree(db, z);\n      return;\n    }\n    p->aCol = aNew;\n  }\n  pCol = &p->aCol[p->nCol];\n  memset(pCol, 0, sizeof(p->aCol[0]));\n  pCol->zName = z;\n  sqlite3ColumnPropertiesFromName(p, pCol);\n \n  if( pType->n==0 ){\n    /* If there is no type specified, columns have the default affinity\n    ** 'BLOB' with a default size of 4 bytes. */\n    pCol->affinity = SQLITE_AFF_BLOB;\n    pCol->szEst = 1;\n#ifdef SQLITE_ENABLE_SORTER_REFERENCES\n    if( 4>=sqlite3GlobalConfig.szSorterRef ){\n      pCol->colFlags |= COLFLAG_SORTERREF;\n    }\n#endif\n  }else{\n    zType = z + sqlite3Strlen30(z) + 1;\n    memcpy(zType, pType->z, pType->n);\n    zType[pType->n] = 0;\n    sqlite3Dequote(zType);\n    pCol->affinity = sqlite3AffinityType(zType, pCol);\n    pCol->colFlags |= COLFLAG_HASTYPE;\n  }\n  p->nCol++;\n  pParse->constraintName.n = 0;\n}\n\n/*\n** This routine is called by the parser while in the middle of\n** parsing a CREATE TABLE statement.  A \"NOT NULL\" constraint has\n** been seen on a column.  This routine sets the notNull flag on\n** the column currently under construction.\n*/\nSQLITE_PRIVATE void sqlite3AddNotNull(Parse *pParse, int onError){\n  Table *p;\n  Column *pCol;\n  p = pParse->pNewTable;\n  if( p==0 || NEVER(p->nCol<1) ) return;\n  pCol = &p->aCol[p->nCol-1];\n  pCol->notNull = (u8)onError;\n  p->tabFlags |= TF_HasNotNull;\n\n  /* Set the uniqNotNull flag on any UNIQUE or PK indexes already created\n  ** on this column.  */\n  if( pCol->colFlags & COLFLAG_UNIQUE ){\n    Index *pIdx;\n    for(pIdx=p->pIndex; pIdx; pIdx=pIdx->pNext){\n      assert( pIdx->nKeyCol==1 && pIdx->onError!=OE_None );\n      if( pIdx->aiColumn[0]==p->nCol-1 ){\n        pIdx->uniqNotNull = 1;\n      }\n    }\n  }\n}\n\n/*\n** Scan the column type name zType (length nType) and return the\n** associated affinity type.\n**\n** This routine does a case-independent search of zType for the \n** substrings in the following table. If one of the substrings is\n** found, the corresponding affinity is returned. If zType contains\n** more than one of the substrings, entries toward the top of \n** the table take priority. For example, if zType is 'BLOBINT', \n** SQLITE_AFF_INTEGER is returned.\n**\n** Substring     | Affinity\n** --------------------------------\n** 'INT'         | SQLITE_AFF_INTEGER\n** 'CHAR'        | SQLITE_AFF_TEXT\n** 'CLOB'        | SQLITE_AFF_TEXT\n** 'TEXT'        | SQLITE_AFF_TEXT\n** 'BLOB'        | SQLITE_AFF_BLOB\n** 'REAL'        | SQLITE_AFF_REAL\n** 'FLOA'        | SQLITE_AFF_REAL\n** 'DOUB'        | SQLITE_AFF_REAL\n**\n** If none of the substrings in the above table are found,\n** SQLITE_AFF_NUMERIC is returned.\n*/\nSQLITE_PRIVATE char sqlite3AffinityType(const char *zIn, Column *pCol){\n  u32 h = 0;\n  char aff = SQLITE_AFF_NUMERIC;\n  const char *zChar = 0;\n\n  assert( zIn!=0 );\n  while( zIn[0] ){\n    h = (h<<8) + sqlite3UpperToLower[(*zIn)&0xff];\n    zIn++;\n    if( h==(('c'<<24)+('h'<<16)+('a'<<8)+'r') ){             /* CHAR */\n      aff = SQLITE_AFF_TEXT;\n      zChar = zIn;\n    }else if( h==(('c'<<24)+('l'<<16)+('o'<<8)+'b') ){       /* CLOB */\n      aff = SQLITE_AFF_TEXT;\n    }else if( h==(('t'<<24)+('e'<<16)+('x'<<8)+'t') ){       /* TEXT */\n      aff = SQLITE_AFF_TEXT;\n    }else if( h==(('b'<<24)+('l'<<16)+('o'<<8)+'b')          /* BLOB */\n        && (aff==SQLITE_AFF_NUMERIC || aff==SQLITE_AFF_REAL) ){\n      aff = SQLITE_AFF_BLOB;\n      if( zIn[0]=='(' ) zChar = zIn;\n#ifndef SQLITE_OMIT_FLOATING_POINT\n    }else if( h==(('r'<<24)+('e'<<16)+('a'<<8)+'l')          /* REAL */\n        && aff==SQLITE_AFF_NUMERIC ){\n      aff = SQLITE_AFF_REAL;\n    }else if( h==(('f'<<24)+('l'<<16)+('o'<<8)+'a')          /* FLOA */\n        && aff==SQLITE_AFF_NUMERIC ){\n      aff = SQLITE_AFF_REAL;\n    }else if( h==(('d'<<24)+('o'<<16)+('u'<<8)+'b')          /* DOUB */\n        && aff==SQLITE_AFF_NUMERIC ){\n      aff = SQLITE_AFF_REAL;\n#endif\n    }else if( (h&0x00FFFFFF)==(('i'<<16)+('n'<<8)+'t') ){    /* INT */\n      aff = SQLITE_AFF_INTEGER;\n      break;\n    }\n  }\n\n  /* If pCol is not NULL, store an estimate of the field size.  The\n  ** estimate is scaled so that the size of an integer is 1.  */\n  if( pCol ){\n    int v = 0;   /* default size is approx 4 bytes */\n    if( aff<SQLITE_AFF_NUMERIC ){\n      if( zChar ){\n        while( zChar[0] ){\n          if( sqlite3Isdigit(zChar[0]) ){\n            /* BLOB(k), VARCHAR(k), CHAR(k) -> r=(k/4+1) */\n            sqlite3GetInt32(zChar, &v);\n            break;\n          }\n          zChar++;\n        }\n      }else{\n        v = 16;   /* BLOB, TEXT, CLOB -> r=5  (approx 20 bytes)*/\n      }\n    }\n#ifdef SQLITE_ENABLE_SORTER_REFERENCES\n    if( v>=sqlite3GlobalConfig.szSorterRef ){\n      pCol->colFlags |= COLFLAG_SORTERREF;\n    }\n#endif\n    v = v/4 + 1;\n    if( v>255 ) v = 255;\n    pCol->szEst = v;\n  }\n  return aff;\n}\n\n/*\n** The expression is the default value for the most recently added column\n** of the table currently under construction.\n**\n** Default value expressions must be constant.  Raise an exception if this\n** is not the case.\n**\n** This routine is called by the parser while in the middle of\n** parsing a CREATE TABLE statement.\n*/\nSQLITE_PRIVATE void sqlite3AddDefaultValue(\n  Parse *pParse,           /* Parsing context */\n  Expr *pExpr,             /* The parsed expression of the default value */\n  const char *zStart,      /* Start of the default value text */\n  const char *zEnd         /* First character past end of defaut value text */\n){\n  Table *p;\n  Column *pCol;\n  sqlite3 *db = pParse->db;\n  p = pParse->pNewTable;\n  if( p!=0 ){\n    pCol = &(p->aCol[p->nCol-1]);\n    if( !sqlite3ExprIsConstantOrFunction(pExpr, db->init.busy) ){\n      sqlite3ErrorMsg(pParse, \"default value of column [%s] is not constant\",\n          pCol->zName);\n    }else{\n      /* A copy of pExpr is used instead of the original, as pExpr contains\n      ** tokens that point to volatile memory.\n      */\n      Expr x;\n      sqlite3ExprDelete(db, pCol->pDflt);\n      memset(&x, 0, sizeof(x));\n      x.op = TK_SPAN;\n      x.u.zToken = sqlite3DbSpanDup(db, zStart, zEnd);\n      x.pLeft = pExpr;\n      x.flags = EP_Skip;\n      pCol->pDflt = sqlite3ExprDup(db, &x, EXPRDUP_REDUCE);\n      sqlite3DbFree(db, x.u.zToken);\n    }\n  }\n  if( IN_RENAME_OBJECT ){\n    sqlite3RenameExprUnmap(pParse, pExpr);\n  }\n  sqlite3ExprDelete(db, pExpr);\n}\n\n/*\n** Backwards Compatibility Hack:\n** \n** Historical versions of SQLite accepted strings as column names in\n** indexes and PRIMARY KEY constraints and in UNIQUE constraints.  Example:\n**\n**     CREATE TABLE xyz(a,b,c,d,e,PRIMARY KEY('a'),UNIQUE('b','c' COLLATE trim)\n**     CREATE INDEX abc ON xyz('c','d' DESC,'e' COLLATE nocase DESC);\n**\n** This is goofy.  But to preserve backwards compatibility we continue to\n** accept it.  This routine does the necessary conversion.  It converts\n** the expression given in its argument from a TK_STRING into a TK_ID\n** if the expression is just a TK_STRING with an optional COLLATE clause.\n** If the epxression is anything other than TK_STRING, the expression is\n** unchanged.\n*/\nstatic void sqlite3StringToId(Expr *p){\n  if( p->op==TK_STRING ){\n    p->op = TK_ID;\n  }else if( p->op==TK_COLLATE && p->pLeft->op==TK_STRING ){\n    p->pLeft->op = TK_ID;\n  }\n}\n\n/*\n** Designate the PRIMARY KEY for the table.  pList is a list of names \n** of columns that form the primary key.  If pList is NULL, then the\n** most recently added column of the table is the primary key.\n**\n** A table can have at most one primary key.  If the table already has\n** a primary key (and this is the second primary key) then create an\n** error.\n**\n** If the PRIMARY KEY is on a single column whose datatype is INTEGER,\n** then we will try to use that column as the rowid.  Set the Table.iPKey\n** field of the table under construction to be the index of the\n** INTEGER PRIMARY KEY column.  Table.iPKey is set to -1 if there is\n** no INTEGER PRIMARY KEY.\n**\n** If the key is not an INTEGER PRIMARY KEY, then create a unique\n** index for the key.  No index is created for INTEGER PRIMARY KEYs.\n*/\nSQLITE_PRIVATE void sqlite3AddPrimaryKey(\n  Parse *pParse,    /* Parsing context */\n  ExprList *pList,  /* List of field names to be indexed */\n  int onError,      /* What to do with a uniqueness conflict */\n  int autoInc,      /* True if the AUTOINCREMENT keyword is present */\n  int sortOrder     /* SQLITE_SO_ASC or SQLITE_SO_DESC */\n){\n  Table *pTab = pParse->pNewTable;\n  Column *pCol = 0;\n  int iCol = -1, i;\n  int nTerm;\n  if( pTab==0 ) goto primary_key_exit;\n  if( pTab->tabFlags & TF_HasPrimaryKey ){\n    sqlite3ErrorMsg(pParse, \n      \"table \\\"%s\\\" has more than one primary key\", pTab->zName);\n    goto primary_key_exit;\n  }\n  pTab->tabFlags |= TF_HasPrimaryKey;\n  if( pList==0 ){\n    iCol = pTab->nCol - 1;\n    pCol = &pTab->aCol[iCol];\n    pCol->colFlags |= COLFLAG_PRIMKEY;\n    nTerm = 1;\n  }else{\n    nTerm = pList->nExpr;\n    for(i=0; i<nTerm; i++){\n      Expr *pCExpr = sqlite3ExprSkipCollate(pList->a[i].pExpr);\n      assert( pCExpr!=0 );\n      sqlite3StringToId(pCExpr);\n      if( pCExpr->op==TK_ID ){\n        const char *zCName = pCExpr->u.zToken;\n        for(iCol=0; iCol<pTab->nCol; iCol++){\n          if( sqlite3StrICmp(zCName, pTab->aCol[iCol].zName)==0 ){\n            pCol = &pTab->aCol[iCol];\n            pCol->colFlags |= COLFLAG_PRIMKEY;\n            break;\n          }\n        }\n      }\n    }\n  }\n  if( nTerm==1\n   && pCol\n   && sqlite3StrICmp(sqlite3ColumnType(pCol,\"\"), \"INTEGER\")==0\n   && sortOrder!=SQLITE_SO_DESC\n  ){\n    if( IN_RENAME_OBJECT && pList ){\n      sqlite3RenameTokenRemap(pParse, &pTab->iPKey, pList->a[0].pExpr);\n    }\n    pTab->iPKey = iCol;\n    pTab->keyConf = (u8)onError;\n    assert( autoInc==0 || autoInc==1 );\n    pTab->tabFlags |= autoInc*TF_Autoincrement;\n    if( pList ) pParse->iPkSortOrder = pList->a[0].sortOrder;\n  }else if( autoInc ){\n#ifndef SQLITE_OMIT_AUTOINCREMENT\n    sqlite3ErrorMsg(pParse, \"AUTOINCREMENT is only allowed on an \"\n       \"INTEGER PRIMARY KEY\");\n#endif\n  }else{\n    sqlite3CreateIndex(pParse, 0, 0, 0, pList, onError, 0,\n                           0, sortOrder, 0, SQLITE_IDXTYPE_PRIMARYKEY);\n    pList = 0;\n  }\n\nprimary_key_exit:\n  sqlite3ExprListDelete(pParse->db, pList);\n  return;\n}\n\n/*\n** Add a new CHECK constraint to the table currently under construction.\n*/\nSQLITE_PRIVATE void sqlite3AddCheckConstraint(\n  Parse *pParse,    /* Parsing context */\n  Expr *pCheckExpr  /* The check expression */\n){\n#ifndef SQLITE_OMIT_CHECK\n  Table *pTab = pParse->pNewTable;\n  sqlite3 *db = pParse->db;\n  if( pTab && !IN_DECLARE_VTAB\n   && !sqlite3BtreeIsReadonly(db->aDb[db->init.iDb].pBt)\n  ){\n    pTab->pCheck = sqlite3ExprListAppend(pParse, pTab->pCheck, pCheckExpr);\n    if( pParse->constraintName.n ){\n      sqlite3ExprListSetName(pParse, pTab->pCheck, &pParse->constraintName, 1);\n    }\n  }else\n#endif\n  {\n    sqlite3ExprDelete(pParse->db, pCheckExpr);\n  }\n}\n\n/*\n** Set the collation function of the most recently parsed table column\n** to the CollSeq given.\n*/\nSQLITE_PRIVATE void sqlite3AddCollateType(Parse *pParse, Token *pToken){\n  Table *p;\n  int i;\n  char *zColl;              /* Dequoted name of collation sequence */\n  sqlite3 *db;\n\n  if( (p = pParse->pNewTable)==0 ) return;\n  i = p->nCol-1;\n  db = pParse->db;\n  zColl = sqlite3NameFromToken(db, pToken);\n  if( !zColl ) return;\n\n  if( sqlite3LocateCollSeq(pParse, zColl) ){\n    Index *pIdx;\n    sqlite3DbFree(db, p->aCol[i].zColl);\n    p->aCol[i].zColl = zColl;\n  \n    /* If the column is declared as \"<name> PRIMARY KEY COLLATE <type>\",\n    ** then an index may have been created on this column before the\n    ** collation type was added. Correct this if it is the case.\n    */\n    for(pIdx=p->pIndex; pIdx; pIdx=pIdx->pNext){\n      assert( pIdx->nKeyCol==1 );\n      if( pIdx->aiColumn[0]==i ){\n        pIdx->azColl[0] = p->aCol[i].zColl;\n      }\n    }\n  }else{\n    sqlite3DbFree(db, zColl);\n  }\n}\n\n/*\n** This function returns the collation sequence for database native text\n** encoding identified by the string zName, length nName.\n**\n** If the requested collation sequence is not available, or not available\n** in the database native encoding, the collation factory is invoked to\n** request it. If the collation factory does not supply such a sequence,\n** and the sequence is available in another text encoding, then that is\n** returned instead.\n**\n** If no versions of the requested collations sequence are available, or\n** another error occurs, NULL is returned and an error message written into\n** pParse.\n**\n** This routine is a wrapper around sqlite3FindCollSeq().  This routine\n** invokes the collation factory if the named collation cannot be found\n** and generates an error message.\n**\n** See also: sqlite3FindCollSeq(), sqlite3GetCollSeq()\n*/\nSQLITE_PRIVATE CollSeq *sqlite3LocateCollSeq(Parse *pParse, const char *zName){\n  sqlite3 *db = pParse->db;\n  u8 enc = ENC(db);\n  u8 initbusy = db->init.busy;\n  CollSeq *pColl;\n\n  pColl = sqlite3FindCollSeq(db, enc, zName, initbusy);\n  if( !initbusy && (!pColl || !pColl->xCmp) ){\n    pColl = sqlite3GetCollSeq(pParse, enc, pColl, zName);\n  }\n\n  return pColl;\n}\n\n\n/*\n** Generate code that will increment the schema cookie.\n**\n** The schema cookie is used to determine when the schema for the\n** database changes.  After each schema change, the cookie value\n** changes.  When a process first reads the schema it records the\n** cookie.  Thereafter, whenever it goes to access the database,\n** it checks the cookie to make sure the schema has not changed\n** since it was last read.\n**\n** This plan is not completely bullet-proof.  It is possible for\n** the schema to change multiple times and for the cookie to be\n** set back to prior value.  But schema changes are infrequent\n** and the probability of hitting the same cookie value is only\n** 1 chance in 2^32.  So we're safe enough.\n**\n** IMPLEMENTATION-OF: R-34230-56049 SQLite automatically increments\n** the schema-version whenever the schema changes.\n*/\nSQLITE_PRIVATE void sqlite3ChangeCookie(Parse *pParse, int iDb){\n  sqlite3 *db = pParse->db;\n  Vdbe *v = pParse->pVdbe;\n  assert( sqlite3SchemaMutexHeld(db, iDb, 0) );\n  sqlite3VdbeAddOp3(v, OP_SetCookie, iDb, BTREE_SCHEMA_VERSION, \n                   (int)(1+(unsigned)db->aDb[iDb].pSchema->schema_cookie));\n}\n\n/*\n** Measure the number of characters needed to output the given\n** identifier.  The number returned includes any quotes used\n** but does not include the null terminator.\n**\n** The estimate is conservative.  It might be larger that what is\n** really needed.\n*/\nstatic int identLength(const char *z){\n  int n;\n  for(n=0; *z; n++, z++){\n    if( *z=='\"' ){ n++; }\n  }\n  return n + 2;\n}\n\n/*\n** The first parameter is a pointer to an output buffer. The second \n** parameter is a pointer to an integer that contains the offset at\n** which to write into the output buffer. This function copies the\n** nul-terminated string pointed to by the third parameter, zSignedIdent,\n** to the specified offset in the buffer and updates *pIdx to refer\n** to the first byte after the last byte written before returning.\n** \n** If the string zSignedIdent consists entirely of alpha-numeric\n** characters, does not begin with a digit and is not an SQL keyword,\n** then it is copied to the output buffer exactly as it is. Otherwise,\n** it is quoted using double-quotes.\n*/\nstatic void identPut(char *z, int *pIdx, char *zSignedIdent){\n  unsigned char *zIdent = (unsigned char*)zSignedIdent;\n  int i, j, needQuote;\n  i = *pIdx;\n\n  for(j=0; zIdent[j]; j++){\n    if( !sqlite3Isalnum(zIdent[j]) && zIdent[j]!='_' ) break;\n  }\n  needQuote = sqlite3Isdigit(zIdent[0])\n            || sqlite3KeywordCode(zIdent, j)!=TK_ID\n            || zIdent[j]!=0\n            || j==0;\n\n  if( needQuote ) z[i++] = '\"';\n  for(j=0; zIdent[j]; j++){\n    z[i++] = zIdent[j];\n    if( zIdent[j]=='\"' ) z[i++] = '\"';\n  }\n  if( needQuote ) z[i++] = '\"';\n  z[i] = 0;\n  *pIdx = i;\n}\n\n/*\n** Generate a CREATE TABLE statement appropriate for the given\n** table.  Memory to hold the text of the statement is obtained\n** from sqliteMalloc() and must be freed by the calling function.\n*/\nstatic char *createTableStmt(sqlite3 *db, Table *p){\n  int i, k, n;\n  char *zStmt;\n  char *zSep, *zSep2, *zEnd;\n  Column *pCol;\n  n = 0;\n  for(pCol = p->aCol, i=0; i<p->nCol; i++, pCol++){\n    n += identLength(pCol->zName) + 5;\n  }\n  n += identLength(p->zName);\n  if( n<50 ){ \n    zSep = \"\";\n    zSep2 = \",\";\n    zEnd = \")\";\n  }else{\n    zSep = \"\\n  \";\n    zSep2 = \",\\n  \";\n    zEnd = \"\\n)\";\n  }\n  n += 35 + 6*p->nCol;\n  zStmt = sqlite3DbMallocRaw(0, n);\n  if( zStmt==0 ){\n    sqlite3OomFault(db);\n    return 0;\n  }\n  sqlite3_snprintf(n, zStmt, \"CREATE TABLE \");\n  k = sqlite3Strlen30(zStmt);\n  identPut(zStmt, &k, p->zName);\n  zStmt[k++] = '(';\n  for(pCol=p->aCol, i=0; i<p->nCol; i++, pCol++){\n    static const char * const azType[] = {\n        /* SQLITE_AFF_BLOB    */ \"\",\n        /* SQLITE_AFF_TEXT    */ \" TEXT\",\n        /* SQLITE_AFF_NUMERIC */ \" NUM\",\n        /* SQLITE_AFF_INTEGER */ \" INT\",\n        /* SQLITE_AFF_REAL    */ \" REAL\"\n    };\n    int len;\n    const char *zType;\n\n    sqlite3_snprintf(n-k, &zStmt[k], zSep);\n    k += sqlite3Strlen30(&zStmt[k]);\n    zSep = zSep2;\n    identPut(zStmt, &k, pCol->zName);\n    assert( pCol->affinity-SQLITE_AFF_BLOB >= 0 );\n    assert( pCol->affinity-SQLITE_AFF_BLOB < ArraySize(azType) );\n    testcase( pCol->affinity==SQLITE_AFF_BLOB );\n    testcase( pCol->affinity==SQLITE_AFF_TEXT );\n    testcase( pCol->affinity==SQLITE_AFF_NUMERIC );\n    testcase( pCol->affinity==SQLITE_AFF_INTEGER );\n    testcase( pCol->affinity==SQLITE_AFF_REAL );\n    \n    zType = azType[pCol->affinity - SQLITE_AFF_BLOB];\n    len = sqlite3Strlen30(zType);\n    assert( pCol->affinity==SQLITE_AFF_BLOB \n            || pCol->affinity==sqlite3AffinityType(zType, 0) );\n    memcpy(&zStmt[k], zType, len);\n    k += len;\n    assert( k<=n );\n  }\n  sqlite3_snprintf(n-k, &zStmt[k], \"%s\", zEnd);\n  return zStmt;\n}\n\n/*\n** Resize an Index object to hold N columns total.  Return SQLITE_OK\n** on success and SQLITE_NOMEM on an OOM error.\n*/\nstatic int resizeIndexObject(sqlite3 *db, Index *pIdx, int N){\n  char *zExtra;\n  int nByte;\n  if( pIdx->nColumn>=N ) return SQLITE_OK;\n  assert( pIdx->isResized==0 );\n  nByte = (sizeof(char*) + sizeof(i16) + 1)*N;\n  zExtra = sqlite3DbMallocZero(db, nByte);\n  if( zExtra==0 ) return SQLITE_NOMEM_BKPT;\n  memcpy(zExtra, pIdx->azColl, sizeof(char*)*pIdx->nColumn);\n  pIdx->azColl = (const char**)zExtra;\n  zExtra += sizeof(char*)*N;\n  memcpy(zExtra, pIdx->aiColumn, sizeof(i16)*pIdx->nColumn);\n  pIdx->aiColumn = (i16*)zExtra;\n  zExtra += sizeof(i16)*N;\n  memcpy(zExtra, pIdx->aSortOrder, pIdx->nColumn);\n  pIdx->aSortOrder = (u8*)zExtra;\n  pIdx->nColumn = N;\n  pIdx->isResized = 1;\n  return SQLITE_OK;\n}\n\n/*\n** Estimate the total row width for a table.\n*/\nstatic void estimateTableWidth(Table *pTab){\n  unsigned wTable = 0;\n  const Column *pTabCol;\n  int i;\n  for(i=pTab->nCol, pTabCol=pTab->aCol; i>0; i--, pTabCol++){\n    wTable += pTabCol->szEst;\n  }\n  if( pTab->iPKey<0 ) wTable++;\n  pTab->szTabRow = sqlite3LogEst(wTable*4);\n}\n\n/*\n** Estimate the average size of a row for an index.\n*/\nstatic void estimateIndexWidth(Index *pIdx){\n  unsigned wIndex = 0;\n  int i;\n  const Column *aCol = pIdx->pTable->aCol;\n  for(i=0; i<pIdx->nColumn; i++){\n    i16 x = pIdx->aiColumn[i];\n    assert( x<pIdx->pTable->nCol );\n    wIndex += x<0 ? 1 : aCol[pIdx->aiColumn[i]].szEst;\n  }\n  pIdx->szIdxRow = sqlite3LogEst(wIndex*4);\n}\n\n/* Return true if value x is found any of the first nCol entries of aiCol[]\n*/\nstatic int hasColumn(const i16 *aiCol, int nCol, int x){\n  while( nCol-- > 0 ) if( x==*(aiCol++) ) return 1;\n  return 0;\n}\n\n/* Recompute the colNotIdxed field of the Index.\n**\n** colNotIdxed is a bitmask that has a 0 bit representing each indexed\n** columns that are within the first 63 columns of the table.  The\n** high-order bit of colNotIdxed is always 1.  All unindexed columns\n** of the table have a 1.\n**\n** The colNotIdxed mask is AND-ed with the SrcList.a[].colUsed mask\n** to determine if the index is covering index.\n*/\nstatic void recomputeColumnsNotIndexed(Index *pIdx){\n  Bitmask m = 0;\n  int j;\n  for(j=pIdx->nColumn-1; j>=0; j--){\n    int x = pIdx->aiColumn[j];\n    if( x>=0 ){\n      testcase( x==BMS-1 );\n      testcase( x==BMS-2 );\n      if( x<BMS-1 ) m |= MASKBIT(x);\n    }\n  }\n  pIdx->colNotIdxed = ~m;\n  assert( (pIdx->colNotIdxed>>63)==1 );\n}\n\n/*\n** This routine runs at the end of parsing a CREATE TABLE statement that\n** has a WITHOUT ROWID clause.  The job of this routine is to convert both\n** internal schema data structures and the generated VDBE code so that they\n** are appropriate for a WITHOUT ROWID table instead of a rowid table.\n** Changes include:\n**\n**     (1)  Set all columns of the PRIMARY KEY schema object to be NOT NULL.\n**     (2)  Convert P3 parameter of the OP_CreateBtree from BTREE_INTKEY \n**          into BTREE_BLOBKEY.\n**     (3)  Bypass the creation of the sqlite_master table entry\n**          for the PRIMARY KEY as the primary key index is now\n**          identified by the sqlite_master table entry of the table itself.\n**     (4)  Set the Index.tnum of the PRIMARY KEY Index object in the\n**          schema to the rootpage from the main table.\n**     (5)  Add all table columns to the PRIMARY KEY Index object\n**          so that the PRIMARY KEY is a covering index.  The surplus\n**          columns are part of KeyInfo.nAllField and are not used for\n**          sorting or lookup or uniqueness checks.\n**     (6)  Replace the rowid tail on all automatically generated UNIQUE\n**          indices with the PRIMARY KEY columns.\n**\n** For virtual tables, only (1) is performed.\n*/\nstatic void convertToWithoutRowidTable(Parse *pParse, Table *pTab){\n  Index *pIdx;\n  Index *pPk;\n  int nPk;\n  int i, j;\n  sqlite3 *db = pParse->db;\n  Vdbe *v = pParse->pVdbe;\n\n  /* Mark every PRIMARY KEY column as NOT NULL (except for imposter tables)\n  */\n  if( !db->init.imposterTable ){\n    for(i=0; i<pTab->nCol; i++){\n      if( (pTab->aCol[i].colFlags & COLFLAG_PRIMKEY)!=0 ){\n        pTab->aCol[i].notNull = OE_Abort;\n      }\n    }\n  }\n\n  /* Convert the P3 operand of the OP_CreateBtree opcode from BTREE_INTKEY\n  ** into BTREE_BLOBKEY.\n  */\n  if( pParse->addrCrTab ){\n    assert( v );\n    sqlite3VdbeChangeP3(v, pParse->addrCrTab, BTREE_BLOBKEY);\n  }\n\n  /* Locate the PRIMARY KEY index.  Or, if this table was originally\n  ** an INTEGER PRIMARY KEY table, create a new PRIMARY KEY index. \n  */\n  if( pTab->iPKey>=0 ){\n    ExprList *pList;\n    Token ipkToken;\n    sqlite3TokenInit(&ipkToken, pTab->aCol[pTab->iPKey].zName);\n    pList = sqlite3ExprListAppend(pParse, 0, \n                  sqlite3ExprAlloc(db, TK_ID, &ipkToken, 0));\n    if( pList==0 ) return;\n    pList->a[0].sortOrder = pParse->iPkSortOrder;\n    assert( pParse->pNewTable==pTab );\n    sqlite3CreateIndex(pParse, 0, 0, 0, pList, pTab->keyConf, 0, 0, 0, 0,\n                       SQLITE_IDXTYPE_PRIMARYKEY);\n    if( db->mallocFailed || pParse->nErr ) return;\n    pPk = sqlite3PrimaryKeyIndex(pTab);\n    pTab->iPKey = -1;\n  }else{\n    pPk = sqlite3PrimaryKeyIndex(pTab);\n\n    /*\n    ** Remove all redundant columns from the PRIMARY KEY.  For example, change\n    ** \"PRIMARY KEY(a,b,a,b,c,b,c,d)\" into just \"PRIMARY KEY(a,b,c,d)\".  Later\n    ** code assumes the PRIMARY KEY contains no repeated columns.\n    */\n    for(i=j=1; i<pPk->nKeyCol; i++){\n      if( hasColumn(pPk->aiColumn, j, pPk->aiColumn[i]) ){\n        pPk->nColumn--;\n      }else{\n        pPk->aiColumn[j++] = pPk->aiColumn[i];\n      }\n    }\n    pPk->nKeyCol = j;\n  }\n  assert( pPk!=0 );\n  pPk->isCovering = 1;\n  if( !db->init.imposterTable ) pPk->uniqNotNull = 1;\n  nPk = pPk->nKeyCol;\n\n  /* Bypass the creation of the PRIMARY KEY btree and the sqlite_master\n  ** table entry. This is only required if currently generating VDBE\n  ** code for a CREATE TABLE (not when parsing one as part of reading\n  ** a database schema).  */\n  if( v && pPk->tnum>0 ){\n    assert( db->init.busy==0 );\n    sqlite3VdbeChangeOpcode(v, pPk->tnum, OP_Goto);\n  }\n\n  /* The root page of the PRIMARY KEY is the table root page */\n  pPk->tnum = pTab->tnum;\n\n  /* Update the in-memory representation of all UNIQUE indices by converting\n  ** the final rowid column into one or more columns of the PRIMARY KEY.\n  */\n  for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){\n    int n;\n    if( IsPrimaryKeyIndex(pIdx) ) continue;\n    for(i=n=0; i<nPk; i++){\n      if( !hasColumn(pIdx->aiColumn, pIdx->nKeyCol, pPk->aiColumn[i]) ) n++;\n    }\n    if( n==0 ){\n      /* This index is a superset of the primary key */\n      pIdx->nColumn = pIdx->nKeyCol;\n      continue;\n    }\n    if( resizeIndexObject(db, pIdx, pIdx->nKeyCol+n) ) return;\n    for(i=0, j=pIdx->nKeyCol; i<nPk; i++){\n      if( !hasColumn(pIdx->aiColumn, pIdx->nKeyCol, pPk->aiColumn[i]) ){\n        pIdx->aiColumn[j] = pPk->aiColumn[i];\n        pIdx->azColl[j] = pPk->azColl[i];\n        j++;\n      }\n    }\n    assert( pIdx->nColumn>=pIdx->nKeyCol+n );\n    assert( pIdx->nColumn>=j );\n  }\n\n  /* Add all table columns to the PRIMARY KEY index\n  */\n  if( nPk<pTab->nCol ){\n    if( resizeIndexObject(db, pPk, pTab->nCol) ) return;\n    for(i=0, j=nPk; i<pTab->nCol; i++){\n      if( !hasColumn(pPk->aiColumn, j, i) ){\n        assert( j<pPk->nColumn );\n        pPk->aiColumn[j] = i;\n        pPk->azColl[j] = sqlite3StrBINARY;\n        j++;\n      }\n    }\n    assert( pPk->nColumn==j );\n    assert( pTab->nCol==j );\n  }else{\n    pPk->nColumn = pTab->nCol;\n  }\n  recomputeColumnsNotIndexed(pPk);\n}\n\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n/*\n** Return true if zName is a shadow table name in the current database\n** connection.\n**\n** zName is temporarily modified while this routine is running, but is\n** restored to its original value prior to this routine returning.\n*/\nstatic int isShadowTableName(sqlite3 *db, char *zName){\n  char *zTail;                  /* Pointer to the last \"_\" in zName */\n  Table *pTab;                  /* Table that zName is a shadow of */\n  Module *pMod;                 /* Module for the virtual table */\n\n  zTail = strrchr(zName, '_');\n  if( zTail==0 ) return 0;\n  *zTail = 0;\n  pTab = sqlite3FindTable(db, zName, 0);\n  *zTail = '_';\n  if( pTab==0 ) return 0;\n  if( !IsVirtual(pTab) ) return 0;\n  pMod = (Module*)sqlite3HashFind(&db->aModule, pTab->azModuleArg[0]);\n  if( pMod==0 ) return 0;\n  if( pMod->pModule->iVersion<3 ) return 0;\n  if( pMod->pModule->xShadowName==0 ) return 0;\n  return pMod->pModule->xShadowName(zTail+1);\n}\n#else\n# define isShadowTableName(x,y) 0\n#endif /* ifndef SQLITE_OMIT_VIRTUALTABLE */\n\n/*\n** This routine is called to report the final \")\" that terminates\n** a CREATE TABLE statement.\n**\n** The table structure that other action routines have been building\n** is added to the internal hash tables, assuming no errors have\n** occurred.\n**\n** An entry for the table is made in the master table on disk, unless\n** this is a temporary table or db->init.busy==1.  When db->init.busy==1\n** it means we are reading the sqlite_master table because we just\n** connected to the database or because the sqlite_master table has\n** recently changed, so the entry for this table already exists in\n** the sqlite_master table.  We do not want to create it again.\n**\n** If the pSelect argument is not NULL, it means that this routine\n** was called to create a table generated from a \n** \"CREATE TABLE ... AS SELECT ...\" statement.  The column names of\n** the new table will match the result set of the SELECT.\n*/\nSQLITE_PRIVATE void sqlite3EndTable(\n  Parse *pParse,          /* Parse context */\n  Token *pCons,           /* The ',' token after the last column defn. */\n  Token *pEnd,            /* The ')' before options in the CREATE TABLE */\n  u8 tabOpts,             /* Extra table options. Usually 0. */\n  Select *pSelect         /* Select from a \"CREATE ... AS SELECT\" */\n){\n  Table *p;                 /* The new table */\n  sqlite3 *db = pParse->db; /* The database connection */\n  int iDb;                  /* Database in which the table lives */\n  Index *pIdx;              /* An implied index of the table */\n\n  if( pEnd==0 && pSelect==0 ){\n    return;\n  }\n  assert( !db->mallocFailed );\n  p = pParse->pNewTable;\n  if( p==0 ) return;\n\n  if( pSelect==0 && isShadowTableName(db, p->zName) ){\n    p->tabFlags |= TF_Shadow;\n  }\n\n  /* If the db->init.busy is 1 it means we are reading the SQL off the\n  ** \"sqlite_master\" or \"sqlite_temp_master\" table on the disk.\n  ** So do not write to the disk again.  Extract the root page number\n  ** for the table from the db->init.newTnum field.  (The page number\n  ** should have been put there by the sqliteOpenCb routine.)\n  **\n  ** If the root page number is 1, that means this is the sqlite_master\n  ** table itself.  So mark it read-only.\n  */\n  if( db->init.busy ){\n    if( pSelect ){\n      sqlite3ErrorMsg(pParse, \"\");\n      return;\n    }\n    p->tnum = db->init.newTnum;\n    if( p->tnum==1 ) p->tabFlags |= TF_Readonly;\n  }\n\n  /* Special processing for WITHOUT ROWID Tables */\n  if( tabOpts & TF_WithoutRowid ){\n    if( (p->tabFlags & TF_Autoincrement) ){\n      sqlite3ErrorMsg(pParse,\n          \"AUTOINCREMENT not allowed on WITHOUT ROWID tables\");\n      return;\n    }\n    if( (p->tabFlags & TF_HasPrimaryKey)==0 ){\n      sqlite3ErrorMsg(pParse, \"PRIMARY KEY missing on table %s\", p->zName);\n    }else{\n      p->tabFlags |= TF_WithoutRowid | TF_NoVisibleRowid;\n      convertToWithoutRowidTable(pParse, p);\n    }\n  }\n\n  iDb = sqlite3SchemaToIndex(db, p->pSchema);\n\n#ifndef SQLITE_OMIT_CHECK\n  /* Resolve names in all CHECK constraint expressions.\n  */\n  if( p->pCheck ){\n    sqlite3ResolveSelfReference(pParse, p, NC_IsCheck, 0, p->pCheck);\n  }\n#endif /* !defined(SQLITE_OMIT_CHECK) */\n\n  /* Estimate the average row size for the table and for all implied indices */\n  estimateTableWidth(p);\n  for(pIdx=p->pIndex; pIdx; pIdx=pIdx->pNext){\n    estimateIndexWidth(pIdx);\n  }\n\n  /* If not initializing, then create a record for the new table\n  ** in the SQLITE_MASTER table of the database.\n  **\n  ** If this is a TEMPORARY table, write the entry into the auxiliary\n  ** file instead of into the main database file.\n  */\n  if( !db->init.busy ){\n    int n;\n    Vdbe *v;\n    char *zType;    /* \"view\" or \"table\" */\n    char *zType2;   /* \"VIEW\" or \"TABLE\" */\n    char *zStmt;    /* Text of the CREATE TABLE or CREATE VIEW statement */\n\n    v = sqlite3GetVdbe(pParse);\n    if( NEVER(v==0) ) return;\n\n    sqlite3VdbeAddOp1(v, OP_Close, 0);\n\n    /* \n    ** Initialize zType for the new view or table.\n    */\n    if( p->pSelect==0 ){\n      /* A regular table */\n      zType = \"table\";\n      zType2 = \"TABLE\";\n#ifndef SQLITE_OMIT_VIEW\n    }else{\n      /* A view */\n      zType = \"view\";\n      zType2 = \"VIEW\";\n#endif\n    }\n\n    /* If this is a CREATE TABLE xx AS SELECT ..., execute the SELECT\n    ** statement to populate the new table. The root-page number for the\n    ** new table is in register pParse->regRoot.\n    **\n    ** Once the SELECT has been coded by sqlite3Select(), it is in a\n    ** suitable state to query for the column names and types to be used\n    ** by the new table.\n    **\n    ** A shared-cache write-lock is not required to write to the new table,\n    ** as a schema-lock must have already been obtained to create it. Since\n    ** a schema-lock excludes all other database users, the write-lock would\n    ** be redundant.\n    */\n    if( pSelect ){\n      SelectDest dest;    /* Where the SELECT should store results */\n      int regYield;       /* Register holding co-routine entry-point */\n      int addrTop;        /* Top of the co-routine */\n      int regRec;         /* A record to be insert into the new table */\n      int regRowid;       /* Rowid of the next row to insert */\n      int addrInsLoop;    /* Top of the loop for inserting rows */\n      Table *pSelTab;     /* A table that describes the SELECT results */\n\n      regYield = ++pParse->nMem;\n      regRec = ++pParse->nMem;\n      regRowid = ++pParse->nMem;\n      assert(pParse->nTab==1);\n      sqlite3MayAbort(pParse);\n      sqlite3VdbeAddOp3(v, OP_OpenWrite, 1, pParse->regRoot, iDb);\n      sqlite3VdbeChangeP5(v, OPFLAG_P2ISREG);\n      pParse->nTab = 2;\n      addrTop = sqlite3VdbeCurrentAddr(v) + 1;\n      sqlite3VdbeAddOp3(v, OP_InitCoroutine, regYield, 0, addrTop);\n      if( pParse->nErr ) return;\n      pSelTab = sqlite3ResultSetOfSelect(pParse, pSelect);\n      if( pSelTab==0 ) return;\n      assert( p->aCol==0 );\n      p->nCol = pSelTab->nCol;\n      p->aCol = pSelTab->aCol;\n      pSelTab->nCol = 0;\n      pSelTab->aCol = 0;\n      sqlite3DeleteTable(db, pSelTab);\n      sqlite3SelectDestInit(&dest, SRT_Coroutine, regYield);\n      sqlite3Select(pParse, pSelect, &dest);\n      if( pParse->nErr ) return;\n      sqlite3VdbeEndCoroutine(v, regYield);\n      sqlite3VdbeJumpHere(v, addrTop - 1);\n      addrInsLoop = sqlite3VdbeAddOp1(v, OP_Yield, dest.iSDParm);\n      VdbeCoverage(v);\n      sqlite3VdbeAddOp3(v, OP_MakeRecord, dest.iSdst, dest.nSdst, regRec);\n      sqlite3TableAffinity(v, p, 0);\n      sqlite3VdbeAddOp2(v, OP_NewRowid, 1, regRowid);\n      sqlite3VdbeAddOp3(v, OP_Insert, 1, regRec, regRowid);\n      sqlite3VdbeGoto(v, addrInsLoop);\n      sqlite3VdbeJumpHere(v, addrInsLoop);\n      sqlite3VdbeAddOp1(v, OP_Close, 1);\n    }\n\n    /* Compute the complete text of the CREATE statement */\n    if( pSelect ){\n      zStmt = createTableStmt(db, p);\n    }else{\n      Token *pEnd2 = tabOpts ? &pParse->sLastToken : pEnd;\n      n = (int)(pEnd2->z - pParse->sNameToken.z);\n      if( pEnd2->z[0]!=';' ) n += pEnd2->n;\n      zStmt = sqlite3MPrintf(db, \n          \"CREATE %s %.*s\", zType2, n, pParse->sNameToken.z\n      );\n    }\n\n    /* A slot for the record has already been allocated in the \n    ** SQLITE_MASTER table.  We just need to update that slot with all\n    ** the information we've collected.\n    */\n    sqlite3NestedParse(pParse,\n      \"UPDATE %Q.%s \"\n         \"SET type='%s', name=%Q, tbl_name=%Q, rootpage=#%d, sql=%Q \"\n       \"WHERE rowid=#%d\",\n      db->aDb[iDb].zDbSName, MASTER_NAME,\n      zType,\n      p->zName,\n      p->zName,\n      pParse->regRoot,\n      zStmt,\n      pParse->regRowid\n    );\n    sqlite3DbFree(db, zStmt);\n    sqlite3ChangeCookie(pParse, iDb);\n\n#ifndef SQLITE_OMIT_AUTOINCREMENT\n    /* Check to see if we need to create an sqlite_sequence table for\n    ** keeping track of autoincrement keys.\n    */\n    if( (p->tabFlags & TF_Autoincrement)!=0 ){\n      Db *pDb = &db->aDb[iDb];\n      assert( sqlite3SchemaMutexHeld(db, iDb, 0) );\n      if( pDb->pSchema->pSeqTab==0 ){\n        sqlite3NestedParse(pParse,\n          \"CREATE TABLE %Q.sqlite_sequence(name,seq)\",\n          pDb->zDbSName\n        );\n      }\n    }\n#endif\n\n    /* Reparse everything to update our internal data structures */\n    sqlite3VdbeAddParseSchemaOp(v, iDb,\n           sqlite3MPrintf(db, \"tbl_name='%q' AND type!='trigger'\", p->zName));\n  }\n\n\n  /* Add the table to the in-memory representation of the database.\n  */\n  if( db->init.busy ){\n    Table *pOld;\n    Schema *pSchema = p->pSchema;\n    assert( sqlite3SchemaMutexHeld(db, iDb, 0) );\n    pOld = sqlite3HashInsert(&pSchema->tblHash, p->zName, p);\n    if( pOld ){\n      assert( p==pOld );  /* Malloc must have failed inside HashInsert() */\n      sqlite3OomFault(db);\n      return;\n    }\n    pParse->pNewTable = 0;\n    db->mDbFlags |= DBFLAG_SchemaChange;\n\n#ifndef SQLITE_OMIT_ALTERTABLE\n    if( !p->pSelect ){\n      const char *zName = (const char *)pParse->sNameToken.z;\n      int nName;\n      assert( !pSelect && pCons && pEnd );\n      if( pCons->z==0 ){\n        pCons = pEnd;\n      }\n      nName = (int)((const char *)pCons->z - zName);\n      p->addColOffset = 13 + sqlite3Utf8CharLen(zName, nName);\n    }\n#endif\n  }\n}\n\n#ifndef SQLITE_OMIT_VIEW\n/*\n** The parser calls this routine in order to create a new VIEW\n*/\nSQLITE_PRIVATE void sqlite3CreateView(\n  Parse *pParse,     /* The parsing context */\n  Token *pBegin,     /* The CREATE token that begins the statement */\n  Token *pName1,     /* The token that holds the name of the view */\n  Token *pName2,     /* The token that holds the name of the view */\n  ExprList *pCNames, /* Optional list of view column names */\n  Select *pSelect,   /* A SELECT statement that will become the new view */\n  int isTemp,        /* TRUE for a TEMPORARY view */\n  int noErr          /* Suppress error messages if VIEW already exists */\n){\n  Table *p;\n  int n;\n  const char *z;\n  Token sEnd;\n  DbFixer sFix;\n  Token *pName = 0;\n  int iDb;\n  sqlite3 *db = pParse->db;\n\n  if( pParse->nVar>0 ){\n    sqlite3ErrorMsg(pParse, \"parameters are not allowed in views\");\n    goto create_view_fail;\n  }\n  sqlite3StartTable(pParse, pName1, pName2, isTemp, 1, 0, noErr);\n  p = pParse->pNewTable;\n  if( p==0 || pParse->nErr ) goto create_view_fail;\n  sqlite3TwoPartName(pParse, pName1, pName2, &pName);\n  iDb = sqlite3SchemaToIndex(db, p->pSchema);\n  sqlite3FixInit(&sFix, pParse, iDb, \"view\", pName);\n  if( sqlite3FixSelect(&sFix, pSelect) ) goto create_view_fail;\n\n  /* Make a copy of the entire SELECT statement that defines the view.\n  ** This will force all the Expr.token.z values to be dynamically\n  ** allocated rather than point to the input string - which means that\n  ** they will persist after the current sqlite3_exec() call returns.\n  */\n  if( IN_RENAME_OBJECT ){\n    p->pSelect = pSelect;\n    pSelect = 0;\n  }else{\n    p->pSelect = sqlite3SelectDup(db, pSelect, EXPRDUP_REDUCE);\n  }\n  p->pCheck = sqlite3ExprListDup(db, pCNames, EXPRDUP_REDUCE);\n  if( db->mallocFailed ) goto create_view_fail;\n\n  /* Locate the end of the CREATE VIEW statement.  Make sEnd point to\n  ** the end.\n  */\n  sEnd = pParse->sLastToken;\n  assert( sEnd.z[0]!=0 || sEnd.n==0 );\n  if( sEnd.z[0]!=';' ){\n    sEnd.z += sEnd.n;\n  }\n  sEnd.n = 0;\n  n = (int)(sEnd.z - pBegin->z);\n  assert( n>0 );\n  z = pBegin->z;\n  while( sqlite3Isspace(z[n-1]) ){ n--; }\n  sEnd.z = &z[n-1];\n  sEnd.n = 1;\n\n  /* Use sqlite3EndTable() to add the view to the SQLITE_MASTER table */\n  sqlite3EndTable(pParse, 0, &sEnd, 0, 0);\n\ncreate_view_fail:\n  sqlite3SelectDelete(db, pSelect);\n  if( IN_RENAME_OBJECT ){\n    sqlite3RenameExprlistUnmap(pParse, pCNames);\n  }\n  sqlite3ExprListDelete(db, pCNames);\n  return;\n}\n#endif /* SQLITE_OMIT_VIEW */\n\n#if !defined(SQLITE_OMIT_VIEW) || !defined(SQLITE_OMIT_VIRTUALTABLE)\n/*\n** The Table structure pTable is really a VIEW.  Fill in the names of\n** the columns of the view in the pTable structure.  Return the number\n** of errors.  If an error is seen leave an error message in pParse->zErrMsg.\n*/\nSQLITE_PRIVATE int sqlite3ViewGetColumnNames(Parse *pParse, Table *pTable){\n  Table *pSelTab;   /* A fake table from which we get the result set */\n  Select *pSel;     /* Copy of the SELECT that implements the view */\n  int nErr = 0;     /* Number of errors encountered */\n  int n;            /* Temporarily holds the number of cursors assigned */\n  sqlite3 *db = pParse->db;  /* Database connection for malloc errors */\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n  int rc;\n#endif\n#ifndef SQLITE_OMIT_AUTHORIZATION\n  sqlite3_xauth xAuth;       /* Saved xAuth pointer */\n#endif\n\n  assert( pTable );\n\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n  db->nSchemaLock++;\n  rc = sqlite3VtabCallConnect(pParse, pTable);\n  db->nSchemaLock--;\n  if( rc ){\n    return 1;\n  }\n  if( IsVirtual(pTable) ) return 0;\n#endif\n\n#ifndef SQLITE_OMIT_VIEW\n  /* A positive nCol means the columns names for this view are\n  ** already known.\n  */\n  if( pTable->nCol>0 ) return 0;\n\n  /* A negative nCol is a special marker meaning that we are currently\n  ** trying to compute the column names.  If we enter this routine with\n  ** a negative nCol, it means two or more views form a loop, like this:\n  **\n  **     CREATE VIEW one AS SELECT * FROM two;\n  **     CREATE VIEW two AS SELECT * FROM one;\n  **\n  ** Actually, the error above is now caught prior to reaching this point.\n  ** But the following test is still important as it does come up\n  ** in the following:\n  ** \n  **     CREATE TABLE main.ex1(a);\n  **     CREATE TEMP VIEW ex1 AS SELECT a FROM ex1;\n  **     SELECT * FROM temp.ex1;\n  */\n  if( pTable->nCol<0 ){\n    sqlite3ErrorMsg(pParse, \"view %s is circularly defined\", pTable->zName);\n    return 1;\n  }\n  assert( pTable->nCol>=0 );\n\n  /* If we get this far, it means we need to compute the table names.\n  ** Note that the call to sqlite3ResultSetOfSelect() will expand any\n  ** \"*\" elements in the results set of the view and will assign cursors\n  ** to the elements of the FROM clause.  But we do not want these changes\n  ** to be permanent.  So the computation is done on a copy of the SELECT\n  ** statement that defines the view.\n  */\n  assert( pTable->pSelect );\n  pSel = sqlite3SelectDup(db, pTable->pSelect, 0);\n  if( pSel ){\n#ifndef SQLITE_OMIT_ALTERTABLE\n    u8 eParseMode = pParse->eParseMode;\n    pParse->eParseMode = PARSE_MODE_NORMAL;\n#endif\n    n = pParse->nTab;\n    sqlite3SrcListAssignCursors(pParse, pSel->pSrc);\n    pTable->nCol = -1;\n    db->lookaside.bDisable++;\n#ifndef SQLITE_OMIT_AUTHORIZATION\n    xAuth = db->xAuth;\n    db->xAuth = 0;\n    pSelTab = sqlite3ResultSetOfSelect(pParse, pSel);\n    db->xAuth = xAuth;\n#else\n    pSelTab = sqlite3ResultSetOfSelect(pParse, pSel);\n#endif\n    pParse->nTab = n;\n    if( pTable->pCheck ){\n      /* CREATE VIEW name(arglist) AS ...\n      ** The names of the columns in the table are taken from\n      ** arglist which is stored in pTable->pCheck.  The pCheck field\n      ** normally holds CHECK constraints on an ordinary table, but for\n      ** a VIEW it holds the list of column names.\n      */\n      sqlite3ColumnsFromExprList(pParse, pTable->pCheck, \n                                 &pTable->nCol, &pTable->aCol);\n      if( db->mallocFailed==0 \n       && pParse->nErr==0\n       && pTable->nCol==pSel->pEList->nExpr\n      ){\n        sqlite3SelectAddColumnTypeAndCollation(pParse, pTable, pSel);\n      }\n    }else if( pSelTab ){\n      /* CREATE VIEW name AS...  without an argument list.  Construct\n      ** the column names from the SELECT statement that defines the view.\n      */\n      assert( pTable->aCol==0 );\n      pTable->nCol = pSelTab->nCol;\n      pTable->aCol = pSelTab->aCol;\n      pSelTab->nCol = 0;\n      pSelTab->aCol = 0;\n      assert( sqlite3SchemaMutexHeld(db, 0, pTable->pSchema) );\n    }else{\n      pTable->nCol = 0;\n      nErr++;\n    }\n    sqlite3DeleteTable(db, pSelTab);\n    sqlite3SelectDelete(db, pSel);\n    db->lookaside.bDisable--;\n#ifndef SQLITE_OMIT_ALTERTABLE\n    pParse->eParseMode = eParseMode;\n#endif\n  } else {\n    nErr++;\n  }\n  pTable->pSchema->schemaFlags |= DB_UnresetViews;\n  if( db->mallocFailed ){\n    sqlite3DeleteColumnNames(db, pTable);\n    pTable->aCol = 0;\n    pTable->nCol = 0;\n  }\n#endif /* SQLITE_OMIT_VIEW */\n  return nErr;  \n}\n#endif /* !defined(SQLITE_OMIT_VIEW) || !defined(SQLITE_OMIT_VIRTUALTABLE) */\n\n#ifndef SQLITE_OMIT_VIEW\n/*\n** Clear the column names from every VIEW in database idx.\n*/\nstatic void sqliteViewResetAll(sqlite3 *db, int idx){\n  HashElem *i;\n  assert( sqlite3SchemaMutexHeld(db, idx, 0) );\n  if( !DbHasProperty(db, idx, DB_UnresetViews) ) return;\n  for(i=sqliteHashFirst(&db->aDb[idx].pSchema->tblHash); i;i=sqliteHashNext(i)){\n    Table *pTab = sqliteHashData(i);\n    if( pTab->pSelect ){\n      sqlite3DeleteColumnNames(db, pTab);\n      pTab->aCol = 0;\n      pTab->nCol = 0;\n    }\n  }\n  DbClearProperty(db, idx, DB_UnresetViews);\n}\n#else\n# define sqliteViewResetAll(A,B)\n#endif /* SQLITE_OMIT_VIEW */\n\n/*\n** This function is called by the VDBE to adjust the internal schema\n** used by SQLite when the btree layer moves a table root page. The\n** root-page of a table or index in database iDb has changed from iFrom\n** to iTo.\n**\n** Ticket #1728:  The symbol table might still contain information\n** on tables and/or indices that are the process of being deleted.\n** If you are unlucky, one of those deleted indices or tables might\n** have the same rootpage number as the real table or index that is\n** being moved.  So we cannot stop searching after the first match \n** because the first match might be for one of the deleted indices\n** or tables and not the table/index that is actually being moved.\n** We must continue looping until all tables and indices with\n** rootpage==iFrom have been converted to have a rootpage of iTo\n** in order to be certain that we got the right one.\n*/\n#ifndef SQLITE_OMIT_AUTOVACUUM\nSQLITE_PRIVATE void sqlite3RootPageMoved(sqlite3 *db, int iDb, int iFrom, int iTo){\n  HashElem *pElem;\n  Hash *pHash;\n  Db *pDb;\n\n  assert( sqlite3SchemaMutexHeld(db, iDb, 0) );\n  pDb = &db->aDb[iDb];\n  pHash = &pDb->pSchema->tblHash;\n  for(pElem=sqliteHashFirst(pHash); pElem; pElem=sqliteHashNext(pElem)){\n    Table *pTab = sqliteHashData(pElem);\n    if( pTab->tnum==iFrom ){\n      pTab->tnum = iTo;\n    }\n  }\n  pHash = &pDb->pSchema->idxHash;\n  for(pElem=sqliteHashFirst(pHash); pElem; pElem=sqliteHashNext(pElem)){\n    Index *pIdx = sqliteHashData(pElem);\n    if( pIdx->tnum==iFrom ){\n      pIdx->tnum = iTo;\n    }\n  }\n}\n#endif\n\n/*\n** Write code to erase the table with root-page iTable from database iDb.\n** Also write code to modify the sqlite_master table and internal schema\n** if a root-page of another table is moved by the btree-layer whilst\n** erasing iTable (this can happen with an auto-vacuum database).\n*/ \nstatic void destroyRootPage(Parse *pParse, int iTable, int iDb){\n  Vdbe *v = sqlite3GetVdbe(pParse);\n  int r1 = sqlite3GetTempReg(pParse);\n  if( iTable<2 ) sqlite3ErrorMsg(pParse, \"corrupt schema\");\n  sqlite3VdbeAddOp3(v, OP_Destroy, iTable, r1, iDb);\n  sqlite3MayAbort(pParse);\n#ifndef SQLITE_OMIT_AUTOVACUUM\n  /* OP_Destroy stores an in integer r1. If this integer\n  ** is non-zero, then it is the root page number of a table moved to\n  ** location iTable. The following code modifies the sqlite_master table to\n  ** reflect this.\n  **\n  ** The \"#NNN\" in the SQL is a special constant that means whatever value\n  ** is in register NNN.  See grammar rules associated with the TK_REGISTER\n  ** token for additional information.\n  */\n  sqlite3NestedParse(pParse, \n     \"UPDATE %Q.%s SET rootpage=%d WHERE #%d AND rootpage=#%d\",\n     pParse->db->aDb[iDb].zDbSName, MASTER_NAME, iTable, r1, r1);\n#endif\n  sqlite3ReleaseTempReg(pParse, r1);\n}\n\n/*\n** Write VDBE code to erase table pTab and all associated indices on disk.\n** Code to update the sqlite_master tables and internal schema definitions\n** in case a root-page belonging to another table is moved by the btree layer\n** is also added (this can happen with an auto-vacuum database).\n*/\nstatic void destroyTable(Parse *pParse, Table *pTab){\n  /* If the database may be auto-vacuum capable (if SQLITE_OMIT_AUTOVACUUM\n  ** is not defined), then it is important to call OP_Destroy on the\n  ** table and index root-pages in order, starting with the numerically \n  ** largest root-page number. This guarantees that none of the root-pages\n  ** to be destroyed is relocated by an earlier OP_Destroy. i.e. if the\n  ** following were coded:\n  **\n  ** OP_Destroy 4 0\n  ** ...\n  ** OP_Destroy 5 0\n  **\n  ** and root page 5 happened to be the largest root-page number in the\n  ** database, then root page 5 would be moved to page 4 by the \n  ** \"OP_Destroy 4 0\" opcode. The subsequent \"OP_Destroy 5 0\" would hit\n  ** a free-list page.\n  */\n  int iTab = pTab->tnum;\n  int iDestroyed = 0;\n\n  while( 1 ){\n    Index *pIdx;\n    int iLargest = 0;\n\n    if( iDestroyed==0 || iTab<iDestroyed ){\n      iLargest = iTab;\n    }\n    for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){\n      int iIdx = pIdx->tnum;\n      assert( pIdx->pSchema==pTab->pSchema );\n      if( (iDestroyed==0 || (iIdx<iDestroyed)) && iIdx>iLargest ){\n        iLargest = iIdx;\n      }\n    }\n    if( iLargest==0 ){\n      return;\n    }else{\n      int iDb = sqlite3SchemaToIndex(pParse->db, pTab->pSchema);\n      assert( iDb>=0 && iDb<pParse->db->nDb );\n      destroyRootPage(pParse, iLargest, iDb);\n      iDestroyed = iLargest;\n    }\n  }\n}\n\n/*\n** Remove entries from the sqlite_statN tables (for N in (1,2,3))\n** after a DROP INDEX or DROP TABLE command.\n*/\nstatic void sqlite3ClearStatTables(\n  Parse *pParse,         /* The parsing context */\n  int iDb,               /* The database number */\n  const char *zType,     /* \"idx\" or \"tbl\" */\n  const char *zName      /* Name of index or table */\n){\n  int i;\n  const char *zDbName = pParse->db->aDb[iDb].zDbSName;\n  for(i=1; i<=4; i++){\n    char zTab[24];\n    sqlite3_snprintf(sizeof(zTab),zTab,\"sqlite_stat%d\",i);\n    if( sqlite3FindTable(pParse->db, zTab, zDbName) ){\n      sqlite3NestedParse(pParse,\n        \"DELETE FROM %Q.%s WHERE %s=%Q\",\n        zDbName, zTab, zType, zName\n      );\n    }\n  }\n}\n\n/*\n** Generate code to drop a table.\n*/\nSQLITE_PRIVATE void sqlite3CodeDropTable(Parse *pParse, Table *pTab, int iDb, int isView){\n  Vdbe *v;\n  sqlite3 *db = pParse->db;\n  Trigger *pTrigger;\n  Db *pDb = &db->aDb[iDb];\n\n  v = sqlite3GetVdbe(pParse);\n  assert( v!=0 );\n  sqlite3BeginWriteOperation(pParse, 1, iDb);\n\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n  if( IsVirtual(pTab) ){\n    sqlite3VdbeAddOp0(v, OP_VBegin);\n  }\n#endif\n\n  /* Drop all triggers associated with the table being dropped. Code\n  ** is generated to remove entries from sqlite_master and/or\n  ** sqlite_temp_master if required.\n  */\n  pTrigger = sqlite3TriggerList(pParse, pTab);\n  while( pTrigger ){\n    assert( pTrigger->pSchema==pTab->pSchema || \n        pTrigger->pSchema==db->aDb[1].pSchema );\n    sqlite3DropTriggerPtr(pParse, pTrigger);\n    pTrigger = pTrigger->pNext;\n  }\n\n#ifndef SQLITE_OMIT_AUTOINCREMENT\n  /* Remove any entries of the sqlite_sequence table associated with\n  ** the table being dropped. This is done before the table is dropped\n  ** at the btree level, in case the sqlite_sequence table needs to\n  ** move as a result of the drop (can happen in auto-vacuum mode).\n  */\n  if( pTab->tabFlags & TF_Autoincrement ){\n    sqlite3NestedParse(pParse,\n      \"DELETE FROM %Q.sqlite_sequence WHERE name=%Q\",\n      pDb->zDbSName, pTab->zName\n    );\n  }\n#endif\n\n  /* Drop all SQLITE_MASTER table and index entries that refer to the\n  ** table. The program name loops through the master table and deletes\n  ** every row that refers to a table of the same name as the one being\n  ** dropped. Triggers are handled separately because a trigger can be\n  ** created in the temp database that refers to a table in another\n  ** database.\n  */\n  sqlite3NestedParse(pParse, \n      \"DELETE FROM %Q.%s WHERE tbl_name=%Q and type!='trigger'\",\n      pDb->zDbSName, MASTER_NAME, pTab->zName);\n  if( !isView && !IsVirtual(pTab) ){\n    destroyTable(pParse, pTab);\n  }\n\n  /* Remove the table entry from SQLite's internal schema and modify\n  ** the schema cookie.\n  */\n  if( IsVirtual(pTab) ){\n    sqlite3VdbeAddOp4(v, OP_VDestroy, iDb, 0, 0, pTab->zName, 0);\n    sqlite3MayAbort(pParse);\n  }\n  sqlite3VdbeAddOp4(v, OP_DropTable, iDb, 0, 0, pTab->zName, 0);\n  sqlite3ChangeCookie(pParse, iDb);\n  sqliteViewResetAll(db, iDb);\n}\n\n/*\n** This routine is called to do the work of a DROP TABLE statement.\n** pName is the name of the table to be dropped.\n*/\nSQLITE_PRIVATE void sqlite3DropTable(Parse *pParse, SrcList *pName, int isView, int noErr){\n  Table *pTab;\n  Vdbe *v;\n  sqlite3 *db = pParse->db;\n  int iDb;\n\n  if( db->mallocFailed ){\n    goto exit_drop_table;\n  }\n  assert( pParse->nErr==0 );\n  assert( pName->nSrc==1 );\n  if( sqlite3ReadSchema(pParse) ) goto exit_drop_table;\n  if( noErr ) db->suppressErr++;\n  assert( isView==0 || isView==LOCATE_VIEW );\n  pTab = sqlite3LocateTableItem(pParse, isView, &pName->a[0]);\n  if( noErr ) db->suppressErr--;\n\n  if( pTab==0 ){\n    if( noErr ) sqlite3CodeVerifyNamedSchema(pParse, pName->a[0].zDatabase);\n    goto exit_drop_table;\n  }\n  iDb = sqlite3SchemaToIndex(db, pTab->pSchema);\n  assert( iDb>=0 && iDb<db->nDb );\n\n  /* If pTab is a virtual table, call ViewGetColumnNames() to ensure\n  ** it is initialized.\n  */\n  if( IsVirtual(pTab) && sqlite3ViewGetColumnNames(pParse, pTab) ){\n    goto exit_drop_table;\n  }\n#ifndef SQLITE_OMIT_AUTHORIZATION\n  {\n    int code;\n    const char *zTab = SCHEMA_TABLE(iDb);\n    const char *zDb = db->aDb[iDb].zDbSName;\n    const char *zArg2 = 0;\n    if( sqlite3AuthCheck(pParse, SQLITE_DELETE, zTab, 0, zDb)){\n      goto exit_drop_table;\n    }\n    if( isView ){\n      if( !OMIT_TEMPDB && iDb==1 ){\n        code = SQLITE_DROP_TEMP_VIEW;\n      }else{\n        code = SQLITE_DROP_VIEW;\n      }\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n    }else if( IsVirtual(pTab) ){\n      code = SQLITE_DROP_VTABLE;\n      zArg2 = sqlite3GetVTable(db, pTab)->pMod->zName;\n#endif\n    }else{\n      if( !OMIT_TEMPDB && iDb==1 ){\n        code = SQLITE_DROP_TEMP_TABLE;\n      }else{\n        code = SQLITE_DROP_TABLE;\n      }\n    }\n    if( sqlite3AuthCheck(pParse, code, pTab->zName, zArg2, zDb) ){\n      goto exit_drop_table;\n    }\n    if( sqlite3AuthCheck(pParse, SQLITE_DELETE, pTab->zName, 0, zDb) ){\n      goto exit_drop_table;\n    }\n  }\n#endif\n  if( sqlite3StrNICmp(pTab->zName, \"sqlite_\", 7)==0 \n    && sqlite3StrNICmp(pTab->zName, \"sqlite_stat\", 11)!=0 ){\n    sqlite3ErrorMsg(pParse, \"table %s may not be dropped\", pTab->zName);\n    goto exit_drop_table;\n  }\n\n#ifndef SQLITE_OMIT_VIEW\n  /* Ensure DROP TABLE is not used on a view, and DROP VIEW is not used\n  ** on a table.\n  */\n  if( isView && pTab->pSelect==0 ){\n    sqlite3ErrorMsg(pParse, \"use DROP TABLE to delete table %s\", pTab->zName);\n    goto exit_drop_table;\n  }\n  if( !isView && pTab->pSelect ){\n    sqlite3ErrorMsg(pParse, \"use DROP VIEW to delete view %s\", pTab->zName);\n    goto exit_drop_table;\n  }\n#endif\n\n  /* Generate code to remove the table from the master table\n  ** on disk.\n  */\n  v = sqlite3GetVdbe(pParse);\n  if( v ){\n    sqlite3BeginWriteOperation(pParse, 1, iDb);\n    if( !isView ){\n      sqlite3ClearStatTables(pParse, iDb, \"tbl\", pTab->zName);\n      sqlite3FkDropTable(pParse, pName, pTab);\n    }\n    sqlite3CodeDropTable(pParse, pTab, iDb, isView);\n  }\n\nexit_drop_table:\n  sqlite3SrcListDelete(db, pName);\n}\n\n/*\n** This routine is called to create a new foreign key on the table\n** currently under construction.  pFromCol determines which columns\n** in the current table point to the foreign key.  If pFromCol==0 then\n** connect the key to the last column inserted.  pTo is the name of\n** the table referred to (a.k.a the \"parent\" table).  pToCol is a list\n** of tables in the parent pTo table.  flags contains all\n** information about the conflict resolution algorithms specified\n** in the ON DELETE, ON UPDATE and ON INSERT clauses.\n**\n** An FKey structure is created and added to the table currently\n** under construction in the pParse->pNewTable field.\n**\n** The foreign key is set for IMMEDIATE processing.  A subsequent call\n** to sqlite3DeferForeignKey() might change this to DEFERRED.\n*/\nSQLITE_PRIVATE void sqlite3CreateForeignKey(\n  Parse *pParse,       /* Parsing context */\n  ExprList *pFromCol,  /* Columns in this table that point to other table */\n  Token *pTo,          /* Name of the other table */\n  ExprList *pToCol,    /* Columns in the other table */\n  int flags            /* Conflict resolution algorithms. */\n){\n  sqlite3 *db = pParse->db;\n#ifndef SQLITE_OMIT_FOREIGN_KEY\n  FKey *pFKey = 0;\n  FKey *pNextTo;\n  Table *p = pParse->pNewTable;\n  int nByte;\n  int i;\n  int nCol;\n  char *z;\n\n  assert( pTo!=0 );\n  if( p==0 || IN_DECLARE_VTAB ) goto fk_end;\n  if( pFromCol==0 ){\n    int iCol = p->nCol-1;\n    if( NEVER(iCol<0) ) goto fk_end;\n    if( pToCol && pToCol->nExpr!=1 ){\n      sqlite3ErrorMsg(pParse, \"foreign key on %s\"\n         \" should reference only one column of table %T\",\n         p->aCol[iCol].zName, pTo);\n      goto fk_end;\n    }\n    nCol = 1;\n  }else if( pToCol && pToCol->nExpr!=pFromCol->nExpr ){\n    sqlite3ErrorMsg(pParse,\n        \"number of columns in foreign key does not match the number of \"\n        \"columns in the referenced table\");\n    goto fk_end;\n  }else{\n    nCol = pFromCol->nExpr;\n  }\n  nByte = sizeof(*pFKey) + (nCol-1)*sizeof(pFKey->aCol[0]) + pTo->n + 1;\n  if( pToCol ){\n    for(i=0; i<pToCol->nExpr; i++){\n      nByte += sqlite3Strlen30(pToCol->a[i].zName) + 1;\n    }\n  }\n  pFKey = sqlite3DbMallocZero(db, nByte );\n  if( pFKey==0 ){\n    goto fk_end;\n  }\n  pFKey->pFrom = p;\n  pFKey->pNextFrom = p->pFKey;\n  z = (char*)&pFKey->aCol[nCol];\n  pFKey->zTo = z;\n  if( IN_RENAME_OBJECT ){\n    sqlite3RenameTokenMap(pParse, (void*)z, pTo);\n  }\n  memcpy(z, pTo->z, pTo->n);\n  z[pTo->n] = 0;\n  sqlite3Dequote(z);\n  z += pTo->n+1;\n  pFKey->nCol = nCol;\n  if( pFromCol==0 ){\n    pFKey->aCol[0].iFrom = p->nCol-1;\n  }else{\n    for(i=0; i<nCol; i++){\n      int j;\n      for(j=0; j<p->nCol; j++){\n        if( sqlite3StrICmp(p->aCol[j].zName, pFromCol->a[i].zName)==0 ){\n          pFKey->aCol[i].iFrom = j;\n          break;\n        }\n      }\n      if( j>=p->nCol ){\n        sqlite3ErrorMsg(pParse, \n          \"unknown column \\\"%s\\\" in foreign key definition\", \n          pFromCol->a[i].zName);\n        goto fk_end;\n      }\n      if( IN_RENAME_OBJECT ){\n        sqlite3RenameTokenRemap(pParse, &pFKey->aCol[i], pFromCol->a[i].zName);\n      }\n    }\n  }\n  if( pToCol ){\n    for(i=0; i<nCol; i++){\n      int n = sqlite3Strlen30(pToCol->a[i].zName);\n      pFKey->aCol[i].zCol = z;\n      if( IN_RENAME_OBJECT ){\n        sqlite3RenameTokenRemap(pParse, z, pToCol->a[i].zName);\n      }\n      memcpy(z, pToCol->a[i].zName, n);\n      z[n] = 0;\n      z += n+1;\n    }\n  }\n  pFKey->isDeferred = 0;\n  pFKey->aAction[0] = (u8)(flags & 0xff);            /* ON DELETE action */\n  pFKey->aAction[1] = (u8)((flags >> 8 ) & 0xff);    /* ON UPDATE action */\n\n  assert( sqlite3SchemaMutexHeld(db, 0, p->pSchema) );\n  pNextTo = (FKey *)sqlite3HashInsert(&p->pSchema->fkeyHash, \n      pFKey->zTo, (void *)pFKey\n  );\n  if( pNextTo==pFKey ){\n    sqlite3OomFault(db);\n    goto fk_end;\n  }\n  if( pNextTo ){\n    assert( pNextTo->pPrevTo==0 );\n    pFKey->pNextTo = pNextTo;\n    pNextTo->pPrevTo = pFKey;\n  }\n\n  /* Link the foreign key to the table as the last step.\n  */\n  p->pFKey = pFKey;\n  pFKey = 0;\n\nfk_end:\n  sqlite3DbFree(db, pFKey);\n#endif /* !defined(SQLITE_OMIT_FOREIGN_KEY) */\n  sqlite3ExprListDelete(db, pFromCol);\n  sqlite3ExprListDelete(db, pToCol);\n}\n\n/*\n** This routine is called when an INITIALLY IMMEDIATE or INITIALLY DEFERRED\n** clause is seen as part of a foreign key definition.  The isDeferred\n** parameter is 1 for INITIALLY DEFERRED and 0 for INITIALLY IMMEDIATE.\n** The behavior of the most recently created foreign key is adjusted\n** accordingly.\n*/\nSQLITE_PRIVATE void sqlite3DeferForeignKey(Parse *pParse, int isDeferred){\n#ifndef SQLITE_OMIT_FOREIGN_KEY\n  Table *pTab;\n  FKey *pFKey;\n  if( (pTab = pParse->pNewTable)==0 || (pFKey = pTab->pFKey)==0 ) return;\n  assert( isDeferred==0 || isDeferred==1 ); /* EV: R-30323-21917 */\n  pFKey->isDeferred = (u8)isDeferred;\n#endif\n}\n\n/*\n** Generate code that will erase and refill index *pIdx.  This is\n** used to initialize a newly created index or to recompute the\n** content of an index in response to a REINDEX command.\n**\n** if memRootPage is not negative, it means that the index is newly\n** created.  The register specified by memRootPage contains the\n** root page number of the index.  If memRootPage is negative, then\n** the index already exists and must be cleared before being refilled and\n** the root page number of the index is taken from pIndex->tnum.\n*/\nstatic void sqlite3RefillIndex(Parse *pParse, Index *pIndex, int memRootPage){\n  Table *pTab = pIndex->pTable;  /* The table that is indexed */\n  int iTab = pParse->nTab++;     /* Btree cursor used for pTab */\n  int iIdx = pParse->nTab++;     /* Btree cursor used for pIndex */\n  int iSorter;                   /* Cursor opened by OpenSorter (if in use) */\n  int addr1;                     /* Address of top of loop */\n  int addr2;                     /* Address to jump to for next iteration */\n  int tnum;                      /* Root page of index */\n  int iPartIdxLabel;             /* Jump to this label to skip a row */\n  Vdbe *v;                       /* Generate code into this virtual machine */\n  KeyInfo *pKey;                 /* KeyInfo for index */\n  int regRecord;                 /* Register holding assembled index record */\n  sqlite3 *db = pParse->db;      /* The database connection */\n  int iDb = sqlite3SchemaToIndex(db, pIndex->pSchema);\n\n#ifndef SQLITE_OMIT_AUTHORIZATION\n  if( sqlite3AuthCheck(pParse, SQLITE_REINDEX, pIndex->zName, 0,\n      db->aDb[iDb].zDbSName ) ){\n    return;\n  }\n#endif\n\n  /* Require a write-lock on the table to perform this operation */\n  sqlite3TableLock(pParse, iDb, pTab->tnum, 1, pTab->zName);\n\n  v = sqlite3GetVdbe(pParse);\n  if( v==0 ) return;\n  if( memRootPage>=0 ){\n    tnum = memRootPage;\n  }else{\n    tnum = pIndex->tnum;\n  }\n  pKey = sqlite3KeyInfoOfIndex(pParse, pIndex);\n  assert( pKey!=0 || db->mallocFailed || pParse->nErr );\n\n  /* Open the sorter cursor if we are to use one. */\n  iSorter = pParse->nTab++;\n  sqlite3VdbeAddOp4(v, OP_SorterOpen, iSorter, 0, pIndex->nKeyCol, (char*)\n                    sqlite3KeyInfoRef(pKey), P4_KEYINFO);\n\n  /* Open the table. Loop through all rows of the table, inserting index\n  ** records into the sorter. */\n  sqlite3OpenTable(pParse, iTab, iDb, pTab, OP_OpenRead);\n  addr1 = sqlite3VdbeAddOp2(v, OP_Rewind, iTab, 0); VdbeCoverage(v);\n  regRecord = sqlite3GetTempReg(pParse);\n  sqlite3MultiWrite(pParse);\n\n  sqlite3GenerateIndexKey(pParse,pIndex,iTab,regRecord,0,&iPartIdxLabel,0,0);\n  sqlite3VdbeAddOp2(v, OP_SorterInsert, iSorter, regRecord);\n  sqlite3ResolvePartIdxLabel(pParse, iPartIdxLabel);\n  sqlite3VdbeAddOp2(v, OP_Next, iTab, addr1+1); VdbeCoverage(v);\n  sqlite3VdbeJumpHere(v, addr1);\n  if( memRootPage<0 ) sqlite3VdbeAddOp2(v, OP_Clear, tnum, iDb);\n  sqlite3VdbeAddOp4(v, OP_OpenWrite, iIdx, tnum, iDb, \n                    (char *)pKey, P4_KEYINFO);\n  sqlite3VdbeChangeP5(v, OPFLAG_BULKCSR|((memRootPage>=0)?OPFLAG_P2ISREG:0));\n\n  addr1 = sqlite3VdbeAddOp2(v, OP_SorterSort, iSorter, 0); VdbeCoverage(v);\n  if( IsUniqueIndex(pIndex) ){\n    int j2 = sqlite3VdbeGoto(v, 1);\n    addr2 = sqlite3VdbeCurrentAddr(v);\n    sqlite3VdbeVerifyAbortable(v, OE_Abort);\n    sqlite3VdbeAddOp4Int(v, OP_SorterCompare, iSorter, j2, regRecord,\n                         pIndex->nKeyCol); VdbeCoverage(v);\n    sqlite3UniqueConstraint(pParse, OE_Abort, pIndex);\n    sqlite3VdbeJumpHere(v, j2);\n  }else{\n    addr2 = sqlite3VdbeCurrentAddr(v);\n  }\n  sqlite3VdbeAddOp3(v, OP_SorterData, iSorter, regRecord, iIdx);\n  sqlite3VdbeAddOp1(v, OP_SeekEnd, iIdx);\n  sqlite3VdbeAddOp2(v, OP_IdxInsert, iIdx, regRecord);\n  sqlite3VdbeChangeP5(v, OPFLAG_USESEEKRESULT);\n  sqlite3ReleaseTempReg(pParse, regRecord);\n  sqlite3VdbeAddOp2(v, OP_SorterNext, iSorter, addr2); VdbeCoverage(v);\n  sqlite3VdbeJumpHere(v, addr1);\n\n  sqlite3VdbeAddOp1(v, OP_Close, iTab);\n  sqlite3VdbeAddOp1(v, OP_Close, iIdx);\n  sqlite3VdbeAddOp1(v, OP_Close, iSorter);\n}\n\n/*\n** Allocate heap space to hold an Index object with nCol columns.\n**\n** Increase the allocation size to provide an extra nExtra bytes\n** of 8-byte aligned space after the Index object and return a\n** pointer to this extra space in *ppExtra.\n*/\nSQLITE_PRIVATE Index *sqlite3AllocateIndexObject(\n  sqlite3 *db,         /* Database connection */\n  i16 nCol,            /* Total number of columns in the index */\n  int nExtra,          /* Number of bytes of extra space to alloc */\n  char **ppExtra       /* Pointer to the \"extra\" space */\n){\n  Index *p;            /* Allocated index object */\n  int nByte;           /* Bytes of space for Index object + arrays */\n\n  nByte = ROUND8(sizeof(Index)) +              /* Index structure  */\n          ROUND8(sizeof(char*)*nCol) +         /* Index.azColl     */\n          ROUND8(sizeof(LogEst)*(nCol+1) +     /* Index.aiRowLogEst   */\n                 sizeof(i16)*nCol +            /* Index.aiColumn   */\n                 sizeof(u8)*nCol);             /* Index.aSortOrder */\n  p = sqlite3DbMallocZero(db, nByte + nExtra);\n  if( p ){\n    char *pExtra = ((char*)p)+ROUND8(sizeof(Index));\n    p->azColl = (const char**)pExtra; pExtra += ROUND8(sizeof(char*)*nCol);\n    p->aiRowLogEst = (LogEst*)pExtra; pExtra += sizeof(LogEst)*(nCol+1);\n    p->aiColumn = (i16*)pExtra;       pExtra += sizeof(i16)*nCol;\n    p->aSortOrder = (u8*)pExtra;\n    p->nColumn = nCol;\n    p->nKeyCol = nCol - 1;\n    *ppExtra = ((char*)p) + nByte;\n  }\n  return p;\n}\n\n/*\n** Create a new index for an SQL table.  pName1.pName2 is the name of the index \n** and pTblList is the name of the table that is to be indexed.  Both will \n** be NULL for a primary key or an index that is created to satisfy a\n** UNIQUE constraint.  If pTable and pIndex are NULL, use pParse->pNewTable\n** as the table to be indexed.  pParse->pNewTable is a table that is\n** currently being constructed by a CREATE TABLE statement.\n**\n** pList is a list of columns to be indexed.  pList will be NULL if this\n** is a primary key or unique-constraint on the most recent column added\n** to the table currently under construction.  \n*/\nSQLITE_PRIVATE void sqlite3CreateIndex(\n  Parse *pParse,     /* All information about this parse */\n  Token *pName1,     /* First part of index name. May be NULL */\n  Token *pName2,     /* Second part of index name. May be NULL */\n  SrcList *pTblName, /* Table to index. Use pParse->pNewTable if 0 */\n  ExprList *pList,   /* A list of columns to be indexed */\n  int onError,       /* OE_Abort, OE_Ignore, OE_Replace, or OE_None */\n  Token *pStart,     /* The CREATE token that begins this statement */\n  Expr *pPIWhere,    /* WHERE clause for partial indices */\n  int sortOrder,     /* Sort order of primary key when pList==NULL */\n  int ifNotExist,    /* Omit error if index already exists */\n  u8 idxType         /* The index type */\n){\n  Table *pTab = 0;     /* Table to be indexed */\n  Index *pIndex = 0;   /* The index to be created */\n  char *zName = 0;     /* Name of the index */\n  int nName;           /* Number of characters in zName */\n  int i, j;\n  DbFixer sFix;        /* For assigning database names to pTable */\n  int sortOrderMask;   /* 1 to honor DESC in index.  0 to ignore. */\n  sqlite3 *db = pParse->db;\n  Db *pDb;             /* The specific table containing the indexed database */\n  int iDb;             /* Index of the database that is being written */\n  Token *pName = 0;    /* Unqualified name of the index to create */\n  struct ExprList_item *pListItem; /* For looping over pList */\n  int nExtra = 0;                  /* Space allocated for zExtra[] */\n  int nExtraCol;                   /* Number of extra columns needed */\n  char *zExtra = 0;                /* Extra space after the Index object */\n  Index *pPk = 0;      /* PRIMARY KEY index for WITHOUT ROWID tables */\n\n  if( db->mallocFailed || pParse->nErr>0 ){\n    goto exit_create_index;\n  }\n  if( IN_DECLARE_VTAB && idxType!=SQLITE_IDXTYPE_PRIMARYKEY ){\n    goto exit_create_index;\n  }\n  if( SQLITE_OK!=sqlite3ReadSchema(pParse) ){\n    goto exit_create_index;\n  }\n\n  /*\n  ** Find the table that is to be indexed.  Return early if not found.\n  */\n  if( pTblName!=0 ){\n\n    /* Use the two-part index name to determine the database \n    ** to search for the table. 'Fix' the table name to this db\n    ** before looking up the table.\n    */\n    assert( pName1 && pName2 );\n    iDb = sqlite3TwoPartName(pParse, pName1, pName2, &pName);\n    if( iDb<0 ) goto exit_create_index;\n    assert( pName && pName->z );\n\n#ifndef SQLITE_OMIT_TEMPDB\n    /* If the index name was unqualified, check if the table\n    ** is a temp table. If so, set the database to 1. Do not do this\n    ** if initialising a database schema.\n    */\n    if( !db->init.busy ){\n      pTab = sqlite3SrcListLookup(pParse, pTblName);\n      if( pName2->n==0 && pTab && pTab->pSchema==db->aDb[1].pSchema ){\n        iDb = 1;\n      }\n    }\n#endif\n\n    sqlite3FixInit(&sFix, pParse, iDb, \"index\", pName);\n    if( sqlite3FixSrcList(&sFix, pTblName) ){\n      /* Because the parser constructs pTblName from a single identifier,\n      ** sqlite3FixSrcList can never fail. */\n      assert(0);\n    }\n    pTab = sqlite3LocateTableItem(pParse, 0, &pTblName->a[0]);\n    assert( db->mallocFailed==0 || pTab==0 );\n    if( pTab==0 ) goto exit_create_index;\n    if( iDb==1 && db->aDb[iDb].pSchema!=pTab->pSchema ){\n      sqlite3ErrorMsg(pParse, \n           \"cannot create a TEMP index on non-TEMP table \\\"%s\\\"\",\n           pTab->zName);\n      goto exit_create_index;\n    }\n    if( !HasRowid(pTab) ) pPk = sqlite3PrimaryKeyIndex(pTab);\n  }else{\n    assert( pName==0 );\n    assert( pStart==0 );\n    pTab = pParse->pNewTable;\n    if( !pTab ) goto exit_create_index;\n    iDb = sqlite3SchemaToIndex(db, pTab->pSchema);\n  }\n  pDb = &db->aDb[iDb];\n\n  assert( pTab!=0 );\n  assert( pParse->nErr==0 );\n  if( sqlite3StrNICmp(pTab->zName, \"sqlite_\", 7)==0 \n       && db->init.busy==0\n#if SQLITE_USER_AUTHENTICATION\n       && sqlite3UserAuthTable(pTab->zName)==0\n#endif\n#ifdef SQLITE_ALLOW_SQLITE_MASTER_INDEX\n       && sqlite3StrICmp(&pTab->zName[7],\"master\")!=0\n#endif\n       && sqlite3StrNICmp(&pTab->zName[7],\"altertab_\",9)!=0\n ){\n    sqlite3ErrorMsg(pParse, \"table %s may not be indexed\", pTab->zName);\n    goto exit_create_index;\n  }\n#ifndef SQLITE_OMIT_VIEW\n  if( pTab->pSelect ){\n    sqlite3ErrorMsg(pParse, \"views may not be indexed\");\n    goto exit_create_index;\n  }\n#endif\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n  if( IsVirtual(pTab) ){\n    sqlite3ErrorMsg(pParse, \"virtual tables may not be indexed\");\n    goto exit_create_index;\n  }\n#endif\n\n  /*\n  ** Find the name of the index.  Make sure there is not already another\n  ** index or table with the same name.  \n  **\n  ** Exception:  If we are reading the names of permanent indices from the\n  ** sqlite_master table (because some other process changed the schema) and\n  ** one of the index names collides with the name of a temporary table or\n  ** index, then we will continue to process this index.\n  **\n  ** If pName==0 it means that we are\n  ** dealing with a primary key or UNIQUE constraint.  We have to invent our\n  ** own name.\n  */\n  if( pName ){\n    zName = sqlite3NameFromToken(db, pName);\n    if( zName==0 ) goto exit_create_index;\n    assert( pName->z!=0 );\n    if( SQLITE_OK!=sqlite3CheckObjectName(pParse, zName) ){\n      goto exit_create_index;\n    }\n    if( !IN_RENAME_OBJECT ){\n      if( !db->init.busy ){\n        if( sqlite3FindTable(db, zName, 0)!=0 ){\n          sqlite3ErrorMsg(pParse, \"there is already a table named %s\", zName);\n          goto exit_create_index;\n        }\n      }\n      if( sqlite3FindIndex(db, zName, pDb->zDbSName)!=0 ){\n        if( !ifNotExist ){\n          sqlite3ErrorMsg(pParse, \"index %s already exists\", zName);\n        }else{\n          assert( !db->init.busy );\n          sqlite3CodeVerifySchema(pParse, iDb);\n        }\n        goto exit_create_index;\n      }\n    }\n  }else{\n    int n;\n    Index *pLoop;\n    for(pLoop=pTab->pIndex, n=1; pLoop; pLoop=pLoop->pNext, n++){}\n    zName = sqlite3MPrintf(db, \"sqlite_autoindex_%s_%d\", pTab->zName, n);\n    if( zName==0 ){\n      goto exit_create_index;\n    }\n\n    /* Automatic index names generated from within sqlite3_declare_vtab()\n    ** must have names that are distinct from normal automatic index names.\n    ** The following statement converts \"sqlite3_autoindex...\" into\n    ** \"sqlite3_butoindex...\" in order to make the names distinct.\n    ** The \"vtab_err.test\" test demonstrates the need of this statement. */\n    if( IN_SPECIAL_PARSE ) zName[7]++;\n  }\n\n  /* Check for authorization to create an index.\n  */\n#ifndef SQLITE_OMIT_AUTHORIZATION\n  if( !IN_RENAME_OBJECT ){\n    const char *zDb = pDb->zDbSName;\n    if( sqlite3AuthCheck(pParse, SQLITE_INSERT, SCHEMA_TABLE(iDb), 0, zDb) ){\n      goto exit_create_index;\n    }\n    i = SQLITE_CREATE_INDEX;\n    if( !OMIT_TEMPDB && iDb==1 ) i = SQLITE_CREATE_TEMP_INDEX;\n    if( sqlite3AuthCheck(pParse, i, zName, pTab->zName, zDb) ){\n      goto exit_create_index;\n    }\n  }\n#endif\n\n  /* If pList==0, it means this routine was called to make a primary\n  ** key out of the last column added to the table under construction.\n  ** So create a fake list to simulate this.\n  */\n  if( pList==0 ){\n    Token prevCol;\n    Column *pCol = &pTab->aCol[pTab->nCol-1];\n    pCol->colFlags |= COLFLAG_UNIQUE;\n    sqlite3TokenInit(&prevCol, pCol->zName);\n    pList = sqlite3ExprListAppend(pParse, 0,\n              sqlite3ExprAlloc(db, TK_ID, &prevCol, 0));\n    if( pList==0 ) goto exit_create_index;\n    assert( pList->nExpr==1 );\n    sqlite3ExprListSetSortOrder(pList, sortOrder);\n  }else{\n    sqlite3ExprListCheckLength(pParse, pList, \"index\");\n  }\n\n  /* Figure out how many bytes of space are required to store explicitly\n  ** specified collation sequence names.\n  */\n  for(i=0; i<pList->nExpr; i++){\n    Expr *pExpr = pList->a[i].pExpr;\n    assert( pExpr!=0 );\n    if( pExpr->op==TK_COLLATE ){\n      nExtra += (1 + sqlite3Strlen30(pExpr->u.zToken));\n    }\n  }\n\n  /* \n  ** Allocate the index structure. \n  */\n  nName = sqlite3Strlen30(zName);\n  nExtraCol = pPk ? pPk->nKeyCol : 1;\n  pIndex = sqlite3AllocateIndexObject(db, pList->nExpr + nExtraCol,\n                                      nName + nExtra + 1, &zExtra);\n  if( db->mallocFailed ){\n    goto exit_create_index;\n  }\n  assert( EIGHT_BYTE_ALIGNMENT(pIndex->aiRowLogEst) );\n  assert( EIGHT_BYTE_ALIGNMENT(pIndex->azColl) );\n  pIndex->zName = zExtra;\n  zExtra += nName + 1;\n  memcpy(pIndex->zName, zName, nName+1);\n  pIndex->pTable = pTab;\n  pIndex->onError = (u8)onError;\n  pIndex->uniqNotNull = onError!=OE_None;\n  pIndex->idxType = idxType;\n  pIndex->pSchema = db->aDb[iDb].pSchema;\n  pIndex->nKeyCol = pList->nExpr;\n  if( pPIWhere ){\n    sqlite3ResolveSelfReference(pParse, pTab, NC_PartIdx, pPIWhere, 0);\n    pIndex->pPartIdxWhere = pPIWhere;\n    pPIWhere = 0;\n  }\n  assert( sqlite3SchemaMutexHeld(db, iDb, 0) );\n\n  /* Check to see if we should honor DESC requests on index columns\n  */\n  if( pDb->pSchema->file_format>=4 ){\n    sortOrderMask = -1;   /* Honor DESC */\n  }else{\n    sortOrderMask = 0;    /* Ignore DESC */\n  }\n\n  /* Analyze the list of expressions that form the terms of the index and\n  ** report any errors.  In the common case where the expression is exactly\n  ** a table column, store that column in aiColumn[].  For general expressions,\n  ** populate pIndex->aColExpr and store XN_EXPR (-2) in aiColumn[].\n  **\n  ** TODO: Issue a warning if two or more columns of the index are identical.\n  ** TODO: Issue a warning if the table primary key is used as part of the\n  ** index key.\n  */\n  pListItem = pList->a;\n  if( IN_RENAME_OBJECT ){\n    pIndex->aColExpr = pList;\n    pList = 0;\n  }\n  for(i=0; i<pIndex->nKeyCol; i++, pListItem++){\n    Expr *pCExpr;                  /* The i-th index expression */\n    int requestedSortOrder;        /* ASC or DESC on the i-th expression */\n    const char *zColl;             /* Collation sequence name */\n\n    sqlite3StringToId(pListItem->pExpr);\n    sqlite3ResolveSelfReference(pParse, pTab, NC_IdxExpr, pListItem->pExpr, 0);\n    if( pParse->nErr ) goto exit_create_index;\n    pCExpr = sqlite3ExprSkipCollate(pListItem->pExpr);\n    if( pCExpr->op!=TK_COLUMN ){\n      if( pTab==pParse->pNewTable ){\n        sqlite3ErrorMsg(pParse, \"expressions prohibited in PRIMARY KEY and \"\n                                \"UNIQUE constraints\");\n        goto exit_create_index;\n      }\n      if( pIndex->aColExpr==0 ){\n        pIndex->aColExpr = pList;\n        pList = 0;\n      }\n      j = XN_EXPR;\n      pIndex->aiColumn[i] = XN_EXPR;\n      pIndex->uniqNotNull = 0;\n    }else{\n      j = pCExpr->iColumn;\n      assert( j<=0x7fff );\n      if( j<0 ){\n        j = pTab->iPKey;\n      }else if( pTab->aCol[j].notNull==0 ){\n        pIndex->uniqNotNull = 0;\n      }\n      pIndex->aiColumn[i] = (i16)j;\n    }\n    zColl = 0;\n    if( pListItem->pExpr->op==TK_COLLATE ){\n      int nColl;\n      zColl = pListItem->pExpr->u.zToken;\n      nColl = sqlite3Strlen30(zColl) + 1;\n      assert( nExtra>=nColl );\n      memcpy(zExtra, zColl, nColl);\n      zColl = zExtra;\n      zExtra += nColl;\n      nExtra -= nColl;\n    }else if( j>=0 ){\n      zColl = pTab->aCol[j].zColl;\n    }\n    if( !zColl ) zColl = sqlite3StrBINARY;\n    if( !db->init.busy && !sqlite3LocateCollSeq(pParse, zColl) ){\n      goto exit_create_index;\n    }\n    pIndex->azColl[i] = zColl;\n    requestedSortOrder = pListItem->sortOrder & sortOrderMask;\n    pIndex->aSortOrder[i] = (u8)requestedSortOrder;\n  }\n\n  /* Append the table key to the end of the index.  For WITHOUT ROWID\n  ** tables (when pPk!=0) this will be the declared PRIMARY KEY.  For\n  ** normal tables (when pPk==0) this will be the rowid.\n  */\n  if( pPk ){\n    for(j=0; j<pPk->nKeyCol; j++){\n      int x = pPk->aiColumn[j];\n      assert( x>=0 );\n      if( hasColumn(pIndex->aiColumn, pIndex->nKeyCol, x) ){\n        pIndex->nColumn--; \n      }else{\n        pIndex->aiColumn[i] = x;\n        pIndex->azColl[i] = pPk->azColl[j];\n        pIndex->aSortOrder[i] = pPk->aSortOrder[j];\n        i++;\n      }\n    }\n    assert( i==pIndex->nColumn );\n  }else{\n    pIndex->aiColumn[i] = XN_ROWID;\n    pIndex->azColl[i] = sqlite3StrBINARY;\n  }\n  sqlite3DefaultRowEst(pIndex);\n  if( pParse->pNewTable==0 ) estimateIndexWidth(pIndex);\n\n  /* If this index contains every column of its table, then mark\n  ** it as a covering index */\n  assert( HasRowid(pTab) \n      || pTab->iPKey<0 || sqlite3ColumnOfIndex(pIndex, pTab->iPKey)>=0 );\n  recomputeColumnsNotIndexed(pIndex);\n  if( pTblName!=0 && pIndex->nColumn>=pTab->nCol ){\n    pIndex->isCovering = 1;\n    for(j=0; j<pTab->nCol; j++){\n      if( j==pTab->iPKey ) continue;\n      if( sqlite3ColumnOfIndex(pIndex,j)>=0 ) continue;\n      pIndex->isCovering = 0;\n      break;\n    }\n  }\n\n  if( pTab==pParse->pNewTable ){\n    /* This routine has been called to create an automatic index as a\n    ** result of a PRIMARY KEY or UNIQUE clause on a column definition, or\n    ** a PRIMARY KEY or UNIQUE clause following the column definitions.\n    ** i.e. one of:\n    **\n    ** CREATE TABLE t(x PRIMARY KEY, y);\n    ** CREATE TABLE t(x, y, UNIQUE(x, y));\n    **\n    ** Either way, check to see if the table already has such an index. If\n    ** so, don't bother creating this one. This only applies to\n    ** automatically created indices. Users can do as they wish with\n    ** explicit indices.\n    **\n    ** Two UNIQUE or PRIMARY KEY constraints are considered equivalent\n    ** (and thus suppressing the second one) even if they have different\n    ** sort orders.\n    **\n    ** If there are different collating sequences or if the columns of\n    ** the constraint occur in different orders, then the constraints are\n    ** considered distinct and both result in separate indices.\n    */\n    Index *pIdx;\n    for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){\n      int k;\n      assert( IsUniqueIndex(pIdx) );\n      assert( pIdx->idxType!=SQLITE_IDXTYPE_APPDEF );\n      assert( IsUniqueIndex(pIndex) );\n\n      if( pIdx->nKeyCol!=pIndex->nKeyCol ) continue;\n      for(k=0; k<pIdx->nKeyCol; k++){\n        const char *z1;\n        const char *z2;\n        assert( pIdx->aiColumn[k]>=0 );\n        if( pIdx->aiColumn[k]!=pIndex->aiColumn[k] ) break;\n        z1 = pIdx->azColl[k];\n        z2 = pIndex->azColl[k];\n        if( sqlite3StrICmp(z1, z2) ) break;\n      }\n      if( k==pIdx->nKeyCol ){\n        if( pIdx->onError!=pIndex->onError ){\n          /* This constraint creates the same index as a previous\n          ** constraint specified somewhere in the CREATE TABLE statement.\n          ** However the ON CONFLICT clauses are different. If both this \n          ** constraint and the previous equivalent constraint have explicit\n          ** ON CONFLICT clauses this is an error. Otherwise, use the\n          ** explicitly specified behavior for the index.\n          */\n          if( !(pIdx->onError==OE_Default || pIndex->onError==OE_Default) ){\n            sqlite3ErrorMsg(pParse, \n                \"conflicting ON CONFLICT clauses specified\", 0);\n          }\n          if( pIdx->onError==OE_Default ){\n            pIdx->onError = pIndex->onError;\n          }\n        }\n        if( idxType==SQLITE_IDXTYPE_PRIMARYKEY ) pIdx->idxType = idxType;\n        if( IN_RENAME_OBJECT ){\n          pIndex->pNext = pParse->pNewIndex;\n          pParse->pNewIndex = pIndex;\n          pIndex = 0;\n        }\n        goto exit_create_index;\n      }\n    }\n  }\n\n  if( !IN_RENAME_OBJECT ){\n\n    /* Link the new Index structure to its table and to the other\n    ** in-memory database structures. \n    */\n    assert( pParse->nErr==0 );\n    if( db->init.busy ){\n      Index *p;\n      assert( !IN_SPECIAL_PARSE );\n      assert( sqlite3SchemaMutexHeld(db, 0, pIndex->pSchema) );\n      if( pTblName!=0 ){\n        pIndex->tnum = db->init.newTnum;\n        if( sqlite3IndexHasDuplicateRootPage(pIndex) ){\n          sqlite3ErrorMsg(pParse, \"invalid rootpage\");\n          pParse->rc = SQLITE_CORRUPT_BKPT;\n          goto exit_create_index;\n        }\n      }\n      p = sqlite3HashInsert(&pIndex->pSchema->idxHash, \n          pIndex->zName, pIndex);\n      if( p ){\n        assert( p==pIndex );  /* Malloc must have failed */\n        sqlite3OomFault(db);\n        goto exit_create_index;\n      }\n      db->mDbFlags |= DBFLAG_SchemaChange;\n    }\n\n    /* If this is the initial CREATE INDEX statement (or CREATE TABLE if the\n    ** index is an implied index for a UNIQUE or PRIMARY KEY constraint) then\n    ** emit code to allocate the index rootpage on disk and make an entry for\n    ** the index in the sqlite_master table and populate the index with\n    ** content.  But, do not do this if we are simply reading the sqlite_master\n    ** table to parse the schema, or if this index is the PRIMARY KEY index\n    ** of a WITHOUT ROWID table.\n    **\n    ** If pTblName==0 it means this index is generated as an implied PRIMARY KEY\n    ** or UNIQUE index in a CREATE TABLE statement.  Since the table\n    ** has just been created, it contains no data and the index initialization\n    ** step can be skipped.\n    */\n    else if( HasRowid(pTab) || pTblName!=0 ){\n      Vdbe *v;\n      char *zStmt;\n      int iMem = ++pParse->nMem;\n\n      v = sqlite3GetVdbe(pParse);\n      if( v==0 ) goto exit_create_index;\n\n      sqlite3BeginWriteOperation(pParse, 1, iDb);\n\n      /* Create the rootpage for the index using CreateIndex. But before\n      ** doing so, code a Noop instruction and store its address in \n      ** Index.tnum. This is required in case this index is actually a \n      ** PRIMARY KEY and the table is actually a WITHOUT ROWID table. In \n      ** that case the convertToWithoutRowidTable() routine will replace\n      ** the Noop with a Goto to jump over the VDBE code generated below. */\n      pIndex->tnum = sqlite3VdbeAddOp0(v, OP_Noop);\n      sqlite3VdbeAddOp3(v, OP_CreateBtree, iDb, iMem, BTREE_BLOBKEY);\n\n      /* Gather the complete text of the CREATE INDEX statement into\n      ** the zStmt variable\n      */\n      if( pStart ){\n        int n = (int)(pParse->sLastToken.z - pName->z) + pParse->sLastToken.n;\n        if( pName->z[n-1]==';' ) n--;\n        /* A named index with an explicit CREATE INDEX statement */\n        zStmt = sqlite3MPrintf(db, \"CREATE%s INDEX %.*s\",\n            onError==OE_None ? \"\" : \" UNIQUE\", n, pName->z);\n      }else{\n        /* An automatic index created by a PRIMARY KEY or UNIQUE constraint */\n        /* zStmt = sqlite3MPrintf(\"\"); */\n        zStmt = 0;\n      }\n\n      /* Add an entry in sqlite_master for this index\n      */\n      sqlite3NestedParse(pParse, \n          \"INSERT INTO %Q.%s VALUES('index',%Q,%Q,#%d,%Q);\",\n          db->aDb[iDb].zDbSName, MASTER_NAME,\n          pIndex->zName,\n          pTab->zName,\n          iMem,\n          zStmt\n          );\n      sqlite3DbFree(db, zStmt);\n\n      /* Fill the index with data and reparse the schema. Code an OP_Expire\n      ** to invalidate all pre-compiled statements.\n      */\n      if( pTblName ){\n        sqlite3RefillIndex(pParse, pIndex, iMem);\n        sqlite3ChangeCookie(pParse, iDb);\n        sqlite3VdbeAddParseSchemaOp(v, iDb,\n            sqlite3MPrintf(db, \"name='%q' AND type='index'\", pIndex->zName));\n        sqlite3VdbeAddOp2(v, OP_Expire, 0, 1);\n      }\n\n      sqlite3VdbeJumpHere(v, pIndex->tnum);\n    }\n  }\n\n  /* When adding an index to the list of indices for a table, make\n  ** sure all indices labeled OE_Replace come after all those labeled\n  ** OE_Ignore.  This is necessary for the correct constraint check\n  ** processing (in sqlite3GenerateConstraintChecks()) as part of\n  ** UPDATE and INSERT statements.  \n  */\n  if( db->init.busy || pTblName==0 ){\n    if( onError!=OE_Replace || pTab->pIndex==0\n         || pTab->pIndex->onError==OE_Replace){\n      pIndex->pNext = pTab->pIndex;\n      pTab->pIndex = pIndex;\n    }else{\n      Index *pOther = pTab->pIndex;\n      while( pOther->pNext && pOther->pNext->onError!=OE_Replace ){\n        pOther = pOther->pNext;\n      }\n      pIndex->pNext = pOther->pNext;\n      pOther->pNext = pIndex;\n    }\n    pIndex = 0;\n  }\n  else if( IN_RENAME_OBJECT ){\n    assert( pParse->pNewIndex==0 );\n    pParse->pNewIndex = pIndex;\n    pIndex = 0;\n  }\n\n  /* Clean up before exiting */\nexit_create_index:\n  if( pIndex ) sqlite3FreeIndex(db, pIndex);\n  sqlite3ExprDelete(db, pPIWhere);\n  sqlite3ExprListDelete(db, pList);\n  sqlite3SrcListDelete(db, pTblName);\n  sqlite3DbFree(db, zName);\n}\n\n/*\n** Fill the Index.aiRowEst[] array with default information - information\n** to be used when we have not run the ANALYZE command.\n**\n** aiRowEst[0] is supposed to contain the number of elements in the index.\n** Since we do not know, guess 1 million.  aiRowEst[1] is an estimate of the\n** number of rows in the table that match any particular value of the\n** first column of the index.  aiRowEst[2] is an estimate of the number\n** of rows that match any particular combination of the first 2 columns\n** of the index.  And so forth.  It must always be the case that\n*\n**           aiRowEst[N]<=aiRowEst[N-1]\n**           aiRowEst[N]>=1\n**\n** Apart from that, we have little to go on besides intuition as to\n** how aiRowEst[] should be initialized.  The numbers generated here\n** are based on typical values found in actual indices.\n*/\nSQLITE_PRIVATE void sqlite3DefaultRowEst(Index *pIdx){\n  /*                10,  9,  8,  7,  6 */\n  LogEst aVal[] = { 33, 32, 30, 28, 26 };\n  LogEst *a = pIdx->aiRowLogEst;\n  int nCopy = MIN(ArraySize(aVal), pIdx->nKeyCol);\n  int i;\n\n  /* Indexes with default row estimates should not have stat1 data */\n  assert( !pIdx->hasStat1 );\n\n  /* Set the first entry (number of rows in the index) to the estimated \n  ** number of rows in the table, or half the number of rows in the table\n  ** for a partial index.   But do not let the estimate drop below 10. */\n  a[0] = pIdx->pTable->nRowLogEst;\n  if( pIdx->pPartIdxWhere!=0 ) a[0] -= 10;  assert( 10==sqlite3LogEst(2) );\n  if( a[0]<33 ) a[0] = 33;                  assert( 33==sqlite3LogEst(10) );\n\n  /* Estimate that a[1] is 10, a[2] is 9, a[3] is 8, a[4] is 7, a[5] is\n  ** 6 and each subsequent value (if any) is 5.  */\n  memcpy(&a[1], aVal, nCopy*sizeof(LogEst));\n  for(i=nCopy+1; i<=pIdx->nKeyCol; i++){\n    a[i] = 23;                    assert( 23==sqlite3LogEst(5) );\n  }\n\n  assert( 0==sqlite3LogEst(1) );\n  if( IsUniqueIndex(pIdx) ) a[pIdx->nKeyCol] = 0;\n}\n\n/*\n** This routine will drop an existing named index.  This routine\n** implements the DROP INDEX statement.\n*/\nSQLITE_PRIVATE void sqlite3DropIndex(Parse *pParse, SrcList *pName, int ifExists){\n  Index *pIndex;\n  Vdbe *v;\n  sqlite3 *db = pParse->db;\n  int iDb;\n\n  assert( pParse->nErr==0 );   /* Never called with prior errors */\n  if( db->mallocFailed ){\n    goto exit_drop_index;\n  }\n  assert( pName->nSrc==1 );\n  if( SQLITE_OK!=sqlite3ReadSchema(pParse) ){\n    goto exit_drop_index;\n  }\n  pIndex = sqlite3FindIndex(db, pName->a[0].zName, pName->a[0].zDatabase);\n  if( pIndex==0 ){\n    if( !ifExists ){\n      sqlite3ErrorMsg(pParse, \"no such index: %S\", pName, 0);\n    }else{\n      sqlite3CodeVerifyNamedSchema(pParse, pName->a[0].zDatabase);\n    }\n    pParse->checkSchema = 1;\n    goto exit_drop_index;\n  }\n  if( pIndex->idxType!=SQLITE_IDXTYPE_APPDEF ){\n    sqlite3ErrorMsg(pParse, \"index associated with UNIQUE \"\n      \"or PRIMARY KEY constraint cannot be dropped\", 0);\n    goto exit_drop_index;\n  }\n  iDb = sqlite3SchemaToIndex(db, pIndex->pSchema);\n#ifndef SQLITE_OMIT_AUTHORIZATION\n  {\n    int code = SQLITE_DROP_INDEX;\n    Table *pTab = pIndex->pTable;\n    const char *zDb = db->aDb[iDb].zDbSName;\n    const char *zTab = SCHEMA_TABLE(iDb);\n    if( sqlite3AuthCheck(pParse, SQLITE_DELETE, zTab, 0, zDb) ){\n      goto exit_drop_index;\n    }\n    if( !OMIT_TEMPDB && iDb ) code = SQLITE_DROP_TEMP_INDEX;\n    if( sqlite3AuthCheck(pParse, code, pIndex->zName, pTab->zName, zDb) ){\n      goto exit_drop_index;\n    }\n  }\n#endif\n\n  /* Generate code to remove the index and from the master table */\n  v = sqlite3GetVdbe(pParse);\n  if( v ){\n    sqlite3BeginWriteOperation(pParse, 1, iDb);\n    sqlite3NestedParse(pParse,\n       \"DELETE FROM %Q.%s WHERE name=%Q AND type='index'\",\n       db->aDb[iDb].zDbSName, MASTER_NAME, pIndex->zName\n    );\n    sqlite3ClearStatTables(pParse, iDb, \"idx\", pIndex->zName);\n    sqlite3ChangeCookie(pParse, iDb);\n    destroyRootPage(pParse, pIndex->tnum, iDb);\n    sqlite3VdbeAddOp4(v, OP_DropIndex, iDb, 0, 0, pIndex->zName, 0);\n  }\n\nexit_drop_index:\n  sqlite3SrcListDelete(db, pName);\n}\n\n/*\n** pArray is a pointer to an array of objects. Each object in the\n** array is szEntry bytes in size. This routine uses sqlite3DbRealloc()\n** to extend the array so that there is space for a new object at the end.\n**\n** When this function is called, *pnEntry contains the current size of\n** the array (in entries - so the allocation is ((*pnEntry) * szEntry) bytes\n** in total).\n**\n** If the realloc() is successful (i.e. if no OOM condition occurs), the\n** space allocated for the new object is zeroed, *pnEntry updated to\n** reflect the new size of the array and a pointer to the new allocation\n** returned. *pIdx is set to the index of the new array entry in this case.\n**\n** Otherwise, if the realloc() fails, *pIdx is set to -1, *pnEntry remains\n** unchanged and a copy of pArray returned.\n*/\nSQLITE_PRIVATE void *sqlite3ArrayAllocate(\n  sqlite3 *db,      /* Connection to notify of malloc failures */\n  void *pArray,     /* Array of objects.  Might be reallocated */\n  int szEntry,      /* Size of each object in the array */\n  int *pnEntry,     /* Number of objects currently in use */\n  int *pIdx         /* Write the index of a new slot here */\n){\n  char *z;\n  int n = *pnEntry;\n  if( (n & (n-1))==0 ){\n    int sz = (n==0) ? 1 : 2*n;\n    void *pNew = sqlite3DbRealloc(db, pArray, sz*szEntry);\n    if( pNew==0 ){\n      *pIdx = -1;\n      return pArray;\n    }\n    pArray = pNew;\n  }\n  z = (char*)pArray;\n  memset(&z[n * szEntry], 0, szEntry);\n  *pIdx = n;\n  ++*pnEntry;\n  return pArray;\n}\n\n/*\n** Append a new element to the given IdList.  Create a new IdList if\n** need be.\n**\n** A new IdList is returned, or NULL if malloc() fails.\n*/\nSQLITE_PRIVATE IdList *sqlite3IdListAppend(Parse *pParse, IdList *pList, Token *pToken){\n  sqlite3 *db = pParse->db;\n  int i;\n  if( pList==0 ){\n    pList = sqlite3DbMallocZero(db, sizeof(IdList) );\n    if( pList==0 ) return 0;\n  }\n  pList->a = sqlite3ArrayAllocate(\n      db,\n      pList->a,\n      sizeof(pList->a[0]),\n      &pList->nId,\n      &i\n  );\n  if( i<0 ){\n    sqlite3IdListDelete(db, pList);\n    return 0;\n  }\n  pList->a[i].zName = sqlite3NameFromToken(db, pToken);\n  if( IN_RENAME_OBJECT && pList->a[i].zName ){\n    sqlite3RenameTokenMap(pParse, (void*)pList->a[i].zName, pToken);\n  }\n  return pList;\n}\n\n/*\n** Delete an IdList.\n*/\nSQLITE_PRIVATE void sqlite3IdListDelete(sqlite3 *db, IdList *pList){\n  int i;\n  if( pList==0 ) return;\n  for(i=0; i<pList->nId; i++){\n    sqlite3DbFree(db, pList->a[i].zName);\n  }\n  sqlite3DbFree(db, pList->a);\n  sqlite3DbFreeNN(db, pList);\n}\n\n/*\n** Return the index in pList of the identifier named zId.  Return -1\n** if not found.\n*/\nSQLITE_PRIVATE int sqlite3IdListIndex(IdList *pList, const char *zName){\n  int i;\n  if( pList==0 ) return -1;\n  for(i=0; i<pList->nId; i++){\n    if( sqlite3StrICmp(pList->a[i].zName, zName)==0 ) return i;\n  }\n  return -1;\n}\n\n/*\n** Maximum size of a SrcList object.\n** The SrcList object is used to represent the FROM clause of a\n** SELECT statement, and the query planner cannot deal with more\n** than 64 tables in a join.  So any value larger than 64 here\n** is sufficient for most uses.  Smaller values, like say 10, are\n** appropriate for small and memory-limited applications.\n*/\n#ifndef SQLITE_MAX_SRCLIST\n# define SQLITE_MAX_SRCLIST 200\n#endif\n\n/*\n** Expand the space allocated for the given SrcList object by\n** creating nExtra new slots beginning at iStart.  iStart is zero based.\n** New slots are zeroed.\n**\n** For example, suppose a SrcList initially contains two entries: A,B.\n** To append 3 new entries onto the end, do this:\n**\n**    sqlite3SrcListEnlarge(db, pSrclist, 3, 2);\n**\n** After the call above it would contain:  A, B, nil, nil, nil.\n** If the iStart argument had been 1 instead of 2, then the result\n** would have been:  A, nil, nil, nil, B.  To prepend the new slots,\n** the iStart value would be 0.  The result then would\n** be: nil, nil, nil, A, B.\n**\n** If a memory allocation fails or the SrcList becomes too large, leave\n** the original SrcList unchanged, return NULL, and leave an error message\n** in pParse.\n*/\nSQLITE_PRIVATE SrcList *sqlite3SrcListEnlarge(\n  Parse *pParse,     /* Parsing context into which errors are reported */\n  SrcList *pSrc,     /* The SrcList to be enlarged */\n  int nExtra,        /* Number of new slots to add to pSrc->a[] */\n  int iStart         /* Index in pSrc->a[] of first new slot */\n){\n  int i;\n\n  /* Sanity checking on calling parameters */\n  assert( iStart>=0 );\n  assert( nExtra>=1 );\n  assert( pSrc!=0 );\n  assert( iStart<=pSrc->nSrc );\n\n  /* Allocate additional space if needed */\n  if( (u32)pSrc->nSrc+nExtra>pSrc->nAlloc ){\n    SrcList *pNew;\n    int nAlloc = pSrc->nSrc*2+nExtra;\n    sqlite3 *db = pParse->db;\n\n    if( pSrc->nSrc+nExtra>=SQLITE_MAX_SRCLIST ){\n      sqlite3ErrorMsg(pParse, \"too many FROM clause terms, max: %d\",\n                      SQLITE_MAX_SRCLIST);\n      return 0;\n    }\n    if( nAlloc>SQLITE_MAX_SRCLIST ) nAlloc = SQLITE_MAX_SRCLIST;\n    pNew = sqlite3DbRealloc(db, pSrc,\n               sizeof(*pSrc) + (nAlloc-1)*sizeof(pSrc->a[0]) );\n    if( pNew==0 ){\n      assert( db->mallocFailed );\n      return 0;\n    }\n    pSrc = pNew;\n    pSrc->nAlloc = nAlloc;\n  }\n\n  /* Move existing slots that come after the newly inserted slots\n  ** out of the way */\n  for(i=pSrc->nSrc-1; i>=iStart; i--){\n    pSrc->a[i+nExtra] = pSrc->a[i];\n  }\n  pSrc->nSrc += nExtra;\n\n  /* Zero the newly allocated slots */\n  memset(&pSrc->a[iStart], 0, sizeof(pSrc->a[0])*nExtra);\n  for(i=iStart; i<iStart+nExtra; i++){\n    pSrc->a[i].iCursor = -1;\n  }\n\n  /* Return a pointer to the enlarged SrcList */\n  return pSrc;\n}\n\n\n/*\n** Append a new table name to the given SrcList.  Create a new SrcList if\n** need be.  A new entry is created in the SrcList even if pTable is NULL.\n**\n** A SrcList is returned, or NULL if there is an OOM error or if the\n** SrcList grows to large.  The returned\n** SrcList might be the same as the SrcList that was input or it might be\n** a new one.  If an OOM error does occurs, then the prior value of pList\n** that is input to this routine is automatically freed.\n**\n** If pDatabase is not null, it means that the table has an optional\n** database name prefix.  Like this:  \"database.table\".  The pDatabase\n** points to the table name and the pTable points to the database name.\n** The SrcList.a[].zName field is filled with the table name which might\n** come from pTable (if pDatabase is NULL) or from pDatabase.  \n** SrcList.a[].zDatabase is filled with the database name from pTable,\n** or with NULL if no database is specified.\n**\n** In other words, if call like this:\n**\n**         sqlite3SrcListAppend(D,A,B,0);\n**\n** Then B is a table name and the database name is unspecified.  If called\n** like this:\n**\n**         sqlite3SrcListAppend(D,A,B,C);\n**\n** Then C is the table name and B is the database name.  If C is defined\n** then so is B.  In other words, we never have a case where:\n**\n**         sqlite3SrcListAppend(D,A,0,C);\n**\n** Both pTable and pDatabase are assumed to be quoted.  They are dequoted\n** before being added to the SrcList.\n*/\nSQLITE_PRIVATE SrcList *sqlite3SrcListAppend(\n  Parse *pParse,      /* Parsing context, in which errors are reported */\n  SrcList *pList,     /* Append to this SrcList. NULL creates a new SrcList */\n  Token *pTable,      /* Table to append */\n  Token *pDatabase    /* Database of the table */\n){\n  struct SrcList_item *pItem;\n  sqlite3 *db;\n  assert( pDatabase==0 || pTable!=0 );  /* Cannot have C without B */\n  assert( pParse!=0 );\n  assert( pParse->db!=0 );\n  db = pParse->db;\n  if( pList==0 ){\n    pList = sqlite3DbMallocRawNN(pParse->db, sizeof(SrcList) );\n    if( pList==0 ) return 0;\n    pList->nAlloc = 1;\n    pList->nSrc = 1;\n    memset(&pList->a[0], 0, sizeof(pList->a[0]));\n    pList->a[0].iCursor = -1;\n  }else{\n    SrcList *pNew = sqlite3SrcListEnlarge(pParse, pList, 1, pList->nSrc);\n    if( pNew==0 ){\n      sqlite3SrcListDelete(db, pList);\n      return 0;\n    }else{\n      pList = pNew;\n    }\n  }\n  pItem = &pList->a[pList->nSrc-1];\n  if( pDatabase && pDatabase->z==0 ){\n    pDatabase = 0;\n  }\n  if( pDatabase ){\n    pItem->zName = sqlite3NameFromToken(db, pDatabase);\n    pItem->zDatabase = sqlite3NameFromToken(db, pTable);\n  }else{\n    pItem->zName = sqlite3NameFromToken(db, pTable);\n    pItem->zDatabase = 0;\n  }\n  return pList;\n}\n\n/*\n** Assign VdbeCursor index numbers to all tables in a SrcList\n*/\nSQLITE_PRIVATE void sqlite3SrcListAssignCursors(Parse *pParse, SrcList *pList){\n  int i;\n  struct SrcList_item *pItem;\n  assert(pList || pParse->db->mallocFailed );\n  if( pList ){\n    for(i=0, pItem=pList->a; i<pList->nSrc; i++, pItem++){\n      if( pItem->iCursor>=0 ) break;\n      pItem->iCursor = pParse->nTab++;\n      if( pItem->pSelect ){\n        sqlite3SrcListAssignCursors(pParse, pItem->pSelect->pSrc);\n      }\n    }\n  }\n}\n\n/*\n** Delete an entire SrcList including all its substructure.\n*/\nSQLITE_PRIVATE void sqlite3SrcListDelete(sqlite3 *db, SrcList *pList){\n  int i;\n  struct SrcList_item *pItem;\n  if( pList==0 ) return;\n  for(pItem=pList->a, i=0; i<pList->nSrc; i++, pItem++){\n    sqlite3DbFree(db, pItem->zDatabase);\n    sqlite3DbFree(db, pItem->zName);\n    sqlite3DbFree(db, pItem->zAlias);\n    if( pItem->fg.isIndexedBy ) sqlite3DbFree(db, pItem->u1.zIndexedBy);\n    if( pItem->fg.isTabFunc ) sqlite3ExprListDelete(db, pItem->u1.pFuncArg);\n    sqlite3DeleteTable(db, pItem->pTab);\n    sqlite3SelectDelete(db, pItem->pSelect);\n    sqlite3ExprDelete(db, pItem->pOn);\n    sqlite3IdListDelete(db, pItem->pUsing);\n  }\n  sqlite3DbFreeNN(db, pList);\n}\n\n/*\n** This routine is called by the parser to add a new term to the\n** end of a growing FROM clause.  The \"p\" parameter is the part of\n** the FROM clause that has already been constructed.  \"p\" is NULL\n** if this is the first term of the FROM clause.  pTable and pDatabase\n** are the name of the table and database named in the FROM clause term.\n** pDatabase is NULL if the database name qualifier is missing - the\n** usual case.  If the term has an alias, then pAlias points to the\n** alias token.  If the term is a subquery, then pSubquery is the\n** SELECT statement that the subquery encodes.  The pTable and\n** pDatabase parameters are NULL for subqueries.  The pOn and pUsing\n** parameters are the content of the ON and USING clauses.\n**\n** Return a new SrcList which encodes is the FROM with the new\n** term added.\n*/\nSQLITE_PRIVATE SrcList *sqlite3SrcListAppendFromTerm(\n  Parse *pParse,          /* Parsing context */\n  SrcList *p,             /* The left part of the FROM clause already seen */\n  Token *pTable,          /* Name of the table to add to the FROM clause */\n  Token *pDatabase,       /* Name of the database containing pTable */\n  Token *pAlias,          /* The right-hand side of the AS subexpression */\n  Select *pSubquery,      /* A subquery used in place of a table name */\n  Expr *pOn,              /* The ON clause of a join */\n  IdList *pUsing          /* The USING clause of a join */\n){\n  struct SrcList_item *pItem;\n  sqlite3 *db = pParse->db;\n  if( !p && (pOn || pUsing) ){\n    sqlite3ErrorMsg(pParse, \"a JOIN clause is required before %s\", \n      (pOn ? \"ON\" : \"USING\")\n    );\n    goto append_from_error;\n  }\n  p = sqlite3SrcListAppend(pParse, p, pTable, pDatabase);\n  if( p==0 ){\n    goto append_from_error;\n  }\n  assert( p->nSrc>0 );\n  pItem = &p->a[p->nSrc-1];\n  assert( (pTable==0)==(pDatabase==0) );\n  assert( pItem->zName==0 || pDatabase!=0 );\n  if( IN_RENAME_OBJECT && pItem->zName ){\n    Token *pToken = (ALWAYS(pDatabase) && pDatabase->z) ? pDatabase : pTable;\n    sqlite3RenameTokenMap(pParse, pItem->zName, pToken);\n  }\n  assert( pAlias!=0 );\n  if( pAlias->n ){\n    pItem->zAlias = sqlite3NameFromToken(db, pAlias);\n  }\n  pItem->pSelect = pSubquery;\n  pItem->pOn = pOn;\n  pItem->pUsing = pUsing;\n  return p;\n\n append_from_error:\n  assert( p==0 );\n  sqlite3ExprDelete(db, pOn);\n  sqlite3IdListDelete(db, pUsing);\n  sqlite3SelectDelete(db, pSubquery);\n  return 0;\n}\n\n/*\n** Add an INDEXED BY or NOT INDEXED clause to the most recently added \n** element of the source-list passed as the second argument.\n*/\nSQLITE_PRIVATE void sqlite3SrcListIndexedBy(Parse *pParse, SrcList *p, Token *pIndexedBy){\n  assert( pIndexedBy!=0 );\n  if( p && pIndexedBy->n>0 ){\n    struct SrcList_item *pItem;\n    assert( p->nSrc>0 );\n    pItem = &p->a[p->nSrc-1];\n    assert( pItem->fg.notIndexed==0 );\n    assert( pItem->fg.isIndexedBy==0 );\n    assert( pItem->fg.isTabFunc==0 );\n    if( pIndexedBy->n==1 && !pIndexedBy->z ){\n      /* A \"NOT INDEXED\" clause was supplied. See parse.y \n      ** construct \"indexed_opt\" for details. */\n      pItem->fg.notIndexed = 1;\n    }else{\n      pItem->u1.zIndexedBy = sqlite3NameFromToken(pParse->db, pIndexedBy);\n      pItem->fg.isIndexedBy = 1;\n    }\n  }\n}\n\n/*\n** Add the list of function arguments to the SrcList entry for a\n** table-valued-function.\n*/\nSQLITE_PRIVATE void sqlite3SrcListFuncArgs(Parse *pParse, SrcList *p, ExprList *pList){\n  if( p ){\n    struct SrcList_item *pItem = &p->a[p->nSrc-1];\n    assert( pItem->fg.notIndexed==0 );\n    assert( pItem->fg.isIndexedBy==0 );\n    assert( pItem->fg.isTabFunc==0 );\n    pItem->u1.pFuncArg = pList;\n    pItem->fg.isTabFunc = 1;\n  }else{\n    sqlite3ExprListDelete(pParse->db, pList);\n  }\n}\n\n/*\n** When building up a FROM clause in the parser, the join operator\n** is initially attached to the left operand.  But the code generator\n** expects the join operator to be on the right operand.  This routine\n** Shifts all join operators from left to right for an entire FROM\n** clause.\n**\n** Example: Suppose the join is like this:\n**\n**           A natural cross join B\n**\n** The operator is \"natural cross join\".  The A and B operands are stored\n** in p->a[0] and p->a[1], respectively.  The parser initially stores the\n** operator with A.  This routine shifts that operator over to B.\n*/\nSQLITE_PRIVATE void sqlite3SrcListShiftJoinType(SrcList *p){\n  if( p ){\n    int i;\n    for(i=p->nSrc-1; i>0; i--){\n      p->a[i].fg.jointype = p->a[i-1].fg.jointype;\n    }\n    p->a[0].fg.jointype = 0;\n  }\n}\n\n/*\n** Generate VDBE code for a BEGIN statement.\n*/\nSQLITE_PRIVATE void sqlite3BeginTransaction(Parse *pParse, int type){\n  sqlite3 *db;\n  Vdbe *v;\n  int i;\n\n  assert( pParse!=0 );\n  db = pParse->db;\n  assert( db!=0 );\n  if( sqlite3AuthCheck(pParse, SQLITE_TRANSACTION, \"BEGIN\", 0, 0) ){\n    return;\n  }\n  v = sqlite3GetVdbe(pParse);\n  if( !v ) return;\n  if( type!=TK_DEFERRED ){\n    for(i=0; i<db->nDb; i++){\n      sqlite3VdbeAddOp2(v, OP_Transaction, i, (type==TK_EXCLUSIVE)+1);\n      sqlite3VdbeUsesBtree(v, i);\n    }\n  }\n  sqlite3VdbeAddOp0(v, OP_AutoCommit);\n}\n\n/*\n** Generate VDBE code for a COMMIT or ROLLBACK statement.\n** Code for ROLLBACK is generated if eType==TK_ROLLBACK.  Otherwise\n** code is generated for a COMMIT.\n*/\nSQLITE_PRIVATE void sqlite3EndTransaction(Parse *pParse, int eType){\n  Vdbe *v;\n  int isRollback;\n\n  assert( pParse!=0 );\n  assert( pParse->db!=0 );\n  assert( eType==TK_COMMIT || eType==TK_END || eType==TK_ROLLBACK );\n  isRollback = eType==TK_ROLLBACK;\n  if( sqlite3AuthCheck(pParse, SQLITE_TRANSACTION, \n       isRollback ? \"ROLLBACK\" : \"COMMIT\", 0, 0) ){\n    return;\n  }\n  v = sqlite3GetVdbe(pParse);\n  if( v ){\n    sqlite3VdbeAddOp2(v, OP_AutoCommit, 1, isRollback);\n  }\n}\n\n/*\n** This function is called by the parser when it parses a command to create,\n** release or rollback an SQL savepoint. \n*/\nSQLITE_PRIVATE void sqlite3Savepoint(Parse *pParse, int op, Token *pName){\n  char *zName = sqlite3NameFromToken(pParse->db, pName);\n  if( zName ){\n    Vdbe *v = sqlite3GetVdbe(pParse);\n#ifndef SQLITE_OMIT_AUTHORIZATION\n    static const char * const az[] = { \"BEGIN\", \"RELEASE\", \"ROLLBACK\" };\n    assert( !SAVEPOINT_BEGIN && SAVEPOINT_RELEASE==1 && SAVEPOINT_ROLLBACK==2 );\n#endif\n    if( !v || sqlite3AuthCheck(pParse, SQLITE_SAVEPOINT, az[op], zName, 0) ){\n      sqlite3DbFree(pParse->db, zName);\n      return;\n    }\n    sqlite3VdbeAddOp4(v, OP_Savepoint, op, 0, 0, zName, P4_DYNAMIC);\n  }\n}\n\n/*\n** Make sure the TEMP database is open and available for use.  Return\n** the number of errors.  Leave any error messages in the pParse structure.\n*/\nSQLITE_PRIVATE int sqlite3OpenTempDatabase(Parse *pParse){\n  sqlite3 *db = pParse->db;\n  if( db->aDb[1].pBt==0 && !pParse->explain ){\n    int rc;\n    Btree *pBt;\n    static const int flags = \n          SQLITE_OPEN_READWRITE |\n          SQLITE_OPEN_CREATE |\n          SQLITE_OPEN_EXCLUSIVE |\n          SQLITE_OPEN_DELETEONCLOSE |\n          SQLITE_OPEN_TEMP_DB;\n\n    rc = sqlite3BtreeOpen(db->pVfs, 0, db, &pBt, 0, flags);\n    if( rc!=SQLITE_OK ){\n      sqlite3ErrorMsg(pParse, \"unable to open a temporary database \"\n        \"file for storing temporary tables\");\n      pParse->rc = rc;\n      return 1;\n    }\n    db->aDb[1].pBt = pBt;\n    assert( db->aDb[1].pSchema );\n    if( SQLITE_NOMEM==sqlite3BtreeSetPageSize(pBt, db->nextPagesize, -1, 0) ){\n      sqlite3OomFault(db);\n      return 1;\n    }\n  }\n  return 0;\n}\n\n/*\n** Record the fact that the schema cookie will need to be verified\n** for database iDb.  The code to actually verify the schema cookie\n** will occur at the end of the top-level VDBE and will be generated\n** later, by sqlite3FinishCoding().\n*/\nSQLITE_PRIVATE void sqlite3CodeVerifySchema(Parse *pParse, int iDb){\n  Parse *pToplevel = sqlite3ParseToplevel(pParse);\n\n  assert( iDb>=0 && iDb<pParse->db->nDb );\n  assert( pParse->db->aDb[iDb].pBt!=0 || iDb==1 );\n  assert( iDb<SQLITE_MAX_ATTACHED+2 );\n  assert( sqlite3SchemaMutexHeld(pParse->db, iDb, 0) );\n  if( DbMaskTest(pToplevel->cookieMask, iDb)==0 ){\n    DbMaskSet(pToplevel->cookieMask, iDb);\n    if( !OMIT_TEMPDB && iDb==1 ){\n      sqlite3OpenTempDatabase(pToplevel);\n    }\n  }\n}\n\n/*\n** If argument zDb is NULL, then call sqlite3CodeVerifySchema() for each \n** attached database. Otherwise, invoke it for the database named zDb only.\n*/\nSQLITE_PRIVATE void sqlite3CodeVerifyNamedSchema(Parse *pParse, const char *zDb){\n  sqlite3 *db = pParse->db;\n  int i;\n  for(i=0; i<db->nDb; i++){\n    Db *pDb = &db->aDb[i];\n    if( pDb->pBt && (!zDb || 0==sqlite3StrICmp(zDb, pDb->zDbSName)) ){\n      sqlite3CodeVerifySchema(pParse, i);\n    }\n  }\n}\n\n/*\n** Generate VDBE code that prepares for doing an operation that\n** might change the database.\n**\n** This routine starts a new transaction if we are not already within\n** a transaction.  If we are already within a transaction, then a checkpoint\n** is set if the setStatement parameter is true.  A checkpoint should\n** be set for operations that might fail (due to a constraint) part of\n** the way through and which will need to undo some writes without having to\n** rollback the whole transaction.  For operations where all constraints\n** can be checked before any changes are made to the database, it is never\n** necessary to undo a write and the checkpoint should not be set.\n*/\nSQLITE_PRIVATE void sqlite3BeginWriteOperation(Parse *pParse, int setStatement, int iDb){\n  Parse *pToplevel = sqlite3ParseToplevel(pParse);\n  sqlite3CodeVerifySchema(pParse, iDb);\n  DbMaskSet(pToplevel->writeMask, iDb);\n  pToplevel->isMultiWrite |= setStatement;\n}\n\n/*\n** Indicate that the statement currently under construction might write\n** more than one entry (example: deleting one row then inserting another,\n** inserting multiple rows in a table, or inserting a row and index entries.)\n** If an abort occurs after some of these writes have completed, then it will\n** be necessary to undo the completed writes.\n*/\nSQLITE_PRIVATE void sqlite3MultiWrite(Parse *pParse){\n  Parse *pToplevel = sqlite3ParseToplevel(pParse);\n  pToplevel->isMultiWrite = 1;\n}\n\n/* \n** The code generator calls this routine if is discovers that it is\n** possible to abort a statement prior to completion.  In order to \n** perform this abort without corrupting the database, we need to make\n** sure that the statement is protected by a statement transaction.\n**\n** Technically, we only need to set the mayAbort flag if the\n** isMultiWrite flag was previously set.  There is a time dependency\n** such that the abort must occur after the multiwrite.  This makes\n** some statements involving the REPLACE conflict resolution algorithm\n** go a little faster.  But taking advantage of this time dependency\n** makes it more difficult to prove that the code is correct (in \n** particular, it prevents us from writing an effective\n** implementation of sqlite3AssertMayAbort()) and so we have chosen\n** to take the safe route and skip the optimization.\n*/\nSQLITE_PRIVATE void sqlite3MayAbort(Parse *pParse){\n  Parse *pToplevel = sqlite3ParseToplevel(pParse);\n  pToplevel->mayAbort = 1;\n}\n\n/*\n** Code an OP_Halt that causes the vdbe to return an SQLITE_CONSTRAINT\n** error. The onError parameter determines which (if any) of the statement\n** and/or current transaction is rolled back.\n*/\nSQLITE_PRIVATE void sqlite3HaltConstraint(\n  Parse *pParse,    /* Parsing context */\n  int errCode,      /* extended error code */\n  int onError,      /* Constraint type */\n  char *p4,         /* Error message */\n  i8 p4type,        /* P4_STATIC or P4_TRANSIENT */\n  u8 p5Errmsg       /* P5_ErrMsg type */\n){\n  Vdbe *v = sqlite3GetVdbe(pParse);\n  assert( (errCode&0xff)==SQLITE_CONSTRAINT );\n  if( onError==OE_Abort ){\n    sqlite3MayAbort(pParse);\n  }\n  sqlite3VdbeAddOp4(v, OP_Halt, errCode, onError, 0, p4, p4type);\n  sqlite3VdbeChangeP5(v, p5Errmsg);\n}\n\n/*\n** Code an OP_Halt due to UNIQUE or PRIMARY KEY constraint violation.\n*/\nSQLITE_PRIVATE void sqlite3UniqueConstraint(\n  Parse *pParse,    /* Parsing context */\n  int onError,      /* Constraint type */\n  Index *pIdx       /* The index that triggers the constraint */\n){\n  char *zErr;\n  int j;\n  StrAccum errMsg;\n  Table *pTab = pIdx->pTable;\n\n  sqlite3StrAccumInit(&errMsg, pParse->db, 0, 0, 200);\n  if( pIdx->aColExpr ){\n    sqlite3_str_appendf(&errMsg, \"index '%q'\", pIdx->zName);\n  }else{\n    for(j=0; j<pIdx->nKeyCol; j++){\n      char *zCol;\n      assert( pIdx->aiColumn[j]>=0 );\n      zCol = pTab->aCol[pIdx->aiColumn[j]].zName;\n      if( j ) sqlite3_str_append(&errMsg, \", \", 2);\n      sqlite3_str_appendall(&errMsg, pTab->zName);\n      sqlite3_str_append(&errMsg, \".\", 1);\n      sqlite3_str_appendall(&errMsg, zCol);\n    }\n  }\n  zErr = sqlite3StrAccumFinish(&errMsg);\n  sqlite3HaltConstraint(pParse, \n    IsPrimaryKeyIndex(pIdx) ? SQLITE_CONSTRAINT_PRIMARYKEY \n                            : SQLITE_CONSTRAINT_UNIQUE,\n    onError, zErr, P4_DYNAMIC, P5_ConstraintUnique);\n}\n\n\n/*\n** Code an OP_Halt due to non-unique rowid.\n*/\nSQLITE_PRIVATE void sqlite3RowidConstraint(\n  Parse *pParse,    /* Parsing context */\n  int onError,      /* Conflict resolution algorithm */\n  Table *pTab       /* The table with the non-unique rowid */ \n){\n  char *zMsg;\n  int rc;\n  if( pTab->iPKey>=0 ){\n    zMsg = sqlite3MPrintf(pParse->db, \"%s.%s\", pTab->zName,\n                          pTab->aCol[pTab->iPKey].zName);\n    rc = SQLITE_CONSTRAINT_PRIMARYKEY;\n  }else{\n    zMsg = sqlite3MPrintf(pParse->db, \"%s.rowid\", pTab->zName);\n    rc = SQLITE_CONSTRAINT_ROWID;\n  }\n  sqlite3HaltConstraint(pParse, rc, onError, zMsg, P4_DYNAMIC,\n                        P5_ConstraintUnique);\n}\n\n/*\n** Check to see if pIndex uses the collating sequence pColl.  Return\n** true if it does and false if it does not.\n*/\n#ifndef SQLITE_OMIT_REINDEX\nstatic int collationMatch(const char *zColl, Index *pIndex){\n  int i;\n  assert( zColl!=0 );\n  for(i=0; i<pIndex->nColumn; i++){\n    const char *z = pIndex->azColl[i];\n    assert( z!=0 || pIndex->aiColumn[i]<0 );\n    if( pIndex->aiColumn[i]>=0 && 0==sqlite3StrICmp(z, zColl) ){\n      return 1;\n    }\n  }\n  return 0;\n}\n#endif\n\n/*\n** Recompute all indices of pTab that use the collating sequence pColl.\n** If pColl==0 then recompute all indices of pTab.\n*/\n#ifndef SQLITE_OMIT_REINDEX\nstatic void reindexTable(Parse *pParse, Table *pTab, char const *zColl){\n  if( !IsVirtual(pTab) ){\n    Index *pIndex;              /* An index associated with pTab */\n\n    for(pIndex=pTab->pIndex; pIndex; pIndex=pIndex->pNext){\n      if( zColl==0 || collationMatch(zColl, pIndex) ){\n        int iDb = sqlite3SchemaToIndex(pParse->db, pTab->pSchema);\n        sqlite3BeginWriteOperation(pParse, 0, iDb);\n        sqlite3RefillIndex(pParse, pIndex, -1);\n      }\n    }\n  }\n}\n#endif\n\n/*\n** Recompute all indices of all tables in all databases where the\n** indices use the collating sequence pColl.  If pColl==0 then recompute\n** all indices everywhere.\n*/\n#ifndef SQLITE_OMIT_REINDEX\nstatic void reindexDatabases(Parse *pParse, char const *zColl){\n  Db *pDb;                    /* A single database */\n  int iDb;                    /* The database index number */\n  sqlite3 *db = pParse->db;   /* The database connection */\n  HashElem *k;                /* For looping over tables in pDb */\n  Table *pTab;                /* A table in the database */\n\n  assert( sqlite3BtreeHoldsAllMutexes(db) );  /* Needed for schema access */\n  for(iDb=0, pDb=db->aDb; iDb<db->nDb; iDb++, pDb++){\n    assert( pDb!=0 );\n    for(k=sqliteHashFirst(&pDb->pSchema->tblHash);  k; k=sqliteHashNext(k)){\n      pTab = (Table*)sqliteHashData(k);\n      reindexTable(pParse, pTab, zColl);\n    }\n  }\n}\n#endif\n\n/*\n** Generate code for the REINDEX command.\n**\n**        REINDEX                            -- 1\n**        REINDEX  <collation>               -- 2\n**        REINDEX  ?<database>.?<tablename>  -- 3\n**        REINDEX  ?<database>.?<indexname>  -- 4\n**\n** Form 1 causes all indices in all attached databases to be rebuilt.\n** Form 2 rebuilds all indices in all databases that use the named\n** collating function.  Forms 3 and 4 rebuild the named index or all\n** indices associated with the named table.\n*/\n#ifndef SQLITE_OMIT_REINDEX\nSQLITE_PRIVATE void sqlite3Reindex(Parse *pParse, Token *pName1, Token *pName2){\n  CollSeq *pColl;             /* Collating sequence to be reindexed, or NULL */\n  char *z;                    /* Name of a table or index */\n  const char *zDb;            /* Name of the database */\n  Table *pTab;                /* A table in the database */\n  Index *pIndex;              /* An index associated with pTab */\n  int iDb;                    /* The database index number */\n  sqlite3 *db = pParse->db;   /* The database connection */\n  Token *pObjName;            /* Name of the table or index to be reindexed */\n\n  /* Read the database schema. If an error occurs, leave an error message\n  ** and code in pParse and return NULL. */\n  if( SQLITE_OK!=sqlite3ReadSchema(pParse) ){\n    return;\n  }\n\n  if( pName1==0 ){\n    reindexDatabases(pParse, 0);\n    return;\n  }else if( NEVER(pName2==0) || pName2->z==0 ){\n    char *zColl;\n    assert( pName1->z );\n    zColl = sqlite3NameFromToken(pParse->db, pName1);\n    if( !zColl ) return;\n    pColl = sqlite3FindCollSeq(db, ENC(db), zColl, 0);\n    if( pColl ){\n      reindexDatabases(pParse, zColl);\n      sqlite3DbFree(db, zColl);\n      return;\n    }\n    sqlite3DbFree(db, zColl);\n  }\n  iDb = sqlite3TwoPartName(pParse, pName1, pName2, &pObjName);\n  if( iDb<0 ) return;\n  z = sqlite3NameFromToken(db, pObjName);\n  if( z==0 ) return;\n  zDb = db->aDb[iDb].zDbSName;\n  pTab = sqlite3FindTable(db, z, zDb);\n  if( pTab ){\n    reindexTable(pParse, pTab, 0);\n    sqlite3DbFree(db, z);\n    return;\n  }\n  pIndex = sqlite3FindIndex(db, z, zDb);\n  sqlite3DbFree(db, z);\n  if( pIndex ){\n    sqlite3BeginWriteOperation(pParse, 0, iDb);\n    sqlite3RefillIndex(pParse, pIndex, -1);\n    return;\n  }\n  sqlite3ErrorMsg(pParse, \"unable to identify the object to be reindexed\");\n}\n#endif\n\n/*\n** Return a KeyInfo structure that is appropriate for the given Index.\n**\n** The caller should invoke sqlite3KeyInfoUnref() on the returned object\n** when it has finished using it.\n*/\nSQLITE_PRIVATE KeyInfo *sqlite3KeyInfoOfIndex(Parse *pParse, Index *pIdx){\n  int i;\n  int nCol = pIdx->nColumn;\n  int nKey = pIdx->nKeyCol;\n  KeyInfo *pKey;\n  if( pParse->nErr ) return 0;\n  if( pIdx->uniqNotNull ){\n    pKey = sqlite3KeyInfoAlloc(pParse->db, nKey, nCol-nKey);\n  }else{\n    pKey = sqlite3KeyInfoAlloc(pParse->db, nCol, 0);\n  }\n  if( pKey ){\n    assert( sqlite3KeyInfoIsWriteable(pKey) );\n    for(i=0; i<nCol; i++){\n      const char *zColl = pIdx->azColl[i];\n      pKey->aColl[i] = zColl==sqlite3StrBINARY ? 0 :\n                        sqlite3LocateCollSeq(pParse, zColl);\n      pKey->aSortOrder[i] = pIdx->aSortOrder[i];\n    }\n    if( pParse->nErr ){\n      assert( pParse->rc==SQLITE_ERROR_MISSING_COLLSEQ );\n      if( pIdx->bNoQuery==0 ){\n        /* Deactivate the index because it contains an unknown collating\n        ** sequence.  The only way to reactive the index is to reload the\n        ** schema.  Adding the missing collating sequence later does not\n        ** reactive the index.  The application had the chance to register\n        ** the missing index using the collation-needed callback.  For\n        ** simplicity, SQLite will not give the application a second chance.\n        */\n        pIdx->bNoQuery = 1;\n        pParse->rc = SQLITE_ERROR_RETRY;\n      }\n      sqlite3KeyInfoUnref(pKey);\n      pKey = 0;\n    }\n  }\n  return pKey;\n}\n\n#ifndef SQLITE_OMIT_CTE\n/* \n** This routine is invoked once per CTE by the parser while parsing a \n** WITH clause. \n*/\nSQLITE_PRIVATE With *sqlite3WithAdd(\n  Parse *pParse,          /* Parsing context */\n  With *pWith,            /* Existing WITH clause, or NULL */\n  Token *pName,           /* Name of the common-table */\n  ExprList *pArglist,     /* Optional column name list for the table */\n  Select *pQuery          /* Query used to initialize the table */\n){\n  sqlite3 *db = pParse->db;\n  With *pNew;\n  char *zName;\n\n  /* Check that the CTE name is unique within this WITH clause. If\n  ** not, store an error in the Parse structure. */\n  zName = sqlite3NameFromToken(pParse->db, pName);\n  if( zName && pWith ){\n    int i;\n    for(i=0; i<pWith->nCte; i++){\n      if( sqlite3StrICmp(zName, pWith->a[i].zName)==0 ){\n        sqlite3ErrorMsg(pParse, \"duplicate WITH table name: %s\", zName);\n      }\n    }\n  }\n\n  if( pWith ){\n    int nByte = sizeof(*pWith) + (sizeof(pWith->a[1]) * pWith->nCte);\n    pNew = sqlite3DbRealloc(db, pWith, nByte);\n  }else{\n    pNew = sqlite3DbMallocZero(db, sizeof(*pWith));\n  }\n  assert( (pNew!=0 && zName!=0) || db->mallocFailed );\n\n  if( db->mallocFailed ){\n    sqlite3ExprListDelete(db, pArglist);\n    sqlite3SelectDelete(db, pQuery);\n    sqlite3DbFree(db, zName);\n    pNew = pWith;\n  }else{\n    pNew->a[pNew->nCte].pSelect = pQuery;\n    pNew->a[pNew->nCte].pCols = pArglist;\n    pNew->a[pNew->nCte].zName = zName;\n    pNew->a[pNew->nCte].zCteErr = 0;\n    pNew->nCte++;\n  }\n\n  return pNew;\n}\n\n/*\n** Free the contents of the With object passed as the second argument.\n*/\nSQLITE_PRIVATE void sqlite3WithDelete(sqlite3 *db, With *pWith){\n  if( pWith ){\n    int i;\n    for(i=0; i<pWith->nCte; i++){\n      struct Cte *pCte = &pWith->a[i];\n      sqlite3ExprListDelete(db, pCte->pCols);\n      sqlite3SelectDelete(db, pCte->pSelect);\n      sqlite3DbFree(db, pCte->zName);\n    }\n    sqlite3DbFree(db, pWith);\n  }\n}\n#endif /* !defined(SQLITE_OMIT_CTE) */\n\n/************** End of build.c ***********************************************/\n/************** Begin file callback.c ****************************************/\n/*\n** 2005 May 23 \n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n**\n** This file contains functions used to access the internal hash tables\n** of user defined functions and collation sequences.\n*/\n\n/* #include \"sqliteInt.h\" */\n\n/*\n** Invoke the 'collation needed' callback to request a collation sequence\n** in the encoding enc of name zName, length nName.\n*/\nstatic void callCollNeeded(sqlite3 *db, int enc, const char *zName){\n  assert( !db->xCollNeeded || !db->xCollNeeded16 );\n  if( db->xCollNeeded ){\n    char *zExternal = sqlite3DbStrDup(db, zName);\n    if( !zExternal ) return;\n    db->xCollNeeded(db->pCollNeededArg, db, enc, zExternal);\n    sqlite3DbFree(db, zExternal);\n  }\n#ifndef SQLITE_OMIT_UTF16\n  if( db->xCollNeeded16 ){\n    char const *zExternal;\n    sqlite3_value *pTmp = sqlite3ValueNew(db);\n    sqlite3ValueSetStr(pTmp, -1, zName, SQLITE_UTF8, SQLITE_STATIC);\n    zExternal = sqlite3ValueText(pTmp, SQLITE_UTF16NATIVE);\n    if( zExternal ){\n      db->xCollNeeded16(db->pCollNeededArg, db, (int)ENC(db), zExternal);\n    }\n    sqlite3ValueFree(pTmp);\n  }\n#endif\n}\n\n/*\n** This routine is called if the collation factory fails to deliver a\n** collation function in the best encoding but there may be other versions\n** of this collation function (for other text encodings) available. Use one\n** of these instead if they exist. Avoid a UTF-8 <-> UTF-16 conversion if\n** possible.\n*/\nstatic int synthCollSeq(sqlite3 *db, CollSeq *pColl){\n  CollSeq *pColl2;\n  char *z = pColl->zName;\n  int i;\n  static const u8 aEnc[] = { SQLITE_UTF16BE, SQLITE_UTF16LE, SQLITE_UTF8 };\n  for(i=0; i<3; i++){\n    pColl2 = sqlite3FindCollSeq(db, aEnc[i], z, 0);\n    if( pColl2->xCmp!=0 ){\n      memcpy(pColl, pColl2, sizeof(CollSeq));\n      pColl->xDel = 0;         /* Do not copy the destructor */\n      return SQLITE_OK;\n    }\n  }\n  return SQLITE_ERROR;\n}\n\n/*\n** This function is responsible for invoking the collation factory callback\n** or substituting a collation sequence of a different encoding when the\n** requested collation sequence is not available in the desired encoding.\n** \n** If it is not NULL, then pColl must point to the database native encoding \n** collation sequence with name zName, length nName.\n**\n** The return value is either the collation sequence to be used in database\n** db for collation type name zName, length nName, or NULL, if no collation\n** sequence can be found.  If no collation is found, leave an error message.\n**\n** See also: sqlite3LocateCollSeq(), sqlite3FindCollSeq()\n*/\nSQLITE_PRIVATE CollSeq *sqlite3GetCollSeq(\n  Parse *pParse,        /* Parsing context */\n  u8 enc,               /* The desired encoding for the collating sequence */\n  CollSeq *pColl,       /* Collating sequence with native encoding, or NULL */\n  const char *zName     /* Collating sequence name */\n){\n  CollSeq *p;\n  sqlite3 *db = pParse->db;\n\n  p = pColl;\n  if( !p ){\n    p = sqlite3FindCollSeq(db, enc, zName, 0);\n  }\n  if( !p || !p->xCmp ){\n    /* No collation sequence of this type for this encoding is registered.\n    ** Call the collation factory to see if it can supply us with one.\n    */\n    callCollNeeded(db, enc, zName);\n    p = sqlite3FindCollSeq(db, enc, zName, 0);\n  }\n  if( p && !p->xCmp && synthCollSeq(db, p) ){\n    p = 0;\n  }\n  assert( !p || p->xCmp );\n  if( p==0 ){\n    sqlite3ErrorMsg(pParse, \"no such collation sequence: %s\", zName);\n    pParse->rc = SQLITE_ERROR_MISSING_COLLSEQ;\n  }\n  return p;\n}\n\n/*\n** This routine is called on a collation sequence before it is used to\n** check that it is defined. An undefined collation sequence exists when\n** a database is loaded that contains references to collation sequences\n** that have not been defined by sqlite3_create_collation() etc.\n**\n** If required, this routine calls the 'collation needed' callback to\n** request a definition of the collating sequence. If this doesn't work, \n** an equivalent collating sequence that uses a text encoding different\n** from the main database is substituted, if one is available.\n*/\nSQLITE_PRIVATE int sqlite3CheckCollSeq(Parse *pParse, CollSeq *pColl){\n  if( pColl && pColl->xCmp==0 ){\n    const char *zName = pColl->zName;\n    sqlite3 *db = pParse->db;\n    CollSeq *p = sqlite3GetCollSeq(pParse, ENC(db), pColl, zName);\n    if( !p ){\n      return SQLITE_ERROR;\n    }\n    assert( p==pColl );\n  }\n  return SQLITE_OK;\n}\n\n\n\n/*\n** Locate and return an entry from the db.aCollSeq hash table. If the entry\n** specified by zName and nName is not found and parameter 'create' is\n** true, then create a new entry. Otherwise return NULL.\n**\n** Each pointer stored in the sqlite3.aCollSeq hash table contains an\n** array of three CollSeq structures. The first is the collation sequence\n** preferred for UTF-8, the second UTF-16le, and the third UTF-16be.\n**\n** Stored immediately after the three collation sequences is a copy of\n** the collation sequence name. A pointer to this string is stored in\n** each collation sequence structure.\n*/\nstatic CollSeq *findCollSeqEntry(\n  sqlite3 *db,          /* Database connection */\n  const char *zName,    /* Name of the collating sequence */\n  int create            /* Create a new entry if true */\n){\n  CollSeq *pColl;\n  pColl = sqlite3HashFind(&db->aCollSeq, zName);\n\n  if( 0==pColl && create ){\n    int nName = sqlite3Strlen30(zName) + 1;\n    pColl = sqlite3DbMallocZero(db, 3*sizeof(*pColl) + nName);\n    if( pColl ){\n      CollSeq *pDel = 0;\n      pColl[0].zName = (char*)&pColl[3];\n      pColl[0].enc = SQLITE_UTF8;\n      pColl[1].zName = (char*)&pColl[3];\n      pColl[1].enc = SQLITE_UTF16LE;\n      pColl[2].zName = (char*)&pColl[3];\n      pColl[2].enc = SQLITE_UTF16BE;\n      memcpy(pColl[0].zName, zName, nName);\n      pDel = sqlite3HashInsert(&db->aCollSeq, pColl[0].zName, pColl);\n\n      /* If a malloc() failure occurred in sqlite3HashInsert(), it will \n      ** return the pColl pointer to be deleted (because it wasn't added\n      ** to the hash table).\n      */\n      assert( pDel==0 || pDel==pColl );\n      if( pDel!=0 ){\n        sqlite3OomFault(db);\n        sqlite3DbFree(db, pDel);\n        pColl = 0;\n      }\n    }\n  }\n  return pColl;\n}\n\n/*\n** Parameter zName points to a UTF-8 encoded string nName bytes long.\n** Return the CollSeq* pointer for the collation sequence named zName\n** for the encoding 'enc' from the database 'db'.\n**\n** If the entry specified is not found and 'create' is true, then create a\n** new entry.  Otherwise return NULL.\n**\n** A separate function sqlite3LocateCollSeq() is a wrapper around\n** this routine.  sqlite3LocateCollSeq() invokes the collation factory\n** if necessary and generates an error message if the collating sequence\n** cannot be found.\n**\n** See also: sqlite3LocateCollSeq(), sqlite3GetCollSeq()\n*/\nSQLITE_PRIVATE CollSeq *sqlite3FindCollSeq(\n  sqlite3 *db,\n  u8 enc,\n  const char *zName,\n  int create\n){\n  CollSeq *pColl;\n  if( zName ){\n    pColl = findCollSeqEntry(db, zName, create);\n  }else{\n    pColl = db->pDfltColl;\n  }\n  assert( SQLITE_UTF8==1 && SQLITE_UTF16LE==2 && SQLITE_UTF16BE==3 );\n  assert( enc>=SQLITE_UTF8 && enc<=SQLITE_UTF16BE );\n  if( pColl ) pColl += enc-1;\n  return pColl;\n}\n\n/* During the search for the best function definition, this procedure\n** is called to test how well the function passed as the first argument\n** matches the request for a function with nArg arguments in a system\n** that uses encoding enc. The value returned indicates how well the\n** request is matched. A higher value indicates a better match.\n**\n** If nArg is -1 that means to only return a match (non-zero) if p->nArg\n** is also -1.  In other words, we are searching for a function that\n** takes a variable number of arguments.\n**\n** If nArg is -2 that means that we are searching for any function \n** regardless of the number of arguments it uses, so return a positive\n** match score for any\n**\n** The returned value is always between 0 and 6, as follows:\n**\n** 0: Not a match.\n** 1: UTF8/16 conversion required and function takes any number of arguments.\n** 2: UTF16 byte order change required and function takes any number of args.\n** 3: encoding matches and function takes any number of arguments\n** 4: UTF8/16 conversion required - argument count matches exactly\n** 5: UTF16 byte order conversion required - argument count matches exactly\n** 6: Perfect match:  encoding and argument count match exactly.\n**\n** If nArg==(-2) then any function with a non-null xSFunc is\n** a perfect match and any function with xSFunc NULL is\n** a non-match.\n*/\n#define FUNC_PERFECT_MATCH 6  /* The score for a perfect match */\nstatic int matchQuality(\n  FuncDef *p,     /* The function we are evaluating for match quality */\n  int nArg,       /* Desired number of arguments.  (-1)==any */\n  u8 enc          /* Desired text encoding */\n){\n  int match;\n\n  /* nArg of -2 is a special case */\n  if( nArg==(-2) ) return (p->xSFunc==0) ? 0 : FUNC_PERFECT_MATCH;\n\n  /* Wrong number of arguments means \"no match\" */\n  if( p->nArg!=nArg && p->nArg>=0 ) return 0;\n\n  /* Give a better score to a function with a specific number of arguments\n  ** than to function that accepts any number of arguments. */\n  if( p->nArg==nArg ){\n    match = 4;\n  }else{\n    match = 1;\n  }\n\n  /* Bonus points if the text encoding matches */\n  if( enc==(p->funcFlags & SQLITE_FUNC_ENCMASK) ){\n    match += 2;  /* Exact encoding match */\n  }else if( (enc & p->funcFlags & 2)!=0 ){\n    match += 1;  /* Both are UTF16, but with different byte orders */\n  }\n\n  return match;\n}\n\n/*\n** Search a FuncDefHash for a function with the given name.  Return\n** a pointer to the matching FuncDef if found, or 0 if there is no match.\n*/\nSQLITE_PRIVATE FuncDef *sqlite3FunctionSearch(\n  int h,               /* Hash of the name */\n  const char *zFunc    /* Name of function */\n){\n  FuncDef *p;\n  for(p=sqlite3BuiltinFunctions.a[h]; p; p=p->u.pHash){\n    if( sqlite3StrICmp(p->zName, zFunc)==0 ){\n      return p;\n    }\n  }\n  return 0;\n}\n\n/*\n** Insert a new FuncDef into a FuncDefHash hash table.\n*/\nSQLITE_PRIVATE void sqlite3InsertBuiltinFuncs(\n  FuncDef *aDef,      /* List of global functions to be inserted */\n  int nDef            /* Length of the apDef[] list */\n){\n  int i;\n  for(i=0; i<nDef; i++){\n    FuncDef *pOther;\n    const char *zName = aDef[i].zName;\n    int nName = sqlite3Strlen30(zName);\n    int h = SQLITE_FUNC_HASH(zName[0], nName);\n    assert( zName[0]>='a' && zName[0]<='z' );\n    pOther = sqlite3FunctionSearch(h, zName);\n    if( pOther ){\n      assert( pOther!=&aDef[i] && pOther->pNext!=&aDef[i] );\n      aDef[i].pNext = pOther->pNext;\n      pOther->pNext = &aDef[i];\n    }else{\n      aDef[i].pNext = 0;\n      aDef[i].u.pHash = sqlite3BuiltinFunctions.a[h];\n      sqlite3BuiltinFunctions.a[h] = &aDef[i];\n    }\n  }\n}\n  \n  \n\n/*\n** Locate a user function given a name, a number of arguments and a flag\n** indicating whether the function prefers UTF-16 over UTF-8.  Return a\n** pointer to the FuncDef structure that defines that function, or return\n** NULL if the function does not exist.\n**\n** If the createFlag argument is true, then a new (blank) FuncDef\n** structure is created and liked into the \"db\" structure if a\n** no matching function previously existed.\n**\n** If nArg is -2, then the first valid function found is returned.  A\n** function is valid if xSFunc is non-zero.  The nArg==(-2)\n** case is used to see if zName is a valid function name for some number\n** of arguments.  If nArg is -2, then createFlag must be 0.\n**\n** If createFlag is false, then a function with the required name and\n** number of arguments may be returned even if the eTextRep flag does not\n** match that requested.\n*/\nSQLITE_PRIVATE FuncDef *sqlite3FindFunction(\n  sqlite3 *db,       /* An open database */\n  const char *zName, /* Name of the function.  zero-terminated */\n  int nArg,          /* Number of arguments.  -1 means any number */\n  u8 enc,            /* Preferred text encoding */\n  u8 createFlag      /* Create new entry if true and does not otherwise exist */\n){\n  FuncDef *p;         /* Iterator variable */\n  FuncDef *pBest = 0; /* Best match found so far */\n  int bestScore = 0;  /* Score of best match */\n  int h;              /* Hash value */\n  int nName;          /* Length of the name */\n\n  assert( nArg>=(-2) );\n  assert( nArg>=(-1) || createFlag==0 );\n  nName = sqlite3Strlen30(zName);\n\n  /* First search for a match amongst the application-defined functions.\n  */\n  p = (FuncDef*)sqlite3HashFind(&db->aFunc, zName);\n  while( p ){\n    int score = matchQuality(p, nArg, enc);\n    if( score>bestScore ){\n      pBest = p;\n      bestScore = score;\n    }\n    p = p->pNext;\n  }\n\n  /* If no match is found, search the built-in functions.\n  **\n  ** If the DBFLAG_PreferBuiltin flag is set, then search the built-in\n  ** functions even if a prior app-defined function was found.  And give\n  ** priority to built-in functions.\n  **\n  ** Except, if createFlag is true, that means that we are trying to\n  ** install a new function.  Whatever FuncDef structure is returned it will\n  ** have fields overwritten with new information appropriate for the\n  ** new function.  But the FuncDefs for built-in functions are read-only.\n  ** So we must not search for built-ins when creating a new function.\n  */ \n  if( !createFlag && (pBest==0 || (db->mDbFlags & DBFLAG_PreferBuiltin)!=0) ){\n    bestScore = 0;\n    h = SQLITE_FUNC_HASH(sqlite3UpperToLower[(u8)zName[0]], nName);\n    p = sqlite3FunctionSearch(h, zName);\n    while( p ){\n      int score = matchQuality(p, nArg, enc);\n      if( score>bestScore ){\n        pBest = p;\n        bestScore = score;\n      }\n      p = p->pNext;\n    }\n  }\n\n  /* If the createFlag parameter is true and the search did not reveal an\n  ** exact match for the name, number of arguments and encoding, then add a\n  ** new entry to the hash table and return it.\n  */\n  if( createFlag && bestScore<FUNC_PERFECT_MATCH && \n      (pBest = sqlite3DbMallocZero(db, sizeof(*pBest)+nName+1))!=0 ){\n    FuncDef *pOther;\n    u8 *z;\n    pBest->zName = (const char*)&pBest[1];\n    pBest->nArg = (u16)nArg;\n    pBest->funcFlags = enc;\n    memcpy((char*)&pBest[1], zName, nName+1);\n    for(z=(u8*)pBest->zName; *z; z++) *z = sqlite3UpperToLower[*z];\n    pOther = (FuncDef*)sqlite3HashInsert(&db->aFunc, pBest->zName, pBest);\n    if( pOther==pBest ){\n      sqlite3DbFree(db, pBest);\n      sqlite3OomFault(db);\n      return 0;\n    }else{\n      pBest->pNext = pOther;\n    }\n  }\n\n  if( pBest && (pBest->xSFunc || createFlag) ){\n    return pBest;\n  }\n  return 0;\n}\n\n/*\n** Free all resources held by the schema structure. The void* argument points\n** at a Schema struct. This function does not call sqlite3DbFree(db, ) on the \n** pointer itself, it just cleans up subsidiary resources (i.e. the contents\n** of the schema hash tables).\n**\n** The Schema.cache_size variable is not cleared.\n*/\nSQLITE_PRIVATE void sqlite3SchemaClear(void *p){\n  Hash temp1;\n  Hash temp2;\n  HashElem *pElem;\n  Schema *pSchema = (Schema *)p;\n\n  temp1 = pSchema->tblHash;\n  temp2 = pSchema->trigHash;\n  sqlite3HashInit(&pSchema->trigHash);\n  sqlite3HashClear(&pSchema->idxHash);\n  for(pElem=sqliteHashFirst(&temp2); pElem; pElem=sqliteHashNext(pElem)){\n    sqlite3DeleteTrigger(0, (Trigger*)sqliteHashData(pElem));\n  }\n  sqlite3HashClear(&temp2);\n  sqlite3HashInit(&pSchema->tblHash);\n  for(pElem=sqliteHashFirst(&temp1); pElem; pElem=sqliteHashNext(pElem)){\n    Table *pTab = sqliteHashData(pElem);\n    sqlite3DeleteTable(0, pTab);\n  }\n  sqlite3HashClear(&temp1);\n  sqlite3HashClear(&pSchema->fkeyHash);\n  pSchema->pSeqTab = 0;\n  if( pSchema->schemaFlags & DB_SchemaLoaded ){\n    pSchema->iGeneration++;\n  }\n  pSchema->schemaFlags &= ~(DB_SchemaLoaded|DB_ResetWanted);\n}\n\n/*\n** Find and return the schema associated with a BTree.  Create\n** a new one if necessary.\n*/\nSQLITE_PRIVATE Schema *sqlite3SchemaGet(sqlite3 *db, Btree *pBt){\n  Schema * p;\n  if( pBt ){\n    p = (Schema *)sqlite3BtreeSchema(pBt, sizeof(Schema), sqlite3SchemaClear);\n  }else{\n    p = (Schema *)sqlite3DbMallocZero(0, sizeof(Schema));\n  }\n  if( !p ){\n    sqlite3OomFault(db);\n  }else if ( 0==p->file_format ){\n    sqlite3HashInit(&p->tblHash);\n    sqlite3HashInit(&p->idxHash);\n    sqlite3HashInit(&p->trigHash);\n    sqlite3HashInit(&p->fkeyHash);\n    p->enc = SQLITE_UTF8;\n  }\n  return p;\n}\n\n/************** End of callback.c ********************************************/\n/************** Begin file delete.c ******************************************/\n/*\n** 2001 September 15\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This file contains C code routines that are called by the parser\n** in order to generate code for DELETE FROM statements.\n*/\n/* #include \"sqliteInt.h\" */\n\n/*\n** While a SrcList can in general represent multiple tables and subqueries\n** (as in the FROM clause of a SELECT statement) in this case it contains\n** the name of a single table, as one might find in an INSERT, DELETE,\n** or UPDATE statement.  Look up that table in the symbol table and\n** return a pointer.  Set an error message and return NULL if the table \n** name is not found or if any other error occurs.\n**\n** The following fields are initialized appropriate in pSrc:\n**\n**    pSrc->a[0].pTab       Pointer to the Table object\n**    pSrc->a[0].pIndex     Pointer to the INDEXED BY index, if there is one\n**\n*/\nSQLITE_PRIVATE Table *sqlite3SrcListLookup(Parse *pParse, SrcList *pSrc){\n  struct SrcList_item *pItem = pSrc->a;\n  Table *pTab;\n  assert( pItem && pSrc->nSrc==1 );\n  pTab = sqlite3LocateTableItem(pParse, 0, pItem);\n  sqlite3DeleteTable(pParse->db, pItem->pTab);\n  pItem->pTab = pTab;\n  if( pTab ){\n    pTab->nTabRef++;\n  }\n  if( sqlite3IndexedByLookup(pParse, pItem) ){\n    pTab = 0;\n  }\n  return pTab;\n}\n\n/* Return true if table pTab is read-only.\n**\n** A table is read-only if any of the following are true:\n**\n**   1) It is a virtual table and no implementation of the xUpdate method\n**      has been provided\n**\n**   2) It is a system table (i.e. sqlite_master), this call is not\n**      part of a nested parse and writable_schema pragma has not \n**      been specified\n**\n**   3) The table is a shadow table, the database connection is in\n**      defensive mode, and the current sqlite3_prepare()\n**      is for a top-level SQL statement.\n*/\nstatic int tabIsReadOnly(Parse *pParse, Table *pTab){\n  sqlite3 *db;\n  if( IsVirtual(pTab) ){\n    return sqlite3GetVTable(pParse->db, pTab)->pMod->pModule->xUpdate==0;\n  }\n  if( (pTab->tabFlags & (TF_Readonly|TF_Shadow))==0 ) return 0;\n  db = pParse->db;\n  if( (pTab->tabFlags & TF_Readonly)!=0 ){\n    return sqlite3WritableSchema(db)==0 && pParse->nested==0;\n  }\n  assert( pTab->tabFlags & TF_Shadow );\n  return (db->flags & SQLITE_Defensive)!=0 \n#ifndef SQLITE_OMIT_VIRTUALTABLE\n          && db->pVtabCtx==0\n#endif\n          && db->nVdbeExec==0;\n}\n\n/*\n** Check to make sure the given table is writable.  If it is not\n** writable, generate an error message and return 1.  If it is\n** writable return 0;\n*/\nSQLITE_PRIVATE int sqlite3IsReadOnly(Parse *pParse, Table *pTab, int viewOk){\n  if( tabIsReadOnly(pParse, pTab) ){\n    sqlite3ErrorMsg(pParse, \"table %s may not be modified\", pTab->zName);\n    return 1;\n  }\n#ifndef SQLITE_OMIT_VIEW\n  if( !viewOk && pTab->pSelect ){\n    sqlite3ErrorMsg(pParse,\"cannot modify %s because it is a view\",pTab->zName);\n    return 1;\n  }\n#endif\n  return 0;\n}\n\n\n#if !defined(SQLITE_OMIT_VIEW) && !defined(SQLITE_OMIT_TRIGGER)\n/*\n** Evaluate a view and store its result in an ephemeral table.  The\n** pWhere argument is an optional WHERE clause that restricts the\n** set of rows in the view that are to be added to the ephemeral table.\n*/\nSQLITE_PRIVATE void sqlite3MaterializeView(\n  Parse *pParse,       /* Parsing context */\n  Table *pView,        /* View definition */\n  Expr *pWhere,        /* Optional WHERE clause to be added */\n  ExprList *pOrderBy,  /* Optional ORDER BY clause */\n  Expr *pLimit,        /* Optional LIMIT clause */\n  int iCur             /* Cursor number for ephemeral table */\n){\n  SelectDest dest;\n  Select *pSel;\n  SrcList *pFrom;\n  sqlite3 *db = pParse->db;\n  int iDb = sqlite3SchemaToIndex(db, pView->pSchema);\n  pWhere = sqlite3ExprDup(db, pWhere, 0);\n  pFrom = sqlite3SrcListAppend(pParse, 0, 0, 0);\n  if( pFrom ){\n    assert( pFrom->nSrc==1 );\n    pFrom->a[0].zName = sqlite3DbStrDup(db, pView->zName);\n    pFrom->a[0].zDatabase = sqlite3DbStrDup(db, db->aDb[iDb].zDbSName);\n    assert( pFrom->a[0].pOn==0 );\n    assert( pFrom->a[0].pUsing==0 );\n  }\n  pSel = sqlite3SelectNew(pParse, 0, pFrom, pWhere, 0, 0, pOrderBy, \n                          SF_IncludeHidden, pLimit);\n  sqlite3SelectDestInit(&dest, SRT_EphemTab, iCur);\n  sqlite3Select(pParse, pSel, &dest);\n  sqlite3SelectDelete(db, pSel);\n}\n#endif /* !defined(SQLITE_OMIT_VIEW) && !defined(SQLITE_OMIT_TRIGGER) */\n\n#if defined(SQLITE_ENABLE_UPDATE_DELETE_LIMIT) && !defined(SQLITE_OMIT_SUBQUERY)\n/*\n** Generate an expression tree to implement the WHERE, ORDER BY,\n** and LIMIT/OFFSET portion of DELETE and UPDATE statements.\n**\n**     DELETE FROM table_wxyz WHERE a<5 ORDER BY a LIMIT 1;\n**                            \\__________________________/\n**                               pLimitWhere (pInClause)\n*/\nSQLITE_PRIVATE Expr *sqlite3LimitWhere(\n  Parse *pParse,               /* The parser context */\n  SrcList *pSrc,               /* the FROM clause -- which tables to scan */\n  Expr *pWhere,                /* The WHERE clause.  May be null */\n  ExprList *pOrderBy,          /* The ORDER BY clause.  May be null */\n  Expr *pLimit,                /* The LIMIT clause.  May be null */\n  char *zStmtType              /* Either DELETE or UPDATE.  For err msgs. */\n){\n  sqlite3 *db = pParse->db;\n  Expr *pLhs = NULL;           /* LHS of IN(SELECT...) operator */\n  Expr *pInClause = NULL;      /* WHERE rowid IN ( select ) */\n  ExprList *pEList = NULL;     /* Expression list contaning only pSelectRowid */\n  SrcList *pSelectSrc = NULL;  /* SELECT rowid FROM x ... (dup of pSrc) */\n  Select *pSelect = NULL;      /* Complete SELECT tree */\n  Table *pTab;\n\n  /* Check that there isn't an ORDER BY without a LIMIT clause.\n  */\n  if( pOrderBy && pLimit==0 ) {\n    sqlite3ErrorMsg(pParse, \"ORDER BY without LIMIT on %s\", zStmtType);\n    sqlite3ExprDelete(pParse->db, pWhere);\n    sqlite3ExprListDelete(pParse->db, pOrderBy);\n    return 0;\n  }\n\n  /* We only need to generate a select expression if there\n  ** is a limit/offset term to enforce.\n  */\n  if( pLimit == 0 ) {\n    return pWhere;\n  }\n\n  /* Generate a select expression tree to enforce the limit/offset \n  ** term for the DELETE or UPDATE statement.  For example:\n  **   DELETE FROM table_a WHERE col1=1 ORDER BY col2 LIMIT 1 OFFSET 1\n  ** becomes:\n  **   DELETE FROM table_a WHERE rowid IN ( \n  **     SELECT rowid FROM table_a WHERE col1=1 ORDER BY col2 LIMIT 1 OFFSET 1\n  **   );\n  */\n\n  pTab = pSrc->a[0].pTab;\n  if( HasRowid(pTab) ){\n    pLhs = sqlite3PExpr(pParse, TK_ROW, 0, 0);\n    pEList = sqlite3ExprListAppend(\n        pParse, 0, sqlite3PExpr(pParse, TK_ROW, 0, 0)\n    );\n  }else{\n    Index *pPk = sqlite3PrimaryKeyIndex(pTab);\n    if( pPk->nKeyCol==1 ){\n      const char *zName = pTab->aCol[pPk->aiColumn[0]].zName;\n      pLhs = sqlite3Expr(db, TK_ID, zName);\n      pEList = sqlite3ExprListAppend(pParse, 0, sqlite3Expr(db, TK_ID, zName));\n    }else{\n      int i;\n      for(i=0; i<pPk->nKeyCol; i++){\n        Expr *p = sqlite3Expr(db, TK_ID, pTab->aCol[pPk->aiColumn[i]].zName);\n        pEList = sqlite3ExprListAppend(pParse, pEList, p);\n      }\n      pLhs = sqlite3PExpr(pParse, TK_VECTOR, 0, 0);\n      if( pLhs ){\n        pLhs->x.pList = sqlite3ExprListDup(db, pEList, 0);\n      }\n    }\n  }\n\n  /* duplicate the FROM clause as it is needed by both the DELETE/UPDATE tree\n  ** and the SELECT subtree. */\n  pSrc->a[0].pTab = 0;\n  pSelectSrc = sqlite3SrcListDup(pParse->db, pSrc, 0);\n  pSrc->a[0].pTab = pTab;\n  pSrc->a[0].pIBIndex = 0;\n\n  /* generate the SELECT expression tree. */\n  pSelect = sqlite3SelectNew(pParse, pEList, pSelectSrc, pWhere, 0 ,0, \n      pOrderBy,0,pLimit\n  );\n\n  /* now generate the new WHERE rowid IN clause for the DELETE/UDPATE */\n  pInClause = sqlite3PExpr(pParse, TK_IN, pLhs, 0);\n  sqlite3PExprAddSelect(pParse, pInClause, pSelect);\n  return pInClause;\n}\n#endif /* defined(SQLITE_ENABLE_UPDATE_DELETE_LIMIT) */\n       /*      && !defined(SQLITE_OMIT_SUBQUERY) */\n\n/*\n** Generate code for a DELETE FROM statement.\n**\n**     DELETE FROM table_wxyz WHERE a<5 AND b NOT NULL;\n**                 \\________/       \\________________/\n**                  pTabList              pWhere\n*/\nSQLITE_PRIVATE void sqlite3DeleteFrom(\n  Parse *pParse,         /* The parser context */\n  SrcList *pTabList,     /* The table from which we should delete things */\n  Expr *pWhere,          /* The WHERE clause.  May be null */\n  ExprList *pOrderBy,    /* ORDER BY clause. May be null */\n  Expr *pLimit           /* LIMIT clause. May be null */\n){\n  Vdbe *v;               /* The virtual database engine */\n  Table *pTab;           /* The table from which records will be deleted */\n  int i;                 /* Loop counter */\n  WhereInfo *pWInfo;     /* Information about the WHERE clause */\n  Index *pIdx;           /* For looping over indices of the table */\n  int iTabCur;           /* Cursor number for the table */\n  int iDataCur = 0;      /* VDBE cursor for the canonical data source */\n  int iIdxCur = 0;       /* Cursor number of the first index */\n  int nIdx;              /* Number of indices */\n  sqlite3 *db;           /* Main database structure */\n  AuthContext sContext;  /* Authorization context */\n  NameContext sNC;       /* Name context to resolve expressions in */\n  int iDb;               /* Database number */\n  int memCnt = 0;        /* Memory cell used for change counting */\n  int rcauth;            /* Value returned by authorization callback */\n  int eOnePass;          /* ONEPASS_OFF or _SINGLE or _MULTI */\n  int aiCurOnePass[2];   /* The write cursors opened by WHERE_ONEPASS */\n  u8 *aToOpen = 0;       /* Open cursor iTabCur+j if aToOpen[j] is true */\n  Index *pPk;            /* The PRIMARY KEY index on the table */\n  int iPk = 0;           /* First of nPk registers holding PRIMARY KEY value */\n  i16 nPk = 1;           /* Number of columns in the PRIMARY KEY */\n  int iKey;              /* Memory cell holding key of row to be deleted */\n  i16 nKey;              /* Number of memory cells in the row key */\n  int iEphCur = 0;       /* Ephemeral table holding all primary key values */\n  int iRowSet = 0;       /* Register for rowset of rows to delete */\n  int addrBypass = 0;    /* Address of jump over the delete logic */\n  int addrLoop = 0;      /* Top of the delete loop */\n  int addrEphOpen = 0;   /* Instruction to open the Ephemeral table */\n  int bComplex;          /* True if there are triggers or FKs or\n                         ** subqueries in the WHERE clause */\n \n#ifndef SQLITE_OMIT_TRIGGER\n  int isView;                  /* True if attempting to delete from a view */\n  Trigger *pTrigger;           /* List of table triggers, if required */\n#endif\n\n  memset(&sContext, 0, sizeof(sContext));\n  db = pParse->db;\n  if( pParse->nErr || db->mallocFailed ){\n    goto delete_from_cleanup;\n  }\n  assert( pTabList->nSrc==1 );\n\n\n  /* Locate the table which we want to delete.  This table has to be\n  ** put in an SrcList structure because some of the subroutines we\n  ** will be calling are designed to work with multiple tables and expect\n  ** an SrcList* parameter instead of just a Table* parameter.\n  */\n  pTab = sqlite3SrcListLookup(pParse, pTabList);\n  if( pTab==0 )  goto delete_from_cleanup;\n\n  /* Figure out if we have any triggers and if the table being\n  ** deleted from is a view\n  */\n#ifndef SQLITE_OMIT_TRIGGER\n  pTrigger = sqlite3TriggersExist(pParse, pTab, TK_DELETE, 0, 0);\n  isView = pTab->pSelect!=0;\n#else\n# define pTrigger 0\n# define isView 0\n#endif\n  bComplex = pTrigger || sqlite3FkRequired(pParse, pTab, 0, 0);\n#ifdef SQLITE_OMIT_VIEW\n# undef isView\n# define isView 0\n#endif\n\n#ifdef SQLITE_ENABLE_UPDATE_DELETE_LIMIT\n  if( !isView ){\n    pWhere = sqlite3LimitWhere(\n        pParse, pTabList, pWhere, pOrderBy, pLimit, \"DELETE\"\n    );\n    pOrderBy = 0;\n    pLimit = 0;\n  }\n#endif\n\n  /* If pTab is really a view, make sure it has been initialized.\n  */\n  if( sqlite3ViewGetColumnNames(pParse, pTab) ){\n    goto delete_from_cleanup;\n  }\n\n  if( sqlite3IsReadOnly(pParse, pTab, (pTrigger?1:0)) ){\n    goto delete_from_cleanup;\n  }\n  iDb = sqlite3SchemaToIndex(db, pTab->pSchema);\n  assert( iDb<db->nDb );\n  rcauth = sqlite3AuthCheck(pParse, SQLITE_DELETE, pTab->zName, 0, \n                            db->aDb[iDb].zDbSName);\n  assert( rcauth==SQLITE_OK || rcauth==SQLITE_DENY || rcauth==SQLITE_IGNORE );\n  if( rcauth==SQLITE_DENY ){\n    goto delete_from_cleanup;\n  }\n  assert(!isView || pTrigger);\n\n  /* Assign cursor numbers to the table and all its indices.\n  */\n  assert( pTabList->nSrc==1 );\n  iTabCur = pTabList->a[0].iCursor = pParse->nTab++;\n  for(nIdx=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, nIdx++){\n    pParse->nTab++;\n  }\n\n  /* Start the view context\n  */\n  if( isView ){\n    sqlite3AuthContextPush(pParse, &sContext, pTab->zName);\n  }\n\n  /* Begin generating code.\n  */\n  v = sqlite3GetVdbe(pParse);\n  if( v==0 ){\n    goto delete_from_cleanup;\n  }\n  if( pParse->nested==0 ) sqlite3VdbeCountChanges(v);\n  sqlite3BeginWriteOperation(pParse, bComplex, iDb);\n\n  /* If we are trying to delete from a view, realize that view into\n  ** an ephemeral table.\n  */\n#if !defined(SQLITE_OMIT_VIEW) && !defined(SQLITE_OMIT_TRIGGER)\n  if( isView ){\n    sqlite3MaterializeView(pParse, pTab, \n        pWhere, pOrderBy, pLimit, iTabCur\n    );\n    iDataCur = iIdxCur = iTabCur;\n    pOrderBy = 0;\n    pLimit = 0;\n  }\n#endif\n\n  /* Resolve the column names in the WHERE clause.\n  */\n  memset(&sNC, 0, sizeof(sNC));\n  sNC.pParse = pParse;\n  sNC.pSrcList = pTabList;\n  if( sqlite3ResolveExprNames(&sNC, pWhere) ){\n    goto delete_from_cleanup;\n  }\n\n  /* Initialize the counter of the number of rows deleted, if\n  ** we are counting rows.\n  */\n  if( (db->flags & SQLITE_CountRows)!=0\n   && !pParse->nested\n   && !pParse->pTriggerTab\n  ){\n    memCnt = ++pParse->nMem;\n    sqlite3VdbeAddOp2(v, OP_Integer, 0, memCnt);\n  }\n\n#ifndef SQLITE_OMIT_TRUNCATE_OPTIMIZATION\n  /* Special case: A DELETE without a WHERE clause deletes everything.\n  ** It is easier just to erase the whole table. Prior to version 3.6.5,\n  ** this optimization caused the row change count (the value returned by \n  ** API function sqlite3_count_changes) to be set incorrectly.\n  **\n  ** The \"rcauth==SQLITE_OK\" terms is the\n  ** IMPLEMENTATION-OF: R-17228-37124 If the action code is SQLITE_DELETE and\n  ** the callback returns SQLITE_IGNORE then the DELETE operation proceeds but\n  ** the truncate optimization is disabled and all rows are deleted\n  ** individually.\n  */\n  if( rcauth==SQLITE_OK\n   && pWhere==0\n   && !bComplex\n   && !IsVirtual(pTab)\n#ifdef SQLITE_ENABLE_PREUPDATE_HOOK\n   && db->xPreUpdateCallback==0\n#endif\n  ){\n    assert( !isView );\n    sqlite3TableLock(pParse, iDb, pTab->tnum, 1, pTab->zName);\n    if( HasRowid(pTab) ){\n      sqlite3VdbeAddOp4(v, OP_Clear, pTab->tnum, iDb, memCnt ? memCnt : -1,\n                        pTab->zName, P4_STATIC);\n    }\n    for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){\n      assert( pIdx->pSchema==pTab->pSchema );\n      sqlite3VdbeAddOp2(v, OP_Clear, pIdx->tnum, iDb);\n    }\n  }else\n#endif /* SQLITE_OMIT_TRUNCATE_OPTIMIZATION */\n  {\n    u16 wcf = WHERE_ONEPASS_DESIRED|WHERE_DUPLICATES_OK|WHERE_SEEK_TABLE;\n    if( sNC.ncFlags & NC_VarSelect ) bComplex = 1;\n    wcf |= (bComplex ? 0 : WHERE_ONEPASS_MULTIROW);\n    if( HasRowid(pTab) ){\n      /* For a rowid table, initialize the RowSet to an empty set */\n      pPk = 0;\n      nPk = 1;\n      iRowSet = ++pParse->nMem;\n      sqlite3VdbeAddOp2(v, OP_Null, 0, iRowSet);\n    }else{\n      /* For a WITHOUT ROWID table, create an ephemeral table used to\n      ** hold all primary keys for rows to be deleted. */\n      pPk = sqlite3PrimaryKeyIndex(pTab);\n      assert( pPk!=0 );\n      nPk = pPk->nKeyCol;\n      iPk = pParse->nMem+1;\n      pParse->nMem += nPk;\n      iEphCur = pParse->nTab++;\n      addrEphOpen = sqlite3VdbeAddOp2(v, OP_OpenEphemeral, iEphCur, nPk);\n      sqlite3VdbeSetP4KeyInfo(pParse, pPk);\n    }\n  \n    /* Construct a query to find the rowid or primary key for every row\n    ** to be deleted, based on the WHERE clause. Set variable eOnePass\n    ** to indicate the strategy used to implement this delete:\n    **\n    **  ONEPASS_OFF:    Two-pass approach - use a FIFO for rowids/PK values.\n    **  ONEPASS_SINGLE: One-pass approach - at most one row deleted.\n    **  ONEPASS_MULTI:  One-pass approach - any number of rows may be deleted.\n    */\n    pWInfo = sqlite3WhereBegin(pParse, pTabList, pWhere, 0, 0, wcf, iTabCur+1);\n    if( pWInfo==0 ) goto delete_from_cleanup;\n    eOnePass = sqlite3WhereOkOnePass(pWInfo, aiCurOnePass);\n    assert( IsVirtual(pTab)==0 || eOnePass!=ONEPASS_MULTI );\n    assert( IsVirtual(pTab) || bComplex || eOnePass!=ONEPASS_OFF );\n    if( eOnePass!=ONEPASS_SINGLE ) sqlite3MultiWrite(pParse);\n  \n    /* Keep track of the number of rows to be deleted */\n    if( memCnt ){\n      sqlite3VdbeAddOp2(v, OP_AddImm, memCnt, 1);\n    }\n  \n    /* Extract the rowid or primary key for the current row */\n    if( pPk ){\n      for(i=0; i<nPk; i++){\n        assert( pPk->aiColumn[i]>=0 );\n        sqlite3ExprCodeGetColumnOfTable(v, pTab, iTabCur,\n                                        pPk->aiColumn[i], iPk+i);\n      }\n      iKey = iPk;\n    }else{\n      iKey = ++pParse->nMem;\n      sqlite3ExprCodeGetColumnOfTable(v, pTab, iTabCur, -1, iKey);\n    }\n  \n    if( eOnePass!=ONEPASS_OFF ){\n      /* For ONEPASS, no need to store the rowid/primary-key. There is only\n      ** one, so just keep it in its register(s) and fall through to the\n      ** delete code.  */\n      nKey = nPk; /* OP_Found will use an unpacked key */\n      aToOpen = sqlite3DbMallocRawNN(db, nIdx+2);\n      if( aToOpen==0 ){\n        sqlite3WhereEnd(pWInfo);\n        goto delete_from_cleanup;\n      }\n      memset(aToOpen, 1, nIdx+1);\n      aToOpen[nIdx+1] = 0;\n      if( aiCurOnePass[0]>=0 ) aToOpen[aiCurOnePass[0]-iTabCur] = 0;\n      if( aiCurOnePass[1]>=0 ) aToOpen[aiCurOnePass[1]-iTabCur] = 0;\n      if( addrEphOpen ) sqlite3VdbeChangeToNoop(v, addrEphOpen);\n    }else{\n      if( pPk ){\n        /* Add the PK key for this row to the temporary table */\n        iKey = ++pParse->nMem;\n        nKey = 0;   /* Zero tells OP_Found to use a composite key */\n        sqlite3VdbeAddOp4(v, OP_MakeRecord, iPk, nPk, iKey,\n            sqlite3IndexAffinityStr(pParse->db, pPk), nPk);\n        sqlite3VdbeAddOp4Int(v, OP_IdxInsert, iEphCur, iKey, iPk, nPk);\n      }else{\n        /* Add the rowid of the row to be deleted to the RowSet */\n        nKey = 1;  /* OP_DeferredSeek always uses a single rowid */\n        sqlite3VdbeAddOp2(v, OP_RowSetAdd, iRowSet, iKey);\n      }\n    }\n  \n    /* If this DELETE cannot use the ONEPASS strategy, this is the \n    ** end of the WHERE loop */\n    if( eOnePass!=ONEPASS_OFF ){\n      addrBypass = sqlite3VdbeMakeLabel(pParse);\n    }else{\n      sqlite3WhereEnd(pWInfo);\n    }\n  \n    /* Unless this is a view, open cursors for the table we are \n    ** deleting from and all its indices. If this is a view, then the\n    ** only effect this statement has is to fire the INSTEAD OF \n    ** triggers.\n    */\n    if( !isView ){\n      int iAddrOnce = 0;\n      if( eOnePass==ONEPASS_MULTI ){\n        iAddrOnce = sqlite3VdbeAddOp0(v, OP_Once); VdbeCoverage(v);\n      }\n      testcase( IsVirtual(pTab) );\n      sqlite3OpenTableAndIndices(pParse, pTab, OP_OpenWrite, OPFLAG_FORDELETE,\n                                 iTabCur, aToOpen, &iDataCur, &iIdxCur);\n      assert( pPk || IsVirtual(pTab) || iDataCur==iTabCur );\n      assert( pPk || IsVirtual(pTab) || iIdxCur==iDataCur+1 );\n      if( eOnePass==ONEPASS_MULTI ) sqlite3VdbeJumpHere(v, iAddrOnce);\n    }\n  \n    /* Set up a loop over the rowids/primary-keys that were found in the\n    ** where-clause loop above.\n    */\n    if( eOnePass!=ONEPASS_OFF ){\n      assert( nKey==nPk );  /* OP_Found will use an unpacked key */\n      if( !IsVirtual(pTab) && aToOpen[iDataCur-iTabCur] ){\n        assert( pPk!=0 || pTab->pSelect!=0 );\n        sqlite3VdbeAddOp4Int(v, OP_NotFound, iDataCur, addrBypass, iKey, nKey);\n        VdbeCoverage(v);\n      }\n    }else if( pPk ){\n      addrLoop = sqlite3VdbeAddOp1(v, OP_Rewind, iEphCur); VdbeCoverage(v);\n      if( IsVirtual(pTab) ){\n        sqlite3VdbeAddOp3(v, OP_Column, iEphCur, 0, iKey);\n      }else{\n        sqlite3VdbeAddOp2(v, OP_RowData, iEphCur, iKey);\n      }\n      assert( nKey==0 );  /* OP_Found will use a composite key */\n    }else{\n      addrLoop = sqlite3VdbeAddOp3(v, OP_RowSetRead, iRowSet, 0, iKey);\n      VdbeCoverage(v);\n      assert( nKey==1 );\n    }  \n  \n    /* Delete the row */\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n    if( IsVirtual(pTab) ){\n      const char *pVTab = (const char *)sqlite3GetVTable(db, pTab);\n      sqlite3VtabMakeWritable(pParse, pTab);\n      assert( eOnePass==ONEPASS_OFF || eOnePass==ONEPASS_SINGLE );\n      sqlite3MayAbort(pParse);\n      if( eOnePass==ONEPASS_SINGLE ){\n        sqlite3VdbeAddOp1(v, OP_Close, iTabCur);\n        if( sqlite3IsToplevel(pParse) ){\n          pParse->isMultiWrite = 0;\n        }\n      }\n      sqlite3VdbeAddOp4(v, OP_VUpdate, 0, 1, iKey, pVTab, P4_VTAB);\n      sqlite3VdbeChangeP5(v, OE_Abort);\n    }else\n#endif\n    {\n      int count = (pParse->nested==0);    /* True to count changes */\n      sqlite3GenerateRowDelete(pParse, pTab, pTrigger, iDataCur, iIdxCur,\n          iKey, nKey, count, OE_Default, eOnePass, aiCurOnePass[1]);\n    }\n  \n    /* End of the loop over all rowids/primary-keys. */\n    if( eOnePass!=ONEPASS_OFF ){\n      sqlite3VdbeResolveLabel(v, addrBypass);\n      sqlite3WhereEnd(pWInfo);\n    }else if( pPk ){\n      sqlite3VdbeAddOp2(v, OP_Next, iEphCur, addrLoop+1); VdbeCoverage(v);\n      sqlite3VdbeJumpHere(v, addrLoop);\n    }else{\n      sqlite3VdbeGoto(v, addrLoop);\n      sqlite3VdbeJumpHere(v, addrLoop);\n    }     \n  } /* End non-truncate path */\n\n  /* Update the sqlite_sequence table by storing the content of the\n  ** maximum rowid counter values recorded while inserting into\n  ** autoincrement tables.\n  */\n  if( pParse->nested==0 && pParse->pTriggerTab==0 ){\n    sqlite3AutoincrementEnd(pParse);\n  }\n\n  /* Return the number of rows that were deleted. If this routine is \n  ** generating code because of a call to sqlite3NestedParse(), do not\n  ** invoke the callback function.\n  */\n  if( memCnt ){\n    sqlite3VdbeAddOp2(v, OP_ResultRow, memCnt, 1);\n    sqlite3VdbeSetNumCols(v, 1);\n    sqlite3VdbeSetColName(v, 0, COLNAME_NAME, \"rows deleted\", SQLITE_STATIC);\n  }\n\ndelete_from_cleanup:\n  sqlite3AuthContextPop(&sContext);\n  sqlite3SrcListDelete(db, pTabList);\n  sqlite3ExprDelete(db, pWhere);\n#if defined(SQLITE_ENABLE_UPDATE_DELETE_LIMIT) \n  sqlite3ExprListDelete(db, pOrderBy);\n  sqlite3ExprDelete(db, pLimit);\n#endif\n  sqlite3DbFree(db, aToOpen);\n  return;\n}\n/* Make sure \"isView\" and other macros defined above are undefined. Otherwise\n** they may interfere with compilation of other functions in this file\n** (or in another file, if this file becomes part of the amalgamation).  */\n#ifdef isView\n #undef isView\n#endif\n#ifdef pTrigger\n #undef pTrigger\n#endif\n\n/*\n** This routine generates VDBE code that causes a single row of a\n** single table to be deleted.  Both the original table entry and\n** all indices are removed.\n**\n** Preconditions:\n**\n**   1.  iDataCur is an open cursor on the btree that is the canonical data\n**       store for the table.  (This will be either the table itself,\n**       in the case of a rowid table, or the PRIMARY KEY index in the case\n**       of a WITHOUT ROWID table.)\n**\n**   2.  Read/write cursors for all indices of pTab must be open as\n**       cursor number iIdxCur+i for the i-th index.\n**\n**   3.  The primary key for the row to be deleted must be stored in a\n**       sequence of nPk memory cells starting at iPk.  If nPk==0 that means\n**       that a search record formed from OP_MakeRecord is contained in the\n**       single memory location iPk.\n**\n** eMode:\n**   Parameter eMode may be passed either ONEPASS_OFF (0), ONEPASS_SINGLE, or\n**   ONEPASS_MULTI.  If eMode is not ONEPASS_OFF, then the cursor\n**   iDataCur already points to the row to delete. If eMode is ONEPASS_OFF\n**   then this function must seek iDataCur to the entry identified by iPk\n**   and nPk before reading from it.\n**\n**   If eMode is ONEPASS_MULTI, then this call is being made as part\n**   of a ONEPASS delete that affects multiple rows. In this case, if \n**   iIdxNoSeek is a valid cursor number (>=0) and is not the same as\n**   iDataCur, then its position should be preserved following the delete\n**   operation. Or, if iIdxNoSeek is not a valid cursor number, the\n**   position of iDataCur should be preserved instead.\n**\n** iIdxNoSeek:\n**   If iIdxNoSeek is a valid cursor number (>=0) not equal to iDataCur,\n**   then it identifies an index cursor (from within array of cursors\n**   starting at iIdxCur) that already points to the index entry to be deleted.\n**   Except, this optimization is disabled if there are BEFORE triggers since\n**   the trigger body might have moved the cursor.\n*/\nSQLITE_PRIVATE void sqlite3GenerateRowDelete(\n  Parse *pParse,     /* Parsing context */\n  Table *pTab,       /* Table containing the row to be deleted */\n  Trigger *pTrigger, /* List of triggers to (potentially) fire */\n  int iDataCur,      /* Cursor from which column data is extracted */\n  int iIdxCur,       /* First index cursor */\n  int iPk,           /* First memory cell containing the PRIMARY KEY */\n  i16 nPk,           /* Number of PRIMARY KEY memory cells */\n  u8 count,          /* If non-zero, increment the row change counter */\n  u8 onconf,         /* Default ON CONFLICT policy for triggers */\n  u8 eMode,          /* ONEPASS_OFF, _SINGLE, or _MULTI.  See above */\n  int iIdxNoSeek     /* Cursor number of cursor that does not need seeking */\n){\n  Vdbe *v = pParse->pVdbe;        /* Vdbe */\n  int iOld = 0;                   /* First register in OLD.* array */\n  int iLabel;                     /* Label resolved to end of generated code */\n  u8 opSeek;                      /* Seek opcode */\n\n  /* Vdbe is guaranteed to have been allocated by this stage. */\n  assert( v );\n  VdbeModuleComment((v, \"BEGIN: GenRowDel(%d,%d,%d,%d)\",\n                         iDataCur, iIdxCur, iPk, (int)nPk));\n\n  /* Seek cursor iCur to the row to delete. If this row no longer exists \n  ** (this can happen if a trigger program has already deleted it), do\n  ** not attempt to delete it or fire any DELETE triggers.  */\n  iLabel = sqlite3VdbeMakeLabel(pParse);\n  opSeek = HasRowid(pTab) ? OP_NotExists : OP_NotFound;\n  if( eMode==ONEPASS_OFF ){\n    sqlite3VdbeAddOp4Int(v, opSeek, iDataCur, iLabel, iPk, nPk);\n    VdbeCoverageIf(v, opSeek==OP_NotExists);\n    VdbeCoverageIf(v, opSeek==OP_NotFound);\n  }\n \n  /* If there are any triggers to fire, allocate a range of registers to\n  ** use for the old.* references in the triggers.  */\n  if( sqlite3FkRequired(pParse, pTab, 0, 0) || pTrigger ){\n    u32 mask;                     /* Mask of OLD.* columns in use */\n    int iCol;                     /* Iterator used while populating OLD.* */\n    int addrStart;                /* Start of BEFORE trigger programs */\n\n    /* TODO: Could use temporary registers here. Also could attempt to\n    ** avoid copying the contents of the rowid register.  */\n    mask = sqlite3TriggerColmask(\n        pParse, pTrigger, 0, 0, TRIGGER_BEFORE|TRIGGER_AFTER, pTab, onconf\n    );\n    mask |= sqlite3FkOldmask(pParse, pTab);\n    iOld = pParse->nMem+1;\n    pParse->nMem += (1 + pTab->nCol);\n\n    /* Populate the OLD.* pseudo-table register array. These values will be \n    ** used by any BEFORE and AFTER triggers that exist.  */\n    sqlite3VdbeAddOp2(v, OP_Copy, iPk, iOld);\n    for(iCol=0; iCol<pTab->nCol; iCol++){\n      testcase( mask!=0xffffffff && iCol==31 );\n      testcase( mask!=0xffffffff && iCol==32 );\n      if( mask==0xffffffff || (iCol<=31 && (mask & MASKBIT32(iCol))!=0) ){\n        sqlite3ExprCodeGetColumnOfTable(v, pTab, iDataCur, iCol, iOld+iCol+1);\n      }\n    }\n\n    /* Invoke BEFORE DELETE trigger programs. */\n    addrStart = sqlite3VdbeCurrentAddr(v);\n    sqlite3CodeRowTrigger(pParse, pTrigger, \n        TK_DELETE, 0, TRIGGER_BEFORE, pTab, iOld, onconf, iLabel\n    );\n\n    /* If any BEFORE triggers were coded, then seek the cursor to the \n    ** row to be deleted again. It may be that the BEFORE triggers moved\n    ** the cursor or already deleted the row that the cursor was\n    ** pointing to.\n    **\n    ** Also disable the iIdxNoSeek optimization since the BEFORE trigger\n    ** may have moved that cursor.\n    */\n    if( addrStart<sqlite3VdbeCurrentAddr(v) ){\n      sqlite3VdbeAddOp4Int(v, opSeek, iDataCur, iLabel, iPk, nPk);\n      VdbeCoverageIf(v, opSeek==OP_NotExists);\n      VdbeCoverageIf(v, opSeek==OP_NotFound);\n      testcase( iIdxNoSeek>=0 );\n      iIdxNoSeek = -1;\n    }\n\n    /* Do FK processing. This call checks that any FK constraints that\n    ** refer to this table (i.e. constraints attached to other tables) \n    ** are not violated by deleting this row.  */\n    sqlite3FkCheck(pParse, pTab, iOld, 0, 0, 0);\n  }\n\n  /* Delete the index and table entries. Skip this step if pTab is really\n  ** a view (in which case the only effect of the DELETE statement is to\n  ** fire the INSTEAD OF triggers).  \n  **\n  ** If variable 'count' is non-zero, then this OP_Delete instruction should\n  ** invoke the update-hook. The pre-update-hook, on the other hand should\n  ** be invoked unless table pTab is a system table. The difference is that\n  ** the update-hook is not invoked for rows removed by REPLACE, but the \n  ** pre-update-hook is.\n  */ \n  if( pTab->pSelect==0 ){\n    u8 p5 = 0;\n    sqlite3GenerateRowIndexDelete(pParse, pTab, iDataCur, iIdxCur,0,iIdxNoSeek);\n    sqlite3VdbeAddOp2(v, OP_Delete, iDataCur, (count?OPFLAG_NCHANGE:0));\n    if( pParse->nested==0 || 0==sqlite3_stricmp(pTab->zName, \"sqlite_stat1\") ){\n      sqlite3VdbeAppendP4(v, (char*)pTab, P4_TABLE);\n    }\n    if( eMode!=ONEPASS_OFF ){\n      sqlite3VdbeChangeP5(v, OPFLAG_AUXDELETE);\n    }\n    if( iIdxNoSeek>=0 && iIdxNoSeek!=iDataCur ){\n      sqlite3VdbeAddOp1(v, OP_Delete, iIdxNoSeek);\n    }\n    if( eMode==ONEPASS_MULTI ) p5 |= OPFLAG_SAVEPOSITION;\n    sqlite3VdbeChangeP5(v, p5);\n  }\n\n  /* Do any ON CASCADE, SET NULL or SET DEFAULT operations required to\n  ** handle rows (possibly in other tables) that refer via a foreign key\n  ** to the row just deleted. */ \n  sqlite3FkActions(pParse, pTab, 0, iOld, 0, 0);\n\n  /* Invoke AFTER DELETE trigger programs. */\n  sqlite3CodeRowTrigger(pParse, pTrigger, \n      TK_DELETE, 0, TRIGGER_AFTER, pTab, iOld, onconf, iLabel\n  );\n\n  /* Jump here if the row had already been deleted before any BEFORE\n  ** trigger programs were invoked. Or if a trigger program throws a \n  ** RAISE(IGNORE) exception.  */\n  sqlite3VdbeResolveLabel(v, iLabel);\n  VdbeModuleComment((v, \"END: GenRowDel()\"));\n}\n\n/*\n** This routine generates VDBE code that causes the deletion of all\n** index entries associated with a single row of a single table, pTab\n**\n** Preconditions:\n**\n**   1.  A read/write cursor \"iDataCur\" must be open on the canonical storage\n**       btree for the table pTab.  (This will be either the table itself\n**       for rowid tables or to the primary key index for WITHOUT ROWID\n**       tables.)\n**\n**   2.  Read/write cursors for all indices of pTab must be open as\n**       cursor number iIdxCur+i for the i-th index.  (The pTab->pIndex\n**       index is the 0-th index.)\n**\n**   3.  The \"iDataCur\" cursor must be already be positioned on the row\n**       that is to be deleted.\n*/\nSQLITE_PRIVATE void sqlite3GenerateRowIndexDelete(\n  Parse *pParse,     /* Parsing and code generating context */\n  Table *pTab,       /* Table containing the row to be deleted */\n  int iDataCur,      /* Cursor of table holding data. */\n  int iIdxCur,       /* First index cursor */\n  int *aRegIdx,      /* Only delete if aRegIdx!=0 && aRegIdx[i]>0 */\n  int iIdxNoSeek     /* Do not delete from this cursor */\n){\n  int i;             /* Index loop counter */\n  int r1 = -1;       /* Register holding an index key */\n  int iPartIdxLabel; /* Jump destination for skipping partial index entries */\n  Index *pIdx;       /* Current index */\n  Index *pPrior = 0; /* Prior index */\n  Vdbe *v;           /* The prepared statement under construction */\n  Index *pPk;        /* PRIMARY KEY index, or NULL for rowid tables */\n\n  v = pParse->pVdbe;\n  pPk = HasRowid(pTab) ? 0 : sqlite3PrimaryKeyIndex(pTab);\n  for(i=0, pIdx=pTab->pIndex; pIdx; i++, pIdx=pIdx->pNext){\n    assert( iIdxCur+i!=iDataCur || pPk==pIdx );\n    if( aRegIdx!=0 && aRegIdx[i]==0 ) continue;\n    if( pIdx==pPk ) continue;\n    if( iIdxCur+i==iIdxNoSeek ) continue;\n    VdbeModuleComment((v, \"GenRowIdxDel for %s\", pIdx->zName));\n    r1 = sqlite3GenerateIndexKey(pParse, pIdx, iDataCur, 0, 1,\n        &iPartIdxLabel, pPrior, r1);\n    sqlite3VdbeAddOp3(v, OP_IdxDelete, iIdxCur+i, r1,\n        pIdx->uniqNotNull ? pIdx->nKeyCol : pIdx->nColumn);\n    sqlite3ResolvePartIdxLabel(pParse, iPartIdxLabel);\n    pPrior = pIdx;\n  }\n}\n\n/*\n** Generate code that will assemble an index key and stores it in register\n** regOut.  The key with be for index pIdx which is an index on pTab.\n** iCur is the index of a cursor open on the pTab table and pointing to\n** the entry that needs indexing.  If pTab is a WITHOUT ROWID table, then\n** iCur must be the cursor of the PRIMARY KEY index.\n**\n** Return a register number which is the first in a block of\n** registers that holds the elements of the index key.  The\n** block of registers has already been deallocated by the time\n** this routine returns.\n**\n** If *piPartIdxLabel is not NULL, fill it in with a label and jump\n** to that label if pIdx is a partial index that should be skipped.\n** The label should be resolved using sqlite3ResolvePartIdxLabel().\n** A partial index should be skipped if its WHERE clause evaluates\n** to false or null.  If pIdx is not a partial index, *piPartIdxLabel\n** will be set to zero which is an empty label that is ignored by\n** sqlite3ResolvePartIdxLabel().\n**\n** The pPrior and regPrior parameters are used to implement a cache to\n** avoid unnecessary register loads.  If pPrior is not NULL, then it is\n** a pointer to a different index for which an index key has just been\n** computed into register regPrior.  If the current pIdx index is generating\n** its key into the same sequence of registers and if pPrior and pIdx share\n** a column in common, then the register corresponding to that column already\n** holds the correct value and the loading of that register is skipped.\n** This optimization is helpful when doing a DELETE or an INTEGRITY_CHECK \n** on a table with multiple indices, and especially with the ROWID or\n** PRIMARY KEY columns of the index.\n*/\nSQLITE_PRIVATE int sqlite3GenerateIndexKey(\n  Parse *pParse,       /* Parsing context */\n  Index *pIdx,         /* The index for which to generate a key */\n  int iDataCur,        /* Cursor number from which to take column data */\n  int regOut,          /* Put the new key into this register if not 0 */\n  int prefixOnly,      /* Compute only a unique prefix of the key */\n  int *piPartIdxLabel, /* OUT: Jump to this label to skip partial index */\n  Index *pPrior,       /* Previously generated index key */\n  int regPrior         /* Register holding previous generated key */\n){\n  Vdbe *v = pParse->pVdbe;\n  int j;\n  int regBase;\n  int nCol;\n\n  if( piPartIdxLabel ){\n    if( pIdx->pPartIdxWhere ){\n      *piPartIdxLabel = sqlite3VdbeMakeLabel(pParse);\n      pParse->iSelfTab = iDataCur + 1;\n      sqlite3ExprIfFalseDup(pParse, pIdx->pPartIdxWhere, *piPartIdxLabel, \n                            SQLITE_JUMPIFNULL);\n      pParse->iSelfTab = 0;\n    }else{\n      *piPartIdxLabel = 0;\n    }\n  }\n  nCol = (prefixOnly && pIdx->uniqNotNull) ? pIdx->nKeyCol : pIdx->nColumn;\n  regBase = sqlite3GetTempRange(pParse, nCol);\n  if( pPrior && (regBase!=regPrior || pPrior->pPartIdxWhere) ) pPrior = 0;\n  for(j=0; j<nCol; j++){\n    if( pPrior\n     && pPrior->aiColumn[j]==pIdx->aiColumn[j]\n     && pPrior->aiColumn[j]!=XN_EXPR\n    ){\n      /* This column was already computed by the previous index */\n      continue;\n    }\n    sqlite3ExprCodeLoadIndexColumn(pParse, pIdx, iDataCur, j, regBase+j);\n    /* If the column affinity is REAL but the number is an integer, then it\n    ** might be stored in the table as an integer (using a compact\n    ** representation) then converted to REAL by an OP_RealAffinity opcode.\n    ** But we are getting ready to store this value back into an index, where\n    ** it should be converted by to INTEGER again.  So omit the OP_RealAffinity\n    ** opcode if it is present */\n    sqlite3VdbeDeletePriorOpcode(v, OP_RealAffinity);\n  }\n  if( regOut ){\n    sqlite3VdbeAddOp3(v, OP_MakeRecord, regBase, nCol, regOut);\n    if( pIdx->pTable->pSelect ){\n      const char *zAff = sqlite3IndexAffinityStr(pParse->db, pIdx);\n      sqlite3VdbeChangeP4(v, -1, zAff, P4_TRANSIENT);\n    }\n  }\n  sqlite3ReleaseTempRange(pParse, regBase, nCol);\n  return regBase;\n}\n\n/*\n** If a prior call to sqlite3GenerateIndexKey() generated a jump-over label\n** because it was a partial index, then this routine should be called to\n** resolve that label.\n*/\nSQLITE_PRIVATE void sqlite3ResolvePartIdxLabel(Parse *pParse, int iLabel){\n  if( iLabel ){\n    sqlite3VdbeResolveLabel(pParse->pVdbe, iLabel);\n  }\n}\n\n/************** End of delete.c **********************************************/\n/************** Begin file func.c ********************************************/\n/*\n** 2002 February 23\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This file contains the C-language implementations for many of the SQL\n** functions of SQLite.  (Some function, and in particular the date and\n** time functions, are implemented separately.)\n*/\n/* #include \"sqliteInt.h\" */\n/* #include <stdlib.h> */\n/* #include <assert.h> */\n/* #include \"vdbeInt.h\" */\n\n/*\n** Return the collating function associated with a function.\n*/\nstatic CollSeq *sqlite3GetFuncCollSeq(sqlite3_context *context){\n  VdbeOp *pOp;\n  assert( context->pVdbe!=0 );\n  pOp = &context->pVdbe->aOp[context->iOp-1];\n  assert( pOp->opcode==OP_CollSeq );\n  assert( pOp->p4type==P4_COLLSEQ );\n  return pOp->p4.pColl;\n}\n\n/*\n** Indicate that the accumulator load should be skipped on this\n** iteration of the aggregate loop.\n*/\nstatic void sqlite3SkipAccumulatorLoad(sqlite3_context *context){\n  assert( context->isError<=0 );\n  context->isError = -1;\n  context->skipFlag = 1;\n}\n\n/*\n** Implementation of the non-aggregate min() and max() functions\n*/\nstatic void minmaxFunc(\n  sqlite3_context *context,\n  int argc,\n  sqlite3_value **argv\n){\n  int i;\n  int mask;    /* 0 for min() or 0xffffffff for max() */\n  int iBest;\n  CollSeq *pColl;\n\n  assert( argc>1 );\n  mask = sqlite3_user_data(context)==0 ? 0 : -1;\n  pColl = sqlite3GetFuncCollSeq(context);\n  assert( pColl );\n  assert( mask==-1 || mask==0 );\n  iBest = 0;\n  if( sqlite3_value_type(argv[0])==SQLITE_NULL ) return;\n  for(i=1; i<argc; i++){\n    if( sqlite3_value_type(argv[i])==SQLITE_NULL ) return;\n    if( (sqlite3MemCompare(argv[iBest], argv[i], pColl)^mask)>=0 ){\n      testcase( mask==0 );\n      iBest = i;\n    }\n  }\n  sqlite3_result_value(context, argv[iBest]);\n}\n\n/*\n** Return the type of the argument.\n*/\nstatic void typeofFunc(\n  sqlite3_context *context,\n  int NotUsed,\n  sqlite3_value **argv\n){\n  static const char *azType[] = { \"integer\", \"real\", \"text\", \"blob\", \"null\" };\n  int i = sqlite3_value_type(argv[0]) - 1;\n  UNUSED_PARAMETER(NotUsed);\n  assert( i>=0 && i<ArraySize(azType) );\n  assert( SQLITE_INTEGER==1 );\n  assert( SQLITE_FLOAT==2 );\n  assert( SQLITE_TEXT==3 );\n  assert( SQLITE_BLOB==4 );\n  assert( SQLITE_NULL==5 );\n  /* EVIDENCE-OF: R-01470-60482 The sqlite3_value_type(V) interface returns\n  ** the datatype code for the initial datatype of the sqlite3_value object\n  ** V. The returned value is one of SQLITE_INTEGER, SQLITE_FLOAT,\n  ** SQLITE_TEXT, SQLITE_BLOB, or SQLITE_NULL. */\n  sqlite3_result_text(context, azType[i], -1, SQLITE_STATIC);\n}\n\n\n/*\n** Implementation of the length() function\n*/\nstatic void lengthFunc(\n  sqlite3_context *context,\n  int argc,\n  sqlite3_value **argv\n){\n  assert( argc==1 );\n  UNUSED_PARAMETER(argc);\n  switch( sqlite3_value_type(argv[0]) ){\n    case SQLITE_BLOB:\n    case SQLITE_INTEGER:\n    case SQLITE_FLOAT: {\n      sqlite3_result_int(context, sqlite3_value_bytes(argv[0]));\n      break;\n    }\n    case SQLITE_TEXT: {\n      const unsigned char *z = sqlite3_value_text(argv[0]);\n      const unsigned char *z0;\n      unsigned char c;\n      if( z==0 ) return;\n      z0 = z;\n      while( (c = *z)!=0 ){\n        z++;\n        if( c>=0xc0 ){\n          while( (*z & 0xc0)==0x80 ){ z++; z0++; }\n        }\n      }\n      sqlite3_result_int(context, (int)(z-z0));\n      break;\n    }\n    default: {\n      sqlite3_result_null(context);\n      break;\n    }\n  }\n}\n\n/*\n** Implementation of the abs() function.\n**\n** IMP: R-23979-26855 The abs(X) function returns the absolute value of\n** the numeric argument X. \n*/\nstatic void absFunc(sqlite3_context *context, int argc, sqlite3_value **argv){\n  assert( argc==1 );\n  UNUSED_PARAMETER(argc);\n  switch( sqlite3_value_type(argv[0]) ){\n    case SQLITE_INTEGER: {\n      i64 iVal = sqlite3_value_int64(argv[0]);\n      if( iVal<0 ){\n        if( iVal==SMALLEST_INT64 ){\n          /* IMP: R-31676-45509 If X is the integer -9223372036854775808\n          ** then abs(X) throws an integer overflow error since there is no\n          ** equivalent positive 64-bit two complement value. */\n          sqlite3_result_error(context, \"integer overflow\", -1);\n          return;\n        }\n        iVal = -iVal;\n      } \n      sqlite3_result_int64(context, iVal);\n      break;\n    }\n    case SQLITE_NULL: {\n      /* IMP: R-37434-19929 Abs(X) returns NULL if X is NULL. */\n      sqlite3_result_null(context);\n      break;\n    }\n    default: {\n      /* Because sqlite3_value_double() returns 0.0 if the argument is not\n      ** something that can be converted into a number, we have:\n      ** IMP: R-01992-00519 Abs(X) returns 0.0 if X is a string or blob\n      ** that cannot be converted to a numeric value.\n      */\n      double rVal = sqlite3_value_double(argv[0]);\n      if( rVal<0 ) rVal = -rVal;\n      sqlite3_result_double(context, rVal);\n      break;\n    }\n  }\n}\n\n/*\n** Implementation of the instr() function.\n**\n** instr(haystack,needle) finds the first occurrence of needle\n** in haystack and returns the number of previous characters plus 1,\n** or 0 if needle does not occur within haystack.\n**\n** If both haystack and needle are BLOBs, then the result is one more than\n** the number of bytes in haystack prior to the first occurrence of needle,\n** or 0 if needle never occurs in haystack.\n*/\nstatic void instrFunc(\n  sqlite3_context *context,\n  int argc,\n  sqlite3_value **argv\n){\n  const unsigned char *zHaystack;\n  const unsigned char *zNeedle;\n  int nHaystack;\n  int nNeedle;\n  int typeHaystack, typeNeedle;\n  int N = 1;\n  int isText;\n  unsigned char firstChar;\n\n  UNUSED_PARAMETER(argc);\n  typeHaystack = sqlite3_value_type(argv[0]);\n  typeNeedle = sqlite3_value_type(argv[1]);\n  if( typeHaystack==SQLITE_NULL || typeNeedle==SQLITE_NULL ) return;\n  nHaystack = sqlite3_value_bytes(argv[0]);\n  nNeedle = sqlite3_value_bytes(argv[1]);\n  if( nNeedle>0 ){\n    if( typeHaystack==SQLITE_BLOB && typeNeedle==SQLITE_BLOB ){\n      zHaystack = sqlite3_value_blob(argv[0]);\n      zNeedle = sqlite3_value_blob(argv[1]);\n      isText = 0;\n    }else{\n      zHaystack = sqlite3_value_text(argv[0]);\n      zNeedle = sqlite3_value_text(argv[1]);\n      isText = 1;\n    }\n    if( zNeedle==0 || (nHaystack && zHaystack==0) ) return;\n    firstChar = zNeedle[0];\n    while( nNeedle<=nHaystack\n       && (zHaystack[0]!=firstChar || memcmp(zHaystack, zNeedle, nNeedle)!=0)\n    ){\n      N++;\n      do{\n        nHaystack--;\n        zHaystack++;\n      }while( isText && (zHaystack[0]&0xc0)==0x80 );\n    }\n    if( nNeedle>nHaystack ) N = 0;\n  }\n  sqlite3_result_int(context, N);\n}\n\n/*\n** Implementation of the printf() function.\n*/\nstatic void printfFunc(\n  sqlite3_context *context,\n  int argc,\n  sqlite3_value **argv\n){\n  PrintfArguments x;\n  StrAccum str;\n  const char *zFormat;\n  int n;\n  sqlite3 *db = sqlite3_context_db_handle(context);\n\n  if( argc>=1 && (zFormat = (const char*)sqlite3_value_text(argv[0]))!=0 ){\n    x.nArg = argc-1;\n    x.nUsed = 0;\n    x.apArg = argv+1;\n    sqlite3StrAccumInit(&str, db, 0, 0, db->aLimit[SQLITE_LIMIT_LENGTH]);\n    str.printfFlags = SQLITE_PRINTF_SQLFUNC;\n    sqlite3_str_appendf(&str, zFormat, &x);\n    n = str.nChar;\n    sqlite3_result_text(context, sqlite3StrAccumFinish(&str), n,\n                        SQLITE_DYNAMIC);\n  }\n}\n\n/*\n** Implementation of the substr() function.\n**\n** substr(x,p1,p2)  returns p2 characters of x[] beginning with p1.\n** p1 is 1-indexed.  So substr(x,1,1) returns the first character\n** of x.  If x is text, then we actually count UTF-8 characters.\n** If x is a blob, then we count bytes.\n**\n** If p1 is negative, then we begin abs(p1) from the end of x[].\n**\n** If p2 is negative, return the p2 characters preceding p1.\n*/\nstatic void substrFunc(\n  sqlite3_context *context,\n  int argc,\n  sqlite3_value **argv\n){\n  const unsigned char *z;\n  const unsigned char *z2;\n  int len;\n  int p0type;\n  i64 p1, p2;\n  int negP2 = 0;\n\n  assert( argc==3 || argc==2 );\n  if( sqlite3_value_type(argv[1])==SQLITE_NULL\n   || (argc==3 && sqlite3_value_type(argv[2])==SQLITE_NULL)\n  ){\n    return;\n  }\n  p0type = sqlite3_value_type(argv[0]);\n  p1 = sqlite3_value_int(argv[1]);\n  if( p0type==SQLITE_BLOB ){\n    len = sqlite3_value_bytes(argv[0]);\n    z = sqlite3_value_blob(argv[0]);\n    if( z==0 ) return;\n    assert( len==sqlite3_value_bytes(argv[0]) );\n  }else{\n    z = sqlite3_value_text(argv[0]);\n    if( z==0 ) return;\n    len = 0;\n    if( p1<0 ){\n      for(z2=z; *z2; len++){\n        SQLITE_SKIP_UTF8(z2);\n      }\n    }\n  }\n#ifdef SQLITE_SUBSTR_COMPATIBILITY\n  /* If SUBSTR_COMPATIBILITY is defined then substr(X,0,N) work the same as\n  ** as substr(X,1,N) - it returns the first N characters of X.  This\n  ** is essentially a back-out of the bug-fix in check-in [5fc125d362df4b8]\n  ** from 2009-02-02 for compatibility of applications that exploited the\n  ** old buggy behavior. */\n  if( p1==0 ) p1 = 1; /* <rdar://problem/6778339> */\n#endif\n  if( argc==3 ){\n    p2 = sqlite3_value_int(argv[2]);\n    if( p2<0 ){\n      p2 = -p2;\n      negP2 = 1;\n    }\n  }else{\n    p2 = sqlite3_context_db_handle(context)->aLimit[SQLITE_LIMIT_LENGTH];\n  }\n  if( p1<0 ){\n    p1 += len;\n    if( p1<0 ){\n      p2 += p1;\n      if( p2<0 ) p2 = 0;\n      p1 = 0;\n    }\n  }else if( p1>0 ){\n    p1--;\n  }else if( p2>0 ){\n    p2--;\n  }\n  if( negP2 ){\n    p1 -= p2;\n    if( p1<0 ){\n      p2 += p1;\n      p1 = 0;\n    }\n  }\n  assert( p1>=0 && p2>=0 );\n  if( p0type!=SQLITE_BLOB ){\n    while( *z && p1 ){\n      SQLITE_SKIP_UTF8(z);\n      p1--;\n    }\n    for(z2=z; *z2 && p2; p2--){\n      SQLITE_SKIP_UTF8(z2);\n    }\n    sqlite3_result_text64(context, (char*)z, z2-z, SQLITE_TRANSIENT,\n                          SQLITE_UTF8);\n  }else{\n    if( p1+p2>len ){\n      p2 = len-p1;\n      if( p2<0 ) p2 = 0;\n    }\n    sqlite3_result_blob64(context, (char*)&z[p1], (u64)p2, SQLITE_TRANSIENT);\n  }\n}\n\n/*\n** Implementation of the round() function\n*/\n#ifndef SQLITE_OMIT_FLOATING_POINT\nstatic void roundFunc(sqlite3_context *context, int argc, sqlite3_value **argv){\n  int n = 0;\n  double r;\n  char *zBuf;\n  assert( argc==1 || argc==2 );\n  if( argc==2 ){\n    if( SQLITE_NULL==sqlite3_value_type(argv[1]) ) return;\n    n = sqlite3_value_int(argv[1]);\n    if( n>30 ) n = 30;\n    if( n<0 ) n = 0;\n  }\n  if( sqlite3_value_type(argv[0])==SQLITE_NULL ) return;\n  r = sqlite3_value_double(argv[0]);\n  /* If Y==0 and X will fit in a 64-bit int,\n  ** handle the rounding directly,\n  ** otherwise use printf.\n  */\n  if( n==0 && r>=0 && r<LARGEST_INT64-1 ){\n    r = (double)((sqlite_int64)(r+0.5));\n  }else if( n==0 && r<0 && (-r)<LARGEST_INT64-1 ){\n    r = -(double)((sqlite_int64)((-r)+0.5));\n  }else{\n    zBuf = sqlite3_mprintf(\"%.*f\",n,r);\n    if( zBuf==0 ){\n      sqlite3_result_error_nomem(context);\n      return;\n    }\n    sqlite3AtoF(zBuf, &r, sqlite3Strlen30(zBuf), SQLITE_UTF8);\n    sqlite3_free(zBuf);\n  }\n  sqlite3_result_double(context, r);\n}\n#endif\n\n/*\n** Allocate nByte bytes of space using sqlite3Malloc(). If the\n** allocation fails, call sqlite3_result_error_nomem() to notify\n** the database handle that malloc() has failed and return NULL.\n** If nByte is larger than the maximum string or blob length, then\n** raise an SQLITE_TOOBIG exception and return NULL.\n*/\nstatic void *contextMalloc(sqlite3_context *context, i64 nByte){\n  char *z;\n  sqlite3 *db = sqlite3_context_db_handle(context);\n  assert( nByte>0 );\n  testcase( nByte==db->aLimit[SQLITE_LIMIT_LENGTH] );\n  testcase( nByte==db->aLimit[SQLITE_LIMIT_LENGTH]+1 );\n  if( nByte>db->aLimit[SQLITE_LIMIT_LENGTH] ){\n    sqlite3_result_error_toobig(context);\n    z = 0;\n  }else{\n    z = sqlite3Malloc(nByte);\n    if( !z ){\n      sqlite3_result_error_nomem(context);\n    }\n  }\n  return z;\n}\n\n/*\n** Implementation of the upper() and lower() SQL functions.\n*/\nstatic void upperFunc(sqlite3_context *context, int argc, sqlite3_value **argv){\n  char *z1;\n  const char *z2;\n  int i, n;\n  UNUSED_PARAMETER(argc);\n  z2 = (char*)sqlite3_value_text(argv[0]);\n  n = sqlite3_value_bytes(argv[0]);\n  /* Verify that the call to _bytes() does not invalidate the _text() pointer */\n  assert( z2==(char*)sqlite3_value_text(argv[0]) );\n  if( z2 ){\n    z1 = contextMalloc(context, ((i64)n)+1);\n    if( z1 ){\n      for(i=0; i<n; i++){\n        z1[i] = (char)sqlite3Toupper(z2[i]);\n      }\n      sqlite3_result_text(context, z1, n, sqlite3_free);\n    }\n  }\n}\nstatic void lowerFunc(sqlite3_context *context, int argc, sqlite3_value **argv){\n  char *z1;\n  const char *z2;\n  int i, n;\n  UNUSED_PARAMETER(argc);\n  z2 = (char*)sqlite3_value_text(argv[0]);\n  n = sqlite3_value_bytes(argv[0]);\n  /* Verify that the call to _bytes() does not invalidate the _text() pointer */\n  assert( z2==(char*)sqlite3_value_text(argv[0]) );\n  if( z2 ){\n    z1 = contextMalloc(context, ((i64)n)+1);\n    if( z1 ){\n      for(i=0; i<n; i++){\n        z1[i] = sqlite3Tolower(z2[i]);\n      }\n      sqlite3_result_text(context, z1, n, sqlite3_free);\n    }\n  }\n}\n\n/*\n** Some functions like COALESCE() and IFNULL() and UNLIKELY() are implemented\n** as VDBE code so that unused argument values do not have to be computed.\n** However, we still need some kind of function implementation for this\n** routines in the function table.  The noopFunc macro provides this.\n** noopFunc will never be called so it doesn't matter what the implementation\n** is.  We might as well use the \"version()\" function as a substitute.\n*/\n#define noopFunc versionFunc   /* Substitute function - never called */\n\n/*\n** Implementation of random().  Return a random integer.  \n*/\nstatic void randomFunc(\n  sqlite3_context *context,\n  int NotUsed,\n  sqlite3_value **NotUsed2\n){\n  sqlite_int64 r;\n  UNUSED_PARAMETER2(NotUsed, NotUsed2);\n  sqlite3_randomness(sizeof(r), &r);\n  if( r<0 ){\n    /* We need to prevent a random number of 0x8000000000000000 \n    ** (or -9223372036854775808) since when you do abs() of that\n    ** number of you get the same value back again.  To do this\n    ** in a way that is testable, mask the sign bit off of negative\n    ** values, resulting in a positive value.  Then take the \n    ** 2s complement of that positive value.  The end result can\n    ** therefore be no less than -9223372036854775807.\n    */\n    r = -(r & LARGEST_INT64);\n  }\n  sqlite3_result_int64(context, r);\n}\n\n/*\n** Implementation of randomblob(N).  Return a random blob\n** that is N bytes long.\n*/\nstatic void randomBlob(\n  sqlite3_context *context,\n  int argc,\n  sqlite3_value **argv\n){\n  sqlite3_int64 n;\n  unsigned char *p;\n  assert( argc==1 );\n  UNUSED_PARAMETER(argc);\n  n = sqlite3_value_int64(argv[0]);\n  if( n<1 ){\n    n = 1;\n  }\n  p = contextMalloc(context, n);\n  if( p ){\n    sqlite3_randomness(n, p);\n    sqlite3_result_blob(context, (char*)p, n, sqlite3_free);\n  }\n}\n\n/*\n** Implementation of the last_insert_rowid() SQL function.  The return\n** value is the same as the sqlite3_last_insert_rowid() API function.\n*/\nstatic void last_insert_rowid(\n  sqlite3_context *context, \n  int NotUsed, \n  sqlite3_value **NotUsed2\n){\n  sqlite3 *db = sqlite3_context_db_handle(context);\n  UNUSED_PARAMETER2(NotUsed, NotUsed2);\n  /* IMP: R-51513-12026 The last_insert_rowid() SQL function is a\n  ** wrapper around the sqlite3_last_insert_rowid() C/C++ interface\n  ** function. */\n  sqlite3_result_int64(context, sqlite3_last_insert_rowid(db));\n}\n\n/*\n** Implementation of the changes() SQL function.\n**\n** IMP: R-62073-11209 The changes() SQL function is a wrapper\n** around the sqlite3_changes() C/C++ function and hence follows the same\n** rules for counting changes.\n*/\nstatic void changes(\n  sqlite3_context *context,\n  int NotUsed,\n  sqlite3_value **NotUsed2\n){\n  sqlite3 *db = sqlite3_context_db_handle(context);\n  UNUSED_PARAMETER2(NotUsed, NotUsed2);\n  sqlite3_result_int(context, sqlite3_changes(db));\n}\n\n/*\n** Implementation of the total_changes() SQL function.  The return value is\n** the same as the sqlite3_total_changes() API function.\n*/\nstatic void total_changes(\n  sqlite3_context *context,\n  int NotUsed,\n  sqlite3_value **NotUsed2\n){\n  sqlite3 *db = sqlite3_context_db_handle(context);\n  UNUSED_PARAMETER2(NotUsed, NotUsed2);\n  /* IMP: R-52756-41993 This function is a wrapper around the\n  ** sqlite3_total_changes() C/C++ interface. */\n  sqlite3_result_int(context, sqlite3_total_changes(db));\n}\n\n/*\n** A structure defining how to do GLOB-style comparisons.\n*/\nstruct compareInfo {\n  u8 matchAll;          /* \"*\" or \"%\" */\n  u8 matchOne;          /* \"?\" or \"_\" */\n  u8 matchSet;          /* \"[\" or 0 */\n  u8 noCase;            /* true to ignore case differences */\n};\n\n/*\n** For LIKE and GLOB matching on EBCDIC machines, assume that every\n** character is exactly one byte in size.  Also, provde the Utf8Read()\n** macro for fast reading of the next character in the common case where\n** the next character is ASCII.\n*/\n#if defined(SQLITE_EBCDIC)\n# define sqlite3Utf8Read(A)        (*((*A)++))\n# define Utf8Read(A)               (*(A++))\n#else\n# define Utf8Read(A)               (A[0]<0x80?*(A++):sqlite3Utf8Read(&A))\n#endif\n\nstatic const struct compareInfo globInfo = { '*', '?', '[', 0 };\n/* The correct SQL-92 behavior is for the LIKE operator to ignore\n** case.  Thus  'a' LIKE 'A' would be true. */\nstatic const struct compareInfo likeInfoNorm = { '%', '_',   0, 1 };\n/* If SQLITE_CASE_SENSITIVE_LIKE is defined, then the LIKE operator\n** is case sensitive causing 'a' LIKE 'A' to be false */\nstatic const struct compareInfo likeInfoAlt = { '%', '_',   0, 0 };\n\n/*\n** Possible error returns from patternMatch()\n*/\n#define SQLITE_MATCH             0\n#define SQLITE_NOMATCH           1\n#define SQLITE_NOWILDCARDMATCH   2\n\n/*\n** Compare two UTF-8 strings for equality where the first string is\n** a GLOB or LIKE expression.  Return values:\n**\n**    SQLITE_MATCH:            Match\n**    SQLITE_NOMATCH:          No match\n**    SQLITE_NOWILDCARDMATCH:  No match in spite of having * or % wildcards.\n**\n** Globbing rules:\n**\n**      '*'       Matches any sequence of zero or more characters.\n**\n**      '?'       Matches exactly one character.\n**\n**     [...]      Matches one character from the enclosed list of\n**                characters.\n**\n**     [^...]     Matches one character not in the enclosed list.\n**\n** With the [...] and [^...] matching, a ']' character can be included\n** in the list by making it the first character after '[' or '^'.  A\n** range of characters can be specified using '-'.  Example:\n** \"[a-z]\" matches any single lower-case letter.  To match a '-', make\n** it the last character in the list.\n**\n** Like matching rules:\n** \n**      '%'       Matches any sequence of zero or more characters\n**\n***     '_'       Matches any one character\n**\n**      Ec        Where E is the \"esc\" character and c is any other\n**                character, including '%', '_', and esc, match exactly c.\n**\n** The comments within this routine usually assume glob matching.\n**\n** This routine is usually quick, but can be N**2 in the worst case.\n*/\nstatic int patternCompare(\n  const u8 *zPattern,              /* The glob pattern */\n  const u8 *zString,               /* The string to compare against the glob */\n  const struct compareInfo *pInfo, /* Information about how to do the compare */\n  u32 matchOther                   /* The escape char (LIKE) or '[' (GLOB) */\n){\n  u32 c, c2;                       /* Next pattern and input string chars */\n  u32 matchOne = pInfo->matchOne;  /* \"?\" or \"_\" */\n  u32 matchAll = pInfo->matchAll;  /* \"*\" or \"%\" */\n  u8 noCase = pInfo->noCase;       /* True if uppercase==lowercase */\n  const u8 *zEscaped = 0;          /* One past the last escaped input char */\n  \n  while( (c = Utf8Read(zPattern))!=0 ){\n    if( c==matchAll ){  /* Match \"*\" */\n      /* Skip over multiple \"*\" characters in the pattern.  If there\n      ** are also \"?\" characters, skip those as well, but consume a\n      ** single character of the input string for each \"?\" skipped */\n      while( (c=Utf8Read(zPattern)) == matchAll || c == matchOne ){\n        if( c==matchOne && sqlite3Utf8Read(&zString)==0 ){\n          return SQLITE_NOWILDCARDMATCH;\n        }\n      }\n      if( c==0 ){\n        return SQLITE_MATCH;   /* \"*\" at the end of the pattern matches */\n      }else if( c==matchOther ){\n        if( pInfo->matchSet==0 ){\n          c = sqlite3Utf8Read(&zPattern);\n          if( c==0 ) return SQLITE_NOWILDCARDMATCH;\n        }else{\n          /* \"[...]\" immediately follows the \"*\".  We have to do a slow\n          ** recursive search in this case, but it is an unusual case. */\n          assert( matchOther<0x80 );  /* '[' is a single-byte character */\n          while( *zString ){\n            int bMatch = patternCompare(&zPattern[-1],zString,pInfo,matchOther);\n            if( bMatch!=SQLITE_NOMATCH ) return bMatch;\n            SQLITE_SKIP_UTF8(zString);\n          }\n          return SQLITE_NOWILDCARDMATCH;\n        }\n      }\n\n      /* At this point variable c contains the first character of the\n      ** pattern string past the \"*\".  Search in the input string for the\n      ** first matching character and recursively continue the match from\n      ** that point.\n      **\n      ** For a case-insensitive search, set variable cx to be the same as\n      ** c but in the other case and search the input string for either\n      ** c or cx.\n      */\n      if( c<=0x80 ){\n        char zStop[3];\n        int bMatch;\n        if( noCase ){\n          zStop[0] = sqlite3Toupper(c);\n          zStop[1] = sqlite3Tolower(c);\n          zStop[2] = 0;\n        }else{\n          zStop[0] = c;\n          zStop[1] = 0;\n        }\n        while(1){\n          zString += strcspn((const char*)zString, zStop);\n          if( zString[0]==0 ) break;\n          zString++;\n          bMatch = patternCompare(zPattern,zString,pInfo,matchOther);\n          if( bMatch!=SQLITE_NOMATCH ) return bMatch;\n        }\n      }else{\n        int bMatch;\n        while( (c2 = Utf8Read(zString))!=0 ){\n          if( c2!=c ) continue;\n          bMatch = patternCompare(zPattern,zString,pInfo,matchOther);\n          if( bMatch!=SQLITE_NOMATCH ) return bMatch;\n        }\n      }\n      return SQLITE_NOWILDCARDMATCH;\n    }\n    if( c==matchOther ){\n      if( pInfo->matchSet==0 ){\n        c = sqlite3Utf8Read(&zPattern);\n        if( c==0 ) return SQLITE_NOMATCH;\n        zEscaped = zPattern;\n      }else{\n        u32 prior_c = 0;\n        int seen = 0;\n        int invert = 0;\n        c = sqlite3Utf8Read(&zString);\n        if( c==0 ) return SQLITE_NOMATCH;\n        c2 = sqlite3Utf8Read(&zPattern);\n        if( c2=='^' ){\n          invert = 1;\n          c2 = sqlite3Utf8Read(&zPattern);\n        }\n        if( c2==']' ){\n          if( c==']' ) seen = 1;\n          c2 = sqlite3Utf8Read(&zPattern);\n        }\n        while( c2 && c2!=']' ){\n          if( c2=='-' && zPattern[0]!=']' && zPattern[0]!=0 && prior_c>0 ){\n            c2 = sqlite3Utf8Read(&zPattern);\n            if( c>=prior_c && c<=c2 ) seen = 1;\n            prior_c = 0;\n          }else{\n            if( c==c2 ){\n              seen = 1;\n            }\n            prior_c = c2;\n          }\n          c2 = sqlite3Utf8Read(&zPattern);\n        }\n        if( c2==0 || (seen ^ invert)==0 ){\n          return SQLITE_NOMATCH;\n        }\n        continue;\n      }\n    }\n    c2 = Utf8Read(zString);\n    if( c==c2 ) continue;\n    if( noCase  && sqlite3Tolower(c)==sqlite3Tolower(c2) && c<0x80 && c2<0x80 ){\n      continue;\n    }\n    if( c==matchOne && zPattern!=zEscaped && c2!=0 ) continue;\n    return SQLITE_NOMATCH;\n  }\n  return *zString==0 ? SQLITE_MATCH : SQLITE_NOMATCH;\n}\n\n/*\n** The sqlite3_strglob() interface.  Return 0 on a match (like strcmp()) and\n** non-zero if there is no match.\n*/\nSQLITE_API int sqlite3_strglob(const char *zGlobPattern, const char *zString){\n  return patternCompare((u8*)zGlobPattern, (u8*)zString, &globInfo, '[');\n}\n\n/*\n** The sqlite3_strlike() interface.  Return 0 on a match and non-zero for\n** a miss - like strcmp().\n*/\nSQLITE_API int sqlite3_strlike(const char *zPattern, const char *zStr, unsigned int esc){\n  return patternCompare((u8*)zPattern, (u8*)zStr, &likeInfoNorm, esc);\n}\n\n/*\n** Count the number of times that the LIKE operator (or GLOB which is\n** just a variation of LIKE) gets called.  This is used for testing\n** only.\n*/\n#ifdef SQLITE_TEST\nSQLITE_API int sqlite3_like_count = 0;\n#endif\n\n\n/*\n** Implementation of the like() SQL function.  This function implements\n** the build-in LIKE operator.  The first argument to the function is the\n** pattern and the second argument is the string.  So, the SQL statements:\n**\n**       A LIKE B\n**\n** is implemented as like(B,A).\n**\n** This same function (with a different compareInfo structure) computes\n** the GLOB operator.\n*/\nstatic void likeFunc(\n  sqlite3_context *context, \n  int argc, \n  sqlite3_value **argv\n){\n  const unsigned char *zA, *zB;\n  u32 escape;\n  int nPat;\n  sqlite3 *db = sqlite3_context_db_handle(context);\n  struct compareInfo *pInfo = sqlite3_user_data(context);\n\n#ifdef SQLITE_LIKE_DOESNT_MATCH_BLOBS\n  if( sqlite3_value_type(argv[0])==SQLITE_BLOB\n   || sqlite3_value_type(argv[1])==SQLITE_BLOB\n  ){\n#ifdef SQLITE_TEST\n    sqlite3_like_count++;\n#endif\n    sqlite3_result_int(context, 0);\n    return;\n  }\n#endif\n  zB = sqlite3_value_text(argv[0]);\n  zA = sqlite3_value_text(argv[1]);\n\n  /* Limit the length of the LIKE or GLOB pattern to avoid problems\n  ** of deep recursion and N*N behavior in patternCompare().\n  */\n  nPat = sqlite3_value_bytes(argv[0]);\n  testcase( nPat==db->aLimit[SQLITE_LIMIT_LIKE_PATTERN_LENGTH] );\n  testcase( nPat==db->aLimit[SQLITE_LIMIT_LIKE_PATTERN_LENGTH]+1 );\n  if( nPat > db->aLimit[SQLITE_LIMIT_LIKE_PATTERN_LENGTH] ){\n    sqlite3_result_error(context, \"LIKE or GLOB pattern too complex\", -1);\n    return;\n  }\n  assert( zB==sqlite3_value_text(argv[0]) );  /* Encoding did not change */\n\n  if( argc==3 ){\n    /* The escape character string must consist of a single UTF-8 character.\n    ** Otherwise, return an error.\n    */\n    const unsigned char *zEsc = sqlite3_value_text(argv[2]);\n    if( zEsc==0 ) return;\n    if( sqlite3Utf8CharLen((char*)zEsc, -1)!=1 ){\n      sqlite3_result_error(context, \n          \"ESCAPE expression must be a single character\", -1);\n      return;\n    }\n    escape = sqlite3Utf8Read(&zEsc);\n  }else{\n    escape = pInfo->matchSet;\n  }\n  if( zA && zB ){\n#ifdef SQLITE_TEST\n    sqlite3_like_count++;\n#endif\n    sqlite3_result_int(context,\n                      patternCompare(zB, zA, pInfo, escape)==SQLITE_MATCH);\n  }\n}\n\n/*\n** Implementation of the NULLIF(x,y) function.  The result is the first\n** argument if the arguments are different.  The result is NULL if the\n** arguments are equal to each other.\n*/\nstatic void nullifFunc(\n  sqlite3_context *context,\n  int NotUsed,\n  sqlite3_value **argv\n){\n  CollSeq *pColl = sqlite3GetFuncCollSeq(context);\n  UNUSED_PARAMETER(NotUsed);\n  if( sqlite3MemCompare(argv[0], argv[1], pColl)!=0 ){\n    sqlite3_result_value(context, argv[0]);\n  }\n}\n\n/*\n** Implementation of the sqlite_version() function.  The result is the version\n** of the SQLite library that is running.\n*/\nstatic void versionFunc(\n  sqlite3_context *context,\n  int NotUsed,\n  sqlite3_value **NotUsed2\n){\n  UNUSED_PARAMETER2(NotUsed, NotUsed2);\n  /* IMP: R-48699-48617 This function is an SQL wrapper around the\n  ** sqlite3_libversion() C-interface. */\n  sqlite3_result_text(context, sqlite3_libversion(), -1, SQLITE_STATIC);\n}\n\n/*\n** Implementation of the sqlite_source_id() function. The result is a string\n** that identifies the particular version of the source code used to build\n** SQLite.\n*/\nstatic void sourceidFunc(\n  sqlite3_context *context,\n  int NotUsed,\n  sqlite3_value **NotUsed2\n){\n  UNUSED_PARAMETER2(NotUsed, NotUsed2);\n  /* IMP: R-24470-31136 This function is an SQL wrapper around the\n  ** sqlite3_sourceid() C interface. */\n  sqlite3_result_text(context, sqlite3_sourceid(), -1, SQLITE_STATIC);\n}\n\n/*\n** Implementation of the sqlite_log() function.  This is a wrapper around\n** sqlite3_log().  The return value is NULL.  The function exists purely for\n** its side-effects.\n*/\nstatic void errlogFunc(\n  sqlite3_context *context,\n  int argc,\n  sqlite3_value **argv\n){\n  UNUSED_PARAMETER(argc);\n  UNUSED_PARAMETER(context);\n  sqlite3_log(sqlite3_value_int(argv[0]), \"%s\", sqlite3_value_text(argv[1]));\n}\n\n/*\n** Implementation of the sqlite_compileoption_used() function.\n** The result is an integer that identifies if the compiler option\n** was used to build SQLite.\n*/\n#ifndef SQLITE_OMIT_COMPILEOPTION_DIAGS\nstatic void compileoptionusedFunc(\n  sqlite3_context *context,\n  int argc,\n  sqlite3_value **argv\n){\n  const char *zOptName;\n  assert( argc==1 );\n  UNUSED_PARAMETER(argc);\n  /* IMP: R-39564-36305 The sqlite_compileoption_used() SQL\n  ** function is a wrapper around the sqlite3_compileoption_used() C/C++\n  ** function.\n  */\n  if( (zOptName = (const char*)sqlite3_value_text(argv[0]))!=0 ){\n    sqlite3_result_int(context, sqlite3_compileoption_used(zOptName));\n  }\n}\n#endif /* SQLITE_OMIT_COMPILEOPTION_DIAGS */\n\n/*\n** Implementation of the sqlite_compileoption_get() function. \n** The result is a string that identifies the compiler options \n** used to build SQLite.\n*/\n#ifndef SQLITE_OMIT_COMPILEOPTION_DIAGS\nstatic void compileoptiongetFunc(\n  sqlite3_context *context,\n  int argc,\n  sqlite3_value **argv\n){\n  int n;\n  assert( argc==1 );\n  UNUSED_PARAMETER(argc);\n  /* IMP: R-04922-24076 The sqlite_compileoption_get() SQL function\n  ** is a wrapper around the sqlite3_compileoption_get() C/C++ function.\n  */\n  n = sqlite3_value_int(argv[0]);\n  sqlite3_result_text(context, sqlite3_compileoption_get(n), -1, SQLITE_STATIC);\n}\n#endif /* SQLITE_OMIT_COMPILEOPTION_DIAGS */\n\n/* Array for converting from half-bytes (nybbles) into ASCII hex\n** digits. */\nstatic const char hexdigits[] = {\n  '0', '1', '2', '3', '4', '5', '6', '7',\n  '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' \n};\n\n/*\n** Implementation of the QUOTE() function.  This function takes a single\n** argument.  If the argument is numeric, the return value is the same as\n** the argument.  If the argument is NULL, the return value is the string\n** \"NULL\".  Otherwise, the argument is enclosed in single quotes with\n** single-quote escapes.\n*/\nstatic void quoteFunc(sqlite3_context *context, int argc, sqlite3_value **argv){\n  assert( argc==1 );\n  UNUSED_PARAMETER(argc);\n  switch( sqlite3_value_type(argv[0]) ){\n    case SQLITE_FLOAT: {\n      double r1, r2;\n      char zBuf[50];\n      r1 = sqlite3_value_double(argv[0]);\n      sqlite3_snprintf(sizeof(zBuf), zBuf, \"%!.17g\", r1);\n      sqlite3AtoF(zBuf, &r2, 20, SQLITE_UTF8);\n      if( r1!=r2 ){\n        sqlite3_snprintf(sizeof(zBuf), zBuf, \"%!.20e\", r1);\n      }\n      sqlite3_result_text(context, zBuf, -1, SQLITE_TRANSIENT);\n      break;\n    }\n    case SQLITE_INTEGER: {\n      sqlite3_result_value(context, argv[0]);\n      break;\n    }\n    case SQLITE_BLOB: {\n      char *zText = 0;\n      char const *zBlob = sqlite3_value_blob(argv[0]);\n      int nBlob = sqlite3_value_bytes(argv[0]);\n      assert( zBlob==sqlite3_value_blob(argv[0]) ); /* No encoding change */\n      zText = (char *)contextMalloc(context, (2*(i64)nBlob)+4); \n      if( zText ){\n        int i;\n        for(i=0; i<nBlob; i++){\n          zText[(i*2)+2] = hexdigits[(zBlob[i]>>4)&0x0F];\n          zText[(i*2)+3] = hexdigits[(zBlob[i])&0x0F];\n        }\n        zText[(nBlob*2)+2] = '\\'';\n        zText[(nBlob*2)+3] = '\\0';\n        zText[0] = 'X';\n        zText[1] = '\\'';\n        sqlite3_result_text(context, zText, -1, SQLITE_TRANSIENT);\n        sqlite3_free(zText);\n      }\n      break;\n    }\n    case SQLITE_TEXT: {\n      int i,j;\n      u64 n;\n      const unsigned char *zArg = sqlite3_value_text(argv[0]);\n      char *z;\n\n      if( zArg==0 ) return;\n      for(i=0, n=0; zArg[i]; i++){ if( zArg[i]=='\\'' ) n++; }\n      z = contextMalloc(context, ((i64)i)+((i64)n)+3);\n      if( z ){\n        z[0] = '\\'';\n        for(i=0, j=1; zArg[i]; i++){\n          z[j++] = zArg[i];\n          if( zArg[i]=='\\'' ){\n            z[j++] = '\\'';\n          }\n        }\n        z[j++] = '\\'';\n        z[j] = 0;\n        sqlite3_result_text(context, z, j, sqlite3_free);\n      }\n      break;\n    }\n    default: {\n      assert( sqlite3_value_type(argv[0])==SQLITE_NULL );\n      sqlite3_result_text(context, \"NULL\", 4, SQLITE_STATIC);\n      break;\n    }\n  }\n}\n\n/*\n** The unicode() function.  Return the integer unicode code-point value\n** for the first character of the input string. \n*/\nstatic void unicodeFunc(\n  sqlite3_context *context,\n  int argc,\n  sqlite3_value **argv\n){\n  const unsigned char *z = sqlite3_value_text(argv[0]);\n  (void)argc;\n  if( z && z[0] ) sqlite3_result_int(context, sqlite3Utf8Read(&z));\n}\n\n/*\n** The char() function takes zero or more arguments, each of which is\n** an integer.  It constructs a string where each character of the string\n** is the unicode character for the corresponding integer argument.\n*/\nstatic void charFunc(\n  sqlite3_context *context,\n  int argc,\n  sqlite3_value **argv\n){\n  unsigned char *z, *zOut;\n  int i;\n  zOut = z = sqlite3_malloc64( argc*4+1 );\n  if( z==0 ){\n    sqlite3_result_error_nomem(context);\n    return;\n  }\n  for(i=0; i<argc; i++){\n    sqlite3_int64 x;\n    unsigned c;\n    x = sqlite3_value_int64(argv[i]);\n    if( x<0 || x>0x10ffff ) x = 0xfffd;\n    c = (unsigned)(x & 0x1fffff);\n    if( c<0x00080 ){\n      *zOut++ = (u8)(c&0xFF);\n    }else if( c<0x00800 ){\n      *zOut++ = 0xC0 + (u8)((c>>6)&0x1F);\n      *zOut++ = 0x80 + (u8)(c & 0x3F);\n    }else if( c<0x10000 ){\n      *zOut++ = 0xE0 + (u8)((c>>12)&0x0F);\n      *zOut++ = 0x80 + (u8)((c>>6) & 0x3F);\n      *zOut++ = 0x80 + (u8)(c & 0x3F);\n    }else{\n      *zOut++ = 0xF0 + (u8)((c>>18) & 0x07);\n      *zOut++ = 0x80 + (u8)((c>>12) & 0x3F);\n      *zOut++ = 0x80 + (u8)((c>>6) & 0x3F);\n      *zOut++ = 0x80 + (u8)(c & 0x3F);\n    }                                                    \\\n  }\n  sqlite3_result_text64(context, (char*)z, zOut-z, sqlite3_free, SQLITE_UTF8);\n}\n\n/*\n** The hex() function.  Interpret the argument as a blob.  Return\n** a hexadecimal rendering as text.\n*/\nstatic void hexFunc(\n  sqlite3_context *context,\n  int argc,\n  sqlite3_value **argv\n){\n  int i, n;\n  const unsigned char *pBlob;\n  char *zHex, *z;\n  assert( argc==1 );\n  UNUSED_PARAMETER(argc);\n  pBlob = sqlite3_value_blob(argv[0]);\n  n = sqlite3_value_bytes(argv[0]);\n  assert( pBlob==sqlite3_value_blob(argv[0]) );  /* No encoding change */\n  z = zHex = contextMalloc(context, ((i64)n)*2 + 1);\n  if( zHex ){\n    for(i=0; i<n; i++, pBlob++){\n      unsigned char c = *pBlob;\n      *(z++) = hexdigits[(c>>4)&0xf];\n      *(z++) = hexdigits[c&0xf];\n    }\n    *z = 0;\n    sqlite3_result_text(context, zHex, n*2, sqlite3_free);\n  }\n}\n\n/*\n** The zeroblob(N) function returns a zero-filled blob of size N bytes.\n*/\nstatic void zeroblobFunc(\n  sqlite3_context *context,\n  int argc,\n  sqlite3_value **argv\n){\n  i64 n;\n  int rc;\n  assert( argc==1 );\n  UNUSED_PARAMETER(argc);\n  n = sqlite3_value_int64(argv[0]);\n  if( n<0 ) n = 0;\n  rc = sqlite3_result_zeroblob64(context, n); /* IMP: R-00293-64994 */\n  if( rc ){\n    sqlite3_result_error_code(context, rc);\n  }\n}\n\n/*\n** The replace() function.  Three arguments are all strings: call\n** them A, B, and C. The result is also a string which is derived\n** from A by replacing every occurrence of B with C.  The match\n** must be exact.  Collating sequences are not used.\n*/\nstatic void replaceFunc(\n  sqlite3_context *context,\n  int argc,\n  sqlite3_value **argv\n){\n  const unsigned char *zStr;        /* The input string A */\n  const unsigned char *zPattern;    /* The pattern string B */\n  const unsigned char *zRep;        /* The replacement string C */\n  unsigned char *zOut;              /* The output */\n  int nStr;                /* Size of zStr */\n  int nPattern;            /* Size of zPattern */\n  int nRep;                /* Size of zRep */\n  i64 nOut;                /* Maximum size of zOut */\n  int loopLimit;           /* Last zStr[] that might match zPattern[] */\n  int i, j;                /* Loop counters */\n  unsigned cntExpand;      /* Number zOut expansions */\n  sqlite3 *db = sqlite3_context_db_handle(context);\n\n  assert( argc==3 );\n  UNUSED_PARAMETER(argc);\n  zStr = sqlite3_value_text(argv[0]);\n  if( zStr==0 ) return;\n  nStr = sqlite3_value_bytes(argv[0]);\n  assert( zStr==sqlite3_value_text(argv[0]) );  /* No encoding change */\n  zPattern = sqlite3_value_text(argv[1]);\n  if( zPattern==0 ){\n    assert( sqlite3_value_type(argv[1])==SQLITE_NULL\n            || sqlite3_context_db_handle(context)->mallocFailed );\n    return;\n  }\n  if( zPattern[0]==0 ){\n    assert( sqlite3_value_type(argv[1])!=SQLITE_NULL );\n    sqlite3_result_value(context, argv[0]);\n    return;\n  }\n  nPattern = sqlite3_value_bytes(argv[1]);\n  assert( zPattern==sqlite3_value_text(argv[1]) );  /* No encoding change */\n  zRep = sqlite3_value_text(argv[2]);\n  if( zRep==0 ) return;\n  nRep = sqlite3_value_bytes(argv[2]);\n  assert( zRep==sqlite3_value_text(argv[2]) );\n  nOut = nStr + 1;\n  assert( nOut<SQLITE_MAX_LENGTH );\n  zOut = contextMalloc(context, (i64)nOut);\n  if( zOut==0 ){\n    return;\n  }\n  loopLimit = nStr - nPattern;  \n  cntExpand = 0;\n  for(i=j=0; i<=loopLimit; i++){\n    if( zStr[i]!=zPattern[0] || memcmp(&zStr[i], zPattern, nPattern) ){\n      zOut[j++] = zStr[i];\n    }else{\n      if( nRep>nPattern ){\n        nOut += nRep - nPattern;\n        testcase( nOut-1==db->aLimit[SQLITE_LIMIT_LENGTH] );\n        testcase( nOut-2==db->aLimit[SQLITE_LIMIT_LENGTH] );\n        if( nOut-1>db->aLimit[SQLITE_LIMIT_LENGTH] ){\n          sqlite3_result_error_toobig(context);\n          sqlite3_free(zOut);\n          return;\n        }\n        cntExpand++;\n        if( (cntExpand&(cntExpand-1))==0 ){\n          /* Grow the size of the output buffer only on substitutions\n          ** whose index is a power of two: 1, 2, 4, 8, 16, 32, ... */\n          u8 *zOld;\n          zOld = zOut;\n          zOut = sqlite3_realloc64(zOut, (int)nOut + (nOut - nStr - 1));\n          if( zOut==0 ){\n            sqlite3_result_error_nomem(context);\n            sqlite3_free(zOld);\n            return;\n          }\n        }\n      }\n      memcpy(&zOut[j], zRep, nRep);\n      j += nRep;\n      i += nPattern-1;\n    }\n  }\n  assert( j+nStr-i+1<=nOut );\n  memcpy(&zOut[j], &zStr[i], nStr-i);\n  j += nStr - i;\n  assert( j<=nOut );\n  zOut[j] = 0;\n  sqlite3_result_text(context, (char*)zOut, j, sqlite3_free);\n}\n\n/*\n** Implementation of the TRIM(), LTRIM(), and RTRIM() functions.\n** The userdata is 0x1 for left trim, 0x2 for right trim, 0x3 for both.\n*/\nstatic void trimFunc(\n  sqlite3_context *context,\n  int argc,\n  sqlite3_value **argv\n){\n  const unsigned char *zIn;         /* Input string */\n  const unsigned char *zCharSet;    /* Set of characters to trim */\n  int nIn;                          /* Number of bytes in input */\n  int flags;                        /* 1: trimleft  2: trimright  3: trim */\n  int i;                            /* Loop counter */\n  unsigned char *aLen = 0;          /* Length of each character in zCharSet */\n  unsigned char **azChar = 0;       /* Individual characters in zCharSet */\n  int nChar;                        /* Number of characters in zCharSet */\n\n  if( sqlite3_value_type(argv[0])==SQLITE_NULL ){\n    return;\n  }\n  zIn = sqlite3_value_text(argv[0]);\n  if( zIn==0 ) return;\n  nIn = sqlite3_value_bytes(argv[0]);\n  assert( zIn==sqlite3_value_text(argv[0]) );\n  if( argc==1 ){\n    static const unsigned char lenOne[] = { 1 };\n    static unsigned char * const azOne[] = { (u8*)\" \" };\n    nChar = 1;\n    aLen = (u8*)lenOne;\n    azChar = (unsigned char **)azOne;\n    zCharSet = 0;\n  }else if( (zCharSet = sqlite3_value_text(argv[1]))==0 ){\n    return;\n  }else{\n    const unsigned char *z;\n    for(z=zCharSet, nChar=0; *z; nChar++){\n      SQLITE_SKIP_UTF8(z);\n    }\n    if( nChar>0 ){\n      azChar = contextMalloc(context, ((i64)nChar)*(sizeof(char*)+1));\n      if( azChar==0 ){\n        return;\n      }\n      aLen = (unsigned char*)&azChar[nChar];\n      for(z=zCharSet, nChar=0; *z; nChar++){\n        azChar[nChar] = (unsigned char *)z;\n        SQLITE_SKIP_UTF8(z);\n        aLen[nChar] = (u8)(z - azChar[nChar]);\n      }\n    }\n  }\n  if( nChar>0 ){\n    flags = SQLITE_PTR_TO_INT(sqlite3_user_data(context));\n    if( flags & 1 ){\n      while( nIn>0 ){\n        int len = 0;\n        for(i=0; i<nChar; i++){\n          len = aLen[i];\n          if( len<=nIn && memcmp(zIn, azChar[i], len)==0 ) break;\n        }\n        if( i>=nChar ) break;\n        zIn += len;\n        nIn -= len;\n      }\n    }\n    if( flags & 2 ){\n      while( nIn>0 ){\n        int len = 0;\n        for(i=0; i<nChar; i++){\n          len = aLen[i];\n          if( len<=nIn && memcmp(&zIn[nIn-len],azChar[i],len)==0 ) break;\n        }\n        if( i>=nChar ) break;\n        nIn -= len;\n      }\n    }\n    if( zCharSet ){\n      sqlite3_free(azChar);\n    }\n  }\n  sqlite3_result_text(context, (char*)zIn, nIn, SQLITE_TRANSIENT);\n}\n\n\n#ifdef SQLITE_ENABLE_UNKNOWN_SQL_FUNCTION\n/*\n** The \"unknown\" function is automatically substituted in place of\n** any unrecognized function name when doing an EXPLAIN or EXPLAIN QUERY PLAN\n** when the SQLITE_ENABLE_UNKNOWN_FUNCTION compile-time option is used.\n** When the \"sqlite3\" command-line shell is built using this functionality,\n** that allows an EXPLAIN or EXPLAIN QUERY PLAN for complex queries\n** involving application-defined functions to be examined in a generic\n** sqlite3 shell.\n*/\nstatic void unknownFunc(\n  sqlite3_context *context,\n  int argc,\n  sqlite3_value **argv\n){\n  /* no-op */\n}\n#endif /*SQLITE_ENABLE_UNKNOWN_SQL_FUNCTION*/\n\n\n/* IMP: R-25361-16150 This function is omitted from SQLite by default. It\n** is only available if the SQLITE_SOUNDEX compile-time option is used\n** when SQLite is built.\n*/\n#ifdef SQLITE_SOUNDEX\n/*\n** Compute the soundex encoding of a word.\n**\n** IMP: R-59782-00072 The soundex(X) function returns a string that is the\n** soundex encoding of the string X. \n*/\nstatic void soundexFunc(\n  sqlite3_context *context,\n  int argc,\n  sqlite3_value **argv\n){\n  char zResult[8];\n  const u8 *zIn;\n  int i, j;\n  static const unsigned char iCode[] = {\n    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n    0, 0, 1, 2, 3, 0, 1, 2, 0, 0, 2, 2, 4, 5, 5, 0,\n    1, 2, 6, 2, 3, 0, 1, 0, 2, 0, 2, 0, 0, 0, 0, 0,\n    0, 0, 1, 2, 3, 0, 1, 2, 0, 0, 2, 2, 4, 5, 5, 0,\n    1, 2, 6, 2, 3, 0, 1, 0, 2, 0, 2, 0, 0, 0, 0, 0,\n  };\n  assert( argc==1 );\n  zIn = (u8*)sqlite3_value_text(argv[0]);\n  if( zIn==0 ) zIn = (u8*)\"\";\n  for(i=0; zIn[i] && !sqlite3Isalpha(zIn[i]); i++){}\n  if( zIn[i] ){\n    u8 prevcode = iCode[zIn[i]&0x7f];\n    zResult[0] = sqlite3Toupper(zIn[i]);\n    for(j=1; j<4 && zIn[i]; i++){\n      int code = iCode[zIn[i]&0x7f];\n      if( code>0 ){\n        if( code!=prevcode ){\n          prevcode = code;\n          zResult[j++] = code + '0';\n        }\n      }else{\n        prevcode = 0;\n      }\n    }\n    while( j<4 ){\n      zResult[j++] = '0';\n    }\n    zResult[j] = 0;\n    sqlite3_result_text(context, zResult, 4, SQLITE_TRANSIENT);\n  }else{\n    /* IMP: R-64894-50321 The string \"?000\" is returned if the argument\n    ** is NULL or contains no ASCII alphabetic characters. */\n    sqlite3_result_text(context, \"?000\", 4, SQLITE_STATIC);\n  }\n}\n#endif /* SQLITE_SOUNDEX */\n\n#ifndef SQLITE_OMIT_LOAD_EXTENSION\n/*\n** A function that loads a shared-library extension then returns NULL.\n*/\nstatic void loadExt(sqlite3_context *context, int argc, sqlite3_value **argv){\n  const char *zFile = (const char *)sqlite3_value_text(argv[0]);\n  const char *zProc;\n  sqlite3 *db = sqlite3_context_db_handle(context);\n  char *zErrMsg = 0;\n\n  /* Disallow the load_extension() SQL function unless the SQLITE_LoadExtFunc\n  ** flag is set.  See the sqlite3_enable_load_extension() API.\n  */\n  if( (db->flags & SQLITE_LoadExtFunc)==0 ){\n    sqlite3_result_error(context, \"not authorized\", -1);\n    return;\n  }\n\n  if( argc==2 ){\n    zProc = (const char *)sqlite3_value_text(argv[1]);\n  }else{\n    zProc = 0;\n  }\n  if( zFile && sqlite3_load_extension(db, zFile, zProc, &zErrMsg) ){\n    sqlite3_result_error(context, zErrMsg, -1);\n    sqlite3_free(zErrMsg);\n  }\n}\n#endif\n\n\n/*\n** An instance of the following structure holds the context of a\n** sum() or avg() aggregate computation.\n*/\ntypedef struct SumCtx SumCtx;\nstruct SumCtx {\n  double rSum;      /* Floating point sum */\n  i64 iSum;         /* Integer sum */   \n  i64 cnt;          /* Number of elements summed */\n  u8 overflow;      /* True if integer overflow seen */\n  u8 approx;        /* True if non-integer value was input to the sum */\n};\n\n/*\n** Routines used to compute the sum, average, and total.\n**\n** The SUM() function follows the (broken) SQL standard which means\n** that it returns NULL if it sums over no inputs.  TOTAL returns\n** 0.0 in that case.  In addition, TOTAL always returns a float where\n** SUM might return an integer if it never encounters a floating point\n** value.  TOTAL never fails, but SUM might through an exception if\n** it overflows an integer.\n*/\nstatic void sumStep(sqlite3_context *context, int argc, sqlite3_value **argv){\n  SumCtx *p;\n  int type;\n  assert( argc==1 );\n  UNUSED_PARAMETER(argc);\n  p = sqlite3_aggregate_context(context, sizeof(*p));\n  type = sqlite3_value_numeric_type(argv[0]);\n  if( p && type!=SQLITE_NULL ){\n    p->cnt++;\n    if( type==SQLITE_INTEGER ){\n      i64 v = sqlite3_value_int64(argv[0]);\n      p->rSum += v;\n      if( (p->approx|p->overflow)==0 && sqlite3AddInt64(&p->iSum, v) ){\n        p->approx = p->overflow = 1;\n      }\n    }else{\n      p->rSum += sqlite3_value_double(argv[0]);\n      p->approx = 1;\n    }\n  }\n}\n#ifndef SQLITE_OMIT_WINDOWFUNC\nstatic void sumInverse(sqlite3_context *context, int argc, sqlite3_value**argv){\n  SumCtx *p;\n  int type;\n  assert( argc==1 );\n  UNUSED_PARAMETER(argc);\n  p = sqlite3_aggregate_context(context, sizeof(*p));\n  type = sqlite3_value_numeric_type(argv[0]);\n  /* p is always non-NULL because sumStep() will have been called first\n  ** to initialize it */\n  if( ALWAYS(p) && type!=SQLITE_NULL ){\n    assert( p->cnt>0 );\n    p->cnt--;\n    assert( type==SQLITE_INTEGER || p->approx );\n    if( type==SQLITE_INTEGER && p->approx==0 ){\n      i64 v = sqlite3_value_int64(argv[0]);\n      p->rSum -= v;\n      p->iSum -= v;\n    }else{\n      p->rSum -= sqlite3_value_double(argv[0]);\n    }\n  }\n}\n#else\n# define sumInverse 0\n#endif /* SQLITE_OMIT_WINDOWFUNC */\nstatic void sumFinalize(sqlite3_context *context){\n  SumCtx *p;\n  p = sqlite3_aggregate_context(context, 0);\n  if( p && p->cnt>0 ){\n    if( p->overflow ){\n      sqlite3_result_error(context,\"integer overflow\",-1);\n    }else if( p->approx ){\n      sqlite3_result_double(context, p->rSum);\n    }else{\n      sqlite3_result_int64(context, p->iSum);\n    }\n  }\n}\nstatic void avgFinalize(sqlite3_context *context){\n  SumCtx *p;\n  p = sqlite3_aggregate_context(context, 0);\n  if( p && p->cnt>0 ){\n    sqlite3_result_double(context, p->rSum/(double)p->cnt);\n  }\n}\nstatic void totalFinalize(sqlite3_context *context){\n  SumCtx *p;\n  p = sqlite3_aggregate_context(context, 0);\n  /* (double)0 In case of SQLITE_OMIT_FLOATING_POINT... */\n  sqlite3_result_double(context, p ? p->rSum : (double)0);\n}\n\n/*\n** The following structure keeps track of state information for the\n** count() aggregate function.\n*/\ntypedef struct CountCtx CountCtx;\nstruct CountCtx {\n  i64 n;\n#ifdef SQLITE_DEBUG\n  int bInverse;                   /* True if xInverse() ever called */\n#endif\n};\n\n/*\n** Routines to implement the count() aggregate function.\n*/\nstatic void countStep(sqlite3_context *context, int argc, sqlite3_value **argv){\n  CountCtx *p;\n  p = sqlite3_aggregate_context(context, sizeof(*p));\n  if( (argc==0 || SQLITE_NULL!=sqlite3_value_type(argv[0])) && p ){\n    p->n++;\n  }\n\n#ifndef SQLITE_OMIT_DEPRECATED\n  /* The sqlite3_aggregate_count() function is deprecated.  But just to make\n  ** sure it still operates correctly, verify that its count agrees with our \n  ** internal count when using count(*) and when the total count can be\n  ** expressed as a 32-bit integer. */\n  assert( argc==1 || p==0 || p->n>0x7fffffff || p->bInverse\n          || p->n==sqlite3_aggregate_count(context) );\n#endif\n}   \nstatic void countFinalize(sqlite3_context *context){\n  CountCtx *p;\n  p = sqlite3_aggregate_context(context, 0);\n  sqlite3_result_int64(context, p ? p->n : 0);\n}\n#ifndef SQLITE_OMIT_WINDOWFUNC\nstatic void countInverse(sqlite3_context *ctx, int argc, sqlite3_value **argv){\n  CountCtx *p;\n  p = sqlite3_aggregate_context(ctx, sizeof(*p));\n  /* p is always non-NULL since countStep() will have been called first */\n  if( (argc==0 || SQLITE_NULL!=sqlite3_value_type(argv[0])) && ALWAYS(p) ){\n    p->n--;\n#ifdef SQLITE_DEBUG\n    p->bInverse = 1;\n#endif\n  }\n}   \n#else\n# define countInverse 0\n#endif /* SQLITE_OMIT_WINDOWFUNC */\n\n/*\n** Routines to implement min() and max() aggregate functions.\n*/\nstatic void minmaxStep(\n  sqlite3_context *context, \n  int NotUsed, \n  sqlite3_value **argv\n){\n  Mem *pArg  = (Mem *)argv[0];\n  Mem *pBest;\n  UNUSED_PARAMETER(NotUsed);\n\n  pBest = (Mem *)sqlite3_aggregate_context(context, sizeof(*pBest));\n  if( !pBest ) return;\n\n  if( sqlite3_value_type(pArg)==SQLITE_NULL ){\n    if( pBest->flags ) sqlite3SkipAccumulatorLoad(context);\n  }else if( pBest->flags ){\n    int max;\n    int cmp;\n    CollSeq *pColl = sqlite3GetFuncCollSeq(context);\n    /* This step function is used for both the min() and max() aggregates,\n    ** the only difference between the two being that the sense of the\n    ** comparison is inverted. For the max() aggregate, the\n    ** sqlite3_user_data() function returns (void *)-1. For min() it\n    ** returns (void *)db, where db is the sqlite3* database pointer.\n    ** Therefore the next statement sets variable 'max' to 1 for the max()\n    ** aggregate, or 0 for min().\n    */\n    max = sqlite3_user_data(context)!=0;\n    cmp = sqlite3MemCompare(pBest, pArg, pColl);\n    if( (max && cmp<0) || (!max && cmp>0) ){\n      sqlite3VdbeMemCopy(pBest, pArg);\n    }else{\n      sqlite3SkipAccumulatorLoad(context);\n    }\n  }else{\n    pBest->db = sqlite3_context_db_handle(context);\n    sqlite3VdbeMemCopy(pBest, pArg);\n  }\n}\nstatic void minMaxValueFinalize(sqlite3_context *context, int bValue){\n  sqlite3_value *pRes;\n  pRes = (sqlite3_value *)sqlite3_aggregate_context(context, 0);\n  if( pRes ){\n    if( pRes->flags ){\n      sqlite3_result_value(context, pRes);\n    }\n    if( bValue==0 ) sqlite3VdbeMemRelease(pRes);\n  }\n}\n#ifndef SQLITE_OMIT_WINDOWFUNC\nstatic void minMaxValue(sqlite3_context *context){\n  minMaxValueFinalize(context, 1);\n}\n#else\n# define minMaxValue 0\n#endif /* SQLITE_OMIT_WINDOWFUNC */\nstatic void minMaxFinalize(sqlite3_context *context){\n  minMaxValueFinalize(context, 0);\n}\n\n/*\n** group_concat(EXPR, ?SEPARATOR?)\n*/\nstatic void groupConcatStep(\n  sqlite3_context *context,\n  int argc,\n  sqlite3_value **argv\n){\n  const char *zVal;\n  StrAccum *pAccum;\n  const char *zSep;\n  int nVal, nSep;\n  assert( argc==1 || argc==2 );\n  if( sqlite3_value_type(argv[0])==SQLITE_NULL ) return;\n  pAccum = (StrAccum*)sqlite3_aggregate_context(context, sizeof(*pAccum));\n\n  if( pAccum ){\n    sqlite3 *db = sqlite3_context_db_handle(context);\n    int firstTerm = pAccum->mxAlloc==0;\n    pAccum->mxAlloc = db->aLimit[SQLITE_LIMIT_LENGTH];\n    if( !firstTerm ){\n      if( argc==2 ){\n        zSep = (char*)sqlite3_value_text(argv[1]);\n        nSep = sqlite3_value_bytes(argv[1]);\n      }else{\n        zSep = \",\";\n        nSep = 1;\n      }\n      if( zSep ) sqlite3_str_append(pAccum, zSep, nSep);\n    }\n    zVal = (char*)sqlite3_value_text(argv[0]);\n    nVal = sqlite3_value_bytes(argv[0]);\n    if( zVal ) sqlite3_str_append(pAccum, zVal, nVal);\n  }\n}\n#ifndef SQLITE_OMIT_WINDOWFUNC\nstatic void groupConcatInverse(\n  sqlite3_context *context,\n  int argc,\n  sqlite3_value **argv\n){\n  int n;\n  StrAccum *pAccum;\n  assert( argc==1 || argc==2 );\n  if( sqlite3_value_type(argv[0])==SQLITE_NULL ) return;\n  pAccum = (StrAccum*)sqlite3_aggregate_context(context, sizeof(*pAccum));\n  /* pAccum is always non-NULL since groupConcatStep() will have always\n  ** run frist to initialize it */\n  if( ALWAYS(pAccum) ){\n    n = sqlite3_value_bytes(argv[0]);\n    if( argc==2 ){\n      n += sqlite3_value_bytes(argv[1]);\n    }else{\n      n++;\n    }\n    if( n>=(int)pAccum->nChar ){\n      pAccum->nChar = 0;\n    }else{\n      pAccum->nChar -= n;\n      memmove(pAccum->zText, &pAccum->zText[n], pAccum->nChar);\n    }\n    if( pAccum->nChar==0 ) pAccum->mxAlloc = 0;\n  }\n}\n#else\n# define groupConcatInverse 0\n#endif /* SQLITE_OMIT_WINDOWFUNC */\nstatic void groupConcatFinalize(sqlite3_context *context){\n  StrAccum *pAccum;\n  pAccum = sqlite3_aggregate_context(context, 0);\n  if( pAccum ){\n    if( pAccum->accError==SQLITE_TOOBIG ){\n      sqlite3_result_error_toobig(context);\n    }else if( pAccum->accError==SQLITE_NOMEM ){\n      sqlite3_result_error_nomem(context);\n    }else{    \n      sqlite3_result_text(context, sqlite3StrAccumFinish(pAccum), -1, \n                          sqlite3_free);\n    }\n  }\n}\n#ifndef SQLITE_OMIT_WINDOWFUNC\nstatic void groupConcatValue(sqlite3_context *context){\n  sqlite3_str *pAccum;\n  pAccum = (sqlite3_str*)sqlite3_aggregate_context(context, 0);\n  if( pAccum ){\n    if( pAccum->accError==SQLITE_TOOBIG ){\n      sqlite3_result_error_toobig(context);\n    }else if( pAccum->accError==SQLITE_NOMEM ){\n      sqlite3_result_error_nomem(context);\n    }else{    \n      const char *zText = sqlite3_str_value(pAccum);\n      sqlite3_result_text(context, zText, -1, SQLITE_TRANSIENT);\n    }\n  }\n}\n#else\n# define groupConcatValue 0\n#endif /* SQLITE_OMIT_WINDOWFUNC */\n\n/*\n** This routine does per-connection function registration.  Most\n** of the built-in functions above are part of the global function set.\n** This routine only deals with those that are not global.\n*/\nSQLITE_PRIVATE void sqlite3RegisterPerConnectionBuiltinFunctions(sqlite3 *db){\n  int rc = sqlite3_overload_function(db, \"MATCH\", 2);\n/* BEGIN SQLCIPHER */\n#ifdef SQLITE_HAS_CODEC\n#ifndef OMIT_EXPORT\n  extern void sqlcipher_exportFunc(sqlite3_context *, int, sqlite3_value **);\n#endif\n#endif\n/* END SQLCIPHER */\n  assert( rc==SQLITE_NOMEM || rc==SQLITE_OK );\n  if( rc==SQLITE_NOMEM ){\n    sqlite3OomFault(db);\n  }\n/* BEGIN SQLCIPHER */\n#ifdef SQLITE_HAS_CODEC\n#ifndef OMIT_EXPORT\n  sqlite3CreateFunc(db, \"sqlcipher_export\", 1, SQLITE_TEXT, 0, sqlcipher_exportFunc, 0, 0, 0, 0, 0);\n  sqlite3CreateFunc(db, \"sqlcipher_export\", 2, SQLITE_TEXT, 0, sqlcipher_exportFunc, 0, 0, 0, 0, 0);\n#endif\n#endif\n/* END SQLCIPHER */\n}\n\n/*\n** Set the LIKEOPT flag on the 2-argument function with the given name.\n*/\nstatic void setLikeOptFlag(sqlite3 *db, const char *zName, u8 flagVal){\n  FuncDef *pDef;\n  pDef = sqlite3FindFunction(db, zName, 2, SQLITE_UTF8, 0);\n  if( ALWAYS(pDef) ){\n    pDef->funcFlags |= flagVal;\n  }\n}\n\n/*\n** Register the built-in LIKE and GLOB functions.  The caseSensitive\n** parameter determines whether or not the LIKE operator is case\n** sensitive.  GLOB is always case sensitive.\n*/\nSQLITE_PRIVATE void sqlite3RegisterLikeFunctions(sqlite3 *db, int caseSensitive){\n  struct compareInfo *pInfo;\n  if( caseSensitive ){\n    pInfo = (struct compareInfo*)&likeInfoAlt;\n  }else{\n    pInfo = (struct compareInfo*)&likeInfoNorm;\n  }\n  sqlite3CreateFunc(db, \"like\", 2, SQLITE_UTF8, pInfo, likeFunc, 0, 0, 0, 0, 0);\n  sqlite3CreateFunc(db, \"like\", 3, SQLITE_UTF8, pInfo, likeFunc, 0, 0, 0, 0, 0);\n  sqlite3CreateFunc(db, \"glob\", 2, SQLITE_UTF8, \n      (struct compareInfo*)&globInfo, likeFunc, 0, 0, 0, 0, 0);\n  setLikeOptFlag(db, \"glob\", SQLITE_FUNC_LIKE | SQLITE_FUNC_CASE);\n  setLikeOptFlag(db, \"like\", \n      caseSensitive ? (SQLITE_FUNC_LIKE | SQLITE_FUNC_CASE) : SQLITE_FUNC_LIKE);\n}\n\n/*\n** pExpr points to an expression which implements a function.  If\n** it is appropriate to apply the LIKE optimization to that function\n** then set aWc[0] through aWc[2] to the wildcard characters and the\n** escape character and then return TRUE.  If the function is not a \n** LIKE-style function then return FALSE.\n**\n** The expression \"a LIKE b ESCAPE c\" is only considered a valid LIKE\n** operator if c is a string literal that is exactly one byte in length.\n** That one byte is stored in aWc[3].  aWc[3] is set to zero if there is\n** no ESCAPE clause.\n**\n** *pIsNocase is set to true if uppercase and lowercase are equivalent for\n** the function (default for LIKE).  If the function makes the distinction\n** between uppercase and lowercase (as does GLOB) then *pIsNocase is set to\n** false.\n*/\nSQLITE_PRIVATE int sqlite3IsLikeFunction(sqlite3 *db, Expr *pExpr, int *pIsNocase, char *aWc){\n  FuncDef *pDef;\n  int nExpr;\n  if( pExpr->op!=TK_FUNCTION || !pExpr->x.pList ){\n    return 0;\n  }\n  assert( !ExprHasProperty(pExpr, EP_xIsSelect) );\n  nExpr = pExpr->x.pList->nExpr;\n  pDef = sqlite3FindFunction(db, pExpr->u.zToken, nExpr, SQLITE_UTF8, 0);\n  if( NEVER(pDef==0) || (pDef->funcFlags & SQLITE_FUNC_LIKE)==0 ){\n    return 0;\n  }\n  if( nExpr<3 ){\n    aWc[3] = 0;\n  }else{\n    Expr *pEscape = pExpr->x.pList->a[2].pExpr;\n    char *zEscape;\n    if( pEscape->op!=TK_STRING ) return 0;\n    zEscape = pEscape->u.zToken;\n    if( zEscape[0]==0 || zEscape[1]!=0 ) return 0;\n    aWc[3] = zEscape[0];\n  }\n\n  /* The memcpy() statement assumes that the wildcard characters are\n  ** the first three statements in the compareInfo structure.  The\n  ** asserts() that follow verify that assumption\n  */\n  memcpy(aWc, pDef->pUserData, 3);\n  assert( (char*)&likeInfoAlt == (char*)&likeInfoAlt.matchAll );\n  assert( &((char*)&likeInfoAlt)[1] == (char*)&likeInfoAlt.matchOne );\n  assert( &((char*)&likeInfoAlt)[2] == (char*)&likeInfoAlt.matchSet );\n  *pIsNocase = (pDef->funcFlags & SQLITE_FUNC_CASE)==0;\n  return 1;\n}\n\n/*\n** All of the FuncDef structures in the aBuiltinFunc[] array above\n** to the global function hash table.  This occurs at start-time (as\n** a consequence of calling sqlite3_initialize()).\n**\n** After this routine runs\n*/\nSQLITE_PRIVATE void sqlite3RegisterBuiltinFunctions(void){\n  /*\n  ** The following array holds FuncDef structures for all of the functions\n  ** defined in this file.\n  **\n  ** The array cannot be constant since changes are made to the\n  ** FuncDef.pHash elements at start-time.  The elements of this array\n  ** are read-only after initialization is complete.\n  **\n  ** For peak efficiency, put the most frequently used function last.\n  */\n  static FuncDef aBuiltinFunc[] = {\n#ifdef SQLITE_SOUNDEX\n    FUNCTION(soundex,            1, 0, 0, soundexFunc      ),\n#endif\n#ifndef SQLITE_OMIT_LOAD_EXTENSION\n    VFUNCTION(load_extension,    1, 0, 0, loadExt          ),\n    VFUNCTION(load_extension,    2, 0, 0, loadExt          ),\n#endif\n#if SQLITE_USER_AUTHENTICATION\n    FUNCTION(sqlite_crypt,       2, 0, 0, sqlite3CryptFunc ),\n#endif\n#ifndef SQLITE_OMIT_COMPILEOPTION_DIAGS\n    DFUNCTION(sqlite_compileoption_used,1, 0, 0, compileoptionusedFunc  ),\n    DFUNCTION(sqlite_compileoption_get, 1, 0, 0, compileoptiongetFunc  ),\n#endif /* SQLITE_OMIT_COMPILEOPTION_DIAGS */\n    FUNCTION2(unlikely,          1, 0, 0, noopFunc,  SQLITE_FUNC_UNLIKELY),\n    FUNCTION2(likelihood,        2, 0, 0, noopFunc,  SQLITE_FUNC_UNLIKELY),\n    FUNCTION2(likely,            1, 0, 0, noopFunc,  SQLITE_FUNC_UNLIKELY),\n#ifdef SQLITE_DEBUG\n    FUNCTION2(affinity,          1, 0, 0, noopFunc,  SQLITE_FUNC_AFFINITY),\n#endif\n#ifdef SQLITE_ENABLE_OFFSET_SQL_FUNC\n    FUNCTION2(sqlite_offset,     1, 0, 0, noopFunc,  SQLITE_FUNC_OFFSET|\n                                                     SQLITE_FUNC_TYPEOF),\n#endif\n    FUNCTION(ltrim,              1, 1, 0, trimFunc         ),\n    FUNCTION(ltrim,              2, 1, 0, trimFunc         ),\n    FUNCTION(rtrim,              1, 2, 0, trimFunc         ),\n    FUNCTION(rtrim,              2, 2, 0, trimFunc         ),\n    FUNCTION(trim,               1, 3, 0, trimFunc         ),\n    FUNCTION(trim,               2, 3, 0, trimFunc         ),\n    FUNCTION(min,               -1, 0, 1, minmaxFunc       ),\n    FUNCTION(min,                0, 0, 1, 0                ),\n    WAGGREGATE(min, 1, 0, 1, minmaxStep, minMaxFinalize, minMaxValue, 0,\n                                          SQLITE_FUNC_MINMAX ),\n    FUNCTION(max,               -1, 1, 1, minmaxFunc       ),\n    FUNCTION(max,                0, 1, 1, 0                ),\n    WAGGREGATE(max, 1, 1, 1, minmaxStep, minMaxFinalize, minMaxValue, 0,\n                                          SQLITE_FUNC_MINMAX ),\n    FUNCTION2(typeof,            1, 0, 0, typeofFunc,  SQLITE_FUNC_TYPEOF),\n    FUNCTION2(length,            1, 0, 0, lengthFunc,  SQLITE_FUNC_LENGTH),\n    FUNCTION(instr,              2, 0, 0, instrFunc        ),\n    FUNCTION(printf,            -1, 0, 0, printfFunc       ),\n    FUNCTION(unicode,            1, 0, 0, unicodeFunc      ),\n    FUNCTION(char,              -1, 0, 0, charFunc         ),\n    FUNCTION(abs,                1, 0, 0, absFunc          ),\n#ifndef SQLITE_OMIT_FLOATING_POINT\n    FUNCTION(round,              1, 0, 0, roundFunc        ),\n    FUNCTION(round,              2, 0, 0, roundFunc        ),\n#endif\n    FUNCTION(upper,              1, 0, 0, upperFunc        ),\n    FUNCTION(lower,              1, 0, 0, lowerFunc        ),\n    FUNCTION(hex,                1, 0, 0, hexFunc          ),\n    FUNCTION2(ifnull,            2, 0, 0, noopFunc,  SQLITE_FUNC_COALESCE),\n    VFUNCTION(random,            0, 0, 0, randomFunc       ),\n    VFUNCTION(randomblob,        1, 0, 0, randomBlob       ),\n    FUNCTION(nullif,             2, 0, 1, nullifFunc       ),\n    DFUNCTION(sqlite_version,    0, 0, 0, versionFunc      ),\n    DFUNCTION(sqlite_source_id,  0, 0, 0, sourceidFunc     ),\n    FUNCTION(sqlite_log,         2, 0, 0, errlogFunc       ),\n    FUNCTION(quote,              1, 0, 0, quoteFunc        ),\n    VFUNCTION(last_insert_rowid, 0, 0, 0, last_insert_rowid),\n    VFUNCTION(changes,           0, 0, 0, changes          ),\n    VFUNCTION(total_changes,     0, 0, 0, total_changes    ),\n    FUNCTION(replace,            3, 0, 0, replaceFunc      ),\n    FUNCTION(zeroblob,           1, 0, 0, zeroblobFunc     ),\n    FUNCTION(substr,             2, 0, 0, substrFunc       ),\n    FUNCTION(substr,             3, 0, 0, substrFunc       ),\n    WAGGREGATE(sum,   1,0,0, sumStep, sumFinalize, sumFinalize, sumInverse, 0),\n    WAGGREGATE(total, 1,0,0, sumStep,totalFinalize,totalFinalize,sumInverse, 0),\n    WAGGREGATE(avg,   1,0,0, sumStep, avgFinalize, avgFinalize, sumInverse, 0),\n    WAGGREGATE(count, 0,0,0, countStep, \n        countFinalize, countFinalize, countInverse, SQLITE_FUNC_COUNT  ),\n    WAGGREGATE(count, 1,0,0, countStep, \n        countFinalize, countFinalize, countInverse, 0  ),\n    WAGGREGATE(group_concat, 1, 0, 0, groupConcatStep, \n        groupConcatFinalize, groupConcatValue, groupConcatInverse, 0),\n    WAGGREGATE(group_concat, 2, 0, 0, groupConcatStep, \n        groupConcatFinalize, groupConcatValue, groupConcatInverse, 0),\n  \n    LIKEFUNC(glob, 2, &globInfo, SQLITE_FUNC_LIKE|SQLITE_FUNC_CASE),\n#ifdef SQLITE_CASE_SENSITIVE_LIKE\n    LIKEFUNC(like, 2, &likeInfoAlt, SQLITE_FUNC_LIKE|SQLITE_FUNC_CASE),\n    LIKEFUNC(like, 3, &likeInfoAlt, SQLITE_FUNC_LIKE|SQLITE_FUNC_CASE),\n#else\n    LIKEFUNC(like, 2, &likeInfoNorm, SQLITE_FUNC_LIKE),\n    LIKEFUNC(like, 3, &likeInfoNorm, SQLITE_FUNC_LIKE),\n#endif\n#ifdef SQLITE_ENABLE_UNKNOWN_SQL_FUNCTION\n    FUNCTION(unknown,           -1, 0, 0, unknownFunc      ),\n#endif\n    FUNCTION(coalesce,           1, 0, 0, 0                ),\n    FUNCTION(coalesce,           0, 0, 0, 0                ),\n    FUNCTION2(coalesce,         -1, 0, 0, noopFunc,  SQLITE_FUNC_COALESCE),\n  };\n#ifndef SQLITE_OMIT_ALTERTABLE\n  sqlite3AlterFunctions();\n#endif\n  sqlite3WindowFunctions();\n#if defined(SQLITE_ENABLE_STAT3) || defined(SQLITE_ENABLE_STAT4)\n  sqlite3AnalyzeFunctions();\n#endif\n  sqlite3RegisterDateTimeFunctions();\n  sqlite3InsertBuiltinFuncs(aBuiltinFunc, ArraySize(aBuiltinFunc));\n\n#if 0  /* Enable to print out how the built-in functions are hashed */\n  {\n    int i;\n    FuncDef *p;\n    for(i=0; i<SQLITE_FUNC_HASH_SZ; i++){\n      printf(\"FUNC-HASH %02d:\", i);\n      for(p=sqlite3BuiltinFunctions.a[i]; p; p=p->u.pHash){\n        int n = sqlite3Strlen30(p->zName);\n        int h = p->zName[0] + n;\n        printf(\" %s(%d)\", p->zName, h);\n      }\n      printf(\"\\n\");\n    }\n  }\n#endif\n}\n\n/************** End of func.c ************************************************/\n/************** Begin file fkey.c ********************************************/\n/*\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This file contains code used by the compiler to add foreign key\n** support to compiled SQL statements.\n*/\n/* #include \"sqliteInt.h\" */\n\n#ifndef SQLITE_OMIT_FOREIGN_KEY\n#ifndef SQLITE_OMIT_TRIGGER\n\n/*\n** Deferred and Immediate FKs\n** --------------------------\n**\n** Foreign keys in SQLite come in two flavours: deferred and immediate.\n** If an immediate foreign key constraint is violated,\n** SQLITE_CONSTRAINT_FOREIGNKEY is returned and the current\n** statement transaction rolled back. If a \n** deferred foreign key constraint is violated, no action is taken \n** immediately. However if the application attempts to commit the \n** transaction before fixing the constraint violation, the attempt fails.\n**\n** Deferred constraints are implemented using a simple counter associated\n** with the database handle. The counter is set to zero each time a \n** database transaction is opened. Each time a statement is executed \n** that causes a foreign key violation, the counter is incremented. Each\n** time a statement is executed that removes an existing violation from\n** the database, the counter is decremented. When the transaction is\n** committed, the commit fails if the current value of the counter is\n** greater than zero. This scheme has two big drawbacks:\n**\n**   * When a commit fails due to a deferred foreign key constraint, \n**     there is no way to tell which foreign constraint is not satisfied,\n**     or which row it is not satisfied for.\n**\n**   * If the database contains foreign key violations when the \n**     transaction is opened, this may cause the mechanism to malfunction.\n**\n** Despite these problems, this approach is adopted as it seems simpler\n** than the alternatives.\n**\n** INSERT operations:\n**\n**   I.1) For each FK for which the table is the child table, search\n**        the parent table for a match. If none is found increment the\n**        constraint counter.\n**\n**   I.2) For each FK for which the table is the parent table, \n**        search the child table for rows that correspond to the new\n**        row in the parent table. Decrement the counter for each row\n**        found (as the constraint is now satisfied).\n**\n** DELETE operations:\n**\n**   D.1) For each FK for which the table is the child table, \n**        search the parent table for a row that corresponds to the \n**        deleted row in the child table. If such a row is not found, \n**        decrement the counter.\n**\n**   D.2) For each FK for which the table is the parent table, search \n**        the child table for rows that correspond to the deleted row \n**        in the parent table. For each found increment the counter.\n**\n** UPDATE operations:\n**\n**   An UPDATE command requires that all 4 steps above are taken, but only\n**   for FK constraints for which the affected columns are actually \n**   modified (values must be compared at runtime).\n**\n** Note that I.1 and D.1 are very similar operations, as are I.2 and D.2.\n** This simplifies the implementation a bit.\n**\n** For the purposes of immediate FK constraints, the OR REPLACE conflict\n** resolution is considered to delete rows before the new row is inserted.\n** If a delete caused by OR REPLACE violates an FK constraint, an exception\n** is thrown, even if the FK constraint would be satisfied after the new \n** row is inserted.\n**\n** Immediate constraints are usually handled similarly. The only difference \n** is that the counter used is stored as part of each individual statement\n** object (struct Vdbe). If, after the statement has run, its immediate\n** constraint counter is greater than zero,\n** it returns SQLITE_CONSTRAINT_FOREIGNKEY\n** and the statement transaction is rolled back. An exception is an INSERT\n** statement that inserts a single row only (no triggers). In this case,\n** instead of using a counter, an exception is thrown immediately if the\n** INSERT violates a foreign key constraint. This is necessary as such\n** an INSERT does not open a statement transaction.\n**\n** TODO: How should dropping a table be handled? How should renaming a \n** table be handled?\n**\n**\n** Query API Notes\n** ---------------\n**\n** Before coding an UPDATE or DELETE row operation, the code-generator\n** for those two operations needs to know whether or not the operation\n** requires any FK processing and, if so, which columns of the original\n** row are required by the FK processing VDBE code (i.e. if FKs were\n** implemented using triggers, which of the old.* columns would be \n** accessed). No information is required by the code-generator before\n** coding an INSERT operation. The functions used by the UPDATE/DELETE\n** generation code to query for this information are:\n**\n**   sqlite3FkRequired() - Test to see if FK processing is required.\n**   sqlite3FkOldmask()  - Query for the set of required old.* columns.\n**\n**\n** Externally accessible module functions\n** --------------------------------------\n**\n**   sqlite3FkCheck()    - Check for foreign key violations.\n**   sqlite3FkActions()  - Code triggers for ON UPDATE/ON DELETE actions.\n**   sqlite3FkDelete()   - Delete an FKey structure.\n*/\n\n/*\n** VDBE Calling Convention\n** -----------------------\n**\n** Example:\n**\n**   For the following INSERT statement:\n**\n**     CREATE TABLE t1(a, b INTEGER PRIMARY KEY, c);\n**     INSERT INTO t1 VALUES(1, 2, 3.1);\n**\n**   Register (x):        2    (type integer)\n**   Register (x+1):      1    (type integer)\n**   Register (x+2):      NULL (type NULL)\n**   Register (x+3):      3.1  (type real)\n*/\n\n/*\n** A foreign key constraint requires that the key columns in the parent\n** table are collectively subject to a UNIQUE or PRIMARY KEY constraint.\n** Given that pParent is the parent table for foreign key constraint pFKey, \n** search the schema for a unique index on the parent key columns. \n**\n** If successful, zero is returned. If the parent key is an INTEGER PRIMARY \n** KEY column, then output variable *ppIdx is set to NULL. Otherwise, *ppIdx \n** is set to point to the unique index. \n** \n** If the parent key consists of a single column (the foreign key constraint\n** is not a composite foreign key), output variable *paiCol is set to NULL.\n** Otherwise, it is set to point to an allocated array of size N, where\n** N is the number of columns in the parent key. The first element of the\n** array is the index of the child table column that is mapped by the FK\n** constraint to the parent table column stored in the left-most column\n** of index *ppIdx. The second element of the array is the index of the\n** child table column that corresponds to the second left-most column of\n** *ppIdx, and so on.\n**\n** If the required index cannot be found, either because:\n**\n**   1) The named parent key columns do not exist, or\n**\n**   2) The named parent key columns do exist, but are not subject to a\n**      UNIQUE or PRIMARY KEY constraint, or\n**\n**   3) No parent key columns were provided explicitly as part of the\n**      foreign key definition, and the parent table does not have a\n**      PRIMARY KEY, or\n**\n**   4) No parent key columns were provided explicitly as part of the\n**      foreign key definition, and the PRIMARY KEY of the parent table \n**      consists of a different number of columns to the child key in \n**      the child table.\n**\n** then non-zero is returned, and a \"foreign key mismatch\" error loaded\n** into pParse. If an OOM error occurs, non-zero is returned and the\n** pParse->db->mallocFailed flag is set.\n*/\nSQLITE_PRIVATE int sqlite3FkLocateIndex(\n  Parse *pParse,                  /* Parse context to store any error in */\n  Table *pParent,                 /* Parent table of FK constraint pFKey */\n  FKey *pFKey,                    /* Foreign key to find index for */\n  Index **ppIdx,                  /* OUT: Unique index on parent table */\n  int **paiCol                    /* OUT: Map of index columns in pFKey */\n){\n  Index *pIdx = 0;                    /* Value to return via *ppIdx */\n  int *aiCol = 0;                     /* Value to return via *paiCol */\n  int nCol = pFKey->nCol;             /* Number of columns in parent key */\n  char *zKey = pFKey->aCol[0].zCol;   /* Name of left-most parent key column */\n\n  /* The caller is responsible for zeroing output parameters. */\n  assert( ppIdx && *ppIdx==0 );\n  assert( !paiCol || *paiCol==0 );\n  assert( pParse );\n\n  /* If this is a non-composite (single column) foreign key, check if it \n  ** maps to the INTEGER PRIMARY KEY of table pParent. If so, leave *ppIdx \n  ** and *paiCol set to zero and return early. \n  **\n  ** Otherwise, for a composite foreign key (more than one column), allocate\n  ** space for the aiCol array (returned via output parameter *paiCol).\n  ** Non-composite foreign keys do not require the aiCol array.\n  */\n  if( nCol==1 ){\n    /* The FK maps to the IPK if any of the following are true:\n    **\n    **   1) There is an INTEGER PRIMARY KEY column and the FK is implicitly \n    **      mapped to the primary key of table pParent, or\n    **   2) The FK is explicitly mapped to a column declared as INTEGER\n    **      PRIMARY KEY.\n    */\n    if( pParent->iPKey>=0 ){\n      if( !zKey ) return 0;\n      if( !sqlite3StrICmp(pParent->aCol[pParent->iPKey].zName, zKey) ) return 0;\n    }\n  }else if( paiCol ){\n    assert( nCol>1 );\n    aiCol = (int *)sqlite3DbMallocRawNN(pParse->db, nCol*sizeof(int));\n    if( !aiCol ) return 1;\n    *paiCol = aiCol;\n  }\n\n  for(pIdx=pParent->pIndex; pIdx; pIdx=pIdx->pNext){\n    if( pIdx->nKeyCol==nCol && IsUniqueIndex(pIdx) && pIdx->pPartIdxWhere==0 ){ \n      /* pIdx is a UNIQUE index (or a PRIMARY KEY) and has the right number\n      ** of columns. If each indexed column corresponds to a foreign key\n      ** column of pFKey, then this index is a winner.  */\n\n      if( zKey==0 ){\n        /* If zKey is NULL, then this foreign key is implicitly mapped to \n        ** the PRIMARY KEY of table pParent. The PRIMARY KEY index may be \n        ** identified by the test.  */\n        if( IsPrimaryKeyIndex(pIdx) ){\n          if( aiCol ){\n            int i;\n            for(i=0; i<nCol; i++) aiCol[i] = pFKey->aCol[i].iFrom;\n          }\n          break;\n        }\n      }else{\n        /* If zKey is non-NULL, then this foreign key was declared to\n        ** map to an explicit list of columns in table pParent. Check if this\n        ** index matches those columns. Also, check that the index uses\n        ** the default collation sequences for each column. */\n        int i, j;\n        for(i=0; i<nCol; i++){\n          i16 iCol = pIdx->aiColumn[i];     /* Index of column in parent tbl */\n          const char *zDfltColl;            /* Def. collation for column */\n          char *zIdxCol;                    /* Name of indexed column */\n\n          if( iCol<0 ) break; /* No foreign keys against expression indexes */\n\n          /* If the index uses a collation sequence that is different from\n          ** the default collation sequence for the column, this index is\n          ** unusable. Bail out early in this case.  */\n          zDfltColl = pParent->aCol[iCol].zColl;\n          if( !zDfltColl ) zDfltColl = sqlite3StrBINARY;\n          if( sqlite3StrICmp(pIdx->azColl[i], zDfltColl) ) break;\n\n          zIdxCol = pParent->aCol[iCol].zName;\n          for(j=0; j<nCol; j++){\n            if( sqlite3StrICmp(pFKey->aCol[j].zCol, zIdxCol)==0 ){\n              if( aiCol ) aiCol[i] = pFKey->aCol[j].iFrom;\n              break;\n            }\n          }\n          if( j==nCol ) break;\n        }\n        if( i==nCol ) break;      /* pIdx is usable */\n      }\n    }\n  }\n\n  if( !pIdx ){\n    if( !pParse->disableTriggers ){\n      sqlite3ErrorMsg(pParse,\n           \"foreign key mismatch - \\\"%w\\\" referencing \\\"%w\\\"\",\n           pFKey->pFrom->zName, pFKey->zTo);\n    }\n    sqlite3DbFree(pParse->db, aiCol);\n    return 1;\n  }\n\n  *ppIdx = pIdx;\n  return 0;\n}\n\n/*\n** This function is called when a row is inserted into or deleted from the \n** child table of foreign key constraint pFKey. If an SQL UPDATE is executed \n** on the child table of pFKey, this function is invoked twice for each row\n** affected - once to \"delete\" the old row, and then again to \"insert\" the\n** new row.\n**\n** Each time it is called, this function generates VDBE code to locate the\n** row in the parent table that corresponds to the row being inserted into \n** or deleted from the child table. If the parent row can be found, no \n** special action is taken. Otherwise, if the parent row can *not* be\n** found in the parent table:\n**\n**   Operation | FK type   | Action taken\n**   --------------------------------------------------------------------------\n**   INSERT      immediate   Increment the \"immediate constraint counter\".\n**\n**   DELETE      immediate   Decrement the \"immediate constraint counter\".\n**\n**   INSERT      deferred    Increment the \"deferred constraint counter\".\n**\n**   DELETE      deferred    Decrement the \"deferred constraint counter\".\n**\n** These operations are identified in the comment at the top of this file \n** (fkey.c) as \"I.1\" and \"D.1\".\n*/\nstatic void fkLookupParent(\n  Parse *pParse,        /* Parse context */\n  int iDb,              /* Index of database housing pTab */\n  Table *pTab,          /* Parent table of FK pFKey */\n  Index *pIdx,          /* Unique index on parent key columns in pTab */\n  FKey *pFKey,          /* Foreign key constraint */\n  int *aiCol,           /* Map from parent key columns to child table columns */\n  int regData,          /* Address of array containing child table row */\n  int nIncr,            /* Increment constraint counter by this */\n  int isIgnore          /* If true, pretend pTab contains all NULL values */\n){\n  int i;                                    /* Iterator variable */\n  Vdbe *v = sqlite3GetVdbe(pParse);         /* Vdbe to add code to */\n  int iCur = pParse->nTab - 1;              /* Cursor number to use */\n  int iOk = sqlite3VdbeMakeLabel(pParse);   /* jump here if parent key found */\n\n  sqlite3VdbeVerifyAbortable(v,\n    (!pFKey->isDeferred\n      && !(pParse->db->flags & SQLITE_DeferFKs)\n      && !pParse->pToplevel \n      && !pParse->isMultiWrite) ? OE_Abort : OE_Ignore);\n\n  /* If nIncr is less than zero, then check at runtime if there are any\n  ** outstanding constraints to resolve. If there are not, there is no need\n  ** to check if deleting this row resolves any outstanding violations.\n  **\n  ** Check if any of the key columns in the child table row are NULL. If \n  ** any are, then the constraint is considered satisfied. No need to \n  ** search for a matching row in the parent table.  */\n  if( nIncr<0 ){\n    sqlite3VdbeAddOp2(v, OP_FkIfZero, pFKey->isDeferred, iOk);\n    VdbeCoverage(v);\n  }\n  for(i=0; i<pFKey->nCol; i++){\n    int iReg = aiCol[i] + regData + 1;\n    sqlite3VdbeAddOp2(v, OP_IsNull, iReg, iOk); VdbeCoverage(v);\n  }\n\n  if( isIgnore==0 ){\n    if( pIdx==0 ){\n      /* If pIdx is NULL, then the parent key is the INTEGER PRIMARY KEY\n      ** column of the parent table (table pTab).  */\n      int iMustBeInt;               /* Address of MustBeInt instruction */\n      int regTemp = sqlite3GetTempReg(pParse);\n  \n      /* Invoke MustBeInt to coerce the child key value to an integer (i.e. \n      ** apply the affinity of the parent key). If this fails, then there\n      ** is no matching parent key. Before using MustBeInt, make a copy of\n      ** the value. Otherwise, the value inserted into the child key column\n      ** will have INTEGER affinity applied to it, which may not be correct.  */\n      sqlite3VdbeAddOp2(v, OP_SCopy, aiCol[0]+1+regData, regTemp);\n      iMustBeInt = sqlite3VdbeAddOp2(v, OP_MustBeInt, regTemp, 0);\n      VdbeCoverage(v);\n  \n      /* If the parent table is the same as the child table, and we are about\n      ** to increment the constraint-counter (i.e. this is an INSERT operation),\n      ** then check if the row being inserted matches itself. If so, do not\n      ** increment the constraint-counter.  */\n      if( pTab==pFKey->pFrom && nIncr==1 ){\n        sqlite3VdbeAddOp3(v, OP_Eq, regData, iOk, regTemp); VdbeCoverage(v);\n        sqlite3VdbeChangeP5(v, SQLITE_NOTNULL);\n      }\n  \n      sqlite3OpenTable(pParse, iCur, iDb, pTab, OP_OpenRead);\n      sqlite3VdbeAddOp3(v, OP_NotExists, iCur, 0, regTemp); VdbeCoverage(v);\n      sqlite3VdbeGoto(v, iOk);\n      sqlite3VdbeJumpHere(v, sqlite3VdbeCurrentAddr(v)-2);\n      sqlite3VdbeJumpHere(v, iMustBeInt);\n      sqlite3ReleaseTempReg(pParse, regTemp);\n    }else{\n      int nCol = pFKey->nCol;\n      int regTemp = sqlite3GetTempRange(pParse, nCol);\n      int regRec = sqlite3GetTempReg(pParse);\n  \n      sqlite3VdbeAddOp3(v, OP_OpenRead, iCur, pIdx->tnum, iDb);\n      sqlite3VdbeSetP4KeyInfo(pParse, pIdx);\n      for(i=0; i<nCol; i++){\n        sqlite3VdbeAddOp2(v, OP_Copy, aiCol[i]+1+regData, regTemp+i);\n      }\n  \n      /* If the parent table is the same as the child table, and we are about\n      ** to increment the constraint-counter (i.e. this is an INSERT operation),\n      ** then check if the row being inserted matches itself. If so, do not\n      ** increment the constraint-counter. \n      **\n      ** If any of the parent-key values are NULL, then the row cannot match \n      ** itself. So set JUMPIFNULL to make sure we do the OP_Found if any\n      ** of the parent-key values are NULL (at this point it is known that\n      ** none of the child key values are).\n      */\n      if( pTab==pFKey->pFrom && nIncr==1 ){\n        int iJump = sqlite3VdbeCurrentAddr(v) + nCol + 1;\n        for(i=0; i<nCol; i++){\n          int iChild = aiCol[i]+1+regData;\n          int iParent = pIdx->aiColumn[i]+1+regData;\n          assert( pIdx->aiColumn[i]>=0 );\n          assert( aiCol[i]!=pTab->iPKey );\n          if( pIdx->aiColumn[i]==pTab->iPKey ){\n            /* The parent key is a composite key that includes the IPK column */\n            iParent = regData;\n          }\n          sqlite3VdbeAddOp3(v, OP_Ne, iChild, iJump, iParent); VdbeCoverage(v);\n          sqlite3VdbeChangeP5(v, SQLITE_JUMPIFNULL);\n        }\n        sqlite3VdbeGoto(v, iOk);\n      }\n  \n      sqlite3VdbeAddOp4(v, OP_MakeRecord, regTemp, nCol, regRec,\n                        sqlite3IndexAffinityStr(pParse->db,pIdx), nCol);\n      sqlite3VdbeAddOp4Int(v, OP_Found, iCur, iOk, regRec, 0); VdbeCoverage(v);\n  \n      sqlite3ReleaseTempReg(pParse, regRec);\n      sqlite3ReleaseTempRange(pParse, regTemp, nCol);\n    }\n  }\n\n  if( !pFKey->isDeferred && !(pParse->db->flags & SQLITE_DeferFKs)\n   && !pParse->pToplevel \n   && !pParse->isMultiWrite \n  ){\n    /* Special case: If this is an INSERT statement that will insert exactly\n    ** one row into the table, raise a constraint immediately instead of\n    ** incrementing a counter. This is necessary as the VM code is being\n    ** generated for will not open a statement transaction.  */\n    assert( nIncr==1 );\n    sqlite3HaltConstraint(pParse, SQLITE_CONSTRAINT_FOREIGNKEY,\n        OE_Abort, 0, P4_STATIC, P5_ConstraintFK);\n  }else{\n    if( nIncr>0 && pFKey->isDeferred==0 ){\n      sqlite3MayAbort(pParse);\n    }\n    sqlite3VdbeAddOp2(v, OP_FkCounter, pFKey->isDeferred, nIncr);\n  }\n\n  sqlite3VdbeResolveLabel(v, iOk);\n  sqlite3VdbeAddOp1(v, OP_Close, iCur);\n}\n\n\n/*\n** Return an Expr object that refers to a memory register corresponding\n** to column iCol of table pTab.\n**\n** regBase is the first of an array of register that contains the data\n** for pTab.  regBase itself holds the rowid.  regBase+1 holds the first\n** column.  regBase+2 holds the second column, and so forth.\n*/\nstatic Expr *exprTableRegister(\n  Parse *pParse,     /* Parsing and code generating context */\n  Table *pTab,       /* The table whose content is at r[regBase]... */\n  int regBase,       /* Contents of table pTab */\n  i16 iCol           /* Which column of pTab is desired */\n){\n  Expr *pExpr;\n  Column *pCol;\n  const char *zColl;\n  sqlite3 *db = pParse->db;\n\n  pExpr = sqlite3Expr(db, TK_REGISTER, 0);\n  if( pExpr ){\n    if( iCol>=0 && iCol!=pTab->iPKey ){\n      pCol = &pTab->aCol[iCol];\n      pExpr->iTable = regBase + iCol + 1;\n      pExpr->affinity = pCol->affinity;\n      zColl = pCol->zColl;\n      if( zColl==0 ) zColl = db->pDfltColl->zName;\n      pExpr = sqlite3ExprAddCollateString(pParse, pExpr, zColl);\n    }else{\n      pExpr->iTable = regBase;\n      pExpr->affinity = SQLITE_AFF_INTEGER;\n    }\n  }\n  return pExpr;\n}\n\n/*\n** Return an Expr object that refers to column iCol of table pTab which\n** has cursor iCur.\n*/\nstatic Expr *exprTableColumn(\n  sqlite3 *db,      /* The database connection */\n  Table *pTab,      /* The table whose column is desired */\n  int iCursor,      /* The open cursor on the table */\n  i16 iCol          /* The column that is wanted */\n){\n  Expr *pExpr = sqlite3Expr(db, TK_COLUMN, 0);\n  if( pExpr ){\n    pExpr->y.pTab = pTab;\n    pExpr->iTable = iCursor;\n    pExpr->iColumn = iCol;\n  }\n  return pExpr;\n}\n\n/*\n** This function is called to generate code executed when a row is deleted\n** from the parent table of foreign key constraint pFKey and, if pFKey is \n** deferred, when a row is inserted into the same table. When generating\n** code for an SQL UPDATE operation, this function may be called twice -\n** once to \"delete\" the old row and once to \"insert\" the new row.\n**\n** Parameter nIncr is passed -1 when inserting a row (as this may decrease\n** the number of FK violations in the db) or +1 when deleting one (as this\n** may increase the number of FK constraint problems).\n**\n** The code generated by this function scans through the rows in the child\n** table that correspond to the parent table row being deleted or inserted.\n** For each child row found, one of the following actions is taken:\n**\n**   Operation | FK type   | Action taken\n**   --------------------------------------------------------------------------\n**   DELETE      immediate   Increment the \"immediate constraint counter\".\n**                           Or, if the ON (UPDATE|DELETE) action is RESTRICT,\n**                           throw a \"FOREIGN KEY constraint failed\" exception.\n**\n**   INSERT      immediate   Decrement the \"immediate constraint counter\".\n**\n**   DELETE      deferred    Increment the \"deferred constraint counter\".\n**                           Or, if the ON (UPDATE|DELETE) action is RESTRICT,\n**                           throw a \"FOREIGN KEY constraint failed\" exception.\n**\n**   INSERT      deferred    Decrement the \"deferred constraint counter\".\n**\n** These operations are identified in the comment at the top of this file \n** (fkey.c) as \"I.2\" and \"D.2\".\n*/\nstatic void fkScanChildren(\n  Parse *pParse,                  /* Parse context */\n  SrcList *pSrc,                  /* The child table to be scanned */\n  Table *pTab,                    /* The parent table */\n  Index *pIdx,                    /* Index on parent covering the foreign key */\n  FKey *pFKey,                    /* The foreign key linking pSrc to pTab */\n  int *aiCol,                     /* Map from pIdx cols to child table cols */\n  int regData,                    /* Parent row data starts here */\n  int nIncr                       /* Amount to increment deferred counter by */\n){\n  sqlite3 *db = pParse->db;       /* Database handle */\n  int i;                          /* Iterator variable */\n  Expr *pWhere = 0;               /* WHERE clause to scan with */\n  NameContext sNameContext;       /* Context used to resolve WHERE clause */\n  WhereInfo *pWInfo;              /* Context used by sqlite3WhereXXX() */\n  int iFkIfZero = 0;              /* Address of OP_FkIfZero */\n  Vdbe *v = sqlite3GetVdbe(pParse);\n\n  assert( pIdx==0 || pIdx->pTable==pTab );\n  assert( pIdx==0 || pIdx->nKeyCol==pFKey->nCol );\n  assert( pIdx!=0 || pFKey->nCol==1 );\n  assert( pIdx!=0 || HasRowid(pTab) );\n\n  if( nIncr<0 ){\n    iFkIfZero = sqlite3VdbeAddOp2(v, OP_FkIfZero, pFKey->isDeferred, 0);\n    VdbeCoverage(v);\n  }\n\n  /* Create an Expr object representing an SQL expression like:\n  **\n  **   <parent-key1> = <child-key1> AND <parent-key2> = <child-key2> ...\n  **\n  ** The collation sequence used for the comparison should be that of\n  ** the parent key columns. The affinity of the parent key column should\n  ** be applied to each child key value before the comparison takes place.\n  */\n  for(i=0; i<pFKey->nCol; i++){\n    Expr *pLeft;                  /* Value from parent table row */\n    Expr *pRight;                 /* Column ref to child table */\n    Expr *pEq;                    /* Expression (pLeft = pRight) */\n    i16 iCol;                     /* Index of column in child table */ \n    const char *zCol;             /* Name of column in child table */\n\n    iCol = pIdx ? pIdx->aiColumn[i] : -1;\n    pLeft = exprTableRegister(pParse, pTab, regData, iCol);\n    iCol = aiCol ? aiCol[i] : pFKey->aCol[0].iFrom;\n    assert( iCol>=0 );\n    zCol = pFKey->pFrom->aCol[iCol].zName;\n    pRight = sqlite3Expr(db, TK_ID, zCol);\n    pEq = sqlite3PExpr(pParse, TK_EQ, pLeft, pRight);\n    pWhere = sqlite3ExprAnd(db, pWhere, pEq);\n  }\n\n  /* If the child table is the same as the parent table, then add terms\n  ** to the WHERE clause that prevent this entry from being scanned.\n  ** The added WHERE clause terms are like this:\n  **\n  **     $current_rowid!=rowid\n  **     NOT( $current_a==a AND $current_b==b AND ... )\n  **\n  ** The first form is used for rowid tables.  The second form is used\n  ** for WITHOUT ROWID tables. In the second form, the *parent* key is\n  ** (a,b,...). Either the parent or primary key could be used to \n  ** uniquely identify the current row, but the parent key is more convenient\n  ** as the required values have already been loaded into registers\n  ** by the caller.\n  */\n  if( pTab==pFKey->pFrom && nIncr>0 ){\n    Expr *pNe;                    /* Expression (pLeft != pRight) */\n    Expr *pLeft;                  /* Value from parent table row */\n    Expr *pRight;                 /* Column ref to child table */\n    if( HasRowid(pTab) ){\n      pLeft = exprTableRegister(pParse, pTab, regData, -1);\n      pRight = exprTableColumn(db, pTab, pSrc->a[0].iCursor, -1);\n      pNe = sqlite3PExpr(pParse, TK_NE, pLeft, pRight);\n    }else{\n      Expr *pEq, *pAll = 0;\n      assert( pIdx!=0 );\n      for(i=0; i<pIdx->nKeyCol; i++){\n        i16 iCol = pIdx->aiColumn[i];\n        assert( iCol>=0 );\n        pLeft = exprTableRegister(pParse, pTab, regData, iCol);\n        pRight = sqlite3Expr(db, TK_ID, pTab->aCol[iCol].zName);\n        pEq = sqlite3PExpr(pParse, TK_IS, pLeft, pRight);\n        pAll = sqlite3ExprAnd(db, pAll, pEq);\n      }\n      pNe = sqlite3PExpr(pParse, TK_NOT, pAll, 0);\n    }\n    pWhere = sqlite3ExprAnd(db, pWhere, pNe);\n  }\n\n  /* Resolve the references in the WHERE clause. */\n  memset(&sNameContext, 0, sizeof(NameContext));\n  sNameContext.pSrcList = pSrc;\n  sNameContext.pParse = pParse;\n  sqlite3ResolveExprNames(&sNameContext, pWhere);\n\n  /* Create VDBE to loop through the entries in pSrc that match the WHERE\n  ** clause. For each row found, increment either the deferred or immediate\n  ** foreign key constraint counter. */\n  if( pParse->nErr==0 ){\n    pWInfo = sqlite3WhereBegin(pParse, pSrc, pWhere, 0, 0, 0, 0);\n    sqlite3VdbeAddOp2(v, OP_FkCounter, pFKey->isDeferred, nIncr);\n    if( pWInfo ){\n      sqlite3WhereEnd(pWInfo);\n    }\n  }\n\n  /* Clean up the WHERE clause constructed above. */\n  sqlite3ExprDelete(db, pWhere);\n  if( iFkIfZero ){\n    sqlite3VdbeJumpHere(v, iFkIfZero);\n  }\n}\n\n/*\n** This function returns a linked list of FKey objects (connected by\n** FKey.pNextTo) holding all children of table pTab.  For example,\n** given the following schema:\n**\n**   CREATE TABLE t1(a PRIMARY KEY);\n**   CREATE TABLE t2(b REFERENCES t1(a);\n**\n** Calling this function with table \"t1\" as an argument returns a pointer\n** to the FKey structure representing the foreign key constraint on table\n** \"t2\". Calling this function with \"t2\" as the argument would return a\n** NULL pointer (as there are no FK constraints for which t2 is the parent\n** table).\n*/\nSQLITE_PRIVATE FKey *sqlite3FkReferences(Table *pTab){\n  return (FKey *)sqlite3HashFind(&pTab->pSchema->fkeyHash, pTab->zName);\n}\n\n/*\n** The second argument is a Trigger structure allocated by the \n** fkActionTrigger() routine. This function deletes the Trigger structure\n** and all of its sub-components.\n**\n** The Trigger structure or any of its sub-components may be allocated from\n** the lookaside buffer belonging to database handle dbMem.\n*/\nstatic void fkTriggerDelete(sqlite3 *dbMem, Trigger *p){\n  if( p ){\n    TriggerStep *pStep = p->step_list;\n    sqlite3ExprDelete(dbMem, pStep->pWhere);\n    sqlite3ExprListDelete(dbMem, pStep->pExprList);\n    sqlite3SelectDelete(dbMem, pStep->pSelect);\n    sqlite3ExprDelete(dbMem, p->pWhen);\n    sqlite3DbFree(dbMem, p);\n  }\n}\n\n/*\n** This function is called to generate code that runs when table pTab is\n** being dropped from the database. The SrcList passed as the second argument\n** to this function contains a single entry guaranteed to resolve to\n** table pTab.\n**\n** Normally, no code is required. However, if either\n**\n**   (a) The table is the parent table of a FK constraint, or\n**   (b) The table is the child table of a deferred FK constraint and it is\n**       determined at runtime that there are outstanding deferred FK \n**       constraint violations in the database,\n**\n** then the equivalent of \"DELETE FROM <tbl>\" is executed before dropping\n** the table from the database. Triggers are disabled while running this\n** DELETE, but foreign key actions are not.\n*/\nSQLITE_PRIVATE void sqlite3FkDropTable(Parse *pParse, SrcList *pName, Table *pTab){\n  sqlite3 *db = pParse->db;\n  if( (db->flags&SQLITE_ForeignKeys) && !IsVirtual(pTab) ){\n    int iSkip = 0;\n    Vdbe *v = sqlite3GetVdbe(pParse);\n\n    assert( v );                  /* VDBE has already been allocated */\n    assert( pTab->pSelect==0 );   /* Not a view */\n    if( sqlite3FkReferences(pTab)==0 ){\n      /* Search for a deferred foreign key constraint for which this table\n      ** is the child table. If one cannot be found, return without \n      ** generating any VDBE code. If one can be found, then jump over\n      ** the entire DELETE if there are no outstanding deferred constraints\n      ** when this statement is run.  */\n      FKey *p;\n      for(p=pTab->pFKey; p; p=p->pNextFrom){\n        if( p->isDeferred || (db->flags & SQLITE_DeferFKs) ) break;\n      }\n      if( !p ) return;\n      iSkip = sqlite3VdbeMakeLabel(pParse);\n      sqlite3VdbeAddOp2(v, OP_FkIfZero, 1, iSkip); VdbeCoverage(v);\n    }\n\n    pParse->disableTriggers = 1;\n    sqlite3DeleteFrom(pParse, sqlite3SrcListDup(db, pName, 0), 0, 0, 0);\n    pParse->disableTriggers = 0;\n\n    /* If the DELETE has generated immediate foreign key constraint \n    ** violations, halt the VDBE and return an error at this point, before\n    ** any modifications to the schema are made. This is because statement\n    ** transactions are not able to rollback schema changes.  \n    **\n    ** If the SQLITE_DeferFKs flag is set, then this is not required, as\n    ** the statement transaction will not be rolled back even if FK\n    ** constraints are violated.\n    */\n    if( (db->flags & SQLITE_DeferFKs)==0 ){\n      sqlite3VdbeVerifyAbortable(v, OE_Abort);\n      sqlite3VdbeAddOp2(v, OP_FkIfZero, 0, sqlite3VdbeCurrentAddr(v)+2);\n      VdbeCoverage(v);\n      sqlite3HaltConstraint(pParse, SQLITE_CONSTRAINT_FOREIGNKEY,\n          OE_Abort, 0, P4_STATIC, P5_ConstraintFK);\n    }\n\n    if( iSkip ){\n      sqlite3VdbeResolveLabel(v, iSkip);\n    }\n  }\n}\n\n\n/*\n** The second argument points to an FKey object representing a foreign key\n** for which pTab is the child table. An UPDATE statement against pTab\n** is currently being processed. For each column of the table that is \n** actually updated, the corresponding element in the aChange[] array\n** is zero or greater (if a column is unmodified the corresponding element\n** is set to -1). If the rowid column is modified by the UPDATE statement\n** the bChngRowid argument is non-zero.\n**\n** This function returns true if any of the columns that are part of the\n** child key for FK constraint *p are modified.\n*/\nstatic int fkChildIsModified(\n  Table *pTab,                    /* Table being updated */\n  FKey *p,                        /* Foreign key for which pTab is the child */\n  int *aChange,                   /* Array indicating modified columns */\n  int bChngRowid                  /* True if rowid is modified by this update */\n){\n  int i;\n  for(i=0; i<p->nCol; i++){\n    int iChildKey = p->aCol[i].iFrom;\n    if( aChange[iChildKey]>=0 ) return 1;\n    if( iChildKey==pTab->iPKey && bChngRowid ) return 1;\n  }\n  return 0;\n}\n\n/*\n** The second argument points to an FKey object representing a foreign key\n** for which pTab is the parent table. An UPDATE statement against pTab\n** is currently being processed. For each column of the table that is \n** actually updated, the corresponding element in the aChange[] array\n** is zero or greater (if a column is unmodified the corresponding element\n** is set to -1). If the rowid column is modified by the UPDATE statement\n** the bChngRowid argument is non-zero.\n**\n** This function returns true if any of the columns that are part of the\n** parent key for FK constraint *p are modified.\n*/\nstatic int fkParentIsModified(\n  Table *pTab, \n  FKey *p, \n  int *aChange, \n  int bChngRowid\n){\n  int i;\n  for(i=0; i<p->nCol; i++){\n    char *zKey = p->aCol[i].zCol;\n    int iKey;\n    for(iKey=0; iKey<pTab->nCol; iKey++){\n      if( aChange[iKey]>=0 || (iKey==pTab->iPKey && bChngRowid) ){\n        Column *pCol = &pTab->aCol[iKey];\n        if( zKey ){\n          if( 0==sqlite3StrICmp(pCol->zName, zKey) ) return 1;\n        }else if( pCol->colFlags & COLFLAG_PRIMKEY ){\n          return 1;\n        }\n      }\n    }\n  }\n  return 0;\n}\n\n/*\n** Return true if the parser passed as the first argument is being\n** used to code a trigger that is really a \"SET NULL\" action belonging\n** to trigger pFKey.\n*/\nstatic int isSetNullAction(Parse *pParse, FKey *pFKey){\n  Parse *pTop = sqlite3ParseToplevel(pParse);\n  if( pTop->pTriggerPrg ){\n    Trigger *p = pTop->pTriggerPrg->pTrigger;\n    if( (p==pFKey->apTrigger[0] && pFKey->aAction[0]==OE_SetNull)\n     || (p==pFKey->apTrigger[1] && pFKey->aAction[1]==OE_SetNull)\n    ){\n      return 1;\n    }\n  }\n  return 0;\n}\n\n/*\n** This function is called when inserting, deleting or updating a row of\n** table pTab to generate VDBE code to perform foreign key constraint \n** processing for the operation.\n**\n** For a DELETE operation, parameter regOld is passed the index of the\n** first register in an array of (pTab->nCol+1) registers containing the\n** rowid of the row being deleted, followed by each of the column values\n** of the row being deleted, from left to right. Parameter regNew is passed\n** zero in this case.\n**\n** For an INSERT operation, regOld is passed zero and regNew is passed the\n** first register of an array of (pTab->nCol+1) registers containing the new\n** row data.\n**\n** For an UPDATE operation, this function is called twice. Once before\n** the original record is deleted from the table using the calling convention\n** described for DELETE. Then again after the original record is deleted\n** but before the new record is inserted using the INSERT convention. \n*/\nSQLITE_PRIVATE void sqlite3FkCheck(\n  Parse *pParse,                  /* Parse context */\n  Table *pTab,                    /* Row is being deleted from this table */ \n  int regOld,                     /* Previous row data is stored here */\n  int regNew,                     /* New row data is stored here */\n  int *aChange,                   /* Array indicating UPDATEd columns (or 0) */\n  int bChngRowid                  /* True if rowid is UPDATEd */\n){\n  sqlite3 *db = pParse->db;       /* Database handle */\n  FKey *pFKey;                    /* Used to iterate through FKs */\n  int iDb;                        /* Index of database containing pTab */\n  const char *zDb;                /* Name of database containing pTab */\n  int isIgnoreErrors = pParse->disableTriggers;\n\n  /* Exactly one of regOld and regNew should be non-zero. */\n  assert( (regOld==0)!=(regNew==0) );\n\n  /* If foreign-keys are disabled, this function is a no-op. */\n  if( (db->flags&SQLITE_ForeignKeys)==0 ) return;\n\n  iDb = sqlite3SchemaToIndex(db, pTab->pSchema);\n  zDb = db->aDb[iDb].zDbSName;\n\n  /* Loop through all the foreign key constraints for which pTab is the\n  ** child table (the table that the foreign key definition is part of).  */\n  for(pFKey=pTab->pFKey; pFKey; pFKey=pFKey->pNextFrom){\n    Table *pTo;                   /* Parent table of foreign key pFKey */\n    Index *pIdx = 0;              /* Index on key columns in pTo */\n    int *aiFree = 0;\n    int *aiCol;\n    int iCol;\n    int i;\n    int bIgnore = 0;\n\n    if( aChange \n     && sqlite3_stricmp(pTab->zName, pFKey->zTo)!=0\n     && fkChildIsModified(pTab, pFKey, aChange, bChngRowid)==0 \n    ){\n      continue;\n    }\n\n    /* Find the parent table of this foreign key. Also find a unique index \n    ** on the parent key columns in the parent table. If either of these \n    ** schema items cannot be located, set an error in pParse and return \n    ** early.  */\n    if( pParse->disableTriggers ){\n      pTo = sqlite3FindTable(db, pFKey->zTo, zDb);\n    }else{\n      pTo = sqlite3LocateTable(pParse, 0, pFKey->zTo, zDb);\n    }\n    if( !pTo || sqlite3FkLocateIndex(pParse, pTo, pFKey, &pIdx, &aiFree) ){\n      assert( isIgnoreErrors==0 || (regOld!=0 && regNew==0) );\n      if( !isIgnoreErrors || db->mallocFailed ) return;\n      if( pTo==0 ){\n        /* If isIgnoreErrors is true, then a table is being dropped. In this\n        ** case SQLite runs a \"DELETE FROM xxx\" on the table being dropped\n        ** before actually dropping it in order to check FK constraints.\n        ** If the parent table of an FK constraint on the current table is\n        ** missing, behave as if it is empty. i.e. decrement the relevant\n        ** FK counter for each row of the current table with non-NULL keys.\n        */\n        Vdbe *v = sqlite3GetVdbe(pParse);\n        int iJump = sqlite3VdbeCurrentAddr(v) + pFKey->nCol + 1;\n        for(i=0; i<pFKey->nCol; i++){\n          int iReg = pFKey->aCol[i].iFrom + regOld + 1;\n          sqlite3VdbeAddOp2(v, OP_IsNull, iReg, iJump); VdbeCoverage(v);\n        }\n        sqlite3VdbeAddOp2(v, OP_FkCounter, pFKey->isDeferred, -1);\n      }\n      continue;\n    }\n    assert( pFKey->nCol==1 || (aiFree && pIdx) );\n\n    if( aiFree ){\n      aiCol = aiFree;\n    }else{\n      iCol = pFKey->aCol[0].iFrom;\n      aiCol = &iCol;\n    }\n    for(i=0; i<pFKey->nCol; i++){\n      if( aiCol[i]==pTab->iPKey ){\n        aiCol[i] = -1;\n      }\n      assert( pIdx==0 || pIdx->aiColumn[i]>=0 );\n#ifndef SQLITE_OMIT_AUTHORIZATION\n      /* Request permission to read the parent key columns. If the \n      ** authorization callback returns SQLITE_IGNORE, behave as if any\n      ** values read from the parent table are NULL. */\n      if( db->xAuth ){\n        int rcauth;\n        char *zCol = pTo->aCol[pIdx ? pIdx->aiColumn[i] : pTo->iPKey].zName;\n        rcauth = sqlite3AuthReadCol(pParse, pTo->zName, zCol, iDb);\n        bIgnore = (rcauth==SQLITE_IGNORE);\n      }\n#endif\n    }\n\n    /* Take a shared-cache advisory read-lock on the parent table. Allocate \n    ** a cursor to use to search the unique index on the parent key columns \n    ** in the parent table.  */\n    sqlite3TableLock(pParse, iDb, pTo->tnum, 0, pTo->zName);\n    pParse->nTab++;\n\n    if( regOld!=0 ){\n      /* A row is being removed from the child table. Search for the parent.\n      ** If the parent does not exist, removing the child row resolves an \n      ** outstanding foreign key constraint violation. */\n      fkLookupParent(pParse, iDb, pTo, pIdx, pFKey, aiCol, regOld, -1, bIgnore);\n    }\n    if( regNew!=0 && !isSetNullAction(pParse, pFKey) ){\n      /* A row is being added to the child table. If a parent row cannot\n      ** be found, adding the child row has violated the FK constraint. \n      **\n      ** If this operation is being performed as part of a trigger program\n      ** that is actually a \"SET NULL\" action belonging to this very \n      ** foreign key, then omit this scan altogether. As all child key\n      ** values are guaranteed to be NULL, it is not possible for adding\n      ** this row to cause an FK violation.  */\n      fkLookupParent(pParse, iDb, pTo, pIdx, pFKey, aiCol, regNew, +1, bIgnore);\n    }\n\n    sqlite3DbFree(db, aiFree);\n  }\n\n  /* Loop through all the foreign key constraints that refer to this table.\n  ** (the \"child\" constraints) */\n  for(pFKey = sqlite3FkReferences(pTab); pFKey; pFKey=pFKey->pNextTo){\n    Index *pIdx = 0;              /* Foreign key index for pFKey */\n    SrcList *pSrc;\n    int *aiCol = 0;\n\n    if( aChange && fkParentIsModified(pTab, pFKey, aChange, bChngRowid)==0 ){\n      continue;\n    }\n\n    if( !pFKey->isDeferred && !(db->flags & SQLITE_DeferFKs) \n     && !pParse->pToplevel && !pParse->isMultiWrite \n    ){\n      assert( regOld==0 && regNew!=0 );\n      /* Inserting a single row into a parent table cannot cause (or fix)\n      ** an immediate foreign key violation. So do nothing in this case.  */\n      continue;\n    }\n\n    if( sqlite3FkLocateIndex(pParse, pTab, pFKey, &pIdx, &aiCol) ){\n      if( !isIgnoreErrors || db->mallocFailed ) return;\n      continue;\n    }\n    assert( aiCol || pFKey->nCol==1 );\n\n    /* Create a SrcList structure containing the child table.  We need the\n    ** child table as a SrcList for sqlite3WhereBegin() */\n    pSrc = sqlite3SrcListAppend(pParse, 0, 0, 0);\n    if( pSrc ){\n      struct SrcList_item *pItem = pSrc->a;\n      pItem->pTab = pFKey->pFrom;\n      pItem->zName = pFKey->pFrom->zName;\n      pItem->pTab->nTabRef++;\n      pItem->iCursor = pParse->nTab++;\n  \n      if( regNew!=0 ){\n        fkScanChildren(pParse, pSrc, pTab, pIdx, pFKey, aiCol, regNew, -1);\n      }\n      if( regOld!=0 ){\n        int eAction = pFKey->aAction[aChange!=0];\n        fkScanChildren(pParse, pSrc, pTab, pIdx, pFKey, aiCol, regOld, 1);\n        /* If this is a deferred FK constraint, or a CASCADE or SET NULL\n        ** action applies, then any foreign key violations caused by\n        ** removing the parent key will be rectified by the action trigger.\n        ** So do not set the \"may-abort\" flag in this case.\n        **\n        ** Note 1: If the FK is declared \"ON UPDATE CASCADE\", then the\n        ** may-abort flag will eventually be set on this statement anyway\n        ** (when this function is called as part of processing the UPDATE\n        ** within the action trigger).\n        **\n        ** Note 2: At first glance it may seem like SQLite could simply omit\n        ** all OP_FkCounter related scans when either CASCADE or SET NULL\n        ** applies. The trouble starts if the CASCADE or SET NULL action \n        ** trigger causes other triggers or action rules attached to the \n        ** child table to fire. In these cases the fk constraint counters\n        ** might be set incorrectly if any OP_FkCounter related scans are \n        ** omitted.  */\n        if( !pFKey->isDeferred && eAction!=OE_Cascade && eAction!=OE_SetNull ){\n          sqlite3MayAbort(pParse);\n        }\n      }\n      pItem->zName = 0;\n      sqlite3SrcListDelete(db, pSrc);\n    }\n    sqlite3DbFree(db, aiCol);\n  }\n}\n\n#define COLUMN_MASK(x) (((x)>31) ? 0xffffffff : ((u32)1<<(x)))\n\n/*\n** This function is called before generating code to update or delete a \n** row contained in table pTab.\n*/\nSQLITE_PRIVATE u32 sqlite3FkOldmask(\n  Parse *pParse,                  /* Parse context */\n  Table *pTab                     /* Table being modified */\n){\n  u32 mask = 0;\n  if( pParse->db->flags&SQLITE_ForeignKeys ){\n    FKey *p;\n    int i;\n    for(p=pTab->pFKey; p; p=p->pNextFrom){\n      for(i=0; i<p->nCol; i++) mask |= COLUMN_MASK(p->aCol[i].iFrom);\n    }\n    for(p=sqlite3FkReferences(pTab); p; p=p->pNextTo){\n      Index *pIdx = 0;\n      sqlite3FkLocateIndex(pParse, pTab, p, &pIdx, 0);\n      if( pIdx ){\n        for(i=0; i<pIdx->nKeyCol; i++){\n          assert( pIdx->aiColumn[i]>=0 );\n          mask |= COLUMN_MASK(pIdx->aiColumn[i]);\n        }\n      }\n    }\n  }\n  return mask;\n}\n\n\n/*\n** This function is called before generating code to update or delete a \n** row contained in table pTab. If the operation is a DELETE, then\n** parameter aChange is passed a NULL value. For an UPDATE, aChange points\n** to an array of size N, where N is the number of columns in table pTab.\n** If the i'th column is not modified by the UPDATE, then the corresponding \n** entry in the aChange[] array is set to -1. If the column is modified,\n** the value is 0 or greater. Parameter chngRowid is set to true if the\n** UPDATE statement modifies the rowid fields of the table.\n**\n** If any foreign key processing will be required, this function returns\n** non-zero. If there is no foreign key related processing, this function \n** returns zero.\n**\n** For an UPDATE, this function returns 2 if:\n**\n**   * There are any FKs for which pTab is the child and the parent table, or\n**   * the UPDATE modifies one or more parent keys for which the action is\n**     not \"NO ACTION\" (i.e. is CASCADE, SET DEFAULT or SET NULL).\n**\n** Or, assuming some other foreign key processing is required, 1.\n*/\nSQLITE_PRIVATE int sqlite3FkRequired(\n  Parse *pParse,                  /* Parse context */\n  Table *pTab,                    /* Table being modified */\n  int *aChange,                   /* Non-NULL for UPDATE operations */\n  int chngRowid                   /* True for UPDATE that affects rowid */\n){\n  int eRet = 0;\n  if( pParse->db->flags&SQLITE_ForeignKeys ){\n    if( !aChange ){\n      /* A DELETE operation. Foreign key processing is required if the \n      ** table in question is either the child or parent table for any \n      ** foreign key constraint.  */\n      eRet = (sqlite3FkReferences(pTab) || pTab->pFKey);\n    }else{\n      /* This is an UPDATE. Foreign key processing is only required if the\n      ** operation modifies one or more child or parent key columns. */\n      FKey *p;\n\n      /* Check if any child key columns are being modified. */\n      for(p=pTab->pFKey; p; p=p->pNextFrom){\n        if( 0==sqlite3_stricmp(pTab->zName, p->zTo) ) return 2;\n        if( fkChildIsModified(pTab, p, aChange, chngRowid) ){\n          eRet = 1;\n        }\n      }\n\n      /* Check if any parent key columns are being modified. */\n      for(p=sqlite3FkReferences(pTab); p; p=p->pNextTo){\n        if( fkParentIsModified(pTab, p, aChange, chngRowid) ){\n          if( p->aAction[1]!=OE_None ) return 2;\n          eRet = 1;\n        }\n      }\n    }\n  }\n  return eRet;\n}\n\n/*\n** This function is called when an UPDATE or DELETE operation is being \n** compiled on table pTab, which is the parent table of foreign-key pFKey.\n** If the current operation is an UPDATE, then the pChanges parameter is\n** passed a pointer to the list of columns being modified. If it is a\n** DELETE, pChanges is passed a NULL pointer.\n**\n** It returns a pointer to a Trigger structure containing a trigger\n** equivalent to the ON UPDATE or ON DELETE action specified by pFKey.\n** If the action is \"NO ACTION\" or \"RESTRICT\", then a NULL pointer is\n** returned (these actions require no special handling by the triggers\n** sub-system, code for them is created by fkScanChildren()).\n**\n** For example, if pFKey is the foreign key and pTab is table \"p\" in \n** the following schema:\n**\n**   CREATE TABLE p(pk PRIMARY KEY);\n**   CREATE TABLE c(ck REFERENCES p ON DELETE CASCADE);\n**\n** then the returned trigger structure is equivalent to:\n**\n**   CREATE TRIGGER ... DELETE ON p BEGIN\n**     DELETE FROM c WHERE ck = old.pk;\n**   END;\n**\n** The returned pointer is cached as part of the foreign key object. It\n** is eventually freed along with the rest of the foreign key object by \n** sqlite3FkDelete().\n*/\nstatic Trigger *fkActionTrigger(\n  Parse *pParse,                  /* Parse context */\n  Table *pTab,                    /* Table being updated or deleted from */\n  FKey *pFKey,                    /* Foreign key to get action for */\n  ExprList *pChanges              /* Change-list for UPDATE, NULL for DELETE */\n){\n  sqlite3 *db = pParse->db;       /* Database handle */\n  int action;                     /* One of OE_None, OE_Cascade etc. */\n  Trigger *pTrigger;              /* Trigger definition to return */\n  int iAction = (pChanges!=0);    /* 1 for UPDATE, 0 for DELETE */\n\n  action = pFKey->aAction[iAction];\n  if( action==OE_Restrict && (db->flags & SQLITE_DeferFKs) ){\n    return 0;\n  }\n  pTrigger = pFKey->apTrigger[iAction];\n\n  if( action!=OE_None && !pTrigger ){\n    char const *zFrom;            /* Name of child table */\n    int nFrom;                    /* Length in bytes of zFrom */\n    Index *pIdx = 0;              /* Parent key index for this FK */\n    int *aiCol = 0;               /* child table cols -> parent key cols */\n    TriggerStep *pStep = 0;        /* First (only) step of trigger program */\n    Expr *pWhere = 0;             /* WHERE clause of trigger step */\n    ExprList *pList = 0;          /* Changes list if ON UPDATE CASCADE */\n    Select *pSelect = 0;          /* If RESTRICT, \"SELECT RAISE(...)\" */\n    int i;                        /* Iterator variable */\n    Expr *pWhen = 0;              /* WHEN clause for the trigger */\n\n    if( sqlite3FkLocateIndex(pParse, pTab, pFKey, &pIdx, &aiCol) ) return 0;\n    assert( aiCol || pFKey->nCol==1 );\n\n    for(i=0; i<pFKey->nCol; i++){\n      Token tOld = { \"old\", 3 };  /* Literal \"old\" token */\n      Token tNew = { \"new\", 3 };  /* Literal \"new\" token */\n      Token tFromCol;             /* Name of column in child table */\n      Token tToCol;               /* Name of column in parent table */\n      int iFromCol;               /* Idx of column in child table */\n      Expr *pEq;                  /* tFromCol = OLD.tToCol */\n\n      iFromCol = aiCol ? aiCol[i] : pFKey->aCol[0].iFrom;\n      assert( iFromCol>=0 );\n      assert( pIdx!=0 || (pTab->iPKey>=0 && pTab->iPKey<pTab->nCol) );\n      assert( pIdx==0 || pIdx->aiColumn[i]>=0 );\n      sqlite3TokenInit(&tToCol,\n                   pTab->aCol[pIdx ? pIdx->aiColumn[i] : pTab->iPKey].zName);\n      sqlite3TokenInit(&tFromCol, pFKey->pFrom->aCol[iFromCol].zName);\n\n      /* Create the expression \"OLD.zToCol = zFromCol\". It is important\n      ** that the \"OLD.zToCol\" term is on the LHS of the = operator, so\n      ** that the affinity and collation sequence associated with the\n      ** parent table are used for the comparison. */\n      pEq = sqlite3PExpr(pParse, TK_EQ,\n          sqlite3PExpr(pParse, TK_DOT, \n            sqlite3ExprAlloc(db, TK_ID, &tOld, 0),\n            sqlite3ExprAlloc(db, TK_ID, &tToCol, 0)),\n          sqlite3ExprAlloc(db, TK_ID, &tFromCol, 0)\n      );\n      pWhere = sqlite3ExprAnd(db, pWhere, pEq);\n\n      /* For ON UPDATE, construct the next term of the WHEN clause.\n      ** The final WHEN clause will be like this:\n      **\n      **    WHEN NOT(old.col1 IS new.col1 AND ... AND old.colN IS new.colN)\n      */\n      if( pChanges ){\n        pEq = sqlite3PExpr(pParse, TK_IS,\n            sqlite3PExpr(pParse, TK_DOT, \n              sqlite3ExprAlloc(db, TK_ID, &tOld, 0),\n              sqlite3ExprAlloc(db, TK_ID, &tToCol, 0)),\n            sqlite3PExpr(pParse, TK_DOT, \n              sqlite3ExprAlloc(db, TK_ID, &tNew, 0),\n              sqlite3ExprAlloc(db, TK_ID, &tToCol, 0))\n            );\n        pWhen = sqlite3ExprAnd(db, pWhen, pEq);\n      }\n  \n      if( action!=OE_Restrict && (action!=OE_Cascade || pChanges) ){\n        Expr *pNew;\n        if( action==OE_Cascade ){\n          pNew = sqlite3PExpr(pParse, TK_DOT, \n            sqlite3ExprAlloc(db, TK_ID, &tNew, 0),\n            sqlite3ExprAlloc(db, TK_ID, &tToCol, 0));\n        }else if( action==OE_SetDflt ){\n          Expr *pDflt = pFKey->pFrom->aCol[iFromCol].pDflt;\n          if( pDflt ){\n            pNew = sqlite3ExprDup(db, pDflt, 0);\n          }else{\n            pNew = sqlite3ExprAlloc(db, TK_NULL, 0, 0);\n          }\n        }else{\n          pNew = sqlite3ExprAlloc(db, TK_NULL, 0, 0);\n        }\n        pList = sqlite3ExprListAppend(pParse, pList, pNew);\n        sqlite3ExprListSetName(pParse, pList, &tFromCol, 0);\n      }\n    }\n    sqlite3DbFree(db, aiCol);\n\n    zFrom = pFKey->pFrom->zName;\n    nFrom = sqlite3Strlen30(zFrom);\n\n    if( action==OE_Restrict ){\n      Token tFrom;\n      Expr *pRaise; \n\n      tFrom.z = zFrom;\n      tFrom.n = nFrom;\n      pRaise = sqlite3Expr(db, TK_RAISE, \"FOREIGN KEY constraint failed\");\n      if( pRaise ){\n        pRaise->affinity = OE_Abort;\n      }\n      pSelect = sqlite3SelectNew(pParse, \n          sqlite3ExprListAppend(pParse, 0, pRaise),\n          sqlite3SrcListAppend(pParse, 0, &tFrom, 0),\n          pWhere,\n          0, 0, 0, 0, 0\n      );\n      pWhere = 0;\n    }\n\n    /* Disable lookaside memory allocation */\n    db->lookaside.bDisable++;\n\n    pTrigger = (Trigger *)sqlite3DbMallocZero(db, \n        sizeof(Trigger) +         /* struct Trigger */\n        sizeof(TriggerStep) +     /* Single step in trigger program */\n        nFrom + 1                 /* Space for pStep->zTarget */\n    );\n    if( pTrigger ){\n      pStep = pTrigger->step_list = (TriggerStep *)&pTrigger[1];\n      pStep->zTarget = (char *)&pStep[1];\n      memcpy((char *)pStep->zTarget, zFrom, nFrom);\n  \n      pStep->pWhere = sqlite3ExprDup(db, pWhere, EXPRDUP_REDUCE);\n      pStep->pExprList = sqlite3ExprListDup(db, pList, EXPRDUP_REDUCE);\n      pStep->pSelect = sqlite3SelectDup(db, pSelect, EXPRDUP_REDUCE);\n      if( pWhen ){\n        pWhen = sqlite3PExpr(pParse, TK_NOT, pWhen, 0);\n        pTrigger->pWhen = sqlite3ExprDup(db, pWhen, EXPRDUP_REDUCE);\n      }\n    }\n\n    /* Re-enable the lookaside buffer, if it was disabled earlier. */\n    db->lookaside.bDisable--;\n\n    sqlite3ExprDelete(db, pWhere);\n    sqlite3ExprDelete(db, pWhen);\n    sqlite3ExprListDelete(db, pList);\n    sqlite3SelectDelete(db, pSelect);\n    if( db->mallocFailed==1 ){\n      fkTriggerDelete(db, pTrigger);\n      return 0;\n    }\n    assert( pStep!=0 );\n\n    switch( action ){\n      case OE_Restrict:\n        pStep->op = TK_SELECT; \n        break;\n      case OE_Cascade: \n        if( !pChanges ){ \n          pStep->op = TK_DELETE; \n          break; \n        }\n      default:\n        pStep->op = TK_UPDATE;\n    }\n    pStep->pTrig = pTrigger;\n    pTrigger->pSchema = pTab->pSchema;\n    pTrigger->pTabSchema = pTab->pSchema;\n    pFKey->apTrigger[iAction] = pTrigger;\n    pTrigger->op = (pChanges ? TK_UPDATE : TK_DELETE);\n  }\n\n  return pTrigger;\n}\n\n/*\n** This function is called when deleting or updating a row to implement\n** any required CASCADE, SET NULL or SET DEFAULT actions.\n*/\nSQLITE_PRIVATE void sqlite3FkActions(\n  Parse *pParse,                  /* Parse context */\n  Table *pTab,                    /* Table being updated or deleted from */\n  ExprList *pChanges,             /* Change-list for UPDATE, NULL for DELETE */\n  int regOld,                     /* Address of array containing old row */\n  int *aChange,                   /* Array indicating UPDATEd columns (or 0) */\n  int bChngRowid                  /* True if rowid is UPDATEd */\n){\n  /* If foreign-key support is enabled, iterate through all FKs that \n  ** refer to table pTab. If there is an action associated with the FK \n  ** for this operation (either update or delete), invoke the associated \n  ** trigger sub-program.  */\n  if( pParse->db->flags&SQLITE_ForeignKeys ){\n    FKey *pFKey;                  /* Iterator variable */\n    for(pFKey = sqlite3FkReferences(pTab); pFKey; pFKey=pFKey->pNextTo){\n      if( aChange==0 || fkParentIsModified(pTab, pFKey, aChange, bChngRowid) ){\n        Trigger *pAct = fkActionTrigger(pParse, pTab, pFKey, pChanges);\n        if( pAct ){\n          sqlite3CodeRowTriggerDirect(pParse, pAct, pTab, regOld, OE_Abort, 0);\n        }\n      }\n    }\n  }\n}\n\n#endif /* ifndef SQLITE_OMIT_TRIGGER */\n\n/*\n** Free all memory associated with foreign key definitions attached to\n** table pTab. Remove the deleted foreign keys from the Schema.fkeyHash\n** hash table.\n*/\nSQLITE_PRIVATE void sqlite3FkDelete(sqlite3 *db, Table *pTab){\n  FKey *pFKey;                    /* Iterator variable */\n  FKey *pNext;                    /* Copy of pFKey->pNextFrom */\n\n  assert( db==0 || IsVirtual(pTab)\n         || sqlite3SchemaMutexHeld(db, 0, pTab->pSchema) );\n  for(pFKey=pTab->pFKey; pFKey; pFKey=pNext){\n\n    /* Remove the FK from the fkeyHash hash table. */\n    if( !db || db->pnBytesFreed==0 ){\n      if( pFKey->pPrevTo ){\n        pFKey->pPrevTo->pNextTo = pFKey->pNextTo;\n      }else{\n        void *p = (void *)pFKey->pNextTo;\n        const char *z = (p ? pFKey->pNextTo->zTo : pFKey->zTo);\n        sqlite3HashInsert(&pTab->pSchema->fkeyHash, z, p);\n      }\n      if( pFKey->pNextTo ){\n        pFKey->pNextTo->pPrevTo = pFKey->pPrevTo;\n      }\n    }\n\n    /* EV: R-30323-21917 Each foreign key constraint in SQLite is\n    ** classified as either immediate or deferred.\n    */\n    assert( pFKey->isDeferred==0 || pFKey->isDeferred==1 );\n\n    /* Delete any triggers created to implement actions for this FK. */\n#ifndef SQLITE_OMIT_TRIGGER\n    fkTriggerDelete(db, pFKey->apTrigger[0]);\n    fkTriggerDelete(db, pFKey->apTrigger[1]);\n#endif\n\n    pNext = pFKey->pNextFrom;\n    sqlite3DbFree(db, pFKey);\n  }\n}\n#endif /* ifndef SQLITE_OMIT_FOREIGN_KEY */\n\n/************** End of fkey.c ************************************************/\n/************** Begin file insert.c ******************************************/\n/*\n** 2001 September 15\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This file contains C code routines that are called by the parser\n** to handle INSERT statements in SQLite.\n*/\n/* #include \"sqliteInt.h\" */\n\n/*\n** Generate code that will \n**\n**   (1) acquire a lock for table pTab then\n**   (2) open pTab as cursor iCur.\n**\n** If pTab is a WITHOUT ROWID table, then it is the PRIMARY KEY index\n** for that table that is actually opened.\n*/\nSQLITE_PRIVATE void sqlite3OpenTable(\n  Parse *pParse,  /* Generate code into this VDBE */\n  int iCur,       /* The cursor number of the table */\n  int iDb,        /* The database index in sqlite3.aDb[] */\n  Table *pTab,    /* The table to be opened */\n  int opcode      /* OP_OpenRead or OP_OpenWrite */\n){\n  Vdbe *v;\n  assert( !IsVirtual(pTab) );\n  v = sqlite3GetVdbe(pParse);\n  assert( opcode==OP_OpenWrite || opcode==OP_OpenRead );\n  sqlite3TableLock(pParse, iDb, pTab->tnum, \n                   (opcode==OP_OpenWrite)?1:0, pTab->zName);\n  if( HasRowid(pTab) ){\n    sqlite3VdbeAddOp4Int(v, opcode, iCur, pTab->tnum, iDb, pTab->nCol);\n    VdbeComment((v, \"%s\", pTab->zName));\n  }else{\n    Index *pPk = sqlite3PrimaryKeyIndex(pTab);\n    assert( pPk!=0 );\n    assert( pPk->tnum==pTab->tnum );\n    sqlite3VdbeAddOp3(v, opcode, iCur, pPk->tnum, iDb);\n    sqlite3VdbeSetP4KeyInfo(pParse, pPk);\n    VdbeComment((v, \"%s\", pTab->zName));\n  }\n}\n\n/*\n** Return a pointer to the column affinity string associated with index\n** pIdx. A column affinity string has one character for each column in \n** the table, according to the affinity of the column:\n**\n**  Character      Column affinity\n**  ------------------------------\n**  'A'            BLOB\n**  'B'            TEXT\n**  'C'            NUMERIC\n**  'D'            INTEGER\n**  'F'            REAL\n**\n** An extra 'D' is appended to the end of the string to cover the\n** rowid that appears as the last column in every index.\n**\n** Memory for the buffer containing the column index affinity string\n** is managed along with the rest of the Index structure. It will be\n** released when sqlite3DeleteIndex() is called.\n*/\nSQLITE_PRIVATE const char *sqlite3IndexAffinityStr(sqlite3 *db, Index *pIdx){\n  if( !pIdx->zColAff ){\n    /* The first time a column affinity string for a particular index is\n    ** required, it is allocated and populated here. It is then stored as\n    ** a member of the Index structure for subsequent use.\n    **\n    ** The column affinity string will eventually be deleted by\n    ** sqliteDeleteIndex() when the Index structure itself is cleaned\n    ** up.\n    */\n    int n;\n    Table *pTab = pIdx->pTable;\n    pIdx->zColAff = (char *)sqlite3DbMallocRaw(0, pIdx->nColumn+1);\n    if( !pIdx->zColAff ){\n      sqlite3OomFault(db);\n      return 0;\n    }\n    for(n=0; n<pIdx->nColumn; n++){\n      i16 x = pIdx->aiColumn[n];\n      if( x>=0 ){\n        pIdx->zColAff[n] = pTab->aCol[x].affinity;\n      }else if( x==XN_ROWID ){\n        pIdx->zColAff[n] = SQLITE_AFF_INTEGER;\n      }else{\n        char aff;\n        assert( x==XN_EXPR );\n        assert( pIdx->aColExpr!=0 );\n        aff = sqlite3ExprAffinity(pIdx->aColExpr->a[n].pExpr);\n        if( aff==0 ) aff = SQLITE_AFF_BLOB;\n        pIdx->zColAff[n] = aff;\n      }\n    }\n    pIdx->zColAff[n] = 0;\n  }\n \n  return pIdx->zColAff;\n}\n\n/*\n** Compute the affinity string for table pTab, if it has not already been\n** computed.  As an optimization, omit trailing SQLITE_AFF_BLOB affinities.\n**\n** If the affinity exists (if it is no entirely SQLITE_AFF_BLOB values) and\n** if iReg>0 then code an OP_Affinity opcode that will set the affinities\n** for register iReg and following.  Or if affinities exists and iReg==0,\n** then just set the P4 operand of the previous opcode (which should  be\n** an OP_MakeRecord) to the affinity string.\n**\n** A column affinity string has one character per column:\n**\n**  Character      Column affinity\n**  ------------------------------\n**  'A'            BLOB\n**  'B'            TEXT\n**  'C'            NUMERIC\n**  'D'            INTEGER\n**  'E'            REAL\n*/\nSQLITE_PRIVATE void sqlite3TableAffinity(Vdbe *v, Table *pTab, int iReg){\n  int i;\n  char *zColAff = pTab->zColAff;\n  if( zColAff==0 ){\n    sqlite3 *db = sqlite3VdbeDb(v);\n    zColAff = (char *)sqlite3DbMallocRaw(0, pTab->nCol+1);\n    if( !zColAff ){\n      sqlite3OomFault(db);\n      return;\n    }\n\n    for(i=0; i<pTab->nCol; i++){\n      zColAff[i] = pTab->aCol[i].affinity;\n    }\n    do{\n      zColAff[i--] = 0;\n    }while( i>=0 && zColAff[i]==SQLITE_AFF_BLOB );\n    pTab->zColAff = zColAff;\n  }\n  assert( zColAff!=0 );\n  i = sqlite3Strlen30NN(zColAff);\n  if( i ){\n    if( iReg ){\n      sqlite3VdbeAddOp4(v, OP_Affinity, iReg, i, 0, zColAff, i);\n    }else{\n      sqlite3VdbeChangeP4(v, -1, zColAff, i);\n    }\n  }\n}\n\n/*\n** Return non-zero if the table pTab in database iDb or any of its indices\n** have been opened at any point in the VDBE program. This is used to see if \n** a statement of the form  \"INSERT INTO <iDb, pTab> SELECT ...\" can \n** run without using a temporary table for the results of the SELECT. \n*/\nstatic int readsTable(Parse *p, int iDb, Table *pTab){\n  Vdbe *v = sqlite3GetVdbe(p);\n  int i;\n  int iEnd = sqlite3VdbeCurrentAddr(v);\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n  VTable *pVTab = IsVirtual(pTab) ? sqlite3GetVTable(p->db, pTab) : 0;\n#endif\n\n  for(i=1; i<iEnd; i++){\n    VdbeOp *pOp = sqlite3VdbeGetOp(v, i);\n    assert( pOp!=0 );\n    if( pOp->opcode==OP_OpenRead && pOp->p3==iDb ){\n      Index *pIndex;\n      int tnum = pOp->p2;\n      if( tnum==pTab->tnum ){\n        return 1;\n      }\n      for(pIndex=pTab->pIndex; pIndex; pIndex=pIndex->pNext){\n        if( tnum==pIndex->tnum ){\n          return 1;\n        }\n      }\n    }\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n    if( pOp->opcode==OP_VOpen && pOp->p4.pVtab==pVTab ){\n      assert( pOp->p4.pVtab!=0 );\n      assert( pOp->p4type==P4_VTAB );\n      return 1;\n    }\n#endif\n  }\n  return 0;\n}\n\n#ifndef SQLITE_OMIT_AUTOINCREMENT\n/*\n** Locate or create an AutoincInfo structure associated with table pTab\n** which is in database iDb.  Return the register number for the register\n** that holds the maximum rowid.  Return zero if pTab is not an AUTOINCREMENT\n** table.  (Also return zero when doing a VACUUM since we do not want to\n** update the AUTOINCREMENT counters during a VACUUM.)\n**\n** There is at most one AutoincInfo structure per table even if the\n** same table is autoincremented multiple times due to inserts within\n** triggers.  A new AutoincInfo structure is created if this is the\n** first use of table pTab.  On 2nd and subsequent uses, the original\n** AutoincInfo structure is used.\n**\n** Four consecutive registers are allocated:\n**\n**   (1)  The name of the pTab table.\n**   (2)  The maximum ROWID of pTab.\n**   (3)  The rowid in sqlite_sequence of pTab\n**   (4)  The original value of the max ROWID in pTab, or NULL if none\n**\n** The 2nd register is the one that is returned.  That is all the\n** insert routine needs to know about.\n*/\nstatic int autoIncBegin(\n  Parse *pParse,      /* Parsing context */\n  int iDb,            /* Index of the database holding pTab */\n  Table *pTab         /* The table we are writing to */\n){\n  int memId = 0;      /* Register holding maximum rowid */\n  assert( pParse->db->aDb[iDb].pSchema!=0 );\n  if( (pTab->tabFlags & TF_Autoincrement)!=0\n   && (pParse->db->mDbFlags & DBFLAG_Vacuum)==0\n  ){\n    Parse *pToplevel = sqlite3ParseToplevel(pParse);\n    AutoincInfo *pInfo;\n    Table *pSeqTab = pParse->db->aDb[iDb].pSchema->pSeqTab;\n\n    /* Verify that the sqlite_sequence table exists and is an ordinary\n    ** rowid table with exactly two columns.\n    ** Ticket d8dc2b3a58cd5dc2918a1d4acb 2018-05-23 */\n    if( pSeqTab==0\n     || !HasRowid(pSeqTab)\n     || IsVirtual(pSeqTab)\n     || pSeqTab->nCol!=2\n    ){\n      pParse->nErr++;\n      pParse->rc = SQLITE_CORRUPT_SEQUENCE;\n      return 0;\n    }\n\n    pInfo = pToplevel->pAinc;\n    while( pInfo && pInfo->pTab!=pTab ){ pInfo = pInfo->pNext; }\n    if( pInfo==0 ){\n      pInfo = sqlite3DbMallocRawNN(pParse->db, sizeof(*pInfo));\n      if( pInfo==0 ) return 0;\n      pInfo->pNext = pToplevel->pAinc;\n      pToplevel->pAinc = pInfo;\n      pInfo->pTab = pTab;\n      pInfo->iDb = iDb;\n      pToplevel->nMem++;                  /* Register to hold name of table */\n      pInfo->regCtr = ++pToplevel->nMem;  /* Max rowid register */\n      pToplevel->nMem +=2;       /* Rowid in sqlite_sequence + orig max val */\n    }\n    memId = pInfo->regCtr;\n  }\n  return memId;\n}\n\n/*\n** This routine generates code that will initialize all of the\n** register used by the autoincrement tracker.  \n*/\nSQLITE_PRIVATE void sqlite3AutoincrementBegin(Parse *pParse){\n  AutoincInfo *p;            /* Information about an AUTOINCREMENT */\n  sqlite3 *db = pParse->db;  /* The database connection */\n  Db *pDb;                   /* Database only autoinc table */\n  int memId;                 /* Register holding max rowid */\n  Vdbe *v = pParse->pVdbe;   /* VDBE under construction */\n\n  /* This routine is never called during trigger-generation.  It is\n  ** only called from the top-level */\n  assert( pParse->pTriggerTab==0 );\n  assert( sqlite3IsToplevel(pParse) );\n\n  assert( v );   /* We failed long ago if this is not so */\n  for(p = pParse->pAinc; p; p = p->pNext){\n    static const int iLn = VDBE_OFFSET_LINENO(2);\n    static const VdbeOpList autoInc[] = {\n      /* 0  */ {OP_Null,    0,  0, 0},\n      /* 1  */ {OP_Rewind,  0, 10, 0},\n      /* 2  */ {OP_Column,  0,  0, 0},\n      /* 3  */ {OP_Ne,      0,  9, 0},\n      /* 4  */ {OP_Rowid,   0,  0, 0},\n      /* 5  */ {OP_Column,  0,  1, 0},\n      /* 6  */ {OP_AddImm,  0,  0, 0},\n      /* 7  */ {OP_Copy,    0,  0, 0},\n      /* 8  */ {OP_Goto,    0, 11, 0},\n      /* 9  */ {OP_Next,    0,  2, 0},\n      /* 10 */ {OP_Integer, 0,  0, 0},\n      /* 11 */ {OP_Close,   0,  0, 0} \n    };\n    VdbeOp *aOp;\n    pDb = &db->aDb[p->iDb];\n    memId = p->regCtr;\n    assert( sqlite3SchemaMutexHeld(db, 0, pDb->pSchema) );\n    sqlite3OpenTable(pParse, 0, p->iDb, pDb->pSchema->pSeqTab, OP_OpenRead);\n    sqlite3VdbeLoadString(v, memId-1, p->pTab->zName);\n    aOp = sqlite3VdbeAddOpList(v, ArraySize(autoInc), autoInc, iLn);\n    if( aOp==0 ) break;\n    aOp[0].p2 = memId;\n    aOp[0].p3 = memId+2;\n    aOp[2].p3 = memId;\n    aOp[3].p1 = memId-1;\n    aOp[3].p3 = memId;\n    aOp[3].p5 = SQLITE_JUMPIFNULL;\n    aOp[4].p2 = memId+1;\n    aOp[5].p3 = memId;\n    aOp[6].p1 = memId;\n    aOp[7].p2 = memId+2;\n    aOp[7].p1 = memId;\n    aOp[10].p2 = memId;\n    if( pParse->nTab==0 ) pParse->nTab = 1;\n  }\n}\n\n/*\n** Update the maximum rowid for an autoincrement calculation.\n**\n** This routine should be called when the regRowid register holds a\n** new rowid that is about to be inserted.  If that new rowid is\n** larger than the maximum rowid in the memId memory cell, then the\n** memory cell is updated.\n*/\nstatic void autoIncStep(Parse *pParse, int memId, int regRowid){\n  if( memId>0 ){\n    sqlite3VdbeAddOp2(pParse->pVdbe, OP_MemMax, memId, regRowid);\n  }\n}\n\n/*\n** This routine generates the code needed to write autoincrement\n** maximum rowid values back into the sqlite_sequence register.\n** Every statement that might do an INSERT into an autoincrement\n** table (either directly or through triggers) needs to call this\n** routine just before the \"exit\" code.\n*/\nstatic SQLITE_NOINLINE void autoIncrementEnd(Parse *pParse){\n  AutoincInfo *p;\n  Vdbe *v = pParse->pVdbe;\n  sqlite3 *db = pParse->db;\n\n  assert( v );\n  for(p = pParse->pAinc; p; p = p->pNext){\n    static const int iLn = VDBE_OFFSET_LINENO(2);\n    static const VdbeOpList autoIncEnd[] = {\n      /* 0 */ {OP_NotNull,     0, 2, 0},\n      /* 1 */ {OP_NewRowid,    0, 0, 0},\n      /* 2 */ {OP_MakeRecord,  0, 2, 0},\n      /* 3 */ {OP_Insert,      0, 0, 0},\n      /* 4 */ {OP_Close,       0, 0, 0}\n    };\n    VdbeOp *aOp;\n    Db *pDb = &db->aDb[p->iDb];\n    int iRec;\n    int memId = p->regCtr;\n\n    iRec = sqlite3GetTempReg(pParse);\n    assert( sqlite3SchemaMutexHeld(db, 0, pDb->pSchema) );\n    sqlite3VdbeAddOp3(v, OP_Le, memId+2, sqlite3VdbeCurrentAddr(v)+7, memId);\n    VdbeCoverage(v);\n    sqlite3OpenTable(pParse, 0, p->iDb, pDb->pSchema->pSeqTab, OP_OpenWrite);\n    aOp = sqlite3VdbeAddOpList(v, ArraySize(autoIncEnd), autoIncEnd, iLn);\n    if( aOp==0 ) break;\n    aOp[0].p1 = memId+1;\n    aOp[1].p2 = memId+1;\n    aOp[2].p1 = memId-1;\n    aOp[2].p3 = iRec;\n    aOp[3].p2 = iRec;\n    aOp[3].p3 = memId+1;\n    aOp[3].p5 = OPFLAG_APPEND;\n    sqlite3ReleaseTempReg(pParse, iRec);\n  }\n}\nSQLITE_PRIVATE void sqlite3AutoincrementEnd(Parse *pParse){\n  if( pParse->pAinc ) autoIncrementEnd(pParse);\n}\n#else\n/*\n** If SQLITE_OMIT_AUTOINCREMENT is defined, then the three routines\n** above are all no-ops\n*/\n# define autoIncBegin(A,B,C) (0)\n# define autoIncStep(A,B,C)\n#endif /* SQLITE_OMIT_AUTOINCREMENT */\n\n\n/* Forward declaration */\nstatic int xferOptimization(\n  Parse *pParse,        /* Parser context */\n  Table *pDest,         /* The table we are inserting into */\n  Select *pSelect,      /* A SELECT statement to use as the data source */\n  int onError,          /* How to handle constraint errors */\n  int iDbDest           /* The database of pDest */\n);\n\n/*\n** This routine is called to handle SQL of the following forms:\n**\n**    insert into TABLE (IDLIST) values(EXPRLIST),(EXPRLIST),...\n**    insert into TABLE (IDLIST) select\n**    insert into TABLE (IDLIST) default values\n**\n** The IDLIST following the table name is always optional.  If omitted,\n** then a list of all (non-hidden) columns for the table is substituted.\n** The IDLIST appears in the pColumn parameter.  pColumn is NULL if IDLIST\n** is omitted.\n**\n** For the pSelect parameter holds the values to be inserted for the\n** first two forms shown above.  A VALUES clause is really just short-hand\n** for a SELECT statement that omits the FROM clause and everything else\n** that follows.  If the pSelect parameter is NULL, that means that the\n** DEFAULT VALUES form of the INSERT statement is intended.\n**\n** The code generated follows one of four templates.  For a simple\n** insert with data coming from a single-row VALUES clause, the code executes\n** once straight down through.  Pseudo-code follows (we call this\n** the \"1st template\"):\n**\n**         open write cursor to <table> and its indices\n**         put VALUES clause expressions into registers\n**         write the resulting record into <table>\n**         cleanup\n**\n** The three remaining templates assume the statement is of the form\n**\n**   INSERT INTO <table> SELECT ...\n**\n** If the SELECT clause is of the restricted form \"SELECT * FROM <table2>\" -\n** in other words if the SELECT pulls all columns from a single table\n** and there is no WHERE or LIMIT or GROUP BY or ORDER BY clauses, and\n** if <table2> and <table1> are distinct tables but have identical\n** schemas, including all the same indices, then a special optimization\n** is invoked that copies raw records from <table2> over to <table1>.\n** See the xferOptimization() function for the implementation of this\n** template.  This is the 2nd template.\n**\n**         open a write cursor to <table>\n**         open read cursor on <table2>\n**         transfer all records in <table2> over to <table>\n**         close cursors\n**         foreach index on <table>\n**           open a write cursor on the <table> index\n**           open a read cursor on the corresponding <table2> index\n**           transfer all records from the read to the write cursors\n**           close cursors\n**         end foreach\n**\n** The 3rd template is for when the second template does not apply\n** and the SELECT clause does not read from <table> at any time.\n** The generated code follows this template:\n**\n**         X <- A\n**         goto B\n**      A: setup for the SELECT\n**         loop over the rows in the SELECT\n**           load values into registers R..R+n\n**           yield X\n**         end loop\n**         cleanup after the SELECT\n**         end-coroutine X\n**      B: open write cursor to <table> and its indices\n**      C: yield X, at EOF goto D\n**         insert the select result into <table> from R..R+n\n**         goto C\n**      D: cleanup\n**\n** The 4th template is used if the insert statement takes its\n** values from a SELECT but the data is being inserted into a table\n** that is also read as part of the SELECT.  In the third form,\n** we have to use an intermediate table to store the results of\n** the select.  The template is like this:\n**\n**         X <- A\n**         goto B\n**      A: setup for the SELECT\n**         loop over the tables in the SELECT\n**           load value into register R..R+n\n**           yield X\n**         end loop\n**         cleanup after the SELECT\n**         end co-routine R\n**      B: open temp table\n**      L: yield X, at EOF goto M\n**         insert row from R..R+n into temp table\n**         goto L\n**      M: open write cursor to <table> and its indices\n**         rewind temp table\n**      C: loop over rows of intermediate table\n**           transfer values form intermediate table into <table>\n**         end loop\n**      D: cleanup\n*/\nSQLITE_PRIVATE void sqlite3Insert(\n  Parse *pParse,        /* Parser context */\n  SrcList *pTabList,    /* Name of table into which we are inserting */\n  Select *pSelect,      /* A SELECT statement to use as the data source */\n  IdList *pColumn,      /* Column names corresponding to IDLIST. */\n  int onError,          /* How to handle constraint errors */\n  Upsert *pUpsert       /* ON CONFLICT clauses for upsert, or NULL */\n){\n  sqlite3 *db;          /* The main database structure */\n  Table *pTab;          /* The table to insert into.  aka TABLE */\n  int i, j;             /* Loop counters */\n  Vdbe *v;              /* Generate code into this virtual machine */\n  Index *pIdx;          /* For looping over indices of the table */\n  int nColumn;          /* Number of columns in the data */\n  int nHidden = 0;      /* Number of hidden columns if TABLE is virtual */\n  int iDataCur = 0;     /* VDBE cursor that is the main data repository */\n  int iIdxCur = 0;      /* First index cursor */\n  int ipkColumn = -1;   /* Column that is the INTEGER PRIMARY KEY */\n  int endOfLoop;        /* Label for the end of the insertion loop */\n  int srcTab = 0;       /* Data comes from this temporary cursor if >=0 */\n  int addrInsTop = 0;   /* Jump to label \"D\" */\n  int addrCont = 0;     /* Top of insert loop. Label \"C\" in templates 3 and 4 */\n  SelectDest dest;      /* Destination for SELECT on rhs of INSERT */\n  int iDb;              /* Index of database holding TABLE */\n  u8 useTempTable = 0;  /* Store SELECT results in intermediate table */\n  u8 appendFlag = 0;    /* True if the insert is likely to be an append */\n  u8 withoutRowid;      /* 0 for normal table.  1 for WITHOUT ROWID table */\n  u8 bIdListInOrder;    /* True if IDLIST is in table order */\n  ExprList *pList = 0;  /* List of VALUES() to be inserted  */\n\n  /* Register allocations */\n  int regFromSelect = 0;/* Base register for data coming from SELECT */\n  int regAutoinc = 0;   /* Register holding the AUTOINCREMENT counter */\n  int regRowCount = 0;  /* Memory cell used for the row counter */\n  int regIns;           /* Block of regs holding rowid+data being inserted */\n  int regRowid;         /* registers holding insert rowid */\n  int regData;          /* register holding first column to insert */\n  int *aRegIdx = 0;     /* One register allocated to each index */\n\n#ifndef SQLITE_OMIT_TRIGGER\n  int isView;                 /* True if attempting to insert into a view */\n  Trigger *pTrigger;          /* List of triggers on pTab, if required */\n  int tmask;                  /* Mask of trigger times */\n#endif\n\n  db = pParse->db;\n  if( pParse->nErr || db->mallocFailed ){\n    goto insert_cleanup;\n  }\n  dest.iSDParm = 0;  /* Suppress a harmless compiler warning */\n\n  /* If the Select object is really just a simple VALUES() list with a\n  ** single row (the common case) then keep that one row of values\n  ** and discard the other (unused) parts of the pSelect object\n  */\n  if( pSelect && (pSelect->selFlags & SF_Values)!=0 && pSelect->pPrior==0 ){\n    pList = pSelect->pEList;\n    pSelect->pEList = 0;\n    sqlite3SelectDelete(db, pSelect);\n    pSelect = 0;\n  }\n\n  /* Locate the table into which we will be inserting new information.\n  */\n  assert( pTabList->nSrc==1 );\n  pTab = sqlite3SrcListLookup(pParse, pTabList);\n  if( pTab==0 ){\n    goto insert_cleanup;\n  }\n  iDb = sqlite3SchemaToIndex(db, pTab->pSchema);\n  assert( iDb<db->nDb );\n  if( sqlite3AuthCheck(pParse, SQLITE_INSERT, pTab->zName, 0,\n                       db->aDb[iDb].zDbSName) ){\n    goto insert_cleanup;\n  }\n  withoutRowid = !HasRowid(pTab);\n\n  /* Figure out if we have any triggers and if the table being\n  ** inserted into is a view\n  */\n#ifndef SQLITE_OMIT_TRIGGER\n  pTrigger = sqlite3TriggersExist(pParse, pTab, TK_INSERT, 0, &tmask);\n  isView = pTab->pSelect!=0;\n#else\n# define pTrigger 0\n# define tmask 0\n# define isView 0\n#endif\n#ifdef SQLITE_OMIT_VIEW\n# undef isView\n# define isView 0\n#endif\n  assert( (pTrigger && tmask) || (pTrigger==0 && tmask==0) );\n\n  /* If pTab is really a view, make sure it has been initialized.\n  ** ViewGetColumnNames() is a no-op if pTab is not a view.\n  */\n  if( sqlite3ViewGetColumnNames(pParse, pTab) ){\n    goto insert_cleanup;\n  }\n\n  /* Cannot insert into a read-only table.\n  */\n  if( sqlite3IsReadOnly(pParse, pTab, tmask) ){\n    goto insert_cleanup;\n  }\n\n  /* Allocate a VDBE\n  */\n  v = sqlite3GetVdbe(pParse);\n  if( v==0 ) goto insert_cleanup;\n  if( pParse->nested==0 ) sqlite3VdbeCountChanges(v);\n  sqlite3BeginWriteOperation(pParse, pSelect || pTrigger, iDb);\n\n#ifndef SQLITE_OMIT_XFER_OPT\n  /* If the statement is of the form\n  **\n  **       INSERT INTO <table1> SELECT * FROM <table2>;\n  **\n  ** Then special optimizations can be applied that make the transfer\n  ** very fast and which reduce fragmentation of indices.\n  **\n  ** This is the 2nd template.\n  */\n  if( pColumn==0 && xferOptimization(pParse, pTab, pSelect, onError, iDb) ){\n    assert( !pTrigger );\n    assert( pList==0 );\n    goto insert_end;\n  }\n#endif /* SQLITE_OMIT_XFER_OPT */\n\n  /* If this is an AUTOINCREMENT table, look up the sequence number in the\n  ** sqlite_sequence table and store it in memory cell regAutoinc.\n  */\n  regAutoinc = autoIncBegin(pParse, iDb, pTab);\n\n  /* Allocate registers for holding the rowid of the new row,\n  ** the content of the new row, and the assembled row record.\n  */\n  regRowid = regIns = pParse->nMem+1;\n  pParse->nMem += pTab->nCol + 1;\n  if( IsVirtual(pTab) ){\n    regRowid++;\n    pParse->nMem++;\n  }\n  regData = regRowid+1;\n\n  /* If the INSERT statement included an IDLIST term, then make sure\n  ** all elements of the IDLIST really are columns of the table and \n  ** remember the column indices.\n  **\n  ** If the table has an INTEGER PRIMARY KEY column and that column\n  ** is named in the IDLIST, then record in the ipkColumn variable\n  ** the index into IDLIST of the primary key column.  ipkColumn is\n  ** the index of the primary key as it appears in IDLIST, not as\n  ** is appears in the original table.  (The index of the INTEGER\n  ** PRIMARY KEY in the original table is pTab->iPKey.)\n  */\n  bIdListInOrder = (pTab->tabFlags & TF_OOOHidden)==0;\n  if( pColumn ){\n    for(i=0; i<pColumn->nId; i++){\n      pColumn->a[i].idx = -1;\n    }\n    for(i=0; i<pColumn->nId; i++){\n      for(j=0; j<pTab->nCol; j++){\n        if( sqlite3StrICmp(pColumn->a[i].zName, pTab->aCol[j].zName)==0 ){\n          pColumn->a[i].idx = j;\n          if( i!=j ) bIdListInOrder = 0;\n          if( j==pTab->iPKey ){\n            ipkColumn = i;  assert( !withoutRowid );\n          }\n          break;\n        }\n      }\n      if( j>=pTab->nCol ){\n        if( sqlite3IsRowid(pColumn->a[i].zName) && !withoutRowid ){\n          ipkColumn = i;\n          bIdListInOrder = 0;\n        }else{\n          sqlite3ErrorMsg(pParse, \"table %S has no column named %s\",\n              pTabList, 0, pColumn->a[i].zName);\n          pParse->checkSchema = 1;\n          goto insert_cleanup;\n        }\n      }\n    }\n  }\n\n  /* Figure out how many columns of data are supplied.  If the data\n  ** is coming from a SELECT statement, then generate a co-routine that\n  ** produces a single row of the SELECT on each invocation.  The\n  ** co-routine is the common header to the 3rd and 4th templates.\n  */\n  if( pSelect ){\n    /* Data is coming from a SELECT or from a multi-row VALUES clause.\n    ** Generate a co-routine to run the SELECT. */\n    int regYield;       /* Register holding co-routine entry-point */\n    int addrTop;        /* Top of the co-routine */\n    int rc;             /* Result code */\n\n    regYield = ++pParse->nMem;\n    addrTop = sqlite3VdbeCurrentAddr(v) + 1;\n    sqlite3VdbeAddOp3(v, OP_InitCoroutine, regYield, 0, addrTop);\n    sqlite3SelectDestInit(&dest, SRT_Coroutine, regYield);\n    dest.iSdst = bIdListInOrder ? regData : 0;\n    dest.nSdst = pTab->nCol;\n    rc = sqlite3Select(pParse, pSelect, &dest);\n    regFromSelect = dest.iSdst;\n    if( rc || db->mallocFailed || pParse->nErr ) goto insert_cleanup;\n    sqlite3VdbeEndCoroutine(v, regYield);\n    sqlite3VdbeJumpHere(v, addrTop - 1);                       /* label B: */\n    assert( pSelect->pEList );\n    nColumn = pSelect->pEList->nExpr;\n\n    /* Set useTempTable to TRUE if the result of the SELECT statement\n    ** should be written into a temporary table (template 4).  Set to\n    ** FALSE if each output row of the SELECT can be written directly into\n    ** the destination table (template 3).\n    **\n    ** A temp table must be used if the table being updated is also one\n    ** of the tables being read by the SELECT statement.  Also use a \n    ** temp table in the case of row triggers.\n    */\n    if( pTrigger || readsTable(pParse, iDb, pTab) ){\n      useTempTable = 1;\n    }\n\n    if( useTempTable ){\n      /* Invoke the coroutine to extract information from the SELECT\n      ** and add it to a transient table srcTab.  The code generated\n      ** here is from the 4th template:\n      **\n      **      B: open temp table\n      **      L: yield X, goto M at EOF\n      **         insert row from R..R+n into temp table\n      **         goto L\n      **      M: ...\n      */\n      int regRec;          /* Register to hold packed record */\n      int regTempRowid;    /* Register to hold temp table ROWID */\n      int addrL;           /* Label \"L\" */\n\n      srcTab = pParse->nTab++;\n      regRec = sqlite3GetTempReg(pParse);\n      regTempRowid = sqlite3GetTempReg(pParse);\n      sqlite3VdbeAddOp2(v, OP_OpenEphemeral, srcTab, nColumn);\n      addrL = sqlite3VdbeAddOp1(v, OP_Yield, dest.iSDParm); VdbeCoverage(v);\n      sqlite3VdbeAddOp3(v, OP_MakeRecord, regFromSelect, nColumn, regRec);\n      sqlite3VdbeAddOp2(v, OP_NewRowid, srcTab, regTempRowid);\n      sqlite3VdbeAddOp3(v, OP_Insert, srcTab, regRec, regTempRowid);\n      sqlite3VdbeGoto(v, addrL);\n      sqlite3VdbeJumpHere(v, addrL);\n      sqlite3ReleaseTempReg(pParse, regRec);\n      sqlite3ReleaseTempReg(pParse, regTempRowid);\n    }\n  }else{\n    /* This is the case if the data for the INSERT is coming from a \n    ** single-row VALUES clause\n    */\n    NameContext sNC;\n    memset(&sNC, 0, sizeof(sNC));\n    sNC.pParse = pParse;\n    srcTab = -1;\n    assert( useTempTable==0 );\n    if( pList ){\n      nColumn = pList->nExpr;\n      if( sqlite3ResolveExprListNames(&sNC, pList) ){\n        goto insert_cleanup;\n      }\n    }else{\n      nColumn = 0;\n    }\n  }\n\n  /* If there is no IDLIST term but the table has an integer primary\n  ** key, the set the ipkColumn variable to the integer primary key \n  ** column index in the original table definition.\n  */\n  if( pColumn==0 && nColumn>0 ){\n    ipkColumn = pTab->iPKey;\n  }\n\n  /* Make sure the number of columns in the source data matches the number\n  ** of columns to be inserted into the table.\n  */\n  for(i=0; i<pTab->nCol; i++){\n    nHidden += (IsHiddenColumn(&pTab->aCol[i]) ? 1 : 0);\n  }\n  if( pColumn==0 && nColumn && nColumn!=(pTab->nCol-nHidden) ){\n    sqlite3ErrorMsg(pParse, \n       \"table %S has %d columns but %d values were supplied\",\n       pTabList, 0, pTab->nCol-nHidden, nColumn);\n    goto insert_cleanup;\n  }\n  if( pColumn!=0 && nColumn!=pColumn->nId ){\n    sqlite3ErrorMsg(pParse, \"%d values for %d columns\", nColumn, pColumn->nId);\n    goto insert_cleanup;\n  }\n    \n  /* Initialize the count of rows to be inserted\n  */\n  if( (db->flags & SQLITE_CountRows)!=0\n   && !pParse->nested\n   && !pParse->pTriggerTab\n  ){\n    regRowCount = ++pParse->nMem;\n    sqlite3VdbeAddOp2(v, OP_Integer, 0, regRowCount);\n  }\n\n  /* If this is not a view, open the table and and all indices */\n  if( !isView ){\n    int nIdx;\n    nIdx = sqlite3OpenTableAndIndices(pParse, pTab, OP_OpenWrite, 0, -1, 0,\n                                      &iDataCur, &iIdxCur);\n    aRegIdx = sqlite3DbMallocRawNN(db, sizeof(int)*(nIdx+1));\n    if( aRegIdx==0 ){\n      goto insert_cleanup;\n    }\n    for(i=0, pIdx=pTab->pIndex; i<nIdx; pIdx=pIdx->pNext, i++){\n      assert( pIdx );\n      aRegIdx[i] = ++pParse->nMem;\n      pParse->nMem += pIdx->nColumn;\n    }\n  }\n#ifndef SQLITE_OMIT_UPSERT\n  if( pUpsert ){\n    if( IsVirtual(pTab) ){\n      sqlite3ErrorMsg(pParse, \"UPSERT not implemented for virtual table \\\"%s\\\"\",\n              pTab->zName);\n      goto insert_cleanup;\n    }\n    pTabList->a[0].iCursor = iDataCur;\n    pUpsert->pUpsertSrc = pTabList;\n    pUpsert->regData = regData;\n    pUpsert->iDataCur = iDataCur;\n    pUpsert->iIdxCur = iIdxCur;\n    if( pUpsert->pUpsertTarget ){\n      sqlite3UpsertAnalyzeTarget(pParse, pTabList, pUpsert);\n    }\n  }\n#endif\n\n\n  /* This is the top of the main insertion loop */\n  if( useTempTable ){\n    /* This block codes the top of loop only.  The complete loop is the\n    ** following pseudocode (template 4):\n    **\n    **         rewind temp table, if empty goto D\n    **      C: loop over rows of intermediate table\n    **           transfer values form intermediate table into <table>\n    **         end loop\n    **      D: ...\n    */\n    addrInsTop = sqlite3VdbeAddOp1(v, OP_Rewind, srcTab); VdbeCoverage(v);\n    addrCont = sqlite3VdbeCurrentAddr(v);\n  }else if( pSelect ){\n    /* This block codes the top of loop only.  The complete loop is the\n    ** following pseudocode (template 3):\n    **\n    **      C: yield X, at EOF goto D\n    **         insert the select result into <table> from R..R+n\n    **         goto C\n    **      D: ...\n    */\n    addrInsTop = addrCont = sqlite3VdbeAddOp1(v, OP_Yield, dest.iSDParm);\n    VdbeCoverage(v);\n  }\n\n  /* Run the BEFORE and INSTEAD OF triggers, if there are any\n  */\n  endOfLoop = sqlite3VdbeMakeLabel(pParse);\n  if( tmask & TRIGGER_BEFORE ){\n    int regCols = sqlite3GetTempRange(pParse, pTab->nCol+1);\n\n    /* build the NEW.* reference row.  Note that if there is an INTEGER\n    ** PRIMARY KEY into which a NULL is being inserted, that NULL will be\n    ** translated into a unique ID for the row.  But on a BEFORE trigger,\n    ** we do not know what the unique ID will be (because the insert has\n    ** not happened yet) so we substitute a rowid of -1\n    */\n    if( ipkColumn<0 ){\n      sqlite3VdbeAddOp2(v, OP_Integer, -1, regCols);\n    }else{\n      int addr1;\n      assert( !withoutRowid );\n      if( useTempTable ){\n        sqlite3VdbeAddOp3(v, OP_Column, srcTab, ipkColumn, regCols);\n      }else{\n        assert( pSelect==0 );  /* Otherwise useTempTable is true */\n        sqlite3ExprCode(pParse, pList->a[ipkColumn].pExpr, regCols);\n      }\n      addr1 = sqlite3VdbeAddOp1(v, OP_NotNull, regCols); VdbeCoverage(v);\n      sqlite3VdbeAddOp2(v, OP_Integer, -1, regCols);\n      sqlite3VdbeJumpHere(v, addr1);\n      sqlite3VdbeAddOp1(v, OP_MustBeInt, regCols); VdbeCoverage(v);\n    }\n\n    /* Cannot have triggers on a virtual table. If it were possible,\n    ** this block would have to account for hidden column.\n    */\n    assert( !IsVirtual(pTab) );\n\n    /* Create the new column data\n    */\n    for(i=j=0; i<pTab->nCol; i++){\n      if( pColumn ){\n        for(j=0; j<pColumn->nId; j++){\n          if( pColumn->a[j].idx==i ) break;\n        }\n      }\n      if( (!useTempTable && !pList) || (pColumn && j>=pColumn->nId)\n            || (pColumn==0 && IsOrdinaryHiddenColumn(&pTab->aCol[i])) ){\n        sqlite3ExprCode(pParse, pTab->aCol[i].pDflt, regCols+i+1);\n      }else if( useTempTable ){\n        sqlite3VdbeAddOp3(v, OP_Column, srcTab, j, regCols+i+1); \n      }else{\n        assert( pSelect==0 ); /* Otherwise useTempTable is true */\n        sqlite3ExprCodeAndCache(pParse, pList->a[j].pExpr, regCols+i+1);\n      }\n      if( pColumn==0 && !IsOrdinaryHiddenColumn(&pTab->aCol[i]) ) j++;\n    }\n\n    /* If this is an INSERT on a view with an INSTEAD OF INSERT trigger,\n    ** do not attempt any conversions before assembling the record.\n    ** If this is a real table, attempt conversions as required by the\n    ** table column affinities.\n    */\n    if( !isView ){\n      sqlite3TableAffinity(v, pTab, regCols+1);\n    }\n\n    /* Fire BEFORE or INSTEAD OF triggers */\n    sqlite3CodeRowTrigger(pParse, pTrigger, TK_INSERT, 0, TRIGGER_BEFORE, \n        pTab, regCols-pTab->nCol-1, onError, endOfLoop);\n\n    sqlite3ReleaseTempRange(pParse, regCols, pTab->nCol+1);\n  }\n\n  /* Compute the content of the next row to insert into a range of\n  ** registers beginning at regIns.\n  */\n  if( !isView ){\n    if( IsVirtual(pTab) ){\n      /* The row that the VUpdate opcode will delete: none */\n      sqlite3VdbeAddOp2(v, OP_Null, 0, regIns);\n    }\n    if( ipkColumn>=0 ){\n      if( useTempTable ){\n        sqlite3VdbeAddOp3(v, OP_Column, srcTab, ipkColumn, regRowid);\n      }else if( pSelect ){\n        sqlite3VdbeAddOp2(v, OP_Copy, regFromSelect+ipkColumn, regRowid);\n      }else{\n        Expr *pIpk = pList->a[ipkColumn].pExpr;\n        if( pIpk->op==TK_NULL && !IsVirtual(pTab) ){\n          sqlite3VdbeAddOp3(v, OP_NewRowid, iDataCur, regRowid, regAutoinc);\n          appendFlag = 1;\n        }else{\n          sqlite3ExprCode(pParse, pList->a[ipkColumn].pExpr, regRowid);\n        }\n      }\n      /* If the PRIMARY KEY expression is NULL, then use OP_NewRowid\n      ** to generate a unique primary key value.\n      */\n      if( !appendFlag ){\n        int addr1;\n        if( !IsVirtual(pTab) ){\n          addr1 = sqlite3VdbeAddOp1(v, OP_NotNull, regRowid); VdbeCoverage(v);\n          sqlite3VdbeAddOp3(v, OP_NewRowid, iDataCur, regRowid, regAutoinc);\n          sqlite3VdbeJumpHere(v, addr1);\n        }else{\n          addr1 = sqlite3VdbeCurrentAddr(v);\n          sqlite3VdbeAddOp2(v, OP_IsNull, regRowid, addr1+2); VdbeCoverage(v);\n        }\n        sqlite3VdbeAddOp1(v, OP_MustBeInt, regRowid); VdbeCoverage(v);\n      }\n    }else if( IsVirtual(pTab) || withoutRowid ){\n      sqlite3VdbeAddOp2(v, OP_Null, 0, regRowid);\n    }else{\n      sqlite3VdbeAddOp3(v, OP_NewRowid, iDataCur, regRowid, regAutoinc);\n      appendFlag = 1;\n    }\n    autoIncStep(pParse, regAutoinc, regRowid);\n\n    /* Compute data for all columns of the new entry, beginning\n    ** with the first column.\n    */\n    nHidden = 0;\n    for(i=0; i<pTab->nCol; i++){\n      int iRegStore = regRowid+1+i;\n      if( i==pTab->iPKey ){\n        /* The value of the INTEGER PRIMARY KEY column is always a NULL.\n        ** Whenever this column is read, the rowid will be substituted\n        ** in its place.  Hence, fill this column with a NULL to avoid\n        ** taking up data space with information that will never be used.\n        ** As there may be shallow copies of this value, make it a soft-NULL */\n        sqlite3VdbeAddOp1(v, OP_SoftNull, iRegStore);\n        continue;\n      }\n      if( pColumn==0 ){\n        if( IsHiddenColumn(&pTab->aCol[i]) ){\n          j = -1;\n          nHidden++;\n        }else{\n          j = i - nHidden;\n        }\n      }else{\n        for(j=0; j<pColumn->nId; j++){\n          if( pColumn->a[j].idx==i ) break;\n        }\n      }\n      if( j<0 || nColumn==0 || (pColumn && j>=pColumn->nId) ){\n        sqlite3ExprCodeFactorable(pParse, pTab->aCol[i].pDflt, iRegStore);\n      }else if( useTempTable ){\n        sqlite3VdbeAddOp3(v, OP_Column, srcTab, j, iRegStore); \n      }else if( pSelect ){\n        if( regFromSelect!=regData ){\n          sqlite3VdbeAddOp2(v, OP_SCopy, regFromSelect+j, iRegStore);\n        }\n      }else{\n        sqlite3ExprCode(pParse, pList->a[j].pExpr, iRegStore);\n      }\n    }\n\n    /* Generate code to check constraints and generate index keys and\n    ** do the insertion.\n    */\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n    if( IsVirtual(pTab) ){\n      const char *pVTab = (const char *)sqlite3GetVTable(db, pTab);\n      sqlite3VtabMakeWritable(pParse, pTab);\n      sqlite3VdbeAddOp4(v, OP_VUpdate, 1, pTab->nCol+2, regIns, pVTab, P4_VTAB);\n      sqlite3VdbeChangeP5(v, onError==OE_Default ? OE_Abort : onError);\n      sqlite3MayAbort(pParse);\n    }else\n#endif\n    {\n      int isReplace;    /* Set to true if constraints may cause a replace */\n      int bUseSeek;     /* True to use OPFLAG_SEEKRESULT */\n      sqlite3GenerateConstraintChecks(pParse, pTab, aRegIdx, iDataCur, iIdxCur,\n          regIns, 0, ipkColumn>=0, onError, endOfLoop, &isReplace, 0, pUpsert\n      );\n      sqlite3FkCheck(pParse, pTab, 0, regIns, 0, 0);\n\n      /* Set the OPFLAG_USESEEKRESULT flag if either (a) there are no REPLACE\n      ** constraints or (b) there are no triggers and this table is not a\n      ** parent table in a foreign key constraint. It is safe to set the\n      ** flag in the second case as if any REPLACE constraint is hit, an\n      ** OP_Delete or OP_IdxDelete instruction will be executed on each \n      ** cursor that is disturbed. And these instructions both clear the\n      ** VdbeCursor.seekResult variable, disabling the OPFLAG_USESEEKRESULT\n      ** functionality.  */\n      bUseSeek = (isReplace==0 || (pTrigger==0 &&\n          ((db->flags & SQLITE_ForeignKeys)==0 || sqlite3FkReferences(pTab)==0)\n      ));\n      sqlite3CompleteInsertion(pParse, pTab, iDataCur, iIdxCur,\n          regIns, aRegIdx, 0, appendFlag, bUseSeek\n      );\n    }\n  }\n\n  /* Update the count of rows that are inserted\n  */\n  if( regRowCount ){\n    sqlite3VdbeAddOp2(v, OP_AddImm, regRowCount, 1);\n  }\n\n  if( pTrigger ){\n    /* Code AFTER triggers */\n    sqlite3CodeRowTrigger(pParse, pTrigger, TK_INSERT, 0, TRIGGER_AFTER, \n        pTab, regData-2-pTab->nCol, onError, endOfLoop);\n  }\n\n  /* The bottom of the main insertion loop, if the data source\n  ** is a SELECT statement.\n  */\n  sqlite3VdbeResolveLabel(v, endOfLoop);\n  if( useTempTable ){\n    sqlite3VdbeAddOp2(v, OP_Next, srcTab, addrCont); VdbeCoverage(v);\n    sqlite3VdbeJumpHere(v, addrInsTop);\n    sqlite3VdbeAddOp1(v, OP_Close, srcTab);\n  }else if( pSelect ){\n    sqlite3VdbeGoto(v, addrCont);\n    sqlite3VdbeJumpHere(v, addrInsTop);\n  }\n\ninsert_end:\n  /* Update the sqlite_sequence table by storing the content of the\n  ** maximum rowid counter values recorded while inserting into\n  ** autoincrement tables.\n  */\n  if( pParse->nested==0 && pParse->pTriggerTab==0 ){\n    sqlite3AutoincrementEnd(pParse);\n  }\n\n  /*\n  ** Return the number of rows inserted. If this routine is \n  ** generating code because of a call to sqlite3NestedParse(), do not\n  ** invoke the callback function.\n  */\n  if( regRowCount ){\n    sqlite3VdbeAddOp2(v, OP_ResultRow, regRowCount, 1);\n    sqlite3VdbeSetNumCols(v, 1);\n    sqlite3VdbeSetColName(v, 0, COLNAME_NAME, \"rows inserted\", SQLITE_STATIC);\n  }\n\ninsert_cleanup:\n  sqlite3SrcListDelete(db, pTabList);\n  sqlite3ExprListDelete(db, pList);\n  sqlite3UpsertDelete(db, pUpsert);\n  sqlite3SelectDelete(db, pSelect);\n  sqlite3IdListDelete(db, pColumn);\n  sqlite3DbFree(db, aRegIdx);\n}\n\n/* Make sure \"isView\" and other macros defined above are undefined. Otherwise\n** they may interfere with compilation of other functions in this file\n** (or in another file, if this file becomes part of the amalgamation).  */\n#ifdef isView\n #undef isView\n#endif\n#ifdef pTrigger\n #undef pTrigger\n#endif\n#ifdef tmask\n #undef tmask\n#endif\n\n/*\n** Meanings of bits in of pWalker->eCode for \n** sqlite3ExprReferencesUpdatedColumn()\n*/\n#define CKCNSTRNT_COLUMN   0x01    /* CHECK constraint uses a changing column */\n#define CKCNSTRNT_ROWID    0x02    /* CHECK constraint references the ROWID */\n\n/* This is the Walker callback from sqlite3ExprReferencesUpdatedColumn().\n*  Set bit 0x01 of pWalker->eCode if pWalker->eCode to 0 and if this\n** expression node references any of the\n** columns that are being modifed by an UPDATE statement.\n*/\nstatic int checkConstraintExprNode(Walker *pWalker, Expr *pExpr){\n  if( pExpr->op==TK_COLUMN ){\n    assert( pExpr->iColumn>=0 || pExpr->iColumn==-1 );\n    if( pExpr->iColumn>=0 ){\n      if( pWalker->u.aiCol[pExpr->iColumn]>=0 ){\n        pWalker->eCode |= CKCNSTRNT_COLUMN;\n      }\n    }else{\n      pWalker->eCode |= CKCNSTRNT_ROWID;\n    }\n  }\n  return WRC_Continue;\n}\n\n/*\n** pExpr is a CHECK constraint on a row that is being UPDATE-ed.  The\n** only columns that are modified by the UPDATE are those for which\n** aiChng[i]>=0, and also the ROWID is modified if chngRowid is true.\n**\n** Return true if CHECK constraint pExpr uses any of the\n** changing columns (or the rowid if it is changing).  In other words,\n** return true if this CHECK constraint must be validated for\n** the new row in the UPDATE statement.\n**\n** 2018-09-15: pExpr might also be an expression for an index-on-expressions.\n** The operation of this routine is the same - return true if an only if\n** the expression uses one or more of columns identified by the second and\n** third arguments.\n*/\nSQLITE_PRIVATE int sqlite3ExprReferencesUpdatedColumn(\n  Expr *pExpr,    /* The expression to be checked */\n  int *aiChng,    /* aiChng[x]>=0 if column x changed by the UPDATE */\n  int chngRowid   /* True if UPDATE changes the rowid */\n){\n  Walker w;\n  memset(&w, 0, sizeof(w));\n  w.eCode = 0;\n  w.xExprCallback = checkConstraintExprNode;\n  w.u.aiCol = aiChng;\n  sqlite3WalkExpr(&w, pExpr);\n  if( !chngRowid ){\n    testcase( (w.eCode & CKCNSTRNT_ROWID)!=0 );\n    w.eCode &= ~CKCNSTRNT_ROWID;\n  }\n  testcase( w.eCode==0 );\n  testcase( w.eCode==CKCNSTRNT_COLUMN );\n  testcase( w.eCode==CKCNSTRNT_ROWID );\n  testcase( w.eCode==(CKCNSTRNT_ROWID|CKCNSTRNT_COLUMN) );\n  return w.eCode!=0;\n}\n\n/*\n** Generate code to do constraint checks prior to an INSERT or an UPDATE\n** on table pTab.\n**\n** The regNewData parameter is the first register in a range that contains\n** the data to be inserted or the data after the update.  There will be\n** pTab->nCol+1 registers in this range.  The first register (the one\n** that regNewData points to) will contain the new rowid, or NULL in the\n** case of a WITHOUT ROWID table.  The second register in the range will\n** contain the content of the first table column.  The third register will\n** contain the content of the second table column.  And so forth.\n**\n** The regOldData parameter is similar to regNewData except that it contains\n** the data prior to an UPDATE rather than afterwards.  regOldData is zero\n** for an INSERT.  This routine can distinguish between UPDATE and INSERT by\n** checking regOldData for zero.\n**\n** For an UPDATE, the pkChng boolean is true if the true primary key (the\n** rowid for a normal table or the PRIMARY KEY for a WITHOUT ROWID table)\n** might be modified by the UPDATE.  If pkChng is false, then the key of\n** the iDataCur content table is guaranteed to be unchanged by the UPDATE.\n**\n** For an INSERT, the pkChng boolean indicates whether or not the rowid\n** was explicitly specified as part of the INSERT statement.  If pkChng\n** is zero, it means that the either rowid is computed automatically or\n** that the table is a WITHOUT ROWID table and has no rowid.  On an INSERT,\n** pkChng will only be true if the INSERT statement provides an integer\n** value for either the rowid column or its INTEGER PRIMARY KEY alias.\n**\n** The code generated by this routine will store new index entries into\n** registers identified by aRegIdx[].  No index entry is created for\n** indices where aRegIdx[i]==0.  The order of indices in aRegIdx[] is\n** the same as the order of indices on the linked list of indices\n** at pTab->pIndex.\n**\n** The caller must have already opened writeable cursors on the main\n** table and all applicable indices (that is to say, all indices for which\n** aRegIdx[] is not zero).  iDataCur is the cursor for the main table when\n** inserting or updating a rowid table, or the cursor for the PRIMARY KEY\n** index when operating on a WITHOUT ROWID table.  iIdxCur is the cursor\n** for the first index in the pTab->pIndex list.  Cursors for other indices\n** are at iIdxCur+N for the N-th element of the pTab->pIndex list.\n**\n** This routine also generates code to check constraints.  NOT NULL,\n** CHECK, and UNIQUE constraints are all checked.  If a constraint fails,\n** then the appropriate action is performed.  There are five possible\n** actions: ROLLBACK, ABORT, FAIL, REPLACE, and IGNORE.\n**\n**  Constraint type  Action       What Happens\n**  ---------------  ----------   ----------------------------------------\n**  any              ROLLBACK     The current transaction is rolled back and\n**                                sqlite3_step() returns immediately with a\n**                                return code of SQLITE_CONSTRAINT.\n**\n**  any              ABORT        Back out changes from the current command\n**                                only (do not do a complete rollback) then\n**                                cause sqlite3_step() to return immediately\n**                                with SQLITE_CONSTRAINT.\n**\n**  any              FAIL         Sqlite3_step() returns immediately with a\n**                                return code of SQLITE_CONSTRAINT.  The\n**                                transaction is not rolled back and any\n**                                changes to prior rows are retained.\n**\n**  any              IGNORE       The attempt in insert or update the current\n**                                row is skipped, without throwing an error.\n**                                Processing continues with the next row.\n**                                (There is an immediate jump to ignoreDest.)\n**\n**  NOT NULL         REPLACE      The NULL value is replace by the default\n**                                value for that column.  If the default value\n**                                is NULL, the action is the same as ABORT.\n**\n**  UNIQUE           REPLACE      The other row that conflicts with the row\n**                                being inserted is removed.\n**\n**  CHECK            REPLACE      Illegal.  The results in an exception.\n**\n** Which action to take is determined by the overrideError parameter.\n** Or if overrideError==OE_Default, then the pParse->onError parameter\n** is used.  Or if pParse->onError==OE_Default then the onError value\n** for the constraint is used.\n*/\nSQLITE_PRIVATE void sqlite3GenerateConstraintChecks(\n  Parse *pParse,       /* The parser context */\n  Table *pTab,         /* The table being inserted or updated */\n  int *aRegIdx,        /* Use register aRegIdx[i] for index i.  0 for unused */\n  int iDataCur,        /* Canonical data cursor (main table or PK index) */\n  int iIdxCur,         /* First index cursor */\n  int regNewData,      /* First register in a range holding values to insert */\n  int regOldData,      /* Previous content.  0 for INSERTs */\n  u8 pkChng,           /* Non-zero if the rowid or PRIMARY KEY changed */\n  u8 overrideError,    /* Override onError to this if not OE_Default */\n  int ignoreDest,      /* Jump to this label on an OE_Ignore resolution */\n  int *pbMayReplace,   /* OUT: Set to true if constraint may cause a replace */\n  int *aiChng,         /* column i is unchanged if aiChng[i]<0 */\n  Upsert *pUpsert      /* ON CONFLICT clauses, if any.  NULL otherwise */\n){\n  Vdbe *v;             /* VDBE under constrution */\n  Index *pIdx;         /* Pointer to one of the indices */\n  Index *pPk = 0;      /* The PRIMARY KEY index */\n  sqlite3 *db;         /* Database connection */\n  int i;               /* loop counter */\n  int ix;              /* Index loop counter */\n  int nCol;            /* Number of columns */\n  int onError;         /* Conflict resolution strategy */\n  int addr1;           /* Address of jump instruction */\n  int seenReplace = 0; /* True if REPLACE is used to resolve INT PK conflict */\n  int nPkField;        /* Number of fields in PRIMARY KEY. 1 for ROWID tables */\n  Index *pUpIdx = 0;   /* Index to which to apply the upsert */\n  u8 isUpdate;         /* True if this is an UPDATE operation */\n  u8 bAffinityDone = 0;  /* True if the OP_Affinity operation has been run */\n  int upsertBypass = 0;  /* Address of Goto to bypass upsert subroutine */\n  int upsertJump = 0;    /* Address of Goto that jumps into upsert subroutine */\n  int ipkTop = 0;        /* Top of the IPK uniqueness check */\n  int ipkBottom = 0;     /* OP_Goto at the end of the IPK uniqueness check */\n\n  isUpdate = regOldData!=0;\n  db = pParse->db;\n  v = sqlite3GetVdbe(pParse);\n  assert( v!=0 );\n  assert( pTab->pSelect==0 );  /* This table is not a VIEW */\n  nCol = pTab->nCol;\n  \n  /* pPk is the PRIMARY KEY index for WITHOUT ROWID tables and NULL for\n  ** normal rowid tables.  nPkField is the number of key fields in the \n  ** pPk index or 1 for a rowid table.  In other words, nPkField is the\n  ** number of fields in the true primary key of the table. */\n  if( HasRowid(pTab) ){\n    pPk = 0;\n    nPkField = 1;\n  }else{\n    pPk = sqlite3PrimaryKeyIndex(pTab);\n    nPkField = pPk->nKeyCol;\n  }\n\n  /* Record that this module has started */\n  VdbeModuleComment((v, \"BEGIN: GenCnstCks(%d,%d,%d,%d,%d)\",\n                     iDataCur, iIdxCur, regNewData, regOldData, pkChng));\n\n  /* Test all NOT NULL constraints.\n  */\n  for(i=0; i<nCol; i++){\n    if( i==pTab->iPKey ){\n      continue;        /* ROWID is never NULL */\n    }\n    if( aiChng && aiChng[i]<0 ){\n      /* Don't bother checking for NOT NULL on columns that do not change */\n      continue;\n    }\n    onError = pTab->aCol[i].notNull;\n    if( onError==OE_None ) continue;  /* This column is allowed to be NULL */\n    if( overrideError!=OE_Default ){\n      onError = overrideError;\n    }else if( onError==OE_Default ){\n      onError = OE_Abort;\n    }\n    if( onError==OE_Replace && pTab->aCol[i].pDflt==0 ){\n      onError = OE_Abort;\n    }\n    assert( onError==OE_Rollback || onError==OE_Abort || onError==OE_Fail\n        || onError==OE_Ignore || onError==OE_Replace );\n    addr1 = 0;\n    switch( onError ){\n      case OE_Replace: {\n        assert( onError==OE_Replace );\n        addr1 = sqlite3VdbeMakeLabel(pParse);\n        sqlite3VdbeAddOp2(v, OP_NotNull, regNewData+1+i, addr1);\n          VdbeCoverage(v);\n        sqlite3ExprCode(pParse, pTab->aCol[i].pDflt, regNewData+1+i);\n        sqlite3VdbeAddOp2(v, OP_NotNull, regNewData+1+i, addr1);\n          VdbeCoverage(v);\n        onError = OE_Abort;\n        /* Fall through into the OE_Abort case to generate code that runs\n        ** if both the input and the default value are NULL */\n      }\n      case OE_Abort:\n        sqlite3MayAbort(pParse);\n        /* Fall through */\n      case OE_Rollback:\n      case OE_Fail: {\n        char *zMsg = sqlite3MPrintf(db, \"%s.%s\", pTab->zName,\n                                    pTab->aCol[i].zName);\n        sqlite3VdbeAddOp3(v, OP_HaltIfNull, SQLITE_CONSTRAINT_NOTNULL, onError,\n                          regNewData+1+i);\n        sqlite3VdbeAppendP4(v, zMsg, P4_DYNAMIC);\n        sqlite3VdbeChangeP5(v, P5_ConstraintNotNull);\n        VdbeCoverage(v);\n        if( addr1 ) sqlite3VdbeResolveLabel(v, addr1);\n        break;\n      }\n      default: {\n        assert( onError==OE_Ignore );\n        sqlite3VdbeAddOp2(v, OP_IsNull, regNewData+1+i, ignoreDest);\n        VdbeCoverage(v);\n        break;\n      }\n    }\n  }\n\n  /* Test all CHECK constraints\n  */\n#ifndef SQLITE_OMIT_CHECK\n  if( pTab->pCheck && (db->flags & SQLITE_IgnoreChecks)==0 ){\n    ExprList *pCheck = pTab->pCheck;\n    pParse->iSelfTab = -(regNewData+1);\n    onError = overrideError!=OE_Default ? overrideError : OE_Abort;\n    for(i=0; i<pCheck->nExpr; i++){\n      int allOk;\n      Expr *pExpr = pCheck->a[i].pExpr;\n      if( aiChng\n       && !sqlite3ExprReferencesUpdatedColumn(pExpr, aiChng, pkChng)\n      ){\n        /* The check constraints do not reference any of the columns being\n        ** updated so there is no point it verifying the check constraint */\n        continue;\n      }\n      allOk = sqlite3VdbeMakeLabel(pParse);\n      sqlite3VdbeVerifyAbortable(v, onError);\n      sqlite3ExprIfTrue(pParse, pExpr, allOk, SQLITE_JUMPIFNULL);\n      if( onError==OE_Ignore ){\n        sqlite3VdbeGoto(v, ignoreDest);\n      }else{\n        char *zName = pCheck->a[i].zName;\n        if( zName==0 ) zName = pTab->zName;\n        if( onError==OE_Replace ) onError = OE_Abort; /* IMP: R-15569-63625 */\n        sqlite3HaltConstraint(pParse, SQLITE_CONSTRAINT_CHECK,\n                              onError, zName, P4_TRANSIENT,\n                              P5_ConstraintCheck);\n      }\n      sqlite3VdbeResolveLabel(v, allOk);\n    }\n    pParse->iSelfTab = 0;\n  }\n#endif /* !defined(SQLITE_OMIT_CHECK) */\n\n  /* UNIQUE and PRIMARY KEY constraints should be handled in the following\n  ** order:\n  **\n  **   (1)  OE_Update\n  **   (2)  OE_Abort, OE_Fail, OE_Rollback, OE_Ignore\n  **   (3)  OE_Replace\n  **\n  ** OE_Fail and OE_Ignore must happen before any changes are made.\n  ** OE_Update guarantees that only a single row will change, so it\n  ** must happen before OE_Replace.  Technically, OE_Abort and OE_Rollback\n  ** could happen in any order, but they are grouped up front for\n  ** convenience.\n  **\n  ** 2018-08-14: Ticket https://www.sqlite.org/src/info/908f001483982c43\n  ** The order of constraints used to have OE_Update as (2) and OE_Abort\n  ** and so forth as (1). But apparently PostgreSQL checks the OE_Update\n  ** constraint before any others, so it had to be moved.\n  **\n  ** Constraint checking code is generated in this order:\n  **   (A)  The rowid constraint\n  **   (B)  Unique index constraints that do not have OE_Replace as their\n  **        default conflict resolution strategy\n  **   (C)  Unique index that do use OE_Replace by default.\n  **\n  ** The ordering of (2) and (3) is accomplished by making sure the linked\n  ** list of indexes attached to a table puts all OE_Replace indexes last\n  ** in the list.  See sqlite3CreateIndex() for where that happens.\n  */\n\n  if( pUpsert ){\n    if( pUpsert->pUpsertTarget==0 ){\n      /* An ON CONFLICT DO NOTHING clause, without a constraint-target.\n      ** Make all unique constraint resolution be OE_Ignore */\n      assert( pUpsert->pUpsertSet==0 );\n      overrideError = OE_Ignore;\n      pUpsert = 0;\n    }else if( (pUpIdx = pUpsert->pUpsertIdx)!=0 ){\n      /* If the constraint-target uniqueness check must be run first.\n      ** Jump to that uniqueness check now */\n      upsertJump = sqlite3VdbeAddOp0(v, OP_Goto);\n      VdbeComment((v, \"UPSERT constraint goes first\"));\n    }\n  }\n\n  /* If rowid is changing, make sure the new rowid does not previously\n  ** exist in the table.\n  */\n  if( pkChng && pPk==0 ){\n    int addrRowidOk = sqlite3VdbeMakeLabel(pParse);\n\n    /* Figure out what action to take in case of a rowid collision */\n    onError = pTab->keyConf;\n    if( overrideError!=OE_Default ){\n      onError = overrideError;\n    }else if( onError==OE_Default ){\n      onError = OE_Abort;\n    }\n\n    /* figure out whether or not upsert applies in this case */\n    if( pUpsert && pUpsert->pUpsertIdx==0 ){\n      if( pUpsert->pUpsertSet==0 ){\n        onError = OE_Ignore;  /* DO NOTHING is the same as INSERT OR IGNORE */\n      }else{\n        onError = OE_Update;  /* DO UPDATE */\n      }\n    }\n\n    /* If the response to a rowid conflict is REPLACE but the response\n    ** to some other UNIQUE constraint is FAIL or IGNORE, then we need\n    ** to defer the running of the rowid conflict checking until after\n    ** the UNIQUE constraints have run.\n    */\n    if( onError==OE_Replace      /* IPK rule is REPLACE */\n     && onError!=overrideError   /* Rules for other contraints are different */\n     && pTab->pIndex             /* There exist other constraints */\n    ){\n      ipkTop = sqlite3VdbeAddOp0(v, OP_Goto)+1;\n      VdbeComment((v, \"defer IPK REPLACE until last\"));\n    }\n\n    if( isUpdate ){\n      /* pkChng!=0 does not mean that the rowid has changed, only that\n      ** it might have changed.  Skip the conflict logic below if the rowid\n      ** is unchanged. */\n      sqlite3VdbeAddOp3(v, OP_Eq, regNewData, addrRowidOk, regOldData);\n      sqlite3VdbeChangeP5(v, SQLITE_NOTNULL);\n      VdbeCoverage(v);\n    }\n\n    /* Check to see if the new rowid already exists in the table.  Skip\n    ** the following conflict logic if it does not. */\n    VdbeNoopComment((v, \"uniqueness check for ROWID\"));\n    sqlite3VdbeVerifyAbortable(v, onError);\n    sqlite3VdbeAddOp3(v, OP_NotExists, iDataCur, addrRowidOk, regNewData);\n    VdbeCoverage(v);\n\n    switch( onError ){\n      default: {\n        onError = OE_Abort;\n        /* Fall thru into the next case */\n      }\n      case OE_Rollback:\n      case OE_Abort:\n      case OE_Fail: {\n        testcase( onError==OE_Rollback );\n        testcase( onError==OE_Abort );\n        testcase( onError==OE_Fail );\n        sqlite3RowidConstraint(pParse, onError, pTab);\n        break;\n      }\n      case OE_Replace: {\n        /* If there are DELETE triggers on this table and the\n        ** recursive-triggers flag is set, call GenerateRowDelete() to\n        ** remove the conflicting row from the table. This will fire\n        ** the triggers and remove both the table and index b-tree entries.\n        **\n        ** Otherwise, if there are no triggers or the recursive-triggers\n        ** flag is not set, but the table has one or more indexes, call \n        ** GenerateRowIndexDelete(). This removes the index b-tree entries \n        ** only. The table b-tree entry will be replaced by the new entry \n        ** when it is inserted.  \n        **\n        ** If either GenerateRowDelete() or GenerateRowIndexDelete() is called,\n        ** also invoke MultiWrite() to indicate that this VDBE may require\n        ** statement rollback (if the statement is aborted after the delete\n        ** takes place). Earlier versions called sqlite3MultiWrite() regardless,\n        ** but being more selective here allows statements like:\n        **\n        **   REPLACE INTO t(rowid) VALUES($newrowid)\n        **\n        ** to run without a statement journal if there are no indexes on the\n        ** table.\n        */\n        Trigger *pTrigger = 0;\n        if( db->flags&SQLITE_RecTriggers ){\n          pTrigger = sqlite3TriggersExist(pParse, pTab, TK_DELETE, 0, 0);\n        }\n        if( pTrigger || sqlite3FkRequired(pParse, pTab, 0, 0) ){\n          sqlite3MultiWrite(pParse);\n          sqlite3GenerateRowDelete(pParse, pTab, pTrigger, iDataCur, iIdxCur,\n                                   regNewData, 1, 0, OE_Replace, 1, -1);\n        }else{\n#ifdef SQLITE_ENABLE_PREUPDATE_HOOK\n          assert( HasRowid(pTab) );\n          /* This OP_Delete opcode fires the pre-update-hook only. It does\n          ** not modify the b-tree. It is more efficient to let the coming\n          ** OP_Insert replace the existing entry than it is to delete the\n          ** existing entry and then insert a new one. */\n          sqlite3VdbeAddOp2(v, OP_Delete, iDataCur, OPFLAG_ISNOOP);\n          sqlite3VdbeAppendP4(v, pTab, P4_TABLE);\n#endif /* SQLITE_ENABLE_PREUPDATE_HOOK */\n          if( pTab->pIndex ){\n            sqlite3MultiWrite(pParse);\n            sqlite3GenerateRowIndexDelete(pParse, pTab, iDataCur, iIdxCur,0,-1);\n          }\n        }\n        seenReplace = 1;\n        break;\n      }\n#ifndef SQLITE_OMIT_UPSERT\n      case OE_Update: {\n        sqlite3UpsertDoUpdate(pParse, pUpsert, pTab, 0, iDataCur);\n        /* Fall through */\n      }\n#endif\n      case OE_Ignore: {\n        testcase( onError==OE_Ignore );\n        sqlite3VdbeGoto(v, ignoreDest);\n        break;\n      }\n    }\n    sqlite3VdbeResolveLabel(v, addrRowidOk);\n    if( ipkTop ){\n      ipkBottom = sqlite3VdbeAddOp0(v, OP_Goto);\n      sqlite3VdbeJumpHere(v, ipkTop-1);\n    }\n  }\n\n  /* Test all UNIQUE constraints by creating entries for each UNIQUE\n  ** index and making sure that duplicate entries do not already exist.\n  ** Compute the revised record entries for indices as we go.\n  **\n  ** This loop also handles the case of the PRIMARY KEY index for a\n  ** WITHOUT ROWID table.\n  */\n  for(ix=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, ix++){\n    int regIdx;          /* Range of registers hold conent for pIdx */\n    int regR;            /* Range of registers holding conflicting PK */\n    int iThisCur;        /* Cursor for this UNIQUE index */\n    int addrUniqueOk;    /* Jump here if the UNIQUE constraint is satisfied */\n\n    if( aRegIdx[ix]==0 ) continue;  /* Skip indices that do not change */\n    if( pUpIdx==pIdx ){\n      addrUniqueOk = upsertJump+1;\n      upsertBypass = sqlite3VdbeGoto(v, 0);\n      VdbeComment((v, \"Skip upsert subroutine\"));\n      sqlite3VdbeJumpHere(v, upsertJump);\n    }else{\n      addrUniqueOk = sqlite3VdbeMakeLabel(pParse);\n    }\n    if( bAffinityDone==0 && (pUpIdx==0 || pUpIdx==pIdx) ){\n      sqlite3TableAffinity(v, pTab, regNewData+1);\n      bAffinityDone = 1;\n    }\n    VdbeNoopComment((v, \"uniqueness check for %s\", pIdx->zName));\n    iThisCur = iIdxCur+ix;\n\n\n    /* Skip partial indices for which the WHERE clause is not true */\n    if( pIdx->pPartIdxWhere ){\n      sqlite3VdbeAddOp2(v, OP_Null, 0, aRegIdx[ix]);\n      pParse->iSelfTab = -(regNewData+1);\n      sqlite3ExprIfFalseDup(pParse, pIdx->pPartIdxWhere, addrUniqueOk,\n                            SQLITE_JUMPIFNULL);\n      pParse->iSelfTab = 0;\n    }\n\n    /* Create a record for this index entry as it should appear after\n    ** the insert or update.  Store that record in the aRegIdx[ix] register\n    */\n    regIdx = aRegIdx[ix]+1;\n    for(i=0; i<pIdx->nColumn; i++){\n      int iField = pIdx->aiColumn[i];\n      int x;\n      if( iField==XN_EXPR ){\n        pParse->iSelfTab = -(regNewData+1);\n        sqlite3ExprCodeCopy(pParse, pIdx->aColExpr->a[i].pExpr, regIdx+i);\n        pParse->iSelfTab = 0;\n        VdbeComment((v, \"%s column %d\", pIdx->zName, i));\n      }else{\n        if( iField==XN_ROWID || iField==pTab->iPKey ){\n          x = regNewData;\n        }else{\n          x = iField + regNewData + 1;\n        }\n        sqlite3VdbeAddOp2(v, iField<0 ? OP_IntCopy : OP_SCopy, x, regIdx+i);\n        VdbeComment((v, \"%s\", iField<0 ? \"rowid\" : pTab->aCol[iField].zName));\n      }\n    }\n    sqlite3VdbeAddOp3(v, OP_MakeRecord, regIdx, pIdx->nColumn, aRegIdx[ix]);\n    VdbeComment((v, \"for %s\", pIdx->zName));\n#ifdef SQLITE_ENABLE_NULL_TRIM\n    if( pIdx->idxType==2 ) sqlite3SetMakeRecordP5(v, pIdx->pTable);\n#endif\n\n    /* In an UPDATE operation, if this index is the PRIMARY KEY index \n    ** of a WITHOUT ROWID table and there has been no change the\n    ** primary key, then no collision is possible.  The collision detection\n    ** logic below can all be skipped. */\n    if( isUpdate && pPk==pIdx && pkChng==0 ){\n      sqlite3VdbeResolveLabel(v, addrUniqueOk);\n      continue;\n    }\n\n    /* Find out what action to take in case there is a uniqueness conflict */\n    onError = pIdx->onError;\n    if( onError==OE_None ){ \n      sqlite3VdbeResolveLabel(v, addrUniqueOk);\n      continue;  /* pIdx is not a UNIQUE index */\n    }\n    if( overrideError!=OE_Default ){\n      onError = overrideError;\n    }else if( onError==OE_Default ){\n      onError = OE_Abort;\n    }\n\n    /* Figure out if the upsert clause applies to this index */\n    if( pUpIdx==pIdx ){\n      if( pUpsert->pUpsertSet==0 ){\n        onError = OE_Ignore;  /* DO NOTHING is the same as INSERT OR IGNORE */\n      }else{\n        onError = OE_Update;  /* DO UPDATE */\n      }\n    }\n\n    /* Collision detection may be omitted if all of the following are true:\n    **   (1) The conflict resolution algorithm is REPLACE\n    **   (2) The table is a WITHOUT ROWID table\n    **   (3) There are no secondary indexes on the table\n    **   (4) No delete triggers need to be fired if there is a conflict\n    **   (5) No FK constraint counters need to be updated if a conflict occurs.\n    **\n    ** This is not possible for ENABLE_PREUPDATE_HOOK builds, as the row\n    ** must be explicitly deleted in order to ensure any pre-update hook\n    ** is invoked.  */ \n#ifndef SQLITE_ENABLE_PREUPDATE_HOOK\n    if( (ix==0 && pIdx->pNext==0)                   /* Condition 3 */\n     && pPk==pIdx                                   /* Condition 2 */\n     && onError==OE_Replace                         /* Condition 1 */\n     && ( 0==(db->flags&SQLITE_RecTriggers) ||      /* Condition 4 */\n          0==sqlite3TriggersExist(pParse, pTab, TK_DELETE, 0, 0))\n     && ( 0==(db->flags&SQLITE_ForeignKeys) ||      /* Condition 5 */\n         (0==pTab->pFKey && 0==sqlite3FkReferences(pTab)))\n    ){\n      sqlite3VdbeResolveLabel(v, addrUniqueOk);\n      continue;\n    }\n#endif /* ifndef SQLITE_ENABLE_PREUPDATE_HOOK */\n\n    /* Check to see if the new index entry will be unique */\n    sqlite3VdbeVerifyAbortable(v, onError);\n    sqlite3VdbeAddOp4Int(v, OP_NoConflict, iThisCur, addrUniqueOk,\n                         regIdx, pIdx->nKeyCol); VdbeCoverage(v);\n\n    /* Generate code to handle collisions */\n    regR = (pIdx==pPk) ? regIdx : sqlite3GetTempRange(pParse, nPkField);\n    if( isUpdate || onError==OE_Replace ){\n      if( HasRowid(pTab) ){\n        sqlite3VdbeAddOp2(v, OP_IdxRowid, iThisCur, regR);\n        /* Conflict only if the rowid of the existing index entry\n        ** is different from old-rowid */\n        if( isUpdate ){\n          sqlite3VdbeAddOp3(v, OP_Eq, regR, addrUniqueOk, regOldData);\n          sqlite3VdbeChangeP5(v, SQLITE_NOTNULL);\n          VdbeCoverage(v);\n        }\n      }else{\n        int x;\n        /* Extract the PRIMARY KEY from the end of the index entry and\n        ** store it in registers regR..regR+nPk-1 */\n        if( pIdx!=pPk ){\n          for(i=0; i<pPk->nKeyCol; i++){\n            assert( pPk->aiColumn[i]>=0 );\n            x = sqlite3ColumnOfIndex(pIdx, pPk->aiColumn[i]);\n            sqlite3VdbeAddOp3(v, OP_Column, iThisCur, x, regR+i);\n            VdbeComment((v, \"%s.%s\", pTab->zName,\n                         pTab->aCol[pPk->aiColumn[i]].zName));\n          }\n        }\n        if( isUpdate ){\n          /* If currently processing the PRIMARY KEY of a WITHOUT ROWID \n          ** table, only conflict if the new PRIMARY KEY values are actually\n          ** different from the old.\n          **\n          ** For a UNIQUE index, only conflict if the PRIMARY KEY values\n          ** of the matched index row are different from the original PRIMARY\n          ** KEY values of this row before the update.  */\n          int addrJump = sqlite3VdbeCurrentAddr(v)+pPk->nKeyCol;\n          int op = OP_Ne;\n          int regCmp = (IsPrimaryKeyIndex(pIdx) ? regIdx : regR);\n  \n          for(i=0; i<pPk->nKeyCol; i++){\n            char *p4 = (char*)sqlite3LocateCollSeq(pParse, pPk->azColl[i]);\n            x = pPk->aiColumn[i];\n            assert( x>=0 );\n            if( i==(pPk->nKeyCol-1) ){\n              addrJump = addrUniqueOk;\n              op = OP_Eq;\n            }\n            sqlite3VdbeAddOp4(v, op, \n                regOldData+1+x, addrJump, regCmp+i, p4, P4_COLLSEQ\n            );\n            sqlite3VdbeChangeP5(v, SQLITE_NOTNULL);\n            VdbeCoverageIf(v, op==OP_Eq);\n            VdbeCoverageIf(v, op==OP_Ne);\n          }\n        }\n      }\n    }\n\n    /* Generate code that executes if the new index entry is not unique */\n    assert( onError==OE_Rollback || onError==OE_Abort || onError==OE_Fail\n        || onError==OE_Ignore || onError==OE_Replace || onError==OE_Update );\n    switch( onError ){\n      case OE_Rollback:\n      case OE_Abort:\n      case OE_Fail: {\n        testcase( onError==OE_Rollback );\n        testcase( onError==OE_Abort );\n        testcase( onError==OE_Fail );\n        sqlite3UniqueConstraint(pParse, onError, pIdx);\n        break;\n      }\n#ifndef SQLITE_OMIT_UPSERT\n      case OE_Update: {\n        sqlite3UpsertDoUpdate(pParse, pUpsert, pTab, pIdx, iIdxCur+ix);\n        /* Fall through */\n      }\n#endif\n      case OE_Ignore: {\n        testcase( onError==OE_Ignore );\n        sqlite3VdbeGoto(v, ignoreDest);\n        break;\n      }\n      default: {\n        Trigger *pTrigger = 0;\n        assert( onError==OE_Replace );\n        if( db->flags&SQLITE_RecTriggers ){\n          pTrigger = sqlite3TriggersExist(pParse, pTab, TK_DELETE, 0, 0);\n        }\n        if( pTrigger || sqlite3FkRequired(pParse, pTab, 0, 0) ){\n          sqlite3MultiWrite(pParse);\n        }\n        sqlite3GenerateRowDelete(pParse, pTab, pTrigger, iDataCur, iIdxCur,\n            regR, nPkField, 0, OE_Replace,\n            (pIdx==pPk ? ONEPASS_SINGLE : ONEPASS_OFF), iThisCur);\n        seenReplace = 1;\n        break;\n      }\n    }\n    if( pUpIdx==pIdx ){\n      sqlite3VdbeGoto(v, upsertJump+1);\n      sqlite3VdbeJumpHere(v, upsertBypass);\n    }else{\n      sqlite3VdbeResolveLabel(v, addrUniqueOk);\n    }\n    if( regR!=regIdx ) sqlite3ReleaseTempRange(pParse, regR, nPkField);\n  }\n\n  /* If the IPK constraint is a REPLACE, run it last */\n  if( ipkTop ){\n    sqlite3VdbeGoto(v, ipkTop);\n    VdbeComment((v, \"Do IPK REPLACE\"));\n    sqlite3VdbeJumpHere(v, ipkBottom);\n  }\n\n  *pbMayReplace = seenReplace;\n  VdbeModuleComment((v, \"END: GenCnstCks(%d)\", seenReplace));\n}\n\n#ifdef SQLITE_ENABLE_NULL_TRIM\n/*\n** Change the P5 operand on the last opcode (which should be an OP_MakeRecord)\n** to be the number of columns in table pTab that must not be NULL-trimmed.\n**\n** Or if no columns of pTab may be NULL-trimmed, leave P5 at zero.\n*/\nSQLITE_PRIVATE void sqlite3SetMakeRecordP5(Vdbe *v, Table *pTab){\n  u16 i;\n\n  /* Records with omitted columns are only allowed for schema format\n  ** version 2 and later (SQLite version 3.1.4, 2005-02-20). */\n  if( pTab->pSchema->file_format<2 ) return;\n\n  for(i=pTab->nCol-1; i>0; i--){\n    if( pTab->aCol[i].pDflt!=0 ) break;\n    if( pTab->aCol[i].colFlags & COLFLAG_PRIMKEY ) break;\n  }\n  sqlite3VdbeChangeP5(v, i+1);\n}\n#endif\n\n/*\n** This routine generates code to finish the INSERT or UPDATE operation\n** that was started by a prior call to sqlite3GenerateConstraintChecks.\n** A consecutive range of registers starting at regNewData contains the\n** rowid and the content to be inserted.\n**\n** The arguments to this routine should be the same as the first six\n** arguments to sqlite3GenerateConstraintChecks.\n*/\nSQLITE_PRIVATE void sqlite3CompleteInsertion(\n  Parse *pParse,      /* The parser context */\n  Table *pTab,        /* the table into which we are inserting */\n  int iDataCur,       /* Cursor of the canonical data source */\n  int iIdxCur,        /* First index cursor */\n  int regNewData,     /* Range of content */\n  int *aRegIdx,       /* Register used by each index.  0 for unused indices */\n  int update_flags,   /* True for UPDATE, False for INSERT */\n  int appendBias,     /* True if this is likely to be an append */\n  int useSeekResult   /* True to set the USESEEKRESULT flag on OP_[Idx]Insert */\n){\n  Vdbe *v;            /* Prepared statements under construction */\n  Index *pIdx;        /* An index being inserted or updated */\n  u8 pik_flags;       /* flag values passed to the btree insert */\n  int regData;        /* Content registers (after the rowid) */\n  int regRec;         /* Register holding assembled record for the table */\n  int i;              /* Loop counter */\n  u8 bAffinityDone = 0; /* True if OP_Affinity has been run already */\n\n  assert( update_flags==0\n       || update_flags==OPFLAG_ISUPDATE\n       || update_flags==(OPFLAG_ISUPDATE|OPFLAG_SAVEPOSITION)\n  );\n\n  v = sqlite3GetVdbe(pParse);\n  assert( v!=0 );\n  assert( pTab->pSelect==0 );  /* This table is not a VIEW */\n  for(i=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, i++){\n    if( aRegIdx[i]==0 ) continue;\n    bAffinityDone = 1;\n    if( pIdx->pPartIdxWhere ){\n      sqlite3VdbeAddOp2(v, OP_IsNull, aRegIdx[i], sqlite3VdbeCurrentAddr(v)+2);\n      VdbeCoverage(v);\n    }\n    pik_flags = (useSeekResult ? OPFLAG_USESEEKRESULT : 0);\n    if( IsPrimaryKeyIndex(pIdx) && !HasRowid(pTab) ){\n      assert( pParse->nested==0 );\n      pik_flags |= OPFLAG_NCHANGE;\n      pik_flags |= (update_flags & OPFLAG_SAVEPOSITION);\n#ifdef SQLITE_ENABLE_PREUPDATE_HOOK\n      if( update_flags==0 ){\n        int r = sqlite3GetTempReg(pParse);\n        sqlite3VdbeAddOp2(v, OP_Integer, 0, r);\n        sqlite3VdbeAddOp4(v, OP_Insert, \n            iIdxCur+i, aRegIdx[i], r, (char*)pTab, P4_TABLE\n        );\n        sqlite3VdbeChangeP5(v, OPFLAG_ISNOOP);\n        sqlite3ReleaseTempReg(pParse, r);\n      }\n#endif\n    }\n    sqlite3VdbeAddOp4Int(v, OP_IdxInsert, iIdxCur+i, aRegIdx[i],\n                         aRegIdx[i]+1,\n                         pIdx->uniqNotNull ? pIdx->nKeyCol: pIdx->nColumn);\n    sqlite3VdbeChangeP5(v, pik_flags);\n  }\n  if( !HasRowid(pTab) ) return;\n  regData = regNewData + 1;\n  regRec = sqlite3GetTempReg(pParse);\n  sqlite3VdbeAddOp3(v, OP_MakeRecord, regData, pTab->nCol, regRec);\n  sqlite3SetMakeRecordP5(v, pTab);\n  if( !bAffinityDone ){\n    sqlite3TableAffinity(v, pTab, 0);\n  }\n  if( pParse->nested ){\n    pik_flags = 0;\n  }else{\n    pik_flags = OPFLAG_NCHANGE;\n    pik_flags |= (update_flags?update_flags:OPFLAG_LASTROWID);\n  }\n  if( appendBias ){\n    pik_flags |= OPFLAG_APPEND;\n  }\n  if( useSeekResult ){\n    pik_flags |= OPFLAG_USESEEKRESULT;\n  }\n  sqlite3VdbeAddOp3(v, OP_Insert, iDataCur, regRec, regNewData);\n  if( !pParse->nested ){\n    sqlite3VdbeAppendP4(v, pTab, P4_TABLE);\n  }\n  sqlite3VdbeChangeP5(v, pik_flags);\n}\n\n/*\n** Allocate cursors for the pTab table and all its indices and generate\n** code to open and initialized those cursors.\n**\n** The cursor for the object that contains the complete data (normally\n** the table itself, but the PRIMARY KEY index in the case of a WITHOUT\n** ROWID table) is returned in *piDataCur.  The first index cursor is\n** returned in *piIdxCur.  The number of indices is returned.\n**\n** Use iBase as the first cursor (either the *piDataCur for rowid tables\n** or the first index for WITHOUT ROWID tables) if it is non-negative.\n** If iBase is negative, then allocate the next available cursor.\n**\n** For a rowid table, *piDataCur will be exactly one less than *piIdxCur.\n** For a WITHOUT ROWID table, *piDataCur will be somewhere in the range\n** of *piIdxCurs, depending on where the PRIMARY KEY index appears on the\n** pTab->pIndex list.\n**\n** If pTab is a virtual table, then this routine is a no-op and the\n** *piDataCur and *piIdxCur values are left uninitialized.\n*/\nSQLITE_PRIVATE int sqlite3OpenTableAndIndices(\n  Parse *pParse,   /* Parsing context */\n  Table *pTab,     /* Table to be opened */\n  int op,          /* OP_OpenRead or OP_OpenWrite */\n  u8 p5,           /* P5 value for OP_Open* opcodes (except on WITHOUT ROWID) */\n  int iBase,       /* Use this for the table cursor, if there is one */\n  u8 *aToOpen,     /* If not NULL: boolean for each table and index */\n  int *piDataCur,  /* Write the database source cursor number here */\n  int *piIdxCur    /* Write the first index cursor number here */\n){\n  int i;\n  int iDb;\n  int iDataCur;\n  Index *pIdx;\n  Vdbe *v;\n\n  assert( op==OP_OpenRead || op==OP_OpenWrite );\n  assert( op==OP_OpenWrite || p5==0 );\n  if( IsVirtual(pTab) ){\n    /* This routine is a no-op for virtual tables. Leave the output\n    ** variables *piDataCur and *piIdxCur uninitialized so that valgrind\n    ** can detect if they are used by mistake in the caller. */\n    return 0;\n  }\n  iDb = sqlite3SchemaToIndex(pParse->db, pTab->pSchema);\n  v = sqlite3GetVdbe(pParse);\n  assert( v!=0 );\n  if( iBase<0 ) iBase = pParse->nTab;\n  iDataCur = iBase++;\n  if( piDataCur ) *piDataCur = iDataCur;\n  if( HasRowid(pTab) && (aToOpen==0 || aToOpen[0]) ){\n    sqlite3OpenTable(pParse, iDataCur, iDb, pTab, op);\n  }else{\n    sqlite3TableLock(pParse, iDb, pTab->tnum, op==OP_OpenWrite, pTab->zName);\n  }\n  if( piIdxCur ) *piIdxCur = iBase;\n  for(i=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, i++){\n    int iIdxCur = iBase++;\n    assert( pIdx->pSchema==pTab->pSchema );\n    if( IsPrimaryKeyIndex(pIdx) && !HasRowid(pTab) ){\n      if( piDataCur ) *piDataCur = iIdxCur;\n      p5 = 0;\n    }\n    if( aToOpen==0 || aToOpen[i+1] ){\n      sqlite3VdbeAddOp3(v, op, iIdxCur, pIdx->tnum, iDb);\n      sqlite3VdbeSetP4KeyInfo(pParse, pIdx);\n      sqlite3VdbeChangeP5(v, p5);\n      VdbeComment((v, \"%s\", pIdx->zName));\n    }\n  }\n  if( iBase>pParse->nTab ) pParse->nTab = iBase;\n  return i;\n}\n\n\n#ifdef SQLITE_TEST\n/*\n** The following global variable is incremented whenever the\n** transfer optimization is used.  This is used for testing\n** purposes only - to make sure the transfer optimization really\n** is happening when it is supposed to.\n*/\nSQLITE_API int sqlite3_xferopt_count;\n#endif /* SQLITE_TEST */\n\n\n#ifndef SQLITE_OMIT_XFER_OPT\n/*\n** Check to see if index pSrc is compatible as a source of data\n** for index pDest in an insert transfer optimization.  The rules\n** for a compatible index:\n**\n**    *   The index is over the same set of columns\n**    *   The same DESC and ASC markings occurs on all columns\n**    *   The same onError processing (OE_Abort, OE_Ignore, etc)\n**    *   The same collating sequence on each column\n**    *   The index has the exact same WHERE clause\n*/\nstatic int xferCompatibleIndex(Index *pDest, Index *pSrc){\n  int i;\n  assert( pDest && pSrc );\n  assert( pDest->pTable!=pSrc->pTable );\n  if( pDest->nKeyCol!=pSrc->nKeyCol ){\n    return 0;   /* Different number of columns */\n  }\n  if( pDest->onError!=pSrc->onError ){\n    return 0;   /* Different conflict resolution strategies */\n  }\n  for(i=0; i<pSrc->nKeyCol; i++){\n    if( pSrc->aiColumn[i]!=pDest->aiColumn[i] ){\n      return 0;   /* Different columns indexed */\n    }\n    if( pSrc->aiColumn[i]==XN_EXPR ){\n      assert( pSrc->aColExpr!=0 && pDest->aColExpr!=0 );\n      if( sqlite3ExprCompare(0, pSrc->aColExpr->a[i].pExpr,\n                             pDest->aColExpr->a[i].pExpr, -1)!=0 ){\n        return 0;   /* Different expressions in the index */\n      }\n    }\n    if( pSrc->aSortOrder[i]!=pDest->aSortOrder[i] ){\n      return 0;   /* Different sort orders */\n    }\n    if( sqlite3_stricmp(pSrc->azColl[i],pDest->azColl[i])!=0 ){\n      return 0;   /* Different collating sequences */\n    }\n  }\n  if( sqlite3ExprCompare(0, pSrc->pPartIdxWhere, pDest->pPartIdxWhere, -1) ){\n    return 0;     /* Different WHERE clauses */\n  }\n\n  /* If no test above fails then the indices must be compatible */\n  return 1;\n}\n\n/*\n** Attempt the transfer optimization on INSERTs of the form\n**\n**     INSERT INTO tab1 SELECT * FROM tab2;\n**\n** The xfer optimization transfers raw records from tab2 over to tab1.  \n** Columns are not decoded and reassembled, which greatly improves\n** performance.  Raw index records are transferred in the same way.\n**\n** The xfer optimization is only attempted if tab1 and tab2 are compatible.\n** There are lots of rules for determining compatibility - see comments\n** embedded in the code for details.\n**\n** This routine returns TRUE if the optimization is guaranteed to be used.\n** Sometimes the xfer optimization will only work if the destination table\n** is empty - a factor that can only be determined at run-time.  In that\n** case, this routine generates code for the xfer optimization but also\n** does a test to see if the destination table is empty and jumps over the\n** xfer optimization code if the test fails.  In that case, this routine\n** returns FALSE so that the caller will know to go ahead and generate\n** an unoptimized transfer.  This routine also returns FALSE if there\n** is no chance that the xfer optimization can be applied.\n**\n** This optimization is particularly useful at making VACUUM run faster.\n*/\nstatic int xferOptimization(\n  Parse *pParse,        /* Parser context */\n  Table *pDest,         /* The table we are inserting into */\n  Select *pSelect,      /* A SELECT statement to use as the data source */\n  int onError,          /* How to handle constraint errors */\n  int iDbDest           /* The database of pDest */\n){\n  sqlite3 *db = pParse->db;\n  ExprList *pEList;                /* The result set of the SELECT */\n  Table *pSrc;                     /* The table in the FROM clause of SELECT */\n  Index *pSrcIdx, *pDestIdx;       /* Source and destination indices */\n  struct SrcList_item *pItem;      /* An element of pSelect->pSrc */\n  int i;                           /* Loop counter */\n  int iDbSrc;                      /* The database of pSrc */\n  int iSrc, iDest;                 /* Cursors from source and destination */\n  int addr1, addr2;                /* Loop addresses */\n  int emptyDestTest = 0;           /* Address of test for empty pDest */\n  int emptySrcTest = 0;            /* Address of test for empty pSrc */\n  Vdbe *v;                         /* The VDBE we are building */\n  int regAutoinc;                  /* Memory register used by AUTOINC */\n  int destHasUniqueIdx = 0;        /* True if pDest has a UNIQUE index */\n  int regData, regRowid;           /* Registers holding data and rowid */\n\n  if( pSelect==0 ){\n    return 0;   /* Must be of the form  INSERT INTO ... SELECT ... */\n  }\n  if( pParse->pWith || pSelect->pWith ){\n    /* Do not attempt to process this query if there are an WITH clauses\n    ** attached to it. Proceeding may generate a false \"no such table: xxx\"\n    ** error if pSelect reads from a CTE named \"xxx\".  */\n    return 0;\n  }\n  if( sqlite3TriggerList(pParse, pDest) ){\n    return 0;   /* tab1 must not have triggers */\n  }\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n  if( IsVirtual(pDest) ){\n    return 0;   /* tab1 must not be a virtual table */\n  }\n#endif\n  if( onError==OE_Default ){\n    if( pDest->iPKey>=0 ) onError = pDest->keyConf;\n    if( onError==OE_Default ) onError = OE_Abort;\n  }\n  assert(pSelect->pSrc);   /* allocated even if there is no FROM clause */\n  if( pSelect->pSrc->nSrc!=1 ){\n    return 0;   /* FROM clause must have exactly one term */\n  }\n  if( pSelect->pSrc->a[0].pSelect ){\n    return 0;   /* FROM clause cannot contain a subquery */\n  }\n  if( pSelect->pWhere ){\n    return 0;   /* SELECT may not have a WHERE clause */\n  }\n  if( pSelect->pOrderBy ){\n    return 0;   /* SELECT may not have an ORDER BY clause */\n  }\n  /* Do not need to test for a HAVING clause.  If HAVING is present but\n  ** there is no ORDER BY, we will get an error. */\n  if( pSelect->pGroupBy ){\n    return 0;   /* SELECT may not have a GROUP BY clause */\n  }\n  if( pSelect->pLimit ){\n    return 0;   /* SELECT may not have a LIMIT clause */\n  }\n  if( pSelect->pPrior ){\n    return 0;   /* SELECT may not be a compound query */\n  }\n  if( pSelect->selFlags & SF_Distinct ){\n    return 0;   /* SELECT may not be DISTINCT */\n  }\n  pEList = pSelect->pEList;\n  assert( pEList!=0 );\n  if( pEList->nExpr!=1 ){\n    return 0;   /* The result set must have exactly one column */\n  }\n  assert( pEList->a[0].pExpr );\n  if( pEList->a[0].pExpr->op!=TK_ASTERISK ){\n    return 0;   /* The result set must be the special operator \"*\" */\n  }\n\n  /* At this point we have established that the statement is of the\n  ** correct syntactic form to participate in this optimization.  Now\n  ** we have to check the semantics.\n  */\n  pItem = pSelect->pSrc->a;\n  pSrc = sqlite3LocateTableItem(pParse, 0, pItem);\n  if( pSrc==0 ){\n    return 0;   /* FROM clause does not contain a real table */\n  }\n  if( pSrc->tnum==pDest->tnum && pSrc->pSchema==pDest->pSchema ){\n    testcase( pSrc!=pDest ); /* Possible due to bad sqlite_master.rootpage */\n    return 0;   /* tab1 and tab2 may not be the same table */\n  }\n  if( HasRowid(pDest)!=HasRowid(pSrc) ){\n    return 0;   /* source and destination must both be WITHOUT ROWID or not */\n  }\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n  if( IsVirtual(pSrc) ){\n    return 0;   /* tab2 must not be a virtual table */\n  }\n#endif\n  if( pSrc->pSelect ){\n    return 0;   /* tab2 may not be a view */\n  }\n  if( pDest->nCol!=pSrc->nCol ){\n    return 0;   /* Number of columns must be the same in tab1 and tab2 */\n  }\n  if( pDest->iPKey!=pSrc->iPKey ){\n    return 0;   /* Both tables must have the same INTEGER PRIMARY KEY */\n  }\n  for(i=0; i<pDest->nCol; i++){\n    Column *pDestCol = &pDest->aCol[i];\n    Column *pSrcCol = &pSrc->aCol[i];\n#ifdef SQLITE_ENABLE_HIDDEN_COLUMNS\n    if( (db->mDbFlags & DBFLAG_Vacuum)==0 \n     && (pDestCol->colFlags | pSrcCol->colFlags) & COLFLAG_HIDDEN \n    ){\n      return 0;    /* Neither table may have __hidden__ columns */\n    }\n#endif\n    if( pDestCol->affinity!=pSrcCol->affinity ){\n      return 0;    /* Affinity must be the same on all columns */\n    }\n    if( sqlite3_stricmp(pDestCol->zColl, pSrcCol->zColl)!=0 ){\n      return 0;    /* Collating sequence must be the same on all columns */\n    }\n    if( pDestCol->notNull && !pSrcCol->notNull ){\n      return 0;    /* tab2 must be NOT NULL if tab1 is */\n    }\n    /* Default values for second and subsequent columns need to match. */\n    if( i>0 ){\n      assert( pDestCol->pDflt==0 || pDestCol->pDflt->op==TK_SPAN );\n      assert( pSrcCol->pDflt==0 || pSrcCol->pDflt->op==TK_SPAN );\n      if( (pDestCol->pDflt==0)!=(pSrcCol->pDflt==0) \n       || (pDestCol->pDflt && strcmp(pDestCol->pDflt->u.zToken,\n                                       pSrcCol->pDflt->u.zToken)!=0)\n      ){\n        return 0;    /* Default values must be the same for all columns */\n      }\n    }\n  }\n  for(pDestIdx=pDest->pIndex; pDestIdx; pDestIdx=pDestIdx->pNext){\n    if( IsUniqueIndex(pDestIdx) ){\n      destHasUniqueIdx = 1;\n    }\n    for(pSrcIdx=pSrc->pIndex; pSrcIdx; pSrcIdx=pSrcIdx->pNext){\n      if( xferCompatibleIndex(pDestIdx, pSrcIdx) ) break;\n    }\n    if( pSrcIdx==0 ){\n      return 0;    /* pDestIdx has no corresponding index in pSrc */\n    }\n  }\n#ifndef SQLITE_OMIT_CHECK\n  if( pDest->pCheck && sqlite3ExprListCompare(pSrc->pCheck,pDest->pCheck,-1) ){\n    return 0;   /* Tables have different CHECK constraints.  Ticket #2252 */\n  }\n#endif\n#ifndef SQLITE_OMIT_FOREIGN_KEY\n  /* Disallow the transfer optimization if the destination table constains\n  ** any foreign key constraints.  This is more restrictive than necessary.\n  ** But the main beneficiary of the transfer optimization is the VACUUM \n  ** command, and the VACUUM command disables foreign key constraints.  So\n  ** the extra complication to make this rule less restrictive is probably\n  ** not worth the effort.  Ticket [6284df89debdfa61db8073e062908af0c9b6118e]\n  */\n  if( (db->flags & SQLITE_ForeignKeys)!=0 && pDest->pFKey!=0 ){\n    return 0;\n  }\n#endif\n  if( (db->flags & SQLITE_CountRows)!=0 ){\n    return 0;  /* xfer opt does not play well with PRAGMA count_changes */\n  }\n\n  /* If we get this far, it means that the xfer optimization is at\n  ** least a possibility, though it might only work if the destination\n  ** table (tab1) is initially empty.\n  */\n#ifdef SQLITE_TEST\n  sqlite3_xferopt_count++;\n#endif\n  iDbSrc = sqlite3SchemaToIndex(db, pSrc->pSchema);\n  v = sqlite3GetVdbe(pParse);\n  sqlite3CodeVerifySchema(pParse, iDbSrc);\n  iSrc = pParse->nTab++;\n  iDest = pParse->nTab++;\n  regAutoinc = autoIncBegin(pParse, iDbDest, pDest);\n  regData = sqlite3GetTempReg(pParse);\n  regRowid = sqlite3GetTempReg(pParse);\n  sqlite3OpenTable(pParse, iDest, iDbDest, pDest, OP_OpenWrite);\n  assert( HasRowid(pDest) || destHasUniqueIdx );\n  if( (db->mDbFlags & DBFLAG_Vacuum)==0 && (\n      (pDest->iPKey<0 && pDest->pIndex!=0)          /* (1) */\n   || destHasUniqueIdx                              /* (2) */\n   || (onError!=OE_Abort && onError!=OE_Rollback)   /* (3) */\n  )){\n    /* In some circumstances, we are able to run the xfer optimization\n    ** only if the destination table is initially empty. Unless the\n    ** DBFLAG_Vacuum flag is set, this block generates code to make\n    ** that determination. If DBFLAG_Vacuum is set, then the destination\n    ** table is always empty.\n    **\n    ** Conditions under which the destination must be empty:\n    **\n    ** (1) There is no INTEGER PRIMARY KEY but there are indices.\n    **     (If the destination is not initially empty, the rowid fields\n    **     of index entries might need to change.)\n    **\n    ** (2) The destination has a unique index.  (The xfer optimization \n    **     is unable to test uniqueness.)\n    **\n    ** (3) onError is something other than OE_Abort and OE_Rollback.\n    */\n    addr1 = sqlite3VdbeAddOp2(v, OP_Rewind, iDest, 0); VdbeCoverage(v);\n    emptyDestTest = sqlite3VdbeAddOp0(v, OP_Goto);\n    sqlite3VdbeJumpHere(v, addr1);\n  }\n  if( HasRowid(pSrc) ){\n    u8 insFlags;\n    sqlite3OpenTable(pParse, iSrc, iDbSrc, pSrc, OP_OpenRead);\n    emptySrcTest = sqlite3VdbeAddOp2(v, OP_Rewind, iSrc, 0); VdbeCoverage(v);\n    if( pDest->iPKey>=0 ){\n      addr1 = sqlite3VdbeAddOp2(v, OP_Rowid, iSrc, regRowid);\n      sqlite3VdbeVerifyAbortable(v, onError);\n      addr2 = sqlite3VdbeAddOp3(v, OP_NotExists, iDest, 0, regRowid);\n      VdbeCoverage(v);\n      sqlite3RowidConstraint(pParse, onError, pDest);\n      sqlite3VdbeJumpHere(v, addr2);\n      autoIncStep(pParse, regAutoinc, regRowid);\n    }else if( pDest->pIndex==0 ){\n      addr1 = sqlite3VdbeAddOp2(v, OP_NewRowid, iDest, regRowid);\n    }else{\n      addr1 = sqlite3VdbeAddOp2(v, OP_Rowid, iSrc, regRowid);\n      assert( (pDest->tabFlags & TF_Autoincrement)==0 );\n    }\n    sqlite3VdbeAddOp3(v, OP_RowData, iSrc, regData, 1);\n    if( db->mDbFlags & DBFLAG_Vacuum ){\n      sqlite3VdbeAddOp1(v, OP_SeekEnd, iDest);\n      insFlags = OPFLAG_NCHANGE|OPFLAG_LASTROWID|\n                           OPFLAG_APPEND|OPFLAG_USESEEKRESULT;\n    }else{\n      insFlags = OPFLAG_NCHANGE|OPFLAG_LASTROWID|OPFLAG_APPEND;\n    }\n    sqlite3VdbeAddOp4(v, OP_Insert, iDest, regData, regRowid,\n                      (char*)pDest, P4_TABLE);\n    sqlite3VdbeChangeP5(v, insFlags);\n    sqlite3VdbeAddOp2(v, OP_Next, iSrc, addr1); VdbeCoverage(v);\n    sqlite3VdbeAddOp2(v, OP_Close, iSrc, 0);\n    sqlite3VdbeAddOp2(v, OP_Close, iDest, 0);\n  }else{\n    sqlite3TableLock(pParse, iDbDest, pDest->tnum, 1, pDest->zName);\n    sqlite3TableLock(pParse, iDbSrc, pSrc->tnum, 0, pSrc->zName);\n  }\n  for(pDestIdx=pDest->pIndex; pDestIdx; pDestIdx=pDestIdx->pNext){\n    u8 idxInsFlags = 0;\n    for(pSrcIdx=pSrc->pIndex; ALWAYS(pSrcIdx); pSrcIdx=pSrcIdx->pNext){\n      if( xferCompatibleIndex(pDestIdx, pSrcIdx) ) break;\n    }\n    assert( pSrcIdx );\n    sqlite3VdbeAddOp3(v, OP_OpenRead, iSrc, pSrcIdx->tnum, iDbSrc);\n    sqlite3VdbeSetP4KeyInfo(pParse, pSrcIdx);\n    VdbeComment((v, \"%s\", pSrcIdx->zName));\n    sqlite3VdbeAddOp3(v, OP_OpenWrite, iDest, pDestIdx->tnum, iDbDest);\n    sqlite3VdbeSetP4KeyInfo(pParse, pDestIdx);\n    sqlite3VdbeChangeP5(v, OPFLAG_BULKCSR);\n    VdbeComment((v, \"%s\", pDestIdx->zName));\n    addr1 = sqlite3VdbeAddOp2(v, OP_Rewind, iSrc, 0); VdbeCoverage(v);\n    sqlite3VdbeAddOp3(v, OP_RowData, iSrc, regData, 1);\n    if( db->mDbFlags & DBFLAG_Vacuum ){\n      /* This INSERT command is part of a VACUUM operation, which guarantees\n      ** that the destination table is empty. If all indexed columns use\n      ** collation sequence BINARY, then it can also be assumed that the\n      ** index will be populated by inserting keys in strictly sorted \n      ** order. In this case, instead of seeking within the b-tree as part\n      ** of every OP_IdxInsert opcode, an OP_SeekEnd is added before the\n      ** OP_IdxInsert to seek to the point within the b-tree where each key \n      ** should be inserted. This is faster.\n      **\n      ** If any of the indexed columns use a collation sequence other than\n      ** BINARY, this optimization is disabled. This is because the user \n      ** might change the definition of a collation sequence and then run\n      ** a VACUUM command. In that case keys may not be written in strictly\n      ** sorted order.  */\n      for(i=0; i<pSrcIdx->nColumn; i++){\n        const char *zColl = pSrcIdx->azColl[i];\n        if( sqlite3_stricmp(sqlite3StrBINARY, zColl) ) break;\n      }\n      if( i==pSrcIdx->nColumn ){\n        idxInsFlags = OPFLAG_USESEEKRESULT;\n        sqlite3VdbeAddOp1(v, OP_SeekEnd, iDest);\n      }\n    }\n    if( !HasRowid(pSrc) && pDestIdx->idxType==2 ){\n      idxInsFlags |= OPFLAG_NCHANGE;\n    }\n    sqlite3VdbeAddOp2(v, OP_IdxInsert, iDest, regData);\n    sqlite3VdbeChangeP5(v, idxInsFlags|OPFLAG_APPEND);\n    sqlite3VdbeAddOp2(v, OP_Next, iSrc, addr1+1); VdbeCoverage(v);\n    sqlite3VdbeJumpHere(v, addr1);\n    sqlite3VdbeAddOp2(v, OP_Close, iSrc, 0);\n    sqlite3VdbeAddOp2(v, OP_Close, iDest, 0);\n  }\n  if( emptySrcTest ) sqlite3VdbeJumpHere(v, emptySrcTest);\n  sqlite3ReleaseTempReg(pParse, regRowid);\n  sqlite3ReleaseTempReg(pParse, regData);\n  if( emptyDestTest ){\n    sqlite3AutoincrementEnd(pParse);\n    sqlite3VdbeAddOp2(v, OP_Halt, SQLITE_OK, 0);\n    sqlite3VdbeJumpHere(v, emptyDestTest);\n    sqlite3VdbeAddOp2(v, OP_Close, iDest, 0);\n    return 0;\n  }else{\n    return 1;\n  }\n}\n#endif /* SQLITE_OMIT_XFER_OPT */\n\n/************** End of insert.c **********************************************/\n/************** Begin file legacy.c ******************************************/\n/*\n** 2001 September 15\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** Main file for the SQLite library.  The routines in this file\n** implement the programmer interface to the library.  Routines in\n** other files are for internal use by SQLite and should not be\n** accessed by users of the library.\n*/\n\n/* #include \"sqliteInt.h\" */\n\n/*\n** Execute SQL code.  Return one of the SQLITE_ success/failure\n** codes.  Also write an error message into memory obtained from\n** malloc() and make *pzErrMsg point to that message.\n**\n** If the SQL is a query, then for each row in the query result\n** the xCallback() function is called.  pArg becomes the first\n** argument to xCallback().  If xCallback=NULL then no callback\n** is invoked, even for queries.\n*/\nSQLITE_API int sqlite3_exec(\n  sqlite3 *db,                /* The database on which the SQL executes */\n  const char *zSql,           /* The SQL to be executed */\n  sqlite3_callback xCallback, /* Invoke this callback routine */\n  void *pArg,                 /* First argument to xCallback() */\n  char **pzErrMsg             /* Write error messages here */\n){\n  int rc = SQLITE_OK;         /* Return code */\n  const char *zLeftover;      /* Tail of unprocessed SQL */\n  sqlite3_stmt *pStmt = 0;    /* The current SQL statement */\n  char **azCols = 0;          /* Names of result columns */\n  int callbackIsInit;         /* True if callback data is initialized */\n\n  if( !sqlite3SafetyCheckOk(db) ) return SQLITE_MISUSE_BKPT;\n  if( zSql==0 ) zSql = \"\";\n\n  sqlite3_mutex_enter(db->mutex);\n  sqlite3Error(db, SQLITE_OK);\n  while( rc==SQLITE_OK && zSql[0] ){\n    int nCol = 0;\n    char **azVals = 0;\n\n    pStmt = 0;\n    rc = sqlite3_prepare_v2(db, zSql, -1, &pStmt, &zLeftover);\n    assert( rc==SQLITE_OK || pStmt==0 );\n    if( rc!=SQLITE_OK ){\n      continue;\n    }\n    if( !pStmt ){\n      /* this happens for a comment or white-space */\n      zSql = zLeftover;\n      continue;\n    }\n    callbackIsInit = 0;\n\n    while( 1 ){\n      int i;\n      rc = sqlite3_step(pStmt);\n\n      /* Invoke the callback function if required */\n      if( xCallback && (SQLITE_ROW==rc || \n          (SQLITE_DONE==rc && !callbackIsInit\n                           && db->flags&SQLITE_NullCallback)) ){\n        if( !callbackIsInit ){\n          nCol = sqlite3_column_count(pStmt);\n          azCols = sqlite3DbMallocRaw(db, (2*nCol+1)*sizeof(const char*));\n          if( azCols==0 ){\n            goto exec_out;\n          }\n          for(i=0; i<nCol; i++){\n            azCols[i] = (char *)sqlite3_column_name(pStmt, i);\n            /* sqlite3VdbeSetColName() installs column names as UTF8\n            ** strings so there is no way for sqlite3_column_name() to fail. */\n            assert( azCols[i]!=0 );\n          }\n          callbackIsInit = 1;\n        }\n        if( rc==SQLITE_ROW ){\n          azVals = &azCols[nCol];\n          for(i=0; i<nCol; i++){\n            azVals[i] = (char *)sqlite3_column_text(pStmt, i);\n            if( !azVals[i] && sqlite3_column_type(pStmt, i)!=SQLITE_NULL ){\n              sqlite3OomFault(db);\n              goto exec_out;\n            }\n          }\n          azVals[i] = 0;\n        }\n        if( xCallback(pArg, nCol, azVals, azCols) ){\n          /* EVIDENCE-OF: R-38229-40159 If the callback function to\n          ** sqlite3_exec() returns non-zero, then sqlite3_exec() will\n          ** return SQLITE_ABORT. */\n          rc = SQLITE_ABORT;\n          sqlite3VdbeFinalize((Vdbe *)pStmt);\n          pStmt = 0;\n          sqlite3Error(db, SQLITE_ABORT);\n          goto exec_out;\n        }\n      }\n\n      if( rc!=SQLITE_ROW ){\n        rc = sqlite3VdbeFinalize((Vdbe *)pStmt);\n        pStmt = 0;\n        zSql = zLeftover;\n        while( sqlite3Isspace(zSql[0]) ) zSql++;\n        break;\n      }\n    }\n\n    sqlite3DbFree(db, azCols);\n    azCols = 0;\n  }\n\nexec_out:\n  if( pStmt ) sqlite3VdbeFinalize((Vdbe *)pStmt);\n  sqlite3DbFree(db, azCols);\n\n  rc = sqlite3ApiExit(db, rc);\n  if( rc!=SQLITE_OK && pzErrMsg ){\n    *pzErrMsg = sqlite3DbStrDup(0, sqlite3_errmsg(db));\n    if( *pzErrMsg==0 ){\n      rc = SQLITE_NOMEM_BKPT;\n      sqlite3Error(db, SQLITE_NOMEM);\n    }\n  }else if( pzErrMsg ){\n    *pzErrMsg = 0;\n  }\n\n  assert( (rc&db->errMask)==rc );\n  sqlite3_mutex_leave(db->mutex);\n  return rc;\n}\n\n/************** End of legacy.c **********************************************/\n/************** Begin file loadext.c *****************************************/\n/*\n** 2006 June 7\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This file contains code used to dynamically load extensions into\n** the SQLite library.\n*/\n\n#ifndef SQLITE_CORE\n  #define SQLITE_CORE 1  /* Disable the API redefinition in sqlite3ext.h */\n#endif\n/************** Include sqlite3ext.h in the middle of loadext.c **************/\n/************** Begin file sqlite3ext.h **************************************/\n/*\n** 2006 June 7\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This header file defines the SQLite interface for use by\n** shared libraries that want to be imported as extensions into\n** an SQLite instance.  Shared libraries that intend to be loaded\n** as extensions by SQLite should #include this file instead of \n** sqlite3.h.\n*/\n#ifndef SQLITE3EXT_H\n#define SQLITE3EXT_H\n/* #include \"sqlite3.h\" */\n/* #include \"sqlcipher.h\" */\n\ntypedef struct sqlcipher_api_routines sqlcipher_api_routines;\ntypedef struct sqlite3_api_routines sqlite3_api_routines;\n\n/*\n** The following structure holds pointers to all of the SQLite API\n** routines.\n**\n** WARNING:  In order to maintain backwards compatibility, add new\n** interfaces to the end of this structure only.  If you insert new\n** interfaces in the middle of this structure, then older different\n** versions of SQLite will not be able to load each other's shared\n** libraries!\n*/\n#ifdef SQLITE_HAS_CODEC\nstruct sqlcipher_api_routines {\n  int (*register_provider)(sqlcipher_provider *p);\n  sqlcipher_provider* (*get_provider)();\n  int (*key)(sqlite3 *db, const void *pKey, int nKey);\n  int (*key_v2)(sqlite3 *db, const char *zDb, const void *pKey, int nKey);\n  int (*rekey)(sqlite3 *db, const void *pKey, int nKey);\n  int (*rekey_v2)(sqlite3 *db, const char *zDb, const void *pKey, int nKey);\n\n  int (*register_custom_provider)(const char *name, const sqlcipher_provider *p);\n  int (*unregister_custom_provider)(const char *name);\n  const sqlcipher_provider* (*get_fallback_provider)();\n};\n#endif\n\nstruct sqlite3_api_routines {\n  void * (*aggregate_context)(sqlite3_context*,int nBytes);\n  int  (*aggregate_count)(sqlite3_context*);\n  int  (*bind_blob)(sqlite3_stmt*,int,const void*,int n,void(*)(void*));\n  int  (*bind_double)(sqlite3_stmt*,int,double);\n  int  (*bind_int)(sqlite3_stmt*,int,int);\n  int  (*bind_int64)(sqlite3_stmt*,int,sqlite_int64);\n  int  (*bind_null)(sqlite3_stmt*,int);\n  int  (*bind_parameter_count)(sqlite3_stmt*);\n  int  (*bind_parameter_index)(sqlite3_stmt*,const char*zName);\n  const char * (*bind_parameter_name)(sqlite3_stmt*,int);\n  int  (*bind_text)(sqlite3_stmt*,int,const char*,int n,void(*)(void*));\n  int  (*bind_text16)(sqlite3_stmt*,int,const void*,int,void(*)(void*));\n  int  (*bind_value)(sqlite3_stmt*,int,const sqlite3_value*);\n  int  (*busy_handler)(sqlite3*,int(*)(void*,int),void*);\n  int  (*busy_timeout)(sqlite3*,int ms);\n  int  (*changes)(sqlite3*);\n  int  (*close)(sqlite3*);\n  int  (*collation_needed)(sqlite3*,void*,void(*)(void*,sqlite3*,\n                           int eTextRep,const char*));\n  int  (*collation_needed16)(sqlite3*,void*,void(*)(void*,sqlite3*,\n                             int eTextRep,const void*));\n  const void * (*column_blob)(sqlite3_stmt*,int iCol);\n  int  (*column_bytes)(sqlite3_stmt*,int iCol);\n  int  (*column_bytes16)(sqlite3_stmt*,int iCol);\n  int  (*column_count)(sqlite3_stmt*pStmt);\n  const char * (*column_database_name)(sqlite3_stmt*,int);\n  const void * (*column_database_name16)(sqlite3_stmt*,int);\n  const char * (*column_decltype)(sqlite3_stmt*,int i);\n  const void * (*column_decltype16)(sqlite3_stmt*,int);\n  double  (*column_double)(sqlite3_stmt*,int iCol);\n  int  (*column_int)(sqlite3_stmt*,int iCol);\n  sqlite_int64  (*column_int64)(sqlite3_stmt*,int iCol);\n  const char * (*column_name)(sqlite3_stmt*,int);\n  const void * (*column_name16)(sqlite3_stmt*,int);\n  const char * (*column_origin_name)(sqlite3_stmt*,int);\n  const void * (*column_origin_name16)(sqlite3_stmt*,int);\n  const char * (*column_table_name)(sqlite3_stmt*,int);\n  const void * (*column_table_name16)(sqlite3_stmt*,int);\n  const unsigned char * (*column_text)(sqlite3_stmt*,int iCol);\n  const void * (*column_text16)(sqlite3_stmt*,int iCol);\n  int  (*column_type)(sqlite3_stmt*,int iCol);\n  sqlite3_value* (*column_value)(sqlite3_stmt*,int iCol);\n  void * (*commit_hook)(sqlite3*,int(*)(void*),void*);\n  int  (*complete)(const char*sql);\n  int  (*complete16)(const void*sql);\n  int  (*create_collation)(sqlite3*,const char*,int,void*,\n                           int(*)(void*,int,const void*,int,const void*));\n  int  (*create_collation16)(sqlite3*,const void*,int,void*,\n                             int(*)(void*,int,const void*,int,const void*));\n  int  (*create_function)(sqlite3*,const char*,int,int,void*,\n                          void (*xFunc)(sqlite3_context*,int,sqlite3_value**),\n                          void (*xStep)(sqlite3_context*,int,sqlite3_value**),\n                          void (*xFinal)(sqlite3_context*));\n  int  (*create_function16)(sqlite3*,const void*,int,int,void*,\n                            void (*xFunc)(sqlite3_context*,int,sqlite3_value**),\n                            void (*xStep)(sqlite3_context*,int,sqlite3_value**),\n                            void (*xFinal)(sqlite3_context*));\n  int (*create_module)(sqlite3*,const char*,const sqlite3_module*,void*);\n  int  (*data_count)(sqlite3_stmt*pStmt);\n  sqlite3 * (*db_handle)(sqlite3_stmt*);\n  int (*declare_vtab)(sqlite3*,const char*);\n  int  (*enable_shared_cache)(int);\n  int  (*errcode)(sqlite3*db);\n  const char * (*errmsg)(sqlite3*);\n  const void * (*errmsg16)(sqlite3*);\n  int  (*exec)(sqlite3*,const char*,sqlite3_callback,void*,char**);\n  int  (*expired)(sqlite3_stmt*);\n  int  (*finalize)(sqlite3_stmt*pStmt);\n  void  (*free)(void*);\n  void  (*free_table)(char**result);\n  int  (*get_autocommit)(sqlite3*);\n  void * (*get_auxdata)(sqlite3_context*,int);\n  int  (*get_table)(sqlite3*,const char*,char***,int*,int*,char**);\n\n#ifdef SQLITE_HAS_CODEC\n  /* Was `int  (*global_recover)(void);`, but no longer used.\n     Replaced with sqlcipher api pointers. */\n  const struct sqlcipher_api_routines *sqlcipher;\n#else\n  int  (*global_recover)(void);\n#endif\n\n  void  (*interruptx)(sqlite3*);\n  sqlite_int64  (*last_insert_rowid)(sqlite3*);\n  const char * (*libversion)(void);\n  int  (*libversion_number)(void);\n  void *(*malloc)(int);\n  char * (*mprintf)(const char*,...);\n  int  (*open)(const char*,sqlite3**);\n  int  (*open16)(const void*,sqlite3**);\n  int  (*prepare)(sqlite3*,const char*,int,sqlite3_stmt**,const char**);\n  int  (*prepare16)(sqlite3*,const void*,int,sqlite3_stmt**,const void**);\n  void * (*profile)(sqlite3*,void(*)(void*,const char*,sqlite_uint64),void*);\n  void  (*progress_handler)(sqlite3*,int,int(*)(void*),void*);\n  void *(*realloc)(void*,int);\n  int  (*reset)(sqlite3_stmt*pStmt);\n  void  (*result_blob)(sqlite3_context*,const void*,int,void(*)(void*));\n  void  (*result_double)(sqlite3_context*,double);\n  void  (*result_error)(sqlite3_context*,const char*,int);\n  void  (*result_error16)(sqlite3_context*,const void*,int);\n  void  (*result_int)(sqlite3_context*,int);\n  void  (*result_int64)(sqlite3_context*,sqlite_int64);\n  void  (*result_null)(sqlite3_context*);\n  void  (*result_text)(sqlite3_context*,const char*,int,void(*)(void*));\n  void  (*result_text16)(sqlite3_context*,const void*,int,void(*)(void*));\n  void  (*result_text16be)(sqlite3_context*,const void*,int,void(*)(void*));\n  void  (*result_text16le)(sqlite3_context*,const void*,int,void(*)(void*));\n  void  (*result_value)(sqlite3_context*,sqlite3_value*);\n  void * (*rollback_hook)(sqlite3*,void(*)(void*),void*);\n  int  (*set_authorizer)(sqlite3*,int(*)(void*,int,const char*,const char*,\n                         const char*,const char*),void*);\n  void  (*set_auxdata)(sqlite3_context*,int,void*,void (*)(void*));\n  char * (*xsnprintf)(int,char*,const char*,...);\n  int  (*step)(sqlite3_stmt*);\n  int  (*table_column_metadata)(sqlite3*,const char*,const char*,const char*,\n                                char const**,char const**,int*,int*,int*);\n  void  (*thread_cleanup)(void);\n  int  (*total_changes)(sqlite3*);\n  void * (*trace)(sqlite3*,void(*xTrace)(void*,const char*),void*);\n  int  (*transfer_bindings)(sqlite3_stmt*,sqlite3_stmt*);\n  void * (*update_hook)(sqlite3*,void(*)(void*,int ,char const*,char const*,\n                                         sqlite_int64),void*);\n  void * (*user_data)(sqlite3_context*);\n  const void * (*value_blob)(sqlite3_value*);\n  int  (*value_bytes)(sqlite3_value*);\n  int  (*value_bytes16)(sqlite3_value*);\n  double  (*value_double)(sqlite3_value*);\n  int  (*value_int)(sqlite3_value*);\n  sqlite_int64  (*value_int64)(sqlite3_value*);\n  int  (*value_numeric_type)(sqlite3_value*);\n  const unsigned char * (*value_text)(sqlite3_value*);\n  const void * (*value_text16)(sqlite3_value*);\n  const void * (*value_text16be)(sqlite3_value*);\n  const void * (*value_text16le)(sqlite3_value*);\n  int  (*value_type)(sqlite3_value*);\n  char *(*vmprintf)(const char*,va_list);\n  /* Added ??? */\n  int (*overload_function)(sqlite3*, const char *zFuncName, int nArg);\n  /* Added by 3.3.13 */\n  int (*prepare_v2)(sqlite3*,const char*,int,sqlite3_stmt**,const char**);\n  int (*prepare16_v2)(sqlite3*,const void*,int,sqlite3_stmt**,const void**);\n  int (*clear_bindings)(sqlite3_stmt*);\n  /* Added by 3.4.1 */\n  int (*create_module_v2)(sqlite3*,const char*,const sqlite3_module*,void*,\n                          void (*xDestroy)(void *));\n  /* Added by 3.5.0 */\n  int (*bind_zeroblob)(sqlite3_stmt*,int,int);\n  int (*blob_bytes)(sqlite3_blob*);\n  int (*blob_close)(sqlite3_blob*);\n  int (*blob_open)(sqlite3*,const char*,const char*,const char*,sqlite3_int64,\n                   int,sqlite3_blob**);\n  int (*blob_read)(sqlite3_blob*,void*,int,int);\n  int (*blob_write)(sqlite3_blob*,const void*,int,int);\n  int (*create_collation_v2)(sqlite3*,const char*,int,void*,\n                             int(*)(void*,int,const void*,int,const void*),\n                             void(*)(void*));\n  int (*file_control)(sqlite3*,const char*,int,void*);\n  sqlite3_int64 (*memory_highwater)(int);\n  sqlite3_int64 (*memory_used)(void);\n  sqlite3_mutex *(*mutex_alloc)(int);\n  void (*mutex_enter)(sqlite3_mutex*);\n  void (*mutex_free)(sqlite3_mutex*);\n  void (*mutex_leave)(sqlite3_mutex*);\n  int (*mutex_try)(sqlite3_mutex*);\n  int (*open_v2)(const char*,sqlite3**,int,const char*);\n  int (*release_memory)(int);\n  void (*result_error_nomem)(sqlite3_context*);\n  void (*result_error_toobig)(sqlite3_context*);\n  int (*sleep)(int);\n  void (*soft_heap_limit)(int);\n  sqlite3_vfs *(*vfs_find)(const char*);\n  int (*vfs_register)(sqlite3_vfs*,int);\n  int (*vfs_unregister)(sqlite3_vfs*);\n  int (*xthreadsafe)(void);\n  void (*result_zeroblob)(sqlite3_context*,int);\n  void (*result_error_code)(sqlite3_context*,int);\n  int (*test_control)(int, ...);\n  void (*randomness)(int,void*);\n  sqlite3 *(*context_db_handle)(sqlite3_context*);\n  int (*extended_result_codes)(sqlite3*,int);\n  int (*limit)(sqlite3*,int,int);\n  sqlite3_stmt *(*next_stmt)(sqlite3*,sqlite3_stmt*);\n  const char *(*sql)(sqlite3_stmt*);\n  int (*status)(int,int*,int*,int);\n  int (*backup_finish)(sqlite3_backup*);\n  sqlite3_backup *(*backup_init)(sqlite3*,const char*,sqlite3*,const char*);\n  int (*backup_pagecount)(sqlite3_backup*);\n  int (*backup_remaining)(sqlite3_backup*);\n  int (*backup_step)(sqlite3_backup*,int);\n  const char *(*compileoption_get)(int);\n  int (*compileoption_used)(const char*);\n  int (*create_function_v2)(sqlite3*,const char*,int,int,void*,\n                            void (*xFunc)(sqlite3_context*,int,sqlite3_value**),\n                            void (*xStep)(sqlite3_context*,int,sqlite3_value**),\n                            void (*xFinal)(sqlite3_context*),\n                            void(*xDestroy)(void*));\n  int (*db_config)(sqlite3*,int,...);\n  sqlite3_mutex *(*db_mutex)(sqlite3*);\n  int (*db_status)(sqlite3*,int,int*,int*,int);\n  int (*extended_errcode)(sqlite3*);\n  void (*log)(int,const char*,...);\n  sqlite3_int64 (*soft_heap_limit64)(sqlite3_int64);\n  const char *(*sourceid)(void);\n  int (*stmt_status)(sqlite3_stmt*,int,int);\n  int (*strnicmp)(const char*,const char*,int);\n  int (*unlock_notify)(sqlite3*,void(*)(void**,int),void*);\n  int (*wal_autocheckpoint)(sqlite3*,int);\n  int (*wal_checkpoint)(sqlite3*,const char*);\n  void *(*wal_hook)(sqlite3*,int(*)(void*,sqlite3*,const char*,int),void*);\n  int (*blob_reopen)(sqlite3_blob*,sqlite3_int64);\n  int (*vtab_config)(sqlite3*,int op,...);\n  int (*vtab_on_conflict)(sqlite3*);\n  /* Version 3.7.16 and later */\n  int (*close_v2)(sqlite3*);\n  const char *(*db_filename)(sqlite3*,const char*);\n  int (*db_readonly)(sqlite3*,const char*);\n  int (*db_release_memory)(sqlite3*);\n  const char *(*errstr)(int);\n  int (*stmt_busy)(sqlite3_stmt*);\n  int (*stmt_readonly)(sqlite3_stmt*);\n  int (*stricmp)(const char*,const char*);\n  int (*uri_boolean)(const char*,const char*,int);\n  sqlite3_int64 (*uri_int64)(const char*,const char*,sqlite3_int64);\n  const char *(*uri_parameter)(const char*,const char*);\n  char *(*xvsnprintf)(int,char*,const char*,va_list);\n  int (*wal_checkpoint_v2)(sqlite3*,const char*,int,int*,int*);\n  /* Version 3.8.7 and later */\n  int (*auto_extension)(void(*)(void));\n  int (*bind_blob64)(sqlite3_stmt*,int,const void*,sqlite3_uint64,\n                     void(*)(void*));\n  int (*bind_text64)(sqlite3_stmt*,int,const char*,sqlite3_uint64,\n                      void(*)(void*),unsigned char);\n  int (*cancel_auto_extension)(void(*)(void));\n  int (*load_extension)(sqlite3*,const char*,const char*,char**);\n  void *(*malloc64)(sqlite3_uint64);\n  sqlite3_uint64 (*msize)(void*);\n  void *(*realloc64)(void*,sqlite3_uint64);\n  void (*reset_auto_extension)(void);\n  void (*result_blob64)(sqlite3_context*,const void*,sqlite3_uint64,\n                        void(*)(void*));\n  void (*result_text64)(sqlite3_context*,const char*,sqlite3_uint64,\n                         void(*)(void*), unsigned char);\n  int (*strglob)(const char*,const char*);\n  /* Version 3.8.11 and later */\n  sqlite3_value *(*value_dup)(const sqlite3_value*);\n  void (*value_free)(sqlite3_value*);\n  int (*result_zeroblob64)(sqlite3_context*,sqlite3_uint64);\n  int (*bind_zeroblob64)(sqlite3_stmt*, int, sqlite3_uint64);\n  /* Version 3.9.0 and later */\n  unsigned int (*value_subtype)(sqlite3_value*);\n  void (*result_subtype)(sqlite3_context*,unsigned int);\n  /* Version 3.10.0 and later */\n  int (*status64)(int,sqlite3_int64*,sqlite3_int64*,int);\n  int (*strlike)(const char*,const char*,unsigned int);\n  int (*db_cacheflush)(sqlite3*);\n  /* Version 3.12.0 and later */\n  int (*system_errno)(sqlite3*);\n  /* Version 3.14.0 and later */\n  int (*trace_v2)(sqlite3*,unsigned,int(*)(unsigned,void*,void*,void*),void*);\n  char *(*expanded_sql)(sqlite3_stmt*);\n  /* Version 3.18.0 and later */\n  void (*set_last_insert_rowid)(sqlite3*,sqlite3_int64);\n  /* Version 3.20.0 and later */\n  int (*prepare_v3)(sqlite3*,const char*,int,unsigned int,\n                    sqlite3_stmt**,const char**);\n  int (*prepare16_v3)(sqlite3*,const void*,int,unsigned int,\n                      sqlite3_stmt**,const void**);\n  int (*bind_pointer)(sqlite3_stmt*,int,void*,const char*,void(*)(void*));\n  void (*result_pointer)(sqlite3_context*,void*,const char*,void(*)(void*));\n  void *(*value_pointer)(sqlite3_value*,const char*);\n  int (*vtab_nochange)(sqlite3_context*);\n  int (*value_nochange)(sqlite3_value*);\n  const char *(*vtab_collation)(sqlite3_index_info*,int);\n  /* Version 3.24.0 and later */\n  int (*keyword_count)(void);\n  int (*keyword_name)(int,const char**,int*);\n  int (*keyword_check)(const char*,int);\n  sqlite3_str *(*str_new)(sqlite3*);\n  char *(*str_finish)(sqlite3_str*);\n  void (*str_appendf)(sqlite3_str*, const char *zFormat, ...);\n  void (*str_vappendf)(sqlite3_str*, const char *zFormat, va_list);\n  void (*str_append)(sqlite3_str*, const char *zIn, int N);\n  void (*str_appendall)(sqlite3_str*, const char *zIn);\n  void (*str_appendchar)(sqlite3_str*, int N, char C);\n  void (*str_reset)(sqlite3_str*);\n  int (*str_errcode)(sqlite3_str*);\n  int (*str_length)(sqlite3_str*);\n  char *(*str_value)(sqlite3_str*);\n  /* Version 3.25.0 and later */\n  int (*create_window_function)(sqlite3*,const char*,int,int,void*,\n                            void (*xStep)(sqlite3_context*,int,sqlite3_value**),\n                            void (*xFinal)(sqlite3_context*),\n                            void (*xValue)(sqlite3_context*),\n                            void (*xInv)(sqlite3_context*,int,sqlite3_value**),\n                            void(*xDestroy)(void*));\n  /* Version 3.26.0 and later */\n  const char *(*normalized_sql)(sqlite3_stmt*);\n};\n\n/*\n** This is the function signature used for all extension entry points.  It\n** is also defined in the file \"loadext.c\".\n*/\ntypedef int (*sqlite3_loadext_entry)(\n  sqlite3 *db,                       /* Handle to the database. */\n  char **pzErrMsg,                   /* Used to set error string on failure. */\n  const sqlite3_api_routines *pThunk /* Extension API function pointers. */\n);\n\n/*\n** The following macros redefine the API routines so that they are\n** redirected through the global sqlite3_api structure.\n**\n** This header file is also used by the loadext.c source file\n** (part of the main SQLite library - not an extension) so that\n** it can get access to the sqlite3_api_routines structure\n** definition.  But the main library does not want to redefine\n** the API.  So the redefinition macros are only valid if the\n** SQLITE_CORE macros is undefined.\n*/\n#if !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION)\n#define sqlite3_aggregate_context      sqlite3_api->aggregate_context\n#ifndef SQLITE_OMIT_DEPRECATED\n#define sqlite3_aggregate_count        sqlite3_api->aggregate_count\n#endif\n#define sqlite3_bind_blob              sqlite3_api->bind_blob\n#define sqlite3_bind_double            sqlite3_api->bind_double\n#define sqlite3_bind_int               sqlite3_api->bind_int\n#define sqlite3_bind_int64             sqlite3_api->bind_int64\n#define sqlite3_bind_null              sqlite3_api->bind_null\n#define sqlite3_bind_parameter_count   sqlite3_api->bind_parameter_count\n#define sqlite3_bind_parameter_index   sqlite3_api->bind_parameter_index\n#define sqlite3_bind_parameter_name    sqlite3_api->bind_parameter_name\n#define sqlite3_bind_text              sqlite3_api->bind_text\n#define sqlite3_bind_text16            sqlite3_api->bind_text16\n#define sqlite3_bind_value             sqlite3_api->bind_value\n#define sqlite3_busy_handler           sqlite3_api->busy_handler\n#define sqlite3_busy_timeout           sqlite3_api->busy_timeout\n#define sqlite3_changes                sqlite3_api->changes\n#define sqlite3_close                  sqlite3_api->close\n#define sqlite3_collation_needed       sqlite3_api->collation_needed\n#define sqlite3_collation_needed16     sqlite3_api->collation_needed16\n#define sqlite3_column_blob            sqlite3_api->column_blob\n#define sqlite3_column_bytes           sqlite3_api->column_bytes\n#define sqlite3_column_bytes16         sqlite3_api->column_bytes16\n#define sqlite3_column_count           sqlite3_api->column_count\n#define sqlite3_column_database_name   sqlite3_api->column_database_name\n#define sqlite3_column_database_name16 sqlite3_api->column_database_name16\n#define sqlite3_column_decltype        sqlite3_api->column_decltype\n#define sqlite3_column_decltype16      sqlite3_api->column_decltype16\n#define sqlite3_column_double          sqlite3_api->column_double\n#define sqlite3_column_int             sqlite3_api->column_int\n#define sqlite3_column_int64           sqlite3_api->column_int64\n#define sqlite3_column_name            sqlite3_api->column_name\n#define sqlite3_column_name16          sqlite3_api->column_name16\n#define sqlite3_column_origin_name     sqlite3_api->column_origin_name\n#define sqlite3_column_origin_name16   sqlite3_api->column_origin_name16\n#define sqlite3_column_table_name      sqlite3_api->column_table_name\n#define sqlite3_column_table_name16    sqlite3_api->column_table_name16\n#define sqlite3_column_text            sqlite3_api->column_text\n#define sqlite3_column_text16          sqlite3_api->column_text16\n#define sqlite3_column_type            sqlite3_api->column_type\n#define sqlite3_column_value           sqlite3_api->column_value\n#define sqlite3_commit_hook            sqlite3_api->commit_hook\n#define sqlite3_complete               sqlite3_api->complete\n#define sqlite3_complete16             sqlite3_api->complete16\n#define sqlite3_create_collation       sqlite3_api->create_collation\n#define sqlite3_create_collation16     sqlite3_api->create_collation16\n#define sqlite3_create_function        sqlite3_api->create_function\n#define sqlite3_create_function16      sqlite3_api->create_function16\n#define sqlite3_create_module          sqlite3_api->create_module\n#define sqlite3_create_module_v2       sqlite3_api->create_module_v2\n#define sqlite3_data_count             sqlite3_api->data_count\n#define sqlite3_db_handle              sqlite3_api->db_handle\n#define sqlite3_declare_vtab           sqlite3_api->declare_vtab\n#define sqlite3_enable_shared_cache    sqlite3_api->enable_shared_cache\n#define sqlite3_errcode                sqlite3_api->errcode\n#define sqlite3_errmsg                 sqlite3_api->errmsg\n#define sqlite3_errmsg16               sqlite3_api->errmsg16\n#define sqlite3_exec                   sqlite3_api->exec\n#ifndef SQLITE_OMIT_DEPRECATED\n#define sqlite3_expired                sqlite3_api->expired\n#endif\n#define sqlite3_finalize               sqlite3_api->finalize\n#define sqlite3_free                   sqlite3_api->free\n#define sqlite3_free_table             sqlite3_api->free_table\n#define sqlite3_get_autocommit         sqlite3_api->get_autocommit\n#define sqlite3_get_auxdata            sqlite3_api->get_auxdata\n#define sqlite3_get_table              sqlite3_api->get_table\n#ifndef SQLITE_OMIT_DEPRECATED\n#define sqlite3_global_recover         sqlite3_api->global_recover\n#endif\n#define sqlite3_interrupt              sqlite3_api->interruptx\n#define sqlite3_last_insert_rowid      sqlite3_api->last_insert_rowid\n#define sqlite3_libversion             sqlite3_api->libversion\n#define sqlite3_libversion_number      sqlite3_api->libversion_number\n#define sqlite3_malloc                 sqlite3_api->malloc\n#define sqlite3_mprintf                sqlite3_api->mprintf\n#define sqlite3_open                   sqlite3_api->open\n#define sqlite3_open16                 sqlite3_api->open16\n#define sqlite3_prepare                sqlite3_api->prepare\n#define sqlite3_prepare16              sqlite3_api->prepare16\n#define sqlite3_prepare_v2             sqlite3_api->prepare_v2\n#define sqlite3_prepare16_v2           sqlite3_api->prepare16_v2\n#define sqlite3_profile                sqlite3_api->profile\n#define sqlite3_progress_handler       sqlite3_api->progress_handler\n#define sqlite3_realloc                sqlite3_api->realloc\n#define sqlite3_reset                  sqlite3_api->reset\n#define sqlite3_result_blob            sqlite3_api->result_blob\n#define sqlite3_result_double          sqlite3_api->result_double\n#define sqlite3_result_error           sqlite3_api->result_error\n#define sqlite3_result_error16         sqlite3_api->result_error16\n#define sqlite3_result_int             sqlite3_api->result_int\n#define sqlite3_result_int64           sqlite3_api->result_int64\n#define sqlite3_result_null            sqlite3_api->result_null\n#define sqlite3_result_text            sqlite3_api->result_text\n#define sqlite3_result_text16          sqlite3_api->result_text16\n#define sqlite3_result_text16be        sqlite3_api->result_text16be\n#define sqlite3_result_text16le        sqlite3_api->result_text16le\n#define sqlite3_result_value           sqlite3_api->result_value\n#define sqlite3_rollback_hook          sqlite3_api->rollback_hook\n#define sqlite3_set_authorizer         sqlite3_api->set_authorizer\n#define sqlite3_set_auxdata            sqlite3_api->set_auxdata\n#define sqlite3_snprintf               sqlite3_api->xsnprintf\n#define sqlite3_step                   sqlite3_api->step\n#define sqlite3_table_column_metadata  sqlite3_api->table_column_metadata\n#define sqlite3_thread_cleanup         sqlite3_api->thread_cleanup\n#define sqlite3_total_changes          sqlite3_api->total_changes\n#define sqlite3_trace                  sqlite3_api->trace\n#ifndef SQLITE_OMIT_DEPRECATED\n#define sqlite3_transfer_bindings      sqlite3_api->transfer_bindings\n#endif\n#define sqlite3_update_hook            sqlite3_api->update_hook\n#define sqlite3_user_data              sqlite3_api->user_data\n#define sqlite3_value_blob             sqlite3_api->value_blob\n#define sqlite3_value_bytes            sqlite3_api->value_bytes\n#define sqlite3_value_bytes16          sqlite3_api->value_bytes16\n#define sqlite3_value_double           sqlite3_api->value_double\n#define sqlite3_value_int              sqlite3_api->value_int\n#define sqlite3_value_int64            sqlite3_api->value_int64\n#define sqlite3_value_numeric_type     sqlite3_api->value_numeric_type\n#define sqlite3_value_text             sqlite3_api->value_text\n#define sqlite3_value_text16           sqlite3_api->value_text16\n#define sqlite3_value_text16be         sqlite3_api->value_text16be\n#define sqlite3_value_text16le         sqlite3_api->value_text16le\n#define sqlite3_value_type             sqlite3_api->value_type\n#define sqlite3_vmprintf               sqlite3_api->vmprintf\n#define sqlite3_vsnprintf              sqlite3_api->xvsnprintf\n#define sqlite3_overload_function      sqlite3_api->overload_function\n#define sqlite3_prepare_v2             sqlite3_api->prepare_v2\n#define sqlite3_prepare16_v2           sqlite3_api->prepare16_v2\n#define sqlite3_clear_bindings         sqlite3_api->clear_bindings\n#define sqlite3_bind_zeroblob          sqlite3_api->bind_zeroblob\n#define sqlite3_blob_bytes             sqlite3_api->blob_bytes\n#define sqlite3_blob_close             sqlite3_api->blob_close\n#define sqlite3_blob_open              sqlite3_api->blob_open\n#define sqlite3_blob_read              sqlite3_api->blob_read\n#define sqlite3_blob_write             sqlite3_api->blob_write\n#define sqlite3_create_collation_v2    sqlite3_api->create_collation_v2\n#define sqlite3_file_control           sqlite3_api->file_control\n#define sqlite3_memory_highwater       sqlite3_api->memory_highwater\n#define sqlite3_memory_used            sqlite3_api->memory_used\n#define sqlite3_mutex_alloc            sqlite3_api->mutex_alloc\n#define sqlite3_mutex_enter            sqlite3_api->mutex_enter\n#define sqlite3_mutex_free             sqlite3_api->mutex_free\n#define sqlite3_mutex_leave            sqlite3_api->mutex_leave\n#define sqlite3_mutex_try              sqlite3_api->mutex_try\n#define sqlite3_open_v2                sqlite3_api->open_v2\n#define sqlite3_release_memory         sqlite3_api->release_memory\n#define sqlite3_result_error_nomem     sqlite3_api->result_error_nomem\n#define sqlite3_result_error_toobig    sqlite3_api->result_error_toobig\n#define sqlite3_sleep                  sqlite3_api->sleep\n#define sqlite3_soft_heap_limit        sqlite3_api->soft_heap_limit\n#define sqlite3_vfs_find               sqlite3_api->vfs_find\n#define sqlite3_vfs_register           sqlite3_api->vfs_register\n#define sqlite3_vfs_unregister         sqlite3_api->vfs_unregister\n#define sqlite3_threadsafe             sqlite3_api->xthreadsafe\n#define sqlite3_result_zeroblob        sqlite3_api->result_zeroblob\n#define sqlite3_result_error_code      sqlite3_api->result_error_code\n#define sqlite3_test_control           sqlite3_api->test_control\n#define sqlite3_randomness             sqlite3_api->randomness\n#define sqlite3_context_db_handle      sqlite3_api->context_db_handle\n#define sqlite3_extended_result_codes  sqlite3_api->extended_result_codes\n#define sqlite3_limit                  sqlite3_api->limit\n#define sqlite3_next_stmt              sqlite3_api->next_stmt\n#define sqlite3_sql                    sqlite3_api->sql\n#define sqlite3_status                 sqlite3_api->status\n#define sqlite3_backup_finish          sqlite3_api->backup_finish\n#define sqlite3_backup_init            sqlite3_api->backup_init\n#define sqlite3_backup_pagecount       sqlite3_api->backup_pagecount\n#define sqlite3_backup_remaining       sqlite3_api->backup_remaining\n#define sqlite3_backup_step            sqlite3_api->backup_step\n#define sqlite3_compileoption_get      sqlite3_api->compileoption_get\n#define sqlite3_compileoption_used     sqlite3_api->compileoption_used\n#define sqlite3_create_function_v2     sqlite3_api->create_function_v2\n#define sqlite3_db_config              sqlite3_api->db_config\n#define sqlite3_db_mutex               sqlite3_api->db_mutex\n#define sqlite3_db_status              sqlite3_api->db_status\n#define sqlite3_extended_errcode       sqlite3_api->extended_errcode\n#define sqlite3_log                    sqlite3_api->log\n#define sqlite3_soft_heap_limit64      sqlite3_api->soft_heap_limit64\n#define sqlite3_sourceid               sqlite3_api->sourceid\n#define sqlite3_stmt_status            sqlite3_api->stmt_status\n#define sqlite3_strnicmp               sqlite3_api->strnicmp\n#define sqlite3_unlock_notify          sqlite3_api->unlock_notify\n#define sqlite3_wal_autocheckpoint     sqlite3_api->wal_autocheckpoint\n#define sqlite3_wal_checkpoint         sqlite3_api->wal_checkpoint\n#define sqlite3_wal_hook               sqlite3_api->wal_hook\n#define sqlite3_blob_reopen            sqlite3_api->blob_reopen\n#define sqlite3_vtab_config            sqlite3_api->vtab_config\n#define sqlite3_vtab_on_conflict       sqlite3_api->vtab_on_conflict\n/* Version 3.7.16 and later */\n#define sqlite3_close_v2               sqlite3_api->close_v2\n#define sqlite3_db_filename            sqlite3_api->db_filename\n#define sqlite3_db_readonly            sqlite3_api->db_readonly\n#define sqlite3_db_release_memory      sqlite3_api->db_release_memory\n#define sqlite3_errstr                 sqlite3_api->errstr\n#define sqlite3_stmt_busy              sqlite3_api->stmt_busy\n#define sqlite3_stmt_readonly          sqlite3_api->stmt_readonly\n#define sqlite3_stricmp                sqlite3_api->stricmp\n#define sqlite3_uri_boolean            sqlite3_api->uri_boolean\n#define sqlite3_uri_int64              sqlite3_api->uri_int64\n#define sqlite3_uri_parameter          sqlite3_api->uri_parameter\n#define sqlite3_uri_vsnprintf          sqlite3_api->xvsnprintf\n#define sqlite3_wal_checkpoint_v2      sqlite3_api->wal_checkpoint_v2\n/* Version 3.8.7 and later */\n#define sqlite3_auto_extension         sqlite3_api->auto_extension\n#define sqlite3_bind_blob64            sqlite3_api->bind_blob64\n#define sqlite3_bind_text64            sqlite3_api->bind_text64\n#define sqlite3_cancel_auto_extension  sqlite3_api->cancel_auto_extension\n#define sqlite3_load_extension         sqlite3_api->load_extension\n#define sqlite3_malloc64               sqlite3_api->malloc64\n#define sqlite3_msize                  sqlite3_api->msize\n#define sqlite3_realloc64              sqlite3_api->realloc64\n#define sqlite3_reset_auto_extension   sqlite3_api->reset_auto_extension\n#define sqlite3_result_blob64          sqlite3_api->result_blob64\n#define sqlite3_result_text64          sqlite3_api->result_text64\n#define sqlite3_strglob                sqlite3_api->strglob\n/* Version 3.8.11 and later */\n#define sqlite3_value_dup              sqlite3_api->value_dup\n#define sqlite3_value_free             sqlite3_api->value_free\n#define sqlite3_result_zeroblob64      sqlite3_api->result_zeroblob64\n#define sqlite3_bind_zeroblob64        sqlite3_api->bind_zeroblob64\n/* Version 3.9.0 and later */\n#define sqlite3_value_subtype          sqlite3_api->value_subtype\n#define sqlite3_result_subtype         sqlite3_api->result_subtype\n/* Version 3.10.0 and later */\n#define sqlite3_status64               sqlite3_api->status64\n#define sqlite3_strlike                sqlite3_api->strlike\n#define sqlite3_db_cacheflush          sqlite3_api->db_cacheflush\n/* Version 3.12.0 and later */\n#define sqlite3_system_errno           sqlite3_api->system_errno\n/* Version 3.14.0 and later */\n#define sqlite3_trace_v2               sqlite3_api->trace_v2\n#define sqlite3_expanded_sql           sqlite3_api->expanded_sql\n/* Version 3.18.0 and later */\n#define sqlite3_set_last_insert_rowid  sqlite3_api->set_last_insert_rowid\n/* Version 3.20.0 and later */\n#define sqlite3_prepare_v3             sqlite3_api->prepare_v3\n#define sqlite3_prepare16_v3           sqlite3_api->prepare16_v3\n#define sqlite3_bind_pointer           sqlite3_api->bind_pointer\n#define sqlite3_result_pointer         sqlite3_api->result_pointer\n#define sqlite3_value_pointer          sqlite3_api->value_pointer\n/* Version 3.22.0 and later */\n#define sqlite3_vtab_nochange          sqlite3_api->vtab_nochange\n#define sqlite3_value_nochange         sqlite3_api->value_nochange\n#define sqlite3_vtab_collation         sqlite3_api->vtab_collation\n/* Version 3.24.0 and later */\n#define sqlite3_keyword_count          sqlite3_api->keyword_count\n#define sqlite3_keyword_name           sqlite3_api->keyword_name\n#define sqlite3_keyword_check          sqlite3_api->keyword_check\n#define sqlite3_str_new                sqlite3_api->str_new\n#define sqlite3_str_finish             sqlite3_api->str_finish\n#define sqlite3_str_appendf            sqlite3_api->str_appendf\n#define sqlite3_str_vappendf           sqlite3_api->str_vappendf\n#define sqlite3_str_append             sqlite3_api->str_append\n#define sqlite3_str_appendall          sqlite3_api->str_appendall\n#define sqlite3_str_appendchar         sqlite3_api->str_appendchar\n#define sqlite3_str_reset              sqlite3_api->str_reset\n#define sqlite3_str_errcode            sqlite3_api->str_errcode\n#define sqlite3_str_length             sqlite3_api->str_length\n#define sqlite3_str_value              sqlite3_api->str_value\n/* Version 3.25.0 and later */\n#define sqlite3_create_window_function sqlite3_api->create_window_function\n/* Version 3.26.0 and later */\n#define sqlite3_normalized_sql         sqlite3_api->normalized_sql\n\n/* SQLCipher APIs */\n#ifdef SQLITE_HAS_CODEC\n#define sqlite3_key                    sqlite3_api->sqlcipher->key\n#define sqlite3_key_v2                 sqlite3_api->sqlcipher->key_v2\n#define sqlite3_rekey                  sqlite3_api->sqlcipher->rekey\n#define sqlite3_rekey_v2               sqlite3_api->sqlcipher->rekey_v2\n#define sqlcipher_register_provider    sqlite3_api->sqlcipher->register_provider\n#define sqlcipher_get_provider         sqlite3_api->sqlcipher->get_provider\n#ifdef SQLCIPHER_CRYPTO_CUSTOM\n#define sqlcipher_register_custom_provider    sqlite3_api->sqlcipher->register_custom_provider\n#define sqlcipher_unregister_custom_provider  sqlite3_api->sqlcipher->unregister_custom_provider\n#define sqlcipher_get_fallback_provider       sqlite3_api->sqlcipher->get_fallback_provider\n#endif\n#endif\n\n#endif /* !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION) */\n\n#if !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION)\n  /* This case when the file really is being compiled as a loadable \n  ** extension */\n# define SQLITE_EXTENSION_INIT1     const sqlite3_api_routines *sqlite3_api=0;\n# define SQLITE_EXTENSION_INIT2(v)  sqlite3_api=v;\n# define SQLITE_EXTENSION_INIT3     \\\n    extern const sqlite3_api_routines *sqlite3_api;\n#else\n  /* This case when the file is being statically linked into the \n  ** application */\n# define SQLITE_EXTENSION_INIT1     /*no-op*/\n# define SQLITE_EXTENSION_INIT2(v)  (void)v; /* unused parameter */\n# define SQLITE_EXTENSION_INIT3     /*no-op*/\n#endif\n\n#endif /* SQLITE3EXT_H */\n\n/************** End of sqlite3ext.h ******************************************/\n/************** Continuing where we left off in loadext.c ********************/\n/* #include \"sqliteInt.h\" */\n\n#ifndef SQLITE_OMIT_LOAD_EXTENSION\n/*\n** Some API routines are omitted when various features are\n** excluded from a build of SQLite.  Substitute a NULL pointer\n** for any missing APIs.\n*/\n#ifndef SQLITE_ENABLE_COLUMN_METADATA\n# define sqlite3_column_database_name   0\n# define sqlite3_column_database_name16 0\n# define sqlite3_column_table_name      0\n# define sqlite3_column_table_name16    0\n# define sqlite3_column_origin_name     0\n# define sqlite3_column_origin_name16   0\n#endif\n\n#ifdef SQLITE_OMIT_AUTHORIZATION\n# define sqlite3_set_authorizer         0\n#endif\n\n#ifdef SQLITE_OMIT_UTF16\n# define sqlite3_bind_text16            0\n# define sqlite3_collation_needed16     0\n# define sqlite3_column_decltype16      0\n# define sqlite3_column_name16          0\n# define sqlite3_column_text16          0\n# define sqlite3_complete16             0\n# define sqlite3_create_collation16     0\n# define sqlite3_create_function16      0\n# define sqlite3_errmsg16               0\n# define sqlite3_open16                 0\n# define sqlite3_prepare16              0\n# define sqlite3_prepare16_v2           0\n# define sqlite3_prepare16_v3           0\n# define sqlite3_result_error16         0\n# define sqlite3_result_text16          0\n# define sqlite3_result_text16be        0\n# define sqlite3_result_text16le        0\n# define sqlite3_value_text16           0\n# define sqlite3_value_text16be         0\n# define sqlite3_value_text16le         0\n# define sqlite3_column_database_name16 0\n# define sqlite3_column_table_name16    0\n# define sqlite3_column_origin_name16   0\n#endif\n\n#ifdef SQLITE_OMIT_COMPLETE\n# define sqlite3_complete 0\n# define sqlite3_complete16 0\n#endif\n\n#ifdef SQLITE_OMIT_DECLTYPE\n# define sqlite3_column_decltype16      0\n# define sqlite3_column_decltype        0\n#endif\n\n#ifdef SQLITE_OMIT_PROGRESS_CALLBACK\n# define sqlite3_progress_handler 0\n#endif\n\n#ifdef SQLITE_OMIT_VIRTUALTABLE\n# define sqlite3_create_module 0\n# define sqlite3_create_module_v2 0\n# define sqlite3_declare_vtab 0\n# define sqlite3_vtab_config 0\n# define sqlite3_vtab_on_conflict 0\n# define sqlite3_vtab_collation 0\n#endif\n\n#ifdef SQLITE_OMIT_SHARED_CACHE\n# define sqlite3_enable_shared_cache 0\n#endif\n\n#if defined(SQLITE_OMIT_TRACE) || defined(SQLITE_OMIT_DEPRECATED)\n# define sqlite3_profile       0\n# define sqlite3_trace         0\n#endif\n\n#ifdef SQLITE_OMIT_GET_TABLE\n# define sqlite3_free_table    0\n# define sqlite3_get_table     0\n#endif\n\n#ifdef SQLITE_OMIT_INCRBLOB\n#define sqlite3_bind_zeroblob  0\n#define sqlite3_blob_bytes     0\n#define sqlite3_blob_close     0\n#define sqlite3_blob_open      0\n#define sqlite3_blob_read      0\n#define sqlite3_blob_write     0\n#define sqlite3_blob_reopen    0\n#endif\n\n#if defined(SQLITE_OMIT_TRACE)\n# define sqlite3_trace_v2      0\n#endif\n\n/*\n** The following structure contains pointers to all SQLite API routines.\n** A pointer to this structure is passed into extensions when they are\n** loaded so that the extension can make calls back into the SQLite\n** library.\n**\n** When adding new APIs, add them to the bottom of this structure\n** in order to preserve backwards compatibility.\n**\n** Extensions that use newer APIs should first call the\n** sqlite3_libversion_number() to make sure that the API they\n** intend to use is supported by the library.  Extensions should\n** also check to make sure that the pointer to the function is\n** not NULL before calling it.\n*/\n#ifdef SQLITE_HAS_CODEC\nstatic const sqlcipher_api_routines sqlcipherApis = {\n  sqlcipher_register_provider,\n  sqlcipher_get_provider,\n  sqlite3_key,\n  sqlite3_key_v2,\n  sqlite3_rekey,\n  sqlite3_rekey_v2,\n\n#ifdef SQLCIPHER_CRYPTO_CUSTOM\n  sqlcipher_register_custom_provider,\n  sqlcipher_unregister_custom_provider,\n  sqlcipher_get_fallback_provider,\n#else\n  0,\n  0,\n  0,\n#endif\n};\n#endif\n\nstatic const sqlite3_api_routines sqlite3Apis = {\n  sqlite3_aggregate_context,\n#ifndef SQLITE_OMIT_DEPRECATED\n  sqlite3_aggregate_count,\n#else\n  0,\n#endif\n  sqlite3_bind_blob,\n  sqlite3_bind_double,\n  sqlite3_bind_int,\n  sqlite3_bind_int64,\n  sqlite3_bind_null,\n  sqlite3_bind_parameter_count,\n  sqlite3_bind_parameter_index,\n  sqlite3_bind_parameter_name,\n  sqlite3_bind_text,\n  sqlite3_bind_text16,\n  sqlite3_bind_value,\n  sqlite3_busy_handler,\n  sqlite3_busy_timeout,\n  sqlite3_changes,\n  sqlite3_close,\n  sqlite3_collation_needed,\n  sqlite3_collation_needed16,\n  sqlite3_column_blob,\n  sqlite3_column_bytes,\n  sqlite3_column_bytes16,\n  sqlite3_column_count,\n  sqlite3_column_database_name,\n  sqlite3_column_database_name16,\n  sqlite3_column_decltype,\n  sqlite3_column_decltype16,\n  sqlite3_column_double,\n  sqlite3_column_int,\n  sqlite3_column_int64,\n  sqlite3_column_name,\n  sqlite3_column_name16,\n  sqlite3_column_origin_name,\n  sqlite3_column_origin_name16,\n  sqlite3_column_table_name,\n  sqlite3_column_table_name16,\n  sqlite3_column_text,\n  sqlite3_column_text16,\n  sqlite3_column_type,\n  sqlite3_column_value,\n  sqlite3_commit_hook,\n  sqlite3_complete,\n  sqlite3_complete16,\n  sqlite3_create_collation,\n  sqlite3_create_collation16,\n  sqlite3_create_function,\n  sqlite3_create_function16,\n  sqlite3_create_module,\n  sqlite3_data_count,\n  sqlite3_db_handle,\n  sqlite3_declare_vtab,\n  sqlite3_enable_shared_cache,\n  sqlite3_errcode,\n  sqlite3_errmsg,\n  sqlite3_errmsg16,\n  sqlite3_exec,\n#ifndef SQLITE_OMIT_DEPRECATED\n  sqlite3_expired,\n#else\n  0,\n#endif\n  sqlite3_finalize,\n  sqlite3_free,\n  sqlite3_free_table,\n  sqlite3_get_autocommit,\n  sqlite3_get_auxdata,\n  sqlite3_get_table,\n\n#ifdef SQLITE_HAS_CODEC  \n  /* Was sqlite3_global_recover(), but that function is deprecated.\n     We 'steal' this slot to place pointers to SQLCipher APIs. */\n  &sqlcipherApis,\n#else\n  0,\n#endif\n  \n  sqlite3_interrupt,\n  sqlite3_last_insert_rowid,\n  sqlite3_libversion,\n  sqlite3_libversion_number,\n  sqlite3_malloc,\n  sqlite3_mprintf,\n  sqlite3_open,\n  sqlite3_open16,\n  sqlite3_prepare,\n  sqlite3_prepare16,\n  sqlite3_profile,\n  sqlite3_progress_handler,\n  sqlite3_realloc,\n  sqlite3_reset,\n  sqlite3_result_blob,\n  sqlite3_result_double,\n  sqlite3_result_error,\n  sqlite3_result_error16,\n  sqlite3_result_int,\n  sqlite3_result_int64,\n  sqlite3_result_null,\n  sqlite3_result_text,\n  sqlite3_result_text16,\n  sqlite3_result_text16be,\n  sqlite3_result_text16le,\n  sqlite3_result_value,\n  sqlite3_rollback_hook,\n  sqlite3_set_authorizer,\n  sqlite3_set_auxdata,\n  sqlite3_snprintf,\n  sqlite3_step,\n  sqlite3_table_column_metadata,\n#ifndef SQLITE_OMIT_DEPRECATED\n  sqlite3_thread_cleanup,\n#else\n  0,\n#endif\n  sqlite3_total_changes,\n  sqlite3_trace,\n#ifndef SQLITE_OMIT_DEPRECATED\n  sqlite3_transfer_bindings,\n#else\n  0,\n#endif\n  sqlite3_update_hook,\n  sqlite3_user_data,\n  sqlite3_value_blob,\n  sqlite3_value_bytes,\n  sqlite3_value_bytes16,\n  sqlite3_value_double,\n  sqlite3_value_int,\n  sqlite3_value_int64,\n  sqlite3_value_numeric_type,\n  sqlite3_value_text,\n  sqlite3_value_text16,\n  sqlite3_value_text16be,\n  sqlite3_value_text16le,\n  sqlite3_value_type,\n  sqlite3_vmprintf,\n  /*\n  ** The original API set ends here.  All extensions can call any\n  ** of the APIs above provided that the pointer is not NULL.  But\n  ** before calling APIs that follow, extension should check the\n  ** sqlite3_libversion_number() to make sure they are dealing with\n  ** a library that is new enough to support that API.\n  *************************************************************************\n  */\n  sqlite3_overload_function,\n\n  /*\n  ** Added after 3.3.13\n  */\n  sqlite3_prepare_v2,\n  sqlite3_prepare16_v2,\n  sqlite3_clear_bindings,\n\n  /*\n  ** Added for 3.4.1\n  */\n  sqlite3_create_module_v2,\n\n  /*\n  ** Added for 3.5.0\n  */\n  sqlite3_bind_zeroblob,\n  sqlite3_blob_bytes,\n  sqlite3_blob_close,\n  sqlite3_blob_open,\n  sqlite3_blob_read,\n  sqlite3_blob_write,\n  sqlite3_create_collation_v2,\n  sqlite3_file_control,\n  sqlite3_memory_highwater,\n  sqlite3_memory_used,\n#ifdef SQLITE_MUTEX_OMIT\n  0, \n  0, \n  0,\n  0,\n  0,\n#else\n  sqlite3_mutex_alloc,\n  sqlite3_mutex_enter,\n  sqlite3_mutex_free,\n  sqlite3_mutex_leave,\n  sqlite3_mutex_try,\n#endif\n  sqlite3_open_v2,\n  sqlite3_release_memory,\n  sqlite3_result_error_nomem,\n  sqlite3_result_error_toobig,\n  sqlite3_sleep,\n  sqlite3_soft_heap_limit,\n  sqlite3_vfs_find,\n  sqlite3_vfs_register,\n  sqlite3_vfs_unregister,\n\n  /*\n  ** Added for 3.5.8\n  */\n  sqlite3_threadsafe,\n  sqlite3_result_zeroblob,\n  sqlite3_result_error_code,\n  sqlite3_test_control,\n  sqlite3_randomness,\n  sqlite3_context_db_handle,\n\n  /*\n  ** Added for 3.6.0\n  */\n  sqlite3_extended_result_codes,\n  sqlite3_limit,\n  sqlite3_next_stmt,\n  sqlite3_sql,\n  sqlite3_status,\n\n  /*\n  ** Added for 3.7.4\n  */\n  sqlite3_backup_finish,\n  sqlite3_backup_init,\n  sqlite3_backup_pagecount,\n  sqlite3_backup_remaining,\n  sqlite3_backup_step,\n#ifndef SQLITE_OMIT_COMPILEOPTION_DIAGS\n  sqlite3_compileoption_get,\n  sqlite3_compileoption_used,\n#else\n  0,\n  0,\n#endif\n  sqlite3_create_function_v2,\n  sqlite3_db_config,\n  sqlite3_db_mutex,\n  sqlite3_db_status,\n  sqlite3_extended_errcode,\n  sqlite3_log,\n  sqlite3_soft_heap_limit64,\n  sqlite3_sourceid,\n  sqlite3_stmt_status,\n  sqlite3_strnicmp,\n#ifdef SQLITE_ENABLE_UNLOCK_NOTIFY\n  sqlite3_unlock_notify,\n#else\n  0,\n#endif\n#ifndef SQLITE_OMIT_WAL\n  sqlite3_wal_autocheckpoint,\n  sqlite3_wal_checkpoint,\n  sqlite3_wal_hook,\n#else\n  0,\n  0,\n  0,\n#endif\n  sqlite3_blob_reopen,\n  sqlite3_vtab_config,\n  sqlite3_vtab_on_conflict,\n  sqlite3_close_v2,\n  sqlite3_db_filename,\n  sqlite3_db_readonly,\n  sqlite3_db_release_memory,\n  sqlite3_errstr,\n  sqlite3_stmt_busy,\n  sqlite3_stmt_readonly,\n  sqlite3_stricmp,\n  sqlite3_uri_boolean,\n  sqlite3_uri_int64,\n  sqlite3_uri_parameter,\n  sqlite3_vsnprintf,\n  sqlite3_wal_checkpoint_v2,\n  /* Version 3.8.7 and later */\n  sqlite3_auto_extension,\n  sqlite3_bind_blob64,\n  sqlite3_bind_text64,\n  sqlite3_cancel_auto_extension,\n  sqlite3_load_extension,\n  sqlite3_malloc64,\n  sqlite3_msize,\n  sqlite3_realloc64,\n  sqlite3_reset_auto_extension,\n  sqlite3_result_blob64,\n  sqlite3_result_text64,\n  sqlite3_strglob,\n  /* Version 3.8.11 and later */\n  (sqlite3_value*(*)(const sqlite3_value*))sqlite3_value_dup,\n  sqlite3_value_free,\n  sqlite3_result_zeroblob64,\n  sqlite3_bind_zeroblob64,\n  /* Version 3.9.0 and later */\n  sqlite3_value_subtype,\n  sqlite3_result_subtype,\n  /* Version 3.10.0 and later */\n  sqlite3_status64,\n  sqlite3_strlike,\n  sqlite3_db_cacheflush,\n  /* Version 3.12.0 and later */\n  sqlite3_system_errno,\n  /* Version 3.14.0 and later */\n  sqlite3_trace_v2,\n  sqlite3_expanded_sql,\n  /* Version 3.18.0 and later */\n  sqlite3_set_last_insert_rowid,\n  /* Version 3.20.0 and later */\n  sqlite3_prepare_v3,\n  sqlite3_prepare16_v3,\n  sqlite3_bind_pointer,\n  sqlite3_result_pointer,\n  sqlite3_value_pointer,\n  /* Version 3.22.0 and later */\n  sqlite3_vtab_nochange,\n  sqlite3_value_nochange,\n  sqlite3_vtab_collation,\n  /* Version 3.24.0 and later */\n  sqlite3_keyword_count,\n  sqlite3_keyword_name,\n  sqlite3_keyword_check,\n  sqlite3_str_new,\n  sqlite3_str_finish,\n  sqlite3_str_appendf,\n  sqlite3_str_vappendf,\n  sqlite3_str_append,\n  sqlite3_str_appendall,\n  sqlite3_str_appendchar,\n  sqlite3_str_reset,\n  sqlite3_str_errcode,\n  sqlite3_str_length,\n  sqlite3_str_value,\n  /* Version 3.25.0 and later */\n  sqlite3_create_window_function,\n  /* Version 3.26.0 and later */\n#ifdef SQLITE_ENABLE_NORMALIZE\n  sqlite3_normalized_sql\n#else\n  0\n#endif\n};\n\n/*\n** Attempt to load an SQLite extension library contained in the file\n** zFile.  The entry point is zProc.  zProc may be 0 in which case a\n** default entry point name (sqlite3_extension_init) is used.  Use\n** of the default name is recommended.\n**\n** Return SQLITE_OK on success and SQLITE_ERROR if something goes wrong.\n**\n** If an error occurs and pzErrMsg is not 0, then fill *pzErrMsg with \n** error message text.  The calling function should free this memory\n** by calling sqlite3DbFree(db, ).\n*/\nstatic int sqlite3LoadExtension(\n  sqlite3 *db,          /* Load the extension into this database connection */\n  const char *zFile,    /* Name of the shared library containing extension */\n  const char *zProc,    /* Entry point.  Use \"sqlite3_extension_init\" if 0 */\n  char **pzErrMsg       /* Put error message here if not 0 */\n){\n  sqlite3_vfs *pVfs = db->pVfs;\n  void *handle;\n  sqlite3_loadext_entry xInit;\n  char *zErrmsg = 0;\n  const char *zEntry;\n  char *zAltEntry = 0;\n  void **aHandle;\n  u64 nMsg = 300 + sqlite3Strlen30(zFile);\n  int ii;\n  int rc;\n\n  /* Shared library endings to try if zFile cannot be loaded as written */\n  static const char *azEndings[] = {\n#if SQLITE_OS_WIN\n     \"dll\"   \n#elif defined(__APPLE__)\n     \"dylib\"\n#else\n     \"so\"\n#endif\n  };\n\n\n  if( pzErrMsg ) *pzErrMsg = 0;\n\n  /* Ticket #1863.  To avoid a creating security problems for older\n  ** applications that relink against newer versions of SQLite, the\n  ** ability to run load_extension is turned off by default.  One\n  ** must call either sqlite3_enable_load_extension(db) or\n  ** sqlite3_db_config(db, SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION, 1, 0)\n  ** to turn on extension loading.\n  */\n  if( (db->flags & SQLITE_LoadExtension)==0 ){\n    if( pzErrMsg ){\n      *pzErrMsg = sqlite3_mprintf(\"not authorized\");\n    }\n    return SQLITE_ERROR;\n  }\n\n  zEntry = zProc ? zProc : \"sqlite3_extension_init\";\n\n  handle = sqlite3OsDlOpen(pVfs, zFile);\n#if SQLITE_OS_UNIX || SQLITE_OS_WIN\n  for(ii=0; ii<ArraySize(azEndings) && handle==0; ii++){\n    char *zAltFile = sqlite3_mprintf(\"%s.%s\", zFile, azEndings[ii]);\n    if( zAltFile==0 ) return SQLITE_NOMEM_BKPT;\n    handle = sqlite3OsDlOpen(pVfs, zAltFile);\n    sqlite3_free(zAltFile);\n  }\n#endif\n  if( handle==0 ){\n    if( pzErrMsg ){\n      *pzErrMsg = zErrmsg = sqlite3_malloc64(nMsg);\n      if( zErrmsg ){\n        sqlite3_snprintf(nMsg, zErrmsg, \n            \"unable to open shared library [%s]\", zFile);\n        sqlite3OsDlError(pVfs, nMsg-1, zErrmsg);\n      }\n    }\n    return SQLITE_ERROR;\n  }\n  xInit = (sqlite3_loadext_entry)sqlite3OsDlSym(pVfs, handle, zEntry);\n\n  /* If no entry point was specified and the default legacy\n  ** entry point name \"sqlite3_extension_init\" was not found, then\n  ** construct an entry point name \"sqlite3_X_init\" where the X is\n  ** replaced by the lowercase value of every ASCII alphabetic \n  ** character in the filename after the last \"/\" upto the first \".\",\n  ** and eliding the first three characters if they are \"lib\".  \n  ** Examples:\n  **\n  **    /usr/local/lib/libExample5.4.3.so ==>  sqlite3_example_init\n  **    C:/lib/mathfuncs.dll              ==>  sqlite3_mathfuncs_init\n  */\n  if( xInit==0 && zProc==0 ){\n    int iFile, iEntry, c;\n    int ncFile = sqlite3Strlen30(zFile);\n    zAltEntry = sqlite3_malloc64(ncFile+30);\n    if( zAltEntry==0 ){\n      sqlite3OsDlClose(pVfs, handle);\n      return SQLITE_NOMEM_BKPT;\n    }\n    memcpy(zAltEntry, \"sqlite3_\", 8);\n    for(iFile=ncFile-1; iFile>=0 && zFile[iFile]!='/'; iFile--){}\n    iFile++;\n    if( sqlite3_strnicmp(zFile+iFile, \"lib\", 3)==0 ) iFile += 3;\n    for(iEntry=8; (c = zFile[iFile])!=0 && c!='.'; iFile++){\n      if( sqlite3Isalpha(c) ){\n        zAltEntry[iEntry++] = (char)sqlite3UpperToLower[(unsigned)c];\n      }\n    }\n    memcpy(zAltEntry+iEntry, \"_init\", 6);\n    zEntry = zAltEntry;\n    xInit = (sqlite3_loadext_entry)sqlite3OsDlSym(pVfs, handle, zEntry);\n  }\n  if( xInit==0 ){\n    if( pzErrMsg ){\n      nMsg += sqlite3Strlen30(zEntry);\n      *pzErrMsg = zErrmsg = sqlite3_malloc64(nMsg);\n      if( zErrmsg ){\n        sqlite3_snprintf(nMsg, zErrmsg,\n            \"no entry point [%s] in shared library [%s]\", zEntry, zFile);\n        sqlite3OsDlError(pVfs, nMsg-1, zErrmsg);\n      }\n    }\n    sqlite3OsDlClose(pVfs, handle);\n    sqlite3_free(zAltEntry);\n    return SQLITE_ERROR;\n  }\n  sqlite3_free(zAltEntry);\n  rc = xInit(db, &zErrmsg, &sqlite3Apis);\n  if( rc ){\n    if( rc==SQLITE_OK_LOAD_PERMANENTLY ) return SQLITE_OK;\n    if( pzErrMsg ){\n      *pzErrMsg = sqlite3_mprintf(\"error during initialization: %s\", zErrmsg);\n    }\n    sqlite3_free(zErrmsg);\n    sqlite3OsDlClose(pVfs, handle);\n    return SQLITE_ERROR;\n  }\n\n  /* Append the new shared library handle to the db->aExtension array. */\n  aHandle = sqlite3DbMallocZero(db, sizeof(handle)*(db->nExtension+1));\n  if( aHandle==0 ){\n    return SQLITE_NOMEM_BKPT;\n  }\n  if( db->nExtension>0 ){\n    memcpy(aHandle, db->aExtension, sizeof(handle)*db->nExtension);\n  }\n  sqlite3DbFree(db, db->aExtension);\n  db->aExtension = aHandle;\n\n  db->aExtension[db->nExtension++] = handle;\n  return SQLITE_OK;\n}\nSQLITE_API int sqlite3_load_extension(\n  sqlite3 *db,          /* Load the extension into this database connection */\n  const char *zFile,    /* Name of the shared library containing extension */\n  const char *zProc,    /* Entry point.  Use \"sqlite3_extension_init\" if 0 */\n  char **pzErrMsg       /* Put error message here if not 0 */\n){\n  int rc;\n  sqlite3_mutex_enter(db->mutex);\n  rc = sqlite3LoadExtension(db, zFile, zProc, pzErrMsg);\n  rc = sqlite3ApiExit(db, rc);\n  sqlite3_mutex_leave(db->mutex);\n  return rc;\n}\n\n/*\n** Call this routine when the database connection is closing in order\n** to clean up loaded extensions\n*/\nSQLITE_PRIVATE void sqlite3CloseExtensions(sqlite3 *db){\n  int i;\n  assert( sqlite3_mutex_held(db->mutex) );\n  for(i=0; i<db->nExtension; i++){\n    sqlite3OsDlClose(db->pVfs, db->aExtension[i]);\n  }\n  sqlite3DbFree(db, db->aExtension);\n}\n\n/*\n** Enable or disable extension loading.  Extension loading is disabled by\n** default so as not to open security holes in older applications.\n*/\nSQLITE_API int sqlite3_enable_load_extension(sqlite3 *db, int onoff){\n  sqlite3_mutex_enter(db->mutex);\n  if( onoff ){\n    db->flags |= SQLITE_LoadExtension|SQLITE_LoadExtFunc;\n  }else{\n    db->flags &= ~(u64)(SQLITE_LoadExtension|SQLITE_LoadExtFunc);\n  }\n  sqlite3_mutex_leave(db->mutex);\n  return SQLITE_OK;\n}\n\n#endif /* !defined(SQLITE_OMIT_LOAD_EXTENSION) */\n\n/*\n** The following object holds the list of automatically loaded\n** extensions.\n**\n** This list is shared across threads.  The SQLITE_MUTEX_STATIC_MASTER\n** mutex must be held while accessing this list.\n*/\ntypedef struct sqlite3AutoExtList sqlite3AutoExtList;\nstatic SQLITE_WSD struct sqlite3AutoExtList {\n  u32 nExt;              /* Number of entries in aExt[] */          \n  void (**aExt)(void);   /* Pointers to the extension init functions */\n} sqlite3Autoext = { 0, 0 };\n\n/* The \"wsdAutoext\" macro will resolve to the autoextension\n** state vector.  If writable static data is unsupported on the target,\n** we have to locate the state vector at run-time.  In the more common\n** case where writable static data is supported, wsdStat can refer directly\n** to the \"sqlite3Autoext\" state vector declared above.\n*/\n#ifdef SQLITE_OMIT_WSD\n# define wsdAutoextInit \\\n  sqlite3AutoExtList *x = &GLOBAL(sqlite3AutoExtList,sqlite3Autoext)\n# define wsdAutoext x[0]\n#else\n# define wsdAutoextInit\n# define wsdAutoext sqlite3Autoext\n#endif\n\n\n/*\n** Register a statically linked extension that is automatically\n** loaded by every new database connection.\n*/\nSQLITE_API int sqlite3_auto_extension(\n  void (*xInit)(void)\n){\n  int rc = SQLITE_OK;\n#ifndef SQLITE_OMIT_AUTOINIT\n  rc = sqlite3_initialize();\n  if( rc ){\n    return rc;\n  }else\n#endif\n  {\n    u32 i;\n#if SQLITE_THREADSAFE\n    sqlite3_mutex *mutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER);\n#endif\n    wsdAutoextInit;\n    sqlite3_mutex_enter(mutex);\n    for(i=0; i<wsdAutoext.nExt; i++){\n      if( wsdAutoext.aExt[i]==xInit ) break;\n    }\n    if( i==wsdAutoext.nExt ){\n      u64 nByte = (wsdAutoext.nExt+1)*sizeof(wsdAutoext.aExt[0]);\n      void (**aNew)(void);\n      aNew = sqlite3_realloc64(wsdAutoext.aExt, nByte);\n      if( aNew==0 ){\n        rc = SQLITE_NOMEM_BKPT;\n      }else{\n        wsdAutoext.aExt = aNew;\n        wsdAutoext.aExt[wsdAutoext.nExt] = xInit;\n        wsdAutoext.nExt++;\n      }\n    }\n    sqlite3_mutex_leave(mutex);\n    assert( (rc&0xff)==rc );\n    return rc;\n  }\n}\n\n/*\n** Cancel a prior call to sqlite3_auto_extension.  Remove xInit from the\n** set of routines that is invoked for each new database connection, if it\n** is currently on the list.  If xInit is not on the list, then this\n** routine is a no-op.\n**\n** Return 1 if xInit was found on the list and removed.  Return 0 if xInit\n** was not on the list.\n*/\nSQLITE_API int sqlite3_cancel_auto_extension(\n  void (*xInit)(void)\n){\n#if SQLITE_THREADSAFE\n  sqlite3_mutex *mutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER);\n#endif\n  int i;\n  int n = 0;\n  wsdAutoextInit;\n  sqlite3_mutex_enter(mutex);\n  for(i=(int)wsdAutoext.nExt-1; i>=0; i--){\n    if( wsdAutoext.aExt[i]==xInit ){\n      wsdAutoext.nExt--;\n      wsdAutoext.aExt[i] = wsdAutoext.aExt[wsdAutoext.nExt];\n      n++;\n      break;\n    }\n  }\n  sqlite3_mutex_leave(mutex);\n  return n;\n}\n\n/*\n** Reset the automatic extension loading mechanism.\n*/\nSQLITE_API void sqlite3_reset_auto_extension(void){\n#ifndef SQLITE_OMIT_AUTOINIT\n  if( sqlite3_initialize()==SQLITE_OK )\n#endif\n  {\n#if SQLITE_THREADSAFE\n    sqlite3_mutex *mutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER);\n#endif\n    wsdAutoextInit;\n    sqlite3_mutex_enter(mutex);\n    sqlite3_free(wsdAutoext.aExt);\n    wsdAutoext.aExt = 0;\n    wsdAutoext.nExt = 0;\n    sqlite3_mutex_leave(mutex);\n  }\n}\n\n/*\n** Load all automatic extensions.\n**\n** If anything goes wrong, set an error in the database connection.\n*/\nSQLITE_PRIVATE void sqlite3AutoLoadExtensions(sqlite3 *db){\n  u32 i;\n  int go = 1;\n  int rc;\n  sqlite3_loadext_entry xInit;\n\n  wsdAutoextInit;\n  if( wsdAutoext.nExt==0 ){\n    /* Common case: early out without every having to acquire a mutex */\n    return;\n  }\n  for(i=0; go; i++){\n    char *zErrmsg;\n#if SQLITE_THREADSAFE\n    sqlite3_mutex *mutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER);\n#endif\n#ifdef SQLITE_OMIT_LOAD_EXTENSION\n    const sqlite3_api_routines *pThunk = 0;\n#else\n    const sqlite3_api_routines *pThunk = &sqlite3Apis;\n#endif\n    sqlite3_mutex_enter(mutex);\n    if( i>=wsdAutoext.nExt ){\n      xInit = 0;\n      go = 0;\n    }else{\n      xInit = (sqlite3_loadext_entry)wsdAutoext.aExt[i];\n    }\n    sqlite3_mutex_leave(mutex);\n    zErrmsg = 0;\n    if( xInit && (rc = xInit(db, &zErrmsg, pThunk))!=0 ){\n      sqlite3ErrorWithMsg(db, rc,\n            \"automatic extension loading failed: %s\", zErrmsg);\n      go = 0;\n    }\n    sqlite3_free(zErrmsg);\n  }\n}\n\n/************** End of loadext.c *********************************************/\n/************** Begin file pragma.c ******************************************/\n/*\n** 2003 April 6\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This file contains code used to implement the PRAGMA command.\n*/\n/* #include \"sqliteInt.h\" */\n\n#if !defined(SQLITE_ENABLE_LOCKING_STYLE)\n#  if defined(__APPLE__)\n#    define SQLITE_ENABLE_LOCKING_STYLE 1\n#  else\n#    define SQLITE_ENABLE_LOCKING_STYLE 0\n#  endif\n#endif\n\n/***************************************************************************\n** The \"pragma.h\" include file is an automatically generated file that\n** that includes the PragType_XXXX macro definitions and the aPragmaName[]\n** object.  This ensures that the aPragmaName[] table is arranged in\n** lexicographical order to facility a binary search of the pragma name.\n** Do not edit pragma.h directly.  Edit and rerun the script in at \n** ../tool/mkpragmatab.tcl. */\n/************** Include pragma.h in the middle of pragma.c *******************/\n/************** Begin file pragma.h ******************************************/\n/* DO NOT EDIT!\n** This file is automatically generated by the script at\n** ../tool/mkpragmatab.tcl.  To update the set of pragmas, edit\n** that script and rerun it.\n*/\n\n/* The various pragma types */\n#define PragTyp_HEADER_VALUE                   0\n#define PragTyp_AUTO_VACUUM                    1\n#define PragTyp_FLAG                           2\n#define PragTyp_BUSY_TIMEOUT                   3\n#define PragTyp_CACHE_SIZE                     4\n#define PragTyp_CACHE_SPILL                    5\n#define PragTyp_CASE_SENSITIVE_LIKE            6\n#define PragTyp_COLLATION_LIST                 7\n#define PragTyp_COMPILE_OPTIONS                8\n#define PragTyp_DATA_STORE_DIRECTORY           9\n#define PragTyp_DATABASE_LIST                 10\n#define PragTyp_DEFAULT_CACHE_SIZE            11\n#define PragTyp_ENCODING                      12\n#define PragTyp_FOREIGN_KEY_CHECK             13\n#define PragTyp_FOREIGN_KEY_LIST              14\n#define PragTyp_FUNCTION_LIST                 15\n#define PragTyp_INCREMENTAL_VACUUM            16\n#define PragTyp_INDEX_INFO                    17\n#define PragTyp_INDEX_LIST                    18\n#define PragTyp_INTEGRITY_CHECK               19\n#define PragTyp_JOURNAL_MODE                  20\n#define PragTyp_JOURNAL_SIZE_LIMIT            21\n#define PragTyp_LOCK_PROXY_FILE               22\n#define PragTyp_LOCKING_MODE                  23\n#define PragTyp_PAGE_COUNT                    24\n#define PragTyp_MMAP_SIZE                     25\n#define PragTyp_MODULE_LIST                   26\n#define PragTyp_OPTIMIZE                      27\n#define PragTyp_PAGE_SIZE                     28\n#define PragTyp_PRAGMA_LIST                   29\n#define PragTyp_SECURE_DELETE                 30\n#define PragTyp_SHRINK_MEMORY                 31\n#define PragTyp_SOFT_HEAP_LIMIT               32\n#define PragTyp_SYNCHRONOUS                   33\n#define PragTyp_TABLE_INFO                    34\n#define PragTyp_TEMP_STORE                    35\n#define PragTyp_TEMP_STORE_DIRECTORY          36\n#define PragTyp_THREADS                       37\n#define PragTyp_WAL_AUTOCHECKPOINT            38\n#define PragTyp_WAL_CHECKPOINT                39\n#define PragTyp_ACTIVATE_EXTENSIONS           40\n#define PragTyp_HEXKEY                        41\n#define PragTyp_KEY                           42\n#define PragTyp_LOCK_STATUS                   43\n#define PragTyp_STATS                         44\n\n/* Property flags associated with various pragma. */\n#define PragFlg_NeedSchema 0x01 /* Force schema load before running */\n#define PragFlg_NoColumns  0x02 /* OP_ResultRow called with zero columns */\n#define PragFlg_NoColumns1 0x04 /* zero columns if RHS argument is present */\n#define PragFlg_ReadOnly   0x08 /* Read-only HEADER_VALUE */\n#define PragFlg_Result0    0x10 /* Acts as query when no argument */\n#define PragFlg_Result1    0x20 /* Acts as query when has one argument */\n#define PragFlg_SchemaOpt  0x40 /* Schema restricts name search if present */\n#define PragFlg_SchemaReq  0x80 /* Schema required - \"main\" is default */\n\n/* Names of columns for pragmas that return multi-column result\n** or that return single-column results where the name of the\n** result column is different from the name of the pragma\n*/\nstatic const char *const pragCName[] = {\n  /*   0 */ \"id\",          /* Used by: foreign_key_list */\n  /*   1 */ \"seq\",        \n  /*   2 */ \"table\",      \n  /*   3 */ \"from\",       \n  /*   4 */ \"to\",         \n  /*   5 */ \"on_update\",  \n  /*   6 */ \"on_delete\",  \n  /*   7 */ \"match\",      \n  /*   8 */ \"cid\",         /* Used by: table_xinfo */\n  /*   9 */ \"name\",       \n  /*  10 */ \"type\",       \n  /*  11 */ \"notnull\",    \n  /*  12 */ \"dflt_value\", \n  /*  13 */ \"pk\",         \n  /*  14 */ \"hidden\",     \n                           /* table_info reuses 8 */\n  /*  15 */ \"seqno\",       /* Used by: index_xinfo */\n  /*  16 */ \"cid\",        \n  /*  17 */ \"name\",       \n  /*  18 */ \"desc\",       \n  /*  19 */ \"coll\",       \n  /*  20 */ \"key\",        \n  /*  21 */ \"tbl\",         /* Used by: stats */\n  /*  22 */ \"idx\",        \n  /*  23 */ \"wdth\",       \n  /*  24 */ \"hght\",       \n  /*  25 */ \"flgs\",       \n  /*  26 */ \"seq\",         /* Used by: index_list */\n  /*  27 */ \"name\",       \n  /*  28 */ \"unique\",     \n  /*  29 */ \"origin\",     \n  /*  30 */ \"partial\",    \n  /*  31 */ \"table\",       /* Used by: foreign_key_check */\n  /*  32 */ \"rowid\",      \n  /*  33 */ \"parent\",     \n  /*  34 */ \"fkid\",       \n                           /* index_info reuses 15 */\n  /*  35 */ \"seq\",         /* Used by: database_list */\n  /*  36 */ \"name\",       \n  /*  37 */ \"file\",       \n  /*  38 */ \"busy\",        /* Used by: wal_checkpoint */\n  /*  39 */ \"log\",        \n  /*  40 */ \"checkpointed\",\n  /*  41 */ \"name\",        /* Used by: function_list */\n  /*  42 */ \"builtin\",    \n                           /* collation_list reuses 26 */\n  /*  43 */ \"database\",    /* Used by: lock_status */\n  /*  44 */ \"status\",     \n  /*  45 */ \"cache_size\",  /* Used by: default_cache_size */\n                           /* module_list pragma_list reuses 9 */\n  /*  46 */ \"timeout\",     /* Used by: busy_timeout */\n};\n\n/* Definitions of all built-in pragmas */\ntypedef struct PragmaName {\n  const char *const zName; /* Name of pragma */\n  u8 ePragTyp;             /* PragTyp_XXX value */\n  u8 mPragFlg;             /* Zero or more PragFlg_XXX values */\n  u8 iPragCName;           /* Start of column names in pragCName[] */\n  u8 nPragCName;           /* Num of col names. 0 means use pragma name */\n  u64 iArg;                /* Extra argument */\n} PragmaName;\nstatic const PragmaName aPragmaName[] = {\n#if defined(SQLITE_HAS_CODEC) || defined(SQLITE_ENABLE_CEROD)\n {/* zName:     */ \"activate_extensions\",\n  /* ePragTyp:  */ PragTyp_ACTIVATE_EXTENSIONS,\n  /* ePragFlg:  */ 0,\n  /* ColNames:  */ 0, 0,\n  /* iArg:      */ 0 },\n#endif\n#if !defined(SQLITE_OMIT_SCHEMA_VERSION_PRAGMAS)\n {/* zName:     */ \"application_id\",\n  /* ePragTyp:  */ PragTyp_HEADER_VALUE,\n  /* ePragFlg:  */ PragFlg_NoColumns1|PragFlg_Result0,\n  /* ColNames:  */ 0, 0,\n  /* iArg:      */ BTREE_APPLICATION_ID },\n#endif\n#if !defined(SQLITE_OMIT_AUTOVACUUM)\n {/* zName:     */ \"auto_vacuum\",\n  /* ePragTyp:  */ PragTyp_AUTO_VACUUM,\n  /* ePragFlg:  */ PragFlg_NeedSchema|PragFlg_Result0|PragFlg_SchemaReq|PragFlg_NoColumns1,\n  /* ColNames:  */ 0, 0,\n  /* iArg:      */ 0 },\n#endif\n#if !defined(SQLITE_OMIT_FLAG_PRAGMAS)\n#if !defined(SQLITE_OMIT_AUTOMATIC_INDEX)\n {/* zName:     */ \"automatic_index\",\n  /* ePragTyp:  */ PragTyp_FLAG,\n  /* ePragFlg:  */ PragFlg_Result0|PragFlg_NoColumns1,\n  /* ColNames:  */ 0, 0,\n  /* iArg:      */ SQLITE_AutoIndex },\n#endif\n#endif\n {/* zName:     */ \"busy_timeout\",\n  /* ePragTyp:  */ PragTyp_BUSY_TIMEOUT,\n  /* ePragFlg:  */ PragFlg_Result0,\n  /* ColNames:  */ 46, 1,\n  /* iArg:      */ 0 },\n#if !defined(SQLITE_OMIT_PAGER_PRAGMAS)\n {/* zName:     */ \"cache_size\",\n  /* ePragTyp:  */ PragTyp_CACHE_SIZE,\n  /* ePragFlg:  */ PragFlg_NeedSchema|PragFlg_Result0|PragFlg_SchemaReq|PragFlg_NoColumns1,\n  /* ColNames:  */ 0, 0,\n  /* iArg:      */ 0 },\n#endif\n#if !defined(SQLITE_OMIT_FLAG_PRAGMAS)\n {/* zName:     */ \"cache_spill\",\n  /* ePragTyp:  */ PragTyp_CACHE_SPILL,\n  /* ePragFlg:  */ PragFlg_Result0|PragFlg_SchemaReq|PragFlg_NoColumns1,\n  /* ColNames:  */ 0, 0,\n  /* iArg:      */ 0 },\n#endif\n {/* zName:     */ \"case_sensitive_like\",\n  /* ePragTyp:  */ PragTyp_CASE_SENSITIVE_LIKE,\n  /* ePragFlg:  */ PragFlg_NoColumns,\n  /* ColNames:  */ 0, 0,\n  /* iArg:      */ 0 },\n {/* zName:     */ \"cell_size_check\",\n  /* ePragTyp:  */ PragTyp_FLAG,\n  /* ePragFlg:  */ PragFlg_Result0|PragFlg_NoColumns1,\n  /* ColNames:  */ 0, 0,\n  /* iArg:      */ SQLITE_CellSizeCk },\n#if !defined(SQLITE_OMIT_FLAG_PRAGMAS)\n {/* zName:     */ \"checkpoint_fullfsync\",\n  /* ePragTyp:  */ PragTyp_FLAG,\n  /* ePragFlg:  */ PragFlg_Result0|PragFlg_NoColumns1,\n  /* ColNames:  */ 0, 0,\n  /* iArg:      */ SQLITE_CkptFullFSync },\n#endif\n#if !defined(SQLITE_OMIT_SCHEMA_PRAGMAS)\n {/* zName:     */ \"collation_list\",\n  /* ePragTyp:  */ PragTyp_COLLATION_LIST,\n  /* ePragFlg:  */ PragFlg_Result0,\n  /* ColNames:  */ 26, 2,\n  /* iArg:      */ 0 },\n#endif\n#if !defined(SQLITE_OMIT_COMPILEOPTION_DIAGS)\n {/* zName:     */ \"compile_options\",\n  /* ePragTyp:  */ PragTyp_COMPILE_OPTIONS,\n  /* ePragFlg:  */ PragFlg_Result0,\n  /* ColNames:  */ 0, 0,\n  /* iArg:      */ 0 },\n#endif\n#if !defined(SQLITE_OMIT_FLAG_PRAGMAS)\n {/* zName:     */ \"count_changes\",\n  /* ePragTyp:  */ PragTyp_FLAG,\n  /* ePragFlg:  */ PragFlg_Result0|PragFlg_NoColumns1,\n  /* ColNames:  */ 0, 0,\n  /* iArg:      */ SQLITE_CountRows },\n#endif\n#if !defined(SQLITE_OMIT_PAGER_PRAGMAS) && SQLITE_OS_WIN\n {/* zName:     */ \"data_store_directory\",\n  /* ePragTyp:  */ PragTyp_DATA_STORE_DIRECTORY,\n  /* ePragFlg:  */ PragFlg_NoColumns1,\n  /* ColNames:  */ 0, 0,\n  /* iArg:      */ 0 },\n#endif\n#if !defined(SQLITE_OMIT_SCHEMA_VERSION_PRAGMAS)\n {/* zName:     */ \"data_version\",\n  /* ePragTyp:  */ PragTyp_HEADER_VALUE,\n  /* ePragFlg:  */ PragFlg_ReadOnly|PragFlg_Result0,\n  /* ColNames:  */ 0, 0,\n  /* iArg:      */ BTREE_DATA_VERSION },\n#endif\n#if !defined(SQLITE_OMIT_SCHEMA_PRAGMAS)\n {/* zName:     */ \"database_list\",\n  /* ePragTyp:  */ PragTyp_DATABASE_LIST,\n  /* ePragFlg:  */ PragFlg_NeedSchema|PragFlg_Result0,\n  /* ColNames:  */ 35, 3,\n  /* iArg:      */ 0 },\n#endif\n#if !defined(SQLITE_OMIT_PAGER_PRAGMAS) && !defined(SQLITE_OMIT_DEPRECATED)\n {/* zName:     */ \"default_cache_size\",\n  /* ePragTyp:  */ PragTyp_DEFAULT_CACHE_SIZE,\n  /* ePragFlg:  */ PragFlg_NeedSchema|PragFlg_Result0|PragFlg_SchemaReq|PragFlg_NoColumns1,\n  /* ColNames:  */ 45, 1,\n  /* iArg:      */ 0 },\n#endif\n#if !defined(SQLITE_OMIT_FLAG_PRAGMAS)\n#if !defined(SQLITE_OMIT_FOREIGN_KEY) && !defined(SQLITE_OMIT_TRIGGER)\n {/* zName:     */ \"defer_foreign_keys\",\n  /* ePragTyp:  */ PragTyp_FLAG,\n  /* ePragFlg:  */ PragFlg_Result0|PragFlg_NoColumns1,\n  /* ColNames:  */ 0, 0,\n  /* iArg:      */ SQLITE_DeferFKs },\n#endif\n#endif\n#if !defined(SQLITE_OMIT_FLAG_PRAGMAS)\n {/* zName:     */ \"empty_result_callbacks\",\n  /* ePragTyp:  */ PragTyp_FLAG,\n  /* ePragFlg:  */ PragFlg_Result0|PragFlg_NoColumns1,\n  /* ColNames:  */ 0, 0,\n  /* iArg:      */ SQLITE_NullCallback },\n#endif\n#if !defined(SQLITE_OMIT_UTF16)\n {/* zName:     */ \"encoding\",\n  /* ePragTyp:  */ PragTyp_ENCODING,\n  /* ePragFlg:  */ PragFlg_Result0|PragFlg_NoColumns1,\n  /* ColNames:  */ 0, 0,\n  /* iArg:      */ 0 },\n#endif\n#if !defined(SQLITE_OMIT_FOREIGN_KEY) && !defined(SQLITE_OMIT_TRIGGER)\n {/* zName:     */ \"foreign_key_check\",\n  /* ePragTyp:  */ PragTyp_FOREIGN_KEY_CHECK,\n  /* ePragFlg:  */ PragFlg_NeedSchema|PragFlg_Result0,\n  /* ColNames:  */ 31, 4,\n  /* iArg:      */ 0 },\n#endif\n#if !defined(SQLITE_OMIT_FOREIGN_KEY)\n {/* zName:     */ \"foreign_key_list\",\n  /* ePragTyp:  */ PragTyp_FOREIGN_KEY_LIST,\n  /* ePragFlg:  */ PragFlg_NeedSchema|PragFlg_Result1|PragFlg_SchemaOpt,\n  /* ColNames:  */ 0, 8,\n  /* iArg:      */ 0 },\n#endif\n#if !defined(SQLITE_OMIT_FLAG_PRAGMAS)\n#if !defined(SQLITE_OMIT_FOREIGN_KEY) && !defined(SQLITE_OMIT_TRIGGER)\n {/* zName:     */ \"foreign_keys\",\n  /* ePragTyp:  */ PragTyp_FLAG,\n  /* ePragFlg:  */ PragFlg_Result0|PragFlg_NoColumns1,\n  /* ColNames:  */ 0, 0,\n  /* iArg:      */ SQLITE_ForeignKeys },\n#endif\n#endif\n#if !defined(SQLITE_OMIT_SCHEMA_VERSION_PRAGMAS)\n {/* zName:     */ \"freelist_count\",\n  /* ePragTyp:  */ PragTyp_HEADER_VALUE,\n  /* ePragFlg:  */ PragFlg_ReadOnly|PragFlg_Result0,\n  /* ColNames:  */ 0, 0,\n  /* iArg:      */ BTREE_FREE_PAGE_COUNT },\n#endif\n#if !defined(SQLITE_OMIT_FLAG_PRAGMAS)\n {/* zName:     */ \"full_column_names\",\n  /* ePragTyp:  */ PragTyp_FLAG,\n  /* ePragFlg:  */ PragFlg_Result0|PragFlg_NoColumns1,\n  /* ColNames:  */ 0, 0,\n  /* iArg:      */ SQLITE_FullColNames },\n {/* zName:     */ \"fullfsync\",\n  /* ePragTyp:  */ PragTyp_FLAG,\n  /* ePragFlg:  */ PragFlg_Result0|PragFlg_NoColumns1,\n  /* ColNames:  */ 0, 0,\n  /* iArg:      */ SQLITE_FullFSync },\n#endif\n#if !defined(SQLITE_OMIT_SCHEMA_PRAGMAS)\n#if defined(SQLITE_INTROSPECTION_PRAGMAS)\n {/* zName:     */ \"function_list\",\n  /* ePragTyp:  */ PragTyp_FUNCTION_LIST,\n  /* ePragFlg:  */ PragFlg_Result0,\n  /* ColNames:  */ 41, 2,\n  /* iArg:      */ 0 },\n#endif\n#endif\n#if defined(SQLITE_HAS_CODEC)\n {/* zName:     */ \"hexkey\",\n  /* ePragTyp:  */ PragTyp_HEXKEY,\n  /* ePragFlg:  */ 0,\n  /* ColNames:  */ 0, 0,\n  /* iArg:      */ 2 },\n {/* zName:     */ \"hexrekey\",\n  /* ePragTyp:  */ PragTyp_HEXKEY,\n  /* ePragFlg:  */ 0,\n  /* ColNames:  */ 0, 0,\n  /* iArg:      */ 3 },\n#endif\n#if !defined(SQLITE_OMIT_FLAG_PRAGMAS)\n#if !defined(SQLITE_OMIT_CHECK)\n {/* zName:     */ \"ignore_check_constraints\",\n  /* ePragTyp:  */ PragTyp_FLAG,\n  /* ePragFlg:  */ PragFlg_Result0|PragFlg_NoColumns1,\n  /* ColNames:  */ 0, 0,\n  /* iArg:      */ SQLITE_IgnoreChecks },\n#endif\n#endif\n#if !defined(SQLITE_OMIT_AUTOVACUUM)\n {/* zName:     */ \"incremental_vacuum\",\n  /* ePragTyp:  */ PragTyp_INCREMENTAL_VACUUM,\n  /* ePragFlg:  */ PragFlg_NeedSchema|PragFlg_NoColumns,\n  /* ColNames:  */ 0, 0,\n  /* iArg:      */ 0 },\n#endif\n#if !defined(SQLITE_OMIT_SCHEMA_PRAGMAS)\n {/* zName:     */ \"index_info\",\n  /* ePragTyp:  */ PragTyp_INDEX_INFO,\n  /* ePragFlg:  */ PragFlg_NeedSchema|PragFlg_Result1|PragFlg_SchemaOpt,\n  /* ColNames:  */ 15, 3,\n  /* iArg:      */ 0 },\n {/* zName:     */ \"index_list\",\n  /* ePragTyp:  */ PragTyp_INDEX_LIST,\n  /* ePragFlg:  */ PragFlg_NeedSchema|PragFlg_Result1|PragFlg_SchemaOpt,\n  /* ColNames:  */ 26, 5,\n  /* iArg:      */ 0 },\n {/* zName:     */ \"index_xinfo\",\n  /* ePragTyp:  */ PragTyp_INDEX_INFO,\n  /* ePragFlg:  */ PragFlg_NeedSchema|PragFlg_Result1|PragFlg_SchemaOpt,\n  /* ColNames:  */ 15, 6,\n  /* iArg:      */ 1 },\n#endif\n#if !defined(SQLITE_OMIT_INTEGRITY_CHECK)\n {/* zName:     */ \"integrity_check\",\n  /* ePragTyp:  */ PragTyp_INTEGRITY_CHECK,\n  /* ePragFlg:  */ PragFlg_NeedSchema|PragFlg_Result0|PragFlg_Result1,\n  /* ColNames:  */ 0, 0,\n  /* iArg:      */ 0 },\n#endif\n#if !defined(SQLITE_OMIT_PAGER_PRAGMAS)\n {/* zName:     */ \"journal_mode\",\n  /* ePragTyp:  */ PragTyp_JOURNAL_MODE,\n  /* ePragFlg:  */ PragFlg_NeedSchema|PragFlg_Result0|PragFlg_SchemaReq,\n  /* ColNames:  */ 0, 0,\n  /* iArg:      */ 0 },\n {/* zName:     */ \"journal_size_limit\",\n  /* ePragTyp:  */ PragTyp_JOURNAL_SIZE_LIMIT,\n  /* ePragFlg:  */ PragFlg_Result0|PragFlg_SchemaReq,\n  /* ColNames:  */ 0, 0,\n  /* iArg:      */ 0 },\n#endif\n#if defined(SQLITE_HAS_CODEC)\n {/* zName:     */ \"key\",\n  /* ePragTyp:  */ PragTyp_KEY,\n  /* ePragFlg:  */ 0,\n  /* ColNames:  */ 0, 0,\n  /* iArg:      */ 0 },\n#endif\n#if !defined(SQLITE_OMIT_FLAG_PRAGMAS)\n {/* zName:     */ \"legacy_alter_table\",\n  /* ePragTyp:  */ PragTyp_FLAG,\n  /* ePragFlg:  */ PragFlg_Result0|PragFlg_NoColumns1,\n  /* ColNames:  */ 0, 0,\n  /* iArg:      */ SQLITE_LegacyAlter },\n {/* zName:     */ \"legacy_file_format\",\n  /* ePragTyp:  */ PragTyp_FLAG,\n  /* ePragFlg:  */ PragFlg_Result0|PragFlg_NoColumns1,\n  /* ColNames:  */ 0, 0,\n  /* iArg:      */ SQLITE_LegacyFileFmt },\n#endif\n#if !defined(SQLITE_OMIT_PAGER_PRAGMAS) && SQLITE_ENABLE_LOCKING_STYLE\n {/* zName:     */ \"lock_proxy_file\",\n  /* ePragTyp:  */ PragTyp_LOCK_PROXY_FILE,\n  /* ePragFlg:  */ PragFlg_NoColumns1,\n  /* ColNames:  */ 0, 0,\n  /* iArg:      */ 0 },\n#endif\n#if defined(SQLITE_DEBUG) || defined(SQLITE_TEST)\n {/* zName:     */ \"lock_status\",\n  /* ePragTyp:  */ PragTyp_LOCK_STATUS,\n  /* ePragFlg:  */ PragFlg_Result0,\n  /* ColNames:  */ 43, 2,\n  /* iArg:      */ 0 },\n#endif\n#if !defined(SQLITE_OMIT_PAGER_PRAGMAS)\n {/* zName:     */ \"locking_mode\",\n  /* ePragTyp:  */ PragTyp_LOCKING_MODE,\n  /* ePragFlg:  */ PragFlg_Result0|PragFlg_SchemaReq,\n  /* ColNames:  */ 0, 0,\n  /* iArg:      */ 0 },\n {/* zName:     */ \"max_page_count\",\n  /* ePragTyp:  */ PragTyp_PAGE_COUNT,\n  /* ePragFlg:  */ PragFlg_NeedSchema|PragFlg_Result0|PragFlg_SchemaReq,\n  /* ColNames:  */ 0, 0,\n  /* iArg:      */ 0 },\n {/* zName:     */ \"mmap_size\",\n  /* ePragTyp:  */ PragTyp_MMAP_SIZE,\n  /* ePragFlg:  */ 0,\n  /* ColNames:  */ 0, 0,\n  /* iArg:      */ 0 },\n#endif\n#if !defined(SQLITE_OMIT_SCHEMA_PRAGMAS)\n#if !defined(SQLITE_OMIT_VIRTUALTABLE)\n#if defined(SQLITE_INTROSPECTION_PRAGMAS)\n {/* zName:     */ \"module_list\",\n  /* ePragTyp:  */ PragTyp_MODULE_LIST,\n  /* ePragFlg:  */ PragFlg_Result0,\n  /* ColNames:  */ 9, 1,\n  /* iArg:      */ 0 },\n#endif\n#endif\n#endif\n {/* zName:     */ \"optimize\",\n  /* ePragTyp:  */ PragTyp_OPTIMIZE,\n  /* ePragFlg:  */ PragFlg_Result1|PragFlg_NeedSchema,\n  /* ColNames:  */ 0, 0,\n  /* iArg:      */ 0 },\n#if !defined(SQLITE_OMIT_PAGER_PRAGMAS)\n {/* zName:     */ \"page_count\",\n  /* ePragTyp:  */ PragTyp_PAGE_COUNT,\n  /* ePragFlg:  */ PragFlg_NeedSchema|PragFlg_Result0|PragFlg_SchemaReq,\n  /* ColNames:  */ 0, 0,\n  /* iArg:      */ 0 },\n {/* zName:     */ \"page_size\",\n  /* ePragTyp:  */ PragTyp_PAGE_SIZE,\n  /* ePragFlg:  */ PragFlg_Result0|PragFlg_SchemaReq|PragFlg_NoColumns1,\n  /* ColNames:  */ 0, 0,\n  /* iArg:      */ 0 },\n#endif\n#if !defined(SQLITE_OMIT_FLAG_PRAGMAS)\n#if defined(SQLITE_DEBUG)\n {/* zName:     */ \"parser_trace\",\n  /* ePragTyp:  */ PragTyp_FLAG,\n  /* ePragFlg:  */ PragFlg_Result0|PragFlg_NoColumns1,\n  /* ColNames:  */ 0, 0,\n  /* iArg:      */ SQLITE_ParserTrace },\n#endif\n#endif\n#if defined(SQLITE_INTROSPECTION_PRAGMAS)\n {/* zName:     */ \"pragma_list\",\n  /* ePragTyp:  */ PragTyp_PRAGMA_LIST,\n  /* ePragFlg:  */ PragFlg_Result0,\n  /* ColNames:  */ 9, 1,\n  /* iArg:      */ 0 },\n#endif\n#if !defined(SQLITE_OMIT_FLAG_PRAGMAS)\n {/* zName:     */ \"query_only\",\n  /* ePragTyp:  */ PragTyp_FLAG,\n  /* ePragFlg:  */ PragFlg_Result0|PragFlg_NoColumns1,\n  /* ColNames:  */ 0, 0,\n  /* iArg:      */ SQLITE_QueryOnly },\n#endif\n#if !defined(SQLITE_OMIT_INTEGRITY_CHECK)\n {/* zName:     */ \"quick_check\",\n  /* ePragTyp:  */ PragTyp_INTEGRITY_CHECK,\n  /* ePragFlg:  */ PragFlg_NeedSchema|PragFlg_Result0|PragFlg_Result1,\n  /* ColNames:  */ 0, 0,\n  /* iArg:      */ 0 },\n#endif\n#if !defined(SQLITE_OMIT_FLAG_PRAGMAS)\n {/* zName:     */ \"read_uncommitted\",\n  /* ePragTyp:  */ PragTyp_FLAG,\n  /* ePragFlg:  */ PragFlg_Result0|PragFlg_NoColumns1,\n  /* ColNames:  */ 0, 0,\n  /* iArg:      */ SQLITE_ReadUncommit },\n {/* zName:     */ \"recursive_triggers\",\n  /* ePragTyp:  */ PragTyp_FLAG,\n  /* ePragFlg:  */ PragFlg_Result0|PragFlg_NoColumns1,\n  /* ColNames:  */ 0, 0,\n  /* iArg:      */ SQLITE_RecTriggers },\n#endif\n#if defined(SQLITE_HAS_CODEC)\n {/* zName:     */ \"rekey\",\n  /* ePragTyp:  */ PragTyp_KEY,\n  /* ePragFlg:  */ 0,\n  /* ColNames:  */ 0, 0,\n  /* iArg:      */ 1 },\n#endif\n#if !defined(SQLITE_OMIT_FLAG_PRAGMAS)\n {/* zName:     */ \"reverse_unordered_selects\",\n  /* ePragTyp:  */ PragTyp_FLAG,\n  /* ePragFlg:  */ PragFlg_Result0|PragFlg_NoColumns1,\n  /* ColNames:  */ 0, 0,\n  /* iArg:      */ SQLITE_ReverseOrder },\n#endif\n#if !defined(SQLITE_OMIT_SCHEMA_VERSION_PRAGMAS)\n {/* zName:     */ \"schema_version\",\n  /* ePragTyp:  */ PragTyp_HEADER_VALUE,\n  /* ePragFlg:  */ PragFlg_NoColumns1|PragFlg_Result0,\n  /* ColNames:  */ 0, 0,\n  /* iArg:      */ BTREE_SCHEMA_VERSION },\n#endif\n#if !defined(SQLITE_OMIT_PAGER_PRAGMAS)\n {/* zName:     */ \"secure_delete\",\n  /* ePragTyp:  */ PragTyp_SECURE_DELETE,\n  /* ePragFlg:  */ PragFlg_Result0,\n  /* ColNames:  */ 0, 0,\n  /* iArg:      */ 0 },\n#endif\n#if !defined(SQLITE_OMIT_FLAG_PRAGMAS)\n {/* zName:     */ \"short_column_names\",\n  /* ePragTyp:  */ PragTyp_FLAG,\n  /* ePragFlg:  */ PragFlg_Result0|PragFlg_NoColumns1,\n  /* ColNames:  */ 0, 0,\n  /* iArg:      */ SQLITE_ShortColNames },\n#endif\n {/* zName:     */ \"shrink_memory\",\n  /* ePragTyp:  */ PragTyp_SHRINK_MEMORY,\n  /* ePragFlg:  */ PragFlg_NoColumns,\n  /* ColNames:  */ 0, 0,\n  /* iArg:      */ 0 },\n {/* zName:     */ \"soft_heap_limit\",\n  /* ePragTyp:  */ PragTyp_SOFT_HEAP_LIMIT,\n  /* ePragFlg:  */ PragFlg_Result0,\n  /* ColNames:  */ 0, 0,\n  /* iArg:      */ 0 },\n#if !defined(SQLITE_OMIT_FLAG_PRAGMAS)\n#if defined(SQLITE_DEBUG)\n {/* zName:     */ \"sql_trace\",\n  /* ePragTyp:  */ PragTyp_FLAG,\n  /* ePragFlg:  */ PragFlg_Result0|PragFlg_NoColumns1,\n  /* ColNames:  */ 0, 0,\n  /* iArg:      */ SQLITE_SqlTrace },\n#endif\n#endif\n#if !defined(SQLITE_OMIT_SCHEMA_PRAGMAS) && defined(SQLITE_DEBUG)\n {/* zName:     */ \"stats\",\n  /* ePragTyp:  */ PragTyp_STATS,\n  /* ePragFlg:  */ PragFlg_NeedSchema|PragFlg_Result0|PragFlg_SchemaReq,\n  /* ColNames:  */ 21, 5,\n  /* iArg:      */ 0 },\n#endif\n#if !defined(SQLITE_OMIT_PAGER_PRAGMAS)\n {/* zName:     */ \"synchronous\",\n  /* ePragTyp:  */ PragTyp_SYNCHRONOUS,\n  /* ePragFlg:  */ PragFlg_NeedSchema|PragFlg_Result0|PragFlg_SchemaReq|PragFlg_NoColumns1,\n  /* ColNames:  */ 0, 0,\n  /* iArg:      */ 0 },\n#endif\n#if !defined(SQLITE_OMIT_SCHEMA_PRAGMAS)\n {/* zName:     */ \"table_info\",\n  /* ePragTyp:  */ PragTyp_TABLE_INFO,\n  /* ePragFlg:  */ PragFlg_NeedSchema|PragFlg_Result1|PragFlg_SchemaOpt,\n  /* ColNames:  */ 8, 6,\n  /* iArg:      */ 0 },\n {/* zName:     */ \"table_xinfo\",\n  /* ePragTyp:  */ PragTyp_TABLE_INFO,\n  /* ePragFlg:  */ PragFlg_NeedSchema|PragFlg_Result1|PragFlg_SchemaOpt,\n  /* ColNames:  */ 8, 7,\n  /* iArg:      */ 1 },\n#endif\n#if !defined(SQLITE_OMIT_PAGER_PRAGMAS)\n {/* zName:     */ \"temp_store\",\n  /* ePragTyp:  */ PragTyp_TEMP_STORE,\n  /* ePragFlg:  */ PragFlg_Result0|PragFlg_NoColumns1,\n  /* ColNames:  */ 0, 0,\n  /* iArg:      */ 0 },\n {/* zName:     */ \"temp_store_directory\",\n  /* ePragTyp:  */ PragTyp_TEMP_STORE_DIRECTORY,\n  /* ePragFlg:  */ PragFlg_NoColumns1,\n  /* ColNames:  */ 0, 0,\n  /* iArg:      */ 0 },\n#endif\n#if defined(SQLITE_HAS_CODEC)\n {/* zName:     */ \"textkey\",\n  /* ePragTyp:  */ PragTyp_KEY,\n  /* ePragFlg:  */ 0,\n  /* ColNames:  */ 0, 0,\n  /* iArg:      */ 4 },\n {/* zName:     */ \"textrekey\",\n  /* ePragTyp:  */ PragTyp_KEY,\n  /* ePragFlg:  */ 0,\n  /* ColNames:  */ 0, 0,\n  /* iArg:      */ 5 },\n#endif\n {/* zName:     */ \"threads\",\n  /* ePragTyp:  */ PragTyp_THREADS,\n  /* ePragFlg:  */ PragFlg_Result0,\n  /* ColNames:  */ 0, 0,\n  /* iArg:      */ 0 },\n#if !defined(SQLITE_OMIT_SCHEMA_VERSION_PRAGMAS)\n {/* zName:     */ \"user_version\",\n  /* ePragTyp:  */ PragTyp_HEADER_VALUE,\n  /* ePragFlg:  */ PragFlg_NoColumns1|PragFlg_Result0,\n  /* ColNames:  */ 0, 0,\n  /* iArg:      */ BTREE_USER_VERSION },\n#endif\n#if !defined(SQLITE_OMIT_FLAG_PRAGMAS)\n#if defined(SQLITE_DEBUG)\n {/* zName:     */ \"vdbe_addoptrace\",\n  /* ePragTyp:  */ PragTyp_FLAG,\n  /* ePragFlg:  */ PragFlg_Result0|PragFlg_NoColumns1,\n  /* ColNames:  */ 0, 0,\n  /* iArg:      */ SQLITE_VdbeAddopTrace },\n {/* zName:     */ \"vdbe_debug\",\n  /* ePragTyp:  */ PragTyp_FLAG,\n  /* ePragFlg:  */ PragFlg_Result0|PragFlg_NoColumns1,\n  /* ColNames:  */ 0, 0,\n  /* iArg:      */ SQLITE_SqlTrace|SQLITE_VdbeListing|SQLITE_VdbeTrace },\n {/* zName:     */ \"vdbe_eqp\",\n  /* ePragTyp:  */ PragTyp_FLAG,\n  /* ePragFlg:  */ PragFlg_Result0|PragFlg_NoColumns1,\n  /* ColNames:  */ 0, 0,\n  /* iArg:      */ SQLITE_VdbeEQP },\n {/* zName:     */ \"vdbe_listing\",\n  /* ePragTyp:  */ PragTyp_FLAG,\n  /* ePragFlg:  */ PragFlg_Result0|PragFlg_NoColumns1,\n  /* ColNames:  */ 0, 0,\n  /* iArg:      */ SQLITE_VdbeListing },\n {/* zName:     */ \"vdbe_trace\",\n  /* ePragTyp:  */ PragTyp_FLAG,\n  /* ePragFlg:  */ PragFlg_Result0|PragFlg_NoColumns1,\n  /* ColNames:  */ 0, 0,\n  /* iArg:      */ SQLITE_VdbeTrace },\n#endif\n#endif\n#if !defined(SQLITE_OMIT_WAL)\n {/* zName:     */ \"wal_autocheckpoint\",\n  /* ePragTyp:  */ PragTyp_WAL_AUTOCHECKPOINT,\n  /* ePragFlg:  */ 0,\n  /* ColNames:  */ 0, 0,\n  /* iArg:      */ 0 },\n {/* zName:     */ \"wal_checkpoint\",\n  /* ePragTyp:  */ PragTyp_WAL_CHECKPOINT,\n  /* ePragFlg:  */ PragFlg_NeedSchema,\n  /* ColNames:  */ 38, 3,\n  /* iArg:      */ 0 },\n#endif\n#if !defined(SQLITE_OMIT_FLAG_PRAGMAS)\n {/* zName:     */ \"writable_schema\",\n  /* ePragTyp:  */ PragTyp_FLAG,\n  /* ePragFlg:  */ PragFlg_Result0|PragFlg_NoColumns1,\n  /* ColNames:  */ 0, 0,\n  /* iArg:      */ SQLITE_WriteSchema|SQLITE_NoSchemaError },\n#endif\n};\n/* Number of pragmas: 62 on by default, 81 total. */\n\n/************** End of pragma.h **********************************************/\n/************** Continuing where we left off in pragma.c *********************/\n\n/*\n** Interpret the given string as a safety level.  Return 0 for OFF,\n** 1 for ON or NORMAL, 2 for FULL, and 3 for EXTRA.  Return 1 for an empty or \n** unrecognized string argument.  The FULL and EXTRA option is disallowed\n** if the omitFull parameter it 1.\n**\n** Note that the values returned are one less that the values that\n** should be passed into sqlite3BtreeSetSafetyLevel().  The is done\n** to support legacy SQL code.  The safety level used to be boolean\n** and older scripts may have used numbers 0 for OFF and 1 for ON.\n*/\nstatic u8 getSafetyLevel(const char *z, int omitFull, u8 dflt){\n                             /* 123456789 123456789 123 */\n  static const char zText[] = \"onoffalseyestruextrafull\";\n  static const u8 iOffset[] = {0, 1, 2,  4,    9,  12,  15,   20};\n  static const u8 iLength[] = {2, 2, 3,  5,    3,   4,   5,    4};\n  static const u8 iValue[] =  {1, 0, 0,  0,    1,   1,   3,    2};\n                            /* on no off false yes true extra full */\n  int i, n;\n  if( sqlite3Isdigit(*z) ){\n    return (u8)sqlite3Atoi(z);\n  }\n  n = sqlite3Strlen30(z);\n  for(i=0; i<ArraySize(iLength); i++){\n    if( iLength[i]==n && sqlite3StrNICmp(&zText[iOffset[i]],z,n)==0\n     && (!omitFull || iValue[i]<=1)\n    ){\n      return iValue[i];\n    }\n  }\n  return dflt;\n}\n\n/*\n** Interpret the given string as a boolean value.\n*/\nSQLITE_PRIVATE u8 sqlite3GetBoolean(const char *z, u8 dflt){\n  return getSafetyLevel(z,1,dflt)!=0;\n}\n\n/* The sqlite3GetBoolean() function is used by other modules but the\n** remainder of this file is specific to PRAGMA processing.  So omit\n** the rest of the file if PRAGMAs are omitted from the build.\n*/\n#if !defined(SQLITE_OMIT_PRAGMA)\n\n/*\n** Interpret the given string as a locking mode value.\n*/\nstatic int getLockingMode(const char *z){\n  if( z ){\n    if( 0==sqlite3StrICmp(z, \"exclusive\") ) return PAGER_LOCKINGMODE_EXCLUSIVE;\n    if( 0==sqlite3StrICmp(z, \"normal\") ) return PAGER_LOCKINGMODE_NORMAL;\n  }\n  return PAGER_LOCKINGMODE_QUERY;\n}\n\n#ifndef SQLITE_OMIT_AUTOVACUUM\n/*\n** Interpret the given string as an auto-vacuum mode value.\n**\n** The following strings, \"none\", \"full\" and \"incremental\" are \n** acceptable, as are their numeric equivalents: 0, 1 and 2 respectively.\n*/\nstatic int getAutoVacuum(const char *z){\n  int i;\n  if( 0==sqlite3StrICmp(z, \"none\") ) return BTREE_AUTOVACUUM_NONE;\n  if( 0==sqlite3StrICmp(z, \"full\") ) return BTREE_AUTOVACUUM_FULL;\n  if( 0==sqlite3StrICmp(z, \"incremental\") ) return BTREE_AUTOVACUUM_INCR;\n  i = sqlite3Atoi(z);\n  return (u8)((i>=0&&i<=2)?i:0);\n}\n#endif /* ifndef SQLITE_OMIT_AUTOVACUUM */\n\n#ifndef SQLITE_OMIT_PAGER_PRAGMAS\n/*\n** Interpret the given string as a temp db location. Return 1 for file\n** backed temporary databases, 2 for the Red-Black tree in memory database\n** and 0 to use the compile-time default.\n*/\nstatic int getTempStore(const char *z){\n  if( z[0]>='0' && z[0]<='2' ){\n    return z[0] - '0';\n  }else if( sqlite3StrICmp(z, \"file\")==0 ){\n    return 1;\n  }else if( sqlite3StrICmp(z, \"memory\")==0 ){\n    return 2;\n  }else{\n    return 0;\n  }\n}\n#endif /* SQLITE_PAGER_PRAGMAS */\n\n#ifndef SQLITE_OMIT_PAGER_PRAGMAS\n/*\n** Invalidate temp storage, either when the temp storage is changed\n** from default, or when 'file' and the temp_store_directory has changed\n*/\nstatic int invalidateTempStorage(Parse *pParse){\n  sqlite3 *db = pParse->db;\n  if( db->aDb[1].pBt!=0 ){\n    if( !db->autoCommit || sqlite3BtreeIsInReadTrans(db->aDb[1].pBt) ){\n      sqlite3ErrorMsg(pParse, \"temporary storage cannot be changed \"\n        \"from within a transaction\");\n      return SQLITE_ERROR;\n    }\n    sqlite3BtreeClose(db->aDb[1].pBt);\n    db->aDb[1].pBt = 0;\n    sqlite3ResetAllSchemasOfConnection(db);\n  }\n  return SQLITE_OK;\n}\n#endif /* SQLITE_PAGER_PRAGMAS */\n\n#ifndef SQLITE_OMIT_PAGER_PRAGMAS\n/*\n** If the TEMP database is open, close it and mark the database schema\n** as needing reloading.  This must be done when using the SQLITE_TEMP_STORE\n** or DEFAULT_TEMP_STORE pragmas.\n*/\nstatic int changeTempStorage(Parse *pParse, const char *zStorageType){\n  int ts = getTempStore(zStorageType);\n  sqlite3 *db = pParse->db;\n  if( db->temp_store==ts ) return SQLITE_OK;\n  if( invalidateTempStorage( pParse ) != SQLITE_OK ){\n    return SQLITE_ERROR;\n  }\n  db->temp_store = (u8)ts;\n  return SQLITE_OK;\n}\n#endif /* SQLITE_PAGER_PRAGMAS */\n\n/*\n** Set result column names for a pragma.\n*/\nstatic void setPragmaResultColumnNames(\n  Vdbe *v,                     /* The query under construction */\n  const PragmaName *pPragma    /* The pragma */\n){\n  u8 n = pPragma->nPragCName;\n  sqlite3VdbeSetNumCols(v, n==0 ? 1 : n);\n  if( n==0 ){\n    sqlite3VdbeSetColName(v, 0, COLNAME_NAME, pPragma->zName, SQLITE_STATIC);\n  }else{\n    int i, j;\n    for(i=0, j=pPragma->iPragCName; i<n; i++, j++){\n      sqlite3VdbeSetColName(v, i, COLNAME_NAME, pragCName[j], SQLITE_STATIC);\n    }\n  }\n}\n\n/*\n** Generate code to return a single integer value.\n*/\nstatic void returnSingleInt(Vdbe *v, i64 value){\n  sqlite3VdbeAddOp4Dup8(v, OP_Int64, 0, 1, 0, (const u8*)&value, P4_INT64);\n  sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 1);\n}\n\n/*\n** Generate code to return a single text value.\n*/\nstatic void returnSingleText(\n  Vdbe *v,                /* Prepared statement under construction */\n  const char *zValue      /* Value to be returned */\n){\n  if( zValue ){\n    sqlite3VdbeLoadString(v, 1, (const char*)zValue);\n    sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 1);\n  }\n}\n\n\n/*\n** Set the safety_level and pager flags for pager iDb.  Or if iDb<0\n** set these values for all pagers.\n*/\n#ifndef SQLITE_OMIT_PAGER_PRAGMAS\nstatic void setAllPagerFlags(sqlite3 *db){\n  if( db->autoCommit ){\n    Db *pDb = db->aDb;\n    int n = db->nDb;\n    assert( SQLITE_FullFSync==PAGER_FULLFSYNC );\n    assert( SQLITE_CkptFullFSync==PAGER_CKPT_FULLFSYNC );\n    assert( SQLITE_CacheSpill==PAGER_CACHESPILL );\n    assert( (PAGER_FULLFSYNC | PAGER_CKPT_FULLFSYNC | PAGER_CACHESPILL)\n             ==  PAGER_FLAGS_MASK );\n    assert( (pDb->safety_level & PAGER_SYNCHRONOUS_MASK)==pDb->safety_level );\n    while( (n--) > 0 ){\n      if( pDb->pBt ){\n        sqlite3BtreeSetPagerFlags(pDb->pBt,\n                 pDb->safety_level | (db->flags & PAGER_FLAGS_MASK) );\n      }\n      pDb++;\n    }\n  }\n}\n#else\n# define setAllPagerFlags(X)  /* no-op */\n#endif\n\n\n/*\n** Return a human-readable name for a constraint resolution action.\n*/\n#ifndef SQLITE_OMIT_FOREIGN_KEY\nstatic const char *actionName(u8 action){\n  const char *zName;\n  switch( action ){\n    case OE_SetNull:  zName = \"SET NULL\";        break;\n    case OE_SetDflt:  zName = \"SET DEFAULT\";     break;\n    case OE_Cascade:  zName = \"CASCADE\";         break;\n    case OE_Restrict: zName = \"RESTRICT\";        break;\n    default:          zName = \"NO ACTION\";  \n                      assert( action==OE_None ); break;\n  }\n  return zName;\n}\n#endif\n\n\n/*\n** Parameter eMode must be one of the PAGER_JOURNALMODE_XXX constants\n** defined in pager.h. This function returns the associated lowercase\n** journal-mode name.\n*/\nSQLITE_PRIVATE const char *sqlite3JournalModename(int eMode){\n  static char * const azModeName[] = {\n    \"delete\", \"persist\", \"off\", \"truncate\", \"memory\"\n#ifndef SQLITE_OMIT_WAL\n     , \"wal\"\n#endif\n  };\n  assert( PAGER_JOURNALMODE_DELETE==0 );\n  assert( PAGER_JOURNALMODE_PERSIST==1 );\n  assert( PAGER_JOURNALMODE_OFF==2 );\n  assert( PAGER_JOURNALMODE_TRUNCATE==3 );\n  assert( PAGER_JOURNALMODE_MEMORY==4 );\n  assert( PAGER_JOURNALMODE_WAL==5 );\n  assert( eMode>=0 && eMode<=ArraySize(azModeName) );\n\n  if( eMode==ArraySize(azModeName) ) return 0;\n  return azModeName[eMode];\n}\n\n/*\n** Locate a pragma in the aPragmaName[] array.\n*/\nstatic const PragmaName *pragmaLocate(const char *zName){\n  int upr, lwr, mid = 0, rc;\n  lwr = 0;\n  upr = ArraySize(aPragmaName)-1;\n  while( lwr<=upr ){\n    mid = (lwr+upr)/2;\n    rc = sqlite3_stricmp(zName, aPragmaName[mid].zName);\n    if( rc==0 ) break;\n    if( rc<0 ){\n      upr = mid - 1;\n    }else{\n      lwr = mid + 1;\n    }\n  }\n  return lwr>upr ? 0 : &aPragmaName[mid];\n}\n\n/*\n** Helper subroutine for PRAGMA integrity_check:\n**\n** Generate code to output a single-column result row with a value of the\n** string held in register 3.  Decrement the result count in register 1\n** and halt if the maximum number of result rows have been issued.\n*/\nstatic int integrityCheckResultRow(Vdbe *v){\n  int addr;\n  sqlite3VdbeAddOp2(v, OP_ResultRow, 3, 1);\n  addr = sqlite3VdbeAddOp3(v, OP_IfPos, 1, sqlite3VdbeCurrentAddr(v)+2, 1);\n  VdbeCoverage(v);\n  sqlite3VdbeAddOp0(v, OP_Halt);\n  return addr;\n}\n\n/*\n** Process a pragma statement.  \n**\n** Pragmas are of this form:\n**\n**      PRAGMA [schema.]id [= value]\n**\n** The identifier might also be a string.  The value is a string, and\n** identifier, or a number.  If minusFlag is true, then the value is\n** a number that was preceded by a minus sign.\n**\n** If the left side is \"database.id\" then pId1 is the database name\n** and pId2 is the id.  If the left side is just \"id\" then pId1 is the\n** id and pId2 is any empty string.\n*/\nSQLITE_PRIVATE void sqlite3Pragma(\n  Parse *pParse, \n  Token *pId1,        /* First part of [schema.]id field */\n  Token *pId2,        /* Second part of [schema.]id field, or NULL */\n  Token *pValue,      /* Token for <value>, or NULL */\n  int minusFlag       /* True if a '-' sign preceded <value> */\n){\n  char *zLeft = 0;       /* Nul-terminated UTF-8 string <id> */\n  char *zRight = 0;      /* Nul-terminated UTF-8 string <value>, or NULL */\n  const char *zDb = 0;   /* The database name */\n  Token *pId;            /* Pointer to <id> token */\n  char *aFcntl[4];       /* Argument to SQLITE_FCNTL_PRAGMA */\n  int iDb;               /* Database index for <database> */\n  int rc;                      /* return value form SQLITE_FCNTL_PRAGMA */\n  sqlite3 *db = pParse->db;    /* The database connection */\n  Db *pDb;                     /* The specific database being pragmaed */\n  Vdbe *v = sqlite3GetVdbe(pParse);  /* Prepared statement */\n  const PragmaName *pPragma;   /* The pragma */\n/* BEGIN SQLCIPHER */\n#ifdef SQLITE_HAS_CODEC\n  extern int sqlcipher_codec_pragma(sqlite3*, int, Parse *, const char *, const char *);\n#endif\n/* END SQLCIPHER */\n\n  if( v==0 ) return;\n  sqlite3VdbeRunOnlyOnce(v);\n  pParse->nMem = 2;\n\n  /* Interpret the [schema.] part of the pragma statement. iDb is the\n  ** index of the database this pragma is being applied to in db.aDb[]. */\n  iDb = sqlite3TwoPartName(pParse, pId1, pId2, &pId);\n  if( iDb<0 ) return;\n  pDb = &db->aDb[iDb];\n\n  /* If the temp database has been explicitly named as part of the \n  ** pragma, make sure it is open. \n  */\n  if( iDb==1 && sqlite3OpenTempDatabase(pParse) ){\n    return;\n  }\n\n  zLeft = sqlite3NameFromToken(db, pId);\n  if( !zLeft ) return;\n  if( minusFlag ){\n    zRight = sqlite3MPrintf(db, \"-%T\", pValue);\n  }else{\n    zRight = sqlite3NameFromToken(db, pValue);\n  }\n\n  assert( pId2 );\n  zDb = pId2->n>0 ? pDb->zDbSName : 0;\n  if( sqlite3AuthCheck(pParse, SQLITE_PRAGMA, zLeft, zRight, zDb) ){\n    goto pragma_out;\n  }\n\n  /* Send an SQLITE_FCNTL_PRAGMA file-control to the underlying VFS\n  ** connection.  If it returns SQLITE_OK, then assume that the VFS\n  ** handled the pragma and generate a no-op prepared statement.\n  **\n  ** IMPLEMENTATION-OF: R-12238-55120 Whenever a PRAGMA statement is parsed,\n  ** an SQLITE_FCNTL_PRAGMA file control is sent to the open sqlite3_file\n  ** object corresponding to the database file to which the pragma\n  ** statement refers.\n  **\n  ** IMPLEMENTATION-OF: R-29875-31678 The argument to the SQLITE_FCNTL_PRAGMA\n  ** file control is an array of pointers to strings (char**) in which the\n  ** second element of the array is the name of the pragma and the third\n  ** element is the argument to the pragma or NULL if the pragma has no\n  ** argument.\n  */\n  aFcntl[0] = 0;\n  aFcntl[1] = zLeft;\n  aFcntl[2] = zRight;\n  aFcntl[3] = 0;\n  db->busyHandler.nBusy = 0;\n  rc = sqlite3_file_control(db, zDb, SQLITE_FCNTL_PRAGMA, (void*)aFcntl);\n  if( rc==SQLITE_OK ){\n    sqlite3VdbeSetNumCols(v, 1);\n    sqlite3VdbeSetColName(v, 0, COLNAME_NAME, aFcntl[0], SQLITE_TRANSIENT);\n    returnSingleText(v, aFcntl[0]);\n    sqlite3_free(aFcntl[0]);\n    goto pragma_out;\n  }\n  if( rc!=SQLITE_NOTFOUND ){\n    if( aFcntl[0] ){\n      sqlite3ErrorMsg(pParse, \"%s\", aFcntl[0]);\n      sqlite3_free(aFcntl[0]);\n    }\n    pParse->nErr++;\n    pParse->rc = rc;\n\n    goto pragma_out;\n  }\n\n/* BEGIN SQLCIPHER */\n#ifdef SQLITE_HAS_CODEC\n  if(sqlcipher_codec_pragma(db, iDb, pParse, zLeft, zRight)) { \n    /* sqlcipher_codec_pragma executes internal */\n    goto pragma_out;\n  }\n#endif\n/* END SQLCIPHER */  \n\n  /* Locate the pragma in the lookup table */\n  pPragma = pragmaLocate(zLeft);\n  if( pPragma==0 ) goto pragma_out;\n\n  /* Make sure the database schema is loaded if the pragma requires that */\n  if( (pPragma->mPragFlg & PragFlg_NeedSchema)!=0 ){\n    if( sqlite3ReadSchema(pParse) ) goto pragma_out;\n  }\n\n  /* Register the result column names for pragmas that return results */\n  if( (pPragma->mPragFlg & PragFlg_NoColumns)==0 \n   && ((pPragma->mPragFlg & PragFlg_NoColumns1)==0 || zRight==0)\n  ){\n    setPragmaResultColumnNames(v, pPragma);\n  }\n\n  /* Jump to the appropriate pragma handler */\n  switch( pPragma->ePragTyp ){\n  \n#if !defined(SQLITE_OMIT_PAGER_PRAGMAS) && !defined(SQLITE_OMIT_DEPRECATED)\n  /*\n  **  PRAGMA [schema.]default_cache_size\n  **  PRAGMA [schema.]default_cache_size=N\n  **\n  ** The first form reports the current persistent setting for the\n  ** page cache size.  The value returned is the maximum number of\n  ** pages in the page cache.  The second form sets both the current\n  ** page cache size value and the persistent page cache size value\n  ** stored in the database file.\n  **\n  ** Older versions of SQLite would set the default cache size to a\n  ** negative number to indicate synchronous=OFF.  These days, synchronous\n  ** is always on by default regardless of the sign of the default cache\n  ** size.  But continue to take the absolute value of the default cache\n  ** size of historical compatibility.\n  */\n  case PragTyp_DEFAULT_CACHE_SIZE: {\n    static const int iLn = VDBE_OFFSET_LINENO(2);\n    static const VdbeOpList getCacheSize[] = {\n      { OP_Transaction, 0, 0,        0},                         /* 0 */\n      { OP_ReadCookie,  0, 1,        BTREE_DEFAULT_CACHE_SIZE},  /* 1 */\n      { OP_IfPos,       1, 8,        0},\n      { OP_Integer,     0, 2,        0},\n      { OP_Subtract,    1, 2,        1},\n      { OP_IfPos,       1, 8,        0},\n      { OP_Integer,     0, 1,        0},                         /* 6 */\n      { OP_Noop,        0, 0,        0},\n      { OP_ResultRow,   1, 1,        0},\n    };\n    VdbeOp *aOp;\n    sqlite3VdbeUsesBtree(v, iDb);\n    if( !zRight ){\n      pParse->nMem += 2;\n      sqlite3VdbeVerifyNoMallocRequired(v, ArraySize(getCacheSize));\n      aOp = sqlite3VdbeAddOpList(v, ArraySize(getCacheSize), getCacheSize, iLn);\n      if( ONLY_IF_REALLOC_STRESS(aOp==0) ) break;\n      aOp[0].p1 = iDb;\n      aOp[1].p1 = iDb;\n      aOp[6].p1 = SQLITE_DEFAULT_CACHE_SIZE;\n    }else{\n      int size = sqlite3AbsInt32(sqlite3Atoi(zRight));\n      sqlite3BeginWriteOperation(pParse, 0, iDb);\n      sqlite3VdbeAddOp3(v, OP_SetCookie, iDb, BTREE_DEFAULT_CACHE_SIZE, size);\n      assert( sqlite3SchemaMutexHeld(db, iDb, 0) );\n      pDb->pSchema->cache_size = size;\n      sqlite3BtreeSetCacheSize(pDb->pBt, pDb->pSchema->cache_size);\n    }\n    break;\n  }\n#endif /* !SQLITE_OMIT_PAGER_PRAGMAS && !SQLITE_OMIT_DEPRECATED */\n\n#if !defined(SQLITE_OMIT_PAGER_PRAGMAS)\n  /*\n  **  PRAGMA [schema.]page_size\n  **  PRAGMA [schema.]page_size=N\n  **\n  ** The first form reports the current setting for the\n  ** database page size in bytes.  The second form sets the\n  ** database page size value.  The value can only be set if\n  ** the database has not yet been created.\n  */\n  case PragTyp_PAGE_SIZE: {\n    Btree *pBt = pDb->pBt;\n    assert( pBt!=0 );\n    if( !zRight ){\n      int size = ALWAYS(pBt) ? sqlite3BtreeGetPageSize(pBt) : 0;\n      returnSingleInt(v, size);\n    }else{\n      /* Malloc may fail when setting the page-size, as there is an internal\n      ** buffer that the pager module resizes using sqlite3_realloc().\n      */\n      db->nextPagesize = sqlite3Atoi(zRight);\n      if( SQLITE_NOMEM==sqlite3BtreeSetPageSize(pBt, db->nextPagesize,-1,0) ){\n        sqlite3OomFault(db);\n      }\n    }\n    break;\n  }\n\n  /*\n  **  PRAGMA [schema.]secure_delete\n  **  PRAGMA [schema.]secure_delete=ON/OFF/FAST\n  **\n  ** The first form reports the current setting for the\n  ** secure_delete flag.  The second form changes the secure_delete\n  ** flag setting and reports the new value.\n  */\n  case PragTyp_SECURE_DELETE: {\n    Btree *pBt = pDb->pBt;\n    int b = -1;\n    assert( pBt!=0 );\n    if( zRight ){\n      if( sqlite3_stricmp(zRight, \"fast\")==0 ){\n        b = 2;\n      }else{\n        b = sqlite3GetBoolean(zRight, 0);\n      }\n    }\n    if( pId2->n==0 && b>=0 ){\n      int ii;\n      for(ii=0; ii<db->nDb; ii++){\n        sqlite3BtreeSecureDelete(db->aDb[ii].pBt, b);\n      }\n    }\n    b = sqlite3BtreeSecureDelete(pBt, b);\n    returnSingleInt(v, b);\n    break;\n  }\n\n  /*\n  **  PRAGMA [schema.]max_page_count\n  **  PRAGMA [schema.]max_page_count=N\n  **\n  ** The first form reports the current setting for the\n  ** maximum number of pages in the database file.  The \n  ** second form attempts to change this setting.  Both\n  ** forms return the current setting.\n  **\n  ** The absolute value of N is used.  This is undocumented and might\n  ** change.  The only purpose is to provide an easy way to test\n  ** the sqlite3AbsInt32() function.\n  **\n  **  PRAGMA [schema.]page_count\n  **\n  ** Return the number of pages in the specified database.\n  */\n  case PragTyp_PAGE_COUNT: {\n    int iReg;\n    sqlite3CodeVerifySchema(pParse, iDb);\n    iReg = ++pParse->nMem;\n    if( sqlite3Tolower(zLeft[0])=='p' ){\n      sqlite3VdbeAddOp2(v, OP_Pagecount, iDb, iReg);\n    }else{\n      sqlite3VdbeAddOp3(v, OP_MaxPgcnt, iDb, iReg, \n                        sqlite3AbsInt32(sqlite3Atoi(zRight)));\n    }\n    sqlite3VdbeAddOp2(v, OP_ResultRow, iReg, 1);\n    break;\n  }\n\n  /*\n  **  PRAGMA [schema.]locking_mode\n  **  PRAGMA [schema.]locking_mode = (normal|exclusive)\n  */\n  case PragTyp_LOCKING_MODE: {\n    const char *zRet = \"normal\";\n    int eMode = getLockingMode(zRight);\n\n    if( pId2->n==0 && eMode==PAGER_LOCKINGMODE_QUERY ){\n      /* Simple \"PRAGMA locking_mode;\" statement. This is a query for\n      ** the current default locking mode (which may be different to\n      ** the locking-mode of the main database).\n      */\n      eMode = db->dfltLockMode;\n    }else{\n      Pager *pPager;\n      if( pId2->n==0 ){\n        /* This indicates that no database name was specified as part\n        ** of the PRAGMA command. In this case the locking-mode must be\n        ** set on all attached databases, as well as the main db file.\n        **\n        ** Also, the sqlite3.dfltLockMode variable is set so that\n        ** any subsequently attached databases also use the specified\n        ** locking mode.\n        */\n        int ii;\n        assert(pDb==&db->aDb[0]);\n        for(ii=2; ii<db->nDb; ii++){\n          pPager = sqlite3BtreePager(db->aDb[ii].pBt);\n          sqlite3PagerLockingMode(pPager, eMode);\n        }\n        db->dfltLockMode = (u8)eMode;\n      }\n      pPager = sqlite3BtreePager(pDb->pBt);\n      eMode = sqlite3PagerLockingMode(pPager, eMode);\n    }\n\n    assert( eMode==PAGER_LOCKINGMODE_NORMAL\n            || eMode==PAGER_LOCKINGMODE_EXCLUSIVE );\n    if( eMode==PAGER_LOCKINGMODE_EXCLUSIVE ){\n      zRet = \"exclusive\";\n    }\n    returnSingleText(v, zRet);\n    break;\n  }\n\n  /*\n  **  PRAGMA [schema.]journal_mode\n  **  PRAGMA [schema.]journal_mode =\n  **                      (delete|persist|off|truncate|memory|wal|off)\n  */\n  case PragTyp_JOURNAL_MODE: {\n    int eMode;        /* One of the PAGER_JOURNALMODE_XXX symbols */\n    int ii;           /* Loop counter */\n\n    if( zRight==0 ){\n      /* If there is no \"=MODE\" part of the pragma, do a query for the\n      ** current mode */\n      eMode = PAGER_JOURNALMODE_QUERY;\n    }else{\n      const char *zMode;\n      int n = sqlite3Strlen30(zRight);\n      for(eMode=0; (zMode = sqlite3JournalModename(eMode))!=0; eMode++){\n        if( sqlite3StrNICmp(zRight, zMode, n)==0 ) break;\n      }\n      if( !zMode ){\n        /* If the \"=MODE\" part does not match any known journal mode,\n        ** then do a query */\n        eMode = PAGER_JOURNALMODE_QUERY;\n      }\n    }\n    if( eMode==PAGER_JOURNALMODE_QUERY && pId2->n==0 ){\n      /* Convert \"PRAGMA journal_mode\" into \"PRAGMA main.journal_mode\" */\n      iDb = 0;\n      pId2->n = 1;\n    }\n    for(ii=db->nDb-1; ii>=0; ii--){\n      if( db->aDb[ii].pBt && (ii==iDb || pId2->n==0) ){\n        sqlite3VdbeUsesBtree(v, ii);\n        sqlite3VdbeAddOp3(v, OP_JournalMode, ii, 1, eMode);\n      }\n    }\n    sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 1);\n    break;\n  }\n\n  /*\n  **  PRAGMA [schema.]journal_size_limit\n  **  PRAGMA [schema.]journal_size_limit=N\n  **\n  ** Get or set the size limit on rollback journal files.\n  */\n  case PragTyp_JOURNAL_SIZE_LIMIT: {\n    Pager *pPager = sqlite3BtreePager(pDb->pBt);\n    i64 iLimit = -2;\n    if( zRight ){\n      sqlite3DecOrHexToI64(zRight, &iLimit);\n      if( iLimit<-1 ) iLimit = -1;\n    }\n    iLimit = sqlite3PagerJournalSizeLimit(pPager, iLimit);\n    returnSingleInt(v, iLimit);\n    break;\n  }\n\n#endif /* SQLITE_OMIT_PAGER_PRAGMAS */\n\n  /*\n  **  PRAGMA [schema.]auto_vacuum\n  **  PRAGMA [schema.]auto_vacuum=N\n  **\n  ** Get or set the value of the database 'auto-vacuum' parameter.\n  ** The value is one of:  0 NONE 1 FULL 2 INCREMENTAL\n  */\n#ifndef SQLITE_OMIT_AUTOVACUUM\n  case PragTyp_AUTO_VACUUM: {\n    Btree *pBt = pDb->pBt;\n    assert( pBt!=0 );\n    if( !zRight ){\n      returnSingleInt(v, sqlite3BtreeGetAutoVacuum(pBt));\n    }else{\n      int eAuto = getAutoVacuum(zRight);\n      assert( eAuto>=0 && eAuto<=2 );\n      db->nextAutovac = (u8)eAuto;\n      /* Call SetAutoVacuum() to set initialize the internal auto and\n      ** incr-vacuum flags. This is required in case this connection\n      ** creates the database file. It is important that it is created\n      ** as an auto-vacuum capable db.\n      */\n      rc = sqlite3BtreeSetAutoVacuum(pBt, eAuto);\n      if( rc==SQLITE_OK && (eAuto==1 || eAuto==2) ){\n        /* When setting the auto_vacuum mode to either \"full\" or \n        ** \"incremental\", write the value of meta[6] in the database\n        ** file. Before writing to meta[6], check that meta[3] indicates\n        ** that this really is an auto-vacuum capable database.\n        */\n        static const int iLn = VDBE_OFFSET_LINENO(2);\n        static const VdbeOpList setMeta6[] = {\n          { OP_Transaction,    0,         1,                 0},    /* 0 */\n          { OP_ReadCookie,     0,         1,         BTREE_LARGEST_ROOT_PAGE},\n          { OP_If,             1,         0,                 0},    /* 2 */\n          { OP_Halt,           SQLITE_OK, OE_Abort,          0},    /* 3 */\n          { OP_SetCookie,      0,         BTREE_INCR_VACUUM, 0},    /* 4 */\n        };\n        VdbeOp *aOp;\n        int iAddr = sqlite3VdbeCurrentAddr(v);\n        sqlite3VdbeVerifyNoMallocRequired(v, ArraySize(setMeta6));\n        aOp = sqlite3VdbeAddOpList(v, ArraySize(setMeta6), setMeta6, iLn);\n        if( ONLY_IF_REALLOC_STRESS(aOp==0) ) break;\n        aOp[0].p1 = iDb;\n        aOp[1].p1 = iDb;\n        aOp[2].p2 = iAddr+4;\n        aOp[4].p1 = iDb;\n        aOp[4].p3 = eAuto - 1;\n        sqlite3VdbeUsesBtree(v, iDb);\n      }\n    }\n    break;\n  }\n#endif\n\n  /*\n  **  PRAGMA [schema.]incremental_vacuum(N)\n  **\n  ** Do N steps of incremental vacuuming on a database.\n  */\n#ifndef SQLITE_OMIT_AUTOVACUUM\n  case PragTyp_INCREMENTAL_VACUUM: {\n    int iLimit, addr;\n    if( zRight==0 || !sqlite3GetInt32(zRight, &iLimit) || iLimit<=0 ){\n      iLimit = 0x7fffffff;\n    }\n    sqlite3BeginWriteOperation(pParse, 0, iDb);\n    sqlite3VdbeAddOp2(v, OP_Integer, iLimit, 1);\n    addr = sqlite3VdbeAddOp1(v, OP_IncrVacuum, iDb); VdbeCoverage(v);\n    sqlite3VdbeAddOp1(v, OP_ResultRow, 1);\n    sqlite3VdbeAddOp2(v, OP_AddImm, 1, -1);\n    sqlite3VdbeAddOp2(v, OP_IfPos, 1, addr); VdbeCoverage(v);\n    sqlite3VdbeJumpHere(v, addr);\n    break;\n  }\n#endif\n\n#ifndef SQLITE_OMIT_PAGER_PRAGMAS\n  /*\n  **  PRAGMA [schema.]cache_size\n  **  PRAGMA [schema.]cache_size=N\n  **\n  ** The first form reports the current local setting for the\n  ** page cache size. The second form sets the local\n  ** page cache size value.  If N is positive then that is the\n  ** number of pages in the cache.  If N is negative, then the\n  ** number of pages is adjusted so that the cache uses -N kibibytes\n  ** of memory.\n  */\n  case PragTyp_CACHE_SIZE: {\n    assert( sqlite3SchemaMutexHeld(db, iDb, 0) );\n    if( !zRight ){\n      returnSingleInt(v, pDb->pSchema->cache_size);\n    }else{\n      int size = sqlite3Atoi(zRight);\n      pDb->pSchema->cache_size = size;\n      sqlite3BtreeSetCacheSize(pDb->pBt, pDb->pSchema->cache_size);\n    }\n    break;\n  }\n\n  /*\n  **  PRAGMA [schema.]cache_spill\n  **  PRAGMA cache_spill=BOOLEAN\n  **  PRAGMA [schema.]cache_spill=N\n  **\n  ** The first form reports the current local setting for the\n  ** page cache spill size. The second form turns cache spill on\n  ** or off.  When turnning cache spill on, the size is set to the\n  ** current cache_size.  The third form sets a spill size that\n  ** may be different form the cache size.\n  ** If N is positive then that is the\n  ** number of pages in the cache.  If N is negative, then the\n  ** number of pages is adjusted so that the cache uses -N kibibytes\n  ** of memory.\n  **\n  ** If the number of cache_spill pages is less then the number of\n  ** cache_size pages, no spilling occurs until the page count exceeds\n  ** the number of cache_size pages.\n  **\n  ** The cache_spill=BOOLEAN setting applies to all attached schemas,\n  ** not just the schema specified.\n  */\n  case PragTyp_CACHE_SPILL: {\n    assert( sqlite3SchemaMutexHeld(db, iDb, 0) );\n    if( !zRight ){\n      returnSingleInt(v,\n         (db->flags & SQLITE_CacheSpill)==0 ? 0 : \n            sqlite3BtreeSetSpillSize(pDb->pBt,0));\n    }else{\n      int size = 1;\n      if( sqlite3GetInt32(zRight, &size) ){\n        sqlite3BtreeSetSpillSize(pDb->pBt, size);\n      }\n      if( sqlite3GetBoolean(zRight, size!=0) ){\n        db->flags |= SQLITE_CacheSpill;\n      }else{\n        db->flags &= ~(u64)SQLITE_CacheSpill;\n      }\n      setAllPagerFlags(db);\n    }\n    break;\n  }\n\n  /*\n  **  PRAGMA [schema.]mmap_size(N)\n  **\n  ** Used to set mapping size limit. The mapping size limit is\n  ** used to limit the aggregate size of all memory mapped regions of the\n  ** database file. If this parameter is set to zero, then memory mapping\n  ** is not used at all.  If N is negative, then the default memory map\n  ** limit determined by sqlite3_config(SQLITE_CONFIG_MMAP_SIZE) is set.\n  ** The parameter N is measured in bytes.\n  **\n  ** This value is advisory.  The underlying VFS is free to memory map\n  ** as little or as much as it wants.  Except, if N is set to 0 then the\n  ** upper layers will never invoke the xFetch interfaces to the VFS.\n  */\n  case PragTyp_MMAP_SIZE: {\n    sqlite3_int64 sz;\n#if SQLITE_MAX_MMAP_SIZE>0\n    assert( sqlite3SchemaMutexHeld(db, iDb, 0) );\n    if( zRight ){\n      int ii;\n      sqlite3DecOrHexToI64(zRight, &sz);\n      if( sz<0 ) sz = sqlite3GlobalConfig.szMmap;\n      if( pId2->n==0 ) db->szMmap = sz;\n      for(ii=db->nDb-1; ii>=0; ii--){\n        if( db->aDb[ii].pBt && (ii==iDb || pId2->n==0) ){\n          sqlite3BtreeSetMmapLimit(db->aDb[ii].pBt, sz);\n        }\n      }\n    }\n    sz = -1;\n    rc = sqlite3_file_control(db, zDb, SQLITE_FCNTL_MMAP_SIZE, &sz);\n#else\n    sz = 0;\n    rc = SQLITE_OK;\n#endif\n    if( rc==SQLITE_OK ){\n      returnSingleInt(v, sz);\n    }else if( rc!=SQLITE_NOTFOUND ){\n      pParse->nErr++;\n      pParse->rc = rc;\n    }\n    break;\n  }\n\n  /*\n  **   PRAGMA temp_store\n  **   PRAGMA temp_store = \"default\"|\"memory\"|\"file\"\n  **\n  ** Return or set the local value of the temp_store flag.  Changing\n  ** the local value does not make changes to the disk file and the default\n  ** value will be restored the next time the database is opened.\n  **\n  ** Note that it is possible for the library compile-time options to\n  ** override this setting\n  */\n  case PragTyp_TEMP_STORE: {\n    if( !zRight ){\n      returnSingleInt(v, db->temp_store);\n    }else{\n      changeTempStorage(pParse, zRight);\n    }\n    break;\n  }\n\n  /*\n  **   PRAGMA temp_store_directory\n  **   PRAGMA temp_store_directory = \"\"|\"directory_name\"\n  **\n  ** Return or set the local value of the temp_store_directory flag.  Changing\n  ** the value sets a specific directory to be used for temporary files.\n  ** Setting to a null string reverts to the default temporary directory search.\n  ** If temporary directory is changed, then invalidateTempStorage.\n  **\n  */\n  case PragTyp_TEMP_STORE_DIRECTORY: {\n    if( !zRight ){\n      returnSingleText(v, sqlite3_temp_directory);\n    }else{\n#ifndef SQLITE_OMIT_WSD\n      if( zRight[0] ){\n        int res;\n        rc = sqlite3OsAccess(db->pVfs, zRight, SQLITE_ACCESS_READWRITE, &res);\n        if( rc!=SQLITE_OK || res==0 ){\n          sqlite3ErrorMsg(pParse, \"not a writable directory\");\n          goto pragma_out;\n        }\n      }\n      if( SQLITE_TEMP_STORE==0\n       || (SQLITE_TEMP_STORE==1 && db->temp_store<=1)\n       || (SQLITE_TEMP_STORE==2 && db->temp_store==1)\n      ){\n        invalidateTempStorage(pParse);\n      }\n      sqlite3_free(sqlite3_temp_directory);\n      if( zRight[0] ){\n        sqlite3_temp_directory = sqlite3_mprintf(\"%s\", zRight);\n      }else{\n        sqlite3_temp_directory = 0;\n      }\n#endif /* SQLITE_OMIT_WSD */\n    }\n    break;\n  }\n\n#if SQLITE_OS_WIN\n  /*\n  **   PRAGMA data_store_directory\n  **   PRAGMA data_store_directory = \"\"|\"directory_name\"\n  **\n  ** Return or set the local value of the data_store_directory flag.  Changing\n  ** the value sets a specific directory to be used for database files that\n  ** were specified with a relative pathname.  Setting to a null string reverts\n  ** to the default database directory, which for database files specified with\n  ** a relative path will probably be based on the current directory for the\n  ** process.  Database file specified with an absolute path are not impacted\n  ** by this setting, regardless of its value.\n  **\n  */\n  case PragTyp_DATA_STORE_DIRECTORY: {\n    if( !zRight ){\n      returnSingleText(v, sqlite3_data_directory);\n    }else{\n#ifndef SQLITE_OMIT_WSD\n      if( zRight[0] ){\n        int res;\n        rc = sqlite3OsAccess(db->pVfs, zRight, SQLITE_ACCESS_READWRITE, &res);\n        if( rc!=SQLITE_OK || res==0 ){\n          sqlite3ErrorMsg(pParse, \"not a writable directory\");\n          goto pragma_out;\n        }\n      }\n      sqlite3_free(sqlite3_data_directory);\n      if( zRight[0] ){\n        sqlite3_data_directory = sqlite3_mprintf(\"%s\", zRight);\n      }else{\n        sqlite3_data_directory = 0;\n      }\n#endif /* SQLITE_OMIT_WSD */\n    }\n    break;\n  }\n#endif\n\n#if SQLITE_ENABLE_LOCKING_STYLE\n  /*\n  **   PRAGMA [schema.]lock_proxy_file\n  **   PRAGMA [schema.]lock_proxy_file = \":auto:\"|\"lock_file_path\"\n  **\n  ** Return or set the value of the lock_proxy_file flag.  Changing\n  ** the value sets a specific file to be used for database access locks.\n  **\n  */\n  case PragTyp_LOCK_PROXY_FILE: {\n    if( !zRight ){\n      Pager *pPager = sqlite3BtreePager(pDb->pBt);\n      char *proxy_file_path = NULL;\n      sqlite3_file *pFile = sqlite3PagerFile(pPager);\n      sqlite3OsFileControlHint(pFile, SQLITE_GET_LOCKPROXYFILE, \n                           &proxy_file_path);\n      returnSingleText(v, proxy_file_path);\n    }else{\n      Pager *pPager = sqlite3BtreePager(pDb->pBt);\n      sqlite3_file *pFile = sqlite3PagerFile(pPager);\n      int res;\n      if( zRight[0] ){\n        res=sqlite3OsFileControl(pFile, SQLITE_SET_LOCKPROXYFILE, \n                                     zRight);\n      } else {\n        res=sqlite3OsFileControl(pFile, SQLITE_SET_LOCKPROXYFILE, \n                                     NULL);\n      }\n      if( res!=SQLITE_OK ){\n        sqlite3ErrorMsg(pParse, \"failed to set lock proxy file\");\n        goto pragma_out;\n      }\n    }\n    break;\n  }\n#endif /* SQLITE_ENABLE_LOCKING_STYLE */      \n    \n  /*\n  **   PRAGMA [schema.]synchronous\n  **   PRAGMA [schema.]synchronous=OFF|ON|NORMAL|FULL|EXTRA\n  **\n  ** Return or set the local value of the synchronous flag.  Changing\n  ** the local value does not make changes to the disk file and the\n  ** default value will be restored the next time the database is\n  ** opened.\n  */\n  case PragTyp_SYNCHRONOUS: {\n    if( !zRight ){\n      returnSingleInt(v, pDb->safety_level-1);\n    }else{\n      if( !db->autoCommit ){\n        sqlite3ErrorMsg(pParse, \n            \"Safety level may not be changed inside a transaction\");\n      }else if( iDb!=1 ){\n        int iLevel = (getSafetyLevel(zRight,0,1)+1) & PAGER_SYNCHRONOUS_MASK;\n        if( iLevel==0 ) iLevel = 1;\n        pDb->safety_level = iLevel;\n        pDb->bSyncSet = 1;\n        setAllPagerFlags(db);\n      }\n    }\n    break;\n  }\n#endif /* SQLITE_OMIT_PAGER_PRAGMAS */\n\n#ifndef SQLITE_OMIT_FLAG_PRAGMAS\n  case PragTyp_FLAG: {\n    if( zRight==0 ){\n      setPragmaResultColumnNames(v, pPragma);\n      returnSingleInt(v, (db->flags & pPragma->iArg)!=0 );\n    }else{\n      u64 mask = pPragma->iArg;    /* Mask of bits to set or clear. */\n      if( db->autoCommit==0 ){\n        /* Foreign key support may not be enabled or disabled while not\n        ** in auto-commit mode.  */\n        mask &= ~(SQLITE_ForeignKeys);\n      }\n#if SQLITE_USER_AUTHENTICATION\n      if( db->auth.authLevel==UAUTH_User ){\n        /* Do not allow non-admin users to modify the schema arbitrarily */\n        mask &= ~(SQLITE_WriteSchema);\n      }\n#endif\n\n      if( sqlite3GetBoolean(zRight, 0) ){\n        db->flags |= mask;\n      }else{\n        db->flags &= ~mask;\n        if( mask==SQLITE_DeferFKs ) db->nDeferredImmCons = 0;\n      }\n\n      /* Many of the flag-pragmas modify the code generated by the SQL \n      ** compiler (eg. count_changes). So add an opcode to expire all\n      ** compiled SQL statements after modifying a pragma value.\n      */\n      sqlite3VdbeAddOp0(v, OP_Expire);\n      setAllPagerFlags(db);\n    }\n    break;\n  }\n#endif /* SQLITE_OMIT_FLAG_PRAGMAS */\n\n#ifndef SQLITE_OMIT_SCHEMA_PRAGMAS\n  /*\n  **   PRAGMA table_info(<table>)\n  **\n  ** Return a single row for each column of the named table. The columns of\n  ** the returned data set are:\n  **\n  ** cid:        Column id (numbered from left to right, starting at 0)\n  ** name:       Column name\n  ** type:       Column declaration type.\n  ** notnull:    True if 'NOT NULL' is part of column declaration\n  ** dflt_value: The default value for the column, if any.\n  ** pk:         Non-zero for PK fields.\n  */\n  case PragTyp_TABLE_INFO: if( zRight ){\n    Table *pTab;\n    pTab = sqlite3LocateTable(pParse, LOCATE_NOERR, zRight, zDb);\n    if( pTab ){\n      int iTabDb = sqlite3SchemaToIndex(db, pTab->pSchema);\n      int i, k;\n      int nHidden = 0;\n      Column *pCol;\n      Index *pPk = sqlite3PrimaryKeyIndex(pTab);\n      pParse->nMem = 7;\n      sqlite3CodeVerifySchema(pParse, iTabDb);\n      sqlite3ViewGetColumnNames(pParse, pTab);\n      for(i=0, pCol=pTab->aCol; i<pTab->nCol; i++, pCol++){\n        int isHidden = IsHiddenColumn(pCol);\n        if( isHidden && pPragma->iArg==0 ){\n          nHidden++;\n          continue;\n        }\n        if( (pCol->colFlags & COLFLAG_PRIMKEY)==0 ){\n          k = 0;\n        }else if( pPk==0 ){\n          k = 1;\n        }else{\n          for(k=1; k<=pTab->nCol && pPk->aiColumn[k-1]!=i; k++){}\n        }\n        assert( pCol->pDflt==0 || pCol->pDflt->op==TK_SPAN );\n        sqlite3VdbeMultiLoad(v, 1, pPragma->iArg ? \"issisii\" : \"issisi\",\n               i-nHidden,\n               pCol->zName,\n               sqlite3ColumnType(pCol,\"\"),\n               pCol->notNull ? 1 : 0,\n               pCol->pDflt ? pCol->pDflt->u.zToken : 0,\n               k,\n               isHidden);\n      }\n    }\n  }\n  break;\n\n#ifdef SQLITE_DEBUG\n  case PragTyp_STATS: {\n    Index *pIdx;\n    HashElem *i;\n    pParse->nMem = 5;\n    sqlite3CodeVerifySchema(pParse, iDb);\n    for(i=sqliteHashFirst(&pDb->pSchema->tblHash); i; i=sqliteHashNext(i)){\n      Table *pTab = sqliteHashData(i);\n      sqlite3VdbeMultiLoad(v, 1, \"ssiii\",\n           pTab->zName,\n           0,\n           pTab->szTabRow,\n           pTab->nRowLogEst,\n           pTab->tabFlags);\n      for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){\n        sqlite3VdbeMultiLoad(v, 2, \"siiiX\",\n           pIdx->zName,\n           pIdx->szIdxRow,\n           pIdx->aiRowLogEst[0],\n           pIdx->hasStat1);\n        sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 5);\n      }\n    }\n  }\n  break;\n#endif\n\n  case PragTyp_INDEX_INFO: if( zRight ){\n    Index *pIdx;\n    Table *pTab;\n    pIdx = sqlite3FindIndex(db, zRight, zDb);\n    if( pIdx ){\n      int iIdxDb = sqlite3SchemaToIndex(db, pIdx->pSchema);\n      int i;\n      int mx;\n      if( pPragma->iArg ){\n        /* PRAGMA index_xinfo (newer version with more rows and columns) */\n        mx = pIdx->nColumn;\n        pParse->nMem = 6;\n      }else{\n        /* PRAGMA index_info (legacy version) */\n        mx = pIdx->nKeyCol;\n        pParse->nMem = 3;\n      }\n      pTab = pIdx->pTable;\n      sqlite3CodeVerifySchema(pParse, iIdxDb);\n      assert( pParse->nMem<=pPragma->nPragCName );\n      for(i=0; i<mx; i++){\n        i16 cnum = pIdx->aiColumn[i];\n        sqlite3VdbeMultiLoad(v, 1, \"iisX\", i, cnum,\n                             cnum<0 ? 0 : pTab->aCol[cnum].zName);\n        if( pPragma->iArg ){\n          sqlite3VdbeMultiLoad(v, 4, \"isiX\",\n            pIdx->aSortOrder[i],\n            pIdx->azColl[i],\n            i<pIdx->nKeyCol);\n        }\n        sqlite3VdbeAddOp2(v, OP_ResultRow, 1, pParse->nMem);\n      }\n    }\n  }\n  break;\n\n  case PragTyp_INDEX_LIST: if( zRight ){\n    Index *pIdx;\n    Table *pTab;\n    int i;\n    pTab = sqlite3FindTable(db, zRight, zDb);\n    if( pTab ){\n      int iTabDb = sqlite3SchemaToIndex(db, pTab->pSchema);\n      pParse->nMem = 5;\n      sqlite3CodeVerifySchema(pParse, iTabDb);\n      for(pIdx=pTab->pIndex, i=0; pIdx; pIdx=pIdx->pNext, i++){\n        const char *azOrigin[] = { \"c\", \"u\", \"pk\" };\n        sqlite3VdbeMultiLoad(v, 1, \"isisi\",\n           i,\n           pIdx->zName,\n           IsUniqueIndex(pIdx),\n           azOrigin[pIdx->idxType],\n           pIdx->pPartIdxWhere!=0);\n      }\n    }\n  }\n  break;\n\n  case PragTyp_DATABASE_LIST: {\n    int i;\n    pParse->nMem = 3;\n    for(i=0; i<db->nDb; i++){\n      if( db->aDb[i].pBt==0 ) continue;\n      assert( db->aDb[i].zDbSName!=0 );\n      sqlite3VdbeMultiLoad(v, 1, \"iss\",\n         i,\n         db->aDb[i].zDbSName,\n         sqlite3BtreeGetFilename(db->aDb[i].pBt));\n    }\n  }\n  break;\n\n  case PragTyp_COLLATION_LIST: {\n    int i = 0;\n    HashElem *p;\n    pParse->nMem = 2;\n    for(p=sqliteHashFirst(&db->aCollSeq); p; p=sqliteHashNext(p)){\n      CollSeq *pColl = (CollSeq *)sqliteHashData(p);\n      sqlite3VdbeMultiLoad(v, 1, \"is\", i++, pColl->zName);\n    }\n  }\n  break;\n\n#ifdef SQLITE_INTROSPECTION_PRAGMAS\n  case PragTyp_FUNCTION_LIST: {\n    int i;\n    HashElem *j;\n    FuncDef *p;\n    pParse->nMem = 2;\n    for(i=0; i<SQLITE_FUNC_HASH_SZ; i++){\n      for(p=sqlite3BuiltinFunctions.a[i]; p; p=p->u.pHash ){\n        if( p->funcFlags & SQLITE_FUNC_INTERNAL ) continue;\n        sqlite3VdbeMultiLoad(v, 1, \"si\", p->zName, 1);\n      }\n    }\n    for(j=sqliteHashFirst(&db->aFunc); j; j=sqliteHashNext(j)){\n      p = (FuncDef*)sqliteHashData(j);\n      sqlite3VdbeMultiLoad(v, 1, \"si\", p->zName, 0);\n    }\n  }\n  break;\n\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n  case PragTyp_MODULE_LIST: {\n    HashElem *j;\n    pParse->nMem = 1;\n    for(j=sqliteHashFirst(&db->aModule); j; j=sqliteHashNext(j)){\n      Module *pMod = (Module*)sqliteHashData(j);\n      sqlite3VdbeMultiLoad(v, 1, \"s\", pMod->zName);\n    }\n  }\n  break;\n#endif /* SQLITE_OMIT_VIRTUALTABLE */\n\n  case PragTyp_PRAGMA_LIST: {\n    int i;\n    for(i=0; i<ArraySize(aPragmaName); i++){\n      sqlite3VdbeMultiLoad(v, 1, \"s\", aPragmaName[i].zName);\n    }\n  }\n  break;\n#endif /* SQLITE_INTROSPECTION_PRAGMAS */\n\n#endif /* SQLITE_OMIT_SCHEMA_PRAGMAS */\n\n#ifndef SQLITE_OMIT_FOREIGN_KEY\n  case PragTyp_FOREIGN_KEY_LIST: if( zRight ){\n    FKey *pFK;\n    Table *pTab;\n    pTab = sqlite3FindTable(db, zRight, zDb);\n    if( pTab ){\n      pFK = pTab->pFKey;\n      if( pFK ){\n        int iTabDb = sqlite3SchemaToIndex(db, pTab->pSchema);\n        int i = 0; \n        pParse->nMem = 8;\n        sqlite3CodeVerifySchema(pParse, iTabDb);\n        while(pFK){\n          int j;\n          for(j=0; j<pFK->nCol; j++){\n            sqlite3VdbeMultiLoad(v, 1, \"iissssss\",\n                   i,\n                   j,\n                   pFK->zTo,\n                   pTab->aCol[pFK->aCol[j].iFrom].zName,\n                   pFK->aCol[j].zCol,\n                   actionName(pFK->aAction[1]),  /* ON UPDATE */\n                   actionName(pFK->aAction[0]),  /* ON DELETE */\n                   \"NONE\");\n          }\n          ++i;\n          pFK = pFK->pNextFrom;\n        }\n      }\n    }\n  }\n  break;\n#endif /* !defined(SQLITE_OMIT_FOREIGN_KEY) */\n\n#ifndef SQLITE_OMIT_FOREIGN_KEY\n#ifndef SQLITE_OMIT_TRIGGER\n  case PragTyp_FOREIGN_KEY_CHECK: {\n    FKey *pFK;             /* A foreign key constraint */\n    Table *pTab;           /* Child table contain \"REFERENCES\" keyword */\n    Table *pParent;        /* Parent table that child points to */\n    Index *pIdx;           /* Index in the parent table */\n    int i;                 /* Loop counter:  Foreign key number for pTab */\n    int j;                 /* Loop counter:  Field of the foreign key */\n    HashElem *k;           /* Loop counter:  Next table in schema */\n    int x;                 /* result variable */\n    int regResult;         /* 3 registers to hold a result row */\n    int regKey;            /* Register to hold key for checking the FK */\n    int regRow;            /* Registers to hold a row from pTab */\n    int addrTop;           /* Top of a loop checking foreign keys */\n    int addrOk;            /* Jump here if the key is OK */\n    int *aiCols;           /* child to parent column mapping */\n\n    regResult = pParse->nMem+1;\n    pParse->nMem += 4;\n    regKey = ++pParse->nMem;\n    regRow = ++pParse->nMem;\n    k = sqliteHashFirst(&db->aDb[iDb].pSchema->tblHash);\n    while( k ){\n      int iTabDb;\n      if( zRight ){\n        pTab = sqlite3LocateTable(pParse, 0, zRight, zDb);\n        k = 0;\n      }else{\n        pTab = (Table*)sqliteHashData(k);\n        k = sqliteHashNext(k);\n      }\n      if( pTab==0 || pTab->pFKey==0 ) continue;\n      iTabDb = sqlite3SchemaToIndex(db, pTab->pSchema);\n      sqlite3CodeVerifySchema(pParse, iTabDb);\n      sqlite3TableLock(pParse, iTabDb, pTab->tnum, 0, pTab->zName);\n      if( pTab->nCol+regRow>pParse->nMem ) pParse->nMem = pTab->nCol + regRow;\n      sqlite3OpenTable(pParse, 0, iTabDb, pTab, OP_OpenRead);\n      sqlite3VdbeLoadString(v, regResult, pTab->zName);\n      for(i=1, pFK=pTab->pFKey; pFK; i++, pFK=pFK->pNextFrom){\n        pParent = sqlite3FindTable(db, pFK->zTo, zDb);\n        if( pParent==0 ) continue;\n        pIdx = 0;\n        sqlite3TableLock(pParse, iTabDb, pParent->tnum, 0, pParent->zName);\n        x = sqlite3FkLocateIndex(pParse, pParent, pFK, &pIdx, 0);\n        if( x==0 ){\n          if( pIdx==0 ){\n            sqlite3OpenTable(pParse, i, iTabDb, pParent, OP_OpenRead);\n          }else{\n            sqlite3VdbeAddOp3(v, OP_OpenRead, i, pIdx->tnum, iTabDb);\n            sqlite3VdbeSetP4KeyInfo(pParse, pIdx);\n          }\n        }else{\n          k = 0;\n          break;\n        }\n      }\n      assert( pParse->nErr>0 || pFK==0 );\n      if( pFK ) break;\n      if( pParse->nTab<i ) pParse->nTab = i;\n      addrTop = sqlite3VdbeAddOp1(v, OP_Rewind, 0); VdbeCoverage(v);\n      for(i=1, pFK=pTab->pFKey; pFK; i++, pFK=pFK->pNextFrom){\n        pParent = sqlite3FindTable(db, pFK->zTo, zDb);\n        pIdx = 0;\n        aiCols = 0;\n        if( pParent ){\n          x = sqlite3FkLocateIndex(pParse, pParent, pFK, &pIdx, &aiCols);\n          assert( x==0 );\n        }\n        addrOk = sqlite3VdbeMakeLabel(pParse);\n\n        /* Generate code to read the child key values into registers\n        ** regRow..regRow+n. If any of the child key values are NULL, this \n        ** row cannot cause an FK violation. Jump directly to addrOk in \n        ** this case. */\n        for(j=0; j<pFK->nCol; j++){\n          int iCol = aiCols ? aiCols[j] : pFK->aCol[j].iFrom;\n          sqlite3ExprCodeGetColumnOfTable(v, pTab, 0, iCol, regRow+j);\n          sqlite3VdbeAddOp2(v, OP_IsNull, regRow+j, addrOk); VdbeCoverage(v);\n        }\n\n        /* Generate code to query the parent index for a matching parent\n        ** key. If a match is found, jump to addrOk. */\n        if( pIdx ){\n          sqlite3VdbeAddOp4(v, OP_MakeRecord, regRow, pFK->nCol, regKey,\n              sqlite3IndexAffinityStr(db,pIdx), pFK->nCol);\n          sqlite3VdbeAddOp4Int(v, OP_Found, i, addrOk, regKey, 0);\n          VdbeCoverage(v);\n        }else if( pParent ){\n          int jmp = sqlite3VdbeCurrentAddr(v)+2;\n          sqlite3VdbeAddOp3(v, OP_SeekRowid, i, jmp, regRow); VdbeCoverage(v);\n          sqlite3VdbeGoto(v, addrOk);\n          assert( pFK->nCol==1 );\n        }\n\n        /* Generate code to report an FK violation to the caller. */\n        if( HasRowid(pTab) ){\n          sqlite3VdbeAddOp2(v, OP_Rowid, 0, regResult+1);\n        }else{\n          sqlite3VdbeAddOp2(v, OP_Null, 0, regResult+1);\n        }\n        sqlite3VdbeMultiLoad(v, regResult+2, \"siX\", pFK->zTo, i-1);\n        sqlite3VdbeAddOp2(v, OP_ResultRow, regResult, 4);\n        sqlite3VdbeResolveLabel(v, addrOk);\n        sqlite3DbFree(db, aiCols);\n      }\n      sqlite3VdbeAddOp2(v, OP_Next, 0, addrTop+1); VdbeCoverage(v);\n      sqlite3VdbeJumpHere(v, addrTop);\n    }\n  }\n  break;\n#endif /* !defined(SQLITE_OMIT_TRIGGER) */\n#endif /* !defined(SQLITE_OMIT_FOREIGN_KEY) */\n\n  /* Reinstall the LIKE and GLOB functions.  The variant of LIKE\n  ** used will be case sensitive or not depending on the RHS.\n  */\n  case PragTyp_CASE_SENSITIVE_LIKE: {\n    if( zRight ){\n      sqlite3RegisterLikeFunctions(db, sqlite3GetBoolean(zRight, 0));\n    }\n  }\n  break;\n\n#ifndef SQLITE_INTEGRITY_CHECK_ERROR_MAX\n# define SQLITE_INTEGRITY_CHECK_ERROR_MAX 100\n#endif\n\n#ifndef SQLITE_OMIT_INTEGRITY_CHECK\n  /*    PRAGMA integrity_check\n  **    PRAGMA integrity_check(N)\n  **    PRAGMA quick_check\n  **    PRAGMA quick_check(N)\n  **\n  ** Verify the integrity of the database.\n  **\n  ** The \"quick_check\" is reduced version of \n  ** integrity_check designed to detect most database corruption\n  ** without the overhead of cross-checking indexes.  Quick_check\n  ** is linear time wherease integrity_check is O(NlogN).\n  */\n  case PragTyp_INTEGRITY_CHECK: {\n    int i, j, addr, mxErr;\n\n    int isQuick = (sqlite3Tolower(zLeft[0])=='q');\n\n    /* If the PRAGMA command was of the form \"PRAGMA <db>.integrity_check\",\n    ** then iDb is set to the index of the database identified by <db>.\n    ** In this case, the integrity of database iDb only is verified by\n    ** the VDBE created below.\n    **\n    ** Otherwise, if the command was simply \"PRAGMA integrity_check\" (or\n    ** \"PRAGMA quick_check\"), then iDb is set to 0. In this case, set iDb\n    ** to -1 here, to indicate that the VDBE should verify the integrity\n    ** of all attached databases.  */\n    assert( iDb>=0 );\n    assert( iDb==0 || pId2->z );\n    if( pId2->z==0 ) iDb = -1;\n\n    /* Initialize the VDBE program */\n    pParse->nMem = 6;\n\n    /* Set the maximum error count */\n    mxErr = SQLITE_INTEGRITY_CHECK_ERROR_MAX;\n    if( zRight ){\n      sqlite3GetInt32(zRight, &mxErr);\n      if( mxErr<=0 ){\n        mxErr = SQLITE_INTEGRITY_CHECK_ERROR_MAX;\n      }\n    }\n    sqlite3VdbeAddOp2(v, OP_Integer, mxErr-1, 1); /* reg[1] holds errors left */\n\n    /* Do an integrity check on each database file */\n    for(i=0; i<db->nDb; i++){\n      HashElem *x;     /* For looping over tables in the schema */\n      Hash *pTbls;     /* Set of all tables in the schema */\n      int *aRoot;      /* Array of root page numbers of all btrees */\n      int cnt = 0;     /* Number of entries in aRoot[] */\n      int mxIdx = 0;   /* Maximum number of indexes for any table */\n\n      if( OMIT_TEMPDB && i==1 ) continue;\n      if( iDb>=0 && i!=iDb ) continue;\n\n      sqlite3CodeVerifySchema(pParse, i);\n\n      /* Do an integrity check of the B-Tree\n      **\n      ** Begin by finding the root pages numbers\n      ** for all tables and indices in the database.\n      */\n      assert( sqlite3SchemaMutexHeld(db, i, 0) );\n      pTbls = &db->aDb[i].pSchema->tblHash;\n      for(cnt=0, x=sqliteHashFirst(pTbls); x; x=sqliteHashNext(x)){\n        Table *pTab = sqliteHashData(x);  /* Current table */\n        Index *pIdx;                      /* An index on pTab */\n        int nIdx;                         /* Number of indexes on pTab */\n        if( HasRowid(pTab) ) cnt++;\n        for(nIdx=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, nIdx++){ cnt++; }\n        if( nIdx>mxIdx ) mxIdx = nIdx;\n      }\n      aRoot = sqlite3DbMallocRawNN(db, sizeof(int)*(cnt+1));\n      if( aRoot==0 ) break;\n      for(cnt=0, x=sqliteHashFirst(pTbls); x; x=sqliteHashNext(x)){\n        Table *pTab = sqliteHashData(x);\n        Index *pIdx;\n        if( HasRowid(pTab) ) aRoot[++cnt] = pTab->tnum;\n        for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){\n          aRoot[++cnt] = pIdx->tnum;\n        }\n      }\n      aRoot[0] = cnt;\n\n      /* Make sure sufficient number of registers have been allocated */\n      pParse->nMem = MAX( pParse->nMem, 8+mxIdx );\n      sqlite3ClearTempRegCache(pParse);\n\n      /* Do the b-tree integrity checks */\n      sqlite3VdbeAddOp4(v, OP_IntegrityCk, 2, cnt, 1, (char*)aRoot,P4_INTARRAY);\n      sqlite3VdbeChangeP5(v, (u8)i);\n      addr = sqlite3VdbeAddOp1(v, OP_IsNull, 2); VdbeCoverage(v);\n      sqlite3VdbeAddOp4(v, OP_String8, 0, 3, 0,\n         sqlite3MPrintf(db, \"*** in database %s ***\\n\", db->aDb[i].zDbSName),\n         P4_DYNAMIC);\n      sqlite3VdbeAddOp3(v, OP_Concat, 2, 3, 3);\n      integrityCheckResultRow(v);\n      sqlite3VdbeJumpHere(v, addr);\n\n      /* Make sure all the indices are constructed correctly.\n      */\n      for(x=sqliteHashFirst(pTbls); x; x=sqliteHashNext(x)){\n        Table *pTab = sqliteHashData(x);\n        Index *pIdx, *pPk;\n        Index *pPrior = 0;\n        int loopTop;\n        int iDataCur, iIdxCur;\n        int r1 = -1;\n\n        if( pTab->tnum<1 ) continue;  /* Skip VIEWs or VIRTUAL TABLEs */\n        pPk = HasRowid(pTab) ? 0 : sqlite3PrimaryKeyIndex(pTab);\n        sqlite3OpenTableAndIndices(pParse, pTab, OP_OpenRead, 0,\n                                   1, 0, &iDataCur, &iIdxCur);\n        /* reg[7] counts the number of entries in the table.\n        ** reg[8+i] counts the number of entries in the i-th index \n        */\n        sqlite3VdbeAddOp2(v, OP_Integer, 0, 7);\n        for(j=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, j++){\n          sqlite3VdbeAddOp2(v, OP_Integer, 0, 8+j); /* index entries counter */\n        }\n        assert( pParse->nMem>=8+j );\n        assert( sqlite3NoTempsInRange(pParse,1,7+j) );\n        sqlite3VdbeAddOp2(v, OP_Rewind, iDataCur, 0); VdbeCoverage(v);\n        loopTop = sqlite3VdbeAddOp2(v, OP_AddImm, 7, 1);\n        if( !isQuick ){\n          /* Sanity check on record header decoding */\n          sqlite3VdbeAddOp3(v, OP_Column, iDataCur, pTab->nCol-1, 3);\n          sqlite3VdbeChangeP5(v, OPFLAG_TYPEOFARG);\n        }\n        /* Verify that all NOT NULL columns really are NOT NULL */\n        for(j=0; j<pTab->nCol; j++){\n          char *zErr;\n          int jmp2;\n          if( j==pTab->iPKey ) continue;\n          if( pTab->aCol[j].notNull==0 ) continue;\n          sqlite3ExprCodeGetColumnOfTable(v, pTab, iDataCur, j, 3);\n          sqlite3VdbeChangeP5(v, OPFLAG_TYPEOFARG);\n          jmp2 = sqlite3VdbeAddOp1(v, OP_NotNull, 3); VdbeCoverage(v);\n          zErr = sqlite3MPrintf(db, \"NULL value in %s.%s\", pTab->zName,\n                              pTab->aCol[j].zName);\n          sqlite3VdbeAddOp4(v, OP_String8, 0, 3, 0, zErr, P4_DYNAMIC);\n          integrityCheckResultRow(v);\n          sqlite3VdbeJumpHere(v, jmp2);\n        }\n        /* Verify CHECK constraints */\n        if( pTab->pCheck && (db->flags & SQLITE_IgnoreChecks)==0 ){\n          ExprList *pCheck = sqlite3ExprListDup(db, pTab->pCheck, 0);\n          if( db->mallocFailed==0 ){\n            int addrCkFault = sqlite3VdbeMakeLabel(pParse);\n            int addrCkOk = sqlite3VdbeMakeLabel(pParse);\n            char *zErr;\n            int k;\n            pParse->iSelfTab = iDataCur + 1;\n            for(k=pCheck->nExpr-1; k>0; k--){\n              sqlite3ExprIfFalse(pParse, pCheck->a[k].pExpr, addrCkFault, 0);\n            }\n            sqlite3ExprIfTrue(pParse, pCheck->a[0].pExpr, addrCkOk, \n                SQLITE_JUMPIFNULL);\n            sqlite3VdbeResolveLabel(v, addrCkFault);\n            pParse->iSelfTab = 0;\n            zErr = sqlite3MPrintf(db, \"CHECK constraint failed in %s\",\n                pTab->zName);\n            sqlite3VdbeAddOp4(v, OP_String8, 0, 3, 0, zErr, P4_DYNAMIC);\n            integrityCheckResultRow(v);\n            sqlite3VdbeResolveLabel(v, addrCkOk);\n          }\n          sqlite3ExprListDelete(db, pCheck);\n        }\n        if( !isQuick ){ /* Omit the remaining tests for quick_check */\n          /* Validate index entries for the current row */\n          for(j=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, j++){\n            int jmp2, jmp3, jmp4, jmp5;\n            int ckUniq = sqlite3VdbeMakeLabel(pParse);\n            if( pPk==pIdx ) continue;\n            r1 = sqlite3GenerateIndexKey(pParse, pIdx, iDataCur, 0, 0, &jmp3,\n                                         pPrior, r1);\n            pPrior = pIdx;\n            sqlite3VdbeAddOp2(v, OP_AddImm, 8+j, 1);/* increment entry count */\n            /* Verify that an index entry exists for the current table row */\n            jmp2 = sqlite3VdbeAddOp4Int(v, OP_Found, iIdxCur+j, ckUniq, r1,\n                                        pIdx->nColumn); VdbeCoverage(v);\n            sqlite3VdbeLoadString(v, 3, \"row \");\n            sqlite3VdbeAddOp3(v, OP_Concat, 7, 3, 3);\n            sqlite3VdbeLoadString(v, 4, \" missing from index \");\n            sqlite3VdbeAddOp3(v, OP_Concat, 4, 3, 3);\n            jmp5 = sqlite3VdbeLoadString(v, 4, pIdx->zName);\n            sqlite3VdbeAddOp3(v, OP_Concat, 4, 3, 3);\n            jmp4 = integrityCheckResultRow(v);\n            sqlite3VdbeJumpHere(v, jmp2);\n            /* For UNIQUE indexes, verify that only one entry exists with the\n            ** current key.  The entry is unique if (1) any column is NULL\n            ** or (2) the next entry has a different key */\n            if( IsUniqueIndex(pIdx) ){\n              int uniqOk = sqlite3VdbeMakeLabel(pParse);\n              int jmp6;\n              int kk;\n              for(kk=0; kk<pIdx->nKeyCol; kk++){\n                int iCol = pIdx->aiColumn[kk];\n                assert( iCol!=XN_ROWID && iCol<pTab->nCol );\n                if( iCol>=0 && pTab->aCol[iCol].notNull ) continue;\n                sqlite3VdbeAddOp2(v, OP_IsNull, r1+kk, uniqOk);\n                VdbeCoverage(v);\n              }\n              jmp6 = sqlite3VdbeAddOp1(v, OP_Next, iIdxCur+j); VdbeCoverage(v);\n              sqlite3VdbeGoto(v, uniqOk);\n              sqlite3VdbeJumpHere(v, jmp6);\n              sqlite3VdbeAddOp4Int(v, OP_IdxGT, iIdxCur+j, uniqOk, r1,\n                                   pIdx->nKeyCol); VdbeCoverage(v);\n              sqlite3VdbeLoadString(v, 3, \"non-unique entry in index \");\n              sqlite3VdbeGoto(v, jmp5);\n              sqlite3VdbeResolveLabel(v, uniqOk);\n            }\n            sqlite3VdbeJumpHere(v, jmp4);\n            sqlite3ResolvePartIdxLabel(pParse, jmp3);\n          }\n        }\n        sqlite3VdbeAddOp2(v, OP_Next, iDataCur, loopTop); VdbeCoverage(v);\n        sqlite3VdbeJumpHere(v, loopTop-1);\n#ifndef SQLITE_OMIT_BTREECOUNT\n        if( !isQuick ){\n          sqlite3VdbeLoadString(v, 2, \"wrong # of entries in index \");\n          for(j=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, j++){\n            if( pPk==pIdx ) continue;\n            sqlite3VdbeAddOp2(v, OP_Count, iIdxCur+j, 3);\n            addr = sqlite3VdbeAddOp3(v, OP_Eq, 8+j, 0, 3); VdbeCoverage(v);\n            sqlite3VdbeChangeP5(v, SQLITE_NOTNULL);\n            sqlite3VdbeLoadString(v, 4, pIdx->zName);\n            sqlite3VdbeAddOp3(v, OP_Concat, 4, 2, 3);\n            integrityCheckResultRow(v);\n            sqlite3VdbeJumpHere(v, addr);\n          }\n        }\n#endif /* SQLITE_OMIT_BTREECOUNT */\n      } \n    }\n    {\n      static const int iLn = VDBE_OFFSET_LINENO(2);\n      static const VdbeOpList endCode[] = {\n        { OP_AddImm,      1, 0,        0},    /* 0 */\n        { OP_IfNotZero,   1, 4,        0},    /* 1 */\n        { OP_String8,     0, 3,        0},    /* 2 */\n        { OP_ResultRow,   3, 1,        0},    /* 3 */\n        { OP_Halt,        0, 0,        0},    /* 4 */\n        { OP_String8,     0, 3,        0},    /* 5 */\n        { OP_Goto,        0, 3,        0},    /* 6 */\n      };\n      VdbeOp *aOp;\n\n      aOp = sqlite3VdbeAddOpList(v, ArraySize(endCode), endCode, iLn);\n      if( aOp ){\n        aOp[0].p2 = 1-mxErr;\n        aOp[2].p4type = P4_STATIC;\n        aOp[2].p4.z = \"ok\";\n        aOp[5].p4type = P4_STATIC;\n        aOp[5].p4.z = (char*)sqlite3ErrStr(SQLITE_CORRUPT);\n      }\n      sqlite3VdbeChangeP3(v, 0, sqlite3VdbeCurrentAddr(v)-2);\n    }\n  }\n  break;\n#endif /* SQLITE_OMIT_INTEGRITY_CHECK */\n\n#ifndef SQLITE_OMIT_UTF16\n  /*\n  **   PRAGMA encoding\n  **   PRAGMA encoding = \"utf-8\"|\"utf-16\"|\"utf-16le\"|\"utf-16be\"\n  **\n  ** In its first form, this pragma returns the encoding of the main\n  ** database. If the database is not initialized, it is initialized now.\n  **\n  ** The second form of this pragma is a no-op if the main database file\n  ** has not already been initialized. In this case it sets the default\n  ** encoding that will be used for the main database file if a new file\n  ** is created. If an existing main database file is opened, then the\n  ** default text encoding for the existing database is used.\n  ** \n  ** In all cases new databases created using the ATTACH command are\n  ** created to use the same default text encoding as the main database. If\n  ** the main database has not been initialized and/or created when ATTACH\n  ** is executed, this is done before the ATTACH operation.\n  **\n  ** In the second form this pragma sets the text encoding to be used in\n  ** new database files created using this database handle. It is only\n  ** useful if invoked immediately after the main database i\n  */\n  case PragTyp_ENCODING: {\n    static const struct EncName {\n      char *zName;\n      u8 enc;\n    } encnames[] = {\n      { \"UTF8\",     SQLITE_UTF8        },\n      { \"UTF-8\",    SQLITE_UTF8        },  /* Must be element [1] */\n      { \"UTF-16le\", SQLITE_UTF16LE     },  /* Must be element [2] */\n      { \"UTF-16be\", SQLITE_UTF16BE     },  /* Must be element [3] */\n      { \"UTF16le\",  SQLITE_UTF16LE     },\n      { \"UTF16be\",  SQLITE_UTF16BE     },\n      { \"UTF-16\",   0                  }, /* SQLITE_UTF16NATIVE */\n      { \"UTF16\",    0                  }, /* SQLITE_UTF16NATIVE */\n      { 0, 0 }\n    };\n    const struct EncName *pEnc;\n    if( !zRight ){    /* \"PRAGMA encoding\" */\n      if( sqlite3ReadSchema(pParse) ) goto pragma_out;\n      assert( encnames[SQLITE_UTF8].enc==SQLITE_UTF8 );\n      assert( encnames[SQLITE_UTF16LE].enc==SQLITE_UTF16LE );\n      assert( encnames[SQLITE_UTF16BE].enc==SQLITE_UTF16BE );\n      returnSingleText(v, encnames[ENC(pParse->db)].zName);\n    }else{                        /* \"PRAGMA encoding = XXX\" */\n      /* Only change the value of sqlite.enc if the database handle is not\n      ** initialized. If the main database exists, the new sqlite.enc value\n      ** will be overwritten when the schema is next loaded. If it does not\n      ** already exists, it will be created to use the new encoding value.\n      */\n      if( \n        !(DbHasProperty(db, 0, DB_SchemaLoaded)) || \n        DbHasProperty(db, 0, DB_Empty) \n      ){\n        for(pEnc=&encnames[0]; pEnc->zName; pEnc++){\n          if( 0==sqlite3StrICmp(zRight, pEnc->zName) ){\n            SCHEMA_ENC(db) = ENC(db) =\n                pEnc->enc ? pEnc->enc : SQLITE_UTF16NATIVE;\n            break;\n          }\n        }\n        if( !pEnc->zName ){\n          sqlite3ErrorMsg(pParse, \"unsupported encoding: %s\", zRight);\n        }\n      }\n    }\n  }\n  break;\n#endif /* SQLITE_OMIT_UTF16 */\n\n#ifndef SQLITE_OMIT_SCHEMA_VERSION_PRAGMAS\n  /*\n  **   PRAGMA [schema.]schema_version\n  **   PRAGMA [schema.]schema_version = <integer>\n  **\n  **   PRAGMA [schema.]user_version\n  **   PRAGMA [schema.]user_version = <integer>\n  **\n  **   PRAGMA [schema.]freelist_count\n  **\n  **   PRAGMA [schema.]data_version\n  **\n  **   PRAGMA [schema.]application_id\n  **   PRAGMA [schema.]application_id = <integer>\n  **\n  ** The pragma's schema_version and user_version are used to set or get\n  ** the value of the schema-version and user-version, respectively. Both\n  ** the schema-version and the user-version are 32-bit signed integers\n  ** stored in the database header.\n  **\n  ** The schema-cookie is usually only manipulated internally by SQLite. It\n  ** is incremented by SQLite whenever the database schema is modified (by\n  ** creating or dropping a table or index). The schema version is used by\n  ** SQLite each time a query is executed to ensure that the internal cache\n  ** of the schema used when compiling the SQL query matches the schema of\n  ** the database against which the compiled query is actually executed.\n  ** Subverting this mechanism by using \"PRAGMA schema_version\" to modify\n  ** the schema-version is potentially dangerous and may lead to program\n  ** crashes or database corruption. Use with caution!\n  **\n  ** The user-version is not used internally by SQLite. It may be used by\n  ** applications for any purpose.\n  */\n  case PragTyp_HEADER_VALUE: {\n    int iCookie = pPragma->iArg;  /* Which cookie to read or write */\n    sqlite3VdbeUsesBtree(v, iDb);\n    if( zRight && (pPragma->mPragFlg & PragFlg_ReadOnly)==0 ){\n      /* Write the specified cookie value */\n      static const VdbeOpList setCookie[] = {\n        { OP_Transaction,    0,  1,  0},    /* 0 */\n        { OP_SetCookie,      0,  0,  0},    /* 1 */\n      };\n      VdbeOp *aOp;\n      sqlite3VdbeVerifyNoMallocRequired(v, ArraySize(setCookie));\n      aOp = sqlite3VdbeAddOpList(v, ArraySize(setCookie), setCookie, 0);\n      if( ONLY_IF_REALLOC_STRESS(aOp==0) ) break;\n      aOp[0].p1 = iDb;\n      aOp[1].p1 = iDb;\n      aOp[1].p2 = iCookie;\n      aOp[1].p3 = sqlite3Atoi(zRight);\n    }else{\n      /* Read the specified cookie value */\n      static const VdbeOpList readCookie[] = {\n        { OP_Transaction,     0,  0,  0},    /* 0 */\n        { OP_ReadCookie,      0,  1,  0},    /* 1 */\n        { OP_ResultRow,       1,  1,  0}\n      };\n      VdbeOp *aOp;\n      sqlite3VdbeVerifyNoMallocRequired(v, ArraySize(readCookie));\n      aOp = sqlite3VdbeAddOpList(v, ArraySize(readCookie),readCookie,0);\n      if( ONLY_IF_REALLOC_STRESS(aOp==0) ) break;\n      aOp[0].p1 = iDb;\n      aOp[1].p1 = iDb;\n      aOp[1].p3 = iCookie;\n      sqlite3VdbeReusable(v);\n    }\n  }\n  break;\n#endif /* SQLITE_OMIT_SCHEMA_VERSION_PRAGMAS */\n\n#ifndef SQLITE_OMIT_COMPILEOPTION_DIAGS\n  /*\n  **   PRAGMA compile_options\n  **\n  ** Return the names of all compile-time options used in this build,\n  ** one option per row.\n  */\n  case PragTyp_COMPILE_OPTIONS: {\n    int i = 0;\n    const char *zOpt;\n    pParse->nMem = 1;\n    while( (zOpt = sqlite3_compileoption_get(i++))!=0 ){\n      sqlite3VdbeLoadString(v, 1, zOpt);\n      sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 1);\n    }\n    sqlite3VdbeReusable(v);\n  }\n  break;\n#endif /* SQLITE_OMIT_COMPILEOPTION_DIAGS */\n\n#ifndef SQLITE_OMIT_WAL\n  /*\n  **   PRAGMA [schema.]wal_checkpoint = passive|full|restart|truncate\n  **\n  ** Checkpoint the database.\n  */\n  case PragTyp_WAL_CHECKPOINT: {\n    int iBt = (pId2->z?iDb:SQLITE_MAX_ATTACHED);\n    int eMode = SQLITE_CHECKPOINT_PASSIVE;\n    if( zRight ){\n      if( sqlite3StrICmp(zRight, \"full\")==0 ){\n        eMode = SQLITE_CHECKPOINT_FULL;\n      }else if( sqlite3StrICmp(zRight, \"restart\")==0 ){\n        eMode = SQLITE_CHECKPOINT_RESTART;\n      }else if( sqlite3StrICmp(zRight, \"truncate\")==0 ){\n        eMode = SQLITE_CHECKPOINT_TRUNCATE;\n      }\n    }\n    pParse->nMem = 3;\n    sqlite3VdbeAddOp3(v, OP_Checkpoint, iBt, eMode, 1);\n    sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 3);\n  }\n  break;\n\n  /*\n  **   PRAGMA wal_autocheckpoint\n  **   PRAGMA wal_autocheckpoint = N\n  **\n  ** Configure a database connection to automatically checkpoint a database\n  ** after accumulating N frames in the log. Or query for the current value\n  ** of N.\n  */\n  case PragTyp_WAL_AUTOCHECKPOINT: {\n    if( zRight ){\n      sqlite3_wal_autocheckpoint(db, sqlite3Atoi(zRight));\n    }\n    returnSingleInt(v, \n       db->xWalCallback==sqlite3WalDefaultHook ? \n           SQLITE_PTR_TO_INT(db->pWalArg) : 0);\n  }\n  break;\n#endif\n\n  /*\n  **  PRAGMA shrink_memory\n  **\n  ** IMPLEMENTATION-OF: R-23445-46109 This pragma causes the database\n  ** connection on which it is invoked to free up as much memory as it\n  ** can, by calling sqlite3_db_release_memory().\n  */\n  case PragTyp_SHRINK_MEMORY: {\n    sqlite3_db_release_memory(db);\n    break;\n  }\n\n  /*\n  **  PRAGMA optimize\n  **  PRAGMA optimize(MASK)\n  **  PRAGMA schema.optimize\n  **  PRAGMA schema.optimize(MASK)\n  **\n  ** Attempt to optimize the database.  All schemas are optimized in the first\n  ** two forms, and only the specified schema is optimized in the latter two.\n  **\n  ** The details of optimizations performed by this pragma are expected\n  ** to change and improve over time.  Applications should anticipate that\n  ** this pragma will perform new optimizations in future releases.\n  **\n  ** The optional argument is a bitmask of optimizations to perform:\n  **\n  **    0x0001    Debugging mode.  Do not actually perform any optimizations\n  **              but instead return one line of text for each optimization\n  **              that would have been done.  Off by default.\n  **\n  **    0x0002    Run ANALYZE on tables that might benefit.  On by default.\n  **              See below for additional information.\n  **\n  **    0x0004    (Not yet implemented) Record usage and performance \n  **              information from the current session in the\n  **              database file so that it will be available to \"optimize\"\n  **              pragmas run by future database connections.\n  **\n  **    0x0008    (Not yet implemented) Create indexes that might have\n  **              been helpful to recent queries\n  **\n  ** The default MASK is and always shall be 0xfffe.  0xfffe means perform all\n  ** of the optimizations listed above except Debug Mode, including new\n  ** optimizations that have not yet been invented.  If new optimizations are\n  ** ever added that should be off by default, those off-by-default \n  ** optimizations will have bitmasks of 0x10000 or larger.\n  **\n  ** DETERMINATION OF WHEN TO RUN ANALYZE\n  **\n  ** In the current implementation, a table is analyzed if only if all of\n  ** the following are true:\n  **\n  ** (1) MASK bit 0x02 is set.\n  **\n  ** (2) The query planner used sqlite_stat1-style statistics for one or\n  **     more indexes of the table at some point during the lifetime of\n  **     the current connection.\n  **\n  ** (3) One or more indexes of the table are currently unanalyzed OR\n  **     the number of rows in the table has increased by 25 times or more\n  **     since the last time ANALYZE was run.\n  **\n  ** The rules for when tables are analyzed are likely to change in\n  ** future releases.\n  */\n  case PragTyp_OPTIMIZE: {\n    int iDbLast;           /* Loop termination point for the schema loop */\n    int iTabCur;           /* Cursor for a table whose size needs checking */\n    HashElem *k;           /* Loop over tables of a schema */\n    Schema *pSchema;       /* The current schema */\n    Table *pTab;           /* A table in the schema */\n    Index *pIdx;           /* An index of the table */\n    LogEst szThreshold;    /* Size threshold above which reanalysis is needd */\n    char *zSubSql;         /* SQL statement for the OP_SqlExec opcode */\n    u32 opMask;            /* Mask of operations to perform */\n\n    if( zRight ){\n      opMask = (u32)sqlite3Atoi(zRight);\n      if( (opMask & 0x02)==0 ) break;\n    }else{\n      opMask = 0xfffe;\n    }\n    iTabCur = pParse->nTab++;\n    for(iDbLast = zDb?iDb:db->nDb-1; iDb<=iDbLast; iDb++){\n      if( iDb==1 ) continue;\n      sqlite3CodeVerifySchema(pParse, iDb);\n      pSchema = db->aDb[iDb].pSchema;\n      for(k=sqliteHashFirst(&pSchema->tblHash); k; k=sqliteHashNext(k)){\n        pTab = (Table*)sqliteHashData(k);\n\n        /* If table pTab has not been used in a way that would benefit from\n        ** having analysis statistics during the current session, then skip it.\n        ** This also has the effect of skipping virtual tables and views */\n        if( (pTab->tabFlags & TF_StatsUsed)==0 ) continue;\n\n        /* Reanalyze if the table is 25 times larger than the last analysis */\n        szThreshold = pTab->nRowLogEst + 46; assert( sqlite3LogEst(25)==46 );\n        for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){\n          if( !pIdx->hasStat1 ){\n            szThreshold = 0; /* Always analyze if any index lacks statistics */\n            break;\n          }\n        }\n        if( szThreshold ){\n          sqlite3OpenTable(pParse, iTabCur, iDb, pTab, OP_OpenRead);\n          sqlite3VdbeAddOp3(v, OP_IfSmaller, iTabCur, \n                         sqlite3VdbeCurrentAddr(v)+2+(opMask&1), szThreshold);\n          VdbeCoverage(v);\n        }\n        zSubSql = sqlite3MPrintf(db, \"ANALYZE \\\"%w\\\".\\\"%w\\\"\",\n                                 db->aDb[iDb].zDbSName, pTab->zName);\n        if( opMask & 0x01 ){\n          int r1 = sqlite3GetTempReg(pParse);\n          sqlite3VdbeAddOp4(v, OP_String8, 0, r1, 0, zSubSql, P4_DYNAMIC);\n          sqlite3VdbeAddOp2(v, OP_ResultRow, r1, 1);\n        }else{\n          sqlite3VdbeAddOp4(v, OP_SqlExec, 0, 0, 0, zSubSql, P4_DYNAMIC);\n        }\n      }\n    }\n    sqlite3VdbeAddOp0(v, OP_Expire);\n    break;\n  }\n\n  /*\n  **   PRAGMA busy_timeout\n  **   PRAGMA busy_timeout = N\n  **\n  ** Call sqlite3_busy_timeout(db, N).  Return the current timeout value\n  ** if one is set.  If no busy handler or a different busy handler is set\n  ** then 0 is returned.  Setting the busy_timeout to 0 or negative\n  ** disables the timeout.\n  */\n  /*case PragTyp_BUSY_TIMEOUT*/ default: {\n    assert( pPragma->ePragTyp==PragTyp_BUSY_TIMEOUT );\n    if( zRight ){\n      sqlite3_busy_timeout(db, sqlite3Atoi(zRight));\n    }\n    returnSingleInt(v, db->busyTimeout);\n    break;\n  }\n\n  /*\n  **   PRAGMA soft_heap_limit\n  **   PRAGMA soft_heap_limit = N\n  **\n  ** IMPLEMENTATION-OF: R-26343-45930 This pragma invokes the\n  ** sqlite3_soft_heap_limit64() interface with the argument N, if N is\n  ** specified and is a non-negative integer.\n  ** IMPLEMENTATION-OF: R-64451-07163 The soft_heap_limit pragma always\n  ** returns the same integer that would be returned by the\n  ** sqlite3_soft_heap_limit64(-1) C-language function.\n  */\n  case PragTyp_SOFT_HEAP_LIMIT: {\n    sqlite3_int64 N;\n    if( zRight && sqlite3DecOrHexToI64(zRight, &N)==SQLITE_OK ){\n      sqlite3_soft_heap_limit64(N);\n    }\n    returnSingleInt(v, sqlite3_soft_heap_limit64(-1));\n    break;\n  }\n\n  /*\n  **   PRAGMA threads\n  **   PRAGMA threads = N\n  **\n  ** Configure the maximum number of worker threads.  Return the new\n  ** maximum, which might be less than requested.\n  */\n  case PragTyp_THREADS: {\n    sqlite3_int64 N;\n    if( zRight\n     && sqlite3DecOrHexToI64(zRight, &N)==SQLITE_OK\n     && N>=0\n    ){\n      sqlite3_limit(db, SQLITE_LIMIT_WORKER_THREADS, (int)(N&0x7fffffff));\n    }\n    returnSingleInt(v, sqlite3_limit(db, SQLITE_LIMIT_WORKER_THREADS, -1));\n    break;\n  }\n\n#if defined(SQLITE_DEBUG) || defined(SQLITE_TEST)\n  /*\n  ** Report the current state of file logs for all databases\n  */\n  case PragTyp_LOCK_STATUS: {\n    static const char *const azLockName[] = {\n      \"unlocked\", \"shared\", \"reserved\", \"pending\", \"exclusive\"\n    };\n    int i;\n    pParse->nMem = 2;\n    for(i=0; i<db->nDb; i++){\n      Btree *pBt;\n      const char *zState = \"unknown\";\n      int j;\n      if( db->aDb[i].zDbSName==0 ) continue;\n      pBt = db->aDb[i].pBt;\n      if( pBt==0 || sqlite3BtreePager(pBt)==0 ){\n        zState = \"closed\";\n      }else if( sqlite3_file_control(db, i ? db->aDb[i].zDbSName : 0, \n                                     SQLITE_FCNTL_LOCKSTATE, &j)==SQLITE_OK ){\n         zState = azLockName[j];\n      }\n      sqlite3VdbeMultiLoad(v, 1, \"ss\", db->aDb[i].zDbSName, zState);\n    }\n    break;\n  }\n#endif\n\n#ifdef SQLITE_HAS_CODEC\n  /* Pragma        iArg\n  ** ----------   ------\n  **  key           0\n  **  rekey         1\n  **  hexkey        2\n  **  hexrekey      3\n  **  textkey       4\n  **  textrekey     5\n  */\n  case PragTyp_KEY: {\n    if( zRight ){\n      int n = pPragma->iArg<4 ? sqlite3Strlen30(zRight) : -1;\n      if( (pPragma->iArg & 1)==0 ){\n        sqlite3_key_v2(db, zDb, zRight, n);\n      }else{\n        sqlite3_rekey_v2(db, zDb, zRight, n);\n      }\n    }\n    break;\n  }\n  case PragTyp_HEXKEY: {\n    if( zRight ){\n      u8 iByte;\n      int i;\n      char zKey[40];\n      for(i=0, iByte=0; i<sizeof(zKey)*2 && sqlite3Isxdigit(zRight[i]); i++){\n        iByte = (iByte<<4) + sqlite3HexToInt(zRight[i]);\n        if( (i&1)!=0 ) zKey[i/2] = iByte;\n      }\n      if( (pPragma->iArg & 1)==0 ){\n        sqlite3_key_v2(db, zDb, zKey, i/2);\n      }else{\n        sqlite3_rekey_v2(db, zDb, zKey, i/2);\n      }\n    }\n    break;\n  }\n#endif\n#if defined(SQLITE_HAS_CODEC) || defined(SQLITE_ENABLE_CEROD)\n  case PragTyp_ACTIVATE_EXTENSIONS: if( zRight ){\n#ifdef SQLITE_HAS_CODEC\n    if( sqlite3StrNICmp(zRight, \"see-\", 4)==0 ){\n      sqlite3_activate_see(&zRight[4]);\n    }\n#endif\n#ifdef SQLITE_ENABLE_CEROD\n    if( sqlite3StrNICmp(zRight, \"cerod-\", 6)==0 ){\n      sqlite3_activate_cerod(&zRight[6]);\n    }\n#endif\n  }\n  break;\n#endif\n\n  } /* End of the PRAGMA switch */\n\n  /* The following block is a no-op unless SQLITE_DEBUG is defined. Its only\n  ** purpose is to execute assert() statements to verify that if the\n  ** PragFlg_NoColumns1 flag is set and the caller specified an argument\n  ** to the PRAGMA, the implementation has not added any OP_ResultRow \n  ** instructions to the VM.  */\n  if( (pPragma->mPragFlg & PragFlg_NoColumns1) && zRight ){\n    sqlite3VdbeVerifyNoResultRow(v);\n  }\n\npragma_out:\n  sqlite3DbFree(db, zLeft);\n  sqlite3DbFree(db, zRight);\n}\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n/*****************************************************************************\n** Implementation of an eponymous virtual table that runs a pragma.\n**\n*/\ntypedef struct PragmaVtab PragmaVtab;\ntypedef struct PragmaVtabCursor PragmaVtabCursor;\nstruct PragmaVtab {\n  sqlite3_vtab base;        /* Base class.  Must be first */\n  sqlite3 *db;              /* The database connection to which it belongs */\n  const PragmaName *pName;  /* Name of the pragma */\n  u8 nHidden;               /* Number of hidden columns */\n  u8 iHidden;               /* Index of the first hidden column */\n};\nstruct PragmaVtabCursor {\n  sqlite3_vtab_cursor base; /* Base class.  Must be first */\n  sqlite3_stmt *pPragma;    /* The pragma statement to run */\n  sqlite_int64 iRowid;      /* Current rowid */\n  char *azArg[2];           /* Value of the argument and schema */\n};\n\n/* \n** Pragma virtual table module xConnect method.\n*/\nstatic int pragmaVtabConnect(\n  sqlite3 *db,\n  void *pAux,\n  int argc, const char *const*argv,\n  sqlite3_vtab **ppVtab,\n  char **pzErr\n){\n  const PragmaName *pPragma = (const PragmaName*)pAux;\n  PragmaVtab *pTab = 0;\n  int rc;\n  int i, j;\n  char cSep = '(';\n  StrAccum acc;\n  char zBuf[200];\n\n  UNUSED_PARAMETER(argc);\n  UNUSED_PARAMETER(argv);\n  sqlite3StrAccumInit(&acc, 0, zBuf, sizeof(zBuf), 0);\n  sqlite3_str_appendall(&acc, \"CREATE TABLE x\");\n  for(i=0, j=pPragma->iPragCName; i<pPragma->nPragCName; i++, j++){\n    sqlite3_str_appendf(&acc, \"%c\\\"%s\\\"\", cSep, pragCName[j]);\n    cSep = ',';\n  }\n  if( i==0 ){\n    sqlite3_str_appendf(&acc, \"(\\\"%s\\\"\", pPragma->zName);\n    i++;\n  }\n  j = 0;\n  if( pPragma->mPragFlg & PragFlg_Result1 ){\n    sqlite3_str_appendall(&acc, \",arg HIDDEN\");\n    j++;\n  }\n  if( pPragma->mPragFlg & (PragFlg_SchemaOpt|PragFlg_SchemaReq) ){\n    sqlite3_str_appendall(&acc, \",schema HIDDEN\");\n    j++;\n  }\n  sqlite3_str_append(&acc, \")\", 1);\n  sqlite3StrAccumFinish(&acc);\n  assert( strlen(zBuf) < sizeof(zBuf)-1 );\n  rc = sqlite3_declare_vtab(db, zBuf);\n  if( rc==SQLITE_OK ){\n    pTab = (PragmaVtab*)sqlite3_malloc(sizeof(PragmaVtab));\n    if( pTab==0 ){\n      rc = SQLITE_NOMEM;\n    }else{\n      memset(pTab, 0, sizeof(PragmaVtab));\n      pTab->pName = pPragma;\n      pTab->db = db;\n      pTab->iHidden = i;\n      pTab->nHidden = j;\n    }\n  }else{\n    *pzErr = sqlite3_mprintf(\"%s\", sqlite3_errmsg(db));\n  }\n\n  *ppVtab = (sqlite3_vtab*)pTab;\n  return rc;\n}\n\n/* \n** Pragma virtual table module xDisconnect method.\n*/\nstatic int pragmaVtabDisconnect(sqlite3_vtab *pVtab){\n  PragmaVtab *pTab = (PragmaVtab*)pVtab;\n  sqlite3_free(pTab);\n  return SQLITE_OK;\n}\n\n/* Figure out the best index to use to search a pragma virtual table.\n**\n** There are not really any index choices.  But we want to encourage the\n** query planner to give == constraints on as many hidden parameters as\n** possible, and especially on the first hidden parameter.  So return a\n** high cost if hidden parameters are unconstrained.\n*/\nstatic int pragmaVtabBestIndex(sqlite3_vtab *tab, sqlite3_index_info *pIdxInfo){\n  PragmaVtab *pTab = (PragmaVtab*)tab;\n  const struct sqlite3_index_constraint *pConstraint;\n  int i, j;\n  int seen[2];\n\n  pIdxInfo->estimatedCost = (double)1;\n  if( pTab->nHidden==0 ){ return SQLITE_OK; }\n  pConstraint = pIdxInfo->aConstraint;\n  seen[0] = 0;\n  seen[1] = 0;\n  for(i=0; i<pIdxInfo->nConstraint; i++, pConstraint++){\n    if( pConstraint->usable==0 ) continue;\n    if( pConstraint->op!=SQLITE_INDEX_CONSTRAINT_EQ ) continue;\n    if( pConstraint->iColumn < pTab->iHidden ) continue;\n    j = pConstraint->iColumn - pTab->iHidden;\n    assert( j < 2 );\n    seen[j] = i+1;\n  }\n  if( seen[0]==0 ){\n    pIdxInfo->estimatedCost = (double)2147483647;\n    pIdxInfo->estimatedRows = 2147483647;\n    return SQLITE_OK;\n  }\n  j = seen[0]-1;\n  pIdxInfo->aConstraintUsage[j].argvIndex = 1;\n  pIdxInfo->aConstraintUsage[j].omit = 1;\n  if( seen[1]==0 ) return SQLITE_OK;\n  pIdxInfo->estimatedCost = (double)20;\n  pIdxInfo->estimatedRows = 20;\n  j = seen[1]-1;\n  pIdxInfo->aConstraintUsage[j].argvIndex = 2;\n  pIdxInfo->aConstraintUsage[j].omit = 1;\n  return SQLITE_OK;\n}\n\n/* Create a new cursor for the pragma virtual table */\nstatic int pragmaVtabOpen(sqlite3_vtab *pVtab, sqlite3_vtab_cursor **ppCursor){\n  PragmaVtabCursor *pCsr;\n  pCsr = (PragmaVtabCursor*)sqlite3_malloc(sizeof(*pCsr));\n  if( pCsr==0 ) return SQLITE_NOMEM;\n  memset(pCsr, 0, sizeof(PragmaVtabCursor));\n  pCsr->base.pVtab = pVtab;\n  *ppCursor = &pCsr->base;\n  return SQLITE_OK;\n}\n\n/* Clear all content from pragma virtual table cursor. */\nstatic void pragmaVtabCursorClear(PragmaVtabCursor *pCsr){\n  int i;\n  sqlite3_finalize(pCsr->pPragma);\n  pCsr->pPragma = 0;\n  for(i=0; i<ArraySize(pCsr->azArg); i++){\n    sqlite3_free(pCsr->azArg[i]);\n    pCsr->azArg[i] = 0;\n  }\n}\n\n/* Close a pragma virtual table cursor */\nstatic int pragmaVtabClose(sqlite3_vtab_cursor *cur){\n  PragmaVtabCursor *pCsr = (PragmaVtabCursor*)cur;\n  pragmaVtabCursorClear(pCsr);\n  sqlite3_free(pCsr);\n  return SQLITE_OK;\n}\n\n/* Advance the pragma virtual table cursor to the next row */\nstatic int pragmaVtabNext(sqlite3_vtab_cursor *pVtabCursor){\n  PragmaVtabCursor *pCsr = (PragmaVtabCursor*)pVtabCursor;\n  int rc = SQLITE_OK;\n\n  /* Increment the xRowid value */\n  pCsr->iRowid++;\n  assert( pCsr->pPragma );\n  if( SQLITE_ROW!=sqlite3_step(pCsr->pPragma) ){\n    rc = sqlite3_finalize(pCsr->pPragma);\n    pCsr->pPragma = 0;\n    pragmaVtabCursorClear(pCsr);\n  }\n  return rc;\n}\n\n/* \n** Pragma virtual table module xFilter method.\n*/\nstatic int pragmaVtabFilter(\n  sqlite3_vtab_cursor *pVtabCursor, \n  int idxNum, const char *idxStr,\n  int argc, sqlite3_value **argv\n){\n  PragmaVtabCursor *pCsr = (PragmaVtabCursor*)pVtabCursor;\n  PragmaVtab *pTab = (PragmaVtab*)(pVtabCursor->pVtab);\n  int rc;\n  int i, j;\n  StrAccum acc;\n  char *zSql;\n\n  UNUSED_PARAMETER(idxNum);\n  UNUSED_PARAMETER(idxStr);\n  pragmaVtabCursorClear(pCsr);\n  j = (pTab->pName->mPragFlg & PragFlg_Result1)!=0 ? 0 : 1;\n  for(i=0; i<argc; i++, j++){\n    const char *zText = (const char*)sqlite3_value_text(argv[i]);\n    assert( j<ArraySize(pCsr->azArg) );\n    assert( pCsr->azArg[j]==0 );\n    if( zText ){\n      pCsr->azArg[j] = sqlite3_mprintf(\"%s\", zText);\n      if( pCsr->azArg[j]==0 ){\n        return SQLITE_NOMEM;\n      }\n    }\n  }\n  sqlite3StrAccumInit(&acc, 0, 0, 0, pTab->db->aLimit[SQLITE_LIMIT_SQL_LENGTH]);\n  sqlite3_str_appendall(&acc, \"PRAGMA \");\n  if( pCsr->azArg[1] ){\n    sqlite3_str_appendf(&acc, \"%Q.\", pCsr->azArg[1]);\n  }\n  sqlite3_str_appendall(&acc, pTab->pName->zName);\n  if( pCsr->azArg[0] ){\n    sqlite3_str_appendf(&acc, \"=%Q\", pCsr->azArg[0]);\n  }\n  zSql = sqlite3StrAccumFinish(&acc);\n  if( zSql==0 ) return SQLITE_NOMEM;\n  rc = sqlite3_prepare_v2(pTab->db, zSql, -1, &pCsr->pPragma, 0);\n  sqlite3_free(zSql);\n  if( rc!=SQLITE_OK ){\n    pTab->base.zErrMsg = sqlite3_mprintf(\"%s\", sqlite3_errmsg(pTab->db));\n    return rc;\n  }\n  return pragmaVtabNext(pVtabCursor);\n}\n\n/*\n** Pragma virtual table module xEof method.\n*/\nstatic int pragmaVtabEof(sqlite3_vtab_cursor *pVtabCursor){\n  PragmaVtabCursor *pCsr = (PragmaVtabCursor*)pVtabCursor;\n  return (pCsr->pPragma==0);\n}\n\n/* The xColumn method simply returns the corresponding column from\n** the PRAGMA.  \n*/\nstatic int pragmaVtabColumn(\n  sqlite3_vtab_cursor *pVtabCursor, \n  sqlite3_context *ctx, \n  int i\n){\n  PragmaVtabCursor *pCsr = (PragmaVtabCursor*)pVtabCursor;\n  PragmaVtab *pTab = (PragmaVtab*)(pVtabCursor->pVtab);\n  if( i<pTab->iHidden ){\n    sqlite3_result_value(ctx, sqlite3_column_value(pCsr->pPragma, i));\n  }else{\n    sqlite3_result_text(ctx, pCsr->azArg[i-pTab->iHidden],-1,SQLITE_TRANSIENT);\n  }\n  return SQLITE_OK;\n}\n\n/* \n** Pragma virtual table module xRowid method.\n*/\nstatic int pragmaVtabRowid(sqlite3_vtab_cursor *pVtabCursor, sqlite_int64 *p){\n  PragmaVtabCursor *pCsr = (PragmaVtabCursor*)pVtabCursor;\n  *p = pCsr->iRowid;\n  return SQLITE_OK;\n}\n\n/* The pragma virtual table object */\nstatic const sqlite3_module pragmaVtabModule = {\n  0,                           /* iVersion */\n  0,                           /* xCreate - create a table */\n  pragmaVtabConnect,           /* xConnect - connect to an existing table */\n  pragmaVtabBestIndex,         /* xBestIndex - Determine search strategy */\n  pragmaVtabDisconnect,        /* xDisconnect - Disconnect from a table */\n  0,                           /* xDestroy - Drop a table */\n  pragmaVtabOpen,              /* xOpen - open a cursor */\n  pragmaVtabClose,             /* xClose - close a cursor */\n  pragmaVtabFilter,            /* xFilter - configure scan constraints */\n  pragmaVtabNext,              /* xNext - advance a cursor */\n  pragmaVtabEof,               /* xEof */\n  pragmaVtabColumn,            /* xColumn - read data */\n  pragmaVtabRowid,             /* xRowid - read data */\n  0,                           /* xUpdate - write data */\n  0,                           /* xBegin - begin transaction */\n  0,                           /* xSync - sync transaction */\n  0,                           /* xCommit - commit transaction */\n  0,                           /* xRollback - rollback transaction */\n  0,                           /* xFindFunction - function overloading */\n  0,                           /* xRename - rename the table */\n  0,                           /* xSavepoint */\n  0,                           /* xRelease */\n  0,                           /* xRollbackTo */\n  0                            /* xShadowName */\n};\n\n/*\n** Check to see if zTabName is really the name of a pragma.  If it is,\n** then register an eponymous virtual table for that pragma and return\n** a pointer to the Module object for the new virtual table.\n*/\nSQLITE_PRIVATE Module *sqlite3PragmaVtabRegister(sqlite3 *db, const char *zName){\n  const PragmaName *pName;\n  assert( sqlite3_strnicmp(zName, \"pragma_\", 7)==0 );\n  pName = pragmaLocate(zName+7);\n  if( pName==0 ) return 0;\n  if( (pName->mPragFlg & (PragFlg_Result0|PragFlg_Result1))==0 ) return 0;\n  assert( sqlite3HashFind(&db->aModule, zName)==0 );\n  return sqlite3VtabCreateModule(db, zName, &pragmaVtabModule, (void*)pName, 0);\n}\n\n#endif /* SQLITE_OMIT_VIRTUALTABLE */\n\n#endif /* SQLITE_OMIT_PRAGMA */\n\n/************** End of pragma.c **********************************************/\n/************** Begin file prepare.c *****************************************/\n/*\n** 2005 May 25\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This file contains the implementation of the sqlite3_prepare()\n** interface, and routines that contribute to loading the database schema\n** from disk.\n*/\n/* #include \"sqliteInt.h\" */\n\n/*\n** Fill the InitData structure with an error message that indicates\n** that the database is corrupt.\n*/\nstatic void corruptSchema(\n  InitData *pData,     /* Initialization context */\n  const char *zObj,    /* Object being parsed at the point of error */\n  const char *zExtra   /* Error information */\n){\n  sqlite3 *db = pData->db;\n  if( db->mallocFailed ){\n    pData->rc = SQLITE_NOMEM_BKPT;\n  }else if( pData->pzErrMsg[0]!=0 ){\n    /* A error message has already been generated.  Do not overwrite it */\n  }else if( pData->mInitFlags & INITFLAG_AlterTable ){\n    *pData->pzErrMsg = sqlite3DbStrDup(db, zExtra);\n    pData->rc = SQLITE_ERROR;\n  }else if( db->flags & SQLITE_WriteSchema ){\n    pData->rc = SQLITE_CORRUPT_BKPT;\n  }else{\n    char *z;\n    if( zObj==0 ) zObj = \"?\";\n    z = sqlite3MPrintf(db, \"malformed database schema (%s)\", zObj);\n    if( zExtra && zExtra[0] ) z = sqlite3MPrintf(db, \"%z - %s\", z, zExtra);\n    *pData->pzErrMsg = z;\n    pData->rc = SQLITE_CORRUPT_BKPT;\n  }\n}\n\n/*\n** Check to see if any sibling index (another index on the same table)\n** of pIndex has the same root page number, and if it does, return true.\n** This would indicate a corrupt schema.\n*/\nSQLITE_PRIVATE int sqlite3IndexHasDuplicateRootPage(Index *pIndex){\n  Index *p;\n  for(p=pIndex->pTable->pIndex; p; p=p->pNext){\n    if( p->tnum==pIndex->tnum && p!=pIndex ) return 1;\n  }\n  return 0;\n}\n\n/*\n** This is the callback routine for the code that initializes the\n** database.  See sqlite3Init() below for additional information.\n** This routine is also called from the OP_ParseSchema opcode of the VDBE.\n**\n** Each callback contains the following information:\n**\n**     argv[0] = name of thing being created\n**     argv[1] = root page number for table or index. 0 for trigger or view.\n**     argv[2] = SQL text for the CREATE statement.\n**\n*/\nSQLITE_PRIVATE int sqlite3InitCallback(void *pInit, int argc, char **argv, char **NotUsed){\n  InitData *pData = (InitData*)pInit;\n  sqlite3 *db = pData->db;\n  int iDb = pData->iDb;\n\n  assert( argc==3 );\n  UNUSED_PARAMETER2(NotUsed, argc);\n  assert( sqlite3_mutex_held(db->mutex) );\n  DbClearProperty(db, iDb, DB_Empty);\n  pData->nInitRow++;\n  if( db->mallocFailed ){\n    corruptSchema(pData, argv[0], 0);\n    return 1;\n  }\n\n  assert( iDb>=0 && iDb<db->nDb );\n  if( argv==0 ) return 0;   /* Might happen if EMPTY_RESULT_CALLBACKS are on */\n  if( argv[1]==0 ){\n    corruptSchema(pData, argv[0], 0);\n  }else if( sqlite3_strnicmp(argv[2],\"create \",7)==0 ){\n    /* Call the parser to process a CREATE TABLE, INDEX or VIEW.\n    ** But because db->init.busy is set to 1, no VDBE code is generated\n    ** or executed.  All the parser does is build the internal data\n    ** structures that describe the table, index, or view.\n    */\n    int rc;\n    u8 saved_iDb = db->init.iDb;\n    sqlite3_stmt *pStmt;\n    TESTONLY(int rcp);            /* Return code from sqlite3_prepare() */\n\n    assert( db->init.busy );\n    db->init.iDb = iDb;\n    db->init.newTnum = sqlite3Atoi(argv[1]);\n    db->init.orphanTrigger = 0;\n    TESTONLY(rcp = ) sqlite3_prepare(db, argv[2], -1, &pStmt, 0);\n    rc = db->errCode;\n    assert( (rc&0xFF)==(rcp&0xFF) );\n    db->init.iDb = saved_iDb;\n    /* assert( saved_iDb==0 || (db->mDbFlags & DBFLAG_Vacuum)!=0 ); */\n    if( SQLITE_OK!=rc ){\n      if( db->init.orphanTrigger ){\n        assert( iDb==1 );\n      }else{\n        pData->rc = rc;\n        if( rc==SQLITE_NOMEM ){\n          sqlite3OomFault(db);\n        }else if( rc!=SQLITE_INTERRUPT && (rc&0xFF)!=SQLITE_LOCKED ){\n          corruptSchema(pData, argv[0], sqlite3_errmsg(db));\n        }\n      }\n    }\n    sqlite3_finalize(pStmt);\n  }else if( argv[0]==0 || (argv[2]!=0 && argv[2][0]!=0) ){\n    corruptSchema(pData, argv[0], 0);\n  }else{\n    /* If the SQL column is blank it means this is an index that\n    ** was created to be the PRIMARY KEY or to fulfill a UNIQUE\n    ** constraint for a CREATE TABLE.  The index should have already\n    ** been created when we processed the CREATE TABLE.  All we have\n    ** to do here is record the root page number for that index.\n    */\n    Index *pIndex;\n    pIndex = sqlite3FindIndex(db, argv[0], db->aDb[iDb].zDbSName);\n    if( pIndex==0\n     || sqlite3GetInt32(argv[1],&pIndex->tnum)==0\n     || pIndex->tnum<2\n     || sqlite3IndexHasDuplicateRootPage(pIndex)\n    ){\n      corruptSchema(pData, argv[0], pIndex?\"invalid rootpage\":\"orphan index\");\n    }\n  }\n  return 0;\n}\n\n/*\n** Attempt to read the database schema and initialize internal\n** data structures for a single database file.  The index of the\n** database file is given by iDb.  iDb==0 is used for the main\n** database.  iDb==1 should never be used.  iDb>=2 is used for\n** auxiliary databases.  Return one of the SQLITE_ error codes to\n** indicate success or failure.\n*/\nSQLITE_PRIVATE int sqlite3InitOne(sqlite3 *db, int iDb, char **pzErrMsg, u32 mFlags){\n  int rc;\n  int i;\n#ifndef SQLITE_OMIT_DEPRECATED\n  int size;\n#endif\n  Db *pDb;\n  char const *azArg[4];\n  int meta[5];\n  InitData initData;\n  const char *zMasterName;\n  int openedTransaction = 0;\n\n  assert( (db->mDbFlags & DBFLAG_SchemaKnownOk)==0 );\n  assert( iDb>=0 && iDb<db->nDb );\n  assert( db->aDb[iDb].pSchema );\n  assert( sqlite3_mutex_held(db->mutex) );\n  assert( iDb==1 || sqlite3BtreeHoldsMutex(db->aDb[iDb].pBt) );\n\n  db->init.busy = 1;\n\n  /* Construct the in-memory representation schema tables (sqlite_master or\n  ** sqlite_temp_master) by invoking the parser directly.  The appropriate\n  ** table name will be inserted automatically by the parser so we can just\n  ** use the abbreviation \"x\" here.  The parser will also automatically tag\n  ** the schema table as read-only. */\n  azArg[0] = zMasterName = SCHEMA_TABLE(iDb);\n  azArg[1] = \"1\";\n  azArg[2] = \"CREATE TABLE x(type text,name text,tbl_name text,\"\n                            \"rootpage int,sql text)\";\n  azArg[3] = 0;\n  initData.db = db;\n  initData.iDb = iDb;\n  initData.rc = SQLITE_OK;\n  initData.pzErrMsg = pzErrMsg;\n  initData.mInitFlags = mFlags;\n  initData.nInitRow = 0;\n  sqlite3InitCallback(&initData, 3, (char **)azArg, 0);\n  if( initData.rc ){\n    rc = initData.rc;\n    goto error_out;\n  }\n\n  /* Create a cursor to hold the database open\n  */\n  pDb = &db->aDb[iDb];\n  if( pDb->pBt==0 ){\n    assert( iDb==1 );\n    DbSetProperty(db, 1, DB_SchemaLoaded);\n    rc = SQLITE_OK;\n    goto error_out;\n  }\n\n  /* If there is not already a read-only (or read-write) transaction opened\n  ** on the b-tree database, open one now. If a transaction is opened, it \n  ** will be closed before this function returns.  */\n  sqlite3BtreeEnter(pDb->pBt);\n  if( !sqlite3BtreeIsInReadTrans(pDb->pBt) ){\n    rc = sqlite3BtreeBeginTrans(pDb->pBt, 0, 0);\n    if( rc!=SQLITE_OK ){\n      sqlite3SetString(pzErrMsg, db, sqlite3ErrStr(rc));\n      goto initone_error_out;\n    }\n    openedTransaction = 1;\n  }\n\n  /* Get the database meta information.\n  **\n  ** Meta values are as follows:\n  **    meta[0]   Schema cookie.  Changes with each schema change.\n  **    meta[1]   File format of schema layer.\n  **    meta[2]   Size of the page cache.\n  **    meta[3]   Largest rootpage (auto/incr_vacuum mode)\n  **    meta[4]   Db text encoding. 1:UTF-8 2:UTF-16LE 3:UTF-16BE\n  **    meta[5]   User version\n  **    meta[6]   Incremental vacuum mode\n  **    meta[7]   unused\n  **    meta[8]   unused\n  **    meta[9]   unused\n  **\n  ** Note: The #defined SQLITE_UTF* symbols in sqliteInt.h correspond to\n  ** the possible values of meta[4].\n  */\n  for(i=0; i<ArraySize(meta); i++){\n    sqlite3BtreeGetMeta(pDb->pBt, i+1, (u32 *)&meta[i]);\n  }\n  if( (db->flags & SQLITE_ResetDatabase)!=0 ){\n    memset(meta, 0, sizeof(meta));\n  }\n  pDb->pSchema->schema_cookie = meta[BTREE_SCHEMA_VERSION-1];\n\n  /* If opening a non-empty database, check the text encoding. For the\n  ** main database, set sqlite3.enc to the encoding of the main database.\n  ** For an attached db, it is an error if the encoding is not the same\n  ** as sqlite3.enc.\n  */\n  if( meta[BTREE_TEXT_ENCODING-1] ){  /* text encoding */\n    if( iDb==0 ){\n#ifndef SQLITE_OMIT_UTF16\n      u8 encoding;\n      /* If opening the main database, set ENC(db). */\n      encoding = (u8)meta[BTREE_TEXT_ENCODING-1] & 3;\n      if( encoding==0 ) encoding = SQLITE_UTF8;\n      ENC(db) = encoding;\n#else\n      ENC(db) = SQLITE_UTF8;\n#endif\n    }else{\n      /* If opening an attached database, the encoding much match ENC(db) */\n      if( meta[BTREE_TEXT_ENCODING-1]!=ENC(db) ){\n        sqlite3SetString(pzErrMsg, db, \"attached databases must use the same\"\n            \" text encoding as main database\");\n        rc = SQLITE_ERROR;\n        goto initone_error_out;\n      }\n    }\n  }else{\n    DbSetProperty(db, iDb, DB_Empty);\n  }\n  pDb->pSchema->enc = ENC(db);\n\n  if( pDb->pSchema->cache_size==0 ){\n#ifndef SQLITE_OMIT_DEPRECATED\n    size = sqlite3AbsInt32(meta[BTREE_DEFAULT_CACHE_SIZE-1]);\n    if( size==0 ){ size = SQLITE_DEFAULT_CACHE_SIZE; }\n    pDb->pSchema->cache_size = size;\n#else\n    pDb->pSchema->cache_size = SQLITE_DEFAULT_CACHE_SIZE;\n#endif\n    sqlite3BtreeSetCacheSize(pDb->pBt, pDb->pSchema->cache_size);\n  }\n\n  /*\n  ** file_format==1    Version 3.0.0.\n  ** file_format==2    Version 3.1.3.  // ALTER TABLE ADD COLUMN\n  ** file_format==3    Version 3.1.4.  // ditto but with non-NULL defaults\n  ** file_format==4    Version 3.3.0.  // DESC indices.  Boolean constants\n  */\n  pDb->pSchema->file_format = (u8)meta[BTREE_FILE_FORMAT-1];\n  if( pDb->pSchema->file_format==0 ){\n    pDb->pSchema->file_format = 1;\n  }\n  if( pDb->pSchema->file_format>SQLITE_MAX_FILE_FORMAT ){\n    sqlite3SetString(pzErrMsg, db, \"unsupported file format\");\n    rc = SQLITE_ERROR;\n    goto initone_error_out;\n  }\n\n  /* Ticket #2804:  When we open a database in the newer file format,\n  ** clear the legacy_file_format pragma flag so that a VACUUM will\n  ** not downgrade the database and thus invalidate any descending\n  ** indices that the user might have created.\n  */\n  if( iDb==0 && meta[BTREE_FILE_FORMAT-1]>=4 ){\n    db->flags &= ~(u64)SQLITE_LegacyFileFmt;\n  }\n\n  /* Read the schema information out of the schema tables\n  */\n  assert( db->init.busy );\n  {\n    char *zSql;\n    zSql = sqlite3MPrintf(db, \n        \"SELECT name, rootpage, sql FROM \\\"%w\\\".%s ORDER BY rowid\",\n        db->aDb[iDb].zDbSName, zMasterName);\n#ifndef SQLITE_OMIT_AUTHORIZATION\n    {\n      sqlite3_xauth xAuth;\n      xAuth = db->xAuth;\n      db->xAuth = 0;\n#endif\n      rc = sqlite3_exec(db, zSql, sqlite3InitCallback, &initData, 0);\n#ifndef SQLITE_OMIT_AUTHORIZATION\n      db->xAuth = xAuth;\n    }\n#endif\n    if( rc==SQLITE_OK ) rc = initData.rc;\n    sqlite3DbFree(db, zSql);\n#ifndef SQLITE_OMIT_ANALYZE\n    if( rc==SQLITE_OK ){\n      sqlite3AnalysisLoad(db, iDb);\n    }\n#endif\n  }\n  if( db->mallocFailed ){\n    rc = SQLITE_NOMEM_BKPT;\n    sqlite3ResetAllSchemasOfConnection(db);\n  }\n  if( rc==SQLITE_OK || (db->flags&SQLITE_NoSchemaError)){\n    /* Black magic: If the SQLITE_NoSchemaError flag is set, then consider\n    ** the schema loaded, even if errors occurred. In this situation the \n    ** current sqlite3_prepare() operation will fail, but the following one\n    ** will attempt to compile the supplied statement against whatever subset\n    ** of the schema was loaded before the error occurred. The primary\n    ** purpose of this is to allow access to the sqlite_master table\n    ** even when its contents have been corrupted.\n    */\n    DbSetProperty(db, iDb, DB_SchemaLoaded);\n    rc = SQLITE_OK;\n  }\n\n  /* Jump here for an error that occurs after successfully allocating\n  ** curMain and calling sqlite3BtreeEnter(). For an error that occurs\n  ** before that point, jump to error_out.\n  */\ninitone_error_out:\n  if( openedTransaction ){\n    sqlite3BtreeCommit(pDb->pBt);\n  }\n  sqlite3BtreeLeave(pDb->pBt);\n\nerror_out:\n  if( rc ){\n    if( rc==SQLITE_NOMEM || rc==SQLITE_IOERR_NOMEM ){\n      sqlite3OomFault(db);\n    }\n    sqlite3ResetOneSchema(db, iDb);\n  }\n  db->init.busy = 0;\n  return rc;\n}\n\n/*\n** Initialize all database files - the main database file, the file\n** used to store temporary tables, and any additional database files\n** created using ATTACH statements.  Return a success code.  If an\n** error occurs, write an error message into *pzErrMsg.\n**\n** After a database is initialized, the DB_SchemaLoaded bit is set\n** bit is set in the flags field of the Db structure. If the database\n** file was of zero-length, then the DB_Empty flag is also set.\n*/\nSQLITE_PRIVATE int sqlite3Init(sqlite3 *db, char **pzErrMsg){\n  int i, rc;\n  int commit_internal = !(db->mDbFlags&DBFLAG_SchemaChange);\n  \n  assert( sqlite3_mutex_held(db->mutex) );\n  assert( sqlite3BtreeHoldsMutex(db->aDb[0].pBt) );\n  assert( db->init.busy==0 );\n  ENC(db) = SCHEMA_ENC(db);\n  assert( db->nDb>0 );\n  /* Do the main schema first */\n  if( !DbHasProperty(db, 0, DB_SchemaLoaded) ){\n    rc = sqlite3InitOne(db, 0, pzErrMsg, 0);\n    if( rc ) return rc;\n  }\n  /* All other schemas after the main schema. The \"temp\" schema must be last */\n  for(i=db->nDb-1; i>0; i--){\n    assert( i==1 || sqlite3BtreeHoldsMutex(db->aDb[i].pBt) );\n    if( !DbHasProperty(db, i, DB_SchemaLoaded) ){\n      rc = sqlite3InitOne(db, i, pzErrMsg, 0);\n      if( rc ) return rc;\n    }\n  }\n  if( commit_internal ){\n    sqlite3CommitInternalChanges(db);\n  }\n  return SQLITE_OK;\n}\n\n/*\n** This routine is a no-op if the database schema is already initialized.\n** Otherwise, the schema is loaded. An error code is returned.\n*/\nSQLITE_PRIVATE int sqlite3ReadSchema(Parse *pParse){\n  int rc = SQLITE_OK;\n  sqlite3 *db = pParse->db;\n  assert( sqlite3_mutex_held(db->mutex) );\n  if( !db->init.busy ){\n    rc = sqlite3Init(db, &pParse->zErrMsg);\n    if( rc!=SQLITE_OK ){\n      pParse->rc = rc;\n      pParse->nErr++;\n    }else if( db->noSharedCache ){\n      db->mDbFlags |= DBFLAG_SchemaKnownOk;\n    }\n  }\n  return rc;\n}\n\n\n/*\n** Check schema cookies in all databases.  If any cookie is out\n** of date set pParse->rc to SQLITE_SCHEMA.  If all schema cookies\n** make no changes to pParse->rc.\n*/\nstatic void schemaIsValid(Parse *pParse){\n  sqlite3 *db = pParse->db;\n  int iDb;\n  int rc;\n  int cookie;\n\n  assert( pParse->checkSchema );\n  assert( sqlite3_mutex_held(db->mutex) );\n  for(iDb=0; iDb<db->nDb; iDb++){\n    int openedTransaction = 0;         /* True if a transaction is opened */\n    Btree *pBt = db->aDb[iDb].pBt;     /* Btree database to read cookie from */\n    if( pBt==0 ) continue;\n\n    /* If there is not already a read-only (or read-write) transaction opened\n    ** on the b-tree database, open one now. If a transaction is opened, it \n    ** will be closed immediately after reading the meta-value. */\n    if( !sqlite3BtreeIsInReadTrans(pBt) ){\n      rc = sqlite3BtreeBeginTrans(pBt, 0, 0);\n      if( rc==SQLITE_NOMEM || rc==SQLITE_IOERR_NOMEM ){\n        sqlite3OomFault(db);\n      }\n      if( rc!=SQLITE_OK ) return;\n      openedTransaction = 1;\n    }\n\n    /* Read the schema cookie from the database. If it does not match the \n    ** value stored as part of the in-memory schema representation,\n    ** set Parse.rc to SQLITE_SCHEMA. */\n    sqlite3BtreeGetMeta(pBt, BTREE_SCHEMA_VERSION, (u32 *)&cookie);\n    assert( sqlite3SchemaMutexHeld(db, iDb, 0) );\n    if( cookie!=db->aDb[iDb].pSchema->schema_cookie ){\n      sqlite3ResetOneSchema(db, iDb);\n      pParse->rc = SQLITE_SCHEMA;\n    }\n\n    /* Close the transaction, if one was opened. */\n    if( openedTransaction ){\n      sqlite3BtreeCommit(pBt);\n    }\n  }\n}\n\n/*\n** Convert a schema pointer into the iDb index that indicates\n** which database file in db->aDb[] the schema refers to.\n**\n** If the same database is attached more than once, the first\n** attached database is returned.\n*/\nSQLITE_PRIVATE int sqlite3SchemaToIndex(sqlite3 *db, Schema *pSchema){\n  int i = -1000000;\n\n  /* If pSchema is NULL, then return -1000000. This happens when code in \n  ** expr.c is trying to resolve a reference to a transient table (i.e. one\n  ** created by a sub-select). In this case the return value of this \n  ** function should never be used.\n  **\n  ** We return -1000000 instead of the more usual -1 simply because using\n  ** -1000000 as the incorrect index into db->aDb[] is much \n  ** more likely to cause a segfault than -1 (of course there are assert()\n  ** statements too, but it never hurts to play the odds).\n  */\n  assert( sqlite3_mutex_held(db->mutex) );\n  if( pSchema ){\n    for(i=0; 1; i++){\n      assert( i<db->nDb );\n      if( db->aDb[i].pSchema==pSchema ){\n        break;\n      }\n    }\n    assert( i>=0 && i<db->nDb );\n  }\n  return i;\n}\n\n/*\n** Free all memory allocations in the pParse object\n*/\nSQLITE_PRIVATE void sqlite3ParserReset(Parse *pParse){\n  sqlite3 *db = pParse->db;\n  sqlite3DbFree(db, pParse->aLabel);\n  sqlite3ExprListDelete(db, pParse->pConstExpr);\n  if( db ){\n    assert( db->lookaside.bDisable >= pParse->disableLookaside );\n    db->lookaside.bDisable -= pParse->disableLookaside;\n  }\n  pParse->disableLookaside = 0;\n}\n\n/*\n** Compile the UTF-8 encoded SQL statement zSql into a statement handle.\n*/\nstatic int sqlite3Prepare(\n  sqlite3 *db,              /* Database handle. */\n  const char *zSql,         /* UTF-8 encoded SQL statement. */\n  int nBytes,               /* Length of zSql in bytes. */\n  u32 prepFlags,            /* Zero or more SQLITE_PREPARE_* flags */\n  Vdbe *pReprepare,         /* VM being reprepared */\n  sqlite3_stmt **ppStmt,    /* OUT: A pointer to the prepared statement */\n  const char **pzTail       /* OUT: End of parsed string */\n){\n  char *zErrMsg = 0;        /* Error message */\n  int rc = SQLITE_OK;       /* Result code */\n  int i;                    /* Loop counter */\n  Parse sParse;             /* Parsing context */\n\n  memset(&sParse, 0, PARSE_HDR_SZ);\n  memset(PARSE_TAIL(&sParse), 0, PARSE_TAIL_SZ);\n  sParse.pReprepare = pReprepare;\n  assert( ppStmt && *ppStmt==0 );\n  /* assert( !db->mallocFailed ); // not true with SQLITE_USE_ALLOCA */\n  assert( sqlite3_mutex_held(db->mutex) );\n\n  /* For a long-term use prepared statement avoid the use of\n  ** lookaside memory.\n  */\n  if( prepFlags & SQLITE_PREPARE_PERSISTENT ){\n    sParse.disableLookaside++;\n    db->lookaside.bDisable++;\n  }\n  sParse.disableVtab = (prepFlags & SQLITE_PREPARE_NO_VTAB)!=0;\n\n  /* Check to verify that it is possible to get a read lock on all\n  ** database schemas.  The inability to get a read lock indicates that\n  ** some other database connection is holding a write-lock, which in\n  ** turn means that the other connection has made uncommitted changes\n  ** to the schema.\n  **\n  ** Were we to proceed and prepare the statement against the uncommitted\n  ** schema changes and if those schema changes are subsequently rolled\n  ** back and different changes are made in their place, then when this\n  ** prepared statement goes to run the schema cookie would fail to detect\n  ** the schema change.  Disaster would follow.\n  **\n  ** This thread is currently holding mutexes on all Btrees (because\n  ** of the sqlite3BtreeEnterAll() in sqlite3LockAndPrepare()) so it\n  ** is not possible for another thread to start a new schema change\n  ** while this routine is running.  Hence, we do not need to hold \n  ** locks on the schema, we just need to make sure nobody else is \n  ** holding them.\n  **\n  ** Note that setting READ_UNCOMMITTED overrides most lock detection,\n  ** but it does *not* override schema lock detection, so this all still\n  ** works even if READ_UNCOMMITTED is set.\n  */\n  for(i=0; i<db->nDb; i++) {\n    Btree *pBt = db->aDb[i].pBt;\n    if( pBt ){\n      assert( sqlite3BtreeHoldsMutex(pBt) );\n      rc = sqlite3BtreeSchemaLocked(pBt);\n      if( rc ){\n        const char *zDb = db->aDb[i].zDbSName;\n        sqlite3ErrorWithMsg(db, rc, \"database schema is locked: %s\", zDb);\n        testcase( db->flags & SQLITE_ReadUncommit );\n        goto end_prepare;\n      }\n    }\n  }\n\n  sqlite3VtabUnlockList(db);\n\n  sParse.db = db;\n  if( nBytes>=0 && (nBytes==0 || zSql[nBytes-1]!=0) ){\n    char *zSqlCopy;\n    int mxLen = db->aLimit[SQLITE_LIMIT_SQL_LENGTH];\n    testcase( nBytes==mxLen );\n    testcase( nBytes==mxLen+1 );\n    if( nBytes>mxLen ){\n      sqlite3ErrorWithMsg(db, SQLITE_TOOBIG, \"statement too long\");\n      rc = sqlite3ApiExit(db, SQLITE_TOOBIG);\n      goto end_prepare;\n    }\n    zSqlCopy = sqlite3DbStrNDup(db, zSql, nBytes);\n    if( zSqlCopy ){\n      sqlite3RunParser(&sParse, zSqlCopy, &zErrMsg);\n      sParse.zTail = &zSql[sParse.zTail-zSqlCopy];\n      sqlite3DbFree(db, zSqlCopy);\n    }else{\n      sParse.zTail = &zSql[nBytes];\n    }\n  }else{\n    sqlite3RunParser(&sParse, zSql, &zErrMsg);\n  }\n  assert( 0==sParse.nQueryLoop );\n\n  if( sParse.rc==SQLITE_DONE ) sParse.rc = SQLITE_OK;\n  if( sParse.checkSchema ){\n    schemaIsValid(&sParse);\n  }\n  if( db->mallocFailed ){\n    sParse.rc = SQLITE_NOMEM_BKPT;\n  }\n  if( pzTail ){\n    *pzTail = sParse.zTail;\n  }\n  rc = sParse.rc;\n\n#ifndef SQLITE_OMIT_EXPLAIN\n  if( rc==SQLITE_OK && sParse.pVdbe && sParse.explain ){\n    static const char * const azColName[] = {\n       \"addr\", \"opcode\", \"p1\", \"p2\", \"p3\", \"p4\", \"p5\", \"comment\",\n       \"id\", \"parent\", \"notused\", \"detail\"\n    };\n    int iFirst, mx;\n    if( sParse.explain==2 ){\n      sqlite3VdbeSetNumCols(sParse.pVdbe, 4);\n      iFirst = 8;\n      mx = 12;\n    }else{\n      sqlite3VdbeSetNumCols(sParse.pVdbe, 8);\n      iFirst = 0;\n      mx = 8;\n    }\n    for(i=iFirst; i<mx; i++){\n      sqlite3VdbeSetColName(sParse.pVdbe, i-iFirst, COLNAME_NAME,\n                            azColName[i], SQLITE_STATIC);\n    }\n  }\n#endif\n\n  if( db->init.busy==0 ){\n    sqlite3VdbeSetSql(sParse.pVdbe, zSql, (int)(sParse.zTail-zSql), prepFlags);\n  }\n  if( sParse.pVdbe && (rc!=SQLITE_OK || db->mallocFailed) ){\n    sqlite3VdbeFinalize(sParse.pVdbe);\n    assert(!(*ppStmt));\n  }else{\n    *ppStmt = (sqlite3_stmt*)sParse.pVdbe;\n  }\n\n  if( zErrMsg ){\n    sqlite3ErrorWithMsg(db, rc, \"%s\", zErrMsg);\n    sqlite3DbFree(db, zErrMsg);\n  }else{\n    sqlite3Error(db, rc);\n  }\n\n  /* Delete any TriggerPrg structures allocated while parsing this statement. */\n  while( sParse.pTriggerPrg ){\n    TriggerPrg *pT = sParse.pTriggerPrg;\n    sParse.pTriggerPrg = pT->pNext;\n    sqlite3DbFree(db, pT);\n  }\n\nend_prepare:\n\n  sqlite3ParserReset(&sParse);\n  return rc;\n}\nstatic int sqlite3LockAndPrepare(\n  sqlite3 *db,              /* Database handle. */\n  const char *zSql,         /* UTF-8 encoded SQL statement. */\n  int nBytes,               /* Length of zSql in bytes. */\n  u32 prepFlags,            /* Zero or more SQLITE_PREPARE_* flags */\n  Vdbe *pOld,               /* VM being reprepared */\n  sqlite3_stmt **ppStmt,    /* OUT: A pointer to the prepared statement */\n  const char **pzTail       /* OUT: End of parsed string */\n){\n  int rc;\n  int cnt = 0;\n\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( ppStmt==0 ) return SQLITE_MISUSE_BKPT;\n#endif\n  *ppStmt = 0;\n#ifdef SQLITE_WCDB_SUSPEND\n  if( db->suspended && !db->unimpeded ) return SQLITE_INTERRUPT;\n#endif\n  if( !sqlite3SafetyCheckOk(db)||zSql==0 ){\n    return SQLITE_MISUSE_BKPT;\n  }\n  sqlite3_mutex_enter(db->mutex);\n  sqlite3BtreeEnterAll(db);\n  do{\n    /* Make multiple attempts to compile the SQL, until it either succeeds\n    ** or encounters a permanent error.  A schema problem after one schema\n    ** reset is considered a permanent error. */\n    rc = sqlite3Prepare(db, zSql, nBytes, prepFlags, pOld, ppStmt, pzTail);\n    assert( rc==SQLITE_OK || *ppStmt==0 );\n  }while( rc==SQLITE_ERROR_RETRY\n       || (rc==SQLITE_SCHEMA && (sqlite3ResetOneSchema(db,-1), cnt++)<SQLITE_MAX_SCHEMA_RETRY) );\n  sqlite3BtreeLeaveAll(db);\n  rc = sqlite3ApiExit(db, rc);\n  assert( (rc&db->errMask)==rc );\n  sqlite3_mutex_leave(db->mutex);\n  return rc;\n}\n\n\n/*\n** Rerun the compilation of a statement after a schema change.\n**\n** If the statement is successfully recompiled, return SQLITE_OK. Otherwise,\n** if the statement cannot be recompiled because another connection has\n** locked the sqlite3_master table, return SQLITE_LOCKED. If any other error\n** occurs, return SQLITE_SCHEMA.\n*/\nSQLITE_PRIVATE int sqlite3Reprepare(Vdbe *p){\n  int rc;\n  sqlite3_stmt *pNew;\n  const char *zSql;\n  sqlite3 *db;\n  u8 prepFlags;\n\n  assert( sqlite3_mutex_held(sqlite3VdbeDb(p)->mutex) );\n  zSql = sqlite3_sql((sqlite3_stmt *)p);\n  assert( zSql!=0 );  /* Reprepare only called for prepare_v2() statements */\n  db = sqlite3VdbeDb(p);\n  assert( sqlite3_mutex_held(db->mutex) );\n  prepFlags = sqlite3VdbePrepareFlags(p);\n  rc = sqlite3LockAndPrepare(db, zSql, -1, prepFlags, p, &pNew, 0);\n  if( rc ){\n    if( rc==SQLITE_NOMEM ){\n      sqlite3OomFault(db);\n    }\n    assert( pNew==0 );\n    return rc;\n  }else{\n    assert( pNew!=0 );\n  }\n  sqlite3VdbeSwap((Vdbe*)pNew, p);\n  sqlite3TransferBindings(pNew, (sqlite3_stmt*)p);\n  sqlite3VdbeResetStepResult((Vdbe*)pNew);\n  sqlite3VdbeFinalize((Vdbe*)pNew);\n  return SQLITE_OK;\n}\n\n\n/*\n** Two versions of the official API.  Legacy and new use.  In the legacy\n** version, the original SQL text is not saved in the prepared statement\n** and so if a schema change occurs, SQLITE_SCHEMA is returned by\n** sqlite3_step().  In the new version, the original SQL text is retained\n** and the statement is automatically recompiled if an schema change\n** occurs.\n*/\nSQLITE_API int sqlite3_prepare(\n  sqlite3 *db,              /* Database handle. */\n  const char *zSql,         /* UTF-8 encoded SQL statement. */\n  int nBytes,               /* Length of zSql in bytes. */\n  sqlite3_stmt **ppStmt,    /* OUT: A pointer to the prepared statement */\n  const char **pzTail       /* OUT: End of parsed string */\n){\n  int rc;\n  rc = sqlite3LockAndPrepare(db,zSql,nBytes,0,0,ppStmt,pzTail);\n  assert( rc==SQLITE_OK || ppStmt==0 || *ppStmt==0 );  /* VERIFY: F13021 */\n  return rc;\n}\nSQLITE_API int sqlite3_prepare_v2(\n  sqlite3 *db,              /* Database handle. */\n  const char *zSql,         /* UTF-8 encoded SQL statement. */\n  int nBytes,               /* Length of zSql in bytes. */\n  sqlite3_stmt **ppStmt,    /* OUT: A pointer to the prepared statement */\n  const char **pzTail       /* OUT: End of parsed string */\n){\n  int rc;\n  /* EVIDENCE-OF: R-37923-12173 The sqlite3_prepare_v2() interface works\n  ** exactly the same as sqlite3_prepare_v3() with a zero prepFlags\n  ** parameter.\n  **\n  ** Proof in that the 5th parameter to sqlite3LockAndPrepare is 0 */\n  rc = sqlite3LockAndPrepare(db,zSql,nBytes,SQLITE_PREPARE_SAVESQL,0,\n                             ppStmt,pzTail);\n  assert( rc==SQLITE_OK || ppStmt==0 || *ppStmt==0 );\n  return rc;\n}\nSQLITE_API int sqlite3_prepare_v3(\n  sqlite3 *db,              /* Database handle. */\n  const char *zSql,         /* UTF-8 encoded SQL statement. */\n  int nBytes,               /* Length of zSql in bytes. */\n  unsigned int prepFlags,   /* Zero or more SQLITE_PREPARE_* flags */\n  sqlite3_stmt **ppStmt,    /* OUT: A pointer to the prepared statement */\n  const char **pzTail       /* OUT: End of parsed string */\n){\n  int rc;\n  /* EVIDENCE-OF: R-56861-42673 sqlite3_prepare_v3() differs from\n  ** sqlite3_prepare_v2() only in having the extra prepFlags parameter,\n  ** which is a bit array consisting of zero or more of the\n  ** SQLITE_PREPARE_* flags.\n  **\n  ** Proof by comparison to the implementation of sqlite3_prepare_v2()\n  ** directly above. */\n  rc = sqlite3LockAndPrepare(db,zSql,nBytes,\n                 SQLITE_PREPARE_SAVESQL|(prepFlags&SQLITE_PREPARE_MASK),\n                 0,ppStmt,pzTail);\n  assert( rc==SQLITE_OK || ppStmt==0 || *ppStmt==0 );\n  return rc;\n}\n\n\n#ifndef SQLITE_OMIT_UTF16\n/*\n** Compile the UTF-16 encoded SQL statement zSql into a statement handle.\n*/\nstatic int sqlite3Prepare16(\n  sqlite3 *db,              /* Database handle. */ \n  const void *zSql,         /* UTF-16 encoded SQL statement. */\n  int nBytes,               /* Length of zSql in bytes. */\n  u32 prepFlags,            /* Zero or more SQLITE_PREPARE_* flags */\n  sqlite3_stmt **ppStmt,    /* OUT: A pointer to the prepared statement */\n  const void **pzTail       /* OUT: End of parsed string */\n){\n  /* This function currently works by first transforming the UTF-16\n  ** encoded string to UTF-8, then invoking sqlite3_prepare(). The\n  ** tricky bit is figuring out the pointer to return in *pzTail.\n  */\n  char *zSql8;\n  const char *zTail8 = 0;\n  int rc = SQLITE_OK;\n\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( ppStmt==0 ) return SQLITE_MISUSE_BKPT;\n#endif\n  *ppStmt = 0;\n  if( !sqlite3SafetyCheckOk(db)||zSql==0 ){\n    return SQLITE_MISUSE_BKPT;\n  }\n  if( nBytes>=0 ){\n    int sz;\n    const char *z = (const char*)zSql;\n    for(sz=0; sz<nBytes && (z[sz]!=0 || z[sz+1]!=0); sz += 2){}\n    nBytes = sz;\n  }\n  sqlite3_mutex_enter(db->mutex);\n  zSql8 = sqlite3Utf16to8(db, zSql, nBytes, SQLITE_UTF16NATIVE);\n  if( zSql8 ){\n    rc = sqlite3LockAndPrepare(db, zSql8, -1, prepFlags, 0, ppStmt, &zTail8);\n  }\n\n  if( zTail8 && pzTail ){\n    /* If sqlite3_prepare returns a tail pointer, we calculate the\n    ** equivalent pointer into the UTF-16 string by counting the unicode\n    ** characters between zSql8 and zTail8, and then returning a pointer\n    ** the same number of characters into the UTF-16 string.\n    */\n    int chars_parsed = sqlite3Utf8CharLen(zSql8, (int)(zTail8-zSql8));\n    *pzTail = (u8 *)zSql + sqlite3Utf16ByteLen(zSql, chars_parsed);\n  }\n  sqlite3DbFree(db, zSql8); \n  rc = sqlite3ApiExit(db, rc);\n  sqlite3_mutex_leave(db->mutex);\n  return rc;\n}\n\n/*\n** Two versions of the official API.  Legacy and new use.  In the legacy\n** version, the original SQL text is not saved in the prepared statement\n** and so if a schema change occurs, SQLITE_SCHEMA is returned by\n** sqlite3_step().  In the new version, the original SQL text is retained\n** and the statement is automatically recompiled if an schema change\n** occurs.\n*/\nSQLITE_API int sqlite3_prepare16(\n  sqlite3 *db,              /* Database handle. */ \n  const void *zSql,         /* UTF-16 encoded SQL statement. */\n  int nBytes,               /* Length of zSql in bytes. */\n  sqlite3_stmt **ppStmt,    /* OUT: A pointer to the prepared statement */\n  const void **pzTail       /* OUT: End of parsed string */\n){\n  int rc;\n  rc = sqlite3Prepare16(db,zSql,nBytes,0,ppStmt,pzTail);\n  assert( rc==SQLITE_OK || ppStmt==0 || *ppStmt==0 );  /* VERIFY: F13021 */\n  return rc;\n}\nSQLITE_API int sqlite3_prepare16_v2(\n  sqlite3 *db,              /* Database handle. */ \n  const void *zSql,         /* UTF-16 encoded SQL statement. */\n  int nBytes,               /* Length of zSql in bytes. */\n  sqlite3_stmt **ppStmt,    /* OUT: A pointer to the prepared statement */\n  const void **pzTail       /* OUT: End of parsed string */\n){\n  int rc;\n  rc = sqlite3Prepare16(db,zSql,nBytes,SQLITE_PREPARE_SAVESQL,ppStmt,pzTail);\n  assert( rc==SQLITE_OK || ppStmt==0 || *ppStmt==0 );  /* VERIFY: F13021 */\n  return rc;\n}\nSQLITE_API int sqlite3_prepare16_v3(\n  sqlite3 *db,              /* Database handle. */ \n  const void *zSql,         /* UTF-16 encoded SQL statement. */\n  int nBytes,               /* Length of zSql in bytes. */\n  unsigned int prepFlags,   /* Zero or more SQLITE_PREPARE_* flags */\n  sqlite3_stmt **ppStmt,    /* OUT: A pointer to the prepared statement */\n  const void **pzTail       /* OUT: End of parsed string */\n){\n  int rc;\n  rc = sqlite3Prepare16(db,zSql,nBytes,\n         SQLITE_PREPARE_SAVESQL|(prepFlags&SQLITE_PREPARE_MASK),\n         ppStmt,pzTail);\n  assert( rc==SQLITE_OK || ppStmt==0 || *ppStmt==0 );  /* VERIFY: F13021 */\n  return rc;\n}\n\n#endif /* SQLITE_OMIT_UTF16 */\n\n/************** End of prepare.c *********************************************/\n/************** Begin file select.c ******************************************/\n/*\n** 2001 September 15\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This file contains C code routines that are called by the parser\n** to handle SELECT statements in SQLite.\n*/\n/* #include \"sqliteInt.h\" */\n\n/*\n** Trace output macros\n*/\n#if SELECTTRACE_ENABLED\n/***/ int sqlite3SelectTrace = 0;\n# define SELECTTRACE(K,P,S,X)  \\\n  if(sqlite3SelectTrace&(K))   \\\n    sqlite3DebugPrintf(\"%u/%d/%p: \",(S)->selId,(P)->addrExplain,(S)),\\\n    sqlite3DebugPrintf X\n#else\n# define SELECTTRACE(K,P,S,X)\n#endif\n\n\n/*\n** An instance of the following object is used to record information about\n** how to process the DISTINCT keyword, to simplify passing that information\n** into the selectInnerLoop() routine.\n*/\ntypedef struct DistinctCtx DistinctCtx;\nstruct DistinctCtx {\n  u8 isTnct;      /* True if the DISTINCT keyword is present */\n  u8 eTnctType;   /* One of the WHERE_DISTINCT_* operators */\n  int tabTnct;    /* Ephemeral table used for DISTINCT processing */\n  int addrTnct;   /* Address of OP_OpenEphemeral opcode for tabTnct */\n};\n\n/*\n** An instance of the following object is used to record information about\n** the ORDER BY (or GROUP BY) clause of query is being coded.\n**\n** The aDefer[] array is used by the sorter-references optimization. For\n** example, assuming there is no index that can be used for the ORDER BY,\n** for the query:\n**\n**     SELECT a, bigblob FROM t1 ORDER BY a LIMIT 10;\n**\n** it may be more efficient to add just the \"a\" values to the sorter, and\n** retrieve the associated \"bigblob\" values directly from table t1 as the\n** 10 smallest \"a\" values are extracted from the sorter.\n**\n** When the sorter-reference optimization is used, there is one entry in the\n** aDefer[] array for each database table that may be read as values are\n** extracted from the sorter.\n*/\ntypedef struct SortCtx SortCtx;\nstruct SortCtx {\n  ExprList *pOrderBy;   /* The ORDER BY (or GROUP BY clause) */\n  int nOBSat;           /* Number of ORDER BY terms satisfied by indices */\n  int iECursor;         /* Cursor number for the sorter */\n  int regReturn;        /* Register holding block-output return address */\n  int labelBkOut;       /* Start label for the block-output subroutine */\n  int addrSortIndex;    /* Address of the OP_SorterOpen or OP_OpenEphemeral */\n  int labelDone;        /* Jump here when done, ex: LIMIT reached */\n  int labelOBLopt;      /* Jump here when sorter is full */\n  u8 sortFlags;         /* Zero or more SORTFLAG_* bits */\n#ifdef SQLITE_ENABLE_SORTER_REFERENCES\n  u8 nDefer;            /* Number of valid entries in aDefer[] */\n  struct DeferredCsr {\n    Table *pTab;        /* Table definition */\n    int iCsr;           /* Cursor number for table */\n    int nKey;           /* Number of PK columns for table pTab (>=1) */\n  } aDefer[4];\n#endif\n  struct RowLoadInfo *pDeferredRowLoad;  /* Deferred row loading info or NULL */\n};\n#define SORTFLAG_UseSorter  0x01   /* Use SorterOpen instead of OpenEphemeral */\n\n/*\n** Delete all the content of a Select structure.  Deallocate the structure\n** itself only if bFree is true.\n*/\nstatic void clearSelect(sqlite3 *db, Select *p, int bFree){\n  while( p ){\n    Select *pPrior = p->pPrior;\n    sqlite3ExprListDelete(db, p->pEList);\n    sqlite3SrcListDelete(db, p->pSrc);\n    sqlite3ExprDelete(db, p->pWhere);\n    sqlite3ExprListDelete(db, p->pGroupBy);\n    sqlite3ExprDelete(db, p->pHaving);\n    sqlite3ExprListDelete(db, p->pOrderBy);\n    sqlite3ExprDelete(db, p->pLimit);\n#ifndef SQLITE_OMIT_WINDOWFUNC\n    if( OK_IF_ALWAYS_TRUE(p->pWinDefn) ){\n      sqlite3WindowListDelete(db, p->pWinDefn);\n    }\n#endif\n    if( OK_IF_ALWAYS_TRUE(p->pWith) ) sqlite3WithDelete(db, p->pWith);\n    if( bFree ) sqlite3DbFreeNN(db, p);\n    p = pPrior;\n    bFree = 1;\n  }\n}\n\n/*\n** Initialize a SelectDest structure.\n*/\nSQLITE_PRIVATE void sqlite3SelectDestInit(SelectDest *pDest, int eDest, int iParm){\n  pDest->eDest = (u8)eDest;\n  pDest->iSDParm = iParm;\n  pDest->zAffSdst = 0;\n  pDest->iSdst = 0;\n  pDest->nSdst = 0;\n}\n\n\n/*\n** Allocate a new Select structure and return a pointer to that\n** structure.\n*/\nSQLITE_PRIVATE Select *sqlite3SelectNew(\n  Parse *pParse,        /* Parsing context */\n  ExprList *pEList,     /* which columns to include in the result */\n  SrcList *pSrc,        /* the FROM clause -- which tables to scan */\n  Expr *pWhere,         /* the WHERE clause */\n  ExprList *pGroupBy,   /* the GROUP BY clause */\n  Expr *pHaving,        /* the HAVING clause */\n  ExprList *pOrderBy,   /* the ORDER BY clause */\n  u32 selFlags,         /* Flag parameters, such as SF_Distinct */\n  Expr *pLimit          /* LIMIT value.  NULL means not used */\n){\n  Select *pNew;\n  Select standin;\n  pNew = sqlite3DbMallocRawNN(pParse->db, sizeof(*pNew) );\n  if( pNew==0 ){\n    assert( pParse->db->mallocFailed );\n    pNew = &standin;\n  }\n  if( pEList==0 ){\n    pEList = sqlite3ExprListAppend(pParse, 0,\n                                   sqlite3Expr(pParse->db,TK_ASTERISK,0));\n  }\n  pNew->pEList = pEList;\n  pNew->op = TK_SELECT;\n  pNew->selFlags = selFlags;\n  pNew->iLimit = 0;\n  pNew->iOffset = 0;\n  pNew->selId = ++pParse->nSelect;\n  pNew->addrOpenEphm[0] = -1;\n  pNew->addrOpenEphm[1] = -1;\n  pNew->nSelectRow = 0;\n  if( pSrc==0 ) pSrc = sqlite3DbMallocZero(pParse->db, sizeof(*pSrc));\n  pNew->pSrc = pSrc;\n  pNew->pWhere = pWhere;\n  pNew->pGroupBy = pGroupBy;\n  pNew->pHaving = pHaving;\n  pNew->pOrderBy = pOrderBy;\n  pNew->pPrior = 0;\n  pNew->pNext = 0;\n  pNew->pLimit = pLimit;\n  pNew->pWith = 0;\n#ifndef SQLITE_OMIT_WINDOWFUNC\n  pNew->pWin = 0;\n  pNew->pWinDefn = 0;\n#endif\n  if( pParse->db->mallocFailed ) {\n    clearSelect(pParse->db, pNew, pNew!=&standin);\n    pNew = 0;\n  }else{\n    assert( pNew->pSrc!=0 || pParse->nErr>0 );\n  }\n  assert( pNew!=&standin );\n  return pNew;\n}\n\n\n/*\n** Delete the given Select structure and all of its substructures.\n*/\nSQLITE_PRIVATE void sqlite3SelectDelete(sqlite3 *db, Select *p){\n  if( OK_IF_ALWAYS_TRUE(p) ) clearSelect(db, p, 1);\n}\n\n/*\n** Return a pointer to the right-most SELECT statement in a compound.\n*/\nstatic Select *findRightmost(Select *p){\n  while( p->pNext ) p = p->pNext;\n  return p;\n}\n\n/*\n** Given 1 to 3 identifiers preceding the JOIN keyword, determine the\n** type of join.  Return an integer constant that expresses that type\n** in terms of the following bit values:\n**\n**     JT_INNER\n**     JT_CROSS\n**     JT_OUTER\n**     JT_NATURAL\n**     JT_LEFT\n**     JT_RIGHT\n**\n** A full outer join is the combination of JT_LEFT and JT_RIGHT.\n**\n** If an illegal or unsupported join type is seen, then still return\n** a join type, but put an error in the pParse structure.\n*/\nSQLITE_PRIVATE int sqlite3JoinType(Parse *pParse, Token *pA, Token *pB, Token *pC){\n  int jointype = 0;\n  Token *apAll[3];\n  Token *p;\n                             /*   0123456789 123456789 123456789 123 */\n  static const char zKeyText[] = \"naturaleftouterightfullinnercross\";\n  static const struct {\n    u8 i;        /* Beginning of keyword text in zKeyText[] */\n    u8 nChar;    /* Length of the keyword in characters */\n    u8 code;     /* Join type mask */\n  } aKeyword[] = {\n    /* natural */ { 0,  7, JT_NATURAL                },\n    /* left    */ { 6,  4, JT_LEFT|JT_OUTER          },\n    /* outer   */ { 10, 5, JT_OUTER                  },\n    /* right   */ { 14, 5, JT_RIGHT|JT_OUTER         },\n    /* full    */ { 19, 4, JT_LEFT|JT_RIGHT|JT_OUTER },\n    /* inner   */ { 23, 5, JT_INNER                  },\n    /* cross   */ { 28, 5, JT_INNER|JT_CROSS         },\n  };\n  int i, j;\n  apAll[0] = pA;\n  apAll[1] = pB;\n  apAll[2] = pC;\n  for(i=0; i<3 && apAll[i]; i++){\n    p = apAll[i];\n    for(j=0; j<ArraySize(aKeyword); j++){\n      if( p->n==aKeyword[j].nChar \n          && sqlite3StrNICmp((char*)p->z, &zKeyText[aKeyword[j].i], p->n)==0 ){\n        jointype |= aKeyword[j].code;\n        break;\n      }\n    }\n    testcase( j==0 || j==1 || j==2 || j==3 || j==4 || j==5 || j==6 );\n    if( j>=ArraySize(aKeyword) ){\n      jointype |= JT_ERROR;\n      break;\n    }\n  }\n  if(\n     (jointype & (JT_INNER|JT_OUTER))==(JT_INNER|JT_OUTER) ||\n     (jointype & JT_ERROR)!=0\n  ){\n    const char *zSp = \" \";\n    assert( pB!=0 );\n    if( pC==0 ){ zSp++; }\n    sqlite3ErrorMsg(pParse, \"unknown or unsupported join type: \"\n       \"%T %T%s%T\", pA, pB, zSp, pC);\n    jointype = JT_INNER;\n  }else if( (jointype & JT_OUTER)!=0 \n         && (jointype & (JT_LEFT|JT_RIGHT))!=JT_LEFT ){\n    sqlite3ErrorMsg(pParse, \n      \"RIGHT and FULL OUTER JOINs are not currently supported\");\n    jointype = JT_INNER;\n  }\n  return jointype;\n}\n\n/*\n** Return the index of a column in a table.  Return -1 if the column\n** is not contained in the table.\n*/\nstatic int columnIndex(Table *pTab, const char *zCol){\n  int i;\n  for(i=0; i<pTab->nCol; i++){\n    if( sqlite3StrICmp(pTab->aCol[i].zName, zCol)==0 ) return i;\n  }\n  return -1;\n}\n\n/*\n** Search the first N tables in pSrc, from left to right, looking for a\n** table that has a column named zCol.  \n**\n** When found, set *piTab and *piCol to the table index and column index\n** of the matching column and return TRUE.\n**\n** If not found, return FALSE.\n*/\nstatic int tableAndColumnIndex(\n  SrcList *pSrc,       /* Array of tables to search */\n  int N,               /* Number of tables in pSrc->a[] to search */\n  const char *zCol,    /* Name of the column we are looking for */\n  int *piTab,          /* Write index of pSrc->a[] here */\n  int *piCol           /* Write index of pSrc->a[*piTab].pTab->aCol[] here */\n){\n  int i;               /* For looping over tables in pSrc */\n  int iCol;            /* Index of column matching zCol */\n\n  assert( (piTab==0)==(piCol==0) );  /* Both or neither are NULL */\n  for(i=0; i<N; i++){\n    iCol = columnIndex(pSrc->a[i].pTab, zCol);\n    if( iCol>=0 ){\n      if( piTab ){\n        *piTab = i;\n        *piCol = iCol;\n      }\n      return 1;\n    }\n  }\n  return 0;\n}\n\n/*\n** This function is used to add terms implied by JOIN syntax to the\n** WHERE clause expression of a SELECT statement. The new term, which\n** is ANDed with the existing WHERE clause, is of the form:\n**\n**    (tab1.col1 = tab2.col2)\n**\n** where tab1 is the iSrc'th table in SrcList pSrc and tab2 is the \n** (iSrc+1)'th. Column col1 is column iColLeft of tab1, and col2 is\n** column iColRight of tab2.\n*/\nstatic void addWhereTerm(\n  Parse *pParse,                  /* Parsing context */\n  SrcList *pSrc,                  /* List of tables in FROM clause */\n  int iLeft,                      /* Index of first table to join in pSrc */\n  int iColLeft,                   /* Index of column in first table */\n  int iRight,                     /* Index of second table in pSrc */\n  int iColRight,                  /* Index of column in second table */\n  int isOuterJoin,                /* True if this is an OUTER join */\n  Expr **ppWhere                  /* IN/OUT: The WHERE clause to add to */\n){\n  sqlite3 *db = pParse->db;\n  Expr *pE1;\n  Expr *pE2;\n  Expr *pEq;\n\n  assert( iLeft<iRight );\n  assert( pSrc->nSrc>iRight );\n  assert( pSrc->a[iLeft].pTab );\n  assert( pSrc->a[iRight].pTab );\n\n  pE1 = sqlite3CreateColumnExpr(db, pSrc, iLeft, iColLeft);\n  pE2 = sqlite3CreateColumnExpr(db, pSrc, iRight, iColRight);\n\n  pEq = sqlite3PExpr(pParse, TK_EQ, pE1, pE2);\n  if( pEq && isOuterJoin ){\n    ExprSetProperty(pEq, EP_FromJoin);\n    assert( !ExprHasProperty(pEq, EP_TokenOnly|EP_Reduced) );\n    ExprSetVVAProperty(pEq, EP_NoReduce);\n    pEq->iRightJoinTable = (i16)pE2->iTable;\n  }\n  *ppWhere = sqlite3ExprAnd(db, *ppWhere, pEq);\n}\n\n/*\n** Set the EP_FromJoin property on all terms of the given expression.\n** And set the Expr.iRightJoinTable to iTable for every term in the\n** expression.\n**\n** The EP_FromJoin property is used on terms of an expression to tell\n** the LEFT OUTER JOIN processing logic that this term is part of the\n** join restriction specified in the ON or USING clause and not a part\n** of the more general WHERE clause.  These terms are moved over to the\n** WHERE clause during join processing but we need to remember that they\n** originated in the ON or USING clause.\n**\n** The Expr.iRightJoinTable tells the WHERE clause processing that the\n** expression depends on table iRightJoinTable even if that table is not\n** explicitly mentioned in the expression.  That information is needed\n** for cases like this:\n**\n**    SELECT * FROM t1 LEFT JOIN t2 ON t1.a=t2.b AND t1.x=5\n**\n** The where clause needs to defer the handling of the t1.x=5\n** term until after the t2 loop of the join.  In that way, a\n** NULL t2 row will be inserted whenever t1.x!=5.  If we do not\n** defer the handling of t1.x=5, it will be processed immediately\n** after the t1 loop and rows with t1.x!=5 will never appear in\n** the output, which is incorrect.\n*/\nstatic void setJoinExpr(Expr *p, int iTable){\n  while( p ){\n    ExprSetProperty(p, EP_FromJoin);\n    assert( !ExprHasProperty(p, EP_TokenOnly|EP_Reduced) );\n    ExprSetVVAProperty(p, EP_NoReduce);\n    p->iRightJoinTable = (i16)iTable;\n    if( p->op==TK_FUNCTION && p->x.pList ){\n      int i;\n      for(i=0; i<p->x.pList->nExpr; i++){\n        setJoinExpr(p->x.pList->a[i].pExpr, iTable);\n      }\n    }\n    setJoinExpr(p->pLeft, iTable);\n    p = p->pRight;\n  } \n}\n\n/* Undo the work of setJoinExpr().  In the expression tree p, convert every\n** term that is marked with EP_FromJoin and iRightJoinTable==iTable into\n** an ordinary term that omits the EP_FromJoin mark.\n**\n** This happens when a LEFT JOIN is simplified into an ordinary JOIN.\n*/\nstatic void unsetJoinExpr(Expr *p, int iTable){\n  while( p ){\n    if( ExprHasProperty(p, EP_FromJoin)\n     && (iTable<0 || p->iRightJoinTable==iTable) ){\n      ExprClearProperty(p, EP_FromJoin);\n    }\n    if( p->op==TK_FUNCTION && p->x.pList ){\n      int i;\n      for(i=0; i<p->x.pList->nExpr; i++){\n        unsetJoinExpr(p->x.pList->a[i].pExpr, iTable);\n      }\n    }\n    unsetJoinExpr(p->pLeft, iTable);\n    p = p->pRight;\n  } \n}\n\n/*\n** This routine processes the join information for a SELECT statement.\n** ON and USING clauses are converted into extra terms of the WHERE clause.\n** NATURAL joins also create extra WHERE clause terms.\n**\n** The terms of a FROM clause are contained in the Select.pSrc structure.\n** The left most table is the first entry in Select.pSrc.  The right-most\n** table is the last entry.  The join operator is held in the entry to\n** the left.  Thus entry 0 contains the join operator for the join between\n** entries 0 and 1.  Any ON or USING clauses associated with the join are\n** also attached to the left entry.\n**\n** This routine returns the number of errors encountered.\n*/\nstatic int sqliteProcessJoin(Parse *pParse, Select *p){\n  SrcList *pSrc;                  /* All tables in the FROM clause */\n  int i, j;                       /* Loop counters */\n  struct SrcList_item *pLeft;     /* Left table being joined */\n  struct SrcList_item *pRight;    /* Right table being joined */\n\n  pSrc = p->pSrc;\n  pLeft = &pSrc->a[0];\n  pRight = &pLeft[1];\n  for(i=0; i<pSrc->nSrc-1; i++, pRight++, pLeft++){\n    Table *pRightTab = pRight->pTab;\n    int isOuter;\n\n    if( NEVER(pLeft->pTab==0 || pRightTab==0) ) continue;\n    isOuter = (pRight->fg.jointype & JT_OUTER)!=0;\n\n    /* When the NATURAL keyword is present, add WHERE clause terms for\n    ** every column that the two tables have in common.\n    */\n    if( pRight->fg.jointype & JT_NATURAL ){\n      if( pRight->pOn || pRight->pUsing ){\n        sqlite3ErrorMsg(pParse, \"a NATURAL join may not have \"\n           \"an ON or USING clause\", 0);\n        return 1;\n      }\n      for(j=0; j<pRightTab->nCol; j++){\n        char *zName;   /* Name of column in the right table */\n        int iLeft;     /* Matching left table */\n        int iLeftCol;  /* Matching column in the left table */\n\n        zName = pRightTab->aCol[j].zName;\n        if( tableAndColumnIndex(pSrc, i+1, zName, &iLeft, &iLeftCol) ){\n          addWhereTerm(pParse, pSrc, iLeft, iLeftCol, i+1, j,\n                       isOuter, &p->pWhere);\n        }\n      }\n    }\n\n    /* Disallow both ON and USING clauses in the same join\n    */\n    if( pRight->pOn && pRight->pUsing ){\n      sqlite3ErrorMsg(pParse, \"cannot have both ON and USING \"\n        \"clauses in the same join\");\n      return 1;\n    }\n\n    /* Add the ON clause to the end of the WHERE clause, connected by\n    ** an AND operator.\n    */\n    if( pRight->pOn ){\n      if( isOuter ) setJoinExpr(pRight->pOn, pRight->iCursor);\n      p->pWhere = sqlite3ExprAnd(pParse->db, p->pWhere, pRight->pOn);\n      pRight->pOn = 0;\n    }\n\n    /* Create extra terms on the WHERE clause for each column named\n    ** in the USING clause.  Example: If the two tables to be joined are \n    ** A and B and the USING clause names X, Y, and Z, then add this\n    ** to the WHERE clause:    A.X=B.X AND A.Y=B.Y AND A.Z=B.Z\n    ** Report an error if any column mentioned in the USING clause is\n    ** not contained in both tables to be joined.\n    */\n    if( pRight->pUsing ){\n      IdList *pList = pRight->pUsing;\n      for(j=0; j<pList->nId; j++){\n        char *zName;     /* Name of the term in the USING clause */\n        int iLeft;       /* Table on the left with matching column name */\n        int iLeftCol;    /* Column number of matching column on the left */\n        int iRightCol;   /* Column number of matching column on the right */\n\n        zName = pList->a[j].zName;\n        iRightCol = columnIndex(pRightTab, zName);\n        if( iRightCol<0\n         || !tableAndColumnIndex(pSrc, i+1, zName, &iLeft, &iLeftCol)\n        ){\n          sqlite3ErrorMsg(pParse, \"cannot join using column %s - column \"\n            \"not present in both tables\", zName);\n          return 1;\n        }\n        addWhereTerm(pParse, pSrc, iLeft, iLeftCol, i+1, iRightCol,\n                     isOuter, &p->pWhere);\n      }\n    }\n  }\n  return 0;\n}\n\n/*\n** An instance of this object holds information (beyond pParse and pSelect)\n** needed to load the next result row that is to be added to the sorter.\n*/\ntypedef struct RowLoadInfo RowLoadInfo;\nstruct RowLoadInfo {\n  int regResult;               /* Store results in array of registers here */\n  u8 ecelFlags;                /* Flag argument to ExprCodeExprList() */\n#ifdef SQLITE_ENABLE_SORTER_REFERENCES\n  ExprList *pExtra;            /* Extra columns needed by sorter refs */\n  int regExtraResult;          /* Where to load the extra columns */\n#endif\n};\n\n/*\n** This routine does the work of loading query data into an array of\n** registers so that it can be added to the sorter.\n*/\nstatic void innerLoopLoadRow(\n  Parse *pParse,             /* Statement under construction */\n  Select *pSelect,           /* The query being coded */\n  RowLoadInfo *pInfo         /* Info needed to complete the row load */\n){\n  sqlite3ExprCodeExprList(pParse, pSelect->pEList, pInfo->regResult,\n                          0, pInfo->ecelFlags);\n#ifdef SQLITE_ENABLE_SORTER_REFERENCES\n  if( pInfo->pExtra ){\n    sqlite3ExprCodeExprList(pParse, pInfo->pExtra, pInfo->regExtraResult, 0, 0);\n    sqlite3ExprListDelete(pParse->db, pInfo->pExtra);\n  }\n#endif\n}\n\n/*\n** Code the OP_MakeRecord instruction that generates the entry to be\n** added into the sorter.\n**\n** Return the register in which the result is stored.\n*/\nstatic int makeSorterRecord(\n  Parse *pParse,\n  SortCtx *pSort,\n  Select *pSelect,\n  int regBase,\n  int nBase\n){\n  int nOBSat = pSort->nOBSat;\n  Vdbe *v = pParse->pVdbe;\n  int regOut = ++pParse->nMem;\n  if( pSort->pDeferredRowLoad ){\n    innerLoopLoadRow(pParse, pSelect, pSort->pDeferredRowLoad);\n  }\n  sqlite3VdbeAddOp3(v, OP_MakeRecord, regBase+nOBSat, nBase-nOBSat, regOut);\n  return regOut;\n}\n\n/*\n** Generate code that will push the record in registers regData\n** through regData+nData-1 onto the sorter.\n*/\nstatic void pushOntoSorter(\n  Parse *pParse,         /* Parser context */\n  SortCtx *pSort,        /* Information about the ORDER BY clause */\n  Select *pSelect,       /* The whole SELECT statement */\n  int regData,           /* First register holding data to be sorted */\n  int regOrigData,       /* First register holding data before packing */\n  int nData,             /* Number of elements in the regData data array */\n  int nPrefixReg         /* No. of reg prior to regData available for use */\n){\n  Vdbe *v = pParse->pVdbe;                         /* Stmt under construction */\n  int bSeq = ((pSort->sortFlags & SORTFLAG_UseSorter)==0);\n  int nExpr = pSort->pOrderBy->nExpr;              /* No. of ORDER BY terms */\n  int nBase = nExpr + bSeq + nData;                /* Fields in sorter record */\n  int regBase;                                     /* Regs for sorter record */\n  int regRecord = 0;                               /* Assembled sorter record */\n  int nOBSat = pSort->nOBSat;                      /* ORDER BY terms to skip */\n  int op;                            /* Opcode to add sorter record to sorter */\n  int iLimit;                        /* LIMIT counter */\n  int iSkip = 0;                     /* End of the sorter insert loop */\n\n  assert( bSeq==0 || bSeq==1 );\n\n  /* Three cases:\n  **   (1) The data to be sorted has already been packed into a Record\n  **       by a prior OP_MakeRecord.  In this case nData==1 and regData\n  **       will be completely unrelated to regOrigData.\n  **   (2) All output columns are included in the sort record.  In that\n  **       case regData==regOrigData.\n  **   (3) Some output columns are omitted from the sort record due to\n  **       the SQLITE_ENABLE_SORTER_REFERENCE optimization, or due to the\n  **       SQLITE_ECEL_OMITREF optimization, or due to the \n  **       SortCtx.pDeferredRowLoad optimiation.  In any of these cases\n  **       regOrigData is 0 to prevent this routine from trying to copy\n  **       values that might not yet exist.\n  */\n  assert( nData==1 || regData==regOrigData || regOrigData==0 );\n\n  if( nPrefixReg ){\n    assert( nPrefixReg==nExpr+bSeq );\n    regBase = regData - nPrefixReg;\n  }else{\n    regBase = pParse->nMem + 1;\n    pParse->nMem += nBase;\n  }\n  assert( pSelect->iOffset==0 || pSelect->iLimit!=0 );\n  iLimit = pSelect->iOffset ? pSelect->iOffset+1 : pSelect->iLimit;\n  pSort->labelDone = sqlite3VdbeMakeLabel(pParse);\n  sqlite3ExprCodeExprList(pParse, pSort->pOrderBy, regBase, regOrigData,\n                          SQLITE_ECEL_DUP | (regOrigData? SQLITE_ECEL_REF : 0));\n  if( bSeq ){\n    sqlite3VdbeAddOp2(v, OP_Sequence, pSort->iECursor, regBase+nExpr);\n  }\n  if( nPrefixReg==0 && nData>0 ){\n    sqlite3ExprCodeMove(pParse, regData, regBase+nExpr+bSeq, nData);\n  }\n  if( nOBSat>0 ){\n    int regPrevKey;   /* The first nOBSat columns of the previous row */\n    int addrFirst;    /* Address of the OP_IfNot opcode */\n    int addrJmp;      /* Address of the OP_Jump opcode */\n    VdbeOp *pOp;      /* Opcode that opens the sorter */\n    int nKey;         /* Number of sorting key columns, including OP_Sequence */\n    KeyInfo *pKI;     /* Original KeyInfo on the sorter table */\n\n    regRecord = makeSorterRecord(pParse, pSort, pSelect, regBase, nBase);\n    regPrevKey = pParse->nMem+1;\n    pParse->nMem += pSort->nOBSat;\n    nKey = nExpr - pSort->nOBSat + bSeq;\n    if( bSeq ){\n      addrFirst = sqlite3VdbeAddOp1(v, OP_IfNot, regBase+nExpr); \n    }else{\n      addrFirst = sqlite3VdbeAddOp1(v, OP_SequenceTest, pSort->iECursor);\n    }\n    VdbeCoverage(v);\n    sqlite3VdbeAddOp3(v, OP_Compare, regPrevKey, regBase, pSort->nOBSat);\n    pOp = sqlite3VdbeGetOp(v, pSort->addrSortIndex);\n    if( pParse->db->mallocFailed ) return;\n    pOp->p2 = nKey + nData;\n    pKI = pOp->p4.pKeyInfo;\n    memset(pKI->aSortOrder, 0, pKI->nKeyField); /* Makes OP_Jump testable */\n    sqlite3VdbeChangeP4(v, -1, (char*)pKI, P4_KEYINFO);\n    testcase( pKI->nAllField > pKI->nKeyField+2 );\n    pOp->p4.pKeyInfo = sqlite3KeyInfoFromExprList(pParse,pSort->pOrderBy,nOBSat,\n                                           pKI->nAllField-pKI->nKeyField-1);\n    addrJmp = sqlite3VdbeCurrentAddr(v);\n    sqlite3VdbeAddOp3(v, OP_Jump, addrJmp+1, 0, addrJmp+1); VdbeCoverage(v);\n    pSort->labelBkOut = sqlite3VdbeMakeLabel(pParse);\n    pSort->regReturn = ++pParse->nMem;\n    sqlite3VdbeAddOp2(v, OP_Gosub, pSort->regReturn, pSort->labelBkOut);\n    sqlite3VdbeAddOp1(v, OP_ResetSorter, pSort->iECursor);\n    if( iLimit ){\n      sqlite3VdbeAddOp2(v, OP_IfNot, iLimit, pSort->labelDone);\n      VdbeCoverage(v);\n    }\n    sqlite3VdbeJumpHere(v, addrFirst);\n    sqlite3ExprCodeMove(pParse, regBase, regPrevKey, pSort->nOBSat);\n    sqlite3VdbeJumpHere(v, addrJmp);\n  }\n  if( iLimit ){\n    /* At this point the values for the new sorter entry are stored\n    ** in an array of registers. They need to be composed into a record\n    ** and inserted into the sorter if either (a) there are currently\n    ** less than LIMIT+OFFSET items or (b) the new record is smaller than \n    ** the largest record currently in the sorter. If (b) is true and there\n    ** are already LIMIT+OFFSET items in the sorter, delete the largest\n    ** entry before inserting the new one. This way there are never more \n    ** than LIMIT+OFFSET items in the sorter.\n    **\n    ** If the new record does not need to be inserted into the sorter,\n    ** jump to the next iteration of the loop. If the pSort->labelOBLopt\n    ** value is not zero, then it is a label of where to jump.  Otherwise,\n    ** just bypass the row insert logic.  See the header comment on the\n    ** sqlite3WhereOrderByLimitOptLabel() function for additional info.\n    */\n    int iCsr = pSort->iECursor;\n    sqlite3VdbeAddOp2(v, OP_IfNotZero, iLimit, sqlite3VdbeCurrentAddr(v)+4);\n    VdbeCoverage(v);\n    sqlite3VdbeAddOp2(v, OP_Last, iCsr, 0);\n    iSkip = sqlite3VdbeAddOp4Int(v, OP_IdxLE,\n                                 iCsr, 0, regBase+nOBSat, nExpr-nOBSat);\n    VdbeCoverage(v);\n    sqlite3VdbeAddOp1(v, OP_Delete, iCsr);\n  }\n  if( regRecord==0 ){\n    regRecord = makeSorterRecord(pParse, pSort, pSelect, regBase, nBase);\n  }\n  if( pSort->sortFlags & SORTFLAG_UseSorter ){\n    op = OP_SorterInsert;\n  }else{\n    op = OP_IdxInsert;\n  }\n  sqlite3VdbeAddOp4Int(v, op, pSort->iECursor, regRecord,\n                       regBase+nOBSat, nBase-nOBSat);\n  if( iSkip ){\n    sqlite3VdbeChangeP2(v, iSkip,\n         pSort->labelOBLopt ? pSort->labelOBLopt : sqlite3VdbeCurrentAddr(v));\n  }\n}\n\n/*\n** Add code to implement the OFFSET\n*/\nstatic void codeOffset(\n  Vdbe *v,          /* Generate code into this VM */\n  int iOffset,      /* Register holding the offset counter */\n  int iContinue     /* Jump here to skip the current record */\n){\n  if( iOffset>0 ){\n    sqlite3VdbeAddOp3(v, OP_IfPos, iOffset, iContinue, 1); VdbeCoverage(v);\n    VdbeComment((v, \"OFFSET\"));\n  }\n}\n\n/*\n** Add code that will check to make sure the N registers starting at iMem\n** form a distinct entry.  iTab is a sorting index that holds previously\n** seen combinations of the N values.  A new entry is made in iTab\n** if the current N values are new.\n**\n** A jump to addrRepeat is made and the N+1 values are popped from the\n** stack if the top N elements are not distinct.\n*/\nstatic void codeDistinct(\n  Parse *pParse,     /* Parsing and code generating context */\n  int iTab,          /* A sorting index used to test for distinctness */\n  int addrRepeat,    /* Jump to here if not distinct */\n  int N,             /* Number of elements */\n  int iMem           /* First element */\n){\n  Vdbe *v;\n  int r1;\n\n  v = pParse->pVdbe;\n  r1 = sqlite3GetTempReg(pParse);\n  sqlite3VdbeAddOp4Int(v, OP_Found, iTab, addrRepeat, iMem, N); VdbeCoverage(v);\n  sqlite3VdbeAddOp3(v, OP_MakeRecord, iMem, N, r1);\n  sqlite3VdbeAddOp4Int(v, OP_IdxInsert, iTab, r1, iMem, N);\n  sqlite3VdbeChangeP5(v, OPFLAG_USESEEKRESULT);\n  sqlite3ReleaseTempReg(pParse, r1);\n}\n\n#ifdef SQLITE_ENABLE_SORTER_REFERENCES\n/*\n** This function is called as part of inner-loop generation for a SELECT\n** statement with an ORDER BY that is not optimized by an index. It \n** determines the expressions, if any, that the sorter-reference \n** optimization should be used for. The sorter-reference optimization\n** is used for SELECT queries like:\n**\n**   SELECT a, bigblob FROM t1 ORDER BY a LIMIT 10\n**\n** If the optimization is used for expression \"bigblob\", then instead of\n** storing values read from that column in the sorter records, the PK of\n** the row from table t1 is stored instead. Then, as records are extracted from\n** the sorter to return to the user, the required value of bigblob is\n** retrieved directly from table t1. If the values are very large, this \n** can be more efficient than storing them directly in the sorter records.\n**\n** The ExprList_item.bSorterRef flag is set for each expression in pEList \n** for which the sorter-reference optimization should be enabled. \n** Additionally, the pSort->aDefer[] array is populated with entries\n** for all cursors required to evaluate all selected expressions. Finally.\n** output variable (*ppExtra) is set to an expression list containing\n** expressions for all extra PK values that should be stored in the\n** sorter records.\n*/\nstatic void selectExprDefer(\n  Parse *pParse,                  /* Leave any error here */\n  SortCtx *pSort,                 /* Sorter context */\n  ExprList *pEList,               /* Expressions destined for sorter */\n  ExprList **ppExtra              /* Expressions to append to sorter record */\n){\n  int i;\n  int nDefer = 0;\n  ExprList *pExtra = 0;\n  for(i=0; i<pEList->nExpr; i++){\n    struct ExprList_item *pItem = &pEList->a[i];\n    if( pItem->u.x.iOrderByCol==0 ){\n      Expr *pExpr = pItem->pExpr;\n      Table *pTab = pExpr->y.pTab;\n      if( pExpr->op==TK_COLUMN && pExpr->iColumn>=0 && pTab && !IsVirtual(pTab)\n       && (pTab->aCol[pExpr->iColumn].colFlags & COLFLAG_SORTERREF)\n      ){\n        int j;\n        for(j=0; j<nDefer; j++){\n          if( pSort->aDefer[j].iCsr==pExpr->iTable ) break;\n        }\n        if( j==nDefer ){\n          if( nDefer==ArraySize(pSort->aDefer) ){\n            continue;\n          }else{\n            int nKey = 1;\n            int k;\n            Index *pPk = 0;\n            if( !HasRowid(pTab) ){\n              pPk = sqlite3PrimaryKeyIndex(pTab);\n              nKey = pPk->nKeyCol;\n            }\n            for(k=0; k<nKey; k++){\n              Expr *pNew = sqlite3PExpr(pParse, TK_COLUMN, 0, 0);\n              if( pNew ){\n                pNew->iTable = pExpr->iTable;\n                pNew->y.pTab = pExpr->y.pTab;\n                pNew->iColumn = pPk ? pPk->aiColumn[k] : -1;\n                pExtra = sqlite3ExprListAppend(pParse, pExtra, pNew);\n              }\n            }\n            pSort->aDefer[nDefer].pTab = pExpr->y.pTab;\n            pSort->aDefer[nDefer].iCsr = pExpr->iTable;\n            pSort->aDefer[nDefer].nKey = nKey;\n            nDefer++;\n          }\n        }\n        pItem->bSorterRef = 1;\n      }\n    }\n  }\n  pSort->nDefer = (u8)nDefer;\n  *ppExtra = pExtra;\n}\n#endif\n\n/*\n** This routine generates the code for the inside of the inner loop\n** of a SELECT.\n**\n** If srcTab is negative, then the p->pEList expressions\n** are evaluated in order to get the data for this row.  If srcTab is\n** zero or more, then data is pulled from srcTab and p->pEList is used only \n** to get the number of columns and the collation sequence for each column.\n*/\nstatic void selectInnerLoop(\n  Parse *pParse,          /* The parser context */\n  Select *p,              /* The complete select statement being coded */\n  int srcTab,             /* Pull data from this table if non-negative */\n  SortCtx *pSort,         /* If not NULL, info on how to process ORDER BY */\n  DistinctCtx *pDistinct, /* If not NULL, info on how to process DISTINCT */\n  SelectDest *pDest,      /* How to dispose of the results */\n  int iContinue,          /* Jump here to continue with next row */\n  int iBreak              /* Jump here to break out of the inner loop */\n){\n  Vdbe *v = pParse->pVdbe;\n  int i;\n  int hasDistinct;            /* True if the DISTINCT keyword is present */\n  int eDest = pDest->eDest;   /* How to dispose of results */\n  int iParm = pDest->iSDParm; /* First argument to disposal method */\n  int nResultCol;             /* Number of result columns */\n  int nPrefixReg = 0;         /* Number of extra registers before regResult */\n  RowLoadInfo sRowLoadInfo;   /* Info for deferred row loading */\n\n  /* Usually, regResult is the first cell in an array of memory cells\n  ** containing the current result row. In this case regOrig is set to the\n  ** same value. However, if the results are being sent to the sorter, the\n  ** values for any expressions that are also part of the sort-key are omitted\n  ** from this array. In this case regOrig is set to zero.  */\n  int regResult;              /* Start of memory holding current results */\n  int regOrig;                /* Start of memory holding full result (or 0) */\n\n  assert( v );\n  assert( p->pEList!=0 );\n  hasDistinct = pDistinct ? pDistinct->eTnctType : WHERE_DISTINCT_NOOP;\n  if( pSort && pSort->pOrderBy==0 ) pSort = 0;\n  if( pSort==0 && !hasDistinct ){\n    assert( iContinue!=0 );\n    codeOffset(v, p->iOffset, iContinue);\n  }\n\n  /* Pull the requested columns.\n  */\n  nResultCol = p->pEList->nExpr;\n\n  if( pDest->iSdst==0 ){\n    if( pSort ){\n      nPrefixReg = pSort->pOrderBy->nExpr;\n      if( !(pSort->sortFlags & SORTFLAG_UseSorter) ) nPrefixReg++;\n      pParse->nMem += nPrefixReg;\n    }\n    pDest->iSdst = pParse->nMem+1;\n    pParse->nMem += nResultCol;\n  }else if( pDest->iSdst+nResultCol > pParse->nMem ){\n    /* This is an error condition that can result, for example, when a SELECT\n    ** on the right-hand side of an INSERT contains more result columns than\n    ** there are columns in the table on the left.  The error will be caught\n    ** and reported later.  But we need to make sure enough memory is allocated\n    ** to avoid other spurious errors in the meantime. */\n    pParse->nMem += nResultCol;\n  }\n  pDest->nSdst = nResultCol;\n  regOrig = regResult = pDest->iSdst;\n  if( srcTab>=0 ){\n    for(i=0; i<nResultCol; i++){\n      sqlite3VdbeAddOp3(v, OP_Column, srcTab, i, regResult+i);\n      VdbeComment((v, \"%s\", p->pEList->a[i].zName));\n    }\n  }else if( eDest!=SRT_Exists ){\n#ifdef SQLITE_ENABLE_SORTER_REFERENCES\n    ExprList *pExtra = 0;\n#endif\n    /* If the destination is an EXISTS(...) expression, the actual\n    ** values returned by the SELECT are not required.\n    */\n    u8 ecelFlags;    /* \"ecel\" is an abbreviation of \"ExprCodeExprList\" */\n    ExprList *pEList;\n    if( eDest==SRT_Mem || eDest==SRT_Output || eDest==SRT_Coroutine ){\n      ecelFlags = SQLITE_ECEL_DUP;\n    }else{\n      ecelFlags = 0;\n    }\n    if( pSort && hasDistinct==0 && eDest!=SRT_EphemTab && eDest!=SRT_Table ){\n      /* For each expression in p->pEList that is a copy of an expression in\n      ** the ORDER BY clause (pSort->pOrderBy), set the associated \n      ** iOrderByCol value to one more than the index of the ORDER BY \n      ** expression within the sort-key that pushOntoSorter() will generate.\n      ** This allows the p->pEList field to be omitted from the sorted record,\n      ** saving space and CPU cycles.  */\n      ecelFlags |= (SQLITE_ECEL_OMITREF|SQLITE_ECEL_REF);\n\n      for(i=pSort->nOBSat; i<pSort->pOrderBy->nExpr; i++){\n        int j;\n        if( (j = pSort->pOrderBy->a[i].u.x.iOrderByCol)>0 ){\n          p->pEList->a[j-1].u.x.iOrderByCol = i+1-pSort->nOBSat;\n        }\n      }\n#ifdef SQLITE_ENABLE_SORTER_REFERENCES\n      selectExprDefer(pParse, pSort, p->pEList, &pExtra);\n      if( pExtra && pParse->db->mallocFailed==0 ){\n        /* If there are any extra PK columns to add to the sorter records,\n        ** allocate extra memory cells and adjust the OpenEphemeral \n        ** instruction to account for the larger records. This is only\n        ** required if there are one or more WITHOUT ROWID tables with\n        ** composite primary keys in the SortCtx.aDefer[] array.  */\n        VdbeOp *pOp = sqlite3VdbeGetOp(v, pSort->addrSortIndex);\n        pOp->p2 += (pExtra->nExpr - pSort->nDefer);\n        pOp->p4.pKeyInfo->nAllField += (pExtra->nExpr - pSort->nDefer);\n        pParse->nMem += pExtra->nExpr;\n      }\n#endif\n\n      /* Adjust nResultCol to account for columns that are omitted\n      ** from the sorter by the optimizations in this branch */\n      pEList = p->pEList;\n      for(i=0; i<pEList->nExpr; i++){\n        if( pEList->a[i].u.x.iOrderByCol>0\n#ifdef SQLITE_ENABLE_SORTER_REFERENCES\n         || pEList->a[i].bSorterRef\n#endif\n        ){\n          nResultCol--;\n          regOrig = 0;\n        }\n      }\n\n      testcase( regOrig );\n      testcase( eDest==SRT_Set );\n      testcase( eDest==SRT_Mem );\n      testcase( eDest==SRT_Coroutine );\n      testcase( eDest==SRT_Output );\n      assert( eDest==SRT_Set || eDest==SRT_Mem \n           || eDest==SRT_Coroutine || eDest==SRT_Output );\n    }\n    sRowLoadInfo.regResult = regResult;\n    sRowLoadInfo.ecelFlags = ecelFlags;\n#ifdef SQLITE_ENABLE_SORTER_REFERENCES\n    sRowLoadInfo.pExtra = pExtra;\n    sRowLoadInfo.regExtraResult = regResult + nResultCol;\n    if( pExtra ) nResultCol += pExtra->nExpr;\n#endif\n    if( p->iLimit\n     && (ecelFlags & SQLITE_ECEL_OMITREF)!=0 \n     && nPrefixReg>0\n    ){\n      assert( pSort!=0 );\n      assert( hasDistinct==0 );\n      pSort->pDeferredRowLoad = &sRowLoadInfo;\n      regOrig = 0;\n    }else{\n      innerLoopLoadRow(pParse, p, &sRowLoadInfo);\n    }\n  }\n\n  /* If the DISTINCT keyword was present on the SELECT statement\n  ** and this row has been seen before, then do not make this row\n  ** part of the result.\n  */\n  if( hasDistinct ){\n    switch( pDistinct->eTnctType ){\n      case WHERE_DISTINCT_ORDERED: {\n        VdbeOp *pOp;            /* No longer required OpenEphemeral instr. */\n        int iJump;              /* Jump destination */\n        int regPrev;            /* Previous row content */\n\n        /* Allocate space for the previous row */\n        regPrev = pParse->nMem+1;\n        pParse->nMem += nResultCol;\n\n        /* Change the OP_OpenEphemeral coded earlier to an OP_Null\n        ** sets the MEM_Cleared bit on the first register of the\n        ** previous value.  This will cause the OP_Ne below to always\n        ** fail on the first iteration of the loop even if the first\n        ** row is all NULLs.\n        */\n        sqlite3VdbeChangeToNoop(v, pDistinct->addrTnct);\n        pOp = sqlite3VdbeGetOp(v, pDistinct->addrTnct);\n        pOp->opcode = OP_Null;\n        pOp->p1 = 1;\n        pOp->p2 = regPrev;\n\n        iJump = sqlite3VdbeCurrentAddr(v) + nResultCol;\n        for(i=0; i<nResultCol; i++){\n          CollSeq *pColl = sqlite3ExprCollSeq(pParse, p->pEList->a[i].pExpr);\n          if( i<nResultCol-1 ){\n            sqlite3VdbeAddOp3(v, OP_Ne, regResult+i, iJump, regPrev+i);\n            VdbeCoverage(v);\n          }else{\n            sqlite3VdbeAddOp3(v, OP_Eq, regResult+i, iContinue, regPrev+i);\n            VdbeCoverage(v);\n           }\n          sqlite3VdbeChangeP4(v, -1, (const char *)pColl, P4_COLLSEQ);\n          sqlite3VdbeChangeP5(v, SQLITE_NULLEQ);\n        }\n        assert( sqlite3VdbeCurrentAddr(v)==iJump || pParse->db->mallocFailed );\n        sqlite3VdbeAddOp3(v, OP_Copy, regResult, regPrev, nResultCol-1);\n        break;\n      }\n\n      case WHERE_DISTINCT_UNIQUE: {\n        sqlite3VdbeChangeToNoop(v, pDistinct->addrTnct);\n        break;\n      }\n\n      default: {\n        assert( pDistinct->eTnctType==WHERE_DISTINCT_UNORDERED );\n        codeDistinct(pParse, pDistinct->tabTnct, iContinue, nResultCol,\n                     regResult);\n        break;\n      }\n    }\n    if( pSort==0 ){\n      codeOffset(v, p->iOffset, iContinue);\n    }\n  }\n\n  switch( eDest ){\n    /* In this mode, write each query result to the key of the temporary\n    ** table iParm.\n    */\n#ifndef SQLITE_OMIT_COMPOUND_SELECT\n    case SRT_Union: {\n      int r1;\n      r1 = sqlite3GetTempReg(pParse);\n      sqlite3VdbeAddOp3(v, OP_MakeRecord, regResult, nResultCol, r1);\n      sqlite3VdbeAddOp4Int(v, OP_IdxInsert, iParm, r1, regResult, nResultCol);\n      sqlite3ReleaseTempReg(pParse, r1);\n      break;\n    }\n\n    /* Construct a record from the query result, but instead of\n    ** saving that record, use it as a key to delete elements from\n    ** the temporary table iParm.\n    */\n    case SRT_Except: {\n      sqlite3VdbeAddOp3(v, OP_IdxDelete, iParm, regResult, nResultCol);\n      break;\n    }\n#endif /* SQLITE_OMIT_COMPOUND_SELECT */\n\n    /* Store the result as data using a unique key.\n    */\n    case SRT_Fifo:\n    case SRT_DistFifo:\n    case SRT_Table:\n    case SRT_EphemTab: {\n      int r1 = sqlite3GetTempRange(pParse, nPrefixReg+1);\n      testcase( eDest==SRT_Table );\n      testcase( eDest==SRT_EphemTab );\n      testcase( eDest==SRT_Fifo );\n      testcase( eDest==SRT_DistFifo );\n      sqlite3VdbeAddOp3(v, OP_MakeRecord, regResult, nResultCol, r1+nPrefixReg);\n#ifndef SQLITE_OMIT_CTE\n      if( eDest==SRT_DistFifo ){\n        /* If the destination is DistFifo, then cursor (iParm+1) is open\n        ** on an ephemeral index. If the current row is already present\n        ** in the index, do not write it to the output. If not, add the\n        ** current row to the index and proceed with writing it to the\n        ** output table as well.  */\n        int addr = sqlite3VdbeCurrentAddr(v) + 4;\n        sqlite3VdbeAddOp4Int(v, OP_Found, iParm+1, addr, r1, 0);\n        VdbeCoverage(v);\n        sqlite3VdbeAddOp4Int(v, OP_IdxInsert, iParm+1, r1,regResult,nResultCol);\n        assert( pSort==0 );\n      }\n#endif\n      if( pSort ){\n        assert( regResult==regOrig );\n        pushOntoSorter(pParse, pSort, p, r1+nPrefixReg, regOrig, 1, nPrefixReg);\n      }else{\n        int r2 = sqlite3GetTempReg(pParse);\n        sqlite3VdbeAddOp2(v, OP_NewRowid, iParm, r2);\n        sqlite3VdbeAddOp3(v, OP_Insert, iParm, r1, r2);\n        sqlite3VdbeChangeP5(v, OPFLAG_APPEND);\n        sqlite3ReleaseTempReg(pParse, r2);\n      }\n      sqlite3ReleaseTempRange(pParse, r1, nPrefixReg+1);\n      break;\n    }\n\n#ifndef SQLITE_OMIT_SUBQUERY\n    /* If we are creating a set for an \"expr IN (SELECT ...)\" construct,\n    ** then there should be a single item on the stack.  Write this\n    ** item into the set table with bogus data.\n    */\n    case SRT_Set: {\n      if( pSort ){\n        /* At first glance you would think we could optimize out the\n        ** ORDER BY in this case since the order of entries in the set\n        ** does not matter.  But there might be a LIMIT clause, in which\n        ** case the order does matter */\n        pushOntoSorter(\n            pParse, pSort, p, regResult, regOrig, nResultCol, nPrefixReg);\n      }else{\n        int r1 = sqlite3GetTempReg(pParse);\n        assert( sqlite3Strlen30(pDest->zAffSdst)==nResultCol );\n        sqlite3VdbeAddOp4(v, OP_MakeRecord, regResult, nResultCol, \n            r1, pDest->zAffSdst, nResultCol);\n        sqlite3VdbeAddOp4Int(v, OP_IdxInsert, iParm, r1, regResult, nResultCol);\n        sqlite3ReleaseTempReg(pParse, r1);\n      }\n      break;\n    }\n\n    /* If any row exist in the result set, record that fact and abort.\n    */\n    case SRT_Exists: {\n      sqlite3VdbeAddOp2(v, OP_Integer, 1, iParm);\n      /* The LIMIT clause will terminate the loop for us */\n      break;\n    }\n\n    /* If this is a scalar select that is part of an expression, then\n    ** store the results in the appropriate memory cell or array of \n    ** memory cells and break out of the scan loop.\n    */\n    case SRT_Mem: {\n      if( pSort ){\n        assert( nResultCol<=pDest->nSdst );\n        pushOntoSorter(\n            pParse, pSort, p, regResult, regOrig, nResultCol, nPrefixReg);\n      }else{\n        assert( nResultCol==pDest->nSdst );\n        assert( regResult==iParm );\n        /* The LIMIT clause will jump out of the loop for us */\n      }\n      break;\n    }\n#endif /* #ifndef SQLITE_OMIT_SUBQUERY */\n\n    case SRT_Coroutine:       /* Send data to a co-routine */\n    case SRT_Output: {        /* Return the results */\n      testcase( eDest==SRT_Coroutine );\n      testcase( eDest==SRT_Output );\n      if( pSort ){\n        pushOntoSorter(pParse, pSort, p, regResult, regOrig, nResultCol,\n                       nPrefixReg);\n      }else if( eDest==SRT_Coroutine ){\n        sqlite3VdbeAddOp1(v, OP_Yield, pDest->iSDParm);\n      }else{\n        sqlite3VdbeAddOp2(v, OP_ResultRow, regResult, nResultCol);\n      }\n      break;\n    }\n\n#ifndef SQLITE_OMIT_CTE\n    /* Write the results into a priority queue that is order according to\n    ** pDest->pOrderBy (in pSO).  pDest->iSDParm (in iParm) is the cursor for an\n    ** index with pSO->nExpr+2 columns.  Build a key using pSO for the first\n    ** pSO->nExpr columns, then make sure all keys are unique by adding a\n    ** final OP_Sequence column.  The last column is the record as a blob.\n    */\n    case SRT_DistQueue:\n    case SRT_Queue: {\n      int nKey;\n      int r1, r2, r3;\n      int addrTest = 0;\n      ExprList *pSO;\n      pSO = pDest->pOrderBy;\n      assert( pSO );\n      nKey = pSO->nExpr;\n      r1 = sqlite3GetTempReg(pParse);\n      r2 = sqlite3GetTempRange(pParse, nKey+2);\n      r3 = r2+nKey+1;\n      if( eDest==SRT_DistQueue ){\n        /* If the destination is DistQueue, then cursor (iParm+1) is open\n        ** on a second ephemeral index that holds all values every previously\n        ** added to the queue. */\n        addrTest = sqlite3VdbeAddOp4Int(v, OP_Found, iParm+1, 0, \n                                        regResult, nResultCol);\n        VdbeCoverage(v);\n      }\n      sqlite3VdbeAddOp3(v, OP_MakeRecord, regResult, nResultCol, r3);\n      if( eDest==SRT_DistQueue ){\n        sqlite3VdbeAddOp2(v, OP_IdxInsert, iParm+1, r3);\n        sqlite3VdbeChangeP5(v, OPFLAG_USESEEKRESULT);\n      }\n      for(i=0; i<nKey; i++){\n        sqlite3VdbeAddOp2(v, OP_SCopy,\n                          regResult + pSO->a[i].u.x.iOrderByCol - 1,\n                          r2+i);\n      }\n      sqlite3VdbeAddOp2(v, OP_Sequence, iParm, r2+nKey);\n      sqlite3VdbeAddOp3(v, OP_MakeRecord, r2, nKey+2, r1);\n      sqlite3VdbeAddOp4Int(v, OP_IdxInsert, iParm, r1, r2, nKey+2);\n      if( addrTest ) sqlite3VdbeJumpHere(v, addrTest);\n      sqlite3ReleaseTempReg(pParse, r1);\n      sqlite3ReleaseTempRange(pParse, r2, nKey+2);\n      break;\n    }\n#endif /* SQLITE_OMIT_CTE */\n\n\n\n#if !defined(SQLITE_OMIT_TRIGGER)\n    /* Discard the results.  This is used for SELECT statements inside\n    ** the body of a TRIGGER.  The purpose of such selects is to call\n    ** user-defined functions that have side effects.  We do not care\n    ** about the actual results of the select.\n    */\n    default: {\n      assert( eDest==SRT_Discard );\n      break;\n    }\n#endif\n  }\n\n  /* Jump to the end of the loop if the LIMIT is reached.  Except, if\n  ** there is a sorter, in which case the sorter has already limited\n  ** the output for us.\n  */\n  if( pSort==0 && p->iLimit ){\n    sqlite3VdbeAddOp2(v, OP_DecrJumpZero, p->iLimit, iBreak); VdbeCoverage(v);\n  }\n}\n\n/*\n** Allocate a KeyInfo object sufficient for an index of N key columns and\n** X extra columns.\n*/\nSQLITE_PRIVATE KeyInfo *sqlite3KeyInfoAlloc(sqlite3 *db, int N, int X){\n  int nExtra = (N+X)*(sizeof(CollSeq*)+1) - sizeof(CollSeq*);\n  KeyInfo *p = sqlite3DbMallocRawNN(db, sizeof(KeyInfo) + nExtra);\n  if( p ){\n    p->aSortOrder = (u8*)&p->aColl[N+X];\n    p->nKeyField = (u16)N;\n    p->nAllField = (u16)(N+X);\n    p->enc = ENC(db);\n    p->db = db;\n    p->nRef = 1;\n    memset(&p[1], 0, nExtra);\n  }else{\n    sqlite3OomFault(db);\n  }\n  return p;\n}\n\n/*\n** Deallocate a KeyInfo object\n*/\nSQLITE_PRIVATE void sqlite3KeyInfoUnref(KeyInfo *p){\n  if( p ){\n    assert( p->nRef>0 );\n    p->nRef--;\n    if( p->nRef==0 ) sqlite3DbFreeNN(p->db, p);\n  }\n}\n\n/*\n** Make a new pointer to a KeyInfo object\n*/\nSQLITE_PRIVATE KeyInfo *sqlite3KeyInfoRef(KeyInfo *p){\n  if( p ){\n    assert( p->nRef>0 );\n    p->nRef++;\n  }\n  return p;\n}\n\n#ifdef SQLITE_DEBUG\n/*\n** Return TRUE if a KeyInfo object can be change.  The KeyInfo object\n** can only be changed if this is just a single reference to the object.\n**\n** This routine is used only inside of assert() statements.\n*/\nSQLITE_PRIVATE int sqlite3KeyInfoIsWriteable(KeyInfo *p){ return p->nRef==1; }\n#endif /* SQLITE_DEBUG */\n\n/*\n** Given an expression list, generate a KeyInfo structure that records\n** the collating sequence for each expression in that expression list.\n**\n** If the ExprList is an ORDER BY or GROUP BY clause then the resulting\n** KeyInfo structure is appropriate for initializing a virtual index to\n** implement that clause.  If the ExprList is the result set of a SELECT\n** then the KeyInfo structure is appropriate for initializing a virtual\n** index to implement a DISTINCT test.\n**\n** Space to hold the KeyInfo structure is obtained from malloc.  The calling\n** function is responsible for seeing that this structure is eventually\n** freed.\n*/\nSQLITE_PRIVATE KeyInfo *sqlite3KeyInfoFromExprList(\n  Parse *pParse,       /* Parsing context */\n  ExprList *pList,     /* Form the KeyInfo object from this ExprList */\n  int iStart,          /* Begin with this column of pList */\n  int nExtra           /* Add this many extra columns to the end */\n){\n  int nExpr;\n  KeyInfo *pInfo;\n  struct ExprList_item *pItem;\n  sqlite3 *db = pParse->db;\n  int i;\n\n  nExpr = pList->nExpr;\n  pInfo = sqlite3KeyInfoAlloc(db, nExpr-iStart, nExtra+1);\n  if( pInfo ){\n    assert( sqlite3KeyInfoIsWriteable(pInfo) );\n    for(i=iStart, pItem=pList->a+iStart; i<nExpr; i++, pItem++){\n      pInfo->aColl[i-iStart] = sqlite3ExprNNCollSeq(pParse, pItem->pExpr);\n      pInfo->aSortOrder[i-iStart] = pItem->sortOrder;\n    }\n  }\n  return pInfo;\n}\n\n/*\n** Name of the connection operator, used for error messages.\n*/\nstatic const char *selectOpName(int id){\n  char *z;\n  switch( id ){\n    case TK_ALL:       z = \"UNION ALL\";   break;\n    case TK_INTERSECT: z = \"INTERSECT\";   break;\n    case TK_EXCEPT:    z = \"EXCEPT\";      break;\n    default:           z = \"UNION\";       break;\n  }\n  return z;\n}\n\n#ifndef SQLITE_OMIT_EXPLAIN\n/*\n** Unless an \"EXPLAIN QUERY PLAN\" command is being processed, this function\n** is a no-op. Otherwise, it adds a single row of output to the EQP result,\n** where the caption is of the form:\n**\n**   \"USE TEMP B-TREE FOR xxx\"\n**\n** where xxx is one of \"DISTINCT\", \"ORDER BY\" or \"GROUP BY\". Exactly which\n** is determined by the zUsage argument.\n*/\nstatic void explainTempTable(Parse *pParse, const char *zUsage){\n  ExplainQueryPlan((pParse, 0, \"USE TEMP B-TREE FOR %s\", zUsage));\n}\n\n/*\n** Assign expression b to lvalue a. A second, no-op, version of this macro\n** is provided when SQLITE_OMIT_EXPLAIN is defined. This allows the code\n** in sqlite3Select() to assign values to structure member variables that\n** only exist if SQLITE_OMIT_EXPLAIN is not defined without polluting the\n** code with #ifndef directives.\n*/\n# define explainSetInteger(a, b) a = b\n\n#else\n/* No-op versions of the explainXXX() functions and macros. */\n# define explainTempTable(y,z)\n# define explainSetInteger(y,z)\n#endif\n\n\n/*\n** If the inner loop was generated using a non-null pOrderBy argument,\n** then the results were placed in a sorter.  After the loop is terminated\n** we need to run the sorter and output the results.  The following\n** routine generates the code needed to do that.\n*/\nstatic void generateSortTail(\n  Parse *pParse,    /* Parsing context */\n  Select *p,        /* The SELECT statement */\n  SortCtx *pSort,   /* Information on the ORDER BY clause */\n  int nColumn,      /* Number of columns of data */\n  SelectDest *pDest /* Write the sorted results here */\n){\n  Vdbe *v = pParse->pVdbe;                     /* The prepared statement */\n  int addrBreak = pSort->labelDone;            /* Jump here to exit loop */\n  int addrContinue = sqlite3VdbeMakeLabel(pParse);/* Jump here for next cycle */\n  int addr;                       /* Top of output loop. Jump for Next. */\n  int addrOnce = 0;\n  int iTab;\n  ExprList *pOrderBy = pSort->pOrderBy;\n  int eDest = pDest->eDest;\n  int iParm = pDest->iSDParm;\n  int regRow;\n  int regRowid;\n  int iCol;\n  int nKey;                       /* Number of key columns in sorter record */\n  int iSortTab;                   /* Sorter cursor to read from */\n  int i;\n  int bSeq;                       /* True if sorter record includes seq. no. */\n  int nRefKey = 0;\n  struct ExprList_item *aOutEx = p->pEList->a;\n\n  assert( addrBreak<0 );\n  if( pSort->labelBkOut ){\n    sqlite3VdbeAddOp2(v, OP_Gosub, pSort->regReturn, pSort->labelBkOut);\n    sqlite3VdbeGoto(v, addrBreak);\n    sqlite3VdbeResolveLabel(v, pSort->labelBkOut);\n  }\n\n#ifdef SQLITE_ENABLE_SORTER_REFERENCES\n  /* Open any cursors needed for sorter-reference expressions */\n  for(i=0; i<pSort->nDefer; i++){\n    Table *pTab = pSort->aDefer[i].pTab;\n    int iDb = sqlite3SchemaToIndex(pParse->db, pTab->pSchema);\n    sqlite3OpenTable(pParse, pSort->aDefer[i].iCsr, iDb, pTab, OP_OpenRead);\n    nRefKey = MAX(nRefKey, pSort->aDefer[i].nKey);\n  }\n#endif\n\n  iTab = pSort->iECursor;\n  if( eDest==SRT_Output || eDest==SRT_Coroutine || eDest==SRT_Mem ){\n    regRowid = 0;\n    regRow = pDest->iSdst;\n  }else{\n    regRowid = sqlite3GetTempReg(pParse);\n    if( eDest==SRT_EphemTab || eDest==SRT_Table ){\n      regRow = sqlite3GetTempReg(pParse);\n      nColumn = 0;\n    }else{\n      regRow = sqlite3GetTempRange(pParse, nColumn);\n    }\n  }\n  nKey = pOrderBy->nExpr - pSort->nOBSat;\n  if( pSort->sortFlags & SORTFLAG_UseSorter ){\n    int regSortOut = ++pParse->nMem;\n    iSortTab = pParse->nTab++;\n    if( pSort->labelBkOut ){\n      addrOnce = sqlite3VdbeAddOp0(v, OP_Once); VdbeCoverage(v);\n    }\n    sqlite3VdbeAddOp3(v, OP_OpenPseudo, iSortTab, regSortOut, \n        nKey+1+nColumn+nRefKey);\n    if( addrOnce ) sqlite3VdbeJumpHere(v, addrOnce);\n    addr = 1 + sqlite3VdbeAddOp2(v, OP_SorterSort, iTab, addrBreak);\n    VdbeCoverage(v);\n    codeOffset(v, p->iOffset, addrContinue);\n    sqlite3VdbeAddOp3(v, OP_SorterData, iTab, regSortOut, iSortTab);\n    bSeq = 0;\n  }else{\n    addr = 1 + sqlite3VdbeAddOp2(v, OP_Sort, iTab, addrBreak); VdbeCoverage(v);\n    codeOffset(v, p->iOffset, addrContinue);\n    iSortTab = iTab;\n    bSeq = 1;\n  }\n  for(i=0, iCol=nKey+bSeq-1; i<nColumn; i++){\n#ifdef SQLITE_ENABLE_SORTER_REFERENCES\n    if( aOutEx[i].bSorterRef ) continue;\n#endif\n    if( aOutEx[i].u.x.iOrderByCol==0 ) iCol++;\n  }\n#ifdef SQLITE_ENABLE_SORTER_REFERENCES\n  if( pSort->nDefer ){\n    int iKey = iCol+1;\n    int regKey = sqlite3GetTempRange(pParse, nRefKey);\n\n    for(i=0; i<pSort->nDefer; i++){\n      int iCsr = pSort->aDefer[i].iCsr;\n      Table *pTab = pSort->aDefer[i].pTab;\n      int nKey = pSort->aDefer[i].nKey;\n\n      sqlite3VdbeAddOp1(v, OP_NullRow, iCsr);\n      if( HasRowid(pTab) ){\n        sqlite3VdbeAddOp3(v, OP_Column, iSortTab, iKey++, regKey);\n        sqlite3VdbeAddOp3(v, OP_SeekRowid, iCsr, \n            sqlite3VdbeCurrentAddr(v)+1, regKey);\n      }else{\n        int k;\n        int iJmp;\n        assert( sqlite3PrimaryKeyIndex(pTab)->nKeyCol==nKey );\n        for(k=0; k<nKey; k++){\n          sqlite3VdbeAddOp3(v, OP_Column, iSortTab, iKey++, regKey+k);\n        }\n        iJmp = sqlite3VdbeCurrentAddr(v);\n        sqlite3VdbeAddOp4Int(v, OP_SeekGE, iCsr, iJmp+2, regKey, nKey);\n        sqlite3VdbeAddOp4Int(v, OP_IdxLE, iCsr, iJmp+3, regKey, nKey);\n        sqlite3VdbeAddOp1(v, OP_NullRow, iCsr);\n      }\n    }\n    sqlite3ReleaseTempRange(pParse, regKey, nRefKey);\n  }\n#endif\n  for(i=nColumn-1; i>=0; i--){\n#ifdef SQLITE_ENABLE_SORTER_REFERENCES\n    if( aOutEx[i].bSorterRef ){\n      sqlite3ExprCode(pParse, aOutEx[i].pExpr, regRow+i);\n    }else\n#endif\n    {\n      int iRead;\n      if( aOutEx[i].u.x.iOrderByCol ){\n        iRead = aOutEx[i].u.x.iOrderByCol-1;\n      }else{\n        iRead = iCol--;\n      }\n      sqlite3VdbeAddOp3(v, OP_Column, iSortTab, iRead, regRow+i);\n      VdbeComment((v, \"%s\", aOutEx[i].zName?aOutEx[i].zName : aOutEx[i].zSpan));\n    }\n  }\n  switch( eDest ){\n    case SRT_Table:\n    case SRT_EphemTab: {\n      sqlite3VdbeAddOp3(v, OP_Column, iSortTab, nKey+bSeq, regRow);\n      sqlite3VdbeAddOp2(v, OP_NewRowid, iParm, regRowid);\n      sqlite3VdbeAddOp3(v, OP_Insert, iParm, regRow, regRowid);\n      sqlite3VdbeChangeP5(v, OPFLAG_APPEND);\n      break;\n    }\n#ifndef SQLITE_OMIT_SUBQUERY\n    case SRT_Set: {\n      assert( nColumn==sqlite3Strlen30(pDest->zAffSdst) );\n      sqlite3VdbeAddOp4(v, OP_MakeRecord, regRow, nColumn, regRowid,\n                        pDest->zAffSdst, nColumn);\n      sqlite3VdbeAddOp4Int(v, OP_IdxInsert, iParm, regRowid, regRow, nColumn);\n      break;\n    }\n    case SRT_Mem: {\n      /* The LIMIT clause will terminate the loop for us */\n      break;\n    }\n#endif\n    default: {\n      assert( eDest==SRT_Output || eDest==SRT_Coroutine ); \n      testcase( eDest==SRT_Output );\n      testcase( eDest==SRT_Coroutine );\n      if( eDest==SRT_Output ){\n        sqlite3VdbeAddOp2(v, OP_ResultRow, pDest->iSdst, nColumn);\n      }else{\n        sqlite3VdbeAddOp1(v, OP_Yield, pDest->iSDParm);\n      }\n      break;\n    }\n  }\n  if( regRowid ){\n    if( eDest==SRT_Set ){\n      sqlite3ReleaseTempRange(pParse, regRow, nColumn);\n    }else{\n      sqlite3ReleaseTempReg(pParse, regRow);\n    }\n    sqlite3ReleaseTempReg(pParse, regRowid);\n  }\n  /* The bottom of the loop\n  */\n  sqlite3VdbeResolveLabel(v, addrContinue);\n  if( pSort->sortFlags & SORTFLAG_UseSorter ){\n    sqlite3VdbeAddOp2(v, OP_SorterNext, iTab, addr); VdbeCoverage(v);\n  }else{\n    sqlite3VdbeAddOp2(v, OP_Next, iTab, addr); VdbeCoverage(v);\n  }\n  if( pSort->regReturn ) sqlite3VdbeAddOp1(v, OP_Return, pSort->regReturn);\n  sqlite3VdbeResolveLabel(v, addrBreak);\n}\n\n/*\n** Return a pointer to a string containing the 'declaration type' of the\n** expression pExpr. The string may be treated as static by the caller.\n**\n** Also try to estimate the size of the returned value and return that\n** result in *pEstWidth.\n**\n** The declaration type is the exact datatype definition extracted from the\n** original CREATE TABLE statement if the expression is a column. The\n** declaration type for a ROWID field is INTEGER. Exactly when an expression\n** is considered a column can be complex in the presence of subqueries. The\n** result-set expression in all of the following SELECT statements is \n** considered a column by this function.\n**\n**   SELECT col FROM tbl;\n**   SELECT (SELECT col FROM tbl;\n**   SELECT (SELECT col FROM tbl);\n**   SELECT abc FROM (SELECT col AS abc FROM tbl);\n** \n** The declaration type for any expression other than a column is NULL.\n**\n** This routine has either 3 or 6 parameters depending on whether or not\n** the SQLITE_ENABLE_COLUMN_METADATA compile-time option is used.\n*/\n#ifdef SQLITE_ENABLE_COLUMN_METADATA\n# define columnType(A,B,C,D,E) columnTypeImpl(A,B,C,D,E)\n#else /* if !defined(SQLITE_ENABLE_COLUMN_METADATA) */\n# define columnType(A,B,C,D,E) columnTypeImpl(A,B)\n#endif\nstatic const char *columnTypeImpl(\n  NameContext *pNC, \n#ifndef SQLITE_ENABLE_COLUMN_METADATA\n  Expr *pExpr\n#else\n  Expr *pExpr,\n  const char **pzOrigDb,\n  const char **pzOrigTab,\n  const char **pzOrigCol\n#endif\n){\n  char const *zType = 0;\n  int j;\n#ifdef SQLITE_ENABLE_COLUMN_METADATA\n  char const *zOrigDb = 0;\n  char const *zOrigTab = 0;\n  char const *zOrigCol = 0;\n#endif\n\n  assert( pExpr!=0 );\n  assert( pNC->pSrcList!=0 );\n  assert( pExpr->op!=TK_AGG_COLUMN );  /* This routine runes before aggregates\n                                       ** are processed */\n  switch( pExpr->op ){\n    case TK_COLUMN: {\n      /* The expression is a column. Locate the table the column is being\n      ** extracted from in NameContext.pSrcList. This table may be real\n      ** database table or a subquery.\n      */\n      Table *pTab = 0;            /* Table structure column is extracted from */\n      Select *pS = 0;             /* Select the column is extracted from */\n      int iCol = pExpr->iColumn;  /* Index of column in pTab */\n      while( pNC && !pTab ){\n        SrcList *pTabList = pNC->pSrcList;\n        for(j=0;j<pTabList->nSrc && pTabList->a[j].iCursor!=pExpr->iTable;j++);\n        if( j<pTabList->nSrc ){\n          pTab = pTabList->a[j].pTab;\n          pS = pTabList->a[j].pSelect;\n        }else{\n          pNC = pNC->pNext;\n        }\n      }\n\n      if( pTab==0 ){\n        /* At one time, code such as \"SELECT new.x\" within a trigger would\n        ** cause this condition to run.  Since then, we have restructured how\n        ** trigger code is generated and so this condition is no longer \n        ** possible. However, it can still be true for statements like\n        ** the following:\n        **\n        **   CREATE TABLE t1(col INTEGER);\n        **   SELECT (SELECT t1.col) FROM FROM t1;\n        **\n        ** when columnType() is called on the expression \"t1.col\" in the \n        ** sub-select. In this case, set the column type to NULL, even\n        ** though it should really be \"INTEGER\".\n        **\n        ** This is not a problem, as the column type of \"t1.col\" is never\n        ** used. When columnType() is called on the expression \n        ** \"(SELECT t1.col)\", the correct type is returned (see the TK_SELECT\n        ** branch below.  */\n        break;\n      }\n\n      assert( pTab && pExpr->y.pTab==pTab );\n      if( pS ){\n        /* The \"table\" is actually a sub-select or a view in the FROM clause\n        ** of the SELECT statement. Return the declaration type and origin\n        ** data for the result-set column of the sub-select.\n        */\n        if( iCol>=0 && iCol<pS->pEList->nExpr ){\n          /* If iCol is less than zero, then the expression requests the\n          ** rowid of the sub-select or view. This expression is legal (see \n          ** test case misc2.2.2) - it always evaluates to NULL.\n          */\n          NameContext sNC;\n          Expr *p = pS->pEList->a[iCol].pExpr;\n          sNC.pSrcList = pS->pSrc;\n          sNC.pNext = pNC;\n          sNC.pParse = pNC->pParse;\n          zType = columnType(&sNC, p,&zOrigDb,&zOrigTab,&zOrigCol); \n        }\n      }else{\n        /* A real table or a CTE table */\n        assert( !pS );\n#ifdef SQLITE_ENABLE_COLUMN_METADATA\n        if( iCol<0 ) iCol = pTab->iPKey;\n        assert( iCol==XN_ROWID || (iCol>=0 && iCol<pTab->nCol) );\n        if( iCol<0 ){\n          zType = \"INTEGER\";\n          zOrigCol = \"rowid\";\n        }else{\n          zOrigCol = pTab->aCol[iCol].zName;\n          zType = sqlite3ColumnType(&pTab->aCol[iCol],0);\n        }\n        zOrigTab = pTab->zName;\n        if( pNC->pParse && pTab->pSchema ){\n          int iDb = sqlite3SchemaToIndex(pNC->pParse->db, pTab->pSchema);\n          zOrigDb = pNC->pParse->db->aDb[iDb].zDbSName;\n        }\n#else\n        assert( iCol==XN_ROWID || (iCol>=0 && iCol<pTab->nCol) );\n        if( iCol<0 ){\n          zType = \"INTEGER\";\n        }else{\n          zType = sqlite3ColumnType(&pTab->aCol[iCol],0);\n        }\n#endif\n      }\n      break;\n    }\n#ifndef SQLITE_OMIT_SUBQUERY\n    case TK_SELECT: {\n      /* The expression is a sub-select. Return the declaration type and\n      ** origin info for the single column in the result set of the SELECT\n      ** statement.\n      */\n      NameContext sNC;\n      Select *pS = pExpr->x.pSelect;\n      Expr *p = pS->pEList->a[0].pExpr;\n      assert( ExprHasProperty(pExpr, EP_xIsSelect) );\n      sNC.pSrcList = pS->pSrc;\n      sNC.pNext = pNC;\n      sNC.pParse = pNC->pParse;\n      zType = columnType(&sNC, p, &zOrigDb, &zOrigTab, &zOrigCol); \n      break;\n    }\n#endif\n  }\n\n#ifdef SQLITE_ENABLE_COLUMN_METADATA  \n  if( pzOrigDb ){\n    assert( pzOrigTab && pzOrigCol );\n    *pzOrigDb = zOrigDb;\n    *pzOrigTab = zOrigTab;\n    *pzOrigCol = zOrigCol;\n  }\n#endif\n  return zType;\n}\n\n/*\n** Generate code that will tell the VDBE the declaration types of columns\n** in the result set.\n*/\nstatic void generateColumnTypes(\n  Parse *pParse,      /* Parser context */\n  SrcList *pTabList,  /* List of tables */\n  ExprList *pEList    /* Expressions defining the result set */\n){\n#ifndef SQLITE_OMIT_DECLTYPE\n  Vdbe *v = pParse->pVdbe;\n  int i;\n  NameContext sNC;\n  sNC.pSrcList = pTabList;\n  sNC.pParse = pParse;\n  sNC.pNext = 0;\n  for(i=0; i<pEList->nExpr; i++){\n    Expr *p = pEList->a[i].pExpr;\n    const char *zType;\n#ifdef SQLITE_ENABLE_COLUMN_METADATA\n    const char *zOrigDb = 0;\n    const char *zOrigTab = 0;\n    const char *zOrigCol = 0;\n    zType = columnType(&sNC, p, &zOrigDb, &zOrigTab, &zOrigCol);\n\n    /* The vdbe must make its own copy of the column-type and other \n    ** column specific strings, in case the schema is reset before this\n    ** virtual machine is deleted.\n    */\n    sqlite3VdbeSetColName(v, i, COLNAME_DATABASE, zOrigDb, SQLITE_TRANSIENT);\n    sqlite3VdbeSetColName(v, i, COLNAME_TABLE, zOrigTab, SQLITE_TRANSIENT);\n    sqlite3VdbeSetColName(v, i, COLNAME_COLUMN, zOrigCol, SQLITE_TRANSIENT);\n#else\n    zType = columnType(&sNC, p, 0, 0, 0);\n#endif\n    sqlite3VdbeSetColName(v, i, COLNAME_DECLTYPE, zType, SQLITE_TRANSIENT);\n  }\n#endif /* !defined(SQLITE_OMIT_DECLTYPE) */\n}\n\n\n/*\n** Compute the column names for a SELECT statement.\n**\n** The only guarantee that SQLite makes about column names is that if the\n** column has an AS clause assigning it a name, that will be the name used.\n** That is the only documented guarantee.  However, countless applications\n** developed over the years have made baseless assumptions about column names\n** and will break if those assumptions changes.  Hence, use extreme caution\n** when modifying this routine to avoid breaking legacy.\n**\n** See Also: sqlite3ColumnsFromExprList()\n**\n** The PRAGMA short_column_names and PRAGMA full_column_names settings are\n** deprecated.  The default setting is short=ON, full=OFF.  99.9% of all\n** applications should operate this way.  Nevertheless, we need to support the\n** other modes for legacy:\n**\n**    short=OFF, full=OFF:      Column name is the text of the expression has it\n**                              originally appears in the SELECT statement.  In\n**                              other words, the zSpan of the result expression.\n**\n**    short=ON, full=OFF:       (This is the default setting).  If the result\n**                              refers directly to a table column, then the\n**                              result column name is just the table column\n**                              name: COLUMN.  Otherwise use zSpan.\n**\n**    full=ON, short=ANY:       If the result refers directly to a table column,\n**                              then the result column name with the table name\n**                              prefix, ex: TABLE.COLUMN.  Otherwise use zSpan.\n*/\nstatic void generateColumnNames(\n  Parse *pParse,      /* Parser context */\n  Select *pSelect     /* Generate column names for this SELECT statement */\n){\n  Vdbe *v = pParse->pVdbe;\n  int i;\n  Table *pTab;\n  SrcList *pTabList;\n  ExprList *pEList;\n  sqlite3 *db = pParse->db;\n  int fullName;    /* TABLE.COLUMN if no AS clause and is a direct table ref */\n  int srcName;     /* COLUMN or TABLE.COLUMN if no AS clause and is direct */\n\n#ifndef SQLITE_OMIT_EXPLAIN\n  /* If this is an EXPLAIN, skip this step */\n  if( pParse->explain ){\n    return;\n  }\n#endif\n\n  if( pParse->colNamesSet ) return;\n  /* Column names are determined by the left-most term of a compound select */\n  while( pSelect->pPrior ) pSelect = pSelect->pPrior;\n  SELECTTRACE(1,pParse,pSelect,(\"generating column names\\n\"));\n  pTabList = pSelect->pSrc;\n  pEList = pSelect->pEList;\n  assert( v!=0 );\n  assert( pTabList!=0 );\n  pParse->colNamesSet = 1;\n  fullName = (db->flags & SQLITE_FullColNames)!=0;\n  srcName = (db->flags & SQLITE_ShortColNames)!=0 || fullName;\n  sqlite3VdbeSetNumCols(v, pEList->nExpr);\n  for(i=0; i<pEList->nExpr; i++){\n    Expr *p = pEList->a[i].pExpr;\n\n    assert( p!=0 );\n    assert( p->op!=TK_AGG_COLUMN );  /* Agg processing has not run yet */\n    assert( p->op!=TK_COLUMN || p->y.pTab!=0 ); /* Covering idx not yet coded */\n    if( pEList->a[i].zName ){\n      /* An AS clause always takes first priority */\n      char *zName = pEList->a[i].zName;\n      sqlite3VdbeSetColName(v, i, COLNAME_NAME, zName, SQLITE_TRANSIENT);\n    }else if( srcName && p->op==TK_COLUMN ){\n      char *zCol;\n      int iCol = p->iColumn;\n      pTab = p->y.pTab;\n      assert( pTab!=0 );\n      if( iCol<0 ) iCol = pTab->iPKey;\n      assert( iCol==-1 || (iCol>=0 && iCol<pTab->nCol) );\n      if( iCol<0 ){\n        zCol = \"rowid\";\n      }else{\n        zCol = pTab->aCol[iCol].zName;\n      }\n      if( fullName ){\n        char *zName = 0;\n        zName = sqlite3MPrintf(db, \"%s.%s\", pTab->zName, zCol);\n        sqlite3VdbeSetColName(v, i, COLNAME_NAME, zName, SQLITE_DYNAMIC);\n      }else{\n        sqlite3VdbeSetColName(v, i, COLNAME_NAME, zCol, SQLITE_TRANSIENT);\n      }\n    }else{\n      const char *z = pEList->a[i].zSpan;\n      z = z==0 ? sqlite3MPrintf(db, \"column%d\", i+1) : sqlite3DbStrDup(db, z);\n      sqlite3VdbeSetColName(v, i, COLNAME_NAME, z, SQLITE_DYNAMIC);\n    }\n  }\n  generateColumnTypes(pParse, pTabList, pEList);\n}\n\n/*\n** Given an expression list (which is really the list of expressions\n** that form the result set of a SELECT statement) compute appropriate\n** column names for a table that would hold the expression list.\n**\n** All column names will be unique.\n**\n** Only the column names are computed.  Column.zType, Column.zColl,\n** and other fields of Column are zeroed.\n**\n** Return SQLITE_OK on success.  If a memory allocation error occurs,\n** store NULL in *paCol and 0 in *pnCol and return SQLITE_NOMEM.\n**\n** The only guarantee that SQLite makes about column names is that if the\n** column has an AS clause assigning it a name, that will be the name used.\n** That is the only documented guarantee.  However, countless applications\n** developed over the years have made baseless assumptions about column names\n** and will break if those assumptions changes.  Hence, use extreme caution\n** when modifying this routine to avoid breaking legacy.\n**\n** See Also: generateColumnNames()\n*/\nSQLITE_PRIVATE int sqlite3ColumnsFromExprList(\n  Parse *pParse,          /* Parsing context */\n  ExprList *pEList,       /* Expr list from which to derive column names */\n  i16 *pnCol,             /* Write the number of columns here */\n  Column **paCol          /* Write the new column list here */\n){\n  sqlite3 *db = pParse->db;   /* Database connection */\n  int i, j;                   /* Loop counters */\n  u32 cnt;                    /* Index added to make the name unique */\n  Column *aCol, *pCol;        /* For looping over result columns */\n  int nCol;                   /* Number of columns in the result set */\n  char *zName;                /* Column name */\n  int nName;                  /* Size of name in zName[] */\n  Hash ht;                    /* Hash table of column names */\n\n  sqlite3HashInit(&ht);\n  if( pEList ){\n    nCol = pEList->nExpr;\n    aCol = sqlite3DbMallocZero(db, sizeof(aCol[0])*nCol);\n    testcase( aCol==0 );\n    if( nCol>32767 ) nCol = 32767;\n  }else{\n    nCol = 0;\n    aCol = 0;\n  }\n  assert( nCol==(i16)nCol );\n  *pnCol = nCol;\n  *paCol = aCol;\n\n  for(i=0, pCol=aCol; i<nCol && !db->mallocFailed; i++, pCol++){\n    /* Get an appropriate name for the column\n    */\n    if( (zName = pEList->a[i].zName)!=0 ){\n      /* If the column contains an \"AS <name>\" phrase, use <name> as the name */\n    }else{\n      Expr *pColExpr = sqlite3ExprSkipCollate(pEList->a[i].pExpr);\n      while( pColExpr->op==TK_DOT ){\n        pColExpr = pColExpr->pRight;\n        assert( pColExpr!=0 );\n      }\n      assert( pColExpr->op!=TK_AGG_COLUMN );\n      if( pColExpr->op==TK_COLUMN ){\n        /* For columns use the column name name */\n        int iCol = pColExpr->iColumn;\n        Table *pTab = pColExpr->y.pTab;\n        assert( pTab!=0 );\n        if( iCol<0 ) iCol = pTab->iPKey;\n        zName = iCol>=0 ? pTab->aCol[iCol].zName : \"rowid\";\n      }else if( pColExpr->op==TK_ID ){\n        assert( !ExprHasProperty(pColExpr, EP_IntValue) );\n        zName = pColExpr->u.zToken;\n      }else{\n        /* Use the original text of the column expression as its name */\n        zName = pEList->a[i].zSpan;\n      }\n    }\n    if( zName ){\n      zName = sqlite3DbStrDup(db, zName);\n    }else{\n      zName = sqlite3MPrintf(db,\"column%d\",i+1);\n    }\n\n    /* Make sure the column name is unique.  If the name is not unique,\n    ** append an integer to the name so that it becomes unique.\n    */\n    cnt = 0;\n    while( zName && sqlite3HashFind(&ht, zName)!=0 ){\n      nName = sqlite3Strlen30(zName);\n      if( nName>0 ){\n        for(j=nName-1; j>0 && sqlite3Isdigit(zName[j]); j--){}\n        if( zName[j]==':' ) nName = j;\n      }\n      zName = sqlite3MPrintf(db, \"%.*z:%u\", nName, zName, ++cnt);\n      if( cnt>3 ) sqlite3_randomness(sizeof(cnt), &cnt);\n    }\n    pCol->zName = zName;\n    sqlite3ColumnPropertiesFromName(0, pCol);\n    if( zName && sqlite3HashInsert(&ht, zName, pCol)==pCol ){\n      sqlite3OomFault(db);\n    }\n  }\n  sqlite3HashClear(&ht);\n  if( db->mallocFailed ){\n    for(j=0; j<i; j++){\n      sqlite3DbFree(db, aCol[j].zName);\n    }\n    sqlite3DbFree(db, aCol);\n    *paCol = 0;\n    *pnCol = 0;\n    return SQLITE_NOMEM_BKPT;\n  }\n  return SQLITE_OK;\n}\n\n/*\n** Add type and collation information to a column list based on\n** a SELECT statement.\n** \n** The column list presumably came from selectColumnNamesFromExprList().\n** The column list has only names, not types or collations.  This\n** routine goes through and adds the types and collations.\n**\n** This routine requires that all identifiers in the SELECT\n** statement be resolved.\n*/\nSQLITE_PRIVATE void sqlite3SelectAddColumnTypeAndCollation(\n  Parse *pParse,        /* Parsing contexts */\n  Table *pTab,          /* Add column type information to this table */\n  Select *pSelect       /* SELECT used to determine types and collations */\n){\n  sqlite3 *db = pParse->db;\n  NameContext sNC;\n  Column *pCol;\n  CollSeq *pColl;\n  int i;\n  Expr *p;\n  struct ExprList_item *a;\n\n  assert( pSelect!=0 );\n  assert( (pSelect->selFlags & SF_Resolved)!=0 );\n  assert( pTab->nCol==pSelect->pEList->nExpr || db->mallocFailed );\n  if( db->mallocFailed ) return;\n  memset(&sNC, 0, sizeof(sNC));\n  sNC.pSrcList = pSelect->pSrc;\n  a = pSelect->pEList->a;\n  for(i=0, pCol=pTab->aCol; i<pTab->nCol; i++, pCol++){\n    const char *zType;\n    int n, m;\n    p = a[i].pExpr;\n    zType = columnType(&sNC, p, 0, 0, 0);\n    /* pCol->szEst = ... // Column size est for SELECT tables never used */\n    pCol->affinity = sqlite3ExprAffinity(p);\n    if( zType ){\n      m = sqlite3Strlen30(zType);\n      n = sqlite3Strlen30(pCol->zName);\n      pCol->zName = sqlite3DbReallocOrFree(db, pCol->zName, n+m+2);\n      if( pCol->zName ){\n        memcpy(&pCol->zName[n+1], zType, m+1);\n        pCol->colFlags |= COLFLAG_HASTYPE;\n      }\n    }\n    if( pCol->affinity==0 ) pCol->affinity = SQLITE_AFF_BLOB;\n    pColl = sqlite3ExprCollSeq(pParse, p);\n    if( pColl && pCol->zColl==0 ){\n      pCol->zColl = sqlite3DbStrDup(db, pColl->zName);\n    }\n  }\n  pTab->szTabRow = 1; /* Any non-zero value works */\n}\n\n/*\n** Given a SELECT statement, generate a Table structure that describes\n** the result set of that SELECT.\n*/\nSQLITE_PRIVATE Table *sqlite3ResultSetOfSelect(Parse *pParse, Select *pSelect){\n  Table *pTab;\n  sqlite3 *db = pParse->db;\n  u64 savedFlags;\n\n  savedFlags = db->flags;\n  db->flags &= ~(u64)SQLITE_FullColNames;\n  db->flags |= SQLITE_ShortColNames;\n  sqlite3SelectPrep(pParse, pSelect, 0);\n  db->flags = savedFlags;\n  if( pParse->nErr ) return 0;\n  while( pSelect->pPrior ) pSelect = pSelect->pPrior;\n  pTab = sqlite3DbMallocZero(db, sizeof(Table) );\n  if( pTab==0 ){\n    return 0;\n  }\n  /* The sqlite3ResultSetOfSelect() is only used n contexts where lookaside\n  ** is disabled */\n  assert( db->lookaside.bDisable );\n  pTab->nTabRef = 1;\n  pTab->zName = 0;\n  pTab->nRowLogEst = 200; assert( 200==sqlite3LogEst(1048576) );\n  sqlite3ColumnsFromExprList(pParse, pSelect->pEList, &pTab->nCol, &pTab->aCol);\n  sqlite3SelectAddColumnTypeAndCollation(pParse, pTab, pSelect);\n  pTab->iPKey = -1;\n  if( db->mallocFailed ){\n    sqlite3DeleteTable(db, pTab);\n    return 0;\n  }\n  return pTab;\n}\n\n/*\n** Get a VDBE for the given parser context.  Create a new one if necessary.\n** If an error occurs, return NULL and leave a message in pParse.\n*/\nSQLITE_PRIVATE Vdbe *sqlite3GetVdbe(Parse *pParse){\n  if( pParse->pVdbe ){\n    return pParse->pVdbe;\n  }\n  if( pParse->pToplevel==0\n   && OptimizationEnabled(pParse->db,SQLITE_FactorOutConst)\n  ){\n    pParse->okConstFactor = 1;\n  }\n  return sqlite3VdbeCreate(pParse);\n}\n\n\n/*\n** Compute the iLimit and iOffset fields of the SELECT based on the\n** pLimit expressions.  pLimit->pLeft and pLimit->pRight hold the expressions\n** that appear in the original SQL statement after the LIMIT and OFFSET\n** keywords.  Or NULL if those keywords are omitted. iLimit and iOffset \n** are the integer memory register numbers for counters used to compute \n** the limit and offset.  If there is no limit and/or offset, then \n** iLimit and iOffset are negative.\n**\n** This routine changes the values of iLimit and iOffset only if\n** a limit or offset is defined by pLimit->pLeft and pLimit->pRight.  iLimit\n** and iOffset should have been preset to appropriate default values (zero)\n** prior to calling this routine.\n**\n** The iOffset register (if it exists) is initialized to the value\n** of the OFFSET.  The iLimit register is initialized to LIMIT.  Register\n** iOffset+1 is initialized to LIMIT+OFFSET.\n**\n** Only if pLimit->pLeft!=0 do the limit registers get\n** redefined.  The UNION ALL operator uses this property to force\n** the reuse of the same limit and offset registers across multiple\n** SELECT statements.\n*/\nstatic void computeLimitRegisters(Parse *pParse, Select *p, int iBreak){\n  Vdbe *v = 0;\n  int iLimit = 0;\n  int iOffset;\n  int n;\n  Expr *pLimit = p->pLimit;\n\n  if( p->iLimit ) return;\n\n  /* \n  ** \"LIMIT -1\" always shows all rows.  There is some\n  ** controversy about what the correct behavior should be.\n  ** The current implementation interprets \"LIMIT 0\" to mean\n  ** no rows.\n  */\n  if( pLimit ){\n    assert( pLimit->op==TK_LIMIT );\n    assert( pLimit->pLeft!=0 );\n    p->iLimit = iLimit = ++pParse->nMem;\n    v = sqlite3GetVdbe(pParse);\n    assert( v!=0 );\n    if( sqlite3ExprIsInteger(pLimit->pLeft, &n) ){\n      sqlite3VdbeAddOp2(v, OP_Integer, n, iLimit);\n      VdbeComment((v, \"LIMIT counter\"));\n      if( n==0 ){\n        sqlite3VdbeGoto(v, iBreak);\n      }else if( n>=0 && p->nSelectRow>sqlite3LogEst((u64)n) ){\n        p->nSelectRow = sqlite3LogEst((u64)n);\n        p->selFlags |= SF_FixedLimit;\n      }\n    }else{\n      sqlite3ExprCode(pParse, pLimit->pLeft, iLimit);\n      sqlite3VdbeAddOp1(v, OP_MustBeInt, iLimit); VdbeCoverage(v);\n      VdbeComment((v, \"LIMIT counter\"));\n      sqlite3VdbeAddOp2(v, OP_IfNot, iLimit, iBreak); VdbeCoverage(v);\n    }\n    if( pLimit->pRight ){\n      p->iOffset = iOffset = ++pParse->nMem;\n      pParse->nMem++;   /* Allocate an extra register for limit+offset */\n      sqlite3ExprCode(pParse, pLimit->pRight, iOffset);\n      sqlite3VdbeAddOp1(v, OP_MustBeInt, iOffset); VdbeCoverage(v);\n      VdbeComment((v, \"OFFSET counter\"));\n      sqlite3VdbeAddOp3(v, OP_OffsetLimit, iLimit, iOffset+1, iOffset);\n      VdbeComment((v, \"LIMIT+OFFSET\"));\n    }\n  }\n}\n\n#ifndef SQLITE_OMIT_COMPOUND_SELECT\n/*\n** Return the appropriate collating sequence for the iCol-th column of\n** the result set for the compound-select statement \"p\".  Return NULL if\n** the column has no default collating sequence.\n**\n** The collating sequence for the compound select is taken from the\n** left-most term of the select that has a collating sequence.\n*/\nstatic CollSeq *multiSelectCollSeq(Parse *pParse, Select *p, int iCol){\n  CollSeq *pRet;\n  if( p->pPrior ){\n    pRet = multiSelectCollSeq(pParse, p->pPrior, iCol);\n  }else{\n    pRet = 0;\n  }\n  assert( iCol>=0 );\n  /* iCol must be less than p->pEList->nExpr.  Otherwise an error would\n  ** have been thrown during name resolution and we would not have gotten\n  ** this far */\n  if( pRet==0 && ALWAYS(iCol<p->pEList->nExpr) ){\n    pRet = sqlite3ExprCollSeq(pParse, p->pEList->a[iCol].pExpr);\n  }\n  return pRet;\n}\n\n/*\n** The select statement passed as the second parameter is a compound SELECT\n** with an ORDER BY clause. This function allocates and returns a KeyInfo\n** structure suitable for implementing the ORDER BY.\n**\n** Space to hold the KeyInfo structure is obtained from malloc. The calling\n** function is responsible for ensuring that this structure is eventually\n** freed.\n*/\nstatic KeyInfo *multiSelectOrderByKeyInfo(Parse *pParse, Select *p, int nExtra){\n  ExprList *pOrderBy = p->pOrderBy;\n  int nOrderBy = p->pOrderBy->nExpr;\n  sqlite3 *db = pParse->db;\n  KeyInfo *pRet = sqlite3KeyInfoAlloc(db, nOrderBy+nExtra, 1);\n  if( pRet ){\n    int i;\n    for(i=0; i<nOrderBy; i++){\n      struct ExprList_item *pItem = &pOrderBy->a[i];\n      Expr *pTerm = pItem->pExpr;\n      CollSeq *pColl;\n\n      if( pTerm->flags & EP_Collate ){\n        pColl = sqlite3ExprCollSeq(pParse, pTerm);\n      }else{\n        pColl = multiSelectCollSeq(pParse, p, pItem->u.x.iOrderByCol-1);\n        if( pColl==0 ) pColl = db->pDfltColl;\n        pOrderBy->a[i].pExpr =\n          sqlite3ExprAddCollateString(pParse, pTerm, pColl->zName);\n      }\n      assert( sqlite3KeyInfoIsWriteable(pRet) );\n      pRet->aColl[i] = pColl;\n      pRet->aSortOrder[i] = pOrderBy->a[i].sortOrder;\n    }\n  }\n\n  return pRet;\n}\n\n#ifndef SQLITE_OMIT_CTE\n/*\n** This routine generates VDBE code to compute the content of a WITH RECURSIVE\n** query of the form:\n**\n**   <recursive-table> AS (<setup-query> UNION [ALL] <recursive-query>)\n**                         \\___________/             \\_______________/\n**                           p->pPrior                      p\n**\n**\n** There is exactly one reference to the recursive-table in the FROM clause\n** of recursive-query, marked with the SrcList->a[].fg.isRecursive flag.\n**\n** The setup-query runs once to generate an initial set of rows that go\n** into a Queue table.  Rows are extracted from the Queue table one by\n** one.  Each row extracted from Queue is output to pDest.  Then the single\n** extracted row (now in the iCurrent table) becomes the content of the\n** recursive-table for a recursive-query run.  The output of the recursive-query\n** is added back into the Queue table.  Then another row is extracted from Queue\n** and the iteration continues until the Queue table is empty.\n**\n** If the compound query operator is UNION then no duplicate rows are ever\n** inserted into the Queue table.  The iDistinct table keeps a copy of all rows\n** that have ever been inserted into Queue and causes duplicates to be\n** discarded.  If the operator is UNION ALL, then duplicates are allowed.\n** \n** If the query has an ORDER BY, then entries in the Queue table are kept in\n** ORDER BY order and the first entry is extracted for each cycle.  Without\n** an ORDER BY, the Queue table is just a FIFO.\n**\n** If a LIMIT clause is provided, then the iteration stops after LIMIT rows\n** have been output to pDest.  A LIMIT of zero means to output no rows and a\n** negative LIMIT means to output all rows.  If there is also an OFFSET clause\n** with a positive value, then the first OFFSET outputs are discarded rather\n** than being sent to pDest.  The LIMIT count does not begin until after OFFSET\n** rows have been skipped.\n*/\nstatic void generateWithRecursiveQuery(\n  Parse *pParse,        /* Parsing context */\n  Select *p,            /* The recursive SELECT to be coded */\n  SelectDest *pDest     /* What to do with query results */\n){\n  SrcList *pSrc = p->pSrc;      /* The FROM clause of the recursive query */\n  int nCol = p->pEList->nExpr;  /* Number of columns in the recursive table */\n  Vdbe *v = pParse->pVdbe;      /* The prepared statement under construction */\n  Select *pSetup = p->pPrior;   /* The setup query */\n  int addrTop;                  /* Top of the loop */\n  int addrCont, addrBreak;      /* CONTINUE and BREAK addresses */\n  int iCurrent = 0;             /* The Current table */\n  int regCurrent;               /* Register holding Current table */\n  int iQueue;                   /* The Queue table */\n  int iDistinct = 0;            /* To ensure unique results if UNION */\n  int eDest = SRT_Fifo;         /* How to write to Queue */\n  SelectDest destQueue;         /* SelectDest targetting the Queue table */\n  int i;                        /* Loop counter */\n  int rc;                       /* Result code */\n  ExprList *pOrderBy;           /* The ORDER BY clause */\n  Expr *pLimit;                 /* Saved LIMIT and OFFSET */\n  int regLimit, regOffset;      /* Registers used by LIMIT and OFFSET */\n\n#ifndef SQLITE_OMIT_WINDOWFUNC\n  if( p->pWin ){\n    sqlite3ErrorMsg(pParse, \"cannot use window functions in recursive queries\");\n    return;\n  }\n#endif\n\n  /* Obtain authorization to do a recursive query */\n  if( sqlite3AuthCheck(pParse, SQLITE_RECURSIVE, 0, 0, 0) ) return;\n\n  /* Process the LIMIT and OFFSET clauses, if they exist */\n  addrBreak = sqlite3VdbeMakeLabel(pParse);\n  p->nSelectRow = 320;  /* 4 billion rows */\n  computeLimitRegisters(pParse, p, addrBreak);\n  pLimit = p->pLimit;\n  regLimit = p->iLimit;\n  regOffset = p->iOffset;\n  p->pLimit = 0;\n  p->iLimit = p->iOffset = 0;\n  pOrderBy = p->pOrderBy;\n\n  /* Locate the cursor number of the Current table */\n  for(i=0; ALWAYS(i<pSrc->nSrc); i++){\n    if( pSrc->a[i].fg.isRecursive ){\n      iCurrent = pSrc->a[i].iCursor;\n      break;\n    }\n  }\n\n  /* Allocate cursors numbers for Queue and Distinct.  The cursor number for\n  ** the Distinct table must be exactly one greater than Queue in order\n  ** for the SRT_DistFifo and SRT_DistQueue destinations to work. */\n  iQueue = pParse->nTab++;\n  if( p->op==TK_UNION ){\n    eDest = pOrderBy ? SRT_DistQueue : SRT_DistFifo;\n    iDistinct = pParse->nTab++;\n  }else{\n    eDest = pOrderBy ? SRT_Queue : SRT_Fifo;\n  }\n  sqlite3SelectDestInit(&destQueue, eDest, iQueue);\n\n  /* Allocate cursors for Current, Queue, and Distinct. */\n  regCurrent = ++pParse->nMem;\n  sqlite3VdbeAddOp3(v, OP_OpenPseudo, iCurrent, regCurrent, nCol);\n  if( pOrderBy ){\n    KeyInfo *pKeyInfo = multiSelectOrderByKeyInfo(pParse, p, 1);\n    sqlite3VdbeAddOp4(v, OP_OpenEphemeral, iQueue, pOrderBy->nExpr+2, 0,\n                      (char*)pKeyInfo, P4_KEYINFO);\n    destQueue.pOrderBy = pOrderBy;\n  }else{\n    sqlite3VdbeAddOp2(v, OP_OpenEphemeral, iQueue, nCol);\n  }\n  VdbeComment((v, \"Queue table\"));\n  if( iDistinct ){\n    p->addrOpenEphm[0] = sqlite3VdbeAddOp2(v, OP_OpenEphemeral, iDistinct, 0);\n    p->selFlags |= SF_UsesEphemeral;\n  }\n\n  /* Detach the ORDER BY clause from the compound SELECT */\n  p->pOrderBy = 0;\n\n  /* Store the results of the setup-query in Queue. */\n  pSetup->pNext = 0;\n  ExplainQueryPlan((pParse, 1, \"SETUP\"));\n  rc = sqlite3Select(pParse, pSetup, &destQueue);\n  pSetup->pNext = p;\n  if( rc ) goto end_of_recursive_query;\n\n  /* Find the next row in the Queue and output that row */\n  addrTop = sqlite3VdbeAddOp2(v, OP_Rewind, iQueue, addrBreak); VdbeCoverage(v);\n\n  /* Transfer the next row in Queue over to Current */\n  sqlite3VdbeAddOp1(v, OP_NullRow, iCurrent); /* To reset column cache */\n  if( pOrderBy ){\n    sqlite3VdbeAddOp3(v, OP_Column, iQueue, pOrderBy->nExpr+1, regCurrent);\n  }else{\n    sqlite3VdbeAddOp2(v, OP_RowData, iQueue, regCurrent);\n  }\n  sqlite3VdbeAddOp1(v, OP_Delete, iQueue);\n\n  /* Output the single row in Current */\n  addrCont = sqlite3VdbeMakeLabel(pParse);\n  codeOffset(v, regOffset, addrCont);\n  selectInnerLoop(pParse, p, iCurrent,\n      0, 0, pDest, addrCont, addrBreak);\n  if( regLimit ){\n    sqlite3VdbeAddOp2(v, OP_DecrJumpZero, regLimit, addrBreak);\n    VdbeCoverage(v);\n  }\n  sqlite3VdbeResolveLabel(v, addrCont);\n\n  /* Execute the recursive SELECT taking the single row in Current as\n  ** the value for the recursive-table. Store the results in the Queue.\n  */\n  if( p->selFlags & SF_Aggregate ){\n    sqlite3ErrorMsg(pParse, \"recursive aggregate queries not supported\");\n  }else{\n    p->pPrior = 0;\n    ExplainQueryPlan((pParse, 1, \"RECURSIVE STEP\"));\n    sqlite3Select(pParse, p, &destQueue);\n    assert( p->pPrior==0 );\n    p->pPrior = pSetup;\n  }\n\n  /* Keep running the loop until the Queue is empty */\n  sqlite3VdbeGoto(v, addrTop);\n  sqlite3VdbeResolveLabel(v, addrBreak);\n\nend_of_recursive_query:\n  sqlite3ExprListDelete(pParse->db, p->pOrderBy);\n  p->pOrderBy = pOrderBy;\n  p->pLimit = pLimit;\n  return;\n}\n#endif /* SQLITE_OMIT_CTE */\n\n/* Forward references */\nstatic int multiSelectOrderBy(\n  Parse *pParse,        /* Parsing context */\n  Select *p,            /* The right-most of SELECTs to be coded */\n  SelectDest *pDest     /* What to do with query results */\n);\n\n/*\n** Handle the special case of a compound-select that originates from a\n** VALUES clause.  By handling this as a special case, we avoid deep\n** recursion, and thus do not need to enforce the SQLITE_LIMIT_COMPOUND_SELECT\n** on a VALUES clause.\n**\n** Because the Select object originates from a VALUES clause:\n**   (1) There is no LIMIT or OFFSET or else there is a LIMIT of exactly 1\n**   (2) All terms are UNION ALL\n**   (3) There is no ORDER BY clause\n**\n** The \"LIMIT of exactly 1\" case of condition (1) comes about when a VALUES\n** clause occurs within scalar expression (ex: \"SELECT (VALUES(1),(2),(3))\").\n** The sqlite3CodeSubselect will have added the LIMIT 1 clause in tht case.\n** Since the limit is exactly 1, we only need to evalutes the left-most VALUES.\n*/\nstatic int multiSelectValues(\n  Parse *pParse,        /* Parsing context */\n  Select *p,            /* The right-most of SELECTs to be coded */\n  SelectDest *pDest     /* What to do with query results */\n){\n  int nRow = 1;\n  int rc = 0;\n  int bShowAll = p->pLimit==0;\n  assert( p->selFlags & SF_MultiValue );\n  do{\n    assert( p->selFlags & SF_Values );\n    assert( p->op==TK_ALL || (p->op==TK_SELECT && p->pPrior==0) );\n    assert( p->pNext==0 || p->pEList->nExpr==p->pNext->pEList->nExpr );\n    if( p->pPrior==0 ) break;\n    assert( p->pPrior->pNext==p );\n    p = p->pPrior;\n    nRow += bShowAll;\n  }while(1);\n  ExplainQueryPlan((pParse, 0, \"SCAN %d CONSTANT ROW%s\", nRow,\n                    nRow==1 ? \"\" : \"S\"));\n  while( p ){\n    selectInnerLoop(pParse, p, -1, 0, 0, pDest, 1, 1);\n    if( !bShowAll ) break;\n    p->nSelectRow = nRow;\n    p = p->pNext;\n  }\n  return rc;\n}\n\n/*\n** This routine is called to process a compound query form from\n** two or more separate queries using UNION, UNION ALL, EXCEPT, or\n** INTERSECT\n**\n** \"p\" points to the right-most of the two queries.  the query on the\n** left is p->pPrior.  The left query could also be a compound query\n** in which case this routine will be called recursively. \n**\n** The results of the total query are to be written into a destination\n** of type eDest with parameter iParm.\n**\n** Example 1:  Consider a three-way compound SQL statement.\n**\n**     SELECT a FROM t1 UNION SELECT b FROM t2 UNION SELECT c FROM t3\n**\n** This statement is parsed up as follows:\n**\n**     SELECT c FROM t3\n**      |\n**      `----->  SELECT b FROM t2\n**                |\n**                `------>  SELECT a FROM t1\n**\n** The arrows in the diagram above represent the Select.pPrior pointer.\n** So if this routine is called with p equal to the t3 query, then\n** pPrior will be the t2 query.  p->op will be TK_UNION in this case.\n**\n** Notice that because of the way SQLite parses compound SELECTs, the\n** individual selects always group from left to right.\n*/\nstatic int multiSelect(\n  Parse *pParse,        /* Parsing context */\n  Select *p,            /* The right-most of SELECTs to be coded */\n  SelectDest *pDest     /* What to do with query results */\n){\n  int rc = SQLITE_OK;   /* Success code from a subroutine */\n  Select *pPrior;       /* Another SELECT immediately to our left */\n  Vdbe *v;              /* Generate code to this VDBE */\n  SelectDest dest;      /* Alternative data destination */\n  Select *pDelete = 0;  /* Chain of simple selects to delete */\n  sqlite3 *db;          /* Database connection */\n\n  /* Make sure there is no ORDER BY or LIMIT clause on prior SELECTs.  Only\n  ** the last (right-most) SELECT in the series may have an ORDER BY or LIMIT.\n  */\n  assert( p && p->pPrior );  /* Calling function guarantees this much */\n  assert( (p->selFlags & SF_Recursive)==0 || p->op==TK_ALL || p->op==TK_UNION );\n  db = pParse->db;\n  pPrior = p->pPrior;\n  dest = *pDest;\n  if( pPrior->pOrderBy || pPrior->pLimit ){\n    sqlite3ErrorMsg(pParse,\"%s clause should come after %s not before\",\n      pPrior->pOrderBy!=0 ? \"ORDER BY\" : \"LIMIT\", selectOpName(p->op));\n    rc = 1;\n    goto multi_select_end;\n  }\n\n  v = sqlite3GetVdbe(pParse);\n  assert( v!=0 );  /* The VDBE already created by calling function */\n\n  /* Create the destination temporary table if necessary\n  */\n  if( dest.eDest==SRT_EphemTab ){\n    assert( p->pEList );\n    sqlite3VdbeAddOp2(v, OP_OpenEphemeral, dest.iSDParm, p->pEList->nExpr);\n    dest.eDest = SRT_Table;\n  }\n\n  /* Special handling for a compound-select that originates as a VALUES clause.\n  */\n  if( p->selFlags & SF_MultiValue ){\n    rc = multiSelectValues(pParse, p, &dest);\n    goto multi_select_end;\n  }\n\n  /* Make sure all SELECTs in the statement have the same number of elements\n  ** in their result sets.\n  */\n  assert( p->pEList && pPrior->pEList );\n  assert( p->pEList->nExpr==pPrior->pEList->nExpr );\n\n#ifndef SQLITE_OMIT_CTE\n  if( p->selFlags & SF_Recursive ){\n    generateWithRecursiveQuery(pParse, p, &dest);\n  }else\n#endif\n\n  /* Compound SELECTs that have an ORDER BY clause are handled separately.\n  */\n  if( p->pOrderBy ){\n    return multiSelectOrderBy(pParse, p, pDest);\n  }else{\n\n#ifndef SQLITE_OMIT_EXPLAIN\n    if( pPrior->pPrior==0 ){\n      ExplainQueryPlan((pParse, 1, \"COMPOUND QUERY\"));\n      ExplainQueryPlan((pParse, 1, \"LEFT-MOST SUBQUERY\"));\n    }\n#endif\n\n    /* Generate code for the left and right SELECT statements.\n    */\n    switch( p->op ){\n      case TK_ALL: {\n        int addr = 0;\n        int nLimit;\n        assert( !pPrior->pLimit );\n        pPrior->iLimit = p->iLimit;\n        pPrior->iOffset = p->iOffset;\n        pPrior->pLimit = p->pLimit;\n        rc = sqlite3Select(pParse, pPrior, &dest);\n        p->pLimit = 0;\n        if( rc ){\n          goto multi_select_end;\n        }\n        p->pPrior = 0;\n        p->iLimit = pPrior->iLimit;\n        p->iOffset = pPrior->iOffset;\n        if( p->iLimit ){\n          addr = sqlite3VdbeAddOp1(v, OP_IfNot, p->iLimit); VdbeCoverage(v);\n          VdbeComment((v, \"Jump ahead if LIMIT reached\"));\n          if( p->iOffset ){\n            sqlite3VdbeAddOp3(v, OP_OffsetLimit,\n                              p->iLimit, p->iOffset+1, p->iOffset);\n          }\n        }\n        ExplainQueryPlan((pParse, 1, \"UNION ALL\"));\n        rc = sqlite3Select(pParse, p, &dest);\n        testcase( rc!=SQLITE_OK );\n        pDelete = p->pPrior;\n        p->pPrior = pPrior;\n        p->nSelectRow = sqlite3LogEstAdd(p->nSelectRow, pPrior->nSelectRow);\n        if( pPrior->pLimit\n         && sqlite3ExprIsInteger(pPrior->pLimit->pLeft, &nLimit)\n         && nLimit>0 && p->nSelectRow > sqlite3LogEst((u64)nLimit) \n        ){\n          p->nSelectRow = sqlite3LogEst((u64)nLimit);\n        }\n        if( addr ){\n          sqlite3VdbeJumpHere(v, addr);\n        }\n        break;\n      }\n      case TK_EXCEPT:\n      case TK_UNION: {\n        int unionTab;    /* Cursor number of the temp table holding result */\n        u8 op = 0;       /* One of the SRT_ operations to apply to self */\n        int priorOp;     /* The SRT_ operation to apply to prior selects */\n        Expr *pLimit;    /* Saved values of p->nLimit  */\n        int addr;\n        SelectDest uniondest;\n  \n        testcase( p->op==TK_EXCEPT );\n        testcase( p->op==TK_UNION );\n        priorOp = SRT_Union;\n        if( dest.eDest==priorOp ){\n          /* We can reuse a temporary table generated by a SELECT to our\n          ** right.\n          */\n          assert( p->pLimit==0 );      /* Not allowed on leftward elements */\n          unionTab = dest.iSDParm;\n        }else{\n          /* We will need to create our own temporary table to hold the\n          ** intermediate results.\n          */\n          unionTab = pParse->nTab++;\n          assert( p->pOrderBy==0 );\n          addr = sqlite3VdbeAddOp2(v, OP_OpenEphemeral, unionTab, 0);\n          assert( p->addrOpenEphm[0] == -1 );\n          p->addrOpenEphm[0] = addr;\n          findRightmost(p)->selFlags |= SF_UsesEphemeral;\n          assert( p->pEList );\n        }\n  \n        /* Code the SELECT statements to our left\n        */\n        assert( !pPrior->pOrderBy );\n        sqlite3SelectDestInit(&uniondest, priorOp, unionTab);\n        rc = sqlite3Select(pParse, pPrior, &uniondest);\n        if( rc ){\n          goto multi_select_end;\n        }\n  \n        /* Code the current SELECT statement\n        */\n        if( p->op==TK_EXCEPT ){\n          op = SRT_Except;\n        }else{\n          assert( p->op==TK_UNION );\n          op = SRT_Union;\n        }\n        p->pPrior = 0;\n        pLimit = p->pLimit;\n        p->pLimit = 0;\n        uniondest.eDest = op;\n        ExplainQueryPlan((pParse, 1, \"%s USING TEMP B-TREE\",\n                          selectOpName(p->op)));\n        rc = sqlite3Select(pParse, p, &uniondest);\n        testcase( rc!=SQLITE_OK );\n        /* Query flattening in sqlite3Select() might refill p->pOrderBy.\n        ** Be sure to delete p->pOrderBy, therefore, to avoid a memory leak. */\n        sqlite3ExprListDelete(db, p->pOrderBy);\n        pDelete = p->pPrior;\n        p->pPrior = pPrior;\n        p->pOrderBy = 0;\n        if( p->op==TK_UNION ){\n          p->nSelectRow = sqlite3LogEstAdd(p->nSelectRow, pPrior->nSelectRow);\n        }\n        sqlite3ExprDelete(db, p->pLimit);\n        p->pLimit = pLimit;\n        p->iLimit = 0;\n        p->iOffset = 0;\n  \n        /* Convert the data in the temporary table into whatever form\n        ** it is that we currently need.\n        */\n        assert( unionTab==dest.iSDParm || dest.eDest!=priorOp );\n        if( dest.eDest!=priorOp ){\n          int iCont, iBreak, iStart;\n          assert( p->pEList );\n          iBreak = sqlite3VdbeMakeLabel(pParse);\n          iCont = sqlite3VdbeMakeLabel(pParse);\n          computeLimitRegisters(pParse, p, iBreak);\n          sqlite3VdbeAddOp2(v, OP_Rewind, unionTab, iBreak); VdbeCoverage(v);\n          iStart = sqlite3VdbeCurrentAddr(v);\n          selectInnerLoop(pParse, p, unionTab,\n                          0, 0, &dest, iCont, iBreak);\n          sqlite3VdbeResolveLabel(v, iCont);\n          sqlite3VdbeAddOp2(v, OP_Next, unionTab, iStart); VdbeCoverage(v);\n          sqlite3VdbeResolveLabel(v, iBreak);\n          sqlite3VdbeAddOp2(v, OP_Close, unionTab, 0);\n        }\n        break;\n      }\n      default: assert( p->op==TK_INTERSECT ); {\n        int tab1, tab2;\n        int iCont, iBreak, iStart;\n        Expr *pLimit;\n        int addr;\n        SelectDest intersectdest;\n        int r1;\n  \n        /* INTERSECT is different from the others since it requires\n        ** two temporary tables.  Hence it has its own case.  Begin\n        ** by allocating the tables we will need.\n        */\n        tab1 = pParse->nTab++;\n        tab2 = pParse->nTab++;\n        assert( p->pOrderBy==0 );\n  \n        addr = sqlite3VdbeAddOp2(v, OP_OpenEphemeral, tab1, 0);\n        assert( p->addrOpenEphm[0] == -1 );\n        p->addrOpenEphm[0] = addr;\n        findRightmost(p)->selFlags |= SF_UsesEphemeral;\n        assert( p->pEList );\n  \n        /* Code the SELECTs to our left into temporary table \"tab1\".\n        */\n        sqlite3SelectDestInit(&intersectdest, SRT_Union, tab1);\n        rc = sqlite3Select(pParse, pPrior, &intersectdest);\n        if( rc ){\n          goto multi_select_end;\n        }\n  \n        /* Code the current SELECT into temporary table \"tab2\"\n        */\n        addr = sqlite3VdbeAddOp2(v, OP_OpenEphemeral, tab2, 0);\n        assert( p->addrOpenEphm[1] == -1 );\n        p->addrOpenEphm[1] = addr;\n        p->pPrior = 0;\n        pLimit = p->pLimit;\n        p->pLimit = 0;\n        intersectdest.iSDParm = tab2;\n        ExplainQueryPlan((pParse, 1, \"%s USING TEMP B-TREE\",\n                          selectOpName(p->op)));\n        rc = sqlite3Select(pParse, p, &intersectdest);\n        testcase( rc!=SQLITE_OK );\n        pDelete = p->pPrior;\n        p->pPrior = pPrior;\n        if( p->nSelectRow>pPrior->nSelectRow ){\n          p->nSelectRow = pPrior->nSelectRow;\n        }\n        sqlite3ExprDelete(db, p->pLimit);\n        p->pLimit = pLimit;\n  \n        /* Generate code to take the intersection of the two temporary\n        ** tables.\n        */\n        assert( p->pEList );\n        iBreak = sqlite3VdbeMakeLabel(pParse);\n        iCont = sqlite3VdbeMakeLabel(pParse);\n        computeLimitRegisters(pParse, p, iBreak);\n        sqlite3VdbeAddOp2(v, OP_Rewind, tab1, iBreak); VdbeCoverage(v);\n        r1 = sqlite3GetTempReg(pParse);\n        iStart = sqlite3VdbeAddOp2(v, OP_RowData, tab1, r1);\n        sqlite3VdbeAddOp4Int(v, OP_NotFound, tab2, iCont, r1, 0);\n        VdbeCoverage(v);\n        sqlite3ReleaseTempReg(pParse, r1);\n        selectInnerLoop(pParse, p, tab1,\n                        0, 0, &dest, iCont, iBreak);\n        sqlite3VdbeResolveLabel(v, iCont);\n        sqlite3VdbeAddOp2(v, OP_Next, tab1, iStart); VdbeCoverage(v);\n        sqlite3VdbeResolveLabel(v, iBreak);\n        sqlite3VdbeAddOp2(v, OP_Close, tab2, 0);\n        sqlite3VdbeAddOp2(v, OP_Close, tab1, 0);\n        break;\n      }\n    }\n  \n  #ifndef SQLITE_OMIT_EXPLAIN\n    if( p->pNext==0 ){\n      ExplainQueryPlanPop(pParse);\n    }\n  #endif\n  }\n  \n  /* Compute collating sequences used by \n  ** temporary tables needed to implement the compound select.\n  ** Attach the KeyInfo structure to all temporary tables.\n  **\n  ** This section is run by the right-most SELECT statement only.\n  ** SELECT statements to the left always skip this part.  The right-most\n  ** SELECT might also skip this part if it has no ORDER BY clause and\n  ** no temp tables are required.\n  */\n  if( p->selFlags & SF_UsesEphemeral ){\n    int i;                        /* Loop counter */\n    KeyInfo *pKeyInfo;            /* Collating sequence for the result set */\n    Select *pLoop;                /* For looping through SELECT statements */\n    CollSeq **apColl;             /* For looping through pKeyInfo->aColl[] */\n    int nCol;                     /* Number of columns in result set */\n\n    assert( p->pNext==0 );\n    nCol = p->pEList->nExpr;\n    pKeyInfo = sqlite3KeyInfoAlloc(db, nCol, 1);\n    if( !pKeyInfo ){\n      rc = SQLITE_NOMEM_BKPT;\n      goto multi_select_end;\n    }\n    for(i=0, apColl=pKeyInfo->aColl; i<nCol; i++, apColl++){\n      *apColl = multiSelectCollSeq(pParse, p, i);\n      if( 0==*apColl ){\n        *apColl = db->pDfltColl;\n      }\n    }\n\n    for(pLoop=p; pLoop; pLoop=pLoop->pPrior){\n      for(i=0; i<2; i++){\n        int addr = pLoop->addrOpenEphm[i];\n        if( addr<0 ){\n          /* If [0] is unused then [1] is also unused.  So we can\n          ** always safely abort as soon as the first unused slot is found */\n          assert( pLoop->addrOpenEphm[1]<0 );\n          break;\n        }\n        sqlite3VdbeChangeP2(v, addr, nCol);\n        sqlite3VdbeChangeP4(v, addr, (char*)sqlite3KeyInfoRef(pKeyInfo),\n                            P4_KEYINFO);\n        pLoop->addrOpenEphm[i] = -1;\n      }\n    }\n    sqlite3KeyInfoUnref(pKeyInfo);\n  }\n\nmulti_select_end:\n  pDest->iSdst = dest.iSdst;\n  pDest->nSdst = dest.nSdst;\n  sqlite3SelectDelete(db, pDelete);\n  return rc;\n}\n#endif /* SQLITE_OMIT_COMPOUND_SELECT */\n\n/*\n** Error message for when two or more terms of a compound select have different\n** size result sets.\n*/\nSQLITE_PRIVATE void sqlite3SelectWrongNumTermsError(Parse *pParse, Select *p){\n  if( p->selFlags & SF_Values ){\n    sqlite3ErrorMsg(pParse, \"all VALUES must have the same number of terms\");\n  }else{\n    sqlite3ErrorMsg(pParse, \"SELECTs to the left and right of %s\"\n      \" do not have the same number of result columns\", selectOpName(p->op));\n  }\n}\n\n/*\n** Code an output subroutine for a coroutine implementation of a\n** SELECT statment.\n**\n** The data to be output is contained in pIn->iSdst.  There are\n** pIn->nSdst columns to be output.  pDest is where the output should\n** be sent.\n**\n** regReturn is the number of the register holding the subroutine\n** return address.\n**\n** If regPrev>0 then it is the first register in a vector that\n** records the previous output.  mem[regPrev] is a flag that is false\n** if there has been no previous output.  If regPrev>0 then code is\n** generated to suppress duplicates.  pKeyInfo is used for comparing\n** keys.\n**\n** If the LIMIT found in p->iLimit is reached, jump immediately to\n** iBreak.\n*/\nstatic int generateOutputSubroutine(\n  Parse *pParse,          /* Parsing context */\n  Select *p,              /* The SELECT statement */\n  SelectDest *pIn,        /* Coroutine supplying data */\n  SelectDest *pDest,      /* Where to send the data */\n  int regReturn,          /* The return address register */\n  int regPrev,            /* Previous result register.  No uniqueness if 0 */\n  KeyInfo *pKeyInfo,      /* For comparing with previous entry */\n  int iBreak              /* Jump here if we hit the LIMIT */\n){\n  Vdbe *v = pParse->pVdbe;\n  int iContinue;\n  int addr;\n\n  addr = sqlite3VdbeCurrentAddr(v);\n  iContinue = sqlite3VdbeMakeLabel(pParse);\n\n  /* Suppress duplicates for UNION, EXCEPT, and INTERSECT \n  */\n  if( regPrev ){\n    int addr1, addr2;\n    addr1 = sqlite3VdbeAddOp1(v, OP_IfNot, regPrev); VdbeCoverage(v);\n    addr2 = sqlite3VdbeAddOp4(v, OP_Compare, pIn->iSdst, regPrev+1, pIn->nSdst,\n                              (char*)sqlite3KeyInfoRef(pKeyInfo), P4_KEYINFO);\n    sqlite3VdbeAddOp3(v, OP_Jump, addr2+2, iContinue, addr2+2); VdbeCoverage(v);\n    sqlite3VdbeJumpHere(v, addr1);\n    sqlite3VdbeAddOp3(v, OP_Copy, pIn->iSdst, regPrev+1, pIn->nSdst-1);\n    sqlite3VdbeAddOp2(v, OP_Integer, 1, regPrev);\n  }\n  if( pParse->db->mallocFailed ) return 0;\n\n  /* Suppress the first OFFSET entries if there is an OFFSET clause\n  */\n  codeOffset(v, p->iOffset, iContinue);\n\n  assert( pDest->eDest!=SRT_Exists );\n  assert( pDest->eDest!=SRT_Table );\n  switch( pDest->eDest ){\n    /* Store the result as data using a unique key.\n    */\n    case SRT_EphemTab: {\n      int r1 = sqlite3GetTempReg(pParse);\n      int r2 = sqlite3GetTempReg(pParse);\n      sqlite3VdbeAddOp3(v, OP_MakeRecord, pIn->iSdst, pIn->nSdst, r1);\n      sqlite3VdbeAddOp2(v, OP_NewRowid, pDest->iSDParm, r2);\n      sqlite3VdbeAddOp3(v, OP_Insert, pDest->iSDParm, r1, r2);\n      sqlite3VdbeChangeP5(v, OPFLAG_APPEND);\n      sqlite3ReleaseTempReg(pParse, r2);\n      sqlite3ReleaseTempReg(pParse, r1);\n      break;\n    }\n\n#ifndef SQLITE_OMIT_SUBQUERY\n    /* If we are creating a set for an \"expr IN (SELECT ...)\".\n    */\n    case SRT_Set: {\n      int r1;\n      testcase( pIn->nSdst>1 );\n      r1 = sqlite3GetTempReg(pParse);\n      sqlite3VdbeAddOp4(v, OP_MakeRecord, pIn->iSdst, pIn->nSdst, \n          r1, pDest->zAffSdst, pIn->nSdst);\n      sqlite3VdbeAddOp4Int(v, OP_IdxInsert, pDest->iSDParm, r1,\n                           pIn->iSdst, pIn->nSdst);\n      sqlite3ReleaseTempReg(pParse, r1);\n      break;\n    }\n\n    /* If this is a scalar select that is part of an expression, then\n    ** store the results in the appropriate memory cell and break out\n    ** of the scan loop.\n    */\n    case SRT_Mem: {\n      assert( pIn->nSdst==1 || pParse->nErr>0 );  testcase( pIn->nSdst!=1 );\n      sqlite3ExprCodeMove(pParse, pIn->iSdst, pDest->iSDParm, 1);\n      /* The LIMIT clause will jump out of the loop for us */\n      break;\n    }\n#endif /* #ifndef SQLITE_OMIT_SUBQUERY */\n\n    /* The results are stored in a sequence of registers\n    ** starting at pDest->iSdst.  Then the co-routine yields.\n    */\n    case SRT_Coroutine: {\n      if( pDest->iSdst==0 ){\n        pDest->iSdst = sqlite3GetTempRange(pParse, pIn->nSdst);\n        pDest->nSdst = pIn->nSdst;\n      }\n      sqlite3ExprCodeMove(pParse, pIn->iSdst, pDest->iSdst, pIn->nSdst);\n      sqlite3VdbeAddOp1(v, OP_Yield, pDest->iSDParm);\n      break;\n    }\n\n    /* If none of the above, then the result destination must be\n    ** SRT_Output.  This routine is never called with any other\n    ** destination other than the ones handled above or SRT_Output.\n    **\n    ** For SRT_Output, results are stored in a sequence of registers.  \n    ** Then the OP_ResultRow opcode is used to cause sqlite3_step() to\n    ** return the next row of result.\n    */\n    default: {\n      assert( pDest->eDest==SRT_Output );\n      sqlite3VdbeAddOp2(v, OP_ResultRow, pIn->iSdst, pIn->nSdst);\n      break;\n    }\n  }\n\n  /* Jump to the end of the loop if the LIMIT is reached.\n  */\n  if( p->iLimit ){\n    sqlite3VdbeAddOp2(v, OP_DecrJumpZero, p->iLimit, iBreak); VdbeCoverage(v);\n  }\n\n  /* Generate the subroutine return\n  */\n  sqlite3VdbeResolveLabel(v, iContinue);\n  sqlite3VdbeAddOp1(v, OP_Return, regReturn);\n\n  return addr;\n}\n\n/*\n** Alternative compound select code generator for cases when there\n** is an ORDER BY clause.\n**\n** We assume a query of the following form:\n**\n**      <selectA>  <operator>  <selectB>  ORDER BY <orderbylist>\n**\n** <operator> is one of UNION ALL, UNION, EXCEPT, or INTERSECT.  The idea\n** is to code both <selectA> and <selectB> with the ORDER BY clause as\n** co-routines.  Then run the co-routines in parallel and merge the results\n** into the output.  In addition to the two coroutines (called selectA and\n** selectB) there are 7 subroutines:\n**\n**    outA:    Move the output of the selectA coroutine into the output\n**             of the compound query.\n**\n**    outB:    Move the output of the selectB coroutine into the output\n**             of the compound query.  (Only generated for UNION and\n**             UNION ALL.  EXCEPT and INSERTSECT never output a row that\n**             appears only in B.)\n**\n**    AltB:    Called when there is data from both coroutines and A<B.\n**\n**    AeqB:    Called when there is data from both coroutines and A==B.\n**\n**    AgtB:    Called when there is data from both coroutines and A>B.\n**\n**    EofA:    Called when data is exhausted from selectA.\n**\n**    EofB:    Called when data is exhausted from selectB.\n**\n** The implementation of the latter five subroutines depend on which \n** <operator> is used:\n**\n**\n**             UNION ALL         UNION            EXCEPT          INTERSECT\n**          -------------  -----------------  --------------  -----------------\n**   AltB:   outA, nextA      outA, nextA       outA, nextA         nextA\n**\n**   AeqB:   outA, nextA         nextA             nextA         outA, nextA\n**\n**   AgtB:   outB, nextB      outB, nextB          nextB            nextB\n**\n**   EofA:   outB, nextB      outB, nextB          halt             halt\n**\n**   EofB:   outA, nextA      outA, nextA       outA, nextA         halt\n**\n** In the AltB, AeqB, and AgtB subroutines, an EOF on A following nextA\n** causes an immediate jump to EofA and an EOF on B following nextB causes\n** an immediate jump to EofB.  Within EofA and EofB, and EOF on entry or\n** following nextX causes a jump to the end of the select processing.\n**\n** Duplicate removal in the UNION, EXCEPT, and INTERSECT cases is handled\n** within the output subroutine.  The regPrev register set holds the previously\n** output value.  A comparison is made against this value and the output\n** is skipped if the next results would be the same as the previous.\n**\n** The implementation plan is to implement the two coroutines and seven\n** subroutines first, then put the control logic at the bottom.  Like this:\n**\n**          goto Init\n**     coA: coroutine for left query (A)\n**     coB: coroutine for right query (B)\n**    outA: output one row of A\n**    outB: output one row of B (UNION and UNION ALL only)\n**    EofA: ...\n**    EofB: ...\n**    AltB: ...\n**    AeqB: ...\n**    AgtB: ...\n**    Init: initialize coroutine registers\n**          yield coA\n**          if eof(A) goto EofA\n**          yield coB\n**          if eof(B) goto EofB\n**    Cmpr: Compare A, B\n**          Jump AltB, AeqB, AgtB\n**     End: ...\n**\n** We call AltB, AeqB, AgtB, EofA, and EofB \"subroutines\" but they are not\n** actually called using Gosub and they do not Return.  EofA and EofB loop\n** until all data is exhausted then jump to the \"end\" labe.  AltB, AeqB,\n** and AgtB jump to either L2 or to one of EofA or EofB.\n*/\n#ifndef SQLITE_OMIT_COMPOUND_SELECT\nstatic int multiSelectOrderBy(\n  Parse *pParse,        /* Parsing context */\n  Select *p,            /* The right-most of SELECTs to be coded */\n  SelectDest *pDest     /* What to do with query results */\n){\n  int i, j;             /* Loop counters */\n  Select *pPrior;       /* Another SELECT immediately to our left */\n  Vdbe *v;              /* Generate code to this VDBE */\n  SelectDest destA;     /* Destination for coroutine A */\n  SelectDest destB;     /* Destination for coroutine B */\n  int regAddrA;         /* Address register for select-A coroutine */\n  int regAddrB;         /* Address register for select-B coroutine */\n  int addrSelectA;      /* Address of the select-A coroutine */\n  int addrSelectB;      /* Address of the select-B coroutine */\n  int regOutA;          /* Address register for the output-A subroutine */\n  int regOutB;          /* Address register for the output-B subroutine */\n  int addrOutA;         /* Address of the output-A subroutine */\n  int addrOutB = 0;     /* Address of the output-B subroutine */\n  int addrEofA;         /* Address of the select-A-exhausted subroutine */\n  int addrEofA_noB;     /* Alternate addrEofA if B is uninitialized */\n  int addrEofB;         /* Address of the select-B-exhausted subroutine */\n  int addrAltB;         /* Address of the A<B subroutine */\n  int addrAeqB;         /* Address of the A==B subroutine */\n  int addrAgtB;         /* Address of the A>B subroutine */\n  int regLimitA;        /* Limit register for select-A */\n  int regLimitB;        /* Limit register for select-A */\n  int regPrev;          /* A range of registers to hold previous output */\n  int savedLimit;       /* Saved value of p->iLimit */\n  int savedOffset;      /* Saved value of p->iOffset */\n  int labelCmpr;        /* Label for the start of the merge algorithm */\n  int labelEnd;         /* Label for the end of the overall SELECT stmt */\n  int addr1;            /* Jump instructions that get retargetted */\n  int op;               /* One of TK_ALL, TK_UNION, TK_EXCEPT, TK_INTERSECT */\n  KeyInfo *pKeyDup = 0; /* Comparison information for duplicate removal */\n  KeyInfo *pKeyMerge;   /* Comparison information for merging rows */\n  sqlite3 *db;          /* Database connection */\n  ExprList *pOrderBy;   /* The ORDER BY clause */\n  int nOrderBy;         /* Number of terms in the ORDER BY clause */\n  int *aPermute;        /* Mapping from ORDER BY terms to result set columns */\n\n  assert( p->pOrderBy!=0 );\n  assert( pKeyDup==0 ); /* \"Managed\" code needs this.  Ticket #3382. */\n  db = pParse->db;\n  v = pParse->pVdbe;\n  assert( v!=0 );       /* Already thrown the error if VDBE alloc failed */\n  labelEnd = sqlite3VdbeMakeLabel(pParse);\n  labelCmpr = sqlite3VdbeMakeLabel(pParse);\n\n\n  /* Patch up the ORDER BY clause\n  */\n  op = p->op;  \n  pPrior = p->pPrior;\n  assert( pPrior->pOrderBy==0 );\n  pOrderBy = p->pOrderBy;\n  assert( pOrderBy );\n  nOrderBy = pOrderBy->nExpr;\n\n  /* For operators other than UNION ALL we have to make sure that\n  ** the ORDER BY clause covers every term of the result set.  Add\n  ** terms to the ORDER BY clause as necessary.\n  */\n  if( op!=TK_ALL ){\n    for(i=1; db->mallocFailed==0 && i<=p->pEList->nExpr; i++){\n      struct ExprList_item *pItem;\n      for(j=0, pItem=pOrderBy->a; j<nOrderBy; j++, pItem++){\n        assert( pItem->u.x.iOrderByCol>0 );\n        if( pItem->u.x.iOrderByCol==i ) break;\n      }\n      if( j==nOrderBy ){\n        Expr *pNew = sqlite3Expr(db, TK_INTEGER, 0);\n        if( pNew==0 ) return SQLITE_NOMEM_BKPT;\n        pNew->flags |= EP_IntValue;\n        pNew->u.iValue = i;\n        p->pOrderBy = pOrderBy = sqlite3ExprListAppend(pParse, pOrderBy, pNew);\n        if( pOrderBy ) pOrderBy->a[nOrderBy++].u.x.iOrderByCol = (u16)i;\n      }\n    }\n  }\n\n  /* Compute the comparison permutation and keyinfo that is used with\n  ** the permutation used to determine if the next\n  ** row of results comes from selectA or selectB.  Also add explicit\n  ** collations to the ORDER BY clause terms so that when the subqueries\n  ** to the right and the left are evaluated, they use the correct\n  ** collation.\n  */\n  aPermute = sqlite3DbMallocRawNN(db, sizeof(int)*(nOrderBy + 1));\n  if( aPermute ){\n    struct ExprList_item *pItem;\n    aPermute[0] = nOrderBy;\n    for(i=1, pItem=pOrderBy->a; i<=nOrderBy; i++, pItem++){\n      assert( pItem->u.x.iOrderByCol>0 );\n      assert( pItem->u.x.iOrderByCol<=p->pEList->nExpr );\n      aPermute[i] = pItem->u.x.iOrderByCol - 1;\n    }\n    pKeyMerge = multiSelectOrderByKeyInfo(pParse, p, 1);\n  }else{\n    pKeyMerge = 0;\n  }\n\n  /* Reattach the ORDER BY clause to the query.\n  */\n  p->pOrderBy = pOrderBy;\n  pPrior->pOrderBy = sqlite3ExprListDup(pParse->db, pOrderBy, 0);\n\n  /* Allocate a range of temporary registers and the KeyInfo needed\n  ** for the logic that removes duplicate result rows when the\n  ** operator is UNION, EXCEPT, or INTERSECT (but not UNION ALL).\n  */\n  if( op==TK_ALL ){\n    regPrev = 0;\n  }else{\n    int nExpr = p->pEList->nExpr;\n    assert( nOrderBy>=nExpr || db->mallocFailed );\n    regPrev = pParse->nMem+1;\n    pParse->nMem += nExpr+1;\n    sqlite3VdbeAddOp2(v, OP_Integer, 0, regPrev);\n    pKeyDup = sqlite3KeyInfoAlloc(db, nExpr, 1);\n    if( pKeyDup ){\n      assert( sqlite3KeyInfoIsWriteable(pKeyDup) );\n      for(i=0; i<nExpr; i++){\n        pKeyDup->aColl[i] = multiSelectCollSeq(pParse, p, i);\n        pKeyDup->aSortOrder[i] = 0;\n      }\n    }\n  }\n \n  /* Separate the left and the right query from one another\n  */\n  p->pPrior = 0;\n  pPrior->pNext = 0;\n  sqlite3ResolveOrderGroupBy(pParse, p, p->pOrderBy, \"ORDER\");\n  if( pPrior->pPrior==0 ){\n    sqlite3ResolveOrderGroupBy(pParse, pPrior, pPrior->pOrderBy, \"ORDER\");\n  }\n\n  /* Compute the limit registers */\n  computeLimitRegisters(pParse, p, labelEnd);\n  if( p->iLimit && op==TK_ALL ){\n    regLimitA = ++pParse->nMem;\n    regLimitB = ++pParse->nMem;\n    sqlite3VdbeAddOp2(v, OP_Copy, p->iOffset ? p->iOffset+1 : p->iLimit,\n                                  regLimitA);\n    sqlite3VdbeAddOp2(v, OP_Copy, regLimitA, regLimitB);\n  }else{\n    regLimitA = regLimitB = 0;\n  }\n  sqlite3ExprDelete(db, p->pLimit);\n  p->pLimit = 0;\n\n  regAddrA = ++pParse->nMem;\n  regAddrB = ++pParse->nMem;\n  regOutA = ++pParse->nMem;\n  regOutB = ++pParse->nMem;\n  sqlite3SelectDestInit(&destA, SRT_Coroutine, regAddrA);\n  sqlite3SelectDestInit(&destB, SRT_Coroutine, regAddrB);\n\n  ExplainQueryPlan((pParse, 1, \"MERGE (%s)\", selectOpName(p->op)));\n\n  /* Generate a coroutine to evaluate the SELECT statement to the\n  ** left of the compound operator - the \"A\" select.\n  */\n  addrSelectA = sqlite3VdbeCurrentAddr(v) + 1;\n  addr1 = sqlite3VdbeAddOp3(v, OP_InitCoroutine, regAddrA, 0, addrSelectA);\n  VdbeComment((v, \"left SELECT\"));\n  pPrior->iLimit = regLimitA;\n  ExplainQueryPlan((pParse, 1, \"LEFT\"));\n  sqlite3Select(pParse, pPrior, &destA);\n  sqlite3VdbeEndCoroutine(v, regAddrA);\n  sqlite3VdbeJumpHere(v, addr1);\n\n  /* Generate a coroutine to evaluate the SELECT statement on \n  ** the right - the \"B\" select\n  */\n  addrSelectB = sqlite3VdbeCurrentAddr(v) + 1;\n  addr1 = sqlite3VdbeAddOp3(v, OP_InitCoroutine, regAddrB, 0, addrSelectB);\n  VdbeComment((v, \"right SELECT\"));\n  savedLimit = p->iLimit;\n  savedOffset = p->iOffset;\n  p->iLimit = regLimitB;\n  p->iOffset = 0;  \n  ExplainQueryPlan((pParse, 1, \"RIGHT\"));\n  sqlite3Select(pParse, p, &destB);\n  p->iLimit = savedLimit;\n  p->iOffset = savedOffset;\n  sqlite3VdbeEndCoroutine(v, regAddrB);\n\n  /* Generate a subroutine that outputs the current row of the A\n  ** select as the next output row of the compound select.\n  */\n  VdbeNoopComment((v, \"Output routine for A\"));\n  addrOutA = generateOutputSubroutine(pParse,\n                 p, &destA, pDest, regOutA,\n                 regPrev, pKeyDup, labelEnd);\n  \n  /* Generate a subroutine that outputs the current row of the B\n  ** select as the next output row of the compound select.\n  */\n  if( op==TK_ALL || op==TK_UNION ){\n    VdbeNoopComment((v, \"Output routine for B\"));\n    addrOutB = generateOutputSubroutine(pParse,\n                 p, &destB, pDest, regOutB,\n                 regPrev, pKeyDup, labelEnd);\n  }\n  sqlite3KeyInfoUnref(pKeyDup);\n\n  /* Generate a subroutine to run when the results from select A\n  ** are exhausted and only data in select B remains.\n  */\n  if( op==TK_EXCEPT || op==TK_INTERSECT ){\n    addrEofA_noB = addrEofA = labelEnd;\n  }else{  \n    VdbeNoopComment((v, \"eof-A subroutine\"));\n    addrEofA = sqlite3VdbeAddOp2(v, OP_Gosub, regOutB, addrOutB);\n    addrEofA_noB = sqlite3VdbeAddOp2(v, OP_Yield, regAddrB, labelEnd);\n                                     VdbeCoverage(v);\n    sqlite3VdbeGoto(v, addrEofA);\n    p->nSelectRow = sqlite3LogEstAdd(p->nSelectRow, pPrior->nSelectRow);\n  }\n\n  /* Generate a subroutine to run when the results from select B\n  ** are exhausted and only data in select A remains.\n  */\n  if( op==TK_INTERSECT ){\n    addrEofB = addrEofA;\n    if( p->nSelectRow > pPrior->nSelectRow ) p->nSelectRow = pPrior->nSelectRow;\n  }else{  \n    VdbeNoopComment((v, \"eof-B subroutine\"));\n    addrEofB = sqlite3VdbeAddOp2(v, OP_Gosub, regOutA, addrOutA);\n    sqlite3VdbeAddOp2(v, OP_Yield, regAddrA, labelEnd); VdbeCoverage(v);\n    sqlite3VdbeGoto(v, addrEofB);\n  }\n\n  /* Generate code to handle the case of A<B\n  */\n  VdbeNoopComment((v, \"A-lt-B subroutine\"));\n  addrAltB = sqlite3VdbeAddOp2(v, OP_Gosub, regOutA, addrOutA);\n  sqlite3VdbeAddOp2(v, OP_Yield, regAddrA, addrEofA); VdbeCoverage(v);\n  sqlite3VdbeGoto(v, labelCmpr);\n\n  /* Generate code to handle the case of A==B\n  */\n  if( op==TK_ALL ){\n    addrAeqB = addrAltB;\n  }else if( op==TK_INTERSECT ){\n    addrAeqB = addrAltB;\n    addrAltB++;\n  }else{\n    VdbeNoopComment((v, \"A-eq-B subroutine\"));\n    addrAeqB =\n    sqlite3VdbeAddOp2(v, OP_Yield, regAddrA, addrEofA); VdbeCoverage(v);\n    sqlite3VdbeGoto(v, labelCmpr);\n  }\n\n  /* Generate code to handle the case of A>B\n  */\n  VdbeNoopComment((v, \"A-gt-B subroutine\"));\n  addrAgtB = sqlite3VdbeCurrentAddr(v);\n  if( op==TK_ALL || op==TK_UNION ){\n    sqlite3VdbeAddOp2(v, OP_Gosub, regOutB, addrOutB);\n  }\n  sqlite3VdbeAddOp2(v, OP_Yield, regAddrB, addrEofB); VdbeCoverage(v);\n  sqlite3VdbeGoto(v, labelCmpr);\n\n  /* This code runs once to initialize everything.\n  */\n  sqlite3VdbeJumpHere(v, addr1);\n  sqlite3VdbeAddOp2(v, OP_Yield, regAddrA, addrEofA_noB); VdbeCoverage(v);\n  sqlite3VdbeAddOp2(v, OP_Yield, regAddrB, addrEofB); VdbeCoverage(v);\n\n  /* Implement the main merge loop\n  */\n  sqlite3VdbeResolveLabel(v, labelCmpr);\n  sqlite3VdbeAddOp4(v, OP_Permutation, 0, 0, 0, (char*)aPermute, P4_INTARRAY);\n  sqlite3VdbeAddOp4(v, OP_Compare, destA.iSdst, destB.iSdst, nOrderBy,\n                         (char*)pKeyMerge, P4_KEYINFO);\n  sqlite3VdbeChangeP5(v, OPFLAG_PERMUTE);\n  sqlite3VdbeAddOp3(v, OP_Jump, addrAltB, addrAeqB, addrAgtB); VdbeCoverage(v);\n\n  /* Jump to the this point in order to terminate the query.\n  */\n  sqlite3VdbeResolveLabel(v, labelEnd);\n\n  /* Reassembly the compound query so that it will be freed correctly\n  ** by the calling function */\n  if( p->pPrior ){\n    sqlite3SelectDelete(db, p->pPrior);\n  }\n  p->pPrior = pPrior;\n  pPrior->pNext = p;\n\n  /*** TBD:  Insert subroutine calls to close cursors on incomplete\n  **** subqueries ****/\n  ExplainQueryPlanPop(pParse);\n  return pParse->nErr!=0;\n}\n#endif\n\n#if !defined(SQLITE_OMIT_SUBQUERY) || !defined(SQLITE_OMIT_VIEW)\n\n/* An instance of the SubstContext object describes an substitution edit\n** to be performed on a parse tree.\n**\n** All references to columns in table iTable are to be replaced by corresponding\n** expressions in pEList.\n*/\ntypedef struct SubstContext {\n  Parse *pParse;            /* The parsing context */\n  int iTable;               /* Replace references to this table */\n  int iNewTable;            /* New table number */\n  int isLeftJoin;           /* Add TK_IF_NULL_ROW opcodes on each replacement */\n  ExprList *pEList;         /* Replacement expressions */\n} SubstContext;\n\n/* Forward Declarations */\nstatic void substExprList(SubstContext*, ExprList*);\nstatic void substSelect(SubstContext*, Select*, int);\n\n/*\n** Scan through the expression pExpr.  Replace every reference to\n** a column in table number iTable with a copy of the iColumn-th\n** entry in pEList.  (But leave references to the ROWID column \n** unchanged.)\n**\n** This routine is part of the flattening procedure.  A subquery\n** whose result set is defined by pEList appears as entry in the\n** FROM clause of a SELECT such that the VDBE cursor assigned to that\n** FORM clause entry is iTable.  This routine makes the necessary \n** changes to pExpr so that it refers directly to the source table\n** of the subquery rather the result set of the subquery.\n*/\nstatic Expr *substExpr(\n  SubstContext *pSubst,  /* Description of the substitution */\n  Expr *pExpr            /* Expr in which substitution occurs */\n){\n  if( pExpr==0 ) return 0;\n  if( ExprHasProperty(pExpr, EP_FromJoin)\n   && pExpr->iRightJoinTable==pSubst->iTable\n  ){\n    pExpr->iRightJoinTable = pSubst->iNewTable;\n  }\n  if( pExpr->op==TK_COLUMN && pExpr->iTable==pSubst->iTable ){\n    if( pExpr->iColumn<0 ){\n      pExpr->op = TK_NULL;\n    }else{\n      Expr *pNew;\n      Expr *pCopy = pSubst->pEList->a[pExpr->iColumn].pExpr;\n      Expr ifNullRow;\n      assert( pSubst->pEList!=0 && pExpr->iColumn<pSubst->pEList->nExpr );\n      assert( pExpr->pRight==0 );\n      if( sqlite3ExprIsVector(pCopy) ){\n        sqlite3VectorErrorMsg(pSubst->pParse, pCopy);\n      }else{\n        sqlite3 *db = pSubst->pParse->db;\n        if( pSubst->isLeftJoin && pCopy->op!=TK_COLUMN ){\n          memset(&ifNullRow, 0, sizeof(ifNullRow));\n          ifNullRow.op = TK_IF_NULL_ROW;\n          ifNullRow.pLeft = pCopy;\n          ifNullRow.iTable = pSubst->iNewTable;\n          pCopy = &ifNullRow;\n        }\n        testcase( ExprHasProperty(pCopy, EP_Subquery) );\n        pNew = sqlite3ExprDup(db, pCopy, 0);\n        if( pNew && pSubst->isLeftJoin ){\n          ExprSetProperty(pNew, EP_CanBeNull);\n        }\n        if( pNew && ExprHasProperty(pExpr,EP_FromJoin) ){\n          pNew->iRightJoinTable = pExpr->iRightJoinTable;\n          ExprSetProperty(pNew, EP_FromJoin);\n        }\n        sqlite3ExprDelete(db, pExpr);\n        pExpr = pNew;\n      }\n    }\n  }else{\n    if( pExpr->op==TK_IF_NULL_ROW && pExpr->iTable==pSubst->iTable ){\n      pExpr->iTable = pSubst->iNewTable;\n    }\n    pExpr->pLeft = substExpr(pSubst, pExpr->pLeft);\n    pExpr->pRight = substExpr(pSubst, pExpr->pRight);\n    if( ExprHasProperty(pExpr, EP_xIsSelect) ){\n      substSelect(pSubst, pExpr->x.pSelect, 1);\n    }else{\n      substExprList(pSubst, pExpr->x.pList);\n    }\n  }\n  return pExpr;\n}\nstatic void substExprList(\n  SubstContext *pSubst, /* Description of the substitution */\n  ExprList *pList       /* List to scan and in which to make substitutes */\n){\n  int i;\n  if( pList==0 ) return;\n  for(i=0; i<pList->nExpr; i++){\n    pList->a[i].pExpr = substExpr(pSubst, pList->a[i].pExpr);\n  }\n}\nstatic void substSelect(\n  SubstContext *pSubst, /* Description of the substitution */\n  Select *p,            /* SELECT statement in which to make substitutions */\n  int doPrior           /* Do substitutes on p->pPrior too */\n){\n  SrcList *pSrc;\n  struct SrcList_item *pItem;\n  int i;\n  if( !p ) return;\n  do{\n    substExprList(pSubst, p->pEList);\n    substExprList(pSubst, p->pGroupBy);\n    substExprList(pSubst, p->pOrderBy);\n    p->pHaving = substExpr(pSubst, p->pHaving);\n    p->pWhere = substExpr(pSubst, p->pWhere);\n    pSrc = p->pSrc;\n    assert( pSrc!=0 );\n    for(i=pSrc->nSrc, pItem=pSrc->a; i>0; i--, pItem++){\n      substSelect(pSubst, pItem->pSelect, 1);\n      if( pItem->fg.isTabFunc ){\n        substExprList(pSubst, pItem->u1.pFuncArg);\n      }\n    }\n  }while( doPrior && (p = p->pPrior)!=0 );\n}\n#endif /* !defined(SQLITE_OMIT_SUBQUERY) || !defined(SQLITE_OMIT_VIEW) */\n\n#if !defined(SQLITE_OMIT_SUBQUERY) || !defined(SQLITE_OMIT_VIEW)\n/*\n** This routine attempts to flatten subqueries as a performance optimization.\n** This routine returns 1 if it makes changes and 0 if no flattening occurs.\n**\n** To understand the concept of flattening, consider the following\n** query:\n**\n**     SELECT a FROM (SELECT x+y AS a FROM t1 WHERE z<100) WHERE a>5\n**\n** The default way of implementing this query is to execute the\n** subquery first and store the results in a temporary table, then\n** run the outer query on that temporary table.  This requires two\n** passes over the data.  Furthermore, because the temporary table\n** has no indices, the WHERE clause on the outer query cannot be\n** optimized.\n**\n** This routine attempts to rewrite queries such as the above into\n** a single flat select, like this:\n**\n**     SELECT x+y AS a FROM t1 WHERE z<100 AND a>5\n**\n** The code generated for this simplification gives the same result\n** but only has to scan the data once.  And because indices might \n** exist on the table t1, a complete scan of the data might be\n** avoided.\n**\n** Flattening is subject to the following constraints:\n**\n**  (**)  We no longer attempt to flatten aggregate subqueries. Was:\n**        The subquery and the outer query cannot both be aggregates.\n**\n**  (**)  We no longer attempt to flatten aggregate subqueries. Was:\n**        (2) If the subquery is an aggregate then\n**        (2a) the outer query must not be a join and\n**        (2b) the outer query must not use subqueries\n**             other than the one FROM-clause subquery that is a candidate\n**             for flattening.  (This is due to ticket [2f7170d73bf9abf80]\n**             from 2015-02-09.)\n**\n**   (3)  If the subquery is the right operand of a LEFT JOIN then\n**        (3a) the subquery may not be a join and\n**        (3b) the FROM clause of the subquery may not contain a virtual\n**             table and\n**        (3c) the outer query may not be an aggregate.\n**\n**   (4)  The subquery can not be DISTINCT.\n**\n**  (**)  At one point restrictions (4) and (5) defined a subset of DISTINCT\n**        sub-queries that were excluded from this optimization. Restriction \n**        (4) has since been expanded to exclude all DISTINCT subqueries.\n**\n**  (**)  We no longer attempt to flatten aggregate subqueries.  Was:\n**        If the subquery is aggregate, the outer query may not be DISTINCT.\n**\n**   (7)  The subquery must have a FROM clause.  TODO:  For subqueries without\n**        A FROM clause, consider adding a FROM clause with the special\n**        table sqlite_once that consists of a single row containing a\n**        single NULL.\n**\n**   (8)  If the subquery uses LIMIT then the outer query may not be a join.\n**\n**   (9)  If the subquery uses LIMIT then the outer query may not be aggregate.\n**\n**  (**)  Restriction (10) was removed from the code on 2005-02-05 but we\n**        accidently carried the comment forward until 2014-09-15.  Original\n**        constraint: \"If the subquery is aggregate then the outer query \n**        may not use LIMIT.\"\n**\n**  (11)  The subquery and the outer query may not both have ORDER BY clauses.\n**\n**  (**)  Not implemented.  Subsumed into restriction (3).  Was previously\n**        a separate restriction deriving from ticket #350.\n**\n**  (13)  The subquery and outer query may not both use LIMIT.\n**\n**  (14)  The subquery may not use OFFSET.\n**\n**  (15)  If the outer query is part of a compound select, then the\n**        subquery may not use LIMIT.\n**        (See ticket #2339 and ticket [02a8e81d44]).\n**\n**  (16)  If the outer query is aggregate, then the subquery may not\n**        use ORDER BY.  (Ticket #2942)  This used to not matter\n**        until we introduced the group_concat() function.  \n**\n**  (17)  If the subquery is a compound select, then\n**        (17a) all compound operators must be a UNION ALL, and\n**        (17b) no terms within the subquery compound may be aggregate\n**              or DISTINCT, and\n**        (17c) every term within the subquery compound must have a FROM clause\n**        (17d) the outer query may not be\n**              (17d1) aggregate, or\n**              (17d2) DISTINCT, or\n**              (17d3) a join.\n**\n**        The parent and sub-query may contain WHERE clauses. Subject to\n**        rules (11), (13) and (14), they may also contain ORDER BY,\n**        LIMIT and OFFSET clauses.  The subquery cannot use any compound\n**        operator other than UNION ALL because all the other compound\n**        operators have an implied DISTINCT which is disallowed by\n**        restriction (4).\n**\n**        Also, each component of the sub-query must return the same number\n**        of result columns. This is actually a requirement for any compound\n**        SELECT statement, but all the code here does is make sure that no\n**        such (illegal) sub-query is flattened. The caller will detect the\n**        syntax error and return a detailed message.\n**\n**  (18)  If the sub-query is a compound select, then all terms of the\n**        ORDER BY clause of the parent must be simple references to \n**        columns of the sub-query.\n**\n**  (19)  If the subquery uses LIMIT then the outer query may not\n**        have a WHERE clause.\n**\n**  (20)  If the sub-query is a compound select, then it must not use\n**        an ORDER BY clause.  Ticket #3773.  We could relax this constraint\n**        somewhat by saying that the terms of the ORDER BY clause must\n**        appear as unmodified result columns in the outer query.  But we\n**        have other optimizations in mind to deal with that case.\n**\n**  (21)  If the subquery uses LIMIT then the outer query may not be\n**        DISTINCT.  (See ticket [752e1646fc]).\n**\n**  (22)  The subquery may not be a recursive CTE.\n**\n**  (**)  Subsumed into restriction (17d3).  Was: If the outer query is\n**        a recursive CTE, then the sub-query may not be a compound query.\n**        This restriction is because transforming the\n**        parent to a compound query confuses the code that handles\n**        recursive queries in multiSelect().\n**\n**  (**)  We no longer attempt to flatten aggregate subqueries.  Was:\n**        The subquery may not be an aggregate that uses the built-in min() or \n**        or max() functions.  (Without this restriction, a query like:\n**        \"SELECT x FROM (SELECT max(y), x FROM t1)\" would not necessarily\n**        return the value X for which Y was maximal.)\n**\n**  (25)  If either the subquery or the parent query contains a window\n**        function in the select list or ORDER BY clause, flattening\n**        is not attempted.\n**\n**\n** In this routine, the \"p\" parameter is a pointer to the outer query.\n** The subquery is p->pSrc->a[iFrom].  isAgg is true if the outer query\n** uses aggregates.\n**\n** If flattening is not attempted, this routine is a no-op and returns 0.\n** If flattening is attempted this routine returns 1.\n**\n** All of the expression analysis must occur on both the outer query and\n** the subquery before this routine runs.\n*/\nstatic int flattenSubquery(\n  Parse *pParse,       /* Parsing context */\n  Select *p,           /* The parent or outer SELECT statement */\n  int iFrom,           /* Index in p->pSrc->a[] of the inner subquery */\n  int isAgg            /* True if outer SELECT uses aggregate functions */\n){\n  const char *zSavedAuthContext = pParse->zAuthContext;\n  Select *pParent;    /* Current UNION ALL term of the other query */\n  Select *pSub;       /* The inner query or \"subquery\" */\n  Select *pSub1;      /* Pointer to the rightmost select in sub-query */\n  SrcList *pSrc;      /* The FROM clause of the outer query */\n  SrcList *pSubSrc;   /* The FROM clause of the subquery */\n  int iParent;        /* VDBE cursor number of the pSub result set temp table */\n  int iNewParent = -1;/* Replacement table for iParent */\n  int isLeftJoin = 0; /* True if pSub is the right side of a LEFT JOIN */    \n  int i;              /* Loop counter */\n  Expr *pWhere;                    /* The WHERE clause */\n  struct SrcList_item *pSubitem;   /* The subquery */\n  sqlite3 *db = pParse->db;\n\n  /* Check to see if flattening is permitted.  Return 0 if not.\n  */\n  assert( p!=0 );\n  assert( p->pPrior==0 );\n  if( OptimizationDisabled(db, SQLITE_QueryFlattener) ) return 0;\n  pSrc = p->pSrc;\n  assert( pSrc && iFrom>=0 && iFrom<pSrc->nSrc );\n  pSubitem = &pSrc->a[iFrom];\n  iParent = pSubitem->iCursor;\n  pSub = pSubitem->pSelect;\n  assert( pSub!=0 );\n\n#ifndef SQLITE_OMIT_WINDOWFUNC\n  if( p->pWin || pSub->pWin ) return 0;                  /* Restriction (25) */\n#endif\n\n  pSubSrc = pSub->pSrc;\n  assert( pSubSrc );\n  /* Prior to version 3.1.2, when LIMIT and OFFSET had to be simple constants,\n  ** not arbitrary expressions, we allowed some combining of LIMIT and OFFSET\n  ** because they could be computed at compile-time.  But when LIMIT and OFFSET\n  ** became arbitrary expressions, we were forced to add restrictions (13)\n  ** and (14). */\n  if( pSub->pLimit && p->pLimit ) return 0;              /* Restriction (13) */\n  if( pSub->pLimit && pSub->pLimit->pRight ) return 0;   /* Restriction (14) */\n  if( (p->selFlags & SF_Compound)!=0 && pSub->pLimit ){\n    return 0;                                            /* Restriction (15) */\n  }\n  if( pSubSrc->nSrc==0 ) return 0;                       /* Restriction (7)  */\n  if( pSub->selFlags & SF_Distinct ) return 0;           /* Restriction (4)  */\n  if( pSub->pLimit && (pSrc->nSrc>1 || isAgg) ){\n     return 0;         /* Restrictions (8)(9) */\n  }\n  if( p->pOrderBy && pSub->pOrderBy ){\n     return 0;                                           /* Restriction (11) */\n  }\n  if( isAgg && pSub->pOrderBy ) return 0;                /* Restriction (16) */\n  if( pSub->pLimit && p->pWhere ) return 0;              /* Restriction (19) */\n  if( pSub->pLimit && (p->selFlags & SF_Distinct)!=0 ){\n     return 0;         /* Restriction (21) */\n  }\n  if( pSub->selFlags & (SF_Recursive) ){\n    return 0; /* Restrictions (22) */\n  }\n\n  /*\n  ** If the subquery is the right operand of a LEFT JOIN, then the\n  ** subquery may not be a join itself (3a). Example of why this is not\n  ** allowed:\n  **\n  **         t1 LEFT OUTER JOIN (t2 JOIN t3)\n  **\n  ** If we flatten the above, we would get\n  **\n  **         (t1 LEFT OUTER JOIN t2) JOIN t3\n  **\n  ** which is not at all the same thing.\n  **\n  ** If the subquery is the right operand of a LEFT JOIN, then the outer\n  ** query cannot be an aggregate. (3c)  This is an artifact of the way\n  ** aggregates are processed - there is no mechanism to determine if\n  ** the LEFT JOIN table should be all-NULL.\n  **\n  ** See also tickets #306, #350, and #3300.\n  */\n  if( (pSubitem->fg.jointype & JT_OUTER)!=0 ){\n    isLeftJoin = 1;\n    if( pSubSrc->nSrc>1 || isAgg || IsVirtual(pSubSrc->a[0].pTab) ){\n      /*  (3a)             (3c)     (3b) */\n      return 0;\n    }\n  }\n#ifdef SQLITE_EXTRA_IFNULLROW\n  else if( iFrom>0 && !isAgg ){\n    /* Setting isLeftJoin to -1 causes OP_IfNullRow opcodes to be generated for\n    ** every reference to any result column from subquery in a join, even\n    ** though they are not necessary.  This will stress-test the OP_IfNullRow \n    ** opcode. */\n    isLeftJoin = -1;\n  }\n#endif\n\n  /* Restriction (17): If the sub-query is a compound SELECT, then it must\n  ** use only the UNION ALL operator. And none of the simple select queries\n  ** that make up the compound SELECT are allowed to be aggregate or distinct\n  ** queries.\n  */\n  if( pSub->pPrior ){\n    if( pSub->pOrderBy ){\n      return 0;  /* Restriction (20) */\n    }\n    if( isAgg || (p->selFlags & SF_Distinct)!=0 || pSrc->nSrc!=1 ){\n      return 0; /* (17d1), (17d2), or (17d3) */\n    }\n    for(pSub1=pSub; pSub1; pSub1=pSub1->pPrior){\n      testcase( (pSub1->selFlags & (SF_Distinct|SF_Aggregate))==SF_Distinct );\n      testcase( (pSub1->selFlags & (SF_Distinct|SF_Aggregate))==SF_Aggregate );\n      assert( pSub->pSrc!=0 );\n      assert( pSub->pEList->nExpr==pSub1->pEList->nExpr );\n      if( (pSub1->selFlags & (SF_Distinct|SF_Aggregate))!=0    /* (17b) */\n       || (pSub1->pPrior && pSub1->op!=TK_ALL)                 /* (17a) */\n       || pSub1->pSrc->nSrc<1                                  /* (17c) */\n      ){\n        return 0;\n      }\n      testcase( pSub1->pSrc->nSrc>1 );\n    }\n\n    /* Restriction (18). */\n    if( p->pOrderBy ){\n      int ii;\n      for(ii=0; ii<p->pOrderBy->nExpr; ii++){\n        if( p->pOrderBy->a[ii].u.x.iOrderByCol==0 ) return 0;\n      }\n    }\n  }\n\n  /* Ex-restriction (23):\n  ** The only way that the recursive part of a CTE can contain a compound\n  ** subquery is for the subquery to be one term of a join.  But if the\n  ** subquery is a join, then the flattening has already been stopped by\n  ** restriction (17d3)\n  */\n  assert( (p->selFlags & SF_Recursive)==0 || pSub->pPrior==0 );\n\n  /***** If we reach this point, flattening is permitted. *****/\n  SELECTTRACE(1,pParse,p,(\"flatten %u.%p from term %d\\n\",\n                   pSub->selId, pSub, iFrom));\n\n  /* Authorize the subquery */\n  pParse->zAuthContext = pSubitem->zName;\n  TESTONLY(i =) sqlite3AuthCheck(pParse, SQLITE_SELECT, 0, 0, 0);\n  testcase( i==SQLITE_DENY );\n  pParse->zAuthContext = zSavedAuthContext;\n\n  /* If the sub-query is a compound SELECT statement, then (by restrictions\n  ** 17 and 18 above) it must be a UNION ALL and the parent query must \n  ** be of the form:\n  **\n  **     SELECT <expr-list> FROM (<sub-query>) <where-clause> \n  **\n  ** followed by any ORDER BY, LIMIT and/or OFFSET clauses. This block\n  ** creates N-1 copies of the parent query without any ORDER BY, LIMIT or \n  ** OFFSET clauses and joins them to the left-hand-side of the original\n  ** using UNION ALL operators. In this case N is the number of simple\n  ** select statements in the compound sub-query.\n  **\n  ** Example:\n  **\n  **     SELECT a+1 FROM (\n  **        SELECT x FROM tab\n  **        UNION ALL\n  **        SELECT y FROM tab\n  **        UNION ALL\n  **        SELECT abs(z*2) FROM tab2\n  **     ) WHERE a!=5 ORDER BY 1\n  **\n  ** Transformed into:\n  **\n  **     SELECT x+1 FROM tab WHERE x+1!=5\n  **     UNION ALL\n  **     SELECT y+1 FROM tab WHERE y+1!=5\n  **     UNION ALL\n  **     SELECT abs(z*2)+1 FROM tab2 WHERE abs(z*2)+1!=5\n  **     ORDER BY 1\n  **\n  ** We call this the \"compound-subquery flattening\".\n  */\n  for(pSub=pSub->pPrior; pSub; pSub=pSub->pPrior){\n    Select *pNew;\n    ExprList *pOrderBy = p->pOrderBy;\n    Expr *pLimit = p->pLimit;\n    Select *pPrior = p->pPrior;\n    p->pOrderBy = 0;\n    p->pSrc = 0;\n    p->pPrior = 0;\n    p->pLimit = 0;\n    pNew = sqlite3SelectDup(db, p, 0);\n    p->pLimit = pLimit;\n    p->pOrderBy = pOrderBy;\n    p->pSrc = pSrc;\n    p->op = TK_ALL;\n    if( pNew==0 ){\n      p->pPrior = pPrior;\n    }else{\n      pNew->pPrior = pPrior;\n      if( pPrior ) pPrior->pNext = pNew;\n      pNew->pNext = p;\n      p->pPrior = pNew;\n      SELECTTRACE(2,pParse,p,(\"compound-subquery flattener\"\n                              \" creates %u as peer\\n\",pNew->selId));\n    }\n    if( db->mallocFailed ) return 1;\n  }\n\n  /* Begin flattening the iFrom-th entry of the FROM clause \n  ** in the outer query.\n  */\n  pSub = pSub1 = pSubitem->pSelect;\n\n  /* Delete the transient table structure associated with the\n  ** subquery\n  */\n  sqlite3DbFree(db, pSubitem->zDatabase);\n  sqlite3DbFree(db, pSubitem->zName);\n  sqlite3DbFree(db, pSubitem->zAlias);\n  pSubitem->zDatabase = 0;\n  pSubitem->zName = 0;\n  pSubitem->zAlias = 0;\n  pSubitem->pSelect = 0;\n\n  /* Defer deleting the Table object associated with the\n  ** subquery until code generation is\n  ** complete, since there may still exist Expr.pTab entries that\n  ** refer to the subquery even after flattening.  Ticket #3346.\n  **\n  ** pSubitem->pTab is always non-NULL by test restrictions and tests above.\n  */\n  if( ALWAYS(pSubitem->pTab!=0) ){\n    Table *pTabToDel = pSubitem->pTab;\n    if( pTabToDel->nTabRef==1 ){\n      Parse *pToplevel = sqlite3ParseToplevel(pParse);\n      pTabToDel->pNextZombie = pToplevel->pZombieTab;\n      pToplevel->pZombieTab = pTabToDel;\n    }else{\n      pTabToDel->nTabRef--;\n    }\n    pSubitem->pTab = 0;\n  }\n\n  /* The following loop runs once for each term in a compound-subquery\n  ** flattening (as described above).  If we are doing a different kind\n  ** of flattening - a flattening other than a compound-subquery flattening -\n  ** then this loop only runs once.\n  **\n  ** This loop moves all of the FROM elements of the subquery into the\n  ** the FROM clause of the outer query.  Before doing this, remember\n  ** the cursor number for the original outer query FROM element in\n  ** iParent.  The iParent cursor will never be used.  Subsequent code\n  ** will scan expressions looking for iParent references and replace\n  ** those references with expressions that resolve to the subquery FROM\n  ** elements we are now copying in.\n  */\n  for(pParent=p; pParent; pParent=pParent->pPrior, pSub=pSub->pPrior){\n    int nSubSrc;\n    u8 jointype = 0;\n    pSubSrc = pSub->pSrc;     /* FROM clause of subquery */\n    nSubSrc = pSubSrc->nSrc;  /* Number of terms in subquery FROM clause */\n    pSrc = pParent->pSrc;     /* FROM clause of the outer query */\n\n    if( pSrc ){\n      assert( pParent==p );  /* First time through the loop */\n      jointype = pSubitem->fg.jointype;\n    }else{\n      assert( pParent!=p );  /* 2nd and subsequent times through the loop */\n      pSrc = sqlite3SrcListAppend(pParse, 0, 0, 0);\n      if( pSrc==0 ) break;\n      pParent->pSrc = pSrc;\n    }\n\n    /* The subquery uses a single slot of the FROM clause of the outer\n    ** query.  If the subquery has more than one element in its FROM clause,\n    ** then expand the outer query to make space for it to hold all elements\n    ** of the subquery.\n    **\n    ** Example:\n    **\n    **    SELECT * FROM tabA, (SELECT * FROM sub1, sub2), tabB;\n    **\n    ** The outer query has 3 slots in its FROM clause.  One slot of the\n    ** outer query (the middle slot) is used by the subquery.  The next\n    ** block of code will expand the outer query FROM clause to 4 slots.\n    ** The middle slot is expanded to two slots in order to make space\n    ** for the two elements in the FROM clause of the subquery.\n    */\n    if( nSubSrc>1 ){\n      pSrc = sqlite3SrcListEnlarge(pParse, pSrc, nSubSrc-1,iFrom+1);\n      if( pSrc==0 ) break;\n      pParent->pSrc = pSrc;\n    }\n\n    /* Transfer the FROM clause terms from the subquery into the\n    ** outer query.\n    */\n    for(i=0; i<nSubSrc; i++){\n      sqlite3IdListDelete(db, pSrc->a[i+iFrom].pUsing);\n      assert( pSrc->a[i+iFrom].fg.isTabFunc==0 );\n      pSrc->a[i+iFrom] = pSubSrc->a[i];\n      iNewParent = pSubSrc->a[i].iCursor;\n      memset(&pSubSrc->a[i], 0, sizeof(pSubSrc->a[i]));\n    }\n    pSrc->a[iFrom].fg.jointype = jointype;\n  \n    /* Now begin substituting subquery result set expressions for \n    ** references to the iParent in the outer query.\n    ** \n    ** Example:\n    **\n    **   SELECT a+5, b*10 FROM (SELECT x*3 AS a, y+10 AS b FROM t1) WHERE a>b;\n    **   \\                     \\_____________ subquery __________/          /\n    **    \\_____________________ outer query ______________________________/\n    **\n    ** We look at every expression in the outer query and every place we see\n    ** \"a\" we substitute \"x*3\" and every place we see \"b\" we substitute \"y+10\".\n    */\n    if( pSub->pOrderBy ){\n      /* At this point, any non-zero iOrderByCol values indicate that the\n      ** ORDER BY column expression is identical to the iOrderByCol'th\n      ** expression returned by SELECT statement pSub. Since these values\n      ** do not necessarily correspond to columns in SELECT statement pParent,\n      ** zero them before transfering the ORDER BY clause.\n      **\n      ** Not doing this may cause an error if a subsequent call to this\n      ** function attempts to flatten a compound sub-query into pParent\n      ** (the only way this can happen is if the compound sub-query is\n      ** currently part of pSub->pSrc). See ticket [d11a6e908f].  */\n      ExprList *pOrderBy = pSub->pOrderBy;\n      for(i=0; i<pOrderBy->nExpr; i++){\n        pOrderBy->a[i].u.x.iOrderByCol = 0;\n      }\n      assert( pParent->pOrderBy==0 );\n      pParent->pOrderBy = pOrderBy;\n      pSub->pOrderBy = 0;\n    }\n    pWhere = pSub->pWhere;\n    pSub->pWhere = 0;\n    if( isLeftJoin>0 ){\n      setJoinExpr(pWhere, iNewParent);\n    }\n    pParent->pWhere = sqlite3ExprAnd(db, pWhere, pParent->pWhere);\n    if( db->mallocFailed==0 ){\n      SubstContext x;\n      x.pParse = pParse;\n      x.iTable = iParent;\n      x.iNewTable = iNewParent;\n      x.isLeftJoin = isLeftJoin;\n      x.pEList = pSub->pEList;\n      substSelect(&x, pParent, 0);\n    }\n  \n    /* The flattened query is distinct if either the inner or the\n    ** outer query is distinct. \n    */\n    pParent->selFlags |= pSub->selFlags & SF_Distinct;\n  \n    /*\n    ** SELECT ... FROM (SELECT ... LIMIT a OFFSET b) LIMIT x OFFSET y;\n    **\n    ** One is tempted to try to add a and b to combine the limits.  But this\n    ** does not work if either limit is negative.\n    */\n    if( pSub->pLimit ){\n      pParent->pLimit = pSub->pLimit;\n      pSub->pLimit = 0;\n    }\n  }\n\n  /* Finially, delete what is left of the subquery and return\n  ** success.\n  */\n  sqlite3SelectDelete(db, pSub1);\n\n#if SELECTTRACE_ENABLED\n  if( sqlite3SelectTrace & 0x100 ){\n    SELECTTRACE(0x100,pParse,p,(\"After flattening:\\n\"));\n    sqlite3TreeViewSelect(0, p, 0);\n  }\n#endif\n\n  return 1;\n}\n#endif /* !defined(SQLITE_OMIT_SUBQUERY) || !defined(SQLITE_OMIT_VIEW) */\n\n/*\n** A structure to keep track of all of the column values that are fixed to\n** a known value due to WHERE clause constraints of the form COLUMN=VALUE.\n*/\ntypedef struct WhereConst WhereConst;\nstruct WhereConst {\n  Parse *pParse;   /* Parsing context */\n  int nConst;      /* Number for COLUMN=CONSTANT terms */\n  int nChng;       /* Number of times a constant is propagated */\n  Expr **apExpr;   /* [i*2] is COLUMN and [i*2+1] is VALUE */\n};\n\n/*\n** Add a new entry to the pConst object.  Except, do not add duplicate\n** pColumn entires.\n*/\nstatic void constInsert(\n  WhereConst *pConst,      /* The WhereConst into which we are inserting */\n  Expr *pColumn,           /* The COLUMN part of the constraint */\n  Expr *pValue             /* The VALUE part of the constraint */\n){\n  int i;\n  assert( pColumn->op==TK_COLUMN );\n\n  /* 2018-10-25 ticket [cf5ed20f]\n  ** Make sure the same pColumn is not inserted more than once */\n  for(i=0; i<pConst->nConst; i++){\n    const Expr *pExpr = pConst->apExpr[i*2];\n    assert( pExpr->op==TK_COLUMN );\n    if( pExpr->iTable==pColumn->iTable\n     && pExpr->iColumn==pColumn->iColumn\n    ){\n      return;  /* Already present.  Return without doing anything. */\n    }\n  }\n\n  pConst->nConst++;\n  pConst->apExpr = sqlite3DbReallocOrFree(pConst->pParse->db, pConst->apExpr,\n                         pConst->nConst*2*sizeof(Expr*));\n  if( pConst->apExpr==0 ){\n    pConst->nConst = 0;\n  }else{\n    if( ExprHasProperty(pValue, EP_FixedCol) ) pValue = pValue->pLeft;\n    pConst->apExpr[pConst->nConst*2-2] = pColumn;\n    pConst->apExpr[pConst->nConst*2-1] = pValue;\n  }\n}\n\n/*\n** Find all terms of COLUMN=VALUE or VALUE=COLUMN in pExpr where VALUE\n** is a constant expression and where the term must be true because it\n** is part of the AND-connected terms of the expression.  For each term\n** found, add it to the pConst structure.\n*/\nstatic void findConstInWhere(WhereConst *pConst, Expr *pExpr){\n  Expr *pRight, *pLeft;\n  if( pExpr==0 ) return;\n  if( ExprHasProperty(pExpr, EP_FromJoin) ) return;\n  if( pExpr->op==TK_AND ){\n    findConstInWhere(pConst, pExpr->pRight);\n    findConstInWhere(pConst, pExpr->pLeft);\n    return;\n  }\n  if( pExpr->op!=TK_EQ ) return;\n  pRight = pExpr->pRight;\n  pLeft = pExpr->pLeft;\n  assert( pRight!=0 );\n  assert( pLeft!=0 );\n  if( pRight->op==TK_COLUMN\n   && !ExprHasProperty(pRight, EP_FixedCol)\n   && sqlite3ExprIsConstant(pLeft)\n   && sqlite3IsBinary(sqlite3BinaryCompareCollSeq(pConst->pParse,pLeft,pRight))\n  ){\n    constInsert(pConst, pRight, pLeft);\n  }else\n  if( pLeft->op==TK_COLUMN\n   && !ExprHasProperty(pLeft, EP_FixedCol)\n   && sqlite3ExprIsConstant(pRight)\n   && sqlite3IsBinary(sqlite3BinaryCompareCollSeq(pConst->pParse,pLeft,pRight))\n  ){\n    constInsert(pConst, pLeft, pRight);\n  }\n}\n\n/*\n** This is a Walker expression callback.  pExpr is a candidate expression\n** to be replaced by a value.  If pExpr is equivalent to one of the\n** columns named in pWalker->u.pConst, then overwrite it with its\n** corresponding value.\n*/\nstatic int propagateConstantExprRewrite(Walker *pWalker, Expr *pExpr){\n  int i;\n  WhereConst *pConst;\n  if( pExpr->op!=TK_COLUMN ) return WRC_Continue;\n  if( ExprHasProperty(pExpr, EP_FixedCol) ) return WRC_Continue;\n  pConst = pWalker->u.pConst;\n  for(i=0; i<pConst->nConst; i++){\n    Expr *pColumn = pConst->apExpr[i*2];\n    if( pColumn==pExpr ) continue;\n    if( pColumn->iTable!=pExpr->iTable ) continue;\n    if( pColumn->iColumn!=pExpr->iColumn ) continue;\n    /* A match is found.  Add the EP_FixedCol property */\n    pConst->nChng++;\n    ExprClearProperty(pExpr, EP_Leaf);\n    ExprSetProperty(pExpr, EP_FixedCol);\n    assert( pExpr->pLeft==0 );\n    pExpr->pLeft = sqlite3ExprDup(pConst->pParse->db, pConst->apExpr[i*2+1], 0);\n    break;\n  }\n  return WRC_Prune;\n}\n\n/*\n** The WHERE-clause constant propagation optimization.\n**\n** If the WHERE clause contains terms of the form COLUMN=CONSTANT or\n** CONSTANT=COLUMN that must be tree (in other words, if the terms top-level\n** AND-connected terms that are not part of a ON clause from a LEFT JOIN)\n** then throughout the query replace all other occurrences of COLUMN\n** with CONSTANT within the WHERE clause.\n**\n** For example, the query:\n**\n**      SELECT * FROM t1, t2, t3 WHERE t1.a=39 AND t2.b=t1.a AND t3.c=t2.b\n**\n** Is transformed into\n**\n**      SELECT * FROM t1, t2, t3 WHERE t1.a=39 AND t2.b=39 AND t3.c=39\n**\n** Return true if any transformations where made and false if not.\n**\n** Implementation note:  Constant propagation is tricky due to affinity\n** and collating sequence interactions.  Consider this example:\n**\n**    CREATE TABLE t1(a INT,b TEXT);\n**    INSERT INTO t1 VALUES(123,'0123');\n**    SELECT * FROM t1 WHERE a=123 AND b=a;\n**    SELECT * FROM t1 WHERE a=123 AND b=123;\n**\n** The two SELECT statements above should return different answers.  b=a\n** is alway true because the comparison uses numeric affinity, but b=123\n** is false because it uses text affinity and '0123' is not the same as '123'.\n** To work around this, the expression tree is not actually changed from\n** \"b=a\" to \"b=123\" but rather the \"a\" in \"b=a\" is tagged with EP_FixedCol\n** and the \"123\" value is hung off of the pLeft pointer.  Code generator\n** routines know to generate the constant \"123\" instead of looking up the\n** column value.  Also, to avoid collation problems, this optimization is\n** only attempted if the \"a=123\" term uses the default BINARY collation.\n*/\nstatic int propagateConstants(\n  Parse *pParse,   /* The parsing context */\n  Select *p        /* The query in which to propagate constants */\n){\n  WhereConst x;\n  Walker w;\n  int nChng = 0;\n  x.pParse = pParse;\n  do{\n    x.nConst = 0;\n    x.nChng = 0;\n    x.apExpr = 0;\n    findConstInWhere(&x, p->pWhere);\n    if( x.nConst ){\n      memset(&w, 0, sizeof(w));\n      w.pParse = pParse;\n      w.xExprCallback = propagateConstantExprRewrite;\n      w.xSelectCallback = sqlite3SelectWalkNoop;\n      w.xSelectCallback2 = 0;\n      w.walkerDepth = 0;\n      w.u.pConst = &x;\n      sqlite3WalkExpr(&w, p->pWhere);\n      sqlite3DbFree(x.pParse->db, x.apExpr);\n      nChng += x.nChng;\n    }\n  }while( x.nChng );  \n  return nChng;\n}\n\n#if !defined(SQLITE_OMIT_SUBQUERY) || !defined(SQLITE_OMIT_VIEW)\n/*\n** Make copies of relevant WHERE clause terms of the outer query into\n** the WHERE clause of subquery.  Example:\n**\n**    SELECT * FROM (SELECT a AS x, c-d AS y FROM t1) WHERE x=5 AND y=10;\n**\n** Transformed into:\n**\n**    SELECT * FROM (SELECT a AS x, c-d AS y FROM t1 WHERE a=5 AND c-d=10)\n**     WHERE x=5 AND y=10;\n**\n** The hope is that the terms added to the inner query will make it more\n** efficient.\n**\n** Do not attempt this optimization if:\n**\n**   (1) (** This restriction was removed on 2017-09-29.  We used to\n**           disallow this optimization for aggregate subqueries, but now\n**           it is allowed by putting the extra terms on the HAVING clause.\n**           The added HAVING clause is pointless if the subquery lacks\n**           a GROUP BY clause.  But such a HAVING clause is also harmless\n**           so there does not appear to be any reason to add extra logic\n**           to suppress it. **)\n**\n**   (2) The inner query is the recursive part of a common table expression.\n**\n**   (3) The inner query has a LIMIT clause (since the changes to the WHERE\n**       clause would change the meaning of the LIMIT).\n**\n**   (4) The inner query is the right operand of a LEFT JOIN and the\n**       expression to be pushed down does not come from the ON clause\n**       on that LEFT JOIN.\n**\n**   (5) The WHERE clause expression originates in the ON or USING clause\n**       of a LEFT JOIN where iCursor is not the right-hand table of that\n**       left join.  An example:\n**\n**           SELECT *\n**           FROM (SELECT 1 AS a1 UNION ALL SELECT 2) AS aa\n**           JOIN (SELECT 1 AS b2 UNION ALL SELECT 2) AS bb ON (a1=b2)\n**           LEFT JOIN (SELECT 8 AS c3 UNION ALL SELECT 9) AS cc ON (b2=2);\n**\n**       The correct answer is three rows:  (1,1,NULL),(2,2,8),(2,2,9).\n**       But if the (b2=2) term were to be pushed down into the bb subquery,\n**       then the (1,1,NULL) row would be suppressed.\n**\n**   (6) The inner query features one or more window-functions (since \n**       changes to the WHERE clause of the inner query could change the \n**       window over which window functions are calculated).\n**\n** Return 0 if no changes are made and non-zero if one or more WHERE clause\n** terms are duplicated into the subquery.\n*/\nstatic int pushDownWhereTerms(\n  Parse *pParse,        /* Parse context (for malloc() and error reporting) */\n  Select *pSubq,        /* The subquery whose WHERE clause is to be augmented */\n  Expr *pWhere,         /* The WHERE clause of the outer query */\n  int iCursor,          /* Cursor number of the subquery */\n  int isLeftJoin        /* True if pSubq is the right term of a LEFT JOIN */\n){\n  Expr *pNew;\n  int nChng = 0;\n  if( pWhere==0 ) return 0;\n  if( pSubq->selFlags & SF_Recursive ) return 0;  /* restriction (2) */\n\n#ifndef SQLITE_OMIT_WINDOWFUNC\n  if( pSubq->pWin ) return 0;    /* restriction (6) */\n#endif\n\n#ifdef SQLITE_DEBUG\n  /* Only the first term of a compound can have a WITH clause.  But make\n  ** sure no other terms are marked SF_Recursive in case something changes\n  ** in the future.\n  */\n  {\n    Select *pX;  \n    for(pX=pSubq; pX; pX=pX->pPrior){\n      assert( (pX->selFlags & (SF_Recursive))==0 );\n    }\n  }\n#endif\n\n  if( pSubq->pLimit!=0 ){\n    return 0; /* restriction (3) */\n  }\n  while( pWhere->op==TK_AND ){\n    nChng += pushDownWhereTerms(pParse, pSubq, pWhere->pRight,\n                                iCursor, isLeftJoin);\n    pWhere = pWhere->pLeft;\n  }\n  if( isLeftJoin\n   && (ExprHasProperty(pWhere,EP_FromJoin)==0\n         || pWhere->iRightJoinTable!=iCursor)\n  ){\n    return 0; /* restriction (4) */\n  }\n  if( ExprHasProperty(pWhere,EP_FromJoin) && pWhere->iRightJoinTable!=iCursor ){\n    return 0; /* restriction (5) */\n  }\n  if( sqlite3ExprIsTableConstant(pWhere, iCursor) ){\n    nChng++;\n    while( pSubq ){\n      SubstContext x;\n      pNew = sqlite3ExprDup(pParse->db, pWhere, 0);\n      unsetJoinExpr(pNew, -1);\n      x.pParse = pParse;\n      x.iTable = iCursor;\n      x.iNewTable = iCursor;\n      x.isLeftJoin = 0;\n      x.pEList = pSubq->pEList;\n      pNew = substExpr(&x, pNew);\n      if( pSubq->selFlags & SF_Aggregate ){\n        pSubq->pHaving = sqlite3ExprAnd(pParse->db, pSubq->pHaving, pNew);\n      }else{\n        pSubq->pWhere = sqlite3ExprAnd(pParse->db, pSubq->pWhere, pNew);\n      }\n      pSubq = pSubq->pPrior;\n    }\n  }\n  return nChng;\n}\n#endif /* !defined(SQLITE_OMIT_SUBQUERY) || !defined(SQLITE_OMIT_VIEW) */\n\n/*\n** The pFunc is the only aggregate function in the query.  Check to see\n** if the query is a candidate for the min/max optimization. \n**\n** If the query is a candidate for the min/max optimization, then set\n** *ppMinMax to be an ORDER BY clause to be used for the optimization\n** and return either WHERE_ORDERBY_MIN or WHERE_ORDERBY_MAX depending on\n** whether pFunc is a min() or max() function.\n**\n** If the query is not a candidate for the min/max optimization, return\n** WHERE_ORDERBY_NORMAL (which must be zero).\n**\n** This routine must be called after aggregate functions have been\n** located but before their arguments have been subjected to aggregate\n** analysis.\n*/\nstatic u8 minMaxQuery(sqlite3 *db, Expr *pFunc, ExprList **ppMinMax){\n  int eRet = WHERE_ORDERBY_NORMAL;      /* Return value */\n  ExprList *pEList = pFunc->x.pList;    /* Arguments to agg function */\n  const char *zFunc;                    /* Name of aggregate function pFunc */\n  ExprList *pOrderBy;\n  u8 sortOrder;\n\n  assert( *ppMinMax==0 );\n  assert( pFunc->op==TK_AGG_FUNCTION );\n  if( pEList==0 || pEList->nExpr!=1 ) return eRet;\n  zFunc = pFunc->u.zToken;\n  if( sqlite3StrICmp(zFunc, \"min\")==0 ){\n    eRet = WHERE_ORDERBY_MIN;\n    sortOrder = SQLITE_SO_ASC;\n  }else if( sqlite3StrICmp(zFunc, \"max\")==0 ){\n    eRet = WHERE_ORDERBY_MAX;\n    sortOrder = SQLITE_SO_DESC;\n  }else{\n    return eRet;\n  }\n  *ppMinMax = pOrderBy = sqlite3ExprListDup(db, pEList, 0);\n  assert( pOrderBy!=0 || db->mallocFailed );\n  if( pOrderBy ) pOrderBy->a[0].sortOrder = sortOrder;\n  return eRet;\n}\n\n/*\n** The select statement passed as the first argument is an aggregate query.\n** The second argument is the associated aggregate-info object. This \n** function tests if the SELECT is of the form:\n**\n**   SELECT count(*) FROM <tbl>\n**\n** where table is a database table, not a sub-select or view. If the query\n** does match this pattern, then a pointer to the Table object representing\n** <tbl> is returned. Otherwise, 0 is returned.\n*/\nstatic Table *isSimpleCount(Select *p, AggInfo *pAggInfo){\n  Table *pTab;\n  Expr *pExpr;\n\n  assert( !p->pGroupBy );\n\n  if( p->pWhere || p->pEList->nExpr!=1 \n   || p->pSrc->nSrc!=1 || p->pSrc->a[0].pSelect\n  ){\n    return 0;\n  }\n  pTab = p->pSrc->a[0].pTab;\n  pExpr = p->pEList->a[0].pExpr;\n  assert( pTab && !pTab->pSelect && pExpr );\n\n  if( IsVirtual(pTab) ) return 0;\n  if( pExpr->op!=TK_AGG_FUNCTION ) return 0;\n  if( NEVER(pAggInfo->nFunc==0) ) return 0;\n  if( (pAggInfo->aFunc[0].pFunc->funcFlags&SQLITE_FUNC_COUNT)==0 ) return 0;\n  if( pExpr->flags&EP_Distinct ) return 0;\n\n  return pTab;\n}\n\n/*\n** If the source-list item passed as an argument was augmented with an\n** INDEXED BY clause, then try to locate the specified index. If there\n** was such a clause and the named index cannot be found, return \n** SQLITE_ERROR and leave an error in pParse. Otherwise, populate \n** pFrom->pIndex and return SQLITE_OK.\n*/\nSQLITE_PRIVATE int sqlite3IndexedByLookup(Parse *pParse, struct SrcList_item *pFrom){\n  if( pFrom->pTab && pFrom->fg.isIndexedBy ){\n    Table *pTab = pFrom->pTab;\n    char *zIndexedBy = pFrom->u1.zIndexedBy;\n    Index *pIdx;\n    for(pIdx=pTab->pIndex; \n        pIdx && sqlite3StrICmp(pIdx->zName, zIndexedBy); \n        pIdx=pIdx->pNext\n    );\n    if( !pIdx ){\n      sqlite3ErrorMsg(pParse, \"no such index: %s\", zIndexedBy, 0);\n      pParse->checkSchema = 1;\n      return SQLITE_ERROR;\n    }\n    pFrom->pIBIndex = pIdx;\n  }\n  return SQLITE_OK;\n}\n/*\n** Detect compound SELECT statements that use an ORDER BY clause with \n** an alternative collating sequence.\n**\n**    SELECT ... FROM t1 EXCEPT SELECT ... FROM t2 ORDER BY .. COLLATE ...\n**\n** These are rewritten as a subquery:\n**\n**    SELECT * FROM (SELECT ... FROM t1 EXCEPT SELECT ... FROM t2)\n**     ORDER BY ... COLLATE ...\n**\n** This transformation is necessary because the multiSelectOrderBy() routine\n** above that generates the code for a compound SELECT with an ORDER BY clause\n** uses a merge algorithm that requires the same collating sequence on the\n** result columns as on the ORDER BY clause.  See ticket\n** http://www.sqlite.org/src/info/6709574d2a\n**\n** This transformation is only needed for EXCEPT, INTERSECT, and UNION.\n** The UNION ALL operator works fine with multiSelectOrderBy() even when\n** there are COLLATE terms in the ORDER BY.\n*/\nstatic int convertCompoundSelectToSubquery(Walker *pWalker, Select *p){\n  int i;\n  Select *pNew;\n  Select *pX;\n  sqlite3 *db;\n  struct ExprList_item *a;\n  SrcList *pNewSrc;\n  Parse *pParse;\n  Token dummy;\n\n  if( p->pPrior==0 ) return WRC_Continue;\n  if( p->pOrderBy==0 ) return WRC_Continue;\n  for(pX=p; pX && (pX->op==TK_ALL || pX->op==TK_SELECT); pX=pX->pPrior){}\n  if( pX==0 ) return WRC_Continue;\n  a = p->pOrderBy->a;\n  for(i=p->pOrderBy->nExpr-1; i>=0; i--){\n    if( a[i].pExpr->flags & EP_Collate ) break;\n  }\n  if( i<0 ) return WRC_Continue;\n\n  /* If we reach this point, that means the transformation is required. */\n\n  pParse = pWalker->pParse;\n  db = pParse->db;\n  pNew = sqlite3DbMallocZero(db, sizeof(*pNew) );\n  if( pNew==0 ) return WRC_Abort;\n  memset(&dummy, 0, sizeof(dummy));\n  pNewSrc = sqlite3SrcListAppendFromTerm(pParse,0,0,0,&dummy,pNew,0,0);\n  if( pNewSrc==0 ) return WRC_Abort;\n  *pNew = *p;\n  p->pSrc = pNewSrc;\n  p->pEList = sqlite3ExprListAppend(pParse, 0, sqlite3Expr(db, TK_ASTERISK, 0));\n  p->op = TK_SELECT;\n  p->pWhere = 0;\n  pNew->pGroupBy = 0;\n  pNew->pHaving = 0;\n  pNew->pOrderBy = 0;\n  p->pPrior = 0;\n  p->pNext = 0;\n  p->pWith = 0;\n  p->selFlags &= ~SF_Compound;\n  assert( (p->selFlags & SF_Converted)==0 );\n  p->selFlags |= SF_Converted;\n  assert( pNew->pPrior!=0 );\n  pNew->pPrior->pNext = pNew;\n  pNew->pLimit = 0;\n  return WRC_Continue;\n}\n\n/*\n** Check to see if the FROM clause term pFrom has table-valued function\n** arguments.  If it does, leave an error message in pParse and return\n** non-zero, since pFrom is not allowed to be a table-valued function.\n*/\nstatic int cannotBeFunction(Parse *pParse, struct SrcList_item *pFrom){\n  if( pFrom->fg.isTabFunc ){\n    sqlite3ErrorMsg(pParse, \"'%s' is not a function\", pFrom->zName);\n    return 1;\n  }\n  return 0;\n}\n\n#ifndef SQLITE_OMIT_CTE\n/*\n** Argument pWith (which may be NULL) points to a linked list of nested \n** WITH contexts, from inner to outermost. If the table identified by \n** FROM clause element pItem is really a common-table-expression (CTE) \n** then return a pointer to the CTE definition for that table. Otherwise\n** return NULL.\n**\n** If a non-NULL value is returned, set *ppContext to point to the With\n** object that the returned CTE belongs to.\n*/\nstatic struct Cte *searchWith(\n  With *pWith,                    /* Current innermost WITH clause */\n  struct SrcList_item *pItem,     /* FROM clause element to resolve */\n  With **ppContext                /* OUT: WITH clause return value belongs to */\n){\n  const char *zName;\n  if( pItem->zDatabase==0 && (zName = pItem->zName)!=0 ){\n    With *p;\n    for(p=pWith; p; p=p->pOuter){\n      int i;\n      for(i=0; i<p->nCte; i++){\n        if( sqlite3StrICmp(zName, p->a[i].zName)==0 ){\n          *ppContext = p;\n          return &p->a[i];\n        }\n      }\n    }\n  }\n  return 0;\n}\n\n/* The code generator maintains a stack of active WITH clauses\n** with the inner-most WITH clause being at the top of the stack.\n**\n** This routine pushes the WITH clause passed as the second argument\n** onto the top of the stack. If argument bFree is true, then this\n** WITH clause will never be popped from the stack. In this case it\n** should be freed along with the Parse object. In other cases, when\n** bFree==0, the With object will be freed along with the SELECT \n** statement with which it is associated.\n*/\nSQLITE_PRIVATE void sqlite3WithPush(Parse *pParse, With *pWith, u8 bFree){\n  assert( bFree==0 || (pParse->pWith==0 && pParse->pWithToFree==0) );\n  if( pWith ){\n    assert( pParse->pWith!=pWith );\n    pWith->pOuter = pParse->pWith;\n    pParse->pWith = pWith;\n    if( bFree ) pParse->pWithToFree = pWith;\n  }\n}\n\n/*\n** This function checks if argument pFrom refers to a CTE declared by \n** a WITH clause on the stack currently maintained by the parser. And,\n** if currently processing a CTE expression, if it is a recursive\n** reference to the current CTE.\n**\n** If pFrom falls into either of the two categories above, pFrom->pTab\n** and other fields are populated accordingly. The caller should check\n** (pFrom->pTab!=0) to determine whether or not a successful match\n** was found.\n**\n** Whether or not a match is found, SQLITE_OK is returned if no error\n** occurs. If an error does occur, an error message is stored in the\n** parser and some error code other than SQLITE_OK returned.\n*/\nstatic int withExpand(\n  Walker *pWalker, \n  struct SrcList_item *pFrom\n){\n  Parse *pParse = pWalker->pParse;\n  sqlite3 *db = pParse->db;\n  struct Cte *pCte;               /* Matched CTE (or NULL if no match) */\n  With *pWith;                    /* WITH clause that pCte belongs to */\n\n  assert( pFrom->pTab==0 );\n\n  pCte = searchWith(pParse->pWith, pFrom, &pWith);\n  if( pCte ){\n    Table *pTab;\n    ExprList *pEList;\n    Select *pSel;\n    Select *pLeft;                /* Left-most SELECT statement */\n    int bMayRecursive;            /* True if compound joined by UNION [ALL] */\n    With *pSavedWith;             /* Initial value of pParse->pWith */\n\n    /* If pCte->zCteErr is non-NULL at this point, then this is an illegal\n    ** recursive reference to CTE pCte. Leave an error in pParse and return\n    ** early. If pCte->zCteErr is NULL, then this is not a recursive reference.\n    ** In this case, proceed.  */\n    if( pCte->zCteErr ){\n      sqlite3ErrorMsg(pParse, pCte->zCteErr, pCte->zName);\n      return SQLITE_ERROR;\n    }\n    if( cannotBeFunction(pParse, pFrom) ) return SQLITE_ERROR;\n\n    assert( pFrom->pTab==0 );\n    pFrom->pTab = pTab = sqlite3DbMallocZero(db, sizeof(Table));\n    if( pTab==0 ) return WRC_Abort;\n    pTab->nTabRef = 1;\n    pTab->zName = sqlite3DbStrDup(db, pCte->zName);\n    pTab->iPKey = -1;\n    pTab->nRowLogEst = 200; assert( 200==sqlite3LogEst(1048576) );\n    pTab->tabFlags |= TF_Ephemeral | TF_NoVisibleRowid;\n    pFrom->pSelect = sqlite3SelectDup(db, pCte->pSelect, 0);\n    if( db->mallocFailed ) return SQLITE_NOMEM_BKPT;\n    assert( pFrom->pSelect );\n\n    /* Check if this is a recursive CTE. */\n    pSel = pFrom->pSelect;\n    bMayRecursive = ( pSel->op==TK_ALL || pSel->op==TK_UNION );\n    if( bMayRecursive ){\n      int i;\n      SrcList *pSrc = pFrom->pSelect->pSrc;\n      for(i=0; i<pSrc->nSrc; i++){\n        struct SrcList_item *pItem = &pSrc->a[i];\n        if( pItem->zDatabase==0 \n         && pItem->zName!=0 \n         && 0==sqlite3StrICmp(pItem->zName, pCte->zName)\n          ){\n          pItem->pTab = pTab;\n          pItem->fg.isRecursive = 1;\n          pTab->nTabRef++;\n          pSel->selFlags |= SF_Recursive;\n        }\n      }\n    }\n\n    /* Only one recursive reference is permitted. */ \n    if( pTab->nTabRef>2 ){\n      sqlite3ErrorMsg(\n          pParse, \"multiple references to recursive table: %s\", pCte->zName\n      );\n      return SQLITE_ERROR;\n    }\n    assert( pTab->nTabRef==1 || \n            ((pSel->selFlags&SF_Recursive) && pTab->nTabRef==2 ));\n\n    pCte->zCteErr = \"circular reference: %s\";\n    pSavedWith = pParse->pWith;\n    pParse->pWith = pWith;\n    if( bMayRecursive ){\n      Select *pPrior = pSel->pPrior;\n      assert( pPrior->pWith==0 );\n      pPrior->pWith = pSel->pWith;\n      sqlite3WalkSelect(pWalker, pPrior);\n      pPrior->pWith = 0;\n    }else{\n      sqlite3WalkSelect(pWalker, pSel);\n    }\n    pParse->pWith = pWith;\n\n    for(pLeft=pSel; pLeft->pPrior; pLeft=pLeft->pPrior);\n    pEList = pLeft->pEList;\n    if( pCte->pCols ){\n      if( pEList && pEList->nExpr!=pCte->pCols->nExpr ){\n        sqlite3ErrorMsg(pParse, \"table %s has %d values for %d columns\",\n            pCte->zName, pEList->nExpr, pCte->pCols->nExpr\n        );\n        pParse->pWith = pSavedWith;\n        return SQLITE_ERROR;\n      }\n      pEList = pCte->pCols;\n    }\n\n    sqlite3ColumnsFromExprList(pParse, pEList, &pTab->nCol, &pTab->aCol);\n    if( bMayRecursive ){\n      if( pSel->selFlags & SF_Recursive ){\n        pCte->zCteErr = \"multiple recursive references: %s\";\n      }else{\n        pCte->zCteErr = \"recursive reference in a subquery: %s\";\n      }\n      sqlite3WalkSelect(pWalker, pSel);\n    }\n    pCte->zCteErr = 0;\n    pParse->pWith = pSavedWith;\n  }\n\n  return SQLITE_OK;\n}\n#endif\n\n#ifndef SQLITE_OMIT_CTE\n/*\n** If the SELECT passed as the second argument has an associated WITH \n** clause, pop it from the stack stored as part of the Parse object.\n**\n** This function is used as the xSelectCallback2() callback by\n** sqlite3SelectExpand() when walking a SELECT tree to resolve table\n** names and other FROM clause elements. \n*/\nstatic void selectPopWith(Walker *pWalker, Select *p){\n  Parse *pParse = pWalker->pParse;\n  if( OK_IF_ALWAYS_TRUE(pParse->pWith) && p->pPrior==0 ){\n    With *pWith = findRightmost(p)->pWith;\n    if( pWith!=0 ){\n      assert( pParse->pWith==pWith );\n      pParse->pWith = pWith->pOuter;\n    }\n  }\n}\n#else\n#define selectPopWith 0\n#endif\n\n/*\n** The SrcList_item structure passed as the second argument represents a\n** sub-query in the FROM clause of a SELECT statement. This function\n** allocates and populates the SrcList_item.pTab object. If successful,\n** SQLITE_OK is returned. Otherwise, if an OOM error is encountered,\n** SQLITE_NOMEM.\n*/\nSQLITE_PRIVATE int sqlite3ExpandSubquery(Parse *pParse, struct SrcList_item *pFrom){\n  Select *pSel = pFrom->pSelect;\n  Table *pTab;\n\n  assert( pSel );\n  pFrom->pTab = pTab = sqlite3DbMallocZero(pParse->db, sizeof(Table));\n  if( pTab==0 ) return SQLITE_NOMEM;\n  pTab->nTabRef = 1;\n  if( pFrom->zAlias ){\n    pTab->zName = sqlite3DbStrDup(pParse->db, pFrom->zAlias);\n  }else{\n    pTab->zName = sqlite3MPrintf(pParse->db, \"subquery_%u\", pSel->selId);\n  }\n  while( pSel->pPrior ){ pSel = pSel->pPrior; }\n  sqlite3ColumnsFromExprList(pParse, pSel->pEList,&pTab->nCol,&pTab->aCol);\n  pTab->iPKey = -1;\n  pTab->nRowLogEst = 200; assert( 200==sqlite3LogEst(1048576) );\n  pTab->tabFlags |= TF_Ephemeral;\n\n  return SQLITE_OK;\n}\n\n/*\n** This routine is a Walker callback for \"expanding\" a SELECT statement.\n** \"Expanding\" means to do the following:\n**\n**    (1)  Make sure VDBE cursor numbers have been assigned to every\n**         element of the FROM clause.\n**\n**    (2)  Fill in the pTabList->a[].pTab fields in the SrcList that \n**         defines FROM clause.  When views appear in the FROM clause,\n**         fill pTabList->a[].pSelect with a copy of the SELECT statement\n**         that implements the view.  A copy is made of the view's SELECT\n**         statement so that we can freely modify or delete that statement\n**         without worrying about messing up the persistent representation\n**         of the view.\n**\n**    (3)  Add terms to the WHERE clause to accommodate the NATURAL keyword\n**         on joins and the ON and USING clause of joins.\n**\n**    (4)  Scan the list of columns in the result set (pEList) looking\n**         for instances of the \"*\" operator or the TABLE.* operator.\n**         If found, expand each \"*\" to be every column in every table\n**         and TABLE.* to be every column in TABLE.\n**\n*/\nstatic int selectExpander(Walker *pWalker, Select *p){\n  Parse *pParse = pWalker->pParse;\n  int i, j, k;\n  SrcList *pTabList;\n  ExprList *pEList;\n  struct SrcList_item *pFrom;\n  sqlite3 *db = pParse->db;\n  Expr *pE, *pRight, *pExpr;\n  u16 selFlags = p->selFlags;\n  u32 elistFlags = 0;\n\n  p->selFlags |= SF_Expanded;\n  if( db->mallocFailed  ){\n    return WRC_Abort;\n  }\n  assert( p->pSrc!=0 );\n  if( (selFlags & SF_Expanded)!=0 ){\n    return WRC_Prune;\n  }\n  pTabList = p->pSrc;\n  pEList = p->pEList;\n  sqlite3WithPush(pParse, p->pWith, 0);\n\n  /* Make sure cursor numbers have been assigned to all entries in\n  ** the FROM clause of the SELECT statement.\n  */\n  sqlite3SrcListAssignCursors(pParse, pTabList);\n\n  /* Look up every table named in the FROM clause of the select.  If\n  ** an entry of the FROM clause is a subquery instead of a table or view,\n  ** then create a transient table structure to describe the subquery.\n  */\n  for(i=0, pFrom=pTabList->a; i<pTabList->nSrc; i++, pFrom++){\n    Table *pTab;\n    assert( pFrom->fg.isRecursive==0 || pFrom->pTab!=0 );\n    if( pFrom->fg.isRecursive ) continue;\n    assert( pFrom->pTab==0 );\n#ifndef SQLITE_OMIT_CTE\n    if( withExpand(pWalker, pFrom) ) return WRC_Abort;\n    if( pFrom->pTab ) {} else\n#endif\n    if( pFrom->zName==0 ){\n#ifndef SQLITE_OMIT_SUBQUERY\n      Select *pSel = pFrom->pSelect;\n      /* A sub-query in the FROM clause of a SELECT */\n      assert( pSel!=0 );\n      assert( pFrom->pTab==0 );\n      if( sqlite3WalkSelect(pWalker, pSel) ) return WRC_Abort;\n      if( sqlite3ExpandSubquery(pParse, pFrom) ) return WRC_Abort;\n#endif\n    }else{\n      /* An ordinary table or view name in the FROM clause */\n      assert( pFrom->pTab==0 );\n      pFrom->pTab = pTab = sqlite3LocateTableItem(pParse, 0, pFrom);\n      if( pTab==0 ) return WRC_Abort;\n      if( pTab->nTabRef>=0xffff ){\n        sqlite3ErrorMsg(pParse, \"too many references to \\\"%s\\\": max 65535\",\n           pTab->zName);\n        pFrom->pTab = 0;\n        return WRC_Abort;\n      }\n      pTab->nTabRef++;\n      if( !IsVirtual(pTab) && cannotBeFunction(pParse, pFrom) ){\n        return WRC_Abort;\n      }\n#if !defined(SQLITE_OMIT_VIEW) || !defined (SQLITE_OMIT_VIRTUALTABLE)\n      if( IsVirtual(pTab) || pTab->pSelect ){\n        i16 nCol;\n        if( sqlite3ViewGetColumnNames(pParse, pTab) ) return WRC_Abort;\n        assert( pFrom->pSelect==0 );\n        pFrom->pSelect = sqlite3SelectDup(db, pTab->pSelect, 0);\n        nCol = pTab->nCol;\n        pTab->nCol = -1;\n        sqlite3WalkSelect(pWalker, pFrom->pSelect);\n        pTab->nCol = nCol;\n      }\n#endif\n    }\n\n    /* Locate the index named by the INDEXED BY clause, if any. */\n    if( sqlite3IndexedByLookup(pParse, pFrom) ){\n      return WRC_Abort;\n    }\n  }\n\n  /* Process NATURAL keywords, and ON and USING clauses of joins.\n  */\n  if( db->mallocFailed || sqliteProcessJoin(pParse, p) ){\n    return WRC_Abort;\n  }\n\n  /* For every \"*\" that occurs in the column list, insert the names of\n  ** all columns in all tables.  And for every TABLE.* insert the names\n  ** of all columns in TABLE.  The parser inserted a special expression\n  ** with the TK_ASTERISK operator for each \"*\" that it found in the column\n  ** list.  The following code just has to locate the TK_ASTERISK\n  ** expressions and expand each one to the list of all columns in\n  ** all tables.\n  **\n  ** The first loop just checks to see if there are any \"*\" operators\n  ** that need expanding.\n  */\n  for(k=0; k<pEList->nExpr; k++){\n    pE = pEList->a[k].pExpr;\n    if( pE->op==TK_ASTERISK ) break;\n    assert( pE->op!=TK_DOT || pE->pRight!=0 );\n    assert( pE->op!=TK_DOT || (pE->pLeft!=0 && pE->pLeft->op==TK_ID) );\n    if( pE->op==TK_DOT && pE->pRight->op==TK_ASTERISK ) break;\n    elistFlags |= pE->flags;\n  }\n  if( k<pEList->nExpr ){\n    /*\n    ** If we get here it means the result set contains one or more \"*\"\n    ** operators that need to be expanded.  Loop through each expression\n    ** in the result set and expand them one by one.\n    */\n    struct ExprList_item *a = pEList->a;\n    ExprList *pNew = 0;\n    int flags = pParse->db->flags;\n    int longNames = (flags & SQLITE_FullColNames)!=0\n                      && (flags & SQLITE_ShortColNames)==0;\n\n    for(k=0; k<pEList->nExpr; k++){\n      pE = a[k].pExpr;\n      elistFlags |= pE->flags;\n      pRight = pE->pRight;\n      assert( pE->op!=TK_DOT || pRight!=0 );\n      if( pE->op!=TK_ASTERISK\n       && (pE->op!=TK_DOT || pRight->op!=TK_ASTERISK)\n      ){\n        /* This particular expression does not need to be expanded.\n        */\n        pNew = sqlite3ExprListAppend(pParse, pNew, a[k].pExpr);\n        if( pNew ){\n          pNew->a[pNew->nExpr-1].zName = a[k].zName;\n          pNew->a[pNew->nExpr-1].zSpan = a[k].zSpan;\n          a[k].zName = 0;\n          a[k].zSpan = 0;\n        }\n        a[k].pExpr = 0;\n      }else{\n        /* This expression is a \"*\" or a \"TABLE.*\" and needs to be\n        ** expanded. */\n        int tableSeen = 0;      /* Set to 1 when TABLE matches */\n        char *zTName = 0;       /* text of name of TABLE */\n        if( pE->op==TK_DOT ){\n          assert( pE->pLeft!=0 );\n          assert( !ExprHasProperty(pE->pLeft, EP_IntValue) );\n          zTName = pE->pLeft->u.zToken;\n        }\n        for(i=0, pFrom=pTabList->a; i<pTabList->nSrc; i++, pFrom++){\n          Table *pTab = pFrom->pTab;\n          Select *pSub = pFrom->pSelect;\n          char *zTabName = pFrom->zAlias;\n          const char *zSchemaName = 0;\n          int iDb;\n          if( zTabName==0 ){\n            zTabName = pTab->zName;\n          }\n          if( db->mallocFailed ) break;\n          if( pSub==0 || (pSub->selFlags & SF_NestedFrom)==0 ){\n            pSub = 0;\n            if( zTName && sqlite3StrICmp(zTName, zTabName)!=0 ){\n              continue;\n            }\n            iDb = sqlite3SchemaToIndex(db, pTab->pSchema);\n            zSchemaName = iDb>=0 ? db->aDb[iDb].zDbSName : \"*\";\n          }\n          for(j=0; j<pTab->nCol; j++){\n            char *zName = pTab->aCol[j].zName;\n            char *zColname;  /* The computed column name */\n            char *zToFree;   /* Malloced string that needs to be freed */\n            Token sColname;  /* Computed column name as a token */\n\n            assert( zName );\n            if( zTName && pSub\n             && sqlite3MatchSpanName(pSub->pEList->a[j].zSpan, 0, zTName, 0)==0\n            ){\n              continue;\n            }\n\n            /* If a column is marked as 'hidden', omit it from the expanded\n            ** result-set list unless the SELECT has the SF_IncludeHidden\n            ** bit set.\n            */\n            if( (p->selFlags & SF_IncludeHidden)==0\n             && IsHiddenColumn(&pTab->aCol[j]) \n            ){\n              continue;\n            }\n            tableSeen = 1;\n\n            if( i>0 && zTName==0 ){\n              if( (pFrom->fg.jointype & JT_NATURAL)!=0\n                && tableAndColumnIndex(pTabList, i, zName, 0, 0)\n              ){\n                /* In a NATURAL join, omit the join columns from the \n                ** table to the right of the join */\n                continue;\n              }\n              if( sqlite3IdListIndex(pFrom->pUsing, zName)>=0 ){\n                /* In a join with a USING clause, omit columns in the\n                ** using clause from the table on the right. */\n                continue;\n              }\n            }\n            pRight = sqlite3Expr(db, TK_ID, zName);\n            zColname = zName;\n            zToFree = 0;\n            if( longNames || pTabList->nSrc>1 ){\n              Expr *pLeft;\n              pLeft = sqlite3Expr(db, TK_ID, zTabName);\n              pExpr = sqlite3PExpr(pParse, TK_DOT, pLeft, pRight);\n              if( zSchemaName ){\n                pLeft = sqlite3Expr(db, TK_ID, zSchemaName);\n                pExpr = sqlite3PExpr(pParse, TK_DOT, pLeft, pExpr);\n              }\n              if( longNames ){\n                zColname = sqlite3MPrintf(db, \"%s.%s\", zTabName, zName);\n                zToFree = zColname;\n              }\n            }else{\n              pExpr = pRight;\n            }\n            pNew = sqlite3ExprListAppend(pParse, pNew, pExpr);\n            sqlite3TokenInit(&sColname, zColname);\n            sqlite3ExprListSetName(pParse, pNew, &sColname, 0);\n            if( pNew && (p->selFlags & SF_NestedFrom)!=0 ){\n              struct ExprList_item *pX = &pNew->a[pNew->nExpr-1];\n              if( pSub ){\n                pX->zSpan = sqlite3DbStrDup(db, pSub->pEList->a[j].zSpan);\n                testcase( pX->zSpan==0 );\n              }else{\n                pX->zSpan = sqlite3MPrintf(db, \"%s.%s.%s\",\n                                           zSchemaName, zTabName, zColname);\n                testcase( pX->zSpan==0 );\n              }\n              pX->bSpanIsTab = 1;\n            }\n            sqlite3DbFree(db, zToFree);\n          }\n        }\n        if( !tableSeen ){\n          if( zTName ){\n            sqlite3ErrorMsg(pParse, \"no such table: %s\", zTName);\n          }else{\n            sqlite3ErrorMsg(pParse, \"no tables specified\");\n          }\n        }\n      }\n    }\n    sqlite3ExprListDelete(db, pEList);\n    p->pEList = pNew;\n  }\n  if( p->pEList ){\n    if( p->pEList->nExpr>db->aLimit[SQLITE_LIMIT_COLUMN] ){\n      sqlite3ErrorMsg(pParse, \"too many columns in result set\");\n      return WRC_Abort;\n    }\n    if( (elistFlags & (EP_HasFunc|EP_Subquery))!=0 ){\n      p->selFlags |= SF_ComplexResult;\n    }\n  }\n  return WRC_Continue;\n}\n\n/*\n** No-op routine for the parse-tree walker.\n**\n** When this routine is the Walker.xExprCallback then expression trees\n** are walked without any actions being taken at each node.  Presumably,\n** when this routine is used for Walker.xExprCallback then \n** Walker.xSelectCallback is set to do something useful for every \n** subquery in the parser tree.\n*/\nSQLITE_PRIVATE int sqlite3ExprWalkNoop(Walker *NotUsed, Expr *NotUsed2){\n  UNUSED_PARAMETER2(NotUsed, NotUsed2);\n  return WRC_Continue;\n}\n\n/*\n** No-op routine for the parse-tree walker for SELECT statements.\n** subquery in the parser tree.\n*/\nSQLITE_PRIVATE int sqlite3SelectWalkNoop(Walker *NotUsed, Select *NotUsed2){\n  UNUSED_PARAMETER2(NotUsed, NotUsed2);\n  return WRC_Continue;\n}\n\n#if SQLITE_DEBUG\n/*\n** Always assert.  This xSelectCallback2 implementation proves that the\n** xSelectCallback2 is never invoked.\n*/\nSQLITE_PRIVATE void sqlite3SelectWalkAssert2(Walker *NotUsed, Select *NotUsed2){\n  UNUSED_PARAMETER2(NotUsed, NotUsed2);\n  assert( 0 );\n}\n#endif\n/*\n** This routine \"expands\" a SELECT statement and all of its subqueries.\n** For additional information on what it means to \"expand\" a SELECT\n** statement, see the comment on the selectExpand worker callback above.\n**\n** Expanding a SELECT statement is the first step in processing a\n** SELECT statement.  The SELECT statement must be expanded before\n** name resolution is performed.\n**\n** If anything goes wrong, an error message is written into pParse.\n** The calling function can detect the problem by looking at pParse->nErr\n** and/or pParse->db->mallocFailed.\n*/\nstatic void sqlite3SelectExpand(Parse *pParse, Select *pSelect){\n  Walker w;\n  w.xExprCallback = sqlite3ExprWalkNoop;\n  w.pParse = pParse;\n  if( OK_IF_ALWAYS_TRUE(pParse->hasCompound) ){\n    w.xSelectCallback = convertCompoundSelectToSubquery;\n    w.xSelectCallback2 = 0;\n    sqlite3WalkSelect(&w, pSelect);\n  }\n  w.xSelectCallback = selectExpander;\n  w.xSelectCallback2 = selectPopWith;\n  sqlite3WalkSelect(&w, pSelect);\n}\n\n\n#ifndef SQLITE_OMIT_SUBQUERY\n/*\n** This is a Walker.xSelectCallback callback for the sqlite3SelectTypeInfo()\n** interface.\n**\n** For each FROM-clause subquery, add Column.zType and Column.zColl\n** information to the Table structure that represents the result set\n** of that subquery.\n**\n** The Table structure that represents the result set was constructed\n** by selectExpander() but the type and collation information was omitted\n** at that point because identifiers had not yet been resolved.  This\n** routine is called after identifier resolution.\n*/\nstatic void selectAddSubqueryTypeInfo(Walker *pWalker, Select *p){\n  Parse *pParse;\n  int i;\n  SrcList *pTabList;\n  struct SrcList_item *pFrom;\n\n  assert( p->selFlags & SF_Resolved );\n  if( p->selFlags & SF_HasTypeInfo ) return;\n  p->selFlags |= SF_HasTypeInfo;\n  pParse = pWalker->pParse;\n  pTabList = p->pSrc;\n  for(i=0, pFrom=pTabList->a; i<pTabList->nSrc; i++, pFrom++){\n    Table *pTab = pFrom->pTab;\n    assert( pTab!=0 );\n    if( (pTab->tabFlags & TF_Ephemeral)!=0 ){\n      /* A sub-query in the FROM clause of a SELECT */\n      Select *pSel = pFrom->pSelect;\n      if( pSel ){\n        while( pSel->pPrior ) pSel = pSel->pPrior;\n        sqlite3SelectAddColumnTypeAndCollation(pParse, pTab, pSel);\n      }\n    }\n  }\n}\n#endif\n\n\n/*\n** This routine adds datatype and collating sequence information to\n** the Table structures of all FROM-clause subqueries in a\n** SELECT statement.\n**\n** Use this routine after name resolution.\n*/\nstatic void sqlite3SelectAddTypeInfo(Parse *pParse, Select *pSelect){\n#ifndef SQLITE_OMIT_SUBQUERY\n  Walker w;\n  w.xSelectCallback = sqlite3SelectWalkNoop;\n  w.xSelectCallback2 = selectAddSubqueryTypeInfo;\n  w.xExprCallback = sqlite3ExprWalkNoop;\n  w.pParse = pParse;\n  sqlite3WalkSelect(&w, pSelect);\n#endif\n}\n\n\n/*\n** This routine sets up a SELECT statement for processing.  The\n** following is accomplished:\n**\n**     *  VDBE Cursor numbers are assigned to all FROM-clause terms.\n**     *  Ephemeral Table objects are created for all FROM-clause subqueries.\n**     *  ON and USING clauses are shifted into WHERE statements\n**     *  Wildcards \"*\" and \"TABLE.*\" in result sets are expanded.\n**     *  Identifiers in expression are matched to tables.\n**\n** This routine acts recursively on all subqueries within the SELECT.\n*/\nSQLITE_PRIVATE void sqlite3SelectPrep(\n  Parse *pParse,         /* The parser context */\n  Select *p,             /* The SELECT statement being coded. */\n  NameContext *pOuterNC  /* Name context for container */\n){\n  assert( p!=0 || pParse->db->mallocFailed );\n  if( pParse->db->mallocFailed ) return;\n  if( p->selFlags & SF_HasTypeInfo ) return;\n  sqlite3SelectExpand(pParse, p);\n  if( pParse->nErr || pParse->db->mallocFailed ) return;\n  sqlite3ResolveSelectNames(pParse, p, pOuterNC);\n  if( pParse->nErr || pParse->db->mallocFailed ) return;\n  sqlite3SelectAddTypeInfo(pParse, p);\n}\n\n/*\n** Reset the aggregate accumulator.\n**\n** The aggregate accumulator is a set of memory cells that hold\n** intermediate results while calculating an aggregate.  This\n** routine generates code that stores NULLs in all of those memory\n** cells.\n*/\nstatic void resetAccumulator(Parse *pParse, AggInfo *pAggInfo){\n  Vdbe *v = pParse->pVdbe;\n  int i;\n  struct AggInfo_func *pFunc;\n  int nReg = pAggInfo->nFunc + pAggInfo->nColumn;\n  if( nReg==0 ) return;\n#ifdef SQLITE_DEBUG\n  /* Verify that all AggInfo registers are within the range specified by\n  ** AggInfo.mnReg..AggInfo.mxReg */\n  assert( nReg==pAggInfo->mxReg-pAggInfo->mnReg+1 );\n  for(i=0; i<pAggInfo->nColumn; i++){\n    assert( pAggInfo->aCol[i].iMem>=pAggInfo->mnReg\n         && pAggInfo->aCol[i].iMem<=pAggInfo->mxReg );\n  }\n  for(i=0; i<pAggInfo->nFunc; i++){\n    assert( pAggInfo->aFunc[i].iMem>=pAggInfo->mnReg\n         && pAggInfo->aFunc[i].iMem<=pAggInfo->mxReg );\n  }\n#endif\n  sqlite3VdbeAddOp3(v, OP_Null, 0, pAggInfo->mnReg, pAggInfo->mxReg);\n  for(pFunc=pAggInfo->aFunc, i=0; i<pAggInfo->nFunc; i++, pFunc++){\n    if( pFunc->iDistinct>=0 ){\n      Expr *pE = pFunc->pExpr;\n      assert( !ExprHasProperty(pE, EP_xIsSelect) );\n      if( pE->x.pList==0 || pE->x.pList->nExpr!=1 ){\n        sqlite3ErrorMsg(pParse, \"DISTINCT aggregates must have exactly one \"\n           \"argument\");\n        pFunc->iDistinct = -1;\n      }else{\n        KeyInfo *pKeyInfo = sqlite3KeyInfoFromExprList(pParse, pE->x.pList,0,0);\n        sqlite3VdbeAddOp4(v, OP_OpenEphemeral, pFunc->iDistinct, 0, 0,\n                          (char*)pKeyInfo, P4_KEYINFO);\n      }\n    }\n  }\n}\n\n/*\n** Invoke the OP_AggFinalize opcode for every aggregate function\n** in the AggInfo structure.\n*/\nstatic void finalizeAggFunctions(Parse *pParse, AggInfo *pAggInfo){\n  Vdbe *v = pParse->pVdbe;\n  int i;\n  struct AggInfo_func *pF;\n  for(i=0, pF=pAggInfo->aFunc; i<pAggInfo->nFunc; i++, pF++){\n    ExprList *pList = pF->pExpr->x.pList;\n    assert( !ExprHasProperty(pF->pExpr, EP_xIsSelect) );\n    sqlite3VdbeAddOp2(v, OP_AggFinal, pF->iMem, pList ? pList->nExpr : 0);\n    sqlite3VdbeAppendP4(v, pF->pFunc, P4_FUNCDEF);\n  }\n}\n\n\n/*\n** Update the accumulator memory cells for an aggregate based on\n** the current cursor position.\n**\n** If regAcc is non-zero and there are no min() or max() aggregates\n** in pAggInfo, then only populate the pAggInfo->nAccumulator accumulator\n** registers i register regAcc contains 0. The caller will take care\n** of setting and clearing regAcc.\n*/\nstatic void updateAccumulator(Parse *pParse, int regAcc, AggInfo *pAggInfo){\n  Vdbe *v = pParse->pVdbe;\n  int i;\n  int regHit = 0;\n  int addrHitTest = 0;\n  struct AggInfo_func *pF;\n  struct AggInfo_col *pC;\n\n  pAggInfo->directMode = 1;\n  for(i=0, pF=pAggInfo->aFunc; i<pAggInfo->nFunc; i++, pF++){\n    int nArg;\n    int addrNext = 0;\n    int regAgg;\n    ExprList *pList = pF->pExpr->x.pList;\n    assert( !ExprHasProperty(pF->pExpr, EP_xIsSelect) );\n    if( pList ){\n      nArg = pList->nExpr;\n      regAgg = sqlite3GetTempRange(pParse, nArg);\n      sqlite3ExprCodeExprList(pParse, pList, regAgg, 0, SQLITE_ECEL_DUP);\n    }else{\n      nArg = 0;\n      regAgg = 0;\n    }\n    if( pF->iDistinct>=0 ){\n      addrNext = sqlite3VdbeMakeLabel(pParse);\n      testcase( nArg==0 );  /* Error condition */\n      testcase( nArg>1 );   /* Also an error */\n      codeDistinct(pParse, pF->iDistinct, addrNext, 1, regAgg);\n    }\n    if( pF->pFunc->funcFlags & SQLITE_FUNC_NEEDCOLL ){\n      CollSeq *pColl = 0;\n      struct ExprList_item *pItem;\n      int j;\n      assert( pList!=0 );  /* pList!=0 if pF->pFunc has NEEDCOLL */\n      for(j=0, pItem=pList->a; !pColl && j<nArg; j++, pItem++){\n        pColl = sqlite3ExprCollSeq(pParse, pItem->pExpr);\n      }\n      if( !pColl ){\n        pColl = pParse->db->pDfltColl;\n      }\n      if( regHit==0 && pAggInfo->nAccumulator ) regHit = ++pParse->nMem;\n      sqlite3VdbeAddOp4(v, OP_CollSeq, regHit, 0, 0, (char *)pColl, P4_COLLSEQ);\n    }\n    sqlite3VdbeAddOp3(v, OP_AggStep, 0, regAgg, pF->iMem);\n    sqlite3VdbeAppendP4(v, pF->pFunc, P4_FUNCDEF);\n    sqlite3VdbeChangeP5(v, (u8)nArg);\n    sqlite3ReleaseTempRange(pParse, regAgg, nArg);\n    if( addrNext ){\n      sqlite3VdbeResolveLabel(v, addrNext);\n    }\n  }\n  if( regHit==0 && pAggInfo->nAccumulator ){\n    regHit = regAcc;\n  }\n  if( regHit ){\n    addrHitTest = sqlite3VdbeAddOp1(v, OP_If, regHit); VdbeCoverage(v);\n  }\n  for(i=0, pC=pAggInfo->aCol; i<pAggInfo->nAccumulator; i++, pC++){\n    sqlite3ExprCode(pParse, pC->pExpr, pC->iMem);\n  }\n  pAggInfo->directMode = 0;\n  if( addrHitTest ){\n    sqlite3VdbeJumpHere(v, addrHitTest);\n  }\n}\n\n/*\n** Add a single OP_Explain instruction to the VDBE to explain a simple\n** count(*) query (\"SELECT count(*) FROM pTab\").\n*/\n#ifndef SQLITE_OMIT_EXPLAIN\nstatic void explainSimpleCount(\n  Parse *pParse,                  /* Parse context */\n  Table *pTab,                    /* Table being queried */\n  Index *pIdx                     /* Index used to optimize scan, or NULL */\n){\n  if( pParse->explain==2 ){\n    int bCover = (pIdx!=0 && (HasRowid(pTab) || !IsPrimaryKeyIndex(pIdx)));\n    sqlite3VdbeExplain(pParse, 0, \"SCAN TABLE %s%s%s\",\n        pTab->zName,\n        bCover ? \" USING COVERING INDEX \" : \"\",\n        bCover ? pIdx->zName : \"\"\n    );\n  }\n}\n#else\n# define explainSimpleCount(a,b,c)\n#endif\n\n/*\n** sqlite3WalkExpr() callback used by havingToWhere().\n**\n** If the node passed to the callback is a TK_AND node, return \n** WRC_Continue to tell sqlite3WalkExpr() to iterate through child nodes.\n**\n** Otherwise, return WRC_Prune. In this case, also check if the \n** sub-expression matches the criteria for being moved to the WHERE\n** clause. If so, add it to the WHERE clause and replace the sub-expression\n** within the HAVING expression with a constant \"1\".\n*/\nstatic int havingToWhereExprCb(Walker *pWalker, Expr *pExpr){\n  if( pExpr->op!=TK_AND ){\n    Select *pS = pWalker->u.pSelect;\n    if( sqlite3ExprIsConstantOrGroupBy(pWalker->pParse, pExpr, pS->pGroupBy) ){\n      sqlite3 *db = pWalker->pParse->db;\n      Expr *pNew = sqlite3ExprAlloc(db, TK_INTEGER, &sqlite3IntTokens[1], 0);\n      if( pNew ){\n        Expr *pWhere = pS->pWhere;\n        SWAP(Expr, *pNew, *pExpr);\n        pNew = sqlite3ExprAnd(db, pWhere, pNew);\n        pS->pWhere = pNew;\n        pWalker->eCode = 1;\n      }\n    }\n    return WRC_Prune;\n  }\n  return WRC_Continue;\n}\n\n/*\n** Transfer eligible terms from the HAVING clause of a query, which is\n** processed after grouping, to the WHERE clause, which is processed before\n** grouping. For example, the query:\n**\n**   SELECT * FROM <tables> WHERE a=? GROUP BY b HAVING b=? AND c=?\n**\n** can be rewritten as:\n**\n**   SELECT * FROM <tables> WHERE a=? AND b=? GROUP BY b HAVING c=?\n**\n** A term of the HAVING expression is eligible for transfer if it consists\n** entirely of constants and expressions that are also GROUP BY terms that\n** use the \"BINARY\" collation sequence.\n*/\nstatic void havingToWhere(Parse *pParse, Select *p){\n  Walker sWalker;\n  memset(&sWalker, 0, sizeof(sWalker));\n  sWalker.pParse = pParse;\n  sWalker.xExprCallback = havingToWhereExprCb;\n  sWalker.u.pSelect = p;\n  sqlite3WalkExpr(&sWalker, p->pHaving);\n#if SELECTTRACE_ENABLED\n  if( sWalker.eCode && (sqlite3SelectTrace & 0x100)!=0 ){\n    SELECTTRACE(0x100,pParse,p,(\"Move HAVING terms into WHERE:\\n\"));\n    sqlite3TreeViewSelect(0, p, 0);\n  }\n#endif\n}\n\n/*\n** Check to see if the pThis entry of pTabList is a self-join of a prior view.\n** If it is, then return the SrcList_item for the prior view.  If it is not,\n** then return 0.\n*/\nstatic struct SrcList_item *isSelfJoinView(\n  SrcList *pTabList,           /* Search for self-joins in this FROM clause */\n  struct SrcList_item *pThis   /* Search for prior reference to this subquery */\n){\n  struct SrcList_item *pItem;\n  for(pItem = pTabList->a; pItem<pThis; pItem++){\n    Select *pS1;\n    if( pItem->pSelect==0 ) continue;\n    if( pItem->fg.viaCoroutine ) continue;\n    if( pItem->zName==0 ) continue;\n    if( sqlite3_stricmp(pItem->zDatabase, pThis->zDatabase)!=0 ) continue;\n    if( sqlite3_stricmp(pItem->zName, pThis->zName)!=0 ) continue;\n    pS1 = pItem->pSelect;\n    if( pThis->pSelect->selId!=pS1->selId ){\n      /* The query flattener left two different CTE tables with identical\n      ** names in the same FROM clause. */\n      continue;\n    }\n    if( sqlite3ExprCompare(0, pThis->pSelect->pWhere, pS1->pWhere, -1) ){\n      /* The view was modified by some other optimization such as\n      ** pushDownWhereTerms() */\n      continue;\n    }\n    return pItem;\n  }\n  return 0;\n}\n\n#ifdef SQLITE_COUNTOFVIEW_OPTIMIZATION\n/*\n** Attempt to transform a query of the form\n**\n**    SELECT count(*) FROM (SELECT x FROM t1 UNION ALL SELECT y FROM t2)\n**\n** Into this:\n**\n**    SELECT (SELECT count(*) FROM t1)+(SELECT count(*) FROM t2)\n**\n** The transformation only works if all of the following are true:\n**\n**   *  The subquery is a UNION ALL of two or more terms\n**   *  The subquery does not have a LIMIT clause\n**   *  There is no WHERE or GROUP BY or HAVING clauses on the subqueries\n**   *  The outer query is a simple count(*)\n**\n** Return TRUE if the optimization is undertaken.\n*/\nstatic int countOfViewOptimization(Parse *pParse, Select *p){\n  Select *pSub, *pPrior;\n  Expr *pExpr;\n  Expr *pCount;\n  sqlite3 *db;\n  if( (p->selFlags & SF_Aggregate)==0 ) return 0;   /* This is an aggregate */\n  if( p->pEList->nExpr!=1 ) return 0;               /* Single result column */\n  pExpr = p->pEList->a[0].pExpr;\n  if( pExpr->op!=TK_AGG_FUNCTION ) return 0;        /* Result is an aggregate */\n  if( sqlite3_stricmp(pExpr->u.zToken,\"count\") ) return 0;  /* Is count() */\n  if( pExpr->x.pList!=0 ) return 0;                 /* Must be count(*) */\n  if( p->pSrc->nSrc!=1 ) return 0;                  /* One table in FROM  */\n  pSub = p->pSrc->a[0].pSelect;\n  if( pSub==0 ) return 0;                           /* The FROM is a subquery */\n  if( pSub->pPrior==0 ) return 0;                   /* Must be a compound ry */\n  do{\n    if( pSub->op!=TK_ALL && pSub->pPrior ) return 0;  /* Must be UNION ALL */\n    if( pSub->pWhere ) return 0;                      /* No WHERE clause */\n    if( pSub->pLimit ) return 0;                      /* No LIMIT clause */\n    if( pSub->selFlags & SF_Aggregate ) return 0;     /* Not an aggregate */\n    pSub = pSub->pPrior;                              /* Repeat over compound */\n  }while( pSub );\n\n  /* If we reach this point then it is OK to perform the transformation */\n\n  db = pParse->db;\n  pCount = pExpr;\n  pExpr = 0;\n  pSub = p->pSrc->a[0].pSelect;\n  p->pSrc->a[0].pSelect = 0;\n  sqlite3SrcListDelete(db, p->pSrc);\n  p->pSrc = sqlite3DbMallocZero(pParse->db, sizeof(*p->pSrc));\n  while( pSub ){\n    Expr *pTerm;\n    pPrior = pSub->pPrior;\n    pSub->pPrior = 0;\n    pSub->pNext = 0;\n    pSub->selFlags |= SF_Aggregate;\n    pSub->selFlags &= ~SF_Compound;\n    pSub->nSelectRow = 0;\n    sqlite3ExprListDelete(db, pSub->pEList);\n    pTerm = pPrior ? sqlite3ExprDup(db, pCount, 0) : pCount;\n    pSub->pEList = sqlite3ExprListAppend(pParse, 0, pTerm);\n    pTerm = sqlite3PExpr(pParse, TK_SELECT, 0, 0);\n    sqlite3PExprAddSelect(pParse, pTerm, pSub);\n    if( pExpr==0 ){\n      pExpr = pTerm;\n    }else{\n      pExpr = sqlite3PExpr(pParse, TK_PLUS, pTerm, pExpr);\n    }\n    pSub = pPrior;\n  }\n  p->pEList->a[0].pExpr = pExpr;\n  p->selFlags &= ~SF_Aggregate;\n\n#if SELECTTRACE_ENABLED\n  if( sqlite3SelectTrace & 0x400 ){\n    SELECTTRACE(0x400,pParse,p,(\"After count-of-view optimization:\\n\"));\n    sqlite3TreeViewSelect(0, p, 0);\n  }\n#endif\n  return 1;\n}\n#endif /* SQLITE_COUNTOFVIEW_OPTIMIZATION */\n\n/*\n** Generate code for the SELECT statement given in the p argument.  \n**\n** The results are returned according to the SelectDest structure.\n** See comments in sqliteInt.h for further information.\n**\n** This routine returns the number of errors.  If any errors are\n** encountered, then an appropriate error message is left in\n** pParse->zErrMsg.\n**\n** This routine does NOT free the Select structure passed in.  The\n** calling function needs to do that.\n*/\nSQLITE_PRIVATE int sqlite3Select(\n  Parse *pParse,         /* The parser context */\n  Select *p,             /* The SELECT statement being coded. */\n  SelectDest *pDest      /* What to do with the query results */\n){\n  int i, j;              /* Loop counters */\n  WhereInfo *pWInfo;     /* Return from sqlite3WhereBegin() */\n  Vdbe *v;               /* The virtual machine under construction */\n  int isAgg;             /* True for select lists like \"count(*)\" */\n  ExprList *pEList = 0;  /* List of columns to extract. */\n  SrcList *pTabList;     /* List of tables to select from */\n  Expr *pWhere;          /* The WHERE clause.  May be NULL */\n  ExprList *pGroupBy;    /* The GROUP BY clause.  May be NULL */\n  Expr *pHaving;         /* The HAVING clause.  May be NULL */\n  int rc = 1;            /* Value to return from this function */\n  DistinctCtx sDistinct; /* Info on how to code the DISTINCT keyword */\n  SortCtx sSort;         /* Info on how to code the ORDER BY clause */\n  AggInfo sAggInfo;      /* Information used by aggregate queries */\n  int iEnd;              /* Address of the end of the query */\n  sqlite3 *db;           /* The database connection */\n  ExprList *pMinMaxOrderBy = 0;  /* Added ORDER BY for min/max queries */\n  u8 minMaxFlag;                 /* Flag for min/max queries */\n\n  db = pParse->db;\n  v = sqlite3GetVdbe(pParse);\n  if( p==0 || db->mallocFailed || pParse->nErr ){\n    return 1;\n  }\n  if( sqlite3AuthCheck(pParse, SQLITE_SELECT, 0, 0, 0) ) return 1;\n  memset(&sAggInfo, 0, sizeof(sAggInfo));\n#if SELECTTRACE_ENABLED\n  SELECTTRACE(1,pParse,p, (\"begin processing:\\n\", pParse->addrExplain));\n  if( sqlite3SelectTrace & 0x100 ){\n    sqlite3TreeViewSelect(0, p, 0);\n  }\n#endif\n\n  assert( p->pOrderBy==0 || pDest->eDest!=SRT_DistFifo );\n  assert( p->pOrderBy==0 || pDest->eDest!=SRT_Fifo );\n  assert( p->pOrderBy==0 || pDest->eDest!=SRT_DistQueue );\n  assert( p->pOrderBy==0 || pDest->eDest!=SRT_Queue );\n  if( IgnorableOrderby(pDest) ){\n    assert(pDest->eDest==SRT_Exists || pDest->eDest==SRT_Union || \n           pDest->eDest==SRT_Except || pDest->eDest==SRT_Discard ||\n           pDest->eDest==SRT_Queue  || pDest->eDest==SRT_DistFifo ||\n           pDest->eDest==SRT_DistQueue || pDest->eDest==SRT_Fifo);\n    /* If ORDER BY makes no difference in the output then neither does\n    ** DISTINCT so it can be removed too. */\n    sqlite3ExprListDelete(db, p->pOrderBy);\n    p->pOrderBy = 0;\n    p->selFlags &= ~SF_Distinct;\n  }\n  sqlite3SelectPrep(pParse, p, 0);\n  if( pParse->nErr || db->mallocFailed ){\n    goto select_end;\n  }\n  assert( p->pEList!=0 );\n#if SELECTTRACE_ENABLED\n  if( sqlite3SelectTrace & 0x104 ){\n    SELECTTRACE(0x104,pParse,p, (\"after name resolution:\\n\"));\n    sqlite3TreeViewSelect(0, p, 0);\n  }\n#endif\n\n  if( pDest->eDest==SRT_Output ){\n    generateColumnNames(pParse, p);\n  }\n\n#ifndef SQLITE_OMIT_WINDOWFUNC\n  if( sqlite3WindowRewrite(pParse, p) ){\n    goto select_end;\n  }\n#if SELECTTRACE_ENABLED\n  if( sqlite3SelectTrace & 0x108 ){\n    SELECTTRACE(0x104,pParse,p, (\"after window rewrite:\\n\"));\n    sqlite3TreeViewSelect(0, p, 0);\n  }\n#endif\n#endif /* SQLITE_OMIT_WINDOWFUNC */\n  pTabList = p->pSrc;\n  isAgg = (p->selFlags & SF_Aggregate)!=0;\n  memset(&sSort, 0, sizeof(sSort));\n  sSort.pOrderBy = p->pOrderBy;\n\n  /* Try to various optimizations (flattening subqueries, and strength\n  ** reduction of join operators) in the FROM clause up into the main query\n  */\n#if !defined(SQLITE_OMIT_SUBQUERY) || !defined(SQLITE_OMIT_VIEW)\n  for(i=0; !p->pPrior && i<pTabList->nSrc; i++){\n    struct SrcList_item *pItem = &pTabList->a[i];\n    Select *pSub = pItem->pSelect;\n    Table *pTab = pItem->pTab;\n\n    /* Convert LEFT JOIN into JOIN if there are terms of the right table\n    ** of the LEFT JOIN used in the WHERE clause.\n    */\n    if( (pItem->fg.jointype & JT_LEFT)!=0\n     && sqlite3ExprImpliesNonNullRow(p->pWhere, pItem->iCursor)\n     && OptimizationEnabled(db, SQLITE_SimplifyJoin)\n    ){\n      SELECTTRACE(0x100,pParse,p,\n                (\"LEFT-JOIN simplifies to JOIN on term %d\\n\",i));\n      pItem->fg.jointype &= ~(JT_LEFT|JT_OUTER);\n      unsetJoinExpr(p->pWhere, pItem->iCursor);\n    }\n\n    /* No futher action if this term of the FROM clause is no a subquery */\n    if( pSub==0 ) continue;\n\n    /* Catch mismatch in the declared columns of a view and the number of\n    ** columns in the SELECT on the RHS */\n    if( pTab->nCol!=pSub->pEList->nExpr ){\n      sqlite3ErrorMsg(pParse, \"expected %d columns for '%s' but got %d\",\n                      pTab->nCol, pTab->zName, pSub->pEList->nExpr);\n      goto select_end;\n    }\n\n    /* Do not try to flatten an aggregate subquery.\n    **\n    ** Flattening an aggregate subquery is only possible if the outer query\n    ** is not a join.  But if the outer query is not a join, then the subquery\n    ** will be implemented as a co-routine and there is no advantage to\n    ** flattening in that case.\n    */\n    if( (pSub->selFlags & SF_Aggregate)!=0 ) continue;\n    assert( pSub->pGroupBy==0 );\n\n    /* If the outer query contains a \"complex\" result set (that is,\n    ** if the result set of the outer query uses functions or subqueries)\n    ** and if the subquery contains an ORDER BY clause and if\n    ** it will be implemented as a co-routine, then do not flatten.  This\n    ** restriction allows SQL constructs like this:\n    **\n    **  SELECT expensive_function(x)\n    **    FROM (SELECT x FROM tab ORDER BY y LIMIT 10);\n    **\n    ** The expensive_function() is only computed on the 10 rows that\n    ** are output, rather than every row of the table.\n    **\n    ** The requirement that the outer query have a complex result set\n    ** means that flattening does occur on simpler SQL constraints without\n    ** the expensive_function() like:\n    **\n    **  SELECT x FROM (SELECT x FROM tab ORDER BY y LIMIT 10);\n    */\n    if( pSub->pOrderBy!=0\n     && i==0\n     && (p->selFlags & SF_ComplexResult)!=0\n     && (pTabList->nSrc==1\n         || (pTabList->a[1].fg.jointype&(JT_LEFT|JT_CROSS))!=0)\n    ){\n      continue;\n    }\n\n    if( flattenSubquery(pParse, p, i, isAgg) ){\n      if( pParse->nErr ) goto select_end;\n      /* This subquery can be absorbed into its parent. */\n      i = -1;\n    }\n    pTabList = p->pSrc;\n    if( db->mallocFailed ) goto select_end;\n    if( !IgnorableOrderby(pDest) ){\n      sSort.pOrderBy = p->pOrderBy;\n    }\n  }\n#endif\n\n#ifndef SQLITE_OMIT_COMPOUND_SELECT\n  /* Handle compound SELECT statements using the separate multiSelect()\n  ** procedure.\n  */\n  if( p->pPrior ){\n    rc = multiSelect(pParse, p, pDest);\n#if SELECTTRACE_ENABLED\n    SELECTTRACE(0x1,pParse,p,(\"end compound-select processing\\n\"));\n    if( (sqlite3SelectTrace & 0x2000)!=0 && ExplainQueryPlanParent(pParse)==0 ){\n      sqlite3TreeViewSelect(0, p, 0);\n    }\n#endif\n    if( p->pNext==0 ) ExplainQueryPlanPop(pParse);\n    return rc;\n  }\n#endif\n\n  /* Do the WHERE-clause constant propagation optimization if this is\n  ** a join.  No need to speed time on this operation for non-join queries\n  ** as the equivalent optimization will be handled by query planner in\n  ** sqlite3WhereBegin().\n  */\n  if( pTabList->nSrc>1\n   && OptimizationEnabled(db, SQLITE_PropagateConst)\n   && propagateConstants(pParse, p)\n  ){\n#if SELECTTRACE_ENABLED\n    if( sqlite3SelectTrace & 0x100 ){\n      SELECTTRACE(0x100,pParse,p,(\"After constant propagation:\\n\"));\n      sqlite3TreeViewSelect(0, p, 0);\n    }\n#endif\n  }else{\n    SELECTTRACE(0x100,pParse,p,(\"Constant propagation not helpful\\n\"));\n  }\n\n#ifdef SQLITE_COUNTOFVIEW_OPTIMIZATION\n  if( OptimizationEnabled(db, SQLITE_QueryFlattener|SQLITE_CountOfView)\n   && countOfViewOptimization(pParse, p)\n  ){\n    if( db->mallocFailed ) goto select_end;\n    pEList = p->pEList;\n    pTabList = p->pSrc;\n  }\n#endif\n\n  /* For each term in the FROM clause, do two things:\n  ** (1) Authorized unreferenced tables\n  ** (2) Generate code for all sub-queries\n  */\n  for(i=0; i<pTabList->nSrc; i++){\n    struct SrcList_item *pItem = &pTabList->a[i];\n    SelectDest dest;\n    Select *pSub;\n#if !defined(SQLITE_OMIT_SUBQUERY) || !defined(SQLITE_OMIT_VIEW)\n    const char *zSavedAuthContext;\n#endif\n\n    /* Issue SQLITE_READ authorizations with a fake column name for any\n    ** tables that are referenced but from which no values are extracted.\n    ** Examples of where these kinds of null SQLITE_READ authorizations\n    ** would occur:\n    **\n    **     SELECT count(*) FROM t1;   -- SQLITE_READ t1.\"\"\n    **     SELECT t1.* FROM t1, t2;   -- SQLITE_READ t2.\"\"\n    **\n    ** The fake column name is an empty string.  It is possible for a table to\n    ** have a column named by the empty string, in which case there is no way to\n    ** distinguish between an unreferenced table and an actual reference to the\n    ** \"\" column. The original design was for the fake column name to be a NULL,\n    ** which would be unambiguous.  But legacy authorization callbacks might\n    ** assume the column name is non-NULL and segfault.  The use of an empty\n    ** string for the fake column name seems safer.\n    */\n    if( pItem->colUsed==0 ){\n      sqlite3AuthCheck(pParse, SQLITE_READ, pItem->zName, \"\", pItem->zDatabase);\n    }\n\n#if !defined(SQLITE_OMIT_SUBQUERY) || !defined(SQLITE_OMIT_VIEW)\n    /* Generate code for all sub-queries in the FROM clause\n    */\n    pSub = pItem->pSelect;\n    if( pSub==0 ) continue;\n\n    /* The code for a subquery should only be generated once, though it is\n    ** technically harmless for it to be generated multiple times. The\n    ** following assert() will detect if something changes to cause\n    ** the same subquery to be coded multiple times, as a signal to the\n    ** developers to try to optimize the situation. */\n    assert( pItem->addrFillSub==0 );\n\n    /* Increment Parse.nHeight by the height of the largest expression\n    ** tree referred to by this, the parent select. The child select\n    ** may contain expression trees of at most\n    ** (SQLITE_MAX_EXPR_DEPTH-Parse.nHeight) height. This is a bit\n    ** more conservative than necessary, but much easier than enforcing\n    ** an exact limit.\n    */\n    pParse->nHeight += sqlite3SelectExprHeight(p);\n\n    /* Make copies of constant WHERE-clause terms in the outer query down\n    ** inside the subquery.  This can help the subquery to run more efficiently.\n    */\n    if( OptimizationEnabled(db, SQLITE_PushDown)\n     && pushDownWhereTerms(pParse, pSub, p->pWhere, pItem->iCursor,\n                           (pItem->fg.jointype & JT_OUTER)!=0)\n    ){\n#if SELECTTRACE_ENABLED\n      if( sqlite3SelectTrace & 0x100 ){\n        SELECTTRACE(0x100,pParse,p,\n            (\"After WHERE-clause push-down into subquery %d:\\n\", pSub->selId));\n        sqlite3TreeViewSelect(0, p, 0);\n      }\n#endif\n    }else{\n      SELECTTRACE(0x100,pParse,p,(\"Push-down not possible\\n\"));\n    }\n\n    zSavedAuthContext = pParse->zAuthContext;\n    pParse->zAuthContext = pItem->zName;\n\n    /* Generate code to implement the subquery\n    **\n    ** The subquery is implemented as a co-routine if the subquery is\n    ** guaranteed to be the outer loop (so that it does not need to be\n    ** computed more than once)\n    **\n    ** TODO: Are there other reasons beside (1) to use a co-routine\n    ** implementation?\n    */\n    if( i==0\n     && (pTabList->nSrc==1\n            || (pTabList->a[1].fg.jointype&(JT_LEFT|JT_CROSS))!=0)  /* (1) */\n    ){\n      /* Implement a co-routine that will return a single row of the result\n      ** set on each invocation.\n      */\n      int addrTop = sqlite3VdbeCurrentAddr(v)+1;\n     \n      pItem->regReturn = ++pParse->nMem;\n      sqlite3VdbeAddOp3(v, OP_InitCoroutine, pItem->regReturn, 0, addrTop);\n      VdbeComment((v, \"%s\", pItem->pTab->zName));\n      pItem->addrFillSub = addrTop;\n      sqlite3SelectDestInit(&dest, SRT_Coroutine, pItem->regReturn);\n      ExplainQueryPlan((pParse, 1, \"CO-ROUTINE %u\", pSub->selId));\n      sqlite3Select(pParse, pSub, &dest);\n      pItem->pTab->nRowLogEst = pSub->nSelectRow;\n      pItem->fg.viaCoroutine = 1;\n      pItem->regResult = dest.iSdst;\n      sqlite3VdbeEndCoroutine(v, pItem->regReturn);\n      sqlite3VdbeJumpHere(v, addrTop-1);\n      sqlite3ClearTempRegCache(pParse);\n    }else{\n      /* Generate a subroutine that will fill an ephemeral table with\n      ** the content of this subquery.  pItem->addrFillSub will point\n      ** to the address of the generated subroutine.  pItem->regReturn\n      ** is a register allocated to hold the subroutine return address\n      */\n      int topAddr;\n      int onceAddr = 0;\n      int retAddr;\n      struct SrcList_item *pPrior;\n\n      assert( pItem->addrFillSub==0 );\n      pItem->regReturn = ++pParse->nMem;\n      topAddr = sqlite3VdbeAddOp2(v, OP_Integer, 0, pItem->regReturn);\n      pItem->addrFillSub = topAddr+1;\n      if( pItem->fg.isCorrelated==0 ){\n        /* If the subquery is not correlated and if we are not inside of\n        ** a trigger, then we only need to compute the value of the subquery\n        ** once. */\n        onceAddr = sqlite3VdbeAddOp0(v, OP_Once); VdbeCoverage(v);\n        VdbeComment((v, \"materialize \\\"%s\\\"\", pItem->pTab->zName));\n      }else{\n        VdbeNoopComment((v, \"materialize \\\"%s\\\"\", pItem->pTab->zName));\n      }\n      pPrior = isSelfJoinView(pTabList, pItem);\n      if( pPrior ){\n        sqlite3VdbeAddOp2(v, OP_OpenDup, pItem->iCursor, pPrior->iCursor);\n        assert( pPrior->pSelect!=0 );\n        pSub->nSelectRow = pPrior->pSelect->nSelectRow;\n      }else{\n        sqlite3SelectDestInit(&dest, SRT_EphemTab, pItem->iCursor);\n        ExplainQueryPlan((pParse, 1, \"MATERIALIZE %u\", pSub->selId));\n        sqlite3Select(pParse, pSub, &dest);\n      }\n      pItem->pTab->nRowLogEst = pSub->nSelectRow;\n      if( onceAddr ) sqlite3VdbeJumpHere(v, onceAddr);\n      retAddr = sqlite3VdbeAddOp1(v, OP_Return, pItem->regReturn);\n      VdbeComment((v, \"end %s\", pItem->pTab->zName));\n      sqlite3VdbeChangeP1(v, topAddr, retAddr);\n      sqlite3ClearTempRegCache(pParse);\n    }\n    if( db->mallocFailed ) goto select_end;\n    pParse->nHeight -= sqlite3SelectExprHeight(p);\n    pParse->zAuthContext = zSavedAuthContext;\n#endif\n  }\n\n  /* Various elements of the SELECT copied into local variables for\n  ** convenience */\n  pEList = p->pEList;\n  pWhere = p->pWhere;\n  pGroupBy = p->pGroupBy;\n  pHaving = p->pHaving;\n  sDistinct.isTnct = (p->selFlags & SF_Distinct)!=0;\n\n#if SELECTTRACE_ENABLED\n  if( sqlite3SelectTrace & 0x400 ){\n    SELECTTRACE(0x400,pParse,p,(\"After all FROM-clause analysis:\\n\"));\n    sqlite3TreeViewSelect(0, p, 0);\n  }\n#endif\n\n  /* If the query is DISTINCT with an ORDER BY but is not an aggregate, and \n  ** if the select-list is the same as the ORDER BY list, then this query\n  ** can be rewritten as a GROUP BY. In other words, this:\n  **\n  **     SELECT DISTINCT xyz FROM ... ORDER BY xyz\n  **\n  ** is transformed to:\n  **\n  **     SELECT xyz FROM ... GROUP BY xyz ORDER BY xyz\n  **\n  ** The second form is preferred as a single index (or temp-table) may be \n  ** used for both the ORDER BY and DISTINCT processing. As originally \n  ** written the query must use a temp-table for at least one of the ORDER \n  ** BY and DISTINCT, and an index or separate temp-table for the other.\n  */\n  if( (p->selFlags & (SF_Distinct|SF_Aggregate))==SF_Distinct \n   && sqlite3ExprListCompare(sSort.pOrderBy, pEList, -1)==0\n  ){\n    p->selFlags &= ~SF_Distinct;\n    pGroupBy = p->pGroupBy = sqlite3ExprListDup(db, pEList, 0);\n    /* Notice that even thought SF_Distinct has been cleared from p->selFlags,\n    ** the sDistinct.isTnct is still set.  Hence, isTnct represents the\n    ** original setting of the SF_Distinct flag, not the current setting */\n    assert( sDistinct.isTnct );\n\n#if SELECTTRACE_ENABLED\n    if( sqlite3SelectTrace & 0x400 ){\n      SELECTTRACE(0x400,pParse,p,(\"Transform DISTINCT into GROUP BY:\\n\"));\n      sqlite3TreeViewSelect(0, p, 0);\n    }\n#endif\n  }\n\n  /* If there is an ORDER BY clause, then create an ephemeral index to\n  ** do the sorting.  But this sorting ephemeral index might end up\n  ** being unused if the data can be extracted in pre-sorted order.\n  ** If that is the case, then the OP_OpenEphemeral instruction will be\n  ** changed to an OP_Noop once we figure out that the sorting index is\n  ** not needed.  The sSort.addrSortIndex variable is used to facilitate\n  ** that change.\n  */\n  if( sSort.pOrderBy ){\n    KeyInfo *pKeyInfo;\n    pKeyInfo = sqlite3KeyInfoFromExprList(\n        pParse, sSort.pOrderBy, 0, pEList->nExpr);\n    sSort.iECursor = pParse->nTab++;\n    sSort.addrSortIndex =\n      sqlite3VdbeAddOp4(v, OP_OpenEphemeral,\n          sSort.iECursor, sSort.pOrderBy->nExpr+1+pEList->nExpr, 0,\n          (char*)pKeyInfo, P4_KEYINFO\n      );\n  }else{\n    sSort.addrSortIndex = -1;\n  }\n\n  /* If the output is destined for a temporary table, open that table.\n  */\n  if( pDest->eDest==SRT_EphemTab ){\n    sqlite3VdbeAddOp2(v, OP_OpenEphemeral, pDest->iSDParm, pEList->nExpr);\n  }\n\n  /* Set the limiter.\n  */\n  iEnd = sqlite3VdbeMakeLabel(pParse);\n  if( (p->selFlags & SF_FixedLimit)==0 ){\n    p->nSelectRow = 320;  /* 4 billion rows */\n  }\n  computeLimitRegisters(pParse, p, iEnd);\n  if( p->iLimit==0 && sSort.addrSortIndex>=0 ){\n    sqlite3VdbeChangeOpcode(v, sSort.addrSortIndex, OP_SorterOpen);\n    sSort.sortFlags |= SORTFLAG_UseSorter;\n  }\n\n  /* Open an ephemeral index to use for the distinct set.\n  */\n  if( p->selFlags & SF_Distinct ){\n    sDistinct.tabTnct = pParse->nTab++;\n    sDistinct.addrTnct = sqlite3VdbeAddOp4(v, OP_OpenEphemeral,\n                       sDistinct.tabTnct, 0, 0,\n                       (char*)sqlite3KeyInfoFromExprList(pParse, p->pEList,0,0),\n                       P4_KEYINFO);\n    sqlite3VdbeChangeP5(v, BTREE_UNORDERED);\n    sDistinct.eTnctType = WHERE_DISTINCT_UNORDERED;\n  }else{\n    sDistinct.eTnctType = WHERE_DISTINCT_NOOP;\n  }\n\n  if( !isAgg && pGroupBy==0 ){\n    /* No aggregate functions and no GROUP BY clause */\n    u16 wctrlFlags = (sDistinct.isTnct ? WHERE_WANT_DISTINCT : 0)\n                   | (p->selFlags & SF_FixedLimit);\n#ifndef SQLITE_OMIT_WINDOWFUNC\n    Window *pWin = p->pWin;      /* Master window object (or NULL) */\n    if( pWin ){\n      sqlite3WindowCodeInit(pParse, pWin);\n    }\n#endif\n    assert( WHERE_USE_LIMIT==SF_FixedLimit );\n\n\n    /* Begin the database scan. */\n    SELECTTRACE(1,pParse,p,(\"WhereBegin\\n\"));\n    pWInfo = sqlite3WhereBegin(pParse, pTabList, pWhere, sSort.pOrderBy,\n                               p->pEList, wctrlFlags, p->nSelectRow);\n    if( pWInfo==0 ) goto select_end;\n    if( sqlite3WhereOutputRowCount(pWInfo) < p->nSelectRow ){\n      p->nSelectRow = sqlite3WhereOutputRowCount(pWInfo);\n    }\n    if( sDistinct.isTnct && sqlite3WhereIsDistinct(pWInfo) ){\n      sDistinct.eTnctType = sqlite3WhereIsDistinct(pWInfo);\n    }\n    if( sSort.pOrderBy ){\n      sSort.nOBSat = sqlite3WhereIsOrdered(pWInfo);\n      sSort.labelOBLopt = sqlite3WhereOrderByLimitOptLabel(pWInfo);\n      if( sSort.nOBSat==sSort.pOrderBy->nExpr ){\n        sSort.pOrderBy = 0;\n      }\n    }\n\n    /* If sorting index that was created by a prior OP_OpenEphemeral \n    ** instruction ended up not being needed, then change the OP_OpenEphemeral\n    ** into an OP_Noop.\n    */\n    if( sSort.addrSortIndex>=0 && sSort.pOrderBy==0 ){\n      sqlite3VdbeChangeToNoop(v, sSort.addrSortIndex);\n    }\n\n    assert( p->pEList==pEList );\n#ifndef SQLITE_OMIT_WINDOWFUNC\n    if( pWin ){\n      int addrGosub = sqlite3VdbeMakeLabel(pParse);\n      int iCont = sqlite3VdbeMakeLabel(pParse);\n      int iBreak = sqlite3VdbeMakeLabel(pParse);\n      int regGosub = ++pParse->nMem;\n\n      sqlite3WindowCodeStep(pParse, p, pWInfo, regGosub, addrGosub);\n\n      sqlite3VdbeAddOp2(v, OP_Goto, 0, iBreak);\n      sqlite3VdbeResolveLabel(v, addrGosub);\n      VdbeNoopComment((v, \"inner-loop subroutine\"));\n      sSort.labelOBLopt = 0;\n      selectInnerLoop(pParse, p, -1, &sSort, &sDistinct, pDest, iCont, iBreak);\n      sqlite3VdbeResolveLabel(v, iCont);\n      sqlite3VdbeAddOp1(v, OP_Return, regGosub);\n      VdbeComment((v, \"end inner-loop subroutine\"));\n      sqlite3VdbeResolveLabel(v, iBreak);\n    }else\n#endif /* SQLITE_OMIT_WINDOWFUNC */\n    {\n      /* Use the standard inner loop. */\n      selectInnerLoop(pParse, p, -1, &sSort, &sDistinct, pDest,\n          sqlite3WhereContinueLabel(pWInfo),\n          sqlite3WhereBreakLabel(pWInfo));\n\n      /* End the database scan loop.\n      */\n      sqlite3WhereEnd(pWInfo);\n    }\n  }else{\n    /* This case when there exist aggregate functions or a GROUP BY clause\n    ** or both */\n    NameContext sNC;    /* Name context for processing aggregate information */\n    int iAMem;          /* First Mem address for storing current GROUP BY */\n    int iBMem;          /* First Mem address for previous GROUP BY */\n    int iUseFlag;       /* Mem address holding flag indicating that at least\n                        ** one row of the input to the aggregator has been\n                        ** processed */\n    int iAbortFlag;     /* Mem address which causes query abort if positive */\n    int groupBySort;    /* Rows come from source in GROUP BY order */\n    int addrEnd;        /* End of processing for this SELECT */\n    int sortPTab = 0;   /* Pseudotable used to decode sorting results */\n    int sortOut = 0;    /* Output register from the sorter */\n    int orderByGrp = 0; /* True if the GROUP BY and ORDER BY are the same */\n\n    /* Remove any and all aliases between the result set and the\n    ** GROUP BY clause.\n    */\n    if( pGroupBy ){\n      int k;                        /* Loop counter */\n      struct ExprList_item *pItem;  /* For looping over expression in a list */\n\n      for(k=p->pEList->nExpr, pItem=p->pEList->a; k>0; k--, pItem++){\n        pItem->u.x.iAlias = 0;\n      }\n      for(k=pGroupBy->nExpr, pItem=pGroupBy->a; k>0; k--, pItem++){\n        pItem->u.x.iAlias = 0;\n      }\n      assert( 66==sqlite3LogEst(100) );\n      if( p->nSelectRow>66 ) p->nSelectRow = 66;\n    }else{\n      assert( 0==sqlite3LogEst(1) );\n      p->nSelectRow = 0;\n    }\n\n    /* If there is both a GROUP BY and an ORDER BY clause and they are\n    ** identical, then it may be possible to disable the ORDER BY clause \n    ** on the grounds that the GROUP BY will cause elements to come out \n    ** in the correct order. It also may not - the GROUP BY might use a\n    ** database index that causes rows to be grouped together as required\n    ** but not actually sorted. Either way, record the fact that the\n    ** ORDER BY and GROUP BY clauses are the same by setting the orderByGrp\n    ** variable.  */\n    if( sqlite3ExprListCompare(pGroupBy, sSort.pOrderBy, -1)==0 ){\n      orderByGrp = 1;\n    }\n \n    /* Create a label to jump to when we want to abort the query */\n    addrEnd = sqlite3VdbeMakeLabel(pParse);\n\n    /* Convert TK_COLUMN nodes into TK_AGG_COLUMN and make entries in\n    ** sAggInfo for all TK_AGG_FUNCTION nodes in expressions of the\n    ** SELECT statement.\n    */\n    memset(&sNC, 0, sizeof(sNC));\n    sNC.pParse = pParse;\n    sNC.pSrcList = pTabList;\n    sNC.uNC.pAggInfo = &sAggInfo;\n    VVA_ONLY( sNC.ncFlags = NC_UAggInfo; )\n    sAggInfo.mnReg = pParse->nMem+1;\n    sAggInfo.nSortingColumn = pGroupBy ? pGroupBy->nExpr : 0;\n    sAggInfo.pGroupBy = pGroupBy;\n    sqlite3ExprAnalyzeAggList(&sNC, pEList);\n    sqlite3ExprAnalyzeAggList(&sNC, sSort.pOrderBy);\n    if( pHaving ){\n      if( pGroupBy ){\n        assert( pWhere==p->pWhere );\n        assert( pHaving==p->pHaving );\n        assert( pGroupBy==p->pGroupBy );\n        havingToWhere(pParse, p);\n        pWhere = p->pWhere;\n      }\n      sqlite3ExprAnalyzeAggregates(&sNC, pHaving);\n    }\n    sAggInfo.nAccumulator = sAggInfo.nColumn;\n    if( p->pGroupBy==0 && p->pHaving==0 && sAggInfo.nFunc==1 ){\n      minMaxFlag = minMaxQuery(db, sAggInfo.aFunc[0].pExpr, &pMinMaxOrderBy);\n    }else{\n      minMaxFlag = WHERE_ORDERBY_NORMAL;\n    }\n    for(i=0; i<sAggInfo.nFunc; i++){\n      assert( !ExprHasProperty(sAggInfo.aFunc[i].pExpr, EP_xIsSelect) );\n      sNC.ncFlags |= NC_InAggFunc;\n      sqlite3ExprAnalyzeAggList(&sNC, sAggInfo.aFunc[i].pExpr->x.pList);\n      sNC.ncFlags &= ~NC_InAggFunc;\n    }\n    sAggInfo.mxReg = pParse->nMem;\n    if( db->mallocFailed ) goto select_end;\n#if SELECTTRACE_ENABLED\n    if( sqlite3SelectTrace & 0x400 ){\n      int ii;\n      SELECTTRACE(0x400,pParse,p,(\"After aggregate analysis:\\n\"));\n      sqlite3TreeViewSelect(0, p, 0);\n      for(ii=0; ii<sAggInfo.nColumn; ii++){\n        sqlite3DebugPrintf(\"agg-column[%d] iMem=%d\\n\",\n            ii, sAggInfo.aCol[ii].iMem);\n        sqlite3TreeViewExpr(0, sAggInfo.aCol[ii].pExpr, 0);\n      }\n      for(ii=0; ii<sAggInfo.nFunc; ii++){\n        sqlite3DebugPrintf(\"agg-func[%d]: iMem=%d\\n\",\n            ii, sAggInfo.aFunc[ii].iMem);\n        sqlite3TreeViewExpr(0, sAggInfo.aFunc[ii].pExpr, 0);\n      }\n    }\n#endif\n\n\n    /* Processing for aggregates with GROUP BY is very different and\n    ** much more complex than aggregates without a GROUP BY.\n    */\n    if( pGroupBy ){\n      KeyInfo *pKeyInfo;  /* Keying information for the group by clause */\n      int addr1;          /* A-vs-B comparision jump */\n      int addrOutputRow;  /* Start of subroutine that outputs a result row */\n      int regOutputRow;   /* Return address register for output subroutine */\n      int addrSetAbort;   /* Set the abort flag and return */\n      int addrTopOfLoop;  /* Top of the input loop */\n      int addrSortingIdx; /* The OP_OpenEphemeral for the sorting index */\n      int addrReset;      /* Subroutine for resetting the accumulator */\n      int regReset;       /* Return address register for reset subroutine */\n\n      /* If there is a GROUP BY clause we might need a sorting index to\n      ** implement it.  Allocate that sorting index now.  If it turns out\n      ** that we do not need it after all, the OP_SorterOpen instruction\n      ** will be converted into a Noop.  \n      */\n      sAggInfo.sortingIdx = pParse->nTab++;\n      pKeyInfo = sqlite3KeyInfoFromExprList(pParse,pGroupBy,0,sAggInfo.nColumn);\n      addrSortingIdx = sqlite3VdbeAddOp4(v, OP_SorterOpen, \n          sAggInfo.sortingIdx, sAggInfo.nSortingColumn, \n          0, (char*)pKeyInfo, P4_KEYINFO);\n\n      /* Initialize memory locations used by GROUP BY aggregate processing\n      */\n      iUseFlag = ++pParse->nMem;\n      iAbortFlag = ++pParse->nMem;\n      regOutputRow = ++pParse->nMem;\n      addrOutputRow = sqlite3VdbeMakeLabel(pParse);\n      regReset = ++pParse->nMem;\n      addrReset = sqlite3VdbeMakeLabel(pParse);\n      iAMem = pParse->nMem + 1;\n      pParse->nMem += pGroupBy->nExpr;\n      iBMem = pParse->nMem + 1;\n      pParse->nMem += pGroupBy->nExpr;\n      sqlite3VdbeAddOp2(v, OP_Integer, 0, iAbortFlag);\n      VdbeComment((v, \"clear abort flag\"));\n      sqlite3VdbeAddOp3(v, OP_Null, 0, iAMem, iAMem+pGroupBy->nExpr-1);\n\n      /* Begin a loop that will extract all source rows in GROUP BY order.\n      ** This might involve two separate loops with an OP_Sort in between, or\n      ** it might be a single loop that uses an index to extract information\n      ** in the right order to begin with.\n      */\n      sqlite3VdbeAddOp2(v, OP_Gosub, regReset, addrReset);\n      SELECTTRACE(1,pParse,p,(\"WhereBegin\\n\"));\n      pWInfo = sqlite3WhereBegin(pParse, pTabList, pWhere, pGroupBy, 0,\n          WHERE_GROUPBY | (orderByGrp ? WHERE_SORTBYGROUP : 0), 0\n      );\n      if( pWInfo==0 ) goto select_end;\n      if( sqlite3WhereIsOrdered(pWInfo)==pGroupBy->nExpr ){\n        /* The optimizer is able to deliver rows in group by order so\n        ** we do not have to sort.  The OP_OpenEphemeral table will be\n        ** cancelled later because we still need to use the pKeyInfo\n        */\n        groupBySort = 0;\n      }else{\n        /* Rows are coming out in undetermined order.  We have to push\n        ** each row into a sorting index, terminate the first loop,\n        ** then loop over the sorting index in order to get the output\n        ** in sorted order\n        */\n        int regBase;\n        int regRecord;\n        int nCol;\n        int nGroupBy;\n\n        explainTempTable(pParse, \n            (sDistinct.isTnct && (p->selFlags&SF_Distinct)==0) ?\n                    \"DISTINCT\" : \"GROUP BY\");\n\n        groupBySort = 1;\n        nGroupBy = pGroupBy->nExpr;\n        nCol = nGroupBy;\n        j = nGroupBy;\n        for(i=0; i<sAggInfo.nColumn; i++){\n          if( sAggInfo.aCol[i].iSorterColumn>=j ){\n            nCol++;\n            j++;\n          }\n        }\n        regBase = sqlite3GetTempRange(pParse, nCol);\n        sqlite3ExprCodeExprList(pParse, pGroupBy, regBase, 0, 0);\n        j = nGroupBy;\n        for(i=0; i<sAggInfo.nColumn; i++){\n          struct AggInfo_col *pCol = &sAggInfo.aCol[i];\n          if( pCol->iSorterColumn>=j ){\n            int r1 = j + regBase;\n            sqlite3ExprCodeGetColumnOfTable(v,\n                               pCol->pTab, pCol->iTable, pCol->iColumn, r1);\n            j++;\n          }\n        }\n        regRecord = sqlite3GetTempReg(pParse);\n        sqlite3VdbeAddOp3(v, OP_MakeRecord, regBase, nCol, regRecord);\n        sqlite3VdbeAddOp2(v, OP_SorterInsert, sAggInfo.sortingIdx, regRecord);\n        sqlite3ReleaseTempReg(pParse, regRecord);\n        sqlite3ReleaseTempRange(pParse, regBase, nCol);\n        sqlite3WhereEnd(pWInfo);\n        sAggInfo.sortingIdxPTab = sortPTab = pParse->nTab++;\n        sortOut = sqlite3GetTempReg(pParse);\n        sqlite3VdbeAddOp3(v, OP_OpenPseudo, sortPTab, sortOut, nCol);\n        sqlite3VdbeAddOp2(v, OP_SorterSort, sAggInfo.sortingIdx, addrEnd);\n        VdbeComment((v, \"GROUP BY sort\")); VdbeCoverage(v);\n        sAggInfo.useSortingIdx = 1;\n      }\n\n      /* If the index or temporary table used by the GROUP BY sort\n      ** will naturally deliver rows in the order required by the ORDER BY\n      ** clause, cancel the ephemeral table open coded earlier.\n      **\n      ** This is an optimization - the correct answer should result regardless.\n      ** Use the SQLITE_GroupByOrder flag with SQLITE_TESTCTRL_OPTIMIZER to \n      ** disable this optimization for testing purposes.  */\n      if( orderByGrp && OptimizationEnabled(db, SQLITE_GroupByOrder) \n       && (groupBySort || sqlite3WhereIsSorted(pWInfo))\n      ){\n        sSort.pOrderBy = 0;\n        sqlite3VdbeChangeToNoop(v, sSort.addrSortIndex);\n      }\n\n      /* Evaluate the current GROUP BY terms and store in b0, b1, b2...\n      ** (b0 is memory location iBMem+0, b1 is iBMem+1, and so forth)\n      ** Then compare the current GROUP BY terms against the GROUP BY terms\n      ** from the previous row currently stored in a0, a1, a2...\n      */\n      addrTopOfLoop = sqlite3VdbeCurrentAddr(v);\n      if( groupBySort ){\n        sqlite3VdbeAddOp3(v, OP_SorterData, sAggInfo.sortingIdx,\n                          sortOut, sortPTab);\n      }\n      for(j=0; j<pGroupBy->nExpr; j++){\n        if( groupBySort ){\n          sqlite3VdbeAddOp3(v, OP_Column, sortPTab, j, iBMem+j);\n        }else{\n          sAggInfo.directMode = 1;\n          sqlite3ExprCode(pParse, pGroupBy->a[j].pExpr, iBMem+j);\n        }\n      }\n      sqlite3VdbeAddOp4(v, OP_Compare, iAMem, iBMem, pGroupBy->nExpr,\n                          (char*)sqlite3KeyInfoRef(pKeyInfo), P4_KEYINFO);\n      addr1 = sqlite3VdbeCurrentAddr(v);\n      sqlite3VdbeAddOp3(v, OP_Jump, addr1+1, 0, addr1+1); VdbeCoverage(v);\n\n      /* Generate code that runs whenever the GROUP BY changes.\n      ** Changes in the GROUP BY are detected by the previous code\n      ** block.  If there were no changes, this block is skipped.\n      **\n      ** This code copies current group by terms in b0,b1,b2,...\n      ** over to a0,a1,a2.  It then calls the output subroutine\n      ** and resets the aggregate accumulator registers in preparation\n      ** for the next GROUP BY batch.\n      */\n      sqlite3ExprCodeMove(pParse, iBMem, iAMem, pGroupBy->nExpr);\n      sqlite3VdbeAddOp2(v, OP_Gosub, regOutputRow, addrOutputRow);\n      VdbeComment((v, \"output one row\"));\n      sqlite3VdbeAddOp2(v, OP_IfPos, iAbortFlag, addrEnd); VdbeCoverage(v);\n      VdbeComment((v, \"check abort flag\"));\n      sqlite3VdbeAddOp2(v, OP_Gosub, regReset, addrReset);\n      VdbeComment((v, \"reset accumulator\"));\n\n      /* Update the aggregate accumulators based on the content of\n      ** the current row\n      */\n      sqlite3VdbeJumpHere(v, addr1);\n      updateAccumulator(pParse, iUseFlag, &sAggInfo);\n      sqlite3VdbeAddOp2(v, OP_Integer, 1, iUseFlag);\n      VdbeComment((v, \"indicate data in accumulator\"));\n\n      /* End of the loop\n      */\n      if( groupBySort ){\n        sqlite3VdbeAddOp2(v, OP_SorterNext, sAggInfo.sortingIdx, addrTopOfLoop);\n        VdbeCoverage(v);\n      }else{\n        sqlite3WhereEnd(pWInfo);\n        sqlite3VdbeChangeToNoop(v, addrSortingIdx);\n      }\n\n      /* Output the final row of result\n      */\n      sqlite3VdbeAddOp2(v, OP_Gosub, regOutputRow, addrOutputRow);\n      VdbeComment((v, \"output final row\"));\n\n      /* Jump over the subroutines\n      */\n      sqlite3VdbeGoto(v, addrEnd);\n\n      /* Generate a subroutine that outputs a single row of the result\n      ** set.  This subroutine first looks at the iUseFlag.  If iUseFlag\n      ** is less than or equal to zero, the subroutine is a no-op.  If\n      ** the processing calls for the query to abort, this subroutine\n      ** increments the iAbortFlag memory location before returning in\n      ** order to signal the caller to abort.\n      */\n      addrSetAbort = sqlite3VdbeCurrentAddr(v);\n      sqlite3VdbeAddOp2(v, OP_Integer, 1, iAbortFlag);\n      VdbeComment((v, \"set abort flag\"));\n      sqlite3VdbeAddOp1(v, OP_Return, regOutputRow);\n      sqlite3VdbeResolveLabel(v, addrOutputRow);\n      addrOutputRow = sqlite3VdbeCurrentAddr(v);\n      sqlite3VdbeAddOp2(v, OP_IfPos, iUseFlag, addrOutputRow+2);\n      VdbeCoverage(v);\n      VdbeComment((v, \"Groupby result generator entry point\"));\n      sqlite3VdbeAddOp1(v, OP_Return, regOutputRow);\n      finalizeAggFunctions(pParse, &sAggInfo);\n      sqlite3ExprIfFalse(pParse, pHaving, addrOutputRow+1, SQLITE_JUMPIFNULL);\n      selectInnerLoop(pParse, p, -1, &sSort,\n                      &sDistinct, pDest,\n                      addrOutputRow+1, addrSetAbort);\n      sqlite3VdbeAddOp1(v, OP_Return, regOutputRow);\n      VdbeComment((v, \"end groupby result generator\"));\n\n      /* Generate a subroutine that will reset the group-by accumulator\n      */\n      sqlite3VdbeResolveLabel(v, addrReset);\n      resetAccumulator(pParse, &sAggInfo);\n      sqlite3VdbeAddOp2(v, OP_Integer, 0, iUseFlag);\n      VdbeComment((v, \"indicate accumulator empty\"));\n      sqlite3VdbeAddOp1(v, OP_Return, regReset);\n     \n    } /* endif pGroupBy.  Begin aggregate queries without GROUP BY: */\n    else {\n#ifndef SQLITE_OMIT_BTREECOUNT\n      Table *pTab;\n      if( (pTab = isSimpleCount(p, &sAggInfo))!=0 ){\n        /* If isSimpleCount() returns a pointer to a Table structure, then\n        ** the SQL statement is of the form:\n        **\n        **   SELECT count(*) FROM <tbl>\n        **\n        ** where the Table structure returned represents table <tbl>.\n        **\n        ** This statement is so common that it is optimized specially. The\n        ** OP_Count instruction is executed either on the intkey table that\n        ** contains the data for table <tbl> or on one of its indexes. It\n        ** is better to execute the op on an index, as indexes are almost\n        ** always spread across less pages than their corresponding tables.\n        */\n        const int iDb = sqlite3SchemaToIndex(pParse->db, pTab->pSchema);\n        const int iCsr = pParse->nTab++;     /* Cursor to scan b-tree */\n        Index *pIdx;                         /* Iterator variable */\n        KeyInfo *pKeyInfo = 0;               /* Keyinfo for scanned index */\n        Index *pBest = 0;                    /* Best index found so far */\n        int iRoot = pTab->tnum;              /* Root page of scanned b-tree */\n\n        sqlite3CodeVerifySchema(pParse, iDb);\n        sqlite3TableLock(pParse, iDb, pTab->tnum, 0, pTab->zName);\n\n        /* Search for the index that has the lowest scan cost.\n        **\n        ** (2011-04-15) Do not do a full scan of an unordered index.\n        **\n        ** (2013-10-03) Do not count the entries in a partial index.\n        **\n        ** In practice the KeyInfo structure will not be used. It is only \n        ** passed to keep OP_OpenRead happy.\n        */\n        if( !HasRowid(pTab) ) pBest = sqlite3PrimaryKeyIndex(pTab);\n        for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){\n          if( pIdx->bUnordered==0\n           && pIdx->szIdxRow<pTab->szTabRow\n           && pIdx->pPartIdxWhere==0\n           && (!pBest || pIdx->szIdxRow<pBest->szIdxRow)\n          ){\n            pBest = pIdx;\n          }\n        }\n        if( pBest ){\n          iRoot = pBest->tnum;\n          pKeyInfo = sqlite3KeyInfoOfIndex(pParse, pBest);\n        }\n\n        /* Open a read-only cursor, execute the OP_Count, close the cursor. */\n        sqlite3VdbeAddOp4Int(v, OP_OpenRead, iCsr, iRoot, iDb, 1);\n        if( pKeyInfo ){\n          sqlite3VdbeChangeP4(v, -1, (char *)pKeyInfo, P4_KEYINFO);\n        }\n        sqlite3VdbeAddOp2(v, OP_Count, iCsr, sAggInfo.aFunc[0].iMem);\n        sqlite3VdbeAddOp1(v, OP_Close, iCsr);\n        explainSimpleCount(pParse, pTab, pBest);\n      }else\n#endif /* SQLITE_OMIT_BTREECOUNT */\n      {\n        int regAcc = 0;           /* \"populate accumulators\" flag */\n\n        /* If there are accumulator registers but no min() or max() functions,\n        ** allocate register regAcc. Register regAcc will contain 0 the first\n        ** time the inner loop runs, and 1 thereafter. The code generated\n        ** by updateAccumulator() only updates the accumulator registers if\n        ** regAcc contains 0.  */\n        if( sAggInfo.nAccumulator ){\n          for(i=0; i<sAggInfo.nFunc; i++){\n            if( sAggInfo.aFunc[i].pFunc->funcFlags&SQLITE_FUNC_NEEDCOLL ) break;\n          }\n          if( i==sAggInfo.nFunc ){\n            regAcc = ++pParse->nMem;\n            sqlite3VdbeAddOp2(v, OP_Integer, 0, regAcc);\n          }\n        }\n\n        /* This case runs if the aggregate has no GROUP BY clause.  The\n        ** processing is much simpler since there is only a single row\n        ** of output.\n        */\n        assert( p->pGroupBy==0 );\n        resetAccumulator(pParse, &sAggInfo);\n\n        /* If this query is a candidate for the min/max optimization, then\n        ** minMaxFlag will have been previously set to either\n        ** WHERE_ORDERBY_MIN or WHERE_ORDERBY_MAX and pMinMaxOrderBy will\n        ** be an appropriate ORDER BY expression for the optimization.\n        */\n        assert( minMaxFlag==WHERE_ORDERBY_NORMAL || pMinMaxOrderBy!=0 );\n        assert( pMinMaxOrderBy==0 || pMinMaxOrderBy->nExpr==1 );\n\n        SELECTTRACE(1,pParse,p,(\"WhereBegin\\n\"));\n        pWInfo = sqlite3WhereBegin(pParse, pTabList, pWhere, pMinMaxOrderBy,\n                                   0, minMaxFlag, 0);\n        if( pWInfo==0 ){\n          goto select_end;\n        }\n        updateAccumulator(pParse, regAcc, &sAggInfo);\n        if( regAcc ) sqlite3VdbeAddOp2(v, OP_Integer, 1, regAcc);\n        if( sqlite3WhereIsOrdered(pWInfo)>0 ){\n          sqlite3VdbeGoto(v, sqlite3WhereBreakLabel(pWInfo));\n          VdbeComment((v, \"%s() by index\",\n                (minMaxFlag==WHERE_ORDERBY_MIN?\"min\":\"max\")));\n        }\n        sqlite3WhereEnd(pWInfo);\n        finalizeAggFunctions(pParse, &sAggInfo);\n      }\n\n      sSort.pOrderBy = 0;\n      sqlite3ExprIfFalse(pParse, pHaving, addrEnd, SQLITE_JUMPIFNULL);\n      selectInnerLoop(pParse, p, -1, 0, 0, \n                      pDest, addrEnd, addrEnd);\n    }\n    sqlite3VdbeResolveLabel(v, addrEnd);\n    \n  } /* endif aggregate query */\n\n  if( sDistinct.eTnctType==WHERE_DISTINCT_UNORDERED ){\n    explainTempTable(pParse, \"DISTINCT\");\n  }\n\n  /* If there is an ORDER BY clause, then we need to sort the results\n  ** and send them to the callback one by one.\n  */\n  if( sSort.pOrderBy ){\n    explainTempTable(pParse,\n                     sSort.nOBSat>0 ? \"RIGHT PART OF ORDER BY\":\"ORDER BY\");\n    assert( p->pEList==pEList );\n    generateSortTail(pParse, p, &sSort, pEList->nExpr, pDest);\n  }\n\n  /* Jump here to skip this query\n  */\n  sqlite3VdbeResolveLabel(v, iEnd);\n\n  /* The SELECT has been coded. If there is an error in the Parse structure,\n  ** set the return code to 1. Otherwise 0. */\n  rc = (pParse->nErr>0);\n\n  /* Control jumps to here if an error is encountered above, or upon\n  ** successful coding of the SELECT.\n  */\nselect_end:\n  sqlite3ExprListDelete(db, pMinMaxOrderBy);\n  sqlite3DbFree(db, sAggInfo.aCol);\n  sqlite3DbFree(db, sAggInfo.aFunc);\n#if SELECTTRACE_ENABLED\n  SELECTTRACE(0x1,pParse,p,(\"end processing\\n\"));\n  if( (sqlite3SelectTrace & 0x2000)!=0 && ExplainQueryPlanParent(pParse)==0 ){\n    sqlite3TreeViewSelect(0, p, 0);\n  }\n#endif\n  ExplainQueryPlanPop(pParse);\n  return rc;\n}\n\n/************** End of select.c **********************************************/\n/************** Begin file table.c *******************************************/\n/*\n** 2001 September 15\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This file contains the sqlite3_get_table() and sqlite3_free_table()\n** interface routines.  These are just wrappers around the main\n** interface routine of sqlite3_exec().\n**\n** These routines are in a separate files so that they will not be linked\n** if they are not used.\n*/\n/* #include \"sqliteInt.h\" */\n\n#ifndef SQLITE_OMIT_GET_TABLE\n\n/*\n** This structure is used to pass data from sqlite3_get_table() through\n** to the callback function is uses to build the result.\n*/\ntypedef struct TabResult {\n  char **azResult;   /* Accumulated output */\n  char *zErrMsg;     /* Error message text, if an error occurs */\n  u32 nAlloc;        /* Slots allocated for azResult[] */\n  u32 nRow;          /* Number of rows in the result */\n  u32 nColumn;       /* Number of columns in the result */\n  u32 nData;         /* Slots used in azResult[].  (nRow+1)*nColumn */\n  int rc;            /* Return code from sqlite3_exec() */\n} TabResult;\n\n/*\n** This routine is called once for each row in the result table.  Its job\n** is to fill in the TabResult structure appropriately, allocating new\n** memory as necessary.\n*/\nstatic int sqlite3_get_table_cb(void *pArg, int nCol, char **argv, char **colv){\n  TabResult *p = (TabResult*)pArg;  /* Result accumulator */\n  int need;                         /* Slots needed in p->azResult[] */\n  int i;                            /* Loop counter */\n  char *z;                          /* A single column of result */\n\n  /* Make sure there is enough space in p->azResult to hold everything\n  ** we need to remember from this invocation of the callback.\n  */\n  if( p->nRow==0 && argv!=0 ){\n    need = nCol*2;\n  }else{\n    need = nCol;\n  }\n  if( p->nData + need > p->nAlloc ){\n    char **azNew;\n    p->nAlloc = p->nAlloc*2 + need;\n    azNew = sqlite3_realloc64( p->azResult, sizeof(char*)*p->nAlloc );\n    if( azNew==0 ) goto malloc_failed;\n    p->azResult = azNew;\n  }\n\n  /* If this is the first row, then generate an extra row containing\n  ** the names of all columns.\n  */\n  if( p->nRow==0 ){\n    p->nColumn = nCol;\n    for(i=0; i<nCol; i++){\n      z = sqlite3_mprintf(\"%s\", colv[i]);\n      if( z==0 ) goto malloc_failed;\n      p->azResult[p->nData++] = z;\n    }\n  }else if( (int)p->nColumn!=nCol ){\n    sqlite3_free(p->zErrMsg);\n    p->zErrMsg = sqlite3_mprintf(\n       \"sqlite3_get_table() called with two or more incompatible queries\"\n    );\n    p->rc = SQLITE_ERROR;\n    return 1;\n  }\n\n  /* Copy over the row data\n  */\n  if( argv!=0 ){\n    for(i=0; i<nCol; i++){\n      if( argv[i]==0 ){\n        z = 0;\n      }else{\n        int n = sqlite3Strlen30(argv[i])+1;\n        z = sqlite3_malloc64( n );\n        if( z==0 ) goto malloc_failed;\n        memcpy(z, argv[i], n);\n      }\n      p->azResult[p->nData++] = z;\n    }\n    p->nRow++;\n  }\n  return 0;\n\nmalloc_failed:\n  p->rc = SQLITE_NOMEM_BKPT;\n  return 1;\n}\n\n/*\n** Query the database.  But instead of invoking a callback for each row,\n** malloc() for space to hold the result and return the entire results\n** at the conclusion of the call.\n**\n** The result that is written to ***pazResult is held in memory obtained\n** from malloc().  But the caller cannot free this memory directly.  \n** Instead, the entire table should be passed to sqlite3_free_table() when\n** the calling procedure is finished using it.\n*/\nSQLITE_API int sqlite3_get_table(\n  sqlite3 *db,                /* The database on which the SQL executes */\n  const char *zSql,           /* The SQL to be executed */\n  char ***pazResult,          /* Write the result table here */\n  int *pnRow,                 /* Write the number of rows in the result here */\n  int *pnColumn,              /* Write the number of columns of result here */\n  char **pzErrMsg             /* Write error messages here */\n){\n  int rc;\n  TabResult res;\n\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( !sqlite3SafetyCheckOk(db) || pazResult==0 ) return SQLITE_MISUSE_BKPT;\n#endif\n  *pazResult = 0;\n  if( pnColumn ) *pnColumn = 0;\n  if( pnRow ) *pnRow = 0;\n  if( pzErrMsg ) *pzErrMsg = 0;\n  res.zErrMsg = 0;\n  res.nRow = 0;\n  res.nColumn = 0;\n  res.nData = 1;\n  res.nAlloc = 20;\n  res.rc = SQLITE_OK;\n  res.azResult = sqlite3_malloc64(sizeof(char*)*res.nAlloc );\n  if( res.azResult==0 ){\n     db->errCode = SQLITE_NOMEM;\n     return SQLITE_NOMEM_BKPT;\n  }\n  res.azResult[0] = 0;\n  rc = sqlite3_exec(db, zSql, sqlite3_get_table_cb, &res, pzErrMsg);\n  assert( sizeof(res.azResult[0])>= sizeof(res.nData) );\n  res.azResult[0] = SQLITE_INT_TO_PTR(res.nData);\n  if( (rc&0xff)==SQLITE_ABORT ){\n    sqlite3_free_table(&res.azResult[1]);\n    if( res.zErrMsg ){\n      if( pzErrMsg ){\n        sqlite3_free(*pzErrMsg);\n        *pzErrMsg = sqlite3_mprintf(\"%s\",res.zErrMsg);\n      }\n      sqlite3_free(res.zErrMsg);\n    }\n    db->errCode = res.rc;  /* Assume 32-bit assignment is atomic */\n    return res.rc;\n  }\n  sqlite3_free(res.zErrMsg);\n  if( rc!=SQLITE_OK ){\n    sqlite3_free_table(&res.azResult[1]);\n    return rc;\n  }\n  if( res.nAlloc>res.nData ){\n    char **azNew;\n    azNew = sqlite3_realloc64( res.azResult, sizeof(char*)*res.nData );\n    if( azNew==0 ){\n      sqlite3_free_table(&res.azResult[1]);\n      db->errCode = SQLITE_NOMEM;\n      return SQLITE_NOMEM_BKPT;\n    }\n    res.azResult = azNew;\n  }\n  *pazResult = &res.azResult[1];\n  if( pnColumn ) *pnColumn = res.nColumn;\n  if( pnRow ) *pnRow = res.nRow;\n  return rc;\n}\n\n/*\n** This routine frees the space the sqlite3_get_table() malloced.\n*/\nSQLITE_API void sqlite3_free_table(\n  char **azResult            /* Result returned from sqlite3_get_table() */\n){\n  if( azResult ){\n    int i, n;\n    azResult--;\n    assert( azResult!=0 );\n    n = SQLITE_PTR_TO_INT(azResult[0]);\n    for(i=1; i<n; i++){ if( azResult[i] ) sqlite3_free(azResult[i]); }\n    sqlite3_free(azResult);\n  }\n}\n\n#endif /* SQLITE_OMIT_GET_TABLE */\n\n/************** End of table.c ***********************************************/\n/************** Begin file trigger.c *****************************************/\n/*\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This file contains the implementation for TRIGGERs\n*/\n/* #include \"sqliteInt.h\" */\n\n#ifndef SQLITE_OMIT_TRIGGER\n/*\n** Delete a linked list of TriggerStep structures.\n*/\nSQLITE_PRIVATE void sqlite3DeleteTriggerStep(sqlite3 *db, TriggerStep *pTriggerStep){\n  while( pTriggerStep ){\n    TriggerStep * pTmp = pTriggerStep;\n    pTriggerStep = pTriggerStep->pNext;\n\n    sqlite3ExprDelete(db, pTmp->pWhere);\n    sqlite3ExprListDelete(db, pTmp->pExprList);\n    sqlite3SelectDelete(db, pTmp->pSelect);\n    sqlite3IdListDelete(db, pTmp->pIdList);\n    sqlite3UpsertDelete(db, pTmp->pUpsert);\n    sqlite3DbFree(db, pTmp->zSpan);\n\n    sqlite3DbFree(db, pTmp);\n  }\n}\n\n/*\n** Given table pTab, return a list of all the triggers attached to \n** the table. The list is connected by Trigger.pNext pointers.\n**\n** All of the triggers on pTab that are in the same database as pTab\n** are already attached to pTab->pTrigger.  But there might be additional\n** triggers on pTab in the TEMP schema.  This routine prepends all\n** TEMP triggers on pTab to the beginning of the pTab->pTrigger list\n** and returns the combined list.\n**\n** To state it another way:  This routine returns a list of all triggers\n** that fire off of pTab.  The list will include any TEMP triggers on\n** pTab as well as the triggers lised in pTab->pTrigger.\n*/\nSQLITE_PRIVATE Trigger *sqlite3TriggerList(Parse *pParse, Table *pTab){\n  Schema * const pTmpSchema = pParse->db->aDb[1].pSchema;\n  Trigger *pList = 0;                  /* List of triggers to return */\n\n  if( pParse->disableTriggers ){\n    return 0;\n  }\n\n  if( pTmpSchema!=pTab->pSchema ){\n    HashElem *p;\n    assert( sqlite3SchemaMutexHeld(pParse->db, 0, pTmpSchema) );\n    for(p=sqliteHashFirst(&pTmpSchema->trigHash); p; p=sqliteHashNext(p)){\n      Trigger *pTrig = (Trigger *)sqliteHashData(p);\n      if( pTrig->pTabSchema==pTab->pSchema\n       && 0==sqlite3StrICmp(pTrig->table, pTab->zName) \n      ){\n        pTrig->pNext = (pList ? pList : pTab->pTrigger);\n        pList = pTrig;\n      }\n    }\n  }\n\n  return (pList ? pList : pTab->pTrigger);\n}\n\n/*\n** This is called by the parser when it sees a CREATE TRIGGER statement\n** up to the point of the BEGIN before the trigger actions.  A Trigger\n** structure is generated based on the information available and stored\n** in pParse->pNewTrigger.  After the trigger actions have been parsed, the\n** sqlite3FinishTrigger() function is called to complete the trigger\n** construction process.\n*/\nSQLITE_PRIVATE void sqlite3BeginTrigger(\n  Parse *pParse,      /* The parse context of the CREATE TRIGGER statement */\n  Token *pName1,      /* The name of the trigger */\n  Token *pName2,      /* The name of the trigger */\n  int tr_tm,          /* One of TK_BEFORE, TK_AFTER, TK_INSTEAD */\n  int op,             /* One of TK_INSERT, TK_UPDATE, TK_DELETE */\n  IdList *pColumns,   /* column list if this is an UPDATE OF trigger */\n  SrcList *pTableName,/* The name of the table/view the trigger applies to */\n  Expr *pWhen,        /* WHEN clause */\n  int isTemp,         /* True if the TEMPORARY keyword is present */\n  int noErr           /* Suppress errors if the trigger already exists */\n){\n  Trigger *pTrigger = 0;  /* The new trigger */\n  Table *pTab;            /* Table that the trigger fires off of */\n  char *zName = 0;        /* Name of the trigger */\n  sqlite3 *db = pParse->db;  /* The database connection */\n  int iDb;                /* The database to store the trigger in */\n  Token *pName;           /* The unqualified db name */\n  DbFixer sFix;           /* State vector for the DB fixer */\n\n  assert( pName1!=0 );   /* pName1->z might be NULL, but not pName1 itself */\n  assert( pName2!=0 );\n  assert( op==TK_INSERT || op==TK_UPDATE || op==TK_DELETE );\n  assert( op>0 && op<0xff );\n  if( isTemp ){\n    /* If TEMP was specified, then the trigger name may not be qualified. */\n    if( pName2->n>0 ){\n      sqlite3ErrorMsg(pParse, \"temporary trigger may not have qualified name\");\n      goto trigger_cleanup;\n    }\n    iDb = 1;\n    pName = pName1;\n  }else{\n    /* Figure out the db that the trigger will be created in */\n    iDb = sqlite3TwoPartName(pParse, pName1, pName2, &pName);\n    if( iDb<0 ){\n      goto trigger_cleanup;\n    }\n  }\n  if( !pTableName || db->mallocFailed ){\n    goto trigger_cleanup;\n  }\n\n  /* A long-standing parser bug is that this syntax was allowed:\n  **\n  **    CREATE TRIGGER attached.demo AFTER INSERT ON attached.tab ....\n  **                                                 ^^^^^^^^\n  **\n  ** To maintain backwards compatibility, ignore the database\n  ** name on pTableName if we are reparsing out of SQLITE_MASTER.\n  */\n  if( db->init.busy && iDb!=1 ){\n    sqlite3DbFree(db, pTableName->a[0].zDatabase);\n    pTableName->a[0].zDatabase = 0;\n  }\n\n  /* If the trigger name was unqualified, and the table is a temp table,\n  ** then set iDb to 1 to create the trigger in the temporary database.\n  ** If sqlite3SrcListLookup() returns 0, indicating the table does not\n  ** exist, the error is caught by the block below.\n  */\n  pTab = sqlite3SrcListLookup(pParse, pTableName);\n  if( db->init.busy==0 && pName2->n==0 && pTab\n        && pTab->pSchema==db->aDb[1].pSchema ){\n    iDb = 1;\n  }\n\n  /* Ensure the table name matches database name and that the table exists */\n  if( db->mallocFailed ) goto trigger_cleanup;\n  assert( pTableName->nSrc==1 );\n  sqlite3FixInit(&sFix, pParse, iDb, \"trigger\", pName);\n  if( sqlite3FixSrcList(&sFix, pTableName) ){\n    goto trigger_cleanup;\n  }\n  pTab = sqlite3SrcListLookup(pParse, pTableName);\n  if( !pTab ){\n    /* The table does not exist. */\n    if( db->init.iDb==1 ){\n      /* Ticket #3810.\n      ** Normally, whenever a table is dropped, all associated triggers are\n      ** dropped too.  But if a TEMP trigger is created on a non-TEMP table\n      ** and the table is dropped by a different database connection, the\n      ** trigger is not visible to the database connection that does the\n      ** drop so the trigger cannot be dropped.  This results in an\n      ** \"orphaned trigger\" - a trigger whose associated table is missing.\n      */\n      db->init.orphanTrigger = 1;\n    }\n    goto trigger_cleanup;\n  }\n  if( IsVirtual(pTab) ){\n    sqlite3ErrorMsg(pParse, \"cannot create triggers on virtual tables\");\n    goto trigger_cleanup;\n  }\n\n  /* Check that the trigger name is not reserved and that no trigger of the\n  ** specified name exists */\n  zName = sqlite3NameFromToken(db, pName);\n  if( !zName || SQLITE_OK!=sqlite3CheckObjectName(pParse, zName) ){\n    goto trigger_cleanup;\n  }\n  assert( sqlite3SchemaMutexHeld(db, iDb, 0) );\n  if( !IN_RENAME_OBJECT ){\n    if( sqlite3HashFind(&(db->aDb[iDb].pSchema->trigHash),zName) ){\n      if( !noErr ){\n        sqlite3ErrorMsg(pParse, \"trigger %T already exists\", pName);\n      }else{\n        assert( !db->init.busy );\n        sqlite3CodeVerifySchema(pParse, iDb);\n      }\n      goto trigger_cleanup;\n    }\n  }\n\n  /* Do not create a trigger on a system table */\n  if( sqlite3StrNICmp(pTab->zName, \"sqlite_\", 7)==0 ){\n    sqlite3ErrorMsg(pParse, \"cannot create trigger on system table\");\n    goto trigger_cleanup;\n  }\n\n  /* INSTEAD of triggers are only for views and views only support INSTEAD\n  ** of triggers.\n  */\n  if( pTab->pSelect && tr_tm!=TK_INSTEAD ){\n    sqlite3ErrorMsg(pParse, \"cannot create %s trigger on view: %S\", \n        (tr_tm == TK_BEFORE)?\"BEFORE\":\"AFTER\", pTableName, 0);\n    goto trigger_cleanup;\n  }\n  if( !pTab->pSelect && tr_tm==TK_INSTEAD ){\n    sqlite3ErrorMsg(pParse, \"cannot create INSTEAD OF\"\n        \" trigger on table: %S\", pTableName, 0);\n    goto trigger_cleanup;\n  }\n\n#ifndef SQLITE_OMIT_AUTHORIZATION\n  if( !IN_RENAME_OBJECT ){\n    int iTabDb = sqlite3SchemaToIndex(db, pTab->pSchema);\n    int code = SQLITE_CREATE_TRIGGER;\n    const char *zDb = db->aDb[iTabDb].zDbSName;\n    const char *zDbTrig = isTemp ? db->aDb[1].zDbSName : zDb;\n    if( iTabDb==1 || isTemp ) code = SQLITE_CREATE_TEMP_TRIGGER;\n    if( sqlite3AuthCheck(pParse, code, zName, pTab->zName, zDbTrig) ){\n      goto trigger_cleanup;\n    }\n    if( sqlite3AuthCheck(pParse, SQLITE_INSERT, SCHEMA_TABLE(iTabDb),0,zDb)){\n      goto trigger_cleanup;\n    }\n  }\n#endif\n\n  /* INSTEAD OF triggers can only appear on views and BEFORE triggers\n  ** cannot appear on views.  So we might as well translate every\n  ** INSTEAD OF trigger into a BEFORE trigger.  It simplifies code\n  ** elsewhere.\n  */\n  if (tr_tm == TK_INSTEAD){\n    tr_tm = TK_BEFORE;\n  }\n\n  /* Build the Trigger object */\n  pTrigger = (Trigger*)sqlite3DbMallocZero(db, sizeof(Trigger));\n  if( pTrigger==0 ) goto trigger_cleanup;\n  pTrigger->zName = zName;\n  zName = 0;\n  pTrigger->table = sqlite3DbStrDup(db, pTableName->a[0].zName);\n  pTrigger->pSchema = db->aDb[iDb].pSchema;\n  pTrigger->pTabSchema = pTab->pSchema;\n  pTrigger->op = (u8)op;\n  pTrigger->tr_tm = tr_tm==TK_BEFORE ? TRIGGER_BEFORE : TRIGGER_AFTER;\n  if( IN_RENAME_OBJECT ){\n    sqlite3RenameTokenRemap(pParse, pTrigger->table, pTableName->a[0].zName);\n    pTrigger->pWhen = pWhen;\n    pWhen = 0;\n  }else{\n    pTrigger->pWhen = sqlite3ExprDup(db, pWhen, EXPRDUP_REDUCE);\n  }\n  pTrigger->pColumns = pColumns;\n  pColumns = 0;\n  assert( pParse->pNewTrigger==0 );\n  pParse->pNewTrigger = pTrigger;\n\ntrigger_cleanup:\n  sqlite3DbFree(db, zName);\n  sqlite3SrcListDelete(db, pTableName);\n  sqlite3IdListDelete(db, pColumns);\n  sqlite3ExprDelete(db, pWhen);\n  if( !pParse->pNewTrigger ){\n    sqlite3DeleteTrigger(db, pTrigger);\n  }else{\n    assert( pParse->pNewTrigger==pTrigger );\n  }\n}\n\n/*\n** This routine is called after all of the trigger actions have been parsed\n** in order to complete the process of building the trigger.\n*/\nSQLITE_PRIVATE void sqlite3FinishTrigger(\n  Parse *pParse,          /* Parser context */\n  TriggerStep *pStepList, /* The triggered program */\n  Token *pAll             /* Token that describes the complete CREATE TRIGGER */\n){\n  Trigger *pTrig = pParse->pNewTrigger;   /* Trigger being finished */\n  char *zName;                            /* Name of trigger */\n  sqlite3 *db = pParse->db;               /* The database */\n  DbFixer sFix;                           /* Fixer object */\n  int iDb;                                /* Database containing the trigger */\n  Token nameToken;                        /* Trigger name for error reporting */\n\n  pParse->pNewTrigger = 0;\n  if( NEVER(pParse->nErr) || !pTrig ) goto triggerfinish_cleanup;\n  zName = pTrig->zName;\n  iDb = sqlite3SchemaToIndex(pParse->db, pTrig->pSchema);\n  pTrig->step_list = pStepList;\n  while( pStepList ){\n    pStepList->pTrig = pTrig;\n    pStepList = pStepList->pNext;\n  }\n  sqlite3TokenInit(&nameToken, pTrig->zName);\n  sqlite3FixInit(&sFix, pParse, iDb, \"trigger\", &nameToken);\n  if( sqlite3FixTriggerStep(&sFix, pTrig->step_list) \n   || sqlite3FixExpr(&sFix, pTrig->pWhen) \n  ){\n    goto triggerfinish_cleanup;\n  }\n\n#ifndef SQLITE_OMIT_ALTERTABLE\n  if( IN_RENAME_OBJECT ){\n    assert( !db->init.busy );\n    pParse->pNewTrigger = pTrig;\n    pTrig = 0;\n  }else\n#endif\n\n  /* if we are not initializing,\n  ** build the sqlite_master entry\n  */\n  if( !db->init.busy ){\n    Vdbe *v;\n    char *z;\n\n    /* Make an entry in the sqlite_master table */\n    v = sqlite3GetVdbe(pParse);\n    if( v==0 ) goto triggerfinish_cleanup;\n    sqlite3BeginWriteOperation(pParse, 0, iDb);\n    z = sqlite3DbStrNDup(db, (char*)pAll->z, pAll->n);\n    testcase( z==0 );\n    sqlite3NestedParse(pParse,\n       \"INSERT INTO %Q.%s VALUES('trigger',%Q,%Q,0,'CREATE TRIGGER %q')\",\n       db->aDb[iDb].zDbSName, MASTER_NAME, zName,\n       pTrig->table, z);\n    sqlite3DbFree(db, z);\n    sqlite3ChangeCookie(pParse, iDb);\n    sqlite3VdbeAddParseSchemaOp(v, iDb,\n        sqlite3MPrintf(db, \"type='trigger' AND name='%q'\", zName));\n  }\n\n  if( db->init.busy ){\n    Trigger *pLink = pTrig;\n    Hash *pHash = &db->aDb[iDb].pSchema->trigHash;\n    assert( sqlite3SchemaMutexHeld(db, iDb, 0) );\n    pTrig = sqlite3HashInsert(pHash, zName, pTrig);\n    if( pTrig ){\n      sqlite3OomFault(db);\n    }else if( pLink->pSchema==pLink->pTabSchema ){\n      Table *pTab;\n      pTab = sqlite3HashFind(&pLink->pTabSchema->tblHash, pLink->table);\n      assert( pTab!=0 );\n      pLink->pNext = pTab->pTrigger;\n      pTab->pTrigger = pLink;\n    }\n  }\n\ntriggerfinish_cleanup:\n  sqlite3DeleteTrigger(db, pTrig);\n  assert( IN_RENAME_OBJECT || !pParse->pNewTrigger );\n  sqlite3DeleteTriggerStep(db, pStepList);\n}\n\n/*\n** Duplicate a range of text from an SQL statement, then convert all\n** whitespace characters into ordinary space characters.\n*/\nstatic char *triggerSpanDup(sqlite3 *db, const char *zStart, const char *zEnd){\n  char *z = sqlite3DbSpanDup(db, zStart, zEnd);\n  int i;\n  if( z ) for(i=0; z[i]; i++) if( sqlite3Isspace(z[i]) ) z[i] = ' ';\n  return z;\n}    \n\n/*\n** Turn a SELECT statement (that the pSelect parameter points to) into\n** a trigger step.  Return a pointer to a TriggerStep structure.\n**\n** The parser calls this routine when it finds a SELECT statement in\n** body of a TRIGGER.  \n*/\nSQLITE_PRIVATE TriggerStep *sqlite3TriggerSelectStep(\n  sqlite3 *db,                /* Database connection */\n  Select *pSelect,            /* The SELECT statement */\n  const char *zStart,         /* Start of SQL text */\n  const char *zEnd            /* End of SQL text */\n){\n  TriggerStep *pTriggerStep = sqlite3DbMallocZero(db, sizeof(TriggerStep));\n  if( pTriggerStep==0 ) {\n    sqlite3SelectDelete(db, pSelect);\n    return 0;\n  }\n  pTriggerStep->op = TK_SELECT;\n  pTriggerStep->pSelect = pSelect;\n  pTriggerStep->orconf = OE_Default;\n  pTriggerStep->zSpan = triggerSpanDup(db, zStart, zEnd);\n  return pTriggerStep;\n}\n\n/*\n** Allocate space to hold a new trigger step.  The allocated space\n** holds both the TriggerStep object and the TriggerStep.target.z string.\n**\n** If an OOM error occurs, NULL is returned and db->mallocFailed is set.\n*/\nstatic TriggerStep *triggerStepAllocate(\n  Parse *pParse,              /* Parser context */\n  u8 op,                      /* Trigger opcode */\n  Token *pName,               /* The target name */\n  const char *zStart,         /* Start of SQL text */\n  const char *zEnd            /* End of SQL text */\n){\n  sqlite3 *db = pParse->db;\n  TriggerStep *pTriggerStep;\n\n  pTriggerStep = sqlite3DbMallocZero(db, sizeof(TriggerStep) + pName->n + 1);\n  if( pTriggerStep ){\n    char *z = (char*)&pTriggerStep[1];\n    memcpy(z, pName->z, pName->n);\n    sqlite3Dequote(z);\n    pTriggerStep->zTarget = z;\n    pTriggerStep->op = op;\n    pTriggerStep->zSpan = triggerSpanDup(db, zStart, zEnd);\n    if( IN_RENAME_OBJECT ){\n      sqlite3RenameTokenMap(pParse, pTriggerStep->zTarget, pName);\n    }\n  }\n  return pTriggerStep;\n}\n\n/*\n** Build a trigger step out of an INSERT statement.  Return a pointer\n** to the new trigger step.\n**\n** The parser calls this routine when it sees an INSERT inside the\n** body of a trigger.\n*/\nSQLITE_PRIVATE TriggerStep *sqlite3TriggerInsertStep(\n  Parse *pParse,      /* Parser */\n  Token *pTableName,  /* Name of the table into which we insert */\n  IdList *pColumn,    /* List of columns in pTableName to insert into */\n  Select *pSelect,    /* A SELECT statement that supplies values */\n  u8 orconf,          /* The conflict algorithm (OE_Abort, OE_Replace, etc.) */\n  Upsert *pUpsert,    /* ON CONFLICT clauses for upsert */\n  const char *zStart, /* Start of SQL text */\n  const char *zEnd    /* End of SQL text */\n){\n  sqlite3 *db = pParse->db;\n  TriggerStep *pTriggerStep;\n\n  assert(pSelect != 0 || db->mallocFailed);\n\n  pTriggerStep = triggerStepAllocate(pParse, TK_INSERT, pTableName,zStart,zEnd);\n  if( pTriggerStep ){\n    if( IN_RENAME_OBJECT ){\n      pTriggerStep->pSelect = pSelect;\n      pSelect = 0;\n    }else{\n      pTriggerStep->pSelect = sqlite3SelectDup(db, pSelect, EXPRDUP_REDUCE);\n    }\n    pTriggerStep->pIdList = pColumn;\n    pTriggerStep->pUpsert = pUpsert;\n    pTriggerStep->orconf = orconf;\n  }else{\n    testcase( pColumn );\n    sqlite3IdListDelete(db, pColumn);\n    testcase( pUpsert );\n    sqlite3UpsertDelete(db, pUpsert);\n  }\n  sqlite3SelectDelete(db, pSelect);\n\n  return pTriggerStep;\n}\n\n/*\n** Construct a trigger step that implements an UPDATE statement and return\n** a pointer to that trigger step.  The parser calls this routine when it\n** sees an UPDATE statement inside the body of a CREATE TRIGGER.\n*/\nSQLITE_PRIVATE TriggerStep *sqlite3TriggerUpdateStep(\n  Parse *pParse,          /* Parser */\n  Token *pTableName,   /* Name of the table to be updated */\n  ExprList *pEList,    /* The SET clause: list of column and new values */\n  Expr *pWhere,        /* The WHERE clause */\n  u8 orconf,           /* The conflict algorithm. (OE_Abort, OE_Ignore, etc) */\n  const char *zStart,  /* Start of SQL text */\n  const char *zEnd     /* End of SQL text */\n){\n  sqlite3 *db = pParse->db;\n  TriggerStep *pTriggerStep;\n\n  pTriggerStep = triggerStepAllocate(pParse, TK_UPDATE, pTableName,zStart,zEnd);\n  if( pTriggerStep ){\n    if( IN_RENAME_OBJECT ){\n      pTriggerStep->pExprList = pEList;\n      pTriggerStep->pWhere = pWhere;\n      pEList = 0;\n      pWhere = 0;\n    }else{\n      pTriggerStep->pExprList = sqlite3ExprListDup(db, pEList, EXPRDUP_REDUCE);\n      pTriggerStep->pWhere = sqlite3ExprDup(db, pWhere, EXPRDUP_REDUCE);\n    }\n    pTriggerStep->orconf = orconf;\n  }\n  sqlite3ExprListDelete(db, pEList);\n  sqlite3ExprDelete(db, pWhere);\n  return pTriggerStep;\n}\n\n/*\n** Construct a trigger step that implements a DELETE statement and return\n** a pointer to that trigger step.  The parser calls this routine when it\n** sees a DELETE statement inside the body of a CREATE TRIGGER.\n*/\nSQLITE_PRIVATE TriggerStep *sqlite3TriggerDeleteStep(\n  Parse *pParse,          /* Parser */\n  Token *pTableName,      /* The table from which rows are deleted */\n  Expr *pWhere,           /* The WHERE clause */\n  const char *zStart,     /* Start of SQL text */\n  const char *zEnd        /* End of SQL text */\n){\n  sqlite3 *db = pParse->db;\n  TriggerStep *pTriggerStep;\n\n  pTriggerStep = triggerStepAllocate(pParse, TK_DELETE, pTableName,zStart,zEnd);\n  if( pTriggerStep ){\n    if( IN_RENAME_OBJECT ){\n      pTriggerStep->pWhere = pWhere;\n      pWhere = 0;\n    }else{\n      pTriggerStep->pWhere = sqlite3ExprDup(db, pWhere, EXPRDUP_REDUCE);\n    }\n    pTriggerStep->orconf = OE_Default;\n  }\n  sqlite3ExprDelete(db, pWhere);\n  return pTriggerStep;\n}\n\n/* \n** Recursively delete a Trigger structure\n*/\nSQLITE_PRIVATE void sqlite3DeleteTrigger(sqlite3 *db, Trigger *pTrigger){\n  if( pTrigger==0 ) return;\n  sqlite3DeleteTriggerStep(db, pTrigger->step_list);\n  sqlite3DbFree(db, pTrigger->zName);\n  sqlite3DbFree(db, pTrigger->table);\n  sqlite3ExprDelete(db, pTrigger->pWhen);\n  sqlite3IdListDelete(db, pTrigger->pColumns);\n  sqlite3DbFree(db, pTrigger);\n}\n\n/*\n** This function is called to drop a trigger from the database schema. \n**\n** This may be called directly from the parser and therefore identifies\n** the trigger by name.  The sqlite3DropTriggerPtr() routine does the\n** same job as this routine except it takes a pointer to the trigger\n** instead of the trigger name.\n**/\nSQLITE_PRIVATE void sqlite3DropTrigger(Parse *pParse, SrcList *pName, int noErr){\n  Trigger *pTrigger = 0;\n  int i;\n  const char *zDb;\n  const char *zName;\n  sqlite3 *db = pParse->db;\n\n  if( db->mallocFailed ) goto drop_trigger_cleanup;\n  if( SQLITE_OK!=sqlite3ReadSchema(pParse) ){\n    goto drop_trigger_cleanup;\n  }\n\n  assert( pName->nSrc==1 );\n  zDb = pName->a[0].zDatabase;\n  zName = pName->a[0].zName;\n  assert( zDb!=0 || sqlite3BtreeHoldsAllMutexes(db) );\n  for(i=OMIT_TEMPDB; i<db->nDb; i++){\n    int j = (i<2) ? i^1 : i;  /* Search TEMP before MAIN */\n    if( zDb && sqlite3StrICmp(db->aDb[j].zDbSName, zDb) ) continue;\n    assert( sqlite3SchemaMutexHeld(db, j, 0) );\n    pTrigger = sqlite3HashFind(&(db->aDb[j].pSchema->trigHash), zName);\n    if( pTrigger ) break;\n  }\n  if( !pTrigger ){\n    if( !noErr ){\n      sqlite3ErrorMsg(pParse, \"no such trigger: %S\", pName, 0);\n    }else{\n      sqlite3CodeVerifyNamedSchema(pParse, zDb);\n    }\n    pParse->checkSchema = 1;\n    goto drop_trigger_cleanup;\n  }\n  sqlite3DropTriggerPtr(pParse, pTrigger);\n\ndrop_trigger_cleanup:\n  sqlite3SrcListDelete(db, pName);\n}\n\n/*\n** Return a pointer to the Table structure for the table that a trigger\n** is set on.\n*/\nstatic Table *tableOfTrigger(Trigger *pTrigger){\n  return sqlite3HashFind(&pTrigger->pTabSchema->tblHash, pTrigger->table);\n}\n\n\n/*\n** Drop a trigger given a pointer to that trigger. \n*/\nSQLITE_PRIVATE void sqlite3DropTriggerPtr(Parse *pParse, Trigger *pTrigger){\n  Table   *pTable;\n  Vdbe *v;\n  sqlite3 *db = pParse->db;\n  int iDb;\n\n  iDb = sqlite3SchemaToIndex(pParse->db, pTrigger->pSchema);\n  assert( iDb>=0 && iDb<db->nDb );\n  pTable = tableOfTrigger(pTrigger);\n  assert( pTable );\n  assert( pTable->pSchema==pTrigger->pSchema || iDb==1 );\n#ifndef SQLITE_OMIT_AUTHORIZATION\n  {\n    int code = SQLITE_DROP_TRIGGER;\n    const char *zDb = db->aDb[iDb].zDbSName;\n    const char *zTab = SCHEMA_TABLE(iDb);\n    if( iDb==1 ) code = SQLITE_DROP_TEMP_TRIGGER;\n    if( sqlite3AuthCheck(pParse, code, pTrigger->zName, pTable->zName, zDb) ||\n      sqlite3AuthCheck(pParse, SQLITE_DELETE, zTab, 0, zDb) ){\n      return;\n    }\n  }\n#endif\n\n  /* Generate code to destroy the database record of the trigger.\n  */\n  assert( pTable!=0 );\n  if( (v = sqlite3GetVdbe(pParse))!=0 ){\n    sqlite3NestedParse(pParse,\n       \"DELETE FROM %Q.%s WHERE name=%Q AND type='trigger'\",\n       db->aDb[iDb].zDbSName, MASTER_NAME, pTrigger->zName\n    );\n    sqlite3ChangeCookie(pParse, iDb);\n    sqlite3VdbeAddOp4(v, OP_DropTrigger, iDb, 0, 0, pTrigger->zName, 0);\n  }\n}\n\n/*\n** Remove a trigger from the hash tables of the sqlite* pointer.\n*/\nSQLITE_PRIVATE void sqlite3UnlinkAndDeleteTrigger(sqlite3 *db, int iDb, const char *zName){\n  Trigger *pTrigger;\n  Hash *pHash;\n\n  assert( sqlite3SchemaMutexHeld(db, iDb, 0) );\n  pHash = &(db->aDb[iDb].pSchema->trigHash);\n  pTrigger = sqlite3HashInsert(pHash, zName, 0);\n  if( ALWAYS(pTrigger) ){\n    if( pTrigger->pSchema==pTrigger->pTabSchema ){\n      Table *pTab = tableOfTrigger(pTrigger);\n      Trigger **pp;\n      for(pp=&pTab->pTrigger; *pp!=pTrigger; pp=&((*pp)->pNext));\n      *pp = (*pp)->pNext;\n    }\n    sqlite3DeleteTrigger(db, pTrigger);\n    db->mDbFlags |= DBFLAG_SchemaChange;\n  }\n}\n\n/*\n** pEList is the SET clause of an UPDATE statement.  Each entry\n** in pEList is of the format <id>=<expr>.  If any of the entries\n** in pEList have an <id> which matches an identifier in pIdList,\n** then return TRUE.  If pIdList==NULL, then it is considered a\n** wildcard that matches anything.  Likewise if pEList==NULL then\n** it matches anything so always return true.  Return false only\n** if there is no match.\n*/\nstatic int checkColumnOverlap(IdList *pIdList, ExprList *pEList){\n  int e;\n  if( pIdList==0 || NEVER(pEList==0) ) return 1;\n  for(e=0; e<pEList->nExpr; e++){\n    if( sqlite3IdListIndex(pIdList, pEList->a[e].zName)>=0 ) return 1;\n  }\n  return 0; \n}\n\n/*\n** Return a list of all triggers on table pTab if there exists at least\n** one trigger that must be fired when an operation of type 'op' is \n** performed on the table, and, if that operation is an UPDATE, if at\n** least one of the columns in pChanges is being modified.\n*/\nSQLITE_PRIVATE Trigger *sqlite3TriggersExist(\n  Parse *pParse,          /* Parse context */\n  Table *pTab,            /* The table the contains the triggers */\n  int op,                 /* one of TK_DELETE, TK_INSERT, TK_UPDATE */\n  ExprList *pChanges,     /* Columns that change in an UPDATE statement */\n  int *pMask              /* OUT: Mask of TRIGGER_BEFORE|TRIGGER_AFTER */\n){\n  int mask = 0;\n  Trigger *pList = 0;\n  Trigger *p;\n\n  if( (pParse->db->flags & SQLITE_EnableTrigger)!=0 ){\n    pList = sqlite3TriggerList(pParse, pTab);\n  }\n  assert( pList==0 || IsVirtual(pTab)==0 );\n  for(p=pList; p; p=p->pNext){\n    if( p->op==op && checkColumnOverlap(p->pColumns, pChanges) ){\n      mask |= p->tr_tm;\n    }\n  }\n  if( pMask ){\n    *pMask = mask;\n  }\n  return (mask ? pList : 0);\n}\n\n/*\n** Convert the pStep->zTarget string into a SrcList and return a pointer\n** to that SrcList.\n**\n** This routine adds a specific database name, if needed, to the target when\n** forming the SrcList.  This prevents a trigger in one database from\n** referring to a target in another database.  An exception is when the\n** trigger is in TEMP in which case it can refer to any other database it\n** wants.\n*/\nstatic SrcList *targetSrcList(\n  Parse *pParse,       /* The parsing context */\n  TriggerStep *pStep   /* The trigger containing the target token */\n){\n  sqlite3 *db = pParse->db;\n  int iDb;             /* Index of the database to use */\n  SrcList *pSrc;       /* SrcList to be returned */\n\n  pSrc = sqlite3SrcListAppend(pParse, 0, 0, 0);\n  if( pSrc ){\n    assert( pSrc->nSrc>0 );\n    pSrc->a[pSrc->nSrc-1].zName = sqlite3DbStrDup(db, pStep->zTarget);\n    iDb = sqlite3SchemaToIndex(db, pStep->pTrig->pSchema);\n    if( iDb==0 || iDb>=2 ){\n      const char *zDb;\n      assert( iDb<db->nDb );\n      zDb = db->aDb[iDb].zDbSName;\n      pSrc->a[pSrc->nSrc-1].zDatabase =  sqlite3DbStrDup(db, zDb);\n    }\n  }\n  return pSrc;\n}\n\n/*\n** Generate VDBE code for the statements inside the body of a single \n** trigger.\n*/\nstatic int codeTriggerProgram(\n  Parse *pParse,            /* The parser context */\n  TriggerStep *pStepList,   /* List of statements inside the trigger body */\n  int orconf                /* Conflict algorithm. (OE_Abort, etc) */  \n){\n  TriggerStep *pStep;\n  Vdbe *v = pParse->pVdbe;\n  sqlite3 *db = pParse->db;\n\n  assert( pParse->pTriggerTab && pParse->pToplevel );\n  assert( pStepList );\n  assert( v!=0 );\n  for(pStep=pStepList; pStep; pStep=pStep->pNext){\n    /* Figure out the ON CONFLICT policy that will be used for this step\n    ** of the trigger program. If the statement that caused this trigger\n    ** to fire had an explicit ON CONFLICT, then use it. Otherwise, use\n    ** the ON CONFLICT policy that was specified as part of the trigger\n    ** step statement. Example:\n    **\n    **   CREATE TRIGGER AFTER INSERT ON t1 BEGIN;\n    **     INSERT OR REPLACE INTO t2 VALUES(new.a, new.b);\n    **   END;\n    **\n    **   INSERT INTO t1 ... ;            -- insert into t2 uses REPLACE policy\n    **   INSERT OR IGNORE INTO t1 ... ;  -- insert into t2 uses IGNORE policy\n    */\n    pParse->eOrconf = (orconf==OE_Default)?pStep->orconf:(u8)orconf;\n    assert( pParse->okConstFactor==0 );\n\n#ifndef SQLITE_OMIT_TRACE\n    if( pStep->zSpan ){\n      sqlite3VdbeAddOp4(v, OP_Trace, 0x7fffffff, 1, 0,\n                        sqlite3MPrintf(db, \"-- %s\", pStep->zSpan),\n                        P4_DYNAMIC);\n    }\n#endif\n\n    switch( pStep->op ){\n      case TK_UPDATE: {\n        sqlite3Update(pParse, \n          targetSrcList(pParse, pStep),\n          sqlite3ExprListDup(db, pStep->pExprList, 0), \n          sqlite3ExprDup(db, pStep->pWhere, 0), \n          pParse->eOrconf, 0, 0, 0\n        );\n        break;\n      }\n      case TK_INSERT: {\n        sqlite3Insert(pParse, \n          targetSrcList(pParse, pStep),\n          sqlite3SelectDup(db, pStep->pSelect, 0), \n          sqlite3IdListDup(db, pStep->pIdList), \n          pParse->eOrconf,\n          sqlite3UpsertDup(db, pStep->pUpsert)\n        );\n        break;\n      }\n      case TK_DELETE: {\n        sqlite3DeleteFrom(pParse, \n          targetSrcList(pParse, pStep),\n          sqlite3ExprDup(db, pStep->pWhere, 0), 0, 0\n        );\n        break;\n      }\n      default: assert( pStep->op==TK_SELECT ); {\n        SelectDest sDest;\n        Select *pSelect = sqlite3SelectDup(db, pStep->pSelect, 0);\n        sqlite3SelectDestInit(&sDest, SRT_Discard, 0);\n        sqlite3Select(pParse, pSelect, &sDest);\n        sqlite3SelectDelete(db, pSelect);\n        break;\n      }\n    } \n    if( pStep->op!=TK_SELECT ){\n      sqlite3VdbeAddOp0(v, OP_ResetCount);\n    }\n  }\n\n  return 0;\n}\n\n#ifdef SQLITE_ENABLE_EXPLAIN_COMMENTS\n/*\n** This function is used to add VdbeComment() annotations to a VDBE\n** program. It is not used in production code, only for debugging.\n*/\nstatic const char *onErrorText(int onError){\n  switch( onError ){\n    case OE_Abort:    return \"abort\";\n    case OE_Rollback: return \"rollback\";\n    case OE_Fail:     return \"fail\";\n    case OE_Replace:  return \"replace\";\n    case OE_Ignore:   return \"ignore\";\n    case OE_Default:  return \"default\";\n  }\n  return \"n/a\";\n}\n#endif\n\n/*\n** Parse context structure pFrom has just been used to create a sub-vdbe\n** (trigger program). If an error has occurred, transfer error information\n** from pFrom to pTo.\n*/\nstatic void transferParseError(Parse *pTo, Parse *pFrom){\n  assert( pFrom->zErrMsg==0 || pFrom->nErr );\n  assert( pTo->zErrMsg==0 || pTo->nErr );\n  if( pTo->nErr==0 ){\n    pTo->zErrMsg = pFrom->zErrMsg;\n    pTo->nErr = pFrom->nErr;\n    pTo->rc = pFrom->rc;\n  }else{\n    sqlite3DbFree(pFrom->db, pFrom->zErrMsg);\n  }\n}\n\n/*\n** Create and populate a new TriggerPrg object with a sub-program \n** implementing trigger pTrigger with ON CONFLICT policy orconf.\n*/\nstatic TriggerPrg *codeRowTrigger(\n  Parse *pParse,       /* Current parse context */\n  Trigger *pTrigger,   /* Trigger to code */\n  Table *pTab,         /* The table pTrigger is attached to */\n  int orconf           /* ON CONFLICT policy to code trigger program with */\n){\n  Parse *pTop = sqlite3ParseToplevel(pParse);\n  sqlite3 *db = pParse->db;   /* Database handle */\n  TriggerPrg *pPrg;           /* Value to return */\n  Expr *pWhen = 0;            /* Duplicate of trigger WHEN expression */\n  Vdbe *v;                    /* Temporary VM */\n  NameContext sNC;            /* Name context for sub-vdbe */\n  SubProgram *pProgram = 0;   /* Sub-vdbe for trigger program */\n  Parse *pSubParse;           /* Parse context for sub-vdbe */\n  int iEndTrigger = 0;        /* Label to jump to if WHEN is false */\n\n  assert( pTrigger->zName==0 || pTab==tableOfTrigger(pTrigger) );\n  assert( pTop->pVdbe );\n\n  /* Allocate the TriggerPrg and SubProgram objects. To ensure that they\n  ** are freed if an error occurs, link them into the Parse.pTriggerPrg \n  ** list of the top-level Parse object sooner rather than later.  */\n  pPrg = sqlite3DbMallocZero(db, sizeof(TriggerPrg));\n  if( !pPrg ) return 0;\n  pPrg->pNext = pTop->pTriggerPrg;\n  pTop->pTriggerPrg = pPrg;\n  pPrg->pProgram = pProgram = sqlite3DbMallocZero(db, sizeof(SubProgram));\n  if( !pProgram ) return 0;\n  sqlite3VdbeLinkSubProgram(pTop->pVdbe, pProgram);\n  pPrg->pTrigger = pTrigger;\n  pPrg->orconf = orconf;\n  pPrg->aColmask[0] = 0xffffffff;\n  pPrg->aColmask[1] = 0xffffffff;\n\n  /* Allocate and populate a new Parse context to use for coding the \n  ** trigger sub-program.  */\n  pSubParse = sqlite3StackAllocZero(db, sizeof(Parse));\n  if( !pSubParse ) return 0;\n  memset(&sNC, 0, sizeof(sNC));\n  sNC.pParse = pSubParse;\n  pSubParse->db = db;\n  pSubParse->pTriggerTab = pTab;\n  pSubParse->pToplevel = pTop;\n  pSubParse->zAuthContext = pTrigger->zName;\n  pSubParse->eTriggerOp = pTrigger->op;\n  pSubParse->nQueryLoop = pParse->nQueryLoop;\n  pSubParse->disableVtab = pParse->disableVtab;\n\n  v = sqlite3GetVdbe(pSubParse);\n  if( v ){\n    VdbeComment((v, \"Start: %s.%s (%s %s%s%s ON %s)\", \n      pTrigger->zName, onErrorText(orconf),\n      (pTrigger->tr_tm==TRIGGER_BEFORE ? \"BEFORE\" : \"AFTER\"),\n        (pTrigger->op==TK_UPDATE ? \"UPDATE\" : \"\"),\n        (pTrigger->op==TK_INSERT ? \"INSERT\" : \"\"),\n        (pTrigger->op==TK_DELETE ? \"DELETE\" : \"\"),\n      pTab->zName\n    ));\n#ifndef SQLITE_OMIT_TRACE\n    if( pTrigger->zName ){\n      sqlite3VdbeChangeP4(v, -1, \n        sqlite3MPrintf(db, \"-- TRIGGER %s\", pTrigger->zName), P4_DYNAMIC\n      );\n    }\n#endif\n\n    /* If one was specified, code the WHEN clause. If it evaluates to false\n    ** (or NULL) the sub-vdbe is immediately halted by jumping to the \n    ** OP_Halt inserted at the end of the program.  */\n    if( pTrigger->pWhen ){\n      pWhen = sqlite3ExprDup(db, pTrigger->pWhen, 0);\n      if( SQLITE_OK==sqlite3ResolveExprNames(&sNC, pWhen) \n       && db->mallocFailed==0 \n      ){\n        iEndTrigger = sqlite3VdbeMakeLabel(pSubParse);\n        sqlite3ExprIfFalse(pSubParse, pWhen, iEndTrigger, SQLITE_JUMPIFNULL);\n      }\n      sqlite3ExprDelete(db, pWhen);\n    }\n\n    /* Code the trigger program into the sub-vdbe. */\n    codeTriggerProgram(pSubParse, pTrigger->step_list, orconf);\n\n    /* Insert an OP_Halt at the end of the sub-program. */\n    if( iEndTrigger ){\n      sqlite3VdbeResolveLabel(v, iEndTrigger);\n    }\n    sqlite3VdbeAddOp0(v, OP_Halt);\n    VdbeComment((v, \"End: %s.%s\", pTrigger->zName, onErrorText(orconf)));\n\n    transferParseError(pParse, pSubParse);\n    if( db->mallocFailed==0 && pParse->nErr==0 ){\n      pProgram->aOp = sqlite3VdbeTakeOpArray(v, &pProgram->nOp, &pTop->nMaxArg);\n    }\n    pProgram->nMem = pSubParse->nMem;\n    pProgram->nCsr = pSubParse->nTab;\n    pProgram->token = (void *)pTrigger;\n    pPrg->aColmask[0] = pSubParse->oldmask;\n    pPrg->aColmask[1] = pSubParse->newmask;\n    sqlite3VdbeDelete(v);\n  }\n\n  assert( !pSubParse->pAinc       && !pSubParse->pZombieTab );\n  assert( !pSubParse->pTriggerPrg && !pSubParse->nMaxArg );\n  sqlite3ParserReset(pSubParse);\n  sqlite3StackFree(db, pSubParse);\n\n  return pPrg;\n}\n    \n/*\n** Return a pointer to a TriggerPrg object containing the sub-program for\n** trigger pTrigger with default ON CONFLICT algorithm orconf. If no such\n** TriggerPrg object exists, a new object is allocated and populated before\n** being returned.\n*/\nstatic TriggerPrg *getRowTrigger(\n  Parse *pParse,       /* Current parse context */\n  Trigger *pTrigger,   /* Trigger to code */\n  Table *pTab,         /* The table trigger pTrigger is attached to */\n  int orconf           /* ON CONFLICT algorithm. */\n){\n  Parse *pRoot = sqlite3ParseToplevel(pParse);\n  TriggerPrg *pPrg;\n\n  assert( pTrigger->zName==0 || pTab==tableOfTrigger(pTrigger) );\n\n  /* It may be that this trigger has already been coded (or is in the\n  ** process of being coded). If this is the case, then an entry with\n  ** a matching TriggerPrg.pTrigger field will be present somewhere\n  ** in the Parse.pTriggerPrg list. Search for such an entry.  */\n  for(pPrg=pRoot->pTriggerPrg; \n      pPrg && (pPrg->pTrigger!=pTrigger || pPrg->orconf!=orconf); \n      pPrg=pPrg->pNext\n  );\n\n  /* If an existing TriggerPrg could not be located, create a new one. */\n  if( !pPrg ){\n    pPrg = codeRowTrigger(pParse, pTrigger, pTab, orconf);\n  }\n\n  return pPrg;\n}\n\n/*\n** Generate code for the trigger program associated with trigger p on \n** table pTab. The reg, orconf and ignoreJump parameters passed to this\n** function are the same as those described in the header function for\n** sqlite3CodeRowTrigger()\n*/\nSQLITE_PRIVATE void sqlite3CodeRowTriggerDirect(\n  Parse *pParse,       /* Parse context */\n  Trigger *p,          /* Trigger to code */\n  Table *pTab,         /* The table to code triggers from */\n  int reg,             /* Reg array containing OLD.* and NEW.* values */\n  int orconf,          /* ON CONFLICT policy */\n  int ignoreJump       /* Instruction to jump to for RAISE(IGNORE) */\n){\n  Vdbe *v = sqlite3GetVdbe(pParse); /* Main VM */\n  TriggerPrg *pPrg;\n  pPrg = getRowTrigger(pParse, p, pTab, orconf);\n  assert( pPrg || pParse->nErr || pParse->db->mallocFailed );\n\n  /* Code the OP_Program opcode in the parent VDBE. P4 of the OP_Program \n  ** is a pointer to the sub-vdbe containing the trigger program.  */\n  if( pPrg ){\n    int bRecursive = (p->zName && 0==(pParse->db->flags&SQLITE_RecTriggers));\n\n    sqlite3VdbeAddOp4(v, OP_Program, reg, ignoreJump, ++pParse->nMem,\n                      (const char *)pPrg->pProgram, P4_SUBPROGRAM);\n    VdbeComment(\n        (v, \"Call: %s.%s\", (p->zName?p->zName:\"fkey\"), onErrorText(orconf)));\n\n    /* Set the P5 operand of the OP_Program instruction to non-zero if\n    ** recursive invocation of this trigger program is disallowed. Recursive\n    ** invocation is disallowed if (a) the sub-program is really a trigger,\n    ** not a foreign key action, and (b) the flag to enable recursive triggers\n    ** is clear.  */\n    sqlite3VdbeChangeP5(v, (u8)bRecursive);\n  }\n}\n\n/*\n** This is called to code the required FOR EACH ROW triggers for an operation\n** on table pTab. The operation to code triggers for (INSERT, UPDATE or DELETE)\n** is given by the op parameter. The tr_tm parameter determines whether the\n** BEFORE or AFTER triggers are coded. If the operation is an UPDATE, then\n** parameter pChanges is passed the list of columns being modified.\n**\n** If there are no triggers that fire at the specified time for the specified\n** operation on pTab, this function is a no-op.\n**\n** The reg argument is the address of the first in an array of registers \n** that contain the values substituted for the new.* and old.* references\n** in the trigger program. If N is the number of columns in table pTab\n** (a copy of pTab->nCol), then registers are populated as follows:\n**\n**   Register       Contains\n**   ------------------------------------------------------\n**   reg+0          OLD.rowid\n**   reg+1          OLD.* value of left-most column of pTab\n**   ...            ...\n**   reg+N          OLD.* value of right-most column of pTab\n**   reg+N+1        NEW.rowid\n**   reg+N+2        OLD.* value of left-most column of pTab\n**   ...            ...\n**   reg+N+N+1      NEW.* value of right-most column of pTab\n**\n** For ON DELETE triggers, the registers containing the NEW.* values will\n** never be accessed by the trigger program, so they are not allocated or \n** populated by the caller (there is no data to populate them with anyway). \n** Similarly, for ON INSERT triggers the values stored in the OLD.* registers\n** are never accessed, and so are not allocated by the caller. So, for an\n** ON INSERT trigger, the value passed to this function as parameter reg\n** is not a readable register, although registers (reg+N) through \n** (reg+N+N+1) are.\n**\n** Parameter orconf is the default conflict resolution algorithm for the\n** trigger program to use (REPLACE, IGNORE etc.). Parameter ignoreJump\n** is the instruction that control should jump to if a trigger program\n** raises an IGNORE exception.\n*/\nSQLITE_PRIVATE void sqlite3CodeRowTrigger(\n  Parse *pParse,       /* Parse context */\n  Trigger *pTrigger,   /* List of triggers on table pTab */\n  int op,              /* One of TK_UPDATE, TK_INSERT, TK_DELETE */\n  ExprList *pChanges,  /* Changes list for any UPDATE OF triggers */\n  int tr_tm,           /* One of TRIGGER_BEFORE, TRIGGER_AFTER */\n  Table *pTab,         /* The table to code triggers from */\n  int reg,             /* The first in an array of registers (see above) */\n  int orconf,          /* ON CONFLICT policy */\n  int ignoreJump       /* Instruction to jump to for RAISE(IGNORE) */\n){\n  Trigger *p;          /* Used to iterate through pTrigger list */\n\n  assert( op==TK_UPDATE || op==TK_INSERT || op==TK_DELETE );\n  assert( tr_tm==TRIGGER_BEFORE || tr_tm==TRIGGER_AFTER );\n  assert( (op==TK_UPDATE)==(pChanges!=0) );\n\n  for(p=pTrigger; p; p=p->pNext){\n\n    /* Sanity checking:  The schema for the trigger and for the table are\n    ** always defined.  The trigger must be in the same schema as the table\n    ** or else it must be a TEMP trigger. */\n    assert( p->pSchema!=0 );\n    assert( p->pTabSchema!=0 );\n    assert( p->pSchema==p->pTabSchema \n         || p->pSchema==pParse->db->aDb[1].pSchema );\n\n    /* Determine whether we should code this trigger */\n    if( p->op==op \n     && p->tr_tm==tr_tm \n     && checkColumnOverlap(p->pColumns, pChanges)\n    ){\n      sqlite3CodeRowTriggerDirect(pParse, p, pTab, reg, orconf, ignoreJump);\n    }\n  }\n}\n\n/*\n** Triggers may access values stored in the old.* or new.* pseudo-table. \n** This function returns a 32-bit bitmask indicating which columns of the \n** old.* or new.* tables actually are used by triggers. This information \n** may be used by the caller, for example, to avoid having to load the entire\n** old.* record into memory when executing an UPDATE or DELETE command.\n**\n** Bit 0 of the returned mask is set if the left-most column of the\n** table may be accessed using an [old|new].<col> reference. Bit 1 is set if\n** the second leftmost column value is required, and so on. If there\n** are more than 32 columns in the table, and at least one of the columns\n** with an index greater than 32 may be accessed, 0xffffffff is returned.\n**\n** It is not possible to determine if the old.rowid or new.rowid column is \n** accessed by triggers. The caller must always assume that it is.\n**\n** Parameter isNew must be either 1 or 0. If it is 0, then the mask returned\n** applies to the old.* table. If 1, the new.* table.\n**\n** Parameter tr_tm must be a mask with one or both of the TRIGGER_BEFORE\n** and TRIGGER_AFTER bits set. Values accessed by BEFORE triggers are only\n** included in the returned mask if the TRIGGER_BEFORE bit is set in the\n** tr_tm parameter. Similarly, values accessed by AFTER triggers are only\n** included in the returned mask if the TRIGGER_AFTER bit is set in tr_tm.\n*/\nSQLITE_PRIVATE u32 sqlite3TriggerColmask(\n  Parse *pParse,       /* Parse context */\n  Trigger *pTrigger,   /* List of triggers on table pTab */\n  ExprList *pChanges,  /* Changes list for any UPDATE OF triggers */\n  int isNew,           /* 1 for new.* ref mask, 0 for old.* ref mask */\n  int tr_tm,           /* Mask of TRIGGER_BEFORE|TRIGGER_AFTER */\n  Table *pTab,         /* The table to code triggers from */\n  int orconf           /* Default ON CONFLICT policy for trigger steps */\n){\n  const int op = pChanges ? TK_UPDATE : TK_DELETE;\n  u32 mask = 0;\n  Trigger *p;\n\n  assert( isNew==1 || isNew==0 );\n  for(p=pTrigger; p; p=p->pNext){\n    if( p->op==op && (tr_tm&p->tr_tm)\n     && checkColumnOverlap(p->pColumns,pChanges)\n    ){\n      TriggerPrg *pPrg;\n      pPrg = getRowTrigger(pParse, p, pTab, orconf);\n      if( pPrg ){\n        mask |= pPrg->aColmask[isNew];\n      }\n    }\n  }\n\n  return mask;\n}\n\n#endif /* !defined(SQLITE_OMIT_TRIGGER) */\n\n/************** End of trigger.c *********************************************/\n/************** Begin file update.c ******************************************/\n/*\n** 2001 September 15\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This file contains C code routines that are called by the parser\n** to handle UPDATE statements.\n*/\n/* #include \"sqliteInt.h\" */\n\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n/* Forward declaration */\nstatic void updateVirtualTable(\n  Parse *pParse,       /* The parsing context */\n  SrcList *pSrc,       /* The virtual table to be modified */\n  Table *pTab,         /* The virtual table */\n  ExprList *pChanges,  /* The columns to change in the UPDATE statement */\n  Expr *pRowidExpr,    /* Expression used to recompute the rowid */\n  int *aXRef,          /* Mapping from columns of pTab to entries in pChanges */\n  Expr *pWhere,        /* WHERE clause of the UPDATE statement */\n  int onError          /* ON CONFLICT strategy */\n);\n#endif /* SQLITE_OMIT_VIRTUALTABLE */\n\n/*\n** The most recently coded instruction was an OP_Column to retrieve the\n** i-th column of table pTab. This routine sets the P4 parameter of the \n** OP_Column to the default value, if any.\n**\n** The default value of a column is specified by a DEFAULT clause in the \n** column definition. This was either supplied by the user when the table\n** was created, or added later to the table definition by an ALTER TABLE\n** command. If the latter, then the row-records in the table btree on disk\n** may not contain a value for the column and the default value, taken\n** from the P4 parameter of the OP_Column instruction, is returned instead.\n** If the former, then all row-records are guaranteed to include a value\n** for the column and the P4 value is not required.\n**\n** Column definitions created by an ALTER TABLE command may only have \n** literal default values specified: a number, null or a string. (If a more\n** complicated default expression value was provided, it is evaluated \n** when the ALTER TABLE is executed and one of the literal values written\n** into the sqlite_master table.)\n**\n** Therefore, the P4 parameter is only required if the default value for\n** the column is a literal number, string or null. The sqlite3ValueFromExpr()\n** function is capable of transforming these types of expressions into\n** sqlite3_value objects.\n**\n** If parameter iReg is not negative, code an OP_RealAffinity instruction\n** on register iReg. This is used when an equivalent integer value is \n** stored in place of an 8-byte floating point value in order to save \n** space.\n*/\nSQLITE_PRIVATE void sqlite3ColumnDefault(Vdbe *v, Table *pTab, int i, int iReg){\n  assert( pTab!=0 );\n  if( !pTab->pSelect ){\n    sqlite3_value *pValue = 0;\n    u8 enc = ENC(sqlite3VdbeDb(v));\n    Column *pCol = &pTab->aCol[i];\n    VdbeComment((v, \"%s.%s\", pTab->zName, pCol->zName));\n    assert( i<pTab->nCol );\n    sqlite3ValueFromExpr(sqlite3VdbeDb(v), pCol->pDflt, enc, \n                         pCol->affinity, &pValue);\n    if( pValue ){\n      sqlite3VdbeAppendP4(v, pValue, P4_MEM);\n    }\n  }\n#ifndef SQLITE_OMIT_FLOATING_POINT\n  if( pTab->aCol[i].affinity==SQLITE_AFF_REAL ){\n    sqlite3VdbeAddOp1(v, OP_RealAffinity, iReg);\n  }\n#endif\n}\n\n/*\n** Check to see if column iCol of index pIdx references any of the\n** columns defined by aXRef and chngRowid.  Return true if it does\n** and false if not.  This is an optimization.  False-positives are a\n** performance degradation, but false-negatives can result in a corrupt\n** index and incorrect answers.\n**\n** aXRef[j] will be non-negative if column j of the original table is\n** being updated.  chngRowid will be true if the rowid of the table is\n** being updated.\n*/\nstatic int indexColumnIsBeingUpdated(\n  Index *pIdx,      /* The index to check */\n  int iCol,         /* Which column of the index to check */\n  int *aXRef,       /* aXRef[j]>=0 if column j is being updated */\n  int chngRowid     /* true if the rowid is being updated */\n){\n  i16 iIdxCol = pIdx->aiColumn[iCol];\n  assert( iIdxCol!=XN_ROWID ); /* Cannot index rowid */\n  if( iIdxCol>=0 ){\n    return aXRef[iIdxCol]>=0;\n  }\n  assert( iIdxCol==XN_EXPR );\n  assert( pIdx->aColExpr!=0 );\n  assert( pIdx->aColExpr->a[iCol].pExpr!=0 );\n  return sqlite3ExprReferencesUpdatedColumn(pIdx->aColExpr->a[iCol].pExpr,\n                                            aXRef,chngRowid);\n}\n\n/*\n** Check to see if index pIdx is a partial index whose conditional\n** expression might change values due to an UPDATE.  Return true if\n** the index is subject to change and false if the index is guaranteed\n** to be unchanged.  This is an optimization.  False-positives are a\n** performance degradation, but false-negatives can result in a corrupt\n** index and incorrect answers.\n**\n** aXRef[j] will be non-negative if column j of the original table is\n** being updated.  chngRowid will be true if the rowid of the table is\n** being updated.\n*/\nstatic int indexWhereClauseMightChange(\n  Index *pIdx,      /* The index to check */\n  int *aXRef,       /* aXRef[j]>=0 if column j is being updated */\n  int chngRowid     /* true if the rowid is being updated */\n){\n  if( pIdx->pPartIdxWhere==0 ) return 0;\n  return sqlite3ExprReferencesUpdatedColumn(pIdx->pPartIdxWhere,\n                                            aXRef, chngRowid);\n}\n\n/*\n** Process an UPDATE statement.\n**\n**   UPDATE OR IGNORE table_wxyz SET a=b, c=d WHERE e<5 AND f NOT NULL;\n**          \\_______/ \\________/     \\______/       \\________________/\n*            onError   pTabList      pChanges             pWhere\n*/\nSQLITE_PRIVATE void sqlite3Update(\n  Parse *pParse,         /* The parser context */\n  SrcList *pTabList,     /* The table in which we should change things */\n  ExprList *pChanges,    /* Things to be changed */\n  Expr *pWhere,          /* The WHERE clause.  May be null */\n  int onError,           /* How to handle constraint errors */\n  ExprList *pOrderBy,    /* ORDER BY clause. May be null */\n  Expr *pLimit,          /* LIMIT clause. May be null */\n  Upsert *pUpsert        /* ON CONFLICT clause, or null */\n){\n  int i, j;              /* Loop counters */\n  Table *pTab;           /* The table to be updated */\n  int addrTop = 0;       /* VDBE instruction address of the start of the loop */\n  WhereInfo *pWInfo;     /* Information about the WHERE clause */\n  Vdbe *v;               /* The virtual database engine */\n  Index *pIdx;           /* For looping over indices */\n  Index *pPk;            /* The PRIMARY KEY index for WITHOUT ROWID tables */\n  int nIdx;              /* Number of indices that need updating */\n  int iBaseCur;          /* Base cursor number */\n  int iDataCur;          /* Cursor for the canonical data btree */\n  int iIdxCur;           /* Cursor for the first index */\n  sqlite3 *db;           /* The database structure */\n  int *aRegIdx = 0;      /* First register in array assigned to each index */\n  int *aXRef = 0;        /* aXRef[i] is the index in pChanges->a[] of the\n                         ** an expression for the i-th column of the table.\n                         ** aXRef[i]==-1 if the i-th column is not changed. */\n  u8 *aToOpen;           /* 1 for tables and indices to be opened */\n  u8 chngPk;             /* PRIMARY KEY changed in a WITHOUT ROWID table */\n  u8 chngRowid;          /* Rowid changed in a normal table */\n  u8 chngKey;            /* Either chngPk or chngRowid */\n  Expr *pRowidExpr = 0;  /* Expression defining the new record number */\n  AuthContext sContext;  /* The authorization context */\n  NameContext sNC;       /* The name-context to resolve expressions in */\n  int iDb;               /* Database containing the table being updated */\n  int eOnePass;          /* ONEPASS_XXX value from where.c */\n  int hasFK;             /* True if foreign key processing is required */\n  int labelBreak;        /* Jump here to break out of UPDATE loop */\n  int labelContinue;     /* Jump here to continue next step of UPDATE loop */\n  int flags;             /* Flags for sqlite3WhereBegin() */\n\n#ifndef SQLITE_OMIT_TRIGGER\n  int isView;            /* True when updating a view (INSTEAD OF trigger) */\n  Trigger *pTrigger;     /* List of triggers on pTab, if required */\n  int tmask;             /* Mask of TRIGGER_BEFORE|TRIGGER_AFTER */\n#endif\n  int newmask;           /* Mask of NEW.* columns accessed by BEFORE triggers */\n  int iEph = 0;          /* Ephemeral table holding all primary key values */\n  int nKey = 0;          /* Number of elements in regKey for WITHOUT ROWID */\n  int aiCurOnePass[2];   /* The write cursors opened by WHERE_ONEPASS */\n  int addrOpen = 0;      /* Address of OP_OpenEphemeral */\n  int iPk = 0;           /* First of nPk cells holding PRIMARY KEY value */\n  i16 nPk = 0;           /* Number of components of the PRIMARY KEY */\n  int bReplace = 0;      /* True if REPLACE conflict resolution might happen */\n\n  /* Register Allocations */\n  int regRowCount = 0;   /* A count of rows changed */\n  int regOldRowid = 0;   /* The old rowid */\n  int regNewRowid = 0;   /* The new rowid */\n  int regNew = 0;        /* Content of the NEW.* table in triggers */\n  int regOld = 0;        /* Content of OLD.* table in triggers */\n  int regRowSet = 0;     /* Rowset of rows to be updated */\n  int regKey = 0;        /* composite PRIMARY KEY value */\n\n  memset(&sContext, 0, sizeof(sContext));\n  db = pParse->db;\n  if( pParse->nErr || db->mallocFailed ){\n    goto update_cleanup;\n  }\n  assert( pTabList->nSrc==1 );\n\n  /* Locate the table which we want to update. \n  */\n  pTab = sqlite3SrcListLookup(pParse, pTabList);\n  if( pTab==0 ) goto update_cleanup;\n  iDb = sqlite3SchemaToIndex(pParse->db, pTab->pSchema);\n\n  /* Figure out if we have any triggers and if the table being\n  ** updated is a view.\n  */\n#ifndef SQLITE_OMIT_TRIGGER\n  pTrigger = sqlite3TriggersExist(pParse, pTab, TK_UPDATE, pChanges, &tmask);\n  isView = pTab->pSelect!=0;\n  assert( pTrigger || tmask==0 );\n#else\n# define pTrigger 0\n# define isView 0\n# define tmask 0\n#endif\n#ifdef SQLITE_OMIT_VIEW\n# undef isView\n# define isView 0\n#endif\n\n#ifdef SQLITE_ENABLE_UPDATE_DELETE_LIMIT\n  if( !isView ){\n    pWhere = sqlite3LimitWhere(\n        pParse, pTabList, pWhere, pOrderBy, pLimit, \"UPDATE\"\n    );\n    pOrderBy = 0;\n    pLimit = 0;\n  }\n#endif\n\n  if( sqlite3ViewGetColumnNames(pParse, pTab) ){\n    goto update_cleanup;\n  }\n  if( sqlite3IsReadOnly(pParse, pTab, tmask) ){\n    goto update_cleanup;\n  }\n\n  /* Allocate a cursors for the main database table and for all indices.\n  ** The index cursors might not be used, but if they are used they\n  ** need to occur right after the database cursor.  So go ahead and\n  ** allocate enough space, just in case.\n  */\n  iBaseCur = iDataCur = pParse->nTab++;\n  iIdxCur = iDataCur+1;\n  pPk = HasRowid(pTab) ? 0 : sqlite3PrimaryKeyIndex(pTab);\n  testcase( pPk!=0 && pPk!=pTab->pIndex );\n  for(nIdx=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, nIdx++){\n    if( pPk==pIdx ){\n      iDataCur = pParse->nTab;\n    }\n    pParse->nTab++;\n  }\n  if( pUpsert ){\n    /* On an UPSERT, reuse the same cursors already opened by INSERT */\n    iDataCur = pUpsert->iDataCur;\n    iIdxCur = pUpsert->iIdxCur;\n    pParse->nTab = iBaseCur;\n  }\n  pTabList->a[0].iCursor = iDataCur;\n\n  /* Allocate space for aXRef[], aRegIdx[], and aToOpen[].  \n  ** Initialize aXRef[] and aToOpen[] to their default values.\n  */\n  aXRef = sqlite3DbMallocRawNN(db, sizeof(int) * (pTab->nCol+nIdx) + nIdx+2 );\n  if( aXRef==0 ) goto update_cleanup;\n  aRegIdx = aXRef+pTab->nCol;\n  aToOpen = (u8*)(aRegIdx+nIdx);\n  memset(aToOpen, 1, nIdx+1);\n  aToOpen[nIdx+1] = 0;\n  for(i=0; i<pTab->nCol; i++) aXRef[i] = -1;\n\n  /* Initialize the name-context */\n  memset(&sNC, 0, sizeof(sNC));\n  sNC.pParse = pParse;\n  sNC.pSrcList = pTabList;\n  sNC.uNC.pUpsert = pUpsert;\n  sNC.ncFlags = NC_UUpsert;\n\n  /* Resolve the column names in all the expressions of the\n  ** of the UPDATE statement.  Also find the column index\n  ** for each column to be updated in the pChanges array.  For each\n  ** column to be updated, make sure we have authorization to change\n  ** that column.\n  */\n  chngRowid = chngPk = 0;\n  for(i=0; i<pChanges->nExpr; i++){\n    if( sqlite3ResolveExprNames(&sNC, pChanges->a[i].pExpr) ){\n      goto update_cleanup;\n    }\n    for(j=0; j<pTab->nCol; j++){\n      if( sqlite3StrICmp(pTab->aCol[j].zName, pChanges->a[i].zName)==0 ){\n        if( j==pTab->iPKey ){\n          chngRowid = 1;\n          pRowidExpr = pChanges->a[i].pExpr;\n        }else if( pPk && (pTab->aCol[j].colFlags & COLFLAG_PRIMKEY)!=0 ){\n          chngPk = 1;\n        }\n        aXRef[j] = i;\n        break;\n      }\n    }\n    if( j>=pTab->nCol ){\n      if( pPk==0 && sqlite3IsRowid(pChanges->a[i].zName) ){\n        j = -1;\n        chngRowid = 1;\n        pRowidExpr = pChanges->a[i].pExpr;\n      }else{\n        sqlite3ErrorMsg(pParse, \"no such column: %s\", pChanges->a[i].zName);\n        pParse->checkSchema = 1;\n        goto update_cleanup;\n      }\n    }\n#ifndef SQLITE_OMIT_AUTHORIZATION\n    {\n      int rc;\n      rc = sqlite3AuthCheck(pParse, SQLITE_UPDATE, pTab->zName,\n                            j<0 ? \"ROWID\" : pTab->aCol[j].zName,\n                            db->aDb[iDb].zDbSName);\n      if( rc==SQLITE_DENY ){\n        goto update_cleanup;\n      }else if( rc==SQLITE_IGNORE ){\n        aXRef[j] = -1;\n      }\n    }\n#endif\n  }\n  assert( (chngRowid & chngPk)==0 );\n  assert( chngRowid==0 || chngRowid==1 );\n  assert( chngPk==0 || chngPk==1 );\n  chngKey = chngRowid + chngPk;\n\n  /* The SET expressions are not actually used inside the WHERE loop.  \n  ** So reset the colUsed mask. Unless this is a virtual table. In that\n  ** case, set all bits of the colUsed mask (to ensure that the virtual\n  ** table implementation makes all columns available).\n  */\n  pTabList->a[0].colUsed = IsVirtual(pTab) ? ALLBITS : 0;\n\n  hasFK = sqlite3FkRequired(pParse, pTab, aXRef, chngKey);\n\n  /* There is one entry in the aRegIdx[] array for each index on the table\n  ** being updated.  Fill in aRegIdx[] with a register number that will hold\n  ** the key for accessing each index.\n  */\n  if( onError==OE_Replace ) bReplace = 1;\n  for(j=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, j++){\n    int reg;\n    if( chngKey || hasFK>1 || pIdx==pPk\n     || indexWhereClauseMightChange(pIdx,aXRef,chngRowid)\n    ){\n      reg = ++pParse->nMem;\n      pParse->nMem += pIdx->nColumn;\n    }else{\n      reg = 0;\n      for(i=0; i<pIdx->nKeyCol; i++){\n        if( indexColumnIsBeingUpdated(pIdx, i, aXRef, chngRowid) ){\n          reg = ++pParse->nMem;\n          pParse->nMem += pIdx->nColumn;\n          if( onError==OE_Default && pIdx->onError==OE_Replace ){\n            bReplace = 1;\n          }\n          break;\n        }\n      }\n    }\n    if( reg==0 ) aToOpen[j+1] = 0;\n    aRegIdx[j] = reg;\n  }\n  if( bReplace ){\n    /* If REPLACE conflict resolution might be invoked, open cursors on all \n    ** indexes in case they are needed to delete records.  */\n    memset(aToOpen, 1, nIdx+1);\n  }\n\n  /* Begin generating code. */\n  v = sqlite3GetVdbe(pParse);\n  if( v==0 ) goto update_cleanup;\n  if( pParse->nested==0 ) sqlite3VdbeCountChanges(v);\n  sqlite3BeginWriteOperation(pParse, pTrigger || hasFK, iDb);\n\n  /* Allocate required registers. */\n  if( !IsVirtual(pTab) ){\n    regRowSet = ++pParse->nMem;\n    regOldRowid = regNewRowid = ++pParse->nMem;\n    if( chngPk || pTrigger || hasFK ){\n      regOld = pParse->nMem + 1;\n      pParse->nMem += pTab->nCol;\n    }\n    if( chngKey || pTrigger || hasFK ){\n      regNewRowid = ++pParse->nMem;\n    }\n    regNew = pParse->nMem + 1;\n    pParse->nMem += pTab->nCol;\n  }\n\n  /* Start the view context. */\n  if( isView ){\n    sqlite3AuthContextPush(pParse, &sContext, pTab->zName);\n  }\n\n  /* If we are trying to update a view, realize that view into\n  ** an ephemeral table.\n  */\n#if !defined(SQLITE_OMIT_VIEW) && !defined(SQLITE_OMIT_TRIGGER)\n  if( isView ){\n    sqlite3MaterializeView(pParse, pTab, \n        pWhere, pOrderBy, pLimit, iDataCur\n    );\n    pOrderBy = 0;\n    pLimit = 0;\n  }\n#endif\n\n  /* Resolve the column names in all the expressions in the\n  ** WHERE clause.\n  */\n  if( sqlite3ResolveExprNames(&sNC, pWhere) ){\n    goto update_cleanup;\n  }\n\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n  /* Virtual tables must be handled separately */\n  if( IsVirtual(pTab) ){\n    updateVirtualTable(pParse, pTabList, pTab, pChanges, pRowidExpr, aXRef,\n                       pWhere, onError);\n    goto update_cleanup;\n  }\n#endif\n\n  /* Jump to labelBreak to abandon further processing of this UPDATE */\n  labelContinue = labelBreak = sqlite3VdbeMakeLabel(pParse);\n\n  /* Not an UPSERT.  Normal processing.  Begin by\n  ** initialize the count of updated rows */\n  if( (db->flags&SQLITE_CountRows)!=0\n   && !pParse->pTriggerTab\n   && !pParse->nested\n   && pUpsert==0\n  ){\n    regRowCount = ++pParse->nMem;\n    sqlite3VdbeAddOp2(v, OP_Integer, 0, regRowCount);\n  }\n\n  if( HasRowid(pTab) ){\n    sqlite3VdbeAddOp3(v, OP_Null, 0, regRowSet, regOldRowid);\n  }else{\n    assert( pPk!=0 );\n    nPk = pPk->nKeyCol;\n    iPk = pParse->nMem+1;\n    pParse->nMem += nPk;\n    regKey = ++pParse->nMem;\n    if( pUpsert==0 ){\n      iEph = pParse->nTab++;\n        sqlite3VdbeAddOp3(v, OP_Null, 0, iPk, iPk+nPk-1);\n      addrOpen = sqlite3VdbeAddOp2(v, OP_OpenEphemeral, iEph, nPk);\n      sqlite3VdbeSetP4KeyInfo(pParse, pPk);\n    }\n  }\n  \n  if( pUpsert ){\n    /* If this is an UPSERT, then all cursors have already been opened by\n    ** the outer INSERT and the data cursor should be pointing at the row\n    ** that is to be updated.  So bypass the code that searches for the\n    ** row(s) to be updated.\n    */\n    pWInfo = 0;\n    eOnePass = ONEPASS_SINGLE;\n    sqlite3ExprIfFalse(pParse, pWhere, labelBreak, SQLITE_JUMPIFNULL);\n  }else{\n    /* Begin the database scan. \n    **\n    ** Do not consider a single-pass strategy for a multi-row update if\n    ** there are any triggers or foreign keys to process, or rows may\n    ** be deleted as a result of REPLACE conflict handling. Any of these\n    ** things might disturb a cursor being used to scan through the table\n    ** or index, causing a single-pass approach to malfunction.  */\n    flags = WHERE_ONEPASS_DESIRED|WHERE_SEEK_UNIQ_TABLE;\n    if( !pParse->nested && !pTrigger && !hasFK && !chngKey && !bReplace ){\n      flags |= WHERE_ONEPASS_MULTIROW;\n    }\n    pWInfo = sqlite3WhereBegin(pParse, pTabList, pWhere, 0, 0, flags, iIdxCur);\n    if( pWInfo==0 ) goto update_cleanup;\n  \n    /* A one-pass strategy that might update more than one row may not\n    ** be used if any column of the index used for the scan is being\n    ** updated. Otherwise, if there is an index on \"b\", statements like\n    ** the following could create an infinite loop:\n    **\n    **   UPDATE t1 SET b=b+1 WHERE b>?\n    **\n    ** Fall back to ONEPASS_OFF if where.c has selected a ONEPASS_MULTI\n    ** strategy that uses an index for which one or more columns are being\n    ** updated.  */\n    eOnePass = sqlite3WhereOkOnePass(pWInfo, aiCurOnePass);\n    if( eOnePass!=ONEPASS_SINGLE ){\n      sqlite3MultiWrite(pParse);\n      if( eOnePass==ONEPASS_MULTI ){\n        int iCur = aiCurOnePass[1];\n        if( iCur>=0 && iCur!=iDataCur && aToOpen[iCur-iBaseCur] ){\n          eOnePass = ONEPASS_OFF;\n        }\n        assert( iCur!=iDataCur || !HasRowid(pTab) );\n      }\n    }\n  }\n\n  if( HasRowid(pTab) ){\n    /* Read the rowid of the current row of the WHERE scan. In ONEPASS_OFF\n    ** mode, write the rowid into the FIFO. In either of the one-pass modes,\n    ** leave it in register regOldRowid.  */\n    sqlite3VdbeAddOp2(v, OP_Rowid, iDataCur, regOldRowid);\n    if( eOnePass==ONEPASS_OFF ){\n      sqlite3VdbeAddOp2(v, OP_RowSetAdd, regRowSet, regOldRowid);\n    }\n  }else{\n    /* Read the PK of the current row into an array of registers. In\n    ** ONEPASS_OFF mode, serialize the array into a record and store it in\n    ** the ephemeral table. Or, in ONEPASS_SINGLE or MULTI mode, change\n    ** the OP_OpenEphemeral instruction to a Noop (the ephemeral table \n    ** is not required) and leave the PK fields in the array of registers.  */\n    for(i=0; i<nPk; i++){\n      assert( pPk->aiColumn[i]>=0 );\n      sqlite3ExprCodeGetColumnOfTable(v, pTab, iDataCur,pPk->aiColumn[i],iPk+i);\n    }\n    if( eOnePass ){\n      if( addrOpen ) sqlite3VdbeChangeToNoop(v, addrOpen);\n      nKey = nPk;\n      regKey = iPk;\n    }else{\n      sqlite3VdbeAddOp4(v, OP_MakeRecord, iPk, nPk, regKey,\n                        sqlite3IndexAffinityStr(db, pPk), nPk);\n      sqlite3VdbeAddOp4Int(v, OP_IdxInsert, iEph, regKey, iPk, nPk);\n    }\n  }\n\n  if( pUpsert==0 ){\n    if( eOnePass!=ONEPASS_MULTI ){\n      sqlite3WhereEnd(pWInfo);\n    }\n  \n    if( !isView ){\n      int addrOnce = 0;\n  \n      /* Open every index that needs updating. */\n      if( eOnePass!=ONEPASS_OFF ){\n        if( aiCurOnePass[0]>=0 ) aToOpen[aiCurOnePass[0]-iBaseCur] = 0;\n        if( aiCurOnePass[1]>=0 ) aToOpen[aiCurOnePass[1]-iBaseCur] = 0;\n      }\n  \n      if( eOnePass==ONEPASS_MULTI && (nIdx-(aiCurOnePass[1]>=0))>0 ){\n        addrOnce = sqlite3VdbeAddOp0(v, OP_Once); VdbeCoverage(v);\n      }\n      sqlite3OpenTableAndIndices(pParse, pTab, OP_OpenWrite, 0, iBaseCur,\n                                 aToOpen, 0, 0);\n      if( addrOnce ) sqlite3VdbeJumpHere(v, addrOnce);\n    }\n  \n    /* Top of the update loop */\n    if( eOnePass!=ONEPASS_OFF ){\n      if( !isView && aiCurOnePass[0]!=iDataCur && aiCurOnePass[1]!=iDataCur ){\n        assert( pPk );\n        sqlite3VdbeAddOp4Int(v, OP_NotFound, iDataCur, labelBreak, regKey,nKey);\n        VdbeCoverage(v);\n      }\n      if( eOnePass!=ONEPASS_SINGLE ){\n        labelContinue = sqlite3VdbeMakeLabel(pParse);\n      }\n      sqlite3VdbeAddOp2(v, OP_IsNull, pPk ? regKey : regOldRowid, labelBreak);\n      VdbeCoverageIf(v, pPk==0);\n      VdbeCoverageIf(v, pPk!=0);\n    }else if( pPk ){\n      labelContinue = sqlite3VdbeMakeLabel(pParse);\n      sqlite3VdbeAddOp2(v, OP_Rewind, iEph, labelBreak); VdbeCoverage(v);\n      addrTop = sqlite3VdbeAddOp2(v, OP_RowData, iEph, regKey);\n      sqlite3VdbeAddOp4Int(v, OP_NotFound, iDataCur, labelContinue, regKey, 0);\n      VdbeCoverage(v);\n    }else{\n      labelContinue = sqlite3VdbeAddOp3(v, OP_RowSetRead, regRowSet,labelBreak,\n                               regOldRowid);\n      VdbeCoverage(v);\n      sqlite3VdbeAddOp3(v, OP_NotExists, iDataCur, labelContinue, regOldRowid);\n      VdbeCoverage(v);\n    }\n  }\n\n  /* If the rowid value will change, set register regNewRowid to\n  ** contain the new value. If the rowid is not being modified,\n  ** then regNewRowid is the same register as regOldRowid, which is\n  ** already populated.  */\n  assert( chngKey || pTrigger || hasFK || regOldRowid==regNewRowid );\n  if( chngRowid ){\n    sqlite3ExprCode(pParse, pRowidExpr, regNewRowid);\n    sqlite3VdbeAddOp1(v, OP_MustBeInt, regNewRowid); VdbeCoverage(v);\n  }\n\n  /* Compute the old pre-UPDATE content of the row being changed, if that\n  ** information is needed */\n  if( chngPk || hasFK || pTrigger ){\n    u32 oldmask = (hasFK ? sqlite3FkOldmask(pParse, pTab) : 0);\n    oldmask |= sqlite3TriggerColmask(pParse, \n        pTrigger, pChanges, 0, TRIGGER_BEFORE|TRIGGER_AFTER, pTab, onError\n    );\n    for(i=0; i<pTab->nCol; i++){\n      if( oldmask==0xffffffff\n       || (i<32 && (oldmask & MASKBIT32(i))!=0)\n       || (pTab->aCol[i].colFlags & COLFLAG_PRIMKEY)!=0\n      ){\n        testcase(  oldmask!=0xffffffff && i==31 );\n        sqlite3ExprCodeGetColumnOfTable(v, pTab, iDataCur, i, regOld+i);\n      }else{\n        sqlite3VdbeAddOp2(v, OP_Null, 0, regOld+i);\n      }\n    }\n    if( chngRowid==0 && pPk==0 ){\n      sqlite3VdbeAddOp2(v, OP_Copy, regOldRowid, regNewRowid);\n    }\n  }\n\n  /* Populate the array of registers beginning at regNew with the new\n  ** row data. This array is used to check constants, create the new\n  ** table and index records, and as the values for any new.* references\n  ** made by triggers.\n  **\n  ** If there are one or more BEFORE triggers, then do not populate the\n  ** registers associated with columns that are (a) not modified by\n  ** this UPDATE statement and (b) not accessed by new.* references. The\n  ** values for registers not modified by the UPDATE must be reloaded from \n  ** the database after the BEFORE triggers are fired anyway (as the trigger \n  ** may have modified them). So not loading those that are not going to\n  ** be used eliminates some redundant opcodes.\n  */\n  newmask = sqlite3TriggerColmask(\n      pParse, pTrigger, pChanges, 1, TRIGGER_BEFORE, pTab, onError\n  );\n  for(i=0; i<pTab->nCol; i++){\n    if( i==pTab->iPKey ){\n      sqlite3VdbeAddOp2(v, OP_Null, 0, regNew+i);\n    }else{\n      j = aXRef[i];\n      if( j>=0 ){\n        sqlite3ExprCode(pParse, pChanges->a[j].pExpr, regNew+i);\n      }else if( 0==(tmask&TRIGGER_BEFORE) || i>31 || (newmask & MASKBIT32(i)) ){\n        /* This branch loads the value of a column that will not be changed \n        ** into a register. This is done if there are no BEFORE triggers, or\n        ** if there are one or more BEFORE triggers that use this value via\n        ** a new.* reference in a trigger program.\n        */\n        testcase( i==31 );\n        testcase( i==32 );\n        sqlite3ExprCodeGetColumnOfTable(v, pTab, iDataCur, i, regNew+i);\n      }else{\n        sqlite3VdbeAddOp2(v, OP_Null, 0, regNew+i);\n      }\n    }\n  }\n\n  /* Fire any BEFORE UPDATE triggers. This happens before constraints are\n  ** verified. One could argue that this is wrong.\n  */\n  if( tmask&TRIGGER_BEFORE ){\n    sqlite3TableAffinity(v, pTab, regNew);\n    sqlite3CodeRowTrigger(pParse, pTrigger, TK_UPDATE, pChanges, \n        TRIGGER_BEFORE, pTab, regOldRowid, onError, labelContinue);\n\n    /* The row-trigger may have deleted the row being updated. In this\n    ** case, jump to the next row. No updates or AFTER triggers are \n    ** required. This behavior - what happens when the row being updated\n    ** is deleted or renamed by a BEFORE trigger - is left undefined in the\n    ** documentation.\n    */\n    if( pPk ){\n      sqlite3VdbeAddOp4Int(v, OP_NotFound, iDataCur, labelContinue,regKey,nKey);\n      VdbeCoverage(v);\n    }else{\n      sqlite3VdbeAddOp3(v, OP_NotExists, iDataCur, labelContinue, regOldRowid);\n      VdbeCoverage(v);\n    }\n\n    /* After-BEFORE-trigger-reload-loop:\n    ** If it did not delete it, the BEFORE trigger may still have modified \n    ** some of the columns of the row being updated. Load the values for \n    ** all columns not modified by the update statement into their registers\n    ** in case this has happened. Only unmodified columns are reloaded.\n    ** The values computed for modified columns use the values before the\n    ** BEFORE trigger runs.  See test case trigger1-18.0 (added 2018-04-26)\n    ** for an example.\n    */\n    for(i=0; i<pTab->nCol; i++){\n      if( aXRef[i]<0 && i!=pTab->iPKey ){\n        sqlite3ExprCodeGetColumnOfTable(v, pTab, iDataCur, i, regNew+i);\n      }\n    }\n  }\n\n  if( !isView ){\n    int addr1 = 0;        /* Address of jump instruction */\n\n    /* Do constraint checks. */\n    assert( regOldRowid>0 );\n    sqlite3GenerateConstraintChecks(pParse, pTab, aRegIdx, iDataCur, iIdxCur,\n        regNewRowid, regOldRowid, chngKey, onError, labelContinue, &bReplace,\n        aXRef, 0);\n\n    /* Do FK constraint checks. */\n    if( hasFK ){\n      sqlite3FkCheck(pParse, pTab, regOldRowid, 0, aXRef, chngKey);\n    }\n\n    /* Delete the index entries associated with the current record.  */\n    if( bReplace || chngKey ){\n      if( pPk ){\n        addr1 = sqlite3VdbeAddOp4Int(v, OP_NotFound, iDataCur, 0, regKey, nKey);\n      }else{\n        addr1 = sqlite3VdbeAddOp3(v, OP_NotExists, iDataCur, 0, regOldRowid);\n      }\n      VdbeCoverageNeverTaken(v);\n    }\n    sqlite3GenerateRowIndexDelete(pParse, pTab, iDataCur, iIdxCur, aRegIdx, -1);\n\n    /* If changing the rowid value, or if there are foreign key constraints\n    ** to process, delete the old record. Otherwise, add a noop OP_Delete\n    ** to invoke the pre-update hook.\n    **\n    ** That (regNew==regnewRowid+1) is true is also important for the \n    ** pre-update hook. If the caller invokes preupdate_new(), the returned\n    ** value is copied from memory cell (regNewRowid+1+iCol), where iCol\n    ** is the column index supplied by the user.\n    */\n    assert( regNew==regNewRowid+1 );\n#ifdef SQLITE_ENABLE_PREUPDATE_HOOK\n    sqlite3VdbeAddOp3(v, OP_Delete, iDataCur,\n        OPFLAG_ISUPDATE | ((hasFK>1 || chngKey) ? 0 : OPFLAG_ISNOOP),\n        regNewRowid\n    );\n    if( eOnePass==ONEPASS_MULTI ){\n      assert( hasFK==0 && chngKey==0 );\n      sqlite3VdbeChangeP5(v, OPFLAG_SAVEPOSITION);\n    }\n    if( !pParse->nested ){\n      sqlite3VdbeAppendP4(v, pTab, P4_TABLE);\n    }\n#else\n    if( hasFK>1 || chngKey ){\n      sqlite3VdbeAddOp2(v, OP_Delete, iDataCur, 0);\n    }\n#endif\n    if( bReplace || chngKey ){\n      sqlite3VdbeJumpHere(v, addr1);\n    }\n\n    if( hasFK ){\n      sqlite3FkCheck(pParse, pTab, 0, regNewRowid, aXRef, chngKey);\n    }\n  \n    /* Insert the new index entries and the new record. */\n    sqlite3CompleteInsertion(\n        pParse, pTab, iDataCur, iIdxCur, regNewRowid, aRegIdx, \n        OPFLAG_ISUPDATE | (eOnePass==ONEPASS_MULTI ? OPFLAG_SAVEPOSITION : 0), \n        0, 0\n    );\n\n    /* Do any ON CASCADE, SET NULL or SET DEFAULT operations required to\n    ** handle rows (possibly in other tables) that refer via a foreign key\n    ** to the row just updated. */ \n    if( hasFK ){\n      sqlite3FkActions(pParse, pTab, pChanges, regOldRowid, aXRef, chngKey);\n    }\n  }\n\n  /* Increment the row counter \n  */\n  if( regRowCount ){\n    sqlite3VdbeAddOp2(v, OP_AddImm, regRowCount, 1);\n  }\n\n  sqlite3CodeRowTrigger(pParse, pTrigger, TK_UPDATE, pChanges, \n      TRIGGER_AFTER, pTab, regOldRowid, onError, labelContinue);\n\n  /* Repeat the above with the next record to be updated, until\n  ** all record selected by the WHERE clause have been updated.\n  */\n  if( eOnePass==ONEPASS_SINGLE ){\n    /* Nothing to do at end-of-loop for a single-pass */\n  }else if( eOnePass==ONEPASS_MULTI ){\n    sqlite3VdbeResolveLabel(v, labelContinue);\n    sqlite3WhereEnd(pWInfo);\n  }else if( pPk ){\n    sqlite3VdbeResolveLabel(v, labelContinue);\n    sqlite3VdbeAddOp2(v, OP_Next, iEph, addrTop); VdbeCoverage(v);\n  }else{\n    sqlite3VdbeGoto(v, labelContinue);\n  }\n  sqlite3VdbeResolveLabel(v, labelBreak);\n\n  /* Update the sqlite_sequence table by storing the content of the\n  ** maximum rowid counter values recorded while inserting into\n  ** autoincrement tables.\n  */\n  if( pParse->nested==0 && pParse->pTriggerTab==0 && pUpsert==0 ){\n    sqlite3AutoincrementEnd(pParse);\n  }\n\n  /*\n  ** Return the number of rows that were changed, if we are tracking\n  ** that information.\n  */\n  if( regRowCount ){\n    sqlite3VdbeAddOp2(v, OP_ResultRow, regRowCount, 1);\n    sqlite3VdbeSetNumCols(v, 1);\n    sqlite3VdbeSetColName(v, 0, COLNAME_NAME, \"rows updated\", SQLITE_STATIC);\n  }\n\nupdate_cleanup:\n  sqlite3AuthContextPop(&sContext);\n  sqlite3DbFree(db, aXRef); /* Also frees aRegIdx[] and aToOpen[] */\n  sqlite3SrcListDelete(db, pTabList);\n  sqlite3ExprListDelete(db, pChanges);\n  sqlite3ExprDelete(db, pWhere);\n#if defined(SQLITE_ENABLE_UPDATE_DELETE_LIMIT) \n  sqlite3ExprListDelete(db, pOrderBy);\n  sqlite3ExprDelete(db, pLimit);\n#endif\n  return;\n}\n/* Make sure \"isView\" and other macros defined above are undefined. Otherwise\n** they may interfere with compilation of other functions in this file\n** (or in another file, if this file becomes part of the amalgamation).  */\n#ifdef isView\n #undef isView\n#endif\n#ifdef pTrigger\n #undef pTrigger\n#endif\n\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n/*\n** Generate code for an UPDATE of a virtual table.\n**\n** There are two possible strategies - the default and the special \n** \"onepass\" strategy. Onepass is only used if the virtual table \n** implementation indicates that pWhere may match at most one row.\n**\n** The default strategy is to create an ephemeral table that contains\n** for each row to be changed:\n**\n**   (A)  The original rowid of that row.\n**   (B)  The revised rowid for the row.\n**   (C)  The content of every column in the row.\n**\n** Then loop through the contents of this ephemeral table executing a\n** VUpdate for each row. When finished, drop the ephemeral table.\n**\n** The \"onepass\" strategy does not use an ephemeral table. Instead, it\n** stores the same values (A, B and C above) in a register array and\n** makes a single invocation of VUpdate.\n*/\nstatic void updateVirtualTable(\n  Parse *pParse,       /* The parsing context */\n  SrcList *pSrc,       /* The virtual table to be modified */\n  Table *pTab,         /* The virtual table */\n  ExprList *pChanges,  /* The columns to change in the UPDATE statement */\n  Expr *pRowid,        /* Expression used to recompute the rowid */\n  int *aXRef,          /* Mapping from columns of pTab to entries in pChanges */\n  Expr *pWhere,        /* WHERE clause of the UPDATE statement */\n  int onError          /* ON CONFLICT strategy */\n){\n  Vdbe *v = pParse->pVdbe;  /* Virtual machine under construction */\n  int ephemTab;             /* Table holding the result of the SELECT */\n  int i;                    /* Loop counter */\n  sqlite3 *db = pParse->db; /* Database connection */\n  const char *pVTab = (const char*)sqlite3GetVTable(db, pTab);\n  WhereInfo *pWInfo;\n  int nArg = 2 + pTab->nCol;      /* Number of arguments to VUpdate */\n  int regArg;                     /* First register in VUpdate arg array */\n  int regRec;                     /* Register in which to assemble record */\n  int regRowid;                   /* Register for ephem table rowid */\n  int iCsr = pSrc->a[0].iCursor;  /* Cursor used for virtual table scan */\n  int aDummy[2];                  /* Unused arg for sqlite3WhereOkOnePass() */\n  int eOnePass;                   /* True to use onepass strategy */\n  int addr;                       /* Address of OP_OpenEphemeral */\n\n  /* Allocate nArg registers in which to gather the arguments for VUpdate. Then\n  ** create and open the ephemeral table in which the records created from\n  ** these arguments will be temporarily stored. */\n  assert( v );\n  ephemTab = pParse->nTab++;\n  addr= sqlite3VdbeAddOp2(v, OP_OpenEphemeral, ephemTab, nArg);\n  regArg = pParse->nMem + 1;\n  pParse->nMem += nArg;\n  regRec = ++pParse->nMem;\n  regRowid = ++pParse->nMem;\n\n  /* Start scanning the virtual table */\n  pWInfo = sqlite3WhereBegin(pParse, pSrc, pWhere, 0,0,WHERE_ONEPASS_DESIRED,0);\n  if( pWInfo==0 ) return;\n\n  /* Populate the argument registers. */\n  for(i=0; i<pTab->nCol; i++){\n    if( aXRef[i]>=0 ){\n      sqlite3ExprCode(pParse, pChanges->a[aXRef[i]].pExpr, regArg+2+i);\n    }else{\n      sqlite3VdbeAddOp3(v, OP_VColumn, iCsr, i, regArg+2+i);\n      sqlite3VdbeChangeP5(v, OPFLAG_NOCHNG);/* Enable sqlite3_vtab_nochange() */\n    }\n  }\n  if( HasRowid(pTab) ){\n    sqlite3VdbeAddOp2(v, OP_Rowid, iCsr, regArg);\n    if( pRowid ){\n      sqlite3ExprCode(pParse, pRowid, regArg+1);\n    }else{\n      sqlite3VdbeAddOp2(v, OP_Rowid, iCsr, regArg+1);\n    }\n  }else{\n    Index *pPk;   /* PRIMARY KEY index */\n    i16 iPk;      /* PRIMARY KEY column */\n    pPk = sqlite3PrimaryKeyIndex(pTab);\n    assert( pPk!=0 );\n    assert( pPk->nKeyCol==1 );\n    iPk = pPk->aiColumn[0];\n    sqlite3VdbeAddOp3(v, OP_VColumn, iCsr, iPk, regArg);\n    sqlite3VdbeAddOp2(v, OP_SCopy, regArg+2+iPk, regArg+1);\n  }\n\n  eOnePass = sqlite3WhereOkOnePass(pWInfo, aDummy);\n\n  /* There is no ONEPASS_MULTI on virtual tables */\n  assert( eOnePass==ONEPASS_OFF || eOnePass==ONEPASS_SINGLE );\n\n  if( eOnePass ){\n    /* If using the onepass strategy, no-op out the OP_OpenEphemeral coded\n    ** above. */\n    sqlite3VdbeChangeToNoop(v, addr);\n    sqlite3VdbeAddOp1(v, OP_Close, iCsr);\n  }else{\n    /* Create a record from the argument register contents and insert it into\n    ** the ephemeral table. */\n    sqlite3MultiWrite(pParse);\n    sqlite3VdbeAddOp3(v, OP_MakeRecord, regArg, nArg, regRec);\n#ifdef SQLITE_DEBUG\n    /* Signal an assert() within OP_MakeRecord that it is allowed to\n    ** accept no-change records with serial_type 10 */\n    sqlite3VdbeChangeP5(v, OPFLAG_NOCHNG_MAGIC);\n#endif\n    sqlite3VdbeAddOp2(v, OP_NewRowid, ephemTab, regRowid);\n    sqlite3VdbeAddOp3(v, OP_Insert, ephemTab, regRec, regRowid);\n  }\n\n\n  if( eOnePass==ONEPASS_OFF ){\n    /* End the virtual table scan */\n    sqlite3WhereEnd(pWInfo);\n\n    /* Begin scannning through the ephemeral table. */\n    addr = sqlite3VdbeAddOp1(v, OP_Rewind, ephemTab); VdbeCoverage(v);\n\n    /* Extract arguments from the current row of the ephemeral table and \n    ** invoke the VUpdate method.  */\n    for(i=0; i<nArg; i++){\n      sqlite3VdbeAddOp3(v, OP_Column, ephemTab, i, regArg+i);\n    }\n  }\n  sqlite3VtabMakeWritable(pParse, pTab);\n  sqlite3VdbeAddOp4(v, OP_VUpdate, 0, nArg, regArg, pVTab, P4_VTAB);\n  sqlite3VdbeChangeP5(v, onError==OE_Default ? OE_Abort : onError);\n  sqlite3MayAbort(pParse);\n\n  /* End of the ephemeral table scan. Or, if using the onepass strategy,\n  ** jump to here if the scan visited zero rows. */\n  if( eOnePass==ONEPASS_OFF ){\n    sqlite3VdbeAddOp2(v, OP_Next, ephemTab, addr+1); VdbeCoverage(v);\n    sqlite3VdbeJumpHere(v, addr);\n    sqlite3VdbeAddOp2(v, OP_Close, ephemTab, 0);\n  }else{\n    sqlite3WhereEnd(pWInfo);\n  }\n}\n#endif /* SQLITE_OMIT_VIRTUALTABLE */\n\n/************** End of update.c **********************************************/\n/************** Begin file upsert.c ******************************************/\n/*\n** 2018-04-12\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This file contains code to implement various aspects of UPSERT\n** processing and handling of the Upsert object.\n*/\n/* #include \"sqliteInt.h\" */\n\n#ifndef SQLITE_OMIT_UPSERT\n/*\n** Free a list of Upsert objects\n*/\nSQLITE_PRIVATE void sqlite3UpsertDelete(sqlite3 *db, Upsert *p){\n  if( p ){\n    sqlite3ExprListDelete(db, p->pUpsertTarget);\n    sqlite3ExprDelete(db, p->pUpsertTargetWhere);\n    sqlite3ExprListDelete(db, p->pUpsertSet);\n    sqlite3ExprDelete(db, p->pUpsertWhere);\n    sqlite3DbFree(db, p);\n  }\n}\n\n/*\n** Duplicate an Upsert object.\n*/\nSQLITE_PRIVATE Upsert *sqlite3UpsertDup(sqlite3 *db, Upsert *p){\n  if( p==0 ) return 0;\n  return sqlite3UpsertNew(db,\n           sqlite3ExprListDup(db, p->pUpsertTarget, 0),\n           sqlite3ExprDup(db, p->pUpsertTargetWhere, 0),\n           sqlite3ExprListDup(db, p->pUpsertSet, 0),\n           sqlite3ExprDup(db, p->pUpsertWhere, 0)\n         );\n}\n\n/*\n** Create a new Upsert object.\n*/\nSQLITE_PRIVATE Upsert *sqlite3UpsertNew(\n  sqlite3 *db,           /* Determines which memory allocator to use */\n  ExprList *pTarget,     /* Target argument to ON CONFLICT, or NULL */\n  Expr *pTargetWhere,    /* Optional WHERE clause on the target */\n  ExprList *pSet,        /* UPDATE columns, or NULL for a DO NOTHING */\n  Expr *pWhere           /* WHERE clause for the ON CONFLICT UPDATE */\n){\n  Upsert *pNew;\n  pNew = sqlite3DbMallocRaw(db, sizeof(Upsert));\n  if( pNew==0 ){\n    sqlite3ExprListDelete(db, pTarget);\n    sqlite3ExprDelete(db, pTargetWhere);\n    sqlite3ExprListDelete(db, pSet);\n    sqlite3ExprDelete(db, pWhere);\n    return 0;\n  }else{\n    pNew->pUpsertTarget = pTarget;\n    pNew->pUpsertTargetWhere = pTargetWhere;\n    pNew->pUpsertSet = pSet;\n    pNew->pUpsertWhere = pWhere;\n    pNew->pUpsertIdx = 0;\n  }\n  return pNew;\n}\n\n/*\n** Analyze the ON CONFLICT clause described by pUpsert.  Resolve all\n** symbols in the conflict-target.\n**\n** Return SQLITE_OK if everything works, or an error code is something\n** is wrong.\n*/\nSQLITE_PRIVATE int sqlite3UpsertAnalyzeTarget(\n  Parse *pParse,     /* The parsing context */\n  SrcList *pTabList, /* Table into which we are inserting */\n  Upsert *pUpsert    /* The ON CONFLICT clauses */\n){\n  Table *pTab;            /* That table into which we are inserting */\n  int rc;                 /* Result code */\n  int iCursor;            /* Cursor used by pTab */\n  Index *pIdx;            /* One of the indexes of pTab */\n  ExprList *pTarget;      /* The conflict-target clause */\n  Expr *pTerm;            /* One term of the conflict-target clause */\n  NameContext sNC;        /* Context for resolving symbolic names */\n  Expr sCol[2];           /* Index column converted into an Expr */\n\n  assert( pTabList->nSrc==1 );\n  assert( pTabList->a[0].pTab!=0 );\n  assert( pUpsert!=0 );\n  assert( pUpsert->pUpsertTarget!=0 );\n\n  /* Resolve all symbolic names in the conflict-target clause, which\n  ** includes both the list of columns and the optional partial-index\n  ** WHERE clause.\n  */\n  memset(&sNC, 0, sizeof(sNC));\n  sNC.pParse = pParse;\n  sNC.pSrcList = pTabList;\n  rc = sqlite3ResolveExprListNames(&sNC, pUpsert->pUpsertTarget);\n  if( rc ) return rc;\n  rc = sqlite3ResolveExprNames(&sNC, pUpsert->pUpsertTargetWhere);\n  if( rc ) return rc;\n\n  /* Check to see if the conflict target matches the rowid. */  \n  pTab = pTabList->a[0].pTab;\n  pTarget = pUpsert->pUpsertTarget;\n  iCursor = pTabList->a[0].iCursor;\n  if( HasRowid(pTab) \n   && pTarget->nExpr==1\n   && (pTerm = pTarget->a[0].pExpr)->op==TK_COLUMN\n   && pTerm->iColumn==XN_ROWID\n  ){\n    /* The conflict-target is the rowid of the primary table */\n    assert( pUpsert->pUpsertIdx==0 );\n    return SQLITE_OK;\n  }\n\n  /* Initialize sCol[0..1] to be an expression parse tree for a\n  ** single column of an index.  The sCol[0] node will be the TK_COLLATE\n  ** operator and sCol[1] will be the TK_COLUMN operator.  Code below\n  ** will populate the specific collation and column number values\n  ** prior to comparing against the conflict-target expression.\n  */\n  memset(sCol, 0, sizeof(sCol));\n  sCol[0].op = TK_COLLATE;\n  sCol[0].pLeft = &sCol[1];\n  sCol[1].op = TK_COLUMN;\n  sCol[1].iTable = pTabList->a[0].iCursor;\n\n  /* Check for matches against other indexes */\n  for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){\n    int ii, jj, nn;\n    if( !IsUniqueIndex(pIdx) ) continue;\n    if( pTarget->nExpr!=pIdx->nKeyCol ) continue;\n    if( pIdx->pPartIdxWhere ){\n      if( pUpsert->pUpsertTargetWhere==0 ) continue;\n      if( sqlite3ExprCompare(pParse, pUpsert->pUpsertTargetWhere,\n                             pIdx->pPartIdxWhere, iCursor)!=0 ){\n        continue;\n      }\n    }\n    nn = pIdx->nKeyCol;\n    for(ii=0; ii<nn; ii++){\n      Expr *pExpr;\n      sCol[0].u.zToken = (char*)pIdx->azColl[ii];\n      if( pIdx->aiColumn[ii]==XN_EXPR ){\n        assert( pIdx->aColExpr!=0 );\n        assert( pIdx->aColExpr->nExpr>ii );\n        pExpr = pIdx->aColExpr->a[ii].pExpr;\n        if( pExpr->op!=TK_COLLATE ){\n          sCol[0].pLeft = pExpr;\n          pExpr = &sCol[0];\n        }\n      }else{\n        sCol[0].pLeft = &sCol[1];\n        sCol[1].iColumn = pIdx->aiColumn[ii];\n        pExpr = &sCol[0];\n      }\n      for(jj=0; jj<nn; jj++){\n        if( sqlite3ExprCompare(pParse, pTarget->a[jj].pExpr, pExpr,iCursor)<2 ){\n          break;  /* Column ii of the index matches column jj of target */\n        }\n      }\n      if( jj>=nn ){\n        /* The target contains no match for column jj of the index */\n        break;\n      }\n    }\n    if( ii<nn ){\n      /* Column ii of the index did not match any term of the conflict target.\n      ** Continue the search with the next index. */\n      continue;\n    }\n    pUpsert->pUpsertIdx = pIdx;\n    return SQLITE_OK;\n  }\n  sqlite3ErrorMsg(pParse, \"ON CONFLICT clause does not match any \"\n                          \"PRIMARY KEY or UNIQUE constraint\");\n  return SQLITE_ERROR;\n}\n\n/*\n** Generate bytecode that does an UPDATE as part of an upsert.\n**\n** If pIdx is NULL, then the UNIQUE constraint that failed was the IPK.\n** In this case parameter iCur is a cursor open on the table b-tree that\n** currently points to the conflicting table row. Otherwise, if pIdx\n** is not NULL, then pIdx is the constraint that failed and iCur is a\n** cursor points to the conflicting row.\n*/\nSQLITE_PRIVATE void sqlite3UpsertDoUpdate(\n  Parse *pParse,        /* The parsing and code-generating context */\n  Upsert *pUpsert,      /* The ON CONFLICT clause for the upsert */\n  Table *pTab,          /* The table being updated */\n  Index *pIdx,          /* The UNIQUE constraint that failed */\n  int iCur              /* Cursor for pIdx (or pTab if pIdx==NULL) */\n){\n  Vdbe *v = pParse->pVdbe;\n  sqlite3 *db = pParse->db;\n  SrcList *pSrc;            /* FROM clause for the UPDATE */\n  int iDataCur;\n\n  assert( v!=0 );\n  assert( pUpsert!=0 );\n  VdbeNoopComment((v, \"Begin DO UPDATE of UPSERT\"));\n  iDataCur = pUpsert->iDataCur;\n  if( pIdx && iCur!=iDataCur ){\n    if( HasRowid(pTab) ){\n      int regRowid = sqlite3GetTempReg(pParse);\n      sqlite3VdbeAddOp2(v, OP_IdxRowid, iCur, regRowid);\n      sqlite3VdbeAddOp3(v, OP_SeekRowid, iDataCur, 0, regRowid);\n      VdbeCoverage(v);\n      sqlite3ReleaseTempReg(pParse, regRowid);\n    }else{\n      Index *pPk = sqlite3PrimaryKeyIndex(pTab);\n      int nPk = pPk->nKeyCol;\n      int iPk = pParse->nMem+1;\n      int i;\n      pParse->nMem += nPk;\n      for(i=0; i<nPk; i++){\n        int k;\n        assert( pPk->aiColumn[i]>=0 );\n        k = sqlite3ColumnOfIndex(pIdx, pPk->aiColumn[i]);\n        sqlite3VdbeAddOp3(v, OP_Column, iCur, k, iPk+i);\n        VdbeComment((v, \"%s.%s\", pIdx->zName,\n                    pTab->aCol[pPk->aiColumn[i]].zName));\n      }\n      sqlite3VdbeVerifyAbortable(v, OE_Abort);\n      i = sqlite3VdbeAddOp4Int(v, OP_Found, iDataCur, 0, iPk, nPk);\n      VdbeCoverage(v);\n      sqlite3VdbeAddOp4(v, OP_Halt, SQLITE_CORRUPT, OE_Abort, 0, \n            \"corrupt database\", P4_STATIC);\n      sqlite3VdbeJumpHere(v, i);\n    }\n  }\n  /* pUpsert does not own pUpsertSrc - the outer INSERT statement does.  So\n  ** we have to make a copy before passing it down into sqlite3Update() */\n  pSrc = sqlite3SrcListDup(db, pUpsert->pUpsertSrc, 0);\n  sqlite3Update(pParse, pSrc, pUpsert->pUpsertSet,\n      pUpsert->pUpsertWhere, OE_Abort, 0, 0, pUpsert);\n  pUpsert->pUpsertSet = 0;    /* Will have been deleted by sqlite3Update() */\n  pUpsert->pUpsertWhere = 0;  /* Will have been deleted by sqlite3Update() */\n  VdbeNoopComment((v, \"End DO UPDATE of UPSERT\"));\n}\n\n#endif /* SQLITE_OMIT_UPSERT */\n\n/************** End of upsert.c **********************************************/\n/************** Begin file vacuum.c ******************************************/\n/*\n** 2003 April 6\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This file contains code used to implement the VACUUM command.\n**\n** Most of the code in this file may be omitted by defining the\n** SQLITE_OMIT_VACUUM macro.\n*/\n/* #include \"sqliteInt.h\" */\n/* #include \"vdbeInt.h\" */\n\n#if !defined(SQLITE_OMIT_VACUUM) && !defined(SQLITE_OMIT_ATTACH)\n\n/*\n** Execute zSql on database db.\n**\n** If zSql returns rows, then each row will have exactly one\n** column.  (This will only happen if zSql begins with \"SELECT\".)\n** Take each row of result and call execSql() again recursively.\n**\n** The execSqlF() routine does the same thing, except it accepts\n** a format string as its third argument\n*/\nstatic int execSql(sqlite3 *db, char **pzErrMsg, const char *zSql){\n  sqlite3_stmt *pStmt;\n  int rc;\n\n  /* printf(\"SQL: [%s]\\n\", zSql); fflush(stdout); */\n  rc = sqlite3_prepare_v2(db, zSql, -1, &pStmt, 0);\n  if( rc!=SQLITE_OK ) return rc;\n  while( SQLITE_ROW==(rc = sqlite3_step(pStmt)) ){\n    const char *zSubSql = (const char*)sqlite3_column_text(pStmt,0);\n    assert( sqlite3_strnicmp(zSql,\"SELECT\",6)==0 );\n    /* The secondary SQL must be one of CREATE TABLE, CREATE INDEX,\n    ** or INSERT.  Historically there have been attacks that first\n    ** corrupt the sqlite_master.sql field with other kinds of statements\n    ** then run VACUUM to get those statements to execute at inappropriate\n    ** times. */\n    if( zSubSql\n     && (strncmp(zSubSql,\"CRE\",3)==0 || strncmp(zSubSql,\"INS\",3)==0)\n    ){\n      rc = execSql(db, pzErrMsg, zSubSql);\n      if( rc!=SQLITE_OK ) break;\n    }\n  }\n  assert( rc!=SQLITE_ROW );\n  if( rc==SQLITE_DONE ) rc = SQLITE_OK;\n  if( rc ){\n    sqlite3SetString(pzErrMsg, db, sqlite3_errmsg(db));\n  }\n  (void)sqlite3_finalize(pStmt);\n  return rc;\n}\nstatic int execSqlF(sqlite3 *db, char **pzErrMsg, const char *zSql, ...){\n  char *z;\n  va_list ap;\n  int rc;\n  va_start(ap, zSql);\n  z = sqlite3VMPrintf(db, zSql, ap);\n  va_end(ap);\n  if( z==0 ) return SQLITE_NOMEM;\n  rc = execSql(db, pzErrMsg, z);\n  sqlite3DbFree(db, z);\n  return rc;\n}\n\n/*\n** The VACUUM command is used to clean up the database,\n** collapse free space, etc.  It is modelled after the VACUUM command\n** in PostgreSQL.  The VACUUM command works as follows:\n**\n**   (1)  Create a new transient database file\n**   (2)  Copy all content from the database being vacuumed into\n**        the new transient database file\n**   (3)  Copy content from the transient database back into the\n**        original database.\n**\n** The transient database requires temporary disk space approximately\n** equal to the size of the original database.  The copy operation of\n** step (3) requires additional temporary disk space approximately equal\n** to the size of the original database for the rollback journal.\n** Hence, temporary disk space that is approximately 2x the size of the\n** original database is required.  Every page of the database is written\n** approximately 3 times:  Once for step (2) and twice for step (3).\n** Two writes per page are required in step (3) because the original\n** database content must be written into the rollback journal prior to\n** overwriting the database with the vacuumed content.\n**\n** Only 1x temporary space and only 1x writes would be required if\n** the copy of step (3) were replaced by deleting the original database\n** and renaming the transient database as the original.  But that will\n** not work if other processes are attached to the original database.\n** And a power loss in between deleting the original and renaming the\n** transient would cause the database file to appear to be deleted\n** following reboot.\n*/\nSQLITE_PRIVATE void sqlite3Vacuum(Parse *pParse, Token *pNm, Expr *pInto){\n  Vdbe *v = sqlite3GetVdbe(pParse);\n  int iDb = 0;\n  if( v==0 ) goto build_vacuum_end;\n  if( pNm ){\n#ifndef SQLITE_BUG_COMPATIBLE_20160819\n    /* Default behavior:  Report an error if the argument to VACUUM is\n    ** not recognized */\n    iDb = sqlite3TwoPartName(pParse, pNm, pNm, &pNm);\n    if( iDb<0 ) goto build_vacuum_end;\n#else\n    /* When SQLITE_BUG_COMPATIBLE_20160819 is defined, unrecognized arguments\n    ** to VACUUM are silently ignored.  This is a back-out of a bug fix that\n    ** occurred on 2016-08-19 (https://www.sqlite.org/src/info/083f9e6270).\n    ** The buggy behavior is required for binary compatibility with some\n    ** legacy applications. */\n    iDb = sqlite3FindDb(pParse->db, pNm);\n    if( iDb<0 ) iDb = 0;\n#endif\n  }\n  if( iDb!=1 ){\n    int iIntoReg = 0;\n    if( pInto && sqlite3ResolveSelfReference(pParse,0,0,pInto,0)==0 ){\n      iIntoReg = ++pParse->nMem;\n      sqlite3ExprCode(pParse, pInto, iIntoReg);\n    }\n    sqlite3VdbeAddOp2(v, OP_Vacuum, iDb, iIntoReg);\n    sqlite3VdbeUsesBtree(v, iDb);\n  }\nbuild_vacuum_end:\n  sqlite3ExprDelete(pParse->db, pInto);\n  return;\n}\n\n/*\n** This routine implements the OP_Vacuum opcode of the VDBE.\n*/\nSQLITE_PRIVATE int sqlite3RunVacuum(\n  char **pzErrMsg,        /* Write error message here */\n  sqlite3 *db,            /* Database connection */\n  int iDb,                /* Which attached DB to vacuum */\n  sqlite3_value *pOut     /* Write results here, if not NULL */\n){\n  int rc = SQLITE_OK;     /* Return code from service routines */\n  Btree *pMain;           /* The database being vacuumed */\n  Btree *pTemp;           /* The temporary database we vacuum into */\n  u32 saved_mDbFlags;     /* Saved value of db->mDbFlags */\n  u64 saved_flags;        /* Saved value of db->flags */\n  int saved_nChange;      /* Saved value of db->nChange */\n  int saved_nTotalChange; /* Saved value of db->nTotalChange */\n  u8 saved_mTrace;        /* Saved trace settings */\n  Db *pDb = 0;            /* Database to detach at end of vacuum */\n  int isMemDb;            /* True if vacuuming a :memory: database */\n  int nRes;               /* Bytes of reserved space at the end of each page */\n  int nDb;                /* Number of attached databases */\n  const char *zDbMain;    /* Schema name of database to vacuum */\n  const char *zOut;       /* Name of output file */\n\n  if( !db->autoCommit ){\n    sqlite3SetString(pzErrMsg, db, \"cannot VACUUM from within a transaction\");\n    return SQLITE_ERROR;\n  }\n  if( db->nVdbeActive>1 ){\n    sqlite3SetString(pzErrMsg, db,\"cannot VACUUM - SQL statements in progress\");\n    return SQLITE_ERROR;\n  }\n  if( pOut ){\n    if( sqlite3_value_type(pOut)!=SQLITE_TEXT ){\n      sqlite3SetString(pzErrMsg, db, \"non-text filename\");\n      return SQLITE_ERROR;\n    }\n    zOut = (const char*)sqlite3_value_text(pOut);\n  }else{\n    zOut = \"\";\n  }\n\n  /* Save the current value of the database flags so that it can be \n  ** restored before returning. Then set the writable-schema flag, and\n  ** disable CHECK and foreign key constraints.  */\n  saved_flags = db->flags;\n  saved_mDbFlags = db->mDbFlags;\n  saved_nChange = db->nChange;\n  saved_nTotalChange = db->nTotalChange;\n  saved_mTrace = db->mTrace;\n  db->flags |= SQLITE_WriteSchema | SQLITE_IgnoreChecks;\n  db->mDbFlags |= DBFLAG_PreferBuiltin | DBFLAG_Vacuum;\n  db->flags &= ~(u64)(SQLITE_ForeignKeys | SQLITE_ReverseOrder\n                   | SQLITE_Defensive | SQLITE_CountRows);\n  db->mTrace = 0;\n\n  zDbMain = db->aDb[iDb].zDbSName;\n  pMain = db->aDb[iDb].pBt;\n  isMemDb = sqlite3PagerIsMemdb(sqlite3BtreePager(pMain));\n\n  /* Attach the temporary database as 'vacuum_db'. The synchronous pragma\n  ** can be set to 'off' for this file, as it is not recovered if a crash\n  ** occurs anyway. The integrity of the database is maintained by a\n  ** (possibly synchronous) transaction opened on the main database before\n  ** sqlite3BtreeCopyFile() is called.\n  **\n  ** An optimisation would be to use a non-journaled pager.\n  ** (Later:) I tried setting \"PRAGMA vacuum_db.journal_mode=OFF\" but\n  ** that actually made the VACUUM run slower.  Very little journalling\n  ** actually occurs when doing a vacuum since the vacuum_db is initially\n  ** empty.  Only the journal header is written.  Apparently it takes more\n  ** time to parse and run the PRAGMA to turn journalling off than it does\n  ** to write the journal header file.\n  */\n  nDb = db->nDb;\n  rc = execSqlF(db, pzErrMsg, \"ATTACH %Q AS vacuum_db\", zOut);\n  if( rc!=SQLITE_OK ) goto end_of_vacuum;\n  assert( (db->nDb-1)==nDb );\n  pDb = &db->aDb[nDb];\n  assert( strcmp(pDb->zDbSName,\"vacuum_db\")==0 );\n  pTemp = pDb->pBt;\n  if( pOut ){\n    sqlite3_file *id = sqlite3PagerFile(sqlite3BtreePager(pTemp));\n    i64 sz = 0;\n    if( id->pMethods!=0 && (sqlite3OsFileSize(id, &sz)!=SQLITE_OK || sz>0) ){\n      rc = SQLITE_ERROR;\n      sqlite3SetString(pzErrMsg, db, \"output file already exists\");\n      goto end_of_vacuum;\n    }\n  }\n  nRes = sqlite3BtreeGetOptimalReserve(pMain);\n\n  /* A VACUUM cannot change the pagesize of an encrypted database. */\n#ifdef SQLITE_HAS_CODEC\n  if( db->nextPagesize ){\n    extern void sqlite3CodecGetKey(sqlite3*, int, void**, int*);\n    int nKey;\n    char *zKey;\n    sqlite3CodecGetKey(db, iDb, (void**)&zKey, &nKey);\n    if( nKey ) db->nextPagesize = 0;\n  }\n#endif\n\n  sqlite3BtreeSetCacheSize(pTemp, db->aDb[iDb].pSchema->cache_size);\n  sqlite3BtreeSetSpillSize(pTemp, sqlite3BtreeSetSpillSize(pMain,0));\n  sqlite3BtreeSetPagerFlags(pTemp, PAGER_SYNCHRONOUS_OFF|PAGER_CACHESPILL);\n\n  /* Begin a transaction and take an exclusive lock on the main database\n  ** file. This is done before the sqlite3BtreeGetPageSize(pMain) call below,\n  ** to ensure that we do not try to change the page-size on a WAL database.\n  */\n  rc = execSql(db, pzErrMsg, \"BEGIN\");\n  if( rc!=SQLITE_OK ) goto end_of_vacuum;\n  rc = sqlite3BtreeBeginTrans(pMain, pOut==0 ? 2 : 0, 0);\n  if( rc!=SQLITE_OK ) goto end_of_vacuum;\n\n  /* Do not attempt to change the page size for a WAL database */\n  if( sqlite3PagerGetJournalMode(sqlite3BtreePager(pMain))\n                                               ==PAGER_JOURNALMODE_WAL ){\n    db->nextPagesize = 0;\n  }\n\n  if( sqlite3BtreeSetPageSize(pTemp, sqlite3BtreeGetPageSize(pMain), nRes, 0)\n   || (!isMemDb && sqlite3BtreeSetPageSize(pTemp, db->nextPagesize, nRes, 0))\n   || NEVER(db->mallocFailed)\n  ){\n    rc = SQLITE_NOMEM_BKPT;\n    goto end_of_vacuum;\n  }\n\n#ifndef SQLITE_OMIT_AUTOVACUUM\n  sqlite3BtreeSetAutoVacuum(pTemp, db->nextAutovac>=0 ? db->nextAutovac :\n                                           sqlite3BtreeGetAutoVacuum(pMain));\n#endif\n\n  /* Query the schema of the main database. Create a mirror schema\n  ** in the temporary database.\n  */\n  db->init.iDb = nDb; /* force new CREATE statements into vacuum_db */\n  rc = execSqlF(db, pzErrMsg,\n      \"SELECT sql FROM \\\"%w\\\".sqlite_master\"\n      \" WHERE type='table'AND name<>'sqlite_sequence'\"\n      \" AND coalesce(rootpage,1)>0\",\n      zDbMain\n  );\n  if( rc!=SQLITE_OK ) goto end_of_vacuum;\n  rc = execSqlF(db, pzErrMsg,\n      \"SELECT sql FROM \\\"%w\\\".sqlite_master\"\n      \" WHERE type='index'\",\n      zDbMain\n  );\n  if( rc!=SQLITE_OK ) goto end_of_vacuum;\n  db->init.iDb = 0;\n\n  /* Loop through the tables in the main database. For each, do\n  ** an \"INSERT INTO vacuum_db.xxx SELECT * FROM main.xxx;\" to copy\n  ** the contents to the temporary database.\n  */\n  rc = execSqlF(db, pzErrMsg,\n      \"SELECT'INSERT INTO vacuum_db.'||quote(name)\"\n      \"||' SELECT*FROM\\\"%w\\\".'||quote(name)\"\n      \"FROM vacuum_db.sqlite_master \"\n      \"WHERE type='table'AND coalesce(rootpage,1)>0\",\n      zDbMain\n  );\n  assert( (db->mDbFlags & DBFLAG_Vacuum)!=0 );\n  db->mDbFlags &= ~DBFLAG_Vacuum;\n  if( rc!=SQLITE_OK ) goto end_of_vacuum;\n\n  /* Copy the triggers, views, and virtual tables from the main database\n  ** over to the temporary database.  None of these objects has any\n  ** associated storage, so all we have to do is copy their entries\n  ** from the SQLITE_MASTER table.\n  */\n  rc = execSqlF(db, pzErrMsg,\n      \"INSERT INTO vacuum_db.sqlite_master\"\n      \" SELECT*FROM \\\"%w\\\".sqlite_master\"\n      \" WHERE type IN('view','trigger')\"\n      \" OR(type='table'AND rootpage=0)\",\n      zDbMain\n  );\n  if( rc ) goto end_of_vacuum;\n\n  /* At this point, there is a write transaction open on both the \n  ** vacuum database and the main database. Assuming no error occurs,\n  ** both transactions are closed by this block - the main database\n  ** transaction by sqlite3BtreeCopyFile() and the other by an explicit\n  ** call to sqlite3BtreeCommit().\n  */\n  {\n    u32 meta;\n    int i;\n\n    /* This array determines which meta meta values are preserved in the\n    ** vacuum.  Even entries are the meta value number and odd entries\n    ** are an increment to apply to the meta value after the vacuum.\n    ** The increment is used to increase the schema cookie so that other\n    ** connections to the same database will know to reread the schema.\n    */\n    static const unsigned char aCopy[] = {\n       BTREE_SCHEMA_VERSION,     1,  /* Add one to the old schema cookie */\n       BTREE_DEFAULT_CACHE_SIZE, 0,  /* Preserve the default page cache size */\n       BTREE_TEXT_ENCODING,      0,  /* Preserve the text encoding */\n       BTREE_USER_VERSION,       0,  /* Preserve the user version */\n       BTREE_APPLICATION_ID,     0,  /* Preserve the application id */\n    };\n\n    assert( 1==sqlite3BtreeIsInTrans(pTemp) );\n    assert( pOut!=0 || 1==sqlite3BtreeIsInTrans(pMain) );\n\n    /* Copy Btree meta values */\n    for(i=0; i<ArraySize(aCopy); i+=2){\n      /* GetMeta() and UpdateMeta() cannot fail in this context because\n      ** we already have page 1 loaded into cache and marked dirty. */\n      sqlite3BtreeGetMeta(pMain, aCopy[i], &meta);\n      rc = sqlite3BtreeUpdateMeta(pTemp, aCopy[i], meta+aCopy[i+1]);\n      if( NEVER(rc!=SQLITE_OK) ) goto end_of_vacuum;\n    }\n\n    if( pOut==0 ){\n      rc = sqlite3BtreeCopyFile(pMain, pTemp);\n    }\n    if( rc!=SQLITE_OK ) goto end_of_vacuum;\n    rc = sqlite3BtreeCommit(pTemp);\n    if( rc!=SQLITE_OK ) goto end_of_vacuum;\n#ifndef SQLITE_OMIT_AUTOVACUUM\n    if( pOut==0 ){\n      sqlite3BtreeSetAutoVacuum(pMain, sqlite3BtreeGetAutoVacuum(pTemp));\n    }\n#endif\n  }\n\n  assert( rc==SQLITE_OK );\n  if( pOut==0 ){\n    rc = sqlite3BtreeSetPageSize(pMain, sqlite3BtreeGetPageSize(pTemp), nRes,1);\n  }\n\nend_of_vacuum:\n  /* Restore the original value of db->flags */\n  db->init.iDb = 0;\n  db->mDbFlags = saved_mDbFlags;\n  db->flags = saved_flags;\n  db->nChange = saved_nChange;\n  db->nTotalChange = saved_nTotalChange;\n  db->mTrace = saved_mTrace;\n  sqlite3BtreeSetPageSize(pMain, -1, -1, 1);\n\n  /* Currently there is an SQL level transaction open on the vacuum\n  ** database. No locks are held on any other files (since the main file\n  ** was committed at the btree level). So it safe to end the transaction\n  ** by manually setting the autoCommit flag to true and detaching the\n  ** vacuum database. The vacuum_db journal file is deleted when the pager\n  ** is closed by the DETACH.\n  */\n  db->autoCommit = 1;\n\n  if( pDb ){\n    sqlite3BtreeClose(pDb->pBt);\n    pDb->pBt = 0;\n    pDb->pSchema = 0;\n  }\n\n  /* This both clears the schemas and reduces the size of the db->aDb[]\n  ** array. */ \n  sqlite3ResetAllSchemasOfConnection(db);\n\n  return rc;\n}\n\n#endif  /* SQLITE_OMIT_VACUUM && SQLITE_OMIT_ATTACH */\n\n/************** End of vacuum.c **********************************************/\n/************** Begin file vtab.c ********************************************/\n/*\n** 2006 June 10\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This file contains code used to help implement virtual tables.\n*/\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n/* #include \"sqliteInt.h\" */\n\n/*\n** Before a virtual table xCreate() or xConnect() method is invoked, the\n** sqlite3.pVtabCtx member variable is set to point to an instance of\n** this struct allocated on the stack. It is used by the implementation of \n** the sqlite3_declare_vtab() and sqlite3_vtab_config() APIs, both of which\n** are invoked only from within xCreate and xConnect methods.\n*/\nstruct VtabCtx {\n  VTable *pVTable;    /* The virtual table being constructed */\n  Table *pTab;        /* The Table object to which the virtual table belongs */\n  VtabCtx *pPrior;    /* Parent context (if any) */\n  int bDeclared;      /* True after sqlite3_declare_vtab() is called */\n};\n\n/*\n** Construct and install a Module object for a virtual table.  When this\n** routine is called, it is guaranteed that all appropriate locks are held\n** and the module is not already part of the connection.\n*/\nSQLITE_PRIVATE Module *sqlite3VtabCreateModule(\n  sqlite3 *db,                    /* Database in which module is registered */\n  const char *zName,              /* Name assigned to this module */\n  const sqlite3_module *pModule,  /* The definition of the module */\n  void *pAux,                     /* Context pointer for xCreate/xConnect */\n  void (*xDestroy)(void *)        /* Module destructor function */\n){\n  Module *pMod;\n  int nName = sqlite3Strlen30(zName);\n  pMod = (Module *)sqlite3Malloc(sizeof(Module) + nName + 1);\n  if( pMod==0 ){\n    sqlite3OomFault(db);\n  }else{\n    Module *pDel;\n    char *zCopy = (char *)(&pMod[1]);\n    memcpy(zCopy, zName, nName+1);\n    pMod->zName = zCopy;\n    pMod->pModule = pModule;\n    pMod->pAux = pAux;\n    pMod->xDestroy = xDestroy;\n    pMod->pEpoTab = 0;\n    pDel = (Module *)sqlite3HashInsert(&db->aModule,zCopy,(void*)pMod);\n    assert( pDel==0 || pDel==pMod );\n    if( pDel ){\n      sqlite3OomFault(db);\n      sqlite3DbFree(db, pDel);\n      pMod = 0;\n    }\n  }\n  return pMod;\n}\n\n/*\n** The actual function that does the work of creating a new module.\n** This function implements the sqlite3_create_module() and\n** sqlite3_create_module_v2() interfaces.\n*/\nstatic int createModule(\n  sqlite3 *db,                    /* Database in which module is registered */\n  const char *zName,              /* Name assigned to this module */\n  const sqlite3_module *pModule,  /* The definition of the module */\n  void *pAux,                     /* Context pointer for xCreate/xConnect */\n  void (*xDestroy)(void *)        /* Module destructor function */\n){\n  int rc = SQLITE_OK;\n\n  sqlite3_mutex_enter(db->mutex);\n  if( sqlite3HashFind(&db->aModule, zName) ){\n    rc = SQLITE_MISUSE_BKPT;\n  }else{\n    (void)sqlite3VtabCreateModule(db, zName, pModule, pAux, xDestroy);\n  }\n  rc = sqlite3ApiExit(db, rc);\n  if( rc!=SQLITE_OK && xDestroy ) xDestroy(pAux);\n  sqlite3_mutex_leave(db->mutex);\n  return rc;\n}\n\n\n/*\n** External API function used to create a new virtual-table module.\n*/\nSQLITE_API int sqlite3_create_module(\n  sqlite3 *db,                    /* Database in which module is registered */\n  const char *zName,              /* Name assigned to this module */\n  const sqlite3_module *pModule,  /* The definition of the module */\n  void *pAux                      /* Context pointer for xCreate/xConnect */\n){\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( !sqlite3SafetyCheckOk(db) || zName==0 ) return SQLITE_MISUSE_BKPT;\n#endif\n  return createModule(db, zName, pModule, pAux, 0);\n}\n\n/*\n** External API function used to create a new virtual-table module.\n*/\nSQLITE_API int sqlite3_create_module_v2(\n  sqlite3 *db,                    /* Database in which module is registered */\n  const char *zName,              /* Name assigned to this module */\n  const sqlite3_module *pModule,  /* The definition of the module */\n  void *pAux,                     /* Context pointer for xCreate/xConnect */\n  void (*xDestroy)(void *)        /* Module destructor function */\n){\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( !sqlite3SafetyCheckOk(db) || zName==0 ) return SQLITE_MISUSE_BKPT;\n#endif\n  return createModule(db, zName, pModule, pAux, xDestroy);\n}\n\n/*\n** Lock the virtual table so that it cannot be disconnected.\n** Locks nest.  Every lock should have a corresponding unlock.\n** If an unlock is omitted, resources leaks will occur.  \n**\n** If a disconnect is attempted while a virtual table is locked,\n** the disconnect is deferred until all locks have been removed.\n*/\nSQLITE_PRIVATE void sqlite3VtabLock(VTable *pVTab){\n  pVTab->nRef++;\n}\n\n\n/*\n** pTab is a pointer to a Table structure representing a virtual-table.\n** Return a pointer to the VTable object used by connection db to access \n** this virtual-table, if one has been created, or NULL otherwise.\n*/\nSQLITE_PRIVATE VTable *sqlite3GetVTable(sqlite3 *db, Table *pTab){\n  VTable *pVtab;\n  assert( IsVirtual(pTab) );\n  for(pVtab=pTab->pVTable; pVtab && pVtab->db!=db; pVtab=pVtab->pNext);\n  return pVtab;\n}\n\n/*\n** Decrement the ref-count on a virtual table object. When the ref-count\n** reaches zero, call the xDisconnect() method to delete the object.\n*/\nSQLITE_PRIVATE void sqlite3VtabUnlock(VTable *pVTab){\n  sqlite3 *db = pVTab->db;\n\n  assert( db );\n  assert( pVTab->nRef>0 );\n  assert( db->magic==SQLITE_MAGIC_OPEN || db->magic==SQLITE_MAGIC_ZOMBIE );\n\n  pVTab->nRef--;\n  if( pVTab->nRef==0 ){\n    sqlite3_vtab *p = pVTab->pVtab;\n    if( p ){\n      p->pModule->xDisconnect(p);\n    }\n    sqlite3DbFree(db, pVTab);\n  }\n}\n\n/*\n** Table p is a virtual table. This function moves all elements in the\n** p->pVTable list to the sqlite3.pDisconnect lists of their associated\n** database connections to be disconnected at the next opportunity. \n** Except, if argument db is not NULL, then the entry associated with\n** connection db is left in the p->pVTable list.\n*/\nstatic VTable *vtabDisconnectAll(sqlite3 *db, Table *p){\n  VTable *pRet = 0;\n  VTable *pVTable = p->pVTable;\n  p->pVTable = 0;\n\n  /* Assert that the mutex (if any) associated with the BtShared database \n  ** that contains table p is held by the caller. See header comments \n  ** above function sqlite3VtabUnlockList() for an explanation of why\n  ** this makes it safe to access the sqlite3.pDisconnect list of any\n  ** database connection that may have an entry in the p->pVTable list.\n  */\n  assert( db==0 || sqlite3SchemaMutexHeld(db, 0, p->pSchema) );\n\n  while( pVTable ){\n    sqlite3 *db2 = pVTable->db;\n    VTable *pNext = pVTable->pNext;\n    assert( db2 );\n    if( db2==db ){\n      pRet = pVTable;\n      p->pVTable = pRet;\n      pRet->pNext = 0;\n    }else{\n      pVTable->pNext = db2->pDisconnect;\n      db2->pDisconnect = pVTable;\n    }\n    pVTable = pNext;\n  }\n\n  assert( !db || pRet );\n  return pRet;\n}\n\n/*\n** Table *p is a virtual table. This function removes the VTable object\n** for table *p associated with database connection db from the linked\n** list in p->pVTab. It also decrements the VTable ref count. This is\n** used when closing database connection db to free all of its VTable\n** objects without disturbing the rest of the Schema object (which may\n** be being used by other shared-cache connections).\n*/\nSQLITE_PRIVATE void sqlite3VtabDisconnect(sqlite3 *db, Table *p){\n  VTable **ppVTab;\n\n  assert( IsVirtual(p) );\n  assert( sqlite3BtreeHoldsAllMutexes(db) );\n  assert( sqlite3_mutex_held(db->mutex) );\n\n  for(ppVTab=&p->pVTable; *ppVTab; ppVTab=&(*ppVTab)->pNext){\n    if( (*ppVTab)->db==db  ){\n      VTable *pVTab = *ppVTab;\n      *ppVTab = pVTab->pNext;\n      sqlite3VtabUnlock(pVTab);\n      break;\n    }\n  }\n}\n\n\n/*\n** Disconnect all the virtual table objects in the sqlite3.pDisconnect list.\n**\n** This function may only be called when the mutexes associated with all\n** shared b-tree databases opened using connection db are held by the \n** caller. This is done to protect the sqlite3.pDisconnect list. The\n** sqlite3.pDisconnect list is accessed only as follows:\n**\n**   1) By this function. In this case, all BtShared mutexes and the mutex\n**      associated with the database handle itself must be held.\n**\n**   2) By function vtabDisconnectAll(), when it adds a VTable entry to\n**      the sqlite3.pDisconnect list. In this case either the BtShared mutex\n**      associated with the database the virtual table is stored in is held\n**      or, if the virtual table is stored in a non-sharable database, then\n**      the database handle mutex is held.\n**\n** As a result, a sqlite3.pDisconnect cannot be accessed simultaneously \n** by multiple threads. It is thread-safe.\n*/\nSQLITE_PRIVATE void sqlite3VtabUnlockList(sqlite3 *db){\n  VTable *p = db->pDisconnect;\n  db->pDisconnect = 0;\n\n  assert( sqlite3BtreeHoldsAllMutexes(db) );\n  assert( sqlite3_mutex_held(db->mutex) );\n\n  if( p ){\n    sqlite3ExpirePreparedStatements(db, 0);\n    do {\n      VTable *pNext = p->pNext;\n      sqlite3VtabUnlock(p);\n      p = pNext;\n    }while( p );\n  }\n}\n\n/*\n** Clear any and all virtual-table information from the Table record.\n** This routine is called, for example, just before deleting the Table\n** record.\n**\n** Since it is a virtual-table, the Table structure contains a pointer\n** to the head of a linked list of VTable structures. Each VTable \n** structure is associated with a single sqlite3* user of the schema.\n** The reference count of the VTable structure associated with database \n** connection db is decremented immediately (which may lead to the \n** structure being xDisconnected and free). Any other VTable structures\n** in the list are moved to the sqlite3.pDisconnect list of the associated \n** database connection.\n*/\nSQLITE_PRIVATE void sqlite3VtabClear(sqlite3 *db, Table *p){\n  if( !db || db->pnBytesFreed==0 ) vtabDisconnectAll(0, p);\n  if( p->azModuleArg ){\n    int i;\n    for(i=0; i<p->nModuleArg; i++){\n      if( i!=1 ) sqlite3DbFree(db, p->azModuleArg[i]);\n    }\n    sqlite3DbFree(db, p->azModuleArg);\n  }\n}\n\n/*\n** Add a new module argument to pTable->azModuleArg[].\n** The string is not copied - the pointer is stored.  The\n** string will be freed automatically when the table is\n** deleted.\n*/\nstatic void addModuleArgument(sqlite3 *db, Table *pTable, char *zArg){\n  int nBytes = sizeof(char *)*(2+pTable->nModuleArg);\n  char **azModuleArg;\n  azModuleArg = sqlite3DbRealloc(db, pTable->azModuleArg, nBytes);\n  if( azModuleArg==0 ){\n    sqlite3DbFree(db, zArg);\n  }else{\n    int i = pTable->nModuleArg++;\n    azModuleArg[i] = zArg;\n    azModuleArg[i+1] = 0;\n    pTable->azModuleArg = azModuleArg;\n  }\n}\n\n/*\n** The parser calls this routine when it first sees a CREATE VIRTUAL TABLE\n** statement.  The module name has been parsed, but the optional list\n** of parameters that follow the module name are still pending.\n*/\nSQLITE_PRIVATE void sqlite3VtabBeginParse(\n  Parse *pParse,        /* Parsing context */\n  Token *pName1,        /* Name of new table, or database name */\n  Token *pName2,        /* Name of new table or NULL */\n  Token *pModuleName,   /* Name of the module for the virtual table */\n  int ifNotExists       /* No error if the table already exists */\n){\n  Table *pTable;        /* The new virtual table */\n  sqlite3 *db;          /* Database connection */\n\n  sqlite3StartTable(pParse, pName1, pName2, 0, 0, 1, ifNotExists);\n  pTable = pParse->pNewTable;\n  if( pTable==0 ) return;\n  assert( 0==pTable->pIndex );\n\n  db = pParse->db;\n\n  assert( pTable->nModuleArg==0 );\n  addModuleArgument(db, pTable, sqlite3NameFromToken(db, pModuleName));\n  addModuleArgument(db, pTable, 0);\n  addModuleArgument(db, pTable, sqlite3DbStrDup(db, pTable->zName));\n  assert( (pParse->sNameToken.z==pName2->z && pName2->z!=0)\n       || (pParse->sNameToken.z==pName1->z && pName2->z==0)\n  );\n  pParse->sNameToken.n = (int)(\n      &pModuleName->z[pModuleName->n] - pParse->sNameToken.z\n  );\n\n#ifndef SQLITE_OMIT_AUTHORIZATION\n  /* Creating a virtual table invokes the authorization callback twice.\n  ** The first invocation, to obtain permission to INSERT a row into the\n  ** sqlite_master table, has already been made by sqlite3StartTable().\n  ** The second call, to obtain permission to create the table, is made now.\n  */\n  if( pTable->azModuleArg ){\n    int iDb = sqlite3SchemaToIndex(db, pTable->pSchema);\n    assert( iDb>=0 ); /* The database the table is being created in */\n    sqlite3AuthCheck(pParse, SQLITE_CREATE_VTABLE, pTable->zName, \n            pTable->azModuleArg[0], pParse->db->aDb[iDb].zDbSName);\n  }\n#endif\n}\n\n/*\n** This routine takes the module argument that has been accumulating\n** in pParse->zArg[] and appends it to the list of arguments on the\n** virtual table currently under construction in pParse->pTable.\n*/\nstatic void addArgumentToVtab(Parse *pParse){\n  if( pParse->sArg.z && pParse->pNewTable ){\n    const char *z = (const char*)pParse->sArg.z;\n    int n = pParse->sArg.n;\n    sqlite3 *db = pParse->db;\n    addModuleArgument(db, pParse->pNewTable, sqlite3DbStrNDup(db, z, n));\n  }\n}\n\n/*\n** The parser calls this routine after the CREATE VIRTUAL TABLE statement\n** has been completely parsed.\n*/\nSQLITE_PRIVATE void sqlite3VtabFinishParse(Parse *pParse, Token *pEnd){\n  Table *pTab = pParse->pNewTable;  /* The table being constructed */\n  sqlite3 *db = pParse->db;         /* The database connection */\n\n  if( pTab==0 ) return;\n  addArgumentToVtab(pParse);\n  pParse->sArg.z = 0;\n  if( pTab->nModuleArg<1 ) return;\n  \n  /* If the CREATE VIRTUAL TABLE statement is being entered for the\n  ** first time (in other words if the virtual table is actually being\n  ** created now instead of just being read out of sqlite_master) then\n  ** do additional initialization work and store the statement text\n  ** in the sqlite_master table.\n  */\n  if( !db->init.busy ){\n    char *zStmt;\n    char *zWhere;\n    int iDb;\n    int iReg;\n    Vdbe *v;\n\n    /* Compute the complete text of the CREATE VIRTUAL TABLE statement */\n    if( pEnd ){\n      pParse->sNameToken.n = (int)(pEnd->z - pParse->sNameToken.z) + pEnd->n;\n    }\n    zStmt = sqlite3MPrintf(db, \"CREATE VIRTUAL TABLE %T\", &pParse->sNameToken);\n\n    /* A slot for the record has already been allocated in the \n    ** SQLITE_MASTER table.  We just need to update that slot with all\n    ** the information we've collected.  \n    **\n    ** The VM register number pParse->regRowid holds the rowid of an\n    ** entry in the sqlite_master table tht was created for this vtab\n    ** by sqlite3StartTable().\n    */\n    iDb = sqlite3SchemaToIndex(db, pTab->pSchema);\n    sqlite3NestedParse(pParse,\n      \"UPDATE %Q.%s \"\n         \"SET type='table', name=%Q, tbl_name=%Q, rootpage=0, sql=%Q \"\n       \"WHERE rowid=#%d\",\n      db->aDb[iDb].zDbSName, MASTER_NAME,\n      pTab->zName,\n      pTab->zName,\n      zStmt,\n      pParse->regRowid\n    );\n    sqlite3DbFree(db, zStmt);\n    v = sqlite3GetVdbe(pParse);\n    sqlite3ChangeCookie(pParse, iDb);\n\n    sqlite3VdbeAddOp0(v, OP_Expire);\n    zWhere = sqlite3MPrintf(db, \"name='%q' AND type='table'\", pTab->zName);\n    sqlite3VdbeAddParseSchemaOp(v, iDb, zWhere);\n\n    iReg = ++pParse->nMem;\n    sqlite3VdbeLoadString(v, iReg, pTab->zName);\n    sqlite3VdbeAddOp2(v, OP_VCreate, iDb, iReg);\n  }\n\n  /* If we are rereading the sqlite_master table create the in-memory\n  ** record of the table. The xConnect() method is not called until\n  ** the first time the virtual table is used in an SQL statement. This\n  ** allows a schema that contains virtual tables to be loaded before\n  ** the required virtual table implementations are registered.  */\n  else {\n    Table *pOld;\n    Schema *pSchema = pTab->pSchema;\n    const char *zName = pTab->zName;\n    assert( sqlite3SchemaMutexHeld(db, 0, pSchema) );\n    pOld = sqlite3HashInsert(&pSchema->tblHash, zName, pTab);\n    if( pOld ){\n      sqlite3OomFault(db);\n      assert( pTab==pOld );  /* Malloc must have failed inside HashInsert() */\n      return;\n    }\n    pParse->pNewTable = 0;\n  }\n}\n\n/*\n** The parser calls this routine when it sees the first token\n** of an argument to the module name in a CREATE VIRTUAL TABLE statement.\n*/\nSQLITE_PRIVATE void sqlite3VtabArgInit(Parse *pParse){\n  addArgumentToVtab(pParse);\n  pParse->sArg.z = 0;\n  pParse->sArg.n = 0;\n}\n\n/*\n** The parser calls this routine for each token after the first token\n** in an argument to the module name in a CREATE VIRTUAL TABLE statement.\n*/\nSQLITE_PRIVATE void sqlite3VtabArgExtend(Parse *pParse, Token *p){\n  Token *pArg = &pParse->sArg;\n  if( pArg->z==0 ){\n    pArg->z = p->z;\n    pArg->n = p->n;\n  }else{\n    assert(pArg->z <= p->z);\n    pArg->n = (int)(&p->z[p->n] - pArg->z);\n  }\n}\n\n/*\n** Invoke a virtual table constructor (either xCreate or xConnect). The\n** pointer to the function to invoke is passed as the fourth parameter\n** to this procedure.\n*/\nstatic int vtabCallConstructor(\n  sqlite3 *db, \n  Table *pTab,\n  Module *pMod,\n  int (*xConstruct)(sqlite3*,void*,int,const char*const*,sqlite3_vtab**,char**),\n  char **pzErr\n){\n  VtabCtx sCtx;\n  VTable *pVTable;\n  int rc;\n  const char *const*azArg = (const char *const*)pTab->azModuleArg;\n  int nArg = pTab->nModuleArg;\n  char *zErr = 0;\n  char *zModuleName;\n  int iDb;\n  VtabCtx *pCtx;\n\n  /* Check that the virtual-table is not already being initialized */\n  for(pCtx=db->pVtabCtx; pCtx; pCtx=pCtx->pPrior){\n    if( pCtx->pTab==pTab ){\n      *pzErr = sqlite3MPrintf(db, \n          \"vtable constructor called recursively: %s\", pTab->zName\n      );\n      return SQLITE_LOCKED;\n    }\n  }\n\n  zModuleName = sqlite3DbStrDup(db, pTab->zName);\n  if( !zModuleName ){\n    return SQLITE_NOMEM_BKPT;\n  }\n\n  pVTable = sqlite3MallocZero(sizeof(VTable));\n  if( !pVTable ){\n    sqlite3OomFault(db);\n    sqlite3DbFree(db, zModuleName);\n    return SQLITE_NOMEM_BKPT;\n  }\n  pVTable->db = db;\n  pVTable->pMod = pMod;\n\n  iDb = sqlite3SchemaToIndex(db, pTab->pSchema);\n  pTab->azModuleArg[1] = db->aDb[iDb].zDbSName;\n\n  /* Invoke the virtual table constructor */\n  assert( &db->pVtabCtx );\n  assert( xConstruct );\n  sCtx.pTab = pTab;\n  sCtx.pVTable = pVTable;\n  sCtx.pPrior = db->pVtabCtx;\n  sCtx.bDeclared = 0;\n  db->pVtabCtx = &sCtx;\n  rc = xConstruct(db, pMod->pAux, nArg, azArg, &pVTable->pVtab, &zErr);\n  db->pVtabCtx = sCtx.pPrior;\n  if( rc==SQLITE_NOMEM ) sqlite3OomFault(db);\n  assert( sCtx.pTab==pTab );\n\n  if( SQLITE_OK!=rc ){\n    if( zErr==0 ){\n      *pzErr = sqlite3MPrintf(db, \"vtable constructor failed: %s\", zModuleName);\n    }else {\n      *pzErr = sqlite3MPrintf(db, \"%s\", zErr);\n      sqlite3_free(zErr);\n    }\n    sqlite3DbFree(db, pVTable);\n  }else if( ALWAYS(pVTable->pVtab) ){\n    /* Justification of ALWAYS():  A correct vtab constructor must allocate\n    ** the sqlite3_vtab object if successful.  */\n    memset(pVTable->pVtab, 0, sizeof(pVTable->pVtab[0]));\n    pVTable->pVtab->pModule = pMod->pModule;\n    pVTable->nRef = 1;\n    if( sCtx.bDeclared==0 ){\n      const char *zFormat = \"vtable constructor did not declare schema: %s\";\n      *pzErr = sqlite3MPrintf(db, zFormat, pTab->zName);\n      sqlite3VtabUnlock(pVTable);\n      rc = SQLITE_ERROR;\n    }else{\n      int iCol;\n      u8 oooHidden = 0;\n      /* If everything went according to plan, link the new VTable structure\n      ** into the linked list headed by pTab->pVTable. Then loop through the \n      ** columns of the table to see if any of them contain the token \"hidden\".\n      ** If so, set the Column COLFLAG_HIDDEN flag and remove the token from\n      ** the type string.  */\n      pVTable->pNext = pTab->pVTable;\n      pTab->pVTable = pVTable;\n\n      for(iCol=0; iCol<pTab->nCol; iCol++){\n        char *zType = sqlite3ColumnType(&pTab->aCol[iCol], \"\");\n        int nType;\n        int i = 0;\n        nType = sqlite3Strlen30(zType);\n        for(i=0; i<nType; i++){\n          if( 0==sqlite3StrNICmp(\"hidden\", &zType[i], 6)\n           && (i==0 || zType[i-1]==' ')\n           && (zType[i+6]=='\\0' || zType[i+6]==' ')\n          ){\n            break;\n          }\n        }\n        if( i<nType ){\n          int j;\n          int nDel = 6 + (zType[i+6] ? 1 : 0);\n          for(j=i; (j+nDel)<=nType; j++){\n            zType[j] = zType[j+nDel];\n          }\n          if( zType[i]=='\\0' && i>0 ){\n            assert(zType[i-1]==' ');\n            zType[i-1] = '\\0';\n          }\n          pTab->aCol[iCol].colFlags |= COLFLAG_HIDDEN;\n          oooHidden = TF_OOOHidden;\n        }else{\n          pTab->tabFlags |= oooHidden;\n        }\n      }\n    }\n  }\n\n  sqlite3DbFree(db, zModuleName);\n  return rc;\n}\n\n/*\n** This function is invoked by the parser to call the xConnect() method\n** of the virtual table pTab. If an error occurs, an error code is returned \n** and an error left in pParse.\n**\n** This call is a no-op if table pTab is not a virtual table.\n*/\nSQLITE_PRIVATE int sqlite3VtabCallConnect(Parse *pParse, Table *pTab){\n  sqlite3 *db = pParse->db;\n  const char *zMod;\n  Module *pMod;\n  int rc;\n\n  assert( pTab );\n  if( !IsVirtual(pTab) || sqlite3GetVTable(db, pTab) ){\n    return SQLITE_OK;\n  }\n\n  /* Locate the required virtual table module */\n  zMod = pTab->azModuleArg[0];\n  pMod = (Module*)sqlite3HashFind(&db->aModule, zMod);\n\n  if( !pMod ){\n    const char *zModule = pTab->azModuleArg[0];\n    sqlite3ErrorMsg(pParse, \"no such module: %s\", zModule);\n    rc = SQLITE_ERROR;\n  }else{\n    char *zErr = 0;\n    rc = vtabCallConstructor(db, pTab, pMod, pMod->pModule->xConnect, &zErr);\n    if( rc!=SQLITE_OK ){\n      sqlite3ErrorMsg(pParse, \"%s\", zErr);\n      pParse->rc = rc;\n    }\n    sqlite3DbFree(db, zErr);\n  }\n\n  return rc;\n}\n/*\n** Grow the db->aVTrans[] array so that there is room for at least one\n** more v-table. Return SQLITE_NOMEM if a malloc fails, or SQLITE_OK otherwise.\n*/\nstatic int growVTrans(sqlite3 *db){\n  const int ARRAY_INCR = 5;\n\n  /* Grow the sqlite3.aVTrans array if required */\n  if( (db->nVTrans%ARRAY_INCR)==0 ){\n    VTable **aVTrans;\n    int nBytes = sizeof(sqlite3_vtab *) * (db->nVTrans + ARRAY_INCR);\n    aVTrans = sqlite3DbRealloc(db, (void *)db->aVTrans, nBytes);\n    if( !aVTrans ){\n      return SQLITE_NOMEM_BKPT;\n    }\n    memset(&aVTrans[db->nVTrans], 0, sizeof(sqlite3_vtab *)*ARRAY_INCR);\n    db->aVTrans = aVTrans;\n  }\n\n  return SQLITE_OK;\n}\n\n/*\n** Add the virtual table pVTab to the array sqlite3.aVTrans[]. Space should\n** have already been reserved using growVTrans().\n*/\nstatic void addToVTrans(sqlite3 *db, VTable *pVTab){\n  /* Add pVtab to the end of sqlite3.aVTrans */\n  db->aVTrans[db->nVTrans++] = pVTab;\n  sqlite3VtabLock(pVTab);\n}\n\n/*\n** This function is invoked by the vdbe to call the xCreate method\n** of the virtual table named zTab in database iDb. \n**\n** If an error occurs, *pzErr is set to point to an English language\n** description of the error and an SQLITE_XXX error code is returned.\n** In this case the caller must call sqlite3DbFree(db, ) on *pzErr.\n*/\nSQLITE_PRIVATE int sqlite3VtabCallCreate(sqlite3 *db, int iDb, const char *zTab, char **pzErr){\n  int rc = SQLITE_OK;\n  Table *pTab;\n  Module *pMod;\n  const char *zMod;\n\n  pTab = sqlite3FindTable(db, zTab, db->aDb[iDb].zDbSName);\n  assert( pTab && IsVirtual(pTab) && !pTab->pVTable );\n\n  /* Locate the required virtual table module */\n  zMod = pTab->azModuleArg[0];\n  pMod = (Module*)sqlite3HashFind(&db->aModule, zMod);\n\n  /* If the module has been registered and includes a Create method, \n  ** invoke it now. If the module has not been registered, return an \n  ** error. Otherwise, do nothing.\n  */\n  if( pMod==0 || pMod->pModule->xCreate==0 || pMod->pModule->xDestroy==0 ){\n    *pzErr = sqlite3MPrintf(db, \"no such module: %s\", zMod);\n    rc = SQLITE_ERROR;\n  }else{\n    rc = vtabCallConstructor(db, pTab, pMod, pMod->pModule->xCreate, pzErr);\n  }\n\n  /* Justification of ALWAYS():  The xConstructor method is required to\n  ** create a valid sqlite3_vtab if it returns SQLITE_OK. */\n  if( rc==SQLITE_OK && ALWAYS(sqlite3GetVTable(db, pTab)) ){\n    rc = growVTrans(db);\n    if( rc==SQLITE_OK ){\n      addToVTrans(db, sqlite3GetVTable(db, pTab));\n    }\n  }\n\n  return rc;\n}\n\n/*\n** This function is used to set the schema of a virtual table.  It is only\n** valid to call this function from within the xCreate() or xConnect() of a\n** virtual table module.\n*/\nSQLITE_API int sqlite3_declare_vtab(sqlite3 *db, const char *zCreateTable){\n  VtabCtx *pCtx;\n  int rc = SQLITE_OK;\n  Table *pTab;\n  char *zErr = 0;\n  Parse sParse;\n\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( !sqlite3SafetyCheckOk(db) || zCreateTable==0 ){\n    return SQLITE_MISUSE_BKPT;\n  }\n#endif\n  sqlite3_mutex_enter(db->mutex);\n  pCtx = db->pVtabCtx;\n  if( !pCtx || pCtx->bDeclared ){\n    sqlite3Error(db, SQLITE_MISUSE);\n    sqlite3_mutex_leave(db->mutex);\n    return SQLITE_MISUSE_BKPT;\n  }\n  pTab = pCtx->pTab;\n  assert( IsVirtual(pTab) );\n\n  memset(&sParse, 0, sizeof(sParse));\n  sParse.eParseMode = PARSE_MODE_DECLARE_VTAB;\n  sParse.db = db;\n  sParse.nQueryLoop = 1;\n  if( SQLITE_OK==sqlite3RunParser(&sParse, zCreateTable, &zErr) \n   && sParse.pNewTable\n   && !db->mallocFailed\n   && !sParse.pNewTable->pSelect\n   && !IsVirtual(sParse.pNewTable)\n  ){\n    if( !pTab->aCol ){\n      Table *pNew = sParse.pNewTable;\n      Index *pIdx;\n      pTab->aCol = pNew->aCol;\n      pTab->nCol = pNew->nCol;\n      pTab->tabFlags |= pNew->tabFlags & (TF_WithoutRowid|TF_NoVisibleRowid);\n      pNew->nCol = 0;\n      pNew->aCol = 0;\n      assert( pTab->pIndex==0 );\n      assert( HasRowid(pNew) || sqlite3PrimaryKeyIndex(pNew)!=0 );\n      if( !HasRowid(pNew)\n       && pCtx->pVTable->pMod->pModule->xUpdate!=0\n       && sqlite3PrimaryKeyIndex(pNew)->nKeyCol!=1\n      ){\n        /* WITHOUT ROWID virtual tables must either be read-only (xUpdate==0)\n        ** or else must have a single-column PRIMARY KEY */\n        rc = SQLITE_ERROR;\n      }\n      pIdx = pNew->pIndex;\n      if( pIdx ){\n        assert( pIdx->pNext==0 );\n        pTab->pIndex = pIdx;\n        pNew->pIndex = 0;\n        pIdx->pTable = pTab;\n      }\n    }\n    pCtx->bDeclared = 1;\n  }else{\n    sqlite3ErrorWithMsg(db, SQLITE_ERROR, (zErr ? \"%s\" : 0), zErr);\n    sqlite3DbFree(db, zErr);\n    rc = SQLITE_ERROR;\n  }\n  sParse.eParseMode = PARSE_MODE_NORMAL;\n\n  if( sParse.pVdbe ){\n    sqlite3VdbeFinalize(sParse.pVdbe);\n  }\n  sqlite3DeleteTable(db, sParse.pNewTable);\n  sqlite3ParserReset(&sParse);\n\n  assert( (rc&0xff)==rc );\n  rc = sqlite3ApiExit(db, rc);\n  sqlite3_mutex_leave(db->mutex);\n  return rc;\n}\n\n/*\n** This function is invoked by the vdbe to call the xDestroy method\n** of the virtual table named zTab in database iDb. This occurs\n** when a DROP TABLE is mentioned.\n**\n** This call is a no-op if zTab is not a virtual table.\n*/\nSQLITE_PRIVATE int sqlite3VtabCallDestroy(sqlite3 *db, int iDb, const char *zTab){\n  int rc = SQLITE_OK;\n  Table *pTab;\n\n  pTab = sqlite3FindTable(db, zTab, db->aDb[iDb].zDbSName);\n  if( pTab!=0 && ALWAYS(pTab->pVTable!=0) ){\n    VTable *p;\n    int (*xDestroy)(sqlite3_vtab *);\n    for(p=pTab->pVTable; p; p=p->pNext){\n      assert( p->pVtab );\n      if( p->pVtab->nRef>0 ){\n        return SQLITE_LOCKED;\n      }\n    }\n    p = vtabDisconnectAll(db, pTab);\n    xDestroy = p->pMod->pModule->xDestroy;\n    assert( xDestroy!=0 );  /* Checked before the virtual table is created */\n    rc = xDestroy(p->pVtab);\n    /* Remove the sqlite3_vtab* from the aVTrans[] array, if applicable */\n    if( rc==SQLITE_OK ){\n      assert( pTab->pVTable==p && p->pNext==0 );\n      p->pVtab = 0;\n      pTab->pVTable = 0;\n      sqlite3VtabUnlock(p);\n    }\n  }\n\n  return rc;\n}\n\n/*\n** This function invokes either the xRollback or xCommit method\n** of each of the virtual tables in the sqlite3.aVTrans array. The method\n** called is identified by the second argument, \"offset\", which is\n** the offset of the method to call in the sqlite3_module structure.\n**\n** The array is cleared after invoking the callbacks. \n*/\nstatic void callFinaliser(sqlite3 *db, int offset){\n  int i;\n  if( db->aVTrans ){\n    VTable **aVTrans = db->aVTrans;\n    db->aVTrans = 0;\n    for(i=0; i<db->nVTrans; i++){\n      VTable *pVTab = aVTrans[i];\n      sqlite3_vtab *p = pVTab->pVtab;\n      if( p ){\n        int (*x)(sqlite3_vtab *);\n        x = *(int (**)(sqlite3_vtab *))((char *)p->pModule + offset);\n        if( x ) x(p);\n      }\n      pVTab->iSavepoint = 0;\n      sqlite3VtabUnlock(pVTab);\n    }\n    sqlite3DbFree(db, aVTrans);\n    db->nVTrans = 0;\n  }\n}\n\n/*\n** Invoke the xSync method of all virtual tables in the sqlite3.aVTrans\n** array. Return the error code for the first error that occurs, or\n** SQLITE_OK if all xSync operations are successful.\n**\n** If an error message is available, leave it in p->zErrMsg.\n*/\nSQLITE_PRIVATE int sqlite3VtabSync(sqlite3 *db, Vdbe *p){\n  int i;\n  int rc = SQLITE_OK;\n  VTable **aVTrans = db->aVTrans;\n\n  db->aVTrans = 0;\n  for(i=0; rc==SQLITE_OK && i<db->nVTrans; i++){\n    int (*x)(sqlite3_vtab *);\n    sqlite3_vtab *pVtab = aVTrans[i]->pVtab;\n    if( pVtab && (x = pVtab->pModule->xSync)!=0 ){\n      rc = x(pVtab);\n      sqlite3VtabImportErrmsg(p, pVtab);\n    }\n  }\n  db->aVTrans = aVTrans;\n  return rc;\n}\n\n/*\n** Invoke the xRollback method of all virtual tables in the \n** sqlite3.aVTrans array. Then clear the array itself.\n*/\nSQLITE_PRIVATE int sqlite3VtabRollback(sqlite3 *db){\n  callFinaliser(db, offsetof(sqlite3_module,xRollback));\n  return SQLITE_OK;\n}\n\n/*\n** Invoke the xCommit method of all virtual tables in the \n** sqlite3.aVTrans array. Then clear the array itself.\n*/\nSQLITE_PRIVATE int sqlite3VtabCommit(sqlite3 *db){\n  callFinaliser(db, offsetof(sqlite3_module,xCommit));\n  return SQLITE_OK;\n}\n\n/*\n** If the virtual table pVtab supports the transaction interface\n** (xBegin/xRollback/xCommit and optionally xSync) and a transaction is\n** not currently open, invoke the xBegin method now.\n**\n** If the xBegin call is successful, place the sqlite3_vtab pointer\n** in the sqlite3.aVTrans array.\n*/\nSQLITE_PRIVATE int sqlite3VtabBegin(sqlite3 *db, VTable *pVTab){\n  int rc = SQLITE_OK;\n  const sqlite3_module *pModule;\n\n  /* Special case: If db->aVTrans is NULL and db->nVTrans is greater\n  ** than zero, then this function is being called from within a\n  ** virtual module xSync() callback. It is illegal to write to \n  ** virtual module tables in this case, so return SQLITE_LOCKED.\n  */\n  if( sqlite3VtabInSync(db) ){\n    return SQLITE_LOCKED;\n  }\n  if( !pVTab ){\n    return SQLITE_OK;\n  } \n  pModule = pVTab->pVtab->pModule;\n\n  if( pModule->xBegin ){\n    int i;\n\n    /* If pVtab is already in the aVTrans array, return early */\n    for(i=0; i<db->nVTrans; i++){\n      if( db->aVTrans[i]==pVTab ){\n        return SQLITE_OK;\n      }\n    }\n\n    /* Invoke the xBegin method. If successful, add the vtab to the \n    ** sqlite3.aVTrans[] array. */\n    rc = growVTrans(db);\n    if( rc==SQLITE_OK ){\n      rc = pModule->xBegin(pVTab->pVtab);\n      if( rc==SQLITE_OK ){\n        int iSvpt = db->nStatement + db->nSavepoint;\n        addToVTrans(db, pVTab);\n        if( iSvpt && pModule->xSavepoint ){\n          pVTab->iSavepoint = iSvpt;\n          rc = pModule->xSavepoint(pVTab->pVtab, iSvpt-1);\n        }\n      }\n    }\n  }\n  return rc;\n}\n\n/*\n** Invoke either the xSavepoint, xRollbackTo or xRelease method of all\n** virtual tables that currently have an open transaction. Pass iSavepoint\n** as the second argument to the virtual table method invoked.\n**\n** If op is SAVEPOINT_BEGIN, the xSavepoint method is invoked. If it is\n** SAVEPOINT_ROLLBACK, the xRollbackTo method. Otherwise, if op is \n** SAVEPOINT_RELEASE, then the xRelease method of each virtual table with\n** an open transaction is invoked.\n**\n** If any virtual table method returns an error code other than SQLITE_OK, \n** processing is abandoned and the error returned to the caller of this\n** function immediately. If all calls to virtual table methods are successful,\n** SQLITE_OK is returned.\n*/\nSQLITE_PRIVATE int sqlite3VtabSavepoint(sqlite3 *db, int op, int iSavepoint){\n  int rc = SQLITE_OK;\n\n  assert( op==SAVEPOINT_RELEASE||op==SAVEPOINT_ROLLBACK||op==SAVEPOINT_BEGIN );\n  assert( iSavepoint>=-1 );\n  if( db->aVTrans ){\n    int i;\n    for(i=0; rc==SQLITE_OK && i<db->nVTrans; i++){\n      VTable *pVTab = db->aVTrans[i];\n      const sqlite3_module *pMod = pVTab->pMod->pModule;\n      if( pVTab->pVtab && pMod->iVersion>=2 ){\n        int (*xMethod)(sqlite3_vtab *, int);\n        sqlite3VtabLock(pVTab);\n        switch( op ){\n          case SAVEPOINT_BEGIN:\n            xMethod = pMod->xSavepoint;\n            pVTab->iSavepoint = iSavepoint+1;\n            break;\n          case SAVEPOINT_ROLLBACK:\n            xMethod = pMod->xRollbackTo;\n            break;\n          default:\n            xMethod = pMod->xRelease;\n            break;\n        }\n        if( xMethod && pVTab->iSavepoint>iSavepoint ){\n          rc = xMethod(pVTab->pVtab, iSavepoint);\n        }\n        sqlite3VtabUnlock(pVTab);\n      }\n    }\n  }\n  return rc;\n}\n\n/*\n** The first parameter (pDef) is a function implementation.  The\n** second parameter (pExpr) is the first argument to this function.\n** If pExpr is a column in a virtual table, then let the virtual\n** table implementation have an opportunity to overload the function.\n**\n** This routine is used to allow virtual table implementations to\n** overload MATCH, LIKE, GLOB, and REGEXP operators.\n**\n** Return either the pDef argument (indicating no change) or a \n** new FuncDef structure that is marked as ephemeral using the\n** SQLITE_FUNC_EPHEM flag.\n*/\nSQLITE_PRIVATE FuncDef *sqlite3VtabOverloadFunction(\n  sqlite3 *db,    /* Database connection for reporting malloc problems */\n  FuncDef *pDef,  /* Function to possibly overload */\n  int nArg,       /* Number of arguments to the function */\n  Expr *pExpr     /* First argument to the function */\n){\n  Table *pTab;\n  sqlite3_vtab *pVtab;\n  sqlite3_module *pMod;\n  void (*xSFunc)(sqlite3_context*,int,sqlite3_value**) = 0;\n  void *pArg = 0;\n  FuncDef *pNew;\n  int rc = 0;\n\n  /* Check to see the left operand is a column in a virtual table */\n  if( NEVER(pExpr==0) ) return pDef;\n  if( pExpr->op!=TK_COLUMN ) return pDef;\n  pTab = pExpr->y.pTab;\n  if( pTab==0 ) return pDef;\n  if( !IsVirtual(pTab) ) return pDef;\n  pVtab = sqlite3GetVTable(db, pTab)->pVtab;\n  assert( pVtab!=0 );\n  assert( pVtab->pModule!=0 );\n  pMod = (sqlite3_module *)pVtab->pModule;\n  if( pMod->xFindFunction==0 ) return pDef;\n \n  /* Call the xFindFunction method on the virtual table implementation\n  ** to see if the implementation wants to overload this function.\n  **\n  ** Though undocumented, we have historically always invoked xFindFunction\n  ** with an all lower-case function name.  Continue in this tradition to\n  ** avoid any chance of an incompatibility.\n  */\n#ifdef SQLITE_DEBUG\n  {\n    int i;\n    for(i=0; pDef->zName[i]; i++){\n      unsigned char x = (unsigned char)pDef->zName[i];\n      assert( x==sqlite3UpperToLower[x] );\n    }\n  }\n#endif\n  rc = pMod->xFindFunction(pVtab, nArg, pDef->zName, &xSFunc, &pArg);\n  if( rc==0 ){\n    return pDef;\n  }\n\n  /* Create a new ephemeral function definition for the overloaded\n  ** function */\n  pNew = sqlite3DbMallocZero(db, sizeof(*pNew)\n                             + sqlite3Strlen30(pDef->zName) + 1);\n  if( pNew==0 ){\n    return pDef;\n  }\n  *pNew = *pDef;\n  pNew->zName = (const char*)&pNew[1];\n  memcpy((char*)&pNew[1], pDef->zName, sqlite3Strlen30(pDef->zName)+1);\n  pNew->xSFunc = xSFunc;\n  pNew->pUserData = pArg;\n  pNew->funcFlags |= SQLITE_FUNC_EPHEM;\n  return pNew;\n}\n\n/*\n** Make sure virtual table pTab is contained in the pParse->apVirtualLock[]\n** array so that an OP_VBegin will get generated for it.  Add pTab to the\n** array if it is missing.  If pTab is already in the array, this routine\n** is a no-op.\n*/\nSQLITE_PRIVATE void sqlite3VtabMakeWritable(Parse *pParse, Table *pTab){\n  Parse *pToplevel = sqlite3ParseToplevel(pParse);\n  int i, n;\n  Table **apVtabLock;\n\n  assert( IsVirtual(pTab) );\n  for(i=0; i<pToplevel->nVtabLock; i++){\n    if( pTab==pToplevel->apVtabLock[i] ) return;\n  }\n  n = (pToplevel->nVtabLock+1)*sizeof(pToplevel->apVtabLock[0]);\n  apVtabLock = sqlite3_realloc64(pToplevel->apVtabLock, n);\n  if( apVtabLock ){\n    pToplevel->apVtabLock = apVtabLock;\n    pToplevel->apVtabLock[pToplevel->nVtabLock++] = pTab;\n  }else{\n    sqlite3OomFault(pToplevel->db);\n  }\n}\n\n/*\n** Check to see if virtual table module pMod can be have an eponymous\n** virtual table instance.  If it can, create one if one does not already\n** exist. Return non-zero if the eponymous virtual table instance exists\n** when this routine returns, and return zero if it does not exist.\n**\n** An eponymous virtual table instance is one that is named after its\n** module, and more importantly, does not require a CREATE VIRTUAL TABLE\n** statement in order to come into existance.  Eponymous virtual table\n** instances always exist.  They cannot be DROP-ed.\n**\n** Any virtual table module for which xConnect and xCreate are the same\n** method can have an eponymous virtual table instance.\n*/\nSQLITE_PRIVATE int sqlite3VtabEponymousTableInit(Parse *pParse, Module *pMod){\n  const sqlite3_module *pModule = pMod->pModule;\n  Table *pTab;\n  char *zErr = 0;\n  int rc;\n  sqlite3 *db = pParse->db;\n  if( pMod->pEpoTab ) return 1;\n  if( pModule->xCreate!=0 && pModule->xCreate!=pModule->xConnect ) return 0;\n  pTab = sqlite3DbMallocZero(db, sizeof(Table));\n  if( pTab==0 ) return 0;\n  pTab->zName = sqlite3DbStrDup(db, pMod->zName);\n  if( pTab->zName==0 ){\n    sqlite3DbFree(db, pTab);\n    return 0;\n  }\n  pMod->pEpoTab = pTab;\n  pTab->nTabRef = 1;\n  pTab->pSchema = db->aDb[0].pSchema;\n  assert( pTab->nModuleArg==0 );\n  pTab->iPKey = -1;\n  addModuleArgument(db, pTab, sqlite3DbStrDup(db, pTab->zName));\n  addModuleArgument(db, pTab, 0);\n  addModuleArgument(db, pTab, sqlite3DbStrDup(db, pTab->zName));\n  rc = vtabCallConstructor(db, pTab, pMod, pModule->xConnect, &zErr);\n  if( rc ){\n    sqlite3ErrorMsg(pParse, \"%s\", zErr);\n    sqlite3DbFree(db, zErr);\n    sqlite3VtabEponymousTableClear(db, pMod);\n    return 0;\n  }\n  return 1;\n}\n\n/*\n** Erase the eponymous virtual table instance associated with\n** virtual table module pMod, if it exists.\n*/\nSQLITE_PRIVATE void sqlite3VtabEponymousTableClear(sqlite3 *db, Module *pMod){\n  Table *pTab = pMod->pEpoTab;\n  if( pTab!=0 ){\n    /* Mark the table as Ephemeral prior to deleting it, so that the\n    ** sqlite3DeleteTable() routine will know that it is not stored in \n    ** the schema. */\n    pTab->tabFlags |= TF_Ephemeral;\n    sqlite3DeleteTable(db, pTab);\n    pMod->pEpoTab = 0;\n  }\n}\n\n/*\n** Return the ON CONFLICT resolution mode in effect for the virtual\n** table update operation currently in progress.\n**\n** The results of this routine are undefined unless it is called from\n** within an xUpdate method.\n*/\nSQLITE_API int sqlite3_vtab_on_conflict(sqlite3 *db){\n  static const unsigned char aMap[] = { \n    SQLITE_ROLLBACK, SQLITE_ABORT, SQLITE_FAIL, SQLITE_IGNORE, SQLITE_REPLACE \n  };\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( !sqlite3SafetyCheckOk(db) ) return SQLITE_MISUSE_BKPT;\n#endif\n  assert( OE_Rollback==1 && OE_Abort==2 && OE_Fail==3 );\n  assert( OE_Ignore==4 && OE_Replace==5 );\n  assert( db->vtabOnConflict>=1 && db->vtabOnConflict<=5 );\n  return (int)aMap[db->vtabOnConflict-1];\n}\n\n/*\n** Call from within the xCreate() or xConnect() methods to provide \n** the SQLite core with additional information about the behavior\n** of the virtual table being implemented.\n*/\nSQLITE_API int sqlite3_vtab_config(sqlite3 *db, int op, ...){\n  va_list ap;\n  int rc = SQLITE_OK;\n\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( !sqlite3SafetyCheckOk(db) ) return SQLITE_MISUSE_BKPT;\n#endif\n  sqlite3_mutex_enter(db->mutex);\n  va_start(ap, op);\n  switch( op ){\n    case SQLITE_VTAB_CONSTRAINT_SUPPORT: {\n      VtabCtx *p = db->pVtabCtx;\n      if( !p ){\n        rc = SQLITE_MISUSE_BKPT;\n      }else{\n        assert( p->pTab==0 || IsVirtual(p->pTab) );\n        p->pVTable->bConstraint = (u8)va_arg(ap, int);\n      }\n      break;\n    }\n    default:\n      rc = SQLITE_MISUSE_BKPT;\n      break;\n  }\n  va_end(ap);\n\n  if( rc!=SQLITE_OK ) sqlite3Error(db, rc);\n  sqlite3_mutex_leave(db->mutex);\n  return rc;\n}\n\n#endif /* SQLITE_OMIT_VIRTUALTABLE */\n\n/************** End of vtab.c ************************************************/\n/************** Begin file wherecode.c ***************************************/\n/*\n** 2015-06-06\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This module contains C code that generates VDBE code used to process\n** the WHERE clause of SQL statements.\n**\n** This file was split off from where.c on 2015-06-06 in order to reduce the\n** size of where.c and make it easier to edit.  This file contains the routines\n** that actually generate the bulk of the WHERE loop code.  The original where.c\n** file retains the code that does query planning and analysis.\n*/\n/* #include \"sqliteInt.h\" */\n/************** Include whereInt.h in the middle of wherecode.c **************/\n/************** Begin file whereInt.h ****************************************/\n/*\n** 2013-11-12\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n**\n** This file contains structure and macro definitions for the query\n** planner logic in \"where.c\".  These definitions are broken out into\n** a separate source file for easier editing.\n*/\n\n/*\n** Trace output macros\n*/\n#if defined(SQLITE_TEST) || defined(SQLITE_DEBUG)\n/***/ extern int sqlite3WhereTrace;\n#endif\n#if defined(SQLITE_DEBUG) \\\n    && (defined(SQLITE_TEST) || defined(SQLITE_ENABLE_WHERETRACE))\n# define WHERETRACE(K,X)  if(sqlite3WhereTrace&(K)) sqlite3DebugPrintf X\n# define WHERETRACE_ENABLED 1\n#else\n# define WHERETRACE(K,X)\n#endif\n\n/* Forward references\n*/\ntypedef struct WhereClause WhereClause;\ntypedef struct WhereMaskSet WhereMaskSet;\ntypedef struct WhereOrInfo WhereOrInfo;\ntypedef struct WhereAndInfo WhereAndInfo;\ntypedef struct WhereLevel WhereLevel;\ntypedef struct WhereLoop WhereLoop;\ntypedef struct WherePath WherePath;\ntypedef struct WhereTerm WhereTerm;\ntypedef struct WhereLoopBuilder WhereLoopBuilder;\ntypedef struct WhereScan WhereScan;\ntypedef struct WhereOrCost WhereOrCost;\ntypedef struct WhereOrSet WhereOrSet;\n\n/*\n** This object contains information needed to implement a single nested\n** loop in WHERE clause.\n**\n** Contrast this object with WhereLoop.  This object describes the\n** implementation of the loop.  WhereLoop describes the algorithm.\n** This object contains a pointer to the WhereLoop algorithm as one of\n** its elements.\n**\n** The WhereInfo object contains a single instance of this object for\n** each term in the FROM clause (which is to say, for each of the\n** nested loops as implemented).  The order of WhereLevel objects determines\n** the loop nested order, with WhereInfo.a[0] being the outer loop and\n** WhereInfo.a[WhereInfo.nLevel-1] being the inner loop.\n*/\nstruct WhereLevel {\n  int iLeftJoin;        /* Memory cell used to implement LEFT OUTER JOIN */\n  int iTabCur;          /* The VDBE cursor used to access the table */\n  int iIdxCur;          /* The VDBE cursor used to access pIdx */\n  int addrBrk;          /* Jump here to break out of the loop */\n  int addrNxt;          /* Jump here to start the next IN combination */\n  int addrSkip;         /* Jump here for next iteration of skip-scan */\n  int addrCont;         /* Jump here to continue with the next loop cycle */\n  int addrFirst;        /* First instruction of interior of the loop */\n  int addrBody;         /* Beginning of the body of this loop */\n#ifndef SQLITE_LIKE_DOESNT_MATCH_BLOBS\n  u32 iLikeRepCntr;     /* LIKE range processing counter register (times 2) */\n  int addrLikeRep;      /* LIKE range processing address */\n#endif\n  u8 iFrom;             /* Which entry in the FROM clause */\n  u8 op, p3, p5;        /* Opcode, P3 & P5 of the opcode that ends the loop */\n  int p1, p2;           /* Operands of the opcode used to ends the loop */\n  union {               /* Information that depends on pWLoop->wsFlags */\n    struct {\n      int nIn;              /* Number of entries in aInLoop[] */\n      struct InLoop {\n        int iCur;              /* The VDBE cursor used by this IN operator */\n        int addrInTop;         /* Top of the IN loop */\n        int iBase;             /* Base register of multi-key index record */\n        int nPrefix;           /* Number of prior entires in the key */\n        u8 eEndLoopOp;         /* IN Loop terminator. OP_Next or OP_Prev */\n      } *aInLoop;           /* Information about each nested IN operator */\n    } in;                 /* Used when pWLoop->wsFlags&WHERE_IN_ABLE */\n    Index *pCovidx;       /* Possible covering index for WHERE_MULTI_OR */\n  } u;\n  struct WhereLoop *pWLoop;  /* The selected WhereLoop object */\n  Bitmask notReady;          /* FROM entries not usable at this level */\n#ifdef SQLITE_ENABLE_STMT_SCANSTATUS\n  int addrVisit;        /* Address at which row is visited */\n#endif\n};\n\n/*\n** Each instance of this object represents an algorithm for evaluating one\n** term of a join.  Every term of the FROM clause will have at least\n** one corresponding WhereLoop object (unless INDEXED BY constraints\n** prevent a query solution - which is an error) and many terms of the\n** FROM clause will have multiple WhereLoop objects, each describing a\n** potential way of implementing that FROM-clause term, together with\n** dependencies and cost estimates for using the chosen algorithm.\n**\n** Query planning consists of building up a collection of these WhereLoop\n** objects, then computing a particular sequence of WhereLoop objects, with\n** one WhereLoop object per FROM clause term, that satisfy all dependencies\n** and that minimize the overall cost.\n*/\nstruct WhereLoop {\n  Bitmask prereq;       /* Bitmask of other loops that must run first */\n  Bitmask maskSelf;     /* Bitmask identifying table iTab */\n#ifdef SQLITE_DEBUG\n  char cId;             /* Symbolic ID of this loop for debugging use */\n#endif\n  u8 iTab;              /* Position in FROM clause of table for this loop */\n  u8 iSortIdx;          /* Sorting index number.  0==None */\n  LogEst rSetup;        /* One-time setup cost (ex: create transient index) */\n  LogEst rRun;          /* Cost of running each loop */\n  LogEst nOut;          /* Estimated number of output rows */\n  union {\n    struct {               /* Information for internal btree tables */\n      u16 nEq;               /* Number of equality constraints */\n      u16 nBtm;              /* Size of BTM vector */\n      u16 nTop;              /* Size of TOP vector */\n      u16 nIdxCol;           /* Index column used for ORDER BY */\n      Index *pIndex;         /* Index used, or NULL */\n    } btree;\n    struct {               /* Information for virtual tables */\n      int idxNum;            /* Index number */\n      u8 needFree;           /* True if sqlite3_free(idxStr) is needed */\n      i8 isOrdered;          /* True if satisfies ORDER BY */\n      u16 omitMask;          /* Terms that may be omitted */\n      char *idxStr;          /* Index identifier string */\n    } vtab;\n  } u;\n  u32 wsFlags;          /* WHERE_* flags describing the plan */\n  u16 nLTerm;           /* Number of entries in aLTerm[] */\n  u16 nSkip;            /* Number of NULL aLTerm[] entries */\n  /**** whereLoopXfer() copies fields above ***********************/\n# define WHERE_LOOP_XFER_SZ offsetof(WhereLoop,nLSlot)\n  u16 nLSlot;           /* Number of slots allocated for aLTerm[] */\n  WhereTerm **aLTerm;   /* WhereTerms used */\n  WhereLoop *pNextLoop; /* Next WhereLoop object in the WhereClause */\n  WhereTerm *aLTermSpace[3];  /* Initial aLTerm[] space */\n};\n\n/* This object holds the prerequisites and the cost of running a\n** subquery on one operand of an OR operator in the WHERE clause.\n** See WhereOrSet for additional information \n*/\nstruct WhereOrCost {\n  Bitmask prereq;     /* Prerequisites */\n  LogEst rRun;        /* Cost of running this subquery */\n  LogEst nOut;        /* Number of outputs for this subquery */\n};\n\n/* The WhereOrSet object holds a set of possible WhereOrCosts that\n** correspond to the subquery(s) of OR-clause processing.  Only the\n** best N_OR_COST elements are retained.\n*/\n#define N_OR_COST 3\nstruct WhereOrSet {\n  u16 n;                      /* Number of valid a[] entries */\n  WhereOrCost a[N_OR_COST];   /* Set of best costs */\n};\n\n/*\n** Each instance of this object holds a sequence of WhereLoop objects\n** that implement some or all of a query plan.\n**\n** Think of each WhereLoop object as a node in a graph with arcs\n** showing dependencies and costs for travelling between nodes.  (That is\n** not a completely accurate description because WhereLoop costs are a\n** vector, not a scalar, and because dependencies are many-to-one, not\n** one-to-one as are graph nodes.  But it is a useful visualization aid.)\n** Then a WherePath object is a path through the graph that visits some\n** or all of the WhereLoop objects once.\n**\n** The \"solver\" works by creating the N best WherePath objects of length\n** 1.  Then using those as a basis to compute the N best WherePath objects\n** of length 2.  And so forth until the length of WherePaths equals the\n** number of nodes in the FROM clause.  The best (lowest cost) WherePath\n** at the end is the chosen query plan.\n*/\nstruct WherePath {\n  Bitmask maskLoop;     /* Bitmask of all WhereLoop objects in this path */\n  Bitmask revLoop;      /* aLoop[]s that should be reversed for ORDER BY */\n  LogEst nRow;          /* Estimated number of rows generated by this path */\n  LogEst rCost;         /* Total cost of this path */\n  LogEst rUnsorted;     /* Total cost of this path ignoring sorting costs */\n  i8 isOrdered;         /* No. of ORDER BY terms satisfied. -1 for unknown */\n  WhereLoop **aLoop;    /* Array of WhereLoop objects implementing this path */\n};\n\n/*\n** The query generator uses an array of instances of this structure to\n** help it analyze the subexpressions of the WHERE clause.  Each WHERE\n** clause subexpression is separated from the others by AND operators,\n** usually, or sometimes subexpressions separated by OR.\n**\n** All WhereTerms are collected into a single WhereClause structure.  \n** The following identity holds:\n**\n**        WhereTerm.pWC->a[WhereTerm.idx] == WhereTerm\n**\n** When a term is of the form:\n**\n**              X <op> <expr>\n**\n** where X is a column name and <op> is one of certain operators,\n** then WhereTerm.leftCursor and WhereTerm.u.leftColumn record the\n** cursor number and column number for X.  WhereTerm.eOperator records\n** the <op> using a bitmask encoding defined by WO_xxx below.  The\n** use of a bitmask encoding for the operator allows us to search\n** quickly for terms that match any of several different operators.\n**\n** A WhereTerm might also be two or more subterms connected by OR:\n**\n**         (t1.X <op> <expr>) OR (t1.Y <op> <expr>) OR ....\n**\n** In this second case, wtFlag has the TERM_ORINFO bit set and eOperator==WO_OR\n** and the WhereTerm.u.pOrInfo field points to auxiliary information that\n** is collected about the OR clause.\n**\n** If a term in the WHERE clause does not match either of the two previous\n** categories, then eOperator==0.  The WhereTerm.pExpr field is still set\n** to the original subexpression content and wtFlags is set up appropriately\n** but no other fields in the WhereTerm object are meaningful.\n**\n** When eOperator!=0, prereqRight and prereqAll record sets of cursor numbers,\n** but they do so indirectly.  A single WhereMaskSet structure translates\n** cursor number into bits and the translated bit is stored in the prereq\n** fields.  The translation is used in order to maximize the number of\n** bits that will fit in a Bitmask.  The VDBE cursor numbers might be\n** spread out over the non-negative integers.  For example, the cursor\n** numbers might be 3, 8, 9, 10, 20, 23, 41, and 45.  The WhereMaskSet\n** translates these sparse cursor numbers into consecutive integers\n** beginning with 0 in order to make the best possible use of the available\n** bits in the Bitmask.  So, in the example above, the cursor numbers\n** would be mapped into integers 0 through 7.\n**\n** The number of terms in a join is limited by the number of bits\n** in prereqRight and prereqAll.  The default is 64 bits, hence SQLite\n** is only able to process joins with 64 or fewer tables.\n*/\nstruct WhereTerm {\n  Expr *pExpr;            /* Pointer to the subexpression that is this term */\n  WhereClause *pWC;       /* The clause this term is part of */\n  LogEst truthProb;       /* Probability of truth for this expression */\n  u16 wtFlags;            /* TERM_xxx bit flags.  See below */\n  u16 eOperator;          /* A WO_xx value describing <op> */\n  u8 nChild;              /* Number of children that must disable us */\n  u8 eMatchOp;            /* Op for vtab MATCH/LIKE/GLOB/REGEXP terms */\n  int iParent;            /* Disable pWC->a[iParent] when this term disabled */\n  int leftCursor;         /* Cursor number of X in \"X <op> <expr>\" */\n  int iField;             /* Field in (?,?,?) IN (SELECT...) vector */\n  union {\n    int leftColumn;         /* Column number of X in \"X <op> <expr>\" */\n    WhereOrInfo *pOrInfo;   /* Extra information if (eOperator & WO_OR)!=0 */\n    WhereAndInfo *pAndInfo; /* Extra information if (eOperator& WO_AND)!=0 */\n  } u;\n  Bitmask prereqRight;    /* Bitmask of tables used by pExpr->pRight */\n  Bitmask prereqAll;      /* Bitmask of tables referenced by pExpr */\n};\n\n/*\n** Allowed values of WhereTerm.wtFlags\n*/\n#define TERM_DYNAMIC    0x01   /* Need to call sqlite3ExprDelete(db, pExpr) */\n#define TERM_VIRTUAL    0x02   /* Added by the optimizer.  Do not code */\n#define TERM_CODED      0x04   /* This term is already coded */\n#define TERM_COPIED     0x08   /* Has a child */\n#define TERM_ORINFO     0x10   /* Need to free the WhereTerm.u.pOrInfo object */\n#define TERM_ANDINFO    0x20   /* Need to free the WhereTerm.u.pAndInfo obj */\n#define TERM_OR_OK      0x40   /* Used during OR-clause processing */\n#ifdef SQLITE_ENABLE_STAT3_OR_STAT4\n#  define TERM_VNULL    0x80   /* Manufactured x>NULL or x<=NULL term */\n#else\n#  define TERM_VNULL    0x00   /* Disabled if not using stat3 */\n#endif\n#define TERM_LIKEOPT    0x100  /* Virtual terms from the LIKE optimization */\n#define TERM_LIKECOND   0x200  /* Conditionally this LIKE operator term */\n#define TERM_LIKE       0x400  /* The original LIKE operator */\n#define TERM_IS         0x800  /* Term.pExpr is an IS operator */\n#define TERM_VARSELECT  0x1000 /* Term.pExpr contains a correlated sub-query */\n\n/*\n** An instance of the WhereScan object is used as an iterator for locating\n** terms in the WHERE clause that are useful to the query planner.\n*/\nstruct WhereScan {\n  WhereClause *pOrigWC;      /* Original, innermost WhereClause */\n  WhereClause *pWC;          /* WhereClause currently being scanned */\n  const char *zCollName;     /* Required collating sequence, if not NULL */\n  Expr *pIdxExpr;            /* Search for this index expression */\n  char idxaff;               /* Must match this affinity, if zCollName!=NULL */\n  unsigned char nEquiv;      /* Number of entries in aEquiv[] */\n  unsigned char iEquiv;      /* Next unused slot in aEquiv[] */\n  u32 opMask;                /* Acceptable operators */\n  int k;                     /* Resume scanning at this->pWC->a[this->k] */\n  int aiCur[11];             /* Cursors in the equivalence class */\n  i16 aiColumn[11];          /* Corresponding column number in the eq-class */\n};\n\n/*\n** An instance of the following structure holds all information about a\n** WHERE clause.  Mostly this is a container for one or more WhereTerms.\n**\n** Explanation of pOuter:  For a WHERE clause of the form\n**\n**           a AND ((b AND c) OR (d AND e)) AND f\n**\n** There are separate WhereClause objects for the whole clause and for\n** the subclauses \"(b AND c)\" and \"(d AND e)\".  The pOuter field of the\n** subclauses points to the WhereClause object for the whole clause.\n*/\nstruct WhereClause {\n  WhereInfo *pWInfo;       /* WHERE clause processing context */\n  WhereClause *pOuter;     /* Outer conjunction */\n  u8 op;                   /* Split operator.  TK_AND or TK_OR */\n  u8 hasOr;                /* True if any a[].eOperator is WO_OR */\n  int nTerm;               /* Number of terms */\n  int nSlot;               /* Number of entries in a[] */\n  WhereTerm *a;            /* Each a[] describes a term of the WHERE cluase */\n#if defined(SQLITE_SMALL_STACK)\n  WhereTerm aStatic[1];    /* Initial static space for a[] */\n#else\n  WhereTerm aStatic[8];    /* Initial static space for a[] */\n#endif\n};\n\n/*\n** A WhereTerm with eOperator==WO_OR has its u.pOrInfo pointer set to\n** a dynamically allocated instance of the following structure.\n*/\nstruct WhereOrInfo {\n  WhereClause wc;          /* Decomposition into subterms */\n  Bitmask indexable;       /* Bitmask of all indexable tables in the clause */\n};\n\n/*\n** A WhereTerm with eOperator==WO_AND has its u.pAndInfo pointer set to\n** a dynamically allocated instance of the following structure.\n*/\nstruct WhereAndInfo {\n  WhereClause wc;          /* The subexpression broken out */\n};\n\n/*\n** An instance of the following structure keeps track of a mapping\n** between VDBE cursor numbers and bits of the bitmasks in WhereTerm.\n**\n** The VDBE cursor numbers are small integers contained in \n** SrcList_item.iCursor and Expr.iTable fields.  For any given WHERE \n** clause, the cursor numbers might not begin with 0 and they might\n** contain gaps in the numbering sequence.  But we want to make maximum\n** use of the bits in our bitmasks.  This structure provides a mapping\n** from the sparse cursor numbers into consecutive integers beginning\n** with 0.\n**\n** If WhereMaskSet.ix[A]==B it means that The A-th bit of a Bitmask\n** corresponds VDBE cursor number B.  The A-th bit of a bitmask is 1<<A.\n**\n** For example, if the WHERE clause expression used these VDBE\n** cursors:  4, 5, 8, 29, 57, 73.  Then the  WhereMaskSet structure\n** would map those cursor numbers into bits 0 through 5.\n**\n** Note that the mapping is not necessarily ordered.  In the example\n** above, the mapping might go like this:  4->3, 5->1, 8->2, 29->0,\n** 57->5, 73->4.  Or one of 719 other combinations might be used. It\n** does not really matter.  What is important is that sparse cursor\n** numbers all get mapped into bit numbers that begin with 0 and contain\n** no gaps.\n*/\nstruct WhereMaskSet {\n  int bVarSelect;               /* Used by sqlite3WhereExprUsage() */\n  int n;                        /* Number of assigned cursor values */\n  int ix[BMS];                  /* Cursor assigned to each bit */\n};\n\n/*\n** Initialize a WhereMaskSet object\n*/\n#define initMaskSet(P)  (P)->n=0\n\n/*\n** This object is a convenience wrapper holding all information needed\n** to construct WhereLoop objects for a particular query.\n*/\nstruct WhereLoopBuilder {\n  WhereInfo *pWInfo;        /* Information about this WHERE */\n  WhereClause *pWC;         /* WHERE clause terms */\n  ExprList *pOrderBy;       /* ORDER BY clause */\n  WhereLoop *pNew;          /* Template WhereLoop */\n  WhereOrSet *pOrSet;       /* Record best loops here, if not NULL */\n#ifdef SQLITE_ENABLE_STAT3_OR_STAT4\n  UnpackedRecord *pRec;     /* Probe for stat4 (if required) */\n  int nRecValid;            /* Number of valid fields currently in pRec */\n#endif\n  unsigned int bldFlags;    /* SQLITE_BLDF_* flags */\n  unsigned int iPlanLimit;  /* Search limiter */\n};\n\n/* Allowed values for WhereLoopBuider.bldFlags */\n#define SQLITE_BLDF_INDEXED  0x0001   /* An index is used */\n#define SQLITE_BLDF_UNIQUE   0x0002   /* All keys of a UNIQUE index used */\n\n/* The WhereLoopBuilder.iPlanLimit is used to limit the number of\n** index+constraint combinations the query planner will consider for a\n** particular query.  If this parameter is unlimited, then certain\n** pathological queries can spend excess time in the sqlite3WhereBegin()\n** routine.  The limit is high enough that is should not impact real-world\n** queries.\n**\n** SQLITE_QUERY_PLANNER_LIMIT is the baseline limit.  The limit is\n** increased by SQLITE_QUERY_PLANNER_LIMIT_INCR before each term of the FROM\n** clause is processed, so that every table in a join is guaranteed to be\n** able to propose a some index+constraint combinations even if the initial\n** baseline limit was exhausted by prior tables of the join.\n*/\n#ifndef SQLITE_QUERY_PLANNER_LIMIT\n# define SQLITE_QUERY_PLANNER_LIMIT 20000\n#endif\n#ifndef SQLITE_QUERY_PLANNER_LIMIT_INCR\n# define SQLITE_QUERY_PLANNER_LIMIT_INCR 1000\n#endif\n\n/*\n** The WHERE clause processing routine has two halves.  The\n** first part does the start of the WHERE loop and the second\n** half does the tail of the WHERE loop.  An instance of\n** this structure is returned by the first half and passed\n** into the second half to give some continuity.\n**\n** An instance of this object holds the complete state of the query\n** planner.\n*/\nstruct WhereInfo {\n  Parse *pParse;            /* Parsing and code generating context */\n  SrcList *pTabList;        /* List of tables in the join */\n  ExprList *pOrderBy;       /* The ORDER BY clause or NULL */\n  ExprList *pResultSet;     /* Result set of the query */\n  Expr *pWhere;             /* The complete WHERE clause */\n  LogEst iLimit;            /* LIMIT if wctrlFlags has WHERE_USE_LIMIT */\n  int aiCurOnePass[2];      /* OP_OpenWrite cursors for the ONEPASS opt */\n  int iContinue;            /* Jump here to continue with next record */\n  int iBreak;               /* Jump here to break out of the loop */\n  int savedNQueryLoop;      /* pParse->nQueryLoop outside the WHERE loop */\n  u16 wctrlFlags;           /* Flags originally passed to sqlite3WhereBegin() */\n  u8 nLevel;                /* Number of nested loop */\n  i8 nOBSat;                /* Number of ORDER BY terms satisfied by indices */\n  u8 sorted;                /* True if really sorted (not just grouped) */\n  u8 eOnePass;              /* ONEPASS_OFF, or _SINGLE, or _MULTI */\n  u8 untestedTerms;         /* Not all WHERE terms resolved by outer loop */\n  u8 eDistinct;             /* One of the WHERE_DISTINCT_* values */\n  u8 bOrderedInnerLoop;     /* True if only the inner-most loop is ordered */\n  int iTop;                 /* The very beginning of the WHERE loop */\n  WhereLoop *pLoops;        /* List of all WhereLoop objects */\n  Bitmask revMask;          /* Mask of ORDER BY terms that need reversing */\n  LogEst nRowOut;           /* Estimated number of output rows */\n  WhereClause sWC;          /* Decomposition of the WHERE clause */\n  WhereMaskSet sMaskSet;    /* Map cursor numbers to bitmasks */\n  WhereLevel a[1];          /* Information about each nest loop in WHERE */\n};\n\n/*\n** Private interfaces - callable only by other where.c routines.\n**\n** where.c:\n*/\nSQLITE_PRIVATE Bitmask sqlite3WhereGetMask(WhereMaskSet*,int);\n#ifdef WHERETRACE_ENABLED\nSQLITE_PRIVATE void sqlite3WhereClausePrint(WhereClause *pWC);\n#endif\nSQLITE_PRIVATE WhereTerm *sqlite3WhereFindTerm(\n  WhereClause *pWC,     /* The WHERE clause to be searched */\n  int iCur,             /* Cursor number of LHS */\n  int iColumn,          /* Column number of LHS */\n  Bitmask notReady,     /* RHS must not overlap with this mask */\n  u32 op,               /* Mask of WO_xx values describing operator */\n  Index *pIdx           /* Must be compatible with this index, if not NULL */\n);\n\n/* wherecode.c: */\n#ifndef SQLITE_OMIT_EXPLAIN\nSQLITE_PRIVATE int sqlite3WhereExplainOneScan(\n  Parse *pParse,                  /* Parse context */\n  SrcList *pTabList,              /* Table list this loop refers to */\n  WhereLevel *pLevel,             /* Scan to write OP_Explain opcode for */\n  u16 wctrlFlags                  /* Flags passed to sqlite3WhereBegin() */\n);\n#else\n# define sqlite3WhereExplainOneScan(u,v,w,x) 0\n#endif /* SQLITE_OMIT_EXPLAIN */\n#ifdef SQLITE_ENABLE_STMT_SCANSTATUS\nSQLITE_PRIVATE void sqlite3WhereAddScanStatus(\n  Vdbe *v,                        /* Vdbe to add scanstatus entry to */\n  SrcList *pSrclist,              /* FROM clause pLvl reads data from */\n  WhereLevel *pLvl,               /* Level to add scanstatus() entry for */\n  int addrExplain                 /* Address of OP_Explain (or 0) */\n);\n#else\n# define sqlite3WhereAddScanStatus(a, b, c, d) ((void)d)\n#endif\nSQLITE_PRIVATE Bitmask sqlite3WhereCodeOneLoopStart(\n  Parse *pParse,       /* Parsing context */\n  Vdbe *v,             /* Prepared statement under construction */\n  WhereInfo *pWInfo,   /* Complete information about the WHERE clause */\n  int iLevel,          /* Which level of pWInfo->a[] should be coded */\n  WhereLevel *pLevel,  /* The current level pointer */\n  Bitmask notReady     /* Which tables are currently available */\n);\n\n/* whereexpr.c: */\nSQLITE_PRIVATE void sqlite3WhereClauseInit(WhereClause*,WhereInfo*);\nSQLITE_PRIVATE void sqlite3WhereClauseClear(WhereClause*);\nSQLITE_PRIVATE void sqlite3WhereSplit(WhereClause*,Expr*,u8);\nSQLITE_PRIVATE Bitmask sqlite3WhereExprUsage(WhereMaskSet*, Expr*);\nSQLITE_PRIVATE Bitmask sqlite3WhereExprUsageNN(WhereMaskSet*, Expr*);\nSQLITE_PRIVATE Bitmask sqlite3WhereExprListUsage(WhereMaskSet*, ExprList*);\nSQLITE_PRIVATE void sqlite3WhereExprAnalyze(SrcList*, WhereClause*);\nSQLITE_PRIVATE void sqlite3WhereTabFuncArgs(Parse*, struct SrcList_item*, WhereClause*);\n\n\n\n\n\n/*\n** Bitmasks for the operators on WhereTerm objects.  These are all\n** operators that are of interest to the query planner.  An\n** OR-ed combination of these values can be used when searching for\n** particular WhereTerms within a WhereClause.\n**\n** Value constraints:\n**     WO_EQ    == SQLITE_INDEX_CONSTRAINT_EQ\n**     WO_LT    == SQLITE_INDEX_CONSTRAINT_LT\n**     WO_LE    == SQLITE_INDEX_CONSTRAINT_LE\n**     WO_GT    == SQLITE_INDEX_CONSTRAINT_GT\n**     WO_GE    == SQLITE_INDEX_CONSTRAINT_GE\n*/\n#define WO_IN     0x0001\n#define WO_EQ     0x0002\n#define WO_LT     (WO_EQ<<(TK_LT-TK_EQ))\n#define WO_LE     (WO_EQ<<(TK_LE-TK_EQ))\n#define WO_GT     (WO_EQ<<(TK_GT-TK_EQ))\n#define WO_GE     (WO_EQ<<(TK_GE-TK_EQ))\n#define WO_AUX    0x0040       /* Op useful to virtual tables only */\n#define WO_IS     0x0080\n#define WO_ISNULL 0x0100\n#define WO_OR     0x0200       /* Two or more OR-connected terms */\n#define WO_AND    0x0400       /* Two or more AND-connected terms */\n#define WO_EQUIV  0x0800       /* Of the form A==B, both columns */\n#define WO_NOOP   0x1000       /* This term does not restrict search space */\n\n#define WO_ALL    0x1fff       /* Mask of all possible WO_* values */\n#define WO_SINGLE 0x01ff       /* Mask of all non-compound WO_* values */\n\n/*\n** These are definitions of bits in the WhereLoop.wsFlags field.\n** The particular combination of bits in each WhereLoop help to\n** determine the algorithm that WhereLoop represents.\n*/\n#define WHERE_COLUMN_EQ    0x00000001  /* x=EXPR */\n#define WHERE_COLUMN_RANGE 0x00000002  /* x<EXPR and/or x>EXPR */\n#define WHERE_COLUMN_IN    0x00000004  /* x IN (...) */\n#define WHERE_COLUMN_NULL  0x00000008  /* x IS NULL */\n#define WHERE_CONSTRAINT   0x0000000f  /* Any of the WHERE_COLUMN_xxx values */\n#define WHERE_TOP_LIMIT    0x00000010  /* x<EXPR or x<=EXPR constraint */\n#define WHERE_BTM_LIMIT    0x00000020  /* x>EXPR or x>=EXPR constraint */\n#define WHERE_BOTH_LIMIT   0x00000030  /* Both x>EXPR and x<EXPR */\n#define WHERE_IDX_ONLY     0x00000040  /* Use index only - omit table */\n#define WHERE_IPK          0x00000100  /* x is the INTEGER PRIMARY KEY */\n#define WHERE_INDEXED      0x00000200  /* WhereLoop.u.btree.pIndex is valid */\n#define WHERE_VIRTUALTABLE 0x00000400  /* WhereLoop.u.vtab is valid */\n#define WHERE_IN_ABLE      0x00000800  /* Able to support an IN operator */\n#define WHERE_ONEROW       0x00001000  /* Selects no more than one row */\n#define WHERE_MULTI_OR     0x00002000  /* OR using multiple indices */\n#define WHERE_AUTO_INDEX   0x00004000  /* Uses an ephemeral index */\n#define WHERE_SKIPSCAN     0x00008000  /* Uses the skip-scan algorithm */\n#define WHERE_UNQ_WANTED   0x00010000  /* WHERE_ONEROW would have been helpful*/\n#define WHERE_PARTIALIDX   0x00020000  /* The automatic index is partial */\n#define WHERE_IN_EARLYOUT  0x00040000  /* Perhaps quit IN loops early */\n\n/************** End of whereInt.h ********************************************/\n/************** Continuing where we left off in wherecode.c ******************/\n\n#ifndef SQLITE_OMIT_EXPLAIN\n\n/*\n** Return the name of the i-th column of the pIdx index.\n*/\nstatic const char *explainIndexColumnName(Index *pIdx, int i){\n  i = pIdx->aiColumn[i];\n  if( i==XN_EXPR ) return \"<expr>\";\n  if( i==XN_ROWID ) return \"rowid\";\n  return pIdx->pTable->aCol[i].zName;\n}\n\n/*\n** This routine is a helper for explainIndexRange() below\n**\n** pStr holds the text of an expression that we are building up one term\n** at a time.  This routine adds a new term to the end of the expression.\n** Terms are separated by AND so add the \"AND\" text for second and subsequent\n** terms only.\n*/\nstatic void explainAppendTerm(\n  StrAccum *pStr,             /* The text expression being built */\n  Index *pIdx,                /* Index to read column names from */\n  int nTerm,                  /* Number of terms */\n  int iTerm,                  /* Zero-based index of first term. */\n  int bAnd,                   /* Non-zero to append \" AND \" */\n  const char *zOp             /* Name of the operator */\n){\n  int i;\n\n  assert( nTerm>=1 );\n  if( bAnd ) sqlite3_str_append(pStr, \" AND \", 5);\n\n  if( nTerm>1 ) sqlite3_str_append(pStr, \"(\", 1);\n  for(i=0; i<nTerm; i++){\n    if( i ) sqlite3_str_append(pStr, \",\", 1);\n    sqlite3_str_appendall(pStr, explainIndexColumnName(pIdx, iTerm+i));\n  }\n  if( nTerm>1 ) sqlite3_str_append(pStr, \")\", 1);\n\n  sqlite3_str_append(pStr, zOp, 1);\n\n  if( nTerm>1 ) sqlite3_str_append(pStr, \"(\", 1);\n  for(i=0; i<nTerm; i++){\n    if( i ) sqlite3_str_append(pStr, \",\", 1);\n    sqlite3_str_append(pStr, \"?\", 1);\n  }\n  if( nTerm>1 ) sqlite3_str_append(pStr, \")\", 1);\n}\n\n/*\n** Argument pLevel describes a strategy for scanning table pTab. This \n** function appends text to pStr that describes the subset of table\n** rows scanned by the strategy in the form of an SQL expression.\n**\n** For example, if the query:\n**\n**   SELECT * FROM t1 WHERE a=1 AND b>2;\n**\n** is run and there is an index on (a, b), then this function returns a\n** string similar to:\n**\n**   \"a=? AND b>?\"\n*/\nstatic void explainIndexRange(StrAccum *pStr, WhereLoop *pLoop){\n  Index *pIndex = pLoop->u.btree.pIndex;\n  u16 nEq = pLoop->u.btree.nEq;\n  u16 nSkip = pLoop->nSkip;\n  int i, j;\n\n  if( nEq==0 && (pLoop->wsFlags&(WHERE_BTM_LIMIT|WHERE_TOP_LIMIT))==0 ) return;\n  sqlite3_str_append(pStr, \" (\", 2);\n  for(i=0; i<nEq; i++){\n    const char *z = explainIndexColumnName(pIndex, i);\n    if( i ) sqlite3_str_append(pStr, \" AND \", 5);\n    sqlite3_str_appendf(pStr, i>=nSkip ? \"%s=?\" : \"ANY(%s)\", z);\n  }\n\n  j = i;\n  if( pLoop->wsFlags&WHERE_BTM_LIMIT ){\n    explainAppendTerm(pStr, pIndex, pLoop->u.btree.nBtm, j, i, \">\");\n    i = 1;\n  }\n  if( pLoop->wsFlags&WHERE_TOP_LIMIT ){\n    explainAppendTerm(pStr, pIndex, pLoop->u.btree.nTop, j, i, \"<\");\n  }\n  sqlite3_str_append(pStr, \")\", 1);\n}\n\n/*\n** This function is a no-op unless currently processing an EXPLAIN QUERY PLAN\n** command, or if either SQLITE_DEBUG or SQLITE_ENABLE_STMT_SCANSTATUS was\n** defined at compile-time. If it is not a no-op, a single OP_Explain opcode \n** is added to the output to describe the table scan strategy in pLevel.\n**\n** If an OP_Explain opcode is added to the VM, its address is returned.\n** Otherwise, if no OP_Explain is coded, zero is returned.\n*/\nSQLITE_PRIVATE int sqlite3WhereExplainOneScan(\n  Parse *pParse,                  /* Parse context */\n  SrcList *pTabList,              /* Table list this loop refers to */\n  WhereLevel *pLevel,             /* Scan to write OP_Explain opcode for */\n  u16 wctrlFlags                  /* Flags passed to sqlite3WhereBegin() */\n){\n  int ret = 0;\n#if !defined(SQLITE_DEBUG) && !defined(SQLITE_ENABLE_STMT_SCANSTATUS)\n  if( sqlite3ParseToplevel(pParse)->explain==2 )\n#endif\n  {\n    struct SrcList_item *pItem = &pTabList->a[pLevel->iFrom];\n    Vdbe *v = pParse->pVdbe;      /* VM being constructed */\n    sqlite3 *db = pParse->db;     /* Database handle */\n    int isSearch;                 /* True for a SEARCH. False for SCAN. */\n    WhereLoop *pLoop;             /* The controlling WhereLoop object */\n    u32 flags;                    /* Flags that describe this loop */\n    char *zMsg;                   /* Text to add to EQP output */\n    StrAccum str;                 /* EQP output string */\n    char zBuf[100];               /* Initial space for EQP output string */\n\n    pLoop = pLevel->pWLoop;\n    flags = pLoop->wsFlags;\n    if( (flags&WHERE_MULTI_OR) || (wctrlFlags&WHERE_OR_SUBCLAUSE) ) return 0;\n\n    isSearch = (flags&(WHERE_BTM_LIMIT|WHERE_TOP_LIMIT))!=0\n            || ((flags&WHERE_VIRTUALTABLE)==0 && (pLoop->u.btree.nEq>0))\n            || (wctrlFlags&(WHERE_ORDERBY_MIN|WHERE_ORDERBY_MAX));\n\n    sqlite3StrAccumInit(&str, db, zBuf, sizeof(zBuf), SQLITE_MAX_LENGTH);\n    sqlite3_str_appendall(&str, isSearch ? \"SEARCH\" : \"SCAN\");\n    if( pItem->pSelect ){\n      sqlite3_str_appendf(&str, \" SUBQUERY %u\", pItem->pSelect->selId);\n    }else{\n      sqlite3_str_appendf(&str, \" TABLE %s\", pItem->zName);\n    }\n\n    if( pItem->zAlias ){\n      sqlite3_str_appendf(&str, \" AS %s\", pItem->zAlias);\n    }\n    if( (flags & (WHERE_IPK|WHERE_VIRTUALTABLE))==0 ){\n      const char *zFmt = 0;\n      Index *pIdx;\n\n      assert( pLoop->u.btree.pIndex!=0 );\n      pIdx = pLoop->u.btree.pIndex;\n      assert( !(flags&WHERE_AUTO_INDEX) || (flags&WHERE_IDX_ONLY) );\n      if( !HasRowid(pItem->pTab) && IsPrimaryKeyIndex(pIdx) ){\n        if( isSearch ){\n          zFmt = \"PRIMARY KEY\";\n        }\n      }else if( flags & WHERE_PARTIALIDX ){\n        zFmt = \"AUTOMATIC PARTIAL COVERING INDEX\";\n      }else if( flags & WHERE_AUTO_INDEX ){\n        zFmt = \"AUTOMATIC COVERING INDEX\";\n      }else if( flags & WHERE_IDX_ONLY ){\n        zFmt = \"COVERING INDEX %s\";\n      }else{\n        zFmt = \"INDEX %s\";\n      }\n      if( zFmt ){\n        sqlite3_str_append(&str, \" USING \", 7);\n        sqlite3_str_appendf(&str, zFmt, pIdx->zName);\n        explainIndexRange(&str, pLoop);\n      }\n    }else if( (flags & WHERE_IPK)!=0 && (flags & WHERE_CONSTRAINT)!=0 ){\n      const char *zRangeOp;\n      if( flags&(WHERE_COLUMN_EQ|WHERE_COLUMN_IN) ){\n        zRangeOp = \"=\";\n      }else if( (flags&WHERE_BOTH_LIMIT)==WHERE_BOTH_LIMIT ){\n        zRangeOp = \">? AND rowid<\";\n      }else if( flags&WHERE_BTM_LIMIT ){\n        zRangeOp = \">\";\n      }else{\n        assert( flags&WHERE_TOP_LIMIT);\n        zRangeOp = \"<\";\n      }\n      sqlite3_str_appendf(&str, \n          \" USING INTEGER PRIMARY KEY (rowid%s?)\",zRangeOp);\n    }\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n    else if( (flags & WHERE_VIRTUALTABLE)!=0 ){\n      sqlite3_str_appendf(&str, \" VIRTUAL TABLE INDEX %d:%s\",\n                  pLoop->u.vtab.idxNum, pLoop->u.vtab.idxStr);\n    }\n#endif\n#ifdef SQLITE_EXPLAIN_ESTIMATED_ROWS\n    if( pLoop->nOut>=10 ){\n      sqlite3_str_appendf(&str, \" (~%llu rows)\",\n             sqlite3LogEstToInt(pLoop->nOut));\n    }else{\n      sqlite3_str_append(&str, \" (~1 row)\", 9);\n    }\n#endif\n    zMsg = sqlite3StrAccumFinish(&str);\n    sqlite3ExplainBreakpoint(\"\",zMsg);\n    ret = sqlite3VdbeAddOp4(v, OP_Explain, sqlite3VdbeCurrentAddr(v),\n                            pParse->addrExplain, 0, zMsg,P4_DYNAMIC);\n  }\n  return ret;\n}\n#endif /* SQLITE_OMIT_EXPLAIN */\n\n#ifdef SQLITE_ENABLE_STMT_SCANSTATUS\n/*\n** Configure the VM passed as the first argument with an\n** sqlite3_stmt_scanstatus() entry corresponding to the scan used to \n** implement level pLvl. Argument pSrclist is a pointer to the FROM \n** clause that the scan reads data from.\n**\n** If argument addrExplain is not 0, it must be the address of an \n** OP_Explain instruction that describes the same loop.\n*/\nSQLITE_PRIVATE void sqlite3WhereAddScanStatus(\n  Vdbe *v,                        /* Vdbe to add scanstatus entry to */\n  SrcList *pSrclist,              /* FROM clause pLvl reads data from */\n  WhereLevel *pLvl,               /* Level to add scanstatus() entry for */\n  int addrExplain                 /* Address of OP_Explain (or 0) */\n){\n  const char *zObj = 0;\n  WhereLoop *pLoop = pLvl->pWLoop;\n  if( (pLoop->wsFlags & WHERE_VIRTUALTABLE)==0  &&  pLoop->u.btree.pIndex!=0 ){\n    zObj = pLoop->u.btree.pIndex->zName;\n  }else{\n    zObj = pSrclist->a[pLvl->iFrom].zName;\n  }\n  sqlite3VdbeScanStatus(\n      v, addrExplain, pLvl->addrBody, pLvl->addrVisit, pLoop->nOut, zObj\n  );\n}\n#endif\n\n\n/*\n** Disable a term in the WHERE clause.  Except, do not disable the term\n** if it controls a LEFT OUTER JOIN and it did not originate in the ON\n** or USING clause of that join.\n**\n** Consider the term t2.z='ok' in the following queries:\n**\n**   (1)  SELECT * FROM t1 LEFT JOIN t2 ON t1.a=t2.x WHERE t2.z='ok'\n**   (2)  SELECT * FROM t1 LEFT JOIN t2 ON t1.a=t2.x AND t2.z='ok'\n**   (3)  SELECT * FROM t1, t2 WHERE t1.a=t2.x AND t2.z='ok'\n**\n** The t2.z='ok' is disabled in the in (2) because it originates\n** in the ON clause.  The term is disabled in (3) because it is not part\n** of a LEFT OUTER JOIN.  In (1), the term is not disabled.\n**\n** Disabling a term causes that term to not be tested in the inner loop\n** of the join.  Disabling is an optimization.  When terms are satisfied\n** by indices, we disable them to prevent redundant tests in the inner\n** loop.  We would get the correct results if nothing were ever disabled,\n** but joins might run a little slower.  The trick is to disable as much\n** as we can without disabling too much.  If we disabled in (1), we'd get\n** the wrong answer.  See ticket #813.\n**\n** If all the children of a term are disabled, then that term is also\n** automatically disabled.  In this way, terms get disabled if derived\n** virtual terms are tested first.  For example:\n**\n**      x GLOB 'abc*' AND x>='abc' AND x<'acd'\n**      \\___________/     \\______/     \\_____/\n**         parent          child1       child2\n**\n** Only the parent term was in the original WHERE clause.  The child1\n** and child2 terms were added by the LIKE optimization.  If both of\n** the virtual child terms are valid, then testing of the parent can be \n** skipped.\n**\n** Usually the parent term is marked as TERM_CODED.  But if the parent\n** term was originally TERM_LIKE, then the parent gets TERM_LIKECOND instead.\n** The TERM_LIKECOND marking indicates that the term should be coded inside\n** a conditional such that is only evaluated on the second pass of a\n** LIKE-optimization loop, when scanning BLOBs instead of strings.\n*/\nstatic void disableTerm(WhereLevel *pLevel, WhereTerm *pTerm){\n  int nLoop = 0;\n  assert( pTerm!=0 );\n  while( (pTerm->wtFlags & TERM_CODED)==0\n      && (pLevel->iLeftJoin==0 || ExprHasProperty(pTerm->pExpr, EP_FromJoin))\n      && (pLevel->notReady & pTerm->prereqAll)==0\n  ){\n    if( nLoop && (pTerm->wtFlags & TERM_LIKE)!=0 ){\n      pTerm->wtFlags |= TERM_LIKECOND;\n    }else{\n      pTerm->wtFlags |= TERM_CODED;\n    }\n    if( pTerm->iParent<0 ) break;\n    pTerm = &pTerm->pWC->a[pTerm->iParent];\n    assert( pTerm!=0 );\n    pTerm->nChild--;\n    if( pTerm->nChild!=0 ) break;\n    nLoop++;\n  }\n}\n\n/*\n** Code an OP_Affinity opcode to apply the column affinity string zAff\n** to the n registers starting at base. \n**\n** As an optimization, SQLITE_AFF_BLOB entries (which are no-ops) at the\n** beginning and end of zAff are ignored.  If all entries in zAff are\n** SQLITE_AFF_BLOB, then no code gets generated.\n**\n** This routine makes its own copy of zAff so that the caller is free\n** to modify zAff after this routine returns.\n*/\nstatic void codeApplyAffinity(Parse *pParse, int base, int n, char *zAff){\n  Vdbe *v = pParse->pVdbe;\n  if( zAff==0 ){\n    assert( pParse->db->mallocFailed );\n    return;\n  }\n  assert( v!=0 );\n\n  /* Adjust base and n to skip over SQLITE_AFF_BLOB entries at the beginning\n  ** and end of the affinity string.\n  */\n  while( n>0 && zAff[0]==SQLITE_AFF_BLOB ){\n    n--;\n    base++;\n    zAff++;\n  }\n  while( n>1 && zAff[n-1]==SQLITE_AFF_BLOB ){\n    n--;\n  }\n\n  /* Code the OP_Affinity opcode if there is anything left to do. */\n  if( n>0 ){\n    sqlite3VdbeAddOp4(v, OP_Affinity, base, n, 0, zAff, n);\n  }\n}\n\n/*\n** Expression pRight, which is the RHS of a comparison operation, is \n** either a vector of n elements or, if n==1, a scalar expression.\n** Before the comparison operation, affinity zAff is to be applied\n** to the pRight values. This function modifies characters within the\n** affinity string to SQLITE_AFF_BLOB if either:\n**\n**   * the comparison will be performed with no affinity, or\n**   * the affinity change in zAff is guaranteed not to change the value.\n*/\nstatic void updateRangeAffinityStr(\n  Expr *pRight,                   /* RHS of comparison */\n  int n,                          /* Number of vector elements in comparison */\n  char *zAff                      /* Affinity string to modify */\n){\n  int i;\n  for(i=0; i<n; i++){\n    Expr *p = sqlite3VectorFieldSubexpr(pRight, i);\n    if( sqlite3CompareAffinity(p, zAff[i])==SQLITE_AFF_BLOB\n     || sqlite3ExprNeedsNoAffinityChange(p, zAff[i])\n    ){\n      zAff[i] = SQLITE_AFF_BLOB;\n    }\n  }\n}\n\n\n/*\n** pX is an expression of the form:  (vector) IN (SELECT ...)\n** In other words, it is a vector IN operator with a SELECT clause on the\n** LHS.  But not all terms in the vector are indexable and the terms might\n** not be in the correct order for indexing.\n**\n** This routine makes a copy of the input pX expression and then adjusts\n** the vector on the LHS with corresponding changes to the SELECT so that\n** the vector contains only index terms and those terms are in the correct\n** order.  The modified IN expression is returned.  The caller is responsible\n** for deleting the returned expression.\n**\n** Example:\n**\n**    CREATE TABLE t1(a,b,c,d,e,f);\n**    CREATE INDEX t1x1 ON t1(e,c);\n**    SELECT * FROM t1 WHERE (a,b,c,d,e) IN (SELECT v,w,x,y,z FROM t2)\n**                           \\_______________________________________/\n**                                     The pX expression\n**\n** Since only columns e and c can be used with the index, in that order,\n** the modified IN expression that is returned will be:\n**\n**        (e,c) IN (SELECT z,x FROM t2)\n**\n** The reduced pX is different from the original (obviously) and thus is\n** only used for indexing, to improve performance.  The original unaltered\n** IN expression must also be run on each output row for correctness.\n*/\nstatic Expr *removeUnindexableInClauseTerms(\n  Parse *pParse,        /* The parsing context */\n  int iEq,              /* Look at loop terms starting here */\n  WhereLoop *pLoop,     /* The current loop */\n  Expr *pX              /* The IN expression to be reduced */\n){\n  sqlite3 *db = pParse->db;\n  Expr *pNew = sqlite3ExprDup(db, pX, 0);\n  if( db->mallocFailed==0 ){\n    ExprList *pOrigRhs = pNew->x.pSelect->pEList;  /* Original unmodified RHS */\n    ExprList *pOrigLhs = pNew->pLeft->x.pList;     /* Original unmodified LHS */\n    ExprList *pRhs = 0;         /* New RHS after modifications */\n    ExprList *pLhs = 0;         /* New LHS after mods */\n    int i;                      /* Loop counter */\n    Select *pSelect;            /* Pointer to the SELECT on the RHS */\n\n    for(i=iEq; i<pLoop->nLTerm; i++){\n      if( pLoop->aLTerm[i]->pExpr==pX ){\n        int iField = pLoop->aLTerm[i]->iField - 1;\n        if( pOrigRhs->a[iField].pExpr==0 ) continue; /* Duplicate PK column */\n        pRhs = sqlite3ExprListAppend(pParse, pRhs, pOrigRhs->a[iField].pExpr);\n        pOrigRhs->a[iField].pExpr = 0;\n        assert( pOrigLhs->a[iField].pExpr!=0 );\n        pLhs = sqlite3ExprListAppend(pParse, pLhs, pOrigLhs->a[iField].pExpr);\n        pOrigLhs->a[iField].pExpr = 0;\n      }\n    }\n    sqlite3ExprListDelete(db, pOrigRhs);\n    sqlite3ExprListDelete(db, pOrigLhs);\n    pNew->pLeft->x.pList = pLhs;\n    pNew->x.pSelect->pEList = pRhs;\n    if( pLhs && pLhs->nExpr==1 ){\n      /* Take care here not to generate a TK_VECTOR containing only a\n      ** single value. Since the parser never creates such a vector, some\n      ** of the subroutines do not handle this case.  */\n      Expr *p = pLhs->a[0].pExpr;\n      pLhs->a[0].pExpr = 0;\n      sqlite3ExprDelete(db, pNew->pLeft);\n      pNew->pLeft = p;\n    }\n    pSelect = pNew->x.pSelect;\n    if( pSelect->pOrderBy ){\n      /* If the SELECT statement has an ORDER BY clause, zero the \n      ** iOrderByCol variables. These are set to non-zero when an \n      ** ORDER BY term exactly matches one of the terms of the \n      ** result-set. Since the result-set of the SELECT statement may\n      ** have been modified or reordered, these variables are no longer \n      ** set correctly.  Since setting them is just an optimization, \n      ** it's easiest just to zero them here.  */\n      ExprList *pOrderBy = pSelect->pOrderBy;\n      for(i=0; i<pOrderBy->nExpr; i++){\n        pOrderBy->a[i].u.x.iOrderByCol = 0;\n      }\n    }\n\n#if 0\n    printf(\"For indexing, change the IN expr:\\n\");\n    sqlite3TreeViewExpr(0, pX, 0);\n    printf(\"Into:\\n\");\n    sqlite3TreeViewExpr(0, pNew, 0);\n#endif\n  }\n  return pNew;\n}\n\n\n/*\n** Generate code for a single equality term of the WHERE clause.  An equality\n** term can be either X=expr or X IN (...).   pTerm is the term to be \n** coded.\n**\n** The current value for the constraint is left in a register, the index\n** of which is returned.  An attempt is made store the result in iTarget but\n** this is only guaranteed for TK_ISNULL and TK_IN constraints.  If the\n** constraint is a TK_EQ or TK_IS, then the current value might be left in\n** some other register and it is the caller's responsibility to compensate.\n**\n** For a constraint of the form X=expr, the expression is evaluated in\n** straight-line code.  For constraints of the form X IN (...)\n** this routine sets up a loop that will iterate over all values of X.\n*/\nstatic int codeEqualityTerm(\n  Parse *pParse,      /* The parsing context */\n  WhereTerm *pTerm,   /* The term of the WHERE clause to be coded */\n  WhereLevel *pLevel, /* The level of the FROM clause we are working on */\n  int iEq,            /* Index of the equality term within this level */\n  int bRev,           /* True for reverse-order IN operations */\n  int iTarget         /* Attempt to leave results in this register */\n){\n  Expr *pX = pTerm->pExpr;\n  Vdbe *v = pParse->pVdbe;\n  int iReg;                  /* Register holding results */\n\n  assert( pLevel->pWLoop->aLTerm[iEq]==pTerm );\n  assert( iTarget>0 );\n  if( pX->op==TK_EQ || pX->op==TK_IS ){\n    iReg = sqlite3ExprCodeTarget(pParse, pX->pRight, iTarget);\n  }else if( pX->op==TK_ISNULL ){\n    iReg = iTarget;\n    sqlite3VdbeAddOp2(v, OP_Null, 0, iReg);\n#ifndef SQLITE_OMIT_SUBQUERY\n  }else{\n    int eType = IN_INDEX_NOOP;\n    int iTab;\n    struct InLoop *pIn;\n    WhereLoop *pLoop = pLevel->pWLoop;\n    int i;\n    int nEq = 0;\n    int *aiMap = 0;\n\n    if( (pLoop->wsFlags & WHERE_VIRTUALTABLE)==0\n      && pLoop->u.btree.pIndex!=0\n      && pLoop->u.btree.pIndex->aSortOrder[iEq]\n    ){\n      testcase( iEq==0 );\n      testcase( bRev );\n      bRev = !bRev;\n    }\n    assert( pX->op==TK_IN );\n    iReg = iTarget;\n\n    for(i=0; i<iEq; i++){\n      if( pLoop->aLTerm[i] && pLoop->aLTerm[i]->pExpr==pX ){\n        disableTerm(pLevel, pTerm);\n        return iTarget;\n      }\n    }\n    for(i=iEq;i<pLoop->nLTerm; i++){\n      assert( pLoop->aLTerm[i]!=0 );\n      if( pLoop->aLTerm[i]->pExpr==pX ) nEq++;\n    }\n\n    iTab = 0;\n    if( (pX->flags & EP_xIsSelect)==0 || pX->x.pSelect->pEList->nExpr==1 ){\n      eType = sqlite3FindInIndex(pParse, pX, IN_INDEX_LOOP, 0, 0, &iTab);\n    }else{\n      sqlite3 *db = pParse->db;\n      pX = removeUnindexableInClauseTerms(pParse, iEq, pLoop, pX);\n\n      if( !db->mallocFailed ){\n        aiMap = (int*)sqlite3DbMallocZero(pParse->db, sizeof(int)*nEq);\n        eType = sqlite3FindInIndex(pParse, pX, IN_INDEX_LOOP, 0, aiMap, &iTab);\n        pTerm->pExpr->iTable = iTab;\n      }\n      sqlite3ExprDelete(db, pX);\n      pX = pTerm->pExpr;\n    }\n\n    if( eType==IN_INDEX_INDEX_DESC ){\n      testcase( bRev );\n      bRev = !bRev;\n    }\n    sqlite3VdbeAddOp2(v, bRev ? OP_Last : OP_Rewind, iTab, 0);\n    VdbeCoverageIf(v, bRev);\n    VdbeCoverageIf(v, !bRev);\n    assert( (pLoop->wsFlags & WHERE_MULTI_OR)==0 );\n\n    pLoop->wsFlags |= WHERE_IN_ABLE;\n    if( pLevel->u.in.nIn==0 ){\n      pLevel->addrNxt = sqlite3VdbeMakeLabel(pParse);\n    }\n\n    i = pLevel->u.in.nIn;\n    pLevel->u.in.nIn += nEq;\n    pLevel->u.in.aInLoop =\n       sqlite3DbReallocOrFree(pParse->db, pLevel->u.in.aInLoop,\n                              sizeof(pLevel->u.in.aInLoop[0])*pLevel->u.in.nIn);\n    pIn = pLevel->u.in.aInLoop;\n    if( pIn ){\n      int iMap = 0;               /* Index in aiMap[] */\n      pIn += i;\n      for(i=iEq;i<pLoop->nLTerm; i++){\n        if( pLoop->aLTerm[i]->pExpr==pX ){\n          int iOut = iReg + i - iEq;\n          if( eType==IN_INDEX_ROWID ){\n            pIn->addrInTop = sqlite3VdbeAddOp2(v, OP_Rowid, iTab, iOut);\n          }else{\n            int iCol = aiMap ? aiMap[iMap++] : 0;\n            pIn->addrInTop = sqlite3VdbeAddOp3(v,OP_Column,iTab, iCol, iOut);\n          }\n          sqlite3VdbeAddOp1(v, OP_IsNull, iOut); VdbeCoverage(v);\n          if( i==iEq ){\n            pIn->iCur = iTab;\n            pIn->eEndLoopOp = bRev ? OP_Prev : OP_Next;\n            if( iEq>0 && (pLoop->wsFlags & WHERE_VIRTUALTABLE)==0 ){\n              pIn->iBase = iReg - i;\n              pIn->nPrefix = i;\n              pLoop->wsFlags |= WHERE_IN_EARLYOUT;\n            }else{\n              pIn->nPrefix = 0;\n            }\n          }else{\n            pIn->eEndLoopOp = OP_Noop;\n          }\n          pIn++;\n        }\n      }\n    }else{\n      pLevel->u.in.nIn = 0;\n    }\n    sqlite3DbFree(pParse->db, aiMap);\n#endif\n  }\n  disableTerm(pLevel, pTerm);\n  return iReg;\n}\n\n/*\n** Generate code that will evaluate all == and IN constraints for an\n** index scan.\n**\n** For example, consider table t1(a,b,c,d,e,f) with index i1(a,b,c).\n** Suppose the WHERE clause is this:  a==5 AND b IN (1,2,3) AND c>5 AND c<10\n** The index has as many as three equality constraints, but in this\n** example, the third \"c\" value is an inequality.  So only two \n** constraints are coded.  This routine will generate code to evaluate\n** a==5 and b IN (1,2,3).  The current values for a and b will be stored\n** in consecutive registers and the index of the first register is returned.\n**\n** In the example above nEq==2.  But this subroutine works for any value\n** of nEq including 0.  If nEq==0, this routine is nearly a no-op.\n** The only thing it does is allocate the pLevel->iMem memory cell and\n** compute the affinity string.\n**\n** The nExtraReg parameter is 0 or 1.  It is 0 if all WHERE clause constraints\n** are == or IN and are covered by the nEq.  nExtraReg is 1 if there is\n** an inequality constraint (such as the \"c>=5 AND c<10\" in the example) that\n** occurs after the nEq quality constraints.\n**\n** This routine allocates a range of nEq+nExtraReg memory cells and returns\n** the index of the first memory cell in that range. The code that\n** calls this routine will use that memory range to store keys for\n** start and termination conditions of the loop.\n** key value of the loop.  If one or more IN operators appear, then\n** this routine allocates an additional nEq memory cells for internal\n** use.\n**\n** Before returning, *pzAff is set to point to a buffer containing a\n** copy of the column affinity string of the index allocated using\n** sqlite3DbMalloc(). Except, entries in the copy of the string associated\n** with equality constraints that use BLOB or NONE affinity are set to\n** SQLITE_AFF_BLOB. This is to deal with SQL such as the following:\n**\n**   CREATE TABLE t1(a TEXT PRIMARY KEY, b);\n**   SELECT ... FROM t1 AS t2, t1 WHERE t1.a = t2.b;\n**\n** In the example above, the index on t1(a) has TEXT affinity. But since\n** the right hand side of the equality constraint (t2.b) has BLOB/NONE affinity,\n** no conversion should be attempted before using a t2.b value as part of\n** a key to search the index. Hence the first byte in the returned affinity\n** string in this example would be set to SQLITE_AFF_BLOB.\n*/\nstatic int codeAllEqualityTerms(\n  Parse *pParse,        /* Parsing context */\n  WhereLevel *pLevel,   /* Which nested loop of the FROM we are coding */\n  int bRev,             /* Reverse the order of IN operators */\n  int nExtraReg,        /* Number of extra registers to allocate */\n  char **pzAff          /* OUT: Set to point to affinity string */\n){\n  u16 nEq;                      /* The number of == or IN constraints to code */\n  u16 nSkip;                    /* Number of left-most columns to skip */\n  Vdbe *v = pParse->pVdbe;      /* The vm under construction */\n  Index *pIdx;                  /* The index being used for this loop */\n  WhereTerm *pTerm;             /* A single constraint term */\n  WhereLoop *pLoop;             /* The WhereLoop object */\n  int j;                        /* Loop counter */\n  int regBase;                  /* Base register */\n  int nReg;                     /* Number of registers to allocate */\n  char *zAff;                   /* Affinity string to return */\n\n  /* This module is only called on query plans that use an index. */\n  pLoop = pLevel->pWLoop;\n  assert( (pLoop->wsFlags & WHERE_VIRTUALTABLE)==0 );\n  nEq = pLoop->u.btree.nEq;\n  nSkip = pLoop->nSkip;\n  pIdx = pLoop->u.btree.pIndex;\n  assert( pIdx!=0 );\n\n  /* Figure out how many memory cells we will need then allocate them.\n  */\n  regBase = pParse->nMem + 1;\n  nReg = pLoop->u.btree.nEq + nExtraReg;\n  pParse->nMem += nReg;\n\n  zAff = sqlite3DbStrDup(pParse->db,sqlite3IndexAffinityStr(pParse->db,pIdx));\n  assert( zAff!=0 || pParse->db->mallocFailed );\n\n  if( nSkip ){\n    int iIdxCur = pLevel->iIdxCur;\n    sqlite3VdbeAddOp1(v, (bRev?OP_Last:OP_Rewind), iIdxCur);\n    VdbeCoverageIf(v, bRev==0);\n    VdbeCoverageIf(v, bRev!=0);\n    VdbeComment((v, \"begin skip-scan on %s\", pIdx->zName));\n    j = sqlite3VdbeAddOp0(v, OP_Goto);\n    pLevel->addrSkip = sqlite3VdbeAddOp4Int(v, (bRev?OP_SeekLT:OP_SeekGT),\n                            iIdxCur, 0, regBase, nSkip);\n    VdbeCoverageIf(v, bRev==0);\n    VdbeCoverageIf(v, bRev!=0);\n    sqlite3VdbeJumpHere(v, j);\n    for(j=0; j<nSkip; j++){\n      sqlite3VdbeAddOp3(v, OP_Column, iIdxCur, j, regBase+j);\n      testcase( pIdx->aiColumn[j]==XN_EXPR );\n      VdbeComment((v, \"%s\", explainIndexColumnName(pIdx, j)));\n    }\n  }    \n\n  /* Evaluate the equality constraints\n  */\n  assert( zAff==0 || (int)strlen(zAff)>=nEq );\n  for(j=nSkip; j<nEq; j++){\n    int r1;\n    pTerm = pLoop->aLTerm[j];\n    assert( pTerm!=0 );\n    /* The following testcase is true for indices with redundant columns. \n    ** Ex: CREATE INDEX i1 ON t1(a,b,a); SELECT * FROM t1 WHERE a=0 AND b=0; */\n    testcase( (pTerm->wtFlags & TERM_CODED)!=0 );\n    testcase( pTerm->wtFlags & TERM_VIRTUAL );\n    r1 = codeEqualityTerm(pParse, pTerm, pLevel, j, bRev, regBase+j);\n    if( r1!=regBase+j ){\n      if( nReg==1 ){\n        sqlite3ReleaseTempReg(pParse, regBase);\n        regBase = r1;\n      }else{\n        sqlite3VdbeAddOp2(v, OP_SCopy, r1, regBase+j);\n      }\n    }\n    if( pTerm->eOperator & WO_IN ){\n      if( pTerm->pExpr->flags & EP_xIsSelect ){\n        /* No affinity ever needs to be (or should be) applied to a value\n        ** from the RHS of an \"? IN (SELECT ...)\" expression. The \n        ** sqlite3FindInIndex() routine has already ensured that the \n        ** affinity of the comparison has been applied to the value.  */\n        if( zAff ) zAff[j] = SQLITE_AFF_BLOB;\n      }\n    }else if( (pTerm->eOperator & WO_ISNULL)==0 ){\n      Expr *pRight = pTerm->pExpr->pRight;\n      if( (pTerm->wtFlags & TERM_IS)==0 && sqlite3ExprCanBeNull(pRight) ){\n        sqlite3VdbeAddOp2(v, OP_IsNull, regBase+j, pLevel->addrBrk);\n        VdbeCoverage(v);\n      }\n      if( zAff ){\n        if( sqlite3CompareAffinity(pRight, zAff[j])==SQLITE_AFF_BLOB ){\n          zAff[j] = SQLITE_AFF_BLOB;\n        }\n        if( sqlite3ExprNeedsNoAffinityChange(pRight, zAff[j]) ){\n          zAff[j] = SQLITE_AFF_BLOB;\n        }\n      }\n    }\n  }\n  *pzAff = zAff;\n  return regBase;\n}\n\n#ifndef SQLITE_LIKE_DOESNT_MATCH_BLOBS\n/*\n** If the most recently coded instruction is a constant range constraint\n** (a string literal) that originated from the LIKE optimization, then \n** set P3 and P5 on the OP_String opcode so that the string will be cast\n** to a BLOB at appropriate times.\n**\n** The LIKE optimization trys to evaluate \"x LIKE 'abc%'\" as a range\n** expression: \"x>='ABC' AND x<'abd'\".  But this requires that the range\n** scan loop run twice, once for strings and a second time for BLOBs.\n** The OP_String opcodes on the second pass convert the upper and lower\n** bound string constants to blobs.  This routine makes the necessary changes\n** to the OP_String opcodes for that to happen.\n**\n** Except, of course, if SQLITE_LIKE_DOESNT_MATCH_BLOBS is defined, then\n** only the one pass through the string space is required, so this routine\n** becomes a no-op.\n*/\nstatic void whereLikeOptimizationStringFixup(\n  Vdbe *v,                /* prepared statement under construction */\n  WhereLevel *pLevel,     /* The loop that contains the LIKE operator */\n  WhereTerm *pTerm        /* The upper or lower bound just coded */\n){\n  if( pTerm->wtFlags & TERM_LIKEOPT ){\n    VdbeOp *pOp;\n    assert( pLevel->iLikeRepCntr>0 );\n    pOp = sqlite3VdbeGetOp(v, -1);\n    assert( pOp!=0 );\n    assert( pOp->opcode==OP_String8 \n            || pTerm->pWC->pWInfo->pParse->db->mallocFailed );\n    pOp->p3 = (int)(pLevel->iLikeRepCntr>>1);  /* Register holding counter */\n    pOp->p5 = (u8)(pLevel->iLikeRepCntr&1);    /* ASC or DESC */\n  }\n}\n#else\n# define whereLikeOptimizationStringFixup(A,B,C)\n#endif\n\n#ifdef SQLITE_ENABLE_CURSOR_HINTS\n/*\n** Information is passed from codeCursorHint() down to individual nodes of\n** the expression tree (by sqlite3WalkExpr()) using an instance of this\n** structure.\n*/\nstruct CCurHint {\n  int iTabCur;    /* Cursor for the main table */\n  int iIdxCur;    /* Cursor for the index, if pIdx!=0.  Unused otherwise */\n  Index *pIdx;    /* The index used to access the table */\n};\n\n/*\n** This function is called for every node of an expression that is a candidate\n** for a cursor hint on an index cursor.  For TK_COLUMN nodes that reference\n** the table CCurHint.iTabCur, verify that the same column can be\n** accessed through the index.  If it cannot, then set pWalker->eCode to 1.\n*/\nstatic int codeCursorHintCheckExpr(Walker *pWalker, Expr *pExpr){\n  struct CCurHint *pHint = pWalker->u.pCCurHint;\n  assert( pHint->pIdx!=0 );\n  if( pExpr->op==TK_COLUMN\n   && pExpr->iTable==pHint->iTabCur\n   && sqlite3ColumnOfIndex(pHint->pIdx, pExpr->iColumn)<0\n  ){\n    pWalker->eCode = 1;\n  }\n  return WRC_Continue;\n}\n\n/*\n** Test whether or not expression pExpr, which was part of a WHERE clause,\n** should be included in the cursor-hint for a table that is on the rhs\n** of a LEFT JOIN. Set Walker.eCode to non-zero before returning if the \n** expression is not suitable.\n**\n** An expression is unsuitable if it might evaluate to non NULL even if\n** a TK_COLUMN node that does affect the value of the expression is set\n** to NULL. For example:\n**\n**   col IS NULL\n**   col IS NOT NULL\n**   coalesce(col, 1)\n**   CASE WHEN col THEN 0 ELSE 1 END\n*/\nstatic int codeCursorHintIsOrFunction(Walker *pWalker, Expr *pExpr){\n  if( pExpr->op==TK_IS \n   || pExpr->op==TK_ISNULL || pExpr->op==TK_ISNOT \n   || pExpr->op==TK_NOTNULL || pExpr->op==TK_CASE \n  ){\n    pWalker->eCode = 1;\n  }else if( pExpr->op==TK_FUNCTION ){\n    int d1;\n    char d2[4];\n    if( 0==sqlite3IsLikeFunction(pWalker->pParse->db, pExpr, &d1, d2) ){\n      pWalker->eCode = 1;\n    }\n  }\n\n  return WRC_Continue;\n}\n\n\n/*\n** This function is called on every node of an expression tree used as an\n** argument to the OP_CursorHint instruction. If the node is a TK_COLUMN\n** that accesses any table other than the one identified by\n** CCurHint.iTabCur, then do the following:\n**\n**   1) allocate a register and code an OP_Column instruction to read \n**      the specified column into the new register, and\n**\n**   2) transform the expression node to a TK_REGISTER node that reads \n**      from the newly populated register.\n**\n** Also, if the node is a TK_COLUMN that does access the table idenified\n** by pCCurHint.iTabCur, and an index is being used (which we will\n** know because CCurHint.pIdx!=0) then transform the TK_COLUMN into\n** an access of the index rather than the original table.\n*/\nstatic int codeCursorHintFixExpr(Walker *pWalker, Expr *pExpr){\n  int rc = WRC_Continue;\n  struct CCurHint *pHint = pWalker->u.pCCurHint;\n  if( pExpr->op==TK_COLUMN ){\n    if( pExpr->iTable!=pHint->iTabCur ){\n      int reg = ++pWalker->pParse->nMem;   /* Register for column value */\n      sqlite3ExprCode(pWalker->pParse, pExpr, reg);\n      pExpr->op = TK_REGISTER;\n      pExpr->iTable = reg;\n    }else if( pHint->pIdx!=0 ){\n      pExpr->iTable = pHint->iIdxCur;\n      pExpr->iColumn = sqlite3ColumnOfIndex(pHint->pIdx, pExpr->iColumn);\n      assert( pExpr->iColumn>=0 );\n    }\n  }else if( pExpr->op==TK_AGG_FUNCTION ){\n    /* An aggregate function in the WHERE clause of a query means this must\n    ** be a correlated sub-query, and expression pExpr is an aggregate from\n    ** the parent context. Do not walk the function arguments in this case.\n    **\n    ** todo: It should be possible to replace this node with a TK_REGISTER\n    ** expression, as the result of the expression must be stored in a \n    ** register at this point. The same holds for TK_AGG_COLUMN nodes. */\n    rc = WRC_Prune;\n  }\n  return rc;\n}\n\n/*\n** Insert an OP_CursorHint instruction if it is appropriate to do so.\n*/\nstatic void codeCursorHint(\n  struct SrcList_item *pTabItem,  /* FROM clause item */\n  WhereInfo *pWInfo,    /* The where clause */\n  WhereLevel *pLevel,   /* Which loop to provide hints for */\n  WhereTerm *pEndRange  /* Hint this end-of-scan boundary term if not NULL */\n){\n  Parse *pParse = pWInfo->pParse;\n  sqlite3 *db = pParse->db;\n  Vdbe *v = pParse->pVdbe;\n  Expr *pExpr = 0;\n  WhereLoop *pLoop = pLevel->pWLoop;\n  int iCur;\n  WhereClause *pWC;\n  WhereTerm *pTerm;\n  int i, j;\n  struct CCurHint sHint;\n  Walker sWalker;\n\n  if( OptimizationDisabled(db, SQLITE_CursorHints) ) return;\n  iCur = pLevel->iTabCur;\n  assert( iCur==pWInfo->pTabList->a[pLevel->iFrom].iCursor );\n  sHint.iTabCur = iCur;\n  sHint.iIdxCur = pLevel->iIdxCur;\n  sHint.pIdx = pLoop->u.btree.pIndex;\n  memset(&sWalker, 0, sizeof(sWalker));\n  sWalker.pParse = pParse;\n  sWalker.u.pCCurHint = &sHint;\n  pWC = &pWInfo->sWC;\n  for(i=0; i<pWC->nTerm; i++){\n    pTerm = &pWC->a[i];\n    if( pTerm->wtFlags & (TERM_VIRTUAL|TERM_CODED) ) continue;\n    if( pTerm->prereqAll & pLevel->notReady ) continue;\n\n    /* Any terms specified as part of the ON(...) clause for any LEFT \n    ** JOIN for which the current table is not the rhs are omitted\n    ** from the cursor-hint. \n    **\n    ** If this table is the rhs of a LEFT JOIN, \"IS\" or \"IS NULL\" terms \n    ** that were specified as part of the WHERE clause must be excluded.\n    ** This is to address the following:\n    **\n    **   SELECT ... t1 LEFT JOIN t2 ON (t1.a=t2.b) WHERE t2.c IS NULL;\n    **\n    ** Say there is a single row in t2 that matches (t1.a=t2.b), but its\n    ** t2.c values is not NULL. If the (t2.c IS NULL) constraint is \n    ** pushed down to the cursor, this row is filtered out, causing\n    ** SQLite to synthesize a row of NULL values. Which does match the\n    ** WHERE clause, and so the query returns a row. Which is incorrect.\n    **\n    ** For the same reason, WHERE terms such as:\n    **\n    **   WHERE 1 = (t2.c IS NULL)\n    **\n    ** are also excluded. See codeCursorHintIsOrFunction() for details.\n    */\n    if( pTabItem->fg.jointype & JT_LEFT ){\n      Expr *pExpr = pTerm->pExpr;\n      if( !ExprHasProperty(pExpr, EP_FromJoin) \n       || pExpr->iRightJoinTable!=pTabItem->iCursor\n      ){\n        sWalker.eCode = 0;\n        sWalker.xExprCallback = codeCursorHintIsOrFunction;\n        sqlite3WalkExpr(&sWalker, pTerm->pExpr);\n        if( sWalker.eCode ) continue;\n      }\n    }else{\n      if( ExprHasProperty(pTerm->pExpr, EP_FromJoin) ) continue;\n    }\n\n    /* All terms in pWLoop->aLTerm[] except pEndRange are used to initialize\n    ** the cursor.  These terms are not needed as hints for a pure range\n    ** scan (that has no == terms) so omit them. */\n    if( pLoop->u.btree.nEq==0 && pTerm!=pEndRange ){\n      for(j=0; j<pLoop->nLTerm && pLoop->aLTerm[j]!=pTerm; j++){}\n      if( j<pLoop->nLTerm ) continue;\n    }\n\n    /* No subqueries or non-deterministic functions allowed */\n    if( sqlite3ExprContainsSubquery(pTerm->pExpr) ) continue;\n\n    /* For an index scan, make sure referenced columns are actually in\n    ** the index. */\n    if( sHint.pIdx!=0 ){\n      sWalker.eCode = 0;\n      sWalker.xExprCallback = codeCursorHintCheckExpr;\n      sqlite3WalkExpr(&sWalker, pTerm->pExpr);\n      if( sWalker.eCode ) continue;\n    }\n\n    /* If we survive all prior tests, that means this term is worth hinting */\n    pExpr = sqlite3ExprAnd(db, pExpr, sqlite3ExprDup(db, pTerm->pExpr, 0));\n  }\n  if( pExpr!=0 ){\n    sWalker.xExprCallback = codeCursorHintFixExpr;\n    sqlite3WalkExpr(&sWalker, pExpr);\n    sqlite3VdbeAddOp4(v, OP_CursorHint, \n                      (sHint.pIdx ? sHint.iIdxCur : sHint.iTabCur), 0, 0,\n                      (const char*)pExpr, P4_EXPR);\n  }\n}\n#else\n# define codeCursorHint(A,B,C,D)  /* No-op */\n#endif /* SQLITE_ENABLE_CURSOR_HINTS */\n\n/*\n** Cursor iCur is open on an intkey b-tree (a table). Register iRowid contains\n** a rowid value just read from cursor iIdxCur, open on index pIdx. This\n** function generates code to do a deferred seek of cursor iCur to the \n** rowid stored in register iRowid.\n**\n** Normally, this is just:\n**\n**   OP_DeferredSeek $iCur $iRowid\n**\n** However, if the scan currently being coded is a branch of an OR-loop and\n** the statement currently being coded is a SELECT, then P3 of OP_DeferredSeek\n** is set to iIdxCur and P4 is set to point to an array of integers\n** containing one entry for each column of the table cursor iCur is open \n** on. For each table column, if the column is the i'th column of the \n** index, then the corresponding array entry is set to (i+1). If the column\n** does not appear in the index at all, the array entry is set to 0.\n*/\nstatic void codeDeferredSeek(\n  WhereInfo *pWInfo,              /* Where clause context */\n  Index *pIdx,                    /* Index scan is using */\n  int iCur,                       /* Cursor for IPK b-tree */\n  int iIdxCur                     /* Index cursor */\n){\n  Parse *pParse = pWInfo->pParse; /* Parse context */\n  Vdbe *v = pParse->pVdbe;        /* Vdbe to generate code within */\n\n  assert( iIdxCur>0 );\n  assert( pIdx->aiColumn[pIdx->nColumn-1]==-1 );\n  \n  sqlite3VdbeAddOp3(v, OP_DeferredSeek, iIdxCur, 0, iCur);\n  if( (pWInfo->wctrlFlags & WHERE_OR_SUBCLAUSE)\n   && DbMaskAllZero(sqlite3ParseToplevel(pParse)->writeMask)\n  ){\n    int i;\n    Table *pTab = pIdx->pTable;\n    int *ai = (int*)sqlite3DbMallocZero(pParse->db, sizeof(int)*(pTab->nCol+1));\n    if( ai ){\n      ai[0] = pTab->nCol;\n      for(i=0; i<pIdx->nColumn-1; i++){\n        assert( pIdx->aiColumn[i]<pTab->nCol );\n        if( pIdx->aiColumn[i]>=0 ) ai[pIdx->aiColumn[i]+1] = i+1;\n      }\n      sqlite3VdbeChangeP4(v, -1, (char*)ai, P4_INTARRAY);\n    }\n  }\n}\n\n/*\n** If the expression passed as the second argument is a vector, generate\n** code to write the first nReg elements of the vector into an array\n** of registers starting with iReg.\n**\n** If the expression is not a vector, then nReg must be passed 1. In\n** this case, generate code to evaluate the expression and leave the\n** result in register iReg.\n*/\nstatic void codeExprOrVector(Parse *pParse, Expr *p, int iReg, int nReg){\n  assert( nReg>0 );\n  if( p && sqlite3ExprIsVector(p) ){\n#ifndef SQLITE_OMIT_SUBQUERY\n    if( (p->flags & EP_xIsSelect) ){\n      Vdbe *v = pParse->pVdbe;\n      int iSelect;\n      assert( p->op==TK_SELECT );\n      iSelect = sqlite3CodeSubselect(pParse, p);\n      sqlite3VdbeAddOp3(v, OP_Copy, iSelect, iReg, nReg-1);\n    }else\n#endif\n    {\n      int i;\n      ExprList *pList = p->x.pList;\n      assert( nReg<=pList->nExpr );\n      for(i=0; i<nReg; i++){\n        sqlite3ExprCode(pParse, pList->a[i].pExpr, iReg+i);\n      }\n    }\n  }else{\n    assert( nReg==1 );\n    sqlite3ExprCode(pParse, p, iReg);\n  }\n}\n\n/* An instance of the IdxExprTrans object carries information about a\n** mapping from an expression on table columns into a column in an index\n** down through the Walker.\n*/\ntypedef struct IdxExprTrans {\n  Expr *pIdxExpr;    /* The index expression */\n  int iTabCur;       /* The cursor of the corresponding table */\n  int iIdxCur;       /* The cursor for the index */\n  int iIdxCol;       /* The column for the index */\n} IdxExprTrans;\n\n/* The walker node callback used to transform matching expressions into\n** a reference to an index column for an index on an expression.\n**\n** If pExpr matches, then transform it into a reference to the index column\n** that contains the value of pExpr.\n*/\nstatic int whereIndexExprTransNode(Walker *p, Expr *pExpr){\n  IdxExprTrans *pX = p->u.pIdxTrans;\n  if( sqlite3ExprCompare(0, pExpr, pX->pIdxExpr, pX->iTabCur)==0 ){\n    pExpr->op = TK_COLUMN;\n    pExpr->iTable = pX->iIdxCur;\n    pExpr->iColumn = pX->iIdxCol;\n    pExpr->y.pTab = 0;\n    return WRC_Prune;\n  }else{\n    return WRC_Continue;\n  }\n}\n\n/*\n** For an indexes on expression X, locate every instance of expression X\n** in pExpr and change that subexpression into a reference to the appropriate\n** column of the index.\n*/\nstatic void whereIndexExprTrans(\n  Index *pIdx,      /* The Index */\n  int iTabCur,      /* Cursor of the table that is being indexed */\n  int iIdxCur,      /* Cursor of the index itself */\n  WhereInfo *pWInfo /* Transform expressions in this WHERE clause */\n){\n  int iIdxCol;               /* Column number of the index */\n  ExprList *aColExpr;        /* Expressions that are indexed */\n  Walker w;\n  IdxExprTrans x;\n  aColExpr = pIdx->aColExpr;\n  if( aColExpr==0 ) return;  /* Not an index on expressions */\n  memset(&w, 0, sizeof(w));\n  w.xExprCallback = whereIndexExprTransNode;\n  w.u.pIdxTrans = &x;\n  x.iTabCur = iTabCur;\n  x.iIdxCur = iIdxCur;\n  for(iIdxCol=0; iIdxCol<aColExpr->nExpr; iIdxCol++){\n    if( pIdx->aiColumn[iIdxCol]!=XN_EXPR ) continue;\n    assert( aColExpr->a[iIdxCol].pExpr!=0 );\n    x.iIdxCol = iIdxCol;\n    x.pIdxExpr = aColExpr->a[iIdxCol].pExpr;\n    sqlite3WalkExpr(&w, pWInfo->pWhere);\n    sqlite3WalkExprList(&w, pWInfo->pOrderBy);\n    sqlite3WalkExprList(&w, pWInfo->pResultSet);\n  }\n}\n\n/*\n** Generate code for the start of the iLevel-th loop in the WHERE clause\n** implementation described by pWInfo.\n*/\nSQLITE_PRIVATE Bitmask sqlite3WhereCodeOneLoopStart(\n  Parse *pParse,       /* Parsing context */\n  Vdbe *v,             /* Prepared statement under construction */\n  WhereInfo *pWInfo,   /* Complete information about the WHERE clause */\n  int iLevel,          /* Which level of pWInfo->a[] should be coded */\n  WhereLevel *pLevel,  /* The current level pointer */\n  Bitmask notReady     /* Which tables are currently available */\n){\n  int j, k;            /* Loop counters */\n  int iCur;            /* The VDBE cursor for the table */\n  int addrNxt;         /* Where to jump to continue with the next IN case */\n  int bRev;            /* True if we need to scan in reverse order */\n  WhereLoop *pLoop;    /* The WhereLoop object being coded */\n  WhereClause *pWC;    /* Decomposition of the entire WHERE clause */\n  WhereTerm *pTerm;               /* A WHERE clause term */\n  sqlite3 *db;                    /* Database connection */\n  struct SrcList_item *pTabItem;  /* FROM clause term being coded */\n  int addrBrk;                    /* Jump here to break out of the loop */\n  int addrHalt;                   /* addrBrk for the outermost loop */\n  int addrCont;                   /* Jump here to continue with next cycle */\n  int iRowidReg = 0;        /* Rowid is stored in this register, if not zero */\n  int iReleaseReg = 0;      /* Temp register to free before returning */\n  Index *pIdx = 0;          /* Index used by loop (if any) */\n  int iLoop;                /* Iteration of constraint generator loop */\n\n  pWC = &pWInfo->sWC;\n  db = pParse->db;\n  pLoop = pLevel->pWLoop;\n  pTabItem = &pWInfo->pTabList->a[pLevel->iFrom];\n  iCur = pTabItem->iCursor;\n  pLevel->notReady = notReady & ~sqlite3WhereGetMask(&pWInfo->sMaskSet, iCur);\n  bRev = (pWInfo->revMask>>iLevel)&1;\n  VdbeModuleComment((v, \"Begin WHERE-loop%d: %s\",iLevel,pTabItem->pTab->zName));\n\n  /* Create labels for the \"break\" and \"continue\" instructions\n  ** for the current loop.  Jump to addrBrk to break out of a loop.\n  ** Jump to cont to go immediately to the next iteration of the\n  ** loop.\n  **\n  ** When there is an IN operator, we also have a \"addrNxt\" label that\n  ** means to continue with the next IN value combination.  When\n  ** there are no IN operators in the constraints, the \"addrNxt\" label\n  ** is the same as \"addrBrk\".\n  */\n  addrBrk = pLevel->addrBrk = pLevel->addrNxt = sqlite3VdbeMakeLabel(pParse);\n  addrCont = pLevel->addrCont = sqlite3VdbeMakeLabel(pParse);\n\n  /* If this is the right table of a LEFT OUTER JOIN, allocate and\n  ** initialize a memory cell that records if this table matches any\n  ** row of the left table of the join.\n  */\n  assert( (pWInfo->wctrlFlags & WHERE_OR_SUBCLAUSE)\n       || pLevel->iFrom>0 || (pTabItem[0].fg.jointype & JT_LEFT)==0\n  );\n  if( pLevel->iFrom>0 && (pTabItem[0].fg.jointype & JT_LEFT)!=0 ){\n    pLevel->iLeftJoin = ++pParse->nMem;\n    sqlite3VdbeAddOp2(v, OP_Integer, 0, pLevel->iLeftJoin);\n    VdbeComment((v, \"init LEFT JOIN no-match flag\"));\n  }\n\n  /* Compute a safe address to jump to if we discover that the table for\n  ** this loop is empty and can never contribute content. */\n  for(j=iLevel; j>0 && pWInfo->a[j].iLeftJoin==0; j--){}\n  addrHalt = pWInfo->a[j].addrBrk;\n\n  /* Special case of a FROM clause subquery implemented as a co-routine */\n  if( pTabItem->fg.viaCoroutine ){\n    int regYield = pTabItem->regReturn;\n    sqlite3VdbeAddOp3(v, OP_InitCoroutine, regYield, 0, pTabItem->addrFillSub);\n    pLevel->p2 =  sqlite3VdbeAddOp2(v, OP_Yield, regYield, addrBrk);\n    VdbeCoverage(v);\n    VdbeComment((v, \"next row of %s\", pTabItem->pTab->zName));\n    pLevel->op = OP_Goto;\n  }else\n\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n  if(  (pLoop->wsFlags & WHERE_VIRTUALTABLE)!=0 ){\n    /* Case 1:  The table is a virtual-table.  Use the VFilter and VNext\n    **          to access the data.\n    */\n    int iReg;   /* P3 Value for OP_VFilter */\n    int addrNotFound;\n    int nConstraint = pLoop->nLTerm;\n    int iIn;    /* Counter for IN constraints */\n\n    iReg = sqlite3GetTempRange(pParse, nConstraint+2);\n    addrNotFound = pLevel->addrBrk;\n    for(j=0; j<nConstraint; j++){\n      int iTarget = iReg+j+2;\n      pTerm = pLoop->aLTerm[j];\n      if( NEVER(pTerm==0) ) continue;\n      if( pTerm->eOperator & WO_IN ){\n        codeEqualityTerm(pParse, pTerm, pLevel, j, bRev, iTarget);\n        addrNotFound = pLevel->addrNxt;\n      }else{\n        Expr *pRight = pTerm->pExpr->pRight;\n        codeExprOrVector(pParse, pRight, iTarget, 1);\n      }\n    }\n    sqlite3VdbeAddOp2(v, OP_Integer, pLoop->u.vtab.idxNum, iReg);\n    sqlite3VdbeAddOp2(v, OP_Integer, nConstraint, iReg+1);\n    sqlite3VdbeAddOp4(v, OP_VFilter, iCur, addrNotFound, iReg,\n                      pLoop->u.vtab.idxStr,\n                      pLoop->u.vtab.needFree ? P4_DYNAMIC : P4_STATIC);\n    VdbeCoverage(v);\n    pLoop->u.vtab.needFree = 0;\n    pLevel->p1 = iCur;\n    pLevel->op = pWInfo->eOnePass ? OP_Noop : OP_VNext;\n    pLevel->p2 = sqlite3VdbeCurrentAddr(v);\n    iIn = pLevel->u.in.nIn;\n    for(j=nConstraint-1; j>=0; j--){\n      pTerm = pLoop->aLTerm[j];\n      if( j<16 && (pLoop->u.vtab.omitMask>>j)&1 ){\n        disableTerm(pLevel, pTerm);\n      }else if( (pTerm->eOperator & WO_IN)!=0 ){\n        Expr *pCompare;  /* The comparison operator */\n        Expr *pRight;    /* RHS of the comparison */\n        VdbeOp *pOp;     /* Opcode to access the value of the IN constraint */\n\n        /* Reload the constraint value into reg[iReg+j+2].  The same value\n        ** was loaded into the same register prior to the OP_VFilter, but\n        ** the xFilter implementation might have changed the datatype or\n        ** encoding of the value in the register, so it *must* be reloaded. */\n        assert( pLevel->u.in.aInLoop!=0 || db->mallocFailed );\n        if( !db->mallocFailed ){\n          assert( iIn>0 );\n          pOp = sqlite3VdbeGetOp(v, pLevel->u.in.aInLoop[--iIn].addrInTop);\n          assert( pOp->opcode==OP_Column || pOp->opcode==OP_Rowid );\n          assert( pOp->opcode!=OP_Column || pOp->p3==iReg+j+2 );\n          assert( pOp->opcode!=OP_Rowid || pOp->p2==iReg+j+2 );\n          testcase( pOp->opcode==OP_Rowid );\n          sqlite3VdbeAddOp3(v, pOp->opcode, pOp->p1, pOp->p2, pOp->p3);\n        }\n\n        /* Generate code that will continue to the next row if \n        ** the IN constraint is not satisfied */\n        pCompare = sqlite3PExpr(pParse, TK_EQ, 0, 0);\n        assert( pCompare!=0 || db->mallocFailed );\n        if( pCompare ){\n          pCompare->pLeft = pTerm->pExpr->pLeft;\n          pCompare->pRight = pRight = sqlite3Expr(db, TK_REGISTER, 0);\n          if( pRight ){\n            pRight->iTable = iReg+j+2;\n            sqlite3ExprIfFalse(pParse, pCompare, pLevel->addrCont, 0);\n          }\n          pCompare->pLeft = 0;\n          sqlite3ExprDelete(db, pCompare);\n        }\n      }\n    }\n    /* These registers need to be preserved in case there is an IN operator\n    ** loop.  So we could deallocate the registers here (and potentially\n    ** reuse them later) if (pLoop->wsFlags & WHERE_IN_ABLE)==0.  But it seems\n    ** simpler and safer to simply not reuse the registers.\n    **\n    **    sqlite3ReleaseTempRange(pParse, iReg, nConstraint+2);\n    */\n  }else\n#endif /* SQLITE_OMIT_VIRTUALTABLE */\n\n  if( (pLoop->wsFlags & WHERE_IPK)!=0\n   && (pLoop->wsFlags & (WHERE_COLUMN_IN|WHERE_COLUMN_EQ))!=0\n  ){\n    /* Case 2:  We can directly reference a single row using an\n    **          equality comparison against the ROWID field.  Or\n    **          we reference multiple rows using a \"rowid IN (...)\"\n    **          construct.\n    */\n    assert( pLoop->u.btree.nEq==1 );\n    pTerm = pLoop->aLTerm[0];\n    assert( pTerm!=0 );\n    assert( pTerm->pExpr!=0 );\n    testcase( pTerm->wtFlags & TERM_VIRTUAL );\n    iReleaseReg = ++pParse->nMem;\n    iRowidReg = codeEqualityTerm(pParse, pTerm, pLevel, 0, bRev, iReleaseReg);\n    if( iRowidReg!=iReleaseReg ) sqlite3ReleaseTempReg(pParse, iReleaseReg);\n    addrNxt = pLevel->addrNxt;\n    sqlite3VdbeAddOp3(v, OP_SeekRowid, iCur, addrNxt, iRowidReg);\n    VdbeCoverage(v);\n    pLevel->op = OP_Noop;\n    if( (pTerm->prereqAll & pLevel->notReady)==0 ){\n      pTerm->wtFlags |= TERM_CODED;\n    }\n  }else if( (pLoop->wsFlags & WHERE_IPK)!=0\n         && (pLoop->wsFlags & WHERE_COLUMN_RANGE)!=0\n  ){\n    /* Case 3:  We have an inequality comparison against the ROWID field.\n    */\n    int testOp = OP_Noop;\n    int start;\n    int memEndValue = 0;\n    WhereTerm *pStart, *pEnd;\n\n    j = 0;\n    pStart = pEnd = 0;\n    if( pLoop->wsFlags & WHERE_BTM_LIMIT ) pStart = pLoop->aLTerm[j++];\n    if( pLoop->wsFlags & WHERE_TOP_LIMIT ) pEnd = pLoop->aLTerm[j++];\n    assert( pStart!=0 || pEnd!=0 );\n    if( bRev ){\n      pTerm = pStart;\n      pStart = pEnd;\n      pEnd = pTerm;\n    }\n    codeCursorHint(pTabItem, pWInfo, pLevel, pEnd);\n    if( pStart ){\n      Expr *pX;             /* The expression that defines the start bound */\n      int r1, rTemp;        /* Registers for holding the start boundary */\n      int op;               /* Cursor seek operation */\n\n      /* The following constant maps TK_xx codes into corresponding \n      ** seek opcodes.  It depends on a particular ordering of TK_xx\n      */\n      const u8 aMoveOp[] = {\n           /* TK_GT */  OP_SeekGT,\n           /* TK_LE */  OP_SeekLE,\n           /* TK_LT */  OP_SeekLT,\n           /* TK_GE */  OP_SeekGE\n      };\n      assert( TK_LE==TK_GT+1 );      /* Make sure the ordering.. */\n      assert( TK_LT==TK_GT+2 );      /*  ... of the TK_xx values... */\n      assert( TK_GE==TK_GT+3 );      /*  ... is correcct. */\n\n      assert( (pStart->wtFlags & TERM_VNULL)==0 );\n      testcase( pStart->wtFlags & TERM_VIRTUAL );\n      pX = pStart->pExpr;\n      assert( pX!=0 );\n      testcase( pStart->leftCursor!=iCur ); /* transitive constraints */\n      if( sqlite3ExprIsVector(pX->pRight) ){\n        r1 = rTemp = sqlite3GetTempReg(pParse);\n        codeExprOrVector(pParse, pX->pRight, r1, 1);\n        testcase( pX->op==TK_GT );\n        testcase( pX->op==TK_GE );\n        testcase( pX->op==TK_LT );\n        testcase( pX->op==TK_LE );\n        op = aMoveOp[((pX->op - TK_GT - 1) & 0x3) | 0x1];\n        assert( pX->op!=TK_GT || op==OP_SeekGE );\n        assert( pX->op!=TK_GE || op==OP_SeekGE );\n        assert( pX->op!=TK_LT || op==OP_SeekLE );\n        assert( pX->op!=TK_LE || op==OP_SeekLE );\n      }else{\n        r1 = sqlite3ExprCodeTemp(pParse, pX->pRight, &rTemp);\n        disableTerm(pLevel, pStart);\n        op = aMoveOp[(pX->op - TK_GT)];\n      }\n      sqlite3VdbeAddOp3(v, op, iCur, addrBrk, r1);\n      VdbeComment((v, \"pk\"));\n      VdbeCoverageIf(v, pX->op==TK_GT);\n      VdbeCoverageIf(v, pX->op==TK_LE);\n      VdbeCoverageIf(v, pX->op==TK_LT);\n      VdbeCoverageIf(v, pX->op==TK_GE);\n      sqlite3ReleaseTempReg(pParse, rTemp);\n    }else{\n      sqlite3VdbeAddOp2(v, bRev ? OP_Last : OP_Rewind, iCur, addrHalt);\n      VdbeCoverageIf(v, bRev==0);\n      VdbeCoverageIf(v, bRev!=0);\n    }\n    if( pEnd ){\n      Expr *pX;\n      pX = pEnd->pExpr;\n      assert( pX!=0 );\n      assert( (pEnd->wtFlags & TERM_VNULL)==0 );\n      testcase( pEnd->leftCursor!=iCur ); /* Transitive constraints */\n      testcase( pEnd->wtFlags & TERM_VIRTUAL );\n      memEndValue = ++pParse->nMem;\n      codeExprOrVector(pParse, pX->pRight, memEndValue, 1);\n      if( 0==sqlite3ExprIsVector(pX->pRight) \n       && (pX->op==TK_LT || pX->op==TK_GT) \n      ){\n        testOp = bRev ? OP_Le : OP_Ge;\n      }else{\n        testOp = bRev ? OP_Lt : OP_Gt;\n      }\n      if( 0==sqlite3ExprIsVector(pX->pRight) ){\n        disableTerm(pLevel, pEnd);\n      }\n    }\n    start = sqlite3VdbeCurrentAddr(v);\n    pLevel->op = bRev ? OP_Prev : OP_Next;\n    pLevel->p1 = iCur;\n    pLevel->p2 = start;\n    assert( pLevel->p5==0 );\n    if( testOp!=OP_Noop ){\n      iRowidReg = ++pParse->nMem;\n      sqlite3VdbeAddOp2(v, OP_Rowid, iCur, iRowidReg);\n      sqlite3VdbeAddOp3(v, testOp, memEndValue, addrBrk, iRowidReg);\n      VdbeCoverageIf(v, testOp==OP_Le);\n      VdbeCoverageIf(v, testOp==OP_Lt);\n      VdbeCoverageIf(v, testOp==OP_Ge);\n      VdbeCoverageIf(v, testOp==OP_Gt);\n      sqlite3VdbeChangeP5(v, SQLITE_AFF_NUMERIC | SQLITE_JUMPIFNULL);\n    }\n  }else if( pLoop->wsFlags & WHERE_INDEXED ){\n    /* Case 4: A scan using an index.\n    **\n    **         The WHERE clause may contain zero or more equality \n    **         terms (\"==\" or \"IN\" operators) that refer to the N\n    **         left-most columns of the index. It may also contain\n    **         inequality constraints (>, <, >= or <=) on the indexed\n    **         column that immediately follows the N equalities. Only \n    **         the right-most column can be an inequality - the rest must\n    **         use the \"==\" and \"IN\" operators. For example, if the \n    **         index is on (x,y,z), then the following clauses are all \n    **         optimized:\n    **\n    **            x=5\n    **            x=5 AND y=10\n    **            x=5 AND y<10\n    **            x=5 AND y>5 AND y<10\n    **            x=5 AND y=5 AND z<=10\n    **\n    **         The z<10 term of the following cannot be used, only\n    **         the x=5 term:\n    **\n    **            x=5 AND z<10\n    **\n    **         N may be zero if there are inequality constraints.\n    **         If there are no inequality constraints, then N is at\n    **         least one.\n    **\n    **         This case is also used when there are no WHERE clause\n    **         constraints but an index is selected anyway, in order\n    **         to force the output order to conform to an ORDER BY.\n    */  \n    static const u8 aStartOp[] = {\n      0,\n      0,\n      OP_Rewind,           /* 2: (!start_constraints && startEq &&  !bRev) */\n      OP_Last,             /* 3: (!start_constraints && startEq &&   bRev) */\n      OP_SeekGT,           /* 4: (start_constraints  && !startEq && !bRev) */\n      OP_SeekLT,           /* 5: (start_constraints  && !startEq &&  bRev) */\n      OP_SeekGE,           /* 6: (start_constraints  &&  startEq && !bRev) */\n      OP_SeekLE            /* 7: (start_constraints  &&  startEq &&  bRev) */\n    };\n    static const u8 aEndOp[] = {\n      OP_IdxGE,            /* 0: (end_constraints && !bRev && !endEq) */\n      OP_IdxGT,            /* 1: (end_constraints && !bRev &&  endEq) */\n      OP_IdxLE,            /* 2: (end_constraints &&  bRev && !endEq) */\n      OP_IdxLT,            /* 3: (end_constraints &&  bRev &&  endEq) */\n    };\n    u16 nEq = pLoop->u.btree.nEq;     /* Number of == or IN terms */\n    u16 nBtm = pLoop->u.btree.nBtm;   /* Length of BTM vector */\n    u16 nTop = pLoop->u.btree.nTop;   /* Length of TOP vector */\n    int regBase;                 /* Base register holding constraint values */\n    WhereTerm *pRangeStart = 0;  /* Inequality constraint at range start */\n    WhereTerm *pRangeEnd = 0;    /* Inequality constraint at range end */\n    int startEq;                 /* True if range start uses ==, >= or <= */\n    int endEq;                   /* True if range end uses ==, >= or <= */\n    int start_constraints;       /* Start of range is constrained */\n    int nConstraint;             /* Number of constraint terms */\n    int iIdxCur;                 /* The VDBE cursor for the index */\n    int nExtraReg = 0;           /* Number of extra registers needed */\n    int op;                      /* Instruction opcode */\n    char *zStartAff;             /* Affinity for start of range constraint */\n    char *zEndAff = 0;           /* Affinity for end of range constraint */\n    u8 bSeekPastNull = 0;        /* True to seek past initial nulls */\n    u8 bStopAtNull = 0;          /* Add condition to terminate at NULLs */\n    int omitTable;               /* True if we use the index only */\n\n\n    pIdx = pLoop->u.btree.pIndex;\n    iIdxCur = pLevel->iIdxCur;\n    assert( nEq>=pLoop->nSkip );\n\n    /* If this loop satisfies a sort order (pOrderBy) request that \n    ** was passed to this function to implement a \"SELECT min(x) ...\" \n    ** query, then the caller will only allow the loop to run for\n    ** a single iteration. This means that the first row returned\n    ** should not have a NULL value stored in 'x'. If column 'x' is\n    ** the first one after the nEq equality constraints in the index,\n    ** this requires some special handling.\n    */\n    assert( pWInfo->pOrderBy==0\n         || pWInfo->pOrderBy->nExpr==1\n         || (pWInfo->wctrlFlags&WHERE_ORDERBY_MIN)==0 );\n    if( (pWInfo->wctrlFlags&WHERE_ORDERBY_MIN)!=0\n     && pWInfo->nOBSat>0\n     && (pIdx->nKeyCol>nEq)\n    ){\n      assert( pLoop->nSkip==0 );\n      bSeekPastNull = 1;\n      nExtraReg = 1;\n    }\n\n    /* Find any inequality constraint terms for the start and end \n    ** of the range. \n    */\n    j = nEq;\n    if( pLoop->wsFlags & WHERE_BTM_LIMIT ){\n      pRangeStart = pLoop->aLTerm[j++];\n      nExtraReg = MAX(nExtraReg, pLoop->u.btree.nBtm);\n      /* Like optimization range constraints always occur in pairs */\n      assert( (pRangeStart->wtFlags & TERM_LIKEOPT)==0 || \n              (pLoop->wsFlags & WHERE_TOP_LIMIT)!=0 );\n    }\n    if( pLoop->wsFlags & WHERE_TOP_LIMIT ){\n      pRangeEnd = pLoop->aLTerm[j++];\n      nExtraReg = MAX(nExtraReg, pLoop->u.btree.nTop);\n#ifndef SQLITE_LIKE_DOESNT_MATCH_BLOBS\n      if( (pRangeEnd->wtFlags & TERM_LIKEOPT)!=0 ){\n        assert( pRangeStart!=0 );                     /* LIKE opt constraints */\n        assert( pRangeStart->wtFlags & TERM_LIKEOPT );   /* occur in pairs */\n        pLevel->iLikeRepCntr = (u32)++pParse->nMem;\n        sqlite3VdbeAddOp2(v, OP_Integer, 1, (int)pLevel->iLikeRepCntr);\n        VdbeComment((v, \"LIKE loop counter\"));\n        pLevel->addrLikeRep = sqlite3VdbeCurrentAddr(v);\n        /* iLikeRepCntr actually stores 2x the counter register number.  The\n        ** bottom bit indicates whether the search order is ASC or DESC. */\n        testcase( bRev );\n        testcase( pIdx->aSortOrder[nEq]==SQLITE_SO_DESC );\n        assert( (bRev & ~1)==0 );\n        pLevel->iLikeRepCntr <<=1;\n        pLevel->iLikeRepCntr |= bRev ^ (pIdx->aSortOrder[nEq]==SQLITE_SO_DESC);\n      }\n#endif\n      if( pRangeStart==0 ){\n        j = pIdx->aiColumn[nEq];\n        if( (j>=0 && pIdx->pTable->aCol[j].notNull==0) || j==XN_EXPR ){\n          bSeekPastNull = 1;\n        }\n      }\n    }\n    assert( pRangeEnd==0 || (pRangeEnd->wtFlags & TERM_VNULL)==0 );\n\n    /* If we are doing a reverse order scan on an ascending index, or\n    ** a forward order scan on a descending index, interchange the \n    ** start and end terms (pRangeStart and pRangeEnd).\n    */\n    if( (nEq<pIdx->nKeyCol && bRev==(pIdx->aSortOrder[nEq]==SQLITE_SO_ASC))\n     || (bRev && pIdx->nKeyCol==nEq)\n    ){\n      SWAP(WhereTerm *, pRangeEnd, pRangeStart);\n      SWAP(u8, bSeekPastNull, bStopAtNull);\n      SWAP(u8, nBtm, nTop);\n    }\n\n    /* Generate code to evaluate all constraint terms using == or IN\n    ** and store the values of those terms in an array of registers\n    ** starting at regBase.\n    */\n    codeCursorHint(pTabItem, pWInfo, pLevel, pRangeEnd);\n    regBase = codeAllEqualityTerms(pParse,pLevel,bRev,nExtraReg,&zStartAff);\n    assert( zStartAff==0 || sqlite3Strlen30(zStartAff)>=nEq );\n    if( zStartAff && nTop ){\n      zEndAff = sqlite3DbStrDup(db, &zStartAff[nEq]);\n    }\n    addrNxt = pLevel->addrNxt;\n\n    testcase( pRangeStart && (pRangeStart->eOperator & WO_LE)!=0 );\n    testcase( pRangeStart && (pRangeStart->eOperator & WO_GE)!=0 );\n    testcase( pRangeEnd && (pRangeEnd->eOperator & WO_LE)!=0 );\n    testcase( pRangeEnd && (pRangeEnd->eOperator & WO_GE)!=0 );\n    startEq = !pRangeStart || pRangeStart->eOperator & (WO_LE|WO_GE);\n    endEq =   !pRangeEnd || pRangeEnd->eOperator & (WO_LE|WO_GE);\n    start_constraints = pRangeStart || nEq>0;\n\n    /* Seek the index cursor to the start of the range. */\n    nConstraint = nEq;\n    if( pRangeStart ){\n      Expr *pRight = pRangeStart->pExpr->pRight;\n      codeExprOrVector(pParse, pRight, regBase+nEq, nBtm);\n      whereLikeOptimizationStringFixup(v, pLevel, pRangeStart);\n      if( (pRangeStart->wtFlags & TERM_VNULL)==0\n       && sqlite3ExprCanBeNull(pRight)\n      ){\n        sqlite3VdbeAddOp2(v, OP_IsNull, regBase+nEq, addrNxt);\n        VdbeCoverage(v);\n      }\n      if( zStartAff ){\n        updateRangeAffinityStr(pRight, nBtm, &zStartAff[nEq]);\n      }  \n      nConstraint += nBtm;\n      testcase( pRangeStart->wtFlags & TERM_VIRTUAL );\n      if( sqlite3ExprIsVector(pRight)==0 ){\n        disableTerm(pLevel, pRangeStart);\n      }else{\n        startEq = 1;\n      }\n      bSeekPastNull = 0;\n    }else if( bSeekPastNull ){\n      sqlite3VdbeAddOp2(v, OP_Null, 0, regBase+nEq);\n      nConstraint++;\n      startEq = 0;\n      start_constraints = 1;\n    }\n    codeApplyAffinity(pParse, regBase, nConstraint - bSeekPastNull, zStartAff);\n    if( pLoop->nSkip>0 && nConstraint==pLoop->nSkip ){\n      /* The skip-scan logic inside the call to codeAllEqualityConstraints()\n      ** above has already left the cursor sitting on the correct row,\n      ** so no further seeking is needed */\n    }else{\n      if( pLoop->wsFlags & WHERE_IN_EARLYOUT ){\n        sqlite3VdbeAddOp1(v, OP_SeekHit, iIdxCur);\n      }\n      op = aStartOp[(start_constraints<<2) + (startEq<<1) + bRev];\n      assert( op!=0 );\n      sqlite3VdbeAddOp4Int(v, op, iIdxCur, addrNxt, regBase, nConstraint);\n      VdbeCoverage(v);\n      VdbeCoverageIf(v, op==OP_Rewind);  testcase( op==OP_Rewind );\n      VdbeCoverageIf(v, op==OP_Last);    testcase( op==OP_Last );\n      VdbeCoverageIf(v, op==OP_SeekGT);  testcase( op==OP_SeekGT );\n      VdbeCoverageIf(v, op==OP_SeekGE);  testcase( op==OP_SeekGE );\n      VdbeCoverageIf(v, op==OP_SeekLE);  testcase( op==OP_SeekLE );\n      VdbeCoverageIf(v, op==OP_SeekLT);  testcase( op==OP_SeekLT );\n    }\n\n    /* Load the value for the inequality constraint at the end of the\n    ** range (if any).\n    */\n    nConstraint = nEq;\n    if( pRangeEnd ){\n      Expr *pRight = pRangeEnd->pExpr->pRight;\n      codeExprOrVector(pParse, pRight, regBase+nEq, nTop);\n      whereLikeOptimizationStringFixup(v, pLevel, pRangeEnd);\n      if( (pRangeEnd->wtFlags & TERM_VNULL)==0\n       && sqlite3ExprCanBeNull(pRight)\n      ){\n        sqlite3VdbeAddOp2(v, OP_IsNull, regBase+nEq, addrNxt);\n        VdbeCoverage(v);\n      }\n      if( zEndAff ){\n        updateRangeAffinityStr(pRight, nTop, zEndAff);\n        codeApplyAffinity(pParse, regBase+nEq, nTop, zEndAff);\n      }else{\n        assert( pParse->db->mallocFailed );\n      }\n      nConstraint += nTop;\n      testcase( pRangeEnd->wtFlags & TERM_VIRTUAL );\n\n      if( sqlite3ExprIsVector(pRight)==0 ){\n        disableTerm(pLevel, pRangeEnd);\n      }else{\n        endEq = 1;\n      }\n    }else if( bStopAtNull ){\n      sqlite3VdbeAddOp2(v, OP_Null, 0, regBase+nEq);\n      endEq = 0;\n      nConstraint++;\n    }\n    sqlite3DbFree(db, zStartAff);\n    sqlite3DbFree(db, zEndAff);\n\n    /* Top of the loop body */\n    pLevel->p2 = sqlite3VdbeCurrentAddr(v);\n\n    /* Check if the index cursor is past the end of the range. */\n    if( nConstraint ){\n      op = aEndOp[bRev*2 + endEq];\n      sqlite3VdbeAddOp4Int(v, op, iIdxCur, addrNxt, regBase, nConstraint);\n      testcase( op==OP_IdxGT );  VdbeCoverageIf(v, op==OP_IdxGT );\n      testcase( op==OP_IdxGE );  VdbeCoverageIf(v, op==OP_IdxGE );\n      testcase( op==OP_IdxLT );  VdbeCoverageIf(v, op==OP_IdxLT );\n      testcase( op==OP_IdxLE );  VdbeCoverageIf(v, op==OP_IdxLE );\n    }\n\n    if( pLoop->wsFlags & WHERE_IN_EARLYOUT ){\n      sqlite3VdbeAddOp2(v, OP_SeekHit, iIdxCur, 1);\n    }\n\n    /* Seek the table cursor, if required */\n    omitTable = (pLoop->wsFlags & WHERE_IDX_ONLY)!=0 \n           && (pWInfo->wctrlFlags & WHERE_OR_SUBCLAUSE)==0;\n    if( omitTable ){\n      /* pIdx is a covering index.  No need to access the main table. */\n    }else if( HasRowid(pIdx->pTable) ){\n      if( (pWInfo->wctrlFlags & WHERE_SEEK_TABLE) || (\n          (pWInfo->wctrlFlags & WHERE_SEEK_UNIQ_TABLE) \n       && (pWInfo->eOnePass==ONEPASS_SINGLE)\n      )){\n        iRowidReg = ++pParse->nMem;\n        sqlite3VdbeAddOp2(v, OP_IdxRowid, iIdxCur, iRowidReg);\n        sqlite3VdbeAddOp3(v, OP_NotExists, iCur, 0, iRowidReg);\n        VdbeCoverage(v);\n      }else{\n        codeDeferredSeek(pWInfo, pIdx, iCur, iIdxCur);\n      }\n    }else if( iCur!=iIdxCur ){\n      Index *pPk = sqlite3PrimaryKeyIndex(pIdx->pTable);\n      iRowidReg = sqlite3GetTempRange(pParse, pPk->nKeyCol);\n      for(j=0; j<pPk->nKeyCol; j++){\n        k = sqlite3ColumnOfIndex(pIdx, pPk->aiColumn[j]);\n        sqlite3VdbeAddOp3(v, OP_Column, iIdxCur, k, iRowidReg+j);\n      }\n      sqlite3VdbeAddOp4Int(v, OP_NotFound, iCur, addrCont,\n                           iRowidReg, pPk->nKeyCol); VdbeCoverage(v);\n    }\n\n    /* If pIdx is an index on one or more expressions, then look through\n    ** all the expressions in pWInfo and try to transform matching expressions\n    ** into reference to index columns.\n    **\n    ** Do not do this for the RHS of a LEFT JOIN. This is because the \n    ** expression may be evaluated after OP_NullRow has been executed on\n    ** the cursor. In this case it is important to do the full evaluation,\n    ** as the result of the expression may not be NULL, even if all table\n    ** column values are.  https://www.sqlite.org/src/info/7fa8049685b50b5a\n    **\n    ** Also, do not do this when processing one index an a multi-index\n    ** OR clause, since the transformation will become invalid once we\n    ** move forward to the next index.\n    ** https://sqlite.org/src/info/4e8e4857d32d401f\n    */\n    if( pLevel->iLeftJoin==0 && (pWInfo->wctrlFlags & WHERE_OR_SUBCLAUSE)==0 ){\n      whereIndexExprTrans(pIdx, iCur, iIdxCur, pWInfo);\n    }\n\n    /* Record the instruction used to terminate the loop. */\n    if( pLoop->wsFlags & WHERE_ONEROW ){\n      pLevel->op = OP_Noop;\n    }else if( bRev ){\n      pLevel->op = OP_Prev;\n    }else{\n      pLevel->op = OP_Next;\n    }\n    pLevel->p1 = iIdxCur;\n    pLevel->p3 = (pLoop->wsFlags&WHERE_UNQ_WANTED)!=0 ? 1:0;\n    if( (pLoop->wsFlags & WHERE_CONSTRAINT)==0 ){\n      pLevel->p5 = SQLITE_STMTSTATUS_FULLSCAN_STEP;\n    }else{\n      assert( pLevel->p5==0 );\n    }\n    if( omitTable ) pIdx = 0;\n  }else\n\n#ifndef SQLITE_OMIT_OR_OPTIMIZATION\n  if( pLoop->wsFlags & WHERE_MULTI_OR ){\n    /* Case 5:  Two or more separately indexed terms connected by OR\n    **\n    ** Example:\n    **\n    **   CREATE TABLE t1(a,b,c,d);\n    **   CREATE INDEX i1 ON t1(a);\n    **   CREATE INDEX i2 ON t1(b);\n    **   CREATE INDEX i3 ON t1(c);\n    **\n    **   SELECT * FROM t1 WHERE a=5 OR b=7 OR (c=11 AND d=13)\n    **\n    ** In the example, there are three indexed terms connected by OR.\n    ** The top of the loop looks like this:\n    **\n    **          Null       1                # Zero the rowset in reg 1\n    **\n    ** Then, for each indexed term, the following. The arguments to\n    ** RowSetTest are such that the rowid of the current row is inserted\n    ** into the RowSet. If it is already present, control skips the\n    ** Gosub opcode and jumps straight to the code generated by WhereEnd().\n    **\n    **        sqlite3WhereBegin(<term>)\n    **          RowSetTest                  # Insert rowid into rowset\n    **          Gosub      2 A\n    **        sqlite3WhereEnd()\n    **\n    ** Following the above, code to terminate the loop. Label A, the target\n    ** of the Gosub above, jumps to the instruction right after the Goto.\n    **\n    **          Null       1                # Zero the rowset in reg 1\n    **          Goto       B                # The loop is finished.\n    **\n    **       A: <loop body>                 # Return data, whatever.\n    **\n    **          Return     2                # Jump back to the Gosub\n    **\n    **       B: <after the loop>\n    **\n    ** Added 2014-05-26: If the table is a WITHOUT ROWID table, then\n    ** use an ephemeral index instead of a RowSet to record the primary\n    ** keys of the rows we have already seen.\n    **\n    */\n    WhereClause *pOrWc;    /* The OR-clause broken out into subterms */\n    SrcList *pOrTab;       /* Shortened table list or OR-clause generation */\n    Index *pCov = 0;             /* Potential covering index (or NULL) */\n    int iCovCur = pParse->nTab++;  /* Cursor used for index scans (if any) */\n\n    int regReturn = ++pParse->nMem;           /* Register used with OP_Gosub */\n    int regRowset = 0;                        /* Register for RowSet object */\n    int regRowid = 0;                         /* Register holding rowid */\n    int iLoopBody = sqlite3VdbeMakeLabel(pParse);/* Start of loop body */\n    int iRetInit;                             /* Address of regReturn init */\n    int untestedTerms = 0;             /* Some terms not completely tested */\n    int ii;                            /* Loop counter */\n    u16 wctrlFlags;                    /* Flags for sub-WHERE clause */\n    Expr *pAndExpr = 0;                /* An \".. AND (...)\" expression */\n    Table *pTab = pTabItem->pTab;\n\n    pTerm = pLoop->aLTerm[0];\n    assert( pTerm!=0 );\n    assert( pTerm->eOperator & WO_OR );\n    assert( (pTerm->wtFlags & TERM_ORINFO)!=0 );\n    pOrWc = &pTerm->u.pOrInfo->wc;\n    pLevel->op = OP_Return;\n    pLevel->p1 = regReturn;\n\n    /* Set up a new SrcList in pOrTab containing the table being scanned\n    ** by this loop in the a[0] slot and all notReady tables in a[1..] slots.\n    ** This becomes the SrcList in the recursive call to sqlite3WhereBegin().\n    */\n    if( pWInfo->nLevel>1 ){\n      int nNotReady;                 /* The number of notReady tables */\n      struct SrcList_item *origSrc;     /* Original list of tables */\n      nNotReady = pWInfo->nLevel - iLevel - 1;\n      pOrTab = sqlite3StackAllocRaw(db,\n                            sizeof(*pOrTab)+ nNotReady*sizeof(pOrTab->a[0]));\n      if( pOrTab==0 ) return notReady;\n      pOrTab->nAlloc = (u8)(nNotReady + 1);\n      pOrTab->nSrc = pOrTab->nAlloc;\n      memcpy(pOrTab->a, pTabItem, sizeof(*pTabItem));\n      origSrc = pWInfo->pTabList->a;\n      for(k=1; k<=nNotReady; k++){\n        memcpy(&pOrTab->a[k], &origSrc[pLevel[k].iFrom], sizeof(pOrTab->a[k]));\n      }\n    }else{\n      pOrTab = pWInfo->pTabList;\n    }\n\n    /* Initialize the rowset register to contain NULL. An SQL NULL is \n    ** equivalent to an empty rowset.  Or, create an ephemeral index\n    ** capable of holding primary keys in the case of a WITHOUT ROWID.\n    **\n    ** Also initialize regReturn to contain the address of the instruction \n    ** immediately following the OP_Return at the bottom of the loop. This\n    ** is required in a few obscure LEFT JOIN cases where control jumps\n    ** over the top of the loop into the body of it. In this case the \n    ** correct response for the end-of-loop code (the OP_Return) is to \n    ** fall through to the next instruction, just as an OP_Next does if\n    ** called on an uninitialized cursor.\n    */\n    if( (pWInfo->wctrlFlags & WHERE_DUPLICATES_OK)==0 ){\n      if( HasRowid(pTab) ){\n        regRowset = ++pParse->nMem;\n        sqlite3VdbeAddOp2(v, OP_Null, 0, regRowset);\n      }else{\n        Index *pPk = sqlite3PrimaryKeyIndex(pTab);\n        regRowset = pParse->nTab++;\n        sqlite3VdbeAddOp2(v, OP_OpenEphemeral, regRowset, pPk->nKeyCol);\n        sqlite3VdbeSetP4KeyInfo(pParse, pPk);\n      }\n      regRowid = ++pParse->nMem;\n    }\n    iRetInit = sqlite3VdbeAddOp2(v, OP_Integer, 0, regReturn);\n\n    /* If the original WHERE clause is z of the form:  (x1 OR x2 OR ...) AND y\n    ** Then for every term xN, evaluate as the subexpression: xN AND z\n    ** That way, terms in y that are factored into the disjunction will\n    ** be picked up by the recursive calls to sqlite3WhereBegin() below.\n    **\n    ** Actually, each subexpression is converted to \"xN AND w\" where w is\n    ** the \"interesting\" terms of z - terms that did not originate in the\n    ** ON or USING clause of a LEFT JOIN, and terms that are usable as \n    ** indices.\n    **\n    ** This optimization also only applies if the (x1 OR x2 OR ...) term\n    ** is not contained in the ON clause of a LEFT JOIN.\n    ** See ticket http://www.sqlite.org/src/info/f2369304e4\n    */\n    if( pWC->nTerm>1 ){\n      int iTerm;\n      for(iTerm=0; iTerm<pWC->nTerm; iTerm++){\n        Expr *pExpr = pWC->a[iTerm].pExpr;\n        if( &pWC->a[iTerm] == pTerm ) continue;\n        testcase( pWC->a[iTerm].wtFlags & TERM_VIRTUAL );\n        testcase( pWC->a[iTerm].wtFlags & TERM_CODED );\n        if( (pWC->a[iTerm].wtFlags & (TERM_VIRTUAL|TERM_CODED))!=0 ) continue;\n        if( (pWC->a[iTerm].eOperator & WO_ALL)==0 ) continue;\n        testcase( pWC->a[iTerm].wtFlags & TERM_ORINFO );\n        pExpr = sqlite3ExprDup(db, pExpr, 0);\n        pAndExpr = sqlite3ExprAnd(db, pAndExpr, pExpr);\n      }\n      if( pAndExpr ){\n        pAndExpr = sqlite3PExpr(pParse, TK_AND|TKFLG_DONTFOLD, 0, pAndExpr);\n      }\n    }\n\n    /* Run a separate WHERE clause for each term of the OR clause.  After\n    ** eliminating duplicates from other WHERE clauses, the action for each\n    ** sub-WHERE clause is to to invoke the main loop body as a subroutine.\n    */\n    wctrlFlags =  WHERE_OR_SUBCLAUSE | (pWInfo->wctrlFlags & WHERE_SEEK_TABLE);\n    ExplainQueryPlan((pParse, 1, \"MULTI-INDEX OR\"));\n    for(ii=0; ii<pOrWc->nTerm; ii++){\n      WhereTerm *pOrTerm = &pOrWc->a[ii];\n      if( pOrTerm->leftCursor==iCur || (pOrTerm->eOperator & WO_AND)!=0 ){\n        WhereInfo *pSubWInfo;           /* Info for single OR-term scan */\n        Expr *pOrExpr = pOrTerm->pExpr; /* Current OR clause term */\n        int jmp1 = 0;                   /* Address of jump operation */\n        assert( (pTabItem[0].fg.jointype & JT_LEFT)==0 \n             || ExprHasProperty(pOrExpr, EP_FromJoin) \n        );\n        if( pAndExpr ){\n          pAndExpr->pLeft = pOrExpr;\n          pOrExpr = pAndExpr;\n        }\n        /* Loop through table entries that match term pOrTerm. */\n        ExplainQueryPlan((pParse, 1, \"INDEX %d\", ii+1));\n        WHERETRACE(0xffff, (\"Subplan for OR-clause:\\n\"));\n        pSubWInfo = sqlite3WhereBegin(pParse, pOrTab, pOrExpr, 0, 0,\n                                      wctrlFlags, iCovCur);\n        assert( pSubWInfo || pParse->nErr || db->mallocFailed );\n        if( pSubWInfo ){\n          WhereLoop *pSubLoop;\n          int addrExplain = sqlite3WhereExplainOneScan(\n              pParse, pOrTab, &pSubWInfo->a[0], 0\n          );\n          sqlite3WhereAddScanStatus(v, pOrTab, &pSubWInfo->a[0], addrExplain);\n\n          /* This is the sub-WHERE clause body.  First skip over\n          ** duplicate rows from prior sub-WHERE clauses, and record the\n          ** rowid (or PRIMARY KEY) for the current row so that the same\n          ** row will be skipped in subsequent sub-WHERE clauses.\n          */\n          if( (pWInfo->wctrlFlags & WHERE_DUPLICATES_OK)==0 ){\n            int iSet = ((ii==pOrWc->nTerm-1)?-1:ii);\n            if( HasRowid(pTab) ){\n              sqlite3ExprCodeGetColumnOfTable(v, pTab, iCur, -1, regRowid);\n              jmp1 = sqlite3VdbeAddOp4Int(v, OP_RowSetTest, regRowset, 0,\n                                          regRowid, iSet);\n              VdbeCoverage(v);\n            }else{\n              Index *pPk = sqlite3PrimaryKeyIndex(pTab);\n              int nPk = pPk->nKeyCol;\n              int iPk;\n              int r;\n\n              /* Read the PK into an array of temp registers. */\n              r = sqlite3GetTempRange(pParse, nPk);\n              for(iPk=0; iPk<nPk; iPk++){\n                int iCol = pPk->aiColumn[iPk];\n                sqlite3ExprCodeGetColumnOfTable(v, pTab, iCur, iCol, r+iPk);\n              }\n\n              /* Check if the temp table already contains this key. If so,\n              ** the row has already been included in the result set and\n              ** can be ignored (by jumping past the Gosub below). Otherwise,\n              ** insert the key into the temp table and proceed with processing\n              ** the row.\n              **\n              ** Use some of the same optimizations as OP_RowSetTest: If iSet\n              ** is zero, assume that the key cannot already be present in\n              ** the temp table. And if iSet is -1, assume that there is no \n              ** need to insert the key into the temp table, as it will never \n              ** be tested for.  */ \n              if( iSet ){\n                jmp1 = sqlite3VdbeAddOp4Int(v, OP_Found, regRowset, 0, r, nPk);\n                VdbeCoverage(v);\n              }\n              if( iSet>=0 ){\n                sqlite3VdbeAddOp3(v, OP_MakeRecord, r, nPk, regRowid);\n                sqlite3VdbeAddOp4Int(v, OP_IdxInsert, regRowset, regRowid,\n                                     r, nPk);\n                if( iSet ) sqlite3VdbeChangeP5(v, OPFLAG_USESEEKRESULT);\n              }\n\n              /* Release the array of temp registers */\n              sqlite3ReleaseTempRange(pParse, r, nPk);\n            }\n          }\n\n          /* Invoke the main loop body as a subroutine */\n          sqlite3VdbeAddOp2(v, OP_Gosub, regReturn, iLoopBody);\n\n          /* Jump here (skipping the main loop body subroutine) if the\n          ** current sub-WHERE row is a duplicate from prior sub-WHEREs. */\n          if( jmp1 ) sqlite3VdbeJumpHere(v, jmp1);\n\n          /* The pSubWInfo->untestedTerms flag means that this OR term\n          ** contained one or more AND term from a notReady table.  The\n          ** terms from the notReady table could not be tested and will\n          ** need to be tested later.\n          */\n          if( pSubWInfo->untestedTerms ) untestedTerms = 1;\n\n          /* If all of the OR-connected terms are optimized using the same\n          ** index, and the index is opened using the same cursor number\n          ** by each call to sqlite3WhereBegin() made by this loop, it may\n          ** be possible to use that index as a covering index.\n          **\n          ** If the call to sqlite3WhereBegin() above resulted in a scan that\n          ** uses an index, and this is either the first OR-connected term\n          ** processed or the index is the same as that used by all previous\n          ** terms, set pCov to the candidate covering index. Otherwise, set \n          ** pCov to NULL to indicate that no candidate covering index will \n          ** be available.\n          */\n          pSubLoop = pSubWInfo->a[0].pWLoop;\n          assert( (pSubLoop->wsFlags & WHERE_AUTO_INDEX)==0 );\n          if( (pSubLoop->wsFlags & WHERE_INDEXED)!=0\n           && (ii==0 || pSubLoop->u.btree.pIndex==pCov)\n           && (HasRowid(pTab) || !IsPrimaryKeyIndex(pSubLoop->u.btree.pIndex))\n          ){\n            assert( pSubWInfo->a[0].iIdxCur==iCovCur );\n            pCov = pSubLoop->u.btree.pIndex;\n          }else{\n            pCov = 0;\n          }\n\n          /* Finish the loop through table entries that match term pOrTerm. */\n          sqlite3WhereEnd(pSubWInfo);\n          ExplainQueryPlanPop(pParse);\n        }\n      }\n    }\n    ExplainQueryPlanPop(pParse);\n    pLevel->u.pCovidx = pCov;\n    if( pCov ) pLevel->iIdxCur = iCovCur;\n    if( pAndExpr ){\n      pAndExpr->pLeft = 0;\n      sqlite3ExprDelete(db, pAndExpr);\n    }\n    sqlite3VdbeChangeP1(v, iRetInit, sqlite3VdbeCurrentAddr(v));\n    sqlite3VdbeGoto(v, pLevel->addrBrk);\n    sqlite3VdbeResolveLabel(v, iLoopBody);\n\n    if( pWInfo->nLevel>1 ) sqlite3StackFree(db, pOrTab);\n    if( !untestedTerms ) disableTerm(pLevel, pTerm);\n  }else\n#endif /* SQLITE_OMIT_OR_OPTIMIZATION */\n\n  {\n    /* Case 6:  There is no usable index.  We must do a complete\n    **          scan of the entire table.\n    */\n    static const u8 aStep[] = { OP_Next, OP_Prev };\n    static const u8 aStart[] = { OP_Rewind, OP_Last };\n    assert( bRev==0 || bRev==1 );\n    if( pTabItem->fg.isRecursive ){\n      /* Tables marked isRecursive have only a single row that is stored in\n      ** a pseudo-cursor.  No need to Rewind or Next such cursors. */\n      pLevel->op = OP_Noop;\n    }else{\n      codeCursorHint(pTabItem, pWInfo, pLevel, 0);\n      pLevel->op = aStep[bRev];\n      pLevel->p1 = iCur;\n      pLevel->p2 = 1 + sqlite3VdbeAddOp2(v, aStart[bRev], iCur, addrHalt);\n      VdbeCoverageIf(v, bRev==0);\n      VdbeCoverageIf(v, bRev!=0);\n      pLevel->p5 = SQLITE_STMTSTATUS_FULLSCAN_STEP;\n    }\n  }\n\n#ifdef SQLITE_ENABLE_STMT_SCANSTATUS\n  pLevel->addrVisit = sqlite3VdbeCurrentAddr(v);\n#endif\n\n  /* Insert code to test every subexpression that can be completely\n  ** computed using the current set of tables.\n  **\n  ** This loop may run between one and three times, depending on the\n  ** constraints to be generated. The value of stack variable iLoop\n  ** determines the constraints coded by each iteration, as follows:\n  **\n  ** iLoop==1: Code only expressions that are entirely covered by pIdx.\n  ** iLoop==2: Code remaining expressions that do not contain correlated\n  **           sub-queries.  \n  ** iLoop==3: Code all remaining expressions.\n  **\n  ** An effort is made to skip unnecessary iterations of the loop.\n  */\n  iLoop = (pIdx ? 1 : 2);\n  do{\n    int iNext = 0;                /* Next value for iLoop */\n    for(pTerm=pWC->a, j=pWC->nTerm; j>0; j--, pTerm++){\n      Expr *pE;\n      int skipLikeAddr = 0;\n      testcase( pTerm->wtFlags & TERM_VIRTUAL );\n      testcase( pTerm->wtFlags & TERM_CODED );\n      if( pTerm->wtFlags & (TERM_VIRTUAL|TERM_CODED) ) continue;\n      if( (pTerm->prereqAll & pLevel->notReady)!=0 ){\n        testcase( pWInfo->untestedTerms==0\n            && (pWInfo->wctrlFlags & WHERE_OR_SUBCLAUSE)!=0 );\n        pWInfo->untestedTerms = 1;\n        continue;\n      }\n      pE = pTerm->pExpr;\n      assert( pE!=0 );\n      if( (pTabItem->fg.jointype&JT_LEFT) && !ExprHasProperty(pE,EP_FromJoin) ){\n        continue;\n      }\n      \n      if( iLoop==1 && !sqlite3ExprCoveredByIndex(pE, pLevel->iTabCur, pIdx) ){\n        iNext = 2;\n        continue;\n      }\n      if( iLoop<3 && (pTerm->wtFlags & TERM_VARSELECT) ){\n        if( iNext==0 ) iNext = 3;\n        continue;\n      }\n\n      if( (pTerm->wtFlags & TERM_LIKECOND)!=0 ){\n        /* If the TERM_LIKECOND flag is set, that means that the range search\n        ** is sufficient to guarantee that the LIKE operator is true, so we\n        ** can skip the call to the like(A,B) function.  But this only works\n        ** for strings.  So do not skip the call to the function on the pass\n        ** that compares BLOBs. */\n#ifdef SQLITE_LIKE_DOESNT_MATCH_BLOBS\n        continue;\n#else\n        u32 x = pLevel->iLikeRepCntr;\n        if( x>0 ){\n          skipLikeAddr = sqlite3VdbeAddOp1(v, (x&1)?OP_IfNot:OP_If,(int)(x>>1));\n        }\n        VdbeCoverage(v);\n#endif\n      }\n#ifdef WHERETRACE_ENABLED /* 0xffff */\n      if( sqlite3WhereTrace ){\n        VdbeNoopComment((v, \"WhereTerm[%d] (%p) priority=%d\",\n                         pWC->nTerm-j, pTerm, iLoop));\n      }\n#endif\n      sqlite3ExprIfFalse(pParse, pE, addrCont, SQLITE_JUMPIFNULL);\n      if( skipLikeAddr ) sqlite3VdbeJumpHere(v, skipLikeAddr);\n      pTerm->wtFlags |= TERM_CODED;\n    }\n    iLoop = iNext;\n  }while( iLoop>0 );\n\n  /* Insert code to test for implied constraints based on transitivity\n  ** of the \"==\" operator.\n  **\n  ** Example: If the WHERE clause contains \"t1.a=t2.b\" and \"t2.b=123\"\n  ** and we are coding the t1 loop and the t2 loop has not yet coded,\n  ** then we cannot use the \"t1.a=t2.b\" constraint, but we can code\n  ** the implied \"t1.a=123\" constraint.\n  */\n  for(pTerm=pWC->a, j=pWC->nTerm; j>0; j--, pTerm++){\n    Expr *pE, sEAlt;\n    WhereTerm *pAlt;\n    if( pTerm->wtFlags & (TERM_VIRTUAL|TERM_CODED) ) continue;\n    if( (pTerm->eOperator & (WO_EQ|WO_IS))==0 ) continue;\n    if( (pTerm->eOperator & WO_EQUIV)==0 ) continue;\n    if( pTerm->leftCursor!=iCur ) continue;\n    if( pLevel->iLeftJoin ) continue;\n    pE = pTerm->pExpr;\n    assert( !ExprHasProperty(pE, EP_FromJoin) );\n    assert( (pTerm->prereqRight & pLevel->notReady)!=0 );\n    pAlt = sqlite3WhereFindTerm(pWC, iCur, pTerm->u.leftColumn, notReady,\n                    WO_EQ|WO_IN|WO_IS, 0);\n    if( pAlt==0 ) continue;\n    if( pAlt->wtFlags & (TERM_CODED) ) continue;\n    if( (pAlt->eOperator & WO_IN) \n     && (pAlt->pExpr->flags & EP_xIsSelect)\n     && (pAlt->pExpr->x.pSelect->pEList->nExpr>1)\n    ){\n      continue;\n    }\n    testcase( pAlt->eOperator & WO_EQ );\n    testcase( pAlt->eOperator & WO_IS );\n    testcase( pAlt->eOperator & WO_IN );\n    VdbeModuleComment((v, \"begin transitive constraint\"));\n    sEAlt = *pAlt->pExpr;\n    sEAlt.pLeft = pE->pLeft;\n    sqlite3ExprIfFalse(pParse, &sEAlt, addrCont, SQLITE_JUMPIFNULL);\n  }\n\n  /* For a LEFT OUTER JOIN, generate code that will record the fact that\n  ** at least one row of the right table has matched the left table.  \n  */\n  if( pLevel->iLeftJoin ){\n    pLevel->addrFirst = sqlite3VdbeCurrentAddr(v);\n    sqlite3VdbeAddOp2(v, OP_Integer, 1, pLevel->iLeftJoin);\n    VdbeComment((v, \"record LEFT JOIN hit\"));\n    for(pTerm=pWC->a, j=0; j<pWC->nTerm; j++, pTerm++){\n      testcase( pTerm->wtFlags & TERM_VIRTUAL );\n      testcase( pTerm->wtFlags & TERM_CODED );\n      if( pTerm->wtFlags & (TERM_VIRTUAL|TERM_CODED) ) continue;\n      if( (pTerm->prereqAll & pLevel->notReady)!=0 ){\n        assert( pWInfo->untestedTerms );\n        continue;\n      }\n      assert( pTerm->pExpr );\n      sqlite3ExprIfFalse(pParse, pTerm->pExpr, addrCont, SQLITE_JUMPIFNULL);\n      pTerm->wtFlags |= TERM_CODED;\n    }\n  }\n\n  return pLevel->notReady;\n}\n\n/************** End of wherecode.c *******************************************/\n/************** Begin file whereexpr.c ***************************************/\n/*\n** 2015-06-08\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This module contains C code that generates VDBE code used to process\n** the WHERE clause of SQL statements.\n**\n** This file was originally part of where.c but was split out to improve\n** readability and editabiliity.  This file contains utility routines for\n** analyzing Expr objects in the WHERE clause.\n*/\n/* #include \"sqliteInt.h\" */\n/* #include \"whereInt.h\" */\n\n/* Forward declarations */\nstatic void exprAnalyze(SrcList*, WhereClause*, int);\n\n/*\n** Deallocate all memory associated with a WhereOrInfo object.\n*/\nstatic void whereOrInfoDelete(sqlite3 *db, WhereOrInfo *p){\n  sqlite3WhereClauseClear(&p->wc);\n  sqlite3DbFree(db, p);\n}\n\n/*\n** Deallocate all memory associated with a WhereAndInfo object.\n*/\nstatic void whereAndInfoDelete(sqlite3 *db, WhereAndInfo *p){\n  sqlite3WhereClauseClear(&p->wc);\n  sqlite3DbFree(db, p);\n}\n\n/*\n** Add a single new WhereTerm entry to the WhereClause object pWC.\n** The new WhereTerm object is constructed from Expr p and with wtFlags.\n** The index in pWC->a[] of the new WhereTerm is returned on success.\n** 0 is returned if the new WhereTerm could not be added due to a memory\n** allocation error.  The memory allocation failure will be recorded in\n** the db->mallocFailed flag so that higher-level functions can detect it.\n**\n** This routine will increase the size of the pWC->a[] array as necessary.\n**\n** If the wtFlags argument includes TERM_DYNAMIC, then responsibility\n** for freeing the expression p is assumed by the WhereClause object pWC.\n** This is true even if this routine fails to allocate a new WhereTerm.\n**\n** WARNING:  This routine might reallocate the space used to store\n** WhereTerms.  All pointers to WhereTerms should be invalidated after\n** calling this routine.  Such pointers may be reinitialized by referencing\n** the pWC->a[] array.\n*/\nstatic int whereClauseInsert(WhereClause *pWC, Expr *p, u16 wtFlags){\n  WhereTerm *pTerm;\n  int idx;\n  testcase( wtFlags & TERM_VIRTUAL );\n  if( pWC->nTerm>=pWC->nSlot ){\n    WhereTerm *pOld = pWC->a;\n    sqlite3 *db = pWC->pWInfo->pParse->db;\n    pWC->a = sqlite3DbMallocRawNN(db, sizeof(pWC->a[0])*pWC->nSlot*2 );\n    if( pWC->a==0 ){\n      if( wtFlags & TERM_DYNAMIC ){\n        sqlite3ExprDelete(db, p);\n      }\n      pWC->a = pOld;\n      return 0;\n    }\n    memcpy(pWC->a, pOld, sizeof(pWC->a[0])*pWC->nTerm);\n    if( pOld!=pWC->aStatic ){\n      sqlite3DbFree(db, pOld);\n    }\n    pWC->nSlot = sqlite3DbMallocSize(db, pWC->a)/sizeof(pWC->a[0]);\n  }\n  pTerm = &pWC->a[idx = pWC->nTerm++];\n  if( p && ExprHasProperty(p, EP_Unlikely) ){\n    pTerm->truthProb = sqlite3LogEst(p->iTable) - 270;\n  }else{\n    pTerm->truthProb = 1;\n  }\n  pTerm->pExpr = sqlite3ExprSkipCollate(p);\n  pTerm->wtFlags = wtFlags;\n  pTerm->pWC = pWC;\n  pTerm->iParent = -1;\n  memset(&pTerm->eOperator, 0,\n         sizeof(WhereTerm) - offsetof(WhereTerm,eOperator));\n  return idx;\n}\n\n/*\n** Return TRUE if the given operator is one of the operators that is\n** allowed for an indexable WHERE clause term.  The allowed operators are\n** \"=\", \"<\", \">\", \"<=\", \">=\", \"IN\", \"IS\", and \"IS NULL\"\n*/\nstatic int allowedOp(int op){\n  assert( TK_GT>TK_EQ && TK_GT<TK_GE );\n  assert( TK_LT>TK_EQ && TK_LT<TK_GE );\n  assert( TK_LE>TK_EQ && TK_LE<TK_GE );\n  assert( TK_GE==TK_EQ+4 );\n  return op==TK_IN || (op>=TK_EQ && op<=TK_GE) || op==TK_ISNULL || op==TK_IS;\n}\n\n/*\n** Commute a comparison operator.  Expressions of the form \"X op Y\"\n** are converted into \"Y op X\".\n**\n** If left/right precedence rules come into play when determining the\n** collating sequence, then COLLATE operators are adjusted to ensure\n** that the collating sequence does not change.  For example:\n** \"Y collate NOCASE op X\" becomes \"X op Y\" because any collation sequence on\n** the left hand side of a comparison overrides any collation sequence \n** attached to the right. For the same reason the EP_Collate flag\n** is not commuted.\n*/\nstatic void exprCommute(Parse *pParse, Expr *pExpr){\n  u16 expRight = (pExpr->pRight->flags & EP_Collate);\n  u16 expLeft = (pExpr->pLeft->flags & EP_Collate);\n  assert( allowedOp(pExpr->op) && pExpr->op!=TK_IN );\n  if( expRight==expLeft ){\n    /* Either X and Y both have COLLATE operator or neither do */\n    if( expRight ){\n      /* Both X and Y have COLLATE operators.  Make sure X is always\n      ** used by clearing the EP_Collate flag from Y. */\n      pExpr->pRight->flags &= ~EP_Collate;\n    }else if( sqlite3ExprCollSeq(pParse, pExpr->pLeft)!=0 ){\n      /* Neither X nor Y have COLLATE operators, but X has a non-default\n      ** collating sequence.  So add the EP_Collate marker on X to cause\n      ** it to be searched first. */\n      pExpr->pLeft->flags |= EP_Collate;\n    }\n  }\n  SWAP(Expr*,pExpr->pRight,pExpr->pLeft);\n  if( pExpr->op>=TK_GT ){\n    assert( TK_LT==TK_GT+2 );\n    assert( TK_GE==TK_LE+2 );\n    assert( TK_GT>TK_EQ );\n    assert( TK_GT<TK_LE );\n    assert( pExpr->op>=TK_GT && pExpr->op<=TK_GE );\n    pExpr->op = ((pExpr->op-TK_GT)^2)+TK_GT;\n  }\n}\n\n/*\n** Translate from TK_xx operator to WO_xx bitmask.\n*/\nstatic u16 operatorMask(int op){\n  u16 c;\n  assert( allowedOp(op) );\n  if( op==TK_IN ){\n    c = WO_IN;\n  }else if( op==TK_ISNULL ){\n    c = WO_ISNULL;\n  }else if( op==TK_IS ){\n    c = WO_IS;\n  }else{\n    assert( (WO_EQ<<(op-TK_EQ)) < 0x7fff );\n    c = (u16)(WO_EQ<<(op-TK_EQ));\n  }\n  assert( op!=TK_ISNULL || c==WO_ISNULL );\n  assert( op!=TK_IN || c==WO_IN );\n  assert( op!=TK_EQ || c==WO_EQ );\n  assert( op!=TK_LT || c==WO_LT );\n  assert( op!=TK_LE || c==WO_LE );\n  assert( op!=TK_GT || c==WO_GT );\n  assert( op!=TK_GE || c==WO_GE );\n  assert( op!=TK_IS || c==WO_IS );\n  return c;\n}\n\n\n#ifndef SQLITE_OMIT_LIKE_OPTIMIZATION\n/*\n** Check to see if the given expression is a LIKE or GLOB operator that\n** can be optimized using inequality constraints.  Return TRUE if it is\n** so and false if not.\n**\n** In order for the operator to be optimizible, the RHS must be a string\n** literal that does not begin with a wildcard.  The LHS must be a column\n** that may only be NULL, a string, or a BLOB, never a number. (This means\n** that virtual tables cannot participate in the LIKE optimization.)  The\n** collating sequence for the column on the LHS must be appropriate for\n** the operator.\n*/\nstatic int isLikeOrGlob(\n  Parse *pParse,    /* Parsing and code generating context */\n  Expr *pExpr,      /* Test this expression */\n  Expr **ppPrefix,  /* Pointer to TK_STRING expression with pattern prefix */\n  int *pisComplete, /* True if the only wildcard is % in the last character */\n  int *pnoCase      /* True if uppercase is equivalent to lowercase */\n){\n  const u8 *z = 0;           /* String on RHS of LIKE operator */\n  Expr *pRight, *pLeft;      /* Right and left size of LIKE operator */\n  ExprList *pList;           /* List of operands to the LIKE operator */\n  u8 c;                      /* One character in z[] */\n  int cnt;                   /* Number of non-wildcard prefix characters */\n  u8 wc[4];                  /* Wildcard characters */\n  sqlite3 *db = pParse->db;  /* Database connection */\n  sqlite3_value *pVal = 0;\n  int op;                    /* Opcode of pRight */\n  int rc;                    /* Result code to return */\n\n  if( !sqlite3IsLikeFunction(db, pExpr, pnoCase, (char*)wc) ){\n    return 0;\n  }\n#ifdef SQLITE_EBCDIC\n  if( *pnoCase ) return 0;\n#endif\n  pList = pExpr->x.pList;\n  pLeft = pList->a[1].pExpr;\n\n  pRight = sqlite3ExprSkipCollate(pList->a[0].pExpr);\n  op = pRight->op;\n  if( op==TK_VARIABLE && (db->flags & SQLITE_EnableQPSG)==0 ){\n    Vdbe *pReprepare = pParse->pReprepare;\n    int iCol = pRight->iColumn;\n    pVal = sqlite3VdbeGetBoundValue(pReprepare, iCol, SQLITE_AFF_BLOB);\n    if( pVal && sqlite3_value_type(pVal)==SQLITE_TEXT ){\n      z = sqlite3_value_text(pVal);\n    }\n    sqlite3VdbeSetVarmask(pParse->pVdbe, iCol);\n    assert( pRight->op==TK_VARIABLE || pRight->op==TK_REGISTER );\n  }else if( op==TK_STRING ){\n    z = (u8*)pRight->u.zToken;\n  }\n  if( z ){\n\n    /* Count the number of prefix characters prior to the first wildcard */\n    cnt = 0;\n    while( (c=z[cnt])!=0 && c!=wc[0] && c!=wc[1] && c!=wc[2] ){\n      cnt++;\n      if( c==wc[3] && z[cnt]!=0 ) cnt++;\n    }\n\n    /* The optimization is possible only if (1) the pattern does not begin\n    ** with a wildcard and if (2) the non-wildcard prefix does not end with\n    ** an (illegal 0xff) character, or (3) the pattern does not consist of\n    ** a single escape character. The second condition is necessary so\n    ** that we can increment the prefix key to find an upper bound for the\n    ** range search. The third is because the caller assumes that the pattern\n    ** consists of at least one character after all escapes have been\n    ** removed.  */\n    if( cnt!=0 && 255!=(u8)z[cnt-1] && (cnt>1 || z[0]!=wc[3]) ){\n      Expr *pPrefix;\n\n      /* A \"complete\" match if the pattern ends with \"*\" or \"%\" */\n      *pisComplete = c==wc[0] && z[cnt+1]==0;\n\n      /* Get the pattern prefix.  Remove all escapes from the prefix. */\n      pPrefix = sqlite3Expr(db, TK_STRING, (char*)z);\n      if( pPrefix ){\n        int iFrom, iTo;\n        char *zNew = pPrefix->u.zToken;\n        zNew[cnt] = 0;\n        for(iFrom=iTo=0; iFrom<cnt; iFrom++){\n          if( zNew[iFrom]==wc[3] ) iFrom++;\n          zNew[iTo++] = zNew[iFrom];\n        }\n        zNew[iTo] = 0;\n\n        /* If the RHS begins with a digit or a minus sign, then the LHS must be\n        ** an ordinary column (not a virtual table column) with TEXT affinity.\n        ** Otherwise the LHS might be numeric and \"lhs >= rhs\" would be false\n        ** even though \"lhs LIKE rhs\" is true.  But if the RHS does not start\n        ** with a digit or '-', then \"lhs LIKE rhs\" will always be false if\n        ** the LHS is numeric and so the optimization still works.\n        **\n        ** 2018-09-10 ticket c94369cae9b561b1f996d0054bfab11389f9d033\n        ** The RHS pattern must not be '/%' because the termination condition\n        ** will then become \"x<'0'\" and if the affinity is numeric, will then\n        ** be converted into \"x<0\", which is incorrect.\n        */\n        if( sqlite3Isdigit(zNew[0])\n         || zNew[0]=='-'\n         || (zNew[0]+1=='0' && iTo==1)\n        ){\n          if( pLeft->op!=TK_COLUMN \n           || sqlite3ExprAffinity(pLeft)!=SQLITE_AFF_TEXT \n           || IsVirtual(pLeft->y.pTab)  /* Value might be numeric */\n          ){\n            sqlite3ExprDelete(db, pPrefix);\n            sqlite3ValueFree(pVal);\n            return 0;\n          }\n        }\n      }\n      *ppPrefix = pPrefix;\n\n      /* If the RHS pattern is a bound parameter, make arrangements to\n      ** reprepare the statement when that parameter is rebound */\n      if( op==TK_VARIABLE ){\n        Vdbe *v = pParse->pVdbe;\n        sqlite3VdbeSetVarmask(v, pRight->iColumn);\n        if( *pisComplete && pRight->u.zToken[1] ){\n          /* If the rhs of the LIKE expression is a variable, and the current\n          ** value of the variable means there is no need to invoke the LIKE\n          ** function, then no OP_Variable will be added to the program.\n          ** This causes problems for the sqlite3_bind_parameter_name()\n          ** API. To work around them, add a dummy OP_Variable here.\n          */ \n          int r1 = sqlite3GetTempReg(pParse);\n          sqlite3ExprCodeTarget(pParse, pRight, r1);\n          sqlite3VdbeChangeP3(v, sqlite3VdbeCurrentAddr(v)-1, 0);\n          sqlite3ReleaseTempReg(pParse, r1);\n        }\n      }\n    }else{\n      z = 0;\n    }\n  }\n\n  rc = (z!=0);\n  sqlite3ValueFree(pVal);\n  return rc;\n}\n#endif /* SQLITE_OMIT_LIKE_OPTIMIZATION */\n\n\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n/*\n** Check to see if the pExpr expression is a form that needs to be passed\n** to the xBestIndex method of virtual tables.  Forms of interest include:\n**\n**          Expression                   Virtual Table Operator\n**          -----------------------      ---------------------------------\n**      1.  column MATCH expr            SQLITE_INDEX_CONSTRAINT_MATCH\n**      2.  column GLOB expr             SQLITE_INDEX_CONSTRAINT_GLOB\n**      3.  column LIKE expr             SQLITE_INDEX_CONSTRAINT_LIKE\n**      4.  column REGEXP expr           SQLITE_INDEX_CONSTRAINT_REGEXP\n**      5.  column != expr               SQLITE_INDEX_CONSTRAINT_NE\n**      6.  expr != column               SQLITE_INDEX_CONSTRAINT_NE\n**      7.  column IS NOT expr           SQLITE_INDEX_CONSTRAINT_ISNOT\n**      8.  expr IS NOT column           SQLITE_INDEX_CONSTRAINT_ISNOT\n**      9.  column IS NOT NULL           SQLITE_INDEX_CONSTRAINT_ISNOTNULL\n**\n** In every case, \"column\" must be a column of a virtual table.  If there\n** is a match, set *ppLeft to the \"column\" expression, set *ppRight to the \n** \"expr\" expression (even though in forms (6) and (8) the column is on the\n** right and the expression is on the left).  Also set *peOp2 to the\n** appropriate virtual table operator.  The return value is 1 or 2 if there\n** is a match.  The usual return is 1, but if the RHS is also a column\n** of virtual table in forms (5) or (7) then return 2.\n**\n** If the expression matches none of the patterns above, return 0.\n*/\nstatic int isAuxiliaryVtabOperator(\n  sqlite3 *db,                    /* Parsing context */\n  Expr *pExpr,                    /* Test this expression */\n  unsigned char *peOp2,           /* OUT: 0 for MATCH, or else an op2 value */\n  Expr **ppLeft,                  /* Column expression to left of MATCH/op2 */\n  Expr **ppRight                  /* Expression to left of MATCH/op2 */\n){\n  if( pExpr->op==TK_FUNCTION ){\n    static const struct Op2 {\n      const char *zOp;\n      unsigned char eOp2;\n    } aOp[] = {\n      { \"match\",  SQLITE_INDEX_CONSTRAINT_MATCH },\n      { \"glob\",   SQLITE_INDEX_CONSTRAINT_GLOB },\n      { \"like\",   SQLITE_INDEX_CONSTRAINT_LIKE },\n      { \"regexp\", SQLITE_INDEX_CONSTRAINT_REGEXP }\n    };\n    ExprList *pList;\n    Expr *pCol;                     /* Column reference */\n    int i;\n\n    pList = pExpr->x.pList;\n    if( pList==0 || pList->nExpr!=2 ){\n      return 0;\n    }\n\n    /* Built-in operators MATCH, GLOB, LIKE, and REGEXP attach to a\n    ** virtual table on their second argument, which is the same as\n    ** the left-hand side operand in their in-fix form.\n    **\n    **       vtab_column MATCH expression\n    **       MATCH(expression,vtab_column)\n    */\n    pCol = pList->a[1].pExpr;\n    if( pCol->op==TK_COLUMN && IsVirtual(pCol->y.pTab) ){\n      for(i=0; i<ArraySize(aOp); i++){\n        if( sqlite3StrICmp(pExpr->u.zToken, aOp[i].zOp)==0 ){\n          *peOp2 = aOp[i].eOp2;\n          *ppRight = pList->a[0].pExpr;\n          *ppLeft = pCol;\n          return 1;\n        }\n      }\n    }\n\n    /* We can also match against the first column of overloaded\n    ** functions where xFindFunction returns a value of at least\n    ** SQLITE_INDEX_CONSTRAINT_FUNCTION.\n    **\n    **      OVERLOADED(vtab_column,expression)\n    **\n    ** Historically, xFindFunction expected to see lower-case function\n    ** names.  But for this use case, xFindFunction is expected to deal\n    ** with function names in an arbitrary case.\n    */\n    pCol = pList->a[0].pExpr;\n    if( pCol->op==TK_COLUMN && IsVirtual(pCol->y.pTab) ){\n      sqlite3_vtab *pVtab;\n      sqlite3_module *pMod;\n      void (*xNotUsed)(sqlite3_context*,int,sqlite3_value**);\n      void *pNotUsed;\n      pVtab = sqlite3GetVTable(db, pCol->y.pTab)->pVtab;\n      assert( pVtab!=0 );\n      assert( pVtab->pModule!=0 );\n      pMod = (sqlite3_module *)pVtab->pModule;\n      if( pMod->xFindFunction!=0 ){\n        i = pMod->xFindFunction(pVtab,2, pExpr->u.zToken, &xNotUsed, &pNotUsed);\n        if( i>=SQLITE_INDEX_CONSTRAINT_FUNCTION ){\n          *peOp2 = i;\n          *ppRight = pList->a[1].pExpr;\n          *ppLeft = pCol;\n          return 1;\n        }\n      }\n    }\n  }else if( pExpr->op==TK_NE || pExpr->op==TK_ISNOT || pExpr->op==TK_NOTNULL ){\n    int res = 0;\n    Expr *pLeft = pExpr->pLeft;\n    Expr *pRight = pExpr->pRight;\n    if( pLeft->op==TK_COLUMN && IsVirtual(pLeft->y.pTab) ){\n      res++;\n    }\n    if( pRight && pRight->op==TK_COLUMN && IsVirtual(pRight->y.pTab) ){\n      res++;\n      SWAP(Expr*, pLeft, pRight);\n    }\n    *ppLeft = pLeft;\n    *ppRight = pRight;\n    if( pExpr->op==TK_NE ) *peOp2 = SQLITE_INDEX_CONSTRAINT_NE;\n    if( pExpr->op==TK_ISNOT ) *peOp2 = SQLITE_INDEX_CONSTRAINT_ISNOT;\n    if( pExpr->op==TK_NOTNULL ) *peOp2 = SQLITE_INDEX_CONSTRAINT_ISNOTNULL;\n    return res;\n  }\n  return 0;\n}\n#endif /* SQLITE_OMIT_VIRTUALTABLE */\n\n/*\n** If the pBase expression originated in the ON or USING clause of\n** a join, then transfer the appropriate markings over to derived.\n*/\nstatic void transferJoinMarkings(Expr *pDerived, Expr *pBase){\n  if( pDerived ){\n    pDerived->flags |= pBase->flags & EP_FromJoin;\n    pDerived->iRightJoinTable = pBase->iRightJoinTable;\n  }\n}\n\n/*\n** Mark term iChild as being a child of term iParent\n*/\nstatic void markTermAsChild(WhereClause *pWC, int iChild, int iParent){\n  pWC->a[iChild].iParent = iParent;\n  pWC->a[iChild].truthProb = pWC->a[iParent].truthProb;\n  pWC->a[iParent].nChild++;\n}\n\n/*\n** Return the N-th AND-connected subterm of pTerm.  Or if pTerm is not\n** a conjunction, then return just pTerm when N==0.  If N is exceeds\n** the number of available subterms, return NULL.\n*/\nstatic WhereTerm *whereNthSubterm(WhereTerm *pTerm, int N){\n  if( pTerm->eOperator!=WO_AND ){\n    return N==0 ? pTerm : 0;\n  }\n  if( N<pTerm->u.pAndInfo->wc.nTerm ){\n    return &pTerm->u.pAndInfo->wc.a[N];\n  }\n  return 0;\n}\n\n/*\n** Subterms pOne and pTwo are contained within WHERE clause pWC.  The\n** two subterms are in disjunction - they are OR-ed together.\n**\n** If these two terms are both of the form:  \"A op B\" with the same\n** A and B values but different operators and if the operators are\n** compatible (if one is = and the other is <, for example) then\n** add a new virtual AND term to pWC that is the combination of the\n** two.\n**\n** Some examples:\n**\n**    x<y OR x=y    -->     x<=y\n**    x=y OR x=y    -->     x=y\n**    x<=y OR x<y   -->     x<=y\n**\n** The following is NOT generated:\n**\n**    x<y OR x>y    -->     x!=y     \n*/\nstatic void whereCombineDisjuncts(\n  SrcList *pSrc,         /* the FROM clause */\n  WhereClause *pWC,      /* The complete WHERE clause */\n  WhereTerm *pOne,       /* First disjunct */\n  WhereTerm *pTwo        /* Second disjunct */\n){\n  u16 eOp = pOne->eOperator | pTwo->eOperator;\n  sqlite3 *db;           /* Database connection (for malloc) */\n  Expr *pNew;            /* New virtual expression */\n  int op;                /* Operator for the combined expression */\n  int idxNew;            /* Index in pWC of the next virtual term */\n\n  if( (pOne->eOperator & (WO_EQ|WO_LT|WO_LE|WO_GT|WO_GE))==0 ) return;\n  if( (pTwo->eOperator & (WO_EQ|WO_LT|WO_LE|WO_GT|WO_GE))==0 ) return;\n  if( (eOp & (WO_EQ|WO_LT|WO_LE))!=eOp\n   && (eOp & (WO_EQ|WO_GT|WO_GE))!=eOp ) return;\n  assert( pOne->pExpr->pLeft!=0 && pOne->pExpr->pRight!=0 );\n  assert( pTwo->pExpr->pLeft!=0 && pTwo->pExpr->pRight!=0 );\n  if( sqlite3ExprCompare(0,pOne->pExpr->pLeft, pTwo->pExpr->pLeft, -1) ) return;\n  if( sqlite3ExprCompare(0,pOne->pExpr->pRight, pTwo->pExpr->pRight,-1) )return;\n  /* If we reach this point, it means the two subterms can be combined */\n  if( (eOp & (eOp-1))!=0 ){\n    if( eOp & (WO_LT|WO_LE) ){\n      eOp = WO_LE;\n    }else{\n      assert( eOp & (WO_GT|WO_GE) );\n      eOp = WO_GE;\n    }\n  }\n  db = pWC->pWInfo->pParse->db;\n  pNew = sqlite3ExprDup(db, pOne->pExpr, 0);\n  if( pNew==0 ) return;\n  for(op=TK_EQ; eOp!=(WO_EQ<<(op-TK_EQ)); op++){ assert( op<TK_GE ); }\n  pNew->op = op;\n  idxNew = whereClauseInsert(pWC, pNew, TERM_VIRTUAL|TERM_DYNAMIC);\n  exprAnalyze(pSrc, pWC, idxNew);\n}\n\n#if !defined(SQLITE_OMIT_OR_OPTIMIZATION) && !defined(SQLITE_OMIT_SUBQUERY)\n/*\n** Analyze a term that consists of two or more OR-connected\n** subterms.  So in:\n**\n**     ... WHERE  (a=5) AND (b=7 OR c=9 OR d=13) AND (d=13)\n**                          ^^^^^^^^^^^^^^^^^^^^\n**\n** This routine analyzes terms such as the middle term in the above example.\n** A WhereOrTerm object is computed and attached to the term under\n** analysis, regardless of the outcome of the analysis.  Hence:\n**\n**     WhereTerm.wtFlags   |=  TERM_ORINFO\n**     WhereTerm.u.pOrInfo  =  a dynamically allocated WhereOrTerm object\n**\n** The term being analyzed must have two or more of OR-connected subterms.\n** A single subterm might be a set of AND-connected sub-subterms.\n** Examples of terms under analysis:\n**\n**     (A)     t1.x=t2.y OR t1.x=t2.z OR t1.y=15 OR t1.z=t3.a+5\n**     (B)     x=expr1 OR expr2=x OR x=expr3\n**     (C)     t1.x=t2.y OR (t1.x=t2.z AND t1.y=15)\n**     (D)     x=expr1 OR (y>11 AND y<22 AND z LIKE '*hello*')\n**     (E)     (p.a=1 AND q.b=2 AND r.c=3) OR (p.x=4 AND q.y=5 AND r.z=6)\n**     (F)     x>A OR (x=A AND y>=B)\n**\n** CASE 1:\n**\n** If all subterms are of the form T.C=expr for some single column of C and\n** a single table T (as shown in example B above) then create a new virtual\n** term that is an equivalent IN expression.  In other words, if the term\n** being analyzed is:\n**\n**      x = expr1  OR  expr2 = x  OR  x = expr3\n**\n** then create a new virtual term like this:\n**\n**      x IN (expr1,expr2,expr3)\n**\n** CASE 2:\n**\n** If there are exactly two disjuncts and one side has x>A and the other side\n** has x=A (for the same x and A) then add a new virtual conjunct term to the\n** WHERE clause of the form \"x>=A\".  Example:\n**\n**      x>A OR (x=A AND y>B)    adds:    x>=A\n**\n** The added conjunct can sometimes be helpful in query planning.\n**\n** CASE 3:\n**\n** If all subterms are indexable by a single table T, then set\n**\n**     WhereTerm.eOperator              =  WO_OR\n**     WhereTerm.u.pOrInfo->indexable  |=  the cursor number for table T\n**\n** A subterm is \"indexable\" if it is of the form\n** \"T.C <op> <expr>\" where C is any column of table T and \n** <op> is one of \"=\", \"<\", \"<=\", \">\", \">=\", \"IS NULL\", or \"IN\".\n** A subterm is also indexable if it is an AND of two or more\n** subsubterms at least one of which is indexable.  Indexable AND \n** subterms have their eOperator set to WO_AND and they have\n** u.pAndInfo set to a dynamically allocated WhereAndTerm object.\n**\n** From another point of view, \"indexable\" means that the subterm could\n** potentially be used with an index if an appropriate index exists.\n** This analysis does not consider whether or not the index exists; that\n** is decided elsewhere.  This analysis only looks at whether subterms\n** appropriate for indexing exist.\n**\n** All examples A through E above satisfy case 3.  But if a term\n** also satisfies case 1 (such as B) we know that the optimizer will\n** always prefer case 1, so in that case we pretend that case 3 is not\n** satisfied.\n**\n** It might be the case that multiple tables are indexable.  For example,\n** (E) above is indexable on tables P, Q, and R.\n**\n** Terms that satisfy case 3 are candidates for lookup by using\n** separate indices to find rowids for each subterm and composing\n** the union of all rowids using a RowSet object.  This is similar\n** to \"bitmap indices\" in other database engines.\n**\n** OTHERWISE:\n**\n** If none of cases 1, 2, or 3 apply, then leave the eOperator set to\n** zero.  This term is not useful for search.\n*/\nstatic void exprAnalyzeOrTerm(\n  SrcList *pSrc,            /* the FROM clause */\n  WhereClause *pWC,         /* the complete WHERE clause */\n  int idxTerm               /* Index of the OR-term to be analyzed */\n){\n  WhereInfo *pWInfo = pWC->pWInfo;        /* WHERE clause processing context */\n  Parse *pParse = pWInfo->pParse;         /* Parser context */\n  sqlite3 *db = pParse->db;               /* Database connection */\n  WhereTerm *pTerm = &pWC->a[idxTerm];    /* The term to be analyzed */\n  Expr *pExpr = pTerm->pExpr;             /* The expression of the term */\n  int i;                                  /* Loop counters */\n  WhereClause *pOrWc;       /* Breakup of pTerm into subterms */\n  WhereTerm *pOrTerm;       /* A Sub-term within the pOrWc */\n  WhereOrInfo *pOrInfo;     /* Additional information associated with pTerm */\n  Bitmask chngToIN;         /* Tables that might satisfy case 1 */\n  Bitmask indexable;        /* Tables that are indexable, satisfying case 2 */\n\n  /*\n  ** Break the OR clause into its separate subterms.  The subterms are\n  ** stored in a WhereClause structure containing within the WhereOrInfo\n  ** object that is attached to the original OR clause term.\n  */\n  assert( (pTerm->wtFlags & (TERM_DYNAMIC|TERM_ORINFO|TERM_ANDINFO))==0 );\n  assert( pExpr->op==TK_OR );\n  pTerm->u.pOrInfo = pOrInfo = sqlite3DbMallocZero(db, sizeof(*pOrInfo));\n  if( pOrInfo==0 ) return;\n  pTerm->wtFlags |= TERM_ORINFO;\n  pOrWc = &pOrInfo->wc;\n  memset(pOrWc->aStatic, 0, sizeof(pOrWc->aStatic));\n  sqlite3WhereClauseInit(pOrWc, pWInfo);\n  sqlite3WhereSplit(pOrWc, pExpr, TK_OR);\n  sqlite3WhereExprAnalyze(pSrc, pOrWc);\n  if( db->mallocFailed ) return;\n  assert( pOrWc->nTerm>=2 );\n\n  /*\n  ** Compute the set of tables that might satisfy cases 1 or 3.\n  */\n  indexable = ~(Bitmask)0;\n  chngToIN = ~(Bitmask)0;\n  for(i=pOrWc->nTerm-1, pOrTerm=pOrWc->a; i>=0 && indexable; i--, pOrTerm++){\n    if( (pOrTerm->eOperator & WO_SINGLE)==0 ){\n      WhereAndInfo *pAndInfo;\n      assert( (pOrTerm->wtFlags & (TERM_ANDINFO|TERM_ORINFO))==0 );\n      chngToIN = 0;\n      pAndInfo = sqlite3DbMallocRawNN(db, sizeof(*pAndInfo));\n      if( pAndInfo ){\n        WhereClause *pAndWC;\n        WhereTerm *pAndTerm;\n        int j;\n        Bitmask b = 0;\n        pOrTerm->u.pAndInfo = pAndInfo;\n        pOrTerm->wtFlags |= TERM_ANDINFO;\n        pOrTerm->eOperator = WO_AND;\n        pAndWC = &pAndInfo->wc;\n        memset(pAndWC->aStatic, 0, sizeof(pAndWC->aStatic));\n        sqlite3WhereClauseInit(pAndWC, pWC->pWInfo);\n        sqlite3WhereSplit(pAndWC, pOrTerm->pExpr, TK_AND);\n        sqlite3WhereExprAnalyze(pSrc, pAndWC);\n        pAndWC->pOuter = pWC;\n        if( !db->mallocFailed ){\n          for(j=0, pAndTerm=pAndWC->a; j<pAndWC->nTerm; j++, pAndTerm++){\n            assert( pAndTerm->pExpr );\n            if( allowedOp(pAndTerm->pExpr->op) \n             || pAndTerm->eOperator==WO_AUX\n            ){\n              b |= sqlite3WhereGetMask(&pWInfo->sMaskSet, pAndTerm->leftCursor);\n            }\n          }\n        }\n        indexable &= b;\n      }\n    }else if( pOrTerm->wtFlags & TERM_COPIED ){\n      /* Skip this term for now.  We revisit it when we process the\n      ** corresponding TERM_VIRTUAL term */\n    }else{\n      Bitmask b;\n      b = sqlite3WhereGetMask(&pWInfo->sMaskSet, pOrTerm->leftCursor);\n      if( pOrTerm->wtFlags & TERM_VIRTUAL ){\n        WhereTerm *pOther = &pOrWc->a[pOrTerm->iParent];\n        b |= sqlite3WhereGetMask(&pWInfo->sMaskSet, pOther->leftCursor);\n      }\n      indexable &= b;\n      if( (pOrTerm->eOperator & WO_EQ)==0 ){\n        chngToIN = 0;\n      }else{\n        chngToIN &= b;\n      }\n    }\n  }\n\n  /*\n  ** Record the set of tables that satisfy case 3.  The set might be\n  ** empty.\n  */\n  pOrInfo->indexable = indexable;\n  if( indexable ){\n    pTerm->eOperator = WO_OR;\n    pWC->hasOr = 1;\n  }else{\n    pTerm->eOperator = WO_OR;\n  }\n\n  /* For a two-way OR, attempt to implementation case 2.\n  */\n  if( indexable && pOrWc->nTerm==2 ){\n    int iOne = 0;\n    WhereTerm *pOne;\n    while( (pOne = whereNthSubterm(&pOrWc->a[0],iOne++))!=0 ){\n      int iTwo = 0;\n      WhereTerm *pTwo;\n      while( (pTwo = whereNthSubterm(&pOrWc->a[1],iTwo++))!=0 ){\n        whereCombineDisjuncts(pSrc, pWC, pOne, pTwo);\n      }\n    }\n  }\n\n  /*\n  ** chngToIN holds a set of tables that *might* satisfy case 1.  But\n  ** we have to do some additional checking to see if case 1 really\n  ** is satisfied.\n  **\n  ** chngToIN will hold either 0, 1, or 2 bits.  The 0-bit case means\n  ** that there is no possibility of transforming the OR clause into an\n  ** IN operator because one or more terms in the OR clause contain\n  ** something other than == on a column in the single table.  The 1-bit\n  ** case means that every term of the OR clause is of the form\n  ** \"table.column=expr\" for some single table.  The one bit that is set\n  ** will correspond to the common table.  We still need to check to make\n  ** sure the same column is used on all terms.  The 2-bit case is when\n  ** the all terms are of the form \"table1.column=table2.column\".  It\n  ** might be possible to form an IN operator with either table1.column\n  ** or table2.column as the LHS if either is common to every term of\n  ** the OR clause.\n  **\n  ** Note that terms of the form \"table.column1=table.column2\" (the\n  ** same table on both sizes of the ==) cannot be optimized.\n  */\n  if( chngToIN ){\n    int okToChngToIN = 0;     /* True if the conversion to IN is valid */\n    int iColumn = -1;         /* Column index on lhs of IN operator */\n    int iCursor = -1;         /* Table cursor common to all terms */\n    int j = 0;                /* Loop counter */\n\n    /* Search for a table and column that appears on one side or the\n    ** other of the == operator in every subterm.  That table and column\n    ** will be recorded in iCursor and iColumn.  There might not be any\n    ** such table and column.  Set okToChngToIN if an appropriate table\n    ** and column is found but leave okToChngToIN false if not found.\n    */\n    for(j=0; j<2 && !okToChngToIN; j++){\n      Expr *pLeft = 0;\n      pOrTerm = pOrWc->a;\n      for(i=pOrWc->nTerm-1; i>=0; i--, pOrTerm++){\n        assert( pOrTerm->eOperator & WO_EQ );\n        pOrTerm->wtFlags &= ~TERM_OR_OK;\n        if( pOrTerm->leftCursor==iCursor ){\n          /* This is the 2-bit case and we are on the second iteration and\n          ** current term is from the first iteration.  So skip this term. */\n          assert( j==1 );\n          continue;\n        }\n        if( (chngToIN & sqlite3WhereGetMask(&pWInfo->sMaskSet,\n                                            pOrTerm->leftCursor))==0 ){\n          /* This term must be of the form t1.a==t2.b where t2 is in the\n          ** chngToIN set but t1 is not.  This term will be either preceded\n          ** or follwed by an inverted copy (t2.b==t1.a).  Skip this term \n          ** and use its inversion. */\n          testcase( pOrTerm->wtFlags & TERM_COPIED );\n          testcase( pOrTerm->wtFlags & TERM_VIRTUAL );\n          assert( pOrTerm->wtFlags & (TERM_COPIED|TERM_VIRTUAL) );\n          continue;\n        }\n        iColumn = pOrTerm->u.leftColumn;\n        iCursor = pOrTerm->leftCursor;\n        pLeft = pOrTerm->pExpr->pLeft;\n        break;\n      }\n      if( i<0 ){\n        /* No candidate table+column was found.  This can only occur\n        ** on the second iteration */\n        assert( j==1 );\n        assert( IsPowerOfTwo(chngToIN) );\n        assert( chngToIN==sqlite3WhereGetMask(&pWInfo->sMaskSet, iCursor) );\n        break;\n      }\n      testcase( j==1 );\n\n      /* We have found a candidate table and column.  Check to see if that\n      ** table and column is common to every term in the OR clause */\n      okToChngToIN = 1;\n      for(; i>=0 && okToChngToIN; i--, pOrTerm++){\n        assert( pOrTerm->eOperator & WO_EQ );\n        if( pOrTerm->leftCursor!=iCursor ){\n          pOrTerm->wtFlags &= ~TERM_OR_OK;\n        }else if( pOrTerm->u.leftColumn!=iColumn || (iColumn==XN_EXPR \n               && sqlite3ExprCompare(pParse, pOrTerm->pExpr->pLeft, pLeft, -1)\n        )){\n          okToChngToIN = 0;\n        }else{\n          int affLeft, affRight;\n          /* If the right-hand side is also a column, then the affinities\n          ** of both right and left sides must be such that no type\n          ** conversions are required on the right.  (Ticket #2249)\n          */\n          affRight = sqlite3ExprAffinity(pOrTerm->pExpr->pRight);\n          affLeft = sqlite3ExprAffinity(pOrTerm->pExpr->pLeft);\n          if( affRight!=0 && affRight!=affLeft ){\n            okToChngToIN = 0;\n          }else{\n            pOrTerm->wtFlags |= TERM_OR_OK;\n          }\n        }\n      }\n    }\n\n    /* At this point, okToChngToIN is true if original pTerm satisfies\n    ** case 1.  In that case, construct a new virtual term that is \n    ** pTerm converted into an IN operator.\n    */\n    if( okToChngToIN ){\n      Expr *pDup;            /* A transient duplicate expression */\n      ExprList *pList = 0;   /* The RHS of the IN operator */\n      Expr *pLeft = 0;       /* The LHS of the IN operator */\n      Expr *pNew;            /* The complete IN operator */\n\n      for(i=pOrWc->nTerm-1, pOrTerm=pOrWc->a; i>=0; i--, pOrTerm++){\n        if( (pOrTerm->wtFlags & TERM_OR_OK)==0 ) continue;\n        assert( pOrTerm->eOperator & WO_EQ );\n        assert( pOrTerm->leftCursor==iCursor );\n        assert( pOrTerm->u.leftColumn==iColumn );\n        pDup = sqlite3ExprDup(db, pOrTerm->pExpr->pRight, 0);\n        pList = sqlite3ExprListAppend(pWInfo->pParse, pList, pDup);\n        pLeft = pOrTerm->pExpr->pLeft;\n      }\n      assert( pLeft!=0 );\n      pDup = sqlite3ExprDup(db, pLeft, 0);\n      pNew = sqlite3PExpr(pParse, TK_IN, pDup, 0);\n      if( pNew ){\n        int idxNew;\n        transferJoinMarkings(pNew, pExpr);\n        assert( !ExprHasProperty(pNew, EP_xIsSelect) );\n        pNew->x.pList = pList;\n        idxNew = whereClauseInsert(pWC, pNew, TERM_VIRTUAL|TERM_DYNAMIC);\n        testcase( idxNew==0 );\n        exprAnalyze(pSrc, pWC, idxNew);\n        /* pTerm = &pWC->a[idxTerm]; // would be needed if pTerm where used again */\n        markTermAsChild(pWC, idxNew, idxTerm);\n      }else{\n        sqlite3ExprListDelete(db, pList);\n      }\n    }\n  }\n}\n#endif /* !SQLITE_OMIT_OR_OPTIMIZATION && !SQLITE_OMIT_SUBQUERY */\n\n/*\n** We already know that pExpr is a binary operator where both operands are\n** column references.  This routine checks to see if pExpr is an equivalence\n** relation:\n**   1.  The SQLITE_Transitive optimization must be enabled\n**   2.  Must be either an == or an IS operator\n**   3.  Not originating in the ON clause of an OUTER JOIN\n**   4.  The affinities of A and B must be compatible\n**   5a. Both operands use the same collating sequence OR\n**   5b. The overall collating sequence is BINARY\n** If this routine returns TRUE, that means that the RHS can be substituted\n** for the LHS anyplace else in the WHERE clause where the LHS column occurs.\n** This is an optimization.  No harm comes from returning 0.  But if 1 is\n** returned when it should not be, then incorrect answers might result.\n*/\nstatic int termIsEquivalence(Parse *pParse, Expr *pExpr){\n  char aff1, aff2;\n  CollSeq *pColl;\n  if( !OptimizationEnabled(pParse->db, SQLITE_Transitive) ) return 0;\n  if( pExpr->op!=TK_EQ && pExpr->op!=TK_IS ) return 0;\n  if( ExprHasProperty(pExpr, EP_FromJoin) ) return 0;\n  aff1 = sqlite3ExprAffinity(pExpr->pLeft);\n  aff2 = sqlite3ExprAffinity(pExpr->pRight);\n  if( aff1!=aff2\n   && (!sqlite3IsNumericAffinity(aff1) || !sqlite3IsNumericAffinity(aff2))\n  ){\n    return 0;\n  }\n  pColl = sqlite3BinaryCompareCollSeq(pParse, pExpr->pLeft, pExpr->pRight);\n  if( sqlite3IsBinary(pColl) ) return 1;\n  return sqlite3ExprCollSeqMatch(pParse, pExpr->pLeft, pExpr->pRight);\n}\n\n/*\n** Recursively walk the expressions of a SELECT statement and generate\n** a bitmask indicating which tables are used in that expression\n** tree.\n*/\nstatic Bitmask exprSelectUsage(WhereMaskSet *pMaskSet, Select *pS){\n  Bitmask mask = 0;\n  while( pS ){\n    SrcList *pSrc = pS->pSrc;\n    mask |= sqlite3WhereExprListUsage(pMaskSet, pS->pEList);\n    mask |= sqlite3WhereExprListUsage(pMaskSet, pS->pGroupBy);\n    mask |= sqlite3WhereExprListUsage(pMaskSet, pS->pOrderBy);\n    mask |= sqlite3WhereExprUsage(pMaskSet, pS->pWhere);\n    mask |= sqlite3WhereExprUsage(pMaskSet, pS->pHaving);\n    if( ALWAYS(pSrc!=0) ){\n      int i;\n      for(i=0; i<pSrc->nSrc; i++){\n        mask |= exprSelectUsage(pMaskSet, pSrc->a[i].pSelect);\n        mask |= sqlite3WhereExprUsage(pMaskSet, pSrc->a[i].pOn);\n        if( pSrc->a[i].fg.isTabFunc ){\n          mask |= sqlite3WhereExprListUsage(pMaskSet, pSrc->a[i].u1.pFuncArg);\n        }\n      }\n    }\n    pS = pS->pPrior;\n  }\n  return mask;\n}\n\n/*\n** Expression pExpr is one operand of a comparison operator that might\n** be useful for indexing.  This routine checks to see if pExpr appears\n** in any index.  Return TRUE (1) if pExpr is an indexed term and return\n** FALSE (0) if not.  If TRUE is returned, also set aiCurCol[0] to the cursor\n** number of the table that is indexed and aiCurCol[1] to the column number\n** of the column that is indexed, or XN_EXPR (-2) if an expression is being\n** indexed.\n**\n** If pExpr is a TK_COLUMN column reference, then this routine always returns\n** true even if that particular column is not indexed, because the column\n** might be added to an automatic index later.\n*/\nstatic SQLITE_NOINLINE int exprMightBeIndexed2(\n  SrcList *pFrom,        /* The FROM clause */\n  Bitmask mPrereq,       /* Bitmask of FROM clause terms referenced by pExpr */\n  int *aiCurCol,         /* Write the referenced table cursor and column here */\n  Expr *pExpr            /* An operand of a comparison operator */\n){\n  Index *pIdx;\n  int i;\n  int iCur;\n  for(i=0; mPrereq>1; i++, mPrereq>>=1){}\n  iCur = pFrom->a[i].iCursor;\n  for(pIdx=pFrom->a[i].pTab->pIndex; pIdx; pIdx=pIdx->pNext){\n    if( pIdx->aColExpr==0 ) continue;\n    for(i=0; i<pIdx->nKeyCol; i++){\n      if( pIdx->aiColumn[i]!=XN_EXPR ) continue;\n      if( sqlite3ExprCompareSkip(pExpr, pIdx->aColExpr->a[i].pExpr, iCur)==0 ){\n        aiCurCol[0] = iCur;\n        aiCurCol[1] = XN_EXPR;\n        return 1;\n      }\n    }\n  }\n  return 0;\n}\nstatic int exprMightBeIndexed(\n  SrcList *pFrom,        /* The FROM clause */\n  Bitmask mPrereq,       /* Bitmask of FROM clause terms referenced by pExpr */\n  int *aiCurCol,         /* Write the referenced table cursor & column here */\n  Expr *pExpr,           /* An operand of a comparison operator */\n  int op                 /* The specific comparison operator */\n){\n  /* If this expression is a vector to the left or right of a \n  ** inequality constraint (>, <, >= or <=), perform the processing \n  ** on the first element of the vector.  */\n  assert( TK_GT+1==TK_LE && TK_GT+2==TK_LT && TK_GT+3==TK_GE );\n  assert( TK_IS<TK_GE && TK_ISNULL<TK_GE && TK_IN<TK_GE );\n  assert( op<=TK_GE );\n  if( pExpr->op==TK_VECTOR && (op>=TK_GT && ALWAYS(op<=TK_GE)) ){\n    pExpr = pExpr->x.pList->a[0].pExpr;\n  }\n\n  if( pExpr->op==TK_COLUMN ){\n    aiCurCol[0] = pExpr->iTable;\n    aiCurCol[1] = pExpr->iColumn;\n    return 1;\n  }\n  if( mPrereq==0 ) return 0;                 /* No table references */\n  if( (mPrereq&(mPrereq-1))!=0 ) return 0;   /* Refs more than one table */\n  return exprMightBeIndexed2(pFrom,mPrereq,aiCurCol,pExpr);\n}\n\n/*\n** The input to this routine is an WhereTerm structure with only the\n** \"pExpr\" field filled in.  The job of this routine is to analyze the\n** subexpression and populate all the other fields of the WhereTerm\n** structure.\n**\n** If the expression is of the form \"<expr> <op> X\" it gets commuted\n** to the standard form of \"X <op> <expr>\".\n**\n** If the expression is of the form \"X <op> Y\" where both X and Y are\n** columns, then the original expression is unchanged and a new virtual\n** term of the form \"Y <op> X\" is added to the WHERE clause and\n** analyzed separately.  The original term is marked with TERM_COPIED\n** and the new term is marked with TERM_DYNAMIC (because it's pExpr\n** needs to be freed with the WhereClause) and TERM_VIRTUAL (because it\n** is a commuted copy of a prior term.)  The original term has nChild=1\n** and the copy has idxParent set to the index of the original term.\n*/\nstatic void exprAnalyze(\n  SrcList *pSrc,            /* the FROM clause */\n  WhereClause *pWC,         /* the WHERE clause */\n  int idxTerm               /* Index of the term to be analyzed */\n){\n  WhereInfo *pWInfo = pWC->pWInfo; /* WHERE clause processing context */\n  WhereTerm *pTerm;                /* The term to be analyzed */\n  WhereMaskSet *pMaskSet;          /* Set of table index masks */\n  Expr *pExpr;                     /* The expression to be analyzed */\n  Bitmask prereqLeft;              /* Prerequesites of the pExpr->pLeft */\n  Bitmask prereqAll;               /* Prerequesites of pExpr */\n  Bitmask extraRight = 0;          /* Extra dependencies on LEFT JOIN */\n  Expr *pStr1 = 0;                 /* RHS of LIKE/GLOB operator */\n  int isComplete = 0;              /* RHS of LIKE/GLOB ends with wildcard */\n  int noCase = 0;                  /* uppercase equivalent to lowercase */\n  int op;                          /* Top-level operator.  pExpr->op */\n  Parse *pParse = pWInfo->pParse;  /* Parsing context */\n  sqlite3 *db = pParse->db;        /* Database connection */\n  unsigned char eOp2 = 0;          /* op2 value for LIKE/REGEXP/GLOB */\n  int nLeft;                       /* Number of elements on left side vector */\n\n  if( db->mallocFailed ){\n    return;\n  }\n  pTerm = &pWC->a[idxTerm];\n  pMaskSet = &pWInfo->sMaskSet;\n  pExpr = pTerm->pExpr;\n  assert( pExpr->op!=TK_AS && pExpr->op!=TK_COLLATE );\n  prereqLeft = sqlite3WhereExprUsage(pMaskSet, pExpr->pLeft);\n  op = pExpr->op;\n  if( op==TK_IN ){\n    assert( pExpr->pRight==0 );\n    if( sqlite3ExprCheckIN(pParse, pExpr) ) return;\n    if( ExprHasProperty(pExpr, EP_xIsSelect) ){\n      pTerm->prereqRight = exprSelectUsage(pMaskSet, pExpr->x.pSelect);\n    }else{\n      pTerm->prereqRight = sqlite3WhereExprListUsage(pMaskSet, pExpr->x.pList);\n    }\n  }else if( op==TK_ISNULL ){\n    pTerm->prereqRight = 0;\n  }else{\n    pTerm->prereqRight = sqlite3WhereExprUsage(pMaskSet, pExpr->pRight);\n  }\n  pMaskSet->bVarSelect = 0;\n  prereqAll = sqlite3WhereExprUsageNN(pMaskSet, pExpr);\n  if( pMaskSet->bVarSelect ) pTerm->wtFlags |= TERM_VARSELECT;\n  if( ExprHasProperty(pExpr, EP_FromJoin) ){\n    Bitmask x = sqlite3WhereGetMask(pMaskSet, pExpr->iRightJoinTable);\n    prereqAll |= x;\n    extraRight = x-1;  /* ON clause terms may not be used with an index\n                       ** on left table of a LEFT JOIN.  Ticket #3015 */\n    if( (prereqAll>>1)>=x ){\n      sqlite3ErrorMsg(pParse, \"ON clause references tables to its right\");\n      return;\n    }\n  }\n  pTerm->prereqAll = prereqAll;\n  pTerm->leftCursor = -1;\n  pTerm->iParent = -1;\n  pTerm->eOperator = 0;\n  if( allowedOp(op) ){\n    int aiCurCol[2];\n    Expr *pLeft = sqlite3ExprSkipCollate(pExpr->pLeft);\n    Expr *pRight = sqlite3ExprSkipCollate(pExpr->pRight);\n    u16 opMask = (pTerm->prereqRight & prereqLeft)==0 ? WO_ALL : WO_EQUIV;\n\n    if( pTerm->iField>0 ){\n      assert( op==TK_IN );\n      assert( pLeft->op==TK_VECTOR );\n      pLeft = pLeft->x.pList->a[pTerm->iField-1].pExpr;\n    }\n\n    if( exprMightBeIndexed(pSrc, prereqLeft, aiCurCol, pLeft, op) ){\n      pTerm->leftCursor = aiCurCol[0];\n      pTerm->u.leftColumn = aiCurCol[1];\n      pTerm->eOperator = operatorMask(op) & opMask;\n    }\n    if( op==TK_IS ) pTerm->wtFlags |= TERM_IS;\n    if( pRight \n     && exprMightBeIndexed(pSrc, pTerm->prereqRight, aiCurCol, pRight, op)\n    ){\n      WhereTerm *pNew;\n      Expr *pDup;\n      u16 eExtraOp = 0;        /* Extra bits for pNew->eOperator */\n      assert( pTerm->iField==0 );\n      if( pTerm->leftCursor>=0 ){\n        int idxNew;\n        pDup = sqlite3ExprDup(db, pExpr, 0);\n        if( db->mallocFailed ){\n          sqlite3ExprDelete(db, pDup);\n          return;\n        }\n        idxNew = whereClauseInsert(pWC, pDup, TERM_VIRTUAL|TERM_DYNAMIC);\n        if( idxNew==0 ) return;\n        pNew = &pWC->a[idxNew];\n        markTermAsChild(pWC, idxNew, idxTerm);\n        if( op==TK_IS ) pNew->wtFlags |= TERM_IS;\n        pTerm = &pWC->a[idxTerm];\n        pTerm->wtFlags |= TERM_COPIED;\n\n        if( termIsEquivalence(pParse, pDup) ){\n          pTerm->eOperator |= WO_EQUIV;\n          eExtraOp = WO_EQUIV;\n        }\n      }else{\n        pDup = pExpr;\n        pNew = pTerm;\n      }\n      exprCommute(pParse, pDup);\n      pNew->leftCursor = aiCurCol[0];\n      pNew->u.leftColumn = aiCurCol[1];\n      testcase( (prereqLeft | extraRight) != prereqLeft );\n      pNew->prereqRight = prereqLeft | extraRight;\n      pNew->prereqAll = prereqAll;\n      pNew->eOperator = (operatorMask(pDup->op) + eExtraOp) & opMask;\n    }\n  }\n\n#ifndef SQLITE_OMIT_BETWEEN_OPTIMIZATION\n  /* If a term is the BETWEEN operator, create two new virtual terms\n  ** that define the range that the BETWEEN implements.  For example:\n  **\n  **      a BETWEEN b AND c\n  **\n  ** is converted into:\n  **\n  **      (a BETWEEN b AND c) AND (a>=b) AND (a<=c)\n  **\n  ** The two new terms are added onto the end of the WhereClause object.\n  ** The new terms are \"dynamic\" and are children of the original BETWEEN\n  ** term.  That means that if the BETWEEN term is coded, the children are\n  ** skipped.  Or, if the children are satisfied by an index, the original\n  ** BETWEEN term is skipped.\n  */\n  else if( pExpr->op==TK_BETWEEN && pWC->op==TK_AND ){\n    ExprList *pList = pExpr->x.pList;\n    int i;\n    static const u8 ops[] = {TK_GE, TK_LE};\n    assert( pList!=0 );\n    assert( pList->nExpr==2 );\n    for(i=0; i<2; i++){\n      Expr *pNewExpr;\n      int idxNew;\n      pNewExpr = sqlite3PExpr(pParse, ops[i], \n                             sqlite3ExprDup(db, pExpr->pLeft, 0),\n                             sqlite3ExprDup(db, pList->a[i].pExpr, 0));\n      transferJoinMarkings(pNewExpr, pExpr);\n      idxNew = whereClauseInsert(pWC, pNewExpr, TERM_VIRTUAL|TERM_DYNAMIC);\n      testcase( idxNew==0 );\n      exprAnalyze(pSrc, pWC, idxNew);\n      pTerm = &pWC->a[idxTerm];\n      markTermAsChild(pWC, idxNew, idxTerm);\n    }\n  }\n#endif /* SQLITE_OMIT_BETWEEN_OPTIMIZATION */\n\n#if !defined(SQLITE_OMIT_OR_OPTIMIZATION) && !defined(SQLITE_OMIT_SUBQUERY)\n  /* Analyze a term that is composed of two or more subterms connected by\n  ** an OR operator.\n  */\n  else if( pExpr->op==TK_OR ){\n    assert( pWC->op==TK_AND );\n    exprAnalyzeOrTerm(pSrc, pWC, idxTerm);\n    pTerm = &pWC->a[idxTerm];\n  }\n#endif /* SQLITE_OMIT_OR_OPTIMIZATION */\n\n#ifndef SQLITE_OMIT_LIKE_OPTIMIZATION\n  /* Add constraints to reduce the search space on a LIKE or GLOB\n  ** operator.\n  **\n  ** A like pattern of the form \"x LIKE 'aBc%'\" is changed into constraints\n  **\n  **          x>='ABC' AND x<'abd' AND x LIKE 'aBc%'\n  **\n  ** The last character of the prefix \"abc\" is incremented to form the\n  ** termination condition \"abd\".  If case is not significant (the default\n  ** for LIKE) then the lower-bound is made all uppercase and the upper-\n  ** bound is made all lowercase so that the bounds also work when comparing\n  ** BLOBs.\n  */\n  if( pWC->op==TK_AND \n   && isLikeOrGlob(pParse, pExpr, &pStr1, &isComplete, &noCase)\n  ){\n    Expr *pLeft;       /* LHS of LIKE/GLOB operator */\n    Expr *pStr2;       /* Copy of pStr1 - RHS of LIKE/GLOB operator */\n    Expr *pNewExpr1;\n    Expr *pNewExpr2;\n    int idxNew1;\n    int idxNew2;\n    const char *zCollSeqName;     /* Name of collating sequence */\n    const u16 wtFlags = TERM_LIKEOPT | TERM_VIRTUAL | TERM_DYNAMIC;\n\n    pLeft = pExpr->x.pList->a[1].pExpr;\n    pStr2 = sqlite3ExprDup(db, pStr1, 0);\n\n    /* Convert the lower bound to upper-case and the upper bound to\n    ** lower-case (upper-case is less than lower-case in ASCII) so that\n    ** the range constraints also work for BLOBs\n    */\n    if( noCase && !pParse->db->mallocFailed ){\n      int i;\n      char c;\n      pTerm->wtFlags |= TERM_LIKE;\n      for(i=0; (c = pStr1->u.zToken[i])!=0; i++){\n        pStr1->u.zToken[i] = sqlite3Toupper(c);\n        pStr2->u.zToken[i] = sqlite3Tolower(c);\n      }\n    }\n\n    if( !db->mallocFailed ){\n      u8 c, *pC;       /* Last character before the first wildcard */\n      pC = (u8*)&pStr2->u.zToken[sqlite3Strlen30(pStr2->u.zToken)-1];\n      c = *pC;\n      if( noCase ){\n        /* The point is to increment the last character before the first\n        ** wildcard.  But if we increment '@', that will push it into the\n        ** alphabetic range where case conversions will mess up the \n        ** inequality.  To avoid this, make sure to also run the full\n        ** LIKE on all candidate expressions by clearing the isComplete flag\n        */\n        if( c=='A'-1 ) isComplete = 0;\n        c = sqlite3UpperToLower[c];\n      }\n      *pC = c + 1;\n    }\n    zCollSeqName = noCase ? \"NOCASE\" : sqlite3StrBINARY;\n    pNewExpr1 = sqlite3ExprDup(db, pLeft, 0);\n    pNewExpr1 = sqlite3PExpr(pParse, TK_GE,\n           sqlite3ExprAddCollateString(pParse,pNewExpr1,zCollSeqName),\n           pStr1);\n    transferJoinMarkings(pNewExpr1, pExpr);\n    idxNew1 = whereClauseInsert(pWC, pNewExpr1, wtFlags);\n    testcase( idxNew1==0 );\n    exprAnalyze(pSrc, pWC, idxNew1);\n    pNewExpr2 = sqlite3ExprDup(db, pLeft, 0);\n    pNewExpr2 = sqlite3PExpr(pParse, TK_LT,\n           sqlite3ExprAddCollateString(pParse,pNewExpr2,zCollSeqName),\n           pStr2);\n    transferJoinMarkings(pNewExpr2, pExpr);\n    idxNew2 = whereClauseInsert(pWC, pNewExpr2, wtFlags);\n    testcase( idxNew2==0 );\n    exprAnalyze(pSrc, pWC, idxNew2);\n    pTerm = &pWC->a[idxTerm];\n    if( isComplete ){\n      markTermAsChild(pWC, idxNew1, idxTerm);\n      markTermAsChild(pWC, idxNew2, idxTerm);\n    }\n  }\n#endif /* SQLITE_OMIT_LIKE_OPTIMIZATION */\n\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n  /* Add a WO_AUX auxiliary term to the constraint set if the\n  ** current expression is of the form \"column OP expr\" where OP\n  ** is an operator that gets passed into virtual tables but which is\n  ** not normally optimized for ordinary tables.  In other words, OP\n  ** is one of MATCH, LIKE, GLOB, REGEXP, !=, IS, IS NOT, or NOT NULL.\n  ** This information is used by the xBestIndex methods of\n  ** virtual tables.  The native query optimizer does not attempt\n  ** to do anything with MATCH functions.\n  */\n  if( pWC->op==TK_AND ){\n    Expr *pRight = 0, *pLeft = 0;\n    int res = isAuxiliaryVtabOperator(db, pExpr, &eOp2, &pLeft, &pRight);\n    while( res-- > 0 ){\n      int idxNew;\n      WhereTerm *pNewTerm;\n      Bitmask prereqColumn, prereqExpr;\n\n      prereqExpr = sqlite3WhereExprUsage(pMaskSet, pRight);\n      prereqColumn = sqlite3WhereExprUsage(pMaskSet, pLeft);\n      if( (prereqExpr & prereqColumn)==0 ){\n        Expr *pNewExpr;\n        pNewExpr = sqlite3PExpr(pParse, TK_MATCH, \n            0, sqlite3ExprDup(db, pRight, 0));\n        if( ExprHasProperty(pExpr, EP_FromJoin) && pNewExpr ){\n          ExprSetProperty(pNewExpr, EP_FromJoin);\n        }\n        idxNew = whereClauseInsert(pWC, pNewExpr, TERM_VIRTUAL|TERM_DYNAMIC);\n        testcase( idxNew==0 );\n        pNewTerm = &pWC->a[idxNew];\n        pNewTerm->prereqRight = prereqExpr;\n        pNewTerm->leftCursor = pLeft->iTable;\n        pNewTerm->u.leftColumn = pLeft->iColumn;\n        pNewTerm->eOperator = WO_AUX;\n        pNewTerm->eMatchOp = eOp2;\n        markTermAsChild(pWC, idxNew, idxTerm);\n        pTerm = &pWC->a[idxTerm];\n        pTerm->wtFlags |= TERM_COPIED;\n        pNewTerm->prereqAll = pTerm->prereqAll;\n      }\n      SWAP(Expr*, pLeft, pRight);\n    }\n  }\n#endif /* SQLITE_OMIT_VIRTUALTABLE */\n\n  /* If there is a vector == or IS term - e.g. \"(a, b) == (?, ?)\" - create\n  ** new terms for each component comparison - \"a = ?\" and \"b = ?\".  The\n  ** new terms completely replace the original vector comparison, which is\n  ** no longer used.\n  **\n  ** This is only required if at least one side of the comparison operation\n  ** is not a sub-select.  */\n  if( pWC->op==TK_AND \n  && (pExpr->op==TK_EQ || pExpr->op==TK_IS)\n  && (nLeft = sqlite3ExprVectorSize(pExpr->pLeft))>1\n  && sqlite3ExprVectorSize(pExpr->pRight)==nLeft\n  && ( (pExpr->pLeft->flags & EP_xIsSelect)==0 \n    || (pExpr->pRight->flags & EP_xIsSelect)==0)\n  ){\n    int i;\n    for(i=0; i<nLeft; i++){\n      int idxNew;\n      Expr *pNew;\n      Expr *pLeft = sqlite3ExprForVectorField(pParse, pExpr->pLeft, i);\n      Expr *pRight = sqlite3ExprForVectorField(pParse, pExpr->pRight, i);\n\n      pNew = sqlite3PExpr(pParse, pExpr->op, pLeft, pRight);\n      transferJoinMarkings(pNew, pExpr);\n      idxNew = whereClauseInsert(pWC, pNew, TERM_DYNAMIC);\n      exprAnalyze(pSrc, pWC, idxNew);\n    }\n    pTerm = &pWC->a[idxTerm];\n    pTerm->wtFlags |= TERM_CODED|TERM_VIRTUAL;  /* Disable the original */\n    pTerm->eOperator = 0;\n  }\n\n  /* If there is a vector IN term - e.g. \"(a, b) IN (SELECT ...)\" - create\n  ** a virtual term for each vector component. The expression object\n  ** used by each such virtual term is pExpr (the full vector IN(...) \n  ** expression). The WhereTerm.iField variable identifies the index within\n  ** the vector on the LHS that the virtual term represents.\n  **\n  ** This only works if the RHS is a simple SELECT, not a compound\n  */\n  if( pWC->op==TK_AND && pExpr->op==TK_IN && pTerm->iField==0\n   && pExpr->pLeft->op==TK_VECTOR\n   && pExpr->x.pSelect->pPrior==0\n  ){\n    int i;\n    for(i=0; i<sqlite3ExprVectorSize(pExpr->pLeft); i++){\n      int idxNew;\n      idxNew = whereClauseInsert(pWC, pExpr, TERM_VIRTUAL);\n      pWC->a[idxNew].iField = i+1;\n      exprAnalyze(pSrc, pWC, idxNew);\n      markTermAsChild(pWC, idxNew, idxTerm);\n    }\n  }\n\n#ifdef SQLITE_ENABLE_STAT3_OR_STAT4\n  /* When sqlite_stat3 histogram data is available an operator of the\n  ** form \"x IS NOT NULL\" can sometimes be evaluated more efficiently\n  ** as \"x>NULL\" if x is not an INTEGER PRIMARY KEY.  So construct a\n  ** virtual term of that form.\n  **\n  ** Note that the virtual term must be tagged with TERM_VNULL.\n  */\n  if( pExpr->op==TK_NOTNULL\n   && pExpr->pLeft->op==TK_COLUMN\n   && pExpr->pLeft->iColumn>=0\n   && !ExprHasProperty(pExpr, EP_FromJoin)\n   && OptimizationEnabled(db, SQLITE_Stat34)\n  ){\n    Expr *pNewExpr;\n    Expr *pLeft = pExpr->pLeft;\n    int idxNew;\n    WhereTerm *pNewTerm;\n\n    pNewExpr = sqlite3PExpr(pParse, TK_GT,\n                            sqlite3ExprDup(db, pLeft, 0),\n                            sqlite3ExprAlloc(db, TK_NULL, 0, 0));\n\n    idxNew = whereClauseInsert(pWC, pNewExpr,\n                              TERM_VIRTUAL|TERM_DYNAMIC|TERM_VNULL);\n    if( idxNew ){\n      pNewTerm = &pWC->a[idxNew];\n      pNewTerm->prereqRight = 0;\n      pNewTerm->leftCursor = pLeft->iTable;\n      pNewTerm->u.leftColumn = pLeft->iColumn;\n      pNewTerm->eOperator = WO_GT;\n      markTermAsChild(pWC, idxNew, idxTerm);\n      pTerm = &pWC->a[idxTerm];\n      pTerm->wtFlags |= TERM_COPIED;\n      pNewTerm->prereqAll = pTerm->prereqAll;\n    }\n  }\n#endif /* SQLITE_ENABLE_STAT3_OR_STAT4 */\n\n  /* Prevent ON clause terms of a LEFT JOIN from being used to drive\n  ** an index for tables to the left of the join.\n  */\n  testcase( pTerm!=&pWC->a[idxTerm] );\n  pTerm = &pWC->a[idxTerm];\n  pTerm->prereqRight |= extraRight;\n}\n\n/***************************************************************************\n** Routines with file scope above.  Interface to the rest of the where.c\n** subsystem follows.\n***************************************************************************/\n\n/*\n** This routine identifies subexpressions in the WHERE clause where\n** each subexpression is separated by the AND operator or some other\n** operator specified in the op parameter.  The WhereClause structure\n** is filled with pointers to subexpressions.  For example:\n**\n**    WHERE  a=='hello' AND coalesce(b,11)<10 AND (c+12!=d OR c==22)\n**           \\________/     \\_______________/     \\________________/\n**            slot[0]            slot[1]               slot[2]\n**\n** The original WHERE clause in pExpr is unaltered.  All this routine\n** does is make slot[] entries point to substructure within pExpr.\n**\n** In the previous sentence and in the diagram, \"slot[]\" refers to\n** the WhereClause.a[] array.  The slot[] array grows as needed to contain\n** all terms of the WHERE clause.\n*/\nSQLITE_PRIVATE void sqlite3WhereSplit(WhereClause *pWC, Expr *pExpr, u8 op){\n  Expr *pE2 = sqlite3ExprSkipCollate(pExpr);\n  pWC->op = op;\n  if( pE2==0 ) return;\n  if( pE2->op!=op ){\n    whereClauseInsert(pWC, pExpr, 0);\n  }else{\n    sqlite3WhereSplit(pWC, pE2->pLeft, op);\n    sqlite3WhereSplit(pWC, pE2->pRight, op);\n  }\n}\n\n/*\n** Initialize a preallocated WhereClause structure.\n*/\nSQLITE_PRIVATE void sqlite3WhereClauseInit(\n  WhereClause *pWC,        /* The WhereClause to be initialized */\n  WhereInfo *pWInfo        /* The WHERE processing context */\n){\n  pWC->pWInfo = pWInfo;\n  pWC->hasOr = 0;\n  pWC->pOuter = 0;\n  pWC->nTerm = 0;\n  pWC->nSlot = ArraySize(pWC->aStatic);\n  pWC->a = pWC->aStatic;\n}\n\n/*\n** Deallocate a WhereClause structure.  The WhereClause structure\n** itself is not freed.  This routine is the inverse of\n** sqlite3WhereClauseInit().\n*/\nSQLITE_PRIVATE void sqlite3WhereClauseClear(WhereClause *pWC){\n  int i;\n  WhereTerm *a;\n  sqlite3 *db = pWC->pWInfo->pParse->db;\n  for(i=pWC->nTerm-1, a=pWC->a; i>=0; i--, a++){\n    if( a->wtFlags & TERM_DYNAMIC ){\n      sqlite3ExprDelete(db, a->pExpr);\n    }\n    if( a->wtFlags & TERM_ORINFO ){\n      whereOrInfoDelete(db, a->u.pOrInfo);\n    }else if( a->wtFlags & TERM_ANDINFO ){\n      whereAndInfoDelete(db, a->u.pAndInfo);\n    }\n  }\n  if( pWC->a!=pWC->aStatic ){\n    sqlite3DbFree(db, pWC->a);\n  }\n}\n\n\n/*\n** These routines walk (recursively) an expression tree and generate\n** a bitmask indicating which tables are used in that expression\n** tree.\n*/\nSQLITE_PRIVATE Bitmask sqlite3WhereExprUsageNN(WhereMaskSet *pMaskSet, Expr *p){\n  Bitmask mask;\n  if( p->op==TK_COLUMN && !ExprHasProperty(p, EP_FixedCol) ){\n    return sqlite3WhereGetMask(pMaskSet, p->iTable);\n  }else if( ExprHasProperty(p, EP_TokenOnly|EP_Leaf) ){\n    assert( p->op!=TK_IF_NULL_ROW );\n    return 0;\n  }\n  mask = (p->op==TK_IF_NULL_ROW) ? sqlite3WhereGetMask(pMaskSet, p->iTable) : 0;\n  if( p->pLeft ) mask |= sqlite3WhereExprUsageNN(pMaskSet, p->pLeft);\n  if( p->pRight ){\n    mask |= sqlite3WhereExprUsageNN(pMaskSet, p->pRight);\n    assert( p->x.pList==0 );\n  }else if( ExprHasProperty(p, EP_xIsSelect) ){\n    if( ExprHasProperty(p, EP_VarSelect) ) pMaskSet->bVarSelect = 1;\n    mask |= exprSelectUsage(pMaskSet, p->x.pSelect);\n  }else if( p->x.pList ){\n    mask |= sqlite3WhereExprListUsage(pMaskSet, p->x.pList);\n  }\n  return mask;\n}\nSQLITE_PRIVATE Bitmask sqlite3WhereExprUsage(WhereMaskSet *pMaskSet, Expr *p){\n  return p ? sqlite3WhereExprUsageNN(pMaskSet,p) : 0;\n}\nSQLITE_PRIVATE Bitmask sqlite3WhereExprListUsage(WhereMaskSet *pMaskSet, ExprList *pList){\n  int i;\n  Bitmask mask = 0;\n  if( pList ){\n    for(i=0; i<pList->nExpr; i++){\n      mask |= sqlite3WhereExprUsage(pMaskSet, pList->a[i].pExpr);\n    }\n  }\n  return mask;\n}\n\n\n/*\n** Call exprAnalyze on all terms in a WHERE clause.  \n**\n** Note that exprAnalyze() might add new virtual terms onto the\n** end of the WHERE clause.  We do not want to analyze these new\n** virtual terms, so start analyzing at the end and work forward\n** so that the added virtual terms are never processed.\n*/\nSQLITE_PRIVATE void sqlite3WhereExprAnalyze(\n  SrcList *pTabList,       /* the FROM clause */\n  WhereClause *pWC         /* the WHERE clause to be analyzed */\n){\n  int i;\n  for(i=pWC->nTerm-1; i>=0; i--){\n    exprAnalyze(pTabList, pWC, i);\n  }\n}\n\n/*\n** For table-valued-functions, transform the function arguments into\n** new WHERE clause terms.  \n**\n** Each function argument translates into an equality constraint against\n** a HIDDEN column in the table.\n*/\nSQLITE_PRIVATE void sqlite3WhereTabFuncArgs(\n  Parse *pParse,                    /* Parsing context */\n  struct SrcList_item *pItem,       /* The FROM clause term to process */\n  WhereClause *pWC                  /* Xfer function arguments to here */\n){\n  Table *pTab;\n  int j, k;\n  ExprList *pArgs;\n  Expr *pColRef;\n  Expr *pTerm;\n  if( pItem->fg.isTabFunc==0 ) return;\n  pTab = pItem->pTab;\n  assert( pTab!=0 );\n  pArgs = pItem->u1.pFuncArg;\n  if( pArgs==0 ) return;\n  for(j=k=0; j<pArgs->nExpr; j++){\n    Expr *pRhs;\n    while( k<pTab->nCol && (pTab->aCol[k].colFlags & COLFLAG_HIDDEN)==0 ){k++;}\n    if( k>=pTab->nCol ){\n      sqlite3ErrorMsg(pParse, \"too many arguments on %s() - max %d\",\n                      pTab->zName, j);\n      return;\n    }\n    pColRef = sqlite3ExprAlloc(pParse->db, TK_COLUMN, 0, 0);\n    if( pColRef==0 ) return;\n    pColRef->iTable = pItem->iCursor;\n    pColRef->iColumn = k++;\n    pColRef->y.pTab = pTab;\n    pRhs = sqlite3PExpr(pParse, TK_UPLUS, \n        sqlite3ExprDup(pParse->db, pArgs->a[j].pExpr, 0), 0);\n    pTerm = sqlite3PExpr(pParse, TK_EQ, pColRef, pRhs);\n    whereClauseInsert(pWC, pTerm, TERM_DYNAMIC);\n  }\n}\n\n/************** End of whereexpr.c *******************************************/\n/************** Begin file where.c *******************************************/\n/*\n** 2001 September 15\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This module contains C code that generates VDBE code used to process\n** the WHERE clause of SQL statements.  This module is responsible for\n** generating the code that loops through a table looking for applicable\n** rows.  Indices are selected and used to speed the search when doing\n** so is applicable.  Because this module is responsible for selecting\n** indices, you might also think of this module as the \"query optimizer\".\n*/\n/* #include \"sqliteInt.h\" */\n/* #include \"whereInt.h\" */\n\n/*\n** Extra information appended to the end of sqlite3_index_info but not\n** visible to the xBestIndex function, at least not directly.  The\n** sqlite3_vtab_collation() interface knows how to reach it, however.\n**\n** This object is not an API and can be changed from one release to the\n** next.  As long as allocateIndexInfo() and sqlite3_vtab_collation()\n** agree on the structure, all will be well.\n*/\ntypedef struct HiddenIndexInfo HiddenIndexInfo;\nstruct HiddenIndexInfo {\n  WhereClause *pWC;   /* The Where clause being analyzed */\n  Parse *pParse;      /* The parsing context */\n};\n\n/* Forward declaration of methods */\nstatic int whereLoopResize(sqlite3*, WhereLoop*, int);\n\n/* Test variable that can be set to enable WHERE tracing */\n#if defined(SQLITE_TEST) || defined(SQLITE_DEBUG)\n/***/ int sqlite3WhereTrace = 0;\n#endif\n\n\n/*\n** Return the estimated number of output rows from a WHERE clause\n*/\nSQLITE_PRIVATE LogEst sqlite3WhereOutputRowCount(WhereInfo *pWInfo){\n  return pWInfo->nRowOut;\n}\n\n/*\n** Return one of the WHERE_DISTINCT_xxxxx values to indicate how this\n** WHERE clause returns outputs for DISTINCT processing.\n*/\nSQLITE_PRIVATE int sqlite3WhereIsDistinct(WhereInfo *pWInfo){\n  return pWInfo->eDistinct;\n}\n\n/*\n** Return TRUE if the WHERE clause returns rows in ORDER BY order.\n** Return FALSE if the output needs to be sorted.\n*/\nSQLITE_PRIVATE int sqlite3WhereIsOrdered(WhereInfo *pWInfo){\n  return pWInfo->nOBSat;\n}\n\n/*\n** In the ORDER BY LIMIT optimization, if the inner-most loop is known\n** to emit rows in increasing order, and if the last row emitted by the\n** inner-most loop did not fit within the sorter, then we can skip all\n** subsequent rows for the current iteration of the inner loop (because they\n** will not fit in the sorter either) and continue with the second inner\n** loop - the loop immediately outside the inner-most.\n**\n** When a row does not fit in the sorter (because the sorter already\n** holds LIMIT+OFFSET rows that are smaller), then a jump is made to the\n** label returned by this function.\n**\n** If the ORDER BY LIMIT optimization applies, the jump destination should\n** be the continuation for the second-inner-most loop.  If the ORDER BY\n** LIMIT optimization does not apply, then the jump destination should\n** be the continuation for the inner-most loop.\n**\n** It is always safe for this routine to return the continuation of the\n** inner-most loop, in the sense that a correct answer will result.  \n** Returning the continuation the second inner loop is an optimization\n** that might make the code run a little faster, but should not change\n** the final answer.\n*/\nSQLITE_PRIVATE int sqlite3WhereOrderByLimitOptLabel(WhereInfo *pWInfo){\n  WhereLevel *pInner;\n  if( !pWInfo->bOrderedInnerLoop ){\n    /* The ORDER BY LIMIT optimization does not apply.  Jump to the \n    ** continuation of the inner-most loop. */\n    return pWInfo->iContinue;\n  }\n  pInner = &pWInfo->a[pWInfo->nLevel-1];\n  assert( pInner->addrNxt!=0 );\n  return pInner->addrNxt;\n}\n\n/*\n** Return the VDBE address or label to jump to in order to continue\n** immediately with the next row of a WHERE clause.\n*/\nSQLITE_PRIVATE int sqlite3WhereContinueLabel(WhereInfo *pWInfo){\n  assert( pWInfo->iContinue!=0 );\n  return pWInfo->iContinue;\n}\n\n/*\n** Return the VDBE address or label to jump to in order to break\n** out of a WHERE loop.\n*/\nSQLITE_PRIVATE int sqlite3WhereBreakLabel(WhereInfo *pWInfo){\n  return pWInfo->iBreak;\n}\n\n/*\n** Return ONEPASS_OFF (0) if an UPDATE or DELETE statement is unable to\n** operate directly on the rowis returned by a WHERE clause.  Return\n** ONEPASS_SINGLE (1) if the statement can operation directly because only\n** a single row is to be changed.  Return ONEPASS_MULTI (2) if the one-pass\n** optimization can be used on multiple \n**\n** If the ONEPASS optimization is used (if this routine returns true)\n** then also write the indices of open cursors used by ONEPASS\n** into aiCur[0] and aiCur[1].  iaCur[0] gets the cursor of the data\n** table and iaCur[1] gets the cursor used by an auxiliary index.\n** Either value may be -1, indicating that cursor is not used.\n** Any cursors returned will have been opened for writing.\n**\n** aiCur[0] and aiCur[1] both get -1 if the where-clause logic is\n** unable to use the ONEPASS optimization.\n*/\nSQLITE_PRIVATE int sqlite3WhereOkOnePass(WhereInfo *pWInfo, int *aiCur){\n  memcpy(aiCur, pWInfo->aiCurOnePass, sizeof(int)*2);\n#ifdef WHERETRACE_ENABLED\n  if( sqlite3WhereTrace && pWInfo->eOnePass!=ONEPASS_OFF ){\n    sqlite3DebugPrintf(\"%s cursors: %d %d\\n\",\n         pWInfo->eOnePass==ONEPASS_SINGLE ? \"ONEPASS_SINGLE\" : \"ONEPASS_MULTI\",\n         aiCur[0], aiCur[1]);\n  }\n#endif\n  return pWInfo->eOnePass;\n}\n\n/*\n** Move the content of pSrc into pDest\n*/\nstatic void whereOrMove(WhereOrSet *pDest, WhereOrSet *pSrc){\n  pDest->n = pSrc->n;\n  memcpy(pDest->a, pSrc->a, pDest->n*sizeof(pDest->a[0]));\n}\n\n/*\n** Try to insert a new prerequisite/cost entry into the WhereOrSet pSet.\n**\n** The new entry might overwrite an existing entry, or it might be\n** appended, or it might be discarded.  Do whatever is the right thing\n** so that pSet keeps the N_OR_COST best entries seen so far.\n*/\nstatic int whereOrInsert(\n  WhereOrSet *pSet,      /* The WhereOrSet to be updated */\n  Bitmask prereq,        /* Prerequisites of the new entry */\n  LogEst rRun,           /* Run-cost of the new entry */\n  LogEst nOut            /* Number of outputs for the new entry */\n){\n  u16 i;\n  WhereOrCost *p;\n  for(i=pSet->n, p=pSet->a; i>0; i--, p++){\n    if( rRun<=p->rRun && (prereq & p->prereq)==prereq ){\n      goto whereOrInsert_done;\n    }\n    if( p->rRun<=rRun && (p->prereq & prereq)==p->prereq ){\n      return 0;\n    }\n  }\n  if( pSet->n<N_OR_COST ){\n    p = &pSet->a[pSet->n++];\n    p->nOut = nOut;\n  }else{\n    p = pSet->a;\n    for(i=1; i<pSet->n; i++){\n      if( p->rRun>pSet->a[i].rRun ) p = pSet->a + i;\n    }\n    if( p->rRun<=rRun ) return 0;\n  }\nwhereOrInsert_done:\n  p->prereq = prereq;\n  p->rRun = rRun;\n  if( p->nOut>nOut ) p->nOut = nOut;\n  return 1;\n}\n\n/*\n** Return the bitmask for the given cursor number.  Return 0 if\n** iCursor is not in the set.\n*/\nSQLITE_PRIVATE Bitmask sqlite3WhereGetMask(WhereMaskSet *pMaskSet, int iCursor){\n  int i;\n  assert( pMaskSet->n<=(int)sizeof(Bitmask)*8 );\n  for(i=0; i<pMaskSet->n; i++){\n    if( pMaskSet->ix[i]==iCursor ){\n      return MASKBIT(i);\n    }\n  }\n  return 0;\n}\n\n/*\n** Create a new mask for cursor iCursor.\n**\n** There is one cursor per table in the FROM clause.  The number of\n** tables in the FROM clause is limited by a test early in the\n** sqlite3WhereBegin() routine.  So we know that the pMaskSet->ix[]\n** array will never overflow.\n*/\nstatic void createMask(WhereMaskSet *pMaskSet, int iCursor){\n  assert( pMaskSet->n < ArraySize(pMaskSet->ix) );\n  pMaskSet->ix[pMaskSet->n++] = iCursor;\n}\n\n/*\n** Advance to the next WhereTerm that matches according to the criteria\n** established when the pScan object was initialized by whereScanInit().\n** Return NULL if there are no more matching WhereTerms.\n*/\nstatic WhereTerm *whereScanNext(WhereScan *pScan){\n  int iCur;            /* The cursor on the LHS of the term */\n  i16 iColumn;         /* The column on the LHS of the term.  -1 for IPK */\n  Expr *pX;            /* An expression being tested */\n  WhereClause *pWC;    /* Shorthand for pScan->pWC */\n  WhereTerm *pTerm;    /* The term being tested */\n  int k = pScan->k;    /* Where to start scanning */\n\n  assert( pScan->iEquiv<=pScan->nEquiv );\n  pWC = pScan->pWC;\n  while(1){\n    iColumn = pScan->aiColumn[pScan->iEquiv-1];\n    iCur = pScan->aiCur[pScan->iEquiv-1];\n    assert( pWC!=0 );\n    do{\n      for(pTerm=pWC->a+k; k<pWC->nTerm; k++, pTerm++){\n        if( pTerm->leftCursor==iCur\n         && pTerm->u.leftColumn==iColumn\n         && (iColumn!=XN_EXPR\n             || sqlite3ExprCompareSkip(pTerm->pExpr->pLeft,\n                                       pScan->pIdxExpr,iCur)==0)\n         && (pScan->iEquiv<=1 || !ExprHasProperty(pTerm->pExpr, EP_FromJoin))\n        ){\n          if( (pTerm->eOperator & WO_EQUIV)!=0\n           && pScan->nEquiv<ArraySize(pScan->aiCur)\n           && (pX = sqlite3ExprSkipCollate(pTerm->pExpr->pRight))->op==TK_COLUMN\n          ){\n            int j;\n            for(j=0; j<pScan->nEquiv; j++){\n              if( pScan->aiCur[j]==pX->iTable\n               && pScan->aiColumn[j]==pX->iColumn ){\n                  break;\n              }\n            }\n            if( j==pScan->nEquiv ){\n              pScan->aiCur[j] = pX->iTable;\n              pScan->aiColumn[j] = pX->iColumn;\n              pScan->nEquiv++;\n            }\n          }\n          if( (pTerm->eOperator & pScan->opMask)!=0 ){\n            /* Verify the affinity and collating sequence match */\n            if( pScan->zCollName && (pTerm->eOperator & WO_ISNULL)==0 ){\n              CollSeq *pColl;\n              Parse *pParse = pWC->pWInfo->pParse;\n              pX = pTerm->pExpr;\n              if( !sqlite3IndexAffinityOk(pX, pScan->idxaff) ){\n                continue;\n              }\n              assert(pX->pLeft);\n              pColl = sqlite3BinaryCompareCollSeq(pParse,\n                                                  pX->pLeft, pX->pRight);\n              if( pColl==0 ) pColl = pParse->db->pDfltColl;\n              if( sqlite3StrICmp(pColl->zName, pScan->zCollName) ){\n                continue;\n              }\n            }\n            if( (pTerm->eOperator & (WO_EQ|WO_IS))!=0\n             && (pX = pTerm->pExpr->pRight)->op==TK_COLUMN\n             && pX->iTable==pScan->aiCur[0]\n             && pX->iColumn==pScan->aiColumn[0]\n            ){\n              testcase( pTerm->eOperator & WO_IS );\n              continue;\n            }\n            pScan->pWC = pWC;\n            pScan->k = k+1;\n            return pTerm;\n          }\n        }\n      }\n      pWC = pWC->pOuter;\n      k = 0;\n    }while( pWC!=0 );\n    if( pScan->iEquiv>=pScan->nEquiv ) break;\n    pWC = pScan->pOrigWC;\n    k = 0;\n    pScan->iEquiv++;\n  }\n  return 0;\n}\n\n/*\n** This is whereScanInit() for the case of an index on an expression.\n** It is factored out into a separate tail-recursion subroutine so that\n** the normal whereScanInit() routine, which is a high-runner, does not\n** need to push registers onto the stack as part of its prologue.\n*/\nstatic SQLITE_NOINLINE WhereTerm *whereScanInitIndexExpr(WhereScan *pScan){\n  pScan->idxaff = sqlite3ExprAffinity(pScan->pIdxExpr);\n  return whereScanNext(pScan);\n}\n\n/*\n** Initialize a WHERE clause scanner object.  Return a pointer to the\n** first match.  Return NULL if there are no matches.\n**\n** The scanner will be searching the WHERE clause pWC.  It will look\n** for terms of the form \"X <op> <expr>\" where X is column iColumn of table\n** iCur.   Or if pIdx!=0 then X is column iColumn of index pIdx.  pIdx\n** must be one of the indexes of table iCur.\n**\n** The <op> must be one of the operators described by opMask.\n**\n** If the search is for X and the WHERE clause contains terms of the\n** form X=Y then this routine might also return terms of the form\n** \"Y <op> <expr>\".  The number of levels of transitivity is limited,\n** but is enough to handle most commonly occurring SQL statements.\n**\n** If X is not the INTEGER PRIMARY KEY then X must be compatible with\n** index pIdx.\n*/\nstatic WhereTerm *whereScanInit(\n  WhereScan *pScan,       /* The WhereScan object being initialized */\n  WhereClause *pWC,       /* The WHERE clause to be scanned */\n  int iCur,               /* Cursor to scan for */\n  int iColumn,            /* Column to scan for */\n  u32 opMask,             /* Operator(s) to scan for */\n  Index *pIdx             /* Must be compatible with this index */\n){\n  pScan->pOrigWC = pWC;\n  pScan->pWC = pWC;\n  pScan->pIdxExpr = 0;\n  pScan->idxaff = 0;\n  pScan->zCollName = 0;\n  pScan->opMask = opMask;\n  pScan->k = 0;\n  pScan->aiCur[0] = iCur;\n  pScan->nEquiv = 1;\n  pScan->iEquiv = 1;\n  if( pIdx ){\n    int j = iColumn;\n    iColumn = pIdx->aiColumn[j];\n    if( iColumn==XN_EXPR ){\n      pScan->pIdxExpr = pIdx->aColExpr->a[j].pExpr;\n      pScan->zCollName = pIdx->azColl[j];\n      pScan->aiColumn[0] = XN_EXPR;\n      return whereScanInitIndexExpr(pScan);\n    }else if( iColumn==pIdx->pTable->iPKey ){\n      iColumn = XN_ROWID;\n    }else if( iColumn>=0 ){\n      pScan->idxaff = pIdx->pTable->aCol[iColumn].affinity;\n      pScan->zCollName = pIdx->azColl[j];\n    }\n  }else if( iColumn==XN_EXPR ){\n    return 0;\n  }\n  pScan->aiColumn[0] = iColumn;\n  return whereScanNext(pScan);\n}\n\n/*\n** Search for a term in the WHERE clause that is of the form \"X <op> <expr>\"\n** where X is a reference to the iColumn of table iCur or of index pIdx\n** if pIdx!=0 and <op> is one of the WO_xx operator codes specified by\n** the op parameter.  Return a pointer to the term.  Return 0 if not found.\n**\n** If pIdx!=0 then it must be one of the indexes of table iCur.  \n** Search for terms matching the iColumn-th column of pIdx\n** rather than the iColumn-th column of table iCur.\n**\n** The term returned might by Y=<expr> if there is another constraint in\n** the WHERE clause that specifies that X=Y.  Any such constraints will be\n** identified by the WO_EQUIV bit in the pTerm->eOperator field.  The\n** aiCur[]/iaColumn[] arrays hold X and all its equivalents. There are 11\n** slots in aiCur[]/aiColumn[] so that means we can look for X plus up to 10\n** other equivalent values.  Hence a search for X will return <expr> if X=A1\n** and A1=A2 and A2=A3 and ... and A9=A10 and A10=<expr>.\n**\n** If there are multiple terms in the WHERE clause of the form \"X <op> <expr>\"\n** then try for the one with no dependencies on <expr> - in other words where\n** <expr> is a constant expression of some kind.  Only return entries of\n** the form \"X <op> Y\" where Y is a column in another table if no terms of\n** the form \"X <op> <const-expr>\" exist.   If no terms with a constant RHS\n** exist, try to return a term that does not use WO_EQUIV.\n*/\nSQLITE_PRIVATE WhereTerm *sqlite3WhereFindTerm(\n  WhereClause *pWC,     /* The WHERE clause to be searched */\n  int iCur,             /* Cursor number of LHS */\n  int iColumn,          /* Column number of LHS */\n  Bitmask notReady,     /* RHS must not overlap with this mask */\n  u32 op,               /* Mask of WO_xx values describing operator */\n  Index *pIdx           /* Must be compatible with this index, if not NULL */\n){\n  WhereTerm *pResult = 0;\n  WhereTerm *p;\n  WhereScan scan;\n\n  p = whereScanInit(&scan, pWC, iCur, iColumn, op, pIdx);\n  op &= WO_EQ|WO_IS;\n  while( p ){\n    if( (p->prereqRight & notReady)==0 ){\n      if( p->prereqRight==0 && (p->eOperator&op)!=0 ){\n        testcase( p->eOperator & WO_IS );\n        return p;\n      }\n      if( pResult==0 ) pResult = p;\n    }\n    p = whereScanNext(&scan);\n  }\n  return pResult;\n}\n\n/*\n** This function searches pList for an entry that matches the iCol-th column\n** of index pIdx.\n**\n** If such an expression is found, its index in pList->a[] is returned. If\n** no expression is found, -1 is returned.\n*/\nstatic int findIndexCol(\n  Parse *pParse,                  /* Parse context */\n  ExprList *pList,                /* Expression list to search */\n  int iBase,                      /* Cursor for table associated with pIdx */\n  Index *pIdx,                    /* Index to match column of */\n  int iCol                        /* Column of index to match */\n){\n  int i;\n  const char *zColl = pIdx->azColl[iCol];\n\n  for(i=0; i<pList->nExpr; i++){\n    Expr *p = sqlite3ExprSkipCollate(pList->a[i].pExpr);\n    if( p->op==TK_COLUMN\n     && p->iColumn==pIdx->aiColumn[iCol]\n     && p->iTable==iBase\n    ){\n      CollSeq *pColl = sqlite3ExprNNCollSeq(pParse, pList->a[i].pExpr);\n      if( 0==sqlite3StrICmp(pColl->zName, zColl) ){\n        return i;\n      }\n    }\n  }\n\n  return -1;\n}\n\n/*\n** Return TRUE if the iCol-th column of index pIdx is NOT NULL\n*/\nstatic int indexColumnNotNull(Index *pIdx, int iCol){\n  int j;\n  assert( pIdx!=0 );\n  assert( iCol>=0 && iCol<pIdx->nColumn );\n  j = pIdx->aiColumn[iCol];\n  if( j>=0 ){\n    return pIdx->pTable->aCol[j].notNull;\n  }else if( j==(-1) ){\n    return 1;\n  }else{\n    assert( j==(-2) );\n    return 0;  /* Assume an indexed expression can always yield a NULL */\n\n  }\n}\n\n/*\n** Return true if the DISTINCT expression-list passed as the third argument\n** is redundant.\n**\n** A DISTINCT list is redundant if any subset of the columns in the\n** DISTINCT list are collectively unique and individually non-null.\n*/\nstatic int isDistinctRedundant(\n  Parse *pParse,            /* Parsing context */\n  SrcList *pTabList,        /* The FROM clause */\n  WhereClause *pWC,         /* The WHERE clause */\n  ExprList *pDistinct       /* The result set that needs to be DISTINCT */\n){\n  Table *pTab;\n  Index *pIdx;\n  int i;                          \n  int iBase;\n\n  /* If there is more than one table or sub-select in the FROM clause of\n  ** this query, then it will not be possible to show that the DISTINCT \n  ** clause is redundant. */\n  if( pTabList->nSrc!=1 ) return 0;\n  iBase = pTabList->a[0].iCursor;\n  pTab = pTabList->a[0].pTab;\n\n  /* If any of the expressions is an IPK column on table iBase, then return \n  ** true. Note: The (p->iTable==iBase) part of this test may be false if the\n  ** current SELECT is a correlated sub-query.\n  */\n  for(i=0; i<pDistinct->nExpr; i++){\n    Expr *p = sqlite3ExprSkipCollate(pDistinct->a[i].pExpr);\n    if( p->op==TK_COLUMN && p->iTable==iBase && p->iColumn<0 ) return 1;\n  }\n\n  /* Loop through all indices on the table, checking each to see if it makes\n  ** the DISTINCT qualifier redundant. It does so if:\n  **\n  **   1. The index is itself UNIQUE, and\n  **\n  **   2. All of the columns in the index are either part of the pDistinct\n  **      list, or else the WHERE clause contains a term of the form \"col=X\",\n  **      where X is a constant value. The collation sequences of the\n  **      comparison and select-list expressions must match those of the index.\n  **\n  **   3. All of those index columns for which the WHERE clause does not\n  **      contain a \"col=X\" term are subject to a NOT NULL constraint.\n  */\n  for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){\n    if( !IsUniqueIndex(pIdx) ) continue;\n    for(i=0; i<pIdx->nKeyCol; i++){\n      if( 0==sqlite3WhereFindTerm(pWC, iBase, i, ~(Bitmask)0, WO_EQ, pIdx) ){\n        if( findIndexCol(pParse, pDistinct, iBase, pIdx, i)<0 ) break;\n        if( indexColumnNotNull(pIdx, i)==0 ) break;\n      }\n    }\n    if( i==pIdx->nKeyCol ){\n      /* This index implies that the DISTINCT qualifier is redundant. */\n      return 1;\n    }\n  }\n\n  return 0;\n}\n\n\n/*\n** Estimate the logarithm of the input value to base 2.\n*/\nstatic LogEst estLog(LogEst N){\n  return N<=10 ? 0 : sqlite3LogEst(N) - 33;\n}\n\n/*\n** Convert OP_Column opcodes to OP_Copy in previously generated code.\n**\n** This routine runs over generated VDBE code and translates OP_Column\n** opcodes into OP_Copy when the table is being accessed via co-routine \n** instead of via table lookup.\n**\n** If the bIncrRowid parameter is 0, then any OP_Rowid instructions on\n** cursor iTabCur are transformed into OP_Null. Or, if bIncrRowid is non-zero,\n** then each OP_Rowid is transformed into an instruction to increment the\n** value stored in its output register.\n*/\nstatic void translateColumnToCopy(\n  Parse *pParse,      /* Parsing context */\n  int iStart,         /* Translate from this opcode to the end */\n  int iTabCur,        /* OP_Column/OP_Rowid references to this table */\n  int iRegister,      /* The first column is in this register */\n  int bIncrRowid      /* If non-zero, transform OP_rowid to OP_AddImm(1) */\n){\n  Vdbe *v = pParse->pVdbe;\n  VdbeOp *pOp = sqlite3VdbeGetOp(v, iStart);\n  int iEnd = sqlite3VdbeCurrentAddr(v);\n  if( pParse->db->mallocFailed ) return;\n  for(; iStart<iEnd; iStart++, pOp++){\n    if( pOp->p1!=iTabCur ) continue;\n    if( pOp->opcode==OP_Column ){\n      pOp->opcode = OP_Copy;\n      pOp->p1 = pOp->p2 + iRegister;\n      pOp->p2 = pOp->p3;\n      pOp->p3 = 0;\n    }else if( pOp->opcode==OP_Rowid ){\n      if( bIncrRowid ){\n        /* Increment the value stored in the P2 operand of the OP_Rowid. */\n        pOp->opcode = OP_AddImm;\n        pOp->p1 = pOp->p2;\n        pOp->p2 = 1;\n      }else{\n        pOp->opcode = OP_Null;\n        pOp->p1 = 0;\n        pOp->p3 = 0;\n      }\n    }\n  }\n}\n\n/*\n** Two routines for printing the content of an sqlite3_index_info\n** structure.  Used for testing and debugging only.  If neither\n** SQLITE_TEST or SQLITE_DEBUG are defined, then these routines\n** are no-ops.\n*/\n#if !defined(SQLITE_OMIT_VIRTUALTABLE) && defined(WHERETRACE_ENABLED)\nstatic void TRACE_IDX_INPUTS(sqlite3_index_info *p){\n  int i;\n  if( !sqlite3WhereTrace ) return;\n  for(i=0; i<p->nConstraint; i++){\n    sqlite3DebugPrintf(\"  constraint[%d]: col=%d termid=%d op=%d usabled=%d\\n\",\n       i,\n       p->aConstraint[i].iColumn,\n       p->aConstraint[i].iTermOffset,\n       p->aConstraint[i].op,\n       p->aConstraint[i].usable);\n  }\n  for(i=0; i<p->nOrderBy; i++){\n    sqlite3DebugPrintf(\"  orderby[%d]: col=%d desc=%d\\n\",\n       i,\n       p->aOrderBy[i].iColumn,\n       p->aOrderBy[i].desc);\n  }\n}\nstatic void TRACE_IDX_OUTPUTS(sqlite3_index_info *p){\n  int i;\n  if( !sqlite3WhereTrace ) return;\n  for(i=0; i<p->nConstraint; i++){\n    sqlite3DebugPrintf(\"  usage[%d]: argvIdx=%d omit=%d\\n\",\n       i,\n       p->aConstraintUsage[i].argvIndex,\n       p->aConstraintUsage[i].omit);\n  }\n  sqlite3DebugPrintf(\"  idxNum=%d\\n\", p->idxNum);\n  sqlite3DebugPrintf(\"  idxStr=%s\\n\", p->idxStr);\n  sqlite3DebugPrintf(\"  orderByConsumed=%d\\n\", p->orderByConsumed);\n  sqlite3DebugPrintf(\"  estimatedCost=%g\\n\", p->estimatedCost);\n  sqlite3DebugPrintf(\"  estimatedRows=%lld\\n\", p->estimatedRows);\n}\n#else\n#define TRACE_IDX_INPUTS(A)\n#define TRACE_IDX_OUTPUTS(A)\n#endif\n\n#ifndef SQLITE_OMIT_AUTOMATIC_INDEX\n/*\n** Return TRUE if the WHERE clause term pTerm is of a form where it\n** could be used with an index to access pSrc, assuming an appropriate\n** index existed.\n*/\nstatic int termCanDriveIndex(\n  WhereTerm *pTerm,              /* WHERE clause term to check */\n  struct SrcList_item *pSrc,     /* Table we are trying to access */\n  Bitmask notReady               /* Tables in outer loops of the join */\n){\n  char aff;\n  if( pTerm->leftCursor!=pSrc->iCursor ) return 0;\n  if( (pTerm->eOperator & (WO_EQ|WO_IS))==0 ) return 0;\n  if( (pSrc->fg.jointype & JT_LEFT) \n   && !ExprHasProperty(pTerm->pExpr, EP_FromJoin)\n   && (pTerm->eOperator & WO_IS)\n  ){\n    /* Cannot use an IS term from the WHERE clause as an index driver for\n    ** the RHS of a LEFT JOIN. Such a term can only be used if it is from\n    ** the ON clause.  */\n    return 0;\n  }\n  if( (pTerm->prereqRight & notReady)!=0 ) return 0;\n  if( pTerm->u.leftColumn<0 ) return 0;\n  aff = pSrc->pTab->aCol[pTerm->u.leftColumn].affinity;\n  if( !sqlite3IndexAffinityOk(pTerm->pExpr, aff) ) return 0;\n  testcase( pTerm->pExpr->op==TK_IS );\n  return 1;\n}\n#endif\n\n\n#ifndef SQLITE_OMIT_AUTOMATIC_INDEX\n/*\n** Generate code to construct the Index object for an automatic index\n** and to set up the WhereLevel object pLevel so that the code generator\n** makes use of the automatic index.\n*/\nstatic void constructAutomaticIndex(\n  Parse *pParse,              /* The parsing context */\n  WhereClause *pWC,           /* The WHERE clause */\n  struct SrcList_item *pSrc,  /* The FROM clause term to get the next index */\n  Bitmask notReady,           /* Mask of cursors that are not available */\n  WhereLevel *pLevel          /* Write new index here */\n){\n  int nKeyCol;                /* Number of columns in the constructed index */\n  WhereTerm *pTerm;           /* A single term of the WHERE clause */\n  WhereTerm *pWCEnd;          /* End of pWC->a[] */\n  Index *pIdx;                /* Object describing the transient index */\n  Vdbe *v;                    /* Prepared statement under construction */\n  int addrInit;               /* Address of the initialization bypass jump */\n  Table *pTable;              /* The table being indexed */\n  int addrTop;                /* Top of the index fill loop */\n  int regRecord;              /* Register holding an index record */\n  int n;                      /* Column counter */\n  int i;                      /* Loop counter */\n  int mxBitCol;               /* Maximum column in pSrc->colUsed */\n  CollSeq *pColl;             /* Collating sequence to on a column */\n  WhereLoop *pLoop;           /* The Loop object */\n  char *zNotUsed;             /* Extra space on the end of pIdx */\n  Bitmask idxCols;            /* Bitmap of columns used for indexing */\n  Bitmask extraCols;          /* Bitmap of additional columns */\n  u8 sentWarning = 0;         /* True if a warnning has been issued */\n  Expr *pPartial = 0;         /* Partial Index Expression */\n  int iContinue = 0;          /* Jump here to skip excluded rows */\n  struct SrcList_item *pTabItem;  /* FROM clause term being indexed */\n  int addrCounter = 0;        /* Address where integer counter is initialized */\n  int regBase;                /* Array of registers where record is assembled */\n\n  /* Generate code to skip over the creation and initialization of the\n  ** transient index on 2nd and subsequent iterations of the loop. */\n  v = pParse->pVdbe;\n  assert( v!=0 );\n  addrInit = sqlite3VdbeAddOp0(v, OP_Once); VdbeCoverage(v);\n\n  /* Count the number of columns that will be added to the index\n  ** and used to match WHERE clause constraints */\n  nKeyCol = 0;\n  pTable = pSrc->pTab;\n  pWCEnd = &pWC->a[pWC->nTerm];\n  pLoop = pLevel->pWLoop;\n  idxCols = 0;\n  for(pTerm=pWC->a; pTerm<pWCEnd; pTerm++){\n    Expr *pExpr = pTerm->pExpr;\n    assert( !ExprHasProperty(pExpr, EP_FromJoin)    /* prereq always non-zero */\n         || pExpr->iRightJoinTable!=pSrc->iCursor   /*   for the right-hand   */\n         || pLoop->prereq!=0 );                     /*   table of a LEFT JOIN */\n    if( pLoop->prereq==0\n     && (pTerm->wtFlags & TERM_VIRTUAL)==0\n     && !ExprHasProperty(pExpr, EP_FromJoin)\n     && sqlite3ExprIsTableConstant(pExpr, pSrc->iCursor) ){\n      pPartial = sqlite3ExprAnd(pParse->db, pPartial,\n                                sqlite3ExprDup(pParse->db, pExpr, 0));\n    }\n    if( termCanDriveIndex(pTerm, pSrc, notReady) ){\n      int iCol = pTerm->u.leftColumn;\n      Bitmask cMask = iCol>=BMS ? MASKBIT(BMS-1) : MASKBIT(iCol);\n      testcase( iCol==BMS );\n      testcase( iCol==BMS-1 );\n      if( !sentWarning ){\n        sqlite3_log(SQLITE_WARNING_AUTOINDEX,\n            \"automatic index on %s(%s)\", pTable->zName,\n            pTable->aCol[iCol].zName);\n        sentWarning = 1;\n      }\n      if( (idxCols & cMask)==0 ){\n        if( whereLoopResize(pParse->db, pLoop, nKeyCol+1) ){\n          goto end_auto_index_create;\n        }\n        pLoop->aLTerm[nKeyCol++] = pTerm;\n        idxCols |= cMask;\n      }\n    }\n  }\n  assert( nKeyCol>0 );\n  pLoop->u.btree.nEq = pLoop->nLTerm = nKeyCol;\n  pLoop->wsFlags = WHERE_COLUMN_EQ | WHERE_IDX_ONLY | WHERE_INDEXED\n                     | WHERE_AUTO_INDEX;\n\n  /* Count the number of additional columns needed to create a\n  ** covering index.  A \"covering index\" is an index that contains all\n  ** columns that are needed by the query.  With a covering index, the\n  ** original table never needs to be accessed.  Automatic indices must\n  ** be a covering index because the index will not be updated if the\n  ** original table changes and the index and table cannot both be used\n  ** if they go out of sync.\n  */\n  extraCols = pSrc->colUsed & (~idxCols | MASKBIT(BMS-1));\n  mxBitCol = MIN(BMS-1,pTable->nCol);\n  testcase( pTable->nCol==BMS-1 );\n  testcase( pTable->nCol==BMS-2 );\n  for(i=0; i<mxBitCol; i++){\n    if( extraCols & MASKBIT(i) ) nKeyCol++;\n  }\n  if( pSrc->colUsed & MASKBIT(BMS-1) ){\n    nKeyCol += pTable->nCol - BMS + 1;\n  }\n\n  /* Construct the Index object to describe this index */\n  pIdx = sqlite3AllocateIndexObject(pParse->db, nKeyCol+1, 0, &zNotUsed);\n  if( pIdx==0 ) goto end_auto_index_create;\n  pLoop->u.btree.pIndex = pIdx;\n  pIdx->zName = \"auto-index\";\n  pIdx->pTable = pTable;\n  n = 0;\n  idxCols = 0;\n  for(pTerm=pWC->a; pTerm<pWCEnd; pTerm++){\n    if( termCanDriveIndex(pTerm, pSrc, notReady) ){\n      int iCol = pTerm->u.leftColumn;\n      Bitmask cMask = iCol>=BMS ? MASKBIT(BMS-1) : MASKBIT(iCol);\n      testcase( iCol==BMS-1 );\n      testcase( iCol==BMS );\n      if( (idxCols & cMask)==0 ){\n        Expr *pX = pTerm->pExpr;\n        idxCols |= cMask;\n        pIdx->aiColumn[n] = pTerm->u.leftColumn;\n        pColl = sqlite3BinaryCompareCollSeq(pParse, pX->pLeft, pX->pRight);\n        pIdx->azColl[n] = pColl ? pColl->zName : sqlite3StrBINARY;\n        n++;\n      }\n    }\n  }\n  assert( (u32)n==pLoop->u.btree.nEq );\n\n  /* Add additional columns needed to make the automatic index into\n  ** a covering index */\n  for(i=0; i<mxBitCol; i++){\n    if( extraCols & MASKBIT(i) ){\n      pIdx->aiColumn[n] = i;\n      pIdx->azColl[n] = sqlite3StrBINARY;\n      n++;\n    }\n  }\n  if( pSrc->colUsed & MASKBIT(BMS-1) ){\n    for(i=BMS-1; i<pTable->nCol; i++){\n      pIdx->aiColumn[n] = i;\n      pIdx->azColl[n] = sqlite3StrBINARY;\n      n++;\n    }\n  }\n  assert( n==nKeyCol );\n  pIdx->aiColumn[n] = XN_ROWID;\n  pIdx->azColl[n] = sqlite3StrBINARY;\n\n  /* Create the automatic index */\n  assert( pLevel->iIdxCur>=0 );\n  pLevel->iIdxCur = pParse->nTab++;\n  sqlite3VdbeAddOp2(v, OP_OpenAutoindex, pLevel->iIdxCur, nKeyCol+1);\n  sqlite3VdbeSetP4KeyInfo(pParse, pIdx);\n  VdbeComment((v, \"for %s\", pTable->zName));\n\n  /* Fill the automatic index with content */\n  pTabItem = &pWC->pWInfo->pTabList->a[pLevel->iFrom];\n  if( pTabItem->fg.viaCoroutine ){\n    int regYield = pTabItem->regReturn;\n    addrCounter = sqlite3VdbeAddOp2(v, OP_Integer, 0, 0);\n    sqlite3VdbeAddOp3(v, OP_InitCoroutine, regYield, 0, pTabItem->addrFillSub);\n    addrTop =  sqlite3VdbeAddOp1(v, OP_Yield, regYield);\n    VdbeCoverage(v);\n    VdbeComment((v, \"next row of %s\", pTabItem->pTab->zName));\n  }else{\n    addrTop = sqlite3VdbeAddOp1(v, OP_Rewind, pLevel->iTabCur); VdbeCoverage(v);\n  }\n  if( pPartial ){\n    iContinue = sqlite3VdbeMakeLabel(pParse);\n    sqlite3ExprIfFalse(pParse, pPartial, iContinue, SQLITE_JUMPIFNULL);\n    pLoop->wsFlags |= WHERE_PARTIALIDX;\n  }\n  regRecord = sqlite3GetTempReg(pParse);\n  regBase = sqlite3GenerateIndexKey(\n      pParse, pIdx, pLevel->iTabCur, regRecord, 0, 0, 0, 0\n  );\n  sqlite3VdbeAddOp2(v, OP_IdxInsert, pLevel->iIdxCur, regRecord);\n  sqlite3VdbeChangeP5(v, OPFLAG_USESEEKRESULT);\n  if( pPartial ) sqlite3VdbeResolveLabel(v, iContinue);\n  if( pTabItem->fg.viaCoroutine ){\n    sqlite3VdbeChangeP2(v, addrCounter, regBase+n);\n    testcase( pParse->db->mallocFailed );\n    translateColumnToCopy(pParse, addrTop, pLevel->iTabCur,\n                          pTabItem->regResult, 1);\n    sqlite3VdbeGoto(v, addrTop);\n    pTabItem->fg.viaCoroutine = 0;\n  }else{\n    sqlite3VdbeAddOp2(v, OP_Next, pLevel->iTabCur, addrTop+1); VdbeCoverage(v);\n  }\n  sqlite3VdbeChangeP5(v, SQLITE_STMTSTATUS_AUTOINDEX);\n  sqlite3VdbeJumpHere(v, addrTop);\n  sqlite3ReleaseTempReg(pParse, regRecord);\n  \n  /* Jump here when skipping the initialization */\n  sqlite3VdbeJumpHere(v, addrInit);\n\nend_auto_index_create:\n  sqlite3ExprDelete(pParse->db, pPartial);\n}\n#endif /* SQLITE_OMIT_AUTOMATIC_INDEX */\n\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n/*\n** Allocate and populate an sqlite3_index_info structure. It is the \n** responsibility of the caller to eventually release the structure\n** by passing the pointer returned by this function to sqlite3_free().\n*/\nstatic sqlite3_index_info *allocateIndexInfo(\n  Parse *pParse,                  /* The parsing context */\n  WhereClause *pWC,               /* The WHERE clause being analyzed */\n  Bitmask mUnusable,              /* Ignore terms with these prereqs */\n  struct SrcList_item *pSrc,      /* The FROM clause term that is the vtab */\n  ExprList *pOrderBy,             /* The ORDER BY clause */\n  u16 *pmNoOmit                   /* Mask of terms not to omit */\n){\n  int i, j;\n  int nTerm;\n  struct sqlite3_index_constraint *pIdxCons;\n  struct sqlite3_index_orderby *pIdxOrderBy;\n  struct sqlite3_index_constraint_usage *pUsage;\n  struct HiddenIndexInfo *pHidden;\n  WhereTerm *pTerm;\n  int nOrderBy;\n  sqlite3_index_info *pIdxInfo;\n  u16 mNoOmit = 0;\n\n  /* Count the number of possible WHERE clause constraints referring\n  ** to this virtual table */\n  for(i=nTerm=0, pTerm=pWC->a; i<pWC->nTerm; i++, pTerm++){\n    if( pTerm->leftCursor != pSrc->iCursor ) continue;\n    if( pTerm->prereqRight & mUnusable ) continue;\n    assert( IsPowerOfTwo(pTerm->eOperator & ~WO_EQUIV) );\n    testcase( pTerm->eOperator & WO_IN );\n    testcase( pTerm->eOperator & WO_ISNULL );\n    testcase( pTerm->eOperator & WO_IS );\n    testcase( pTerm->eOperator & WO_ALL );\n    if( (pTerm->eOperator & ~(WO_EQUIV))==0 ) continue;\n    if( pTerm->wtFlags & TERM_VNULL ) continue;\n    assert( pTerm->u.leftColumn>=(-1) );\n    nTerm++;\n  }\n\n  /* If the ORDER BY clause contains only columns in the current \n  ** virtual table then allocate space for the aOrderBy part of\n  ** the sqlite3_index_info structure.\n  */\n  nOrderBy = 0;\n  if( pOrderBy ){\n    int n = pOrderBy->nExpr;\n    for(i=0; i<n; i++){\n      Expr *pExpr = pOrderBy->a[i].pExpr;\n      if( pExpr->op!=TK_COLUMN || pExpr->iTable!=pSrc->iCursor ) break;\n    }\n    if( i==n){\n      nOrderBy = n;\n    }\n  }\n\n  /* Allocate the sqlite3_index_info structure\n  */\n  pIdxInfo = sqlite3DbMallocZero(pParse->db, sizeof(*pIdxInfo)\n                           + (sizeof(*pIdxCons) + sizeof(*pUsage))*nTerm\n                           + sizeof(*pIdxOrderBy)*nOrderBy + sizeof(*pHidden) );\n  if( pIdxInfo==0 ){\n    sqlite3ErrorMsg(pParse, \"out of memory\");\n    return 0;\n  }\n\n  /* Initialize the structure.  The sqlite3_index_info structure contains\n  ** many fields that are declared \"const\" to prevent xBestIndex from\n  ** changing them.  We have to do some funky casting in order to\n  ** initialize those fields.\n  */\n  pHidden = (struct HiddenIndexInfo*)&pIdxInfo[1];\n  pIdxCons = (struct sqlite3_index_constraint*)&pHidden[1];\n  pIdxOrderBy = (struct sqlite3_index_orderby*)&pIdxCons[nTerm];\n  pUsage = (struct sqlite3_index_constraint_usage*)&pIdxOrderBy[nOrderBy];\n  *(int*)&pIdxInfo->nConstraint = nTerm;\n  *(int*)&pIdxInfo->nOrderBy = nOrderBy;\n  *(struct sqlite3_index_constraint**)&pIdxInfo->aConstraint = pIdxCons;\n  *(struct sqlite3_index_orderby**)&pIdxInfo->aOrderBy = pIdxOrderBy;\n  *(struct sqlite3_index_constraint_usage**)&pIdxInfo->aConstraintUsage =\n                                                                   pUsage;\n\n  pHidden->pWC = pWC;\n  pHidden->pParse = pParse;\n  for(i=j=0, pTerm=pWC->a; i<pWC->nTerm; i++, pTerm++){\n    u16 op;\n    if( pTerm->leftCursor != pSrc->iCursor ) continue;\n    if( pTerm->prereqRight & mUnusable ) continue;\n    assert( IsPowerOfTwo(pTerm->eOperator & ~WO_EQUIV) );\n    testcase( pTerm->eOperator & WO_IN );\n    testcase( pTerm->eOperator & WO_IS );\n    testcase( pTerm->eOperator & WO_ISNULL );\n    testcase( pTerm->eOperator & WO_ALL );\n    if( (pTerm->eOperator & ~(WO_EQUIV))==0 ) continue;\n    if( pTerm->wtFlags & TERM_VNULL ) continue;\n    if( (pSrc->fg.jointype & JT_LEFT)!=0\n     && !ExprHasProperty(pTerm->pExpr, EP_FromJoin)\n     && (pTerm->eOperator & (WO_IS|WO_ISNULL))\n    ){\n      /* An \"IS\" term in the WHERE clause where the virtual table is the rhs\n      ** of a LEFT JOIN. Do not pass this term to the virtual table\n      ** implementation, as this can lead to incorrect results from SQL such\n      ** as:\n      **\n      **   \"LEFT JOIN vtab WHERE vtab.col IS NULL\"  */\n      testcase( pTerm->eOperator & WO_ISNULL );\n      testcase( pTerm->eOperator & WO_IS );\n      continue;\n    }\n    assert( pTerm->u.leftColumn>=(-1) );\n    pIdxCons[j].iColumn = pTerm->u.leftColumn;\n    pIdxCons[j].iTermOffset = i;\n    op = pTerm->eOperator & WO_ALL;\n    if( op==WO_IN ) op = WO_EQ;\n    if( op==WO_AUX ){\n      pIdxCons[j].op = pTerm->eMatchOp;\n    }else if( op & (WO_ISNULL|WO_IS) ){\n      if( op==WO_ISNULL ){\n        pIdxCons[j].op = SQLITE_INDEX_CONSTRAINT_ISNULL;\n      }else{\n        pIdxCons[j].op = SQLITE_INDEX_CONSTRAINT_IS;\n      }\n    }else{\n      pIdxCons[j].op = (u8)op;\n      /* The direct assignment in the previous line is possible only because\n      ** the WO_ and SQLITE_INDEX_CONSTRAINT_ codes are identical.  The\n      ** following asserts verify this fact. */\n      assert( WO_EQ==SQLITE_INDEX_CONSTRAINT_EQ );\n      assert( WO_LT==SQLITE_INDEX_CONSTRAINT_LT );\n      assert( WO_LE==SQLITE_INDEX_CONSTRAINT_LE );\n      assert( WO_GT==SQLITE_INDEX_CONSTRAINT_GT );\n      assert( WO_GE==SQLITE_INDEX_CONSTRAINT_GE );\n      assert( pTerm->eOperator&(WO_IN|WO_EQ|WO_LT|WO_LE|WO_GT|WO_GE|WO_AUX) );\n\n      if( op & (WO_LT|WO_LE|WO_GT|WO_GE)\n       && sqlite3ExprIsVector(pTerm->pExpr->pRight) \n      ){\n        if( i<16 ) mNoOmit |= (1 << i);\n        if( op==WO_LT ) pIdxCons[j].op = WO_LE;\n        if( op==WO_GT ) pIdxCons[j].op = WO_GE;\n      }\n    }\n\n    j++;\n  }\n  for(i=0; i<nOrderBy; i++){\n    Expr *pExpr = pOrderBy->a[i].pExpr;\n    pIdxOrderBy[i].iColumn = pExpr->iColumn;\n    pIdxOrderBy[i].desc = pOrderBy->a[i].sortOrder;\n  }\n\n  *pmNoOmit = mNoOmit;\n  return pIdxInfo;\n}\n\n/*\n** The table object reference passed as the second argument to this function\n** must represent a virtual table. This function invokes the xBestIndex()\n** method of the virtual table with the sqlite3_index_info object that\n** comes in as the 3rd argument to this function.\n**\n** If an error occurs, pParse is populated with an error message and an\n** appropriate error code is returned.  A return of SQLITE_CONSTRAINT from\n** xBestIndex is not considered an error.  SQLITE_CONSTRAINT indicates that\n** the current configuration of \"unusable\" flags in sqlite3_index_info can\n** not result in a valid plan.\n**\n** Whether or not an error is returned, it is the responsibility of the\n** caller to eventually free p->idxStr if p->needToFreeIdxStr indicates\n** that this is required.\n*/\nstatic int vtabBestIndex(Parse *pParse, Table *pTab, sqlite3_index_info *p){\n  sqlite3_vtab *pVtab = sqlite3GetVTable(pParse->db, pTab)->pVtab;\n  int rc;\n\n  TRACE_IDX_INPUTS(p);\n  rc = pVtab->pModule->xBestIndex(pVtab, p);\n  TRACE_IDX_OUTPUTS(p);\n\n  if( rc!=SQLITE_OK && rc!=SQLITE_CONSTRAINT ){\n    if( rc==SQLITE_NOMEM ){\n      sqlite3OomFault(pParse->db);\n    }else if( !pVtab->zErrMsg ){\n      sqlite3ErrorMsg(pParse, \"%s\", sqlite3ErrStr(rc));\n    }else{\n      sqlite3ErrorMsg(pParse, \"%s\", pVtab->zErrMsg);\n    }\n  }\n  sqlite3_free(pVtab->zErrMsg);\n  pVtab->zErrMsg = 0;\n  return rc;\n}\n#endif /* !defined(SQLITE_OMIT_VIRTUALTABLE) */\n\n#ifdef SQLITE_ENABLE_STAT3_OR_STAT4\n/*\n** Estimate the location of a particular key among all keys in an\n** index.  Store the results in aStat as follows:\n**\n**    aStat[0]      Est. number of rows less than pRec\n**    aStat[1]      Est. number of rows equal to pRec\n**\n** Return the index of the sample that is the smallest sample that\n** is greater than or equal to pRec. Note that this index is not an index\n** into the aSample[] array - it is an index into a virtual set of samples\n** based on the contents of aSample[] and the number of fields in record \n** pRec. \n*/\nstatic int whereKeyStats(\n  Parse *pParse,              /* Database connection */\n  Index *pIdx,                /* Index to consider domain of */\n  UnpackedRecord *pRec,       /* Vector of values to consider */\n  int roundUp,                /* Round up if true.  Round down if false */\n  tRowcnt *aStat              /* OUT: stats written here */\n){\n  IndexSample *aSample = pIdx->aSample;\n  int iCol;                   /* Index of required stats in anEq[] etc. */\n  int i;                      /* Index of first sample >= pRec */\n  int iSample;                /* Smallest sample larger than or equal to pRec */\n  int iMin = 0;               /* Smallest sample not yet tested */\n  int iTest;                  /* Next sample to test */\n  int res;                    /* Result of comparison operation */\n  int nField;                 /* Number of fields in pRec */\n  tRowcnt iLower = 0;         /* anLt[] + anEq[] of largest sample pRec is > */\n\n#ifndef SQLITE_DEBUG\n  UNUSED_PARAMETER( pParse );\n#endif\n  assert( pRec!=0 );\n  assert( pIdx->nSample>0 );\n  assert( pRec->nField>0 && pRec->nField<=pIdx->nSampleCol );\n\n  /* Do a binary search to find the first sample greater than or equal\n  ** to pRec. If pRec contains a single field, the set of samples to search\n  ** is simply the aSample[] array. If the samples in aSample[] contain more\n  ** than one fields, all fields following the first are ignored.\n  **\n  ** If pRec contains N fields, where N is more than one, then as well as the\n  ** samples in aSample[] (truncated to N fields), the search also has to\n  ** consider prefixes of those samples. For example, if the set of samples\n  ** in aSample is:\n  **\n  **     aSample[0] = (a, 5) \n  **     aSample[1] = (a, 10) \n  **     aSample[2] = (b, 5) \n  **     aSample[3] = (c, 100) \n  **     aSample[4] = (c, 105)\n  **\n  ** Then the search space should ideally be the samples above and the \n  ** unique prefixes [a], [b] and [c]. But since that is hard to organize, \n  ** the code actually searches this set:\n  **\n  **     0: (a) \n  **     1: (a, 5) \n  **     2: (a, 10) \n  **     3: (a, 10) \n  **     4: (b) \n  **     5: (b, 5) \n  **     6: (c) \n  **     7: (c, 100) \n  **     8: (c, 105)\n  **     9: (c, 105)\n  **\n  ** For each sample in the aSample[] array, N samples are present in the\n  ** effective sample array. In the above, samples 0 and 1 are based on \n  ** sample aSample[0]. Samples 2 and 3 on aSample[1] etc.\n  **\n  ** Often, sample i of each block of N effective samples has (i+1) fields.\n  ** Except, each sample may be extended to ensure that it is greater than or\n  ** equal to the previous sample in the array. For example, in the above, \n  ** sample 2 is the first sample of a block of N samples, so at first it \n  ** appears that it should be 1 field in size. However, that would make it \n  ** smaller than sample 1, so the binary search would not work. As a result, \n  ** it is extended to two fields. The duplicates that this creates do not \n  ** cause any problems.\n  */\n  nField = pRec->nField;\n  iCol = 0;\n  iSample = pIdx->nSample * nField;\n  do{\n    int iSamp;                    /* Index in aSample[] of test sample */\n    int n;                        /* Number of fields in test sample */\n\n    iTest = (iMin+iSample)/2;\n    iSamp = iTest / nField;\n    if( iSamp>0 ){\n      /* The proposed effective sample is a prefix of sample aSample[iSamp].\n      ** Specifically, the shortest prefix of at least (1 + iTest%nField) \n      ** fields that is greater than the previous effective sample.  */\n      for(n=(iTest % nField) + 1; n<nField; n++){\n        if( aSample[iSamp-1].anLt[n-1]!=aSample[iSamp].anLt[n-1] ) break;\n      }\n    }else{\n      n = iTest + 1;\n    }\n\n    pRec->nField = n;\n    res = sqlite3VdbeRecordCompare(aSample[iSamp].n, aSample[iSamp].p, pRec);\n    if( res<0 ){\n      iLower = aSample[iSamp].anLt[n-1] + aSample[iSamp].anEq[n-1];\n      iMin = iTest+1;\n    }else if( res==0 && n<nField ){\n      iLower = aSample[iSamp].anLt[n-1];\n      iMin = iTest+1;\n      res = -1;\n    }else{\n      iSample = iTest;\n      iCol = n-1;\n    }\n  }while( res && iMin<iSample );\n  i = iSample / nField;\n\n#ifdef SQLITE_DEBUG\n  /* The following assert statements check that the binary search code\n  ** above found the right answer. This block serves no purpose other\n  ** than to invoke the asserts.  */\n  if( pParse->db->mallocFailed==0 ){\n    if( res==0 ){\n      /* If (res==0) is true, then pRec must be equal to sample i. */\n      assert( i<pIdx->nSample );\n      assert( iCol==nField-1 );\n      pRec->nField = nField;\n      assert( 0==sqlite3VdbeRecordCompare(aSample[i].n, aSample[i].p, pRec) \n           || pParse->db->mallocFailed \n      );\n    }else{\n      /* Unless i==pIdx->nSample, indicating that pRec is larger than\n      ** all samples in the aSample[] array, pRec must be smaller than the\n      ** (iCol+1) field prefix of sample i.  */\n      assert( i<=pIdx->nSample && i>=0 );\n      pRec->nField = iCol+1;\n      assert( i==pIdx->nSample \n           || sqlite3VdbeRecordCompare(aSample[i].n, aSample[i].p, pRec)>0\n           || pParse->db->mallocFailed );\n\n      /* if i==0 and iCol==0, then record pRec is smaller than all samples\n      ** in the aSample[] array. Otherwise, if (iCol>0) then pRec must\n      ** be greater than or equal to the (iCol) field prefix of sample i.\n      ** If (i>0), then pRec must also be greater than sample (i-1).  */\n      if( iCol>0 ){\n        pRec->nField = iCol;\n        assert( sqlite3VdbeRecordCompare(aSample[i].n, aSample[i].p, pRec)<=0\n             || pParse->db->mallocFailed );\n      }\n      if( i>0 ){\n        pRec->nField = nField;\n        assert( sqlite3VdbeRecordCompare(aSample[i-1].n, aSample[i-1].p, pRec)<0\n             || pParse->db->mallocFailed );\n      }\n    }\n  }\n#endif /* ifdef SQLITE_DEBUG */\n\n  if( res==0 ){\n    /* Record pRec is equal to sample i */\n    assert( iCol==nField-1 );\n    aStat[0] = aSample[i].anLt[iCol];\n    aStat[1] = aSample[i].anEq[iCol];\n  }else{\n    /* At this point, the (iCol+1) field prefix of aSample[i] is the first \n    ** sample that is greater than pRec. Or, if i==pIdx->nSample then pRec\n    ** is larger than all samples in the array. */\n    tRowcnt iUpper, iGap;\n    if( i>=pIdx->nSample ){\n      iUpper = sqlite3LogEstToInt(pIdx->aiRowLogEst[0]);\n    }else{\n      iUpper = aSample[i].anLt[iCol];\n    }\n\n    if( iLower>=iUpper ){\n      iGap = 0;\n    }else{\n      iGap = iUpper - iLower;\n    }\n    if( roundUp ){\n      iGap = (iGap*2)/3;\n    }else{\n      iGap = iGap/3;\n    }\n    aStat[0] = iLower + iGap;\n    aStat[1] = pIdx->aAvgEq[nField-1];\n  }\n\n  /* Restore the pRec->nField value before returning.  */\n  pRec->nField = nField;\n  return i;\n}\n#endif /* SQLITE_ENABLE_STAT3_OR_STAT4 */\n\n/*\n** If it is not NULL, pTerm is a term that provides an upper or lower\n** bound on a range scan. Without considering pTerm, it is estimated \n** that the scan will visit nNew rows. This function returns the number\n** estimated to be visited after taking pTerm into account.\n**\n** If the user explicitly specified a likelihood() value for this term,\n** then the return value is the likelihood multiplied by the number of\n** input rows. Otherwise, this function assumes that an \"IS NOT NULL\" term\n** has a likelihood of 0.50, and any other term a likelihood of 0.25.\n*/\nstatic LogEst whereRangeAdjust(WhereTerm *pTerm, LogEst nNew){\n  LogEst nRet = nNew;\n  if( pTerm ){\n    if( pTerm->truthProb<=0 ){\n      nRet += pTerm->truthProb;\n    }else if( (pTerm->wtFlags & TERM_VNULL)==0 ){\n      nRet -= 20;        assert( 20==sqlite3LogEst(4) );\n    }\n  }\n  return nRet;\n}\n\n\n#ifdef SQLITE_ENABLE_STAT3_OR_STAT4\n/*\n** Return the affinity for a single column of an index.\n*/\nSQLITE_PRIVATE char sqlite3IndexColumnAffinity(sqlite3 *db, Index *pIdx, int iCol){\n  assert( iCol>=0 && iCol<pIdx->nColumn );\n  if( !pIdx->zColAff ){\n    if( sqlite3IndexAffinityStr(db, pIdx)==0 ) return SQLITE_AFF_BLOB;\n  }\n  return pIdx->zColAff[iCol];\n}\n#endif\n\n\n#ifdef SQLITE_ENABLE_STAT3_OR_STAT4\n/* \n** This function is called to estimate the number of rows visited by a\n** range-scan on a skip-scan index. For example:\n**\n**   CREATE INDEX i1 ON t1(a, b, c);\n**   SELECT * FROM t1 WHERE a=? AND c BETWEEN ? AND ?;\n**\n** Value pLoop->nOut is currently set to the estimated number of rows \n** visited for scanning (a=? AND b=?). This function reduces that estimate \n** by some factor to account for the (c BETWEEN ? AND ?) expression based\n** on the stat4 data for the index. this scan will be peformed multiple \n** times (once for each (a,b) combination that matches a=?) is dealt with \n** by the caller.\n**\n** It does this by scanning through all stat4 samples, comparing values\n** extracted from pLower and pUpper with the corresponding column in each\n** sample. If L and U are the number of samples found to be less than or\n** equal to the values extracted from pLower and pUpper respectively, and\n** N is the total number of samples, the pLoop->nOut value is adjusted\n** as follows:\n**\n**   nOut = nOut * ( min(U - L, 1) / N )\n**\n** If pLower is NULL, or a value cannot be extracted from the term, L is\n** set to zero. If pUpper is NULL, or a value cannot be extracted from it,\n** U is set to N.\n**\n** Normally, this function sets *pbDone to 1 before returning. However,\n** if no value can be extracted from either pLower or pUpper (and so the\n** estimate of the number of rows delivered remains unchanged), *pbDone\n** is left as is.\n**\n** If an error occurs, an SQLite error code is returned. Otherwise, \n** SQLITE_OK.\n*/\nstatic int whereRangeSkipScanEst(\n  Parse *pParse,       /* Parsing & code generating context */\n  WhereTerm *pLower,   /* Lower bound on the range. ex: \"x>123\" Might be NULL */\n  WhereTerm *pUpper,   /* Upper bound on the range. ex: \"x<455\" Might be NULL */\n  WhereLoop *pLoop,    /* Update the .nOut value of this loop */\n  int *pbDone          /* Set to true if at least one expr. value extracted */\n){\n  Index *p = pLoop->u.btree.pIndex;\n  int nEq = pLoop->u.btree.nEq;\n  sqlite3 *db = pParse->db;\n  int nLower = -1;\n  int nUpper = p->nSample+1;\n  int rc = SQLITE_OK;\n  u8 aff = sqlite3IndexColumnAffinity(db, p, nEq);\n  CollSeq *pColl;\n  \n  sqlite3_value *p1 = 0;          /* Value extracted from pLower */\n  sqlite3_value *p2 = 0;          /* Value extracted from pUpper */\n  sqlite3_value *pVal = 0;        /* Value extracted from record */\n\n  pColl = sqlite3LocateCollSeq(pParse, p->azColl[nEq]);\n  if( pLower ){\n    rc = sqlite3Stat4ValueFromExpr(pParse, pLower->pExpr->pRight, aff, &p1);\n    nLower = 0;\n  }\n  if( pUpper && rc==SQLITE_OK ){\n    rc = sqlite3Stat4ValueFromExpr(pParse, pUpper->pExpr->pRight, aff, &p2);\n    nUpper = p2 ? 0 : p->nSample;\n  }\n\n  if( p1 || p2 ){\n    int i;\n    int nDiff;\n    for(i=0; rc==SQLITE_OK && i<p->nSample; i++){\n      rc = sqlite3Stat4Column(db, p->aSample[i].p, p->aSample[i].n, nEq, &pVal);\n      if( rc==SQLITE_OK && p1 ){\n        int res = sqlite3MemCompare(p1, pVal, pColl);\n        if( res>=0 ) nLower++;\n      }\n      if( rc==SQLITE_OK && p2 ){\n        int res = sqlite3MemCompare(p2, pVal, pColl);\n        if( res>=0 ) nUpper++;\n      }\n    }\n    nDiff = (nUpper - nLower);\n    if( nDiff<=0 ) nDiff = 1;\n\n    /* If there is both an upper and lower bound specified, and the \n    ** comparisons indicate that they are close together, use the fallback\n    ** method (assume that the scan visits 1/64 of the rows) for estimating\n    ** the number of rows visited. Otherwise, estimate the number of rows\n    ** using the method described in the header comment for this function. */\n    if( nDiff!=1 || pUpper==0 || pLower==0 ){\n      int nAdjust = (sqlite3LogEst(p->nSample) - sqlite3LogEst(nDiff));\n      pLoop->nOut -= nAdjust;\n      *pbDone = 1;\n      WHERETRACE(0x10, (\"range skip-scan regions: %u..%u  adjust=%d est=%d\\n\",\n                           nLower, nUpper, nAdjust*-1, pLoop->nOut));\n    }\n\n  }else{\n    assert( *pbDone==0 );\n  }\n\n  sqlite3ValueFree(p1);\n  sqlite3ValueFree(p2);\n  sqlite3ValueFree(pVal);\n\n  return rc;\n}\n#endif /* SQLITE_ENABLE_STAT3_OR_STAT4 */\n\n/*\n** This function is used to estimate the number of rows that will be visited\n** by scanning an index for a range of values. The range may have an upper\n** bound, a lower bound, or both. The WHERE clause terms that set the upper\n** and lower bounds are represented by pLower and pUpper respectively. For\n** example, assuming that index p is on t1(a):\n**\n**   ... FROM t1 WHERE a > ? AND a < ? ...\n**                    |_____|   |_____|\n**                       |         |\n**                     pLower    pUpper\n**\n** If either of the upper or lower bound is not present, then NULL is passed in\n** place of the corresponding WhereTerm.\n**\n** The value in (pBuilder->pNew->u.btree.nEq) is the number of the index\n** column subject to the range constraint. Or, equivalently, the number of\n** equality constraints optimized by the proposed index scan. For example,\n** assuming index p is on t1(a, b), and the SQL query is:\n**\n**   ... FROM t1 WHERE a = ? AND b > ? AND b < ? ...\n**\n** then nEq is set to 1 (as the range restricted column, b, is the second \n** left-most column of the index). Or, if the query is:\n**\n**   ... FROM t1 WHERE a > ? AND a < ? ...\n**\n** then nEq is set to 0.\n**\n** When this function is called, *pnOut is set to the sqlite3LogEst() of the\n** number of rows that the index scan is expected to visit without \n** considering the range constraints. If nEq is 0, then *pnOut is the number of \n** rows in the index. Assuming no error occurs, *pnOut is adjusted (reduced)\n** to account for the range constraints pLower and pUpper.\n** \n** In the absence of sqlite_stat4 ANALYZE data, or if such data cannot be\n** used, a single range inequality reduces the search space by a factor of 4. \n** and a pair of constraints (x>? AND x<?) reduces the expected number of\n** rows visited by a factor of 64.\n*/\nstatic int whereRangeScanEst(\n  Parse *pParse,       /* Parsing & code generating context */\n  WhereLoopBuilder *pBuilder,\n  WhereTerm *pLower,   /* Lower bound on the range. ex: \"x>123\" Might be NULL */\n  WhereTerm *pUpper,   /* Upper bound on the range. ex: \"x<455\" Might be NULL */\n  WhereLoop *pLoop     /* Modify the .nOut and maybe .rRun fields */\n){\n  int rc = SQLITE_OK;\n  int nOut = pLoop->nOut;\n  LogEst nNew;\n\n#ifdef SQLITE_ENABLE_STAT3_OR_STAT4\n  Index *p = pLoop->u.btree.pIndex;\n  int nEq = pLoop->u.btree.nEq;\n\n  if( p->nSample>0 && nEq<p->nSampleCol\n   && OptimizationEnabled(pParse->db, SQLITE_Stat34)\n  ){\n    if( nEq==pBuilder->nRecValid ){\n      UnpackedRecord *pRec = pBuilder->pRec;\n      tRowcnt a[2];\n      int nBtm = pLoop->u.btree.nBtm;\n      int nTop = pLoop->u.btree.nTop;\n\n      /* Variable iLower will be set to the estimate of the number of rows in \n      ** the index that are less than the lower bound of the range query. The\n      ** lower bound being the concatenation of $P and $L, where $P is the\n      ** key-prefix formed by the nEq values matched against the nEq left-most\n      ** columns of the index, and $L is the value in pLower.\n      **\n      ** Or, if pLower is NULL or $L cannot be extracted from it (because it\n      ** is not a simple variable or literal value), the lower bound of the\n      ** range is $P. Due to a quirk in the way whereKeyStats() works, even\n      ** if $L is available, whereKeyStats() is called for both ($P) and \n      ** ($P:$L) and the larger of the two returned values is used.\n      **\n      ** Similarly, iUpper is to be set to the estimate of the number of rows\n      ** less than the upper bound of the range query. Where the upper bound\n      ** is either ($P) or ($P:$U). Again, even if $U is available, both values\n      ** of iUpper are requested of whereKeyStats() and the smaller used.\n      **\n      ** The number of rows between the two bounds is then just iUpper-iLower.\n      */\n      tRowcnt iLower;     /* Rows less than the lower bound */\n      tRowcnt iUpper;     /* Rows less than the upper bound */\n      int iLwrIdx = -2;   /* aSample[] for the lower bound */\n      int iUprIdx = -1;   /* aSample[] for the upper bound */\n\n      if( pRec ){\n        testcase( pRec->nField!=pBuilder->nRecValid );\n        pRec->nField = pBuilder->nRecValid;\n      }\n      /* Determine iLower and iUpper using ($P) only. */\n      if( nEq==0 ){\n        iLower = 0;\n        iUpper = p->nRowEst0;\n      }else{\n        /* Note: this call could be optimized away - since the same values must \n        ** have been requested when testing key $P in whereEqualScanEst().  */\n        whereKeyStats(pParse, p, pRec, 0, a);\n        iLower = a[0];\n        iUpper = a[0] + a[1];\n      }\n\n      assert( pLower==0 || (pLower->eOperator & (WO_GT|WO_GE))!=0 );\n      assert( pUpper==0 || (pUpper->eOperator & (WO_LT|WO_LE))!=0 );\n      assert( p->aSortOrder!=0 );\n      if( p->aSortOrder[nEq] ){\n        /* The roles of pLower and pUpper are swapped for a DESC index */\n        SWAP(WhereTerm*, pLower, pUpper);\n        SWAP(int, nBtm, nTop);\n      }\n\n      /* If possible, improve on the iLower estimate using ($P:$L). */\n      if( pLower ){\n        int n;                    /* Values extracted from pExpr */\n        Expr *pExpr = pLower->pExpr->pRight;\n        rc = sqlite3Stat4ProbeSetValue(pParse, p, &pRec, pExpr, nBtm, nEq, &n);\n        if( rc==SQLITE_OK && n ){\n          tRowcnt iNew;\n          u16 mask = WO_GT|WO_LE;\n          if( sqlite3ExprVectorSize(pExpr)>n ) mask = (WO_LE|WO_LT);\n          iLwrIdx = whereKeyStats(pParse, p, pRec, 0, a);\n          iNew = a[0] + ((pLower->eOperator & mask) ? a[1] : 0);\n          if( iNew>iLower ) iLower = iNew;\n          nOut--;\n          pLower = 0;\n        }\n      }\n\n      /* If possible, improve on the iUpper estimate using ($P:$U). */\n      if( pUpper ){\n        int n;                    /* Values extracted from pExpr */\n        Expr *pExpr = pUpper->pExpr->pRight;\n        rc = sqlite3Stat4ProbeSetValue(pParse, p, &pRec, pExpr, nTop, nEq, &n);\n        if( rc==SQLITE_OK && n ){\n          tRowcnt iNew;\n          u16 mask = WO_GT|WO_LE;\n          if( sqlite3ExprVectorSize(pExpr)>n ) mask = (WO_LE|WO_LT);\n          iUprIdx = whereKeyStats(pParse, p, pRec, 1, a);\n          iNew = a[0] + ((pUpper->eOperator & mask) ? a[1] : 0);\n          if( iNew<iUpper ) iUpper = iNew;\n          nOut--;\n          pUpper = 0;\n        }\n      }\n\n      pBuilder->pRec = pRec;\n      if( rc==SQLITE_OK ){\n        if( iUpper>iLower ){\n          nNew = sqlite3LogEst(iUpper - iLower);\n          /* TUNING:  If both iUpper and iLower are derived from the same\n          ** sample, then assume they are 4x more selective.  This brings\n          ** the estimated selectivity more in line with what it would be\n          ** if estimated without the use of STAT3/4 tables. */\n          if( iLwrIdx==iUprIdx ) nNew -= 20;  assert( 20==sqlite3LogEst(4) );\n        }else{\n          nNew = 10;        assert( 10==sqlite3LogEst(2) );\n        }\n        if( nNew<nOut ){\n          nOut = nNew;\n        }\n        WHERETRACE(0x10, (\"STAT4 range scan: %u..%u  est=%d\\n\",\n                           (u32)iLower, (u32)iUpper, nOut));\n      }\n    }else{\n      int bDone = 0;\n      rc = whereRangeSkipScanEst(pParse, pLower, pUpper, pLoop, &bDone);\n      if( bDone ) return rc;\n    }\n  }\n#else\n  UNUSED_PARAMETER(pParse);\n  UNUSED_PARAMETER(pBuilder);\n  assert( pLower || pUpper );\n#endif\n  assert( pUpper==0 || (pUpper->wtFlags & TERM_VNULL)==0 );\n  nNew = whereRangeAdjust(pLower, nOut);\n  nNew = whereRangeAdjust(pUpper, nNew);\n\n  /* TUNING: If there is both an upper and lower limit and neither limit\n  ** has an application-defined likelihood(), assume the range is\n  ** reduced by an additional 75%. This means that, by default, an open-ended\n  ** range query (e.g. col > ?) is assumed to match 1/4 of the rows in the\n  ** index. While a closed range (e.g. col BETWEEN ? AND ?) is estimated to\n  ** match 1/64 of the index. */ \n  if( pLower && pLower->truthProb>0 && pUpper && pUpper->truthProb>0 ){\n    nNew -= 20;\n  }\n\n  nOut -= (pLower!=0) + (pUpper!=0);\n  if( nNew<10 ) nNew = 10;\n  if( nNew<nOut ) nOut = nNew;\n#if defined(WHERETRACE_ENABLED)\n  if( pLoop->nOut>nOut ){\n    WHERETRACE(0x10,(\"Range scan lowers nOut from %d to %d\\n\",\n                    pLoop->nOut, nOut));\n  }\n#endif\n  pLoop->nOut = (LogEst)nOut;\n  return rc;\n}\n\n#ifdef SQLITE_ENABLE_STAT3_OR_STAT4\n/*\n** Estimate the number of rows that will be returned based on\n** an equality constraint x=VALUE and where that VALUE occurs in\n** the histogram data.  This only works when x is the left-most\n** column of an index and sqlite_stat3 histogram data is available\n** for that index.  When pExpr==NULL that means the constraint is\n** \"x IS NULL\" instead of \"x=VALUE\".\n**\n** Write the estimated row count into *pnRow and return SQLITE_OK. \n** If unable to make an estimate, leave *pnRow unchanged and return\n** non-zero.\n**\n** This routine can fail if it is unable to load a collating sequence\n** required for string comparison, or if unable to allocate memory\n** for a UTF conversion required for comparison.  The error is stored\n** in the pParse structure.\n*/\nstatic int whereEqualScanEst(\n  Parse *pParse,       /* Parsing & code generating context */\n  WhereLoopBuilder *pBuilder,\n  Expr *pExpr,         /* Expression for VALUE in the x=VALUE constraint */\n  tRowcnt *pnRow       /* Write the revised row estimate here */\n){\n  Index *p = pBuilder->pNew->u.btree.pIndex;\n  int nEq = pBuilder->pNew->u.btree.nEq;\n  UnpackedRecord *pRec = pBuilder->pRec;\n  int rc;                   /* Subfunction return code */\n  tRowcnt a[2];             /* Statistics */\n  int bOk;\n\n  assert( nEq>=1 );\n  assert( nEq<=p->nColumn );\n  assert( p->aSample!=0 );\n  assert( p->nSample>0 );\n  assert( pBuilder->nRecValid<nEq );\n\n  /* If values are not available for all fields of the index to the left\n  ** of this one, no estimate can be made. Return SQLITE_NOTFOUND. */\n  if( pBuilder->nRecValid<(nEq-1) ){\n    return SQLITE_NOTFOUND;\n  }\n\n  /* This is an optimization only. The call to sqlite3Stat4ProbeSetValue()\n  ** below would return the same value.  */\n  if( nEq>=p->nColumn ){\n    *pnRow = 1;\n    return SQLITE_OK;\n  }\n\n  rc = sqlite3Stat4ProbeSetValue(pParse, p, &pRec, pExpr, 1, nEq-1, &bOk);\n  pBuilder->pRec = pRec;\n  if( rc!=SQLITE_OK ) return rc;\n  if( bOk==0 ) return SQLITE_NOTFOUND;\n  pBuilder->nRecValid = nEq;\n\n  whereKeyStats(pParse, p, pRec, 0, a);\n  WHERETRACE(0x10,(\"equality scan regions %s(%d): %d\\n\",\n                   p->zName, nEq-1, (int)a[1]));\n  *pnRow = a[1];\n  \n  return rc;\n}\n#endif /* SQLITE_ENABLE_STAT3_OR_STAT4 */\n\n#ifdef SQLITE_ENABLE_STAT3_OR_STAT4\n/*\n** Estimate the number of rows that will be returned based on\n** an IN constraint where the right-hand side of the IN operator\n** is a list of values.  Example:\n**\n**        WHERE x IN (1,2,3,4)\n**\n** Write the estimated row count into *pnRow and return SQLITE_OK. \n** If unable to make an estimate, leave *pnRow unchanged and return\n** non-zero.\n**\n** This routine can fail if it is unable to load a collating sequence\n** required for string comparison, or if unable to allocate memory\n** for a UTF conversion required for comparison.  The error is stored\n** in the pParse structure.\n*/\nstatic int whereInScanEst(\n  Parse *pParse,       /* Parsing & code generating context */\n  WhereLoopBuilder *pBuilder,\n  ExprList *pList,     /* The value list on the RHS of \"x IN (v1,v2,v3,...)\" */\n  tRowcnt *pnRow       /* Write the revised row estimate here */\n){\n  Index *p = pBuilder->pNew->u.btree.pIndex;\n  i64 nRow0 = sqlite3LogEstToInt(p->aiRowLogEst[0]);\n  int nRecValid = pBuilder->nRecValid;\n  int rc = SQLITE_OK;     /* Subfunction return code */\n  tRowcnt nEst;           /* Number of rows for a single term */\n  tRowcnt nRowEst = 0;    /* New estimate of the number of rows */\n  int i;                  /* Loop counter */\n\n  assert( p->aSample!=0 );\n  for(i=0; rc==SQLITE_OK && i<pList->nExpr; i++){\n    nEst = nRow0;\n    rc = whereEqualScanEst(pParse, pBuilder, pList->a[i].pExpr, &nEst);\n    nRowEst += nEst;\n    pBuilder->nRecValid = nRecValid;\n  }\n\n  if( rc==SQLITE_OK ){\n    if( nRowEst > nRow0 ) nRowEst = nRow0;\n    *pnRow = nRowEst;\n    WHERETRACE(0x10,(\"IN row estimate: est=%d\\n\", nRowEst));\n  }\n  assert( pBuilder->nRecValid==nRecValid );\n  return rc;\n}\n#endif /* SQLITE_ENABLE_STAT3_OR_STAT4 */\n\n\n#ifdef WHERETRACE_ENABLED\n/*\n** Print the content of a WhereTerm object\n*/\nstatic void whereTermPrint(WhereTerm *pTerm, int iTerm){\n  if( pTerm==0 ){\n    sqlite3DebugPrintf(\"TERM-%-3d NULL\\n\", iTerm);\n  }else{\n    char zType[4];\n    char zLeft[50];\n    memcpy(zType, \"...\", 4);\n    if( pTerm->wtFlags & TERM_VIRTUAL ) zType[0] = 'V';\n    if( pTerm->eOperator & WO_EQUIV  ) zType[1] = 'E';\n    if( ExprHasProperty(pTerm->pExpr, EP_FromJoin) ) zType[2] = 'L';\n    if( pTerm->eOperator & WO_SINGLE ){\n      sqlite3_snprintf(sizeof(zLeft),zLeft,\"left={%d:%d}\",\n                       pTerm->leftCursor, pTerm->u.leftColumn);\n    }else if( (pTerm->eOperator & WO_OR)!=0 && pTerm->u.pOrInfo!=0 ){\n      sqlite3_snprintf(sizeof(zLeft),zLeft,\"indexable=0x%lld\", \n                       pTerm->u.pOrInfo->indexable);\n    }else{\n      sqlite3_snprintf(sizeof(zLeft),zLeft,\"left=%d\", pTerm->leftCursor);\n    }\n    sqlite3DebugPrintf(\n       \"TERM-%-3d %p %s %-12s prob=%-3d op=0x%03x wtFlags=0x%04x\",\n       iTerm, pTerm, zType, zLeft, pTerm->truthProb,\n       pTerm->eOperator, pTerm->wtFlags);\n    if( pTerm->iField ){\n      sqlite3DebugPrintf(\" iField=%d\\n\", pTerm->iField);\n    }else{\n      sqlite3DebugPrintf(\"\\n\");\n    }\n    sqlite3TreeViewExpr(0, pTerm->pExpr, 0);\n  }\n}\n#endif\n\n#ifdef WHERETRACE_ENABLED\n/*\n** Show the complete content of a WhereClause\n*/\nSQLITE_PRIVATE void sqlite3WhereClausePrint(WhereClause *pWC){\n  int i;\n  for(i=0; i<pWC->nTerm; i++){\n    whereTermPrint(&pWC->a[i], i);\n  }\n}\n#endif\n\n#ifdef WHERETRACE_ENABLED\n/*\n** Print a WhereLoop object for debugging purposes\n*/\nstatic void whereLoopPrint(WhereLoop *p, WhereClause *pWC){\n  WhereInfo *pWInfo = pWC->pWInfo;\n  int nb = 1+(pWInfo->pTabList->nSrc+3)/4;\n  struct SrcList_item *pItem = pWInfo->pTabList->a + p->iTab;\n  Table *pTab = pItem->pTab;\n  Bitmask mAll = (((Bitmask)1)<<(nb*4)) - 1;\n  sqlite3DebugPrintf(\"%c%2d.%0*llx.%0*llx\", p->cId,\n                     p->iTab, nb, p->maskSelf, nb, p->prereq & mAll);\n  sqlite3DebugPrintf(\" %12s\",\n                     pItem->zAlias ? pItem->zAlias : pTab->zName);\n  if( (p->wsFlags & WHERE_VIRTUALTABLE)==0 ){\n    const char *zName;\n    if( p->u.btree.pIndex && (zName = p->u.btree.pIndex->zName)!=0 ){\n      if( strncmp(zName, \"sqlite_autoindex_\", 17)==0 ){\n        int i = sqlite3Strlen30(zName) - 1;\n        while( zName[i]!='_' ) i--;\n        zName += i;\n      }\n      sqlite3DebugPrintf(\".%-16s %2d\", zName, p->u.btree.nEq);\n    }else{\n      sqlite3DebugPrintf(\"%20s\",\"\");\n    }\n  }else{\n    char *z;\n    if( p->u.vtab.idxStr ){\n      z = sqlite3_mprintf(\"(%d,\\\"%s\\\",%x)\",\n                p->u.vtab.idxNum, p->u.vtab.idxStr, p->u.vtab.omitMask);\n    }else{\n      z = sqlite3_mprintf(\"(%d,%x)\", p->u.vtab.idxNum, p->u.vtab.omitMask);\n    }\n    sqlite3DebugPrintf(\" %-19s\", z);\n    sqlite3_free(z);\n  }\n  if( p->wsFlags & WHERE_SKIPSCAN ){\n    sqlite3DebugPrintf(\" f %05x %d-%d\", p->wsFlags, p->nLTerm,p->nSkip);\n  }else{\n    sqlite3DebugPrintf(\" f %05x N %d\", p->wsFlags, p->nLTerm);\n  }\n  sqlite3DebugPrintf(\" cost %d,%d,%d\\n\", p->rSetup, p->rRun, p->nOut);\n  if( p->nLTerm && (sqlite3WhereTrace & 0x100)!=0 ){\n    int i;\n    for(i=0; i<p->nLTerm; i++){\n      whereTermPrint(p->aLTerm[i], i);\n    }\n  }\n}\n#endif\n\n/*\n** Convert bulk memory into a valid WhereLoop that can be passed\n** to whereLoopClear harmlessly.\n*/\nstatic void whereLoopInit(WhereLoop *p){\n  p->aLTerm = p->aLTermSpace;\n  p->nLTerm = 0;\n  p->nLSlot = ArraySize(p->aLTermSpace);\n  p->wsFlags = 0;\n}\n\n/*\n** Clear the WhereLoop.u union.  Leave WhereLoop.pLTerm intact.\n*/\nstatic void whereLoopClearUnion(sqlite3 *db, WhereLoop *p){\n  if( p->wsFlags & (WHERE_VIRTUALTABLE|WHERE_AUTO_INDEX) ){\n    if( (p->wsFlags & WHERE_VIRTUALTABLE)!=0 && p->u.vtab.needFree ){\n      sqlite3_free(p->u.vtab.idxStr);\n      p->u.vtab.needFree = 0;\n      p->u.vtab.idxStr = 0;\n    }else if( (p->wsFlags & WHERE_AUTO_INDEX)!=0 && p->u.btree.pIndex!=0 ){\n      sqlite3DbFree(db, p->u.btree.pIndex->zColAff);\n      sqlite3DbFreeNN(db, p->u.btree.pIndex);\n      p->u.btree.pIndex = 0;\n    }\n  }\n}\n\n/*\n** Deallocate internal memory used by a WhereLoop object\n*/\nstatic void whereLoopClear(sqlite3 *db, WhereLoop *p){\n  if( p->aLTerm!=p->aLTermSpace ) sqlite3DbFreeNN(db, p->aLTerm);\n  whereLoopClearUnion(db, p);\n  whereLoopInit(p);\n}\n\n/*\n** Increase the memory allocation for pLoop->aLTerm[] to be at least n.\n*/\nstatic int whereLoopResize(sqlite3 *db, WhereLoop *p, int n){\n  WhereTerm **paNew;\n  if( p->nLSlot>=n ) return SQLITE_OK;\n  n = (n+7)&~7;\n  paNew = sqlite3DbMallocRawNN(db, sizeof(p->aLTerm[0])*n);\n  if( paNew==0 ) return SQLITE_NOMEM_BKPT;\n  memcpy(paNew, p->aLTerm, sizeof(p->aLTerm[0])*p->nLSlot);\n  if( p->aLTerm!=p->aLTermSpace ) sqlite3DbFreeNN(db, p->aLTerm);\n  p->aLTerm = paNew;\n  p->nLSlot = n;\n  return SQLITE_OK;\n}\n\n/*\n** Transfer content from the second pLoop into the first.\n*/\nstatic int whereLoopXfer(sqlite3 *db, WhereLoop *pTo, WhereLoop *pFrom){\n  whereLoopClearUnion(db, pTo);\n  if( whereLoopResize(db, pTo, pFrom->nLTerm) ){\n    memset(&pTo->u, 0, sizeof(pTo->u));\n    return SQLITE_NOMEM_BKPT;\n  }\n  memcpy(pTo, pFrom, WHERE_LOOP_XFER_SZ);\n  memcpy(pTo->aLTerm, pFrom->aLTerm, pTo->nLTerm*sizeof(pTo->aLTerm[0]));\n  if( pFrom->wsFlags & WHERE_VIRTUALTABLE ){\n    pFrom->u.vtab.needFree = 0;\n  }else if( (pFrom->wsFlags & WHERE_AUTO_INDEX)!=0 ){\n    pFrom->u.btree.pIndex = 0;\n  }\n  return SQLITE_OK;\n}\n\n/*\n** Delete a WhereLoop object\n*/\nstatic void whereLoopDelete(sqlite3 *db, WhereLoop *p){\n  whereLoopClear(db, p);\n  sqlite3DbFreeNN(db, p);\n}\n\n/*\n** Free a WhereInfo structure\n*/\nstatic void whereInfoFree(sqlite3 *db, WhereInfo *pWInfo){\n  int i;\n  assert( pWInfo!=0 );\n  for(i=0; i<pWInfo->nLevel; i++){\n    WhereLevel *pLevel = &pWInfo->a[i];\n    if( pLevel->pWLoop && (pLevel->pWLoop->wsFlags & WHERE_IN_ABLE) ){\n      sqlite3DbFree(db, pLevel->u.in.aInLoop);\n    }\n  }\n  sqlite3WhereClauseClear(&pWInfo->sWC);\n  while( pWInfo->pLoops ){\n    WhereLoop *p = pWInfo->pLoops;\n    pWInfo->pLoops = p->pNextLoop;\n    whereLoopDelete(db, p);\n  }\n  sqlite3DbFreeNN(db, pWInfo);\n}\n\n/*\n** Return TRUE if all of the following are true:\n**\n**   (1)  X has the same or lower cost that Y\n**   (2)  X uses fewer WHERE clause terms than Y\n**   (3)  Every WHERE clause term used by X is also used by Y\n**   (4)  X skips at least as many columns as Y\n**   (5)  If X is a covering index, than Y is too\n**\n** Conditions (2) and (3) mean that X is a \"proper subset\" of Y.\n** If X is a proper subset of Y then Y is a better choice and ought\n** to have a lower cost.  This routine returns TRUE when that cost \n** relationship is inverted and needs to be adjusted.  Constraint (4)\n** was added because if X uses skip-scan less than Y it still might\n** deserve a lower cost even if it is a proper subset of Y.  Constraint (5)\n** was added because a covering index probably deserves to have a lower cost\n** than a non-covering index even if it is a proper subset.\n*/\nstatic int whereLoopCheaperProperSubset(\n  const WhereLoop *pX,       /* First WhereLoop to compare */\n  const WhereLoop *pY        /* Compare against this WhereLoop */\n){\n  int i, j;\n  if( pX->nLTerm-pX->nSkip >= pY->nLTerm-pY->nSkip ){\n    return 0; /* X is not a subset of Y */\n  }\n  if( pY->nSkip > pX->nSkip ) return 0;\n  if( pX->rRun >= pY->rRun ){\n    if( pX->rRun > pY->rRun ) return 0;    /* X costs more than Y */\n    if( pX->nOut > pY->nOut ) return 0;    /* X costs more than Y */\n  }\n  for(i=pX->nLTerm-1; i>=0; i--){\n    if( pX->aLTerm[i]==0 ) continue;\n    for(j=pY->nLTerm-1; j>=0; j--){\n      if( pY->aLTerm[j]==pX->aLTerm[i] ) break;\n    }\n    if( j<0 ) return 0;  /* X not a subset of Y since term X[i] not used by Y */\n  }\n  if( (pX->wsFlags&WHERE_IDX_ONLY)!=0 \n   && (pY->wsFlags&WHERE_IDX_ONLY)==0 ){\n    return 0;  /* Constraint (5) */\n  }\n  return 1;  /* All conditions meet */\n}\n\n/*\n** Try to adjust the cost of WhereLoop pTemplate upwards or downwards so\n** that:\n**\n**   (1) pTemplate costs less than any other WhereLoops that are a proper\n**       subset of pTemplate\n**\n**   (2) pTemplate costs more than any other WhereLoops for which pTemplate\n**       is a proper subset.\n**\n** To say \"WhereLoop X is a proper subset of Y\" means that X uses fewer\n** WHERE clause terms than Y and that every WHERE clause term used by X is\n** also used by Y.\n*/\nstatic void whereLoopAdjustCost(const WhereLoop *p, WhereLoop *pTemplate){\n  if( (pTemplate->wsFlags & WHERE_INDEXED)==0 ) return;\n  for(; p; p=p->pNextLoop){\n    if( p->iTab!=pTemplate->iTab ) continue;\n    if( (p->wsFlags & WHERE_INDEXED)==0 ) continue;\n    if( whereLoopCheaperProperSubset(p, pTemplate) ){\n      /* Adjust pTemplate cost downward so that it is cheaper than its \n      ** subset p. */\n      WHERETRACE(0x80,(\"subset cost adjustment %d,%d to %d,%d\\n\",\n                       pTemplate->rRun, pTemplate->nOut, p->rRun, p->nOut-1));\n      pTemplate->rRun = p->rRun;\n      pTemplate->nOut = p->nOut - 1;\n    }else if( whereLoopCheaperProperSubset(pTemplate, p) ){\n      /* Adjust pTemplate cost upward so that it is costlier than p since\n      ** pTemplate is a proper subset of p */\n      WHERETRACE(0x80,(\"subset cost adjustment %d,%d to %d,%d\\n\",\n                       pTemplate->rRun, pTemplate->nOut, p->rRun, p->nOut+1));\n      pTemplate->rRun = p->rRun;\n      pTemplate->nOut = p->nOut + 1;\n    }\n  }\n}\n\n/*\n** Search the list of WhereLoops in *ppPrev looking for one that can be\n** replaced by pTemplate.\n**\n** Return NULL if pTemplate does not belong on the WhereLoop list.\n** In other words if pTemplate ought to be dropped from further consideration.\n**\n** If pX is a WhereLoop that pTemplate can replace, then return the\n** link that points to pX.\n**\n** If pTemplate cannot replace any existing element of the list but needs\n** to be added to the list as a new entry, then return a pointer to the\n** tail of the list.\n*/\nstatic WhereLoop **whereLoopFindLesser(\n  WhereLoop **ppPrev,\n  const WhereLoop *pTemplate\n){\n  WhereLoop *p;\n  for(p=(*ppPrev); p; ppPrev=&p->pNextLoop, p=*ppPrev){\n    if( p->iTab!=pTemplate->iTab || p->iSortIdx!=pTemplate->iSortIdx ){\n      /* If either the iTab or iSortIdx values for two WhereLoop are different\n      ** then those WhereLoops need to be considered separately.  Neither is\n      ** a candidate to replace the other. */\n      continue;\n    }\n    /* In the current implementation, the rSetup value is either zero\n    ** or the cost of building an automatic index (NlogN) and the NlogN\n    ** is the same for compatible WhereLoops. */\n    assert( p->rSetup==0 || pTemplate->rSetup==0 \n                 || p->rSetup==pTemplate->rSetup );\n\n    /* whereLoopAddBtree() always generates and inserts the automatic index\n    ** case first.  Hence compatible candidate WhereLoops never have a larger\n    ** rSetup. Call this SETUP-INVARIANT */\n    assert( p->rSetup>=pTemplate->rSetup );\n\n    /* Any loop using an appliation-defined index (or PRIMARY KEY or\n    ** UNIQUE constraint) with one or more == constraints is better\n    ** than an automatic index. Unless it is a skip-scan. */\n    if( (p->wsFlags & WHERE_AUTO_INDEX)!=0\n     && (pTemplate->nSkip)==0\n     && (pTemplate->wsFlags & WHERE_INDEXED)!=0\n     && (pTemplate->wsFlags & WHERE_COLUMN_EQ)!=0\n     && (p->prereq & pTemplate->prereq)==pTemplate->prereq\n    ){\n      break;\n    }\n\n    /* If existing WhereLoop p is better than pTemplate, pTemplate can be\n    ** discarded.  WhereLoop p is better if:\n    **   (1)  p has no more dependencies than pTemplate, and\n    **   (2)  p has an equal or lower cost than pTemplate\n    */\n    if( (p->prereq & pTemplate->prereq)==p->prereq    /* (1)  */\n     && p->rSetup<=pTemplate->rSetup                  /* (2a) */\n     && p->rRun<=pTemplate->rRun                      /* (2b) */\n     && p->nOut<=pTemplate->nOut                      /* (2c) */\n    ){\n      return 0;  /* Discard pTemplate */\n    }\n\n    /* If pTemplate is always better than p, then cause p to be overwritten\n    ** with pTemplate.  pTemplate is better than p if:\n    **   (1)  pTemplate has no more dependences than p, and\n    **   (2)  pTemplate has an equal or lower cost than p.\n    */\n    if( (p->prereq & pTemplate->prereq)==pTemplate->prereq   /* (1)  */\n     && p->rRun>=pTemplate->rRun                             /* (2a) */\n     && p->nOut>=pTemplate->nOut                             /* (2b) */\n    ){\n      assert( p->rSetup>=pTemplate->rSetup ); /* SETUP-INVARIANT above */\n      break;   /* Cause p to be overwritten by pTemplate */\n    }\n  }\n  return ppPrev;\n}\n\n/*\n** Insert or replace a WhereLoop entry using the template supplied.\n**\n** An existing WhereLoop entry might be overwritten if the new template\n** is better and has fewer dependencies.  Or the template will be ignored\n** and no insert will occur if an existing WhereLoop is faster and has\n** fewer dependencies than the template.  Otherwise a new WhereLoop is\n** added based on the template.\n**\n** If pBuilder->pOrSet is not NULL then we care about only the\n** prerequisites and rRun and nOut costs of the N best loops.  That\n** information is gathered in the pBuilder->pOrSet object.  This special\n** processing mode is used only for OR clause processing.\n**\n** When accumulating multiple loops (when pBuilder->pOrSet is NULL) we\n** still might overwrite similar loops with the new template if the\n** new template is better.  Loops may be overwritten if the following \n** conditions are met:\n**\n**    (1)  They have the same iTab.\n**    (2)  They have the same iSortIdx.\n**    (3)  The template has same or fewer dependencies than the current loop\n**    (4)  The template has the same or lower cost than the current loop\n*/\nstatic int whereLoopInsert(WhereLoopBuilder *pBuilder, WhereLoop *pTemplate){\n  WhereLoop **ppPrev, *p;\n  WhereInfo *pWInfo = pBuilder->pWInfo;\n  sqlite3 *db = pWInfo->pParse->db;\n  int rc;\n\n  /* Stop the search once we hit the query planner search limit */\n  if( pBuilder->iPlanLimit==0 ){\n    WHERETRACE(0xffffffff,(\"=== query planner search limit reached ===\\n\"));\n    if( pBuilder->pOrSet ) pBuilder->pOrSet->n = 0;\n    return SQLITE_DONE;\n  }\n  pBuilder->iPlanLimit--;\n\n  /* If pBuilder->pOrSet is defined, then only keep track of the costs\n  ** and prereqs.\n  */\n  if( pBuilder->pOrSet!=0 ){\n    if( pTemplate->nLTerm ){\n#if WHERETRACE_ENABLED\n      u16 n = pBuilder->pOrSet->n;\n      int x =\n#endif\n      whereOrInsert(pBuilder->pOrSet, pTemplate->prereq, pTemplate->rRun,\n                                    pTemplate->nOut);\n#if WHERETRACE_ENABLED /* 0x8 */\n      if( sqlite3WhereTrace & 0x8 ){\n        sqlite3DebugPrintf(x?\"   or-%d:  \":\"   or-X:  \", n);\n        whereLoopPrint(pTemplate, pBuilder->pWC);\n      }\n#endif\n    }\n    return SQLITE_OK;\n  }\n\n  /* Look for an existing WhereLoop to replace with pTemplate\n  */\n  whereLoopAdjustCost(pWInfo->pLoops, pTemplate);\n  ppPrev = whereLoopFindLesser(&pWInfo->pLoops, pTemplate);\n\n  if( ppPrev==0 ){\n    /* There already exists a WhereLoop on the list that is better\n    ** than pTemplate, so just ignore pTemplate */\n#if WHERETRACE_ENABLED /* 0x8 */\n    if( sqlite3WhereTrace & 0x8 ){\n      sqlite3DebugPrintf(\"   skip: \");\n      whereLoopPrint(pTemplate, pBuilder->pWC);\n    }\n#endif\n    return SQLITE_OK;  \n  }else{\n    p = *ppPrev;\n  }\n\n  /* If we reach this point it means that either p[] should be overwritten\n  ** with pTemplate[] if p[] exists, or if p==NULL then allocate a new\n  ** WhereLoop and insert it.\n  */\n#if WHERETRACE_ENABLED /* 0x8 */\n  if( sqlite3WhereTrace & 0x8 ){\n    if( p!=0 ){\n      sqlite3DebugPrintf(\"replace: \");\n      whereLoopPrint(p, pBuilder->pWC);\n      sqlite3DebugPrintf(\"   with: \");\n    }else{\n      sqlite3DebugPrintf(\"    add: \");\n    }\n    whereLoopPrint(pTemplate, pBuilder->pWC);\n  }\n#endif\n  if( p==0 ){\n    /* Allocate a new WhereLoop to add to the end of the list */\n    *ppPrev = p = sqlite3DbMallocRawNN(db, sizeof(WhereLoop));\n    if( p==0 ) return SQLITE_NOMEM_BKPT;\n    whereLoopInit(p);\n    p->pNextLoop = 0;\n  }else{\n    /* We will be overwriting WhereLoop p[].  But before we do, first\n    ** go through the rest of the list and delete any other entries besides\n    ** p[] that are also supplated by pTemplate */\n    WhereLoop **ppTail = &p->pNextLoop;\n    WhereLoop *pToDel;\n    while( *ppTail ){\n      ppTail = whereLoopFindLesser(ppTail, pTemplate);\n      if( ppTail==0 ) break;\n      pToDel = *ppTail;\n      if( pToDel==0 ) break;\n      *ppTail = pToDel->pNextLoop;\n#if WHERETRACE_ENABLED /* 0x8 */\n      if( sqlite3WhereTrace & 0x8 ){\n        sqlite3DebugPrintf(\" delete: \");\n        whereLoopPrint(pToDel, pBuilder->pWC);\n      }\n#endif\n      whereLoopDelete(db, pToDel);\n    }\n  }\n  rc = whereLoopXfer(db, p, pTemplate);\n  if( (p->wsFlags & WHERE_VIRTUALTABLE)==0 ){\n    Index *pIndex = p->u.btree.pIndex;\n    if( pIndex && pIndex->idxType==SQLITE_IDXTYPE_IPK ){\n      p->u.btree.pIndex = 0;\n    }\n  }\n  return rc;\n}\n\n/*\n** Adjust the WhereLoop.nOut value downward to account for terms of the\n** WHERE clause that reference the loop but which are not used by an\n** index.\n*\n** For every WHERE clause term that is not used by the index\n** and which has a truth probability assigned by one of the likelihood(),\n** likely(), or unlikely() SQL functions, reduce the estimated number\n** of output rows by the probability specified.\n**\n** TUNING:  For every WHERE clause term that is not used by the index\n** and which does not have an assigned truth probability, heuristics\n** described below are used to try to estimate the truth probability.\n** TODO --> Perhaps this is something that could be improved by better\n** table statistics.\n**\n** Heuristic 1:  Estimate the truth probability as 93.75%.  The 93.75%\n** value corresponds to -1 in LogEst notation, so this means decrement\n** the WhereLoop.nOut field for every such WHERE clause term.\n**\n** Heuristic 2:  If there exists one or more WHERE clause terms of the\n** form \"x==EXPR\" and EXPR is not a constant 0 or 1, then make sure the\n** final output row estimate is no greater than 1/4 of the total number\n** of rows in the table.  In other words, assume that x==EXPR will filter\n** out at least 3 out of 4 rows.  If EXPR is -1 or 0 or 1, then maybe the\n** \"x\" column is boolean or else -1 or 0 or 1 is a common default value\n** on the \"x\" column and so in that case only cap the output row estimate\n** at 1/2 instead of 1/4.\n*/\nstatic void whereLoopOutputAdjust(\n  WhereClause *pWC,      /* The WHERE clause */\n  WhereLoop *pLoop,      /* The loop to adjust downward */\n  LogEst nRow            /* Number of rows in the entire table */\n){\n  WhereTerm *pTerm, *pX;\n  Bitmask notAllowed = ~(pLoop->prereq|pLoop->maskSelf);\n  int i, j, k;\n  LogEst iReduce = 0;    /* pLoop->nOut should not exceed nRow-iReduce */\n\n  assert( (pLoop->wsFlags & WHERE_AUTO_INDEX)==0 );\n  for(i=pWC->nTerm, pTerm=pWC->a; i>0; i--, pTerm++){\n    if( (pTerm->wtFlags & TERM_VIRTUAL)!=0 ) break;\n    if( (pTerm->prereqAll & pLoop->maskSelf)==0 ) continue;\n    if( (pTerm->prereqAll & notAllowed)!=0 ) continue;\n    for(j=pLoop->nLTerm-1; j>=0; j--){\n      pX = pLoop->aLTerm[j];\n      if( pX==0 ) continue;\n      if( pX==pTerm ) break;\n      if( pX->iParent>=0 && (&pWC->a[pX->iParent])==pTerm ) break;\n    }\n    if( j<0 ){\n      if( pTerm->truthProb<=0 ){\n        /* If a truth probability is specified using the likelihood() hints,\n        ** then use the probability provided by the application. */\n        pLoop->nOut += pTerm->truthProb;\n      }else{\n        /* In the absence of explicit truth probabilities, use heuristics to\n        ** guess a reasonable truth probability. */\n        pLoop->nOut--;\n        if( pTerm->eOperator&(WO_EQ|WO_IS) ){\n          Expr *pRight = pTerm->pExpr->pRight;\n          testcase( pTerm->pExpr->op==TK_IS );\n          if( sqlite3ExprIsInteger(pRight, &k) && k>=(-1) && k<=1 ){\n            k = 10;\n          }else{\n            k = 20;\n          }\n          if( iReduce<k ) iReduce = k;\n        }\n      }\n    }\n  }\n  if( pLoop->nOut > nRow-iReduce )  pLoop->nOut = nRow - iReduce;\n}\n\n/* \n** Term pTerm is a vector range comparison operation. The first comparison\n** in the vector can be optimized using column nEq of the index. This\n** function returns the total number of vector elements that can be used\n** as part of the range comparison.\n**\n** For example, if the query is:\n**\n**   WHERE a = ? AND (b, c, d) > (?, ?, ?)\n**\n** and the index:\n**\n**   CREATE INDEX ... ON (a, b, c, d, e)\n**\n** then this function would be invoked with nEq=1. The value returned in\n** this case is 3.\n*/\nstatic int whereRangeVectorLen(\n  Parse *pParse,       /* Parsing context */\n  int iCur,            /* Cursor open on pIdx */\n  Index *pIdx,         /* The index to be used for a inequality constraint */\n  int nEq,             /* Number of prior equality constraints on same index */\n  WhereTerm *pTerm     /* The vector inequality constraint */\n){\n  int nCmp = sqlite3ExprVectorSize(pTerm->pExpr->pLeft);\n  int i;\n\n  nCmp = MIN(nCmp, (pIdx->nColumn - nEq));\n  for(i=1; i<nCmp; i++){\n    /* Test if comparison i of pTerm is compatible with column (i+nEq) \n    ** of the index. If not, exit the loop.  */\n    char aff;                     /* Comparison affinity */\n    char idxaff = 0;              /* Indexed columns affinity */\n    CollSeq *pColl;               /* Comparison collation sequence */\n    Expr *pLhs = pTerm->pExpr->pLeft->x.pList->a[i].pExpr;\n    Expr *pRhs = pTerm->pExpr->pRight;\n    if( pRhs->flags & EP_xIsSelect ){\n      pRhs = pRhs->x.pSelect->pEList->a[i].pExpr;\n    }else{\n      pRhs = pRhs->x.pList->a[i].pExpr;\n    }\n\n    /* Check that the LHS of the comparison is a column reference to\n    ** the right column of the right source table. And that the sort\n    ** order of the index column is the same as the sort order of the\n    ** leftmost index column.  */\n    if( pLhs->op!=TK_COLUMN \n     || pLhs->iTable!=iCur \n     || pLhs->iColumn!=pIdx->aiColumn[i+nEq] \n     || pIdx->aSortOrder[i+nEq]!=pIdx->aSortOrder[nEq]\n    ){\n      break;\n    }\n\n    testcase( pLhs->iColumn==XN_ROWID );\n    aff = sqlite3CompareAffinity(pRhs, sqlite3ExprAffinity(pLhs));\n    idxaff = sqlite3TableColumnAffinity(pIdx->pTable, pLhs->iColumn);\n    if( aff!=idxaff ) break;\n\n    pColl = sqlite3BinaryCompareCollSeq(pParse, pLhs, pRhs);\n    if( pColl==0 ) break;\n    if( sqlite3StrICmp(pColl->zName, pIdx->azColl[i+nEq]) ) break;\n  }\n  return i;\n}\n\n/*\n** Adjust the cost C by the costMult facter T.  This only occurs if\n** compiled with -DSQLITE_ENABLE_COSTMULT\n*/\n#ifdef SQLITE_ENABLE_COSTMULT\n# define ApplyCostMultiplier(C,T)  C += T\n#else\n# define ApplyCostMultiplier(C,T)\n#endif\n\n/*\n** We have so far matched pBuilder->pNew->u.btree.nEq terms of the \n** index pIndex. Try to match one more.\n**\n** When this function is called, pBuilder->pNew->nOut contains the \n** number of rows expected to be visited by filtering using the nEq \n** terms only. If it is modified, this value is restored before this \n** function returns.\n**\n** If pProbe->idxType==SQLITE_IDXTYPE_IPK, that means pIndex is \n** a fake index used for the INTEGER PRIMARY KEY.\n*/\nstatic int whereLoopAddBtreeIndex(\n  WhereLoopBuilder *pBuilder,     /* The WhereLoop factory */\n  struct SrcList_item *pSrc,      /* FROM clause term being analyzed */\n  Index *pProbe,                  /* An index on pSrc */\n  LogEst nInMul                   /* log(Number of iterations due to IN) */\n){\n  WhereInfo *pWInfo = pBuilder->pWInfo;  /* WHERE analyse context */\n  Parse *pParse = pWInfo->pParse;        /* Parsing context */\n  sqlite3 *db = pParse->db;       /* Database connection malloc context */\n  WhereLoop *pNew;                /* Template WhereLoop under construction */\n  WhereTerm *pTerm;               /* A WhereTerm under consideration */\n  int opMask;                     /* Valid operators for constraints */\n  WhereScan scan;                 /* Iterator for WHERE terms */\n  Bitmask saved_prereq;           /* Original value of pNew->prereq */\n  u16 saved_nLTerm;               /* Original value of pNew->nLTerm */\n  u16 saved_nEq;                  /* Original value of pNew->u.btree.nEq */\n  u16 saved_nBtm;                 /* Original value of pNew->u.btree.nBtm */\n  u16 saved_nTop;                 /* Original value of pNew->u.btree.nTop */\n  u16 saved_nSkip;                /* Original value of pNew->nSkip */\n  u32 saved_wsFlags;              /* Original value of pNew->wsFlags */\n  LogEst saved_nOut;              /* Original value of pNew->nOut */\n  int rc = SQLITE_OK;             /* Return code */\n  LogEst rSize;                   /* Number of rows in the table */\n  LogEst rLogSize;                /* Logarithm of table size */\n  WhereTerm *pTop = 0, *pBtm = 0; /* Top and bottom range constraints */\n\n  pNew = pBuilder->pNew;\n  if( db->mallocFailed ) return SQLITE_NOMEM_BKPT;\n  WHERETRACE(0x800, (\"BEGIN %s.addBtreeIdx(%s), nEq=%d\\n\",\n                     pProbe->pTable->zName,pProbe->zName, pNew->u.btree.nEq));\n\n  assert( (pNew->wsFlags & WHERE_VIRTUALTABLE)==0 );\n  assert( (pNew->wsFlags & WHERE_TOP_LIMIT)==0 );\n  if( pNew->wsFlags & WHERE_BTM_LIMIT ){\n    opMask = WO_LT|WO_LE;\n  }else{\n    assert( pNew->u.btree.nBtm==0 );\n    opMask = WO_EQ|WO_IN|WO_GT|WO_GE|WO_LT|WO_LE|WO_ISNULL|WO_IS;\n  }\n  if( pProbe->bUnordered ) opMask &= ~(WO_GT|WO_GE|WO_LT|WO_LE);\n\n  assert( pNew->u.btree.nEq<pProbe->nColumn );\n\n  saved_nEq = pNew->u.btree.nEq;\n  saved_nBtm = pNew->u.btree.nBtm;\n  saved_nTop = pNew->u.btree.nTop;\n  saved_nSkip = pNew->nSkip;\n  saved_nLTerm = pNew->nLTerm;\n  saved_wsFlags = pNew->wsFlags;\n  saved_prereq = pNew->prereq;\n  saved_nOut = pNew->nOut;\n  pTerm = whereScanInit(&scan, pBuilder->pWC, pSrc->iCursor, saved_nEq,\n                        opMask, pProbe);\n  pNew->rSetup = 0;\n  rSize = pProbe->aiRowLogEst[0];\n  rLogSize = estLog(rSize);\n  for(; rc==SQLITE_OK && pTerm!=0; pTerm = whereScanNext(&scan)){\n    u16 eOp = pTerm->eOperator;   /* Shorthand for pTerm->eOperator */\n    LogEst rCostIdx;\n    LogEst nOutUnadjusted;        /* nOut before IN() and WHERE adjustments */\n    int nIn = 0;\n#ifdef SQLITE_ENABLE_STAT3_OR_STAT4\n    int nRecValid = pBuilder->nRecValid;\n#endif\n    if( (eOp==WO_ISNULL || (pTerm->wtFlags&TERM_VNULL)!=0)\n     && indexColumnNotNull(pProbe, saved_nEq)\n    ){\n      continue; /* ignore IS [NOT] NULL constraints on NOT NULL columns */\n    }\n    if( pTerm->prereqRight & pNew->maskSelf ) continue;\n\n    /* Do not allow the upper bound of a LIKE optimization range constraint\n    ** to mix with a lower range bound from some other source */\n    if( pTerm->wtFlags & TERM_LIKEOPT && pTerm->eOperator==WO_LT ) continue;\n\n    /* Do not allow constraints from the WHERE clause to be used by the\n    ** right table of a LEFT JOIN.  Only constraints in the ON clause are\n    ** allowed */\n    if( (pSrc->fg.jointype & JT_LEFT)!=0\n     && !ExprHasProperty(pTerm->pExpr, EP_FromJoin)\n    ){\n      continue;\n    }\n\n    if( IsUniqueIndex(pProbe) && saved_nEq==pProbe->nKeyCol-1 ){\n      pBuilder->bldFlags |= SQLITE_BLDF_UNIQUE;\n    }else{\n      pBuilder->bldFlags |= SQLITE_BLDF_INDEXED;\n    }\n    pNew->wsFlags = saved_wsFlags;\n    pNew->u.btree.nEq = saved_nEq;\n    pNew->u.btree.nBtm = saved_nBtm;\n    pNew->u.btree.nTop = saved_nTop;\n    pNew->nLTerm = saved_nLTerm;\n    if( whereLoopResize(db, pNew, pNew->nLTerm+1) ) break; /* OOM */\n    pNew->aLTerm[pNew->nLTerm++] = pTerm;\n    pNew->prereq = (saved_prereq | pTerm->prereqRight) & ~pNew->maskSelf;\n\n    assert( nInMul==0\n        || (pNew->wsFlags & WHERE_COLUMN_NULL)!=0 \n        || (pNew->wsFlags & WHERE_COLUMN_IN)!=0 \n        || (pNew->wsFlags & WHERE_SKIPSCAN)!=0 \n    );\n\n    if( eOp & WO_IN ){\n      Expr *pExpr = pTerm->pExpr;\n      if( ExprHasProperty(pExpr, EP_xIsSelect) ){\n        /* \"x IN (SELECT ...)\":  TUNING: the SELECT returns 25 rows */\n        int i;\n        nIn = 46;  assert( 46==sqlite3LogEst(25) );\n\n        /* The expression may actually be of the form (x, y) IN (SELECT...).\n        ** In this case there is a separate term for each of (x) and (y).\n        ** However, the nIn multiplier should only be applied once, not once\n        ** for each such term. The following loop checks that pTerm is the\n        ** first such term in use, and sets nIn back to 0 if it is not. */\n        for(i=0; i<pNew->nLTerm-1; i++){\n          if( pNew->aLTerm[i] && pNew->aLTerm[i]->pExpr==pExpr ) nIn = 0;\n        }\n      }else if( ALWAYS(pExpr->x.pList && pExpr->x.pList->nExpr) ){\n        /* \"x IN (value, value, ...)\" */\n        nIn = sqlite3LogEst(pExpr->x.pList->nExpr);\n        assert( nIn>0 );  /* RHS always has 2 or more terms...  The parser\n                          ** changes \"x IN (?)\" into \"x=?\". */\n      }\n      if( pProbe->hasStat1 ){\n        LogEst M, logK, safetyMargin;\n        /* Let:\n        **   N = the total number of rows in the table\n        **   K = the number of entries on the RHS of the IN operator\n        **   M = the number of rows in the table that match terms to the \n        **       to the left in the same index.  If the IN operator is on\n        **       the left-most index column, M==N.\n        **\n        ** Given the definitions above, it is better to omit the IN operator\n        ** from the index lookup and instead do a scan of the M elements,\n        ** testing each scanned row against the IN operator separately, if:\n        **\n        **        M*log(K) < K*log(N)\n        **\n        ** Our estimates for M, K, and N might be inaccurate, so we build in\n        ** a safety margin of 2 (LogEst: 10) that favors using the IN operator\n        ** with the index, as using an index has better worst-case behavior.\n        ** If we do not have real sqlite_stat1 data, always prefer to use\n        ** the index.\n        */\n        M = pProbe->aiRowLogEst[saved_nEq];\n        logK = estLog(nIn);\n        safetyMargin = 10;  /* TUNING: extra weight for indexed IN */\n        if( M + logK + safetyMargin < nIn + rLogSize ){\n          WHERETRACE(0x40,\n            (\"Scan preferred over IN operator on column %d of \\\"%s\\\" (%d<%d)\\n\",\n             saved_nEq, pProbe->zName, M+logK+10, nIn+rLogSize));\n          continue;\n        }else{\n          WHERETRACE(0x40,\n            (\"IN operator preferred on column %d of \\\"%s\\\" (%d>=%d)\\n\",\n             saved_nEq, pProbe->zName, M+logK+10, nIn+rLogSize));\n        }\n      }\n      pNew->wsFlags |= WHERE_COLUMN_IN;\n    }else if( eOp & (WO_EQ|WO_IS) ){\n      int iCol = pProbe->aiColumn[saved_nEq];\n      pNew->wsFlags |= WHERE_COLUMN_EQ;\n      assert( saved_nEq==pNew->u.btree.nEq );\n      if( iCol==XN_ROWID \n       || (iCol>=0 && nInMul==0 && saved_nEq==pProbe->nKeyCol-1)\n      ){\n        if( iCol==XN_ROWID || pProbe->uniqNotNull \n         || (pProbe->nKeyCol==1 && pProbe->onError && eOp==WO_EQ) \n        ){\n          pNew->wsFlags |= WHERE_ONEROW;\n        }else{\n          pNew->wsFlags |= WHERE_UNQ_WANTED;\n        }\n      }\n    }else if( eOp & WO_ISNULL ){\n      pNew->wsFlags |= WHERE_COLUMN_NULL;\n    }else if( eOp & (WO_GT|WO_GE) ){\n      testcase( eOp & WO_GT );\n      testcase( eOp & WO_GE );\n      pNew->wsFlags |= WHERE_COLUMN_RANGE|WHERE_BTM_LIMIT;\n      pNew->u.btree.nBtm = whereRangeVectorLen(\n          pParse, pSrc->iCursor, pProbe, saved_nEq, pTerm\n      );\n      pBtm = pTerm;\n      pTop = 0;\n      if( pTerm->wtFlags & TERM_LIKEOPT ){\n        /* Range contraints that come from the LIKE optimization are\n        ** always used in pairs. */\n        pTop = &pTerm[1];\n        assert( (pTop-(pTerm->pWC->a))<pTerm->pWC->nTerm );\n        assert( pTop->wtFlags & TERM_LIKEOPT );\n        assert( pTop->eOperator==WO_LT );\n        if( whereLoopResize(db, pNew, pNew->nLTerm+1) ) break; /* OOM */\n        pNew->aLTerm[pNew->nLTerm++] = pTop;\n        pNew->wsFlags |= WHERE_TOP_LIMIT;\n        pNew->u.btree.nTop = 1;\n      }\n    }else{\n      assert( eOp & (WO_LT|WO_LE) );\n      testcase( eOp & WO_LT );\n      testcase( eOp & WO_LE );\n      pNew->wsFlags |= WHERE_COLUMN_RANGE|WHERE_TOP_LIMIT;\n      pNew->u.btree.nTop = whereRangeVectorLen(\n          pParse, pSrc->iCursor, pProbe, saved_nEq, pTerm\n      );\n      pTop = pTerm;\n      pBtm = (pNew->wsFlags & WHERE_BTM_LIMIT)!=0 ?\n                     pNew->aLTerm[pNew->nLTerm-2] : 0;\n    }\n\n    /* At this point pNew->nOut is set to the number of rows expected to\n    ** be visited by the index scan before considering term pTerm, or the\n    ** values of nIn and nInMul. In other words, assuming that all \n    ** \"x IN(...)\" terms are replaced with \"x = ?\". This block updates\n    ** the value of pNew->nOut to account for pTerm (but not nIn/nInMul).  */\n    assert( pNew->nOut==saved_nOut );\n    if( pNew->wsFlags & WHERE_COLUMN_RANGE ){\n      /* Adjust nOut using stat3/stat4 data. Or, if there is no stat3/stat4\n      ** data, using some other estimate.  */\n      whereRangeScanEst(pParse, pBuilder, pBtm, pTop, pNew);\n    }else{\n      int nEq = ++pNew->u.btree.nEq;\n      assert( eOp & (WO_ISNULL|WO_EQ|WO_IN|WO_IS) );\n\n      assert( pNew->nOut==saved_nOut );\n      if( pTerm->truthProb<=0 && pProbe->aiColumn[saved_nEq]>=0 ){\n        assert( (eOp & WO_IN) || nIn==0 );\n        testcase( eOp & WO_IN );\n        pNew->nOut += pTerm->truthProb;\n        pNew->nOut -= nIn;\n      }else{\n#ifdef SQLITE_ENABLE_STAT3_OR_STAT4\n        tRowcnt nOut = 0;\n        if( nInMul==0 \n         && pProbe->nSample \n         && pNew->u.btree.nEq<=pProbe->nSampleCol\n         && ((eOp & WO_IN)==0 || !ExprHasProperty(pTerm->pExpr, EP_xIsSelect))\n         && OptimizationEnabled(db, SQLITE_Stat34)\n        ){\n          Expr *pExpr = pTerm->pExpr;\n          if( (eOp & (WO_EQ|WO_ISNULL|WO_IS))!=0 ){\n            testcase( eOp & WO_EQ );\n            testcase( eOp & WO_IS );\n            testcase( eOp & WO_ISNULL );\n            rc = whereEqualScanEst(pParse, pBuilder, pExpr->pRight, &nOut);\n          }else{\n            rc = whereInScanEst(pParse, pBuilder, pExpr->x.pList, &nOut);\n          }\n          if( rc==SQLITE_NOTFOUND ) rc = SQLITE_OK;\n          if( rc!=SQLITE_OK ) break;          /* Jump out of the pTerm loop */\n          if( nOut ){\n            pNew->nOut = sqlite3LogEst(nOut);\n            if( pNew->nOut>saved_nOut ) pNew->nOut = saved_nOut;\n            pNew->nOut -= nIn;\n          }\n        }\n        if( nOut==0 )\n#endif\n        {\n          pNew->nOut += (pProbe->aiRowLogEst[nEq] - pProbe->aiRowLogEst[nEq-1]);\n          if( eOp & WO_ISNULL ){\n            /* TUNING: If there is no likelihood() value, assume that a \n            ** \"col IS NULL\" expression matches twice as many rows \n            ** as (col=?). */\n            pNew->nOut += 10;\n          }\n        }\n      }\n    }\n\n    /* Set rCostIdx to the cost of visiting selected rows in index. Add\n    ** it to pNew->rRun, which is currently set to the cost of the index\n    ** seek only. Then, if this is a non-covering index, add the cost of\n    ** visiting the rows in the main table.  */\n    rCostIdx = pNew->nOut + 1 + (15*pProbe->szIdxRow)/pSrc->pTab->szTabRow;\n    pNew->rRun = sqlite3LogEstAdd(rLogSize, rCostIdx);\n    if( (pNew->wsFlags & (WHERE_IDX_ONLY|WHERE_IPK))==0 ){\n      pNew->rRun = sqlite3LogEstAdd(pNew->rRun, pNew->nOut + 16);\n    }\n    ApplyCostMultiplier(pNew->rRun, pProbe->pTable->costMult);\n\n    nOutUnadjusted = pNew->nOut;\n    pNew->rRun += nInMul + nIn;\n    pNew->nOut += nInMul + nIn;\n    whereLoopOutputAdjust(pBuilder->pWC, pNew, rSize);\n    rc = whereLoopInsert(pBuilder, pNew);\n\n    if( pNew->wsFlags & WHERE_COLUMN_RANGE ){\n      pNew->nOut = saved_nOut;\n    }else{\n      pNew->nOut = nOutUnadjusted;\n    }\n\n    if( (pNew->wsFlags & WHERE_TOP_LIMIT)==0\n     && pNew->u.btree.nEq<pProbe->nColumn\n    ){\n      whereLoopAddBtreeIndex(pBuilder, pSrc, pProbe, nInMul+nIn);\n    }\n    pNew->nOut = saved_nOut;\n#ifdef SQLITE_ENABLE_STAT3_OR_STAT4\n    pBuilder->nRecValid = nRecValid;\n#endif\n  }\n  pNew->prereq = saved_prereq;\n  pNew->u.btree.nEq = saved_nEq;\n  pNew->u.btree.nBtm = saved_nBtm;\n  pNew->u.btree.nTop = saved_nTop;\n  pNew->nSkip = saved_nSkip;\n  pNew->wsFlags = saved_wsFlags;\n  pNew->nOut = saved_nOut;\n  pNew->nLTerm = saved_nLTerm;\n\n  /* Consider using a skip-scan if there are no WHERE clause constraints\n  ** available for the left-most terms of the index, and if the average\n  ** number of repeats in the left-most terms is at least 18. \n  **\n  ** The magic number 18 is selected on the basis that scanning 17 rows\n  ** is almost always quicker than an index seek (even though if the index\n  ** contains fewer than 2^17 rows we assume otherwise in other parts of\n  ** the code). And, even if it is not, it should not be too much slower. \n  ** On the other hand, the extra seeks could end up being significantly\n  ** more expensive.  */\n  assert( 42==sqlite3LogEst(18) );\n  if( saved_nEq==saved_nSkip\n   && saved_nEq+1<pProbe->nKeyCol\n   && pProbe->noSkipScan==0\n   && OptimizationEnabled(db, SQLITE_SkipScan)\n   && pProbe->aiRowLogEst[saved_nEq+1]>=42  /* TUNING: Minimum for skip-scan */\n   && (rc = whereLoopResize(db, pNew, pNew->nLTerm+1))==SQLITE_OK\n  ){\n    LogEst nIter;\n    pNew->u.btree.nEq++;\n    pNew->nSkip++;\n    pNew->aLTerm[pNew->nLTerm++] = 0;\n    pNew->wsFlags |= WHERE_SKIPSCAN;\n    nIter = pProbe->aiRowLogEst[saved_nEq] - pProbe->aiRowLogEst[saved_nEq+1];\n    pNew->nOut -= nIter;\n    /* TUNING:  Because uncertainties in the estimates for skip-scan queries,\n    ** add a 1.375 fudge factor to make skip-scan slightly less likely. */\n    nIter += 5;\n    whereLoopAddBtreeIndex(pBuilder, pSrc, pProbe, nIter + nInMul);\n    pNew->nOut = saved_nOut;\n    pNew->u.btree.nEq = saved_nEq;\n    pNew->nSkip = saved_nSkip;\n    pNew->wsFlags = saved_wsFlags;\n  }\n\n  WHERETRACE(0x800, (\"END %s.addBtreeIdx(%s), nEq=%d, rc=%d\\n\",\n                      pProbe->pTable->zName, pProbe->zName, saved_nEq, rc));\n  return rc;\n}\n\n/*\n** Return True if it is possible that pIndex might be useful in\n** implementing the ORDER BY clause in pBuilder.\n**\n** Return False if pBuilder does not contain an ORDER BY clause or\n** if there is no way for pIndex to be useful in implementing that\n** ORDER BY clause.\n*/\nstatic int indexMightHelpWithOrderBy(\n  WhereLoopBuilder *pBuilder,\n  Index *pIndex,\n  int iCursor\n){\n  ExprList *pOB;\n  ExprList *aColExpr;\n  int ii, jj;\n\n  if( pIndex->bUnordered ) return 0;\n  if( (pOB = pBuilder->pWInfo->pOrderBy)==0 ) return 0;\n  for(ii=0; ii<pOB->nExpr; ii++){\n    Expr *pExpr = sqlite3ExprSkipCollate(pOB->a[ii].pExpr);\n    if( pExpr->op==TK_COLUMN && pExpr->iTable==iCursor ){\n      if( pExpr->iColumn<0 ) return 1;\n      for(jj=0; jj<pIndex->nKeyCol; jj++){\n        if( pExpr->iColumn==pIndex->aiColumn[jj] ) return 1;\n      }\n    }else if( (aColExpr = pIndex->aColExpr)!=0 ){\n      for(jj=0; jj<pIndex->nKeyCol; jj++){\n        if( pIndex->aiColumn[jj]!=XN_EXPR ) continue;\n        if( sqlite3ExprCompareSkip(pExpr,aColExpr->a[jj].pExpr,iCursor)==0 ){\n          return 1;\n        }\n      }\n    }\n  }\n  return 0;\n}\n\n/* Check to see if a partial index with pPartIndexWhere can be used\n** in the current query.  Return true if it can be and false if not.\n*/\nstatic int whereUsablePartialIndex(int iTab, WhereClause *pWC, Expr *pWhere){\n  int i;\n  WhereTerm *pTerm;\n  Parse *pParse = pWC->pWInfo->pParse;\n  while( pWhere->op==TK_AND ){\n    if( !whereUsablePartialIndex(iTab,pWC,pWhere->pLeft) ) return 0;\n    pWhere = pWhere->pRight;\n  }\n  if( pParse->db->flags & SQLITE_EnableQPSG ) pParse = 0;\n  for(i=0, pTerm=pWC->a; i<pWC->nTerm; i++, pTerm++){\n    Expr *pExpr = pTerm->pExpr;\n    if( (!ExprHasProperty(pExpr, EP_FromJoin) || pExpr->iRightJoinTable==iTab)\n     && sqlite3ExprImpliesExpr(pParse, pExpr, pWhere, iTab) \n    ){\n      return 1;\n    }\n  }\n  return 0;\n}\n\n/*\n** Add all WhereLoop objects for a single table of the join where the table\n** is identified by pBuilder->pNew->iTab.  That table is guaranteed to be\n** a b-tree table, not a virtual table.\n**\n** The costs (WhereLoop.rRun) of the b-tree loops added by this function\n** are calculated as follows:\n**\n** For a full scan, assuming the table (or index) contains nRow rows:\n**\n**     cost = nRow * 3.0                    // full-table scan\n**     cost = nRow * K                      // scan of covering index\n**     cost = nRow * (K+3.0)                // scan of non-covering index\n**\n** where K is a value between 1.1 and 3.0 set based on the relative \n** estimated average size of the index and table records.\n**\n** For an index scan, where nVisit is the number of index rows visited\n** by the scan, and nSeek is the number of seek operations required on \n** the index b-tree:\n**\n**     cost = nSeek * (log(nRow) + K * nVisit)          // covering index\n**     cost = nSeek * (log(nRow) + (K+3.0) * nVisit)    // non-covering index\n**\n** Normally, nSeek is 1. nSeek values greater than 1 come about if the \n** WHERE clause includes \"x IN (....)\" terms used in place of \"x=?\". Or when \n** implicit \"x IN (SELECT x FROM tbl)\" terms are added for skip-scans.\n**\n** The estimated values (nRow, nVisit, nSeek) often contain a large amount\n** of uncertainty.  For this reason, scoring is designed to pick plans that\n** \"do the least harm\" if the estimates are inaccurate.  For example, a\n** log(nRow) factor is omitted from a non-covering index scan in order to\n** bias the scoring in favor of using an index, since the worst-case\n** performance of using an index is far better than the worst-case performance\n** of a full table scan.\n*/\nstatic int whereLoopAddBtree(\n  WhereLoopBuilder *pBuilder, /* WHERE clause information */\n  Bitmask mPrereq             /* Extra prerequesites for using this table */\n){\n  WhereInfo *pWInfo;          /* WHERE analysis context */\n  Index *pProbe;              /* An index we are evaluating */\n  Index sPk;                  /* A fake index object for the primary key */\n  LogEst aiRowEstPk[2];       /* The aiRowLogEst[] value for the sPk index */\n  i16 aiColumnPk = -1;        /* The aColumn[] value for the sPk index */\n  SrcList *pTabList;          /* The FROM clause */\n  struct SrcList_item *pSrc;  /* The FROM clause btree term to add */\n  WhereLoop *pNew;            /* Template WhereLoop object */\n  int rc = SQLITE_OK;         /* Return code */\n  int iSortIdx = 1;           /* Index number */\n  int b;                      /* A boolean value */\n  LogEst rSize;               /* number of rows in the table */\n  LogEst rLogSize;            /* Logarithm of the number of rows in the table */\n  WhereClause *pWC;           /* The parsed WHERE clause */\n  Table *pTab;                /* Table being queried */\n  \n  pNew = pBuilder->pNew;\n  pWInfo = pBuilder->pWInfo;\n  pTabList = pWInfo->pTabList;\n  pSrc = pTabList->a + pNew->iTab;\n  pTab = pSrc->pTab;\n  pWC = pBuilder->pWC;\n  assert( !IsVirtual(pSrc->pTab) );\n\n  if( pSrc->pIBIndex ){\n    /* An INDEXED BY clause specifies a particular index to use */\n    pProbe = pSrc->pIBIndex;\n  }else if( !HasRowid(pTab) ){\n    pProbe = pTab->pIndex;\n  }else{\n    /* There is no INDEXED BY clause.  Create a fake Index object in local\n    ** variable sPk to represent the rowid primary key index.  Make this\n    ** fake index the first in a chain of Index objects with all of the real\n    ** indices to follow */\n    Index *pFirst;                  /* First of real indices on the table */\n    memset(&sPk, 0, sizeof(Index));\n    sPk.nKeyCol = 1;\n    sPk.nColumn = 1;\n    sPk.aiColumn = &aiColumnPk;\n    sPk.aiRowLogEst = aiRowEstPk;\n    sPk.onError = OE_Replace;\n    sPk.pTable = pTab;\n    sPk.szIdxRow = pTab->szTabRow;\n    sPk.idxType = SQLITE_IDXTYPE_IPK;\n    aiRowEstPk[0] = pTab->nRowLogEst;\n    aiRowEstPk[1] = 0;\n    pFirst = pSrc->pTab->pIndex;\n    if( pSrc->fg.notIndexed==0 ){\n      /* The real indices of the table are only considered if the\n      ** NOT INDEXED qualifier is omitted from the FROM clause */\n      sPk.pNext = pFirst;\n    }\n    pProbe = &sPk;\n  }\n  rSize = pTab->nRowLogEst;\n  rLogSize = estLog(rSize);\n\n#ifndef SQLITE_OMIT_AUTOMATIC_INDEX\n  /* Automatic indexes */\n  if( !pBuilder->pOrSet      /* Not part of an OR optimization */\n   && (pWInfo->wctrlFlags & WHERE_OR_SUBCLAUSE)==0\n   && (pWInfo->pParse->db->flags & SQLITE_AutoIndex)!=0\n   && pSrc->pIBIndex==0      /* Has no INDEXED BY clause */\n   && !pSrc->fg.notIndexed   /* Has no NOT INDEXED clause */\n   && HasRowid(pTab)         /* Not WITHOUT ROWID table. (FIXME: Why not?) */\n   && !pSrc->fg.isCorrelated /* Not a correlated subquery */\n   && !pSrc->fg.isRecursive  /* Not a recursive common table expression. */\n  ){\n    /* Generate auto-index WhereLoops */\n    WhereTerm *pTerm;\n    WhereTerm *pWCEnd = pWC->a + pWC->nTerm;\n    for(pTerm=pWC->a; rc==SQLITE_OK && pTerm<pWCEnd; pTerm++){\n      if( pTerm->prereqRight & pNew->maskSelf ) continue;\n      if( termCanDriveIndex(pTerm, pSrc, 0) ){\n        pNew->u.btree.nEq = 1;\n        pNew->nSkip = 0;\n        pNew->u.btree.pIndex = 0;\n        pNew->nLTerm = 1;\n        pNew->aLTerm[0] = pTerm;\n        /* TUNING: One-time cost for computing the automatic index is\n        ** estimated to be X*N*log2(N) where N is the number of rows in\n        ** the table being indexed and where X is 7 (LogEst=28) for normal\n        ** tables or 0.5 (LogEst=-10) for views and subqueries.  The value\n        ** of X is smaller for views and subqueries so that the query planner\n        ** will be more aggressive about generating automatic indexes for\n        ** those objects, since there is no opportunity to add schema\n        ** indexes on subqueries and views. */\n        pNew->rSetup = rLogSize + rSize;\n        if( pTab->pSelect==0 && (pTab->tabFlags & TF_Ephemeral)==0 ){\n          pNew->rSetup += 28;\n        }else{\n          pNew->rSetup -= 10;\n        }\n        ApplyCostMultiplier(pNew->rSetup, pTab->costMult);\n        if( pNew->rSetup<0 ) pNew->rSetup = 0;\n        /* TUNING: Each index lookup yields 20 rows in the table.  This\n        ** is more than the usual guess of 10 rows, since we have no way\n        ** of knowing how selective the index will ultimately be.  It would\n        ** not be unreasonable to make this value much larger. */\n        pNew->nOut = 43;  assert( 43==sqlite3LogEst(20) );\n        pNew->rRun = sqlite3LogEstAdd(rLogSize,pNew->nOut);\n        pNew->wsFlags = WHERE_AUTO_INDEX;\n        pNew->prereq = mPrereq | pTerm->prereqRight;\n        rc = whereLoopInsert(pBuilder, pNew);\n      }\n    }\n  }\n#endif /* SQLITE_OMIT_AUTOMATIC_INDEX */\n\n  /* Loop over all indices. If there was an INDEXED BY clause, then only \n  ** consider index pProbe.  */\n  for(; rc==SQLITE_OK && pProbe; \n      pProbe=(pSrc->pIBIndex ? 0 : pProbe->pNext), iSortIdx++\n  ){\n    if( pProbe->pPartIdxWhere!=0\n     && !whereUsablePartialIndex(pSrc->iCursor, pWC, pProbe->pPartIdxWhere) ){\n      testcase( pNew->iTab!=pSrc->iCursor );  /* See ticket [98d973b8f5] */\n      continue;  /* Partial index inappropriate for this query */\n    }\n    if( pProbe->bNoQuery ) continue;\n    rSize = pProbe->aiRowLogEst[0];\n    pNew->u.btree.nEq = 0;\n    pNew->u.btree.nBtm = 0;\n    pNew->u.btree.nTop = 0;\n    pNew->nSkip = 0;\n    pNew->nLTerm = 0;\n    pNew->iSortIdx = 0;\n    pNew->rSetup = 0;\n    pNew->prereq = mPrereq;\n    pNew->nOut = rSize;\n    pNew->u.btree.pIndex = pProbe;\n    b = indexMightHelpWithOrderBy(pBuilder, pProbe, pSrc->iCursor);\n    /* The ONEPASS_DESIRED flags never occurs together with ORDER BY */\n    assert( (pWInfo->wctrlFlags & WHERE_ONEPASS_DESIRED)==0 || b==0 );\n    if( pProbe->idxType==SQLITE_IDXTYPE_IPK ){\n      /* Integer primary key index */\n      pNew->wsFlags = WHERE_IPK;\n\n      /* Full table scan */\n      pNew->iSortIdx = b ? iSortIdx : 0;\n      /* TUNING: Cost of full table scan is (N*3.0). */\n      pNew->rRun = rSize + 16;\n      ApplyCostMultiplier(pNew->rRun, pTab->costMult);\n      whereLoopOutputAdjust(pWC, pNew, rSize);\n      rc = whereLoopInsert(pBuilder, pNew);\n      pNew->nOut = rSize;\n      if( rc ) break;\n    }else{\n      Bitmask m;\n      if( pProbe->isCovering ){\n        pNew->wsFlags = WHERE_IDX_ONLY | WHERE_INDEXED;\n        m = 0;\n      }else{\n        m = pSrc->colUsed & pProbe->colNotIdxed;\n        pNew->wsFlags = (m==0) ? (WHERE_IDX_ONLY|WHERE_INDEXED) : WHERE_INDEXED;\n      }\n\n      /* Full scan via index */\n      if( b\n       || !HasRowid(pTab)\n       || pProbe->pPartIdxWhere!=0\n       || ( m==0\n         && pProbe->bUnordered==0\n         && (pProbe->szIdxRow<pTab->szTabRow)\n         && (pWInfo->wctrlFlags & WHERE_ONEPASS_DESIRED)==0\n         && sqlite3GlobalConfig.bUseCis\n         && OptimizationEnabled(pWInfo->pParse->db, SQLITE_CoverIdxScan)\n          )\n      ){\n        pNew->iSortIdx = b ? iSortIdx : 0;\n\n        /* The cost of visiting the index rows is N*K, where K is\n        ** between 1.1 and 3.0, depending on the relative sizes of the\n        ** index and table rows. */\n        pNew->rRun = rSize + 1 + (15*pProbe->szIdxRow)/pTab->szTabRow;\n        if( m!=0 ){\n          /* If this is a non-covering index scan, add in the cost of\n          ** doing table lookups.  The cost will be 3x the number of\n          ** lookups.  Take into account WHERE clause terms that can be\n          ** satisfied using just the index, and that do not require a\n          ** table lookup. */\n          LogEst nLookup = rSize + 16;  /* Base cost:  N*3 */\n          int ii;\n          int iCur = pSrc->iCursor;\n          WhereClause *pWC2 = &pWInfo->sWC;\n          for(ii=0; ii<pWC2->nTerm; ii++){\n            WhereTerm *pTerm = &pWC2->a[ii];\n            if( !sqlite3ExprCoveredByIndex(pTerm->pExpr, iCur, pProbe) ){\n              break;\n            }\n            /* pTerm can be evaluated using just the index.  So reduce\n            ** the expected number of table lookups accordingly */\n            if( pTerm->truthProb<=0 ){\n              nLookup += pTerm->truthProb;\n            }else{\n              nLookup--;\n              if( pTerm->eOperator & (WO_EQ|WO_IS) ) nLookup -= 19;\n            }\n          }\n          \n          pNew->rRun = sqlite3LogEstAdd(pNew->rRun, nLookup);\n        }\n        ApplyCostMultiplier(pNew->rRun, pTab->costMult);\n        whereLoopOutputAdjust(pWC, pNew, rSize);\n        rc = whereLoopInsert(pBuilder, pNew);\n        pNew->nOut = rSize;\n        if( rc ) break;\n      }\n    }\n\n    pBuilder->bldFlags = 0;\n    rc = whereLoopAddBtreeIndex(pBuilder, pSrc, pProbe, 0);\n    if( pBuilder->bldFlags==SQLITE_BLDF_INDEXED ){\n      /* If a non-unique index is used, or if a prefix of the key for\n      ** unique index is used (making the index functionally non-unique)\n      ** then the sqlite_stat1 data becomes important for scoring the\n      ** plan */\n      pTab->tabFlags |= TF_StatsUsed;\n    }\n#ifdef SQLITE_ENABLE_STAT3_OR_STAT4\n    sqlite3Stat4ProbeFree(pBuilder->pRec);\n    pBuilder->nRecValid = 0;\n    pBuilder->pRec = 0;\n#endif\n  }\n  return rc;\n}\n\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n\n/*\n** Argument pIdxInfo is already populated with all constraints that may\n** be used by the virtual table identified by pBuilder->pNew->iTab. This\n** function marks a subset of those constraints usable, invokes the\n** xBestIndex method and adds the returned plan to pBuilder.\n**\n** A constraint is marked usable if:\n**\n**   * Argument mUsable indicates that its prerequisites are available, and\n**\n**   * It is not one of the operators specified in the mExclude mask passed\n**     as the fourth argument (which in practice is either WO_IN or 0).\n**\n** Argument mPrereq is a mask of tables that must be scanned before the\n** virtual table in question. These are added to the plans prerequisites\n** before it is added to pBuilder.\n**\n** Output parameter *pbIn is set to true if the plan added to pBuilder\n** uses one or more WO_IN terms, or false otherwise.\n*/\nstatic int whereLoopAddVirtualOne(\n  WhereLoopBuilder *pBuilder,\n  Bitmask mPrereq,                /* Mask of tables that must be used. */\n  Bitmask mUsable,                /* Mask of usable tables */\n  u16 mExclude,                   /* Exclude terms using these operators */\n  sqlite3_index_info *pIdxInfo,   /* Populated object for xBestIndex */\n  u16 mNoOmit,                    /* Do not omit these constraints */\n  int *pbIn                       /* OUT: True if plan uses an IN(...) op */\n){\n  WhereClause *pWC = pBuilder->pWC;\n  struct sqlite3_index_constraint *pIdxCons;\n  struct sqlite3_index_constraint_usage *pUsage = pIdxInfo->aConstraintUsage;\n  int i;\n  int mxTerm;\n  int rc = SQLITE_OK;\n  WhereLoop *pNew = pBuilder->pNew;\n  Parse *pParse = pBuilder->pWInfo->pParse;\n  struct SrcList_item *pSrc = &pBuilder->pWInfo->pTabList->a[pNew->iTab];\n  int nConstraint = pIdxInfo->nConstraint;\n\n  assert( (mUsable & mPrereq)==mPrereq );\n  *pbIn = 0;\n  pNew->prereq = mPrereq;\n\n  /* Set the usable flag on the subset of constraints identified by \n  ** arguments mUsable and mExclude. */\n  pIdxCons = *(struct sqlite3_index_constraint**)&pIdxInfo->aConstraint;\n  for(i=0; i<nConstraint; i++, pIdxCons++){\n    WhereTerm *pTerm = &pWC->a[pIdxCons->iTermOffset];\n    pIdxCons->usable = 0;\n    if( (pTerm->prereqRight & mUsable)==pTerm->prereqRight \n     && (pTerm->eOperator & mExclude)==0\n    ){\n      pIdxCons->usable = 1;\n    }\n  }\n\n  /* Initialize the output fields of the sqlite3_index_info structure */\n  memset(pUsage, 0, sizeof(pUsage[0])*nConstraint);\n  assert( pIdxInfo->needToFreeIdxStr==0 );\n  pIdxInfo->idxStr = 0;\n  pIdxInfo->idxNum = 0;\n  pIdxInfo->orderByConsumed = 0;\n  pIdxInfo->estimatedCost = SQLITE_BIG_DBL / (double)2;\n  pIdxInfo->estimatedRows = 25;\n  pIdxInfo->idxFlags = 0;\n  pIdxInfo->colUsed = (sqlite3_int64)pSrc->colUsed;\n\n  /* Invoke the virtual table xBestIndex() method */\n  rc = vtabBestIndex(pParse, pSrc->pTab, pIdxInfo);\n  if( rc ){\n    if( rc==SQLITE_CONSTRAINT ){\n      /* If the xBestIndex method returns SQLITE_CONSTRAINT, that means\n      ** that the particular combination of parameters provided is unusable.\n      ** Make no entries in the loop table.\n      */\n      WHERETRACE(0xffff, (\"  ^^^^--- non-viable plan rejected!\\n\"));\n      return SQLITE_OK;\n    }\n    return rc;\n  }\n\n  mxTerm = -1;\n  assert( pNew->nLSlot>=nConstraint );\n  for(i=0; i<nConstraint; i++) pNew->aLTerm[i] = 0;\n  pNew->u.vtab.omitMask = 0;\n  pIdxCons = *(struct sqlite3_index_constraint**)&pIdxInfo->aConstraint;\n  for(i=0; i<nConstraint; i++, pIdxCons++){\n    int iTerm;\n    if( (iTerm = pUsage[i].argvIndex - 1)>=0 ){\n      WhereTerm *pTerm;\n      int j = pIdxCons->iTermOffset;\n      if( iTerm>=nConstraint\n       || j<0\n       || j>=pWC->nTerm\n       || pNew->aLTerm[iTerm]!=0\n       || pIdxCons->usable==0\n      ){\n        sqlite3ErrorMsg(pParse,\"%s.xBestIndex malfunction\",pSrc->pTab->zName);\n        testcase( pIdxInfo->needToFreeIdxStr );\n        return SQLITE_ERROR;\n      }\n      testcase( iTerm==nConstraint-1 );\n      testcase( j==0 );\n      testcase( j==pWC->nTerm-1 );\n      pTerm = &pWC->a[j];\n      pNew->prereq |= pTerm->prereqRight;\n      assert( iTerm<pNew->nLSlot );\n      pNew->aLTerm[iTerm] = pTerm;\n      if( iTerm>mxTerm ) mxTerm = iTerm;\n      testcase( iTerm==15 );\n      testcase( iTerm==16 );\n      if( iTerm<16 && pUsage[i].omit ) pNew->u.vtab.omitMask |= 1<<iTerm;\n      if( (pTerm->eOperator & WO_IN)!=0 ){\n        /* A virtual table that is constrained by an IN clause may not\n        ** consume the ORDER BY clause because (1) the order of IN terms\n        ** is not necessarily related to the order of output terms and\n        ** (2) Multiple outputs from a single IN value will not merge\n        ** together.  */\n        pIdxInfo->orderByConsumed = 0;\n        pIdxInfo->idxFlags &= ~SQLITE_INDEX_SCAN_UNIQUE;\n        *pbIn = 1; assert( (mExclude & WO_IN)==0 );\n      }\n    }\n  }\n  pNew->u.vtab.omitMask &= ~mNoOmit;\n\n  pNew->nLTerm = mxTerm+1;\n  for(i=0; i<=mxTerm; i++){\n    if( pNew->aLTerm[i]==0 ){\n      /* The non-zero argvIdx values must be contiguous.  Raise an\n      ** error if they are not */\n      sqlite3ErrorMsg(pParse,\"%s.xBestIndex malfunction\",pSrc->pTab->zName);\n      testcase( pIdxInfo->needToFreeIdxStr );\n      return SQLITE_ERROR;\n    }\n  }\n  assert( pNew->nLTerm<=pNew->nLSlot );\n  pNew->u.vtab.idxNum = pIdxInfo->idxNum;\n  pNew->u.vtab.needFree = pIdxInfo->needToFreeIdxStr;\n  pIdxInfo->needToFreeIdxStr = 0;\n  pNew->u.vtab.idxStr = pIdxInfo->idxStr;\n  pNew->u.vtab.isOrdered = (i8)(pIdxInfo->orderByConsumed ?\n      pIdxInfo->nOrderBy : 0);\n  pNew->rSetup = 0;\n  pNew->rRun = sqlite3LogEstFromDouble(pIdxInfo->estimatedCost);\n  pNew->nOut = sqlite3LogEst(pIdxInfo->estimatedRows);\n\n  /* Set the WHERE_ONEROW flag if the xBestIndex() method indicated\n  ** that the scan will visit at most one row. Clear it otherwise. */\n  if( pIdxInfo->idxFlags & SQLITE_INDEX_SCAN_UNIQUE ){\n    pNew->wsFlags |= WHERE_ONEROW;\n  }else{\n    pNew->wsFlags &= ~WHERE_ONEROW;\n  }\n  rc = whereLoopInsert(pBuilder, pNew);\n  if( pNew->u.vtab.needFree ){\n    sqlite3_free(pNew->u.vtab.idxStr);\n    pNew->u.vtab.needFree = 0;\n  }\n  WHERETRACE(0xffff, (\"  bIn=%d prereqIn=%04llx prereqOut=%04llx\\n\",\n                      *pbIn, (sqlite3_uint64)mPrereq,\n                      (sqlite3_uint64)(pNew->prereq & ~mPrereq)));\n\n  return rc;\n}\n\n/*\n** If this function is invoked from within an xBestIndex() callback, it\n** returns a pointer to a buffer containing the name of the collation\n** sequence associated with element iCons of the sqlite3_index_info.aConstraint\n** array. Or, if iCons is out of range or there is no active xBestIndex\n** call, return NULL.\n*/\nSQLITE_API const char *sqlite3_vtab_collation(sqlite3_index_info *pIdxInfo, int iCons){\n  HiddenIndexInfo *pHidden = (HiddenIndexInfo*)&pIdxInfo[1];\n  const char *zRet = 0;\n  if( iCons>=0 && iCons<pIdxInfo->nConstraint ){\n    CollSeq *pC = 0;\n    int iTerm = pIdxInfo->aConstraint[iCons].iTermOffset;\n    Expr *pX = pHidden->pWC->a[iTerm].pExpr;\n    if( pX->pLeft ){\n      pC = sqlite3BinaryCompareCollSeq(pHidden->pParse, pX->pLeft, pX->pRight);\n    }\n    zRet = (pC ? pC->zName : sqlite3StrBINARY);\n  }\n  return zRet;\n}\n\n/*\n** Add all WhereLoop objects for a table of the join identified by\n** pBuilder->pNew->iTab.  That table is guaranteed to be a virtual table.\n**\n** If there are no LEFT or CROSS JOIN joins in the query, both mPrereq and\n** mUnusable are set to 0. Otherwise, mPrereq is a mask of all FROM clause\n** entries that occur before the virtual table in the FROM clause and are\n** separated from it by at least one LEFT or CROSS JOIN. Similarly, the\n** mUnusable mask contains all FROM clause entries that occur after the\n** virtual table and are separated from it by at least one LEFT or \n** CROSS JOIN. \n**\n** For example, if the query were:\n**\n**   ... FROM t1, t2 LEFT JOIN t3, t4, vt CROSS JOIN t5, t6;\n**\n** then mPrereq corresponds to (t1, t2) and mUnusable to (t5, t6).\n**\n** All the tables in mPrereq must be scanned before the current virtual \n** table. So any terms for which all prerequisites are satisfied by \n** mPrereq may be specified as \"usable\" in all calls to xBestIndex. \n** Conversely, all tables in mUnusable must be scanned after the current\n** virtual table, so any terms for which the prerequisites overlap with\n** mUnusable should always be configured as \"not-usable\" for xBestIndex.\n*/\nstatic int whereLoopAddVirtual(\n  WhereLoopBuilder *pBuilder,  /* WHERE clause information */\n  Bitmask mPrereq,             /* Tables that must be scanned before this one */\n  Bitmask mUnusable            /* Tables that must be scanned after this one */\n){\n  int rc = SQLITE_OK;          /* Return code */\n  WhereInfo *pWInfo;           /* WHERE analysis context */\n  Parse *pParse;               /* The parsing context */\n  WhereClause *pWC;            /* The WHERE clause */\n  struct SrcList_item *pSrc;   /* The FROM clause term to search */\n  sqlite3_index_info *p;       /* Object to pass to xBestIndex() */\n  int nConstraint;             /* Number of constraints in p */\n  int bIn;                     /* True if plan uses IN(...) operator */\n  WhereLoop *pNew;\n  Bitmask mBest;               /* Tables used by best possible plan */\n  u16 mNoOmit;\n\n  assert( (mPrereq & mUnusable)==0 );\n  pWInfo = pBuilder->pWInfo;\n  pParse = pWInfo->pParse;\n  pWC = pBuilder->pWC;\n  pNew = pBuilder->pNew;\n  pSrc = &pWInfo->pTabList->a[pNew->iTab];\n  assert( IsVirtual(pSrc->pTab) );\n  p = allocateIndexInfo(pParse, pWC, mUnusable, pSrc, pBuilder->pOrderBy, \n      &mNoOmit);\n  if( p==0 ) return SQLITE_NOMEM_BKPT;\n  pNew->rSetup = 0;\n  pNew->wsFlags = WHERE_VIRTUALTABLE;\n  pNew->nLTerm = 0;\n  pNew->u.vtab.needFree = 0;\n  nConstraint = p->nConstraint;\n  if( whereLoopResize(pParse->db, pNew, nConstraint) ){\n    sqlite3DbFree(pParse->db, p);\n    return SQLITE_NOMEM_BKPT;\n  }\n\n  /* First call xBestIndex() with all constraints usable. */\n  WHERETRACE(0x800, (\"BEGIN %s.addVirtual()\\n\", pSrc->pTab->zName));\n  WHERETRACE(0x40, (\"  VirtualOne: all usable\\n\"));\n  rc = whereLoopAddVirtualOne(pBuilder, mPrereq, ALLBITS, 0, p, mNoOmit, &bIn);\n\n  /* If the call to xBestIndex() with all terms enabled produced a plan\n  ** that does not require any source tables (IOW: a plan with mBest==0),\n  ** then there is no point in making any further calls to xBestIndex() \n  ** since they will all return the same result (if the xBestIndex()\n  ** implementation is sane). */\n  if( rc==SQLITE_OK && (mBest = (pNew->prereq & ~mPrereq))!=0 ){\n    int seenZero = 0;             /* True if a plan with no prereqs seen */\n    int seenZeroNoIN = 0;         /* Plan with no prereqs and no IN(...) seen */\n    Bitmask mPrev = 0;\n    Bitmask mBestNoIn = 0;\n\n    /* If the plan produced by the earlier call uses an IN(...) term, call\n    ** xBestIndex again, this time with IN(...) terms disabled. */\n    if( bIn ){\n      WHERETRACE(0x40, (\"  VirtualOne: all usable w/o IN\\n\"));\n      rc = whereLoopAddVirtualOne(\n          pBuilder, mPrereq, ALLBITS, WO_IN, p, mNoOmit, &bIn);\n      assert( bIn==0 );\n      mBestNoIn = pNew->prereq & ~mPrereq;\n      if( mBestNoIn==0 ){\n        seenZero = 1;\n        seenZeroNoIN = 1;\n      }\n    }\n\n    /* Call xBestIndex once for each distinct value of (prereqRight & ~mPrereq) \n    ** in the set of terms that apply to the current virtual table.  */\n    while( rc==SQLITE_OK ){\n      int i;\n      Bitmask mNext = ALLBITS;\n      assert( mNext>0 );\n      for(i=0; i<nConstraint; i++){\n        Bitmask mThis = (\n            pWC->a[p->aConstraint[i].iTermOffset].prereqRight & ~mPrereq\n        );\n        if( mThis>mPrev && mThis<mNext ) mNext = mThis;\n      }\n      mPrev = mNext;\n      if( mNext==ALLBITS ) break;\n      if( mNext==mBest || mNext==mBestNoIn ) continue;\n      WHERETRACE(0x40, (\"  VirtualOne: mPrev=%04llx mNext=%04llx\\n\",\n                       (sqlite3_uint64)mPrev, (sqlite3_uint64)mNext));\n      rc = whereLoopAddVirtualOne(\n          pBuilder, mPrereq, mNext|mPrereq, 0, p, mNoOmit, &bIn);\n      if( pNew->prereq==mPrereq ){\n        seenZero = 1;\n        if( bIn==0 ) seenZeroNoIN = 1;\n      }\n    }\n\n    /* If the calls to xBestIndex() in the above loop did not find a plan\n    ** that requires no source tables at all (i.e. one guaranteed to be\n    ** usable), make a call here with all source tables disabled */\n    if( rc==SQLITE_OK && seenZero==0 ){\n      WHERETRACE(0x40, (\"  VirtualOne: all disabled\\n\"));\n      rc = whereLoopAddVirtualOne(\n          pBuilder, mPrereq, mPrereq, 0, p, mNoOmit, &bIn);\n      if( bIn==0 ) seenZeroNoIN = 1;\n    }\n\n    /* If the calls to xBestIndex() have so far failed to find a plan\n    ** that requires no source tables at all and does not use an IN(...)\n    ** operator, make a final call to obtain one here.  */\n    if( rc==SQLITE_OK && seenZeroNoIN==0 ){\n      WHERETRACE(0x40, (\"  VirtualOne: all disabled and w/o IN\\n\"));\n      rc = whereLoopAddVirtualOne(\n          pBuilder, mPrereq, mPrereq, WO_IN, p, mNoOmit, &bIn);\n    }\n  }\n\n  if( p->needToFreeIdxStr ) sqlite3_free(p->idxStr);\n  sqlite3DbFreeNN(pParse->db, p);\n  WHERETRACE(0x800, (\"END %s.addVirtual(), rc=%d\\n\", pSrc->pTab->zName, rc));\n  return rc;\n}\n#endif /* SQLITE_OMIT_VIRTUALTABLE */\n\n/*\n** Add WhereLoop entries to handle OR terms.  This works for either\n** btrees or virtual tables.\n*/\nstatic int whereLoopAddOr(\n  WhereLoopBuilder *pBuilder, \n  Bitmask mPrereq, \n  Bitmask mUnusable\n){\n  WhereInfo *pWInfo = pBuilder->pWInfo;\n  WhereClause *pWC;\n  WhereLoop *pNew;\n  WhereTerm *pTerm, *pWCEnd;\n  int rc = SQLITE_OK;\n  int iCur;\n  WhereClause tempWC;\n  WhereLoopBuilder sSubBuild;\n  WhereOrSet sSum, sCur;\n  struct SrcList_item *pItem;\n  \n  pWC = pBuilder->pWC;\n  pWCEnd = pWC->a + pWC->nTerm;\n  pNew = pBuilder->pNew;\n  memset(&sSum, 0, sizeof(sSum));\n  pItem = pWInfo->pTabList->a + pNew->iTab;\n  iCur = pItem->iCursor;\n\n  for(pTerm=pWC->a; pTerm<pWCEnd && rc==SQLITE_OK; pTerm++){\n    if( (pTerm->eOperator & WO_OR)!=0\n     && (pTerm->u.pOrInfo->indexable & pNew->maskSelf)!=0 \n    ){\n      WhereClause * const pOrWC = &pTerm->u.pOrInfo->wc;\n      WhereTerm * const pOrWCEnd = &pOrWC->a[pOrWC->nTerm];\n      WhereTerm *pOrTerm;\n      int once = 1;\n      int i, j;\n    \n      sSubBuild = *pBuilder;\n      sSubBuild.pOrderBy = 0;\n      sSubBuild.pOrSet = &sCur;\n\n      WHERETRACE(0x200, (\"Begin processing OR-clause %p\\n\", pTerm));\n      for(pOrTerm=pOrWC->a; pOrTerm<pOrWCEnd; pOrTerm++){\n        if( (pOrTerm->eOperator & WO_AND)!=0 ){\n          sSubBuild.pWC = &pOrTerm->u.pAndInfo->wc;\n        }else if( pOrTerm->leftCursor==iCur ){\n          tempWC.pWInfo = pWC->pWInfo;\n          tempWC.pOuter = pWC;\n          tempWC.op = TK_AND;\n          tempWC.nTerm = 1;\n          tempWC.a = pOrTerm;\n          sSubBuild.pWC = &tempWC;\n        }else{\n          continue;\n        }\n        sCur.n = 0;\n#ifdef WHERETRACE_ENABLED\n        WHERETRACE(0x200, (\"OR-term %d of %p has %d subterms:\\n\", \n                   (int)(pOrTerm-pOrWC->a), pTerm, sSubBuild.pWC->nTerm));\n        if( sqlite3WhereTrace & 0x400 ){\n          sqlite3WhereClausePrint(sSubBuild.pWC);\n        }\n#endif\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n        if( IsVirtual(pItem->pTab) ){\n          rc = whereLoopAddVirtual(&sSubBuild, mPrereq, mUnusable);\n        }else\n#endif\n        {\n          rc = whereLoopAddBtree(&sSubBuild, mPrereq);\n        }\n        if( rc==SQLITE_OK ){\n          rc = whereLoopAddOr(&sSubBuild, mPrereq, mUnusable);\n        }\n        assert( rc==SQLITE_OK || sCur.n==0 );\n        if( sCur.n==0 ){\n          sSum.n = 0;\n          break;\n        }else if( once ){\n          whereOrMove(&sSum, &sCur);\n          once = 0;\n        }else{\n          WhereOrSet sPrev;\n          whereOrMove(&sPrev, &sSum);\n          sSum.n = 0;\n          for(i=0; i<sPrev.n; i++){\n            for(j=0; j<sCur.n; j++){\n              whereOrInsert(&sSum, sPrev.a[i].prereq | sCur.a[j].prereq,\n                            sqlite3LogEstAdd(sPrev.a[i].rRun, sCur.a[j].rRun),\n                            sqlite3LogEstAdd(sPrev.a[i].nOut, sCur.a[j].nOut));\n            }\n          }\n        }\n      }\n      pNew->nLTerm = 1;\n      pNew->aLTerm[0] = pTerm;\n      pNew->wsFlags = WHERE_MULTI_OR;\n      pNew->rSetup = 0;\n      pNew->iSortIdx = 0;\n      memset(&pNew->u, 0, sizeof(pNew->u));\n      for(i=0; rc==SQLITE_OK && i<sSum.n; i++){\n        /* TUNING: Currently sSum.a[i].rRun is set to the sum of the costs\n        ** of all sub-scans required by the OR-scan. However, due to rounding\n        ** errors, it may be that the cost of the OR-scan is equal to its\n        ** most expensive sub-scan. Add the smallest possible penalty \n        ** (equivalent to multiplying the cost by 1.07) to ensure that \n        ** this does not happen. Otherwise, for WHERE clauses such as the\n        ** following where there is an index on \"y\":\n        **\n        **     WHERE likelihood(x=?, 0.99) OR y=?\n        **\n        ** the planner may elect to \"OR\" together a full-table scan and an\n        ** index lookup. And other similarly odd results.  */\n        pNew->rRun = sSum.a[i].rRun + 1;\n        pNew->nOut = sSum.a[i].nOut;\n        pNew->prereq = sSum.a[i].prereq;\n        rc = whereLoopInsert(pBuilder, pNew);\n      }\n      WHERETRACE(0x200, (\"End processing OR-clause %p\\n\", pTerm));\n    }\n  }\n  return rc;\n}\n\n/*\n** Add all WhereLoop objects for all tables \n*/\nstatic int whereLoopAddAll(WhereLoopBuilder *pBuilder){\n  WhereInfo *pWInfo = pBuilder->pWInfo;\n  Bitmask mPrereq = 0;\n  Bitmask mPrior = 0;\n  int iTab;\n  SrcList *pTabList = pWInfo->pTabList;\n  struct SrcList_item *pItem;\n  struct SrcList_item *pEnd = &pTabList->a[pWInfo->nLevel];\n  sqlite3 *db = pWInfo->pParse->db;\n  int rc = SQLITE_OK;\n  WhereLoop *pNew;\n  u8 priorJointype = 0;\n\n  /* Loop over the tables in the join, from left to right */\n  pNew = pBuilder->pNew;\n  whereLoopInit(pNew);\n  pBuilder->iPlanLimit = SQLITE_QUERY_PLANNER_LIMIT;\n  for(iTab=0, pItem=pTabList->a; pItem<pEnd; iTab++, pItem++){\n    Bitmask mUnusable = 0;\n    pNew->iTab = iTab;\n    pBuilder->iPlanLimit += SQLITE_QUERY_PLANNER_LIMIT_INCR;\n    pNew->maskSelf = sqlite3WhereGetMask(&pWInfo->sMaskSet, pItem->iCursor);\n    if( ((pItem->fg.jointype|priorJointype) & (JT_LEFT|JT_CROSS))!=0 ){\n      /* This condition is true when pItem is the FROM clause term on the\n      ** right-hand-side of a LEFT or CROSS JOIN.  */\n      mPrereq = mPrior;\n    }\n    priorJointype = pItem->fg.jointype;\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n    if( IsVirtual(pItem->pTab) ){\n      struct SrcList_item *p;\n      for(p=&pItem[1]; p<pEnd; p++){\n        if( mUnusable || (p->fg.jointype & (JT_LEFT|JT_CROSS)) ){\n          mUnusable |= sqlite3WhereGetMask(&pWInfo->sMaskSet, p->iCursor);\n        }\n      }\n      rc = whereLoopAddVirtual(pBuilder, mPrereq, mUnusable);\n    }else\n#endif /* SQLITE_OMIT_VIRTUALTABLE */\n    {\n      rc = whereLoopAddBtree(pBuilder, mPrereq);\n    }\n    if( rc==SQLITE_OK && pBuilder->pWC->hasOr ){\n      rc = whereLoopAddOr(pBuilder, mPrereq, mUnusable);\n    }\n    mPrior |= pNew->maskSelf;\n    if( rc || db->mallocFailed ){\n      if( rc==SQLITE_DONE ){\n        /* We hit the query planner search limit set by iPlanLimit */\n        sqlite3_log(SQLITE_WARNING, \"abbreviated query algorithm search\");\n        rc = SQLITE_OK;\n      }else{\n        break;\n      }\n    }\n  }\n\n  whereLoopClear(db, pNew);\n  return rc;\n}\n\n/*\n** Examine a WherePath (with the addition of the extra WhereLoop of the 6th\n** parameters) to see if it outputs rows in the requested ORDER BY\n** (or GROUP BY) without requiring a separate sort operation.  Return N:\n** \n**   N>0:   N terms of the ORDER BY clause are satisfied\n**   N==0:  No terms of the ORDER BY clause are satisfied\n**   N<0:   Unknown yet how many terms of ORDER BY might be satisfied.   \n**\n** Note that processing for WHERE_GROUPBY and WHERE_DISTINCTBY is not as\n** strict.  With GROUP BY and DISTINCT the only requirement is that\n** equivalent rows appear immediately adjacent to one another.  GROUP BY\n** and DISTINCT do not require rows to appear in any particular order as long\n** as equivalent rows are grouped together.  Thus for GROUP BY and DISTINCT\n** the pOrderBy terms can be matched in any order.  With ORDER BY, the \n** pOrderBy terms must be matched in strict left-to-right order.\n*/\nstatic i8 wherePathSatisfiesOrderBy(\n  WhereInfo *pWInfo,    /* The WHERE clause */\n  ExprList *pOrderBy,   /* ORDER BY or GROUP BY or DISTINCT clause to check */\n  WherePath *pPath,     /* The WherePath to check */\n  u16 wctrlFlags,       /* WHERE_GROUPBY or _DISTINCTBY or _ORDERBY_LIMIT */\n  u16 nLoop,            /* Number of entries in pPath->aLoop[] */\n  WhereLoop *pLast,     /* Add this WhereLoop to the end of pPath->aLoop[] */\n  Bitmask *pRevMask     /* OUT: Mask of WhereLoops to run in reverse order */\n){\n  u8 revSet;            /* True if rev is known */\n  u8 rev;               /* Composite sort order */\n  u8 revIdx;            /* Index sort order */\n  u8 isOrderDistinct;   /* All prior WhereLoops are order-distinct */\n  u8 distinctColumns;   /* True if the loop has UNIQUE NOT NULL columns */\n  u8 isMatch;           /* iColumn matches a term of the ORDER BY clause */\n  u16 eqOpMask;         /* Allowed equality operators */\n  u16 nKeyCol;          /* Number of key columns in pIndex */\n  u16 nColumn;          /* Total number of ordered columns in the index */\n  u16 nOrderBy;         /* Number terms in the ORDER BY clause */\n  int iLoop;            /* Index of WhereLoop in pPath being processed */\n  int i, j;             /* Loop counters */\n  int iCur;             /* Cursor number for current WhereLoop */\n  int iColumn;          /* A column number within table iCur */\n  WhereLoop *pLoop = 0; /* Current WhereLoop being processed. */\n  WhereTerm *pTerm;     /* A single term of the WHERE clause */\n  Expr *pOBExpr;        /* An expression from the ORDER BY clause */\n  CollSeq *pColl;       /* COLLATE function from an ORDER BY clause term */\n  Index *pIndex;        /* The index associated with pLoop */\n  sqlite3 *db = pWInfo->pParse->db;  /* Database connection */\n  Bitmask obSat = 0;    /* Mask of ORDER BY terms satisfied so far */\n  Bitmask obDone;       /* Mask of all ORDER BY terms */\n  Bitmask orderDistinctMask;  /* Mask of all well-ordered loops */\n  Bitmask ready;              /* Mask of inner loops */\n\n  /*\n  ** We say the WhereLoop is \"one-row\" if it generates no more than one\n  ** row of output.  A WhereLoop is one-row if all of the following are true:\n  **  (a) All index columns match with WHERE_COLUMN_EQ.\n  **  (b) The index is unique\n  ** Any WhereLoop with an WHERE_COLUMN_EQ constraint on the rowid is one-row.\n  ** Every one-row WhereLoop will have the WHERE_ONEROW bit set in wsFlags.\n  **\n  ** We say the WhereLoop is \"order-distinct\" if the set of columns from\n  ** that WhereLoop that are in the ORDER BY clause are different for every\n  ** row of the WhereLoop.  Every one-row WhereLoop is automatically\n  ** order-distinct.   A WhereLoop that has no columns in the ORDER BY clause\n  ** is not order-distinct. To be order-distinct is not quite the same as being\n  ** UNIQUE since a UNIQUE column or index can have multiple rows that \n  ** are NULL and NULL values are equivalent for the purpose of order-distinct.\n  ** To be order-distinct, the columns must be UNIQUE and NOT NULL.\n  **\n  ** The rowid for a table is always UNIQUE and NOT NULL so whenever the\n  ** rowid appears in the ORDER BY clause, the corresponding WhereLoop is\n  ** automatically order-distinct.\n  */\n\n  assert( pOrderBy!=0 );\n  if( nLoop && OptimizationDisabled(db, SQLITE_OrderByIdxJoin) ) return 0;\n\n  nOrderBy = pOrderBy->nExpr;\n  testcase( nOrderBy==BMS-1 );\n  if( nOrderBy>BMS-1 ) return 0;  /* Cannot optimize overly large ORDER BYs */\n  isOrderDistinct = 1;\n  obDone = MASKBIT(nOrderBy)-1;\n  orderDistinctMask = 0;\n  ready = 0;\n  eqOpMask = WO_EQ | WO_IS | WO_ISNULL;\n  if( wctrlFlags & WHERE_ORDERBY_LIMIT ) eqOpMask |= WO_IN;\n  for(iLoop=0; isOrderDistinct && obSat<obDone && iLoop<=nLoop; iLoop++){\n    if( iLoop>0 ) ready |= pLoop->maskSelf;\n    if( iLoop<nLoop ){\n      pLoop = pPath->aLoop[iLoop];\n      if( wctrlFlags & WHERE_ORDERBY_LIMIT ) continue;\n    }else{\n      pLoop = pLast;\n    }\n    if( pLoop->wsFlags & WHERE_VIRTUALTABLE ){\n      if( pLoop->u.vtab.isOrdered ) obSat = obDone;\n      break;\n    }else{\n      pLoop->u.btree.nIdxCol = 0;\n    }\n    iCur = pWInfo->pTabList->a[pLoop->iTab].iCursor;\n\n    /* Mark off any ORDER BY term X that is a column in the table of\n    ** the current loop for which there is term in the WHERE\n    ** clause of the form X IS NULL or X=? that reference only outer\n    ** loops.\n    */\n    for(i=0; i<nOrderBy; i++){\n      if( MASKBIT(i) & obSat ) continue;\n      pOBExpr = sqlite3ExprSkipCollate(pOrderBy->a[i].pExpr);\n      if( pOBExpr->op!=TK_COLUMN ) continue;\n      if( pOBExpr->iTable!=iCur ) continue;\n      pTerm = sqlite3WhereFindTerm(&pWInfo->sWC, iCur, pOBExpr->iColumn,\n                       ~ready, eqOpMask, 0);\n      if( pTerm==0 ) continue;\n      if( pTerm->eOperator==WO_IN ){\n        /* IN terms are only valid for sorting in the ORDER BY LIMIT \n        ** optimization, and then only if they are actually used\n        ** by the query plan */\n        assert( wctrlFlags & WHERE_ORDERBY_LIMIT );\n        for(j=0; j<pLoop->nLTerm && pTerm!=pLoop->aLTerm[j]; j++){}\n        if( j>=pLoop->nLTerm ) continue;\n      }\n      if( (pTerm->eOperator&(WO_EQ|WO_IS))!=0 && pOBExpr->iColumn>=0 ){\n        if( sqlite3ExprCollSeqMatch(pWInfo->pParse, \n                  pOrderBy->a[i].pExpr, pTerm->pExpr)==0 ){\n          continue;\n        }\n        testcase( pTerm->pExpr->op==TK_IS );\n      }\n      obSat |= MASKBIT(i);\n    }\n\n    if( (pLoop->wsFlags & WHERE_ONEROW)==0 ){\n      if( pLoop->wsFlags & WHERE_IPK ){\n        pIndex = 0;\n        nKeyCol = 0;\n        nColumn = 1;\n      }else if( (pIndex = pLoop->u.btree.pIndex)==0 || pIndex->bUnordered ){\n        return 0;\n      }else{\n        nKeyCol = pIndex->nKeyCol;\n        nColumn = pIndex->nColumn;\n        assert( nColumn==nKeyCol+1 || !HasRowid(pIndex->pTable) );\n        assert( pIndex->aiColumn[nColumn-1]==XN_ROWID\n                          || !HasRowid(pIndex->pTable));\n        isOrderDistinct = IsUniqueIndex(pIndex);\n      }\n\n      /* Loop through all columns of the index and deal with the ones\n      ** that are not constrained by == or IN.\n      */\n      rev = revSet = 0;\n      distinctColumns = 0;\n      for(j=0; j<nColumn; j++){\n        u8 bOnce = 1; /* True to run the ORDER BY search loop */\n\n        assert( j>=pLoop->u.btree.nEq \n            || (pLoop->aLTerm[j]==0)==(j<pLoop->nSkip)\n        );\n        if( j<pLoop->u.btree.nEq && j>=pLoop->nSkip ){\n          u16 eOp = pLoop->aLTerm[j]->eOperator;\n\n          /* Skip over == and IS and ISNULL terms.  (Also skip IN terms when\n          ** doing WHERE_ORDERBY_LIMIT processing). \n          **\n          ** If the current term is a column of an ((?,?) IN (SELECT...)) \n          ** expression for which the SELECT returns more than one column,\n          ** check that it is the only column used by this loop. Otherwise,\n          ** if it is one of two or more, none of the columns can be\n          ** considered to match an ORDER BY term.  */\n          if( (eOp & eqOpMask)!=0 ){\n            if( eOp & WO_ISNULL ){\n              testcase( isOrderDistinct );\n              isOrderDistinct = 0;\n            }\n            continue;  \n          }else if( ALWAYS(eOp & WO_IN) ){\n            /* ALWAYS() justification: eOp is an equality operator due to the\n            ** j<pLoop->u.btree.nEq constraint above.  Any equality other\n            ** than WO_IN is captured by the previous \"if\".  So this one\n            ** always has to be WO_IN. */\n            Expr *pX = pLoop->aLTerm[j]->pExpr;\n            for(i=j+1; i<pLoop->u.btree.nEq; i++){\n              if( pLoop->aLTerm[i]->pExpr==pX ){\n                assert( (pLoop->aLTerm[i]->eOperator & WO_IN) );\n                bOnce = 0;\n                break;\n              }\n            }\n          }\n        }\n\n        /* Get the column number in the table (iColumn) and sort order\n        ** (revIdx) for the j-th column of the index.\n        */\n        if( pIndex ){\n          iColumn = pIndex->aiColumn[j];\n          revIdx = pIndex->aSortOrder[j];\n          if( iColumn==pIndex->pTable->iPKey ) iColumn = XN_ROWID;\n        }else{\n          iColumn = XN_ROWID;\n          revIdx = 0;\n        }\n\n        /* An unconstrained column that might be NULL means that this\n        ** WhereLoop is not well-ordered\n        */\n        if( isOrderDistinct\n         && iColumn>=0\n         && j>=pLoop->u.btree.nEq\n         && pIndex->pTable->aCol[iColumn].notNull==0\n        ){\n          isOrderDistinct = 0;\n        }\n\n        /* Find the ORDER BY term that corresponds to the j-th column\n        ** of the index and mark that ORDER BY term off \n        */\n        isMatch = 0;\n        for(i=0; bOnce && i<nOrderBy; i++){\n          if( MASKBIT(i) & obSat ) continue;\n          pOBExpr = sqlite3ExprSkipCollate(pOrderBy->a[i].pExpr);\n          testcase( wctrlFlags & WHERE_GROUPBY );\n          testcase( wctrlFlags & WHERE_DISTINCTBY );\n          if( (wctrlFlags & (WHERE_GROUPBY|WHERE_DISTINCTBY))==0 ) bOnce = 0;\n          if( iColumn>=XN_ROWID ){\n            if( pOBExpr->op!=TK_COLUMN ) continue;\n            if( pOBExpr->iTable!=iCur ) continue;\n            if( pOBExpr->iColumn!=iColumn ) continue;\n          }else{\n            Expr *pIdxExpr = pIndex->aColExpr->a[j].pExpr;\n            if( sqlite3ExprCompareSkip(pOBExpr, pIdxExpr, iCur) ){\n              continue;\n            }\n          }\n          if( iColumn!=XN_ROWID ){\n            pColl = sqlite3ExprNNCollSeq(pWInfo->pParse, pOrderBy->a[i].pExpr);\n            if( sqlite3StrICmp(pColl->zName, pIndex->azColl[j])!=0 ) continue;\n          }\n          pLoop->u.btree.nIdxCol = j+1;\n          isMatch = 1;\n          break;\n        }\n        if( isMatch && (wctrlFlags & WHERE_GROUPBY)==0 ){\n          /* Make sure the sort order is compatible in an ORDER BY clause.\n          ** Sort order is irrelevant for a GROUP BY clause. */\n          if( revSet ){\n            if( (rev ^ revIdx)!=pOrderBy->a[i].sortOrder ) isMatch = 0;\n          }else{\n            rev = revIdx ^ pOrderBy->a[i].sortOrder;\n            if( rev ) *pRevMask |= MASKBIT(iLoop);\n            revSet = 1;\n          }\n        }\n        if( isMatch ){\n          if( iColumn==XN_ROWID ){\n            testcase( distinctColumns==0 );\n            distinctColumns = 1;\n          }\n          obSat |= MASKBIT(i);\n        }else{\n          /* No match found */\n          if( j==0 || j<nKeyCol ){\n            testcase( isOrderDistinct!=0 );\n            isOrderDistinct = 0;\n          }\n          break;\n        }\n      } /* end Loop over all index columns */\n      if( distinctColumns ){\n        testcase( isOrderDistinct==0 );\n        isOrderDistinct = 1;\n      }\n    } /* end-if not one-row */\n\n    /* Mark off any other ORDER BY terms that reference pLoop */\n    if( isOrderDistinct ){\n      orderDistinctMask |= pLoop->maskSelf;\n      for(i=0; i<nOrderBy; i++){\n        Expr *p;\n        Bitmask mTerm;\n        if( MASKBIT(i) & obSat ) continue;\n        p = pOrderBy->a[i].pExpr;\n        mTerm = sqlite3WhereExprUsage(&pWInfo->sMaskSet,p);\n        if( mTerm==0 && !sqlite3ExprIsConstant(p) ) continue;\n        if( (mTerm&~orderDistinctMask)==0 ){\n          obSat |= MASKBIT(i);\n        }\n      }\n    }\n  } /* End the loop over all WhereLoops from outer-most down to inner-most */\n  if( obSat==obDone ) return (i8)nOrderBy;\n  if( !isOrderDistinct ){\n    for(i=nOrderBy-1; i>0; i--){\n      Bitmask m = MASKBIT(i) - 1;\n      if( (obSat&m)==m ) return i;\n    }\n    return 0;\n  }\n  return -1;\n}\n\n\n/*\n** If the WHERE_GROUPBY flag is set in the mask passed to sqlite3WhereBegin(),\n** the planner assumes that the specified pOrderBy list is actually a GROUP\n** BY clause - and so any order that groups rows as required satisfies the\n** request.\n**\n** Normally, in this case it is not possible for the caller to determine\n** whether or not the rows are really being delivered in sorted order, or\n** just in some other order that provides the required grouping. However,\n** if the WHERE_SORTBYGROUP flag is also passed to sqlite3WhereBegin(), then\n** this function may be called on the returned WhereInfo object. It returns\n** true if the rows really will be sorted in the specified order, or false\n** otherwise.\n**\n** For example, assuming:\n**\n**   CREATE INDEX i1 ON t1(x, Y);\n**\n** then\n**\n**   SELECT * FROM t1 GROUP BY x,y ORDER BY x,y;   -- IsSorted()==1\n**   SELECT * FROM t1 GROUP BY y,x ORDER BY y,x;   -- IsSorted()==0\n*/\nSQLITE_PRIVATE int sqlite3WhereIsSorted(WhereInfo *pWInfo){\n  assert( pWInfo->wctrlFlags & WHERE_GROUPBY );\n  assert( pWInfo->wctrlFlags & WHERE_SORTBYGROUP );\n  return pWInfo->sorted;\n}\n\n#ifdef WHERETRACE_ENABLED\n/* For debugging use only: */\nstatic const char *wherePathName(WherePath *pPath, int nLoop, WhereLoop *pLast){\n  static char zName[65];\n  int i;\n  for(i=0; i<nLoop; i++){ zName[i] = pPath->aLoop[i]->cId; }\n  if( pLast ) zName[i++] = pLast->cId;\n  zName[i] = 0;\n  return zName;\n}\n#endif\n\n/*\n** Return the cost of sorting nRow rows, assuming that the keys have \n** nOrderby columns and that the first nSorted columns are already in\n** order.\n*/\nstatic LogEst whereSortingCost(\n  WhereInfo *pWInfo,\n  LogEst nRow,\n  int nOrderBy,\n  int nSorted\n){\n  /* TUNING: Estimated cost of a full external sort, where N is \n  ** the number of rows to sort is:\n  **\n  **   cost = (3.0 * N * log(N)).\n  ** \n  ** Or, if the order-by clause has X terms but only the last Y \n  ** terms are out of order, then block-sorting will reduce the \n  ** sorting cost to:\n  **\n  **   cost = (3.0 * N * log(N)) * (Y/X)\n  **\n  ** The (Y/X) term is implemented using stack variable rScale\n  ** below.  */\n  LogEst rScale, rSortCost;\n  assert( nOrderBy>0 && 66==sqlite3LogEst(100) );\n  rScale = sqlite3LogEst((nOrderBy-nSorted)*100/nOrderBy) - 66;\n  rSortCost = nRow + rScale + 16;\n\n  /* Multiple by log(M) where M is the number of output rows.\n  ** Use the LIMIT for M if it is smaller */\n  if( (pWInfo->wctrlFlags & WHERE_USE_LIMIT)!=0 && pWInfo->iLimit<nRow ){\n    nRow = pWInfo->iLimit;\n  }\n  rSortCost += estLog(nRow);\n  return rSortCost;\n}\n\n/*\n** Given the list of WhereLoop objects at pWInfo->pLoops, this routine\n** attempts to find the lowest cost path that visits each WhereLoop\n** once.  This path is then loaded into the pWInfo->a[].pWLoop fields.\n**\n** Assume that the total number of output rows that will need to be sorted\n** will be nRowEst (in the 10*log2 representation).  Or, ignore sorting\n** costs if nRowEst==0.\n**\n** Return SQLITE_OK on success or SQLITE_NOMEM of a memory allocation\n** error occurs.\n*/\nstatic int wherePathSolver(WhereInfo *pWInfo, LogEst nRowEst){\n  int mxChoice;             /* Maximum number of simultaneous paths tracked */\n  int nLoop;                /* Number of terms in the join */\n  Parse *pParse;            /* Parsing context */\n  sqlite3 *db;              /* The database connection */\n  int iLoop;                /* Loop counter over the terms of the join */\n  int ii, jj;               /* Loop counters */\n  int mxI = 0;              /* Index of next entry to replace */\n  int nOrderBy;             /* Number of ORDER BY clause terms */\n  LogEst mxCost = 0;        /* Maximum cost of a set of paths */\n  LogEst mxUnsorted = 0;    /* Maximum unsorted cost of a set of path */\n  int nTo, nFrom;           /* Number of valid entries in aTo[] and aFrom[] */\n  WherePath *aFrom;         /* All nFrom paths at the previous level */\n  WherePath *aTo;           /* The nTo best paths at the current level */\n  WherePath *pFrom;         /* An element of aFrom[] that we are working on */\n  WherePath *pTo;           /* An element of aTo[] that we are working on */\n  WhereLoop *pWLoop;        /* One of the WhereLoop objects */\n  WhereLoop **pX;           /* Used to divy up the pSpace memory */\n  LogEst *aSortCost = 0;    /* Sorting and partial sorting costs */\n  char *pSpace;             /* Temporary memory used by this routine */\n  int nSpace;               /* Bytes of space allocated at pSpace */\n\n  pParse = pWInfo->pParse;\n  db = pParse->db;\n  nLoop = pWInfo->nLevel;\n  /* TUNING: For simple queries, only the best path is tracked.\n  ** For 2-way joins, the 5 best paths are followed.\n  ** For joins of 3 or more tables, track the 10 best paths */\n  mxChoice = (nLoop<=1) ? 1 : (nLoop==2 ? 5 : 10);\n  assert( nLoop<=pWInfo->pTabList->nSrc );\n  WHERETRACE(0x002, (\"---- begin solver.  (nRowEst=%d)\\n\", nRowEst));\n\n  /* If nRowEst is zero and there is an ORDER BY clause, ignore it. In this\n  ** case the purpose of this call is to estimate the number of rows returned\n  ** by the overall query. Once this estimate has been obtained, the caller\n  ** will invoke this function a second time, passing the estimate as the\n  ** nRowEst parameter.  */\n  if( pWInfo->pOrderBy==0 || nRowEst==0 ){\n    nOrderBy = 0;\n  }else{\n    nOrderBy = pWInfo->pOrderBy->nExpr;\n  }\n\n  /* Allocate and initialize space for aTo, aFrom and aSortCost[] */\n  nSpace = (sizeof(WherePath)+sizeof(WhereLoop*)*nLoop)*mxChoice*2;\n  nSpace += sizeof(LogEst) * nOrderBy;\n  pSpace = sqlite3DbMallocRawNN(db, nSpace);\n  if( pSpace==0 ) return SQLITE_NOMEM_BKPT;\n  aTo = (WherePath*)pSpace;\n  aFrom = aTo+mxChoice;\n  memset(aFrom, 0, sizeof(aFrom[0]));\n  pX = (WhereLoop**)(aFrom+mxChoice);\n  for(ii=mxChoice*2, pFrom=aTo; ii>0; ii--, pFrom++, pX += nLoop){\n    pFrom->aLoop = pX;\n  }\n  if( nOrderBy ){\n    /* If there is an ORDER BY clause and it is not being ignored, set up\n    ** space for the aSortCost[] array. Each element of the aSortCost array\n    ** is either zero - meaning it has not yet been initialized - or the\n    ** cost of sorting nRowEst rows of data where the first X terms of\n    ** the ORDER BY clause are already in order, where X is the array \n    ** index.  */\n    aSortCost = (LogEst*)pX;\n    memset(aSortCost, 0, sizeof(LogEst) * nOrderBy);\n  }\n  assert( aSortCost==0 || &pSpace[nSpace]==(char*)&aSortCost[nOrderBy] );\n  assert( aSortCost!=0 || &pSpace[nSpace]==(char*)pX );\n\n  /* Seed the search with a single WherePath containing zero WhereLoops.\n  **\n  ** TUNING: Do not let the number of iterations go above 28.  If the cost\n  ** of computing an automatic index is not paid back within the first 28\n  ** rows, then do not use the automatic index. */\n  aFrom[0].nRow = MIN(pParse->nQueryLoop, 48);  assert( 48==sqlite3LogEst(28) );\n  nFrom = 1;\n  assert( aFrom[0].isOrdered==0 );\n  if( nOrderBy ){\n    /* If nLoop is zero, then there are no FROM terms in the query. Since\n    ** in this case the query may return a maximum of one row, the results\n    ** are already in the requested order. Set isOrdered to nOrderBy to\n    ** indicate this. Or, if nLoop is greater than zero, set isOrdered to\n    ** -1, indicating that the result set may or may not be ordered, \n    ** depending on the loops added to the current plan.  */\n    aFrom[0].isOrdered = nLoop>0 ? -1 : nOrderBy;\n  }\n\n  /* Compute successively longer WherePaths using the previous generation\n  ** of WherePaths as the basis for the next.  Keep track of the mxChoice\n  ** best paths at each generation */\n  for(iLoop=0; iLoop<nLoop; iLoop++){\n    nTo = 0;\n    for(ii=0, pFrom=aFrom; ii<nFrom; ii++, pFrom++){\n      for(pWLoop=pWInfo->pLoops; pWLoop; pWLoop=pWLoop->pNextLoop){\n        LogEst nOut;                      /* Rows visited by (pFrom+pWLoop) */\n        LogEst rCost;                     /* Cost of path (pFrom+pWLoop) */\n        LogEst rUnsorted;                 /* Unsorted cost of (pFrom+pWLoop) */\n        i8 isOrdered = pFrom->isOrdered;  /* isOrdered for (pFrom+pWLoop) */\n        Bitmask maskNew;                  /* Mask of src visited by (..) */\n        Bitmask revMask = 0;              /* Mask of rev-order loops for (..) */\n\n        if( (pWLoop->prereq & ~pFrom->maskLoop)!=0 ) continue;\n        if( (pWLoop->maskSelf & pFrom->maskLoop)!=0 ) continue;\n        if( (pWLoop->wsFlags & WHERE_AUTO_INDEX)!=0 && pFrom->nRow<3 ){\n          /* Do not use an automatic index if the this loop is expected\n          ** to run less than 1.25 times.  It is tempting to also exclude\n          ** automatic index usage on an outer loop, but sometimes an automatic\n          ** index is useful in the outer loop of a correlated subquery. */\n          assert( 10==sqlite3LogEst(2) );\n          continue;\n        }\n\n        /* At this point, pWLoop is a candidate to be the next loop. \n        ** Compute its cost */\n        rUnsorted = sqlite3LogEstAdd(pWLoop->rSetup,pWLoop->rRun + pFrom->nRow);\n        rUnsorted = sqlite3LogEstAdd(rUnsorted, pFrom->rUnsorted);\n        nOut = pFrom->nRow + pWLoop->nOut;\n        maskNew = pFrom->maskLoop | pWLoop->maskSelf;\n        if( isOrdered<0 ){\n          isOrdered = wherePathSatisfiesOrderBy(pWInfo,\n                       pWInfo->pOrderBy, pFrom, pWInfo->wctrlFlags,\n                       iLoop, pWLoop, &revMask);\n        }else{\n          revMask = pFrom->revLoop;\n        }\n        if( isOrdered>=0 && isOrdered<nOrderBy ){\n          if( aSortCost[isOrdered]==0 ){\n            aSortCost[isOrdered] = whereSortingCost(\n                pWInfo, nRowEst, nOrderBy, isOrdered\n            );\n          }\n          /* TUNING:  Add a small extra penalty (5) to sorting as an\n          ** extra encouragment to the query planner to select a plan\n          ** where the rows emerge in the correct order without any sorting\n          ** required. */\n          rCost = sqlite3LogEstAdd(rUnsorted, aSortCost[isOrdered]) + 5;\n\n          WHERETRACE(0x002,\n              (\"---- sort cost=%-3d (%d/%d) increases cost %3d to %-3d\\n\",\n               aSortCost[isOrdered], (nOrderBy-isOrdered), nOrderBy, \n               rUnsorted, rCost));\n        }else{\n          rCost = rUnsorted;\n          rUnsorted -= 2;  /* TUNING:  Slight bias in favor of no-sort plans */\n        }\n\n        /* Check to see if pWLoop should be added to the set of\n        ** mxChoice best-so-far paths.\n        **\n        ** First look for an existing path among best-so-far paths\n        ** that covers the same set of loops and has the same isOrdered\n        ** setting as the current path candidate.\n        **\n        ** The term \"((pTo->isOrdered^isOrdered)&0x80)==0\" is equivalent\n        ** to (pTo->isOrdered==(-1))==(isOrdered==(-1))\" for the range\n        ** of legal values for isOrdered, -1..64.\n        */\n        for(jj=0, pTo=aTo; jj<nTo; jj++, pTo++){\n          if( pTo->maskLoop==maskNew\n           && ((pTo->isOrdered^isOrdered)&0x80)==0\n          ){\n            testcase( jj==nTo-1 );\n            break;\n          }\n        }\n        if( jj>=nTo ){\n          /* None of the existing best-so-far paths match the candidate. */\n          if( nTo>=mxChoice\n           && (rCost>mxCost || (rCost==mxCost && rUnsorted>=mxUnsorted))\n          ){\n            /* The current candidate is no better than any of the mxChoice\n            ** paths currently in the best-so-far buffer.  So discard\n            ** this candidate as not viable. */\n#ifdef WHERETRACE_ENABLED /* 0x4 */\n            if( sqlite3WhereTrace&0x4 ){\n              sqlite3DebugPrintf(\"Skip   %s cost=%-3d,%3d,%3d order=%c\\n\",\n                  wherePathName(pFrom, iLoop, pWLoop), rCost, nOut, rUnsorted,\n                  isOrdered>=0 ? isOrdered+'0' : '?');\n            }\n#endif\n            continue;\n          }\n          /* If we reach this points it means that the new candidate path\n          ** needs to be added to the set of best-so-far paths. */\n          if( nTo<mxChoice ){\n            /* Increase the size of the aTo set by one */\n            jj = nTo++;\n          }else{\n            /* New path replaces the prior worst to keep count below mxChoice */\n            jj = mxI;\n          }\n          pTo = &aTo[jj];\n#ifdef WHERETRACE_ENABLED /* 0x4 */\n          if( sqlite3WhereTrace&0x4 ){\n            sqlite3DebugPrintf(\"New    %s cost=%-3d,%3d,%3d order=%c\\n\",\n                wherePathName(pFrom, iLoop, pWLoop), rCost, nOut, rUnsorted,\n                isOrdered>=0 ? isOrdered+'0' : '?');\n          }\n#endif\n        }else{\n          /* Control reaches here if best-so-far path pTo=aTo[jj] covers the\n          ** same set of loops and has the same isOrdered setting as the\n          ** candidate path.  Check to see if the candidate should replace\n          ** pTo or if the candidate should be skipped.\n          ** \n          ** The conditional is an expanded vector comparison equivalent to:\n          **   (pTo->rCost,pTo->nRow,pTo->rUnsorted) <= (rCost,nOut,rUnsorted)\n          */\n          if( pTo->rCost<rCost \n           || (pTo->rCost==rCost\n               && (pTo->nRow<nOut\n                   || (pTo->nRow==nOut && pTo->rUnsorted<=rUnsorted)\n                  )\n              )\n          ){\n#ifdef WHERETRACE_ENABLED /* 0x4 */\n            if( sqlite3WhereTrace&0x4 ){\n              sqlite3DebugPrintf(\n                  \"Skip   %s cost=%-3d,%3d,%3d order=%c\",\n                  wherePathName(pFrom, iLoop, pWLoop), rCost, nOut, rUnsorted,\n                  isOrdered>=0 ? isOrdered+'0' : '?');\n              sqlite3DebugPrintf(\"   vs %s cost=%-3d,%3d,%3d order=%c\\n\",\n                  wherePathName(pTo, iLoop+1, 0), pTo->rCost, pTo->nRow,\n                  pTo->rUnsorted, pTo->isOrdered>=0 ? pTo->isOrdered+'0' : '?');\n            }\n#endif\n            /* Discard the candidate path from further consideration */\n            testcase( pTo->rCost==rCost );\n            continue;\n          }\n          testcase( pTo->rCost==rCost+1 );\n          /* Control reaches here if the candidate path is better than the\n          ** pTo path.  Replace pTo with the candidate. */\n#ifdef WHERETRACE_ENABLED /* 0x4 */\n          if( sqlite3WhereTrace&0x4 ){\n            sqlite3DebugPrintf(\n                \"Update %s cost=%-3d,%3d,%3d order=%c\",\n                wherePathName(pFrom, iLoop, pWLoop), rCost, nOut, rUnsorted,\n                isOrdered>=0 ? isOrdered+'0' : '?');\n            sqlite3DebugPrintf(\"  was %s cost=%-3d,%3d,%3d order=%c\\n\",\n                wherePathName(pTo, iLoop+1, 0), pTo->rCost, pTo->nRow,\n                pTo->rUnsorted, pTo->isOrdered>=0 ? pTo->isOrdered+'0' : '?');\n          }\n#endif\n        }\n        /* pWLoop is a winner.  Add it to the set of best so far */\n        pTo->maskLoop = pFrom->maskLoop | pWLoop->maskSelf;\n        pTo->revLoop = revMask;\n        pTo->nRow = nOut;\n        pTo->rCost = rCost;\n        pTo->rUnsorted = rUnsorted;\n        pTo->isOrdered = isOrdered;\n        memcpy(pTo->aLoop, pFrom->aLoop, sizeof(WhereLoop*)*iLoop);\n        pTo->aLoop[iLoop] = pWLoop;\n        if( nTo>=mxChoice ){\n          mxI = 0;\n          mxCost = aTo[0].rCost;\n          mxUnsorted = aTo[0].nRow;\n          for(jj=1, pTo=&aTo[1]; jj<mxChoice; jj++, pTo++){\n            if( pTo->rCost>mxCost \n             || (pTo->rCost==mxCost && pTo->rUnsorted>mxUnsorted) \n            ){\n              mxCost = pTo->rCost;\n              mxUnsorted = pTo->rUnsorted;\n              mxI = jj;\n            }\n          }\n        }\n      }\n    }\n\n#ifdef WHERETRACE_ENABLED  /* >=2 */\n    if( sqlite3WhereTrace & 0x02 ){\n      sqlite3DebugPrintf(\"---- after round %d ----\\n\", iLoop);\n      for(ii=0, pTo=aTo; ii<nTo; ii++, pTo++){\n        sqlite3DebugPrintf(\" %s cost=%-3d nrow=%-3d order=%c\",\n           wherePathName(pTo, iLoop+1, 0), pTo->rCost, pTo->nRow,\n           pTo->isOrdered>=0 ? (pTo->isOrdered+'0') : '?');\n        if( pTo->isOrdered>0 ){\n          sqlite3DebugPrintf(\" rev=0x%llx\\n\", pTo->revLoop);\n        }else{\n          sqlite3DebugPrintf(\"\\n\");\n        }\n      }\n    }\n#endif\n\n    /* Swap the roles of aFrom and aTo for the next generation */\n    pFrom = aTo;\n    aTo = aFrom;\n    aFrom = pFrom;\n    nFrom = nTo;\n  }\n\n  if( nFrom==0 ){\n    sqlite3ErrorMsg(pParse, \"no query solution\");\n    sqlite3DbFreeNN(db, pSpace);\n    return SQLITE_ERROR;\n  }\n  \n  /* Find the lowest cost path.  pFrom will be left pointing to that path */\n  pFrom = aFrom;\n  for(ii=1; ii<nFrom; ii++){\n    if( pFrom->rCost>aFrom[ii].rCost ) pFrom = &aFrom[ii];\n  }\n  assert( pWInfo->nLevel==nLoop );\n  /* Load the lowest cost path into pWInfo */\n  for(iLoop=0; iLoop<nLoop; iLoop++){\n    WhereLevel *pLevel = pWInfo->a + iLoop;\n    pLevel->pWLoop = pWLoop = pFrom->aLoop[iLoop];\n    pLevel->iFrom = pWLoop->iTab;\n    pLevel->iTabCur = pWInfo->pTabList->a[pLevel->iFrom].iCursor;\n  }\n  if( (pWInfo->wctrlFlags & WHERE_WANT_DISTINCT)!=0\n   && (pWInfo->wctrlFlags & WHERE_DISTINCTBY)==0\n   && pWInfo->eDistinct==WHERE_DISTINCT_NOOP\n   && nRowEst\n  ){\n    Bitmask notUsed;\n    int rc = wherePathSatisfiesOrderBy(pWInfo, pWInfo->pResultSet, pFrom,\n                 WHERE_DISTINCTBY, nLoop-1, pFrom->aLoop[nLoop-1], &notUsed);\n    if( rc==pWInfo->pResultSet->nExpr ){\n      pWInfo->eDistinct = WHERE_DISTINCT_ORDERED;\n    }\n  }\n  pWInfo->bOrderedInnerLoop = 0;\n  if( pWInfo->pOrderBy ){\n    if( pWInfo->wctrlFlags & WHERE_DISTINCTBY ){\n      if( pFrom->isOrdered==pWInfo->pOrderBy->nExpr ){\n        pWInfo->eDistinct = WHERE_DISTINCT_ORDERED;\n      }\n    }else{\n      pWInfo->nOBSat = pFrom->isOrdered;\n      pWInfo->revMask = pFrom->revLoop;\n      if( pWInfo->nOBSat<=0 ){\n        pWInfo->nOBSat = 0;\n        if( nLoop>0 ){\n          u32 wsFlags = pFrom->aLoop[nLoop-1]->wsFlags;\n          if( (wsFlags & WHERE_ONEROW)==0 \n           && (wsFlags&(WHERE_IPK|WHERE_COLUMN_IN))!=(WHERE_IPK|WHERE_COLUMN_IN)\n          ){\n            Bitmask m = 0;\n            int rc = wherePathSatisfiesOrderBy(pWInfo, pWInfo->pOrderBy, pFrom,\n                      WHERE_ORDERBY_LIMIT, nLoop-1, pFrom->aLoop[nLoop-1], &m);\n            testcase( wsFlags & WHERE_IPK );\n            testcase( wsFlags & WHERE_COLUMN_IN );\n            if( rc==pWInfo->pOrderBy->nExpr ){\n              pWInfo->bOrderedInnerLoop = 1;\n              pWInfo->revMask = m;\n            }\n          }\n        }\n      }\n    }\n    if( (pWInfo->wctrlFlags & WHERE_SORTBYGROUP)\n        && pWInfo->nOBSat==pWInfo->pOrderBy->nExpr && nLoop>0\n    ){\n      Bitmask revMask = 0;\n      int nOrder = wherePathSatisfiesOrderBy(pWInfo, pWInfo->pOrderBy, \n          pFrom, 0, nLoop-1, pFrom->aLoop[nLoop-1], &revMask\n      );\n      assert( pWInfo->sorted==0 );\n      if( nOrder==pWInfo->pOrderBy->nExpr ){\n        pWInfo->sorted = 1;\n        pWInfo->revMask = revMask;\n      }\n    }\n  }\n\n\n  pWInfo->nRowOut = pFrom->nRow;\n\n  /* Free temporary memory and return success */\n  sqlite3DbFreeNN(db, pSpace);\n  return SQLITE_OK;\n}\n\n/*\n** Most queries use only a single table (they are not joins) and have\n** simple == constraints against indexed fields.  This routine attempts\n** to plan those simple cases using much less ceremony than the\n** general-purpose query planner, and thereby yield faster sqlite3_prepare()\n** times for the common case.\n**\n** Return non-zero on success, if this query can be handled by this\n** no-frills query planner.  Return zero if this query needs the \n** general-purpose query planner.\n*/\nstatic int whereShortCut(WhereLoopBuilder *pBuilder){\n  WhereInfo *pWInfo;\n  struct SrcList_item *pItem;\n  WhereClause *pWC;\n  WhereTerm *pTerm;\n  WhereLoop *pLoop;\n  int iCur;\n  int j;\n  Table *pTab;\n  Index *pIdx;\n\n  pWInfo = pBuilder->pWInfo;\n  if( pWInfo->wctrlFlags & WHERE_OR_SUBCLAUSE ) return 0;\n  assert( pWInfo->pTabList->nSrc>=1 );\n  pItem = pWInfo->pTabList->a;\n  pTab = pItem->pTab;\n  if( IsVirtual(pTab) ) return 0;\n  if( pItem->fg.isIndexedBy ) return 0;\n  iCur = pItem->iCursor;\n  pWC = &pWInfo->sWC;\n  pLoop = pBuilder->pNew;\n  pLoop->wsFlags = 0;\n  pLoop->nSkip = 0;\n  pTerm = sqlite3WhereFindTerm(pWC, iCur, -1, 0, WO_EQ|WO_IS, 0);\n  if( pTerm ){\n    testcase( pTerm->eOperator & WO_IS );\n    pLoop->wsFlags = WHERE_COLUMN_EQ|WHERE_IPK|WHERE_ONEROW;\n    pLoop->aLTerm[0] = pTerm;\n    pLoop->nLTerm = 1;\n    pLoop->u.btree.nEq = 1;\n    /* TUNING: Cost of a rowid lookup is 10 */\n    pLoop->rRun = 33;  /* 33==sqlite3LogEst(10) */\n  }else{\n    for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){\n      int opMask;\n      assert( pLoop->aLTermSpace==pLoop->aLTerm );\n      if( !IsUniqueIndex(pIdx)\n       || pIdx->pPartIdxWhere!=0 \n       || pIdx->nKeyCol>ArraySize(pLoop->aLTermSpace) \n      ) continue;\n      opMask = pIdx->uniqNotNull ? (WO_EQ|WO_IS) : WO_EQ;\n      for(j=0; j<pIdx->nKeyCol; j++){\n        pTerm = sqlite3WhereFindTerm(pWC, iCur, j, 0, opMask, pIdx);\n        if( pTerm==0 ) break;\n        testcase( pTerm->eOperator & WO_IS );\n        pLoop->aLTerm[j] = pTerm;\n      }\n      if( j!=pIdx->nKeyCol ) continue;\n      pLoop->wsFlags = WHERE_COLUMN_EQ|WHERE_ONEROW|WHERE_INDEXED;\n      if( pIdx->isCovering || (pItem->colUsed & pIdx->colNotIdxed)==0 ){\n        pLoop->wsFlags |= WHERE_IDX_ONLY;\n      }\n      pLoop->nLTerm = j;\n      pLoop->u.btree.nEq = j;\n      pLoop->u.btree.pIndex = pIdx;\n      /* TUNING: Cost of a unique index lookup is 15 */\n      pLoop->rRun = 39;  /* 39==sqlite3LogEst(15) */\n      break;\n    }\n  }\n  if( pLoop->wsFlags ){\n    pLoop->nOut = (LogEst)1;\n    pWInfo->a[0].pWLoop = pLoop;\n    assert( pWInfo->sMaskSet.n==1 && iCur==pWInfo->sMaskSet.ix[0] );\n    pLoop->maskSelf = 1; /* sqlite3WhereGetMask(&pWInfo->sMaskSet, iCur); */\n    pWInfo->a[0].iTabCur = iCur;\n    pWInfo->nRowOut = 1;\n    if( pWInfo->pOrderBy ) pWInfo->nOBSat =  pWInfo->pOrderBy->nExpr;\n    if( pWInfo->wctrlFlags & WHERE_WANT_DISTINCT ){\n      pWInfo->eDistinct = WHERE_DISTINCT_UNIQUE;\n    }\n#ifdef SQLITE_DEBUG\n    pLoop->cId = '0';\n#endif\n    return 1;\n  }\n  return 0;\n}\n\n/*\n** Helper function for exprIsDeterministic().\n*/\nstatic int exprNodeIsDeterministic(Walker *pWalker, Expr *pExpr){\n  if( pExpr->op==TK_FUNCTION && ExprHasProperty(pExpr, EP_ConstFunc)==0 ){\n    pWalker->eCode = 0;\n    return WRC_Abort;\n  }\n  return WRC_Continue;\n}\n\n/*\n** Return true if the expression contains no non-deterministic SQL \n** functions. Do not consider non-deterministic SQL functions that are \n** part of sub-select statements.\n*/\nstatic int exprIsDeterministic(Expr *p){\n  Walker w;\n  memset(&w, 0, sizeof(w));\n  w.eCode = 1;\n  w.xExprCallback = exprNodeIsDeterministic;\n  w.xSelectCallback = sqlite3SelectWalkFail;\n  sqlite3WalkExpr(&w, p);\n  return w.eCode;\n}\n\n/*\n** Generate the beginning of the loop used for WHERE clause processing.\n** The return value is a pointer to an opaque structure that contains\n** information needed to terminate the loop.  Later, the calling routine\n** should invoke sqlite3WhereEnd() with the return value of this function\n** in order to complete the WHERE clause processing.\n**\n** If an error occurs, this routine returns NULL.\n**\n** The basic idea is to do a nested loop, one loop for each table in\n** the FROM clause of a select.  (INSERT and UPDATE statements are the\n** same as a SELECT with only a single table in the FROM clause.)  For\n** example, if the SQL is this:\n**\n**       SELECT * FROM t1, t2, t3 WHERE ...;\n**\n** Then the code generated is conceptually like the following:\n**\n**      foreach row1 in t1 do       \\    Code generated\n**        foreach row2 in t2 do      |-- by sqlite3WhereBegin()\n**          foreach row3 in t3 do   /\n**            ...\n**          end                     \\    Code generated\n**        end                        |-- by sqlite3WhereEnd()\n**      end                         /\n**\n** Note that the loops might not be nested in the order in which they\n** appear in the FROM clause if a different order is better able to make\n** use of indices.  Note also that when the IN operator appears in\n** the WHERE clause, it might result in additional nested loops for\n** scanning through all values on the right-hand side of the IN.\n**\n** There are Btree cursors associated with each table.  t1 uses cursor\n** number pTabList->a[0].iCursor.  t2 uses the cursor pTabList->a[1].iCursor.\n** And so forth.  This routine generates code to open those VDBE cursors\n** and sqlite3WhereEnd() generates the code to close them.\n**\n** The code that sqlite3WhereBegin() generates leaves the cursors named\n** in pTabList pointing at their appropriate entries.  The [...] code\n** can use OP_Column and OP_Rowid opcodes on these cursors to extract\n** data from the various tables of the loop.\n**\n** If the WHERE clause is empty, the foreach loops must each scan their\n** entire tables.  Thus a three-way join is an O(N^3) operation.  But if\n** the tables have indices and there are terms in the WHERE clause that\n** refer to those indices, a complete table scan can be avoided and the\n** code will run much faster.  Most of the work of this routine is checking\n** to see if there are indices that can be used to speed up the loop.\n**\n** Terms of the WHERE clause are also used to limit which rows actually\n** make it to the \"...\" in the middle of the loop.  After each \"foreach\",\n** terms of the WHERE clause that use only terms in that loop and outer\n** loops are evaluated and if false a jump is made around all subsequent\n** inner loops (or around the \"...\" if the test occurs within the inner-\n** most loop)\n**\n** OUTER JOINS\n**\n** An outer join of tables t1 and t2 is conceptally coded as follows:\n**\n**    foreach row1 in t1 do\n**      flag = 0\n**      foreach row2 in t2 do\n**        start:\n**          ...\n**          flag = 1\n**      end\n**      if flag==0 then\n**        move the row2 cursor to a null row\n**        goto start\n**      fi\n**    end\n**\n** ORDER BY CLAUSE PROCESSING\n**\n** pOrderBy is a pointer to the ORDER BY clause (or the GROUP BY clause\n** if the WHERE_GROUPBY flag is set in wctrlFlags) of a SELECT statement\n** if there is one.  If there is no ORDER BY clause or if this routine\n** is called from an UPDATE or DELETE statement, then pOrderBy is NULL.\n**\n** The iIdxCur parameter is the cursor number of an index.  If \n** WHERE_OR_SUBCLAUSE is set, iIdxCur is the cursor number of an index\n** to use for OR clause processing.  The WHERE clause should use this\n** specific cursor.  If WHERE_ONEPASS_DESIRED is set, then iIdxCur is\n** the first cursor in an array of cursors for all indices.  iIdxCur should\n** be used to compute the appropriate cursor depending on which index is\n** used.\n*/\nSQLITE_PRIVATE WhereInfo *sqlite3WhereBegin(\n  Parse *pParse,          /* The parser context */\n  SrcList *pTabList,      /* FROM clause: A list of all tables to be scanned */\n  Expr *pWhere,           /* The WHERE clause */\n  ExprList *pOrderBy,     /* An ORDER BY (or GROUP BY) clause, or NULL */\n  ExprList *pResultSet,   /* Query result set.  Req'd for DISTINCT */\n  u16 wctrlFlags,         /* The WHERE_* flags defined in sqliteInt.h */\n  int iAuxArg             /* If WHERE_OR_SUBCLAUSE is set, index cursor number\n                          ** If WHERE_USE_LIMIT, then the limit amount */\n){\n  int nByteWInfo;            /* Num. bytes allocated for WhereInfo struct */\n  int nTabList;              /* Number of elements in pTabList */\n  WhereInfo *pWInfo;         /* Will become the return value of this function */\n  Vdbe *v = pParse->pVdbe;   /* The virtual database engine */\n  Bitmask notReady;          /* Cursors that are not yet positioned */\n  WhereLoopBuilder sWLB;     /* The WhereLoop builder */\n  WhereMaskSet *pMaskSet;    /* The expression mask set */\n  WhereLevel *pLevel;        /* A single level in pWInfo->a[] */\n  WhereLoop *pLoop;          /* Pointer to a single WhereLoop object */\n  int ii;                    /* Loop counter */\n  sqlite3 *db;               /* Database connection */\n  int rc;                    /* Return code */\n  u8 bFordelete = 0;         /* OPFLAG_FORDELETE or zero, as appropriate */\n\n  assert( (wctrlFlags & WHERE_ONEPASS_MULTIROW)==0 || (\n        (wctrlFlags & WHERE_ONEPASS_DESIRED)!=0 \n     && (wctrlFlags & WHERE_OR_SUBCLAUSE)==0 \n  ));\n\n  /* Only one of WHERE_OR_SUBCLAUSE or WHERE_USE_LIMIT */\n  assert( (wctrlFlags & WHERE_OR_SUBCLAUSE)==0\n            || (wctrlFlags & WHERE_USE_LIMIT)==0 );\n\n  /* Variable initialization */\n  db = pParse->db;\n  memset(&sWLB, 0, sizeof(sWLB));\n\n  /* An ORDER/GROUP BY clause of more than 63 terms cannot be optimized */\n  testcase( pOrderBy && pOrderBy->nExpr==BMS-1 );\n  if( pOrderBy && pOrderBy->nExpr>=BMS ) pOrderBy = 0;\n  sWLB.pOrderBy = pOrderBy;\n\n  /* Disable the DISTINCT optimization if SQLITE_DistinctOpt is set via\n  ** sqlite3_test_ctrl(SQLITE_TESTCTRL_OPTIMIZATIONS,...) */\n  if( OptimizationDisabled(db, SQLITE_DistinctOpt) ){\n    wctrlFlags &= ~WHERE_WANT_DISTINCT;\n  }\n\n  /* The number of tables in the FROM clause is limited by the number of\n  ** bits in a Bitmask \n  */\n  testcase( pTabList->nSrc==BMS );\n  if( pTabList->nSrc>BMS ){\n    sqlite3ErrorMsg(pParse, \"at most %d tables in a join\", BMS);\n    return 0;\n  }\n\n  /* This function normally generates a nested loop for all tables in \n  ** pTabList.  But if the WHERE_OR_SUBCLAUSE flag is set, then we should\n  ** only generate code for the first table in pTabList and assume that\n  ** any cursors associated with subsequent tables are uninitialized.\n  */\n  nTabList = (wctrlFlags & WHERE_OR_SUBCLAUSE) ? 1 : pTabList->nSrc;\n\n  /* Allocate and initialize the WhereInfo structure that will become the\n  ** return value. A single allocation is used to store the WhereInfo\n  ** struct, the contents of WhereInfo.a[], the WhereClause structure\n  ** and the WhereMaskSet structure. Since WhereClause contains an 8-byte\n  ** field (type Bitmask) it must be aligned on an 8-byte boundary on\n  ** some architectures. Hence the ROUND8() below.\n  */\n  nByteWInfo = ROUND8(sizeof(WhereInfo)+(nTabList-1)*sizeof(WhereLevel));\n  pWInfo = sqlite3DbMallocRawNN(db, nByteWInfo + sizeof(WhereLoop));\n  if( db->mallocFailed ){\n    sqlite3DbFree(db, pWInfo);\n    pWInfo = 0;\n    goto whereBeginError;\n  }\n  pWInfo->pParse = pParse;\n  pWInfo->pTabList = pTabList;\n  pWInfo->pOrderBy = pOrderBy;\n  pWInfo->pWhere = pWhere;\n  pWInfo->pResultSet = pResultSet;\n  pWInfo->aiCurOnePass[0] = pWInfo->aiCurOnePass[1] = -1;\n  pWInfo->nLevel = nTabList;\n  pWInfo->iBreak = pWInfo->iContinue = sqlite3VdbeMakeLabel(pParse);\n  pWInfo->wctrlFlags = wctrlFlags;\n  pWInfo->iLimit = iAuxArg;\n  pWInfo->savedNQueryLoop = pParse->nQueryLoop;\n  memset(&pWInfo->nOBSat, 0, \n         offsetof(WhereInfo,sWC) - offsetof(WhereInfo,nOBSat));\n  memset(&pWInfo->a[0], 0, sizeof(WhereLoop)+nTabList*sizeof(WhereLevel));\n  assert( pWInfo->eOnePass==ONEPASS_OFF );  /* ONEPASS defaults to OFF */\n  pMaskSet = &pWInfo->sMaskSet;\n  sWLB.pWInfo = pWInfo;\n  sWLB.pWC = &pWInfo->sWC;\n  sWLB.pNew = (WhereLoop*)(((char*)pWInfo)+nByteWInfo);\n  assert( EIGHT_BYTE_ALIGNMENT(sWLB.pNew) );\n  whereLoopInit(sWLB.pNew);\n#ifdef SQLITE_DEBUG\n  sWLB.pNew->cId = '*';\n#endif\n\n  /* Split the WHERE clause into separate subexpressions where each\n  ** subexpression is separated by an AND operator.\n  */\n  initMaskSet(pMaskSet);\n  sqlite3WhereClauseInit(&pWInfo->sWC, pWInfo);\n  sqlite3WhereSplit(&pWInfo->sWC, pWhere, TK_AND);\n    \n  /* Special case: No FROM clause\n  */\n  if( nTabList==0 ){\n    if( pOrderBy ) pWInfo->nOBSat = pOrderBy->nExpr;\n    if( wctrlFlags & WHERE_WANT_DISTINCT ){\n      pWInfo->eDistinct = WHERE_DISTINCT_UNIQUE;\n    }\n    ExplainQueryPlan((pParse, 0, \"SCAN CONSTANT ROW\"));\n  }else{\n    /* Assign a bit from the bitmask to every term in the FROM clause.\n    **\n    ** The N-th term of the FROM clause is assigned a bitmask of 1<<N.\n    **\n    ** The rule of the previous sentence ensures thta if X is the bitmask for\n    ** a table T, then X-1 is the bitmask for all other tables to the left of T.\n    ** Knowing the bitmask for all tables to the left of a left join is\n    ** important.  Ticket #3015.\n    **\n    ** Note that bitmasks are created for all pTabList->nSrc tables in\n    ** pTabList, not just the first nTabList tables.  nTabList is normally\n    ** equal to pTabList->nSrc but might be shortened to 1 if the\n    ** WHERE_OR_SUBCLAUSE flag is set.\n    */\n    ii = 0;\n    do{\n      createMask(pMaskSet, pTabList->a[ii].iCursor);\n      sqlite3WhereTabFuncArgs(pParse, &pTabList->a[ii], &pWInfo->sWC);\n    }while( (++ii)<pTabList->nSrc );\n  #ifdef SQLITE_DEBUG\n    {\n      Bitmask mx = 0;\n      for(ii=0; ii<pTabList->nSrc; ii++){\n        Bitmask m = sqlite3WhereGetMask(pMaskSet, pTabList->a[ii].iCursor);\n        assert( m>=mx );\n        mx = m;\n      }\n    }\n  #endif\n  }\n  \n  /* Analyze all of the subexpressions. */\n  sqlite3WhereExprAnalyze(pTabList, &pWInfo->sWC);\n  if( db->mallocFailed ) goto whereBeginError;\n\n  /* Special case: WHERE terms that do not refer to any tables in the join\n  ** (constant expressions). Evaluate each such term, and jump over all the\n  ** generated code if the result is not true.  \n  **\n  ** Do not do this if the expression contains non-deterministic functions\n  ** that are not within a sub-select. This is not strictly required, but\n  ** preserves SQLite's legacy behaviour in the following two cases:\n  **\n  **   FROM ... WHERE random()>0;           -- eval random() once per row\n  **   FROM ... WHERE (SELECT random())>0;  -- eval random() once overall\n  */\n  for(ii=0; ii<sWLB.pWC->nTerm; ii++){\n    WhereTerm *pT = &sWLB.pWC->a[ii];\n    if( pT->wtFlags & TERM_VIRTUAL ) continue;\n    if( pT->prereqAll==0 && (nTabList==0 || exprIsDeterministic(pT->pExpr)) ){\n      sqlite3ExprIfFalse(pParse, pT->pExpr, pWInfo->iBreak, SQLITE_JUMPIFNULL);\n      pT->wtFlags |= TERM_CODED;\n    }\n  }\n\n  if( wctrlFlags & WHERE_WANT_DISTINCT ){\n    if( isDistinctRedundant(pParse, pTabList, &pWInfo->sWC, pResultSet) ){\n      /* The DISTINCT marking is pointless.  Ignore it. */\n      pWInfo->eDistinct = WHERE_DISTINCT_UNIQUE;\n    }else if( pOrderBy==0 ){\n      /* Try to ORDER BY the result set to make distinct processing easier */\n      pWInfo->wctrlFlags |= WHERE_DISTINCTBY;\n      pWInfo->pOrderBy = pResultSet;\n    }\n  }\n\n  /* Construct the WhereLoop objects */\n#if defined(WHERETRACE_ENABLED)\n  if( sqlite3WhereTrace & 0xffff ){\n    sqlite3DebugPrintf(\"*** Optimizer Start *** (wctrlFlags: 0x%x\",wctrlFlags);\n    if( wctrlFlags & WHERE_USE_LIMIT ){\n      sqlite3DebugPrintf(\", limit: %d\", iAuxArg);\n    }\n    sqlite3DebugPrintf(\")\\n\");\n  }\n  if( sqlite3WhereTrace & 0x100 ){ /* Display all terms of the WHERE clause */\n    sqlite3WhereClausePrint(sWLB.pWC);\n  }\n#endif\n\n  if( nTabList!=1 || whereShortCut(&sWLB)==0 ){\n    rc = whereLoopAddAll(&sWLB);\n    if( rc ) goto whereBeginError;\n  \n#ifdef WHERETRACE_ENABLED\n    if( sqlite3WhereTrace ){    /* Display all of the WhereLoop objects */\n      WhereLoop *p;\n      int i;\n      static const char zLabel[] = \"0123456789abcdefghijklmnopqrstuvwyxz\"\n                                             \"ABCDEFGHIJKLMNOPQRSTUVWYXZ\";\n      for(p=pWInfo->pLoops, i=0; p; p=p->pNextLoop, i++){\n        p->cId = zLabel[i%(sizeof(zLabel)-1)];\n        whereLoopPrint(p, sWLB.pWC);\n      }\n    }\n#endif\n  \n    wherePathSolver(pWInfo, 0);\n    if( db->mallocFailed ) goto whereBeginError;\n    if( pWInfo->pOrderBy ){\n       wherePathSolver(pWInfo, pWInfo->nRowOut+1);\n       if( db->mallocFailed ) goto whereBeginError;\n    }\n  }\n  if( pWInfo->pOrderBy==0 && (db->flags & SQLITE_ReverseOrder)!=0 ){\n     pWInfo->revMask = ALLBITS;\n  }\n  if( pParse->nErr || NEVER(db->mallocFailed) ){\n    goto whereBeginError;\n  }\n#ifdef WHERETRACE_ENABLED\n  if( sqlite3WhereTrace ){\n    sqlite3DebugPrintf(\"---- Solution nRow=%d\", pWInfo->nRowOut);\n    if( pWInfo->nOBSat>0 ){\n      sqlite3DebugPrintf(\" ORDERBY=%d,0x%llx\", pWInfo->nOBSat, pWInfo->revMask);\n    }\n    switch( pWInfo->eDistinct ){\n      case WHERE_DISTINCT_UNIQUE: {\n        sqlite3DebugPrintf(\"  DISTINCT=unique\");\n        break;\n      }\n      case WHERE_DISTINCT_ORDERED: {\n        sqlite3DebugPrintf(\"  DISTINCT=ordered\");\n        break;\n      }\n      case WHERE_DISTINCT_UNORDERED: {\n        sqlite3DebugPrintf(\"  DISTINCT=unordered\");\n        break;\n      }\n    }\n    sqlite3DebugPrintf(\"\\n\");\n    for(ii=0; ii<pWInfo->nLevel; ii++){\n      whereLoopPrint(pWInfo->a[ii].pWLoop, sWLB.pWC);\n    }\n  }\n#endif\n\n  /* Attempt to omit tables from the join that do not affect the result.\n  ** For a table to not affect the result, the following must be true:\n  **\n  **   1) The query must not be an aggregate.\n  **   2) The table must be the RHS of a LEFT JOIN.\n  **   3) Either the query must be DISTINCT, or else the ON or USING clause\n  **      must contain a constraint that limits the scan of the table to \n  **      at most a single row.\n  **   4) The table must not be referenced by any part of the query apart\n  **      from its own USING or ON clause.\n  **\n  ** For example, given:\n  **\n  **     CREATE TABLE t1(ipk INTEGER PRIMARY KEY, v1);\n  **     CREATE TABLE t2(ipk INTEGER PRIMARY KEY, v2);\n  **     CREATE TABLE t3(ipk INTEGER PRIMARY KEY, v3);\n  **\n  ** then table t2 can be omitted from the following:\n  **\n  **     SELECT v1, v3 FROM t1 \n  **       LEFT JOIN t2 USING (t1.ipk=t2.ipk)\n  **       LEFT JOIN t3 USING (t1.ipk=t3.ipk)\n  **\n  ** or from:\n  **\n  **     SELECT DISTINCT v1, v3 FROM t1 \n  **       LEFT JOIN t2\n  **       LEFT JOIN t3 USING (t1.ipk=t3.ipk)\n  */\n  notReady = ~(Bitmask)0;\n  if( pWInfo->nLevel>=2\n   && pResultSet!=0               /* guarantees condition (1) above */\n   && OptimizationEnabled(db, SQLITE_OmitNoopJoin)\n  ){\n    int i;\n    Bitmask tabUsed = sqlite3WhereExprListUsage(pMaskSet, pResultSet);\n    if( sWLB.pOrderBy ){\n      tabUsed |= sqlite3WhereExprListUsage(pMaskSet, sWLB.pOrderBy);\n    }\n    for(i=pWInfo->nLevel-1; i>=1; i--){\n      WhereTerm *pTerm, *pEnd;\n      struct SrcList_item *pItem;\n      pLoop = pWInfo->a[i].pWLoop;\n      pItem = &pWInfo->pTabList->a[pLoop->iTab];\n      if( (pItem->fg.jointype & JT_LEFT)==0 ) continue;\n      if( (wctrlFlags & WHERE_WANT_DISTINCT)==0\n       && (pLoop->wsFlags & WHERE_ONEROW)==0\n      ){\n        continue;\n      }\n      if( (tabUsed & pLoop->maskSelf)!=0 ) continue;\n      pEnd = sWLB.pWC->a + sWLB.pWC->nTerm;\n      for(pTerm=sWLB.pWC->a; pTerm<pEnd; pTerm++){\n        if( (pTerm->prereqAll & pLoop->maskSelf)!=0 ){\n          if( !ExprHasProperty(pTerm->pExpr, EP_FromJoin)\n           || pTerm->pExpr->iRightJoinTable!=pItem->iCursor\n          ){\n            break;\n          }\n        }\n      }\n      if( pTerm<pEnd ) continue;\n      WHERETRACE(0xffff, (\"-> drop loop %c not used\\n\", pLoop->cId));\n      notReady &= ~pLoop->maskSelf;\n      for(pTerm=sWLB.pWC->a; pTerm<pEnd; pTerm++){\n        if( (pTerm->prereqAll & pLoop->maskSelf)!=0 ){\n          pTerm->wtFlags |= TERM_CODED;\n        }\n      }\n      if( i!=pWInfo->nLevel-1 ){\n        int nByte = (pWInfo->nLevel-1-i) * sizeof(WhereLevel);\n        memmove(&pWInfo->a[i], &pWInfo->a[i+1], nByte);\n      }\n      pWInfo->nLevel--;\n      nTabList--;\n    }\n  }\n  WHERETRACE(0xffff,(\"*** Optimizer Finished ***\\n\"));\n  pWInfo->pParse->nQueryLoop += pWInfo->nRowOut;\n\n  /* If the caller is an UPDATE or DELETE statement that is requesting\n  ** to use a one-pass algorithm, determine if this is appropriate.\n  **\n  ** A one-pass approach can be used if the caller has requested one\n  ** and either (a) the scan visits at most one row or (b) each\n  ** of the following are true:\n  **\n  **   * the caller has indicated that a one-pass approach can be used\n  **     with multiple rows (by setting WHERE_ONEPASS_MULTIROW), and\n  **   * the table is not a virtual table, and\n  **   * either the scan does not use the OR optimization or the caller\n  **     is a DELETE operation (WHERE_DUPLICATES_OK is only specified\n  **     for DELETE).\n  **\n  ** The last qualification is because an UPDATE statement uses\n  ** WhereInfo.aiCurOnePass[1] to determine whether or not it really can\n  ** use a one-pass approach, and this is not set accurately for scans\n  ** that use the OR optimization.\n  */\n  assert( (wctrlFlags & WHERE_ONEPASS_DESIRED)==0 || pWInfo->nLevel==1 );\n  if( (wctrlFlags & WHERE_ONEPASS_DESIRED)!=0 ){\n    int wsFlags = pWInfo->a[0].pWLoop->wsFlags;\n    int bOnerow = (wsFlags & WHERE_ONEROW)!=0;\n    assert( !(wsFlags & WHERE_VIRTUALTABLE) || IsVirtual(pTabList->a[0].pTab) );\n    if( bOnerow || (\n        0!=(wctrlFlags & WHERE_ONEPASS_MULTIROW)\n     && !IsVirtual(pTabList->a[0].pTab)\n     && (0==(wsFlags & WHERE_MULTI_OR) || (wctrlFlags & WHERE_DUPLICATES_OK))\n    )){\n      pWInfo->eOnePass = bOnerow ? ONEPASS_SINGLE : ONEPASS_MULTI;\n      if( HasRowid(pTabList->a[0].pTab) && (wsFlags & WHERE_IDX_ONLY) ){\n        if( wctrlFlags & WHERE_ONEPASS_MULTIROW ){\n          bFordelete = OPFLAG_FORDELETE;\n        }\n        pWInfo->a[0].pWLoop->wsFlags = (wsFlags & ~WHERE_IDX_ONLY);\n      }\n    }\n  }\n\n  /* Open all tables in the pTabList and any indices selected for\n  ** searching those tables.\n  */\n  for(ii=0, pLevel=pWInfo->a; ii<nTabList; ii++, pLevel++){\n    Table *pTab;     /* Table to open */\n    int iDb;         /* Index of database containing table/index */\n    struct SrcList_item *pTabItem;\n\n    pTabItem = &pTabList->a[pLevel->iFrom];\n    pTab = pTabItem->pTab;\n    iDb = sqlite3SchemaToIndex(db, pTab->pSchema);\n    pLoop = pLevel->pWLoop;\n    if( (pTab->tabFlags & TF_Ephemeral)!=0 || pTab->pSelect ){\n      /* Do nothing */\n    }else\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n    if( (pLoop->wsFlags & WHERE_VIRTUALTABLE)!=0 ){\n      const char *pVTab = (const char *)sqlite3GetVTable(db, pTab);\n      int iCur = pTabItem->iCursor;\n      sqlite3VdbeAddOp4(v, OP_VOpen, iCur, 0, 0, pVTab, P4_VTAB);\n    }else if( IsVirtual(pTab) ){\n      /* noop */\n    }else\n#endif\n    if( (pLoop->wsFlags & WHERE_IDX_ONLY)==0\n         && (wctrlFlags & WHERE_OR_SUBCLAUSE)==0 ){\n      int op = OP_OpenRead;\n      if( pWInfo->eOnePass!=ONEPASS_OFF ){\n        op = OP_OpenWrite;\n        pWInfo->aiCurOnePass[0] = pTabItem->iCursor;\n      };\n      sqlite3OpenTable(pParse, pTabItem->iCursor, iDb, pTab, op);\n      assert( pTabItem->iCursor==pLevel->iTabCur );\n      testcase( pWInfo->eOnePass==ONEPASS_OFF && pTab->nCol==BMS-1 );\n      testcase( pWInfo->eOnePass==ONEPASS_OFF && pTab->nCol==BMS );\n      if( pWInfo->eOnePass==ONEPASS_OFF && pTab->nCol<BMS && HasRowid(pTab) ){\n        Bitmask b = pTabItem->colUsed;\n        int n = 0;\n        for(; b; b=b>>1, n++){}\n        sqlite3VdbeChangeP4(v, -1, SQLITE_INT_TO_PTR(n), P4_INT32);\n        assert( n<=pTab->nCol );\n      }\n#ifdef SQLITE_ENABLE_CURSOR_HINTS\n      if( pLoop->u.btree.pIndex!=0 ){\n        sqlite3VdbeChangeP5(v, OPFLAG_SEEKEQ|bFordelete);\n      }else\n#endif\n      {\n        sqlite3VdbeChangeP5(v, bFordelete);\n      }\n#ifdef SQLITE_ENABLE_COLUMN_USED_MASK\n      sqlite3VdbeAddOp4Dup8(v, OP_ColumnsUsed, pTabItem->iCursor, 0, 0,\n                            (const u8*)&pTabItem->colUsed, P4_INT64);\n#endif\n    }else{\n      sqlite3TableLock(pParse, iDb, pTab->tnum, 0, pTab->zName);\n    }\n    if( pLoop->wsFlags & WHERE_INDEXED ){\n      Index *pIx = pLoop->u.btree.pIndex;\n      int iIndexCur;\n      int op = OP_OpenRead;\n      /* iAuxArg is always set to a positive value if ONEPASS is possible */\n      assert( iAuxArg!=0 || (pWInfo->wctrlFlags & WHERE_ONEPASS_DESIRED)==0 );\n      if( !HasRowid(pTab) && IsPrimaryKeyIndex(pIx)\n       && (wctrlFlags & WHERE_OR_SUBCLAUSE)!=0\n      ){\n        /* This is one term of an OR-optimization using the PRIMARY KEY of a\n        ** WITHOUT ROWID table.  No need for a separate index */\n        iIndexCur = pLevel->iTabCur;\n        op = 0;\n      }else if( pWInfo->eOnePass!=ONEPASS_OFF ){\n        Index *pJ = pTabItem->pTab->pIndex;\n        iIndexCur = iAuxArg;\n        assert( wctrlFlags & WHERE_ONEPASS_DESIRED );\n        while( ALWAYS(pJ) && pJ!=pIx ){\n          iIndexCur++;\n          pJ = pJ->pNext;\n        }\n        op = OP_OpenWrite;\n        pWInfo->aiCurOnePass[1] = iIndexCur;\n      }else if( iAuxArg && (wctrlFlags & WHERE_OR_SUBCLAUSE)!=0 ){\n        iIndexCur = iAuxArg;\n        op = OP_ReopenIdx;\n      }else{\n        iIndexCur = pParse->nTab++;\n      }\n      pLevel->iIdxCur = iIndexCur;\n      assert( pIx->pSchema==pTab->pSchema );\n      assert( iIndexCur>=0 );\n      if( op ){\n        sqlite3VdbeAddOp3(v, op, iIndexCur, pIx->tnum, iDb);\n        sqlite3VdbeSetP4KeyInfo(pParse, pIx);\n        if( (pLoop->wsFlags & WHERE_CONSTRAINT)!=0\n         && (pLoop->wsFlags & (WHERE_COLUMN_RANGE|WHERE_SKIPSCAN))==0\n         && (pWInfo->wctrlFlags&WHERE_ORDERBY_MIN)==0\n         && pWInfo->eDistinct!=WHERE_DISTINCT_ORDERED\n        ){\n          sqlite3VdbeChangeP5(v, OPFLAG_SEEKEQ); /* Hint to COMDB2 */\n        }\n        VdbeComment((v, \"%s\", pIx->zName));\n#ifdef SQLITE_ENABLE_COLUMN_USED_MASK\n        {\n          u64 colUsed = 0;\n          int ii, jj;\n          for(ii=0; ii<pIx->nColumn; ii++){\n            jj = pIx->aiColumn[ii];\n            if( jj<0 ) continue;\n            if( jj>63 ) jj = 63;\n            if( (pTabItem->colUsed & MASKBIT(jj))==0 ) continue;\n            colUsed |= ((u64)1)<<(ii<63 ? ii : 63);\n          }\n          sqlite3VdbeAddOp4Dup8(v, OP_ColumnsUsed, iIndexCur, 0, 0,\n                                (u8*)&colUsed, P4_INT64);\n        }\n#endif /* SQLITE_ENABLE_COLUMN_USED_MASK */\n      }\n    }\n    if( iDb>=0 ) sqlite3CodeVerifySchema(pParse, iDb);\n  }\n  pWInfo->iTop = sqlite3VdbeCurrentAddr(v);\n  if( db->mallocFailed ) goto whereBeginError;\n\n  /* Generate the code to do the search.  Each iteration of the for\n  ** loop below generates code for a single nested loop of the VM\n  ** program.\n  */\n  for(ii=0; ii<nTabList; ii++){\n    int addrExplain;\n    int wsFlags;\n    pLevel = &pWInfo->a[ii];\n    wsFlags = pLevel->pWLoop->wsFlags;\n#ifndef SQLITE_OMIT_AUTOMATIC_INDEX\n    if( (pLevel->pWLoop->wsFlags & WHERE_AUTO_INDEX)!=0 ){\n      constructAutomaticIndex(pParse, &pWInfo->sWC,\n                &pTabList->a[pLevel->iFrom], notReady, pLevel);\n      if( db->mallocFailed ) goto whereBeginError;\n    }\n#endif\n    addrExplain = sqlite3WhereExplainOneScan(\n        pParse, pTabList, pLevel, wctrlFlags\n    );\n    pLevel->addrBody = sqlite3VdbeCurrentAddr(v);\n    notReady = sqlite3WhereCodeOneLoopStart(pParse,v,pWInfo,ii,pLevel,notReady);\n    pWInfo->iContinue = pLevel->addrCont;\n    if( (wsFlags&WHERE_MULTI_OR)==0 && (wctrlFlags&WHERE_OR_SUBCLAUSE)==0 ){\n      sqlite3WhereAddScanStatus(v, pTabList, pLevel, addrExplain);\n    }\n  }\n\n  /* Done. */\n  VdbeModuleComment((v, \"Begin WHERE-core\"));\n  return pWInfo;\n\n  /* Jump here if malloc fails */\nwhereBeginError:\n  if( pWInfo ){\n    pParse->nQueryLoop = pWInfo->savedNQueryLoop;\n    whereInfoFree(db, pWInfo);\n  }\n  return 0;\n}\n\n/*\n** Part of sqlite3WhereEnd() will rewrite opcodes to reference the\n** index rather than the main table.  In SQLITE_DEBUG mode, we want\n** to trace those changes if PRAGMA vdbe_addoptrace=on.  This routine\n** does that.\n*/\n#ifndef SQLITE_DEBUG\n# define OpcodeRewriteTrace(D,K,P) /* no-op */\n#else\n# define OpcodeRewriteTrace(D,K,P) sqlite3WhereOpcodeRewriteTrace(D,K,P)\n  static void sqlite3WhereOpcodeRewriteTrace(\n    sqlite3 *db,\n    int pc,\n    VdbeOp *pOp\n  ){\n    if( (db->flags & SQLITE_VdbeAddopTrace)==0 ) return;\n    sqlite3VdbePrintOp(0, pc, pOp);\n  }\n#endif\n\n/*\n** Generate the end of the WHERE loop.  See comments on \n** sqlite3WhereBegin() for additional information.\n*/\nSQLITE_PRIVATE void sqlite3WhereEnd(WhereInfo *pWInfo){\n  Parse *pParse = pWInfo->pParse;\n  Vdbe *v = pParse->pVdbe;\n  int i;\n  WhereLevel *pLevel;\n  WhereLoop *pLoop;\n  SrcList *pTabList = pWInfo->pTabList;\n  sqlite3 *db = pParse->db;\n\n  /* Generate loop termination code.\n  */\n  VdbeModuleComment((v, \"End WHERE-core\"));\n  for(i=pWInfo->nLevel-1; i>=0; i--){\n    int addr;\n    pLevel = &pWInfo->a[i];\n    pLoop = pLevel->pWLoop;\n    if( pLevel->op!=OP_Noop ){\n#ifndef SQLITE_DISABLE_SKIPAHEAD_DISTINCT\n      int addrSeek = 0;\n      Index *pIdx;\n      int n;\n      if( pWInfo->eDistinct==WHERE_DISTINCT_ORDERED\n       && i==pWInfo->nLevel-1  /* Ticket [ef9318757b152e3] 2017-10-21 */\n       && (pLoop->wsFlags & WHERE_INDEXED)!=0\n       && (pIdx = pLoop->u.btree.pIndex)->hasStat1\n       && (n = pLoop->u.btree.nIdxCol)>0\n       && pIdx->aiRowLogEst[n]>=36\n      ){\n        int r1 = pParse->nMem+1;\n        int j, op;\n        for(j=0; j<n; j++){\n          sqlite3VdbeAddOp3(v, OP_Column, pLevel->iIdxCur, j, r1+j);\n        }\n        pParse->nMem += n+1;\n        op = pLevel->op==OP_Prev ? OP_SeekLT : OP_SeekGT;\n        addrSeek = sqlite3VdbeAddOp4Int(v, op, pLevel->iIdxCur, 0, r1, n);\n        VdbeCoverageIf(v, op==OP_SeekLT);\n        VdbeCoverageIf(v, op==OP_SeekGT);\n        sqlite3VdbeAddOp2(v, OP_Goto, 1, pLevel->p2);\n      }\n#endif /* SQLITE_DISABLE_SKIPAHEAD_DISTINCT */\n      /* The common case: Advance to the next row */\n      sqlite3VdbeResolveLabel(v, pLevel->addrCont);\n      sqlite3VdbeAddOp3(v, pLevel->op, pLevel->p1, pLevel->p2, pLevel->p3);\n      sqlite3VdbeChangeP5(v, pLevel->p5);\n      VdbeCoverage(v);\n      VdbeCoverageIf(v, pLevel->op==OP_Next);\n      VdbeCoverageIf(v, pLevel->op==OP_Prev);\n      VdbeCoverageIf(v, pLevel->op==OP_VNext);\n#ifndef SQLITE_DISABLE_SKIPAHEAD_DISTINCT\n      if( addrSeek ) sqlite3VdbeJumpHere(v, addrSeek);\n#endif\n    }else{\n      sqlite3VdbeResolveLabel(v, pLevel->addrCont);\n    }\n    if( pLoop->wsFlags & WHERE_IN_ABLE && pLevel->u.in.nIn>0 ){\n      struct InLoop *pIn;\n      int j;\n      sqlite3VdbeResolveLabel(v, pLevel->addrNxt);\n      for(j=pLevel->u.in.nIn, pIn=&pLevel->u.in.aInLoop[j-1]; j>0; j--, pIn--){\n        sqlite3VdbeJumpHere(v, pIn->addrInTop+1);\n        if( pIn->eEndLoopOp!=OP_Noop ){\n          if( pIn->nPrefix ){\n            assert( pLoop->wsFlags & WHERE_IN_EARLYOUT );\n            sqlite3VdbeAddOp4Int(v, OP_IfNoHope, pLevel->iIdxCur,\n                              sqlite3VdbeCurrentAddr(v)+2,\n                              pIn->iBase, pIn->nPrefix);\n            VdbeCoverage(v);\n          }\n          sqlite3VdbeAddOp2(v, pIn->eEndLoopOp, pIn->iCur, pIn->addrInTop);\n          VdbeCoverage(v);\n          VdbeCoverageIf(v, pIn->eEndLoopOp==OP_Prev);\n          VdbeCoverageIf(v, pIn->eEndLoopOp==OP_Next);\n        }\n        sqlite3VdbeJumpHere(v, pIn->addrInTop-1);\n      }\n    }\n    sqlite3VdbeResolveLabel(v, pLevel->addrBrk);\n    if( pLevel->addrSkip ){\n      sqlite3VdbeGoto(v, pLevel->addrSkip);\n      VdbeComment((v, \"next skip-scan on %s\", pLoop->u.btree.pIndex->zName));\n      sqlite3VdbeJumpHere(v, pLevel->addrSkip);\n      sqlite3VdbeJumpHere(v, pLevel->addrSkip-2);\n    }\n#ifndef SQLITE_LIKE_DOESNT_MATCH_BLOBS\n    if( pLevel->addrLikeRep ){\n      sqlite3VdbeAddOp2(v, OP_DecrJumpZero, (int)(pLevel->iLikeRepCntr>>1),\n                        pLevel->addrLikeRep);\n      VdbeCoverage(v);\n    }\n#endif\n    if( pLevel->iLeftJoin ){\n      int ws = pLoop->wsFlags;\n      addr = sqlite3VdbeAddOp1(v, OP_IfPos, pLevel->iLeftJoin); VdbeCoverage(v);\n      assert( (ws & WHERE_IDX_ONLY)==0 || (ws & WHERE_INDEXED)!=0 );\n      if( (ws & WHERE_IDX_ONLY)==0 ){\n        assert( pLevel->iTabCur==pTabList->a[pLevel->iFrom].iCursor );\n        sqlite3VdbeAddOp1(v, OP_NullRow, pLevel->iTabCur);\n      }\n      if( (ws & WHERE_INDEXED) \n       || ((ws & WHERE_MULTI_OR) && pLevel->u.pCovidx) \n      ){\n        sqlite3VdbeAddOp1(v, OP_NullRow, pLevel->iIdxCur);\n      }\n      if( pLevel->op==OP_Return ){\n        sqlite3VdbeAddOp2(v, OP_Gosub, pLevel->p1, pLevel->addrFirst);\n      }else{\n        sqlite3VdbeGoto(v, pLevel->addrFirst);\n      }\n      sqlite3VdbeJumpHere(v, addr);\n    }\n    VdbeModuleComment((v, \"End WHERE-loop%d: %s\", i,\n                     pWInfo->pTabList->a[pLevel->iFrom].pTab->zName));\n  }\n\n  /* The \"break\" point is here, just past the end of the outer loop.\n  ** Set it.\n  */\n  sqlite3VdbeResolveLabel(v, pWInfo->iBreak);\n\n  assert( pWInfo->nLevel<=pTabList->nSrc );\n  for(i=0, pLevel=pWInfo->a; i<pWInfo->nLevel; i++, pLevel++){\n    int k, last;\n    VdbeOp *pOp;\n    Index *pIdx = 0;\n    struct SrcList_item *pTabItem = &pTabList->a[pLevel->iFrom];\n    Table *pTab = pTabItem->pTab;\n    assert( pTab!=0 );\n    pLoop = pLevel->pWLoop;\n\n    /* For a co-routine, change all OP_Column references to the table of\n    ** the co-routine into OP_Copy of result contained in a register.\n    ** OP_Rowid becomes OP_Null.\n    */\n    if( pTabItem->fg.viaCoroutine ){\n      testcase( pParse->db->mallocFailed );\n      translateColumnToCopy(pParse, pLevel->addrBody, pLevel->iTabCur,\n                            pTabItem->regResult, 0);\n      continue;\n    }\n\n#ifdef SQLITE_ENABLE_EARLY_CURSOR_CLOSE\n    /* Close all of the cursors that were opened by sqlite3WhereBegin.\n    ** Except, do not close cursors that will be reused by the OR optimization\n    ** (WHERE_OR_SUBCLAUSE).  And do not close the OP_OpenWrite cursors\n    ** created for the ONEPASS optimization.\n    */\n    if( (pTab->tabFlags & TF_Ephemeral)==0\n     && pTab->pSelect==0\n     && (pWInfo->wctrlFlags & WHERE_OR_SUBCLAUSE)==0\n    ){\n      int ws = pLoop->wsFlags;\n      if( pWInfo->eOnePass==ONEPASS_OFF && (ws & WHERE_IDX_ONLY)==0 ){\n        sqlite3VdbeAddOp1(v, OP_Close, pTabItem->iCursor);\n      }\n      if( (ws & WHERE_INDEXED)!=0\n       && (ws & (WHERE_IPK|WHERE_AUTO_INDEX))==0 \n       && pLevel->iIdxCur!=pWInfo->aiCurOnePass[1]\n      ){\n        sqlite3VdbeAddOp1(v, OP_Close, pLevel->iIdxCur);\n      }\n    }\n#endif\n\n    /* If this scan uses an index, make VDBE code substitutions to read data\n    ** from the index instead of from the table where possible.  In some cases\n    ** this optimization prevents the table from ever being read, which can\n    ** yield a significant performance boost.\n    ** \n    ** Calls to the code generator in between sqlite3WhereBegin and\n    ** sqlite3WhereEnd will have created code that references the table\n    ** directly.  This loop scans all that code looking for opcodes\n    ** that reference the table and converts them into opcodes that\n    ** reference the index.\n    */\n    if( pLoop->wsFlags & (WHERE_INDEXED|WHERE_IDX_ONLY) ){\n      pIdx = pLoop->u.btree.pIndex;\n    }else if( pLoop->wsFlags & WHERE_MULTI_OR ){\n      pIdx = pLevel->u.pCovidx;\n    }\n    if( pIdx\n     && (pWInfo->eOnePass==ONEPASS_OFF || !HasRowid(pIdx->pTable))\n     && !db->mallocFailed\n    ){\n      last = sqlite3VdbeCurrentAddr(v);\n      k = pLevel->addrBody;\n#ifdef SQLITE_DEBUG\n      if( db->flags & SQLITE_VdbeAddopTrace ){\n        printf(\"TRANSLATE opcodes in range %d..%d\\n\", k, last-1);\n      }\n#endif\n      pOp = sqlite3VdbeGetOp(v, k);\n      for(; k<last; k++, pOp++){\n        if( pOp->p1!=pLevel->iTabCur ) continue;\n        if( pOp->opcode==OP_Column\n#ifdef SQLITE_ENABLE_OFFSET_SQL_FUNC\n         || pOp->opcode==OP_Offset\n#endif\n        ){\n          int x = pOp->p2;\n          assert( pIdx->pTable==pTab );\n          if( !HasRowid(pTab) ){\n            Index *pPk = sqlite3PrimaryKeyIndex(pTab);\n            x = pPk->aiColumn[x];\n            assert( x>=0 );\n          }\n          x = sqlite3ColumnOfIndex(pIdx, x);\n          if( x>=0 ){\n            pOp->p2 = x;\n            pOp->p1 = pLevel->iIdxCur;\n            OpcodeRewriteTrace(db, k, pOp);\n          }\n          assert( (pLoop->wsFlags & WHERE_IDX_ONLY)==0 || x>=0 \n              || pWInfo->eOnePass );\n        }else if( pOp->opcode==OP_Rowid ){\n          pOp->p1 = pLevel->iIdxCur;\n          pOp->opcode = OP_IdxRowid;\n          OpcodeRewriteTrace(db, k, pOp);\n        }else if( pOp->opcode==OP_IfNullRow ){\n          pOp->p1 = pLevel->iIdxCur;\n          OpcodeRewriteTrace(db, k, pOp);\n        }\n      }\n#ifdef SQLITE_DEBUG\n      if( db->flags & SQLITE_VdbeAddopTrace ) printf(\"TRANSLATE complete\\n\");\n#endif\n    }\n  }\n\n  /* Final cleanup\n  */\n  pParse->nQueryLoop = pWInfo->savedNQueryLoop;\n  whereInfoFree(db, pWInfo);\n  return;\n}\n\n/************** End of where.c ***********************************************/\n/************** Begin file window.c ******************************************/\n/*\n** 2018 May 08\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n*/\n/* #include \"sqliteInt.h\" */\n\n#ifndef SQLITE_OMIT_WINDOWFUNC\n\n/*\n** SELECT REWRITING\n**\n**   Any SELECT statement that contains one or more window functions in\n**   either the select list or ORDER BY clause (the only two places window\n**   functions may be used) is transformed by function sqlite3WindowRewrite()\n**   in order to support window function processing. For example, with the\n**   schema:\n**\n**     CREATE TABLE t1(a, b, c, d, e, f, g);\n**\n**   the statement:\n**\n**     SELECT a+1, max(b) OVER (PARTITION BY c ORDER BY d) FROM t1 ORDER BY e;\n**\n**   is transformed to:\n**\n**     SELECT a+1, max(b) OVER (PARTITION BY c ORDER BY d) FROM (\n**         SELECT a, e, c, d, b FROM t1 ORDER BY c, d\n**     ) ORDER BY e;\n**\n**   The flattening optimization is disabled when processing this transformed\n**   SELECT statement. This allows the implementation of the window function\n**   (in this case max()) to process rows sorted in order of (c, d), which\n**   makes things easier for obvious reasons. More generally:\n**\n**     * FROM, WHERE, GROUP BY and HAVING clauses are all moved to \n**       the sub-query.\n**\n**     * ORDER BY, LIMIT and OFFSET remain part of the parent query.\n**\n**     * Terminals from each of the expression trees that make up the \n**       select-list and ORDER BY expressions in the parent query are\n**       selected by the sub-query. For the purposes of the transformation,\n**       terminals are column references and aggregate functions.\n**\n**   If there is more than one window function in the SELECT that uses\n**   the same window declaration (the OVER bit), then a single scan may\n**   be used to process more than one window function. For example:\n**\n**     SELECT max(b) OVER (PARTITION BY c ORDER BY d), \n**            min(e) OVER (PARTITION BY c ORDER BY d) \n**     FROM t1;\n**\n**   is transformed in the same way as the example above. However:\n**\n**     SELECT max(b) OVER (PARTITION BY c ORDER BY d), \n**            min(e) OVER (PARTITION BY a ORDER BY b) \n**     FROM t1;\n**\n**   Must be transformed to:\n**\n**     SELECT max(b) OVER (PARTITION BY c ORDER BY d) FROM (\n**         SELECT e, min(e) OVER (PARTITION BY a ORDER BY b), c, d, b FROM\n**           SELECT a, e, c, d, b FROM t1 ORDER BY a, b\n**         ) ORDER BY c, d\n**     ) ORDER BY e;\n**\n**   so that both min() and max() may process rows in the order defined by\n**   their respective window declarations.\n**\n** INTERFACE WITH SELECT.C\n**\n**   When processing the rewritten SELECT statement, code in select.c calls\n**   sqlite3WhereBegin() to begin iterating through the results of the\n**   sub-query, which is always implemented as a co-routine. It then calls\n**   sqlite3WindowCodeStep() to process rows and finish the scan by calling\n**   sqlite3WhereEnd().\n**\n**   sqlite3WindowCodeStep() generates VM code so that, for each row returned\n**   by the sub-query a sub-routine (OP_Gosub) coded by select.c is invoked.\n**   When the sub-routine is invoked:\n**\n**     * The results of all window-functions for the row are stored\n**       in the associated Window.regResult registers.\n**\n**     * The required terminal values are stored in the current row of\n**       temp table Window.iEphCsr.\n**\n**   In some cases, depending on the window frame and the specific window\n**   functions invoked, sqlite3WindowCodeStep() caches each entire partition\n**   in a temp table before returning any rows. In other cases it does not.\n**   This detail is encapsulated within this file, the code generated by\n**   select.c is the same in either case.\n**\n** BUILT-IN WINDOW FUNCTIONS\n**\n**   This implementation features the following built-in window functions:\n**\n**     row_number()\n**     rank()\n**     dense_rank()\n**     percent_rank()\n**     cume_dist()\n**     ntile(N)\n**     lead(expr [, offset [, default]])\n**     lag(expr [, offset [, default]])\n**     first_value(expr)\n**     last_value(expr)\n**     nth_value(expr, N)\n**   \n**   These are the same built-in window functions supported by Postgres. \n**   Although the behaviour of aggregate window functions (functions that\n**   can be used as either aggregates or window funtions) allows them to\n**   be implemented using an API, built-in window functions are much more\n**   esoteric. Additionally, some window functions (e.g. nth_value()) \n**   may only be implemented by caching the entire partition in memory.\n**   As such, some built-in window functions use the same API as aggregate\n**   window functions and some are implemented directly using VDBE \n**   instructions. Additionally, for those functions that use the API, the\n**   window frame is sometimes modified before the SELECT statement is\n**   rewritten. For example, regardless of the specified window frame, the\n**   row_number() function always uses:\n**\n**     ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW\n**\n**   See sqlite3WindowUpdate() for details.\n**\n**   As well as some of the built-in window functions, aggregate window\n**   functions min() and max() are implemented using VDBE instructions if\n**   the start of the window frame is declared as anything other than \n**   UNBOUNDED PRECEDING.\n*/\n\n/*\n** Implementation of built-in window function row_number(). Assumes that the\n** window frame has been coerced to:\n**\n**   ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW\n*/\nstatic void row_numberStepFunc(\n  sqlite3_context *pCtx, \n  int nArg,\n  sqlite3_value **apArg\n){\n  i64 *p = (i64*)sqlite3_aggregate_context(pCtx, sizeof(*p));\n  if( p ) (*p)++;\n  UNUSED_PARAMETER(nArg);\n  UNUSED_PARAMETER(apArg);\n}\nstatic void row_numberValueFunc(sqlite3_context *pCtx){\n  i64 *p = (i64*)sqlite3_aggregate_context(pCtx, sizeof(*p));\n  sqlite3_result_int64(pCtx, (p ? *p : 0));\n}\n\n/*\n** Context object type used by rank(), dense_rank(), percent_rank() and\n** cume_dist().\n*/\nstruct CallCount {\n  i64 nValue;\n  i64 nStep;\n  i64 nTotal;\n};\n\n/*\n** Implementation of built-in window function dense_rank(). Assumes that\n** the window frame has been set to:\n**\n**   RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW \n*/\nstatic void dense_rankStepFunc(\n  sqlite3_context *pCtx, \n  int nArg,\n  sqlite3_value **apArg\n){\n  struct CallCount *p;\n  p = (struct CallCount*)sqlite3_aggregate_context(pCtx, sizeof(*p));\n  if( p ) p->nStep = 1;\n  UNUSED_PARAMETER(nArg);\n  UNUSED_PARAMETER(apArg);\n}\nstatic void dense_rankValueFunc(sqlite3_context *pCtx){\n  struct CallCount *p;\n  p = (struct CallCount*)sqlite3_aggregate_context(pCtx, sizeof(*p));\n  if( p ){\n    if( p->nStep ){\n      p->nValue++;\n      p->nStep = 0;\n    }\n    sqlite3_result_int64(pCtx, p->nValue);\n  }\n}\n\n/*\n** Implementation of built-in window function rank(). Assumes that\n** the window frame has been set to:\n**\n**   RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW \n*/\nstatic void rankStepFunc(\n  sqlite3_context *pCtx, \n  int nArg,\n  sqlite3_value **apArg\n){\n  struct CallCount *p;\n  p = (struct CallCount*)sqlite3_aggregate_context(pCtx, sizeof(*p));\n  if( p ){\n    p->nStep++;\n    if( p->nValue==0 ){\n      p->nValue = p->nStep;\n    }\n  }\n  UNUSED_PARAMETER(nArg);\n  UNUSED_PARAMETER(apArg);\n}\nstatic void rankValueFunc(sqlite3_context *pCtx){\n  struct CallCount *p;\n  p = (struct CallCount*)sqlite3_aggregate_context(pCtx, sizeof(*p));\n  if( p ){\n    sqlite3_result_int64(pCtx, p->nValue);\n    p->nValue = 0;\n  }\n}\n\n/*\n** Implementation of built-in window function percent_rank(). Assumes that\n** the window frame has been set to:\n**\n**   RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW \n*/\nstatic void percent_rankStepFunc(\n  sqlite3_context *pCtx, \n  int nArg,\n  sqlite3_value **apArg\n){\n  struct CallCount *p;\n  UNUSED_PARAMETER(nArg); assert( nArg==1 );\n\n  p = (struct CallCount*)sqlite3_aggregate_context(pCtx, sizeof(*p));\n  if( p ){\n    if( p->nTotal==0 ){\n      p->nTotal = sqlite3_value_int64(apArg[0]);\n    }\n    p->nStep++;\n    if( p->nValue==0 ){\n      p->nValue = p->nStep;\n    }\n  }\n}\nstatic void percent_rankValueFunc(sqlite3_context *pCtx){\n  struct CallCount *p;\n  p = (struct CallCount*)sqlite3_aggregate_context(pCtx, sizeof(*p));\n  if( p ){\n    if( p->nTotal>1 ){\n      double r = (double)(p->nValue-1) / (double)(p->nTotal-1);\n      sqlite3_result_double(pCtx, r);\n    }else{\n      sqlite3_result_double(pCtx, 0.0);\n    }\n    p->nValue = 0;\n  }\n}\n\n/*\n** Implementation of built-in window function cume_dist(). Assumes that\n** the window frame has been set to:\n**\n**   RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW \n*/\nstatic void cume_distStepFunc(\n  sqlite3_context *pCtx, \n  int nArg,\n  sqlite3_value **apArg\n){\n  struct CallCount *p;\n  assert( nArg==1 ); UNUSED_PARAMETER(nArg);\n\n  p = (struct CallCount*)sqlite3_aggregate_context(pCtx, sizeof(*p));\n  if( p ){\n    if( p->nTotal==0 ){\n      p->nTotal = sqlite3_value_int64(apArg[0]);\n    }\n    p->nStep++;\n  }\n}\nstatic void cume_distValueFunc(sqlite3_context *pCtx){\n  struct CallCount *p;\n  p = (struct CallCount*)sqlite3_aggregate_context(pCtx, sizeof(*p));\n  if( p && p->nTotal ){\n    double r = (double)(p->nStep) / (double)(p->nTotal);\n    sqlite3_result_double(pCtx, r);\n  }\n}\n\n/*\n** Context object for ntile() window function.\n*/\nstruct NtileCtx {\n  i64 nTotal;                     /* Total rows in partition */\n  i64 nParam;                     /* Parameter passed to ntile(N) */\n  i64 iRow;                       /* Current row */\n};\n\n/*\n** Implementation of ntile(). This assumes that the window frame has\n** been coerced to:\n**\n**   ROWS UNBOUNDED PRECEDING AND CURRENT ROW\n*/\nstatic void ntileStepFunc(\n  sqlite3_context *pCtx, \n  int nArg,\n  sqlite3_value **apArg\n){\n  struct NtileCtx *p;\n  assert( nArg==2 ); UNUSED_PARAMETER(nArg);\n  p = (struct NtileCtx*)sqlite3_aggregate_context(pCtx, sizeof(*p));\n  if( p ){\n    if( p->nTotal==0 ){\n      p->nParam = sqlite3_value_int64(apArg[0]);\n      p->nTotal = sqlite3_value_int64(apArg[1]);\n      if( p->nParam<=0 ){\n        sqlite3_result_error(\n            pCtx, \"argument of ntile must be a positive integer\", -1\n        );\n      }\n    }\n    p->iRow++;\n  }\n}\nstatic void ntileValueFunc(sqlite3_context *pCtx){\n  struct NtileCtx *p;\n  p = (struct NtileCtx*)sqlite3_aggregate_context(pCtx, sizeof(*p));\n  if( p && p->nParam>0 ){\n    int nSize = (p->nTotal / p->nParam);\n    if( nSize==0 ){\n      sqlite3_result_int64(pCtx, p->iRow);\n    }else{\n      i64 nLarge = p->nTotal - p->nParam*nSize;\n      i64 iSmall = nLarge*(nSize+1);\n      i64 iRow = p->iRow-1;\n\n      assert( (nLarge*(nSize+1) + (p->nParam-nLarge)*nSize)==p->nTotal );\n\n      if( iRow<iSmall ){\n        sqlite3_result_int64(pCtx, 1 + iRow/(nSize+1));\n      }else{\n        sqlite3_result_int64(pCtx, 1 + nLarge + (iRow-iSmall)/nSize);\n      }\n    }\n  }\n}\n\n/*\n** Context object for last_value() window function.\n*/\nstruct LastValueCtx {\n  sqlite3_value *pVal;\n  int nVal;\n};\n\n/*\n** Implementation of last_value().\n*/\nstatic void last_valueStepFunc(\n  sqlite3_context *pCtx, \n  int nArg,\n  sqlite3_value **apArg\n){\n  struct LastValueCtx *p;\n  UNUSED_PARAMETER(nArg);\n  p = (struct LastValueCtx*)sqlite3_aggregate_context(pCtx, sizeof(*p));\n  if( p ){\n    sqlite3_value_free(p->pVal);\n    p->pVal = sqlite3_value_dup(apArg[0]);\n    if( p->pVal==0 ){\n      sqlite3_result_error_nomem(pCtx);\n    }else{\n      p->nVal++;\n    }\n  }\n}\nstatic void last_valueInvFunc(\n  sqlite3_context *pCtx, \n  int nArg,\n  sqlite3_value **apArg\n){\n  struct LastValueCtx *p;\n  UNUSED_PARAMETER(nArg);\n  UNUSED_PARAMETER(apArg);\n  p = (struct LastValueCtx*)sqlite3_aggregate_context(pCtx, sizeof(*p));\n  if( ALWAYS(p) ){\n    p->nVal--;\n    if( p->nVal==0 ){\n      sqlite3_value_free(p->pVal);\n      p->pVal = 0;\n    }\n  }\n}\nstatic void last_valueValueFunc(sqlite3_context *pCtx){\n  struct LastValueCtx *p;\n  p = (struct LastValueCtx*)sqlite3_aggregate_context(pCtx, sizeof(*p));\n  if( p && p->pVal ){\n    sqlite3_result_value(pCtx, p->pVal);\n  }\n}\nstatic void last_valueFinalizeFunc(sqlite3_context *pCtx){\n  struct LastValueCtx *p;\n  p = (struct LastValueCtx*)sqlite3_aggregate_context(pCtx, sizeof(*p));\n  if( p && p->pVal ){\n    sqlite3_result_value(pCtx, p->pVal);\n    sqlite3_value_free(p->pVal);\n    p->pVal = 0;\n  }\n}\n\n/*\n** Static names for the built-in window function names.  These static\n** names are used, rather than string literals, so that FuncDef objects\n** can be associated with a particular window function by direct\n** comparison of the zName pointer.  Example:\n**\n**       if( pFuncDef->zName==row_valueName ){ ... }\n*/\nstatic const char row_numberName[] =   \"row_number\";\nstatic const char dense_rankName[] =   \"dense_rank\";\nstatic const char rankName[] =         \"rank\";\nstatic const char percent_rankName[] = \"percent_rank\";\nstatic const char cume_distName[] =    \"cume_dist\";\nstatic const char ntileName[] =        \"ntile\";\nstatic const char last_valueName[] =   \"last_value\";\nstatic const char nth_valueName[] =    \"nth_value\";\nstatic const char first_valueName[] =  \"first_value\";\nstatic const char leadName[] =         \"lead\";\nstatic const char lagName[] =          \"lag\";\n\n/*\n** No-op implementations of xStep() and xFinalize().  Used as place-holders\n** for built-in window functions that never call those interfaces.\n**\n** The noopValueFunc() is called but is expected to do nothing.  The\n** noopStepFunc() is never called, and so it is marked with NO_TEST to\n** let the test coverage routine know not to expect this function to be\n** invoked.\n*/\nstatic void noopStepFunc(    /*NO_TEST*/\n  sqlite3_context *p,        /*NO_TEST*/\n  int n,                     /*NO_TEST*/\n  sqlite3_value **a          /*NO_TEST*/\n){                           /*NO_TEST*/\n  UNUSED_PARAMETER(p);       /*NO_TEST*/\n  UNUSED_PARAMETER(n);       /*NO_TEST*/\n  UNUSED_PARAMETER(a);       /*NO_TEST*/\n  assert(0);                 /*NO_TEST*/\n}                            /*NO_TEST*/\nstatic void noopValueFunc(sqlite3_context *p){ UNUSED_PARAMETER(p); /*no-op*/ }\n\n/* Window functions that use all window interfaces: xStep, xFinal,\n** xValue, and xInverse */\n#define WINDOWFUNCALL(name,nArg,extra) {                                   \\\n  nArg, (SQLITE_UTF8|SQLITE_FUNC_WINDOW|extra), 0, 0,                      \\\n  name ## StepFunc, name ## FinalizeFunc, name ## ValueFunc,               \\\n  name ## InvFunc, name ## Name, {0}                                       \\\n}\n\n/* Window functions that are implemented using bytecode and thus have\n** no-op routines for their methods */\n#define WINDOWFUNCNOOP(name,nArg,extra) {                                  \\\n  nArg, (SQLITE_UTF8|SQLITE_FUNC_WINDOW|extra), 0, 0,                      \\\n  noopStepFunc, noopValueFunc, noopValueFunc,                              \\\n  noopStepFunc, name ## Name, {0}                                          \\\n}\n\n/* Window functions that use all window interfaces: xStep, the\n** same routine for xFinalize and xValue and which never call\n** xInverse. */\n#define WINDOWFUNCX(name,nArg,extra) {                                     \\\n  nArg, (SQLITE_UTF8|SQLITE_FUNC_WINDOW|extra), 0, 0,                      \\\n  name ## StepFunc, name ## ValueFunc, name ## ValueFunc,                  \\\n  noopStepFunc, name ## Name, {0}                                          \\\n}\n\n\n/*\n** Register those built-in window functions that are not also aggregates.\n*/\nSQLITE_PRIVATE void sqlite3WindowFunctions(void){\n  static FuncDef aWindowFuncs[] = {\n    WINDOWFUNCX(row_number, 0, 0),\n    WINDOWFUNCX(dense_rank, 0, 0),\n    WINDOWFUNCX(rank, 0, 0),\n    WINDOWFUNCX(percent_rank, 0, SQLITE_FUNC_WINDOW_SIZE),\n    WINDOWFUNCX(cume_dist, 0, SQLITE_FUNC_WINDOW_SIZE),\n    WINDOWFUNCX(ntile, 1, SQLITE_FUNC_WINDOW_SIZE),\n    WINDOWFUNCALL(last_value, 1, 0),\n    WINDOWFUNCNOOP(nth_value, 2, 0),\n    WINDOWFUNCNOOP(first_value, 1, 0),\n    WINDOWFUNCNOOP(lead, 1, 0),\n    WINDOWFUNCNOOP(lead, 2, 0),\n    WINDOWFUNCNOOP(lead, 3, 0),\n    WINDOWFUNCNOOP(lag, 1, 0),\n    WINDOWFUNCNOOP(lag, 2, 0),\n    WINDOWFUNCNOOP(lag, 3, 0),\n  };\n  sqlite3InsertBuiltinFuncs(aWindowFuncs, ArraySize(aWindowFuncs));\n}\n\n/*\n** This function is called immediately after resolving the function name\n** for a window function within a SELECT statement. Argument pList is a\n** linked list of WINDOW definitions for the current SELECT statement.\n** Argument pFunc is the function definition just resolved and pWin\n** is the Window object representing the associated OVER clause. This\n** function updates the contents of pWin as follows:\n**\n**   * If the OVER clause refered to a named window (as in \"max(x) OVER win\"),\n**     search list pList for a matching WINDOW definition, and update pWin\n**     accordingly. If no such WINDOW clause can be found, leave an error\n**     in pParse.\n**\n**   * If the function is a built-in window function that requires the\n**     window to be coerced (see \"BUILT-IN WINDOW FUNCTIONS\" at the top\n**     of this file), pWin is updated here.\n*/\nSQLITE_PRIVATE void sqlite3WindowUpdate(\n  Parse *pParse, \n  Window *pList,                  /* List of named windows for this SELECT */\n  Window *pWin,                   /* Window frame to update */\n  FuncDef *pFunc                  /* Window function definition */\n){\n  if( pWin->zName && pWin->eType==0 ){\n    Window *p;\n    for(p=pList; p; p=p->pNextWin){\n      if( sqlite3StrICmp(p->zName, pWin->zName)==0 ) break;\n    }\n    if( p==0 ){\n      sqlite3ErrorMsg(pParse, \"no such window: %s\", pWin->zName);\n      return;\n    }\n    pWin->pPartition = sqlite3ExprListDup(pParse->db, p->pPartition, 0);\n    pWin->pOrderBy = sqlite3ExprListDup(pParse->db, p->pOrderBy, 0);\n    pWin->pStart = sqlite3ExprDup(pParse->db, p->pStart, 0);\n    pWin->pEnd = sqlite3ExprDup(pParse->db, p->pEnd, 0);\n    pWin->eStart = p->eStart;\n    pWin->eEnd = p->eEnd;\n    pWin->eType = p->eType;\n  }\n  if( pFunc->funcFlags & SQLITE_FUNC_WINDOW ){\n    sqlite3 *db = pParse->db;\n    if( pWin->pFilter ){\n      sqlite3ErrorMsg(pParse, \n          \"FILTER clause may only be used with aggregate window functions\"\n      );\n    }else\n    if( pFunc->zName==row_numberName || pFunc->zName==ntileName ){\n      sqlite3ExprDelete(db, pWin->pStart);\n      sqlite3ExprDelete(db, pWin->pEnd);\n      pWin->pStart = pWin->pEnd = 0;\n      pWin->eType = TK_ROWS;\n      pWin->eStart = TK_UNBOUNDED;\n      pWin->eEnd = TK_CURRENT;\n    }else\n\n    if( pFunc->zName==dense_rankName || pFunc->zName==rankName\n     || pFunc->zName==percent_rankName || pFunc->zName==cume_distName\n    ){\n      sqlite3ExprDelete(db, pWin->pStart);\n      sqlite3ExprDelete(db, pWin->pEnd);\n      pWin->pStart = pWin->pEnd = 0;\n      pWin->eType = TK_RANGE;\n      pWin->eStart = TK_UNBOUNDED;\n      pWin->eEnd = TK_CURRENT;\n    }\n  }\n  pWin->pFunc = pFunc;\n}\n\n/*\n** Context object passed through sqlite3WalkExprList() to\n** selectWindowRewriteExprCb() by selectWindowRewriteEList().\n*/\ntypedef struct WindowRewrite WindowRewrite;\nstruct WindowRewrite {\n  Window *pWin;\n  SrcList *pSrc;\n  ExprList *pSub;\n  Select *pSubSelect;             /* Current sub-select, if any */\n};\n\n/*\n** Callback function used by selectWindowRewriteEList(). If necessary,\n** this function appends to the output expression-list and updates \n** expression (*ppExpr) in place.\n*/\nstatic int selectWindowRewriteExprCb(Walker *pWalker, Expr *pExpr){\n  struct WindowRewrite *p = pWalker->u.pRewrite;\n  Parse *pParse = pWalker->pParse;\n\n  /* If this function is being called from within a scalar sub-select\n  ** that used by the SELECT statement being processed, only process\n  ** TK_COLUMN expressions that refer to it (the outer SELECT). Do\n  ** not process aggregates or window functions at all, as they belong\n  ** to the scalar sub-select.  */\n  if( p->pSubSelect ){\n    if( pExpr->op!=TK_COLUMN ){\n      return WRC_Continue;\n    }else{\n      int nSrc = p->pSrc->nSrc;\n      int i;\n      for(i=0; i<nSrc; i++){\n        if( pExpr->iTable==p->pSrc->a[i].iCursor ) break;\n      }\n      if( i==nSrc ) return WRC_Continue;\n    }\n  }\n\n  switch( pExpr->op ){\n\n    case TK_FUNCTION:\n      if( !ExprHasProperty(pExpr, EP_WinFunc) ){\n        break;\n      }else{\n        Window *pWin;\n        for(pWin=p->pWin; pWin; pWin=pWin->pNextWin){\n          if( pExpr->y.pWin==pWin ){\n            assert( pWin->pOwner==pExpr );\n            return WRC_Prune;\n          }\n        }\n      }\n      /* Fall through.  */\n\n    case TK_AGG_FUNCTION:\n    case TK_COLUMN: {\n      Expr *pDup = sqlite3ExprDup(pParse->db, pExpr, 0);\n      p->pSub = sqlite3ExprListAppend(pParse, p->pSub, pDup);\n      if( p->pSub ){\n        assert( ExprHasProperty(pExpr, EP_Static)==0 );\n        ExprSetProperty(pExpr, EP_Static);\n        sqlite3ExprDelete(pParse->db, pExpr);\n        ExprClearProperty(pExpr, EP_Static);\n        memset(pExpr, 0, sizeof(Expr));\n\n        pExpr->op = TK_COLUMN;\n        pExpr->iColumn = p->pSub->nExpr-1;\n        pExpr->iTable = p->pWin->iEphCsr;\n      }\n\n      break;\n    }\n\n    default: /* no-op */\n      break;\n  }\n\n  return WRC_Continue;\n}\nstatic int selectWindowRewriteSelectCb(Walker *pWalker, Select *pSelect){\n  struct WindowRewrite *p = pWalker->u.pRewrite;\n  Select *pSave = p->pSubSelect;\n  if( pSave==pSelect ){\n    return WRC_Continue;\n  }else{\n    p->pSubSelect = pSelect;\n    sqlite3WalkSelect(pWalker, pSelect);\n    p->pSubSelect = pSave;\n  }\n  return WRC_Prune;\n}\n\n\n/*\n** Iterate through each expression in expression-list pEList. For each:\n**\n**   * TK_COLUMN,\n**   * aggregate function, or\n**   * window function with a Window object that is not a member of the \n**     Window list passed as the second argument (pWin).\n**\n** Append the node to output expression-list (*ppSub). And replace it\n** with a TK_COLUMN that reads the (N-1)th element of table \n** pWin->iEphCsr, where N is the number of elements in (*ppSub) after\n** appending the new one.\n*/\nstatic void selectWindowRewriteEList(\n  Parse *pParse, \n  Window *pWin,\n  SrcList *pSrc,\n  ExprList *pEList,               /* Rewrite expressions in this list */\n  ExprList **ppSub                /* IN/OUT: Sub-select expression-list */\n){\n  Walker sWalker;\n  WindowRewrite sRewrite;\n\n  memset(&sWalker, 0, sizeof(Walker));\n  memset(&sRewrite, 0, sizeof(WindowRewrite));\n\n  sRewrite.pSub = *ppSub;\n  sRewrite.pWin = pWin;\n  sRewrite.pSrc = pSrc;\n\n  sWalker.pParse = pParse;\n  sWalker.xExprCallback = selectWindowRewriteExprCb;\n  sWalker.xSelectCallback = selectWindowRewriteSelectCb;\n  sWalker.u.pRewrite = &sRewrite;\n\n  (void)sqlite3WalkExprList(&sWalker, pEList);\n\n  *ppSub = sRewrite.pSub;\n}\n\n/*\n** Append a copy of each expression in expression-list pAppend to\n** expression list pList. Return a pointer to the result list.\n*/\nstatic ExprList *exprListAppendList(\n  Parse *pParse,          /* Parsing context */\n  ExprList *pList,        /* List to which to append. Might be NULL */\n  ExprList *pAppend       /* List of values to append. Might be NULL */\n){\n  if( pAppend ){\n    int i;\n    int nInit = pList ? pList->nExpr : 0;\n    for(i=0; i<pAppend->nExpr; i++){\n      Expr *pDup = sqlite3ExprDup(pParse->db, pAppend->a[i].pExpr, 0);\n      pList = sqlite3ExprListAppend(pParse, pList, pDup);\n      if( pList ) pList->a[nInit+i].sortOrder = pAppend->a[i].sortOrder;\n    }\n  }\n  return pList;\n}\n\n/*\n** If the SELECT statement passed as the second argument does not invoke\n** any SQL window functions, this function is a no-op. Otherwise, it \n** rewrites the SELECT statement so that window function xStep functions\n** are invoked in the correct order as described under \"SELECT REWRITING\"\n** at the top of this file.\n*/\nSQLITE_PRIVATE int sqlite3WindowRewrite(Parse *pParse, Select *p){\n  int rc = SQLITE_OK;\n  if( p->pWin && p->pPrior==0 ){\n    Vdbe *v = sqlite3GetVdbe(pParse);\n    sqlite3 *db = pParse->db;\n    Select *pSub = 0;             /* The subquery */\n    SrcList *pSrc = p->pSrc;\n    Expr *pWhere = p->pWhere;\n    ExprList *pGroupBy = p->pGroupBy;\n    Expr *pHaving = p->pHaving;\n    ExprList *pSort = 0;\n\n    ExprList *pSublist = 0;       /* Expression list for sub-query */\n    Window *pMWin = p->pWin;      /* Master window object */\n    Window *pWin;                 /* Window object iterator */\n\n    p->pSrc = 0;\n    p->pWhere = 0;\n    p->pGroupBy = 0;\n    p->pHaving = 0;\n\n    /* Create the ORDER BY clause for the sub-select. This is the concatenation\n    ** of the window PARTITION and ORDER BY clauses. Then, if this makes it\n    ** redundant, remove the ORDER BY from the parent SELECT.  */\n    pSort = sqlite3ExprListDup(db, pMWin->pPartition, 0);\n    pSort = exprListAppendList(pParse, pSort, pMWin->pOrderBy);\n    if( pSort && p->pOrderBy ){\n      if( sqlite3ExprListCompare(pSort, p->pOrderBy, -1)==0 ){\n        sqlite3ExprListDelete(db, p->pOrderBy);\n        p->pOrderBy = 0;\n      }\n    }\n\n    /* Assign a cursor number for the ephemeral table used to buffer rows.\n    ** The OpenEphemeral instruction is coded later, after it is known how\n    ** many columns the table will have.  */\n    pMWin->iEphCsr = pParse->nTab++;\n\n    selectWindowRewriteEList(pParse, pMWin, pSrc, p->pEList, &pSublist);\n    selectWindowRewriteEList(pParse, pMWin, pSrc, p->pOrderBy, &pSublist);\n    pMWin->nBufferCol = (pSublist ? pSublist->nExpr : 0);\n\n    /* Append the PARTITION BY and ORDER BY expressions to the to the \n    ** sub-select expression list. They are required to figure out where \n    ** boundaries for partitions and sets of peer rows lie.  */\n    pSublist = exprListAppendList(pParse, pSublist, pMWin->pPartition);\n    pSublist = exprListAppendList(pParse, pSublist, pMWin->pOrderBy);\n\n    /* Append the arguments passed to each window function to the\n    ** sub-select expression list. Also allocate two registers for each\n    ** window function - one for the accumulator, another for interim\n    ** results.  */\n    for(pWin=pMWin; pWin; pWin=pWin->pNextWin){\n      pWin->iArgCol = (pSublist ? pSublist->nExpr : 0);\n      pSublist = exprListAppendList(pParse, pSublist, pWin->pOwner->x.pList);\n      if( pWin->pFilter ){\n        Expr *pFilter = sqlite3ExprDup(db, pWin->pFilter, 0);\n        pSublist = sqlite3ExprListAppend(pParse, pSublist, pFilter);\n      }\n      pWin->regAccum = ++pParse->nMem;\n      pWin->regResult = ++pParse->nMem;\n      sqlite3VdbeAddOp2(v, OP_Null, 0, pWin->regAccum);\n    }\n\n    /* If there is no ORDER BY or PARTITION BY clause, and the window\n    ** function accepts zero arguments, and there are no other columns\n    ** selected (e.g. \"SELECT row_number() OVER () FROM t1\"), it is possible\n    ** that pSublist is still NULL here. Add a constant expression here to \n    ** keep everything legal in this case. \n    */\n    if( pSublist==0 ){\n      pSublist = sqlite3ExprListAppend(pParse, 0, \n          sqlite3ExprAlloc(db, TK_INTEGER, &sqlite3IntTokens[0], 0)\n      );\n    }\n\n    pSub = sqlite3SelectNew(\n        pParse, pSublist, pSrc, pWhere, pGroupBy, pHaving, pSort, 0, 0\n    );\n    p->pSrc = sqlite3SrcListAppend(pParse, 0, 0, 0);\n    if( p->pSrc ){\n      p->pSrc->a[0].pSelect = pSub;\n      sqlite3SrcListAssignCursors(pParse, p->pSrc);\n      if( sqlite3ExpandSubquery(pParse, &p->pSrc->a[0]) ){\n        rc = SQLITE_NOMEM;\n      }else{\n        pSub->selFlags |= SF_Expanded;\n        p->selFlags &= ~SF_Aggregate;\n        sqlite3SelectPrep(pParse, pSub, 0);\n      }\n\n      sqlite3VdbeAddOp2(v, OP_OpenEphemeral, pMWin->iEphCsr, pSublist->nExpr);\n    }else{\n      sqlite3SelectDelete(db, pSub);\n    }\n    if( db->mallocFailed ) rc = SQLITE_NOMEM;\n  }\n\n  return rc;\n}\n\n/*\n** Free the Window object passed as the second argument.\n*/\nSQLITE_PRIVATE void sqlite3WindowDelete(sqlite3 *db, Window *p){\n  if( p ){\n    sqlite3ExprDelete(db, p->pFilter);\n    sqlite3ExprListDelete(db, p->pPartition);\n    sqlite3ExprListDelete(db, p->pOrderBy);\n    sqlite3ExprDelete(db, p->pEnd);\n    sqlite3ExprDelete(db, p->pStart);\n    sqlite3DbFree(db, p->zName);\n    sqlite3DbFree(db, p);\n  }\n}\n\n/*\n** Free the linked list of Window objects starting at the second argument.\n*/\nSQLITE_PRIVATE void sqlite3WindowListDelete(sqlite3 *db, Window *p){\n  while( p ){\n    Window *pNext = p->pNextWin;\n    sqlite3WindowDelete(db, p);\n    p = pNext;\n  }\n}\n\n/*\n** The argument expression is an PRECEDING or FOLLOWING offset.  The\n** value should be a non-negative integer.  If the value is not a\n** constant, change it to NULL.  The fact that it is then a non-negative\n** integer will be caught later.  But it is important not to leave\n** variable values in the expression tree.\n*/\nstatic Expr *sqlite3WindowOffsetExpr(Parse *pParse, Expr *pExpr){\n  if( 0==sqlite3ExprIsConstant(pExpr) ){\n    if( IN_RENAME_OBJECT ) sqlite3RenameExprUnmap(pParse, pExpr);\n    sqlite3ExprDelete(pParse->db, pExpr);\n    pExpr = sqlite3ExprAlloc(pParse->db, TK_NULL, 0, 0);\n  }\n  return pExpr;\n}\n\n/*\n** Allocate and return a new Window object describing a Window Definition.\n*/\nSQLITE_PRIVATE Window *sqlite3WindowAlloc(\n  Parse *pParse,    /* Parsing context */\n  int eType,        /* Frame type. TK_RANGE or TK_ROWS */\n  int eStart,       /* Start type: CURRENT, PRECEDING, FOLLOWING, UNBOUNDED */\n  Expr *pStart,     /* Start window size if TK_PRECEDING or FOLLOWING */\n  int eEnd,         /* End type: CURRENT, FOLLOWING, TK_UNBOUNDED, PRECEDING */\n  Expr *pEnd        /* End window size if TK_FOLLOWING or PRECEDING */\n){\n  Window *pWin = 0;\n\n  /* Parser assures the following: */\n  assert( eType==TK_RANGE || eType==TK_ROWS );\n  assert( eStart==TK_CURRENT || eStart==TK_PRECEDING\n           || eStart==TK_UNBOUNDED || eStart==TK_FOLLOWING );\n  assert( eEnd==TK_CURRENT || eEnd==TK_FOLLOWING\n           || eEnd==TK_UNBOUNDED || eEnd==TK_PRECEDING );\n  assert( (eStart==TK_PRECEDING || eStart==TK_FOLLOWING)==(pStart!=0) );\n  assert( (eEnd==TK_FOLLOWING || eEnd==TK_PRECEDING)==(pEnd!=0) );\n\n\n  /* If a frame is declared \"RANGE\" (not \"ROWS\"), then it may not use\n  ** either \"<expr> PRECEDING\" or \"<expr> FOLLOWING\".\n  */\n  if( eType==TK_RANGE && (pStart!=0 || pEnd!=0) ){\n    sqlite3ErrorMsg(pParse, \"RANGE must use only UNBOUNDED or CURRENT ROW\");\n    goto windowAllocErr;\n  }\n\n  /* Additionally, the\n  ** starting boundary type may not occur earlier in the following list than\n  ** the ending boundary type:\n  **\n  **   UNBOUNDED PRECEDING\n  **   <expr> PRECEDING\n  **   CURRENT ROW\n  **   <expr> FOLLOWING\n  **   UNBOUNDED FOLLOWING\n  **\n  ** The parser ensures that \"UNBOUNDED PRECEDING\" cannot be used as an ending\n  ** boundary, and than \"UNBOUNDED FOLLOWING\" cannot be used as a starting\n  ** frame boundary.\n  */\n  if( (eStart==TK_CURRENT && eEnd==TK_PRECEDING)\n   || (eStart==TK_FOLLOWING && (eEnd==TK_PRECEDING || eEnd==TK_CURRENT))\n  ){\n    sqlite3ErrorMsg(pParse, \"unsupported frame delimiter for ROWS\");\n    goto windowAllocErr;\n  }\n\n  pWin = (Window*)sqlite3DbMallocZero(pParse->db, sizeof(Window));\n  if( pWin==0 ) goto windowAllocErr;\n  pWin->eType = eType;\n  pWin->eStart = eStart;\n  pWin->eEnd = eEnd;\n  pWin->pEnd = sqlite3WindowOffsetExpr(pParse, pEnd);\n  pWin->pStart = sqlite3WindowOffsetExpr(pParse, pStart);\n  return pWin;\n\nwindowAllocErr:\n  sqlite3ExprDelete(pParse->db, pEnd);\n  sqlite3ExprDelete(pParse->db, pStart);\n  return 0;\n}\n\n/*\n** Attach window object pWin to expression p.\n*/\nSQLITE_PRIVATE void sqlite3WindowAttach(Parse *pParse, Expr *p, Window *pWin){\n  if( p ){\n    assert( p->op==TK_FUNCTION );\n    /* This routine is only called for the parser.  If pWin was not\n    ** allocated due to an OOM, then the parser would fail before ever\n    ** invoking this routine */\n    if( ALWAYS(pWin) ){\n      p->y.pWin = pWin;\n      ExprSetProperty(p, EP_WinFunc);\n      pWin->pOwner = p;\n      if( p->flags & EP_Distinct ){\n        sqlite3ErrorMsg(pParse,\n           \"DISTINCT is not supported for window functions\");\n      }\n    }\n  }else{\n    sqlite3WindowDelete(pParse->db, pWin);\n  }\n}\n\n/*\n** Return 0 if the two window objects are identical, or non-zero otherwise.\n** Identical window objects can be processed in a single scan.\n*/\nSQLITE_PRIVATE int sqlite3WindowCompare(Parse *pParse, Window *p1, Window *p2){\n  if( p1->eType!=p2->eType ) return 1;\n  if( p1->eStart!=p2->eStart ) return 1;\n  if( p1->eEnd!=p2->eEnd ) return 1;\n  if( sqlite3ExprCompare(pParse, p1->pStart, p2->pStart, -1) ) return 1;\n  if( sqlite3ExprCompare(pParse, p1->pEnd, p2->pEnd, -1) ) return 1;\n  if( sqlite3ExprListCompare(p1->pPartition, p2->pPartition, -1) ) return 1;\n  if( sqlite3ExprListCompare(p1->pOrderBy, p2->pOrderBy, -1) ) return 1;\n  return 0;\n}\n\n\n/*\n** This is called by code in select.c before it calls sqlite3WhereBegin()\n** to begin iterating through the sub-query results. It is used to allocate\n** and initialize registers and cursors used by sqlite3WindowCodeStep().\n*/\nSQLITE_PRIVATE void sqlite3WindowCodeInit(Parse *pParse, Window *pMWin){\n  Window *pWin;\n  Vdbe *v = sqlite3GetVdbe(pParse);\n  int nPart = (pMWin->pPartition ? pMWin->pPartition->nExpr : 0);\n  nPart += (pMWin->pOrderBy ? pMWin->pOrderBy->nExpr : 0);\n  if( nPart ){\n    pMWin->regPart = pParse->nMem+1;\n    pParse->nMem += nPart;\n    sqlite3VdbeAddOp3(v, OP_Null, 0, pMWin->regPart, pMWin->regPart+nPart-1);\n  }\n\n  for(pWin=pMWin; pWin; pWin=pWin->pNextWin){\n    FuncDef *p = pWin->pFunc;\n    if( (p->funcFlags & SQLITE_FUNC_MINMAX) && pWin->eStart!=TK_UNBOUNDED ){\n      /* The inline versions of min() and max() require a single ephemeral\n      ** table and 3 registers. The registers are used as follows:\n      **\n      **   regApp+0: slot to copy min()/max() argument to for MakeRecord\n      **   regApp+1: integer value used to ensure keys are unique\n      **   regApp+2: output of MakeRecord\n      */\n      ExprList *pList = pWin->pOwner->x.pList;\n      KeyInfo *pKeyInfo = sqlite3KeyInfoFromExprList(pParse, pList, 0, 0);\n      pWin->csrApp = pParse->nTab++;\n      pWin->regApp = pParse->nMem+1;\n      pParse->nMem += 3;\n      if( pKeyInfo && pWin->pFunc->zName[1]=='i' ){\n        assert( pKeyInfo->aSortOrder[0]==0 );\n        pKeyInfo->aSortOrder[0] = 1;\n      }\n      sqlite3VdbeAddOp2(v, OP_OpenEphemeral, pWin->csrApp, 2);\n      sqlite3VdbeAppendP4(v, pKeyInfo, P4_KEYINFO);\n      sqlite3VdbeAddOp2(v, OP_Integer, 0, pWin->regApp+1);\n    }\n    else if( p->zName==nth_valueName || p->zName==first_valueName ){\n      /* Allocate two registers at pWin->regApp. These will be used to\n      ** store the start and end index of the current frame.  */\n      assert( pMWin->iEphCsr );\n      pWin->regApp = pParse->nMem+1;\n      pWin->csrApp = pParse->nTab++;\n      pParse->nMem += 2;\n      sqlite3VdbeAddOp2(v, OP_OpenDup, pWin->csrApp, pMWin->iEphCsr);\n    }\n    else if( p->zName==leadName || p->zName==lagName ){\n      assert( pMWin->iEphCsr );\n      pWin->csrApp = pParse->nTab++;\n      sqlite3VdbeAddOp2(v, OP_OpenDup, pWin->csrApp, pMWin->iEphCsr);\n    }\n  }\n}\n\n/*\n** A \"PRECEDING <expr>\" (eCond==0) or \"FOLLOWING <expr>\" (eCond==1) or the\n** value of the second argument to nth_value() (eCond==2) has just been\n** evaluated and the result left in register reg. This function generates VM\n** code to check that the value is a non-negative integer and throws an\n** exception if it is not.\n*/\nstatic void windowCheckIntValue(Parse *pParse, int reg, int eCond){\n  static const char *azErr[] = {\n    \"frame starting offset must be a non-negative integer\",\n    \"frame ending offset must be a non-negative integer\",\n    \"second argument to nth_value must be a positive integer\"\n  };\n  static int aOp[] = { OP_Ge, OP_Ge, OP_Gt };\n  Vdbe *v = sqlite3GetVdbe(pParse);\n  int regZero = sqlite3GetTempReg(pParse);\n  assert( eCond==0 || eCond==1 || eCond==2 );\n  sqlite3VdbeAddOp2(v, OP_Integer, 0, regZero);\n  sqlite3VdbeAddOp2(v, OP_MustBeInt, reg, sqlite3VdbeCurrentAddr(v)+2);\n  VdbeCoverageIf(v, eCond==0);\n  VdbeCoverageIf(v, eCond==1);\n  VdbeCoverageIf(v, eCond==2);\n  sqlite3VdbeAddOp3(v, aOp[eCond], regZero, sqlite3VdbeCurrentAddr(v)+2, reg);\n  VdbeCoverageNeverNullIf(v, eCond==0);\n  VdbeCoverageNeverNullIf(v, eCond==1);\n  VdbeCoverageNeverNullIf(v, eCond==2);\n  sqlite3MayAbort(pParse);\n  sqlite3VdbeAddOp2(v, OP_Halt, SQLITE_ERROR, OE_Abort);\n  sqlite3VdbeAppendP4(v, (void*)azErr[eCond], P4_STATIC);\n  sqlite3ReleaseTempReg(pParse, regZero);\n}\n\n/*\n** Return the number of arguments passed to the window-function associated\n** with the object passed as the only argument to this function.\n*/\nstatic int windowArgCount(Window *pWin){\n  ExprList *pList = pWin->pOwner->x.pList;\n  return (pList ? pList->nExpr : 0);\n}\n\n/*\n** Generate VM code to invoke either xStep() (if bInverse is 0) or \n** xInverse (if bInverse is non-zero) for each window function in the \n** linked list starting at pMWin. Or, for built-in window functions\n** that do not use the standard function API, generate the required\n** inline VM code.\n**\n** If argument csr is greater than or equal to 0, then argument reg is\n** the first register in an array of registers guaranteed to be large\n** enough to hold the array of arguments for each function. In this case\n** the arguments are extracted from the current row of csr into the\n** array of registers before invoking OP_AggStep or OP_AggInverse\n**\n** Or, if csr is less than zero, then the array of registers at reg is\n** already populated with all columns from the current row of the sub-query.\n**\n** If argument regPartSize is non-zero, then it is a register containing the\n** number of rows in the current partition.\n*/\nstatic void windowAggStep(\n  Parse *pParse, \n  Window *pMWin,                  /* Linked list of window functions */\n  int csr,                        /* Read arguments from this cursor */\n  int bInverse,                   /* True to invoke xInverse instead of xStep */\n  int reg,                        /* Array of registers */\n  int regPartSize                 /* Register containing size of partition */\n){\n  Vdbe *v = sqlite3GetVdbe(pParse);\n  Window *pWin;\n  for(pWin=pMWin; pWin; pWin=pWin->pNextWin){\n    int flags = pWin->pFunc->funcFlags;\n    int regArg;\n    int nArg = windowArgCount(pWin);\n\n    if( csr>=0 ){\n      int i;\n      for(i=0; i<nArg; i++){\n        sqlite3VdbeAddOp3(v, OP_Column, csr, pWin->iArgCol+i, reg+i);\n      }\n      regArg = reg;\n      if( flags & SQLITE_FUNC_WINDOW_SIZE ){\n        if( nArg==0 ){\n          regArg = regPartSize;\n        }else{\n          sqlite3VdbeAddOp2(v, OP_SCopy, regPartSize, reg+nArg);\n        }\n        nArg++;\n      }\n    }else{\n      assert( !(flags & SQLITE_FUNC_WINDOW_SIZE) );\n      regArg = reg + pWin->iArgCol;\n    }\n\n    if( (pWin->pFunc->funcFlags & SQLITE_FUNC_MINMAX) \n      && pWin->eStart!=TK_UNBOUNDED \n    ){\n      int addrIsNull = sqlite3VdbeAddOp1(v, OP_IsNull, regArg);\n      VdbeCoverage(v);\n      if( bInverse==0 ){\n        sqlite3VdbeAddOp2(v, OP_AddImm, pWin->regApp+1, 1);\n        sqlite3VdbeAddOp2(v, OP_SCopy, regArg, pWin->regApp);\n        sqlite3VdbeAddOp3(v, OP_MakeRecord, pWin->regApp, 2, pWin->regApp+2);\n        sqlite3VdbeAddOp2(v, OP_IdxInsert, pWin->csrApp, pWin->regApp+2);\n      }else{\n        sqlite3VdbeAddOp4Int(v, OP_SeekGE, pWin->csrApp, 0, regArg, 1);\n        VdbeCoverageNeverTaken(v);\n        sqlite3VdbeAddOp1(v, OP_Delete, pWin->csrApp);\n        sqlite3VdbeJumpHere(v, sqlite3VdbeCurrentAddr(v)-2);\n      }\n      sqlite3VdbeJumpHere(v, addrIsNull);\n    }else if( pWin->regApp ){\n      assert( pWin->pFunc->zName==nth_valueName\n           || pWin->pFunc->zName==first_valueName\n      );\n      assert( bInverse==0 || bInverse==1 );\n      sqlite3VdbeAddOp2(v, OP_AddImm, pWin->regApp+1-bInverse, 1);\n    }else if( pWin->pFunc->zName==leadName\n           || pWin->pFunc->zName==lagName\n    ){\n      /* no-op */\n    }else{\n      int addrIf = 0;\n      if( pWin->pFilter ){\n        int regTmp;\n        assert( nArg==0 || nArg==pWin->pOwner->x.pList->nExpr );\n        assert( nArg || pWin->pOwner->x.pList==0 );\n        if( csr>0 ){\n          regTmp = sqlite3GetTempReg(pParse);\n          sqlite3VdbeAddOp3(v, OP_Column, csr, pWin->iArgCol+nArg,regTmp);\n        }else{\n          regTmp = regArg + nArg;\n        }\n        addrIf = sqlite3VdbeAddOp3(v, OP_IfNot, regTmp, 0, 1);\n        VdbeCoverage(v);\n        if( csr>0 ){\n          sqlite3ReleaseTempReg(pParse, regTmp);\n        }\n      }\n      if( pWin->pFunc->funcFlags & SQLITE_FUNC_NEEDCOLL ){\n        CollSeq *pColl;\n        assert( nArg>0 );\n        pColl = sqlite3ExprNNCollSeq(pParse, pWin->pOwner->x.pList->a[0].pExpr);\n        sqlite3VdbeAddOp4(v, OP_CollSeq, 0,0,0, (const char*)pColl, P4_COLLSEQ);\n      }\n      sqlite3VdbeAddOp3(v, bInverse? OP_AggInverse : OP_AggStep, \n                        bInverse, regArg, pWin->regAccum);\n      sqlite3VdbeAppendP4(v, pWin->pFunc, P4_FUNCDEF);\n      sqlite3VdbeChangeP5(v, (u8)nArg);\n      if( addrIf ) sqlite3VdbeJumpHere(v, addrIf);\n    }\n  }\n}\n\n/*\n** Generate VM code to invoke either xValue() (bFinal==0) or xFinalize()\n** (bFinal==1) for each window function in the linked list starting at\n** pMWin. Or, for built-in window-functions that do not use the standard\n** API, generate the equivalent VM code.\n*/\nstatic void windowAggFinal(Parse *pParse, Window *pMWin, int bFinal){\n  Vdbe *v = sqlite3GetVdbe(pParse);\n  Window *pWin;\n\n  for(pWin=pMWin; pWin; pWin=pWin->pNextWin){\n    if( (pWin->pFunc->funcFlags & SQLITE_FUNC_MINMAX) \n     && pWin->eStart!=TK_UNBOUNDED \n    ){\n      sqlite3VdbeAddOp2(v, OP_Null, 0, pWin->regResult);\n      sqlite3VdbeAddOp1(v, OP_Last, pWin->csrApp);\n      VdbeCoverage(v);\n      sqlite3VdbeAddOp3(v, OP_Column, pWin->csrApp, 0, pWin->regResult);\n      sqlite3VdbeJumpHere(v, sqlite3VdbeCurrentAddr(v)-2);\n      if( bFinal ){\n        sqlite3VdbeAddOp1(v, OP_ResetSorter, pWin->csrApp);\n      }\n    }else if( pWin->regApp ){\n    }else{\n      if( bFinal ){\n        sqlite3VdbeAddOp2(v, OP_AggFinal, pWin->regAccum, windowArgCount(pWin));\n        sqlite3VdbeAppendP4(v, pWin->pFunc, P4_FUNCDEF);\n        sqlite3VdbeAddOp2(v, OP_Copy, pWin->regAccum, pWin->regResult);\n        sqlite3VdbeAddOp2(v, OP_Null, 0, pWin->regAccum);\n      }else{\n        sqlite3VdbeAddOp3(v, OP_AggValue, pWin->regAccum, windowArgCount(pWin),\n                             pWin->regResult);\n        sqlite3VdbeAppendP4(v, pWin->pFunc, P4_FUNCDEF);\n      }\n    }\n  }\n}\n\n/*\n** This function generates VM code to invoke the sub-routine at address\n** lblFlushPart once for each partition with the entire partition cached in\n** the Window.iEphCsr temp table.\n*/\nstatic void windowPartitionCache(\n  Parse *pParse,\n  Select *p,                      /* The rewritten SELECT statement */\n  WhereInfo *pWInfo,              /* WhereInfo to call WhereEnd() on */\n  int regFlushPart,               /* Register to use with Gosub lblFlushPart */\n  int lblFlushPart,               /* Subroutine to Gosub to */\n  int *pRegSize                   /* OUT: Register containing partition size */\n){\n  Window *pMWin = p->pWin;\n  Vdbe *v = sqlite3GetVdbe(pParse);\n  int iSubCsr = p->pSrc->a[0].iCursor;\n  int nSub = p->pSrc->a[0].pTab->nCol;\n  int k;\n\n  int reg = pParse->nMem+1;\n  int regRecord = reg+nSub;\n  int regRowid = regRecord+1;\n\n  *pRegSize = regRowid;\n  pParse->nMem += nSub + 2;\n\n  /* Load the column values for the row returned by the sub-select\n  ** into an array of registers starting at reg. */\n  for(k=0; k<nSub; k++){\n    sqlite3VdbeAddOp3(v, OP_Column, iSubCsr, k, reg+k);\n  }\n  sqlite3VdbeAddOp3(v, OP_MakeRecord, reg, nSub, regRecord);\n\n  /* Check if this is the start of a new partition. If so, call the\n  ** flush_partition sub-routine.  */\n  if( pMWin->pPartition ){\n    int addr;\n    ExprList *pPart = pMWin->pPartition;\n    int nPart = pPart->nExpr;\n    int regNewPart = reg + pMWin->nBufferCol;\n    KeyInfo *pKeyInfo = sqlite3KeyInfoFromExprList(pParse, pPart, 0, 0);\n\n    addr = sqlite3VdbeAddOp3(v, OP_Compare, regNewPart, pMWin->regPart,nPart);\n    sqlite3VdbeAppendP4(v, (void*)pKeyInfo, P4_KEYINFO);\n    sqlite3VdbeAddOp3(v, OP_Jump, addr+2, addr+4, addr+2);\n    VdbeCoverageEqNe(v);\n    sqlite3VdbeAddOp3(v, OP_Copy, regNewPart, pMWin->regPart, nPart-1);\n    sqlite3VdbeAddOp2(v, OP_Gosub, regFlushPart, lblFlushPart);\n    VdbeComment((v, \"call flush_partition\"));\n  }\n\n  /* Buffer the current row in the ephemeral table. */\n  sqlite3VdbeAddOp2(v, OP_NewRowid, pMWin->iEphCsr, regRowid);\n  sqlite3VdbeAddOp3(v, OP_Insert, pMWin->iEphCsr, regRecord, regRowid);\n\n  /* End of the input loop */\n  sqlite3WhereEnd(pWInfo);\n\n  /* Invoke \"flush_partition\" to deal with the final (or only) partition */\n  sqlite3VdbeAddOp2(v, OP_Gosub, regFlushPart, lblFlushPart);\n  VdbeComment((v, \"call flush_partition\"));\n}\n\n/*\n** Invoke the sub-routine at regGosub (generated by code in select.c) to\n** return the current row of Window.iEphCsr. If all window functions are\n** aggregate window functions that use the standard API, a single\n** OP_Gosub instruction is all that this routine generates. Extra VM code\n** for per-row processing is only generated for the following built-in window\n** functions:\n**\n**   nth_value()\n**   first_value()\n**   lag()\n**   lead()\n*/\nstatic void windowReturnOneRow(\n  Parse *pParse,\n  Window *pMWin,\n  int regGosub,\n  int addrGosub\n){\n  Vdbe *v = sqlite3GetVdbe(pParse);\n  Window *pWin;\n  for(pWin=pMWin; pWin; pWin=pWin->pNextWin){\n    FuncDef *pFunc = pWin->pFunc;\n    if( pFunc->zName==nth_valueName\n     || pFunc->zName==first_valueName\n    ){\n      int csr = pWin->csrApp;\n      int lbl = sqlite3VdbeMakeLabel(pParse);\n      int tmpReg = sqlite3GetTempReg(pParse);\n      sqlite3VdbeAddOp2(v, OP_Null, 0, pWin->regResult);\n\n      if( pFunc->zName==nth_valueName ){\n        sqlite3VdbeAddOp3(v, OP_Column, pMWin->iEphCsr, pWin->iArgCol+1,tmpReg);\n        windowCheckIntValue(pParse, tmpReg, 2);\n      }else{\n        sqlite3VdbeAddOp2(v, OP_Integer, 1, tmpReg);\n      }\n      sqlite3VdbeAddOp3(v, OP_Add, tmpReg, pWin->regApp, tmpReg);\n      sqlite3VdbeAddOp3(v, OP_Gt, pWin->regApp+1, lbl, tmpReg);\n      VdbeCoverageNeverNull(v);\n      sqlite3VdbeAddOp3(v, OP_SeekRowid, csr, 0, tmpReg);\n      VdbeCoverageNeverTaken(v);\n      sqlite3VdbeAddOp3(v, OP_Column, csr, pWin->iArgCol, pWin->regResult);\n      sqlite3VdbeResolveLabel(v, lbl);\n      sqlite3ReleaseTempReg(pParse, tmpReg);\n    }\n    else if( pFunc->zName==leadName || pFunc->zName==lagName ){\n      int nArg = pWin->pOwner->x.pList->nExpr;\n      int iEph = pMWin->iEphCsr;\n      int csr = pWin->csrApp;\n      int lbl = sqlite3VdbeMakeLabel(pParse);\n      int tmpReg = sqlite3GetTempReg(pParse);\n\n      if( nArg<3 ){\n        sqlite3VdbeAddOp2(v, OP_Null, 0, pWin->regResult);\n      }else{\n        sqlite3VdbeAddOp3(v, OP_Column, iEph, pWin->iArgCol+2, pWin->regResult);\n      }\n      sqlite3VdbeAddOp2(v, OP_Rowid, iEph, tmpReg);\n      if( nArg<2 ){\n        int val = (pFunc->zName==leadName ? 1 : -1);\n        sqlite3VdbeAddOp2(v, OP_AddImm, tmpReg, val);\n      }else{\n        int op = (pFunc->zName==leadName ? OP_Add : OP_Subtract);\n        int tmpReg2 = sqlite3GetTempReg(pParse);\n        sqlite3VdbeAddOp3(v, OP_Column, iEph, pWin->iArgCol+1, tmpReg2);\n        sqlite3VdbeAddOp3(v, op, tmpReg2, tmpReg, tmpReg);\n        sqlite3ReleaseTempReg(pParse, tmpReg2);\n      }\n\n      sqlite3VdbeAddOp3(v, OP_SeekRowid, csr, lbl, tmpReg);\n      VdbeCoverage(v);\n      sqlite3VdbeAddOp3(v, OP_Column, csr, pWin->iArgCol, pWin->regResult);\n      sqlite3VdbeResolveLabel(v, lbl);\n      sqlite3ReleaseTempReg(pParse, tmpReg);\n    }\n  }\n  sqlite3VdbeAddOp2(v, OP_Gosub, regGosub, addrGosub);\n}\n\n/*\n** Invoke the code generated by windowReturnOneRow() and, optionally, the\n** xInverse() function for each window function, for one or more rows\n** from the Window.iEphCsr temp table. This routine generates VM code\n** similar to:\n**\n**   while( regCtr>0 ){\n**     regCtr--;\n**     windowReturnOneRow()\n**     if( bInverse ){\n**       AggInverse\n**     }\n**     Next (Window.iEphCsr)\n**   }\n*/\nstatic void windowReturnRows(\n  Parse *pParse,\n  Window *pMWin,                  /* List of window functions */\n  int regCtr,                     /* Register containing number of rows */\n  int regGosub,                   /* Register for Gosub addrGosub */\n  int addrGosub,                  /* Address of sub-routine for ReturnOneRow */\n  int regInvArg,                  /* Array of registers for xInverse args */\n  int regInvSize                  /* Register containing size of partition */\n){\n  int addr;\n  Vdbe *v = sqlite3GetVdbe(pParse);\n  windowAggFinal(pParse, pMWin, 0);\n  addr = sqlite3VdbeAddOp3(v, OP_IfPos, regCtr, sqlite3VdbeCurrentAddr(v)+2 ,1);\n  VdbeCoverage(v);\n  sqlite3VdbeAddOp2(v, OP_Goto, 0, 0);\n  windowReturnOneRow(pParse, pMWin, regGosub, addrGosub);\n  if( regInvArg ){\n    windowAggStep(pParse, pMWin, pMWin->iEphCsr, 1, regInvArg, regInvSize);\n  }\n  sqlite3VdbeAddOp2(v, OP_Next, pMWin->iEphCsr, addr);\n  VdbeCoverage(v);\n  sqlite3VdbeJumpHere(v, addr+1);   /* The OP_Goto */\n}\n\n/*\n** Generate code to set the accumulator register for each window function\n** in the linked list passed as the second argument to NULL. And perform\n** any equivalent initialization required by any built-in window functions\n** in the list.\n*/\nstatic int windowInitAccum(Parse *pParse, Window *pMWin){\n  Vdbe *v = sqlite3GetVdbe(pParse);\n  int regArg;\n  int nArg = 0;\n  Window *pWin;\n  for(pWin=pMWin; pWin; pWin=pWin->pNextWin){\n    FuncDef *pFunc = pWin->pFunc;\n    sqlite3VdbeAddOp2(v, OP_Null, 0, pWin->regAccum);\n    nArg = MAX(nArg, windowArgCount(pWin));\n    if( pFunc->zName==nth_valueName\n     || pFunc->zName==first_valueName\n    ){\n      sqlite3VdbeAddOp2(v, OP_Integer, 0, pWin->regApp);\n      sqlite3VdbeAddOp2(v, OP_Integer, 0, pWin->regApp+1);\n    }\n\n    if( (pFunc->funcFlags & SQLITE_FUNC_MINMAX) && pWin->csrApp ){\n      assert( pWin->eStart!=TK_UNBOUNDED );\n      sqlite3VdbeAddOp1(v, OP_ResetSorter, pWin->csrApp);\n      sqlite3VdbeAddOp2(v, OP_Integer, 0, pWin->regApp+1);\n    }\n  }\n  regArg = pParse->nMem+1;\n  pParse->nMem += nArg;\n  return regArg;\n}\n\n\n/*\n** This function does the work of sqlite3WindowCodeStep() for all \"ROWS\"\n** window frame types except for \"BETWEEN UNBOUNDED PRECEDING AND CURRENT\n** ROW\". Pseudo-code for each follows.\n**\n** ROWS BETWEEN <expr1> PRECEDING AND <expr2> FOLLOWING\n**\n**     ...\n**       if( new partition ){\n**         Gosub flush_partition\n**       }\n**       Insert (record in eph-table)\n**     sqlite3WhereEnd()\n**     Gosub flush_partition\n**  \n**   flush_partition:\n**     Once {\n**       OpenDup (iEphCsr -> csrStart)\n**       OpenDup (iEphCsr -> csrEnd)\n**     }\n**     regStart = <expr1>                // PRECEDING expression\n**     regEnd = <expr2>                  // FOLLOWING expression\n**     if( regStart<0 || regEnd<0 ){ error! }\n**     Rewind (csr,csrStart,csrEnd)      // if EOF goto flush_partition_done\n**       Next(csrEnd)                    // if EOF skip Aggstep\n**       Aggstep (csrEnd)\n**       if( (regEnd--)<=0 ){\n**         AggFinal (xValue)\n**         Gosub addrGosub\n**         Next(csr)                // if EOF goto flush_partition_done\n**         if( (regStart--)<=0 ){\n**           AggInverse (csrStart)\n**           Next(csrStart)\n**         }\n**       }\n**   flush_partition_done:\n**     ResetSorter (csr)\n**     Return\n**\n** ROWS BETWEEN <expr> PRECEDING    AND CURRENT ROW\n** ROWS BETWEEN CURRENT ROW         AND <expr> FOLLOWING\n** ROWS BETWEEN UNBOUNDED PRECEDING AND <expr> FOLLOWING\n**\n**   These are similar to the above. For \"CURRENT ROW\", intialize the\n**   register to 0. For \"UNBOUNDED PRECEDING\" to infinity.\n**\n** ROWS BETWEEN <expr> PRECEDING    AND UNBOUNDED FOLLOWING\n** ROWS BETWEEN CURRENT ROW         AND UNBOUNDED FOLLOWING\n**\n**     Rewind (csr,csrStart,csrEnd)    // if EOF goto flush_partition_done\n**     while( 1 ){\n**       Next(csrEnd)                  // Exit while(1) at EOF\n**       Aggstep (csrEnd)\n**     }\n**     while( 1 ){\n**       AggFinal (xValue)\n**       Gosub addrGosub\n**       Next(csr)                     // if EOF goto flush_partition_done\n**       if( (regStart--)<=0 ){\n**         AggInverse (csrStart)\n**         Next(csrStart)\n**       }\n**     }\n**\n**   For the \"CURRENT ROW AND UNBOUNDED FOLLOWING\" case, the final if() \n**   condition is always true (as if regStart were initialized to 0).\n**\n** RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING\n** \n**   This is the only RANGE case handled by this routine. It modifies the\n**   second while( 1 ) loop in \"ROWS BETWEEN CURRENT ... UNBOUNDED...\" to\n**   be:\n**\n**     while( 1 ){\n**       AggFinal (xValue)\n**       while( 1 ){\n**         regPeer++\n**         Gosub addrGosub\n**         Next(csr)                     // if EOF goto flush_partition_done\n**         if( new peer ) break;\n**       }\n**       while( (regPeer--)>0 ){\n**         AggInverse (csrStart)\n**         Next(csrStart)\n**       }\n**     }\n**\n** ROWS BETWEEN <expr> FOLLOWING    AND <expr> FOLLOWING\n**\n**   regEnd = regEnd - regStart\n**   Rewind (csr,csrStart,csrEnd)   // if EOF goto flush_partition_done\n**     Aggstep (csrEnd)\n**     Next(csrEnd)                 // if EOF fall-through\n**     if( (regEnd--)<=0 ){\n**       if( (regStart--)<=0 ){\n**         AggFinal (xValue)\n**         Gosub addrGosub\n**         Next(csr)              // if EOF goto flush_partition_done\n**       }\n**       AggInverse (csrStart)\n**       Next (csrStart)\n**     }\n**\n** ROWS BETWEEN <expr> PRECEDING    AND <expr> PRECEDING\n**\n**   Replace the bit after \"Rewind\" in the above with:\n**\n**     if( (regEnd--)<=0 ){\n**       AggStep (csrEnd)\n**       Next (csrEnd)\n**     }\n**     AggFinal (xValue)\n**     Gosub addrGosub\n**     Next(csr)                  // if EOF goto flush_partition_done\n**     if( (regStart--)<=0 ){\n**       AggInverse (csr2)\n**       Next (csr2)\n**     }\n**\n*/\nstatic void windowCodeRowExprStep(\n  Parse *pParse, \n  Select *p,\n  WhereInfo *pWInfo,\n  int regGosub, \n  int addrGosub\n){\n  Window *pMWin = p->pWin;\n  Vdbe *v = sqlite3GetVdbe(pParse);\n  int regFlushPart;               /* Register for \"Gosub flush_partition\" */\n  int lblFlushPart;               /* Label for \"Gosub flush_partition\" */\n  int lblFlushDone;               /* Label for \"Gosub flush_partition_done\" */\n\n  int regArg;\n  int addr;\n  int csrStart = pParse->nTab++;\n  int csrEnd = pParse->nTab++;\n  int regStart;                    /* Value of <expr> PRECEDING */\n  int regEnd;                      /* Value of <expr> FOLLOWING */\n  int addrGoto;\n  int addrTop;\n  int addrIfPos1 = 0;\n  int addrIfPos2 = 0;\n  int regSize = 0;\n\n  assert( pMWin->eStart==TK_PRECEDING \n       || pMWin->eStart==TK_CURRENT \n       || pMWin->eStart==TK_FOLLOWING \n       || pMWin->eStart==TK_UNBOUNDED \n  );\n  assert( pMWin->eEnd==TK_FOLLOWING \n       || pMWin->eEnd==TK_CURRENT \n       || pMWin->eEnd==TK_UNBOUNDED \n       || pMWin->eEnd==TK_PRECEDING \n  );\n\n  /* Allocate register and label for the \"flush_partition\" sub-routine. */\n  regFlushPart = ++pParse->nMem;\n  lblFlushPart = sqlite3VdbeMakeLabel(pParse);\n  lblFlushDone = sqlite3VdbeMakeLabel(pParse);\n\n  regStart = ++pParse->nMem;\n  regEnd = ++pParse->nMem;\n\n  windowPartitionCache(pParse, p, pWInfo, regFlushPart, lblFlushPart, &regSize);\n\n  addrGoto = sqlite3VdbeAddOp0(v, OP_Goto);\n\n  /* Start of \"flush_partition\" */\n  sqlite3VdbeResolveLabel(v, lblFlushPart);\n  sqlite3VdbeAddOp2(v, OP_Once, 0, sqlite3VdbeCurrentAddr(v)+3);\n  VdbeCoverage(v);\n  VdbeComment((v, \"Flush_partition subroutine\"));\n  sqlite3VdbeAddOp2(v, OP_OpenDup, csrStart, pMWin->iEphCsr);\n  sqlite3VdbeAddOp2(v, OP_OpenDup, csrEnd, pMWin->iEphCsr);\n\n  /* If either regStart or regEnd are not non-negative integers, throw \n  ** an exception.  */\n  if( pMWin->pStart ){\n    sqlite3ExprCode(pParse, pMWin->pStart, regStart);\n    windowCheckIntValue(pParse, regStart, 0);\n  }\n  if( pMWin->pEnd ){\n    sqlite3ExprCode(pParse, pMWin->pEnd, regEnd);\n    windowCheckIntValue(pParse, regEnd, 1);\n  }\n\n  /* If this is \"ROWS <expr1> FOLLOWING AND ROWS <expr2> FOLLOWING\", do:\n  **\n  **   if( regEnd<regStart ){\n  **     // The frame always consists of 0 rows\n  **     regStart = regSize;\n  **   }\n  **   regEnd = regEnd - regStart;\n  */\n  if( pMWin->pEnd && pMWin->eStart==TK_FOLLOWING ){\n    assert( pMWin->pStart!=0 );\n    assert( pMWin->eEnd==TK_FOLLOWING );\n    sqlite3VdbeAddOp3(v, OP_Ge, regStart, sqlite3VdbeCurrentAddr(v)+2, regEnd);\n    VdbeCoverageNeverNull(v);\n    sqlite3VdbeAddOp2(v, OP_Copy, regSize, regStart);\n    sqlite3VdbeAddOp3(v, OP_Subtract, regStart, regEnd, regEnd);\n  }\n\n  if( pMWin->pStart && pMWin->eEnd==TK_PRECEDING ){\n    assert( pMWin->pEnd!=0 );\n    assert( pMWin->eStart==TK_PRECEDING );\n    sqlite3VdbeAddOp3(v, OP_Le, regStart, sqlite3VdbeCurrentAddr(v)+3, regEnd);\n    VdbeCoverageNeverNull(v);\n    sqlite3VdbeAddOp2(v, OP_Copy, regSize, regStart);\n    sqlite3VdbeAddOp2(v, OP_Copy, regSize, regEnd);\n  }\n\n  /* Initialize the accumulator register for each window function to NULL */\n  regArg = windowInitAccum(pParse, pMWin);\n\n  sqlite3VdbeAddOp2(v, OP_Rewind, pMWin->iEphCsr, lblFlushDone);\n  VdbeCoverage(v);\n  sqlite3VdbeAddOp2(v, OP_Rewind, csrStart, lblFlushDone);\n  VdbeCoverageNeverTaken(v);\n  sqlite3VdbeChangeP5(v, 1);\n  sqlite3VdbeAddOp2(v, OP_Rewind, csrEnd, lblFlushDone);\n  VdbeCoverageNeverTaken(v);\n  sqlite3VdbeChangeP5(v, 1);\n\n  /* Invoke AggStep function for each window function using the row that\n  ** csrEnd currently points to. Or, if csrEnd is already at EOF,\n  ** do nothing.  */\n  addrTop = sqlite3VdbeCurrentAddr(v);\n  if( pMWin->eEnd==TK_PRECEDING ){\n    addrIfPos1 = sqlite3VdbeAddOp3(v, OP_IfPos, regEnd, 0 , 1);\n    VdbeCoverage(v);\n  }\n  sqlite3VdbeAddOp2(v, OP_Next, csrEnd, sqlite3VdbeCurrentAddr(v)+2);\n  VdbeCoverage(v);\n  addr = sqlite3VdbeAddOp0(v, OP_Goto);\n  windowAggStep(pParse, pMWin, csrEnd, 0, regArg, regSize);\n  if( pMWin->eEnd==TK_UNBOUNDED ){\n    sqlite3VdbeAddOp2(v, OP_Goto, 0, addrTop);\n    sqlite3VdbeJumpHere(v, addr);\n    addrTop = sqlite3VdbeCurrentAddr(v);\n  }else{\n    sqlite3VdbeJumpHere(v, addr);\n    if( pMWin->eEnd==TK_PRECEDING ){\n      sqlite3VdbeJumpHere(v, addrIfPos1);\n    }\n  }\n\n  if( pMWin->eEnd==TK_FOLLOWING ){\n    addrIfPos1 = sqlite3VdbeAddOp3(v, OP_IfPos, regEnd, 0 , 1);\n    VdbeCoverage(v);\n  }\n  if( pMWin->eStart==TK_FOLLOWING ){\n    addrIfPos2 = sqlite3VdbeAddOp3(v, OP_IfPos, regStart, 0 , 1);\n    VdbeCoverage(v);\n  }\n  windowAggFinal(pParse, pMWin, 0);\n  windowReturnOneRow(pParse, pMWin, regGosub, addrGosub);\n  sqlite3VdbeAddOp2(v, OP_Next, pMWin->iEphCsr, sqlite3VdbeCurrentAddr(v)+2);\n  VdbeCoverage(v);\n  sqlite3VdbeAddOp2(v, OP_Goto, 0, lblFlushDone);\n  if( pMWin->eStart==TK_FOLLOWING ){\n    sqlite3VdbeJumpHere(v, addrIfPos2);\n  }\n\n  if( pMWin->eStart==TK_CURRENT \n   || pMWin->eStart==TK_PRECEDING \n   || pMWin->eStart==TK_FOLLOWING \n  ){\n    int lblSkipInverse = sqlite3VdbeMakeLabel(pParse);;\n    if( pMWin->eStart==TK_PRECEDING ){\n      sqlite3VdbeAddOp3(v, OP_IfPos, regStart, lblSkipInverse, 1);\n      VdbeCoverage(v);\n    }\n    if( pMWin->eStart==TK_FOLLOWING ){\n      sqlite3VdbeAddOp2(v, OP_Next, csrStart, sqlite3VdbeCurrentAddr(v)+2);\n      VdbeCoverage(v);\n      sqlite3VdbeAddOp2(v, OP_Goto, 0, lblSkipInverse);\n    }else{\n      sqlite3VdbeAddOp2(v, OP_Next, csrStart, sqlite3VdbeCurrentAddr(v)+1);\n      VdbeCoverageAlwaysTaken(v);\n    }\n    windowAggStep(pParse, pMWin, csrStart, 1, regArg, regSize);\n    sqlite3VdbeResolveLabel(v, lblSkipInverse);\n  }\n  if( pMWin->eEnd==TK_FOLLOWING ){\n    sqlite3VdbeJumpHere(v, addrIfPos1);\n  }\n  sqlite3VdbeAddOp2(v, OP_Goto, 0, addrTop);\n\n  /* flush_partition_done: */\n  sqlite3VdbeResolveLabel(v, lblFlushDone);\n  sqlite3VdbeAddOp1(v, OP_ResetSorter, pMWin->iEphCsr);\n  sqlite3VdbeAddOp1(v, OP_Return, regFlushPart);\n  VdbeComment((v, \"end flush_partition subroutine\"));\n\n  /* Jump to here to skip over flush_partition */\n  sqlite3VdbeJumpHere(v, addrGoto);\n}\n\n/*\n** This function does the work of sqlite3WindowCodeStep() for cases that\n** would normally be handled by windowCodeDefaultStep() when there are\n** one or more built-in window-functions that require the entire partition\n** to be cached in a temp table before any rows can be returned. Additionally.\n** \"RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING\" is always handled by\n** this function.\n**\n** Pseudo-code corresponding to the VM code generated by this function\n** for each type of window follows.\n**\n** RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW\n**\n**   flush_partition:\n**     Once {\n**       OpenDup (iEphCsr -> csrLead)\n**     }\n**     Integer ctr 0\n**     foreach row (csrLead){\n**       if( new peer ){\n**         AggFinal (xValue)\n**         for(i=0; i<ctr; i++){\n**           Gosub addrGosub\n**           Next iEphCsr\n**         }\n**         Integer ctr 0\n**       }\n**       AggStep (csrLead)\n**       Incr ctr\n**     }\n**\n**     AggFinal (xFinalize)\n**     for(i=0; i<ctr; i++){\n**       Gosub addrGosub\n**       Next iEphCsr\n**     }\n**\n**     ResetSorter (csr)\n**     Return\n**\n** ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW\n**\n**   As above, except that the \"if( new peer )\" branch is always taken.\n**\n** RANGE BETWEEN CURRENT ROW AND CURRENT ROW \n**\n**   As above, except that each of the for() loops becomes:\n**\n**         for(i=0; i<ctr; i++){\n**           Gosub addrGosub\n**           AggInverse (iEphCsr)\n**           Next iEphCsr\n**         }\n**\n** RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING\n**\n**   flush_partition:\n**     Once {\n**       OpenDup (iEphCsr -> csrLead)\n**     }\n**     foreach row (csrLead) {\n**       AggStep (csrLead)\n**     }\n**     foreach row (iEphCsr) {\n**       Gosub addrGosub\n**     }\n** \n** RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING\n**\n**   flush_partition:\n**     Once {\n**       OpenDup (iEphCsr -> csrLead)\n**     }\n**     foreach row (csrLead){\n**       AggStep (csrLead)\n**     }\n**     Rewind (csrLead)\n**     Integer ctr 0\n**     foreach row (csrLead){\n**       if( new peer ){\n**         AggFinal (xValue)\n**         for(i=0; i<ctr; i++){\n**           Gosub addrGosub\n**           AggInverse (iEphCsr)\n**           Next iEphCsr\n**         }\n**         Integer ctr 0\n**       }\n**       Incr ctr\n**     }\n**\n**     AggFinal (xFinalize)\n**     for(i=0; i<ctr; i++){\n**       Gosub addrGosub\n**       Next iEphCsr\n**     }\n**\n**     ResetSorter (csr)\n**     Return\n*/\nstatic void windowCodeCacheStep(\n  Parse *pParse, \n  Select *p,\n  WhereInfo *pWInfo,\n  int regGosub, \n  int addrGosub\n){\n  Window *pMWin = p->pWin;\n  Vdbe *v = sqlite3GetVdbe(pParse);\n  int k;\n  int addr;\n  ExprList *pPart = pMWin->pPartition;\n  ExprList *pOrderBy = pMWin->pOrderBy;\n  int nPeer = pOrderBy ? pOrderBy->nExpr : 0;\n  int regNewPeer;\n\n  int addrGoto;                   /* Address of Goto used to jump flush_par.. */\n  int addrNext;                   /* Jump here for next iteration of loop */\n  int regFlushPart;\n  int lblFlushPart;\n  int csrLead;\n  int regCtr;\n  int regArg;                     /* Register array to martial function args */\n  int regSize;\n  int lblEmpty;\n  int bReverse = pMWin->pOrderBy && pMWin->eStart==TK_CURRENT \n          && pMWin->eEnd==TK_UNBOUNDED;\n\n  assert( (pMWin->eStart==TK_UNBOUNDED && pMWin->eEnd==TK_CURRENT) \n       || (pMWin->eStart==TK_UNBOUNDED && pMWin->eEnd==TK_UNBOUNDED) \n       || (pMWin->eStart==TK_CURRENT && pMWin->eEnd==TK_CURRENT) \n       || (pMWin->eStart==TK_CURRENT && pMWin->eEnd==TK_UNBOUNDED) \n  );\n\n  lblEmpty = sqlite3VdbeMakeLabel(pParse);\n  regNewPeer = pParse->nMem+1;\n  pParse->nMem += nPeer;\n\n  /* Allocate register and label for the \"flush_partition\" sub-routine. */\n  regFlushPart = ++pParse->nMem;\n  lblFlushPart = sqlite3VdbeMakeLabel(pParse);\n\n  csrLead = pParse->nTab++;\n  regCtr = ++pParse->nMem;\n\n  windowPartitionCache(pParse, p, pWInfo, regFlushPart, lblFlushPart, &regSize);\n  addrGoto = sqlite3VdbeAddOp0(v, OP_Goto);\n\n  /* Start of \"flush_partition\" */\n  sqlite3VdbeResolveLabel(v, lblFlushPart);\n  sqlite3VdbeAddOp2(v, OP_Once, 0, sqlite3VdbeCurrentAddr(v)+2);\n  VdbeCoverage(v);\n  sqlite3VdbeAddOp2(v, OP_OpenDup, csrLead, pMWin->iEphCsr);\n\n  /* Initialize the accumulator register for each window function to NULL */\n  regArg = windowInitAccum(pParse, pMWin);\n\n  sqlite3VdbeAddOp2(v, OP_Integer, 0, regCtr);\n  sqlite3VdbeAddOp2(v, OP_Rewind, csrLead, lblEmpty);\n  VdbeCoverage(v);\n  sqlite3VdbeAddOp2(v, OP_Rewind, pMWin->iEphCsr, lblEmpty);\n  VdbeCoverageNeverTaken(v);\n\n  if( bReverse ){\n    int addr2 = sqlite3VdbeCurrentAddr(v);\n    windowAggStep(pParse, pMWin, csrLead, 0, regArg, regSize);\n    sqlite3VdbeAddOp2(v, OP_Next, csrLead, addr2);\n    VdbeCoverage(v);\n    sqlite3VdbeAddOp2(v, OP_Rewind, csrLead, lblEmpty);\n    VdbeCoverageNeverTaken(v);\n  }\n  addrNext = sqlite3VdbeCurrentAddr(v);\n\n  if( pOrderBy && (pMWin->eEnd==TK_CURRENT || pMWin->eStart==TK_CURRENT) ){\n    int bCurrent = (pMWin->eStart==TK_CURRENT);\n    int addrJump = 0;             /* Address of OP_Jump below */\n    if( pMWin->eType==TK_RANGE ){\n      int iOff = pMWin->nBufferCol + (pPart ? pPart->nExpr : 0);\n      int regPeer = pMWin->regPart + (pPart ? pPart->nExpr : 0);\n      KeyInfo *pKeyInfo = sqlite3KeyInfoFromExprList(pParse, pOrderBy, 0, 0);\n      for(k=0; k<nPeer; k++){\n        sqlite3VdbeAddOp3(v, OP_Column, csrLead, iOff+k, regNewPeer+k);\n      }\n      addr = sqlite3VdbeAddOp3(v, OP_Compare, regNewPeer, regPeer, nPeer);\n      sqlite3VdbeAppendP4(v, (void*)pKeyInfo, P4_KEYINFO);\n      addrJump = sqlite3VdbeAddOp3(v, OP_Jump, addr+2, 0, addr+2);\n      VdbeCoverage(v);\n      sqlite3VdbeAddOp3(v, OP_Copy, regNewPeer, regPeer, nPeer-1);\n    }\n\n    windowReturnRows(pParse, pMWin, regCtr, regGosub, addrGosub, \n        (bCurrent ? regArg : 0), (bCurrent ? regSize : 0)\n    );\n    if( addrJump ) sqlite3VdbeJumpHere(v, addrJump);\n  }\n\n  if( bReverse==0 ){\n    windowAggStep(pParse, pMWin, csrLead, 0, regArg, regSize);\n  }\n  sqlite3VdbeAddOp2(v, OP_AddImm, regCtr, 1);\n  sqlite3VdbeAddOp2(v, OP_Next, csrLead, addrNext);\n  VdbeCoverage(v);\n\n  windowReturnRows(pParse, pMWin, regCtr, regGosub, addrGosub, 0, 0);\n\n  sqlite3VdbeResolveLabel(v, lblEmpty);\n  sqlite3VdbeAddOp1(v, OP_ResetSorter, pMWin->iEphCsr);\n  sqlite3VdbeAddOp1(v, OP_Return, regFlushPart);\n\n  /* Jump to here to skip over flush_partition */\n  sqlite3VdbeJumpHere(v, addrGoto);\n}\n\n\n/*\n** RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW\n**\n**   ...\n**     if( new partition ){\n**       AggFinal (xFinalize)\n**       Gosub addrGosub\n**       ResetSorter eph-table\n**     }\n**     else if( new peer ){\n**       AggFinal (xValue)\n**       Gosub addrGosub\n**       ResetSorter eph-table\n**     }\n**     AggStep\n**     Insert (record into eph-table)\n**   sqlite3WhereEnd()\n**   AggFinal (xFinalize)\n**   Gosub addrGosub\n**\n** RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING\n**\n**   As above, except take no action for a \"new peer\". Invoke\n**   the sub-routine once only for each partition.\n**\n** RANGE BETWEEN CURRENT ROW AND CURRENT ROW\n**\n**   As above, except that the \"new peer\" condition is handled in the\n**   same way as \"new partition\" (so there is no \"else if\" block).\n**\n** ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW\n** \n**   As above, except assume every row is a \"new peer\".\n*/\nstatic void windowCodeDefaultStep(\n  Parse *pParse, \n  Select *p,\n  WhereInfo *pWInfo,\n  int regGosub, \n  int addrGosub\n){\n  Window *pMWin = p->pWin;\n  Vdbe *v = sqlite3GetVdbe(pParse);\n  int k;\n  int iSubCsr = p->pSrc->a[0].iCursor;\n  int nSub = p->pSrc->a[0].pTab->nCol;\n  int reg = pParse->nMem+1;\n  int regRecord = reg+nSub;\n  int regRowid = regRecord+1;\n  int addr;\n  ExprList *pPart = pMWin->pPartition;\n  ExprList *pOrderBy = pMWin->pOrderBy;\n\n  assert( pMWin->eType==TK_RANGE \n      || (pMWin->eStart==TK_UNBOUNDED && pMWin->eEnd==TK_CURRENT)\n  );\n\n  assert( (pMWin->eStart==TK_UNBOUNDED && pMWin->eEnd==TK_CURRENT)\n       || (pMWin->eStart==TK_UNBOUNDED && pMWin->eEnd==TK_UNBOUNDED)\n       || (pMWin->eStart==TK_CURRENT && pMWin->eEnd==TK_CURRENT)\n       || (pMWin->eStart==TK_CURRENT && pMWin->eEnd==TK_UNBOUNDED && !pOrderBy)\n  );\n\n  if( pMWin->eEnd==TK_UNBOUNDED ){\n    pOrderBy = 0;\n  }\n\n  pParse->nMem += nSub + 2;\n\n  /* Load the individual column values of the row returned by\n  ** the sub-select into an array of registers. */\n  for(k=0; k<nSub; k++){\n    sqlite3VdbeAddOp3(v, OP_Column, iSubCsr, k, reg+k);\n  }\n\n  /* Check if this is the start of a new partition or peer group. */\n  if( pPart || pOrderBy ){\n    int nPart = (pPart ? pPart->nExpr : 0);\n    int addrGoto = 0;\n    int addrJump = 0;\n    int nPeer = (pOrderBy ? pOrderBy->nExpr : 0);\n\n    if( pPart ){\n      int regNewPart = reg + pMWin->nBufferCol;\n      KeyInfo *pKeyInfo = sqlite3KeyInfoFromExprList(pParse, pPart, 0, 0);\n      addr = sqlite3VdbeAddOp3(v, OP_Compare, regNewPart, pMWin->regPart,nPart);\n      sqlite3VdbeAppendP4(v, (void*)pKeyInfo, P4_KEYINFO);\n      addrJump = sqlite3VdbeAddOp3(v, OP_Jump, addr+2, 0, addr+2);\n      VdbeCoverageEqNe(v);\n      windowAggFinal(pParse, pMWin, 1);\n      if( pOrderBy ){\n        addrGoto = sqlite3VdbeAddOp0(v, OP_Goto);\n      }\n    }\n\n    if( pOrderBy ){\n      int regNewPeer = reg + pMWin->nBufferCol + nPart;\n      int regPeer = pMWin->regPart + nPart;\n\n      if( addrJump ) sqlite3VdbeJumpHere(v, addrJump);\n      if( pMWin->eType==TK_RANGE ){\n        KeyInfo *pKeyInfo = sqlite3KeyInfoFromExprList(pParse, pOrderBy, 0, 0);\n        addr = sqlite3VdbeAddOp3(v, OP_Compare, regNewPeer, regPeer, nPeer);\n        sqlite3VdbeAppendP4(v, (void*)pKeyInfo, P4_KEYINFO);\n        addrJump = sqlite3VdbeAddOp3(v, OP_Jump, addr+2, 0, addr+2);\n        VdbeCoverage(v);\n      }else{\n        addrJump = 0;\n      }\n      windowAggFinal(pParse, pMWin, pMWin->eStart==TK_CURRENT);\n      if( addrGoto ) sqlite3VdbeJumpHere(v, addrGoto);\n    }\n\n    sqlite3VdbeAddOp2(v, OP_Rewind, pMWin->iEphCsr,sqlite3VdbeCurrentAddr(v)+3);\n    VdbeCoverage(v);\n    sqlite3VdbeAddOp2(v, OP_Gosub, regGosub, addrGosub);\n    sqlite3VdbeAddOp2(v, OP_Next, pMWin->iEphCsr, sqlite3VdbeCurrentAddr(v)-1);\n    VdbeCoverage(v);\n\n    sqlite3VdbeAddOp1(v, OP_ResetSorter, pMWin->iEphCsr);\n    sqlite3VdbeAddOp3(\n        v, OP_Copy, reg+pMWin->nBufferCol, pMWin->regPart, nPart+nPeer-1\n    );\n\n    if( addrJump ) sqlite3VdbeJumpHere(v, addrJump);\n  }\n\n  /* Invoke step function for window functions */\n  windowAggStep(pParse, pMWin, -1, 0, reg, 0);\n\n  /* Buffer the current row in the ephemeral table. */\n  if( pMWin->nBufferCol>0 ){\n    sqlite3VdbeAddOp3(v, OP_MakeRecord, reg, pMWin->nBufferCol, regRecord);\n  }else{\n    sqlite3VdbeAddOp2(v, OP_Blob, 0, regRecord);\n    sqlite3VdbeAppendP4(v, (void*)\"\", 0);\n  }\n  sqlite3VdbeAddOp2(v, OP_NewRowid, pMWin->iEphCsr, regRowid);\n  sqlite3VdbeAddOp3(v, OP_Insert, pMWin->iEphCsr, regRecord, regRowid);\n\n  /* End the database scan loop. */\n  sqlite3WhereEnd(pWInfo);\n\n  windowAggFinal(pParse, pMWin, 1);\n  sqlite3VdbeAddOp2(v, OP_Rewind, pMWin->iEphCsr,sqlite3VdbeCurrentAddr(v)+3);\n  VdbeCoverage(v);\n  sqlite3VdbeAddOp2(v, OP_Gosub, regGosub, addrGosub);\n  sqlite3VdbeAddOp2(v, OP_Next, pMWin->iEphCsr, sqlite3VdbeCurrentAddr(v)-1);\n  VdbeCoverage(v);\n}\n\n/*\n** Allocate and return a duplicate of the Window object indicated by the\n** third argument. Set the Window.pOwner field of the new object to\n** pOwner.\n*/\nSQLITE_PRIVATE Window *sqlite3WindowDup(sqlite3 *db, Expr *pOwner, Window *p){\n  Window *pNew = 0;\n  if( ALWAYS(p) ){\n    pNew = sqlite3DbMallocZero(db, sizeof(Window));\n    if( pNew ){\n      pNew->zName = sqlite3DbStrDup(db, p->zName);\n      pNew->pFilter = sqlite3ExprDup(db, p->pFilter, 0);\n      pNew->pFunc = p->pFunc;\n      pNew->pPartition = sqlite3ExprListDup(db, p->pPartition, 0);\n      pNew->pOrderBy = sqlite3ExprListDup(db, p->pOrderBy, 0);\n      pNew->eType = p->eType;\n      pNew->eEnd = p->eEnd;\n      pNew->eStart = p->eStart;\n      pNew->pStart = sqlite3ExprDup(db, p->pStart, 0);\n      pNew->pEnd = sqlite3ExprDup(db, p->pEnd, 0);\n      pNew->pOwner = pOwner;\n    }\n  }\n  return pNew;\n}\n\n/*\n** Return a copy of the linked list of Window objects passed as the\n** second argument.\n*/\nSQLITE_PRIVATE Window *sqlite3WindowListDup(sqlite3 *db, Window *p){\n  Window *pWin;\n  Window *pRet = 0;\n  Window **pp = &pRet;\n\n  for(pWin=p; pWin; pWin=pWin->pNextWin){\n    *pp = sqlite3WindowDup(db, 0, pWin);\n    if( *pp==0 ) break;\n    pp = &((*pp)->pNextWin);\n  }\n\n  return pRet;\n}\n\n/*\n** sqlite3WhereBegin() has already been called for the SELECT statement \n** passed as the second argument when this function is invoked. It generates\n** code to populate the Window.regResult register for each window function and\n** invoke the sub-routine at instruction addrGosub once for each row.\n** This function calls sqlite3WhereEnd() before returning. \n*/\nSQLITE_PRIVATE void sqlite3WindowCodeStep(\n  Parse *pParse,                  /* Parse context */\n  Select *p,                      /* Rewritten SELECT statement */\n  WhereInfo *pWInfo,              /* Context returned by sqlite3WhereBegin() */\n  int regGosub,                   /* Register for OP_Gosub */\n  int addrGosub                   /* OP_Gosub here to return each row */\n){\n  Window *pMWin = p->pWin;\n\n  /* There are three different functions that may be used to do the work\n  ** of this one, depending on the window frame and the specific built-in\n  ** window functions used (if any).\n  **\n  ** windowCodeRowExprStep() handles all \"ROWS\" window frames, except for:\n  **\n  **   ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW\n  **\n  ** The exception is because windowCodeRowExprStep() implements all window\n  ** frame types by caching the entire partition in a temp table, and\n  ** \"ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW\" is easy enough to\n  ** implement without such a cache.\n  **\n  ** windowCodeCacheStep() is used for:\n  **\n  **   RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING\n  **\n  ** It is also used for anything not handled by windowCodeRowExprStep() \n  ** that invokes a built-in window function that requires the entire \n  ** partition to be cached in a temp table before any rows are returned\n  ** (e.g. nth_value() or percent_rank()).\n  **\n  ** Finally, assuming there is no built-in window function that requires\n  ** the partition to be cached, windowCodeDefaultStep() is used for:\n  **\n  **   RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW \n  **   RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING\n  **   RANGE BETWEEN CURRENT ROW AND CURRENT ROW \n  **   ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW\n  **\n  ** windowCodeDefaultStep() is the only one of the three functions that\n  ** does not cache each partition in a temp table before beginning to\n  ** return rows.\n  */\n  if( pMWin->eType==TK_ROWS \n   && (pMWin->eStart!=TK_UNBOUNDED||pMWin->eEnd!=TK_CURRENT||!pMWin->pOrderBy)\n  ){\n    VdbeModuleComment((pParse->pVdbe, \"Begin RowExprStep()\"));\n    windowCodeRowExprStep(pParse, p, pWInfo, regGosub, addrGosub);\n  }else{\n    Window *pWin;\n    int bCache = 0;               /* True to use CacheStep() */\n\n    if( pMWin->eStart==TK_CURRENT && pMWin->eEnd==TK_UNBOUNDED ){\n      bCache = 1;\n    }else{\n      for(pWin=pMWin; pWin; pWin=pWin->pNextWin){\n        FuncDef *pFunc = pWin->pFunc;\n        if( (pFunc->funcFlags & SQLITE_FUNC_WINDOW_SIZE)\n         || (pFunc->zName==nth_valueName)\n         || (pFunc->zName==first_valueName)\n         || (pFunc->zName==leadName)\n         || (pFunc->zName==lagName)\n        ){\n          bCache = 1;\n          break;\n        }\n      }\n    }\n\n    /* Otherwise, call windowCodeDefaultStep().  */\n    if( bCache ){\n      VdbeModuleComment((pParse->pVdbe, \"Begin CacheStep()\"));\n      windowCodeCacheStep(pParse, p, pWInfo, regGosub, addrGosub);\n    }else{\n      VdbeModuleComment((pParse->pVdbe, \"Begin DefaultStep()\"));\n      windowCodeDefaultStep(pParse, p, pWInfo, regGosub, addrGosub);\n    }\n  }\n}\n\n#endif /* SQLITE_OMIT_WINDOWFUNC */\n\n/************** End of window.c **********************************************/\n/************** Begin file parse.c *******************************************/\n/*\n** 2000-05-29\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** Driver template for the LEMON parser generator.\n**\n** The \"lemon\" program processes an LALR(1) input grammar file, then uses\n** this template to construct a parser.  The \"lemon\" program inserts text\n** at each \"%%\" line.  Also, any \"P-a-r-s-e\" identifer prefix (without the\n** interstitial \"-\" characters) contained in this template is changed into\n** the value of the %name directive from the grammar.  Otherwise, the content\n** of this template is copied straight through into the generate parser\n** source file.\n**\n** The following is the concatenation of all %include directives from the\n** input grammar file:\n*/\n/* #include <stdio.h> */\n/* #include <assert.h> */\n/************ Begin %include sections from the grammar ************************/\n\n/* #include \"sqliteInt.h\" */\n\n/*\n** Disable all error recovery processing in the parser push-down\n** automaton.\n*/\n#define YYNOERRORRECOVERY 1\n\n/*\n** Make yytestcase() the same as testcase()\n*/\n#define yytestcase(X) testcase(X)\n\n/*\n** Indicate that sqlite3ParserFree() will never be called with a null\n** pointer.\n*/\n#define YYPARSEFREENEVERNULL 1\n\n/*\n** In the amalgamation, the parse.c file generated by lemon and the\n** tokenize.c file are concatenated.  In that case, sqlite3RunParser()\n** has access to the the size of the yyParser object and so the parser\n** engine can be allocated from stack.  In that case, only the\n** sqlite3ParserInit() and sqlite3ParserFinalize() routines are invoked\n** and the sqlite3ParserAlloc() and sqlite3ParserFree() routines can be\n** omitted.\n*/\n#ifdef SQLITE_AMALGAMATION\n# define sqlite3Parser_ENGINEALWAYSONSTACK 1\n#endif\n\n/*\n** Alternative datatype for the argument to the malloc() routine passed\n** into sqlite3ParserAlloc().  The default is size_t.\n*/\n#define YYMALLOCARGTYPE  u64\n\n/*\n** An instance of the following structure describes the event of a\n** TRIGGER.  \"a\" is the event type, one of TK_UPDATE, TK_INSERT,\n** TK_DELETE, or TK_INSTEAD.  If the event is of the form\n**\n**      UPDATE ON (a,b,c)\n**\n** Then the \"b\" IdList records the list \"a,b,c\".\n*/\nstruct TrigEvent { int a; IdList * b; };\n\nstruct FrameBound     { int eType; Expr *pExpr; };\n\n/*\n** Disable lookaside memory allocation for objects that might be\n** shared across database connections.\n*/\nstatic void disableLookaside(Parse *pParse){\n  pParse->disableLookaside++;\n  pParse->db->lookaside.bDisable++;\n}\n\n\n  /*\n  ** For a compound SELECT statement, make sure p->pPrior->pNext==p for\n  ** all elements in the list.  And make sure list length does not exceed\n  ** SQLITE_LIMIT_COMPOUND_SELECT.\n  */\n  static void parserDoubleLinkSelect(Parse *pParse, Select *p){\n    if( p->pPrior ){\n      Select *pNext = 0, *pLoop;\n      int mxSelect, cnt = 0;\n      for(pLoop=p; pLoop; pNext=pLoop, pLoop=pLoop->pPrior, cnt++){\n        pLoop->pNext = pNext;\n        pLoop->selFlags |= SF_Compound;\n      }\n      if( (p->selFlags & SF_MultiValue)==0 && \n        (mxSelect = pParse->db->aLimit[SQLITE_LIMIT_COMPOUND_SELECT])>0 &&\n        cnt>mxSelect\n      ){\n        sqlite3ErrorMsg(pParse, \"too many terms in compound SELECT\");\n      }\n    }\n  }\n\n\n  /* Construct a new Expr object from a single identifier.  Use the\n  ** new Expr to populate pOut.  Set the span of pOut to be the identifier\n  ** that created the expression.\n  */\n  static Expr *tokenExpr(Parse *pParse, int op, Token t){\n    Expr *p = sqlite3DbMallocRawNN(pParse->db, sizeof(Expr)+t.n+1);\n    if( p ){\n      /* memset(p, 0, sizeof(Expr)); */\n      p->op = (u8)op;\n      p->affinity = 0;\n      p->flags = EP_Leaf;\n      p->iAgg = -1;\n      p->pLeft = p->pRight = 0;\n      p->x.pList = 0;\n      p->pAggInfo = 0;\n      p->y.pTab = 0;\n      p->op2 = 0;\n      p->iTable = 0;\n      p->iColumn = 0;\n      p->u.zToken = (char*)&p[1];\n      memcpy(p->u.zToken, t.z, t.n);\n      p->u.zToken[t.n] = 0;\n      if( sqlite3Isquote(p->u.zToken[0]) ){\n        sqlite3DequoteExpr(p);\n      }\n#if SQLITE_MAX_EXPR_DEPTH>0\n      p->nHeight = 1;\n#endif  \n      if( IN_RENAME_OBJECT ){\n        return (Expr*)sqlite3RenameTokenMap(pParse, (void*)p, &t);\n      }\n    }\n    return p;\n  }\n\n\n  /* A routine to convert a binary TK_IS or TK_ISNOT expression into a\n  ** unary TK_ISNULL or TK_NOTNULL expression. */\n  static void binaryToUnaryIfNull(Parse *pParse, Expr *pY, Expr *pA, int op){\n    sqlite3 *db = pParse->db;\n    if( pA && pY && pY->op==TK_NULL && !IN_RENAME_OBJECT ){\n      pA->op = (u8)op;\n      sqlite3ExprDelete(db, pA->pRight);\n      pA->pRight = 0;\n    }\n  }\n\n  /* Add a single new term to an ExprList that is used to store a\n  ** list of identifiers.  Report an error if the ID list contains\n  ** a COLLATE clause or an ASC or DESC keyword, except ignore the\n  ** error while parsing a legacy schema.\n  */\n  static ExprList *parserAddExprIdListTerm(\n    Parse *pParse,\n    ExprList *pPrior,\n    Token *pIdToken,\n    int hasCollate,\n    int sortOrder\n  ){\n    ExprList *p = sqlite3ExprListAppend(pParse, pPrior, 0);\n    if( (hasCollate || sortOrder!=SQLITE_SO_UNDEFINED)\n        && pParse->db->init.busy==0\n    ){\n      sqlite3ErrorMsg(pParse, \"syntax error after column name \\\"%.*s\\\"\",\n                         pIdToken->n, pIdToken->z);\n    }\n    sqlite3ExprListSetName(pParse, p, pIdToken, 1);\n    return p;\n  }\n/**************** End of %include directives **********************************/\n/* These constants specify the various numeric values for terminal symbols\n** in a format understandable to \"makeheaders\".  This section is blank unless\n** \"lemon\" is run with the \"-m\" command-line option.\n***************** Begin makeheaders token definitions *************************/\n/**************** End makeheaders token definitions ***************************/\n\n/* The next sections is a series of control #defines.\n** various aspects of the generated parser.\n**    YYCODETYPE         is the data type used to store the integer codes\n**                       that represent terminal and non-terminal symbols.\n**                       \"unsigned char\" is used if there are fewer than\n**                       256 symbols.  Larger types otherwise.\n**    YYNOCODE           is a number of type YYCODETYPE that is not used for\n**                       any terminal or nonterminal symbol.\n**    YYFALLBACK         If defined, this indicates that one or more tokens\n**                       (also known as: \"terminal symbols\") have fall-back\n**                       values which should be used if the original symbol\n**                       would not parse.  This permits keywords to sometimes\n**                       be used as identifiers, for example.\n**    YYACTIONTYPE       is the data type used for \"action codes\" - numbers\n**                       that indicate what to do in response to the next\n**                       token.\n**    sqlite3ParserTOKENTYPE     is the data type used for minor type for terminal\n**                       symbols.  Background: A \"minor type\" is a semantic\n**                       value associated with a terminal or non-terminal\n**                       symbols.  For example, for an \"ID\" terminal symbol,\n**                       the minor type might be the name of the identifier.\n**                       Each non-terminal can have a different minor type.\n**                       Terminal symbols all have the same minor type, though.\n**                       This macros defines the minor type for terminal \n**                       symbols.\n**    YYMINORTYPE        is the data type used for all minor types.\n**                       This is typically a union of many types, one of\n**                       which is sqlite3ParserTOKENTYPE.  The entry in the union\n**                       for terminal symbols is called \"yy0\".\n**    YYSTACKDEPTH       is the maximum depth of the parser's stack.  If\n**                       zero the stack is dynamically sized using realloc()\n**    sqlite3ParserARG_SDECL     A static variable declaration for the %extra_argument\n**    sqlite3ParserARG_PDECL     A parameter declaration for the %extra_argument\n**    sqlite3ParserARG_PARAM     Code to pass %extra_argument as a subroutine parameter\n**    sqlite3ParserARG_STORE     Code to store %extra_argument into yypParser\n**    sqlite3ParserARG_FETCH     Code to extract %extra_argument from yypParser\n**    sqlite3ParserCTX_*         As sqlite3ParserARG_ except for %extra_context\n**    YYERRORSYMBOL      is the code number of the error symbol.  If not\n**                       defined, then do no error processing.\n**    YYNSTATE           the combined number of states.\n**    YYNRULE            the number of rules in the grammar\n**    YYNTOKEN           Number of terminal symbols\n**    YY_MAX_SHIFT       Maximum value for shift actions\n**    YY_MIN_SHIFTREDUCE Minimum value for shift-reduce actions\n**    YY_MAX_SHIFTREDUCE Maximum value for shift-reduce actions\n**    YY_ERROR_ACTION    The yy_action[] code for syntax error\n**    YY_ACCEPT_ACTION   The yy_action[] code for accept\n**    YY_NO_ACTION       The yy_action[] code for no-op\n**    YY_MIN_REDUCE      Minimum value for reduce actions\n**    YY_MAX_REDUCE      Maximum value for reduce actions\n*/\n#ifndef INTERFACE\n# define INTERFACE 1\n#endif\n/************* Begin control #defines *****************************************/\n#define YYCODETYPE unsigned short int\n#define YYNOCODE 278\n#define YYACTIONTYPE unsigned short int\n#define YYWILDCARD 91\n#define sqlite3ParserTOKENTYPE Token\ntypedef union {\n  int yyinit;\n  sqlite3ParserTOKENTYPE yy0;\n  ExprList* yy42;\n  int yy96;\n  TriggerStep* yy119;\n  Window* yy147;\n  SrcList* yy167;\n  Upsert* yy266;\n  struct FrameBound yy317;\n  IdList* yy336;\n  struct TrigEvent yy350;\n  struct {int value; int mask;} yy367;\n  Select* yy423;\n  const char* yy464;\n  Expr* yy490;\n  With* yy499;\n} YYMINORTYPE;\n#ifndef YYSTACKDEPTH\n#define YYSTACKDEPTH 100\n#endif\n#define sqlite3ParserARG_SDECL\n#define sqlite3ParserARG_PDECL\n#define sqlite3ParserARG_PARAM\n#define sqlite3ParserARG_FETCH\n#define sqlite3ParserARG_STORE\n#define sqlite3ParserCTX_SDECL Parse *pParse;\n#define sqlite3ParserCTX_PDECL ,Parse *pParse\n#define sqlite3ParserCTX_PARAM ,pParse\n#define sqlite3ParserCTX_FETCH Parse *pParse=yypParser->pParse;\n#define sqlite3ParserCTX_STORE yypParser->pParse=pParse;\n#define YYFALLBACK 1\n#define YYNSTATE             524\n#define YYNRULE              369\n#define YYNTOKEN             155\n#define YY_MAX_SHIFT         523\n#define YY_MIN_SHIFTREDUCE   760\n#define YY_MAX_SHIFTREDUCE   1128\n#define YY_ERROR_ACTION      1129\n#define YY_ACCEPT_ACTION     1130\n#define YY_NO_ACTION         1131\n#define YY_MIN_REDUCE        1132\n#define YY_MAX_REDUCE        1500\n/************* End control #defines *******************************************/\n#define YY_NLOOKAHEAD ((int)(sizeof(yy_lookahead)/sizeof(yy_lookahead[0])))\n\n/* Define the yytestcase() macro to be a no-op if is not already defined\n** otherwise.\n**\n** Applications can choose to define yytestcase() in the %include section\n** to a macro that can assist in verifying code coverage.  For production\n** code the yytestcase() macro should be turned off.  But it is useful\n** for testing.\n*/\n#ifndef yytestcase\n# define yytestcase(X)\n#endif\n\n\n/* Next are the tables used to determine what action to take based on the\n** current state and lookahead token.  These tables are used to implement\n** functions that take a state number and lookahead value and return an\n** action integer.  \n**\n** Suppose the action integer is N.  Then the action is determined as\n** follows\n**\n**   0 <= N <= YY_MAX_SHIFT             Shift N.  That is, push the lookahead\n**                                      token onto the stack and goto state N.\n**\n**   N between YY_MIN_SHIFTREDUCE       Shift to an arbitrary state then\n**     and YY_MAX_SHIFTREDUCE           reduce by rule N-YY_MIN_SHIFTREDUCE.\n**\n**   N == YY_ERROR_ACTION               A syntax error has occurred.\n**\n**   N == YY_ACCEPT_ACTION              The parser accepts its input.\n**\n**   N == YY_NO_ACTION                  No such action.  Denotes unused\n**                                      slots in the yy_action[] table.\n**\n**   N between YY_MIN_REDUCE            Reduce by rule N-YY_MIN_REDUCE\n**     and YY_MAX_REDUCE\n**\n** The action table is constructed as a single large table named yy_action[].\n** Given state S and lookahead X, the action is computed as either:\n**\n**    (A)   N = yy_action[ yy_shift_ofst[S] + X ]\n**    (B)   N = yy_default[S]\n**\n** The (A) formula is preferred.  The B formula is used instead if\n** yy_lookahead[yy_shift_ofst[S]+X] is not equal to X.\n**\n** The formulas above are for computing the action when the lookahead is\n** a terminal symbol.  If the lookahead is a non-terminal (as occurs after\n** a reduce action) then the yy_reduce_ofst[] array is used in place of\n** the yy_shift_ofst[] array.\n**\n** The following are the tables generated in this section:\n**\n**  yy_action[]        A single table containing all actions.\n**  yy_lookahead[]     A table containing the lookahead for each entry in\n**                     yy_action.  Used to detect hash collisions.\n**  yy_shift_ofst[]    For each state, the offset into yy_action for\n**                     shifting terminals.\n**  yy_reduce_ofst[]   For each state, the offset into yy_action for\n**                     shifting non-terminals after a reduce.\n**  yy_default[]       Default action for each state.\n**\n*********** Begin parsing tables **********************************************/\n#define YY_ACTTAB_COUNT (2009)\nstatic const YYACTIONTYPE yy_action[] = {\n /*     0 */   377,  518,  371,  107,  104,  200, 1293,  518, 1130,    1,\n /*    10 */     1,  523,    2, 1134,  518, 1203, 1203, 1262,  277,  373,\n /*    20 */   129,  495,   37,   37, 1397, 1201, 1201, 1211,   65,   65,\n /*    30 */   480,  891,  107,  104,  200,   37,   37, 1043, 1494,  892,\n /*    40 */   346, 1494,  342,  114,  115,  105, 1106, 1106,  957,  960,\n /*    50 */   950,  950,  112,  112,  113,  113,  113,  113,  285,  254,\n /*    60 */   254,  518,  254,  254,  500,  518,  495,  518,  107,  104,\n /*    70 */   200, 1085,  515,  481,  386,  515, 1464,  442,  501,  230,\n /*    80 */   197,  439,   37,   37, 1172,  210,   65,   65,   65,   65,\n /*    90 */   254,  254,  111,  111,  111,  111,  110,  110,  109,  109,\n /*   100 */   109,  108,  404,  515,  404,  155, 1041,  431,  401,  400,\n /*   110 */   254,  254,  373, 1431, 1427,  408, 1110, 1085, 1086, 1087,\n /*   120 */   284, 1112,  500,  515,  500,  368, 1433, 1421, 1428, 1111,\n /*   130 */  1261,  499,  373,  502,  108,  404,  114,  115,  105, 1106,\n /*   140 */  1106,  957,  960,  950,  950,  112,  112,  113,  113,  113,\n /*   150 */   113,  276,  509, 1113,  369, 1113,  114,  115,  105, 1106,\n /*   160 */  1106,  957,  960,  950,  950,  112,  112,  113,  113,  113,\n /*   170 */   113,  496, 1420, 1431,  493, 1468, 1065,  260, 1063,  433,\n /*   180 */    74,  107,  104,  200,  498,  111,  111,  111,  111,  110,\n /*   190 */   110,  109,  109,  109,  108,  404,  373,  113,  113,  113,\n /*   200 */   113,  106,  131,   91, 1361,  111,  111,  111,  111,  110,\n /*   210 */   110,  109,  109,  109,  108,  404,  113,  113,  113,  113,\n /*   220 */   114,  115,  105, 1106, 1106,  957,  960,  950,  950,  112,\n /*   230 */   112,  113,  113,  113,  113,  111,  111,  111,  111,  110,\n /*   240 */   110,  109,  109,  109,  108,  404,  116,  110,  110,  109,\n /*   250 */   109,  109,  108,  404,  111,  111,  111,  111,  110,  110,\n /*   260 */   109,  109,  109,  108,  404,  917,  512,  512,  512,  111,\n /*   270 */   111,  111,  111,  110,  110,  109,  109,  109,  108,  404,\n /*   280 */   517, 1198, 1177,  181,  109,  109,  109,  108,  404,  373,\n /*   290 */  1198,  402,  402,  402,   75,  360,  111,  111,  111,  111,\n /*   300 */   110,  110,  109,  109,  109,  108,  404,  382,  299,  419,\n /*   310 */   287,  170,  518,  114,  115,  105, 1106, 1106,  957,  960,\n /*   320 */   950,  950,  112,  112,  113,  113,  113,  113, 1444,  523,\n /*   330 */     2, 1134,  518,   13,   13,  337,  277, 1085,  129,  226,\n /*   340 */   937, 1058, 1000,  471,  917, 1211,  453,  384, 1085,  395,\n /*   350 */   162, 1057,  155,   45,   45,  416,  928,  401,  400,  479,\n /*   360 */   927,   12,  111,  111,  111,  111,  110,  110,  109,  109,\n /*   370 */   109,  108,  404,  226,  286,  254,  254,  254,  254,  518,\n /*   380 */    16,   16,  373, 1085, 1086, 1087,  314,  299,  515,  472,\n /*   390 */   515,  927,  927,  929, 1085, 1086, 1087,  378,  276,  509,\n /*   400 */    65,   65, 1113,  210, 1113, 1085,  114,  115,  105, 1106,\n /*   410 */  1106,  957,  960,  950,  950,  112,  112,  113,  113,  113,\n /*   420 */   113, 1448,  222, 1134, 1089,  461,  458,  457,  277,  180,\n /*   430 */   129,  378,  392,  408,  423,  456,  500, 1211,  240,  257,\n /*   440 */   324,  464,  319,  463,  227,  470,   12,  317,  424,  300,\n /*   450 */   317, 1085, 1086, 1087,  485,  111,  111,  111,  111,  110,\n /*   460 */   110,  109,  109,  109,  108,  404,  181,  118, 1085,  254,\n /*   470 */   254, 1089,  518,   90,  351,  373,  518, 1181,  365,  798,\n /*   480 */  1440,  339,  515,  248,  248,   77,  325,  133, 1085,  249,\n /*   490 */   424,  300,  794,   49,   49,  210,  515,   65,   65,  114,\n /*   500 */   115,  105, 1106, 1106,  957,  960,  950,  950,  112,  112,\n /*   510 */   113,  113,  113,  113, 1085, 1086, 1087,  222, 1085,  438,\n /*   520 */   461,  458,  457,  937,  787,  408,  171,  857,  362, 1021,\n /*   530 */   456,  136,  198,  486, 1085, 1086, 1087,  448,  794,  928,\n /*   540 */     5,  193,  192,  927, 1022,  107,  104,  200,  111,  111,\n /*   550 */   111,  111,  110,  110,  109,  109,  109,  108,  404, 1023,\n /*   560 */   254,  254,  803, 1085, 1085, 1086, 1087,  437,  373, 1085,\n /*   570 */   344,  787,  791,  515,  927,  927,  929, 1085, 1408, 1396,\n /*   580 */   832, 1085,  176,    3,  852, 1085,  518, 1439,  429,  851,\n /*   590 */   833,  518,  114,  115,  105, 1106, 1106,  957,  960,  950,\n /*   600 */   950,  112,  112,  113,  113,  113,  113,   13,   13, 1085,\n /*   610 */  1086, 1087,   13,   13,  518, 1085, 1086, 1087, 1496,  358,\n /*   620 */  1085,  389, 1234, 1085, 1086, 1087,  391, 1085, 1086, 1087,\n /*   630 */   448, 1085, 1086, 1087,  518,   65,   65,  947,  947,  958,\n /*   640 */   961,  111,  111,  111,  111,  110,  110,  109,  109,  109,\n /*   650 */   108,  404,  518,  382,  878,   13,   13,  518,  877,  518,\n /*   660 */   263,  373,  518,  431,  448, 1070, 1085, 1086, 1087,  267,\n /*   670 */   448,  488, 1360,   64,   64,  431,  812,  155,   50,   50,\n /*   680 */    65,   65,  518,   65,   65,  114,  115,  105, 1106, 1106,\n /*   690 */   957,  960,  950,  950,  112,  112,  113,  113,  113,  113,\n /*   700 */   518,  951,  382,   13,   13,  415,  411,  462,  414, 1085,\n /*   710 */  1366,  777, 1210,  292,  297,  813,  399,  497,  181,  403,\n /*   720 */   261,   15,   15,  276,  509,  414,  413, 1366, 1368,  410,\n /*   730 */   372,  345, 1209,  264,  111,  111,  111,  111,  110,  110,\n /*   740 */   109,  109,  109,  108,  404,  265,  254,  254,  229, 1405,\n /*   750 */   268, 1215,  268, 1103,  373, 1085, 1086, 1087,  938,  515,\n /*   760 */   393,  409,  876,  515,  254,  254, 1152,  482,  473,  262,\n /*   770 */   422,  476,  325,  503,  289,  518,  291,  515,  114,  115,\n /*   780 */   105, 1106, 1106,  957,  960,  950,  950,  112,  112,  113,\n /*   790 */   113,  113,  113,  414, 1021, 1366,   39,   39,  254,  254,\n /*   800 */   254,  254,  980,  254,  254,  254,  254,  255,  255, 1022,\n /*   810 */   279,  515,  516,  515,  846,  846,  515,  138,  515,  518,\n /*   820 */   515, 1043, 1495,  251, 1023, 1495,  876,  111,  111,  111,\n /*   830 */   111,  110,  110,  109,  109,  109,  108,  404,  518, 1353,\n /*   840 */    51,   51,  518,  199,  518,  506,  290,  373,  518,  276,\n /*   850 */   509,  922,    9,  483,  233, 1005, 1005,  445,  189,   52,\n /*   860 */    52,  325,  280,   53,   53,   54,   54,  373,  876,   55,\n /*   870 */    55,  114,  115,  105, 1106, 1106,  957,  960,  950,  950,\n /*   880 */   112,  112,  113,  113,  113,  113,   97,  518,   95, 1104,\n /*   890 */  1041,  114,  115,  105, 1106, 1106,  957,  960,  950,  950,\n /*   900 */   112,  112,  113,  113,  113,  113,  135,  199,   56,   56,\n /*   910 */   765,  766,  767,  225,  224,  223,  518,  283,  437,  233,\n /*   920 */   111,  111,  111,  111,  110,  110,  109,  109,  109,  108,\n /*   930 */   404, 1002,  876,  326,  518, 1002, 1104,   40,   40,  518,\n /*   940 */   111,  111,  111,  111,  110,  110,  109,  109,  109,  108,\n /*   950 */   404,  518,  448,  518, 1104,   41,   41,  518,   17,  518,\n /*   960 */    43,   43, 1155,  379,  518,  448,  518,  443,  518,  390,\n /*   970 */   518,  194,   44,   44,   57,   57, 1247,  518,   58,   58,\n /*   980 */    59,   59,  518,  466,  326,   14,   14,   60,   60,  120,\n /*   990 */   120,   61,   61,  449, 1206,   93,  518,  425,   46,   46,\n /*  1000 */   518, 1104,  518,   62,   62,  518,  437,  305,  518,  852,\n /*  1010 */   518,  298,  518, 1246,  851,  373,  518,   63,   63, 1293,\n /*  1020 */   397,   47,   47,  142,  142, 1467,  143,  143,  821,   70,\n /*  1030 */    70,   48,   48,   66,   66,  373,  518,  121,  121,  114,\n /*  1040 */   115,  105, 1106, 1106,  957,  960,  950,  950,  112,  112,\n /*  1050 */   113,  113,  113,  113,  518,  418,  518,   67,   67,  114,\n /*  1060 */   115,  105, 1106, 1106,  957,  960,  950,  950,  112,  112,\n /*  1070 */   113,  113,  113,  113,  312,  122,  122,  123,  123, 1293,\n /*  1080 */   518,  357, 1126,   88,  518,  435,  325,  387,  111,  111,\n /*  1090 */   111,  111,  110,  110,  109,  109,  109,  108,  404,  266,\n /*  1100 */   518,  119,  119,  518, 1293,  141,  141,  518,  111,  111,\n /*  1110 */   111,  111,  110,  110,  109,  109,  109,  108,  404,  518,\n /*  1120 */   801,  140,  140,  518,  127,  127,  511,  379,  126,  126,\n /*  1130 */   518,  137,  518, 1308,  518,  307,  518,  310,  518,  203,\n /*  1140 */   124,  124, 1307,   96,  125,  125,  207,  388, 1441,  468,\n /*  1150 */  1127,   69,   69,   71,   71,   68,   68,   38,   38,   42,\n /*  1160 */    42,  357, 1042,  373, 1293,  276,  509,  801,  185,  469,\n /*  1170 */   494,  436,  444,    6,  380,  156,  253,  197,  469,  134,\n /*  1180 */   426,   33, 1038,  373, 1121,  359, 1411,  114,  115,  105,\n /*  1190 */  1106, 1106,  957,  960,  950,  950,  112,  112,  113,  113,\n /*  1200 */   113,  113,  914,  296,   27,  293,   90,  114,  103,  105,\n /*  1210 */  1106, 1106,  957,  960,  950,  950,  112,  112,  113,  113,\n /*  1220 */   113,  113,  919,  275,  430,  232,  891,  232,  432,  256,\n /*  1230 */  1127,  232,  398,  370,  892,   28,  111,  111,  111,  111,\n /*  1240 */   110,  110,  109,  109,  109,  108,  404,  301,  454, 1385,\n /*  1250 */    90,  228,  209,  987,  811,  810,  111,  111,  111,  111,\n /*  1260 */   110,  110,  109,  109,  109,  108,  404,  315,  818,  819,\n /*  1270 */    90,  323,  983,  931,  885,  228,  373,  232,  999,  849,\n /*  1280 */   999,  322,  102,  998, 1384,  998,  785,  850,  440,  132,\n /*  1290 */   102,  302, 1243,  306,  309,  311,  373,  313, 1194, 1180,\n /*  1300 */   987,  115,  105, 1106, 1106,  957,  960,  950,  950,  112,\n /*  1310 */   112,  113,  113,  113,  113, 1178, 1179,  318,  327,  328,\n /*  1320 */   931, 1255,  105, 1106, 1106,  957,  960,  950,  950,  112,\n /*  1330 */   112,  113,  113,  113,  113, 1292, 1230, 1457,  273, 1241,\n /*  1340 */   504,  505, 1298,  100,  510,  246,    4, 1161, 1154,  111,\n /*  1350 */   111,  111,  111,  110,  110,  109,  109,  109,  108,  404,\n /*  1360 */   513, 1143,  187, 1142,  202, 1144, 1451,  356, 1227,  111,\n /*  1370 */   111,  111,  111,  110,  110,  109,  109,  109,  108,  404,\n /*  1380 */    11, 1277,  330,  405,  332,  334,  191, 1285,  364,  195,\n /*  1390 */   295,  417,  288,  100,  510,  507,    4,  434,  459,  321,\n /*  1400 */  1177,  349, 1357, 1356,  336,  155,  190, 1454, 1121,  158,\n /*  1410 */   513,  508,  235, 1404,  937, 1402, 1118,  381,   77,  428,\n /*  1420 */    98,   98,    8, 1282,  168,   30,  152,   99,  160,  405,\n /*  1430 */   520,  519,   88,  405,  927, 1362, 1274,  420,  163,   73,\n /*  1440 */   164,   76,  165,  166,  421,  507,  452,  212,  361,  363,\n /*  1450 */   427,  276,  509,   31, 1288,  172,  491,  441,  216, 1351,\n /*  1460 */    82,  490,  447, 1373,  937,  927,  927,  929,  930,   24,\n /*  1470 */    98,   98,  304,  247,  218,  177,  308,   99,  219,  405,\n /*  1480 */   520,  519,  450, 1145,  927,  220,  366, 1197,  100,  510,\n /*  1490 */   465,    4, 1188, 1196, 1195,  394,  803, 1169, 1187,  367,\n /*  1500 */  1168,  396,  484,  320, 1167,  513, 1466,   87,  475,  100,\n /*  1510 */   510,  271,    4,  272,  478,  927,  927,  929,  930,   24,\n /*  1520 */  1443, 1074,  407, 1238, 1239,  258,  513,  329,  405,  331,\n /*  1530 */   355,  355,  354,  243,  352,  234,  489,  774,  498,  184,\n /*  1540 */   507,  338, 1422,  339,  117, 1220,   10,  341,  333,  405,\n /*  1550 */   204,  491,  282, 1219, 1237, 1236,  492,  335,  343,  937,\n /*  1560 */   281,  507,   94, 1337,  186,   98,   98,  347,   89,  487,\n /*  1570 */   348,  241,   99,   29,  405,  520,  519,  274, 1151,  927,\n /*  1580 */   937,  521, 1080,  245,  242,  244,   98,   98,  856,  522,\n /*  1590 */   206, 1140, 1135,   99,  144,  405,  520,  519,  147,  375,\n /*  1600 */   927,  149,  376,  157, 1389, 1390, 1388, 1387,  205,  145,\n /*  1610 */   927,  927,  929,  930,   24,  146,  130,  761, 1165, 1164,\n /*  1620 */    72,  100,  510, 1162,    4,  269,  406,  188,  278,  201,\n /*  1630 */   259,  927,  927,  929,  930,   24,  128,  911,  513,  997,\n /*  1640 */   995,  159,  374,  208,  148,  161,  835,  276,  509,  211,\n /*  1650 */   294, 1011,  915,  167,  150,  383,  169,   78,  385,   79,\n /*  1660 */    80,  405,   81,  151, 1014,  213,  214, 1010,  139,   18,\n /*  1670 */   412,  215,  303,  507,  232, 1115, 1003,  446,  173,  217,\n /*  1680 */   174,   32,  776,  451,  491,  322,  221,  175,  814,  490,\n /*  1690 */    83,  455,  937,   19,  460,  316,   20,   84,   98,   98,\n /*  1700 */   270,  182,   85,  467,  153,   99,  154,  405,  520,  519,\n /*  1710 */  1074,  407,  927,  183,  258,  963, 1046,   86,   34,  355,\n /*  1720 */   355,  354,  243,  352,  474, 1047,  774,   35,  477,  196,\n /*  1730 */   250,  100,  510,  252,    4,  884,  178,  231, 1060,  204,\n /*  1740 */    21,  282,  102,  927,  927,  929,  930,   24,  513,  281,\n /*  1750 */   879,   22, 1064, 1062, 1051,    7,  340,   23,  978,  179,\n /*  1760 */    90,   92,  510,  964,    4,  236,  962,  966, 1020, 1019,\n /*  1770 */   237,  405,  967,   25,   36,  514,  932,  786,  513,  206,\n /*  1780 */   101,   26,  845,  507,  238,  239, 1459,  147,  350, 1458,\n /*  1790 */   149,  353, 1075, 1131, 1131, 1131, 1131,  205, 1131, 1131,\n /*  1800 */  1131,  405,  937, 1131, 1131, 1131, 1131, 1131,   98,   98,\n /*  1810 */  1131, 1131, 1131,  507, 1131,   99, 1131,  405,  520,  519,\n /*  1820 */  1131, 1131,  927, 1131, 1131, 1131, 1131, 1131, 1131, 1131,\n /*  1830 */  1131,  374,  937, 1131, 1131, 1131,  276,  509,   98,   98,\n /*  1840 */  1131, 1131, 1131, 1131, 1131,   99, 1131,  405,  520,  519,\n /*  1850 */  1131, 1131,  927,  927,  927,  929,  930,   24, 1131,  412,\n /*  1860 */  1131, 1131, 1131,  258, 1131, 1131, 1131, 1131,  355,  355,\n /*  1870 */   354,  243,  352, 1131, 1131,  774, 1131, 1131, 1131, 1131,\n /*  1880 */  1131, 1131, 1131,  927,  927,  929,  930,   24,  204, 1131,\n /*  1890 */   282, 1131, 1131, 1131, 1131, 1131, 1131, 1131,  281, 1131,\n /*  1900 */  1131, 1131, 1131, 1131, 1131, 1131, 1131, 1131, 1131, 1131,\n /*  1910 */  1131, 1131, 1131, 1131, 1131, 1131, 1131, 1131, 1131, 1131,\n /*  1920 */  1131, 1131, 1131, 1131, 1131, 1131, 1131, 1131,  206, 1131,\n /*  1930 */  1131, 1131, 1131, 1131, 1131, 1131,  147, 1131, 1131,  149,\n /*  1940 */  1131, 1131, 1131, 1131, 1131, 1131,  205, 1131, 1131, 1131,\n /*  1950 */  1131, 1131, 1131, 1131, 1131, 1131, 1131, 1131, 1131, 1131,\n /*  1960 */  1131, 1131, 1131, 1131, 1131, 1131, 1131, 1131, 1131, 1131,\n /*  1970 */  1131, 1131, 1131, 1131, 1131, 1131, 1131, 1131, 1131, 1131,\n /*  1980 */   374, 1131, 1131, 1131, 1131,  276,  509, 1131, 1131, 1131,\n /*  1990 */  1131, 1131, 1131, 1131, 1131, 1131, 1131, 1131, 1131, 1131,\n /*  2000 */  1131, 1131, 1131, 1131, 1131, 1131, 1131, 1131,  412,\n};\nstatic const YYCODETYPE yy_lookahead[] = {\n /*     0 */   168,  163,  184,  238,  239,  240,  163,  163,  155,  156,\n /*    10 */   157,  158,  159,  160,  163,  202,  203,  187,  165,   19,\n /*    20 */   167,  163,  184,  185,  259,  202,  203,  174,  184,  185,\n /*    30 */   174,   31,  238,  239,  240,  184,  185,   22,   23,   39,\n /*    40 */   216,   26,  218,   43,   44,   45,   46,   47,   48,   49,\n /*    50 */    50,   51,   52,   53,   54,   55,   56,   57,  174,  206,\n /*    60 */   207,  163,  206,  207,  220,  163,  163,  163,  238,  239,\n /*    70 */   240,   59,  219,  229,  231,  219,  183,  245,  174,  223,\n /*    80 */   224,  249,  184,  185,  191,  232,  184,  185,  184,  185,\n /*    90 */   206,  207,   92,   93,   94,   95,   96,   97,   98,   99,\n /*   100 */   100,  101,  102,  219,  102,   81,   91,  163,   96,   97,\n /*   110 */   206,  207,   19,  275,  276,  262,  104,  105,  106,  107,\n /*   120 */   163,  109,  220,  219,  220,  184,  275,  269,  277,  117,\n /*   130 */   187,  229,   19,  229,  101,  102,   43,   44,   45,   46,\n /*   140 */    47,   48,   49,   50,   51,   52,   53,   54,   55,   56,\n /*   150 */    57,  127,  128,  141,  184,  143,   43,   44,   45,   46,\n /*   160 */    47,   48,   49,   50,   51,   52,   53,   54,   55,   56,\n /*   170 */    57,  268,  269,  275,  276,  197,   83,  233,   85,  163,\n /*   180 */    67,  238,  239,  240,  134,   92,   93,   94,   95,   96,\n /*   190 */    97,   98,   99,  100,  101,  102,   19,   54,   55,   56,\n /*   200 */    57,   58,  152,   26,  247,   92,   93,   94,   95,   96,\n /*   210 */    97,   98,   99,  100,  101,  102,   54,   55,   56,   57,\n /*   220 */    43,   44,   45,   46,   47,   48,   49,   50,   51,   52,\n /*   230 */    53,   54,   55,   56,   57,   92,   93,   94,   95,   96,\n /*   240 */    97,   98,   99,  100,  101,  102,   69,   96,   97,   98,\n /*   250 */    99,  100,  101,  102,   92,   93,   94,   95,   96,   97,\n /*   260 */    98,   99,  100,  101,  102,   73,  179,  180,  181,   92,\n /*   270 */    93,   94,   95,   96,   97,   98,   99,  100,  101,  102,\n /*   280 */   163,  191,  192,  163,   98,   99,  100,  101,  102,   19,\n /*   290 */   200,  179,  180,  181,   24,  175,   92,   93,   94,   95,\n /*   300 */    96,   97,   98,   99,  100,  101,  102,  163,  116,  117,\n /*   310 */   118,   22,  163,   43,   44,   45,   46,   47,   48,   49,\n /*   320 */    50,   51,   52,   53,   54,   55,   56,   57,  157,  158,\n /*   330 */   159,  160,  163,  184,  185,  163,  165,   59,  167,   46,\n /*   340 */    90,   76,   11,  174,   73,  174,   19,  198,   59,   19,\n /*   350 */    72,   86,   81,  184,  185,  234,  106,   96,   97,  163,\n /*   360 */   110,  182,   92,   93,   94,   95,   96,   97,   98,   99,\n /*   370 */   100,  101,  102,   46,  230,  206,  207,  206,  207,  163,\n /*   380 */   184,  185,   19,  105,  106,  107,   23,  116,  219,  220,\n /*   390 */   219,  141,  142,  143,  105,  106,  107,  104,  127,  128,\n /*   400 */   184,  185,  141,  232,  143,   59,   43,   44,   45,   46,\n /*   410 */    47,   48,   49,   50,   51,   52,   53,   54,   55,   56,\n /*   420 */    57,  158,  108,  160,   59,  111,  112,  113,  165,  250,\n /*   430 */   167,  104,  102,  262,  255,  121,  220,  174,  108,  109,\n /*   440 */   110,  111,  112,  113,  114,  229,  182,  120,  117,  118,\n /*   450 */   120,  105,  106,  107,  163,   92,   93,   94,   95,   96,\n /*   460 */    97,   98,   99,  100,  101,  102,  163,   22,   59,  206,\n /*   470 */   207,  106,  163,   26,  171,   19,  163,  193,  175,   23,\n /*   480 */   163,   22,  219,  206,  207,  139,  163,   22,   59,  182,\n /*   490 */   117,  118,   59,  184,  185,  232,  219,  184,  185,   43,\n /*   500 */    44,   45,   46,   47,   48,   49,   50,   51,   52,   53,\n /*   510 */    54,   55,   56,   57,  105,  106,  107,  108,   59,  255,\n /*   520 */   111,  112,  113,   90,   59,  262,   22,   98,  174,   12,\n /*   530 */   121,  208,  163,  220,  105,  106,  107,  163,  105,  106,\n /*   540 */    22,   96,   97,  110,   27,  238,  239,  240,   92,   93,\n /*   550 */    94,   95,   96,   97,   98,   99,  100,  101,  102,   42,\n /*   560 */   206,  207,  115,   59,  105,  106,  107,  163,   19,   59,\n /*   570 */   163,  106,   23,  219,  141,  142,  143,   59,  163,  205,\n /*   580 */    63,   59,   72,   22,  124,   59,  163,  270,  234,  129,\n /*   590 */    73,  163,   43,   44,   45,   46,   47,   48,   49,   50,\n /*   600 */    51,   52,   53,   54,   55,   56,   57,  184,  185,  105,\n /*   610 */   106,  107,  184,  185,  163,  105,  106,  107,  265,  266,\n /*   620 */    59,  198,  225,  105,  106,  107,  198,  105,  106,  107,\n /*   630 */   163,  105,  106,  107,  163,  184,  185,   46,   47,   48,\n /*   640 */    49,   92,   93,   94,   95,   96,   97,   98,   99,  100,\n /*   650 */   101,  102,  163,  163,  132,  184,  185,  163,  132,  163,\n /*   660 */   256,   19,  163,  163,  163,   23,  105,  106,  107,  198,\n /*   670 */   163,  220,  205,  184,  185,  163,   35,   81,  184,  185,\n /*   680 */   184,  185,  163,  184,  185,   43,   44,   45,   46,   47,\n /*   690 */    48,   49,   50,   51,   52,   53,   54,   55,   56,   57,\n /*   700 */   163,  110,  163,  184,  185,  109,  205,   66,  163,   59,\n /*   710 */   163,   21,  205,   16,  174,   74,  220,  198,  163,  220,\n /*   720 */   230,  184,  185,  127,  128,  180,  181,  180,  181,  163,\n /*   730 */   175,  242,  174,  233,   92,   93,   94,   95,   96,   97,\n /*   740 */    98,   99,  100,  101,  102,  233,  206,  207,   26,  163,\n /*   750 */   195,  207,  197,   26,   19,  105,  106,  107,   23,  219,\n /*   760 */   119,  260,   26,  219,  206,  207,  174,   19,  174,  230,\n /*   770 */    80,  174,  163,  174,   77,  163,   79,  219,   43,   44,\n /*   780 */    45,   46,   47,   48,   49,   50,   51,   52,   53,   54,\n /*   790 */    55,   56,   57,  248,   12,  248,  184,  185,  206,  207,\n /*   800 */   206,  207,  112,  206,  207,  206,  207,  206,  207,   27,\n /*   810 */   163,  219,  123,  219,  125,  126,  219,  208,  219,  163,\n /*   820 */   219,   22,   23,   23,   42,   26,   26,   92,   93,   94,\n /*   830 */    95,   96,   97,   98,   99,  100,  101,  102,  163,  149,\n /*   840 */   184,  185,  163,  107,  163,   63,  149,   19,  163,  127,\n /*   850 */   128,   23,   22,  105,   24,  116,  117,  118,  131,  184,\n /*   860 */   185,  163,  163,  184,  185,  184,  185,   19,  132,  184,\n /*   870 */   185,   43,   44,   45,   46,   47,   48,   49,   50,   51,\n /*   880 */    52,   53,   54,   55,   56,   57,  146,  163,  148,   59,\n /*   890 */    91,   43,   44,   45,   46,   47,   48,   49,   50,   51,\n /*   900 */    52,   53,   54,   55,   56,   57,  208,  107,  184,  185,\n /*   910 */     7,    8,    9,  116,  117,  118,  163,  163,  163,   24,\n /*   920 */    92,   93,   94,   95,   96,   97,   98,   99,  100,  101,\n /*   930 */   102,   29,  132,  163,  163,   33,  106,  184,  185,  163,\n /*   940 */    92,   93,   94,   95,   96,   97,   98,   99,  100,  101,\n /*   950 */   102,  163,  163,  163,   59,  184,  185,  163,   22,  163,\n /*   960 */   184,  185,  177,  178,  163,  163,  163,   65,  163,  199,\n /*   970 */   163,   26,  184,  185,  184,  185,  163,  163,  184,  185,\n /*   980 */   184,  185,  163,   98,  163,  184,  185,  184,  185,  184,\n /*   990 */   185,  184,  185,  252,  205,  147,  163,   61,  184,  185,\n /*  1000 */   163,  106,  163,  184,  185,  163,  163,  205,  163,  124,\n /*  1010 */   163,  256,  163,  163,  129,   19,  163,  184,  185,  163,\n /*  1020 */   199,  184,  185,  184,  185,   23,  184,  185,   26,  184,\n /*  1030 */   185,  184,  185,  184,  185,   19,  163,  184,  185,   43,\n /*  1040 */    44,   45,   46,   47,   48,   49,   50,   51,   52,   53,\n /*  1050 */    54,   55,   56,   57,  163,  163,  163,  184,  185,   43,\n /*  1060 */    44,   45,   46,   47,   48,   49,   50,   51,   52,   53,\n /*  1070 */    54,   55,   56,   57,   16,  184,  185,  184,  185,  163,\n /*  1080 */   163,   22,   23,  138,  163,   19,  163,  231,   92,   93,\n /*  1090 */    94,   95,   96,   97,   98,   99,  100,  101,  102,  256,\n /*  1100 */   163,  184,  185,  163,  163,  184,  185,  163,   92,   93,\n /*  1110 */    94,   95,   96,   97,   98,   99,  100,  101,  102,  163,\n /*  1120 */    59,  184,  185,  163,  184,  185,  177,  178,  184,  185,\n /*  1130 */   163,  208,  163,  237,  163,   77,  163,   79,  163,   15,\n /*  1140 */   184,  185,  237,  147,  184,  185,   24,  231,  153,  154,\n /*  1150 */    91,  184,  185,  184,  185,  184,  185,  184,  185,  184,\n /*  1160 */   185,   22,   23,   19,  163,  127,  128,  106,   24,  273,\n /*  1170 */   271,  105,  231,  274,  263,  264,  223,  224,  273,   22,\n /*  1180 */   118,   24,   23,   19,   60,   26,  163,   43,   44,   45,\n /*  1190 */    46,   47,   48,   49,   50,   51,   52,   53,   54,   55,\n /*  1200 */    56,   57,  140,   23,   22,  163,   26,   43,   44,   45,\n /*  1210 */    46,   47,   48,   49,   50,   51,   52,   53,   54,   55,\n /*  1220 */    56,   57,   23,  211,   23,   26,   31,   26,   23,   22,\n /*  1230 */    91,   26,  231,  221,   39,   53,   92,   93,   94,   95,\n /*  1240 */    96,   97,   98,   99,  100,  101,  102,   23,   23,  163,\n /*  1250 */    26,   26,  130,   59,  109,  110,   92,   93,   94,   95,\n /*  1260 */    96,   97,   98,   99,  100,  101,  102,   23,    7,    8,\n /*  1270 */    26,  110,   23,   59,   23,   26,   19,   26,  141,   23,\n /*  1280 */   143,  120,   26,  141,  163,  143,   23,   23,  163,   26,\n /*  1290 */    26,  163,  163,  163,  163,  163,   19,  163,  163,  193,\n /*  1300 */   106,   44,   45,   46,   47,   48,   49,   50,   51,   52,\n /*  1310 */    53,   54,   55,   56,   57,  163,  193,  163,  163,  163,\n /*  1320 */   106,  163,   45,   46,   47,   48,   49,   50,   51,   52,\n /*  1330 */    53,   54,   55,   56,   57,  163,  163,  130,  222,  163,\n /*  1340 */   163,  203,  163,   19,   20,  251,   22,  163,  163,   92,\n /*  1350 */    93,   94,   95,   96,   97,   98,   99,  100,  101,  102,\n /*  1360 */    36,  163,  209,  163,  261,  163,  163,  161,  222,   92,\n /*  1370 */    93,   94,   95,   96,   97,   98,   99,  100,  101,  102,\n /*  1380 */   210,  213,  222,   59,  222,  222,  182,  213,  213,  196,\n /*  1390 */   257,  226,  226,   19,   20,   71,   22,  257,  188,  187,\n /*  1400 */   192,  212,  187,  187,  226,   81,  210,  166,   60,  261,\n /*  1410 */    36,  244,  130,  170,   90,  170,   38,  170,  139,  104,\n /*  1420 */    96,   97,   48,  236,   22,  235,   43,  103,  201,  105,\n /*  1430 */   106,  107,  138,   59,  110,  247,  213,   18,  204,  258,\n /*  1440 */   204,  258,  204,  204,  170,   71,   18,  169,  213,  236,\n /*  1450 */   213,  127,  128,  235,  201,  201,   82,  170,  169,  213,\n /*  1460 */   146,   87,   62,  254,   90,  141,  142,  143,  144,  145,\n /*  1470 */    96,   97,  253,  170,  169,   22,  170,  103,  169,  105,\n /*  1480 */   106,  107,  189,  170,  110,  169,  189,  186,   19,   20,\n /*  1490 */   104,   22,  194,  186,  186,   64,  115,  186,  194,  189,\n /*  1500 */   188,  102,  133,  186,  186,   36,  186,  104,  189,   19,\n /*  1510 */    20,  246,   22,  246,  189,  141,  142,  143,  144,  145,\n /*  1520 */     0,    1,    2,  228,  228,    5,   36,  227,   59,  227,\n /*  1530 */    10,   11,   12,   13,   14,  170,   84,   17,  134,  216,\n /*  1540 */    71,  272,  270,   22,  137,  217,   22,  216,  227,   59,\n /*  1550 */    30,   82,   32,  217,  228,  228,   87,  227,  170,   90,\n /*  1560 */    40,   71,  146,  241,  215,   96,   97,  214,  136,  135,\n /*  1570 */   213,   25,  103,   26,  105,  106,  107,  243,  173,  110,\n /*  1580 */    90,  172,   13,    6,  164,  164,   96,   97,   98,  162,\n /*  1590 */    70,  162,  162,  103,  176,  105,  106,  107,   78,  267,\n /*  1600 */   110,   81,  267,  264,  182,  182,  182,  182,   88,  176,\n /*  1610 */   141,  142,  143,  144,  145,  176,  190,    4,  182,  182,\n /*  1620 */   182,   19,   20,  182,   22,  190,    3,   22,  151,   15,\n /*  1630 */    89,  141,  142,  143,  144,  145,   16,  128,   36,   23,\n /*  1640 */    23,  139,  122,   24,  119,  131,   20,  127,  128,  133,\n /*  1650 */    16,    1,  140,  131,  119,   61,  139,   53,   37,   53,\n /*  1660 */    53,   59,   53,  119,  105,   34,  130,    1,    5,   22,\n /*  1670 */   150,  104,  149,   71,   26,   75,   68,   41,   68,  130,\n /*  1680 */   104,   24,   20,   19,   82,  120,  114,   22,   28,   87,\n /*  1690 */    22,   67,   90,   22,   67,   23,   22,   22,   96,   97,\n /*  1700 */    67,   23,  138,   22,   37,  103,  153,  105,  106,  107,\n /*  1710 */     1,    2,  110,   23,    5,   23,   23,   26,   22,   10,\n /*  1720 */    11,   12,   13,   14,   24,   23,   17,   22,   24,  130,\n /*  1730 */    23,   19,   20,   23,   22,  105,   22,   34,   85,   30,\n /*  1740 */    34,   32,   26,  141,  142,  143,  144,  145,   36,   40,\n /*  1750 */   132,   34,   75,   83,   23,   44,   24,   34,   23,   26,\n /*  1760 */    26,   19,   20,   23,   22,   26,   23,   23,   23,   23,\n /*  1770 */    22,   59,   11,   22,   22,   26,   23,   23,   36,   70,\n /*  1780 */    22,   22,  124,   71,  130,  130,  130,   78,   23,  130,\n /*  1790 */    81,   15,    1,  278,  278,  278,  278,   88,  278,  278,\n /*  1800 */   278,   59,   90,  278,  278,  278,  278,  278,   96,   97,\n /*  1810 */   278,  278,  278,   71,  278,  103,  278,  105,  106,  107,\n /*  1820 */   278,  278,  110,  278,  278,  278,  278,  278,  278,  278,\n /*  1830 */   278,  122,   90,  278,  278,  278,  127,  128,   96,   97,\n /*  1840 */   278,  278,  278,  278,  278,  103,  278,  105,  106,  107,\n /*  1850 */   278,  278,  110,  141,  142,  143,  144,  145,  278,  150,\n /*  1860 */   278,  278,  278,    5,  278,  278,  278,  278,   10,   11,\n /*  1870 */    12,   13,   14,  278,  278,   17,  278,  278,  278,  278,\n /*  1880 */   278,  278,  278,  141,  142,  143,  144,  145,   30,  278,\n /*  1890 */    32,  278,  278,  278,  278,  278,  278,  278,   40,  278,\n /*  1900 */   278,  278,  278,  278,  278,  278,  278,  278,  278,  278,\n /*  1910 */   278,  278,  278,  278,  278,  278,  278,  278,  278,  278,\n /*  1920 */   278,  278,  278,  278,  278,  278,  278,  278,   70,  278,\n /*  1930 */   278,  278,  278,  278,  278,  278,   78,  278,  278,   81,\n /*  1940 */   278,  278,  278,  278,  278,  278,   88,  278,  278,  278,\n /*  1950 */   278,  278,  278,  278,  278,  278,  278,  278,  278,  278,\n /*  1960 */   278,  278,  278,  278,  278,  278,  278,  278,  278,  278,\n /*  1970 */   278,  278,  278,  278,  278,  278,  278,  278,  278,  278,\n /*  1980 */   122,  278,  278,  278,  278,  127,  128,  278,  278,  278,\n /*  1990 */   278,  278,  278,  278,  278,  278,  278,  278,  278,  278,\n /*  2000 */   278,  278,  278,  278,  278,  278,  278,  278,  150,  278,\n /*  2010 */   278,  278,  278,  278,  278,  278,  278,  278,  278,\n};\n#define YY_SHIFT_COUNT    (523)\n#define YY_SHIFT_MIN      (0)\n#define YY_SHIFT_MAX      (1858)\nstatic const unsigned short int yy_shift_ofst[] = {\n /*     0 */  1709, 1520, 1858, 1324, 1324,   24, 1374, 1469, 1602, 1712,\n /*    10 */  1712, 1712,  271,    0,    0,  113, 1016, 1712, 1712, 1712,\n /*    20 */  1712, 1712, 1712, 1712, 1712, 1712, 1712,   12,   12,  409,\n /*    30 */   596,   24,   24,   24,   24,   24,   24,   93,  177,  270,\n /*    40 */   363,  456,  549,  642,  735,  828,  848,  996, 1144, 1016,\n /*    50 */  1016, 1016, 1016, 1016, 1016, 1016, 1016, 1016, 1016, 1016,\n /*    60 */  1016, 1016, 1016, 1016, 1016, 1016, 1016, 1164, 1016, 1257,\n /*    70 */  1277, 1277, 1490, 1712, 1712, 1712, 1712, 1712, 1712, 1712,\n /*    80 */  1712, 1712, 1712, 1712, 1712, 1712, 1712, 1712, 1712, 1712,\n /*    90 */  1712, 1712, 1712, 1712, 1712, 1712, 1712, 1712, 1712, 1712,\n /*   100 */  1712, 1712, 1712, 1712, 1712, 1742, 1712, 1712, 1712, 1712,\n /*   110 */  1712, 1712, 1712, 1712, 1712, 1712, 1712, 1712, 1712,  143,\n /*   120 */   162,  162,  162,  162,  162,  204,  151,  186,  650,  690,\n /*   130 */   327,  650,  261,  261,  650,  722,  722,  722,  722,  373,\n /*   140 */    33,    2, 2009, 2009,  330,  330,  330,  346,  289,  278,\n /*   150 */   289,  289,  517,  517,  459,  510,   15,  799,  650,  650,\n /*   160 */   650,  650,  650,  650,  650,  650,  650,  650,  650,  650,\n /*   170 */   650,  650,  650,  650,  650,  650,  650,  650,  650,  650,\n /*   180 */   331,  365,  995,  995,  265,  365,   50, 1038, 2009, 2009,\n /*   190 */  2009,  433,  250,  250,  504,  314,  429,  518,  522,  526,\n /*   200 */   561,  650,  650,  650,  650,  650,  650,  650,  650,  650,\n /*   210 */   192,  650,  650,  650,  650,  650,  650,  650,  650,  650,\n /*   220 */   650,  650,  650,  641,  641,  641,  650,  650,  650,  650,\n /*   230 */   800,  650,  650,  650,  830,  650,  650,  782,  650,  650,\n /*   240 */   650,  650,  650,  650,  650,  650,  739,  902,  689,  895,\n /*   250 */   895,  895,  895,  736,  689,  689,  885,  445,  903, 1124,\n /*   260 */   945,  748,  748, 1066,  945,  945, 1066,  447, 1002,  293,\n /*   270 */  1195, 1195, 1195,  748,  740,  727,  460, 1157, 1348, 1282,\n /*   280 */  1282, 1378, 1378, 1282, 1279, 1315, 1402, 1383, 1294, 1419,\n /*   290 */  1419, 1419, 1419, 1282, 1428, 1294, 1294, 1315, 1402, 1383,\n /*   300 */  1383, 1294, 1282, 1428, 1314, 1400, 1282, 1428, 1453, 1282,\n /*   310 */  1428, 1282, 1428, 1453, 1386, 1386, 1386, 1431, 1453, 1386,\n /*   320 */  1381, 1386, 1431, 1386, 1386, 1453, 1399, 1399, 1453, 1369,\n /*   330 */  1403, 1369, 1403, 1369, 1403, 1369, 1403, 1282, 1404, 1452,\n /*   340 */  1521, 1407, 1404, 1524, 1282, 1416, 1407, 1432, 1434, 1294,\n /*   350 */  1546, 1547, 1569, 1569, 1577, 1577, 1577, 2009, 2009, 2009,\n /*   360 */  2009, 2009, 2009, 2009, 2009, 2009, 2009, 2009, 2009, 2009,\n /*   370 */  2009, 2009, 2009,  591,  697, 1059, 1139, 1058,  797,  465,\n /*   380 */  1159, 1182, 1122, 1062, 1180,  936, 1199, 1201, 1205, 1224,\n /*   390 */  1225, 1244, 1061, 1145, 1261, 1161, 1194, 1249, 1251, 1256,\n /*   400 */  1137, 1142, 1263, 1264, 1214, 1207, 1613, 1623, 1605, 1477,\n /*   410 */  1614, 1541, 1620, 1616, 1617, 1509, 1502, 1525, 1619, 1514,\n /*   420 */  1626, 1516, 1634, 1650, 1522, 1512, 1535, 1594, 1621, 1517,\n /*   430 */  1604, 1606, 1607, 1609, 1544, 1559, 1631, 1536, 1666, 1663,\n /*   440 */  1647, 1567, 1523, 1608, 1648, 1610, 1600, 1636, 1549, 1576,\n /*   450 */  1657, 1662, 1664, 1565, 1572, 1665, 1624, 1668, 1671, 1672,\n /*   460 */  1674, 1627, 1660, 1675, 1633, 1667, 1678, 1564, 1681, 1553,\n /*   470 */  1690, 1692, 1691, 1693, 1696, 1700, 1702, 1705, 1704, 1599,\n /*   480 */  1707, 1710, 1630, 1703, 1714, 1618, 1716, 1706, 1716, 1717,\n /*   490 */  1653, 1677, 1670, 1711, 1731, 1732, 1733, 1734, 1723, 1735,\n /*   500 */  1716, 1740, 1743, 1744, 1745, 1739, 1746, 1748, 1761, 1751,\n /*   510 */  1752, 1753, 1754, 1758, 1759, 1749, 1658, 1654, 1655, 1656,\n /*   520 */  1659, 1765, 1776, 1791,\n};\n#define YY_REDUCE_COUNT (372)\n#define YY_REDUCE_MIN   (-235)\n#define YY_REDUCE_MAX   (1441)\nstatic const short yy_reduce_ofst[] = {\n /*     0 */  -147,  171,  263,  -96,  169, -144, -162, -149, -102, -156,\n /*    10 */   -98,  216,  354, -170,  -57, -235,  307,  149,  423,  428,\n /*    20 */   471,  313,  451,  519,  489,  496,  499,  545,  547,  555,\n /*    30 */  -116,  540,  558,  592,  594,  597,  599, -206, -206, -206,\n /*    40 */  -206, -206, -206, -206, -206, -206, -206, -206, -206, -206,\n /*    50 */  -206, -206, -206, -206, -206, -206, -206, -206, -206, -206,\n /*    60 */  -206, -206, -206, -206, -206, -206, -206, -206, -206, -206,\n /*    70 */  -206, -206,  196,  309,  494,  537,  612,  656,  675,  679,\n /*    80 */   681,  685,  724,  753,  771,  776,  788,  790,  794,  796,\n /*    90 */   801,  803,  805,  807,  814,  819,  833,  837,  839,  842,\n /*   100 */   845,  847,  849,  853,  873,  891,  893,  917,  921,  937,\n /*   110 */   940,  944,  956,  960,  967,  969,  971,  973,  975, -206,\n /*   120 */  -206, -206, -206, -206, -206, -206, -206, -206,  501, -168,\n /*   130 */    90,  -97,   87,  112,  303,  277,  601,  277,  601,  179,\n /*   140 */  -206, -206, -206, -206, -107, -107, -107,  -43,  -56,  323,\n /*   150 */   500,  512, -187, -177,  317,  609,  353,  353,  120,  144,\n /*   160 */   490,  539,  698,  374,  467,  507,  789,  404, -157,  755,\n /*   170 */   856,  916,  843,  941,  802,  770,  923,  821, 1001, -142,\n /*   180 */   264,  785,  896,  905,  899,  949, -176,  544,  911,  953,\n /*   190 */  1012, -182,  -59,  -30,   16,  -22,  117,  172,  291,  369,\n /*   200 */   407,  415,  566,  586,  647,  699,  754,  813,  850,  892,\n /*   210 */   121, 1023, 1042, 1086, 1121, 1125, 1128, 1129, 1130, 1131,\n /*   220 */  1132, 1134, 1135,  284, 1106, 1123, 1152, 1154, 1155, 1156,\n /*   230 */   397, 1158, 1172, 1173, 1116, 1176, 1177, 1138, 1179,  117,\n /*   240 */  1184, 1185, 1198, 1200, 1202, 1203,  741, 1094, 1153, 1146,\n /*   250 */  1160, 1162, 1163,  397, 1153, 1153, 1170, 1204, 1206, 1103,\n /*   260 */  1168, 1165, 1166, 1133, 1174, 1175, 1140, 1210, 1193, 1208,\n /*   270 */  1212, 1215, 1216, 1178, 1167, 1189, 1196, 1241, 1148, 1243,\n /*   280 */  1245, 1181, 1183, 1247, 1188, 1187, 1190, 1227, 1223, 1234,\n /*   290 */  1236, 1238, 1239, 1274, 1278, 1235, 1237, 1213, 1218, 1253,\n /*   300 */  1254, 1246, 1287, 1289, 1209, 1219, 1303, 1305, 1293, 1306,\n /*   310 */  1309, 1313, 1316, 1297, 1301, 1307, 1308, 1298, 1310, 1311,\n /*   320 */  1312, 1317, 1304, 1318, 1320, 1319, 1265, 1267, 1325, 1295,\n /*   330 */  1300, 1296, 1302, 1326, 1321, 1327, 1330, 1365, 1323, 1269,\n /*   340 */  1272, 1328, 1331, 1322, 1388, 1334, 1336, 1349, 1353, 1357,\n /*   350 */  1405, 1409, 1420, 1421, 1427, 1429, 1430, 1332, 1335, 1339,\n /*   360 */  1418, 1422, 1423, 1424, 1425, 1433, 1426, 1435, 1436, 1437,\n /*   370 */  1438, 1441, 1439,\n};\nstatic const YYACTIONTYPE yy_default[] = {\n /*     0 */  1500, 1500, 1500, 1346, 1129, 1235, 1129, 1129, 1129, 1346,\n /*    10 */  1346, 1346, 1129, 1265, 1265, 1399, 1160, 1129, 1129, 1129,\n /*    20 */  1129, 1129, 1129, 1129, 1345, 1129, 1129, 1129, 1129, 1129,\n /*    30 */  1129, 1129, 1129, 1129, 1129, 1129, 1129, 1129, 1271, 1129,\n /*    40 */  1129, 1129, 1129, 1129, 1347, 1348, 1129, 1129, 1129, 1398,\n /*    50 */  1400, 1363, 1281, 1280, 1279, 1278, 1381, 1252, 1276, 1269,\n /*    60 */  1273, 1341, 1342, 1340, 1344, 1348, 1347, 1129, 1272, 1312,\n /*    70 */  1326, 1311, 1129, 1129, 1129, 1129, 1129, 1129, 1129, 1129,\n /*    80 */  1129, 1129, 1129, 1129, 1129, 1129, 1129, 1129, 1129, 1129,\n /*    90 */  1129, 1129, 1129, 1129, 1129, 1129, 1129, 1129, 1129, 1129,\n /*   100 */  1129, 1129, 1129, 1129, 1129, 1129, 1129, 1129, 1129, 1129,\n /*   110 */  1129, 1129, 1129, 1129, 1129, 1129, 1129, 1129, 1129, 1320,\n /*   120 */  1325, 1331, 1324, 1321, 1314, 1313, 1315, 1316, 1129, 1150,\n /*   130 */  1199, 1129, 1129, 1129, 1129, 1417, 1416, 1129, 1129, 1160,\n /*   140 */  1317, 1318, 1328, 1327, 1406, 1456, 1455, 1364, 1129, 1129,\n /*   150 */  1129, 1129, 1129, 1129, 1129, 1129, 1129, 1129, 1129, 1129,\n /*   160 */  1129, 1129, 1129, 1129, 1129, 1129, 1129, 1129, 1129, 1129,\n /*   170 */  1129, 1129, 1129, 1129, 1129, 1129, 1129, 1129, 1129, 1129,\n /*   180 */  1160, 1156, 1306, 1305, 1426, 1156, 1259, 1129, 1412, 1235,\n /*   190 */  1226, 1129, 1129, 1129, 1129, 1129, 1129, 1129, 1129, 1129,\n /*   200 */  1129, 1129, 1129, 1129, 1403, 1401, 1129, 1129, 1129, 1129,\n /*   210 */  1129, 1129, 1129, 1129, 1129, 1129, 1129, 1129, 1129, 1129,\n /*   220 */  1129, 1129, 1129, 1129, 1129, 1129, 1129, 1129, 1129, 1129,\n /*   230 */  1129, 1129, 1129, 1129, 1231, 1129, 1129, 1129, 1129, 1129,\n /*   240 */  1129, 1129, 1129, 1129, 1129, 1450, 1129, 1376, 1213, 1231,\n /*   250 */  1231, 1231, 1231, 1233, 1214, 1212, 1225, 1160, 1136, 1492,\n /*   260 */  1275, 1254, 1254, 1489, 1275, 1275, 1489, 1174, 1470, 1171,\n /*   270 */  1265, 1265, 1265, 1254, 1343, 1232, 1225, 1129, 1492, 1240,\n /*   280 */  1240, 1491, 1491, 1240, 1364, 1284, 1290, 1202, 1275, 1208,\n /*   290 */  1208, 1208, 1208, 1240, 1147, 1275, 1275, 1284, 1290, 1202,\n /*   300 */  1202, 1275, 1240, 1147, 1380, 1486, 1240, 1147, 1354, 1240,\n /*   310 */  1147, 1240, 1147, 1354, 1200, 1200, 1200, 1189, 1354, 1200,\n /*   320 */  1174, 1200, 1189, 1200, 1200, 1354, 1358, 1358, 1354, 1258,\n /*   330 */  1253, 1258, 1253, 1258, 1253, 1258, 1253, 1240, 1259, 1425,\n /*   340 */  1129, 1270, 1259, 1349, 1240, 1129, 1270, 1268, 1266, 1275,\n /*   350 */  1153, 1192, 1453, 1453, 1449, 1449, 1449, 1497, 1497, 1412,\n /*   360 */  1465, 1160, 1160, 1160, 1160, 1465, 1176, 1176, 1160, 1160,\n /*   370 */  1160, 1160, 1465, 1129, 1129, 1129, 1129, 1129, 1129, 1460,\n /*   380 */  1129, 1365, 1244, 1129, 1129, 1129, 1129, 1129, 1129, 1129,\n /*   390 */  1129, 1129, 1129, 1129, 1129, 1129, 1129, 1129, 1129, 1129,\n /*   400 */  1129, 1129, 1129, 1129, 1129, 1295, 1129, 1132, 1409, 1129,\n /*   410 */  1129, 1407, 1129, 1129, 1129, 1129, 1129, 1129, 1245, 1129,\n /*   420 */  1129, 1129, 1129, 1129, 1129, 1129, 1129, 1129, 1129, 1129,\n /*   430 */  1129, 1129, 1129, 1129, 1129, 1129, 1129, 1488, 1129, 1129,\n /*   440 */  1129, 1129, 1129, 1129, 1379, 1378, 1129, 1129, 1242, 1129,\n /*   450 */  1129, 1129, 1129, 1129, 1129, 1129, 1129, 1129, 1129, 1129,\n /*   460 */  1129, 1129, 1129, 1129, 1129, 1129, 1129, 1129, 1129, 1129,\n /*   470 */  1129, 1129, 1129, 1129, 1129, 1129, 1129, 1129, 1129, 1129,\n /*   480 */  1129, 1129, 1129, 1129, 1129, 1129, 1267, 1129, 1424, 1129,\n /*   490 */  1129, 1129, 1129, 1129, 1129, 1129, 1438, 1260, 1129, 1129,\n /*   500 */  1479, 1129, 1129, 1129, 1129, 1129, 1129, 1129, 1129, 1129,\n /*   510 */  1129, 1129, 1129, 1129, 1129, 1474, 1216, 1297, 1129, 1296,\n /*   520 */  1300, 1129, 1141, 1129,\n};\n/********** End of lemon-generated parsing tables *****************************/\n\n/* The next table maps tokens (terminal symbols) into fallback tokens.  \n** If a construct like the following:\n** \n**      %fallback ID X Y Z.\n**\n** appears in the grammar, then ID becomes a fallback token for X, Y,\n** and Z.  Whenever one of the tokens X, Y, or Z is input to the parser\n** but it does not parse, the type of the token is changed to ID and\n** the parse is retried before an error is thrown.\n**\n** This feature can be used, for example, to cause some keywords in a language\n** to revert to identifiers if they keyword does not apply in the context where\n** it appears.\n*/\n#ifdef YYFALLBACK\nstatic const YYCODETYPE yyFallback[] = {\n    0,  /*          $ => nothing */\n    0,  /*       SEMI => nothing */\n   59,  /*    EXPLAIN => ID */\n   59,  /*      QUERY => ID */\n   59,  /*       PLAN => ID */\n   59,  /*      BEGIN => ID */\n    0,  /* TRANSACTION => nothing */\n   59,  /*   DEFERRED => ID */\n   59,  /*  IMMEDIATE => ID */\n   59,  /*  EXCLUSIVE => ID */\n    0,  /*     COMMIT => nothing */\n   59,  /*        END => ID */\n   59,  /*   ROLLBACK => ID */\n   59,  /*  SAVEPOINT => ID */\n   59,  /*    RELEASE => ID */\n    0,  /*         TO => nothing */\n    0,  /*      TABLE => nothing */\n    0,  /*     CREATE => nothing */\n   59,  /*         IF => ID */\n    0,  /*        NOT => nothing */\n    0,  /*     EXISTS => nothing */\n   59,  /*       TEMP => ID */\n    0,  /*         LP => nothing */\n    0,  /*         RP => nothing */\n    0,  /*         AS => nothing */\n   59,  /*    WITHOUT => ID */\n    0,  /*      COMMA => nothing */\n   59,  /*      ABORT => ID */\n   59,  /*     ACTION => ID */\n   59,  /*      AFTER => ID */\n   59,  /*    ANALYZE => ID */\n   59,  /*        ASC => ID */\n   59,  /*     ATTACH => ID */\n   59,  /*     BEFORE => ID */\n   59,  /*         BY => ID */\n   59,  /*    CASCADE => ID */\n   59,  /*       CAST => ID */\n   59,  /*   CONFLICT => ID */\n   59,  /*   DATABASE => ID */\n   59,  /*       DESC => ID */\n   59,  /*     DETACH => ID */\n   59,  /*       EACH => ID */\n   59,  /*       FAIL => ID */\n    0,  /*         OR => nothing */\n    0,  /*        AND => nothing */\n    0,  /*         IS => nothing */\n   59,  /*      MATCH => ID */\n   59,  /*    LIKE_KW => ID */\n    0,  /*    BETWEEN => nothing */\n    0,  /*         IN => nothing */\n    0,  /*     ISNULL => nothing */\n    0,  /*    NOTNULL => nothing */\n    0,  /*         NE => nothing */\n    0,  /*         EQ => nothing */\n    0,  /*         GT => nothing */\n    0,  /*         LE => nothing */\n    0,  /*         LT => nothing */\n    0,  /*         GE => nothing */\n    0,  /*     ESCAPE => nothing */\n    0,  /*         ID => nothing */\n   59,  /*   COLUMNKW => ID */\n   59,  /*         DO => ID */\n   59,  /*        FOR => ID */\n   59,  /*     IGNORE => ID */\n   59,  /*  INITIALLY => ID */\n   59,  /*    INSTEAD => ID */\n   59,  /*         NO => ID */\n   59,  /*        KEY => ID */\n   59,  /*         OF => ID */\n   59,  /*     OFFSET => ID */\n   59,  /*     PRAGMA => ID */\n   59,  /*      RAISE => ID */\n   59,  /*  RECURSIVE => ID */\n   59,  /*    REPLACE => ID */\n   59,  /*   RESTRICT => ID */\n   59,  /*        ROW => ID */\n   59,  /*       ROWS => ID */\n   59,  /*    TRIGGER => ID */\n   59,  /*     VACUUM => ID */\n   59,  /*       VIEW => ID */\n   59,  /*    VIRTUAL => ID */\n   59,  /*       WITH => ID */\n   59,  /*    CURRENT => ID */\n   59,  /*  FOLLOWING => ID */\n   59,  /*  PARTITION => ID */\n   59,  /*  PRECEDING => ID */\n   59,  /*      RANGE => ID */\n   59,  /*  UNBOUNDED => ID */\n   59,  /*    REINDEX => ID */\n   59,  /*     RENAME => ID */\n   59,  /*   CTIME_KW => ID */\n};\n#endif /* YYFALLBACK */\n\n/* The following structure represents a single element of the\n** parser's stack.  Information stored includes:\n**\n**   +  The state number for the parser at this level of the stack.\n**\n**   +  The value of the token stored at this level of the stack.\n**      (In other words, the \"major\" token.)\n**\n**   +  The semantic value stored at this level of the stack.  This is\n**      the information used by the action routines in the grammar.\n**      It is sometimes called the \"minor\" token.\n**\n** After the \"shift\" half of a SHIFTREDUCE action, the stateno field\n** actually contains the reduce action for the second half of the\n** SHIFTREDUCE.\n*/\nstruct yyStackEntry {\n  YYACTIONTYPE stateno;  /* The state-number, or reduce action in SHIFTREDUCE */\n  YYCODETYPE major;      /* The major token value.  This is the code\n                         ** number for the token at this stack level */\n  YYMINORTYPE minor;     /* The user-supplied minor token value.  This\n                         ** is the value of the token  */\n};\ntypedef struct yyStackEntry yyStackEntry;\n\n/* The state of the parser is completely contained in an instance of\n** the following structure */\nstruct yyParser {\n  yyStackEntry *yytos;          /* Pointer to top element of the stack */\n#ifdef YYTRACKMAXSTACKDEPTH\n  int yyhwm;                    /* High-water mark of the stack */\n#endif\n#ifndef YYNOERRORRECOVERY\n  int yyerrcnt;                 /* Shifts left before out of the error */\n#endif\n  sqlite3ParserARG_SDECL                /* A place to hold %extra_argument */\n  sqlite3ParserCTX_SDECL                /* A place to hold %extra_context */\n#if YYSTACKDEPTH<=0\n  int yystksz;                  /* Current side of the stack */\n  yyStackEntry *yystack;        /* The parser's stack */\n  yyStackEntry yystk0;          /* First stack entry */\n#else\n  yyStackEntry yystack[YYSTACKDEPTH];  /* The parser's stack */\n  yyStackEntry *yystackEnd;            /* Last entry in the stack */\n#endif\n};\ntypedef struct yyParser yyParser;\n\n#ifndef NDEBUG\n/* #include <stdio.h> */\nstatic FILE *yyTraceFILE = 0;\nstatic char *yyTracePrompt = 0;\n#endif /* NDEBUG */\n\n#ifndef NDEBUG\n/* \n** Turn parser tracing on by giving a stream to which to write the trace\n** and a prompt to preface each trace message.  Tracing is turned off\n** by making either argument NULL \n**\n** Inputs:\n** <ul>\n** <li> A FILE* to which trace output should be written.\n**      If NULL, then tracing is turned off.\n** <li> A prefix string written at the beginning of every\n**      line of trace output.  If NULL, then tracing is\n**      turned off.\n** </ul>\n**\n** Outputs:\n** None.\n*/\nSQLITE_PRIVATE void sqlite3ParserTrace(FILE *TraceFILE, char *zTracePrompt){\n  yyTraceFILE = TraceFILE;\n  yyTracePrompt = zTracePrompt;\n  if( yyTraceFILE==0 ) yyTracePrompt = 0;\n  else if( yyTracePrompt==0 ) yyTraceFILE = 0;\n}\n#endif /* NDEBUG */\n\n#if defined(YYCOVERAGE) || !defined(NDEBUG)\n/* For tracing shifts, the names of all terminals and nonterminals\n** are required.  The following table supplies these names */\nstatic const char *const yyTokenName[] = { \n  /*    0 */ \"$\",\n  /*    1 */ \"SEMI\",\n  /*    2 */ \"EXPLAIN\",\n  /*    3 */ \"QUERY\",\n  /*    4 */ \"PLAN\",\n  /*    5 */ \"BEGIN\",\n  /*    6 */ \"TRANSACTION\",\n  /*    7 */ \"DEFERRED\",\n  /*    8 */ \"IMMEDIATE\",\n  /*    9 */ \"EXCLUSIVE\",\n  /*   10 */ \"COMMIT\",\n  /*   11 */ \"END\",\n  /*   12 */ \"ROLLBACK\",\n  /*   13 */ \"SAVEPOINT\",\n  /*   14 */ \"RELEASE\",\n  /*   15 */ \"TO\",\n  /*   16 */ \"TABLE\",\n  /*   17 */ \"CREATE\",\n  /*   18 */ \"IF\",\n  /*   19 */ \"NOT\",\n  /*   20 */ \"EXISTS\",\n  /*   21 */ \"TEMP\",\n  /*   22 */ \"LP\",\n  /*   23 */ \"RP\",\n  /*   24 */ \"AS\",\n  /*   25 */ \"WITHOUT\",\n  /*   26 */ \"COMMA\",\n  /*   27 */ \"ABORT\",\n  /*   28 */ \"ACTION\",\n  /*   29 */ \"AFTER\",\n  /*   30 */ \"ANALYZE\",\n  /*   31 */ \"ASC\",\n  /*   32 */ \"ATTACH\",\n  /*   33 */ \"BEFORE\",\n  /*   34 */ \"BY\",\n  /*   35 */ \"CASCADE\",\n  /*   36 */ \"CAST\",\n  /*   37 */ \"CONFLICT\",\n  /*   38 */ \"DATABASE\",\n  /*   39 */ \"DESC\",\n  /*   40 */ \"DETACH\",\n  /*   41 */ \"EACH\",\n  /*   42 */ \"FAIL\",\n  /*   43 */ \"OR\",\n  /*   44 */ \"AND\",\n  /*   45 */ \"IS\",\n  /*   46 */ \"MATCH\",\n  /*   47 */ \"LIKE_KW\",\n  /*   48 */ \"BETWEEN\",\n  /*   49 */ \"IN\",\n  /*   50 */ \"ISNULL\",\n  /*   51 */ \"NOTNULL\",\n  /*   52 */ \"NE\",\n  /*   53 */ \"EQ\",\n  /*   54 */ \"GT\",\n  /*   55 */ \"LE\",\n  /*   56 */ \"LT\",\n  /*   57 */ \"GE\",\n  /*   58 */ \"ESCAPE\",\n  /*   59 */ \"ID\",\n  /*   60 */ \"COLUMNKW\",\n  /*   61 */ \"DO\",\n  /*   62 */ \"FOR\",\n  /*   63 */ \"IGNORE\",\n  /*   64 */ \"INITIALLY\",\n  /*   65 */ \"INSTEAD\",\n  /*   66 */ \"NO\",\n  /*   67 */ \"KEY\",\n  /*   68 */ \"OF\",\n  /*   69 */ \"OFFSET\",\n  /*   70 */ \"PRAGMA\",\n  /*   71 */ \"RAISE\",\n  /*   72 */ \"RECURSIVE\",\n  /*   73 */ \"REPLACE\",\n  /*   74 */ \"RESTRICT\",\n  /*   75 */ \"ROW\",\n  /*   76 */ \"ROWS\",\n  /*   77 */ \"TRIGGER\",\n  /*   78 */ \"VACUUM\",\n  /*   79 */ \"VIEW\",\n  /*   80 */ \"VIRTUAL\",\n  /*   81 */ \"WITH\",\n  /*   82 */ \"CURRENT\",\n  /*   83 */ \"FOLLOWING\",\n  /*   84 */ \"PARTITION\",\n  /*   85 */ \"PRECEDING\",\n  /*   86 */ \"RANGE\",\n  /*   87 */ \"UNBOUNDED\",\n  /*   88 */ \"REINDEX\",\n  /*   89 */ \"RENAME\",\n  /*   90 */ \"CTIME_KW\",\n  /*   91 */ \"ANY\",\n  /*   92 */ \"BITAND\",\n  /*   93 */ \"BITOR\",\n  /*   94 */ \"LSHIFT\",\n  /*   95 */ \"RSHIFT\",\n  /*   96 */ \"PLUS\",\n  /*   97 */ \"MINUS\",\n  /*   98 */ \"STAR\",\n  /*   99 */ \"SLASH\",\n  /*  100 */ \"REM\",\n  /*  101 */ \"CONCAT\",\n  /*  102 */ \"COLLATE\",\n  /*  103 */ \"BITNOT\",\n  /*  104 */ \"ON\",\n  /*  105 */ \"INDEXED\",\n  /*  106 */ \"STRING\",\n  /*  107 */ \"JOIN_KW\",\n  /*  108 */ \"CONSTRAINT\",\n  /*  109 */ \"DEFAULT\",\n  /*  110 */ \"NULL\",\n  /*  111 */ \"PRIMARY\",\n  /*  112 */ \"UNIQUE\",\n  /*  113 */ \"CHECK\",\n  /*  114 */ \"REFERENCES\",\n  /*  115 */ \"AUTOINCR\",\n  /*  116 */ \"INSERT\",\n  /*  117 */ \"DELETE\",\n  /*  118 */ \"UPDATE\",\n  /*  119 */ \"SET\",\n  /*  120 */ \"DEFERRABLE\",\n  /*  121 */ \"FOREIGN\",\n  /*  122 */ \"DROP\",\n  /*  123 */ \"UNION\",\n  /*  124 */ \"ALL\",\n  /*  125 */ \"EXCEPT\",\n  /*  126 */ \"INTERSECT\",\n  /*  127 */ \"SELECT\",\n  /*  128 */ \"VALUES\",\n  /*  129 */ \"DISTINCT\",\n  /*  130 */ \"DOT\",\n  /*  131 */ \"FROM\",\n  /*  132 */ \"JOIN\",\n  /*  133 */ \"USING\",\n  /*  134 */ \"ORDER\",\n  /*  135 */ \"GROUP\",\n  /*  136 */ \"HAVING\",\n  /*  137 */ \"LIMIT\",\n  /*  138 */ \"WHERE\",\n  /*  139 */ \"INTO\",\n  /*  140 */ \"NOTHING\",\n  /*  141 */ \"FLOAT\",\n  /*  142 */ \"BLOB\",\n  /*  143 */ \"INTEGER\",\n  /*  144 */ \"VARIABLE\",\n  /*  145 */ \"CASE\",\n  /*  146 */ \"WHEN\",\n  /*  147 */ \"THEN\",\n  /*  148 */ \"ELSE\",\n  /*  149 */ \"INDEX\",\n  /*  150 */ \"ALTER\",\n  /*  151 */ \"ADD\",\n  /*  152 */ \"WINDOW\",\n  /*  153 */ \"OVER\",\n  /*  154 */ \"FILTER\",\n  /*  155 */ \"input\",\n  /*  156 */ \"cmdlist\",\n  /*  157 */ \"ecmd\",\n  /*  158 */ \"cmdx\",\n  /*  159 */ \"explain\",\n  /*  160 */ \"cmd\",\n  /*  161 */ \"transtype\",\n  /*  162 */ \"trans_opt\",\n  /*  163 */ \"nm\",\n  /*  164 */ \"savepoint_opt\",\n  /*  165 */ \"create_table\",\n  /*  166 */ \"create_table_args\",\n  /*  167 */ \"createkw\",\n  /*  168 */ \"temp\",\n  /*  169 */ \"ifnotexists\",\n  /*  170 */ \"dbnm\",\n  /*  171 */ \"columnlist\",\n  /*  172 */ \"conslist_opt\",\n  /*  173 */ \"table_options\",\n  /*  174 */ \"select\",\n  /*  175 */ \"columnname\",\n  /*  176 */ \"carglist\",\n  /*  177 */ \"typetoken\",\n  /*  178 */ \"typename\",\n  /*  179 */ \"signed\",\n  /*  180 */ \"plus_num\",\n  /*  181 */ \"minus_num\",\n  /*  182 */ \"scanpt\",\n  /*  183 */ \"ccons\",\n  /*  184 */ \"term\",\n  /*  185 */ \"expr\",\n  /*  186 */ \"onconf\",\n  /*  187 */ \"sortorder\",\n  /*  188 */ \"autoinc\",\n  /*  189 */ \"eidlist_opt\",\n  /*  190 */ \"refargs\",\n  /*  191 */ \"defer_subclause\",\n  /*  192 */ \"refarg\",\n  /*  193 */ \"refact\",\n  /*  194 */ \"init_deferred_pred_opt\",\n  /*  195 */ \"conslist\",\n  /*  196 */ \"tconscomma\",\n  /*  197 */ \"tcons\",\n  /*  198 */ \"sortlist\",\n  /*  199 */ \"eidlist\",\n  /*  200 */ \"defer_subclause_opt\",\n  /*  201 */ \"orconf\",\n  /*  202 */ \"resolvetype\",\n  /*  203 */ \"raisetype\",\n  /*  204 */ \"ifexists\",\n  /*  205 */ \"fullname\",\n  /*  206 */ \"selectnowith\",\n  /*  207 */ \"oneselect\",\n  /*  208 */ \"wqlist\",\n  /*  209 */ \"multiselect_op\",\n  /*  210 */ \"distinct\",\n  /*  211 */ \"selcollist\",\n  /*  212 */ \"from\",\n  /*  213 */ \"where_opt\",\n  /*  214 */ \"groupby_opt\",\n  /*  215 */ \"having_opt\",\n  /*  216 */ \"orderby_opt\",\n  /*  217 */ \"limit_opt\",\n  /*  218 */ \"window_clause\",\n  /*  219 */ \"values\",\n  /*  220 */ \"nexprlist\",\n  /*  221 */ \"sclp\",\n  /*  222 */ \"as\",\n  /*  223 */ \"seltablist\",\n  /*  224 */ \"stl_prefix\",\n  /*  225 */ \"joinop\",\n  /*  226 */ \"indexed_opt\",\n  /*  227 */ \"on_opt\",\n  /*  228 */ \"using_opt\",\n  /*  229 */ \"exprlist\",\n  /*  230 */ \"xfullname\",\n  /*  231 */ \"idlist\",\n  /*  232 */ \"with\",\n  /*  233 */ \"setlist\",\n  /*  234 */ \"insert_cmd\",\n  /*  235 */ \"idlist_opt\",\n  /*  236 */ \"upsert\",\n  /*  237 */ \"over_clause\",\n  /*  238 */ \"likeop\",\n  /*  239 */ \"between_op\",\n  /*  240 */ \"in_op\",\n  /*  241 */ \"paren_exprlist\",\n  /*  242 */ \"case_operand\",\n  /*  243 */ \"case_exprlist\",\n  /*  244 */ \"case_else\",\n  /*  245 */ \"uniqueflag\",\n  /*  246 */ \"collate\",\n  /*  247 */ \"vinto\",\n  /*  248 */ \"nmnum\",\n  /*  249 */ \"trigger_decl\",\n  /*  250 */ \"trigger_cmd_list\",\n  /*  251 */ \"trigger_time\",\n  /*  252 */ \"trigger_event\",\n  /*  253 */ \"foreach_clause\",\n  /*  254 */ \"when_clause\",\n  /*  255 */ \"trigger_cmd\",\n  /*  256 */ \"trnm\",\n  /*  257 */ \"tridxby\",\n  /*  258 */ \"database_kw_opt\",\n  /*  259 */ \"key_opt\",\n  /*  260 */ \"add_column_fullname\",\n  /*  261 */ \"kwcolumn_opt\",\n  /*  262 */ \"create_vtab\",\n  /*  263 */ \"vtabarglist\",\n  /*  264 */ \"vtabarg\",\n  /*  265 */ \"vtabargtoken\",\n  /*  266 */ \"lp\",\n  /*  267 */ \"anylist\",\n  /*  268 */ \"windowdefn_list\",\n  /*  269 */ \"windowdefn\",\n  /*  270 */ \"window\",\n  /*  271 */ \"frame_opt\",\n  /*  272 */ \"part_opt\",\n  /*  273 */ \"filter_opt\",\n  /*  274 */ \"range_or_rows\",\n  /*  275 */ \"frame_bound\",\n  /*  276 */ \"frame_bound_s\",\n  /*  277 */ \"frame_bound_e\",\n};\n#endif /* defined(YYCOVERAGE) || !defined(NDEBUG) */\n\n#ifndef NDEBUG\n/* For tracing reduce actions, the names of all rules are required.\n*/\nstatic const char *const yyRuleName[] = {\n /*   0 */ \"explain ::= EXPLAIN\",\n /*   1 */ \"explain ::= EXPLAIN QUERY PLAN\",\n /*   2 */ \"cmdx ::= cmd\",\n /*   3 */ \"cmd ::= BEGIN transtype trans_opt\",\n /*   4 */ \"transtype ::=\",\n /*   5 */ \"transtype ::= DEFERRED\",\n /*   6 */ \"transtype ::= IMMEDIATE\",\n /*   7 */ \"transtype ::= EXCLUSIVE\",\n /*   8 */ \"cmd ::= COMMIT|END trans_opt\",\n /*   9 */ \"cmd ::= ROLLBACK trans_opt\",\n /*  10 */ \"cmd ::= SAVEPOINT nm\",\n /*  11 */ \"cmd ::= RELEASE savepoint_opt nm\",\n /*  12 */ \"cmd ::= ROLLBACK trans_opt TO savepoint_opt nm\",\n /*  13 */ \"create_table ::= createkw temp TABLE ifnotexists nm dbnm\",\n /*  14 */ \"createkw ::= CREATE\",\n /*  15 */ \"ifnotexists ::=\",\n /*  16 */ \"ifnotexists ::= IF NOT EXISTS\",\n /*  17 */ \"temp ::= TEMP\",\n /*  18 */ \"temp ::=\",\n /*  19 */ \"create_table_args ::= LP columnlist conslist_opt RP table_options\",\n /*  20 */ \"create_table_args ::= AS select\",\n /*  21 */ \"table_options ::=\",\n /*  22 */ \"table_options ::= WITHOUT nm\",\n /*  23 */ \"columnname ::= nm typetoken\",\n /*  24 */ \"typetoken ::=\",\n /*  25 */ \"typetoken ::= typename LP signed RP\",\n /*  26 */ \"typetoken ::= typename LP signed COMMA signed RP\",\n /*  27 */ \"typename ::= typename ID|STRING\",\n /*  28 */ \"scanpt ::=\",\n /*  29 */ \"ccons ::= CONSTRAINT nm\",\n /*  30 */ \"ccons ::= DEFAULT scanpt term scanpt\",\n /*  31 */ \"ccons ::= DEFAULT LP expr RP\",\n /*  32 */ \"ccons ::= DEFAULT PLUS term scanpt\",\n /*  33 */ \"ccons ::= DEFAULT MINUS term scanpt\",\n /*  34 */ \"ccons ::= DEFAULT scanpt ID|INDEXED\",\n /*  35 */ \"ccons ::= NOT NULL onconf\",\n /*  36 */ \"ccons ::= PRIMARY KEY sortorder onconf autoinc\",\n /*  37 */ \"ccons ::= UNIQUE onconf\",\n /*  38 */ \"ccons ::= CHECK LP expr RP\",\n /*  39 */ \"ccons ::= REFERENCES nm eidlist_opt refargs\",\n /*  40 */ \"ccons ::= defer_subclause\",\n /*  41 */ \"ccons ::= COLLATE ID|STRING\",\n /*  42 */ \"autoinc ::=\",\n /*  43 */ \"autoinc ::= AUTOINCR\",\n /*  44 */ \"refargs ::=\",\n /*  45 */ \"refargs ::= refargs refarg\",\n /*  46 */ \"refarg ::= MATCH nm\",\n /*  47 */ \"refarg ::= ON INSERT refact\",\n /*  48 */ \"refarg ::= ON DELETE refact\",\n /*  49 */ \"refarg ::= ON UPDATE refact\",\n /*  50 */ \"refact ::= SET NULL\",\n /*  51 */ \"refact ::= SET DEFAULT\",\n /*  52 */ \"refact ::= CASCADE\",\n /*  53 */ \"refact ::= RESTRICT\",\n /*  54 */ \"refact ::= NO ACTION\",\n /*  55 */ \"defer_subclause ::= NOT DEFERRABLE init_deferred_pred_opt\",\n /*  56 */ \"defer_subclause ::= DEFERRABLE init_deferred_pred_opt\",\n /*  57 */ \"init_deferred_pred_opt ::=\",\n /*  58 */ \"init_deferred_pred_opt ::= INITIALLY DEFERRED\",\n /*  59 */ \"init_deferred_pred_opt ::= INITIALLY IMMEDIATE\",\n /*  60 */ \"conslist_opt ::=\",\n /*  61 */ \"tconscomma ::= COMMA\",\n /*  62 */ \"tcons ::= CONSTRAINT nm\",\n /*  63 */ \"tcons ::= PRIMARY KEY LP sortlist autoinc RP onconf\",\n /*  64 */ \"tcons ::= UNIQUE LP sortlist RP onconf\",\n /*  65 */ \"tcons ::= CHECK LP expr RP onconf\",\n /*  66 */ \"tcons ::= FOREIGN KEY LP eidlist RP REFERENCES nm eidlist_opt refargs defer_subclause_opt\",\n /*  67 */ \"defer_subclause_opt ::=\",\n /*  68 */ \"onconf ::=\",\n /*  69 */ \"onconf ::= ON CONFLICT resolvetype\",\n /*  70 */ \"orconf ::=\",\n /*  71 */ \"orconf ::= OR resolvetype\",\n /*  72 */ \"resolvetype ::= IGNORE\",\n /*  73 */ \"resolvetype ::= REPLACE\",\n /*  74 */ \"cmd ::= DROP TABLE ifexists fullname\",\n /*  75 */ \"ifexists ::= IF EXISTS\",\n /*  76 */ \"ifexists ::=\",\n /*  77 */ \"cmd ::= createkw temp VIEW ifnotexists nm dbnm eidlist_opt AS select\",\n /*  78 */ \"cmd ::= DROP VIEW ifexists fullname\",\n /*  79 */ \"cmd ::= select\",\n /*  80 */ \"select ::= WITH wqlist selectnowith\",\n /*  81 */ \"select ::= WITH RECURSIVE wqlist selectnowith\",\n /*  82 */ \"select ::= selectnowith\",\n /*  83 */ \"selectnowith ::= selectnowith multiselect_op oneselect\",\n /*  84 */ \"multiselect_op ::= UNION\",\n /*  85 */ \"multiselect_op ::= UNION ALL\",\n /*  86 */ \"multiselect_op ::= EXCEPT|INTERSECT\",\n /*  87 */ \"oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt orderby_opt limit_opt\",\n /*  88 */ \"oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt window_clause orderby_opt limit_opt\",\n /*  89 */ \"values ::= VALUES LP nexprlist RP\",\n /*  90 */ \"values ::= values COMMA LP nexprlist RP\",\n /*  91 */ \"distinct ::= DISTINCT\",\n /*  92 */ \"distinct ::= ALL\",\n /*  93 */ \"distinct ::=\",\n /*  94 */ \"sclp ::=\",\n /*  95 */ \"selcollist ::= sclp scanpt expr scanpt as\",\n /*  96 */ \"selcollist ::= sclp scanpt STAR\",\n /*  97 */ \"selcollist ::= sclp scanpt nm DOT STAR\",\n /*  98 */ \"as ::= AS nm\",\n /*  99 */ \"as ::=\",\n /* 100 */ \"from ::=\",\n /* 101 */ \"from ::= FROM seltablist\",\n /* 102 */ \"stl_prefix ::= seltablist joinop\",\n /* 103 */ \"stl_prefix ::=\",\n /* 104 */ \"seltablist ::= stl_prefix nm dbnm as indexed_opt on_opt using_opt\",\n /* 105 */ \"seltablist ::= stl_prefix nm dbnm LP exprlist RP as on_opt using_opt\",\n /* 106 */ \"seltablist ::= stl_prefix LP select RP as on_opt using_opt\",\n /* 107 */ \"seltablist ::= stl_prefix LP seltablist RP as on_opt using_opt\",\n /* 108 */ \"dbnm ::=\",\n /* 109 */ \"dbnm ::= DOT nm\",\n /* 110 */ \"fullname ::= nm\",\n /* 111 */ \"fullname ::= nm DOT nm\",\n /* 112 */ \"xfullname ::= nm\",\n /* 113 */ \"xfullname ::= nm DOT nm\",\n /* 114 */ \"xfullname ::= nm DOT nm AS nm\",\n /* 115 */ \"xfullname ::= nm AS nm\",\n /* 116 */ \"joinop ::= COMMA|JOIN\",\n /* 117 */ \"joinop ::= JOIN_KW JOIN\",\n /* 118 */ \"joinop ::= JOIN_KW nm JOIN\",\n /* 119 */ \"joinop ::= JOIN_KW nm nm JOIN\",\n /* 120 */ \"on_opt ::= ON expr\",\n /* 121 */ \"on_opt ::=\",\n /* 122 */ \"indexed_opt ::=\",\n /* 123 */ \"indexed_opt ::= INDEXED BY nm\",\n /* 124 */ \"indexed_opt ::= NOT INDEXED\",\n /* 125 */ \"using_opt ::= USING LP idlist RP\",\n /* 126 */ \"using_opt ::=\",\n /* 127 */ \"orderby_opt ::=\",\n /* 128 */ \"orderby_opt ::= ORDER BY sortlist\",\n /* 129 */ \"sortlist ::= sortlist COMMA expr sortorder\",\n /* 130 */ \"sortlist ::= expr sortorder\",\n /* 131 */ \"sortorder ::= ASC\",\n /* 132 */ \"sortorder ::= DESC\",\n /* 133 */ \"sortorder ::=\",\n /* 134 */ \"groupby_opt ::=\",\n /* 135 */ \"groupby_opt ::= GROUP BY nexprlist\",\n /* 136 */ \"having_opt ::=\",\n /* 137 */ \"having_opt ::= HAVING expr\",\n /* 138 */ \"limit_opt ::=\",\n /* 139 */ \"limit_opt ::= LIMIT expr\",\n /* 140 */ \"limit_opt ::= LIMIT expr OFFSET expr\",\n /* 141 */ \"limit_opt ::= LIMIT expr COMMA expr\",\n /* 142 */ \"cmd ::= with DELETE FROM xfullname indexed_opt where_opt\",\n /* 143 */ \"where_opt ::=\",\n /* 144 */ \"where_opt ::= WHERE expr\",\n /* 145 */ \"cmd ::= with UPDATE orconf xfullname indexed_opt SET setlist where_opt\",\n /* 146 */ \"setlist ::= setlist COMMA nm EQ expr\",\n /* 147 */ \"setlist ::= setlist COMMA LP idlist RP EQ expr\",\n /* 148 */ \"setlist ::= nm EQ expr\",\n /* 149 */ \"setlist ::= LP idlist RP EQ expr\",\n /* 150 */ \"cmd ::= with insert_cmd INTO xfullname idlist_opt select upsert\",\n /* 151 */ \"cmd ::= with insert_cmd INTO xfullname idlist_opt DEFAULT VALUES\",\n /* 152 */ \"upsert ::=\",\n /* 153 */ \"upsert ::= ON CONFLICT LP sortlist RP where_opt DO UPDATE SET setlist where_opt\",\n /* 154 */ \"upsert ::= ON CONFLICT LP sortlist RP where_opt DO NOTHING\",\n /* 155 */ \"upsert ::= ON CONFLICT DO NOTHING\",\n /* 156 */ \"insert_cmd ::= INSERT orconf\",\n /* 157 */ \"insert_cmd ::= REPLACE\",\n /* 158 */ \"idlist_opt ::=\",\n /* 159 */ \"idlist_opt ::= LP idlist RP\",\n /* 160 */ \"idlist ::= idlist COMMA nm\",\n /* 161 */ \"idlist ::= nm\",\n /* 162 */ \"expr ::= LP expr RP\",\n /* 163 */ \"expr ::= ID|INDEXED\",\n /* 164 */ \"expr ::= JOIN_KW\",\n /* 165 */ \"expr ::= nm DOT nm\",\n /* 166 */ \"expr ::= nm DOT nm DOT nm\",\n /* 167 */ \"term ::= NULL|FLOAT|BLOB\",\n /* 168 */ \"term ::= STRING\",\n /* 169 */ \"term ::= INTEGER\",\n /* 170 */ \"expr ::= VARIABLE\",\n /* 171 */ \"expr ::= expr COLLATE ID|STRING\",\n /* 172 */ \"expr ::= CAST LP expr AS typetoken RP\",\n /* 173 */ \"expr ::= ID|INDEXED LP distinct exprlist RP\",\n /* 174 */ \"expr ::= ID|INDEXED LP STAR RP\",\n /* 175 */ \"expr ::= ID|INDEXED LP distinct exprlist RP over_clause\",\n /* 176 */ \"expr ::= ID|INDEXED LP STAR RP over_clause\",\n /* 177 */ \"term ::= CTIME_KW\",\n /* 178 */ \"expr ::= LP nexprlist COMMA expr RP\",\n /* 179 */ \"expr ::= expr AND expr\",\n /* 180 */ \"expr ::= expr OR expr\",\n /* 181 */ \"expr ::= expr LT|GT|GE|LE expr\",\n /* 182 */ \"expr ::= expr EQ|NE expr\",\n /* 183 */ \"expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr\",\n /* 184 */ \"expr ::= expr PLUS|MINUS expr\",\n /* 185 */ \"expr ::= expr STAR|SLASH|REM expr\",\n /* 186 */ \"expr ::= expr CONCAT expr\",\n /* 187 */ \"likeop ::= NOT LIKE_KW|MATCH\",\n /* 188 */ \"expr ::= expr likeop expr\",\n /* 189 */ \"expr ::= expr likeop expr ESCAPE expr\",\n /* 190 */ \"expr ::= expr ISNULL|NOTNULL\",\n /* 191 */ \"expr ::= expr NOT NULL\",\n /* 192 */ \"expr ::= expr IS expr\",\n /* 193 */ \"expr ::= expr IS NOT expr\",\n /* 194 */ \"expr ::= NOT expr\",\n /* 195 */ \"expr ::= BITNOT expr\",\n /* 196 */ \"expr ::= PLUS|MINUS expr\",\n /* 197 */ \"between_op ::= BETWEEN\",\n /* 198 */ \"between_op ::= NOT BETWEEN\",\n /* 199 */ \"expr ::= expr between_op expr AND expr\",\n /* 200 */ \"in_op ::= IN\",\n /* 201 */ \"in_op ::= NOT IN\",\n /* 202 */ \"expr ::= expr in_op LP exprlist RP\",\n /* 203 */ \"expr ::= LP select RP\",\n /* 204 */ \"expr ::= expr in_op LP select RP\",\n /* 205 */ \"expr ::= expr in_op nm dbnm paren_exprlist\",\n /* 206 */ \"expr ::= EXISTS LP select RP\",\n /* 207 */ \"expr ::= CASE case_operand case_exprlist case_else END\",\n /* 208 */ \"case_exprlist ::= case_exprlist WHEN expr THEN expr\",\n /* 209 */ \"case_exprlist ::= WHEN expr THEN expr\",\n /* 210 */ \"case_else ::= ELSE expr\",\n /* 211 */ \"case_else ::=\",\n /* 212 */ \"case_operand ::= expr\",\n /* 213 */ \"case_operand ::=\",\n /* 214 */ \"exprlist ::=\",\n /* 215 */ \"nexprlist ::= nexprlist COMMA expr\",\n /* 216 */ \"nexprlist ::= expr\",\n /* 217 */ \"paren_exprlist ::=\",\n /* 218 */ \"paren_exprlist ::= LP exprlist RP\",\n /* 219 */ \"cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt\",\n /* 220 */ \"uniqueflag ::= UNIQUE\",\n /* 221 */ \"uniqueflag ::=\",\n /* 222 */ \"eidlist_opt ::=\",\n /* 223 */ \"eidlist_opt ::= LP eidlist RP\",\n /* 224 */ \"eidlist ::= eidlist COMMA nm collate sortorder\",\n /* 225 */ \"eidlist ::= nm collate sortorder\",\n /* 226 */ \"collate ::=\",\n /* 227 */ \"collate ::= COLLATE ID|STRING\",\n /* 228 */ \"cmd ::= DROP INDEX ifexists fullname\",\n /* 229 */ \"cmd ::= VACUUM vinto\",\n /* 230 */ \"cmd ::= VACUUM nm vinto\",\n /* 231 */ \"vinto ::= INTO expr\",\n /* 232 */ \"vinto ::=\",\n /* 233 */ \"cmd ::= PRAGMA nm dbnm\",\n /* 234 */ \"cmd ::= PRAGMA nm dbnm EQ nmnum\",\n /* 235 */ \"cmd ::= PRAGMA nm dbnm LP nmnum RP\",\n /* 236 */ \"cmd ::= PRAGMA nm dbnm EQ minus_num\",\n /* 237 */ \"cmd ::= PRAGMA nm dbnm LP minus_num RP\",\n /* 238 */ \"plus_num ::= PLUS INTEGER|FLOAT\",\n /* 239 */ \"minus_num ::= MINUS INTEGER|FLOAT\",\n /* 240 */ \"cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END\",\n /* 241 */ \"trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause\",\n /* 242 */ \"trigger_time ::= BEFORE|AFTER\",\n /* 243 */ \"trigger_time ::= INSTEAD OF\",\n /* 244 */ \"trigger_time ::=\",\n /* 245 */ \"trigger_event ::= DELETE|INSERT\",\n /* 246 */ \"trigger_event ::= UPDATE\",\n /* 247 */ \"trigger_event ::= UPDATE OF idlist\",\n /* 248 */ \"when_clause ::=\",\n /* 249 */ \"when_clause ::= WHEN expr\",\n /* 250 */ \"trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI\",\n /* 251 */ \"trigger_cmd_list ::= trigger_cmd SEMI\",\n /* 252 */ \"trnm ::= nm DOT nm\",\n /* 253 */ \"tridxby ::= INDEXED BY nm\",\n /* 254 */ \"tridxby ::= NOT INDEXED\",\n /* 255 */ \"trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt scanpt\",\n /* 256 */ \"trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt\",\n /* 257 */ \"trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt\",\n /* 258 */ \"trigger_cmd ::= scanpt select scanpt\",\n /* 259 */ \"expr ::= RAISE LP IGNORE RP\",\n /* 260 */ \"expr ::= RAISE LP raisetype COMMA nm RP\",\n /* 261 */ \"raisetype ::= ROLLBACK\",\n /* 262 */ \"raisetype ::= ABORT\",\n /* 263 */ \"raisetype ::= FAIL\",\n /* 264 */ \"cmd ::= DROP TRIGGER ifexists fullname\",\n /* 265 */ \"cmd ::= ATTACH database_kw_opt expr AS expr key_opt\",\n /* 266 */ \"cmd ::= DETACH database_kw_opt expr\",\n /* 267 */ \"key_opt ::=\",\n /* 268 */ \"key_opt ::= KEY expr\",\n /* 269 */ \"cmd ::= REINDEX\",\n /* 270 */ \"cmd ::= REINDEX nm dbnm\",\n /* 271 */ \"cmd ::= ANALYZE\",\n /* 272 */ \"cmd ::= ANALYZE nm dbnm\",\n /* 273 */ \"cmd ::= ALTER TABLE fullname RENAME TO nm\",\n /* 274 */ \"cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist\",\n /* 275 */ \"add_column_fullname ::= fullname\",\n /* 276 */ \"cmd ::= ALTER TABLE fullname RENAME kwcolumn_opt nm TO nm\",\n /* 277 */ \"cmd ::= create_vtab\",\n /* 278 */ \"cmd ::= create_vtab LP vtabarglist RP\",\n /* 279 */ \"create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm\",\n /* 280 */ \"vtabarg ::=\",\n /* 281 */ \"vtabargtoken ::= ANY\",\n /* 282 */ \"vtabargtoken ::= lp anylist RP\",\n /* 283 */ \"lp ::= LP\",\n /* 284 */ \"with ::= WITH wqlist\",\n /* 285 */ \"with ::= WITH RECURSIVE wqlist\",\n /* 286 */ \"wqlist ::= nm eidlist_opt AS LP select RP\",\n /* 287 */ \"wqlist ::= wqlist COMMA nm eidlist_opt AS LP select RP\",\n /* 288 */ \"windowdefn_list ::= windowdefn\",\n /* 289 */ \"windowdefn_list ::= windowdefn_list COMMA windowdefn\",\n /* 290 */ \"windowdefn ::= nm AS window\",\n /* 291 */ \"window ::= LP part_opt orderby_opt frame_opt RP\",\n /* 292 */ \"part_opt ::= PARTITION BY nexprlist\",\n /* 293 */ \"part_opt ::=\",\n /* 294 */ \"frame_opt ::=\",\n /* 295 */ \"frame_opt ::= range_or_rows frame_bound_s\",\n /* 296 */ \"frame_opt ::= range_or_rows BETWEEN frame_bound_s AND frame_bound_e\",\n /* 297 */ \"range_or_rows ::= RANGE\",\n /* 298 */ \"range_or_rows ::= ROWS\",\n /* 299 */ \"frame_bound_s ::= frame_bound\",\n /* 300 */ \"frame_bound_s ::= UNBOUNDED PRECEDING\",\n /* 301 */ \"frame_bound_e ::= frame_bound\",\n /* 302 */ \"frame_bound_e ::= UNBOUNDED FOLLOWING\",\n /* 303 */ \"frame_bound ::= expr PRECEDING\",\n /* 304 */ \"frame_bound ::= CURRENT ROW\",\n /* 305 */ \"frame_bound ::= expr FOLLOWING\",\n /* 306 */ \"window_clause ::= WINDOW windowdefn_list\",\n /* 307 */ \"over_clause ::= filter_opt OVER window\",\n /* 308 */ \"over_clause ::= filter_opt OVER nm\",\n /* 309 */ \"filter_opt ::=\",\n /* 310 */ \"filter_opt ::= FILTER LP WHERE expr RP\",\n /* 311 */ \"input ::= cmdlist\",\n /* 312 */ \"cmdlist ::= cmdlist ecmd\",\n /* 313 */ \"cmdlist ::= ecmd\",\n /* 314 */ \"ecmd ::= SEMI\",\n /* 315 */ \"ecmd ::= cmdx SEMI\",\n /* 316 */ \"ecmd ::= explain cmdx\",\n /* 317 */ \"trans_opt ::=\",\n /* 318 */ \"trans_opt ::= TRANSACTION\",\n /* 319 */ \"trans_opt ::= TRANSACTION nm\",\n /* 320 */ \"savepoint_opt ::= SAVEPOINT\",\n /* 321 */ \"savepoint_opt ::=\",\n /* 322 */ \"cmd ::= create_table create_table_args\",\n /* 323 */ \"columnlist ::= columnlist COMMA columnname carglist\",\n /* 324 */ \"columnlist ::= columnname carglist\",\n /* 325 */ \"nm ::= ID|INDEXED\",\n /* 326 */ \"nm ::= STRING\",\n /* 327 */ \"nm ::= JOIN_KW\",\n /* 328 */ \"typetoken ::= typename\",\n /* 329 */ \"typename ::= ID|STRING\",\n /* 330 */ \"signed ::= plus_num\",\n /* 331 */ \"signed ::= minus_num\",\n /* 332 */ \"carglist ::= carglist ccons\",\n /* 333 */ \"carglist ::=\",\n /* 334 */ \"ccons ::= NULL onconf\",\n /* 335 */ \"conslist_opt ::= COMMA conslist\",\n /* 336 */ \"conslist ::= conslist tconscomma tcons\",\n /* 337 */ \"conslist ::= tcons\",\n /* 338 */ \"tconscomma ::=\",\n /* 339 */ \"defer_subclause_opt ::= defer_subclause\",\n /* 340 */ \"resolvetype ::= raisetype\",\n /* 341 */ \"selectnowith ::= oneselect\",\n /* 342 */ \"oneselect ::= values\",\n /* 343 */ \"sclp ::= selcollist COMMA\",\n /* 344 */ \"as ::= ID|STRING\",\n /* 345 */ \"expr ::= term\",\n /* 346 */ \"likeop ::= LIKE_KW|MATCH\",\n /* 347 */ \"exprlist ::= nexprlist\",\n /* 348 */ \"nmnum ::= plus_num\",\n /* 349 */ \"nmnum ::= nm\",\n /* 350 */ \"nmnum ::= ON\",\n /* 351 */ \"nmnum ::= DELETE\",\n /* 352 */ \"nmnum ::= DEFAULT\",\n /* 353 */ \"plus_num ::= INTEGER|FLOAT\",\n /* 354 */ \"foreach_clause ::=\",\n /* 355 */ \"foreach_clause ::= FOR EACH ROW\",\n /* 356 */ \"trnm ::= nm\",\n /* 357 */ \"tridxby ::=\",\n /* 358 */ \"database_kw_opt ::= DATABASE\",\n /* 359 */ \"database_kw_opt ::=\",\n /* 360 */ \"kwcolumn_opt ::=\",\n /* 361 */ \"kwcolumn_opt ::= COLUMNKW\",\n /* 362 */ \"vtabarglist ::= vtabarg\",\n /* 363 */ \"vtabarglist ::= vtabarglist COMMA vtabarg\",\n /* 364 */ \"vtabarg ::= vtabarg vtabargtoken\",\n /* 365 */ \"anylist ::=\",\n /* 366 */ \"anylist ::= anylist LP anylist RP\",\n /* 367 */ \"anylist ::= anylist ANY\",\n /* 368 */ \"with ::=\",\n};\n#endif /* NDEBUG */\n\n\n#if YYSTACKDEPTH<=0\n/*\n** Try to increase the size of the parser stack.  Return the number\n** of errors.  Return 0 on success.\n*/\nstatic int yyGrowStack(yyParser *p){\n  int newSize;\n  int idx;\n  yyStackEntry *pNew;\n\n  newSize = p->yystksz*2 + 100;\n  idx = p->yytos ? (int)(p->yytos - p->yystack) : 0;\n  if( p->yystack==&p->yystk0 ){\n    pNew = malloc(newSize*sizeof(pNew[0]));\n    if( pNew ) pNew[0] = p->yystk0;\n  }else{\n    pNew = realloc(p->yystack, newSize*sizeof(pNew[0]));\n  }\n  if( pNew ){\n    p->yystack = pNew;\n    p->yytos = &p->yystack[idx];\n#ifndef NDEBUG\n    if( yyTraceFILE ){\n      fprintf(yyTraceFILE,\"%sStack grows from %d to %d entries.\\n\",\n              yyTracePrompt, p->yystksz, newSize);\n    }\n#endif\n    p->yystksz = newSize;\n  }\n  return pNew==0; \n}\n#endif\n\n/* Datatype of the argument to the memory allocated passed as the\n** second argument to sqlite3ParserAlloc() below.  This can be changed by\n** putting an appropriate #define in the %include section of the input\n** grammar.\n*/\n#ifndef YYMALLOCARGTYPE\n# define YYMALLOCARGTYPE size_t\n#endif\n\n/* Initialize a new parser that has already been allocated.\n*/\nSQLITE_PRIVATE void sqlite3ParserInit(void *yypRawParser sqlite3ParserCTX_PDECL){\n  yyParser *yypParser = (yyParser*)yypRawParser;\n  sqlite3ParserCTX_STORE\n#ifdef YYTRACKMAXSTACKDEPTH\n  yypParser->yyhwm = 0;\n#endif\n#if YYSTACKDEPTH<=0\n  yypParser->yytos = NULL;\n  yypParser->yystack = NULL;\n  yypParser->yystksz = 0;\n  if( yyGrowStack(yypParser) ){\n    yypParser->yystack = &yypParser->yystk0;\n    yypParser->yystksz = 1;\n  }\n#endif\n#ifndef YYNOERRORRECOVERY\n  yypParser->yyerrcnt = -1;\n#endif\n  yypParser->yytos = yypParser->yystack;\n  yypParser->yystack[0].stateno = 0;\n  yypParser->yystack[0].major = 0;\n#if YYSTACKDEPTH>0\n  yypParser->yystackEnd = &yypParser->yystack[YYSTACKDEPTH-1];\n#endif\n}\n\n#ifndef sqlite3Parser_ENGINEALWAYSONSTACK\n/* \n** This function allocates a new parser.\n** The only argument is a pointer to a function which works like\n** malloc.\n**\n** Inputs:\n** A pointer to the function used to allocate memory.\n**\n** Outputs:\n** A pointer to a parser.  This pointer is used in subsequent calls\n** to sqlite3Parser and sqlite3ParserFree.\n*/\nSQLITE_PRIVATE void *sqlite3ParserAlloc(void *(*mallocProc)(YYMALLOCARGTYPE) sqlite3ParserCTX_PDECL){\n  yyParser *yypParser;\n  yypParser = (yyParser*)(*mallocProc)( (YYMALLOCARGTYPE)sizeof(yyParser) );\n  if( yypParser ){\n    sqlite3ParserCTX_STORE\n    sqlite3ParserInit(yypParser sqlite3ParserCTX_PARAM);\n  }\n  return (void*)yypParser;\n}\n#endif /* sqlite3Parser_ENGINEALWAYSONSTACK */\n\n\n/* The following function deletes the \"minor type\" or semantic value\n** associated with a symbol.  The symbol can be either a terminal\n** or nonterminal. \"yymajor\" is the symbol code, and \"yypminor\" is\n** a pointer to the value to be deleted.  The code used to do the \n** deletions is derived from the %destructor and/or %token_destructor\n** directives of the input grammar.\n*/\nstatic void yy_destructor(\n  yyParser *yypParser,    /* The parser */\n  YYCODETYPE yymajor,     /* Type code for object to destroy */\n  YYMINORTYPE *yypminor   /* The object to be destroyed */\n){\n  sqlite3ParserARG_FETCH\n  sqlite3ParserCTX_FETCH\n  switch( yymajor ){\n    /* Here is inserted the actions which take place when a\n    ** terminal or non-terminal is destroyed.  This can happen\n    ** when the symbol is popped from the stack during a\n    ** reduce or during error processing or when a parser is \n    ** being destroyed before it is finished parsing.\n    **\n    ** Note: during a reduce, the only symbols destroyed are those\n    ** which appear on the RHS of the rule, but which are *not* used\n    ** inside the C code.\n    */\n/********* Begin destructor definitions ***************************************/\n    case 174: /* select */\n    case 206: /* selectnowith */\n    case 207: /* oneselect */\n    case 219: /* values */\n{\nsqlite3SelectDelete(pParse->db, (yypminor->yy423));\n}\n      break;\n    case 184: /* term */\n    case 185: /* expr */\n    case 213: /* where_opt */\n    case 215: /* having_opt */\n    case 227: /* on_opt */\n    case 242: /* case_operand */\n    case 244: /* case_else */\n    case 247: /* vinto */\n    case 254: /* when_clause */\n    case 259: /* key_opt */\n    case 273: /* filter_opt */\n{\nsqlite3ExprDelete(pParse->db, (yypminor->yy490));\n}\n      break;\n    case 189: /* eidlist_opt */\n    case 198: /* sortlist */\n    case 199: /* eidlist */\n    case 211: /* selcollist */\n    case 214: /* groupby_opt */\n    case 216: /* orderby_opt */\n    case 220: /* nexprlist */\n    case 221: /* sclp */\n    case 229: /* exprlist */\n    case 233: /* setlist */\n    case 241: /* paren_exprlist */\n    case 243: /* case_exprlist */\n    case 272: /* part_opt */\n{\nsqlite3ExprListDelete(pParse->db, (yypminor->yy42));\n}\n      break;\n    case 205: /* fullname */\n    case 212: /* from */\n    case 223: /* seltablist */\n    case 224: /* stl_prefix */\n    case 230: /* xfullname */\n{\nsqlite3SrcListDelete(pParse->db, (yypminor->yy167));\n}\n      break;\n    case 208: /* wqlist */\n{\nsqlite3WithDelete(pParse->db, (yypminor->yy499));\n}\n      break;\n    case 218: /* window_clause */\n    case 268: /* windowdefn_list */\n{\nsqlite3WindowListDelete(pParse->db, (yypminor->yy147));\n}\n      break;\n    case 228: /* using_opt */\n    case 231: /* idlist */\n    case 235: /* idlist_opt */\n{\nsqlite3IdListDelete(pParse->db, (yypminor->yy336));\n}\n      break;\n    case 237: /* over_clause */\n    case 269: /* windowdefn */\n    case 270: /* window */\n    case 271: /* frame_opt */\n{\nsqlite3WindowDelete(pParse->db, (yypminor->yy147));\n}\n      break;\n    case 250: /* trigger_cmd_list */\n    case 255: /* trigger_cmd */\n{\nsqlite3DeleteTriggerStep(pParse->db, (yypminor->yy119));\n}\n      break;\n    case 252: /* trigger_event */\n{\nsqlite3IdListDelete(pParse->db, (yypminor->yy350).b);\n}\n      break;\n    case 275: /* frame_bound */\n    case 276: /* frame_bound_s */\n    case 277: /* frame_bound_e */\n{\nsqlite3ExprDelete(pParse->db, (yypminor->yy317).pExpr);\n}\n      break;\n/********* End destructor definitions *****************************************/\n    default:  break;   /* If no destructor action specified: do nothing */\n  }\n}\n\n/*\n** Pop the parser's stack once.\n**\n** If there is a destructor routine associated with the token which\n** is popped from the stack, then call it.\n*/\nstatic void yy_pop_parser_stack(yyParser *pParser){\n  yyStackEntry *yytos;\n  assert( pParser->yytos!=0 );\n  assert( pParser->yytos > pParser->yystack );\n  yytos = pParser->yytos--;\n#ifndef NDEBUG\n  if( yyTraceFILE ){\n    fprintf(yyTraceFILE,\"%sPopping %s\\n\",\n      yyTracePrompt,\n      yyTokenName[yytos->major]);\n  }\n#endif\n  yy_destructor(pParser, yytos->major, &yytos->minor);\n}\n\n/*\n** Clear all secondary memory allocations from the parser\n*/\nSQLITE_PRIVATE void sqlite3ParserFinalize(void *p){\n  yyParser *pParser = (yyParser*)p;\n  while( pParser->yytos>pParser->yystack ) yy_pop_parser_stack(pParser);\n#if YYSTACKDEPTH<=0\n  if( pParser->yystack!=&pParser->yystk0 ) free(pParser->yystack);\n#endif\n}\n\n#ifndef sqlite3Parser_ENGINEALWAYSONSTACK\n/* \n** Deallocate and destroy a parser.  Destructors are called for\n** all stack elements before shutting the parser down.\n**\n** If the YYPARSEFREENEVERNULL macro exists (for example because it\n** is defined in a %include section of the input grammar) then it is\n** assumed that the input pointer is never NULL.\n*/\nSQLITE_PRIVATE void sqlite3ParserFree(\n  void *p,                    /* The parser to be deleted */\n  void (*freeProc)(void*)     /* Function used to reclaim memory */\n){\n#ifndef YYPARSEFREENEVERNULL\n  if( p==0 ) return;\n#endif\n  sqlite3ParserFinalize(p);\n  (*freeProc)(p);\n}\n#endif /* sqlite3Parser_ENGINEALWAYSONSTACK */\n\n/*\n** Return the peak depth of the stack for a parser.\n*/\n#ifdef YYTRACKMAXSTACKDEPTH\nSQLITE_PRIVATE int sqlite3ParserStackPeak(void *p){\n  yyParser *pParser = (yyParser*)p;\n  return pParser->yyhwm;\n}\n#endif\n\n/* This array of booleans keeps track of the parser statement\n** coverage.  The element yycoverage[X][Y] is set when the parser\n** is in state X and has a lookahead token Y.  In a well-tested\n** systems, every element of this matrix should end up being set.\n*/\n#if defined(YYCOVERAGE)\nstatic unsigned char yycoverage[YYNSTATE][YYNTOKEN];\n#endif\n\n/*\n** Write into out a description of every state/lookahead combination that\n**\n**   (1)  has not been used by the parser, and\n**   (2)  is not a syntax error.\n**\n** Return the number of missed state/lookahead combinations.\n*/\n#if defined(YYCOVERAGE)\nSQLITE_PRIVATE int sqlite3ParserCoverage(FILE *out){\n  int stateno, iLookAhead, i;\n  int nMissed = 0;\n  for(stateno=0; stateno<YYNSTATE; stateno++){\n    i = yy_shift_ofst[stateno];\n    for(iLookAhead=0; iLookAhead<YYNTOKEN; iLookAhead++){\n      if( yy_lookahead[i+iLookAhead]!=iLookAhead ) continue;\n      if( yycoverage[stateno][iLookAhead]==0 ) nMissed++;\n      if( out ){\n        fprintf(out,\"State %d lookahead %s %s\\n\", stateno,\n                yyTokenName[iLookAhead],\n                yycoverage[stateno][iLookAhead] ? \"ok\" : \"missed\");\n      }\n    }\n  }\n  return nMissed;\n}\n#endif\n\n/*\n** Find the appropriate action for a parser given the terminal\n** look-ahead token iLookAhead.\n*/\nstatic YYACTIONTYPE yy_find_shift_action(\n  YYCODETYPE iLookAhead,    /* The look-ahead token */\n  YYACTIONTYPE stateno      /* Current state number */\n){\n  int i;\n\n  if( stateno>YY_MAX_SHIFT ) return stateno;\n  assert( stateno <= YY_SHIFT_COUNT );\n#if defined(YYCOVERAGE)\n  yycoverage[stateno][iLookAhead] = 1;\n#endif\n  do{\n    i = yy_shift_ofst[stateno];\n    assert( i>=0 );\n    /* assert( i+YYNTOKEN<=(int)YY_NLOOKAHEAD ); */\n    assert( iLookAhead!=YYNOCODE );\n    assert( iLookAhead < YYNTOKEN );\n    i += iLookAhead;\n    if( i>=YY_NLOOKAHEAD || yy_lookahead[i]!=iLookAhead ){\n#ifdef YYFALLBACK\n      YYCODETYPE iFallback;            /* Fallback token */\n      if( iLookAhead<sizeof(yyFallback)/sizeof(yyFallback[0])\n             && (iFallback = yyFallback[iLookAhead])!=0 ){\n#ifndef NDEBUG\n        if( yyTraceFILE ){\n          fprintf(yyTraceFILE, \"%sFALLBACK %s => %s\\n\",\n             yyTracePrompt, yyTokenName[iLookAhead], yyTokenName[iFallback]);\n        }\n#endif\n        assert( yyFallback[iFallback]==0 ); /* Fallback loop must terminate */\n        iLookAhead = iFallback;\n        continue;\n      }\n#endif\n#ifdef YYWILDCARD\n      {\n        int j = i - iLookAhead + YYWILDCARD;\n        if( \n#if YY_SHIFT_MIN+YYWILDCARD<0\n          j>=0 &&\n#endif\n#if YY_SHIFT_MAX+YYWILDCARD>=YY_ACTTAB_COUNT\n          j<YY_ACTTAB_COUNT &&\n#endif\n          j<(int)(sizeof(yy_lookahead)/sizeof(yy_lookahead[0])) &&\n          yy_lookahead[j]==YYWILDCARD && iLookAhead>0\n        ){\n#ifndef NDEBUG\n          if( yyTraceFILE ){\n            fprintf(yyTraceFILE, \"%sWILDCARD %s => %s\\n\",\n               yyTracePrompt, yyTokenName[iLookAhead],\n               yyTokenName[YYWILDCARD]);\n          }\n#endif /* NDEBUG */\n          return yy_action[j];\n        }\n      }\n#endif /* YYWILDCARD */\n      return yy_default[stateno];\n    }else{\n      return yy_action[i];\n    }\n  }while(1);\n}\n\n/*\n** Find the appropriate action for a parser given the non-terminal\n** look-ahead token iLookAhead.\n*/\nstatic YYACTIONTYPE yy_find_reduce_action(\n  YYACTIONTYPE stateno,     /* Current state number */\n  YYCODETYPE iLookAhead     /* The look-ahead token */\n){\n  int i;\n#ifdef YYERRORSYMBOL\n  if( stateno>YY_REDUCE_COUNT ){\n    return yy_default[stateno];\n  }\n#else\n  assert( stateno<=YY_REDUCE_COUNT );\n#endif\n  i = yy_reduce_ofst[stateno];\n  assert( iLookAhead!=YYNOCODE );\n  i += iLookAhead;\n#ifdef YYERRORSYMBOL\n  if( i<0 || i>=YY_ACTTAB_COUNT || yy_lookahead[i]!=iLookAhead ){\n    return yy_default[stateno];\n  }\n#else\n  assert( i>=0 && i<YY_ACTTAB_COUNT );\n  assert( yy_lookahead[i]==iLookAhead );\n#endif\n  return yy_action[i];\n}\n\n/*\n** The following routine is called if the stack overflows.\n*/\nstatic void yyStackOverflow(yyParser *yypParser){\n   sqlite3ParserARG_FETCH\n   sqlite3ParserCTX_FETCH\n#ifndef NDEBUG\n   if( yyTraceFILE ){\n     fprintf(yyTraceFILE,\"%sStack Overflow!\\n\",yyTracePrompt);\n   }\n#endif\n   while( yypParser->yytos>yypParser->yystack ) yy_pop_parser_stack(yypParser);\n   /* Here code is inserted which will execute if the parser\n   ** stack every overflows */\n/******** Begin %stack_overflow code ******************************************/\n\n  sqlite3ErrorMsg(pParse, \"parser stack overflow\");\n/******** End %stack_overflow code ********************************************/\n   sqlite3ParserARG_STORE /* Suppress warning about unused %extra_argument var */\n   sqlite3ParserCTX_STORE\n}\n\n/*\n** Print tracing information for a SHIFT action\n*/\n#ifndef NDEBUG\nstatic void yyTraceShift(yyParser *yypParser, int yyNewState, const char *zTag){\n  if( yyTraceFILE ){\n    if( yyNewState<YYNSTATE ){\n      fprintf(yyTraceFILE,\"%s%s '%s', go to state %d\\n\",\n         yyTracePrompt, zTag, yyTokenName[yypParser->yytos->major],\n         yyNewState);\n    }else{\n      fprintf(yyTraceFILE,\"%s%s '%s', pending reduce %d\\n\",\n         yyTracePrompt, zTag, yyTokenName[yypParser->yytos->major],\n         yyNewState - YY_MIN_REDUCE);\n    }\n  }\n}\n#else\n# define yyTraceShift(X,Y,Z)\n#endif\n\n/*\n** Perform a shift action.\n*/\nstatic void yy_shift(\n  yyParser *yypParser,          /* The parser to be shifted */\n  YYACTIONTYPE yyNewState,      /* The new state to shift in */\n  YYCODETYPE yyMajor,           /* The major token to shift in */\n  sqlite3ParserTOKENTYPE yyMinor        /* The minor token to shift in */\n){\n  yyStackEntry *yytos;\n  yypParser->yytos++;\n#ifdef YYTRACKMAXSTACKDEPTH\n  if( (int)(yypParser->yytos - yypParser->yystack)>yypParser->yyhwm ){\n    yypParser->yyhwm++;\n    assert( yypParser->yyhwm == (int)(yypParser->yytos - yypParser->yystack) );\n  }\n#endif\n#if YYSTACKDEPTH>0 \n  if( yypParser->yytos>yypParser->yystackEnd ){\n    yypParser->yytos--;\n    yyStackOverflow(yypParser);\n    return;\n  }\n#else\n  if( yypParser->yytos>=&yypParser->yystack[yypParser->yystksz] ){\n    if( yyGrowStack(yypParser) ){\n      yypParser->yytos--;\n      yyStackOverflow(yypParser);\n      return;\n    }\n  }\n#endif\n  if( yyNewState > YY_MAX_SHIFT ){\n    yyNewState += YY_MIN_REDUCE - YY_MIN_SHIFTREDUCE;\n  }\n  yytos = yypParser->yytos;\n  yytos->stateno = yyNewState;\n  yytos->major = yyMajor;\n  yytos->minor.yy0 = yyMinor;\n  yyTraceShift(yypParser, yyNewState, \"Shift\");\n}\n\n/* For rule J, yyRuleInfoLhs[J] contains the symbol on the left-hand side\n** of that rule */\nstatic const YYCODETYPE yyRuleInfoLhs[] = {\n   159,  /* (0) explain ::= EXPLAIN */\n   159,  /* (1) explain ::= EXPLAIN QUERY PLAN */\n   158,  /* (2) cmdx ::= cmd */\n   160,  /* (3) cmd ::= BEGIN transtype trans_opt */\n   161,  /* (4) transtype ::= */\n   161,  /* (5) transtype ::= DEFERRED */\n   161,  /* (6) transtype ::= IMMEDIATE */\n   161,  /* (7) transtype ::= EXCLUSIVE */\n   160,  /* (8) cmd ::= COMMIT|END trans_opt */\n   160,  /* (9) cmd ::= ROLLBACK trans_opt */\n   160,  /* (10) cmd ::= SAVEPOINT nm */\n   160,  /* (11) cmd ::= RELEASE savepoint_opt nm */\n   160,  /* (12) cmd ::= ROLLBACK trans_opt TO savepoint_opt nm */\n   165,  /* (13) create_table ::= createkw temp TABLE ifnotexists nm dbnm */\n   167,  /* (14) createkw ::= CREATE */\n   169,  /* (15) ifnotexists ::= */\n   169,  /* (16) ifnotexists ::= IF NOT EXISTS */\n   168,  /* (17) temp ::= TEMP */\n   168,  /* (18) temp ::= */\n   166,  /* (19) create_table_args ::= LP columnlist conslist_opt RP table_options */\n   166,  /* (20) create_table_args ::= AS select */\n   173,  /* (21) table_options ::= */\n   173,  /* (22) table_options ::= WITHOUT nm */\n   175,  /* (23) columnname ::= nm typetoken */\n   177,  /* (24) typetoken ::= */\n   177,  /* (25) typetoken ::= typename LP signed RP */\n   177,  /* (26) typetoken ::= typename LP signed COMMA signed RP */\n   178,  /* (27) typename ::= typename ID|STRING */\n   182,  /* (28) scanpt ::= */\n   183,  /* (29) ccons ::= CONSTRAINT nm */\n   183,  /* (30) ccons ::= DEFAULT scanpt term scanpt */\n   183,  /* (31) ccons ::= DEFAULT LP expr RP */\n   183,  /* (32) ccons ::= DEFAULT PLUS term scanpt */\n   183,  /* (33) ccons ::= DEFAULT MINUS term scanpt */\n   183,  /* (34) ccons ::= DEFAULT scanpt ID|INDEXED */\n   183,  /* (35) ccons ::= NOT NULL onconf */\n   183,  /* (36) ccons ::= PRIMARY KEY sortorder onconf autoinc */\n   183,  /* (37) ccons ::= UNIQUE onconf */\n   183,  /* (38) ccons ::= CHECK LP expr RP */\n   183,  /* (39) ccons ::= REFERENCES nm eidlist_opt refargs */\n   183,  /* (40) ccons ::= defer_subclause */\n   183,  /* (41) ccons ::= COLLATE ID|STRING */\n   188,  /* (42) autoinc ::= */\n   188,  /* (43) autoinc ::= AUTOINCR */\n   190,  /* (44) refargs ::= */\n   190,  /* (45) refargs ::= refargs refarg */\n   192,  /* (46) refarg ::= MATCH nm */\n   192,  /* (47) refarg ::= ON INSERT refact */\n   192,  /* (48) refarg ::= ON DELETE refact */\n   192,  /* (49) refarg ::= ON UPDATE refact */\n   193,  /* (50) refact ::= SET NULL */\n   193,  /* (51) refact ::= SET DEFAULT */\n   193,  /* (52) refact ::= CASCADE */\n   193,  /* (53) refact ::= RESTRICT */\n   193,  /* (54) refact ::= NO ACTION */\n   191,  /* (55) defer_subclause ::= NOT DEFERRABLE init_deferred_pred_opt */\n   191,  /* (56) defer_subclause ::= DEFERRABLE init_deferred_pred_opt */\n   194,  /* (57) init_deferred_pred_opt ::= */\n   194,  /* (58) init_deferred_pred_opt ::= INITIALLY DEFERRED */\n   194,  /* (59) init_deferred_pred_opt ::= INITIALLY IMMEDIATE */\n   172,  /* (60) conslist_opt ::= */\n   196,  /* (61) tconscomma ::= COMMA */\n   197,  /* (62) tcons ::= CONSTRAINT nm */\n   197,  /* (63) tcons ::= PRIMARY KEY LP sortlist autoinc RP onconf */\n   197,  /* (64) tcons ::= UNIQUE LP sortlist RP onconf */\n   197,  /* (65) tcons ::= CHECK LP expr RP onconf */\n   197,  /* (66) tcons ::= FOREIGN KEY LP eidlist RP REFERENCES nm eidlist_opt refargs defer_subclause_opt */\n   200,  /* (67) defer_subclause_opt ::= */\n   186,  /* (68) onconf ::= */\n   186,  /* (69) onconf ::= ON CONFLICT resolvetype */\n   201,  /* (70) orconf ::= */\n   201,  /* (71) orconf ::= OR resolvetype */\n   202,  /* (72) resolvetype ::= IGNORE */\n   202,  /* (73) resolvetype ::= REPLACE */\n   160,  /* (74) cmd ::= DROP TABLE ifexists fullname */\n   204,  /* (75) ifexists ::= IF EXISTS */\n   204,  /* (76) ifexists ::= */\n   160,  /* (77) cmd ::= createkw temp VIEW ifnotexists nm dbnm eidlist_opt AS select */\n   160,  /* (78) cmd ::= DROP VIEW ifexists fullname */\n   160,  /* (79) cmd ::= select */\n   174,  /* (80) select ::= WITH wqlist selectnowith */\n   174,  /* (81) select ::= WITH RECURSIVE wqlist selectnowith */\n   174,  /* (82) select ::= selectnowith */\n   206,  /* (83) selectnowith ::= selectnowith multiselect_op oneselect */\n   209,  /* (84) multiselect_op ::= UNION */\n   209,  /* (85) multiselect_op ::= UNION ALL */\n   209,  /* (86) multiselect_op ::= EXCEPT|INTERSECT */\n   207,  /* (87) oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt orderby_opt limit_opt */\n   207,  /* (88) oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt window_clause orderby_opt limit_opt */\n   219,  /* (89) values ::= VALUES LP nexprlist RP */\n   219,  /* (90) values ::= values COMMA LP nexprlist RP */\n   210,  /* (91) distinct ::= DISTINCT */\n   210,  /* (92) distinct ::= ALL */\n   210,  /* (93) distinct ::= */\n   221,  /* (94) sclp ::= */\n   211,  /* (95) selcollist ::= sclp scanpt expr scanpt as */\n   211,  /* (96) selcollist ::= sclp scanpt STAR */\n   211,  /* (97) selcollist ::= sclp scanpt nm DOT STAR */\n   222,  /* (98) as ::= AS nm */\n   222,  /* (99) as ::= */\n   212,  /* (100) from ::= */\n   212,  /* (101) from ::= FROM seltablist */\n   224,  /* (102) stl_prefix ::= seltablist joinop */\n   224,  /* (103) stl_prefix ::= */\n   223,  /* (104) seltablist ::= stl_prefix nm dbnm as indexed_opt on_opt using_opt */\n   223,  /* (105) seltablist ::= stl_prefix nm dbnm LP exprlist RP as on_opt using_opt */\n   223,  /* (106) seltablist ::= stl_prefix LP select RP as on_opt using_opt */\n   223,  /* (107) seltablist ::= stl_prefix LP seltablist RP as on_opt using_opt */\n   170,  /* (108) dbnm ::= */\n   170,  /* (109) dbnm ::= DOT nm */\n   205,  /* (110) fullname ::= nm */\n   205,  /* (111) fullname ::= nm DOT nm */\n   230,  /* (112) xfullname ::= nm */\n   230,  /* (113) xfullname ::= nm DOT nm */\n   230,  /* (114) xfullname ::= nm DOT nm AS nm */\n   230,  /* (115) xfullname ::= nm AS nm */\n   225,  /* (116) joinop ::= COMMA|JOIN */\n   225,  /* (117) joinop ::= JOIN_KW JOIN */\n   225,  /* (118) joinop ::= JOIN_KW nm JOIN */\n   225,  /* (119) joinop ::= JOIN_KW nm nm JOIN */\n   227,  /* (120) on_opt ::= ON expr */\n   227,  /* (121) on_opt ::= */\n   226,  /* (122) indexed_opt ::= */\n   226,  /* (123) indexed_opt ::= INDEXED BY nm */\n   226,  /* (124) indexed_opt ::= NOT INDEXED */\n   228,  /* (125) using_opt ::= USING LP idlist RP */\n   228,  /* (126) using_opt ::= */\n   216,  /* (127) orderby_opt ::= */\n   216,  /* (128) orderby_opt ::= ORDER BY sortlist */\n   198,  /* (129) sortlist ::= sortlist COMMA expr sortorder */\n   198,  /* (130) sortlist ::= expr sortorder */\n   187,  /* (131) sortorder ::= ASC */\n   187,  /* (132) sortorder ::= DESC */\n   187,  /* (133) sortorder ::= */\n   214,  /* (134) groupby_opt ::= */\n   214,  /* (135) groupby_opt ::= GROUP BY nexprlist */\n   215,  /* (136) having_opt ::= */\n   215,  /* (137) having_opt ::= HAVING expr */\n   217,  /* (138) limit_opt ::= */\n   217,  /* (139) limit_opt ::= LIMIT expr */\n   217,  /* (140) limit_opt ::= LIMIT expr OFFSET expr */\n   217,  /* (141) limit_opt ::= LIMIT expr COMMA expr */\n   160,  /* (142) cmd ::= with DELETE FROM xfullname indexed_opt where_opt */\n   213,  /* (143) where_opt ::= */\n   213,  /* (144) where_opt ::= WHERE expr */\n   160,  /* (145) cmd ::= with UPDATE orconf xfullname indexed_opt SET setlist where_opt */\n   233,  /* (146) setlist ::= setlist COMMA nm EQ expr */\n   233,  /* (147) setlist ::= setlist COMMA LP idlist RP EQ expr */\n   233,  /* (148) setlist ::= nm EQ expr */\n   233,  /* (149) setlist ::= LP idlist RP EQ expr */\n   160,  /* (150) cmd ::= with insert_cmd INTO xfullname idlist_opt select upsert */\n   160,  /* (151) cmd ::= with insert_cmd INTO xfullname idlist_opt DEFAULT VALUES */\n   236,  /* (152) upsert ::= */\n   236,  /* (153) upsert ::= ON CONFLICT LP sortlist RP where_opt DO UPDATE SET setlist where_opt */\n   236,  /* (154) upsert ::= ON CONFLICT LP sortlist RP where_opt DO NOTHING */\n   236,  /* (155) upsert ::= ON CONFLICT DO NOTHING */\n   234,  /* (156) insert_cmd ::= INSERT orconf */\n   234,  /* (157) insert_cmd ::= REPLACE */\n   235,  /* (158) idlist_opt ::= */\n   235,  /* (159) idlist_opt ::= LP idlist RP */\n   231,  /* (160) idlist ::= idlist COMMA nm */\n   231,  /* (161) idlist ::= nm */\n   185,  /* (162) expr ::= LP expr RP */\n   185,  /* (163) expr ::= ID|INDEXED */\n   185,  /* (164) expr ::= JOIN_KW */\n   185,  /* (165) expr ::= nm DOT nm */\n   185,  /* (166) expr ::= nm DOT nm DOT nm */\n   184,  /* (167) term ::= NULL|FLOAT|BLOB */\n   184,  /* (168) term ::= STRING */\n   184,  /* (169) term ::= INTEGER */\n   185,  /* (170) expr ::= VARIABLE */\n   185,  /* (171) expr ::= expr COLLATE ID|STRING */\n   185,  /* (172) expr ::= CAST LP expr AS typetoken RP */\n   185,  /* (173) expr ::= ID|INDEXED LP distinct exprlist RP */\n   185,  /* (174) expr ::= ID|INDEXED LP STAR RP */\n   185,  /* (175) expr ::= ID|INDEXED LP distinct exprlist RP over_clause */\n   185,  /* (176) expr ::= ID|INDEXED LP STAR RP over_clause */\n   184,  /* (177) term ::= CTIME_KW */\n   185,  /* (178) expr ::= LP nexprlist COMMA expr RP */\n   185,  /* (179) expr ::= expr AND expr */\n   185,  /* (180) expr ::= expr OR expr */\n   185,  /* (181) expr ::= expr LT|GT|GE|LE expr */\n   185,  /* (182) expr ::= expr EQ|NE expr */\n   185,  /* (183) expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr */\n   185,  /* (184) expr ::= expr PLUS|MINUS expr */\n   185,  /* (185) expr ::= expr STAR|SLASH|REM expr */\n   185,  /* (186) expr ::= expr CONCAT expr */\n   238,  /* (187) likeop ::= NOT LIKE_KW|MATCH */\n   185,  /* (188) expr ::= expr likeop expr */\n   185,  /* (189) expr ::= expr likeop expr ESCAPE expr */\n   185,  /* (190) expr ::= expr ISNULL|NOTNULL */\n   185,  /* (191) expr ::= expr NOT NULL */\n   185,  /* (192) expr ::= expr IS expr */\n   185,  /* (193) expr ::= expr IS NOT expr */\n   185,  /* (194) expr ::= NOT expr */\n   185,  /* (195) expr ::= BITNOT expr */\n   185,  /* (196) expr ::= PLUS|MINUS expr */\n   239,  /* (197) between_op ::= BETWEEN */\n   239,  /* (198) between_op ::= NOT BETWEEN */\n   185,  /* (199) expr ::= expr between_op expr AND expr */\n   240,  /* (200) in_op ::= IN */\n   240,  /* (201) in_op ::= NOT IN */\n   185,  /* (202) expr ::= expr in_op LP exprlist RP */\n   185,  /* (203) expr ::= LP select RP */\n   185,  /* (204) expr ::= expr in_op LP select RP */\n   185,  /* (205) expr ::= expr in_op nm dbnm paren_exprlist */\n   185,  /* (206) expr ::= EXISTS LP select RP */\n   185,  /* (207) expr ::= CASE case_operand case_exprlist case_else END */\n   243,  /* (208) case_exprlist ::= case_exprlist WHEN expr THEN expr */\n   243,  /* (209) case_exprlist ::= WHEN expr THEN expr */\n   244,  /* (210) case_else ::= ELSE expr */\n   244,  /* (211) case_else ::= */\n   242,  /* (212) case_operand ::= expr */\n   242,  /* (213) case_operand ::= */\n   229,  /* (214) exprlist ::= */\n   220,  /* (215) nexprlist ::= nexprlist COMMA expr */\n   220,  /* (216) nexprlist ::= expr */\n   241,  /* (217) paren_exprlist ::= */\n   241,  /* (218) paren_exprlist ::= LP exprlist RP */\n   160,  /* (219) cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt */\n   245,  /* (220) uniqueflag ::= UNIQUE */\n   245,  /* (221) uniqueflag ::= */\n   189,  /* (222) eidlist_opt ::= */\n   189,  /* (223) eidlist_opt ::= LP eidlist RP */\n   199,  /* (224) eidlist ::= eidlist COMMA nm collate sortorder */\n   199,  /* (225) eidlist ::= nm collate sortorder */\n   246,  /* (226) collate ::= */\n   246,  /* (227) collate ::= COLLATE ID|STRING */\n   160,  /* (228) cmd ::= DROP INDEX ifexists fullname */\n   160,  /* (229) cmd ::= VACUUM vinto */\n   160,  /* (230) cmd ::= VACUUM nm vinto */\n   247,  /* (231) vinto ::= INTO expr */\n   247,  /* (232) vinto ::= */\n   160,  /* (233) cmd ::= PRAGMA nm dbnm */\n   160,  /* (234) cmd ::= PRAGMA nm dbnm EQ nmnum */\n   160,  /* (235) cmd ::= PRAGMA nm dbnm LP nmnum RP */\n   160,  /* (236) cmd ::= PRAGMA nm dbnm EQ minus_num */\n   160,  /* (237) cmd ::= PRAGMA nm dbnm LP minus_num RP */\n   180,  /* (238) plus_num ::= PLUS INTEGER|FLOAT */\n   181,  /* (239) minus_num ::= MINUS INTEGER|FLOAT */\n   160,  /* (240) cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */\n   249,  /* (241) trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */\n   251,  /* (242) trigger_time ::= BEFORE|AFTER */\n   251,  /* (243) trigger_time ::= INSTEAD OF */\n   251,  /* (244) trigger_time ::= */\n   252,  /* (245) trigger_event ::= DELETE|INSERT */\n   252,  /* (246) trigger_event ::= UPDATE */\n   252,  /* (247) trigger_event ::= UPDATE OF idlist */\n   254,  /* (248) when_clause ::= */\n   254,  /* (249) when_clause ::= WHEN expr */\n   250,  /* (250) trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */\n   250,  /* (251) trigger_cmd_list ::= trigger_cmd SEMI */\n   256,  /* (252) trnm ::= nm DOT nm */\n   257,  /* (253) tridxby ::= INDEXED BY nm */\n   257,  /* (254) tridxby ::= NOT INDEXED */\n   255,  /* (255) trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt scanpt */\n   255,  /* (256) trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt */\n   255,  /* (257) trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt */\n   255,  /* (258) trigger_cmd ::= scanpt select scanpt */\n   185,  /* (259) expr ::= RAISE LP IGNORE RP */\n   185,  /* (260) expr ::= RAISE LP raisetype COMMA nm RP */\n   203,  /* (261) raisetype ::= ROLLBACK */\n   203,  /* (262) raisetype ::= ABORT */\n   203,  /* (263) raisetype ::= FAIL */\n   160,  /* (264) cmd ::= DROP TRIGGER ifexists fullname */\n   160,  /* (265) cmd ::= ATTACH database_kw_opt expr AS expr key_opt */\n   160,  /* (266) cmd ::= DETACH database_kw_opt expr */\n   259,  /* (267) key_opt ::= */\n   259,  /* (268) key_opt ::= KEY expr */\n   160,  /* (269) cmd ::= REINDEX */\n   160,  /* (270) cmd ::= REINDEX nm dbnm */\n   160,  /* (271) cmd ::= ANALYZE */\n   160,  /* (272) cmd ::= ANALYZE nm dbnm */\n   160,  /* (273) cmd ::= ALTER TABLE fullname RENAME TO nm */\n   160,  /* (274) cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist */\n   260,  /* (275) add_column_fullname ::= fullname */\n   160,  /* (276) cmd ::= ALTER TABLE fullname RENAME kwcolumn_opt nm TO nm */\n   160,  /* (277) cmd ::= create_vtab */\n   160,  /* (278) cmd ::= create_vtab LP vtabarglist RP */\n   262,  /* (279) create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */\n   264,  /* (280) vtabarg ::= */\n   265,  /* (281) vtabargtoken ::= ANY */\n   265,  /* (282) vtabargtoken ::= lp anylist RP */\n   266,  /* (283) lp ::= LP */\n   232,  /* (284) with ::= WITH wqlist */\n   232,  /* (285) with ::= WITH RECURSIVE wqlist */\n   208,  /* (286) wqlist ::= nm eidlist_opt AS LP select RP */\n   208,  /* (287) wqlist ::= wqlist COMMA nm eidlist_opt AS LP select RP */\n   268,  /* (288) windowdefn_list ::= windowdefn */\n   268,  /* (289) windowdefn_list ::= windowdefn_list COMMA windowdefn */\n   269,  /* (290) windowdefn ::= nm AS window */\n   270,  /* (291) window ::= LP part_opt orderby_opt frame_opt RP */\n   272,  /* (292) part_opt ::= PARTITION BY nexprlist */\n   272,  /* (293) part_opt ::= */\n   271,  /* (294) frame_opt ::= */\n   271,  /* (295) frame_opt ::= range_or_rows frame_bound_s */\n   271,  /* (296) frame_opt ::= range_or_rows BETWEEN frame_bound_s AND frame_bound_e */\n   274,  /* (297) range_or_rows ::= RANGE */\n   274,  /* (298) range_or_rows ::= ROWS */\n   276,  /* (299) frame_bound_s ::= frame_bound */\n   276,  /* (300) frame_bound_s ::= UNBOUNDED PRECEDING */\n   277,  /* (301) frame_bound_e ::= frame_bound */\n   277,  /* (302) frame_bound_e ::= UNBOUNDED FOLLOWING */\n   275,  /* (303) frame_bound ::= expr PRECEDING */\n   275,  /* (304) frame_bound ::= CURRENT ROW */\n   275,  /* (305) frame_bound ::= expr FOLLOWING */\n   218,  /* (306) window_clause ::= WINDOW windowdefn_list */\n   237,  /* (307) over_clause ::= filter_opt OVER window */\n   237,  /* (308) over_clause ::= filter_opt OVER nm */\n   273,  /* (309) filter_opt ::= */\n   273,  /* (310) filter_opt ::= FILTER LP WHERE expr RP */\n   155,  /* (311) input ::= cmdlist */\n   156,  /* (312) cmdlist ::= cmdlist ecmd */\n   156,  /* (313) cmdlist ::= ecmd */\n   157,  /* (314) ecmd ::= SEMI */\n   157,  /* (315) ecmd ::= cmdx SEMI */\n   157,  /* (316) ecmd ::= explain cmdx */\n   162,  /* (317) trans_opt ::= */\n   162,  /* (318) trans_opt ::= TRANSACTION */\n   162,  /* (319) trans_opt ::= TRANSACTION nm */\n   164,  /* (320) savepoint_opt ::= SAVEPOINT */\n   164,  /* (321) savepoint_opt ::= */\n   160,  /* (322) cmd ::= create_table create_table_args */\n   171,  /* (323) columnlist ::= columnlist COMMA columnname carglist */\n   171,  /* (324) columnlist ::= columnname carglist */\n   163,  /* (325) nm ::= ID|INDEXED */\n   163,  /* (326) nm ::= STRING */\n   163,  /* (327) nm ::= JOIN_KW */\n   177,  /* (328) typetoken ::= typename */\n   178,  /* (329) typename ::= ID|STRING */\n   179,  /* (330) signed ::= plus_num */\n   179,  /* (331) signed ::= minus_num */\n   176,  /* (332) carglist ::= carglist ccons */\n   176,  /* (333) carglist ::= */\n   183,  /* (334) ccons ::= NULL onconf */\n   172,  /* (335) conslist_opt ::= COMMA conslist */\n   195,  /* (336) conslist ::= conslist tconscomma tcons */\n   195,  /* (337) conslist ::= tcons */\n   196,  /* (338) tconscomma ::= */\n   200,  /* (339) defer_subclause_opt ::= defer_subclause */\n   202,  /* (340) resolvetype ::= raisetype */\n   206,  /* (341) selectnowith ::= oneselect */\n   207,  /* (342) oneselect ::= values */\n   221,  /* (343) sclp ::= selcollist COMMA */\n   222,  /* (344) as ::= ID|STRING */\n   185,  /* (345) expr ::= term */\n   238,  /* (346) likeop ::= LIKE_KW|MATCH */\n   229,  /* (347) exprlist ::= nexprlist */\n   248,  /* (348) nmnum ::= plus_num */\n   248,  /* (349) nmnum ::= nm */\n   248,  /* (350) nmnum ::= ON */\n   248,  /* (351) nmnum ::= DELETE */\n   248,  /* (352) nmnum ::= DEFAULT */\n   180,  /* (353) plus_num ::= INTEGER|FLOAT */\n   253,  /* (354) foreach_clause ::= */\n   253,  /* (355) foreach_clause ::= FOR EACH ROW */\n   256,  /* (356) trnm ::= nm */\n   257,  /* (357) tridxby ::= */\n   258,  /* (358) database_kw_opt ::= DATABASE */\n   258,  /* (359) database_kw_opt ::= */\n   261,  /* (360) kwcolumn_opt ::= */\n   261,  /* (361) kwcolumn_opt ::= COLUMNKW */\n   263,  /* (362) vtabarglist ::= vtabarg */\n   263,  /* (363) vtabarglist ::= vtabarglist COMMA vtabarg */\n   264,  /* (364) vtabarg ::= vtabarg vtabargtoken */\n   267,  /* (365) anylist ::= */\n   267,  /* (366) anylist ::= anylist LP anylist RP */\n   267,  /* (367) anylist ::= anylist ANY */\n   232,  /* (368) with ::= */\n};\n\n/* For rule J, yyRuleInfoNRhs[J] contains the negative of the number\n** of symbols on the right-hand side of that rule. */\nstatic const signed char yyRuleInfoNRhs[] = {\n   -1,  /* (0) explain ::= EXPLAIN */\n   -3,  /* (1) explain ::= EXPLAIN QUERY PLAN */\n   -1,  /* (2) cmdx ::= cmd */\n   -3,  /* (3) cmd ::= BEGIN transtype trans_opt */\n    0,  /* (4) transtype ::= */\n   -1,  /* (5) transtype ::= DEFERRED */\n   -1,  /* (6) transtype ::= IMMEDIATE */\n   -1,  /* (7) transtype ::= EXCLUSIVE */\n   -2,  /* (8) cmd ::= COMMIT|END trans_opt */\n   -2,  /* (9) cmd ::= ROLLBACK trans_opt */\n   -2,  /* (10) cmd ::= SAVEPOINT nm */\n   -3,  /* (11) cmd ::= RELEASE savepoint_opt nm */\n   -5,  /* (12) cmd ::= ROLLBACK trans_opt TO savepoint_opt nm */\n   -6,  /* (13) create_table ::= createkw temp TABLE ifnotexists nm dbnm */\n   -1,  /* (14) createkw ::= CREATE */\n    0,  /* (15) ifnotexists ::= */\n   -3,  /* (16) ifnotexists ::= IF NOT EXISTS */\n   -1,  /* (17) temp ::= TEMP */\n    0,  /* (18) temp ::= */\n   -5,  /* (19) create_table_args ::= LP columnlist conslist_opt RP table_options */\n   -2,  /* (20) create_table_args ::= AS select */\n    0,  /* (21) table_options ::= */\n   -2,  /* (22) table_options ::= WITHOUT nm */\n   -2,  /* (23) columnname ::= nm typetoken */\n    0,  /* (24) typetoken ::= */\n   -4,  /* (25) typetoken ::= typename LP signed RP */\n   -6,  /* (26) typetoken ::= typename LP signed COMMA signed RP */\n   -2,  /* (27) typename ::= typename ID|STRING */\n    0,  /* (28) scanpt ::= */\n   -2,  /* (29) ccons ::= CONSTRAINT nm */\n   -4,  /* (30) ccons ::= DEFAULT scanpt term scanpt */\n   -4,  /* (31) ccons ::= DEFAULT LP expr RP */\n   -4,  /* (32) ccons ::= DEFAULT PLUS term scanpt */\n   -4,  /* (33) ccons ::= DEFAULT MINUS term scanpt */\n   -3,  /* (34) ccons ::= DEFAULT scanpt ID|INDEXED */\n   -3,  /* (35) ccons ::= NOT NULL onconf */\n   -5,  /* (36) ccons ::= PRIMARY KEY sortorder onconf autoinc */\n   -2,  /* (37) ccons ::= UNIQUE onconf */\n   -4,  /* (38) ccons ::= CHECK LP expr RP */\n   -4,  /* (39) ccons ::= REFERENCES nm eidlist_opt refargs */\n   -1,  /* (40) ccons ::= defer_subclause */\n   -2,  /* (41) ccons ::= COLLATE ID|STRING */\n    0,  /* (42) autoinc ::= */\n   -1,  /* (43) autoinc ::= AUTOINCR */\n    0,  /* (44) refargs ::= */\n   -2,  /* (45) refargs ::= refargs refarg */\n   -2,  /* (46) refarg ::= MATCH nm */\n   -3,  /* (47) refarg ::= ON INSERT refact */\n   -3,  /* (48) refarg ::= ON DELETE refact */\n   -3,  /* (49) refarg ::= ON UPDATE refact */\n   -2,  /* (50) refact ::= SET NULL */\n   -2,  /* (51) refact ::= SET DEFAULT */\n   -1,  /* (52) refact ::= CASCADE */\n   -1,  /* (53) refact ::= RESTRICT */\n   -2,  /* (54) refact ::= NO ACTION */\n   -3,  /* (55) defer_subclause ::= NOT DEFERRABLE init_deferred_pred_opt */\n   -2,  /* (56) defer_subclause ::= DEFERRABLE init_deferred_pred_opt */\n    0,  /* (57) init_deferred_pred_opt ::= */\n   -2,  /* (58) init_deferred_pred_opt ::= INITIALLY DEFERRED */\n   -2,  /* (59) init_deferred_pred_opt ::= INITIALLY IMMEDIATE */\n    0,  /* (60) conslist_opt ::= */\n   -1,  /* (61) tconscomma ::= COMMA */\n   -2,  /* (62) tcons ::= CONSTRAINT nm */\n   -7,  /* (63) tcons ::= PRIMARY KEY LP sortlist autoinc RP onconf */\n   -5,  /* (64) tcons ::= UNIQUE LP sortlist RP onconf */\n   -5,  /* (65) tcons ::= CHECK LP expr RP onconf */\n  -10,  /* (66) tcons ::= FOREIGN KEY LP eidlist RP REFERENCES nm eidlist_opt refargs defer_subclause_opt */\n    0,  /* (67) defer_subclause_opt ::= */\n    0,  /* (68) onconf ::= */\n   -3,  /* (69) onconf ::= ON CONFLICT resolvetype */\n    0,  /* (70) orconf ::= */\n   -2,  /* (71) orconf ::= OR resolvetype */\n   -1,  /* (72) resolvetype ::= IGNORE */\n   -1,  /* (73) resolvetype ::= REPLACE */\n   -4,  /* (74) cmd ::= DROP TABLE ifexists fullname */\n   -2,  /* (75) ifexists ::= IF EXISTS */\n    0,  /* (76) ifexists ::= */\n   -9,  /* (77) cmd ::= createkw temp VIEW ifnotexists nm dbnm eidlist_opt AS select */\n   -4,  /* (78) cmd ::= DROP VIEW ifexists fullname */\n   -1,  /* (79) cmd ::= select */\n   -3,  /* (80) select ::= WITH wqlist selectnowith */\n   -4,  /* (81) select ::= WITH RECURSIVE wqlist selectnowith */\n   -1,  /* (82) select ::= selectnowith */\n   -3,  /* (83) selectnowith ::= selectnowith multiselect_op oneselect */\n   -1,  /* (84) multiselect_op ::= UNION */\n   -2,  /* (85) multiselect_op ::= UNION ALL */\n   -1,  /* (86) multiselect_op ::= EXCEPT|INTERSECT */\n   -9,  /* (87) oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt orderby_opt limit_opt */\n  -10,  /* (88) oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt window_clause orderby_opt limit_opt */\n   -4,  /* (89) values ::= VALUES LP nexprlist RP */\n   -5,  /* (90) values ::= values COMMA LP nexprlist RP */\n   -1,  /* (91) distinct ::= DISTINCT */\n   -1,  /* (92) distinct ::= ALL */\n    0,  /* (93) distinct ::= */\n    0,  /* (94) sclp ::= */\n   -5,  /* (95) selcollist ::= sclp scanpt expr scanpt as */\n   -3,  /* (96) selcollist ::= sclp scanpt STAR */\n   -5,  /* (97) selcollist ::= sclp scanpt nm DOT STAR */\n   -2,  /* (98) as ::= AS nm */\n    0,  /* (99) as ::= */\n    0,  /* (100) from ::= */\n   -2,  /* (101) from ::= FROM seltablist */\n   -2,  /* (102) stl_prefix ::= seltablist joinop */\n    0,  /* (103) stl_prefix ::= */\n   -7,  /* (104) seltablist ::= stl_prefix nm dbnm as indexed_opt on_opt using_opt */\n   -9,  /* (105) seltablist ::= stl_prefix nm dbnm LP exprlist RP as on_opt using_opt */\n   -7,  /* (106) seltablist ::= stl_prefix LP select RP as on_opt using_opt */\n   -7,  /* (107) seltablist ::= stl_prefix LP seltablist RP as on_opt using_opt */\n    0,  /* (108) dbnm ::= */\n   -2,  /* (109) dbnm ::= DOT nm */\n   -1,  /* (110) fullname ::= nm */\n   -3,  /* (111) fullname ::= nm DOT nm */\n   -1,  /* (112) xfullname ::= nm */\n   -3,  /* (113) xfullname ::= nm DOT nm */\n   -5,  /* (114) xfullname ::= nm DOT nm AS nm */\n   -3,  /* (115) xfullname ::= nm AS nm */\n   -1,  /* (116) joinop ::= COMMA|JOIN */\n   -2,  /* (117) joinop ::= JOIN_KW JOIN */\n   -3,  /* (118) joinop ::= JOIN_KW nm JOIN */\n   -4,  /* (119) joinop ::= JOIN_KW nm nm JOIN */\n   -2,  /* (120) on_opt ::= ON expr */\n    0,  /* (121) on_opt ::= */\n    0,  /* (122) indexed_opt ::= */\n   -3,  /* (123) indexed_opt ::= INDEXED BY nm */\n   -2,  /* (124) indexed_opt ::= NOT INDEXED */\n   -4,  /* (125) using_opt ::= USING LP idlist RP */\n    0,  /* (126) using_opt ::= */\n    0,  /* (127) orderby_opt ::= */\n   -3,  /* (128) orderby_opt ::= ORDER BY sortlist */\n   -4,  /* (129) sortlist ::= sortlist COMMA expr sortorder */\n   -2,  /* (130) sortlist ::= expr sortorder */\n   -1,  /* (131) sortorder ::= ASC */\n   -1,  /* (132) sortorder ::= DESC */\n    0,  /* (133) sortorder ::= */\n    0,  /* (134) groupby_opt ::= */\n   -3,  /* (135) groupby_opt ::= GROUP BY nexprlist */\n    0,  /* (136) having_opt ::= */\n   -2,  /* (137) having_opt ::= HAVING expr */\n    0,  /* (138) limit_opt ::= */\n   -2,  /* (139) limit_opt ::= LIMIT expr */\n   -4,  /* (140) limit_opt ::= LIMIT expr OFFSET expr */\n   -4,  /* (141) limit_opt ::= LIMIT expr COMMA expr */\n   -6,  /* (142) cmd ::= with DELETE FROM xfullname indexed_opt where_opt */\n    0,  /* (143) where_opt ::= */\n   -2,  /* (144) where_opt ::= WHERE expr */\n   -8,  /* (145) cmd ::= with UPDATE orconf xfullname indexed_opt SET setlist where_opt */\n   -5,  /* (146) setlist ::= setlist COMMA nm EQ expr */\n   -7,  /* (147) setlist ::= setlist COMMA LP idlist RP EQ expr */\n   -3,  /* (148) setlist ::= nm EQ expr */\n   -5,  /* (149) setlist ::= LP idlist RP EQ expr */\n   -7,  /* (150) cmd ::= with insert_cmd INTO xfullname idlist_opt select upsert */\n   -7,  /* (151) cmd ::= with insert_cmd INTO xfullname idlist_opt DEFAULT VALUES */\n    0,  /* (152) upsert ::= */\n  -11,  /* (153) upsert ::= ON CONFLICT LP sortlist RP where_opt DO UPDATE SET setlist where_opt */\n   -8,  /* (154) upsert ::= ON CONFLICT LP sortlist RP where_opt DO NOTHING */\n   -4,  /* (155) upsert ::= ON CONFLICT DO NOTHING */\n   -2,  /* (156) insert_cmd ::= INSERT orconf */\n   -1,  /* (157) insert_cmd ::= REPLACE */\n    0,  /* (158) idlist_opt ::= */\n   -3,  /* (159) idlist_opt ::= LP idlist RP */\n   -3,  /* (160) idlist ::= idlist COMMA nm */\n   -1,  /* (161) idlist ::= nm */\n   -3,  /* (162) expr ::= LP expr RP */\n   -1,  /* (163) expr ::= ID|INDEXED */\n   -1,  /* (164) expr ::= JOIN_KW */\n   -3,  /* (165) expr ::= nm DOT nm */\n   -5,  /* (166) expr ::= nm DOT nm DOT nm */\n   -1,  /* (167) term ::= NULL|FLOAT|BLOB */\n   -1,  /* (168) term ::= STRING */\n   -1,  /* (169) term ::= INTEGER */\n   -1,  /* (170) expr ::= VARIABLE */\n   -3,  /* (171) expr ::= expr COLLATE ID|STRING */\n   -6,  /* (172) expr ::= CAST LP expr AS typetoken RP */\n   -5,  /* (173) expr ::= ID|INDEXED LP distinct exprlist RP */\n   -4,  /* (174) expr ::= ID|INDEXED LP STAR RP */\n   -6,  /* (175) expr ::= ID|INDEXED LP distinct exprlist RP over_clause */\n   -5,  /* (176) expr ::= ID|INDEXED LP STAR RP over_clause */\n   -1,  /* (177) term ::= CTIME_KW */\n   -5,  /* (178) expr ::= LP nexprlist COMMA expr RP */\n   -3,  /* (179) expr ::= expr AND expr */\n   -3,  /* (180) expr ::= expr OR expr */\n   -3,  /* (181) expr ::= expr LT|GT|GE|LE expr */\n   -3,  /* (182) expr ::= expr EQ|NE expr */\n   -3,  /* (183) expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr */\n   -3,  /* (184) expr ::= expr PLUS|MINUS expr */\n   -3,  /* (185) expr ::= expr STAR|SLASH|REM expr */\n   -3,  /* (186) expr ::= expr CONCAT expr */\n   -2,  /* (187) likeop ::= NOT LIKE_KW|MATCH */\n   -3,  /* (188) expr ::= expr likeop expr */\n   -5,  /* (189) expr ::= expr likeop expr ESCAPE expr */\n   -2,  /* (190) expr ::= expr ISNULL|NOTNULL */\n   -3,  /* (191) expr ::= expr NOT NULL */\n   -3,  /* (192) expr ::= expr IS expr */\n   -4,  /* (193) expr ::= expr IS NOT expr */\n   -2,  /* (194) expr ::= NOT expr */\n   -2,  /* (195) expr ::= BITNOT expr */\n   -2,  /* (196) expr ::= PLUS|MINUS expr */\n   -1,  /* (197) between_op ::= BETWEEN */\n   -2,  /* (198) between_op ::= NOT BETWEEN */\n   -5,  /* (199) expr ::= expr between_op expr AND expr */\n   -1,  /* (200) in_op ::= IN */\n   -2,  /* (201) in_op ::= NOT IN */\n   -5,  /* (202) expr ::= expr in_op LP exprlist RP */\n   -3,  /* (203) expr ::= LP select RP */\n   -5,  /* (204) expr ::= expr in_op LP select RP */\n   -5,  /* (205) expr ::= expr in_op nm dbnm paren_exprlist */\n   -4,  /* (206) expr ::= EXISTS LP select RP */\n   -5,  /* (207) expr ::= CASE case_operand case_exprlist case_else END */\n   -5,  /* (208) case_exprlist ::= case_exprlist WHEN expr THEN expr */\n   -4,  /* (209) case_exprlist ::= WHEN expr THEN expr */\n   -2,  /* (210) case_else ::= ELSE expr */\n    0,  /* (211) case_else ::= */\n   -1,  /* (212) case_operand ::= expr */\n    0,  /* (213) case_operand ::= */\n    0,  /* (214) exprlist ::= */\n   -3,  /* (215) nexprlist ::= nexprlist COMMA expr */\n   -1,  /* (216) nexprlist ::= expr */\n    0,  /* (217) paren_exprlist ::= */\n   -3,  /* (218) paren_exprlist ::= LP exprlist RP */\n  -12,  /* (219) cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt */\n   -1,  /* (220) uniqueflag ::= UNIQUE */\n    0,  /* (221) uniqueflag ::= */\n    0,  /* (222) eidlist_opt ::= */\n   -3,  /* (223) eidlist_opt ::= LP eidlist RP */\n   -5,  /* (224) eidlist ::= eidlist COMMA nm collate sortorder */\n   -3,  /* (225) eidlist ::= nm collate sortorder */\n    0,  /* (226) collate ::= */\n   -2,  /* (227) collate ::= COLLATE ID|STRING */\n   -4,  /* (228) cmd ::= DROP INDEX ifexists fullname */\n   -2,  /* (229) cmd ::= VACUUM vinto */\n   -3,  /* (230) cmd ::= VACUUM nm vinto */\n   -2,  /* (231) vinto ::= INTO expr */\n    0,  /* (232) vinto ::= */\n   -3,  /* (233) cmd ::= PRAGMA nm dbnm */\n   -5,  /* (234) cmd ::= PRAGMA nm dbnm EQ nmnum */\n   -6,  /* (235) cmd ::= PRAGMA nm dbnm LP nmnum RP */\n   -5,  /* (236) cmd ::= PRAGMA nm dbnm EQ minus_num */\n   -6,  /* (237) cmd ::= PRAGMA nm dbnm LP minus_num RP */\n   -2,  /* (238) plus_num ::= PLUS INTEGER|FLOAT */\n   -2,  /* (239) minus_num ::= MINUS INTEGER|FLOAT */\n   -5,  /* (240) cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */\n  -11,  /* (241) trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */\n   -1,  /* (242) trigger_time ::= BEFORE|AFTER */\n   -2,  /* (243) trigger_time ::= INSTEAD OF */\n    0,  /* (244) trigger_time ::= */\n   -1,  /* (245) trigger_event ::= DELETE|INSERT */\n   -1,  /* (246) trigger_event ::= UPDATE */\n   -3,  /* (247) trigger_event ::= UPDATE OF idlist */\n    0,  /* (248) when_clause ::= */\n   -2,  /* (249) when_clause ::= WHEN expr */\n   -3,  /* (250) trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */\n   -2,  /* (251) trigger_cmd_list ::= trigger_cmd SEMI */\n   -3,  /* (252) trnm ::= nm DOT nm */\n   -3,  /* (253) tridxby ::= INDEXED BY nm */\n   -2,  /* (254) tridxby ::= NOT INDEXED */\n   -8,  /* (255) trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt scanpt */\n   -8,  /* (256) trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt */\n   -6,  /* (257) trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt */\n   -3,  /* (258) trigger_cmd ::= scanpt select scanpt */\n   -4,  /* (259) expr ::= RAISE LP IGNORE RP */\n   -6,  /* (260) expr ::= RAISE LP raisetype COMMA nm RP */\n   -1,  /* (261) raisetype ::= ROLLBACK */\n   -1,  /* (262) raisetype ::= ABORT */\n   -1,  /* (263) raisetype ::= FAIL */\n   -4,  /* (264) cmd ::= DROP TRIGGER ifexists fullname */\n   -6,  /* (265) cmd ::= ATTACH database_kw_opt expr AS expr key_opt */\n   -3,  /* (266) cmd ::= DETACH database_kw_opt expr */\n    0,  /* (267) key_opt ::= */\n   -2,  /* (268) key_opt ::= KEY expr */\n   -1,  /* (269) cmd ::= REINDEX */\n   -3,  /* (270) cmd ::= REINDEX nm dbnm */\n   -1,  /* (271) cmd ::= ANALYZE */\n   -3,  /* (272) cmd ::= ANALYZE nm dbnm */\n   -6,  /* (273) cmd ::= ALTER TABLE fullname RENAME TO nm */\n   -7,  /* (274) cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist */\n   -1,  /* (275) add_column_fullname ::= fullname */\n   -8,  /* (276) cmd ::= ALTER TABLE fullname RENAME kwcolumn_opt nm TO nm */\n   -1,  /* (277) cmd ::= create_vtab */\n   -4,  /* (278) cmd ::= create_vtab LP vtabarglist RP */\n   -8,  /* (279) create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */\n    0,  /* (280) vtabarg ::= */\n   -1,  /* (281) vtabargtoken ::= ANY */\n   -3,  /* (282) vtabargtoken ::= lp anylist RP */\n   -1,  /* (283) lp ::= LP */\n   -2,  /* (284) with ::= WITH wqlist */\n   -3,  /* (285) with ::= WITH RECURSIVE wqlist */\n   -6,  /* (286) wqlist ::= nm eidlist_opt AS LP select RP */\n   -8,  /* (287) wqlist ::= wqlist COMMA nm eidlist_opt AS LP select RP */\n   -1,  /* (288) windowdefn_list ::= windowdefn */\n   -3,  /* (289) windowdefn_list ::= windowdefn_list COMMA windowdefn */\n   -3,  /* (290) windowdefn ::= nm AS window */\n   -5,  /* (291) window ::= LP part_opt orderby_opt frame_opt RP */\n   -3,  /* (292) part_opt ::= PARTITION BY nexprlist */\n    0,  /* (293) part_opt ::= */\n    0,  /* (294) frame_opt ::= */\n   -2,  /* (295) frame_opt ::= range_or_rows frame_bound_s */\n   -5,  /* (296) frame_opt ::= range_or_rows BETWEEN frame_bound_s AND frame_bound_e */\n   -1,  /* (297) range_or_rows ::= RANGE */\n   -1,  /* (298) range_or_rows ::= ROWS */\n   -1,  /* (299) frame_bound_s ::= frame_bound */\n   -2,  /* (300) frame_bound_s ::= UNBOUNDED PRECEDING */\n   -1,  /* (301) frame_bound_e ::= frame_bound */\n   -2,  /* (302) frame_bound_e ::= UNBOUNDED FOLLOWING */\n   -2,  /* (303) frame_bound ::= expr PRECEDING */\n   -2,  /* (304) frame_bound ::= CURRENT ROW */\n   -2,  /* (305) frame_bound ::= expr FOLLOWING */\n   -2,  /* (306) window_clause ::= WINDOW windowdefn_list */\n   -3,  /* (307) over_clause ::= filter_opt OVER window */\n   -3,  /* (308) over_clause ::= filter_opt OVER nm */\n    0,  /* (309) filter_opt ::= */\n   -5,  /* (310) filter_opt ::= FILTER LP WHERE expr RP */\n   -1,  /* (311) input ::= cmdlist */\n   -2,  /* (312) cmdlist ::= cmdlist ecmd */\n   -1,  /* (313) cmdlist ::= ecmd */\n   -1,  /* (314) ecmd ::= SEMI */\n   -2,  /* (315) ecmd ::= cmdx SEMI */\n   -2,  /* (316) ecmd ::= explain cmdx */\n    0,  /* (317) trans_opt ::= */\n   -1,  /* (318) trans_opt ::= TRANSACTION */\n   -2,  /* (319) trans_opt ::= TRANSACTION nm */\n   -1,  /* (320) savepoint_opt ::= SAVEPOINT */\n    0,  /* (321) savepoint_opt ::= */\n   -2,  /* (322) cmd ::= create_table create_table_args */\n   -4,  /* (323) columnlist ::= columnlist COMMA columnname carglist */\n   -2,  /* (324) columnlist ::= columnname carglist */\n   -1,  /* (325) nm ::= ID|INDEXED */\n   -1,  /* (326) nm ::= STRING */\n   -1,  /* (327) nm ::= JOIN_KW */\n   -1,  /* (328) typetoken ::= typename */\n   -1,  /* (329) typename ::= ID|STRING */\n   -1,  /* (330) signed ::= plus_num */\n   -1,  /* (331) signed ::= minus_num */\n   -2,  /* (332) carglist ::= carglist ccons */\n    0,  /* (333) carglist ::= */\n   -2,  /* (334) ccons ::= NULL onconf */\n   -2,  /* (335) conslist_opt ::= COMMA conslist */\n   -3,  /* (336) conslist ::= conslist tconscomma tcons */\n   -1,  /* (337) conslist ::= tcons */\n    0,  /* (338) tconscomma ::= */\n   -1,  /* (339) defer_subclause_opt ::= defer_subclause */\n   -1,  /* (340) resolvetype ::= raisetype */\n   -1,  /* (341) selectnowith ::= oneselect */\n   -1,  /* (342) oneselect ::= values */\n   -2,  /* (343) sclp ::= selcollist COMMA */\n   -1,  /* (344) as ::= ID|STRING */\n   -1,  /* (345) expr ::= term */\n   -1,  /* (346) likeop ::= LIKE_KW|MATCH */\n   -1,  /* (347) exprlist ::= nexprlist */\n   -1,  /* (348) nmnum ::= plus_num */\n   -1,  /* (349) nmnum ::= nm */\n   -1,  /* (350) nmnum ::= ON */\n   -1,  /* (351) nmnum ::= DELETE */\n   -1,  /* (352) nmnum ::= DEFAULT */\n   -1,  /* (353) plus_num ::= INTEGER|FLOAT */\n    0,  /* (354) foreach_clause ::= */\n   -3,  /* (355) foreach_clause ::= FOR EACH ROW */\n   -1,  /* (356) trnm ::= nm */\n    0,  /* (357) tridxby ::= */\n   -1,  /* (358) database_kw_opt ::= DATABASE */\n    0,  /* (359) database_kw_opt ::= */\n    0,  /* (360) kwcolumn_opt ::= */\n   -1,  /* (361) kwcolumn_opt ::= COLUMNKW */\n   -1,  /* (362) vtabarglist ::= vtabarg */\n   -3,  /* (363) vtabarglist ::= vtabarglist COMMA vtabarg */\n   -2,  /* (364) vtabarg ::= vtabarg vtabargtoken */\n    0,  /* (365) anylist ::= */\n   -4,  /* (366) anylist ::= anylist LP anylist RP */\n   -2,  /* (367) anylist ::= anylist ANY */\n    0,  /* (368) with ::= */\n};\n\nstatic void yy_accept(yyParser*);  /* Forward Declaration */\n\n/*\n** Perform a reduce action and the shift that must immediately\n** follow the reduce.\n**\n** The yyLookahead and yyLookaheadToken parameters provide reduce actions\n** access to the lookahead token (if any).  The yyLookahead will be YYNOCODE\n** if the lookahead token has already been consumed.  As this procedure is\n** only called from one place, optimizing compilers will in-line it, which\n** means that the extra parameters have no performance impact.\n*/\nstatic YYACTIONTYPE yy_reduce(\n  yyParser *yypParser,         /* The parser */\n  unsigned int yyruleno,       /* Number of the rule by which to reduce */\n  int yyLookahead,             /* Lookahead token, or YYNOCODE if none */\n  sqlite3ParserTOKENTYPE yyLookaheadToken  /* Value of the lookahead token */\n  sqlite3ParserCTX_PDECL                   /* %extra_context */\n){\n  int yygoto;                     /* The next state */\n  YYACTIONTYPE yyact;             /* The next action */\n  yyStackEntry *yymsp;            /* The top of the parser's stack */\n  int yysize;                     /* Amount to pop the stack */\n  sqlite3ParserARG_FETCH\n  (void)yyLookahead;\n  (void)yyLookaheadToken;\n  yymsp = yypParser->yytos;\n#ifndef NDEBUG\n  if( yyTraceFILE && yyruleno<(int)(sizeof(yyRuleName)/sizeof(yyRuleName[0])) ){\n    yysize = yyRuleInfoNRhs[yyruleno];\n    if( yysize ){\n      fprintf(yyTraceFILE, \"%sReduce %d [%s], go to state %d.\\n\",\n        yyTracePrompt,\n        yyruleno, yyRuleName[yyruleno], yymsp[yysize].stateno);\n    }else{\n      fprintf(yyTraceFILE, \"%sReduce %d [%s].\\n\",\n        yyTracePrompt, yyruleno, yyRuleName[yyruleno]);\n    }\n  }\n#endif /* NDEBUG */\n\n  /* Check that the stack is large enough to grow by a single entry\n  ** if the RHS of the rule is empty.  This ensures that there is room\n  ** enough on the stack to push the LHS value */\n  if( yyRuleInfoNRhs[yyruleno]==0 ){\n#ifdef YYTRACKMAXSTACKDEPTH\n    if( (int)(yypParser->yytos - yypParser->yystack)>yypParser->yyhwm ){\n      yypParser->yyhwm++;\n      assert( yypParser->yyhwm == (int)(yypParser->yytos - yypParser->yystack));\n    }\n#endif\n#if YYSTACKDEPTH>0 \n    if( yypParser->yytos>=yypParser->yystackEnd ){\n      yyStackOverflow(yypParser);\n      /* The call to yyStackOverflow() above pops the stack until it is\n      ** empty, causing the main parser loop to exit.  So the return value\n      ** is never used and does not matter. */\n      return 0;\n    }\n#else\n    if( yypParser->yytos>=&yypParser->yystack[yypParser->yystksz-1] ){\n      if( yyGrowStack(yypParser) ){\n        yyStackOverflow(yypParser);\n        /* The call to yyStackOverflow() above pops the stack until it is\n        ** empty, causing the main parser loop to exit.  So the return value\n        ** is never used and does not matter. */\n        return 0;\n      }\n      yymsp = yypParser->yytos;\n    }\n#endif\n  }\n\n  switch( yyruleno ){\n  /* Beginning here are the reduction cases.  A typical example\n  ** follows:\n  **   case 0:\n  **  #line <lineno> <grammarfile>\n  **     { ... }           // User supplied code\n  **  #line <lineno> <thisfile>\n  **     break;\n  */\n/********** Begin reduce actions **********************************************/\n        YYMINORTYPE yylhsminor;\n      case 0: /* explain ::= EXPLAIN */\n{ pParse->explain = 1; }\n        break;\n      case 1: /* explain ::= EXPLAIN QUERY PLAN */\n{ pParse->explain = 2; }\n        break;\n      case 2: /* cmdx ::= cmd */\n{ sqlite3FinishCoding(pParse); }\n        break;\n      case 3: /* cmd ::= BEGIN transtype trans_opt */\n{sqlite3BeginTransaction(pParse, yymsp[-1].minor.yy96);}\n        break;\n      case 4: /* transtype ::= */\n{yymsp[1].minor.yy96 = TK_DEFERRED;}\n        break;\n      case 5: /* transtype ::= DEFERRED */\n      case 6: /* transtype ::= IMMEDIATE */ yytestcase(yyruleno==6);\n      case 7: /* transtype ::= EXCLUSIVE */ yytestcase(yyruleno==7);\n{yymsp[0].minor.yy96 = yymsp[0].major; /*A-overwrites-X*/}\n        break;\n      case 8: /* cmd ::= COMMIT|END trans_opt */\n      case 9: /* cmd ::= ROLLBACK trans_opt */ yytestcase(yyruleno==9);\n{sqlite3EndTransaction(pParse,yymsp[-1].major);}\n        break;\n      case 10: /* cmd ::= SAVEPOINT nm */\n{\n  sqlite3Savepoint(pParse, SAVEPOINT_BEGIN, &yymsp[0].minor.yy0);\n}\n        break;\n      case 11: /* cmd ::= RELEASE savepoint_opt nm */\n{\n  sqlite3Savepoint(pParse, SAVEPOINT_RELEASE, &yymsp[0].minor.yy0);\n}\n        break;\n      case 12: /* cmd ::= ROLLBACK trans_opt TO savepoint_opt nm */\n{\n  sqlite3Savepoint(pParse, SAVEPOINT_ROLLBACK, &yymsp[0].minor.yy0);\n}\n        break;\n      case 13: /* create_table ::= createkw temp TABLE ifnotexists nm dbnm */\n{\n   sqlite3StartTable(pParse,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0,yymsp[-4].minor.yy96,0,0,yymsp[-2].minor.yy96);\n}\n        break;\n      case 14: /* createkw ::= CREATE */\n{disableLookaside(pParse);}\n        break;\n      case 15: /* ifnotexists ::= */\n      case 18: /* temp ::= */ yytestcase(yyruleno==18);\n      case 21: /* table_options ::= */ yytestcase(yyruleno==21);\n      case 42: /* autoinc ::= */ yytestcase(yyruleno==42);\n      case 57: /* init_deferred_pred_opt ::= */ yytestcase(yyruleno==57);\n      case 67: /* defer_subclause_opt ::= */ yytestcase(yyruleno==67);\n      case 76: /* ifexists ::= */ yytestcase(yyruleno==76);\n      case 93: /* distinct ::= */ yytestcase(yyruleno==93);\n      case 226: /* collate ::= */ yytestcase(yyruleno==226);\n{yymsp[1].minor.yy96 = 0;}\n        break;\n      case 16: /* ifnotexists ::= IF NOT EXISTS */\n{yymsp[-2].minor.yy96 = 1;}\n        break;\n      case 17: /* temp ::= TEMP */\n      case 43: /* autoinc ::= AUTOINCR */ yytestcase(yyruleno==43);\n{yymsp[0].minor.yy96 = 1;}\n        break;\n      case 19: /* create_table_args ::= LP columnlist conslist_opt RP table_options */\n{\n  sqlite3EndTable(pParse,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0,yymsp[0].minor.yy96,0);\n}\n        break;\n      case 20: /* create_table_args ::= AS select */\n{\n  sqlite3EndTable(pParse,0,0,0,yymsp[0].minor.yy423);\n  sqlite3SelectDelete(pParse->db, yymsp[0].minor.yy423);\n}\n        break;\n      case 22: /* table_options ::= WITHOUT nm */\n{\n  if( yymsp[0].minor.yy0.n==5 && sqlite3_strnicmp(yymsp[0].minor.yy0.z,\"rowid\",5)==0 ){\n    yymsp[-1].minor.yy96 = TF_WithoutRowid | TF_NoVisibleRowid;\n  }else{\n    yymsp[-1].minor.yy96 = 0;\n    sqlite3ErrorMsg(pParse, \"unknown table option: %.*s\", yymsp[0].minor.yy0.n, yymsp[0].minor.yy0.z);\n  }\n}\n        break;\n      case 23: /* columnname ::= nm typetoken */\n{sqlite3AddColumn(pParse,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0);}\n        break;\n      case 24: /* typetoken ::= */\n      case 60: /* conslist_opt ::= */ yytestcase(yyruleno==60);\n      case 99: /* as ::= */ yytestcase(yyruleno==99);\n{yymsp[1].minor.yy0.n = 0; yymsp[1].minor.yy0.z = 0;}\n        break;\n      case 25: /* typetoken ::= typename LP signed RP */\n{\n  yymsp[-3].minor.yy0.n = (int)(&yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n] - yymsp[-3].minor.yy0.z);\n}\n        break;\n      case 26: /* typetoken ::= typename LP signed COMMA signed RP */\n{\n  yymsp[-5].minor.yy0.n = (int)(&yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n] - yymsp[-5].minor.yy0.z);\n}\n        break;\n      case 27: /* typename ::= typename ID|STRING */\n{yymsp[-1].minor.yy0.n=yymsp[0].minor.yy0.n+(int)(yymsp[0].minor.yy0.z-yymsp[-1].minor.yy0.z);}\n        break;\n      case 28: /* scanpt ::= */\n{\n  assert( yyLookahead!=YYNOCODE );\n  yymsp[1].minor.yy464 = yyLookaheadToken.z;\n}\n        break;\n      case 29: /* ccons ::= CONSTRAINT nm */\n      case 62: /* tcons ::= CONSTRAINT nm */ yytestcase(yyruleno==62);\n{pParse->constraintName = yymsp[0].minor.yy0;}\n        break;\n      case 30: /* ccons ::= DEFAULT scanpt term scanpt */\n{sqlite3AddDefaultValue(pParse,yymsp[-1].minor.yy490,yymsp[-2].minor.yy464,yymsp[0].minor.yy464);}\n        break;\n      case 31: /* ccons ::= DEFAULT LP expr RP */\n{sqlite3AddDefaultValue(pParse,yymsp[-1].minor.yy490,yymsp[-2].minor.yy0.z+1,yymsp[0].minor.yy0.z);}\n        break;\n      case 32: /* ccons ::= DEFAULT PLUS term scanpt */\n{sqlite3AddDefaultValue(pParse,yymsp[-1].minor.yy490,yymsp[-2].minor.yy0.z,yymsp[0].minor.yy464);}\n        break;\n      case 33: /* ccons ::= DEFAULT MINUS term scanpt */\n{\n  Expr *p = sqlite3PExpr(pParse, TK_UMINUS, yymsp[-1].minor.yy490, 0);\n  sqlite3AddDefaultValue(pParse,p,yymsp[-2].minor.yy0.z,yymsp[0].minor.yy464);\n}\n        break;\n      case 34: /* ccons ::= DEFAULT scanpt ID|INDEXED */\n{\n  Expr *p = tokenExpr(pParse, TK_STRING, yymsp[0].minor.yy0);\n  if( p ){\n    sqlite3ExprIdToTrueFalse(p);\n    testcase( p->op==TK_TRUEFALSE && sqlite3ExprTruthValue(p) );\n  }\n    sqlite3AddDefaultValue(pParse,p,yymsp[0].minor.yy0.z,yymsp[0].minor.yy0.z+yymsp[0].minor.yy0.n);\n}\n        break;\n      case 35: /* ccons ::= NOT NULL onconf */\n{sqlite3AddNotNull(pParse, yymsp[0].minor.yy96);}\n        break;\n      case 36: /* ccons ::= PRIMARY KEY sortorder onconf autoinc */\n{sqlite3AddPrimaryKey(pParse,0,yymsp[-1].minor.yy96,yymsp[0].minor.yy96,yymsp[-2].minor.yy96);}\n        break;\n      case 37: /* ccons ::= UNIQUE onconf */\n{sqlite3CreateIndex(pParse,0,0,0,0,yymsp[0].minor.yy96,0,0,0,0,\n                                   SQLITE_IDXTYPE_UNIQUE);}\n        break;\n      case 38: /* ccons ::= CHECK LP expr RP */\n{sqlite3AddCheckConstraint(pParse,yymsp[-1].minor.yy490);}\n        break;\n      case 39: /* ccons ::= REFERENCES nm eidlist_opt refargs */\n{sqlite3CreateForeignKey(pParse,0,&yymsp[-2].minor.yy0,yymsp[-1].minor.yy42,yymsp[0].minor.yy96);}\n        break;\n      case 40: /* ccons ::= defer_subclause */\n{sqlite3DeferForeignKey(pParse,yymsp[0].minor.yy96);}\n        break;\n      case 41: /* ccons ::= COLLATE ID|STRING */\n{sqlite3AddCollateType(pParse, &yymsp[0].minor.yy0);}\n        break;\n      case 44: /* refargs ::= */\n{ yymsp[1].minor.yy96 = OE_None*0x0101; /* EV: R-19803-45884 */}\n        break;\n      case 45: /* refargs ::= refargs refarg */\n{ yymsp[-1].minor.yy96 = (yymsp[-1].minor.yy96 & ~yymsp[0].minor.yy367.mask) | yymsp[0].minor.yy367.value; }\n        break;\n      case 46: /* refarg ::= MATCH nm */\n{ yymsp[-1].minor.yy367.value = 0;     yymsp[-1].minor.yy367.mask = 0x000000; }\n        break;\n      case 47: /* refarg ::= ON INSERT refact */\n{ yymsp[-2].minor.yy367.value = 0;     yymsp[-2].minor.yy367.mask = 0x000000; }\n        break;\n      case 48: /* refarg ::= ON DELETE refact */\n{ yymsp[-2].minor.yy367.value = yymsp[0].minor.yy96;     yymsp[-2].minor.yy367.mask = 0x0000ff; }\n        break;\n      case 49: /* refarg ::= ON UPDATE refact */\n{ yymsp[-2].minor.yy367.value = yymsp[0].minor.yy96<<8;  yymsp[-2].minor.yy367.mask = 0x00ff00; }\n        break;\n      case 50: /* refact ::= SET NULL */\n{ yymsp[-1].minor.yy96 = OE_SetNull;  /* EV: R-33326-45252 */}\n        break;\n      case 51: /* refact ::= SET DEFAULT */\n{ yymsp[-1].minor.yy96 = OE_SetDflt;  /* EV: R-33326-45252 */}\n        break;\n      case 52: /* refact ::= CASCADE */\n{ yymsp[0].minor.yy96 = OE_Cascade;  /* EV: R-33326-45252 */}\n        break;\n      case 53: /* refact ::= RESTRICT */\n{ yymsp[0].minor.yy96 = OE_Restrict; /* EV: R-33326-45252 */}\n        break;\n      case 54: /* refact ::= NO ACTION */\n{ yymsp[-1].minor.yy96 = OE_None;     /* EV: R-33326-45252 */}\n        break;\n      case 55: /* defer_subclause ::= NOT DEFERRABLE init_deferred_pred_opt */\n{yymsp[-2].minor.yy96 = 0;}\n        break;\n      case 56: /* defer_subclause ::= DEFERRABLE init_deferred_pred_opt */\n      case 71: /* orconf ::= OR resolvetype */ yytestcase(yyruleno==71);\n      case 156: /* insert_cmd ::= INSERT orconf */ yytestcase(yyruleno==156);\n{yymsp[-1].minor.yy96 = yymsp[0].minor.yy96;}\n        break;\n      case 58: /* init_deferred_pred_opt ::= INITIALLY DEFERRED */\n      case 75: /* ifexists ::= IF EXISTS */ yytestcase(yyruleno==75);\n      case 198: /* between_op ::= NOT BETWEEN */ yytestcase(yyruleno==198);\n      case 201: /* in_op ::= NOT IN */ yytestcase(yyruleno==201);\n      case 227: /* collate ::= COLLATE ID|STRING */ yytestcase(yyruleno==227);\n{yymsp[-1].minor.yy96 = 1;}\n        break;\n      case 59: /* init_deferred_pred_opt ::= INITIALLY IMMEDIATE */\n{yymsp[-1].minor.yy96 = 0;}\n        break;\n      case 61: /* tconscomma ::= COMMA */\n{pParse->constraintName.n = 0;}\n        break;\n      case 63: /* tcons ::= PRIMARY KEY LP sortlist autoinc RP onconf */\n{sqlite3AddPrimaryKey(pParse,yymsp[-3].minor.yy42,yymsp[0].minor.yy96,yymsp[-2].minor.yy96,0);}\n        break;\n      case 64: /* tcons ::= UNIQUE LP sortlist RP onconf */\n{sqlite3CreateIndex(pParse,0,0,0,yymsp[-2].minor.yy42,yymsp[0].minor.yy96,0,0,0,0,\n                                       SQLITE_IDXTYPE_UNIQUE);}\n        break;\n      case 65: /* tcons ::= CHECK LP expr RP onconf */\n{sqlite3AddCheckConstraint(pParse,yymsp[-2].minor.yy490);}\n        break;\n      case 66: /* tcons ::= FOREIGN KEY LP eidlist RP REFERENCES nm eidlist_opt refargs defer_subclause_opt */\n{\n    sqlite3CreateForeignKey(pParse, yymsp[-6].minor.yy42, &yymsp[-3].minor.yy0, yymsp[-2].minor.yy42, yymsp[-1].minor.yy96);\n    sqlite3DeferForeignKey(pParse, yymsp[0].minor.yy96);\n}\n        break;\n      case 68: /* onconf ::= */\n      case 70: /* orconf ::= */ yytestcase(yyruleno==70);\n{yymsp[1].minor.yy96 = OE_Default;}\n        break;\n      case 69: /* onconf ::= ON CONFLICT resolvetype */\n{yymsp[-2].minor.yy96 = yymsp[0].minor.yy96;}\n        break;\n      case 72: /* resolvetype ::= IGNORE */\n{yymsp[0].minor.yy96 = OE_Ignore;}\n        break;\n      case 73: /* resolvetype ::= REPLACE */\n      case 157: /* insert_cmd ::= REPLACE */ yytestcase(yyruleno==157);\n{yymsp[0].minor.yy96 = OE_Replace;}\n        break;\n      case 74: /* cmd ::= DROP TABLE ifexists fullname */\n{\n  sqlite3DropTable(pParse, yymsp[0].minor.yy167, 0, yymsp[-1].minor.yy96);\n}\n        break;\n      case 77: /* cmd ::= createkw temp VIEW ifnotexists nm dbnm eidlist_opt AS select */\n{\n  sqlite3CreateView(pParse, &yymsp[-8].minor.yy0, &yymsp[-4].minor.yy0, &yymsp[-3].minor.yy0, yymsp[-2].minor.yy42, yymsp[0].minor.yy423, yymsp[-7].minor.yy96, yymsp[-5].minor.yy96);\n}\n        break;\n      case 78: /* cmd ::= DROP VIEW ifexists fullname */\n{\n  sqlite3DropTable(pParse, yymsp[0].minor.yy167, 1, yymsp[-1].minor.yy96);\n}\n        break;\n      case 79: /* cmd ::= select */\n{\n  SelectDest dest = {SRT_Output, 0, 0, 0, 0, 0};\n  sqlite3Select(pParse, yymsp[0].minor.yy423, &dest);\n  sqlite3SelectDelete(pParse->db, yymsp[0].minor.yy423);\n}\n        break;\n      case 80: /* select ::= WITH wqlist selectnowith */\n{\n  Select *p = yymsp[0].minor.yy423;\n  if( p ){\n    p->pWith = yymsp[-1].minor.yy499;\n    parserDoubleLinkSelect(pParse, p);\n  }else{\n    sqlite3WithDelete(pParse->db, yymsp[-1].minor.yy499);\n  }\n  yymsp[-2].minor.yy423 = p;\n}\n        break;\n      case 81: /* select ::= WITH RECURSIVE wqlist selectnowith */\n{\n  Select *p = yymsp[0].minor.yy423;\n  if( p ){\n    p->pWith = yymsp[-1].minor.yy499;\n    parserDoubleLinkSelect(pParse, p);\n  }else{\n    sqlite3WithDelete(pParse->db, yymsp[-1].minor.yy499);\n  }\n  yymsp[-3].minor.yy423 = p;\n}\n        break;\n      case 82: /* select ::= selectnowith */\n{\n  Select *p = yymsp[0].minor.yy423;\n  if( p ){\n    parserDoubleLinkSelect(pParse, p);\n  }\n  yymsp[0].minor.yy423 = p; /*A-overwrites-X*/\n}\n        break;\n      case 83: /* selectnowith ::= selectnowith multiselect_op oneselect */\n{\n  Select *pRhs = yymsp[0].minor.yy423;\n  Select *pLhs = yymsp[-2].minor.yy423;\n  if( pRhs && pRhs->pPrior ){\n    SrcList *pFrom;\n    Token x;\n    x.n = 0;\n    parserDoubleLinkSelect(pParse, pRhs);\n    pFrom = sqlite3SrcListAppendFromTerm(pParse,0,0,0,&x,pRhs,0,0);\n    pRhs = sqlite3SelectNew(pParse,0,pFrom,0,0,0,0,0,0);\n  }\n  if( pRhs ){\n    pRhs->op = (u8)yymsp[-1].minor.yy96;\n    pRhs->pPrior = pLhs;\n    if( ALWAYS(pLhs) ) pLhs->selFlags &= ~SF_MultiValue;\n    pRhs->selFlags &= ~SF_MultiValue;\n    if( yymsp[-1].minor.yy96!=TK_ALL ) pParse->hasCompound = 1;\n  }else{\n    sqlite3SelectDelete(pParse->db, pLhs);\n  }\n  yymsp[-2].minor.yy423 = pRhs;\n}\n        break;\n      case 84: /* multiselect_op ::= UNION */\n      case 86: /* multiselect_op ::= EXCEPT|INTERSECT */ yytestcase(yyruleno==86);\n{yymsp[0].minor.yy96 = yymsp[0].major; /*A-overwrites-OP*/}\n        break;\n      case 85: /* multiselect_op ::= UNION ALL */\n{yymsp[-1].minor.yy96 = TK_ALL;}\n        break;\n      case 87: /* oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt orderby_opt limit_opt */\n{\n  yymsp[-8].minor.yy423 = sqlite3SelectNew(pParse,yymsp[-6].minor.yy42,yymsp[-5].minor.yy167,yymsp[-4].minor.yy490,yymsp[-3].minor.yy42,yymsp[-2].minor.yy490,yymsp[-1].minor.yy42,yymsp[-7].minor.yy96,yymsp[0].minor.yy490);\n}\n        break;\n      case 88: /* oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt window_clause orderby_opt limit_opt */\n{\n  yymsp[-9].minor.yy423 = sqlite3SelectNew(pParse,yymsp[-7].minor.yy42,yymsp[-6].minor.yy167,yymsp[-5].minor.yy490,yymsp[-4].minor.yy42,yymsp[-3].minor.yy490,yymsp[-1].minor.yy42,yymsp[-8].minor.yy96,yymsp[0].minor.yy490);\n  if( yymsp[-9].minor.yy423 ){\n    yymsp[-9].minor.yy423->pWinDefn = yymsp[-2].minor.yy147;\n  }else{\n    sqlite3WindowListDelete(pParse->db, yymsp[-2].minor.yy147);\n  }\n}\n        break;\n      case 89: /* values ::= VALUES LP nexprlist RP */\n{\n  yymsp[-3].minor.yy423 = sqlite3SelectNew(pParse,yymsp[-1].minor.yy42,0,0,0,0,0,SF_Values,0);\n}\n        break;\n      case 90: /* values ::= values COMMA LP nexprlist RP */\n{\n  Select *pRight, *pLeft = yymsp[-4].minor.yy423;\n  pRight = sqlite3SelectNew(pParse,yymsp[-1].minor.yy42,0,0,0,0,0,SF_Values|SF_MultiValue,0);\n  if( ALWAYS(pLeft) ) pLeft->selFlags &= ~SF_MultiValue;\n  if( pRight ){\n    pRight->op = TK_ALL;\n    pRight->pPrior = pLeft;\n    yymsp[-4].minor.yy423 = pRight;\n  }else{\n    yymsp[-4].minor.yy423 = pLeft;\n  }\n}\n        break;\n      case 91: /* distinct ::= DISTINCT */\n{yymsp[0].minor.yy96 = SF_Distinct;}\n        break;\n      case 92: /* distinct ::= ALL */\n{yymsp[0].minor.yy96 = SF_All;}\n        break;\n      case 94: /* sclp ::= */\n      case 127: /* orderby_opt ::= */ yytestcase(yyruleno==127);\n      case 134: /* groupby_opt ::= */ yytestcase(yyruleno==134);\n      case 214: /* exprlist ::= */ yytestcase(yyruleno==214);\n      case 217: /* paren_exprlist ::= */ yytestcase(yyruleno==217);\n      case 222: /* eidlist_opt ::= */ yytestcase(yyruleno==222);\n{yymsp[1].minor.yy42 = 0;}\n        break;\n      case 95: /* selcollist ::= sclp scanpt expr scanpt as */\n{\n   yymsp[-4].minor.yy42 = sqlite3ExprListAppend(pParse, yymsp[-4].minor.yy42, yymsp[-2].minor.yy490);\n   if( yymsp[0].minor.yy0.n>0 ) sqlite3ExprListSetName(pParse, yymsp[-4].minor.yy42, &yymsp[0].minor.yy0, 1);\n   sqlite3ExprListSetSpan(pParse,yymsp[-4].minor.yy42,yymsp[-3].minor.yy464,yymsp[-1].minor.yy464);\n}\n        break;\n      case 96: /* selcollist ::= sclp scanpt STAR */\n{\n  Expr *p = sqlite3Expr(pParse->db, TK_ASTERISK, 0);\n  yymsp[-2].minor.yy42 = sqlite3ExprListAppend(pParse, yymsp[-2].minor.yy42, p);\n}\n        break;\n      case 97: /* selcollist ::= sclp scanpt nm DOT STAR */\n{\n  Expr *pRight = sqlite3PExpr(pParse, TK_ASTERISK, 0, 0);\n  Expr *pLeft = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[-2].minor.yy0, 1);\n  Expr *pDot = sqlite3PExpr(pParse, TK_DOT, pLeft, pRight);\n  yymsp[-4].minor.yy42 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy42, pDot);\n}\n        break;\n      case 98: /* as ::= AS nm */\n      case 109: /* dbnm ::= DOT nm */ yytestcase(yyruleno==109);\n      case 238: /* plus_num ::= PLUS INTEGER|FLOAT */ yytestcase(yyruleno==238);\n      case 239: /* minus_num ::= MINUS INTEGER|FLOAT */ yytestcase(yyruleno==239);\n{yymsp[-1].minor.yy0 = yymsp[0].minor.yy0;}\n        break;\n      case 100: /* from ::= */\n{yymsp[1].minor.yy167 = sqlite3DbMallocZero(pParse->db, sizeof(*yymsp[1].minor.yy167));}\n        break;\n      case 101: /* from ::= FROM seltablist */\n{\n  yymsp[-1].minor.yy167 = yymsp[0].minor.yy167;\n  sqlite3SrcListShiftJoinType(yymsp[-1].minor.yy167);\n}\n        break;\n      case 102: /* stl_prefix ::= seltablist joinop */\n{\n   if( ALWAYS(yymsp[-1].minor.yy167 && yymsp[-1].minor.yy167->nSrc>0) ) yymsp[-1].minor.yy167->a[yymsp[-1].minor.yy167->nSrc-1].fg.jointype = (u8)yymsp[0].minor.yy96;\n}\n        break;\n      case 103: /* stl_prefix ::= */\n{yymsp[1].minor.yy167 = 0;}\n        break;\n      case 104: /* seltablist ::= stl_prefix nm dbnm as indexed_opt on_opt using_opt */\n{\n  yymsp[-6].minor.yy167 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy167,&yymsp[-5].minor.yy0,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,0,yymsp[-1].minor.yy490,yymsp[0].minor.yy336);\n  sqlite3SrcListIndexedBy(pParse, yymsp[-6].minor.yy167, &yymsp[-2].minor.yy0);\n}\n        break;\n      case 105: /* seltablist ::= stl_prefix nm dbnm LP exprlist RP as on_opt using_opt */\n{\n  yymsp[-8].minor.yy167 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-8].minor.yy167,&yymsp[-7].minor.yy0,&yymsp[-6].minor.yy0,&yymsp[-2].minor.yy0,0,yymsp[-1].minor.yy490,yymsp[0].minor.yy336);\n  sqlite3SrcListFuncArgs(pParse, yymsp[-8].minor.yy167, yymsp[-4].minor.yy42);\n}\n        break;\n      case 106: /* seltablist ::= stl_prefix LP select RP as on_opt using_opt */\n{\n    yymsp[-6].minor.yy167 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy167,0,0,&yymsp[-2].minor.yy0,yymsp[-4].minor.yy423,yymsp[-1].minor.yy490,yymsp[0].minor.yy336);\n  }\n        break;\n      case 107: /* seltablist ::= stl_prefix LP seltablist RP as on_opt using_opt */\n{\n    if( yymsp[-6].minor.yy167==0 && yymsp[-2].minor.yy0.n==0 && yymsp[-1].minor.yy490==0 && yymsp[0].minor.yy336==0 ){\n      yymsp[-6].minor.yy167 = yymsp[-4].minor.yy167;\n    }else if( yymsp[-4].minor.yy167->nSrc==1 ){\n      yymsp[-6].minor.yy167 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy167,0,0,&yymsp[-2].minor.yy0,0,yymsp[-1].minor.yy490,yymsp[0].minor.yy336);\n      if( yymsp[-6].minor.yy167 ){\n        struct SrcList_item *pNew = &yymsp[-6].minor.yy167->a[yymsp[-6].minor.yy167->nSrc-1];\n        struct SrcList_item *pOld = yymsp[-4].minor.yy167->a;\n        pNew->zName = pOld->zName;\n        pNew->zDatabase = pOld->zDatabase;\n        pNew->pSelect = pOld->pSelect;\n        if( pOld->fg.isTabFunc ){\n          pNew->u1.pFuncArg = pOld->u1.pFuncArg;\n          pOld->u1.pFuncArg = 0;\n          pOld->fg.isTabFunc = 0;\n          pNew->fg.isTabFunc = 1;\n        }\n        pOld->zName = pOld->zDatabase = 0;\n        pOld->pSelect = 0;\n      }\n      sqlite3SrcListDelete(pParse->db, yymsp[-4].minor.yy167);\n    }else{\n      Select *pSubquery;\n      sqlite3SrcListShiftJoinType(yymsp[-4].minor.yy167);\n      pSubquery = sqlite3SelectNew(pParse,0,yymsp[-4].minor.yy167,0,0,0,0,SF_NestedFrom,0);\n      yymsp[-6].minor.yy167 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy167,0,0,&yymsp[-2].minor.yy0,pSubquery,yymsp[-1].minor.yy490,yymsp[0].minor.yy336);\n    }\n  }\n        break;\n      case 108: /* dbnm ::= */\n      case 122: /* indexed_opt ::= */ yytestcase(yyruleno==122);\n{yymsp[1].minor.yy0.z=0; yymsp[1].minor.yy0.n=0;}\n        break;\n      case 110: /* fullname ::= nm */\n{\n  yylhsminor.yy167 = sqlite3SrcListAppend(pParse,0,&yymsp[0].minor.yy0,0);\n  if( IN_RENAME_OBJECT && yylhsminor.yy167 ) sqlite3RenameTokenMap(pParse, yylhsminor.yy167->a[0].zName, &yymsp[0].minor.yy0);\n}\n  yymsp[0].minor.yy167 = yylhsminor.yy167;\n        break;\n      case 111: /* fullname ::= nm DOT nm */\n{\n  yylhsminor.yy167 = sqlite3SrcListAppend(pParse,0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0);\n  if( IN_RENAME_OBJECT && yylhsminor.yy167 ) sqlite3RenameTokenMap(pParse, yylhsminor.yy167->a[0].zName, &yymsp[0].minor.yy0);\n}\n  yymsp[-2].minor.yy167 = yylhsminor.yy167;\n        break;\n      case 112: /* xfullname ::= nm */\n{yymsp[0].minor.yy167 = sqlite3SrcListAppend(pParse,0,&yymsp[0].minor.yy0,0); /*A-overwrites-X*/}\n        break;\n      case 113: /* xfullname ::= nm DOT nm */\n{yymsp[-2].minor.yy167 = sqlite3SrcListAppend(pParse,0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-X*/}\n        break;\n      case 114: /* xfullname ::= nm DOT nm AS nm */\n{\n   yymsp[-4].minor.yy167 = sqlite3SrcListAppend(pParse,0,&yymsp[-4].minor.yy0,&yymsp[-2].minor.yy0); /*A-overwrites-X*/\n   if( yymsp[-4].minor.yy167 ) yymsp[-4].minor.yy167->a[0].zAlias = sqlite3NameFromToken(pParse->db, &yymsp[0].minor.yy0);\n}\n        break;\n      case 115: /* xfullname ::= nm AS nm */\n{  \n   yymsp[-2].minor.yy167 = sqlite3SrcListAppend(pParse,0,&yymsp[-2].minor.yy0,0); /*A-overwrites-X*/\n   if( yymsp[-2].minor.yy167 ) yymsp[-2].minor.yy167->a[0].zAlias = sqlite3NameFromToken(pParse->db, &yymsp[0].minor.yy0);\n}\n        break;\n      case 116: /* joinop ::= COMMA|JOIN */\n{ yymsp[0].minor.yy96 = JT_INNER; }\n        break;\n      case 117: /* joinop ::= JOIN_KW JOIN */\n{yymsp[-1].minor.yy96 = sqlite3JoinType(pParse,&yymsp[-1].minor.yy0,0,0);  /*X-overwrites-A*/}\n        break;\n      case 118: /* joinop ::= JOIN_KW nm JOIN */\n{yymsp[-2].minor.yy96 = sqlite3JoinType(pParse,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0,0); /*X-overwrites-A*/}\n        break;\n      case 119: /* joinop ::= JOIN_KW nm nm JOIN */\n{yymsp[-3].minor.yy96 = sqlite3JoinType(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0);/*X-overwrites-A*/}\n        break;\n      case 120: /* on_opt ::= ON expr */\n      case 137: /* having_opt ::= HAVING expr */ yytestcase(yyruleno==137);\n      case 144: /* where_opt ::= WHERE expr */ yytestcase(yyruleno==144);\n      case 210: /* case_else ::= ELSE expr */ yytestcase(yyruleno==210);\n      case 231: /* vinto ::= INTO expr */ yytestcase(yyruleno==231);\n{yymsp[-1].minor.yy490 = yymsp[0].minor.yy490;}\n        break;\n      case 121: /* on_opt ::= */\n      case 136: /* having_opt ::= */ yytestcase(yyruleno==136);\n      case 138: /* limit_opt ::= */ yytestcase(yyruleno==138);\n      case 143: /* where_opt ::= */ yytestcase(yyruleno==143);\n      case 211: /* case_else ::= */ yytestcase(yyruleno==211);\n      case 213: /* case_operand ::= */ yytestcase(yyruleno==213);\n      case 232: /* vinto ::= */ yytestcase(yyruleno==232);\n{yymsp[1].minor.yy490 = 0;}\n        break;\n      case 123: /* indexed_opt ::= INDEXED BY nm */\n{yymsp[-2].minor.yy0 = yymsp[0].minor.yy0;}\n        break;\n      case 124: /* indexed_opt ::= NOT INDEXED */\n{yymsp[-1].minor.yy0.z=0; yymsp[-1].minor.yy0.n=1;}\n        break;\n      case 125: /* using_opt ::= USING LP idlist RP */\n{yymsp[-3].minor.yy336 = yymsp[-1].minor.yy336;}\n        break;\n      case 126: /* using_opt ::= */\n      case 158: /* idlist_opt ::= */ yytestcase(yyruleno==158);\n{yymsp[1].minor.yy336 = 0;}\n        break;\n      case 128: /* orderby_opt ::= ORDER BY sortlist */\n      case 135: /* groupby_opt ::= GROUP BY nexprlist */ yytestcase(yyruleno==135);\n{yymsp[-2].minor.yy42 = yymsp[0].minor.yy42;}\n        break;\n      case 129: /* sortlist ::= sortlist COMMA expr sortorder */\n{\n  yymsp[-3].minor.yy42 = sqlite3ExprListAppend(pParse,yymsp[-3].minor.yy42,yymsp[-1].minor.yy490);\n  sqlite3ExprListSetSortOrder(yymsp[-3].minor.yy42,yymsp[0].minor.yy96);\n}\n        break;\n      case 130: /* sortlist ::= expr sortorder */\n{\n  yymsp[-1].minor.yy42 = sqlite3ExprListAppend(pParse,0,yymsp[-1].minor.yy490); /*A-overwrites-Y*/\n  sqlite3ExprListSetSortOrder(yymsp[-1].minor.yy42,yymsp[0].minor.yy96);\n}\n        break;\n      case 131: /* sortorder ::= ASC */\n{yymsp[0].minor.yy96 = SQLITE_SO_ASC;}\n        break;\n      case 132: /* sortorder ::= DESC */\n{yymsp[0].minor.yy96 = SQLITE_SO_DESC;}\n        break;\n      case 133: /* sortorder ::= */\n{yymsp[1].minor.yy96 = SQLITE_SO_UNDEFINED;}\n        break;\n      case 139: /* limit_opt ::= LIMIT expr */\n{yymsp[-1].minor.yy490 = sqlite3PExpr(pParse,TK_LIMIT,yymsp[0].minor.yy490,0);}\n        break;\n      case 140: /* limit_opt ::= LIMIT expr OFFSET expr */\n{yymsp[-3].minor.yy490 = sqlite3PExpr(pParse,TK_LIMIT,yymsp[-2].minor.yy490,yymsp[0].minor.yy490);}\n        break;\n      case 141: /* limit_opt ::= LIMIT expr COMMA expr */\n{yymsp[-3].minor.yy490 = sqlite3PExpr(pParse,TK_LIMIT,yymsp[0].minor.yy490,yymsp[-2].minor.yy490);}\n        break;\n      case 142: /* cmd ::= with DELETE FROM xfullname indexed_opt where_opt */\n{\n  sqlite3SrcListIndexedBy(pParse, yymsp[-2].minor.yy167, &yymsp[-1].minor.yy0);\n  sqlite3DeleteFrom(pParse,yymsp[-2].minor.yy167,yymsp[0].minor.yy490,0,0);\n}\n        break;\n      case 145: /* cmd ::= with UPDATE orconf xfullname indexed_opt SET setlist where_opt */\n{\n  sqlite3SrcListIndexedBy(pParse, yymsp[-4].minor.yy167, &yymsp[-3].minor.yy0);\n  sqlite3ExprListCheckLength(pParse,yymsp[-1].minor.yy42,\"set list\"); \n  sqlite3Update(pParse,yymsp[-4].minor.yy167,yymsp[-1].minor.yy42,yymsp[0].minor.yy490,yymsp[-5].minor.yy96,0,0,0);\n}\n        break;\n      case 146: /* setlist ::= setlist COMMA nm EQ expr */\n{\n  yymsp[-4].minor.yy42 = sqlite3ExprListAppend(pParse, yymsp[-4].minor.yy42, yymsp[0].minor.yy490);\n  sqlite3ExprListSetName(pParse, yymsp[-4].minor.yy42, &yymsp[-2].minor.yy0, 1);\n}\n        break;\n      case 147: /* setlist ::= setlist COMMA LP idlist RP EQ expr */\n{\n  yymsp[-6].minor.yy42 = sqlite3ExprListAppendVector(pParse, yymsp[-6].minor.yy42, yymsp[-3].minor.yy336, yymsp[0].minor.yy490);\n}\n        break;\n      case 148: /* setlist ::= nm EQ expr */\n{\n  yylhsminor.yy42 = sqlite3ExprListAppend(pParse, 0, yymsp[0].minor.yy490);\n  sqlite3ExprListSetName(pParse, yylhsminor.yy42, &yymsp[-2].minor.yy0, 1);\n}\n  yymsp[-2].minor.yy42 = yylhsminor.yy42;\n        break;\n      case 149: /* setlist ::= LP idlist RP EQ expr */\n{\n  yymsp[-4].minor.yy42 = sqlite3ExprListAppendVector(pParse, 0, yymsp[-3].minor.yy336, yymsp[0].minor.yy490);\n}\n        break;\n      case 150: /* cmd ::= with insert_cmd INTO xfullname idlist_opt select upsert */\n{\n  sqlite3Insert(pParse, yymsp[-3].minor.yy167, yymsp[-1].minor.yy423, yymsp[-2].minor.yy336, yymsp[-5].minor.yy96, yymsp[0].minor.yy266);\n}\n        break;\n      case 151: /* cmd ::= with insert_cmd INTO xfullname idlist_opt DEFAULT VALUES */\n{\n  sqlite3Insert(pParse, yymsp[-3].minor.yy167, 0, yymsp[-2].minor.yy336, yymsp[-5].minor.yy96, 0);\n}\n        break;\n      case 152: /* upsert ::= */\n{ yymsp[1].minor.yy266 = 0; }\n        break;\n      case 153: /* upsert ::= ON CONFLICT LP sortlist RP where_opt DO UPDATE SET setlist where_opt */\n{ yymsp[-10].minor.yy266 = sqlite3UpsertNew(pParse->db,yymsp[-7].minor.yy42,yymsp[-5].minor.yy490,yymsp[-1].minor.yy42,yymsp[0].minor.yy490);}\n        break;\n      case 154: /* upsert ::= ON CONFLICT LP sortlist RP where_opt DO NOTHING */\n{ yymsp[-7].minor.yy266 = sqlite3UpsertNew(pParse->db,yymsp[-4].minor.yy42,yymsp[-2].minor.yy490,0,0); }\n        break;\n      case 155: /* upsert ::= ON CONFLICT DO NOTHING */\n{ yymsp[-3].minor.yy266 = sqlite3UpsertNew(pParse->db,0,0,0,0); }\n        break;\n      case 159: /* idlist_opt ::= LP idlist RP */\n{yymsp[-2].minor.yy336 = yymsp[-1].minor.yy336;}\n        break;\n      case 160: /* idlist ::= idlist COMMA nm */\n{yymsp[-2].minor.yy336 = sqlite3IdListAppend(pParse,yymsp[-2].minor.yy336,&yymsp[0].minor.yy0);}\n        break;\n      case 161: /* idlist ::= nm */\n{yymsp[0].minor.yy336 = sqlite3IdListAppend(pParse,0,&yymsp[0].minor.yy0); /*A-overwrites-Y*/}\n        break;\n      case 162: /* expr ::= LP expr RP */\n{yymsp[-2].minor.yy490 = yymsp[-1].minor.yy490;}\n        break;\n      case 163: /* expr ::= ID|INDEXED */\n      case 164: /* expr ::= JOIN_KW */ yytestcase(yyruleno==164);\n{yymsp[0].minor.yy490=tokenExpr(pParse,TK_ID,yymsp[0].minor.yy0); /*A-overwrites-X*/}\n        break;\n      case 165: /* expr ::= nm DOT nm */\n{\n  Expr *temp1 = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[-2].minor.yy0, 1);\n  Expr *temp2 = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[0].minor.yy0, 1);\n  if( IN_RENAME_OBJECT ){\n    sqlite3RenameTokenMap(pParse, (void*)temp2, &yymsp[0].minor.yy0);\n    sqlite3RenameTokenMap(pParse, (void*)temp1, &yymsp[-2].minor.yy0);\n  }\n  yylhsminor.yy490 = sqlite3PExpr(pParse, TK_DOT, temp1, temp2);\n}\n  yymsp[-2].minor.yy490 = yylhsminor.yy490;\n        break;\n      case 166: /* expr ::= nm DOT nm DOT nm */\n{\n  Expr *temp1 = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[-4].minor.yy0, 1);\n  Expr *temp2 = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[-2].minor.yy0, 1);\n  Expr *temp3 = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[0].minor.yy0, 1);\n  Expr *temp4 = sqlite3PExpr(pParse, TK_DOT, temp2, temp3);\n  if( IN_RENAME_OBJECT ){\n    sqlite3RenameTokenMap(pParse, (void*)temp3, &yymsp[0].minor.yy0);\n    sqlite3RenameTokenMap(pParse, (void*)temp2, &yymsp[-2].minor.yy0);\n  }\n  yylhsminor.yy490 = sqlite3PExpr(pParse, TK_DOT, temp1, temp4);\n}\n  yymsp[-4].minor.yy490 = yylhsminor.yy490;\n        break;\n      case 167: /* term ::= NULL|FLOAT|BLOB */\n      case 168: /* term ::= STRING */ yytestcase(yyruleno==168);\n{yymsp[0].minor.yy490=tokenExpr(pParse,yymsp[0].major,yymsp[0].minor.yy0); /*A-overwrites-X*/}\n        break;\n      case 169: /* term ::= INTEGER */\n{\n  yylhsminor.yy490 = sqlite3ExprAlloc(pParse->db, TK_INTEGER, &yymsp[0].minor.yy0, 1);\n}\n  yymsp[0].minor.yy490 = yylhsminor.yy490;\n        break;\n      case 170: /* expr ::= VARIABLE */\n{\n  if( !(yymsp[0].minor.yy0.z[0]=='#' && sqlite3Isdigit(yymsp[0].minor.yy0.z[1])) ){\n    u32 n = yymsp[0].minor.yy0.n;\n    yymsp[0].minor.yy490 = tokenExpr(pParse, TK_VARIABLE, yymsp[0].minor.yy0);\n    sqlite3ExprAssignVarNumber(pParse, yymsp[0].minor.yy490, n);\n  }else{\n    /* When doing a nested parse, one can include terms in an expression\n    ** that look like this:   #1 #2 ...  These terms refer to registers\n    ** in the virtual machine.  #N is the N-th register. */\n    Token t = yymsp[0].minor.yy0; /*A-overwrites-X*/\n    assert( t.n>=2 );\n    if( pParse->nested==0 ){\n      sqlite3ErrorMsg(pParse, \"near \\\"%T\\\": syntax error\", &t);\n      yymsp[0].minor.yy490 = 0;\n    }else{\n      yymsp[0].minor.yy490 = sqlite3PExpr(pParse, TK_REGISTER, 0, 0);\n      if( yymsp[0].minor.yy490 ) sqlite3GetInt32(&t.z[1], &yymsp[0].minor.yy490->iTable);\n    }\n  }\n}\n        break;\n      case 171: /* expr ::= expr COLLATE ID|STRING */\n{\n  yymsp[-2].minor.yy490 = sqlite3ExprAddCollateToken(pParse, yymsp[-2].minor.yy490, &yymsp[0].minor.yy0, 1);\n}\n        break;\n      case 172: /* expr ::= CAST LP expr AS typetoken RP */\n{\n  yymsp[-5].minor.yy490 = sqlite3ExprAlloc(pParse->db, TK_CAST, &yymsp[-1].minor.yy0, 1);\n  sqlite3ExprAttachSubtrees(pParse->db, yymsp[-5].minor.yy490, yymsp[-3].minor.yy490, 0);\n}\n        break;\n      case 173: /* expr ::= ID|INDEXED LP distinct exprlist RP */\n{\n  yylhsminor.yy490 = sqlite3ExprFunction(pParse, yymsp[-1].minor.yy42, &yymsp[-4].minor.yy0, yymsp[-2].minor.yy96);\n}\n  yymsp[-4].minor.yy490 = yylhsminor.yy490;\n        break;\n      case 174: /* expr ::= ID|INDEXED LP STAR RP */\n{\n  yylhsminor.yy490 = sqlite3ExprFunction(pParse, 0, &yymsp[-3].minor.yy0, 0);\n}\n  yymsp[-3].minor.yy490 = yylhsminor.yy490;\n        break;\n      case 175: /* expr ::= ID|INDEXED LP distinct exprlist RP over_clause */\n{\n  yylhsminor.yy490 = sqlite3ExprFunction(pParse, yymsp[-2].minor.yy42, &yymsp[-5].minor.yy0, yymsp[-3].minor.yy96);\n  sqlite3WindowAttach(pParse, yylhsminor.yy490, yymsp[0].minor.yy147);\n}\n  yymsp[-5].minor.yy490 = yylhsminor.yy490;\n        break;\n      case 176: /* expr ::= ID|INDEXED LP STAR RP over_clause */\n{\n  yylhsminor.yy490 = sqlite3ExprFunction(pParse, 0, &yymsp[-4].minor.yy0, 0);\n  sqlite3WindowAttach(pParse, yylhsminor.yy490, yymsp[0].minor.yy147);\n}\n  yymsp[-4].minor.yy490 = yylhsminor.yy490;\n        break;\n      case 177: /* term ::= CTIME_KW */\n{\n  yylhsminor.yy490 = sqlite3ExprFunction(pParse, 0, &yymsp[0].minor.yy0, 0);\n}\n  yymsp[0].minor.yy490 = yylhsminor.yy490;\n        break;\n      case 178: /* expr ::= LP nexprlist COMMA expr RP */\n{\n  ExprList *pList = sqlite3ExprListAppend(pParse, yymsp[-3].minor.yy42, yymsp[-1].minor.yy490);\n  yymsp[-4].minor.yy490 = sqlite3PExpr(pParse, TK_VECTOR, 0, 0);\n  if( yymsp[-4].minor.yy490 ){\n    yymsp[-4].minor.yy490->x.pList = pList;\n  }else{\n    sqlite3ExprListDelete(pParse->db, pList);\n  }\n}\n        break;\n      case 179: /* expr ::= expr AND expr */\n      case 180: /* expr ::= expr OR expr */ yytestcase(yyruleno==180);\n      case 181: /* expr ::= expr LT|GT|GE|LE expr */ yytestcase(yyruleno==181);\n      case 182: /* expr ::= expr EQ|NE expr */ yytestcase(yyruleno==182);\n      case 183: /* expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr */ yytestcase(yyruleno==183);\n      case 184: /* expr ::= expr PLUS|MINUS expr */ yytestcase(yyruleno==184);\n      case 185: /* expr ::= expr STAR|SLASH|REM expr */ yytestcase(yyruleno==185);\n      case 186: /* expr ::= expr CONCAT expr */ yytestcase(yyruleno==186);\n{yymsp[-2].minor.yy490=sqlite3PExpr(pParse,yymsp[-1].major,yymsp[-2].minor.yy490,yymsp[0].minor.yy490);}\n        break;\n      case 187: /* likeop ::= NOT LIKE_KW|MATCH */\n{yymsp[-1].minor.yy0=yymsp[0].minor.yy0; yymsp[-1].minor.yy0.n|=0x80000000; /*yymsp[-1].minor.yy0-overwrite-yymsp[0].minor.yy0*/}\n        break;\n      case 188: /* expr ::= expr likeop expr */\n{\n  ExprList *pList;\n  int bNot = yymsp[-1].minor.yy0.n & 0x80000000;\n  yymsp[-1].minor.yy0.n &= 0x7fffffff;\n  pList = sqlite3ExprListAppend(pParse,0, yymsp[0].minor.yy490);\n  pList = sqlite3ExprListAppend(pParse,pList, yymsp[-2].minor.yy490);\n  yymsp[-2].minor.yy490 = sqlite3ExprFunction(pParse, pList, &yymsp[-1].minor.yy0, 0);\n  if( bNot ) yymsp[-2].minor.yy490 = sqlite3PExpr(pParse, TK_NOT, yymsp[-2].minor.yy490, 0);\n  if( yymsp[-2].minor.yy490 ) yymsp[-2].minor.yy490->flags |= EP_InfixFunc;\n}\n        break;\n      case 189: /* expr ::= expr likeop expr ESCAPE expr */\n{\n  ExprList *pList;\n  int bNot = yymsp[-3].minor.yy0.n & 0x80000000;\n  yymsp[-3].minor.yy0.n &= 0x7fffffff;\n  pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy490);\n  pList = sqlite3ExprListAppend(pParse,pList, yymsp[-4].minor.yy490);\n  pList = sqlite3ExprListAppend(pParse,pList, yymsp[0].minor.yy490);\n  yymsp[-4].minor.yy490 = sqlite3ExprFunction(pParse, pList, &yymsp[-3].minor.yy0, 0);\n  if( bNot ) yymsp[-4].minor.yy490 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy490, 0);\n  if( yymsp[-4].minor.yy490 ) yymsp[-4].minor.yy490->flags |= EP_InfixFunc;\n}\n        break;\n      case 190: /* expr ::= expr ISNULL|NOTNULL */\n{yymsp[-1].minor.yy490 = sqlite3PExpr(pParse,yymsp[0].major,yymsp[-1].minor.yy490,0);}\n        break;\n      case 191: /* expr ::= expr NOT NULL */\n{yymsp[-2].minor.yy490 = sqlite3PExpr(pParse,TK_NOTNULL,yymsp[-2].minor.yy490,0);}\n        break;\n      case 192: /* expr ::= expr IS expr */\n{\n  yymsp[-2].minor.yy490 = sqlite3PExpr(pParse,TK_IS,yymsp[-2].minor.yy490,yymsp[0].minor.yy490);\n  binaryToUnaryIfNull(pParse, yymsp[0].minor.yy490, yymsp[-2].minor.yy490, TK_ISNULL);\n}\n        break;\n      case 193: /* expr ::= expr IS NOT expr */\n{\n  yymsp[-3].minor.yy490 = sqlite3PExpr(pParse,TK_ISNOT,yymsp[-3].minor.yy490,yymsp[0].minor.yy490);\n  binaryToUnaryIfNull(pParse, yymsp[0].minor.yy490, yymsp[-3].minor.yy490, TK_NOTNULL);\n}\n        break;\n      case 194: /* expr ::= NOT expr */\n      case 195: /* expr ::= BITNOT expr */ yytestcase(yyruleno==195);\n{yymsp[-1].minor.yy490 = sqlite3PExpr(pParse, yymsp[-1].major, yymsp[0].minor.yy490, 0);/*A-overwrites-B*/}\n        break;\n      case 196: /* expr ::= PLUS|MINUS expr */\n{\n  yymsp[-1].minor.yy490 = sqlite3PExpr(pParse, yymsp[-1].major==TK_PLUS ? TK_UPLUS : TK_UMINUS, yymsp[0].minor.yy490, 0);\n  /*A-overwrites-B*/\n}\n        break;\n      case 197: /* between_op ::= BETWEEN */\n      case 200: /* in_op ::= IN */ yytestcase(yyruleno==200);\n{yymsp[0].minor.yy96 = 0;}\n        break;\n      case 199: /* expr ::= expr between_op expr AND expr */\n{\n  ExprList *pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy490);\n  pList = sqlite3ExprListAppend(pParse,pList, yymsp[0].minor.yy490);\n  yymsp[-4].minor.yy490 = sqlite3PExpr(pParse, TK_BETWEEN, yymsp[-4].minor.yy490, 0);\n  if( yymsp[-4].minor.yy490 ){\n    yymsp[-4].minor.yy490->x.pList = pList;\n  }else{\n    sqlite3ExprListDelete(pParse->db, pList);\n  } \n  if( yymsp[-3].minor.yy96 ) yymsp[-4].minor.yy490 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy490, 0);\n}\n        break;\n      case 202: /* expr ::= expr in_op LP exprlist RP */\n{\n    if( yymsp[-1].minor.yy42==0 ){\n      /* Expressions of the form\n      **\n      **      expr1 IN ()\n      **      expr1 NOT IN ()\n      **\n      ** simplify to constants 0 (false) and 1 (true), respectively,\n      ** regardless of the value of expr1.\n      */\n      if( IN_RENAME_OBJECT==0 ){\n        sqlite3ExprDelete(pParse->db, yymsp[-4].minor.yy490);\n        yymsp[-4].minor.yy490 = sqlite3ExprAlloc(pParse->db, TK_INTEGER,&sqlite3IntTokens[yymsp[-3].minor.yy96],1);\n      }\n    }else if( yymsp[-1].minor.yy42->nExpr==1 ){\n      /* Expressions of the form:\n      **\n      **      expr1 IN (?1)\n      **      expr1 NOT IN (?2)\n      **\n      ** with exactly one value on the RHS can be simplified to something\n      ** like this:\n      **\n      **      expr1 == ?1\n      **      expr1 <> ?2\n      **\n      ** But, the RHS of the == or <> is marked with the EP_Generic flag\n      ** so that it may not contribute to the computation of comparison\n      ** affinity or the collating sequence to use for comparison.  Otherwise,\n      ** the semantics would be subtly different from IN or NOT IN.\n      */\n      Expr *pRHS = yymsp[-1].minor.yy42->a[0].pExpr;\n      yymsp[-1].minor.yy42->a[0].pExpr = 0;\n      sqlite3ExprListDelete(pParse->db, yymsp[-1].minor.yy42);\n      /* pRHS cannot be NULL because a malloc error would have been detected\n      ** before now and control would have never reached this point */\n      if( ALWAYS(pRHS) ){\n        pRHS->flags &= ~EP_Collate;\n        pRHS->flags |= EP_Generic;\n      }\n      yymsp[-4].minor.yy490 = sqlite3PExpr(pParse, yymsp[-3].minor.yy96 ? TK_NE : TK_EQ, yymsp[-4].minor.yy490, pRHS);\n    }else{\n      yymsp[-4].minor.yy490 = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy490, 0);\n      if( yymsp[-4].minor.yy490 ){\n        yymsp[-4].minor.yy490->x.pList = yymsp[-1].minor.yy42;\n        sqlite3ExprSetHeightAndFlags(pParse, yymsp[-4].minor.yy490);\n      }else{\n        sqlite3ExprListDelete(pParse->db, yymsp[-1].minor.yy42);\n      }\n      if( yymsp[-3].minor.yy96 ) yymsp[-4].minor.yy490 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy490, 0);\n    }\n  }\n        break;\n      case 203: /* expr ::= LP select RP */\n{\n    yymsp[-2].minor.yy490 = sqlite3PExpr(pParse, TK_SELECT, 0, 0);\n    sqlite3PExprAddSelect(pParse, yymsp[-2].minor.yy490, yymsp[-1].minor.yy423);\n  }\n        break;\n      case 204: /* expr ::= expr in_op LP select RP */\n{\n    yymsp[-4].minor.yy490 = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy490, 0);\n    sqlite3PExprAddSelect(pParse, yymsp[-4].minor.yy490, yymsp[-1].minor.yy423);\n    if( yymsp[-3].minor.yy96 ) yymsp[-4].minor.yy490 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy490, 0);\n  }\n        break;\n      case 205: /* expr ::= expr in_op nm dbnm paren_exprlist */\n{\n    SrcList *pSrc = sqlite3SrcListAppend(pParse, 0,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0);\n    Select *pSelect = sqlite3SelectNew(pParse, 0,pSrc,0,0,0,0,0,0);\n    if( yymsp[0].minor.yy42 )  sqlite3SrcListFuncArgs(pParse, pSelect ? pSrc : 0, yymsp[0].minor.yy42);\n    yymsp[-4].minor.yy490 = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy490, 0);\n    sqlite3PExprAddSelect(pParse, yymsp[-4].minor.yy490, pSelect);\n    if( yymsp[-3].minor.yy96 ) yymsp[-4].minor.yy490 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy490, 0);\n  }\n        break;\n      case 206: /* expr ::= EXISTS LP select RP */\n{\n    Expr *p;\n    p = yymsp[-3].minor.yy490 = sqlite3PExpr(pParse, TK_EXISTS, 0, 0);\n    sqlite3PExprAddSelect(pParse, p, yymsp[-1].minor.yy423);\n  }\n        break;\n      case 207: /* expr ::= CASE case_operand case_exprlist case_else END */\n{\n  yymsp[-4].minor.yy490 = sqlite3PExpr(pParse, TK_CASE, yymsp[-3].minor.yy490, 0);\n  if( yymsp[-4].minor.yy490 ){\n    yymsp[-4].minor.yy490->x.pList = yymsp[-1].minor.yy490 ? sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy42,yymsp[-1].minor.yy490) : yymsp[-2].minor.yy42;\n    sqlite3ExprSetHeightAndFlags(pParse, yymsp[-4].minor.yy490);\n  }else{\n    sqlite3ExprListDelete(pParse->db, yymsp[-2].minor.yy42);\n    sqlite3ExprDelete(pParse->db, yymsp[-1].minor.yy490);\n  }\n}\n        break;\n      case 208: /* case_exprlist ::= case_exprlist WHEN expr THEN expr */\n{\n  yymsp[-4].minor.yy42 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy42, yymsp[-2].minor.yy490);\n  yymsp[-4].minor.yy42 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy42, yymsp[0].minor.yy490);\n}\n        break;\n      case 209: /* case_exprlist ::= WHEN expr THEN expr */\n{\n  yymsp[-3].minor.yy42 = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy490);\n  yymsp[-3].minor.yy42 = sqlite3ExprListAppend(pParse,yymsp[-3].minor.yy42, yymsp[0].minor.yy490);\n}\n        break;\n      case 212: /* case_operand ::= expr */\n{yymsp[0].minor.yy490 = yymsp[0].minor.yy490; /*A-overwrites-X*/}\n        break;\n      case 215: /* nexprlist ::= nexprlist COMMA expr */\n{yymsp[-2].minor.yy42 = sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy42,yymsp[0].minor.yy490);}\n        break;\n      case 216: /* nexprlist ::= expr */\n{yymsp[0].minor.yy42 = sqlite3ExprListAppend(pParse,0,yymsp[0].minor.yy490); /*A-overwrites-Y*/}\n        break;\n      case 218: /* paren_exprlist ::= LP exprlist RP */\n      case 223: /* eidlist_opt ::= LP eidlist RP */ yytestcase(yyruleno==223);\n{yymsp[-2].minor.yy42 = yymsp[-1].minor.yy42;}\n        break;\n      case 219: /* cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt */\n{\n  sqlite3CreateIndex(pParse, &yymsp[-7].minor.yy0, &yymsp[-6].minor.yy0, \n                     sqlite3SrcListAppend(pParse,0,&yymsp[-4].minor.yy0,0), yymsp[-2].minor.yy42, yymsp[-10].minor.yy96,\n                      &yymsp[-11].minor.yy0, yymsp[0].minor.yy490, SQLITE_SO_ASC, yymsp[-8].minor.yy96, SQLITE_IDXTYPE_APPDEF);\n  if( IN_RENAME_OBJECT && pParse->pNewIndex ){\n    sqlite3RenameTokenMap(pParse, pParse->pNewIndex->zName, &yymsp[-4].minor.yy0);\n  }\n}\n        break;\n      case 220: /* uniqueflag ::= UNIQUE */\n      case 262: /* raisetype ::= ABORT */ yytestcase(yyruleno==262);\n{yymsp[0].minor.yy96 = OE_Abort;}\n        break;\n      case 221: /* uniqueflag ::= */\n{yymsp[1].minor.yy96 = OE_None;}\n        break;\n      case 224: /* eidlist ::= eidlist COMMA nm collate sortorder */\n{\n  yymsp[-4].minor.yy42 = parserAddExprIdListTerm(pParse, yymsp[-4].minor.yy42, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy96, yymsp[0].minor.yy96);\n}\n        break;\n      case 225: /* eidlist ::= nm collate sortorder */\n{\n  yymsp[-2].minor.yy42 = parserAddExprIdListTerm(pParse, 0, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy96, yymsp[0].minor.yy96); /*A-overwrites-Y*/\n}\n        break;\n      case 228: /* cmd ::= DROP INDEX ifexists fullname */\n{sqlite3DropIndex(pParse, yymsp[0].minor.yy167, yymsp[-1].minor.yy96);}\n        break;\n      case 229: /* cmd ::= VACUUM vinto */\n{sqlite3Vacuum(pParse,0,yymsp[0].minor.yy490);}\n        break;\n      case 230: /* cmd ::= VACUUM nm vinto */\n{sqlite3Vacuum(pParse,&yymsp[-1].minor.yy0,yymsp[0].minor.yy490);}\n        break;\n      case 233: /* cmd ::= PRAGMA nm dbnm */\n{sqlite3Pragma(pParse,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0,0,0);}\n        break;\n      case 234: /* cmd ::= PRAGMA nm dbnm EQ nmnum */\n{sqlite3Pragma(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0,0);}\n        break;\n      case 235: /* cmd ::= PRAGMA nm dbnm LP nmnum RP */\n{sqlite3Pragma(pParse,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,&yymsp[-1].minor.yy0,0);}\n        break;\n      case 236: /* cmd ::= PRAGMA nm dbnm EQ minus_num */\n{sqlite3Pragma(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0,1);}\n        break;\n      case 237: /* cmd ::= PRAGMA nm dbnm LP minus_num RP */\n{sqlite3Pragma(pParse,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,&yymsp[-1].minor.yy0,1);}\n        break;\n      case 240: /* cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */\n{\n  Token all;\n  all.z = yymsp[-3].minor.yy0.z;\n  all.n = (int)(yymsp[0].minor.yy0.z - yymsp[-3].minor.yy0.z) + yymsp[0].minor.yy0.n;\n  sqlite3FinishTrigger(pParse, yymsp[-1].minor.yy119, &all);\n}\n        break;\n      case 241: /* trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */\n{\n  sqlite3BeginTrigger(pParse, &yymsp[-7].minor.yy0, &yymsp[-6].minor.yy0, yymsp[-5].minor.yy96, yymsp[-4].minor.yy350.a, yymsp[-4].minor.yy350.b, yymsp[-2].minor.yy167, yymsp[0].minor.yy490, yymsp[-10].minor.yy96, yymsp[-8].minor.yy96);\n  yymsp[-10].minor.yy0 = (yymsp[-6].minor.yy0.n==0?yymsp[-7].minor.yy0:yymsp[-6].minor.yy0); /*A-overwrites-T*/\n}\n        break;\n      case 242: /* trigger_time ::= BEFORE|AFTER */\n{ yymsp[0].minor.yy96 = yymsp[0].major; /*A-overwrites-X*/ }\n        break;\n      case 243: /* trigger_time ::= INSTEAD OF */\n{ yymsp[-1].minor.yy96 = TK_INSTEAD;}\n        break;\n      case 244: /* trigger_time ::= */\n{ yymsp[1].minor.yy96 = TK_BEFORE; }\n        break;\n      case 245: /* trigger_event ::= DELETE|INSERT */\n      case 246: /* trigger_event ::= UPDATE */ yytestcase(yyruleno==246);\n{yymsp[0].minor.yy350.a = yymsp[0].major; /*A-overwrites-X*/ yymsp[0].minor.yy350.b = 0;}\n        break;\n      case 247: /* trigger_event ::= UPDATE OF idlist */\n{yymsp[-2].minor.yy350.a = TK_UPDATE; yymsp[-2].minor.yy350.b = yymsp[0].minor.yy336;}\n        break;\n      case 248: /* when_clause ::= */\n      case 267: /* key_opt ::= */ yytestcase(yyruleno==267);\n      case 309: /* filter_opt ::= */ yytestcase(yyruleno==309);\n{ yymsp[1].minor.yy490 = 0; }\n        break;\n      case 249: /* when_clause ::= WHEN expr */\n      case 268: /* key_opt ::= KEY expr */ yytestcase(yyruleno==268);\n{ yymsp[-1].minor.yy490 = yymsp[0].minor.yy490; }\n        break;\n      case 250: /* trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */\n{\n  assert( yymsp[-2].minor.yy119!=0 );\n  yymsp[-2].minor.yy119->pLast->pNext = yymsp[-1].minor.yy119;\n  yymsp[-2].minor.yy119->pLast = yymsp[-1].minor.yy119;\n}\n        break;\n      case 251: /* trigger_cmd_list ::= trigger_cmd SEMI */\n{ \n  assert( yymsp[-1].minor.yy119!=0 );\n  yymsp[-1].minor.yy119->pLast = yymsp[-1].minor.yy119;\n}\n        break;\n      case 252: /* trnm ::= nm DOT nm */\n{\n  yymsp[-2].minor.yy0 = yymsp[0].minor.yy0;\n  sqlite3ErrorMsg(pParse, \n        \"qualified table names are not allowed on INSERT, UPDATE, and DELETE \"\n        \"statements within triggers\");\n}\n        break;\n      case 253: /* tridxby ::= INDEXED BY nm */\n{\n  sqlite3ErrorMsg(pParse,\n        \"the INDEXED BY clause is not allowed on UPDATE or DELETE statements \"\n        \"within triggers\");\n}\n        break;\n      case 254: /* tridxby ::= NOT INDEXED */\n{\n  sqlite3ErrorMsg(pParse,\n        \"the NOT INDEXED clause is not allowed on UPDATE or DELETE statements \"\n        \"within triggers\");\n}\n        break;\n      case 255: /* trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt scanpt */\n{yylhsminor.yy119 = sqlite3TriggerUpdateStep(pParse, &yymsp[-5].minor.yy0, yymsp[-2].minor.yy42, yymsp[-1].minor.yy490, yymsp[-6].minor.yy96, yymsp[-7].minor.yy0.z, yymsp[0].minor.yy464);}\n  yymsp[-7].minor.yy119 = yylhsminor.yy119;\n        break;\n      case 256: /* trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt */\n{\n   yylhsminor.yy119 = sqlite3TriggerInsertStep(pParse,&yymsp[-4].minor.yy0,yymsp[-3].minor.yy336,yymsp[-2].minor.yy423,yymsp[-6].minor.yy96,yymsp[-1].minor.yy266,yymsp[-7].minor.yy464,yymsp[0].minor.yy464);/*yylhsminor.yy119-overwrites-yymsp[-6].minor.yy96*/\n}\n  yymsp[-7].minor.yy119 = yylhsminor.yy119;\n        break;\n      case 257: /* trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt */\n{yylhsminor.yy119 = sqlite3TriggerDeleteStep(pParse, &yymsp[-3].minor.yy0, yymsp[-1].minor.yy490, yymsp[-5].minor.yy0.z, yymsp[0].minor.yy464);}\n  yymsp[-5].minor.yy119 = yylhsminor.yy119;\n        break;\n      case 258: /* trigger_cmd ::= scanpt select scanpt */\n{yylhsminor.yy119 = sqlite3TriggerSelectStep(pParse->db, yymsp[-1].minor.yy423, yymsp[-2].minor.yy464, yymsp[0].minor.yy464); /*yylhsminor.yy119-overwrites-yymsp[-1].minor.yy423*/}\n  yymsp[-2].minor.yy119 = yylhsminor.yy119;\n        break;\n      case 259: /* expr ::= RAISE LP IGNORE RP */\n{\n  yymsp[-3].minor.yy490 = sqlite3PExpr(pParse, TK_RAISE, 0, 0); \n  if( yymsp[-3].minor.yy490 ){\n    yymsp[-3].minor.yy490->affinity = OE_Ignore;\n  }\n}\n        break;\n      case 260: /* expr ::= RAISE LP raisetype COMMA nm RP */\n{\n  yymsp[-5].minor.yy490 = sqlite3ExprAlloc(pParse->db, TK_RAISE, &yymsp[-1].minor.yy0, 1); \n  if( yymsp[-5].minor.yy490 ) {\n    yymsp[-5].minor.yy490->affinity = (char)yymsp[-3].minor.yy96;\n  }\n}\n        break;\n      case 261: /* raisetype ::= ROLLBACK */\n{yymsp[0].minor.yy96 = OE_Rollback;}\n        break;\n      case 263: /* raisetype ::= FAIL */\n{yymsp[0].minor.yy96 = OE_Fail;}\n        break;\n      case 264: /* cmd ::= DROP TRIGGER ifexists fullname */\n{\n  sqlite3DropTrigger(pParse,yymsp[0].minor.yy167,yymsp[-1].minor.yy96);\n}\n        break;\n      case 265: /* cmd ::= ATTACH database_kw_opt expr AS expr key_opt */\n{\n  sqlite3Attach(pParse, yymsp[-3].minor.yy490, yymsp[-1].minor.yy490, yymsp[0].minor.yy490);\n}\n        break;\n      case 266: /* cmd ::= DETACH database_kw_opt expr */\n{\n  sqlite3Detach(pParse, yymsp[0].minor.yy490);\n}\n        break;\n      case 269: /* cmd ::= REINDEX */\n{sqlite3Reindex(pParse, 0, 0);}\n        break;\n      case 270: /* cmd ::= REINDEX nm dbnm */\n{sqlite3Reindex(pParse, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0);}\n        break;\n      case 271: /* cmd ::= ANALYZE */\n{sqlite3Analyze(pParse, 0, 0);}\n        break;\n      case 272: /* cmd ::= ANALYZE nm dbnm */\n{sqlite3Analyze(pParse, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0);}\n        break;\n      case 273: /* cmd ::= ALTER TABLE fullname RENAME TO nm */\n{\n  sqlite3AlterRenameTable(pParse,yymsp[-3].minor.yy167,&yymsp[0].minor.yy0);\n}\n        break;\n      case 274: /* cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist */\n{\n  yymsp[-1].minor.yy0.n = (int)(pParse->sLastToken.z-yymsp[-1].minor.yy0.z) + pParse->sLastToken.n;\n  sqlite3AlterFinishAddColumn(pParse, &yymsp[-1].minor.yy0);\n}\n        break;\n      case 275: /* add_column_fullname ::= fullname */\n{\n  disableLookaside(pParse);\n  sqlite3AlterBeginAddColumn(pParse, yymsp[0].minor.yy167);\n}\n        break;\n      case 276: /* cmd ::= ALTER TABLE fullname RENAME kwcolumn_opt nm TO nm */\n{\n  sqlite3AlterRenameColumn(pParse, yymsp[-5].minor.yy167, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0);\n}\n        break;\n      case 277: /* cmd ::= create_vtab */\n{sqlite3VtabFinishParse(pParse,0);}\n        break;\n      case 278: /* cmd ::= create_vtab LP vtabarglist RP */\n{sqlite3VtabFinishParse(pParse,&yymsp[0].minor.yy0);}\n        break;\n      case 279: /* create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */\n{\n    sqlite3VtabBeginParse(pParse, &yymsp[-3].minor.yy0, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, yymsp[-4].minor.yy96);\n}\n        break;\n      case 280: /* vtabarg ::= */\n{sqlite3VtabArgInit(pParse);}\n        break;\n      case 281: /* vtabargtoken ::= ANY */\n      case 282: /* vtabargtoken ::= lp anylist RP */ yytestcase(yyruleno==282);\n      case 283: /* lp ::= LP */ yytestcase(yyruleno==283);\n{sqlite3VtabArgExtend(pParse,&yymsp[0].minor.yy0);}\n        break;\n      case 284: /* with ::= WITH wqlist */\n      case 285: /* with ::= WITH RECURSIVE wqlist */ yytestcase(yyruleno==285);\n{ sqlite3WithPush(pParse, yymsp[0].minor.yy499, 1); }\n        break;\n      case 286: /* wqlist ::= nm eidlist_opt AS LP select RP */\n{\n  yymsp[-5].minor.yy499 = sqlite3WithAdd(pParse, 0, &yymsp[-5].minor.yy0, yymsp[-4].minor.yy42, yymsp[-1].minor.yy423); /*A-overwrites-X*/\n}\n        break;\n      case 287: /* wqlist ::= wqlist COMMA nm eidlist_opt AS LP select RP */\n{\n  yymsp[-7].minor.yy499 = sqlite3WithAdd(pParse, yymsp[-7].minor.yy499, &yymsp[-5].minor.yy0, yymsp[-4].minor.yy42, yymsp[-1].minor.yy423);\n}\n        break;\n      case 288: /* windowdefn_list ::= windowdefn */\n{ yylhsminor.yy147 = yymsp[0].minor.yy147; }\n  yymsp[0].minor.yy147 = yylhsminor.yy147;\n        break;\n      case 289: /* windowdefn_list ::= windowdefn_list COMMA windowdefn */\n{\n  assert( yymsp[0].minor.yy147!=0 );\n  yymsp[0].minor.yy147->pNextWin = yymsp[-2].minor.yy147;\n  yylhsminor.yy147 = yymsp[0].minor.yy147;\n}\n  yymsp[-2].minor.yy147 = yylhsminor.yy147;\n        break;\n      case 290: /* windowdefn ::= nm AS window */\n{\n  if( ALWAYS(yymsp[0].minor.yy147) ){\n    yymsp[0].minor.yy147->zName = sqlite3DbStrNDup(pParse->db, yymsp[-2].minor.yy0.z, yymsp[-2].minor.yy0.n);\n  }\n  yylhsminor.yy147 = yymsp[0].minor.yy147;\n}\n  yymsp[-2].minor.yy147 = yylhsminor.yy147;\n        break;\n      case 291: /* window ::= LP part_opt orderby_opt frame_opt RP */\n{\n  yymsp[-4].minor.yy147 = yymsp[-1].minor.yy147;\n  if( ALWAYS(yymsp[-4].minor.yy147) ){\n    yymsp[-4].minor.yy147->pPartition = yymsp[-3].minor.yy42;\n    yymsp[-4].minor.yy147->pOrderBy = yymsp[-2].minor.yy42;\n  }\n}\n        break;\n      case 292: /* part_opt ::= PARTITION BY nexprlist */\n{ yymsp[-2].minor.yy42 = yymsp[0].minor.yy42; }\n        break;\n      case 293: /* part_opt ::= */\n{ yymsp[1].minor.yy42 = 0; }\n        break;\n      case 294: /* frame_opt ::= */\n{ \n  yymsp[1].minor.yy147 = sqlite3WindowAlloc(pParse, TK_RANGE, TK_UNBOUNDED, 0, TK_CURRENT, 0);\n}\n        break;\n      case 295: /* frame_opt ::= range_or_rows frame_bound_s */\n{ \n  yylhsminor.yy147 = sqlite3WindowAlloc(pParse, yymsp[-1].minor.yy96, yymsp[0].minor.yy317.eType, yymsp[0].minor.yy317.pExpr, TK_CURRENT, 0);\n}\n  yymsp[-1].minor.yy147 = yylhsminor.yy147;\n        break;\n      case 296: /* frame_opt ::= range_or_rows BETWEEN frame_bound_s AND frame_bound_e */\n{ \n  yylhsminor.yy147 = sqlite3WindowAlloc(pParse, yymsp[-4].minor.yy96, yymsp[-2].minor.yy317.eType, yymsp[-2].minor.yy317.pExpr, yymsp[0].minor.yy317.eType, yymsp[0].minor.yy317.pExpr);\n}\n  yymsp[-4].minor.yy147 = yylhsminor.yy147;\n        break;\n      case 297: /* range_or_rows ::= RANGE */\n{ yymsp[0].minor.yy96 = TK_RANGE; }\n        break;\n      case 298: /* range_or_rows ::= ROWS */\n{ yymsp[0].minor.yy96 = TK_ROWS;  }\n        break;\n      case 299: /* frame_bound_s ::= frame_bound */\n      case 301: /* frame_bound_e ::= frame_bound */ yytestcase(yyruleno==301);\n{ yylhsminor.yy317 = yymsp[0].minor.yy317; }\n  yymsp[0].minor.yy317 = yylhsminor.yy317;\n        break;\n      case 300: /* frame_bound_s ::= UNBOUNDED PRECEDING */\n      case 302: /* frame_bound_e ::= UNBOUNDED FOLLOWING */ yytestcase(yyruleno==302);\n{yymsp[-1].minor.yy317.eType = TK_UNBOUNDED; yymsp[-1].minor.yy317.pExpr = 0;}\n        break;\n      case 303: /* frame_bound ::= expr PRECEDING */\n{ yylhsminor.yy317.eType = TK_PRECEDING; yylhsminor.yy317.pExpr = yymsp[-1].minor.yy490; }\n  yymsp[-1].minor.yy317 = yylhsminor.yy317;\n        break;\n      case 304: /* frame_bound ::= CURRENT ROW */\n{ yymsp[-1].minor.yy317.eType = TK_CURRENT  ; yymsp[-1].minor.yy317.pExpr = 0; }\n        break;\n      case 305: /* frame_bound ::= expr FOLLOWING */\n{ yylhsminor.yy317.eType = TK_FOLLOWING; yylhsminor.yy317.pExpr = yymsp[-1].minor.yy490; }\n  yymsp[-1].minor.yy317 = yylhsminor.yy317;\n        break;\n      case 306: /* window_clause ::= WINDOW windowdefn_list */\n{ yymsp[-1].minor.yy147 = yymsp[0].minor.yy147; }\n        break;\n      case 307: /* over_clause ::= filter_opt OVER window */\n{\n  yylhsminor.yy147 = yymsp[0].minor.yy147;\n  assert( yylhsminor.yy147!=0 );\n  yylhsminor.yy147->pFilter = yymsp[-2].minor.yy490;\n}\n  yymsp[-2].minor.yy147 = yylhsminor.yy147;\n        break;\n      case 308: /* over_clause ::= filter_opt OVER nm */\n{\n  yylhsminor.yy147 = (Window*)sqlite3DbMallocZero(pParse->db, sizeof(Window));\n  if( yylhsminor.yy147 ){\n    yylhsminor.yy147->zName = sqlite3DbStrNDup(pParse->db, yymsp[0].minor.yy0.z, yymsp[0].minor.yy0.n);\n    yylhsminor.yy147->pFilter = yymsp[-2].minor.yy490;\n  }else{\n    sqlite3ExprDelete(pParse->db, yymsp[-2].minor.yy490);\n  }\n}\n  yymsp[-2].minor.yy147 = yylhsminor.yy147;\n        break;\n      case 310: /* filter_opt ::= FILTER LP WHERE expr RP */\n{ yymsp[-4].minor.yy490 = yymsp[-1].minor.yy490; }\n        break;\n      default:\n      /* (311) input ::= cmdlist */ yytestcase(yyruleno==311);\n      /* (312) cmdlist ::= cmdlist ecmd */ yytestcase(yyruleno==312);\n      /* (313) cmdlist ::= ecmd (OPTIMIZED OUT) */ assert(yyruleno!=313);\n      /* (314) ecmd ::= SEMI */ yytestcase(yyruleno==314);\n      /* (315) ecmd ::= cmdx SEMI */ yytestcase(yyruleno==315);\n      /* (316) ecmd ::= explain cmdx */ yytestcase(yyruleno==316);\n      /* (317) trans_opt ::= */ yytestcase(yyruleno==317);\n      /* (318) trans_opt ::= TRANSACTION */ yytestcase(yyruleno==318);\n      /* (319) trans_opt ::= TRANSACTION nm */ yytestcase(yyruleno==319);\n      /* (320) savepoint_opt ::= SAVEPOINT */ yytestcase(yyruleno==320);\n      /* (321) savepoint_opt ::= */ yytestcase(yyruleno==321);\n      /* (322) cmd ::= create_table create_table_args */ yytestcase(yyruleno==322);\n      /* (323) columnlist ::= columnlist COMMA columnname carglist */ yytestcase(yyruleno==323);\n      /* (324) columnlist ::= columnname carglist */ yytestcase(yyruleno==324);\n      /* (325) nm ::= ID|INDEXED */ yytestcase(yyruleno==325);\n      /* (326) nm ::= STRING */ yytestcase(yyruleno==326);\n      /* (327) nm ::= JOIN_KW */ yytestcase(yyruleno==327);\n      /* (328) typetoken ::= typename */ yytestcase(yyruleno==328);\n      /* (329) typename ::= ID|STRING */ yytestcase(yyruleno==329);\n      /* (330) signed ::= plus_num (OPTIMIZED OUT) */ assert(yyruleno!=330);\n      /* (331) signed ::= minus_num (OPTIMIZED OUT) */ assert(yyruleno!=331);\n      /* (332) carglist ::= carglist ccons */ yytestcase(yyruleno==332);\n      /* (333) carglist ::= */ yytestcase(yyruleno==333);\n      /* (334) ccons ::= NULL onconf */ yytestcase(yyruleno==334);\n      /* (335) conslist_opt ::= COMMA conslist */ yytestcase(yyruleno==335);\n      /* (336) conslist ::= conslist tconscomma tcons */ yytestcase(yyruleno==336);\n      /* (337) conslist ::= tcons (OPTIMIZED OUT) */ assert(yyruleno!=337);\n      /* (338) tconscomma ::= */ yytestcase(yyruleno==338);\n      /* (339) defer_subclause_opt ::= defer_subclause (OPTIMIZED OUT) */ assert(yyruleno!=339);\n      /* (340) resolvetype ::= raisetype (OPTIMIZED OUT) */ assert(yyruleno!=340);\n      /* (341) selectnowith ::= oneselect (OPTIMIZED OUT) */ assert(yyruleno!=341);\n      /* (342) oneselect ::= values */ yytestcase(yyruleno==342);\n      /* (343) sclp ::= selcollist COMMA */ yytestcase(yyruleno==343);\n      /* (344) as ::= ID|STRING */ yytestcase(yyruleno==344);\n      /* (345) expr ::= term (OPTIMIZED OUT) */ assert(yyruleno!=345);\n      /* (346) likeop ::= LIKE_KW|MATCH */ yytestcase(yyruleno==346);\n      /* (347) exprlist ::= nexprlist */ yytestcase(yyruleno==347);\n      /* (348) nmnum ::= plus_num (OPTIMIZED OUT) */ assert(yyruleno!=348);\n      /* (349) nmnum ::= nm (OPTIMIZED OUT) */ assert(yyruleno!=349);\n      /* (350) nmnum ::= ON */ yytestcase(yyruleno==350);\n      /* (351) nmnum ::= DELETE */ yytestcase(yyruleno==351);\n      /* (352) nmnum ::= DEFAULT */ yytestcase(yyruleno==352);\n      /* (353) plus_num ::= INTEGER|FLOAT */ yytestcase(yyruleno==353);\n      /* (354) foreach_clause ::= */ yytestcase(yyruleno==354);\n      /* (355) foreach_clause ::= FOR EACH ROW */ yytestcase(yyruleno==355);\n      /* (356) trnm ::= nm */ yytestcase(yyruleno==356);\n      /* (357) tridxby ::= */ yytestcase(yyruleno==357);\n      /* (358) database_kw_opt ::= DATABASE */ yytestcase(yyruleno==358);\n      /* (359) database_kw_opt ::= */ yytestcase(yyruleno==359);\n      /* (360) kwcolumn_opt ::= */ yytestcase(yyruleno==360);\n      /* (361) kwcolumn_opt ::= COLUMNKW */ yytestcase(yyruleno==361);\n      /* (362) vtabarglist ::= vtabarg */ yytestcase(yyruleno==362);\n      /* (363) vtabarglist ::= vtabarglist COMMA vtabarg */ yytestcase(yyruleno==363);\n      /* (364) vtabarg ::= vtabarg vtabargtoken */ yytestcase(yyruleno==364);\n      /* (365) anylist ::= */ yytestcase(yyruleno==365);\n      /* (366) anylist ::= anylist LP anylist RP */ yytestcase(yyruleno==366);\n      /* (367) anylist ::= anylist ANY */ yytestcase(yyruleno==367);\n      /* (368) with ::= */ yytestcase(yyruleno==368);\n        break;\n/********** End reduce actions ************************************************/\n  };\n  assert( yyruleno<sizeof(yyRuleInfoLhs)/sizeof(yyRuleInfoLhs[0]) );\n  yygoto = yyRuleInfoLhs[yyruleno];\n  yysize = yyRuleInfoNRhs[yyruleno];\n  yyact = yy_find_reduce_action(yymsp[yysize].stateno,(YYCODETYPE)yygoto);\n\n  /* There are no SHIFTREDUCE actions on nonterminals because the table\n  ** generator has simplified them to pure REDUCE actions. */\n  assert( !(yyact>YY_MAX_SHIFT && yyact<=YY_MAX_SHIFTREDUCE) );\n\n  /* It is not possible for a REDUCE to be followed by an error */\n  assert( yyact!=YY_ERROR_ACTION );\n\n  yymsp += yysize+1;\n  yypParser->yytos = yymsp;\n  yymsp->stateno = (YYACTIONTYPE)yyact;\n  yymsp->major = (YYCODETYPE)yygoto;\n  yyTraceShift(yypParser, yyact, \"... then shift\");\n  return yyact;\n}\n\n/*\n** The following code executes when the parse fails\n*/\n#ifndef YYNOERRORRECOVERY\nstatic void yy_parse_failed(\n  yyParser *yypParser           /* The parser */\n){\n  sqlite3ParserARG_FETCH\n  sqlite3ParserCTX_FETCH\n#ifndef NDEBUG\n  if( yyTraceFILE ){\n    fprintf(yyTraceFILE,\"%sFail!\\n\",yyTracePrompt);\n  }\n#endif\n  while( yypParser->yytos>yypParser->yystack ) yy_pop_parser_stack(yypParser);\n  /* Here code is inserted which will be executed whenever the\n  ** parser fails */\n/************ Begin %parse_failure code ***************************************/\n/************ End %parse_failure code *****************************************/\n  sqlite3ParserARG_STORE /* Suppress warning about unused %extra_argument variable */\n  sqlite3ParserCTX_STORE\n}\n#endif /* YYNOERRORRECOVERY */\n\n/*\n** The following code executes when a syntax error first occurs.\n*/\nstatic void yy_syntax_error(\n  yyParser *yypParser,           /* The parser */\n  int yymajor,                   /* The major type of the error token */\n  sqlite3ParserTOKENTYPE yyminor         /* The minor type of the error token */\n){\n  sqlite3ParserARG_FETCH\n  sqlite3ParserCTX_FETCH\n#define TOKEN yyminor\n/************ Begin %syntax_error code ****************************************/\n\n  UNUSED_PARAMETER(yymajor);  /* Silence some compiler warnings */\n  if( TOKEN.z[0] ){\n    sqlite3ErrorMsg(pParse, \"near \\\"%T\\\": syntax error\", &TOKEN);\n  }else{\n    sqlite3ErrorMsg(pParse, \"incomplete input\");\n  }\n/************ End %syntax_error code ******************************************/\n  sqlite3ParserARG_STORE /* Suppress warning about unused %extra_argument variable */\n  sqlite3ParserCTX_STORE\n}\n\n/*\n** The following is executed when the parser accepts\n*/\nstatic void yy_accept(\n  yyParser *yypParser           /* The parser */\n){\n  sqlite3ParserARG_FETCH\n  sqlite3ParserCTX_FETCH\n#ifndef NDEBUG\n  if( yyTraceFILE ){\n    fprintf(yyTraceFILE,\"%sAccept!\\n\",yyTracePrompt);\n  }\n#endif\n#ifndef YYNOERRORRECOVERY\n  yypParser->yyerrcnt = -1;\n#endif\n  assert( yypParser->yytos==yypParser->yystack );\n  /* Here code is inserted which will be executed whenever the\n  ** parser accepts */\n/*********** Begin %parse_accept code *****************************************/\n/*********** End %parse_accept code *******************************************/\n  sqlite3ParserARG_STORE /* Suppress warning about unused %extra_argument variable */\n  sqlite3ParserCTX_STORE\n}\n\n/* The main parser program.\n** The first argument is a pointer to a structure obtained from\n** \"sqlite3ParserAlloc\" which describes the current state of the parser.\n** The second argument is the major token number.  The third is\n** the minor token.  The fourth optional argument is whatever the\n** user wants (and specified in the grammar) and is available for\n** use by the action routines.\n**\n** Inputs:\n** <ul>\n** <li> A pointer to the parser (an opaque structure.)\n** <li> The major token number.\n** <li> The minor token number.\n** <li> An option argument of a grammar-specified type.\n** </ul>\n**\n** Outputs:\n** None.\n*/\nSQLITE_PRIVATE void sqlite3Parser(\n  void *yyp,                   /* The parser */\n  int yymajor,                 /* The major token code number */\n  sqlite3ParserTOKENTYPE yyminor       /* The value for the token */\n  sqlite3ParserARG_PDECL               /* Optional %extra_argument parameter */\n){\n  YYMINORTYPE yyminorunion;\n  YYACTIONTYPE yyact;   /* The parser action. */\n#if !defined(YYERRORSYMBOL) && !defined(YYNOERRORRECOVERY)\n  int yyendofinput;     /* True if we are at the end of input */\n#endif\n#ifdef YYERRORSYMBOL\n  int yyerrorhit = 0;   /* True if yymajor has invoked an error */\n#endif\n  yyParser *yypParser = (yyParser*)yyp;  /* The parser */\n  sqlite3ParserCTX_FETCH\n  sqlite3ParserARG_STORE\n\n  assert( yypParser->yytos!=0 );\n#if !defined(YYERRORSYMBOL) && !defined(YYNOERRORRECOVERY)\n  yyendofinput = (yymajor==0);\n#endif\n\n  yyact = yypParser->yytos->stateno;\n#ifndef NDEBUG\n  if( yyTraceFILE ){\n    if( yyact < YY_MIN_REDUCE ){\n      fprintf(yyTraceFILE,\"%sInput '%s' in state %d\\n\",\n              yyTracePrompt,yyTokenName[yymajor],yyact);\n    }else{\n      fprintf(yyTraceFILE,\"%sInput '%s' with pending reduce %d\\n\",\n              yyTracePrompt,yyTokenName[yymajor],yyact-YY_MIN_REDUCE);\n    }\n  }\n#endif\n\n  do{\n    assert( yyact==yypParser->yytos->stateno );\n    yyact = yy_find_shift_action((YYCODETYPE)yymajor,yyact);\n    if( yyact >= YY_MIN_REDUCE ){\n      yyact = yy_reduce(yypParser,yyact-YY_MIN_REDUCE,yymajor,\n                        yyminor sqlite3ParserCTX_PARAM);\n    }else if( yyact <= YY_MAX_SHIFTREDUCE ){\n      yy_shift(yypParser,yyact,(YYCODETYPE)yymajor,yyminor);\n#ifndef YYNOERRORRECOVERY\n      yypParser->yyerrcnt--;\n#endif\n      break;\n    }else if( yyact==YY_ACCEPT_ACTION ){\n      yypParser->yytos--;\n      yy_accept(yypParser);\n      return;\n    }else{\n      assert( yyact == YY_ERROR_ACTION );\n      yyminorunion.yy0 = yyminor;\n#ifdef YYERRORSYMBOL\n      int yymx;\n#endif\n#ifndef NDEBUG\n      if( yyTraceFILE ){\n        fprintf(yyTraceFILE,\"%sSyntax Error!\\n\",yyTracePrompt);\n      }\n#endif\n#ifdef YYERRORSYMBOL\n      /* A syntax error has occurred.\n      ** The response to an error depends upon whether or not the\n      ** grammar defines an error token \"ERROR\".  \n      **\n      ** This is what we do if the grammar does define ERROR:\n      **\n      **  * Call the %syntax_error function.\n      **\n      **  * Begin popping the stack until we enter a state where\n      **    it is legal to shift the error symbol, then shift\n      **    the error symbol.\n      **\n      **  * Set the error count to three.\n      **\n      **  * Begin accepting and shifting new tokens.  No new error\n      **    processing will occur until three tokens have been\n      **    shifted successfully.\n      **\n      */\n      if( yypParser->yyerrcnt<0 ){\n        yy_syntax_error(yypParser,yymajor,yyminor);\n      }\n      yymx = yypParser->yytos->major;\n      if( yymx==YYERRORSYMBOL || yyerrorhit ){\n#ifndef NDEBUG\n        if( yyTraceFILE ){\n          fprintf(yyTraceFILE,\"%sDiscard input token %s\\n\",\n             yyTracePrompt,yyTokenName[yymajor]);\n        }\n#endif\n        yy_destructor(yypParser, (YYCODETYPE)yymajor, &yyminorunion);\n        yymajor = YYNOCODE;\n      }else{\n        while( yypParser->yytos >= yypParser->yystack\n            && (yyact = yy_find_reduce_action(\n                        yypParser->yytos->stateno,\n                        YYERRORSYMBOL)) > YY_MAX_SHIFTREDUCE\n        ){\n          yy_pop_parser_stack(yypParser);\n        }\n        if( yypParser->yytos < yypParser->yystack || yymajor==0 ){\n          yy_destructor(yypParser,(YYCODETYPE)yymajor,&yyminorunion);\n          yy_parse_failed(yypParser);\n#ifndef YYNOERRORRECOVERY\n          yypParser->yyerrcnt = -1;\n#endif\n          yymajor = YYNOCODE;\n        }else if( yymx!=YYERRORSYMBOL ){\n          yy_shift(yypParser,yyact,YYERRORSYMBOL,yyminor);\n        }\n      }\n      yypParser->yyerrcnt = 3;\n      yyerrorhit = 1;\n      if( yymajor==YYNOCODE ) break;\n      yyact = yypParser->yytos->stateno;\n#elif defined(YYNOERRORRECOVERY)\n      /* If the YYNOERRORRECOVERY macro is defined, then do not attempt to\n      ** do any kind of error recovery.  Instead, simply invoke the syntax\n      ** error routine and continue going as if nothing had happened.\n      **\n      ** Applications can set this macro (for example inside %include) if\n      ** they intend to abandon the parse upon the first syntax error seen.\n      */\n      yy_syntax_error(yypParser,yymajor, yyminor);\n      yy_destructor(yypParser,(YYCODETYPE)yymajor,&yyminorunion);\n      break;\n#else  /* YYERRORSYMBOL is not defined */\n      /* This is what we do if the grammar does not define ERROR:\n      **\n      **  * Report an error message, and throw away the input token.\n      **\n      **  * If the input token is $, then fail the parse.\n      **\n      ** As before, subsequent error messages are suppressed until\n      ** three input tokens have been successfully shifted.\n      */\n      if( yypParser->yyerrcnt<=0 ){\n        yy_syntax_error(yypParser,yymajor, yyminor);\n      }\n      yypParser->yyerrcnt = 3;\n      yy_destructor(yypParser,(YYCODETYPE)yymajor,&yyminorunion);\n      if( yyendofinput ){\n        yy_parse_failed(yypParser);\n#ifndef YYNOERRORRECOVERY\n        yypParser->yyerrcnt = -1;\n#endif\n      }\n      break;\n#endif\n    }\n  }while( yypParser->yytos>yypParser->yystack );\n#ifndef NDEBUG\n  if( yyTraceFILE ){\n    yyStackEntry *i;\n    char cDiv = '[';\n    fprintf(yyTraceFILE,\"%sReturn. Stack=\",yyTracePrompt);\n    for(i=&yypParser->yystack[1]; i<=yypParser->yytos; i++){\n      fprintf(yyTraceFILE,\"%c%s\", cDiv, yyTokenName[i->major]);\n      cDiv = ' ';\n    }\n    fprintf(yyTraceFILE,\"]\\n\");\n  }\n#endif\n  return;\n}\n\n/*\n** Return the fallback token corresponding to canonical token iToken, or\n** 0 if iToken has no fallback.\n*/\nSQLITE_PRIVATE int sqlite3ParserFallback(int iToken){\n#ifdef YYFALLBACK\n  if( iToken<(int)(sizeof(yyFallback)/sizeof(yyFallback[0])) ){\n    return yyFallback[iToken];\n  }\n#else\n  (void)iToken;\n#endif\n  return 0;\n}\n\n/************** End of parse.c ***********************************************/\n/************** Begin file tokenize.c ****************************************/\n/*\n** 2001 September 15\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** An tokenizer for SQL\n**\n** This file contains C code that splits an SQL input string up into\n** individual tokens and sends those tokens one-by-one over to the\n** parser for analysis.\n*/\n/* #include \"sqliteInt.h\" */\n/* #include <stdlib.h> */\n\n/* Character classes for tokenizing\n**\n** In the sqlite3GetToken() function, a switch() on aiClass[c] is implemented\n** using a lookup table, whereas a switch() directly on c uses a binary search.\n** The lookup table is much faster.  To maximize speed, and to ensure that\n** a lookup table is used, all of the classes need to be small integers and\n** all of them need to be used within the switch.\n*/\n#define CC_X          0    /* The letter 'x', or start of BLOB literal */\n#define CC_KYWD       1    /* Alphabetics or '_'.  Usable in a keyword */\n#define CC_ID         2    /* unicode characters usable in IDs */\n#define CC_DIGIT      3    /* Digits */\n#define CC_DOLLAR     4    /* '$' */\n#define CC_VARALPHA   5    /* '@', '#', ':'.  Alphabetic SQL variables */\n#define CC_VARNUM     6    /* '?'.  Numeric SQL variables */\n#define CC_SPACE      7    /* Space characters */\n#define CC_QUOTE      8    /* '\"', '\\'', or '`'.  String literals, quoted ids */\n#define CC_QUOTE2     9    /* '['.   [...] style quoted ids */\n#define CC_PIPE      10    /* '|'.   Bitwise OR or concatenate */\n#define CC_MINUS     11    /* '-'.  Minus or SQL-style comment */\n#define CC_LT        12    /* '<'.  Part of < or <= or <> */\n#define CC_GT        13    /* '>'.  Part of > or >= */\n#define CC_EQ        14    /* '='.  Part of = or == */\n#define CC_BANG      15    /* '!'.  Part of != */\n#define CC_SLASH     16    /* '/'.  / or c-style comment */\n#define CC_LP        17    /* '(' */\n#define CC_RP        18    /* ')' */\n#define CC_SEMI      19    /* ';' */\n#define CC_PLUS      20    /* '+' */\n#define CC_STAR      21    /* '*' */\n#define CC_PERCENT   22    /* '%' */\n#define CC_COMMA     23    /* ',' */\n#define CC_AND       24    /* '&' */\n#define CC_TILDA     25    /* '~' */\n#define CC_DOT       26    /* '.' */\n#define CC_ILLEGAL   27    /* Illegal character */\n#define CC_NUL       28    /* 0x00 */\n\nstatic const unsigned char aiClass[] = {\n#ifdef SQLITE_ASCII\n/*         x0  x1  x2  x3  x4  x5  x6  x7  x8  x9  xa  xb  xc  xd  xe  xf */\n/* 0x */   28, 27, 27, 27, 27, 27, 27, 27, 27,  7,  7, 27,  7,  7, 27, 27,\n/* 1x */   27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27,\n/* 2x */    7, 15,  8,  5,  4, 22, 24,  8, 17, 18, 21, 20, 23, 11, 26, 16,\n/* 3x */    3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  5, 19, 12, 14, 13,  6,\n/* 4x */    5,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,\n/* 5x */    1,  1,  1,  1,  1,  1,  1,  1,  0,  1,  1,  9, 27, 27, 27,  1,\n/* 6x */    8,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,\n/* 7x */    1,  1,  1,  1,  1,  1,  1,  1,  0,  1,  1, 27, 10, 27, 25, 27,\n/* 8x */    2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,\n/* 9x */    2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,\n/* Ax */    2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,\n/* Bx */    2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,\n/* Cx */    2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,\n/* Dx */    2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,\n/* Ex */    2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,\n/* Fx */    2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2\n#endif\n#ifdef SQLITE_EBCDIC\n/*         x0  x1  x2  x3  x4  x5  x6  x7  x8  x9  xa  xb  xc  xd  xe  xf */\n/* 0x */   27, 27, 27, 27, 27,  7, 27, 27, 27, 27, 27, 27,  7,  7, 27, 27,\n/* 1x */   27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27,\n/* 2x */   27, 27, 27, 27, 27,  7, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27,\n/* 3x */   27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27,\n/* 4x */    7, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 26, 12, 17, 20, 10,\n/* 5x */   24, 27, 27, 27, 27, 27, 27, 27, 27, 27, 15,  4, 21, 18, 19, 27,\n/* 6x */   11, 16, 27, 27, 27, 27, 27, 27, 27, 27, 27, 23, 22,  1, 13,  6,\n/* 7x */   27, 27, 27, 27, 27, 27, 27, 27, 27,  8,  5,  5,  5,  8, 14,  8,\n/* 8x */   27,  1,  1,  1,  1,  1,  1,  1,  1,  1, 27, 27, 27, 27, 27, 27,\n/* 9x */   27,  1,  1,  1,  1,  1,  1,  1,  1,  1, 27, 27, 27, 27, 27, 27,\n/* Ax */   27, 25,  1,  1,  1,  1,  1,  0,  1,  1, 27, 27, 27, 27, 27, 27,\n/* Bx */   27, 27, 27, 27, 27, 27, 27, 27, 27, 27,  9, 27, 27, 27, 27, 27,\n/* Cx */   27,  1,  1,  1,  1,  1,  1,  1,  1,  1, 27, 27, 27, 27, 27, 27,\n/* Dx */   27,  1,  1,  1,  1,  1,  1,  1,  1,  1, 27, 27, 27, 27, 27, 27,\n/* Ex */   27, 27,  1,  1,  1,  1,  1,  0,  1,  1, 27, 27, 27, 27, 27, 27,\n/* Fx */    3,  3,  3,  3,  3,  3,  3,  3,  3,  3, 27, 27, 27, 27, 27, 27,\n#endif\n};\n\n/*\n** The charMap() macro maps alphabetic characters (only) into their\n** lower-case ASCII equivalent.  On ASCII machines, this is just\n** an upper-to-lower case map.  On EBCDIC machines we also need\n** to adjust the encoding.  The mapping is only valid for alphabetics\n** which are the only characters for which this feature is used. \n**\n** Used by keywordhash.h\n*/\n#ifdef SQLITE_ASCII\n# define charMap(X) sqlite3UpperToLower[(unsigned char)X]\n#endif\n#ifdef SQLITE_EBCDIC\n# define charMap(X) ebcdicToAscii[(unsigned char)X]\nconst unsigned char ebcdicToAscii[] = {\n/* 0   1   2   3   4   5   6   7   8   9   A   B   C   D   E   F */\n   0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  /* 0x */\n   0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  /* 1x */\n   0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  /* 2x */\n   0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  /* 3x */\n   0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  /* 4x */\n   0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  /* 5x */\n   0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 95,  0,  0,  /* 6x */\n   0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  /* 7x */\n   0, 97, 98, 99,100,101,102,103,104,105,  0,  0,  0,  0,  0,  0,  /* 8x */\n   0,106,107,108,109,110,111,112,113,114,  0,  0,  0,  0,  0,  0,  /* 9x */\n   0,  0,115,116,117,118,119,120,121,122,  0,  0,  0,  0,  0,  0,  /* Ax */\n   0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  /* Bx */\n   0, 97, 98, 99,100,101,102,103,104,105,  0,  0,  0,  0,  0,  0,  /* Cx */\n   0,106,107,108,109,110,111,112,113,114,  0,  0,  0,  0,  0,  0,  /* Dx */\n   0,  0,115,116,117,118,119,120,121,122,  0,  0,  0,  0,  0,  0,  /* Ex */\n   0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  /* Fx */\n};\n#endif\n\n/*\n** The sqlite3KeywordCode function looks up an identifier to determine if\n** it is a keyword.  If it is a keyword, the token code of that keyword is \n** returned.  If the input is not a keyword, TK_ID is returned.\n**\n** The implementation of this routine was generated by a program,\n** mkkeywordhash.c, located in the tool subdirectory of the distribution.\n** The output of the mkkeywordhash.c program is written into a file\n** named keywordhash.h and then included into this source file by\n** the #include below.\n*/\n/************** Include keywordhash.h in the middle of tokenize.c ************/\n/************** Begin file keywordhash.h *************************************/\n/***** This file contains automatically generated code ******\n**\n** The code in this file has been automatically generated by\n**\n**   sqlite/tool/mkkeywordhash.c\n**\n** The code in this file implements a function that determines whether\n** or not a given identifier is really an SQL keyword.  The same thing\n** might be implemented more directly using a hand-written hash table.\n** But by using this automatically generated code, the size of the code\n** is substantially reduced.  This is important for embedded applications\n** on platforms with limited memory.\n*/\n/* Hash score: 208 */\n/* zKWText[] encodes 923 bytes of keyword text in 614 bytes */\n/*   REINDEXEDESCAPEACHECKEYBEFOREIGNOREGEXPLAINSTEADDATABASELECT       */\n/*   ABLEFTHENDEFERRABLELSEXCEPTRANSACTIONATURALTERAISEXCLUSIVE         */\n/*   XISTSAVEPOINTERSECTRIGGEREFERENCESCONSTRAINTOFFSETEMPORARY         */\n/*   UNIQUERYWITHOUTERELEASEATTACHAVINGROUPDATEBEGINNERANGEBETWEEN      */\n/*   OTHINGLOBYCASCADELETECASECOLLATECREATECURRENT_DATEDETACH           */\n/*   IMMEDIATEJOINSERTLIKEMATCHPLANALYZEPRAGMABORTVALUESVIRTUALIMIT     */\n/*   WHENOTNULLWHERECURSIVEAFTERENAMEANDEFAULTAUTOINCREMENTCAST         */\n/*   COLUMNCOMMITCONFLICTCROSSCURRENT_TIMESTAMPARTITIONDEFERRED         */\n/*   ISTINCTDROPRECEDINGFAILFILTEREPLACEFOLLOWINGFROMFULLIFISNULL       */\n/*   ORDERESTRICTOVERIGHTROLLBACKROWSUNBOUNDEDUNIONUSINGVACUUMVIEW      */\n/*   INDOWINITIALLYPRIMARY                                              */\nstatic const char zKWText[613] = {\n  'R','E','I','N','D','E','X','E','D','E','S','C','A','P','E','A','C','H',\n  'E','C','K','E','Y','B','E','F','O','R','E','I','G','N','O','R','E','G',\n  'E','X','P','L','A','I','N','S','T','E','A','D','D','A','T','A','B','A',\n  'S','E','L','E','C','T','A','B','L','E','F','T','H','E','N','D','E','F',\n  'E','R','R','A','B','L','E','L','S','E','X','C','E','P','T','R','A','N',\n  'S','A','C','T','I','O','N','A','T','U','R','A','L','T','E','R','A','I',\n  'S','E','X','C','L','U','S','I','V','E','X','I','S','T','S','A','V','E',\n  'P','O','I','N','T','E','R','S','E','C','T','R','I','G','G','E','R','E',\n  'F','E','R','E','N','C','E','S','C','O','N','S','T','R','A','I','N','T',\n  'O','F','F','S','E','T','E','M','P','O','R','A','R','Y','U','N','I','Q',\n  'U','E','R','Y','W','I','T','H','O','U','T','E','R','E','L','E','A','S',\n  'E','A','T','T','A','C','H','A','V','I','N','G','R','O','U','P','D','A',\n  'T','E','B','E','G','I','N','N','E','R','A','N','G','E','B','E','T','W',\n  'E','E','N','O','T','H','I','N','G','L','O','B','Y','C','A','S','C','A',\n  'D','E','L','E','T','E','C','A','S','E','C','O','L','L','A','T','E','C',\n  'R','E','A','T','E','C','U','R','R','E','N','T','_','D','A','T','E','D',\n  'E','T','A','C','H','I','M','M','E','D','I','A','T','E','J','O','I','N',\n  'S','E','R','T','L','I','K','E','M','A','T','C','H','P','L','A','N','A',\n  'L','Y','Z','E','P','R','A','G','M','A','B','O','R','T','V','A','L','U',\n  'E','S','V','I','R','T','U','A','L','I','M','I','T','W','H','E','N','O',\n  'T','N','U','L','L','W','H','E','R','E','C','U','R','S','I','V','E','A',\n  'F','T','E','R','E','N','A','M','E','A','N','D','E','F','A','U','L','T',\n  'A','U','T','O','I','N','C','R','E','M','E','N','T','C','A','S','T','C',\n  'O','L','U','M','N','C','O','M','M','I','T','C','O','N','F','L','I','C',\n  'T','C','R','O','S','S','C','U','R','R','E','N','T','_','T','I','M','E',\n  'S','T','A','M','P','A','R','T','I','T','I','O','N','D','E','F','E','R',\n  'R','E','D','I','S','T','I','N','C','T','D','R','O','P','R','E','C','E',\n  'D','I','N','G','F','A','I','L','F','I','L','T','E','R','E','P','L','A',\n  'C','E','F','O','L','L','O','W','I','N','G','F','R','O','M','F','U','L',\n  'L','I','F','I','S','N','U','L','L','O','R','D','E','R','E','S','T','R',\n  'I','C','T','O','V','E','R','I','G','H','T','R','O','L','L','B','A','C',\n  'K','R','O','W','S','U','N','B','O','U','N','D','E','D','U','N','I','O',\n  'N','U','S','I','N','G','V','A','C','U','U','M','V','I','E','W','I','N',\n  'D','O','W','I','N','I','T','I','A','L','L','Y','P','R','I','M','A','R',\n  'Y',\n};\n/* aKWHash[i] is the hash value for the i-th keyword */\nstatic const unsigned char aKWHash[127] = {\n    74, 109, 124,  72, 106,  45,   0,   0,  81,   0,  76,  61,   0,\n    42,  12,  77,  15,   0, 123,  84,  54, 118, 125,  19,   0,   0,\n   130,   0, 128, 121,   0,  22,  96,   0,   9,   0,   0, 115,  69,\n     0,  67,   6,   0,  48,  93, 136,   0, 126, 104,   0,   0,  44,\n     0, 107,  24,   0,  17,   0, 131,  53,  23,   0,   5,  62, 132,\n    99,   0,   0, 135, 110,  60, 134,  57, 113,  55,   0,  94,   0,\n   103,  26,   0, 102,   0,   0,   0,  98,  95, 100, 105, 117,  14,\n    39, 116,   0,  80,   0, 133, 114,  92,  59,   0, 129,  79, 119,\n    86,  46,  83,   0,   0,  97,  40, 122, 120,   0, 127,   0,   0,\n    29,   0,  89,  87,  88,   0,  20,  85, 111,  56,\n};\n/* aKWNext[] forms the hash collision chain.  If aKWHash[i]==0\n** then the i-th keyword has no more hash collisions.  Otherwise,\n** the next keyword with the same hash is aKWHash[i]-1. */\nstatic const unsigned char aKWNext[136] = {\n     0,   0,   0,   0,   4,   0,   0,   0,   0,   0,   0,   0,   0,\n     0,   2,   0,   0,   0,   0,   0,   0,  13,   0,   0,   0,   0,\n     0,   7,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,\n     0,   0,   0,   0,  33,   0,  21,   0,   0,   0,   0,   0,  50,\n     0,  43,   3,  47,   0,   0,  32,   0,   0,   0,   0,   0,   0,\n     0,   1,  64,   0,   0,  65,   0,  41,   0,  38,   0,   0,   0,\n     0,   0,  49,  75,   0,   0,  30,   0,  58,   0,   0,   0,  31,\n    63,  16,  34,  10,   0,   0,   0,   0,   0,   0,   0,  11,  70,\n    91,   0,   0,   8,   0, 108,   0, 101,  28,  52,  68,   0, 112,\n     0,  73,  51,   0,  90,  27,  37,   0,  71,  36,  82,   0,  35,\n    66,  25,  18,   0,   0,  78,\n};\n/* aKWLen[i] is the length (in bytes) of the i-th keyword */\nstatic const unsigned char aKWLen[136] = {\n     7,   7,   5,   4,   6,   4,   5,   3,   6,   7,   3,   6,   6,\n     7,   7,   3,   8,   2,   6,   5,   4,   4,   3,  10,   4,   6,\n    11,   6,   2,   7,   5,   5,   9,   6,   9,   9,   7,  10,  10,\n     4,   6,   2,   3,   9,   4,   2,   6,   5,   7,   4,   5,   7,\n     6,   6,   5,   6,   5,   5,   5,   7,   7,   4,   2,   7,   3,\n     6,   4,   7,   6,  12,   6,   9,   4,   6,   4,   5,   4,   7,\n     6,   5,   6,   7,   5,   4,   7,   3,   2,   4,   5,   9,   5,\n     6,   3,   7,  13,   2,   2,   4,   6,   6,   8,   5,  17,  12,\n     7,   9,   8,   8,   2,   4,   9,   4,   6,   7,   9,   4,   4,\n     2,   6,   5,   8,   4,   5,   8,   4,   3,   9,   5,   5,   6,\n     4,   6,   2,   9,   3,   7,\n};\n/* aKWOffset[i] is the index into zKWText[] of the start of\n** the text for the i-th keyword. */\nstatic const unsigned short int aKWOffset[136] = {\n     0,   2,   2,   8,   9,  14,  16,  20,  23,  25,  25,  29,  33,\n    36,  41,  46,  48,  53,  54,  59,  62,  65,  67,  69,  78,  81,\n    86,  91,  95,  96, 101, 105, 109, 117, 122, 128, 136, 142, 152,\n   159, 162, 162, 165, 167, 167, 171, 176, 179, 184, 184, 188, 192,\n   199, 204, 209, 212, 218, 221, 225, 230, 236, 242, 245, 247, 248,\n   252, 258, 262, 269, 275, 287, 293, 302, 304, 310, 314, 319, 321,\n   328, 333, 338, 344, 350, 355, 358, 358, 358, 361, 365, 368, 377,\n   381, 387, 389, 396, 398, 400, 409, 413, 419, 425, 433, 438, 438,\n   438, 454, 463, 470, 471, 478, 481, 490, 494, 499, 506, 515, 519,\n   523, 525, 531, 535, 543, 546, 551, 559, 559, 563, 572, 577, 582,\n   588, 591, 594, 597, 602, 606,\n};\n/* aKWCode[i] is the parser symbol code for the i-th keyword */\nstatic const unsigned char aKWCode[136] = {\n  TK_REINDEX,    TK_INDEXED,    TK_INDEX,      TK_DESC,       TK_ESCAPE,     \n  TK_EACH,       TK_CHECK,      TK_KEY,        TK_BEFORE,     TK_FOREIGN,    \n  TK_FOR,        TK_IGNORE,     TK_LIKE_KW,    TK_EXPLAIN,    TK_INSTEAD,    \n  TK_ADD,        TK_DATABASE,   TK_AS,         TK_SELECT,     TK_TABLE,      \n  TK_JOIN_KW,    TK_THEN,       TK_END,        TK_DEFERRABLE, TK_ELSE,       \n  TK_EXCEPT,     TK_TRANSACTION,TK_ACTION,     TK_ON,         TK_JOIN_KW,    \n  TK_ALTER,      TK_RAISE,      TK_EXCLUSIVE,  TK_EXISTS,     TK_SAVEPOINT,  \n  TK_INTERSECT,  TK_TRIGGER,    TK_REFERENCES, TK_CONSTRAINT, TK_INTO,       \n  TK_OFFSET,     TK_OF,         TK_SET,        TK_TEMP,       TK_TEMP,       \n  TK_OR,         TK_UNIQUE,     TK_QUERY,      TK_WITHOUT,    TK_WITH,       \n  TK_JOIN_KW,    TK_RELEASE,    TK_ATTACH,     TK_HAVING,     TK_GROUP,      \n  TK_UPDATE,     TK_BEGIN,      TK_JOIN_KW,    TK_RANGE,      TK_BETWEEN,    \n  TK_NOTHING,    TK_LIKE_KW,    TK_BY,         TK_CASCADE,    TK_ASC,        \n  TK_DELETE,     TK_CASE,       TK_COLLATE,    TK_CREATE,     TK_CTIME_KW,   \n  TK_DETACH,     TK_IMMEDIATE,  TK_JOIN,       TK_INSERT,     TK_LIKE_KW,    \n  TK_MATCH,      TK_PLAN,       TK_ANALYZE,    TK_PRAGMA,     TK_ABORT,      \n  TK_VALUES,     TK_VIRTUAL,    TK_LIMIT,      TK_WHEN,       TK_NOTNULL,    \n  TK_NOT,        TK_NO,         TK_NULL,       TK_WHERE,      TK_RECURSIVE,  \n  TK_AFTER,      TK_RENAME,     TK_AND,        TK_DEFAULT,    TK_AUTOINCR,   \n  TK_TO,         TK_IN,         TK_CAST,       TK_COLUMNKW,   TK_COMMIT,     \n  TK_CONFLICT,   TK_JOIN_KW,    TK_CTIME_KW,   TK_CTIME_KW,   TK_CURRENT,    \n  TK_PARTITION,  TK_DEFERRED,   TK_DISTINCT,   TK_IS,         TK_DROP,       \n  TK_PRECEDING,  TK_FAIL,       TK_FILTER,     TK_REPLACE,    TK_FOLLOWING,  \n  TK_FROM,       TK_JOIN_KW,    TK_IF,         TK_ISNULL,     TK_ORDER,      \n  TK_RESTRICT,   TK_OVER,       TK_JOIN_KW,    TK_ROLLBACK,   TK_ROWS,       \n  TK_ROW,        TK_UNBOUNDED,  TK_UNION,      TK_USING,      TK_VACUUM,     \n  TK_VIEW,       TK_WINDOW,     TK_DO,         TK_INITIALLY,  TK_ALL,        \n  TK_PRIMARY,    \n};\n/* Check to see if z[0..n-1] is a keyword. If it is, write the\n** parser symbol code for that keyword into *pType.  Always\n** return the integer n (the length of the token). */\nstatic int keywordCode(const char *z, int n, int *pType){\n  int i, j;\n  const char *zKW;\n  if( n>=2 ){\n    i = ((charMap(z[0])*4) ^ (charMap(z[n-1])*3) ^ n) % 127;\n    for(i=((int)aKWHash[i])-1; i>=0; i=((int)aKWNext[i])-1){\n      if( aKWLen[i]!=n ) continue;\n      j = 0;\n      zKW = &zKWText[aKWOffset[i]];\n#ifdef SQLITE_ASCII\n      while( j<n && (z[j]&~0x20)==zKW[j] ){ j++; }\n#endif\n#ifdef SQLITE_EBCDIC\n      while( j<n && toupper(z[j])==zKW[j] ){ j++; }\n#endif\n      if( j<n ) continue;\n      testcase( i==0 ); /* REINDEX */\n      testcase( i==1 ); /* INDEXED */\n      testcase( i==2 ); /* INDEX */\n      testcase( i==3 ); /* DESC */\n      testcase( i==4 ); /* ESCAPE */\n      testcase( i==5 ); /* EACH */\n      testcase( i==6 ); /* CHECK */\n      testcase( i==7 ); /* KEY */\n      testcase( i==8 ); /* BEFORE */\n      testcase( i==9 ); /* FOREIGN */\n      testcase( i==10 ); /* FOR */\n      testcase( i==11 ); /* IGNORE */\n      testcase( i==12 ); /* REGEXP */\n      testcase( i==13 ); /* EXPLAIN */\n      testcase( i==14 ); /* INSTEAD */\n      testcase( i==15 ); /* ADD */\n      testcase( i==16 ); /* DATABASE */\n      testcase( i==17 ); /* AS */\n      testcase( i==18 ); /* SELECT */\n      testcase( i==19 ); /* TABLE */\n      testcase( i==20 ); /* LEFT */\n      testcase( i==21 ); /* THEN */\n      testcase( i==22 ); /* END */\n      testcase( i==23 ); /* DEFERRABLE */\n      testcase( i==24 ); /* ELSE */\n      testcase( i==25 ); /* EXCEPT */\n      testcase( i==26 ); /* TRANSACTION */\n      testcase( i==27 ); /* ACTION */\n      testcase( i==28 ); /* ON */\n      testcase( i==29 ); /* NATURAL */\n      testcase( i==30 ); /* ALTER */\n      testcase( i==31 ); /* RAISE */\n      testcase( i==32 ); /* EXCLUSIVE */\n      testcase( i==33 ); /* EXISTS */\n      testcase( i==34 ); /* SAVEPOINT */\n      testcase( i==35 ); /* INTERSECT */\n      testcase( i==36 ); /* TRIGGER */\n      testcase( i==37 ); /* REFERENCES */\n      testcase( i==38 ); /* CONSTRAINT */\n      testcase( i==39 ); /* INTO */\n      testcase( i==40 ); /* OFFSET */\n      testcase( i==41 ); /* OF */\n      testcase( i==42 ); /* SET */\n      testcase( i==43 ); /* TEMPORARY */\n      testcase( i==44 ); /* TEMP */\n      testcase( i==45 ); /* OR */\n      testcase( i==46 ); /* UNIQUE */\n      testcase( i==47 ); /* QUERY */\n      testcase( i==48 ); /* WITHOUT */\n      testcase( i==49 ); /* WITH */\n      testcase( i==50 ); /* OUTER */\n      testcase( i==51 ); /* RELEASE */\n      testcase( i==52 ); /* ATTACH */\n      testcase( i==53 ); /* HAVING */\n      testcase( i==54 ); /* GROUP */\n      testcase( i==55 ); /* UPDATE */\n      testcase( i==56 ); /* BEGIN */\n      testcase( i==57 ); /* INNER */\n      testcase( i==58 ); /* RANGE */\n      testcase( i==59 ); /* BETWEEN */\n      testcase( i==60 ); /* NOTHING */\n      testcase( i==61 ); /* GLOB */\n      testcase( i==62 ); /* BY */\n      testcase( i==63 ); /* CASCADE */\n      testcase( i==64 ); /* ASC */\n      testcase( i==65 ); /* DELETE */\n      testcase( i==66 ); /* CASE */\n      testcase( i==67 ); /* COLLATE */\n      testcase( i==68 ); /* CREATE */\n      testcase( i==69 ); /* CURRENT_DATE */\n      testcase( i==70 ); /* DETACH */\n      testcase( i==71 ); /* IMMEDIATE */\n      testcase( i==72 ); /* JOIN */\n      testcase( i==73 ); /* INSERT */\n      testcase( i==74 ); /* LIKE */\n      testcase( i==75 ); /* MATCH */\n      testcase( i==76 ); /* PLAN */\n      testcase( i==77 ); /* ANALYZE */\n      testcase( i==78 ); /* PRAGMA */\n      testcase( i==79 ); /* ABORT */\n      testcase( i==80 ); /* VALUES */\n      testcase( i==81 ); /* VIRTUAL */\n      testcase( i==82 ); /* LIMIT */\n      testcase( i==83 ); /* WHEN */\n      testcase( i==84 ); /* NOTNULL */\n      testcase( i==85 ); /* NOT */\n      testcase( i==86 ); /* NO */\n      testcase( i==87 ); /* NULL */\n      testcase( i==88 ); /* WHERE */\n      testcase( i==89 ); /* RECURSIVE */\n      testcase( i==90 ); /* AFTER */\n      testcase( i==91 ); /* RENAME */\n      testcase( i==92 ); /* AND */\n      testcase( i==93 ); /* DEFAULT */\n      testcase( i==94 ); /* AUTOINCREMENT */\n      testcase( i==95 ); /* TO */\n      testcase( i==96 ); /* IN */\n      testcase( i==97 ); /* CAST */\n      testcase( i==98 ); /* COLUMN */\n      testcase( i==99 ); /* COMMIT */\n      testcase( i==100 ); /* CONFLICT */\n      testcase( i==101 ); /* CROSS */\n      testcase( i==102 ); /* CURRENT_TIMESTAMP */\n      testcase( i==103 ); /* CURRENT_TIME */\n      testcase( i==104 ); /* CURRENT */\n      testcase( i==105 ); /* PARTITION */\n      testcase( i==106 ); /* DEFERRED */\n      testcase( i==107 ); /* DISTINCT */\n      testcase( i==108 ); /* IS */\n      testcase( i==109 ); /* DROP */\n      testcase( i==110 ); /* PRECEDING */\n      testcase( i==111 ); /* FAIL */\n      testcase( i==112 ); /* FILTER */\n      testcase( i==113 ); /* REPLACE */\n      testcase( i==114 ); /* FOLLOWING */\n      testcase( i==115 ); /* FROM */\n      testcase( i==116 ); /* FULL */\n      testcase( i==117 ); /* IF */\n      testcase( i==118 ); /* ISNULL */\n      testcase( i==119 ); /* ORDER */\n      testcase( i==120 ); /* RESTRICT */\n      testcase( i==121 ); /* OVER */\n      testcase( i==122 ); /* RIGHT */\n      testcase( i==123 ); /* ROLLBACK */\n      testcase( i==124 ); /* ROWS */\n      testcase( i==125 ); /* ROW */\n      testcase( i==126 ); /* UNBOUNDED */\n      testcase( i==127 ); /* UNION */\n      testcase( i==128 ); /* USING */\n      testcase( i==129 ); /* VACUUM */\n      testcase( i==130 ); /* VIEW */\n      testcase( i==131 ); /* WINDOW */\n      testcase( i==132 ); /* DO */\n      testcase( i==133 ); /* INITIALLY */\n      testcase( i==134 ); /* ALL */\n      testcase( i==135 ); /* PRIMARY */\n      *pType = aKWCode[i];\n      break;\n    }\n  }\n  return n;\n}\nSQLITE_PRIVATE int sqlite3KeywordCode(const unsigned char *z, int n){\n  int id = TK_ID;\n  keywordCode((char*)z, n, &id);\n  return id;\n}\n#define SQLITE_N_KEYWORD 136\nSQLITE_API int sqlite3_keyword_name(int i,const char **pzName,int *pnName){\n  if( i<0 || i>=SQLITE_N_KEYWORD ) return SQLITE_ERROR;\n  *pzName = zKWText + aKWOffset[i];\n  *pnName = aKWLen[i];\n  return SQLITE_OK;\n}\nSQLITE_API int sqlite3_keyword_count(void){ return SQLITE_N_KEYWORD; }\nSQLITE_API int sqlite3_keyword_check(const char *zName, int nName){\n  return TK_ID!=sqlite3KeywordCode((const u8*)zName, nName);\n}\n\n/************** End of keywordhash.h *****************************************/\n/************** Continuing where we left off in tokenize.c *******************/\n\n\n/*\n** If X is a character that can be used in an identifier then\n** IdChar(X) will be true.  Otherwise it is false.\n**\n** For ASCII, any character with the high-order bit set is\n** allowed in an identifier.  For 7-bit characters, \n** sqlite3IsIdChar[X] must be 1.\n**\n** For EBCDIC, the rules are more complex but have the same\n** end result.\n**\n** Ticket #1066.  the SQL standard does not allow '$' in the\n** middle of identifiers.  But many SQL implementations do. \n** SQLite will allow '$' in identifiers for compatibility.\n** But the feature is undocumented.\n*/\n#ifdef SQLITE_ASCII\n#define IdChar(C)  ((sqlite3CtypeMap[(unsigned char)C]&0x46)!=0)\n#endif\n#ifdef SQLITE_EBCDIC\nSQLITE_PRIVATE const char sqlite3IsEbcdicIdChar[] = {\n/* x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 xA xB xC xD xE xF */\n    0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0,  /* 4x */\n    0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 0, 0, 0,  /* 5x */\n    0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 0, 0,  /* 6x */\n    0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0,  /* 7x */\n    0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 0,  /* 8x */\n    0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 0, 1, 0,  /* 9x */\n    1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0,  /* Ax */\n    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,  /* Bx */\n    0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1,  /* Cx */\n    0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1,  /* Dx */\n    0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1,  /* Ex */\n    1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 0,  /* Fx */\n};\n#define IdChar(C)  (((c=C)>=0x42 && sqlite3IsEbcdicIdChar[c-0x40]))\n#endif\n\n/* Make the IdChar function accessible from ctime.c and alter.c */\nSQLITE_PRIVATE int sqlite3IsIdChar(u8 c){ return IdChar(c); }\n\n#ifndef SQLITE_OMIT_WINDOWFUNC\n/*\n** Return the id of the next token in string (*pz). Before returning, set\n** (*pz) to point to the byte following the parsed token.\n*/\nstatic int getToken(const unsigned char **pz){\n  const unsigned char *z = *pz;\n  int t;                          /* Token type to return */\n  do {\n    z += sqlite3GetToken(z, &t);\n  }while( t==TK_SPACE );\n  if( t==TK_ID \n   || t==TK_STRING \n   || t==TK_JOIN_KW \n   || t==TK_WINDOW \n   || t==TK_OVER \n   || sqlite3ParserFallback(t)==TK_ID \n  ){\n    t = TK_ID;\n  }\n  *pz = z;\n  return t;\n}\n\n/*\n** The following three functions are called immediately after the tokenizer\n** reads the keywords WINDOW, OVER and FILTER, respectively, to determine\n** whether the token should be treated as a keyword or an SQL identifier.\n** This cannot be handled by the usual lemon %fallback method, due to\n** the ambiguity in some constructions. e.g.\n**\n**   SELECT sum(x) OVER ...\n**\n** In the above, \"OVER\" might be a keyword, or it might be an alias for the \n** sum(x) expression. If a \"%fallback ID OVER\" directive were added to \n** grammar, then SQLite would always treat \"OVER\" as an alias, making it\n** impossible to call a window-function without a FILTER clause.\n**\n** WINDOW is treated as a keyword if:\n**\n**   * the following token is an identifier, or a keyword that can fallback\n**     to being an identifier, and\n**   * the token after than one is TK_AS.\n**\n** OVER is a keyword if:\n**\n**   * the previous token was TK_RP, and\n**   * the next token is either TK_LP or an identifier.\n**\n** FILTER is a keyword if:\n**\n**   * the previous token was TK_RP, and\n**   * the next token is TK_LP.\n*/\nstatic int analyzeWindowKeyword(const unsigned char *z){\n  int t;\n  t = getToken(&z);\n  if( t!=TK_ID ) return TK_ID;\n  t = getToken(&z);\n  if( t!=TK_AS ) return TK_ID;\n  return TK_WINDOW;\n}\nstatic int analyzeOverKeyword(const unsigned char *z, int lastToken){\n  if( lastToken==TK_RP ){\n    int t = getToken(&z);\n    if( t==TK_LP || t==TK_ID ) return TK_OVER;\n  }\n  return TK_ID;\n}\nstatic int analyzeFilterKeyword(const unsigned char *z, int lastToken){\n  if( lastToken==TK_RP && getToken(&z)==TK_LP ){\n    return TK_FILTER;\n  }\n  return TK_ID;\n}\n#endif /* SQLITE_OMIT_WINDOWFUNC */\n\n/*\n** Return the length (in bytes) of the token that begins at z[0]. \n** Store the token type in *tokenType before returning.\n*/\nSQLITE_PRIVATE int sqlite3GetToken(const unsigned char *z, int *tokenType){\n  int i, c;\n  switch( aiClass[*z] ){  /* Switch on the character-class of the first byte\n                          ** of the token. See the comment on the CC_ defines\n                          ** above. */\n    case CC_SPACE: {\n      testcase( z[0]==' ' );\n      testcase( z[0]=='\\t' );\n      testcase( z[0]=='\\n' );\n      testcase( z[0]=='\\f' );\n      testcase( z[0]=='\\r' );\n      for(i=1; sqlite3Isspace(z[i]); i++){}\n      *tokenType = TK_SPACE;\n      return i;\n    }\n    case CC_MINUS: {\n      if( z[1]=='-' ){\n        for(i=2; (c=z[i])!=0 && c!='\\n'; i++){}\n        *tokenType = TK_SPACE;   /* IMP: R-22934-25134 */\n        return i;\n      }\n      *tokenType = TK_MINUS;\n      return 1;\n    }\n    case CC_LP: {\n      *tokenType = TK_LP;\n      return 1;\n    }\n    case CC_RP: {\n      *tokenType = TK_RP;\n      return 1;\n    }\n    case CC_SEMI: {\n      *tokenType = TK_SEMI;\n      return 1;\n    }\n    case CC_PLUS: {\n      *tokenType = TK_PLUS;\n      return 1;\n    }\n    case CC_STAR: {\n      *tokenType = TK_STAR;\n      return 1;\n    }\n    case CC_SLASH: {\n      if( z[1]!='*' || z[2]==0 ){\n        *tokenType = TK_SLASH;\n        return 1;\n      }\n      for(i=3, c=z[2]; (c!='*' || z[i]!='/') && (c=z[i])!=0; i++){}\n      if( c ) i++;\n      *tokenType = TK_SPACE;   /* IMP: R-22934-25134 */\n      return i;\n    }\n    case CC_PERCENT: {\n      *tokenType = TK_REM;\n      return 1;\n    }\n    case CC_EQ: {\n      *tokenType = TK_EQ;\n      return 1 + (z[1]=='=');\n    }\n    case CC_LT: {\n      if( (c=z[1])=='=' ){\n        *tokenType = TK_LE;\n        return 2;\n      }else if( c=='>' ){\n        *tokenType = TK_NE;\n        return 2;\n      }else if( c=='<' ){\n        *tokenType = TK_LSHIFT;\n        return 2;\n      }else{\n        *tokenType = TK_LT;\n        return 1;\n      }\n    }\n    case CC_GT: {\n      if( (c=z[1])=='=' ){\n        *tokenType = TK_GE;\n        return 2;\n      }else if( c=='>' ){\n        *tokenType = TK_RSHIFT;\n        return 2;\n      }else{\n        *tokenType = TK_GT;\n        return 1;\n      }\n    }\n    case CC_BANG: {\n      if( z[1]!='=' ){\n        *tokenType = TK_ILLEGAL;\n        return 1;\n      }else{\n        *tokenType = TK_NE;\n        return 2;\n      }\n    }\n    case CC_PIPE: {\n      if( z[1]!='|' ){\n        *tokenType = TK_BITOR;\n        return 1;\n      }else{\n        *tokenType = TK_CONCAT;\n        return 2;\n      }\n    }\n    case CC_COMMA: {\n      *tokenType = TK_COMMA;\n      return 1;\n    }\n    case CC_AND: {\n      *tokenType = TK_BITAND;\n      return 1;\n    }\n    case CC_TILDA: {\n      *tokenType = TK_BITNOT;\n      return 1;\n    }\n    case CC_QUOTE: {\n      int delim = z[0];\n      testcase( delim=='`' );\n      testcase( delim=='\\'' );\n      testcase( delim=='\"' );\n      for(i=1; (c=z[i])!=0; i++){\n        if( c==delim ){\n          if( z[i+1]==delim ){\n            i++;\n          }else{\n            break;\n          }\n        }\n      }\n      if( c=='\\'' ){\n        *tokenType = TK_STRING;\n        return i+1;\n      }else if( c!=0 ){\n        *tokenType = TK_ID;\n        return i+1;\n      }else{\n        *tokenType = TK_ILLEGAL;\n        return i;\n      }\n    }\n    case CC_DOT: {\n#ifndef SQLITE_OMIT_FLOATING_POINT\n      if( !sqlite3Isdigit(z[1]) )\n#endif\n      {\n        *tokenType = TK_DOT;\n        return 1;\n      }\n      /* If the next character is a digit, this is a floating point\n      ** number that begins with \".\".  Fall thru into the next case */\n    }\n    case CC_DIGIT: {\n      testcase( z[0]=='0' );  testcase( z[0]=='1' );  testcase( z[0]=='2' );\n      testcase( z[0]=='3' );  testcase( z[0]=='4' );  testcase( z[0]=='5' );\n      testcase( z[0]=='6' );  testcase( z[0]=='7' );  testcase( z[0]=='8' );\n      testcase( z[0]=='9' );\n      *tokenType = TK_INTEGER;\n#ifndef SQLITE_OMIT_HEX_INTEGER\n      if( z[0]=='0' && (z[1]=='x' || z[1]=='X') && sqlite3Isxdigit(z[2]) ){\n        for(i=3; sqlite3Isxdigit(z[i]); i++){}\n        return i;\n      }\n#endif\n      for(i=0; sqlite3Isdigit(z[i]); i++){}\n#ifndef SQLITE_OMIT_FLOATING_POINT\n      if( z[i]=='.' ){\n        i++;\n        while( sqlite3Isdigit(z[i]) ){ i++; }\n        *tokenType = TK_FLOAT;\n      }\n      if( (z[i]=='e' || z[i]=='E') &&\n           ( sqlite3Isdigit(z[i+1]) \n            || ((z[i+1]=='+' || z[i+1]=='-') && sqlite3Isdigit(z[i+2]))\n           )\n      ){\n        i += 2;\n        while( sqlite3Isdigit(z[i]) ){ i++; }\n        *tokenType = TK_FLOAT;\n      }\n#endif\n      while( IdChar(z[i]) ){\n        *tokenType = TK_ILLEGAL;\n        i++;\n      }\n      return i;\n    }\n    case CC_QUOTE2: {\n      for(i=1, c=z[0]; c!=']' && (c=z[i])!=0; i++){}\n      *tokenType = c==']' ? TK_ID : TK_ILLEGAL;\n      return i;\n    }\n    case CC_VARNUM: {\n      *tokenType = TK_VARIABLE;\n      for(i=1; sqlite3Isdigit(z[i]); i++){}\n      return i;\n    }\n    case CC_DOLLAR:\n    case CC_VARALPHA: {\n      int n = 0;\n      testcase( z[0]=='$' );  testcase( z[0]=='@' );\n      testcase( z[0]==':' );  testcase( z[0]=='#' );\n      *tokenType = TK_VARIABLE;\n      for(i=1; (c=z[i])!=0; i++){\n        if( IdChar(c) ){\n          n++;\n#ifndef SQLITE_OMIT_TCL_VARIABLE\n        }else if( c=='(' && n>0 ){\n          do{\n            i++;\n          }while( (c=z[i])!=0 && !sqlite3Isspace(c) && c!=')' );\n          if( c==')' ){\n            i++;\n          }else{\n            *tokenType = TK_ILLEGAL;\n          }\n          break;\n        }else if( c==':' && z[i+1]==':' ){\n          i++;\n#endif\n        }else{\n          break;\n        }\n      }\n      if( n==0 ) *tokenType = TK_ILLEGAL;\n      return i;\n    }\n    case CC_KYWD: {\n      for(i=1; aiClass[z[i]]<=CC_KYWD; i++){}\n      if( IdChar(z[i]) ){\n        /* This token started out using characters that can appear in keywords,\n        ** but z[i] is a character not allowed within keywords, so this must\n        ** be an identifier instead */\n        i++;\n        break;\n      }\n      *tokenType = TK_ID;\n      return keywordCode((char*)z, i, tokenType);\n    }\n    case CC_X: {\n#ifndef SQLITE_OMIT_BLOB_LITERAL\n      testcase( z[0]=='x' ); testcase( z[0]=='X' );\n      if( z[1]=='\\'' ){\n        *tokenType = TK_BLOB;\n        for(i=2; sqlite3Isxdigit(z[i]); i++){}\n        if( z[i]!='\\'' || i%2 ){\n          *tokenType = TK_ILLEGAL;\n          while( z[i] && z[i]!='\\'' ){ i++; }\n        }\n        if( z[i] ) i++;\n        return i;\n      }\n#endif\n      /* If it is not a BLOB literal, then it must be an ID, since no\n      ** SQL keywords start with the letter 'x'.  Fall through */\n    }\n    case CC_ID: {\n      i = 1;\n      break;\n    }\n    case CC_NUL: {\n      *tokenType = TK_ILLEGAL;\n      return 0;\n    }\n    default: {\n      *tokenType = TK_ILLEGAL;\n      return 1;\n    }\n  }\n  while( IdChar(z[i]) ){ i++; }\n  *tokenType = TK_ID;\n  return i;\n}\n\n/*\n** Run the parser on the given SQL string.  The parser structure is\n** passed in.  An SQLITE_ status code is returned.  If an error occurs\n** then an and attempt is made to write an error message into \n** memory obtained from sqlite3_malloc() and to make *pzErrMsg point to that\n** error message.\n*/\nSQLITE_PRIVATE int sqlite3RunParser(Parse *pParse, const char *zSql, char **pzErrMsg){\n  int nErr = 0;                   /* Number of errors encountered */\n  void *pEngine;                  /* The LEMON-generated LALR(1) parser */\n  int n = 0;                      /* Length of the next token token */\n  int tokenType;                  /* type of the next token */\n  int lastTokenParsed = -1;       /* type of the previous token */\n  sqlite3 *db = pParse->db;       /* The database connection */\n  int mxSqlLen;                   /* Max length of an SQL string */\n#ifdef sqlite3Parser_ENGINEALWAYSONSTACK\n  yyParser sEngine;    /* Space to hold the Lemon-generated Parser object */\n#endif\n\n  assert( zSql!=0 );\n  mxSqlLen = db->aLimit[SQLITE_LIMIT_SQL_LENGTH];\n  if( db->nVdbeActive==0 ){\n    db->u1.isInterrupted = 0;\n  }\n  pParse->rc = SQLITE_OK;\n  pParse->zTail = zSql;\n  assert( pzErrMsg!=0 );\n#ifdef SQLITE_DEBUG\n  if( db->flags & SQLITE_ParserTrace ){\n    printf(\"parser: [[[%s]]]\\n\", zSql);\n    sqlite3ParserTrace(stdout, \"parser: \");\n  }else{\n    sqlite3ParserTrace(0, 0);\n  }\n#endif\n#ifdef sqlite3Parser_ENGINEALWAYSONSTACK\n  pEngine = &sEngine;\n  sqlite3ParserInit(pEngine, pParse);\n#else\n  pEngine = sqlite3ParserAlloc(sqlite3Malloc, pParse);\n  if( pEngine==0 ){\n    sqlite3OomFault(db);\n    return SQLITE_NOMEM_BKPT;\n  }\n#endif\n  assert( pParse->pNewTable==0 );\n  assert( pParse->pNewTrigger==0 );\n  assert( pParse->nVar==0 );\n  assert( pParse->pVList==0 );\n  while( 1 ){\n    n = sqlite3GetToken((u8*)zSql, &tokenType);\n    mxSqlLen -= n;\n    if( mxSqlLen<0 ){\n      pParse->rc = SQLITE_TOOBIG;\n      break;\n    }\n#ifndef SQLITE_OMIT_WINDOWFUNC\n    if( tokenType>=TK_WINDOW ){\n      assert( tokenType==TK_SPACE || tokenType==TK_OVER || tokenType==TK_FILTER\n           || tokenType==TK_ILLEGAL || tokenType==TK_WINDOW \n      );\n#else\n    if( tokenType>=TK_SPACE ){\n      assert( tokenType==TK_SPACE || tokenType==TK_ILLEGAL );\n#endif /* SQLITE_OMIT_WINDOWFUNC */\n      if( (db->u1.isInterrupted || db->suspended) && !db->unimpeded ){\n        pParse->rc = SQLITE_INTERRUPT;\n        break;\n      }\n      if( tokenType==TK_SPACE ){\n        zSql += n;\n        continue;\n      }\n      if( zSql[0]==0 ){\n        /* Upon reaching the end of input, call the parser two more times\n        ** with tokens TK_SEMI and 0, in that order. */\n        if( lastTokenParsed==TK_SEMI ){\n          tokenType = 0;\n        }else if( lastTokenParsed==0 ){\n          break;\n        }else{\n          tokenType = TK_SEMI;\n        }\n        n = 0;\n#ifndef SQLITE_OMIT_WINDOWFUNC\n      }else if( tokenType==TK_WINDOW ){\n        assert( n==6 );\n        tokenType = analyzeWindowKeyword((const u8*)&zSql[6]);\n      }else if( tokenType==TK_OVER ){\n        assert( n==4 );\n        tokenType = analyzeOverKeyword((const u8*)&zSql[4], lastTokenParsed);\n      }else if( tokenType==TK_FILTER ){\n        assert( n==6 );\n        tokenType = analyzeFilterKeyword((const u8*)&zSql[6], lastTokenParsed);\n#endif /* SQLITE_OMIT_WINDOWFUNC */\n      }else{\n        sqlite3ErrorMsg(pParse, \"unrecognized token: \\\"%.*s\\\"\", n, zSql);\n        break;\n      }\n    }\n    pParse->sLastToken.z = zSql;\n    pParse->sLastToken.n = n;\n    sqlite3Parser(pEngine, tokenType, pParse->sLastToken);\n    lastTokenParsed = tokenType;\n    zSql += n;\n    if( pParse->rc!=SQLITE_OK || db->mallocFailed ) break;\n  }\n  assert( nErr==0 );\n#ifdef YYTRACKMAXSTACKDEPTH\n  sqlite3_mutex_enter(sqlite3MallocMutex());\n  sqlite3StatusHighwater(SQLITE_STATUS_PARSER_STACK,\n      sqlite3ParserStackPeak(pEngine)\n  );\n  sqlite3_mutex_leave(sqlite3MallocMutex());\n#endif /* YYDEBUG */\n#ifdef sqlite3Parser_ENGINEALWAYSONSTACK\n  sqlite3ParserFinalize(pEngine);\n#else\n  sqlite3ParserFree(pEngine, sqlite3_free);\n#endif\n  if( db->mallocFailed ){\n    pParse->rc = SQLITE_NOMEM_BKPT;\n  }\n  if( pParse->rc!=SQLITE_OK && pParse->rc!=SQLITE_DONE && pParse->zErrMsg==0 ){\n    pParse->zErrMsg = sqlite3MPrintf(db, \"%s\", sqlite3ErrStr(pParse->rc));\n  }\n  assert( pzErrMsg!=0 );\n  if( pParse->zErrMsg ){\n    *pzErrMsg = pParse->zErrMsg;\n    sqlite3_log(pParse->rc, \"%s in \\\"%s\\\"\", \n                *pzErrMsg, pParse->zTail);\n    pParse->zErrMsg = 0;\n    nErr++;\n  }\n  pParse->zTail = zSql;\n  if( pParse->pVdbe && pParse->nErr>0 && pParse->nested==0 ){\n    sqlite3VdbeDelete(pParse->pVdbe);\n    pParse->pVdbe = 0;\n  }\n#ifndef SQLITE_OMIT_SHARED_CACHE\n  if( pParse->nested==0 ){\n    sqlite3DbFree(db, pParse->aTableLock);\n    pParse->aTableLock = 0;\n    pParse->nTableLock = 0;\n  }\n#endif\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n  sqlite3_free(pParse->apVtabLock);\n#endif\n\n  if( !IN_SPECIAL_PARSE ){\n    /* If the pParse->declareVtab flag is set, do not delete any table \n    ** structure built up in pParse->pNewTable. The calling code (see vtab.c)\n    ** will take responsibility for freeing the Table structure.\n    */\n    sqlite3DeleteTable(db, pParse->pNewTable);\n  }\n  if( !IN_RENAME_OBJECT ){\n    sqlite3DeleteTrigger(db, pParse->pNewTrigger);\n  }\n\n  if( pParse->pWithToFree ) sqlite3WithDelete(db, pParse->pWithToFree);\n  sqlite3DbFree(db, pParse->pVList);\n  while( pParse->pAinc ){\n    AutoincInfo *p = pParse->pAinc;\n    pParse->pAinc = p->pNext;\n    sqlite3DbFreeNN(db, p);\n  }\n  while( pParse->pZombieTab ){\n    Table *p = pParse->pZombieTab;\n    pParse->pZombieTab = p->pNextZombie;\n    sqlite3DeleteTable(db, p);\n  }\n  assert( nErr==0 || pParse->rc!=SQLITE_OK );\n  return nErr;\n}\n\n\n#ifdef SQLITE_ENABLE_NORMALIZE\n/*\n** Insert a single space character into pStr if the current string\n** ends with an identifier\n*/\nstatic void addSpaceSeparator(sqlite3_str *pStr){\n  if( pStr->nChar && sqlite3IsIdChar(pStr->zText[pStr->nChar-1]) ){\n    sqlite3_str_append(pStr, \" \", 1);\n  }\n}\n\n/*\n** Compute a normalization of the SQL given by zSql[0..nSql-1].  Return\n** the normalization in space obtained from sqlite3DbMalloc().  Or return\n** NULL if anything goes wrong or if zSql is NULL.\n*/\nSQLITE_PRIVATE char *sqlite3Normalize(\n  Vdbe *pVdbe,       /* VM being reprepared */\n  const char *zSql   /* The original SQL string */\n){\n  sqlite3 *db;       /* The database connection */\n  int i;             /* Next unread byte of zSql[] */\n  int n;             /* length of current token */\n  int tokenType;     /* type of current token */\n  int prevType = 0;  /* Previous non-whitespace token */\n  int nParen;        /* Number of nested levels of parentheses */\n  int iStartIN;      /* Start of RHS of IN operator in z[] */\n  int nParenAtIN;    /* Value of nParent at start of RHS of IN operator */\n  int j;             /* Bytes of normalized SQL generated so far */\n  sqlite3_str *pStr; /* The normalized SQL string under construction */\n\n  db = sqlite3VdbeDb(pVdbe);\n  tokenType = -1;\n  nParen = iStartIN = nParenAtIN = 0;\n  pStr = sqlite3_str_new(db);\n  assert( pStr!=0 );  /* sqlite3_str_new() never returns NULL */\n  for(i=0; zSql[i] && pStr->accError==0; i+=n){\n    if( tokenType!=TK_SPACE ){\n      prevType = tokenType;\n    }\n    n = sqlite3GetToken((unsigned char*)zSql+i, &tokenType);\n    if( NEVER(n<=0) ) break;\n    switch( tokenType ){\n      case TK_SPACE: {\n        break;\n      }\n      case TK_NULL: {\n        if( prevType==TK_IS || prevType==TK_NOT ){\n          sqlite3_str_append(pStr, \" NULL\", 5);\n          break;\n        }\n        /* Fall through */\n      }\n      case TK_STRING:\n      case TK_INTEGER:\n      case TK_FLOAT:\n      case TK_VARIABLE:\n      case TK_BLOB: {\n        sqlite3_str_append(pStr, \"?\", 1);\n        break;\n      }\n      case TK_LP: {\n        nParen++;\n        if( prevType==TK_IN ){\n          iStartIN = pStr->nChar;\n          nParenAtIN = nParen;\n        }\n        sqlite3_str_append(pStr, \"(\", 1);\n        break;\n      }\n      case TK_RP: {\n        if( iStartIN>0 && nParen==nParenAtIN ){\n          assert( pStr->nChar>=iStartIN );\n          pStr->nChar = iStartIN+1;\n          sqlite3_str_append(pStr, \"?,?,?\", 5);\n          iStartIN = 0;\n        }\n        nParen--;\n        sqlite3_str_append(pStr, \")\", 1);\n        break;\n      }\n      case TK_ID: {\n        iStartIN = 0;\n        j = pStr->nChar;\n        if( sqlite3Isquote(zSql[i]) ){\n          char *zId = sqlite3DbStrNDup(db, zSql+i, n);\n          int nId;\n          int eType = 0;\n          if( zId==0 ) break;\n          sqlite3Dequote(zId);\n          if( zSql[i]=='\"' && sqlite3VdbeUsesDoubleQuotedString(pVdbe, zId) ){\n            sqlite3_str_append(pStr, \"?\", 1);\n            sqlite3DbFree(db, zId);\n            break;\n          }\n          nId = sqlite3Strlen30(zId);\n          if( sqlite3GetToken((u8*)zId, &eType)==nId && eType==TK_ID ){\n            addSpaceSeparator(pStr);\n            sqlite3_str_append(pStr, zId, nId);\n          }else{\n            sqlite3_str_appendf(pStr, \"\\\"%w\\\"\", zId);\n          }\n          sqlite3DbFree(db, zId);\n        }else{\n          addSpaceSeparator(pStr);\n          sqlite3_str_append(pStr, zSql+i, n);\n        }\n        while( j<pStr->nChar ){\n          pStr->zText[j] = sqlite3Tolower(pStr->zText[j]);\n          j++;\n        }\n        break;\n      }\n      case TK_SELECT: {\n        iStartIN = 0;\n        /* fall through */\n      }\n      default: {\n        if( sqlite3IsIdChar(zSql[i]) ) addSpaceSeparator(pStr);\n        j = pStr->nChar;\n        sqlite3_str_append(pStr, zSql+i, n);\n        while( j<pStr->nChar ){\n          pStr->zText[j] = sqlite3Toupper(pStr->zText[j]);\n          j++;\n        }\n        break;\n      }\n    }\n  }\n  if( tokenType!=TK_SEMI ) sqlite3_str_append(pStr, \";\", 1);\n  return sqlite3_str_finish(pStr);\n}\n#endif /* SQLITE_ENABLE_NORMALIZE */\n\n/************** End of tokenize.c ********************************************/\n/************** Begin file complete.c ****************************************/\n/*\n** 2001 September 15\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** An tokenizer for SQL\n**\n** This file contains C code that implements the sqlite3_complete() API.\n** This code used to be part of the tokenizer.c source file.  But by\n** separating it out, the code will be automatically omitted from\n** static links that do not use it.\n*/\n/* #include \"sqliteInt.h\" */\n#ifndef SQLITE_OMIT_COMPLETE\n\n/*\n** This is defined in tokenize.c.  We just have to import the definition.\n*/\n#ifndef SQLITE_AMALGAMATION\n#ifdef SQLITE_ASCII\n#define IdChar(C)  ((sqlite3CtypeMap[(unsigned char)C]&0x46)!=0)\n#endif\n#ifdef SQLITE_EBCDIC\nSQLITE_PRIVATE const char sqlite3IsEbcdicIdChar[];\n#define IdChar(C)  (((c=C)>=0x42 && sqlite3IsEbcdicIdChar[c-0x40]))\n#endif\n#endif /* SQLITE_AMALGAMATION */\n\n\n/*\n** Token types used by the sqlite3_complete() routine.  See the header\n** comments on that procedure for additional information.\n*/\n#define tkSEMI    0\n#define tkWS      1\n#define tkOTHER   2\n#ifndef SQLITE_OMIT_TRIGGER\n#define tkEXPLAIN 3\n#define tkCREATE  4\n#define tkTEMP    5\n#define tkTRIGGER 6\n#define tkEND     7\n#endif\n\n/*\n** Return TRUE if the given SQL string ends in a semicolon.\n**\n** Special handling is require for CREATE TRIGGER statements.\n** Whenever the CREATE TRIGGER keywords are seen, the statement\n** must end with \";END;\".\n**\n** This implementation uses a state machine with 8 states:\n**\n**   (0) INVALID   We have not yet seen a non-whitespace character.\n**\n**   (1) START     At the beginning or end of an SQL statement.  This routine\n**                 returns 1 if it ends in the START state and 0 if it ends\n**                 in any other state.\n**\n**   (2) NORMAL    We are in the middle of statement which ends with a single\n**                 semicolon.\n**\n**   (3) EXPLAIN   The keyword EXPLAIN has been seen at the beginning of \n**                 a statement.\n**\n**   (4) CREATE    The keyword CREATE has been seen at the beginning of a\n**                 statement, possibly preceded by EXPLAIN and/or followed by\n**                 TEMP or TEMPORARY\n**\n**   (5) TRIGGER   We are in the middle of a trigger definition that must be\n**                 ended by a semicolon, the keyword END, and another semicolon.\n**\n**   (6) SEMI      We've seen the first semicolon in the \";END;\" that occurs at\n**                 the end of a trigger definition.\n**\n**   (7) END       We've seen the \";END\" of the \";END;\" that occurs at the end\n**                 of a trigger definition.\n**\n** Transitions between states above are determined by tokens extracted\n** from the input.  The following tokens are significant:\n**\n**   (0) tkSEMI      A semicolon.\n**   (1) tkWS        Whitespace.\n**   (2) tkOTHER     Any other SQL token.\n**   (3) tkEXPLAIN   The \"explain\" keyword.\n**   (4) tkCREATE    The \"create\" keyword.\n**   (5) tkTEMP      The \"temp\" or \"temporary\" keyword.\n**   (6) tkTRIGGER   The \"trigger\" keyword.\n**   (7) tkEND       The \"end\" keyword.\n**\n** Whitespace never causes a state transition and is always ignored.\n** This means that a SQL string of all whitespace is invalid.\n**\n** If we compile with SQLITE_OMIT_TRIGGER, all of the computation needed\n** to recognize the end of a trigger can be omitted.  All we have to do\n** is look for a semicolon that is not part of an string or comment.\n*/\nSQLITE_API int sqlite3_complete(const char *zSql){\n  u8 state = 0;   /* Current state, using numbers defined in header comment */\n  u8 token;       /* Value of the next token */\n\n#ifndef SQLITE_OMIT_TRIGGER\n  /* A complex statement machine used to detect the end of a CREATE TRIGGER\n  ** statement.  This is the normal case.\n  */\n  static const u8 trans[8][8] = {\n                     /* Token:                                                */\n     /* State:       **  SEMI  WS  OTHER  EXPLAIN  CREATE  TEMP  TRIGGER  END */\n     /* 0 INVALID: */ {    1,  0,     2,       3,      4,    2,       2,   2, },\n     /* 1   START: */ {    1,  1,     2,       3,      4,    2,       2,   2, },\n     /* 2  NORMAL: */ {    1,  2,     2,       2,      2,    2,       2,   2, },\n     /* 3 EXPLAIN: */ {    1,  3,     3,       2,      4,    2,       2,   2, },\n     /* 4  CREATE: */ {    1,  4,     2,       2,      2,    4,       5,   2, },\n     /* 5 TRIGGER: */ {    6,  5,     5,       5,      5,    5,       5,   5, },\n     /* 6    SEMI: */ {    6,  6,     5,       5,      5,    5,       5,   7, },\n     /* 7     END: */ {    1,  7,     5,       5,      5,    5,       5,   5, },\n  };\n#else\n  /* If triggers are not supported by this compile then the statement machine\n  ** used to detect the end of a statement is much simpler\n  */\n  static const u8 trans[3][3] = {\n                     /* Token:           */\n     /* State:       **  SEMI  WS  OTHER */\n     /* 0 INVALID: */ {    1,  0,     2, },\n     /* 1   START: */ {    1,  1,     2, },\n     /* 2  NORMAL: */ {    1,  2,     2, },\n  };\n#endif /* SQLITE_OMIT_TRIGGER */\n\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( zSql==0 ){\n    (void)SQLITE_MISUSE_BKPT;\n    return 0;\n  }\n#endif\n\n  while( *zSql ){\n    switch( *zSql ){\n      case ';': {  /* A semicolon */\n        token = tkSEMI;\n        break;\n      }\n      case ' ':\n      case '\\r':\n      case '\\t':\n      case '\\n':\n      case '\\f': {  /* White space is ignored */\n        token = tkWS;\n        break;\n      }\n      case '/': {   /* C-style comments */\n        if( zSql[1]!='*' ){\n          token = tkOTHER;\n          break;\n        }\n        zSql += 2;\n        while( zSql[0] && (zSql[0]!='*' || zSql[1]!='/') ){ zSql++; }\n        if( zSql[0]==0 ) return 0;\n        zSql++;\n        token = tkWS;\n        break;\n      }\n      case '-': {   /* SQL-style comments from \"--\" to end of line */\n        if( zSql[1]!='-' ){\n          token = tkOTHER;\n          break;\n        }\n        while( *zSql && *zSql!='\\n' ){ zSql++; }\n        if( *zSql==0 ) return state==1;\n        token = tkWS;\n        break;\n      }\n      case '[': {   /* Microsoft-style identifiers in [...] */\n        zSql++;\n        while( *zSql && *zSql!=']' ){ zSql++; }\n        if( *zSql==0 ) return 0;\n        token = tkOTHER;\n        break;\n      }\n      case '`':     /* Grave-accent quoted symbols used by MySQL */\n      case '\"':     /* single- and double-quoted strings */\n      case '\\'': {\n        int c = *zSql;\n        zSql++;\n        while( *zSql && *zSql!=c ){ zSql++; }\n        if( *zSql==0 ) return 0;\n        token = tkOTHER;\n        break;\n      }\n      default: {\n#ifdef SQLITE_EBCDIC\n        unsigned char c;\n#endif\n        if( IdChar((u8)*zSql) ){\n          /* Keywords and unquoted identifiers */\n          int nId;\n          for(nId=1; IdChar(zSql[nId]); nId++){}\n#ifdef SQLITE_OMIT_TRIGGER\n          token = tkOTHER;\n#else\n          switch( *zSql ){\n            case 'c': case 'C': {\n              if( nId==6 && sqlite3StrNICmp(zSql, \"create\", 6)==0 ){\n                token = tkCREATE;\n              }else{\n                token = tkOTHER;\n              }\n              break;\n            }\n            case 't': case 'T': {\n              if( nId==7 && sqlite3StrNICmp(zSql, \"trigger\", 7)==0 ){\n                token = tkTRIGGER;\n              }else if( nId==4 && sqlite3StrNICmp(zSql, \"temp\", 4)==0 ){\n                token = tkTEMP;\n              }else if( nId==9 && sqlite3StrNICmp(zSql, \"temporary\", 9)==0 ){\n                token = tkTEMP;\n              }else{\n                token = tkOTHER;\n              }\n              break;\n            }\n            case 'e':  case 'E': {\n              if( nId==3 && sqlite3StrNICmp(zSql, \"end\", 3)==0 ){\n                token = tkEND;\n              }else\n#ifndef SQLITE_OMIT_EXPLAIN\n              if( nId==7 && sqlite3StrNICmp(zSql, \"explain\", 7)==0 ){\n                token = tkEXPLAIN;\n              }else\n#endif\n              {\n                token = tkOTHER;\n              }\n              break;\n            }\n            default: {\n              token = tkOTHER;\n              break;\n            }\n          }\n#endif /* SQLITE_OMIT_TRIGGER */\n          zSql += nId-1;\n        }else{\n          /* Operators and special symbols */\n          token = tkOTHER;\n        }\n        break;\n      }\n    }\n    state = trans[state][token];\n    zSql++;\n  }\n  return state==1;\n}\n\n#ifndef SQLITE_OMIT_UTF16\n/*\n** This routine is the same as the sqlite3_complete() routine described\n** above, except that the parameter is required to be UTF-16 encoded, not\n** UTF-8.\n*/\nSQLITE_API int sqlite3_complete16(const void *zSql){\n  sqlite3_value *pVal;\n  char const *zSql8;\n  int rc;\n\n#ifndef SQLITE_OMIT_AUTOINIT\n  rc = sqlite3_initialize();\n  if( rc ) return rc;\n#endif\n  pVal = sqlite3ValueNew(0);\n  sqlite3ValueSetStr(pVal, -1, zSql, SQLITE_UTF16NATIVE, SQLITE_STATIC);\n  zSql8 = sqlite3ValueText(pVal, SQLITE_UTF8);\n  if( zSql8 ){\n    rc = sqlite3_complete(zSql8);\n  }else{\n    rc = SQLITE_NOMEM_BKPT;\n  }\n  sqlite3ValueFree(pVal);\n  return rc & 0xff;\n}\n#endif /* SQLITE_OMIT_UTF16 */\n#endif /* SQLITE_OMIT_COMPLETE */\n\n/************** End of complete.c ********************************************/\n/************** Begin file main.c ********************************************/\n/*\n** 2001 September 15\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** Main file for the SQLite library.  The routines in this file\n** implement the programmer interface to the library.  Routines in\n** other files are for internal use by SQLite and should not be\n** accessed by users of the library.\n*/\n/* #include \"sqliteInt.h\" */\n\n#ifdef SQLITE_ENABLE_FTS3\n/************** Include fts3.h in the middle of main.c ***********************/\n/************** Begin file fts3.h ********************************************/\n/*\n** 2006 Oct 10\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n******************************************************************************\n**\n** This header file is used by programs that want to link against the\n** FTS3 library.  All it does is declare the sqlite3Fts3Init() interface.\n*/\n/* #include \"sqlite3.h\" */\n\n#if 0\nextern \"C\" {\n#endif  /* __cplusplus */\n\nSQLITE_PRIVATE int sqlite3Fts3Init(sqlite3 *db);\n\n#if 0\n}  /* extern \"C\" */\n#endif  /* __cplusplus */\n\n/************** End of fts3.h ************************************************/\n/************** Continuing where we left off in main.c ***********************/\n#endif\n#ifdef SQLITE_ENABLE_RTREE\n/************** Include rtree.h in the middle of main.c **********************/\n/************** Begin file rtree.h *******************************************/\n/*\n** 2008 May 26\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n******************************************************************************\n**\n** This header file is used by programs that want to link against the\n** RTREE library.  All it does is declare the sqlite3RtreeInit() interface.\n*/\n/* #include \"sqlite3.h\" */\n\n#ifdef SQLITE_OMIT_VIRTUALTABLE\n# undef SQLITE_ENABLE_RTREE\n#endif\n\n#if 0\nextern \"C\" {\n#endif  /* __cplusplus */\n\nSQLITE_PRIVATE int sqlite3RtreeInit(sqlite3 *db);\n\n#if 0\n}  /* extern \"C\" */\n#endif  /* __cplusplus */\n\n/************** End of rtree.h ***********************************************/\n/************** Continuing where we left off in main.c ***********************/\n#endif\n#if defined(SQLITE_ENABLE_ICU) || defined(SQLITE_ENABLE_ICU_COLLATIONS)\n/************** Include sqliteicu.h in the middle of main.c ******************/\n/************** Begin file sqliteicu.h ***************************************/\n/*\n** 2008 May 26\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n******************************************************************************\n**\n** This header file is used by programs that want to link against the\n** ICU extension.  All it does is declare the sqlite3IcuInit() interface.\n*/\n/* #include \"sqlite3.h\" */\n\n#if 0\nextern \"C\" {\n#endif  /* __cplusplus */\n\nSQLITE_PRIVATE int sqlite3IcuInit(sqlite3 *db);\n\n#if 0\n}  /* extern \"C\" */\n#endif  /* __cplusplus */\n\n\n/************** End of sqliteicu.h *******************************************/\n/************** Continuing where we left off in main.c ***********************/\n#endif\n#ifdef SQLITE_ENABLE_JSON1\nSQLITE_PRIVATE int sqlite3Json1Init(sqlite3*);\n#endif\n#ifdef SQLITE_ENABLE_STMTVTAB\nSQLITE_PRIVATE int sqlite3StmtVtabInit(sqlite3*);\n#endif\n#ifdef SQLITE_ENABLE_FTS5\nSQLITE_PRIVATE int sqlite3Fts5Init(sqlite3*);\n#endif\n\n#ifndef SQLITE_AMALGAMATION\n/* IMPLEMENTATION-OF: R-46656-45156 The sqlite3_version[] string constant\n** contains the text of SQLITE_VERSION macro. \n*/\nSQLITE_API const char sqlite3_version[] = SQLITE_VERSION;\n#endif\n\n/* IMPLEMENTATION-OF: R-53536-42575 The sqlite3_libversion() function returns\n** a pointer to the to the sqlite3_version[] string constant. \n*/\nSQLITE_API const char *sqlite3_libversion(void){ return sqlite3_version; }\n\n/* IMPLEMENTATION-OF: R-25063-23286 The sqlite3_sourceid() function returns a\n** pointer to a string constant whose value is the same as the\n** SQLITE_SOURCE_ID C preprocessor macro. Except if SQLite is built using\n** an edited copy of the amalgamation, then the last four characters of\n** the hash might be different from SQLITE_SOURCE_ID.\n*/\n/* SQLITE_API const char *sqlite3_sourceid(void){ return SQLITE_SOURCE_ID; } */\n\n/* IMPLEMENTATION-OF: R-35210-63508 The sqlite3_libversion_number() function\n** returns an integer equal to SQLITE_VERSION_NUMBER.\n*/\nSQLITE_API int sqlite3_libversion_number(void){ return SQLITE_VERSION_NUMBER; }\n\n/* IMPLEMENTATION-OF: R-20790-14025 The sqlite3_threadsafe() function returns\n** zero if and only if SQLite was compiled with mutexing code omitted due to\n** the SQLITE_THREADSAFE compile-time option being set to 0.\n*/\nSQLITE_API int sqlite3_threadsafe(void){ return SQLITE_THREADSAFE; }\n\n/*\n** When compiling the test fixture or with debugging enabled (on Win32),\n** this variable being set to non-zero will cause OSTRACE macros to emit\n** extra diagnostic information.\n*/\n#ifdef SQLITE_HAVE_OS_TRACE\n# ifndef SQLITE_DEBUG_OS_TRACE\n#   define SQLITE_DEBUG_OS_TRACE 0\n# endif\n  int sqlite3OSTrace = SQLITE_DEBUG_OS_TRACE;\n#endif\n\n#if !defined(SQLITE_OMIT_TRACE) && defined(SQLITE_ENABLE_IOTRACE)\n/*\n** If the following function pointer is not NULL and if\n** SQLITE_ENABLE_IOTRACE is enabled, then messages describing\n** I/O active are written using this function.  These messages\n** are intended for debugging activity only.\n*/\nSQLITE_API void (SQLITE_CDECL *sqlite3IoTrace)(const char*, ...) = 0;\n#endif\n\n/*\n** If the following global variable points to a string which is the\n** name of a directory, then that directory will be used to store\n** temporary files.\n**\n** See also the \"PRAGMA temp_store_directory\" SQL command.\n*/\nSQLITE_API char *sqlite3_temp_directory = 0;\n\n/*\n** If the following global variable points to a string which is the\n** name of a directory, then that directory will be used to store\n** all database files specified with a relative pathname.\n**\n** See also the \"PRAGMA data_store_directory\" SQL command.\n*/\nSQLITE_API char *sqlite3_data_directory = 0;\n\n/*\n** Initialize SQLite.  \n**\n** This routine must be called to initialize the memory allocation,\n** VFS, and mutex subsystems prior to doing any serious work with\n** SQLite.  But as long as you do not compile with SQLITE_OMIT_AUTOINIT\n** this routine will be called automatically by key routines such as\n** sqlite3_open().  \n**\n** This routine is a no-op except on its very first call for the process,\n** or for the first call after a call to sqlite3_shutdown.\n**\n** The first thread to call this routine runs the initialization to\n** completion.  If subsequent threads call this routine before the first\n** thread has finished the initialization process, then the subsequent\n** threads must block until the first thread finishes with the initialization.\n**\n** The first thread might call this routine recursively.  Recursive\n** calls to this routine should not block, of course.  Otherwise the\n** initialization process would never complete.\n**\n** Let X be the first thread to enter this routine.  Let Y be some other\n** thread.  Then while the initial invocation of this routine by X is\n** incomplete, it is required that:\n**\n**    *  Calls to this routine from Y must block until the outer-most\n**       call by X completes.\n**\n**    *  Recursive calls to this routine from thread X return immediately\n**       without blocking.\n*/\nSQLITE_API int sqlite3_initialize(void){\n  MUTEX_LOGIC( sqlite3_mutex *pMaster; )       /* The main static mutex */\n  int rc;                                      /* Result code */\n#ifdef SQLITE_EXTRA_INIT\n  int bRunExtraInit = 0;                       /* Extra initialization needed */\n#endif\n\n#ifdef SQLITE_OMIT_WSD\n  rc = sqlite3_wsd_init(4096, 24);\n  if( rc!=SQLITE_OK ){\n    return rc;\n  }\n#endif\n\n  /* If the following assert() fails on some obscure processor/compiler\n  ** combination, the work-around is to set the correct pointer\n  ** size at compile-time using -DSQLITE_PTRSIZE=n compile-time option */\n  assert( SQLITE_PTRSIZE==sizeof(char*) );\n\n  /* If SQLite is already completely initialized, then this call\n  ** to sqlite3_initialize() should be a no-op.  But the initialization\n  ** must be complete.  So isInit must not be set until the very end\n  ** of this routine.\n  */\n  if( sqlite3GlobalConfig.isInit ) return SQLITE_OK;\n\n  /* Make sure the mutex subsystem is initialized.  If unable to \n  ** initialize the mutex subsystem, return early with the error.\n  ** If the system is so sick that we are unable to allocate a mutex,\n  ** there is not much SQLite is going to be able to do.\n  **\n  ** The mutex subsystem must take care of serializing its own\n  ** initialization.\n  */\n  rc = sqlite3MutexInit();\n  if( rc ) return rc;\n\n  /* Initialize the malloc() system and the recursive pInitMutex mutex.\n  ** This operation is protected by the STATIC_MASTER mutex.  Note that\n  ** MutexAlloc() is called for a static mutex prior to initializing the\n  ** malloc subsystem - this implies that the allocation of a static\n  ** mutex must not require support from the malloc subsystem.\n  */\n  MUTEX_LOGIC( pMaster = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER); )\n  sqlite3_mutex_enter(pMaster);\n  sqlite3GlobalConfig.isMutexInit = 1;\n  if( !sqlite3GlobalConfig.isMallocInit ){\n    rc = sqlite3MallocInit();\n  }\n  if( rc==SQLITE_OK ){\n    sqlite3GlobalConfig.isMallocInit = 1;\n    if( !sqlite3GlobalConfig.pInitMutex ){\n      sqlite3GlobalConfig.pInitMutex =\n           sqlite3MutexAlloc(SQLITE_MUTEX_RECURSIVE);\n      if( sqlite3GlobalConfig.bCoreMutex && !sqlite3GlobalConfig.pInitMutex ){\n        rc = SQLITE_NOMEM_BKPT;\n      }\n    }\n  }\n  if( rc==SQLITE_OK ){\n    sqlite3GlobalConfig.nRefInitMutex++;\n  }\n  sqlite3_mutex_leave(pMaster);\n\n  /* If rc is not SQLITE_OK at this point, then either the malloc\n  ** subsystem could not be initialized or the system failed to allocate\n  ** the pInitMutex mutex. Return an error in either case.  */\n  if( rc!=SQLITE_OK ){\n    return rc;\n  }\n\n  /* Do the rest of the initialization under the recursive mutex so\n  ** that we will be able to handle recursive calls into\n  ** sqlite3_initialize().  The recursive calls normally come through\n  ** sqlite3_os_init() when it invokes sqlite3_vfs_register(), but other\n  ** recursive calls might also be possible.\n  **\n  ** IMPLEMENTATION-OF: R-00140-37445 SQLite automatically serializes calls\n  ** to the xInit method, so the xInit method need not be threadsafe.\n  **\n  ** The following mutex is what serializes access to the appdef pcache xInit\n  ** methods.  The sqlite3_pcache_methods.xInit() all is embedded in the\n  ** call to sqlite3PcacheInitialize().\n  */\n  sqlite3_mutex_enter(sqlite3GlobalConfig.pInitMutex);\n  if( sqlite3GlobalConfig.isInit==0 && sqlite3GlobalConfig.inProgress==0 ){\n    sqlite3GlobalConfig.inProgress = 1;\n#ifdef SQLITE_ENABLE_SQLLOG\n    {\n      extern void sqlite3_init_sqllog(void);\n      sqlite3_init_sqllog();\n    }\n#endif\n    memset(&sqlite3BuiltinFunctions, 0, sizeof(sqlite3BuiltinFunctions));\n    sqlite3RegisterBuiltinFunctions();\n    if( sqlite3GlobalConfig.isPCacheInit==0 ){\n      rc = sqlite3PcacheInitialize();\n    }\n    if( rc==SQLITE_OK ){\n      sqlite3GlobalConfig.isPCacheInit = 1;\n      rc = sqlite3OsInit();\n    }\n#ifdef SQLITE_ENABLE_DESERIALIZE\n    if( rc==SQLITE_OK ){\n      rc = sqlite3MemdbInit();\n    }\n#endif\n    if( rc==SQLITE_OK ){\n      sqlite3PCacheBufferSetup( sqlite3GlobalConfig.pPage, \n          sqlite3GlobalConfig.szPage, sqlite3GlobalConfig.nPage);\n      sqlite3GlobalConfig.isInit = 1;\n#ifdef SQLITE_EXTRA_INIT\n      bRunExtraInit = 1;\n#endif\n    }\n    sqlite3GlobalConfig.inProgress = 0;\n  }\n  sqlite3_mutex_leave(sqlite3GlobalConfig.pInitMutex);\n\n  /* Go back under the static mutex and clean up the recursive\n  ** mutex to prevent a resource leak.\n  */\n  sqlite3_mutex_enter(pMaster);\n  sqlite3GlobalConfig.nRefInitMutex--;\n  if( sqlite3GlobalConfig.nRefInitMutex<=0 ){\n    assert( sqlite3GlobalConfig.nRefInitMutex==0 );\n    sqlite3_mutex_free(sqlite3GlobalConfig.pInitMutex);\n    sqlite3GlobalConfig.pInitMutex = 0;\n  }\n  sqlite3_mutex_leave(pMaster);\n\n  /* The following is just a sanity check to make sure SQLite has\n  ** been compiled correctly.  It is important to run this code, but\n  ** we don't want to run it too often and soak up CPU cycles for no\n  ** reason.  So we run it once during initialization.\n  */\n#ifndef NDEBUG\n#ifndef SQLITE_OMIT_FLOATING_POINT\n  /* This section of code's only \"output\" is via assert() statements. */\n  if( rc==SQLITE_OK ){\n    u64 x = (((u64)1)<<63)-1;\n    double y;\n    assert(sizeof(x)==8);\n    assert(sizeof(x)==sizeof(y));\n    memcpy(&y, &x, 8);\n    assert( sqlite3IsNaN(y) );\n  }\n#endif\n#endif\n\n  /* Do extra initialization steps requested by the SQLITE_EXTRA_INIT\n  ** compile-time option.\n  */\n#ifdef SQLITE_EXTRA_INIT\n  if( bRunExtraInit ){\n    int SQLITE_EXTRA_INIT(const char*);\n    rc = SQLITE_EXTRA_INIT(0);\n  }\n#endif\n\n  return rc;\n}\n\n/*\n** Undo the effects of sqlite3_initialize().  Must not be called while\n** there are outstanding database connections or memory allocations or\n** while any part of SQLite is otherwise in use in any thread.  This\n** routine is not threadsafe.  But it is safe to invoke this routine\n** on when SQLite is already shut down.  If SQLite is already shut down\n** when this routine is invoked, then this routine is a harmless no-op.\n*/\nSQLITE_API int sqlite3_shutdown(void){\n#ifdef SQLITE_OMIT_WSD\n  int rc = sqlite3_wsd_init(4096, 24);\n  if( rc!=SQLITE_OK ){\n    return rc;\n  }\n#endif\n\n  if( sqlite3GlobalConfig.isInit ){\n#ifdef SQLITE_EXTRA_SHUTDOWN\n    void SQLITE_EXTRA_SHUTDOWN(void);\n    SQLITE_EXTRA_SHUTDOWN();\n#endif\n    sqlite3_os_end();\n    sqlite3_reset_auto_extension();\n    sqlite3GlobalConfig.isInit = 0;\n  }\n  if( sqlite3GlobalConfig.isPCacheInit ){\n    sqlite3PcacheShutdown();\n    sqlite3GlobalConfig.isPCacheInit = 0;\n  }\n  if( sqlite3GlobalConfig.isMallocInit ){\n    sqlite3MallocEnd();\n    sqlite3GlobalConfig.isMallocInit = 0;\n\n#ifndef SQLITE_OMIT_SHUTDOWN_DIRECTORIES\n    /* The heap subsystem has now been shutdown and these values are supposed\n    ** to be NULL or point to memory that was obtained from sqlite3_malloc(),\n    ** which would rely on that heap subsystem; therefore, make sure these\n    ** values cannot refer to heap memory that was just invalidated when the\n    ** heap subsystem was shutdown.  This is only done if the current call to\n    ** this function resulted in the heap subsystem actually being shutdown.\n    */\n    sqlite3_data_directory = 0;\n    sqlite3_temp_directory = 0;\n#endif\n  }\n  if( sqlite3GlobalConfig.isMutexInit ){\n    sqlite3MutexEnd();\n    sqlite3GlobalConfig.isMutexInit = 0;\n  }\n\n  return SQLITE_OK;\n}\n\n/*\n** This API allows applications to modify the global configuration of\n** the SQLite library at run-time.\n**\n** This routine should only be called when there are no outstanding\n** database connections or memory allocations.  This routine is not\n** threadsafe.  Failure to heed these warnings can lead to unpredictable\n** behavior.\n*/\nSQLITE_API int sqlite3_config(int op, ...){\n  va_list ap;\n  int rc = SQLITE_OK;\n\n  /* sqlite3_config() shall return SQLITE_MISUSE if it is invoked while\n  ** the SQLite library is in use. */\n  if( sqlite3GlobalConfig.isInit ) return SQLITE_MISUSE_BKPT;\n\n  va_start(ap, op);\n  switch( op ){\n\n    /* Mutex configuration options are only available in a threadsafe\n    ** compile.\n    */\n#if defined(SQLITE_THREADSAFE) && SQLITE_THREADSAFE>0  /* IMP: R-54466-46756 */\n    case SQLITE_CONFIG_SINGLETHREAD: {\n      /* EVIDENCE-OF: R-02748-19096 This option sets the threading mode to\n      ** Single-thread. */\n      sqlite3GlobalConfig.bCoreMutex = 0;  /* Disable mutex on core */\n      sqlite3GlobalConfig.bFullMutex = 0;  /* Disable mutex on connections */\n      break;\n    }\n#endif\n#if defined(SQLITE_THREADSAFE) && SQLITE_THREADSAFE>0 /* IMP: R-20520-54086 */\n    case SQLITE_CONFIG_MULTITHREAD: {\n      /* EVIDENCE-OF: R-14374-42468 This option sets the threading mode to\n      ** Multi-thread. */\n      sqlite3GlobalConfig.bCoreMutex = 1;  /* Enable mutex on core */\n      sqlite3GlobalConfig.bFullMutex = 0;  /* Disable mutex on connections */\n      break;\n    }\n#endif\n#if defined(SQLITE_THREADSAFE) && SQLITE_THREADSAFE>0 /* IMP: R-59593-21810 */\n    case SQLITE_CONFIG_SERIALIZED: {\n      /* EVIDENCE-OF: R-41220-51800 This option sets the threading mode to\n      ** Serialized. */\n      sqlite3GlobalConfig.bCoreMutex = 1;  /* Enable mutex on core */\n      sqlite3GlobalConfig.bFullMutex = 1;  /* Enable mutex on connections */\n      break;\n    }\n#endif\n#if defined(SQLITE_THREADSAFE) && SQLITE_THREADSAFE>0 /* IMP: R-63666-48755 */\n    case SQLITE_CONFIG_MUTEX: {\n      /* Specify an alternative mutex implementation */\n      sqlite3GlobalConfig.mutex = *va_arg(ap, sqlite3_mutex_methods*);\n      break;\n    }\n#endif\n#if defined(SQLITE_THREADSAFE) && SQLITE_THREADSAFE>0 /* IMP: R-14450-37597 */\n    case SQLITE_CONFIG_GETMUTEX: {\n      /* Retrieve the current mutex implementation */\n      *va_arg(ap, sqlite3_mutex_methods*) = sqlite3GlobalConfig.mutex;\n      break;\n    }\n#endif\n\n    case SQLITE_CONFIG_MALLOC: {\n      /* EVIDENCE-OF: R-55594-21030 The SQLITE_CONFIG_MALLOC option takes a\n      ** single argument which is a pointer to an instance of the\n      ** sqlite3_mem_methods structure. The argument specifies alternative\n      ** low-level memory allocation routines to be used in place of the memory\n      ** allocation routines built into SQLite. */\n      sqlite3GlobalConfig.m = *va_arg(ap, sqlite3_mem_methods*);\n      break;\n    }\n    case SQLITE_CONFIG_GETMALLOC: {\n      /* EVIDENCE-OF: R-51213-46414 The SQLITE_CONFIG_GETMALLOC option takes a\n      ** single argument which is a pointer to an instance of the\n      ** sqlite3_mem_methods structure. The sqlite3_mem_methods structure is\n      ** filled with the currently defined memory allocation routines. */\n      if( sqlite3GlobalConfig.m.xMalloc==0 ) sqlite3MemSetDefault();\n      *va_arg(ap, sqlite3_mem_methods*) = sqlite3GlobalConfig.m;\n      break;\n    }\n    case SQLITE_CONFIG_MEMSTATUS: {\n      /* EVIDENCE-OF: R-61275-35157 The SQLITE_CONFIG_MEMSTATUS option takes\n      ** single argument of type int, interpreted as a boolean, which enables\n      ** or disables the collection of memory allocation statistics. */\n      sqlite3GlobalConfig.bMemstat = va_arg(ap, int);\n      break;\n    }\n    case SQLITE_CONFIG_SMALL_MALLOC: {\n      sqlite3GlobalConfig.bSmallMalloc = va_arg(ap, int);\n      break;\n    }\n    case SQLITE_CONFIG_PAGECACHE: {\n      /* EVIDENCE-OF: R-18761-36601 There are three arguments to\n      ** SQLITE_CONFIG_PAGECACHE: A pointer to 8-byte aligned memory (pMem),\n      ** the size of each page cache line (sz), and the number of cache lines\n      ** (N). */\n      sqlite3GlobalConfig.pPage = va_arg(ap, void*);\n      sqlite3GlobalConfig.szPage = va_arg(ap, int);\n      sqlite3GlobalConfig.nPage = va_arg(ap, int);\n      break;\n    }\n    case SQLITE_CONFIG_PCACHE_HDRSZ: {\n      /* EVIDENCE-OF: R-39100-27317 The SQLITE_CONFIG_PCACHE_HDRSZ option takes\n      ** a single parameter which is a pointer to an integer and writes into\n      ** that integer the number of extra bytes per page required for each page\n      ** in SQLITE_CONFIG_PAGECACHE. */\n      *va_arg(ap, int*) = \n          sqlite3HeaderSizeBtree() +\n          sqlite3HeaderSizePcache() +\n          sqlite3HeaderSizePcache1();\n      break;\n    }\n\n    case SQLITE_CONFIG_PCACHE: {\n      /* no-op */\n      break;\n    }\n    case SQLITE_CONFIG_GETPCACHE: {\n      /* now an error */\n      rc = SQLITE_ERROR;\n      break;\n    }\n\n    case SQLITE_CONFIG_PCACHE2: {\n      /* EVIDENCE-OF: R-63325-48378 The SQLITE_CONFIG_PCACHE2 option takes a\n      ** single argument which is a pointer to an sqlite3_pcache_methods2\n      ** object. This object specifies the interface to a custom page cache\n      ** implementation. */\n      sqlite3GlobalConfig.pcache2 = *va_arg(ap, sqlite3_pcache_methods2*);\n      break;\n    }\n    case SQLITE_CONFIG_GETPCACHE2: {\n      /* EVIDENCE-OF: R-22035-46182 The SQLITE_CONFIG_GETPCACHE2 option takes a\n      ** single argument which is a pointer to an sqlite3_pcache_methods2\n      ** object. SQLite copies of the current page cache implementation into\n      ** that object. */\n      if( sqlite3GlobalConfig.pcache2.xInit==0 ){\n        sqlite3PCacheSetDefault();\n      }\n      *va_arg(ap, sqlite3_pcache_methods2*) = sqlite3GlobalConfig.pcache2;\n      break;\n    }\n\n/* EVIDENCE-OF: R-06626-12911 The SQLITE_CONFIG_HEAP option is only\n** available if SQLite is compiled with either SQLITE_ENABLE_MEMSYS3 or\n** SQLITE_ENABLE_MEMSYS5 and returns SQLITE_ERROR if invoked otherwise. */\n#if defined(SQLITE_ENABLE_MEMSYS3) || defined(SQLITE_ENABLE_MEMSYS5)\n    case SQLITE_CONFIG_HEAP: {\n      /* EVIDENCE-OF: R-19854-42126 There are three arguments to\n      ** SQLITE_CONFIG_HEAP: An 8-byte aligned pointer to the memory, the\n      ** number of bytes in the memory buffer, and the minimum allocation size.\n      */\n      sqlite3GlobalConfig.pHeap = va_arg(ap, void*);\n      sqlite3GlobalConfig.nHeap = va_arg(ap, int);\n      sqlite3GlobalConfig.mnReq = va_arg(ap, int);\n\n      if( sqlite3GlobalConfig.mnReq<1 ){\n        sqlite3GlobalConfig.mnReq = 1;\n      }else if( sqlite3GlobalConfig.mnReq>(1<<12) ){\n        /* cap min request size at 2^12 */\n        sqlite3GlobalConfig.mnReq = (1<<12);\n      }\n\n      if( sqlite3GlobalConfig.pHeap==0 ){\n        /* EVIDENCE-OF: R-49920-60189 If the first pointer (the memory pointer)\n        ** is NULL, then SQLite reverts to using its default memory allocator\n        ** (the system malloc() implementation), undoing any prior invocation of\n        ** SQLITE_CONFIG_MALLOC.\n        **\n        ** Setting sqlite3GlobalConfig.m to all zeros will cause malloc to\n        ** revert to its default implementation when sqlite3_initialize() is run\n        */\n        memset(&sqlite3GlobalConfig.m, 0, sizeof(sqlite3GlobalConfig.m));\n      }else{\n        /* EVIDENCE-OF: R-61006-08918 If the memory pointer is not NULL then the\n        ** alternative memory allocator is engaged to handle all of SQLites\n        ** memory allocation needs. */\n#ifdef SQLITE_ENABLE_MEMSYS3\n        sqlite3GlobalConfig.m = *sqlite3MemGetMemsys3();\n#endif\n#ifdef SQLITE_ENABLE_MEMSYS5\n        sqlite3GlobalConfig.m = *sqlite3MemGetMemsys5();\n#endif\n      }\n      break;\n    }\n#endif\n\n    case SQLITE_CONFIG_LOOKASIDE: {\n      sqlite3GlobalConfig.szLookaside = va_arg(ap, int);\n      sqlite3GlobalConfig.nLookaside = va_arg(ap, int);\n      break;\n    }\n    \n    /* Record a pointer to the logger function and its first argument.\n    ** The default is NULL.  Logging is disabled if the function pointer is\n    ** NULL.\n    */\n    case SQLITE_CONFIG_LOG: {\n      /* MSVC is picky about pulling func ptrs from va lists.\n      ** http://support.microsoft.com/kb/47961\n      ** sqlite3GlobalConfig.xLog = va_arg(ap, void(*)(void*,int,const char*));\n      */\n      typedef void(*LOGFUNC_t)(void*,int,const char*);\n      sqlite3GlobalConfig.xLog = va_arg(ap, LOGFUNC_t);\n      sqlite3GlobalConfig.pLogArg = va_arg(ap, void*);\n      break;\n    }\n\n    /* EVIDENCE-OF: R-55548-33817 The compile-time setting for URI filenames\n    ** can be changed at start-time using the\n    ** sqlite3_config(SQLITE_CONFIG_URI,1) or\n    ** sqlite3_config(SQLITE_CONFIG_URI,0) configuration calls.\n    */\n    case SQLITE_CONFIG_URI: {\n      /* EVIDENCE-OF: R-25451-61125 The SQLITE_CONFIG_URI option takes a single\n      ** argument of type int. If non-zero, then URI handling is globally\n      ** enabled. If the parameter is zero, then URI handling is globally\n      ** disabled. */\n      sqlite3GlobalConfig.bOpenUri = va_arg(ap, int);\n      break;\n    }\n\n    case SQLITE_CONFIG_COVERING_INDEX_SCAN: {\n      /* EVIDENCE-OF: R-36592-02772 The SQLITE_CONFIG_COVERING_INDEX_SCAN\n      ** option takes a single integer argument which is interpreted as a\n      ** boolean in order to enable or disable the use of covering indices for\n      ** full table scans in the query optimizer. */\n      sqlite3GlobalConfig.bUseCis = va_arg(ap, int);\n      break;\n    }\n\n#ifdef SQLITE_ENABLE_SQLLOG\n    case SQLITE_CONFIG_SQLLOG: {\n      typedef void(*SQLLOGFUNC_t)(void*, sqlite3*, const char*, int);\n      sqlite3GlobalConfig.xSqllog = va_arg(ap, SQLLOGFUNC_t);\n      sqlite3GlobalConfig.pSqllogArg = va_arg(ap, void *);\n      break;\n    }\n#endif\n\n    case SQLITE_CONFIG_MMAP_SIZE: {\n      /* EVIDENCE-OF: R-58063-38258 SQLITE_CONFIG_MMAP_SIZE takes two 64-bit\n      ** integer (sqlite3_int64) values that are the default mmap size limit\n      ** (the default setting for PRAGMA mmap_size) and the maximum allowed\n      ** mmap size limit. */\n      sqlite3_int64 szMmap = va_arg(ap, sqlite3_int64);\n      sqlite3_int64 mxMmap = va_arg(ap, sqlite3_int64);\n      /* EVIDENCE-OF: R-53367-43190 If either argument to this option is\n      ** negative, then that argument is changed to its compile-time default.\n      **\n      ** EVIDENCE-OF: R-34993-45031 The maximum allowed mmap size will be\n      ** silently truncated if necessary so that it does not exceed the\n      ** compile-time maximum mmap size set by the SQLITE_MAX_MMAP_SIZE\n      ** compile-time option.\n      */\n      if( mxMmap<0 || mxMmap>SQLITE_MAX_MMAP_SIZE ){\n        mxMmap = SQLITE_MAX_MMAP_SIZE;\n      }\n      if( szMmap<0 ) szMmap = SQLITE_DEFAULT_MMAP_SIZE;\n      if( szMmap>mxMmap) szMmap = mxMmap;\n      sqlite3GlobalConfig.mxMmap = mxMmap;\n      sqlite3GlobalConfig.szMmap = szMmap;\n      break;\n    }\n\n#if SQLITE_OS_WIN && defined(SQLITE_WIN32_MALLOC) /* IMP: R-04780-55815 */\n    case SQLITE_CONFIG_WIN32_HEAPSIZE: {\n      /* EVIDENCE-OF: R-34926-03360 SQLITE_CONFIG_WIN32_HEAPSIZE takes a 32-bit\n      ** unsigned integer value that specifies the maximum size of the created\n      ** heap. */\n      sqlite3GlobalConfig.nHeap = va_arg(ap, int);\n      break;\n    }\n#endif\n\n    case SQLITE_CONFIG_PMASZ: {\n      sqlite3GlobalConfig.szPma = va_arg(ap, unsigned int);\n      break;\n    }\n\n    case SQLITE_CONFIG_STMTJRNL_SPILL: {\n      sqlite3GlobalConfig.nStmtSpill = va_arg(ap, int);\n      break;\n    }\n\n#ifdef SQLITE_ENABLE_SORTER_REFERENCES\n    case SQLITE_CONFIG_SORTERREF_SIZE: {\n      int iVal = va_arg(ap, int);\n      if( iVal<0 ){\n        iVal = SQLITE_DEFAULT_SORTERREF_SIZE;\n      }\n      sqlite3GlobalConfig.szSorterRef = (u32)iVal;\n      break;\n    }\n#endif /* SQLITE_ENABLE_SORTER_REFERENCES */\n\n#ifdef SQLITE_ENABLE_DESERIALIZE\n    case SQLITE_CONFIG_MEMDB_MAXSIZE: {\n      sqlite3GlobalConfig.mxMemdbSize = va_arg(ap, sqlite3_int64);\n      break;\n    }\n#endif /* SQLITE_ENABLE_DESERIALIZE */\n\n    default: {\n      rc = SQLITE_ERROR;\n      break;\n    }\n  }\n  va_end(ap);\n  return rc;\n}\n\n/*\n** Set up the lookaside buffers for a database connection.\n** Return SQLITE_OK on success.  \n** If lookaside is already active, return SQLITE_BUSY.\n**\n** The sz parameter is the number of bytes in each lookaside slot.\n** The cnt parameter is the number of slots.  If pStart is NULL the\n** space for the lookaside memory is obtained from sqlite3_malloc().\n** If pStart is not NULL then it is sz*cnt bytes of memory to use for\n** the lookaside memory.\n*/\nstatic int setupLookaside(sqlite3 *db, void *pBuf, int sz, int cnt){\n#ifndef SQLITE_OMIT_LOOKASIDE\n  void *pStart;\n  \n  if( sqlite3LookasideUsed(db,0)>0 ){\n    return SQLITE_BUSY;\n  }\n  /* Free any existing lookaside buffer for this handle before\n  ** allocating a new one so we don't have to have space for \n  ** both at the same time.\n  */\n  if( db->lookaside.bMalloced ){\n    sqlite3_free(db->lookaside.pStart);\n  }\n  /* The size of a lookaside slot after ROUNDDOWN8 needs to be larger\n  ** than a pointer to be useful.\n  */\n  sz = ROUNDDOWN8(sz);  /* IMP: R-33038-09382 */\n  if( sz<=(int)sizeof(LookasideSlot*) ) sz = 0;\n  if( cnt<0 ) cnt = 0;\n  if( sz==0 || cnt==0 ){\n    sz = 0;\n    pStart = 0;\n  }else if( pBuf==0 ){\n    sqlite3BeginBenignMalloc();\n    pStart = sqlite3Malloc( sz*cnt );  /* IMP: R-61949-35727 */\n    sqlite3EndBenignMalloc();\n    if( pStart ) cnt = sqlite3MallocSize(pStart)/sz;\n  }else{\n    pStart = pBuf;\n  }\n  db->lookaside.pStart = pStart;\n  db->lookaside.pInit = 0;\n  db->lookaside.pFree = 0;\n  db->lookaside.sz = (u16)sz;\n  if( pStart ){\n    int i;\n    LookasideSlot *p;\n    assert( sz > (int)sizeof(LookasideSlot*) );\n    db->lookaside.nSlot = cnt;\n    p = (LookasideSlot*)pStart;\n    for(i=cnt-1; i>=0; i--){\n      p->pNext = db->lookaside.pInit;\n      db->lookaside.pInit = p;\n      p = (LookasideSlot*)&((u8*)p)[sz];\n    }\n    db->lookaside.pEnd = p;\n    db->lookaside.bDisable = 0;\n    db->lookaside.bMalloced = pBuf==0 ?1:0;\n  }else{\n    db->lookaside.pStart = db;\n    db->lookaside.pEnd = db;\n    db->lookaside.bDisable = 1;\n    db->lookaside.bMalloced = 0;\n    db->lookaside.nSlot = 0;\n  }\n#endif /* SQLITE_OMIT_LOOKASIDE */\n  return SQLITE_OK;\n}\n\n/*\n** Return the mutex associated with a database connection.\n*/\nSQLITE_API sqlite3_mutex *sqlite3_db_mutex(sqlite3 *db){\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( !sqlite3SafetyCheckOk(db) ){\n    (void)SQLITE_MISUSE_BKPT;\n    return 0;\n  }\n#endif\n  return db->mutex;\n}\n\n/*\n** Free up as much memory as we can from the given database\n** connection.\n*/\nSQLITE_API int sqlite3_db_release_memory(sqlite3 *db){\n  int i;\n\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( !sqlite3SafetyCheckOk(db) ) return SQLITE_MISUSE_BKPT;\n#endif\n  sqlite3_mutex_enter(db->mutex);\n  sqlite3BtreeEnterAll(db);\n  for(i=0; i<db->nDb; i++){\n    Btree *pBt = db->aDb[i].pBt;\n    if( pBt ){\n      Pager *pPager = sqlite3BtreePager(pBt);\n      sqlite3PagerShrink(pPager);\n    }\n  }\n  sqlite3BtreeLeaveAll(db);\n  sqlite3_mutex_leave(db->mutex);\n  return SQLITE_OK;\n}\n\n/*\n** Flush any dirty pages in the pager-cache for any attached database\n** to disk.\n*/\nSQLITE_API int sqlite3_db_cacheflush(sqlite3 *db){\n  int i;\n  int rc = SQLITE_OK;\n  int bSeenBusy = 0;\n\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( !sqlite3SafetyCheckOk(db) ) return SQLITE_MISUSE_BKPT;\n#endif\n  sqlite3_mutex_enter(db->mutex);\n  sqlite3BtreeEnterAll(db);\n  for(i=0; rc==SQLITE_OK && i<db->nDb; i++){\n    Btree *pBt = db->aDb[i].pBt;\n    if( pBt && sqlite3BtreeIsInTrans(pBt) ){\n      Pager *pPager = sqlite3BtreePager(pBt);\n      rc = sqlite3PagerFlush(pPager);\n      if( rc==SQLITE_BUSY ){\n        bSeenBusy = 1;\n        rc = SQLITE_OK;\n      }\n    }\n  }\n  sqlite3BtreeLeaveAll(db);\n  sqlite3_mutex_leave(db->mutex);\n  return ((rc==SQLITE_OK && bSeenBusy) ? SQLITE_BUSY : rc);\n}\n\n/*\n** Configuration settings for an individual database connection\n*/\nSQLITE_API int sqlite3_db_config(sqlite3 *db, int op, ...){\n  va_list ap;\n  int rc;\n  va_start(ap, op);\n  switch( op ){\n    case SQLITE_DBCONFIG_MAINDBNAME: {\n      /* IMP: R-06824-28531 */\n      /* IMP: R-36257-52125 */\n      db->aDb[0].zDbSName = va_arg(ap,char*);\n      rc = SQLITE_OK;\n      break;\n    }\n    case SQLITE_DBCONFIG_LOOKASIDE: {\n      void *pBuf = va_arg(ap, void*); /* IMP: R-26835-10964 */\n      int sz = va_arg(ap, int);       /* IMP: R-47871-25994 */\n      int cnt = va_arg(ap, int);      /* IMP: R-04460-53386 */\n      rc = setupLookaside(db, pBuf, sz, cnt);\n      break;\n    }\n    default: {\n      static const struct {\n        int op;      /* The opcode */\n        u32 mask;    /* Mask of the bit in sqlite3.flags to set/clear */\n      } aFlagOp[] = {\n        { SQLITE_DBCONFIG_ENABLE_FKEY,           SQLITE_ForeignKeys    },\n        { SQLITE_DBCONFIG_ENABLE_TRIGGER,        SQLITE_EnableTrigger  },\n        { SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER, SQLITE_Fts3Tokenizer  },\n        { SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION, SQLITE_LoadExtension  },\n        { SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE,      SQLITE_NoCkptOnClose  },\n        { SQLITE_DBCONFIG_ENABLE_QPSG,           SQLITE_EnableQPSG     },\n        { SQLITE_DBCONFIG_TRIGGER_EQP,           SQLITE_TriggerEQP     },\n        { SQLITE_DBCONFIG_RESET_DATABASE,        SQLITE_ResetDatabase  },\n        { SQLITE_DBCONFIG_DEFENSIVE,             SQLITE_Defensive      },\n      };\n      unsigned int i;\n      rc = SQLITE_ERROR; /* IMP: R-42790-23372 */\n      for(i=0; i<ArraySize(aFlagOp); i++){\n        if( aFlagOp[i].op==op ){\n          int onoff = va_arg(ap, int);\n          int *pRes = va_arg(ap, int*);\n          u64 oldFlags = db->flags;\n          if( onoff>0 ){\n            db->flags |= aFlagOp[i].mask;\n          }else if( onoff==0 ){\n            db->flags &= ~(u64)aFlagOp[i].mask;\n          }\n          if( oldFlags!=db->flags ){\n            sqlite3ExpirePreparedStatements(db, 0);\n          }\n          if( pRes ){\n            *pRes = (db->flags & aFlagOp[i].mask)!=0;\n          }\n          rc = SQLITE_OK;\n          break;\n        }\n      }\n      break;\n    }\n  }\n  va_end(ap);\n  return rc;\n}\n\n\n/*\n** Return true if the buffer z[0..n-1] contains all spaces.\n*/\nstatic int allSpaces(const char *z, int n){\n  while( n>0 && z[n-1]==' ' ){ n--; }\n  return n==0;\n}\n\n/*\n** This is the default collating function named \"BINARY\" which is always\n** available.\n**\n** If the padFlag argument is not NULL then space padding at the end\n** of strings is ignored.  This implements the RTRIM collation.\n*/\nstatic int binCollFunc(\n  void *padFlag,\n  int nKey1, const void *pKey1,\n  int nKey2, const void *pKey2\n){\n  int rc, n;\n  n = nKey1<nKey2 ? nKey1 : nKey2;\n  /* EVIDENCE-OF: R-65033-28449 The built-in BINARY collation compares\n  ** strings byte by byte using the memcmp() function from the standard C\n  ** library. */\n  assert( pKey1 && pKey2 );\n  rc = memcmp(pKey1, pKey2, n);\n  if( rc==0 ){\n    if( padFlag\n     && allSpaces(((char*)pKey1)+n, nKey1-n)\n     && allSpaces(((char*)pKey2)+n, nKey2-n)\n    ){\n      /* EVIDENCE-OF: R-31624-24737 RTRIM is like BINARY except that extra\n      ** spaces at the end of either string do not change the result. In other\n      ** words, strings will compare equal to one another as long as they\n      ** differ only in the number of spaces at the end.\n      */\n    }else{\n      rc = nKey1 - nKey2;\n    }\n  }\n  return rc;\n}\n\n/*\n** Return true if CollSeq is the default built-in BINARY.\n*/\nSQLITE_PRIVATE int sqlite3IsBinary(const CollSeq *p){\n  assert( p==0 || p->xCmp!=binCollFunc || p->pUser!=0\n            || strcmp(p->zName,\"BINARY\")==0 );\n  return p==0 || (p->xCmp==binCollFunc && p->pUser==0);\n}\n\n/*\n** Another built-in collating sequence: NOCASE. \n**\n** This collating sequence is intended to be used for \"case independent\n** comparison\". SQLite's knowledge of upper and lower case equivalents\n** extends only to the 26 characters used in the English language.\n**\n** At the moment there is only a UTF-8 implementation.\n*/\nstatic int nocaseCollatingFunc(\n  void *NotUsed,\n  int nKey1, const void *pKey1,\n  int nKey2, const void *pKey2\n){\n  int r = sqlite3StrNICmp(\n      (const char *)pKey1, (const char *)pKey2, (nKey1<nKey2)?nKey1:nKey2);\n  UNUSED_PARAMETER(NotUsed);\n  if( 0==r ){\n    r = nKey1-nKey2;\n  }\n  return r;\n}\n\n/*\n** Return the ROWID of the most recent insert\n*/\nSQLITE_API sqlite_int64 sqlite3_last_insert_rowid(sqlite3 *db){\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( !sqlite3SafetyCheckOk(db) ){\n    (void)SQLITE_MISUSE_BKPT;\n    return 0;\n  }\n#endif\n  return db->lastRowid;\n}\n\n/*\n** Set the value returned by the sqlite3_last_insert_rowid() API function.\n*/\nSQLITE_API void sqlite3_set_last_insert_rowid(sqlite3 *db, sqlite3_int64 iRowid){\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( !sqlite3SafetyCheckOk(db) ){\n    (void)SQLITE_MISUSE_BKPT;\n    return;\n  }\n#endif\n  sqlite3_mutex_enter(db->mutex);\n  db->lastRowid = iRowid;\n  sqlite3_mutex_leave(db->mutex);\n}\n\n/*\n** Return the number of changes in the most recent call to sqlite3_exec().\n*/\nSQLITE_API int sqlite3_changes(sqlite3 *db){\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( !sqlite3SafetyCheckOk(db) ){\n    (void)SQLITE_MISUSE_BKPT;\n    return 0;\n  }\n#endif\n  return db->nChange;\n}\n\n/*\n** Return the number of changes since the database handle was opened.\n*/\nSQLITE_API int sqlite3_total_changes(sqlite3 *db){\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( !sqlite3SafetyCheckOk(db) ){\n    (void)SQLITE_MISUSE_BKPT;\n    return 0;\n  }\n#endif\n  return db->nTotalChange;\n}\n\n/*\n** Close all open savepoints. This function only manipulates fields of the\n** database handle object, it does not close any savepoints that may be open\n** at the b-tree/pager level.\n*/\nSQLITE_PRIVATE void sqlite3CloseSavepoints(sqlite3 *db){\n  while( db->pSavepoint ){\n    Savepoint *pTmp = db->pSavepoint;\n    db->pSavepoint = pTmp->pNext;\n    sqlite3DbFree(db, pTmp);\n  }\n  db->nSavepoint = 0;\n  db->nStatement = 0;\n  db->isTransactionSavepoint = 0;\n}\n\n/*\n** Invoke the destructor function associated with FuncDef p, if any. Except,\n** if this is not the last copy of the function, do not invoke it. Multiple\n** copies of a single function are created when create_function() is called\n** with SQLITE_ANY as the encoding.\n*/\nstatic void functionDestroy(sqlite3 *db, FuncDef *p){\n  FuncDestructor *pDestructor = p->u.pDestructor;\n  if( pDestructor ){\n    pDestructor->nRef--;\n    if( pDestructor->nRef==0 ){\n      pDestructor->xDestroy(pDestructor->pUserData);\n      sqlite3DbFree(db, pDestructor);\n    }\n  }\n}\n\n/*\n** Disconnect all sqlite3_vtab objects that belong to database connection\n** db. This is called when db is being closed.\n*/\nstatic void disconnectAllVtab(sqlite3 *db){\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n  int i;\n  HashElem *p;\n  sqlite3BtreeEnterAll(db);\n  for(i=0; i<db->nDb; i++){\n    Schema *pSchema = db->aDb[i].pSchema;\n    if( pSchema ){\n      for(p=sqliteHashFirst(&pSchema->tblHash); p; p=sqliteHashNext(p)){\n        Table *pTab = (Table *)sqliteHashData(p);\n        if( IsVirtual(pTab) ) sqlite3VtabDisconnect(db, pTab);\n      }\n    }\n  }\n  for(p=sqliteHashFirst(&db->aModule); p; p=sqliteHashNext(p)){\n    Module *pMod = (Module *)sqliteHashData(p);\n    if( pMod->pEpoTab ){\n      sqlite3VtabDisconnect(db, pMod->pEpoTab);\n    }\n  }\n  sqlite3VtabUnlockList(db);\n  sqlite3BtreeLeaveAll(db);\n#else\n  UNUSED_PARAMETER(db);\n#endif\n}\n\n/*\n** Return TRUE if database connection db has unfinalized prepared\n** statements or unfinished sqlite3_backup objects.  \n*/\nstatic int connectionIsBusy(sqlite3 *db){\n  int j;\n  assert( sqlite3_mutex_held(db->mutex) );\n  if( db->pVdbe ) return 1;\n  for(j=0; j<db->nDb; j++){\n    Btree *pBt = db->aDb[j].pBt;\n    if( pBt && sqlite3BtreeIsInBackup(pBt) ) return 1;\n  }\n  return 0;\n}\n\n/*\n** Close an existing SQLite database\n*/\nstatic int sqlite3Close(sqlite3 *db, int forceZombie){\n  if( !db ){\n    /* EVIDENCE-OF: R-63257-11740 Calling sqlite3_close() or\n    ** sqlite3_close_v2() with a NULL pointer argument is a harmless no-op. */\n    return SQLITE_OK;\n  }\n  if( !sqlite3SafetyCheckSickOrOk(db) ){\n    return SQLITE_MISUSE_BKPT;\n  }\n  sqlite3_mutex_enter(db->mutex);\n  if( db->mTrace & SQLITE_TRACE_CLOSE ){\n    db->xTrace(SQLITE_TRACE_CLOSE, db->pTraceArg, db, 0);\n  }\n\n  /* Force xDisconnect calls on all virtual tables */\n  disconnectAllVtab(db);\n\n  /* If a transaction is open, the disconnectAllVtab() call above\n  ** will not have called the xDisconnect() method on any virtual\n  ** tables in the db->aVTrans[] array. The following sqlite3VtabRollback()\n  ** call will do so. We need to do this before the check for active\n  ** SQL statements below, as the v-table implementation may be storing\n  ** some prepared statements internally.\n  */\n  sqlite3VtabRollback(db);\n\n  /* Legacy behavior (sqlite3_close() behavior) is to return\n  ** SQLITE_BUSY if the connection can not be closed immediately.\n  */\n  if( !forceZombie && connectionIsBusy(db) ){\n    sqlite3ErrorWithMsg(db, SQLITE_BUSY, \"unable to close due to unfinalized \"\n       \"statements or unfinished backups\");\n    sqlite3_mutex_leave(db->mutex);\n    return SQLITE_BUSY;\n  }\n\n#ifdef SQLITE_ENABLE_SQLLOG\n  if( sqlite3GlobalConfig.xSqllog ){\n    /* Closing the handle. Fourth parameter is passed the value 2. */\n    sqlite3GlobalConfig.xSqllog(sqlite3GlobalConfig.pSqllogArg, db, 0, 2);\n  }\n#endif\n\n  /* Convert the connection into a zombie and then close it.\n  */\n  db->magic = SQLITE_MAGIC_ZOMBIE;\n  sqlite3LeaveMutexAndCloseZombie(db);\n  return SQLITE_OK;\n}\n\n/*\n** Two variations on the public interface for closing a database\n** connection. The sqlite3_close() version returns SQLITE_BUSY and\n** leaves the connection option if there are unfinalized prepared\n** statements or unfinished sqlite3_backups.  The sqlite3_close_v2()\n** version forces the connection to become a zombie if there are\n** unclosed resources, and arranges for deallocation when the last\n** prepare statement or sqlite3_backup closes.\n*/\nSQLITE_API int sqlite3_close(sqlite3 *db){ return sqlite3Close(db,0); }\nSQLITE_API int sqlite3_close_v2(sqlite3 *db){ return sqlite3Close(db,1); }\n\n\n/*\n** Close the mutex on database connection db.\n**\n** Furthermore, if database connection db is a zombie (meaning that there\n** has been a prior call to sqlite3_close(db) or sqlite3_close_v2(db)) and\n** every sqlite3_stmt has now been finalized and every sqlite3_backup has\n** finished, then free all resources.\n*/\nSQLITE_PRIVATE void sqlite3LeaveMutexAndCloseZombie(sqlite3 *db){\n  HashElem *i;                    /* Hash table iterator */\n  int j;\n\n  /* If there are outstanding sqlite3_stmt or sqlite3_backup objects\n  ** or if the connection has not yet been closed by sqlite3_close_v2(),\n  ** then just leave the mutex and return.\n  */\n  if( db->magic!=SQLITE_MAGIC_ZOMBIE || connectionIsBusy(db) ){\n    sqlite3_mutex_leave(db->mutex);\n    return;\n  }\n\n  /* If we reach this point, it means that the database connection has\n  ** closed all sqlite3_stmt and sqlite3_backup objects and has been\n  ** passed to sqlite3_close (meaning that it is a zombie).  Therefore,\n  ** go ahead and free all resources.\n  */\n\n  /* If a transaction is open, roll it back. This also ensures that if\n  ** any database schemas have been modified by an uncommitted transaction\n  ** they are reset. And that the required b-tree mutex is held to make\n  ** the pager rollback and schema reset an atomic operation. */\n  sqlite3RollbackAll(db, SQLITE_OK);\n\n  /* Free any outstanding Savepoint structures. */\n  sqlite3CloseSavepoints(db);\n\n  /* Close all database connections */\n  for(j=0; j<db->nDb; j++){\n    struct Db *pDb = &db->aDb[j];\n    if( pDb->pBt ){\n      sqlite3BtreeClose(pDb->pBt);\n      pDb->pBt = 0;\n      if( j!=1 ){\n        pDb->pSchema = 0;\n      }\n    }\n  }\n  /* Clear the TEMP schema separately and last */\n  if( db->aDb[1].pSchema ){\n    sqlite3SchemaClear(db->aDb[1].pSchema);\n  }\n  sqlite3VtabUnlockList(db);\n\n  /* Free up the array of auxiliary databases */\n  sqlite3CollapseDatabaseArray(db);\n  assert( db->nDb<=2 );\n  assert( db->aDb==db->aDbStatic );\n\n  /* Tell the code in notify.c that the connection no longer holds any\n  ** locks and does not require any further unlock-notify callbacks.\n  */\n  sqlite3ConnectionClosed(db);\n\n  for(i=sqliteHashFirst(&db->aFunc); i; i=sqliteHashNext(i)){\n    FuncDef *pNext, *p;\n    p = sqliteHashData(i);\n    do{\n      functionDestroy(db, p);\n      pNext = p->pNext;\n      sqlite3DbFree(db, p);\n      p = pNext;\n    }while( p );\n  }\n  sqlite3HashClear(&db->aFunc);\n  for(i=sqliteHashFirst(&db->aCollSeq); i; i=sqliteHashNext(i)){\n    CollSeq *pColl = (CollSeq *)sqliteHashData(i);\n    /* Invoke any destructors registered for collation sequence user data. */\n    for(j=0; j<3; j++){\n      if( pColl[j].xDel ){\n        pColl[j].xDel(pColl[j].pUser);\n      }\n    }\n    sqlite3DbFree(db, pColl);\n  }\n  sqlite3HashClear(&db->aCollSeq);\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n  for(i=sqliteHashFirst(&db->aModule); i; i=sqliteHashNext(i)){\n    Module *pMod = (Module *)sqliteHashData(i);\n    if( pMod->xDestroy ){\n      pMod->xDestroy(pMod->pAux);\n    }\n    sqlite3VtabEponymousTableClear(db, pMod);\n    sqlite3DbFree(db, pMod);\n  }\n  sqlite3HashClear(&db->aModule);\n#endif\n\n  sqlite3Error(db, SQLITE_OK); /* Deallocates any cached error strings. */\n  sqlite3ValueFree(db->pErr);\n  sqlite3CloseExtensions(db);\n#if SQLITE_USER_AUTHENTICATION\n  sqlite3_free(db->auth.zAuthUser);\n  sqlite3_free(db->auth.zAuthPW);\n#endif\n\n  db->magic = SQLITE_MAGIC_ERROR;\n\n  /* The temp-database schema is allocated differently from the other schema\n  ** objects (using sqliteMalloc() directly, instead of sqlite3BtreeSchema()).\n  ** So it needs to be freed here. Todo: Why not roll the temp schema into\n  ** the same sqliteMalloc() as the one that allocates the database \n  ** structure?\n  */\n  sqlite3DbFree(db, db->aDb[1].pSchema);\n  sqlite3_mutex_leave(db->mutex);\n  db->magic = SQLITE_MAGIC_CLOSED;\n  sqlite3_mutex_free(db->mutex);\n  assert( sqlite3LookasideUsed(db,0)==0 );\n  if( db->lookaside.bMalloced ){\n    sqlite3_free(db->lookaside.pStart);\n  }\n  sqlite3_free(db);\n}\n\n/*\n** Rollback all database files.  If tripCode is not SQLITE_OK, then\n** any write cursors are invalidated (\"tripped\" - as in \"tripping a circuit\n** breaker\") and made to return tripCode if there are any further\n** attempts to use that cursor.  Read cursors remain open and valid\n** but are \"saved\" in case the table pages are moved around.\n*/\nSQLITE_PRIVATE void sqlite3RollbackAll(sqlite3 *db, int tripCode){\n  int i;\n  int inTrans = 0;\n  int schemaChange;\n  assert( sqlite3_mutex_held(db->mutex) );\n  sqlite3BeginBenignMalloc();\n\n  /* Obtain all b-tree mutexes before making any calls to BtreeRollback(). \n  ** This is important in case the transaction being rolled back has\n  ** modified the database schema. If the b-tree mutexes are not taken\n  ** here, then another shared-cache connection might sneak in between\n  ** the database rollback and schema reset, which can cause false\n  ** corruption reports in some cases.  */\n  sqlite3BtreeEnterAll(db);\n  schemaChange = (db->mDbFlags & DBFLAG_SchemaChange)!=0 && db->init.busy==0;\n\n  for(i=0; i<db->nDb; i++){\n    Btree *p = db->aDb[i].pBt;\n    if( p ){\n      if( sqlite3BtreeIsInTrans(p) ){\n        inTrans = 1;\n      }\n      sqlite3BtreeRollback(p, tripCode, !schemaChange);\n    }\n  }\n  sqlite3VtabRollback(db);\n  sqlite3EndBenignMalloc();\n\n  if( schemaChange ){\n    sqlite3ExpirePreparedStatements(db, 0);\n    sqlite3ResetAllSchemasOfConnection(db);\n  }\n  sqlite3BtreeLeaveAll(db);\n\n  /* Any deferred constraint violations have now been resolved. */\n  db->nDeferredCons = 0;\n  db->nDeferredImmCons = 0;\n  db->flags &= ~(u64)SQLITE_DeferFKs;\n\n  /* If one has been configured, invoke the rollback-hook callback */\n  if( db->xRollbackCallback && (inTrans || !db->autoCommit) ){\n    db->xRollbackCallback(db->pRollbackArg);\n  }\n}\n\n/*\n** Return a static string containing the name corresponding to the error code\n** specified in the argument.\n*/\n#if defined(SQLITE_NEED_ERR_NAME)\nSQLITE_PRIVATE const char *sqlite3ErrName(int rc){\n  const char *zName = 0;\n  int i, origRc = rc;\n  for(i=0; i<2 && zName==0; i++, rc &= 0xff){\n    switch( rc ){\n      case SQLITE_OK:                 zName = \"SQLITE_OK\";                break;\n      case SQLITE_ERROR:              zName = \"SQLITE_ERROR\";             break;\n      case SQLITE_ERROR_SNAPSHOT:     zName = \"SQLITE_ERROR_SNAPSHOT\";    break;\n      case SQLITE_INTERNAL:           zName = \"SQLITE_INTERNAL\";          break;\n      case SQLITE_PERM:               zName = \"SQLITE_PERM\";              break;\n      case SQLITE_ABORT:              zName = \"SQLITE_ABORT\";             break;\n      case SQLITE_ABORT_ROLLBACK:     zName = \"SQLITE_ABORT_ROLLBACK\";    break;\n      case SQLITE_BUSY:               zName = \"SQLITE_BUSY\";              break;\n      case SQLITE_BUSY_RECOVERY:      zName = \"SQLITE_BUSY_RECOVERY\";     break;\n      case SQLITE_BUSY_SNAPSHOT:      zName = \"SQLITE_BUSY_SNAPSHOT\";     break;\n      case SQLITE_LOCKED:             zName = \"SQLITE_LOCKED\";            break;\n      case SQLITE_LOCKED_SHAREDCACHE: zName = \"SQLITE_LOCKED_SHAREDCACHE\";break;\n      case SQLITE_NOMEM:              zName = \"SQLITE_NOMEM\";             break;\n      case SQLITE_READONLY:           zName = \"SQLITE_READONLY\";          break;\n      case SQLITE_READONLY_RECOVERY:  zName = \"SQLITE_READONLY_RECOVERY\"; break;\n      case SQLITE_READONLY_CANTINIT:  zName = \"SQLITE_READONLY_CANTINIT\"; break;\n      case SQLITE_READONLY_ROLLBACK:  zName = \"SQLITE_READONLY_ROLLBACK\"; break;\n      case SQLITE_READONLY_DBMOVED:   zName = \"SQLITE_READONLY_DBMOVED\";  break;\n      case SQLITE_READONLY_DIRECTORY: zName = \"SQLITE_READONLY_DIRECTORY\";break;\n      case SQLITE_INTERRUPT:          zName = \"SQLITE_INTERRUPT\";         break;\n      case SQLITE_IOERR:              zName = \"SQLITE_IOERR\";             break;\n      case SQLITE_IOERR_READ:         zName = \"SQLITE_IOERR_READ\";        break;\n      case SQLITE_IOERR_SHORT_READ:   zName = \"SQLITE_IOERR_SHORT_READ\";  break;\n      case SQLITE_IOERR_WRITE:        zName = \"SQLITE_IOERR_WRITE\";       break;\n      case SQLITE_IOERR_FSYNC:        zName = \"SQLITE_IOERR_FSYNC\";       break;\n      case SQLITE_IOERR_DIR_FSYNC:    zName = \"SQLITE_IOERR_DIR_FSYNC\";   break;\n      case SQLITE_IOERR_TRUNCATE:     zName = \"SQLITE_IOERR_TRUNCATE\";    break;\n      case SQLITE_IOERR_FSTAT:        zName = \"SQLITE_IOERR_FSTAT\";       break;\n      case SQLITE_IOERR_UNLOCK:       zName = \"SQLITE_IOERR_UNLOCK\";      break;\n      case SQLITE_IOERR_RDLOCK:       zName = \"SQLITE_IOERR_RDLOCK\";      break;\n      case SQLITE_IOERR_DELETE:       zName = \"SQLITE_IOERR_DELETE\";      break;\n      case SQLITE_IOERR_NOMEM:        zName = \"SQLITE_IOERR_NOMEM\";       break;\n      case SQLITE_IOERR_ACCESS:       zName = \"SQLITE_IOERR_ACCESS\";      break;\n      case SQLITE_IOERR_CHECKRESERVEDLOCK:\n                                zName = \"SQLITE_IOERR_CHECKRESERVEDLOCK\"; break;\n      case SQLITE_IOERR_LOCK:         zName = \"SQLITE_IOERR_LOCK\";        break;\n      case SQLITE_IOERR_CLOSE:        zName = \"SQLITE_IOERR_CLOSE\";       break;\n      case SQLITE_IOERR_DIR_CLOSE:    zName = \"SQLITE_IOERR_DIR_CLOSE\";   break;\n      case SQLITE_IOERR_SHMOPEN:      zName = \"SQLITE_IOERR_SHMOPEN\";     break;\n      case SQLITE_IOERR_SHMSIZE:      zName = \"SQLITE_IOERR_SHMSIZE\";     break;\n      case SQLITE_IOERR_SHMLOCK:      zName = \"SQLITE_IOERR_SHMLOCK\";     break;\n      case SQLITE_IOERR_SHMMAP:       zName = \"SQLITE_IOERR_SHMMAP\";      break;\n      case SQLITE_IOERR_SEEK:         zName = \"SQLITE_IOERR_SEEK\";        break;\n      case SQLITE_IOERR_DELETE_NOENT: zName = \"SQLITE_IOERR_DELETE_NOENT\";break;\n      case SQLITE_IOERR_MMAP:         zName = \"SQLITE_IOERR_MMAP\";        break;\n      case SQLITE_IOERR_GETTEMPPATH:  zName = \"SQLITE_IOERR_GETTEMPPATH\"; break;\n      case SQLITE_IOERR_CONVPATH:     zName = \"SQLITE_IOERR_CONVPATH\";    break;\n      case SQLITE_CORRUPT:            zName = \"SQLITE_CORRUPT\";           break;\n      case SQLITE_CORRUPT_VTAB:       zName = \"SQLITE_CORRUPT_VTAB\";      break;\n      case SQLITE_NOTFOUND:           zName = \"SQLITE_NOTFOUND\";          break;\n      case SQLITE_FULL:               zName = \"SQLITE_FULL\";              break;\n      case SQLITE_CANTOPEN:           zName = \"SQLITE_CANTOPEN\";          break;\n      case SQLITE_CANTOPEN_NOTEMPDIR: zName = \"SQLITE_CANTOPEN_NOTEMPDIR\";break;\n      case SQLITE_CANTOPEN_ISDIR:     zName = \"SQLITE_CANTOPEN_ISDIR\";    break;\n      case SQLITE_CANTOPEN_FULLPATH:  zName = \"SQLITE_CANTOPEN_FULLPATH\"; break;\n      case SQLITE_CANTOPEN_CONVPATH:  zName = \"SQLITE_CANTOPEN_CONVPATH\"; break;\n      case SQLITE_PROTOCOL:           zName = \"SQLITE_PROTOCOL\";          break;\n      case SQLITE_EMPTY:              zName = \"SQLITE_EMPTY\";             break;\n      case SQLITE_SCHEMA:             zName = \"SQLITE_SCHEMA\";            break;\n      case SQLITE_TOOBIG:             zName = \"SQLITE_TOOBIG\";            break;\n      case SQLITE_CONSTRAINT:         zName = \"SQLITE_CONSTRAINT\";        break;\n      case SQLITE_CONSTRAINT_UNIQUE:  zName = \"SQLITE_CONSTRAINT_UNIQUE\"; break;\n      case SQLITE_CONSTRAINT_TRIGGER: zName = \"SQLITE_CONSTRAINT_TRIGGER\";break;\n      case SQLITE_CONSTRAINT_FOREIGNKEY:\n                                zName = \"SQLITE_CONSTRAINT_FOREIGNKEY\";   break;\n      case SQLITE_CONSTRAINT_CHECK:   zName = \"SQLITE_CONSTRAINT_CHECK\";  break;\n      case SQLITE_CONSTRAINT_PRIMARYKEY:\n                                zName = \"SQLITE_CONSTRAINT_PRIMARYKEY\";   break;\n      case SQLITE_CONSTRAINT_NOTNULL: zName = \"SQLITE_CONSTRAINT_NOTNULL\";break;\n      case SQLITE_CONSTRAINT_COMMITHOOK:\n                                zName = \"SQLITE_CONSTRAINT_COMMITHOOK\";   break;\n      case SQLITE_CONSTRAINT_VTAB:    zName = \"SQLITE_CONSTRAINT_VTAB\";   break;\n      case SQLITE_CONSTRAINT_FUNCTION:\n                                zName = \"SQLITE_CONSTRAINT_FUNCTION\";     break;\n      case SQLITE_CONSTRAINT_ROWID:   zName = \"SQLITE_CONSTRAINT_ROWID\";  break;\n      case SQLITE_MISMATCH:           zName = \"SQLITE_MISMATCH\";          break;\n      case SQLITE_MISUSE:             zName = \"SQLITE_MISUSE\";            break;\n      case SQLITE_NOLFS:              zName = \"SQLITE_NOLFS\";             break;\n      case SQLITE_AUTH:               zName = \"SQLITE_AUTH\";              break;\n      case SQLITE_FORMAT:             zName = \"SQLITE_FORMAT\";            break;\n      case SQLITE_RANGE:              zName = \"SQLITE_RANGE\";             break;\n      case SQLITE_NOTADB:             zName = \"SQLITE_NOTADB\";            break;\n      case SQLITE_ROW:                zName = \"SQLITE_ROW\";               break;\n      case SQLITE_NOTICE:             zName = \"SQLITE_NOTICE\";            break;\n      case SQLITE_NOTICE_RECOVER_WAL: zName = \"SQLITE_NOTICE_RECOVER_WAL\";break;\n      case SQLITE_NOTICE_RECOVER_ROLLBACK:\n                                zName = \"SQLITE_NOTICE_RECOVER_ROLLBACK\"; break;\n      case SQLITE_WARNING:            zName = \"SQLITE_WARNING\";           break;\n      case SQLITE_WARNING_AUTOINDEX:  zName = \"SQLITE_WARNING_AUTOINDEX\"; break;\n      case SQLITE_DONE:               zName = \"SQLITE_DONE\";              break;\n    }\n  }\n  if( zName==0 ){\n    static char zBuf[50];\n    sqlite3_snprintf(sizeof(zBuf), zBuf, \"SQLITE_UNKNOWN(%d)\", origRc);\n    zName = zBuf;\n  }\n  return zName;\n}\n#endif\n\n/*\n** Return a static string that describes the kind of error specified in the\n** argument.\n*/\nSQLITE_PRIVATE const char *sqlite3ErrStr(int rc){\n  static const char* const aMsg[] = {\n    /* SQLITE_OK          */ \"not an error\",\n    /* SQLITE_ERROR       */ \"SQL logic error\",\n    /* SQLITE_INTERNAL    */ 0,\n    /* SQLITE_PERM        */ \"access permission denied\",\n    /* SQLITE_ABORT       */ \"query aborted\",\n    /* SQLITE_BUSY        */ \"database is locked\",\n    /* SQLITE_LOCKED      */ \"database table is locked\",\n    /* SQLITE_NOMEM       */ \"out of memory\",\n    /* SQLITE_READONLY    */ \"attempt to write a readonly database\",\n    /* SQLITE_INTERRUPT   */ \"interrupted\",\n    /* SQLITE_IOERR       */ \"disk I/O error\",\n    /* SQLITE_CORRUPT     */ \"database disk image is malformed\",\n    /* SQLITE_NOTFOUND    */ \"unknown operation\",\n    /* SQLITE_FULL        */ \"database or disk is full\",\n    /* SQLITE_CANTOPEN    */ \"unable to open database file\",\n    /* SQLITE_PROTOCOL    */ \"locking protocol\",\n    /* SQLITE_EMPTY       */ 0,\n    /* SQLITE_SCHEMA      */ \"database schema has changed\",\n    /* SQLITE_TOOBIG      */ \"string or blob too big\",\n    /* SQLITE_CONSTRAINT  */ \"constraint failed\",\n    /* SQLITE_MISMATCH    */ \"datatype mismatch\",\n    /* SQLITE_MISUSE      */ \"bad parameter or other API misuse\",\n#ifdef SQLITE_DISABLE_LFS\n    /* SQLITE_NOLFS       */ \"large file support is disabled\",\n#else\n    /* SQLITE_NOLFS       */ 0,\n#endif\n    /* SQLITE_AUTH        */ \"authorization denied\",\n    /* SQLITE_FORMAT      */ 0,\n    /* SQLITE_RANGE       */ \"column index out of range\",\n    /* SQLITE_NOTADB      */ \"file is not a database\",\n    /* SQLITE_NOTICE      */ \"notification message\",\n    /* SQLITE_WARNING     */ \"warning message\",\n  };\n  const char *zErr = \"unknown error\";\n  switch( rc ){\n    case SQLITE_ABORT_ROLLBACK: {\n      zErr = \"abort due to ROLLBACK\";\n      break;\n    }\n    case SQLITE_ROW: {\n      zErr = \"another row available\";\n      break;\n    }\n    case SQLITE_DONE: {\n      zErr = \"no more rows available\";\n      break;\n    }\n    default: {\n      rc &= 0xff;\n      if( ALWAYS(rc>=0) && rc<ArraySize(aMsg) && aMsg[rc]!=0 ){\n        zErr = aMsg[rc];\n      }\n      break;\n    }\n  }\n  return zErr;\n}\n\n/*\n** This routine implements a busy callback that sleeps and tries\n** again until a timeout value is reached.  The timeout value is\n** an integer number of milliseconds passed in as the first\n** argument.\n**\n** Return non-zero to retry the lock.  Return zero to stop trying\n** and cause SQLite to return SQLITE_BUSY.\n*/\nstatic int sqliteDefaultBusyCallback(\n  void *ptr,               /* Database connection */\n  int count,               /* Number of times table has been busy */\n  sqlite3_file *pFile      /* The file on which the lock occurred */\n){\n#if SQLITE_OS_WIN || HAVE_USLEEP\n  /* This case is for systems that have support for sleeping for fractions of\n  ** a second.  Examples:  All windows systems, unix systems with usleep() */\n  static const u8 delays[] =\n     { 1, 2, 5, 10, 15, 20, 25, 25,  25,  50,  50, 100 };\n  static const u8 totals[] =\n     { 0, 1, 3,  8, 18, 33, 53, 78, 103, 128, 178, 228 };\n# define NDELAY ArraySize(delays)\n  sqlite3 *db = (sqlite3 *)ptr;\n  int tmout = db->busyTimeout;\n  int delay, prior;\n\n#ifdef SQLITE_ENABLE_SETLK_TIMEOUT\n  if( sqlite3OsFileControl(pFile,SQLITE_FCNTL_LOCK_TIMEOUT,&tmout)==SQLITE_OK ){\n    if( count ){\n      tmout = 0;\n      sqlite3OsFileControl(pFile, SQLITE_FCNTL_LOCK_TIMEOUT, &tmout);\n      return 0;\n    }else{\n      return 1;\n    }\n  }\n#else\n  UNUSED_PARAMETER(pFile);\n#endif\n  assert( count>=0 );\n  if( count < NDELAY ){\n    delay = delays[count];\n    prior = totals[count];\n  }else{\n    delay = delays[NDELAY-1];\n    prior = totals[NDELAY-1] + delay*(count-(NDELAY-1));\n  }\n  if( prior + delay > tmout ){\n    delay = tmout - prior;\n    if( delay<=0 ) return 0;\n  }\n  sqlite3OsSleep(db->pVfs, delay*1000);\n  return 1;\n#else\n  /* This case for unix systems that lack usleep() support.  Sleeping\n  ** must be done in increments of whole seconds */\n  sqlite3 *db = (sqlite3 *)ptr;\n  int tmout = ((sqlite3 *)ptr)->busyTimeout;\n  UNUSED_PARAMETER(pFile);\n  if( (count+1)*1000 > tmout ){\n    return 0;\n  }\n  sqlite3OsSleep(db->pVfs, 1000000);\n  return 1;\n#endif\n}\n\n/*\n** Invoke the given busy handler.\n**\n** This routine is called when an operation failed to acquire a\n** lock on VFS file pFile.\n**\n** If this routine returns non-zero, the lock is retried.  If it\n** returns 0, the operation aborts with an SQLITE_BUSY error.\n*/\nSQLITE_PRIVATE int sqlite3InvokeBusyHandler(BusyHandler *p, sqlite3_file *pFile){\n  int rc;\n  if( p->xBusyHandler==0 || p->nBusy<0 ) return 0;\n  if( p->bExtraFileArg ){\n    /* Add an extra parameter with the pFile pointer to the end of the\n    ** callback argument list */\n    int (*xTra)(void*,int,sqlite3_file*);\n    xTra = (int(*)(void*,int,sqlite3_file*))p->xBusyHandler;\n    rc = xTra(p->pBusyArg, p->nBusy, pFile);\n  }else{\n    /* Legacy style busy handler callback */\n    rc = p->xBusyHandler(p->pBusyArg, p->nBusy);\n  }\n  if( rc==0 ){\n    p->nBusy = -1;\n  }else{\n    p->nBusy++;\n  }\n  return rc; \n}\n\n/*\n** This routine sets the busy callback for an Sqlite database to the\n** given callback function with the given argument.\n*/\nSQLITE_API int sqlite3_busy_handler(\n  sqlite3 *db,\n  int (*xBusy)(void*,int),\n  void *pArg\n){\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( !sqlite3SafetyCheckOk(db) ) return SQLITE_MISUSE_BKPT;\n#endif\n  sqlite3_mutex_enter(db->mutex);\n  db->busyHandler.xBusyHandler = xBusy;\n  db->busyHandler.pBusyArg = pArg;\n  db->busyHandler.nBusy = 0;\n  db->busyHandler.bExtraFileArg = 0;\n  db->busyTimeout = 0;\n  sqlite3_mutex_leave(db->mutex);\n  return SQLITE_OK;\n}\n\n#ifndef SQLITE_OMIT_PROGRESS_CALLBACK\n/*\n** This routine sets the progress callback for an Sqlite database to the\n** given callback function with the given argument. The progress callback will\n** be invoked every nOps opcodes.\n*/\nSQLITE_API void sqlite3_progress_handler(\n  sqlite3 *db, \n  int nOps,\n  int (*xProgress)(void*), \n  void *pArg\n){\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( !sqlite3SafetyCheckOk(db) ){\n    (void)SQLITE_MISUSE_BKPT;\n    return;\n  }\n#endif\n  sqlite3_mutex_enter(db->mutex);\n  if( nOps>0 ){\n    db->xProgress = xProgress;\n    db->nProgressOps = (unsigned)nOps;\n    db->pProgressArg = pArg;\n  }else{\n    db->xProgress = 0;\n    db->nProgressOps = 0;\n    db->pProgressArg = 0;\n  }\n  sqlite3_mutex_leave(db->mutex);\n}\n#endif\n\n\n/*\n** This routine installs a default busy handler that waits for the\n** specified number of milliseconds before returning 0.\n*/\nSQLITE_API int sqlite3_busy_timeout(sqlite3 *db, int ms){\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( !sqlite3SafetyCheckOk(db) ) return SQLITE_MISUSE_BKPT;\n#endif\n  if( ms>0 ){\n    sqlite3_busy_handler(db, (int(*)(void*,int))sqliteDefaultBusyCallback,\n                             (void*)db);\n    db->busyTimeout = ms;\n    db->busyHandler.bExtraFileArg = 1;\n  }else{\n    sqlite3_busy_handler(db, 0, 0);\n  }\n  return SQLITE_OK;\n}\n\n\n/*\n** Cause any pending operation to stop at its earliest opportunity.\n*/\nSQLITE_API void sqlite3_interrupt(sqlite3 *db){\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( !sqlite3SafetyCheckOk(db) && (db==0 || db->magic!=SQLITE_MAGIC_ZOMBIE) ){\n    (void)SQLITE_MISUSE_BKPT;\n    return;\n  }\n#endif\n  db->u1.isInterrupted = 1;\n}\n\n#ifdef SQLITE_WCDB_SUSPEND\nSQLITE_API void sqlite3_suspend(sqlite3 *db, int suspend){\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( !sqlite3SafetyCheckOk(db) && (db==0 || db->magic!=SQLITE_MAGIC_ZOMBIE) ){\n    (void)SQLITE_MISUSE_BKPT;\n    return;\n  }\n#endif\n  db->suspended = !!suspend;\n}\n\nSQLITE_API void sqlite3_unimpeded(sqlite3 *db, int unimpeded)\n{\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( !sqlite3SafetyCheckOk(db) && (db==0 || db->magic!=SQLITE_MAGIC_ZOMBIE) ){\n    (void)SQLITE_MISUSE_BKPT;\n    return;\n  }\n#endif\n  db->unimpeded = !!unimpeded;\n}\n#endif\n\nSQLITE_API void sqlite3_revertCommitOrder(sqlite3 *db)\n{\n    if(db == NULL){\n        return;\n    }\n    db->revertCommit = 1;\n}\n\n/*\n** This function is exactly the same as sqlite3_create_function(), except\n** that it is designed to be called by internal code. The difference is\n** that if a malloc() fails in sqlite3_create_function(), an error code\n** is returned and the mallocFailed flag cleared. \n*/\nSQLITE_PRIVATE int sqlite3CreateFunc(\n  sqlite3 *db,\n  const char *zFunctionName,\n  int nArg,\n  int enc,\n  void *pUserData,\n  void (*xSFunc)(sqlite3_context*,int,sqlite3_value **),\n  void (*xStep)(sqlite3_context*,int,sqlite3_value **),\n  void (*xFinal)(sqlite3_context*),\n  void (*xValue)(sqlite3_context*),\n  void (*xInverse)(sqlite3_context*,int,sqlite3_value **),\n  FuncDestructor *pDestructor\n){\n  FuncDef *p;\n  int nName;\n  int extraFlags;\n\n  assert( sqlite3_mutex_held(db->mutex) );\n  assert( xValue==0 || xSFunc==0 );\n  if( zFunctionName==0                /* Must have a valid name */\n   || (xSFunc!=0 && xFinal!=0)        /* Not both xSFunc and xFinal */\n   || ((xFinal==0)!=(xStep==0))       /* Both or neither of xFinal and xStep */\n   || ((xValue==0)!=(xInverse==0))    /* Both or neither of xValue, xInverse */\n   || (nArg<-1 || nArg>SQLITE_MAX_FUNCTION_ARG)\n   || (255<(nName = sqlite3Strlen30( zFunctionName)))\n  ){\n    return SQLITE_MISUSE_BKPT;\n  }\n\n  assert( SQLITE_FUNC_CONSTANT==SQLITE_DETERMINISTIC );\n  extraFlags = enc &  SQLITE_DETERMINISTIC;\n  enc &= (SQLITE_FUNC_ENCMASK|SQLITE_ANY);\n  \n#ifndef SQLITE_OMIT_UTF16\n  /* If SQLITE_UTF16 is specified as the encoding type, transform this\n  ** to one of SQLITE_UTF16LE or SQLITE_UTF16BE using the\n  ** SQLITE_UTF16NATIVE macro. SQLITE_UTF16 is not used internally.\n  **\n  ** If SQLITE_ANY is specified, add three versions of the function\n  ** to the hash table.\n  */\n  if( enc==SQLITE_UTF16 ){\n    enc = SQLITE_UTF16NATIVE;\n  }else if( enc==SQLITE_ANY ){\n    int rc;\n    rc = sqlite3CreateFunc(db, zFunctionName, nArg, SQLITE_UTF8|extraFlags,\n         pUserData, xSFunc, xStep, xFinal, xValue, xInverse, pDestructor);\n    if( rc==SQLITE_OK ){\n      rc = sqlite3CreateFunc(db, zFunctionName, nArg, SQLITE_UTF16LE|extraFlags,\n          pUserData, xSFunc, xStep, xFinal, xValue, xInverse, pDestructor);\n    }\n    if( rc!=SQLITE_OK ){\n      return rc;\n    }\n    enc = SQLITE_UTF16BE;\n  }\n#else\n  enc = SQLITE_UTF8;\n#endif\n  \n  /* Check if an existing function is being overridden or deleted. If so,\n  ** and there are active VMs, then return SQLITE_BUSY. If a function\n  ** is being overridden/deleted but there are no active VMs, allow the\n  ** operation to continue but invalidate all precompiled statements.\n  */\n  p = sqlite3FindFunction(db, zFunctionName, nArg, (u8)enc, 0);\n  if( p && (p->funcFlags & SQLITE_FUNC_ENCMASK)==(u32)enc && p->nArg==nArg ){\n    if( db->nVdbeActive ){\n      sqlite3ErrorWithMsg(db, SQLITE_BUSY, \n        \"unable to delete/modify user-function due to active statements\");\n      assert( !db->mallocFailed );\n      return SQLITE_BUSY;\n    }else{\n      sqlite3ExpirePreparedStatements(db, 0);\n    }\n  }\n\n  p = sqlite3FindFunction(db, zFunctionName, nArg, (u8)enc, 1);\n  assert(p || db->mallocFailed);\n  if( !p ){\n    return SQLITE_NOMEM_BKPT;\n  }\n\n  /* If an older version of the function with a configured destructor is\n  ** being replaced invoke the destructor function here. */\n  functionDestroy(db, p);\n\n  if( pDestructor ){\n    pDestructor->nRef++;\n  }\n  p->u.pDestructor = pDestructor;\n  p->funcFlags = (p->funcFlags & SQLITE_FUNC_ENCMASK) | extraFlags;\n  testcase( p->funcFlags & SQLITE_DETERMINISTIC );\n  p->xSFunc = xSFunc ? xSFunc : xStep;\n  p->xFinalize = xFinal;\n  p->xValue = xValue;\n  p->xInverse = xInverse;\n  p->pUserData = pUserData;\n  p->nArg = (u16)nArg;\n  return SQLITE_OK;\n}\n\n/*\n** Worker function used by utf-8 APIs that create new functions:\n**\n**    sqlite3_create_function()\n**    sqlite3_create_function_v2()\n**    sqlite3_create_window_function()\n*/\nstatic int createFunctionApi(\n  sqlite3 *db,\n  const char *zFunc,\n  int nArg,\n  int enc,\n  void *p,\n  void (*xSFunc)(sqlite3_context*,int,sqlite3_value**),\n  void (*xStep)(sqlite3_context*,int,sqlite3_value**),\n  void (*xFinal)(sqlite3_context*),\n  void (*xValue)(sqlite3_context*),\n  void (*xInverse)(sqlite3_context*,int,sqlite3_value**),\n  void(*xDestroy)(void*)\n){\n  int rc = SQLITE_ERROR;\n  FuncDestructor *pArg = 0;\n\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( !sqlite3SafetyCheckOk(db) ){\n    return SQLITE_MISUSE_BKPT;\n  }\n#endif\n  sqlite3_mutex_enter(db->mutex);\n  if( xDestroy ){\n    pArg = (FuncDestructor *)sqlite3Malloc(sizeof(FuncDestructor));\n    if( !pArg ){\n      sqlite3OomFault(db);\n      xDestroy(p);\n      goto out;\n    }\n    pArg->nRef = 0;\n    pArg->xDestroy = xDestroy;\n    pArg->pUserData = p;\n  }\n  rc = sqlite3CreateFunc(db, zFunc, nArg, enc, p, \n      xSFunc, xStep, xFinal, xValue, xInverse, pArg\n  );\n  if( pArg && pArg->nRef==0 ){\n    assert( rc!=SQLITE_OK );\n    xDestroy(p);\n    sqlite3_free(pArg);\n  }\n\n out:\n  rc = sqlite3ApiExit(db, rc);\n  sqlite3_mutex_leave(db->mutex);\n  return rc;\n}\n\n/*\n** Create new user functions.\n*/\nSQLITE_API int sqlite3_create_function(\n  sqlite3 *db,\n  const char *zFunc,\n  int nArg,\n  int enc,\n  void *p,\n  void (*xSFunc)(sqlite3_context*,int,sqlite3_value **),\n  void (*xStep)(sqlite3_context*,int,sqlite3_value **),\n  void (*xFinal)(sqlite3_context*)\n){\n  return createFunctionApi(db, zFunc, nArg, enc, p, xSFunc, xStep,\n                                    xFinal, 0, 0, 0);\n}\nSQLITE_API int sqlite3_create_function_v2(\n  sqlite3 *db,\n  const char *zFunc,\n  int nArg,\n  int enc,\n  void *p,\n  void (*xSFunc)(sqlite3_context*,int,sqlite3_value **),\n  void (*xStep)(sqlite3_context*,int,sqlite3_value **),\n  void (*xFinal)(sqlite3_context*),\n  void (*xDestroy)(void *)\n){\n  return createFunctionApi(db, zFunc, nArg, enc, p, xSFunc, xStep,\n                                    xFinal, 0, 0, xDestroy);\n}\nSQLITE_API int sqlite3_create_window_function(\n  sqlite3 *db,\n  const char *zFunc,\n  int nArg,\n  int enc,\n  void *p,\n  void (*xStep)(sqlite3_context*,int,sqlite3_value **),\n  void (*xFinal)(sqlite3_context*),\n  void (*xValue)(sqlite3_context*),\n  void (*xInverse)(sqlite3_context*,int,sqlite3_value **),\n  void (*xDestroy)(void *)\n){\n  return createFunctionApi(db, zFunc, nArg, enc, p, 0, xStep,\n                                    xFinal, xValue, xInverse, xDestroy);\n}\n\n#ifndef SQLITE_OMIT_UTF16\nSQLITE_API int sqlite3_create_function16(\n  sqlite3 *db,\n  const void *zFunctionName,\n  int nArg,\n  int eTextRep,\n  void *p,\n  void (*xSFunc)(sqlite3_context*,int,sqlite3_value**),\n  void (*xStep)(sqlite3_context*,int,sqlite3_value**),\n  void (*xFinal)(sqlite3_context*)\n){\n  int rc;\n  char *zFunc8;\n\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( !sqlite3SafetyCheckOk(db) || zFunctionName==0 ) return SQLITE_MISUSE_BKPT;\n#endif\n  sqlite3_mutex_enter(db->mutex);\n  assert( !db->mallocFailed );\n  zFunc8 = sqlite3Utf16to8(db, zFunctionName, -1, SQLITE_UTF16NATIVE);\n  rc = sqlite3CreateFunc(db, zFunc8, nArg, eTextRep, p, xSFunc,xStep,xFinal,0,0,0);\n  sqlite3DbFree(db, zFunc8);\n  rc = sqlite3ApiExit(db, rc);\n  sqlite3_mutex_leave(db->mutex);\n  return rc;\n}\n#endif\n\n\n/*\n** The following is the implementation of an SQL function that always\n** fails with an error message stating that the function is used in the\n** wrong context.  The sqlite3_overload_function() API might construct\n** SQL function that use this routine so that the functions will exist\n** for name resolution but are actually overloaded by the xFindFunction\n** method of virtual tables.\n*/\nstatic void sqlite3InvalidFunction(\n  sqlite3_context *context,  /* The function calling context */\n  int NotUsed,               /* Number of arguments to the function */\n  sqlite3_value **NotUsed2   /* Value of each argument */\n){\n  const char *zName = (const char*)sqlite3_user_data(context);\n  char *zErr;\n  UNUSED_PARAMETER2(NotUsed, NotUsed2);\n  zErr = sqlite3_mprintf(\n      \"unable to use function %s in the requested context\", zName);\n  sqlite3_result_error(context, zErr, -1);\n  sqlite3_free(zErr);\n}\n\n/*\n** Declare that a function has been overloaded by a virtual table.\n**\n** If the function already exists as a regular global function, then\n** this routine is a no-op.  If the function does not exist, then create\n** a new one that always throws a run-time error.  \n**\n** When virtual tables intend to provide an overloaded function, they\n** should call this routine to make sure the global function exists.\n** A global function must exist in order for name resolution to work\n** properly.\n*/\nSQLITE_API int sqlite3_overload_function(\n  sqlite3 *db,\n  const char *zName,\n  int nArg\n){\n  int rc;\n  char *zCopy;\n\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( !sqlite3SafetyCheckOk(db) || zName==0 || nArg<-2 ){\n    return SQLITE_MISUSE_BKPT;\n  }\n#endif\n  sqlite3_mutex_enter(db->mutex);\n  rc = sqlite3FindFunction(db, zName, nArg, SQLITE_UTF8, 0)!=0;\n  sqlite3_mutex_leave(db->mutex);\n  if( rc ) return SQLITE_OK;\n  zCopy = sqlite3_mprintf(zName);\n  if( zCopy==0 ) return SQLITE_NOMEM;\n  return sqlite3_create_function_v2(db, zName, nArg, SQLITE_UTF8,\n                           zCopy, sqlite3InvalidFunction, 0, 0, sqlite3_free);\n}\n\n#ifndef SQLITE_OMIT_TRACE\n/*\n** Register a trace function.  The pArg from the previously registered trace\n** is returned.  \n**\n** A NULL trace function means that no tracing is executes.  A non-NULL\n** trace is a pointer to a function that is invoked at the start of each\n** SQL statement.\n*/\n#ifndef SQLITE_OMIT_DEPRECATED\nSQLITE_API void *sqlite3_trace(sqlite3 *db, void(*xTrace)(void*,const char*), void *pArg){\n  void *pOld;\n\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( !sqlite3SafetyCheckOk(db) ){\n    (void)SQLITE_MISUSE_BKPT;\n    return 0;\n  }\n#endif\n  sqlite3_mutex_enter(db->mutex);\n  pOld = db->pTraceArg;\n  db->mTrace = xTrace ? SQLITE_TRACE_LEGACY : 0;\n  db->xTrace = (int(*)(u32,void*,void*,void*))xTrace;\n  db->pTraceArg = pArg;\n  sqlite3_mutex_leave(db->mutex);\n  return pOld;\n}\n#endif /* SQLITE_OMIT_DEPRECATED */\n\n/* Register a trace callback using the version-2 interface.\n*/\nSQLITE_API int sqlite3_trace_v2(\n  sqlite3 *db,                               /* Trace this connection */\n  unsigned mTrace,                           /* Mask of events to be traced */\n  int(*xTrace)(unsigned,void*,void*,void*),  /* Callback to invoke */\n  void *pArg                                 /* Context */\n){\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( !sqlite3SafetyCheckOk(db) ){\n    return SQLITE_MISUSE_BKPT;\n  }\n#endif\n  sqlite3_mutex_enter(db->mutex);\n  if( mTrace==0 ) xTrace = 0;\n  if( xTrace==0 ) mTrace = 0;\n  db->mTrace = mTrace;\n  db->xTrace = xTrace;\n  db->pTraceArg = pArg;\n  sqlite3_mutex_leave(db->mutex);\n  return SQLITE_OK;\n}\n\n#ifndef SQLITE_OMIT_DEPRECATED\n/*\n** Register a profile function.  The pArg from the previously registered \n** profile function is returned.  \n**\n** A NULL profile function means that no profiling is executes.  A non-NULL\n** profile is a pointer to a function that is invoked at the conclusion of\n** each SQL statement that is run.\n*/\nSQLITE_API void *sqlite3_profile(\n  sqlite3 *db,\n  void (*xProfile)(void*,const char*,sqlite_uint64),\n  void *pArg\n){\n  void *pOld;\n\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( !sqlite3SafetyCheckOk(db) ){\n    (void)SQLITE_MISUSE_BKPT;\n    return 0;\n  }\n#endif\n  sqlite3_mutex_enter(db->mutex);\n  pOld = db->pProfileArg;\n  db->xProfile = xProfile;\n  db->pProfileArg = pArg;\n  db->mTrace &= SQLITE_TRACE_NONLEGACY_MASK;\n  if( db->xProfile ) db->mTrace |= SQLITE_TRACE_XPROFILE;\n  sqlite3_mutex_leave(db->mutex);\n  return pOld;\n}\n#endif /* SQLITE_OMIT_DEPRECATED */\n#endif /* SQLITE_OMIT_TRACE */\n\n/*\n** Register a function to be invoked when a transaction commits.\n** If the invoked function returns non-zero, then the commit becomes a\n** rollback.\n*/\nSQLITE_API void *sqlite3_commit_hook(\n  sqlite3 *db,              /* Attach the hook to this database */\n  int (*xCallback)(void*),  /* Function to invoke on each commit */\n  void *pArg                /* Argument to the function */\n){\n  void *pOld;\n\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( !sqlite3SafetyCheckOk(db) ){\n    (void)SQLITE_MISUSE_BKPT;\n    return 0;\n  }\n#endif\n  sqlite3_mutex_enter(db->mutex);\n  pOld = db->pCommitArg;\n  db->xCommitCallback = xCallback;\n  db->pCommitArg = pArg;\n  sqlite3_mutex_leave(db->mutex);\n  return pOld;\n}\n\n/*\n** Register a callback to be invoked each time a row is updated,\n** inserted or deleted using this database connection.\n*/\nSQLITE_API void *sqlite3_update_hook(\n  sqlite3 *db,              /* Attach the hook to this database */\n  void (*xCallback)(void*,int,char const *,char const *,sqlite_int64),\n  void *pArg                /* Argument to the function */\n){\n  void *pRet;\n\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( !sqlite3SafetyCheckOk(db) ){\n    (void)SQLITE_MISUSE_BKPT;\n    return 0;\n  }\n#endif\n  sqlite3_mutex_enter(db->mutex);\n  pRet = db->pUpdateArg;\n  db->xUpdateCallback = xCallback;\n  db->pUpdateArg = pArg;\n  sqlite3_mutex_leave(db->mutex);\n  return pRet;\n}\n\n/*\n** Register a callback to be invoked each time a transaction is rolled\n** back by this database connection.\n*/\nSQLITE_API void *sqlite3_rollback_hook(\n  sqlite3 *db,              /* Attach the hook to this database */\n  void (*xCallback)(void*), /* Callback function */\n  void *pArg                /* Argument to the function */\n){\n  void *pRet;\n\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( !sqlite3SafetyCheckOk(db) ){\n    (void)SQLITE_MISUSE_BKPT;\n    return 0;\n  }\n#endif\n  sqlite3_mutex_enter(db->mutex);\n  pRet = db->pRollbackArg;\n  db->xRollbackCallback = xCallback;\n  db->pRollbackArg = pArg;\n  sqlite3_mutex_leave(db->mutex);\n  return pRet;\n}\n\n#ifdef SQLITE_ENABLE_PREUPDATE_HOOK\n/*\n** Register a callback to be invoked each time a row is updated,\n** inserted or deleted using this database connection.\n*/\nSQLITE_API void *sqlite3_preupdate_hook(\n  sqlite3 *db,              /* Attach the hook to this database */\n  void(*xCallback)(         /* Callback function */\n    void*,sqlite3*,int,char const*,char const*,sqlite3_int64,sqlite3_int64),\n  void *pArg                /* First callback argument */\n){\n  void *pRet;\n  sqlite3_mutex_enter(db->mutex);\n  pRet = db->pPreUpdateArg;\n  db->xPreUpdateCallback = xCallback;\n  db->pPreUpdateArg = pArg;\n  sqlite3_mutex_leave(db->mutex);\n  return pRet;\n}\n#endif /* SQLITE_ENABLE_PREUPDATE_HOOK */\n\n#ifndef SQLITE_OMIT_WAL\n/*\n** The sqlite3_wal_hook() callback registered by sqlite3_wal_autocheckpoint().\n** Invoke sqlite3_wal_checkpoint if the number of frames in the log file\n** is greater than sqlite3.pWalArg cast to an integer (the value configured by\n** wal_autocheckpoint()).\n*/ \nSQLITE_PRIVATE int sqlite3WalDefaultHook(\n  void *pClientData,     /* Argument */\n  sqlite3 *db,           /* Connection */\n  const char *zDb,       /* Database */\n  int nFrame             /* Size of WAL */\n){\n  if( nFrame>=SQLITE_PTR_TO_INT(pClientData) ){\n    sqlite3BeginBenignMalloc();\n    sqlite3_wal_checkpoint(db, zDb);\n    sqlite3EndBenignMalloc();\n  }\n  return SQLITE_OK;\n}\n#endif /* SQLITE_OMIT_WAL */\n\n/*\n** Configure an sqlite3_wal_hook() callback to automatically checkpoint\n** a database after committing a transaction if there are nFrame or\n** more frames in the log file. Passing zero or a negative value as the\n** nFrame parameter disables automatic checkpoints entirely.\n**\n** The callback registered by this function replaces any existing callback\n** registered using sqlite3_wal_hook(). Likewise, registering a callback\n** using sqlite3_wal_hook() disables the automatic checkpoint mechanism\n** configured by this function.\n*/\nSQLITE_API int sqlite3_wal_autocheckpoint(sqlite3 *db, int nFrame){\n#ifdef SQLITE_OMIT_WAL\n  UNUSED_PARAMETER(db);\n  UNUSED_PARAMETER(nFrame);\n#else\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( !sqlite3SafetyCheckOk(db) ) return SQLITE_MISUSE_BKPT;\n#endif\n  if( nFrame>0 ){\n    sqlite3_wal_hook(db, sqlite3WalDefaultHook, SQLITE_INT_TO_PTR(nFrame));\n  }else{\n    sqlite3_wal_hook(db, 0, 0);\n  }\n#endif\n  return SQLITE_OK;\n}\n\n/*\n** Register a callback to be invoked each time a transaction is written\n** into the write-ahead-log by this database connection.\n*/\nSQLITE_API void *sqlite3_wal_hook(\n  sqlite3 *db,                    /* Attach the hook to this db handle */\n  int(*xCallback)(void *, sqlite3*, const char*, int),\n  void *pArg                      /* First argument passed to xCallback() */\n){\n#ifndef SQLITE_OMIT_WAL\n  void *pRet;\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( !sqlite3SafetyCheckOk(db) ){\n    (void)SQLITE_MISUSE_BKPT;\n    return 0;\n  }\n#endif\n  sqlite3_mutex_enter(db->mutex);\n  pRet = db->pWalArg;\n  db->xWalCallback = xCallback;\n  db->pWalArg = pArg;\n  sqlite3_mutex_leave(db->mutex);\n  return pRet;\n#else\n  return 0;\n#endif\n}\n\n/*\n** Checkpoint database zDb.\n*/\nSQLITE_API int sqlite3_wal_checkpoint_v2(\n  sqlite3 *db,                    /* Database handle */\n  const char *zDb,                /* Name of attached database (or NULL) */\n  int eMode,                      /* SQLITE_CHECKPOINT_* value */\n  int *pnLog,                     /* OUT: Size of WAL log in frames */\n  int *pnCkpt                     /* OUT: Total number of frames checkpointed */\n){\n#ifdef SQLITE_OMIT_WAL\n  return SQLITE_OK;\n#else\n  int rc;                         /* Return code */\n  int iDb = SQLITE_MAX_ATTACHED;  /* sqlite3.aDb[] index of db to checkpoint */\n\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( !sqlite3SafetyCheckOk(db) ) return SQLITE_MISUSE_BKPT;\n#endif\n\n  /* Initialize the output variables to -1 in case an error occurs. */\n  if( pnLog ) *pnLog = -1;\n  if( pnCkpt ) *pnCkpt = -1;\n\n  assert( SQLITE_CHECKPOINT_PASSIVE==0 );\n  assert( SQLITE_CHECKPOINT_FULL==1 );\n  assert( SQLITE_CHECKPOINT_RESTART==2 );\n  assert( SQLITE_CHECKPOINT_TRUNCATE==3 );\n  if( eMode<SQLITE_CHECKPOINT_PASSIVE || eMode>SQLITE_CHECKPOINT_TRUNCATE ){\n    /* EVIDENCE-OF: R-03996-12088 The M parameter must be a valid checkpoint\n    ** mode: */\n    return SQLITE_MISUSE;\n  }\n\n  sqlite3_mutex_enter(db->mutex);\n  if( zDb && zDb[0] ){\n    iDb = sqlite3FindDbName(db, zDb);\n  }\n  if( iDb<0 ){\n    rc = SQLITE_ERROR;\n    sqlite3ErrorWithMsg(db, SQLITE_ERROR, \"unknown database: %s\", zDb);\n  }else{\n    db->busyHandler.nBusy = 0;\n    rc = sqlite3Checkpoint(db, iDb, eMode, pnLog, pnCkpt);\n    sqlite3Error(db, rc);\n  }\n  rc = sqlite3ApiExit(db, rc);\n\n  /* If there are no active statements, clear the interrupt flag at this\n  ** point.  */\n  if( db->nVdbeActive==0 ){\n    db->u1.isInterrupted = 0;\n  }\n\n  sqlite3_mutex_leave(db->mutex);\n  return rc;\n#endif\n}\n\n\n/*\n** Checkpoint database zDb. If zDb is NULL, or if the buffer zDb points\n** to contains a zero-length string, all attached databases are \n** checkpointed.\n*/\nSQLITE_API int sqlite3_wal_checkpoint(sqlite3 *db, const char *zDb){\n  /* EVIDENCE-OF: R-41613-20553 The sqlite3_wal_checkpoint(D,X) is equivalent to\n  ** sqlite3_wal_checkpoint_v2(D,X,SQLITE_CHECKPOINT_PASSIVE,0,0). */\n  return sqlite3_wal_checkpoint_v2(db,zDb,SQLITE_CHECKPOINT_PASSIVE,0,0);\n}\n\n#ifdef SQLITE_WCDB_CHECKPOINT_HANDLER\nSQLITE_API void *sqlite3_wal_checkpoint_handler(sqlite3 *db,\n                                   void (*xCallback)(void*, sqlite3*, const char *),\n                                   void* pArg){\n#ifndef SQLITE_OMIT_WAL\n  void *pRet;\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( !sqlite3SafetyCheckOk(db) ){\n    (void)SQLITE_MISUSE_BKPT;\n    return 0;\n  }\n#endif\n  sqlite3_mutex_enter(db->mutex);\n  pRet = db->pCheckpointArg;\n  db->xCheckpointCallback = xCallback;\n  db->pCheckpointArg = pArg;\n  sqlite3_mutex_leave(db->mutex);\n  return pRet;\n#else\n  return 0;\n#endif\n}\n#endif //SQLITE_WCDB_CHECKPOINT_HANDLER\n\n#ifndef SQLITE_OMIT_WAL\n/*\n** Run a checkpoint on database iDb. This is a no-op if database iDb is\n** not currently open in WAL mode.\n**\n** If a transaction is open on the database being checkpointed, this \n** function returns SQLITE_LOCKED and a checkpoint is not attempted. If \n** an error occurs while running the checkpoint, an SQLite error code is \n** returned (i.e. SQLITE_IOERR). Otherwise, SQLITE_OK.\n**\n** The mutex on database handle db should be held by the caller. The mutex\n** associated with the specific b-tree being checkpointed is taken by\n** this function while the checkpoint is running.\n**\n** If iDb is passed SQLITE_MAX_ATTACHED, then all attached databases are\n** checkpointed. If an error is encountered it is returned immediately -\n** no attempt is made to checkpoint any remaining databases.\n**\n** Parameter eMode is one of SQLITE_CHECKPOINT_PASSIVE, FULL, RESTART\n** or TRUNCATE.\n*/\nSQLITE_PRIVATE int sqlite3Checkpoint(sqlite3 *db, int iDb, int eMode, int *pnLog, int *pnCkpt){\n  int rc = SQLITE_OK;             /* Return code */\n  int i;                          /* Used to iterate through attached dbs */\n  int bBusy = 0;                  /* True if SQLITE_BUSY has been encountered */\n\n  assert( sqlite3_mutex_held(db->mutex) );\n  assert( !pnLog || *pnLog==-1 );\n  assert( !pnCkpt || *pnCkpt==-1 );\n  \n  for(i=0; i<db->nDb && rc==SQLITE_OK; i++){\n    if( i==iDb || iDb==SQLITE_MAX_ATTACHED ){\n      rc = sqlite3BtreeCheckpoint(db->aDb[i].pBt, eMode, pnLog, pnCkpt);\n      pnLog = 0;\n      pnCkpt = 0;\n      if( rc==SQLITE_BUSY ){\n        bBusy = 1;\n        rc = SQLITE_OK;\n      }\n#ifdef SQLITE_WCDB_CHECKPOINT_HANDLER\n      if( rc==SQLITE_OK && db->xCheckpointCallback) {\n        db->xCheckpointCallback(db->pCheckpointArg, db, db->aDb[i].zDbSName);\n      }\n#endif\n    }\n  }\n\n  return (rc==SQLITE_OK && bBusy) ? SQLITE_BUSY : rc;\n}\n#endif /* SQLITE_OMIT_WAL */\n\n/*\n** This function returns true if main-memory should be used instead of\n** a temporary file for transient pager files and statement journals.\n** The value returned depends on the value of db->temp_store (runtime\n** parameter) and the compile time value of SQLITE_TEMP_STORE. The\n** following table describes the relationship between these two values\n** and this functions return value.\n**\n**   SQLITE_TEMP_STORE     db->temp_store     Location of temporary database\n**   -----------------     --------------     ------------------------------\n**   0                     any                file      (return 0)\n**   1                     1                  file      (return 0)\n**   1                     2                  memory    (return 1)\n**   1                     0                  file      (return 0)\n**   2                     1                  file      (return 0)\n**   2                     2                  memory    (return 1)\n**   2                     0                  memory    (return 1)\n**   3                     any                memory    (return 1)\n*/\nSQLITE_PRIVATE int sqlite3TempInMemory(const sqlite3 *db){\n#if SQLITE_TEMP_STORE==1\n  return ( db->temp_store==2 );\n#endif\n#if SQLITE_TEMP_STORE==2\n  return ( db->temp_store!=1 );\n#endif\n#if SQLITE_TEMP_STORE==3\n  UNUSED_PARAMETER(db);\n  return 1;\n#endif\n#if SQLITE_TEMP_STORE<1 || SQLITE_TEMP_STORE>3\n  UNUSED_PARAMETER(db);\n  return 0;\n#endif\n}\n\n/*\n** Return UTF-8 encoded English language explanation of the most recent\n** error.\n*/\nSQLITE_API const char *sqlite3_errmsg(sqlite3 *db){\n  const char *z;\n  if( !db ){\n    return sqlite3ErrStr(SQLITE_NOMEM_BKPT);\n  }\n  if( !sqlite3SafetyCheckSickOrOk(db) ){\n    return sqlite3ErrStr(SQLITE_MISUSE_BKPT);\n  }\n  sqlite3_mutex_enter(db->mutex);\n  if( db->mallocFailed ){\n    z = sqlite3ErrStr(SQLITE_NOMEM_BKPT);\n  }else{\n    testcase( db->pErr==0 );\n    z = db->errCode ? (char*)sqlite3_value_text(db->pErr) : 0;\n    assert( !db->mallocFailed );\n    if( z==0 ){\n      z = sqlite3ErrStr(db->errCode);\n    }\n  }\n  sqlite3_mutex_leave(db->mutex);\n  return z;\n}\n\n#ifndef SQLITE_OMIT_UTF16\n/*\n** Return UTF-16 encoded English language explanation of the most recent\n** error.\n*/\nSQLITE_API const void *sqlite3_errmsg16(sqlite3 *db){\n  static const u16 outOfMem[] = {\n    'o', 'u', 't', ' ', 'o', 'f', ' ', 'm', 'e', 'm', 'o', 'r', 'y', 0\n  };\n  static const u16 misuse[] = {\n    'b', 'a', 'd', ' ', 'p', 'a', 'r', 'a', 'm', 'e', 't', 'e', 'r', ' ',\n    'o', 'r', ' ', 'o', 't', 'h', 'e', 'r', ' ', 'A', 'P', 'I', ' ',\n    'm', 'i', 's', 'u', 's', 'e', 0\n  };\n\n  const void *z;\n  if( !db ){\n    return (void *)outOfMem;\n  }\n  if( !sqlite3SafetyCheckSickOrOk(db) ){\n    return (void *)misuse;\n  }\n  sqlite3_mutex_enter(db->mutex);\n  if( db->mallocFailed ){\n    z = (void *)outOfMem;\n  }else{\n    z = sqlite3_value_text16(db->pErr);\n    if( z==0 ){\n      sqlite3ErrorWithMsg(db, db->errCode, sqlite3ErrStr(db->errCode));\n      z = sqlite3_value_text16(db->pErr);\n    }\n    /* A malloc() may have failed within the call to sqlite3_value_text16()\n    ** above. If this is the case, then the db->mallocFailed flag needs to\n    ** be cleared before returning. Do this directly, instead of via\n    ** sqlite3ApiExit(), to avoid setting the database handle error message.\n    */\n    sqlite3OomClear(db);\n  }\n  sqlite3_mutex_leave(db->mutex);\n  return z;\n}\n#endif /* SQLITE_OMIT_UTF16 */\n\n/*\n** Return the most recent error code generated by an SQLite routine. If NULL is\n** passed to this function, we assume a malloc() failed during sqlite3_open().\n*/\nSQLITE_API int sqlite3_errcode(sqlite3 *db){\n  if( db && !sqlite3SafetyCheckSickOrOk(db) ){\n    return SQLITE_MISUSE_BKPT;\n  }\n  if( !db || db->mallocFailed ){\n    return SQLITE_NOMEM_BKPT;\n  }\n  return db->errCode & db->errMask;\n}\nSQLITE_API int sqlite3_extended_errcode(sqlite3 *db){\n  if( db && !sqlite3SafetyCheckSickOrOk(db) ){\n    return SQLITE_MISUSE_BKPT;\n  }\n  if( !db || db->mallocFailed ){\n    return SQLITE_NOMEM_BKPT;\n  }\n  return db->errCode;\n}\nSQLITE_API int sqlite3_system_errno(sqlite3 *db){\n  return db ? db->iSysErrno : 0;\n}  \n\n/*\n** Return a string that describes the kind of error specified in the\n** argument.  For now, this simply calls the internal sqlite3ErrStr()\n** function.\n*/\nSQLITE_API const char *sqlite3_errstr(int rc){\n  return sqlite3ErrStr(rc);\n}\n\n/*\n** Create a new collating function for database \"db\".  The name is zName\n** and the encoding is enc.\n*/\nstatic int createCollation(\n  sqlite3* db,\n  const char *zName, \n  u8 enc,\n  void* pCtx,\n  int(*xCompare)(void*,int,const void*,int,const void*),\n  void(*xDel)(void*)\n){\n  CollSeq *pColl;\n  int enc2;\n  \n  assert( sqlite3_mutex_held(db->mutex) );\n\n  /* If SQLITE_UTF16 is specified as the encoding type, transform this\n  ** to one of SQLITE_UTF16LE or SQLITE_UTF16BE using the\n  ** SQLITE_UTF16NATIVE macro. SQLITE_UTF16 is not used internally.\n  */\n  enc2 = enc;\n  testcase( enc2==SQLITE_UTF16 );\n  testcase( enc2==SQLITE_UTF16_ALIGNED );\n  if( enc2==SQLITE_UTF16 || enc2==SQLITE_UTF16_ALIGNED ){\n    enc2 = SQLITE_UTF16NATIVE;\n  }\n  if( enc2<SQLITE_UTF8 || enc2>SQLITE_UTF16BE ){\n    return SQLITE_MISUSE_BKPT;\n  }\n\n  /* Check if this call is removing or replacing an existing collation \n  ** sequence. If so, and there are active VMs, return busy. If there\n  ** are no active VMs, invalidate any pre-compiled statements.\n  */\n  pColl = sqlite3FindCollSeq(db, (u8)enc2, zName, 0);\n  if( pColl && pColl->xCmp ){\n    if( db->nVdbeActive ){\n      sqlite3ErrorWithMsg(db, SQLITE_BUSY, \n        \"unable to delete/modify collation sequence due to active statements\");\n      return SQLITE_BUSY;\n    }\n    sqlite3ExpirePreparedStatements(db, 0);\n\n    /* If collation sequence pColl was created directly by a call to\n    ** sqlite3_create_collation, and not generated by synthCollSeq(),\n    ** then any copies made by synthCollSeq() need to be invalidated.\n    ** Also, collation destructor - CollSeq.xDel() - function may need\n    ** to be called.\n    */ \n    if( (pColl->enc & ~SQLITE_UTF16_ALIGNED)==enc2 ){\n      CollSeq *aColl = sqlite3HashFind(&db->aCollSeq, zName);\n      int j;\n      for(j=0; j<3; j++){\n        CollSeq *p = &aColl[j];\n        if( p->enc==pColl->enc ){\n          if( p->xDel ){\n            p->xDel(p->pUser);\n          }\n          p->xCmp = 0;\n        }\n      }\n    }\n  }\n\n  pColl = sqlite3FindCollSeq(db, (u8)enc2, zName, 1);\n  if( pColl==0 ) return SQLITE_NOMEM_BKPT;\n  pColl->xCmp = xCompare;\n  pColl->pUser = pCtx;\n  pColl->xDel = xDel;\n  pColl->enc = (u8)(enc2 | (enc & SQLITE_UTF16_ALIGNED));\n  sqlite3Error(db, SQLITE_OK);\n  return SQLITE_OK;\n}\n\n\n/*\n** This array defines hard upper bounds on limit values.  The\n** initializer must be kept in sync with the SQLITE_LIMIT_*\n** #defines in sqlite3.h.\n*/\nstatic const int aHardLimit[] = {\n  SQLITE_MAX_LENGTH,\n  SQLITE_MAX_SQL_LENGTH,\n  SQLITE_MAX_COLUMN,\n  SQLITE_MAX_EXPR_DEPTH,\n  SQLITE_MAX_COMPOUND_SELECT,\n  SQLITE_MAX_VDBE_OP,\n  SQLITE_MAX_FUNCTION_ARG,\n  SQLITE_MAX_ATTACHED,\n  SQLITE_MAX_LIKE_PATTERN_LENGTH,\n  SQLITE_MAX_VARIABLE_NUMBER,      /* IMP: R-38091-32352 */\n  SQLITE_MAX_TRIGGER_DEPTH,\n  SQLITE_MAX_WORKER_THREADS,\n};\n\n/*\n** Make sure the hard limits are set to reasonable values\n*/\n#if SQLITE_MAX_LENGTH<100\n# error SQLITE_MAX_LENGTH must be at least 100\n#endif\n#if SQLITE_MAX_SQL_LENGTH<100\n# error SQLITE_MAX_SQL_LENGTH must be at least 100\n#endif\n#if SQLITE_MAX_SQL_LENGTH>SQLITE_MAX_LENGTH\n# error SQLITE_MAX_SQL_LENGTH must not be greater than SQLITE_MAX_LENGTH\n#endif\n#if SQLITE_MAX_COMPOUND_SELECT<2\n# error SQLITE_MAX_COMPOUND_SELECT must be at least 2\n#endif\n#if SQLITE_MAX_VDBE_OP<40\n# error SQLITE_MAX_VDBE_OP must be at least 40\n#endif\n#if SQLITE_MAX_FUNCTION_ARG<0 || SQLITE_MAX_FUNCTION_ARG>127\n# error SQLITE_MAX_FUNCTION_ARG must be between 0 and 127\n#endif\n#if SQLITE_MAX_ATTACHED<0 || SQLITE_MAX_ATTACHED>125\n# error SQLITE_MAX_ATTACHED must be between 0 and 125\n#endif\n#if SQLITE_MAX_LIKE_PATTERN_LENGTH<1\n# error SQLITE_MAX_LIKE_PATTERN_LENGTH must be at least 1\n#endif\n#if SQLITE_MAX_COLUMN>32767\n# error SQLITE_MAX_COLUMN must not exceed 32767\n#endif\n#if SQLITE_MAX_TRIGGER_DEPTH<1\n# error SQLITE_MAX_TRIGGER_DEPTH must be at least 1\n#endif\n#if SQLITE_MAX_WORKER_THREADS<0 || SQLITE_MAX_WORKER_THREADS>50\n# error SQLITE_MAX_WORKER_THREADS must be between 0 and 50\n#endif\n\n\n/*\n** Change the value of a limit.  Report the old value.\n** If an invalid limit index is supplied, report -1.\n** Make no changes but still report the old value if the\n** new limit is negative.\n**\n** A new lower limit does not shrink existing constructs.\n** It merely prevents new constructs that exceed the limit\n** from forming.\n*/\nSQLITE_API int sqlite3_limit(sqlite3 *db, int limitId, int newLimit){\n  int oldLimit;\n\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( !sqlite3SafetyCheckOk(db) ){\n    (void)SQLITE_MISUSE_BKPT;\n    return -1;\n  }\n#endif\n\n  /* EVIDENCE-OF: R-30189-54097 For each limit category SQLITE_LIMIT_NAME\n  ** there is a hard upper bound set at compile-time by a C preprocessor\n  ** macro called SQLITE_MAX_NAME. (The \"_LIMIT_\" in the name is changed to\n  ** \"_MAX_\".)\n  */\n  assert( aHardLimit[SQLITE_LIMIT_LENGTH]==SQLITE_MAX_LENGTH );\n  assert( aHardLimit[SQLITE_LIMIT_SQL_LENGTH]==SQLITE_MAX_SQL_LENGTH );\n  assert( aHardLimit[SQLITE_LIMIT_COLUMN]==SQLITE_MAX_COLUMN );\n  assert( aHardLimit[SQLITE_LIMIT_EXPR_DEPTH]==SQLITE_MAX_EXPR_DEPTH );\n  assert( aHardLimit[SQLITE_LIMIT_COMPOUND_SELECT]==SQLITE_MAX_COMPOUND_SELECT);\n  assert( aHardLimit[SQLITE_LIMIT_VDBE_OP]==SQLITE_MAX_VDBE_OP );\n  assert( aHardLimit[SQLITE_LIMIT_FUNCTION_ARG]==SQLITE_MAX_FUNCTION_ARG );\n  assert( aHardLimit[SQLITE_LIMIT_ATTACHED]==SQLITE_MAX_ATTACHED );\n  assert( aHardLimit[SQLITE_LIMIT_LIKE_PATTERN_LENGTH]==\n                                               SQLITE_MAX_LIKE_PATTERN_LENGTH );\n  assert( aHardLimit[SQLITE_LIMIT_VARIABLE_NUMBER]==SQLITE_MAX_VARIABLE_NUMBER);\n  assert( aHardLimit[SQLITE_LIMIT_TRIGGER_DEPTH]==SQLITE_MAX_TRIGGER_DEPTH );\n  assert( aHardLimit[SQLITE_LIMIT_WORKER_THREADS]==SQLITE_MAX_WORKER_THREADS );\n  assert( SQLITE_LIMIT_WORKER_THREADS==(SQLITE_N_LIMIT-1) );\n\n\n  if( limitId<0 || limitId>=SQLITE_N_LIMIT ){\n    return -1;\n  }\n  oldLimit = db->aLimit[limitId];\n  if( newLimit>=0 ){                   /* IMP: R-52476-28732 */\n    if( newLimit>aHardLimit[limitId] ){\n      newLimit = aHardLimit[limitId];  /* IMP: R-51463-25634 */\n    }\n    db->aLimit[limitId] = newLimit;\n  }\n  return oldLimit;                     /* IMP: R-53341-35419 */\n}\n\n/*\n** This function is used to parse both URIs and non-URI filenames passed by the\n** user to API functions sqlite3_open() or sqlite3_open_v2(), and for database\n** URIs specified as part of ATTACH statements.\n**\n** The first argument to this function is the name of the VFS to use (or\n** a NULL to signify the default VFS) if the URI does not contain a \"vfs=xxx\"\n** query parameter. The second argument contains the URI (or non-URI filename)\n** itself. When this function is called the *pFlags variable should contain\n** the default flags to open the database handle with. The value stored in\n** *pFlags may be updated before returning if the URI filename contains \n** \"cache=xxx\" or \"mode=xxx\" query parameters.\n**\n** If successful, SQLITE_OK is returned. In this case *ppVfs is set to point to\n** the VFS that should be used to open the database file. *pzFile is set to\n** point to a buffer containing the name of the file to open. It is the \n** responsibility of the caller to eventually call sqlite3_free() to release\n** this buffer.\n**\n** If an error occurs, then an SQLite error code is returned and *pzErrMsg\n** may be set to point to a buffer containing an English language error \n** message. It is the responsibility of the caller to eventually release\n** this buffer by calling sqlite3_free().\n*/\nSQLITE_PRIVATE int sqlite3ParseUri(\n  const char *zDefaultVfs,        /* VFS to use if no \"vfs=xxx\" query option */\n  const char *zUri,               /* Nul-terminated URI to parse */\n  unsigned int *pFlags,           /* IN/OUT: SQLITE_OPEN_XXX flags */\n  sqlite3_vfs **ppVfs,            /* OUT: VFS to use */ \n  char **pzFile,                  /* OUT: Filename component of URI */\n  char **pzErrMsg                 /* OUT: Error message (if rc!=SQLITE_OK) */\n){\n  int rc = SQLITE_OK;\n  unsigned int flags = *pFlags;\n  const char *zVfs = zDefaultVfs;\n  char *zFile;\n  char c;\n  int nUri = sqlite3Strlen30(zUri);\n\n  assert( *pzErrMsg==0 );\n\n  if( ((flags & SQLITE_OPEN_URI)             /* IMP: R-48725-32206 */\n            || sqlite3GlobalConfig.bOpenUri) /* IMP: R-51689-46548 */\n   && nUri>=5 && memcmp(zUri, \"file:\", 5)==0 /* IMP: R-57884-37496 */\n  ){\n    char *zOpt;\n    int eState;                   /* Parser state when parsing URI */\n    int iIn;                      /* Input character index */\n    int iOut = 0;                 /* Output character index */\n    u64 nByte = nUri+2;           /* Bytes of space to allocate */\n\n    /* Make sure the SQLITE_OPEN_URI flag is set to indicate to the VFS xOpen \n    ** method that there may be extra parameters following the file-name.  */\n    flags |= SQLITE_OPEN_URI;\n\n    for(iIn=0; iIn<nUri; iIn++) nByte += (zUri[iIn]=='&');\n    zFile = sqlite3_malloc64(nByte);\n    if( !zFile ) return SQLITE_NOMEM_BKPT;\n\n    iIn = 5;\n#ifdef SQLITE_ALLOW_URI_AUTHORITY\n    if( strncmp(zUri+5, \"///\", 3)==0 ){\n      iIn = 7;\n      /* The following condition causes URIs with five leading / characters\n      ** like file://///host/path to be converted into UNCs like //host/path.\n      ** The correct URI for that UNC has only two or four leading / characters\n      ** file://host/path or file:////host/path.  But 5 leading slashes is a \n      ** common error, we are told, so we handle it as a special case. */\n      if( strncmp(zUri+7, \"///\", 3)==0 ){ iIn++; }\n    }else if( strncmp(zUri+5, \"//localhost/\", 12)==0 ){\n      iIn = 16;\n    }\n#else\n    /* Discard the scheme and authority segments of the URI. */\n    if( zUri[5]=='/' && zUri[6]=='/' ){\n      iIn = 7;\n      while( zUri[iIn] && zUri[iIn]!='/' ) iIn++;\n      if( iIn!=7 && (iIn!=16 || memcmp(\"localhost\", &zUri[7], 9)) ){\n        *pzErrMsg = sqlite3_mprintf(\"invalid uri authority: %.*s\", \n            iIn-7, &zUri[7]);\n        rc = SQLITE_ERROR;\n        goto parse_uri_out;\n      }\n    }\n#endif\n\n    /* Copy the filename and any query parameters into the zFile buffer. \n    ** Decode %HH escape codes along the way. \n    **\n    ** Within this loop, variable eState may be set to 0, 1 or 2, depending\n    ** on the parsing context. As follows:\n    **\n    **   0: Parsing file-name.\n    **   1: Parsing name section of a name=value query parameter.\n    **   2: Parsing value section of a name=value query parameter.\n    */\n    eState = 0;\n    while( (c = zUri[iIn])!=0 && c!='#' ){\n      iIn++;\n      if( c=='%' \n       && sqlite3Isxdigit(zUri[iIn]) \n       && sqlite3Isxdigit(zUri[iIn+1]) \n      ){\n        int octet = (sqlite3HexToInt(zUri[iIn++]) << 4);\n        octet += sqlite3HexToInt(zUri[iIn++]);\n\n        assert( octet>=0 && octet<256 );\n        if( octet==0 ){\n#ifndef SQLITE_ENABLE_URI_00_ERROR\n          /* This branch is taken when \"%00\" appears within the URI. In this\n          ** case we ignore all text in the remainder of the path, name or\n          ** value currently being parsed. So ignore the current character\n          ** and skip to the next \"?\", \"=\" or \"&\", as appropriate. */\n          while( (c = zUri[iIn])!=0 && c!='#' \n              && (eState!=0 || c!='?')\n              && (eState!=1 || (c!='=' && c!='&'))\n              && (eState!=2 || c!='&')\n          ){\n            iIn++;\n          }\n          continue;\n#else\n          /* If ENABLE_URI_00_ERROR is defined, \"%00\" in a URI is an error. */\n          *pzErrMsg = sqlite3_mprintf(\"unexpected %%00 in uri\");\n          rc = SQLITE_ERROR;\n          goto parse_uri_out;\n#endif\n        }\n        c = octet;\n      }else if( eState==1 && (c=='&' || c=='=') ){\n        if( zFile[iOut-1]==0 ){\n          /* An empty option name. Ignore this option altogether. */\n          while( zUri[iIn] && zUri[iIn]!='#' && zUri[iIn-1]!='&' ) iIn++;\n          continue;\n        }\n        if( c=='&' ){\n          zFile[iOut++] = '\\0';\n        }else{\n          eState = 2;\n        }\n        c = 0;\n      }else if( (eState==0 && c=='?') || (eState==2 && c=='&') ){\n        c = 0;\n        eState = 1;\n      }\n      zFile[iOut++] = c;\n    }\n    if( eState==1 ) zFile[iOut++] = '\\0';\n    zFile[iOut++] = '\\0';\n    zFile[iOut++] = '\\0';\n\n    /* Check if there were any options specified that should be interpreted \n    ** here. Options that are interpreted here include \"vfs\" and those that\n    ** correspond to flags that may be passed to the sqlite3_open_v2()\n    ** method. */\n    zOpt = &zFile[sqlite3Strlen30(zFile)+1];\n    while( zOpt[0] ){\n      int nOpt = sqlite3Strlen30(zOpt);\n      char *zVal = &zOpt[nOpt+1];\n      int nVal = sqlite3Strlen30(zVal);\n\n      if( nOpt==3 && memcmp(\"vfs\", zOpt, 3)==0 ){\n        zVfs = zVal;\n      }else{\n        struct OpenMode {\n          const char *z;\n          int mode;\n        } *aMode = 0;\n        char *zModeType = 0;\n        int mask = 0;\n        int limit = 0;\n\n        if( nOpt==5 && memcmp(\"cache\", zOpt, 5)==0 ){\n          static struct OpenMode aCacheMode[] = {\n            { \"shared\",  SQLITE_OPEN_SHAREDCACHE },\n            { \"private\", SQLITE_OPEN_PRIVATECACHE },\n            { 0, 0 }\n          };\n\n          mask = SQLITE_OPEN_SHAREDCACHE|SQLITE_OPEN_PRIVATECACHE;\n          aMode = aCacheMode;\n          limit = mask;\n          zModeType = \"cache\";\n        }\n        if( nOpt==4 && memcmp(\"mode\", zOpt, 4)==0 ){\n          static struct OpenMode aOpenMode[] = {\n            { \"ro\",  SQLITE_OPEN_READONLY },\n            { \"rw\",  SQLITE_OPEN_READWRITE }, \n            { \"rwc\", SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE },\n            { \"memory\", SQLITE_OPEN_MEMORY },\n            { 0, 0 }\n          };\n\n          mask = SQLITE_OPEN_READONLY | SQLITE_OPEN_READWRITE\n                   | SQLITE_OPEN_CREATE | SQLITE_OPEN_MEMORY;\n          aMode = aOpenMode;\n          limit = mask & flags;\n          zModeType = \"access\";\n        }\n\n        if( aMode ){\n          int i;\n          int mode = 0;\n          for(i=0; aMode[i].z; i++){\n            const char *z = aMode[i].z;\n            if( nVal==sqlite3Strlen30(z) && 0==memcmp(zVal, z, nVal) ){\n              mode = aMode[i].mode;\n              break;\n            }\n          }\n          if( mode==0 ){\n            *pzErrMsg = sqlite3_mprintf(\"no such %s mode: %s\", zModeType, zVal);\n            rc = SQLITE_ERROR;\n            goto parse_uri_out;\n          }\n          if( (mode & ~SQLITE_OPEN_MEMORY)>limit ){\n            *pzErrMsg = sqlite3_mprintf(\"%s mode not allowed: %s\",\n                                        zModeType, zVal);\n            rc = SQLITE_PERM;\n            goto parse_uri_out;\n          }\n          flags = (flags & ~mask) | mode;\n        }\n      }\n\n      zOpt = &zVal[nVal+1];\n    }\n\n  }else{\n    zFile = sqlite3_malloc64(nUri+2);\n    if( !zFile ) return SQLITE_NOMEM_BKPT;\n    if( nUri ){\n      memcpy(zFile, zUri, nUri);\n    }\n    zFile[nUri] = '\\0';\n    zFile[nUri+1] = '\\0';\n    flags &= ~SQLITE_OPEN_URI;\n  }\n\n  *ppVfs = sqlite3_vfs_find(zVfs);\n  if( *ppVfs==0 ){\n    *pzErrMsg = sqlite3_mprintf(\"no such vfs: %s\", zVfs);\n    rc = SQLITE_ERROR;\n  }\n parse_uri_out:\n  if( rc!=SQLITE_OK ){\n    sqlite3_free(zFile);\n    zFile = 0;\n  }\n  *pFlags = flags;\n  *pzFile = zFile;\n  return rc;\n}\n\n#if defined(SQLITE_HAS_CODEC)\n/*\n** Process URI filename query parameters relevant to the SQLite Encryption\n** Extension.  Return true if any of the relevant query parameters are\n** seen and return false if not.\n*/\nSQLITE_PRIVATE int sqlite3CodecQueryParameters(\n  sqlite3 *db,           /* Database connection */\n  const char *zDb,       /* Which schema is being created/attached */\n  const char *zUri       /* URI filename */\n){\n  const char *zKey;\n  if( (zKey = sqlite3_uri_parameter(zUri, \"hexkey\"))!=0 && zKey[0] ){\n    u8 iByte;\n    int i;\n    char zDecoded[40];\n    for(i=0, iByte=0; i<sizeof(zDecoded)*2 && sqlite3Isxdigit(zKey[i]); i++){\n      iByte = (iByte<<4) + sqlite3HexToInt(zKey[i]);\n      if( (i&1)!=0 ) zDecoded[i/2] = iByte;\n    }\n    sqlite3_key_v2(db, zDb, zDecoded, i/2);\n    return 1;\n  }else if( (zKey = sqlite3_uri_parameter(zUri, \"key\"))!=0 ){\n    sqlite3_key_v2(db, zDb, zKey, sqlite3Strlen30(zKey));\n    return 1;\n  }else if( (zKey = sqlite3_uri_parameter(zUri, \"textkey\"))!=0 ){\n    sqlite3_key_v2(db, zDb, zKey, -1);\n    return 1;\n  }else{\n    return 0;\n  }\n}\n#endif\n\n\n/*\n** This routine does the work of opening a database on behalf of\n** sqlite3_open() and sqlite3_open16(). The database filename \"zFilename\"  \n** is UTF-8 encoded.\n*/\nstatic int openDatabase(\n  const char *zFilename, /* Database filename UTF-8 encoded */\n  sqlite3 **ppDb,        /* OUT: Returned database handle */\n  unsigned int flags,    /* Operational flags */\n  const char *zVfs       /* Name of the VFS to use */\n){\n  sqlite3 *db;                    /* Store allocated handle here */\n  int rc;                         /* Return code */\n  int isThreadsafe;               /* True for threadsafe connections */\n  char *zOpen = 0;                /* Filename argument to pass to BtreeOpen() */\n  char *zErrMsg = 0;              /* Error message from sqlite3ParseUri() */\n\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( ppDb==0 ) return SQLITE_MISUSE_BKPT;\n#endif\n  *ppDb = 0;\n#ifndef SQLITE_OMIT_AUTOINIT\n  rc = sqlite3_initialize();\n  if( rc ) return rc;\n#endif\n\n  if( sqlite3GlobalConfig.bCoreMutex==0 ){\n    isThreadsafe = 0;\n  }else if( flags & SQLITE_OPEN_NOMUTEX ){\n    isThreadsafe = 0;\n  }else if( flags & SQLITE_OPEN_FULLMUTEX ){\n    isThreadsafe = 1;\n  }else{\n    isThreadsafe = sqlite3GlobalConfig.bFullMutex;\n  }\n\n  if( flags & SQLITE_OPEN_PRIVATECACHE ){\n    flags &= ~SQLITE_OPEN_SHAREDCACHE;\n  }else if( sqlite3GlobalConfig.sharedCacheEnabled ){\n    flags |= SQLITE_OPEN_SHAREDCACHE;\n  }\n\n  /* Remove harmful bits from the flags parameter\n  **\n  ** The SQLITE_OPEN_NOMUTEX and SQLITE_OPEN_FULLMUTEX flags were\n  ** dealt with in the previous code block.  Besides these, the only\n  ** valid input flags for sqlite3_open_v2() are SQLITE_OPEN_READONLY,\n  ** SQLITE_OPEN_READWRITE, SQLITE_OPEN_CREATE, SQLITE_OPEN_SHAREDCACHE,\n  ** SQLITE_OPEN_PRIVATECACHE, and some reserved bits.  Silently mask\n  ** off all other flags.\n  */\n  flags &=  ~( SQLITE_OPEN_DELETEONCLOSE |\n               SQLITE_OPEN_EXCLUSIVE |\n               SQLITE_OPEN_MAIN_DB |\n               SQLITE_OPEN_TEMP_DB | \n               SQLITE_OPEN_TRANSIENT_DB | \n               SQLITE_OPEN_MAIN_JOURNAL | \n               SQLITE_OPEN_TEMP_JOURNAL | \n               SQLITE_OPEN_SUBJOURNAL | \n               SQLITE_OPEN_MASTER_JOURNAL |\n               SQLITE_OPEN_NOMUTEX |\n               SQLITE_OPEN_FULLMUTEX |\n               SQLITE_OPEN_WAL\n             );\n\n  /* Allocate the sqlite data structure */\n  db = sqlite3MallocZero( sizeof(sqlite3) );\n  if( db==0 ) goto opendb_out;\n  if( isThreadsafe \n#ifdef SQLITE_ENABLE_MULTITHREADED_CHECKS\n   || sqlite3GlobalConfig.bCoreMutex\n#endif\n  ){\n    db->mutex = sqlite3MutexAlloc(SQLITE_MUTEX_RECURSIVE);\n    if( db->mutex==0 ){\n      sqlite3_free(db);\n      db = 0;\n      goto opendb_out;\n    }\n    if( isThreadsafe==0 ){\n      sqlite3MutexWarnOnContention(db->mutex);\n    }\n  }\n  sqlite3_mutex_enter(db->mutex);\n  db->errMask = 0xff;\n  db->nDb = 2;\n  db->magic = SQLITE_MAGIC_BUSY;\n  db->aDb = db->aDbStatic;\n  db->lookaside.bDisable = 1;\n\n  assert( sizeof(db->aLimit)==sizeof(aHardLimit) );\n  memcpy(db->aLimit, aHardLimit, sizeof(db->aLimit));\n  db->aLimit[SQLITE_LIMIT_WORKER_THREADS] = SQLITE_DEFAULT_WORKER_THREADS;\n  db->autoCommit = 1;\n  db->nextAutovac = -1;\n  db->szMmap = sqlite3GlobalConfig.szMmap;\n  db->nextPagesize = 0;\n  db->nMaxSorterMmap = 0x7FFFFFFF;\n  db->flags |= SQLITE_ShortColNames | SQLITE_EnableTrigger | SQLITE_CacheSpill\n#if !defined(SQLITE_DEFAULT_AUTOMATIC_INDEX) || SQLITE_DEFAULT_AUTOMATIC_INDEX\n                 | SQLITE_AutoIndex\n#endif\n#if SQLITE_DEFAULT_CKPTFULLFSYNC\n                 | SQLITE_CkptFullFSync\n#endif\n#if SQLITE_DEFAULT_FILE_FORMAT<4\n                 | SQLITE_LegacyFileFmt\n#endif\n#ifdef SQLITE_ENABLE_LOAD_EXTENSION\n                 | SQLITE_LoadExtension\n#endif\n#if SQLITE_DEFAULT_RECURSIVE_TRIGGERS\n                 | SQLITE_RecTriggers\n#endif\n#if defined(SQLITE_DEFAULT_FOREIGN_KEYS) && SQLITE_DEFAULT_FOREIGN_KEYS\n                 | SQLITE_ForeignKeys\n#endif\n#if defined(SQLITE_REVERSE_UNORDERED_SELECTS)\n                 | SQLITE_ReverseOrder\n#endif\n#if defined(SQLITE_ENABLE_OVERSIZE_CELL_CHECK)\n                 | SQLITE_CellSizeCk\n#endif\n#if defined(SQLITE_ENABLE_FTS3_TOKENIZER)\n                 | SQLITE_Fts3Tokenizer\n#endif\n#if defined(SQLITE_ENABLE_QPSG)\n                 | SQLITE_EnableQPSG\n#endif\n#if defined(SQLITE_DEFAULT_DEFENSIVE)\n                 | SQLITE_Defensive\n#endif\n      ;\n  sqlite3HashInit(&db->aCollSeq);\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n  sqlite3HashInit(&db->aModule);\n#endif\n\n  /* Add the default collation sequence BINARY. BINARY works for both UTF-8\n  ** and UTF-16, so add a version for each to avoid any unnecessary\n  ** conversions. The only error that can occur here is a malloc() failure.\n  **\n  ** EVIDENCE-OF: R-52786-44878 SQLite defines three built-in collating\n  ** functions:\n  */\n  createCollation(db, sqlite3StrBINARY, SQLITE_UTF8, 0, binCollFunc, 0);\n  createCollation(db, sqlite3StrBINARY, SQLITE_UTF16BE, 0, binCollFunc, 0);\n  createCollation(db, sqlite3StrBINARY, SQLITE_UTF16LE, 0, binCollFunc, 0);\n  createCollation(db, \"NOCASE\", SQLITE_UTF8, 0, nocaseCollatingFunc, 0);\n  createCollation(db, \"RTRIM\", SQLITE_UTF8, (void*)1, binCollFunc, 0);\n  if( db->mallocFailed ){\n    goto opendb_out;\n  }\n  /* EVIDENCE-OF: R-08308-17224 The default collating function for all\n  ** strings is BINARY. \n  */\n  db->pDfltColl = sqlite3FindCollSeq(db, SQLITE_UTF8, sqlite3StrBINARY, 0);\n  assert( db->pDfltColl!=0 );\n\n  /* Parse the filename/URI argument\n  **\n  ** Only allow sensible combinations of bits in the flags argument.  \n  ** Throw an error if any non-sense combination is used.  If we\n  ** do not block illegal combinations here, it could trigger\n  ** assert() statements in deeper layers.  Sensible combinations\n  ** are:\n  **\n  **  1:  SQLITE_OPEN_READONLY\n  **  2:  SQLITE_OPEN_READWRITE\n  **  6:  SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE\n  */\n  db->openFlags = flags;\n  assert( SQLITE_OPEN_READONLY  == 0x01 );\n  assert( SQLITE_OPEN_READWRITE == 0x02 );\n  assert( SQLITE_OPEN_CREATE    == 0x04 );\n  testcase( (1<<(flags&7))==0x02 ); /* READONLY */\n  testcase( (1<<(flags&7))==0x04 ); /* READWRITE */\n  testcase( (1<<(flags&7))==0x40 ); /* READWRITE | CREATE */\n  if( ((1<<(flags&7)) & 0x46)==0 ){\n    rc = SQLITE_MISUSE_BKPT;  /* IMP: R-65497-44594 */\n  }else{\n    rc = sqlite3ParseUri(zVfs, zFilename, &flags, &db->pVfs, &zOpen, &zErrMsg);\n  }\n  if( rc!=SQLITE_OK ){\n    if( rc==SQLITE_NOMEM ) sqlite3OomFault(db);\n    sqlite3ErrorWithMsg(db, rc, zErrMsg ? \"%s\" : 0, zErrMsg);\n    sqlite3_free(zErrMsg);\n    goto opendb_out;\n  }\n\n  /* Open the backend database driver */\n  rc = sqlite3BtreeOpen(db->pVfs, zOpen, db, &db->aDb[0].pBt, 0,\n                        flags | SQLITE_OPEN_MAIN_DB);\n  if( rc!=SQLITE_OK ){\n    if( rc==SQLITE_IOERR_NOMEM ){\n      rc = SQLITE_NOMEM_BKPT;\n    }\n    sqlite3Error(db, rc);\n    goto opendb_out;\n  }\n  sqlite3BtreeEnter(db->aDb[0].pBt);\n  db->aDb[0].pSchema = sqlite3SchemaGet(db, db->aDb[0].pBt);\n  if( !db->mallocFailed ) ENC(db) = SCHEMA_ENC(db);\n  sqlite3BtreeLeave(db->aDb[0].pBt);\n  db->aDb[1].pSchema = sqlite3SchemaGet(db, 0);\n\n  /* The default safety_level for the main database is FULL; for the temp\n  ** database it is OFF. This matches the pager layer defaults.  \n  */\n  db->aDb[0].zDbSName = \"main\";\n  db->aDb[0].safety_level = SQLITE_DEFAULT_SYNCHRONOUS+1;\n  db->aDb[1].zDbSName = \"temp\";\n  db->aDb[1].safety_level = PAGER_SYNCHRONOUS_OFF;\n\n  db->magic = SQLITE_MAGIC_OPEN;\n  if( db->mallocFailed ){\n    goto opendb_out;\n  }\n\n  /* Register all built-in functions, but do not attempt to read the\n  ** database schema yet. This is delayed until the first time the database\n  ** is accessed.\n  */\n  sqlite3Error(db, SQLITE_OK);\n  sqlite3RegisterPerConnectionBuiltinFunctions(db);\n  rc = sqlite3_errcode(db);\n\n#ifdef SQLITE_ENABLE_FTS5\n  /* Register any built-in FTS5 module before loading the automatic\n  ** extensions. This allows automatic extensions to register FTS5 \n  ** tokenizers and auxiliary functions.  */\n  if( !db->mallocFailed && rc==SQLITE_OK ){\n    rc = sqlite3Fts5Init(db);\n  }\n#endif\n\n  /* Load automatic extensions - extensions that have been registered\n  ** using the sqlite3_automatic_extension() API.\n  */\n  if( rc==SQLITE_OK ){\n    sqlite3AutoLoadExtensions(db);\n    rc = sqlite3_errcode(db);\n    if( rc!=SQLITE_OK ){\n      goto opendb_out;\n    }\n  }\n\n#ifdef SQLITE_ENABLE_FTS1\n  if( !db->mallocFailed ){\n    extern int sqlite3Fts1Init(sqlite3*);\n    rc = sqlite3Fts1Init(db);\n  }\n#endif\n\n#ifdef SQLITE_ENABLE_FTS2\n  if( !db->mallocFailed && rc==SQLITE_OK ){\n    extern int sqlite3Fts2Init(sqlite3*);\n    rc = sqlite3Fts2Init(db);\n  }\n#endif\n\n#ifdef SQLITE_ENABLE_FTS3 /* automatically defined by SQLITE_ENABLE_FTS4 */\n  if( !db->mallocFailed && rc==SQLITE_OK ){\n    rc = sqlite3Fts3Init(db);\n  }\n#endif\n\n#if defined(SQLITE_ENABLE_ICU) || defined(SQLITE_ENABLE_ICU_COLLATIONS)\n  if( !db->mallocFailed && rc==SQLITE_OK ){\n    rc = sqlite3IcuInit(db);\n  }\n#endif\n\n#ifdef SQLITE_ENABLE_RTREE\n  if( !db->mallocFailed && rc==SQLITE_OK){\n    rc = sqlite3RtreeInit(db);\n  }\n#endif\n\n#ifdef SQLITE_ENABLE_DBPAGE_VTAB\n  if( !db->mallocFailed && rc==SQLITE_OK){\n    rc = sqlite3DbpageRegister(db);\n  }\n#endif\n\n#ifdef SQLITE_ENABLE_DBSTAT_VTAB\n  if( !db->mallocFailed && rc==SQLITE_OK){\n    rc = sqlite3DbstatRegister(db);\n  }\n#endif\n\n#ifdef SQLITE_ENABLE_JSON1\n  if( !db->mallocFailed && rc==SQLITE_OK){\n    rc = sqlite3Json1Init(db);\n  }\n#endif\n\n#ifdef SQLITE_ENABLE_STMTVTAB\n  if( !db->mallocFailed && rc==SQLITE_OK){\n    rc = sqlite3StmtVtabInit(db);\n  }\n#endif\n\n  /* -DSQLITE_DEFAULT_LOCKING_MODE=1 makes EXCLUSIVE the default locking\n  ** mode.  -DSQLITE_DEFAULT_LOCKING_MODE=0 make NORMAL the default locking\n  ** mode.  Doing nothing at all also makes NORMAL the default.\n  */\n#ifdef SQLITE_DEFAULT_LOCKING_MODE\n  db->dfltLockMode = SQLITE_DEFAULT_LOCKING_MODE;\n  sqlite3PagerLockingMode(sqlite3BtreePager(db->aDb[0].pBt),\n                          SQLITE_DEFAULT_LOCKING_MODE);\n#endif\n\n  if( rc ) sqlite3Error(db, rc);\n\n  /* Enable the lookaside-malloc subsystem */\n  setupLookaside(db, 0, sqlite3GlobalConfig.szLookaside,\n                        sqlite3GlobalConfig.nLookaside);\n\n  sqlite3_wal_autocheckpoint(db, SQLITE_DEFAULT_WAL_AUTOCHECKPOINT);\n\nopendb_out:\n  if( db ){\n    assert( db->mutex!=0 || isThreadsafe==0\n           || sqlite3GlobalConfig.bFullMutex==0 );\n    sqlite3_mutex_leave(db->mutex);\n  }\n  rc = sqlite3_errcode(db);\n  assert( db!=0 || rc==SQLITE_NOMEM );\n  if( rc==SQLITE_NOMEM ){\n    sqlite3_close(db);\n    db = 0;\n  }else if( rc!=SQLITE_OK ){\n    db->magic = SQLITE_MAGIC_SICK;\n  }\n  *ppDb = db;\n#ifdef SQLITE_ENABLE_SQLLOG\n  if( sqlite3GlobalConfig.xSqllog ){\n    /* Opening a db handle. Fourth parameter is passed 0. */\n    void *pArg = sqlite3GlobalConfig.pSqllogArg;\n    sqlite3GlobalConfig.xSqllog(pArg, db, zFilename, 0);\n  }\n#endif\n#if defined(SQLITE_HAS_CODEC)\n  if( rc==SQLITE_OK ) sqlite3CodecQueryParameters(db, 0, zOpen);\n#endif\n  sqlite3_free(zOpen);\n  return rc & 0xff;\n}\n\n\n/*\n** Open a new database handle.\n*/\nSQLITE_API int sqlite3_open(\n  const char *zFilename, \n  sqlite3 **ppDb \n){\n  return openDatabase(zFilename, ppDb,\n                      SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE, 0);\n}\nSQLITE_API int sqlite3_open_v2(\n  const char *filename,   /* Database filename (UTF-8) */\n  sqlite3 **ppDb,         /* OUT: SQLite db handle */\n  int flags,              /* Flags */\n  const char *zVfs        /* Name of VFS module to use */\n){\n  return openDatabase(filename, ppDb, (unsigned int)flags, zVfs);\n}\n\n#ifndef SQLITE_OMIT_UTF16\n/*\n** Open a new database handle.\n*/\nSQLITE_API int sqlite3_open16(\n  const void *zFilename, \n  sqlite3 **ppDb\n){\n  char const *zFilename8;   /* zFilename encoded in UTF-8 instead of UTF-16 */\n  sqlite3_value *pVal;\n  int rc;\n\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( ppDb==0 ) return SQLITE_MISUSE_BKPT;\n#endif\n  *ppDb = 0;\n#ifndef SQLITE_OMIT_AUTOINIT\n  rc = sqlite3_initialize();\n  if( rc ) return rc;\n#endif\n  if( zFilename==0 ) zFilename = \"\\000\\000\";\n  pVal = sqlite3ValueNew(0);\n  sqlite3ValueSetStr(pVal, -1, zFilename, SQLITE_UTF16NATIVE, SQLITE_STATIC);\n  zFilename8 = sqlite3ValueText(pVal, SQLITE_UTF8);\n  if( zFilename8 ){\n    rc = openDatabase(zFilename8, ppDb,\n                      SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE, 0);\n    assert( *ppDb || rc==SQLITE_NOMEM );\n    if( rc==SQLITE_OK && !DbHasProperty(*ppDb, 0, DB_SchemaLoaded) ){\n      SCHEMA_ENC(*ppDb) = ENC(*ppDb) = SQLITE_UTF16NATIVE;\n    }\n  }else{\n    rc = SQLITE_NOMEM_BKPT;\n  }\n  sqlite3ValueFree(pVal);\n\n  return rc & 0xff;\n}\n#endif /* SQLITE_OMIT_UTF16 */\n\n/*\n** Register a new collation sequence with the database handle db.\n*/\nSQLITE_API int sqlite3_create_collation(\n  sqlite3* db, \n  const char *zName, \n  int enc, \n  void* pCtx,\n  int(*xCompare)(void*,int,const void*,int,const void*)\n){\n  return sqlite3_create_collation_v2(db, zName, enc, pCtx, xCompare, 0);\n}\n\n/*\n** Register a new collation sequence with the database handle db.\n*/\nSQLITE_API int sqlite3_create_collation_v2(\n  sqlite3* db, \n  const char *zName, \n  int enc, \n  void* pCtx,\n  int(*xCompare)(void*,int,const void*,int,const void*),\n  void(*xDel)(void*)\n){\n  int rc;\n\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( !sqlite3SafetyCheckOk(db) || zName==0 ) return SQLITE_MISUSE_BKPT;\n#endif\n  sqlite3_mutex_enter(db->mutex);\n  assert( !db->mallocFailed );\n  rc = createCollation(db, zName, (u8)enc, pCtx, xCompare, xDel);\n  rc = sqlite3ApiExit(db, rc);\n  sqlite3_mutex_leave(db->mutex);\n  return rc;\n}\n\n#ifndef SQLITE_OMIT_UTF16\n/*\n** Register a new collation sequence with the database handle db.\n*/\nSQLITE_API int sqlite3_create_collation16(\n  sqlite3* db, \n  const void *zName,\n  int enc, \n  void* pCtx,\n  int(*xCompare)(void*,int,const void*,int,const void*)\n){\n  int rc = SQLITE_OK;\n  char *zName8;\n\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( !sqlite3SafetyCheckOk(db) || zName==0 ) return SQLITE_MISUSE_BKPT;\n#endif\n  sqlite3_mutex_enter(db->mutex);\n  assert( !db->mallocFailed );\n  zName8 = sqlite3Utf16to8(db, zName, -1, SQLITE_UTF16NATIVE);\n  if( zName8 ){\n    rc = createCollation(db, zName8, (u8)enc, pCtx, xCompare, 0);\n    sqlite3DbFree(db, zName8);\n  }\n  rc = sqlite3ApiExit(db, rc);\n  sqlite3_mutex_leave(db->mutex);\n  return rc;\n}\n#endif /* SQLITE_OMIT_UTF16 */\n\n/*\n** Register a collation sequence factory callback with the database handle\n** db. Replace any previously installed collation sequence factory.\n*/\nSQLITE_API int sqlite3_collation_needed(\n  sqlite3 *db, \n  void *pCollNeededArg, \n  void(*xCollNeeded)(void*,sqlite3*,int eTextRep,const char*)\n){\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( !sqlite3SafetyCheckOk(db) ) return SQLITE_MISUSE_BKPT;\n#endif\n  sqlite3_mutex_enter(db->mutex);\n  db->xCollNeeded = xCollNeeded;\n  db->xCollNeeded16 = 0;\n  db->pCollNeededArg = pCollNeededArg;\n  sqlite3_mutex_leave(db->mutex);\n  return SQLITE_OK;\n}\n\n#ifndef SQLITE_OMIT_UTF16\n/*\n** Register a collation sequence factory callback with the database handle\n** db. Replace any previously installed collation sequence factory.\n*/\nSQLITE_API int sqlite3_collation_needed16(\n  sqlite3 *db, \n  void *pCollNeededArg, \n  void(*xCollNeeded16)(void*,sqlite3*,int eTextRep,const void*)\n){\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( !sqlite3SafetyCheckOk(db) ) return SQLITE_MISUSE_BKPT;\n#endif\n  sqlite3_mutex_enter(db->mutex);\n  db->xCollNeeded = 0;\n  db->xCollNeeded16 = xCollNeeded16;\n  db->pCollNeededArg = pCollNeededArg;\n  sqlite3_mutex_leave(db->mutex);\n  return SQLITE_OK;\n}\n#endif /* SQLITE_OMIT_UTF16 */\n\n#ifndef SQLITE_OMIT_DEPRECATED\n/*\n** This function is now an anachronism. It used to be used to recover from a\n** malloc() failure, but SQLite now does this automatically.\n*/\nSQLITE_API int sqlite3_global_recover(void){\n  return SQLITE_OK;\n}\n#endif\n\n/*\n** Test to see whether or not the database connection is in autocommit\n** mode.  Return TRUE if it is and FALSE if not.  Autocommit mode is on\n** by default.  Autocommit is disabled by a BEGIN statement and reenabled\n** by the next COMMIT or ROLLBACK.\n*/\nSQLITE_API int sqlite3_get_autocommit(sqlite3 *db){\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( !sqlite3SafetyCheckOk(db) ){\n    (void)SQLITE_MISUSE_BKPT;\n    return 0;\n  }\n#endif\n  return db->autoCommit;\n}\n\n/*\n** The following routines are substitutes for constants SQLITE_CORRUPT,\n** SQLITE_MISUSE, SQLITE_CANTOPEN, SQLITE_NOMEM and possibly other error\n** constants.  They serve two purposes:\n**\n**   1.  Serve as a convenient place to set a breakpoint in a debugger\n**       to detect when version error conditions occurs.\n**\n**   2.  Invoke sqlite3_log() to provide the source code location where\n**       a low-level error is first detected.\n*/\nSQLITE_PRIVATE int sqlite3ReportError(int iErr, int lineno, const char *zType){\n  sqlite3_log(iErr, \"%s at line %d of [%.10s]\",\n              zType, lineno, 20+sqlite3_sourceid());\n  return iErr;\n}\nSQLITE_PRIVATE int sqlite3CorruptError(int lineno){\n  testcase( sqlite3GlobalConfig.xLog!=0 );\n  return sqlite3ReportError(SQLITE_CORRUPT, lineno, \"database corruption\");\n}\nSQLITE_PRIVATE int sqlite3MisuseError(int lineno){\n  testcase( sqlite3GlobalConfig.xLog!=0 );\n  return sqlite3ReportError(SQLITE_MISUSE, lineno, \"misuse\");\n}\nSQLITE_PRIVATE int sqlite3CantopenError(int lineno){\n  testcase( sqlite3GlobalConfig.xLog!=0 );\n  return sqlite3ReportError(SQLITE_CANTOPEN, lineno, \"cannot open file\");\n}\n#ifdef SQLITE_DEBUG\nSQLITE_PRIVATE int sqlite3CorruptPgnoError(int lineno, Pgno pgno){\n  char zMsg[100];\n  sqlite3_snprintf(sizeof(zMsg), zMsg, \"database corruption page %d\", pgno);\n  testcase( sqlite3GlobalConfig.xLog!=0 );\n  return sqlite3ReportError(SQLITE_CORRUPT, lineno, zMsg);\n}\nSQLITE_PRIVATE int sqlite3NomemError(int lineno){\n  testcase( sqlite3GlobalConfig.xLog!=0 );\n  return sqlite3ReportError(SQLITE_NOMEM, lineno, \"OOM\");\n}\nSQLITE_PRIVATE int sqlite3IoerrnomemError(int lineno){\n  testcase( sqlite3GlobalConfig.xLog!=0 );\n  return sqlite3ReportError(SQLITE_IOERR_NOMEM, lineno, \"I/O OOM error\");\n}\n#endif\n\n#ifndef SQLITE_OMIT_DEPRECATED\n/*\n** This is a convenience routine that makes sure that all thread-specific\n** data for this thread has been deallocated.\n**\n** SQLite no longer uses thread-specific data so this routine is now a\n** no-op.  It is retained for historical compatibility.\n*/\nSQLITE_API void sqlite3_thread_cleanup(void){\n}\n#endif\n\n/*\n** Return meta information about a specific column of a database table.\n** See comment in sqlite3.h (sqlite.h.in) for details.\n*/\nSQLITE_API int sqlite3_table_column_metadata(\n  sqlite3 *db,                /* Connection handle */\n  const char *zDbName,        /* Database name or NULL */\n  const char *zTableName,     /* Table name */\n  const char *zColumnName,    /* Column name */\n  char const **pzDataType,    /* OUTPUT: Declared data type */\n  char const **pzCollSeq,     /* OUTPUT: Collation sequence name */\n  int *pNotNull,              /* OUTPUT: True if NOT NULL constraint exists */\n  int *pPrimaryKey,           /* OUTPUT: True if column part of PK */\n  int *pAutoinc               /* OUTPUT: True if column is auto-increment */\n){\n  int rc;\n  char *zErrMsg = 0;\n  Table *pTab = 0;\n  Column *pCol = 0;\n  int iCol = 0;\n  char const *zDataType = 0;\n  char const *zCollSeq = 0;\n  int notnull = 0;\n  int primarykey = 0;\n  int autoinc = 0;\n\n\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( !sqlite3SafetyCheckOk(db) || zTableName==0 ){\n    return SQLITE_MISUSE_BKPT;\n  }\n#endif\n\n  /* Ensure the database schema has been loaded */\n  sqlite3_mutex_enter(db->mutex);\n  sqlite3BtreeEnterAll(db);\n  rc = sqlite3Init(db, &zErrMsg);\n  if( SQLITE_OK!=rc ){\n    goto error_out;\n  }\n\n  /* Locate the table in question */\n  pTab = sqlite3FindTable(db, zTableName, zDbName);\n  if( !pTab || pTab->pSelect ){\n    pTab = 0;\n    goto error_out;\n  }\n\n  /* Find the column for which info is requested */\n  if( zColumnName==0 ){\n    /* Query for existance of table only */\n  }else{\n    for(iCol=0; iCol<pTab->nCol; iCol++){\n      pCol = &pTab->aCol[iCol];\n      if( 0==sqlite3StrICmp(pCol->zName, zColumnName) ){\n        break;\n      }\n    }\n    if( iCol==pTab->nCol ){\n      if( HasRowid(pTab) && sqlite3IsRowid(zColumnName) ){\n        iCol = pTab->iPKey;\n        pCol = iCol>=0 ? &pTab->aCol[iCol] : 0;\n      }else{\n        pTab = 0;\n        goto error_out;\n      }\n    }\n  }\n\n  /* The following block stores the meta information that will be returned\n  ** to the caller in local variables zDataType, zCollSeq, notnull, primarykey\n  ** and autoinc. At this point there are two possibilities:\n  ** \n  **     1. The specified column name was rowid\", \"oid\" or \"_rowid_\" \n  **        and there is no explicitly declared IPK column. \n  **\n  **     2. The table is not a view and the column name identified an \n  **        explicitly declared column. Copy meta information from *pCol.\n  */ \n  if( pCol ){\n    zDataType = sqlite3ColumnType(pCol,0);\n    zCollSeq = pCol->zColl;\n    notnull = pCol->notNull!=0;\n    primarykey  = (pCol->colFlags & COLFLAG_PRIMKEY)!=0;\n    autoinc = pTab->iPKey==iCol && (pTab->tabFlags & TF_Autoincrement)!=0;\n  }else{\n    zDataType = \"INTEGER\";\n    primarykey = 1;\n  }\n  if( !zCollSeq ){\n    zCollSeq = sqlite3StrBINARY;\n  }\n\nerror_out:\n  sqlite3BtreeLeaveAll(db);\n\n  /* Whether the function call succeeded or failed, set the output parameters\n  ** to whatever their local counterparts contain. If an error did occur,\n  ** this has the effect of zeroing all output parameters.\n  */\n  if( pzDataType ) *pzDataType = zDataType;\n  if( pzCollSeq ) *pzCollSeq = zCollSeq;\n  if( pNotNull ) *pNotNull = notnull;\n  if( pPrimaryKey ) *pPrimaryKey = primarykey;\n  if( pAutoinc ) *pAutoinc = autoinc;\n\n  if( SQLITE_OK==rc && !pTab ){\n    sqlite3DbFree(db, zErrMsg);\n    zErrMsg = sqlite3MPrintf(db, \"no such table column: %s.%s\", zTableName,\n        zColumnName);\n    rc = SQLITE_ERROR;\n  }\n  sqlite3ErrorWithMsg(db, rc, (zErrMsg?\"%s\":0), zErrMsg);\n  sqlite3DbFree(db, zErrMsg);\n  rc = sqlite3ApiExit(db, rc);\n  sqlite3_mutex_leave(db->mutex);\n  return rc;\n}\n\n/*\n** Sleep for a little while.  Return the amount of time slept.\n*/\nSQLITE_API int sqlite3_sleep(int ms){\n  sqlite3_vfs *pVfs;\n  int rc;\n  pVfs = sqlite3_vfs_find(0);\n  if( pVfs==0 ) return 0;\n\n  /* This function works in milliseconds, but the underlying OsSleep() \n  ** API uses microseconds. Hence the 1000's.\n  */\n  rc = (sqlite3OsSleep(pVfs, 1000*ms)/1000);\n  return rc;\n}\n\n/*\n** Enable or disable the extended result codes.\n*/\nSQLITE_API int sqlite3_extended_result_codes(sqlite3 *db, int onoff){\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( !sqlite3SafetyCheckOk(db) ) return SQLITE_MISUSE_BKPT;\n#endif\n  sqlite3_mutex_enter(db->mutex);\n  db->errMask = onoff ? 0xffffffff : 0xff;\n  sqlite3_mutex_leave(db->mutex);\n  return SQLITE_OK;\n}\n\n/*\n** Invoke the xFileControl method on a particular database.\n*/\nSQLITE_API int sqlite3_file_control(sqlite3 *db, const char *zDbName, int op, void *pArg){\n  int rc = SQLITE_ERROR;\n  Btree *pBtree;\n\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( !sqlite3SafetyCheckOk(db) ) return SQLITE_MISUSE_BKPT;\n#endif\n  sqlite3_mutex_enter(db->mutex);\n  pBtree = sqlite3DbNameToBtree(db, zDbName);\n  if( pBtree ){\n    Pager *pPager;\n    sqlite3_file *fd;\n    sqlite3BtreeEnter(pBtree);\n    pPager = sqlite3BtreePager(pBtree);\n    assert( pPager!=0 );\n    fd = sqlite3PagerFile(pPager);\n    assert( fd!=0 );\n    if( op==SQLITE_FCNTL_FILE_POINTER ){\n      *(sqlite3_file**)pArg = fd;\n      rc = SQLITE_OK;\n    }else if( op==SQLITE_FCNTL_VFS_POINTER ){\n      *(sqlite3_vfs**)pArg = sqlite3PagerVfs(pPager);\n      rc = SQLITE_OK;\n    }else if( op==SQLITE_FCNTL_JOURNAL_POINTER ){\n      *(sqlite3_file**)pArg = sqlite3PagerJrnlFile(pPager);\n      rc = SQLITE_OK;\n    }else if( op==SQLITE_FCNTL_DATA_VERSION ){\n      *(unsigned int*)pArg = sqlite3PagerDataVersion(pPager);\n      rc = SQLITE_OK;\n    }else{\n      rc = sqlite3OsFileControl(fd, op, pArg);\n    }\n    sqlite3BtreeLeave(pBtree);\n  }\n  sqlite3_mutex_leave(db->mutex);\n  return rc;\n}\n\n/*\n** Interface to the testing logic.\n*/\nSQLITE_API int sqlite3_test_control(int op, ...){\n  int rc = 0;\n#ifdef SQLITE_UNTESTABLE\n  UNUSED_PARAMETER(op);\n#else\n  va_list ap;\n  va_start(ap, op);\n  switch( op ){\n\n    /*\n    ** Save the current state of the PRNG.\n    */\n    case SQLITE_TESTCTRL_PRNG_SAVE: {\n      sqlite3PrngSaveState();\n      break;\n    }\n\n    /*\n    ** Restore the state of the PRNG to the last state saved using\n    ** PRNG_SAVE.  If PRNG_SAVE has never before been called, then\n    ** this verb acts like PRNG_RESET.\n    */\n    case SQLITE_TESTCTRL_PRNG_RESTORE: {\n      sqlite3PrngRestoreState();\n      break;\n    }\n\n    /*\n    ** Reset the PRNG back to its uninitialized state.  The next call\n    ** to sqlite3_randomness() will reseed the PRNG using a single call\n    ** to the xRandomness method of the default VFS.\n    */\n    case SQLITE_TESTCTRL_PRNG_RESET: {\n      sqlite3_randomness(0,0);\n      break;\n    }\n\n    /*\n    **  sqlite3_test_control(BITVEC_TEST, size, program)\n    **\n    ** Run a test against a Bitvec object of size.  The program argument\n    ** is an array of integers that defines the test.  Return -1 on a\n    ** memory allocation error, 0 on success, or non-zero for an error.\n    ** See the sqlite3BitvecBuiltinTest() for additional information.\n    */\n    case SQLITE_TESTCTRL_BITVEC_TEST: {\n      int sz = va_arg(ap, int);\n      int *aProg = va_arg(ap, int*);\n      rc = sqlite3BitvecBuiltinTest(sz, aProg);\n      break;\n    }\n\n    /*\n    **  sqlite3_test_control(FAULT_INSTALL, xCallback)\n    **\n    ** Arrange to invoke xCallback() whenever sqlite3FaultSim() is called,\n    ** if xCallback is not NULL.\n    **\n    ** As a test of the fault simulator mechanism itself, sqlite3FaultSim(0)\n    ** is called immediately after installing the new callback and the return\n    ** value from sqlite3FaultSim(0) becomes the return from\n    ** sqlite3_test_control().\n    */\n    case SQLITE_TESTCTRL_FAULT_INSTALL: {\n      /* MSVC is picky about pulling func ptrs from va lists.\n      ** http://support.microsoft.com/kb/47961\n      ** sqlite3GlobalConfig.xTestCallback = va_arg(ap, int(*)(int));\n      */\n      typedef int(*TESTCALLBACKFUNC_t)(int);\n      sqlite3GlobalConfig.xTestCallback = va_arg(ap, TESTCALLBACKFUNC_t);\n      rc = sqlite3FaultSim(0);\n      break;\n    }\n\n    /*\n    **  sqlite3_test_control(BENIGN_MALLOC_HOOKS, xBegin, xEnd)\n    **\n    ** Register hooks to call to indicate which malloc() failures \n    ** are benign.\n    */\n    case SQLITE_TESTCTRL_BENIGN_MALLOC_HOOKS: {\n      typedef void (*void_function)(void);\n      void_function xBenignBegin;\n      void_function xBenignEnd;\n      xBenignBegin = va_arg(ap, void_function);\n      xBenignEnd = va_arg(ap, void_function);\n      sqlite3BenignMallocHooks(xBenignBegin, xBenignEnd);\n      break;\n    }\n\n    /*\n    **  sqlite3_test_control(SQLITE_TESTCTRL_PENDING_BYTE, unsigned int X)\n    **\n    ** Set the PENDING byte to the value in the argument, if X>0.\n    ** Make no changes if X==0.  Return the value of the pending byte\n    ** as it existing before this routine was called.\n    **\n    ** IMPORTANT:  Changing the PENDING byte from 0x40000000 results in\n    ** an incompatible database file format.  Changing the PENDING byte\n    ** while any database connection is open results in undefined and\n    ** deleterious behavior.\n    */\n    case SQLITE_TESTCTRL_PENDING_BYTE: {\n      rc = PENDING_BYTE;\n#ifndef SQLITE_OMIT_WSD\n      {\n        unsigned int newVal = va_arg(ap, unsigned int);\n        if( newVal ) sqlite3PendingByte = newVal;\n      }\n#endif\n      break;\n    }\n\n    /*\n    **  sqlite3_test_control(SQLITE_TESTCTRL_ASSERT, int X)\n    **\n    ** This action provides a run-time test to see whether or not\n    ** assert() was enabled at compile-time.  If X is true and assert()\n    ** is enabled, then the return value is true.  If X is true and\n    ** assert() is disabled, then the return value is zero.  If X is\n    ** false and assert() is enabled, then the assertion fires and the\n    ** process aborts.  If X is false and assert() is disabled, then the\n    ** return value is zero.\n    */\n    case SQLITE_TESTCTRL_ASSERT: {\n      volatile int x = 0;\n      assert( /*side-effects-ok*/ (x = va_arg(ap,int))!=0 );\n      rc = x;\n      break;\n    }\n\n\n    /*\n    **  sqlite3_test_control(SQLITE_TESTCTRL_ALWAYS, int X)\n    **\n    ** This action provides a run-time test to see how the ALWAYS and\n    ** NEVER macros were defined at compile-time.\n    **\n    ** The return value is ALWAYS(X) if X is true, or 0 if X is false.\n    **\n    ** The recommended test is X==2.  If the return value is 2, that means\n    ** ALWAYS() and NEVER() are both no-op pass-through macros, which is the\n    ** default setting.  If the return value is 1, then ALWAYS() is either\n    ** hard-coded to true or else it asserts if its argument is false.\n    ** The first behavior (hard-coded to true) is the case if\n    ** SQLITE_TESTCTRL_ASSERT shows that assert() is disabled and the second\n    ** behavior (assert if the argument to ALWAYS() is false) is the case if\n    ** SQLITE_TESTCTRL_ASSERT shows that assert() is enabled.\n    **\n    ** The run-time test procedure might look something like this:\n    **\n    **    if( sqlite3_test_control(SQLITE_TESTCTRL_ALWAYS, 2)==2 ){\n    **      // ALWAYS() and NEVER() are no-op pass-through macros\n    **    }else if( sqlite3_test_control(SQLITE_TESTCTRL_ASSERT, 1) ){\n    **      // ALWAYS(x) asserts that x is true. NEVER(x) asserts x is false.\n    **    }else{\n    **      // ALWAYS(x) is a constant 1.  NEVER(x) is a constant 0.\n    **    }\n    */\n    case SQLITE_TESTCTRL_ALWAYS: {\n      int x = va_arg(ap,int);\n      rc = x ? ALWAYS(x) : 0;\n      break;\n    }\n\n    /*\n    **   sqlite3_test_control(SQLITE_TESTCTRL_BYTEORDER);\n    **\n    ** The integer returned reveals the byte-order of the computer on which\n    ** SQLite is running:\n    **\n    **       1     big-endian,    determined at run-time\n    **      10     little-endian, determined at run-time\n    **  432101     big-endian,    determined at compile-time\n    **  123410     little-endian, determined at compile-time\n    */ \n    case SQLITE_TESTCTRL_BYTEORDER: {\n      rc = SQLITE_BYTEORDER*100 + SQLITE_LITTLEENDIAN*10 + SQLITE_BIGENDIAN;\n      break;\n    }\n\n    /*   sqlite3_test_control(SQLITE_TESTCTRL_RESERVE, sqlite3 *db, int N)\n    **\n    ** Set the nReserve size to N for the main database on the database\n    ** connection db.\n    */\n    case SQLITE_TESTCTRL_RESERVE: {\n      sqlite3 *db = va_arg(ap, sqlite3*);\n      int x = va_arg(ap,int);\n      sqlite3_mutex_enter(db->mutex);\n      sqlite3BtreeSetPageSize(db->aDb[0].pBt, 0, x, 0);\n      sqlite3_mutex_leave(db->mutex);\n      break;\n    }\n\n    /*  sqlite3_test_control(SQLITE_TESTCTRL_OPTIMIZATIONS, sqlite3 *db, int N)\n    **\n    ** Enable or disable various optimizations for testing purposes.  The \n    ** argument N is a bitmask of optimizations to be disabled.  For normal\n    ** operation N should be 0.  The idea is that a test program (like the\n    ** SQL Logic Test or SLT test module) can run the same SQL multiple times\n    ** with various optimizations disabled to verify that the same answer\n    ** is obtained in every case.\n    */\n    case SQLITE_TESTCTRL_OPTIMIZATIONS: {\n      sqlite3 *db = va_arg(ap, sqlite3*);\n      db->dbOptFlags = (u16)(va_arg(ap, int) & 0xffff);\n      break;\n    }\n\n    /*   sqlite3_test_control(SQLITE_TESTCTRL_LOCALTIME_FAULT, int onoff);\n    **\n    ** If parameter onoff is non-zero, subsequent calls to localtime()\n    ** and its variants fail. If onoff is zero, undo this setting.\n    */\n    case SQLITE_TESTCTRL_LOCALTIME_FAULT: {\n      sqlite3GlobalConfig.bLocaltimeFault = va_arg(ap, int);\n      break;\n    }\n\n    /*   sqlite3_test_control(SQLITE_TESTCTRL_INTERNAL_FUNCS, int onoff);\n    **\n    ** If parameter onoff is non-zero, internal-use-only SQL functions\n    ** are visible to ordinary SQL.  This is useful for testing but is\n    ** unsafe because invalid parameters to those internal-use-only functions\n    ** can result in crashes or segfaults.\n    */\n    case SQLITE_TESTCTRL_INTERNAL_FUNCTIONS: {\n      sqlite3GlobalConfig.bInternalFunctions = va_arg(ap, int);\n      break;\n    }\n\n    /*   sqlite3_test_control(SQLITE_TESTCTRL_NEVER_CORRUPT, int);\n    **\n    ** Set or clear a flag that indicates that the database file is always well-\n    ** formed and never corrupt.  This flag is clear by default, indicating that\n    ** database files might have arbitrary corruption.  Setting the flag during\n    ** testing causes certain assert() statements in the code to be activated\n    ** that demonstrat invariants on well-formed database files.\n    */\n    case SQLITE_TESTCTRL_NEVER_CORRUPT: {\n      sqlite3GlobalConfig.neverCorrupt = va_arg(ap, int);\n      break;\n    }\n\n    /* Set the threshold at which OP_Once counters reset back to zero.\n    ** By default this is 0x7ffffffe (over 2 billion), but that value is\n    ** too big to test in a reasonable amount of time, so this control is\n    ** provided to set a small and easily reachable reset value.\n    */\n    case SQLITE_TESTCTRL_ONCE_RESET_THRESHOLD: {\n      sqlite3GlobalConfig.iOnceResetThreshold = va_arg(ap, int);\n      break;\n    }\n\n    /*   sqlite3_test_control(SQLITE_TESTCTRL_VDBE_COVERAGE, xCallback, ptr);\n    **\n    ** Set the VDBE coverage callback function to xCallback with context \n    ** pointer ptr.\n    */\n    case SQLITE_TESTCTRL_VDBE_COVERAGE: {\n#ifdef SQLITE_VDBE_COVERAGE\n      typedef void (*branch_callback)(void*,unsigned int,\n                                      unsigned char,unsigned char);\n      sqlite3GlobalConfig.xVdbeBranch = va_arg(ap,branch_callback);\n      sqlite3GlobalConfig.pVdbeBranchArg = va_arg(ap,void*);\n#endif\n      break;\n    }\n\n    /*   sqlite3_test_control(SQLITE_TESTCTRL_SORTER_MMAP, db, nMax); */\n    case SQLITE_TESTCTRL_SORTER_MMAP: {\n      sqlite3 *db = va_arg(ap, sqlite3*);\n      db->nMaxSorterMmap = va_arg(ap, int);\n      break;\n    }\n\n    /*   sqlite3_test_control(SQLITE_TESTCTRL_ISINIT);\n    **\n    ** Return SQLITE_OK if SQLite has been initialized and SQLITE_ERROR if\n    ** not.\n    */\n    case SQLITE_TESTCTRL_ISINIT: {\n      if( sqlite3GlobalConfig.isInit==0 ) rc = SQLITE_ERROR;\n      break;\n    }\n\n    /*  sqlite3_test_control(SQLITE_TESTCTRL_IMPOSTER, db, dbName, onOff, tnum);\n    **\n    ** This test control is used to create imposter tables.  \"db\" is a pointer\n    ** to the database connection.  dbName is the database name (ex: \"main\" or\n    ** \"temp\") which will receive the imposter.  \"onOff\" turns imposter mode on\n    ** or off.  \"tnum\" is the root page of the b-tree to which the imposter\n    ** table should connect.\n    **\n    ** Enable imposter mode only when the schema has already been parsed.  Then\n    ** run a single CREATE TABLE statement to construct the imposter table in\n    ** the parsed schema.  Then turn imposter mode back off again.\n    **\n    ** If onOff==0 and tnum>0 then reset the schema for all databases, causing\n    ** the schema to be reparsed the next time it is needed.  This has the\n    ** effect of erasing all imposter tables.\n    */\n    case SQLITE_TESTCTRL_IMPOSTER: {\n      sqlite3 *db = va_arg(ap, sqlite3*);\n      sqlite3_mutex_enter(db->mutex);\n      db->init.iDb = sqlite3FindDbName(db, va_arg(ap,const char*));\n      db->init.busy = db->init.imposterTable = va_arg(ap,int);\n      db->init.newTnum = va_arg(ap,int);\n      if( db->init.busy==0 && db->init.newTnum>0 ){\n        sqlite3ResetAllSchemasOfConnection(db);\n      }\n      sqlite3_mutex_leave(db->mutex);\n      break;\n    }\n\n#if defined(YYCOVERAGE)\n    /*  sqlite3_test_control(SQLITE_TESTCTRL_PARSER_COVERAGE, FILE *out)\n    **\n    ** This test control (only available when SQLite is compiled with\n    ** -DYYCOVERAGE) writes a report onto \"out\" that shows all\n    ** state/lookahead combinations in the parser state machine\n    ** which are never exercised.  If any state is missed, make the\n    ** return code SQLITE_ERROR.\n    */\n    case SQLITE_TESTCTRL_PARSER_COVERAGE: {\n      FILE *out = va_arg(ap, FILE*);\n      if( sqlite3ParserCoverage(out) ) rc = SQLITE_ERROR;\n      break;\n    }\n#endif /* defined(YYCOVERAGE) */\n  }\n  va_end(ap);\n#endif /* SQLITE_UNTESTABLE */\n  return rc;\n}\n\n/*\n** This is a utility routine, useful to VFS implementations, that checks\n** to see if a database file was a URI that contained a specific query \n** parameter, and if so obtains the value of the query parameter.\n**\n** The zFilename argument is the filename pointer passed into the xOpen()\n** method of a VFS implementation.  The zParam argument is the name of the\n** query parameter we seek.  This routine returns the value of the zParam\n** parameter if it exists.  If the parameter does not exist, this routine\n** returns a NULL pointer.\n*/\nSQLITE_API const char *sqlite3_uri_parameter(const char *zFilename, const char *zParam){\n  if( zFilename==0 || zParam==0 ) return 0;\n  zFilename += sqlite3Strlen30(zFilename) + 1;\n  while( zFilename[0] ){\n    int x = strcmp(zFilename, zParam);\n    zFilename += sqlite3Strlen30(zFilename) + 1;\n    if( x==0 ) return zFilename;\n    zFilename += sqlite3Strlen30(zFilename) + 1;\n  }\n  return 0;\n}\n\n/*\n** Return a boolean value for a query parameter.\n*/\nSQLITE_API int sqlite3_uri_boolean(const char *zFilename, const char *zParam, int bDflt){\n  const char *z = sqlite3_uri_parameter(zFilename, zParam);\n  bDflt = bDflt!=0;\n  return z ? sqlite3GetBoolean(z, bDflt) : bDflt;\n}\n\n/*\n** Return a 64-bit integer value for a query parameter.\n*/\nSQLITE_API sqlite3_int64 sqlite3_uri_int64(\n  const char *zFilename,    /* Filename as passed to xOpen */\n  const char *zParam,       /* URI parameter sought */\n  sqlite3_int64 bDflt       /* return if parameter is missing */\n){\n  const char *z = sqlite3_uri_parameter(zFilename, zParam);\n  sqlite3_int64 v;\n  if( z && sqlite3DecOrHexToI64(z, &v)==0 ){\n    bDflt = v;\n  }\n  return bDflt;\n}\n\n/*\n** Return the Btree pointer identified by zDbName.  Return NULL if not found.\n*/\nSQLITE_PRIVATE Btree *sqlite3DbNameToBtree(sqlite3 *db, const char *zDbName){\n  int iDb = zDbName ? sqlite3FindDbName(db, zDbName) : 0;\n  return iDb<0 ? 0 : db->aDb[iDb].pBt;\n}\n\n/*\n** Return the filename of the database associated with a database\n** connection.\n*/\nSQLITE_API const char *sqlite3_db_filename(sqlite3 *db, const char *zDbName){\n  Btree *pBt;\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( !sqlite3SafetyCheckOk(db) ){\n    (void)SQLITE_MISUSE_BKPT;\n    return 0;\n  }\n#endif\n  pBt = sqlite3DbNameToBtree(db, zDbName);\n  return pBt ? sqlite3BtreeGetFilename(pBt) : 0;\n}\n\n/*\n** Return 1 if database is read-only or 0 if read/write.  Return -1 if\n** no such database exists.\n*/\nSQLITE_API int sqlite3_db_readonly(sqlite3 *db, const char *zDbName){\n  Btree *pBt;\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( !sqlite3SafetyCheckOk(db) ){\n    (void)SQLITE_MISUSE_BKPT;\n    return -1;\n  }\n#endif\n  pBt = sqlite3DbNameToBtree(db, zDbName);\n  return pBt ? sqlite3BtreeIsReadonly(pBt) : -1;\n}\n\n#ifdef SQLITE_ENABLE_SNAPSHOT\n/*\n** Obtain a snapshot handle for the snapshot of database zDb currently \n** being read by handle db.\n*/\nSQLITE_API int sqlite3_snapshot_get(\n  sqlite3 *db, \n  const char *zDb,\n  sqlite3_snapshot **ppSnapshot\n){\n  int rc = SQLITE_ERROR;\n#ifndef SQLITE_OMIT_WAL\n\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( !sqlite3SafetyCheckOk(db) ){\n    return SQLITE_MISUSE_BKPT;\n  }\n#endif\n  sqlite3_mutex_enter(db->mutex);\n\n  if( db->autoCommit==0 ){\n    int iDb = sqlite3FindDbName(db, zDb);\n    if( iDb==0 || iDb>1 ){\n      Btree *pBt = db->aDb[iDb].pBt;\n      if( 0==sqlite3BtreeIsInTrans(pBt) ){\n        rc = sqlite3BtreeBeginTrans(pBt, 0, 0);\n        if( rc==SQLITE_OK ){\n          rc = sqlite3PagerSnapshotGet(sqlite3BtreePager(pBt), ppSnapshot);\n        }\n      }\n    }\n  }\n\n  sqlite3_mutex_leave(db->mutex);\n#endif   /* SQLITE_OMIT_WAL */\n  return rc;\n}\n\n/*\n** Open a read-transaction on the snapshot idendified by pSnapshot.\n*/\nSQLITE_API int sqlite3_snapshot_open(\n  sqlite3 *db, \n  const char *zDb, \n  sqlite3_snapshot *pSnapshot\n){\n  int rc = SQLITE_ERROR;\n#ifndef SQLITE_OMIT_WAL\n\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( !sqlite3SafetyCheckOk(db) ){\n    return SQLITE_MISUSE_BKPT;\n  }\n#endif\n  sqlite3_mutex_enter(db->mutex);\n  if( db->autoCommit==0 ){\n    int iDb;\n    iDb = sqlite3FindDbName(db, zDb);\n    if( iDb==0 || iDb>1 ){\n      Btree *pBt = db->aDb[iDb].pBt;\n      if( sqlite3BtreeIsInTrans(pBt)==0 ){\n        Pager *pPager = sqlite3BtreePager(pBt);\n        int bUnlock = 0;\n        if( sqlite3BtreeIsInReadTrans(pBt) ){\n          if( db->nVdbeActive==0 ){\n            rc = sqlite3PagerSnapshotCheck(pPager, pSnapshot);\n            if( rc==SQLITE_OK ){\n              bUnlock = 1;\n              rc = sqlite3BtreeCommit(pBt);\n            }\n          }\n        }else{\n          rc = SQLITE_OK;\n        }\n        if( rc==SQLITE_OK ){\n          rc = sqlite3PagerSnapshotOpen(pPager, pSnapshot);\n        }\n        if( rc==SQLITE_OK ){\n          rc = sqlite3BtreeBeginTrans(pBt, 0, 0);\n          sqlite3PagerSnapshotOpen(pPager, 0);\n        }\n        if( bUnlock ){\n          sqlite3PagerSnapshotUnlock(pPager);\n        }\n      }\n    }\n  }\n\n  sqlite3_mutex_leave(db->mutex);\n#endif   /* SQLITE_OMIT_WAL */\n  return rc;\n}\n\n/*\n** Recover as many snapshots as possible from the wal file associated with\n** schema zDb of database db.\n*/\nSQLITE_API int sqlite3_snapshot_recover(sqlite3 *db, const char *zDb){\n  int rc = SQLITE_ERROR;\n  int iDb;\n#ifndef SQLITE_OMIT_WAL\n\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( !sqlite3SafetyCheckOk(db) ){\n    return SQLITE_MISUSE_BKPT;\n  }\n#endif\n\n  sqlite3_mutex_enter(db->mutex);\n  iDb = sqlite3FindDbName(db, zDb);\n  if( iDb==0 || iDb>1 ){\n    Btree *pBt = db->aDb[iDb].pBt;\n    if( 0==sqlite3BtreeIsInReadTrans(pBt) ){\n      rc = sqlite3BtreeBeginTrans(pBt, 0, 0);\n      if( rc==SQLITE_OK ){\n        rc = sqlite3PagerSnapshotRecover(sqlite3BtreePager(pBt));\n        sqlite3BtreeCommit(pBt);\n      }\n    }\n  }\n  sqlite3_mutex_leave(db->mutex);\n#endif   /* SQLITE_OMIT_WAL */\n  return rc;\n}\n\n/*\n** Free a snapshot handle obtained from sqlite3_snapshot_get().\n*/\nSQLITE_API void sqlite3_snapshot_free(sqlite3_snapshot *pSnapshot){\n  sqlite3_free(pSnapshot);\n}\n#endif /* SQLITE_ENABLE_SNAPSHOT */\n\n#ifndef SQLITE_OMIT_COMPILEOPTION_DIAGS\n/*\n** Given the name of a compile-time option, return true if that option\n** was used and false if not.\n**\n** The name can optionally begin with \"SQLITE_\" but the \"SQLITE_\" prefix\n** is not required for a match.\n*/\nSQLITE_API int sqlite3_compileoption_used(const char *zOptName){\n  int i, n;\n  int nOpt;\n  const char **azCompileOpt;\n \n#if SQLITE_ENABLE_API_ARMOR\n  if( zOptName==0 ){\n    (void)SQLITE_MISUSE_BKPT;\n    return 0;\n  }\n#endif\n\n  azCompileOpt = sqlite3CompileOptions(&nOpt);\n\n  if( sqlite3StrNICmp(zOptName, \"SQLITE_\", 7)==0 ) zOptName += 7;\n  n = sqlite3Strlen30(zOptName);\n\n  /* Since nOpt is normally in single digits, a linear search is \n  ** adequate. No need for a binary search. */\n  for(i=0; i<nOpt; i++){\n    if( sqlite3StrNICmp(zOptName, azCompileOpt[i], n)==0\n     && sqlite3IsIdChar((unsigned char)azCompileOpt[i][n])==0\n    ){\n      return 1;\n    }\n  }\n  return 0;\n}\n\n/*\n** Return the N-th compile-time option string.  If N is out of range,\n** return a NULL pointer.\n*/\nSQLITE_API const char *sqlite3_compileoption_get(int N){\n  int nOpt;\n  const char **azCompileOpt;\n  azCompileOpt = sqlite3CompileOptions(&nOpt);\n  if( N>=0 && N<nOpt ){\n    return azCompileOpt[N];\n  }\n  return 0;\n}\n#endif /* SQLITE_OMIT_COMPILEOPTION_DIAGS */\n\n/************** End of main.c ************************************************/\n/************** Begin file notify.c ******************************************/\n/*\n** 2009 March 3\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n**\n** This file contains the implementation of the sqlite3_unlock_notify()\n** API method and its associated functionality.\n*/\n/* #include \"sqliteInt.h\" */\n/* #include \"btreeInt.h\" */\n\n/* Omit this entire file if SQLITE_ENABLE_UNLOCK_NOTIFY is not defined. */\n#ifdef SQLITE_ENABLE_UNLOCK_NOTIFY\n\n/*\n** Public interfaces:\n**\n**   sqlite3ConnectionBlocked()\n**   sqlite3ConnectionUnlocked()\n**   sqlite3ConnectionClosed()\n**   sqlite3_unlock_notify()\n*/\n\n#define assertMutexHeld() \\\n  assert( sqlite3_mutex_held(sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER)) )\n\n/*\n** Head of a linked list of all sqlite3 objects created by this process\n** for which either sqlite3.pBlockingConnection or sqlite3.pUnlockConnection\n** is not NULL. This variable may only accessed while the STATIC_MASTER\n** mutex is held.\n*/\nstatic sqlite3 *SQLITE_WSD sqlite3BlockedList = 0;\n\n#ifndef NDEBUG\n/*\n** This function is a complex assert() that verifies the following \n** properties of the blocked connections list:\n**\n**   1) Each entry in the list has a non-NULL value for either \n**      pUnlockConnection or pBlockingConnection, or both.\n**\n**   2) All entries in the list that share a common value for \n**      xUnlockNotify are grouped together.\n**\n**   3) If the argument db is not NULL, then none of the entries in the\n**      blocked connections list have pUnlockConnection or pBlockingConnection\n**      set to db. This is used when closing connection db.\n*/\nstatic void checkListProperties(sqlite3 *db){\n  sqlite3 *p;\n  for(p=sqlite3BlockedList; p; p=p->pNextBlocked){\n    int seen = 0;\n    sqlite3 *p2;\n\n    /* Verify property (1) */\n    assert( p->pUnlockConnection || p->pBlockingConnection );\n\n    /* Verify property (2) */\n    for(p2=sqlite3BlockedList; p2!=p; p2=p2->pNextBlocked){\n      if( p2->xUnlockNotify==p->xUnlockNotify ) seen = 1;\n      assert( p2->xUnlockNotify==p->xUnlockNotify || !seen );\n      assert( db==0 || p->pUnlockConnection!=db );\n      assert( db==0 || p->pBlockingConnection!=db );\n    }\n  }\n}\n#else\n# define checkListProperties(x)\n#endif\n\n/*\n** Remove connection db from the blocked connections list. If connection\n** db is not currently a part of the list, this function is a no-op.\n*/\nstatic void removeFromBlockedList(sqlite3 *db){\n  sqlite3 **pp;\n  assertMutexHeld();\n  for(pp=&sqlite3BlockedList; *pp; pp = &(*pp)->pNextBlocked){\n    if( *pp==db ){\n      *pp = (*pp)->pNextBlocked;\n      break;\n    }\n  }\n}\n\n/*\n** Add connection db to the blocked connections list. It is assumed\n** that it is not already a part of the list.\n*/\nstatic void addToBlockedList(sqlite3 *db){\n  sqlite3 **pp;\n  assertMutexHeld();\n  for(\n    pp=&sqlite3BlockedList; \n    *pp && (*pp)->xUnlockNotify!=db->xUnlockNotify; \n    pp=&(*pp)->pNextBlocked\n  );\n  db->pNextBlocked = *pp;\n  *pp = db;\n}\n\n/*\n** Obtain the STATIC_MASTER mutex.\n*/\nstatic void enterMutex(void){\n  sqlite3_mutex_enter(sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER));\n  checkListProperties(0);\n}\n\n/*\n** Release the STATIC_MASTER mutex.\n*/\nstatic void leaveMutex(void){\n  assertMutexHeld();\n  checkListProperties(0);\n  sqlite3_mutex_leave(sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER));\n}\n\n/*\n** Register an unlock-notify callback.\n**\n** This is called after connection \"db\" has attempted some operation\n** but has received an SQLITE_LOCKED error because another connection\n** (call it pOther) in the same process was busy using the same shared\n** cache.  pOther is found by looking at db->pBlockingConnection.\n**\n** If there is no blocking connection, the callback is invoked immediately,\n** before this routine returns.\n**\n** If pOther is already blocked on db, then report SQLITE_LOCKED, to indicate\n** a deadlock.\n**\n** Otherwise, make arrangements to invoke xNotify when pOther drops\n** its locks.\n**\n** Each call to this routine overrides any prior callbacks registered\n** on the same \"db\".  If xNotify==0 then any prior callbacks are immediately\n** cancelled.\n*/\nSQLITE_API int sqlite3_unlock_notify(\n  sqlite3 *db,\n  void (*xNotify)(void **, int),\n  void *pArg\n){\n  int rc = SQLITE_OK;\n\n  sqlite3_mutex_enter(db->mutex);\n  enterMutex();\n\n  if( xNotify==0 ){\n    removeFromBlockedList(db);\n    db->pBlockingConnection = 0;\n    db->pUnlockConnection = 0;\n    db->xUnlockNotify = 0;\n    db->pUnlockArg = 0;\n  }else if( 0==db->pBlockingConnection ){\n    /* The blocking transaction has been concluded. Or there never was a \n    ** blocking transaction. In either case, invoke the notify callback\n    ** immediately. \n    */\n    xNotify(&pArg, 1);\n  }else{\n    sqlite3 *p;\n\n    for(p=db->pBlockingConnection; p && p!=db; p=p->pUnlockConnection){}\n    if( p ){\n      rc = SQLITE_LOCKED;              /* Deadlock detected. */\n    }else{\n      db->pUnlockConnection = db->pBlockingConnection;\n      db->xUnlockNotify = xNotify;\n      db->pUnlockArg = pArg;\n      removeFromBlockedList(db);\n      addToBlockedList(db);\n    }\n  }\n\n  leaveMutex();\n  assert( !db->mallocFailed );\n  sqlite3ErrorWithMsg(db, rc, (rc?\"database is deadlocked\":0));\n  sqlite3_mutex_leave(db->mutex);\n  return rc;\n}\n\n/*\n** This function is called while stepping or preparing a statement \n** associated with connection db. The operation will return SQLITE_LOCKED\n** to the user because it requires a lock that will not be available\n** until connection pBlocker concludes its current transaction.\n*/\nSQLITE_PRIVATE void sqlite3ConnectionBlocked(sqlite3 *db, sqlite3 *pBlocker){\n  enterMutex();\n  if( db->pBlockingConnection==0 && db->pUnlockConnection==0 ){\n    addToBlockedList(db);\n  }\n  db->pBlockingConnection = pBlocker;\n  leaveMutex();\n}\n\n/*\n** This function is called when\n** the transaction opened by database db has just finished. Locks held \n** by database connection db have been released.\n**\n** This function loops through each entry in the blocked connections\n** list and does the following:\n**\n**   1) If the sqlite3.pBlockingConnection member of a list entry is\n**      set to db, then set pBlockingConnection=0.\n**\n**   2) If the sqlite3.pUnlockConnection member of a list entry is\n**      set to db, then invoke the configured unlock-notify callback and\n**      set pUnlockConnection=0.\n**\n**   3) If the two steps above mean that pBlockingConnection==0 and\n**      pUnlockConnection==0, remove the entry from the blocked connections\n**      list.\n*/\nSQLITE_PRIVATE void sqlite3ConnectionUnlocked(sqlite3 *db){\n  void (*xUnlockNotify)(void **, int) = 0; /* Unlock-notify cb to invoke */\n  int nArg = 0;                            /* Number of entries in aArg[] */\n  sqlite3 **pp;                            /* Iterator variable */\n  void **aArg;               /* Arguments to the unlock callback */\n  void **aDyn = 0;           /* Dynamically allocated space for aArg[] */\n  void *aStatic[16];         /* Starter space for aArg[].  No malloc required */\n\n  aArg = aStatic;\n  enterMutex();         /* Enter STATIC_MASTER mutex */\n\n  /* This loop runs once for each entry in the blocked-connections list. */\n  for(pp=&sqlite3BlockedList; *pp; /* no-op */ ){\n    sqlite3 *p = *pp;\n\n    /* Step 1. */\n    if( p->pBlockingConnection==db ){\n      p->pBlockingConnection = 0;\n    }\n\n    /* Step 2. */\n    if( p->pUnlockConnection==db ){\n      assert( p->xUnlockNotify );\n      if( p->xUnlockNotify!=xUnlockNotify && nArg!=0 ){\n        xUnlockNotify(aArg, nArg);\n        nArg = 0;\n      }\n\n      sqlite3BeginBenignMalloc();\n      assert( aArg==aDyn || (aDyn==0 && aArg==aStatic) );\n      assert( nArg<=(int)ArraySize(aStatic) || aArg==aDyn );\n      if( (!aDyn && nArg==(int)ArraySize(aStatic))\n       || (aDyn && nArg==(int)(sqlite3MallocSize(aDyn)/sizeof(void*)))\n      ){\n        /* The aArg[] array needs to grow. */\n        void **pNew = (void **)sqlite3Malloc(nArg*sizeof(void *)*2);\n        if( pNew ){\n          memcpy(pNew, aArg, nArg*sizeof(void *));\n          sqlite3_free(aDyn);\n          aDyn = aArg = pNew;\n        }else{\n          /* This occurs when the array of context pointers that need to\n          ** be passed to the unlock-notify callback is larger than the\n          ** aStatic[] array allocated on the stack and the attempt to \n          ** allocate a larger array from the heap has failed.\n          **\n          ** This is a difficult situation to handle. Returning an error\n          ** code to the caller is insufficient, as even if an error code\n          ** is returned the transaction on connection db will still be\n          ** closed and the unlock-notify callbacks on blocked connections\n          ** will go unissued. This might cause the application to wait\n          ** indefinitely for an unlock-notify callback that will never \n          ** arrive.\n          **\n          ** Instead, invoke the unlock-notify callback with the context\n          ** array already accumulated. We can then clear the array and\n          ** begin accumulating any further context pointers without \n          ** requiring any dynamic allocation. This is sub-optimal because\n          ** it means that instead of one callback with a large array of\n          ** context pointers the application will receive two or more\n          ** callbacks with smaller arrays of context pointers, which will\n          ** reduce the applications ability to prioritize multiple \n          ** connections. But it is the best that can be done under the\n          ** circumstances.\n          */\n          xUnlockNotify(aArg, nArg);\n          nArg = 0;\n        }\n      }\n      sqlite3EndBenignMalloc();\n\n      aArg[nArg++] = p->pUnlockArg;\n      xUnlockNotify = p->xUnlockNotify;\n      p->pUnlockConnection = 0;\n      p->xUnlockNotify = 0;\n      p->pUnlockArg = 0;\n    }\n\n    /* Step 3. */\n    if( p->pBlockingConnection==0 && p->pUnlockConnection==0 ){\n      /* Remove connection p from the blocked connections list. */\n      *pp = p->pNextBlocked;\n      p->pNextBlocked = 0;\n    }else{\n      pp = &p->pNextBlocked;\n    }\n  }\n\n  if( nArg!=0 ){\n    xUnlockNotify(aArg, nArg);\n  }\n  sqlite3_free(aDyn);\n  leaveMutex();         /* Leave STATIC_MASTER mutex */\n}\n\n/*\n** This is called when the database connection passed as an argument is \n** being closed. The connection is removed from the blocked list.\n*/\nSQLITE_PRIVATE void sqlite3ConnectionClosed(sqlite3 *db){\n  sqlite3ConnectionUnlocked(db);\n  enterMutex();\n  removeFromBlockedList(db);\n  checkListProperties(db);\n  leaveMutex();\n}\n#endif\n\n/************** End of notify.c **********************************************/\n/************** Begin file fts3.c ********************************************/\n/*\n** 2006 Oct 10\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n******************************************************************************\n**\n** This is an SQLite module implementing full-text search.\n*/\n\n/*\n** The code in this file is only compiled if:\n**\n**     * The FTS3 module is being built as an extension\n**       (in which case SQLITE_CORE is not defined), or\n**\n**     * The FTS3 module is being built into the core of\n**       SQLite (in which case SQLITE_ENABLE_FTS3 is defined).\n*/\n\n/* The full-text index is stored in a series of b+tree (-like)\n** structures called segments which map terms to doclists.  The\n** structures are like b+trees in layout, but are constructed from the\n** bottom up in optimal fashion and are not updatable.  Since trees\n** are built from the bottom up, things will be described from the\n** bottom up.\n**\n**\n**** Varints ****\n** The basic unit of encoding is a variable-length integer called a\n** varint.  We encode variable-length integers in little-endian order\n** using seven bits * per byte as follows:\n**\n** KEY:\n**         A = 0xxxxxxx    7 bits of data and one flag bit\n**         B = 1xxxxxxx    7 bits of data and one flag bit\n**\n**  7 bits - A\n** 14 bits - BA\n** 21 bits - BBA\n** and so on.\n**\n** This is similar in concept to how sqlite encodes \"varints\" but\n** the encoding is not the same.  SQLite varints are big-endian\n** are are limited to 9 bytes in length whereas FTS3 varints are\n** little-endian and can be up to 10 bytes in length (in theory).\n**\n** Example encodings:\n**\n**     1:    0x01\n**   127:    0x7f\n**   128:    0x81 0x00\n**\n**\n**** Document lists ****\n** A doclist (document list) holds a docid-sorted list of hits for a\n** given term.  Doclists hold docids and associated token positions.\n** A docid is the unique integer identifier for a single document.\n** A position is the index of a word within the document.  The first \n** word of the document has a position of 0.\n**\n** FTS3 used to optionally store character offsets using a compile-time\n** option.  But that functionality is no longer supported.\n**\n** A doclist is stored like this:\n**\n** array {\n**   varint docid;          (delta from previous doclist)\n**   array {                (position list for column 0)\n**     varint position;     (2 more than the delta from previous position)\n**   }\n**   array {\n**     varint POS_COLUMN;   (marks start of position list for new column)\n**     varint column;       (index of new column)\n**     array {\n**       varint position;   (2 more than the delta from previous position)\n**     }\n**   }\n**   varint POS_END;        (marks end of positions for this document.\n** }\n**\n** Here, array { X } means zero or more occurrences of X, adjacent in\n** memory.  A \"position\" is an index of a token in the token stream\n** generated by the tokenizer. Note that POS_END and POS_COLUMN occur \n** in the same logical place as the position element, and act as sentinals\n** ending a position list array.  POS_END is 0.  POS_COLUMN is 1.\n** The positions numbers are not stored literally but rather as two more\n** than the difference from the prior position, or the just the position plus\n** 2 for the first position.  Example:\n**\n**   label:       A B C D E  F  G H   I  J K\n**   value:     123 5 9 1 1 14 35 0 234 72 0\n**\n** The 123 value is the first docid.  For column zero in this document\n** there are two matches at positions 3 and 10 (5-2 and 9-2+3).  The 1\n** at D signals the start of a new column; the 1 at E indicates that the\n** new column is column number 1.  There are two positions at 12 and 45\n** (14-2 and 35-2+12).  The 0 at H indicate the end-of-document.  The\n** 234 at I is the delta to next docid (357).  It has one position 70\n** (72-2) and then terminates with the 0 at K.\n**\n** A \"position-list\" is the list of positions for multiple columns for\n** a single docid.  A \"column-list\" is the set of positions for a single\n** column.  Hence, a position-list consists of one or more column-lists,\n** a document record consists of a docid followed by a position-list and\n** a doclist consists of one or more document records.\n**\n** A bare doclist omits the position information, becoming an \n** array of varint-encoded docids.\n**\n**** Segment leaf nodes ****\n** Segment leaf nodes store terms and doclists, ordered by term.  Leaf\n** nodes are written using LeafWriter, and read using LeafReader (to\n** iterate through a single leaf node's data) and LeavesReader (to\n** iterate through a segment's entire leaf layer).  Leaf nodes have\n** the format:\n**\n** varint iHeight;             (height from leaf level, always 0)\n** varint nTerm;               (length of first term)\n** char pTerm[nTerm];          (content of first term)\n** varint nDoclist;            (length of term's associated doclist)\n** char pDoclist[nDoclist];    (content of doclist)\n** array {\n**                             (further terms are delta-encoded)\n**   varint nPrefix;           (length of prefix shared with previous term)\n**   varint nSuffix;           (length of unshared suffix)\n**   char pTermSuffix[nSuffix];(unshared suffix of next term)\n**   varint nDoclist;          (length of term's associated doclist)\n**   char pDoclist[nDoclist];  (content of doclist)\n** }\n**\n** Here, array { X } means zero or more occurrences of X, adjacent in\n** memory.\n**\n** Leaf nodes are broken into blocks which are stored contiguously in\n** the %_segments table in sorted order.  This means that when the end\n** of a node is reached, the next term is in the node with the next\n** greater node id.\n**\n** New data is spilled to a new leaf node when the current node\n** exceeds LEAF_MAX bytes (default 2048).  New data which itself is\n** larger than STANDALONE_MIN (default 1024) is placed in a standalone\n** node (a leaf node with a single term and doclist).  The goal of\n** these settings is to pack together groups of small doclists while\n** making it efficient to directly access large doclists.  The\n** assumption is that large doclists represent terms which are more\n** likely to be query targets.\n**\n** TODO(shess) It may be useful for blocking decisions to be more\n** dynamic.  For instance, it may make more sense to have a 2.5k leaf\n** node rather than splitting into 2k and .5k nodes.  My intuition is\n** that this might extend through 2x or 4x the pagesize.\n**\n**\n**** Segment interior nodes ****\n** Segment interior nodes store blockids for subtree nodes and terms\n** to describe what data is stored by the each subtree.  Interior\n** nodes are written using InteriorWriter, and read using\n** InteriorReader.  InteriorWriters are created as needed when\n** SegmentWriter creates new leaf nodes, or when an interior node\n** itself grows too big and must be split.  The format of interior\n** nodes:\n**\n** varint iHeight;           (height from leaf level, always >0)\n** varint iBlockid;          (block id of node's leftmost subtree)\n** optional {\n**   varint nTerm;           (length of first term)\n**   char pTerm[nTerm];      (content of first term)\n**   array {\n**                                (further terms are delta-encoded)\n**     varint nPrefix;            (length of shared prefix with previous term)\n**     varint nSuffix;            (length of unshared suffix)\n**     char pTermSuffix[nSuffix]; (unshared suffix of next term)\n**   }\n** }\n**\n** Here, optional { X } means an optional element, while array { X }\n** means zero or more occurrences of X, adjacent in memory.\n**\n** An interior node encodes n terms separating n+1 subtrees.  The\n** subtree blocks are contiguous, so only the first subtree's blockid\n** is encoded.  The subtree at iBlockid will contain all terms less\n** than the first term encoded (or all terms if no term is encoded).\n** Otherwise, for terms greater than or equal to pTerm[i] but less\n** than pTerm[i+1], the subtree for that term will be rooted at\n** iBlockid+i.  Interior nodes only store enough term data to\n** distinguish adjacent children (if the rightmost term of the left\n** child is \"something\", and the leftmost term of the right child is\n** \"wicked\", only \"w\" is stored).\n**\n** New data is spilled to a new interior node at the same height when\n** the current node exceeds INTERIOR_MAX bytes (default 2048).\n** INTERIOR_MIN_TERMS (default 7) keeps large terms from monopolizing\n** interior nodes and making the tree too skinny.  The interior nodes\n** at a given height are naturally tracked by interior nodes at\n** height+1, and so on.\n**\n**\n**** Segment directory ****\n** The segment directory in table %_segdir stores meta-information for\n** merging and deleting segments, and also the root node of the\n** segment's tree.\n**\n** The root node is the top node of the segment's tree after encoding\n** the entire segment, restricted to ROOT_MAX bytes (default 1024).\n** This could be either a leaf node or an interior node.  If the top\n** node requires more than ROOT_MAX bytes, it is flushed to %_segments\n** and a new root interior node is generated (which should always fit\n** within ROOT_MAX because it only needs space for 2 varints, the\n** height and the blockid of the previous root).\n**\n** The meta-information in the segment directory is:\n**   level               - segment level (see below)\n**   idx                 - index within level\n**                       - (level,idx uniquely identify a segment)\n**   start_block         - first leaf node\n**   leaves_end_block    - last leaf node\n**   end_block           - last block (including interior nodes)\n**   root                - contents of root node\n**\n** If the root node is a leaf node, then start_block,\n** leaves_end_block, and end_block are all 0.\n**\n**\n**** Segment merging ****\n** To amortize update costs, segments are grouped into levels and\n** merged in batches.  Each increase in level represents exponentially\n** more documents.\n**\n** New documents (actually, document updates) are tokenized and\n** written individually (using LeafWriter) to a level 0 segment, with\n** incrementing idx.  When idx reaches MERGE_COUNT (default 16), all\n** level 0 segments are merged into a single level 1 segment.  Level 1\n** is populated like level 0, and eventually MERGE_COUNT level 1\n** segments are merged to a single level 2 segment (representing\n** MERGE_COUNT^2 updates), and so on.\n**\n** A segment merge traverses all segments at a given level in\n** parallel, performing a straightforward sorted merge.  Since segment\n** leaf nodes are written in to the %_segments table in order, this\n** merge traverses the underlying sqlite disk structures efficiently.\n** After the merge, all segment blocks from the merged level are\n** deleted.\n**\n** MERGE_COUNT controls how often we merge segments.  16 seems to be\n** somewhat of a sweet spot for insertion performance.  32 and 64 show\n** very similar performance numbers to 16 on insertion, though they're\n** a tiny bit slower (perhaps due to more overhead in merge-time\n** sorting).  8 is about 20% slower than 16, 4 about 50% slower than\n** 16, 2 about 66% slower than 16.\n**\n** At query time, high MERGE_COUNT increases the number of segments\n** which need to be scanned and merged.  For instance, with 100k docs\n** inserted:\n**\n**    MERGE_COUNT   segments\n**       16           25\n**        8           12\n**        4           10\n**        2            6\n**\n** This appears to have only a moderate impact on queries for very\n** frequent terms (which are somewhat dominated by segment merge\n** costs), and infrequent and non-existent terms still seem to be fast\n** even with many segments.\n**\n** TODO(shess) That said, it would be nice to have a better query-side\n** argument for MERGE_COUNT of 16.  Also, it is possible/likely that\n** optimizations to things like doclist merging will swing the sweet\n** spot around.\n**\n**\n**\n**** Handling of deletions and updates ****\n** Since we're using a segmented structure, with no docid-oriented\n** index into the term index, we clearly cannot simply update the term\n** index when a document is deleted or updated.  For deletions, we\n** write an empty doclist (varint(docid) varint(POS_END)), for updates\n** we simply write the new doclist.  Segment merges overwrite older\n** data for a particular docid with newer data, so deletes or updates\n** will eventually overtake the earlier data and knock it out.  The\n** query logic likewise merges doclists so that newer data knocks out\n** older data.\n*/\n\n/************** Include fts3Int.h in the middle of fts3.c ********************/\n/************** Begin file fts3Int.h *****************************************/\n/*\n** 2009 Nov 12\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n******************************************************************************\n**\n*/\n#ifndef _FTSINT_H\n#define _FTSINT_H\n\n#if !defined(NDEBUG) && !defined(SQLITE_DEBUG) \n# define NDEBUG 1\n#endif\n\n/* FTS3/FTS4 require virtual tables */\n#ifdef SQLITE_OMIT_VIRTUALTABLE\n# undef SQLITE_ENABLE_FTS3\n# undef SQLITE_ENABLE_FTS4\n#endif\n\n/*\n** FTS4 is really an extension for FTS3.  It is enabled using the\n** SQLITE_ENABLE_FTS3 macro.  But to avoid confusion we also all\n** the SQLITE_ENABLE_FTS4 macro to serve as an alisse for SQLITE_ENABLE_FTS3.\n*/\n#if defined(SQLITE_ENABLE_FTS4) && !defined(SQLITE_ENABLE_FTS3)\n# define SQLITE_ENABLE_FTS3\n#endif\n\n#if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3)\n\n/* If not building as part of the core, include sqlite3ext.h. */\n#ifndef SQLITE_CORE\n/* # include \"sqlite3ext.h\"  */\nSQLITE_EXTENSION_INIT3\n#endif\n\n/* #include \"sqlite3.h\" */\n/************** Include fts3_tokenizer.h in the middle of fts3Int.h **********/\n/************** Begin file fts3_tokenizer.h **********************************/\n/*\n** 2006 July 10\n**\n** The author disclaims copyright to this source code.\n**\n*************************************************************************\n** Defines the interface to tokenizers used by fulltext-search.  There\n** are three basic components:\n**\n** sqlite3_tokenizer_module is a singleton defining the tokenizer\n** interface functions.  This is essentially the class structure for\n** tokenizers.\n**\n** sqlite3_tokenizer is used to define a particular tokenizer, perhaps\n** including customization information defined at creation time.\n**\n** sqlite3_tokenizer_cursor is generated by a tokenizer to generate\n** tokens from a particular input.\n*/\n#ifndef _FTS3_TOKENIZER_H_\n#define _FTS3_TOKENIZER_H_\n\n/* TODO(shess) Only used for SQLITE_OK and SQLITE_DONE at this time.\n** If tokenizers are to be allowed to call sqlite3_*() functions, then\n** we will need a way to register the API consistently.\n*/\n/* #include \"sqlite3.h\" */\n\n/*\n** Structures used by the tokenizer interface. When a new tokenizer\n** implementation is registered, the caller provides a pointer to\n** an sqlite3_tokenizer_module containing pointers to the callback\n** functions that make up an implementation.\n**\n** When an fts3 table is created, it passes any arguments passed to\n** the tokenizer clause of the CREATE VIRTUAL TABLE statement to the\n** sqlite3_tokenizer_module.xCreate() function of the requested tokenizer\n** implementation. The xCreate() function in turn returns an \n** sqlite3_tokenizer structure representing the specific tokenizer to\n** be used for the fts3 table (customized by the tokenizer clause arguments).\n**\n** To tokenize an input buffer, the sqlite3_tokenizer_module.xOpen()\n** method is called. It returns an sqlite3_tokenizer_cursor object\n** that may be used to tokenize a specific input buffer based on\n** the tokenization rules supplied by a specific sqlite3_tokenizer\n** object.\n*/\ntypedef struct sqlite3_tokenizer_module sqlite3_tokenizer_module;\ntypedef struct sqlite3_tokenizer sqlite3_tokenizer;\ntypedef struct sqlite3_tokenizer_cursor sqlite3_tokenizer_cursor;\n\nstruct sqlite3_tokenizer_module {\n\n  /*\n  ** Structure version. Should always be set to 0 or 1.\n  */\n  int iVersion;\n\n  /*\n  ** Create a new tokenizer. The values in the argv[] array are the\n  ** arguments passed to the \"tokenizer\" clause of the CREATE VIRTUAL\n  ** TABLE statement that created the fts3 table. For example, if\n  ** the following SQL is executed:\n  **\n  **   CREATE .. USING fts3( ... , tokenizer <tokenizer-name> arg1 arg2)\n  **\n  ** then argc is set to 2, and the argv[] array contains pointers\n  ** to the strings \"arg1\" and \"arg2\".\n  **\n  ** This method should return either SQLITE_OK (0), or an SQLite error \n  ** code. If SQLITE_OK is returned, then *ppTokenizer should be set\n  ** to point at the newly created tokenizer structure. The generic\n  ** sqlite3_tokenizer.pModule variable should not be initialized by\n  ** this callback. The caller will do so.\n  */\n  int (*xCreate)(\n    int argc,                           /* Size of argv array */\n    const char *const*argv,             /* Tokenizer argument strings */\n    sqlite3_tokenizer **ppTokenizer     /* OUT: Created tokenizer */\n  );\n\n  /*\n  ** Destroy an existing tokenizer. The fts3 module calls this method\n  ** exactly once for each successful call to xCreate().\n  */\n  int (*xDestroy)(sqlite3_tokenizer *pTokenizer);\n\n  /*\n  ** Create a tokenizer cursor to tokenize an input buffer. The caller\n  ** is responsible for ensuring that the input buffer remains valid\n  ** until the cursor is closed (using the xClose() method). \n  */\n  int (*xOpen)(\n    sqlite3_tokenizer *pTokenizer,       /* Tokenizer object */\n    const char *pInput, int nBytes,      /* Input buffer */\n    sqlite3_tokenizer_cursor **ppCursor  /* OUT: Created tokenizer cursor */\n  );\n\n  /*\n  ** Destroy an existing tokenizer cursor. The fts3 module calls this \n  ** method exactly once for each successful call to xOpen().\n  */\n  int (*xClose)(sqlite3_tokenizer_cursor *pCursor);\n\n  /*\n  ** Retrieve the next token from the tokenizer cursor pCursor. This\n  ** method should either return SQLITE_OK and set the values of the\n  ** \"OUT\" variables identified below, or SQLITE_DONE to indicate that\n  ** the end of the buffer has been reached, or an SQLite error code.\n  **\n  ** *ppToken should be set to point at a buffer containing the \n  ** normalized version of the token (i.e. after any case-folding and/or\n  ** stemming has been performed). *pnBytes should be set to the length\n  ** of this buffer in bytes. The input text that generated the token is\n  ** identified by the byte offsets returned in *piStartOffset and\n  ** *piEndOffset. *piStartOffset should be set to the index of the first\n  ** byte of the token in the input buffer. *piEndOffset should be set\n  ** to the index of the first byte just past the end of the token in\n  ** the input buffer.\n  **\n  ** The buffer *ppToken is set to point at is managed by the tokenizer\n  ** implementation. It is only required to be valid until the next call\n  ** to xNext() or xClose(). \n  */\n  /* TODO(shess) current implementation requires pInput to be\n  ** nul-terminated.  This should either be fixed, or pInput/nBytes\n  ** should be converted to zInput.\n  */\n  int (*xNext)(\n    sqlite3_tokenizer_cursor *pCursor,   /* Tokenizer cursor */\n    const char **ppToken, int *pnBytes,  /* OUT: Normalized text for token */\n    int *piStartOffset,  /* OUT: Byte offset of token in input buffer */\n    int *piEndOffset,    /* OUT: Byte offset of end of token in input buffer */\n    int *piPosition      /* OUT: Number of tokens returned before this one */\n  );\n\n  /***********************************************************************\n  ** Methods below this point are only available if iVersion>=1.\n  */\n\n  /* \n  ** Configure the language id of a tokenizer cursor.\n  */\n  int (*xLanguageid)(sqlite3_tokenizer_cursor *pCsr, int iLangid);\n};\n\nstruct sqlite3_tokenizer {\n  const sqlite3_tokenizer_module *pModule;  /* The module for this tokenizer */\n  /* Tokenizer implementations will typically add additional fields */\n};\n\nstruct sqlite3_tokenizer_cursor {\n  sqlite3_tokenizer *pTokenizer;       /* Tokenizer for this cursor. */\n  /* Tokenizer implementations will typically add additional fields */\n};\n\nint fts3_global_term_cnt(int iTerm, int iCol);\nint fts3_term_cnt(int iTerm, int iCol);\n\n\n#endif /* _FTS3_TOKENIZER_H_ */\n\n/************** End of fts3_tokenizer.h **************************************/\n/************** Continuing where we left off in fts3Int.h ********************/\n/************** Include fts3_hash.h in the middle of fts3Int.h ***************/\n/************** Begin file fts3_hash.h ***************************************/\n/*\n** 2001 September 22\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This is the header file for the generic hash-table implementation\n** used in SQLite.  We've modified it slightly to serve as a standalone\n** hash table implementation for the full-text indexing module.\n**\n*/\n#ifndef _FTS3_HASH_H_\n#define _FTS3_HASH_H_\n\n/* Forward declarations of structures. */\ntypedef struct Fts3Hash Fts3Hash;\ntypedef struct Fts3HashElem Fts3HashElem;\n\n/* A complete hash table is an instance of the following structure.\n** The internals of this structure are intended to be opaque -- client\n** code should not attempt to access or modify the fields of this structure\n** directly.  Change this structure only by using the routines below.\n** However, many of the \"procedures\" and \"functions\" for modifying and\n** accessing this structure are really macros, so we can't really make\n** this structure opaque.\n*/\nstruct Fts3Hash {\n  char keyClass;          /* HASH_INT, _POINTER, _STRING, _BINARY */\n  char copyKey;           /* True if copy of key made on insert */\n  int count;              /* Number of entries in this table */\n  Fts3HashElem *first;    /* The first element of the array */\n  int htsize;             /* Number of buckets in the hash table */\n  struct _fts3ht {        /* the hash table */\n    int count;               /* Number of entries with this hash */\n    Fts3HashElem *chain;     /* Pointer to first entry with this hash */\n  } *ht;\n};\n\n/* Each element in the hash table is an instance of the following \n** structure.  All elements are stored on a single doubly-linked list.\n**\n** Again, this structure is intended to be opaque, but it can't really\n** be opaque because it is used by macros.\n*/\nstruct Fts3HashElem {\n  Fts3HashElem *next, *prev; /* Next and previous elements in the table */\n  void *data;                /* Data associated with this element */\n  void *pKey; int nKey;      /* Key associated with this element */\n};\n\n/*\n** There are 2 different modes of operation for a hash table:\n**\n**   FTS3_HASH_STRING        pKey points to a string that is nKey bytes long\n**                           (including the null-terminator, if any).  Case\n**                           is respected in comparisons.\n**\n**   FTS3_HASH_BINARY        pKey points to binary data nKey bytes long. \n**                           memcmp() is used to compare keys.\n**\n** A copy of the key is made if the copyKey parameter to fts3HashInit is 1.  \n*/\n#define FTS3_HASH_STRING    1\n#define FTS3_HASH_BINARY    2\n\n/*\n** Access routines.  To delete, insert a NULL pointer.\n*/\nSQLITE_PRIVATE void sqlite3Fts3HashInit(Fts3Hash *pNew, char keyClass, char copyKey);\nSQLITE_PRIVATE void *sqlite3Fts3HashInsert(Fts3Hash*, const void *pKey, int nKey, void *pData);\nSQLITE_PRIVATE void *sqlite3Fts3HashFind(const Fts3Hash*, const void *pKey, int nKey);\nSQLITE_PRIVATE void sqlite3Fts3HashClear(Fts3Hash*);\nSQLITE_PRIVATE Fts3HashElem *sqlite3Fts3HashFindElem(const Fts3Hash *, const void *, int);\n\n/*\n** Shorthand for the functions above\n*/\n#define fts3HashInit     sqlite3Fts3HashInit\n#define fts3HashInsert   sqlite3Fts3HashInsert\n#define fts3HashFind     sqlite3Fts3HashFind\n#define fts3HashClear    sqlite3Fts3HashClear\n#define fts3HashFindElem sqlite3Fts3HashFindElem\n\n/*\n** Macros for looping over all elements of a hash table.  The idiom is\n** like this:\n**\n**   Fts3Hash h;\n**   Fts3HashElem *p;\n**   ...\n**   for(p=fts3HashFirst(&h); p; p=fts3HashNext(p)){\n**     SomeStructure *pData = fts3HashData(p);\n**     // do something with pData\n**   }\n*/\n#define fts3HashFirst(H)  ((H)->first)\n#define fts3HashNext(E)   ((E)->next)\n#define fts3HashData(E)   ((E)->data)\n#define fts3HashKey(E)    ((E)->pKey)\n#define fts3HashKeysize(E) ((E)->nKey)\n\n/*\n** Number of entries in a hash table\n*/\n#define fts3HashCount(H)  ((H)->count)\n\n#endif /* _FTS3_HASH_H_ */\n\n/************** End of fts3_hash.h *******************************************/\n/************** Continuing where we left off in fts3Int.h ********************/\n\n/*\n** This constant determines the maximum depth of an FTS expression tree\n** that the library will create and use. FTS uses recursion to perform \n** various operations on the query tree, so the disadvantage of a large\n** limit is that it may allow very large queries to use large amounts\n** of stack space (perhaps causing a stack overflow).\n*/\n#ifndef SQLITE_FTS3_MAX_EXPR_DEPTH\n# define SQLITE_FTS3_MAX_EXPR_DEPTH 12\n#endif\n\n\n/*\n** This constant controls how often segments are merged. Once there are\n** FTS3_MERGE_COUNT segments of level N, they are merged into a single\n** segment of level N+1.\n*/\n#define FTS3_MERGE_COUNT 16\n\n/*\n** This is the maximum amount of data (in bytes) to store in the \n** Fts3Table.pendingTerms hash table. Normally, the hash table is\n** populated as documents are inserted/updated/deleted in a transaction\n** and used to create a new segment when the transaction is committed.\n** However if this limit is reached midway through a transaction, a new \n** segment is created and the hash table cleared immediately.\n*/\n#define FTS3_MAX_PENDING_DATA (1*1024*1024)\n\n/*\n** Macro to return the number of elements in an array. SQLite has a\n** similar macro called ArraySize(). Use a different name to avoid\n** a collision when building an amalgamation with built-in FTS3.\n*/\n#define SizeofArray(X) ((int)(sizeof(X)/sizeof(X[0])))\n\n\n#ifndef MIN\n# define MIN(x,y) ((x)<(y)?(x):(y))\n#endif\n#ifndef MAX\n# define MAX(x,y) ((x)>(y)?(x):(y))\n#endif\n\n/*\n** Maximum length of a varint encoded integer. The varint format is different\n** from that used by SQLite, so the maximum length is 10, not 9.\n*/\n#define FTS3_VARINT_MAX 10\n\n#define FTS3_BUFFER_PADDING 8\n\n/*\n** FTS4 virtual tables may maintain multiple indexes - one index of all terms\n** in the document set and zero or more prefix indexes. All indexes are stored\n** as one or more b+-trees in the %_segments and %_segdir tables. \n**\n** It is possible to determine which index a b+-tree belongs to based on the\n** value stored in the \"%_segdir.level\" column. Given this value L, the index\n** that the b+-tree belongs to is (L<<10). In other words, all b+-trees with\n** level values between 0 and 1023 (inclusive) belong to index 0, all levels\n** between 1024 and 2047 to index 1, and so on.\n**\n** It is considered impossible for an index to use more than 1024 levels. In \n** theory though this may happen, but only after at least \n** (FTS3_MERGE_COUNT^1024) separate flushes of the pending-terms tables.\n*/\n#define FTS3_SEGDIR_MAXLEVEL      1024\n#define FTS3_SEGDIR_MAXLEVEL_STR \"1024\"\n\n/*\n** The testcase() macro is only used by the amalgamation.  If undefined,\n** make it a no-op.\n*/\n#ifndef testcase\n# define testcase(X)\n#endif\n\n/*\n** Terminator values for position-lists and column-lists.\n*/\n#define POS_COLUMN  (1)     /* Column-list terminator */\n#define POS_END     (0)     /* Position-list terminator */ \n\n/*\n** The assert_fts3_nc() macro is similar to the assert() macro, except that it\n** is used for assert() conditions that are true only if it can be \n** guranteed that the database is not corrupt.\n*/\n#if defined(SQLITE_DEBUG) || defined(SQLITE_TEST)\nSQLITE_API extern int sqlite3_fts3_may_be_corrupt;\n# define assert_fts3_nc(x) assert(sqlite3_fts3_may_be_corrupt || (x))\n#else\n# define assert_fts3_nc(x) assert(x)\n#endif\n\n/*\n** This section provides definitions to allow the\n** FTS3 extension to be compiled outside of the \n** amalgamation.\n*/\n#ifndef SQLITE_AMALGAMATION\n/*\n** Macros indicating that conditional expressions are always true or\n** false.\n*/\n#ifdef SQLITE_COVERAGE_TEST\n# define ALWAYS(x) (1)\n# define NEVER(X)  (0)\n#elif defined(SQLITE_DEBUG)\n# define ALWAYS(x) sqlite3Fts3Always((x)!=0)\n# define NEVER(x) sqlite3Fts3Never((x)!=0)\nSQLITE_PRIVATE int sqlite3Fts3Always(int b);\nSQLITE_PRIVATE int sqlite3Fts3Never(int b);\n#else\n# define ALWAYS(x) (x)\n# define NEVER(x)  (x)\n#endif\n\n/*\n** Internal types used by SQLite.\n*/\ntypedef unsigned char u8;         /* 1-byte (or larger) unsigned integer */\ntypedef short int i16;            /* 2-byte (or larger) signed integer */\ntypedef unsigned int u32;         /* 4-byte unsigned integer */\ntypedef sqlite3_uint64 u64;       /* 8-byte unsigned integer */\ntypedef sqlite3_int64 i64;        /* 8-byte signed integer */\n\n/*\n** Macro used to suppress compiler warnings for unused parameters.\n*/\n#define UNUSED_PARAMETER(x) (void)(x)\n\n/*\n** Activate assert() only if SQLITE_TEST is enabled.\n*/\n#if !defined(NDEBUG) && !defined(SQLITE_DEBUG) \n# define NDEBUG 1\n#endif\n\n/*\n** The TESTONLY macro is used to enclose variable declarations or\n** other bits of code that are needed to support the arguments\n** within testcase() and assert() macros.\n*/\n#if defined(SQLITE_DEBUG) || defined(SQLITE_COVERAGE_TEST)\n# define TESTONLY(X)  X\n#else\n# define TESTONLY(X)\n#endif\n\n#endif /* SQLITE_AMALGAMATION */\n\n#ifdef SQLITE_DEBUG\nSQLITE_PRIVATE int sqlite3Fts3Corrupt(void);\n# define FTS_CORRUPT_VTAB sqlite3Fts3Corrupt()\n#else\n# define FTS_CORRUPT_VTAB SQLITE_CORRUPT_VTAB\n#endif\n\ntypedef struct Fts3Table Fts3Table;\ntypedef struct Fts3Cursor Fts3Cursor;\ntypedef struct Fts3Expr Fts3Expr;\ntypedef struct Fts3Phrase Fts3Phrase;\ntypedef struct Fts3PhraseToken Fts3PhraseToken;\n\ntypedef struct Fts3Doclist Fts3Doclist;\ntypedef struct Fts3SegFilter Fts3SegFilter;\ntypedef struct Fts3DeferredToken Fts3DeferredToken;\ntypedef struct Fts3SegReader Fts3SegReader;\ntypedef struct Fts3MultiSegReader Fts3MultiSegReader;\n\ntypedef struct MatchinfoBuffer MatchinfoBuffer;\n\n/*\n** A connection to a fulltext index is an instance of the following\n** structure. The xCreate and xConnect methods create an instance\n** of this structure and xDestroy and xDisconnect free that instance.\n** All other methods receive a pointer to the structure as one of their\n** arguments.\n*/\nstruct Fts3Table {\n  sqlite3_vtab base;              /* Base class used by SQLite core */\n  sqlite3 *db;                    /* The database connection */\n  const char *zDb;                /* logical database name */\n  const char *zName;              /* virtual table name */\n  int nColumn;                    /* number of named columns in virtual table */\n  char **azColumn;                /* column names.  malloced */\n  u8 *abNotindexed;               /* True for 'notindexed' columns */\n  sqlite3_tokenizer *pTokenizer;  /* tokenizer for inserts and queries */\n  char *zContentTbl;              /* content=xxx option, or NULL */\n  char *zLanguageid;              /* languageid=xxx option, or NULL */\n  int nAutoincrmerge;             /* Value configured by 'automerge' */\n  u32 nLeafAdd;                   /* Number of leaf blocks added this trans */\n\n  /* Precompiled statements used by the implementation. Each of these \n  ** statements is run and reset within a single virtual table API call. \n  */\n  sqlite3_stmt *aStmt[40];\n  sqlite3_stmt *pSeekStmt;        /* Cache for fts3CursorSeekStmt() */\n\n  char *zReadExprlist;\n  char *zWriteExprlist;\n\n  int nNodeSize;                  /* Soft limit for node size */\n  u8 bFts4;                       /* True for FTS4, false for FTS3 */\n  u8 bHasStat;                    /* True if %_stat table exists (2==unknown) */\n  u8 bHasDocsize;                 /* True if %_docsize table exists */\n  u8 bDescIdx;                    /* True if doclists are in reverse order */\n  u8 bIgnoreSavepoint;            /* True to ignore xSavepoint invocations */\n  int nPgsz;                      /* Page size for host database */\n  char *zSegmentsTbl;             /* Name of %_segments table */\n  sqlite3_blob *pSegments;        /* Blob handle open on %_segments table */\n\n  /* \n  ** The following array of hash tables is used to buffer pending index \n  ** updates during transactions. All pending updates buffered at any one\n  ** time must share a common language-id (see the FTS4 langid= feature).\n  ** The current language id is stored in variable iPrevLangid.\n  **\n  ** A single FTS4 table may have multiple full-text indexes. For each index\n  ** there is an entry in the aIndex[] array. Index 0 is an index of all the\n  ** terms that appear in the document set. Each subsequent index in aIndex[]\n  ** is an index of prefixes of a specific length.\n  **\n  ** Variable nPendingData contains an estimate the memory consumed by the \n  ** pending data structures, including hash table overhead, but not including\n  ** malloc overhead.  When nPendingData exceeds nMaxPendingData, all hash\n  ** tables are flushed to disk. Variable iPrevDocid is the docid of the most \n  ** recently inserted record.\n  */\n  int nIndex;                     /* Size of aIndex[] */\n  struct Fts3Index {\n    int nPrefix;                  /* Prefix length (0 for main terms index) */\n    Fts3Hash hPending;            /* Pending terms table for this index */\n  } *aIndex;\n  int nMaxPendingData;            /* Max pending data before flush to disk */\n  int nPendingData;               /* Current bytes of pending data */\n  sqlite_int64 iPrevDocid;        /* Docid of most recently inserted document */\n  int iPrevLangid;                /* Langid of recently inserted document */\n  int bPrevDelete;                /* True if last operation was a delete */\n\n#if defined(SQLITE_DEBUG) || defined(SQLITE_COVERAGE_TEST)\n  /* State variables used for validating that the transaction control\n  ** methods of the virtual table are called at appropriate times.  These\n  ** values do not contribute to FTS functionality; they are used for\n  ** verifying the operation of the SQLite core.\n  */\n  int inTransaction;     /* True after xBegin but before xCommit/xRollback */\n  int mxSavepoint;       /* Largest valid xSavepoint integer */\n#endif\n\n#ifdef SQLITE_TEST\n  /* True to disable the incremental doclist optimization. This is controled\n  ** by special insert command 'test-no-incr-doclist'.  */\n  int bNoIncrDoclist;\n#endif\n};\n\n/*\n** When the core wants to read from the virtual table, it creates a\n** virtual table cursor (an instance of the following structure) using\n** the xOpen method. Cursors are destroyed using the xClose method.\n*/\nstruct Fts3Cursor {\n  sqlite3_vtab_cursor base;       /* Base class used by SQLite core */\n  i16 eSearch;                    /* Search strategy (see below) */\n  u8 isEof;                       /* True if at End Of Results */\n  u8 isRequireSeek;               /* True if must seek pStmt to %_content row */\n  u8 bSeekStmt;                   /* True if pStmt is a seek */\n  sqlite3_stmt *pStmt;            /* Prepared statement in use by the cursor */\n  Fts3Expr *pExpr;                /* Parsed MATCH query string */\n  int iLangid;                    /* Language being queried for */\n  int nPhrase;                    /* Number of matchable phrases in query */\n  Fts3DeferredToken *pDeferred;   /* Deferred search tokens, if any */\n  sqlite3_int64 iPrevId;          /* Previous id read from aDoclist */\n  char *pNextId;                  /* Pointer into the body of aDoclist */\n  char *aDoclist;                 /* List of docids for full-text queries */\n  int nDoclist;                   /* Size of buffer at aDoclist */\n  u8 bDesc;                       /* True to sort in descending order */\n  int eEvalmode;                  /* An FTS3_EVAL_XX constant */\n  int nRowAvg;                    /* Average size of database rows, in pages */\n  sqlite3_int64 nDoc;             /* Documents in table */\n  i64 iMinDocid;                  /* Minimum docid to return */\n  i64 iMaxDocid;                  /* Maximum docid to return */\n  int isMatchinfoNeeded;          /* True when aMatchinfo[] needs filling in */\n  MatchinfoBuffer *pMIBuffer;     /* Buffer for matchinfo data */\n};\n\n#define FTS3_EVAL_FILTER    0\n#define FTS3_EVAL_NEXT      1\n#define FTS3_EVAL_MATCHINFO 2\n\n/*\n** The Fts3Cursor.eSearch member is always set to one of the following.\n** Actualy, Fts3Cursor.eSearch can be greater than or equal to\n** FTS3_FULLTEXT_SEARCH.  If so, then Fts3Cursor.eSearch - 2 is the index\n** of the column to be searched.  For example, in\n**\n**     CREATE VIRTUAL TABLE ex1 USING fts3(a,b,c,d);\n**     SELECT docid FROM ex1 WHERE b MATCH 'one two three';\n** \n** Because the LHS of the MATCH operator is 2nd column \"b\",\n** Fts3Cursor.eSearch will be set to FTS3_FULLTEXT_SEARCH+1.  (+0 for a,\n** +1 for b, +2 for c, +3 for d.)  If the LHS of MATCH were \"ex1\" \n** indicating that all columns should be searched,\n** then eSearch would be set to FTS3_FULLTEXT_SEARCH+4.\n*/\n#define FTS3_FULLSCAN_SEARCH 0    /* Linear scan of %_content table */\n#define FTS3_DOCID_SEARCH    1    /* Lookup by rowid on %_content table */\n#define FTS3_FULLTEXT_SEARCH 2    /* Full-text index search */\n\n/*\n** The lower 16-bits of the sqlite3_index_info.idxNum value set by\n** the xBestIndex() method contains the Fts3Cursor.eSearch value described\n** above. The upper 16-bits contain a combination of the following\n** bits, used to describe extra constraints on full-text searches.\n*/\n#define FTS3_HAVE_LANGID    0x00010000      /* languageid=? */\n#define FTS3_HAVE_DOCID_GE  0x00020000      /* docid>=? */\n#define FTS3_HAVE_DOCID_LE  0x00040000      /* docid<=? */\n\nstruct Fts3Doclist {\n  char *aAll;                    /* Array containing doclist (or NULL) */\n  int nAll;                      /* Size of a[] in bytes */\n  char *pNextDocid;              /* Pointer to next docid */\n\n  sqlite3_int64 iDocid;          /* Current docid (if pList!=0) */\n  int bFreeList;                 /* True if pList should be sqlite3_free()d */\n  char *pList;                   /* Pointer to position list following iDocid */\n  int nList;                     /* Length of position list */\n};\n\n/*\n** A \"phrase\" is a sequence of one or more tokens that must match in\n** sequence.  A single token is the base case and the most common case.\n** For a sequence of tokens contained in double-quotes (i.e. \"one two three\")\n** nToken will be the number of tokens in the string.\n*/\nstruct Fts3PhraseToken {\n  char *z;                        /* Text of the token */\n  int n;                          /* Number of bytes in buffer z */\n  int isPrefix;                   /* True if token ends with a \"*\" character */\n  int bFirst;                     /* True if token must appear at position 0 */\n\n  /* Variables above this point are populated when the expression is\n  ** parsed (by code in fts3_expr.c). Below this point the variables are\n  ** used when evaluating the expression. */\n  Fts3DeferredToken *pDeferred;   /* Deferred token object for this token */\n  Fts3MultiSegReader *pSegcsr;    /* Segment-reader for this token */\n};\n\nstruct Fts3Phrase {\n  /* Cache of doclist for this phrase. */\n  Fts3Doclist doclist;\n  int bIncr;                 /* True if doclist is loaded incrementally */\n  int iDoclistToken;\n\n  /* Used by sqlite3Fts3EvalPhrasePoslist() if this is a descendent of an\n  ** OR condition.  */\n  char *pOrPoslist;\n  i64 iOrDocid;\n\n  /* Variables below this point are populated by fts3_expr.c when parsing \n  ** a MATCH expression. Everything above is part of the evaluation phase. \n  */\n  int nToken;                /* Number of tokens in the phrase */\n  int iColumn;               /* Index of column this phrase must match */\n  Fts3PhraseToken aToken[1]; /* One entry for each token in the phrase */\n};\n\n/*\n** A tree of these objects forms the RHS of a MATCH operator.\n**\n** If Fts3Expr.eType is FTSQUERY_PHRASE and isLoaded is true, then aDoclist \n** points to a malloced buffer, size nDoclist bytes, containing the results \n** of this phrase query in FTS3 doclist format. As usual, the initial \n** \"Length\" field found in doclists stored on disk is omitted from this \n** buffer.\n**\n** Variable aMI is used only for FTSQUERY_NEAR nodes to store the global\n** matchinfo data. If it is not NULL, it points to an array of size nCol*3,\n** where nCol is the number of columns in the queried FTS table. The array\n** is populated as follows:\n**\n**   aMI[iCol*3 + 0] = Undefined\n**   aMI[iCol*3 + 1] = Number of occurrences\n**   aMI[iCol*3 + 2] = Number of rows containing at least one instance\n**\n** The aMI array is allocated using sqlite3_malloc(). It should be freed \n** when the expression node is.\n*/\nstruct Fts3Expr {\n  int eType;                 /* One of the FTSQUERY_XXX values defined below */\n  int nNear;                 /* Valid if eType==FTSQUERY_NEAR */\n  Fts3Expr *pParent;         /* pParent->pLeft==this or pParent->pRight==this */\n  Fts3Expr *pLeft;           /* Left operand */\n  Fts3Expr *pRight;          /* Right operand */\n  Fts3Phrase *pPhrase;       /* Valid if eType==FTSQUERY_PHRASE */\n\n  /* The following are used by the fts3_eval.c module. */\n  sqlite3_int64 iDocid;      /* Current docid */\n  u8 bEof;                   /* True this expression is at EOF already */\n  u8 bStart;                 /* True if iDocid is valid */\n  u8 bDeferred;              /* True if this expression is entirely deferred */\n\n  /* The following are used by the fts3_snippet.c module. */\n  int iPhrase;               /* Index of this phrase in matchinfo() results */\n  u32 *aMI;                  /* See above */\n};\n\n/*\n** Candidate values for Fts3Query.eType. Note that the order of the first\n** four values is in order of precedence when parsing expressions. For \n** example, the following:\n**\n**   \"a OR b AND c NOT d NEAR e\"\n**\n** is equivalent to:\n**\n**   \"a OR (b AND (c NOT (d NEAR e)))\"\n*/\n#define FTSQUERY_NEAR   1\n#define FTSQUERY_NOT    2\n#define FTSQUERY_AND    3\n#define FTSQUERY_OR     4\n#define FTSQUERY_PHRASE 5\n\n\n/* fts3_write.c */\nSQLITE_PRIVATE int sqlite3Fts3UpdateMethod(sqlite3_vtab*,int,sqlite3_value**,sqlite3_int64*);\nSQLITE_PRIVATE int sqlite3Fts3PendingTermsFlush(Fts3Table *);\nSQLITE_PRIVATE void sqlite3Fts3PendingTermsClear(Fts3Table *);\nSQLITE_PRIVATE int sqlite3Fts3Optimize(Fts3Table *);\nSQLITE_PRIVATE int sqlite3Fts3SegReaderNew(int, int, sqlite3_int64,\n  sqlite3_int64, sqlite3_int64, const char *, int, Fts3SegReader**);\nSQLITE_PRIVATE int sqlite3Fts3SegReaderPending(\n  Fts3Table*,int,const char*,int,int,Fts3SegReader**);\nSQLITE_PRIVATE void sqlite3Fts3SegReaderFree(Fts3SegReader *);\nSQLITE_PRIVATE int sqlite3Fts3AllSegdirs(Fts3Table*, int, int, int, sqlite3_stmt **);\nSQLITE_PRIVATE int sqlite3Fts3ReadBlock(Fts3Table*, sqlite3_int64, char **, int*, int*);\n\nSQLITE_PRIVATE int sqlite3Fts3SelectDoctotal(Fts3Table *, sqlite3_stmt **);\nSQLITE_PRIVATE int sqlite3Fts3SelectDocsize(Fts3Table *, sqlite3_int64, sqlite3_stmt **);\n\n#ifndef SQLITE_DISABLE_FTS4_DEFERRED\nSQLITE_PRIVATE void sqlite3Fts3FreeDeferredTokens(Fts3Cursor *);\nSQLITE_PRIVATE int sqlite3Fts3DeferToken(Fts3Cursor *, Fts3PhraseToken *, int);\nSQLITE_PRIVATE int sqlite3Fts3CacheDeferredDoclists(Fts3Cursor *);\nSQLITE_PRIVATE void sqlite3Fts3FreeDeferredDoclists(Fts3Cursor *);\nSQLITE_PRIVATE int sqlite3Fts3DeferredTokenList(Fts3DeferredToken *, char **, int *);\n#else\n# define sqlite3Fts3FreeDeferredTokens(x)\n# define sqlite3Fts3DeferToken(x,y,z) SQLITE_OK\n# define sqlite3Fts3CacheDeferredDoclists(x) SQLITE_OK\n# define sqlite3Fts3FreeDeferredDoclists(x)\n# define sqlite3Fts3DeferredTokenList(x,y,z) SQLITE_OK\n#endif\n\nSQLITE_PRIVATE void sqlite3Fts3SegmentsClose(Fts3Table *);\nSQLITE_PRIVATE int sqlite3Fts3MaxLevel(Fts3Table *, int *);\n\n/* Special values interpreted by sqlite3SegReaderCursor() */\n#define FTS3_SEGCURSOR_PENDING        -1\n#define FTS3_SEGCURSOR_ALL            -2\n\nSQLITE_PRIVATE int sqlite3Fts3SegReaderStart(Fts3Table*, Fts3MultiSegReader*, Fts3SegFilter*);\nSQLITE_PRIVATE int sqlite3Fts3SegReaderStep(Fts3Table *, Fts3MultiSegReader *);\nSQLITE_PRIVATE void sqlite3Fts3SegReaderFinish(Fts3MultiSegReader *);\n\nSQLITE_PRIVATE int sqlite3Fts3SegReaderCursor(Fts3Table *, \n    int, int, int, const char *, int, int, int, Fts3MultiSegReader *);\n\n/* Flags allowed as part of the 4th argument to SegmentReaderIterate() */\n#define FTS3_SEGMENT_REQUIRE_POS   0x00000001\n#define FTS3_SEGMENT_IGNORE_EMPTY  0x00000002\n#define FTS3_SEGMENT_COLUMN_FILTER 0x00000004\n#define FTS3_SEGMENT_PREFIX        0x00000008\n#define FTS3_SEGMENT_SCAN          0x00000010\n#define FTS3_SEGMENT_FIRST         0x00000020\n\n/* Type passed as 4th argument to SegmentReaderIterate() */\nstruct Fts3SegFilter {\n  const char *zTerm;\n  int nTerm;\n  int iCol;\n  int flags;\n};\n\nstruct Fts3MultiSegReader {\n  /* Used internally by sqlite3Fts3SegReaderXXX() calls */\n  Fts3SegReader **apSegment;      /* Array of Fts3SegReader objects */\n  int nSegment;                   /* Size of apSegment array */\n  int nAdvance;                   /* How many seg-readers to advance */\n  Fts3SegFilter *pFilter;         /* Pointer to filter object */\n  char *aBuffer;                  /* Buffer to merge doclists in */\n  int nBuffer;                    /* Allocated size of aBuffer[] in bytes */\n\n  int iColFilter;                 /* If >=0, filter for this column */\n  int bRestart;\n\n  /* Used by fts3.c only. */\n  int nCost;                      /* Cost of running iterator */\n  int bLookup;                    /* True if a lookup of a single entry. */\n\n  /* Output values. Valid only after Fts3SegReaderStep() returns SQLITE_ROW. */\n  char *zTerm;                    /* Pointer to term buffer */\n  int nTerm;                      /* Size of zTerm in bytes */\n  char *aDoclist;                 /* Pointer to doclist buffer */\n  int nDoclist;                   /* Size of aDoclist[] in bytes */\n};\n\nSQLITE_PRIVATE int sqlite3Fts3Incrmerge(Fts3Table*,int,int);\n\n#define fts3GetVarint32(p, piVal) (                                           \\\n  (*(u8*)(p)&0x80) ? sqlite3Fts3GetVarint32(p, piVal) : (*piVal=*(u8*)(p), 1) \\\n)\n\n/* fts3.c */\nSQLITE_PRIVATE void sqlite3Fts3ErrMsg(char**,const char*,...);\nSQLITE_PRIVATE int sqlite3Fts3PutVarint(char *, sqlite3_int64);\nSQLITE_PRIVATE int sqlite3Fts3GetVarint(const char *, sqlite_int64 *);\nSQLITE_PRIVATE int sqlite3Fts3GetVarint32(const char *, int *);\nSQLITE_PRIVATE int sqlite3Fts3VarintLen(sqlite3_uint64);\nSQLITE_PRIVATE void sqlite3Fts3Dequote(char *);\nSQLITE_PRIVATE void sqlite3Fts3DoclistPrev(int,char*,int,char**,sqlite3_int64*,int*,u8*);\nSQLITE_PRIVATE int sqlite3Fts3EvalPhraseStats(Fts3Cursor *, Fts3Expr *, u32 *);\nSQLITE_PRIVATE int sqlite3Fts3FirstFilter(sqlite3_int64, char *, int, char *);\nSQLITE_PRIVATE void sqlite3Fts3CreateStatTable(int*, Fts3Table*);\nSQLITE_PRIVATE int sqlite3Fts3EvalTestDeferred(Fts3Cursor *pCsr, int *pRc);\n\n/* fts3_tokenizer.c */\nSQLITE_PRIVATE const char *sqlite3Fts3NextToken(const char *, int *);\nSQLITE_PRIVATE int sqlite3Fts3InitHashTable(sqlite3 *, Fts3Hash *, const char *);\nSQLITE_PRIVATE int sqlite3Fts3InitTokenizer(Fts3Hash *pHash, const char *, \n    sqlite3_tokenizer **, char **\n);\nSQLITE_PRIVATE int sqlite3Fts3IsIdChar(char);\n\n/* fts3_snippet.c */\nSQLITE_PRIVATE void sqlite3Fts3Offsets(sqlite3_context*, Fts3Cursor*);\nSQLITE_PRIVATE void sqlite3Fts3Snippet(sqlite3_context *, Fts3Cursor *, const char *,\n  const char *, const char *, int, int\n);\nSQLITE_PRIVATE void sqlite3Fts3Matchinfo(sqlite3_context *, Fts3Cursor *, const char *);\nSQLITE_PRIVATE void sqlite3Fts3MIBufferFree(MatchinfoBuffer *p);\n\n/* fts3_expr.c */\nSQLITE_PRIVATE int sqlite3Fts3ExprParse(sqlite3_tokenizer *, int,\n  char **, int, int, int, const char *, int, Fts3Expr **, char **\n);\nSQLITE_PRIVATE void sqlite3Fts3ExprFree(Fts3Expr *);\n#ifdef SQLITE_TEST\nSQLITE_PRIVATE int sqlite3Fts3ExprInitTestInterface(sqlite3 *db, Fts3Hash*);\nSQLITE_PRIVATE int sqlite3Fts3InitTerm(sqlite3 *db);\n#endif\n\nSQLITE_PRIVATE int sqlite3Fts3OpenTokenizer(sqlite3_tokenizer *, int, const char *, int,\n  sqlite3_tokenizer_cursor **\n);\n\n/* fts3_aux.c */\nSQLITE_PRIVATE int sqlite3Fts3InitAux(sqlite3 *db);\n\nSQLITE_PRIVATE void sqlite3Fts3EvalPhraseCleanup(Fts3Phrase *);\n\nSQLITE_PRIVATE int sqlite3Fts3MsrIncrStart(\n    Fts3Table*, Fts3MultiSegReader*, int, const char*, int);\nSQLITE_PRIVATE int sqlite3Fts3MsrIncrNext(\n    Fts3Table *, Fts3MultiSegReader *, sqlite3_int64 *, char **, int *);\nSQLITE_PRIVATE int sqlite3Fts3EvalPhrasePoslist(Fts3Cursor *, Fts3Expr *, int iCol, char **); \nSQLITE_PRIVATE int sqlite3Fts3MsrOvfl(Fts3Cursor *, Fts3MultiSegReader *, int *);\nSQLITE_PRIVATE int sqlite3Fts3MsrIncrRestart(Fts3MultiSegReader *pCsr);\n\n/* fts3_tokenize_vtab.c */\nSQLITE_PRIVATE int sqlite3Fts3InitTok(sqlite3*, Fts3Hash *);\n\n/* fts3_unicode2.c (functions generated by parsing unicode text files) */\n#ifndef SQLITE_DISABLE_FTS3_UNICODE\nSQLITE_PRIVATE int sqlite3FtsUnicodeFold(int, int);\nSQLITE_PRIVATE int sqlite3FtsUnicodeIsalnum(int);\nSQLITE_PRIVATE int sqlite3FtsUnicodeIsdiacritic(int);\n#endif\n\n#endif /* !SQLITE_CORE || SQLITE_ENABLE_FTS3 */\n#endif /* _FTSINT_H */\n\n/************** End of fts3Int.h *********************************************/\n/************** Continuing where we left off in fts3.c ***********************/\n#if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3)\n\n#if defined(SQLITE_ENABLE_FTS3) && !defined(SQLITE_CORE)\n# define SQLITE_CORE 1\n#endif\n\n/* #include <assert.h> */\n/* #include <stdlib.h> */\n/* #include <stddef.h> */\n/* #include <stdio.h> */\n/* #include <string.h> */\n/* #include <stdarg.h> */\n\n/* #include \"fts3.h\" */\n#ifndef SQLITE_CORE \n/* # include \"sqlite3ext.h\" */\n  SQLITE_EXTENSION_INIT1\n#endif\n\nstatic int fts3EvalNext(Fts3Cursor *pCsr);\nstatic int fts3EvalStart(Fts3Cursor *pCsr);\nstatic int fts3TermSegReaderCursor(\n    Fts3Cursor *, const char *, int, int, Fts3MultiSegReader **);\n\n#ifndef SQLITE_AMALGAMATION\n# if defined(SQLITE_DEBUG)\nSQLITE_PRIVATE int sqlite3Fts3Always(int b) { assert( b ); return b; }\nSQLITE_PRIVATE int sqlite3Fts3Never(int b)  { assert( !b ); return b; }\n# endif\n#endif\n\n/*\n** This variable is set to false when running tests for which the on disk\n** structures should not be corrupt. Otherwise, true. If it is false, extra\n** assert() conditions in the fts3 code are activated - conditions that are\n** only true if it is guaranteed that the fts3 database is not corrupt.\n*/\nSQLITE_API int sqlite3_fts3_may_be_corrupt = 1;\n\n/* \n** Write a 64-bit variable-length integer to memory starting at p[0].\n** The length of data written will be between 1 and FTS3_VARINT_MAX bytes.\n** The number of bytes written is returned.\n*/\nSQLITE_PRIVATE int sqlite3Fts3PutVarint(char *p, sqlite_int64 v){\n  unsigned char *q = (unsigned char *) p;\n  sqlite_uint64 vu = v;\n  do{\n    *q++ = (unsigned char) ((vu & 0x7f) | 0x80);\n    vu >>= 7;\n  }while( vu!=0 );\n  q[-1] &= 0x7f;  /* turn off high bit in final byte */\n  assert( q - (unsigned char *)p <= FTS3_VARINT_MAX );\n  return (int) (q - (unsigned char *)p);\n}\n\n#define GETVARINT_STEP(v, ptr, shift, mask1, mask2, var, ret) \\\n  v = (v & mask1) | ( (*(const unsigned char*)(ptr++)) << shift );  \\\n  if( (v & mask2)==0 ){ var = v; return ret; }\n#define GETVARINT_INIT(v, ptr, shift, mask1, mask2, var, ret) \\\n  v = (*ptr++);                                               \\\n  if( (v & mask2)==0 ){ var = v; return ret; }\n\n/* \n** Read a 64-bit variable-length integer from memory starting at p[0].\n** Return the number of bytes read, or 0 on error.\n** The value is stored in *v.\n*/\nSQLITE_PRIVATE int sqlite3Fts3GetVarint(const char *pBuf, sqlite_int64 *v){\n  const unsigned char *p = (const unsigned char*)pBuf;\n  const unsigned char *pStart = p;\n  u32 a;\n  u64 b;\n  int shift;\n\n  GETVARINT_INIT(a, p, 0,  0x00,     0x80, *v, 1);\n  GETVARINT_STEP(a, p, 7,  0x7F,     0x4000, *v, 2);\n  GETVARINT_STEP(a, p, 14, 0x3FFF,   0x200000, *v, 3);\n  GETVARINT_STEP(a, p, 21, 0x1FFFFF, 0x10000000, *v, 4);\n  b = (a & 0x0FFFFFFF );\n\n  for(shift=28; shift<=63; shift+=7){\n    u64 c = *p++;\n    b += (c&0x7F) << shift;\n    if( (c & 0x80)==0 ) break;\n  }\n  *v = b;\n  return (int)(p - pStart);\n}\n\n/*\n** Similar to sqlite3Fts3GetVarint(), except that the output is truncated to \n** a non-negative 32-bit integer before it is returned.\n*/\nSQLITE_PRIVATE int sqlite3Fts3GetVarint32(const char *p, int *pi){\n  const unsigned char *ptr = (const unsigned char*)p;\n  u32 a;\n\n#ifndef fts3GetVarint32\n  GETVARINT_INIT(a, ptr, 0,  0x00,     0x80, *pi, 1);\n#else\n  a = (*ptr++);\n  assert( a & 0x80 );\n#endif\n\n  GETVARINT_STEP(a, ptr, 7,  0x7F,     0x4000, *pi, 2);\n  GETVARINT_STEP(a, ptr, 14, 0x3FFF,   0x200000, *pi, 3);\n  GETVARINT_STEP(a, ptr, 21, 0x1FFFFF, 0x10000000, *pi, 4);\n  a = (a & 0x0FFFFFFF );\n  *pi = (int)(a | ((u32)(*ptr & 0x07) << 28));\n  assert( 0==(a & 0x80000000) );\n  assert( *pi>=0 );\n  return 5;\n}\n\n/*\n** Return the number of bytes required to encode v as a varint\n*/\nSQLITE_PRIVATE int sqlite3Fts3VarintLen(sqlite3_uint64 v){\n  int i = 0;\n  do{\n    i++;\n    v >>= 7;\n  }while( v!=0 );\n  return i;\n}\n\n/*\n** Convert an SQL-style quoted string into a normal string by removing\n** the quote characters.  The conversion is done in-place.  If the\n** input does not begin with a quote character, then this routine\n** is a no-op.\n**\n** Examples:\n**\n**     \"abc\"   becomes   abc\n**     'xyz'   becomes   xyz\n**     [pqr]   becomes   pqr\n**     `mno`   becomes   mno\n**\n*/\nSQLITE_PRIVATE void sqlite3Fts3Dequote(char *z){\n  char quote;                     /* Quote character (if any ) */\n\n  quote = z[0];\n  if( quote=='[' || quote=='\\'' || quote=='\"' || quote=='`' ){\n    int iIn = 1;                  /* Index of next byte to read from input */\n    int iOut = 0;                 /* Index of next byte to write to output */\n\n    /* If the first byte was a '[', then the close-quote character is a ']' */\n    if( quote=='[' ) quote = ']';  \n\n    while( z[iIn] ){\n      if( z[iIn]==quote ){\n        if( z[iIn+1]!=quote ) break;\n        z[iOut++] = quote;\n        iIn += 2;\n      }else{\n        z[iOut++] = z[iIn++];\n      }\n    }\n    z[iOut] = '\\0';\n  }\n}\n\n/*\n** Read a single varint from the doclist at *pp and advance *pp to point\n** to the first byte past the end of the varint.  Add the value of the varint\n** to *pVal.\n*/\nstatic void fts3GetDeltaVarint(char **pp, sqlite3_int64 *pVal){\n  sqlite3_int64 iVal;\n  *pp += sqlite3Fts3GetVarint(*pp, &iVal);\n  *pVal += iVal;\n}\n\n/*\n** When this function is called, *pp points to the first byte following a\n** varint that is part of a doclist (or position-list, or any other list\n** of varints). This function moves *pp to point to the start of that varint,\n** and sets *pVal by the varint value.\n**\n** Argument pStart points to the first byte of the doclist that the\n** varint is part of.\n*/\nstatic void fts3GetReverseVarint(\n  char **pp, \n  char *pStart, \n  sqlite3_int64 *pVal\n){\n  sqlite3_int64 iVal;\n  char *p;\n\n  /* Pointer p now points at the first byte past the varint we are \n  ** interested in. So, unless the doclist is corrupt, the 0x80 bit is\n  ** clear on character p[-1]. */\n  for(p = (*pp)-2; p>=pStart && *p&0x80; p--);\n  p++;\n  *pp = p;\n\n  sqlite3Fts3GetVarint(p, &iVal);\n  *pVal = iVal;\n}\n\n/*\n** The xDisconnect() virtual table method.\n*/\nstatic int fts3DisconnectMethod(sqlite3_vtab *pVtab){\n  Fts3Table *p = (Fts3Table *)pVtab;\n  int i;\n\n  assert( p->nPendingData==0 );\n  assert( p->pSegments==0 );\n\n  /* Free any prepared statements held */\n  sqlite3_finalize(p->pSeekStmt);\n  for(i=0; i<SizeofArray(p->aStmt); i++){\n    sqlite3_finalize(p->aStmt[i]);\n  }\n  sqlite3_free(p->zSegmentsTbl);\n  sqlite3_free(p->zReadExprlist);\n  sqlite3_free(p->zWriteExprlist);\n  sqlite3_free(p->zContentTbl);\n  sqlite3_free(p->zLanguageid);\n\n  /* Invoke the tokenizer destructor to free the tokenizer. */\n  p->pTokenizer->pModule->xDestroy(p->pTokenizer);\n\n  sqlite3_free(p);\n  return SQLITE_OK;\n}\n\n/*\n** Write an error message into *pzErr\n*/\nSQLITE_PRIVATE void sqlite3Fts3ErrMsg(char **pzErr, const char *zFormat, ...){\n  va_list ap;\n  sqlite3_free(*pzErr);\n  va_start(ap, zFormat);\n  *pzErr = sqlite3_vmprintf(zFormat, ap);\n  va_end(ap);\n}\n\n/*\n** Construct one or more SQL statements from the format string given\n** and then evaluate those statements. The success code is written\n** into *pRc.\n**\n** If *pRc is initially non-zero then this routine is a no-op.\n*/\nstatic void fts3DbExec(\n  int *pRc,              /* Success code */\n  sqlite3 *db,           /* Database in which to run SQL */\n  const char *zFormat,   /* Format string for SQL */\n  ...                    /* Arguments to the format string */\n){\n  va_list ap;\n  char *zSql;\n  if( *pRc ) return;\n  va_start(ap, zFormat);\n  zSql = sqlite3_vmprintf(zFormat, ap);\n  va_end(ap);\n  if( zSql==0 ){\n    *pRc = SQLITE_NOMEM;\n  }else{\n    *pRc = sqlite3_exec(db, zSql, 0, 0, 0);\n    sqlite3_free(zSql);\n  }\n}\n\n/*\n** The xDestroy() virtual table method.\n*/\nstatic int fts3DestroyMethod(sqlite3_vtab *pVtab){\n  Fts3Table *p = (Fts3Table *)pVtab;\n  int rc = SQLITE_OK;              /* Return code */\n  const char *zDb = p->zDb;        /* Name of database (e.g. \"main\", \"temp\") */\n  sqlite3 *db = p->db;             /* Database handle */\n\n  /* Drop the shadow tables */\n  fts3DbExec(&rc, db, \n    \"DROP TABLE IF EXISTS %Q.'%q_segments';\"\n    \"DROP TABLE IF EXISTS %Q.'%q_segdir';\"\n    \"DROP TABLE IF EXISTS %Q.'%q_docsize';\"\n    \"DROP TABLE IF EXISTS %Q.'%q_stat';\"\n    \"%s DROP TABLE IF EXISTS %Q.'%q_content';\",\n    zDb, p->zName,\n    zDb, p->zName,\n    zDb, p->zName,\n    zDb, p->zName,\n    (p->zContentTbl ? \"--\" : \"\"), zDb,p->zName\n  );\n\n  /* If everything has worked, invoke fts3DisconnectMethod() to free the\n  ** memory associated with the Fts3Table structure and return SQLITE_OK.\n  ** Otherwise, return an SQLite error code.\n  */\n  return (rc==SQLITE_OK ? fts3DisconnectMethod(pVtab) : rc);\n}\n\n\n/*\n** Invoke sqlite3_declare_vtab() to declare the schema for the FTS3 table\n** passed as the first argument. This is done as part of the xConnect()\n** and xCreate() methods.\n**\n** If *pRc is non-zero when this function is called, it is a no-op. \n** Otherwise, if an error occurs, an SQLite error code is stored in *pRc\n** before returning.\n*/\nstatic void fts3DeclareVtab(int *pRc, Fts3Table *p){\n  if( *pRc==SQLITE_OK ){\n    int i;                        /* Iterator variable */\n    int rc;                       /* Return code */\n    char *zSql;                   /* SQL statement passed to declare_vtab() */\n    char *zCols;                  /* List of user defined columns */\n    const char *zLanguageid;\n\n    zLanguageid = (p->zLanguageid ? p->zLanguageid : \"__langid\");\n    sqlite3_vtab_config(p->db, SQLITE_VTAB_CONSTRAINT_SUPPORT, 1);\n\n    /* Create a list of user columns for the virtual table */\n    zCols = sqlite3_mprintf(\"%Q, \", p->azColumn[0]);\n    for(i=1; zCols && i<p->nColumn; i++){\n      zCols = sqlite3_mprintf(\"%z%Q, \", zCols, p->azColumn[i]);\n    }\n\n    /* Create the whole \"CREATE TABLE\" statement to pass to SQLite */\n    zSql = sqlite3_mprintf(\n        \"CREATE TABLE x(%s %Q HIDDEN, docid HIDDEN, %Q HIDDEN)\", \n        zCols, p->zName, zLanguageid\n    );\n    if( !zCols || !zSql ){\n      rc = SQLITE_NOMEM;\n    }else{\n      rc = sqlite3_declare_vtab(p->db, zSql);\n    }\n\n    sqlite3_free(zSql);\n    sqlite3_free(zCols);\n    *pRc = rc;\n  }\n}\n\n/*\n** Create the %_stat table if it does not already exist.\n*/\nSQLITE_PRIVATE void sqlite3Fts3CreateStatTable(int *pRc, Fts3Table *p){\n  fts3DbExec(pRc, p->db, \n      \"CREATE TABLE IF NOT EXISTS %Q.'%q_stat'\"\n          \"(id INTEGER PRIMARY KEY, value BLOB);\",\n      p->zDb, p->zName\n  );\n  if( (*pRc)==SQLITE_OK ) p->bHasStat = 1;\n}\n\n/*\n** Create the backing store tables (%_content, %_segments and %_segdir)\n** required by the FTS3 table passed as the only argument. This is done\n** as part of the vtab xCreate() method.\n**\n** If the p->bHasDocsize boolean is true (indicating that this is an\n** FTS4 table, not an FTS3 table) then also create the %_docsize and\n** %_stat tables required by FTS4.\n*/\nstatic int fts3CreateTables(Fts3Table *p){\n  int rc = SQLITE_OK;             /* Return code */\n  int i;                          /* Iterator variable */\n  sqlite3 *db = p->db;            /* The database connection */\n\n  if( p->zContentTbl==0 ){\n    const char *zLanguageid = p->zLanguageid;\n    char *zContentCols;           /* Columns of %_content table */\n\n    /* Create a list of user columns for the content table */\n    zContentCols = sqlite3_mprintf(\"docid INTEGER PRIMARY KEY\");\n    for(i=0; zContentCols && i<p->nColumn; i++){\n      char *z = p->azColumn[i];\n      zContentCols = sqlite3_mprintf(\"%z, 'c%d%q'\", zContentCols, i, z);\n    }\n    if( zLanguageid && zContentCols ){\n      zContentCols = sqlite3_mprintf(\"%z, langid\", zContentCols, zLanguageid);\n    }\n    if( zContentCols==0 ) rc = SQLITE_NOMEM;\n  \n    /* Create the content table */\n    fts3DbExec(&rc, db, \n       \"CREATE TABLE %Q.'%q_content'(%s)\",\n       p->zDb, p->zName, zContentCols\n    );\n    sqlite3_free(zContentCols);\n  }\n\n  /* Create other tables */\n  fts3DbExec(&rc, db, \n      \"CREATE TABLE %Q.'%q_segments'(blockid INTEGER PRIMARY KEY, block BLOB);\",\n      p->zDb, p->zName\n  );\n  fts3DbExec(&rc, db, \n      \"CREATE TABLE %Q.'%q_segdir'(\"\n        \"level INTEGER,\"\n        \"idx INTEGER,\"\n        \"start_block INTEGER,\"\n        \"leaves_end_block INTEGER,\"\n        \"end_block INTEGER,\"\n        \"root BLOB,\"\n        \"PRIMARY KEY(level, idx)\"\n      \");\",\n      p->zDb, p->zName\n  );\n  if( p->bHasDocsize ){\n    fts3DbExec(&rc, db, \n        \"CREATE TABLE %Q.'%q_docsize'(docid INTEGER PRIMARY KEY, size BLOB);\",\n        p->zDb, p->zName\n    );\n  }\n  assert( p->bHasStat==p->bFts4 );\n  if( p->bHasStat ){\n    sqlite3Fts3CreateStatTable(&rc, p);\n  }\n  return rc;\n}\n\n/*\n** Store the current database page-size in bytes in p->nPgsz.\n**\n** If *pRc is non-zero when this function is called, it is a no-op. \n** Otherwise, if an error occurs, an SQLite error code is stored in *pRc\n** before returning.\n*/\nstatic void fts3DatabasePageSize(int *pRc, Fts3Table *p){\n  if( *pRc==SQLITE_OK ){\n    int rc;                       /* Return code */\n    char *zSql;                   /* SQL text \"PRAGMA %Q.page_size\" */\n    sqlite3_stmt *pStmt;          /* Compiled \"PRAGMA %Q.page_size\" statement */\n  \n    zSql = sqlite3_mprintf(\"PRAGMA %Q.page_size\", p->zDb);\n    if( !zSql ){\n      rc = SQLITE_NOMEM;\n    }else{\n      rc = sqlite3_prepare(p->db, zSql, -1, &pStmt, 0);\n      if( rc==SQLITE_OK ){\n        sqlite3_step(pStmt);\n        p->nPgsz = sqlite3_column_int(pStmt, 0);\n        rc = sqlite3_finalize(pStmt);\n      }else if( rc==SQLITE_AUTH ){\n        p->nPgsz = 1024;\n        rc = SQLITE_OK;\n      }\n    }\n    assert( p->nPgsz>0 || rc!=SQLITE_OK );\n    sqlite3_free(zSql);\n    *pRc = rc;\n  }\n}\n\n/*\n** \"Special\" FTS4 arguments are column specifications of the following form:\n**\n**   <key> = <value>\n**\n** There may not be whitespace surrounding the \"=\" character. The <value> \n** term may be quoted, but the <key> may not.\n*/\nstatic int fts3IsSpecialColumn(\n  const char *z, \n  int *pnKey,\n  char **pzValue\n){\n  char *zValue;\n  const char *zCsr = z;\n\n  while( *zCsr!='=' ){\n    if( *zCsr=='\\0' ) return 0;\n    zCsr++;\n  }\n\n  *pnKey = (int)(zCsr-z);\n  zValue = sqlite3_mprintf(\"%s\", &zCsr[1]);\n  if( zValue ){\n    sqlite3Fts3Dequote(zValue);\n  }\n  *pzValue = zValue;\n  return 1;\n}\n\n/*\n** Append the output of a printf() style formatting to an existing string.\n*/\nstatic void fts3Appendf(\n  int *pRc,                       /* IN/OUT: Error code */\n  char **pz,                      /* IN/OUT: Pointer to string buffer */\n  const char *zFormat,            /* Printf format string to append */\n  ...                             /* Arguments for printf format string */\n){\n  if( *pRc==SQLITE_OK ){\n    va_list ap;\n    char *z;\n    va_start(ap, zFormat);\n    z = sqlite3_vmprintf(zFormat, ap);\n    va_end(ap);\n    if( z && *pz ){\n      char *z2 = sqlite3_mprintf(\"%s%s\", *pz, z);\n      sqlite3_free(z);\n      z = z2;\n    }\n    if( z==0 ) *pRc = SQLITE_NOMEM;\n    sqlite3_free(*pz);\n    *pz = z;\n  }\n}\n\n/*\n** Return a copy of input string zInput enclosed in double-quotes (\") and\n** with all double quote characters escaped. For example:\n**\n**     fts3QuoteId(\"un \\\"zip\\\"\")   ->    \"un \\\"\\\"zip\\\"\\\"\"\n**\n** The pointer returned points to memory obtained from sqlite3_malloc(). It\n** is the callers responsibility to call sqlite3_free() to release this\n** memory.\n*/\nstatic char *fts3QuoteId(char const *zInput){\n  sqlite3_int64 nRet;\n  char *zRet;\n  nRet = 2 + (int)strlen(zInput)*2 + 1;\n  zRet = sqlite3_malloc64(nRet);\n  if( zRet ){\n    int i;\n    char *z = zRet;\n    *(z++) = '\"';\n    for(i=0; zInput[i]; i++){\n      if( zInput[i]=='\"' ) *(z++) = '\"';\n      *(z++) = zInput[i];\n    }\n    *(z++) = '\"';\n    *(z++) = '\\0';\n  }\n  return zRet;\n}\n\n/*\n** Return a list of comma separated SQL expressions and a FROM clause that \n** could be used in a SELECT statement such as the following:\n**\n**     SELECT <list of expressions> FROM %_content AS x ...\n**\n** to return the docid, followed by each column of text data in order\n** from left to write. If parameter zFunc is not NULL, then instead of\n** being returned directly each column of text data is passed to an SQL\n** function named zFunc first. For example, if zFunc is \"unzip\" and the\n** table has the three user-defined columns \"a\", \"b\", and \"c\", the following\n** string is returned:\n**\n**     \"docid, unzip(x.'a'), unzip(x.'b'), unzip(x.'c') FROM %_content AS x\"\n**\n** The pointer returned points to a buffer allocated by sqlite3_malloc(). It\n** is the responsibility of the caller to eventually free it.\n**\n** If *pRc is not SQLITE_OK when this function is called, it is a no-op (and\n** a NULL pointer is returned). Otherwise, if an OOM error is encountered\n** by this function, NULL is returned and *pRc is set to SQLITE_NOMEM. If\n** no error occurs, *pRc is left unmodified.\n*/\nstatic char *fts3ReadExprList(Fts3Table *p, const char *zFunc, int *pRc){\n  char *zRet = 0;\n  char *zFree = 0;\n  char *zFunction;\n  int i;\n\n  if( p->zContentTbl==0 ){\n    if( !zFunc ){\n      zFunction = \"\";\n    }else{\n      zFree = zFunction = fts3QuoteId(zFunc);\n    }\n    fts3Appendf(pRc, &zRet, \"docid\");\n    for(i=0; i<p->nColumn; i++){\n      fts3Appendf(pRc, &zRet, \",%s(x.'c%d%q')\", zFunction, i, p->azColumn[i]);\n    }\n    if( p->zLanguageid ){\n      fts3Appendf(pRc, &zRet, \", x.%Q\", \"langid\");\n    }\n    sqlite3_free(zFree);\n  }else{\n    fts3Appendf(pRc, &zRet, \"rowid\");\n    for(i=0; i<p->nColumn; i++){\n      fts3Appendf(pRc, &zRet, \", x.'%q'\", p->azColumn[i]);\n    }\n    if( p->zLanguageid ){\n      fts3Appendf(pRc, &zRet, \", x.%Q\", p->zLanguageid);\n    }\n  }\n  fts3Appendf(pRc, &zRet, \" FROM '%q'.'%q%s' AS x\", \n      p->zDb,\n      (p->zContentTbl ? p->zContentTbl : p->zName),\n      (p->zContentTbl ? \"\" : \"_content\")\n  );\n  return zRet;\n}\n\n/*\n** Return a list of N comma separated question marks, where N is the number\n** of columns in the %_content table (one for the docid plus one for each\n** user-defined text column).\n**\n** If argument zFunc is not NULL, then all but the first question mark\n** is preceded by zFunc and an open bracket, and followed by a closed\n** bracket. For example, if zFunc is \"zip\" and the FTS3 table has three \n** user-defined text columns, the following string is returned:\n**\n**     \"?, zip(?), zip(?), zip(?)\"\n**\n** The pointer returned points to a buffer allocated by sqlite3_malloc(). It\n** is the responsibility of the caller to eventually free it.\n**\n** If *pRc is not SQLITE_OK when this function is called, it is a no-op (and\n** a NULL pointer is returned). Otherwise, if an OOM error is encountered\n** by this function, NULL is returned and *pRc is set to SQLITE_NOMEM. If\n** no error occurs, *pRc is left unmodified.\n*/\nstatic char *fts3WriteExprList(Fts3Table *p, const char *zFunc, int *pRc){\n  char *zRet = 0;\n  char *zFree = 0;\n  char *zFunction;\n  int i;\n\n  if( !zFunc ){\n    zFunction = \"\";\n  }else{\n    zFree = zFunction = fts3QuoteId(zFunc);\n  }\n  fts3Appendf(pRc, &zRet, \"?\");\n  for(i=0; i<p->nColumn; i++){\n    fts3Appendf(pRc, &zRet, \",%s(?)\", zFunction);\n  }\n  if( p->zLanguageid ){\n    fts3Appendf(pRc, &zRet, \", ?\");\n  }\n  sqlite3_free(zFree);\n  return zRet;\n}\n\n/*\n** This function interprets the string at (*pp) as a non-negative integer\n** value. It reads the integer and sets *pnOut to the value read, then \n** sets *pp to point to the byte immediately following the last byte of\n** the integer value.\n**\n** Only decimal digits ('0'..'9') may be part of an integer value. \n**\n** If *pp does not being with a decimal digit SQLITE_ERROR is returned and\n** the output value undefined. Otherwise SQLITE_OK is returned.\n**\n** This function is used when parsing the \"prefix=\" FTS4 parameter.\n*/\nstatic int fts3GobbleInt(const char **pp, int *pnOut){\n  const int MAX_NPREFIX = 10000000;\n  const char *p;                  /* Iterator pointer */\n  int nInt = 0;                   /* Output value */\n\n  for(p=*pp; p[0]>='0' && p[0]<='9'; p++){\n    nInt = nInt * 10 + (p[0] - '0');\n    if( nInt>MAX_NPREFIX ){\n      nInt = 0;\n      break;\n    }\n  }\n  if( p==*pp ) return SQLITE_ERROR;\n  *pnOut = nInt;\n  *pp = p;\n  return SQLITE_OK;\n}\n\n/*\n** This function is called to allocate an array of Fts3Index structures\n** representing the indexes maintained by the current FTS table. FTS tables\n** always maintain the main \"terms\" index, but may also maintain one or\n** more \"prefix\" indexes, depending on the value of the \"prefix=\" parameter\n** (if any) specified as part of the CREATE VIRTUAL TABLE statement.\n**\n** Argument zParam is passed the value of the \"prefix=\" option if one was\n** specified, or NULL otherwise.\n**\n** If no error occurs, SQLITE_OK is returned and *apIndex set to point to\n** the allocated array. *pnIndex is set to the number of elements in the\n** array. If an error does occur, an SQLite error code is returned.\n**\n** Regardless of whether or not an error is returned, it is the responsibility\n** of the caller to call sqlite3_free() on the output array to free it.\n*/\nstatic int fts3PrefixParameter(\n  const char *zParam,             /* ABC in prefix=ABC parameter to parse */\n  int *pnIndex,                   /* OUT: size of *apIndex[] array */\n  struct Fts3Index **apIndex      /* OUT: Array of indexes for this table */\n){\n  struct Fts3Index *aIndex;       /* Allocated array */\n  int nIndex = 1;                 /* Number of entries in array */\n\n  if( zParam && zParam[0] ){\n    const char *p;\n    nIndex++;\n    for(p=zParam; *p; p++){\n      if( *p==',' ) nIndex++;\n    }\n  }\n\n  aIndex = sqlite3_malloc64(sizeof(struct Fts3Index) * nIndex);\n  *apIndex = aIndex;\n  if( !aIndex ){\n    return SQLITE_NOMEM;\n  }\n\n  memset(aIndex, 0, sizeof(struct Fts3Index) * nIndex);\n  if( zParam ){\n    const char *p = zParam;\n    int i;\n    for(i=1; i<nIndex; i++){\n      int nPrefix = 0;\n      if( fts3GobbleInt(&p, &nPrefix) ) return SQLITE_ERROR;\n      assert( nPrefix>=0 );\n      if( nPrefix==0 ){\n        nIndex--;\n        i--;\n      }else{\n        aIndex[i].nPrefix = nPrefix;\n      }\n      p++;\n    }\n  }\n\n  *pnIndex = nIndex;\n  return SQLITE_OK;\n}\n\n/*\n** This function is called when initializing an FTS4 table that uses the\n** content=xxx option. It determines the number of and names of the columns\n** of the new FTS4 table.\n**\n** The third argument passed to this function is the value passed to the\n** config=xxx option (i.e. \"xxx\"). This function queries the database for\n** a table of that name. If found, the output variables are populated\n** as follows:\n**\n**   *pnCol:   Set to the number of columns table xxx has,\n**\n**   *pnStr:   Set to the total amount of space required to store a copy\n**             of each columns name, including the nul-terminator.\n**\n**   *pazCol:  Set to point to an array of *pnCol strings. Each string is\n**             the name of the corresponding column in table xxx. The array\n**             and its contents are allocated using a single allocation. It\n**             is the responsibility of the caller to free this allocation\n**             by eventually passing the *pazCol value to sqlite3_free().\n**\n** If the table cannot be found, an error code is returned and the output\n** variables are undefined. Or, if an OOM is encountered, SQLITE_NOMEM is\n** returned (and the output variables are undefined).\n*/\nstatic int fts3ContentColumns(\n  sqlite3 *db,                    /* Database handle */\n  const char *zDb,                /* Name of db (i.e. \"main\", \"temp\" etc.) */\n  const char *zTbl,               /* Name of content table */\n  const char ***pazCol,           /* OUT: Malloc'd array of column names */\n  int *pnCol,                     /* OUT: Size of array *pazCol */\n  int *pnStr,                     /* OUT: Bytes of string content */\n  char **pzErr                    /* OUT: error message */\n){\n  int rc = SQLITE_OK;             /* Return code */\n  char *zSql;                     /* \"SELECT *\" statement on zTbl */  \n  sqlite3_stmt *pStmt = 0;        /* Compiled version of zSql */\n\n  zSql = sqlite3_mprintf(\"SELECT * FROM %Q.%Q\", zDb, zTbl);\n  if( !zSql ){\n    rc = SQLITE_NOMEM;\n  }else{\n    rc = sqlite3_prepare(db, zSql, -1, &pStmt, 0);\n    if( rc!=SQLITE_OK ){\n      sqlite3Fts3ErrMsg(pzErr, \"%s\", sqlite3_errmsg(db));\n    }\n  }\n  sqlite3_free(zSql);\n\n  if( rc==SQLITE_OK ){\n    const char **azCol;           /* Output array */\n    sqlite3_int64 nStr = 0;       /* Size of all column names (incl. 0x00) */\n    int nCol;                     /* Number of table columns */\n    int i;                        /* Used to iterate through columns */\n\n    /* Loop through the returned columns. Set nStr to the number of bytes of\n    ** space required to store a copy of each column name, including the\n    ** nul-terminator byte.  */\n    nCol = sqlite3_column_count(pStmt);\n    for(i=0; i<nCol; i++){\n      const char *zCol = sqlite3_column_name(pStmt, i);\n      nStr += strlen(zCol) + 1;\n    }\n\n    /* Allocate and populate the array to return. */\n    azCol = (const char **)sqlite3_malloc64(sizeof(char *) * nCol + nStr);\n    if( azCol==0 ){\n      rc = SQLITE_NOMEM;\n    }else{\n      char *p = (char *)&azCol[nCol];\n      for(i=0; i<nCol; i++){\n        const char *zCol = sqlite3_column_name(pStmt, i);\n        int n = (int)strlen(zCol)+1;\n        memcpy(p, zCol, n);\n        azCol[i] = p;\n        p += n;\n      }\n    }\n    sqlite3_finalize(pStmt);\n\n    /* Set the output variables. */\n    *pnCol = nCol;\n    *pnStr = nStr;\n    *pazCol = azCol;\n  }\n\n  return rc;\n}\n\n/*\n** This function is the implementation of both the xConnect and xCreate\n** methods of the FTS3 virtual table.\n**\n** The argv[] array contains the following:\n**\n**   argv[0]   -> module name  (\"fts3\" or \"fts4\")\n**   argv[1]   -> database name\n**   argv[2]   -> table name\n**   argv[...] -> \"column name\" and other module argument fields.\n*/\nstatic int fts3InitVtab(\n  int isCreate,                   /* True for xCreate, false for xConnect */\n  sqlite3 *db,                    /* The SQLite database connection */\n  void *pAux,                     /* Hash table containing tokenizers */\n  int argc,                       /* Number of elements in argv array */\n  const char * const *argv,       /* xCreate/xConnect argument array */\n  sqlite3_vtab **ppVTab,          /* Write the resulting vtab structure here */\n  char **pzErr                    /* Write any error message here */\n){\n  Fts3Hash *pHash = (Fts3Hash *)pAux;\n  Fts3Table *p = 0;               /* Pointer to allocated vtab */\n  int rc = SQLITE_OK;             /* Return code */\n  int i;                          /* Iterator variable */\n  sqlite3_int64 nByte;            /* Size of allocation used for *p */\n  int iCol;                       /* Column index */\n  int nString = 0;                /* Bytes required to hold all column names */\n  int nCol = 0;                   /* Number of columns in the FTS table */\n  char *zCsr;                     /* Space for holding column names */\n  int nDb;                        /* Bytes required to hold database name */\n  int nName;                      /* Bytes required to hold table name */\n  int isFts4 = (argv[0][3]=='4'); /* True for FTS4, false for FTS3 */\n  const char **aCol;              /* Array of column names */\n  sqlite3_tokenizer *pTokenizer = 0;        /* Tokenizer for this table */\n\n  int nIndex = 0;                 /* Size of aIndex[] array */\n  struct Fts3Index *aIndex = 0;   /* Array of indexes for this table */\n\n  /* The results of parsing supported FTS4 key=value options: */\n  int bNoDocsize = 0;             /* True to omit %_docsize table */\n  int bDescIdx = 0;               /* True to store descending indexes */\n  char *zPrefix = 0;              /* Prefix parameter value (or NULL) */\n  char *zCompress = 0;            /* compress=? parameter (or NULL) */\n  char *zUncompress = 0;          /* uncompress=? parameter (or NULL) */\n  char *zContent = 0;             /* content=? parameter (or NULL) */\n  char *zLanguageid = 0;          /* languageid=? parameter (or NULL) */\n  char **azNotindexed = 0;        /* The set of notindexed= columns */\n  int nNotindexed = 0;            /* Size of azNotindexed[] array */\n\n  assert( strlen(argv[0])==4 );\n  assert( (sqlite3_strnicmp(argv[0], \"fts4\", 4)==0 && isFts4)\n       || (sqlite3_strnicmp(argv[0], \"fts3\", 4)==0 && !isFts4)\n  );\n\n  nDb = (int)strlen(argv[1]) + 1;\n  nName = (int)strlen(argv[2]) + 1;\n\n  nByte = sizeof(const char *) * (argc-2);\n  aCol = (const char **)sqlite3_malloc64(nByte);\n  if( aCol ){\n    memset((void*)aCol, 0, nByte);\n    azNotindexed = (char **)sqlite3_malloc64(nByte);\n  }\n  if( azNotindexed ){\n    memset(azNotindexed, 0, nByte);\n  }\n  if( !aCol || !azNotindexed ){\n    rc = SQLITE_NOMEM;\n    goto fts3_init_out;\n  }\n\n  /* Loop through all of the arguments passed by the user to the FTS3/4\n  ** module (i.e. all the column names and special arguments). This loop\n  ** does the following:\n  **\n  **   + Figures out the number of columns the FTSX table will have, and\n  **     the number of bytes of space that must be allocated to store copies\n  **     of the column names.\n  **\n  **   + If there is a tokenizer specification included in the arguments,\n  **     initializes the tokenizer pTokenizer.\n  */\n  for(i=3; rc==SQLITE_OK && i<argc; i++){\n    char const *z = argv[i];\n    int nKey;\n    char *zVal;\n\n    /* Check if this is a tokenizer specification */\n    if( !pTokenizer \n     && strlen(z)>8\n     && 0==sqlite3_strnicmp(z, \"tokenize\", 8) \n     && 0==sqlite3Fts3IsIdChar(z[8])\n    ){\n      rc = sqlite3Fts3InitTokenizer(pHash, &z[9], &pTokenizer, pzErr);\n    }\n\n    /* Check if it is an FTS4 special argument. */\n    else if( isFts4 && fts3IsSpecialColumn(z, &nKey, &zVal) ){\n      struct Fts4Option {\n        const char *zOpt;\n        int nOpt;\n      } aFts4Opt[] = {\n        { \"matchinfo\",   9 },     /* 0 -> MATCHINFO */\n        { \"prefix\",      6 },     /* 1 -> PREFIX */\n        { \"compress\",    8 },     /* 2 -> COMPRESS */\n        { \"uncompress\", 10 },     /* 3 -> UNCOMPRESS */\n        { \"order\",       5 },     /* 4 -> ORDER */\n        { \"content\",     7 },     /* 5 -> CONTENT */\n        { \"languageid\", 10 },     /* 6 -> LANGUAGEID */\n        { \"notindexed\", 10 }      /* 7 -> NOTINDEXED */\n      };\n\n      int iOpt;\n      if( !zVal ){\n        rc = SQLITE_NOMEM;\n      }else{\n        for(iOpt=0; iOpt<SizeofArray(aFts4Opt); iOpt++){\n          struct Fts4Option *pOp = &aFts4Opt[iOpt];\n          if( nKey==pOp->nOpt && !sqlite3_strnicmp(z, pOp->zOpt, pOp->nOpt) ){\n            break;\n          }\n        }\n        switch( iOpt ){\n          case 0:               /* MATCHINFO */\n            if( strlen(zVal)!=4 || sqlite3_strnicmp(zVal, \"fts3\", 4) ){\n              sqlite3Fts3ErrMsg(pzErr, \"unrecognized matchinfo: %s\", zVal);\n              rc = SQLITE_ERROR;\n            }\n            bNoDocsize = 1;\n            break;\n\n          case 1:               /* PREFIX */\n            sqlite3_free(zPrefix);\n            zPrefix = zVal;\n            zVal = 0;\n            break;\n\n          case 2:               /* COMPRESS */\n            sqlite3_free(zCompress);\n            zCompress = zVal;\n            zVal = 0;\n            break;\n\n          case 3:               /* UNCOMPRESS */\n            sqlite3_free(zUncompress);\n            zUncompress = zVal;\n            zVal = 0;\n            break;\n\n          case 4:               /* ORDER */\n            if( (strlen(zVal)!=3 || sqlite3_strnicmp(zVal, \"asc\", 3)) \n             && (strlen(zVal)!=4 || sqlite3_strnicmp(zVal, \"desc\", 4)) \n            ){\n              sqlite3Fts3ErrMsg(pzErr, \"unrecognized order: %s\", zVal);\n              rc = SQLITE_ERROR;\n            }\n            bDescIdx = (zVal[0]=='d' || zVal[0]=='D');\n            break;\n\n          case 5:              /* CONTENT */\n            sqlite3_free(zContent);\n            zContent = zVal;\n            zVal = 0;\n            break;\n\n          case 6:              /* LANGUAGEID */\n            assert( iOpt==6 );\n            sqlite3_free(zLanguageid);\n            zLanguageid = zVal;\n            zVal = 0;\n            break;\n\n          case 7:              /* NOTINDEXED */\n            azNotindexed[nNotindexed++] = zVal;\n            zVal = 0;\n            break;\n\n          default:\n            assert( iOpt==SizeofArray(aFts4Opt) );\n            sqlite3Fts3ErrMsg(pzErr, \"unrecognized parameter: %s\", z);\n            rc = SQLITE_ERROR;\n            break;\n        }\n        sqlite3_free(zVal);\n      }\n    }\n\n    /* Otherwise, the argument is a column name. */\n    else {\n      nString += (int)(strlen(z) + 1);\n      aCol[nCol++] = z;\n    }\n  }\n\n  /* If a content=xxx option was specified, the following:\n  **\n  **   1. Ignore any compress= and uncompress= options.\n  **\n  **   2. If no column names were specified as part of the CREATE VIRTUAL\n  **      TABLE statement, use all columns from the content table.\n  */\n  if( rc==SQLITE_OK && zContent ){\n    sqlite3_free(zCompress); \n    sqlite3_free(zUncompress); \n    zCompress = 0;\n    zUncompress = 0;\n    if( nCol==0 ){\n      sqlite3_free((void*)aCol); \n      aCol = 0;\n      rc = fts3ContentColumns(db, argv[1], zContent,&aCol,&nCol,&nString,pzErr);\n\n      /* If a languageid= option was specified, remove the language id\n      ** column from the aCol[] array. */ \n      if( rc==SQLITE_OK && zLanguageid ){\n        int j;\n        for(j=0; j<nCol; j++){\n          if( sqlite3_stricmp(zLanguageid, aCol[j])==0 ){\n            int k;\n            for(k=j; k<nCol; k++) aCol[k] = aCol[k+1];\n            nCol--;\n            break;\n          }\n        }\n      }\n    }\n  }\n  if( rc!=SQLITE_OK ) goto fts3_init_out;\n\n  if( nCol==0 ){\n    assert( nString==0 );\n    aCol[0] = \"content\";\n    nString = 8;\n    nCol = 1;\n  }\n\n  if( pTokenizer==0 ){\n    rc = sqlite3Fts3InitTokenizer(pHash, \"simple\", &pTokenizer, pzErr);\n    if( rc!=SQLITE_OK ) goto fts3_init_out;\n  }\n  assert( pTokenizer );\n\n  rc = fts3PrefixParameter(zPrefix, &nIndex, &aIndex);\n  if( rc==SQLITE_ERROR ){\n    assert( zPrefix );\n    sqlite3Fts3ErrMsg(pzErr, \"error parsing prefix parameter: %s\", zPrefix);\n  }\n  if( rc!=SQLITE_OK ) goto fts3_init_out;\n\n  /* Allocate and populate the Fts3Table structure. */\n  nByte = sizeof(Fts3Table) +                  /* Fts3Table */\n          nCol * sizeof(char *) +              /* azColumn */\n          nIndex * sizeof(struct Fts3Index) +  /* aIndex */\n          nCol * sizeof(u8) +                  /* abNotindexed */\n          nName +                              /* zName */\n          nDb +                                /* zDb */\n          nString;                             /* Space for azColumn strings */\n  p = (Fts3Table*)sqlite3_malloc64(nByte);\n  if( p==0 ){\n    rc = SQLITE_NOMEM;\n    goto fts3_init_out;\n  }\n  memset(p, 0, nByte);\n  p->db = db;\n  p->nColumn = nCol;\n  p->nPendingData = 0;\n  p->azColumn = (char **)&p[1];\n  p->pTokenizer = pTokenizer;\n  p->nMaxPendingData = FTS3_MAX_PENDING_DATA;\n  p->bHasDocsize = (isFts4 && bNoDocsize==0);\n  p->bHasStat = (u8)isFts4;\n  p->bFts4 = (u8)isFts4;\n  p->bDescIdx = (u8)bDescIdx;\n  p->nAutoincrmerge = 0xff;   /* 0xff means setting unknown */\n  p->zContentTbl = zContent;\n  p->zLanguageid = zLanguageid;\n  zContent = 0;\n  zLanguageid = 0;\n  TESTONLY( p->inTransaction = -1 );\n  TESTONLY( p->mxSavepoint = -1 );\n\n  p->aIndex = (struct Fts3Index *)&p->azColumn[nCol];\n  memcpy(p->aIndex, aIndex, sizeof(struct Fts3Index) * nIndex);\n  p->nIndex = nIndex;\n  for(i=0; i<nIndex; i++){\n    fts3HashInit(&p->aIndex[i].hPending, FTS3_HASH_STRING, 1);\n  }\n  p->abNotindexed = (u8 *)&p->aIndex[nIndex];\n\n  /* Fill in the zName and zDb fields of the vtab structure. */\n  zCsr = (char *)&p->abNotindexed[nCol];\n  p->zName = zCsr;\n  memcpy(zCsr, argv[2], nName);\n  zCsr += nName;\n  p->zDb = zCsr;\n  memcpy(zCsr, argv[1], nDb);\n  zCsr += nDb;\n\n  /* Fill in the azColumn array */\n  for(iCol=0; iCol<nCol; iCol++){\n    char *z; \n    int n = 0;\n    z = (char *)sqlite3Fts3NextToken(aCol[iCol], &n);\n    if( n>0 ){\n      memcpy(zCsr, z, n);\n    }\n    zCsr[n] = '\\0';\n    sqlite3Fts3Dequote(zCsr);\n    p->azColumn[iCol] = zCsr;\n    zCsr += n+1;\n    assert( zCsr <= &((char *)p)[nByte] );\n  }\n\n  /* Fill in the abNotindexed array */\n  for(iCol=0; iCol<nCol; iCol++){\n    int n = (int)strlen(p->azColumn[iCol]);\n    for(i=0; i<nNotindexed; i++){\n      char *zNot = azNotindexed[i];\n      if( zNot && n==(int)strlen(zNot)\n       && 0==sqlite3_strnicmp(p->azColumn[iCol], zNot, n) \n      ){\n        p->abNotindexed[iCol] = 1;\n        sqlite3_free(zNot);\n        azNotindexed[i] = 0;\n      }\n    }\n  }\n  for(i=0; i<nNotindexed; i++){\n    if( azNotindexed[i] ){\n      sqlite3Fts3ErrMsg(pzErr, \"no such column: %s\", azNotindexed[i]);\n      rc = SQLITE_ERROR;\n    }\n  }\n\n  if( rc==SQLITE_OK && (zCompress==0)!=(zUncompress==0) ){\n    char const *zMiss = (zCompress==0 ? \"compress\" : \"uncompress\");\n    rc = SQLITE_ERROR;\n    sqlite3Fts3ErrMsg(pzErr, \"missing %s parameter in fts4 constructor\", zMiss);\n  }\n  p->zReadExprlist = fts3ReadExprList(p, zUncompress, &rc);\n  p->zWriteExprlist = fts3WriteExprList(p, zCompress, &rc);\n  if( rc!=SQLITE_OK ) goto fts3_init_out;\n\n  /* If this is an xCreate call, create the underlying tables in the \n  ** database. TODO: For xConnect(), it could verify that said tables exist.\n  */\n  if( isCreate ){\n    rc = fts3CreateTables(p);\n  }\n\n  /* Check to see if a legacy fts3 table has been \"upgraded\" by the\n  ** addition of a %_stat table so that it can use incremental merge.\n  */\n  if( !isFts4 && !isCreate ){\n    p->bHasStat = 2;\n  }\n\n  /* Figure out the page-size for the database. This is required in order to\n  ** estimate the cost of loading large doclists from the database.  */\n  fts3DatabasePageSize(&rc, p);\n  p->nNodeSize = p->nPgsz-35;\n\n  /* Declare the table schema to SQLite. */\n  fts3DeclareVtab(&rc, p);\n\nfts3_init_out:\n  sqlite3_free(zPrefix);\n  sqlite3_free(aIndex);\n  sqlite3_free(zCompress);\n  sqlite3_free(zUncompress);\n  sqlite3_free(zContent);\n  sqlite3_free(zLanguageid);\n  for(i=0; i<nNotindexed; i++) sqlite3_free(azNotindexed[i]);\n  sqlite3_free((void *)aCol);\n  sqlite3_free((void *)azNotindexed);\n  if( rc!=SQLITE_OK ){\n    if( p ){\n      fts3DisconnectMethod((sqlite3_vtab *)p);\n    }else if( pTokenizer ){\n      pTokenizer->pModule->xDestroy(pTokenizer);\n    }\n  }else{\n    assert( p->pSegments==0 );\n    *ppVTab = &p->base;\n  }\n  return rc;\n}\n\n/*\n** The xConnect() and xCreate() methods for the virtual table. All the\n** work is done in function fts3InitVtab().\n*/\nstatic int fts3ConnectMethod(\n  sqlite3 *db,                    /* Database connection */\n  void *pAux,                     /* Pointer to tokenizer hash table */\n  int argc,                       /* Number of elements in argv array */\n  const char * const *argv,       /* xCreate/xConnect argument array */\n  sqlite3_vtab **ppVtab,          /* OUT: New sqlite3_vtab object */\n  char **pzErr                    /* OUT: sqlite3_malloc'd error message */\n){\n  return fts3InitVtab(0, db, pAux, argc, argv, ppVtab, pzErr);\n}\nstatic int fts3CreateMethod(\n  sqlite3 *db,                    /* Database connection */\n  void *pAux,                     /* Pointer to tokenizer hash table */\n  int argc,                       /* Number of elements in argv array */\n  const char * const *argv,       /* xCreate/xConnect argument array */\n  sqlite3_vtab **ppVtab,          /* OUT: New sqlite3_vtab object */\n  char **pzErr                    /* OUT: sqlite3_malloc'd error message */\n){\n  return fts3InitVtab(1, db, pAux, argc, argv, ppVtab, pzErr);\n}\n\n/*\n** Set the pIdxInfo->estimatedRows variable to nRow. Unless this\n** extension is currently being used by a version of SQLite too old to\n** support estimatedRows. In that case this function is a no-op.\n*/\nstatic void fts3SetEstimatedRows(sqlite3_index_info *pIdxInfo, i64 nRow){\n#if SQLITE_VERSION_NUMBER>=3008002\n  if( sqlite3_libversion_number()>=3008002 ){\n    pIdxInfo->estimatedRows = nRow;\n  }\n#endif\n}\n\n/*\n** Set the SQLITE_INDEX_SCAN_UNIQUE flag in pIdxInfo->flags. Unless this\n** extension is currently being used by a version of SQLite too old to\n** support index-info flags. In that case this function is a no-op.\n*/\nstatic void fts3SetUniqueFlag(sqlite3_index_info *pIdxInfo){\n#if SQLITE_VERSION_NUMBER>=3008012\n  if( sqlite3_libversion_number()>=3008012 ){\n    pIdxInfo->idxFlags |= SQLITE_INDEX_SCAN_UNIQUE;\n  }\n#endif\n}\n\n/* \n** Implementation of the xBestIndex method for FTS3 tables. There\n** are three possible strategies, in order of preference:\n**\n**   1. Direct lookup by rowid or docid. \n**   2. Full-text search using a MATCH operator on a non-docid column.\n**   3. Linear scan of %_content table.\n*/\nstatic int fts3BestIndexMethod(sqlite3_vtab *pVTab, sqlite3_index_info *pInfo){\n  Fts3Table *p = (Fts3Table *)pVTab;\n  int i;                          /* Iterator variable */\n  int iCons = -1;                 /* Index of constraint to use */\n\n  int iLangidCons = -1;           /* Index of langid=x constraint, if present */\n  int iDocidGe = -1;              /* Index of docid>=x constraint, if present */\n  int iDocidLe = -1;              /* Index of docid<=x constraint, if present */\n  int iIdx;\n\n  /* By default use a full table scan. This is an expensive option,\n  ** so search through the constraints to see if a more efficient \n  ** strategy is possible.\n  */\n  pInfo->idxNum = FTS3_FULLSCAN_SEARCH;\n  pInfo->estimatedCost = 5000000;\n  for(i=0; i<pInfo->nConstraint; i++){\n    int bDocid;                 /* True if this constraint is on docid */\n    struct sqlite3_index_constraint *pCons = &pInfo->aConstraint[i];\n    if( pCons->usable==0 ){\n      if( pCons->op==SQLITE_INDEX_CONSTRAINT_MATCH ){\n        /* There exists an unusable MATCH constraint. This means that if\n        ** the planner does elect to use the results of this call as part\n        ** of the overall query plan the user will see an \"unable to use\n        ** function MATCH in the requested context\" error. To discourage\n        ** this, return a very high cost here.  */\n        pInfo->idxNum = FTS3_FULLSCAN_SEARCH;\n        pInfo->estimatedCost = 1e50;\n        fts3SetEstimatedRows(pInfo, ((sqlite3_int64)1) << 50);\n        return SQLITE_OK;\n      }\n      continue;\n    }\n\n    bDocid = (pCons->iColumn<0 || pCons->iColumn==p->nColumn+1);\n\n    /* A direct lookup on the rowid or docid column. Assign a cost of 1.0. */\n    if( iCons<0 && pCons->op==SQLITE_INDEX_CONSTRAINT_EQ && bDocid ){\n      pInfo->idxNum = FTS3_DOCID_SEARCH;\n      pInfo->estimatedCost = 1.0;\n      iCons = i;\n    }\n\n    /* A MATCH constraint. Use a full-text search.\n    **\n    ** If there is more than one MATCH constraint available, use the first\n    ** one encountered. If there is both a MATCH constraint and a direct\n    ** rowid/docid lookup, prefer the MATCH strategy. This is done even \n    ** though the rowid/docid lookup is faster than a MATCH query, selecting\n    ** it would lead to an \"unable to use function MATCH in the requested \n    ** context\" error.\n    */\n    if( pCons->op==SQLITE_INDEX_CONSTRAINT_MATCH \n     && pCons->iColumn>=0 && pCons->iColumn<=p->nColumn\n    ){\n      pInfo->idxNum = FTS3_FULLTEXT_SEARCH + pCons->iColumn;\n      pInfo->estimatedCost = 2.0;\n      iCons = i;\n    }\n\n    /* Equality constraint on the langid column */\n    if( pCons->op==SQLITE_INDEX_CONSTRAINT_EQ \n     && pCons->iColumn==p->nColumn + 2\n    ){\n      iLangidCons = i;\n    }\n\n    if( bDocid ){\n      switch( pCons->op ){\n        case SQLITE_INDEX_CONSTRAINT_GE:\n        case SQLITE_INDEX_CONSTRAINT_GT:\n          iDocidGe = i;\n          break;\n\n        case SQLITE_INDEX_CONSTRAINT_LE:\n        case SQLITE_INDEX_CONSTRAINT_LT:\n          iDocidLe = i;\n          break;\n      }\n    }\n  }\n\n  /* If using a docid=? or rowid=? strategy, set the UNIQUE flag. */\n  if( pInfo->idxNum==FTS3_DOCID_SEARCH ) fts3SetUniqueFlag(pInfo);\n\n  iIdx = 1;\n  if( iCons>=0 ){\n    pInfo->aConstraintUsage[iCons].argvIndex = iIdx++;\n    pInfo->aConstraintUsage[iCons].omit = 1;\n  } \n  if( iLangidCons>=0 ){\n    pInfo->idxNum |= FTS3_HAVE_LANGID;\n    pInfo->aConstraintUsage[iLangidCons].argvIndex = iIdx++;\n  } \n  if( iDocidGe>=0 ){\n    pInfo->idxNum |= FTS3_HAVE_DOCID_GE;\n    pInfo->aConstraintUsage[iDocidGe].argvIndex = iIdx++;\n  } \n  if( iDocidLe>=0 ){\n    pInfo->idxNum |= FTS3_HAVE_DOCID_LE;\n    pInfo->aConstraintUsage[iDocidLe].argvIndex = iIdx++;\n  } \n\n  /* Regardless of the strategy selected, FTS can deliver rows in rowid (or\n  ** docid) order. Both ascending and descending are possible. \n  */\n  if( pInfo->nOrderBy==1 ){\n    struct sqlite3_index_orderby *pOrder = &pInfo->aOrderBy[0];\n    if( pOrder->iColumn<0 || pOrder->iColumn==p->nColumn+1 ){\n      if( pOrder->desc ){\n        pInfo->idxStr = \"DESC\";\n      }else{\n        pInfo->idxStr = \"ASC\";\n      }\n      pInfo->orderByConsumed = 1;\n    }\n  }\n\n  assert( p->pSegments==0 );\n  return SQLITE_OK;\n}\n\n/*\n** Implementation of xOpen method.\n*/\nstatic int fts3OpenMethod(sqlite3_vtab *pVTab, sqlite3_vtab_cursor **ppCsr){\n  sqlite3_vtab_cursor *pCsr;               /* Allocated cursor */\n\n  UNUSED_PARAMETER(pVTab);\n\n  /* Allocate a buffer large enough for an Fts3Cursor structure. If the\n  ** allocation succeeds, zero it and return SQLITE_OK. Otherwise, \n  ** if the allocation fails, return SQLITE_NOMEM.\n  */\n  *ppCsr = pCsr = (sqlite3_vtab_cursor *)sqlite3_malloc(sizeof(Fts3Cursor));\n  if( !pCsr ){\n    return SQLITE_NOMEM;\n  }\n  memset(pCsr, 0, sizeof(Fts3Cursor));\n  return SQLITE_OK;\n}\n\n/*\n** Finalize the statement handle at pCsr->pStmt.\n**\n** Or, if that statement handle is one created by fts3CursorSeekStmt(),\n** and the Fts3Table.pSeekStmt slot is currently NULL, save the statement\n** pointer there instead of finalizing it.\n*/\nstatic void fts3CursorFinalizeStmt(Fts3Cursor *pCsr){\n  if( pCsr->bSeekStmt ){\n    Fts3Table *p = (Fts3Table *)pCsr->base.pVtab;\n    if( p->pSeekStmt==0 ){\n      p->pSeekStmt = pCsr->pStmt;\n      sqlite3_reset(pCsr->pStmt);\n      pCsr->pStmt = 0;\n    }\n    pCsr->bSeekStmt = 0;\n  }\n  sqlite3_finalize(pCsr->pStmt);\n}\n\n/*\n** Free all resources currently held by the cursor passed as the only\n** argument.\n*/\nstatic void fts3ClearCursor(Fts3Cursor *pCsr){\n  fts3CursorFinalizeStmt(pCsr);\n  sqlite3Fts3FreeDeferredTokens(pCsr);\n  sqlite3_free(pCsr->aDoclist);\n  sqlite3Fts3MIBufferFree(pCsr->pMIBuffer);\n  sqlite3Fts3ExprFree(pCsr->pExpr);\n  memset(&(&pCsr->base)[1], 0, sizeof(Fts3Cursor)-sizeof(sqlite3_vtab_cursor));\n}\n\n/*\n** Close the cursor.  For additional information see the documentation\n** on the xClose method of the virtual table interface.\n*/\nstatic int fts3CloseMethod(sqlite3_vtab_cursor *pCursor){\n  Fts3Cursor *pCsr = (Fts3Cursor *)pCursor;\n  assert( ((Fts3Table *)pCsr->base.pVtab)->pSegments==0 );\n  fts3ClearCursor(pCsr);\n  assert( ((Fts3Table *)pCsr->base.pVtab)->pSegments==0 );\n  sqlite3_free(pCsr);\n  return SQLITE_OK;\n}\n\n/*\n** If pCsr->pStmt has not been prepared (i.e. if pCsr->pStmt==0), then\n** compose and prepare an SQL statement of the form:\n**\n**    \"SELECT <columns> FROM %_content WHERE rowid = ?\"\n**\n** (or the equivalent for a content=xxx table) and set pCsr->pStmt to\n** it. If an error occurs, return an SQLite error code.\n*/\nstatic int fts3CursorSeekStmt(Fts3Cursor *pCsr){\n  int rc = SQLITE_OK;\n  if( pCsr->pStmt==0 ){\n    Fts3Table *p = (Fts3Table *)pCsr->base.pVtab;\n    char *zSql;\n    if( p->pSeekStmt ){\n      pCsr->pStmt = p->pSeekStmt;\n      p->pSeekStmt = 0;\n    }else{\n      zSql = sqlite3_mprintf(\"SELECT %s WHERE rowid = ?\", p->zReadExprlist);\n      if( !zSql ) return SQLITE_NOMEM;\n      rc = sqlite3_prepare_v3(p->db, zSql,-1,SQLITE_PREPARE_PERSISTENT,&pCsr->pStmt,0);\n      sqlite3_free(zSql);\n    }\n    if( rc==SQLITE_OK ) pCsr->bSeekStmt = 1;\n  }\n  return rc;\n}\n\n/*\n** Position the pCsr->pStmt statement so that it is on the row\n** of the %_content table that contains the last match.  Return\n** SQLITE_OK on success.  \n*/\nstatic int fts3CursorSeek(sqlite3_context *pContext, Fts3Cursor *pCsr){\n  int rc = SQLITE_OK;\n  if( pCsr->isRequireSeek ){\n    rc = fts3CursorSeekStmt(pCsr);\n    if( rc==SQLITE_OK ){\n      sqlite3_bind_int64(pCsr->pStmt, 1, pCsr->iPrevId);\n      pCsr->isRequireSeek = 0;\n      if( SQLITE_ROW==sqlite3_step(pCsr->pStmt) ){\n        return SQLITE_OK;\n      }else{\n        rc = sqlite3_reset(pCsr->pStmt);\n        if( rc==SQLITE_OK && ((Fts3Table *)pCsr->base.pVtab)->zContentTbl==0 ){\n          /* If no row was found and no error has occurred, then the %_content\n          ** table is missing a row that is present in the full-text index.\n          ** The data structures are corrupt.  */\n          rc = FTS_CORRUPT_VTAB;\n          pCsr->isEof = 1;\n        }\n      }\n    }\n  }\n\n  if( rc!=SQLITE_OK && pContext ){\n    sqlite3_result_error_code(pContext, rc);\n  }\n  return rc;\n}\n\n/*\n** This function is used to process a single interior node when searching\n** a b-tree for a term or term prefix. The node data is passed to this \n** function via the zNode/nNode parameters. The term to search for is\n** passed in zTerm/nTerm.\n**\n** If piFirst is not NULL, then this function sets *piFirst to the blockid\n** of the child node that heads the sub-tree that may contain the term.\n**\n** If piLast is not NULL, then *piLast is set to the right-most child node\n** that heads a sub-tree that may contain a term for which zTerm/nTerm is\n** a prefix.\n**\n** If an OOM error occurs, SQLITE_NOMEM is returned. Otherwise, SQLITE_OK.\n*/\nstatic int fts3ScanInteriorNode(\n  const char *zTerm,              /* Term to select leaves for */\n  int nTerm,                      /* Size of term zTerm in bytes */\n  const char *zNode,              /* Buffer containing segment interior node */\n  int nNode,                      /* Size of buffer at zNode */\n  sqlite3_int64 *piFirst,         /* OUT: Selected child node */\n  sqlite3_int64 *piLast           /* OUT: Selected child node */\n){\n  int rc = SQLITE_OK;             /* Return code */\n  const char *zCsr = zNode;       /* Cursor to iterate through node */\n  const char *zEnd = &zCsr[nNode];/* End of interior node buffer */\n  char *zBuffer = 0;              /* Buffer to load terms into */\n  i64 nAlloc = 0;                 /* Size of allocated buffer */\n  int isFirstTerm = 1;            /* True when processing first term on page */\n  sqlite3_int64 iChild;           /* Block id of child node to descend to */\n\n  /* Skip over the 'height' varint that occurs at the start of every \n  ** interior node. Then load the blockid of the left-child of the b-tree\n  ** node into variable iChild.  \n  **\n  ** Even if the data structure on disk is corrupted, this (reading two\n  ** varints from the buffer) does not risk an overread. If zNode is a\n  ** root node, then the buffer comes from a SELECT statement. SQLite does\n  ** not make this guarantee explicitly, but in practice there are always\n  ** either more than 20 bytes of allocated space following the nNode bytes of\n  ** contents, or two zero bytes. Or, if the node is read from the %_segments\n  ** table, then there are always 20 bytes of zeroed padding following the\n  ** nNode bytes of content (see sqlite3Fts3ReadBlock() for details).\n  */\n  zCsr += sqlite3Fts3GetVarint(zCsr, &iChild);\n  zCsr += sqlite3Fts3GetVarint(zCsr, &iChild);\n  if( zCsr>zEnd ){\n    return FTS_CORRUPT_VTAB;\n  }\n  \n  while( zCsr<zEnd && (piFirst || piLast) ){\n    int cmp;                      /* memcmp() result */\n    int nSuffix;                  /* Size of term suffix */\n    int nPrefix = 0;              /* Size of term prefix */\n    int nBuffer;                  /* Total term size */\n  \n    /* Load the next term on the node into zBuffer. Use realloc() to expand\n    ** the size of zBuffer if required.  */\n    if( !isFirstTerm ){\n      zCsr += fts3GetVarint32(zCsr, &nPrefix);\n    }\n    isFirstTerm = 0;\n    zCsr += fts3GetVarint32(zCsr, &nSuffix);\n    \n    assert( nPrefix>=0 && nSuffix>=0 );\n    if( nPrefix>zCsr-zNode || nSuffix>zEnd-zCsr ){\n      rc = FTS_CORRUPT_VTAB;\n      goto finish_scan;\n    }\n    if( (i64)nPrefix+nSuffix>nAlloc ){\n      char *zNew;\n      nAlloc = ((i64)nPrefix+nSuffix) * 2;\n      zNew = (char *)sqlite3_realloc64(zBuffer, nAlloc);\n      if( !zNew ){\n        rc = SQLITE_NOMEM;\n        goto finish_scan;\n      }\n      zBuffer = zNew;\n    }\n    assert( zBuffer );\n    memcpy(&zBuffer[nPrefix], zCsr, nSuffix);\n    nBuffer = nPrefix + nSuffix;\n    zCsr += nSuffix;\n\n    /* Compare the term we are searching for with the term just loaded from\n    ** the interior node. If the specified term is greater than or equal\n    ** to the term from the interior node, then all terms on the sub-tree \n    ** headed by node iChild are smaller than zTerm. No need to search \n    ** iChild.\n    **\n    ** If the interior node term is larger than the specified term, then\n    ** the tree headed by iChild may contain the specified term.\n    */\n    cmp = memcmp(zTerm, zBuffer, (nBuffer>nTerm ? nTerm : nBuffer));\n    if( piFirst && (cmp<0 || (cmp==0 && nBuffer>nTerm)) ){\n      *piFirst = iChild;\n      piFirst = 0;\n    }\n\n    if( piLast && cmp<0 ){\n      *piLast = iChild;\n      piLast = 0;\n    }\n\n    iChild++;\n  };\n\n  if( piFirst ) *piFirst = iChild;\n  if( piLast ) *piLast = iChild;\n\n finish_scan:\n  sqlite3_free(zBuffer);\n  return rc;\n}\n\n\n/*\n** The buffer pointed to by argument zNode (size nNode bytes) contains an\n** interior node of a b-tree segment. The zTerm buffer (size nTerm bytes)\n** contains a term. This function searches the sub-tree headed by the zNode\n** node for the range of leaf nodes that may contain the specified term\n** or terms for which the specified term is a prefix.\n**\n** If piLeaf is not NULL, then *piLeaf is set to the blockid of the \n** left-most leaf node in the tree that may contain the specified term.\n** If piLeaf2 is not NULL, then *piLeaf2 is set to the blockid of the\n** right-most leaf node that may contain a term for which the specified\n** term is a prefix.\n**\n** It is possible that the range of returned leaf nodes does not contain \n** the specified term or any terms for which it is a prefix. However, if the \n** segment does contain any such terms, they are stored within the identified\n** range. Because this function only inspects interior segment nodes (and\n** never loads leaf nodes into memory), it is not possible to be sure.\n**\n** If an error occurs, an error code other than SQLITE_OK is returned.\n*/ \nstatic int fts3SelectLeaf(\n  Fts3Table *p,                   /* Virtual table handle */\n  const char *zTerm,              /* Term to select leaves for */\n  int nTerm,                      /* Size of term zTerm in bytes */\n  const char *zNode,              /* Buffer containing segment interior node */\n  int nNode,                      /* Size of buffer at zNode */\n  sqlite3_int64 *piLeaf,          /* Selected leaf node */\n  sqlite3_int64 *piLeaf2          /* Selected leaf node */\n){\n  int rc = SQLITE_OK;             /* Return code */\n  int iHeight;                    /* Height of this node in tree */\n\n  assert( piLeaf || piLeaf2 );\n\n  fts3GetVarint32(zNode, &iHeight);\n  rc = fts3ScanInteriorNode(zTerm, nTerm, zNode, nNode, piLeaf, piLeaf2);\n  assert( !piLeaf2 || !piLeaf || rc!=SQLITE_OK || (*piLeaf<=*piLeaf2) );\n\n  if( rc==SQLITE_OK && iHeight>1 ){\n    char *zBlob = 0;              /* Blob read from %_segments table */\n    int nBlob = 0;                /* Size of zBlob in bytes */\n\n    if( piLeaf && piLeaf2 && (*piLeaf!=*piLeaf2) ){\n      rc = sqlite3Fts3ReadBlock(p, *piLeaf, &zBlob, &nBlob, 0);\n      if( rc==SQLITE_OK ){\n        rc = fts3SelectLeaf(p, zTerm, nTerm, zBlob, nBlob, piLeaf, 0);\n      }\n      sqlite3_free(zBlob);\n      piLeaf = 0;\n      zBlob = 0;\n    }\n\n    if( rc==SQLITE_OK ){\n      rc = sqlite3Fts3ReadBlock(p, piLeaf?*piLeaf:*piLeaf2, &zBlob, &nBlob, 0);\n    }\n    if( rc==SQLITE_OK ){\n      rc = fts3SelectLeaf(p, zTerm, nTerm, zBlob, nBlob, piLeaf, piLeaf2);\n    }\n    sqlite3_free(zBlob);\n  }\n\n  return rc;\n}\n\n/*\n** This function is used to create delta-encoded serialized lists of FTS3 \n** varints. Each call to this function appends a single varint to a list.\n*/\nstatic void fts3PutDeltaVarint(\n  char **pp,                      /* IN/OUT: Output pointer */\n  sqlite3_int64 *piPrev,          /* IN/OUT: Previous value written to list */\n  sqlite3_int64 iVal              /* Write this value to the list */\n){\n  assert( iVal-*piPrev > 0 || (*piPrev==0 && iVal==0) );\n  *pp += sqlite3Fts3PutVarint(*pp, iVal-*piPrev);\n  *piPrev = iVal;\n}\n\n/*\n** When this function is called, *ppPoslist is assumed to point to the \n** start of a position-list. After it returns, *ppPoslist points to the\n** first byte after the position-list.\n**\n** A position list is list of positions (delta encoded) and columns for \n** a single document record of a doclist.  So, in other words, this\n** routine advances *ppPoslist so that it points to the next docid in\n** the doclist, or to the first byte past the end of the doclist.\n**\n** If pp is not NULL, then the contents of the position list are copied\n** to *pp. *pp is set to point to the first byte past the last byte copied\n** before this function returns.\n*/\nstatic void fts3PoslistCopy(char **pp, char **ppPoslist){\n  char *pEnd = *ppPoslist;\n  char c = 0;\n\n  /* The end of a position list is marked by a zero encoded as an FTS3 \n  ** varint. A single POS_END (0) byte. Except, if the 0 byte is preceded by\n  ** a byte with the 0x80 bit set, then it is not a varint 0, but the tail\n  ** of some other, multi-byte, value.\n  **\n  ** The following while-loop moves pEnd to point to the first byte that is not \n  ** immediately preceded by a byte with the 0x80 bit set. Then increments\n  ** pEnd once more so that it points to the byte immediately following the\n  ** last byte in the position-list.\n  */\n  while( *pEnd | c ){\n    c = *pEnd++ & 0x80;\n    testcase( c!=0 && (*pEnd)==0 );\n  }\n  pEnd++;  /* Advance past the POS_END terminator byte */\n\n  if( pp ){\n    int n = (int)(pEnd - *ppPoslist);\n    char *p = *pp;\n    memcpy(p, *ppPoslist, n);\n    p += n;\n    *pp = p;\n  }\n  *ppPoslist = pEnd;\n}\n\n/*\n** When this function is called, *ppPoslist is assumed to point to the \n** start of a column-list. After it returns, *ppPoslist points to the\n** to the terminator (POS_COLUMN or POS_END) byte of the column-list.\n**\n** A column-list is list of delta-encoded positions for a single column\n** within a single document within a doclist.\n**\n** The column-list is terminated either by a POS_COLUMN varint (1) or\n** a POS_END varint (0).  This routine leaves *ppPoslist pointing to\n** the POS_COLUMN or POS_END that terminates the column-list.\n**\n** If pp is not NULL, then the contents of the column-list are copied\n** to *pp. *pp is set to point to the first byte past the last byte copied\n** before this function returns.  The POS_COLUMN or POS_END terminator\n** is not copied into *pp.\n*/\nstatic void fts3ColumnlistCopy(char **pp, char **ppPoslist){\n  char *pEnd = *ppPoslist;\n  char c = 0;\n\n  /* A column-list is terminated by either a 0x01 or 0x00 byte that is\n  ** not part of a multi-byte varint.\n  */\n  while( 0xFE & (*pEnd | c) ){\n    c = *pEnd++ & 0x80;\n    testcase( c!=0 && ((*pEnd)&0xfe)==0 );\n  }\n  if( pp ){\n    int n = (int)(pEnd - *ppPoslist);\n    char *p = *pp;\n    memcpy(p, *ppPoslist, n);\n    p += n;\n    *pp = p;\n  }\n  *ppPoslist = pEnd;\n}\n\n/*\n** Value used to signify the end of an position-list. This is safe because\n** it is not possible to have a document with 2^31 terms.\n*/\n#define POSITION_LIST_END 0x7fffffff\n\n/*\n** This function is used to help parse position-lists. When this function is\n** called, *pp may point to the start of the next varint in the position-list\n** being parsed, or it may point to 1 byte past the end of the position-list\n** (in which case **pp will be a terminator bytes POS_END (0) or\n** (1)).\n**\n** If *pp points past the end of the current position-list, set *pi to \n** POSITION_LIST_END and return. Otherwise, read the next varint from *pp,\n** increment the current value of *pi by the value read, and set *pp to\n** point to the next value before returning.\n**\n** Before calling this routine *pi must be initialized to the value of\n** the previous position, or zero if we are reading the first position\n** in the position-list.  Because positions are delta-encoded, the value\n** of the previous position is needed in order to compute the value of\n** the next position.\n*/\nstatic void fts3ReadNextPos(\n  char **pp,                    /* IN/OUT: Pointer into position-list buffer */\n  sqlite3_int64 *pi             /* IN/OUT: Value read from position-list */\n){\n  if( (**pp)&0xFE ){\n    fts3GetDeltaVarint(pp, pi);\n    *pi -= 2;\n  }else{\n    *pi = POSITION_LIST_END;\n  }\n}\n\n/*\n** If parameter iCol is not 0, write an POS_COLUMN (1) byte followed by\n** the value of iCol encoded as a varint to *pp.   This will start a new\n** column list.\n**\n** Set *pp to point to the byte just after the last byte written before \n** returning (do not modify it if iCol==0). Return the total number of bytes\n** written (0 if iCol==0).\n*/\nstatic int fts3PutColNumber(char **pp, int iCol){\n  int n = 0;                      /* Number of bytes written */\n  if( iCol ){\n    char *p = *pp;                /* Output pointer */\n    n = 1 + sqlite3Fts3PutVarint(&p[1], iCol);\n    *p = 0x01;\n    *pp = &p[n];\n  }\n  return n;\n}\n\n/*\n** Compute the union of two position lists.  The output written\n** into *pp contains all positions of both *pp1 and *pp2 in sorted\n** order and with any duplicates removed.  All pointers are\n** updated appropriately.   The caller is responsible for insuring\n** that there is enough space in *pp to hold the complete output.\n*/\nstatic int fts3PoslistMerge(\n  char **pp,                      /* Output buffer */\n  char **pp1,                     /* Left input list */\n  char **pp2                      /* Right input list */\n){\n  char *p = *pp;\n  char *p1 = *pp1;\n  char *p2 = *pp2;\n\n  while( *p1 || *p2 ){\n    int iCol1;         /* The current column index in pp1 */\n    int iCol2;         /* The current column index in pp2 */\n\n    if( *p1==POS_COLUMN ){ \n      fts3GetVarint32(&p1[1], &iCol1);\n      if( iCol1==0 ) return FTS_CORRUPT_VTAB;\n    }\n    else if( *p1==POS_END ) iCol1 = POSITION_LIST_END;\n    else iCol1 = 0;\n\n    if( *p2==POS_COLUMN ){\n      fts3GetVarint32(&p2[1], &iCol2);\n      if( iCol2==0 ) return FTS_CORRUPT_VTAB;\n    }\n    else if( *p2==POS_END ) iCol2 = POSITION_LIST_END;\n    else iCol2 = 0;\n\n    if( iCol1==iCol2 ){\n      sqlite3_int64 i1 = 0;       /* Last position from pp1 */\n      sqlite3_int64 i2 = 0;       /* Last position from pp2 */\n      sqlite3_int64 iPrev = 0;\n      int n = fts3PutColNumber(&p, iCol1);\n      p1 += n;\n      p2 += n;\n\n      /* At this point, both p1 and p2 point to the start of column-lists\n      ** for the same column (the column with index iCol1 and iCol2).\n      ** A column-list is a list of non-negative delta-encoded varints, each \n      ** incremented by 2 before being stored. Each list is terminated by a\n      ** POS_END (0) or POS_COLUMN (1). The following block merges the two lists\n      ** and writes the results to buffer p. p is left pointing to the byte\n      ** after the list written. No terminator (POS_END or POS_COLUMN) is\n      ** written to the output.\n      */\n      fts3GetDeltaVarint(&p1, &i1);\n      fts3GetDeltaVarint(&p2, &i2);\n      do {\n        fts3PutDeltaVarint(&p, &iPrev, (i1<i2) ? i1 : i2); \n        iPrev -= 2;\n        if( i1==i2 ){\n          fts3ReadNextPos(&p1, &i1);\n          fts3ReadNextPos(&p2, &i2);\n        }else if( i1<i2 ){\n          fts3ReadNextPos(&p1, &i1);\n        }else{\n          fts3ReadNextPos(&p2, &i2);\n        }\n      }while( i1!=POSITION_LIST_END || i2!=POSITION_LIST_END );\n    }else if( iCol1<iCol2 ){\n      p1 += fts3PutColNumber(&p, iCol1);\n      fts3ColumnlistCopy(&p, &p1);\n    }else{\n      p2 += fts3PutColNumber(&p, iCol2);\n      fts3ColumnlistCopy(&p, &p2);\n    }\n  }\n\n  *p++ = POS_END;\n  *pp = p;\n  *pp1 = p1 + 1;\n  *pp2 = p2 + 1;\n  return SQLITE_OK;\n}\n\n/*\n** This function is used to merge two position lists into one. When it is\n** called, *pp1 and *pp2 must both point to position lists. A position-list is\n** the part of a doclist that follows each document id. For example, if a row\n** contains:\n**\n**     'a b c'|'x y z'|'a b b a'\n**\n** Then the position list for this row for token 'b' would consist of:\n**\n**     0x02 0x01 0x02 0x03 0x03 0x00\n**\n** When this function returns, both *pp1 and *pp2 are left pointing to the\n** byte following the 0x00 terminator of their respective position lists.\n**\n** If isSaveLeft is 0, an entry is added to the output position list for \n** each position in *pp2 for which there exists one or more positions in\n** *pp1 so that (pos(*pp2)>pos(*pp1) && pos(*pp2)-pos(*pp1)<=nToken). i.e.\n** when the *pp1 token appears before the *pp2 token, but not more than nToken\n** slots before it.\n**\n** e.g. nToken==1 searches for adjacent positions.\n*/\nstatic int fts3PoslistPhraseMerge(\n  char **pp,                      /* IN/OUT: Preallocated output buffer */\n  int nToken,                     /* Maximum difference in token positions */\n  int isSaveLeft,                 /* Save the left position */\n  int isExact,                    /* If *pp1 is exactly nTokens before *pp2 */\n  char **pp1,                     /* IN/OUT: Left input list */\n  char **pp2                      /* IN/OUT: Right input list */\n){\n  char *p = *pp;\n  char *p1 = *pp1;\n  char *p2 = *pp2;\n  int iCol1 = 0;\n  int iCol2 = 0;\n\n  /* Never set both isSaveLeft and isExact for the same invocation. */\n  assert( isSaveLeft==0 || isExact==0 );\n\n  assert( p!=0 && *p1!=0 && *p2!=0 );\n  if( *p1==POS_COLUMN ){ \n    p1++;\n    p1 += fts3GetVarint32(p1, &iCol1);\n  }\n  if( *p2==POS_COLUMN ){ \n    p2++;\n    p2 += fts3GetVarint32(p2, &iCol2);\n  }\n\n  while( 1 ){\n    if( iCol1==iCol2 ){\n      char *pSave = p;\n      sqlite3_int64 iPrev = 0;\n      sqlite3_int64 iPos1 = 0;\n      sqlite3_int64 iPos2 = 0;\n\n      if( iCol1 ){\n        *p++ = POS_COLUMN;\n        p += sqlite3Fts3PutVarint(p, iCol1);\n      }\n\n      fts3GetDeltaVarint(&p1, &iPos1); iPos1 -= 2;\n      fts3GetDeltaVarint(&p2, &iPos2); iPos2 -= 2;\n      if( iPos1<0 || iPos2<0 ) break;\n\n      while( 1 ){\n        if( iPos2==iPos1+nToken \n         || (isExact==0 && iPos2>iPos1 && iPos2<=iPos1+nToken) \n        ){\n          sqlite3_int64 iSave;\n          iSave = isSaveLeft ? iPos1 : iPos2;\n          fts3PutDeltaVarint(&p, &iPrev, iSave+2); iPrev -= 2;\n          pSave = 0;\n          assert( p );\n        }\n        if( (!isSaveLeft && iPos2<=(iPos1+nToken)) || iPos2<=iPos1 ){\n          if( (*p2&0xFE)==0 ) break;\n          fts3GetDeltaVarint(&p2, &iPos2); iPos2 -= 2;\n        }else{\n          if( (*p1&0xFE)==0 ) break;\n          fts3GetDeltaVarint(&p1, &iPos1); iPos1 -= 2;\n        }\n      }\n\n      if( pSave ){\n        assert( pp && p );\n        p = pSave;\n      }\n\n      fts3ColumnlistCopy(0, &p1);\n      fts3ColumnlistCopy(0, &p2);\n      assert( (*p1&0xFE)==0 && (*p2&0xFE)==0 );\n      if( 0==*p1 || 0==*p2 ) break;\n\n      p1++;\n      p1 += fts3GetVarint32(p1, &iCol1);\n      p2++;\n      p2 += fts3GetVarint32(p2, &iCol2);\n    }\n\n    /* Advance pointer p1 or p2 (whichever corresponds to the smaller of\n    ** iCol1 and iCol2) so that it points to either the 0x00 that marks the\n    ** end of the position list, or the 0x01 that precedes the next \n    ** column-number in the position list. \n    */\n    else if( iCol1<iCol2 ){\n      fts3ColumnlistCopy(0, &p1);\n      if( 0==*p1 ) break;\n      p1++;\n      p1 += fts3GetVarint32(p1, &iCol1);\n    }else{\n      fts3ColumnlistCopy(0, &p2);\n      if( 0==*p2 ) break;\n      p2++;\n      p2 += fts3GetVarint32(p2, &iCol2);\n    }\n  }\n\n  fts3PoslistCopy(0, &p2);\n  fts3PoslistCopy(0, &p1);\n  *pp1 = p1;\n  *pp2 = p2;\n  if( *pp==p ){\n    return 0;\n  }\n  *p++ = 0x00;\n  *pp = p;\n  return 1;\n}\n\n/*\n** Merge two position-lists as required by the NEAR operator. The argument\n** position lists correspond to the left and right phrases of an expression \n** like:\n**\n**     \"phrase 1\" NEAR \"phrase number 2\"\n**\n** Position list *pp1 corresponds to the left-hand side of the NEAR \n** expression and *pp2 to the right. As usual, the indexes in the position \n** lists are the offsets of the last token in each phrase (tokens \"1\" and \"2\" \n** in the example above).\n**\n** The output position list - written to *pp - is a copy of *pp2 with those\n** entries that are not sufficiently NEAR entries in *pp1 removed.\n*/\nstatic int fts3PoslistNearMerge(\n  char **pp,                      /* Output buffer */\n  char *aTmp,                     /* Temporary buffer space */\n  int nRight,                     /* Maximum difference in token positions */\n  int nLeft,                      /* Maximum difference in token positions */\n  char **pp1,                     /* IN/OUT: Left input list */\n  char **pp2                      /* IN/OUT: Right input list */\n){\n  char *p1 = *pp1;\n  char *p2 = *pp2;\n\n  char *pTmp1 = aTmp;\n  char *pTmp2;\n  char *aTmp2;\n  int res = 1;\n\n  fts3PoslistPhraseMerge(&pTmp1, nRight, 0, 0, pp1, pp2);\n  aTmp2 = pTmp2 = pTmp1;\n  *pp1 = p1;\n  *pp2 = p2;\n  fts3PoslistPhraseMerge(&pTmp2, nLeft, 1, 0, pp2, pp1);\n  if( pTmp1!=aTmp && pTmp2!=aTmp2 ){\n    fts3PoslistMerge(pp, &aTmp, &aTmp2);\n  }else if( pTmp1!=aTmp ){\n    fts3PoslistCopy(pp, &aTmp);\n  }else if( pTmp2!=aTmp2 ){\n    fts3PoslistCopy(pp, &aTmp2);\n  }else{\n    res = 0;\n  }\n\n  return res;\n}\n\n/* \n** An instance of this function is used to merge together the (potentially\n** large number of) doclists for each term that matches a prefix query.\n** See function fts3TermSelectMerge() for details.\n*/\ntypedef struct TermSelect TermSelect;\nstruct TermSelect {\n  char *aaOutput[16];             /* Malloc'd output buffers */\n  int anOutput[16];               /* Size each output buffer in bytes */\n};\n\n/*\n** This function is used to read a single varint from a buffer. Parameter\n** pEnd points 1 byte past the end of the buffer. When this function is\n** called, if *pp points to pEnd or greater, then the end of the buffer\n** has been reached. In this case *pp is set to 0 and the function returns.\n**\n** If *pp does not point to or past pEnd, then a single varint is read\n** from *pp. *pp is then set to point 1 byte past the end of the read varint.\n**\n** If bDescIdx is false, the value read is added to *pVal before returning.\n** If it is true, the value read is subtracted from *pVal before this \n** function returns.\n*/\nstatic void fts3GetDeltaVarint3(\n  char **pp,                      /* IN/OUT: Point to read varint from */\n  char *pEnd,                     /* End of buffer */\n  int bDescIdx,                   /* True if docids are descending */\n  sqlite3_int64 *pVal             /* IN/OUT: Integer value */\n){\n  if( *pp>=pEnd ){\n    *pp = 0;\n  }else{\n    sqlite3_int64 iVal;\n    *pp += sqlite3Fts3GetVarint(*pp, &iVal);\n    if( bDescIdx ){\n      *pVal -= iVal;\n    }else{\n      *pVal += iVal;\n    }\n  }\n}\n\n/*\n** This function is used to write a single varint to a buffer. The varint\n** is written to *pp. Before returning, *pp is set to point 1 byte past the\n** end of the value written.\n**\n** If *pbFirst is zero when this function is called, the value written to\n** the buffer is that of parameter iVal. \n**\n** If *pbFirst is non-zero when this function is called, then the value \n** written is either (iVal-*piPrev) (if bDescIdx is zero) or (*piPrev-iVal)\n** (if bDescIdx is non-zero).\n**\n** Before returning, this function always sets *pbFirst to 1 and *piPrev\n** to the value of parameter iVal.\n*/\nstatic void fts3PutDeltaVarint3(\n  char **pp,                      /* IN/OUT: Output pointer */\n  int bDescIdx,                   /* True for descending docids */\n  sqlite3_int64 *piPrev,          /* IN/OUT: Previous value written to list */\n  int *pbFirst,                   /* IN/OUT: True after first int written */\n  sqlite3_int64 iVal              /* Write this value to the list */\n){\n  sqlite3_int64 iWrite;\n  if( bDescIdx==0 || *pbFirst==0 ){\n    iWrite = iVal - *piPrev;\n  }else{\n    iWrite = *piPrev - iVal;\n  }\n  assert( *pbFirst || *piPrev==0 );\n  assert( *pbFirst==0 || iWrite>0 );\n  *pp += sqlite3Fts3PutVarint(*pp, iWrite);\n  *piPrev = iVal;\n  *pbFirst = 1;\n}\n\n\n/*\n** This macro is used by various functions that merge doclists. The two\n** arguments are 64-bit docid values. If the value of the stack variable\n** bDescDoclist is 0 when this macro is invoked, then it returns (i1-i2). \n** Otherwise, (i2-i1).\n**\n** Using this makes it easier to write code that can merge doclists that are\n** sorted in either ascending or descending order.\n*/\n#define DOCID_CMP(i1, i2) ((bDescDoclist?-1:1) * (i1-i2))\n\n/*\n** This function does an \"OR\" merge of two doclists (output contains all\n** positions contained in either argument doclist). If the docids in the \n** input doclists are sorted in ascending order, parameter bDescDoclist\n** should be false. If they are sorted in ascending order, it should be\n** passed a non-zero value.\n**\n** If no error occurs, *paOut is set to point at an sqlite3_malloc'd buffer\n** containing the output doclist and SQLITE_OK is returned. In this case\n** *pnOut is set to the number of bytes in the output doclist.\n**\n** If an error occurs, an SQLite error code is returned. The output values\n** are undefined in this case.\n*/\nstatic int fts3DoclistOrMerge(\n  int bDescDoclist,               /* True if arguments are desc */\n  char *a1, int n1,               /* First doclist */\n  char *a2, int n2,               /* Second doclist */\n  char **paOut, int *pnOut        /* OUT: Malloc'd doclist */\n){\n  int rc = SQLITE_OK;\n  sqlite3_int64 i1 = 0;\n  sqlite3_int64 i2 = 0;\n  sqlite3_int64 iPrev = 0;\n  char *pEnd1 = &a1[n1];\n  char *pEnd2 = &a2[n2];\n  char *p1 = a1;\n  char *p2 = a2;\n  char *p;\n  char *aOut;\n  int bFirstOut = 0;\n\n  *paOut = 0;\n  *pnOut = 0;\n\n  /* Allocate space for the output. Both the input and output doclists\n  ** are delta encoded. If they are in ascending order (bDescDoclist==0),\n  ** then the first docid in each list is simply encoded as a varint. For\n  ** each subsequent docid, the varint stored is the difference between the\n  ** current and previous docid (a positive number - since the list is in\n  ** ascending order).\n  **\n  ** The first docid written to the output is therefore encoded using the \n  ** same number of bytes as it is in whichever of the input lists it is\n  ** read from. And each subsequent docid read from the same input list \n  ** consumes either the same or less bytes as it did in the input (since\n  ** the difference between it and the previous value in the output must\n  ** be a positive value less than or equal to the delta value read from \n  ** the input list). The same argument applies to all but the first docid\n  ** read from the 'other' list. And to the contents of all position lists\n  ** that will be copied and merged from the input to the output.\n  **\n  ** However, if the first docid copied to the output is a negative number,\n  ** then the encoding of the first docid from the 'other' input list may\n  ** be larger in the output than it was in the input (since the delta value\n  ** may be a larger positive integer than the actual docid).\n  **\n  ** The space required to store the output is therefore the sum of the\n  ** sizes of the two inputs, plus enough space for exactly one of the input\n  ** docids to grow. \n  **\n  ** A symetric argument may be made if the doclists are in descending \n  ** order.\n  */\n  aOut = sqlite3_malloc64((i64)n1+n2+FTS3_VARINT_MAX-1+FTS3_BUFFER_PADDING);\n  if( !aOut ) return SQLITE_NOMEM;\n\n  p = aOut;\n  fts3GetDeltaVarint3(&p1, pEnd1, 0, &i1);\n  fts3GetDeltaVarint3(&p2, pEnd2, 0, &i2);\n  while( p1 || p2 ){\n    sqlite3_int64 iDiff = DOCID_CMP(i1, i2);\n\n    if( p2 && p1 && iDiff==0 ){\n      fts3PutDeltaVarint3(&p, bDescDoclist, &iPrev, &bFirstOut, i1);\n      rc = fts3PoslistMerge(&p, &p1, &p2);\n      if( rc ) break;\n      fts3GetDeltaVarint3(&p1, pEnd1, bDescDoclist, &i1);\n      fts3GetDeltaVarint3(&p2, pEnd2, bDescDoclist, &i2);\n    }else if( !p2 || (p1 && iDiff<0) ){\n      fts3PutDeltaVarint3(&p, bDescDoclist, &iPrev, &bFirstOut, i1);\n      fts3PoslistCopy(&p, &p1);\n      fts3GetDeltaVarint3(&p1, pEnd1, bDescDoclist, &i1);\n    }else{\n      fts3PutDeltaVarint3(&p, bDescDoclist, &iPrev, &bFirstOut, i2);\n      fts3PoslistCopy(&p, &p2);\n      fts3GetDeltaVarint3(&p2, pEnd2, bDescDoclist, &i2);\n    }\n  }\n\n  if( rc!=SQLITE_OK ){\n    sqlite3_free(aOut);\n    p = aOut = 0;\n  }else{\n    assert( (p-aOut)<=n1+n2+FTS3_VARINT_MAX-1 );\n    memset(&aOut[(p-aOut)], 0, FTS3_BUFFER_PADDING);\n  }\n  *paOut = aOut;\n  *pnOut = (int)(p-aOut);\n  return rc;\n}\n\n/*\n** This function does a \"phrase\" merge of two doclists. In a phrase merge,\n** the output contains a copy of each position from the right-hand input\n** doclist for which there is a position in the left-hand input doclist\n** exactly nDist tokens before it.\n**\n** If the docids in the input doclists are sorted in ascending order,\n** parameter bDescDoclist should be false. If they are sorted in ascending \n** order, it should be passed a non-zero value.\n**\n** The right-hand input doclist is overwritten by this function.\n*/\nstatic int fts3DoclistPhraseMerge(\n  int bDescDoclist,               /* True if arguments are desc */\n  int nDist,                      /* Distance from left to right (1=adjacent) */\n  char *aLeft, int nLeft,         /* Left doclist */\n  char **paRight, int *pnRight    /* IN/OUT: Right/output doclist */\n){\n  sqlite3_int64 i1 = 0;\n  sqlite3_int64 i2 = 0;\n  sqlite3_int64 iPrev = 0;\n  char *aRight = *paRight;\n  char *pEnd1 = &aLeft[nLeft];\n  char *pEnd2 = &aRight[*pnRight];\n  char *p1 = aLeft;\n  char *p2 = aRight;\n  char *p;\n  int bFirstOut = 0;\n  char *aOut;\n\n  assert( nDist>0 );\n  if( bDescDoclist ){\n    aOut = sqlite3_malloc64((sqlite3_int64)*pnRight + FTS3_VARINT_MAX);\n    if( aOut==0 ) return SQLITE_NOMEM;\n  }else{\n    aOut = aRight;\n  }\n  p = aOut;\n\n  fts3GetDeltaVarint3(&p1, pEnd1, 0, &i1);\n  fts3GetDeltaVarint3(&p2, pEnd2, 0, &i2);\n\n  while( p1 && p2 ){\n    sqlite3_int64 iDiff = DOCID_CMP(i1, i2);\n    if( iDiff==0 ){\n      char *pSave = p;\n      sqlite3_int64 iPrevSave = iPrev;\n      int bFirstOutSave = bFirstOut;\n\n      fts3PutDeltaVarint3(&p, bDescDoclist, &iPrev, &bFirstOut, i1);\n      if( 0==fts3PoslistPhraseMerge(&p, nDist, 0, 1, &p1, &p2) ){\n        p = pSave;\n        iPrev = iPrevSave;\n        bFirstOut = bFirstOutSave;\n      }\n      fts3GetDeltaVarint3(&p1, pEnd1, bDescDoclist, &i1);\n      fts3GetDeltaVarint3(&p2, pEnd2, bDescDoclist, &i2);\n    }else if( iDiff<0 ){\n      fts3PoslistCopy(0, &p1);\n      fts3GetDeltaVarint3(&p1, pEnd1, bDescDoclist, &i1);\n    }else{\n      fts3PoslistCopy(0, &p2);\n      fts3GetDeltaVarint3(&p2, pEnd2, bDescDoclist, &i2);\n    }\n  }\n\n  *pnRight = (int)(p - aOut);\n  if( bDescDoclist ){\n    sqlite3_free(aRight);\n    *paRight = aOut;\n  }\n\n  return SQLITE_OK;\n}\n\n/*\n** Argument pList points to a position list nList bytes in size. This\n** function checks to see if the position list contains any entries for\n** a token in position 0 (of any column). If so, it writes argument iDelta\n** to the output buffer pOut, followed by a position list consisting only\n** of the entries from pList at position 0, and terminated by an 0x00 byte.\n** The value returned is the number of bytes written to pOut (if any).\n*/\nSQLITE_PRIVATE int sqlite3Fts3FirstFilter(\n  sqlite3_int64 iDelta,           /* Varint that may be written to pOut */\n  char *pList,                    /* Position list (no 0x00 term) */\n  int nList,                      /* Size of pList in bytes */\n  char *pOut                      /* Write output here */\n){\n  int nOut = 0;\n  int bWritten = 0;               /* True once iDelta has been written */\n  char *p = pList;\n  char *pEnd = &pList[nList];\n\n  if( *p!=0x01 ){\n    if( *p==0x02 ){\n      nOut += sqlite3Fts3PutVarint(&pOut[nOut], iDelta);\n      pOut[nOut++] = 0x02;\n      bWritten = 1;\n    }\n    fts3ColumnlistCopy(0, &p);\n  }\n\n  while( p<pEnd ){\n    sqlite3_int64 iCol;\n    p++;\n    p += sqlite3Fts3GetVarint(p, &iCol);\n    if( *p==0x02 ){\n      if( bWritten==0 ){\n        nOut += sqlite3Fts3PutVarint(&pOut[nOut], iDelta);\n        bWritten = 1;\n      }\n      pOut[nOut++] = 0x01;\n      nOut += sqlite3Fts3PutVarint(&pOut[nOut], iCol);\n      pOut[nOut++] = 0x02;\n    }\n    fts3ColumnlistCopy(0, &p);\n  }\n  if( bWritten ){\n    pOut[nOut++] = 0x00;\n  }\n\n  return nOut;\n}\n\n\n/*\n** Merge all doclists in the TermSelect.aaOutput[] array into a single\n** doclist stored in TermSelect.aaOutput[0]. If successful, delete all\n** other doclists (except the aaOutput[0] one) and return SQLITE_OK.\n**\n** If an OOM error occurs, return SQLITE_NOMEM. In this case it is\n** the responsibility of the caller to free any doclists left in the\n** TermSelect.aaOutput[] array.\n*/\nstatic int fts3TermSelectFinishMerge(Fts3Table *p, TermSelect *pTS){\n  char *aOut = 0;\n  int nOut = 0;\n  int i;\n\n  /* Loop through the doclists in the aaOutput[] array. Merge them all\n  ** into a single doclist.\n  */\n  for(i=0; i<SizeofArray(pTS->aaOutput); i++){\n    if( pTS->aaOutput[i] ){\n      if( !aOut ){\n        aOut = pTS->aaOutput[i];\n        nOut = pTS->anOutput[i];\n        pTS->aaOutput[i] = 0;\n      }else{\n        int nNew;\n        char *aNew;\n\n        int rc = fts3DoclistOrMerge(p->bDescIdx, \n            pTS->aaOutput[i], pTS->anOutput[i], aOut, nOut, &aNew, &nNew\n        );\n        if( rc!=SQLITE_OK ){\n          sqlite3_free(aOut);\n          return rc;\n        }\n\n        sqlite3_free(pTS->aaOutput[i]);\n        sqlite3_free(aOut);\n        pTS->aaOutput[i] = 0;\n        aOut = aNew;\n        nOut = nNew;\n      }\n    }\n  }\n\n  pTS->aaOutput[0] = aOut;\n  pTS->anOutput[0] = nOut;\n  return SQLITE_OK;\n}\n\n/*\n** Merge the doclist aDoclist/nDoclist into the TermSelect object passed\n** as the first argument. The merge is an \"OR\" merge (see function\n** fts3DoclistOrMerge() for details).\n**\n** This function is called with the doclist for each term that matches\n** a queried prefix. It merges all these doclists into one, the doclist\n** for the specified prefix. Since there can be a very large number of\n** doclists to merge, the merging is done pair-wise using the TermSelect\n** object.\n**\n** This function returns SQLITE_OK if the merge is successful, or an\n** SQLite error code (SQLITE_NOMEM) if an error occurs.\n*/\nstatic int fts3TermSelectMerge(\n  Fts3Table *p,                   /* FTS table handle */\n  TermSelect *pTS,                /* TermSelect object to merge into */\n  char *aDoclist,                 /* Pointer to doclist */\n  int nDoclist                    /* Size of aDoclist in bytes */\n){\n  if( pTS->aaOutput[0]==0 ){\n    /* If this is the first term selected, copy the doclist to the output\n    ** buffer using memcpy(). \n    **\n    ** Add FTS3_VARINT_MAX bytes of unused space to the end of the \n    ** allocation. This is so as to ensure that the buffer is big enough\n    ** to hold the current doclist AND'd with any other doclist. If the\n    ** doclists are stored in order=ASC order, this padding would not be\n    ** required (since the size of [doclistA AND doclistB] is always less\n    ** than or equal to the size of [doclistA] in that case). But this is\n    ** not true for order=DESC. For example, a doclist containing (1, -1) \n    ** may be smaller than (-1), as in the first example the -1 may be stored\n    ** as a single-byte delta, whereas in the second it must be stored as a\n    ** FTS3_VARINT_MAX byte varint.\n    **\n    ** Similar padding is added in the fts3DoclistOrMerge() function.\n    */\n    pTS->aaOutput[0] = sqlite3_malloc(nDoclist + FTS3_VARINT_MAX + 1);\n    pTS->anOutput[0] = nDoclist;\n    if( pTS->aaOutput[0] ){\n      memcpy(pTS->aaOutput[0], aDoclist, nDoclist);\n      memset(&pTS->aaOutput[0][nDoclist], 0, FTS3_VARINT_MAX);\n    }else{\n      return SQLITE_NOMEM;\n    }\n  }else{\n    char *aMerge = aDoclist;\n    int nMerge = nDoclist;\n    int iOut;\n\n    for(iOut=0; iOut<SizeofArray(pTS->aaOutput); iOut++){\n      if( pTS->aaOutput[iOut]==0 ){\n        assert( iOut>0 );\n        pTS->aaOutput[iOut] = aMerge;\n        pTS->anOutput[iOut] = nMerge;\n        break;\n      }else{\n        char *aNew;\n        int nNew;\n\n        int rc = fts3DoclistOrMerge(p->bDescIdx, aMerge, nMerge, \n            pTS->aaOutput[iOut], pTS->anOutput[iOut], &aNew, &nNew\n        );\n        if( rc!=SQLITE_OK ){\n          if( aMerge!=aDoclist ) sqlite3_free(aMerge);\n          return rc;\n        }\n\n        if( aMerge!=aDoclist ) sqlite3_free(aMerge);\n        sqlite3_free(pTS->aaOutput[iOut]);\n        pTS->aaOutput[iOut] = 0;\n  \n        aMerge = aNew;\n        nMerge = nNew;\n        if( (iOut+1)==SizeofArray(pTS->aaOutput) ){\n          pTS->aaOutput[iOut] = aMerge;\n          pTS->anOutput[iOut] = nMerge;\n        }\n      }\n    }\n  }\n  return SQLITE_OK;\n}\n\n/*\n** Append SegReader object pNew to the end of the pCsr->apSegment[] array.\n*/\nstatic int fts3SegReaderCursorAppend(\n  Fts3MultiSegReader *pCsr, \n  Fts3SegReader *pNew\n){\n  if( (pCsr->nSegment%16)==0 ){\n    Fts3SegReader **apNew;\n    sqlite3_int64 nByte = (pCsr->nSegment + 16)*sizeof(Fts3SegReader*);\n    apNew = (Fts3SegReader **)sqlite3_realloc64(pCsr->apSegment, nByte);\n    if( !apNew ){\n      sqlite3Fts3SegReaderFree(pNew);\n      return SQLITE_NOMEM;\n    }\n    pCsr->apSegment = apNew;\n  }\n  pCsr->apSegment[pCsr->nSegment++] = pNew;\n  return SQLITE_OK;\n}\n\n/*\n** Add seg-reader objects to the Fts3MultiSegReader object passed as the\n** 8th argument.\n**\n** This function returns SQLITE_OK if successful, or an SQLite error code\n** otherwise.\n*/\nstatic int fts3SegReaderCursor(\n  Fts3Table *p,                   /* FTS3 table handle */\n  int iLangid,                    /* Language id */\n  int iIndex,                     /* Index to search (from 0 to p->nIndex-1) */\n  int iLevel,                     /* Level of segments to scan */\n  const char *zTerm,              /* Term to query for */\n  int nTerm,                      /* Size of zTerm in bytes */\n  int isPrefix,                   /* True for a prefix search */\n  int isScan,                     /* True to scan from zTerm to EOF */\n  Fts3MultiSegReader *pCsr        /* Cursor object to populate */\n){\n  int rc = SQLITE_OK;             /* Error code */\n  sqlite3_stmt *pStmt = 0;        /* Statement to iterate through segments */\n  int rc2;                        /* Result of sqlite3_reset() */\n\n  /* If iLevel is less than 0 and this is not a scan, include a seg-reader \n  ** for the pending-terms. If this is a scan, then this call must be being\n  ** made by an fts4aux module, not an FTS table. In this case calling\n  ** Fts3SegReaderPending might segfault, as the data structures used by \n  ** fts4aux are not completely populated. So it's easiest to filter these\n  ** calls out here.  */\n  if( iLevel<0 && p->aIndex ){\n    Fts3SegReader *pSeg = 0;\n    rc = sqlite3Fts3SegReaderPending(p, iIndex, zTerm, nTerm, isPrefix||isScan, &pSeg);\n    if( rc==SQLITE_OK && pSeg ){\n      rc = fts3SegReaderCursorAppend(pCsr, pSeg);\n    }\n  }\n\n  if( iLevel!=FTS3_SEGCURSOR_PENDING ){\n    if( rc==SQLITE_OK ){\n      rc = sqlite3Fts3AllSegdirs(p, iLangid, iIndex, iLevel, &pStmt);\n    }\n\n    while( rc==SQLITE_OK && SQLITE_ROW==(rc = sqlite3_step(pStmt)) ){\n      Fts3SegReader *pSeg = 0;\n\n      /* Read the values returned by the SELECT into local variables. */\n      sqlite3_int64 iStartBlock = sqlite3_column_int64(pStmt, 1);\n      sqlite3_int64 iLeavesEndBlock = sqlite3_column_int64(pStmt, 2);\n      sqlite3_int64 iEndBlock = sqlite3_column_int64(pStmt, 3);\n      int nRoot = sqlite3_column_bytes(pStmt, 4);\n      char const *zRoot = sqlite3_column_blob(pStmt, 4);\n\n      /* If zTerm is not NULL, and this segment is not stored entirely on its\n      ** root node, the range of leaves scanned can be reduced. Do this. */\n      if( iStartBlock && zTerm && zRoot ){\n        sqlite3_int64 *pi = (isPrefix ? &iLeavesEndBlock : 0);\n        rc = fts3SelectLeaf(p, zTerm, nTerm, zRoot, nRoot, &iStartBlock, pi);\n        if( rc!=SQLITE_OK ) goto finished;\n        if( isPrefix==0 && isScan==0 ) iLeavesEndBlock = iStartBlock;\n      }\n \n      rc = sqlite3Fts3SegReaderNew(pCsr->nSegment+1, \n          (isPrefix==0 && isScan==0),\n          iStartBlock, iLeavesEndBlock, \n          iEndBlock, zRoot, nRoot, &pSeg\n      );\n      if( rc!=SQLITE_OK ) goto finished;\n      rc = fts3SegReaderCursorAppend(pCsr, pSeg);\n    }\n  }\n\n finished:\n  rc2 = sqlite3_reset(pStmt);\n  if( rc==SQLITE_DONE ) rc = rc2;\n\n  return rc;\n}\n\n/*\n** Set up a cursor object for iterating through a full-text index or a \n** single level therein.\n*/\nSQLITE_PRIVATE int sqlite3Fts3SegReaderCursor(\n  Fts3Table *p,                   /* FTS3 table handle */\n  int iLangid,                    /* Language-id to search */\n  int iIndex,                     /* Index to search (from 0 to p->nIndex-1) */\n  int iLevel,                     /* Level of segments to scan */\n  const char *zTerm,              /* Term to query for */\n  int nTerm,                      /* Size of zTerm in bytes */\n  int isPrefix,                   /* True for a prefix search */\n  int isScan,                     /* True to scan from zTerm to EOF */\n  Fts3MultiSegReader *pCsr       /* Cursor object to populate */\n){\n  assert( iIndex>=0 && iIndex<p->nIndex );\n  assert( iLevel==FTS3_SEGCURSOR_ALL\n      ||  iLevel==FTS3_SEGCURSOR_PENDING \n      ||  iLevel>=0\n  );\n  assert( iLevel<FTS3_SEGDIR_MAXLEVEL );\n  assert( FTS3_SEGCURSOR_ALL<0 && FTS3_SEGCURSOR_PENDING<0 );\n  assert( isPrefix==0 || isScan==0 );\n\n  memset(pCsr, 0, sizeof(Fts3MultiSegReader));\n  return fts3SegReaderCursor(\n      p, iLangid, iIndex, iLevel, zTerm, nTerm, isPrefix, isScan, pCsr\n  );\n}\n\n/*\n** In addition to its current configuration, have the Fts3MultiSegReader\n** passed as the 4th argument also scan the doclist for term zTerm/nTerm.\n**\n** SQLITE_OK is returned if no error occurs, otherwise an SQLite error code.\n*/\nstatic int fts3SegReaderCursorAddZero(\n  Fts3Table *p,                   /* FTS virtual table handle */\n  int iLangid,\n  const char *zTerm,              /* Term to scan doclist of */\n  int nTerm,                      /* Number of bytes in zTerm */\n  Fts3MultiSegReader *pCsr        /* Fts3MultiSegReader to modify */\n){\n  return fts3SegReaderCursor(p, \n      iLangid, 0, FTS3_SEGCURSOR_ALL, zTerm, nTerm, 0, 0,pCsr\n  );\n}\n\n/*\n** Open an Fts3MultiSegReader to scan the doclist for term zTerm/nTerm. Or,\n** if isPrefix is true, to scan the doclist for all terms for which \n** zTerm/nTerm is a prefix. If successful, return SQLITE_OK and write\n** a pointer to the new Fts3MultiSegReader to *ppSegcsr. Otherwise, return\n** an SQLite error code.\n**\n** It is the responsibility of the caller to free this object by eventually\n** passing it to fts3SegReaderCursorFree() \n**\n** SQLITE_OK is returned if no error occurs, otherwise an SQLite error code.\n** Output parameter *ppSegcsr is set to 0 if an error occurs.\n*/\nstatic int fts3TermSegReaderCursor(\n  Fts3Cursor *pCsr,               /* Virtual table cursor handle */\n  const char *zTerm,              /* Term to query for */\n  int nTerm,                      /* Size of zTerm in bytes */\n  int isPrefix,                   /* True for a prefix search */\n  Fts3MultiSegReader **ppSegcsr   /* OUT: Allocated seg-reader cursor */\n){\n  Fts3MultiSegReader *pSegcsr;    /* Object to allocate and return */\n  int rc = SQLITE_NOMEM;          /* Return code */\n\n  pSegcsr = sqlite3_malloc(sizeof(Fts3MultiSegReader));\n  if( pSegcsr ){\n    int i;\n    int bFound = 0;               /* True once an index has been found */\n    Fts3Table *p = (Fts3Table *)pCsr->base.pVtab;\n\n    if( isPrefix ){\n      for(i=1; bFound==0 && i<p->nIndex; i++){\n        if( p->aIndex[i].nPrefix==nTerm ){\n          bFound = 1;\n          rc = sqlite3Fts3SegReaderCursor(p, pCsr->iLangid, \n              i, FTS3_SEGCURSOR_ALL, zTerm, nTerm, 0, 0, pSegcsr\n          );\n          pSegcsr->bLookup = 1;\n        }\n      }\n\n      for(i=1; bFound==0 && i<p->nIndex; i++){\n        if( p->aIndex[i].nPrefix==nTerm+1 ){\n          bFound = 1;\n          rc = sqlite3Fts3SegReaderCursor(p, pCsr->iLangid, \n              i, FTS3_SEGCURSOR_ALL, zTerm, nTerm, 1, 0, pSegcsr\n          );\n          if( rc==SQLITE_OK ){\n            rc = fts3SegReaderCursorAddZero(\n                p, pCsr->iLangid, zTerm, nTerm, pSegcsr\n            );\n          }\n        }\n      }\n    }\n\n    if( bFound==0 ){\n      rc = sqlite3Fts3SegReaderCursor(p, pCsr->iLangid, \n          0, FTS3_SEGCURSOR_ALL, zTerm, nTerm, isPrefix, 0, pSegcsr\n      );\n      pSegcsr->bLookup = !isPrefix;\n    }\n  }\n\n  *ppSegcsr = pSegcsr;\n  return rc;\n}\n\n/*\n** Free an Fts3MultiSegReader allocated by fts3TermSegReaderCursor().\n*/\nstatic void fts3SegReaderCursorFree(Fts3MultiSegReader *pSegcsr){\n  sqlite3Fts3SegReaderFinish(pSegcsr);\n  sqlite3_free(pSegcsr);\n}\n\n/*\n** This function retrieves the doclist for the specified term (or term\n** prefix) from the database.\n*/\nstatic int fts3TermSelect(\n  Fts3Table *p,                   /* Virtual table handle */\n  Fts3PhraseToken *pTok,          /* Token to query for */\n  int iColumn,                    /* Column to query (or -ve for all columns) */\n  int *pnOut,                     /* OUT: Size of buffer at *ppOut */\n  char **ppOut                    /* OUT: Malloced result buffer */\n){\n  int rc;                         /* Return code */\n  Fts3MultiSegReader *pSegcsr;    /* Seg-reader cursor for this term */\n  TermSelect tsc;                 /* Object for pair-wise doclist merging */\n  Fts3SegFilter filter;           /* Segment term filter configuration */\n\n  pSegcsr = pTok->pSegcsr;\n  memset(&tsc, 0, sizeof(TermSelect));\n\n  filter.flags = FTS3_SEGMENT_IGNORE_EMPTY | FTS3_SEGMENT_REQUIRE_POS\n        | (pTok->isPrefix ? FTS3_SEGMENT_PREFIX : 0)\n        | (pTok->bFirst ? FTS3_SEGMENT_FIRST : 0)\n        | (iColumn<p->nColumn ? FTS3_SEGMENT_COLUMN_FILTER : 0);\n  filter.iCol = iColumn;\n  filter.zTerm = pTok->z;\n  filter.nTerm = pTok->n;\n\n  rc = sqlite3Fts3SegReaderStart(p, pSegcsr, &filter);\n  while( SQLITE_OK==rc\n      && SQLITE_ROW==(rc = sqlite3Fts3SegReaderStep(p, pSegcsr)) \n  ){\n    rc = fts3TermSelectMerge(p, &tsc, pSegcsr->aDoclist, pSegcsr->nDoclist);\n  }\n\n  if( rc==SQLITE_OK ){\n    rc = fts3TermSelectFinishMerge(p, &tsc);\n  }\n  if( rc==SQLITE_OK ){\n    *ppOut = tsc.aaOutput[0];\n    *pnOut = tsc.anOutput[0];\n  }else{\n    int i;\n    for(i=0; i<SizeofArray(tsc.aaOutput); i++){\n      sqlite3_free(tsc.aaOutput[i]);\n    }\n  }\n\n  fts3SegReaderCursorFree(pSegcsr);\n  pTok->pSegcsr = 0;\n  return rc;\n}\n\n/*\n** This function counts the total number of docids in the doclist stored\n** in buffer aList[], size nList bytes.\n**\n** If the isPoslist argument is true, then it is assumed that the doclist\n** contains a position-list following each docid. Otherwise, it is assumed\n** that the doclist is simply a list of docids stored as delta encoded \n** varints.\n*/\nstatic int fts3DoclistCountDocids(char *aList, int nList){\n  int nDoc = 0;                   /* Return value */\n  if( aList ){\n    char *aEnd = &aList[nList];   /* Pointer to one byte after EOF */\n    char *p = aList;              /* Cursor */\n    while( p<aEnd ){\n      nDoc++;\n      while( (*p++)&0x80 );     /* Skip docid varint */\n      fts3PoslistCopy(0, &p);   /* Skip over position list */\n    }\n  }\n\n  return nDoc;\n}\n\n/*\n** Advance the cursor to the next row in the %_content table that\n** matches the search criteria.  For a MATCH search, this will be\n** the next row that matches. For a full-table scan, this will be\n** simply the next row in the %_content table.  For a docid lookup,\n** this routine simply sets the EOF flag.\n**\n** Return SQLITE_OK if nothing goes wrong.  SQLITE_OK is returned\n** even if we reach end-of-file.  The fts3EofMethod() will be called\n** subsequently to determine whether or not an EOF was hit.\n*/\nstatic int fts3NextMethod(sqlite3_vtab_cursor *pCursor){\n  int rc;\n  Fts3Cursor *pCsr = (Fts3Cursor *)pCursor;\n  if( pCsr->eSearch==FTS3_DOCID_SEARCH || pCsr->eSearch==FTS3_FULLSCAN_SEARCH ){\n    if( SQLITE_ROW!=sqlite3_step(pCsr->pStmt) ){\n      pCsr->isEof = 1;\n      rc = sqlite3_reset(pCsr->pStmt);\n    }else{\n      pCsr->iPrevId = sqlite3_column_int64(pCsr->pStmt, 0);\n      rc = SQLITE_OK;\n    }\n  }else{\n    rc = fts3EvalNext((Fts3Cursor *)pCursor);\n  }\n  assert( ((Fts3Table *)pCsr->base.pVtab)->pSegments==0 );\n  return rc;\n}\n\n/*\n** The following are copied from sqliteInt.h.\n**\n** Constants for the largest and smallest possible 64-bit signed integers.\n** These macros are designed to work correctly on both 32-bit and 64-bit\n** compilers.\n*/\n#ifndef SQLITE_AMALGAMATION\n# define LARGEST_INT64  (0xffffffff|(((sqlite3_int64)0x7fffffff)<<32))\n# define SMALLEST_INT64 (((sqlite3_int64)-1) - LARGEST_INT64)\n#endif\n\n/*\n** If the numeric type of argument pVal is \"integer\", then return it\n** converted to a 64-bit signed integer. Otherwise, return a copy of\n** the second parameter, iDefault.\n*/\nstatic sqlite3_int64 fts3DocidRange(sqlite3_value *pVal, i64 iDefault){\n  if( pVal ){\n    int eType = sqlite3_value_numeric_type(pVal);\n    if( eType==SQLITE_INTEGER ){\n      return sqlite3_value_int64(pVal);\n    }\n  }\n  return iDefault;\n}\n\n/*\n** This is the xFilter interface for the virtual table.  See\n** the virtual table xFilter method documentation for additional\n** information.\n**\n** If idxNum==FTS3_FULLSCAN_SEARCH then do a full table scan against\n** the %_content table.\n**\n** If idxNum==FTS3_DOCID_SEARCH then do a docid lookup for a single entry\n** in the %_content table.\n**\n** If idxNum>=FTS3_FULLTEXT_SEARCH then use the full text index.  The\n** column on the left-hand side of the MATCH operator is column\n** number idxNum-FTS3_FULLTEXT_SEARCH, 0 indexed.  argv[0] is the right-hand\n** side of the MATCH operator.\n*/\nstatic int fts3FilterMethod(\n  sqlite3_vtab_cursor *pCursor,   /* The cursor used for this query */\n  int idxNum,                     /* Strategy index */\n  const char *idxStr,             /* Unused */\n  int nVal,                       /* Number of elements in apVal */\n  sqlite3_value **apVal           /* Arguments for the indexing scheme */\n){\n  int rc = SQLITE_OK;\n  char *zSql;                     /* SQL statement used to access %_content */\n  int eSearch;\n  Fts3Table *p = (Fts3Table *)pCursor->pVtab;\n  Fts3Cursor *pCsr = (Fts3Cursor *)pCursor;\n\n  sqlite3_value *pCons = 0;       /* The MATCH or rowid constraint, if any */\n  sqlite3_value *pLangid = 0;     /* The \"langid = ?\" constraint, if any */\n  sqlite3_value *pDocidGe = 0;    /* The \"docid >= ?\" constraint, if any */\n  sqlite3_value *pDocidLe = 0;    /* The \"docid <= ?\" constraint, if any */\n  int iIdx;\n\n  UNUSED_PARAMETER(idxStr);\n  UNUSED_PARAMETER(nVal);\n\n  eSearch = (idxNum & 0x0000FFFF);\n  assert( eSearch>=0 && eSearch<=(FTS3_FULLTEXT_SEARCH+p->nColumn) );\n  assert( p->pSegments==0 );\n\n  /* Collect arguments into local variables */\n  iIdx = 0;\n  if( eSearch!=FTS3_FULLSCAN_SEARCH ) pCons = apVal[iIdx++];\n  if( idxNum & FTS3_HAVE_LANGID ) pLangid = apVal[iIdx++];\n  if( idxNum & FTS3_HAVE_DOCID_GE ) pDocidGe = apVal[iIdx++];\n  if( idxNum & FTS3_HAVE_DOCID_LE ) pDocidLe = apVal[iIdx++];\n  assert( iIdx==nVal );\n\n  /* In case the cursor has been used before, clear it now. */\n  fts3ClearCursor(pCsr);\n\n  /* Set the lower and upper bounds on docids to return */\n  pCsr->iMinDocid = fts3DocidRange(pDocidGe, SMALLEST_INT64);\n  pCsr->iMaxDocid = fts3DocidRange(pDocidLe, LARGEST_INT64);\n\n  if( idxStr ){\n    pCsr->bDesc = (idxStr[0]=='D');\n  }else{\n    pCsr->bDesc = p->bDescIdx;\n  }\n  pCsr->eSearch = (i16)eSearch;\n\n  if( eSearch!=FTS3_DOCID_SEARCH && eSearch!=FTS3_FULLSCAN_SEARCH ){\n    int iCol = eSearch-FTS3_FULLTEXT_SEARCH;\n    const char *zQuery = (const char *)sqlite3_value_text(pCons);\n\n    if( zQuery==0 && sqlite3_value_type(pCons)!=SQLITE_NULL ){\n      return SQLITE_NOMEM;\n    }\n\n    pCsr->iLangid = 0;\n    if( pLangid ) pCsr->iLangid = sqlite3_value_int(pLangid);\n\n    assert( p->base.zErrMsg==0 );\n    rc = sqlite3Fts3ExprParse(p->pTokenizer, pCsr->iLangid,\n        p->azColumn, p->bFts4, p->nColumn, iCol, zQuery, -1, &pCsr->pExpr, \n        &p->base.zErrMsg\n    );\n    if( rc!=SQLITE_OK ){\n      return rc;\n    }\n\n    rc = fts3EvalStart(pCsr);\n    sqlite3Fts3SegmentsClose(p);\n    if( rc!=SQLITE_OK ) return rc;\n    pCsr->pNextId = pCsr->aDoclist;\n    pCsr->iPrevId = 0;\n  }\n\n  /* Compile a SELECT statement for this cursor. For a full-table-scan, the\n  ** statement loops through all rows of the %_content table. For a\n  ** full-text query or docid lookup, the statement retrieves a single\n  ** row by docid.\n  */\n  if( eSearch==FTS3_FULLSCAN_SEARCH ){\n    if( pDocidGe || pDocidLe ){\n      zSql = sqlite3_mprintf(\n          \"SELECT %s WHERE rowid BETWEEN %lld AND %lld ORDER BY rowid %s\",\n          p->zReadExprlist, pCsr->iMinDocid, pCsr->iMaxDocid,\n          (pCsr->bDesc ? \"DESC\" : \"ASC\")\n      );\n    }else{\n      zSql = sqlite3_mprintf(\"SELECT %s ORDER BY rowid %s\", \n          p->zReadExprlist, (pCsr->bDesc ? \"DESC\" : \"ASC\")\n      );\n    }\n    if( zSql ){\n      rc = sqlite3_prepare_v3(p->db,zSql,-1,SQLITE_PREPARE_PERSISTENT,&pCsr->pStmt,0);\n      sqlite3_free(zSql);\n    }else{\n      rc = SQLITE_NOMEM;\n    }\n  }else if( eSearch==FTS3_DOCID_SEARCH ){\n    rc = fts3CursorSeekStmt(pCsr);\n    if( rc==SQLITE_OK ){\n      rc = sqlite3_bind_value(pCsr->pStmt, 1, pCons);\n    }\n  }\n  if( rc!=SQLITE_OK ) return rc;\n\n  return fts3NextMethod(pCursor);\n}\n\n/* \n** This is the xEof method of the virtual table. SQLite calls this \n** routine to find out if it has reached the end of a result set.\n*/\nstatic int fts3EofMethod(sqlite3_vtab_cursor *pCursor){\n  Fts3Cursor *pCsr = (Fts3Cursor*)pCursor;\n  if( pCsr->isEof ){\n    fts3ClearCursor(pCsr);\n    pCsr->isEof = 1;\n  }\n  return pCsr->isEof;\n}\n\n/* \n** This is the xRowid method. The SQLite core calls this routine to\n** retrieve the rowid for the current row of the result set. fts3\n** exposes %_content.docid as the rowid for the virtual table. The\n** rowid should be written to *pRowid.\n*/\nstatic int fts3RowidMethod(sqlite3_vtab_cursor *pCursor, sqlite_int64 *pRowid){\n  Fts3Cursor *pCsr = (Fts3Cursor *) pCursor;\n  *pRowid = pCsr->iPrevId;\n  return SQLITE_OK;\n}\n\n/* \n** This is the xColumn method, called by SQLite to request a value from\n** the row that the supplied cursor currently points to.\n**\n** If:\n**\n**   (iCol <  p->nColumn)   -> The value of the iCol'th user column.\n**   (iCol == p->nColumn)   -> Magic column with the same name as the table.\n**   (iCol == p->nColumn+1) -> Docid column\n**   (iCol == p->nColumn+2) -> Langid column\n*/\nstatic int fts3ColumnMethod(\n  sqlite3_vtab_cursor *pCursor,   /* Cursor to retrieve value from */\n  sqlite3_context *pCtx,          /* Context for sqlite3_result_xxx() calls */\n  int iCol                        /* Index of column to read value from */\n){\n  int rc = SQLITE_OK;             /* Return Code */\n  Fts3Cursor *pCsr = (Fts3Cursor *) pCursor;\n  Fts3Table *p = (Fts3Table *)pCursor->pVtab;\n\n  /* The column value supplied by SQLite must be in range. */\n  assert( iCol>=0 && iCol<=p->nColumn+2 );\n\n  switch( iCol-p->nColumn ){\n    case 0:\n      /* The special 'table-name' column */\n      sqlite3_result_pointer(pCtx, pCsr, \"fts3cursor\", 0);\n      break;\n\n    case 1:\n      /* The docid column */\n      sqlite3_result_int64(pCtx, pCsr->iPrevId);\n      break;\n\n    case 2:\n      if( pCsr->pExpr ){\n        sqlite3_result_int64(pCtx, pCsr->iLangid);\n        break;\n      }else if( p->zLanguageid==0 ){\n        sqlite3_result_int(pCtx, 0);\n        break;\n      }else{\n        iCol = p->nColumn;\n        /* fall-through */\n      }\n\n    default:\n      /* A user column. Or, if this is a full-table scan, possibly the\n      ** language-id column. Seek the cursor. */\n      rc = fts3CursorSeek(0, pCsr);\n      if( rc==SQLITE_OK && sqlite3_data_count(pCsr->pStmt)-1>iCol ){\n        sqlite3_result_value(pCtx, sqlite3_column_value(pCsr->pStmt, iCol+1));\n      }\n      break;\n  }\n\n  assert( ((Fts3Table *)pCsr->base.pVtab)->pSegments==0 );\n  return rc;\n}\n\n/* \n** This function is the implementation of the xUpdate callback used by \n** FTS3 virtual tables. It is invoked by SQLite each time a row is to be\n** inserted, updated or deleted.\n*/\nstatic int fts3UpdateMethod(\n  sqlite3_vtab *pVtab,            /* Virtual table handle */\n  int nArg,                       /* Size of argument array */\n  sqlite3_value **apVal,          /* Array of arguments */\n  sqlite_int64 *pRowid            /* OUT: The affected (or effected) rowid */\n){\n  return sqlite3Fts3UpdateMethod(pVtab, nArg, apVal, pRowid);\n}\n\n/*\n** Implementation of xSync() method. Flush the contents of the pending-terms\n** hash-table to the database.\n*/\nstatic int fts3SyncMethod(sqlite3_vtab *pVtab){\n\n  /* Following an incremental-merge operation, assuming that the input\n  ** segments are not completely consumed (the usual case), they are updated\n  ** in place to remove the entries that have already been merged. This\n  ** involves updating the leaf block that contains the smallest unmerged\n  ** entry and each block (if any) between the leaf and the root node. So\n  ** if the height of the input segment b-trees is N, and input segments\n  ** are merged eight at a time, updating the input segments at the end\n  ** of an incremental-merge requires writing (8*(1+N)) blocks. N is usually\n  ** small - often between 0 and 2. So the overhead of the incremental\n  ** merge is somewhere between 8 and 24 blocks. To avoid this overhead\n  ** dwarfing the actual productive work accomplished, the incremental merge\n  ** is only attempted if it will write at least 64 leaf blocks. Hence\n  ** nMinMerge.\n  **\n  ** Of course, updating the input segments also involves deleting a bunch\n  ** of blocks from the segments table. But this is not considered overhead\n  ** as it would also be required by a crisis-merge that used the same input \n  ** segments.\n  */\n  const u32 nMinMerge = 64;       /* Minimum amount of incr-merge work to do */\n\n  Fts3Table *p = (Fts3Table*)pVtab;\n  int rc;\n  i64 iLastRowid = sqlite3_last_insert_rowid(p->db);\n\n  rc = sqlite3Fts3PendingTermsFlush(p);\n  if( rc==SQLITE_OK \n   && p->nLeafAdd>(nMinMerge/16) \n   && p->nAutoincrmerge && p->nAutoincrmerge!=0xff\n  ){\n    int mxLevel = 0;              /* Maximum relative level value in db */\n    int A;                        /* Incr-merge parameter A */\n\n    rc = sqlite3Fts3MaxLevel(p, &mxLevel);\n    assert( rc==SQLITE_OK || mxLevel==0 );\n    A = p->nLeafAdd * mxLevel;\n    A += (A/2);\n    if( A>(int)nMinMerge ) rc = sqlite3Fts3Incrmerge(p, A, p->nAutoincrmerge);\n  }\n  sqlite3Fts3SegmentsClose(p);\n  sqlite3_set_last_insert_rowid(p->db, iLastRowid);\n  return rc;\n}\n\n/*\n** If it is currently unknown whether or not the FTS table has an %_stat\n** table (if p->bHasStat==2), attempt to determine this (set p->bHasStat\n** to 0 or 1). Return SQLITE_OK if successful, or an SQLite error code\n** if an error occurs.\n*/\nstatic int fts3SetHasStat(Fts3Table *p){\n  int rc = SQLITE_OK;\n  if( p->bHasStat==2 ){\n    char *zTbl = sqlite3_mprintf(\"%s_stat\", p->zName);\n    if( zTbl ){\n      int res = sqlite3_table_column_metadata(p->db, p->zDb, zTbl, 0,0,0,0,0,0);\n      sqlite3_free(zTbl);\n      p->bHasStat = (res==SQLITE_OK);\n    }else{\n      rc = SQLITE_NOMEM;\n    }\n  }\n  return rc;\n}\n\n/*\n** Implementation of xBegin() method. \n*/\nstatic int fts3BeginMethod(sqlite3_vtab *pVtab){\n  Fts3Table *p = (Fts3Table*)pVtab;\n  UNUSED_PARAMETER(pVtab);\n  assert( p->pSegments==0 );\n  assert( p->nPendingData==0 );\n  assert( p->inTransaction!=1 );\n  TESTONLY( p->inTransaction = 1 );\n  TESTONLY( p->mxSavepoint = -1; );\n  p->nLeafAdd = 0;\n  return fts3SetHasStat(p);\n}\n\n/*\n** Implementation of xCommit() method. This is a no-op. The contents of\n** the pending-terms hash-table have already been flushed into the database\n** by fts3SyncMethod().\n*/\nstatic int fts3CommitMethod(sqlite3_vtab *pVtab){\n  TESTONLY( Fts3Table *p = (Fts3Table*)pVtab );\n  UNUSED_PARAMETER(pVtab);\n  assert( p->nPendingData==0 );\n  assert( p->inTransaction!=0 );\n  assert( p->pSegments==0 );\n  TESTONLY( p->inTransaction = 0 );\n  TESTONLY( p->mxSavepoint = -1; );\n  return SQLITE_OK;\n}\n\n/*\n** Implementation of xRollback(). Discard the contents of the pending-terms\n** hash-table. Any changes made to the database are reverted by SQLite.\n*/\nstatic int fts3RollbackMethod(sqlite3_vtab *pVtab){\n  Fts3Table *p = (Fts3Table*)pVtab;\n  sqlite3Fts3PendingTermsClear(p);\n  assert( p->inTransaction!=0 );\n  TESTONLY( p->inTransaction = 0 );\n  TESTONLY( p->mxSavepoint = -1; );\n  return SQLITE_OK;\n}\n\n/*\n** When called, *ppPoslist must point to the byte immediately following the\n** end of a position-list. i.e. ( (*ppPoslist)[-1]==POS_END ). This function\n** moves *ppPoslist so that it instead points to the first byte of the\n** same position list.\n*/\nstatic void fts3ReversePoslist(char *pStart, char **ppPoslist){\n  char *p = &(*ppPoslist)[-2];\n  char c = 0;\n\n  /* Skip backwards passed any trailing 0x00 bytes added by NearTrim() */\n  while( p>pStart && (c=*p--)==0 );\n\n  /* Search backwards for a varint with value zero (the end of the previous \n  ** poslist). This is an 0x00 byte preceded by some byte that does not\n  ** have the 0x80 bit set.  */\n  while( p>pStart && (*p & 0x80) | c ){ \n    c = *p--; \n  }\n  assert( p==pStart || c==0 );\n\n  /* At this point p points to that preceding byte without the 0x80 bit\n  ** set. So to find the start of the poslist, skip forward 2 bytes then\n  ** over a varint. \n  **\n  ** Normally. The other case is that p==pStart and the poslist to return\n  ** is the first in the doclist. In this case do not skip forward 2 bytes.\n  ** The second part of the if condition (c==0 && *ppPoslist>&p[2])\n  ** is required for cases where the first byte of a doclist and the\n  ** doclist is empty. For example, if the first docid is 10, a doclist\n  ** that begins with:\n  **\n  **   0x0A 0x00 <next docid delta varint>\n  */\n  if( p>pStart || (c==0 && *ppPoslist>&p[2]) ){ p = &p[2]; }\n  while( *p++&0x80 );\n  *ppPoslist = p;\n}\n\n/*\n** Helper function used by the implementation of the overloaded snippet(),\n** offsets() and optimize() SQL functions.\n**\n** If the value passed as the third argument is a blob of size\n** sizeof(Fts3Cursor*), then the blob contents are copied to the \n** output variable *ppCsr and SQLITE_OK is returned. Otherwise, an error\n** message is written to context pContext and SQLITE_ERROR returned. The\n** string passed via zFunc is used as part of the error message.\n*/\nstatic int fts3FunctionArg(\n  sqlite3_context *pContext,      /* SQL function call context */\n  const char *zFunc,              /* Function name */\n  sqlite3_value *pVal,            /* argv[0] passed to function */\n  Fts3Cursor **ppCsr              /* OUT: Store cursor handle here */\n){\n  int rc;\n  *ppCsr = (Fts3Cursor*)sqlite3_value_pointer(pVal, \"fts3cursor\");\n  if( (*ppCsr)!=0 ){\n    rc = SQLITE_OK;\n  }else{\n    char *zErr = sqlite3_mprintf(\"illegal first argument to %s\", zFunc);\n    sqlite3_result_error(pContext, zErr, -1);\n    sqlite3_free(zErr);\n    rc = SQLITE_ERROR;\n  }\n  return rc;\n}\n\n/*\n** Implementation of the snippet() function for FTS3\n*/\nstatic void fts3SnippetFunc(\n  sqlite3_context *pContext,      /* SQLite function call context */\n  int nVal,                       /* Size of apVal[] array */\n  sqlite3_value **apVal           /* Array of arguments */\n){\n  Fts3Cursor *pCsr;               /* Cursor handle passed through apVal[0] */\n  const char *zStart = \"<b>\";\n  const char *zEnd = \"</b>\";\n  const char *zEllipsis = \"<b>...</b>\";\n  int iCol = -1;\n  int nToken = 15;                /* Default number of tokens in snippet */\n\n  /* There must be at least one argument passed to this function (otherwise\n  ** the non-overloaded version would have been called instead of this one).\n  */\n  assert( nVal>=1 );\n\n  if( nVal>6 ){\n    sqlite3_result_error(pContext, \n        \"wrong number of arguments to function snippet()\", -1);\n    return;\n  }\n  if( fts3FunctionArg(pContext, \"snippet\", apVal[0], &pCsr) ) return;\n\n  switch( nVal ){\n    case 6: nToken = sqlite3_value_int(apVal[5]);\n    case 5: iCol = sqlite3_value_int(apVal[4]);\n    case 4: zEllipsis = (const char*)sqlite3_value_text(apVal[3]);\n    case 3: zEnd = (const char*)sqlite3_value_text(apVal[2]);\n    case 2: zStart = (const char*)sqlite3_value_text(apVal[1]);\n  }\n  if( !zEllipsis || !zEnd || !zStart ){\n    sqlite3_result_error_nomem(pContext);\n  }else if( nToken==0 ){\n    sqlite3_result_text(pContext, \"\", -1, SQLITE_STATIC);\n  }else if( SQLITE_OK==fts3CursorSeek(pContext, pCsr) ){\n    sqlite3Fts3Snippet(pContext, pCsr, zStart, zEnd, zEllipsis, iCol, nToken);\n  }\n}\n\n/*\n** Implementation of the offsets() function for FTS3\n*/\nstatic void fts3OffsetsFunc(\n  sqlite3_context *pContext,      /* SQLite function call context */\n  int nVal,                       /* Size of argument array */\n  sqlite3_value **apVal           /* Array of arguments */\n){\n  Fts3Cursor *pCsr;               /* Cursor handle passed through apVal[0] */\n\n  UNUSED_PARAMETER(nVal);\n\n  assert( nVal==1 );\n  if( fts3FunctionArg(pContext, \"offsets\", apVal[0], &pCsr) ) return;\n  assert( pCsr );\n  if( SQLITE_OK==fts3CursorSeek(pContext, pCsr) ){\n    sqlite3Fts3Offsets(pContext, pCsr);\n  }\n}\n\n/* \n** Implementation of the special optimize() function for FTS3. This \n** function merges all segments in the database to a single segment.\n** Example usage is:\n**\n**   SELECT optimize(t) FROM t LIMIT 1;\n**\n** where 't' is the name of an FTS3 table.\n*/\nstatic void fts3OptimizeFunc(\n  sqlite3_context *pContext,      /* SQLite function call context */\n  int nVal,                       /* Size of argument array */\n  sqlite3_value **apVal           /* Array of arguments */\n){\n  int rc;                         /* Return code */\n  Fts3Table *p;                   /* Virtual table handle */\n  Fts3Cursor *pCursor;            /* Cursor handle passed through apVal[0] */\n\n  UNUSED_PARAMETER(nVal);\n\n  assert( nVal==1 );\n  if( fts3FunctionArg(pContext, \"optimize\", apVal[0], &pCursor) ) return;\n  p = (Fts3Table *)pCursor->base.pVtab;\n  assert( p );\n\n  rc = sqlite3Fts3Optimize(p);\n\n  switch( rc ){\n    case SQLITE_OK:\n      sqlite3_result_text(pContext, \"Index optimized\", -1, SQLITE_STATIC);\n      break;\n    case SQLITE_DONE:\n      sqlite3_result_text(pContext, \"Index already optimal\", -1, SQLITE_STATIC);\n      break;\n    default:\n      sqlite3_result_error_code(pContext, rc);\n      break;\n  }\n}\n\n/*\n** Implementation of the matchinfo() function for FTS3\n*/\nstatic void fts3MatchinfoFunc(\n  sqlite3_context *pContext,      /* SQLite function call context */\n  int nVal,                       /* Size of argument array */\n  sqlite3_value **apVal           /* Array of arguments */\n){\n  Fts3Cursor *pCsr;               /* Cursor handle passed through apVal[0] */\n  assert( nVal==1 || nVal==2 );\n  if( SQLITE_OK==fts3FunctionArg(pContext, \"matchinfo\", apVal[0], &pCsr) ){\n    const char *zArg = 0;\n    if( nVal>1 ){\n      zArg = (const char *)sqlite3_value_text(apVal[1]);\n    }\n    sqlite3Fts3Matchinfo(pContext, pCsr, zArg);\n  }\n}\n\n/*\n** This routine implements the xFindFunction method for the FTS3\n** virtual table.\n*/\nstatic int fts3FindFunctionMethod(\n  sqlite3_vtab *pVtab,            /* Virtual table handle */\n  int nArg,                       /* Number of SQL function arguments */\n  const char *zName,              /* Name of SQL function */\n  void (**pxFunc)(sqlite3_context*,int,sqlite3_value**), /* OUT: Result */\n  void **ppArg                    /* Unused */\n){\n  struct Overloaded {\n    const char *zName;\n    void (*xFunc)(sqlite3_context*,int,sqlite3_value**);\n  } aOverload[] = {\n    { \"snippet\", fts3SnippetFunc },\n    { \"offsets\", fts3OffsetsFunc },\n    { \"optimize\", fts3OptimizeFunc },\n    { \"matchinfo\", fts3MatchinfoFunc },\n  };\n  int i;                          /* Iterator variable */\n\n  UNUSED_PARAMETER(pVtab);\n  UNUSED_PARAMETER(nArg);\n  UNUSED_PARAMETER(ppArg);\n\n  for(i=0; i<SizeofArray(aOverload); i++){\n    if( strcmp(zName, aOverload[i].zName)==0 ){\n      *pxFunc = aOverload[i].xFunc;\n      return 1;\n    }\n  }\n\n  /* No function of the specified name was found. Return 0. */\n  return 0;\n}\n\n/*\n** Implementation of FTS3 xRename method. Rename an fts3 table.\n*/\nstatic int fts3RenameMethod(\n  sqlite3_vtab *pVtab,            /* Virtual table handle */\n  const char *zName               /* New name of table */\n){\n  Fts3Table *p = (Fts3Table *)pVtab;\n  sqlite3 *db = p->db;            /* Database connection */\n  int rc;                         /* Return Code */\n\n  /* At this point it must be known if the %_stat table exists or not.\n  ** So bHasStat may not be 2.  */\n  rc = fts3SetHasStat(p);\n  \n  /* As it happens, the pending terms table is always empty here. This is\n  ** because an \"ALTER TABLE RENAME TABLE\" statement inside a transaction \n  ** always opens a savepoint transaction. And the xSavepoint() method \n  ** flushes the pending terms table. But leave the (no-op) call to\n  ** PendingTermsFlush() in in case that changes.\n  */\n  assert( p->nPendingData==0 );\n  if( rc==SQLITE_OK ){\n    rc = sqlite3Fts3PendingTermsFlush(p);\n  }\n\n  if( p->zContentTbl==0 ){\n    fts3DbExec(&rc, db,\n      \"ALTER TABLE %Q.'%q_content'  RENAME TO '%q_content';\",\n      p->zDb, p->zName, zName\n    );\n  }\n\n  if( p->bHasDocsize ){\n    fts3DbExec(&rc, db,\n      \"ALTER TABLE %Q.'%q_docsize'  RENAME TO '%q_docsize';\",\n      p->zDb, p->zName, zName\n    );\n  }\n  if( p->bHasStat ){\n    fts3DbExec(&rc, db,\n      \"ALTER TABLE %Q.'%q_stat'  RENAME TO '%q_stat';\",\n      p->zDb, p->zName, zName\n    );\n  }\n  fts3DbExec(&rc, db,\n    \"ALTER TABLE %Q.'%q_segments' RENAME TO '%q_segments';\",\n    p->zDb, p->zName, zName\n  );\n  fts3DbExec(&rc, db,\n    \"ALTER TABLE %Q.'%q_segdir'   RENAME TO '%q_segdir';\",\n    p->zDb, p->zName, zName\n  );\n  return rc;\n}\n\n/*\n** The xSavepoint() method.\n**\n** Flush the contents of the pending-terms table to disk.\n*/\nstatic int fts3SavepointMethod(sqlite3_vtab *pVtab, int iSavepoint){\n  int rc = SQLITE_OK;\n  UNUSED_PARAMETER(iSavepoint);\n  assert( ((Fts3Table *)pVtab)->inTransaction );\n  assert( ((Fts3Table *)pVtab)->mxSavepoint <= iSavepoint );\n  TESTONLY( ((Fts3Table *)pVtab)->mxSavepoint = iSavepoint );\n  if( ((Fts3Table *)pVtab)->bIgnoreSavepoint==0 ){\n    rc = fts3SyncMethod(pVtab);\n  }\n  return rc;\n}\n\n/*\n** The xRelease() method.\n**\n** This is a no-op.\n*/\nstatic int fts3ReleaseMethod(sqlite3_vtab *pVtab, int iSavepoint){\n  TESTONLY( Fts3Table *p = (Fts3Table*)pVtab );\n  UNUSED_PARAMETER(iSavepoint);\n  UNUSED_PARAMETER(pVtab);\n  assert( p->inTransaction );\n  assert( p->mxSavepoint >= iSavepoint );\n  TESTONLY( p->mxSavepoint = iSavepoint-1 );\n  return SQLITE_OK;\n}\n\n/*\n** The xRollbackTo() method.\n**\n** Discard the contents of the pending terms table.\n*/\nstatic int fts3RollbackToMethod(sqlite3_vtab *pVtab, int iSavepoint){\n  Fts3Table *p = (Fts3Table*)pVtab;\n  UNUSED_PARAMETER(iSavepoint);\n  assert( p->inTransaction );\n  TESTONLY( p->mxSavepoint = iSavepoint );\n  sqlite3Fts3PendingTermsClear(p);\n  return SQLITE_OK;\n}\n\n/*\n** Return true if zName is the extension on one of the shadow tables used\n** by this module.\n*/\nstatic int fts3ShadowName(const char *zName){\n  static const char *azName[] = {\n    \"content\", \"docsize\", \"segdir\", \"segments\", \"stat\", \n  };\n  unsigned int i;\n  for(i=0; i<sizeof(azName)/sizeof(azName[0]); i++){\n    if( sqlite3_stricmp(zName, azName[i])==0 ) return 1;\n  }\n  return 0;\n}\n\nstatic const sqlite3_module fts3Module = {\n  /* iVersion      */ 3,\n  /* xCreate       */ fts3CreateMethod,\n  /* xConnect      */ fts3ConnectMethod,\n  /* xBestIndex    */ fts3BestIndexMethod,\n  /* xDisconnect   */ fts3DisconnectMethod,\n  /* xDestroy      */ fts3DestroyMethod,\n  /* xOpen         */ fts3OpenMethod,\n  /* xClose        */ fts3CloseMethod,\n  /* xFilter       */ fts3FilterMethod,\n  /* xNext         */ fts3NextMethod,\n  /* xEof          */ fts3EofMethod,\n  /* xColumn       */ fts3ColumnMethod,\n  /* xRowid        */ fts3RowidMethod,\n  /* xUpdate       */ fts3UpdateMethod,\n  /* xBegin        */ fts3BeginMethod,\n  /* xSync         */ fts3SyncMethod,\n  /* xCommit       */ fts3CommitMethod,\n  /* xRollback     */ fts3RollbackMethod,\n  /* xFindFunction */ fts3FindFunctionMethod,\n  /* xRename */       fts3RenameMethod,\n  /* xSavepoint    */ fts3SavepointMethod,\n  /* xRelease      */ fts3ReleaseMethod,\n  /* xRollbackTo   */ fts3RollbackToMethod,\n  /* xShadowName   */ fts3ShadowName,\n};\n\n/*\n** This function is registered as the module destructor (called when an\n** FTS3 enabled database connection is closed). It frees the memory\n** allocated for the tokenizer hash table.\n*/\nstatic void hashDestroy(void *p){\n  Fts3Hash *pHash = (Fts3Hash *)p;\n  sqlite3Fts3HashClear(pHash);\n  sqlite3_free(pHash);\n}\n\n/*\n** The fts3 built-in tokenizers - \"simple\", \"porter\" and \"icu\"- are \n** implemented in files fts3_tokenizer1.c, fts3_porter.c and fts3_icu.c\n** respectively. The following three forward declarations are for functions\n** declared in these files used to retrieve the respective implementations.\n**\n** Calling sqlite3Fts3SimpleTokenizerModule() sets the value pointed\n** to by the argument to point to the \"simple\" tokenizer implementation.\n** And so on.\n*/\nSQLITE_PRIVATE void sqlite3Fts3SimpleTokenizerModule(sqlite3_tokenizer_module const**ppModule);\nSQLITE_PRIVATE void sqlite3Fts3PorterTokenizerModule(sqlite3_tokenizer_module const**ppModule);\n#ifndef SQLITE_DISABLE_FTS3_UNICODE\nSQLITE_PRIVATE void sqlite3Fts3UnicodeTokenizer(sqlite3_tokenizer_module const**ppModule);\n#endif\n#ifdef SQLITE_ENABLE_ICU\nSQLITE_PRIVATE void sqlite3Fts3IcuTokenizerModule(sqlite3_tokenizer_module const**ppModule);\n#endif\n\n/*\n** Initialize the fts3 extension. If this extension is built as part\n** of the sqlite library, then this function is called directly by\n** SQLite. If fts3 is built as a dynamically loadable extension, this\n** function is called by the sqlite3_extension_init() entry point.\n*/\nSQLITE_PRIVATE int sqlite3Fts3Init(sqlite3 *db){\n  int rc = SQLITE_OK;\n  Fts3Hash *pHash = 0;\n  const sqlite3_tokenizer_module *pSimple = 0;\n  const sqlite3_tokenizer_module *pPorter = 0;\n#ifndef SQLITE_DISABLE_FTS3_UNICODE\n  const sqlite3_tokenizer_module *pUnicode = 0;\n#endif\n\n#ifdef SQLITE_ENABLE_ICU\n  const sqlite3_tokenizer_module *pIcu = 0;\n  sqlite3Fts3IcuTokenizerModule(&pIcu);\n#endif\n\n#ifndef SQLITE_DISABLE_FTS3_UNICODE\n  sqlite3Fts3UnicodeTokenizer(&pUnicode);\n#endif\n\n#ifdef SQLITE_TEST\n  rc = sqlite3Fts3InitTerm(db);\n  if( rc!=SQLITE_OK ) return rc;\n#endif\n\n  rc = sqlite3Fts3InitAux(db);\n  if( rc!=SQLITE_OK ) return rc;\n\n  sqlite3Fts3SimpleTokenizerModule(&pSimple);\n  sqlite3Fts3PorterTokenizerModule(&pPorter);\n\n  /* Allocate and initialize the hash-table used to store tokenizers. */\n  pHash = sqlite3_malloc(sizeof(Fts3Hash));\n  if( !pHash ){\n    rc = SQLITE_NOMEM;\n  }else{\n    sqlite3Fts3HashInit(pHash, FTS3_HASH_STRING, 1);\n  }\n\n  /* Load the built-in tokenizers into the hash table */\n  if( rc==SQLITE_OK ){\n    if( sqlite3Fts3HashInsert(pHash, \"simple\", 7, (void *)pSimple)\n     || sqlite3Fts3HashInsert(pHash, \"porter\", 7, (void *)pPorter) \n\n#ifndef SQLITE_DISABLE_FTS3_UNICODE\n     || sqlite3Fts3HashInsert(pHash, \"unicode61\", 10, (void *)pUnicode) \n#endif\n#ifdef SQLITE_ENABLE_ICU\n     || (pIcu && sqlite3Fts3HashInsert(pHash, \"icu\", 4, (void *)pIcu))\n#endif\n    ){\n      rc = SQLITE_NOMEM;\n    }\n  }\n\n#ifdef SQLITE_TEST\n  if( rc==SQLITE_OK ){\n    rc = sqlite3Fts3ExprInitTestInterface(db, pHash);\n  }\n#endif\n\n  /* Create the virtual table wrapper around the hash-table and overload \n  ** the four scalar functions. If this is successful, register the\n  ** module with sqlite.\n  */\n  if( SQLITE_OK==rc \n   && SQLITE_OK==(rc = sqlite3Fts3InitHashTable(db, pHash, \"fts3_tokenizer\"))\n   && SQLITE_OK==(rc = sqlite3_overload_function(db, \"snippet\", -1))\n   && SQLITE_OK==(rc = sqlite3_overload_function(db, \"offsets\", 1))\n   && SQLITE_OK==(rc = sqlite3_overload_function(db, \"matchinfo\", 1))\n   && SQLITE_OK==(rc = sqlite3_overload_function(db, \"matchinfo\", 2))\n   && SQLITE_OK==(rc = sqlite3_overload_function(db, \"optimize\", 1))\n  ){\n    rc = sqlite3_create_module_v2(\n        db, \"fts3\", &fts3Module, (void *)pHash, hashDestroy\n    );\n    if( rc==SQLITE_OK ){\n      rc = sqlite3_create_module_v2(\n          db, \"fts4\", &fts3Module, (void *)pHash, 0\n      );\n    }\n    if( rc==SQLITE_OK ){\n      rc = sqlite3Fts3InitTok(db, (void *)pHash);\n    }\n    return rc;\n  }\n\n\n  /* An error has occurred. Delete the hash table and return the error code. */\n  assert( rc!=SQLITE_OK );\n  if( pHash ){\n    sqlite3Fts3HashClear(pHash);\n    sqlite3_free(pHash);\n  }\n  return rc;\n}\n\n/*\n** Allocate an Fts3MultiSegReader for each token in the expression headed\n** by pExpr. \n**\n** An Fts3SegReader object is a cursor that can seek or scan a range of\n** entries within a single segment b-tree. An Fts3MultiSegReader uses multiple\n** Fts3SegReader objects internally to provide an interface to seek or scan\n** within the union of all segments of a b-tree. Hence the name.\n**\n** If the allocated Fts3MultiSegReader just seeks to a single entry in a\n** segment b-tree (if the term is not a prefix or it is a prefix for which\n** there exists prefix b-tree of the right length) then it may be traversed\n** and merged incrementally. Otherwise, it has to be merged into an in-memory \n** doclist and then traversed.\n*/\nstatic void fts3EvalAllocateReaders(\n  Fts3Cursor *pCsr,               /* FTS cursor handle */\n  Fts3Expr *pExpr,                /* Allocate readers for this expression */\n  int *pnToken,                   /* OUT: Total number of tokens in phrase. */\n  int *pnOr,                      /* OUT: Total number of OR nodes in expr. */\n  int *pRc                        /* IN/OUT: Error code */\n){\n  if( pExpr && SQLITE_OK==*pRc ){\n    if( pExpr->eType==FTSQUERY_PHRASE ){\n      int i;\n      int nToken = pExpr->pPhrase->nToken;\n      *pnToken += nToken;\n      for(i=0; i<nToken; i++){\n        Fts3PhraseToken *pToken = &pExpr->pPhrase->aToken[i];\n        int rc = fts3TermSegReaderCursor(pCsr, \n            pToken->z, pToken->n, pToken->isPrefix, &pToken->pSegcsr\n        );\n        if( rc!=SQLITE_OK ){\n          *pRc = rc;\n          return;\n        }\n      }\n      assert( pExpr->pPhrase->iDoclistToken==0 );\n      pExpr->pPhrase->iDoclistToken = -1;\n    }else{\n      *pnOr += (pExpr->eType==FTSQUERY_OR);\n      fts3EvalAllocateReaders(pCsr, pExpr->pLeft, pnToken, pnOr, pRc);\n      fts3EvalAllocateReaders(pCsr, pExpr->pRight, pnToken, pnOr, pRc);\n    }\n  }\n}\n\n/*\n** Arguments pList/nList contain the doclist for token iToken of phrase p.\n** It is merged into the main doclist stored in p->doclist.aAll/nAll.\n**\n** This function assumes that pList points to a buffer allocated using\n** sqlite3_malloc(). This function takes responsibility for eventually\n** freeing the buffer.\n**\n** SQLITE_OK is returned if successful, or SQLITE_NOMEM if an error occurs.\n*/\nstatic int fts3EvalPhraseMergeToken(\n  Fts3Table *pTab,                /* FTS Table pointer */\n  Fts3Phrase *p,                  /* Phrase to merge pList/nList into */\n  int iToken,                     /* Token pList/nList corresponds to */\n  char *pList,                    /* Pointer to doclist */\n  int nList                       /* Number of bytes in pList */\n){\n  int rc = SQLITE_OK;\n  assert( iToken!=p->iDoclistToken );\n\n  if( pList==0 ){\n    sqlite3_free(p->doclist.aAll);\n    p->doclist.aAll = 0;\n    p->doclist.nAll = 0;\n  }\n\n  else if( p->iDoclistToken<0 ){\n    p->doclist.aAll = pList;\n    p->doclist.nAll = nList;\n  }\n\n  else if( p->doclist.aAll==0 ){\n    sqlite3_free(pList);\n  }\n\n  else {\n    char *pLeft;\n    char *pRight;\n    int nLeft;\n    int nRight;\n    int nDiff;\n\n    if( p->iDoclistToken<iToken ){\n      pLeft = p->doclist.aAll;\n      nLeft = p->doclist.nAll;\n      pRight = pList;\n      nRight = nList;\n      nDiff = iToken - p->iDoclistToken;\n    }else{\n      pRight = p->doclist.aAll;\n      nRight = p->doclist.nAll;\n      pLeft = pList;\n      nLeft = nList;\n      nDiff = p->iDoclistToken - iToken;\n    }\n\n    rc = fts3DoclistPhraseMerge(\n        pTab->bDescIdx, nDiff, pLeft, nLeft, &pRight, &nRight\n    );\n    sqlite3_free(pLeft);\n    p->doclist.aAll = pRight;\n    p->doclist.nAll = nRight;\n  }\n\n  if( iToken>p->iDoclistToken ) p->iDoclistToken = iToken;\n  return rc;\n}\n\n/*\n** Load the doclist for phrase p into p->doclist.aAll/nAll. The loaded doclist\n** does not take deferred tokens into account.\n**\n** SQLITE_OK is returned if no error occurs, otherwise an SQLite error code.\n*/\nstatic int fts3EvalPhraseLoad(\n  Fts3Cursor *pCsr,               /* FTS Cursor handle */\n  Fts3Phrase *p                   /* Phrase object */\n){\n  Fts3Table *pTab = (Fts3Table *)pCsr->base.pVtab;\n  int iToken;\n  int rc = SQLITE_OK;\n\n  for(iToken=0; rc==SQLITE_OK && iToken<p->nToken; iToken++){\n    Fts3PhraseToken *pToken = &p->aToken[iToken];\n    assert( pToken->pDeferred==0 || pToken->pSegcsr==0 );\n\n    if( pToken->pSegcsr ){\n      int nThis = 0;\n      char *pThis = 0;\n      rc = fts3TermSelect(pTab, pToken, p->iColumn, &nThis, &pThis);\n      if( rc==SQLITE_OK ){\n        rc = fts3EvalPhraseMergeToken(pTab, p, iToken, pThis, nThis);\n      }\n    }\n    assert( pToken->pSegcsr==0 );\n  }\n\n  return rc;\n}\n\n#ifndef SQLITE_DISABLE_FTS4_DEFERRED\n/*\n** This function is called on each phrase after the position lists for\n** any deferred tokens have been loaded into memory. It updates the phrases\n** current position list to include only those positions that are really\n** instances of the phrase (after considering deferred tokens). If this\n** means that the phrase does not appear in the current row, doclist.pList\n** and doclist.nList are both zeroed.\n**\n** SQLITE_OK is returned if no error occurs, otherwise an SQLite error code.\n*/\nstatic int fts3EvalDeferredPhrase(Fts3Cursor *pCsr, Fts3Phrase *pPhrase){\n  int iToken;                     /* Used to iterate through phrase tokens */\n  char *aPoslist = 0;             /* Position list for deferred tokens */\n  int nPoslist = 0;               /* Number of bytes in aPoslist */\n  int iPrev = -1;                 /* Token number of previous deferred token */\n\n  assert( pPhrase->doclist.bFreeList==0 );\n\n  for(iToken=0; iToken<pPhrase->nToken; iToken++){\n    Fts3PhraseToken *pToken = &pPhrase->aToken[iToken];\n    Fts3DeferredToken *pDeferred = pToken->pDeferred;\n\n    if( pDeferred ){\n      char *pList;\n      int nList;\n      int rc = sqlite3Fts3DeferredTokenList(pDeferred, &pList, &nList);\n      if( rc!=SQLITE_OK ) return rc;\n\n      if( pList==0 ){\n        sqlite3_free(aPoslist);\n        pPhrase->doclist.pList = 0;\n        pPhrase->doclist.nList = 0;\n        return SQLITE_OK;\n\n      }else if( aPoslist==0 ){\n        aPoslist = pList;\n        nPoslist = nList;\n\n      }else{\n        char *aOut = pList;\n        char *p1 = aPoslist;\n        char *p2 = aOut;\n\n        assert( iPrev>=0 );\n        fts3PoslistPhraseMerge(&aOut, iToken-iPrev, 0, 1, &p1, &p2);\n        sqlite3_free(aPoslist);\n        aPoslist = pList;\n        nPoslist = (int)(aOut - aPoslist);\n        if( nPoslist==0 ){\n          sqlite3_free(aPoslist);\n          pPhrase->doclist.pList = 0;\n          pPhrase->doclist.nList = 0;\n          return SQLITE_OK;\n        }\n      }\n      iPrev = iToken;\n    }\n  }\n\n  if( iPrev>=0 ){\n    int nMaxUndeferred = pPhrase->iDoclistToken;\n    if( nMaxUndeferred<0 ){\n      pPhrase->doclist.pList = aPoslist;\n      pPhrase->doclist.nList = nPoslist;\n      pPhrase->doclist.iDocid = pCsr->iPrevId;\n      pPhrase->doclist.bFreeList = 1;\n    }else{\n      int nDistance;\n      char *p1;\n      char *p2;\n      char *aOut;\n\n      if( nMaxUndeferred>iPrev ){\n        p1 = aPoslist;\n        p2 = pPhrase->doclist.pList;\n        nDistance = nMaxUndeferred - iPrev;\n      }else{\n        p1 = pPhrase->doclist.pList;\n        p2 = aPoslist;\n        nDistance = iPrev - nMaxUndeferred;\n      }\n\n      aOut = (char *)sqlite3_malloc(nPoslist+8);\n      if( !aOut ){\n        sqlite3_free(aPoslist);\n        return SQLITE_NOMEM;\n      }\n      \n      pPhrase->doclist.pList = aOut;\n      if( fts3PoslistPhraseMerge(&aOut, nDistance, 0, 1, &p1, &p2) ){\n        pPhrase->doclist.bFreeList = 1;\n        pPhrase->doclist.nList = (int)(aOut - pPhrase->doclist.pList);\n      }else{\n        sqlite3_free(aOut);\n        pPhrase->doclist.pList = 0;\n        pPhrase->doclist.nList = 0;\n      }\n      sqlite3_free(aPoslist);\n    }\n  }\n\n  return SQLITE_OK;\n}\n#endif /* SQLITE_DISABLE_FTS4_DEFERRED */\n\n/*\n** Maximum number of tokens a phrase may have to be considered for the\n** incremental doclists strategy.\n*/\n#define MAX_INCR_PHRASE_TOKENS 4\n\n/*\n** This function is called for each Fts3Phrase in a full-text query \n** expression to initialize the mechanism for returning rows. Once this\n** function has been called successfully on an Fts3Phrase, it may be\n** used with fts3EvalPhraseNext() to iterate through the matching docids.\n**\n** If parameter bOptOk is true, then the phrase may (or may not) use the\n** incremental loading strategy. Otherwise, the entire doclist is loaded into\n** memory within this call.\n**\n** SQLITE_OK is returned if no error occurs, otherwise an SQLite error code.\n*/\nstatic int fts3EvalPhraseStart(Fts3Cursor *pCsr, int bOptOk, Fts3Phrase *p){\n  Fts3Table *pTab = (Fts3Table *)pCsr->base.pVtab;\n  int rc = SQLITE_OK;             /* Error code */\n  int i;\n\n  /* Determine if doclists may be loaded from disk incrementally. This is\n  ** possible if the bOptOk argument is true, the FTS doclists will be\n  ** scanned in forward order, and the phrase consists of \n  ** MAX_INCR_PHRASE_TOKENS or fewer tokens, none of which are are \"^first\"\n  ** tokens or prefix tokens that cannot use a prefix-index.  */\n  int bHaveIncr = 0;\n  int bIncrOk = (bOptOk \n   && pCsr->bDesc==pTab->bDescIdx \n   && p->nToken<=MAX_INCR_PHRASE_TOKENS && p->nToken>0\n#ifdef SQLITE_TEST\n   && pTab->bNoIncrDoclist==0\n#endif\n  );\n  for(i=0; bIncrOk==1 && i<p->nToken; i++){\n    Fts3PhraseToken *pToken = &p->aToken[i];\n    if( pToken->bFirst || (pToken->pSegcsr!=0 && !pToken->pSegcsr->bLookup) ){\n      bIncrOk = 0;\n    }\n    if( pToken->pSegcsr ) bHaveIncr = 1;\n  }\n\n  if( bIncrOk && bHaveIncr ){\n    /* Use the incremental approach. */\n    int iCol = (p->iColumn >= pTab->nColumn ? -1 : p->iColumn);\n    for(i=0; rc==SQLITE_OK && i<p->nToken; i++){\n      Fts3PhraseToken *pToken = &p->aToken[i];\n      Fts3MultiSegReader *pSegcsr = pToken->pSegcsr;\n      if( pSegcsr ){\n        rc = sqlite3Fts3MsrIncrStart(pTab, pSegcsr, iCol, pToken->z, pToken->n);\n      }\n    }\n    p->bIncr = 1;\n  }else{\n    /* Load the full doclist for the phrase into memory. */\n    rc = fts3EvalPhraseLoad(pCsr, p);\n    p->bIncr = 0;\n  }\n\n  assert( rc!=SQLITE_OK || p->nToken<1 || p->aToken[0].pSegcsr==0 || p->bIncr );\n  return rc;\n}\n\n/*\n** This function is used to iterate backwards (from the end to start) \n** through doclists. It is used by this module to iterate through phrase\n** doclists in reverse and by the fts3_write.c module to iterate through\n** pending-terms lists when writing to databases with \"order=desc\".\n**\n** The doclist may be sorted in ascending (parameter bDescIdx==0) or \n** descending (parameter bDescIdx==1) order of docid. Regardless, this\n** function iterates from the end of the doclist to the beginning.\n*/\nSQLITE_PRIVATE void sqlite3Fts3DoclistPrev(\n  int bDescIdx,                   /* True if the doclist is desc */\n  char *aDoclist,                 /* Pointer to entire doclist */\n  int nDoclist,                   /* Length of aDoclist in bytes */\n  char **ppIter,                  /* IN/OUT: Iterator pointer */\n  sqlite3_int64 *piDocid,         /* IN/OUT: Docid pointer */\n  int *pnList,                    /* OUT: List length pointer */\n  u8 *pbEof                       /* OUT: End-of-file flag */\n){\n  char *p = *ppIter;\n\n  assert( nDoclist>0 );\n  assert( *pbEof==0 );\n  assert( p || *piDocid==0 );\n  assert( !p || (p>aDoclist && p<&aDoclist[nDoclist]) );\n\n  if( p==0 ){\n    sqlite3_int64 iDocid = 0;\n    char *pNext = 0;\n    char *pDocid = aDoclist;\n    char *pEnd = &aDoclist[nDoclist];\n    int iMul = 1;\n\n    while( pDocid<pEnd ){\n      sqlite3_int64 iDelta;\n      pDocid += sqlite3Fts3GetVarint(pDocid, &iDelta);\n      iDocid += (iMul * iDelta);\n      pNext = pDocid;\n      fts3PoslistCopy(0, &pDocid);\n      while( pDocid<pEnd && *pDocid==0 ) pDocid++;\n      iMul = (bDescIdx ? -1 : 1);\n    }\n\n    *pnList = (int)(pEnd - pNext);\n    *ppIter = pNext;\n    *piDocid = iDocid;\n  }else{\n    int iMul = (bDescIdx ? -1 : 1);\n    sqlite3_int64 iDelta;\n    fts3GetReverseVarint(&p, aDoclist, &iDelta);\n    *piDocid -= (iMul * iDelta);\n\n    if( p==aDoclist ){\n      *pbEof = 1;\n    }else{\n      char *pSave = p;\n      fts3ReversePoslist(aDoclist, &p);\n      *pnList = (int)(pSave - p);\n    }\n    *ppIter = p;\n  }\n}\n\n/*\n** Iterate forwards through a doclist.\n*/\nSQLITE_PRIVATE void sqlite3Fts3DoclistNext(\n  int bDescIdx,                   /* True if the doclist is desc */\n  char *aDoclist,                 /* Pointer to entire doclist */\n  int nDoclist,                   /* Length of aDoclist in bytes */\n  char **ppIter,                  /* IN/OUT: Iterator pointer */\n  sqlite3_int64 *piDocid,         /* IN/OUT: Docid pointer */\n  u8 *pbEof                       /* OUT: End-of-file flag */\n){\n  char *p = *ppIter;\n\n  assert( nDoclist>0 );\n  assert( *pbEof==0 );\n  assert( p || *piDocid==0 );\n  assert( !p || (p>=aDoclist && p<=&aDoclist[nDoclist]) );\n\n  if( p==0 ){\n    p = aDoclist;\n    p += sqlite3Fts3GetVarint(p, piDocid);\n  }else{\n    fts3PoslistCopy(0, &p);\n    while( p<&aDoclist[nDoclist] && *p==0 ) p++; \n    if( p>=&aDoclist[nDoclist] ){\n      *pbEof = 1;\n    }else{\n      sqlite3_int64 iVar;\n      p += sqlite3Fts3GetVarint(p, &iVar);\n      *piDocid += ((bDescIdx ? -1 : 1) * iVar);\n    }\n  }\n\n  *ppIter = p;\n}\n\n/*\n** Advance the iterator pDL to the next entry in pDL->aAll/nAll. Set *pbEof\n** to true if EOF is reached.\n*/\nstatic void fts3EvalDlPhraseNext(\n  Fts3Table *pTab,\n  Fts3Doclist *pDL,\n  u8 *pbEof\n){\n  char *pIter;                            /* Used to iterate through aAll */\n  char *pEnd = &pDL->aAll[pDL->nAll];     /* 1 byte past end of aAll */\n \n  if( pDL->pNextDocid ){\n    pIter = pDL->pNextDocid;\n  }else{\n    pIter = pDL->aAll;\n  }\n\n  if( pIter>=pEnd ){\n    /* We have already reached the end of this doclist. EOF. */\n    *pbEof = 1;\n  }else{\n    sqlite3_int64 iDelta;\n    pIter += sqlite3Fts3GetVarint(pIter, &iDelta);\n    if( pTab->bDescIdx==0 || pDL->pNextDocid==0 ){\n      pDL->iDocid += iDelta;\n    }else{\n      pDL->iDocid -= iDelta;\n    }\n    pDL->pList = pIter;\n    fts3PoslistCopy(0, &pIter);\n    pDL->nList = (int)(pIter - pDL->pList);\n\n    /* pIter now points just past the 0x00 that terminates the position-\n    ** list for document pDL->iDocid. However, if this position-list was\n    ** edited in place by fts3EvalNearTrim(), then pIter may not actually\n    ** point to the start of the next docid value. The following line deals\n    ** with this case by advancing pIter past the zero-padding added by\n    ** fts3EvalNearTrim().  */\n    while( pIter<pEnd && *pIter==0 ) pIter++;\n\n    pDL->pNextDocid = pIter;\n    assert( pIter>=&pDL->aAll[pDL->nAll] || *pIter );\n    *pbEof = 0;\n  }\n}\n\n/*\n** Helper type used by fts3EvalIncrPhraseNext() and incrPhraseTokenNext().\n*/\ntypedef struct TokenDoclist TokenDoclist;\nstruct TokenDoclist {\n  int bIgnore;\n  sqlite3_int64 iDocid;\n  char *pList;\n  int nList;\n};\n\n/*\n** Token pToken is an incrementally loaded token that is part of a \n** multi-token phrase. Advance it to the next matching document in the\n** database and populate output variable *p with the details of the new\n** entry. Or, if the iterator has reached EOF, set *pbEof to true.\n**\n** If an error occurs, return an SQLite error code. Otherwise, return \n** SQLITE_OK.\n*/\nstatic int incrPhraseTokenNext(\n  Fts3Table *pTab,                /* Virtual table handle */\n  Fts3Phrase *pPhrase,            /* Phrase to advance token of */\n  int iToken,                     /* Specific token to advance */\n  TokenDoclist *p,                /* OUT: Docid and doclist for new entry */\n  u8 *pbEof                       /* OUT: True if iterator is at EOF */\n){\n  int rc = SQLITE_OK;\n\n  if( pPhrase->iDoclistToken==iToken ){\n    assert( p->bIgnore==0 );\n    assert( pPhrase->aToken[iToken].pSegcsr==0 );\n    fts3EvalDlPhraseNext(pTab, &pPhrase->doclist, pbEof);\n    p->pList = pPhrase->doclist.pList;\n    p->nList = pPhrase->doclist.nList;\n    p->iDocid = pPhrase->doclist.iDocid;\n  }else{\n    Fts3PhraseToken *pToken = &pPhrase->aToken[iToken];\n    assert( pToken->pDeferred==0 );\n    assert( pToken->pSegcsr || pPhrase->iDoclistToken>=0 );\n    if( pToken->pSegcsr ){\n      assert( p->bIgnore==0 );\n      rc = sqlite3Fts3MsrIncrNext(\n          pTab, pToken->pSegcsr, &p->iDocid, &p->pList, &p->nList\n      );\n      if( p->pList==0 ) *pbEof = 1;\n    }else{\n      p->bIgnore = 1;\n    }\n  }\n\n  return rc;\n}\n\n\n/*\n** The phrase iterator passed as the second argument:\n**\n**   * features at least one token that uses an incremental doclist, and \n**\n**   * does not contain any deferred tokens.\n**\n** Advance it to the next matching documnent in the database and populate\n** the Fts3Doclist.pList and nList fields. \n**\n** If there is no \"next\" entry and no error occurs, then *pbEof is set to\n** 1 before returning. Otherwise, if no error occurs and the iterator is\n** successfully advanced, *pbEof is set to 0.\n**\n** If an error occurs, return an SQLite error code. Otherwise, return \n** SQLITE_OK.\n*/\nstatic int fts3EvalIncrPhraseNext(\n  Fts3Cursor *pCsr,               /* FTS Cursor handle */\n  Fts3Phrase *p,                  /* Phrase object to advance to next docid */\n  u8 *pbEof                       /* OUT: Set to 1 if EOF */\n){\n  int rc = SQLITE_OK;\n  Fts3Doclist *pDL = &p->doclist;\n  Fts3Table *pTab = (Fts3Table *)pCsr->base.pVtab;\n  u8 bEof = 0;\n\n  /* This is only called if it is guaranteed that the phrase has at least\n  ** one incremental token. In which case the bIncr flag is set. */\n  assert( p->bIncr==1 );\n\n  if( p->nToken==1 ){\n    rc = sqlite3Fts3MsrIncrNext(pTab, p->aToken[0].pSegcsr, \n        &pDL->iDocid, &pDL->pList, &pDL->nList\n    );\n    if( pDL->pList==0 ) bEof = 1;\n  }else{\n    int bDescDoclist = pCsr->bDesc;\n    struct TokenDoclist a[MAX_INCR_PHRASE_TOKENS];\n\n    memset(a, 0, sizeof(a));\n    assert( p->nToken<=MAX_INCR_PHRASE_TOKENS );\n    assert( p->iDoclistToken<MAX_INCR_PHRASE_TOKENS );\n\n    while( bEof==0 ){\n      int bMaxSet = 0;\n      sqlite3_int64 iMax = 0;     /* Largest docid for all iterators */\n      int i;                      /* Used to iterate through tokens */\n\n      /* Advance the iterator for each token in the phrase once. */\n      for(i=0; rc==SQLITE_OK && i<p->nToken && bEof==0; i++){\n        rc = incrPhraseTokenNext(pTab, p, i, &a[i], &bEof);\n        if( a[i].bIgnore==0 && (bMaxSet==0 || DOCID_CMP(iMax, a[i].iDocid)<0) ){\n          iMax = a[i].iDocid;\n          bMaxSet = 1;\n        }\n      }\n      assert( rc!=SQLITE_OK || (p->nToken>=1 && a[p->nToken-1].bIgnore==0) );\n      assert( rc!=SQLITE_OK || bMaxSet );\n\n      /* Keep advancing iterators until they all point to the same document */\n      for(i=0; i<p->nToken; i++){\n        while( rc==SQLITE_OK && bEof==0 \n            && a[i].bIgnore==0 && DOCID_CMP(a[i].iDocid, iMax)<0 \n        ){\n          rc = incrPhraseTokenNext(pTab, p, i, &a[i], &bEof);\n          if( DOCID_CMP(a[i].iDocid, iMax)>0 ){\n            iMax = a[i].iDocid;\n            i = 0;\n          }\n        }\n      }\n\n      /* Check if the current entries really are a phrase match */\n      if( bEof==0 ){\n        int nList = 0;\n        int nByte = a[p->nToken-1].nList;\n        char *aDoclist = sqlite3_malloc(nByte+FTS3_BUFFER_PADDING);\n        if( !aDoclist ) return SQLITE_NOMEM;\n        memcpy(aDoclist, a[p->nToken-1].pList, nByte+1);\n        memset(&aDoclist[nByte], 0, FTS3_BUFFER_PADDING);\n\n        for(i=0; i<(p->nToken-1); i++){\n          if( a[i].bIgnore==0 ){\n            char *pL = a[i].pList;\n            char *pR = aDoclist;\n            char *pOut = aDoclist;\n            int nDist = p->nToken-1-i;\n            int res = fts3PoslistPhraseMerge(&pOut, nDist, 0, 1, &pL, &pR);\n            if( res==0 ) break;\n            nList = (int)(pOut - aDoclist);\n          }\n        }\n        if( i==(p->nToken-1) ){\n          pDL->iDocid = iMax;\n          pDL->pList = aDoclist;\n          pDL->nList = nList;\n          pDL->bFreeList = 1;\n          break;\n        }\n        sqlite3_free(aDoclist);\n      }\n    }\n  }\n\n  *pbEof = bEof;\n  return rc;\n}\n\n/*\n** Attempt to move the phrase iterator to point to the next matching docid. \n** If an error occurs, return an SQLite error code. Otherwise, return \n** SQLITE_OK.\n**\n** If there is no \"next\" entry and no error occurs, then *pbEof is set to\n** 1 before returning. Otherwise, if no error occurs and the iterator is\n** successfully advanced, *pbEof is set to 0.\n*/\nstatic int fts3EvalPhraseNext(\n  Fts3Cursor *pCsr,               /* FTS Cursor handle */\n  Fts3Phrase *p,                  /* Phrase object to advance to next docid */\n  u8 *pbEof                       /* OUT: Set to 1 if EOF */\n){\n  int rc = SQLITE_OK;\n  Fts3Doclist *pDL = &p->doclist;\n  Fts3Table *pTab = (Fts3Table *)pCsr->base.pVtab;\n\n  if( p->bIncr ){\n    rc = fts3EvalIncrPhraseNext(pCsr, p, pbEof);\n  }else if( pCsr->bDesc!=pTab->bDescIdx && pDL->nAll ){\n    sqlite3Fts3DoclistPrev(pTab->bDescIdx, pDL->aAll, pDL->nAll, \n        &pDL->pNextDocid, &pDL->iDocid, &pDL->nList, pbEof\n    );\n    pDL->pList = pDL->pNextDocid;\n  }else{\n    fts3EvalDlPhraseNext(pTab, pDL, pbEof);\n  }\n\n  return rc;\n}\n\n/*\n**\n** If *pRc is not SQLITE_OK when this function is called, it is a no-op.\n** Otherwise, fts3EvalPhraseStart() is called on all phrases within the\n** expression. Also the Fts3Expr.bDeferred variable is set to true for any\n** expressions for which all descendent tokens are deferred.\n**\n** If parameter bOptOk is zero, then it is guaranteed that the\n** Fts3Phrase.doclist.aAll/nAll variables contain the entire doclist for\n** each phrase in the expression (subject to deferred token processing).\n** Or, if bOptOk is non-zero, then one or more tokens within the expression\n** may be loaded incrementally, meaning doclist.aAll/nAll is not available.\n**\n** If an error occurs within this function, *pRc is set to an SQLite error\n** code before returning.\n*/\nstatic void fts3EvalStartReaders(\n  Fts3Cursor *pCsr,               /* FTS Cursor handle */\n  Fts3Expr *pExpr,                /* Expression to initialize phrases in */\n  int *pRc                        /* IN/OUT: Error code */\n){\n  if( pExpr && SQLITE_OK==*pRc ){\n    if( pExpr->eType==FTSQUERY_PHRASE ){\n      int nToken = pExpr->pPhrase->nToken;\n      if( nToken ){\n        int i;\n        for(i=0; i<nToken; i++){\n          if( pExpr->pPhrase->aToken[i].pDeferred==0 ) break;\n        }\n        pExpr->bDeferred = (i==nToken);\n      }\n      *pRc = fts3EvalPhraseStart(pCsr, 1, pExpr->pPhrase);\n    }else{\n      fts3EvalStartReaders(pCsr, pExpr->pLeft, pRc);\n      fts3EvalStartReaders(pCsr, pExpr->pRight, pRc);\n      pExpr->bDeferred = (pExpr->pLeft->bDeferred && pExpr->pRight->bDeferred);\n    }\n  }\n}\n\n/*\n** An array of the following structures is assembled as part of the process\n** of selecting tokens to defer before the query starts executing (as part\n** of the xFilter() method). There is one element in the array for each\n** token in the FTS expression.\n**\n** Tokens are divided into AND/NEAR clusters. All tokens in a cluster belong\n** to phrases that are connected only by AND and NEAR operators (not OR or\n** NOT). When determining tokens to defer, each AND/NEAR cluster is considered\n** separately. The root of a tokens AND/NEAR cluster is stored in \n** Fts3TokenAndCost.pRoot.\n*/\ntypedef struct Fts3TokenAndCost Fts3TokenAndCost;\nstruct Fts3TokenAndCost {\n  Fts3Phrase *pPhrase;            /* The phrase the token belongs to */\n  int iToken;                     /* Position of token in phrase */\n  Fts3PhraseToken *pToken;        /* The token itself */\n  Fts3Expr *pRoot;                /* Root of NEAR/AND cluster */\n  int nOvfl;                      /* Number of overflow pages to load doclist */\n  int iCol;                       /* The column the token must match */\n};\n\n/*\n** This function is used to populate an allocated Fts3TokenAndCost array.\n**\n** If *pRc is not SQLITE_OK when this function is called, it is a no-op.\n** Otherwise, if an error occurs during execution, *pRc is set to an\n** SQLite error code.\n*/\nstatic void fts3EvalTokenCosts(\n  Fts3Cursor *pCsr,               /* FTS Cursor handle */\n  Fts3Expr *pRoot,                /* Root of current AND/NEAR cluster */\n  Fts3Expr *pExpr,                /* Expression to consider */\n  Fts3TokenAndCost **ppTC,        /* Write new entries to *(*ppTC)++ */\n  Fts3Expr ***ppOr,               /* Write new OR root to *(*ppOr)++ */\n  int *pRc                        /* IN/OUT: Error code */\n){\n  if( *pRc==SQLITE_OK ){\n    if( pExpr->eType==FTSQUERY_PHRASE ){\n      Fts3Phrase *pPhrase = pExpr->pPhrase;\n      int i;\n      for(i=0; *pRc==SQLITE_OK && i<pPhrase->nToken; i++){\n        Fts3TokenAndCost *pTC = (*ppTC)++;\n        pTC->pPhrase = pPhrase;\n        pTC->iToken = i;\n        pTC->pRoot = pRoot;\n        pTC->pToken = &pPhrase->aToken[i];\n        pTC->iCol = pPhrase->iColumn;\n        *pRc = sqlite3Fts3MsrOvfl(pCsr, pTC->pToken->pSegcsr, &pTC->nOvfl);\n      }\n    }else if( pExpr->eType!=FTSQUERY_NOT ){\n      assert( pExpr->eType==FTSQUERY_OR\n           || pExpr->eType==FTSQUERY_AND\n           || pExpr->eType==FTSQUERY_NEAR\n      );\n      assert( pExpr->pLeft && pExpr->pRight );\n      if( pExpr->eType==FTSQUERY_OR ){\n        pRoot = pExpr->pLeft;\n        **ppOr = pRoot;\n        (*ppOr)++;\n      }\n      fts3EvalTokenCosts(pCsr, pRoot, pExpr->pLeft, ppTC, ppOr, pRc);\n      if( pExpr->eType==FTSQUERY_OR ){\n        pRoot = pExpr->pRight;\n        **ppOr = pRoot;\n        (*ppOr)++;\n      }\n      fts3EvalTokenCosts(pCsr, pRoot, pExpr->pRight, ppTC, ppOr, pRc);\n    }\n  }\n}\n\n/*\n** Determine the average document (row) size in pages. If successful,\n** write this value to *pnPage and return SQLITE_OK. Otherwise, return\n** an SQLite error code.\n**\n** The average document size in pages is calculated by first calculating \n** determining the average size in bytes, B. If B is less than the amount\n** of data that will fit on a single leaf page of an intkey table in\n** this database, then the average docsize is 1. Otherwise, it is 1 plus\n** the number of overflow pages consumed by a record B bytes in size.\n*/\nstatic int fts3EvalAverageDocsize(Fts3Cursor *pCsr, int *pnPage){\n  int rc = SQLITE_OK;\n  if( pCsr->nRowAvg==0 ){\n    /* The average document size, which is required to calculate the cost\n    ** of each doclist, has not yet been determined. Read the required \n    ** data from the %_stat table to calculate it.\n    **\n    ** Entry 0 of the %_stat table is a blob containing (nCol+1) FTS3 \n    ** varints, where nCol is the number of columns in the FTS3 table.\n    ** The first varint is the number of documents currently stored in\n    ** the table. The following nCol varints contain the total amount of\n    ** data stored in all rows of each column of the table, from left\n    ** to right.\n    */\n    Fts3Table *p = (Fts3Table*)pCsr->base.pVtab;\n    sqlite3_stmt *pStmt;\n    sqlite3_int64 nDoc = 0;\n    sqlite3_int64 nByte = 0;\n    const char *pEnd;\n    const char *a;\n\n    rc = sqlite3Fts3SelectDoctotal(p, &pStmt);\n    if( rc!=SQLITE_OK ) return rc;\n    a = sqlite3_column_blob(pStmt, 0);\n    assert( a );\n\n    pEnd = &a[sqlite3_column_bytes(pStmt, 0)];\n    a += sqlite3Fts3GetVarint(a, &nDoc);\n    while( a<pEnd ){\n      a += sqlite3Fts3GetVarint(a, &nByte);\n    }\n    if( nDoc==0 || nByte==0 ){\n      sqlite3_reset(pStmt);\n      return FTS_CORRUPT_VTAB;\n    }\n\n    pCsr->nDoc = nDoc;\n    pCsr->nRowAvg = (int)(((nByte / nDoc) + p->nPgsz) / p->nPgsz);\n    assert( pCsr->nRowAvg>0 ); \n    rc = sqlite3_reset(pStmt);\n  }\n\n  *pnPage = pCsr->nRowAvg;\n  return rc;\n}\n\n/*\n** This function is called to select the tokens (if any) that will be \n** deferred. The array aTC[] has already been populated when this is\n** called.\n**\n** This function is called once for each AND/NEAR cluster in the \n** expression. Each invocation determines which tokens to defer within\n** the cluster with root node pRoot. See comments above the definition\n** of struct Fts3TokenAndCost for more details.\n**\n** If no error occurs, SQLITE_OK is returned and sqlite3Fts3DeferToken()\n** called on each token to defer. Otherwise, an SQLite error code is\n** returned.\n*/\nstatic int fts3EvalSelectDeferred(\n  Fts3Cursor *pCsr,               /* FTS Cursor handle */\n  Fts3Expr *pRoot,                /* Consider tokens with this root node */\n  Fts3TokenAndCost *aTC,          /* Array of expression tokens and costs */\n  int nTC                         /* Number of entries in aTC[] */\n){\n  Fts3Table *pTab = (Fts3Table *)pCsr->base.pVtab;\n  int nDocSize = 0;               /* Number of pages per doc loaded */\n  int rc = SQLITE_OK;             /* Return code */\n  int ii;                         /* Iterator variable for various purposes */\n  int nOvfl = 0;                  /* Total overflow pages used by doclists */\n  int nToken = 0;                 /* Total number of tokens in cluster */\n\n  int nMinEst = 0;                /* The minimum count for any phrase so far. */\n  int nLoad4 = 1;                 /* (Phrases that will be loaded)^4. */\n\n  /* Tokens are never deferred for FTS tables created using the content=xxx\n  ** option. The reason being that it is not guaranteed that the content\n  ** table actually contains the same data as the index. To prevent this from\n  ** causing any problems, the deferred token optimization is completely\n  ** disabled for content=xxx tables. */\n  if( pTab->zContentTbl ){\n    return SQLITE_OK;\n  }\n\n  /* Count the tokens in this AND/NEAR cluster. If none of the doclists\n  ** associated with the tokens spill onto overflow pages, or if there is\n  ** only 1 token, exit early. No tokens to defer in this case. */\n  for(ii=0; ii<nTC; ii++){\n    if( aTC[ii].pRoot==pRoot ){\n      nOvfl += aTC[ii].nOvfl;\n      nToken++;\n    }\n  }\n  if( nOvfl==0 || nToken<2 ) return SQLITE_OK;\n\n  /* Obtain the average docsize (in pages). */\n  rc = fts3EvalAverageDocsize(pCsr, &nDocSize);\n  assert( rc!=SQLITE_OK || nDocSize>0 );\n\n\n  /* Iterate through all tokens in this AND/NEAR cluster, in ascending order \n  ** of the number of overflow pages that will be loaded by the pager layer \n  ** to retrieve the entire doclist for the token from the full-text index.\n  ** Load the doclists for tokens that are either:\n  **\n  **   a. The cheapest token in the entire query (i.e. the one visited by the\n  **      first iteration of this loop), or\n  **\n  **   b. Part of a multi-token phrase.\n  **\n  ** After each token doclist is loaded, merge it with the others from the\n  ** same phrase and count the number of documents that the merged doclist\n  ** contains. Set variable \"nMinEst\" to the smallest number of documents in \n  ** any phrase doclist for which 1 or more token doclists have been loaded.\n  ** Let nOther be the number of other phrases for which it is certain that\n  ** one or more tokens will not be deferred.\n  **\n  ** Then, for each token, defer it if loading the doclist would result in\n  ** loading N or more overflow pages into memory, where N is computed as:\n  **\n  **    (nMinEst + 4^nOther - 1) / (4^nOther)\n  */\n  for(ii=0; ii<nToken && rc==SQLITE_OK; ii++){\n    int iTC;                      /* Used to iterate through aTC[] array. */\n    Fts3TokenAndCost *pTC = 0;    /* Set to cheapest remaining token. */\n\n    /* Set pTC to point to the cheapest remaining token. */\n    for(iTC=0; iTC<nTC; iTC++){\n      if( aTC[iTC].pToken && aTC[iTC].pRoot==pRoot \n       && (!pTC || aTC[iTC].nOvfl<pTC->nOvfl) \n      ){\n        pTC = &aTC[iTC];\n      }\n    }\n    assert( pTC );\n\n    if( ii && pTC->nOvfl>=((nMinEst+(nLoad4/4)-1)/(nLoad4/4))*nDocSize ){\n      /* The number of overflow pages to load for this (and therefore all\n      ** subsequent) tokens is greater than the estimated number of pages \n      ** that will be loaded if all subsequent tokens are deferred.\n      */\n      Fts3PhraseToken *pToken = pTC->pToken;\n      rc = sqlite3Fts3DeferToken(pCsr, pToken, pTC->iCol);\n      fts3SegReaderCursorFree(pToken->pSegcsr);\n      pToken->pSegcsr = 0;\n    }else{\n      /* Set nLoad4 to the value of (4^nOther) for the next iteration of the\n      ** for-loop. Except, limit the value to 2^24 to prevent it from \n      ** overflowing the 32-bit integer it is stored in. */\n      if( ii<12 ) nLoad4 = nLoad4*4;\n\n      if( ii==0 || (pTC->pPhrase->nToken>1 && ii!=nToken-1) ){\n        /* Either this is the cheapest token in the entire query, or it is\n        ** part of a multi-token phrase. Either way, the entire doclist will\n        ** (eventually) be loaded into memory. It may as well be now. */\n        Fts3PhraseToken *pToken = pTC->pToken;\n        int nList = 0;\n        char *pList = 0;\n        rc = fts3TermSelect(pTab, pToken, pTC->iCol, &nList, &pList);\n        assert( rc==SQLITE_OK || pList==0 );\n        if( rc==SQLITE_OK ){\n          rc = fts3EvalPhraseMergeToken(\n              pTab, pTC->pPhrase, pTC->iToken,pList,nList\n          );\n        }\n        if( rc==SQLITE_OK ){\n          int nCount;\n          nCount = fts3DoclistCountDocids(\n              pTC->pPhrase->doclist.aAll, pTC->pPhrase->doclist.nAll\n          );\n          if( ii==0 || nCount<nMinEst ) nMinEst = nCount;\n        }\n      }\n    }\n    pTC->pToken = 0;\n  }\n\n  return rc;\n}\n\n/*\n** This function is called from within the xFilter method. It initializes\n** the full-text query currently stored in pCsr->pExpr. To iterate through\n** the results of a query, the caller does:\n**\n**    fts3EvalStart(pCsr);\n**    while( 1 ){\n**      fts3EvalNext(pCsr);\n**      if( pCsr->bEof ) break;\n**      ... return row pCsr->iPrevId to the caller ...\n**    }\n*/\nstatic int fts3EvalStart(Fts3Cursor *pCsr){\n  Fts3Table *pTab = (Fts3Table *)pCsr->base.pVtab;\n  int rc = SQLITE_OK;\n  int nToken = 0;\n  int nOr = 0;\n\n  /* Allocate a MultiSegReader for each token in the expression. */\n  fts3EvalAllocateReaders(pCsr, pCsr->pExpr, &nToken, &nOr, &rc);\n\n  /* Determine which, if any, tokens in the expression should be deferred. */\n#ifndef SQLITE_DISABLE_FTS4_DEFERRED\n  if( rc==SQLITE_OK && nToken>1 && pTab->bFts4 ){\n    Fts3TokenAndCost *aTC;\n    Fts3Expr **apOr;\n    aTC = (Fts3TokenAndCost *)sqlite3_malloc64(\n        sizeof(Fts3TokenAndCost) * nToken\n      + sizeof(Fts3Expr *) * nOr * 2\n    );\n    apOr = (Fts3Expr **)&aTC[nToken];\n\n    if( !aTC ){\n      rc = SQLITE_NOMEM;\n    }else{\n      int ii;\n      Fts3TokenAndCost *pTC = aTC;\n      Fts3Expr **ppOr = apOr;\n\n      fts3EvalTokenCosts(pCsr, 0, pCsr->pExpr, &pTC, &ppOr, &rc);\n      nToken = (int)(pTC-aTC);\n      nOr = (int)(ppOr-apOr);\n\n      if( rc==SQLITE_OK ){\n        rc = fts3EvalSelectDeferred(pCsr, 0, aTC, nToken);\n        for(ii=0; rc==SQLITE_OK && ii<nOr; ii++){\n          rc = fts3EvalSelectDeferred(pCsr, apOr[ii], aTC, nToken);\n        }\n      }\n\n      sqlite3_free(aTC);\n    }\n  }\n#endif\n\n  fts3EvalStartReaders(pCsr, pCsr->pExpr, &rc);\n  return rc;\n}\n\n/*\n** Invalidate the current position list for phrase pPhrase.\n*/\nstatic void fts3EvalInvalidatePoslist(Fts3Phrase *pPhrase){\n  if( pPhrase->doclist.bFreeList ){\n    sqlite3_free(pPhrase->doclist.pList);\n  }\n  pPhrase->doclist.pList = 0;\n  pPhrase->doclist.nList = 0;\n  pPhrase->doclist.bFreeList = 0;\n}\n\n/*\n** This function is called to edit the position list associated with\n** the phrase object passed as the fifth argument according to a NEAR\n** condition. For example:\n**\n**     abc NEAR/5 \"def ghi\"\n**\n** Parameter nNear is passed the NEAR distance of the expression (5 in\n** the example above). When this function is called, *paPoslist points to\n** the position list, and *pnToken is the number of phrase tokens in, the\n** phrase on the other side of the NEAR operator to pPhrase. For example,\n** if pPhrase refers to the \"def ghi\" phrase, then *paPoslist points to\n** the position list associated with phrase \"abc\".\n**\n** All positions in the pPhrase position list that are not sufficiently\n** close to a position in the *paPoslist position list are removed. If this\n** leaves 0 positions, zero is returned. Otherwise, non-zero.\n**\n** Before returning, *paPoslist is set to point to the position lsit \n** associated with pPhrase. And *pnToken is set to the number of tokens in\n** pPhrase.\n*/\nstatic int fts3EvalNearTrim(\n  int nNear,                      /* NEAR distance. As in \"NEAR/nNear\". */\n  char *aTmp,                     /* Temporary space to use */\n  char **paPoslist,               /* IN/OUT: Position list */\n  int *pnToken,                   /* IN/OUT: Tokens in phrase of *paPoslist */\n  Fts3Phrase *pPhrase             /* The phrase object to trim the doclist of */\n){\n  int nParam1 = nNear + pPhrase->nToken;\n  int nParam2 = nNear + *pnToken;\n  int nNew;\n  char *p2; \n  char *pOut; \n  int res;\n\n  assert( pPhrase->doclist.pList );\n\n  p2 = pOut = pPhrase->doclist.pList;\n  res = fts3PoslistNearMerge(\n    &pOut, aTmp, nParam1, nParam2, paPoslist, &p2\n  );\n  if( res ){\n    nNew = (int)(pOut - pPhrase->doclist.pList) - 1;\n    assert( pPhrase->doclist.pList[nNew]=='\\0' );\n    assert( nNew<=pPhrase->doclist.nList && nNew>0 );\n    memset(&pPhrase->doclist.pList[nNew], 0, pPhrase->doclist.nList - nNew);\n    pPhrase->doclist.nList = nNew;\n    *paPoslist = pPhrase->doclist.pList;\n    *pnToken = pPhrase->nToken;\n  }\n\n  return res;\n}\n\n/*\n** This function is a no-op if *pRc is other than SQLITE_OK when it is called.\n** Otherwise, it advances the expression passed as the second argument to\n** point to the next matching row in the database. Expressions iterate through\n** matching rows in docid order. Ascending order if Fts3Cursor.bDesc is zero,\n** or descending if it is non-zero.\n**\n** If an error occurs, *pRc is set to an SQLite error code. Otherwise, if\n** successful, the following variables in pExpr are set:\n**\n**   Fts3Expr.bEof                (non-zero if EOF - there is no next row)\n**   Fts3Expr.iDocid              (valid if bEof==0. The docid of the next row)\n**\n** If the expression is of type FTSQUERY_PHRASE, and the expression is not\n** at EOF, then the following variables are populated with the position list\n** for the phrase for the visited row:\n**\n**   FTs3Expr.pPhrase->doclist.nList        (length of pList in bytes)\n**   FTs3Expr.pPhrase->doclist.pList        (pointer to position list)\n**\n** It says above that this function advances the expression to the next\n** matching row. This is usually true, but there are the following exceptions:\n**\n**   1. Deferred tokens are not taken into account. If a phrase consists\n**      entirely of deferred tokens, it is assumed to match every row in\n**      the db. In this case the position-list is not populated at all. \n**\n**      Or, if a phrase contains one or more deferred tokens and one or\n**      more non-deferred tokens, then the expression is advanced to the \n**      next possible match, considering only non-deferred tokens. In other\n**      words, if the phrase is \"A B C\", and \"B\" is deferred, the expression\n**      is advanced to the next row that contains an instance of \"A * C\", \n**      where \"*\" may match any single token. The position list in this case\n**      is populated as for \"A * C\" before returning.\n**\n**   2. NEAR is treated as AND. If the expression is \"x NEAR y\", it is \n**      advanced to point to the next row that matches \"x AND y\".\n** \n** See sqlite3Fts3EvalTestDeferred() for details on testing if a row is\n** really a match, taking into account deferred tokens and NEAR operators.\n*/\nstatic void fts3EvalNextRow(\n  Fts3Cursor *pCsr,               /* FTS Cursor handle */\n  Fts3Expr *pExpr,                /* Expr. to advance to next matching row */\n  int *pRc                        /* IN/OUT: Error code */\n){\n  if( *pRc==SQLITE_OK ){\n    int bDescDoclist = pCsr->bDesc;         /* Used by DOCID_CMP() macro */\n    assert( pExpr->bEof==0 );\n    pExpr->bStart = 1;\n\n    switch( pExpr->eType ){\n      case FTSQUERY_NEAR:\n      case FTSQUERY_AND: {\n        Fts3Expr *pLeft = pExpr->pLeft;\n        Fts3Expr *pRight = pExpr->pRight;\n        assert( !pLeft->bDeferred || !pRight->bDeferred );\n\n        if( pLeft->bDeferred ){\n          /* LHS is entirely deferred. So we assume it matches every row.\n          ** Advance the RHS iterator to find the next row visited. */\n          fts3EvalNextRow(pCsr, pRight, pRc);\n          pExpr->iDocid = pRight->iDocid;\n          pExpr->bEof = pRight->bEof;\n        }else if( pRight->bDeferred ){\n          /* RHS is entirely deferred. So we assume it matches every row.\n          ** Advance the LHS iterator to find the next row visited. */\n          fts3EvalNextRow(pCsr, pLeft, pRc);\n          pExpr->iDocid = pLeft->iDocid;\n          pExpr->bEof = pLeft->bEof;\n        }else{\n          /* Neither the RHS or LHS are deferred. */\n          fts3EvalNextRow(pCsr, pLeft, pRc);\n          fts3EvalNextRow(pCsr, pRight, pRc);\n          while( !pLeft->bEof && !pRight->bEof && *pRc==SQLITE_OK ){\n            sqlite3_int64 iDiff = DOCID_CMP(pLeft->iDocid, pRight->iDocid);\n            if( iDiff==0 ) break;\n            if( iDiff<0 ){\n              fts3EvalNextRow(pCsr, pLeft, pRc);\n            }else{\n              fts3EvalNextRow(pCsr, pRight, pRc);\n            }\n          }\n          pExpr->iDocid = pLeft->iDocid;\n          pExpr->bEof = (pLeft->bEof || pRight->bEof);\n          if( pExpr->eType==FTSQUERY_NEAR && pExpr->bEof ){\n            assert( pRight->eType==FTSQUERY_PHRASE );\n            if( pRight->pPhrase->doclist.aAll ){\n              Fts3Doclist *pDl = &pRight->pPhrase->doclist;\n              while( *pRc==SQLITE_OK && pRight->bEof==0 ){\n                memset(pDl->pList, 0, pDl->nList);\n                fts3EvalNextRow(pCsr, pRight, pRc);\n              }\n            }\n            if( pLeft->pPhrase && pLeft->pPhrase->doclist.aAll ){\n              Fts3Doclist *pDl = &pLeft->pPhrase->doclist;\n              while( *pRc==SQLITE_OK && pLeft->bEof==0 ){\n                memset(pDl->pList, 0, pDl->nList);\n                fts3EvalNextRow(pCsr, pLeft, pRc);\n              }\n            }\n          }\n        }\n        break;\n      }\n  \n      case FTSQUERY_OR: {\n        Fts3Expr *pLeft = pExpr->pLeft;\n        Fts3Expr *pRight = pExpr->pRight;\n        sqlite3_int64 iCmp = DOCID_CMP(pLeft->iDocid, pRight->iDocid);\n\n        assert( pLeft->bStart || pLeft->iDocid==pRight->iDocid );\n        assert( pRight->bStart || pLeft->iDocid==pRight->iDocid );\n\n        if( pRight->bEof || (pLeft->bEof==0 && iCmp<0) ){\n          fts3EvalNextRow(pCsr, pLeft, pRc);\n        }else if( pLeft->bEof || iCmp>0 ){\n          fts3EvalNextRow(pCsr, pRight, pRc);\n        }else{\n          fts3EvalNextRow(pCsr, pLeft, pRc);\n          fts3EvalNextRow(pCsr, pRight, pRc);\n        }\n\n        pExpr->bEof = (pLeft->bEof && pRight->bEof);\n        iCmp = DOCID_CMP(pLeft->iDocid, pRight->iDocid);\n        if( pRight->bEof || (pLeft->bEof==0 &&  iCmp<0) ){\n          pExpr->iDocid = pLeft->iDocid;\n        }else{\n          pExpr->iDocid = pRight->iDocid;\n        }\n\n        break;\n      }\n\n      case FTSQUERY_NOT: {\n        Fts3Expr *pLeft = pExpr->pLeft;\n        Fts3Expr *pRight = pExpr->pRight;\n\n        if( pRight->bStart==0 ){\n          fts3EvalNextRow(pCsr, pRight, pRc);\n          assert( *pRc!=SQLITE_OK || pRight->bStart );\n        }\n\n        fts3EvalNextRow(pCsr, pLeft, pRc);\n        if( pLeft->bEof==0 ){\n          while( !*pRc \n              && !pRight->bEof \n              && DOCID_CMP(pLeft->iDocid, pRight->iDocid)>0 \n          ){\n            fts3EvalNextRow(pCsr, pRight, pRc);\n          }\n        }\n        pExpr->iDocid = pLeft->iDocid;\n        pExpr->bEof = pLeft->bEof;\n        break;\n      }\n\n      default: {\n        Fts3Phrase *pPhrase = pExpr->pPhrase;\n        fts3EvalInvalidatePoslist(pPhrase);\n        *pRc = fts3EvalPhraseNext(pCsr, pPhrase, &pExpr->bEof);\n        pExpr->iDocid = pPhrase->doclist.iDocid;\n        break;\n      }\n    }\n  }\n}\n\n/*\n** If *pRc is not SQLITE_OK, or if pExpr is not the root node of a NEAR\n** cluster, then this function returns 1 immediately.\n**\n** Otherwise, it checks if the current row really does match the NEAR \n** expression, using the data currently stored in the position lists \n** (Fts3Expr->pPhrase.doclist.pList/nList) for each phrase in the expression. \n**\n** If the current row is a match, the position list associated with each\n** phrase in the NEAR expression is edited in place to contain only those\n** phrase instances sufficiently close to their peers to satisfy all NEAR\n** constraints. In this case it returns 1. If the NEAR expression does not \n** match the current row, 0 is returned. The position lists may or may not\n** be edited if 0 is returned.\n*/\nstatic int fts3EvalNearTest(Fts3Expr *pExpr, int *pRc){\n  int res = 1;\n\n  /* The following block runs if pExpr is the root of a NEAR query.\n  ** For example, the query:\n  **\n  **         \"w\" NEAR \"x\" NEAR \"y\" NEAR \"z\"\n  **\n  ** which is represented in tree form as:\n  **\n  **                               |\n  **                          +--NEAR--+      <-- root of NEAR query\n  **                          |        |\n  **                     +--NEAR--+   \"z\"\n  **                     |        |\n  **                +--NEAR--+   \"y\"\n  **                |        |\n  **               \"w\"      \"x\"\n  **\n  ** The right-hand child of a NEAR node is always a phrase. The \n  ** left-hand child may be either a phrase or a NEAR node. There are\n  ** no exceptions to this - it's the way the parser in fts3_expr.c works.\n  */\n  if( *pRc==SQLITE_OK \n   && pExpr->eType==FTSQUERY_NEAR \n   && (pExpr->pParent==0 || pExpr->pParent->eType!=FTSQUERY_NEAR)\n  ){\n    Fts3Expr *p; \n    sqlite3_int64 nTmp = 0;       /* Bytes of temp space */\n    char *aTmp;                   /* Temp space for PoslistNearMerge() */\n\n    /* Allocate temporary working space. */\n    for(p=pExpr; p->pLeft; p=p->pLeft){\n      assert( p->pRight->pPhrase->doclist.nList>0 );\n      nTmp += p->pRight->pPhrase->doclist.nList;\n    }\n    nTmp += p->pPhrase->doclist.nList;\n    aTmp = sqlite3_malloc64(nTmp*2);\n    if( !aTmp ){\n      *pRc = SQLITE_NOMEM;\n      res = 0;\n    }else{\n      char *aPoslist = p->pPhrase->doclist.pList;\n      int nToken = p->pPhrase->nToken;\n\n      for(p=p->pParent;res && p && p->eType==FTSQUERY_NEAR; p=p->pParent){\n        Fts3Phrase *pPhrase = p->pRight->pPhrase;\n        int nNear = p->nNear;\n        res = fts3EvalNearTrim(nNear, aTmp, &aPoslist, &nToken, pPhrase);\n      }\n\n      aPoslist = pExpr->pRight->pPhrase->doclist.pList;\n      nToken = pExpr->pRight->pPhrase->nToken;\n      for(p=pExpr->pLeft; p && res; p=p->pLeft){\n        int nNear;\n        Fts3Phrase *pPhrase;\n        assert( p->pParent && p->pParent->pLeft==p );\n        nNear = p->pParent->nNear;\n        pPhrase = (\n            p->eType==FTSQUERY_NEAR ? p->pRight->pPhrase : p->pPhrase\n        );\n        res = fts3EvalNearTrim(nNear, aTmp, &aPoslist, &nToken, pPhrase);\n      }\n    }\n\n    sqlite3_free(aTmp);\n  }\n\n  return res;\n}\n\n/*\n** This function is a helper function for sqlite3Fts3EvalTestDeferred().\n** Assuming no error occurs or has occurred, It returns non-zero if the\n** expression passed as the second argument matches the row that pCsr \n** currently points to, or zero if it does not.\n**\n** If *pRc is not SQLITE_OK when this function is called, it is a no-op.\n** If an error occurs during execution of this function, *pRc is set to \n** the appropriate SQLite error code. In this case the returned value is \n** undefined.\n*/\nstatic int fts3EvalTestExpr(\n  Fts3Cursor *pCsr,               /* FTS cursor handle */\n  Fts3Expr *pExpr,                /* Expr to test. May or may not be root. */\n  int *pRc                        /* IN/OUT: Error code */\n){\n  int bHit = 1;                   /* Return value */\n  if( *pRc==SQLITE_OK ){\n    switch( pExpr->eType ){\n      case FTSQUERY_NEAR:\n      case FTSQUERY_AND:\n        bHit = (\n            fts3EvalTestExpr(pCsr, pExpr->pLeft, pRc)\n         && fts3EvalTestExpr(pCsr, pExpr->pRight, pRc)\n         && fts3EvalNearTest(pExpr, pRc)\n        );\n\n        /* If the NEAR expression does not match any rows, zero the doclist for \n        ** all phrases involved in the NEAR. This is because the snippet(),\n        ** offsets() and matchinfo() functions are not supposed to recognize \n        ** any instances of phrases that are part of unmatched NEAR queries. \n        ** For example if this expression:\n        **\n        **    ... MATCH 'a OR (b NEAR c)'\n        **\n        ** is matched against a row containing:\n        **\n        **        'a b d e'\n        **\n        ** then any snippet() should ony highlight the \"a\" term, not the \"b\"\n        ** (as \"b\" is part of a non-matching NEAR clause).\n        */\n        if( bHit==0 \n         && pExpr->eType==FTSQUERY_NEAR \n         && (pExpr->pParent==0 || pExpr->pParent->eType!=FTSQUERY_NEAR)\n        ){\n          Fts3Expr *p;\n          for(p=pExpr; p->pPhrase==0; p=p->pLeft){\n            if( p->pRight->iDocid==pCsr->iPrevId ){\n              fts3EvalInvalidatePoslist(p->pRight->pPhrase);\n            }\n          }\n          if( p->iDocid==pCsr->iPrevId ){\n            fts3EvalInvalidatePoslist(p->pPhrase);\n          }\n        }\n\n        break;\n\n      case FTSQUERY_OR: {\n        int bHit1 = fts3EvalTestExpr(pCsr, pExpr->pLeft, pRc);\n        int bHit2 = fts3EvalTestExpr(pCsr, pExpr->pRight, pRc);\n        bHit = bHit1 || bHit2;\n        break;\n      }\n\n      case FTSQUERY_NOT:\n        bHit = (\n            fts3EvalTestExpr(pCsr, pExpr->pLeft, pRc)\n         && !fts3EvalTestExpr(pCsr, pExpr->pRight, pRc)\n        );\n        break;\n\n      default: {\n#ifndef SQLITE_DISABLE_FTS4_DEFERRED\n        if( pCsr->pDeferred \n         && (pExpr->iDocid==pCsr->iPrevId || pExpr->bDeferred)\n        ){\n          Fts3Phrase *pPhrase = pExpr->pPhrase;\n          assert( pExpr->bDeferred || pPhrase->doclist.bFreeList==0 );\n          if( pExpr->bDeferred ){\n            fts3EvalInvalidatePoslist(pPhrase);\n          }\n          *pRc = fts3EvalDeferredPhrase(pCsr, pPhrase);\n          bHit = (pPhrase->doclist.pList!=0);\n          pExpr->iDocid = pCsr->iPrevId;\n        }else\n#endif\n        {\n          bHit = (pExpr->bEof==0 && pExpr->iDocid==pCsr->iPrevId);\n        }\n        break;\n      }\n    }\n  }\n  return bHit;\n}\n\n/*\n** This function is called as the second part of each xNext operation when\n** iterating through the results of a full-text query. At this point the\n** cursor points to a row that matches the query expression, with the\n** following caveats:\n**\n**   * Up until this point, \"NEAR\" operators in the expression have been\n**     treated as \"AND\".\n**\n**   * Deferred tokens have not yet been considered.\n**\n** If *pRc is not SQLITE_OK when this function is called, it immediately\n** returns 0. Otherwise, it tests whether or not after considering NEAR\n** operators and deferred tokens the current row is still a match for the\n** expression. It returns 1 if both of the following are true:\n**\n**   1. *pRc is SQLITE_OK when this function returns, and\n**\n**   2. After scanning the current FTS table row for the deferred tokens,\n**      it is determined that the row does *not* match the query.\n**\n** Or, if no error occurs and it seems the current row does match the FTS\n** query, return 0.\n*/\nSQLITE_PRIVATE int sqlite3Fts3EvalTestDeferred(Fts3Cursor *pCsr, int *pRc){\n  int rc = *pRc;\n  int bMiss = 0;\n  if( rc==SQLITE_OK ){\n\n    /* If there are one or more deferred tokens, load the current row into\n    ** memory and scan it to determine the position list for each deferred\n    ** token. Then, see if this row is really a match, considering deferred\n    ** tokens and NEAR operators (neither of which were taken into account\n    ** earlier, by fts3EvalNextRow()). \n    */\n    if( pCsr->pDeferred ){\n      rc = fts3CursorSeek(0, pCsr);\n      if( rc==SQLITE_OK ){\n        rc = sqlite3Fts3CacheDeferredDoclists(pCsr);\n      }\n    }\n    bMiss = (0==fts3EvalTestExpr(pCsr, pCsr->pExpr, &rc));\n\n    /* Free the position-lists accumulated for each deferred token above. */\n    sqlite3Fts3FreeDeferredDoclists(pCsr);\n    *pRc = rc;\n  }\n  return (rc==SQLITE_OK && bMiss);\n}\n\n/*\n** Advance to the next document that matches the FTS expression in\n** Fts3Cursor.pExpr.\n*/\nstatic int fts3EvalNext(Fts3Cursor *pCsr){\n  int rc = SQLITE_OK;             /* Return Code */\n  Fts3Expr *pExpr = pCsr->pExpr;\n  assert( pCsr->isEof==0 );\n  if( pExpr==0 ){\n    pCsr->isEof = 1;\n  }else{\n    do {\n      if( pCsr->isRequireSeek==0 ){\n        sqlite3_reset(pCsr->pStmt);\n      }\n      assert( sqlite3_data_count(pCsr->pStmt)==0 );\n      fts3EvalNextRow(pCsr, pExpr, &rc);\n      pCsr->isEof = pExpr->bEof;\n      pCsr->isRequireSeek = 1;\n      pCsr->isMatchinfoNeeded = 1;\n      pCsr->iPrevId = pExpr->iDocid;\n    }while( pCsr->isEof==0 && sqlite3Fts3EvalTestDeferred(pCsr, &rc) );\n  }\n\n  /* Check if the cursor is past the end of the docid range specified\n  ** by Fts3Cursor.iMinDocid/iMaxDocid. If so, set the EOF flag.  */\n  if( rc==SQLITE_OK && (\n        (pCsr->bDesc==0 && pCsr->iPrevId>pCsr->iMaxDocid)\n     || (pCsr->bDesc!=0 && pCsr->iPrevId<pCsr->iMinDocid)\n  )){\n    pCsr->isEof = 1;\n  }\n\n  return rc;\n}\n\n/*\n** Restart interation for expression pExpr so that the next call to\n** fts3EvalNext() visits the first row. Do not allow incremental \n** loading or merging of phrase doclists for this iteration.\n**\n** If *pRc is other than SQLITE_OK when this function is called, it is\n** a no-op. If an error occurs within this function, *pRc is set to an\n** SQLite error code before returning.\n*/\nstatic void fts3EvalRestart(\n  Fts3Cursor *pCsr,\n  Fts3Expr *pExpr,\n  int *pRc\n){\n  if( pExpr && *pRc==SQLITE_OK ){\n    Fts3Phrase *pPhrase = pExpr->pPhrase;\n\n    if( pPhrase ){\n      fts3EvalInvalidatePoslist(pPhrase);\n      if( pPhrase->bIncr ){\n        int i;\n        for(i=0; i<pPhrase->nToken; i++){\n          Fts3PhraseToken *pToken = &pPhrase->aToken[i];\n          assert( pToken->pDeferred==0 );\n          if( pToken->pSegcsr ){\n            sqlite3Fts3MsrIncrRestart(pToken->pSegcsr);\n          }\n        }\n        *pRc = fts3EvalPhraseStart(pCsr, 0, pPhrase);\n      }\n      pPhrase->doclist.pNextDocid = 0;\n      pPhrase->doclist.iDocid = 0;\n      pPhrase->pOrPoslist = 0;\n    }\n\n    pExpr->iDocid = 0;\n    pExpr->bEof = 0;\n    pExpr->bStart = 0;\n\n    fts3EvalRestart(pCsr, pExpr->pLeft, pRc);\n    fts3EvalRestart(pCsr, pExpr->pRight, pRc);\n  }\n}\n\n/*\n** After allocating the Fts3Expr.aMI[] array for each phrase in the \n** expression rooted at pExpr, the cursor iterates through all rows matched\n** by pExpr, calling this function for each row. This function increments\n** the values in Fts3Expr.aMI[] according to the position-list currently\n** found in Fts3Expr.pPhrase->doclist.pList for each of the phrase \n** expression nodes.\n*/\nstatic void fts3EvalUpdateCounts(Fts3Expr *pExpr, int nCol){\n  if( pExpr ){\n    Fts3Phrase *pPhrase = pExpr->pPhrase;\n    if( pPhrase && pPhrase->doclist.pList ){\n      int iCol = 0;\n      char *p = pPhrase->doclist.pList;\n\n      do{\n        u8 c = 0;\n        int iCnt = 0;\n        while( 0xFE & (*p | c) ){\n          if( (c&0x80)==0 ) iCnt++;\n          c = *p++ & 0x80;\n        }\n\n        /* aMI[iCol*3 + 1] = Number of occurrences\n        ** aMI[iCol*3 + 2] = Number of rows containing at least one instance\n        */\n        pExpr->aMI[iCol*3 + 1] += iCnt;\n        pExpr->aMI[iCol*3 + 2] += (iCnt>0);\n        if( *p==0x00 ) break;\n        p++;\n        p += fts3GetVarint32(p, &iCol);\n      }while( iCol<nCol );\n    }\n\n    fts3EvalUpdateCounts(pExpr->pLeft, nCol);\n    fts3EvalUpdateCounts(pExpr->pRight, nCol);\n  }\n}\n\n/*\n** Expression pExpr must be of type FTSQUERY_PHRASE.\n**\n** If it is not already allocated and populated, this function allocates and\n** populates the Fts3Expr.aMI[] array for expression pExpr. If pExpr is part\n** of a NEAR expression, then it also allocates and populates the same array\n** for all other phrases that are part of the NEAR expression.\n**\n** SQLITE_OK is returned if the aMI[] array is successfully allocated and\n** populated. Otherwise, if an error occurs, an SQLite error code is returned.\n*/\nstatic int fts3EvalGatherStats(\n  Fts3Cursor *pCsr,               /* Cursor object */\n  Fts3Expr *pExpr                 /* FTSQUERY_PHRASE expression */\n){\n  int rc = SQLITE_OK;             /* Return code */\n\n  assert( pExpr->eType==FTSQUERY_PHRASE );\n  if( pExpr->aMI==0 ){\n    Fts3Table *pTab = (Fts3Table *)pCsr->base.pVtab;\n    Fts3Expr *pRoot;                /* Root of NEAR expression */\n    Fts3Expr *p;                    /* Iterator used for several purposes */\n\n    sqlite3_int64 iPrevId = pCsr->iPrevId;\n    sqlite3_int64 iDocid;\n    u8 bEof;\n\n    /* Find the root of the NEAR expression */\n    pRoot = pExpr;\n    while( pRoot->pParent && pRoot->pParent->eType==FTSQUERY_NEAR ){\n      pRoot = pRoot->pParent;\n    }\n    iDocid = pRoot->iDocid;\n    bEof = pRoot->bEof;\n    assert( pRoot->bStart );\n\n    /* Allocate space for the aMSI[] array of each FTSQUERY_PHRASE node */\n    for(p=pRoot; p; p=p->pLeft){\n      Fts3Expr *pE = (p->eType==FTSQUERY_PHRASE?p:p->pRight);\n      assert( pE->aMI==0 );\n      pE->aMI = (u32 *)sqlite3_malloc64(pTab->nColumn * 3 * sizeof(u32));\n      if( !pE->aMI ) return SQLITE_NOMEM;\n      memset(pE->aMI, 0, pTab->nColumn * 3 * sizeof(u32));\n    }\n\n    fts3EvalRestart(pCsr, pRoot, &rc);\n\n    while( pCsr->isEof==0 && rc==SQLITE_OK ){\n\n      do {\n        /* Ensure the %_content statement is reset. */\n        if( pCsr->isRequireSeek==0 ) sqlite3_reset(pCsr->pStmt);\n        assert( sqlite3_data_count(pCsr->pStmt)==0 );\n\n        /* Advance to the next document */\n        fts3EvalNextRow(pCsr, pRoot, &rc);\n        pCsr->isEof = pRoot->bEof;\n        pCsr->isRequireSeek = 1;\n        pCsr->isMatchinfoNeeded = 1;\n        pCsr->iPrevId = pRoot->iDocid;\n      }while( pCsr->isEof==0 \n           && pRoot->eType==FTSQUERY_NEAR \n           && sqlite3Fts3EvalTestDeferred(pCsr, &rc) \n      );\n\n      if( rc==SQLITE_OK && pCsr->isEof==0 ){\n        fts3EvalUpdateCounts(pRoot, pTab->nColumn);\n      }\n    }\n\n    pCsr->isEof = 0;\n    pCsr->iPrevId = iPrevId;\n\n    if( bEof ){\n      pRoot->bEof = bEof;\n    }else{\n      /* Caution: pRoot may iterate through docids in ascending or descending\n      ** order. For this reason, even though it seems more defensive, the \n      ** do loop can not be written:\n      **\n      **   do {...} while( pRoot->iDocid<iDocid && rc==SQLITE_OK );\n      */\n      fts3EvalRestart(pCsr, pRoot, &rc);\n      do {\n        fts3EvalNextRow(pCsr, pRoot, &rc);\n        assert( pRoot->bEof==0 );\n      }while( pRoot->iDocid!=iDocid && rc==SQLITE_OK );\n    }\n  }\n  return rc;\n}\n\n/*\n** This function is used by the matchinfo() module to query a phrase \n** expression node for the following information:\n**\n**   1. The total number of occurrences of the phrase in each column of \n**      the FTS table (considering all rows), and\n**\n**   2. For each column, the number of rows in the table for which the\n**      column contains at least one instance of the phrase.\n**\n** If no error occurs, SQLITE_OK is returned and the values for each column\n** written into the array aiOut as follows:\n**\n**   aiOut[iCol*3 + 1] = Number of occurrences\n**   aiOut[iCol*3 + 2] = Number of rows containing at least one instance\n**\n** Caveats:\n**\n**   * If a phrase consists entirely of deferred tokens, then all output \n**     values are set to the number of documents in the table. In other\n**     words we assume that very common tokens occur exactly once in each \n**     column of each row of the table.\n**\n**   * If a phrase contains some deferred tokens (and some non-deferred \n**     tokens), count the potential occurrence identified by considering\n**     the non-deferred tokens instead of actual phrase occurrences.\n**\n**   * If the phrase is part of a NEAR expression, then only phrase instances\n**     that meet the NEAR constraint are included in the counts.\n*/\nSQLITE_PRIVATE int sqlite3Fts3EvalPhraseStats(\n  Fts3Cursor *pCsr,               /* FTS cursor handle */\n  Fts3Expr *pExpr,                /* Phrase expression */\n  u32 *aiOut                      /* Array to write results into (see above) */\n){\n  Fts3Table *pTab = (Fts3Table *)pCsr->base.pVtab;\n  int rc = SQLITE_OK;\n  int iCol;\n\n  if( pExpr->bDeferred && pExpr->pParent->eType!=FTSQUERY_NEAR ){\n    assert( pCsr->nDoc>0 );\n    for(iCol=0; iCol<pTab->nColumn; iCol++){\n      aiOut[iCol*3 + 1] = (u32)pCsr->nDoc;\n      aiOut[iCol*3 + 2] = (u32)pCsr->nDoc;\n    }\n  }else{\n    rc = fts3EvalGatherStats(pCsr, pExpr);\n    if( rc==SQLITE_OK ){\n      assert( pExpr->aMI );\n      for(iCol=0; iCol<pTab->nColumn; iCol++){\n        aiOut[iCol*3 + 1] = pExpr->aMI[iCol*3 + 1];\n        aiOut[iCol*3 + 2] = pExpr->aMI[iCol*3 + 2];\n      }\n    }\n  }\n\n  return rc;\n}\n\n/*\n** The expression pExpr passed as the second argument to this function\n** must be of type FTSQUERY_PHRASE. \n**\n** The returned value is either NULL or a pointer to a buffer containing\n** a position-list indicating the occurrences of the phrase in column iCol\n** of the current row. \n**\n** More specifically, the returned buffer contains 1 varint for each \n** occurrence of the phrase in the column, stored using the normal (delta+2) \n** compression and is terminated by either an 0x01 or 0x00 byte. For example,\n** if the requested column contains \"a b X c d X X\" and the position-list\n** for 'X' is requested, the buffer returned may contain:\n**\n**     0x04 0x05 0x03 0x01   or   0x04 0x05 0x03 0x00\n**\n** This function works regardless of whether or not the phrase is deferred,\n** incremental, or neither.\n*/\nSQLITE_PRIVATE int sqlite3Fts3EvalPhrasePoslist(\n  Fts3Cursor *pCsr,               /* FTS3 cursor object */\n  Fts3Expr *pExpr,                /* Phrase to return doclist for */\n  int iCol,                       /* Column to return position list for */\n  char **ppOut                    /* OUT: Pointer to position list */\n){\n  Fts3Phrase *pPhrase = pExpr->pPhrase;\n  Fts3Table *pTab = (Fts3Table *)pCsr->base.pVtab;\n  char *pIter;\n  int iThis;\n  sqlite3_int64 iDocid;\n\n  /* If this phrase is applies specifically to some column other than \n  ** column iCol, return a NULL pointer.  */\n  *ppOut = 0;\n  assert( iCol>=0 && iCol<pTab->nColumn );\n  if( (pPhrase->iColumn<pTab->nColumn && pPhrase->iColumn!=iCol) ){\n    return SQLITE_OK;\n  }\n\n  iDocid = pExpr->iDocid;\n  pIter = pPhrase->doclist.pList;\n  if( iDocid!=pCsr->iPrevId || pExpr->bEof ){\n    int rc = SQLITE_OK;\n    int bDescDoclist = pTab->bDescIdx;      /* For DOCID_CMP macro */\n    int bOr = 0;\n    u8 bTreeEof = 0;\n    Fts3Expr *p;                  /* Used to iterate from pExpr to root */\n    Fts3Expr *pNear;              /* Most senior NEAR ancestor (or pExpr) */\n    int bMatch;\n\n    /* Check if this phrase descends from an OR expression node. If not, \n    ** return NULL. Otherwise, the entry that corresponds to docid \n    ** pCsr->iPrevId may lie earlier in the doclist buffer. Or, if the\n    ** tree that the node is part of has been marked as EOF, but the node\n    ** itself is not EOF, then it may point to an earlier entry. */\n    pNear = pExpr;\n    for(p=pExpr->pParent; p; p=p->pParent){\n      if( p->eType==FTSQUERY_OR ) bOr = 1;\n      if( p->eType==FTSQUERY_NEAR ) pNear = p;\n      if( p->bEof ) bTreeEof = 1;\n    }\n    if( bOr==0 ) return SQLITE_OK;\n\n    /* This is the descendent of an OR node. In this case we cannot use\n    ** an incremental phrase. Load the entire doclist for the phrase\n    ** into memory in this case.  */\n    if( pPhrase->bIncr ){\n      int bEofSave = pNear->bEof;\n      fts3EvalRestart(pCsr, pNear, &rc);\n      while( rc==SQLITE_OK && !pNear->bEof ){\n        fts3EvalNextRow(pCsr, pNear, &rc);\n        if( bEofSave==0 && pNear->iDocid==iDocid ) break;\n      }\n      assert( rc!=SQLITE_OK || pPhrase->bIncr==0 );\n    }\n    if( bTreeEof ){\n      while( rc==SQLITE_OK && !pNear->bEof ){\n        fts3EvalNextRow(pCsr, pNear, &rc);\n      }\n    }\n    if( rc!=SQLITE_OK ) return rc;\n\n    bMatch = 1;\n    for(p=pNear; p; p=p->pLeft){\n      u8 bEof = 0;\n      Fts3Expr *pTest = p;\n      Fts3Phrase *pPh;\n      assert( pTest->eType==FTSQUERY_NEAR || pTest->eType==FTSQUERY_PHRASE );\n      if( pTest->eType==FTSQUERY_NEAR ) pTest = pTest->pRight;\n      assert( pTest->eType==FTSQUERY_PHRASE );\n      pPh = pTest->pPhrase;\n\n      pIter = pPh->pOrPoslist;\n      iDocid = pPh->iOrDocid;\n      if( pCsr->bDesc==bDescDoclist ){\n        bEof = !pPh->doclist.nAll ||\n          (pIter >= (pPh->doclist.aAll + pPh->doclist.nAll));\n        while( (pIter==0 || DOCID_CMP(iDocid, pCsr->iPrevId)<0 ) && bEof==0 ){\n          sqlite3Fts3DoclistNext(\n              bDescDoclist, pPh->doclist.aAll, pPh->doclist.nAll, \n              &pIter, &iDocid, &bEof\n          );\n        }\n      }else{\n        bEof = !pPh->doclist.nAll || (pIter && pIter<=pPh->doclist.aAll);\n        while( (pIter==0 || DOCID_CMP(iDocid, pCsr->iPrevId)>0 ) && bEof==0 ){\n          int dummy;\n          sqlite3Fts3DoclistPrev(\n              bDescDoclist, pPh->doclist.aAll, pPh->doclist.nAll, \n              &pIter, &iDocid, &dummy, &bEof\n              );\n        }\n      }\n      pPh->pOrPoslist = pIter;\n      pPh->iOrDocid = iDocid;\n      if( bEof || iDocid!=pCsr->iPrevId ) bMatch = 0;\n    }\n\n    if( bMatch ){\n      pIter = pPhrase->pOrPoslist;\n    }else{\n      pIter = 0;\n    }\n  }\n  if( pIter==0 ) return SQLITE_OK;\n\n  if( *pIter==0x01 ){\n    pIter++;\n    pIter += fts3GetVarint32(pIter, &iThis);\n  }else{\n    iThis = 0;\n  }\n  while( iThis<iCol ){\n    fts3ColumnlistCopy(0, &pIter);\n    if( *pIter==0x00 ) return SQLITE_OK;\n    pIter++;\n    pIter += fts3GetVarint32(pIter, &iThis);\n  }\n  if( *pIter==0x00 ){\n    pIter = 0;\n  }\n\n  *ppOut = ((iCol==iThis)?pIter:0);\n  return SQLITE_OK;\n}\n\n/*\n** Free all components of the Fts3Phrase structure that were allocated by\n** the eval module. Specifically, this means to free:\n**\n**   * the contents of pPhrase->doclist, and\n**   * any Fts3MultiSegReader objects held by phrase tokens.\n*/\nSQLITE_PRIVATE void sqlite3Fts3EvalPhraseCleanup(Fts3Phrase *pPhrase){\n  if( pPhrase ){\n    int i;\n    sqlite3_free(pPhrase->doclist.aAll);\n    fts3EvalInvalidatePoslist(pPhrase);\n    memset(&pPhrase->doclist, 0, sizeof(Fts3Doclist));\n    for(i=0; i<pPhrase->nToken; i++){\n      fts3SegReaderCursorFree(pPhrase->aToken[i].pSegcsr);\n      pPhrase->aToken[i].pSegcsr = 0;\n    }\n  }\n}\n\n\n/*\n** Return SQLITE_CORRUPT_VTAB.\n*/\n#ifdef SQLITE_DEBUG\nSQLITE_PRIVATE int sqlite3Fts3Corrupt(){\n  return SQLITE_CORRUPT_VTAB;\n}\n#endif\n\n#if !SQLITE_CORE\n/*\n** Initialize API pointer table, if required.\n*/\n#ifdef _WIN32\n__declspec(dllexport)\n#endif\nSQLITE_API int sqlite3_fts3_init(\n  sqlite3 *db, \n  char **pzErrMsg,\n  const sqlite3_api_routines *pApi\n){\n  SQLITE_EXTENSION_INIT2(pApi)\n  return sqlite3Fts3Init(db);\n}\n#endif\n\n#endif\n\n/************** End of fts3.c ************************************************/\n/************** Begin file fts3_aux.c ****************************************/\n/*\n** 2011 Jan 27\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n******************************************************************************\n**\n*/\n/* #include \"fts3Int.h\" */\n#if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3)\n\n/* #include <string.h> */\n/* #include <assert.h> */\n\ntypedef struct Fts3auxTable Fts3auxTable;\ntypedef struct Fts3auxCursor Fts3auxCursor;\n\nstruct Fts3auxTable {\n  sqlite3_vtab base;              /* Base class used by SQLite core */\n  Fts3Table *pFts3Tab;\n};\n\nstruct Fts3auxCursor {\n  sqlite3_vtab_cursor base;       /* Base class used by SQLite core */\n  Fts3MultiSegReader csr;        /* Must be right after \"base\" */\n  Fts3SegFilter filter;\n  char *zStop;\n  int nStop;                      /* Byte-length of string zStop */\n  int iLangid;                    /* Language id to query */\n  int isEof;                      /* True if cursor is at EOF */\n  sqlite3_int64 iRowid;           /* Current rowid */\n\n  int iCol;                       /* Current value of 'col' column */\n  int nStat;                      /* Size of aStat[] array */\n  struct Fts3auxColstats {\n    sqlite3_int64 nDoc;           /* 'documents' values for current csr row */\n    sqlite3_int64 nOcc;           /* 'occurrences' values for current csr row */\n  } *aStat;\n};\n\n/*\n** Schema of the terms table.\n*/\n#define FTS3_AUX_SCHEMA \\\n  \"CREATE TABLE x(term, col, documents, occurrences, languageid HIDDEN)\"\n\n/*\n** This function does all the work for both the xConnect and xCreate methods.\n** These tables have no persistent representation of their own, so xConnect\n** and xCreate are identical operations.\n*/\nstatic int fts3auxConnectMethod(\n  sqlite3 *db,                    /* Database connection */\n  void *pUnused,                  /* Unused */\n  int argc,                       /* Number of elements in argv array */\n  const char * const *argv,       /* xCreate/xConnect argument array */\n  sqlite3_vtab **ppVtab,          /* OUT: New sqlite3_vtab object */\n  char **pzErr                    /* OUT: sqlite3_malloc'd error message */\n){\n  char const *zDb;                /* Name of database (e.g. \"main\") */\n  char const *zFts3;              /* Name of fts3 table */\n  int nDb;                        /* Result of strlen(zDb) */\n  int nFts3;                      /* Result of strlen(zFts3) */\n  sqlite3_int64 nByte;            /* Bytes of space to allocate here */\n  int rc;                         /* value returned by declare_vtab() */\n  Fts3auxTable *p;                /* Virtual table object to return */\n\n  UNUSED_PARAMETER(pUnused);\n\n  /* The user should invoke this in one of two forms:\n  **\n  **     CREATE VIRTUAL TABLE xxx USING fts4aux(fts4-table);\n  **     CREATE VIRTUAL TABLE xxx USING fts4aux(fts4-table-db, fts4-table);\n  */\n  if( argc!=4 && argc!=5 ) goto bad_args;\n\n  zDb = argv[1]; \n  nDb = (int)strlen(zDb);\n  if( argc==5 ){\n    if( nDb==4 && 0==sqlite3_strnicmp(\"temp\", zDb, 4) ){\n      zDb = argv[3]; \n      nDb = (int)strlen(zDb);\n      zFts3 = argv[4];\n    }else{\n      goto bad_args;\n    }\n  }else{\n    zFts3 = argv[3];\n  }\n  nFts3 = (int)strlen(zFts3);\n\n  rc = sqlite3_declare_vtab(db, FTS3_AUX_SCHEMA);\n  if( rc!=SQLITE_OK ) return rc;\n\n  nByte = sizeof(Fts3auxTable) + sizeof(Fts3Table) + nDb + nFts3 + 2;\n  p = (Fts3auxTable *)sqlite3_malloc64(nByte);\n  if( !p ) return SQLITE_NOMEM;\n  memset(p, 0, nByte);\n\n  p->pFts3Tab = (Fts3Table *)&p[1];\n  p->pFts3Tab->zDb = (char *)&p->pFts3Tab[1];\n  p->pFts3Tab->zName = &p->pFts3Tab->zDb[nDb+1];\n  p->pFts3Tab->db = db;\n  p->pFts3Tab->nIndex = 1;\n\n  memcpy((char *)p->pFts3Tab->zDb, zDb, nDb);\n  memcpy((char *)p->pFts3Tab->zName, zFts3, nFts3);\n  sqlite3Fts3Dequote((char *)p->pFts3Tab->zName);\n\n  *ppVtab = (sqlite3_vtab *)p;\n  return SQLITE_OK;\n\n bad_args:\n  sqlite3Fts3ErrMsg(pzErr, \"invalid arguments to fts4aux constructor\");\n  return SQLITE_ERROR;\n}\n\n/*\n** This function does the work for both the xDisconnect and xDestroy methods.\n** These tables have no persistent representation of their own, so xDisconnect\n** and xDestroy are identical operations.\n*/\nstatic int fts3auxDisconnectMethod(sqlite3_vtab *pVtab){\n  Fts3auxTable *p = (Fts3auxTable *)pVtab;\n  Fts3Table *pFts3 = p->pFts3Tab;\n  int i;\n\n  /* Free any prepared statements held */\n  for(i=0; i<SizeofArray(pFts3->aStmt); i++){\n    sqlite3_finalize(pFts3->aStmt[i]);\n  }\n  sqlite3_free(pFts3->zSegmentsTbl);\n  sqlite3_free(p);\n  return SQLITE_OK;\n}\n\n#define FTS4AUX_EQ_CONSTRAINT 1\n#define FTS4AUX_GE_CONSTRAINT 2\n#define FTS4AUX_LE_CONSTRAINT 4\n\n/*\n** xBestIndex - Analyze a WHERE and ORDER BY clause.\n*/\nstatic int fts3auxBestIndexMethod(\n  sqlite3_vtab *pVTab, \n  sqlite3_index_info *pInfo\n){\n  int i;\n  int iEq = -1;\n  int iGe = -1;\n  int iLe = -1;\n  int iLangid = -1;\n  int iNext = 1;                  /* Next free argvIndex value */\n\n  UNUSED_PARAMETER(pVTab);\n\n  /* This vtab delivers always results in \"ORDER BY term ASC\" order. */\n  if( pInfo->nOrderBy==1 \n   && pInfo->aOrderBy[0].iColumn==0 \n   && pInfo->aOrderBy[0].desc==0\n  ){\n    pInfo->orderByConsumed = 1;\n  }\n\n  /* Search for equality and range constraints on the \"term\" column. \n  ** And equality constraints on the hidden \"languageid\" column. */\n  for(i=0; i<pInfo->nConstraint; i++){\n    if( pInfo->aConstraint[i].usable ){\n      int op = pInfo->aConstraint[i].op;\n      int iCol = pInfo->aConstraint[i].iColumn;\n\n      if( iCol==0 ){\n        if( op==SQLITE_INDEX_CONSTRAINT_EQ ) iEq = i;\n        if( op==SQLITE_INDEX_CONSTRAINT_LT ) iLe = i;\n        if( op==SQLITE_INDEX_CONSTRAINT_LE ) iLe = i;\n        if( op==SQLITE_INDEX_CONSTRAINT_GT ) iGe = i;\n        if( op==SQLITE_INDEX_CONSTRAINT_GE ) iGe = i;\n      }\n      if( iCol==4 ){\n        if( op==SQLITE_INDEX_CONSTRAINT_EQ ) iLangid = i;\n      }\n    }\n  }\n\n  if( iEq>=0 ){\n    pInfo->idxNum = FTS4AUX_EQ_CONSTRAINT;\n    pInfo->aConstraintUsage[iEq].argvIndex = iNext++;\n    pInfo->estimatedCost = 5;\n  }else{\n    pInfo->idxNum = 0;\n    pInfo->estimatedCost = 20000;\n    if( iGe>=0 ){\n      pInfo->idxNum += FTS4AUX_GE_CONSTRAINT;\n      pInfo->aConstraintUsage[iGe].argvIndex = iNext++;\n      pInfo->estimatedCost /= 2;\n    }\n    if( iLe>=0 ){\n      pInfo->idxNum += FTS4AUX_LE_CONSTRAINT;\n      pInfo->aConstraintUsage[iLe].argvIndex = iNext++;\n      pInfo->estimatedCost /= 2;\n    }\n  }\n  if( iLangid>=0 ){\n    pInfo->aConstraintUsage[iLangid].argvIndex = iNext++;\n    pInfo->estimatedCost--;\n  }\n\n  return SQLITE_OK;\n}\n\n/*\n** xOpen - Open a cursor.\n*/\nstatic int fts3auxOpenMethod(sqlite3_vtab *pVTab, sqlite3_vtab_cursor **ppCsr){\n  Fts3auxCursor *pCsr;            /* Pointer to cursor object to return */\n\n  UNUSED_PARAMETER(pVTab);\n\n  pCsr = (Fts3auxCursor *)sqlite3_malloc(sizeof(Fts3auxCursor));\n  if( !pCsr ) return SQLITE_NOMEM;\n  memset(pCsr, 0, sizeof(Fts3auxCursor));\n\n  *ppCsr = (sqlite3_vtab_cursor *)pCsr;\n  return SQLITE_OK;\n}\n\n/*\n** xClose - Close a cursor.\n*/\nstatic int fts3auxCloseMethod(sqlite3_vtab_cursor *pCursor){\n  Fts3Table *pFts3 = ((Fts3auxTable *)pCursor->pVtab)->pFts3Tab;\n  Fts3auxCursor *pCsr = (Fts3auxCursor *)pCursor;\n\n  sqlite3Fts3SegmentsClose(pFts3);\n  sqlite3Fts3SegReaderFinish(&pCsr->csr);\n  sqlite3_free((void *)pCsr->filter.zTerm);\n  sqlite3_free(pCsr->zStop);\n  sqlite3_free(pCsr->aStat);\n  sqlite3_free(pCsr);\n  return SQLITE_OK;\n}\n\nstatic int fts3auxGrowStatArray(Fts3auxCursor *pCsr, int nSize){\n  if( nSize>pCsr->nStat ){\n    struct Fts3auxColstats *aNew;\n    aNew = (struct Fts3auxColstats *)sqlite3_realloc64(pCsr->aStat, \n        sizeof(struct Fts3auxColstats) * nSize\n    );\n    if( aNew==0 ) return SQLITE_NOMEM;\n    memset(&aNew[pCsr->nStat], 0, \n        sizeof(struct Fts3auxColstats) * (nSize - pCsr->nStat)\n    );\n    pCsr->aStat = aNew;\n    pCsr->nStat = nSize;\n  }\n  return SQLITE_OK;\n}\n\n/*\n** xNext - Advance the cursor to the next row, if any.\n*/\nstatic int fts3auxNextMethod(sqlite3_vtab_cursor *pCursor){\n  Fts3auxCursor *pCsr = (Fts3auxCursor *)pCursor;\n  Fts3Table *pFts3 = ((Fts3auxTable *)pCursor->pVtab)->pFts3Tab;\n  int rc;\n\n  /* Increment our pretend rowid value. */\n  pCsr->iRowid++;\n\n  for(pCsr->iCol++; pCsr->iCol<pCsr->nStat; pCsr->iCol++){\n    if( pCsr->aStat[pCsr->iCol].nDoc>0 ) return SQLITE_OK;\n  }\n\n  rc = sqlite3Fts3SegReaderStep(pFts3, &pCsr->csr);\n  if( rc==SQLITE_ROW ){\n    int i = 0;\n    int nDoclist = pCsr->csr.nDoclist;\n    char *aDoclist = pCsr->csr.aDoclist;\n    int iCol;\n\n    int eState = 0;\n\n    if( pCsr->zStop ){\n      int n = (pCsr->nStop<pCsr->csr.nTerm) ? pCsr->nStop : pCsr->csr.nTerm;\n      int mc = memcmp(pCsr->zStop, pCsr->csr.zTerm, n);\n      if( mc<0 || (mc==0 && pCsr->csr.nTerm>pCsr->nStop) ){\n        pCsr->isEof = 1;\n        return SQLITE_OK;\n      }\n    }\n\n    if( fts3auxGrowStatArray(pCsr, 2) ) return SQLITE_NOMEM;\n    memset(pCsr->aStat, 0, sizeof(struct Fts3auxColstats) * pCsr->nStat);\n    iCol = 0;\n\n    while( i<nDoclist ){\n      sqlite3_int64 v = 0;\n\n      i += sqlite3Fts3GetVarint(&aDoclist[i], &v);\n      switch( eState ){\n        /* State 0. In this state the integer just read was a docid. */\n        case 0:\n          pCsr->aStat[0].nDoc++;\n          eState = 1;\n          iCol = 0;\n          break;\n\n        /* State 1. In this state we are expecting either a 1, indicating\n        ** that the following integer will be a column number, or the\n        ** start of a position list for column 0.  \n        ** \n        ** The only difference between state 1 and state 2 is that if the\n        ** integer encountered in state 1 is not 0 or 1, then we need to\n        ** increment the column 0 \"nDoc\" count for this term.\n        */\n        case 1:\n          assert( iCol==0 );\n          if( v>1 ){\n            pCsr->aStat[1].nDoc++;\n          }\n          eState = 2;\n          /* fall through */\n\n        case 2:\n          if( v==0 ){       /* 0x00. Next integer will be a docid. */\n            eState = 0;\n          }else if( v==1 ){ /* 0x01. Next integer will be a column number. */\n            eState = 3;\n          }else{            /* 2 or greater. A position. */\n            pCsr->aStat[iCol+1].nOcc++;\n            pCsr->aStat[0].nOcc++;\n          }\n          break;\n\n        /* State 3. The integer just read is a column number. */\n        default: assert( eState==3 );\n          iCol = (int)v;\n          if( fts3auxGrowStatArray(pCsr, iCol+2) ) return SQLITE_NOMEM;\n          pCsr->aStat[iCol+1].nDoc++;\n          eState = 2;\n          break;\n      }\n    }\n\n    pCsr->iCol = 0;\n    rc = SQLITE_OK;\n  }else{\n    pCsr->isEof = 1;\n  }\n  return rc;\n}\n\n/*\n** xFilter - Initialize a cursor to point at the start of its data.\n*/\nstatic int fts3auxFilterMethod(\n  sqlite3_vtab_cursor *pCursor,   /* The cursor used for this query */\n  int idxNum,                     /* Strategy index */\n  const char *idxStr,             /* Unused */\n  int nVal,                       /* Number of elements in apVal */\n  sqlite3_value **apVal           /* Arguments for the indexing scheme */\n){\n  Fts3auxCursor *pCsr = (Fts3auxCursor *)pCursor;\n  Fts3Table *pFts3 = ((Fts3auxTable *)pCursor->pVtab)->pFts3Tab;\n  int rc;\n  int isScan = 0;\n  int iLangVal = 0;               /* Language id to query */\n\n  int iEq = -1;                   /* Index of term=? value in apVal */\n  int iGe = -1;                   /* Index of term>=? value in apVal */\n  int iLe = -1;                   /* Index of term<=? value in apVal */\n  int iLangid = -1;               /* Index of languageid=? value in apVal */\n  int iNext = 0;\n\n  UNUSED_PARAMETER(nVal);\n  UNUSED_PARAMETER(idxStr);\n\n  assert( idxStr==0 );\n  assert( idxNum==FTS4AUX_EQ_CONSTRAINT || idxNum==0\n       || idxNum==FTS4AUX_LE_CONSTRAINT || idxNum==FTS4AUX_GE_CONSTRAINT\n       || idxNum==(FTS4AUX_LE_CONSTRAINT|FTS4AUX_GE_CONSTRAINT)\n  );\n\n  if( idxNum==FTS4AUX_EQ_CONSTRAINT ){\n    iEq = iNext++;\n  }else{\n    isScan = 1;\n    if( idxNum & FTS4AUX_GE_CONSTRAINT ){\n      iGe = iNext++;\n    }\n    if( idxNum & FTS4AUX_LE_CONSTRAINT ){\n      iLe = iNext++;\n    }\n  }\n  if( iNext<nVal ){\n    iLangid = iNext++;\n  }\n\n  /* In case this cursor is being reused, close and zero it. */\n  testcase(pCsr->filter.zTerm);\n  sqlite3Fts3SegReaderFinish(&pCsr->csr);\n  sqlite3_free((void *)pCsr->filter.zTerm);\n  sqlite3_free(pCsr->aStat);\n  memset(&pCsr->csr, 0, ((u8*)&pCsr[1]) - (u8*)&pCsr->csr);\n\n  pCsr->filter.flags = FTS3_SEGMENT_REQUIRE_POS|FTS3_SEGMENT_IGNORE_EMPTY;\n  if( isScan ) pCsr->filter.flags |= FTS3_SEGMENT_SCAN;\n\n  if( iEq>=0 || iGe>=0 ){\n    const unsigned char *zStr = sqlite3_value_text(apVal[0]);\n    assert( (iEq==0 && iGe==-1) || (iEq==-1 && iGe==0) );\n    if( zStr ){\n      pCsr->filter.zTerm = sqlite3_mprintf(\"%s\", zStr);\n      if( pCsr->filter.zTerm==0 ) return SQLITE_NOMEM;\n      pCsr->filter.nTerm = (int)strlen(pCsr->filter.zTerm);\n    }\n  }\n\n  if( iLe>=0 ){\n    pCsr->zStop = sqlite3_mprintf(\"%s\", sqlite3_value_text(apVal[iLe]));\n    if( pCsr->zStop==0 ) return SQLITE_NOMEM;\n    pCsr->nStop = (int)strlen(pCsr->zStop);\n  }\n  \n  if( iLangid>=0 ){\n    iLangVal = sqlite3_value_int(apVal[iLangid]);\n\n    /* If the user specified a negative value for the languageid, use zero\n    ** instead. This works, as the \"languageid=?\" constraint will also\n    ** be tested by the VDBE layer. The test will always be false (since\n    ** this module will not return a row with a negative languageid), and\n    ** so the overall query will return zero rows.  */\n    if( iLangVal<0 ) iLangVal = 0;\n  }\n  pCsr->iLangid = iLangVal;\n\n  rc = sqlite3Fts3SegReaderCursor(pFts3, iLangVal, 0, FTS3_SEGCURSOR_ALL,\n      pCsr->filter.zTerm, pCsr->filter.nTerm, 0, isScan, &pCsr->csr\n  );\n  if( rc==SQLITE_OK ){\n    rc = sqlite3Fts3SegReaderStart(pFts3, &pCsr->csr, &pCsr->filter);\n  }\n\n  if( rc==SQLITE_OK ) rc = fts3auxNextMethod(pCursor);\n  return rc;\n}\n\n/*\n** xEof - Return true if the cursor is at EOF, or false otherwise.\n*/\nstatic int fts3auxEofMethod(sqlite3_vtab_cursor *pCursor){\n  Fts3auxCursor *pCsr = (Fts3auxCursor *)pCursor;\n  return pCsr->isEof;\n}\n\n/*\n** xColumn - Return a column value.\n*/\nstatic int fts3auxColumnMethod(\n  sqlite3_vtab_cursor *pCursor,   /* Cursor to retrieve value from */\n  sqlite3_context *pCtx,          /* Context for sqlite3_result_xxx() calls */\n  int iCol                        /* Index of column to read value from */\n){\n  Fts3auxCursor *p = (Fts3auxCursor *)pCursor;\n\n  assert( p->isEof==0 );\n  switch( iCol ){\n    case 0: /* term */\n      sqlite3_result_text(pCtx, p->csr.zTerm, p->csr.nTerm, SQLITE_TRANSIENT);\n      break;\n\n    case 1: /* col */\n      if( p->iCol ){\n        sqlite3_result_int(pCtx, p->iCol-1);\n      }else{\n        sqlite3_result_text(pCtx, \"*\", -1, SQLITE_STATIC);\n      }\n      break;\n\n    case 2: /* documents */\n      sqlite3_result_int64(pCtx, p->aStat[p->iCol].nDoc);\n      break;\n\n    case 3: /* occurrences */\n      sqlite3_result_int64(pCtx, p->aStat[p->iCol].nOcc);\n      break;\n\n    default: /* languageid */\n      assert( iCol==4 );\n      sqlite3_result_int(pCtx, p->iLangid);\n      break;\n  }\n\n  return SQLITE_OK;\n}\n\n/*\n** xRowid - Return the current rowid for the cursor.\n*/\nstatic int fts3auxRowidMethod(\n  sqlite3_vtab_cursor *pCursor,   /* Cursor to retrieve value from */\n  sqlite_int64 *pRowid            /* OUT: Rowid value */\n){\n  Fts3auxCursor *pCsr = (Fts3auxCursor *)pCursor;\n  *pRowid = pCsr->iRowid;\n  return SQLITE_OK;\n}\n\n/*\n** Register the fts3aux module with database connection db. Return SQLITE_OK\n** if successful or an error code if sqlite3_create_module() fails.\n*/\nSQLITE_PRIVATE int sqlite3Fts3InitAux(sqlite3 *db){\n  static const sqlite3_module fts3aux_module = {\n     0,                           /* iVersion      */\n     fts3auxConnectMethod,        /* xCreate       */\n     fts3auxConnectMethod,        /* xConnect      */\n     fts3auxBestIndexMethod,      /* xBestIndex    */\n     fts3auxDisconnectMethod,     /* xDisconnect   */\n     fts3auxDisconnectMethod,     /* xDestroy      */\n     fts3auxOpenMethod,           /* xOpen         */\n     fts3auxCloseMethod,          /* xClose        */\n     fts3auxFilterMethod,         /* xFilter       */\n     fts3auxNextMethod,           /* xNext         */\n     fts3auxEofMethod,            /* xEof          */\n     fts3auxColumnMethod,         /* xColumn       */\n     fts3auxRowidMethod,          /* xRowid        */\n     0,                           /* xUpdate       */\n     0,                           /* xBegin        */\n     0,                           /* xSync         */\n     0,                           /* xCommit       */\n     0,                           /* xRollback     */\n     0,                           /* xFindFunction */\n     0,                           /* xRename       */\n     0,                           /* xSavepoint    */\n     0,                           /* xRelease      */\n     0,                           /* xRollbackTo   */\n     0                            /* xShadowName   */\n  };\n  int rc;                         /* Return code */\n\n  rc = sqlite3_create_module(db, \"fts4aux\", &fts3aux_module, 0);\n  return rc;\n}\n\n#endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3) */\n\n/************** End of fts3_aux.c ********************************************/\n/************** Begin file fts3_expr.c ***************************************/\n/*\n** 2008 Nov 28\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n******************************************************************************\n**\n** This module contains code that implements a parser for fts3 query strings\n** (the right-hand argument to the MATCH operator). Because the supported \n** syntax is relatively simple, the whole tokenizer/parser system is\n** hand-coded. \n*/\n/* #include \"fts3Int.h\" */\n#if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3)\n\n/*\n** By default, this module parses the legacy syntax that has been \n** traditionally used by fts3. Or, if SQLITE_ENABLE_FTS3_PARENTHESIS\n** is defined, then it uses the new syntax. The differences between\n** the new and the old syntaxes are:\n**\n**  a) The new syntax supports parenthesis. The old does not.\n**\n**  b) The new syntax supports the AND and NOT operators. The old does not.\n**\n**  c) The old syntax supports the \"-\" token qualifier. This is not \n**     supported by the new syntax (it is replaced by the NOT operator).\n**\n**  d) When using the old syntax, the OR operator has a greater precedence\n**     than an implicit AND. When using the new, both implicity and explicit\n**     AND operators have a higher precedence than OR.\n**\n** If compiled with SQLITE_TEST defined, then this module exports the\n** symbol \"int sqlite3_fts3_enable_parentheses\". Setting this variable\n** to zero causes the module to use the old syntax. If it is set to \n** non-zero the new syntax is activated. This is so both syntaxes can\n** be tested using a single build of testfixture.\n**\n** The following describes the syntax supported by the fts3 MATCH\n** operator in a similar format to that used by the lemon parser\n** generator. This module does not use actually lemon, it uses a\n** custom parser.\n**\n**   query ::= andexpr (OR andexpr)*.\n**\n**   andexpr ::= notexpr (AND? notexpr)*.\n**\n**   notexpr ::= nearexpr (NOT nearexpr|-TOKEN)*.\n**   notexpr ::= LP query RP.\n**\n**   nearexpr ::= phrase (NEAR distance_opt nearexpr)*.\n**\n**   distance_opt ::= .\n**   distance_opt ::= / INTEGER.\n**\n**   phrase ::= TOKEN.\n**   phrase ::= COLUMN:TOKEN.\n**   phrase ::= \"TOKEN TOKEN TOKEN...\".\n*/\n\n#ifdef SQLITE_TEST\nSQLITE_API int sqlite3_fts3_enable_parentheses = 0;\n#else\n# ifdef SQLITE_ENABLE_FTS3_PARENTHESIS \n#  define sqlite3_fts3_enable_parentheses 1\n# else\n#  define sqlite3_fts3_enable_parentheses 0\n# endif\n#endif\n\n/*\n** Default span for NEAR operators.\n*/\n#define SQLITE_FTS3_DEFAULT_NEAR_PARAM 10\n\n/* #include <string.h> */\n/* #include <assert.h> */\n\n/*\n** isNot:\n**   This variable is used by function getNextNode(). When getNextNode() is\n**   called, it sets ParseContext.isNot to true if the 'next node' is a \n**   FTSQUERY_PHRASE with a unary \"-\" attached to it. i.e. \"mysql\" in the\n**   FTS3 query \"sqlite -mysql\". Otherwise, ParseContext.isNot is set to\n**   zero.\n*/\ntypedef struct ParseContext ParseContext;\nstruct ParseContext {\n  sqlite3_tokenizer *pTokenizer;      /* Tokenizer module */\n  int iLangid;                        /* Language id used with tokenizer */\n  const char **azCol;                 /* Array of column names for fts3 table */\n  int bFts4;                          /* True to allow FTS4-only syntax */\n  int nCol;                           /* Number of entries in azCol[] */\n  int iDefaultCol;                    /* Default column to query */\n  int isNot;                          /* True if getNextNode() sees a unary - */\n  sqlite3_context *pCtx;              /* Write error message here */\n  int nNest;                          /* Number of nested brackets */\n};\n\n/*\n** This function is equivalent to the standard isspace() function. \n**\n** The standard isspace() can be awkward to use safely, because although it\n** is defined to accept an argument of type int, its behavior when passed\n** an integer that falls outside of the range of the unsigned char type\n** is undefined (and sometimes, \"undefined\" means segfault). This wrapper\n** is defined to accept an argument of type char, and always returns 0 for\n** any values that fall outside of the range of the unsigned char type (i.e.\n** negative values).\n*/\nstatic int fts3isspace(char c){\n  return c==' ' || c=='\\t' || c=='\\n' || c=='\\r' || c=='\\v' || c=='\\f';\n}\n\n/*\n** Allocate nByte bytes of memory using sqlite3_malloc(). If successful,\n** zero the memory before returning a pointer to it. If unsuccessful, \n** return NULL.\n*/\nstatic void *fts3MallocZero(sqlite3_int64 nByte){\n  void *pRet = sqlite3_malloc64(nByte);\n  if( pRet ) memset(pRet, 0, nByte);\n  return pRet;\n}\n\nSQLITE_PRIVATE int sqlite3Fts3OpenTokenizer(\n  sqlite3_tokenizer *pTokenizer,\n  int iLangid,\n  const char *z,\n  int n,\n  sqlite3_tokenizer_cursor **ppCsr\n){\n  sqlite3_tokenizer_module const *pModule = pTokenizer->pModule;\n  sqlite3_tokenizer_cursor *pCsr = 0;\n  int rc;\n\n  rc = pModule->xOpen(pTokenizer, z, n, &pCsr);\n  assert( rc==SQLITE_OK || pCsr==0 );\n  if( rc==SQLITE_OK ){\n    pCsr->pTokenizer = pTokenizer;\n    if( pModule->iVersion>=1 ){\n      rc = pModule->xLanguageid(pCsr, iLangid);\n      if( rc!=SQLITE_OK ){\n        pModule->xClose(pCsr);\n        pCsr = 0;\n      }\n    }\n  }\n  *ppCsr = pCsr;\n  return rc;\n}\n\n/*\n** Function getNextNode(), which is called by fts3ExprParse(), may itself\n** call fts3ExprParse(). So this forward declaration is required.\n*/\nstatic int fts3ExprParse(ParseContext *, const char *, int, Fts3Expr **, int *);\n\n/*\n** Extract the next token from buffer z (length n) using the tokenizer\n** and other information (column names etc.) in pParse. Create an Fts3Expr\n** structure of type FTSQUERY_PHRASE containing a phrase consisting of this\n** single token and set *ppExpr to point to it. If the end of the buffer is\n** reached before a token is found, set *ppExpr to zero. It is the\n** responsibility of the caller to eventually deallocate the allocated \n** Fts3Expr structure (if any) by passing it to sqlite3_free().\n**\n** Return SQLITE_OK if successful, or SQLITE_NOMEM if a memory allocation\n** fails.\n*/\nstatic int getNextToken(\n  ParseContext *pParse,                   /* fts3 query parse context */\n  int iCol,                               /* Value for Fts3Phrase.iColumn */\n  const char *z, int n,                   /* Input string */\n  Fts3Expr **ppExpr,                      /* OUT: expression */\n  int *pnConsumed                         /* OUT: Number of bytes consumed */\n){\n  sqlite3_tokenizer *pTokenizer = pParse->pTokenizer;\n  sqlite3_tokenizer_module const *pModule = pTokenizer->pModule;\n  int rc;\n  sqlite3_tokenizer_cursor *pCursor;\n  Fts3Expr *pRet = 0;\n  int i = 0;\n\n  /* Set variable i to the maximum number of bytes of input to tokenize. */\n  for(i=0; i<n; i++){\n    if( sqlite3_fts3_enable_parentheses && (z[i]=='(' || z[i]==')') ) break;\n    if( z[i]=='\"' ) break;\n  }\n\n  *pnConsumed = i;\n  rc = sqlite3Fts3OpenTokenizer(pTokenizer, pParse->iLangid, z, i, &pCursor);\n  if( rc==SQLITE_OK ){\n    const char *zToken;\n    int nToken = 0, iStart = 0, iEnd = 0, iPosition = 0;\n    sqlite3_int64 nByte;                    /* total space to allocate */\n\n    rc = pModule->xNext(pCursor, &zToken, &nToken, &iStart, &iEnd, &iPosition);\n    if( rc==SQLITE_OK ){\n      nByte = sizeof(Fts3Expr) + sizeof(Fts3Phrase) + nToken;\n      pRet = (Fts3Expr *)fts3MallocZero(nByte);\n      if( !pRet ){\n        rc = SQLITE_NOMEM;\n      }else{\n        pRet->eType = FTSQUERY_PHRASE;\n        pRet->pPhrase = (Fts3Phrase *)&pRet[1];\n        pRet->pPhrase->nToken = 1;\n        pRet->pPhrase->iColumn = iCol;\n        pRet->pPhrase->aToken[0].n = nToken;\n        pRet->pPhrase->aToken[0].z = (char *)&pRet->pPhrase[1];\n        memcpy(pRet->pPhrase->aToken[0].z, zToken, nToken);\n\n        if( iEnd<n && z[iEnd]=='*' ){\n          pRet->pPhrase->aToken[0].isPrefix = 1;\n          iEnd++;\n        }\n\n        while( 1 ){\n          if( !sqlite3_fts3_enable_parentheses \n           && iStart>0 && z[iStart-1]=='-' \n          ){\n            pParse->isNot = 1;\n            iStart--;\n          }else if( pParse->bFts4 && iStart>0 && z[iStart-1]=='^' ){\n            pRet->pPhrase->aToken[0].bFirst = 1;\n            iStart--;\n          }else{\n            break;\n          }\n        }\n\n      }\n      *pnConsumed = iEnd;\n    }else if( i && rc==SQLITE_DONE ){\n      rc = SQLITE_OK;\n    }\n\n    pModule->xClose(pCursor);\n  }\n  \n  *ppExpr = pRet;\n  return rc;\n}\n\n\n/*\n** Enlarge a memory allocation.  If an out-of-memory allocation occurs,\n** then free the old allocation.\n*/\nstatic void *fts3ReallocOrFree(void *pOrig, sqlite3_int64 nNew){\n  void *pRet = sqlite3_realloc64(pOrig, nNew);\n  if( !pRet ){\n    sqlite3_free(pOrig);\n  }\n  return pRet;\n}\n\n/*\n** Buffer zInput, length nInput, contains the contents of a quoted string\n** that appeared as part of an fts3 query expression. Neither quote character\n** is included in the buffer. This function attempts to tokenize the entire\n** input buffer and create an Fts3Expr structure of type FTSQUERY_PHRASE \n** containing the results.\n**\n** If successful, SQLITE_OK is returned and *ppExpr set to point at the\n** allocated Fts3Expr structure. Otherwise, either SQLITE_NOMEM (out of memory\n** error) or SQLITE_ERROR (tokenization error) is returned and *ppExpr set\n** to 0.\n*/\nstatic int getNextString(\n  ParseContext *pParse,                   /* fts3 query parse context */\n  const char *zInput, int nInput,         /* Input string */\n  Fts3Expr **ppExpr                       /* OUT: expression */\n){\n  sqlite3_tokenizer *pTokenizer = pParse->pTokenizer;\n  sqlite3_tokenizer_module const *pModule = pTokenizer->pModule;\n  int rc;\n  Fts3Expr *p = 0;\n  sqlite3_tokenizer_cursor *pCursor = 0;\n  char *zTemp = 0;\n  int nTemp = 0;\n\n  const int nSpace = sizeof(Fts3Expr) + sizeof(Fts3Phrase);\n  int nToken = 0;\n\n  /* The final Fts3Expr data structure, including the Fts3Phrase,\n  ** Fts3PhraseToken structures token buffers are all stored as a single \n  ** allocation so that the expression can be freed with a single call to\n  ** sqlite3_free(). Setting this up requires a two pass approach.\n  **\n  ** The first pass, in the block below, uses a tokenizer cursor to iterate\n  ** through the tokens in the expression. This pass uses fts3ReallocOrFree()\n  ** to assemble data in two dynamic buffers:\n  **\n  **   Buffer p: Points to the Fts3Expr structure, followed by the Fts3Phrase\n  **             structure, followed by the array of Fts3PhraseToken \n  **             structures. This pass only populates the Fts3PhraseToken array.\n  **\n  **   Buffer zTemp: Contains copies of all tokens.\n  **\n  ** The second pass, in the block that begins \"if( rc==SQLITE_DONE )\" below,\n  ** appends buffer zTemp to buffer p, and fills in the Fts3Expr and Fts3Phrase\n  ** structures.\n  */\n  rc = sqlite3Fts3OpenTokenizer(\n      pTokenizer, pParse->iLangid, zInput, nInput, &pCursor);\n  if( rc==SQLITE_OK ){\n    int ii;\n    for(ii=0; rc==SQLITE_OK; ii++){\n      const char *zByte;\n      int nByte = 0, iBegin = 0, iEnd = 0, iPos = 0;\n      rc = pModule->xNext(pCursor, &zByte, &nByte, &iBegin, &iEnd, &iPos);\n      if( rc==SQLITE_OK ){\n        Fts3PhraseToken *pToken;\n\n        p = fts3ReallocOrFree(p, nSpace + ii*sizeof(Fts3PhraseToken));\n        if( !p ) goto no_mem;\n\n        zTemp = fts3ReallocOrFree(zTemp, nTemp + nByte);\n        if( !zTemp ) goto no_mem;\n\n        assert( nToken==ii );\n        pToken = &((Fts3Phrase *)(&p[1]))->aToken[ii];\n        memset(pToken, 0, sizeof(Fts3PhraseToken));\n\n        memcpy(&zTemp[nTemp], zByte, nByte);\n        nTemp += nByte;\n\n        pToken->n = nByte;\n        pToken->isPrefix = (iEnd<nInput && zInput[iEnd]=='*');\n        pToken->bFirst = (iBegin>0 && zInput[iBegin-1]=='^');\n        nToken = ii+1;\n      }\n    }\n\n    pModule->xClose(pCursor);\n    pCursor = 0;\n  }\n\n  if( rc==SQLITE_DONE ){\n    int jj;\n    char *zBuf = 0;\n\n    p = fts3ReallocOrFree(p, nSpace + nToken*sizeof(Fts3PhraseToken) + nTemp);\n    if( !p ) goto no_mem;\n    memset(p, 0, (char *)&(((Fts3Phrase *)&p[1])->aToken[0])-(char *)p);\n    p->eType = FTSQUERY_PHRASE;\n    p->pPhrase = (Fts3Phrase *)&p[1];\n    p->pPhrase->iColumn = pParse->iDefaultCol;\n    p->pPhrase->nToken = nToken;\n\n    zBuf = (char *)&p->pPhrase->aToken[nToken];\n    if( zTemp ){\n      memcpy(zBuf, zTemp, nTemp);\n      sqlite3_free(zTemp);\n    }else{\n      assert( nTemp==0 );\n    }\n\n    for(jj=0; jj<p->pPhrase->nToken; jj++){\n      p->pPhrase->aToken[jj].z = zBuf;\n      zBuf += p->pPhrase->aToken[jj].n;\n    }\n    rc = SQLITE_OK;\n  }\n\n  *ppExpr = p;\n  return rc;\nno_mem:\n\n  if( pCursor ){\n    pModule->xClose(pCursor);\n  }\n  sqlite3_free(zTemp);\n  sqlite3_free(p);\n  *ppExpr = 0;\n  return SQLITE_NOMEM;\n}\n\n/*\n** The output variable *ppExpr is populated with an allocated Fts3Expr \n** structure, or set to 0 if the end of the input buffer is reached.\n**\n** Returns an SQLite error code. SQLITE_OK if everything works, SQLITE_NOMEM\n** if a malloc failure occurs, or SQLITE_ERROR if a parse error is encountered.\n** If SQLITE_ERROR is returned, pContext is populated with an error message.\n*/\nstatic int getNextNode(\n  ParseContext *pParse,                   /* fts3 query parse context */\n  const char *z, int n,                   /* Input string */\n  Fts3Expr **ppExpr,                      /* OUT: expression */\n  int *pnConsumed                         /* OUT: Number of bytes consumed */\n){\n  static const struct Fts3Keyword {\n    char *z;                              /* Keyword text */\n    unsigned char n;                      /* Length of the keyword */\n    unsigned char parenOnly;              /* Only valid in paren mode */\n    unsigned char eType;                  /* Keyword code */\n  } aKeyword[] = {\n    { \"OR\" ,  2, 0, FTSQUERY_OR   },\n    { \"AND\",  3, 1, FTSQUERY_AND  },\n    { \"NOT\",  3, 1, FTSQUERY_NOT  },\n    { \"NEAR\", 4, 0, FTSQUERY_NEAR }\n  };\n  int ii;\n  int iCol;\n  int iColLen;\n  int rc;\n  Fts3Expr *pRet = 0;\n\n  const char *zInput = z;\n  int nInput = n;\n\n  pParse->isNot = 0;\n\n  /* Skip over any whitespace before checking for a keyword, an open or\n  ** close bracket, or a quoted string. \n  */\n  while( nInput>0 && fts3isspace(*zInput) ){\n    nInput--;\n    zInput++;\n  }\n  if( nInput==0 ){\n    return SQLITE_DONE;\n  }\n\n  /* See if we are dealing with a keyword. */\n  for(ii=0; ii<(int)(sizeof(aKeyword)/sizeof(struct Fts3Keyword)); ii++){\n    const struct Fts3Keyword *pKey = &aKeyword[ii];\n\n    if( (pKey->parenOnly & ~sqlite3_fts3_enable_parentheses)!=0 ){\n      continue;\n    }\n\n    if( nInput>=pKey->n && 0==memcmp(zInput, pKey->z, pKey->n) ){\n      int nNear = SQLITE_FTS3_DEFAULT_NEAR_PARAM;\n      int nKey = pKey->n;\n      char cNext;\n\n      /* If this is a \"NEAR\" keyword, check for an explicit nearness. */\n      if( pKey->eType==FTSQUERY_NEAR ){\n        assert( nKey==4 );\n        if( zInput[4]=='/' && zInput[5]>='0' && zInput[5]<='9' ){\n          nNear = 0;\n          for(nKey=5; zInput[nKey]>='0' && zInput[nKey]<='9'; nKey++){\n            nNear = nNear * 10 + (zInput[nKey] - '0');\n          }\n        }\n      }\n\n      /* At this point this is probably a keyword. But for that to be true,\n      ** the next byte must contain either whitespace, an open or close\n      ** parenthesis, a quote character, or EOF. \n      */\n      cNext = zInput[nKey];\n      if( fts3isspace(cNext) \n       || cNext=='\"' || cNext=='(' || cNext==')' || cNext==0\n      ){\n        pRet = (Fts3Expr *)fts3MallocZero(sizeof(Fts3Expr));\n        if( !pRet ){\n          return SQLITE_NOMEM;\n        }\n        pRet->eType = pKey->eType;\n        pRet->nNear = nNear;\n        *ppExpr = pRet;\n        *pnConsumed = (int)((zInput - z) + nKey);\n        return SQLITE_OK;\n      }\n\n      /* Turns out that wasn't a keyword after all. This happens if the\n      ** user has supplied a token such as \"ORacle\". Continue.\n      */\n    }\n  }\n\n  /* See if we are dealing with a quoted phrase. If this is the case, then\n  ** search for the closing quote and pass the whole string to getNextString()\n  ** for processing. This is easy to do, as fts3 has no syntax for escaping\n  ** a quote character embedded in a string.\n  */\n  if( *zInput=='\"' ){\n    for(ii=1; ii<nInput && zInput[ii]!='\"'; ii++);\n    *pnConsumed = (int)((zInput - z) + ii + 1);\n    if( ii==nInput ){\n      return SQLITE_ERROR;\n    }\n    return getNextString(pParse, &zInput[1], ii-1, ppExpr);\n  }\n\n  if( sqlite3_fts3_enable_parentheses ){\n    if( *zInput=='(' ){\n      int nConsumed = 0;\n      pParse->nNest++;\n      rc = fts3ExprParse(pParse, zInput+1, nInput-1, ppExpr, &nConsumed);\n      *pnConsumed = (int)(zInput - z) + 1 + nConsumed;\n      return rc;\n    }else if( *zInput==')' ){\n      pParse->nNest--;\n      *pnConsumed = (int)((zInput - z) + 1);\n      *ppExpr = 0;\n      return SQLITE_DONE;\n    }\n  }\n\n  /* If control flows to this point, this must be a regular token, or \n  ** the end of the input. Read a regular token using the sqlite3_tokenizer\n  ** interface. Before doing so, figure out if there is an explicit\n  ** column specifier for the token. \n  **\n  ** TODO: Strangely, it is not possible to associate a column specifier\n  ** with a quoted phrase, only with a single token. Not sure if this was\n  ** an implementation artifact or an intentional decision when fts3 was\n  ** first implemented. Whichever it was, this module duplicates the \n  ** limitation.\n  */\n  iCol = pParse->iDefaultCol;\n  iColLen = 0;\n  for(ii=0; ii<pParse->nCol; ii++){\n    const char *zStr = pParse->azCol[ii];\n    int nStr = (int)strlen(zStr);\n    if( nInput>nStr && zInput[nStr]==':' \n     && sqlite3_strnicmp(zStr, zInput, nStr)==0 \n    ){\n      iCol = ii;\n      iColLen = (int)((zInput - z) + nStr + 1);\n      break;\n    }\n  }\n  rc = getNextToken(pParse, iCol, &z[iColLen], n-iColLen, ppExpr, pnConsumed);\n  *pnConsumed += iColLen;\n  return rc;\n}\n\n/*\n** The argument is an Fts3Expr structure for a binary operator (any type\n** except an FTSQUERY_PHRASE). Return an integer value representing the\n** precedence of the operator. Lower values have a higher precedence (i.e.\n** group more tightly). For example, in the C language, the == operator\n** groups more tightly than ||, and would therefore have a higher precedence.\n**\n** When using the new fts3 query syntax (when SQLITE_ENABLE_FTS3_PARENTHESIS\n** is defined), the order of the operators in precedence from highest to\n** lowest is:\n**\n**   NEAR\n**   NOT\n**   AND (including implicit ANDs)\n**   OR\n**\n** Note that when using the old query syntax, the OR operator has a higher\n** precedence than the AND operator.\n*/\nstatic int opPrecedence(Fts3Expr *p){\n  assert( p->eType!=FTSQUERY_PHRASE );\n  if( sqlite3_fts3_enable_parentheses ){\n    return p->eType;\n  }else if( p->eType==FTSQUERY_NEAR ){\n    return 1;\n  }else if( p->eType==FTSQUERY_OR ){\n    return 2;\n  }\n  assert( p->eType==FTSQUERY_AND );\n  return 3;\n}\n\n/*\n** Argument ppHead contains a pointer to the current head of a query \n** expression tree being parsed. pPrev is the expression node most recently\n** inserted into the tree. This function adds pNew, which is always a binary\n** operator node, into the expression tree based on the relative precedence\n** of pNew and the existing nodes of the tree. This may result in the head\n** of the tree changing, in which case *ppHead is set to the new root node.\n*/\nstatic void insertBinaryOperator(\n  Fts3Expr **ppHead,       /* Pointer to the root node of a tree */\n  Fts3Expr *pPrev,         /* Node most recently inserted into the tree */\n  Fts3Expr *pNew           /* New binary node to insert into expression tree */\n){\n  Fts3Expr *pSplit = pPrev;\n  while( pSplit->pParent && opPrecedence(pSplit->pParent)<=opPrecedence(pNew) ){\n    pSplit = pSplit->pParent;\n  }\n\n  if( pSplit->pParent ){\n    assert( pSplit->pParent->pRight==pSplit );\n    pSplit->pParent->pRight = pNew;\n    pNew->pParent = pSplit->pParent;\n  }else{\n    *ppHead = pNew;\n  }\n  pNew->pLeft = pSplit;\n  pSplit->pParent = pNew;\n}\n\n/*\n** Parse the fts3 query expression found in buffer z, length n. This function\n** returns either when the end of the buffer is reached or an unmatched \n** closing bracket - ')' - is encountered.\n**\n** If successful, SQLITE_OK is returned, *ppExpr is set to point to the\n** parsed form of the expression and *pnConsumed is set to the number of\n** bytes read from buffer z. Otherwise, *ppExpr is set to 0 and SQLITE_NOMEM\n** (out of memory error) or SQLITE_ERROR (parse error) is returned.\n*/\nstatic int fts3ExprParse(\n  ParseContext *pParse,                   /* fts3 query parse context */\n  const char *z, int n,                   /* Text of MATCH query */\n  Fts3Expr **ppExpr,                      /* OUT: Parsed query structure */\n  int *pnConsumed                         /* OUT: Number of bytes consumed */\n){\n  Fts3Expr *pRet = 0;\n  Fts3Expr *pPrev = 0;\n  Fts3Expr *pNotBranch = 0;               /* Only used in legacy parse mode */\n  int nIn = n;\n  const char *zIn = z;\n  int rc = SQLITE_OK;\n  int isRequirePhrase = 1;\n\n  while( rc==SQLITE_OK ){\n    Fts3Expr *p = 0;\n    int nByte = 0;\n\n    rc = getNextNode(pParse, zIn, nIn, &p, &nByte);\n    assert( nByte>0 || (rc!=SQLITE_OK && p==0) );\n    if( rc==SQLITE_OK ){\n      if( p ){\n        int isPhrase;\n\n        if( !sqlite3_fts3_enable_parentheses \n            && p->eType==FTSQUERY_PHRASE && pParse->isNot \n        ){\n          /* Create an implicit NOT operator. */\n          Fts3Expr *pNot = fts3MallocZero(sizeof(Fts3Expr));\n          if( !pNot ){\n            sqlite3Fts3ExprFree(p);\n            rc = SQLITE_NOMEM;\n            goto exprparse_out;\n          }\n          pNot->eType = FTSQUERY_NOT;\n          pNot->pRight = p;\n          p->pParent = pNot;\n          if( pNotBranch ){\n            pNot->pLeft = pNotBranch;\n            pNotBranch->pParent = pNot;\n          }\n          pNotBranch = pNot;\n          p = pPrev;\n        }else{\n          int eType = p->eType;\n          isPhrase = (eType==FTSQUERY_PHRASE || p->pLeft);\n\n          /* The isRequirePhrase variable is set to true if a phrase or\n          ** an expression contained in parenthesis is required. If a\n          ** binary operator (AND, OR, NOT or NEAR) is encounted when\n          ** isRequirePhrase is set, this is a syntax error.\n          */\n          if( !isPhrase && isRequirePhrase ){\n            sqlite3Fts3ExprFree(p);\n            rc = SQLITE_ERROR;\n            goto exprparse_out;\n          }\n\n          if( isPhrase && !isRequirePhrase ){\n            /* Insert an implicit AND operator. */\n            Fts3Expr *pAnd;\n            assert( pRet && pPrev );\n            pAnd = fts3MallocZero(sizeof(Fts3Expr));\n            if( !pAnd ){\n              sqlite3Fts3ExprFree(p);\n              rc = SQLITE_NOMEM;\n              goto exprparse_out;\n            }\n            pAnd->eType = FTSQUERY_AND;\n            insertBinaryOperator(&pRet, pPrev, pAnd);\n            pPrev = pAnd;\n          }\n\n          /* This test catches attempts to make either operand of a NEAR\n           ** operator something other than a phrase. For example, either of\n           ** the following:\n           **\n           **    (bracketed expression) NEAR phrase\n           **    phrase NEAR (bracketed expression)\n           **\n           ** Return an error in either case.\n           */\n          if( pPrev && (\n            (eType==FTSQUERY_NEAR && !isPhrase && pPrev->eType!=FTSQUERY_PHRASE)\n         || (eType!=FTSQUERY_PHRASE && isPhrase && pPrev->eType==FTSQUERY_NEAR)\n          )){\n            sqlite3Fts3ExprFree(p);\n            rc = SQLITE_ERROR;\n            goto exprparse_out;\n          }\n\n          if( isPhrase ){\n            if( pRet ){\n              assert( pPrev && pPrev->pLeft && pPrev->pRight==0 );\n              pPrev->pRight = p;\n              p->pParent = pPrev;\n            }else{\n              pRet = p;\n            }\n          }else{\n            insertBinaryOperator(&pRet, pPrev, p);\n          }\n          isRequirePhrase = !isPhrase;\n        }\n        pPrev = p;\n      }\n      assert( nByte>0 );\n    }\n    assert( rc!=SQLITE_OK || (nByte>0 && nByte<=nIn) );\n    nIn -= nByte;\n    zIn += nByte;\n  }\n\n  if( rc==SQLITE_DONE && pRet && isRequirePhrase ){\n    rc = SQLITE_ERROR;\n  }\n\n  if( rc==SQLITE_DONE ){\n    rc = SQLITE_OK;\n    if( !sqlite3_fts3_enable_parentheses && pNotBranch ){\n      if( !pRet ){\n        rc = SQLITE_ERROR;\n      }else{\n        Fts3Expr *pIter = pNotBranch;\n        while( pIter->pLeft ){\n          pIter = pIter->pLeft;\n        }\n        pIter->pLeft = pRet;\n        pRet->pParent = pIter;\n        pRet = pNotBranch;\n      }\n    }\n  }\n  *pnConsumed = n - nIn;\n\nexprparse_out:\n  if( rc!=SQLITE_OK ){\n    sqlite3Fts3ExprFree(pRet);\n    sqlite3Fts3ExprFree(pNotBranch);\n    pRet = 0;\n  }\n  *ppExpr = pRet;\n  return rc;\n}\n\n/*\n** Return SQLITE_ERROR if the maximum depth of the expression tree passed \n** as the only argument is more than nMaxDepth.\n*/\nstatic int fts3ExprCheckDepth(Fts3Expr *p, int nMaxDepth){\n  int rc = SQLITE_OK;\n  if( p ){\n    if( nMaxDepth<0 ){ \n      rc = SQLITE_TOOBIG;\n    }else{\n      rc = fts3ExprCheckDepth(p->pLeft, nMaxDepth-1);\n      if( rc==SQLITE_OK ){\n        rc = fts3ExprCheckDepth(p->pRight, nMaxDepth-1);\n      }\n    }\n  }\n  return rc;\n}\n\n/*\n** This function attempts to transform the expression tree at (*pp) to\n** an equivalent but more balanced form. The tree is modified in place.\n** If successful, SQLITE_OK is returned and (*pp) set to point to the \n** new root expression node. \n**\n** nMaxDepth is the maximum allowable depth of the balanced sub-tree.\n**\n** Otherwise, if an error occurs, an SQLite error code is returned and \n** expression (*pp) freed.\n*/\nstatic int fts3ExprBalance(Fts3Expr **pp, int nMaxDepth){\n  int rc = SQLITE_OK;             /* Return code */\n  Fts3Expr *pRoot = *pp;          /* Initial root node */\n  Fts3Expr *pFree = 0;            /* List of free nodes. Linked by pParent. */\n  int eType = pRoot->eType;       /* Type of node in this tree */\n\n  if( nMaxDepth==0 ){\n    rc = SQLITE_ERROR;\n  }\n\n  if( rc==SQLITE_OK ){\n    if( (eType==FTSQUERY_AND || eType==FTSQUERY_OR) ){\n      Fts3Expr **apLeaf;\n      apLeaf = (Fts3Expr **)sqlite3_malloc64(sizeof(Fts3Expr *) * nMaxDepth);\n      if( 0==apLeaf ){\n        rc = SQLITE_NOMEM;\n      }else{\n        memset(apLeaf, 0, sizeof(Fts3Expr *) * nMaxDepth);\n      }\n\n      if( rc==SQLITE_OK ){\n        int i;\n        Fts3Expr *p;\n\n        /* Set $p to point to the left-most leaf in the tree of eType nodes. */\n        for(p=pRoot; p->eType==eType; p=p->pLeft){\n          assert( p->pParent==0 || p->pParent->pLeft==p );\n          assert( p->pLeft && p->pRight );\n        }\n\n        /* This loop runs once for each leaf in the tree of eType nodes. */\n        while( 1 ){\n          int iLvl;\n          Fts3Expr *pParent = p->pParent;     /* Current parent of p */\n\n          assert( pParent==0 || pParent->pLeft==p );\n          p->pParent = 0;\n          if( pParent ){\n            pParent->pLeft = 0;\n          }else{\n            pRoot = 0;\n          }\n          rc = fts3ExprBalance(&p, nMaxDepth-1);\n          if( rc!=SQLITE_OK ) break;\n\n          for(iLvl=0; p && iLvl<nMaxDepth; iLvl++){\n            if( apLeaf[iLvl]==0 ){\n              apLeaf[iLvl] = p;\n              p = 0;\n            }else{\n              assert( pFree );\n              pFree->pLeft = apLeaf[iLvl];\n              pFree->pRight = p;\n              pFree->pLeft->pParent = pFree;\n              pFree->pRight->pParent = pFree;\n\n              p = pFree;\n              pFree = pFree->pParent;\n              p->pParent = 0;\n              apLeaf[iLvl] = 0;\n            }\n          }\n          if( p ){\n            sqlite3Fts3ExprFree(p);\n            rc = SQLITE_TOOBIG;\n            break;\n          }\n\n          /* If that was the last leaf node, break out of the loop */\n          if( pParent==0 ) break;\n\n          /* Set $p to point to the next leaf in the tree of eType nodes */\n          for(p=pParent->pRight; p->eType==eType; p=p->pLeft);\n\n          /* Remove pParent from the original tree. */\n          assert( pParent->pParent==0 || pParent->pParent->pLeft==pParent );\n          pParent->pRight->pParent = pParent->pParent;\n          if( pParent->pParent ){\n            pParent->pParent->pLeft = pParent->pRight;\n          }else{\n            assert( pParent==pRoot );\n            pRoot = pParent->pRight;\n          }\n\n          /* Link pParent into the free node list. It will be used as an\n          ** internal node of the new tree.  */\n          pParent->pParent = pFree;\n          pFree = pParent;\n        }\n\n        if( rc==SQLITE_OK ){\n          p = 0;\n          for(i=0; i<nMaxDepth; i++){\n            if( apLeaf[i] ){\n              if( p==0 ){\n                p = apLeaf[i];\n                p->pParent = 0;\n              }else{\n                assert( pFree!=0 );\n                pFree->pRight = p;\n                pFree->pLeft = apLeaf[i];\n                pFree->pLeft->pParent = pFree;\n                pFree->pRight->pParent = pFree;\n\n                p = pFree;\n                pFree = pFree->pParent;\n                p->pParent = 0;\n              }\n            }\n          }\n          pRoot = p;\n        }else{\n          /* An error occurred. Delete the contents of the apLeaf[] array \n          ** and pFree list. Everything else is cleaned up by the call to\n          ** sqlite3Fts3ExprFree(pRoot) below.  */\n          Fts3Expr *pDel;\n          for(i=0; i<nMaxDepth; i++){\n            sqlite3Fts3ExprFree(apLeaf[i]);\n          }\n          while( (pDel=pFree)!=0 ){\n            pFree = pDel->pParent;\n            sqlite3_free(pDel);\n          }\n        }\n\n        assert( pFree==0 );\n        sqlite3_free( apLeaf );\n      }\n    }else if( eType==FTSQUERY_NOT ){\n      Fts3Expr *pLeft = pRoot->pLeft;\n      Fts3Expr *pRight = pRoot->pRight;\n\n      pRoot->pLeft = 0;\n      pRoot->pRight = 0;\n      pLeft->pParent = 0;\n      pRight->pParent = 0;\n\n      rc = fts3ExprBalance(&pLeft, nMaxDepth-1);\n      if( rc==SQLITE_OK ){\n        rc = fts3ExprBalance(&pRight, nMaxDepth-1);\n      }\n\n      if( rc!=SQLITE_OK ){\n        sqlite3Fts3ExprFree(pRight);\n        sqlite3Fts3ExprFree(pLeft);\n      }else{\n        assert( pLeft && pRight );\n        pRoot->pLeft = pLeft;\n        pLeft->pParent = pRoot;\n        pRoot->pRight = pRight;\n        pRight->pParent = pRoot;\n      }\n    }\n  }\n  \n  if( rc!=SQLITE_OK ){\n    sqlite3Fts3ExprFree(pRoot);\n    pRoot = 0;\n  }\n  *pp = pRoot;\n  return rc;\n}\n\n/*\n** This function is similar to sqlite3Fts3ExprParse(), with the following\n** differences:\n**\n**   1. It does not do expression rebalancing.\n**   2. It does not check that the expression does not exceed the \n**      maximum allowable depth.\n**   3. Even if it fails, *ppExpr may still be set to point to an \n**      expression tree. It should be deleted using sqlite3Fts3ExprFree()\n**      in this case.\n*/\nstatic int fts3ExprParseUnbalanced(\n  sqlite3_tokenizer *pTokenizer,      /* Tokenizer module */\n  int iLangid,                        /* Language id for tokenizer */\n  char **azCol,                       /* Array of column names for fts3 table */\n  int bFts4,                          /* True to allow FTS4-only syntax */\n  int nCol,                           /* Number of entries in azCol[] */\n  int iDefaultCol,                    /* Default column to query */\n  const char *z, int n,               /* Text of MATCH query */\n  Fts3Expr **ppExpr                   /* OUT: Parsed query structure */\n){\n  int nParsed;\n  int rc;\n  ParseContext sParse;\n\n  memset(&sParse, 0, sizeof(ParseContext));\n  sParse.pTokenizer = pTokenizer;\n  sParse.iLangid = iLangid;\n  sParse.azCol = (const char **)azCol;\n  sParse.nCol = nCol;\n  sParse.iDefaultCol = iDefaultCol;\n  sParse.bFts4 = bFts4;\n  if( z==0 ){\n    *ppExpr = 0;\n    return SQLITE_OK;\n  }\n  if( n<0 ){\n    n = (int)strlen(z);\n  }\n  rc = fts3ExprParse(&sParse, z, n, ppExpr, &nParsed);\n  assert( rc==SQLITE_OK || *ppExpr==0 );\n\n  /* Check for mismatched parenthesis */\n  if( rc==SQLITE_OK && sParse.nNest ){\n    rc = SQLITE_ERROR;\n  }\n  \n  return rc;\n}\n\n/*\n** Parameters z and n contain a pointer to and length of a buffer containing\n** an fts3 query expression, respectively. This function attempts to parse the\n** query expression and create a tree of Fts3Expr structures representing the\n** parsed expression. If successful, *ppExpr is set to point to the head\n** of the parsed expression tree and SQLITE_OK is returned. If an error\n** occurs, either SQLITE_NOMEM (out-of-memory error) or SQLITE_ERROR (parse\n** error) is returned and *ppExpr is set to 0.\n**\n** If parameter n is a negative number, then z is assumed to point to a\n** nul-terminated string and the length is determined using strlen().\n**\n** The first parameter, pTokenizer, is passed the fts3 tokenizer module to\n** use to normalize query tokens while parsing the expression. The azCol[]\n** array, which is assumed to contain nCol entries, should contain the names\n** of each column in the target fts3 table, in order from left to right. \n** Column names must be nul-terminated strings.\n**\n** The iDefaultCol parameter should be passed the index of the table column\n** that appears on the left-hand-side of the MATCH operator (the default\n** column to match against for tokens for which a column name is not explicitly\n** specified as part of the query string), or -1 if tokens may by default\n** match any table column.\n*/\nSQLITE_PRIVATE int sqlite3Fts3ExprParse(\n  sqlite3_tokenizer *pTokenizer,      /* Tokenizer module */\n  int iLangid,                        /* Language id for tokenizer */\n  char **azCol,                       /* Array of column names for fts3 table */\n  int bFts4,                          /* True to allow FTS4-only syntax */\n  int nCol,                           /* Number of entries in azCol[] */\n  int iDefaultCol,                    /* Default column to query */\n  const char *z, int n,               /* Text of MATCH query */\n  Fts3Expr **ppExpr,                  /* OUT: Parsed query structure */\n  char **pzErr                        /* OUT: Error message (sqlite3_malloc) */\n){\n  int rc = fts3ExprParseUnbalanced(\n      pTokenizer, iLangid, azCol, bFts4, nCol, iDefaultCol, z, n, ppExpr\n  );\n  \n  /* Rebalance the expression. And check that its depth does not exceed\n  ** SQLITE_FTS3_MAX_EXPR_DEPTH.  */\n  if( rc==SQLITE_OK && *ppExpr ){\n    rc = fts3ExprBalance(ppExpr, SQLITE_FTS3_MAX_EXPR_DEPTH);\n    if( rc==SQLITE_OK ){\n      rc = fts3ExprCheckDepth(*ppExpr, SQLITE_FTS3_MAX_EXPR_DEPTH);\n    }\n  }\n\n  if( rc!=SQLITE_OK ){\n    sqlite3Fts3ExprFree(*ppExpr);\n    *ppExpr = 0;\n    if( rc==SQLITE_TOOBIG ){\n      sqlite3Fts3ErrMsg(pzErr,\n          \"FTS expression tree is too large (maximum depth %d)\", \n          SQLITE_FTS3_MAX_EXPR_DEPTH\n      );\n      rc = SQLITE_ERROR;\n    }else if( rc==SQLITE_ERROR ){\n      sqlite3Fts3ErrMsg(pzErr, \"malformed MATCH expression: [%s]\", z);\n    }\n  }\n\n  return rc;\n}\n\n/*\n** Free a single node of an expression tree.\n*/\nstatic void fts3FreeExprNode(Fts3Expr *p){\n  assert( p->eType==FTSQUERY_PHRASE || p->pPhrase==0 );\n  sqlite3Fts3EvalPhraseCleanup(p->pPhrase);\n  sqlite3_free(p->aMI);\n  sqlite3_free(p);\n}\n\n/*\n** Free a parsed fts3 query expression allocated by sqlite3Fts3ExprParse().\n**\n** This function would be simpler if it recursively called itself. But\n** that would mean passing a sufficiently large expression to ExprParse()\n** could cause a stack overflow.\n*/\nSQLITE_PRIVATE void sqlite3Fts3ExprFree(Fts3Expr *pDel){\n  Fts3Expr *p;\n  assert( pDel==0 || pDel->pParent==0 );\n  for(p=pDel; p && (p->pLeft||p->pRight); p=(p->pLeft ? p->pLeft : p->pRight)){\n    assert( p->pParent==0 || p==p->pParent->pRight || p==p->pParent->pLeft );\n  }\n  while( p ){\n    Fts3Expr *pParent = p->pParent;\n    fts3FreeExprNode(p);\n    if( pParent && p==pParent->pLeft && pParent->pRight ){\n      p = pParent->pRight;\n      while( p && (p->pLeft || p->pRight) ){\n        assert( p==p->pParent->pRight || p==p->pParent->pLeft );\n        p = (p->pLeft ? p->pLeft : p->pRight);\n      }\n    }else{\n      p = pParent;\n    }\n  }\n}\n\n/****************************************************************************\n*****************************************************************************\n** Everything after this point is just test code.\n*/\n\n#ifdef SQLITE_TEST\n\n/* #include <stdio.h> */\n\n/*\n** Return a pointer to a buffer containing a text representation of the\n** expression passed as the first argument. The buffer is obtained from\n** sqlite3_malloc(). It is the responsibility of the caller to use \n** sqlite3_free() to release the memory. If an OOM condition is encountered,\n** NULL is returned.\n**\n** If the second argument is not NULL, then its contents are prepended to \n** the returned expression text and then freed using sqlite3_free().\n*/\nstatic char *exprToString(Fts3Expr *pExpr, char *zBuf){\n  if( pExpr==0 ){\n    return sqlite3_mprintf(\"\");\n  }\n  switch( pExpr->eType ){\n    case FTSQUERY_PHRASE: {\n      Fts3Phrase *pPhrase = pExpr->pPhrase;\n      int i;\n      zBuf = sqlite3_mprintf(\n          \"%zPHRASE %d 0\", zBuf, pPhrase->iColumn);\n      for(i=0; zBuf && i<pPhrase->nToken; i++){\n        zBuf = sqlite3_mprintf(\"%z %.*s%s\", zBuf, \n            pPhrase->aToken[i].n, pPhrase->aToken[i].z,\n            (pPhrase->aToken[i].isPrefix?\"+\":\"\")\n        );\n      }\n      return zBuf;\n    }\n\n    case FTSQUERY_NEAR:\n      zBuf = sqlite3_mprintf(\"%zNEAR/%d \", zBuf, pExpr->nNear);\n      break;\n    case FTSQUERY_NOT:\n      zBuf = sqlite3_mprintf(\"%zNOT \", zBuf);\n      break;\n    case FTSQUERY_AND:\n      zBuf = sqlite3_mprintf(\"%zAND \", zBuf);\n      break;\n    case FTSQUERY_OR:\n      zBuf = sqlite3_mprintf(\"%zOR \", zBuf);\n      break;\n  }\n\n  if( zBuf ) zBuf = sqlite3_mprintf(\"%z{\", zBuf);\n  if( zBuf ) zBuf = exprToString(pExpr->pLeft, zBuf);\n  if( zBuf ) zBuf = sqlite3_mprintf(\"%z} {\", zBuf);\n\n  if( zBuf ) zBuf = exprToString(pExpr->pRight, zBuf);\n  if( zBuf ) zBuf = sqlite3_mprintf(\"%z}\", zBuf);\n\n  return zBuf;\n}\n\n/*\n** This is the implementation of a scalar SQL function used to test the \n** expression parser. It should be called as follows:\n**\n**   fts3_exprtest(<tokenizer>, <expr>, <column 1>, ...);\n**\n** The first argument, <tokenizer>, is the name of the fts3 tokenizer used\n** to parse the query expression (see README.tokenizers). The second argument\n** is the query expression to parse. Each subsequent argument is the name\n** of a column of the fts3 table that the query expression may refer to.\n** For example:\n**\n**   SELECT fts3_exprtest('simple', 'Bill col2:Bloggs', 'col1', 'col2');\n*/\nstatic void fts3ExprTestCommon(\n  int bRebalance,\n  sqlite3_context *context,\n  int argc,\n  sqlite3_value **argv\n){\n  sqlite3_tokenizer *pTokenizer = 0;\n  int rc;\n  char **azCol = 0;\n  const char *zExpr;\n  int nExpr;\n  int nCol;\n  int ii;\n  Fts3Expr *pExpr;\n  char *zBuf = 0;\n  Fts3Hash *pHash = (Fts3Hash*)sqlite3_user_data(context);\n  const char *zTokenizer = 0;\n  char *zErr = 0;\n\n  if( argc<3 ){\n    sqlite3_result_error(context, \n        \"Usage: fts3_exprtest(tokenizer, expr, col1, ...\", -1\n    );\n    return;\n  }\n\n  zTokenizer = (const char*)sqlite3_value_text(argv[0]);\n  rc = sqlite3Fts3InitTokenizer(pHash, zTokenizer, &pTokenizer, &zErr);\n  if( rc!=SQLITE_OK ){\n    if( rc==SQLITE_NOMEM ){\n      sqlite3_result_error_nomem(context);\n    }else{\n      sqlite3_result_error(context, zErr, -1);\n    }\n    sqlite3_free(zErr);\n    return;\n  }\n\n  zExpr = (const char *)sqlite3_value_text(argv[1]);\n  nExpr = sqlite3_value_bytes(argv[1]);\n  nCol = argc-2;\n  azCol = (char **)sqlite3_malloc64(nCol*sizeof(char *));\n  if( !azCol ){\n    sqlite3_result_error_nomem(context);\n    goto exprtest_out;\n  }\n  for(ii=0; ii<nCol; ii++){\n    azCol[ii] = (char *)sqlite3_value_text(argv[ii+2]);\n  }\n\n  if( bRebalance ){\n    char *zDummy = 0;\n    rc = sqlite3Fts3ExprParse(\n        pTokenizer, 0, azCol, 0, nCol, nCol, zExpr, nExpr, &pExpr, &zDummy\n    );\n    assert( rc==SQLITE_OK || pExpr==0 );\n    sqlite3_free(zDummy);\n  }else{\n    rc = fts3ExprParseUnbalanced(\n        pTokenizer, 0, azCol, 0, nCol, nCol, zExpr, nExpr, &pExpr\n    );\n  }\n\n  if( rc!=SQLITE_OK && rc!=SQLITE_NOMEM ){\n    sqlite3Fts3ExprFree(pExpr);\n    sqlite3_result_error(context, \"Error parsing expression\", -1);\n  }else if( rc==SQLITE_NOMEM || !(zBuf = exprToString(pExpr, 0)) ){\n    sqlite3_result_error_nomem(context);\n  }else{\n    sqlite3_result_text(context, zBuf, -1, SQLITE_TRANSIENT);\n    sqlite3_free(zBuf);\n  }\n\n  sqlite3Fts3ExprFree(pExpr);\n\nexprtest_out:\n  if( pTokenizer ){\n    rc = pTokenizer->pModule->xDestroy(pTokenizer);\n  }\n  sqlite3_free(azCol);\n}\n\nstatic void fts3ExprTest(\n  sqlite3_context *context,\n  int argc,\n  sqlite3_value **argv\n){\n  fts3ExprTestCommon(0, context, argc, argv);\n}\nstatic void fts3ExprTestRebalance(\n  sqlite3_context *context,\n  int argc,\n  sqlite3_value **argv\n){\n  fts3ExprTestCommon(1, context, argc, argv);\n}\n\n/*\n** Register the query expression parser test function fts3_exprtest() \n** with database connection db. \n*/\nSQLITE_PRIVATE int sqlite3Fts3ExprInitTestInterface(sqlite3 *db, Fts3Hash *pHash){\n  int rc = sqlite3_create_function(\n      db, \"fts3_exprtest\", -1, SQLITE_UTF8, (void*)pHash, fts3ExprTest, 0, 0\n  );\n  if( rc==SQLITE_OK ){\n    rc = sqlite3_create_function(db, \"fts3_exprtest_rebalance\", \n        -1, SQLITE_UTF8, (void*)pHash, fts3ExprTestRebalance, 0, 0\n    );\n  }\n  return rc;\n}\n\n#endif\n#endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3) */\n\n/************** End of fts3_expr.c *******************************************/\n/************** Begin file fts3_hash.c ***************************************/\n/*\n** 2001 September 22\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This is the implementation of generic hash-tables used in SQLite.\n** We've modified it slightly to serve as a standalone hash table\n** implementation for the full-text indexing module.\n*/\n\n/*\n** The code in this file is only compiled if:\n**\n**     * The FTS3 module is being built as an extension\n**       (in which case SQLITE_CORE is not defined), or\n**\n**     * The FTS3 module is being built into the core of\n**       SQLite (in which case SQLITE_ENABLE_FTS3 is defined).\n*/\n/* #include \"fts3Int.h\" */\n#if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3)\n\n/* #include <assert.h> */\n/* #include <stdlib.h> */\n/* #include <string.h> */\n\n/* #include \"fts3_hash.h\" */\n\n/*\n** Malloc and Free functions\n*/\nstatic void *fts3HashMalloc(sqlite3_int64 n){\n  void *p = sqlite3_malloc64(n);\n  if( p ){\n    memset(p, 0, n);\n  }\n  return p;\n}\nstatic void fts3HashFree(void *p){\n  sqlite3_free(p);\n}\n\n/* Turn bulk memory into a hash table object by initializing the\n** fields of the Hash structure.\n**\n** \"pNew\" is a pointer to the hash table that is to be initialized.\n** keyClass is one of the constants \n** FTS3_HASH_BINARY or FTS3_HASH_STRING.  The value of keyClass \n** determines what kind of key the hash table will use.  \"copyKey\" is\n** true if the hash table should make its own private copy of keys and\n** false if it should just use the supplied pointer.\n*/\nSQLITE_PRIVATE void sqlite3Fts3HashInit(Fts3Hash *pNew, char keyClass, char copyKey){\n  assert( pNew!=0 );\n  assert( keyClass>=FTS3_HASH_STRING && keyClass<=FTS3_HASH_BINARY );\n  pNew->keyClass = keyClass;\n  pNew->copyKey = copyKey;\n  pNew->first = 0;\n  pNew->count = 0;\n  pNew->htsize = 0;\n  pNew->ht = 0;\n}\n\n/* Remove all entries from a hash table.  Reclaim all memory.\n** Call this routine to delete a hash table or to reset a hash table\n** to the empty state.\n*/\nSQLITE_PRIVATE void sqlite3Fts3HashClear(Fts3Hash *pH){\n  Fts3HashElem *elem;         /* For looping over all elements of the table */\n\n  assert( pH!=0 );\n  elem = pH->first;\n  pH->first = 0;\n  fts3HashFree(pH->ht);\n  pH->ht = 0;\n  pH->htsize = 0;\n  while( elem ){\n    Fts3HashElem *next_elem = elem->next;\n    if( pH->copyKey && elem->pKey ){\n      fts3HashFree(elem->pKey);\n    }\n    fts3HashFree(elem);\n    elem = next_elem;\n  }\n  pH->count = 0;\n}\n\n/*\n** Hash and comparison functions when the mode is FTS3_HASH_STRING\n*/\nstatic int fts3StrHash(const void *pKey, int nKey){\n  const char *z = (const char *)pKey;\n  unsigned h = 0;\n  if( nKey<=0 ) nKey = (int) strlen(z);\n  while( nKey > 0  ){\n    h = (h<<3) ^ h ^ *z++;\n    nKey--;\n  }\n  return (int)(h & 0x7fffffff);\n}\nstatic int fts3StrCompare(const void *pKey1, int n1, const void *pKey2, int n2){\n  if( n1!=n2 ) return 1;\n  return strncmp((const char*)pKey1,(const char*)pKey2,n1);\n}\n\n/*\n** Hash and comparison functions when the mode is FTS3_HASH_BINARY\n*/\nstatic int fts3BinHash(const void *pKey, int nKey){\n  int h = 0;\n  const char *z = (const char *)pKey;\n  while( nKey-- > 0 ){\n    h = (h<<3) ^ h ^ *(z++);\n  }\n  return h & 0x7fffffff;\n}\nstatic int fts3BinCompare(const void *pKey1, int n1, const void *pKey2, int n2){\n  if( n1!=n2 ) return 1;\n  return memcmp(pKey1,pKey2,n1);\n}\n\n/*\n** Return a pointer to the appropriate hash function given the key class.\n**\n** The C syntax in this function definition may be unfamilar to some \n** programmers, so we provide the following additional explanation:\n**\n** The name of the function is \"ftsHashFunction\".  The function takes a\n** single parameter \"keyClass\".  The return value of ftsHashFunction()\n** is a pointer to another function.  Specifically, the return value\n** of ftsHashFunction() is a pointer to a function that takes two parameters\n** with types \"const void*\" and \"int\" and returns an \"int\".\n*/\nstatic int (*ftsHashFunction(int keyClass))(const void*,int){\n  if( keyClass==FTS3_HASH_STRING ){\n    return &fts3StrHash;\n  }else{\n    assert( keyClass==FTS3_HASH_BINARY );\n    return &fts3BinHash;\n  }\n}\n\n/*\n** Return a pointer to the appropriate hash function given the key class.\n**\n** For help in interpreted the obscure C code in the function definition,\n** see the header comment on the previous function.\n*/\nstatic int (*ftsCompareFunction(int keyClass))(const void*,int,const void*,int){\n  if( keyClass==FTS3_HASH_STRING ){\n    return &fts3StrCompare;\n  }else{\n    assert( keyClass==FTS3_HASH_BINARY );\n    return &fts3BinCompare;\n  }\n}\n\n/* Link an element into the hash table\n*/\nstatic void fts3HashInsertElement(\n  Fts3Hash *pH,            /* The complete hash table */\n  struct _fts3ht *pEntry,  /* The entry into which pNew is inserted */\n  Fts3HashElem *pNew       /* The element to be inserted */\n){\n  Fts3HashElem *pHead;     /* First element already in pEntry */\n  pHead = pEntry->chain;\n  if( pHead ){\n    pNew->next = pHead;\n    pNew->prev = pHead->prev;\n    if( pHead->prev ){ pHead->prev->next = pNew; }\n    else             { pH->first = pNew; }\n    pHead->prev = pNew;\n  }else{\n    pNew->next = pH->first;\n    if( pH->first ){ pH->first->prev = pNew; }\n    pNew->prev = 0;\n    pH->first = pNew;\n  }\n  pEntry->count++;\n  pEntry->chain = pNew;\n}\n\n\n/* Resize the hash table so that it cantains \"new_size\" buckets.\n** \"new_size\" must be a power of 2.  The hash table might fail \n** to resize if sqliteMalloc() fails.\n**\n** Return non-zero if a memory allocation error occurs.\n*/\nstatic int fts3Rehash(Fts3Hash *pH, int new_size){\n  struct _fts3ht *new_ht;          /* The new hash table */\n  Fts3HashElem *elem, *next_elem;  /* For looping over existing elements */\n  int (*xHash)(const void*,int);   /* The hash function */\n\n  assert( (new_size & (new_size-1))==0 );\n  new_ht = (struct _fts3ht *)fts3HashMalloc( new_size*sizeof(struct _fts3ht) );\n  if( new_ht==0 ) return 1;\n  fts3HashFree(pH->ht);\n  pH->ht = new_ht;\n  pH->htsize = new_size;\n  xHash = ftsHashFunction(pH->keyClass);\n  for(elem=pH->first, pH->first=0; elem; elem = next_elem){\n    int h = (*xHash)(elem->pKey, elem->nKey) & (new_size-1);\n    next_elem = elem->next;\n    fts3HashInsertElement(pH, &new_ht[h], elem);\n  }\n  return 0;\n}\n\n/* This function (for internal use only) locates an element in an\n** hash table that matches the given key.  The hash for this key has\n** already been computed and is passed as the 4th parameter.\n*/\nstatic Fts3HashElem *fts3FindElementByHash(\n  const Fts3Hash *pH, /* The pH to be searched */\n  const void *pKey,   /* The key we are searching for */\n  int nKey,\n  int h               /* The hash for this key. */\n){\n  Fts3HashElem *elem;            /* Used to loop thru the element list */\n  int count;                     /* Number of elements left to test */\n  int (*xCompare)(const void*,int,const void*,int);  /* comparison function */\n\n  if( pH->ht ){\n    struct _fts3ht *pEntry = &pH->ht[h];\n    elem = pEntry->chain;\n    count = pEntry->count;\n    xCompare = ftsCompareFunction(pH->keyClass);\n    while( count-- && elem ){\n      if( (*xCompare)(elem->pKey,elem->nKey,pKey,nKey)==0 ){ \n        return elem;\n      }\n      elem = elem->next;\n    }\n  }\n  return 0;\n}\n\n/* Remove a single entry from the hash table given a pointer to that\n** element and a hash on the element's key.\n*/\nstatic void fts3RemoveElementByHash(\n  Fts3Hash *pH,         /* The pH containing \"elem\" */\n  Fts3HashElem* elem,   /* The element to be removed from the pH */\n  int h                 /* Hash value for the element */\n){\n  struct _fts3ht *pEntry;\n  if( elem->prev ){\n    elem->prev->next = elem->next; \n  }else{\n    pH->first = elem->next;\n  }\n  if( elem->next ){\n    elem->next->prev = elem->prev;\n  }\n  pEntry = &pH->ht[h];\n  if( pEntry->chain==elem ){\n    pEntry->chain = elem->next;\n  }\n  pEntry->count--;\n  if( pEntry->count<=0 ){\n    pEntry->chain = 0;\n  }\n  if( pH->copyKey && elem->pKey ){\n    fts3HashFree(elem->pKey);\n  }\n  fts3HashFree( elem );\n  pH->count--;\n  if( pH->count<=0 ){\n    assert( pH->first==0 );\n    assert( pH->count==0 );\n    fts3HashClear(pH);\n  }\n}\n\nSQLITE_PRIVATE Fts3HashElem *sqlite3Fts3HashFindElem(\n  const Fts3Hash *pH, \n  const void *pKey, \n  int nKey\n){\n  int h;                          /* A hash on key */\n  int (*xHash)(const void*,int);  /* The hash function */\n\n  if( pH==0 || pH->ht==0 ) return 0;\n  xHash = ftsHashFunction(pH->keyClass);\n  assert( xHash!=0 );\n  h = (*xHash)(pKey,nKey);\n  assert( (pH->htsize & (pH->htsize-1))==0 );\n  return fts3FindElementByHash(pH,pKey,nKey, h & (pH->htsize-1));\n}\n\n/* \n** Attempt to locate an element of the hash table pH with a key\n** that matches pKey,nKey.  Return the data for this element if it is\n** found, or NULL if there is no match.\n*/\nSQLITE_PRIVATE void *sqlite3Fts3HashFind(const Fts3Hash *pH, const void *pKey, int nKey){\n  Fts3HashElem *pElem;            /* The element that matches key (if any) */\n\n  pElem = sqlite3Fts3HashFindElem(pH, pKey, nKey);\n  return pElem ? pElem->data : 0;\n}\n\n/* Insert an element into the hash table pH.  The key is pKey,nKey\n** and the data is \"data\".\n**\n** If no element exists with a matching key, then a new\n** element is created.  A copy of the key is made if the copyKey\n** flag is set.  NULL is returned.\n**\n** If another element already exists with the same key, then the\n** new data replaces the old data and the old data is returned.\n** The key is not copied in this instance.  If a malloc fails, then\n** the new data is returned and the hash table is unchanged.\n**\n** If the \"data\" parameter to this function is NULL, then the\n** element corresponding to \"key\" is removed from the hash table.\n*/\nSQLITE_PRIVATE void *sqlite3Fts3HashInsert(\n  Fts3Hash *pH,        /* The hash table to insert into */\n  const void *pKey,    /* The key */\n  int nKey,            /* Number of bytes in the key */\n  void *data           /* The data */\n){\n  int hraw;                 /* Raw hash value of the key */\n  int h;                    /* the hash of the key modulo hash table size */\n  Fts3HashElem *elem;       /* Used to loop thru the element list */\n  Fts3HashElem *new_elem;   /* New element added to the pH */\n  int (*xHash)(const void*,int);  /* The hash function */\n\n  assert( pH!=0 );\n  xHash = ftsHashFunction(pH->keyClass);\n  assert( xHash!=0 );\n  hraw = (*xHash)(pKey, nKey);\n  assert( (pH->htsize & (pH->htsize-1))==0 );\n  h = hraw & (pH->htsize-1);\n  elem = fts3FindElementByHash(pH,pKey,nKey,h);\n  if( elem ){\n    void *old_data = elem->data;\n    if( data==0 ){\n      fts3RemoveElementByHash(pH,elem,h);\n    }else{\n      elem->data = data;\n    }\n    return old_data;\n  }\n  if( data==0 ) return 0;\n  if( (pH->htsize==0 && fts3Rehash(pH,8))\n   || (pH->count>=pH->htsize && fts3Rehash(pH, pH->htsize*2))\n  ){\n    pH->count = 0;\n    return data;\n  }\n  assert( pH->htsize>0 );\n  new_elem = (Fts3HashElem*)fts3HashMalloc( sizeof(Fts3HashElem) );\n  if( new_elem==0 ) return data;\n  if( pH->copyKey && pKey!=0 ){\n    new_elem->pKey = fts3HashMalloc( nKey );\n    if( new_elem->pKey==0 ){\n      fts3HashFree(new_elem);\n      return data;\n    }\n    memcpy((void*)new_elem->pKey, pKey, nKey);\n  }else{\n    new_elem->pKey = (void*)pKey;\n  }\n  new_elem->nKey = nKey;\n  pH->count++;\n  assert( pH->htsize>0 );\n  assert( (pH->htsize & (pH->htsize-1))==0 );\n  h = hraw & (pH->htsize-1);\n  fts3HashInsertElement(pH, &pH->ht[h], new_elem);\n  new_elem->data = data;\n  return 0;\n}\n\n#endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3) */\n\n/************** End of fts3_hash.c *******************************************/\n/************** Begin file fts3_porter.c *************************************/\n/*\n** 2006 September 30\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** Implementation of the full-text-search tokenizer that implements\n** a Porter stemmer.\n*/\n\n/*\n** The code in this file is only compiled if:\n**\n**     * The FTS3 module is being built as an extension\n**       (in which case SQLITE_CORE is not defined), or\n**\n**     * The FTS3 module is being built into the core of\n**       SQLite (in which case SQLITE_ENABLE_FTS3 is defined).\n*/\n/* #include \"fts3Int.h\" */\n#if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3)\n\n/* #include <assert.h> */\n/* #include <stdlib.h> */\n/* #include <stdio.h> */\n/* #include <string.h> */\n\n/* #include \"fts3_tokenizer.h\" */\n\n/*\n** Class derived from sqlite3_tokenizer\n*/\ntypedef struct porter_tokenizer {\n  sqlite3_tokenizer base;      /* Base class */\n} porter_tokenizer;\n\n/*\n** Class derived from sqlite3_tokenizer_cursor\n*/\ntypedef struct porter_tokenizer_cursor {\n  sqlite3_tokenizer_cursor base;\n  const char *zInput;          /* input we are tokenizing */\n  int nInput;                  /* size of the input */\n  int iOffset;                 /* current position in zInput */\n  int iToken;                  /* index of next token to be returned */\n  char *zToken;                /* storage for current token */\n  int nAllocated;              /* space allocated to zToken buffer */\n} porter_tokenizer_cursor;\n\n\n/*\n** Create a new tokenizer instance.\n*/\nstatic int porterCreate(\n  int argc, const char * const *argv,\n  sqlite3_tokenizer **ppTokenizer\n){\n  porter_tokenizer *t;\n\n  UNUSED_PARAMETER(argc);\n  UNUSED_PARAMETER(argv);\n\n  t = (porter_tokenizer *) sqlite3_malloc(sizeof(*t));\n  if( t==NULL ) return SQLITE_NOMEM;\n  memset(t, 0, sizeof(*t));\n  *ppTokenizer = &t->base;\n  return SQLITE_OK;\n}\n\n/*\n** Destroy a tokenizer\n*/\nstatic int porterDestroy(sqlite3_tokenizer *pTokenizer){\n  sqlite3_free(pTokenizer);\n  return SQLITE_OK;\n}\n\n/*\n** Prepare to begin tokenizing a particular string.  The input\n** string to be tokenized is zInput[0..nInput-1].  A cursor\n** used to incrementally tokenize this string is returned in \n** *ppCursor.\n*/\nstatic int porterOpen(\n  sqlite3_tokenizer *pTokenizer,         /* The tokenizer */\n  const char *zInput, int nInput,        /* String to be tokenized */\n  sqlite3_tokenizer_cursor **ppCursor    /* OUT: Tokenization cursor */\n){\n  porter_tokenizer_cursor *c;\n\n  UNUSED_PARAMETER(pTokenizer);\n\n  c = (porter_tokenizer_cursor *) sqlite3_malloc(sizeof(*c));\n  if( c==NULL ) return SQLITE_NOMEM;\n\n  c->zInput = zInput;\n  if( zInput==0 ){\n    c->nInput = 0;\n  }else if( nInput<0 ){\n    c->nInput = (int)strlen(zInput);\n  }else{\n    c->nInput = nInput;\n  }\n  c->iOffset = 0;                 /* start tokenizing at the beginning */\n  c->iToken = 0;\n  c->zToken = NULL;               /* no space allocated, yet. */\n  c->nAllocated = 0;\n\n  *ppCursor = &c->base;\n  return SQLITE_OK;\n}\n\n/*\n** Close a tokenization cursor previously opened by a call to\n** porterOpen() above.\n*/\nstatic int porterClose(sqlite3_tokenizer_cursor *pCursor){\n  porter_tokenizer_cursor *c = (porter_tokenizer_cursor *) pCursor;\n  sqlite3_free(c->zToken);\n  sqlite3_free(c);\n  return SQLITE_OK;\n}\n/*\n** Vowel or consonant\n*/\nstatic const char cType[] = {\n   0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0,\n   1, 1, 1, 2, 1\n};\n\n/*\n** isConsonant() and isVowel() determine if their first character in\n** the string they point to is a consonant or a vowel, according\n** to Porter ruls.  \n**\n** A consonate is any letter other than 'a', 'e', 'i', 'o', or 'u'.\n** 'Y' is a consonant unless it follows another consonant,\n** in which case it is a vowel.\n**\n** In these routine, the letters are in reverse order.  So the 'y' rule\n** is that 'y' is a consonant unless it is followed by another\n** consonent.\n*/\nstatic int isVowel(const char*);\nstatic int isConsonant(const char *z){\n  int j;\n  char x = *z;\n  if( x==0 ) return 0;\n  assert( x>='a' && x<='z' );\n  j = cType[x-'a'];\n  if( j<2 ) return j;\n  return z[1]==0 || isVowel(z + 1);\n}\nstatic int isVowel(const char *z){\n  int j;\n  char x = *z;\n  if( x==0 ) return 0;\n  assert( x>='a' && x<='z' );\n  j = cType[x-'a'];\n  if( j<2 ) return 1-j;\n  return isConsonant(z + 1);\n}\n\n/*\n** Let any sequence of one or more vowels be represented by V and let\n** C be sequence of one or more consonants.  Then every word can be\n** represented as:\n**\n**           [C] (VC){m} [V]\n**\n** In prose:  A word is an optional consonant followed by zero or\n** vowel-consonant pairs followed by an optional vowel.  \"m\" is the\n** number of vowel consonant pairs.  This routine computes the value\n** of m for the first i bytes of a word.\n**\n** Return true if the m-value for z is 1 or more.  In other words,\n** return true if z contains at least one vowel that is followed\n** by a consonant.\n**\n** In this routine z[] is in reverse order.  So we are really looking\n** for an instance of a consonant followed by a vowel.\n*/\nstatic int m_gt_0(const char *z){\n  while( isVowel(z) ){ z++; }\n  if( *z==0 ) return 0;\n  while( isConsonant(z) ){ z++; }\n  return *z!=0;\n}\n\n/* Like mgt0 above except we are looking for a value of m which is\n** exactly 1\n*/\nstatic int m_eq_1(const char *z){\n  while( isVowel(z) ){ z++; }\n  if( *z==0 ) return 0;\n  while( isConsonant(z) ){ z++; }\n  if( *z==0 ) return 0;\n  while( isVowel(z) ){ z++; }\n  if( *z==0 ) return 1;\n  while( isConsonant(z) ){ z++; }\n  return *z==0;\n}\n\n/* Like mgt0 above except we are looking for a value of m>1 instead\n** or m>0\n*/\nstatic int m_gt_1(const char *z){\n  while( isVowel(z) ){ z++; }\n  if( *z==0 ) return 0;\n  while( isConsonant(z) ){ z++; }\n  if( *z==0 ) return 0;\n  while( isVowel(z) ){ z++; }\n  if( *z==0 ) return 0;\n  while( isConsonant(z) ){ z++; }\n  return *z!=0;\n}\n\n/*\n** Return TRUE if there is a vowel anywhere within z[0..n-1]\n*/\nstatic int hasVowel(const char *z){\n  while( isConsonant(z) ){ z++; }\n  return *z!=0;\n}\n\n/*\n** Return TRUE if the word ends in a double consonant.\n**\n** The text is reversed here. So we are really looking at\n** the first two characters of z[].\n*/\nstatic int doubleConsonant(const char *z){\n  return isConsonant(z) && z[0]==z[1];\n}\n\n/*\n** Return TRUE if the word ends with three letters which\n** are consonant-vowel-consonent and where the final consonant\n** is not 'w', 'x', or 'y'.\n**\n** The word is reversed here.  So we are really checking the\n** first three letters and the first one cannot be in [wxy].\n*/\nstatic int star_oh(const char *z){\n  return\n    isConsonant(z) &&\n    z[0]!='w' && z[0]!='x' && z[0]!='y' &&\n    isVowel(z+1) &&\n    isConsonant(z+2);\n}\n\n/*\n** If the word ends with zFrom and xCond() is true for the stem\n** of the word that preceeds the zFrom ending, then change the \n** ending to zTo.\n**\n** The input word *pz and zFrom are both in reverse order.  zTo\n** is in normal order. \n**\n** Return TRUE if zFrom matches.  Return FALSE if zFrom does not\n** match.  Not that TRUE is returned even if xCond() fails and\n** no substitution occurs.\n*/\nstatic int stem(\n  char **pz,             /* The word being stemmed (Reversed) */\n  const char *zFrom,     /* If the ending matches this... (Reversed) */\n  const char *zTo,       /* ... change the ending to this (not reversed) */\n  int (*xCond)(const char*)   /* Condition that must be true */\n){\n  char *z = *pz;\n  while( *zFrom && *zFrom==*z ){ z++; zFrom++; }\n  if( *zFrom!=0 ) return 0;\n  if( xCond && !xCond(z) ) return 1;\n  while( *zTo ){\n    *(--z) = *(zTo++);\n  }\n  *pz = z;\n  return 1;\n}\n\n/*\n** This is the fallback stemmer used when the porter stemmer is\n** inappropriate.  The input word is copied into the output with\n** US-ASCII case folding.  If the input word is too long (more\n** than 20 bytes if it contains no digits or more than 6 bytes if\n** it contains digits) then word is truncated to 20 or 6 bytes\n** by taking 10 or 3 bytes from the beginning and end.\n*/\nstatic void copy_stemmer(const char *zIn, int nIn, char *zOut, int *pnOut){\n  int i, mx, j;\n  int hasDigit = 0;\n  for(i=0; i<nIn; i++){\n    char c = zIn[i];\n    if( c>='A' && c<='Z' ){\n      zOut[i] = c - 'A' + 'a';\n    }else{\n      if( c>='0' && c<='9' ) hasDigit = 1;\n      zOut[i] = c;\n    }\n  }\n  mx = hasDigit ? 3 : 10;\n  if( nIn>mx*2 ){\n    for(j=mx, i=nIn-mx; i<nIn; i++, j++){\n      zOut[j] = zOut[i];\n    }\n    i = j;\n  }\n  zOut[i] = 0;\n  *pnOut = i;\n}\n\n\n/*\n** Stem the input word zIn[0..nIn-1].  Store the output in zOut.\n** zOut is at least big enough to hold nIn bytes.  Write the actual\n** size of the output word (exclusive of the '\\0' terminator) into *pnOut.\n**\n** Any upper-case characters in the US-ASCII character set ([A-Z])\n** are converted to lower case.  Upper-case UTF characters are\n** unchanged.\n**\n** Words that are longer than about 20 bytes are stemmed by retaining\n** a few bytes from the beginning and the end of the word.  If the\n** word contains digits, 3 bytes are taken from the beginning and\n** 3 bytes from the end.  For long words without digits, 10 bytes\n** are taken from each end.  US-ASCII case folding still applies.\n** \n** If the input word contains not digits but does characters not \n** in [a-zA-Z] then no stemming is attempted and this routine just \n** copies the input into the input into the output with US-ASCII\n** case folding.\n**\n** Stemming never increases the length of the word.  So there is\n** no chance of overflowing the zOut buffer.\n*/\nstatic void porter_stemmer(const char *zIn, int nIn, char *zOut, int *pnOut){\n  int i, j;\n  char zReverse[28];\n  char *z, *z2;\n  if( nIn<3 || nIn>=(int)sizeof(zReverse)-7 ){\n    /* The word is too big or too small for the porter stemmer.\n    ** Fallback to the copy stemmer */\n    copy_stemmer(zIn, nIn, zOut, pnOut);\n    return;\n  }\n  for(i=0, j=sizeof(zReverse)-6; i<nIn; i++, j--){\n    char c = zIn[i];\n    if( c>='A' && c<='Z' ){\n      zReverse[j] = c + 'a' - 'A';\n    }else if( c>='a' && c<='z' ){\n      zReverse[j] = c;\n    }else{\n      /* The use of a character not in [a-zA-Z] means that we fallback\n      ** to the copy stemmer */\n      copy_stemmer(zIn, nIn, zOut, pnOut);\n      return;\n    }\n  }\n  memset(&zReverse[sizeof(zReverse)-5], 0, 5);\n  z = &zReverse[j+1];\n\n\n  /* Step 1a */\n  if( z[0]=='s' ){\n    if(\n     !stem(&z, \"sess\", \"ss\", 0) &&\n     !stem(&z, \"sei\", \"i\", 0)  &&\n     !stem(&z, \"ss\", \"ss\", 0)\n    ){\n      z++;\n    }\n  }\n\n  /* Step 1b */  \n  z2 = z;\n  if( stem(&z, \"dee\", \"ee\", m_gt_0) ){\n    /* Do nothing.  The work was all in the test */\n  }else if( \n     (stem(&z, \"gni\", \"\", hasVowel) || stem(&z, \"de\", \"\", hasVowel))\n      && z!=z2\n  ){\n     if( stem(&z, \"ta\", \"ate\", 0) ||\n         stem(&z, \"lb\", \"ble\", 0) ||\n         stem(&z, \"zi\", \"ize\", 0) ){\n       /* Do nothing.  The work was all in the test */\n     }else if( doubleConsonant(z) && (*z!='l' && *z!='s' && *z!='z') ){\n       z++;\n     }else if( m_eq_1(z) && star_oh(z) ){\n       *(--z) = 'e';\n     }\n  }\n\n  /* Step 1c */\n  if( z[0]=='y' && hasVowel(z+1) ){\n    z[0] = 'i';\n  }\n\n  /* Step 2 */\n  switch( z[1] ){\n   case 'a':\n     if( !stem(&z, \"lanoita\", \"ate\", m_gt_0) ){\n       stem(&z, \"lanoit\", \"tion\", m_gt_0);\n     }\n     break;\n   case 'c':\n     if( !stem(&z, \"icne\", \"ence\", m_gt_0) ){\n       stem(&z, \"icna\", \"ance\", m_gt_0);\n     }\n     break;\n   case 'e':\n     stem(&z, \"rezi\", \"ize\", m_gt_0);\n     break;\n   case 'g':\n     stem(&z, \"igol\", \"log\", m_gt_0);\n     break;\n   case 'l':\n     if( !stem(&z, \"ilb\", \"ble\", m_gt_0) \n      && !stem(&z, \"illa\", \"al\", m_gt_0)\n      && !stem(&z, \"iltne\", \"ent\", m_gt_0)\n      && !stem(&z, \"ile\", \"e\", m_gt_0)\n     ){\n       stem(&z, \"ilsuo\", \"ous\", m_gt_0);\n     }\n     break;\n   case 'o':\n     if( !stem(&z, \"noitazi\", \"ize\", m_gt_0)\n      && !stem(&z, \"noita\", \"ate\", m_gt_0)\n     ){\n       stem(&z, \"rota\", \"ate\", m_gt_0);\n     }\n     break;\n   case 's':\n     if( !stem(&z, \"msila\", \"al\", m_gt_0)\n      && !stem(&z, \"ssenevi\", \"ive\", m_gt_0)\n      && !stem(&z, \"ssenluf\", \"ful\", m_gt_0)\n     ){\n       stem(&z, \"ssensuo\", \"ous\", m_gt_0);\n     }\n     break;\n   case 't':\n     if( !stem(&z, \"itila\", \"al\", m_gt_0)\n      && !stem(&z, \"itivi\", \"ive\", m_gt_0)\n     ){\n       stem(&z, \"itilib\", \"ble\", m_gt_0);\n     }\n     break;\n  }\n\n  /* Step 3 */\n  switch( z[0] ){\n   case 'e':\n     if( !stem(&z, \"etaci\", \"ic\", m_gt_0)\n      && !stem(&z, \"evita\", \"\", m_gt_0)\n     ){\n       stem(&z, \"ezila\", \"al\", m_gt_0);\n     }\n     break;\n   case 'i':\n     stem(&z, \"itici\", \"ic\", m_gt_0);\n     break;\n   case 'l':\n     if( !stem(&z, \"laci\", \"ic\", m_gt_0) ){\n       stem(&z, \"luf\", \"\", m_gt_0);\n     }\n     break;\n   case 's':\n     stem(&z, \"ssen\", \"\", m_gt_0);\n     break;\n  }\n\n  /* Step 4 */\n  switch( z[1] ){\n   case 'a':\n     if( z[0]=='l' && m_gt_1(z+2) ){\n       z += 2;\n     }\n     break;\n   case 'c':\n     if( z[0]=='e' && z[2]=='n' && (z[3]=='a' || z[3]=='e')  && m_gt_1(z+4)  ){\n       z += 4;\n     }\n     break;\n   case 'e':\n     if( z[0]=='r' && m_gt_1(z+2) ){\n       z += 2;\n     }\n     break;\n   case 'i':\n     if( z[0]=='c' && m_gt_1(z+2) ){\n       z += 2;\n     }\n     break;\n   case 'l':\n     if( z[0]=='e' && z[2]=='b' && (z[3]=='a' || z[3]=='i') && m_gt_1(z+4) ){\n       z += 4;\n     }\n     break;\n   case 'n':\n     if( z[0]=='t' ){\n       if( z[2]=='a' ){\n         if( m_gt_1(z+3) ){\n           z += 3;\n         }\n       }else if( z[2]=='e' ){\n         if( !stem(&z, \"tneme\", \"\", m_gt_1)\n          && !stem(&z, \"tnem\", \"\", m_gt_1)\n         ){\n           stem(&z, \"tne\", \"\", m_gt_1);\n         }\n       }\n     }\n     break;\n   case 'o':\n     if( z[0]=='u' ){\n       if( m_gt_1(z+2) ){\n         z += 2;\n       }\n     }else if( z[3]=='s' || z[3]=='t' ){\n       stem(&z, \"noi\", \"\", m_gt_1);\n     }\n     break;\n   case 's':\n     if( z[0]=='m' && z[2]=='i' && m_gt_1(z+3) ){\n       z += 3;\n     }\n     break;\n   case 't':\n     if( !stem(&z, \"eta\", \"\", m_gt_1) ){\n       stem(&z, \"iti\", \"\", m_gt_1);\n     }\n     break;\n   case 'u':\n     if( z[0]=='s' && z[2]=='o' && m_gt_1(z+3) ){\n       z += 3;\n     }\n     break;\n   case 'v':\n   case 'z':\n     if( z[0]=='e' && z[2]=='i' && m_gt_1(z+3) ){\n       z += 3;\n     }\n     break;\n  }\n\n  /* Step 5a */\n  if( z[0]=='e' ){\n    if( m_gt_1(z+1) ){\n      z++;\n    }else if( m_eq_1(z+1) && !star_oh(z+1) ){\n      z++;\n    }\n  }\n\n  /* Step 5b */\n  if( m_gt_1(z) && z[0]=='l' && z[1]=='l' ){\n    z++;\n  }\n\n  /* z[] is now the stemmed word in reverse order.  Flip it back\n  ** around into forward order and return.\n  */\n  *pnOut = i = (int)strlen(z);\n  zOut[i] = 0;\n  while( *z ){\n    zOut[--i] = *(z++);\n  }\n}\n\n/*\n** Characters that can be part of a token.  We assume any character\n** whose value is greater than 0x80 (any UTF character) can be\n** part of a token.  In other words, delimiters all must have\n** values of 0x7f or lower.\n*/\nstatic const char porterIdChar[] = {\n/* x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 xA xB xC xD xE xF */\n    1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0,  /* 3x */\n    0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,  /* 4x */\n    1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1,  /* 5x */\n    0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,  /* 6x */\n    1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0,  /* 7x */\n};\n#define isDelim(C) (((ch=C)&0x80)==0 && (ch<0x30 || !porterIdChar[ch-0x30]))\n\n/*\n** Extract the next token from a tokenization cursor.  The cursor must\n** have been opened by a prior call to porterOpen().\n*/\nstatic int porterNext(\n  sqlite3_tokenizer_cursor *pCursor,  /* Cursor returned by porterOpen */\n  const char **pzToken,               /* OUT: *pzToken is the token text */\n  int *pnBytes,                       /* OUT: Number of bytes in token */\n  int *piStartOffset,                 /* OUT: Starting offset of token */\n  int *piEndOffset,                   /* OUT: Ending offset of token */\n  int *piPosition                     /* OUT: Position integer of token */\n){\n  porter_tokenizer_cursor *c = (porter_tokenizer_cursor *) pCursor;\n  const char *z = c->zInput;\n\n  while( c->iOffset<c->nInput ){\n    int iStartOffset, ch;\n\n    /* Scan past delimiter characters */\n    while( c->iOffset<c->nInput && isDelim(z[c->iOffset]) ){\n      c->iOffset++;\n    }\n\n    /* Count non-delimiter characters. */\n    iStartOffset = c->iOffset;\n    while( c->iOffset<c->nInput && !isDelim(z[c->iOffset]) ){\n      c->iOffset++;\n    }\n\n    if( c->iOffset>iStartOffset ){\n      int n = c->iOffset-iStartOffset;\n      if( n>c->nAllocated ){\n        char *pNew;\n        c->nAllocated = n+20;\n        pNew = sqlite3_realloc(c->zToken, c->nAllocated);\n        if( !pNew ) return SQLITE_NOMEM;\n        c->zToken = pNew;\n      }\n      porter_stemmer(&z[iStartOffset], n, c->zToken, pnBytes);\n      *pzToken = c->zToken;\n      *piStartOffset = iStartOffset;\n      *piEndOffset = c->iOffset;\n      *piPosition = c->iToken++;\n      return SQLITE_OK;\n    }\n  }\n  return SQLITE_DONE;\n}\n\n/*\n** The set of routines that implement the porter-stemmer tokenizer\n*/\nstatic const sqlite3_tokenizer_module porterTokenizerModule = {\n  0,\n  porterCreate,\n  porterDestroy,\n  porterOpen,\n  porterClose,\n  porterNext,\n  0\n};\n\n/*\n** Allocate a new porter tokenizer.  Return a pointer to the new\n** tokenizer in *ppModule\n*/\nSQLITE_PRIVATE void sqlite3Fts3PorterTokenizerModule(\n  sqlite3_tokenizer_module const**ppModule\n){\n  *ppModule = &porterTokenizerModule;\n}\n\n#endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3) */\n\n/************** End of fts3_porter.c *****************************************/\n/************** Begin file fts3_tokenizer.c **********************************/\n/*\n** 2007 June 22\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n******************************************************************************\n**\n** This is part of an SQLite module implementing full-text search.\n** This particular file implements the generic tokenizer interface.\n*/\n\n/*\n** The code in this file is only compiled if:\n**\n**     * The FTS3 module is being built as an extension\n**       (in which case SQLITE_CORE is not defined), or\n**\n**     * The FTS3 module is being built into the core of\n**       SQLite (in which case SQLITE_ENABLE_FTS3 is defined).\n*/\n/* #include \"fts3Int.h\" */\n#if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3)\n\n/* #include <assert.h> */\n/* #include <string.h> */\n\n/*\n** Return true if the two-argument version of fts3_tokenizer()\n** has been activated via a prior call to sqlite3_db_config(db,\n** SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER, 1, 0);\n*/\nstatic int fts3TokenizerEnabled(sqlite3_context *context){\n  sqlite3 *db = sqlite3_context_db_handle(context);\n  int isEnabled = 0;\n  sqlite3_db_config(db,SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER,-1,&isEnabled);\n  return isEnabled;\n}\n\n/*\n** Implementation of the SQL scalar function for accessing the underlying \n** hash table. This function may be called as follows:\n**\n**   SELECT <function-name>(<key-name>);\n**   SELECT <function-name>(<key-name>, <pointer>);\n**\n** where <function-name> is the name passed as the second argument\n** to the sqlite3Fts3InitHashTable() function (e.g. 'fts3_tokenizer').\n**\n** If the <pointer> argument is specified, it must be a blob value\n** containing a pointer to be stored as the hash data corresponding\n** to the string <key-name>. If <pointer> is not specified, then\n** the string <key-name> must already exist in the has table. Otherwise,\n** an error is returned.\n**\n** Whether or not the <pointer> argument is specified, the value returned\n** is a blob containing the pointer stored as the hash data corresponding\n** to string <key-name> (after the hash-table is updated, if applicable).\n*/\nstatic void fts3TokenizerFunc(\n  sqlite3_context *context,\n  int argc,\n  sqlite3_value **argv\n){\n  Fts3Hash *pHash;\n  void *pPtr = 0;\n  const unsigned char *zName;\n  int nName;\n\n  assert( argc==1 || argc==2 );\n\n  pHash = (Fts3Hash *)sqlite3_user_data(context);\n\n  zName = sqlite3_value_text(argv[0]);\n  nName = sqlite3_value_bytes(argv[0])+1;\n\n  if( argc==2 ){\n    if( fts3TokenizerEnabled(context) ){\n      void *pOld;\n      int n = sqlite3_value_bytes(argv[1]);\n      if( zName==0 || n!=sizeof(pPtr) ){\n        sqlite3_result_error(context, \"argument type mismatch\", -1);\n        return;\n      }\n      pPtr = *(void **)sqlite3_value_blob(argv[1]);\n      pOld = sqlite3Fts3HashInsert(pHash, (void *)zName, nName, pPtr);\n      if( pOld==pPtr ){\n        sqlite3_result_error(context, \"out of memory\", -1);\n      }\n    }else{\n      sqlite3_result_error(context, \"fts3tokenize disabled\", -1);\n      return;\n    }\n  }else{\n    if( zName ){\n      pPtr = sqlite3Fts3HashFind(pHash, zName, nName);\n    }\n    if( !pPtr ){\n      char *zErr = sqlite3_mprintf(\"unknown tokenizer: %s\", zName);\n      sqlite3_result_error(context, zErr, -1);\n      sqlite3_free(zErr);\n      return;\n    }\n  }\n  sqlite3_result_blob(context, (void *)&pPtr, sizeof(pPtr), SQLITE_TRANSIENT);\n}\n\nSQLITE_PRIVATE int sqlite3Fts3IsIdChar(char c){\n  static const char isFtsIdChar[] = {\n      0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,  /* 0x */\n      0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,  /* 1x */\n      0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,  /* 2x */\n      1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0,  /* 3x */\n      0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,  /* 4x */\n      1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1,  /* 5x */\n      0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,  /* 6x */\n      1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0,  /* 7x */\n  };\n  return (c&0x80 || isFtsIdChar[(int)(c)]);\n}\n\nSQLITE_PRIVATE const char *sqlite3Fts3NextToken(const char *zStr, int *pn){\n  const char *z1;\n  const char *z2 = 0;\n\n  /* Find the start of the next token. */\n  z1 = zStr;\n  while( z2==0 ){\n    char c = *z1;\n    switch( c ){\n      case '\\0': return 0;        /* No more tokens here */\n      case '\\'':\n      case '\"':\n      case '`': {\n        z2 = z1;\n        while( *++z2 && (*z2!=c || *++z2==c) );\n        break;\n      }\n      case '[':\n        z2 = &z1[1];\n        while( *z2 && z2[0]!=']' ) z2++;\n        if( *z2 ) z2++;\n        break;\n\n      default:\n        if( sqlite3Fts3IsIdChar(*z1) ){\n          z2 = &z1[1];\n          while( sqlite3Fts3IsIdChar(*z2) ) z2++;\n        }else{\n          z1++;\n        }\n    }\n  }\n\n  *pn = (int)(z2-z1);\n  return z1;\n}\n\nSQLITE_PRIVATE int sqlite3Fts3InitTokenizer(\n  Fts3Hash *pHash,                /* Tokenizer hash table */\n  const char *zArg,               /* Tokenizer name */\n  sqlite3_tokenizer **ppTok,      /* OUT: Tokenizer (if applicable) */\n  char **pzErr                    /* OUT: Set to malloced error message */\n){\n  int rc;\n  char *z = (char *)zArg;\n  int n = 0;\n  char *zCopy;\n  char *zEnd;                     /* Pointer to nul-term of zCopy */\n  sqlite3_tokenizer_module *m;\n\n  zCopy = sqlite3_mprintf(\"%s\", zArg);\n  if( !zCopy ) return SQLITE_NOMEM;\n  zEnd = &zCopy[strlen(zCopy)];\n\n  z = (char *)sqlite3Fts3NextToken(zCopy, &n);\n  if( z==0 ){\n    assert( n==0 );\n    z = zCopy;\n  }\n  z[n] = '\\0';\n  sqlite3Fts3Dequote(z);\n\n  m = (sqlite3_tokenizer_module *)sqlite3Fts3HashFind(pHash,z,(int)strlen(z)+1);\n  if( !m ){\n    sqlite3Fts3ErrMsg(pzErr, \"unknown tokenizer: %s\", z);\n    rc = SQLITE_ERROR;\n  }else{\n    char const **aArg = 0;\n    int iArg = 0;\n    z = &z[n+1];\n    while( z<zEnd && (NULL!=(z = (char *)sqlite3Fts3NextToken(z, &n))) ){\n      int nNew = sizeof(char *)*(iArg+1);\n      char const **aNew = (const char **)sqlite3_realloc((void *)aArg, nNew);\n      if( !aNew ){\n        sqlite3_free(zCopy);\n        sqlite3_free((void *)aArg);\n        return SQLITE_NOMEM;\n      }\n      aArg = aNew;\n      aArg[iArg++] = z;\n      z[n] = '\\0';\n      sqlite3Fts3Dequote(z);\n      z = &z[n+1];\n    }\n    rc = m->xCreate(iArg, aArg, ppTok);\n    assert( rc!=SQLITE_OK || *ppTok );\n    if( rc!=SQLITE_OK ){\n      sqlite3Fts3ErrMsg(pzErr, \"unknown tokenizer\");\n    }else{\n      (*ppTok)->pModule = m; \n    }\n    sqlite3_free((void *)aArg);\n  }\n\n  sqlite3_free(zCopy);\n  return rc;\n}\n\n\n#ifdef SQLITE_TEST\n\n#if defined(INCLUDE_SQLITE_TCL_H)\n#  include \"sqlite_tcl.h\"\n#else\n#  include \"tcl.h\"\n#endif\n/* #include <string.h> */\n\n/*\n** Implementation of a special SQL scalar function for testing tokenizers \n** designed to be used in concert with the Tcl testing framework. This\n** function must be called with two or more arguments:\n**\n**   SELECT <function-name>(<key-name>, ..., <input-string>);\n**\n** where <function-name> is the name passed as the second argument\n** to the sqlite3Fts3InitHashTable() function (e.g. 'fts3_tokenizer')\n** concatenated with the string '_test' (e.g. 'fts3_tokenizer_test').\n**\n** The return value is a string that may be interpreted as a Tcl\n** list. For each token in the <input-string>, three elements are\n** added to the returned list. The first is the token position, the \n** second is the token text (folded, stemmed, etc.) and the third is the\n** substring of <input-string> associated with the token. For example, \n** using the built-in \"simple\" tokenizer:\n**\n**   SELECT fts_tokenizer_test('simple', 'I don't see how');\n**\n** will return the string:\n**\n**   \"{0 i I 1 dont don't 2 see see 3 how how}\"\n**   \n*/\nstatic void testFunc(\n  sqlite3_context *context,\n  int argc,\n  sqlite3_value **argv\n){\n  Fts3Hash *pHash;\n  sqlite3_tokenizer_module *p;\n  sqlite3_tokenizer *pTokenizer = 0;\n  sqlite3_tokenizer_cursor *pCsr = 0;\n\n  const char *zErr = 0;\n\n  const char *zName;\n  int nName;\n  const char *zInput;\n  int nInput;\n\n  const char *azArg[64];\n\n  const char *zToken;\n  int nToken = 0;\n  int iStart = 0;\n  int iEnd = 0;\n  int iPos = 0;\n  int i;\n\n  Tcl_Obj *pRet;\n\n  if( argc<2 ){\n    sqlite3_result_error(context, \"insufficient arguments\", -1);\n    return;\n  }\n\n  nName = sqlite3_value_bytes(argv[0]);\n  zName = (const char *)sqlite3_value_text(argv[0]);\n  nInput = sqlite3_value_bytes(argv[argc-1]);\n  zInput = (const char *)sqlite3_value_text(argv[argc-1]);\n\n  pHash = (Fts3Hash *)sqlite3_user_data(context);\n  p = (sqlite3_tokenizer_module *)sqlite3Fts3HashFind(pHash, zName, nName+1);\n\n  if( !p ){\n    char *zErr2 = sqlite3_mprintf(\"unknown tokenizer: %s\", zName);\n    sqlite3_result_error(context, zErr2, -1);\n    sqlite3_free(zErr2);\n    return;\n  }\n\n  pRet = Tcl_NewObj();\n  Tcl_IncrRefCount(pRet);\n\n  for(i=1; i<argc-1; i++){\n    azArg[i-1] = (const char *)sqlite3_value_text(argv[i]);\n  }\n\n  if( SQLITE_OK!=p->xCreate(argc-2, azArg, &pTokenizer) ){\n    zErr = \"error in xCreate()\";\n    goto finish;\n  }\n  pTokenizer->pModule = p;\n  if( sqlite3Fts3OpenTokenizer(pTokenizer, 0, zInput, nInput, &pCsr) ){\n    zErr = \"error in xOpen()\";\n    goto finish;\n  }\n\n  while( SQLITE_OK==p->xNext(pCsr, &zToken, &nToken, &iStart, &iEnd, &iPos) ){\n    Tcl_ListObjAppendElement(0, pRet, Tcl_NewIntObj(iPos));\n    Tcl_ListObjAppendElement(0, pRet, Tcl_NewStringObj(zToken, nToken));\n    zToken = &zInput[iStart];\n    nToken = iEnd-iStart;\n    Tcl_ListObjAppendElement(0, pRet, Tcl_NewStringObj(zToken, nToken));\n  }\n\n  if( SQLITE_OK!=p->xClose(pCsr) ){\n    zErr = \"error in xClose()\";\n    goto finish;\n  }\n  if( SQLITE_OK!=p->xDestroy(pTokenizer) ){\n    zErr = \"error in xDestroy()\";\n    goto finish;\n  }\n\nfinish:\n  if( zErr ){\n    sqlite3_result_error(context, zErr, -1);\n  }else{\n    sqlite3_result_text(context, Tcl_GetString(pRet), -1, SQLITE_TRANSIENT);\n  }\n  Tcl_DecrRefCount(pRet);\n}\n\nstatic\nint registerTokenizer(\n  sqlite3 *db, \n  char *zName, \n  const sqlite3_tokenizer_module *p\n){\n  int rc;\n  sqlite3_stmt *pStmt;\n  const char zSql[] = \"SELECT fts3_tokenizer(?, ?)\";\n\n  rc = sqlite3_prepare_v2(db, zSql, -1, &pStmt, 0);\n  if( rc!=SQLITE_OK ){\n    return rc;\n  }\n\n  sqlite3_bind_text(pStmt, 1, zName, -1, SQLITE_STATIC);\n  sqlite3_bind_blob(pStmt, 2, &p, sizeof(p), SQLITE_STATIC);\n  sqlite3_step(pStmt);\n\n  return sqlite3_finalize(pStmt);\n}\n\n\nstatic\nint queryTokenizer(\n  sqlite3 *db, \n  char *zName,  \n  const sqlite3_tokenizer_module **pp\n){\n  int rc;\n  sqlite3_stmt *pStmt;\n  const char zSql[] = \"SELECT fts3_tokenizer(?)\";\n\n  *pp = 0;\n  rc = sqlite3_prepare_v2(db, zSql, -1, &pStmt, 0);\n  if( rc!=SQLITE_OK ){\n    return rc;\n  }\n\n  sqlite3_bind_text(pStmt, 1, zName, -1, SQLITE_STATIC);\n  if( SQLITE_ROW==sqlite3_step(pStmt) ){\n    if( sqlite3_column_type(pStmt, 0)==SQLITE_BLOB ){\n      memcpy((void *)pp, sqlite3_column_blob(pStmt, 0), sizeof(*pp));\n    }\n  }\n\n  return sqlite3_finalize(pStmt);\n}\n\nSQLITE_PRIVATE void sqlite3Fts3SimpleTokenizerModule(sqlite3_tokenizer_module const**ppModule);\n\n/*\n** Implementation of the scalar function fts3_tokenizer_internal_test().\n** This function is used for testing only, it is not included in the\n** build unless SQLITE_TEST is defined.\n**\n** The purpose of this is to test that the fts3_tokenizer() function\n** can be used as designed by the C-code in the queryTokenizer and\n** registerTokenizer() functions above. These two functions are repeated\n** in the README.tokenizer file as an example, so it is important to\n** test them.\n**\n** To run the tests, evaluate the fts3_tokenizer_internal_test() scalar\n** function with no arguments. An assert() will fail if a problem is\n** detected. i.e.:\n**\n**     SELECT fts3_tokenizer_internal_test();\n**\n*/\nstatic void intTestFunc(\n  sqlite3_context *context,\n  int argc,\n  sqlite3_value **argv\n){\n  int rc;\n  const sqlite3_tokenizer_module *p1;\n  const sqlite3_tokenizer_module *p2;\n  sqlite3 *db = (sqlite3 *)sqlite3_user_data(context);\n\n  UNUSED_PARAMETER(argc);\n  UNUSED_PARAMETER(argv);\n\n  /* Test the query function */\n  sqlite3Fts3SimpleTokenizerModule(&p1);\n  rc = queryTokenizer(db, \"simple\", &p2);\n  assert( rc==SQLITE_OK );\n  assert( p1==p2 );\n  rc = queryTokenizer(db, \"nosuchtokenizer\", &p2);\n  assert( rc==SQLITE_ERROR );\n  assert( p2==0 );\n  assert( 0==strcmp(sqlite3_errmsg(db), \"unknown tokenizer: nosuchtokenizer\") );\n\n  /* Test the storage function */\n  if( fts3TokenizerEnabled(context) ){\n    rc = registerTokenizer(db, \"nosuchtokenizer\", p1);\n    assert( rc==SQLITE_OK );\n    rc = queryTokenizer(db, \"nosuchtokenizer\", &p2);\n    assert( rc==SQLITE_OK );\n    assert( p2==p1 );\n  }\n\n  sqlite3_result_text(context, \"ok\", -1, SQLITE_STATIC);\n}\n\n#endif\n\n/*\n** Set up SQL objects in database db used to access the contents of\n** the hash table pointed to by argument pHash. The hash table must\n** been initialized to use string keys, and to take a private copy \n** of the key when a value is inserted. i.e. by a call similar to:\n**\n**    sqlite3Fts3HashInit(pHash, FTS3_HASH_STRING, 1);\n**\n** This function adds a scalar function (see header comment above\n** fts3TokenizerFunc() in this file for details) and, if ENABLE_TABLE is\n** defined at compilation time, a temporary virtual table (see header \n** comment above struct HashTableVtab) to the database schema. Both \n** provide read/write access to the contents of *pHash.\n**\n** The third argument to this function, zName, is used as the name\n** of both the scalar and, if created, the virtual table.\n*/\nSQLITE_PRIVATE int sqlite3Fts3InitHashTable(\n  sqlite3 *db, \n  Fts3Hash *pHash, \n  const char *zName\n){\n  int rc = SQLITE_OK;\n  void *p = (void *)pHash;\n  const int any = SQLITE_ANY;\n\n#ifdef SQLITE_TEST\n  char *zTest = 0;\n  char *zTest2 = 0;\n  void *pdb = (void *)db;\n  zTest = sqlite3_mprintf(\"%s_test\", zName);\n  zTest2 = sqlite3_mprintf(\"%s_internal_test\", zName);\n  if( !zTest || !zTest2 ){\n    rc = SQLITE_NOMEM;\n  }\n#endif\n\n  if( SQLITE_OK==rc ){\n    rc = sqlite3_create_function(db, zName, 1, any, p, fts3TokenizerFunc, 0, 0);\n  }\n  if( SQLITE_OK==rc ){\n    rc = sqlite3_create_function(db, zName, 2, any, p, fts3TokenizerFunc, 0, 0);\n  }\n#ifdef SQLITE_TEST\n  if( SQLITE_OK==rc ){\n    rc = sqlite3_create_function(db, zTest, -1, any, p, testFunc, 0, 0);\n  }\n  if( SQLITE_OK==rc ){\n    rc = sqlite3_create_function(db, zTest2, 0, any, pdb, intTestFunc, 0, 0);\n  }\n#endif\n\n#ifdef SQLITE_TEST\n  sqlite3_free(zTest);\n  sqlite3_free(zTest2);\n#endif\n\n  return rc;\n}\n\n#endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3) */\n\n/************** End of fts3_tokenizer.c **************************************/\n/************** Begin file fts3_tokenizer1.c *********************************/\n/*\n** 2006 Oct 10\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n******************************************************************************\n**\n** Implementation of the \"simple\" full-text-search tokenizer.\n*/\n\n/*\n** The code in this file is only compiled if:\n**\n**     * The FTS3 module is being built as an extension\n**       (in which case SQLITE_CORE is not defined), or\n**\n**     * The FTS3 module is being built into the core of\n**       SQLite (in which case SQLITE_ENABLE_FTS3 is defined).\n*/\n/* #include \"fts3Int.h\" */\n#if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3)\n\n/* #include <assert.h> */\n/* #include <stdlib.h> */\n/* #include <stdio.h> */\n/* #include <string.h> */\n\n/* #include \"fts3_tokenizer.h\" */\n\ntypedef struct simple_tokenizer {\n  sqlite3_tokenizer base;\n  char delim[128];             /* flag ASCII delimiters */\n} simple_tokenizer;\n\ntypedef struct simple_tokenizer_cursor {\n  sqlite3_tokenizer_cursor base;\n  const char *pInput;          /* input we are tokenizing */\n  int nBytes;                  /* size of the input */\n  int iOffset;                 /* current position in pInput */\n  int iToken;                  /* index of next token to be returned */\n  char *pToken;                /* storage for current token */\n  int nTokenAllocated;         /* space allocated to zToken buffer */\n} simple_tokenizer_cursor;\n\n\nstatic int simpleDelim(simple_tokenizer *t, unsigned char c){\n  return c<0x80 && t->delim[c];\n}\nstatic int fts3_isalnum(int x){\n  return (x>='0' && x<='9') || (x>='A' && x<='Z') || (x>='a' && x<='z');\n}\n\n/*\n** Create a new tokenizer instance.\n*/\nstatic int simpleCreate(\n  int argc, const char * const *argv,\n  sqlite3_tokenizer **ppTokenizer\n){\n  simple_tokenizer *t;\n\n  t = (simple_tokenizer *) sqlite3_malloc(sizeof(*t));\n  if( t==NULL ) return SQLITE_NOMEM;\n  memset(t, 0, sizeof(*t));\n\n  /* TODO(shess) Delimiters need to remain the same from run to run,\n  ** else we need to reindex.  One solution would be a meta-table to\n  ** track such information in the database, then we'd only want this\n  ** information on the initial create.\n  */\n  if( argc>1 ){\n    int i, n = (int)strlen(argv[1]);\n    for(i=0; i<n; i++){\n      unsigned char ch = argv[1][i];\n      /* We explicitly don't support UTF-8 delimiters for now. */\n      if( ch>=0x80 ){\n        sqlite3_free(t);\n        return SQLITE_ERROR;\n      }\n      t->delim[ch] = 1;\n    }\n  } else {\n    /* Mark non-alphanumeric ASCII characters as delimiters */\n    int i;\n    for(i=1; i<0x80; i++){\n      t->delim[i] = !fts3_isalnum(i) ? -1 : 0;\n    }\n  }\n\n  *ppTokenizer = &t->base;\n  return SQLITE_OK;\n}\n\n/*\n** Destroy a tokenizer\n*/\nstatic int simpleDestroy(sqlite3_tokenizer *pTokenizer){\n  sqlite3_free(pTokenizer);\n  return SQLITE_OK;\n}\n\n/*\n** Prepare to begin tokenizing a particular string.  The input\n** string to be tokenized is pInput[0..nBytes-1].  A cursor\n** used to incrementally tokenize this string is returned in \n** *ppCursor.\n*/\nstatic int simpleOpen(\n  sqlite3_tokenizer *pTokenizer,         /* The tokenizer */\n  const char *pInput, int nBytes,        /* String to be tokenized */\n  sqlite3_tokenizer_cursor **ppCursor    /* OUT: Tokenization cursor */\n){\n  simple_tokenizer_cursor *c;\n\n  UNUSED_PARAMETER(pTokenizer);\n\n  c = (simple_tokenizer_cursor *) sqlite3_malloc(sizeof(*c));\n  if( c==NULL ) return SQLITE_NOMEM;\n\n  c->pInput = pInput;\n  if( pInput==0 ){\n    c->nBytes = 0;\n  }else if( nBytes<0 ){\n    c->nBytes = (int)strlen(pInput);\n  }else{\n    c->nBytes = nBytes;\n  }\n  c->iOffset = 0;                 /* start tokenizing at the beginning */\n  c->iToken = 0;\n  c->pToken = NULL;               /* no space allocated, yet. */\n  c->nTokenAllocated = 0;\n\n  *ppCursor = &c->base;\n  return SQLITE_OK;\n}\n\n/*\n** Close a tokenization cursor previously opened by a call to\n** simpleOpen() above.\n*/\nstatic int simpleClose(sqlite3_tokenizer_cursor *pCursor){\n  simple_tokenizer_cursor *c = (simple_tokenizer_cursor *) pCursor;\n  sqlite3_free(c->pToken);\n  sqlite3_free(c);\n  return SQLITE_OK;\n}\n\n/*\n** Extract the next token from a tokenization cursor.  The cursor must\n** have been opened by a prior call to simpleOpen().\n*/\nstatic int simpleNext(\n  sqlite3_tokenizer_cursor *pCursor,  /* Cursor returned by simpleOpen */\n  const char **ppToken,               /* OUT: *ppToken is the token text */\n  int *pnBytes,                       /* OUT: Number of bytes in token */\n  int *piStartOffset,                 /* OUT: Starting offset of token */\n  int *piEndOffset,                   /* OUT: Ending offset of token */\n  int *piPosition                     /* OUT: Position integer of token */\n){\n  simple_tokenizer_cursor *c = (simple_tokenizer_cursor *) pCursor;\n  simple_tokenizer *t = (simple_tokenizer *) pCursor->pTokenizer;\n  unsigned char *p = (unsigned char *)c->pInput;\n\n  while( c->iOffset<c->nBytes ){\n    int iStartOffset;\n\n    /* Scan past delimiter characters */\n    while( c->iOffset<c->nBytes && simpleDelim(t, p[c->iOffset]) ){\n      c->iOffset++;\n    }\n\n    /* Count non-delimiter characters. */\n    iStartOffset = c->iOffset;\n    while( c->iOffset<c->nBytes && !simpleDelim(t, p[c->iOffset]) ){\n      c->iOffset++;\n    }\n\n    if( c->iOffset>iStartOffset ){\n      int i, n = c->iOffset-iStartOffset;\n      if( n>c->nTokenAllocated ){\n        char *pNew;\n        c->nTokenAllocated = n+20;\n        pNew = sqlite3_realloc(c->pToken, c->nTokenAllocated);\n        if( !pNew ) return SQLITE_NOMEM;\n        c->pToken = pNew;\n      }\n      for(i=0; i<n; i++){\n        /* TODO(shess) This needs expansion to handle UTF-8\n        ** case-insensitivity.\n        */\n        unsigned char ch = p[iStartOffset+i];\n        c->pToken[i] = (char)((ch>='A' && ch<='Z') ? ch-'A'+'a' : ch);\n      }\n      *ppToken = c->pToken;\n      *pnBytes = n;\n      *piStartOffset = iStartOffset;\n      *piEndOffset = c->iOffset;\n      *piPosition = c->iToken++;\n\n      return SQLITE_OK;\n    }\n  }\n  return SQLITE_DONE;\n}\n\n/*\n** The set of routines that implement the simple tokenizer\n*/\nstatic const sqlite3_tokenizer_module simpleTokenizerModule = {\n  0,\n  simpleCreate,\n  simpleDestroy,\n  simpleOpen,\n  simpleClose,\n  simpleNext,\n  0,\n};\n\n/*\n** Allocate a new simple tokenizer.  Return a pointer to the new\n** tokenizer in *ppModule\n*/\nSQLITE_PRIVATE void sqlite3Fts3SimpleTokenizerModule(\n  sqlite3_tokenizer_module const**ppModule\n){\n  *ppModule = &simpleTokenizerModule;\n}\n\n#endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3) */\n\n/************** End of fts3_tokenizer1.c *************************************/\n/************** Begin file fts3_tokenize_vtab.c ******************************/\n/*\n** 2013 Apr 22\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n******************************************************************************\n**\n** This file contains code for the \"fts3tokenize\" virtual table module.\n** An fts3tokenize virtual table is created as follows:\n**\n**   CREATE VIRTUAL TABLE <tbl> USING fts3tokenize(\n**       <tokenizer-name>, <arg-1>, ...\n**   );\n**\n** The table created has the following schema:\n**\n**   CREATE TABLE <tbl>(input, token, start, end, position)\n**\n** When queried, the query must include a WHERE clause of type:\n**\n**   input = <string>\n**\n** The virtual table module tokenizes this <string>, using the FTS3 \n** tokenizer specified by the arguments to the CREATE VIRTUAL TABLE \n** statement and returns one row for each token in the result. With\n** fields set as follows:\n**\n**   input:   Always set to a copy of <string>\n**   token:   A token from the input.\n**   start:   Byte offset of the token within the input <string>.\n**   end:     Byte offset of the byte immediately following the end of the\n**            token within the input string.\n**   pos:     Token offset of token within input.\n**\n*/\n/* #include \"fts3Int.h\" */\n#if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3)\n\n/* #include <string.h> */\n/* #include <assert.h> */\n\ntypedef struct Fts3tokTable Fts3tokTable;\ntypedef struct Fts3tokCursor Fts3tokCursor;\n\n/*\n** Virtual table structure.\n*/\nstruct Fts3tokTable {\n  sqlite3_vtab base;              /* Base class used by SQLite core */\n  const sqlite3_tokenizer_module *pMod;\n  sqlite3_tokenizer *pTok;\n};\n\n/*\n** Virtual table cursor structure.\n*/\nstruct Fts3tokCursor {\n  sqlite3_vtab_cursor base;       /* Base class used by SQLite core */\n  char *zInput;                   /* Input string */\n  sqlite3_tokenizer_cursor *pCsr; /* Cursor to iterate through zInput */\n  int iRowid;                     /* Current 'rowid' value */\n  const char *zToken;             /* Current 'token' value */\n  int nToken;                     /* Size of zToken in bytes */\n  int iStart;                     /* Current 'start' value */\n  int iEnd;                       /* Current 'end' value */\n  int iPos;                       /* Current 'pos' value */\n};\n\n/*\n** Query FTS for the tokenizer implementation named zName.\n*/\nstatic int fts3tokQueryTokenizer(\n  Fts3Hash *pHash,\n  const char *zName,\n  const sqlite3_tokenizer_module **pp,\n  char **pzErr\n){\n  sqlite3_tokenizer_module *p;\n  int nName = (int)strlen(zName);\n\n  p = (sqlite3_tokenizer_module *)sqlite3Fts3HashFind(pHash, zName, nName+1);\n  if( !p ){\n    sqlite3Fts3ErrMsg(pzErr, \"unknown tokenizer: %s\", zName);\n    return SQLITE_ERROR;\n  }\n\n  *pp = p;\n  return SQLITE_OK;\n}\n\n/*\n** The second argument, argv[], is an array of pointers to nul-terminated\n** strings. This function makes a copy of the array and strings into a \n** single block of memory. It then dequotes any of the strings that appear\n** to be quoted.\n**\n** If successful, output parameter *pazDequote is set to point at the\n** array of dequoted strings and SQLITE_OK is returned. The caller is\n** responsible for eventually calling sqlite3_free() to free the array\n** in this case. Or, if an error occurs, an SQLite error code is returned.\n** The final value of *pazDequote is undefined in this case.\n*/\nstatic int fts3tokDequoteArray(\n  int argc,                       /* Number of elements in argv[] */\n  const char * const *argv,       /* Input array */\n  char ***pazDequote              /* Output array */\n){\n  int rc = SQLITE_OK;             /* Return code */\n  if( argc==0 ){\n    *pazDequote = 0;\n  }else{\n    int i;\n    int nByte = 0;\n    char **azDequote;\n\n    for(i=0; i<argc; i++){\n      nByte += (int)(strlen(argv[i]) + 1);\n    }\n\n    *pazDequote = azDequote = sqlite3_malloc64(sizeof(char *)*argc + nByte);\n    if( azDequote==0 ){\n      rc = SQLITE_NOMEM;\n    }else{\n      char *pSpace = (char *)&azDequote[argc];\n      for(i=0; i<argc; i++){\n        int n = (int)strlen(argv[i]);\n        azDequote[i] = pSpace;\n        memcpy(pSpace, argv[i], n+1);\n        sqlite3Fts3Dequote(pSpace);\n        pSpace += (n+1);\n      }\n    }\n  }\n\n  return rc;\n}\n\n/*\n** Schema of the tokenizer table.\n*/\n#define FTS3_TOK_SCHEMA \"CREATE TABLE x(input, token, start, end, position)\"\n\n/*\n** This function does all the work for both the xConnect and xCreate methods.\n** These tables have no persistent representation of their own, so xConnect\n** and xCreate are identical operations.\n**\n**   argv[0]: module name\n**   argv[1]: database name \n**   argv[2]: table name\n**   argv[3]: first argument (tokenizer name)\n*/\nstatic int fts3tokConnectMethod(\n  sqlite3 *db,                    /* Database connection */\n  void *pHash,                    /* Hash table of tokenizers */\n  int argc,                       /* Number of elements in argv array */\n  const char * const *argv,       /* xCreate/xConnect argument array */\n  sqlite3_vtab **ppVtab,          /* OUT: New sqlite3_vtab object */\n  char **pzErr                    /* OUT: sqlite3_malloc'd error message */\n){\n  Fts3tokTable *pTab = 0;\n  const sqlite3_tokenizer_module *pMod = 0;\n  sqlite3_tokenizer *pTok = 0;\n  int rc;\n  char **azDequote = 0;\n  int nDequote;\n\n  rc = sqlite3_declare_vtab(db, FTS3_TOK_SCHEMA);\n  if( rc!=SQLITE_OK ) return rc;\n\n  nDequote = argc-3;\n  rc = fts3tokDequoteArray(nDequote, &argv[3], &azDequote);\n\n  if( rc==SQLITE_OK ){\n    const char *zModule;\n    if( nDequote<1 ){\n      zModule = \"simple\";\n    }else{\n      zModule = azDequote[0];\n    }\n    rc = fts3tokQueryTokenizer((Fts3Hash*)pHash, zModule, &pMod, pzErr);\n  }\n\n  assert( (rc==SQLITE_OK)==(pMod!=0) );\n  if( rc==SQLITE_OK ){\n    const char * const *azArg = (const char * const *)&azDequote[1];\n    rc = pMod->xCreate((nDequote>1 ? nDequote-1 : 0), azArg, &pTok);\n  }\n\n  if( rc==SQLITE_OK ){\n    pTab = (Fts3tokTable *)sqlite3_malloc(sizeof(Fts3tokTable));\n    if( pTab==0 ){\n      rc = SQLITE_NOMEM;\n    }\n  }\n\n  if( rc==SQLITE_OK ){\n    memset(pTab, 0, sizeof(Fts3tokTable));\n    pTab->pMod = pMod;\n    pTab->pTok = pTok;\n    *ppVtab = &pTab->base;\n  }else{\n    if( pTok ){\n      pMod->xDestroy(pTok);\n    }\n  }\n\n  sqlite3_free(azDequote);\n  return rc;\n}\n\n/*\n** This function does the work for both the xDisconnect and xDestroy methods.\n** These tables have no persistent representation of their own, so xDisconnect\n** and xDestroy are identical operations.\n*/\nstatic int fts3tokDisconnectMethod(sqlite3_vtab *pVtab){\n  Fts3tokTable *pTab = (Fts3tokTable *)pVtab;\n\n  pTab->pMod->xDestroy(pTab->pTok);\n  sqlite3_free(pTab);\n  return SQLITE_OK;\n}\n\n/*\n** xBestIndex - Analyze a WHERE and ORDER BY clause.\n*/\nstatic int fts3tokBestIndexMethod(\n  sqlite3_vtab *pVTab, \n  sqlite3_index_info *pInfo\n){\n  int i;\n  UNUSED_PARAMETER(pVTab);\n\n  for(i=0; i<pInfo->nConstraint; i++){\n    if( pInfo->aConstraint[i].usable \n     && pInfo->aConstraint[i].iColumn==0 \n     && pInfo->aConstraint[i].op==SQLITE_INDEX_CONSTRAINT_EQ \n    ){\n      pInfo->idxNum = 1;\n      pInfo->aConstraintUsage[i].argvIndex = 1;\n      pInfo->aConstraintUsage[i].omit = 1;\n      pInfo->estimatedCost = 1;\n      return SQLITE_OK;\n    }\n  }\n\n  pInfo->idxNum = 0;\n  assert( pInfo->estimatedCost>1000000.0 );\n\n  return SQLITE_OK;\n}\n\n/*\n** xOpen - Open a cursor.\n*/\nstatic int fts3tokOpenMethod(sqlite3_vtab *pVTab, sqlite3_vtab_cursor **ppCsr){\n  Fts3tokCursor *pCsr;\n  UNUSED_PARAMETER(pVTab);\n\n  pCsr = (Fts3tokCursor *)sqlite3_malloc(sizeof(Fts3tokCursor));\n  if( pCsr==0 ){\n    return SQLITE_NOMEM;\n  }\n  memset(pCsr, 0, sizeof(Fts3tokCursor));\n\n  *ppCsr = (sqlite3_vtab_cursor *)pCsr;\n  return SQLITE_OK;\n}\n\n/*\n** Reset the tokenizer cursor passed as the only argument. As if it had\n** just been returned by fts3tokOpenMethod().\n*/\nstatic void fts3tokResetCursor(Fts3tokCursor *pCsr){\n  if( pCsr->pCsr ){\n    Fts3tokTable *pTab = (Fts3tokTable *)(pCsr->base.pVtab);\n    pTab->pMod->xClose(pCsr->pCsr);\n    pCsr->pCsr = 0;\n  }\n  sqlite3_free(pCsr->zInput);\n  pCsr->zInput = 0;\n  pCsr->zToken = 0;\n  pCsr->nToken = 0;\n  pCsr->iStart = 0;\n  pCsr->iEnd = 0;\n  pCsr->iPos = 0;\n  pCsr->iRowid = 0;\n}\n\n/*\n** xClose - Close a cursor.\n*/\nstatic int fts3tokCloseMethod(sqlite3_vtab_cursor *pCursor){\n  Fts3tokCursor *pCsr = (Fts3tokCursor *)pCursor;\n\n  fts3tokResetCursor(pCsr);\n  sqlite3_free(pCsr);\n  return SQLITE_OK;\n}\n\n/*\n** xNext - Advance the cursor to the next row, if any.\n*/\nstatic int fts3tokNextMethod(sqlite3_vtab_cursor *pCursor){\n  Fts3tokCursor *pCsr = (Fts3tokCursor *)pCursor;\n  Fts3tokTable *pTab = (Fts3tokTable *)(pCursor->pVtab);\n  int rc;                         /* Return code */\n\n  pCsr->iRowid++;\n  rc = pTab->pMod->xNext(pCsr->pCsr,\n      &pCsr->zToken, &pCsr->nToken,\n      &pCsr->iStart, &pCsr->iEnd, &pCsr->iPos\n  );\n\n  if( rc!=SQLITE_OK ){\n    fts3tokResetCursor(pCsr);\n    if( rc==SQLITE_DONE ) rc = SQLITE_OK;\n  }\n\n  return rc;\n}\n\n/*\n** xFilter - Initialize a cursor to point at the start of its data.\n*/\nstatic int fts3tokFilterMethod(\n  sqlite3_vtab_cursor *pCursor,   /* The cursor used for this query */\n  int idxNum,                     /* Strategy index */\n  const char *idxStr,             /* Unused */\n  int nVal,                       /* Number of elements in apVal */\n  sqlite3_value **apVal           /* Arguments for the indexing scheme */\n){\n  int rc = SQLITE_ERROR;\n  Fts3tokCursor *pCsr = (Fts3tokCursor *)pCursor;\n  Fts3tokTable *pTab = (Fts3tokTable *)(pCursor->pVtab);\n  UNUSED_PARAMETER(idxStr);\n  UNUSED_PARAMETER(nVal);\n\n  fts3tokResetCursor(pCsr);\n  if( idxNum==1 ){\n    const char *zByte = (const char *)sqlite3_value_text(apVal[0]);\n    int nByte = sqlite3_value_bytes(apVal[0]);\n    pCsr->zInput = sqlite3_malloc(nByte+1);\n    if( pCsr->zInput==0 ){\n      rc = SQLITE_NOMEM;\n    }else{\n      memcpy(pCsr->zInput, zByte, nByte);\n      pCsr->zInput[nByte] = 0;\n      rc = pTab->pMod->xOpen(pTab->pTok, pCsr->zInput, nByte, &pCsr->pCsr);\n      if( rc==SQLITE_OK ){\n        pCsr->pCsr->pTokenizer = pTab->pTok;\n      }\n    }\n  }\n\n  if( rc!=SQLITE_OK ) return rc;\n  return fts3tokNextMethod(pCursor);\n}\n\n/*\n** xEof - Return true if the cursor is at EOF, or false otherwise.\n*/\nstatic int fts3tokEofMethod(sqlite3_vtab_cursor *pCursor){\n  Fts3tokCursor *pCsr = (Fts3tokCursor *)pCursor;\n  return (pCsr->zToken==0);\n}\n\n/*\n** xColumn - Return a column value.\n*/\nstatic int fts3tokColumnMethod(\n  sqlite3_vtab_cursor *pCursor,   /* Cursor to retrieve value from */\n  sqlite3_context *pCtx,          /* Context for sqlite3_result_xxx() calls */\n  int iCol                        /* Index of column to read value from */\n){\n  Fts3tokCursor *pCsr = (Fts3tokCursor *)pCursor;\n\n  /* CREATE TABLE x(input, token, start, end, position) */\n  switch( iCol ){\n    case 0:\n      sqlite3_result_text(pCtx, pCsr->zInput, -1, SQLITE_TRANSIENT);\n      break;\n    case 1:\n      sqlite3_result_text(pCtx, pCsr->zToken, pCsr->nToken, SQLITE_TRANSIENT);\n      break;\n    case 2:\n      sqlite3_result_int(pCtx, pCsr->iStart);\n      break;\n    case 3:\n      sqlite3_result_int(pCtx, pCsr->iEnd);\n      break;\n    default:\n      assert( iCol==4 );\n      sqlite3_result_int(pCtx, pCsr->iPos);\n      break;\n  }\n  return SQLITE_OK;\n}\n\n/*\n** xRowid - Return the current rowid for the cursor.\n*/\nstatic int fts3tokRowidMethod(\n  sqlite3_vtab_cursor *pCursor,   /* Cursor to retrieve value from */\n  sqlite_int64 *pRowid            /* OUT: Rowid value */\n){\n  Fts3tokCursor *pCsr = (Fts3tokCursor *)pCursor;\n  *pRowid = (sqlite3_int64)pCsr->iRowid;\n  return SQLITE_OK;\n}\n\n/*\n** Register the fts3tok module with database connection db. Return SQLITE_OK\n** if successful or an error code if sqlite3_create_module() fails.\n*/\nSQLITE_PRIVATE int sqlite3Fts3InitTok(sqlite3 *db, Fts3Hash *pHash){\n  static const sqlite3_module fts3tok_module = {\n     0,                           /* iVersion      */\n     fts3tokConnectMethod,        /* xCreate       */\n     fts3tokConnectMethod,        /* xConnect      */\n     fts3tokBestIndexMethod,      /* xBestIndex    */\n     fts3tokDisconnectMethod,     /* xDisconnect   */\n     fts3tokDisconnectMethod,     /* xDestroy      */\n     fts3tokOpenMethod,           /* xOpen         */\n     fts3tokCloseMethod,          /* xClose        */\n     fts3tokFilterMethod,         /* xFilter       */\n     fts3tokNextMethod,           /* xNext         */\n     fts3tokEofMethod,            /* xEof          */\n     fts3tokColumnMethod,         /* xColumn       */\n     fts3tokRowidMethod,          /* xRowid        */\n     0,                           /* xUpdate       */\n     0,                           /* xBegin        */\n     0,                           /* xSync         */\n     0,                           /* xCommit       */\n     0,                           /* xRollback     */\n     0,                           /* xFindFunction */\n     0,                           /* xRename       */\n     0,                           /* xSavepoint    */\n     0,                           /* xRelease      */\n     0,                           /* xRollbackTo   */\n     0                            /* xShadowName   */\n  };\n  int rc;                         /* Return code */\n\n  rc = sqlite3_create_module(db, \"fts3tokenize\", &fts3tok_module, (void*)pHash);\n  return rc;\n}\n\n#endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3) */\n\n/************** End of fts3_tokenize_vtab.c **********************************/\n/************** Begin file fts3_write.c **************************************/\n/*\n** 2009 Oct 23\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n******************************************************************************\n**\n** This file is part of the SQLite FTS3 extension module. Specifically,\n** this file contains code to insert, update and delete rows from FTS3\n** tables. It also contains code to merge FTS3 b-tree segments. Some\n** of the sub-routines used to merge segments are also used by the query \n** code in fts3.c.\n*/\n\n/* #include \"fts3Int.h\" */\n#if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3)\n\n/* #include <string.h> */\n/* #include <assert.h> */\n/* #include <stdlib.h> */\n\n\n#define FTS_MAX_APPENDABLE_HEIGHT 16\n\n/*\n** When full-text index nodes are loaded from disk, the buffer that they\n** are loaded into has the following number of bytes of padding at the end \n** of it. i.e. if a full-text index node is 900 bytes in size, then a buffer\n** of 920 bytes is allocated for it.\n**\n** This means that if we have a pointer into a buffer containing node data,\n** it is always safe to read up to two varints from it without risking an\n** overread, even if the node data is corrupted.\n*/\n#define FTS3_NODE_PADDING (FTS3_VARINT_MAX*2)\n\n/*\n** Under certain circumstances, b-tree nodes (doclists) can be loaded into\n** memory incrementally instead of all at once. This can be a big performance\n** win (reduced IO and CPU) if SQLite stops calling the virtual table xNext()\n** method before retrieving all query results (as may happen, for example,\n** if a query has a LIMIT clause).\n**\n** Incremental loading is used for b-tree nodes FTS3_NODE_CHUNK_THRESHOLD \n** bytes and larger. Nodes are loaded in chunks of FTS3_NODE_CHUNKSIZE bytes.\n** The code is written so that the hard lower-limit for each of these values \n** is 1. Clearly such small values would be inefficient, but can be useful \n** for testing purposes.\n**\n** If this module is built with SQLITE_TEST defined, these constants may\n** be overridden at runtime for testing purposes. File fts3_test.c contains\n** a Tcl interface to read and write the values.\n*/\n#ifdef SQLITE_TEST\nint test_fts3_node_chunksize = (4*1024);\nint test_fts3_node_chunk_threshold = (4*1024)*4;\n# define FTS3_NODE_CHUNKSIZE       test_fts3_node_chunksize\n# define FTS3_NODE_CHUNK_THRESHOLD test_fts3_node_chunk_threshold\n#else\n# define FTS3_NODE_CHUNKSIZE (4*1024) \n# define FTS3_NODE_CHUNK_THRESHOLD (FTS3_NODE_CHUNKSIZE*4)\n#endif\n\n/*\n** The two values that may be meaningfully bound to the :1 parameter in\n** statements SQL_REPLACE_STAT and SQL_SELECT_STAT.\n*/\n#define FTS_STAT_DOCTOTAL      0\n#define FTS_STAT_INCRMERGEHINT 1\n#define FTS_STAT_AUTOINCRMERGE 2\n\n/*\n** If FTS_LOG_MERGES is defined, call sqlite3_log() to report each automatic\n** and incremental merge operation that takes place. This is used for \n** debugging FTS only, it should not usually be turned on in production\n** systems.\n*/\n#ifdef FTS3_LOG_MERGES\nstatic void fts3LogMerge(int nMerge, sqlite3_int64 iAbsLevel){\n  sqlite3_log(SQLITE_OK, \"%d-way merge from level %d\", nMerge, (int)iAbsLevel);\n}\n#else\n#define fts3LogMerge(x, y)\n#endif\n\n\ntypedef struct PendingList PendingList;\ntypedef struct SegmentNode SegmentNode;\ntypedef struct SegmentWriter SegmentWriter;\n\n/*\n** An instance of the following data structure is used to build doclists\n** incrementally. See function fts3PendingListAppend() for details.\n*/\nstruct PendingList {\n  int nData;\n  char *aData;\n  int nSpace;\n  sqlite3_int64 iLastDocid;\n  sqlite3_int64 iLastCol;\n  sqlite3_int64 iLastPos;\n};\n\n\n/*\n** Each cursor has a (possibly empty) linked list of the following objects.\n*/\nstruct Fts3DeferredToken {\n  Fts3PhraseToken *pToken;        /* Pointer to corresponding expr token */\n  int iCol;                       /* Column token must occur in */\n  Fts3DeferredToken *pNext;       /* Next in list of deferred tokens */\n  PendingList *pList;             /* Doclist is assembled here */\n};\n\n/*\n** An instance of this structure is used to iterate through the terms on\n** a contiguous set of segment b-tree leaf nodes. Although the details of\n** this structure are only manipulated by code in this file, opaque handles\n** of type Fts3SegReader* are also used by code in fts3.c to iterate through\n** terms when querying the full-text index. See functions:\n**\n**   sqlite3Fts3SegReaderNew()\n**   sqlite3Fts3SegReaderFree()\n**   sqlite3Fts3SegReaderIterate()\n**\n** Methods used to manipulate Fts3SegReader structures:\n**\n**   fts3SegReaderNext()\n**   fts3SegReaderFirstDocid()\n**   fts3SegReaderNextDocid()\n*/\nstruct Fts3SegReader {\n  int iIdx;                       /* Index within level, or 0x7FFFFFFF for PT */\n  u8 bLookup;                     /* True for a lookup only */\n  u8 rootOnly;                    /* True for a root-only reader */\n\n  sqlite3_int64 iStartBlock;      /* Rowid of first leaf block to traverse */\n  sqlite3_int64 iLeafEndBlock;    /* Rowid of final leaf block to traverse */\n  sqlite3_int64 iEndBlock;        /* Rowid of final block in segment (or 0) */\n  sqlite3_int64 iCurrentBlock;    /* Current leaf block (or 0) */\n\n  char *aNode;                    /* Pointer to node data (or NULL) */\n  int nNode;                      /* Size of buffer at aNode (or 0) */\n  int nPopulate;                  /* If >0, bytes of buffer aNode[] loaded */\n  sqlite3_blob *pBlob;            /* If not NULL, blob handle to read node */\n\n  Fts3HashElem **ppNextElem;\n\n  /* Variables set by fts3SegReaderNext(). These may be read directly\n  ** by the caller. They are valid from the time SegmentReaderNew() returns\n  ** until SegmentReaderNext() returns something other than SQLITE_OK\n  ** (i.e. SQLITE_DONE).\n  */\n  int nTerm;                      /* Number of bytes in current term */\n  char *zTerm;                    /* Pointer to current term */\n  int nTermAlloc;                 /* Allocated size of zTerm buffer */\n  char *aDoclist;                 /* Pointer to doclist of current entry */\n  int nDoclist;                   /* Size of doclist in current entry */\n\n  /* The following variables are used by fts3SegReaderNextDocid() to iterate \n  ** through the current doclist (aDoclist/nDoclist).\n  */\n  char *pOffsetList;\n  int nOffsetList;                /* For descending pending seg-readers only */\n  sqlite3_int64 iDocid;\n};\n\n#define fts3SegReaderIsPending(p) ((p)->ppNextElem!=0)\n#define fts3SegReaderIsRootOnly(p) ((p)->rootOnly!=0)\n\n/*\n** An instance of this structure is used to create a segment b-tree in the\n** database. The internal details of this type are only accessed by the\n** following functions:\n**\n**   fts3SegWriterAdd()\n**   fts3SegWriterFlush()\n**   fts3SegWriterFree()\n*/\nstruct SegmentWriter {\n  SegmentNode *pTree;             /* Pointer to interior tree structure */\n  sqlite3_int64 iFirst;           /* First slot in %_segments written */\n  sqlite3_int64 iFree;            /* Next free slot in %_segments */\n  char *zTerm;                    /* Pointer to previous term buffer */\n  int nTerm;                      /* Number of bytes in zTerm */\n  int nMalloc;                    /* Size of malloc'd buffer at zMalloc */\n  char *zMalloc;                  /* Malloc'd space (possibly) used for zTerm */\n  int nSize;                      /* Size of allocation at aData */\n  int nData;                      /* Bytes of data in aData */\n  char *aData;                    /* Pointer to block from malloc() */\n  i64 nLeafData;                  /* Number of bytes of leaf data written */\n};\n\n/*\n** Type SegmentNode is used by the following three functions to create\n** the interior part of the segment b+-tree structures (everything except\n** the leaf nodes). These functions and type are only ever used by code\n** within the fts3SegWriterXXX() family of functions described above.\n**\n**   fts3NodeAddTerm()\n**   fts3NodeWrite()\n**   fts3NodeFree()\n**\n** When a b+tree is written to the database (either as a result of a merge\n** or the pending-terms table being flushed), leaves are written into the \n** database file as soon as they are completely populated. The interior of\n** the tree is assembled in memory and written out only once all leaves have\n** been populated and stored. This is Ok, as the b+-tree fanout is usually\n** very large, meaning that the interior of the tree consumes relatively \n** little memory.\n*/\nstruct SegmentNode {\n  SegmentNode *pParent;           /* Parent node (or NULL for root node) */\n  SegmentNode *pRight;            /* Pointer to right-sibling */\n  SegmentNode *pLeftmost;         /* Pointer to left-most node of this depth */\n  int nEntry;                     /* Number of terms written to node so far */\n  char *zTerm;                    /* Pointer to previous term buffer */\n  int nTerm;                      /* Number of bytes in zTerm */\n  int nMalloc;                    /* Size of malloc'd buffer at zMalloc */\n  char *zMalloc;                  /* Malloc'd space (possibly) used for zTerm */\n  int nData;                      /* Bytes of valid data so far */\n  char *aData;                    /* Node data */\n};\n\n/*\n** Valid values for the second argument to fts3SqlStmt().\n*/\n#define SQL_DELETE_CONTENT             0\n#define SQL_IS_EMPTY                   1\n#define SQL_DELETE_ALL_CONTENT         2 \n#define SQL_DELETE_ALL_SEGMENTS        3\n#define SQL_DELETE_ALL_SEGDIR          4\n#define SQL_DELETE_ALL_DOCSIZE         5\n#define SQL_DELETE_ALL_STAT            6\n#define SQL_SELECT_CONTENT_BY_ROWID    7\n#define SQL_NEXT_SEGMENT_INDEX         8\n#define SQL_INSERT_SEGMENTS            9\n#define SQL_NEXT_SEGMENTS_ID          10\n#define SQL_INSERT_SEGDIR             11\n#define SQL_SELECT_LEVEL              12\n#define SQL_SELECT_LEVEL_RANGE        13\n#define SQL_SELECT_LEVEL_COUNT        14\n#define SQL_SELECT_SEGDIR_MAX_LEVEL   15\n#define SQL_DELETE_SEGDIR_LEVEL       16\n#define SQL_DELETE_SEGMENTS_RANGE     17\n#define SQL_CONTENT_INSERT            18\n#define SQL_DELETE_DOCSIZE            19\n#define SQL_REPLACE_DOCSIZE           20\n#define SQL_SELECT_DOCSIZE            21\n#define SQL_SELECT_STAT               22\n#define SQL_REPLACE_STAT              23\n\n#define SQL_SELECT_ALL_PREFIX_LEVEL   24\n#define SQL_DELETE_ALL_TERMS_SEGDIR   25\n#define SQL_DELETE_SEGDIR_RANGE       26\n#define SQL_SELECT_ALL_LANGID         27\n#define SQL_FIND_MERGE_LEVEL          28\n#define SQL_MAX_LEAF_NODE_ESTIMATE    29\n#define SQL_DELETE_SEGDIR_ENTRY       30\n#define SQL_SHIFT_SEGDIR_ENTRY        31\n#define SQL_SELECT_SEGDIR             32\n#define SQL_CHOMP_SEGDIR              33\n#define SQL_SEGMENT_IS_APPENDABLE     34\n#define SQL_SELECT_INDEXES            35\n#define SQL_SELECT_MXLEVEL            36\n\n#define SQL_SELECT_LEVEL_RANGE2       37\n#define SQL_UPDATE_LEVEL_IDX          38\n#define SQL_UPDATE_LEVEL              39\n\n/*\n** This function is used to obtain an SQLite prepared statement handle\n** for the statement identified by the second argument. If successful,\n** *pp is set to the requested statement handle and SQLITE_OK returned.\n** Otherwise, an SQLite error code is returned and *pp is set to 0.\n**\n** If argument apVal is not NULL, then it must point to an array with\n** at least as many entries as the requested statement has bound \n** parameters. The values are bound to the statements parameters before\n** returning.\n*/\nstatic int fts3SqlStmt(\n  Fts3Table *p,                   /* Virtual table handle */\n  int eStmt,                      /* One of the SQL_XXX constants above */\n  sqlite3_stmt **pp,              /* OUT: Statement handle */\n  sqlite3_value **apVal           /* Values to bind to statement */\n){\n  const char *azSql[] = {\n/* 0  */  \"DELETE FROM %Q.'%q_content' WHERE rowid = ?\",\n/* 1  */  \"SELECT NOT EXISTS(SELECT docid FROM %Q.'%q_content' WHERE rowid!=?)\",\n/* 2  */  \"DELETE FROM %Q.'%q_content'\",\n/* 3  */  \"DELETE FROM %Q.'%q_segments'\",\n/* 4  */  \"DELETE FROM %Q.'%q_segdir'\",\n/* 5  */  \"DELETE FROM %Q.'%q_docsize'\",\n/* 6  */  \"DELETE FROM %Q.'%q_stat'\",\n/* 7  */  \"SELECT %s WHERE rowid=?\",\n/* 8  */  \"SELECT (SELECT max(idx) FROM %Q.'%q_segdir' WHERE level = ?) + 1\",\n/* 9  */  \"REPLACE INTO %Q.'%q_segments'(blockid, block) VALUES(?, ?)\",\n/* 10 */  \"SELECT coalesce((SELECT max(blockid) FROM %Q.'%q_segments') + 1, 1)\",\n/* 11 */  \"REPLACE INTO %Q.'%q_segdir' VALUES(?,?,?,?,?,?)\",\n\n          /* Return segments in order from oldest to newest.*/ \n/* 12 */  \"SELECT idx, start_block, leaves_end_block, end_block, root \"\n            \"FROM %Q.'%q_segdir' WHERE level = ? ORDER BY idx ASC\",\n/* 13 */  \"SELECT idx, start_block, leaves_end_block, end_block, root \"\n            \"FROM %Q.'%q_segdir' WHERE level BETWEEN ? AND ?\"\n            \"ORDER BY level DESC, idx ASC\",\n\n/* 14 */  \"SELECT count(*) FROM %Q.'%q_segdir' WHERE level = ?\",\n/* 15 */  \"SELECT max(level) FROM %Q.'%q_segdir' WHERE level BETWEEN ? AND ?\",\n\n/* 16 */  \"DELETE FROM %Q.'%q_segdir' WHERE level = ?\",\n/* 17 */  \"DELETE FROM %Q.'%q_segments' WHERE blockid BETWEEN ? AND ?\",\n/* 18 */  \"INSERT INTO %Q.'%q_content' VALUES(%s)\",\n/* 19 */  \"DELETE FROM %Q.'%q_docsize' WHERE docid = ?\",\n/* 20 */  \"REPLACE INTO %Q.'%q_docsize' VALUES(?,?)\",\n/* 21 */  \"SELECT size FROM %Q.'%q_docsize' WHERE docid=?\",\n/* 22 */  \"SELECT value FROM %Q.'%q_stat' WHERE id=?\",\n/* 23 */  \"REPLACE INTO %Q.'%q_stat' VALUES(?,?)\",\n/* 24 */  \"\",\n/* 25 */  \"\",\n\n/* 26 */ \"DELETE FROM %Q.'%q_segdir' WHERE level BETWEEN ? AND ?\",\n/* 27 */ \"SELECT ? UNION SELECT level / (1024 * ?) FROM %Q.'%q_segdir'\",\n\n/* This statement is used to determine which level to read the input from\n** when performing an incremental merge. It returns the absolute level number\n** of the oldest level in the db that contains at least ? segments. Or,\n** if no level in the FTS index contains more than ? segments, the statement\n** returns zero rows.  */\n/* 28 */ \"SELECT level, count(*) AS cnt FROM %Q.'%q_segdir' \"\n         \"  GROUP BY level HAVING cnt>=?\"\n         \"  ORDER BY (level %% 1024) ASC LIMIT 1\",\n\n/* Estimate the upper limit on the number of leaf nodes in a new segment\n** created by merging the oldest :2 segments from absolute level :1. See \n** function sqlite3Fts3Incrmerge() for details.  */\n/* 29 */ \"SELECT 2 * total(1 + leaves_end_block - start_block) \"\n         \"  FROM %Q.'%q_segdir' WHERE level = ? AND idx < ?\",\n\n/* SQL_DELETE_SEGDIR_ENTRY\n**   Delete the %_segdir entry on absolute level :1 with index :2.  */\n/* 30 */ \"DELETE FROM %Q.'%q_segdir' WHERE level = ? AND idx = ?\",\n\n/* SQL_SHIFT_SEGDIR_ENTRY\n**   Modify the idx value for the segment with idx=:3 on absolute level :2\n**   to :1.  */\n/* 31 */ \"UPDATE %Q.'%q_segdir' SET idx = ? WHERE level=? AND idx=?\",\n\n/* SQL_SELECT_SEGDIR\n**   Read a single entry from the %_segdir table. The entry from absolute \n**   level :1 with index value :2.  */\n/* 32 */  \"SELECT idx, start_block, leaves_end_block, end_block, root \"\n            \"FROM %Q.'%q_segdir' WHERE level = ? AND idx = ?\",\n\n/* SQL_CHOMP_SEGDIR\n**   Update the start_block (:1) and root (:2) fields of the %_segdir\n**   entry located on absolute level :3 with index :4.  */\n/* 33 */  \"UPDATE %Q.'%q_segdir' SET start_block = ?, root = ?\"\n            \"WHERE level = ? AND idx = ?\",\n\n/* SQL_SEGMENT_IS_APPENDABLE\n**   Return a single row if the segment with end_block=? is appendable. Or\n**   no rows otherwise.  */\n/* 34 */  \"SELECT 1 FROM %Q.'%q_segments' WHERE blockid=? AND block IS NULL\",\n\n/* SQL_SELECT_INDEXES\n**   Return the list of valid segment indexes for absolute level ?  */\n/* 35 */  \"SELECT idx FROM %Q.'%q_segdir' WHERE level=? ORDER BY 1 ASC\",\n\n/* SQL_SELECT_MXLEVEL\n**   Return the largest relative level in the FTS index or indexes.  */\n/* 36 */  \"SELECT max( level %% 1024 ) FROM %Q.'%q_segdir'\",\n\n          /* Return segments in order from oldest to newest.*/ \n/* 37 */  \"SELECT level, idx, end_block \"\n            \"FROM %Q.'%q_segdir' WHERE level BETWEEN ? AND ? \"\n            \"ORDER BY level DESC, idx ASC\",\n\n          /* Update statements used while promoting segments */\n/* 38 */  \"UPDATE OR FAIL %Q.'%q_segdir' SET level=-1,idx=? \"\n            \"WHERE level=? AND idx=?\",\n/* 39 */  \"UPDATE OR FAIL %Q.'%q_segdir' SET level=? WHERE level=-1\"\n\n  };\n  int rc = SQLITE_OK;\n  sqlite3_stmt *pStmt;\n\n  assert( SizeofArray(azSql)==SizeofArray(p->aStmt) );\n  assert( eStmt<SizeofArray(azSql) && eStmt>=0 );\n  \n  pStmt = p->aStmt[eStmt];\n  if( !pStmt ){\n    int f = SQLITE_PREPARE_PERSISTENT|SQLITE_PREPARE_NO_VTAB;\n    char *zSql;\n    if( eStmt==SQL_CONTENT_INSERT ){\n      zSql = sqlite3_mprintf(azSql[eStmt], p->zDb, p->zName, p->zWriteExprlist);\n    }else if( eStmt==SQL_SELECT_CONTENT_BY_ROWID ){\n      f &= ~SQLITE_PREPARE_NO_VTAB;\n      zSql = sqlite3_mprintf(azSql[eStmt], p->zReadExprlist);\n    }else{\n      zSql = sqlite3_mprintf(azSql[eStmt], p->zDb, p->zName);\n    }\n    if( !zSql ){\n      rc = SQLITE_NOMEM;\n    }else{\n      rc = sqlite3_prepare_v3(p->db, zSql, -1, f, &pStmt, NULL);\n      sqlite3_free(zSql);\n      assert( rc==SQLITE_OK || pStmt==0 );\n      p->aStmt[eStmt] = pStmt;\n    }\n  }\n  if( apVal ){\n    int i;\n    int nParam = sqlite3_bind_parameter_count(pStmt);\n    for(i=0; rc==SQLITE_OK && i<nParam; i++){\n      rc = sqlite3_bind_value(pStmt, i+1, apVal[i]);\n    }\n  }\n  *pp = pStmt;\n  return rc;\n}\n\n\nstatic int fts3SelectDocsize(\n  Fts3Table *pTab,                /* FTS3 table handle */\n  sqlite3_int64 iDocid,           /* Docid to bind for SQL_SELECT_DOCSIZE */\n  sqlite3_stmt **ppStmt           /* OUT: Statement handle */\n){\n  sqlite3_stmt *pStmt = 0;        /* Statement requested from fts3SqlStmt() */\n  int rc;                         /* Return code */\n\n  rc = fts3SqlStmt(pTab, SQL_SELECT_DOCSIZE, &pStmt, 0);\n  if( rc==SQLITE_OK ){\n    sqlite3_bind_int64(pStmt, 1, iDocid);\n    rc = sqlite3_step(pStmt);\n    if( rc!=SQLITE_ROW || sqlite3_column_type(pStmt, 0)!=SQLITE_BLOB ){\n      rc = sqlite3_reset(pStmt);\n      if( rc==SQLITE_OK ) rc = FTS_CORRUPT_VTAB;\n      pStmt = 0;\n    }else{\n      rc = SQLITE_OK;\n    }\n  }\n\n  *ppStmt = pStmt;\n  return rc;\n}\n\nSQLITE_PRIVATE int sqlite3Fts3SelectDoctotal(\n  Fts3Table *pTab,                /* Fts3 table handle */\n  sqlite3_stmt **ppStmt           /* OUT: Statement handle */\n){\n  sqlite3_stmt *pStmt = 0;\n  int rc;\n  rc = fts3SqlStmt(pTab, SQL_SELECT_STAT, &pStmt, 0);\n  if( rc==SQLITE_OK ){\n    sqlite3_bind_int(pStmt, 1, FTS_STAT_DOCTOTAL);\n    if( sqlite3_step(pStmt)!=SQLITE_ROW\n     || sqlite3_column_type(pStmt, 0)!=SQLITE_BLOB\n    ){\n      rc = sqlite3_reset(pStmt);\n      if( rc==SQLITE_OK ) rc = FTS_CORRUPT_VTAB;\n      pStmt = 0;\n    }\n  }\n  *ppStmt = pStmt;\n  return rc;\n}\n\nSQLITE_PRIVATE int sqlite3Fts3SelectDocsize(\n  Fts3Table *pTab,                /* Fts3 table handle */\n  sqlite3_int64 iDocid,           /* Docid to read size data for */\n  sqlite3_stmt **ppStmt           /* OUT: Statement handle */\n){\n  return fts3SelectDocsize(pTab, iDocid, ppStmt);\n}\n\n/*\n** Similar to fts3SqlStmt(). Except, after binding the parameters in\n** array apVal[] to the SQL statement identified by eStmt, the statement\n** is executed.\n**\n** Returns SQLITE_OK if the statement is successfully executed, or an\n** SQLite error code otherwise.\n*/\nstatic void fts3SqlExec(\n  int *pRC,                /* Result code */\n  Fts3Table *p,            /* The FTS3 table */\n  int eStmt,               /* Index of statement to evaluate */\n  sqlite3_value **apVal    /* Parameters to bind */\n){\n  sqlite3_stmt *pStmt;\n  int rc;\n  if( *pRC ) return;\n  rc = fts3SqlStmt(p, eStmt, &pStmt, apVal); \n  if( rc==SQLITE_OK ){\n    sqlite3_step(pStmt);\n    rc = sqlite3_reset(pStmt);\n  }\n  *pRC = rc;\n}\n\n\n/*\n** This function ensures that the caller has obtained an exclusive \n** shared-cache table-lock on the %_segdir table. This is required before \n** writing data to the fts3 table. If this lock is not acquired first, then\n** the caller may end up attempting to take this lock as part of committing\n** a transaction, causing SQLite to return SQLITE_LOCKED or \n** LOCKED_SHAREDCACHEto a COMMIT command.\n**\n** It is best to avoid this because if FTS3 returns any error when \n** committing a transaction, the whole transaction will be rolled back. \n** And this is not what users expect when they get SQLITE_LOCKED_SHAREDCACHE. \n** It can still happen if the user locks the underlying tables directly \n** instead of accessing them via FTS.\n*/\nstatic int fts3Writelock(Fts3Table *p){\n  int rc = SQLITE_OK;\n  \n  if( p->nPendingData==0 ){\n    sqlite3_stmt *pStmt;\n    rc = fts3SqlStmt(p, SQL_DELETE_SEGDIR_LEVEL, &pStmt, 0);\n    if( rc==SQLITE_OK ){\n      sqlite3_bind_null(pStmt, 1);\n      sqlite3_step(pStmt);\n      rc = sqlite3_reset(pStmt);\n    }\n  }\n\n  return rc;\n}\n\n/*\n** FTS maintains a separate indexes for each language-id (a 32-bit integer).\n** Within each language id, a separate index is maintained to store the\n** document terms, and each configured prefix size (configured the FTS \n** \"prefix=\" option). And each index consists of multiple levels (\"relative\n** levels\").\n**\n** All three of these values (the language id, the specific index and the\n** level within the index) are encoded in 64-bit integer values stored\n** in the %_segdir table on disk. This function is used to convert three\n** separate component values into the single 64-bit integer value that\n** can be used to query the %_segdir table.\n**\n** Specifically, each language-id/index combination is allocated 1024 \n** 64-bit integer level values (\"absolute levels\"). The main terms index\n** for language-id 0 is allocate values 0-1023. The first prefix index\n** (if any) for language-id 0 is allocated values 1024-2047. And so on.\n** Language 1 indexes are allocated immediately following language 0.\n**\n** So, for a system with nPrefix prefix indexes configured, the block of\n** absolute levels that corresponds to language-id iLangid and index \n** iIndex starts at absolute level ((iLangid * (nPrefix+1) + iIndex) * 1024).\n*/\nstatic sqlite3_int64 getAbsoluteLevel(\n  Fts3Table *p,                   /* FTS3 table handle */\n  int iLangid,                    /* Language id */\n  int iIndex,                     /* Index in p->aIndex[] */\n  int iLevel                      /* Level of segments */\n){\n  sqlite3_int64 iBase;            /* First absolute level for iLangid/iIndex */\n  assert_fts3_nc( iLangid>=0 );\n  assert( p->nIndex>0 );\n  assert( iIndex>=0 && iIndex<p->nIndex );\n\n  iBase = ((sqlite3_int64)iLangid * p->nIndex + iIndex) * FTS3_SEGDIR_MAXLEVEL;\n  return iBase + iLevel;\n}\n\n/*\n** Set *ppStmt to a statement handle that may be used to iterate through\n** all rows in the %_segdir table, from oldest to newest. If successful,\n** return SQLITE_OK. If an error occurs while preparing the statement, \n** return an SQLite error code.\n**\n** There is only ever one instance of this SQL statement compiled for\n** each FTS3 table.\n**\n** The statement returns the following columns from the %_segdir table:\n**\n**   0: idx\n**   1: start_block\n**   2: leaves_end_block\n**   3: end_block\n**   4: root\n*/\nSQLITE_PRIVATE int sqlite3Fts3AllSegdirs(\n  Fts3Table *p,                   /* FTS3 table */\n  int iLangid,                    /* Language being queried */\n  int iIndex,                     /* Index for p->aIndex[] */\n  int iLevel,                     /* Level to select (relative level) */\n  sqlite3_stmt **ppStmt           /* OUT: Compiled statement */\n){\n  int rc;\n  sqlite3_stmt *pStmt = 0;\n\n  assert( iLevel==FTS3_SEGCURSOR_ALL || iLevel>=0 );\n  assert( iLevel<FTS3_SEGDIR_MAXLEVEL );\n  assert( iIndex>=0 && iIndex<p->nIndex );\n\n  if( iLevel<0 ){\n    /* \"SELECT * FROM %_segdir WHERE level BETWEEN ? AND ? ORDER BY ...\" */\n    rc = fts3SqlStmt(p, SQL_SELECT_LEVEL_RANGE, &pStmt, 0);\n    if( rc==SQLITE_OK ){ \n      sqlite3_bind_int64(pStmt, 1, getAbsoluteLevel(p, iLangid, iIndex, 0));\n      sqlite3_bind_int64(pStmt, 2, \n          getAbsoluteLevel(p, iLangid, iIndex, FTS3_SEGDIR_MAXLEVEL-1)\n      );\n    }\n  }else{\n    /* \"SELECT * FROM %_segdir WHERE level = ? ORDER BY ...\" */\n    rc = fts3SqlStmt(p, SQL_SELECT_LEVEL, &pStmt, 0);\n    if( rc==SQLITE_OK ){ \n      sqlite3_bind_int64(pStmt, 1, getAbsoluteLevel(p, iLangid, iIndex,iLevel));\n    }\n  }\n  *ppStmt = pStmt;\n  return rc;\n}\n\n\n/*\n** Append a single varint to a PendingList buffer. SQLITE_OK is returned\n** if successful, or an SQLite error code otherwise.\n**\n** This function also serves to allocate the PendingList structure itself.\n** For example, to create a new PendingList structure containing two\n** varints:\n**\n**   PendingList *p = 0;\n**   fts3PendingListAppendVarint(&p, 1);\n**   fts3PendingListAppendVarint(&p, 2);\n*/\nstatic int fts3PendingListAppendVarint(\n  PendingList **pp,               /* IN/OUT: Pointer to PendingList struct */\n  sqlite3_int64 i                 /* Value to append to data */\n){\n  PendingList *p = *pp;\n\n  /* Allocate or grow the PendingList as required. */\n  if( !p ){\n    p = sqlite3_malloc(sizeof(*p) + 100);\n    if( !p ){\n      return SQLITE_NOMEM;\n    }\n    p->nSpace = 100;\n    p->aData = (char *)&p[1];\n    p->nData = 0;\n  }\n  else if( p->nData+FTS3_VARINT_MAX+1>p->nSpace ){\n    int nNew = p->nSpace * 2;\n    p = sqlite3_realloc(p, sizeof(*p) + nNew);\n    if( !p ){\n      sqlite3_free(*pp);\n      *pp = 0;\n      return SQLITE_NOMEM;\n    }\n    p->nSpace = nNew;\n    p->aData = (char *)&p[1];\n  }\n\n  /* Append the new serialized varint to the end of the list. */\n  p->nData += sqlite3Fts3PutVarint(&p->aData[p->nData], i);\n  p->aData[p->nData] = '\\0';\n  *pp = p;\n  return SQLITE_OK;\n}\n\n/*\n** Add a docid/column/position entry to a PendingList structure. Non-zero\n** is returned if the structure is sqlite3_realloced as part of adding\n** the entry. Otherwise, zero.\n**\n** If an OOM error occurs, *pRc is set to SQLITE_NOMEM before returning.\n** Zero is always returned in this case. Otherwise, if no OOM error occurs,\n** it is set to SQLITE_OK.\n*/\nstatic int fts3PendingListAppend(\n  PendingList **pp,               /* IN/OUT: PendingList structure */\n  sqlite3_int64 iDocid,           /* Docid for entry to add */\n  sqlite3_int64 iCol,             /* Column for entry to add */\n  sqlite3_int64 iPos,             /* Position of term for entry to add */\n  int *pRc                        /* OUT: Return code */\n){\n  PendingList *p = *pp;\n  int rc = SQLITE_OK;\n\n  assert( !p || p->iLastDocid<=iDocid );\n\n  if( !p || p->iLastDocid!=iDocid ){\n    sqlite3_int64 iDelta = iDocid - (p ? p->iLastDocid : 0);\n    if( p ){\n      assert( p->nData<p->nSpace );\n      assert( p->aData[p->nData]==0 );\n      p->nData++;\n    }\n    if( SQLITE_OK!=(rc = fts3PendingListAppendVarint(&p, iDelta)) ){\n      goto pendinglistappend_out;\n    }\n    p->iLastCol = -1;\n    p->iLastPos = 0;\n    p->iLastDocid = iDocid;\n  }\n  if( iCol>0 && p->iLastCol!=iCol ){\n    if( SQLITE_OK!=(rc = fts3PendingListAppendVarint(&p, 1))\n     || SQLITE_OK!=(rc = fts3PendingListAppendVarint(&p, iCol))\n    ){\n      goto pendinglistappend_out;\n    }\n    p->iLastCol = iCol;\n    p->iLastPos = 0;\n  }\n  if( iCol>=0 ){\n    assert( iPos>p->iLastPos || (iPos==0 && p->iLastPos==0) );\n    rc = fts3PendingListAppendVarint(&p, 2+iPos-p->iLastPos);\n    if( rc==SQLITE_OK ){\n      p->iLastPos = iPos;\n    }\n  }\n\n pendinglistappend_out:\n  *pRc = rc;\n  if( p!=*pp ){\n    *pp = p;\n    return 1;\n  }\n  return 0;\n}\n\n/*\n** Free a PendingList object allocated by fts3PendingListAppend().\n*/\nstatic void fts3PendingListDelete(PendingList *pList){\n  sqlite3_free(pList);\n}\n\n/*\n** Add an entry to one of the pending-terms hash tables.\n*/\nstatic int fts3PendingTermsAddOne(\n  Fts3Table *p,\n  int iCol,\n  int iPos,\n  Fts3Hash *pHash,                /* Pending terms hash table to add entry to */\n  const char *zToken,\n  int nToken\n){\n  PendingList *pList;\n  int rc = SQLITE_OK;\n\n  pList = (PendingList *)fts3HashFind(pHash, zToken, nToken);\n  if( pList ){\n    p->nPendingData -= (pList->nData + nToken + sizeof(Fts3HashElem));\n  }\n  if( fts3PendingListAppend(&pList, p->iPrevDocid, iCol, iPos, &rc) ){\n    if( pList==fts3HashInsert(pHash, zToken, nToken, pList) ){\n      /* Malloc failed while inserting the new entry. This can only \n      ** happen if there was no previous entry for this token.\n      */\n      assert( 0==fts3HashFind(pHash, zToken, nToken) );\n      sqlite3_free(pList);\n      rc = SQLITE_NOMEM;\n    }\n  }\n  if( rc==SQLITE_OK ){\n    p->nPendingData += (pList->nData + nToken + sizeof(Fts3HashElem));\n  }\n  return rc;\n}\n\n/*\n** Tokenize the nul-terminated string zText and add all tokens to the\n** pending-terms hash-table. The docid used is that currently stored in\n** p->iPrevDocid, and the column is specified by argument iCol.\n**\n** If successful, SQLITE_OK is returned. Otherwise, an SQLite error code.\n*/\nstatic int fts3PendingTermsAdd(\n  Fts3Table *p,                   /* Table into which text will be inserted */\n  int iLangid,                    /* Language id to use */\n  const char *zText,              /* Text of document to be inserted */\n  int iCol,                       /* Column into which text is being inserted */\n  u32 *pnWord                     /* IN/OUT: Incr. by number tokens inserted */\n){\n  int rc;\n  int iStart = 0;\n  int iEnd = 0;\n  int iPos = 0;\n  int nWord = 0;\n\n  char const *zToken;\n  int nToken = 0;\n\n  sqlite3_tokenizer *pTokenizer = p->pTokenizer;\n  sqlite3_tokenizer_module const *pModule = pTokenizer->pModule;\n  sqlite3_tokenizer_cursor *pCsr;\n  int (*xNext)(sqlite3_tokenizer_cursor *pCursor,\n      const char**,int*,int*,int*,int*);\n\n  assert( pTokenizer && pModule );\n\n  /* If the user has inserted a NULL value, this function may be called with\n  ** zText==0. In this case, add zero token entries to the hash table and \n  ** return early. */\n  if( zText==0 ){\n    *pnWord = 0;\n    return SQLITE_OK;\n  }\n\n  rc = sqlite3Fts3OpenTokenizer(pTokenizer, iLangid, zText, -1, &pCsr);\n  if( rc!=SQLITE_OK ){\n    return rc;\n  }\n\n  xNext = pModule->xNext;\n  while( SQLITE_OK==rc\n      && SQLITE_OK==(rc = xNext(pCsr, &zToken, &nToken, &iStart, &iEnd, &iPos))\n  ){\n    int i;\n    if( iPos>=nWord ) nWord = iPos+1;\n\n    /* Positions cannot be negative; we use -1 as a terminator internally.\n    ** Tokens must have a non-zero length.\n    */\n    if( iPos<0 || !zToken || nToken<=0 ){\n      rc = SQLITE_ERROR;\n      break;\n    }\n\n    /* Add the term to the terms index */\n    rc = fts3PendingTermsAddOne(\n        p, iCol, iPos, &p->aIndex[0].hPending, zToken, nToken\n    );\n    \n    /* Add the term to each of the prefix indexes that it is not too \n    ** short for. */\n    for(i=1; rc==SQLITE_OK && i<p->nIndex; i++){\n      struct Fts3Index *pIndex = &p->aIndex[i];\n      if( nToken<pIndex->nPrefix ) continue;\n      rc = fts3PendingTermsAddOne(\n          p, iCol, iPos, &pIndex->hPending, zToken, pIndex->nPrefix\n      );\n    }\n  }\n\n  pModule->xClose(pCsr);\n  *pnWord += nWord;\n  return (rc==SQLITE_DONE ? SQLITE_OK : rc);\n}\n\n/* \n** Calling this function indicates that subsequent calls to \n** fts3PendingTermsAdd() are to add term/position-list pairs for the\n** contents of the document with docid iDocid.\n*/\nstatic int fts3PendingTermsDocid(\n  Fts3Table *p,                   /* Full-text table handle */\n  int bDelete,                    /* True if this op is a delete */\n  int iLangid,                    /* Language id of row being written */\n  sqlite_int64 iDocid             /* Docid of row being written */\n){\n  assert( iLangid>=0 );\n  assert( bDelete==1 || bDelete==0 );\n\n  /* TODO(shess) Explore whether partially flushing the buffer on\n  ** forced-flush would provide better performance.  I suspect that if\n  ** we ordered the doclists by size and flushed the largest until the\n  ** buffer was half empty, that would let the less frequent terms\n  ** generate longer doclists.\n  */\n  if( iDocid<p->iPrevDocid \n   || (iDocid==p->iPrevDocid && p->bPrevDelete==0)\n   || p->iPrevLangid!=iLangid\n   || p->nPendingData>p->nMaxPendingData \n  ){\n    int rc = sqlite3Fts3PendingTermsFlush(p);\n    if( rc!=SQLITE_OK ) return rc;\n  }\n  p->iPrevDocid = iDocid;\n  p->iPrevLangid = iLangid;\n  p->bPrevDelete = bDelete;\n  return SQLITE_OK;\n}\n\n/*\n** Discard the contents of the pending-terms hash tables. \n*/\nSQLITE_PRIVATE void sqlite3Fts3PendingTermsClear(Fts3Table *p){\n  int i;\n  for(i=0; i<p->nIndex; i++){\n    Fts3HashElem *pElem;\n    Fts3Hash *pHash = &p->aIndex[i].hPending;\n    for(pElem=fts3HashFirst(pHash); pElem; pElem=fts3HashNext(pElem)){\n      PendingList *pList = (PendingList *)fts3HashData(pElem);\n      fts3PendingListDelete(pList);\n    }\n    fts3HashClear(pHash);\n  }\n  p->nPendingData = 0;\n}\n\n/*\n** This function is called by the xUpdate() method as part of an INSERT\n** operation. It adds entries for each term in the new record to the\n** pendingTerms hash table.\n**\n** Argument apVal is the same as the similarly named argument passed to\n** fts3InsertData(). Parameter iDocid is the docid of the new row.\n*/\nstatic int fts3InsertTerms(\n  Fts3Table *p, \n  int iLangid, \n  sqlite3_value **apVal, \n  u32 *aSz\n){\n  int i;                          /* Iterator variable */\n  for(i=2; i<p->nColumn+2; i++){\n    int iCol = i-2;\n    if( p->abNotindexed[iCol]==0 ){\n      const char *zText = (const char *)sqlite3_value_text(apVal[i]);\n      int rc = fts3PendingTermsAdd(p, iLangid, zText, iCol, &aSz[iCol]);\n      if( rc!=SQLITE_OK ){\n        return rc;\n      }\n      aSz[p->nColumn] += sqlite3_value_bytes(apVal[i]);\n    }\n  }\n  return SQLITE_OK;\n}\n\n/*\n** This function is called by the xUpdate() method for an INSERT operation.\n** The apVal parameter is passed a copy of the apVal argument passed by\n** SQLite to the xUpdate() method. i.e:\n**\n**   apVal[0]                Not used for INSERT.\n**   apVal[1]                rowid\n**   apVal[2]                Left-most user-defined column\n**   ...\n**   apVal[p->nColumn+1]     Right-most user-defined column\n**   apVal[p->nColumn+2]     Hidden column with same name as table\n**   apVal[p->nColumn+3]     Hidden \"docid\" column (alias for rowid)\n**   apVal[p->nColumn+4]     Hidden languageid column\n*/\nstatic int fts3InsertData(\n  Fts3Table *p,                   /* Full-text table */\n  sqlite3_value **apVal,          /* Array of values to insert */\n  sqlite3_int64 *piDocid          /* OUT: Docid for row just inserted */\n){\n  int rc;                         /* Return code */\n  sqlite3_stmt *pContentInsert;   /* INSERT INTO %_content VALUES(...) */\n\n  if( p->zContentTbl ){\n    sqlite3_value *pRowid = apVal[p->nColumn+3];\n    if( sqlite3_value_type(pRowid)==SQLITE_NULL ){\n      pRowid = apVal[1];\n    }\n    if( sqlite3_value_type(pRowid)!=SQLITE_INTEGER ){\n      return SQLITE_CONSTRAINT;\n    }\n    *piDocid = sqlite3_value_int64(pRowid);\n    return SQLITE_OK;\n  }\n\n  /* Locate the statement handle used to insert data into the %_content\n  ** table. The SQL for this statement is:\n  **\n  **   INSERT INTO %_content VALUES(?, ?, ?, ...)\n  **\n  ** The statement features N '?' variables, where N is the number of user\n  ** defined columns in the FTS3 table, plus one for the docid field.\n  */\n  rc = fts3SqlStmt(p, SQL_CONTENT_INSERT, &pContentInsert, &apVal[1]);\n  if( rc==SQLITE_OK && p->zLanguageid ){\n    rc = sqlite3_bind_int(\n        pContentInsert, p->nColumn+2, \n        sqlite3_value_int(apVal[p->nColumn+4])\n    );\n  }\n  if( rc!=SQLITE_OK ) return rc;\n\n  /* There is a quirk here. The users INSERT statement may have specified\n  ** a value for the \"rowid\" field, for the \"docid\" field, or for both.\n  ** Which is a problem, since \"rowid\" and \"docid\" are aliases for the\n  ** same value. For example:\n  **\n  **   INSERT INTO fts3tbl(rowid, docid) VALUES(1, 2);\n  **\n  ** In FTS3, this is an error. It is an error to specify non-NULL values\n  ** for both docid and some other rowid alias.\n  */\n  if( SQLITE_NULL!=sqlite3_value_type(apVal[3+p->nColumn]) ){\n    if( SQLITE_NULL==sqlite3_value_type(apVal[0])\n     && SQLITE_NULL!=sqlite3_value_type(apVal[1])\n    ){\n      /* A rowid/docid conflict. */\n      return SQLITE_ERROR;\n    }\n    rc = sqlite3_bind_value(pContentInsert, 1, apVal[3+p->nColumn]);\n    if( rc!=SQLITE_OK ) return rc;\n  }\n\n  /* Execute the statement to insert the record. Set *piDocid to the \n  ** new docid value. \n  */\n  sqlite3_step(pContentInsert);\n  rc = sqlite3_reset(pContentInsert);\n\n  *piDocid = sqlite3_last_insert_rowid(p->db);\n  return rc;\n}\n\n\n\n/*\n** Remove all data from the FTS3 table. Clear the hash table containing\n** pending terms.\n*/\nstatic int fts3DeleteAll(Fts3Table *p, int bContent){\n  int rc = SQLITE_OK;             /* Return code */\n\n  /* Discard the contents of the pending-terms hash table. */\n  sqlite3Fts3PendingTermsClear(p);\n\n  /* Delete everything from the shadow tables. Except, leave %_content as\n  ** is if bContent is false.  */\n  assert( p->zContentTbl==0 || bContent==0 );\n  if( bContent ) fts3SqlExec(&rc, p, SQL_DELETE_ALL_CONTENT, 0);\n  fts3SqlExec(&rc, p, SQL_DELETE_ALL_SEGMENTS, 0);\n  fts3SqlExec(&rc, p, SQL_DELETE_ALL_SEGDIR, 0);\n  if( p->bHasDocsize ){\n    fts3SqlExec(&rc, p, SQL_DELETE_ALL_DOCSIZE, 0);\n  }\n  if( p->bHasStat ){\n    fts3SqlExec(&rc, p, SQL_DELETE_ALL_STAT, 0);\n  }\n  return rc;\n}\n\n/*\n**\n*/\nstatic int langidFromSelect(Fts3Table *p, sqlite3_stmt *pSelect){\n  int iLangid = 0;\n  if( p->zLanguageid ) iLangid = sqlite3_column_int(pSelect, p->nColumn+1);\n  return iLangid;\n}\n\n/*\n** The first element in the apVal[] array is assumed to contain the docid\n** (an integer) of a row about to be deleted. Remove all terms from the\n** full-text index.\n*/\nstatic void fts3DeleteTerms( \n  int *pRC,               /* Result code */\n  Fts3Table *p,           /* The FTS table to delete from */\n  sqlite3_value *pRowid,  /* The docid to be deleted */\n  u32 *aSz,               /* Sizes of deleted document written here */\n  int *pbFound            /* OUT: Set to true if row really does exist */\n){\n  int rc;\n  sqlite3_stmt *pSelect;\n\n  assert( *pbFound==0 );\n  if( *pRC ) return;\n  rc = fts3SqlStmt(p, SQL_SELECT_CONTENT_BY_ROWID, &pSelect, &pRowid);\n  if( rc==SQLITE_OK ){\n    if( SQLITE_ROW==sqlite3_step(pSelect) ){\n      int i;\n      int iLangid = langidFromSelect(p, pSelect);\n      i64 iDocid = sqlite3_column_int64(pSelect, 0);\n      rc = fts3PendingTermsDocid(p, 1, iLangid, iDocid);\n      for(i=1; rc==SQLITE_OK && i<=p->nColumn; i++){\n        int iCol = i-1;\n        if( p->abNotindexed[iCol]==0 ){\n          const char *zText = (const char *)sqlite3_column_text(pSelect, i);\n          rc = fts3PendingTermsAdd(p, iLangid, zText, -1, &aSz[iCol]);\n          aSz[p->nColumn] += sqlite3_column_bytes(pSelect, i);\n        }\n      }\n      if( rc!=SQLITE_OK ){\n        sqlite3_reset(pSelect);\n        *pRC = rc;\n        return;\n      }\n      *pbFound = 1;\n    }\n    rc = sqlite3_reset(pSelect);\n  }else{\n    sqlite3_reset(pSelect);\n  }\n  *pRC = rc;\n}\n\n/*\n** Forward declaration to account for the circular dependency between\n** functions fts3SegmentMerge() and fts3AllocateSegdirIdx().\n*/\nstatic int fts3SegmentMerge(Fts3Table *, int, int, int);\n\n/* \n** This function allocates a new level iLevel index in the segdir table.\n** Usually, indexes are allocated within a level sequentially starting\n** with 0, so the allocated index is one greater than the value returned\n** by:\n**\n**   SELECT max(idx) FROM %_segdir WHERE level = :iLevel\n**\n** However, if there are already FTS3_MERGE_COUNT indexes at the requested\n** level, they are merged into a single level (iLevel+1) segment and the \n** allocated index is 0.\n**\n** If successful, *piIdx is set to the allocated index slot and SQLITE_OK\n** returned. Otherwise, an SQLite error code is returned.\n*/\nstatic int fts3AllocateSegdirIdx(\n  Fts3Table *p, \n  int iLangid,                    /* Language id */\n  int iIndex,                     /* Index for p->aIndex */\n  int iLevel, \n  int *piIdx\n){\n  int rc;                         /* Return Code */\n  sqlite3_stmt *pNextIdx;         /* Query for next idx at level iLevel */\n  int iNext = 0;                  /* Result of query pNextIdx */\n\n  assert( iLangid>=0 );\n  assert( p->nIndex>=1 );\n\n  /* Set variable iNext to the next available segdir index at level iLevel. */\n  rc = fts3SqlStmt(p, SQL_NEXT_SEGMENT_INDEX, &pNextIdx, 0);\n  if( rc==SQLITE_OK ){\n    sqlite3_bind_int64(\n        pNextIdx, 1, getAbsoluteLevel(p, iLangid, iIndex, iLevel)\n    );\n    if( SQLITE_ROW==sqlite3_step(pNextIdx) ){\n      iNext = sqlite3_column_int(pNextIdx, 0);\n    }\n    rc = sqlite3_reset(pNextIdx);\n  }\n\n  if( rc==SQLITE_OK ){\n    /* If iNext is FTS3_MERGE_COUNT, indicating that level iLevel is already\n    ** full, merge all segments in level iLevel into a single iLevel+1\n    ** segment and allocate (newly freed) index 0 at level iLevel. Otherwise,\n    ** if iNext is less than FTS3_MERGE_COUNT, allocate index iNext.\n    */\n    if( iNext>=FTS3_MERGE_COUNT ){\n      fts3LogMerge(16, getAbsoluteLevel(p, iLangid, iIndex, iLevel));\n      rc = fts3SegmentMerge(p, iLangid, iIndex, iLevel);\n      *piIdx = 0;\n    }else{\n      *piIdx = iNext;\n    }\n  }\n\n  return rc;\n}\n\n/*\n** The %_segments table is declared as follows:\n**\n**   CREATE TABLE %_segments(blockid INTEGER PRIMARY KEY, block BLOB)\n**\n** This function reads data from a single row of the %_segments table. The\n** specific row is identified by the iBlockid parameter. If paBlob is not\n** NULL, then a buffer is allocated using sqlite3_malloc() and populated\n** with the contents of the blob stored in the \"block\" column of the \n** identified table row is. Whether or not paBlob is NULL, *pnBlob is set\n** to the size of the blob in bytes before returning.\n**\n** If an error occurs, or the table does not contain the specified row,\n** an SQLite error code is returned. Otherwise, SQLITE_OK is returned. If\n** paBlob is non-NULL, then it is the responsibility of the caller to\n** eventually free the returned buffer.\n**\n** This function may leave an open sqlite3_blob* handle in the\n** Fts3Table.pSegments variable. This handle is reused by subsequent calls\n** to this function. The handle may be closed by calling the\n** sqlite3Fts3SegmentsClose() function. Reusing a blob handle is a handy\n** performance improvement, but the blob handle should always be closed\n** before control is returned to the user (to prevent a lock being held\n** on the database file for longer than necessary). Thus, any virtual table\n** method (xFilter etc.) that may directly or indirectly call this function\n** must call sqlite3Fts3SegmentsClose() before returning.\n*/\nSQLITE_PRIVATE int sqlite3Fts3ReadBlock(\n  Fts3Table *p,                   /* FTS3 table handle */\n  sqlite3_int64 iBlockid,         /* Access the row with blockid=$iBlockid */\n  char **paBlob,                  /* OUT: Blob data in malloc'd buffer */\n  int *pnBlob,                    /* OUT: Size of blob data */\n  int *pnLoad                     /* OUT: Bytes actually loaded */\n){\n  int rc;                         /* Return code */\n\n  /* pnBlob must be non-NULL. paBlob may be NULL or non-NULL. */\n  assert( pnBlob );\n\n  if( p->pSegments ){\n    rc = sqlite3_blob_reopen(p->pSegments, iBlockid);\n  }else{\n    if( 0==p->zSegmentsTbl ){\n      p->zSegmentsTbl = sqlite3_mprintf(\"%s_segments\", p->zName);\n      if( 0==p->zSegmentsTbl ) return SQLITE_NOMEM;\n    }\n    rc = sqlite3_blob_open(\n       p->db, p->zDb, p->zSegmentsTbl, \"block\", iBlockid, 0, &p->pSegments\n    );\n  }\n\n  if( rc==SQLITE_OK ){\n    int nByte = sqlite3_blob_bytes(p->pSegments);\n    *pnBlob = nByte;\n    if( paBlob ){\n      char *aByte = sqlite3_malloc(nByte + FTS3_NODE_PADDING);\n      if( !aByte ){\n        rc = SQLITE_NOMEM;\n      }else{\n        if( pnLoad && nByte>(FTS3_NODE_CHUNK_THRESHOLD) ){\n          nByte = FTS3_NODE_CHUNKSIZE;\n          *pnLoad = nByte;\n        }\n        rc = sqlite3_blob_read(p->pSegments, aByte, nByte, 0);\n        memset(&aByte[nByte], 0, FTS3_NODE_PADDING);\n        if( rc!=SQLITE_OK ){\n          sqlite3_free(aByte);\n          aByte = 0;\n        }\n      }\n      *paBlob = aByte;\n    }\n  }\n\n  return rc;\n}\n\n/*\n** Close the blob handle at p->pSegments, if it is open. See comments above\n** the sqlite3Fts3ReadBlock() function for details.\n*/\nSQLITE_PRIVATE void sqlite3Fts3SegmentsClose(Fts3Table *p){\n  sqlite3_blob_close(p->pSegments);\n  p->pSegments = 0;\n}\n    \nstatic int fts3SegReaderIncrRead(Fts3SegReader *pReader){\n  int nRead;                      /* Number of bytes to read */\n  int rc;                         /* Return code */\n\n  nRead = MIN(pReader->nNode - pReader->nPopulate, FTS3_NODE_CHUNKSIZE);\n  rc = sqlite3_blob_read(\n      pReader->pBlob, \n      &pReader->aNode[pReader->nPopulate],\n      nRead,\n      pReader->nPopulate\n  );\n\n  if( rc==SQLITE_OK ){\n    pReader->nPopulate += nRead;\n    memset(&pReader->aNode[pReader->nPopulate], 0, FTS3_NODE_PADDING);\n    if( pReader->nPopulate==pReader->nNode ){\n      sqlite3_blob_close(pReader->pBlob);\n      pReader->pBlob = 0;\n      pReader->nPopulate = 0;\n    }\n  }\n  return rc;\n}\n\nstatic int fts3SegReaderRequire(Fts3SegReader *pReader, char *pFrom, int nByte){\n  int rc = SQLITE_OK;\n  assert( !pReader->pBlob \n       || (pFrom>=pReader->aNode && pFrom<&pReader->aNode[pReader->nNode])\n  );\n  while( pReader->pBlob && rc==SQLITE_OK \n     &&  (pFrom - pReader->aNode + nByte)>pReader->nPopulate\n  ){\n    rc = fts3SegReaderIncrRead(pReader);\n  }\n  return rc;\n}\n\n/*\n** Set an Fts3SegReader cursor to point at EOF.\n*/\nstatic void fts3SegReaderSetEof(Fts3SegReader *pSeg){\n  if( !fts3SegReaderIsRootOnly(pSeg) ){\n    sqlite3_free(pSeg->aNode);\n    sqlite3_blob_close(pSeg->pBlob);\n    pSeg->pBlob = 0;\n  }\n  pSeg->aNode = 0;\n}\n\n/*\n** Move the iterator passed as the first argument to the next term in the\n** segment. If successful, SQLITE_OK is returned. If there is no next term,\n** SQLITE_DONE. Otherwise, an SQLite error code.\n*/\nstatic int fts3SegReaderNext(\n  Fts3Table *p, \n  Fts3SegReader *pReader,\n  int bIncr\n){\n  int rc;                         /* Return code of various sub-routines */\n  char *pNext;                    /* Cursor variable */\n  int nPrefix;                    /* Number of bytes in term prefix */\n  int nSuffix;                    /* Number of bytes in term suffix */\n\n  if( !pReader->aDoclist ){\n    pNext = pReader->aNode;\n  }else{\n    pNext = &pReader->aDoclist[pReader->nDoclist];\n  }\n\n  if( !pNext || pNext>=&pReader->aNode[pReader->nNode] ){\n\n    if( fts3SegReaderIsPending(pReader) ){\n      Fts3HashElem *pElem = *(pReader->ppNextElem);\n      sqlite3_free(pReader->aNode);\n      pReader->aNode = 0;\n      if( pElem ){\n        char *aCopy;\n        PendingList *pList = (PendingList *)fts3HashData(pElem);\n        int nCopy = pList->nData+1;\n        pReader->zTerm = (char *)fts3HashKey(pElem);\n        pReader->nTerm = fts3HashKeysize(pElem);\n        aCopy = (char*)sqlite3_malloc(nCopy);\n        if( !aCopy ) return SQLITE_NOMEM;\n        memcpy(aCopy, pList->aData, nCopy);\n        pReader->nNode = pReader->nDoclist = nCopy;\n        pReader->aNode = pReader->aDoclist = aCopy;\n        pReader->ppNextElem++;\n        assert( pReader->aNode );\n      }\n      return SQLITE_OK;\n    }\n\n    fts3SegReaderSetEof(pReader);\n\n    /* If iCurrentBlock>=iLeafEndBlock, this is an EOF condition. All leaf \n    ** blocks have already been traversed.  */\n    assert( pReader->iCurrentBlock<=pReader->iLeafEndBlock );\n    if( pReader->iCurrentBlock>=pReader->iLeafEndBlock ){\n      return SQLITE_OK;\n    }\n\n    rc = sqlite3Fts3ReadBlock(\n        p, ++pReader->iCurrentBlock, &pReader->aNode, &pReader->nNode, \n        (bIncr ? &pReader->nPopulate : 0)\n    );\n    if( rc!=SQLITE_OK ) return rc;\n    assert( pReader->pBlob==0 );\n    if( bIncr && pReader->nPopulate<pReader->nNode ){\n      pReader->pBlob = p->pSegments;\n      p->pSegments = 0;\n    }\n    pNext = pReader->aNode;\n  }\n\n  assert( !fts3SegReaderIsPending(pReader) );\n\n  rc = fts3SegReaderRequire(pReader, pNext, FTS3_VARINT_MAX*2);\n  if( rc!=SQLITE_OK ) return rc;\n  \n  /* Because of the FTS3_NODE_PADDING bytes of padding, the following is \n  ** safe (no risk of overread) even if the node data is corrupted. */\n  pNext += fts3GetVarint32(pNext, &nPrefix);\n  pNext += fts3GetVarint32(pNext, &nSuffix);\n  if( nSuffix<=0 \n   || (&pReader->aNode[pReader->nNode] - pNext)<nSuffix\n   || nPrefix>pReader->nTermAlloc\n  ){\n    return FTS_CORRUPT_VTAB;\n  }\n\n  /* Both nPrefix and nSuffix were read by fts3GetVarint32() and so are\n  ** between 0 and 0x7FFFFFFF. But the sum of the two may cause integer\n  ** overflow - hence the (i64) casts.  */\n  if( (i64)nPrefix+nSuffix>(i64)pReader->nTermAlloc ){\n    i64 nNew = ((i64)nPrefix+nSuffix)*2;\n    char *zNew = sqlite3_realloc64(pReader->zTerm, nNew);\n    if( !zNew ){\n      return SQLITE_NOMEM;\n    }\n    pReader->zTerm = zNew;\n    pReader->nTermAlloc = nNew;\n  }\n\n  rc = fts3SegReaderRequire(pReader, pNext, nSuffix+FTS3_VARINT_MAX);\n  if( rc!=SQLITE_OK ) return rc;\n\n  memcpy(&pReader->zTerm[nPrefix], pNext, nSuffix);\n  pReader->nTerm = nPrefix+nSuffix;\n  pNext += nSuffix;\n  pNext += fts3GetVarint32(pNext, &pReader->nDoclist);\n  pReader->aDoclist = pNext;\n  pReader->pOffsetList = 0;\n\n  /* Check that the doclist does not appear to extend past the end of the\n  ** b-tree node. And that the final byte of the doclist is 0x00. If either \n  ** of these statements is untrue, then the data structure is corrupt.\n  */\n  if( pReader->nDoclist > pReader->nNode-(pReader->aDoclist-pReader->aNode)\n   || (pReader->nPopulate==0 && pReader->aDoclist[pReader->nDoclist-1])\n  ){\n    return FTS_CORRUPT_VTAB;\n  }\n  return SQLITE_OK;\n}\n\n/*\n** Set the SegReader to point to the first docid in the doclist associated\n** with the current term.\n*/\nstatic int fts3SegReaderFirstDocid(Fts3Table *pTab, Fts3SegReader *pReader){\n  int rc = SQLITE_OK;\n  assert( pReader->aDoclist );\n  assert( !pReader->pOffsetList );\n  if( pTab->bDescIdx && fts3SegReaderIsPending(pReader) ){\n    u8 bEof = 0;\n    pReader->iDocid = 0;\n    pReader->nOffsetList = 0;\n    sqlite3Fts3DoclistPrev(0,\n        pReader->aDoclist, pReader->nDoclist, &pReader->pOffsetList, \n        &pReader->iDocid, &pReader->nOffsetList, &bEof\n    );\n  }else{\n    rc = fts3SegReaderRequire(pReader, pReader->aDoclist, FTS3_VARINT_MAX);\n    if( rc==SQLITE_OK ){\n      int n = sqlite3Fts3GetVarint(pReader->aDoclist, &pReader->iDocid);\n      pReader->pOffsetList = &pReader->aDoclist[n];\n    }\n  }\n  return rc;\n}\n\n/*\n** Advance the SegReader to point to the next docid in the doclist\n** associated with the current term.\n** \n** If arguments ppOffsetList and pnOffsetList are not NULL, then \n** *ppOffsetList is set to point to the first column-offset list\n** in the doclist entry (i.e. immediately past the docid varint).\n** *pnOffsetList is set to the length of the set of column-offset\n** lists, not including the nul-terminator byte. For example:\n*/\nstatic int fts3SegReaderNextDocid(\n  Fts3Table *pTab,\n  Fts3SegReader *pReader,         /* Reader to advance to next docid */\n  char **ppOffsetList,            /* OUT: Pointer to current position-list */\n  int *pnOffsetList               /* OUT: Length of *ppOffsetList in bytes */\n){\n  int rc = SQLITE_OK;\n  char *p = pReader->pOffsetList;\n  char c = 0;\n\n  assert( p );\n\n  if( pTab->bDescIdx && fts3SegReaderIsPending(pReader) ){\n    /* A pending-terms seg-reader for an FTS4 table that uses order=desc.\n    ** Pending-terms doclists are always built up in ascending order, so\n    ** we have to iterate through them backwards here. */\n    u8 bEof = 0;\n    if( ppOffsetList ){\n      *ppOffsetList = pReader->pOffsetList;\n      *pnOffsetList = pReader->nOffsetList - 1;\n    }\n    sqlite3Fts3DoclistPrev(0,\n        pReader->aDoclist, pReader->nDoclist, &p, &pReader->iDocid,\n        &pReader->nOffsetList, &bEof\n    );\n    if( bEof ){\n      pReader->pOffsetList = 0;\n    }else{\n      pReader->pOffsetList = p;\n    }\n  }else{\n    char *pEnd = &pReader->aDoclist[pReader->nDoclist];\n\n    /* Pointer p currently points at the first byte of an offset list. The\n    ** following block advances it to point one byte past the end of\n    ** the same offset list. */\n    while( 1 ){\n  \n      /* The following line of code (and the \"p++\" below the while() loop) is\n      ** normally all that is required to move pointer p to the desired \n      ** position. The exception is if this node is being loaded from disk\n      ** incrementally and pointer \"p\" now points to the first byte past\n      ** the populated part of pReader->aNode[].\n      */\n      while( *p | c ) c = *p++ & 0x80;\n      assert( *p==0 );\n  \n      if( pReader->pBlob==0 || p<&pReader->aNode[pReader->nPopulate] ) break;\n      rc = fts3SegReaderIncrRead(pReader);\n      if( rc!=SQLITE_OK ) return rc;\n    }\n    p++;\n  \n    /* If required, populate the output variables with a pointer to and the\n    ** size of the previous offset-list.\n    */\n    if( ppOffsetList ){\n      *ppOffsetList = pReader->pOffsetList;\n      *pnOffsetList = (int)(p - pReader->pOffsetList - 1);\n    }\n\n    /* List may have been edited in place by fts3EvalNearTrim() */\n    while( p<pEnd && *p==0 ) p++;\n  \n    /* If there are no more entries in the doclist, set pOffsetList to\n    ** NULL. Otherwise, set Fts3SegReader.iDocid to the next docid and\n    ** Fts3SegReader.pOffsetList to point to the next offset list before\n    ** returning.\n    */\n    if( p>=pEnd ){\n      pReader->pOffsetList = 0;\n    }else{\n      rc = fts3SegReaderRequire(pReader, p, FTS3_VARINT_MAX);\n      if( rc==SQLITE_OK ){\n        sqlite3_int64 iDelta;\n        pReader->pOffsetList = p + sqlite3Fts3GetVarint(p, &iDelta);\n        if( pTab->bDescIdx ){\n          pReader->iDocid -= iDelta;\n        }else{\n          pReader->iDocid += iDelta;\n        }\n      }\n    }\n  }\n\n  return SQLITE_OK;\n}\n\n\nSQLITE_PRIVATE int sqlite3Fts3MsrOvfl(\n  Fts3Cursor *pCsr, \n  Fts3MultiSegReader *pMsr,\n  int *pnOvfl\n){\n  Fts3Table *p = (Fts3Table*)pCsr->base.pVtab;\n  int nOvfl = 0;\n  int ii;\n  int rc = SQLITE_OK;\n  int pgsz = p->nPgsz;\n\n  assert( p->bFts4 );\n  assert( pgsz>0 );\n\n  for(ii=0; rc==SQLITE_OK && ii<pMsr->nSegment; ii++){\n    Fts3SegReader *pReader = pMsr->apSegment[ii];\n    if( !fts3SegReaderIsPending(pReader) \n     && !fts3SegReaderIsRootOnly(pReader) \n    ){\n      sqlite3_int64 jj;\n      for(jj=pReader->iStartBlock; jj<=pReader->iLeafEndBlock; jj++){\n        int nBlob;\n        rc = sqlite3Fts3ReadBlock(p, jj, 0, &nBlob, 0);\n        if( rc!=SQLITE_OK ) break;\n        if( (nBlob+35)>pgsz ){\n          nOvfl += (nBlob + 34)/pgsz;\n        }\n      }\n    }\n  }\n  *pnOvfl = nOvfl;\n  return rc;\n}\n\n/*\n** Free all allocations associated with the iterator passed as the \n** second argument.\n*/\nSQLITE_PRIVATE void sqlite3Fts3SegReaderFree(Fts3SegReader *pReader){\n  if( pReader ){\n    if( !fts3SegReaderIsPending(pReader) ){\n      sqlite3_free(pReader->zTerm);\n    }\n    if( !fts3SegReaderIsRootOnly(pReader) ){\n      sqlite3_free(pReader->aNode);\n    }\n    sqlite3_blob_close(pReader->pBlob);\n  }\n  sqlite3_free(pReader);\n}\n\n/*\n** Allocate a new SegReader object.\n*/\nSQLITE_PRIVATE int sqlite3Fts3SegReaderNew(\n  int iAge,                       /* Segment \"age\". */\n  int bLookup,                    /* True for a lookup only */\n  sqlite3_int64 iStartLeaf,       /* First leaf to traverse */\n  sqlite3_int64 iEndLeaf,         /* Final leaf to traverse */\n  sqlite3_int64 iEndBlock,        /* Final block of segment */\n  const char *zRoot,              /* Buffer containing root node */\n  int nRoot,                      /* Size of buffer containing root node */\n  Fts3SegReader **ppReader        /* OUT: Allocated Fts3SegReader */\n){\n  Fts3SegReader *pReader;         /* Newly allocated SegReader object */\n  int nExtra = 0;                 /* Bytes to allocate segment root node */\n\n  assert( zRoot!=0 || nRoot==0 );\n#ifdef CORRUPT_DB\n  assert( zRoot!=0 || CORRUPT_DB );\n#endif\n\n  if( iStartLeaf==0 ){\n    if( iEndLeaf!=0 ) return FTS_CORRUPT_VTAB;\n    nExtra = nRoot + FTS3_NODE_PADDING;\n  }\n\n  pReader = (Fts3SegReader *)sqlite3_malloc(sizeof(Fts3SegReader) + nExtra);\n  if( !pReader ){\n    return SQLITE_NOMEM;\n  }\n  memset(pReader, 0, sizeof(Fts3SegReader));\n  pReader->iIdx = iAge;\n  pReader->bLookup = bLookup!=0;\n  pReader->iStartBlock = iStartLeaf;\n  pReader->iLeafEndBlock = iEndLeaf;\n  pReader->iEndBlock = iEndBlock;\n\n  if( nExtra ){\n    /* The entire segment is stored in the root node. */\n    pReader->aNode = (char *)&pReader[1];\n    pReader->rootOnly = 1;\n    pReader->nNode = nRoot;\n    if( nRoot ) memcpy(pReader->aNode, zRoot, nRoot);\n    memset(&pReader->aNode[nRoot], 0, FTS3_NODE_PADDING);\n  }else{\n    pReader->iCurrentBlock = iStartLeaf-1;\n  }\n  *ppReader = pReader;\n  return SQLITE_OK;\n}\n\n/*\n** This is a comparison function used as a qsort() callback when sorting\n** an array of pending terms by term. This occurs as part of flushing\n** the contents of the pending-terms hash table to the database.\n*/\nstatic int SQLITE_CDECL fts3CompareElemByTerm(\n  const void *lhs,\n  const void *rhs\n){\n  char *z1 = fts3HashKey(*(Fts3HashElem **)lhs);\n  char *z2 = fts3HashKey(*(Fts3HashElem **)rhs);\n  int n1 = fts3HashKeysize(*(Fts3HashElem **)lhs);\n  int n2 = fts3HashKeysize(*(Fts3HashElem **)rhs);\n\n  int n = (n1<n2 ? n1 : n2);\n  int c = memcmp(z1, z2, n);\n  if( c==0 ){\n    c = n1 - n2;\n  }\n  return c;\n}\n\n/*\n** This function is used to allocate an Fts3SegReader that iterates through\n** a subset of the terms stored in the Fts3Table.pendingTerms array.\n**\n** If the isPrefixIter parameter is zero, then the returned SegReader iterates\n** through each term in the pending-terms table. Or, if isPrefixIter is\n** non-zero, it iterates through each term and its prefixes. For example, if\n** the pending terms hash table contains the terms \"sqlite\", \"mysql\" and\n** \"firebird\", then the iterator visits the following 'terms' (in the order\n** shown):\n**\n**   f fi fir fire fireb firebi firebir firebird\n**   m my mys mysq mysql\n**   s sq sql sqli sqlit sqlite\n**\n** Whereas if isPrefixIter is zero, the terms visited are:\n**\n**   firebird mysql sqlite\n*/\nSQLITE_PRIVATE int sqlite3Fts3SegReaderPending(\n  Fts3Table *p,                   /* Virtual table handle */\n  int iIndex,                     /* Index for p->aIndex */\n  const char *zTerm,              /* Term to search for */\n  int nTerm,                      /* Size of buffer zTerm */\n  int bPrefix,                    /* True for a prefix iterator */\n  Fts3SegReader **ppReader        /* OUT: SegReader for pending-terms */\n){\n  Fts3SegReader *pReader = 0;     /* Fts3SegReader object to return */\n  Fts3HashElem *pE;               /* Iterator variable */\n  Fts3HashElem **aElem = 0;       /* Array of term hash entries to scan */\n  int nElem = 0;                  /* Size of array at aElem */\n  int rc = SQLITE_OK;             /* Return Code */\n  Fts3Hash *pHash;\n\n  pHash = &p->aIndex[iIndex].hPending;\n  if( bPrefix ){\n    int nAlloc = 0;               /* Size of allocated array at aElem */\n\n    for(pE=fts3HashFirst(pHash); pE; pE=fts3HashNext(pE)){\n      char *zKey = (char *)fts3HashKey(pE);\n      int nKey = fts3HashKeysize(pE);\n      if( nTerm==0 || (nKey>=nTerm && 0==memcmp(zKey, zTerm, nTerm)) ){\n        if( nElem==nAlloc ){\n          Fts3HashElem **aElem2;\n          nAlloc += 16;\n          aElem2 = (Fts3HashElem **)sqlite3_realloc(\n              aElem, nAlloc*sizeof(Fts3HashElem *)\n          );\n          if( !aElem2 ){\n            rc = SQLITE_NOMEM;\n            nElem = 0;\n            break;\n          }\n          aElem = aElem2;\n        }\n\n        aElem[nElem++] = pE;\n      }\n    }\n\n    /* If more than one term matches the prefix, sort the Fts3HashElem\n    ** objects in term order using qsort(). This uses the same comparison\n    ** callback as is used when flushing terms to disk.\n    */\n    if( nElem>1 ){\n      qsort(aElem, nElem, sizeof(Fts3HashElem *), fts3CompareElemByTerm);\n    }\n\n  }else{\n    /* The query is a simple term lookup that matches at most one term in\n    ** the index. All that is required is a straight hash-lookup. \n    **\n    ** Because the stack address of pE may be accessed via the aElem pointer\n    ** below, the \"Fts3HashElem *pE\" must be declared so that it is valid\n    ** within this entire function, not just this \"else{...}\" block.\n    */\n    pE = fts3HashFindElem(pHash, zTerm, nTerm);\n    if( pE ){\n      aElem = &pE;\n      nElem = 1;\n    }\n  }\n\n  if( nElem>0 ){\n    int nByte = sizeof(Fts3SegReader) + (nElem+1)*sizeof(Fts3HashElem *);\n    pReader = (Fts3SegReader *)sqlite3_malloc(nByte);\n    if( !pReader ){\n      rc = SQLITE_NOMEM;\n    }else{\n      memset(pReader, 0, nByte);\n      pReader->iIdx = 0x7FFFFFFF;\n      pReader->ppNextElem = (Fts3HashElem **)&pReader[1];\n      memcpy(pReader->ppNextElem, aElem, nElem*sizeof(Fts3HashElem *));\n    }\n  }\n\n  if( bPrefix ){\n    sqlite3_free(aElem);\n  }\n  *ppReader = pReader;\n  return rc;\n}\n\n/*\n** Compare the entries pointed to by two Fts3SegReader structures. \n** Comparison is as follows:\n**\n**   1) EOF is greater than not EOF.\n**\n**   2) The current terms (if any) are compared using memcmp(). If one\n**      term is a prefix of another, the longer term is considered the\n**      larger.\n**\n**   3) By segment age. An older segment is considered larger.\n*/\nstatic int fts3SegReaderCmp(Fts3SegReader *pLhs, Fts3SegReader *pRhs){\n  int rc;\n  if( pLhs->aNode && pRhs->aNode ){\n    int rc2 = pLhs->nTerm - pRhs->nTerm;\n    if( rc2<0 ){\n      rc = memcmp(pLhs->zTerm, pRhs->zTerm, pLhs->nTerm);\n    }else{\n      rc = memcmp(pLhs->zTerm, pRhs->zTerm, pRhs->nTerm);\n    }\n    if( rc==0 ){\n      rc = rc2;\n    }\n  }else{\n    rc = (pLhs->aNode==0) - (pRhs->aNode==0);\n  }\n  if( rc==0 ){\n    rc = pRhs->iIdx - pLhs->iIdx;\n  }\n  assert( rc!=0 );\n  return rc;\n}\n\n/*\n** A different comparison function for SegReader structures. In this\n** version, it is assumed that each SegReader points to an entry in\n** a doclist for identical terms. Comparison is made as follows:\n**\n**   1) EOF (end of doclist in this case) is greater than not EOF.\n**\n**   2) By current docid.\n**\n**   3) By segment age. An older segment is considered larger.\n*/\nstatic int fts3SegReaderDoclistCmp(Fts3SegReader *pLhs, Fts3SegReader *pRhs){\n  int rc = (pLhs->pOffsetList==0)-(pRhs->pOffsetList==0);\n  if( rc==0 ){\n    if( pLhs->iDocid==pRhs->iDocid ){\n      rc = pRhs->iIdx - pLhs->iIdx;\n    }else{\n      rc = (pLhs->iDocid > pRhs->iDocid) ? 1 : -1;\n    }\n  }\n  assert( pLhs->aNode && pRhs->aNode );\n  return rc;\n}\nstatic int fts3SegReaderDoclistCmpRev(Fts3SegReader *pLhs, Fts3SegReader *pRhs){\n  int rc = (pLhs->pOffsetList==0)-(pRhs->pOffsetList==0);\n  if( rc==0 ){\n    if( pLhs->iDocid==pRhs->iDocid ){\n      rc = pRhs->iIdx - pLhs->iIdx;\n    }else{\n      rc = (pLhs->iDocid < pRhs->iDocid) ? 1 : -1;\n    }\n  }\n  assert( pLhs->aNode && pRhs->aNode );\n  return rc;\n}\n\n/*\n** Compare the term that the Fts3SegReader object passed as the first argument\n** points to with the term specified by arguments zTerm and nTerm. \n**\n** If the pSeg iterator is already at EOF, return 0. Otherwise, return\n** -ve if the pSeg term is less than zTerm/nTerm, 0 if the two terms are\n** equal, or +ve if the pSeg term is greater than zTerm/nTerm.\n*/\nstatic int fts3SegReaderTermCmp(\n  Fts3SegReader *pSeg,            /* Segment reader object */\n  const char *zTerm,              /* Term to compare to */\n  int nTerm                       /* Size of term zTerm in bytes */\n){\n  int res = 0;\n  if( pSeg->aNode ){\n    if( pSeg->nTerm>nTerm ){\n      res = memcmp(pSeg->zTerm, zTerm, nTerm);\n    }else{\n      res = memcmp(pSeg->zTerm, zTerm, pSeg->nTerm);\n    }\n    if( res==0 ){\n      res = pSeg->nTerm-nTerm;\n    }\n  }\n  return res;\n}\n\n/*\n** Argument apSegment is an array of nSegment elements. It is known that\n** the final (nSegment-nSuspect) members are already in sorted order\n** (according to the comparison function provided). This function shuffles\n** the array around until all entries are in sorted order.\n*/\nstatic void fts3SegReaderSort(\n  Fts3SegReader **apSegment,                     /* Array to sort entries of */\n  int nSegment,                                  /* Size of apSegment array */\n  int nSuspect,                                  /* Unsorted entry count */\n  int (*xCmp)(Fts3SegReader *, Fts3SegReader *)  /* Comparison function */\n){\n  int i;                          /* Iterator variable */\n\n  assert( nSuspect<=nSegment );\n\n  if( nSuspect==nSegment ) nSuspect--;\n  for(i=nSuspect-1; i>=0; i--){\n    int j;\n    for(j=i; j<(nSegment-1); j++){\n      Fts3SegReader *pTmp;\n      if( xCmp(apSegment[j], apSegment[j+1])<0 ) break;\n      pTmp = apSegment[j+1];\n      apSegment[j+1] = apSegment[j];\n      apSegment[j] = pTmp;\n    }\n  }\n\n#ifndef NDEBUG\n  /* Check that the list really is sorted now. */\n  for(i=0; i<(nSuspect-1); i++){\n    assert( xCmp(apSegment[i], apSegment[i+1])<0 );\n  }\n#endif\n}\n\n/* \n** Insert a record into the %_segments table.\n*/\nstatic int fts3WriteSegment(\n  Fts3Table *p,                   /* Virtual table handle */\n  sqlite3_int64 iBlock,           /* Block id for new block */\n  char *z,                        /* Pointer to buffer containing block data */\n  int n                           /* Size of buffer z in bytes */\n){\n  sqlite3_stmt *pStmt;\n  int rc = fts3SqlStmt(p, SQL_INSERT_SEGMENTS, &pStmt, 0);\n  if( rc==SQLITE_OK ){\n    sqlite3_bind_int64(pStmt, 1, iBlock);\n    sqlite3_bind_blob(pStmt, 2, z, n, SQLITE_STATIC);\n    sqlite3_step(pStmt);\n    rc = sqlite3_reset(pStmt);\n    sqlite3_bind_null(pStmt, 2);\n  }\n  return rc;\n}\n\n/*\n** Find the largest relative level number in the table. If successful, set\n** *pnMax to this value and return SQLITE_OK. Otherwise, if an error occurs,\n** set *pnMax to zero and return an SQLite error code.\n*/\nSQLITE_PRIVATE int sqlite3Fts3MaxLevel(Fts3Table *p, int *pnMax){\n  int rc;\n  int mxLevel = 0;\n  sqlite3_stmt *pStmt = 0;\n\n  rc = fts3SqlStmt(p, SQL_SELECT_MXLEVEL, &pStmt, 0);\n  if( rc==SQLITE_OK ){\n    if( SQLITE_ROW==sqlite3_step(pStmt) ){\n      mxLevel = sqlite3_column_int(pStmt, 0);\n    }\n    rc = sqlite3_reset(pStmt);\n  }\n  *pnMax = mxLevel;\n  return rc;\n}\n\n/* \n** Insert a record into the %_segdir table.\n*/\nstatic int fts3WriteSegdir(\n  Fts3Table *p,                   /* Virtual table handle */\n  sqlite3_int64 iLevel,           /* Value for \"level\" field (absolute level) */\n  int iIdx,                       /* Value for \"idx\" field */\n  sqlite3_int64 iStartBlock,      /* Value for \"start_block\" field */\n  sqlite3_int64 iLeafEndBlock,    /* Value for \"leaves_end_block\" field */\n  sqlite3_int64 iEndBlock,        /* Value for \"end_block\" field */\n  sqlite3_int64 nLeafData,        /* Bytes of leaf data in segment */\n  char *zRoot,                    /* Blob value for \"root\" field */\n  int nRoot                       /* Number of bytes in buffer zRoot */\n){\n  sqlite3_stmt *pStmt;\n  int rc = fts3SqlStmt(p, SQL_INSERT_SEGDIR, &pStmt, 0);\n  if( rc==SQLITE_OK ){\n    sqlite3_bind_int64(pStmt, 1, iLevel);\n    sqlite3_bind_int(pStmt, 2, iIdx);\n    sqlite3_bind_int64(pStmt, 3, iStartBlock);\n    sqlite3_bind_int64(pStmt, 4, iLeafEndBlock);\n    if( nLeafData==0 ){\n      sqlite3_bind_int64(pStmt, 5, iEndBlock);\n    }else{\n      char *zEnd = sqlite3_mprintf(\"%lld %lld\", iEndBlock, nLeafData);\n      if( !zEnd ) return SQLITE_NOMEM;\n      sqlite3_bind_text(pStmt, 5, zEnd, -1, sqlite3_free);\n    }\n    sqlite3_bind_blob(pStmt, 6, zRoot, nRoot, SQLITE_STATIC);\n    sqlite3_step(pStmt);\n    rc = sqlite3_reset(pStmt);\n    sqlite3_bind_null(pStmt, 6);\n  }\n  return rc;\n}\n\n/*\n** Return the size of the common prefix (if any) shared by zPrev and\n** zNext, in bytes. For example, \n**\n**   fts3PrefixCompress(\"abc\", 3, \"abcdef\", 6)   // returns 3\n**   fts3PrefixCompress(\"abX\", 3, \"abcdef\", 6)   // returns 2\n**   fts3PrefixCompress(\"abX\", 3, \"Xbcdef\", 6)   // returns 0\n*/\nstatic int fts3PrefixCompress(\n  const char *zPrev,              /* Buffer containing previous term */\n  int nPrev,                      /* Size of buffer zPrev in bytes */\n  const char *zNext,              /* Buffer containing next term */\n  int nNext                       /* Size of buffer zNext in bytes */\n){\n  int n;\n  UNUSED_PARAMETER(nNext);\n  for(n=0; n<nPrev && zPrev[n]==zNext[n]; n++);\n  return n;\n}\n\n/*\n** Add term zTerm to the SegmentNode. It is guaranteed that zTerm is larger\n** (according to memcmp) than the previous term.\n*/\nstatic int fts3NodeAddTerm(\n  Fts3Table *p,                   /* Virtual table handle */\n  SegmentNode **ppTree,           /* IN/OUT: SegmentNode handle */ \n  int isCopyTerm,                 /* True if zTerm/nTerm is transient */\n  const char *zTerm,              /* Pointer to buffer containing term */\n  int nTerm                       /* Size of term in bytes */\n){\n  SegmentNode *pTree = *ppTree;\n  int rc;\n  SegmentNode *pNew;\n\n  /* First try to append the term to the current node. Return early if \n  ** this is possible.\n  */\n  if( pTree ){\n    int nData = pTree->nData;     /* Current size of node in bytes */\n    int nReq = nData;             /* Required space after adding zTerm */\n    int nPrefix;                  /* Number of bytes of prefix compression */\n    int nSuffix;                  /* Suffix length */\n\n    nPrefix = fts3PrefixCompress(pTree->zTerm, pTree->nTerm, zTerm, nTerm);\n    nSuffix = nTerm-nPrefix;\n\n    nReq += sqlite3Fts3VarintLen(nPrefix)+sqlite3Fts3VarintLen(nSuffix)+nSuffix;\n    if( nReq<=p->nNodeSize || !pTree->zTerm ){\n\n      if( nReq>p->nNodeSize ){\n        /* An unusual case: this is the first term to be added to the node\n        ** and the static node buffer (p->nNodeSize bytes) is not large\n        ** enough. Use a separately malloced buffer instead This wastes\n        ** p->nNodeSize bytes, but since this scenario only comes about when\n        ** the database contain two terms that share a prefix of almost 2KB, \n        ** this is not expected to be a serious problem. \n        */\n        assert( pTree->aData==(char *)&pTree[1] );\n        pTree->aData = (char *)sqlite3_malloc(nReq);\n        if( !pTree->aData ){\n          return SQLITE_NOMEM;\n        }\n      }\n\n      if( pTree->zTerm ){\n        /* There is no prefix-length field for first term in a node */\n        nData += sqlite3Fts3PutVarint(&pTree->aData[nData], nPrefix);\n      }\n\n      nData += sqlite3Fts3PutVarint(&pTree->aData[nData], nSuffix);\n      memcpy(&pTree->aData[nData], &zTerm[nPrefix], nSuffix);\n      pTree->nData = nData + nSuffix;\n      pTree->nEntry++;\n\n      if( isCopyTerm ){\n        if( pTree->nMalloc<nTerm ){\n          char *zNew = sqlite3_realloc(pTree->zMalloc, nTerm*2);\n          if( !zNew ){\n            return SQLITE_NOMEM;\n          }\n          pTree->nMalloc = nTerm*2;\n          pTree->zMalloc = zNew;\n        }\n        pTree->zTerm = pTree->zMalloc;\n        memcpy(pTree->zTerm, zTerm, nTerm);\n        pTree->nTerm = nTerm;\n      }else{\n        pTree->zTerm = (char *)zTerm;\n        pTree->nTerm = nTerm;\n      }\n      return SQLITE_OK;\n    }\n  }\n\n  /* If control flows to here, it was not possible to append zTerm to the\n  ** current node. Create a new node (a right-sibling of the current node).\n  ** If this is the first node in the tree, the term is added to it.\n  **\n  ** Otherwise, the term is not added to the new node, it is left empty for\n  ** now. Instead, the term is inserted into the parent of pTree. If pTree \n  ** has no parent, one is created here.\n  */\n  pNew = (SegmentNode *)sqlite3_malloc(sizeof(SegmentNode) + p->nNodeSize);\n  if( !pNew ){\n    return SQLITE_NOMEM;\n  }\n  memset(pNew, 0, sizeof(SegmentNode));\n  pNew->nData = 1 + FTS3_VARINT_MAX;\n  pNew->aData = (char *)&pNew[1];\n\n  if( pTree ){\n    SegmentNode *pParent = pTree->pParent;\n    rc = fts3NodeAddTerm(p, &pParent, isCopyTerm, zTerm, nTerm);\n    if( pTree->pParent==0 ){\n      pTree->pParent = pParent;\n    }\n    pTree->pRight = pNew;\n    pNew->pLeftmost = pTree->pLeftmost;\n    pNew->pParent = pParent;\n    pNew->zMalloc = pTree->zMalloc;\n    pNew->nMalloc = pTree->nMalloc;\n    pTree->zMalloc = 0;\n  }else{\n    pNew->pLeftmost = pNew;\n    rc = fts3NodeAddTerm(p, &pNew, isCopyTerm, zTerm, nTerm); \n  }\n\n  *ppTree = pNew;\n  return rc;\n}\n\n/*\n** Helper function for fts3NodeWrite().\n*/\nstatic int fts3TreeFinishNode(\n  SegmentNode *pTree, \n  int iHeight, \n  sqlite3_int64 iLeftChild\n){\n  int nStart;\n  assert( iHeight>=1 && iHeight<128 );\n  nStart = FTS3_VARINT_MAX - sqlite3Fts3VarintLen(iLeftChild);\n  pTree->aData[nStart] = (char)iHeight;\n  sqlite3Fts3PutVarint(&pTree->aData[nStart+1], iLeftChild);\n  return nStart;\n}\n\n/*\n** Write the buffer for the segment node pTree and all of its peers to the\n** database. Then call this function recursively to write the parent of \n** pTree and its peers to the database. \n**\n** Except, if pTree is a root node, do not write it to the database. Instead,\n** set output variables *paRoot and *pnRoot to contain the root node.\n**\n** If successful, SQLITE_OK is returned and output variable *piLast is\n** set to the largest blockid written to the database (or zero if no\n** blocks were written to the db). Otherwise, an SQLite error code is \n** returned.\n*/\nstatic int fts3NodeWrite(\n  Fts3Table *p,                   /* Virtual table handle */\n  SegmentNode *pTree,             /* SegmentNode handle */\n  int iHeight,                    /* Height of this node in tree */\n  sqlite3_int64 iLeaf,            /* Block id of first leaf node */\n  sqlite3_int64 iFree,            /* Block id of next free slot in %_segments */\n  sqlite3_int64 *piLast,          /* OUT: Block id of last entry written */\n  char **paRoot,                  /* OUT: Data for root node */\n  int *pnRoot                     /* OUT: Size of root node in bytes */\n){\n  int rc = SQLITE_OK;\n\n  if( !pTree->pParent ){\n    /* Root node of the tree. */\n    int nStart = fts3TreeFinishNode(pTree, iHeight, iLeaf);\n    *piLast = iFree-1;\n    *pnRoot = pTree->nData - nStart;\n    *paRoot = &pTree->aData[nStart];\n  }else{\n    SegmentNode *pIter;\n    sqlite3_int64 iNextFree = iFree;\n    sqlite3_int64 iNextLeaf = iLeaf;\n    for(pIter=pTree->pLeftmost; pIter && rc==SQLITE_OK; pIter=pIter->pRight){\n      int nStart = fts3TreeFinishNode(pIter, iHeight, iNextLeaf);\n      int nWrite = pIter->nData - nStart;\n  \n      rc = fts3WriteSegment(p, iNextFree, &pIter->aData[nStart], nWrite);\n      iNextFree++;\n      iNextLeaf += (pIter->nEntry+1);\n    }\n    if( rc==SQLITE_OK ){\n      assert( iNextLeaf==iFree );\n      rc = fts3NodeWrite(\n          p, pTree->pParent, iHeight+1, iFree, iNextFree, piLast, paRoot, pnRoot\n      );\n    }\n  }\n\n  return rc;\n}\n\n/*\n** Free all memory allocations associated with the tree pTree.\n*/\nstatic void fts3NodeFree(SegmentNode *pTree){\n  if( pTree ){\n    SegmentNode *p = pTree->pLeftmost;\n    fts3NodeFree(p->pParent);\n    while( p ){\n      SegmentNode *pRight = p->pRight;\n      if( p->aData!=(char *)&p[1] ){\n        sqlite3_free(p->aData);\n      }\n      assert( pRight==0 || p->zMalloc==0 );\n      sqlite3_free(p->zMalloc);\n      sqlite3_free(p);\n      p = pRight;\n    }\n  }\n}\n\n/*\n** Add a term to the segment being constructed by the SegmentWriter object\n** *ppWriter. When adding the first term to a segment, *ppWriter should\n** be passed NULL. This function will allocate a new SegmentWriter object\n** and return it via the input/output variable *ppWriter in this case.\n**\n** If successful, SQLITE_OK is returned. Otherwise, an SQLite error code.\n*/\nstatic int fts3SegWriterAdd(\n  Fts3Table *p,                   /* Virtual table handle */\n  SegmentWriter **ppWriter,       /* IN/OUT: SegmentWriter handle */ \n  int isCopyTerm,                 /* True if buffer zTerm must be copied */\n  const char *zTerm,              /* Pointer to buffer containing term */\n  int nTerm,                      /* Size of term in bytes */\n  const char *aDoclist,           /* Pointer to buffer containing doclist */\n  int nDoclist                    /* Size of doclist in bytes */\n){\n  int nPrefix;                    /* Size of term prefix in bytes */\n  int nSuffix;                    /* Size of term suffix in bytes */\n  int nReq;                       /* Number of bytes required on leaf page */\n  int nData;\n  SegmentWriter *pWriter = *ppWriter;\n\n  if( !pWriter ){\n    int rc;\n    sqlite3_stmt *pStmt;\n\n    /* Allocate the SegmentWriter structure */\n    pWriter = (SegmentWriter *)sqlite3_malloc(sizeof(SegmentWriter));\n    if( !pWriter ) return SQLITE_NOMEM;\n    memset(pWriter, 0, sizeof(SegmentWriter));\n    *ppWriter = pWriter;\n\n    /* Allocate a buffer in which to accumulate data */\n    pWriter->aData = (char *)sqlite3_malloc(p->nNodeSize);\n    if( !pWriter->aData ) return SQLITE_NOMEM;\n    pWriter->nSize = p->nNodeSize;\n\n    /* Find the next free blockid in the %_segments table */\n    rc = fts3SqlStmt(p, SQL_NEXT_SEGMENTS_ID, &pStmt, 0);\n    if( rc!=SQLITE_OK ) return rc;\n    if( SQLITE_ROW==sqlite3_step(pStmt) ){\n      pWriter->iFree = sqlite3_column_int64(pStmt, 0);\n      pWriter->iFirst = pWriter->iFree;\n    }\n    rc = sqlite3_reset(pStmt);\n    if( rc!=SQLITE_OK ) return rc;\n  }\n  nData = pWriter->nData;\n\n  nPrefix = fts3PrefixCompress(pWriter->zTerm, pWriter->nTerm, zTerm, nTerm);\n  nSuffix = nTerm-nPrefix;\n\n  /* If nSuffix is zero or less, then zTerm/nTerm must be a prefix of \n  ** pWriter->zTerm/pWriter->nTerm. i.e. must be equal to or less than when\n  ** compared with BINARY collation. This indicates corruption.  */\n  if( nSuffix<=0 ) return FTS_CORRUPT_VTAB;\n\n  /* Figure out how many bytes are required by this new entry */\n  nReq = sqlite3Fts3VarintLen(nPrefix) +    /* varint containing prefix size */\n    sqlite3Fts3VarintLen(nSuffix) +         /* varint containing suffix size */\n    nSuffix +                               /* Term suffix */\n    sqlite3Fts3VarintLen(nDoclist) +        /* Size of doclist */\n    nDoclist;                               /* Doclist data */\n\n  if( nData>0 && nData+nReq>p->nNodeSize ){\n    int rc;\n\n    /* The current leaf node is full. Write it out to the database. */\n    rc = fts3WriteSegment(p, pWriter->iFree++, pWriter->aData, nData);\n    if( rc!=SQLITE_OK ) return rc;\n    p->nLeafAdd++;\n\n    /* Add the current term to the interior node tree. The term added to\n    ** the interior tree must:\n    **\n    **   a) be greater than the largest term on the leaf node just written\n    **      to the database (still available in pWriter->zTerm), and\n    **\n    **   b) be less than or equal to the term about to be added to the new\n    **      leaf node (zTerm/nTerm).\n    **\n    ** In other words, it must be the prefix of zTerm 1 byte longer than\n    ** the common prefix (if any) of zTerm and pWriter->zTerm.\n    */\n    assert( nPrefix<nTerm );\n    rc = fts3NodeAddTerm(p, &pWriter->pTree, isCopyTerm, zTerm, nPrefix+1);\n    if( rc!=SQLITE_OK ) return rc;\n\n    nData = 0;\n    pWriter->nTerm = 0;\n\n    nPrefix = 0;\n    nSuffix = nTerm;\n    nReq = 1 +                              /* varint containing prefix size */\n      sqlite3Fts3VarintLen(nTerm) +         /* varint containing suffix size */\n      nTerm +                               /* Term suffix */\n      sqlite3Fts3VarintLen(nDoclist) +      /* Size of doclist */\n      nDoclist;                             /* Doclist data */\n  }\n\n  /* Increase the total number of bytes written to account for the new entry. */\n  pWriter->nLeafData += nReq;\n\n  /* If the buffer currently allocated is too small for this entry, realloc\n  ** the buffer to make it large enough.\n  */\n  if( nReq>pWriter->nSize ){\n    char *aNew = sqlite3_realloc(pWriter->aData, nReq);\n    if( !aNew ) return SQLITE_NOMEM;\n    pWriter->aData = aNew;\n    pWriter->nSize = nReq;\n  }\n  assert( nData+nReq<=pWriter->nSize );\n\n  /* Append the prefix-compressed term and doclist to the buffer. */\n  nData += sqlite3Fts3PutVarint(&pWriter->aData[nData], nPrefix);\n  nData += sqlite3Fts3PutVarint(&pWriter->aData[nData], nSuffix);\n  memcpy(&pWriter->aData[nData], &zTerm[nPrefix], nSuffix);\n  nData += nSuffix;\n  nData += sqlite3Fts3PutVarint(&pWriter->aData[nData], nDoclist);\n  memcpy(&pWriter->aData[nData], aDoclist, nDoclist);\n  pWriter->nData = nData + nDoclist;\n\n  /* Save the current term so that it can be used to prefix-compress the next.\n  ** If the isCopyTerm parameter is true, then the buffer pointed to by\n  ** zTerm is transient, so take a copy of the term data. Otherwise, just\n  ** store a copy of the pointer.\n  */\n  if( isCopyTerm ){\n    if( nTerm>pWriter->nMalloc ){\n      char *zNew = sqlite3_realloc(pWriter->zMalloc, nTerm*2);\n      if( !zNew ){\n        return SQLITE_NOMEM;\n      }\n      pWriter->nMalloc = nTerm*2;\n      pWriter->zMalloc = zNew;\n      pWriter->zTerm = zNew;\n    }\n    assert( pWriter->zTerm==pWriter->zMalloc );\n    memcpy(pWriter->zTerm, zTerm, nTerm);\n  }else{\n    pWriter->zTerm = (char *)zTerm;\n  }\n  pWriter->nTerm = nTerm;\n\n  return SQLITE_OK;\n}\n\n/*\n** Flush all data associated with the SegmentWriter object pWriter to the\n** database. This function must be called after all terms have been added\n** to the segment using fts3SegWriterAdd(). If successful, SQLITE_OK is\n** returned. Otherwise, an SQLite error code.\n*/\nstatic int fts3SegWriterFlush(\n  Fts3Table *p,                   /* Virtual table handle */\n  SegmentWriter *pWriter,         /* SegmentWriter to flush to the db */\n  sqlite3_int64 iLevel,           /* Value for 'level' column of %_segdir */\n  int iIdx                        /* Value for 'idx' column of %_segdir */\n){\n  int rc;                         /* Return code */\n  if( pWriter->pTree ){\n    sqlite3_int64 iLast = 0;      /* Largest block id written to database */\n    sqlite3_int64 iLastLeaf;      /* Largest leaf block id written to db */\n    char *zRoot = NULL;           /* Pointer to buffer containing root node */\n    int nRoot = 0;                /* Size of buffer zRoot */\n\n    iLastLeaf = pWriter->iFree;\n    rc = fts3WriteSegment(p, pWriter->iFree++, pWriter->aData, pWriter->nData);\n    if( rc==SQLITE_OK ){\n      rc = fts3NodeWrite(p, pWriter->pTree, 1,\n          pWriter->iFirst, pWriter->iFree, &iLast, &zRoot, &nRoot);\n    }\n    if( rc==SQLITE_OK ){\n      rc = fts3WriteSegdir(p, iLevel, iIdx, \n          pWriter->iFirst, iLastLeaf, iLast, pWriter->nLeafData, zRoot, nRoot);\n    }\n  }else{\n    /* The entire tree fits on the root node. Write it to the segdir table. */\n    rc = fts3WriteSegdir(p, iLevel, iIdx, \n        0, 0, 0, pWriter->nLeafData, pWriter->aData, pWriter->nData);\n  }\n  p->nLeafAdd++;\n  return rc;\n}\n\n/*\n** Release all memory held by the SegmentWriter object passed as the \n** first argument.\n*/\nstatic void fts3SegWriterFree(SegmentWriter *pWriter){\n  if( pWriter ){\n    sqlite3_free(pWriter->aData);\n    sqlite3_free(pWriter->zMalloc);\n    fts3NodeFree(pWriter->pTree);\n    sqlite3_free(pWriter);\n  }\n}\n\n/*\n** The first value in the apVal[] array is assumed to contain an integer.\n** This function tests if there exist any documents with docid values that\n** are different from that integer. i.e. if deleting the document with docid\n** pRowid would mean the FTS3 table were empty.\n**\n** If successful, *pisEmpty is set to true if the table is empty except for\n** document pRowid, or false otherwise, and SQLITE_OK is returned. If an\n** error occurs, an SQLite error code is returned.\n*/\nstatic int fts3IsEmpty(Fts3Table *p, sqlite3_value *pRowid, int *pisEmpty){\n  sqlite3_stmt *pStmt;\n  int rc;\n  if( p->zContentTbl ){\n    /* If using the content=xxx option, assume the table is never empty */\n    *pisEmpty = 0;\n    rc = SQLITE_OK;\n  }else{\n    rc = fts3SqlStmt(p, SQL_IS_EMPTY, &pStmt, &pRowid);\n    if( rc==SQLITE_OK ){\n      if( SQLITE_ROW==sqlite3_step(pStmt) ){\n        *pisEmpty = sqlite3_column_int(pStmt, 0);\n      }\n      rc = sqlite3_reset(pStmt);\n    }\n  }\n  return rc;\n}\n\n/*\n** Set *pnMax to the largest segment level in the database for the index\n** iIndex.\n**\n** Segment levels are stored in the 'level' column of the %_segdir table.\n**\n** Return SQLITE_OK if successful, or an SQLite error code if not.\n*/\nstatic int fts3SegmentMaxLevel(\n  Fts3Table *p, \n  int iLangid,\n  int iIndex, \n  sqlite3_int64 *pnMax\n){\n  sqlite3_stmt *pStmt;\n  int rc;\n  assert( iIndex>=0 && iIndex<p->nIndex );\n\n  /* Set pStmt to the compiled version of:\n  **\n  **   SELECT max(level) FROM %Q.'%q_segdir' WHERE level BETWEEN ? AND ?\n  **\n  ** (1024 is actually the value of macro FTS3_SEGDIR_PREFIXLEVEL_STR).\n  */\n  rc = fts3SqlStmt(p, SQL_SELECT_SEGDIR_MAX_LEVEL, &pStmt, 0);\n  if( rc!=SQLITE_OK ) return rc;\n  sqlite3_bind_int64(pStmt, 1, getAbsoluteLevel(p, iLangid, iIndex, 0));\n  sqlite3_bind_int64(pStmt, 2, \n      getAbsoluteLevel(p, iLangid, iIndex, FTS3_SEGDIR_MAXLEVEL-1)\n  );\n  if( SQLITE_ROW==sqlite3_step(pStmt) ){\n    *pnMax = sqlite3_column_int64(pStmt, 0);\n  }\n  return sqlite3_reset(pStmt);\n}\n\n/*\n** iAbsLevel is an absolute level that may be assumed to exist within\n** the database. This function checks if it is the largest level number\n** within its index. Assuming no error occurs, *pbMax is set to 1 if\n** iAbsLevel is indeed the largest level, or 0 otherwise, and SQLITE_OK\n** is returned. If an error occurs, an error code is returned and the\n** final value of *pbMax is undefined.\n*/\nstatic int fts3SegmentIsMaxLevel(Fts3Table *p, i64 iAbsLevel, int *pbMax){\n\n  /* Set pStmt to the compiled version of:\n  **\n  **   SELECT max(level) FROM %Q.'%q_segdir' WHERE level BETWEEN ? AND ?\n  **\n  ** (1024 is actually the value of macro FTS3_SEGDIR_PREFIXLEVEL_STR).\n  */\n  sqlite3_stmt *pStmt;\n  int rc = fts3SqlStmt(p, SQL_SELECT_SEGDIR_MAX_LEVEL, &pStmt, 0);\n  if( rc!=SQLITE_OK ) return rc;\n  sqlite3_bind_int64(pStmt, 1, iAbsLevel+1);\n  sqlite3_bind_int64(pStmt, 2, \n      ((iAbsLevel/FTS3_SEGDIR_MAXLEVEL)+1) * FTS3_SEGDIR_MAXLEVEL\n  );\n\n  *pbMax = 0;\n  if( SQLITE_ROW==sqlite3_step(pStmt) ){\n    *pbMax = sqlite3_column_type(pStmt, 0)==SQLITE_NULL;\n  }\n  return sqlite3_reset(pStmt);\n}\n\n/*\n** Delete all entries in the %_segments table associated with the segment\n** opened with seg-reader pSeg. This function does not affect the contents\n** of the %_segdir table.\n*/\nstatic int fts3DeleteSegment(\n  Fts3Table *p,                   /* FTS table handle */\n  Fts3SegReader *pSeg             /* Segment to delete */\n){\n  int rc = SQLITE_OK;             /* Return code */\n  if( pSeg->iStartBlock ){\n    sqlite3_stmt *pDelete;        /* SQL statement to delete rows */\n    rc = fts3SqlStmt(p, SQL_DELETE_SEGMENTS_RANGE, &pDelete, 0);\n    if( rc==SQLITE_OK ){\n      sqlite3_bind_int64(pDelete, 1, pSeg->iStartBlock);\n      sqlite3_bind_int64(pDelete, 2, pSeg->iEndBlock);\n      sqlite3_step(pDelete);\n      rc = sqlite3_reset(pDelete);\n    }\n  }\n  return rc;\n}\n\n/*\n** This function is used after merging multiple segments into a single large\n** segment to delete the old, now redundant, segment b-trees. Specifically,\n** it:\n** \n**   1) Deletes all %_segments entries for the segments associated with \n**      each of the SegReader objects in the array passed as the third \n**      argument, and\n**\n**   2) deletes all %_segdir entries with level iLevel, or all %_segdir\n**      entries regardless of level if (iLevel<0).\n**\n** SQLITE_OK is returned if successful, otherwise an SQLite error code.\n*/\nstatic int fts3DeleteSegdir(\n  Fts3Table *p,                   /* Virtual table handle */\n  int iLangid,                    /* Language id */\n  int iIndex,                     /* Index for p->aIndex */\n  int iLevel,                     /* Level of %_segdir entries to delete */\n  Fts3SegReader **apSegment,      /* Array of SegReader objects */\n  int nReader                     /* Size of array apSegment */\n){\n  int rc = SQLITE_OK;             /* Return Code */\n  int i;                          /* Iterator variable */\n  sqlite3_stmt *pDelete = 0;      /* SQL statement to delete rows */\n\n  for(i=0; rc==SQLITE_OK && i<nReader; i++){\n    rc = fts3DeleteSegment(p, apSegment[i]);\n  }\n  if( rc!=SQLITE_OK ){\n    return rc;\n  }\n\n  assert( iLevel>=0 || iLevel==FTS3_SEGCURSOR_ALL );\n  if( iLevel==FTS3_SEGCURSOR_ALL ){\n    rc = fts3SqlStmt(p, SQL_DELETE_SEGDIR_RANGE, &pDelete, 0);\n    if( rc==SQLITE_OK ){\n      sqlite3_bind_int64(pDelete, 1, getAbsoluteLevel(p, iLangid, iIndex, 0));\n      sqlite3_bind_int64(pDelete, 2, \n          getAbsoluteLevel(p, iLangid, iIndex, FTS3_SEGDIR_MAXLEVEL-1)\n      );\n    }\n  }else{\n    rc = fts3SqlStmt(p, SQL_DELETE_SEGDIR_LEVEL, &pDelete, 0);\n    if( rc==SQLITE_OK ){\n      sqlite3_bind_int64(\n          pDelete, 1, getAbsoluteLevel(p, iLangid, iIndex, iLevel)\n      );\n    }\n  }\n\n  if( rc==SQLITE_OK ){\n    sqlite3_step(pDelete);\n    rc = sqlite3_reset(pDelete);\n  }\n\n  return rc;\n}\n\n/*\n** When this function is called, buffer *ppList (size *pnList bytes) contains \n** a position list that may (or may not) feature multiple columns. This\n** function adjusts the pointer *ppList and the length *pnList so that they\n** identify the subset of the position list that corresponds to column iCol.\n**\n** If there are no entries in the input position list for column iCol, then\n** *pnList is set to zero before returning.\n**\n** If parameter bZero is non-zero, then any part of the input list following\n** the end of the output list is zeroed before returning.\n*/\nstatic void fts3ColumnFilter(\n  int iCol,                       /* Column to filter on */\n  int bZero,                      /* Zero out anything following *ppList */\n  char **ppList,                  /* IN/OUT: Pointer to position list */\n  int *pnList                     /* IN/OUT: Size of buffer *ppList in bytes */\n){\n  char *pList = *ppList;\n  int nList = *pnList;\n  char *pEnd = &pList[nList];\n  int iCurrent = 0;\n  char *p = pList;\n\n  assert( iCol>=0 );\n  while( 1 ){\n    char c = 0;\n    while( p<pEnd && (c | *p)&0xFE ) c = *p++ & 0x80;\n  \n    if( iCol==iCurrent ){\n      nList = (int)(p - pList);\n      break;\n    }\n\n    nList -= (int)(p - pList);\n    pList = p;\n    if( nList==0 ){\n      break;\n    }\n    p = &pList[1];\n    p += fts3GetVarint32(p, &iCurrent);\n  }\n\n  if( bZero && &pList[nList]!=pEnd ){\n    memset(&pList[nList], 0, pEnd - &pList[nList]);\n  }\n  *ppList = pList;\n  *pnList = nList;\n}\n\n/*\n** Cache data in the Fts3MultiSegReader.aBuffer[] buffer (overwriting any\n** existing data). Grow the buffer if required.\n**\n** If successful, return SQLITE_OK. Otherwise, if an OOM error is encountered\n** trying to resize the buffer, return SQLITE_NOMEM.\n*/\nstatic int fts3MsrBufferData(\n  Fts3MultiSegReader *pMsr,       /* Multi-segment-reader handle */\n  char *pList,\n  int nList\n){\n  if( nList>pMsr->nBuffer ){\n    char *pNew;\n    pMsr->nBuffer = nList*2;\n    pNew = (char *)sqlite3_realloc(pMsr->aBuffer, pMsr->nBuffer);\n    if( !pNew ) return SQLITE_NOMEM;\n    pMsr->aBuffer = pNew;\n  }\n\n  memcpy(pMsr->aBuffer, pList, nList);\n  return SQLITE_OK;\n}\n\nSQLITE_PRIVATE int sqlite3Fts3MsrIncrNext(\n  Fts3Table *p,                   /* Virtual table handle */\n  Fts3MultiSegReader *pMsr,       /* Multi-segment-reader handle */\n  sqlite3_int64 *piDocid,         /* OUT: Docid value */\n  char **paPoslist,               /* OUT: Pointer to position list */\n  int *pnPoslist                  /* OUT: Size of position list in bytes */\n){\n  int nMerge = pMsr->nAdvance;\n  Fts3SegReader **apSegment = pMsr->apSegment;\n  int (*xCmp)(Fts3SegReader *, Fts3SegReader *) = (\n    p->bDescIdx ? fts3SegReaderDoclistCmpRev : fts3SegReaderDoclistCmp\n  );\n\n  if( nMerge==0 ){\n    *paPoslist = 0;\n    return SQLITE_OK;\n  }\n\n  while( 1 ){\n    Fts3SegReader *pSeg;\n    pSeg = pMsr->apSegment[0];\n\n    if( pSeg->pOffsetList==0 ){\n      *paPoslist = 0;\n      break;\n    }else{\n      int rc;\n      char *pList;\n      int nList;\n      int j;\n      sqlite3_int64 iDocid = apSegment[0]->iDocid;\n\n      rc = fts3SegReaderNextDocid(p, apSegment[0], &pList, &nList);\n      j = 1;\n      while( rc==SQLITE_OK \n        && j<nMerge\n        && apSegment[j]->pOffsetList\n        && apSegment[j]->iDocid==iDocid\n      ){\n        rc = fts3SegReaderNextDocid(p, apSegment[j], 0, 0);\n        j++;\n      }\n      if( rc!=SQLITE_OK ) return rc;\n      fts3SegReaderSort(pMsr->apSegment, nMerge, j, xCmp);\n\n      if( nList>0 && fts3SegReaderIsPending(apSegment[0]) ){\n        rc = fts3MsrBufferData(pMsr, pList, nList+1);\n        if( rc!=SQLITE_OK ) return rc;\n        assert( (pMsr->aBuffer[nList] & 0xFE)==0x00 );\n        pList = pMsr->aBuffer;\n      }\n\n      if( pMsr->iColFilter>=0 ){\n        fts3ColumnFilter(pMsr->iColFilter, 1, &pList, &nList);\n      }\n\n      if( nList>0 ){\n        *paPoslist = pList;\n        *piDocid = iDocid;\n        *pnPoslist = nList;\n        break;\n      }\n    }\n  }\n\n  return SQLITE_OK;\n}\n\nstatic int fts3SegReaderStart(\n  Fts3Table *p,                   /* Virtual table handle */\n  Fts3MultiSegReader *pCsr,       /* Cursor object */\n  const char *zTerm,              /* Term searched for (or NULL) */\n  int nTerm                       /* Length of zTerm in bytes */\n){\n  int i;\n  int nSeg = pCsr->nSegment;\n\n  /* If the Fts3SegFilter defines a specific term (or term prefix) to search \n  ** for, then advance each segment iterator until it points to a term of\n  ** equal or greater value than the specified term. This prevents many\n  ** unnecessary merge/sort operations for the case where single segment\n  ** b-tree leaf nodes contain more than one term.\n  */\n  for(i=0; pCsr->bRestart==0 && i<pCsr->nSegment; i++){\n    int res = 0;\n    Fts3SegReader *pSeg = pCsr->apSegment[i];\n    do {\n      int rc = fts3SegReaderNext(p, pSeg, 0);\n      if( rc!=SQLITE_OK ) return rc;\n    }while( zTerm && (res = fts3SegReaderTermCmp(pSeg, zTerm, nTerm))<0 );\n\n    if( pSeg->bLookup && res!=0 ){\n      fts3SegReaderSetEof(pSeg);\n    }\n  }\n  fts3SegReaderSort(pCsr->apSegment, nSeg, nSeg, fts3SegReaderCmp);\n\n  return SQLITE_OK;\n}\n\nSQLITE_PRIVATE int sqlite3Fts3SegReaderStart(\n  Fts3Table *p,                   /* Virtual table handle */\n  Fts3MultiSegReader *pCsr,       /* Cursor object */\n  Fts3SegFilter *pFilter          /* Restrictions on range of iteration */\n){\n  pCsr->pFilter = pFilter;\n  return fts3SegReaderStart(p, pCsr, pFilter->zTerm, pFilter->nTerm);\n}\n\nSQLITE_PRIVATE int sqlite3Fts3MsrIncrStart(\n  Fts3Table *p,                   /* Virtual table handle */\n  Fts3MultiSegReader *pCsr,       /* Cursor object */\n  int iCol,                       /* Column to match on. */\n  const char *zTerm,              /* Term to iterate through a doclist for */\n  int nTerm                       /* Number of bytes in zTerm */\n){\n  int i;\n  int rc;\n  int nSegment = pCsr->nSegment;\n  int (*xCmp)(Fts3SegReader *, Fts3SegReader *) = (\n    p->bDescIdx ? fts3SegReaderDoclistCmpRev : fts3SegReaderDoclistCmp\n  );\n\n  assert( pCsr->pFilter==0 );\n  assert( zTerm && nTerm>0 );\n\n  /* Advance each segment iterator until it points to the term zTerm/nTerm. */\n  rc = fts3SegReaderStart(p, pCsr, zTerm, nTerm);\n  if( rc!=SQLITE_OK ) return rc;\n\n  /* Determine how many of the segments actually point to zTerm/nTerm. */\n  for(i=0; i<nSegment; i++){\n    Fts3SegReader *pSeg = pCsr->apSegment[i];\n    if( !pSeg->aNode || fts3SegReaderTermCmp(pSeg, zTerm, nTerm) ){\n      break;\n    }\n  }\n  pCsr->nAdvance = i;\n\n  /* Advance each of the segments to point to the first docid. */\n  for(i=0; i<pCsr->nAdvance; i++){\n    rc = fts3SegReaderFirstDocid(p, pCsr->apSegment[i]);\n    if( rc!=SQLITE_OK ) return rc;\n  }\n  fts3SegReaderSort(pCsr->apSegment, i, i, xCmp);\n\n  assert( iCol<0 || iCol<p->nColumn );\n  pCsr->iColFilter = iCol;\n\n  return SQLITE_OK;\n}\n\n/*\n** This function is called on a MultiSegReader that has been started using\n** sqlite3Fts3MsrIncrStart(). One or more calls to MsrIncrNext() may also\n** have been made. Calling this function puts the MultiSegReader in such\n** a state that if the next two calls are:\n**\n**   sqlite3Fts3SegReaderStart()\n**   sqlite3Fts3SegReaderStep()\n**\n** then the entire doclist for the term is available in \n** MultiSegReader.aDoclist/nDoclist.\n*/\nSQLITE_PRIVATE int sqlite3Fts3MsrIncrRestart(Fts3MultiSegReader *pCsr){\n  int i;                          /* Used to iterate through segment-readers */\n\n  assert( pCsr->zTerm==0 );\n  assert( pCsr->nTerm==0 );\n  assert( pCsr->aDoclist==0 );\n  assert( pCsr->nDoclist==0 );\n\n  pCsr->nAdvance = 0;\n  pCsr->bRestart = 1;\n  for(i=0; i<pCsr->nSegment; i++){\n    pCsr->apSegment[i]->pOffsetList = 0;\n    pCsr->apSegment[i]->nOffsetList = 0;\n    pCsr->apSegment[i]->iDocid = 0;\n  }\n\n  return SQLITE_OK;\n}\n\n\nSQLITE_PRIVATE int sqlite3Fts3SegReaderStep(\n  Fts3Table *p,                   /* Virtual table handle */\n  Fts3MultiSegReader *pCsr        /* Cursor object */\n){\n  int rc = SQLITE_OK;\n\n  int isIgnoreEmpty =  (pCsr->pFilter->flags & FTS3_SEGMENT_IGNORE_EMPTY);\n  int isRequirePos =   (pCsr->pFilter->flags & FTS3_SEGMENT_REQUIRE_POS);\n  int isColFilter =    (pCsr->pFilter->flags & FTS3_SEGMENT_COLUMN_FILTER);\n  int isPrefix =       (pCsr->pFilter->flags & FTS3_SEGMENT_PREFIX);\n  int isScan =         (pCsr->pFilter->flags & FTS3_SEGMENT_SCAN);\n  int isFirst =        (pCsr->pFilter->flags & FTS3_SEGMENT_FIRST);\n\n  Fts3SegReader **apSegment = pCsr->apSegment;\n  int nSegment = pCsr->nSegment;\n  Fts3SegFilter *pFilter = pCsr->pFilter;\n  int (*xCmp)(Fts3SegReader *, Fts3SegReader *) = (\n    p->bDescIdx ? fts3SegReaderDoclistCmpRev : fts3SegReaderDoclistCmp\n  );\n\n  if( pCsr->nSegment==0 ) return SQLITE_OK;\n\n  do {\n    int nMerge;\n    int i;\n  \n    /* Advance the first pCsr->nAdvance entries in the apSegment[] array\n    ** forward. Then sort the list in order of current term again.  \n    */\n    for(i=0; i<pCsr->nAdvance; i++){\n      Fts3SegReader *pSeg = apSegment[i];\n      if( pSeg->bLookup ){\n        fts3SegReaderSetEof(pSeg);\n      }else{\n        rc = fts3SegReaderNext(p, pSeg, 0);\n      }\n      if( rc!=SQLITE_OK ) return rc;\n    }\n    fts3SegReaderSort(apSegment, nSegment, pCsr->nAdvance, fts3SegReaderCmp);\n    pCsr->nAdvance = 0;\n\n    /* If all the seg-readers are at EOF, we're finished. return SQLITE_OK. */\n    assert( rc==SQLITE_OK );\n    if( apSegment[0]->aNode==0 ) break;\n\n    pCsr->nTerm = apSegment[0]->nTerm;\n    pCsr->zTerm = apSegment[0]->zTerm;\n\n    /* If this is a prefix-search, and if the term that apSegment[0] points\n    ** to does not share a suffix with pFilter->zTerm/nTerm, then all \n    ** required callbacks have been made. In this case exit early.\n    **\n    ** Similarly, if this is a search for an exact match, and the first term\n    ** of segment apSegment[0] is not a match, exit early.\n    */\n    if( pFilter->zTerm && !isScan ){\n      if( pCsr->nTerm<pFilter->nTerm \n       || (!isPrefix && pCsr->nTerm>pFilter->nTerm)\n       || memcmp(pCsr->zTerm, pFilter->zTerm, pFilter->nTerm) \n      ){\n        break;\n      }\n    }\n\n    nMerge = 1;\n    while( nMerge<nSegment \n        && apSegment[nMerge]->aNode\n        && apSegment[nMerge]->nTerm==pCsr->nTerm \n        && 0==memcmp(pCsr->zTerm, apSegment[nMerge]->zTerm, pCsr->nTerm)\n    ){\n      nMerge++;\n    }\n\n    assert( isIgnoreEmpty || (isRequirePos && !isColFilter) );\n    if( nMerge==1 \n     && !isIgnoreEmpty \n     && !isFirst \n     && (p->bDescIdx==0 || fts3SegReaderIsPending(apSegment[0])==0)\n    ){\n      pCsr->nDoclist = apSegment[0]->nDoclist;\n      if( fts3SegReaderIsPending(apSegment[0]) ){\n        rc = fts3MsrBufferData(pCsr, apSegment[0]->aDoclist, pCsr->nDoclist);\n        pCsr->aDoclist = pCsr->aBuffer;\n      }else{\n        pCsr->aDoclist = apSegment[0]->aDoclist;\n      }\n      if( rc==SQLITE_OK ) rc = SQLITE_ROW;\n    }else{\n      int nDoclist = 0;           /* Size of doclist */\n      sqlite3_int64 iPrev = 0;    /* Previous docid stored in doclist */\n\n      /* The current term of the first nMerge entries in the array\n      ** of Fts3SegReader objects is the same. The doclists must be merged\n      ** and a single term returned with the merged doclist.\n      */\n      for(i=0; i<nMerge; i++){\n        fts3SegReaderFirstDocid(p, apSegment[i]);\n      }\n      fts3SegReaderSort(apSegment, nMerge, nMerge, xCmp);\n      while( apSegment[0]->pOffsetList ){\n        int j;                    /* Number of segments that share a docid */\n        char *pList = 0;\n        int nList = 0;\n        int nByte;\n        sqlite3_int64 iDocid = apSegment[0]->iDocid;\n        fts3SegReaderNextDocid(p, apSegment[0], &pList, &nList);\n        j = 1;\n        while( j<nMerge\n            && apSegment[j]->pOffsetList\n            && apSegment[j]->iDocid==iDocid\n        ){\n          fts3SegReaderNextDocid(p, apSegment[j], 0, 0);\n          j++;\n        }\n\n        if( isColFilter ){\n          fts3ColumnFilter(pFilter->iCol, 0, &pList, &nList);\n        }\n\n        if( !isIgnoreEmpty || nList>0 ){\n\n          /* Calculate the 'docid' delta value to write into the merged \n          ** doclist. */\n          sqlite3_int64 iDelta;\n          if( p->bDescIdx && nDoclist>0 ){\n            iDelta = iPrev - iDocid;\n          }else{\n            iDelta = iDocid - iPrev;\n          }\n          if( iDelta<=0 && (nDoclist>0 || iDelta!=iDocid) ){\n            return FTS_CORRUPT_VTAB;\n          }\n          assert( nDoclist>0 || iDelta==iDocid );\n\n          nByte = sqlite3Fts3VarintLen(iDelta) + (isRequirePos?nList+1:0);\n          if( nDoclist+nByte>pCsr->nBuffer ){\n            char *aNew;\n            pCsr->nBuffer = (nDoclist+nByte)*2;\n            aNew = sqlite3_realloc(pCsr->aBuffer, pCsr->nBuffer);\n            if( !aNew ){\n              return SQLITE_NOMEM;\n            }\n            pCsr->aBuffer = aNew;\n          }\n\n          if( isFirst ){\n            char *a = &pCsr->aBuffer[nDoclist];\n            int nWrite;\n           \n            nWrite = sqlite3Fts3FirstFilter(iDelta, pList, nList, a);\n            if( nWrite ){\n              iPrev = iDocid;\n              nDoclist += nWrite;\n            }\n          }else{\n            nDoclist += sqlite3Fts3PutVarint(&pCsr->aBuffer[nDoclist], iDelta);\n            iPrev = iDocid;\n            if( isRequirePos ){\n              memcpy(&pCsr->aBuffer[nDoclist], pList, nList);\n              nDoclist += nList;\n              pCsr->aBuffer[nDoclist++] = '\\0';\n            }\n          }\n        }\n\n        fts3SegReaderSort(apSegment, nMerge, j, xCmp);\n      }\n      if( nDoclist>0 ){\n        pCsr->aDoclist = pCsr->aBuffer;\n        pCsr->nDoclist = nDoclist;\n        rc = SQLITE_ROW;\n      }\n    }\n    pCsr->nAdvance = nMerge;\n  }while( rc==SQLITE_OK );\n\n  return rc;\n}\n\n\nSQLITE_PRIVATE void sqlite3Fts3SegReaderFinish(\n  Fts3MultiSegReader *pCsr       /* Cursor object */\n){\n  if( pCsr ){\n    int i;\n    for(i=0; i<pCsr->nSegment; i++){\n      sqlite3Fts3SegReaderFree(pCsr->apSegment[i]);\n    }\n    sqlite3_free(pCsr->apSegment);\n    sqlite3_free(pCsr->aBuffer);\n\n    pCsr->nSegment = 0;\n    pCsr->apSegment = 0;\n    pCsr->aBuffer = 0;\n  }\n}\n\n/*\n** Decode the \"end_block\" field, selected by column iCol of the SELECT \n** statement passed as the first argument. \n**\n** The \"end_block\" field may contain either an integer, or a text field\n** containing the text representation of two non-negative integers separated \n** by one or more space (0x20) characters. In the first case, set *piEndBlock \n** to the integer value and *pnByte to zero before returning. In the second, \n** set *piEndBlock to the first value and *pnByte to the second.\n*/\nstatic void fts3ReadEndBlockField(\n  sqlite3_stmt *pStmt, \n  int iCol, \n  i64 *piEndBlock,\n  i64 *pnByte\n){\n  const unsigned char *zText = sqlite3_column_text(pStmt, iCol);\n  if( zText ){\n    int i;\n    int iMul = 1;\n    i64 iVal = 0;\n    for(i=0; zText[i]>='0' && zText[i]<='9'; i++){\n      iVal = iVal*10 + (zText[i] - '0');\n    }\n    *piEndBlock = iVal;\n    while( zText[i]==' ' ) i++;\n    iVal = 0;\n    if( zText[i]=='-' ){\n      i++;\n      iMul = -1;\n    }\n    for(/* no-op */; zText[i]>='0' && zText[i]<='9'; i++){\n      iVal = iVal*10 + (zText[i] - '0');\n    }\n    *pnByte = (iVal * (i64)iMul);\n  }\n}\n\n\n/*\n** A segment of size nByte bytes has just been written to absolute level\n** iAbsLevel. Promote any segments that should be promoted as a result.\n*/\nstatic int fts3PromoteSegments(\n  Fts3Table *p,                   /* FTS table handle */\n  sqlite3_int64 iAbsLevel,        /* Absolute level just updated */\n  sqlite3_int64 nByte             /* Size of new segment at iAbsLevel */\n){\n  int rc = SQLITE_OK;\n  sqlite3_stmt *pRange;\n\n  rc = fts3SqlStmt(p, SQL_SELECT_LEVEL_RANGE2, &pRange, 0);\n\n  if( rc==SQLITE_OK ){\n    int bOk = 0;\n    i64 iLast = (iAbsLevel/FTS3_SEGDIR_MAXLEVEL + 1) * FTS3_SEGDIR_MAXLEVEL - 1;\n    i64 nLimit = (nByte*3)/2;\n\n    /* Loop through all entries in the %_segdir table corresponding to \n    ** segments in this index on levels greater than iAbsLevel. If there is\n    ** at least one such segment, and it is possible to determine that all \n    ** such segments are smaller than nLimit bytes in size, they will be \n    ** promoted to level iAbsLevel.  */\n    sqlite3_bind_int64(pRange, 1, iAbsLevel+1);\n    sqlite3_bind_int64(pRange, 2, iLast);\n    while( SQLITE_ROW==sqlite3_step(pRange) ){\n      i64 nSize = 0, dummy;\n      fts3ReadEndBlockField(pRange, 2, &dummy, &nSize);\n      if( nSize<=0 || nSize>nLimit ){\n        /* If nSize==0, then the %_segdir.end_block field does not not \n        ** contain a size value. This happens if it was written by an\n        ** old version of FTS. In this case it is not possible to determine\n        ** the size of the segment, and so segment promotion does not\n        ** take place.  */\n        bOk = 0;\n        break;\n      }\n      bOk = 1;\n    }\n    rc = sqlite3_reset(pRange);\n\n    if( bOk ){\n      int iIdx = 0;\n      sqlite3_stmt *pUpdate1 = 0;\n      sqlite3_stmt *pUpdate2 = 0;\n\n      if( rc==SQLITE_OK ){\n        rc = fts3SqlStmt(p, SQL_UPDATE_LEVEL_IDX, &pUpdate1, 0);\n      }\n      if( rc==SQLITE_OK ){\n        rc = fts3SqlStmt(p, SQL_UPDATE_LEVEL, &pUpdate2, 0);\n      }\n\n      if( rc==SQLITE_OK ){\n\n        /* Loop through all %_segdir entries for segments in this index with\n        ** levels equal to or greater than iAbsLevel. As each entry is visited,\n        ** updated it to set (level = -1) and (idx = N), where N is 0 for the\n        ** oldest segment in the range, 1 for the next oldest, and so on.\n        **\n        ** In other words, move all segments being promoted to level -1,\n        ** setting the \"idx\" fields as appropriate to keep them in the same\n        ** order. The contents of level -1 (which is never used, except\n        ** transiently here), will be moved back to level iAbsLevel below.  */\n        sqlite3_bind_int64(pRange, 1, iAbsLevel);\n        while( SQLITE_ROW==sqlite3_step(pRange) ){\n          sqlite3_bind_int(pUpdate1, 1, iIdx++);\n          sqlite3_bind_int(pUpdate1, 2, sqlite3_column_int(pRange, 0));\n          sqlite3_bind_int(pUpdate1, 3, sqlite3_column_int(pRange, 1));\n          sqlite3_step(pUpdate1);\n          rc = sqlite3_reset(pUpdate1);\n          if( rc!=SQLITE_OK ){\n            sqlite3_reset(pRange);\n            break;\n          }\n        }\n      }\n      if( rc==SQLITE_OK ){\n        rc = sqlite3_reset(pRange);\n      }\n\n      /* Move level -1 to level iAbsLevel */\n      if( rc==SQLITE_OK ){\n        sqlite3_bind_int64(pUpdate2, 1, iAbsLevel);\n        sqlite3_step(pUpdate2);\n        rc = sqlite3_reset(pUpdate2);\n      }\n    }\n  }\n\n\n  return rc;\n}\n\n/*\n** Merge all level iLevel segments in the database into a single \n** iLevel+1 segment. Or, if iLevel<0, merge all segments into a\n** single segment with a level equal to the numerically largest level \n** currently present in the database.\n**\n** If this function is called with iLevel<0, but there is only one\n** segment in the database, SQLITE_DONE is returned immediately. \n** Otherwise, if successful, SQLITE_OK is returned. If an error occurs, \n** an SQLite error code is returned.\n*/\nstatic int fts3SegmentMerge(\n  Fts3Table *p, \n  int iLangid,                    /* Language id to merge */\n  int iIndex,                     /* Index in p->aIndex[] to merge */\n  int iLevel                      /* Level to merge */\n){\n  int rc;                         /* Return code */\n  int iIdx = 0;                   /* Index of new segment */\n  sqlite3_int64 iNewLevel = 0;    /* Level/index to create new segment at */\n  SegmentWriter *pWriter = 0;     /* Used to write the new, merged, segment */\n  Fts3SegFilter filter;           /* Segment term filter condition */\n  Fts3MultiSegReader csr;         /* Cursor to iterate through level(s) */\n  int bIgnoreEmpty = 0;           /* True to ignore empty segments */\n  i64 iMaxLevel = 0;              /* Max level number for this index/langid */\n\n  assert( iLevel==FTS3_SEGCURSOR_ALL\n       || iLevel==FTS3_SEGCURSOR_PENDING\n       || iLevel>=0\n  );\n  assert( iLevel<FTS3_SEGDIR_MAXLEVEL );\n  assert( iIndex>=0 && iIndex<p->nIndex );\n\n  rc = sqlite3Fts3SegReaderCursor(p, iLangid, iIndex, iLevel, 0, 0, 1, 0, &csr);\n  if( rc!=SQLITE_OK || csr.nSegment==0 ) goto finished;\n\n  if( iLevel!=FTS3_SEGCURSOR_PENDING ){\n    rc = fts3SegmentMaxLevel(p, iLangid, iIndex, &iMaxLevel);\n    if( rc!=SQLITE_OK ) goto finished;\n  }\n\n  if( iLevel==FTS3_SEGCURSOR_ALL ){\n    /* This call is to merge all segments in the database to a single\n    ** segment. The level of the new segment is equal to the numerically\n    ** greatest segment level currently present in the database for this\n    ** index. The idx of the new segment is always 0.  */\n    if( csr.nSegment==1 && 0==fts3SegReaderIsPending(csr.apSegment[0]) ){\n      rc = SQLITE_DONE;\n      goto finished;\n    }\n    iNewLevel = iMaxLevel;\n    bIgnoreEmpty = 1;\n\n  }else{\n    /* This call is to merge all segments at level iLevel. find the next\n    ** available segment index at level iLevel+1. The call to\n    ** fts3AllocateSegdirIdx() will merge the segments at level iLevel+1 to \n    ** a single iLevel+2 segment if necessary.  */\n    assert( FTS3_SEGCURSOR_PENDING==-1 );\n    iNewLevel = getAbsoluteLevel(p, iLangid, iIndex, iLevel+1);\n    rc = fts3AllocateSegdirIdx(p, iLangid, iIndex, iLevel+1, &iIdx);\n    bIgnoreEmpty = (iLevel!=FTS3_SEGCURSOR_PENDING) && (iNewLevel>iMaxLevel);\n  }\n  if( rc!=SQLITE_OK ) goto finished;\n\n  assert( csr.nSegment>0 );\n  assert( iNewLevel>=getAbsoluteLevel(p, iLangid, iIndex, 0) );\n  assert( iNewLevel<getAbsoluteLevel(p, iLangid, iIndex,FTS3_SEGDIR_MAXLEVEL) );\n\n  memset(&filter, 0, sizeof(Fts3SegFilter));\n  filter.flags = FTS3_SEGMENT_REQUIRE_POS;\n  filter.flags |= (bIgnoreEmpty ? FTS3_SEGMENT_IGNORE_EMPTY : 0);\n\n  rc = sqlite3Fts3SegReaderStart(p, &csr, &filter);\n  while( SQLITE_OK==rc ){\n    rc = sqlite3Fts3SegReaderStep(p, &csr);\n    if( rc!=SQLITE_ROW ) break;\n    rc = fts3SegWriterAdd(p, &pWriter, 1, \n        csr.zTerm, csr.nTerm, csr.aDoclist, csr.nDoclist);\n  }\n  if( rc!=SQLITE_OK ) goto finished;\n  assert( pWriter || bIgnoreEmpty );\n\n  if( iLevel!=FTS3_SEGCURSOR_PENDING ){\n    rc = fts3DeleteSegdir(\n        p, iLangid, iIndex, iLevel, csr.apSegment, csr.nSegment\n    );\n    if( rc!=SQLITE_OK ) goto finished;\n  }\n  if( pWriter ){\n    rc = fts3SegWriterFlush(p, pWriter, iNewLevel, iIdx);\n    if( rc==SQLITE_OK ){\n      if( iLevel==FTS3_SEGCURSOR_PENDING || iNewLevel<iMaxLevel ){\n        rc = fts3PromoteSegments(p, iNewLevel, pWriter->nLeafData);\n      }\n    }\n  }\n\n finished:\n  fts3SegWriterFree(pWriter);\n  sqlite3Fts3SegReaderFinish(&csr);\n  return rc;\n}\n\n\n/* \n** Flush the contents of pendingTerms to level 0 segments. \n*/\nSQLITE_PRIVATE int sqlite3Fts3PendingTermsFlush(Fts3Table *p){\n  int rc = SQLITE_OK;\n  int i;\n        \n  for(i=0; rc==SQLITE_OK && i<p->nIndex; i++){\n    rc = fts3SegmentMerge(p, p->iPrevLangid, i, FTS3_SEGCURSOR_PENDING);\n    if( rc==SQLITE_DONE ) rc = SQLITE_OK;\n  }\n  sqlite3Fts3PendingTermsClear(p);\n\n  /* Determine the auto-incr-merge setting if unknown.  If enabled,\n  ** estimate the number of leaf blocks of content to be written\n  */\n  if( rc==SQLITE_OK && p->bHasStat\n   && p->nAutoincrmerge==0xff && p->nLeafAdd>0\n  ){\n    sqlite3_stmt *pStmt = 0;\n    rc = fts3SqlStmt(p, SQL_SELECT_STAT, &pStmt, 0);\n    if( rc==SQLITE_OK ){\n      sqlite3_bind_int(pStmt, 1, FTS_STAT_AUTOINCRMERGE);\n      rc = sqlite3_step(pStmt);\n      if( rc==SQLITE_ROW ){\n        p->nAutoincrmerge = sqlite3_column_int(pStmt, 0);\n        if( p->nAutoincrmerge==1 ) p->nAutoincrmerge = 8;\n      }else if( rc==SQLITE_DONE ){\n        p->nAutoincrmerge = 0;\n      }\n      rc = sqlite3_reset(pStmt);\n    }\n  }\n  return rc;\n}\n\n/*\n** Encode N integers as varints into a blob.\n*/\nstatic void fts3EncodeIntArray(\n  int N,             /* The number of integers to encode */\n  u32 *a,            /* The integer values */\n  char *zBuf,        /* Write the BLOB here */\n  int *pNBuf         /* Write number of bytes if zBuf[] used here */\n){\n  int i, j;\n  for(i=j=0; i<N; i++){\n    j += sqlite3Fts3PutVarint(&zBuf[j], (sqlite3_int64)a[i]);\n  }\n  *pNBuf = j;\n}\n\n/*\n** Decode a blob of varints into N integers\n*/\nstatic void fts3DecodeIntArray(\n  int N,             /* The number of integers to decode */\n  u32 *a,            /* Write the integer values */\n  const char *zBuf,  /* The BLOB containing the varints */\n  int nBuf           /* size of the BLOB */\n){\n  int i = 0;\n  if( nBuf && (zBuf[nBuf-1]&0x80)==0 ){\n    int j;\n    for(i=j=0; i<N && j<nBuf; i++){\n      sqlite3_int64 x;\n      j += sqlite3Fts3GetVarint(&zBuf[j], &x);\n      a[i] = (u32)(x & 0xffffffff);\n    }\n  }\n  while( i<N ) a[i++] = 0;\n}\n\n/*\n** Insert the sizes (in tokens) for each column of the document\n** with docid equal to p->iPrevDocid.  The sizes are encoded as\n** a blob of varints.\n*/\nstatic void fts3InsertDocsize(\n  int *pRC,                       /* Result code */\n  Fts3Table *p,                   /* Table into which to insert */\n  u32 *aSz                        /* Sizes of each column, in tokens */\n){\n  char *pBlob;             /* The BLOB encoding of the document size */\n  int nBlob;               /* Number of bytes in the BLOB */\n  sqlite3_stmt *pStmt;     /* Statement used to insert the encoding */\n  int rc;                  /* Result code from subfunctions */\n\n  if( *pRC ) return;\n  pBlob = sqlite3_malloc( 10*p->nColumn );\n  if( pBlob==0 ){\n    *pRC = SQLITE_NOMEM;\n    return;\n  }\n  fts3EncodeIntArray(p->nColumn, aSz, pBlob, &nBlob);\n  rc = fts3SqlStmt(p, SQL_REPLACE_DOCSIZE, &pStmt, 0);\n  if( rc ){\n    sqlite3_free(pBlob);\n    *pRC = rc;\n    return;\n  }\n  sqlite3_bind_int64(pStmt, 1, p->iPrevDocid);\n  sqlite3_bind_blob(pStmt, 2, pBlob, nBlob, sqlite3_free);\n  sqlite3_step(pStmt);\n  *pRC = sqlite3_reset(pStmt);\n}\n\n/*\n** Record 0 of the %_stat table contains a blob consisting of N varints,\n** where N is the number of user defined columns in the fts3 table plus\n** two. If nCol is the number of user defined columns, then values of the \n** varints are set as follows:\n**\n**   Varint 0:       Total number of rows in the table.\n**\n**   Varint 1..nCol: For each column, the total number of tokens stored in\n**                   the column for all rows of the table.\n**\n**   Varint 1+nCol:  The total size, in bytes, of all text values in all\n**                   columns of all rows of the table.\n**\n*/\nstatic void fts3UpdateDocTotals(\n  int *pRC,                       /* The result code */\n  Fts3Table *p,                   /* Table being updated */\n  u32 *aSzIns,                    /* Size increases */\n  u32 *aSzDel,                    /* Size decreases */\n  int nChng                       /* Change in the number of documents */\n){\n  char *pBlob;             /* Storage for BLOB written into %_stat */\n  int nBlob;               /* Size of BLOB written into %_stat */\n  u32 *a;                  /* Array of integers that becomes the BLOB */\n  sqlite3_stmt *pStmt;     /* Statement for reading and writing */\n  int i;                   /* Loop counter */\n  int rc;                  /* Result code from subfunctions */\n\n  const int nStat = p->nColumn+2;\n\n  if( *pRC ) return;\n  a = sqlite3_malloc( (sizeof(u32)+10)*nStat );\n  if( a==0 ){\n    *pRC = SQLITE_NOMEM;\n    return;\n  }\n  pBlob = (char*)&a[nStat];\n  rc = fts3SqlStmt(p, SQL_SELECT_STAT, &pStmt, 0);\n  if( rc ){\n    sqlite3_free(a);\n    *pRC = rc;\n    return;\n  }\n  sqlite3_bind_int(pStmt, 1, FTS_STAT_DOCTOTAL);\n  if( sqlite3_step(pStmt)==SQLITE_ROW ){\n    fts3DecodeIntArray(nStat, a,\n         sqlite3_column_blob(pStmt, 0),\n         sqlite3_column_bytes(pStmt, 0));\n  }else{\n    memset(a, 0, sizeof(u32)*(nStat) );\n  }\n  rc = sqlite3_reset(pStmt);\n  if( rc!=SQLITE_OK ){\n    sqlite3_free(a);\n    *pRC = rc;\n    return;\n  }\n  if( nChng<0 && a[0]<(u32)(-nChng) ){\n    a[0] = 0;\n  }else{\n    a[0] += nChng;\n  }\n  for(i=0; i<p->nColumn+1; i++){\n    u32 x = a[i+1];\n    if( x+aSzIns[i] < aSzDel[i] ){\n      x = 0;\n    }else{\n      x = x + aSzIns[i] - aSzDel[i];\n    }\n    a[i+1] = x;\n  }\n  fts3EncodeIntArray(nStat, a, pBlob, &nBlob);\n  rc = fts3SqlStmt(p, SQL_REPLACE_STAT, &pStmt, 0);\n  if( rc ){\n    sqlite3_free(a);\n    *pRC = rc;\n    return;\n  }\n  sqlite3_bind_int(pStmt, 1, FTS_STAT_DOCTOTAL);\n  sqlite3_bind_blob(pStmt, 2, pBlob, nBlob, SQLITE_STATIC);\n  sqlite3_step(pStmt);\n  *pRC = sqlite3_reset(pStmt);\n  sqlite3_bind_null(pStmt, 2);\n  sqlite3_free(a);\n}\n\n/*\n** Merge the entire database so that there is one segment for each \n** iIndex/iLangid combination.\n*/\nstatic int fts3DoOptimize(Fts3Table *p, int bReturnDone){\n  int bSeenDone = 0;\n  int rc;\n  sqlite3_stmt *pAllLangid = 0;\n\n  rc = fts3SqlStmt(p, SQL_SELECT_ALL_LANGID, &pAllLangid, 0);\n  if( rc==SQLITE_OK ){\n    int rc2;\n    sqlite3_bind_int(pAllLangid, 1, p->iPrevLangid);\n    sqlite3_bind_int(pAllLangid, 2, p->nIndex);\n    while( sqlite3_step(pAllLangid)==SQLITE_ROW ){\n      int i;\n      int iLangid = sqlite3_column_int(pAllLangid, 0);\n      for(i=0; rc==SQLITE_OK && i<p->nIndex; i++){\n        rc = fts3SegmentMerge(p, iLangid, i, FTS3_SEGCURSOR_ALL);\n        if( rc==SQLITE_DONE ){\n          bSeenDone = 1;\n          rc = SQLITE_OK;\n        }\n      }\n    }\n    rc2 = sqlite3_reset(pAllLangid);\n    if( rc==SQLITE_OK ) rc = rc2;\n  }\n\n  sqlite3Fts3SegmentsClose(p);\n  sqlite3Fts3PendingTermsClear(p);\n\n  return (rc==SQLITE_OK && bReturnDone && bSeenDone) ? SQLITE_DONE : rc;\n}\n\n/*\n** This function is called when the user executes the following statement:\n**\n**     INSERT INTO <tbl>(<tbl>) VALUES('rebuild');\n**\n** The entire FTS index is discarded and rebuilt. If the table is one \n** created using the content=xxx option, then the new index is based on\n** the current contents of the xxx table. Otherwise, it is rebuilt based\n** on the contents of the %_content table.\n*/\nstatic int fts3DoRebuild(Fts3Table *p){\n  int rc;                         /* Return Code */\n\n  rc = fts3DeleteAll(p, 0);\n  if( rc==SQLITE_OK ){\n    u32 *aSz = 0;\n    u32 *aSzIns = 0;\n    u32 *aSzDel = 0;\n    sqlite3_stmt *pStmt = 0;\n    int nEntry = 0;\n\n    /* Compose and prepare an SQL statement to loop through the content table */\n    char *zSql = sqlite3_mprintf(\"SELECT %s\" , p->zReadExprlist);\n    if( !zSql ){\n      rc = SQLITE_NOMEM;\n    }else{\n      rc = sqlite3_prepare_v2(p->db, zSql, -1, &pStmt, 0);\n      sqlite3_free(zSql);\n    }\n\n    if( rc==SQLITE_OK ){\n      int nByte = sizeof(u32) * (p->nColumn+1)*3;\n      aSz = (u32 *)sqlite3_malloc(nByte);\n      if( aSz==0 ){\n        rc = SQLITE_NOMEM;\n      }else{\n        memset(aSz, 0, nByte);\n        aSzIns = &aSz[p->nColumn+1];\n        aSzDel = &aSzIns[p->nColumn+1];\n      }\n    }\n\n    while( rc==SQLITE_OK && SQLITE_ROW==sqlite3_step(pStmt) ){\n      int iCol;\n      int iLangid = langidFromSelect(p, pStmt);\n      rc = fts3PendingTermsDocid(p, 0, iLangid, sqlite3_column_int64(pStmt, 0));\n      memset(aSz, 0, sizeof(aSz[0]) * (p->nColumn+1));\n      for(iCol=0; rc==SQLITE_OK && iCol<p->nColumn; iCol++){\n        if( p->abNotindexed[iCol]==0 ){\n          const char *z = (const char *) sqlite3_column_text(pStmt, iCol+1);\n          rc = fts3PendingTermsAdd(p, iLangid, z, iCol, &aSz[iCol]);\n          aSz[p->nColumn] += sqlite3_column_bytes(pStmt, iCol+1);\n        }\n      }\n      if( p->bHasDocsize ){\n        fts3InsertDocsize(&rc, p, aSz);\n      }\n      if( rc!=SQLITE_OK ){\n        sqlite3_finalize(pStmt);\n        pStmt = 0;\n      }else{\n        nEntry++;\n        for(iCol=0; iCol<=p->nColumn; iCol++){\n          aSzIns[iCol] += aSz[iCol];\n        }\n      }\n    }\n    if( p->bFts4 ){\n      fts3UpdateDocTotals(&rc, p, aSzIns, aSzDel, nEntry);\n    }\n    sqlite3_free(aSz);\n\n    if( pStmt ){\n      int rc2 = sqlite3_finalize(pStmt);\n      if( rc==SQLITE_OK ){\n        rc = rc2;\n      }\n    }\n  }\n\n  return rc;\n}\n\n\n/*\n** This function opens a cursor used to read the input data for an \n** incremental merge operation. Specifically, it opens a cursor to scan\n** the oldest nSeg segments (idx=0 through idx=(nSeg-1)) in absolute \n** level iAbsLevel.\n*/\nstatic int fts3IncrmergeCsr(\n  Fts3Table *p,                   /* FTS3 table handle */\n  sqlite3_int64 iAbsLevel,        /* Absolute level to open */\n  int nSeg,                       /* Number of segments to merge */\n  Fts3MultiSegReader *pCsr        /* Cursor object to populate */\n){\n  int rc;                         /* Return Code */\n  sqlite3_stmt *pStmt = 0;        /* Statement used to read %_segdir entry */  \n  int nByte;                      /* Bytes allocated at pCsr->apSegment[] */\n\n  /* Allocate space for the Fts3MultiSegReader.aCsr[] array */\n  memset(pCsr, 0, sizeof(*pCsr));\n  nByte = sizeof(Fts3SegReader *) * nSeg;\n  pCsr->apSegment = (Fts3SegReader **)sqlite3_malloc(nByte);\n\n  if( pCsr->apSegment==0 ){\n    rc = SQLITE_NOMEM;\n  }else{\n    memset(pCsr->apSegment, 0, nByte);\n    rc = fts3SqlStmt(p, SQL_SELECT_LEVEL, &pStmt, 0);\n  }\n  if( rc==SQLITE_OK ){\n    int i;\n    int rc2;\n    sqlite3_bind_int64(pStmt, 1, iAbsLevel);\n    assert( pCsr->nSegment==0 );\n    for(i=0; rc==SQLITE_OK && sqlite3_step(pStmt)==SQLITE_ROW && i<nSeg; i++){\n      rc = sqlite3Fts3SegReaderNew(i, 0,\n          sqlite3_column_int64(pStmt, 1),        /* segdir.start_block */\n          sqlite3_column_int64(pStmt, 2),        /* segdir.leaves_end_block */\n          sqlite3_column_int64(pStmt, 3),        /* segdir.end_block */\n          sqlite3_column_blob(pStmt, 4),         /* segdir.root */\n          sqlite3_column_bytes(pStmt, 4),        /* segdir.root */\n          &pCsr->apSegment[i]\n      );\n      pCsr->nSegment++;\n    }\n    rc2 = sqlite3_reset(pStmt);\n    if( rc==SQLITE_OK ) rc = rc2;\n  }\n\n  return rc;\n}\n\ntypedef struct IncrmergeWriter IncrmergeWriter;\ntypedef struct NodeWriter NodeWriter;\ntypedef struct Blob Blob;\ntypedef struct NodeReader NodeReader;\n\n/*\n** An instance of the following structure is used as a dynamic buffer\n** to build up nodes or other blobs of data in.\n**\n** The function blobGrowBuffer() is used to extend the allocation.\n*/\nstruct Blob {\n  char *a;                        /* Pointer to allocation */\n  int n;                          /* Number of valid bytes of data in a[] */\n  int nAlloc;                     /* Allocated size of a[] (nAlloc>=n) */\n};\n\n/*\n** This structure is used to build up buffers containing segment b-tree \n** nodes (blocks).\n*/\nstruct NodeWriter {\n  sqlite3_int64 iBlock;           /* Current block id */\n  Blob key;                       /* Last key written to the current block */\n  Blob block;                     /* Current block image */\n};\n\n/*\n** An object of this type contains the state required to create or append\n** to an appendable b-tree segment.\n*/\nstruct IncrmergeWriter {\n  int nLeafEst;                   /* Space allocated for leaf blocks */\n  int nWork;                      /* Number of leaf pages flushed */\n  sqlite3_int64 iAbsLevel;        /* Absolute level of input segments */\n  int iIdx;                       /* Index of *output* segment in iAbsLevel+1 */\n  sqlite3_int64 iStart;           /* Block number of first allocated block */\n  sqlite3_int64 iEnd;             /* Block number of last allocated block */\n  sqlite3_int64 nLeafData;        /* Bytes of leaf page data so far */\n  u8 bNoLeafData;                 /* If true, store 0 for segment size */\n  NodeWriter aNodeWriter[FTS_MAX_APPENDABLE_HEIGHT];\n};\n\n/*\n** An object of the following type is used to read data from a single\n** FTS segment node. See the following functions:\n**\n**     nodeReaderInit()\n**     nodeReaderNext()\n**     nodeReaderRelease()\n*/\nstruct NodeReader {\n  const char *aNode;\n  int nNode;\n  int iOff;                       /* Current offset within aNode[] */\n\n  /* Output variables. Containing the current node entry. */\n  sqlite3_int64 iChild;           /* Pointer to child node */\n  Blob term;                      /* Current term */\n  const char *aDoclist;           /* Pointer to doclist */\n  int nDoclist;                   /* Size of doclist in bytes */\n};\n\n/*\n** If *pRc is not SQLITE_OK when this function is called, it is a no-op.\n** Otherwise, if the allocation at pBlob->a is not already at least nMin\n** bytes in size, extend (realloc) it to be so.\n**\n** If an OOM error occurs, set *pRc to SQLITE_NOMEM and leave pBlob->a\n** unmodified. Otherwise, if the allocation succeeds, update pBlob->nAlloc\n** to reflect the new size of the pBlob->a[] buffer.\n*/\nstatic void blobGrowBuffer(Blob *pBlob, int nMin, int *pRc){\n  if( *pRc==SQLITE_OK && nMin>pBlob->nAlloc ){\n    int nAlloc = nMin;\n    char *a = (char *)sqlite3_realloc(pBlob->a, nAlloc);\n    if( a ){\n      pBlob->nAlloc = nAlloc;\n      pBlob->a = a;\n    }else{\n      *pRc = SQLITE_NOMEM;\n    }\n  }\n}\n\n/*\n** Attempt to advance the node-reader object passed as the first argument to\n** the next entry on the node. \n**\n** Return an error code if an error occurs (SQLITE_NOMEM is possible). \n** Otherwise return SQLITE_OK. If there is no next entry on the node\n** (e.g. because the current entry is the last) set NodeReader->aNode to\n** NULL to indicate EOF. Otherwise, populate the NodeReader structure output \n** variables for the new entry.\n*/\nstatic int nodeReaderNext(NodeReader *p){\n  int bFirst = (p->term.n==0);    /* True for first term on the node */\n  int nPrefix = 0;                /* Bytes to copy from previous term */\n  int nSuffix = 0;                /* Bytes to append to the prefix */\n  int rc = SQLITE_OK;             /* Return code */\n\n  assert( p->aNode );\n  if( p->iChild && bFirst==0 ) p->iChild++;\n  if( p->iOff>=p->nNode ){\n    /* EOF */\n    p->aNode = 0;\n  }else{\n    if( bFirst==0 ){\n      p->iOff += fts3GetVarint32(&p->aNode[p->iOff], &nPrefix);\n    }\n    p->iOff += fts3GetVarint32(&p->aNode[p->iOff], &nSuffix);\n\n    if( nPrefix>p->iOff || nSuffix>p->nNode-p->iOff ){\n      return FTS_CORRUPT_VTAB;\n    }\n    blobGrowBuffer(&p->term, nPrefix+nSuffix, &rc);\n    if( rc==SQLITE_OK ){\n      memcpy(&p->term.a[nPrefix], &p->aNode[p->iOff], nSuffix);\n      p->term.n = nPrefix+nSuffix;\n      p->iOff += nSuffix;\n      if( p->iChild==0 ){\n        p->iOff += fts3GetVarint32(&p->aNode[p->iOff], &p->nDoclist);\n        if( (p->nNode-p->iOff)<p->nDoclist ){\n          return FTS_CORRUPT_VTAB;\n        }\n        p->aDoclist = &p->aNode[p->iOff];\n        p->iOff += p->nDoclist;\n      }\n    }\n  }\n\n  assert( p->iOff<=p->nNode );\n  return rc;\n}\n\n/*\n** Release all dynamic resources held by node-reader object *p.\n*/\nstatic void nodeReaderRelease(NodeReader *p){\n  sqlite3_free(p->term.a);\n}\n\n/*\n** Initialize a node-reader object to read the node in buffer aNode/nNode.\n**\n** If successful, SQLITE_OK is returned and the NodeReader object set to \n** point to the first entry on the node (if any). Otherwise, an SQLite\n** error code is returned.\n*/\nstatic int nodeReaderInit(NodeReader *p, const char *aNode, int nNode){\n  memset(p, 0, sizeof(NodeReader));\n  p->aNode = aNode;\n  p->nNode = nNode;\n\n  /* Figure out if this is a leaf or an internal node. */\n  if( p->aNode[0] ){\n    /* An internal node. */\n    p->iOff = 1 + sqlite3Fts3GetVarint(&p->aNode[1], &p->iChild);\n  }else{\n    p->iOff = 1;\n  }\n\n  return nodeReaderNext(p);\n}\n\n/*\n** This function is called while writing an FTS segment each time a leaf o\n** node is finished and written to disk. The key (zTerm/nTerm) is guaranteed\n** to be greater than the largest key on the node just written, but smaller\n** than or equal to the first key that will be written to the next leaf\n** node.\n**\n** The block id of the leaf node just written to disk may be found in\n** (pWriter->aNodeWriter[0].iBlock) when this function is called.\n*/\nstatic int fts3IncrmergePush(\n  Fts3Table *p,                   /* Fts3 table handle */\n  IncrmergeWriter *pWriter,       /* Writer object */\n  const char *zTerm,              /* Term to write to internal node */\n  int nTerm                       /* Bytes at zTerm */\n){\n  sqlite3_int64 iPtr = pWriter->aNodeWriter[0].iBlock;\n  int iLayer;\n\n  assert( nTerm>0 );\n  for(iLayer=1; ALWAYS(iLayer<FTS_MAX_APPENDABLE_HEIGHT); iLayer++){\n    sqlite3_int64 iNextPtr = 0;\n    NodeWriter *pNode = &pWriter->aNodeWriter[iLayer];\n    int rc = SQLITE_OK;\n    int nPrefix;\n    int nSuffix;\n    int nSpace;\n\n    /* Figure out how much space the key will consume if it is written to\n    ** the current node of layer iLayer. Due to the prefix compression, \n    ** the space required changes depending on which node the key is to\n    ** be added to.  */\n    nPrefix = fts3PrefixCompress(pNode->key.a, pNode->key.n, zTerm, nTerm);\n    nSuffix = nTerm - nPrefix;\n    nSpace  = sqlite3Fts3VarintLen(nPrefix);\n    nSpace += sqlite3Fts3VarintLen(nSuffix) + nSuffix;\n\n    if( pNode->key.n==0 || (pNode->block.n + nSpace)<=p->nNodeSize ){ \n      /* If the current node of layer iLayer contains zero keys, or if adding\n      ** the key to it will not cause it to grow to larger than nNodeSize \n      ** bytes in size, write the key here.  */\n\n      Blob *pBlk = &pNode->block;\n      if( pBlk->n==0 ){\n        blobGrowBuffer(pBlk, p->nNodeSize, &rc);\n        if( rc==SQLITE_OK ){\n          pBlk->a[0] = (char)iLayer;\n          pBlk->n = 1 + sqlite3Fts3PutVarint(&pBlk->a[1], iPtr);\n        }\n      }\n      blobGrowBuffer(pBlk, pBlk->n + nSpace, &rc);\n      blobGrowBuffer(&pNode->key, nTerm, &rc);\n\n      if( rc==SQLITE_OK ){\n        if( pNode->key.n ){\n          pBlk->n += sqlite3Fts3PutVarint(&pBlk->a[pBlk->n], nPrefix);\n        }\n        pBlk->n += sqlite3Fts3PutVarint(&pBlk->a[pBlk->n], nSuffix);\n        memcpy(&pBlk->a[pBlk->n], &zTerm[nPrefix], nSuffix);\n        pBlk->n += nSuffix;\n\n        memcpy(pNode->key.a, zTerm, nTerm);\n        pNode->key.n = nTerm;\n      }\n    }else{\n      /* Otherwise, flush the current node of layer iLayer to disk.\n      ** Then allocate a new, empty sibling node. The key will be written\n      ** into the parent of this node. */\n      rc = fts3WriteSegment(p, pNode->iBlock, pNode->block.a, pNode->block.n);\n\n      assert( pNode->block.nAlloc>=p->nNodeSize );\n      pNode->block.a[0] = (char)iLayer;\n      pNode->block.n = 1 + sqlite3Fts3PutVarint(&pNode->block.a[1], iPtr+1);\n\n      iNextPtr = pNode->iBlock;\n      pNode->iBlock++;\n      pNode->key.n = 0;\n    }\n\n    if( rc!=SQLITE_OK || iNextPtr==0 ) return rc;\n    iPtr = iNextPtr;\n  }\n\n  assert( 0 );\n  return 0;\n}\n\n/*\n** Append a term and (optionally) doclist to the FTS segment node currently\n** stored in blob *pNode. The node need not contain any terms, but the\n** header must be written before this function is called.\n**\n** A node header is a single 0x00 byte for a leaf node, or a height varint\n** followed by the left-hand-child varint for an internal node.\n**\n** The term to be appended is passed via arguments zTerm/nTerm. For a \n** leaf node, the doclist is passed as aDoclist/nDoclist. For an internal\n** node, both aDoclist and nDoclist must be passed 0.\n**\n** If the size of the value in blob pPrev is zero, then this is the first\n** term written to the node. Otherwise, pPrev contains a copy of the \n** previous term. Before this function returns, it is updated to contain a\n** copy of zTerm/nTerm.\n**\n** It is assumed that the buffer associated with pNode is already large\n** enough to accommodate the new entry. The buffer associated with pPrev\n** is extended by this function if requrired.\n**\n** If an error (i.e. OOM condition) occurs, an SQLite error code is\n** returned. Otherwise, SQLITE_OK.\n*/\nstatic int fts3AppendToNode(\n  Blob *pNode,                    /* Current node image to append to */\n  Blob *pPrev,                    /* Buffer containing previous term written */\n  const char *zTerm,              /* New term to write */\n  int nTerm,                      /* Size of zTerm in bytes */\n  const char *aDoclist,           /* Doclist (or NULL) to write */\n  int nDoclist                    /* Size of aDoclist in bytes */ \n){\n  int rc = SQLITE_OK;             /* Return code */\n  int bFirst = (pPrev->n==0);     /* True if this is the first term written */\n  int nPrefix;                    /* Size of term prefix in bytes */\n  int nSuffix;                    /* Size of term suffix in bytes */\n\n  /* Node must have already been started. There must be a doclist for a\n  ** leaf node, and there must not be a doclist for an internal node.  */\n  assert( pNode->n>0 );\n  assert( (pNode->a[0]=='\\0')==(aDoclist!=0) );\n\n  blobGrowBuffer(pPrev, nTerm, &rc);\n  if( rc!=SQLITE_OK ) return rc;\n\n  nPrefix = fts3PrefixCompress(pPrev->a, pPrev->n, zTerm, nTerm);\n  nSuffix = nTerm - nPrefix;\n  memcpy(pPrev->a, zTerm, nTerm);\n  pPrev->n = nTerm;\n\n  if( bFirst==0 ){\n    pNode->n += sqlite3Fts3PutVarint(&pNode->a[pNode->n], nPrefix);\n  }\n  pNode->n += sqlite3Fts3PutVarint(&pNode->a[pNode->n], nSuffix);\n  memcpy(&pNode->a[pNode->n], &zTerm[nPrefix], nSuffix);\n  pNode->n += nSuffix;\n\n  if( aDoclist ){\n    pNode->n += sqlite3Fts3PutVarint(&pNode->a[pNode->n], nDoclist);\n    memcpy(&pNode->a[pNode->n], aDoclist, nDoclist);\n    pNode->n += nDoclist;\n  }\n\n  assert( pNode->n<=pNode->nAlloc );\n\n  return SQLITE_OK;\n}\n\n/*\n** Append the current term and doclist pointed to by cursor pCsr to the\n** appendable b-tree segment opened for writing by pWriter.\n**\n** Return SQLITE_OK if successful, or an SQLite error code otherwise.\n*/\nstatic int fts3IncrmergeAppend(\n  Fts3Table *p,                   /* Fts3 table handle */\n  IncrmergeWriter *pWriter,       /* Writer object */\n  Fts3MultiSegReader *pCsr        /* Cursor containing term and doclist */\n){\n  const char *zTerm = pCsr->zTerm;\n  int nTerm = pCsr->nTerm;\n  const char *aDoclist = pCsr->aDoclist;\n  int nDoclist = pCsr->nDoclist;\n  int rc = SQLITE_OK;           /* Return code */\n  int nSpace;                   /* Total space in bytes required on leaf */\n  int nPrefix;                  /* Size of prefix shared with previous term */\n  int nSuffix;                  /* Size of suffix (nTerm - nPrefix) */\n  NodeWriter *pLeaf;            /* Object used to write leaf nodes */\n\n  pLeaf = &pWriter->aNodeWriter[0];\n  nPrefix = fts3PrefixCompress(pLeaf->key.a, pLeaf->key.n, zTerm, nTerm);\n  nSuffix = nTerm - nPrefix;\n\n  nSpace  = sqlite3Fts3VarintLen(nPrefix);\n  nSpace += sqlite3Fts3VarintLen(nSuffix) + nSuffix;\n  nSpace += sqlite3Fts3VarintLen(nDoclist) + nDoclist;\n\n  /* If the current block is not empty, and if adding this term/doclist\n  ** to the current block would make it larger than Fts3Table.nNodeSize\n  ** bytes, write this block out to the database. */\n  if( pLeaf->block.n>0 && (pLeaf->block.n + nSpace)>p->nNodeSize ){\n    rc = fts3WriteSegment(p, pLeaf->iBlock, pLeaf->block.a, pLeaf->block.n);\n    pWriter->nWork++;\n\n    /* Add the current term to the parent node. The term added to the \n    ** parent must:\n    **\n    **   a) be greater than the largest term on the leaf node just written\n    **      to the database (still available in pLeaf->key), and\n    **\n    **   b) be less than or equal to the term about to be added to the new\n    **      leaf node (zTerm/nTerm).\n    **\n    ** In other words, it must be the prefix of zTerm 1 byte longer than\n    ** the common prefix (if any) of zTerm and pWriter->zTerm.\n    */\n    if( rc==SQLITE_OK ){\n      rc = fts3IncrmergePush(p, pWriter, zTerm, nPrefix+1);\n    }\n\n    /* Advance to the next output block */\n    pLeaf->iBlock++;\n    pLeaf->key.n = 0;\n    pLeaf->block.n = 0;\n\n    nSuffix = nTerm;\n    nSpace  = 1;\n    nSpace += sqlite3Fts3VarintLen(nSuffix) + nSuffix;\n    nSpace += sqlite3Fts3VarintLen(nDoclist) + nDoclist;\n  }\n\n  pWriter->nLeafData += nSpace;\n  blobGrowBuffer(&pLeaf->block, pLeaf->block.n + nSpace, &rc);\n  if( rc==SQLITE_OK ){\n    if( pLeaf->block.n==0 ){\n      pLeaf->block.n = 1;\n      pLeaf->block.a[0] = '\\0';\n    }\n    rc = fts3AppendToNode(\n        &pLeaf->block, &pLeaf->key, zTerm, nTerm, aDoclist, nDoclist\n    );\n  }\n\n  return rc;\n}\n\n/*\n** This function is called to release all dynamic resources held by the\n** merge-writer object pWriter, and if no error has occurred, to flush\n** all outstanding node buffers held by pWriter to disk.\n**\n** If *pRc is not SQLITE_OK when this function is called, then no attempt\n** is made to write any data to disk. Instead, this function serves only\n** to release outstanding resources.\n**\n** Otherwise, if *pRc is initially SQLITE_OK and an error occurs while\n** flushing buffers to disk, *pRc is set to an SQLite error code before\n** returning.\n*/\nstatic void fts3IncrmergeRelease(\n  Fts3Table *p,                   /* FTS3 table handle */\n  IncrmergeWriter *pWriter,       /* Merge-writer object */\n  int *pRc                        /* IN/OUT: Error code */\n){\n  int i;                          /* Used to iterate through non-root layers */\n  int iRoot;                      /* Index of root in pWriter->aNodeWriter */\n  NodeWriter *pRoot;              /* NodeWriter for root node */\n  int rc = *pRc;                  /* Error code */\n\n  /* Set iRoot to the index in pWriter->aNodeWriter[] of the output segment \n  ** root node. If the segment fits entirely on a single leaf node, iRoot\n  ** will be set to 0. If the root node is the parent of the leaves, iRoot\n  ** will be 1. And so on.  */\n  for(iRoot=FTS_MAX_APPENDABLE_HEIGHT-1; iRoot>=0; iRoot--){\n    NodeWriter *pNode = &pWriter->aNodeWriter[iRoot];\n    if( pNode->block.n>0 ) break;\n    assert( *pRc || pNode->block.nAlloc==0 );\n    assert( *pRc || pNode->key.nAlloc==0 );\n    sqlite3_free(pNode->block.a);\n    sqlite3_free(pNode->key.a);\n  }\n\n  /* Empty output segment. This is a no-op. */\n  if( iRoot<0 ) return;\n\n  /* The entire output segment fits on a single node. Normally, this means\n  ** the node would be stored as a blob in the \"root\" column of the %_segdir\n  ** table. However, this is not permitted in this case. The problem is that \n  ** space has already been reserved in the %_segments table, and so the \n  ** start_block and end_block fields of the %_segdir table must be populated. \n  ** And, by design or by accident, released versions of FTS cannot handle \n  ** segments that fit entirely on the root node with start_block!=0.\n  **\n  ** Instead, create a synthetic root node that contains nothing but a \n  ** pointer to the single content node. So that the segment consists of a\n  ** single leaf and a single interior (root) node.\n  **\n  ** Todo: Better might be to defer allocating space in the %_segments \n  ** table until we are sure it is needed.\n  */\n  if( iRoot==0 ){\n    Blob *pBlock = &pWriter->aNodeWriter[1].block;\n    blobGrowBuffer(pBlock, 1 + FTS3_VARINT_MAX, &rc);\n    if( rc==SQLITE_OK ){\n      pBlock->a[0] = 0x01;\n      pBlock->n = 1 + sqlite3Fts3PutVarint(\n          &pBlock->a[1], pWriter->aNodeWriter[0].iBlock\n      );\n    }\n    iRoot = 1;\n  }\n  pRoot = &pWriter->aNodeWriter[iRoot];\n\n  /* Flush all currently outstanding nodes to disk. */\n  for(i=0; i<iRoot; i++){\n    NodeWriter *pNode = &pWriter->aNodeWriter[i];\n    if( pNode->block.n>0 && rc==SQLITE_OK ){\n      rc = fts3WriteSegment(p, pNode->iBlock, pNode->block.a, pNode->block.n);\n    }\n    sqlite3_free(pNode->block.a);\n    sqlite3_free(pNode->key.a);\n  }\n\n  /* Write the %_segdir record. */\n  if( rc==SQLITE_OK ){\n    rc = fts3WriteSegdir(p, \n        pWriter->iAbsLevel+1,               /* level */\n        pWriter->iIdx,                      /* idx */\n        pWriter->iStart,                    /* start_block */\n        pWriter->aNodeWriter[0].iBlock,     /* leaves_end_block */\n        pWriter->iEnd,                      /* end_block */\n        (pWriter->bNoLeafData==0 ? pWriter->nLeafData : 0),   /* end_block */\n        pRoot->block.a, pRoot->block.n      /* root */\n    );\n  }\n  sqlite3_free(pRoot->block.a);\n  sqlite3_free(pRoot->key.a);\n\n  *pRc = rc;\n}\n\n/*\n** Compare the term in buffer zLhs (size in bytes nLhs) with that in\n** zRhs (size in bytes nRhs) using memcmp. If one term is a prefix of\n** the other, it is considered to be smaller than the other.\n**\n** Return -ve if zLhs is smaller than zRhs, 0 if it is equal, or +ve\n** if it is greater.\n*/\nstatic int fts3TermCmp(\n  const char *zLhs, int nLhs,     /* LHS of comparison */\n  const char *zRhs, int nRhs      /* RHS of comparison */\n){\n  int nCmp = MIN(nLhs, nRhs);\n  int res;\n\n  res = memcmp(zLhs, zRhs, nCmp);\n  if( res==0 ) res = nLhs - nRhs;\n\n  return res;\n}\n\n\n/*\n** Query to see if the entry in the %_segments table with blockid iEnd is \n** NULL. If no error occurs and the entry is NULL, set *pbRes 1 before\n** returning. Otherwise, set *pbRes to 0. \n**\n** Or, if an error occurs while querying the database, return an SQLite \n** error code. The final value of *pbRes is undefined in this case.\n**\n** This is used to test if a segment is an \"appendable\" segment. If it\n** is, then a NULL entry has been inserted into the %_segments table\n** with blockid %_segdir.end_block.\n*/\nstatic int fts3IsAppendable(Fts3Table *p, sqlite3_int64 iEnd, int *pbRes){\n  int bRes = 0;                   /* Result to set *pbRes to */\n  sqlite3_stmt *pCheck = 0;       /* Statement to query database with */\n  int rc;                         /* Return code */\n\n  rc = fts3SqlStmt(p, SQL_SEGMENT_IS_APPENDABLE, &pCheck, 0);\n  if( rc==SQLITE_OK ){\n    sqlite3_bind_int64(pCheck, 1, iEnd);\n    if( SQLITE_ROW==sqlite3_step(pCheck) ) bRes = 1;\n    rc = sqlite3_reset(pCheck);\n  }\n  \n  *pbRes = bRes;\n  return rc;\n}\n\n/*\n** This function is called when initializing an incremental-merge operation.\n** It checks if the existing segment with index value iIdx at absolute level \n** (iAbsLevel+1) can be appended to by the incremental merge. If it can, the\n** merge-writer object *pWriter is initialized to write to it.\n**\n** An existing segment can be appended to by an incremental merge if:\n**\n**   * It was initially created as an appendable segment (with all required\n**     space pre-allocated), and\n**\n**   * The first key read from the input (arguments zKey and nKey) is \n**     greater than the largest key currently stored in the potential\n**     output segment.\n*/\nstatic int fts3IncrmergeLoad(\n  Fts3Table *p,                   /* Fts3 table handle */\n  sqlite3_int64 iAbsLevel,        /* Absolute level of input segments */\n  int iIdx,                       /* Index of candidate output segment */\n  const char *zKey,               /* First key to write */\n  int nKey,                       /* Number of bytes in nKey */\n  IncrmergeWriter *pWriter        /* Populate this object */\n){\n  int rc;                         /* Return code */\n  sqlite3_stmt *pSelect = 0;      /* SELECT to read %_segdir entry */\n\n  rc = fts3SqlStmt(p, SQL_SELECT_SEGDIR, &pSelect, 0);\n  if( rc==SQLITE_OK ){\n    sqlite3_int64 iStart = 0;     /* Value of %_segdir.start_block */\n    sqlite3_int64 iLeafEnd = 0;   /* Value of %_segdir.leaves_end_block */\n    sqlite3_int64 iEnd = 0;       /* Value of %_segdir.end_block */\n    const char *aRoot = 0;        /* Pointer to %_segdir.root buffer */\n    int nRoot = 0;                /* Size of aRoot[] in bytes */\n    int rc2;                      /* Return code from sqlite3_reset() */\n    int bAppendable = 0;          /* Set to true if segment is appendable */\n\n    /* Read the %_segdir entry for index iIdx absolute level (iAbsLevel+1) */\n    sqlite3_bind_int64(pSelect, 1, iAbsLevel+1);\n    sqlite3_bind_int(pSelect, 2, iIdx);\n    if( sqlite3_step(pSelect)==SQLITE_ROW ){\n      iStart = sqlite3_column_int64(pSelect, 1);\n      iLeafEnd = sqlite3_column_int64(pSelect, 2);\n      fts3ReadEndBlockField(pSelect, 3, &iEnd, &pWriter->nLeafData);\n      if( pWriter->nLeafData<0 ){\n        pWriter->nLeafData = pWriter->nLeafData * -1;\n      }\n      pWriter->bNoLeafData = (pWriter->nLeafData==0);\n      nRoot = sqlite3_column_bytes(pSelect, 4);\n      aRoot = sqlite3_column_blob(pSelect, 4);\n    }else{\n      return sqlite3_reset(pSelect);\n    }\n\n    /* Check for the zero-length marker in the %_segments table */\n    rc = fts3IsAppendable(p, iEnd, &bAppendable);\n\n    /* Check that zKey/nKey is larger than the largest key the candidate */\n    if( rc==SQLITE_OK && bAppendable ){\n      char *aLeaf = 0;\n      int nLeaf = 0;\n\n      rc = sqlite3Fts3ReadBlock(p, iLeafEnd, &aLeaf, &nLeaf, 0);\n      if( rc==SQLITE_OK ){\n        NodeReader reader;\n        for(rc = nodeReaderInit(&reader, aLeaf, nLeaf);\n            rc==SQLITE_OK && reader.aNode;\n            rc = nodeReaderNext(&reader)\n        ){\n          assert( reader.aNode );\n        }\n        if( fts3TermCmp(zKey, nKey, reader.term.a, reader.term.n)<=0 ){\n          bAppendable = 0;\n        }\n        nodeReaderRelease(&reader);\n      }\n      sqlite3_free(aLeaf);\n    }\n\n    if( rc==SQLITE_OK && bAppendable ){\n      /* It is possible to append to this segment. Set up the IncrmergeWriter\n      ** object to do so.  */\n      int i;\n      int nHeight = (int)aRoot[0];\n      NodeWriter *pNode;\n\n      pWriter->nLeafEst = (int)((iEnd - iStart) + 1)/FTS_MAX_APPENDABLE_HEIGHT;\n      pWriter->iStart = iStart;\n      pWriter->iEnd = iEnd;\n      pWriter->iAbsLevel = iAbsLevel;\n      pWriter->iIdx = iIdx;\n\n      for(i=nHeight+1; i<FTS_MAX_APPENDABLE_HEIGHT; i++){\n        pWriter->aNodeWriter[i].iBlock = pWriter->iStart + i*pWriter->nLeafEst;\n      }\n\n      pNode = &pWriter->aNodeWriter[nHeight];\n      pNode->iBlock = pWriter->iStart + pWriter->nLeafEst*nHeight;\n      blobGrowBuffer(&pNode->block, MAX(nRoot, p->nNodeSize), &rc);\n      if( rc==SQLITE_OK ){\n        memcpy(pNode->block.a, aRoot, nRoot);\n        pNode->block.n = nRoot;\n      }\n\n      for(i=nHeight; i>=0 && rc==SQLITE_OK; i--){\n        NodeReader reader;\n        pNode = &pWriter->aNodeWriter[i];\n\n        rc = nodeReaderInit(&reader, pNode->block.a, pNode->block.n);\n        while( reader.aNode && rc==SQLITE_OK ) rc = nodeReaderNext(&reader);\n        blobGrowBuffer(&pNode->key, reader.term.n, &rc);\n        if( rc==SQLITE_OK ){\n          memcpy(pNode->key.a, reader.term.a, reader.term.n);\n          pNode->key.n = reader.term.n;\n          if( i>0 ){\n            char *aBlock = 0;\n            int nBlock = 0;\n            pNode = &pWriter->aNodeWriter[i-1];\n            pNode->iBlock = reader.iChild;\n            rc = sqlite3Fts3ReadBlock(p, reader.iChild, &aBlock, &nBlock, 0);\n            blobGrowBuffer(&pNode->block, MAX(nBlock, p->nNodeSize), &rc);\n            if( rc==SQLITE_OK ){\n              memcpy(pNode->block.a, aBlock, nBlock);\n              pNode->block.n = nBlock;\n            }\n            sqlite3_free(aBlock);\n          }\n        }\n        nodeReaderRelease(&reader);\n      }\n    }\n\n    rc2 = sqlite3_reset(pSelect);\n    if( rc==SQLITE_OK ) rc = rc2;\n  }\n\n  return rc;\n}\n\n/*\n** Determine the largest segment index value that exists within absolute\n** level iAbsLevel+1. If no error occurs, set *piIdx to this value plus\n** one before returning SQLITE_OK. Or, if there are no segments at all \n** within level iAbsLevel, set *piIdx to zero.\n**\n** If an error occurs, return an SQLite error code. The final value of\n** *piIdx is undefined in this case.\n*/\nstatic int fts3IncrmergeOutputIdx( \n  Fts3Table *p,                   /* FTS Table handle */\n  sqlite3_int64 iAbsLevel,        /* Absolute index of input segments */\n  int *piIdx                      /* OUT: Next free index at iAbsLevel+1 */\n){\n  int rc;\n  sqlite3_stmt *pOutputIdx = 0;   /* SQL used to find output index */\n\n  rc = fts3SqlStmt(p, SQL_NEXT_SEGMENT_INDEX, &pOutputIdx, 0);\n  if( rc==SQLITE_OK ){\n    sqlite3_bind_int64(pOutputIdx, 1, iAbsLevel+1);\n    sqlite3_step(pOutputIdx);\n    *piIdx = sqlite3_column_int(pOutputIdx, 0);\n    rc = sqlite3_reset(pOutputIdx);\n  }\n\n  return rc;\n}\n\n/* \n** Allocate an appendable output segment on absolute level iAbsLevel+1\n** with idx value iIdx.\n**\n** In the %_segdir table, a segment is defined by the values in three\n** columns:\n**\n**     start_block\n**     leaves_end_block\n**     end_block\n**\n** When an appendable segment is allocated, it is estimated that the\n** maximum number of leaf blocks that may be required is the sum of the\n** number of leaf blocks consumed by the input segments, plus the number\n** of input segments, multiplied by two. This value is stored in stack \n** variable nLeafEst.\n**\n** A total of 16*nLeafEst blocks are allocated when an appendable segment\n** is created ((1 + end_block - start_block)==16*nLeafEst). The contiguous\n** array of leaf nodes starts at the first block allocated. The array\n** of interior nodes that are parents of the leaf nodes start at block\n** (start_block + (1 + end_block - start_block) / 16). And so on.\n**\n** In the actual code below, the value \"16\" is replaced with the \n** pre-processor macro FTS_MAX_APPENDABLE_HEIGHT.\n*/\nstatic int fts3IncrmergeWriter( \n  Fts3Table *p,                   /* Fts3 table handle */\n  sqlite3_int64 iAbsLevel,        /* Absolute level of input segments */\n  int iIdx,                       /* Index of new output segment */\n  Fts3MultiSegReader *pCsr,       /* Cursor that data will be read from */\n  IncrmergeWriter *pWriter        /* Populate this object */\n){\n  int rc;                         /* Return Code */\n  int i;                          /* Iterator variable */\n  int nLeafEst = 0;               /* Blocks allocated for leaf nodes */\n  sqlite3_stmt *pLeafEst = 0;     /* SQL used to determine nLeafEst */\n  sqlite3_stmt *pFirstBlock = 0;  /* SQL used to determine first block */\n\n  /* Calculate nLeafEst. */\n  rc = fts3SqlStmt(p, SQL_MAX_LEAF_NODE_ESTIMATE, &pLeafEst, 0);\n  if( rc==SQLITE_OK ){\n    sqlite3_bind_int64(pLeafEst, 1, iAbsLevel);\n    sqlite3_bind_int64(pLeafEst, 2, pCsr->nSegment);\n    if( SQLITE_ROW==sqlite3_step(pLeafEst) ){\n      nLeafEst = sqlite3_column_int(pLeafEst, 0);\n    }\n    rc = sqlite3_reset(pLeafEst);\n  }\n  if( rc!=SQLITE_OK ) return rc;\n\n  /* Calculate the first block to use in the output segment */\n  rc = fts3SqlStmt(p, SQL_NEXT_SEGMENTS_ID, &pFirstBlock, 0);\n  if( rc==SQLITE_OK ){\n    if( SQLITE_ROW==sqlite3_step(pFirstBlock) ){\n      pWriter->iStart = sqlite3_column_int64(pFirstBlock, 0);\n      pWriter->iEnd = pWriter->iStart - 1;\n      pWriter->iEnd += nLeafEst * FTS_MAX_APPENDABLE_HEIGHT;\n    }\n    rc = sqlite3_reset(pFirstBlock);\n  }\n  if( rc!=SQLITE_OK ) return rc;\n\n  /* Insert the marker in the %_segments table to make sure nobody tries\n  ** to steal the space just allocated. This is also used to identify \n  ** appendable segments.  */\n  rc = fts3WriteSegment(p, pWriter->iEnd, 0, 0);\n  if( rc!=SQLITE_OK ) return rc;\n\n  pWriter->iAbsLevel = iAbsLevel;\n  pWriter->nLeafEst = nLeafEst;\n  pWriter->iIdx = iIdx;\n\n  /* Set up the array of NodeWriter objects */\n  for(i=0; i<FTS_MAX_APPENDABLE_HEIGHT; i++){\n    pWriter->aNodeWriter[i].iBlock = pWriter->iStart + i*pWriter->nLeafEst;\n  }\n  return SQLITE_OK;\n}\n\n/*\n** Remove an entry from the %_segdir table. This involves running the \n** following two statements:\n**\n**   DELETE FROM %_segdir WHERE level = :iAbsLevel AND idx = :iIdx\n**   UPDATE %_segdir SET idx = idx - 1 WHERE level = :iAbsLevel AND idx > :iIdx\n**\n** The DELETE statement removes the specific %_segdir level. The UPDATE \n** statement ensures that the remaining segments have contiguously allocated\n** idx values.\n*/\nstatic int fts3RemoveSegdirEntry(\n  Fts3Table *p,                   /* FTS3 table handle */\n  sqlite3_int64 iAbsLevel,        /* Absolute level to delete from */\n  int iIdx                        /* Index of %_segdir entry to delete */\n){\n  int rc;                         /* Return code */\n  sqlite3_stmt *pDelete = 0;      /* DELETE statement */\n\n  rc = fts3SqlStmt(p, SQL_DELETE_SEGDIR_ENTRY, &pDelete, 0);\n  if( rc==SQLITE_OK ){\n    sqlite3_bind_int64(pDelete, 1, iAbsLevel);\n    sqlite3_bind_int(pDelete, 2, iIdx);\n    sqlite3_step(pDelete);\n    rc = sqlite3_reset(pDelete);\n  }\n\n  return rc;\n}\n\n/*\n** One or more segments have just been removed from absolute level iAbsLevel.\n** Update the 'idx' values of the remaining segments in the level so that\n** the idx values are a contiguous sequence starting from 0.\n*/\nstatic int fts3RepackSegdirLevel(\n  Fts3Table *p,                   /* FTS3 table handle */\n  sqlite3_int64 iAbsLevel         /* Absolute level to repack */\n){\n  int rc;                         /* Return code */\n  int *aIdx = 0;                  /* Array of remaining idx values */\n  int nIdx = 0;                   /* Valid entries in aIdx[] */\n  int nAlloc = 0;                 /* Allocated size of aIdx[] */\n  int i;                          /* Iterator variable */\n  sqlite3_stmt *pSelect = 0;      /* Select statement to read idx values */\n  sqlite3_stmt *pUpdate = 0;      /* Update statement to modify idx values */\n\n  rc = fts3SqlStmt(p, SQL_SELECT_INDEXES, &pSelect, 0);\n  if( rc==SQLITE_OK ){\n    int rc2;\n    sqlite3_bind_int64(pSelect, 1, iAbsLevel);\n    while( SQLITE_ROW==sqlite3_step(pSelect) ){\n      if( nIdx>=nAlloc ){\n        int *aNew;\n        nAlloc += 16;\n        aNew = sqlite3_realloc(aIdx, nAlloc*sizeof(int));\n        if( !aNew ){\n          rc = SQLITE_NOMEM;\n          break;\n        }\n        aIdx = aNew;\n      }\n      aIdx[nIdx++] = sqlite3_column_int(pSelect, 0);\n    }\n    rc2 = sqlite3_reset(pSelect);\n    if( rc==SQLITE_OK ) rc = rc2;\n  }\n\n  if( rc==SQLITE_OK ){\n    rc = fts3SqlStmt(p, SQL_SHIFT_SEGDIR_ENTRY, &pUpdate, 0);\n  }\n  if( rc==SQLITE_OK ){\n    sqlite3_bind_int64(pUpdate, 2, iAbsLevel);\n  }\n\n  assert( p->bIgnoreSavepoint==0 );\n  p->bIgnoreSavepoint = 1;\n  for(i=0; rc==SQLITE_OK && i<nIdx; i++){\n    if( aIdx[i]!=i ){\n      sqlite3_bind_int(pUpdate, 3, aIdx[i]);\n      sqlite3_bind_int(pUpdate, 1, i);\n      sqlite3_step(pUpdate);\n      rc = sqlite3_reset(pUpdate);\n    }\n  }\n  p->bIgnoreSavepoint = 0;\n\n  sqlite3_free(aIdx);\n  return rc;\n}\n\nstatic void fts3StartNode(Blob *pNode, int iHeight, sqlite3_int64 iChild){\n  pNode->a[0] = (char)iHeight;\n  if( iChild ){\n    assert( pNode->nAlloc>=1+sqlite3Fts3VarintLen(iChild) );\n    pNode->n = 1 + sqlite3Fts3PutVarint(&pNode->a[1], iChild);\n  }else{\n    assert( pNode->nAlloc>=1 );\n    pNode->n = 1;\n  }\n}\n\n/*\n** The first two arguments are a pointer to and the size of a segment b-tree\n** node. The node may be a leaf or an internal node.\n**\n** This function creates a new node image in blob object *pNew by copying\n** all terms that are greater than or equal to zTerm/nTerm (for leaf nodes)\n** or greater than zTerm/nTerm (for internal nodes) from aNode/nNode.\n*/\nstatic int fts3TruncateNode(\n  const char *aNode,              /* Current node image */\n  int nNode,                      /* Size of aNode in bytes */\n  Blob *pNew,                     /* OUT: Write new node image here */\n  const char *zTerm,              /* Omit all terms smaller than this */\n  int nTerm,                      /* Size of zTerm in bytes */\n  sqlite3_int64 *piBlock          /* OUT: Block number in next layer down */\n){\n  NodeReader reader;              /* Reader object */\n  Blob prev = {0, 0, 0};          /* Previous term written to new node */\n  int rc = SQLITE_OK;             /* Return code */\n  int bLeaf = aNode[0]=='\\0';     /* True for a leaf node */\n\n  /* Allocate required output space */\n  blobGrowBuffer(pNew, nNode, &rc);\n  if( rc!=SQLITE_OK ) return rc;\n  pNew->n = 0;\n\n  /* Populate new node buffer */\n  for(rc = nodeReaderInit(&reader, aNode, nNode); \n      rc==SQLITE_OK && reader.aNode; \n      rc = nodeReaderNext(&reader)\n  ){\n    if( pNew->n==0 ){\n      int res = fts3TermCmp(reader.term.a, reader.term.n, zTerm, nTerm);\n      if( res<0 || (bLeaf==0 && res==0) ) continue;\n      fts3StartNode(pNew, (int)aNode[0], reader.iChild);\n      *piBlock = reader.iChild;\n    }\n    rc = fts3AppendToNode(\n        pNew, &prev, reader.term.a, reader.term.n,\n        reader.aDoclist, reader.nDoclist\n    );\n    if( rc!=SQLITE_OK ) break;\n  }\n  if( pNew->n==0 ){\n    fts3StartNode(pNew, (int)aNode[0], reader.iChild);\n    *piBlock = reader.iChild;\n  }\n  assert( pNew->n<=pNew->nAlloc );\n\n  nodeReaderRelease(&reader);\n  sqlite3_free(prev.a);\n  return rc;\n}\n\n/*\n** Remove all terms smaller than zTerm/nTerm from segment iIdx in absolute \n** level iAbsLevel. This may involve deleting entries from the %_segments\n** table, and modifying existing entries in both the %_segments and %_segdir\n** tables.\n**\n** SQLITE_OK is returned if the segment is updated successfully. Or an\n** SQLite error code otherwise.\n*/\nstatic int fts3TruncateSegment(\n  Fts3Table *p,                   /* FTS3 table handle */\n  sqlite3_int64 iAbsLevel,        /* Absolute level of segment to modify */\n  int iIdx,                       /* Index within level of segment to modify */\n  const char *zTerm,              /* Remove terms smaller than this */\n  int nTerm                      /* Number of bytes in buffer zTerm */\n){\n  int rc = SQLITE_OK;             /* Return code */\n  Blob root = {0,0,0};            /* New root page image */\n  Blob block = {0,0,0};           /* Buffer used for any other block */\n  sqlite3_int64 iBlock = 0;       /* Block id */\n  sqlite3_int64 iNewStart = 0;    /* New value for iStartBlock */\n  sqlite3_int64 iOldStart = 0;    /* Old value for iStartBlock */\n  sqlite3_stmt *pFetch = 0;       /* Statement used to fetch segdir */\n\n  rc = fts3SqlStmt(p, SQL_SELECT_SEGDIR, &pFetch, 0);\n  if( rc==SQLITE_OK ){\n    int rc2;                      /* sqlite3_reset() return code */\n    sqlite3_bind_int64(pFetch, 1, iAbsLevel);\n    sqlite3_bind_int(pFetch, 2, iIdx);\n    if( SQLITE_ROW==sqlite3_step(pFetch) ){\n      const char *aRoot = sqlite3_column_blob(pFetch, 4);\n      int nRoot = sqlite3_column_bytes(pFetch, 4);\n      iOldStart = sqlite3_column_int64(pFetch, 1);\n      rc = fts3TruncateNode(aRoot, nRoot, &root, zTerm, nTerm, &iBlock);\n    }\n    rc2 = sqlite3_reset(pFetch);\n    if( rc==SQLITE_OK ) rc = rc2;\n  }\n\n  while( rc==SQLITE_OK && iBlock ){\n    char *aBlock = 0;\n    int nBlock = 0;\n    iNewStart = iBlock;\n\n    rc = sqlite3Fts3ReadBlock(p, iBlock, &aBlock, &nBlock, 0);\n    if( rc==SQLITE_OK ){\n      rc = fts3TruncateNode(aBlock, nBlock, &block, zTerm, nTerm, &iBlock);\n    }\n    if( rc==SQLITE_OK ){\n      rc = fts3WriteSegment(p, iNewStart, block.a, block.n);\n    }\n    sqlite3_free(aBlock);\n  }\n\n  /* Variable iNewStart now contains the first valid leaf node. */\n  if( rc==SQLITE_OK && iNewStart ){\n    sqlite3_stmt *pDel = 0;\n    rc = fts3SqlStmt(p, SQL_DELETE_SEGMENTS_RANGE, &pDel, 0);\n    if( rc==SQLITE_OK ){\n      sqlite3_bind_int64(pDel, 1, iOldStart);\n      sqlite3_bind_int64(pDel, 2, iNewStart-1);\n      sqlite3_step(pDel);\n      rc = sqlite3_reset(pDel);\n    }\n  }\n\n  if( rc==SQLITE_OK ){\n    sqlite3_stmt *pChomp = 0;\n    rc = fts3SqlStmt(p, SQL_CHOMP_SEGDIR, &pChomp, 0);\n    if( rc==SQLITE_OK ){\n      sqlite3_bind_int64(pChomp, 1, iNewStart);\n      sqlite3_bind_blob(pChomp, 2, root.a, root.n, SQLITE_STATIC);\n      sqlite3_bind_int64(pChomp, 3, iAbsLevel);\n      sqlite3_bind_int(pChomp, 4, iIdx);\n      sqlite3_step(pChomp);\n      rc = sqlite3_reset(pChomp);\n      sqlite3_bind_null(pChomp, 2);\n    }\n  }\n\n  sqlite3_free(root.a);\n  sqlite3_free(block.a);\n  return rc;\n}\n\n/*\n** This function is called after an incrmental-merge operation has run to\n** merge (or partially merge) two or more segments from absolute level\n** iAbsLevel.\n**\n** Each input segment is either removed from the db completely (if all of\n** its data was copied to the output segment by the incrmerge operation)\n** or modified in place so that it no longer contains those entries that\n** have been duplicated in the output segment.\n*/\nstatic int fts3IncrmergeChomp(\n  Fts3Table *p,                   /* FTS table handle */\n  sqlite3_int64 iAbsLevel,        /* Absolute level containing segments */\n  Fts3MultiSegReader *pCsr,       /* Chomp all segments opened by this cursor */\n  int *pnRem                      /* Number of segments not deleted */\n){\n  int i;\n  int nRem = 0;\n  int rc = SQLITE_OK;\n\n  for(i=pCsr->nSegment-1; i>=0 && rc==SQLITE_OK; i--){\n    Fts3SegReader *pSeg = 0;\n    int j;\n\n    /* Find the Fts3SegReader object with Fts3SegReader.iIdx==i. It is hiding\n    ** somewhere in the pCsr->apSegment[] array.  */\n    for(j=0; ALWAYS(j<pCsr->nSegment); j++){\n      pSeg = pCsr->apSegment[j];\n      if( pSeg->iIdx==i ) break;\n    }\n    assert( j<pCsr->nSegment && pSeg->iIdx==i );\n\n    if( pSeg->aNode==0 ){\n      /* Seg-reader is at EOF. Remove the entire input segment. */\n      rc = fts3DeleteSegment(p, pSeg);\n      if( rc==SQLITE_OK ){\n        rc = fts3RemoveSegdirEntry(p, iAbsLevel, pSeg->iIdx);\n      }\n      *pnRem = 0;\n    }else{\n      /* The incremental merge did not copy all the data from this \n      ** segment to the upper level. The segment is modified in place\n      ** so that it contains no keys smaller than zTerm/nTerm. */ \n      const char *zTerm = pSeg->zTerm;\n      int nTerm = pSeg->nTerm;\n      rc = fts3TruncateSegment(p, iAbsLevel, pSeg->iIdx, zTerm, nTerm);\n      nRem++;\n    }\n  }\n\n  if( rc==SQLITE_OK && nRem!=pCsr->nSegment ){\n    rc = fts3RepackSegdirLevel(p, iAbsLevel);\n  }\n\n  *pnRem = nRem;\n  return rc;\n}\n\n/*\n** Store an incr-merge hint in the database.\n*/\nstatic int fts3IncrmergeHintStore(Fts3Table *p, Blob *pHint){\n  sqlite3_stmt *pReplace = 0;\n  int rc;                         /* Return code */\n\n  rc = fts3SqlStmt(p, SQL_REPLACE_STAT, &pReplace, 0);\n  if( rc==SQLITE_OK ){\n    sqlite3_bind_int(pReplace, 1, FTS_STAT_INCRMERGEHINT);\n    sqlite3_bind_blob(pReplace, 2, pHint->a, pHint->n, SQLITE_STATIC);\n    sqlite3_step(pReplace);\n    rc = sqlite3_reset(pReplace);\n    sqlite3_bind_null(pReplace, 2);\n  }\n\n  return rc;\n}\n\n/*\n** Load an incr-merge hint from the database. The incr-merge hint, if one \n** exists, is stored in the rowid==1 row of the %_stat table.\n**\n** If successful, populate blob *pHint with the value read from the %_stat\n** table and return SQLITE_OK. Otherwise, if an error occurs, return an\n** SQLite error code.\n*/\nstatic int fts3IncrmergeHintLoad(Fts3Table *p, Blob *pHint){\n  sqlite3_stmt *pSelect = 0;\n  int rc;\n\n  pHint->n = 0;\n  rc = fts3SqlStmt(p, SQL_SELECT_STAT, &pSelect, 0);\n  if( rc==SQLITE_OK ){\n    int rc2;\n    sqlite3_bind_int(pSelect, 1, FTS_STAT_INCRMERGEHINT);\n    if( SQLITE_ROW==sqlite3_step(pSelect) ){\n      const char *aHint = sqlite3_column_blob(pSelect, 0);\n      int nHint = sqlite3_column_bytes(pSelect, 0);\n      if( aHint ){\n        blobGrowBuffer(pHint, nHint, &rc);\n        if( rc==SQLITE_OK ){\n          memcpy(pHint->a, aHint, nHint);\n          pHint->n = nHint;\n        }\n      }\n    }\n    rc2 = sqlite3_reset(pSelect);\n    if( rc==SQLITE_OK ) rc = rc2;\n  }\n\n  return rc;\n}\n\n/*\n** If *pRc is not SQLITE_OK when this function is called, it is a no-op.\n** Otherwise, append an entry to the hint stored in blob *pHint. Each entry\n** consists of two varints, the absolute level number of the input segments \n** and the number of input segments.\n**\n** If successful, leave *pRc set to SQLITE_OK and return. If an error occurs,\n** set *pRc to an SQLite error code before returning.\n*/\nstatic void fts3IncrmergeHintPush(\n  Blob *pHint,                    /* Hint blob to append to */\n  i64 iAbsLevel,                  /* First varint to store in hint */\n  int nInput,                     /* Second varint to store in hint */\n  int *pRc                        /* IN/OUT: Error code */\n){\n  blobGrowBuffer(pHint, pHint->n + 2*FTS3_VARINT_MAX, pRc);\n  if( *pRc==SQLITE_OK ){\n    pHint->n += sqlite3Fts3PutVarint(&pHint->a[pHint->n], iAbsLevel);\n    pHint->n += sqlite3Fts3PutVarint(&pHint->a[pHint->n], (i64)nInput);\n  }\n}\n\n/*\n** Read the last entry (most recently pushed) from the hint blob *pHint\n** and then remove the entry. Write the two values read to *piAbsLevel and \n** *pnInput before returning.\n**\n** If no error occurs, return SQLITE_OK. If the hint blob in *pHint does\n** not contain at least two valid varints, return SQLITE_CORRUPT_VTAB.\n*/\nstatic int fts3IncrmergeHintPop(Blob *pHint, i64 *piAbsLevel, int *pnInput){\n  const int nHint = pHint->n;\n  int i;\n\n  i = pHint->n-2;\n  while( i>0 && (pHint->a[i-1] & 0x80) ) i--;\n  while( i>0 && (pHint->a[i-1] & 0x80) ) i--;\n\n  pHint->n = i;\n  i += sqlite3Fts3GetVarint(&pHint->a[i], piAbsLevel);\n  i += fts3GetVarint32(&pHint->a[i], pnInput);\n  if( i!=nHint ) return FTS_CORRUPT_VTAB;\n\n  return SQLITE_OK;\n}\n\n\n/*\n** Attempt an incremental merge that writes nMerge leaf blocks.\n**\n** Incremental merges happen nMin segments at a time. The segments \n** to be merged are the nMin oldest segments (the ones with the smallest \n** values for the _segdir.idx field) in the highest level that contains \n** at least nMin segments. Multiple merges might occur in an attempt to \n** write the quota of nMerge leaf blocks.\n*/\nSQLITE_PRIVATE int sqlite3Fts3Incrmerge(Fts3Table *p, int nMerge, int nMin){\n  int rc;                         /* Return code */\n  int nRem = nMerge;              /* Number of leaf pages yet to  be written */\n  Fts3MultiSegReader *pCsr;       /* Cursor used to read input data */\n  Fts3SegFilter *pFilter;         /* Filter used with cursor pCsr */\n  IncrmergeWriter *pWriter;       /* Writer object */\n  int nSeg = 0;                   /* Number of input segments */\n  sqlite3_int64 iAbsLevel = 0;    /* Absolute level number to work on */\n  Blob hint = {0, 0, 0};          /* Hint read from %_stat table */\n  int bDirtyHint = 0;             /* True if blob 'hint' has been modified */\n\n  /* Allocate space for the cursor, filter and writer objects */\n  const int nAlloc = sizeof(*pCsr) + sizeof(*pFilter) + sizeof(*pWriter);\n  pWriter = (IncrmergeWriter *)sqlite3_malloc(nAlloc);\n  if( !pWriter ) return SQLITE_NOMEM;\n  pFilter = (Fts3SegFilter *)&pWriter[1];\n  pCsr = (Fts3MultiSegReader *)&pFilter[1];\n\n  rc = fts3IncrmergeHintLoad(p, &hint);\n  while( rc==SQLITE_OK && nRem>0 ){\n    const i64 nMod = FTS3_SEGDIR_MAXLEVEL * p->nIndex;\n    sqlite3_stmt *pFindLevel = 0; /* SQL used to determine iAbsLevel */\n    int bUseHint = 0;             /* True if attempting to append */\n    int iIdx = 0;                 /* Largest idx in level (iAbsLevel+1) */\n\n    /* Search the %_segdir table for the absolute level with the smallest\n    ** relative level number that contains at least nMin segments, if any.\n    ** If one is found, set iAbsLevel to the absolute level number and\n    ** nSeg to nMin. If no level with at least nMin segments can be found, \n    ** set nSeg to -1.\n    */\n    rc = fts3SqlStmt(p, SQL_FIND_MERGE_LEVEL, &pFindLevel, 0);\n    sqlite3_bind_int(pFindLevel, 1, MAX(2, nMin));\n    if( sqlite3_step(pFindLevel)==SQLITE_ROW ){\n      iAbsLevel = sqlite3_column_int64(pFindLevel, 0);\n      nSeg = sqlite3_column_int(pFindLevel, 1);\n      assert( nSeg>=2 );\n    }else{\n      nSeg = -1;\n    }\n    rc = sqlite3_reset(pFindLevel);\n\n    /* If the hint read from the %_stat table is not empty, check if the\n    ** last entry in it specifies a relative level smaller than or equal\n    ** to the level identified by the block above (if any). If so, this \n    ** iteration of the loop will work on merging at the hinted level.\n    */\n    if( rc==SQLITE_OK && hint.n ){\n      int nHint = hint.n;\n      sqlite3_int64 iHintAbsLevel = 0;      /* Hint level */\n      int nHintSeg = 0;                     /* Hint number of segments */\n\n      rc = fts3IncrmergeHintPop(&hint, &iHintAbsLevel, &nHintSeg);\n      if( nSeg<0 || (iAbsLevel % nMod) >= (iHintAbsLevel % nMod) ){\n        iAbsLevel = iHintAbsLevel;\n        nSeg = nHintSeg;\n        bUseHint = 1;\n        bDirtyHint = 1;\n      }else{\n        /* This undoes the effect of the HintPop() above - so that no entry\n        ** is removed from the hint blob.  */\n        hint.n = nHint;\n      }\n    }\n\n    /* If nSeg is less that zero, then there is no level with at least\n    ** nMin segments and no hint in the %_stat table. No work to do.\n    ** Exit early in this case.  */\n    if( nSeg<0 ) break;\n\n    /* Open a cursor to iterate through the contents of the oldest nSeg \n    ** indexes of absolute level iAbsLevel. If this cursor is opened using \n    ** the 'hint' parameters, it is possible that there are less than nSeg\n    ** segments available in level iAbsLevel. In this case, no work is\n    ** done on iAbsLevel - fall through to the next iteration of the loop \n    ** to start work on some other level.  */\n    memset(pWriter, 0, nAlloc);\n    pFilter->flags = FTS3_SEGMENT_REQUIRE_POS;\n\n    if( rc==SQLITE_OK ){\n      rc = fts3IncrmergeOutputIdx(p, iAbsLevel, &iIdx);\n      assert( bUseHint==1 || bUseHint==0 );\n      if( iIdx==0 || (bUseHint && iIdx==1) ){\n        int bIgnore = 0;\n        rc = fts3SegmentIsMaxLevel(p, iAbsLevel+1, &bIgnore);\n        if( bIgnore ){\n          pFilter->flags |= FTS3_SEGMENT_IGNORE_EMPTY;\n        }\n      }\n    }\n\n    if( rc==SQLITE_OK ){\n      rc = fts3IncrmergeCsr(p, iAbsLevel, nSeg, pCsr);\n    }\n    if( SQLITE_OK==rc && pCsr->nSegment==nSeg\n     && SQLITE_OK==(rc = sqlite3Fts3SegReaderStart(p, pCsr, pFilter))\n     && SQLITE_ROW==(rc = sqlite3Fts3SegReaderStep(p, pCsr))\n    ){\n      if( bUseHint && iIdx>0 ){\n        const char *zKey = pCsr->zTerm;\n        int nKey = pCsr->nTerm;\n        rc = fts3IncrmergeLoad(p, iAbsLevel, iIdx-1, zKey, nKey, pWriter);\n      }else{\n        rc = fts3IncrmergeWriter(p, iAbsLevel, iIdx, pCsr, pWriter);\n      }\n\n      if( rc==SQLITE_OK && pWriter->nLeafEst ){\n        fts3LogMerge(nSeg, iAbsLevel);\n        do {\n          rc = fts3IncrmergeAppend(p, pWriter, pCsr);\n          if( rc==SQLITE_OK ) rc = sqlite3Fts3SegReaderStep(p, pCsr);\n          if( pWriter->nWork>=nRem && rc==SQLITE_ROW ) rc = SQLITE_OK;\n        }while( rc==SQLITE_ROW );\n\n        /* Update or delete the input segments */\n        if( rc==SQLITE_OK ){\n          nRem -= (1 + pWriter->nWork);\n          rc = fts3IncrmergeChomp(p, iAbsLevel, pCsr, &nSeg);\n          if( nSeg!=0 ){\n            bDirtyHint = 1;\n            fts3IncrmergeHintPush(&hint, iAbsLevel, nSeg, &rc);\n          }\n        }\n      }\n\n      if( nSeg!=0 ){\n        pWriter->nLeafData = pWriter->nLeafData * -1;\n      }\n      fts3IncrmergeRelease(p, pWriter, &rc);\n      if( nSeg==0 && pWriter->bNoLeafData==0 ){\n        fts3PromoteSegments(p, iAbsLevel+1, pWriter->nLeafData);\n      }\n    }\n\n    sqlite3Fts3SegReaderFinish(pCsr);\n  }\n\n  /* Write the hint values into the %_stat table for the next incr-merger */\n  if( bDirtyHint && rc==SQLITE_OK ){\n    rc = fts3IncrmergeHintStore(p, &hint);\n  }\n\n  sqlite3_free(pWriter);\n  sqlite3_free(hint.a);\n  return rc;\n}\n\n/*\n** Convert the text beginning at *pz into an integer and return\n** its value.  Advance *pz to point to the first character past\n** the integer.\n**\n** This function used for parameters to merge= and incrmerge=\n** commands. \n*/\nstatic int fts3Getint(const char **pz){\n  const char *z = *pz;\n  int i = 0;\n  while( (*z)>='0' && (*z)<='9' && i<214748363 ) i = 10*i + *(z++) - '0';\n  *pz = z;\n  return i;\n}\n\n/*\n** Process statements of the form:\n**\n**    INSERT INTO table(table) VALUES('merge=A,B');\n**\n** A and B are integers that decode to be the number of leaf pages\n** written for the merge, and the minimum number of segments on a level\n** before it will be selected for a merge, respectively.\n*/\nstatic int fts3DoIncrmerge(\n  Fts3Table *p,                   /* FTS3 table handle */\n  const char *zParam              /* Nul-terminated string containing \"A,B\" */\n){\n  int rc;\n  int nMin = (FTS3_MERGE_COUNT / 2);\n  int nMerge = 0;\n  const char *z = zParam;\n\n  /* Read the first integer value */\n  nMerge = fts3Getint(&z);\n\n  /* If the first integer value is followed by a ',',  read the second\n  ** integer value. */\n  if( z[0]==',' && z[1]!='\\0' ){\n    z++;\n    nMin = fts3Getint(&z);\n  }\n\n  if( z[0]!='\\0' || nMin<2 ){\n    rc = SQLITE_ERROR;\n  }else{\n    rc = SQLITE_OK;\n    if( !p->bHasStat ){\n      assert( p->bFts4==0 );\n      sqlite3Fts3CreateStatTable(&rc, p);\n    }\n    if( rc==SQLITE_OK ){\n      rc = sqlite3Fts3Incrmerge(p, nMerge, nMin);\n    }\n    sqlite3Fts3SegmentsClose(p);\n  }\n  return rc;\n}\n\n/*\n** Process statements of the form:\n**\n**    INSERT INTO table(table) VALUES('automerge=X');\n**\n** where X is an integer.  X==0 means to turn automerge off.  X!=0 means\n** turn it on.  The setting is persistent.\n*/\nstatic int fts3DoAutoincrmerge(\n  Fts3Table *p,                   /* FTS3 table handle */\n  const char *zParam              /* Nul-terminated string containing boolean */\n){\n  int rc = SQLITE_OK;\n  sqlite3_stmt *pStmt = 0;\n  p->nAutoincrmerge = fts3Getint(&zParam);\n  if( p->nAutoincrmerge==1 || p->nAutoincrmerge>FTS3_MERGE_COUNT ){\n    p->nAutoincrmerge = 8;\n  }\n  if( !p->bHasStat ){\n    assert( p->bFts4==0 );\n    sqlite3Fts3CreateStatTable(&rc, p);\n    if( rc ) return rc;\n  }\n  rc = fts3SqlStmt(p, SQL_REPLACE_STAT, &pStmt, 0);\n  if( rc ) return rc;\n  sqlite3_bind_int(pStmt, 1, FTS_STAT_AUTOINCRMERGE);\n  sqlite3_bind_int(pStmt, 2, p->nAutoincrmerge);\n  sqlite3_step(pStmt);\n  rc = sqlite3_reset(pStmt);\n  return rc;\n}\n\n/*\n** Return a 64-bit checksum for the FTS index entry specified by the\n** arguments to this function.\n*/\nstatic u64 fts3ChecksumEntry(\n  const char *zTerm,              /* Pointer to buffer containing term */\n  int nTerm,                      /* Size of zTerm in bytes */\n  int iLangid,                    /* Language id for current row */\n  int iIndex,                     /* Index (0..Fts3Table.nIndex-1) */\n  i64 iDocid,                     /* Docid for current row. */\n  int iCol,                       /* Column number */\n  int iPos                        /* Position */\n){\n  int i;\n  u64 ret = (u64)iDocid;\n\n  ret += (ret<<3) + iLangid;\n  ret += (ret<<3) + iIndex;\n  ret += (ret<<3) + iCol;\n  ret += (ret<<3) + iPos;\n  for(i=0; i<nTerm; i++) ret += (ret<<3) + zTerm[i];\n\n  return ret;\n}\n\n/*\n** Return a checksum of all entries in the FTS index that correspond to\n** language id iLangid. The checksum is calculated by XORing the checksums\n** of each individual entry (see fts3ChecksumEntry()) together.\n**\n** If successful, the checksum value is returned and *pRc set to SQLITE_OK.\n** Otherwise, if an error occurs, *pRc is set to an SQLite error code. The\n** return value is undefined in this case.\n*/\nstatic u64 fts3ChecksumIndex(\n  Fts3Table *p,                   /* FTS3 table handle */\n  int iLangid,                    /* Language id to return cksum for */\n  int iIndex,                     /* Index to cksum (0..p->nIndex-1) */\n  int *pRc                        /* OUT: Return code */\n){\n  Fts3SegFilter filter;\n  Fts3MultiSegReader csr;\n  int rc;\n  u64 cksum = 0;\n\n  assert( *pRc==SQLITE_OK );\n\n  memset(&filter, 0, sizeof(filter));\n  memset(&csr, 0, sizeof(csr));\n  filter.flags =  FTS3_SEGMENT_REQUIRE_POS|FTS3_SEGMENT_IGNORE_EMPTY;\n  filter.flags |= FTS3_SEGMENT_SCAN;\n\n  rc = sqlite3Fts3SegReaderCursor(\n      p, iLangid, iIndex, FTS3_SEGCURSOR_ALL, 0, 0, 0, 1,&csr\n  );\n  if( rc==SQLITE_OK ){\n    rc = sqlite3Fts3SegReaderStart(p, &csr, &filter);\n  }\n\n  if( rc==SQLITE_OK ){\n    while( SQLITE_ROW==(rc = sqlite3Fts3SegReaderStep(p, &csr)) ){\n      char *pCsr = csr.aDoclist;\n      char *pEnd = &pCsr[csr.nDoclist];\n\n      i64 iDocid = 0;\n      i64 iCol = 0;\n      i64 iPos = 0;\n\n      pCsr += sqlite3Fts3GetVarint(pCsr, &iDocid);\n      while( pCsr<pEnd ){\n        i64 iVal = 0;\n        pCsr += sqlite3Fts3GetVarint(pCsr, &iVal);\n        if( pCsr<pEnd ){\n          if( iVal==0 || iVal==1 ){\n            iCol = 0;\n            iPos = 0;\n            if( iVal ){\n              pCsr += sqlite3Fts3GetVarint(pCsr, &iCol);\n            }else{\n              pCsr += sqlite3Fts3GetVarint(pCsr, &iVal);\n              iDocid += iVal;\n            }\n          }else{\n            iPos += (iVal - 2);\n            cksum = cksum ^ fts3ChecksumEntry(\n                csr.zTerm, csr.nTerm, iLangid, iIndex, iDocid,\n                (int)iCol, (int)iPos\n            );\n          }\n        }\n      }\n    }\n  }\n  sqlite3Fts3SegReaderFinish(&csr);\n\n  *pRc = rc;\n  return cksum;\n}\n\n/*\n** Check if the contents of the FTS index match the current contents of the\n** content table. If no error occurs and the contents do match, set *pbOk\n** to true and return SQLITE_OK. Or if the contents do not match, set *pbOk\n** to false before returning.\n**\n** If an error occurs (e.g. an OOM or IO error), return an SQLite error \n** code. The final value of *pbOk is undefined in this case.\n*/\nstatic int fts3IntegrityCheck(Fts3Table *p, int *pbOk){\n  int rc = SQLITE_OK;             /* Return code */\n  u64 cksum1 = 0;                 /* Checksum based on FTS index contents */\n  u64 cksum2 = 0;                 /* Checksum based on %_content contents */\n  sqlite3_stmt *pAllLangid = 0;   /* Statement to return all language-ids */\n\n  /* This block calculates the checksum according to the FTS index. */\n  rc = fts3SqlStmt(p, SQL_SELECT_ALL_LANGID, &pAllLangid, 0);\n  if( rc==SQLITE_OK ){\n    int rc2;\n    sqlite3_bind_int(pAllLangid, 1, p->iPrevLangid);\n    sqlite3_bind_int(pAllLangid, 2, p->nIndex);\n    while( rc==SQLITE_OK && sqlite3_step(pAllLangid)==SQLITE_ROW ){\n      int iLangid = sqlite3_column_int(pAllLangid, 0);\n      int i;\n      for(i=0; i<p->nIndex; i++){\n        cksum1 = cksum1 ^ fts3ChecksumIndex(p, iLangid, i, &rc);\n      }\n    }\n    rc2 = sqlite3_reset(pAllLangid);\n    if( rc==SQLITE_OK ) rc = rc2;\n  }\n\n  /* This block calculates the checksum according to the %_content table */\n  if( rc==SQLITE_OK ){\n    sqlite3_tokenizer_module const *pModule = p->pTokenizer->pModule;\n    sqlite3_stmt *pStmt = 0;\n    char *zSql;\n   \n    zSql = sqlite3_mprintf(\"SELECT %s\" , p->zReadExprlist);\n    if( !zSql ){\n      rc = SQLITE_NOMEM;\n    }else{\n      rc = sqlite3_prepare_v2(p->db, zSql, -1, &pStmt, 0);\n      sqlite3_free(zSql);\n    }\n\n    while( rc==SQLITE_OK && SQLITE_ROW==sqlite3_step(pStmt) ){\n      i64 iDocid = sqlite3_column_int64(pStmt, 0);\n      int iLang = langidFromSelect(p, pStmt);\n      int iCol;\n\n      for(iCol=0; rc==SQLITE_OK && iCol<p->nColumn; iCol++){\n        if( p->abNotindexed[iCol]==0 ){\n          const char *zText = (const char *)sqlite3_column_text(pStmt, iCol+1);\n          int nText = sqlite3_column_bytes(pStmt, iCol+1);\n          sqlite3_tokenizer_cursor *pT = 0;\n\n          rc = sqlite3Fts3OpenTokenizer(p->pTokenizer, iLang, zText, nText,&pT);\n          while( rc==SQLITE_OK ){\n            char const *zToken;       /* Buffer containing token */\n            int nToken = 0;           /* Number of bytes in token */\n            int iDum1 = 0, iDum2 = 0; /* Dummy variables */\n            int iPos = 0;             /* Position of token in zText */\n\n            rc = pModule->xNext(pT, &zToken, &nToken, &iDum1, &iDum2, &iPos);\n            if( rc==SQLITE_OK ){\n              int i;\n              cksum2 = cksum2 ^ fts3ChecksumEntry(\n                  zToken, nToken, iLang, 0, iDocid, iCol, iPos\n              );\n              for(i=1; i<p->nIndex; i++){\n                if( p->aIndex[i].nPrefix<=nToken ){\n                  cksum2 = cksum2 ^ fts3ChecksumEntry(\n                      zToken, p->aIndex[i].nPrefix, iLang, i, iDocid, iCol, iPos\n                  );\n                }\n              }\n            }\n          }\n          if( pT ) pModule->xClose(pT);\n          if( rc==SQLITE_DONE ) rc = SQLITE_OK;\n        }\n      }\n    }\n\n    sqlite3_finalize(pStmt);\n  }\n\n  *pbOk = (cksum1==cksum2);\n  return rc;\n}\n\n/*\n** Run the integrity-check. If no error occurs and the current contents of\n** the FTS index are correct, return SQLITE_OK. Or, if the contents of the\n** FTS index are incorrect, return SQLITE_CORRUPT_VTAB.\n**\n** Or, if an error (e.g. an OOM or IO error) occurs, return an SQLite \n** error code.\n**\n** The integrity-check works as follows. For each token and indexed token\n** prefix in the document set, a 64-bit checksum is calculated (by code\n** in fts3ChecksumEntry()) based on the following:\n**\n**     + The index number (0 for the main index, 1 for the first prefix\n**       index etc.),\n**     + The token (or token prefix) text itself, \n**     + The language-id of the row it appears in,\n**     + The docid of the row it appears in,\n**     + The column it appears in, and\n**     + The tokens position within that column.\n**\n** The checksums for all entries in the index are XORed together to create\n** a single checksum for the entire index.\n**\n** The integrity-check code calculates the same checksum in two ways:\n**\n**     1. By scanning the contents of the FTS index, and \n**     2. By scanning and tokenizing the content table.\n**\n** If the two checksums are identical, the integrity-check is deemed to have\n** passed.\n*/\nstatic int fts3DoIntegrityCheck(\n  Fts3Table *p                    /* FTS3 table handle */\n){\n  int rc;\n  int bOk = 0;\n  rc = fts3IntegrityCheck(p, &bOk);\n  if( rc==SQLITE_OK && bOk==0 ) rc = FTS_CORRUPT_VTAB;\n  return rc;\n}\n\n/*\n** Handle a 'special' INSERT of the form:\n**\n**   \"INSERT INTO tbl(tbl) VALUES(<expr>)\"\n**\n** Argument pVal contains the result of <expr>. Currently the only \n** meaningful value to insert is the text 'optimize'.\n*/\nstatic int fts3SpecialInsert(Fts3Table *p, sqlite3_value *pVal){\n  int rc;                         /* Return Code */\n  const char *zVal = (const char *)sqlite3_value_text(pVal);\n  int nVal = sqlite3_value_bytes(pVal);\n\n  if( !zVal ){\n    return SQLITE_NOMEM;\n  }else if( nVal==8 && 0==sqlite3_strnicmp(zVal, \"optimize\", 8) ){\n    rc = fts3DoOptimize(p, 0);\n  }else if( nVal==7 && 0==sqlite3_strnicmp(zVal, \"rebuild\", 7) ){\n    rc = fts3DoRebuild(p);\n  }else if( nVal==15 && 0==sqlite3_strnicmp(zVal, \"integrity-check\", 15) ){\n    rc = fts3DoIntegrityCheck(p);\n  }else if( nVal>6 && 0==sqlite3_strnicmp(zVal, \"merge=\", 6) ){\n    rc = fts3DoIncrmerge(p, &zVal[6]);\n  }else if( nVal>10 && 0==sqlite3_strnicmp(zVal, \"automerge=\", 10) ){\n    rc = fts3DoAutoincrmerge(p, &zVal[10]);\n#ifdef SQLITE_TEST\n  }else if( nVal>9 && 0==sqlite3_strnicmp(zVal, \"nodesize=\", 9) ){\n    p->nNodeSize = atoi(&zVal[9]);\n    rc = SQLITE_OK;\n  }else if( nVal>11 && 0==sqlite3_strnicmp(zVal, \"maxpending=\", 9) ){\n    p->nMaxPendingData = atoi(&zVal[11]);\n    rc = SQLITE_OK;\n  }else if( nVal>21 && 0==sqlite3_strnicmp(zVal, \"test-no-incr-doclist=\", 21) ){\n    p->bNoIncrDoclist = atoi(&zVal[21]);\n    rc = SQLITE_OK;\n#endif\n  }else{\n    rc = SQLITE_ERROR;\n  }\n\n  return rc;\n}\n\n#ifndef SQLITE_DISABLE_FTS4_DEFERRED\n/*\n** Delete all cached deferred doclists. Deferred doclists are cached\n** (allocated) by the sqlite3Fts3CacheDeferredDoclists() function.\n*/\nSQLITE_PRIVATE void sqlite3Fts3FreeDeferredDoclists(Fts3Cursor *pCsr){\n  Fts3DeferredToken *pDef;\n  for(pDef=pCsr->pDeferred; pDef; pDef=pDef->pNext){\n    fts3PendingListDelete(pDef->pList);\n    pDef->pList = 0;\n  }\n}\n\n/*\n** Free all entries in the pCsr->pDeffered list. Entries are added to \n** this list using sqlite3Fts3DeferToken().\n*/\nSQLITE_PRIVATE void sqlite3Fts3FreeDeferredTokens(Fts3Cursor *pCsr){\n  Fts3DeferredToken *pDef;\n  Fts3DeferredToken *pNext;\n  for(pDef=pCsr->pDeferred; pDef; pDef=pNext){\n    pNext = pDef->pNext;\n    fts3PendingListDelete(pDef->pList);\n    sqlite3_free(pDef);\n  }\n  pCsr->pDeferred = 0;\n}\n\n/*\n** Generate deferred-doclists for all tokens in the pCsr->pDeferred list\n** based on the row that pCsr currently points to.\n**\n** A deferred-doclist is like any other doclist with position information\n** included, except that it only contains entries for a single row of the\n** table, not for all rows.\n*/\nSQLITE_PRIVATE int sqlite3Fts3CacheDeferredDoclists(Fts3Cursor *pCsr){\n  int rc = SQLITE_OK;             /* Return code */\n  if( pCsr->pDeferred ){\n    int i;                        /* Used to iterate through table columns */\n    sqlite3_int64 iDocid;         /* Docid of the row pCsr points to */\n    Fts3DeferredToken *pDef;      /* Used to iterate through deferred tokens */\n  \n    Fts3Table *p = (Fts3Table *)pCsr->base.pVtab;\n    sqlite3_tokenizer *pT = p->pTokenizer;\n    sqlite3_tokenizer_module const *pModule = pT->pModule;\n   \n    assert( pCsr->isRequireSeek==0 );\n    iDocid = sqlite3_column_int64(pCsr->pStmt, 0);\n  \n    for(i=0; i<p->nColumn && rc==SQLITE_OK; i++){\n      if( p->abNotindexed[i]==0 ){\n        const char *zText = (const char *)sqlite3_column_text(pCsr->pStmt, i+1);\n        sqlite3_tokenizer_cursor *pTC = 0;\n\n        rc = sqlite3Fts3OpenTokenizer(pT, pCsr->iLangid, zText, -1, &pTC);\n        while( rc==SQLITE_OK ){\n          char const *zToken;       /* Buffer containing token */\n          int nToken = 0;           /* Number of bytes in token */\n          int iDum1 = 0, iDum2 = 0; /* Dummy variables */\n          int iPos = 0;             /* Position of token in zText */\n\n          rc = pModule->xNext(pTC, &zToken, &nToken, &iDum1, &iDum2, &iPos);\n          for(pDef=pCsr->pDeferred; pDef && rc==SQLITE_OK; pDef=pDef->pNext){\n            Fts3PhraseToken *pPT = pDef->pToken;\n            if( (pDef->iCol>=p->nColumn || pDef->iCol==i)\n                && (pPT->bFirst==0 || iPos==0)\n                && (pPT->n==nToken || (pPT->isPrefix && pPT->n<nToken))\n                && (0==memcmp(zToken, pPT->z, pPT->n))\n              ){\n              fts3PendingListAppend(&pDef->pList, iDocid, i, iPos, &rc);\n            }\n          }\n        }\n        if( pTC ) pModule->xClose(pTC);\n        if( rc==SQLITE_DONE ) rc = SQLITE_OK;\n      }\n    }\n\n    for(pDef=pCsr->pDeferred; pDef && rc==SQLITE_OK; pDef=pDef->pNext){\n      if( pDef->pList ){\n        rc = fts3PendingListAppendVarint(&pDef->pList, 0);\n      }\n    }\n  }\n\n  return rc;\n}\n\nSQLITE_PRIVATE int sqlite3Fts3DeferredTokenList(\n  Fts3DeferredToken *p, \n  char **ppData, \n  int *pnData\n){\n  char *pRet;\n  int nSkip;\n  sqlite3_int64 dummy;\n\n  *ppData = 0;\n  *pnData = 0;\n\n  if( p->pList==0 ){\n    return SQLITE_OK;\n  }\n\n  pRet = (char *)sqlite3_malloc(p->pList->nData);\n  if( !pRet ) return SQLITE_NOMEM;\n\n  nSkip = sqlite3Fts3GetVarint(p->pList->aData, &dummy);\n  *pnData = p->pList->nData - nSkip;\n  *ppData = pRet;\n  \n  memcpy(pRet, &p->pList->aData[nSkip], *pnData);\n  return SQLITE_OK;\n}\n\n/*\n** Add an entry for token pToken to the pCsr->pDeferred list.\n*/\nSQLITE_PRIVATE int sqlite3Fts3DeferToken(\n  Fts3Cursor *pCsr,               /* Fts3 table cursor */\n  Fts3PhraseToken *pToken,        /* Token to defer */\n  int iCol                        /* Column that token must appear in (or -1) */\n){\n  Fts3DeferredToken *pDeferred;\n  pDeferred = sqlite3_malloc(sizeof(*pDeferred));\n  if( !pDeferred ){\n    return SQLITE_NOMEM;\n  }\n  memset(pDeferred, 0, sizeof(*pDeferred));\n  pDeferred->pToken = pToken;\n  pDeferred->pNext = pCsr->pDeferred; \n  pDeferred->iCol = iCol;\n  pCsr->pDeferred = pDeferred;\n\n  assert( pToken->pDeferred==0 );\n  pToken->pDeferred = pDeferred;\n\n  return SQLITE_OK;\n}\n#endif\n\n/*\n** SQLite value pRowid contains the rowid of a row that may or may not be\n** present in the FTS3 table. If it is, delete it and adjust the contents\n** of subsiduary data structures accordingly.\n*/\nstatic int fts3DeleteByRowid(\n  Fts3Table *p, \n  sqlite3_value *pRowid, \n  int *pnChng,                    /* IN/OUT: Decrement if row is deleted */\n  u32 *aSzDel\n){\n  int rc = SQLITE_OK;             /* Return code */\n  int bFound = 0;                 /* True if *pRowid really is in the table */\n\n  fts3DeleteTerms(&rc, p, pRowid, aSzDel, &bFound);\n  if( bFound && rc==SQLITE_OK ){\n    int isEmpty = 0;              /* Deleting *pRowid leaves the table empty */\n    rc = fts3IsEmpty(p, pRowid, &isEmpty);\n    if( rc==SQLITE_OK ){\n      if( isEmpty ){\n        /* Deleting this row means the whole table is empty. In this case\n        ** delete the contents of all three tables and throw away any\n        ** data in the pendingTerms hash table.  */\n        rc = fts3DeleteAll(p, 1);\n        *pnChng = 0;\n        memset(aSzDel, 0, sizeof(u32) * (p->nColumn+1) * 2);\n      }else{\n        *pnChng = *pnChng - 1;\n        if( p->zContentTbl==0 ){\n          fts3SqlExec(&rc, p, SQL_DELETE_CONTENT, &pRowid);\n        }\n        if( p->bHasDocsize ){\n          fts3SqlExec(&rc, p, SQL_DELETE_DOCSIZE, &pRowid);\n        }\n      }\n    }\n  }\n\n  return rc;\n}\n\n/*\n** This function does the work for the xUpdate method of FTS3 virtual\n** tables. The schema of the virtual table being:\n**\n**     CREATE TABLE <table name>( \n**       <user columns>,\n**       <table name> HIDDEN, \n**       docid HIDDEN, \n**       <langid> HIDDEN\n**     );\n**\n** \n*/\nSQLITE_PRIVATE int sqlite3Fts3UpdateMethod(\n  sqlite3_vtab *pVtab,            /* FTS3 vtab object */\n  int nArg,                       /* Size of argument array */\n  sqlite3_value **apVal,          /* Array of arguments */\n  sqlite_int64 *pRowid            /* OUT: The affected (or effected) rowid */\n){\n  Fts3Table *p = (Fts3Table *)pVtab;\n  int rc = SQLITE_OK;             /* Return Code */\n  u32 *aSzIns = 0;                /* Sizes of inserted documents */\n  u32 *aSzDel = 0;                /* Sizes of deleted documents */\n  int nChng = 0;                  /* Net change in number of documents */\n  int bInsertDone = 0;\n\n  /* At this point it must be known if the %_stat table exists or not.\n  ** So bHasStat may not be 2.  */\n  assert( p->bHasStat==0 || p->bHasStat==1 );\n\n  assert( p->pSegments==0 );\n  assert( \n      nArg==1                     /* DELETE operations */\n   || nArg==(2 + p->nColumn + 3)  /* INSERT or UPDATE operations */\n  );\n\n  /* Check for a \"special\" INSERT operation. One of the form:\n  **\n  **   INSERT INTO xyz(xyz) VALUES('command');\n  */\n  if( nArg>1 \n   && sqlite3_value_type(apVal[0])==SQLITE_NULL \n   && sqlite3_value_type(apVal[p->nColumn+2])!=SQLITE_NULL \n  ){\n    rc = fts3SpecialInsert(p, apVal[p->nColumn+2]);\n    goto update_out;\n  }\n\n  if( nArg>1 && sqlite3_value_int(apVal[2 + p->nColumn + 2])<0 ){\n    rc = SQLITE_CONSTRAINT;\n    goto update_out;\n  }\n\n  /* Allocate space to hold the change in document sizes */\n  aSzDel = sqlite3_malloc( sizeof(aSzDel[0])*(p->nColumn+1)*2 );\n  if( aSzDel==0 ){\n    rc = SQLITE_NOMEM;\n    goto update_out;\n  }\n  aSzIns = &aSzDel[p->nColumn+1];\n  memset(aSzDel, 0, sizeof(aSzDel[0])*(p->nColumn+1)*2);\n\n  rc = fts3Writelock(p);\n  if( rc!=SQLITE_OK ) goto update_out;\n\n  /* If this is an INSERT operation, or an UPDATE that modifies the rowid\n  ** value, then this operation requires constraint handling.\n  **\n  ** If the on-conflict mode is REPLACE, this means that the existing row\n  ** should be deleted from the database before inserting the new row. Or,\n  ** if the on-conflict mode is other than REPLACE, then this method must\n  ** detect the conflict and return SQLITE_CONSTRAINT before beginning to\n  ** modify the database file.\n  */\n  if( nArg>1 && p->zContentTbl==0 ){\n    /* Find the value object that holds the new rowid value. */\n    sqlite3_value *pNewRowid = apVal[3+p->nColumn];\n    if( sqlite3_value_type(pNewRowid)==SQLITE_NULL ){\n      pNewRowid = apVal[1];\n    }\n\n    if( sqlite3_value_type(pNewRowid)!=SQLITE_NULL && ( \n        sqlite3_value_type(apVal[0])==SQLITE_NULL\n     || sqlite3_value_int64(apVal[0])!=sqlite3_value_int64(pNewRowid)\n    )){\n      /* The new rowid is not NULL (in this case the rowid will be\n      ** automatically assigned and there is no chance of a conflict), and \n      ** the statement is either an INSERT or an UPDATE that modifies the\n      ** rowid column. So if the conflict mode is REPLACE, then delete any\n      ** existing row with rowid=pNewRowid. \n      **\n      ** Or, if the conflict mode is not REPLACE, insert the new record into \n      ** the %_content table. If we hit the duplicate rowid constraint (or any\n      ** other error) while doing so, return immediately.\n      **\n      ** This branch may also run if pNewRowid contains a value that cannot\n      ** be losslessly converted to an integer. In this case, the eventual \n      ** call to fts3InsertData() (either just below or further on in this\n      ** function) will return SQLITE_MISMATCH. If fts3DeleteByRowid is \n      ** invoked, it will delete zero rows (since no row will have\n      ** docid=$pNewRowid if $pNewRowid is not an integer value).\n      */\n      if( sqlite3_vtab_on_conflict(p->db)==SQLITE_REPLACE ){\n        rc = fts3DeleteByRowid(p, pNewRowid, &nChng, aSzDel);\n      }else{\n        rc = fts3InsertData(p, apVal, pRowid);\n        bInsertDone = 1;\n      }\n    }\n  }\n  if( rc!=SQLITE_OK ){\n    goto update_out;\n  }\n\n  /* If this is a DELETE or UPDATE operation, remove the old record. */\n  if( sqlite3_value_type(apVal[0])!=SQLITE_NULL ){\n    assert( sqlite3_value_type(apVal[0])==SQLITE_INTEGER );\n    rc = fts3DeleteByRowid(p, apVal[0], &nChng, aSzDel);\n  }\n  \n  /* If this is an INSERT or UPDATE operation, insert the new record. */\n  if( nArg>1 && rc==SQLITE_OK ){\n    int iLangid = sqlite3_value_int(apVal[2 + p->nColumn + 2]);\n    if( bInsertDone==0 ){\n      rc = fts3InsertData(p, apVal, pRowid);\n      if( rc==SQLITE_CONSTRAINT && p->zContentTbl==0 ){\n        rc = FTS_CORRUPT_VTAB;\n      }\n    }\n    if( rc==SQLITE_OK ){\n      rc = fts3PendingTermsDocid(p, 0, iLangid, *pRowid);\n    }\n    if( rc==SQLITE_OK ){\n      assert( p->iPrevDocid==*pRowid );\n      rc = fts3InsertTerms(p, iLangid, apVal, aSzIns);\n    }\n    if( p->bHasDocsize ){\n      fts3InsertDocsize(&rc, p, aSzIns);\n    }\n    nChng++;\n  }\n\n  if( p->bFts4 ){\n    fts3UpdateDocTotals(&rc, p, aSzIns, aSzDel, nChng);\n  }\n\n update_out:\n  sqlite3_free(aSzDel);\n  sqlite3Fts3SegmentsClose(p);\n  return rc;\n}\n\n/* \n** Flush any data in the pending-terms hash table to disk. If successful,\n** merge all segments in the database (including the new segment, if \n** there was any data to flush) into a single segment. \n*/\nSQLITE_PRIVATE int sqlite3Fts3Optimize(Fts3Table *p){\n  int rc;\n  rc = sqlite3_exec(p->db, \"SAVEPOINT fts3\", 0, 0, 0);\n  if( rc==SQLITE_OK ){\n    rc = fts3DoOptimize(p, 1);\n    if( rc==SQLITE_OK || rc==SQLITE_DONE ){\n      int rc2 = sqlite3_exec(p->db, \"RELEASE fts3\", 0, 0, 0);\n      if( rc2!=SQLITE_OK ) rc = rc2;\n    }else{\n      sqlite3_exec(p->db, \"ROLLBACK TO fts3\", 0, 0, 0);\n      sqlite3_exec(p->db, \"RELEASE fts3\", 0, 0, 0);\n    }\n  }\n  sqlite3Fts3SegmentsClose(p);\n  return rc;\n}\n\n#endif\n\n/************** End of fts3_write.c ******************************************/\n/************** Begin file fts3_snippet.c ************************************/\n/*\n** 2009 Oct 23\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n******************************************************************************\n*/\n\n/* #include \"fts3Int.h\" */\n#if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3)\n\n/* #include <string.h> */\n/* #include <assert.h> */\n\n/*\n** Characters that may appear in the second argument to matchinfo().\n*/\n#define FTS3_MATCHINFO_NPHRASE   'p'        /* 1 value */\n#define FTS3_MATCHINFO_NCOL      'c'        /* 1 value */\n#define FTS3_MATCHINFO_NDOC      'n'        /* 1 value */\n#define FTS3_MATCHINFO_AVGLENGTH 'a'        /* nCol values */\n#define FTS3_MATCHINFO_LENGTH    'l'        /* nCol values */\n#define FTS3_MATCHINFO_LCS       's'        /* nCol values */\n#define FTS3_MATCHINFO_HITS      'x'        /* 3*nCol*nPhrase values */\n#define FTS3_MATCHINFO_LHITS     'y'        /* nCol*nPhrase values */\n#define FTS3_MATCHINFO_LHITS_BM  'b'        /* nCol*nPhrase values */\n\n/*\n** The default value for the second argument to matchinfo(). \n*/\n#define FTS3_MATCHINFO_DEFAULT   \"pcx\"\n\n\n/*\n** Used as an fts3ExprIterate() context when loading phrase doclists to\n** Fts3Expr.aDoclist[]/nDoclist.\n*/\ntypedef struct LoadDoclistCtx LoadDoclistCtx;\nstruct LoadDoclistCtx {\n  Fts3Cursor *pCsr;               /* FTS3 Cursor */\n  int nPhrase;                    /* Number of phrases seen so far */\n  int nToken;                     /* Number of tokens seen so far */\n};\n\n/*\n** The following types are used as part of the implementation of the \n** fts3BestSnippet() routine.\n*/\ntypedef struct SnippetIter SnippetIter;\ntypedef struct SnippetPhrase SnippetPhrase;\ntypedef struct SnippetFragment SnippetFragment;\n\nstruct SnippetIter {\n  Fts3Cursor *pCsr;               /* Cursor snippet is being generated from */\n  int iCol;                       /* Extract snippet from this column */\n  int nSnippet;                   /* Requested snippet length (in tokens) */\n  int nPhrase;                    /* Number of phrases in query */\n  SnippetPhrase *aPhrase;         /* Array of size nPhrase */\n  int iCurrent;                   /* First token of current snippet */\n};\n\nstruct SnippetPhrase {\n  int nToken;                     /* Number of tokens in phrase */\n  char *pList;                    /* Pointer to start of phrase position list */\n  int iHead;                      /* Next value in position list */\n  char *pHead;                    /* Position list data following iHead */\n  int iTail;                      /* Next value in trailing position list */\n  char *pTail;                    /* Position list data following iTail */\n};\n\nstruct SnippetFragment {\n  int iCol;                       /* Column snippet is extracted from */\n  int iPos;                       /* Index of first token in snippet */\n  u64 covered;                    /* Mask of query phrases covered */\n  u64 hlmask;                     /* Mask of snippet terms to highlight */\n};\n\n/*\n** This type is used as an fts3ExprIterate() context object while \n** accumulating the data returned by the matchinfo() function.\n*/\ntypedef struct MatchInfo MatchInfo;\nstruct MatchInfo {\n  Fts3Cursor *pCursor;            /* FTS3 Cursor */\n  int nCol;                       /* Number of columns in table */\n  int nPhrase;                    /* Number of matchable phrases in query */\n  sqlite3_int64 nDoc;             /* Number of docs in database */\n  char flag;\n  u32 *aMatchinfo;                /* Pre-allocated buffer */\n};\n\n/*\n** An instance of this structure is used to manage a pair of buffers, each\n** (nElem * sizeof(u32)) bytes in size. See the MatchinfoBuffer code below\n** for details.\n*/\nstruct MatchinfoBuffer {\n  u8 aRef[3];\n  int nElem;\n  int bGlobal;                    /* Set if global data is loaded */\n  char *zMatchinfo;\n  u32 aMatchinfo[1];\n};\n\n\n/*\n** The snippet() and offsets() functions both return text values. An instance\n** of the following structure is used to accumulate those values while the\n** functions are running. See fts3StringAppend() for details.\n*/\ntypedef struct StrBuffer StrBuffer;\nstruct StrBuffer {\n  char *z;                        /* Pointer to buffer containing string */\n  int n;                          /* Length of z in bytes (excl. nul-term) */\n  int nAlloc;                     /* Allocated size of buffer z in bytes */\n};\n\n\n/*************************************************************************\n** Start of MatchinfoBuffer code.\n*/\n\n/*\n** Allocate a two-slot MatchinfoBuffer object.\n*/\nstatic MatchinfoBuffer *fts3MIBufferNew(int nElem, const char *zMatchinfo){\n  MatchinfoBuffer *pRet;\n  int nByte = sizeof(u32) * (2*nElem + 1) + sizeof(MatchinfoBuffer);\n  int nStr = (int)strlen(zMatchinfo);\n\n  pRet = sqlite3_malloc(nByte + nStr+1);\n  if( pRet ){\n    memset(pRet, 0, nByte);\n    pRet->aMatchinfo[0] = (u8*)(&pRet->aMatchinfo[1]) - (u8*)pRet;\n    pRet->aMatchinfo[1+nElem] = pRet->aMatchinfo[0] + sizeof(u32)*(nElem+1);\n    pRet->nElem = nElem;\n    pRet->zMatchinfo = ((char*)pRet) + nByte;\n    memcpy(pRet->zMatchinfo, zMatchinfo, nStr+1);\n    pRet->aRef[0] = 1;\n  }\n\n  return pRet;\n}\n\nstatic void fts3MIBufferFree(void *p){\n  MatchinfoBuffer *pBuf = (MatchinfoBuffer*)((u8*)p - ((u32*)p)[-1]);\n\n  assert( (u32*)p==&pBuf->aMatchinfo[1] \n       || (u32*)p==&pBuf->aMatchinfo[pBuf->nElem+2] \n  );\n  if( (u32*)p==&pBuf->aMatchinfo[1] ){\n    pBuf->aRef[1] = 0;\n  }else{\n    pBuf->aRef[2] = 0;\n  }\n\n  if( pBuf->aRef[0]==0 && pBuf->aRef[1]==0 && pBuf->aRef[2]==0 ){\n    sqlite3_free(pBuf);\n  }\n}\n\nstatic void (*fts3MIBufferAlloc(MatchinfoBuffer *p, u32 **paOut))(void*){\n  void (*xRet)(void*) = 0;\n  u32 *aOut = 0;\n\n  if( p->aRef[1]==0 ){\n    p->aRef[1] = 1;\n    aOut = &p->aMatchinfo[1];\n    xRet = fts3MIBufferFree;\n  }\n  else if( p->aRef[2]==0 ){\n    p->aRef[2] = 1;\n    aOut = &p->aMatchinfo[p->nElem+2];\n    xRet = fts3MIBufferFree;\n  }else{\n    aOut = (u32*)sqlite3_malloc64(p->nElem * sizeof(u32));\n    if( aOut ){\n      xRet = sqlite3_free;\n      if( p->bGlobal ) memcpy(aOut, &p->aMatchinfo[1], p->nElem*sizeof(u32));\n    }\n  }\n\n  *paOut = aOut;\n  return xRet;\n}\n\nstatic void fts3MIBufferSetGlobal(MatchinfoBuffer *p){\n  p->bGlobal = 1;\n  memcpy(&p->aMatchinfo[2+p->nElem], &p->aMatchinfo[1], p->nElem*sizeof(u32));\n}\n\n/*\n** Free a MatchinfoBuffer object allocated using fts3MIBufferNew()\n*/\nSQLITE_PRIVATE void sqlite3Fts3MIBufferFree(MatchinfoBuffer *p){\n  if( p ){\n    assert( p->aRef[0]==1 );\n    p->aRef[0] = 0;\n    if( p->aRef[0]==0 && p->aRef[1]==0 && p->aRef[2]==0 ){\n      sqlite3_free(p);\n    }\n  }\n}\n\n/* \n** End of MatchinfoBuffer code.\n*************************************************************************/\n\n\n/*\n** This function is used to help iterate through a position-list. A position\n** list is a list of unique integers, sorted from smallest to largest. Each\n** element of the list is represented by an FTS3 varint that takes the value\n** of the difference between the current element and the previous one plus\n** two. For example, to store the position-list:\n**\n**     4 9 113\n**\n** the three varints:\n**\n**     6 7 106\n**\n** are encoded.\n**\n** When this function is called, *pp points to the start of an element of\n** the list. *piPos contains the value of the previous entry in the list.\n** After it returns, *piPos contains the value of the next element of the\n** list and *pp is advanced to the following varint.\n*/\nstatic void fts3GetDeltaPosition(char **pp, int *piPos){\n  int iVal;\n  *pp += fts3GetVarint32(*pp, &iVal);\n  *piPos += (iVal-2);\n}\n\n/*\n** Helper function for fts3ExprIterate() (see below).\n*/\nstatic int fts3ExprIterate2(\n  Fts3Expr *pExpr,                /* Expression to iterate phrases of */\n  int *piPhrase,                  /* Pointer to phrase counter */\n  int (*x)(Fts3Expr*,int,void*),  /* Callback function to invoke for phrases */\n  void *pCtx                      /* Second argument to pass to callback */\n){\n  int rc;                         /* Return code */\n  int eType = pExpr->eType;     /* Type of expression node pExpr */\n\n  if( eType!=FTSQUERY_PHRASE ){\n    assert( pExpr->pLeft && pExpr->pRight );\n    rc = fts3ExprIterate2(pExpr->pLeft, piPhrase, x, pCtx);\n    if( rc==SQLITE_OK && eType!=FTSQUERY_NOT ){\n      rc = fts3ExprIterate2(pExpr->pRight, piPhrase, x, pCtx);\n    }\n  }else{\n    rc = x(pExpr, *piPhrase, pCtx);\n    (*piPhrase)++;\n  }\n  return rc;\n}\n\n/*\n** Iterate through all phrase nodes in an FTS3 query, except those that\n** are part of a sub-tree that is the right-hand-side of a NOT operator.\n** For each phrase node found, the supplied callback function is invoked.\n**\n** If the callback function returns anything other than SQLITE_OK, \n** the iteration is abandoned and the error code returned immediately.\n** Otherwise, SQLITE_OK is returned after a callback has been made for\n** all eligible phrase nodes.\n*/\nstatic int fts3ExprIterate(\n  Fts3Expr *pExpr,                /* Expression to iterate phrases of */\n  int (*x)(Fts3Expr*,int,void*),  /* Callback function to invoke for phrases */\n  void *pCtx                      /* Second argument to pass to callback */\n){\n  int iPhrase = 0;                /* Variable used as the phrase counter */\n  return fts3ExprIterate2(pExpr, &iPhrase, x, pCtx);\n}\n\n\n/*\n** This is an fts3ExprIterate() callback used while loading the doclists\n** for each phrase into Fts3Expr.aDoclist[]/nDoclist. See also\n** fts3ExprLoadDoclists().\n*/\nstatic int fts3ExprLoadDoclistsCb(Fts3Expr *pExpr, int iPhrase, void *ctx){\n  int rc = SQLITE_OK;\n  Fts3Phrase *pPhrase = pExpr->pPhrase;\n  LoadDoclistCtx *p = (LoadDoclistCtx *)ctx;\n\n  UNUSED_PARAMETER(iPhrase);\n\n  p->nPhrase++;\n  p->nToken += pPhrase->nToken;\n\n  return rc;\n}\n\n/*\n** Load the doclists for each phrase in the query associated with FTS3 cursor\n** pCsr. \n**\n** If pnPhrase is not NULL, then *pnPhrase is set to the number of matchable \n** phrases in the expression (all phrases except those directly or \n** indirectly descended from the right-hand-side of a NOT operator). If \n** pnToken is not NULL, then it is set to the number of tokens in all\n** matchable phrases of the expression.\n*/\nstatic int fts3ExprLoadDoclists(\n  Fts3Cursor *pCsr,               /* Fts3 cursor for current query */\n  int *pnPhrase,                  /* OUT: Number of phrases in query */\n  int *pnToken                    /* OUT: Number of tokens in query */\n){\n  int rc;                         /* Return Code */\n  LoadDoclistCtx sCtx = {0,0,0};  /* Context for fts3ExprIterate() */\n  sCtx.pCsr = pCsr;\n  rc = fts3ExprIterate(pCsr->pExpr, fts3ExprLoadDoclistsCb, (void *)&sCtx);\n  if( pnPhrase ) *pnPhrase = sCtx.nPhrase;\n  if( pnToken ) *pnToken = sCtx.nToken;\n  return rc;\n}\n\nstatic int fts3ExprPhraseCountCb(Fts3Expr *pExpr, int iPhrase, void *ctx){\n  (*(int *)ctx)++;\n  pExpr->iPhrase = iPhrase;\n  return SQLITE_OK;\n}\nstatic int fts3ExprPhraseCount(Fts3Expr *pExpr){\n  int nPhrase = 0;\n  (void)fts3ExprIterate(pExpr, fts3ExprPhraseCountCb, (void *)&nPhrase);\n  return nPhrase;\n}\n\n/*\n** Advance the position list iterator specified by the first two \n** arguments so that it points to the first element with a value greater\n** than or equal to parameter iNext.\n*/\nstatic void fts3SnippetAdvance(char **ppIter, int *piIter, int iNext){\n  char *pIter = *ppIter;\n  if( pIter ){\n    int iIter = *piIter;\n\n    while( iIter<iNext ){\n      if( 0==(*pIter & 0xFE) ){\n        iIter = -1;\n        pIter = 0;\n        break;\n      }\n      fts3GetDeltaPosition(&pIter, &iIter);\n    }\n\n    *piIter = iIter;\n    *ppIter = pIter;\n  }\n}\n\n/*\n** Advance the snippet iterator to the next candidate snippet.\n*/\nstatic int fts3SnippetNextCandidate(SnippetIter *pIter){\n  int i;                          /* Loop counter */\n\n  if( pIter->iCurrent<0 ){\n    /* The SnippetIter object has just been initialized. The first snippet\n    ** candidate always starts at offset 0 (even if this candidate has a\n    ** score of 0.0).\n    */\n    pIter->iCurrent = 0;\n\n    /* Advance the 'head' iterator of each phrase to the first offset that\n    ** is greater than or equal to (iNext+nSnippet).\n    */\n    for(i=0; i<pIter->nPhrase; i++){\n      SnippetPhrase *pPhrase = &pIter->aPhrase[i];\n      fts3SnippetAdvance(&pPhrase->pHead, &pPhrase->iHead, pIter->nSnippet);\n    }\n  }else{\n    int iStart;\n    int iEnd = 0x7FFFFFFF;\n\n    for(i=0; i<pIter->nPhrase; i++){\n      SnippetPhrase *pPhrase = &pIter->aPhrase[i];\n      if( pPhrase->pHead && pPhrase->iHead<iEnd ){\n        iEnd = pPhrase->iHead;\n      }\n    }\n    if( iEnd==0x7FFFFFFF ){\n      return 1;\n    }\n\n    pIter->iCurrent = iStart = iEnd - pIter->nSnippet + 1;\n    for(i=0; i<pIter->nPhrase; i++){\n      SnippetPhrase *pPhrase = &pIter->aPhrase[i];\n      fts3SnippetAdvance(&pPhrase->pHead, &pPhrase->iHead, iEnd+1);\n      fts3SnippetAdvance(&pPhrase->pTail, &pPhrase->iTail, iStart);\n    }\n  }\n\n  return 0;\n}\n\n/*\n** Retrieve information about the current candidate snippet of snippet \n** iterator pIter.\n*/\nstatic void fts3SnippetDetails(\n  SnippetIter *pIter,             /* Snippet iterator */\n  u64 mCovered,                   /* Bitmask of phrases already covered */\n  int *piToken,                   /* OUT: First token of proposed snippet */\n  int *piScore,                   /* OUT: \"Score\" for this snippet */\n  u64 *pmCover,                   /* OUT: Bitmask of phrases covered */\n  u64 *pmHighlight                /* OUT: Bitmask of terms to highlight */\n){\n  int iStart = pIter->iCurrent;   /* First token of snippet */\n  int iScore = 0;                 /* Score of this snippet */\n  int i;                          /* Loop counter */\n  u64 mCover = 0;                 /* Mask of phrases covered by this snippet */\n  u64 mHighlight = 0;             /* Mask of tokens to highlight in snippet */\n\n  for(i=0; i<pIter->nPhrase; i++){\n    SnippetPhrase *pPhrase = &pIter->aPhrase[i];\n    if( pPhrase->pTail ){\n      char *pCsr = pPhrase->pTail;\n      int iCsr = pPhrase->iTail;\n\n      while( iCsr<(iStart+pIter->nSnippet) ){\n        int j;\n        u64 mPhrase = (u64)1 << i;\n        u64 mPos = (u64)1 << (iCsr - iStart);\n        assert( iCsr>=iStart && (iCsr - iStart)<=64 );\n        assert( i>=0 && i<=64 );\n        if( (mCover|mCovered)&mPhrase ){\n          iScore++;\n        }else{\n          iScore += 1000;\n        }\n        mCover |= mPhrase;\n\n        for(j=0; j<pPhrase->nToken; j++){\n          mHighlight |= (mPos>>j);\n        }\n\n        if( 0==(*pCsr & 0x0FE) ) break;\n        fts3GetDeltaPosition(&pCsr, &iCsr);\n      }\n    }\n  }\n\n  /* Set the output variables before returning. */\n  *piToken = iStart;\n  *piScore = iScore;\n  *pmCover = mCover;\n  *pmHighlight = mHighlight;\n}\n\n/*\n** This function is an fts3ExprIterate() callback used by fts3BestSnippet().\n** Each invocation populates an element of the SnippetIter.aPhrase[] array.\n*/\nstatic int fts3SnippetFindPositions(Fts3Expr *pExpr, int iPhrase, void *ctx){\n  SnippetIter *p = (SnippetIter *)ctx;\n  SnippetPhrase *pPhrase = &p->aPhrase[iPhrase];\n  char *pCsr;\n  int rc;\n\n  pPhrase->nToken = pExpr->pPhrase->nToken;\n  rc = sqlite3Fts3EvalPhrasePoslist(p->pCsr, pExpr, p->iCol, &pCsr);\n  assert( rc==SQLITE_OK || pCsr==0 );\n  if( pCsr ){\n    int iFirst = 0;\n    pPhrase->pList = pCsr;\n    fts3GetDeltaPosition(&pCsr, &iFirst);\n    if( iFirst<0 ){\n      rc = FTS_CORRUPT_VTAB;\n    }else{\n      pPhrase->pHead = pCsr;\n      pPhrase->pTail = pCsr;\n      pPhrase->iHead = iFirst;\n      pPhrase->iTail = iFirst;\n    }\n  }else{\n    assert( rc!=SQLITE_OK || (\n       pPhrase->pList==0 && pPhrase->pHead==0 && pPhrase->pTail==0 \n    ));\n  }\n\n  return rc;\n}\n\n/*\n** Select the fragment of text consisting of nFragment contiguous tokens \n** from column iCol that represent the \"best\" snippet. The best snippet\n** is the snippet with the highest score, where scores are calculated\n** by adding:\n**\n**   (a) +1 point for each occurrence of a matchable phrase in the snippet.\n**\n**   (b) +1000 points for the first occurrence of each matchable phrase in \n**       the snippet for which the corresponding mCovered bit is not set.\n**\n** The selected snippet parameters are stored in structure *pFragment before\n** returning. The score of the selected snippet is stored in *piScore\n** before returning.\n*/\nstatic int fts3BestSnippet(\n  int nSnippet,                   /* Desired snippet length */\n  Fts3Cursor *pCsr,               /* Cursor to create snippet for */\n  int iCol,                       /* Index of column to create snippet from */\n  u64 mCovered,                   /* Mask of phrases already covered */\n  u64 *pmSeen,                    /* IN/OUT: Mask of phrases seen */\n  SnippetFragment *pFragment,     /* OUT: Best snippet found */\n  int *piScore                    /* OUT: Score of snippet pFragment */\n){\n  int rc;                         /* Return Code */\n  int nList;                      /* Number of phrases in expression */\n  SnippetIter sIter;              /* Iterates through snippet candidates */\n  sqlite3_int64 nByte;            /* Number of bytes of space to allocate */\n  int iBestScore = -1;            /* Best snippet score found so far */\n  int i;                          /* Loop counter */\n\n  memset(&sIter, 0, sizeof(sIter));\n\n  /* Iterate through the phrases in the expression to count them. The same\n  ** callback makes sure the doclists are loaded for each phrase.\n  */\n  rc = fts3ExprLoadDoclists(pCsr, &nList, 0);\n  if( rc!=SQLITE_OK ){\n    return rc;\n  }\n\n  /* Now that it is known how many phrases there are, allocate and zero\n  ** the required space using malloc().\n  */\n  nByte = sizeof(SnippetPhrase) * nList;\n  sIter.aPhrase = (SnippetPhrase *)sqlite3_malloc64(nByte);\n  if( !sIter.aPhrase ){\n    return SQLITE_NOMEM;\n  }\n  memset(sIter.aPhrase, 0, nByte);\n\n  /* Initialize the contents of the SnippetIter object. Then iterate through\n  ** the set of phrases in the expression to populate the aPhrase[] array.\n  */\n  sIter.pCsr = pCsr;\n  sIter.iCol = iCol;\n  sIter.nSnippet = nSnippet;\n  sIter.nPhrase = nList;\n  sIter.iCurrent = -1;\n  rc = fts3ExprIterate(pCsr->pExpr, fts3SnippetFindPositions, (void*)&sIter);\n  if( rc==SQLITE_OK ){\n\n    /* Set the *pmSeen output variable. */\n    for(i=0; i<nList; i++){\n      if( sIter.aPhrase[i].pHead ){\n        *pmSeen |= (u64)1 << i;\n      }\n    }\n\n    /* Loop through all candidate snippets. Store the best snippet in \n     ** *pFragment. Store its associated 'score' in iBestScore.\n     */\n    pFragment->iCol = iCol;\n    while( !fts3SnippetNextCandidate(&sIter) ){\n      int iPos;\n      int iScore;\n      u64 mCover;\n      u64 mHighlite;\n      fts3SnippetDetails(&sIter, mCovered, &iPos, &iScore, &mCover,&mHighlite);\n      assert( iScore>=0 );\n      if( iScore>iBestScore ){\n        pFragment->iPos = iPos;\n        pFragment->hlmask = mHighlite;\n        pFragment->covered = mCover;\n        iBestScore = iScore;\n      }\n    }\n\n    *piScore = iBestScore;\n  }\n  sqlite3_free(sIter.aPhrase);\n  return rc;\n}\n\n\n/*\n** Append a string to the string-buffer passed as the first argument.\n**\n** If nAppend is negative, then the length of the string zAppend is\n** determined using strlen().\n*/\nstatic int fts3StringAppend(\n  StrBuffer *pStr,                /* Buffer to append to */\n  const char *zAppend,            /* Pointer to data to append to buffer */\n  int nAppend                     /* Size of zAppend in bytes (or -1) */\n){\n  if( nAppend<0 ){\n    nAppend = (int)strlen(zAppend);\n  }\n\n  /* If there is insufficient space allocated at StrBuffer.z, use realloc()\n  ** to grow the buffer until so that it is big enough to accomadate the\n  ** appended data.\n  */\n  if( pStr->n+nAppend+1>=pStr->nAlloc ){\n    sqlite3_int64 nAlloc = pStr->nAlloc+(sqlite3_int64)nAppend+100;\n    char *zNew = sqlite3_realloc64(pStr->z, nAlloc);\n    if( !zNew ){\n      return SQLITE_NOMEM;\n    }\n    pStr->z = zNew;\n    pStr->nAlloc = nAlloc;\n  }\n  assert( pStr->z!=0 && (pStr->nAlloc >= pStr->n+nAppend+1) );\n\n  /* Append the data to the string buffer. */\n  memcpy(&pStr->z[pStr->n], zAppend, nAppend);\n  pStr->n += nAppend;\n  pStr->z[pStr->n] = '\\0';\n\n  return SQLITE_OK;\n}\n\n/*\n** The fts3BestSnippet() function often selects snippets that end with a\n** query term. That is, the final term of the snippet is always a term\n** that requires highlighting. For example, if 'X' is a highlighted term\n** and '.' is a non-highlighted term, BestSnippet() may select:\n**\n**     ........X.....X\n**\n** This function \"shifts\" the beginning of the snippet forward in the \n** document so that there are approximately the same number of \n** non-highlighted terms to the right of the final highlighted term as there\n** are to the left of the first highlighted term. For example, to this:\n**\n**     ....X.....X....\n**\n** This is done as part of extracting the snippet text, not when selecting\n** the snippet. Snippet selection is done based on doclists only, so there\n** is no way for fts3BestSnippet() to know whether or not the document \n** actually contains terms that follow the final highlighted term. \n*/\nstatic int fts3SnippetShift(\n  Fts3Table *pTab,                /* FTS3 table snippet comes from */\n  int iLangid,                    /* Language id to use in tokenizing */\n  int nSnippet,                   /* Number of tokens desired for snippet */\n  const char *zDoc,               /* Document text to extract snippet from */\n  int nDoc,                       /* Size of buffer zDoc in bytes */\n  int *piPos,                     /* IN/OUT: First token of snippet */\n  u64 *pHlmask                    /* IN/OUT: Mask of tokens to highlight */\n){\n  u64 hlmask = *pHlmask;          /* Local copy of initial highlight-mask */\n\n  if( hlmask ){\n    int nLeft;                    /* Tokens to the left of first highlight */\n    int nRight;                   /* Tokens to the right of last highlight */\n    int nDesired;                 /* Ideal number of tokens to shift forward */\n\n    for(nLeft=0; !(hlmask & ((u64)1 << nLeft)); nLeft++);\n    for(nRight=0; !(hlmask & ((u64)1 << (nSnippet-1-nRight))); nRight++);\n    assert( (nSnippet-1-nRight)<=63 && (nSnippet-1-nRight)>=0 );\n    nDesired = (nLeft-nRight)/2;\n\n    /* Ideally, the start of the snippet should be pushed forward in the\n    ** document nDesired tokens. This block checks if there are actually\n    ** nDesired tokens to the right of the snippet. If so, *piPos and\n    ** *pHlMask are updated to shift the snippet nDesired tokens to the\n    ** right. Otherwise, the snippet is shifted by the number of tokens\n    ** available.\n    */\n    if( nDesired>0 ){\n      int nShift;                 /* Number of tokens to shift snippet by */\n      int iCurrent = 0;           /* Token counter */\n      int rc;                     /* Return Code */\n      sqlite3_tokenizer_module *pMod;\n      sqlite3_tokenizer_cursor *pC;\n      pMod = (sqlite3_tokenizer_module *)pTab->pTokenizer->pModule;\n\n      /* Open a cursor on zDoc/nDoc. Check if there are (nSnippet+nDesired)\n      ** or more tokens in zDoc/nDoc.\n      */\n      rc = sqlite3Fts3OpenTokenizer(pTab->pTokenizer, iLangid, zDoc, nDoc, &pC);\n      if( rc!=SQLITE_OK ){\n        return rc;\n      }\n      while( rc==SQLITE_OK && iCurrent<(nSnippet+nDesired) ){\n        const char *ZDUMMY; int DUMMY1 = 0, DUMMY2 = 0, DUMMY3 = 0;\n        rc = pMod->xNext(pC, &ZDUMMY, &DUMMY1, &DUMMY2, &DUMMY3, &iCurrent);\n      }\n      pMod->xClose(pC);\n      if( rc!=SQLITE_OK && rc!=SQLITE_DONE ){ return rc; }\n\n      nShift = (rc==SQLITE_DONE)+iCurrent-nSnippet;\n      assert( nShift<=nDesired );\n      if( nShift>0 ){\n        *piPos += nShift;\n        *pHlmask = hlmask >> nShift;\n      }\n    }\n  }\n  return SQLITE_OK;\n}\n\n/*\n** Extract the snippet text for fragment pFragment from cursor pCsr and\n** append it to string buffer pOut.\n*/\nstatic int fts3SnippetText(\n  Fts3Cursor *pCsr,               /* FTS3 Cursor */\n  SnippetFragment *pFragment,     /* Snippet to extract */\n  int iFragment,                  /* Fragment number */\n  int isLast,                     /* True for final fragment in snippet */\n  int nSnippet,                   /* Number of tokens in extracted snippet */\n  const char *zOpen,              /* String inserted before highlighted term */\n  const char *zClose,             /* String inserted after highlighted term */\n  const char *zEllipsis,          /* String inserted between snippets */\n  StrBuffer *pOut                 /* Write output here */\n){\n  Fts3Table *pTab = (Fts3Table *)pCsr->base.pVtab;\n  int rc;                         /* Return code */\n  const char *zDoc;               /* Document text to extract snippet from */\n  int nDoc;                       /* Size of zDoc in bytes */\n  int iCurrent = 0;               /* Current token number of document */\n  int iEnd = 0;                   /* Byte offset of end of current token */\n  int isShiftDone = 0;            /* True after snippet is shifted */\n  int iPos = pFragment->iPos;     /* First token of snippet */\n  u64 hlmask = pFragment->hlmask; /* Highlight-mask for snippet */\n  int iCol = pFragment->iCol+1;   /* Query column to extract text from */\n  sqlite3_tokenizer_module *pMod; /* Tokenizer module methods object */\n  sqlite3_tokenizer_cursor *pC;   /* Tokenizer cursor open on zDoc/nDoc */\n  \n  zDoc = (const char *)sqlite3_column_text(pCsr->pStmt, iCol);\n  if( zDoc==0 ){\n    if( sqlite3_column_type(pCsr->pStmt, iCol)!=SQLITE_NULL ){\n      return SQLITE_NOMEM;\n    }\n    return SQLITE_OK;\n  }\n  nDoc = sqlite3_column_bytes(pCsr->pStmt, iCol);\n\n  /* Open a token cursor on the document. */\n  pMod = (sqlite3_tokenizer_module *)pTab->pTokenizer->pModule;\n  rc = sqlite3Fts3OpenTokenizer(pTab->pTokenizer, pCsr->iLangid, zDoc,nDoc,&pC);\n  if( rc!=SQLITE_OK ){\n    return rc;\n  }\n\n  while( rc==SQLITE_OK ){\n    const char *ZDUMMY;           /* Dummy argument used with tokenizer */\n    int DUMMY1 = -1;              /* Dummy argument used with tokenizer */\n    int iBegin = 0;               /* Offset in zDoc of start of token */\n    int iFin = 0;                 /* Offset in zDoc of end of token */\n    int isHighlight = 0;          /* True for highlighted terms */\n\n    /* Variable DUMMY1 is initialized to a negative value above. Elsewhere\n    ** in the FTS code the variable that the third argument to xNext points to\n    ** is initialized to zero before the first (*but not necessarily\n    ** subsequent*) call to xNext(). This is done for a particular application\n    ** that needs to know whether or not the tokenizer is being used for\n    ** snippet generation or for some other purpose.\n    **\n    ** Extreme care is required when writing code to depend on this\n    ** initialization. It is not a documented part of the tokenizer interface.\n    ** If a tokenizer is used directly by any code outside of FTS, this\n    ** convention might not be respected.  */\n    rc = pMod->xNext(pC, &ZDUMMY, &DUMMY1, &iBegin, &iFin, &iCurrent);\n    if( rc!=SQLITE_OK ){\n      if( rc==SQLITE_DONE ){\n        /* Special case - the last token of the snippet is also the last token\n        ** of the column. Append any punctuation that occurred between the end\n        ** of the previous token and the end of the document to the output. \n        ** Then break out of the loop. */\n        rc = fts3StringAppend(pOut, &zDoc[iEnd], -1);\n      }\n      break;\n    }\n    if( iCurrent<iPos ){ continue; }\n\n    if( !isShiftDone ){\n      int n = nDoc - iBegin;\n      rc = fts3SnippetShift(\n          pTab, pCsr->iLangid, nSnippet, &zDoc[iBegin], n, &iPos, &hlmask\n      );\n      isShiftDone = 1;\n\n      /* Now that the shift has been done, check if the initial \"...\" are\n      ** required. They are required if (a) this is not the first fragment,\n      ** or (b) this fragment does not begin at position 0 of its column. \n      */\n      if( rc==SQLITE_OK ){\n        if( iPos>0 || iFragment>0 ){\n          rc = fts3StringAppend(pOut, zEllipsis, -1);\n        }else if( iBegin ){\n          rc = fts3StringAppend(pOut, zDoc, iBegin);\n        }\n      }\n      if( rc!=SQLITE_OK || iCurrent<iPos ) continue;\n    }\n\n    if( iCurrent>=(iPos+nSnippet) ){\n      if( isLast ){\n        rc = fts3StringAppend(pOut, zEllipsis, -1);\n      }\n      break;\n    }\n\n    /* Set isHighlight to true if this term should be highlighted. */\n    isHighlight = (hlmask & ((u64)1 << (iCurrent-iPos)))!=0;\n\n    if( iCurrent>iPos ) rc = fts3StringAppend(pOut, &zDoc[iEnd], iBegin-iEnd);\n    if( rc==SQLITE_OK && isHighlight ) rc = fts3StringAppend(pOut, zOpen, -1);\n    if( rc==SQLITE_OK ) rc = fts3StringAppend(pOut, &zDoc[iBegin], iFin-iBegin);\n    if( rc==SQLITE_OK && isHighlight ) rc = fts3StringAppend(pOut, zClose, -1);\n\n    iEnd = iFin;\n  }\n\n  pMod->xClose(pC);\n  return rc;\n}\n\n\n/*\n** This function is used to count the entries in a column-list (a \n** delta-encoded list of term offsets within a single column of a single \n** row). When this function is called, *ppCollist should point to the\n** beginning of the first varint in the column-list (the varint that\n** contains the position of the first matching term in the column data).\n** Before returning, *ppCollist is set to point to the first byte after\n** the last varint in the column-list (either the 0x00 signifying the end\n** of the position-list, or the 0x01 that precedes the column number of\n** the next column in the position-list).\n**\n** The number of elements in the column-list is returned.\n*/\nstatic int fts3ColumnlistCount(char **ppCollist){\n  char *pEnd = *ppCollist;\n  char c = 0;\n  int nEntry = 0;\n\n  /* A column-list is terminated by either a 0x01 or 0x00. */\n  while( 0xFE & (*pEnd | c) ){\n    c = *pEnd++ & 0x80;\n    if( !c ) nEntry++;\n  }\n\n  *ppCollist = pEnd;\n  return nEntry;\n}\n\n/*\n** This function gathers 'y' or 'b' data for a single phrase.\n*/\nstatic int fts3ExprLHits(\n  Fts3Expr *pExpr,                /* Phrase expression node */\n  MatchInfo *p                    /* Matchinfo context */\n){\n  Fts3Table *pTab = (Fts3Table *)p->pCursor->base.pVtab;\n  int iStart;\n  Fts3Phrase *pPhrase = pExpr->pPhrase;\n  char *pIter = pPhrase->doclist.pList;\n  int iCol = 0;\n\n  assert( p->flag==FTS3_MATCHINFO_LHITS_BM || p->flag==FTS3_MATCHINFO_LHITS );\n  if( p->flag==FTS3_MATCHINFO_LHITS ){\n    iStart = pExpr->iPhrase * p->nCol;\n  }else{\n    iStart = pExpr->iPhrase * ((p->nCol + 31) / 32);\n  }\n\n  while( 1 ){\n    int nHit = fts3ColumnlistCount(&pIter);\n    if( (pPhrase->iColumn>=pTab->nColumn || pPhrase->iColumn==iCol) ){\n      if( p->flag==FTS3_MATCHINFO_LHITS ){\n        p->aMatchinfo[iStart + iCol] = (u32)nHit;\n      }else if( nHit ){\n        p->aMatchinfo[iStart + (iCol+1)/32] |= (1 << (iCol&0x1F));\n      }\n    }\n    assert( *pIter==0x00 || *pIter==0x01 );\n    if( *pIter!=0x01 ) break;\n    pIter++;\n    pIter += fts3GetVarint32(pIter, &iCol);\n    if( iCol>=p->nCol ) return FTS_CORRUPT_VTAB;\n  }\n  return SQLITE_OK;\n}\n\n/*\n** Gather the results for matchinfo directives 'y' and 'b'.\n*/\nstatic int fts3ExprLHitGather(\n  Fts3Expr *pExpr,\n  MatchInfo *p\n){\n  int rc = SQLITE_OK;\n  assert( (pExpr->pLeft==0)==(pExpr->pRight==0) );\n  if( pExpr->bEof==0 && pExpr->iDocid==p->pCursor->iPrevId ){\n    if( pExpr->pLeft ){\n      rc = fts3ExprLHitGather(pExpr->pLeft, p);\n      if( rc==SQLITE_OK ) rc = fts3ExprLHitGather(pExpr->pRight, p);\n    }else{\n      rc = fts3ExprLHits(pExpr, p);\n    }\n  }\n  return rc;\n}\n\n/*\n** fts3ExprIterate() callback used to collect the \"global\" matchinfo stats\n** for a single query. \n**\n** fts3ExprIterate() callback to load the 'global' elements of a\n** FTS3_MATCHINFO_HITS matchinfo array. The global stats are those elements \n** of the matchinfo array that are constant for all rows returned by the \n** current query.\n**\n** Argument pCtx is actually a pointer to a struct of type MatchInfo. This\n** function populates Matchinfo.aMatchinfo[] as follows:\n**\n**   for(iCol=0; iCol<nCol; iCol++){\n**     aMatchinfo[3*iPhrase*nCol + 3*iCol + 1] = X;\n**     aMatchinfo[3*iPhrase*nCol + 3*iCol + 2] = Y;\n**   }\n**\n** where X is the number of matches for phrase iPhrase is column iCol of all\n** rows of the table. Y is the number of rows for which column iCol contains\n** at least one instance of phrase iPhrase.\n**\n** If the phrase pExpr consists entirely of deferred tokens, then all X and\n** Y values are set to nDoc, where nDoc is the number of documents in the \n** file system. This is done because the full-text index doclist is required\n** to calculate these values properly, and the full-text index doclist is\n** not available for deferred tokens.\n*/\nstatic int fts3ExprGlobalHitsCb(\n  Fts3Expr *pExpr,                /* Phrase expression node */\n  int iPhrase,                    /* Phrase number (numbered from zero) */\n  void *pCtx                      /* Pointer to MatchInfo structure */\n){\n  MatchInfo *p = (MatchInfo *)pCtx;\n  return sqlite3Fts3EvalPhraseStats(\n      p->pCursor, pExpr, &p->aMatchinfo[3*iPhrase*p->nCol]\n  );\n}\n\n/*\n** fts3ExprIterate() callback used to collect the \"local\" part of the\n** FTS3_MATCHINFO_HITS array. The local stats are those elements of the \n** array that are different for each row returned by the query.\n*/\nstatic int fts3ExprLocalHitsCb(\n  Fts3Expr *pExpr,                /* Phrase expression node */\n  int iPhrase,                    /* Phrase number */\n  void *pCtx                      /* Pointer to MatchInfo structure */\n){\n  int rc = SQLITE_OK;\n  MatchInfo *p = (MatchInfo *)pCtx;\n  int iStart = iPhrase * p->nCol * 3;\n  int i;\n\n  for(i=0; i<p->nCol && rc==SQLITE_OK; i++){\n    char *pCsr;\n    rc = sqlite3Fts3EvalPhrasePoslist(p->pCursor, pExpr, i, &pCsr);\n    if( pCsr ){\n      p->aMatchinfo[iStart+i*3] = fts3ColumnlistCount(&pCsr);\n    }else{\n      p->aMatchinfo[iStart+i*3] = 0;\n    }\n  }\n\n  return rc;\n}\n\nstatic int fts3MatchinfoCheck(\n  Fts3Table *pTab, \n  char cArg,\n  char **pzErr\n){\n  if( (cArg==FTS3_MATCHINFO_NPHRASE)\n   || (cArg==FTS3_MATCHINFO_NCOL)\n   || (cArg==FTS3_MATCHINFO_NDOC && pTab->bFts4)\n   || (cArg==FTS3_MATCHINFO_AVGLENGTH && pTab->bFts4)\n   || (cArg==FTS3_MATCHINFO_LENGTH && pTab->bHasDocsize)\n   || (cArg==FTS3_MATCHINFO_LCS)\n   || (cArg==FTS3_MATCHINFO_HITS)\n   || (cArg==FTS3_MATCHINFO_LHITS)\n   || (cArg==FTS3_MATCHINFO_LHITS_BM)\n  ){\n    return SQLITE_OK;\n  }\n  sqlite3Fts3ErrMsg(pzErr, \"unrecognized matchinfo request: %c\", cArg);\n  return SQLITE_ERROR;\n}\n\nstatic int fts3MatchinfoSize(MatchInfo *pInfo, char cArg){\n  int nVal;                       /* Number of integers output by cArg */\n\n  switch( cArg ){\n    case FTS3_MATCHINFO_NDOC:\n    case FTS3_MATCHINFO_NPHRASE: \n    case FTS3_MATCHINFO_NCOL: \n      nVal = 1;\n      break;\n\n    case FTS3_MATCHINFO_AVGLENGTH:\n    case FTS3_MATCHINFO_LENGTH:\n    case FTS3_MATCHINFO_LCS:\n      nVal = pInfo->nCol;\n      break;\n\n    case FTS3_MATCHINFO_LHITS:\n      nVal = pInfo->nCol * pInfo->nPhrase;\n      break;\n\n    case FTS3_MATCHINFO_LHITS_BM:\n      nVal = pInfo->nPhrase * ((pInfo->nCol + 31) / 32);\n      break;\n\n    default:\n      assert( cArg==FTS3_MATCHINFO_HITS );\n      nVal = pInfo->nCol * pInfo->nPhrase * 3;\n      break;\n  }\n\n  return nVal;\n}\n\nstatic int fts3MatchinfoSelectDoctotal(\n  Fts3Table *pTab,\n  sqlite3_stmt **ppStmt,\n  sqlite3_int64 *pnDoc,\n  const char **paLen\n){\n  sqlite3_stmt *pStmt;\n  const char *a;\n  sqlite3_int64 nDoc;\n\n  if( !*ppStmt ){\n    int rc = sqlite3Fts3SelectDoctotal(pTab, ppStmt);\n    if( rc!=SQLITE_OK ) return rc;\n  }\n  pStmt = *ppStmt;\n  assert( sqlite3_data_count(pStmt)==1 );\n\n  a = sqlite3_column_blob(pStmt, 0);\n  a += sqlite3Fts3GetVarint(a, &nDoc);\n  if( nDoc==0 ) return FTS_CORRUPT_VTAB;\n  *pnDoc = (u32)nDoc;\n\n  if( paLen ) *paLen = a;\n  return SQLITE_OK;\n}\n\n/*\n** An instance of the following structure is used to store state while \n** iterating through a multi-column position-list corresponding to the\n** hits for a single phrase on a single row in order to calculate the\n** values for a matchinfo() FTS3_MATCHINFO_LCS request.\n*/\ntypedef struct LcsIterator LcsIterator;\nstruct LcsIterator {\n  Fts3Expr *pExpr;                /* Pointer to phrase expression */\n  int iPosOffset;                 /* Tokens count up to end of this phrase */\n  char *pRead;                    /* Cursor used to iterate through aDoclist */\n  int iPos;                       /* Current position */\n};\n\n/* \n** If LcsIterator.iCol is set to the following value, the iterator has\n** finished iterating through all offsets for all columns.\n*/\n#define LCS_ITERATOR_FINISHED 0x7FFFFFFF;\n\nstatic int fts3MatchinfoLcsCb(\n  Fts3Expr *pExpr,                /* Phrase expression node */\n  int iPhrase,                    /* Phrase number (numbered from zero) */\n  void *pCtx                      /* Pointer to MatchInfo structure */\n){\n  LcsIterator *aIter = (LcsIterator *)pCtx;\n  aIter[iPhrase].pExpr = pExpr;\n  return SQLITE_OK;\n}\n\n/*\n** Advance the iterator passed as an argument to the next position. Return\n** 1 if the iterator is at EOF or if it now points to the start of the\n** position list for the next column.\n*/\nstatic int fts3LcsIteratorAdvance(LcsIterator *pIter){\n  char *pRead = pIter->pRead;\n  sqlite3_int64 iRead;\n  int rc = 0;\n\n  pRead += sqlite3Fts3GetVarint(pRead, &iRead);\n  if( iRead==0 || iRead==1 ){\n    pRead = 0;\n    rc = 1;\n  }else{\n    pIter->iPos += (int)(iRead-2);\n  }\n\n  pIter->pRead = pRead;\n  return rc;\n}\n  \n/*\n** This function implements the FTS3_MATCHINFO_LCS matchinfo() flag. \n**\n** If the call is successful, the longest-common-substring lengths for each\n** column are written into the first nCol elements of the pInfo->aMatchinfo[] \n** array before returning. SQLITE_OK is returned in this case.\n**\n** Otherwise, if an error occurs, an SQLite error code is returned and the\n** data written to the first nCol elements of pInfo->aMatchinfo[] is \n** undefined.\n*/\nstatic int fts3MatchinfoLcs(Fts3Cursor *pCsr, MatchInfo *pInfo){\n  LcsIterator *aIter;\n  int i;\n  int iCol;\n  int nToken = 0;\n  int rc = SQLITE_OK;\n\n  /* Allocate and populate the array of LcsIterator objects. The array\n  ** contains one element for each matchable phrase in the query.\n  **/\n  aIter = sqlite3_malloc64(sizeof(LcsIterator) * pCsr->nPhrase);\n  if( !aIter ) return SQLITE_NOMEM;\n  memset(aIter, 0, sizeof(LcsIterator) * pCsr->nPhrase);\n  (void)fts3ExprIterate(pCsr->pExpr, fts3MatchinfoLcsCb, (void*)aIter);\n\n  for(i=0; i<pInfo->nPhrase; i++){\n    LcsIterator *pIter = &aIter[i];\n    nToken -= pIter->pExpr->pPhrase->nToken;\n    pIter->iPosOffset = nToken;\n  }\n\n  for(iCol=0; iCol<pInfo->nCol; iCol++){\n    int nLcs = 0;                 /* LCS value for this column */\n    int nLive = 0;                /* Number of iterators in aIter not at EOF */\n\n    for(i=0; i<pInfo->nPhrase; i++){\n      LcsIterator *pIt = &aIter[i];\n      rc = sqlite3Fts3EvalPhrasePoslist(pCsr, pIt->pExpr, iCol, &pIt->pRead);\n      if( rc!=SQLITE_OK ) goto matchinfo_lcs_out;\n      if( pIt->pRead ){\n        pIt->iPos = pIt->iPosOffset;\n        fts3LcsIteratorAdvance(pIt);\n        if( pIt->pRead==0 ){\n          rc = FTS_CORRUPT_VTAB;\n          goto matchinfo_lcs_out;\n        }\n        nLive++;\n      }\n    }\n\n    while( nLive>0 ){\n      LcsIterator *pAdv = 0;      /* The iterator to advance by one position */\n      int nThisLcs = 0;           /* LCS for the current iterator positions */\n\n      for(i=0; i<pInfo->nPhrase; i++){\n        LcsIterator *pIter = &aIter[i];\n        if( pIter->pRead==0 ){\n          /* This iterator is already at EOF for this column. */\n          nThisLcs = 0;\n        }else{\n          if( pAdv==0 || pIter->iPos<pAdv->iPos ){\n            pAdv = pIter;\n          }\n          if( nThisLcs==0 || pIter->iPos==pIter[-1].iPos ){\n            nThisLcs++;\n          }else{\n            nThisLcs = 1;\n          }\n          if( nThisLcs>nLcs ) nLcs = nThisLcs;\n        }\n      }\n      if( fts3LcsIteratorAdvance(pAdv) ) nLive--;\n    }\n\n    pInfo->aMatchinfo[iCol] = nLcs;\n  }\n\n matchinfo_lcs_out:\n  sqlite3_free(aIter);\n  return rc;\n}\n\n/*\n** Populate the buffer pInfo->aMatchinfo[] with an array of integers to\n** be returned by the matchinfo() function. Argument zArg contains the \n** format string passed as the second argument to matchinfo (or the\n** default value \"pcx\" if no second argument was specified). The format\n** string has already been validated and the pInfo->aMatchinfo[] array\n** is guaranteed to be large enough for the output.\n**\n** If bGlobal is true, then populate all fields of the matchinfo() output.\n** If it is false, then assume that those fields that do not change between\n** rows (i.e. FTS3_MATCHINFO_NPHRASE, NCOL, NDOC, AVGLENGTH and part of HITS)\n** have already been populated.\n**\n** Return SQLITE_OK if successful, or an SQLite error code if an error \n** occurs. If a value other than SQLITE_OK is returned, the state the\n** pInfo->aMatchinfo[] buffer is left in is undefined.\n*/\nstatic int fts3MatchinfoValues(\n  Fts3Cursor *pCsr,               /* FTS3 cursor object */\n  int bGlobal,                    /* True to grab the global stats */\n  MatchInfo *pInfo,               /* Matchinfo context object */\n  const char *zArg                /* Matchinfo format string */\n){\n  int rc = SQLITE_OK;\n  int i;\n  Fts3Table *pTab = (Fts3Table *)pCsr->base.pVtab;\n  sqlite3_stmt *pSelect = 0;\n\n  for(i=0; rc==SQLITE_OK && zArg[i]; i++){\n    pInfo->flag = zArg[i];\n    switch( zArg[i] ){\n      case FTS3_MATCHINFO_NPHRASE:\n        if( bGlobal ) pInfo->aMatchinfo[0] = pInfo->nPhrase;\n        break;\n\n      case FTS3_MATCHINFO_NCOL:\n        if( bGlobal ) pInfo->aMatchinfo[0] = pInfo->nCol;\n        break;\n        \n      case FTS3_MATCHINFO_NDOC:\n        if( bGlobal ){\n          sqlite3_int64 nDoc = 0;\n          rc = fts3MatchinfoSelectDoctotal(pTab, &pSelect, &nDoc, 0);\n          pInfo->aMatchinfo[0] = (u32)nDoc;\n        }\n        break;\n\n      case FTS3_MATCHINFO_AVGLENGTH: \n        if( bGlobal ){\n          sqlite3_int64 nDoc;     /* Number of rows in table */\n          const char *a;          /* Aggregate column length array */\n\n          rc = fts3MatchinfoSelectDoctotal(pTab, &pSelect, &nDoc, &a);\n          if( rc==SQLITE_OK ){\n            int iCol;\n            for(iCol=0; iCol<pInfo->nCol; iCol++){\n              u32 iVal;\n              sqlite3_int64 nToken;\n              a += sqlite3Fts3GetVarint(a, &nToken);\n              iVal = (u32)(((u32)(nToken&0xffffffff)+nDoc/2)/nDoc);\n              pInfo->aMatchinfo[iCol] = iVal;\n            }\n          }\n        }\n        break;\n\n      case FTS3_MATCHINFO_LENGTH: {\n        sqlite3_stmt *pSelectDocsize = 0;\n        rc = sqlite3Fts3SelectDocsize(pTab, pCsr->iPrevId, &pSelectDocsize);\n        if( rc==SQLITE_OK ){\n          int iCol;\n          const char *a = sqlite3_column_blob(pSelectDocsize, 0);\n          for(iCol=0; iCol<pInfo->nCol; iCol++){\n            sqlite3_int64 nToken;\n            a += sqlite3Fts3GetVarint(a, &nToken);\n            pInfo->aMatchinfo[iCol] = (u32)nToken;\n          }\n        }\n        sqlite3_reset(pSelectDocsize);\n        break;\n      }\n\n      case FTS3_MATCHINFO_LCS:\n        rc = fts3ExprLoadDoclists(pCsr, 0, 0);\n        if( rc==SQLITE_OK ){\n          rc = fts3MatchinfoLcs(pCsr, pInfo);\n        }\n        break;\n\n      case FTS3_MATCHINFO_LHITS_BM:\n      case FTS3_MATCHINFO_LHITS: {\n        int nZero = fts3MatchinfoSize(pInfo, zArg[i]) * sizeof(u32);\n        memset(pInfo->aMatchinfo, 0, nZero);\n        rc = fts3ExprLHitGather(pCsr->pExpr, pInfo);\n        break;\n      }\n\n      default: {\n        Fts3Expr *pExpr;\n        assert( zArg[i]==FTS3_MATCHINFO_HITS );\n        pExpr = pCsr->pExpr;\n        rc = fts3ExprLoadDoclists(pCsr, 0, 0);\n        if( rc!=SQLITE_OK ) break;\n        if( bGlobal ){\n          if( pCsr->pDeferred ){\n            rc = fts3MatchinfoSelectDoctotal(pTab, &pSelect, &pInfo->nDoc, 0);\n            if( rc!=SQLITE_OK ) break;\n          }\n          rc = fts3ExprIterate(pExpr, fts3ExprGlobalHitsCb,(void*)pInfo);\n          sqlite3Fts3EvalTestDeferred(pCsr, &rc);\n          if( rc!=SQLITE_OK ) break;\n        }\n        (void)fts3ExprIterate(pExpr, fts3ExprLocalHitsCb,(void*)pInfo);\n        break;\n      }\n    }\n\n    pInfo->aMatchinfo += fts3MatchinfoSize(pInfo, zArg[i]);\n  }\n\n  sqlite3_reset(pSelect);\n  return rc;\n}\n\n\n/*\n** Populate pCsr->aMatchinfo[] with data for the current row. The \n** 'matchinfo' data is an array of 32-bit unsigned integers (C type u32).\n*/\nstatic void fts3GetMatchinfo(\n  sqlite3_context *pCtx,        /* Return results here */\n  Fts3Cursor *pCsr,               /* FTS3 Cursor object */\n  const char *zArg                /* Second argument to matchinfo() function */\n){\n  MatchInfo sInfo;\n  Fts3Table *pTab = (Fts3Table *)pCsr->base.pVtab;\n  int rc = SQLITE_OK;\n  int bGlobal = 0;                /* Collect 'global' stats as well as local */\n\n  u32 *aOut = 0;\n  void (*xDestroyOut)(void*) = 0;\n\n  memset(&sInfo, 0, sizeof(MatchInfo));\n  sInfo.pCursor = pCsr;\n  sInfo.nCol = pTab->nColumn;\n\n  /* If there is cached matchinfo() data, but the format string for the \n  ** cache does not match the format string for this request, discard \n  ** the cached data. */\n  if( pCsr->pMIBuffer && strcmp(pCsr->pMIBuffer->zMatchinfo, zArg) ){\n    sqlite3Fts3MIBufferFree(pCsr->pMIBuffer);\n    pCsr->pMIBuffer = 0;\n  }\n\n  /* If Fts3Cursor.pMIBuffer is NULL, then this is the first time the\n  ** matchinfo function has been called for this query. In this case \n  ** allocate the array used to accumulate the matchinfo data and\n  ** initialize those elements that are constant for every row.\n  */\n  if( pCsr->pMIBuffer==0 ){\n    int nMatchinfo = 0;           /* Number of u32 elements in match-info */\n    int i;                        /* Used to iterate through zArg */\n\n    /* Determine the number of phrases in the query */\n    pCsr->nPhrase = fts3ExprPhraseCount(pCsr->pExpr);\n    sInfo.nPhrase = pCsr->nPhrase;\n\n    /* Determine the number of integers in the buffer returned by this call. */\n    for(i=0; zArg[i]; i++){\n      char *zErr = 0;\n      if( fts3MatchinfoCheck(pTab, zArg[i], &zErr) ){\n        sqlite3_result_error(pCtx, zErr, -1);\n        sqlite3_free(zErr);\n        return;\n      }\n      nMatchinfo += fts3MatchinfoSize(&sInfo, zArg[i]);\n    }\n\n    /* Allocate space for Fts3Cursor.aMatchinfo[] and Fts3Cursor.zMatchinfo. */\n    pCsr->pMIBuffer = fts3MIBufferNew(nMatchinfo, zArg);\n    if( !pCsr->pMIBuffer ) rc = SQLITE_NOMEM;\n\n    pCsr->isMatchinfoNeeded = 1;\n    bGlobal = 1;\n  }\n\n  if( rc==SQLITE_OK ){\n    xDestroyOut = fts3MIBufferAlloc(pCsr->pMIBuffer, &aOut);\n    if( xDestroyOut==0 ){\n      rc = SQLITE_NOMEM;\n    }\n  }\n\n  if( rc==SQLITE_OK ){\n    sInfo.aMatchinfo = aOut;\n    sInfo.nPhrase = pCsr->nPhrase;\n    rc = fts3MatchinfoValues(pCsr, bGlobal, &sInfo, zArg);\n    if( bGlobal ){\n      fts3MIBufferSetGlobal(pCsr->pMIBuffer);\n    }\n  }\n\n  if( rc!=SQLITE_OK ){\n    sqlite3_result_error_code(pCtx, rc);\n    if( xDestroyOut ) xDestroyOut(aOut);\n  }else{\n    int n = pCsr->pMIBuffer->nElem * sizeof(u32);\n    sqlite3_result_blob(pCtx, aOut, n, xDestroyOut);\n  }\n}\n\n/*\n** Implementation of snippet() function.\n*/\nSQLITE_PRIVATE void sqlite3Fts3Snippet(\n  sqlite3_context *pCtx,          /* SQLite function call context */\n  Fts3Cursor *pCsr,               /* Cursor object */\n  const char *zStart,             /* Snippet start text - \"<b>\" */\n  const char *zEnd,               /* Snippet end text - \"</b>\" */\n  const char *zEllipsis,          /* Snippet ellipsis text - \"<b>...</b>\" */\n  int iCol,                       /* Extract snippet from this column */\n  int nToken                      /* Approximate number of tokens in snippet */\n){\n  Fts3Table *pTab = (Fts3Table *)pCsr->base.pVtab;\n  int rc = SQLITE_OK;\n  int i;\n  StrBuffer res = {0, 0, 0};\n\n  /* The returned text includes up to four fragments of text extracted from\n  ** the data in the current row. The first iteration of the for(...) loop\n  ** below attempts to locate a single fragment of text nToken tokens in \n  ** size that contains at least one instance of all phrases in the query\n  ** expression that appear in the current row. If such a fragment of text\n  ** cannot be found, the second iteration of the loop attempts to locate\n  ** a pair of fragments, and so on.\n  */\n  int nSnippet = 0;               /* Number of fragments in this snippet */\n  SnippetFragment aSnippet[4];    /* Maximum of 4 fragments per snippet */\n  int nFToken = -1;               /* Number of tokens in each fragment */\n\n  if( !pCsr->pExpr ){\n    sqlite3_result_text(pCtx, \"\", 0, SQLITE_STATIC);\n    return;\n  }\n\n  /* Limit the snippet length to 64 tokens. */\n  if( nToken<-64 ) nToken = -64;\n  if( nToken>+64 ) nToken = +64;\n\n  for(nSnippet=1; 1; nSnippet++){\n\n    int iSnip;                    /* Loop counter 0..nSnippet-1 */\n    u64 mCovered = 0;             /* Bitmask of phrases covered by snippet */\n    u64 mSeen = 0;                /* Bitmask of phrases seen by BestSnippet() */\n\n    if( nToken>=0 ){\n      nFToken = (nToken+nSnippet-1) / nSnippet;\n    }else{\n      nFToken = -1 * nToken;\n    }\n\n    for(iSnip=0; iSnip<nSnippet; iSnip++){\n      int iBestScore = -1;        /* Best score of columns checked so far */\n      int iRead;                  /* Used to iterate through columns */\n      SnippetFragment *pFragment = &aSnippet[iSnip];\n\n      memset(pFragment, 0, sizeof(*pFragment));\n\n      /* Loop through all columns of the table being considered for snippets.\n      ** If the iCol argument to this function was negative, this means all\n      ** columns of the FTS3 table. Otherwise, only column iCol is considered.\n      */\n      for(iRead=0; iRead<pTab->nColumn; iRead++){\n        SnippetFragment sF = {0, 0, 0, 0};\n        int iS = 0;\n        if( iCol>=0 && iRead!=iCol ) continue;\n\n        /* Find the best snippet of nFToken tokens in column iRead. */\n        rc = fts3BestSnippet(nFToken, pCsr, iRead, mCovered, &mSeen, &sF, &iS);\n        if( rc!=SQLITE_OK ){\n          goto snippet_out;\n        }\n        if( iS>iBestScore ){\n          *pFragment = sF;\n          iBestScore = iS;\n        }\n      }\n\n      mCovered |= pFragment->covered;\n    }\n\n    /* If all query phrases seen by fts3BestSnippet() are present in at least\n    ** one of the nSnippet snippet fragments, break out of the loop.\n    */\n    assert( (mCovered&mSeen)==mCovered );\n    if( mSeen==mCovered || nSnippet==SizeofArray(aSnippet) ) break;\n  }\n\n  assert( nFToken>0 );\n\n  for(i=0; i<nSnippet && rc==SQLITE_OK; i++){\n    rc = fts3SnippetText(pCsr, &aSnippet[i], \n        i, (i==nSnippet-1), nFToken, zStart, zEnd, zEllipsis, &res\n    );\n  }\n\n snippet_out:\n  sqlite3Fts3SegmentsClose(pTab);\n  if( rc!=SQLITE_OK ){\n    sqlite3_result_error_code(pCtx, rc);\n    sqlite3_free(res.z);\n  }else{\n    sqlite3_result_text(pCtx, res.z, -1, sqlite3_free);\n  }\n}\n\n\ntypedef struct TermOffset TermOffset;\ntypedef struct TermOffsetCtx TermOffsetCtx;\n\nstruct TermOffset {\n  char *pList;                    /* Position-list */\n  int iPos;                       /* Position just read from pList */\n  int iOff;                       /* Offset of this term from read positions */\n};\n\nstruct TermOffsetCtx {\n  Fts3Cursor *pCsr;\n  int iCol;                       /* Column of table to populate aTerm for */\n  int iTerm;\n  sqlite3_int64 iDocid;\n  TermOffset *aTerm;\n};\n\n/*\n** This function is an fts3ExprIterate() callback used by sqlite3Fts3Offsets().\n*/\nstatic int fts3ExprTermOffsetInit(Fts3Expr *pExpr, int iPhrase, void *ctx){\n  TermOffsetCtx *p = (TermOffsetCtx *)ctx;\n  int nTerm;                      /* Number of tokens in phrase */\n  int iTerm;                      /* For looping through nTerm phrase terms */\n  char *pList;                    /* Pointer to position list for phrase */\n  int iPos = 0;                   /* First position in position-list */\n  int rc;\n\n  UNUSED_PARAMETER(iPhrase);\n  rc = sqlite3Fts3EvalPhrasePoslist(p->pCsr, pExpr, p->iCol, &pList);\n  nTerm = pExpr->pPhrase->nToken;\n  if( pList ){\n    fts3GetDeltaPosition(&pList, &iPos);\n    assert( iPos>=0 );\n  }\n\n  for(iTerm=0; iTerm<nTerm; iTerm++){\n    TermOffset *pT = &p->aTerm[p->iTerm++];\n    pT->iOff = nTerm-iTerm-1;\n    pT->pList = pList;\n    pT->iPos = iPos;\n  }\n\n  return rc;\n}\n\n/*\n** Implementation of offsets() function.\n*/\nSQLITE_PRIVATE void sqlite3Fts3Offsets(\n  sqlite3_context *pCtx,          /* SQLite function call context */\n  Fts3Cursor *pCsr                /* Cursor object */\n){\n  Fts3Table *pTab = (Fts3Table *)pCsr->base.pVtab;\n  sqlite3_tokenizer_module const *pMod = pTab->pTokenizer->pModule;\n  int rc;                         /* Return Code */\n  int nToken;                     /* Number of tokens in query */\n  int iCol;                       /* Column currently being processed */\n  StrBuffer res = {0, 0, 0};      /* Result string */\n  TermOffsetCtx sCtx;             /* Context for fts3ExprTermOffsetInit() */\n\n  if( !pCsr->pExpr ){\n    sqlite3_result_text(pCtx, \"\", 0, SQLITE_STATIC);\n    return;\n  }\n\n  memset(&sCtx, 0, sizeof(sCtx));\n  assert( pCsr->isRequireSeek==0 );\n\n  /* Count the number of terms in the query */\n  rc = fts3ExprLoadDoclists(pCsr, 0, &nToken);\n  if( rc!=SQLITE_OK ) goto offsets_out;\n\n  /* Allocate the array of TermOffset iterators. */\n  sCtx.aTerm = (TermOffset *)sqlite3_malloc64(sizeof(TermOffset)*nToken);\n  if( 0==sCtx.aTerm ){\n    rc = SQLITE_NOMEM;\n    goto offsets_out;\n  }\n  sCtx.iDocid = pCsr->iPrevId;\n  sCtx.pCsr = pCsr;\n\n  /* Loop through the table columns, appending offset information to \n  ** string-buffer res for each column.\n  */\n  for(iCol=0; iCol<pTab->nColumn; iCol++){\n    sqlite3_tokenizer_cursor *pC; /* Tokenizer cursor */\n    const char *ZDUMMY;           /* Dummy argument used with xNext() */\n    int NDUMMY = 0;               /* Dummy argument used with xNext() */\n    int iStart = 0;\n    int iEnd = 0;\n    int iCurrent = 0;\n    const char *zDoc;\n    int nDoc;\n\n    /* Initialize the contents of sCtx.aTerm[] for column iCol. There is \n    ** no way that this operation can fail, so the return code from\n    ** fts3ExprIterate() can be discarded.\n    */\n    sCtx.iCol = iCol;\n    sCtx.iTerm = 0;\n    (void)fts3ExprIterate(pCsr->pExpr, fts3ExprTermOffsetInit, (void*)&sCtx);\n\n    /* Retreive the text stored in column iCol. If an SQL NULL is stored \n    ** in column iCol, jump immediately to the next iteration of the loop.\n    ** If an OOM occurs while retrieving the data (this can happen if SQLite\n    ** needs to transform the data from utf-16 to utf-8), return SQLITE_NOMEM \n    ** to the caller. \n    */\n    zDoc = (const char *)sqlite3_column_text(pCsr->pStmt, iCol+1);\n    nDoc = sqlite3_column_bytes(pCsr->pStmt, iCol+1);\n    if( zDoc==0 ){\n      if( sqlite3_column_type(pCsr->pStmt, iCol+1)==SQLITE_NULL ){\n        continue;\n      }\n      rc = SQLITE_NOMEM;\n      goto offsets_out;\n    }\n\n    /* Initialize a tokenizer iterator to iterate through column iCol. */\n    rc = sqlite3Fts3OpenTokenizer(pTab->pTokenizer, pCsr->iLangid,\n        zDoc, nDoc, &pC\n    );\n    if( rc!=SQLITE_OK ) goto offsets_out;\n\n    rc = pMod->xNext(pC, &ZDUMMY, &NDUMMY, &iStart, &iEnd, &iCurrent);\n    while( rc==SQLITE_OK ){\n      int i;                      /* Used to loop through terms */\n      int iMinPos = 0x7FFFFFFF;   /* Position of next token */\n      TermOffset *pTerm = 0;      /* TermOffset associated with next token */\n\n      for(i=0; i<nToken; i++){\n        TermOffset *pT = &sCtx.aTerm[i];\n        if( pT->pList && (pT->iPos-pT->iOff)<iMinPos ){\n          iMinPos = pT->iPos-pT->iOff;\n          pTerm = pT;\n        }\n      }\n\n      if( !pTerm ){\n        /* All offsets for this column have been gathered. */\n        rc = SQLITE_DONE;\n      }else{\n        assert( iCurrent<=iMinPos );\n        if( 0==(0xFE&*pTerm->pList) ){\n          pTerm->pList = 0;\n        }else{\n          fts3GetDeltaPosition(&pTerm->pList, &pTerm->iPos);\n        }\n        while( rc==SQLITE_OK && iCurrent<iMinPos ){\n          rc = pMod->xNext(pC, &ZDUMMY, &NDUMMY, &iStart, &iEnd, &iCurrent);\n        }\n        if( rc==SQLITE_OK ){\n          char aBuffer[64];\n          sqlite3_snprintf(sizeof(aBuffer), aBuffer, \n              \"%d %d %d %d \", iCol, pTerm-sCtx.aTerm, iStart, iEnd-iStart\n          );\n          rc = fts3StringAppend(&res, aBuffer, -1);\n        }else if( rc==SQLITE_DONE && pTab->zContentTbl==0 ){\n          rc = FTS_CORRUPT_VTAB;\n        }\n      }\n    }\n    if( rc==SQLITE_DONE ){\n      rc = SQLITE_OK;\n    }\n\n    pMod->xClose(pC);\n    if( rc!=SQLITE_OK ) goto offsets_out;\n  }\n\n offsets_out:\n  sqlite3_free(sCtx.aTerm);\n  assert( rc!=SQLITE_DONE );\n  sqlite3Fts3SegmentsClose(pTab);\n  if( rc!=SQLITE_OK ){\n    sqlite3_result_error_code(pCtx,  rc);\n    sqlite3_free(res.z);\n  }else{\n    sqlite3_result_text(pCtx, res.z, res.n-1, sqlite3_free);\n  }\n  return;\n}\n\n/*\n** Implementation of matchinfo() function.\n*/\nSQLITE_PRIVATE void sqlite3Fts3Matchinfo(\n  sqlite3_context *pContext,      /* Function call context */\n  Fts3Cursor *pCsr,               /* FTS3 table cursor */\n  const char *zArg                /* Second arg to matchinfo() function */\n){\n  Fts3Table *pTab = (Fts3Table *)pCsr->base.pVtab;\n  const char *zFormat;\n\n  if( zArg ){\n    zFormat = zArg;\n  }else{\n    zFormat = FTS3_MATCHINFO_DEFAULT;\n  }\n\n  if( !pCsr->pExpr ){\n    sqlite3_result_blob(pContext, \"\", 0, SQLITE_STATIC);\n    return;\n  }else{\n    /* Retrieve matchinfo() data. */\n    fts3GetMatchinfo(pContext, pCsr, zFormat);\n    sqlite3Fts3SegmentsClose(pTab);\n  }\n}\n\n#endif\n\n/************** End of fts3_snippet.c ****************************************/\n/************** Begin file fts3_unicode.c ************************************/\n/*\n** 2012 May 24\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n******************************************************************************\n**\n** Implementation of the \"unicode\" full-text-search tokenizer.\n*/\n\n#ifndef SQLITE_DISABLE_FTS3_UNICODE\n\n/* #include \"fts3Int.h\" */\n#if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3)\n\n/* #include <assert.h> */\n/* #include <stdlib.h> */\n/* #include <stdio.h> */\n/* #include <string.h> */\n\n/* #include \"fts3_tokenizer.h\" */\n\n/*\n** The following two macros - READ_UTF8 and WRITE_UTF8 - have been copied\n** from the sqlite3 source file utf.c. If this file is compiled as part\n** of the amalgamation, they are not required.\n*/\n#ifndef SQLITE_AMALGAMATION\n\nstatic const unsigned char sqlite3Utf8Trans1[] = {\n  0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,\n  0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,\n  0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,\n  0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,\n  0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,\n  0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,\n  0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,\n  0x00, 0x01, 0x02, 0x03, 0x00, 0x01, 0x00, 0x00,\n};\n\n#define READ_UTF8(zIn, zTerm, c)                           \\\n  c = *(zIn++);                                            \\\n  if( c>=0xc0 ){                                           \\\n    c = sqlite3Utf8Trans1[c-0xc0];                         \\\n    while( zIn!=zTerm && (*zIn & 0xc0)==0x80 ){            \\\n      c = (c<<6) + (0x3f & *(zIn++));                      \\\n    }                                                      \\\n    if( c<0x80                                             \\\n        || (c&0xFFFFF800)==0xD800                          \\\n        || (c&0xFFFFFFFE)==0xFFFE ){  c = 0xFFFD; }        \\\n  }\n\n#define WRITE_UTF8(zOut, c) {                          \\\n  if( c<0x00080 ){                                     \\\n    *zOut++ = (u8)(c&0xFF);                            \\\n  }                                                    \\\n  else if( c<0x00800 ){                                \\\n    *zOut++ = 0xC0 + (u8)((c>>6)&0x1F);                \\\n    *zOut++ = 0x80 + (u8)(c & 0x3F);                   \\\n  }                                                    \\\n  else if( c<0x10000 ){                                \\\n    *zOut++ = 0xE0 + (u8)((c>>12)&0x0F);               \\\n    *zOut++ = 0x80 + (u8)((c>>6) & 0x3F);              \\\n    *zOut++ = 0x80 + (u8)(c & 0x3F);                   \\\n  }else{                                               \\\n    *zOut++ = 0xF0 + (u8)((c>>18) & 0x07);             \\\n    *zOut++ = 0x80 + (u8)((c>>12) & 0x3F);             \\\n    *zOut++ = 0x80 + (u8)((c>>6) & 0x3F);              \\\n    *zOut++ = 0x80 + (u8)(c & 0x3F);                   \\\n  }                                                    \\\n}\n\n#endif /* ifndef SQLITE_AMALGAMATION */\n\ntypedef struct unicode_tokenizer unicode_tokenizer;\ntypedef struct unicode_cursor unicode_cursor;\n\nstruct unicode_tokenizer {\n  sqlite3_tokenizer base;\n  int eRemoveDiacritic;\n  int nException;\n  int *aiException;\n};\n\nstruct unicode_cursor {\n  sqlite3_tokenizer_cursor base;\n  const unsigned char *aInput;    /* Input text being tokenized */\n  int nInput;                     /* Size of aInput[] in bytes */\n  int iOff;                       /* Current offset within aInput[] */\n  int iToken;                     /* Index of next token to be returned */\n  char *zToken;                   /* storage for current token */\n  int nAlloc;                     /* space allocated at zToken */\n};\n\n\n/*\n** Destroy a tokenizer allocated by unicodeCreate().\n*/\nstatic int unicodeDestroy(sqlite3_tokenizer *pTokenizer){\n  if( pTokenizer ){\n    unicode_tokenizer *p = (unicode_tokenizer *)pTokenizer;\n    sqlite3_free(p->aiException);\n    sqlite3_free(p);\n  }\n  return SQLITE_OK;\n}\n\n/*\n** As part of a tokenchars= or separators= option, the CREATE VIRTUAL TABLE\n** statement has specified that the tokenizer for this table shall consider\n** all characters in string zIn/nIn to be separators (if bAlnum==0) or\n** token characters (if bAlnum==1).\n**\n** For each codepoint in the zIn/nIn string, this function checks if the\n** sqlite3FtsUnicodeIsalnum() function already returns the desired result.\n** If so, no action is taken. Otherwise, the codepoint is added to the \n** unicode_tokenizer.aiException[] array. For the purposes of tokenization,\n** the return value of sqlite3FtsUnicodeIsalnum() is inverted for all\n** codepoints in the aiException[] array.\n**\n** If a standalone diacritic mark (one that sqlite3FtsUnicodeIsdiacritic()\n** identifies as a diacritic) occurs in the zIn/nIn string it is ignored.\n** It is not possible to change the behavior of the tokenizer with respect\n** to these codepoints.\n*/\nstatic int unicodeAddExceptions(\n  unicode_tokenizer *p,           /* Tokenizer to add exceptions to */\n  int bAlnum,                     /* Replace Isalnum() return value with this */\n  const char *zIn,                /* Array of characters to make exceptions */\n  int nIn                         /* Length of z in bytes */\n){\n  const unsigned char *z = (const unsigned char *)zIn;\n  const unsigned char *zTerm = &z[nIn];\n  unsigned int iCode;\n  int nEntry = 0;\n\n  assert( bAlnum==0 || bAlnum==1 );\n\n  while( z<zTerm ){\n    READ_UTF8(z, zTerm, iCode);\n    assert( (sqlite3FtsUnicodeIsalnum((int)iCode) & 0xFFFFFFFE)==0 );\n    if( sqlite3FtsUnicodeIsalnum((int)iCode)!=bAlnum \n     && sqlite3FtsUnicodeIsdiacritic((int)iCode)==0 \n    ){\n      nEntry++;\n    }\n  }\n\n  if( nEntry ){\n    int *aNew;                    /* New aiException[] array */\n    int nNew;                     /* Number of valid entries in array aNew[] */\n\n    aNew = sqlite3_realloc64(p->aiException,(p->nException+nEntry)*sizeof(int));\n    if( aNew==0 ) return SQLITE_NOMEM;\n    nNew = p->nException;\n\n    z = (const unsigned char *)zIn;\n    while( z<zTerm ){\n      READ_UTF8(z, zTerm, iCode);\n      if( sqlite3FtsUnicodeIsalnum((int)iCode)!=bAlnum \n       && sqlite3FtsUnicodeIsdiacritic((int)iCode)==0\n      ){\n        int i, j;\n        for(i=0; i<nNew && aNew[i]<(int)iCode; i++);\n        for(j=nNew; j>i; j--) aNew[j] = aNew[j-1];\n        aNew[i] = (int)iCode;\n        nNew++;\n      }\n    }\n    p->aiException = aNew;\n    p->nException = nNew;\n  }\n\n  return SQLITE_OK;\n}\n\n/*\n** Return true if the p->aiException[] array contains the value iCode.\n*/\nstatic int unicodeIsException(unicode_tokenizer *p, int iCode){\n  if( p->nException>0 ){\n    int *a = p->aiException;\n    int iLo = 0;\n    int iHi = p->nException-1;\n\n    while( iHi>=iLo ){\n      int iTest = (iHi + iLo) / 2;\n      if( iCode==a[iTest] ){\n        return 1;\n      }else if( iCode>a[iTest] ){\n        iLo = iTest+1;\n      }else{\n        iHi = iTest-1;\n      }\n    }\n  }\n\n  return 0;\n}\n\n/*\n** Return true if, for the purposes of tokenization, codepoint iCode is\n** considered a token character (not a separator).\n*/\nstatic int unicodeIsAlnum(unicode_tokenizer *p, int iCode){\n  assert( (sqlite3FtsUnicodeIsalnum(iCode) & 0xFFFFFFFE)==0 );\n  return sqlite3FtsUnicodeIsalnum(iCode) ^ unicodeIsException(p, iCode);\n}\n\n/*\n** Create a new tokenizer instance.\n*/\nstatic int unicodeCreate(\n  int nArg,                       /* Size of array argv[] */\n  const char * const *azArg,      /* Tokenizer creation arguments */\n  sqlite3_tokenizer **pp          /* OUT: New tokenizer handle */\n){\n  unicode_tokenizer *pNew;        /* New tokenizer object */\n  int i;\n  int rc = SQLITE_OK;\n\n  pNew = (unicode_tokenizer *) sqlite3_malloc(sizeof(unicode_tokenizer));\n  if( pNew==NULL ) return SQLITE_NOMEM;\n  memset(pNew, 0, sizeof(unicode_tokenizer));\n  pNew->eRemoveDiacritic = 1;\n\n  for(i=0; rc==SQLITE_OK && i<nArg; i++){\n    const char *z = azArg[i];\n    int n = (int)strlen(z);\n\n    if( n==19 && memcmp(\"remove_diacritics=1\", z, 19)==0 ){\n      pNew->eRemoveDiacritic = 1;\n    }\n    else if( n==19 && memcmp(\"remove_diacritics=0\", z, 19)==0 ){\n      pNew->eRemoveDiacritic = 0;\n    }\n    else if( n==19 && memcmp(\"remove_diacritics=2\", z, 19)==0 ){\n      pNew->eRemoveDiacritic = 2;\n    }\n    else if( n>=11 && memcmp(\"tokenchars=\", z, 11)==0 ){\n      rc = unicodeAddExceptions(pNew, 1, &z[11], n-11);\n    }\n    else if( n>=11 && memcmp(\"separators=\", z, 11)==0 ){\n      rc = unicodeAddExceptions(pNew, 0, &z[11], n-11);\n    }\n    else{\n      /* Unrecognized argument */\n      rc  = SQLITE_ERROR;\n    }\n  }\n\n  if( rc!=SQLITE_OK ){\n    unicodeDestroy((sqlite3_tokenizer *)pNew);\n    pNew = 0;\n  }\n  *pp = (sqlite3_tokenizer *)pNew;\n  return rc;\n}\n\n/*\n** Prepare to begin tokenizing a particular string.  The input\n** string to be tokenized is pInput[0..nBytes-1].  A cursor\n** used to incrementally tokenize this string is returned in \n** *ppCursor.\n*/\nstatic int unicodeOpen(\n  sqlite3_tokenizer *p,           /* The tokenizer */\n  const char *aInput,             /* Input string */\n  int nInput,                     /* Size of string aInput in bytes */\n  sqlite3_tokenizer_cursor **pp   /* OUT: New cursor object */\n){\n  unicode_cursor *pCsr;\n\n  pCsr = (unicode_cursor *)sqlite3_malloc(sizeof(unicode_cursor));\n  if( pCsr==0 ){\n    return SQLITE_NOMEM;\n  }\n  memset(pCsr, 0, sizeof(unicode_cursor));\n\n  pCsr->aInput = (const unsigned char *)aInput;\n  if( aInput==0 ){\n    pCsr->nInput = 0;\n  }else if( nInput<0 ){\n    pCsr->nInput = (int)strlen(aInput);\n  }else{\n    pCsr->nInput = nInput;\n  }\n\n  *pp = &pCsr->base;\n  UNUSED_PARAMETER(p);\n  return SQLITE_OK;\n}\n\n/*\n** Close a tokenization cursor previously opened by a call to\n** simpleOpen() above.\n*/\nstatic int unicodeClose(sqlite3_tokenizer_cursor *pCursor){\n  unicode_cursor *pCsr = (unicode_cursor *) pCursor;\n  sqlite3_free(pCsr->zToken);\n  sqlite3_free(pCsr);\n  return SQLITE_OK;\n}\n\n/*\n** Extract the next token from a tokenization cursor.  The cursor must\n** have been opened by a prior call to simpleOpen().\n*/\nstatic int unicodeNext(\n  sqlite3_tokenizer_cursor *pC,   /* Cursor returned by simpleOpen */\n  const char **paToken,           /* OUT: Token text */\n  int *pnToken,                   /* OUT: Number of bytes at *paToken */\n  int *piStart,                   /* OUT: Starting offset of token */\n  int *piEnd,                     /* OUT: Ending offset of token */\n  int *piPos                      /* OUT: Position integer of token */\n){\n  unicode_cursor *pCsr = (unicode_cursor *)pC;\n  unicode_tokenizer *p = ((unicode_tokenizer *)pCsr->base.pTokenizer);\n  unsigned int iCode = 0;\n  char *zOut;\n  const unsigned char *z = &pCsr->aInput[pCsr->iOff];\n  const unsigned char *zStart = z;\n  const unsigned char *zEnd;\n  const unsigned char *zTerm = &pCsr->aInput[pCsr->nInput];\n\n  /* Scan past any delimiter characters before the start of the next token.\n  ** Return SQLITE_DONE early if this takes us all the way to the end of \n  ** the input.  */\n  while( z<zTerm ){\n    READ_UTF8(z, zTerm, iCode);\n    if( unicodeIsAlnum(p, (int)iCode) ) break;\n    zStart = z;\n  }\n  if( zStart>=zTerm ) return SQLITE_DONE;\n\n  zOut = pCsr->zToken;\n  do {\n    int iOut;\n\n    /* Grow the output buffer if required. */\n    if( (zOut-pCsr->zToken)>=(pCsr->nAlloc-4) ){\n      char *zNew = sqlite3_realloc64(pCsr->zToken, pCsr->nAlloc+64);\n      if( !zNew ) return SQLITE_NOMEM;\n      zOut = &zNew[zOut - pCsr->zToken];\n      pCsr->zToken = zNew;\n      pCsr->nAlloc += 64;\n    }\n\n    /* Write the folded case of the last character read to the output */\n    zEnd = z;\n    iOut = sqlite3FtsUnicodeFold((int)iCode, p->eRemoveDiacritic);\n    if( iOut ){\n      WRITE_UTF8(zOut, iOut);\n    }\n\n    /* If the cursor is not at EOF, read the next character */\n    if( z>=zTerm ) break;\n    READ_UTF8(z, zTerm, iCode);\n  }while( unicodeIsAlnum(p, (int)iCode) \n       || sqlite3FtsUnicodeIsdiacritic((int)iCode)\n  );\n\n  /* Set the output variables and return. */\n  pCsr->iOff = (int)(z - pCsr->aInput);\n  *paToken = pCsr->zToken;\n  *pnToken = (int)(zOut - pCsr->zToken);\n  *piStart = (int)(zStart - pCsr->aInput);\n  *piEnd = (int)(zEnd - pCsr->aInput);\n  *piPos = pCsr->iToken++;\n  return SQLITE_OK;\n}\n\n/*\n** Set *ppModule to a pointer to the sqlite3_tokenizer_module \n** structure for the unicode tokenizer.\n*/\nSQLITE_PRIVATE void sqlite3Fts3UnicodeTokenizer(sqlite3_tokenizer_module const **ppModule){\n  static const sqlite3_tokenizer_module module = {\n    0,\n    unicodeCreate,\n    unicodeDestroy,\n    unicodeOpen,\n    unicodeClose,\n    unicodeNext,\n    0,\n  };\n  *ppModule = &module;\n}\n\n#endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3) */\n#endif /* ifndef SQLITE_DISABLE_FTS3_UNICODE */\n\n/************** End of fts3_unicode.c ****************************************/\n/************** Begin file fts3_unicode2.c ***********************************/\n/*\n** 2012-05-25\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n******************************************************************************\n*/\n\n/*\n** DO NOT EDIT THIS MACHINE GENERATED FILE.\n*/\n\n#ifndef SQLITE_DISABLE_FTS3_UNICODE\n#if defined(SQLITE_ENABLE_FTS3) || defined(SQLITE_ENABLE_FTS4)\n\n/* #include <assert.h> */\n\n/*\n** Return true if the argument corresponds to a unicode codepoint\n** classified as either a letter or a number. Otherwise false.\n**\n** The results are undefined if the value passed to this function\n** is less than zero.\n*/\nSQLITE_PRIVATE int sqlite3FtsUnicodeIsalnum(int c){\n  /* Each unsigned integer in the following array corresponds to a contiguous\n  ** range of unicode codepoints that are not either letters or numbers (i.e.\n  ** codepoints for which this function should return 0).\n  **\n  ** The most significant 22 bits in each 32-bit value contain the first \n  ** codepoint in the range. The least significant 10 bits are used to store\n  ** the size of the range (always at least 1). In other words, the value \n  ** ((C<<22) + N) represents a range of N codepoints starting with codepoint \n  ** C. It is not possible to represent a range larger than 1023 codepoints \n  ** using this format.\n  */\n  static const unsigned int aEntry[] = {\n    0x00000030, 0x0000E807, 0x00016C06, 0x0001EC2F, 0x0002AC07,\n    0x0002D001, 0x0002D803, 0x0002EC01, 0x0002FC01, 0x00035C01,\n    0x0003DC01, 0x000B0804, 0x000B480E, 0x000B9407, 0x000BB401,\n    0x000BBC81, 0x000DD401, 0x000DF801, 0x000E1002, 0x000E1C01,\n    0x000FD801, 0x00120808, 0x00156806, 0x00162402, 0x00163C01,\n    0x00164437, 0x0017CC02, 0x00180005, 0x00181816, 0x00187802,\n    0x00192C15, 0x0019A804, 0x0019C001, 0x001B5001, 0x001B580F,\n    0x001B9C07, 0x001BF402, 0x001C000E, 0x001C3C01, 0x001C4401,\n    0x001CC01B, 0x001E980B, 0x001FAC09, 0x001FD804, 0x00205804,\n    0x00206C09, 0x00209403, 0x0020A405, 0x0020C00F, 0x00216403,\n    0x00217801, 0x0023901B, 0x00240004, 0x0024E803, 0x0024F812,\n    0x00254407, 0x00258804, 0x0025C001, 0x00260403, 0x0026F001,\n    0x0026F807, 0x00271C02, 0x00272C03, 0x00275C01, 0x00278802,\n    0x0027C802, 0x0027E802, 0x00280403, 0x0028F001, 0x0028F805,\n    0x00291C02, 0x00292C03, 0x00294401, 0x0029C002, 0x0029D401,\n    0x002A0403, 0x002AF001, 0x002AF808, 0x002B1C03, 0x002B2C03,\n    0x002B8802, 0x002BC002, 0x002C0403, 0x002CF001, 0x002CF807,\n    0x002D1C02, 0x002D2C03, 0x002D5802, 0x002D8802, 0x002DC001,\n    0x002E0801, 0x002EF805, 0x002F1803, 0x002F2804, 0x002F5C01,\n    0x002FCC08, 0x00300403, 0x0030F807, 0x00311803, 0x00312804,\n    0x00315402, 0x00318802, 0x0031FC01, 0x00320802, 0x0032F001,\n    0x0032F807, 0x00331803, 0x00332804, 0x00335402, 0x00338802,\n    0x00340802, 0x0034F807, 0x00351803, 0x00352804, 0x00355C01,\n    0x00358802, 0x0035E401, 0x00360802, 0x00372801, 0x00373C06,\n    0x00375801, 0x00376008, 0x0037C803, 0x0038C401, 0x0038D007,\n    0x0038FC01, 0x00391C09, 0x00396802, 0x003AC401, 0x003AD006,\n    0x003AEC02, 0x003B2006, 0x003C041F, 0x003CD00C, 0x003DC417,\n    0x003E340B, 0x003E6424, 0x003EF80F, 0x003F380D, 0x0040AC14,\n    0x00412806, 0x00415804, 0x00417803, 0x00418803, 0x00419C07,\n    0x0041C404, 0x0042080C, 0x00423C01, 0x00426806, 0x0043EC01,\n    0x004D740C, 0x004E400A, 0x00500001, 0x0059B402, 0x005A0001,\n    0x005A6C02, 0x005BAC03, 0x005C4803, 0x005CC805, 0x005D4802,\n    0x005DC802, 0x005ED023, 0x005F6004, 0x005F7401, 0x0060000F,\n    0x0062A401, 0x0064800C, 0x0064C00C, 0x00650001, 0x00651002,\n    0x0066C011, 0x00672002, 0x00677822, 0x00685C05, 0x00687802,\n    0x0069540A, 0x0069801D, 0x0069FC01, 0x006A8007, 0x006AA006,\n    0x006C0005, 0x006CD011, 0x006D6823, 0x006E0003, 0x006E840D,\n    0x006F980E, 0x006FF004, 0x00709014, 0x0070EC05, 0x0071F802,\n    0x00730008, 0x00734019, 0x0073B401, 0x0073C803, 0x00770027,\n    0x0077F004, 0x007EF401, 0x007EFC03, 0x007F3403, 0x007F7403,\n    0x007FB403, 0x007FF402, 0x00800065, 0x0081A806, 0x0081E805,\n    0x00822805, 0x0082801A, 0x00834021, 0x00840002, 0x00840C04,\n    0x00842002, 0x00845001, 0x00845803, 0x00847806, 0x00849401,\n    0x00849C01, 0x0084A401, 0x0084B801, 0x0084E802, 0x00850005,\n    0x00852804, 0x00853C01, 0x00864264, 0x00900027, 0x0091000B,\n    0x0092704E, 0x00940200, 0x009C0475, 0x009E53B9, 0x00AD400A,\n    0x00B39406, 0x00B3BC03, 0x00B3E404, 0x00B3F802, 0x00B5C001,\n    0x00B5FC01, 0x00B7804F, 0x00B8C00C, 0x00BA001A, 0x00BA6C59,\n    0x00BC00D6, 0x00BFC00C, 0x00C00005, 0x00C02019, 0x00C0A807,\n    0x00C0D802, 0x00C0F403, 0x00C26404, 0x00C28001, 0x00C3EC01,\n    0x00C64002, 0x00C6580A, 0x00C70024, 0x00C8001F, 0x00C8A81E,\n    0x00C94001, 0x00C98020, 0x00CA2827, 0x00CB003F, 0x00CC0100,\n    0x01370040, 0x02924037, 0x0293F802, 0x02983403, 0x0299BC10,\n    0x029A7C01, 0x029BC008, 0x029C0017, 0x029C8002, 0x029E2402,\n    0x02A00801, 0x02A01801, 0x02A02C01, 0x02A08C09, 0x02A0D804,\n    0x02A1D004, 0x02A20002, 0x02A2D011, 0x02A33802, 0x02A38012,\n    0x02A3E003, 0x02A4980A, 0x02A51C0D, 0x02A57C01, 0x02A60004,\n    0x02A6CC1B, 0x02A77802, 0x02A8A40E, 0x02A90C01, 0x02A93002,\n    0x02A97004, 0x02A9DC03, 0x02A9EC01, 0x02AAC001, 0x02AAC803,\n    0x02AADC02, 0x02AAF802, 0x02AB0401, 0x02AB7802, 0x02ABAC07,\n    0x02ABD402, 0x02AF8C0B, 0x03600001, 0x036DFC02, 0x036FFC02,\n    0x037FFC01, 0x03EC7801, 0x03ECA401, 0x03EEC810, 0x03F4F802,\n    0x03F7F002, 0x03F8001A, 0x03F88007, 0x03F8C023, 0x03F95013,\n    0x03F9A004, 0x03FBFC01, 0x03FC040F, 0x03FC6807, 0x03FCEC06,\n    0x03FD6C0B, 0x03FF8007, 0x03FFA007, 0x03FFE405, 0x04040003,\n    0x0404DC09, 0x0405E411, 0x0406400C, 0x0407402E, 0x040E7C01,\n    0x040F4001, 0x04215C01, 0x04247C01, 0x0424FC01, 0x04280403,\n    0x04281402, 0x04283004, 0x0428E003, 0x0428FC01, 0x04294009,\n    0x0429FC01, 0x042CE407, 0x04400003, 0x0440E016, 0x04420003,\n    0x0442C012, 0x04440003, 0x04449C0E, 0x04450004, 0x04460003,\n    0x0446CC0E, 0x04471404, 0x045AAC0D, 0x0491C004, 0x05BD442E,\n    0x05BE3C04, 0x074000F6, 0x07440027, 0x0744A4B5, 0x07480046,\n    0x074C0057, 0x075B0401, 0x075B6C01, 0x075BEC01, 0x075C5401,\n    0x075CD401, 0x075D3C01, 0x075DBC01, 0x075E2401, 0x075EA401,\n    0x075F0C01, 0x07BBC002, 0x07C0002C, 0x07C0C064, 0x07C2800F,\n    0x07C2C40E, 0x07C3040F, 0x07C3440F, 0x07C4401F, 0x07C4C03C,\n    0x07C5C02B, 0x07C7981D, 0x07C8402B, 0x07C90009, 0x07C94002,\n    0x07CC0021, 0x07CCC006, 0x07CCDC46, 0x07CE0014, 0x07CE8025,\n    0x07CF1805, 0x07CF8011, 0x07D0003F, 0x07D10001, 0x07D108B6,\n    0x07D3E404, 0x07D4003E, 0x07D50004, 0x07D54018, 0x07D7EC46,\n    0x07D9140B, 0x07DA0046, 0x07DC0074, 0x38000401, 0x38008060,\n    0x380400F0,\n  };\n  static const unsigned int aAscii[4] = {\n    0xFFFFFFFF, 0xFC00FFFF, 0xF8000001, 0xF8000001,\n  };\n\n  if( (unsigned int)c<128 ){\n    return ( (aAscii[c >> 5] & ((unsigned int)1 << (c & 0x001F)))==0 );\n  }else if( (unsigned int)c<(1<<22) ){\n    unsigned int key = (((unsigned int)c)<<10) | 0x000003FF;\n    int iRes = 0;\n    int iHi = sizeof(aEntry)/sizeof(aEntry[0]) - 1;\n    int iLo = 0;\n    while( iHi>=iLo ){\n      int iTest = (iHi + iLo) / 2;\n      if( key >= aEntry[iTest] ){\n        iRes = iTest;\n        iLo = iTest+1;\n      }else{\n        iHi = iTest-1;\n      }\n    }\n    assert( aEntry[0]<key );\n    assert( key>=aEntry[iRes] );\n    return (((unsigned int)c) >= ((aEntry[iRes]>>10) + (aEntry[iRes]&0x3FF)));\n  }\n  return 1;\n}\n\n\n/*\n** If the argument is a codepoint corresponding to a lowercase letter\n** in the ASCII range with a diacritic added, return the codepoint\n** of the ASCII letter only. For example, if passed 235 - \"LATIN\n** SMALL LETTER E WITH DIAERESIS\" - return 65 (\"LATIN SMALL LETTER\n** E\"). The resuls of passing a codepoint that corresponds to an\n** uppercase letter are undefined.\n*/\nstatic int remove_diacritic(int c, int bComplex){\n  unsigned short aDia[] = {\n        0,  1797,  1848,  1859,  1891,  1928,  1940,  1995, \n     2024,  2040,  2060,  2110,  2168,  2206,  2264,  2286, \n     2344,  2383,  2472,  2488,  2516,  2596,  2668,  2732, \n     2782,  2842,  2894,  2954,  2984,  3000,  3028,  3336, \n     3456,  3696,  3712,  3728,  3744,  3766,  3832,  3896, \n     3912,  3928,  3944,  3968,  4008,  4040,  4056,  4106, \n     4138,  4170,  4202,  4234,  4266,  4296,  4312,  4344, \n     4408,  4424,  4442,  4472,  4488,  4504,  6148,  6198, \n     6264,  6280,  6360,  6429,  6505,  6529, 61448, 61468, \n    61512, 61534, 61592, 61610, 61642, 61672, 61688, 61704, \n    61726, 61784, 61800, 61816, 61836, 61880, 61896, 61914, \n    61948, 61998, 62062, 62122, 62154, 62184, 62200, 62218, \n    62252, 62302, 62364, 62410, 62442, 62478, 62536, 62554, \n    62584, 62604, 62640, 62648, 62656, 62664, 62730, 62766, \n    62830, 62890, 62924, 62974, 63032, 63050, 63082, 63118, \n    63182, 63242, 63274, 63310, 63368, 63390, \n  };\n#define HIBIT ((unsigned char)0x80)\n  unsigned char aChar[] = {\n    '\\0',      'a',       'c',       'e',       'i',       'n',       \n    'o',       'u',       'y',       'y',       'a',       'c',       \n    'd',       'e',       'e',       'g',       'h',       'i',       \n    'j',       'k',       'l',       'n',       'o',       'r',       \n    's',       't',       'u',       'u',       'w',       'y',       \n    'z',       'o',       'u',       'a',       'i',       'o',       \n    'u',       'u'|HIBIT, 'a'|HIBIT, 'g',       'k',       'o',       \n    'o'|HIBIT, 'j',       'g',       'n',       'a'|HIBIT, 'a',       \n    'e',       'i',       'o',       'r',       'u',       's',       \n    't',       'h',       'a',       'e',       'o'|HIBIT, 'o',       \n    'o'|HIBIT, 'y',       '\\0',      '\\0',      '\\0',      '\\0',      \n    '\\0',      '\\0',      '\\0',      '\\0',      'a',       'b',       \n    'c'|HIBIT, 'd',       'd',       'e'|HIBIT, 'e',       'e'|HIBIT, \n    'f',       'g',       'h',       'h',       'i',       'i'|HIBIT, \n    'k',       'l',       'l'|HIBIT, 'l',       'm',       'n',       \n    'o'|HIBIT, 'p',       'r',       'r'|HIBIT, 'r',       's',       \n    's'|HIBIT, 't',       'u',       'u'|HIBIT, 'v',       'w',       \n    'w',       'x',       'y',       'z',       'h',       't',       \n    'w',       'y',       'a',       'a'|HIBIT, 'a'|HIBIT, 'a'|HIBIT, \n    'e',       'e'|HIBIT, 'e'|HIBIT, 'i',       'o',       'o'|HIBIT, \n    'o'|HIBIT, 'o'|HIBIT, 'u',       'u'|HIBIT, 'u'|HIBIT, 'y',       \n  };\n\n  unsigned int key = (((unsigned int)c)<<3) | 0x00000007;\n  int iRes = 0;\n  int iHi = sizeof(aDia)/sizeof(aDia[0]) - 1;\n  int iLo = 0;\n  while( iHi>=iLo ){\n    int iTest = (iHi + iLo) / 2;\n    if( key >= aDia[iTest] ){\n      iRes = iTest;\n      iLo = iTest+1;\n    }else{\n      iHi = iTest-1;\n    }\n  }\n  assert( key>=aDia[iRes] );\n  if( bComplex==0 && (aChar[iRes] & 0x80) ) return c;\n  return (c > (aDia[iRes]>>3) + (aDia[iRes]&0x07)) ? c : ((int)aChar[iRes] & 0x7F);\n}\n\n\n/*\n** Return true if the argument interpreted as a unicode codepoint\n** is a diacritical modifier character.\n*/\nSQLITE_PRIVATE int sqlite3FtsUnicodeIsdiacritic(int c){\n  unsigned int mask0 = 0x08029FDF;\n  unsigned int mask1 = 0x000361F8;\n  if( c<768 || c>817 ) return 0;\n  return (c < 768+32) ?\n      (mask0 & ((unsigned int)1 << (c-768))) :\n      (mask1 & ((unsigned int)1 << (c-768-32)));\n}\n\n\n/*\n** Interpret the argument as a unicode codepoint. If the codepoint\n** is an upper case character that has a lower case equivalent,\n** return the codepoint corresponding to the lower case version.\n** Otherwise, return a copy of the argument.\n**\n** The results are undefined if the value passed to this function\n** is less than zero.\n*/\nSQLITE_PRIVATE int sqlite3FtsUnicodeFold(int c, int eRemoveDiacritic){\n  /* Each entry in the following array defines a rule for folding a range\n  ** of codepoints to lower case. The rule applies to a range of nRange\n  ** codepoints starting at codepoint iCode.\n  **\n  ** If the least significant bit in flags is clear, then the rule applies\n  ** to all nRange codepoints (i.e. all nRange codepoints are upper case and\n  ** need to be folded). Or, if it is set, then the rule only applies to\n  ** every second codepoint in the range, starting with codepoint C.\n  **\n  ** The 7 most significant bits in flags are an index into the aiOff[]\n  ** array. If a specific codepoint C does require folding, then its lower\n  ** case equivalent is ((C + aiOff[flags>>1]) & 0xFFFF).\n  **\n  ** The contents of this array are generated by parsing the CaseFolding.txt\n  ** file distributed as part of the \"Unicode Character Database\". See\n  ** http://www.unicode.org for details.\n  */\n  static const struct TableEntry {\n    unsigned short iCode;\n    unsigned char flags;\n    unsigned char nRange;\n  } aEntry[] = {\n    {65, 14, 26},          {181, 64, 1},          {192, 14, 23},\n    {216, 14, 7},          {256, 1, 48},          {306, 1, 6},\n    {313, 1, 16},          {330, 1, 46},          {376, 116, 1},\n    {377, 1, 6},           {383, 104, 1},         {385, 50, 1},\n    {386, 1, 4},           {390, 44, 1},          {391, 0, 1},\n    {393, 42, 2},          {395, 0, 1},           {398, 32, 1},\n    {399, 38, 1},          {400, 40, 1},          {401, 0, 1},\n    {403, 42, 1},          {404, 46, 1},          {406, 52, 1},\n    {407, 48, 1},          {408, 0, 1},           {412, 52, 1},\n    {413, 54, 1},          {415, 56, 1},          {416, 1, 6},\n    {422, 60, 1},          {423, 0, 1},           {425, 60, 1},\n    {428, 0, 1},           {430, 60, 1},          {431, 0, 1},\n    {433, 58, 2},          {435, 1, 4},           {439, 62, 1},\n    {440, 0, 1},           {444, 0, 1},           {452, 2, 1},\n    {453, 0, 1},           {455, 2, 1},           {456, 0, 1},\n    {458, 2, 1},           {459, 1, 18},          {478, 1, 18},\n    {497, 2, 1},           {498, 1, 4},           {502, 122, 1},\n    {503, 134, 1},         {504, 1, 40},          {544, 110, 1},\n    {546, 1, 18},          {570, 70, 1},          {571, 0, 1},\n    {573, 108, 1},         {574, 68, 1},          {577, 0, 1},\n    {579, 106, 1},         {580, 28, 1},          {581, 30, 1},\n    {582, 1, 10},          {837, 36, 1},          {880, 1, 4},\n    {886, 0, 1},           {902, 18, 1},          {904, 16, 3},\n    {908, 26, 1},          {910, 24, 2},          {913, 14, 17},\n    {931, 14, 9},          {962, 0, 1},           {975, 4, 1},\n    {976, 140, 1},         {977, 142, 1},         {981, 146, 1},\n    {982, 144, 1},         {984, 1, 24},          {1008, 136, 1},\n    {1009, 138, 1},        {1012, 130, 1},        {1013, 128, 1},\n    {1015, 0, 1},          {1017, 152, 1},        {1018, 0, 1},\n    {1021, 110, 3},        {1024, 34, 16},        {1040, 14, 32},\n    {1120, 1, 34},         {1162, 1, 54},         {1216, 6, 1},\n    {1217, 1, 14},         {1232, 1, 88},         {1329, 22, 38},\n    {4256, 66, 38},        {4295, 66, 1},         {4301, 66, 1},\n    {7680, 1, 150},        {7835, 132, 1},        {7838, 96, 1},\n    {7840, 1, 96},         {7944, 150, 8},        {7960, 150, 6},\n    {7976, 150, 8},        {7992, 150, 8},        {8008, 150, 6},\n    {8025, 151, 8},        {8040, 150, 8},        {8072, 150, 8},\n    {8088, 150, 8},        {8104, 150, 8},        {8120, 150, 2},\n    {8122, 126, 2},        {8124, 148, 1},        {8126, 100, 1},\n    {8136, 124, 4},        {8140, 148, 1},        {8152, 150, 2},\n    {8154, 120, 2},        {8168, 150, 2},        {8170, 118, 2},\n    {8172, 152, 1},        {8184, 112, 2},        {8186, 114, 2},\n    {8188, 148, 1},        {8486, 98, 1},         {8490, 92, 1},\n    {8491, 94, 1},         {8498, 12, 1},         {8544, 8, 16},\n    {8579, 0, 1},          {9398, 10, 26},        {11264, 22, 47},\n    {11360, 0, 1},         {11362, 88, 1},        {11363, 102, 1},\n    {11364, 90, 1},        {11367, 1, 6},         {11373, 84, 1},\n    {11374, 86, 1},        {11375, 80, 1},        {11376, 82, 1},\n    {11378, 0, 1},         {11381, 0, 1},         {11390, 78, 2},\n    {11392, 1, 100},       {11499, 1, 4},         {11506, 0, 1},\n    {42560, 1, 46},        {42624, 1, 24},        {42786, 1, 14},\n    {42802, 1, 62},        {42873, 1, 4},         {42877, 76, 1},\n    {42878, 1, 10},        {42891, 0, 1},         {42893, 74, 1},\n    {42896, 1, 4},         {42912, 1, 10},        {42922, 72, 1},\n    {65313, 14, 26},       \n  };\n  static const unsigned short aiOff[] = {\n   1,     2,     8,     15,    16,    26,    28,    32,    \n   37,    38,    40,    48,    63,    64,    69,    71,    \n   79,    80,    116,   202,   203,   205,   206,   207,   \n   209,   210,   211,   213,   214,   217,   218,   219,   \n   775,   7264,  10792, 10795, 23228, 23256, 30204, 54721, \n   54753, 54754, 54756, 54787, 54793, 54809, 57153, 57274, \n   57921, 58019, 58363, 61722, 65268, 65341, 65373, 65406, \n   65408, 65410, 65415, 65424, 65436, 65439, 65450, 65462, \n   65472, 65476, 65478, 65480, 65482, 65488, 65506, 65511, \n   65514, 65521, 65527, 65528, 65529, \n  };\n\n  int ret = c;\n\n  assert( sizeof(unsigned short)==2 && sizeof(unsigned char)==1 );\n\n  if( c<128 ){\n    if( c>='A' && c<='Z' ) ret = c + ('a' - 'A');\n  }else if( c<65536 ){\n    const struct TableEntry *p;\n    int iHi = sizeof(aEntry)/sizeof(aEntry[0]) - 1;\n    int iLo = 0;\n    int iRes = -1;\n\n    assert( c>aEntry[0].iCode );\n    while( iHi>=iLo ){\n      int iTest = (iHi + iLo) / 2;\n      int cmp = (c - aEntry[iTest].iCode);\n      if( cmp>=0 ){\n        iRes = iTest;\n        iLo = iTest+1;\n      }else{\n        iHi = iTest-1;\n      }\n    }\n\n    assert( iRes>=0 && c>=aEntry[iRes].iCode );\n    p = &aEntry[iRes];\n    if( c<(p->iCode + p->nRange) && 0==(0x01 & p->flags & (p->iCode ^ c)) ){\n      ret = (c + (aiOff[p->flags>>1])) & 0x0000FFFF;\n      assert( ret>0 );\n    }\n\n    if( eRemoveDiacritic ){\n      ret = remove_diacritic(ret, eRemoveDiacritic==2);\n    }\n  }\n  \n  else if( c>=66560 && c<66600 ){\n    ret = c + 40;\n  }\n\n  return ret;\n}\n#endif /* defined(SQLITE_ENABLE_FTS3) || defined(SQLITE_ENABLE_FTS4) */\n#endif /* !defined(SQLITE_DISABLE_FTS3_UNICODE) */\n\n/************** End of fts3_unicode2.c ***************************************/\n/************** Begin file json1.c *******************************************/\n/*\n** 2015-08-12\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n******************************************************************************\n**\n** This SQLite extension implements JSON functions.  The interface is\n** modeled after MySQL JSON functions:\n**\n**     https://dev.mysql.com/doc/refman/5.7/en/json.html\n**\n** For the time being, all JSON is stored as pure text.  (We might add\n** a JSONB type in the future which stores a binary encoding of JSON in\n** a BLOB, but there is no support for JSONB in the current implementation.\n** This implementation parses JSON text at 250 MB/s, so it is hard to see\n** how JSONB might improve on that.)\n*/\n#if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_JSON1)\n#if !defined(SQLITEINT_H)\n/* #include \"sqlite3ext.h\" */\n#endif\nSQLITE_EXTENSION_INIT1\n/* #include <assert.h> */\n/* #include <string.h> */\n/* #include <stdlib.h> */\n/* #include <stdarg.h> */\n\n/* Mark a function parameter as unused, to suppress nuisance compiler\n** warnings. */\n#ifndef UNUSED_PARAM\n# define UNUSED_PARAM(X)  (void)(X)\n#endif\n\n#ifndef LARGEST_INT64\n# define LARGEST_INT64  (0xffffffff|(((sqlite3_int64)0x7fffffff)<<32))\n# define SMALLEST_INT64 (((sqlite3_int64)-1) - LARGEST_INT64)\n#endif\n\n/*\n** Versions of isspace(), isalnum() and isdigit() to which it is safe\n** to pass signed char values.\n*/\n#ifdef sqlite3Isdigit\n   /* Use the SQLite core versions if this routine is part of the\n   ** SQLite amalgamation */\n#  define safe_isdigit(x)  sqlite3Isdigit(x)\n#  define safe_isalnum(x)  sqlite3Isalnum(x)\n#  define safe_isxdigit(x) sqlite3Isxdigit(x)\n#else\n   /* Use the standard library for separate compilation */\n#include <ctype.h>  /* amalgamator: keep */\n#  define safe_isdigit(x)  isdigit((unsigned char)(x))\n#  define safe_isalnum(x)  isalnum((unsigned char)(x))\n#  define safe_isxdigit(x) isxdigit((unsigned char)(x))\n#endif\n\n/*\n** Growing our own isspace() routine this way is twice as fast as\n** the library isspace() function, resulting in a 7% overall performance\n** increase for the parser.  (Ubuntu14.10 gcc 4.8.4 x64 with -Os).\n*/\nstatic const char jsonIsSpace[] = {\n  0, 0, 0, 0, 0, 0, 0, 0,     0, 1, 1, 0, 0, 1, 0, 0,\n  0, 0, 0, 0, 0, 0, 0, 0,     0, 0, 0, 0, 0, 0, 0, 0,\n  1, 0, 0, 0, 0, 0, 0, 0,     0, 0, 0, 0, 0, 0, 0, 0,\n  0, 0, 0, 0, 0, 0, 0, 0,     0, 0, 0, 0, 0, 0, 0, 0,\n  0, 0, 0, 0, 0, 0, 0, 0,     0, 0, 0, 0, 0, 0, 0, 0,\n  0, 0, 0, 0, 0, 0, 0, 0,     0, 0, 0, 0, 0, 0, 0, 0,\n  0, 0, 0, 0, 0, 0, 0, 0,     0, 0, 0, 0, 0, 0, 0, 0,\n  0, 0, 0, 0, 0, 0, 0, 0,     0, 0, 0, 0, 0, 0, 0, 0,\n  0, 0, 0, 0, 0, 0, 0, 0,     0, 0, 0, 0, 0, 0, 0, 0,\n  0, 0, 0, 0, 0, 0, 0, 0,     0, 0, 0, 0, 0, 0, 0, 0,\n  0, 0, 0, 0, 0, 0, 0, 0,     0, 0, 0, 0, 0, 0, 0, 0,\n  0, 0, 0, 0, 0, 0, 0, 0,     0, 0, 0, 0, 0, 0, 0, 0,\n  0, 0, 0, 0, 0, 0, 0, 0,     0, 0, 0, 0, 0, 0, 0, 0,\n  0, 0, 0, 0, 0, 0, 0, 0,     0, 0, 0, 0, 0, 0, 0, 0,\n  0, 0, 0, 0, 0, 0, 0, 0,     0, 0, 0, 0, 0, 0, 0, 0,\n  0, 0, 0, 0, 0, 0, 0, 0,     0, 0, 0, 0, 0, 0, 0, 0,\n};\n#define safe_isspace(x) (jsonIsSpace[(unsigned char)x])\n\n#ifndef SQLITE_AMALGAMATION\n  /* Unsigned integer types.  These are already defined in the sqliteInt.h,\n  ** but the definitions need to be repeated for separate compilation. */\n  typedef sqlite3_uint64 u64;\n  typedef unsigned int u32;\n  typedef unsigned short int u16;\n  typedef unsigned char u8;\n#endif\n\n/* Objects */\ntypedef struct JsonString JsonString;\ntypedef struct JsonNode JsonNode;\ntypedef struct JsonParse JsonParse;\n\n/* An instance of this object represents a JSON string\n** under construction.  Really, this is a generic string accumulator\n** that can be and is used to create strings other than JSON.\n*/\nstruct JsonString {\n  sqlite3_context *pCtx;   /* Function context - put error messages here */\n  char *zBuf;              /* Append JSON content here */\n  u64 nAlloc;              /* Bytes of storage available in zBuf[] */\n  u64 nUsed;               /* Bytes of zBuf[] currently used */\n  u8 bStatic;              /* True if zBuf is static space */\n  u8 bErr;                 /* True if an error has been encountered */\n  char zSpace[100];        /* Initial static space */\n};\n\n/* JSON type values\n*/\n#define JSON_NULL     0\n#define JSON_TRUE     1\n#define JSON_FALSE    2\n#define JSON_INT      3\n#define JSON_REAL     4\n#define JSON_STRING   5\n#define JSON_ARRAY    6\n#define JSON_OBJECT   7\n\n/* The \"subtype\" set for JSON values */\n#define JSON_SUBTYPE  74    /* Ascii for \"J\" */\n\n/*\n** Names of the various JSON types:\n*/\nstatic const char * const jsonType[] = {\n  \"null\", \"true\", \"false\", \"integer\", \"real\", \"text\", \"array\", \"object\"\n};\n\n/* Bit values for the JsonNode.jnFlag field\n*/\n#define JNODE_RAW     0x01         /* Content is raw, not JSON encoded */\n#define JNODE_ESCAPE  0x02         /* Content is text with \\ escapes */\n#define JNODE_REMOVE  0x04         /* Do not output */\n#define JNODE_REPLACE 0x08         /* Replace with JsonNode.u.iReplace */\n#define JNODE_PATCH   0x10         /* Patch with JsonNode.u.pPatch */\n#define JNODE_APPEND  0x20         /* More ARRAY/OBJECT entries at u.iAppend */\n#define JNODE_LABEL   0x40         /* Is a label of an object */\n\n\n/* A single node of parsed JSON\n*/\nstruct JsonNode {\n  u8 eType;              /* One of the JSON_ type values */\n  u8 jnFlags;            /* JNODE flags */\n  u32 n;                 /* Bytes of content, or number of sub-nodes */\n  union {\n    const char *zJContent; /* Content for INT, REAL, and STRING */\n    u32 iAppend;           /* More terms for ARRAY and OBJECT */\n    u32 iKey;              /* Key for ARRAY objects in json_tree() */\n    u32 iReplace;          /* Replacement content for JNODE_REPLACE */\n    JsonNode *pPatch;      /* Node chain of patch for JNODE_PATCH */\n  } u;\n};\n\n/* A completely parsed JSON string\n*/\nstruct JsonParse {\n  u32 nNode;         /* Number of slots of aNode[] used */\n  u32 nAlloc;        /* Number of slots of aNode[] allocated */\n  JsonNode *aNode;   /* Array of nodes containing the parse */\n  const char *zJson; /* Original JSON string */\n  u32 *aUp;          /* Index of parent of each node */\n  u8 oom;            /* Set to true if out of memory */\n  u8 nErr;           /* Number of errors seen */\n  u16 iDepth;        /* Nesting depth */\n  int nJson;         /* Length of the zJson string in bytes */\n  u32 iHold;         /* Replace cache line with the lowest iHold value */\n};\n\n/*\n** Maximum nesting depth of JSON for this implementation.\n**\n** This limit is needed to avoid a stack overflow in the recursive\n** descent parser.  A depth of 2000 is far deeper than any sane JSON\n** should go.\n*/\n#define JSON_MAX_DEPTH  2000\n\n/**************************************************************************\n** Utility routines for dealing with JsonString objects\n**************************************************************************/\n\n/* Set the JsonString object to an empty string\n*/\nstatic void jsonZero(JsonString *p){\n  p->zBuf = p->zSpace;\n  p->nAlloc = sizeof(p->zSpace);\n  p->nUsed = 0;\n  p->bStatic = 1;\n}\n\n/* Initialize the JsonString object\n*/\nstatic void jsonInit(JsonString *p, sqlite3_context *pCtx){\n  p->pCtx = pCtx;\n  p->bErr = 0;\n  jsonZero(p);\n}\n\n\n/* Free all allocated memory and reset the JsonString object back to its\n** initial state.\n*/\nstatic void jsonReset(JsonString *p){\n  if( !p->bStatic ) sqlite3_free(p->zBuf);\n  jsonZero(p);\n}\n\n\n/* Report an out-of-memory (OOM) condition \n*/\nstatic void jsonOom(JsonString *p){\n  p->bErr = 1;\n  sqlite3_result_error_nomem(p->pCtx);\n  jsonReset(p);\n}\n\n/* Enlarge pJson->zBuf so that it can hold at least N more bytes.\n** Return zero on success.  Return non-zero on an OOM error\n*/\nstatic int jsonGrow(JsonString *p, u32 N){\n  u64 nTotal = N<p->nAlloc ? p->nAlloc*2 : p->nAlloc+N+10;\n  char *zNew;\n  if( p->bStatic ){\n    if( p->bErr ) return 1;\n    zNew = sqlite3_malloc64(nTotal);\n    if( zNew==0 ){\n      jsonOom(p);\n      return SQLITE_NOMEM;\n    }\n    memcpy(zNew, p->zBuf, (size_t)p->nUsed);\n    p->zBuf = zNew;\n    p->bStatic = 0;\n  }else{\n    zNew = sqlite3_realloc64(p->zBuf, nTotal);\n    if( zNew==0 ){\n      jsonOom(p);\n      return SQLITE_NOMEM;\n    }\n    p->zBuf = zNew;\n  }\n  p->nAlloc = nTotal;\n  return SQLITE_OK;\n}\n\n/* Append N bytes from zIn onto the end of the JsonString string.\n*/\nstatic void jsonAppendRaw(JsonString *p, const char *zIn, u32 N){\n  if( (N+p->nUsed >= p->nAlloc) && jsonGrow(p,N)!=0 ) return;\n  memcpy(p->zBuf+p->nUsed, zIn, N);\n  p->nUsed += N;\n}\n\n/* Append formatted text (not to exceed N bytes) to the JsonString.\n*/\nstatic void jsonPrintf(int N, JsonString *p, const char *zFormat, ...){\n  va_list ap;\n  if( (p->nUsed + N >= p->nAlloc) && jsonGrow(p, N) ) return;\n  va_start(ap, zFormat);\n  sqlite3_vsnprintf(N, p->zBuf+p->nUsed, zFormat, ap);\n  va_end(ap);\n  p->nUsed += (int)strlen(p->zBuf+p->nUsed);\n}\n\n/* Append a single character\n*/\nstatic void jsonAppendChar(JsonString *p, char c){\n  if( p->nUsed>=p->nAlloc && jsonGrow(p,1)!=0 ) return;\n  p->zBuf[p->nUsed++] = c;\n}\n\n/* Append a comma separator to the output buffer, if the previous\n** character is not '[' or '{'.\n*/\nstatic void jsonAppendSeparator(JsonString *p){\n  char c;\n  if( p->nUsed==0 ) return;\n  c = p->zBuf[p->nUsed-1];\n  if( c!='[' && c!='{' ) jsonAppendChar(p, ',');\n}\n\n/* Append the N-byte string in zIn to the end of the JsonString string\n** under construction.  Enclose the string in \"...\" and escape\n** any double-quotes or backslash characters contained within the\n** string.\n*/\nstatic void jsonAppendString(JsonString *p, const char *zIn, u32 N){\n  u32 i;\n  if( (N+p->nUsed+2 >= p->nAlloc) && jsonGrow(p,N+2)!=0 ) return;\n  p->zBuf[p->nUsed++] = '\"';\n  for(i=0; i<N; i++){\n    unsigned char c = ((unsigned const char*)zIn)[i];\n    if( c=='\"' || c=='\\\\' ){\n      json_simple_escape:\n      if( (p->nUsed+N+3-i > p->nAlloc) && jsonGrow(p,N+3-i)!=0 ) return;\n      p->zBuf[p->nUsed++] = '\\\\';\n    }else if( c<=0x1f ){\n      static const char aSpecial[] = {\n         0, 0, 0, 0, 0, 0, 0, 0, 'b', 't', 'n', 0, 'f', 'r', 0, 0,\n         0, 0, 0, 0, 0, 0, 0, 0,   0,   0,   0, 0,   0,   0, 0, 0\n      };\n      assert( sizeof(aSpecial)==32 );\n      assert( aSpecial['\\b']=='b' );\n      assert( aSpecial['\\f']=='f' );\n      assert( aSpecial['\\n']=='n' );\n      assert( aSpecial['\\r']=='r' );\n      assert( aSpecial['\\t']=='t' );\n      if( aSpecial[c] ){\n        c = aSpecial[c];\n        goto json_simple_escape;\n      }\n      if( (p->nUsed+N+7+i > p->nAlloc) && jsonGrow(p,N+7-i)!=0 ) return;\n      p->zBuf[p->nUsed++] = '\\\\';\n      p->zBuf[p->nUsed++] = 'u';\n      p->zBuf[p->nUsed++] = '0';\n      p->zBuf[p->nUsed++] = '0';\n      p->zBuf[p->nUsed++] = '0' + (c>>4);\n      c = \"0123456789abcdef\"[c&0xf];\n    }\n    p->zBuf[p->nUsed++] = c;\n  }\n  p->zBuf[p->nUsed++] = '\"';\n  assert( p->nUsed<p->nAlloc );\n}\n\n/*\n** Append a function parameter value to the JSON string under \n** construction.\n*/\nstatic void jsonAppendValue(\n  JsonString *p,                 /* Append to this JSON string */\n  sqlite3_value *pValue          /* Value to append */\n){\n  switch( sqlite3_value_type(pValue) ){\n    case SQLITE_NULL: {\n      jsonAppendRaw(p, \"null\", 4);\n      break;\n    }\n    case SQLITE_INTEGER:\n    case SQLITE_FLOAT: {\n      const char *z = (const char*)sqlite3_value_text(pValue);\n      u32 n = (u32)sqlite3_value_bytes(pValue);\n      jsonAppendRaw(p, z, n);\n      break;\n    }\n    case SQLITE_TEXT: {\n      const char *z = (const char*)sqlite3_value_text(pValue);\n      u32 n = (u32)sqlite3_value_bytes(pValue);\n      if( sqlite3_value_subtype(pValue)==JSON_SUBTYPE ){\n        jsonAppendRaw(p, z, n);\n      }else{\n        jsonAppendString(p, z, n);\n      }\n      break;\n    }\n    default: {\n      if( p->bErr==0 ){\n        sqlite3_result_error(p->pCtx, \"JSON cannot hold BLOB values\", -1);\n        p->bErr = 2;\n        jsonReset(p);\n      }\n      break;\n    }\n  }\n}\n\n\n/* Make the JSON in p the result of the SQL function.\n*/\nstatic void jsonResult(JsonString *p){\n  if( p->bErr==0 ){\n    sqlite3_result_text64(p->pCtx, p->zBuf, p->nUsed, \n                          p->bStatic ? SQLITE_TRANSIENT : sqlite3_free,\n                          SQLITE_UTF8);\n    jsonZero(p);\n  }\n  assert( p->bStatic );\n}\n\n/**************************************************************************\n** Utility routines for dealing with JsonNode and JsonParse objects\n**************************************************************************/\n\n/*\n** Return the number of consecutive JsonNode slots need to represent\n** the parsed JSON at pNode.  The minimum answer is 1.  For ARRAY and\n** OBJECT types, the number might be larger.\n**\n** Appended elements are not counted.  The value returned is the number\n** by which the JsonNode counter should increment in order to go to the\n** next peer value.\n*/\nstatic u32 jsonNodeSize(JsonNode *pNode){\n  return pNode->eType>=JSON_ARRAY ? pNode->n+1 : 1;\n}\n\n/*\n** Reclaim all memory allocated by a JsonParse object.  But do not\n** delete the JsonParse object itself.\n*/\nstatic void jsonParseReset(JsonParse *pParse){\n  sqlite3_free(pParse->aNode);\n  pParse->aNode = 0;\n  pParse->nNode = 0;\n  pParse->nAlloc = 0;\n  sqlite3_free(pParse->aUp);\n  pParse->aUp = 0;\n}\n\n/*\n** Free a JsonParse object that was obtained from sqlite3_malloc().\n*/\nstatic void jsonParseFree(JsonParse *pParse){\n  jsonParseReset(pParse);\n  sqlite3_free(pParse);\n}\n\n/*\n** Convert the JsonNode pNode into a pure JSON string and\n** append to pOut.  Subsubstructure is also included.  Return\n** the number of JsonNode objects that are encoded.\n*/\nstatic void jsonRenderNode(\n  JsonNode *pNode,               /* The node to render */\n  JsonString *pOut,              /* Write JSON here */\n  sqlite3_value **aReplace       /* Replacement values */\n){\n  if( pNode->jnFlags & (JNODE_REPLACE|JNODE_PATCH) ){\n    if( pNode->jnFlags & JNODE_REPLACE ){\n      jsonAppendValue(pOut, aReplace[pNode->u.iReplace]);\n      return;\n    }\n    pNode = pNode->u.pPatch;\n  }\n  switch( pNode->eType ){\n    default: {\n      assert( pNode->eType==JSON_NULL );\n      jsonAppendRaw(pOut, \"null\", 4);\n      break;\n    }\n    case JSON_TRUE: {\n      jsonAppendRaw(pOut, \"true\", 4);\n      break;\n    }\n    case JSON_FALSE: {\n      jsonAppendRaw(pOut, \"false\", 5);\n      break;\n    }\n    case JSON_STRING: {\n      if( pNode->jnFlags & JNODE_RAW ){\n        jsonAppendString(pOut, pNode->u.zJContent, pNode->n);\n        break;\n      }\n      /* Fall through into the next case */\n    }\n    case JSON_REAL:\n    case JSON_INT: {\n      jsonAppendRaw(pOut, pNode->u.zJContent, pNode->n);\n      break;\n    }\n    case JSON_ARRAY: {\n      u32 j = 1;\n      jsonAppendChar(pOut, '[');\n      for(;;){\n        while( j<=pNode->n ){\n          if( (pNode[j].jnFlags & JNODE_REMOVE)==0 ){\n            jsonAppendSeparator(pOut);\n            jsonRenderNode(&pNode[j], pOut, aReplace);\n          }\n          j += jsonNodeSize(&pNode[j]);\n        }\n        if( (pNode->jnFlags & JNODE_APPEND)==0 ) break;\n        pNode = &pNode[pNode->u.iAppend];\n        j = 1;\n      }\n      jsonAppendChar(pOut, ']');\n      break;\n    }\n    case JSON_OBJECT: {\n      u32 j = 1;\n      jsonAppendChar(pOut, '{');\n      for(;;){\n        while( j<=pNode->n ){\n          if( (pNode[j+1].jnFlags & JNODE_REMOVE)==0 ){\n            jsonAppendSeparator(pOut);\n            jsonRenderNode(&pNode[j], pOut, aReplace);\n            jsonAppendChar(pOut, ':');\n            jsonRenderNode(&pNode[j+1], pOut, aReplace);\n          }\n          j += 1 + jsonNodeSize(&pNode[j+1]);\n        }\n        if( (pNode->jnFlags & JNODE_APPEND)==0 ) break;\n        pNode = &pNode[pNode->u.iAppend];\n        j = 1;\n      }\n      jsonAppendChar(pOut, '}');\n      break;\n    }\n  }\n}\n\n/*\n** Return a JsonNode and all its descendents as a JSON string.\n*/\nstatic void jsonReturnJson(\n  JsonNode *pNode,            /* Node to return */\n  sqlite3_context *pCtx,      /* Return value for this function */\n  sqlite3_value **aReplace    /* Array of replacement values */\n){\n  JsonString s;\n  jsonInit(&s, pCtx);\n  jsonRenderNode(pNode, &s, aReplace);\n  jsonResult(&s);\n  sqlite3_result_subtype(pCtx, JSON_SUBTYPE);\n}\n\n/*\n** Make the JsonNode the return value of the function.\n*/\nstatic void jsonReturn(\n  JsonNode *pNode,            /* Node to return */\n  sqlite3_context *pCtx,      /* Return value for this function */\n  sqlite3_value **aReplace    /* Array of replacement values */\n){\n  switch( pNode->eType ){\n    default: {\n      assert( pNode->eType==JSON_NULL );\n      sqlite3_result_null(pCtx);\n      break;\n    }\n    case JSON_TRUE: {\n      sqlite3_result_int(pCtx, 1);\n      break;\n    }\n    case JSON_FALSE: {\n      sqlite3_result_int(pCtx, 0);\n      break;\n    }\n    case JSON_INT: {\n      sqlite3_int64 i = 0;\n      const char *z = pNode->u.zJContent;\n      if( z[0]=='-' ){ z++; }\n      while( z[0]>='0' && z[0]<='9' ){\n        unsigned v = *(z++) - '0';\n        if( i>=LARGEST_INT64/10 ){\n          if( i>LARGEST_INT64/10 ) goto int_as_real;\n          if( z[0]>='0' && z[0]<='9' ) goto int_as_real;\n          if( v==9 ) goto int_as_real;\n          if( v==8 ){\n            if( pNode->u.zJContent[0]=='-' ){\n              sqlite3_result_int64(pCtx, SMALLEST_INT64);\n              goto int_done;\n            }else{\n              goto int_as_real;\n            }\n          }\n        }\n        i = i*10 + v;\n      }\n      if( pNode->u.zJContent[0]=='-' ){ i = -i; }\n      sqlite3_result_int64(pCtx, i);\n      int_done:\n      break;\n      int_as_real: /* fall through to real */;\n    }\n    case JSON_REAL: {\n      double r;\n#ifdef SQLITE_AMALGAMATION\n      const char *z = pNode->u.zJContent;\n      sqlite3AtoF(z, &r, sqlite3Strlen30(z), SQLITE_UTF8);\n#else\n      r = strtod(pNode->u.zJContent, 0);\n#endif\n      sqlite3_result_double(pCtx, r);\n      break;\n    }\n    case JSON_STRING: {\n#if 0 /* Never happens because JNODE_RAW is only set by json_set(),\n      ** json_insert() and json_replace() and those routines do not\n      ** call jsonReturn() */\n      if( pNode->jnFlags & JNODE_RAW ){\n        sqlite3_result_text(pCtx, pNode->u.zJContent, pNode->n,\n                            SQLITE_TRANSIENT);\n      }else \n#endif\n      assert( (pNode->jnFlags & JNODE_RAW)==0 );\n      if( (pNode->jnFlags & JNODE_ESCAPE)==0 ){\n        /* JSON formatted without any backslash-escapes */\n        sqlite3_result_text(pCtx, pNode->u.zJContent+1, pNode->n-2,\n                            SQLITE_TRANSIENT);\n      }else{\n        /* Translate JSON formatted string into raw text */\n        u32 i;\n        u32 n = pNode->n;\n        const char *z = pNode->u.zJContent;\n        char *zOut;\n        u32 j;\n        zOut = sqlite3_malloc( n+1 );\n        if( zOut==0 ){\n          sqlite3_result_error_nomem(pCtx);\n          break;\n        }\n        for(i=1, j=0; i<n-1; i++){\n          char c = z[i];\n          if( c!='\\\\' ){\n            zOut[j++] = c;\n          }else{\n            c = z[++i];\n            if( c=='u' ){\n              u32 v = 0, k;\n              for(k=0; k<4; i++, k++){\n                assert( i<n-2 );\n                c = z[i+1];\n                assert( safe_isxdigit(c) );\n                if( c<='9' ) v = v*16 + c - '0';\n                else if( c<='F' ) v = v*16 + c - 'A' + 10;\n                else v = v*16 + c - 'a' + 10;\n              }\n              if( v==0 ) break;\n              if( v<=0x7f ){\n                zOut[j++] = (char)v;\n              }else if( v<=0x7ff ){\n                zOut[j++] = (char)(0xc0 | (v>>6));\n                zOut[j++] = 0x80 | (v&0x3f);\n              }else{\n                zOut[j++] = (char)(0xe0 | (v>>12));\n                zOut[j++] = 0x80 | ((v>>6)&0x3f);\n                zOut[j++] = 0x80 | (v&0x3f);\n              }\n            }else{\n              if( c=='b' ){\n                c = '\\b';\n              }else if( c=='f' ){\n                c = '\\f';\n              }else if( c=='n' ){\n                c = '\\n';\n              }else if( c=='r' ){\n                c = '\\r';\n              }else if( c=='t' ){\n                c = '\\t';\n              }\n              zOut[j++] = c;\n            }\n          }\n        }\n        zOut[j] = 0;\n        sqlite3_result_text(pCtx, zOut, j, sqlite3_free);\n      }\n      break;\n    }\n    case JSON_ARRAY:\n    case JSON_OBJECT: {\n      jsonReturnJson(pNode, pCtx, aReplace);\n      break;\n    }\n  }\n}\n\n/* Forward reference */\nstatic int jsonParseAddNode(JsonParse*,u32,u32,const char*);\n\n/*\n** A macro to hint to the compiler that a function should not be\n** inlined.\n*/\n#if defined(__GNUC__)\n#  define JSON_NOINLINE  __attribute__((noinline))\n#elif defined(_MSC_VER) && _MSC_VER>=1310\n#  define JSON_NOINLINE  __declspec(noinline)\n#else\n#  define JSON_NOINLINE\n#endif\n\n\nstatic JSON_NOINLINE int jsonParseAddNodeExpand(\n  JsonParse *pParse,        /* Append the node to this object */\n  u32 eType,                /* Node type */\n  u32 n,                    /* Content size or sub-node count */\n  const char *zContent      /* Content */\n){\n  u32 nNew;\n  JsonNode *pNew;\n  assert( pParse->nNode>=pParse->nAlloc );\n  if( pParse->oom ) return -1;\n  nNew = pParse->nAlloc*2 + 10;\n  pNew = sqlite3_realloc64(pParse->aNode, sizeof(JsonNode)*nNew);\n  if( pNew==0 ){\n    pParse->oom = 1;\n    return -1;\n  }\n  pParse->nAlloc = nNew;\n  pParse->aNode = pNew;\n  assert( pParse->nNode<pParse->nAlloc );\n  return jsonParseAddNode(pParse, eType, n, zContent);\n}\n\n/*\n** Create a new JsonNode instance based on the arguments and append that\n** instance to the JsonParse.  Return the index in pParse->aNode[] of the\n** new node, or -1 if a memory allocation fails.\n*/\nstatic int jsonParseAddNode(\n  JsonParse *pParse,        /* Append the node to this object */\n  u32 eType,                /* Node type */\n  u32 n,                    /* Content size or sub-node count */\n  const char *zContent      /* Content */\n){\n  JsonNode *p;\n  if( pParse->nNode>=pParse->nAlloc ){\n    return jsonParseAddNodeExpand(pParse, eType, n, zContent);\n  }\n  p = &pParse->aNode[pParse->nNode];\n  p->eType = (u8)eType;\n  p->jnFlags = 0;\n  p->n = n;\n  p->u.zJContent = zContent;\n  return pParse->nNode++;\n}\n\n/*\n** Return true if z[] begins with 4 (or more) hexadecimal digits\n*/\nstatic int jsonIs4Hex(const char *z){\n  int i;\n  for(i=0; i<4; i++) if( !safe_isxdigit(z[i]) ) return 0;\n  return 1;\n}\n\n/*\n** Parse a single JSON value which begins at pParse->zJson[i].  Return the\n** index of the first character past the end of the value parsed.\n**\n** Return negative for a syntax error.  Special cases:  return -2 if the\n** first non-whitespace character is '}' and return -3 if the first\n** non-whitespace character is ']'.\n*/\nstatic int jsonParseValue(JsonParse *pParse, u32 i){\n  char c;\n  u32 j;\n  int iThis;\n  int x;\n  JsonNode *pNode;\n  const char *z = pParse->zJson;\n  while( safe_isspace(z[i]) ){ i++; }\n  if( (c = z[i])=='{' ){\n    /* Parse object */\n    iThis = jsonParseAddNode(pParse, JSON_OBJECT, 0, 0);\n    if( iThis<0 ) return -1;\n    for(j=i+1;;j++){\n      while( safe_isspace(z[j]) ){ j++; }\n      if( ++pParse->iDepth > JSON_MAX_DEPTH ) return -1;\n      x = jsonParseValue(pParse, j);\n      if( x<0 ){\n        pParse->iDepth--;\n        if( x==(-2) && pParse->nNode==(u32)iThis+1 ) return j+1;\n        return -1;\n      }\n      if( pParse->oom ) return -1;\n      pNode = &pParse->aNode[pParse->nNode-1];\n      if( pNode->eType!=JSON_STRING ) return -1;\n      pNode->jnFlags |= JNODE_LABEL;\n      j = x;\n      while( safe_isspace(z[j]) ){ j++; }\n      if( z[j]!=':' ) return -1;\n      j++;\n      x = jsonParseValue(pParse, j);\n      pParse->iDepth--;\n      if( x<0 ) return -1;\n      j = x;\n      while( safe_isspace(z[j]) ){ j++; }\n      c = z[j];\n      if( c==',' ) continue;\n      if( c!='}' ) return -1;\n      break;\n    }\n    pParse->aNode[iThis].n = pParse->nNode - (u32)iThis - 1;\n    return j+1;\n  }else if( c=='[' ){\n    /* Parse array */\n    iThis = jsonParseAddNode(pParse, JSON_ARRAY, 0, 0);\n    if( iThis<0 ) return -1;\n    for(j=i+1;;j++){\n      while( safe_isspace(z[j]) ){ j++; }\n      if( ++pParse->iDepth > JSON_MAX_DEPTH ) return -1;\n      x = jsonParseValue(pParse, j);\n      pParse->iDepth--;\n      if( x<0 ){\n        if( x==(-3) && pParse->nNode==(u32)iThis+1 ) return j+1;\n        return -1;\n      }\n      j = x;\n      while( safe_isspace(z[j]) ){ j++; }\n      c = z[j];\n      if( c==',' ) continue;\n      if( c!=']' ) return -1;\n      break;\n    }\n    pParse->aNode[iThis].n = pParse->nNode - (u32)iThis - 1;\n    return j+1;\n  }else if( c=='\"' ){\n    /* Parse string */\n    u8 jnFlags = 0;\n    j = i+1;\n    for(;;){\n      c = z[j];\n      if( (c & ~0x1f)==0 ){\n        /* Control characters are not allowed in strings */\n        return -1;\n      }\n      if( c=='\\\\' ){\n        c = z[++j];\n        if( c=='\"' || c=='\\\\' || c=='/' || c=='b' || c=='f'\n           || c=='n' || c=='r' || c=='t'\n           || (c=='u' && jsonIs4Hex(z+j+1)) ){\n          jnFlags = JNODE_ESCAPE;\n        }else{\n          return -1;\n        }\n      }else if( c=='\"' ){\n        break;\n      }\n      j++;\n    }\n    jsonParseAddNode(pParse, JSON_STRING, j+1-i, &z[i]);\n    if( !pParse->oom ) pParse->aNode[pParse->nNode-1].jnFlags = jnFlags;\n    return j+1;\n  }else if( c=='n'\n         && strncmp(z+i,\"null\",4)==0\n         && !safe_isalnum(z[i+4]) ){\n    jsonParseAddNode(pParse, JSON_NULL, 0, 0);\n    return i+4;\n  }else if( c=='t'\n         && strncmp(z+i,\"true\",4)==0\n         && !safe_isalnum(z[i+4]) ){\n    jsonParseAddNode(pParse, JSON_TRUE, 0, 0);\n    return i+4;\n  }else if( c=='f'\n         && strncmp(z+i,\"false\",5)==0\n         && !safe_isalnum(z[i+5]) ){\n    jsonParseAddNode(pParse, JSON_FALSE, 0, 0);\n    return i+5;\n  }else if( c=='-' || (c>='0' && c<='9') ){\n    /* Parse number */\n    u8 seenDP = 0;\n    u8 seenE = 0;\n    assert( '-' < '0' );\n    if( c<='0' ){\n      j = c=='-' ? i+1 : i;\n      if( z[j]=='0' && z[j+1]>='0' && z[j+1]<='9' ) return -1;\n    }\n    j = i+1;\n    for(;; j++){\n      c = z[j];\n      if( c>='0' && c<='9' ) continue;\n      if( c=='.' ){\n        if( z[j-1]=='-' ) return -1;\n        if( seenDP ) return -1;\n        seenDP = 1;\n        continue;\n      }\n      if( c=='e' || c=='E' ){\n        if( z[j-1]<'0' ) return -1;\n        if( seenE ) return -1;\n        seenDP = seenE = 1;\n        c = z[j+1];\n        if( c=='+' || c=='-' ){\n          j++;\n          c = z[j+1];\n        }\n        if( c<'0' || c>'9' ) return -1;\n        continue;\n      }\n      break;\n    }\n    if( z[j-1]<'0' ) return -1;\n    jsonParseAddNode(pParse, seenDP ? JSON_REAL : JSON_INT,\n                        j - i, &z[i]);\n    return j;\n  }else if( c=='}' ){\n    return -2;  /* End of {...} */\n  }else if( c==']' ){\n    return -3;  /* End of [...] */\n  }else if( c==0 ){\n    return 0;   /* End of file */\n  }else{\n    return -1;  /* Syntax error */\n  }\n}\n\n/*\n** Parse a complete JSON string.  Return 0 on success or non-zero if there\n** are any errors.  If an error occurs, free all memory associated with\n** pParse.\n**\n** pParse is uninitialized when this routine is called.\n*/\nstatic int jsonParse(\n  JsonParse *pParse,           /* Initialize and fill this JsonParse object */\n  sqlite3_context *pCtx,       /* Report errors here */\n  const char *zJson            /* Input JSON text to be parsed */\n){\n  int i;\n  memset(pParse, 0, sizeof(*pParse));\n  if( zJson==0 ) return 1;\n  pParse->zJson = zJson;\n  i = jsonParseValue(pParse, 0);\n  if( pParse->oom ) i = -1;\n  if( i>0 ){\n    assert( pParse->iDepth==0 );\n    while( safe_isspace(zJson[i]) ) i++;\n    if( zJson[i] ) i = -1;\n  }\n  if( i<=0 ){\n    if( pCtx!=0 ){\n      if( pParse->oom ){\n        sqlite3_result_error_nomem(pCtx);\n      }else{\n        sqlite3_result_error(pCtx, \"malformed JSON\", -1);\n      }\n    }\n    jsonParseReset(pParse);\n    return 1;\n  }\n  return 0;\n}\n\n/* Mark node i of pParse as being a child of iParent.  Call recursively\n** to fill in all the descendants of node i.\n*/\nstatic void jsonParseFillInParentage(JsonParse *pParse, u32 i, u32 iParent){\n  JsonNode *pNode = &pParse->aNode[i];\n  u32 j;\n  pParse->aUp[i] = iParent;\n  switch( pNode->eType ){\n    case JSON_ARRAY: {\n      for(j=1; j<=pNode->n; j += jsonNodeSize(pNode+j)){\n        jsonParseFillInParentage(pParse, i+j, i);\n      }\n      break;\n    }\n    case JSON_OBJECT: {\n      for(j=1; j<=pNode->n; j += jsonNodeSize(pNode+j+1)+1){\n        pParse->aUp[i+j] = i;\n        jsonParseFillInParentage(pParse, i+j+1, i);\n      }\n      break;\n    }\n    default: {\n      break;\n    }\n  }\n}\n\n/*\n** Compute the parentage of all nodes in a completed parse.\n*/\nstatic int jsonParseFindParents(JsonParse *pParse){\n  u32 *aUp;\n  assert( pParse->aUp==0 );\n  aUp = pParse->aUp = sqlite3_malloc64( sizeof(u32)*pParse->nNode );\n  if( aUp==0 ){\n    pParse->oom = 1;\n    return SQLITE_NOMEM;\n  }\n  jsonParseFillInParentage(pParse, 0, 0);\n  return SQLITE_OK;\n}\n\n/*\n** Magic number used for the JSON parse cache in sqlite3_get_auxdata()\n*/\n#define JSON_CACHE_ID  (-429938)  /* First cache entry */\n#define JSON_CACHE_SZ  4          /* Max number of cache entries */\n\n/*\n** Obtain a complete parse of the JSON found in the first argument\n** of the argv array.  Use the sqlite3_get_auxdata() cache for this\n** parse if it is available.  If the cache is not available or if it\n** is no longer valid, parse the JSON again and return the new parse,\n** and also register the new parse so that it will be available for\n** future sqlite3_get_auxdata() calls.\n*/\nstatic JsonParse *jsonParseCached(\n  sqlite3_context *pCtx,\n  sqlite3_value **argv,\n  sqlite3_context *pErrCtx\n){\n  const char *zJson = (const char*)sqlite3_value_text(argv[0]);\n  int nJson = sqlite3_value_bytes(argv[0]);\n  JsonParse *p;\n  JsonParse *pMatch = 0;\n  int iKey;\n  int iMinKey = 0;\n  u32 iMinHold = 0xffffffff;\n  u32 iMaxHold = 0;\n  if( zJson==0 ) return 0;\n  for(iKey=0; iKey<JSON_CACHE_SZ; iKey++){\n    p = (JsonParse*)sqlite3_get_auxdata(pCtx, JSON_CACHE_ID+iKey);\n    if( p==0 ){\n      iMinKey = iKey;\n      break;\n    }\n    if( pMatch==0\n     && p->nJson==nJson\n     && memcmp(p->zJson,zJson,nJson)==0\n    ){\n      p->nErr = 0;\n      pMatch = p;\n    }else if( p->iHold<iMinHold ){\n      iMinHold = p->iHold;\n      iMinKey = iKey;\n    }\n    if( p->iHold>iMaxHold ){\n      iMaxHold = p->iHold;\n    }\n  }\n  if( pMatch ){\n    pMatch->nErr = 0;\n    pMatch->iHold = iMaxHold+1;\n    return pMatch;\n  }\n  p = sqlite3_malloc64( sizeof(*p) + nJson + 1 );\n  if( p==0 ){\n    sqlite3_result_error_nomem(pCtx);\n    return 0;\n  }\n  memset(p, 0, sizeof(*p));\n  p->zJson = (char*)&p[1];\n  memcpy((char*)p->zJson, zJson, nJson+1);\n  if( jsonParse(p, pErrCtx, p->zJson) ){\n    sqlite3_free(p);\n    return 0;\n  }\n  p->nJson = nJson;\n  p->iHold = iMaxHold+1;\n  sqlite3_set_auxdata(pCtx, JSON_CACHE_ID+iMinKey, p,\n                      (void(*)(void*))jsonParseFree);\n  return (JsonParse*)sqlite3_get_auxdata(pCtx, JSON_CACHE_ID+iMinKey);\n}\n\n/*\n** Compare the OBJECT label at pNode against zKey,nKey.  Return true on\n** a match.\n*/\nstatic int jsonLabelCompare(JsonNode *pNode, const char *zKey, u32 nKey){\n  if( pNode->jnFlags & JNODE_RAW ){\n    if( pNode->n!=nKey ) return 0;\n    return strncmp(pNode->u.zJContent, zKey, nKey)==0;\n  }else{\n    if( pNode->n!=nKey+2 ) return 0;\n    return strncmp(pNode->u.zJContent+1, zKey, nKey)==0;\n  }\n}\n\n/* forward declaration */\nstatic JsonNode *jsonLookupAppend(JsonParse*,const char*,int*,const char**);\n\n/*\n** Search along zPath to find the node specified.  Return a pointer\n** to that node, or NULL if zPath is malformed or if there is no such\n** node.\n**\n** If pApnd!=0, then try to append new nodes to complete zPath if it is\n** possible to do so and if no existing node corresponds to zPath.  If\n** new nodes are appended *pApnd is set to 1.\n*/\nstatic JsonNode *jsonLookupStep(\n  JsonParse *pParse,      /* The JSON to search */\n  u32 iRoot,              /* Begin the search at this node */\n  const char *zPath,      /* The path to search */\n  int *pApnd,             /* Append nodes to complete path if not NULL */\n  const char **pzErr      /* Make *pzErr point to any syntax error in zPath */\n){\n  u32 i, j, nKey;\n  const char *zKey;\n  JsonNode *pRoot = &pParse->aNode[iRoot];\n  if( zPath[0]==0 ) return pRoot;\n  if( zPath[0]=='.' ){\n    if( pRoot->eType!=JSON_OBJECT ) return 0;\n    zPath++;\n    if( zPath[0]=='\"' ){\n      zKey = zPath + 1;\n      for(i=1; zPath[i] && zPath[i]!='\"'; i++){}\n      nKey = i-1;\n      if( zPath[i] ){\n        i++;\n      }else{\n        *pzErr = zPath;\n        return 0;\n      }\n    }else{\n      zKey = zPath;\n      for(i=0; zPath[i] && zPath[i]!='.' && zPath[i]!='['; i++){}\n      nKey = i;\n    }\n    if( nKey==0 ){\n      *pzErr = zPath;\n      return 0;\n    }\n    j = 1;\n    for(;;){\n      while( j<=pRoot->n ){\n        if( jsonLabelCompare(pRoot+j, zKey, nKey) ){\n          return jsonLookupStep(pParse, iRoot+j+1, &zPath[i], pApnd, pzErr);\n        }\n        j++;\n        j += jsonNodeSize(&pRoot[j]);\n      }\n      if( (pRoot->jnFlags & JNODE_APPEND)==0 ) break;\n      iRoot += pRoot->u.iAppend;\n      pRoot = &pParse->aNode[iRoot];\n      j = 1;\n    }\n    if( pApnd ){\n      u32 iStart, iLabel;\n      JsonNode *pNode;\n      iStart = jsonParseAddNode(pParse, JSON_OBJECT, 2, 0);\n      iLabel = jsonParseAddNode(pParse, JSON_STRING, i, zPath);\n      zPath += i;\n      pNode = jsonLookupAppend(pParse, zPath, pApnd, pzErr);\n      if( pParse->oom ) return 0;\n      if( pNode ){\n        pRoot = &pParse->aNode[iRoot];\n        pRoot->u.iAppend = iStart - iRoot;\n        pRoot->jnFlags |= JNODE_APPEND;\n        pParse->aNode[iLabel].jnFlags |= JNODE_RAW;\n      }\n      return pNode;\n    }\n  }else if( zPath[0]=='[' && safe_isdigit(zPath[1]) ){\n    if( pRoot->eType!=JSON_ARRAY ) return 0;\n    i = 0;\n    j = 1;\n    while( safe_isdigit(zPath[j]) ){\n      i = i*10 + zPath[j] - '0';\n      j++;\n    }\n    if( zPath[j]!=']' ){\n      *pzErr = zPath;\n      return 0;\n    }\n    zPath += j + 1;\n    j = 1;\n    for(;;){\n      while( j<=pRoot->n && (i>0 || (pRoot[j].jnFlags & JNODE_REMOVE)!=0) ){\n        if( (pRoot[j].jnFlags & JNODE_REMOVE)==0 ) i--;\n        j += jsonNodeSize(&pRoot[j]);\n      }\n      if( (pRoot->jnFlags & JNODE_APPEND)==0 ) break;\n      iRoot += pRoot->u.iAppend;\n      pRoot = &pParse->aNode[iRoot];\n      j = 1;\n    }\n    if( j<=pRoot->n ){\n      return jsonLookupStep(pParse, iRoot+j, zPath, pApnd, pzErr);\n    }\n    if( i==0 && pApnd ){\n      u32 iStart;\n      JsonNode *pNode;\n      iStart = jsonParseAddNode(pParse, JSON_ARRAY, 1, 0);\n      pNode = jsonLookupAppend(pParse, zPath, pApnd, pzErr);\n      if( pParse->oom ) return 0;\n      if( pNode ){\n        pRoot = &pParse->aNode[iRoot];\n        pRoot->u.iAppend = iStart - iRoot;\n        pRoot->jnFlags |= JNODE_APPEND;\n      }\n      return pNode;\n    }\n  }else{\n    *pzErr = zPath;\n  }\n  return 0;\n}\n\n/*\n** Append content to pParse that will complete zPath.  Return a pointer\n** to the inserted node, or return NULL if the append fails.\n*/\nstatic JsonNode *jsonLookupAppend(\n  JsonParse *pParse,     /* Append content to the JSON parse */\n  const char *zPath,     /* Description of content to append */\n  int *pApnd,            /* Set this flag to 1 */\n  const char **pzErr     /* Make this point to any syntax error */\n){\n  *pApnd = 1;\n  if( zPath[0]==0 ){\n    jsonParseAddNode(pParse, JSON_NULL, 0, 0);\n    return pParse->oom ? 0 : &pParse->aNode[pParse->nNode-1];\n  }\n  if( zPath[0]=='.' ){\n    jsonParseAddNode(pParse, JSON_OBJECT, 0, 0);\n  }else if( strncmp(zPath,\"[0]\",3)==0 ){\n    jsonParseAddNode(pParse, JSON_ARRAY, 0, 0);\n  }else{\n    return 0;\n  }\n  if( pParse->oom ) return 0;\n  return jsonLookupStep(pParse, pParse->nNode-1, zPath, pApnd, pzErr);\n}\n\n/*\n** Return the text of a syntax error message on a JSON path.  Space is\n** obtained from sqlite3_malloc().\n*/\nstatic char *jsonPathSyntaxError(const char *zErr){\n  return sqlite3_mprintf(\"JSON path error near '%q'\", zErr);\n}\n\n/*\n** Do a node lookup using zPath.  Return a pointer to the node on success.\n** Return NULL if not found or if there is an error.\n**\n** On an error, write an error message into pCtx and increment the\n** pParse->nErr counter.\n**\n** If pApnd!=NULL then try to append missing nodes and set *pApnd = 1 if\n** nodes are appended.\n*/\nstatic JsonNode *jsonLookup(\n  JsonParse *pParse,      /* The JSON to search */\n  const char *zPath,      /* The path to search */\n  int *pApnd,             /* Append nodes to complete path if not NULL */\n  sqlite3_context *pCtx   /* Report errors here, if not NULL */\n){\n  const char *zErr = 0;\n  JsonNode *pNode = 0;\n  char *zMsg;\n\n  if( zPath==0 ) return 0;\n  if( zPath[0]!='$' ){\n    zErr = zPath;\n    goto lookup_err;\n  }\n  zPath++;\n  pNode = jsonLookupStep(pParse, 0, zPath, pApnd, &zErr);\n  if( zErr==0 ) return pNode;\n\nlookup_err:\n  pParse->nErr++;\n  assert( zErr!=0 && pCtx!=0 );\n  zMsg = jsonPathSyntaxError(zErr);\n  if( zMsg ){\n    sqlite3_result_error(pCtx, zMsg, -1);\n    sqlite3_free(zMsg);\n  }else{\n    sqlite3_result_error_nomem(pCtx);\n  }\n  return 0;\n}\n\n\n/*\n** Report the wrong number of arguments for json_insert(), json_replace()\n** or json_set().\n*/\nstatic void jsonWrongNumArgs(\n  sqlite3_context *pCtx,\n  const char *zFuncName\n){\n  char *zMsg = sqlite3_mprintf(\"json_%s() needs an odd number of arguments\",\n                               zFuncName);\n  sqlite3_result_error(pCtx, zMsg, -1);\n  sqlite3_free(zMsg);     \n}\n\n/*\n** Mark all NULL entries in the Object passed in as JNODE_REMOVE.\n*/\nstatic void jsonRemoveAllNulls(JsonNode *pNode){\n  int i, n;\n  assert( pNode->eType==JSON_OBJECT );\n  n = pNode->n;\n  for(i=2; i<=n; i += jsonNodeSize(&pNode[i])+1){\n    switch( pNode[i].eType ){\n      case JSON_NULL:\n        pNode[i].jnFlags |= JNODE_REMOVE;\n        break;\n      case JSON_OBJECT:\n        jsonRemoveAllNulls(&pNode[i]);\n        break;\n    }\n  }\n}\n\n\n/****************************************************************************\n** SQL functions used for testing and debugging\n****************************************************************************/\n\n#ifdef SQLITE_DEBUG\n/*\n** The json_parse(JSON) function returns a string which describes\n** a parse of the JSON provided.  Or it returns NULL if JSON is not\n** well-formed.\n*/\nstatic void jsonParseFunc(\n  sqlite3_context *ctx,\n  int argc,\n  sqlite3_value **argv\n){\n  JsonString s;       /* Output string - not real JSON */\n  JsonParse x;        /* The parse */\n  u32 i;\n\n  assert( argc==1 );\n  if( jsonParse(&x, ctx, (const char*)sqlite3_value_text(argv[0])) ) return;\n  jsonParseFindParents(&x);\n  jsonInit(&s, ctx);\n  for(i=0; i<x.nNode; i++){\n    const char *zType;\n    if( x.aNode[i].jnFlags & JNODE_LABEL ){\n      assert( x.aNode[i].eType==JSON_STRING );\n      zType = \"label\";\n    }else{\n      zType = jsonType[x.aNode[i].eType];\n    }\n    jsonPrintf(100, &s,\"node %3u: %7s n=%-4d up=%-4d\",\n               i, zType, x.aNode[i].n, x.aUp[i]);\n    if( x.aNode[i].u.zJContent!=0 ){\n      jsonAppendRaw(&s, \" \", 1);\n      jsonAppendRaw(&s, x.aNode[i].u.zJContent, x.aNode[i].n);\n    }\n    jsonAppendRaw(&s, \"\\n\", 1);\n  }\n  jsonParseReset(&x);\n  jsonResult(&s);\n}\n\n/*\n** The json_test1(JSON) function return true (1) if the input is JSON\n** text generated by another json function.  It returns (0) if the input\n** is not known to be JSON.\n*/\nstatic void jsonTest1Func(\n  sqlite3_context *ctx,\n  int argc,\n  sqlite3_value **argv\n){\n  UNUSED_PARAM(argc);\n  sqlite3_result_int(ctx, sqlite3_value_subtype(argv[0])==JSON_SUBTYPE);\n}\n#endif /* SQLITE_DEBUG */\n\n/****************************************************************************\n** Scalar SQL function implementations\n****************************************************************************/\n\n/*\n** Implementation of the json_QUOTE(VALUE) function.  Return a JSON value\n** corresponding to the SQL value input.  Mostly this means putting \n** double-quotes around strings and returning the unquoted string \"null\"\n** when given a NULL input.\n*/\nstatic void jsonQuoteFunc(\n  sqlite3_context *ctx,\n  int argc,\n  sqlite3_value **argv\n){\n  JsonString jx;\n  UNUSED_PARAM(argc);\n\n  jsonInit(&jx, ctx);\n  jsonAppendValue(&jx, argv[0]);\n  jsonResult(&jx);\n  sqlite3_result_subtype(ctx, JSON_SUBTYPE);\n}\n\n/*\n** Implementation of the json_array(VALUE,...) function.  Return a JSON\n** array that contains all values given in arguments.  Or if any argument\n** is a BLOB, throw an error.\n*/\nstatic void jsonArrayFunc(\n  sqlite3_context *ctx,\n  int argc,\n  sqlite3_value **argv\n){\n  int i;\n  JsonString jx;\n\n  jsonInit(&jx, ctx);\n  jsonAppendChar(&jx, '[');\n  for(i=0; i<argc; i++){\n    jsonAppendSeparator(&jx);\n    jsonAppendValue(&jx, argv[i]);\n  }\n  jsonAppendChar(&jx, ']');\n  jsonResult(&jx);\n  sqlite3_result_subtype(ctx, JSON_SUBTYPE);\n}\n\n\n/*\n** json_array_length(JSON)\n** json_array_length(JSON, PATH)\n**\n** Return the number of elements in the top-level JSON array.  \n** Return 0 if the input is not a well-formed JSON array.\n*/\nstatic void jsonArrayLengthFunc(\n  sqlite3_context *ctx,\n  int argc,\n  sqlite3_value **argv\n){\n  JsonParse *p;          /* The parse */\n  sqlite3_int64 n = 0;\n  u32 i;\n  JsonNode *pNode;\n\n  p = jsonParseCached(ctx, argv, ctx);\n  if( p==0 ) return;\n  assert( p->nNode );\n  if( argc==2 ){\n    const char *zPath = (const char*)sqlite3_value_text(argv[1]);\n    pNode = jsonLookup(p, zPath, 0, ctx);\n  }else{\n    pNode = p->aNode;\n  }\n  if( pNode==0 ){\n    return;\n  }\n  if( pNode->eType==JSON_ARRAY ){\n    assert( (pNode->jnFlags & JNODE_APPEND)==0 );\n    for(i=1; i<=pNode->n; n++){\n      i += jsonNodeSize(&pNode[i]);\n    }\n  }\n  sqlite3_result_int64(ctx, n);\n}\n\n/*\n** json_extract(JSON, PATH, ...)\n**\n** Return the element described by PATH.  Return NULL if there is no\n** PATH element.  If there are multiple PATHs, then return a JSON array\n** with the result from each path.  Throw an error if the JSON or any PATH\n** is malformed.\n*/\nstatic void jsonExtractFunc(\n  sqlite3_context *ctx,\n  int argc,\n  sqlite3_value **argv\n){\n  JsonParse *p;          /* The parse */\n  JsonNode *pNode;\n  const char *zPath;\n  JsonString jx;\n  int i;\n\n  if( argc<2 ) return;\n  p = jsonParseCached(ctx, argv, ctx);\n  if( p==0 ) return;\n  jsonInit(&jx, ctx);\n  jsonAppendChar(&jx, '[');\n  for(i=1; i<argc; i++){\n    zPath = (const char*)sqlite3_value_text(argv[i]);\n    pNode = jsonLookup(p, zPath, 0, ctx);\n    if( p->nErr ) break;\n    if( argc>2 ){\n      jsonAppendSeparator(&jx);\n      if( pNode ){\n        jsonRenderNode(pNode, &jx, 0);\n      }else{\n        jsonAppendRaw(&jx, \"null\", 4);\n      }\n    }else if( pNode ){\n      jsonReturn(pNode, ctx, 0);\n    }\n  }\n  if( argc>2 && i==argc ){\n    jsonAppendChar(&jx, ']');\n    jsonResult(&jx);\n    sqlite3_result_subtype(ctx, JSON_SUBTYPE);\n  }\n  jsonReset(&jx);\n}\n\n/* This is the RFC 7396 MergePatch algorithm.\n*/\nstatic JsonNode *jsonMergePatch(\n  JsonParse *pParse,   /* The JSON parser that contains the TARGET */\n  u32 iTarget,         /* Node of the TARGET in pParse */\n  JsonNode *pPatch     /* The PATCH */\n){\n  u32 i, j;\n  u32 iRoot;\n  JsonNode *pTarget;\n  if( pPatch->eType!=JSON_OBJECT ){\n    return pPatch;\n  }\n  assert( iTarget>=0 && iTarget<pParse->nNode );\n  pTarget = &pParse->aNode[iTarget];\n  assert( (pPatch->jnFlags & JNODE_APPEND)==0 );\n  if( pTarget->eType!=JSON_OBJECT ){\n    jsonRemoveAllNulls(pPatch);\n    return pPatch;\n  }\n  iRoot = iTarget;\n  for(i=1; i<pPatch->n; i += jsonNodeSize(&pPatch[i+1])+1){\n    u32 nKey;\n    const char *zKey;\n    assert( pPatch[i].eType==JSON_STRING );\n    assert( pPatch[i].jnFlags & JNODE_LABEL );\n    nKey = pPatch[i].n;\n    zKey = pPatch[i].u.zJContent;\n    assert( (pPatch[i].jnFlags & JNODE_RAW)==0 );\n    for(j=1; j<pTarget->n; j += jsonNodeSize(&pTarget[j+1])+1 ){\n      assert( pTarget[j].eType==JSON_STRING );\n      assert( pTarget[j].jnFlags & JNODE_LABEL );\n      assert( (pPatch[i].jnFlags & JNODE_RAW)==0 );\n      if( pTarget[j].n==nKey && strncmp(pTarget[j].u.zJContent,zKey,nKey)==0 ){\n        if( pTarget[j+1].jnFlags & (JNODE_REMOVE|JNODE_PATCH) ) break;\n        if( pPatch[i+1].eType==JSON_NULL ){\n          pTarget[j+1].jnFlags |= JNODE_REMOVE;\n        }else{\n          JsonNode *pNew = jsonMergePatch(pParse, iTarget+j+1, &pPatch[i+1]);\n          if( pNew==0 ) return 0;\n          pTarget = &pParse->aNode[iTarget];\n          if( pNew!=&pTarget[j+1] ){\n            pTarget[j+1].u.pPatch = pNew;\n            pTarget[j+1].jnFlags |= JNODE_PATCH;\n          }\n        }\n        break;\n      }\n    }\n    if( j>=pTarget->n && pPatch[i+1].eType!=JSON_NULL ){\n      int iStart, iPatch;\n      iStart = jsonParseAddNode(pParse, JSON_OBJECT, 2, 0);\n      jsonParseAddNode(pParse, JSON_STRING, nKey, zKey);\n      iPatch = jsonParseAddNode(pParse, JSON_TRUE, 0, 0);\n      if( pParse->oom ) return 0;\n      jsonRemoveAllNulls(pPatch);\n      pTarget = &pParse->aNode[iTarget];\n      pParse->aNode[iRoot].jnFlags |= JNODE_APPEND;\n      pParse->aNode[iRoot].u.iAppend = iStart - iRoot;\n      iRoot = iStart;\n      pParse->aNode[iPatch].jnFlags |= JNODE_PATCH;\n      pParse->aNode[iPatch].u.pPatch = &pPatch[i+1];\n    }\n  }\n  return pTarget;\n}\n\n/*\n** Implementation of the json_mergepatch(JSON1,JSON2) function.  Return a JSON\n** object that is the result of running the RFC 7396 MergePatch() algorithm\n** on the two arguments.\n*/\nstatic void jsonPatchFunc(\n  sqlite3_context *ctx,\n  int argc,\n  sqlite3_value **argv\n){\n  JsonParse x;     /* The JSON that is being patched */\n  JsonParse y;     /* The patch */\n  JsonNode *pResult;   /* The result of the merge */\n\n  UNUSED_PARAM(argc);\n  if( jsonParse(&x, ctx, (const char*)sqlite3_value_text(argv[0])) ) return;\n  if( jsonParse(&y, ctx, (const char*)sqlite3_value_text(argv[1])) ){\n    jsonParseReset(&x);\n    return;\n  }\n  pResult = jsonMergePatch(&x, 0, y.aNode);\n  assert( pResult!=0 || x.oom );\n  if( pResult ){\n    jsonReturnJson(pResult, ctx, 0);\n  }else{\n    sqlite3_result_error_nomem(ctx);\n  }\n  jsonParseReset(&x);\n  jsonParseReset(&y);\n}\n\n\n/*\n** Implementation of the json_object(NAME,VALUE,...) function.  Return a JSON\n** object that contains all name/value given in arguments.  Or if any name\n** is not a string or if any value is a BLOB, throw an error.\n*/\nstatic void jsonObjectFunc(\n  sqlite3_context *ctx,\n  int argc,\n  sqlite3_value **argv\n){\n  int i;\n  JsonString jx;\n  const char *z;\n  u32 n;\n\n  if( argc&1 ){\n    sqlite3_result_error(ctx, \"json_object() requires an even number \"\n                                  \"of arguments\", -1);\n    return;\n  }\n  jsonInit(&jx, ctx);\n  jsonAppendChar(&jx, '{');\n  for(i=0; i<argc; i+=2){\n    if( sqlite3_value_type(argv[i])!=SQLITE_TEXT ){\n      sqlite3_result_error(ctx, \"json_object() labels must be TEXT\", -1);\n      jsonReset(&jx);\n      return;\n    }\n    jsonAppendSeparator(&jx);\n    z = (const char*)sqlite3_value_text(argv[i]);\n    n = (u32)sqlite3_value_bytes(argv[i]);\n    jsonAppendString(&jx, z, n);\n    jsonAppendChar(&jx, ':');\n    jsonAppendValue(&jx, argv[i+1]);\n  }\n  jsonAppendChar(&jx, '}');\n  jsonResult(&jx);\n  sqlite3_result_subtype(ctx, JSON_SUBTYPE);\n}\n\n\n/*\n** json_remove(JSON, PATH, ...)\n**\n** Remove the named elements from JSON and return the result.  malformed\n** JSON or PATH arguments result in an error.\n*/\nstatic void jsonRemoveFunc(\n  sqlite3_context *ctx,\n  int argc,\n  sqlite3_value **argv\n){\n  JsonParse x;          /* The parse */\n  JsonNode *pNode;\n  const char *zPath;\n  u32 i;\n\n  if( argc<1 ) return;\n  if( jsonParse(&x, ctx, (const char*)sqlite3_value_text(argv[0])) ) return;\n  assert( x.nNode );\n  for(i=1; i<(u32)argc; i++){\n    zPath = (const char*)sqlite3_value_text(argv[i]);\n    if( zPath==0 ) goto remove_done;\n    pNode = jsonLookup(&x, zPath, 0, ctx);\n    if( x.nErr ) goto remove_done;\n    if( pNode ) pNode->jnFlags |= JNODE_REMOVE;\n  }\n  if( (x.aNode[0].jnFlags & JNODE_REMOVE)==0 ){\n    jsonReturnJson(x.aNode, ctx, 0);\n  }\nremove_done:\n  jsonParseReset(&x);\n}\n\n/*\n** json_replace(JSON, PATH, VALUE, ...)\n**\n** Replace the value at PATH with VALUE.  If PATH does not already exist,\n** this routine is a no-op.  If JSON or PATH is malformed, throw an error.\n*/\nstatic void jsonReplaceFunc(\n  sqlite3_context *ctx,\n  int argc,\n  sqlite3_value **argv\n){\n  JsonParse x;          /* The parse */\n  JsonNode *pNode;\n  const char *zPath;\n  u32 i;\n\n  if( argc<1 ) return;\n  if( (argc&1)==0 ) {\n    jsonWrongNumArgs(ctx, \"replace\");\n    return;\n  }\n  if( jsonParse(&x, ctx, (const char*)sqlite3_value_text(argv[0])) ) return;\n  assert( x.nNode );\n  for(i=1; i<(u32)argc; i+=2){\n    zPath = (const char*)sqlite3_value_text(argv[i]);\n    pNode = jsonLookup(&x, zPath, 0, ctx);\n    if( x.nErr ) goto replace_err;\n    if( pNode ){\n      pNode->jnFlags |= (u8)JNODE_REPLACE;\n      pNode->u.iReplace = i + 1;\n    }\n  }\n  if( x.aNode[0].jnFlags & JNODE_REPLACE ){\n    sqlite3_result_value(ctx, argv[x.aNode[0].u.iReplace]);\n  }else{\n    jsonReturnJson(x.aNode, ctx, argv);\n  }\nreplace_err:\n  jsonParseReset(&x);\n}\n\n/*\n** json_set(JSON, PATH, VALUE, ...)\n**\n** Set the value at PATH to VALUE.  Create the PATH if it does not already\n** exist.  Overwrite existing values that do exist.\n** If JSON or PATH is malformed, throw an error.\n**\n** json_insert(JSON, PATH, VALUE, ...)\n**\n** Create PATH and initialize it to VALUE.  If PATH already exists, this\n** routine is a no-op.  If JSON or PATH is malformed, throw an error.\n*/\nstatic void jsonSetFunc(\n  sqlite3_context *ctx,\n  int argc,\n  sqlite3_value **argv\n){\n  JsonParse x;          /* The parse */\n  JsonNode *pNode;\n  const char *zPath;\n  u32 i;\n  int bApnd;\n  int bIsSet = *(int*)sqlite3_user_data(ctx);\n\n  if( argc<1 ) return;\n  if( (argc&1)==0 ) {\n    jsonWrongNumArgs(ctx, bIsSet ? \"set\" : \"insert\");\n    return;\n  }\n  if( jsonParse(&x, ctx, (const char*)sqlite3_value_text(argv[0])) ) return;\n  assert( x.nNode );\n  for(i=1; i<(u32)argc; i+=2){\n    zPath = (const char*)sqlite3_value_text(argv[i]);\n    bApnd = 0;\n    pNode = jsonLookup(&x, zPath, &bApnd, ctx);\n    if( x.oom ){\n      sqlite3_result_error_nomem(ctx);\n      goto jsonSetDone;\n    }else if( x.nErr ){\n      goto jsonSetDone;\n    }else if( pNode && (bApnd || bIsSet) ){\n      pNode->jnFlags |= (u8)JNODE_REPLACE;\n      pNode->u.iReplace = i + 1;\n    }\n  }\n  if( x.aNode[0].jnFlags & JNODE_REPLACE ){\n    sqlite3_result_value(ctx, argv[x.aNode[0].u.iReplace]);\n  }else{\n    jsonReturnJson(x.aNode, ctx, argv);\n  }\njsonSetDone:\n  jsonParseReset(&x);\n}\n\n/*\n** json_type(JSON)\n** json_type(JSON, PATH)\n**\n** Return the top-level \"type\" of a JSON string.  Throw an error if\n** either the JSON or PATH inputs are not well-formed.\n*/\nstatic void jsonTypeFunc(\n  sqlite3_context *ctx,\n  int argc,\n  sqlite3_value **argv\n){\n  JsonParse *p;          /* The parse */\n  const char *zPath;\n  JsonNode *pNode;\n\n  p = jsonParseCached(ctx, argv, ctx);\n  if( p==0 ) return;\n  if( argc==2 ){\n    zPath = (const char*)sqlite3_value_text(argv[1]);\n    pNode = jsonLookup(p, zPath, 0, ctx);\n  }else{\n    pNode = p->aNode;\n  }\n  if( pNode ){\n    sqlite3_result_text(ctx, jsonType[pNode->eType], -1, SQLITE_STATIC);\n  }\n}\n\n/*\n** json_valid(JSON)\n**\n** Return 1 if JSON is a well-formed JSON string according to RFC-7159.\n** Return 0 otherwise.\n*/\nstatic void jsonValidFunc(\n  sqlite3_context *ctx,\n  int argc,\n  sqlite3_value **argv\n){\n  JsonParse *p;          /* The parse */\n  UNUSED_PARAM(argc);\n  p = jsonParseCached(ctx, argv, 0);\n  sqlite3_result_int(ctx, p!=0);\n}\n\n\n/****************************************************************************\n** Aggregate SQL function implementations\n****************************************************************************/\n/*\n** json_group_array(VALUE)\n**\n** Return a JSON array composed of all values in the aggregate.\n*/\nstatic void jsonArrayStep(\n  sqlite3_context *ctx,\n  int argc,\n  sqlite3_value **argv\n){\n  JsonString *pStr;\n  UNUSED_PARAM(argc);\n  pStr = (JsonString*)sqlite3_aggregate_context(ctx, sizeof(*pStr));\n  if( pStr ){\n    if( pStr->zBuf==0 ){\n      jsonInit(pStr, ctx);\n      jsonAppendChar(pStr, '[');\n    }else{\n      jsonAppendChar(pStr, ',');\n      pStr->pCtx = ctx;\n    }\n    jsonAppendValue(pStr, argv[0]);\n  }\n}\nstatic void jsonArrayCompute(sqlite3_context *ctx, int isFinal){\n  JsonString *pStr;\n  pStr = (JsonString*)sqlite3_aggregate_context(ctx, 0);\n  if( pStr ){\n    pStr->pCtx = ctx;\n    jsonAppendChar(pStr, ']');\n    if( pStr->bErr ){\n      if( pStr->bErr==1 ) sqlite3_result_error_nomem(ctx);\n      assert( pStr->bStatic );\n    }else if( isFinal ){\n      sqlite3_result_text(ctx, pStr->zBuf, (int)pStr->nUsed,\n                          pStr->bStatic ? SQLITE_TRANSIENT : sqlite3_free);\n      pStr->bStatic = 1;\n    }else{\n      sqlite3_result_text(ctx, pStr->zBuf, (int)pStr->nUsed, SQLITE_TRANSIENT);\n      pStr->nUsed--;\n    }\n  }else{\n    sqlite3_result_text(ctx, \"[]\", 2, SQLITE_STATIC);\n  }\n  sqlite3_result_subtype(ctx, JSON_SUBTYPE);\n}\nstatic void jsonArrayValue(sqlite3_context *ctx){\n  jsonArrayCompute(ctx, 0);\n}\nstatic void jsonArrayFinal(sqlite3_context *ctx){\n  jsonArrayCompute(ctx, 1);\n}\n\n#ifndef SQLITE_OMIT_WINDOWFUNC\n/*\n** This method works for both json_group_array() and json_group_object().\n** It works by removing the first element of the group by searching forward\n** to the first comma (\",\") that is not within a string and deleting all\n** text through that comma.\n*/\nstatic void jsonGroupInverse(\n  sqlite3_context *ctx,\n  int argc,\n  sqlite3_value **argv\n){\n  int i;\n  int inStr = 0;\n  char *z;\n  JsonString *pStr;\n  UNUSED_PARAM(argc);\n  UNUSED_PARAM(argv);\n  pStr = (JsonString*)sqlite3_aggregate_context(ctx, 0);\n#ifdef NEVER\n  /* pStr is always non-NULL since jsonArrayStep() or jsonObjectStep() will\n  ** always have been called to initalize it */\n  if( NEVER(!pStr) ) return;\n#endif\n  z = pStr->zBuf;\n  for(i=1; z[i]!=',' || inStr; i++){\n    assert( i<pStr->nUsed );\n    if( z[i]=='\"' ){\n      inStr = !inStr;\n    }else if( z[i]=='\\\\' ){\n      i++;\n    }\n  }\n  pStr->nUsed -= i;      \n  memmove(&z[1], &z[i+1], (size_t)pStr->nUsed-1);\n}\n#else\n# define jsonGroupInverse 0\n#endif\n\n\n/*\n** json_group_obj(NAME,VALUE)\n**\n** Return a JSON object composed of all names and values in the aggregate.\n*/\nstatic void jsonObjectStep(\n  sqlite3_context *ctx,\n  int argc,\n  sqlite3_value **argv\n){\n  JsonString *pStr;\n  const char *z;\n  u32 n;\n  UNUSED_PARAM(argc);\n  pStr = (JsonString*)sqlite3_aggregate_context(ctx, sizeof(*pStr));\n  if( pStr ){\n    if( pStr->zBuf==0 ){\n      jsonInit(pStr, ctx);\n      jsonAppendChar(pStr, '{');\n    }else{\n      jsonAppendChar(pStr, ',');\n      pStr->pCtx = ctx;\n    }\n    z = (const char*)sqlite3_value_text(argv[0]);\n    n = (u32)sqlite3_value_bytes(argv[0]);\n    jsonAppendString(pStr, z, n);\n    jsonAppendChar(pStr, ':');\n    jsonAppendValue(pStr, argv[1]);\n  }\n}\nstatic void jsonObjectCompute(sqlite3_context *ctx, int isFinal){\n  JsonString *pStr;\n  pStr = (JsonString*)sqlite3_aggregate_context(ctx, 0);\n  if( pStr ){\n    jsonAppendChar(pStr, '}');\n    if( pStr->bErr ){\n      if( pStr->bErr==1 ) sqlite3_result_error_nomem(ctx);\n      assert( pStr->bStatic );\n    }else if( isFinal ){\n      sqlite3_result_text(ctx, pStr->zBuf, (int)pStr->nUsed,\n                          pStr->bStatic ? SQLITE_TRANSIENT : sqlite3_free);\n      pStr->bStatic = 1;\n    }else{\n      sqlite3_result_text(ctx, pStr->zBuf, (int)pStr->nUsed, SQLITE_TRANSIENT);\n      pStr->nUsed--;\n    }\n  }else{\n    sqlite3_result_text(ctx, \"{}\", 2, SQLITE_STATIC);\n  }\n  sqlite3_result_subtype(ctx, JSON_SUBTYPE);\n}\nstatic void jsonObjectValue(sqlite3_context *ctx){\n  jsonObjectCompute(ctx, 0);\n}\nstatic void jsonObjectFinal(sqlite3_context *ctx){\n  jsonObjectCompute(ctx, 1);\n}\n\n\n\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n/****************************************************************************\n** The json_each virtual table\n****************************************************************************/\ntypedef struct JsonEachCursor JsonEachCursor;\nstruct JsonEachCursor {\n  sqlite3_vtab_cursor base;  /* Base class - must be first */\n  u32 iRowid;                /* The rowid */\n  u32 iBegin;                /* The first node of the scan */\n  u32 i;                     /* Index in sParse.aNode[] of current row */\n  u32 iEnd;                  /* EOF when i equals or exceeds this value */\n  u8 eType;                  /* Type of top-level element */\n  u8 bRecursive;             /* True for json_tree().  False for json_each() */\n  char *zJson;               /* Input JSON */\n  char *zRoot;               /* Path by which to filter zJson */\n  JsonParse sParse;          /* Parse of the input JSON */\n};\n\n/* Constructor for the json_each virtual table */\nstatic int jsonEachConnect(\n  sqlite3 *db,\n  void *pAux,\n  int argc, const char *const*argv,\n  sqlite3_vtab **ppVtab,\n  char **pzErr\n){\n  sqlite3_vtab *pNew;\n  int rc;\n\n/* Column numbers */\n#define JEACH_KEY     0\n#define JEACH_VALUE   1\n#define JEACH_TYPE    2\n#define JEACH_ATOM    3\n#define JEACH_ID      4\n#define JEACH_PARENT  5\n#define JEACH_FULLKEY 6\n#define JEACH_PATH    7\n/* The xBestIndex method assumes that the JSON and ROOT columns are\n** the last two columns in the table.  Should this ever changes, be\n** sure to update the xBestIndex method. */\n#define JEACH_JSON    8\n#define JEACH_ROOT    9\n\n  UNUSED_PARAM(pzErr);\n  UNUSED_PARAM(argv);\n  UNUSED_PARAM(argc);\n  UNUSED_PARAM(pAux);\n  rc = sqlite3_declare_vtab(db, \n     \"CREATE TABLE x(key,value,type,atom,id,parent,fullkey,path,\"\n                    \"json HIDDEN,root HIDDEN)\");\n  if( rc==SQLITE_OK ){\n    pNew = *ppVtab = sqlite3_malloc( sizeof(*pNew) );\n    if( pNew==0 ) return SQLITE_NOMEM;\n    memset(pNew, 0, sizeof(*pNew));\n  }\n  return rc;\n}\n\n/* destructor for json_each virtual table */\nstatic int jsonEachDisconnect(sqlite3_vtab *pVtab){\n  sqlite3_free(pVtab);\n  return SQLITE_OK;\n}\n\n/* constructor for a JsonEachCursor object for json_each(). */\nstatic int jsonEachOpenEach(sqlite3_vtab *p, sqlite3_vtab_cursor **ppCursor){\n  JsonEachCursor *pCur;\n\n  UNUSED_PARAM(p);\n  pCur = sqlite3_malloc( sizeof(*pCur) );\n  if( pCur==0 ) return SQLITE_NOMEM;\n  memset(pCur, 0, sizeof(*pCur));\n  *ppCursor = &pCur->base;\n  return SQLITE_OK;\n}\n\n/* constructor for a JsonEachCursor object for json_tree(). */\nstatic int jsonEachOpenTree(sqlite3_vtab *p, sqlite3_vtab_cursor **ppCursor){\n  int rc = jsonEachOpenEach(p, ppCursor);\n  if( rc==SQLITE_OK ){\n    JsonEachCursor *pCur = (JsonEachCursor*)*ppCursor;\n    pCur->bRecursive = 1;\n  }\n  return rc;\n}\n\n/* Reset a JsonEachCursor back to its original state.  Free any memory\n** held. */\nstatic void jsonEachCursorReset(JsonEachCursor *p){\n  sqlite3_free(p->zJson);\n  sqlite3_free(p->zRoot);\n  jsonParseReset(&p->sParse);\n  p->iRowid = 0;\n  p->i = 0;\n  p->iEnd = 0;\n  p->eType = 0;\n  p->zJson = 0;\n  p->zRoot = 0;\n}\n\n/* Destructor for a jsonEachCursor object */\nstatic int jsonEachClose(sqlite3_vtab_cursor *cur){\n  JsonEachCursor *p = (JsonEachCursor*)cur;\n  jsonEachCursorReset(p);\n  sqlite3_free(cur);\n  return SQLITE_OK;\n}\n\n/* Return TRUE if the jsonEachCursor object has been advanced off the end\n** of the JSON object */\nstatic int jsonEachEof(sqlite3_vtab_cursor *cur){\n  JsonEachCursor *p = (JsonEachCursor*)cur;\n  return p->i >= p->iEnd;\n}\n\n/* Advance the cursor to the next element for json_tree() */\nstatic int jsonEachNext(sqlite3_vtab_cursor *cur){\n  JsonEachCursor *p = (JsonEachCursor*)cur;\n  if( p->bRecursive ){\n    if( p->sParse.aNode[p->i].jnFlags & JNODE_LABEL ) p->i++;\n    p->i++;\n    p->iRowid++;\n    if( p->i<p->iEnd ){\n      u32 iUp = p->sParse.aUp[p->i];\n      JsonNode *pUp = &p->sParse.aNode[iUp];\n      p->eType = pUp->eType;\n      if( pUp->eType==JSON_ARRAY ){\n        if( iUp==p->i-1 ){\n          pUp->u.iKey = 0;\n        }else{\n          pUp->u.iKey++;\n        }\n      }\n    }\n  }else{\n    switch( p->eType ){\n      case JSON_ARRAY: {\n        p->i += jsonNodeSize(&p->sParse.aNode[p->i]);\n        p->iRowid++;\n        break;\n      }\n      case JSON_OBJECT: {\n        p->i += 1 + jsonNodeSize(&p->sParse.aNode[p->i+1]);\n        p->iRowid++;\n        break;\n      }\n      default: {\n        p->i = p->iEnd;\n        break;\n      }\n    }\n  }\n  return SQLITE_OK;\n}\n\n/* Append the name of the path for element i to pStr\n*/\nstatic void jsonEachComputePath(\n  JsonEachCursor *p,       /* The cursor */\n  JsonString *pStr,        /* Write the path here */\n  u32 i                    /* Path to this element */\n){\n  JsonNode *pNode, *pUp;\n  u32 iUp;\n  if( i==0 ){\n    jsonAppendChar(pStr, '$');\n    return;\n  }\n  iUp = p->sParse.aUp[i];\n  jsonEachComputePath(p, pStr, iUp);\n  pNode = &p->sParse.aNode[i];\n  pUp = &p->sParse.aNode[iUp];\n  if( pUp->eType==JSON_ARRAY ){\n    jsonPrintf(30, pStr, \"[%d]\", pUp->u.iKey);\n  }else{\n    assert( pUp->eType==JSON_OBJECT );\n    if( (pNode->jnFlags & JNODE_LABEL)==0 ) pNode--;\n    assert( pNode->eType==JSON_STRING );\n    assert( pNode->jnFlags & JNODE_LABEL );\n    jsonPrintf(pNode->n+1, pStr, \".%.*s\", pNode->n-2, pNode->u.zJContent+1);\n  }\n}\n\n/* Return the value of a column */\nstatic int jsonEachColumn(\n  sqlite3_vtab_cursor *cur,   /* The cursor */\n  sqlite3_context *ctx,       /* First argument to sqlite3_result_...() */\n  int i                       /* Which column to return */\n){\n  JsonEachCursor *p = (JsonEachCursor*)cur;\n  JsonNode *pThis = &p->sParse.aNode[p->i];\n  switch( i ){\n    case JEACH_KEY: {\n      if( p->i==0 ) break;\n      if( p->eType==JSON_OBJECT ){\n        jsonReturn(pThis, ctx, 0);\n      }else if( p->eType==JSON_ARRAY ){\n        u32 iKey;\n        if( p->bRecursive ){\n          if( p->iRowid==0 ) break;\n          iKey = p->sParse.aNode[p->sParse.aUp[p->i]].u.iKey;\n        }else{\n          iKey = p->iRowid;\n        }\n        sqlite3_result_int64(ctx, (sqlite3_int64)iKey);\n      }\n      break;\n    }\n    case JEACH_VALUE: {\n      if( pThis->jnFlags & JNODE_LABEL ) pThis++;\n      jsonReturn(pThis, ctx, 0);\n      break;\n    }\n    case JEACH_TYPE: {\n      if( pThis->jnFlags & JNODE_LABEL ) pThis++;\n      sqlite3_result_text(ctx, jsonType[pThis->eType], -1, SQLITE_STATIC);\n      break;\n    }\n    case JEACH_ATOM: {\n      if( pThis->jnFlags & JNODE_LABEL ) pThis++;\n      if( pThis->eType>=JSON_ARRAY ) break;\n      jsonReturn(pThis, ctx, 0);\n      break;\n    }\n    case JEACH_ID: {\n      sqlite3_result_int64(ctx, \n         (sqlite3_int64)p->i + ((pThis->jnFlags & JNODE_LABEL)!=0));\n      break;\n    }\n    case JEACH_PARENT: {\n      if( p->i>p->iBegin && p->bRecursive ){\n        sqlite3_result_int64(ctx, (sqlite3_int64)p->sParse.aUp[p->i]);\n      }\n      break;\n    }\n    case JEACH_FULLKEY: {\n      JsonString x;\n      jsonInit(&x, ctx);\n      if( p->bRecursive ){\n        jsonEachComputePath(p, &x, p->i);\n      }else{\n        if( p->zRoot ){\n          jsonAppendRaw(&x, p->zRoot, (int)strlen(p->zRoot));\n        }else{\n          jsonAppendChar(&x, '$');\n        }\n        if( p->eType==JSON_ARRAY ){\n          jsonPrintf(30, &x, \"[%d]\", p->iRowid);\n        }else if( p->eType==JSON_OBJECT ){\n          jsonPrintf(pThis->n, &x, \".%.*s\", pThis->n-2, pThis->u.zJContent+1);\n        }\n      }\n      jsonResult(&x);\n      break;\n    }\n    case JEACH_PATH: {\n      if( p->bRecursive ){\n        JsonString x;\n        jsonInit(&x, ctx);\n        jsonEachComputePath(p, &x, p->sParse.aUp[p->i]);\n        jsonResult(&x);\n        break;\n      }\n      /* For json_each() path and root are the same so fall through\n      ** into the root case */\n    }\n    default: {\n      const char *zRoot = p->zRoot;\n      if( zRoot==0 ) zRoot = \"$\";\n      sqlite3_result_text(ctx, zRoot, -1, SQLITE_STATIC);\n      break;\n    }\n    case JEACH_JSON: {\n      assert( i==JEACH_JSON );\n      sqlite3_result_text(ctx, p->sParse.zJson, -1, SQLITE_STATIC);\n      break;\n    }\n  }\n  return SQLITE_OK;\n}\n\n/* Return the current rowid value */\nstatic int jsonEachRowid(sqlite3_vtab_cursor *cur, sqlite_int64 *pRowid){\n  JsonEachCursor *p = (JsonEachCursor*)cur;\n  *pRowid = p->iRowid;\n  return SQLITE_OK;\n}\n\n/* The query strategy is to look for an equality constraint on the json\n** column.  Without such a constraint, the table cannot operate.  idxNum is\n** 1 if the constraint is found, 3 if the constraint and zRoot are found,\n** and 0 otherwise.\n*/\nstatic int jsonEachBestIndex(\n  sqlite3_vtab *tab,\n  sqlite3_index_info *pIdxInfo\n){\n  int i;                     /* Loop counter or computed array index */\n  int aIdx[2];               /* Index of constraints for JSON and ROOT */\n  int unusableMask = 0;      /* Mask of unusable JSON and ROOT constraints */\n  int idxMask = 0;           /* Mask of usable == constraints JSON and ROOT */\n  const struct sqlite3_index_constraint *pConstraint;\n\n  /* This implementation assumes that JSON and ROOT are the last two\n  ** columns in the table */\n  assert( JEACH_ROOT == JEACH_JSON+1 );\n  UNUSED_PARAM(tab);\n  aIdx[0] = aIdx[1] = -1;\n  pConstraint = pIdxInfo->aConstraint;\n  for(i=0; i<pIdxInfo->nConstraint; i++, pConstraint++){\n    int iCol;\n    int iMask;\n    if( pConstraint->iColumn < JEACH_JSON ) continue;\n    iCol = pConstraint->iColumn - JEACH_JSON;\n    assert( iCol==0 || iCol==1 );\n    iMask = 1 << iCol;\n    if( pConstraint->usable==0 ){\n      unusableMask |= iMask;\n    }else if( pConstraint->op==SQLITE_INDEX_CONSTRAINT_EQ ){\n      aIdx[iCol] = i;\n      idxMask |= iMask;\n    }\n  }\n  if( (unusableMask & ~idxMask)!=0 ){\n    /* If there are any unusable constraints on JSON or ROOT, then reject\n    ** this entire plan */\n    return SQLITE_CONSTRAINT;\n  }\n  if( aIdx[0]<0 ){\n    /* No JSON input.  Leave estimatedCost at the huge value that it was\n    ** initialized to to discourage the query planner from selecting this\n    ** plan. */\n    pIdxInfo->idxNum = 0;\n  }else{\n    pIdxInfo->estimatedCost = 1.0;\n    i = aIdx[0];\n    pIdxInfo->aConstraintUsage[i].argvIndex = 1;\n    pIdxInfo->aConstraintUsage[i].omit = 1;\n    if( aIdx[1]<0 ){\n      pIdxInfo->idxNum = 1;  /* Only JSON supplied.  Plan 1 */\n    }else{\n      i = aIdx[1];\n      pIdxInfo->aConstraintUsage[i].argvIndex = 2;\n      pIdxInfo->aConstraintUsage[i].omit = 1;\n      pIdxInfo->idxNum = 3;  /* Both JSON and ROOT are supplied.  Plan 3 */\n    }\n  }\n  return SQLITE_OK;\n}\n\n/* Start a search on a new JSON string */\nstatic int jsonEachFilter(\n  sqlite3_vtab_cursor *cur,\n  int idxNum, const char *idxStr,\n  int argc, sqlite3_value **argv\n){\n  JsonEachCursor *p = (JsonEachCursor*)cur;\n  const char *z;\n  const char *zRoot = 0;\n  sqlite3_int64 n;\n\n  UNUSED_PARAM(idxStr);\n  UNUSED_PARAM(argc);\n  jsonEachCursorReset(p);\n  if( idxNum==0 ) return SQLITE_OK;\n  z = (const char*)sqlite3_value_text(argv[0]);\n  if( z==0 ) return SQLITE_OK;\n  n = sqlite3_value_bytes(argv[0]);\n  p->zJson = sqlite3_malloc64( n+1 );\n  if( p->zJson==0 ) return SQLITE_NOMEM;\n  memcpy(p->zJson, z, (size_t)n+1);\n  if( jsonParse(&p->sParse, 0, p->zJson) ){\n    int rc = SQLITE_NOMEM;\n    if( p->sParse.oom==0 ){\n      sqlite3_free(cur->pVtab->zErrMsg);\n      cur->pVtab->zErrMsg = sqlite3_mprintf(\"malformed JSON\");\n      if( cur->pVtab->zErrMsg ) rc = SQLITE_ERROR;\n    }\n    jsonEachCursorReset(p);\n    return rc;\n  }else if( p->bRecursive && jsonParseFindParents(&p->sParse) ){\n    jsonEachCursorReset(p);\n    return SQLITE_NOMEM;\n  }else{\n    JsonNode *pNode = 0;\n    if( idxNum==3 ){\n      const char *zErr = 0;\n      zRoot = (const char*)sqlite3_value_text(argv[1]);\n      if( zRoot==0 ) return SQLITE_OK;\n      n = sqlite3_value_bytes(argv[1]);\n      p->zRoot = sqlite3_malloc64( n+1 );\n      if( p->zRoot==0 ) return SQLITE_NOMEM;\n      memcpy(p->zRoot, zRoot, (size_t)n+1);\n      if( zRoot[0]!='$' ){\n        zErr = zRoot;\n      }else{\n        pNode = jsonLookupStep(&p->sParse, 0, p->zRoot+1, 0, &zErr);\n      }\n      if( zErr ){\n        sqlite3_free(cur->pVtab->zErrMsg);\n        cur->pVtab->zErrMsg = jsonPathSyntaxError(zErr);\n        jsonEachCursorReset(p);\n        return cur->pVtab->zErrMsg ? SQLITE_ERROR : SQLITE_NOMEM;\n      }else if( pNode==0 ){\n        return SQLITE_OK;\n      }\n    }else{\n      pNode = p->sParse.aNode;\n    }\n    p->iBegin = p->i = (int)(pNode - p->sParse.aNode);\n    p->eType = pNode->eType;\n    if( p->eType>=JSON_ARRAY ){\n      pNode->u.iKey = 0;\n      p->iEnd = p->i + pNode->n + 1;\n      if( p->bRecursive ){\n        p->eType = p->sParse.aNode[p->sParse.aUp[p->i]].eType;\n        if( p->i>0 && (p->sParse.aNode[p->i-1].jnFlags & JNODE_LABEL)!=0 ){\n          p->i--;\n        }\n      }else{\n        p->i++;\n      }\n    }else{\n      p->iEnd = p->i+1;\n    }\n  }\n  return SQLITE_OK;\n}\n\n/* The methods of the json_each virtual table */\nstatic sqlite3_module jsonEachModule = {\n  0,                         /* iVersion */\n  0,                         /* xCreate */\n  jsonEachConnect,           /* xConnect */\n  jsonEachBestIndex,         /* xBestIndex */\n  jsonEachDisconnect,        /* xDisconnect */\n  0,                         /* xDestroy */\n  jsonEachOpenEach,          /* xOpen - open a cursor */\n  jsonEachClose,             /* xClose - close a cursor */\n  jsonEachFilter,            /* xFilter - configure scan constraints */\n  jsonEachNext,              /* xNext - advance a cursor */\n  jsonEachEof,               /* xEof - check for end of scan */\n  jsonEachColumn,            /* xColumn - read data */\n  jsonEachRowid,             /* xRowid - read data */\n  0,                         /* xUpdate */\n  0,                         /* xBegin */\n  0,                         /* xSync */\n  0,                         /* xCommit */\n  0,                         /* xRollback */\n  0,                         /* xFindMethod */\n  0,                         /* xRename */\n  0,                         /* xSavepoint */\n  0,                         /* xRelease */\n  0,                         /* xRollbackTo */\n  0                          /* xShadowName */\n};\n\n/* The methods of the json_tree virtual table. */\nstatic sqlite3_module jsonTreeModule = {\n  0,                         /* iVersion */\n  0,                         /* xCreate */\n  jsonEachConnect,           /* xConnect */\n  jsonEachBestIndex,         /* xBestIndex */\n  jsonEachDisconnect,        /* xDisconnect */\n  0,                         /* xDestroy */\n  jsonEachOpenTree,          /* xOpen - open a cursor */\n  jsonEachClose,             /* xClose - close a cursor */\n  jsonEachFilter,            /* xFilter - configure scan constraints */\n  jsonEachNext,              /* xNext - advance a cursor */\n  jsonEachEof,               /* xEof - check for end of scan */\n  jsonEachColumn,            /* xColumn - read data */\n  jsonEachRowid,             /* xRowid - read data */\n  0,                         /* xUpdate */\n  0,                         /* xBegin */\n  0,                         /* xSync */\n  0,                         /* xCommit */\n  0,                         /* xRollback */\n  0,                         /* xFindMethod */\n  0,                         /* xRename */\n  0,                         /* xSavepoint */\n  0,                         /* xRelease */\n  0,                         /* xRollbackTo */\n  0                          /* xShadowName */\n};\n#endif /* SQLITE_OMIT_VIRTUALTABLE */\n\n/****************************************************************************\n** The following routines are the only publically visible identifiers in this\n** file.  Call the following routines in order to register the various SQL\n** functions and the virtual table implemented by this file.\n****************************************************************************/\n\nSQLITE_PRIVATE int sqlite3Json1Init(sqlite3 *db){\n  int rc = SQLITE_OK;\n  unsigned int i;\n  static const struct {\n     const char *zName;\n     int nArg;\n     int flag;\n     void (*xFunc)(sqlite3_context*,int,sqlite3_value**);\n  } aFunc[] = {\n    { \"json\",                 1, 0,   jsonRemoveFunc        },\n    { \"json_array\",          -1, 0,   jsonArrayFunc         },\n    { \"json_array_length\",    1, 0,   jsonArrayLengthFunc   },\n    { \"json_array_length\",    2, 0,   jsonArrayLengthFunc   },\n    { \"json_extract\",        -1, 0,   jsonExtractFunc       },\n    { \"json_insert\",         -1, 0,   jsonSetFunc           },\n    { \"json_object\",         -1, 0,   jsonObjectFunc        },\n    { \"json_patch\",           2, 0,   jsonPatchFunc         },\n    { \"json_quote\",           1, 0,   jsonQuoteFunc         },\n    { \"json_remove\",         -1, 0,   jsonRemoveFunc        },\n    { \"json_replace\",        -1, 0,   jsonReplaceFunc       },\n    { \"json_set\",            -1, 1,   jsonSetFunc           },\n    { \"json_type\",            1, 0,   jsonTypeFunc          },\n    { \"json_type\",            2, 0,   jsonTypeFunc          },\n    { \"json_valid\",           1, 0,   jsonValidFunc         },\n\n#if SQLITE_DEBUG\n    /* DEBUG and TESTING functions */\n    { \"json_parse\",           1, 0,   jsonParseFunc         },\n    { \"json_test1\",           1, 0,   jsonTest1Func         },\n#endif\n  };\n  static const struct {\n     const char *zName;\n     int nArg;\n     void (*xStep)(sqlite3_context*,int,sqlite3_value**);\n     void (*xFinal)(sqlite3_context*);\n     void (*xValue)(sqlite3_context*);\n  } aAgg[] = {\n    { \"json_group_array\",     1,\n      jsonArrayStep,   jsonArrayFinal,  jsonArrayValue  },\n    { \"json_group_object\",    2,\n      jsonObjectStep,  jsonObjectFinal, jsonObjectValue },\n  };\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n  static const struct {\n     const char *zName;\n     sqlite3_module *pModule;\n  } aMod[] = {\n    { \"json_each\",            &jsonEachModule               },\n    { \"json_tree\",            &jsonTreeModule               },\n  };\n#endif\n  for(i=0; i<sizeof(aFunc)/sizeof(aFunc[0]) && rc==SQLITE_OK; i++){\n    rc = sqlite3_create_function(db, aFunc[i].zName, aFunc[i].nArg,\n                                 SQLITE_UTF8 | SQLITE_DETERMINISTIC, \n                                 (void*)&aFunc[i].flag,\n                                 aFunc[i].xFunc, 0, 0);\n  }\n#ifndef SQLITE_OMIT_WINDOWFUNC\n  for(i=0; i<sizeof(aAgg)/sizeof(aAgg[0]) && rc==SQLITE_OK; i++){\n    rc = sqlite3_create_window_function(db, aAgg[i].zName, aAgg[i].nArg,\n                                 SQLITE_UTF8 | SQLITE_DETERMINISTIC, 0,\n                                 aAgg[i].xStep, aAgg[i].xFinal,\n                                 aAgg[i].xValue, jsonGroupInverse, 0);\n  }\n#endif\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n  for(i=0; i<sizeof(aMod)/sizeof(aMod[0]) && rc==SQLITE_OK; i++){\n    rc = sqlite3_create_module(db, aMod[i].zName, aMod[i].pModule, 0);\n  }\n#endif\n  return rc;\n}\n\n\n#ifndef SQLITE_CORE\n#ifdef _WIN32\n__declspec(dllexport)\n#endif\nSQLITE_API int sqlite3_json_init(\n  sqlite3 *db, \n  char **pzErrMsg, \n  const sqlite3_api_routines *pApi\n){\n  SQLITE_EXTENSION_INIT2(pApi);\n  (void)pzErrMsg;  /* Unused parameter */\n  return sqlite3Json1Init(db);\n}\n#endif\n#endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_JSON1) */\n\n/************** End of json1.c ***********************************************/\n/************** Begin file rtree.c *******************************************/\n/*\n** 2001 September 15\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This file contains code for implementations of the r-tree and r*-tree\n** algorithms packaged as an SQLite virtual table module.\n*/\n\n/*\n** Database Format of R-Tree Tables\n** --------------------------------\n**\n** The data structure for a single virtual r-tree table is stored in three \n** native SQLite tables declared as follows. In each case, the '%' character\n** in the table name is replaced with the user-supplied name of the r-tree\n** table.\n**\n**   CREATE TABLE %_node(nodeno INTEGER PRIMARY KEY, data BLOB)\n**   CREATE TABLE %_parent(nodeno INTEGER PRIMARY KEY, parentnode INTEGER)\n**   CREATE TABLE %_rowid(rowid INTEGER PRIMARY KEY, nodeno INTEGER, ...)\n**\n** The data for each node of the r-tree structure is stored in the %_node\n** table. For each node that is not the root node of the r-tree, there is\n** an entry in the %_parent table associating the node with its parent.\n** And for each row of data in the table, there is an entry in the %_rowid\n** table that maps from the entries rowid to the id of the node that it\n** is stored on.  If the r-tree contains auxiliary columns, those are stored\n** on the end of the %_rowid table.\n**\n** The root node of an r-tree always exists, even if the r-tree table is\n** empty. The nodeno of the root node is always 1. All other nodes in the\n** table must be the same size as the root node. The content of each node\n** is formatted as follows:\n**\n**   1. If the node is the root node (node 1), then the first 2 bytes\n**      of the node contain the tree depth as a big-endian integer.\n**      For non-root nodes, the first 2 bytes are left unused.\n**\n**   2. The next 2 bytes contain the number of entries currently \n**      stored in the node.\n**\n**   3. The remainder of the node contains the node entries. Each entry\n**      consists of a single 8-byte integer followed by an even number\n**      of 4-byte coordinates. For leaf nodes the integer is the rowid\n**      of a record. For internal nodes it is the node number of a\n**      child page.\n*/\n\n#if !defined(SQLITE_CORE) \\\n  || (defined(SQLITE_ENABLE_RTREE) && !defined(SQLITE_OMIT_VIRTUALTABLE))\n\n#ifndef SQLITE_CORE\n/*   #include \"sqlite3ext.h\" */\n  SQLITE_EXTENSION_INIT1\n#else\n/*   #include \"sqlite3.h\" */\n#endif\n\n/* #include <string.h> */\n/* #include <assert.h> */\n/* #include <stdio.h> */\n\n#ifndef SQLITE_AMALGAMATION\n#include \"sqlite3rtree.h\"\ntypedef sqlite3_int64 i64;\ntypedef sqlite3_uint64 u64;\ntypedef unsigned char u8;\ntypedef unsigned short u16;\ntypedef unsigned int u32;\n#endif\n\n/*  The following macro is used to suppress compiler warnings.\n*/\n#ifndef UNUSED_PARAMETER\n# define UNUSED_PARAMETER(x) (void)(x)\n#endif\n\ntypedef struct Rtree Rtree;\ntypedef struct RtreeCursor RtreeCursor;\ntypedef struct RtreeNode RtreeNode;\ntypedef struct RtreeCell RtreeCell;\ntypedef struct RtreeConstraint RtreeConstraint;\ntypedef struct RtreeMatchArg RtreeMatchArg;\ntypedef struct RtreeGeomCallback RtreeGeomCallback;\ntypedef union RtreeCoord RtreeCoord;\ntypedef struct RtreeSearchPoint RtreeSearchPoint;\n\n/* The rtree may have between 1 and RTREE_MAX_DIMENSIONS dimensions. */\n#define RTREE_MAX_DIMENSIONS 5\n\n/* Maximum number of auxiliary columns */\n#define RTREE_MAX_AUX_COLUMN 100\n\n/* Size of hash table Rtree.aHash. This hash table is not expected to\n** ever contain very many entries, so a fixed number of buckets is \n** used.\n*/\n#define HASHSIZE 97\n\n/* The xBestIndex method of this virtual table requires an estimate of\n** the number of rows in the virtual table to calculate the costs of\n** various strategies. If possible, this estimate is loaded from the\n** sqlite_stat1 table (with RTREE_MIN_ROWEST as a hard-coded minimum).\n** Otherwise, if no sqlite_stat1 entry is available, use \n** RTREE_DEFAULT_ROWEST.\n*/\n#define RTREE_DEFAULT_ROWEST 1048576\n#define RTREE_MIN_ROWEST         100\n\n/* \n** An rtree virtual-table object.\n*/\nstruct Rtree {\n  sqlite3_vtab base;          /* Base class.  Must be first */\n  sqlite3 *db;                /* Host database connection */\n  int iNodeSize;              /* Size in bytes of each node in the node table */\n  u8 nDim;                    /* Number of dimensions */\n  u8 nDim2;                   /* Twice the number of dimensions */\n  u8 eCoordType;              /* RTREE_COORD_REAL32 or RTREE_COORD_INT32 */\n  u8 nBytesPerCell;           /* Bytes consumed per cell */\n  u8 inWrTrans;               /* True if inside write transaction */\n  u8 nAux;                    /* # of auxiliary columns in %_rowid */\n  u8 nAuxNotNull;             /* Number of initial not-null aux columns */\n#ifdef SQLITE_DEBUG\n  u8 bCorrupt;                /* Shadow table corruption detected */\n#endif\n  int iDepth;                 /* Current depth of the r-tree structure */\n  char *zDb;                  /* Name of database containing r-tree table */\n  char *zName;                /* Name of r-tree table */ \n  u32 nBusy;                  /* Current number of users of this structure */\n  i64 nRowEst;                /* Estimated number of rows in this table */\n  u32 nCursor;                /* Number of open cursors */\n  u32 nNodeRef;               /* Number RtreeNodes with positive nRef */\n  char *zReadAuxSql;          /* SQL for statement to read aux data */\n\n  /* List of nodes removed during a CondenseTree operation. List is\n  ** linked together via the pointer normally used for hash chains -\n  ** RtreeNode.pNext. RtreeNode.iNode stores the depth of the sub-tree \n  ** headed by the node (leaf nodes have RtreeNode.iNode==0).\n  */\n  RtreeNode *pDeleted;\n  int iReinsertHeight;        /* Height of sub-trees Reinsert() has run on */\n\n  /* Blob I/O on xxx_node */\n  sqlite3_blob *pNodeBlob;\n\n  /* Statements to read/write/delete a record from xxx_node */\n  sqlite3_stmt *pWriteNode;\n  sqlite3_stmt *pDeleteNode;\n\n  /* Statements to read/write/delete a record from xxx_rowid */\n  sqlite3_stmt *pReadRowid;\n  sqlite3_stmt *pWriteRowid;\n  sqlite3_stmt *pDeleteRowid;\n\n  /* Statements to read/write/delete a record from xxx_parent */\n  sqlite3_stmt *pReadParent;\n  sqlite3_stmt *pWriteParent;\n  sqlite3_stmt *pDeleteParent;\n\n  /* Statement for writing to the \"aux:\" fields, if there are any */\n  sqlite3_stmt *pWriteAux;\n\n  RtreeNode *aHash[HASHSIZE]; /* Hash table of in-memory nodes. */ \n};\n\n/* Possible values for Rtree.eCoordType: */\n#define RTREE_COORD_REAL32 0\n#define RTREE_COORD_INT32  1\n\n/*\n** If SQLITE_RTREE_INT_ONLY is defined, then this virtual table will\n** only deal with integer coordinates.  No floating point operations\n** will be done.\n*/\n#ifdef SQLITE_RTREE_INT_ONLY\n  typedef sqlite3_int64 RtreeDValue;       /* High accuracy coordinate */\n  typedef int RtreeValue;                  /* Low accuracy coordinate */\n# define RTREE_ZERO 0\n#else\n  typedef double RtreeDValue;              /* High accuracy coordinate */\n  typedef float RtreeValue;                /* Low accuracy coordinate */\n# define RTREE_ZERO 0.0\n#endif\n\n/*\n** Set the Rtree.bCorrupt flag\n*/\n#ifdef SQLITE_DEBUG\n# define RTREE_IS_CORRUPT(X) ((X)->bCorrupt = 1)\n#else\n# define RTREE_IS_CORRUPT(X)\n#endif\n\n/*\n** When doing a search of an r-tree, instances of the following structure\n** record intermediate results from the tree walk.\n**\n** The id is always a node-id.  For iLevel>=1 the id is the node-id of\n** the node that the RtreeSearchPoint represents.  When iLevel==0, however,\n** the id is of the parent node and the cell that RtreeSearchPoint\n** represents is the iCell-th entry in the parent node.\n*/\nstruct RtreeSearchPoint {\n  RtreeDValue rScore;    /* The score for this node.  Smallest goes first. */\n  sqlite3_int64 id;      /* Node ID */\n  u8 iLevel;             /* 0=entries.  1=leaf node.  2+ for higher */\n  u8 eWithin;            /* PARTLY_WITHIN or FULLY_WITHIN */\n  u8 iCell;              /* Cell index within the node */\n};\n\n/*\n** The minimum number of cells allowed for a node is a third of the \n** maximum. In Gutman's notation:\n**\n**     m = M/3\n**\n** If an R*-tree \"Reinsert\" operation is required, the same number of\n** cells are removed from the overfull node and reinserted into the tree.\n*/\n#define RTREE_MINCELLS(p) ((((p)->iNodeSize-4)/(p)->nBytesPerCell)/3)\n#define RTREE_REINSERT(p) RTREE_MINCELLS(p)\n#define RTREE_MAXCELLS 51\n\n/*\n** The smallest possible node-size is (512-64)==448 bytes. And the largest\n** supported cell size is 48 bytes (8 byte rowid + ten 4 byte coordinates).\n** Therefore all non-root nodes must contain at least 3 entries. Since \n** 3^40 is greater than 2^64, an r-tree structure always has a depth of\n** 40 or less.\n*/\n#define RTREE_MAX_DEPTH 40\n\n\n/*\n** Number of entries in the cursor RtreeNode cache.  The first entry is\n** used to cache the RtreeNode for RtreeCursor.sPoint.  The remaining\n** entries cache the RtreeNode for the first elements of the priority queue.\n*/\n#define RTREE_CACHE_SZ  5\n\n/* \n** An rtree cursor object.\n*/\nstruct RtreeCursor {\n  sqlite3_vtab_cursor base;         /* Base class.  Must be first */\n  u8 atEOF;                         /* True if at end of search */\n  u8 bPoint;                        /* True if sPoint is valid */\n  u8 bAuxValid;                     /* True if pReadAux is valid */\n  int iStrategy;                    /* Copy of idxNum search parameter */\n  int nConstraint;                  /* Number of entries in aConstraint */\n  RtreeConstraint *aConstraint;     /* Search constraints. */\n  int nPointAlloc;                  /* Number of slots allocated for aPoint[] */\n  int nPoint;                       /* Number of slots used in aPoint[] */\n  int mxLevel;                      /* iLevel value for root of the tree */\n  RtreeSearchPoint *aPoint;         /* Priority queue for search points */\n  sqlite3_stmt *pReadAux;           /* Statement to read aux-data */\n  RtreeSearchPoint sPoint;          /* Cached next search point */\n  RtreeNode *aNode[RTREE_CACHE_SZ]; /* Rtree node cache */\n  u32 anQueue[RTREE_MAX_DEPTH+1];   /* Number of queued entries by iLevel */\n};\n\n/* Return the Rtree of a RtreeCursor */\n#define RTREE_OF_CURSOR(X)   ((Rtree*)((X)->base.pVtab))\n\n/*\n** A coordinate can be either a floating point number or a integer.  All\n** coordinates within a single R-Tree are always of the same time.\n*/\nunion RtreeCoord {\n  RtreeValue f;      /* Floating point value */\n  int i;             /* Integer value */\n  u32 u;             /* Unsigned for byte-order conversions */\n};\n\n/*\n** The argument is an RtreeCoord. Return the value stored within the RtreeCoord\n** formatted as a RtreeDValue (double or int64). This macro assumes that local\n** variable pRtree points to the Rtree structure associated with the\n** RtreeCoord.\n*/\n#ifdef SQLITE_RTREE_INT_ONLY\n# define DCOORD(coord) ((RtreeDValue)coord.i)\n#else\n# define DCOORD(coord) (                           \\\n    (pRtree->eCoordType==RTREE_COORD_REAL32) ?      \\\n      ((double)coord.f) :                           \\\n      ((double)coord.i)                             \\\n  )\n#endif\n\n/*\n** A search constraint.\n*/\nstruct RtreeConstraint {\n  int iCoord;                     /* Index of constrained coordinate */\n  int op;                         /* Constraining operation */\n  union {\n    RtreeDValue rValue;             /* Constraint value. */\n    int (*xGeom)(sqlite3_rtree_geometry*,int,RtreeDValue*,int*);\n    int (*xQueryFunc)(sqlite3_rtree_query_info*);\n  } u;\n  sqlite3_rtree_query_info *pInfo;  /* xGeom and xQueryFunc argument */\n};\n\n/* Possible values for RtreeConstraint.op */\n#define RTREE_EQ    0x41  /* A */\n#define RTREE_LE    0x42  /* B */\n#define RTREE_LT    0x43  /* C */\n#define RTREE_GE    0x44  /* D */\n#define RTREE_GT    0x45  /* E */\n#define RTREE_MATCH 0x46  /* F: Old-style sqlite3_rtree_geometry_callback() */\n#define RTREE_QUERY 0x47  /* G: New-style sqlite3_rtree_query_callback() */\n\n\n/* \n** An rtree structure node.\n*/\nstruct RtreeNode {\n  RtreeNode *pParent;         /* Parent node */\n  i64 iNode;                  /* The node number */\n  int nRef;                   /* Number of references to this node */\n  int isDirty;                /* True if the node needs to be written to disk */\n  u8 *zData;                  /* Content of the node, as should be on disk */\n  RtreeNode *pNext;           /* Next node in this hash collision chain */\n};\n\n/* Return the number of cells in a node  */\n#define NCELL(pNode) readInt16(&(pNode)->zData[2])\n\n/* \n** A single cell from a node, deserialized\n*/\nstruct RtreeCell {\n  i64 iRowid;                                 /* Node or entry ID */\n  RtreeCoord aCoord[RTREE_MAX_DIMENSIONS*2];  /* Bounding box coordinates */\n};\n\n\n/*\n** This object becomes the sqlite3_user_data() for the SQL functions\n** that are created by sqlite3_rtree_geometry_callback() and\n** sqlite3_rtree_query_callback() and which appear on the right of MATCH\n** operators in order to constrain a search.\n**\n** xGeom and xQueryFunc are the callback functions.  Exactly one of \n** xGeom and xQueryFunc fields is non-NULL, depending on whether the\n** SQL function was created using sqlite3_rtree_geometry_callback() or\n** sqlite3_rtree_query_callback().\n** \n** This object is deleted automatically by the destructor mechanism in\n** sqlite3_create_function_v2().\n*/\nstruct RtreeGeomCallback {\n  int (*xGeom)(sqlite3_rtree_geometry*, int, RtreeDValue*, int*);\n  int (*xQueryFunc)(sqlite3_rtree_query_info*);\n  void (*xDestructor)(void*);\n  void *pContext;\n};\n\n/*\n** An instance of this structure (in the form of a BLOB) is returned by\n** the SQL functions that sqlite3_rtree_geometry_callback() and\n** sqlite3_rtree_query_callback() create, and is read as the right-hand\n** operand to the MATCH operator of an R-Tree.\n*/\nstruct RtreeMatchArg {\n  u32 iSize;                  /* Size of this object */\n  RtreeGeomCallback cb;       /* Info about the callback functions */\n  int nParam;                 /* Number of parameters to the SQL function */\n  sqlite3_value **apSqlParam; /* Original SQL parameter values */\n  RtreeDValue aParam[1];      /* Values for parameters to the SQL function */\n};\n\n#ifndef MAX\n# define MAX(x,y) ((x) < (y) ? (y) : (x))\n#endif\n#ifndef MIN\n# define MIN(x,y) ((x) > (y) ? (y) : (x))\n#endif\n\n/* What version of GCC is being used.  0 means GCC is not being used .\n** Note that the GCC_VERSION macro will also be set correctly when using\n** clang, since clang works hard to be gcc compatible.  So the gcc\n** optimizations will also work when compiling with clang.\n*/\n#ifndef GCC_VERSION\n#if defined(__GNUC__) && !defined(SQLITE_DISABLE_INTRINSIC)\n# define GCC_VERSION (__GNUC__*1000000+__GNUC_MINOR__*1000+__GNUC_PATCHLEVEL__)\n#else\n# define GCC_VERSION 0\n#endif\n#endif\n\n/* The testcase() macro should already be defined in the amalgamation.  If\n** it is not, make it a no-op.\n*/\n#ifndef SQLITE_AMALGAMATION\n# define testcase(X)\n#endif\n\n/*\n** Macros to determine whether the machine is big or little endian,\n** and whether or not that determination is run-time or compile-time.\n**\n** For best performance, an attempt is made to guess at the byte-order\n** using C-preprocessor macros.  If that is unsuccessful, or if\n** -DSQLITE_RUNTIME_BYTEORDER=1 is set, then byte-order is determined\n** at run-time.\n*/\n#ifndef SQLITE_BYTEORDER\n#if defined(i386)     || defined(__i386__)   || defined(_M_IX86) ||    \\\n    defined(__x86_64) || defined(__x86_64__) || defined(_M_X64)  ||    \\\n    defined(_M_AMD64) || defined(_M_ARM)     || defined(__x86)   ||    \\\n    defined(__arm__)\n# define SQLITE_BYTEORDER    1234\n#elif defined(sparc)    || defined(__ppc__)\n# define SQLITE_BYTEORDER    4321\n#else\n# define SQLITE_BYTEORDER    0     /* 0 means \"unknown at compile-time\" */\n#endif\n#endif\n\n\n/* What version of MSVC is being used.  0 means MSVC is not being used */\n#ifndef MSVC_VERSION\n#if defined(_MSC_VER) && !defined(SQLITE_DISABLE_INTRINSIC)\n# define MSVC_VERSION _MSC_VER\n#else\n# define MSVC_VERSION 0\n#endif\n#endif\n\n/*\n** Functions to deserialize a 16 bit integer, 32 bit real number and\n** 64 bit integer. The deserialized value is returned.\n*/\nstatic int readInt16(u8 *p){\n  return (p[0]<<8) + p[1];\n}\nstatic void readCoord(u8 *p, RtreeCoord *pCoord){\n  assert( ((((char*)p) - (char*)0)&3)==0 );  /* p is always 4-byte aligned */\n#if SQLITE_BYTEORDER==1234 && MSVC_VERSION>=1300\n  pCoord->u = _byteswap_ulong(*(u32*)p);\n#elif SQLITE_BYTEORDER==1234 && GCC_VERSION>=4003000\n  pCoord->u = __builtin_bswap32(*(u32*)p);\n#elif SQLITE_BYTEORDER==4321\n  pCoord->u = *(u32*)p;\n#else\n  pCoord->u = (\n    (((u32)p[0]) << 24) + \n    (((u32)p[1]) << 16) + \n    (((u32)p[2]) <<  8) + \n    (((u32)p[3]) <<  0)\n  );\n#endif\n}\nstatic i64 readInt64(u8 *p){\n#if SQLITE_BYTEORDER==1234 && MSVC_VERSION>=1300\n  u64 x;\n  memcpy(&x, p, 8);\n  return (i64)_byteswap_uint64(x);\n#elif SQLITE_BYTEORDER==1234 && GCC_VERSION>=4003000\n  u64 x;\n  memcpy(&x, p, 8);\n  return (i64)__builtin_bswap64(x);\n#elif SQLITE_BYTEORDER==4321\n  i64 x;\n  memcpy(&x, p, 8);\n  return x;\n#else\n  return (i64)(\n    (((u64)p[0]) << 56) + \n    (((u64)p[1]) << 48) + \n    (((u64)p[2]) << 40) + \n    (((u64)p[3]) << 32) + \n    (((u64)p[4]) << 24) + \n    (((u64)p[5]) << 16) + \n    (((u64)p[6]) <<  8) + \n    (((u64)p[7]) <<  0)\n  );\n#endif\n}\n\n/*\n** Functions to serialize a 16 bit integer, 32 bit real number and\n** 64 bit integer. The value returned is the number of bytes written\n** to the argument buffer (always 2, 4 and 8 respectively).\n*/\nstatic void writeInt16(u8 *p, int i){\n  p[0] = (i>> 8)&0xFF;\n  p[1] = (i>> 0)&0xFF;\n}\nstatic int writeCoord(u8 *p, RtreeCoord *pCoord){\n  u32 i;\n  assert( ((((char*)p) - (char*)0)&3)==0 );  /* p is always 4-byte aligned */\n  assert( sizeof(RtreeCoord)==4 );\n  assert( sizeof(u32)==4 );\n#if SQLITE_BYTEORDER==1234 && GCC_VERSION>=4003000\n  i = __builtin_bswap32(pCoord->u);\n  memcpy(p, &i, 4);\n#elif SQLITE_BYTEORDER==1234 && MSVC_VERSION>=1300\n  i = _byteswap_ulong(pCoord->u);\n  memcpy(p, &i, 4);\n#elif SQLITE_BYTEORDER==4321\n  i = pCoord->u;\n  memcpy(p, &i, 4);\n#else\n  i = pCoord->u;\n  p[0] = (i>>24)&0xFF;\n  p[1] = (i>>16)&0xFF;\n  p[2] = (i>> 8)&0xFF;\n  p[3] = (i>> 0)&0xFF;\n#endif\n  return 4;\n}\nstatic int writeInt64(u8 *p, i64 i){\n#if SQLITE_BYTEORDER==1234 && GCC_VERSION>=4003000\n  i = (i64)__builtin_bswap64((u64)i);\n  memcpy(p, &i, 8);\n#elif SQLITE_BYTEORDER==1234 && MSVC_VERSION>=1300\n  i = (i64)_byteswap_uint64((u64)i);\n  memcpy(p, &i, 8);\n#elif SQLITE_BYTEORDER==4321\n  memcpy(p, &i, 8);\n#else\n  p[0] = (i>>56)&0xFF;\n  p[1] = (i>>48)&0xFF;\n  p[2] = (i>>40)&0xFF;\n  p[3] = (i>>32)&0xFF;\n  p[4] = (i>>24)&0xFF;\n  p[5] = (i>>16)&0xFF;\n  p[6] = (i>> 8)&0xFF;\n  p[7] = (i>> 0)&0xFF;\n#endif\n  return 8;\n}\n\n/*\n** Increment the reference count of node p.\n*/\nstatic void nodeReference(RtreeNode *p){\n  if( p ){\n    assert( p->nRef>0 );\n    p->nRef++;\n  }\n}\n\n/*\n** Clear the content of node p (set all bytes to 0x00).\n*/\nstatic void nodeZero(Rtree *pRtree, RtreeNode *p){\n  memset(&p->zData[2], 0, pRtree->iNodeSize-2);\n  p->isDirty = 1;\n}\n\n/*\n** Given a node number iNode, return the corresponding key to use\n** in the Rtree.aHash table.\n*/\nstatic unsigned int nodeHash(i64 iNode){\n  return ((unsigned)iNode) % HASHSIZE;\n}\n\n/*\n** Search the node hash table for node iNode. If found, return a pointer\n** to it. Otherwise, return 0.\n*/\nstatic RtreeNode *nodeHashLookup(Rtree *pRtree, i64 iNode){\n  RtreeNode *p;\n  for(p=pRtree->aHash[nodeHash(iNode)]; p && p->iNode!=iNode; p=p->pNext);\n  return p;\n}\n\n/*\n** Add node pNode to the node hash table.\n*/\nstatic void nodeHashInsert(Rtree *pRtree, RtreeNode *pNode){\n  int iHash;\n  assert( pNode->pNext==0 );\n  iHash = nodeHash(pNode->iNode);\n  pNode->pNext = pRtree->aHash[iHash];\n  pRtree->aHash[iHash] = pNode;\n}\n\n/*\n** Remove node pNode from the node hash table.\n*/\nstatic void nodeHashDelete(Rtree *pRtree, RtreeNode *pNode){\n  RtreeNode **pp;\n  if( pNode->iNode!=0 ){\n    pp = &pRtree->aHash[nodeHash(pNode->iNode)];\n    for( ; (*pp)!=pNode; pp = &(*pp)->pNext){ assert(*pp); }\n    *pp = pNode->pNext;\n    pNode->pNext = 0;\n  }\n}\n\n/*\n** Allocate and return new r-tree node. Initially, (RtreeNode.iNode==0),\n** indicating that node has not yet been assigned a node number. It is\n** assigned a node number when nodeWrite() is called to write the\n** node contents out to the database.\n*/\nstatic RtreeNode *nodeNew(Rtree *pRtree, RtreeNode *pParent){\n  RtreeNode *pNode;\n  pNode = (RtreeNode *)sqlite3_malloc64(sizeof(RtreeNode) + pRtree->iNodeSize);\n  if( pNode ){\n    memset(pNode, 0, sizeof(RtreeNode) + pRtree->iNodeSize);\n    pNode->zData = (u8 *)&pNode[1];\n    pNode->nRef = 1;\n    pRtree->nNodeRef++;\n    pNode->pParent = pParent;\n    pNode->isDirty = 1;\n    nodeReference(pParent);\n  }\n  return pNode;\n}\n\n/*\n** Clear the Rtree.pNodeBlob object\n*/\nstatic void nodeBlobReset(Rtree *pRtree){\n  if( pRtree->pNodeBlob && pRtree->inWrTrans==0 && pRtree->nCursor==0 ){\n    sqlite3_blob *pBlob = pRtree->pNodeBlob;\n    pRtree->pNodeBlob = 0;\n    sqlite3_blob_close(pBlob);\n  }\n}\n\n/*\n** Check to see if pNode is the same as pParent or any of the parents\n** of pParent.\n*/\nstatic int nodeInParentChain(const RtreeNode *pNode, const RtreeNode *pParent){\n  do{\n    if( pNode==pParent ) return 1;\n    pParent = pParent->pParent;\n  }while( pParent );\n  return 0;\n}\n\n/*\n** Obtain a reference to an r-tree node.\n*/\nstatic int nodeAcquire(\n  Rtree *pRtree,             /* R-tree structure */\n  i64 iNode,                 /* Node number to load */\n  RtreeNode *pParent,        /* Either the parent node or NULL */\n  RtreeNode **ppNode         /* OUT: Acquired node */\n){\n  int rc = SQLITE_OK;\n  RtreeNode *pNode = 0;\n\n  /* Check if the requested node is already in the hash table. If so,\n  ** increase its reference count and return it.\n  */\n  if( (pNode = nodeHashLookup(pRtree, iNode))!=0 ){\n    assert( !pParent || !pNode->pParent || pNode->pParent==pParent );\n    if( pParent && !pNode->pParent ){\n      if( nodeInParentChain(pNode, pParent) ){\n        RTREE_IS_CORRUPT(pRtree);\n        return SQLITE_CORRUPT_VTAB;\n      }\n      pParent->nRef++;\n      pNode->pParent = pParent;\n    }\n    pNode->nRef++;\n    *ppNode = pNode;\n    return SQLITE_OK;\n  }\n\n  if( pRtree->pNodeBlob ){\n    sqlite3_blob *pBlob = pRtree->pNodeBlob;\n    pRtree->pNodeBlob = 0;\n    rc = sqlite3_blob_reopen(pBlob, iNode);\n    pRtree->pNodeBlob = pBlob;\n    if( rc ){\n      nodeBlobReset(pRtree);\n      if( rc==SQLITE_NOMEM ) return SQLITE_NOMEM;\n    }\n  }\n  if( pRtree->pNodeBlob==0 ){\n    char *zTab = sqlite3_mprintf(\"%s_node\", pRtree->zName);\n    if( zTab==0 ) return SQLITE_NOMEM;\n    rc = sqlite3_blob_open(pRtree->db, pRtree->zDb, zTab, \"data\", iNode, 0,\n                           &pRtree->pNodeBlob);\n    sqlite3_free(zTab);\n  }\n  if( rc ){\n    nodeBlobReset(pRtree);\n    *ppNode = 0;\n    /* If unable to open an sqlite3_blob on the desired row, that can only\n    ** be because the shadow tables hold erroneous data. */\n    if( rc==SQLITE_ERROR ){\n      rc = SQLITE_CORRUPT_VTAB;\n      RTREE_IS_CORRUPT(pRtree);\n    }\n  }else if( pRtree->iNodeSize==sqlite3_blob_bytes(pRtree->pNodeBlob) ){\n    pNode = (RtreeNode *)sqlite3_malloc64(sizeof(RtreeNode)+pRtree->iNodeSize);\n    if( !pNode ){\n      rc = SQLITE_NOMEM;\n    }else{\n      pNode->pParent = pParent;\n      pNode->zData = (u8 *)&pNode[1];\n      pNode->nRef = 1;\n      pRtree->nNodeRef++;\n      pNode->iNode = iNode;\n      pNode->isDirty = 0;\n      pNode->pNext = 0;\n      rc = sqlite3_blob_read(pRtree->pNodeBlob, pNode->zData,\n                             pRtree->iNodeSize, 0);\n    }\n  }\n\n  /* If the root node was just loaded, set pRtree->iDepth to the height\n  ** of the r-tree structure. A height of zero means all data is stored on\n  ** the root node. A height of one means the children of the root node\n  ** are the leaves, and so on. If the depth as specified on the root node\n  ** is greater than RTREE_MAX_DEPTH, the r-tree structure must be corrupt.\n  */\n  if( pNode && iNode==1 ){\n    pRtree->iDepth = readInt16(pNode->zData);\n    if( pRtree->iDepth>RTREE_MAX_DEPTH ){\n      rc = SQLITE_CORRUPT_VTAB;\n      RTREE_IS_CORRUPT(pRtree);\n    }\n  }\n\n  /* If no error has occurred so far, check if the \"number of entries\"\n  ** field on the node is too large. If so, set the return code to \n  ** SQLITE_CORRUPT_VTAB.\n  */\n  if( pNode && rc==SQLITE_OK ){\n    if( NCELL(pNode)>((pRtree->iNodeSize-4)/pRtree->nBytesPerCell) ){\n      rc = SQLITE_CORRUPT_VTAB;\n      RTREE_IS_CORRUPT(pRtree);\n    }\n  }\n\n  if( rc==SQLITE_OK ){\n    if( pNode!=0 ){\n      nodeReference(pParent);\n      nodeHashInsert(pRtree, pNode);\n    }else{\n      rc = SQLITE_CORRUPT_VTAB;\n      RTREE_IS_CORRUPT(pRtree);\n    }\n    *ppNode = pNode;\n  }else{\n    if( pNode ){\n      pRtree->nNodeRef--;\n      sqlite3_free(pNode);\n    }\n    *ppNode = 0;\n  }\n\n  return rc;\n}\n\n/*\n** Overwrite cell iCell of node pNode with the contents of pCell.\n*/\nstatic void nodeOverwriteCell(\n  Rtree *pRtree,             /* The overall R-Tree */\n  RtreeNode *pNode,          /* The node into which the cell is to be written */\n  RtreeCell *pCell,          /* The cell to write */\n  int iCell                  /* Index into pNode into which pCell is written */\n){\n  int ii;\n  u8 *p = &pNode->zData[4 + pRtree->nBytesPerCell*iCell];\n  p += writeInt64(p, pCell->iRowid);\n  for(ii=0; ii<pRtree->nDim2; ii++){\n    p += writeCoord(p, &pCell->aCoord[ii]);\n  }\n  pNode->isDirty = 1;\n}\n\n/*\n** Remove the cell with index iCell from node pNode.\n*/\nstatic void nodeDeleteCell(Rtree *pRtree, RtreeNode *pNode, int iCell){\n  u8 *pDst = &pNode->zData[4 + pRtree->nBytesPerCell*iCell];\n  u8 *pSrc = &pDst[pRtree->nBytesPerCell];\n  int nByte = (NCELL(pNode) - iCell - 1) * pRtree->nBytesPerCell;\n  memmove(pDst, pSrc, nByte);\n  writeInt16(&pNode->zData[2], NCELL(pNode)-1);\n  pNode->isDirty = 1;\n}\n\n/*\n** Insert the contents of cell pCell into node pNode. If the insert\n** is successful, return SQLITE_OK.\n**\n** If there is not enough free space in pNode, return SQLITE_FULL.\n*/\nstatic int nodeInsertCell(\n  Rtree *pRtree,                /* The overall R-Tree */\n  RtreeNode *pNode,             /* Write new cell into this node */\n  RtreeCell *pCell              /* The cell to be inserted */\n){\n  int nCell;                    /* Current number of cells in pNode */\n  int nMaxCell;                 /* Maximum number of cells for pNode */\n\n  nMaxCell = (pRtree->iNodeSize-4)/pRtree->nBytesPerCell;\n  nCell = NCELL(pNode);\n\n  assert( nCell<=nMaxCell );\n  if( nCell<nMaxCell ){\n    nodeOverwriteCell(pRtree, pNode, pCell, nCell);\n    writeInt16(&pNode->zData[2], nCell+1);\n    pNode->isDirty = 1;\n  }\n\n  return (nCell==nMaxCell);\n}\n\n/*\n** If the node is dirty, write it out to the database.\n*/\nstatic int nodeWrite(Rtree *pRtree, RtreeNode *pNode){\n  int rc = SQLITE_OK;\n  if( pNode->isDirty ){\n    sqlite3_stmt *p = pRtree->pWriteNode;\n    if( pNode->iNode ){\n      sqlite3_bind_int64(p, 1, pNode->iNode);\n    }else{\n      sqlite3_bind_null(p, 1);\n    }\n    sqlite3_bind_blob(p, 2, pNode->zData, pRtree->iNodeSize, SQLITE_STATIC);\n    sqlite3_step(p);\n    pNode->isDirty = 0;\n    rc = sqlite3_reset(p);\n    sqlite3_bind_null(p, 2);\n    if( pNode->iNode==0 && rc==SQLITE_OK ){\n      pNode->iNode = sqlite3_last_insert_rowid(pRtree->db);\n      nodeHashInsert(pRtree, pNode);\n    }\n  }\n  return rc;\n}\n\n/*\n** Release a reference to a node. If the node is dirty and the reference\n** count drops to zero, the node data is written to the database.\n*/\nstatic int nodeRelease(Rtree *pRtree, RtreeNode *pNode){\n  int rc = SQLITE_OK;\n  if( pNode ){\n    assert( pNode->nRef>0 );\n    assert( pRtree->nNodeRef>0 );\n    pNode->nRef--;\n    if( pNode->nRef==0 ){\n      pRtree->nNodeRef--;\n      if( pNode->iNode==1 ){\n        pRtree->iDepth = -1;\n      }\n      if( pNode->pParent ){\n        rc = nodeRelease(pRtree, pNode->pParent);\n      }\n      if( rc==SQLITE_OK ){\n        rc = nodeWrite(pRtree, pNode);\n      }\n      nodeHashDelete(pRtree, pNode);\n      sqlite3_free(pNode);\n    }\n  }\n  return rc;\n}\n\n/*\n** Return the 64-bit integer value associated with cell iCell of\n** node pNode. If pNode is a leaf node, this is a rowid. If it is\n** an internal node, then the 64-bit integer is a child page number.\n*/\nstatic i64 nodeGetRowid(\n  Rtree *pRtree,       /* The overall R-Tree */\n  RtreeNode *pNode,    /* The node from which to extract the ID */\n  int iCell            /* The cell index from which to extract the ID */\n){\n  assert( iCell<NCELL(pNode) );\n  return readInt64(&pNode->zData[4 + pRtree->nBytesPerCell*iCell]);\n}\n\n/*\n** Return coordinate iCoord from cell iCell in node pNode.\n*/\nstatic void nodeGetCoord(\n  Rtree *pRtree,               /* The overall R-Tree */\n  RtreeNode *pNode,            /* The node from which to extract a coordinate */\n  int iCell,                   /* The index of the cell within the node */\n  int iCoord,                  /* Which coordinate to extract */\n  RtreeCoord *pCoord           /* OUT: Space to write result to */\n){\n  readCoord(&pNode->zData[12 + pRtree->nBytesPerCell*iCell + 4*iCoord], pCoord);\n}\n\n/*\n** Deserialize cell iCell of node pNode. Populate the structure pointed\n** to by pCell with the results.\n*/\nstatic void nodeGetCell(\n  Rtree *pRtree,               /* The overall R-Tree */\n  RtreeNode *pNode,            /* The node containing the cell to be read */\n  int iCell,                   /* Index of the cell within the node */\n  RtreeCell *pCell             /* OUT: Write the cell contents here */\n){\n  u8 *pData;\n  RtreeCoord *pCoord;\n  int ii = 0;\n  pCell->iRowid = nodeGetRowid(pRtree, pNode, iCell);\n  pData = pNode->zData + (12 + pRtree->nBytesPerCell*iCell);\n  pCoord = pCell->aCoord;\n  do{\n    readCoord(pData, &pCoord[ii]);\n    readCoord(pData+4, &pCoord[ii+1]);\n    pData += 8;\n    ii += 2;\n  }while( ii<pRtree->nDim2 );\n}\n\n\n/* Forward declaration for the function that does the work of\n** the virtual table module xCreate() and xConnect() methods.\n*/\nstatic int rtreeInit(\n  sqlite3 *, void *, int, const char *const*, sqlite3_vtab **, char **, int\n);\n\n/* \n** Rtree virtual table module xCreate method.\n*/\nstatic int rtreeCreate(\n  sqlite3 *db,\n  void *pAux,\n  int argc, const char *const*argv,\n  sqlite3_vtab **ppVtab,\n  char **pzErr\n){\n  return rtreeInit(db, pAux, argc, argv, ppVtab, pzErr, 1);\n}\n\n/* \n** Rtree virtual table module xConnect method.\n*/\nstatic int rtreeConnect(\n  sqlite3 *db,\n  void *pAux,\n  int argc, const char *const*argv,\n  sqlite3_vtab **ppVtab,\n  char **pzErr\n){\n  return rtreeInit(db, pAux, argc, argv, ppVtab, pzErr, 0);\n}\n\n/*\n** Increment the r-tree reference count.\n*/\nstatic void rtreeReference(Rtree *pRtree){\n  pRtree->nBusy++;\n}\n\n/*\n** Decrement the r-tree reference count. When the reference count reaches\n** zero the structure is deleted.\n*/\nstatic void rtreeRelease(Rtree *pRtree){\n  pRtree->nBusy--;\n  if( pRtree->nBusy==0 ){\n    pRtree->inWrTrans = 0;\n    assert( pRtree->nCursor==0 );\n    nodeBlobReset(pRtree);\n    assert( pRtree->nNodeRef==0 || pRtree->bCorrupt );\n    sqlite3_finalize(pRtree->pWriteNode);\n    sqlite3_finalize(pRtree->pDeleteNode);\n    sqlite3_finalize(pRtree->pReadRowid);\n    sqlite3_finalize(pRtree->pWriteRowid);\n    sqlite3_finalize(pRtree->pDeleteRowid);\n    sqlite3_finalize(pRtree->pReadParent);\n    sqlite3_finalize(pRtree->pWriteParent);\n    sqlite3_finalize(pRtree->pDeleteParent);\n    sqlite3_finalize(pRtree->pWriteAux);\n    sqlite3_free(pRtree->zReadAuxSql);\n    sqlite3_free(pRtree);\n  }\n}\n\n/* \n** Rtree virtual table module xDisconnect method.\n*/\nstatic int rtreeDisconnect(sqlite3_vtab *pVtab){\n  rtreeRelease((Rtree *)pVtab);\n  return SQLITE_OK;\n}\n\n/* \n** Rtree virtual table module xDestroy method.\n*/\nstatic int rtreeDestroy(sqlite3_vtab *pVtab){\n  Rtree *pRtree = (Rtree *)pVtab;\n  int rc;\n  char *zCreate = sqlite3_mprintf(\n    \"DROP TABLE '%q'.'%q_node';\"\n    \"DROP TABLE '%q'.'%q_rowid';\"\n    \"DROP TABLE '%q'.'%q_parent';\",\n    pRtree->zDb, pRtree->zName, \n    pRtree->zDb, pRtree->zName,\n    pRtree->zDb, pRtree->zName\n  );\n  if( !zCreate ){\n    rc = SQLITE_NOMEM;\n  }else{\n    nodeBlobReset(pRtree);\n    rc = sqlite3_exec(pRtree->db, zCreate, 0, 0, 0);\n    sqlite3_free(zCreate);\n  }\n  if( rc==SQLITE_OK ){\n    rtreeRelease(pRtree);\n  }\n\n  return rc;\n}\n\n/* \n** Rtree virtual table module xOpen method.\n*/\nstatic int rtreeOpen(sqlite3_vtab *pVTab, sqlite3_vtab_cursor **ppCursor){\n  int rc = SQLITE_NOMEM;\n  Rtree *pRtree = (Rtree *)pVTab;\n  RtreeCursor *pCsr;\n\n  pCsr = (RtreeCursor *)sqlite3_malloc64(sizeof(RtreeCursor));\n  if( pCsr ){\n    memset(pCsr, 0, sizeof(RtreeCursor));\n    pCsr->base.pVtab = pVTab;\n    rc = SQLITE_OK;\n    pRtree->nCursor++;\n  }\n  *ppCursor = (sqlite3_vtab_cursor *)pCsr;\n\n  return rc;\n}\n\n\n/*\n** Free the RtreeCursor.aConstraint[] array and its contents.\n*/\nstatic void freeCursorConstraints(RtreeCursor *pCsr){\n  if( pCsr->aConstraint ){\n    int i;                        /* Used to iterate through constraint array */\n    for(i=0; i<pCsr->nConstraint; i++){\n      sqlite3_rtree_query_info *pInfo = pCsr->aConstraint[i].pInfo;\n      if( pInfo ){\n        if( pInfo->xDelUser ) pInfo->xDelUser(pInfo->pUser);\n        sqlite3_free(pInfo);\n      }\n    }\n    sqlite3_free(pCsr->aConstraint);\n    pCsr->aConstraint = 0;\n  }\n}\n\n/* \n** Rtree virtual table module xClose method.\n*/\nstatic int rtreeClose(sqlite3_vtab_cursor *cur){\n  Rtree *pRtree = (Rtree *)(cur->pVtab);\n  int ii;\n  RtreeCursor *pCsr = (RtreeCursor *)cur;\n  assert( pRtree->nCursor>0 );\n  freeCursorConstraints(pCsr);\n  sqlite3_finalize(pCsr->pReadAux);\n  sqlite3_free(pCsr->aPoint);\n  for(ii=0; ii<RTREE_CACHE_SZ; ii++) nodeRelease(pRtree, pCsr->aNode[ii]);\n  sqlite3_free(pCsr);\n  pRtree->nCursor--;\n  nodeBlobReset(pRtree);\n  return SQLITE_OK;\n}\n\n/*\n** Rtree virtual table module xEof method.\n**\n** Return non-zero if the cursor does not currently point to a valid \n** record (i.e if the scan has finished), or zero otherwise.\n*/\nstatic int rtreeEof(sqlite3_vtab_cursor *cur){\n  RtreeCursor *pCsr = (RtreeCursor *)cur;\n  return pCsr->atEOF;\n}\n\n/*\n** Convert raw bits from the on-disk RTree record into a coordinate value.\n** The on-disk format is big-endian and needs to be converted for little-\n** endian platforms.  The on-disk record stores integer coordinates if\n** eInt is true and it stores 32-bit floating point records if eInt is\n** false.  a[] is the four bytes of the on-disk record to be decoded.\n** Store the results in \"r\".\n**\n** There are five versions of this macro.  The last one is generic.  The\n** other four are various architectures-specific optimizations.\n*/\n#if SQLITE_BYTEORDER==1234 && MSVC_VERSION>=1300\n#define RTREE_DECODE_COORD(eInt, a, r) {                        \\\n    RtreeCoord c;    /* Coordinate decoded */                   \\\n    c.u = _byteswap_ulong(*(u32*)a);                            \\\n    r = eInt ? (sqlite3_rtree_dbl)c.i : (sqlite3_rtree_dbl)c.f; \\\n}\n#elif SQLITE_BYTEORDER==1234 && GCC_VERSION>=4003000\n#define RTREE_DECODE_COORD(eInt, a, r) {                        \\\n    RtreeCoord c;    /* Coordinate decoded */                   \\\n    c.u = __builtin_bswap32(*(u32*)a);                          \\\n    r = eInt ? (sqlite3_rtree_dbl)c.i : (sqlite3_rtree_dbl)c.f; \\\n}\n#elif SQLITE_BYTEORDER==1234\n#define RTREE_DECODE_COORD(eInt, a, r) {                        \\\n    RtreeCoord c;    /* Coordinate decoded */                   \\\n    memcpy(&c.u,a,4);                                           \\\n    c.u = ((c.u>>24)&0xff)|((c.u>>8)&0xff00)|                   \\\n          ((c.u&0xff)<<24)|((c.u&0xff00)<<8);                   \\\n    r = eInt ? (sqlite3_rtree_dbl)c.i : (sqlite3_rtree_dbl)c.f; \\\n}\n#elif SQLITE_BYTEORDER==4321\n#define RTREE_DECODE_COORD(eInt, a, r) {                        \\\n    RtreeCoord c;    /* Coordinate decoded */                   \\\n    memcpy(&c.u,a,4);                                           \\\n    r = eInt ? (sqlite3_rtree_dbl)c.i : (sqlite3_rtree_dbl)c.f; \\\n}\n#else\n#define RTREE_DECODE_COORD(eInt, a, r) {                        \\\n    RtreeCoord c;    /* Coordinate decoded */                   \\\n    c.u = ((u32)a[0]<<24) + ((u32)a[1]<<16)                     \\\n           +((u32)a[2]<<8) + a[3];                              \\\n    r = eInt ? (sqlite3_rtree_dbl)c.i : (sqlite3_rtree_dbl)c.f; \\\n}\n#endif\n\n/*\n** Check the RTree node or entry given by pCellData and p against the MATCH\n** constraint pConstraint.  \n*/\nstatic int rtreeCallbackConstraint(\n  RtreeConstraint *pConstraint,  /* The constraint to test */\n  int eInt,                      /* True if RTree holding integer coordinates */\n  u8 *pCellData,                 /* Raw cell content */\n  RtreeSearchPoint *pSearch,     /* Container of this cell */\n  sqlite3_rtree_dbl *prScore,    /* OUT: score for the cell */\n  int *peWithin                  /* OUT: visibility of the cell */\n){\n  sqlite3_rtree_query_info *pInfo = pConstraint->pInfo; /* Callback info */\n  int nCoord = pInfo->nCoord;                           /* No. of coordinates */\n  int rc;                                             /* Callback return code */\n  RtreeCoord c;                                       /* Translator union */\n  sqlite3_rtree_dbl aCoord[RTREE_MAX_DIMENSIONS*2];   /* Decoded coordinates */\n\n  assert( pConstraint->op==RTREE_MATCH || pConstraint->op==RTREE_QUERY );\n  assert( nCoord==2 || nCoord==4 || nCoord==6 || nCoord==8 || nCoord==10 );\n\n  if( pConstraint->op==RTREE_QUERY && pSearch->iLevel==1 ){\n    pInfo->iRowid = readInt64(pCellData);\n  }\n  pCellData += 8;\n#ifndef SQLITE_RTREE_INT_ONLY\n  if( eInt==0 ){\n    switch( nCoord ){\n      case 10:  readCoord(pCellData+36, &c); aCoord[9] = c.f;\n                readCoord(pCellData+32, &c); aCoord[8] = c.f;\n      case 8:   readCoord(pCellData+28, &c); aCoord[7] = c.f;\n                readCoord(pCellData+24, &c); aCoord[6] = c.f;\n      case 6:   readCoord(pCellData+20, &c); aCoord[5] = c.f;\n                readCoord(pCellData+16, &c); aCoord[4] = c.f;\n      case 4:   readCoord(pCellData+12, &c); aCoord[3] = c.f;\n                readCoord(pCellData+8,  &c); aCoord[2] = c.f;\n      default:  readCoord(pCellData+4,  &c); aCoord[1] = c.f;\n                readCoord(pCellData,    &c); aCoord[0] = c.f;\n    }\n  }else\n#endif\n  {\n    switch( nCoord ){\n      case 10:  readCoord(pCellData+36, &c); aCoord[9] = c.i;\n                readCoord(pCellData+32, &c); aCoord[8] = c.i;\n      case 8:   readCoord(pCellData+28, &c); aCoord[7] = c.i;\n                readCoord(pCellData+24, &c); aCoord[6] = c.i;\n      case 6:   readCoord(pCellData+20, &c); aCoord[5] = c.i;\n                readCoord(pCellData+16, &c); aCoord[4] = c.i;\n      case 4:   readCoord(pCellData+12, &c); aCoord[3] = c.i;\n                readCoord(pCellData+8,  &c); aCoord[2] = c.i;\n      default:  readCoord(pCellData+4,  &c); aCoord[1] = c.i;\n                readCoord(pCellData,    &c); aCoord[0] = c.i;\n    }\n  }\n  if( pConstraint->op==RTREE_MATCH ){\n    int eWithin = 0;\n    rc = pConstraint->u.xGeom((sqlite3_rtree_geometry*)pInfo,\n                              nCoord, aCoord, &eWithin);\n    if( eWithin==0 ) *peWithin = NOT_WITHIN;\n    *prScore = RTREE_ZERO;\n  }else{\n    pInfo->aCoord = aCoord;\n    pInfo->iLevel = pSearch->iLevel - 1;\n    pInfo->rScore = pInfo->rParentScore = pSearch->rScore;\n    pInfo->eWithin = pInfo->eParentWithin = pSearch->eWithin;\n    rc = pConstraint->u.xQueryFunc(pInfo);\n    if( pInfo->eWithin<*peWithin ) *peWithin = pInfo->eWithin;\n    if( pInfo->rScore<*prScore || *prScore<RTREE_ZERO ){\n      *prScore = pInfo->rScore;\n    }\n  }\n  return rc;\n}\n\n/* \n** Check the internal RTree node given by pCellData against constraint p.\n** If this constraint cannot be satisfied by any child within the node,\n** set *peWithin to NOT_WITHIN.\n*/\nstatic void rtreeNonleafConstraint(\n  RtreeConstraint *p,        /* The constraint to test */\n  int eInt,                  /* True if RTree holds integer coordinates */\n  u8 *pCellData,             /* Raw cell content as appears on disk */\n  int *peWithin              /* Adjust downward, as appropriate */\n){\n  sqlite3_rtree_dbl val;     /* Coordinate value convert to a double */\n\n  /* p->iCoord might point to either a lower or upper bound coordinate\n  ** in a coordinate pair.  But make pCellData point to the lower bound.\n  */\n  pCellData += 8 + 4*(p->iCoord&0xfe);\n\n  assert(p->op==RTREE_LE || p->op==RTREE_LT || p->op==RTREE_GE \n      || p->op==RTREE_GT || p->op==RTREE_EQ );\n  assert( ((((char*)pCellData) - (char*)0)&3)==0 );  /* 4-byte aligned */\n  switch( p->op ){\n    case RTREE_LE:\n    case RTREE_LT:\n    case RTREE_EQ:\n      RTREE_DECODE_COORD(eInt, pCellData, val);\n      /* val now holds the lower bound of the coordinate pair */\n      if( p->u.rValue>=val ) return;\n      if( p->op!=RTREE_EQ ) break;  /* RTREE_LE and RTREE_LT end here */\n      /* Fall through for the RTREE_EQ case */\n\n    default: /* RTREE_GT or RTREE_GE,  or fallthrough of RTREE_EQ */\n      pCellData += 4;\n      RTREE_DECODE_COORD(eInt, pCellData, val);\n      /* val now holds the upper bound of the coordinate pair */\n      if( p->u.rValue<=val ) return;\n  }\n  *peWithin = NOT_WITHIN;\n}\n\n/*\n** Check the leaf RTree cell given by pCellData against constraint p.\n** If this constraint is not satisfied, set *peWithin to NOT_WITHIN.\n** If the constraint is satisfied, leave *peWithin unchanged.\n**\n** The constraint is of the form:  xN op $val\n**\n** The op is given by p->op.  The xN is p->iCoord-th coordinate in\n** pCellData.  $val is given by p->u.rValue.\n*/\nstatic void rtreeLeafConstraint(\n  RtreeConstraint *p,        /* The constraint to test */\n  int eInt,                  /* True if RTree holds integer coordinates */\n  u8 *pCellData,             /* Raw cell content as appears on disk */\n  int *peWithin              /* Adjust downward, as appropriate */\n){\n  RtreeDValue xN;      /* Coordinate value converted to a double */\n\n  assert(p->op==RTREE_LE || p->op==RTREE_LT || p->op==RTREE_GE \n      || p->op==RTREE_GT || p->op==RTREE_EQ );\n  pCellData += 8 + p->iCoord*4;\n  assert( ((((char*)pCellData) - (char*)0)&3)==0 );  /* 4-byte aligned */\n  RTREE_DECODE_COORD(eInt, pCellData, xN);\n  switch( p->op ){\n    case RTREE_LE: if( xN <= p->u.rValue ) return;  break;\n    case RTREE_LT: if( xN <  p->u.rValue ) return;  break;\n    case RTREE_GE: if( xN >= p->u.rValue ) return;  break;\n    case RTREE_GT: if( xN >  p->u.rValue ) return;  break;\n    default:       if( xN == p->u.rValue ) return;  break;\n  }\n  *peWithin = NOT_WITHIN;\n}\n\n/*\n** One of the cells in node pNode is guaranteed to have a 64-bit \n** integer value equal to iRowid. Return the index of this cell.\n*/\nstatic int nodeRowidIndex(\n  Rtree *pRtree, \n  RtreeNode *pNode, \n  i64 iRowid,\n  int *piIndex\n){\n  int ii;\n  int nCell = NCELL(pNode);\n  assert( nCell<200 );\n  for(ii=0; ii<nCell; ii++){\n    if( nodeGetRowid(pRtree, pNode, ii)==iRowid ){\n      *piIndex = ii;\n      return SQLITE_OK;\n    }\n  }\n  RTREE_IS_CORRUPT(pRtree);\n  return SQLITE_CORRUPT_VTAB;\n}\n\n/*\n** Return the index of the cell containing a pointer to node pNode\n** in its parent. If pNode is the root node, return -1.\n*/\nstatic int nodeParentIndex(Rtree *pRtree, RtreeNode *pNode, int *piIndex){\n  RtreeNode *pParent = pNode->pParent;\n  if( pParent ){\n    return nodeRowidIndex(pRtree, pParent, pNode->iNode, piIndex);\n  }\n  *piIndex = -1;\n  return SQLITE_OK;\n}\n\n/*\n** Compare two search points.  Return negative, zero, or positive if the first\n** is less than, equal to, or greater than the second.\n**\n** The rScore is the primary key.  Smaller rScore values come first.\n** If the rScore is a tie, then use iLevel as the tie breaker with smaller\n** iLevel values coming first.  In this way, if rScore is the same for all\n** SearchPoints, then iLevel becomes the deciding factor and the result\n** is a depth-first search, which is the desired default behavior.\n*/\nstatic int rtreeSearchPointCompare(\n  const RtreeSearchPoint *pA,\n  const RtreeSearchPoint *pB\n){\n  if( pA->rScore<pB->rScore ) return -1;\n  if( pA->rScore>pB->rScore ) return +1;\n  if( pA->iLevel<pB->iLevel ) return -1;\n  if( pA->iLevel>pB->iLevel ) return +1;\n  return 0;\n}\n\n/*\n** Interchange two search points in a cursor.\n*/\nstatic void rtreeSearchPointSwap(RtreeCursor *p, int i, int j){\n  RtreeSearchPoint t = p->aPoint[i];\n  assert( i<j );\n  p->aPoint[i] = p->aPoint[j];\n  p->aPoint[j] = t;\n  i++; j++;\n  if( i<RTREE_CACHE_SZ ){\n    if( j>=RTREE_CACHE_SZ ){\n      nodeRelease(RTREE_OF_CURSOR(p), p->aNode[i]);\n      p->aNode[i] = 0;\n    }else{\n      RtreeNode *pTemp = p->aNode[i];\n      p->aNode[i] = p->aNode[j];\n      p->aNode[j] = pTemp;\n    }\n  }\n}\n\n/*\n** Return the search point with the lowest current score.\n*/\nstatic RtreeSearchPoint *rtreeSearchPointFirst(RtreeCursor *pCur){\n  return pCur->bPoint ? &pCur->sPoint : pCur->nPoint ? pCur->aPoint : 0;\n}\n\n/*\n** Get the RtreeNode for the search point with the lowest score.\n*/\nstatic RtreeNode *rtreeNodeOfFirstSearchPoint(RtreeCursor *pCur, int *pRC){\n  sqlite3_int64 id;\n  int ii = 1 - pCur->bPoint;\n  assert( ii==0 || ii==1 );\n  assert( pCur->bPoint || pCur->nPoint );\n  if( pCur->aNode[ii]==0 ){\n    assert( pRC!=0 );\n    id = ii ? pCur->aPoint[0].id : pCur->sPoint.id;\n    *pRC = nodeAcquire(RTREE_OF_CURSOR(pCur), id, 0, &pCur->aNode[ii]);\n  }\n  return pCur->aNode[ii];\n}\n\n/*\n** Push a new element onto the priority queue\n*/\nstatic RtreeSearchPoint *rtreeEnqueue(\n  RtreeCursor *pCur,    /* The cursor */\n  RtreeDValue rScore,   /* Score for the new search point */\n  u8 iLevel             /* Level for the new search point */\n){\n  int i, j;\n  RtreeSearchPoint *pNew;\n  if( pCur->nPoint>=pCur->nPointAlloc ){\n    int nNew = pCur->nPointAlloc*2 + 8;\n    pNew = sqlite3_realloc64(pCur->aPoint, nNew*sizeof(pCur->aPoint[0]));\n    if( pNew==0 ) return 0;\n    pCur->aPoint = pNew;\n    pCur->nPointAlloc = nNew;\n  }\n  i = pCur->nPoint++;\n  pNew = pCur->aPoint + i;\n  pNew->rScore = rScore;\n  pNew->iLevel = iLevel;\n  assert( iLevel<=RTREE_MAX_DEPTH );\n  while( i>0 ){\n    RtreeSearchPoint *pParent;\n    j = (i-1)/2;\n    pParent = pCur->aPoint + j;\n    if( rtreeSearchPointCompare(pNew, pParent)>=0 ) break;\n    rtreeSearchPointSwap(pCur, j, i);\n    i = j;\n    pNew = pParent;\n  }\n  return pNew;\n}\n\n/*\n** Allocate a new RtreeSearchPoint and return a pointer to it.  Return\n** NULL if malloc fails.\n*/\nstatic RtreeSearchPoint *rtreeSearchPointNew(\n  RtreeCursor *pCur,    /* The cursor */\n  RtreeDValue rScore,   /* Score for the new search point */\n  u8 iLevel             /* Level for the new search point */\n){\n  RtreeSearchPoint *pNew, *pFirst;\n  pFirst = rtreeSearchPointFirst(pCur);\n  pCur->anQueue[iLevel]++;\n  if( pFirst==0\n   || pFirst->rScore>rScore \n   || (pFirst->rScore==rScore && pFirst->iLevel>iLevel)\n  ){\n    if( pCur->bPoint ){\n      int ii;\n      pNew = rtreeEnqueue(pCur, rScore, iLevel);\n      if( pNew==0 ) return 0;\n      ii = (int)(pNew - pCur->aPoint) + 1;\n      if( ii<RTREE_CACHE_SZ ){\n        assert( pCur->aNode[ii]==0 );\n        pCur->aNode[ii] = pCur->aNode[0];\n      }else{\n        nodeRelease(RTREE_OF_CURSOR(pCur), pCur->aNode[0]);\n      }\n      pCur->aNode[0] = 0;\n      *pNew = pCur->sPoint;\n    }\n    pCur->sPoint.rScore = rScore;\n    pCur->sPoint.iLevel = iLevel;\n    pCur->bPoint = 1;\n    return &pCur->sPoint;\n  }else{\n    return rtreeEnqueue(pCur, rScore, iLevel);\n  }\n}\n\n#if 0\n/* Tracing routines for the RtreeSearchPoint queue */\nstatic void tracePoint(RtreeSearchPoint *p, int idx, RtreeCursor *pCur){\n  if( idx<0 ){ printf(\" s\"); }else{ printf(\"%2d\", idx); }\n  printf(\" %d.%05lld.%02d %g %d\",\n    p->iLevel, p->id, p->iCell, p->rScore, p->eWithin\n  );\n  idx++;\n  if( idx<RTREE_CACHE_SZ ){\n    printf(\" %p\\n\", pCur->aNode[idx]);\n  }else{\n    printf(\"\\n\");\n  }\n}\nstatic void traceQueue(RtreeCursor *pCur, const char *zPrefix){\n  int ii;\n  printf(\"=== %9s \", zPrefix);\n  if( pCur->bPoint ){\n    tracePoint(&pCur->sPoint, -1, pCur);\n  }\n  for(ii=0; ii<pCur->nPoint; ii++){\n    if( ii>0 || pCur->bPoint ) printf(\"              \");\n    tracePoint(&pCur->aPoint[ii], ii, pCur);\n  }\n}\n# define RTREE_QUEUE_TRACE(A,B) traceQueue(A,B)\n#else\n# define RTREE_QUEUE_TRACE(A,B)   /* no-op */\n#endif\n\n/* Remove the search point with the lowest current score.\n*/\nstatic void rtreeSearchPointPop(RtreeCursor *p){\n  int i, j, k, n;\n  i = 1 - p->bPoint;\n  assert( i==0 || i==1 );\n  if( p->aNode[i] ){\n    nodeRelease(RTREE_OF_CURSOR(p), p->aNode[i]);\n    p->aNode[i] = 0;\n  }\n  if( p->bPoint ){\n    p->anQueue[p->sPoint.iLevel]--;\n    p->bPoint = 0;\n  }else if( p->nPoint ){\n    p->anQueue[p->aPoint[0].iLevel]--;\n    n = --p->nPoint;\n    p->aPoint[0] = p->aPoint[n];\n    if( n<RTREE_CACHE_SZ-1 ){\n      p->aNode[1] = p->aNode[n+1];\n      p->aNode[n+1] = 0;\n    }\n    i = 0;\n    while( (j = i*2+1)<n ){\n      k = j+1;\n      if( k<n && rtreeSearchPointCompare(&p->aPoint[k], &p->aPoint[j])<0 ){\n        if( rtreeSearchPointCompare(&p->aPoint[k], &p->aPoint[i])<0 ){\n          rtreeSearchPointSwap(p, i, k);\n          i = k;\n        }else{\n          break;\n        }\n      }else{\n        if( rtreeSearchPointCompare(&p->aPoint[j], &p->aPoint[i])<0 ){\n          rtreeSearchPointSwap(p, i, j);\n          i = j;\n        }else{\n          break;\n        }\n      }\n    }\n  }\n}\n\n\n/*\n** Continue the search on cursor pCur until the front of the queue\n** contains an entry suitable for returning as a result-set row,\n** or until the RtreeSearchPoint queue is empty, indicating that the\n** query has completed.\n*/\nstatic int rtreeStepToLeaf(RtreeCursor *pCur){\n  RtreeSearchPoint *p;\n  Rtree *pRtree = RTREE_OF_CURSOR(pCur);\n  RtreeNode *pNode;\n  int eWithin;\n  int rc = SQLITE_OK;\n  int nCell;\n  int nConstraint = pCur->nConstraint;\n  int ii;\n  int eInt;\n  RtreeSearchPoint x;\n\n  eInt = pRtree->eCoordType==RTREE_COORD_INT32;\n  while( (p = rtreeSearchPointFirst(pCur))!=0 && p->iLevel>0 ){\n    pNode = rtreeNodeOfFirstSearchPoint(pCur, &rc);\n    if( rc ) return rc;\n    nCell = NCELL(pNode);\n    assert( nCell<200 );\n    while( p->iCell<nCell ){\n      sqlite3_rtree_dbl rScore = (sqlite3_rtree_dbl)-1;\n      u8 *pCellData = pNode->zData + (4+pRtree->nBytesPerCell*p->iCell);\n      eWithin = FULLY_WITHIN;\n      for(ii=0; ii<nConstraint; ii++){\n        RtreeConstraint *pConstraint = pCur->aConstraint + ii;\n        if( pConstraint->op>=RTREE_MATCH ){\n          rc = rtreeCallbackConstraint(pConstraint, eInt, pCellData, p,\n                                       &rScore, &eWithin);\n          if( rc ) return rc;\n        }else if( p->iLevel==1 ){\n          rtreeLeafConstraint(pConstraint, eInt, pCellData, &eWithin);\n        }else{\n          rtreeNonleafConstraint(pConstraint, eInt, pCellData, &eWithin);\n        }\n        if( eWithin==NOT_WITHIN ) break;\n      }\n      p->iCell++;\n      if( eWithin==NOT_WITHIN ) continue;\n      x.iLevel = p->iLevel - 1;\n      if( x.iLevel ){\n        x.id = readInt64(pCellData);\n        x.iCell = 0;\n      }else{\n        x.id = p->id;\n        x.iCell = p->iCell - 1;\n      }\n      if( p->iCell>=nCell ){\n        RTREE_QUEUE_TRACE(pCur, \"POP-S:\");\n        rtreeSearchPointPop(pCur);\n      }\n      if( rScore<RTREE_ZERO ) rScore = RTREE_ZERO;\n      p = rtreeSearchPointNew(pCur, rScore, x.iLevel);\n      if( p==0 ) return SQLITE_NOMEM;\n      p->eWithin = (u8)eWithin;\n      p->id = x.id;\n      p->iCell = x.iCell;\n      RTREE_QUEUE_TRACE(pCur, \"PUSH-S:\");\n      break;\n    }\n    if( p->iCell>=nCell ){\n      RTREE_QUEUE_TRACE(pCur, \"POP-Se:\");\n      rtreeSearchPointPop(pCur);\n    }\n  }\n  pCur->atEOF = p==0;\n  return SQLITE_OK;\n}\n\n/* \n** Rtree virtual table module xNext method.\n*/\nstatic int rtreeNext(sqlite3_vtab_cursor *pVtabCursor){\n  RtreeCursor *pCsr = (RtreeCursor *)pVtabCursor;\n  int rc = SQLITE_OK;\n\n  /* Move to the next entry that matches the configured constraints. */\n  RTREE_QUEUE_TRACE(pCsr, \"POP-Nx:\");\n  if( pCsr->bAuxValid ){\n    pCsr->bAuxValid = 0;\n    sqlite3_reset(pCsr->pReadAux);\n  }\n  rtreeSearchPointPop(pCsr);\n  rc = rtreeStepToLeaf(pCsr);\n  return rc;\n}\n\n/* \n** Rtree virtual table module xRowid method.\n*/\nstatic int rtreeRowid(sqlite3_vtab_cursor *pVtabCursor, sqlite_int64 *pRowid){\n  RtreeCursor *pCsr = (RtreeCursor *)pVtabCursor;\n  RtreeSearchPoint *p = rtreeSearchPointFirst(pCsr);\n  int rc = SQLITE_OK;\n  RtreeNode *pNode = rtreeNodeOfFirstSearchPoint(pCsr, &rc);\n  if( rc==SQLITE_OK && p ){\n    *pRowid = nodeGetRowid(RTREE_OF_CURSOR(pCsr), pNode, p->iCell);\n  }\n  return rc;\n}\n\n/* \n** Rtree virtual table module xColumn method.\n*/\nstatic int rtreeColumn(sqlite3_vtab_cursor *cur, sqlite3_context *ctx, int i){\n  Rtree *pRtree = (Rtree *)cur->pVtab;\n  RtreeCursor *pCsr = (RtreeCursor *)cur;\n  RtreeSearchPoint *p = rtreeSearchPointFirst(pCsr);\n  RtreeCoord c;\n  int rc = SQLITE_OK;\n  RtreeNode *pNode = rtreeNodeOfFirstSearchPoint(pCsr, &rc);\n\n  if( rc ) return rc;\n  if( p==0 ) return SQLITE_OK;\n  if( i==0 ){\n    sqlite3_result_int64(ctx, nodeGetRowid(pRtree, pNode, p->iCell));\n  }else if( i<=pRtree->nDim2 ){\n    nodeGetCoord(pRtree, pNode, p->iCell, i-1, &c);\n#ifndef SQLITE_RTREE_INT_ONLY\n    if( pRtree->eCoordType==RTREE_COORD_REAL32 ){\n      sqlite3_result_double(ctx, c.f);\n    }else\n#endif\n    {\n      assert( pRtree->eCoordType==RTREE_COORD_INT32 );\n      sqlite3_result_int(ctx, c.i);\n    }\n  }else{\n    if( !pCsr->bAuxValid ){\n      if( pCsr->pReadAux==0 ){\n        rc = sqlite3_prepare_v3(pRtree->db, pRtree->zReadAuxSql, -1, 0,\n                                &pCsr->pReadAux, 0);\n        if( rc ) return rc;\n      }\n      sqlite3_bind_int64(pCsr->pReadAux, 1, \n          nodeGetRowid(pRtree, pNode, p->iCell));\n      rc = sqlite3_step(pCsr->pReadAux);\n      if( rc==SQLITE_ROW ){\n        pCsr->bAuxValid = 1;\n      }else{\n        sqlite3_reset(pCsr->pReadAux);\n        if( rc==SQLITE_DONE ) rc = SQLITE_OK;\n        return rc;\n      }\n    }\n    sqlite3_result_value(ctx,\n         sqlite3_column_value(pCsr->pReadAux, i - pRtree->nDim2 + 1));\n  }  \n  return SQLITE_OK;\n}\n\n/* \n** Use nodeAcquire() to obtain the leaf node containing the record with \n** rowid iRowid. If successful, set *ppLeaf to point to the node and\n** return SQLITE_OK. If there is no such record in the table, set\n** *ppLeaf to 0 and return SQLITE_OK. If an error occurs, set *ppLeaf\n** to zero and return an SQLite error code.\n*/\nstatic int findLeafNode(\n  Rtree *pRtree,              /* RTree to search */\n  i64 iRowid,                 /* The rowid searching for */\n  RtreeNode **ppLeaf,         /* Write the node here */\n  sqlite3_int64 *piNode       /* Write the node-id here */\n){\n  int rc;\n  *ppLeaf = 0;\n  sqlite3_bind_int64(pRtree->pReadRowid, 1, iRowid);\n  if( sqlite3_step(pRtree->pReadRowid)==SQLITE_ROW ){\n    i64 iNode = sqlite3_column_int64(pRtree->pReadRowid, 0);\n    if( piNode ) *piNode = iNode;\n    rc = nodeAcquire(pRtree, iNode, 0, ppLeaf);\n    sqlite3_reset(pRtree->pReadRowid);\n  }else{\n    rc = sqlite3_reset(pRtree->pReadRowid);\n  }\n  return rc;\n}\n\n/*\n** This function is called to configure the RtreeConstraint object passed\n** as the second argument for a MATCH constraint. The value passed as the\n** first argument to this function is the right-hand operand to the MATCH\n** operator.\n*/\nstatic int deserializeGeometry(sqlite3_value *pValue, RtreeConstraint *pCons){\n  RtreeMatchArg *pBlob, *pSrc;       /* BLOB returned by geometry function */\n  sqlite3_rtree_query_info *pInfo;   /* Callback information */\n\n  pSrc = sqlite3_value_pointer(pValue, \"RtreeMatchArg\");\n  if( pSrc==0 ) return SQLITE_ERROR;\n  pInfo = (sqlite3_rtree_query_info*)\n                sqlite3_malloc64( sizeof(*pInfo)+pSrc->iSize );\n  if( !pInfo ) return SQLITE_NOMEM;\n  memset(pInfo, 0, sizeof(*pInfo));\n  pBlob = (RtreeMatchArg*)&pInfo[1];\n  memcpy(pBlob, pSrc, pSrc->iSize);\n  pInfo->pContext = pBlob->cb.pContext;\n  pInfo->nParam = pBlob->nParam;\n  pInfo->aParam = pBlob->aParam;\n  pInfo->apSqlParam = pBlob->apSqlParam;\n\n  if( pBlob->cb.xGeom ){\n    pCons->u.xGeom = pBlob->cb.xGeom;\n  }else{\n    pCons->op = RTREE_QUERY;\n    pCons->u.xQueryFunc = pBlob->cb.xQueryFunc;\n  }\n  pCons->pInfo = pInfo;\n  return SQLITE_OK;\n}\n\n/* \n** Rtree virtual table module xFilter method.\n*/\nstatic int rtreeFilter(\n  sqlite3_vtab_cursor *pVtabCursor, \n  int idxNum, const char *idxStr,\n  int argc, sqlite3_value **argv\n){\n  Rtree *pRtree = (Rtree *)pVtabCursor->pVtab;\n  RtreeCursor *pCsr = (RtreeCursor *)pVtabCursor;\n  RtreeNode *pRoot = 0;\n  int ii;\n  int rc = SQLITE_OK;\n  int iCell = 0;\n  sqlite3_stmt *pStmt;\n\n  rtreeReference(pRtree);\n\n  /* Reset the cursor to the same state as rtreeOpen() leaves it in. */\n  freeCursorConstraints(pCsr);\n  sqlite3_free(pCsr->aPoint);\n  pStmt = pCsr->pReadAux;\n  memset(pCsr, 0, sizeof(RtreeCursor));\n  pCsr->base.pVtab = (sqlite3_vtab*)pRtree;\n  pCsr->pReadAux = pStmt;\n\n  pCsr->iStrategy = idxNum;\n  if( idxNum==1 ){\n    /* Special case - lookup by rowid. */\n    RtreeNode *pLeaf;        /* Leaf on which the required cell resides */\n    RtreeSearchPoint *p;     /* Search point for the leaf */\n    i64 iRowid = sqlite3_value_int64(argv[0]);\n    i64 iNode = 0;\n    rc = findLeafNode(pRtree, iRowid, &pLeaf, &iNode);\n    if( rc==SQLITE_OK && pLeaf!=0 ){\n      p = rtreeSearchPointNew(pCsr, RTREE_ZERO, 0);\n      assert( p!=0 );  /* Always returns pCsr->sPoint */\n      pCsr->aNode[0] = pLeaf;\n      p->id = iNode;\n      p->eWithin = PARTLY_WITHIN;\n      rc = nodeRowidIndex(pRtree, pLeaf, iRowid, &iCell);\n      p->iCell = (u8)iCell;\n      RTREE_QUEUE_TRACE(pCsr, \"PUSH-F1:\");\n    }else{\n      pCsr->atEOF = 1;\n    }\n  }else{\n    /* Normal case - r-tree scan. Set up the RtreeCursor.aConstraint array \n    ** with the configured constraints. \n    */\n    rc = nodeAcquire(pRtree, 1, 0, &pRoot);\n    if( rc==SQLITE_OK && argc>0 ){\n      pCsr->aConstraint = sqlite3_malloc64(sizeof(RtreeConstraint)*argc);\n      pCsr->nConstraint = argc;\n      if( !pCsr->aConstraint ){\n        rc = SQLITE_NOMEM;\n      }else{\n        memset(pCsr->aConstraint, 0, sizeof(RtreeConstraint)*argc);\n        memset(pCsr->anQueue, 0, sizeof(u32)*(pRtree->iDepth + 1));\n        assert( (idxStr==0 && argc==0)\n                || (idxStr && (int)strlen(idxStr)==argc*2) );\n        for(ii=0; ii<argc; ii++){\n          RtreeConstraint *p = &pCsr->aConstraint[ii];\n          p->op = idxStr[ii*2];\n          p->iCoord = idxStr[ii*2+1]-'0';\n          if( p->op>=RTREE_MATCH ){\n            /* A MATCH operator. The right-hand-side must be a blob that\n            ** can be cast into an RtreeMatchArg object. One created using\n            ** an sqlite3_rtree_geometry_callback() SQL user function.\n            */\n            rc = deserializeGeometry(argv[ii], p);\n            if( rc!=SQLITE_OK ){\n              break;\n            }\n            p->pInfo->nCoord = pRtree->nDim2;\n            p->pInfo->anQueue = pCsr->anQueue;\n            p->pInfo->mxLevel = pRtree->iDepth + 1;\n          }else{\n#ifdef SQLITE_RTREE_INT_ONLY\n            p->u.rValue = sqlite3_value_int64(argv[ii]);\n#else\n            p->u.rValue = sqlite3_value_double(argv[ii]);\n#endif\n          }\n        }\n      }\n    }\n    if( rc==SQLITE_OK ){\n      RtreeSearchPoint *pNew;\n      pNew = rtreeSearchPointNew(pCsr, RTREE_ZERO, (u8)(pRtree->iDepth+1));\n      if( pNew==0 ) return SQLITE_NOMEM;\n      pNew->id = 1;\n      pNew->iCell = 0;\n      pNew->eWithin = PARTLY_WITHIN;\n      assert( pCsr->bPoint==1 );\n      pCsr->aNode[0] = pRoot;\n      pRoot = 0;\n      RTREE_QUEUE_TRACE(pCsr, \"PUSH-Fm:\");\n      rc = rtreeStepToLeaf(pCsr);\n    }\n  }\n\n  nodeRelease(pRtree, pRoot);\n  rtreeRelease(pRtree);\n  return rc;\n}\n\n/*\n** Rtree virtual table module xBestIndex method. There are three\n** table scan strategies to choose from (in order from most to \n** least desirable):\n**\n**   idxNum     idxStr        Strategy\n**   ------------------------------------------------\n**     1        Unused        Direct lookup by rowid.\n**     2        See below     R-tree query or full-table scan.\n**   ------------------------------------------------\n**\n** If strategy 1 is used, then idxStr is not meaningful. If strategy\n** 2 is used, idxStr is formatted to contain 2 bytes for each \n** constraint used. The first two bytes of idxStr correspond to \n** the constraint in sqlite3_index_info.aConstraintUsage[] with\n** (argvIndex==1) etc.\n**\n** The first of each pair of bytes in idxStr identifies the constraint\n** operator as follows:\n**\n**   Operator    Byte Value\n**   ----------------------\n**      =        0x41 ('A')\n**     <=        0x42 ('B')\n**      <        0x43 ('C')\n**     >=        0x44 ('D')\n**      >        0x45 ('E')\n**   MATCH       0x46 ('F')\n**   ----------------------\n**\n** The second of each pair of bytes identifies the coordinate column\n** to which the constraint applies. The leftmost coordinate column\n** is 'a', the second from the left 'b' etc.\n*/\nstatic int rtreeBestIndex(sqlite3_vtab *tab, sqlite3_index_info *pIdxInfo){\n  Rtree *pRtree = (Rtree*)tab;\n  int rc = SQLITE_OK;\n  int ii;\n  int bMatch = 0;                 /* True if there exists a MATCH constraint */\n  i64 nRow;                       /* Estimated rows returned by this scan */\n\n  int iIdx = 0;\n  char zIdxStr[RTREE_MAX_DIMENSIONS*8+1];\n  memset(zIdxStr, 0, sizeof(zIdxStr));\n\n  /* Check if there exists a MATCH constraint - even an unusable one. If there\n  ** is, do not consider the lookup-by-rowid plan as using such a plan would\n  ** require the VDBE to evaluate the MATCH constraint, which is not currently\n  ** possible. */\n  for(ii=0; ii<pIdxInfo->nConstraint; ii++){\n    if( pIdxInfo->aConstraint[ii].op==SQLITE_INDEX_CONSTRAINT_MATCH ){\n      bMatch = 1;\n    }\n  }\n\n  assert( pIdxInfo->idxStr==0 );\n  for(ii=0; ii<pIdxInfo->nConstraint && iIdx<(int)(sizeof(zIdxStr)-1); ii++){\n    struct sqlite3_index_constraint *p = &pIdxInfo->aConstraint[ii];\n\n    if( bMatch==0 && p->usable \n     && p->iColumn==0 && p->op==SQLITE_INDEX_CONSTRAINT_EQ \n    ){\n      /* We have an equality constraint on the rowid. Use strategy 1. */\n      int jj;\n      for(jj=0; jj<ii; jj++){\n        pIdxInfo->aConstraintUsage[jj].argvIndex = 0;\n        pIdxInfo->aConstraintUsage[jj].omit = 0;\n      }\n      pIdxInfo->idxNum = 1;\n      pIdxInfo->aConstraintUsage[ii].argvIndex = 1;\n      pIdxInfo->aConstraintUsage[jj].omit = 1;\n\n      /* This strategy involves a two rowid lookups on an B-Tree structures\n      ** and then a linear search of an R-Tree node. This should be \n      ** considered almost as quick as a direct rowid lookup (for which \n      ** sqlite uses an internal cost of 0.0). It is expected to return\n      ** a single row.\n      */ \n      pIdxInfo->estimatedCost = 30.0;\n      pIdxInfo->estimatedRows = 1;\n      pIdxInfo->idxFlags = SQLITE_INDEX_SCAN_UNIQUE;\n      return SQLITE_OK;\n    }\n\n    if( p->usable\n    && ((p->iColumn>0 && p->iColumn<=pRtree->nDim2)\n        || p->op==SQLITE_INDEX_CONSTRAINT_MATCH)\n    ){\n      u8 op;\n      switch( p->op ){\n        case SQLITE_INDEX_CONSTRAINT_EQ:    op = RTREE_EQ;    break;\n        case SQLITE_INDEX_CONSTRAINT_GT:    op = RTREE_GT;    break;\n        case SQLITE_INDEX_CONSTRAINT_LE:    op = RTREE_LE;    break;\n        case SQLITE_INDEX_CONSTRAINT_LT:    op = RTREE_LT;    break;\n        case SQLITE_INDEX_CONSTRAINT_GE:    op = RTREE_GE;    break;\n        case SQLITE_INDEX_CONSTRAINT_MATCH: op = RTREE_MATCH; break;\n        default:                            op = 0;           break;\n      }\n      if( op ){\n        zIdxStr[iIdx++] = op;\n        zIdxStr[iIdx++] = (char)(p->iColumn - 1 + '0');\n        pIdxInfo->aConstraintUsage[ii].argvIndex = (iIdx/2);\n        pIdxInfo->aConstraintUsage[ii].omit = 1;\n      }\n    }\n  }\n\n  pIdxInfo->idxNum = 2;\n  pIdxInfo->needToFreeIdxStr = 1;\n  if( iIdx>0 && 0==(pIdxInfo->idxStr = sqlite3_mprintf(\"%s\", zIdxStr)) ){\n    return SQLITE_NOMEM;\n  }\n\n  nRow = pRtree->nRowEst >> (iIdx/2);\n  pIdxInfo->estimatedCost = (double)6.0 * (double)nRow;\n  pIdxInfo->estimatedRows = nRow;\n\n  return rc;\n}\n\n/*\n** Return the N-dimensional volumn of the cell stored in *p.\n*/\nstatic RtreeDValue cellArea(Rtree *pRtree, RtreeCell *p){\n  RtreeDValue area = (RtreeDValue)1;\n  assert( pRtree->nDim>=1 && pRtree->nDim<=5 );\n#ifndef SQLITE_RTREE_INT_ONLY\n  if( pRtree->eCoordType==RTREE_COORD_REAL32 ){\n    switch( pRtree->nDim ){\n      case 5:  area  = p->aCoord[9].f - p->aCoord[8].f;\n      case 4:  area *= p->aCoord[7].f - p->aCoord[6].f;\n      case 3:  area *= p->aCoord[5].f - p->aCoord[4].f;\n      case 2:  area *= p->aCoord[3].f - p->aCoord[2].f;\n      default: area *= p->aCoord[1].f - p->aCoord[0].f;\n    }\n  }else\n#endif\n  {\n    switch( pRtree->nDim ){\n      case 5:  area  = (i64)p->aCoord[9].i - (i64)p->aCoord[8].i;\n      case 4:  area *= (i64)p->aCoord[7].i - (i64)p->aCoord[6].i;\n      case 3:  area *= (i64)p->aCoord[5].i - (i64)p->aCoord[4].i;\n      case 2:  area *= (i64)p->aCoord[3].i - (i64)p->aCoord[2].i;\n      default: area *= (i64)p->aCoord[1].i - (i64)p->aCoord[0].i;\n    }\n  }\n  return area;\n}\n\n/*\n** Return the margin length of cell p. The margin length is the sum\n** of the objects size in each dimension.\n*/\nstatic RtreeDValue cellMargin(Rtree *pRtree, RtreeCell *p){\n  RtreeDValue margin = 0;\n  int ii = pRtree->nDim2 - 2;\n  do{\n    margin += (DCOORD(p->aCoord[ii+1]) - DCOORD(p->aCoord[ii]));\n    ii -= 2;\n  }while( ii>=0 );\n  return margin;\n}\n\n/*\n** Store the union of cells p1 and p2 in p1.\n*/\nstatic void cellUnion(Rtree *pRtree, RtreeCell *p1, RtreeCell *p2){\n  int ii = 0;\n  if( pRtree->eCoordType==RTREE_COORD_REAL32 ){\n    do{\n      p1->aCoord[ii].f = MIN(p1->aCoord[ii].f, p2->aCoord[ii].f);\n      p1->aCoord[ii+1].f = MAX(p1->aCoord[ii+1].f, p2->aCoord[ii+1].f);\n      ii += 2;\n    }while( ii<pRtree->nDim2 );\n  }else{\n    do{\n      p1->aCoord[ii].i = MIN(p1->aCoord[ii].i, p2->aCoord[ii].i);\n      p1->aCoord[ii+1].i = MAX(p1->aCoord[ii+1].i, p2->aCoord[ii+1].i);\n      ii += 2;\n    }while( ii<pRtree->nDim2 );\n  }\n}\n\n/*\n** Return true if the area covered by p2 is a subset of the area covered\n** by p1. False otherwise.\n*/\nstatic int cellContains(Rtree *pRtree, RtreeCell *p1, RtreeCell *p2){\n  int ii;\n  int isInt = (pRtree->eCoordType==RTREE_COORD_INT32);\n  for(ii=0; ii<pRtree->nDim2; ii+=2){\n    RtreeCoord *a1 = &p1->aCoord[ii];\n    RtreeCoord *a2 = &p2->aCoord[ii];\n    if( (!isInt && (a2[0].f<a1[0].f || a2[1].f>a1[1].f)) \n     || ( isInt && (a2[0].i<a1[0].i || a2[1].i>a1[1].i)) \n    ){\n      return 0;\n    }\n  }\n  return 1;\n}\n\n/*\n** Return the amount cell p would grow by if it were unioned with pCell.\n*/\nstatic RtreeDValue cellGrowth(Rtree *pRtree, RtreeCell *p, RtreeCell *pCell){\n  RtreeDValue area;\n  RtreeCell cell;\n  memcpy(&cell, p, sizeof(RtreeCell));\n  area = cellArea(pRtree, &cell);\n  cellUnion(pRtree, &cell, pCell);\n  return (cellArea(pRtree, &cell)-area);\n}\n\nstatic RtreeDValue cellOverlap(\n  Rtree *pRtree, \n  RtreeCell *p, \n  RtreeCell *aCell, \n  int nCell\n){\n  int ii;\n  RtreeDValue overlap = RTREE_ZERO;\n  for(ii=0; ii<nCell; ii++){\n    int jj;\n    RtreeDValue o = (RtreeDValue)1;\n    for(jj=0; jj<pRtree->nDim2; jj+=2){\n      RtreeDValue x1, x2;\n      x1 = MAX(DCOORD(p->aCoord[jj]), DCOORD(aCell[ii].aCoord[jj]));\n      x2 = MIN(DCOORD(p->aCoord[jj+1]), DCOORD(aCell[ii].aCoord[jj+1]));\n      if( x2<x1 ){\n        o = (RtreeDValue)0;\n        break;\n      }else{\n        o = o * (x2-x1);\n      }\n    }\n    overlap += o;\n  }\n  return overlap;\n}\n\n\n/*\n** This function implements the ChooseLeaf algorithm from Gutman[84].\n** ChooseSubTree in r*tree terminology.\n*/\nstatic int ChooseLeaf(\n  Rtree *pRtree,               /* Rtree table */\n  RtreeCell *pCell,            /* Cell to insert into rtree */\n  int iHeight,                 /* Height of sub-tree rooted at pCell */\n  RtreeNode **ppLeaf           /* OUT: Selected leaf page */\n){\n  int rc;\n  int ii;\n  RtreeNode *pNode = 0;\n  rc = nodeAcquire(pRtree, 1, 0, &pNode);\n\n  for(ii=0; rc==SQLITE_OK && ii<(pRtree->iDepth-iHeight); ii++){\n    int iCell;\n    sqlite3_int64 iBest = 0;\n\n    RtreeDValue fMinGrowth = RTREE_ZERO;\n    RtreeDValue fMinArea = RTREE_ZERO;\n\n    int nCell = NCELL(pNode);\n    RtreeCell cell;\n    RtreeNode *pChild;\n\n    RtreeCell *aCell = 0;\n\n    /* Select the child node which will be enlarged the least if pCell\n    ** is inserted into it. Resolve ties by choosing the entry with\n    ** the smallest area.\n    */\n    for(iCell=0; iCell<nCell; iCell++){\n      int bBest = 0;\n      RtreeDValue growth;\n      RtreeDValue area;\n      nodeGetCell(pRtree, pNode, iCell, &cell);\n      growth = cellGrowth(pRtree, &cell, pCell);\n      area = cellArea(pRtree, &cell);\n      if( iCell==0||growth<fMinGrowth||(growth==fMinGrowth && area<fMinArea) ){\n        bBest = 1;\n      }\n      if( bBest ){\n        fMinGrowth = growth;\n        fMinArea = area;\n        iBest = cell.iRowid;\n      }\n    }\n\n    sqlite3_free(aCell);\n    rc = nodeAcquire(pRtree, iBest, pNode, &pChild);\n    nodeRelease(pRtree, pNode);\n    pNode = pChild;\n  }\n\n  *ppLeaf = pNode;\n  return rc;\n}\n\n/*\n** A cell with the same content as pCell has just been inserted into\n** the node pNode. This function updates the bounding box cells in\n** all ancestor elements.\n*/\nstatic int AdjustTree(\n  Rtree *pRtree,                    /* Rtree table */\n  RtreeNode *pNode,                 /* Adjust ancestry of this node. */\n  RtreeCell *pCell                  /* This cell was just inserted */\n){\n  RtreeNode *p = pNode;\n  int cnt = 0;\n  while( p->pParent ){\n    RtreeNode *pParent = p->pParent;\n    RtreeCell cell;\n    int iCell;\n\n    if( (++cnt)>1000 || nodeParentIndex(pRtree, p, &iCell)  ){\n      RTREE_IS_CORRUPT(pRtree);\n      return SQLITE_CORRUPT_VTAB;\n    }\n\n    nodeGetCell(pRtree, pParent, iCell, &cell);\n    if( !cellContains(pRtree, &cell, pCell) ){\n      cellUnion(pRtree, &cell, pCell);\n      nodeOverwriteCell(pRtree, pParent, &cell, iCell);\n    }\n \n    p = pParent;\n  }\n  return SQLITE_OK;\n}\n\n/*\n** Write mapping (iRowid->iNode) to the <rtree>_rowid table.\n*/\nstatic int rowidWrite(Rtree *pRtree, sqlite3_int64 iRowid, sqlite3_int64 iNode){\n  sqlite3_bind_int64(pRtree->pWriteRowid, 1, iRowid);\n  sqlite3_bind_int64(pRtree->pWriteRowid, 2, iNode);\n  sqlite3_step(pRtree->pWriteRowid);\n  return sqlite3_reset(pRtree->pWriteRowid);\n}\n\n/*\n** Write mapping (iNode->iPar) to the <rtree>_parent table.\n*/\nstatic int parentWrite(Rtree *pRtree, sqlite3_int64 iNode, sqlite3_int64 iPar){\n  sqlite3_bind_int64(pRtree->pWriteParent, 1, iNode);\n  sqlite3_bind_int64(pRtree->pWriteParent, 2, iPar);\n  sqlite3_step(pRtree->pWriteParent);\n  return sqlite3_reset(pRtree->pWriteParent);\n}\n\nstatic int rtreeInsertCell(Rtree *, RtreeNode *, RtreeCell *, int);\n\n\n/*\n** Arguments aIdx, aDistance and aSpare all point to arrays of size\n** nIdx. The aIdx array contains the set of integers from 0 to \n** (nIdx-1) in no particular order. This function sorts the values\n** in aIdx according to the indexed values in aDistance. For\n** example, assuming the inputs:\n**\n**   aIdx      = { 0,   1,   2,   3 }\n**   aDistance = { 5.0, 2.0, 7.0, 6.0 }\n**\n** this function sets the aIdx array to contain:\n**\n**   aIdx      = { 0,   1,   2,   3 }\n**\n** The aSpare array is used as temporary working space by the\n** sorting algorithm.\n*/\nstatic void SortByDistance(\n  int *aIdx, \n  int nIdx, \n  RtreeDValue *aDistance, \n  int *aSpare\n){\n  if( nIdx>1 ){\n    int iLeft = 0;\n    int iRight = 0;\n\n    int nLeft = nIdx/2;\n    int nRight = nIdx-nLeft;\n    int *aLeft = aIdx;\n    int *aRight = &aIdx[nLeft];\n\n    SortByDistance(aLeft, nLeft, aDistance, aSpare);\n    SortByDistance(aRight, nRight, aDistance, aSpare);\n\n    memcpy(aSpare, aLeft, sizeof(int)*nLeft);\n    aLeft = aSpare;\n\n    while( iLeft<nLeft || iRight<nRight ){\n      if( iLeft==nLeft ){\n        aIdx[iLeft+iRight] = aRight[iRight];\n        iRight++;\n      }else if( iRight==nRight ){\n        aIdx[iLeft+iRight] = aLeft[iLeft];\n        iLeft++;\n      }else{\n        RtreeDValue fLeft = aDistance[aLeft[iLeft]];\n        RtreeDValue fRight = aDistance[aRight[iRight]];\n        if( fLeft<fRight ){\n          aIdx[iLeft+iRight] = aLeft[iLeft];\n          iLeft++;\n        }else{\n          aIdx[iLeft+iRight] = aRight[iRight];\n          iRight++;\n        }\n      }\n    }\n\n#if 0\n    /* Check that the sort worked */\n    {\n      int jj;\n      for(jj=1; jj<nIdx; jj++){\n        RtreeDValue left = aDistance[aIdx[jj-1]];\n        RtreeDValue right = aDistance[aIdx[jj]];\n        assert( left<=right );\n      }\n    }\n#endif\n  }\n}\n\n/*\n** Arguments aIdx, aCell and aSpare all point to arrays of size\n** nIdx. The aIdx array contains the set of integers from 0 to \n** (nIdx-1) in no particular order. This function sorts the values\n** in aIdx according to dimension iDim of the cells in aCell. The\n** minimum value of dimension iDim is considered first, the\n** maximum used to break ties.\n**\n** The aSpare array is used as temporary working space by the\n** sorting algorithm.\n*/\nstatic void SortByDimension(\n  Rtree *pRtree,\n  int *aIdx, \n  int nIdx, \n  int iDim, \n  RtreeCell *aCell, \n  int *aSpare\n){\n  if( nIdx>1 ){\n\n    int iLeft = 0;\n    int iRight = 0;\n\n    int nLeft = nIdx/2;\n    int nRight = nIdx-nLeft;\n    int *aLeft = aIdx;\n    int *aRight = &aIdx[nLeft];\n\n    SortByDimension(pRtree, aLeft, nLeft, iDim, aCell, aSpare);\n    SortByDimension(pRtree, aRight, nRight, iDim, aCell, aSpare);\n\n    memcpy(aSpare, aLeft, sizeof(int)*nLeft);\n    aLeft = aSpare;\n    while( iLeft<nLeft || iRight<nRight ){\n      RtreeDValue xleft1 = DCOORD(aCell[aLeft[iLeft]].aCoord[iDim*2]);\n      RtreeDValue xleft2 = DCOORD(aCell[aLeft[iLeft]].aCoord[iDim*2+1]);\n      RtreeDValue xright1 = DCOORD(aCell[aRight[iRight]].aCoord[iDim*2]);\n      RtreeDValue xright2 = DCOORD(aCell[aRight[iRight]].aCoord[iDim*2+1]);\n      if( (iLeft!=nLeft) && ((iRight==nRight)\n       || (xleft1<xright1)\n       || (xleft1==xright1 && xleft2<xright2)\n      )){\n        aIdx[iLeft+iRight] = aLeft[iLeft];\n        iLeft++;\n      }else{\n        aIdx[iLeft+iRight] = aRight[iRight];\n        iRight++;\n      }\n    }\n\n#if 0\n    /* Check that the sort worked */\n    {\n      int jj;\n      for(jj=1; jj<nIdx; jj++){\n        RtreeDValue xleft1 = aCell[aIdx[jj-1]].aCoord[iDim*2];\n        RtreeDValue xleft2 = aCell[aIdx[jj-1]].aCoord[iDim*2+1];\n        RtreeDValue xright1 = aCell[aIdx[jj]].aCoord[iDim*2];\n        RtreeDValue xright2 = aCell[aIdx[jj]].aCoord[iDim*2+1];\n        assert( xleft1<=xright1 && (xleft1<xright1 || xleft2<=xright2) );\n      }\n    }\n#endif\n  }\n}\n\n/*\n** Implementation of the R*-tree variant of SplitNode from Beckman[1990].\n*/\nstatic int splitNodeStartree(\n  Rtree *pRtree,\n  RtreeCell *aCell,\n  int nCell,\n  RtreeNode *pLeft,\n  RtreeNode *pRight,\n  RtreeCell *pBboxLeft,\n  RtreeCell *pBboxRight\n){\n  int **aaSorted;\n  int *aSpare;\n  int ii;\n\n  int iBestDim = 0;\n  int iBestSplit = 0;\n  RtreeDValue fBestMargin = RTREE_ZERO;\n\n  sqlite3_int64 nByte = (pRtree->nDim+1)*(sizeof(int*)+nCell*sizeof(int));\n\n  aaSorted = (int **)sqlite3_malloc64(nByte);\n  if( !aaSorted ){\n    return SQLITE_NOMEM;\n  }\n\n  aSpare = &((int *)&aaSorted[pRtree->nDim])[pRtree->nDim*nCell];\n  memset(aaSorted, 0, nByte);\n  for(ii=0; ii<pRtree->nDim; ii++){\n    int jj;\n    aaSorted[ii] = &((int *)&aaSorted[pRtree->nDim])[ii*nCell];\n    for(jj=0; jj<nCell; jj++){\n      aaSorted[ii][jj] = jj;\n    }\n    SortByDimension(pRtree, aaSorted[ii], nCell, ii, aCell, aSpare);\n  }\n\n  for(ii=0; ii<pRtree->nDim; ii++){\n    RtreeDValue margin = RTREE_ZERO;\n    RtreeDValue fBestOverlap = RTREE_ZERO;\n    RtreeDValue fBestArea = RTREE_ZERO;\n    int iBestLeft = 0;\n    int nLeft;\n\n    for(\n      nLeft=RTREE_MINCELLS(pRtree); \n      nLeft<=(nCell-RTREE_MINCELLS(pRtree)); \n      nLeft++\n    ){\n      RtreeCell left;\n      RtreeCell right;\n      int kk;\n      RtreeDValue overlap;\n      RtreeDValue area;\n\n      memcpy(&left, &aCell[aaSorted[ii][0]], sizeof(RtreeCell));\n      memcpy(&right, &aCell[aaSorted[ii][nCell-1]], sizeof(RtreeCell));\n      for(kk=1; kk<(nCell-1); kk++){\n        if( kk<nLeft ){\n          cellUnion(pRtree, &left, &aCell[aaSorted[ii][kk]]);\n        }else{\n          cellUnion(pRtree, &right, &aCell[aaSorted[ii][kk]]);\n        }\n      }\n      margin += cellMargin(pRtree, &left);\n      margin += cellMargin(pRtree, &right);\n      overlap = cellOverlap(pRtree, &left, &right, 1);\n      area = cellArea(pRtree, &left) + cellArea(pRtree, &right);\n      if( (nLeft==RTREE_MINCELLS(pRtree))\n       || (overlap<fBestOverlap)\n       || (overlap==fBestOverlap && area<fBestArea)\n      ){\n        iBestLeft = nLeft;\n        fBestOverlap = overlap;\n        fBestArea = area;\n      }\n    }\n\n    if( ii==0 || margin<fBestMargin ){\n      iBestDim = ii;\n      fBestMargin = margin;\n      iBestSplit = iBestLeft;\n    }\n  }\n\n  memcpy(pBboxLeft, &aCell[aaSorted[iBestDim][0]], sizeof(RtreeCell));\n  memcpy(pBboxRight, &aCell[aaSorted[iBestDim][iBestSplit]], sizeof(RtreeCell));\n  for(ii=0; ii<nCell; ii++){\n    RtreeNode *pTarget = (ii<iBestSplit)?pLeft:pRight;\n    RtreeCell *pBbox = (ii<iBestSplit)?pBboxLeft:pBboxRight;\n    RtreeCell *pCell = &aCell[aaSorted[iBestDim][ii]];\n    nodeInsertCell(pRtree, pTarget, pCell);\n    cellUnion(pRtree, pBbox, pCell);\n  }\n\n  sqlite3_free(aaSorted);\n  return SQLITE_OK;\n}\n\n\nstatic int updateMapping(\n  Rtree *pRtree, \n  i64 iRowid, \n  RtreeNode *pNode, \n  int iHeight\n){\n  int (*xSetMapping)(Rtree *, sqlite3_int64, sqlite3_int64);\n  xSetMapping = ((iHeight==0)?rowidWrite:parentWrite);\n  if( iHeight>0 ){\n    RtreeNode *pChild = nodeHashLookup(pRtree, iRowid);\n    if( pChild ){\n      nodeRelease(pRtree, pChild->pParent);\n      nodeReference(pNode);\n      pChild->pParent = pNode;\n    }\n  }\n  return xSetMapping(pRtree, iRowid, pNode->iNode);\n}\n\nstatic int SplitNode(\n  Rtree *pRtree,\n  RtreeNode *pNode,\n  RtreeCell *pCell,\n  int iHeight\n){\n  int i;\n  int newCellIsRight = 0;\n\n  int rc = SQLITE_OK;\n  int nCell = NCELL(pNode);\n  RtreeCell *aCell;\n  int *aiUsed;\n\n  RtreeNode *pLeft = 0;\n  RtreeNode *pRight = 0;\n\n  RtreeCell leftbbox;\n  RtreeCell rightbbox;\n\n  /* Allocate an array and populate it with a copy of pCell and \n  ** all cells from node pLeft. Then zero the original node.\n  */\n  aCell = sqlite3_malloc64((sizeof(RtreeCell)+sizeof(int))*(nCell+1));\n  if( !aCell ){\n    rc = SQLITE_NOMEM;\n    goto splitnode_out;\n  }\n  aiUsed = (int *)&aCell[nCell+1];\n  memset(aiUsed, 0, sizeof(int)*(nCell+1));\n  for(i=0; i<nCell; i++){\n    nodeGetCell(pRtree, pNode, i, &aCell[i]);\n  }\n  nodeZero(pRtree, pNode);\n  memcpy(&aCell[nCell], pCell, sizeof(RtreeCell));\n  nCell++;\n\n  if( pNode->iNode==1 ){\n    pRight = nodeNew(pRtree, pNode);\n    pLeft = nodeNew(pRtree, pNode);\n    pRtree->iDepth++;\n    pNode->isDirty = 1;\n    writeInt16(pNode->zData, pRtree->iDepth);\n  }else{\n    pLeft = pNode;\n    pRight = nodeNew(pRtree, pLeft->pParent);\n    pLeft->nRef++;\n  }\n\n  if( !pLeft || !pRight ){\n    rc = SQLITE_NOMEM;\n    goto splitnode_out;\n  }\n\n  memset(pLeft->zData, 0, pRtree->iNodeSize);\n  memset(pRight->zData, 0, pRtree->iNodeSize);\n\n  rc = splitNodeStartree(pRtree, aCell, nCell, pLeft, pRight,\n                         &leftbbox, &rightbbox);\n  if( rc!=SQLITE_OK ){\n    goto splitnode_out;\n  }\n\n  /* Ensure both child nodes have node numbers assigned to them by calling\n  ** nodeWrite(). Node pRight always needs a node number, as it was created\n  ** by nodeNew() above. But node pLeft sometimes already has a node number.\n  ** In this case avoid the all to nodeWrite().\n  */\n  if( SQLITE_OK!=(rc = nodeWrite(pRtree, pRight))\n   || (0==pLeft->iNode && SQLITE_OK!=(rc = nodeWrite(pRtree, pLeft)))\n  ){\n    goto splitnode_out;\n  }\n\n  rightbbox.iRowid = pRight->iNode;\n  leftbbox.iRowid = pLeft->iNode;\n\n  if( pNode->iNode==1 ){\n    rc = rtreeInsertCell(pRtree, pLeft->pParent, &leftbbox, iHeight+1);\n    if( rc!=SQLITE_OK ){\n      goto splitnode_out;\n    }\n  }else{\n    RtreeNode *pParent = pLeft->pParent;\n    int iCell;\n    rc = nodeParentIndex(pRtree, pLeft, &iCell);\n    if( rc==SQLITE_OK ){\n      nodeOverwriteCell(pRtree, pParent, &leftbbox, iCell);\n      rc = AdjustTree(pRtree, pParent, &leftbbox);\n    }\n    if( rc!=SQLITE_OK ){\n      goto splitnode_out;\n    }\n  }\n  if( (rc = rtreeInsertCell(pRtree, pRight->pParent, &rightbbox, iHeight+1)) ){\n    goto splitnode_out;\n  }\n\n  for(i=0; i<NCELL(pRight); i++){\n    i64 iRowid = nodeGetRowid(pRtree, pRight, i);\n    rc = updateMapping(pRtree, iRowid, pRight, iHeight);\n    if( iRowid==pCell->iRowid ){\n      newCellIsRight = 1;\n    }\n    if( rc!=SQLITE_OK ){\n      goto splitnode_out;\n    }\n  }\n  if( pNode->iNode==1 ){\n    for(i=0; i<NCELL(pLeft); i++){\n      i64 iRowid = nodeGetRowid(pRtree, pLeft, i);\n      rc = updateMapping(pRtree, iRowid, pLeft, iHeight);\n      if( rc!=SQLITE_OK ){\n        goto splitnode_out;\n      }\n    }\n  }else if( newCellIsRight==0 ){\n    rc = updateMapping(pRtree, pCell->iRowid, pLeft, iHeight);\n  }\n\n  if( rc==SQLITE_OK ){\n    rc = nodeRelease(pRtree, pRight);\n    pRight = 0;\n  }\n  if( rc==SQLITE_OK ){\n    rc = nodeRelease(pRtree, pLeft);\n    pLeft = 0;\n  }\n\nsplitnode_out:\n  nodeRelease(pRtree, pRight);\n  nodeRelease(pRtree, pLeft);\n  sqlite3_free(aCell);\n  return rc;\n}\n\n/*\n** If node pLeaf is not the root of the r-tree and its pParent pointer is \n** still NULL, load all ancestor nodes of pLeaf into memory and populate\n** the pLeaf->pParent chain all the way up to the root node.\n**\n** This operation is required when a row is deleted (or updated - an update\n** is implemented as a delete followed by an insert). SQLite provides the\n** rowid of the row to delete, which can be used to find the leaf on which\n** the entry resides (argument pLeaf). Once the leaf is located, this \n** function is called to determine its ancestry.\n*/\nstatic int fixLeafParent(Rtree *pRtree, RtreeNode *pLeaf){\n  int rc = SQLITE_OK;\n  RtreeNode *pChild = pLeaf;\n  while( rc==SQLITE_OK && pChild->iNode!=1 && pChild->pParent==0 ){\n    int rc2 = SQLITE_OK;          /* sqlite3_reset() return code */\n    sqlite3_bind_int64(pRtree->pReadParent, 1, pChild->iNode);\n    rc = sqlite3_step(pRtree->pReadParent);\n    if( rc==SQLITE_ROW ){\n      RtreeNode *pTest;           /* Used to test for reference loops */\n      i64 iNode;                  /* Node number of parent node */\n\n      /* Before setting pChild->pParent, test that we are not creating a\n      ** loop of references (as we would if, say, pChild==pParent). We don't\n      ** want to do this as it leads to a memory leak when trying to delete\n      ** the referenced counted node structures.\n      */\n      iNode = sqlite3_column_int64(pRtree->pReadParent, 0);\n      for(pTest=pLeaf; pTest && pTest->iNode!=iNode; pTest=pTest->pParent);\n      if( !pTest ){\n        rc2 = nodeAcquire(pRtree, iNode, 0, &pChild->pParent);\n      }\n    }\n    rc = sqlite3_reset(pRtree->pReadParent);\n    if( rc==SQLITE_OK ) rc = rc2;\n    if( rc==SQLITE_OK && !pChild->pParent ){\n      RTREE_IS_CORRUPT(pRtree);\n      rc = SQLITE_CORRUPT_VTAB;\n    }\n    pChild = pChild->pParent;\n  }\n  return rc;\n}\n\nstatic int deleteCell(Rtree *, RtreeNode *, int, int);\n\nstatic int removeNode(Rtree *pRtree, RtreeNode *pNode, int iHeight){\n  int rc;\n  int rc2;\n  RtreeNode *pParent = 0;\n  int iCell;\n\n  assert( pNode->nRef==1 );\n\n  /* Remove the entry in the parent cell. */\n  rc = nodeParentIndex(pRtree, pNode, &iCell);\n  if( rc==SQLITE_OK ){\n    pParent = pNode->pParent;\n    pNode->pParent = 0;\n    rc = deleteCell(pRtree, pParent, iCell, iHeight+1);\n  }\n  rc2 = nodeRelease(pRtree, pParent);\n  if( rc==SQLITE_OK ){\n    rc = rc2;\n  }\n  if( rc!=SQLITE_OK ){\n    return rc;\n  }\n\n  /* Remove the xxx_node entry. */\n  sqlite3_bind_int64(pRtree->pDeleteNode, 1, pNode->iNode);\n  sqlite3_step(pRtree->pDeleteNode);\n  if( SQLITE_OK!=(rc = sqlite3_reset(pRtree->pDeleteNode)) ){\n    return rc;\n  }\n\n  /* Remove the xxx_parent entry. */\n  sqlite3_bind_int64(pRtree->pDeleteParent, 1, pNode->iNode);\n  sqlite3_step(pRtree->pDeleteParent);\n  if( SQLITE_OK!=(rc = sqlite3_reset(pRtree->pDeleteParent)) ){\n    return rc;\n  }\n  \n  /* Remove the node from the in-memory hash table and link it into\n  ** the Rtree.pDeleted list. Its contents will be re-inserted later on.\n  */\n  nodeHashDelete(pRtree, pNode);\n  pNode->iNode = iHeight;\n  pNode->pNext = pRtree->pDeleted;\n  pNode->nRef++;\n  pRtree->pDeleted = pNode;\n\n  return SQLITE_OK;\n}\n\nstatic int fixBoundingBox(Rtree *pRtree, RtreeNode *pNode){\n  RtreeNode *pParent = pNode->pParent;\n  int rc = SQLITE_OK; \n  if( pParent ){\n    int ii; \n    int nCell = NCELL(pNode);\n    RtreeCell box;                            /* Bounding box for pNode */\n    nodeGetCell(pRtree, pNode, 0, &box);\n    for(ii=1; ii<nCell; ii++){\n      RtreeCell cell;\n      nodeGetCell(pRtree, pNode, ii, &cell);\n      cellUnion(pRtree, &box, &cell);\n    }\n    box.iRowid = pNode->iNode;\n    rc = nodeParentIndex(pRtree, pNode, &ii);\n    if( rc==SQLITE_OK ){\n      nodeOverwriteCell(pRtree, pParent, &box, ii);\n      rc = fixBoundingBox(pRtree, pParent);\n    }\n  }\n  return rc;\n}\n\n/*\n** Delete the cell at index iCell of node pNode. After removing the\n** cell, adjust the r-tree data structure if required.\n*/\nstatic int deleteCell(Rtree *pRtree, RtreeNode *pNode, int iCell, int iHeight){\n  RtreeNode *pParent;\n  int rc;\n\n  if( SQLITE_OK!=(rc = fixLeafParent(pRtree, pNode)) ){\n    return rc;\n  }\n\n  /* Remove the cell from the node. This call just moves bytes around\n  ** the in-memory node image, so it cannot fail.\n  */\n  nodeDeleteCell(pRtree, pNode, iCell);\n\n  /* If the node is not the tree root and now has less than the minimum\n  ** number of cells, remove it from the tree. Otherwise, update the\n  ** cell in the parent node so that it tightly contains the updated\n  ** node.\n  */\n  pParent = pNode->pParent;\n  assert( pParent || pNode->iNode==1 );\n  if( pParent ){\n    if( NCELL(pNode)<RTREE_MINCELLS(pRtree) ){\n      rc = removeNode(pRtree, pNode, iHeight);\n    }else{\n      rc = fixBoundingBox(pRtree, pNode);\n    }\n  }\n\n  return rc;\n}\n\nstatic int Reinsert(\n  Rtree *pRtree, \n  RtreeNode *pNode, \n  RtreeCell *pCell, \n  int iHeight\n){\n  int *aOrder;\n  int *aSpare;\n  RtreeCell *aCell;\n  RtreeDValue *aDistance;\n  int nCell;\n  RtreeDValue aCenterCoord[RTREE_MAX_DIMENSIONS];\n  int iDim;\n  int ii;\n  int rc = SQLITE_OK;\n  int n;\n\n  memset(aCenterCoord, 0, sizeof(RtreeDValue)*RTREE_MAX_DIMENSIONS);\n\n  nCell = NCELL(pNode)+1;\n  n = (nCell+1)&(~1);\n\n  /* Allocate the buffers used by this operation. The allocation is\n  ** relinquished before this function returns.\n  */\n  aCell = (RtreeCell *)sqlite3_malloc64(n * (\n    sizeof(RtreeCell)     +         /* aCell array */\n    sizeof(int)           +         /* aOrder array */\n    sizeof(int)           +         /* aSpare array */\n    sizeof(RtreeDValue)             /* aDistance array */\n  ));\n  if( !aCell ){\n    return SQLITE_NOMEM;\n  }\n  aOrder    = (int *)&aCell[n];\n  aSpare    = (int *)&aOrder[n];\n  aDistance = (RtreeDValue *)&aSpare[n];\n\n  for(ii=0; ii<nCell; ii++){\n    if( ii==(nCell-1) ){\n      memcpy(&aCell[ii], pCell, sizeof(RtreeCell));\n    }else{\n      nodeGetCell(pRtree, pNode, ii, &aCell[ii]);\n    }\n    aOrder[ii] = ii;\n    for(iDim=0; iDim<pRtree->nDim; iDim++){\n      aCenterCoord[iDim] += DCOORD(aCell[ii].aCoord[iDim*2]);\n      aCenterCoord[iDim] += DCOORD(aCell[ii].aCoord[iDim*2+1]);\n    }\n  }\n  for(iDim=0; iDim<pRtree->nDim; iDim++){\n    aCenterCoord[iDim] = (aCenterCoord[iDim]/(nCell*(RtreeDValue)2));\n  }\n\n  for(ii=0; ii<nCell; ii++){\n    aDistance[ii] = RTREE_ZERO;\n    for(iDim=0; iDim<pRtree->nDim; iDim++){\n      RtreeDValue coord = (DCOORD(aCell[ii].aCoord[iDim*2+1]) - \n                               DCOORD(aCell[ii].aCoord[iDim*2]));\n      aDistance[ii] += (coord-aCenterCoord[iDim])*(coord-aCenterCoord[iDim]);\n    }\n  }\n\n  SortByDistance(aOrder, nCell, aDistance, aSpare);\n  nodeZero(pRtree, pNode);\n\n  for(ii=0; rc==SQLITE_OK && ii<(nCell-(RTREE_MINCELLS(pRtree)+1)); ii++){\n    RtreeCell *p = &aCell[aOrder[ii]];\n    nodeInsertCell(pRtree, pNode, p);\n    if( p->iRowid==pCell->iRowid ){\n      if( iHeight==0 ){\n        rc = rowidWrite(pRtree, p->iRowid, pNode->iNode);\n      }else{\n        rc = parentWrite(pRtree, p->iRowid, pNode->iNode);\n      }\n    }\n  }\n  if( rc==SQLITE_OK ){\n    rc = fixBoundingBox(pRtree, pNode);\n  }\n  for(; rc==SQLITE_OK && ii<nCell; ii++){\n    /* Find a node to store this cell in. pNode->iNode currently contains\n    ** the height of the sub-tree headed by the cell.\n    */\n    RtreeNode *pInsert;\n    RtreeCell *p = &aCell[aOrder[ii]];\n    rc = ChooseLeaf(pRtree, p, iHeight, &pInsert);\n    if( rc==SQLITE_OK ){\n      int rc2;\n      rc = rtreeInsertCell(pRtree, pInsert, p, iHeight);\n      rc2 = nodeRelease(pRtree, pInsert);\n      if( rc==SQLITE_OK ){\n        rc = rc2;\n      }\n    }\n  }\n\n  sqlite3_free(aCell);\n  return rc;\n}\n\n/*\n** Insert cell pCell into node pNode. Node pNode is the head of a \n** subtree iHeight high (leaf nodes have iHeight==0).\n*/\nstatic int rtreeInsertCell(\n  Rtree *pRtree,\n  RtreeNode *pNode,\n  RtreeCell *pCell,\n  int iHeight\n){\n  int rc = SQLITE_OK;\n  if( iHeight>0 ){\n    RtreeNode *pChild = nodeHashLookup(pRtree, pCell->iRowid);\n    if( pChild ){\n      nodeRelease(pRtree, pChild->pParent);\n      nodeReference(pNode);\n      pChild->pParent = pNode;\n    }\n  }\n  if( nodeInsertCell(pRtree, pNode, pCell) ){\n    if( iHeight<=pRtree->iReinsertHeight || pNode->iNode==1){\n      rc = SplitNode(pRtree, pNode, pCell, iHeight);\n    }else{\n      pRtree->iReinsertHeight = iHeight;\n      rc = Reinsert(pRtree, pNode, pCell, iHeight);\n    }\n  }else{\n    rc = AdjustTree(pRtree, pNode, pCell);\n    if( rc==SQLITE_OK ){\n      if( iHeight==0 ){\n        rc = rowidWrite(pRtree, pCell->iRowid, pNode->iNode);\n      }else{\n        rc = parentWrite(pRtree, pCell->iRowid, pNode->iNode);\n      }\n    }\n  }\n  return rc;\n}\n\nstatic int reinsertNodeContent(Rtree *pRtree, RtreeNode *pNode){\n  int ii;\n  int rc = SQLITE_OK;\n  int nCell = NCELL(pNode);\n\n  for(ii=0; rc==SQLITE_OK && ii<nCell; ii++){\n    RtreeNode *pInsert;\n    RtreeCell cell;\n    nodeGetCell(pRtree, pNode, ii, &cell);\n\n    /* Find a node to store this cell in. pNode->iNode currently contains\n    ** the height of the sub-tree headed by the cell.\n    */\n    rc = ChooseLeaf(pRtree, &cell, (int)pNode->iNode, &pInsert);\n    if( rc==SQLITE_OK ){\n      int rc2;\n      rc = rtreeInsertCell(pRtree, pInsert, &cell, (int)pNode->iNode);\n      rc2 = nodeRelease(pRtree, pInsert);\n      if( rc==SQLITE_OK ){\n        rc = rc2;\n      }\n    }\n  }\n  return rc;\n}\n\n/*\n** Select a currently unused rowid for a new r-tree record.\n*/\nstatic int rtreeNewRowid(Rtree *pRtree, i64 *piRowid){\n  int rc;\n  sqlite3_bind_null(pRtree->pWriteRowid, 1);\n  sqlite3_bind_null(pRtree->pWriteRowid, 2);\n  sqlite3_step(pRtree->pWriteRowid);\n  rc = sqlite3_reset(pRtree->pWriteRowid);\n  *piRowid = sqlite3_last_insert_rowid(pRtree->db);\n  return rc;\n}\n\n/*\n** Remove the entry with rowid=iDelete from the r-tree structure.\n*/\nstatic int rtreeDeleteRowid(Rtree *pRtree, sqlite3_int64 iDelete){\n  int rc;                         /* Return code */\n  RtreeNode *pLeaf = 0;           /* Leaf node containing record iDelete */\n  int iCell;                      /* Index of iDelete cell in pLeaf */\n  RtreeNode *pRoot = 0;           /* Root node of rtree structure */\n\n\n  /* Obtain a reference to the root node to initialize Rtree.iDepth */\n  rc = nodeAcquire(pRtree, 1, 0, &pRoot);\n\n  /* Obtain a reference to the leaf node that contains the entry \n  ** about to be deleted. \n  */\n  if( rc==SQLITE_OK ){\n    rc = findLeafNode(pRtree, iDelete, &pLeaf, 0);\n  }\n\n#ifdef CORRUPT_DB\n  assert( pLeaf!=0 || rc!=SQLITE_OK || CORRUPT_DB );\n#endif\n\n  /* Delete the cell in question from the leaf node. */\n  if( rc==SQLITE_OK && pLeaf ){\n    int rc2;\n    rc = nodeRowidIndex(pRtree, pLeaf, iDelete, &iCell);\n    if( rc==SQLITE_OK ){\n      rc = deleteCell(pRtree, pLeaf, iCell, 0);\n    }\n    rc2 = nodeRelease(pRtree, pLeaf);\n    if( rc==SQLITE_OK ){\n      rc = rc2;\n    }\n  }\n\n  /* Delete the corresponding entry in the <rtree>_rowid table. */\n  if( rc==SQLITE_OK ){\n    sqlite3_bind_int64(pRtree->pDeleteRowid, 1, iDelete);\n    sqlite3_step(pRtree->pDeleteRowid);\n    rc = sqlite3_reset(pRtree->pDeleteRowid);\n  }\n\n  /* Check if the root node now has exactly one child. If so, remove\n  ** it, schedule the contents of the child for reinsertion and \n  ** reduce the tree height by one.\n  **\n  ** This is equivalent to copying the contents of the child into\n  ** the root node (the operation that Gutman's paper says to perform \n  ** in this scenario).\n  */\n  if( rc==SQLITE_OK && pRtree->iDepth>0 && NCELL(pRoot)==1 ){\n    int rc2;\n    RtreeNode *pChild = 0;\n    i64 iChild = nodeGetRowid(pRtree, pRoot, 0);\n    rc = nodeAcquire(pRtree, iChild, pRoot, &pChild);\n    if( rc==SQLITE_OK ){\n      rc = removeNode(pRtree, pChild, pRtree->iDepth-1);\n    }\n    rc2 = nodeRelease(pRtree, pChild);\n    if( rc==SQLITE_OK ) rc = rc2;\n    if( rc==SQLITE_OK ){\n      pRtree->iDepth--;\n      writeInt16(pRoot->zData, pRtree->iDepth);\n      pRoot->isDirty = 1;\n    }\n  }\n\n  /* Re-insert the contents of any underfull nodes removed from the tree. */\n  for(pLeaf=pRtree->pDeleted; pLeaf; pLeaf=pRtree->pDeleted){\n    if( rc==SQLITE_OK ){\n      rc = reinsertNodeContent(pRtree, pLeaf);\n    }\n    pRtree->pDeleted = pLeaf->pNext;\n    pRtree->nNodeRef--;\n    sqlite3_free(pLeaf);\n  }\n\n  /* Release the reference to the root node. */\n  if( rc==SQLITE_OK ){\n    rc = nodeRelease(pRtree, pRoot);\n  }else{\n    nodeRelease(pRtree, pRoot);\n  }\n\n  return rc;\n}\n\n/*\n** Rounding constants for float->double conversion.\n*/\n#define RNDTOWARDS  (1.0 - 1.0/8388608.0)  /* Round towards zero */\n#define RNDAWAY     (1.0 + 1.0/8388608.0)  /* Round away from zero */\n\n#if !defined(SQLITE_RTREE_INT_ONLY)\n/*\n** Convert an sqlite3_value into an RtreeValue (presumably a float)\n** while taking care to round toward negative or positive, respectively.\n*/\nstatic RtreeValue rtreeValueDown(sqlite3_value *v){\n  double d = sqlite3_value_double(v);\n  float f = (float)d;\n  if( f>d ){\n    f = (float)(d*(d<0 ? RNDAWAY : RNDTOWARDS));\n  }\n  return f;\n}\nstatic RtreeValue rtreeValueUp(sqlite3_value *v){\n  double d = sqlite3_value_double(v);\n  float f = (float)d;\n  if( f<d ){\n    f = (float)(d*(d<0 ? RNDTOWARDS : RNDAWAY));\n  }\n  return f;\n}\n#endif /* !defined(SQLITE_RTREE_INT_ONLY) */\n\n/*\n** A constraint has failed while inserting a row into an rtree table. \n** Assuming no OOM error occurs, this function sets the error message \n** (at pRtree->base.zErrMsg) to an appropriate value and returns\n** SQLITE_CONSTRAINT.\n**\n** Parameter iCol is the index of the leftmost column involved in the\n** constraint failure. If it is 0, then the constraint that failed is\n** the unique constraint on the id column. Otherwise, it is the rtree\n** (c1<=c2) constraint on columns iCol and iCol+1 that has failed.\n**\n** If an OOM occurs, SQLITE_NOMEM is returned instead of SQLITE_CONSTRAINT.\n*/\nstatic int rtreeConstraintError(Rtree *pRtree, int iCol){\n  sqlite3_stmt *pStmt = 0;\n  char *zSql; \n  int rc;\n\n  assert( iCol==0 || iCol%2 );\n  zSql = sqlite3_mprintf(\"SELECT * FROM %Q.%Q\", pRtree->zDb, pRtree->zName);\n  if( zSql ){\n    rc = sqlite3_prepare_v2(pRtree->db, zSql, -1, &pStmt, 0);\n  }else{\n    rc = SQLITE_NOMEM;\n  }\n  sqlite3_free(zSql);\n\n  if( rc==SQLITE_OK ){\n    if( iCol==0 ){\n      const char *zCol = sqlite3_column_name(pStmt, 0);\n      pRtree->base.zErrMsg = sqlite3_mprintf(\n          \"UNIQUE constraint failed: %s.%s\", pRtree->zName, zCol\n      );\n    }else{\n      const char *zCol1 = sqlite3_column_name(pStmt, iCol);\n      const char *zCol2 = sqlite3_column_name(pStmt, iCol+1);\n      pRtree->base.zErrMsg = sqlite3_mprintf(\n          \"rtree constraint failed: %s.(%s<=%s)\", pRtree->zName, zCol1, zCol2\n      );\n    }\n  }\n\n  sqlite3_finalize(pStmt);\n  return (rc==SQLITE_OK ? SQLITE_CONSTRAINT : rc);\n}\n\n\n\n/*\n** The xUpdate method for rtree module virtual tables.\n*/\nstatic int rtreeUpdate(\n  sqlite3_vtab *pVtab, \n  int nData, \n  sqlite3_value **aData, \n  sqlite_int64 *pRowid\n){\n  Rtree *pRtree = (Rtree *)pVtab;\n  int rc = SQLITE_OK;\n  RtreeCell cell;                 /* New cell to insert if nData>1 */\n  int bHaveRowid = 0;             /* Set to 1 after new rowid is determined */\n\n  if( pRtree->nNodeRef ){\n    /* Unable to write to the btree while another cursor is reading from it,\n    ** since the write might do a rebalance which would disrupt the read\n    ** cursor. */\n    return SQLITE_LOCKED_VTAB;\n  }\n  rtreeReference(pRtree);\n  assert(nData>=1);\n\n  cell.iRowid = 0;  /* Used only to suppress a compiler warning */\n\n  /* Constraint handling. A write operation on an r-tree table may return\n  ** SQLITE_CONSTRAINT for two reasons:\n  **\n  **   1. A duplicate rowid value, or\n  **   2. The supplied data violates the \"x2>=x1\" constraint.\n  **\n  ** In the first case, if the conflict-handling mode is REPLACE, then\n  ** the conflicting row can be removed before proceeding. In the second\n  ** case, SQLITE_CONSTRAINT must be returned regardless of the\n  ** conflict-handling mode specified by the user.\n  */\n  if( nData>1 ){\n    int ii;\n    int nn = nData - 4;\n\n    if( nn > pRtree->nDim2 ) nn = pRtree->nDim2;\n    /* Populate the cell.aCoord[] array. The first coordinate is aData[3].\n    **\n    ** NB: nData can only be less than nDim*2+3 if the rtree is mis-declared\n    ** with \"column\" that are interpreted as table constraints.\n    ** Example:  CREATE VIRTUAL TABLE bad USING rtree(x,y,CHECK(y>5));\n    ** This problem was discovered after years of use, so we silently ignore\n    ** these kinds of misdeclared tables to avoid breaking any legacy.\n    */\n\n#ifndef SQLITE_RTREE_INT_ONLY\n    if( pRtree->eCoordType==RTREE_COORD_REAL32 ){\n      for(ii=0; ii<nn; ii+=2){\n        cell.aCoord[ii].f = rtreeValueDown(aData[ii+3]);\n        cell.aCoord[ii+1].f = rtreeValueUp(aData[ii+4]);\n        if( cell.aCoord[ii].f>cell.aCoord[ii+1].f ){\n          rc = rtreeConstraintError(pRtree, ii+1);\n          goto constraint;\n        }\n      }\n    }else\n#endif\n    {\n      for(ii=0; ii<nn; ii+=2){\n        cell.aCoord[ii].i = sqlite3_value_int(aData[ii+3]);\n        cell.aCoord[ii+1].i = sqlite3_value_int(aData[ii+4]);\n        if( cell.aCoord[ii].i>cell.aCoord[ii+1].i ){\n          rc = rtreeConstraintError(pRtree, ii+1);\n          goto constraint;\n        }\n      }\n    }\n\n    /* If a rowid value was supplied, check if it is already present in \n    ** the table. If so, the constraint has failed. */\n    if( sqlite3_value_type(aData[2])!=SQLITE_NULL ){\n      cell.iRowid = sqlite3_value_int64(aData[2]);\n      if( sqlite3_value_type(aData[0])==SQLITE_NULL\n       || sqlite3_value_int64(aData[0])!=cell.iRowid\n      ){\n        int steprc;\n        sqlite3_bind_int64(pRtree->pReadRowid, 1, cell.iRowid);\n        steprc = sqlite3_step(pRtree->pReadRowid);\n        rc = sqlite3_reset(pRtree->pReadRowid);\n        if( SQLITE_ROW==steprc ){\n          if( sqlite3_vtab_on_conflict(pRtree->db)==SQLITE_REPLACE ){\n            rc = rtreeDeleteRowid(pRtree, cell.iRowid);\n          }else{\n            rc = rtreeConstraintError(pRtree, 0);\n            goto constraint;\n          }\n        }\n      }\n      bHaveRowid = 1;\n    }\n  }\n\n  /* If aData[0] is not an SQL NULL value, it is the rowid of a\n  ** record to delete from the r-tree table. The following block does\n  ** just that.\n  */\n  if( sqlite3_value_type(aData[0])!=SQLITE_NULL ){\n    rc = rtreeDeleteRowid(pRtree, sqlite3_value_int64(aData[0]));\n  }\n\n  /* If the aData[] array contains more than one element, elements\n  ** (aData[2]..aData[argc-1]) contain a new record to insert into\n  ** the r-tree structure.\n  */\n  if( rc==SQLITE_OK && nData>1 ){\n    /* Insert the new record into the r-tree */\n    RtreeNode *pLeaf = 0;\n\n    /* Figure out the rowid of the new row. */\n    if( bHaveRowid==0 ){\n      rc = rtreeNewRowid(pRtree, &cell.iRowid);\n    }\n    *pRowid = cell.iRowid;\n\n    if( rc==SQLITE_OK ){\n      rc = ChooseLeaf(pRtree, &cell, 0, &pLeaf);\n    }\n    if( rc==SQLITE_OK ){\n      int rc2;\n      pRtree->iReinsertHeight = -1;\n      rc = rtreeInsertCell(pRtree, pLeaf, &cell, 0);\n      rc2 = nodeRelease(pRtree, pLeaf);\n      if( rc==SQLITE_OK ){\n        rc = rc2;\n      }\n    }\n    if( rc==SQLITE_OK && pRtree->nAux ){\n      sqlite3_stmt *pUp = pRtree->pWriteAux;\n      int jj;\n      sqlite3_bind_int64(pUp, 1, *pRowid);\n      for(jj=0; jj<pRtree->nAux; jj++){\n        sqlite3_bind_value(pUp, jj+2, aData[pRtree->nDim2+3+jj]);\n      }\n      sqlite3_step(pUp);\n      rc = sqlite3_reset(pUp);\n    }\n  }\n\nconstraint:\n  rtreeRelease(pRtree);\n  return rc;\n}\n\n/*\n** Called when a transaction starts.\n*/\nstatic int rtreeBeginTransaction(sqlite3_vtab *pVtab){\n  Rtree *pRtree = (Rtree *)pVtab;\n  assert( pRtree->inWrTrans==0 );\n  pRtree->inWrTrans++;\n  return SQLITE_OK;\n}\n\n/*\n** Called when a transaction completes (either by COMMIT or ROLLBACK).\n** The sqlite3_blob object should be released at this point.\n*/\nstatic int rtreeEndTransaction(sqlite3_vtab *pVtab){\n  Rtree *pRtree = (Rtree *)pVtab;\n  pRtree->inWrTrans = 0;\n  nodeBlobReset(pRtree);\n  return SQLITE_OK;\n}\n\n/*\n** The xRename method for rtree module virtual tables.\n*/\nstatic int rtreeRename(sqlite3_vtab *pVtab, const char *zNewName){\n  Rtree *pRtree = (Rtree *)pVtab;\n  int rc = SQLITE_NOMEM;\n  char *zSql = sqlite3_mprintf(\n    \"ALTER TABLE %Q.'%q_node'   RENAME TO \\\"%w_node\\\";\"\n    \"ALTER TABLE %Q.'%q_parent' RENAME TO \\\"%w_parent\\\";\"\n    \"ALTER TABLE %Q.'%q_rowid'  RENAME TO \\\"%w_rowid\\\";\"\n    , pRtree->zDb, pRtree->zName, zNewName \n    , pRtree->zDb, pRtree->zName, zNewName \n    , pRtree->zDb, pRtree->zName, zNewName\n  );\n  if( zSql ){\n    nodeBlobReset(pRtree);\n    rc = sqlite3_exec(pRtree->db, zSql, 0, 0, 0);\n    sqlite3_free(zSql);\n  }\n  return rc;\n}\n\n/*\n** The xSavepoint method.\n**\n** This module does not need to do anything to support savepoints. However,\n** it uses this hook to close any open blob handle. This is done because a \n** DROP TABLE command - which fortunately always opens a savepoint - cannot \n** succeed if there are any open blob handles. i.e. if the blob handle were\n** not closed here, the following would fail:\n**\n**   BEGIN;\n**     INSERT INTO rtree...\n**     DROP TABLE <tablename>;    -- Would fail with SQLITE_LOCKED\n**   COMMIT;\n*/\nstatic int rtreeSavepoint(sqlite3_vtab *pVtab, int iSavepoint){\n  Rtree *pRtree = (Rtree *)pVtab;\n  u8 iwt = pRtree->inWrTrans;\n  UNUSED_PARAMETER(iSavepoint);\n  pRtree->inWrTrans = 0;\n  nodeBlobReset(pRtree);\n  pRtree->inWrTrans = iwt;\n  return SQLITE_OK;\n}\n\n/*\n** This function populates the pRtree->nRowEst variable with an estimate\n** of the number of rows in the virtual table. If possible, this is based\n** on sqlite_stat1 data. Otherwise, use RTREE_DEFAULT_ROWEST.\n*/\nstatic int rtreeQueryStat1(sqlite3 *db, Rtree *pRtree){\n  const char *zFmt = \"SELECT stat FROM %Q.sqlite_stat1 WHERE tbl = '%q_rowid'\";\n  char *zSql;\n  sqlite3_stmt *p;\n  int rc;\n  i64 nRow = 0;\n\n  rc = sqlite3_table_column_metadata(\n      db, pRtree->zDb, \"sqlite_stat1\",0,0,0,0,0,0\n  );\n  if( rc!=SQLITE_OK ){\n    pRtree->nRowEst = RTREE_DEFAULT_ROWEST;\n    return rc==SQLITE_ERROR ? SQLITE_OK : rc;\n  }\n  zSql = sqlite3_mprintf(zFmt, pRtree->zDb, pRtree->zName);\n  if( zSql==0 ){\n    rc = SQLITE_NOMEM;\n  }else{\n    rc = sqlite3_prepare_v2(db, zSql, -1, &p, 0);\n    if( rc==SQLITE_OK ){\n      if( sqlite3_step(p)==SQLITE_ROW ) nRow = sqlite3_column_int64(p, 0);\n      rc = sqlite3_finalize(p);\n    }else if( rc!=SQLITE_NOMEM ){\n      rc = SQLITE_OK;\n    }\n\n    if( rc==SQLITE_OK ){\n      if( nRow==0 ){\n        pRtree->nRowEst = RTREE_DEFAULT_ROWEST;\n      }else{\n        pRtree->nRowEst = MAX(nRow, RTREE_MIN_ROWEST);\n      }\n    }\n    sqlite3_free(zSql);\n  }\n\n  return rc;\n}\n\n\n/*\n** Return true if zName is the extension on one of the shadow tables used\n** by this module.\n*/\nstatic int rtreeShadowName(const char *zName){\n  static const char *azName[] = {\n    \"node\", \"parent\", \"rowid\"\n  };\n  unsigned int i;\n  for(i=0; i<sizeof(azName)/sizeof(azName[0]); i++){\n    if( sqlite3_stricmp(zName, azName[i])==0 ) return 1;\n  }\n  return 0;\n}\n\nstatic sqlite3_module rtreeModule = {\n  3,                          /* iVersion */\n  rtreeCreate,                /* xCreate - create a table */\n  rtreeConnect,               /* xConnect - connect to an existing table */\n  rtreeBestIndex,             /* xBestIndex - Determine search strategy */\n  rtreeDisconnect,            /* xDisconnect - Disconnect from a table */\n  rtreeDestroy,               /* xDestroy - Drop a table */\n  rtreeOpen,                  /* xOpen - open a cursor */\n  rtreeClose,                 /* xClose - close a cursor */\n  rtreeFilter,                /* xFilter - configure scan constraints */\n  rtreeNext,                  /* xNext - advance a cursor */\n  rtreeEof,                   /* xEof */\n  rtreeColumn,                /* xColumn - read data */\n  rtreeRowid,                 /* xRowid - read data */\n  rtreeUpdate,                /* xUpdate - write data */\n  rtreeBeginTransaction,      /* xBegin - begin transaction */\n  rtreeEndTransaction,        /* xSync - sync transaction */\n  rtreeEndTransaction,        /* xCommit - commit transaction */\n  rtreeEndTransaction,        /* xRollback - rollback transaction */\n  0,                          /* xFindFunction - function overloading */\n  rtreeRename,                /* xRename - rename the table */\n  rtreeSavepoint,             /* xSavepoint */\n  0,                          /* xRelease */\n  0,                          /* xRollbackTo */\n  rtreeShadowName             /* xShadowName */\n};\n\nstatic int rtreeSqlInit(\n  Rtree *pRtree, \n  sqlite3 *db, \n  const char *zDb, \n  const char *zPrefix, \n  int isCreate\n){\n  int rc = SQLITE_OK;\n\n  #define N_STATEMENT 8\n  static const char *azSql[N_STATEMENT] = {\n    /* Write the xxx_node table */\n    \"INSERT OR REPLACE INTO '%q'.'%q_node' VALUES(?1, ?2)\",\n    \"DELETE FROM '%q'.'%q_node' WHERE nodeno = ?1\",\n\n    /* Read and write the xxx_rowid table */\n    \"SELECT nodeno FROM '%q'.'%q_rowid' WHERE rowid = ?1\",\n    \"INSERT OR REPLACE INTO '%q'.'%q_rowid' VALUES(?1, ?2)\",\n    \"DELETE FROM '%q'.'%q_rowid' WHERE rowid = ?1\",\n\n    /* Read and write the xxx_parent table */\n    \"SELECT parentnode FROM '%q'.'%q_parent' WHERE nodeno = ?1\",\n    \"INSERT OR REPLACE INTO '%q'.'%q_parent' VALUES(?1, ?2)\",\n    \"DELETE FROM '%q'.'%q_parent' WHERE nodeno = ?1\"\n  };\n  sqlite3_stmt **appStmt[N_STATEMENT];\n  int i;\n  const int f = SQLITE_PREPARE_PERSISTENT|SQLITE_PREPARE_NO_VTAB;\n\n  pRtree->db = db;\n\n  if( isCreate ){\n    char *zCreate;\n    sqlite3_str *p = sqlite3_str_new(db);\n    int ii;\n    sqlite3_str_appendf(p,\n       \"CREATE TABLE \\\"%w\\\".\\\"%w_rowid\\\"(rowid INTEGER PRIMARY KEY,nodeno\",\n       zDb, zPrefix);\n    for(ii=0; ii<pRtree->nAux; ii++){\n      sqlite3_str_appendf(p,\",a%d\",ii);\n    }\n    sqlite3_str_appendf(p,\n      \");CREATE TABLE \\\"%w\\\".\\\"%w_node\\\"(nodeno INTEGER PRIMARY KEY,data);\",\n      zDb, zPrefix);\n    sqlite3_str_appendf(p,\n    \"CREATE TABLE \\\"%w\\\".\\\"%w_parent\\\"(nodeno INTEGER PRIMARY KEY,parentnode);\",\n      zDb, zPrefix);\n    sqlite3_str_appendf(p,\n       \"INSERT INTO \\\"%w\\\".\\\"%w_node\\\"VALUES(1,zeroblob(%d))\",\n       zDb, zPrefix, pRtree->iNodeSize);\n    zCreate = sqlite3_str_finish(p);\n    if( !zCreate ){\n      return SQLITE_NOMEM;\n    }\n    rc = sqlite3_exec(db, zCreate, 0, 0, 0);\n    sqlite3_free(zCreate);\n    if( rc!=SQLITE_OK ){\n      return rc;\n    }\n  }\n\n  appStmt[0] = &pRtree->pWriteNode;\n  appStmt[1] = &pRtree->pDeleteNode;\n  appStmt[2] = &pRtree->pReadRowid;\n  appStmt[3] = &pRtree->pWriteRowid;\n  appStmt[4] = &pRtree->pDeleteRowid;\n  appStmt[5] = &pRtree->pReadParent;\n  appStmt[6] = &pRtree->pWriteParent;\n  appStmt[7] = &pRtree->pDeleteParent;\n\n  rc = rtreeQueryStat1(db, pRtree);\n  for(i=0; i<N_STATEMENT && rc==SQLITE_OK; i++){\n    char *zSql;\n    const char *zFormat;\n    if( i!=3 || pRtree->nAux==0 ){\n       zFormat = azSql[i];\n    }else {\n       /* An UPSERT is very slightly slower than REPLACE, but it is needed\n       ** if there are auxiliary columns */\n       zFormat = \"INSERT INTO\\\"%w\\\".\\\"%w_rowid\\\"(rowid,nodeno)VALUES(?1,?2)\"\n                  \"ON CONFLICT(rowid)DO UPDATE SET nodeno=excluded.nodeno\";\n    }\n    zSql = sqlite3_mprintf(zFormat, zDb, zPrefix);\n    if( zSql ){\n      rc = sqlite3_prepare_v3(db, zSql, -1, f, appStmt[i], 0); \n    }else{\n      rc = SQLITE_NOMEM;\n    }\n    sqlite3_free(zSql);\n  }\n  if( pRtree->nAux ){\n    pRtree->zReadAuxSql = sqlite3_mprintf(\n       \"SELECT * FROM \\\"%w\\\".\\\"%w_rowid\\\" WHERE rowid=?1\",\n       zDb, zPrefix);\n    if( pRtree->zReadAuxSql==0 ){\n      rc = SQLITE_NOMEM;\n    }else{\n      sqlite3_str *p = sqlite3_str_new(db);\n      int ii;\n      char *zSql;\n      sqlite3_str_appendf(p, \"UPDATE \\\"%w\\\".\\\"%w_rowid\\\"SET \", zDb, zPrefix);\n      for(ii=0; ii<pRtree->nAux; ii++){\n        if( ii ) sqlite3_str_append(p, \",\", 1);\n        if( ii<pRtree->nAuxNotNull ){\n          sqlite3_str_appendf(p,\"a%d=coalesce(?%d,a%d)\",ii,ii+2,ii);\n        }else{\n          sqlite3_str_appendf(p,\"a%d=?%d\",ii,ii+2);\n        }\n      }\n      sqlite3_str_appendf(p, \" WHERE rowid=?1\");\n      zSql = sqlite3_str_finish(p);\n      if( zSql==0 ){\n        rc = SQLITE_NOMEM;\n      }else{\n        rc = sqlite3_prepare_v3(db, zSql, -1, f, &pRtree->pWriteAux, 0); \n        sqlite3_free(zSql);\n      }\n    }\n  }\n\n  return rc;\n}\n\n/*\n** The second argument to this function contains the text of an SQL statement\n** that returns a single integer value. The statement is compiled and executed\n** using database connection db. If successful, the integer value returned\n** is written to *piVal and SQLITE_OK returned. Otherwise, an SQLite error\n** code is returned and the value of *piVal after returning is not defined.\n*/\nstatic int getIntFromStmt(sqlite3 *db, const char *zSql, int *piVal){\n  int rc = SQLITE_NOMEM;\n  if( zSql ){\n    sqlite3_stmt *pStmt = 0;\n    rc = sqlite3_prepare_v2(db, zSql, -1, &pStmt, 0);\n    if( rc==SQLITE_OK ){\n      if( SQLITE_ROW==sqlite3_step(pStmt) ){\n        *piVal = sqlite3_column_int(pStmt, 0);\n      }\n      rc = sqlite3_finalize(pStmt);\n    }\n  }\n  return rc;\n}\n\n/*\n** This function is called from within the xConnect() or xCreate() method to\n** determine the node-size used by the rtree table being created or connected\n** to. If successful, pRtree->iNodeSize is populated and SQLITE_OK returned.\n** Otherwise, an SQLite error code is returned.\n**\n** If this function is being called as part of an xConnect(), then the rtree\n** table already exists. In this case the node-size is determined by inspecting\n** the root node of the tree.\n**\n** Otherwise, for an xCreate(), use 64 bytes less than the database page-size. \n** This ensures that each node is stored on a single database page. If the \n** database page-size is so large that more than RTREE_MAXCELLS entries \n** would fit in a single node, use a smaller node-size.\n*/\nstatic int getNodeSize(\n  sqlite3 *db,                    /* Database handle */\n  Rtree *pRtree,                  /* Rtree handle */\n  int isCreate,                   /* True for xCreate, false for xConnect */\n  char **pzErr                    /* OUT: Error message, if any */\n){\n  int rc;\n  char *zSql;\n  if( isCreate ){\n    int iPageSize = 0;\n    zSql = sqlite3_mprintf(\"PRAGMA %Q.page_size\", pRtree->zDb);\n    rc = getIntFromStmt(db, zSql, &iPageSize);\n    if( rc==SQLITE_OK ){\n      pRtree->iNodeSize = iPageSize-64;\n      if( (4+pRtree->nBytesPerCell*RTREE_MAXCELLS)<pRtree->iNodeSize ){\n        pRtree->iNodeSize = 4+pRtree->nBytesPerCell*RTREE_MAXCELLS;\n      }\n    }else{\n      *pzErr = sqlite3_mprintf(\"%s\", sqlite3_errmsg(db));\n    }\n  }else{\n    zSql = sqlite3_mprintf(\n        \"SELECT length(data) FROM '%q'.'%q_node' WHERE nodeno = 1\",\n        pRtree->zDb, pRtree->zName\n    );\n    rc = getIntFromStmt(db, zSql, &pRtree->iNodeSize);\n    if( rc!=SQLITE_OK ){\n      *pzErr = sqlite3_mprintf(\"%s\", sqlite3_errmsg(db));\n    }else if( pRtree->iNodeSize<(512-64) ){\n      rc = SQLITE_CORRUPT_VTAB;\n      RTREE_IS_CORRUPT(pRtree);\n      *pzErr = sqlite3_mprintf(\"undersize RTree blobs in \\\"%q_node\\\"\",\n                               pRtree->zName);\n    }\n  }\n\n  sqlite3_free(zSql);\n  return rc;\n}\n\n/* \n** This function is the implementation of both the xConnect and xCreate\n** methods of the r-tree virtual table.\n**\n**   argv[0]   -> module name\n**   argv[1]   -> database name\n**   argv[2]   -> table name\n**   argv[...] -> column names...\n*/\nstatic int rtreeInit(\n  sqlite3 *db,                        /* Database connection */\n  void *pAux,                         /* One of the RTREE_COORD_* constants */\n  int argc, const char *const*argv,   /* Parameters to CREATE TABLE statement */\n  sqlite3_vtab **ppVtab,              /* OUT: New virtual table */\n  char **pzErr,                       /* OUT: Error message, if any */\n  int isCreate                        /* True for xCreate, false for xConnect */\n){\n  int rc = SQLITE_OK;\n  Rtree *pRtree;\n  int nDb;              /* Length of string argv[1] */\n  int nName;            /* Length of string argv[2] */\n  int eCoordType = (pAux ? RTREE_COORD_INT32 : RTREE_COORD_REAL32);\n  sqlite3_str *pSql;\n  char *zSql;\n  int ii = 4;\n  int iErr;\n\n  const char *aErrMsg[] = {\n    0,                                                    /* 0 */\n    \"Wrong number of columns for an rtree table\",         /* 1 */\n    \"Too few columns for an rtree table\",                 /* 2 */\n    \"Too many columns for an rtree table\",                /* 3 */\n    \"Auxiliary rtree columns must be last\"                /* 4 */\n  };\n\n  assert( RTREE_MAX_AUX_COLUMN<256 ); /* Aux columns counted by a u8 */\n  if( argc>RTREE_MAX_AUX_COLUMN+3 ){\n    *pzErr = sqlite3_mprintf(\"%s\", aErrMsg[3]);\n    return SQLITE_ERROR;\n  }\n\n  sqlite3_vtab_config(db, SQLITE_VTAB_CONSTRAINT_SUPPORT, 1);\n\n  /* Allocate the sqlite3_vtab structure */\n  nDb = (int)strlen(argv[1]);\n  nName = (int)strlen(argv[2]);\n  pRtree = (Rtree *)sqlite3_malloc64(sizeof(Rtree)+nDb+nName+2);\n  if( !pRtree ){\n    return SQLITE_NOMEM;\n  }\n  memset(pRtree, 0, sizeof(Rtree)+nDb+nName+2);\n  pRtree->nBusy = 1;\n  pRtree->base.pModule = &rtreeModule;\n  pRtree->zDb = (char *)&pRtree[1];\n  pRtree->zName = &pRtree->zDb[nDb+1];\n  pRtree->eCoordType = (u8)eCoordType;\n  memcpy(pRtree->zDb, argv[1], nDb);\n  memcpy(pRtree->zName, argv[2], nName);\n\n\n  /* Create/Connect to the underlying relational database schema. If\n  ** that is successful, call sqlite3_declare_vtab() to configure\n  ** the r-tree table schema.\n  */\n  pSql = sqlite3_str_new(db);\n  sqlite3_str_appendf(pSql, \"CREATE TABLE x(%s\", argv[3]);\n  for(ii=4; ii<argc; ii++){\n    if( argv[ii][0]=='+' ){\n      pRtree->nAux++;\n      sqlite3_str_appendf(pSql, \",%s\", argv[ii]+1);\n    }else if( pRtree->nAux>0 ){\n      break;\n    }else{\n      pRtree->nDim2++;\n      sqlite3_str_appendf(pSql, \",%s\", argv[ii]);\n    }\n  }\n  sqlite3_str_appendf(pSql, \");\");\n  zSql = sqlite3_str_finish(pSql);\n  if( !zSql ){\n    rc = SQLITE_NOMEM;\n  }else if( ii<argc ){\n    *pzErr = sqlite3_mprintf(\"%s\", aErrMsg[4]);\n    rc = SQLITE_ERROR;\n  }else if( SQLITE_OK!=(rc = sqlite3_declare_vtab(db, zSql)) ){\n    *pzErr = sqlite3_mprintf(\"%s\", sqlite3_errmsg(db));\n  }\n  sqlite3_free(zSql);\n  if( rc ) goto rtreeInit_fail;\n  pRtree->nDim = pRtree->nDim2/2;\n  if( pRtree->nDim<1 ){\n    iErr = 2;\n  }else if( pRtree->nDim2>RTREE_MAX_DIMENSIONS*2 ){\n    iErr = 3;\n  }else if( pRtree->nDim2 % 2 ){\n    iErr = 1;\n  }else{\n    iErr = 0;\n  }\n  if( iErr ){\n    *pzErr = sqlite3_mprintf(\"%s\", aErrMsg[iErr]);\n    goto rtreeInit_fail;\n  }\n  pRtree->nBytesPerCell = 8 + pRtree->nDim2*4;\n\n  /* Figure out the node size to use. */\n  rc = getNodeSize(db, pRtree, isCreate, pzErr);\n  if( rc ) goto rtreeInit_fail;\n  rc = rtreeSqlInit(pRtree, db, argv[1], argv[2], isCreate);\n  if( rc ){\n    *pzErr = sqlite3_mprintf(\"%s\", sqlite3_errmsg(db));\n    goto rtreeInit_fail;\n  }\n\n  *ppVtab = (sqlite3_vtab *)pRtree;\n  return SQLITE_OK;\n\nrtreeInit_fail:\n  if( rc==SQLITE_OK ) rc = SQLITE_ERROR;\n  assert( *ppVtab==0 );\n  assert( pRtree->nBusy==1 );\n  rtreeRelease(pRtree);\n  return rc;\n}\n\n\n/*\n** Implementation of a scalar function that decodes r-tree nodes to\n** human readable strings. This can be used for debugging and analysis.\n**\n** The scalar function takes two arguments: (1) the number of dimensions\n** to the rtree (between 1 and 5, inclusive) and (2) a blob of data containing\n** an r-tree node.  For a two-dimensional r-tree structure called \"rt\", to\n** deserialize all nodes, a statement like:\n**\n**   SELECT rtreenode(2, data) FROM rt_node;\n**\n** The human readable string takes the form of a Tcl list with one\n** entry for each cell in the r-tree node. Each entry is itself a\n** list, containing the 8-byte rowid/pageno followed by the \n** <num-dimension>*2 coordinates.\n*/\nstatic void rtreenode(sqlite3_context *ctx, int nArg, sqlite3_value **apArg){\n  char *zText = 0;\n  RtreeNode node;\n  Rtree tree;\n  int ii;\n\n  UNUSED_PARAMETER(nArg);\n  memset(&node, 0, sizeof(RtreeNode));\n  memset(&tree, 0, sizeof(Rtree));\n  tree.nDim = (u8)sqlite3_value_int(apArg[0]);\n  tree.nDim2 = tree.nDim*2;\n  tree.nBytesPerCell = 8 + 8 * tree.nDim;\n  node.zData = (u8 *)sqlite3_value_blob(apArg[1]);\n\n  for(ii=0; ii<NCELL(&node); ii++){\n    char zCell[512];\n    int nCell = 0;\n    RtreeCell cell;\n    int jj;\n\n    nodeGetCell(&tree, &node, ii, &cell);\n    sqlite3_snprintf(512-nCell,&zCell[nCell],\"%lld\", cell.iRowid);\n    nCell = (int)strlen(zCell);\n    for(jj=0; jj<tree.nDim2; jj++){\n#ifndef SQLITE_RTREE_INT_ONLY\n      sqlite3_snprintf(512-nCell,&zCell[nCell], \" %g\",\n                       (double)cell.aCoord[jj].f);\n#else\n      sqlite3_snprintf(512-nCell,&zCell[nCell], \" %d\",\n                       cell.aCoord[jj].i);\n#endif\n      nCell = (int)strlen(zCell);\n    }\n\n    if( zText ){\n      char *zTextNew = sqlite3_mprintf(\"%s {%s}\", zText, zCell);\n      sqlite3_free(zText);\n      zText = zTextNew;\n    }else{\n      zText = sqlite3_mprintf(\"{%s}\", zCell);\n    }\n  }\n  \n  sqlite3_result_text(ctx, zText, -1, sqlite3_free);\n}\n\n/* This routine implements an SQL function that returns the \"depth\" parameter\n** from the front of a blob that is an r-tree node.  For example:\n**\n**     SELECT rtreedepth(data) FROM rt_node WHERE nodeno=1;\n**\n** The depth value is 0 for all nodes other than the root node, and the root\n** node always has nodeno=1, so the example above is the primary use for this\n** routine.  This routine is intended for testing and analysis only.\n*/\nstatic void rtreedepth(sqlite3_context *ctx, int nArg, sqlite3_value **apArg){\n  UNUSED_PARAMETER(nArg);\n  if( sqlite3_value_type(apArg[0])!=SQLITE_BLOB \n   || sqlite3_value_bytes(apArg[0])<2\n  ){\n    sqlite3_result_error(ctx, \"Invalid argument to rtreedepth()\", -1); \n  }else{\n    u8 *zBlob = (u8 *)sqlite3_value_blob(apArg[0]);\n    sqlite3_result_int(ctx, readInt16(zBlob));\n  }\n}\n\n/*\n** Context object passed between the various routines that make up the\n** implementation of integrity-check function rtreecheck().\n*/\ntypedef struct RtreeCheck RtreeCheck;\nstruct RtreeCheck {\n  sqlite3 *db;                    /* Database handle */\n  const char *zDb;                /* Database containing rtree table */\n  const char *zTab;               /* Name of rtree table */\n  int bInt;                       /* True for rtree_i32 table */\n  int nDim;                       /* Number of dimensions for this rtree tbl */\n  sqlite3_stmt *pGetNode;         /* Statement used to retrieve nodes */\n  sqlite3_stmt *aCheckMapping[2]; /* Statements to query %_parent/%_rowid */\n  int nLeaf;                      /* Number of leaf cells in table */\n  int nNonLeaf;                   /* Number of non-leaf cells in table */\n  int rc;                         /* Return code */\n  char *zReport;                  /* Message to report */\n  int nErr;                       /* Number of lines in zReport */\n};\n\n#define RTREE_CHECK_MAX_ERROR 100\n\n/*\n** Reset SQL statement pStmt. If the sqlite3_reset() call returns an error,\n** and RtreeCheck.rc==SQLITE_OK, set RtreeCheck.rc to the error code.\n*/\nstatic void rtreeCheckReset(RtreeCheck *pCheck, sqlite3_stmt *pStmt){\n  int rc = sqlite3_reset(pStmt);\n  if( pCheck->rc==SQLITE_OK ) pCheck->rc = rc;\n}\n\n/*\n** The second and subsequent arguments to this function are a format string\n** and printf style arguments. This function formats the string and attempts\n** to compile it as an SQL statement.\n**\n** If successful, a pointer to the new SQL statement is returned. Otherwise,\n** NULL is returned and an error code left in RtreeCheck.rc.\n*/\nstatic sqlite3_stmt *rtreeCheckPrepare(\n  RtreeCheck *pCheck,             /* RtreeCheck object */\n  const char *zFmt, ...           /* Format string and trailing args */\n){\n  va_list ap;\n  char *z;\n  sqlite3_stmt *pRet = 0;\n\n  va_start(ap, zFmt);\n  z = sqlite3_vmprintf(zFmt, ap);\n\n  if( pCheck->rc==SQLITE_OK ){\n    if( z==0 ){\n      pCheck->rc = SQLITE_NOMEM;\n    }else{\n      pCheck->rc = sqlite3_prepare_v2(pCheck->db, z, -1, &pRet, 0);\n    }\n  }\n\n  sqlite3_free(z);\n  va_end(ap);\n  return pRet;\n}\n\n/*\n** The second and subsequent arguments to this function are a printf()\n** style format string and arguments. This function formats the string and\n** appends it to the report being accumuated in pCheck.\n*/\nstatic void rtreeCheckAppendMsg(RtreeCheck *pCheck, const char *zFmt, ...){\n  va_list ap;\n  va_start(ap, zFmt);\n  if( pCheck->rc==SQLITE_OK && pCheck->nErr<RTREE_CHECK_MAX_ERROR ){\n    char *z = sqlite3_vmprintf(zFmt, ap);\n    if( z==0 ){\n      pCheck->rc = SQLITE_NOMEM;\n    }else{\n      pCheck->zReport = sqlite3_mprintf(\"%z%s%z\", \n          pCheck->zReport, (pCheck->zReport ? \"\\n\" : \"\"), z\n      );\n      if( pCheck->zReport==0 ){\n        pCheck->rc = SQLITE_NOMEM;\n      }\n    }\n    pCheck->nErr++;\n  }\n  va_end(ap);\n}\n\n/*\n** This function is a no-op if there is already an error code stored\n** in the RtreeCheck object indicated by the first argument. NULL is\n** returned in this case.\n**\n** Otherwise, the contents of rtree table node iNode are loaded from\n** the database and copied into a buffer obtained from sqlite3_malloc().\n** If no error occurs, a pointer to the buffer is returned and (*pnNode)\n** is set to the size of the buffer in bytes.\n**\n** Or, if an error does occur, NULL is returned and an error code left\n** in the RtreeCheck object. The final value of *pnNode is undefined in\n** this case.\n*/\nstatic u8 *rtreeCheckGetNode(RtreeCheck *pCheck, i64 iNode, int *pnNode){\n  u8 *pRet = 0;                   /* Return value */\n\n  if( pCheck->rc==SQLITE_OK && pCheck->pGetNode==0 ){\n    pCheck->pGetNode = rtreeCheckPrepare(pCheck,\n        \"SELECT data FROM %Q.'%q_node' WHERE nodeno=?\", \n        pCheck->zDb, pCheck->zTab\n    );\n  }\n\n  if( pCheck->rc==SQLITE_OK ){\n    sqlite3_bind_int64(pCheck->pGetNode, 1, iNode);\n    if( sqlite3_step(pCheck->pGetNode)==SQLITE_ROW ){\n      int nNode = sqlite3_column_bytes(pCheck->pGetNode, 0);\n      const u8 *pNode = (const u8*)sqlite3_column_blob(pCheck->pGetNode, 0);\n      pRet = sqlite3_malloc64(nNode);\n      if( pRet==0 ){\n        pCheck->rc = SQLITE_NOMEM;\n      }else{\n        memcpy(pRet, pNode, nNode);\n        *pnNode = nNode;\n      }\n    }\n    rtreeCheckReset(pCheck, pCheck->pGetNode);\n    if( pCheck->rc==SQLITE_OK && pRet==0 ){\n      rtreeCheckAppendMsg(pCheck, \"Node %lld missing from database\", iNode);\n    }\n  }\n\n  return pRet;\n}\n\n/*\n** This function is used to check that the %_parent (if bLeaf==0) or %_rowid\n** (if bLeaf==1) table contains a specified entry. The schemas of the\n** two tables are:\n**\n**   CREATE TABLE %_parent(nodeno INTEGER PRIMARY KEY, parentnode INTEGER)\n**   CREATE TABLE %_rowid(rowid INTEGER PRIMARY KEY, nodeno INTEGER, ...)\n**\n** In both cases, this function checks that there exists an entry with\n** IPK value iKey and the second column set to iVal.\n**\n*/\nstatic void rtreeCheckMapping(\n  RtreeCheck *pCheck,             /* RtreeCheck object */\n  int bLeaf,                      /* True for a leaf cell, false for interior */\n  i64 iKey,                       /* Key for mapping */\n  i64 iVal                        /* Expected value for mapping */\n){\n  int rc;\n  sqlite3_stmt *pStmt;\n  const char *azSql[2] = {\n    \"SELECT parentnode FROM %Q.'%q_parent' WHERE nodeno=?1\",\n    \"SELECT nodeno FROM %Q.'%q_rowid' WHERE rowid=?1\"\n  };\n\n  assert( bLeaf==0 || bLeaf==1 );\n  if( pCheck->aCheckMapping[bLeaf]==0 ){\n    pCheck->aCheckMapping[bLeaf] = rtreeCheckPrepare(pCheck,\n        azSql[bLeaf], pCheck->zDb, pCheck->zTab\n    );\n  }\n  if( pCheck->rc!=SQLITE_OK ) return;\n\n  pStmt = pCheck->aCheckMapping[bLeaf];\n  sqlite3_bind_int64(pStmt, 1, iKey);\n  rc = sqlite3_step(pStmt);\n  if( rc==SQLITE_DONE ){\n    rtreeCheckAppendMsg(pCheck, \"Mapping (%lld -> %lld) missing from %s table\",\n        iKey, iVal, (bLeaf ? \"%_rowid\" : \"%_parent\")\n    );\n  }else if( rc==SQLITE_ROW ){\n    i64 ii = sqlite3_column_int64(pStmt, 0);\n    if( ii!=iVal ){\n      rtreeCheckAppendMsg(pCheck, \n          \"Found (%lld -> %lld) in %s table, expected (%lld -> %lld)\",\n          iKey, ii, (bLeaf ? \"%_rowid\" : \"%_parent\"), iKey, iVal\n      );\n    }\n  }\n  rtreeCheckReset(pCheck, pStmt);\n}\n\n/*\n** Argument pCell points to an array of coordinates stored on an rtree page.\n** This function checks that the coordinates are internally consistent (no\n** x1>x2 conditions) and adds an error message to the RtreeCheck object\n** if they are not.\n**\n** Additionally, if pParent is not NULL, then it is assumed to point to\n** the array of coordinates on the parent page that bound the page \n** containing pCell. In this case it is also verified that the two\n** sets of coordinates are mutually consistent and an error message added\n** to the RtreeCheck object if they are not.\n*/\nstatic void rtreeCheckCellCoord(\n  RtreeCheck *pCheck, \n  i64 iNode,                      /* Node id to use in error messages */\n  int iCell,                      /* Cell number to use in error messages */\n  u8 *pCell,                      /* Pointer to cell coordinates */\n  u8 *pParent                     /* Pointer to parent coordinates */\n){\n  RtreeCoord c1, c2;\n  RtreeCoord p1, p2;\n  int i;\n\n  for(i=0; i<pCheck->nDim; i++){\n    readCoord(&pCell[4*2*i], &c1);\n    readCoord(&pCell[4*(2*i + 1)], &c2);\n\n    /* printf(\"%e, %e\\n\", c1.u.f, c2.u.f); */\n    if( pCheck->bInt ? c1.i>c2.i : c1.f>c2.f ){\n      rtreeCheckAppendMsg(pCheck, \n          \"Dimension %d of cell %d on node %lld is corrupt\", i, iCell, iNode\n      );\n    }\n\n    if( pParent ){\n      readCoord(&pParent[4*2*i], &p1);\n      readCoord(&pParent[4*(2*i + 1)], &p2);\n\n      if( (pCheck->bInt ? c1.i<p1.i : c1.f<p1.f) \n       || (pCheck->bInt ? c2.i>p2.i : c2.f>p2.f)\n      ){\n        rtreeCheckAppendMsg(pCheck, \n            \"Dimension %d of cell %d on node %lld is corrupt relative to parent\"\n            , i, iCell, iNode\n        );\n      }\n    }\n  }\n}\n\n/*\n** Run rtreecheck() checks on node iNode, which is at depth iDepth within\n** the r-tree structure. Argument aParent points to the array of coordinates\n** that bound node iNode on the parent node.\n**\n** If any problems are discovered, an error message is appended to the\n** report accumulated in the RtreeCheck object.\n*/\nstatic void rtreeCheckNode(\n  RtreeCheck *pCheck,\n  int iDepth,                     /* Depth of iNode (0==leaf) */\n  u8 *aParent,                    /* Buffer containing parent coords */\n  i64 iNode                       /* Node to check */\n){\n  u8 *aNode = 0;\n  int nNode = 0;\n\n  assert( iNode==1 || aParent!=0 );\n  assert( pCheck->nDim>0 );\n\n  aNode = rtreeCheckGetNode(pCheck, iNode, &nNode);\n  if( aNode ){\n    if( nNode<4 ){\n      rtreeCheckAppendMsg(pCheck, \n          \"Node %lld is too small (%d bytes)\", iNode, nNode\n      );\n    }else{\n      int nCell;                  /* Number of cells on page */\n      int i;                      /* Used to iterate through cells */\n      if( aParent==0 ){\n        iDepth = readInt16(aNode);\n        if( iDepth>RTREE_MAX_DEPTH ){\n          rtreeCheckAppendMsg(pCheck, \"Rtree depth out of range (%d)\", iDepth);\n          sqlite3_free(aNode);\n          return;\n        }\n      }\n      nCell = readInt16(&aNode[2]);\n      if( (4 + nCell*(8 + pCheck->nDim*2*4))>nNode ){\n        rtreeCheckAppendMsg(pCheck, \n            \"Node %lld is too small for cell count of %d (%d bytes)\", \n            iNode, nCell, nNode\n        );\n      }else{\n        for(i=0; i<nCell; i++){\n          u8 *pCell = &aNode[4 + i*(8 + pCheck->nDim*2*4)];\n          i64 iVal = readInt64(pCell);\n          rtreeCheckCellCoord(pCheck, iNode, i, &pCell[8], aParent);\n\n          if( iDepth>0 ){\n            rtreeCheckMapping(pCheck, 0, iVal, iNode);\n            rtreeCheckNode(pCheck, iDepth-1, &pCell[8], iVal);\n            pCheck->nNonLeaf++;\n          }else{\n            rtreeCheckMapping(pCheck, 1, iVal, iNode);\n            pCheck->nLeaf++;\n          }\n        }\n      }\n    }\n    sqlite3_free(aNode);\n  }\n}\n\n/*\n** The second argument to this function must be either \"_rowid\" or\n** \"_parent\". This function checks that the number of entries in the\n** %_rowid or %_parent table is exactly nExpect. If not, it adds\n** an error message to the report in the RtreeCheck object indicated\n** by the first argument.\n*/\nstatic void rtreeCheckCount(RtreeCheck *pCheck, const char *zTbl, i64 nExpect){\n  if( pCheck->rc==SQLITE_OK ){\n    sqlite3_stmt *pCount;\n    pCount = rtreeCheckPrepare(pCheck, \"SELECT count(*) FROM %Q.'%q%s'\",\n        pCheck->zDb, pCheck->zTab, zTbl\n    );\n    if( pCount ){\n      if( sqlite3_step(pCount)==SQLITE_ROW ){\n        i64 nActual = sqlite3_column_int64(pCount, 0);\n        if( nActual!=nExpect ){\n          rtreeCheckAppendMsg(pCheck, \"Wrong number of entries in %%%s table\"\n              \" - expected %lld, actual %lld\" , zTbl, nExpect, nActual\n          );\n        }\n      }\n      pCheck->rc = sqlite3_finalize(pCount);\n    }\n  }\n}\n\n/*\n** This function does the bulk of the work for the rtree integrity-check.\n** It is called by rtreecheck(), which is the SQL function implementation.\n*/\nstatic int rtreeCheckTable(\n  sqlite3 *db,                    /* Database handle to access db through */\n  const char *zDb,                /* Name of db (\"main\", \"temp\" etc.) */\n  const char *zTab,               /* Name of rtree table to check */\n  char **pzReport                 /* OUT: sqlite3_malloc'd report text */\n){\n  RtreeCheck check;               /* Common context for various routines */\n  sqlite3_stmt *pStmt = 0;        /* Used to find column count of rtree table */\n  int bEnd = 0;                   /* True if transaction should be closed */\n  int nAux = 0;                   /* Number of extra columns. */\n\n  /* Initialize the context object */\n  memset(&check, 0, sizeof(check));\n  check.db = db;\n  check.zDb = zDb;\n  check.zTab = zTab;\n\n  /* If there is not already an open transaction, open one now. This is\n  ** to ensure that the queries run as part of this integrity-check operate\n  ** on a consistent snapshot.  */\n  if( sqlite3_get_autocommit(db) ){\n    check.rc = sqlite3_exec(db, \"BEGIN\", 0, 0, 0);\n    bEnd = 1;\n  }\n\n  /* Find the number of auxiliary columns */\n  if( check.rc==SQLITE_OK ){\n    pStmt = rtreeCheckPrepare(&check, \"SELECT * FROM %Q.'%q_rowid'\", zDb, zTab);\n    if( pStmt ){\n      nAux = sqlite3_column_count(pStmt) - 2;\n      sqlite3_finalize(pStmt);\n    }\n    check.rc = SQLITE_OK;\n  }\n\n  /* Find number of dimensions in the rtree table. */\n  pStmt = rtreeCheckPrepare(&check, \"SELECT * FROM %Q.%Q\", zDb, zTab);\n  if( pStmt ){\n    int rc;\n    check.nDim = (sqlite3_column_count(pStmt) - 1 - nAux) / 2;\n    if( check.nDim<1 ){\n      rtreeCheckAppendMsg(&check, \"Schema corrupt or not an rtree\");\n    }else if( SQLITE_ROW==sqlite3_step(pStmt) ){\n      check.bInt = (sqlite3_column_type(pStmt, 1)==SQLITE_INTEGER);\n    }\n    rc = sqlite3_finalize(pStmt);\n    if( rc!=SQLITE_CORRUPT ) check.rc = rc;\n  }\n\n  /* Do the actual integrity-check */\n  if( check.nDim>=1 ){\n    if( check.rc==SQLITE_OK ){\n      rtreeCheckNode(&check, 0, 0, 1);\n    }\n    rtreeCheckCount(&check, \"_rowid\", check.nLeaf);\n    rtreeCheckCount(&check, \"_parent\", check.nNonLeaf);\n  }\n\n  /* Finalize SQL statements used by the integrity-check */\n  sqlite3_finalize(check.pGetNode);\n  sqlite3_finalize(check.aCheckMapping[0]);\n  sqlite3_finalize(check.aCheckMapping[1]);\n\n  /* If one was opened, close the transaction */\n  if( bEnd ){\n    int rc = sqlite3_exec(db, \"END\", 0, 0, 0);\n    if( check.rc==SQLITE_OK ) check.rc = rc;\n  }\n  *pzReport = check.zReport;\n  return check.rc;\n}\n\n/*\n** Usage:\n**\n**   rtreecheck(<rtree-table>);\n**   rtreecheck(<database>, <rtree-table>);\n**\n** Invoking this SQL function runs an integrity-check on the named rtree\n** table. The integrity-check verifies the following:\n**\n**   1. For each cell in the r-tree structure (%_node table), that:\n**\n**       a) for each dimension, (coord1 <= coord2).\n**\n**       b) unless the cell is on the root node, that the cell is bounded\n**          by the parent cell on the parent node.\n**\n**       c) for leaf nodes, that there is an entry in the %_rowid \n**          table corresponding to the cell's rowid value that \n**          points to the correct node.\n**\n**       d) for cells on non-leaf nodes, that there is an entry in the \n**          %_parent table mapping from the cell's child node to the\n**          node that it resides on.\n**\n**   2. That there are the same number of entries in the %_rowid table\n**      as there are leaf cells in the r-tree structure, and that there\n**      is a leaf cell that corresponds to each entry in the %_rowid table.\n**\n**   3. That there are the same number of entries in the %_parent table\n**      as there are non-leaf cells in the r-tree structure, and that \n**      there is a non-leaf cell that corresponds to each entry in the \n**      %_parent table.\n*/\nstatic void rtreecheck(\n  sqlite3_context *ctx, \n  int nArg, \n  sqlite3_value **apArg\n){\n  if( nArg!=1 && nArg!=2 ){\n    sqlite3_result_error(ctx, \n        \"wrong number of arguments to function rtreecheck()\", -1\n    );\n  }else{\n    int rc;\n    char *zReport = 0;\n    const char *zDb = (const char*)sqlite3_value_text(apArg[0]);\n    const char *zTab;\n    if( nArg==1 ){\n      zTab = zDb;\n      zDb = \"main\";\n    }else{\n      zTab = (const char*)sqlite3_value_text(apArg[1]);\n    }\n    rc = rtreeCheckTable(sqlite3_context_db_handle(ctx), zDb, zTab, &zReport);\n    if( rc==SQLITE_OK ){\n      sqlite3_result_text(ctx, zReport ? zReport : \"ok\", -1, SQLITE_TRANSIENT);\n    }else{\n      sqlite3_result_error_code(ctx, rc);\n    }\n    sqlite3_free(zReport);\n  }\n}\n\n/* Conditionally include the geopoly code */\n#ifdef SQLITE_ENABLE_GEOPOLY\n/************** Include geopoly.c in the middle of rtree.c *******************/\n/************** Begin file geopoly.c *****************************************/\n/*\n** 2018-05-25\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n******************************************************************************\n**\n** This file implements an alternative R-Tree virtual table that\n** uses polygons to express the boundaries of 2-dimensional objects.\n**\n** This file is #include-ed onto the end of \"rtree.c\" so that it has\n** access to all of the R-Tree internals.\n*/\n/* #include <stdlib.h> */\n\n/* Enable -DGEOPOLY_ENABLE_DEBUG for debugging facilities */\n#ifdef GEOPOLY_ENABLE_DEBUG\n  static int geo_debug = 0;\n# define GEODEBUG(X) if(geo_debug)printf X\n#else\n# define GEODEBUG(X)\n#endif\n\n#ifndef JSON_NULL   /* The following stuff repeats things found in json1 */\n/*\n** Versions of isspace(), isalnum() and isdigit() to which it is safe\n** to pass signed char values.\n*/\n#ifdef sqlite3Isdigit\n   /* Use the SQLite core versions if this routine is part of the\n   ** SQLite amalgamation */\n#  define safe_isdigit(x)  sqlite3Isdigit(x)\n#  define safe_isalnum(x)  sqlite3Isalnum(x)\n#  define safe_isxdigit(x) sqlite3Isxdigit(x)\n#else\n   /* Use the standard library for separate compilation */\n#include <ctype.h>  /* amalgamator: keep */\n#  define safe_isdigit(x)  isdigit((unsigned char)(x))\n#  define safe_isalnum(x)  isalnum((unsigned char)(x))\n#  define safe_isxdigit(x) isxdigit((unsigned char)(x))\n#endif\n\n/*\n** Growing our own isspace() routine this way is twice as fast as\n** the library isspace() function.\n*/\nstatic const char geopolyIsSpace[] = {\n  0, 0, 0, 0, 0, 0, 0, 0,     0, 1, 1, 0, 0, 1, 0, 0,\n  0, 0, 0, 0, 0, 0, 0, 0,     0, 0, 0, 0, 0, 0, 0, 0,\n  1, 0, 0, 0, 0, 0, 0, 0,     0, 0, 0, 0, 0, 0, 0, 0,\n  0, 0, 0, 0, 0, 0, 0, 0,     0, 0, 0, 0, 0, 0, 0, 0,\n  0, 0, 0, 0, 0, 0, 0, 0,     0, 0, 0, 0, 0, 0, 0, 0,\n  0, 0, 0, 0, 0, 0, 0, 0,     0, 0, 0, 0, 0, 0, 0, 0,\n  0, 0, 0, 0, 0, 0, 0, 0,     0, 0, 0, 0, 0, 0, 0, 0,\n  0, 0, 0, 0, 0, 0, 0, 0,     0, 0, 0, 0, 0, 0, 0, 0,\n  0, 0, 0, 0, 0, 0, 0, 0,     0, 0, 0, 0, 0, 0, 0, 0,\n  0, 0, 0, 0, 0, 0, 0, 0,     0, 0, 0, 0, 0, 0, 0, 0,\n  0, 0, 0, 0, 0, 0, 0, 0,     0, 0, 0, 0, 0, 0, 0, 0,\n  0, 0, 0, 0, 0, 0, 0, 0,     0, 0, 0, 0, 0, 0, 0, 0,\n  0, 0, 0, 0, 0, 0, 0, 0,     0, 0, 0, 0, 0, 0, 0, 0,\n  0, 0, 0, 0, 0, 0, 0, 0,     0, 0, 0, 0, 0, 0, 0, 0,\n  0, 0, 0, 0, 0, 0, 0, 0,     0, 0, 0, 0, 0, 0, 0, 0,\n  0, 0, 0, 0, 0, 0, 0, 0,     0, 0, 0, 0, 0, 0, 0, 0,\n};\n#define safe_isspace(x) (geopolyIsSpace[(unsigned char)x])\n#endif /* JSON NULL - back to original code */\n\n/* Compiler and version */\n#ifndef GCC_VERSION\n#if defined(__GNUC__) && !defined(SQLITE_DISABLE_INTRINSIC)\n# define GCC_VERSION (__GNUC__*1000000+__GNUC_MINOR__*1000+__GNUC_PATCHLEVEL__)\n#else\n# define GCC_VERSION 0\n#endif\n#endif\n#ifndef MSVC_VERSION\n#if defined(_MSC_VER) && !defined(SQLITE_DISABLE_INTRINSIC)\n# define MSVC_VERSION _MSC_VER\n#else\n# define MSVC_VERSION 0\n#endif\n#endif\n\n/* Datatype for coordinates\n*/\ntypedef float GeoCoord;\n\n/*\n** Internal representation of a polygon.\n**\n** The polygon consists of a sequence of vertexes.  There is a line\n** segment between each pair of vertexes, and one final segment from\n** the last vertex back to the first.  (This differs from the GeoJSON\n** standard in which the final vertex is a repeat of the first.)\n**\n** The polygon follows the right-hand rule.  The area to the right of\n** each segment is \"outside\" and the area to the left is \"inside\".\n**\n** The on-disk representation consists of a 4-byte header followed by\n** the values.  The 4-byte header is:\n**\n**      encoding    (1 byte)   0=big-endian, 1=little-endian\n**      nvertex     (3 bytes)  Number of vertexes as a big-endian integer\n**\n** Enough space is allocated for 4 coordinates, to work around over-zealous\n** warnings coming from some compiler (notably, clang). In reality, the size\n** of each GeoPoly memory allocate is adjusted as necessary so that the\n** GeoPoly.a[] array at the end is the appropriate size.\n*/\ntypedef struct GeoPoly GeoPoly;\nstruct GeoPoly {\n  int nVertex;          /* Number of vertexes */\n  unsigned char hdr[4]; /* Header for on-disk representation */\n  GeoCoord a[8];        /* 2*nVertex values. X (longitude) first, then Y */\n};\n\n/* The size of a memory allocation needed for a GeoPoly object sufficient\n** to hold N coordinate pairs.\n*/\n#define GEOPOLY_SZ(N)  (sizeof(GeoPoly) + sizeof(GeoCoord)*2*((N)-4))\n\n/* Macros to access coordinates of a GeoPoly.\n** We have to use these macros, rather than just say p->a[i] in order\n** to silence (incorrect) UBSAN warnings if the array index is too large.\n*/\n#define GeoX(P,I)  (((GeoCoord*)(P)->a)[(I)*2])\n#define GeoY(P,I)  (((GeoCoord*)(P)->a)[(I)*2+1])\n\n\n/*\n** State of a parse of a GeoJSON input.\n*/\ntypedef struct GeoParse GeoParse;\nstruct GeoParse {\n  const unsigned char *z;   /* Unparsed input */\n  int nVertex;              /* Number of vertexes in a[] */\n  int nAlloc;               /* Space allocated to a[] */\n  int nErr;                 /* Number of errors encountered */\n  GeoCoord *a;          /* Array of vertexes.  From sqlite3_malloc64() */\n};\n\n/* Do a 4-byte byte swap */\nstatic void geopolySwab32(unsigned char *a){\n  unsigned char t = a[0];\n  a[0] = a[3];\n  a[3] = t;\n  t = a[1];\n  a[1] = a[2];\n  a[2] = t;\n}\n\n/* Skip whitespace.  Return the next non-whitespace character. */\nstatic char geopolySkipSpace(GeoParse *p){\n  while( safe_isspace(p->z[0]) ) p->z++;\n  return p->z[0];\n}\n\n/* Parse out a number.  Write the value into *pVal if pVal!=0.\n** return non-zero on success and zero if the next token is not a number.\n*/\nstatic int geopolyParseNumber(GeoParse *p, GeoCoord *pVal){\n  char c = geopolySkipSpace(p);\n  const unsigned char *z = p->z;\n  int j = 0;\n  int seenDP = 0;\n  int seenE = 0;\n  if( c=='-' ){\n    j = 1;\n    c = z[j];\n  }\n  if( c=='0' && z[j+1]>='0' && z[j+1]<='9' ) return 0;\n  for(;; j++){\n    c = z[j];\n    if( safe_isdigit(c) ) continue;\n    if( c=='.' ){\n      if( z[j-1]=='-' ) return 0;\n      if( seenDP ) return 0;\n      seenDP = 1;\n      continue;\n    }\n    if( c=='e' || c=='E' ){\n      if( z[j-1]<'0' ) return 0;\n      if( seenE ) return -1;\n      seenDP = seenE = 1;\n      c = z[j+1];\n      if( c=='+' || c=='-' ){\n        j++;\n        c = z[j+1];\n      }\n      if( c<'0' || c>'9' ) return 0;\n      continue;\n    }\n    break;\n  }\n  if( z[j-1]<'0' ) return 0;\n  if( pVal ){\n#ifdef SQLITE_AMALGAMATION\n     /* The sqlite3AtoF() routine is much much faster than atof(), if it\n     ** is available */\n     double r;\n     (void)sqlite3AtoF((const char*)p->z, &r, j, SQLITE_UTF8);\n     *pVal = r;\n#else\n     *pVal = (GeoCoord)atof((const char*)p->z);\n#endif\n  }\n  p->z += j;\n  return 1;\n}\n\n/*\n** If the input is a well-formed JSON array of coordinates with at least\n** four coordinates and where each coordinate is itself a two-value array,\n** then convert the JSON into a GeoPoly object and return a pointer to\n** that object.\n**\n** If any error occurs, return NULL.\n*/\nstatic GeoPoly *geopolyParseJson(const unsigned char *z, int *pRc){\n  GeoParse s;\n  int rc = SQLITE_OK;\n  memset(&s, 0, sizeof(s));\n  s.z = z;\n  if( geopolySkipSpace(&s)=='[' ){\n    s.z++;\n    while( geopolySkipSpace(&s)=='[' ){\n      int ii = 0;\n      char c;\n      s.z++;\n      if( s.nVertex>=s.nAlloc ){\n        GeoCoord *aNew;\n        s.nAlloc = s.nAlloc*2 + 16;\n        aNew = sqlite3_realloc64(s.a, s.nAlloc*sizeof(GeoCoord)*2 );\n        if( aNew==0 ){\n          rc = SQLITE_NOMEM;\n          s.nErr++;\n          break;\n        }\n        s.a = aNew;\n      }\n      while( geopolyParseNumber(&s, ii<=1 ? &s.a[s.nVertex*2+ii] : 0) ){\n        ii++;\n        if( ii==2 ) s.nVertex++;\n        c = geopolySkipSpace(&s);\n        s.z++;\n        if( c==',' ) continue;\n        if( c==']' && ii>=2 ) break;\n        s.nErr++;\n        rc = SQLITE_ERROR;\n        goto parse_json_err;\n      }\n      if( geopolySkipSpace(&s)==',' ){\n        s.z++;\n        continue;\n      }\n      break;\n    }\n    if( geopolySkipSpace(&s)==']'\n     && s.nVertex>=4\n     && s.a[0]==s.a[s.nVertex*2-2]\n     && s.a[1]==s.a[s.nVertex*2-1]\n     && (s.z++, geopolySkipSpace(&s)==0)\n    ){\n      GeoPoly *pOut;\n      int x = 1;\n      s.nVertex--;  /* Remove the redundant vertex at the end */\n      pOut = sqlite3_malloc64( GEOPOLY_SZ(s.nVertex) );\n      x = 1;\n      if( pOut==0 ) goto parse_json_err;\n      pOut->nVertex = s.nVertex;\n      memcpy(pOut->a, s.a, s.nVertex*2*sizeof(GeoCoord));\n      pOut->hdr[0] = *(unsigned char*)&x;\n      pOut->hdr[1] = (s.nVertex>>16)&0xff;\n      pOut->hdr[2] = (s.nVertex>>8)&0xff;\n      pOut->hdr[3] = s.nVertex&0xff;\n      sqlite3_free(s.a);\n      if( pRc ) *pRc = SQLITE_OK;\n      return pOut;\n    }else{\n      s.nErr++;\n      rc = SQLITE_ERROR;\n    }\n  }\nparse_json_err:\n  if( pRc ) *pRc = rc;\n  sqlite3_free(s.a);\n  return 0;\n}\n\n/*\n** Given a function parameter, try to interpret it as a polygon, either\n** in the binary format or JSON text.  Compute a GeoPoly object and\n** return a pointer to that object.  Or if the input is not a well-formed\n** polygon, put an error message in sqlite3_context and return NULL.\n*/\nstatic GeoPoly *geopolyFuncParam(\n  sqlite3_context *pCtx,      /* Context for error messages */\n  sqlite3_value *pVal,        /* The value to decode */\n  int *pRc                    /* Write error here */\n){\n  GeoPoly *p = 0;\n  int nByte;\n  if( sqlite3_value_type(pVal)==SQLITE_BLOB\n   && (nByte = sqlite3_value_bytes(pVal))>=(4+6*sizeof(GeoCoord))\n  ){\n    const unsigned char *a = sqlite3_value_blob(pVal);\n    int nVertex;\n    nVertex = (a[1]<<16) + (a[2]<<8) + a[3];\n    if( (a[0]==0 || a[0]==1)\n     && (nVertex*2*sizeof(GeoCoord) + 4)==(unsigned int)nByte\n    ){\n      p = sqlite3_malloc64( sizeof(*p) + (nVertex-1)*2*sizeof(GeoCoord) );\n      if( p==0 ){\n        if( pRc ) *pRc = SQLITE_NOMEM;\n        if( pCtx ) sqlite3_result_error_nomem(pCtx);\n      }else{\n        int x = 1;\n        p->nVertex = nVertex;\n        memcpy(p->hdr, a, nByte);\n        if( a[0] != *(unsigned char*)&x ){\n          int ii;\n          for(ii=0; ii<nVertex; ii++){\n            geopolySwab32((unsigned char*)&GeoX(p,ii));\n            geopolySwab32((unsigned char*)&GeoY(p,ii));\n          }\n          p->hdr[0] ^= 1;\n        }\n      }\n    }\n    if( pRc ) *pRc = SQLITE_OK;\n    return p;\n  }else if( sqlite3_value_type(pVal)==SQLITE_TEXT ){\n    const unsigned char *zJson = sqlite3_value_text(pVal);\n    if( zJson==0 ){\n      if( pRc ) *pRc = SQLITE_NOMEM;\n      return 0;\n    }\n    return geopolyParseJson(zJson, pRc);\n  }else{\n    if( pRc ) *pRc = SQLITE_ERROR;\n    return 0;\n  }\n}\n\n/*\n** Implementation of the geopoly_blob(X) function.\n**\n** If the input is a well-formed Geopoly BLOB or JSON string\n** then return the BLOB representation of the polygon.  Otherwise\n** return NULL.\n*/\nstatic void geopolyBlobFunc(\n  sqlite3_context *context,\n  int argc,\n  sqlite3_value **argv\n){\n  GeoPoly *p = geopolyFuncParam(context, argv[0], 0);\n  if( p ){\n    sqlite3_result_blob(context, p->hdr, \n       4+8*p->nVertex, SQLITE_TRANSIENT);\n    sqlite3_free(p);\n  }\n}\n\n/*\n** SQL function:     geopoly_json(X)\n**\n** Interpret X as a polygon and render it as a JSON array\n** of coordinates.  Or, if X is not a valid polygon, return NULL.\n*/\nstatic void geopolyJsonFunc(\n  sqlite3_context *context,\n  int argc,\n  sqlite3_value **argv\n){\n  GeoPoly *p = geopolyFuncParam(context, argv[0], 0);\n  if( p ){\n    sqlite3 *db = sqlite3_context_db_handle(context);\n    sqlite3_str *x = sqlite3_str_new(db);\n    int i;\n    sqlite3_str_append(x, \"[\", 1);\n    for(i=0; i<p->nVertex; i++){\n      sqlite3_str_appendf(x, \"[%!g,%!g],\", GeoX(p,i), GeoY(p,i));\n    }\n    sqlite3_str_appendf(x, \"[%!g,%!g]]\", GeoX(p,0), GeoY(p,0));\n    sqlite3_result_text(context, sqlite3_str_finish(x), -1, sqlite3_free);\n    sqlite3_free(p);\n  }\n}\n\n/*\n** SQL function:     geopoly_svg(X, ....)\n**\n** Interpret X as a polygon and render it as a SVG <polyline>.\n** Additional arguments are added as attributes to the <polyline>.\n*/\nstatic void geopolySvgFunc(\n  sqlite3_context *context,\n  int argc,\n  sqlite3_value **argv\n){\n  GeoPoly *p;\n  if( argc<1 ) return;\n  p = geopolyFuncParam(context, argv[0], 0);\n  if( p ){\n    sqlite3 *db = sqlite3_context_db_handle(context);\n    sqlite3_str *x = sqlite3_str_new(db);\n    int i;\n    char cSep = '\\'';\n    sqlite3_str_appendf(x, \"<polyline points=\");\n    for(i=0; i<p->nVertex; i++){\n      sqlite3_str_appendf(x, \"%c%g,%g\", cSep, GeoX(p,i), GeoY(p,i));\n      cSep = ' ';\n    }\n    sqlite3_str_appendf(x, \" %g,%g'\", GeoX(p,0), GeoY(p,0));\n    for(i=1; i<argc; i++){\n      const char *z = (const char*)sqlite3_value_text(argv[i]);\n      if( z && z[0] ){\n        sqlite3_str_appendf(x, \" %s\", z);\n      }\n    }\n    sqlite3_str_appendf(x, \"></polyline>\");\n    sqlite3_result_text(context, sqlite3_str_finish(x), -1, sqlite3_free);\n    sqlite3_free(p);\n  }\n}\n\n/*\n** SQL Function:      geopoly_xform(poly, A, B, C, D, E, F)\n**\n** Transform and/or translate a polygon as follows:\n**\n**      x1 = A*x0 + B*y0 + E\n**      y1 = C*x0 + D*y0 + F\n**\n** For a translation:\n**\n**      geopoly_xform(poly, 1, 0, 0, 1, x-offset, y-offset)\n**\n** Rotate by R around the point (0,0):\n**\n**      geopoly_xform(poly, cos(R), sin(R), -sin(R), cos(R), 0, 0)\n*/\nstatic void geopolyXformFunc(\n  sqlite3_context *context,\n  int argc,\n  sqlite3_value **argv\n){\n  GeoPoly *p = geopolyFuncParam(context, argv[0], 0);\n  double A = sqlite3_value_double(argv[1]);\n  double B = sqlite3_value_double(argv[2]);\n  double C = sqlite3_value_double(argv[3]);\n  double D = sqlite3_value_double(argv[4]);\n  double E = sqlite3_value_double(argv[5]);\n  double F = sqlite3_value_double(argv[6]);\n  GeoCoord x1, y1, x0, y0;\n  int ii;\n  if( p ){\n    for(ii=0; ii<p->nVertex; ii++){\n      x0 = GeoX(p,ii);\n      y0 = GeoY(p,ii);\n      x1 = (GeoCoord)(A*x0 + B*y0 + E);\n      y1 = (GeoCoord)(C*x0 + D*y0 + F);\n      GeoX(p,ii) = x1;\n      GeoY(p,ii) = y1;\n    }\n    sqlite3_result_blob(context, p->hdr, \n       4+8*p->nVertex, SQLITE_TRANSIENT);\n    sqlite3_free(p);\n  }\n}\n\n/*\n** Compute the area enclosed by the polygon.\n**\n** This routine can also be used to detect polygons that rotate in\n** the wrong direction.  Polygons are suppose to be counter-clockwise (CCW).\n** This routine returns a negative value for clockwise (CW) polygons.\n*/\nstatic double geopolyArea(GeoPoly *p){\n  double rArea = 0.0;\n  int ii;\n  for(ii=0; ii<p->nVertex-1; ii++){\n    rArea += (GeoX(p,ii) - GeoX(p,ii+1))           /* (x0 - x1) */\n              * (GeoY(p,ii) + GeoY(p,ii+1))        /* (y0 + y1) */\n              * 0.5;\n  }\n  rArea += (GeoX(p,ii) - GeoX(p,0))                /* (xN - x0) */\n           * (GeoY(p,ii) + GeoY(p,0))              /* (yN + y0) */\n           * 0.5;\n  return rArea;\n}\n\n/*\n** Implementation of the geopoly_area(X) function.\n**\n** If the input is a well-formed Geopoly BLOB then return the area\n** enclosed by the polygon.  If the polygon circulates clockwise instead\n** of counterclockwise (as it should) then return the negative of the\n** enclosed area.  Otherwise return NULL.\n*/\nstatic void geopolyAreaFunc(\n  sqlite3_context *context,\n  int argc,\n  sqlite3_value **argv\n){\n  GeoPoly *p = geopolyFuncParam(context, argv[0], 0);\n  if( p ){\n    sqlite3_result_double(context, geopolyArea(p));\n    sqlite3_free(p);\n  }            \n}\n\n/*\n** Implementation of the geopoly_ccw(X) function.\n**\n** If the rotation of polygon X is clockwise (incorrect) instead of\n** counter-clockwise (the correct winding order according to RFC7946)\n** then reverse the order of the vertexes in polygon X.  \n**\n** In other words, this routine returns a CCW polygon regardless of the\n** winding order of its input.\n**\n** Use this routine to sanitize historical inputs that that sometimes\n** contain polygons that wind in the wrong direction.\n*/\nstatic void geopolyCcwFunc(\n  sqlite3_context *context,\n  int argc,\n  sqlite3_value **argv\n){\n  GeoPoly *p = geopolyFuncParam(context, argv[0], 0);\n  if( p ){\n    if( geopolyArea(p)<0.0 ){\n      int ii, jj;\n      for(ii=1, jj=p->nVertex-1; ii<jj; ii++, jj--){\n        GeoCoord t = GeoX(p,ii);\n        GeoX(p,ii) = GeoX(p,jj);\n        GeoX(p,jj) = t;\n        t = GeoY(p,ii);\n        GeoY(p,ii) = GeoY(p,jj);\n        GeoY(p,jj) = t;\n      }\n    }\n    sqlite3_result_blob(context, p->hdr, \n       4+8*p->nVertex, SQLITE_TRANSIENT);\n    sqlite3_free(p);\n  }            \n}\n\n#define GEOPOLY_PI 3.1415926535897932385\n\n/* Fast approximation for sine(X) for X between -0.5*pi and 2*pi\n*/\nstatic double geopolySine(double r){\n  assert( r>=-0.5*GEOPOLY_PI && r<=2.0*GEOPOLY_PI );\n  if( r>=1.5*GEOPOLY_PI ){\n    r -= 2.0*GEOPOLY_PI;\n  }\n  if( r>=0.5*GEOPOLY_PI ){\n    return -geopolySine(r-GEOPOLY_PI);\n  }else{\n    double r2 = r*r;\n    double r3 = r2*r;\n    double r5 = r3*r2;\n    return 0.9996949*r - 0.1656700*r3 + 0.0075134*r5;\n  }\n}\n\n/*\n** Function:   geopoly_regular(X,Y,R,N)\n**\n** Construct a simple, convex, regular polygon centered at X, Y\n** with circumradius R and with N sides.\n*/\nstatic void geopolyRegularFunc(\n  sqlite3_context *context,\n  int argc,\n  sqlite3_value **argv\n){\n  double x = sqlite3_value_double(argv[0]);\n  double y = sqlite3_value_double(argv[1]);\n  double r = sqlite3_value_double(argv[2]);\n  int n = sqlite3_value_int(argv[3]);\n  int i;\n  GeoPoly *p;\n\n  if( n<3 || r<=0.0 ) return;\n  if( n>1000 ) n = 1000;\n  p = sqlite3_malloc64( sizeof(*p) + (n-1)*2*sizeof(GeoCoord) );\n  if( p==0 ){\n    sqlite3_result_error_nomem(context);\n    return;\n  }\n  i = 1;\n  p->hdr[0] = *(unsigned char*)&i;\n  p->hdr[1] = 0;\n  p->hdr[2] = (n>>8)&0xff;\n  p->hdr[3] = n&0xff;\n  for(i=0; i<n; i++){\n    double rAngle = 2.0*GEOPOLY_PI*i/n;\n    GeoX(p,i) = x - r*geopolySine(rAngle-0.5*GEOPOLY_PI);\n    GeoY(p,i) = y + r*geopolySine(rAngle);\n  }\n  sqlite3_result_blob(context, p->hdr, 4+8*n, SQLITE_TRANSIENT);\n  sqlite3_free(p);\n}\n\n/*\n** If pPoly is a polygon, compute its bounding box. Then:\n**\n**    (1) if aCoord!=0 store the bounding box in aCoord, returning NULL\n**    (2) otherwise, compute a GeoPoly for the bounding box and return the\n**        new GeoPoly\n**\n** If pPoly is NULL but aCoord is not NULL, then compute a new GeoPoly from\n** the bounding box in aCoord and return a pointer to that GeoPoly.\n*/\nstatic GeoPoly *geopolyBBox(\n  sqlite3_context *context,   /* For recording the error */\n  sqlite3_value *pPoly,       /* The polygon */\n  RtreeCoord *aCoord,         /* Results here */\n  int *pRc                    /* Error code here */\n){\n  GeoPoly *pOut = 0;\n  GeoPoly *p;\n  float mnX, mxX, mnY, mxY;\n  if( pPoly==0 && aCoord!=0 ){\n    p = 0;\n    mnX = aCoord[0].f;\n    mxX = aCoord[1].f;\n    mnY = aCoord[2].f;\n    mxY = aCoord[3].f;\n    goto geopolyBboxFill;\n  }else{\n    p = geopolyFuncParam(context, pPoly, pRc);\n  }\n  if( p ){\n    int ii;\n    mnX = mxX = GeoX(p,0);\n    mnY = mxY = GeoY(p,0);\n    for(ii=1; ii<p->nVertex; ii++){\n      double r = GeoX(p,ii);\n      if( r<mnX ) mnX = (float)r;\n      else if( r>mxX ) mxX = (float)r;\n      r = GeoY(p,ii);\n      if( r<mnY ) mnY = (float)r;\n      else if( r>mxY ) mxY = (float)r;\n    }\n    if( pRc ) *pRc = SQLITE_OK;\n    if( aCoord==0 ){\n      geopolyBboxFill:\n      pOut = sqlite3_realloc(p, GEOPOLY_SZ(4));\n      if( pOut==0 ){\n        sqlite3_free(p);\n        if( context ) sqlite3_result_error_nomem(context);\n        if( pRc ) *pRc = SQLITE_NOMEM;\n        return 0;\n      }\n      pOut->nVertex = 4;\n      ii = 1;\n      pOut->hdr[0] = *(unsigned char*)&ii;\n      pOut->hdr[1] = 0;\n      pOut->hdr[2] = 0;\n      pOut->hdr[3] = 4;\n      GeoX(pOut,0) = mnX;\n      GeoY(pOut,0) = mnY;\n      GeoX(pOut,1) = mxX;\n      GeoY(pOut,1) = mnY;\n      GeoX(pOut,2) = mxX;\n      GeoY(pOut,2) = mxY;\n      GeoX(pOut,3) = mnX;\n      GeoY(pOut,3) = mxY;\n    }else{\n      sqlite3_free(p);\n      aCoord[0].f = mnX;\n      aCoord[1].f = mxX;\n      aCoord[2].f = mnY;\n      aCoord[3].f = mxY;\n    }\n  }\n  return pOut;\n}\n\n/*\n** Implementation of the geopoly_bbox(X) SQL function.\n*/\nstatic void geopolyBBoxFunc(\n  sqlite3_context *context,\n  int argc,\n  sqlite3_value **argv\n){\n  GeoPoly *p = geopolyBBox(context, argv[0], 0, 0);\n  if( p ){\n    sqlite3_result_blob(context, p->hdr, \n       4+8*p->nVertex, SQLITE_TRANSIENT);\n    sqlite3_free(p);\n  }\n}\n\n/*\n** State vector for the geopoly_group_bbox() aggregate function.\n*/\ntypedef struct GeoBBox GeoBBox;\nstruct GeoBBox {\n  int isInit;\n  RtreeCoord a[4];\n};\n\n\n/*\n** Implementation of the geopoly_group_bbox(X) aggregate SQL function.\n*/\nstatic void geopolyBBoxStep(\n  sqlite3_context *context,\n  int argc,\n  sqlite3_value **argv\n){\n  RtreeCoord a[4];\n  int rc = SQLITE_OK;\n  (void)geopolyBBox(context, argv[0], a, &rc);\n  if( rc==SQLITE_OK ){\n    GeoBBox *pBBox;\n    pBBox = (GeoBBox*)sqlite3_aggregate_context(context, sizeof(*pBBox));\n    if( pBBox==0 ) return;\n    if( pBBox->isInit==0 ){\n      pBBox->isInit = 1;\n      memcpy(pBBox->a, a, sizeof(RtreeCoord)*4);\n    }else{\n      if( a[0].f < pBBox->a[0].f ) pBBox->a[0] = a[0];\n      if( a[1].f > pBBox->a[1].f ) pBBox->a[1] = a[1];\n      if( a[2].f < pBBox->a[2].f ) pBBox->a[2] = a[2];\n      if( a[3].f > pBBox->a[3].f ) pBBox->a[3] = a[3];\n    }\n  }\n}\nstatic void geopolyBBoxFinal(\n  sqlite3_context *context\n){\n  GeoPoly *p;\n  GeoBBox *pBBox;\n  pBBox = (GeoBBox*)sqlite3_aggregate_context(context, 0);\n  if( pBBox==0 ) return;\n  p = geopolyBBox(context, 0, pBBox->a, 0);\n  if( p ){\n    sqlite3_result_blob(context, p->hdr, \n       4+8*p->nVertex, SQLITE_TRANSIENT);\n    sqlite3_free(p);\n  }\n}\n\n\n/*\n** Determine if point (x0,y0) is beneath line segment (x1,y1)->(x2,y2).\n** Returns:\n**\n**    +2  x0,y0 is on the line segement\n**\n**    +1  x0,y0 is beneath line segment\n**\n**    0   x0,y0 is not on or beneath the line segment or the line segment\n**        is vertical and x0,y0 is not on the line segment\n**\n** The left-most coordinate min(x1,x2) is not considered to be part of\n** the line segment for the purposes of this analysis.\n*/\nstatic int pointBeneathLine(\n  double x0, double y0,\n  double x1, double y1,\n  double x2, double y2\n){\n  double y;\n  if( x0==x1 && y0==y1 ) return 2;\n  if( x1<x2 ){\n    if( x0<=x1 || x0>x2 ) return 0;\n  }else if( x1>x2 ){\n    if( x0<=x2 || x0>x1 ) return 0;\n  }else{\n    /* Vertical line segment */\n    if( x0!=x1 ) return 0;\n    if( y0<y1 && y0<y2 ) return 0;\n    if( y0>y1 && y0>y2 ) return 0;\n    return 2;\n  }\n  y = y1 + (y2-y1)*(x0-x1)/(x2-x1);\n  if( y0==y ) return 2;\n  if( y0<y ) return 1;\n  return 0;\n}\n\n/*\n** SQL function:    geopoly_contains_point(P,X,Y)\n**\n** Return +2 if point X,Y is within polygon P.\n** Return +1 if point X,Y is on the polygon boundary.\n** Return 0 if point X,Y is outside the polygon\n*/\nstatic void geopolyContainsPointFunc(\n  sqlite3_context *context,\n  int argc,\n  sqlite3_value **argv\n){\n  GeoPoly *p1 = geopolyFuncParam(context, argv[0], 0);\n  double x0 = sqlite3_value_double(argv[1]);\n  double y0 = sqlite3_value_double(argv[2]);\n  int v = 0;\n  int cnt = 0;\n  int ii;\n  if( p1==0 ) return;\n  for(ii=0; ii<p1->nVertex-1; ii++){\n    v = pointBeneathLine(x0,y0,GeoX(p1,ii), GeoY(p1,ii),\n                               GeoX(p1,ii+1),GeoY(p1,ii+1));\n    if( v==2 ) break;\n    cnt += v;\n  }\n  if( v!=2 ){\n    v = pointBeneathLine(x0,y0,GeoX(p1,ii), GeoY(p1,ii),\n                               GeoX(p1,0),  GeoY(p1,0));\n  }\n  if( v==2 ){\n    sqlite3_result_int(context, 1);\n  }else if( ((v+cnt)&1)==0 ){\n    sqlite3_result_int(context, 0);\n  }else{\n    sqlite3_result_int(context, 2);\n  }\n  sqlite3_free(p1);\n}\n\n/* Forward declaration */\nstatic int geopolyOverlap(GeoPoly *p1, GeoPoly *p2);\n\n/*\n** SQL function:    geopoly_within(P1,P2)\n**\n** Return +2 if P1 and P2 are the same polygon\n** Return +1 if P2 is contained within P1\n** Return 0 if any part of P2 is on the outside of P1\n**\n*/\nstatic void geopolyWithinFunc(\n  sqlite3_context *context,\n  int argc,\n  sqlite3_value **argv\n){\n  GeoPoly *p1 = geopolyFuncParam(context, argv[0], 0);\n  GeoPoly *p2 = geopolyFuncParam(context, argv[1], 0);\n  if( p1 && p2 ){\n    int x = geopolyOverlap(p1, p2);\n    if( x<0 ){\n      sqlite3_result_error_nomem(context);\n    }else{\n      sqlite3_result_int(context, x==2 ? 1 : x==4 ? 2 : 0);\n    }\n  }\n  sqlite3_free(p1);\n  sqlite3_free(p2);\n}\n\n/* Objects used by the overlap algorihm. */\ntypedef struct GeoEvent GeoEvent;\ntypedef struct GeoSegment GeoSegment;\ntypedef struct GeoOverlap GeoOverlap;\nstruct GeoEvent {\n  double x;              /* X coordinate at which event occurs */\n  int eType;             /* 0 for ADD, 1 for REMOVE */\n  GeoSegment *pSeg;      /* The segment to be added or removed */\n  GeoEvent *pNext;       /* Next event in the sorted list */\n};\nstruct GeoSegment {\n  double C, B;           /* y = C*x + B */\n  double y;              /* Current y value */\n  float y0;              /* Initial y value */\n  unsigned char side;    /* 1 for p1, 2 for p2 */\n  unsigned int idx;      /* Which segment within the side */\n  GeoSegment *pNext;     /* Next segment in a list sorted by y */\n};\nstruct GeoOverlap {\n  GeoEvent *aEvent;          /* Array of all events */\n  GeoSegment *aSegment;      /* Array of all segments */\n  int nEvent;                /* Number of events */\n  int nSegment;              /* Number of segments */\n};\n\n/*\n** Add a single segment and its associated events.\n*/\nstatic void geopolyAddOneSegment(\n  GeoOverlap *p,\n  GeoCoord x0,\n  GeoCoord y0,\n  GeoCoord x1,\n  GeoCoord y1,\n  unsigned char side,\n  unsigned int idx\n){\n  GeoSegment *pSeg;\n  GeoEvent *pEvent;\n  if( x0==x1 ) return;  /* Ignore vertical segments */\n  if( x0>x1 ){\n    GeoCoord t = x0;\n    x0 = x1;\n    x1 = t;\n    t = y0;\n    y0 = y1;\n    y1 = t;\n  }\n  pSeg = p->aSegment + p->nSegment;\n  p->nSegment++;\n  pSeg->C = (y1-y0)/(x1-x0);\n  pSeg->B = y1 - x1*pSeg->C;\n  pSeg->y0 = y0;\n  pSeg->side = side;\n  pSeg->idx = idx;\n  pEvent = p->aEvent + p->nEvent;\n  p->nEvent++;\n  pEvent->x = x0;\n  pEvent->eType = 0;\n  pEvent->pSeg = pSeg;\n  pEvent = p->aEvent + p->nEvent;\n  p->nEvent++;\n  pEvent->x = x1;\n  pEvent->eType = 1;\n  pEvent->pSeg = pSeg;\n}\n  \n\n\n/*\n** Insert all segments and events for polygon pPoly.\n*/\nstatic void geopolyAddSegments(\n  GeoOverlap *p,          /* Add segments to this Overlap object */\n  GeoPoly *pPoly,         /* Take all segments from this polygon */\n  unsigned char side      /* The side of pPoly */\n){\n  unsigned int i;\n  GeoCoord *x;\n  for(i=0; i<(unsigned)pPoly->nVertex-1; i++){\n    x = &GeoX(pPoly,i);\n    geopolyAddOneSegment(p, x[0], x[1], x[2], x[3], side, i);\n  }\n  x = &GeoX(pPoly,i);\n  geopolyAddOneSegment(p, x[0], x[1], pPoly->a[0], pPoly->a[1], side, i);\n}\n\n/*\n** Merge two lists of sorted events by X coordinate\n*/\nstatic GeoEvent *geopolyEventMerge(GeoEvent *pLeft, GeoEvent *pRight){\n  GeoEvent head, *pLast;\n  head.pNext = 0;\n  pLast = &head;\n  while( pRight && pLeft ){\n    if( pRight->x <= pLeft->x ){\n      pLast->pNext = pRight;\n      pLast = pRight;\n      pRight = pRight->pNext;\n    }else{\n      pLast->pNext = pLeft;\n      pLast = pLeft;\n      pLeft = pLeft->pNext;\n    }\n  }\n  pLast->pNext = pRight ? pRight : pLeft;\n  return head.pNext;  \n}\n\n/*\n** Sort an array of nEvent event objects into a list.\n*/\nstatic GeoEvent *geopolySortEventsByX(GeoEvent *aEvent, int nEvent){\n  int mx = 0;\n  int i, j;\n  GeoEvent *p;\n  GeoEvent *a[50];\n  for(i=0; i<nEvent; i++){\n    p = &aEvent[i];\n    p->pNext = 0;\n    for(j=0; j<mx && a[j]; j++){\n      p = geopolyEventMerge(a[j], p);\n      a[j] = 0;\n    }\n    a[j] = p;\n    if( j>=mx ) mx = j+1;\n  }\n  p = 0;\n  for(i=0; i<mx; i++){\n    p = geopolyEventMerge(a[i], p);\n  }\n  return p;\n}\n\n/*\n** Merge two lists of sorted segments by Y, and then by C.\n*/\nstatic GeoSegment *geopolySegmentMerge(GeoSegment *pLeft, GeoSegment *pRight){\n  GeoSegment head, *pLast;\n  head.pNext = 0;\n  pLast = &head;\n  while( pRight && pLeft ){\n    double r = pRight->y - pLeft->y;\n    if( r==0.0 ) r = pRight->C - pLeft->C;\n    if( r<0.0 ){\n      pLast->pNext = pRight;\n      pLast = pRight;\n      pRight = pRight->pNext;\n    }else{\n      pLast->pNext = pLeft;\n      pLast = pLeft;\n      pLeft = pLeft->pNext;\n    }\n  }\n  pLast->pNext = pRight ? pRight : pLeft;\n  return head.pNext;  \n}\n\n/*\n** Sort a list of GeoSegments in order of increasing Y and in the event of\n** a tie, increasing C (slope).\n*/\nstatic GeoSegment *geopolySortSegmentsByYAndC(GeoSegment *pList){\n  int mx = 0;\n  int i;\n  GeoSegment *p;\n  GeoSegment *a[50];\n  while( pList ){\n    p = pList;\n    pList = pList->pNext;\n    p->pNext = 0;\n    for(i=0; i<mx && a[i]; i++){\n      p = geopolySegmentMerge(a[i], p);\n      a[i] = 0;\n    }\n    a[i] = p;\n    if( i>=mx ) mx = i+1;\n  }\n  p = 0;\n  for(i=0; i<mx; i++){\n    p = geopolySegmentMerge(a[i], p);\n  }\n  return p;\n}\n\n/*\n** Determine the overlap between two polygons\n*/\nstatic int geopolyOverlap(GeoPoly *p1, GeoPoly *p2){\n  int nVertex = p1->nVertex + p2->nVertex + 2;\n  GeoOverlap *p;\n  int nByte;\n  GeoEvent *pThisEvent;\n  double rX;\n  int rc = 0;\n  int needSort = 0;\n  GeoSegment *pActive = 0;\n  GeoSegment *pSeg;\n  unsigned char aOverlap[4];\n\n  nByte = sizeof(GeoEvent)*nVertex*2 \n           + sizeof(GeoSegment)*nVertex \n           + sizeof(GeoOverlap);\n  p = sqlite3_malloc( nByte );\n  if( p==0 ) return -1;\n  p->aEvent = (GeoEvent*)&p[1];\n  p->aSegment = (GeoSegment*)&p->aEvent[nVertex*2];\n  p->nEvent = p->nSegment = 0;\n  geopolyAddSegments(p, p1, 1);\n  geopolyAddSegments(p, p2, 2);\n  pThisEvent = geopolySortEventsByX(p->aEvent, p->nEvent);\n  rX = pThisEvent->x==0.0 ? -1.0 : 0.0;\n  memset(aOverlap, 0, sizeof(aOverlap));\n  while( pThisEvent ){\n    if( pThisEvent->x!=rX ){\n      GeoSegment *pPrev = 0;\n      int iMask = 0;\n      GEODEBUG((\"Distinct X: %g\\n\", pThisEvent->x));\n      rX = pThisEvent->x;\n      if( needSort ){\n        GEODEBUG((\"SORT\\n\"));\n        pActive = geopolySortSegmentsByYAndC(pActive);\n        needSort = 0;\n      }\n      for(pSeg=pActive; pSeg; pSeg=pSeg->pNext){\n        if( pPrev ){\n          if( pPrev->y!=pSeg->y ){\n            GEODEBUG((\"MASK: %d\\n\", iMask));\n            aOverlap[iMask] = 1;\n          }\n        }\n        iMask ^= pSeg->side;\n        pPrev = pSeg;\n      }\n      pPrev = 0;\n      for(pSeg=pActive; pSeg; pSeg=pSeg->pNext){\n        double y = pSeg->C*rX + pSeg->B;\n        GEODEBUG((\"Segment %d.%d %g->%g\\n\", pSeg->side, pSeg->idx, pSeg->y, y));\n        pSeg->y = y;\n        if( pPrev ){\n          if( pPrev->y>pSeg->y && pPrev->side!=pSeg->side ){\n            rc = 1;\n            GEODEBUG((\"Crossing: %d.%d and %d.%d\\n\",\n                    pPrev->side, pPrev->idx,\n                    pSeg->side, pSeg->idx));\n            goto geopolyOverlapDone;\n          }else if( pPrev->y!=pSeg->y ){\n            GEODEBUG((\"MASK: %d\\n\", iMask));\n            aOverlap[iMask] = 1;\n          }\n        }\n        iMask ^= pSeg->side;\n        pPrev = pSeg;\n      }\n    }\n    GEODEBUG((\"%s %d.%d C=%g B=%g\\n\",\n      pThisEvent->eType ? \"RM \" : \"ADD\",\n      pThisEvent->pSeg->side, pThisEvent->pSeg->idx,\n      pThisEvent->pSeg->C,\n      pThisEvent->pSeg->B));\n    if( pThisEvent->eType==0 ){\n      /* Add a segment */\n      pSeg = pThisEvent->pSeg;\n      pSeg->y = pSeg->y0;\n      pSeg->pNext = pActive;\n      pActive = pSeg;\n      needSort = 1;\n    }else{\n      /* Remove a segment */\n      if( pActive==pThisEvent->pSeg ){\n        pActive = pActive->pNext;\n      }else{\n        for(pSeg=pActive; pSeg; pSeg=pSeg->pNext){\n          if( pSeg->pNext==pThisEvent->pSeg ){\n            pSeg->pNext = pSeg->pNext->pNext;\n            break;\n          }\n        }\n      }\n    }\n    pThisEvent = pThisEvent->pNext;\n  }\n  if( aOverlap[3]==0 ){\n    rc = 0;\n  }else if( aOverlap[1]!=0 && aOverlap[2]==0 ){\n    rc = 3;\n  }else if( aOverlap[1]==0 && aOverlap[2]!=0 ){\n    rc = 2;\n  }else if( aOverlap[1]==0 && aOverlap[2]==0 ){\n    rc = 4;\n  }else{\n    rc = 1;\n  }\n\ngeopolyOverlapDone:\n  sqlite3_free(p);\n  return rc;\n}\n\n/*\n** SQL function:    geopoly_overlap(P1,P2)\n**\n** Determine whether or not P1 and P2 overlap. Return value:\n**\n**   0     The two polygons are disjoint\n**   1     They overlap\n**   2     P1 is completely contained within P2\n**   3     P2 is completely contained within P1\n**   4     P1 and P2 are the same polygon\n**   NULL  Either P1 or P2 or both are not valid polygons\n*/\nstatic void geopolyOverlapFunc(\n  sqlite3_context *context,\n  int argc,\n  sqlite3_value **argv\n){\n  GeoPoly *p1 = geopolyFuncParam(context, argv[0], 0);\n  GeoPoly *p2 = geopolyFuncParam(context, argv[1], 0);\n  if( p1 && p2 ){\n    int x = geopolyOverlap(p1, p2);\n    if( x<0 ){\n      sqlite3_result_error_nomem(context);\n    }else{\n      sqlite3_result_int(context, x);\n    }\n  }\n  sqlite3_free(p1);\n  sqlite3_free(p2);\n}\n\n/*\n** Enable or disable debugging output\n*/\nstatic void geopolyDebugFunc(\n  sqlite3_context *context,\n  int argc,\n  sqlite3_value **argv\n){\n#ifdef GEOPOLY_ENABLE_DEBUG\n  geo_debug = sqlite3_value_int(argv[0]);\n#endif\n}\n\n/* \n** This function is the implementation of both the xConnect and xCreate\n** methods of the geopoly virtual table.\n**\n**   argv[0]   -> module name\n**   argv[1]   -> database name\n**   argv[2]   -> table name\n**   argv[...] -> column names...\n*/\nstatic int geopolyInit(\n  sqlite3 *db,                        /* Database connection */\n  void *pAux,                         /* One of the RTREE_COORD_* constants */\n  int argc, const char *const*argv,   /* Parameters to CREATE TABLE statement */\n  sqlite3_vtab **ppVtab,              /* OUT: New virtual table */\n  char **pzErr,                       /* OUT: Error message, if any */\n  int isCreate                        /* True for xCreate, false for xConnect */\n){\n  int rc = SQLITE_OK;\n  Rtree *pRtree;\n  int nDb;              /* Length of string argv[1] */\n  int nName;            /* Length of string argv[2] */\n  sqlite3_str *pSql;\n  char *zSql;\n  int ii;\n\n  sqlite3_vtab_config(db, SQLITE_VTAB_CONSTRAINT_SUPPORT, 1);\n\n  /* Allocate the sqlite3_vtab structure */\n  nDb = (int)strlen(argv[1]);\n  nName = (int)strlen(argv[2]);\n  pRtree = (Rtree *)sqlite3_malloc(sizeof(Rtree)+nDb+nName+2);\n  if( !pRtree ){\n    return SQLITE_NOMEM;\n  }\n  memset(pRtree, 0, sizeof(Rtree)+nDb+nName+2);\n  pRtree->nBusy = 1;\n  pRtree->base.pModule = &rtreeModule;\n  pRtree->zDb = (char *)&pRtree[1];\n  pRtree->zName = &pRtree->zDb[nDb+1];\n  pRtree->eCoordType = RTREE_COORD_REAL32;\n  pRtree->nDim = 2;\n  pRtree->nDim2 = 4;\n  memcpy(pRtree->zDb, argv[1], nDb);\n  memcpy(pRtree->zName, argv[2], nName);\n\n\n  /* Create/Connect to the underlying relational database schema. If\n  ** that is successful, call sqlite3_declare_vtab() to configure\n  ** the r-tree table schema.\n  */\n  pSql = sqlite3_str_new(db);\n  sqlite3_str_appendf(pSql, \"CREATE TABLE x(_shape\");\n  pRtree->nAux = 1;         /* Add one for _shape */\n  pRtree->nAuxNotNull = 1;  /* The _shape column is always not-null */\n  for(ii=3; ii<argc; ii++){\n    pRtree->nAux++;\n    sqlite3_str_appendf(pSql, \",%s\", argv[ii]);\n  }\n  sqlite3_str_appendf(pSql, \");\");\n  zSql = sqlite3_str_finish(pSql);\n  if( !zSql ){\n    rc = SQLITE_NOMEM;\n  }else if( SQLITE_OK!=(rc = sqlite3_declare_vtab(db, zSql)) ){\n    *pzErr = sqlite3_mprintf(\"%s\", sqlite3_errmsg(db));\n  }\n  sqlite3_free(zSql);\n  if( rc ) goto geopolyInit_fail;\n  pRtree->nBytesPerCell = 8 + pRtree->nDim2*4;\n\n  /* Figure out the node size to use. */\n  rc = getNodeSize(db, pRtree, isCreate, pzErr);\n  if( rc ) goto geopolyInit_fail;\n  rc = rtreeSqlInit(pRtree, db, argv[1], argv[2], isCreate);\n  if( rc ){\n    *pzErr = sqlite3_mprintf(\"%s\", sqlite3_errmsg(db));\n    goto geopolyInit_fail;\n  }\n\n  *ppVtab = (sqlite3_vtab *)pRtree;\n  return SQLITE_OK;\n\ngeopolyInit_fail:\n  if( rc==SQLITE_OK ) rc = SQLITE_ERROR;\n  assert( *ppVtab==0 );\n  assert( pRtree->nBusy==1 );\n  rtreeRelease(pRtree);\n  return rc;\n}\n\n\n/* \n** GEOPOLY virtual table module xCreate method.\n*/\nstatic int geopolyCreate(\n  sqlite3 *db,\n  void *pAux,\n  int argc, const char *const*argv,\n  sqlite3_vtab **ppVtab,\n  char **pzErr\n){\n  return geopolyInit(db, pAux, argc, argv, ppVtab, pzErr, 1);\n}\n\n/* \n** GEOPOLY virtual table module xConnect method.\n*/\nstatic int geopolyConnect(\n  sqlite3 *db,\n  void *pAux,\n  int argc, const char *const*argv,\n  sqlite3_vtab **ppVtab,\n  char **pzErr\n){\n  return geopolyInit(db, pAux, argc, argv, ppVtab, pzErr, 0);\n}\n\n\n/* \n** GEOPOLY virtual table module xFilter method.\n**\n** Query plans:\n**\n**      1         rowid lookup\n**      2         search for objects overlapping the same bounding box\n**                that contains polygon argv[0]\n**      3         search for objects overlapping the same bounding box\n**                that contains polygon argv[0]\n**      4         full table scan\n*/\nstatic int geopolyFilter(\n  sqlite3_vtab_cursor *pVtabCursor,     /* The cursor to initialize */\n  int idxNum,                           /* Query plan */\n  const char *idxStr,                   /* Not Used */\n  int argc, sqlite3_value **argv        /* Parameters to the query plan */\n){\n  Rtree *pRtree = (Rtree *)pVtabCursor->pVtab;\n  RtreeCursor *pCsr = (RtreeCursor *)pVtabCursor;\n  RtreeNode *pRoot = 0;\n  int rc = SQLITE_OK;\n  int iCell = 0;\n  sqlite3_stmt *pStmt;\n\n  rtreeReference(pRtree);\n\n  /* Reset the cursor to the same state as rtreeOpen() leaves it in. */\n  freeCursorConstraints(pCsr);\n  sqlite3_free(pCsr->aPoint);\n  pStmt = pCsr->pReadAux;\n  memset(pCsr, 0, sizeof(RtreeCursor));\n  pCsr->base.pVtab = (sqlite3_vtab*)pRtree;\n  pCsr->pReadAux = pStmt;\n\n  pCsr->iStrategy = idxNum;\n  if( idxNum==1 ){\n    /* Special case - lookup by rowid. */\n    RtreeNode *pLeaf;        /* Leaf on which the required cell resides */\n    RtreeSearchPoint *p;     /* Search point for the leaf */\n    i64 iRowid = sqlite3_value_int64(argv[0]);\n    i64 iNode = 0;\n    rc = findLeafNode(pRtree, iRowid, &pLeaf, &iNode);\n    if( rc==SQLITE_OK && pLeaf!=0 ){\n      p = rtreeSearchPointNew(pCsr, RTREE_ZERO, 0);\n      assert( p!=0 );  /* Always returns pCsr->sPoint */\n      pCsr->aNode[0] = pLeaf;\n      p->id = iNode;\n      p->eWithin = PARTLY_WITHIN;\n      rc = nodeRowidIndex(pRtree, pLeaf, iRowid, &iCell);\n      p->iCell = (u8)iCell;\n      RTREE_QUEUE_TRACE(pCsr, \"PUSH-F1:\");\n    }else{\n      pCsr->atEOF = 1;\n    }\n  }else{\n    /* Normal case - r-tree scan. Set up the RtreeCursor.aConstraint array \n    ** with the configured constraints. \n    */\n    rc = nodeAcquire(pRtree, 1, 0, &pRoot);\n    if( rc==SQLITE_OK && idxNum<=3 ){\n      RtreeCoord bbox[4];\n      RtreeConstraint *p;\n      assert( argc==1 );\n      geopolyBBox(0, argv[0], bbox, &rc);\n      if( rc ){\n        goto geopoly_filter_end;\n      }\n      pCsr->aConstraint = p = sqlite3_malloc(sizeof(RtreeConstraint)*4);\n      pCsr->nConstraint = 4;\n      if( p==0 ){\n        rc = SQLITE_NOMEM;\n      }else{\n        memset(pCsr->aConstraint, 0, sizeof(RtreeConstraint)*4);\n        memset(pCsr->anQueue, 0, sizeof(u32)*(pRtree->iDepth + 1));\n        if( idxNum==2 ){\n          /* Overlap query */\n          p->op = 'B';\n          p->iCoord = 0;\n          p->u.rValue = bbox[1].f;\n          p++;\n          p->op = 'D';\n          p->iCoord = 1;\n          p->u.rValue = bbox[0].f;\n          p++;\n          p->op = 'B';\n          p->iCoord = 2;\n          p->u.rValue = bbox[3].f;\n          p++;\n          p->op = 'D';\n          p->iCoord = 3;\n          p->u.rValue = bbox[2].f;\n        }else{\n          /* Within query */\n          p->op = 'D';\n          p->iCoord = 0;\n          p->u.rValue = bbox[0].f;\n          p++;\n          p->op = 'B';\n          p->iCoord = 1;\n          p->u.rValue = bbox[1].f;\n          p++;\n          p->op = 'D';\n          p->iCoord = 2;\n          p->u.rValue = bbox[2].f;\n          p++;\n          p->op = 'B';\n          p->iCoord = 3;\n          p->u.rValue = bbox[3].f;\n        }\n      }\n    }\n    if( rc==SQLITE_OK ){\n      RtreeSearchPoint *pNew;\n      pNew = rtreeSearchPointNew(pCsr, RTREE_ZERO, (u8)(pRtree->iDepth+1));\n      if( pNew==0 ){\n        rc = SQLITE_NOMEM;\n        goto geopoly_filter_end;\n      }\n      pNew->id = 1;\n      pNew->iCell = 0;\n      pNew->eWithin = PARTLY_WITHIN;\n      assert( pCsr->bPoint==1 );\n      pCsr->aNode[0] = pRoot;\n      pRoot = 0;\n      RTREE_QUEUE_TRACE(pCsr, \"PUSH-Fm:\");\n      rc = rtreeStepToLeaf(pCsr);\n    }\n  }\n\ngeopoly_filter_end:\n  nodeRelease(pRtree, pRoot);\n  rtreeRelease(pRtree);\n  return rc;\n}\n\n/*\n** Rtree virtual table module xBestIndex method. There are three\n** table scan strategies to choose from (in order from most to \n** least desirable):\n**\n**   idxNum     idxStr        Strategy\n**   ------------------------------------------------\n**     1        \"rowid\"       Direct lookup by rowid.\n**     2        \"rtree\"       R-tree overlap query using geopoly_overlap()\n**     3        \"rtree\"       R-tree within query using geopoly_within()\n**     4        \"fullscan\"    full-table scan.\n**   ------------------------------------------------\n*/\nstatic int geopolyBestIndex(sqlite3_vtab *tab, sqlite3_index_info *pIdxInfo){\n  int ii;\n  int iRowidTerm = -1;\n  int iFuncTerm = -1;\n  int idxNum = 0;\n\n  for(ii=0; ii<pIdxInfo->nConstraint; ii++){\n    struct sqlite3_index_constraint *p = &pIdxInfo->aConstraint[ii];\n    if( !p->usable ) continue;\n    if( p->iColumn<0 && p->op==SQLITE_INDEX_CONSTRAINT_EQ  ){\n      iRowidTerm = ii;\n      break;\n    }\n    if( p->iColumn==0 && p->op>=SQLITE_INDEX_CONSTRAINT_FUNCTION ){\n      /* p->op==SQLITE_INDEX_CONSTRAINT_FUNCTION for geopoly_overlap()\n      ** p->op==(SQLITE_INDEX_CONTRAINT_FUNCTION+1) for geopoly_within().\n      ** See geopolyFindFunction() */\n      iFuncTerm = ii;\n      idxNum = p->op - SQLITE_INDEX_CONSTRAINT_FUNCTION + 2;\n    }\n  }\n\n  if( iRowidTerm>=0 ){\n    pIdxInfo->idxNum = 1;\n    pIdxInfo->idxStr = \"rowid\";\n    pIdxInfo->aConstraintUsage[iRowidTerm].argvIndex = 1;\n    pIdxInfo->aConstraintUsage[iRowidTerm].omit = 1;\n    pIdxInfo->estimatedCost = 30.0;\n    pIdxInfo->estimatedRows = 1;\n    pIdxInfo->idxFlags = SQLITE_INDEX_SCAN_UNIQUE;\n    return SQLITE_OK;\n  }\n  if( iFuncTerm>=0 ){\n    pIdxInfo->idxNum = idxNum;\n    pIdxInfo->idxStr = \"rtree\";\n    pIdxInfo->aConstraintUsage[iFuncTerm].argvIndex = 1;\n    pIdxInfo->aConstraintUsage[iFuncTerm].omit = 0;\n    pIdxInfo->estimatedCost = 300.0;\n    pIdxInfo->estimatedRows = 10;\n    return SQLITE_OK;\n  }\n  pIdxInfo->idxNum = 4;\n  pIdxInfo->idxStr = \"fullscan\";\n  pIdxInfo->estimatedCost = 3000000.0;\n  pIdxInfo->estimatedRows = 100000;\n  return SQLITE_OK;\n}\n\n\n/* \n** GEOPOLY virtual table module xColumn method.\n*/\nstatic int geopolyColumn(sqlite3_vtab_cursor *cur, sqlite3_context *ctx, int i){\n  Rtree *pRtree = (Rtree *)cur->pVtab;\n  RtreeCursor *pCsr = (RtreeCursor *)cur;\n  RtreeSearchPoint *p = rtreeSearchPointFirst(pCsr);\n  int rc = SQLITE_OK;\n  RtreeNode *pNode = rtreeNodeOfFirstSearchPoint(pCsr, &rc);\n\n  if( rc ) return rc;\n  if( p==0 ) return SQLITE_OK;\n  if( i==0 && sqlite3_vtab_nochange(ctx) ) return SQLITE_OK;\n  if( i<=pRtree->nAux ){\n    if( !pCsr->bAuxValid ){\n      if( pCsr->pReadAux==0 ){\n        rc = sqlite3_prepare_v3(pRtree->db, pRtree->zReadAuxSql, -1, 0,\n                                &pCsr->pReadAux, 0);\n        if( rc ) return rc;\n      }\n      sqlite3_bind_int64(pCsr->pReadAux, 1, \n          nodeGetRowid(pRtree, pNode, p->iCell));\n      rc = sqlite3_step(pCsr->pReadAux);\n      if( rc==SQLITE_ROW ){\n        pCsr->bAuxValid = 1;\n      }else{\n        sqlite3_reset(pCsr->pReadAux);\n        if( rc==SQLITE_DONE ) rc = SQLITE_OK;\n        return rc;\n      }\n    }\n    sqlite3_result_value(ctx, sqlite3_column_value(pCsr->pReadAux, i+2));\n  }\n  return SQLITE_OK;\n}\n\n\n/*\n** The xUpdate method for GEOPOLY module virtual tables.\n**\n** For DELETE:\n**\n**     argv[0] = the rowid to be deleted\n**\n** For INSERT:\n**\n**     argv[0] = SQL NULL\n**     argv[1] = rowid to insert, or an SQL NULL to select automatically\n**     argv[2] = _shape column\n**     argv[3] = first application-defined column....\n**\n** For UPDATE:\n**\n**     argv[0] = rowid to modify.  Never NULL\n**     argv[1] = rowid after the change.  Never NULL\n**     argv[2] = new value for _shape\n**     argv[3] = new value for first application-defined column....\n*/\nstatic int geopolyUpdate(\n  sqlite3_vtab *pVtab, \n  int nData, \n  sqlite3_value **aData, \n  sqlite_int64 *pRowid\n){\n  Rtree *pRtree = (Rtree *)pVtab;\n  int rc = SQLITE_OK;\n  RtreeCell cell;                 /* New cell to insert if nData>1 */\n  i64 oldRowid;                   /* The old rowid */\n  int oldRowidValid;              /* True if oldRowid is valid */\n  i64 newRowid;                   /* The new rowid */\n  int newRowidValid;              /* True if newRowid is valid */\n  int coordChange = 0;            /* Change in coordinates */\n\n  if( pRtree->nNodeRef ){\n    /* Unable to write to the btree while another cursor is reading from it,\n    ** since the write might do a rebalance which would disrupt the read\n    ** cursor. */\n    return SQLITE_LOCKED_VTAB;\n  }\n  rtreeReference(pRtree);\n  assert(nData>=1);\n\n  oldRowidValid = sqlite3_value_type(aData[0])!=SQLITE_NULL;;\n  oldRowid = oldRowidValid ? sqlite3_value_int64(aData[0]) : 0;\n  newRowidValid = nData>1 && sqlite3_value_type(aData[1])!=SQLITE_NULL;\n  newRowid = newRowidValid ? sqlite3_value_int64(aData[1]) : 0;\n  cell.iRowid = newRowid;\n\n  if( nData>1                                 /* not a DELETE */\n   && (!oldRowidValid                         /* INSERT */\n        || !sqlite3_value_nochange(aData[2])  /* UPDATE _shape */\n        || oldRowid!=newRowid)                /* Rowid change */\n  ){\n    geopolyBBox(0, aData[2], cell.aCoord, &rc);\n    if( rc ){\n      if( rc==SQLITE_ERROR ){\n        pVtab->zErrMsg =\n          sqlite3_mprintf(\"_shape does not contain a valid polygon\");\n      }\n      goto geopoly_update_end;\n    }\n    coordChange = 1;\n\n    /* If a rowid value was supplied, check if it is already present in \n    ** the table. If so, the constraint has failed. */\n    if( newRowidValid && (!oldRowidValid || oldRowid!=newRowid) ){\n      int steprc;\n      sqlite3_bind_int64(pRtree->pReadRowid, 1, cell.iRowid);\n      steprc = sqlite3_step(pRtree->pReadRowid);\n      rc = sqlite3_reset(pRtree->pReadRowid);\n      if( SQLITE_ROW==steprc ){\n        if( sqlite3_vtab_on_conflict(pRtree->db)==SQLITE_REPLACE ){\n          rc = rtreeDeleteRowid(pRtree, cell.iRowid);\n        }else{\n          rc = rtreeConstraintError(pRtree, 0);\n        }\n      }\n    }\n  }\n\n  /* If aData[0] is not an SQL NULL value, it is the rowid of a\n  ** record to delete from the r-tree table. The following block does\n  ** just that.\n  */\n  if( rc==SQLITE_OK && (nData==1 || (coordChange && oldRowidValid)) ){\n    rc = rtreeDeleteRowid(pRtree, oldRowid);\n  }\n\n  /* If the aData[] array contains more than one element, elements\n  ** (aData[2]..aData[argc-1]) contain a new record to insert into\n  ** the r-tree structure.\n  */\n  if( rc==SQLITE_OK && nData>1 && coordChange ){\n    /* Insert the new record into the r-tree */\n    RtreeNode *pLeaf = 0;\n    if( !newRowidValid ){\n      rc = rtreeNewRowid(pRtree, &cell.iRowid);\n    }\n    *pRowid = cell.iRowid;\n    if( rc==SQLITE_OK ){\n      rc = ChooseLeaf(pRtree, &cell, 0, &pLeaf);\n    }\n    if( rc==SQLITE_OK ){\n      int rc2;\n      pRtree->iReinsertHeight = -1;\n      rc = rtreeInsertCell(pRtree, pLeaf, &cell, 0);\n      rc2 = nodeRelease(pRtree, pLeaf);\n      if( rc==SQLITE_OK ){\n        rc = rc2;\n      }\n    }\n  }\n\n  /* Change the data */\n  if( rc==SQLITE_OK && nData>1 ){\n    sqlite3_stmt *pUp = pRtree->pWriteAux;\n    int jj;\n    int nChange = 0;\n    sqlite3_bind_int64(pUp, 1, cell.iRowid);\n    assert( pRtree->nAux>=1 );\n    if( sqlite3_value_nochange(aData[2]) ){\n      sqlite3_bind_null(pUp, 2);\n    }else{\n      GeoPoly *p = 0;\n      if( sqlite3_value_type(aData[2])==SQLITE_TEXT\n       && (p = geopolyFuncParam(0, aData[2], &rc))!=0\n       && rc==SQLITE_OK\n      ){\n        sqlite3_bind_blob(pUp, 2, p->hdr, 4+8*p->nVertex, SQLITE_TRANSIENT);\n      }else{\n        sqlite3_bind_value(pUp, 2, aData[2]);\n      }\n      sqlite3_free(p);\n      nChange = 1;\n    }\n    for(jj=1; jj<pRtree->nAux; jj++){\n      nChange++;\n      sqlite3_bind_value(pUp, jj+2, aData[jj+2]);\n    }\n    if( nChange ){\n      sqlite3_step(pUp);\n      rc = sqlite3_reset(pUp);\n    }\n  }\n\ngeopoly_update_end:\n  rtreeRelease(pRtree);\n  return rc;\n}\n\n/*\n** Report that geopoly_overlap() is an overloaded function suitable\n** for use in xBestIndex.\n*/\nstatic int geopolyFindFunction(\n  sqlite3_vtab *pVtab,\n  int nArg,\n  const char *zName,\n  void (**pxFunc)(sqlite3_context*,int,sqlite3_value**),\n  void **ppArg\n){\n  if( sqlite3_stricmp(zName, \"geopoly_overlap\")==0 ){\n    *pxFunc = geopolyOverlapFunc;\n    *ppArg = 0;\n    return SQLITE_INDEX_CONSTRAINT_FUNCTION;\n  }\n  if( sqlite3_stricmp(zName, \"geopoly_within\")==0 ){\n    *pxFunc = geopolyWithinFunc;\n    *ppArg = 0;\n    return SQLITE_INDEX_CONSTRAINT_FUNCTION+1;\n  }\n  return 0;\n}\n\n\nstatic sqlite3_module geopolyModule = {\n  3,                          /* iVersion */\n  geopolyCreate,              /* xCreate - create a table */\n  geopolyConnect,             /* xConnect - connect to an existing table */\n  geopolyBestIndex,           /* xBestIndex - Determine search strategy */\n  rtreeDisconnect,            /* xDisconnect - Disconnect from a table */\n  rtreeDestroy,               /* xDestroy - Drop a table */\n  rtreeOpen,                  /* xOpen - open a cursor */\n  rtreeClose,                 /* xClose - close a cursor */\n  geopolyFilter,              /* xFilter - configure scan constraints */\n  rtreeNext,                  /* xNext - advance a cursor */\n  rtreeEof,                   /* xEof */\n  geopolyColumn,              /* xColumn - read data */\n  rtreeRowid,                 /* xRowid - read data */\n  geopolyUpdate,              /* xUpdate - write data */\n  rtreeBeginTransaction,      /* xBegin - begin transaction */\n  rtreeEndTransaction,        /* xSync - sync transaction */\n  rtreeEndTransaction,        /* xCommit - commit transaction */\n  rtreeEndTransaction,        /* xRollback - rollback transaction */\n  geopolyFindFunction,        /* xFindFunction - function overloading */\n  rtreeRename,                /* xRename - rename the table */\n  rtreeSavepoint,             /* xSavepoint */\n  0,                          /* xRelease */\n  0,                          /* xRollbackTo */\n  rtreeShadowName             /* xShadowName */\n};\n\nstatic int sqlite3_geopoly_init(sqlite3 *db){\n  int rc = SQLITE_OK;\n  static const struct {\n    void (*xFunc)(sqlite3_context*,int,sqlite3_value**);\n    signed char nArg;\n    unsigned char bPure;\n    const char *zName;\n  } aFunc[] = {\n     { geopolyAreaFunc,          1, 1,    \"geopoly_area\"             },\n     { geopolyBlobFunc,          1, 1,    \"geopoly_blob\"             },\n     { geopolyJsonFunc,          1, 1,    \"geopoly_json\"             },\n     { geopolySvgFunc,          -1, 1,    \"geopoly_svg\"              },\n     { geopolyWithinFunc,        2, 1,    \"geopoly_within\"           },\n     { geopolyContainsPointFunc, 3, 1,    \"geopoly_contains_point\"   },\n     { geopolyOverlapFunc,       2, 1,    \"geopoly_overlap\"          },\n     { geopolyDebugFunc,         1, 0,    \"geopoly_debug\"            },\n     { geopolyBBoxFunc,          1, 1,    \"geopoly_bbox\"             },\n     { geopolyXformFunc,         7, 1,    \"geopoly_xform\"            },\n     { geopolyRegularFunc,       4, 1,    \"geopoly_regular\"          },\n     { geopolyCcwFunc,           1, 1,    \"geopoly_ccw\"              },\n  };\n  static const struct {\n    void (*xStep)(sqlite3_context*,int,sqlite3_value**);\n    void (*xFinal)(sqlite3_context*);\n    const char *zName;\n  } aAgg[] = {\n     { geopolyBBoxStep, geopolyBBoxFinal, \"geopoly_group_bbox\"    },\n  };\n  int i;\n  for(i=0; i<sizeof(aFunc)/sizeof(aFunc[0]) && rc==SQLITE_OK; i++){\n    int enc = aFunc[i].bPure ? SQLITE_UTF8|SQLITE_DETERMINISTIC : SQLITE_UTF8;\n    rc = sqlite3_create_function(db, aFunc[i].zName, aFunc[i].nArg,\n                                 enc, 0,\n                                 aFunc[i].xFunc, 0, 0);\n  }\n  for(i=0; i<sizeof(aAgg)/sizeof(aAgg[0]) && rc==SQLITE_OK; i++){\n    rc = sqlite3_create_function(db, aAgg[i].zName, 1, SQLITE_UTF8, 0,\n                                 0, aAgg[i].xStep, aAgg[i].xFinal);\n  }\n  if( rc==SQLITE_OK ){\n    rc = sqlite3_create_module_v2(db, \"geopoly\", &geopolyModule, 0, 0);\n  }\n  return rc;\n}\n\n/************** End of geopoly.c *********************************************/\n/************** Continuing where we left off in rtree.c **********************/\n#endif\n\n/*\n** Register the r-tree module with database handle db. This creates the\n** virtual table module \"rtree\" and the debugging/analysis scalar \n** function \"rtreenode\".\n*/\nSQLITE_PRIVATE int sqlite3RtreeInit(sqlite3 *db){\n  const int utf8 = SQLITE_UTF8;\n  int rc;\n\n  rc = sqlite3_create_function(db, \"rtreenode\", 2, utf8, 0, rtreenode, 0, 0);\n  if( rc==SQLITE_OK ){\n    rc = sqlite3_create_function(db, \"rtreedepth\", 1, utf8, 0,rtreedepth, 0, 0);\n  }\n  if( rc==SQLITE_OK ){\n    rc = sqlite3_create_function(db, \"rtreecheck\", -1, utf8, 0,rtreecheck, 0,0);\n  }\n  if( rc==SQLITE_OK ){\n#ifdef SQLITE_RTREE_INT_ONLY\n    void *c = (void *)RTREE_COORD_INT32;\n#else\n    void *c = (void *)RTREE_COORD_REAL32;\n#endif\n    rc = sqlite3_create_module_v2(db, \"rtree\", &rtreeModule, c, 0);\n  }\n  if( rc==SQLITE_OK ){\n    void *c = (void *)RTREE_COORD_INT32;\n    rc = sqlite3_create_module_v2(db, \"rtree_i32\", &rtreeModule, c, 0);\n  }\n#ifdef SQLITE_ENABLE_GEOPOLY\n  if( rc==SQLITE_OK ){\n    rc = sqlite3_geopoly_init(db);\n  }\n#endif\n\n  return rc;\n}\n\n/*\n** This routine deletes the RtreeGeomCallback object that was attached\n** one of the SQL functions create by sqlite3_rtree_geometry_callback()\n** or sqlite3_rtree_query_callback().  In other words, this routine is the\n** destructor for an RtreeGeomCallback objecct.  This routine is called when\n** the corresponding SQL function is deleted.\n*/\nstatic void rtreeFreeCallback(void *p){\n  RtreeGeomCallback *pInfo = (RtreeGeomCallback*)p;\n  if( pInfo->xDestructor ) pInfo->xDestructor(pInfo->pContext);\n  sqlite3_free(p);\n}\n\n/*\n** This routine frees the BLOB that is returned by geomCallback().\n*/\nstatic void rtreeMatchArgFree(void *pArg){\n  int i;\n  RtreeMatchArg *p = (RtreeMatchArg*)pArg;\n  for(i=0; i<p->nParam; i++){\n    sqlite3_value_free(p->apSqlParam[i]);\n  }\n  sqlite3_free(p);\n}\n\n/*\n** Each call to sqlite3_rtree_geometry_callback() or\n** sqlite3_rtree_query_callback() creates an ordinary SQLite\n** scalar function that is implemented by this routine.\n**\n** All this function does is construct an RtreeMatchArg object that\n** contains the geometry-checking callback routines and a list of\n** parameters to this function, then return that RtreeMatchArg object\n** as a BLOB.\n**\n** The R-Tree MATCH operator will read the returned BLOB, deserialize\n** the RtreeMatchArg object, and use the RtreeMatchArg object to figure\n** out which elements of the R-Tree should be returned by the query.\n*/\nstatic void geomCallback(sqlite3_context *ctx, int nArg, sqlite3_value **aArg){\n  RtreeGeomCallback *pGeomCtx = (RtreeGeomCallback *)sqlite3_user_data(ctx);\n  RtreeMatchArg *pBlob;\n  sqlite3_int64 nBlob;\n  int memErr = 0;\n\n  nBlob = sizeof(RtreeMatchArg) + (nArg-1)*sizeof(RtreeDValue)\n           + nArg*sizeof(sqlite3_value*);\n  pBlob = (RtreeMatchArg *)sqlite3_malloc64(nBlob);\n  if( !pBlob ){\n    sqlite3_result_error_nomem(ctx);\n  }else{\n    int i;\n    pBlob->iSize = nBlob;\n    pBlob->cb = pGeomCtx[0];\n    pBlob->apSqlParam = (sqlite3_value**)&pBlob->aParam[nArg];\n    pBlob->nParam = nArg;\n    for(i=0; i<nArg; i++){\n      pBlob->apSqlParam[i] = sqlite3_value_dup(aArg[i]);\n      if( pBlob->apSqlParam[i]==0 ) memErr = 1;\n#ifdef SQLITE_RTREE_INT_ONLY\n      pBlob->aParam[i] = sqlite3_value_int64(aArg[i]);\n#else\n      pBlob->aParam[i] = sqlite3_value_double(aArg[i]);\n#endif\n    }\n    if( memErr ){\n      sqlite3_result_error_nomem(ctx);\n      rtreeMatchArgFree(pBlob);\n    }else{\n      sqlite3_result_pointer(ctx, pBlob, \"RtreeMatchArg\", rtreeMatchArgFree);\n    }\n  }\n}\n\n/*\n** Register a new geometry function for use with the r-tree MATCH operator.\n*/\nSQLITE_API int sqlite3_rtree_geometry_callback(\n  sqlite3 *db,                  /* Register SQL function on this connection */\n  const char *zGeom,            /* Name of the new SQL function */\n  int (*xGeom)(sqlite3_rtree_geometry*,int,RtreeDValue*,int*), /* Callback */\n  void *pContext                /* Extra data associated with the callback */\n){\n  RtreeGeomCallback *pGeomCtx;      /* Context object for new user-function */\n\n  /* Allocate and populate the context object. */\n  pGeomCtx = (RtreeGeomCallback *)sqlite3_malloc(sizeof(RtreeGeomCallback));\n  if( !pGeomCtx ) return SQLITE_NOMEM;\n  pGeomCtx->xGeom = xGeom;\n  pGeomCtx->xQueryFunc = 0;\n  pGeomCtx->xDestructor = 0;\n  pGeomCtx->pContext = pContext;\n  return sqlite3_create_function_v2(db, zGeom, -1, SQLITE_ANY, \n      (void *)pGeomCtx, geomCallback, 0, 0, rtreeFreeCallback\n  );\n}\n\n/*\n** Register a new 2nd-generation geometry function for use with the\n** r-tree MATCH operator.\n*/\nSQLITE_API int sqlite3_rtree_query_callback(\n  sqlite3 *db,                 /* Register SQL function on this connection */\n  const char *zQueryFunc,      /* Name of new SQL function */\n  int (*xQueryFunc)(sqlite3_rtree_query_info*), /* Callback */\n  void *pContext,              /* Extra data passed into the callback */\n  void (*xDestructor)(void*)   /* Destructor for the extra data */\n){\n  RtreeGeomCallback *pGeomCtx;      /* Context object for new user-function */\n\n  /* Allocate and populate the context object. */\n  pGeomCtx = (RtreeGeomCallback *)sqlite3_malloc(sizeof(RtreeGeomCallback));\n  if( !pGeomCtx ) return SQLITE_NOMEM;\n  pGeomCtx->xGeom = 0;\n  pGeomCtx->xQueryFunc = xQueryFunc;\n  pGeomCtx->xDestructor = xDestructor;\n  pGeomCtx->pContext = pContext;\n  return sqlite3_create_function_v2(db, zQueryFunc, -1, SQLITE_ANY, \n      (void *)pGeomCtx, geomCallback, 0, 0, rtreeFreeCallback\n  );\n}\n\n#if !SQLITE_CORE\n#ifdef _WIN32\n__declspec(dllexport)\n#endif\nSQLITE_API int sqlite3_rtree_init(\n  sqlite3 *db,\n  char **pzErrMsg,\n  const sqlite3_api_routines *pApi\n){\n  SQLITE_EXTENSION_INIT2(pApi)\n  return sqlite3RtreeInit(db);\n}\n#endif\n\n#endif\n\n/************** End of rtree.c ***********************************************/\n/************** Begin file icu.c *********************************************/\n/*\n** 2007 May 6\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** $Id: icu.c,v 1.7 2007/12/13 21:54:11 drh Exp $\n**\n** This file implements an integration between the ICU library \n** (\"International Components for Unicode\", an open-source library \n** for handling unicode data) and SQLite. The integration uses \n** ICU to provide the following to SQLite:\n**\n**   * An implementation of the SQL regexp() function (and hence REGEXP\n**     operator) using the ICU uregex_XX() APIs.\n**\n**   * Implementations of the SQL scalar upper() and lower() functions\n**     for case mapping.\n**\n**   * Integration of ICU and SQLite collation sequences.\n**\n**   * An implementation of the LIKE operator that uses ICU to \n**     provide case-independent matching.\n*/\n\n#if !defined(SQLITE_CORE)                  \\\n || defined(SQLITE_ENABLE_ICU)             \\\n || defined(SQLITE_ENABLE_ICU_COLLATIONS)\n\n/* Include ICU headers */\n#include <unicode/utypes.h>\n#include <unicode/uregex.h>\n#include <unicode/ustring.h>\n#include <unicode/ucol.h>\n\n/* #include <assert.h> */\n\n#ifndef SQLITE_CORE\n/*   #include \"sqlite3ext.h\" */\n  SQLITE_EXTENSION_INIT1\n#else\n/*   #include \"sqlite3.h\" */\n#endif\n\n/*\n** This function is called when an ICU function called from within\n** the implementation of an SQL scalar function returns an error.\n**\n** The scalar function context passed as the first argument is \n** loaded with an error message based on the following two args.\n*/\nstatic void icuFunctionError(\n  sqlite3_context *pCtx,       /* SQLite scalar function context */\n  const char *zName,           /* Name of ICU function that failed */\n  UErrorCode e                 /* Error code returned by ICU function */\n){\n  char zBuf[128];\n  sqlite3_snprintf(128, zBuf, \"ICU error: %s(): %s\", zName, u_errorName(e));\n  zBuf[127] = '\\0';\n  sqlite3_result_error(pCtx, zBuf, -1);\n}\n\n#if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_ICU)\n\n/*\n** Maximum length (in bytes) of the pattern in a LIKE or GLOB\n** operator.\n*/\n#ifndef SQLITE_MAX_LIKE_PATTERN_LENGTH\n# define SQLITE_MAX_LIKE_PATTERN_LENGTH 50000\n#endif\n\n/*\n** Version of sqlite3_free() that is always a function, never a macro.\n*/\nstatic void xFree(void *p){\n  sqlite3_free(p);\n}\n\n/*\n** This lookup table is used to help decode the first byte of\n** a multi-byte UTF8 character. It is copied here from SQLite source\n** code file utf8.c.\n*/\nstatic const unsigned char icuUtf8Trans1[] = {\n  0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,\n  0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,\n  0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,\n  0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,\n  0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,\n  0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,\n  0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,\n  0x00, 0x01, 0x02, 0x03, 0x00, 0x01, 0x00, 0x00,\n};\n\n#define SQLITE_ICU_READ_UTF8(zIn, c)                       \\\n  c = *(zIn++);                                            \\\n  if( c>=0xc0 ){                                           \\\n    c = icuUtf8Trans1[c-0xc0];                             \\\n    while( (*zIn & 0xc0)==0x80 ){                          \\\n      c = (c<<6) + (0x3f & *(zIn++));                      \\\n    }                                                      \\\n  }\n\n#define SQLITE_ICU_SKIP_UTF8(zIn)                          \\\n  assert( *zIn );                                          \\\n  if( *(zIn++)>=0xc0 ){                                    \\\n    while( (*zIn & 0xc0)==0x80 ){zIn++;}                   \\\n  }\n\n\n/*\n** Compare two UTF-8 strings for equality where the first string is\n** a \"LIKE\" expression. Return true (1) if they are the same and \n** false (0) if they are different.\n*/\nstatic int icuLikeCompare(\n  const uint8_t *zPattern,   /* LIKE pattern */\n  const uint8_t *zString,    /* The UTF-8 string to compare against */\n  const UChar32 uEsc         /* The escape character */\n){\n  static const uint32_t MATCH_ONE = (uint32_t)'_';\n  static const uint32_t MATCH_ALL = (uint32_t)'%';\n\n  int prevEscape = 0;     /* True if the previous character was uEsc */\n\n  while( 1 ){\n\n    /* Read (and consume) the next character from the input pattern. */\n    uint32_t uPattern;\n    SQLITE_ICU_READ_UTF8(zPattern, uPattern);\n    if( uPattern==0 ) break;\n\n    /* There are now 4 possibilities:\n    **\n    **     1. uPattern is an unescaped match-all character \"%\",\n    **     2. uPattern is an unescaped match-one character \"_\",\n    **     3. uPattern is an unescaped escape character, or\n    **     4. uPattern is to be handled as an ordinary character\n    */\n    if( !prevEscape && uPattern==MATCH_ALL ){\n      /* Case 1. */\n      uint8_t c;\n\n      /* Skip any MATCH_ALL or MATCH_ONE characters that follow a\n      ** MATCH_ALL. For each MATCH_ONE, skip one character in the \n      ** test string.\n      */\n      while( (c=*zPattern) == MATCH_ALL || c == MATCH_ONE ){\n        if( c==MATCH_ONE ){\n          if( *zString==0 ) return 0;\n          SQLITE_ICU_SKIP_UTF8(zString);\n        }\n        zPattern++;\n      }\n\n      if( *zPattern==0 ) return 1;\n\n      while( *zString ){\n        if( icuLikeCompare(zPattern, zString, uEsc) ){\n          return 1;\n        }\n        SQLITE_ICU_SKIP_UTF8(zString);\n      }\n      return 0;\n\n    }else if( !prevEscape && uPattern==MATCH_ONE ){\n      /* Case 2. */\n      if( *zString==0 ) return 0;\n      SQLITE_ICU_SKIP_UTF8(zString);\n\n    }else if( !prevEscape && uPattern==(uint32_t)uEsc){\n      /* Case 3. */\n      prevEscape = 1;\n\n    }else{\n      /* Case 4. */\n      uint32_t uString;\n      SQLITE_ICU_READ_UTF8(zString, uString);\n      uString = (uint32_t)u_foldCase((UChar32)uString, U_FOLD_CASE_DEFAULT);\n      uPattern = (uint32_t)u_foldCase((UChar32)uPattern, U_FOLD_CASE_DEFAULT);\n      if( uString!=uPattern ){\n        return 0;\n      }\n      prevEscape = 0;\n    }\n  }\n\n  return *zString==0;\n}\n\n/*\n** Implementation of the like() SQL function.  This function implements\n** the build-in LIKE operator.  The first argument to the function is the\n** pattern and the second argument is the string.  So, the SQL statements:\n**\n**       A LIKE B\n**\n** is implemented as like(B, A). If there is an escape character E, \n**\n**       A LIKE B ESCAPE E\n**\n** is mapped to like(B, A, E).\n*/\nstatic void icuLikeFunc(\n  sqlite3_context *context, \n  int argc, \n  sqlite3_value **argv\n){\n  const unsigned char *zA = sqlite3_value_text(argv[0]);\n  const unsigned char *zB = sqlite3_value_text(argv[1]);\n  UChar32 uEsc = 0;\n\n  /* Limit the length of the LIKE or GLOB pattern to avoid problems\n  ** of deep recursion and N*N behavior in patternCompare().\n  */\n  if( sqlite3_value_bytes(argv[0])>SQLITE_MAX_LIKE_PATTERN_LENGTH ){\n    sqlite3_result_error(context, \"LIKE or GLOB pattern too complex\", -1);\n    return;\n  }\n\n\n  if( argc==3 ){\n    /* The escape character string must consist of a single UTF-8 character.\n    ** Otherwise, return an error.\n    */\n    int nE= sqlite3_value_bytes(argv[2]);\n    const unsigned char *zE = sqlite3_value_text(argv[2]);\n    int i = 0;\n    if( zE==0 ) return;\n    U8_NEXT(zE, i, nE, uEsc);\n    if( i!=nE){\n      sqlite3_result_error(context, \n          \"ESCAPE expression must be a single character\", -1);\n      return;\n    }\n  }\n\n  if( zA && zB ){\n    sqlite3_result_int(context, icuLikeCompare(zA, zB, uEsc));\n  }\n}\n\n/*\n** Function to delete compiled regexp objects. Registered as\n** a destructor function with sqlite3_set_auxdata().\n*/\nstatic void icuRegexpDelete(void *p){\n  URegularExpression *pExpr = (URegularExpression *)p;\n  uregex_close(pExpr);\n}\n\n/*\n** Implementation of SQLite REGEXP operator. This scalar function takes\n** two arguments. The first is a regular expression pattern to compile\n** the second is a string to match against that pattern. If either \n** argument is an SQL NULL, then NULL Is returned. Otherwise, the result\n** is 1 if the string matches the pattern, or 0 otherwise.\n**\n** SQLite maps the regexp() function to the regexp() operator such\n** that the following two are equivalent:\n**\n**     zString REGEXP zPattern\n**     regexp(zPattern, zString)\n**\n** Uses the following ICU regexp APIs:\n**\n**     uregex_open()\n**     uregex_matches()\n**     uregex_close()\n*/\nstatic void icuRegexpFunc(sqlite3_context *p, int nArg, sqlite3_value **apArg){\n  UErrorCode status = U_ZERO_ERROR;\n  URegularExpression *pExpr;\n  UBool res;\n  const UChar *zString = sqlite3_value_text16(apArg[1]);\n\n  (void)nArg;  /* Unused parameter */\n\n  /* If the left hand side of the regexp operator is NULL, \n  ** then the result is also NULL. \n  */\n  if( !zString ){\n    return;\n  }\n\n  pExpr = sqlite3_get_auxdata(p, 0);\n  if( !pExpr ){\n    const UChar *zPattern = sqlite3_value_text16(apArg[0]);\n    if( !zPattern ){\n      return;\n    }\n    pExpr = uregex_open(zPattern, -1, 0, 0, &status);\n\n    if( U_SUCCESS(status) ){\n      sqlite3_set_auxdata(p, 0, pExpr, icuRegexpDelete);\n    }else{\n      assert(!pExpr);\n      icuFunctionError(p, \"uregex_open\", status);\n      return;\n    }\n  }\n\n  /* Configure the text that the regular expression operates on. */\n  uregex_setText(pExpr, zString, -1, &status);\n  if( !U_SUCCESS(status) ){\n    icuFunctionError(p, \"uregex_setText\", status);\n    return;\n  }\n\n  /* Attempt the match */\n  res = uregex_matches(pExpr, 0, &status);\n  if( !U_SUCCESS(status) ){\n    icuFunctionError(p, \"uregex_matches\", status);\n    return;\n  }\n\n  /* Set the text that the regular expression operates on to a NULL\n  ** pointer. This is not really necessary, but it is tidier than \n  ** leaving the regular expression object configured with an invalid\n  ** pointer after this function returns.\n  */\n  uregex_setText(pExpr, 0, 0, &status);\n\n  /* Return 1 or 0. */\n  sqlite3_result_int(p, res ? 1 : 0);\n}\n\n/*\n** Implementations of scalar functions for case mapping - upper() and \n** lower(). Function upper() converts its input to upper-case (ABC).\n** Function lower() converts to lower-case (abc).\n**\n** ICU provides two types of case mapping, \"general\" case mapping and\n** \"language specific\". Refer to ICU documentation for the differences\n** between the two.\n**\n** To utilise \"general\" case mapping, the upper() or lower() scalar \n** functions are invoked with one argument:\n**\n**     upper('ABC') -> 'abc'\n**     lower('abc') -> 'ABC'\n**\n** To access ICU \"language specific\" case mapping, upper() or lower()\n** should be invoked with two arguments. The second argument is the name\n** of the locale to use. Passing an empty string (\"\") or SQL NULL value\n** as the second argument is the same as invoking the 1 argument version\n** of upper() or lower().\n**\n**     lower('I', 'en_us') -> 'i'\n**     lower('I', 'tr_tr') -> '\\u131' (small dotless i)\n**\n** http://www.icu-project.org/userguide/posix.html#case_mappings\n*/\nstatic void icuCaseFunc16(sqlite3_context *p, int nArg, sqlite3_value **apArg){\n  const UChar *zInput;            /* Pointer to input string */\n  UChar *zOutput = 0;             /* Pointer to output buffer */\n  int nInput;                     /* Size of utf-16 input string in bytes */\n  int nOut;                       /* Size of output buffer in bytes */\n  int cnt;\n  int bToUpper;                   /* True for toupper(), false for tolower() */\n  UErrorCode status;\n  const char *zLocale = 0;\n\n  assert(nArg==1 || nArg==2);\n  bToUpper = (sqlite3_user_data(p)!=0);\n  if( nArg==2 ){\n    zLocale = (const char *)sqlite3_value_text(apArg[1]);\n  }\n\n  zInput = sqlite3_value_text16(apArg[0]);\n  if( !zInput ){\n    return;\n  }\n  nOut = nInput = sqlite3_value_bytes16(apArg[0]);\n  if( nOut==0 ){\n    sqlite3_result_text16(p, \"\", 0, SQLITE_STATIC);\n    return;\n  }\n\n  for(cnt=0; cnt<2; cnt++){\n    UChar *zNew = sqlite3_realloc(zOutput, nOut);\n    if( zNew==0 ){\n      sqlite3_free(zOutput);\n      sqlite3_result_error_nomem(p);\n      return;\n    }\n    zOutput = zNew;\n    status = U_ZERO_ERROR;\n    if( bToUpper ){\n      nOut = 2*u_strToUpper(zOutput,nOut/2,zInput,nInput/2,zLocale,&status);\n    }else{\n      nOut = 2*u_strToLower(zOutput,nOut/2,zInput,nInput/2,zLocale,&status);\n    }\n\n    if( U_SUCCESS(status) ){\n      sqlite3_result_text16(p, zOutput, nOut, xFree);\n    }else if( status==U_BUFFER_OVERFLOW_ERROR ){\n      assert( cnt==0 );\n      continue;\n    }else{\n      icuFunctionError(p, bToUpper ? \"u_strToUpper\" : \"u_strToLower\", status);\n    }\n    return;\n  }\n  assert( 0 );     /* Unreachable */\n}\n\n#endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_ICU) */\n\n/*\n** Collation sequence destructor function. The pCtx argument points to\n** a UCollator structure previously allocated using ucol_open().\n*/\nstatic void icuCollationDel(void *pCtx){\n  UCollator *p = (UCollator *)pCtx;\n  ucol_close(p);\n}\n\n/*\n** Collation sequence comparison function. The pCtx argument points to\n** a UCollator structure previously allocated using ucol_open().\n*/\nstatic int icuCollationColl(\n  void *pCtx,\n  int nLeft,\n  const void *zLeft,\n  int nRight,\n  const void *zRight\n){\n  UCollationResult res;\n  UCollator *p = (UCollator *)pCtx;\n  res = ucol_strcoll(p, (UChar *)zLeft, nLeft/2, (UChar *)zRight, nRight/2);\n  switch( res ){\n    case UCOL_LESS:    return -1;\n    case UCOL_GREATER: return +1;\n    case UCOL_EQUAL:   return 0;\n  }\n  assert(!\"Unexpected return value from ucol_strcoll()\");\n  return 0;\n}\n\n/*\n** Implementation of the scalar function icu_load_collation().\n**\n** This scalar function is used to add ICU collation based collation \n** types to an SQLite database connection. It is intended to be called\n** as follows:\n**\n**     SELECT icu_load_collation(<locale>, <collation-name>);\n**\n** Where <locale> is a string containing an ICU locale identifier (i.e.\n** \"en_AU\", \"tr_TR\" etc.) and <collation-name> is the name of the\n** collation sequence to create.\n*/\nstatic void icuLoadCollation(\n  sqlite3_context *p, \n  int nArg, \n  sqlite3_value **apArg\n){\n  sqlite3 *db = (sqlite3 *)sqlite3_user_data(p);\n  UErrorCode status = U_ZERO_ERROR;\n  const char *zLocale;      /* Locale identifier - (eg. \"jp_JP\") */\n  const char *zName;        /* SQL Collation sequence name (eg. \"japanese\") */\n  UCollator *pUCollator;    /* ICU library collation object */\n  int rc;                   /* Return code from sqlite3_create_collation_x() */\n\n  assert(nArg==2);\n  (void)nArg; /* Unused parameter */\n  zLocale = (const char *)sqlite3_value_text(apArg[0]);\n  zName = (const char *)sqlite3_value_text(apArg[1]);\n\n  if( !zLocale || !zName ){\n    return;\n  }\n\n  pUCollator = ucol_open(zLocale, &status);\n  if( !U_SUCCESS(status) ){\n    icuFunctionError(p, \"ucol_open\", status);\n    return;\n  }\n  assert(p);\n\n  rc = sqlite3_create_collation_v2(db, zName, SQLITE_UTF16, (void *)pUCollator, \n      icuCollationColl, icuCollationDel\n  );\n  if( rc!=SQLITE_OK ){\n    ucol_close(pUCollator);\n    sqlite3_result_error(p, \"Error registering collation function\", -1);\n  }\n}\n\n/*\n** Register the ICU extension functions with database db.\n*/\nSQLITE_PRIVATE int sqlite3IcuInit(sqlite3 *db){\n  static const struct IcuScalar {\n    const char *zName;                        /* Function name */\n    unsigned char nArg;                       /* Number of arguments */\n    unsigned short enc;                       /* Optimal text encoding */\n    unsigned char iContext;                   /* sqlite3_user_data() context */\n    void (*xFunc)(sqlite3_context*,int,sqlite3_value**);\n  } scalars[] = {\n    {\"icu_load_collation\",  2, SQLITE_UTF8,                1, icuLoadCollation},\n#if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_ICU)\n    {\"regexp\", 2, SQLITE_ANY|SQLITE_DETERMINISTIC,         0, icuRegexpFunc},\n    {\"lower\",  1, SQLITE_UTF16|SQLITE_DETERMINISTIC,       0, icuCaseFunc16},\n    {\"lower\",  2, SQLITE_UTF16|SQLITE_DETERMINISTIC,       0, icuCaseFunc16},\n    {\"upper\",  1, SQLITE_UTF16|SQLITE_DETERMINISTIC,       1, icuCaseFunc16},\n    {\"upper\",  2, SQLITE_UTF16|SQLITE_DETERMINISTIC,       1, icuCaseFunc16},\n    {\"lower\",  1, SQLITE_UTF8|SQLITE_DETERMINISTIC,        0, icuCaseFunc16},\n    {\"lower\",  2, SQLITE_UTF8|SQLITE_DETERMINISTIC,        0, icuCaseFunc16},\n    {\"upper\",  1, SQLITE_UTF8|SQLITE_DETERMINISTIC,        1, icuCaseFunc16},\n    {\"upper\",  2, SQLITE_UTF8|SQLITE_DETERMINISTIC,        1, icuCaseFunc16},\n    {\"like\",   2, SQLITE_UTF8|SQLITE_DETERMINISTIC,        0, icuLikeFunc},\n    {\"like\",   3, SQLITE_UTF8|SQLITE_DETERMINISTIC,        0, icuLikeFunc},\n#endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_ICU) */\n  };\n  int rc = SQLITE_OK;\n  int i;\n  \n  for(i=0; rc==SQLITE_OK && i<(int)(sizeof(scalars)/sizeof(scalars[0])); i++){\n    const struct IcuScalar *p = &scalars[i];\n    rc = sqlite3_create_function(\n        db, p->zName, p->nArg, p->enc, \n        p->iContext ? (void*)db : (void*)0,\n        p->xFunc, 0, 0\n    );\n  }\n\n  return rc;\n}\n\n#if !SQLITE_CORE\n#ifdef _WIN32\n__declspec(dllexport)\n#endif\nSQLITE_API int sqlite3_icu_init(\n  sqlite3 *db, \n  char **pzErrMsg,\n  const sqlite3_api_routines *pApi\n){\n  SQLITE_EXTENSION_INIT2(pApi)\n  return sqlite3IcuInit(db);\n}\n#endif\n\n#endif\n\n/************** End of icu.c *************************************************/\n/************** Begin file fts3_icu.c ****************************************/\n/*\n** 2007 June 22\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This file implements a tokenizer for fts3 based on the ICU library.\n*/\n/* #include \"fts3Int.h\" */\n#if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3)\n#ifdef SQLITE_ENABLE_ICU\n\n/* #include <assert.h> */\n/* #include <string.h> */\n/* #include \"fts3_tokenizer.h\" */\n\n#include <unicode/ubrk.h>\n/* #include <unicode/ucol.h> */\n/* #include <unicode/ustring.h> */\n#include <unicode/utf16.h>\n\ntypedef struct IcuTokenizer IcuTokenizer;\ntypedef struct IcuCursor IcuCursor;\n\nstruct IcuTokenizer {\n  sqlite3_tokenizer base;\n  char *zLocale;\n};\n\nstruct IcuCursor {\n  sqlite3_tokenizer_cursor base;\n\n  UBreakIterator *pIter;      /* ICU break-iterator object */\n  int nChar;                  /* Number of UChar elements in pInput */\n  UChar *aChar;               /* Copy of input using utf-16 encoding */\n  int *aOffset;               /* Offsets of each character in utf-8 input */\n\n  int nBuffer;\n  char *zBuffer;\n\n  int iToken;\n};\n\n/*\n** Create a new tokenizer instance.\n*/\nstatic int icuCreate(\n  int argc,                            /* Number of entries in argv[] */\n  const char * const *argv,            /* Tokenizer creation arguments */\n  sqlite3_tokenizer **ppTokenizer      /* OUT: Created tokenizer */\n){\n  IcuTokenizer *p;\n  int n = 0;\n\n  if( argc>0 ){\n    n = strlen(argv[0])+1;\n  }\n  p = (IcuTokenizer *)sqlite3_malloc64(sizeof(IcuTokenizer)+n);\n  if( !p ){\n    return SQLITE_NOMEM;\n  }\n  memset(p, 0, sizeof(IcuTokenizer));\n\n  if( n ){\n    p->zLocale = (char *)&p[1];\n    memcpy(p->zLocale, argv[0], n);\n  }\n\n  *ppTokenizer = (sqlite3_tokenizer *)p;\n\n  return SQLITE_OK;\n}\n\n/*\n** Destroy a tokenizer\n*/\nstatic int icuDestroy(sqlite3_tokenizer *pTokenizer){\n  IcuTokenizer *p = (IcuTokenizer *)pTokenizer;\n  sqlite3_free(p);\n  return SQLITE_OK;\n}\n\n/*\n** Prepare to begin tokenizing a particular string.  The input\n** string to be tokenized is pInput[0..nBytes-1].  A cursor\n** used to incrementally tokenize this string is returned in \n** *ppCursor.\n*/\nstatic int icuOpen(\n  sqlite3_tokenizer *pTokenizer,         /* The tokenizer */\n  const char *zInput,                    /* Input string */\n  int nInput,                            /* Length of zInput in bytes */\n  sqlite3_tokenizer_cursor **ppCursor    /* OUT: Tokenization cursor */\n){\n  IcuTokenizer *p = (IcuTokenizer *)pTokenizer;\n  IcuCursor *pCsr;\n\n  const int32_t opt = U_FOLD_CASE_DEFAULT;\n  UErrorCode status = U_ZERO_ERROR;\n  int nChar;\n\n  UChar32 c;\n  int iInput = 0;\n  int iOut = 0;\n\n  *ppCursor = 0;\n\n  if( zInput==0 ){\n    nInput = 0;\n    zInput = \"\";\n  }else if( nInput<0 ){\n    nInput = strlen(zInput);\n  }\n  nChar = nInput+1;\n  pCsr = (IcuCursor *)sqlite3_malloc64(\n      sizeof(IcuCursor) +                /* IcuCursor */\n      ((nChar+3)&~3) * sizeof(UChar) +   /* IcuCursor.aChar[] */\n      (nChar+1) * sizeof(int)            /* IcuCursor.aOffset[] */\n  );\n  if( !pCsr ){\n    return SQLITE_NOMEM;\n  }\n  memset(pCsr, 0, sizeof(IcuCursor));\n  pCsr->aChar = (UChar *)&pCsr[1];\n  pCsr->aOffset = (int *)&pCsr->aChar[(nChar+3)&~3];\n\n  pCsr->aOffset[iOut] = iInput;\n  U8_NEXT(zInput, iInput, nInput, c); \n  while( c>0 ){\n    int isError = 0;\n    c = u_foldCase(c, opt);\n    U16_APPEND(pCsr->aChar, iOut, nChar, c, isError);\n    if( isError ){\n      sqlite3_free(pCsr);\n      return SQLITE_ERROR;\n    }\n    pCsr->aOffset[iOut] = iInput;\n\n    if( iInput<nInput ){\n      U8_NEXT(zInput, iInput, nInput, c);\n    }else{\n      c = 0;\n    }\n  }\n\n  pCsr->pIter = ubrk_open(UBRK_WORD, p->zLocale, pCsr->aChar, iOut, &status);\n  if( !U_SUCCESS(status) ){\n    sqlite3_free(pCsr);\n    return SQLITE_ERROR;\n  }\n  pCsr->nChar = iOut;\n\n  ubrk_first(pCsr->pIter);\n  *ppCursor = (sqlite3_tokenizer_cursor *)pCsr;\n  return SQLITE_OK;\n}\n\n/*\n** Close a tokenization cursor previously opened by a call to icuOpen().\n*/\nstatic int icuClose(sqlite3_tokenizer_cursor *pCursor){\n  IcuCursor *pCsr = (IcuCursor *)pCursor;\n  ubrk_close(pCsr->pIter);\n  sqlite3_free(pCsr->zBuffer);\n  sqlite3_free(pCsr);\n  return SQLITE_OK;\n}\n\n/*\n** Extract the next token from a tokenization cursor.\n*/\nstatic int icuNext(\n  sqlite3_tokenizer_cursor *pCursor,  /* Cursor returned by simpleOpen */\n  const char **ppToken,               /* OUT: *ppToken is the token text */\n  int *pnBytes,                       /* OUT: Number of bytes in token */\n  int *piStartOffset,                 /* OUT: Starting offset of token */\n  int *piEndOffset,                   /* OUT: Ending offset of token */\n  int *piPosition                     /* OUT: Position integer of token */\n){\n  IcuCursor *pCsr = (IcuCursor *)pCursor;\n\n  int iStart = 0;\n  int iEnd = 0;\n  int nByte = 0;\n\n  while( iStart==iEnd ){\n    UChar32 c;\n\n    iStart = ubrk_current(pCsr->pIter);\n    iEnd = ubrk_next(pCsr->pIter);\n    if( iEnd==UBRK_DONE ){\n      return SQLITE_DONE;\n    }\n\n    while( iStart<iEnd ){\n      int iWhite = iStart;\n      U16_NEXT(pCsr->aChar, iWhite, pCsr->nChar, c);\n      if( u_isspace(c) ){\n        iStart = iWhite;\n      }else{\n        break;\n      }\n    }\n    assert(iStart<=iEnd);\n  }\n\n  do {\n    UErrorCode status = U_ZERO_ERROR;\n    if( nByte ){\n      char *zNew = sqlite3_realloc(pCsr->zBuffer, nByte);\n      if( !zNew ){\n        return SQLITE_NOMEM;\n      }\n      pCsr->zBuffer = zNew;\n      pCsr->nBuffer = nByte;\n    }\n\n    u_strToUTF8(\n        pCsr->zBuffer, pCsr->nBuffer, &nByte,    /* Output vars */\n        &pCsr->aChar[iStart], iEnd-iStart,       /* Input vars */\n        &status                                  /* Output success/failure */\n    );\n  } while( nByte>pCsr->nBuffer );\n\n  *ppToken = pCsr->zBuffer;\n  *pnBytes = nByte;\n  *piStartOffset = pCsr->aOffset[iStart];\n  *piEndOffset = pCsr->aOffset[iEnd];\n  *piPosition = pCsr->iToken++;\n\n  return SQLITE_OK;\n}\n\n/*\n** The set of routines that implement the simple tokenizer\n*/\nstatic const sqlite3_tokenizer_module icuTokenizerModule = {\n  0,                           /* iVersion    */\n  icuCreate,                   /* xCreate     */\n  icuDestroy,                  /* xCreate     */\n  icuOpen,                     /* xOpen       */\n  icuClose,                    /* xClose      */\n  icuNext,                     /* xNext       */\n  0,                           /* xLanguageid */\n};\n\n/*\n** Set *ppModule to point at the implementation of the ICU tokenizer.\n*/\nSQLITE_PRIVATE void sqlite3Fts3IcuTokenizerModule(\n  sqlite3_tokenizer_module const**ppModule\n){\n  *ppModule = &icuTokenizerModule;\n}\n\n#endif /* defined(SQLITE_ENABLE_ICU) */\n#endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3) */\n\n/************** End of fts3_icu.c ********************************************/\n/************** Begin file sqlite3rbu.c **************************************/\n/*\n** 2014 August 30\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n**\n**\n** OVERVIEW \n**\n**  The RBU extension requires that the RBU update be packaged as an\n**  SQLite database. The tables it expects to find are described in\n**  sqlite3rbu.h.  Essentially, for each table xyz in the target database\n**  that the user wishes to write to, a corresponding data_xyz table is\n**  created in the RBU database and populated with one row for each row to\n**  update, insert or delete from the target table.\n** \n**  The update proceeds in three stages:\n** \n**  1) The database is updated. The modified database pages are written\n**     to a *-oal file. A *-oal file is just like a *-wal file, except\n**     that it is named \"<database>-oal\" instead of \"<database>-wal\".\n**     Because regular SQLite clients do not look for file named\n**     \"<database>-oal\", they go on using the original database in\n**     rollback mode while the *-oal file is being generated.\n** \n**     During this stage RBU does not update the database by writing\n**     directly to the target tables. Instead it creates \"imposter\"\n**     tables using the SQLITE_TESTCTRL_IMPOSTER interface that it uses\n**     to update each b-tree individually. All updates required by each\n**     b-tree are completed before moving on to the next, and all\n**     updates are done in sorted key order.\n** \n**  2) The \"<database>-oal\" file is moved to the equivalent \"<database>-wal\"\n**     location using a call to rename(2). Before doing this the RBU\n**     module takes an EXCLUSIVE lock on the database file, ensuring\n**     that there are no other active readers.\n** \n**     Once the EXCLUSIVE lock is released, any other database readers\n**     detect the new *-wal file and read the database in wal mode. At\n**     this point they see the new version of the database - including\n**     the updates made as part of the RBU update.\n** \n**  3) The new *-wal file is checkpointed. This proceeds in the same way \n**     as a regular database checkpoint, except that a single frame is\n**     checkpointed each time sqlite3rbu_step() is called. If the RBU\n**     handle is closed before the entire *-wal file is checkpointed,\n**     the checkpoint progress is saved in the RBU database and the\n**     checkpoint can be resumed by another RBU client at some point in\n**     the future.\n**\n** POTENTIAL PROBLEMS\n** \n**  The rename() call might not be portable. And RBU is not currently\n**  syncing the directory after renaming the file.\n**\n**  When state is saved, any commit to the *-oal file and the commit to\n**  the RBU update database are not atomic. So if the power fails at the\n**  wrong moment they might get out of sync. As the main database will be\n**  committed before the RBU update database this will likely either just\n**  pass unnoticed, or result in SQLITE_CONSTRAINT errors (due to UNIQUE\n**  constraint violations).\n**\n**  If some client does modify the target database mid RBU update, or some\n**  other error occurs, the RBU extension will keep throwing errors. It's\n**  not really clear how to get out of this state. The system could just\n**  by delete the RBU update database and *-oal file and have the device\n**  download the update again and start over.\n**\n**  At present, for an UPDATE, both the new.* and old.* records are\n**  collected in the rbu_xyz table. And for both UPDATEs and DELETEs all\n**  fields are collected.  This means we're probably writing a lot more\n**  data to disk when saving the state of an ongoing update to the RBU\n**  update database than is strictly necessary.\n** \n*/\n\n/* #include <assert.h> */\n/* #include <string.h> */\n/* #include <stdio.h> */\n\n/* #include \"sqlite3.h\" */\n\n#if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_RBU)\n/************** Include sqlite3rbu.h in the middle of sqlite3rbu.c ***********/\n/************** Begin file sqlite3rbu.h **************************************/\n/*\n** 2014 August 30\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n**\n** This file contains the public interface for the RBU extension. \n*/\n\n/*\n** SUMMARY\n**\n** Writing a transaction containing a large number of operations on \n** b-tree indexes that are collectively larger than the available cache\n** memory can be very inefficient. \n**\n** The problem is that in order to update a b-tree, the leaf page (at least)\n** containing the entry being inserted or deleted must be modified. If the\n** working set of leaves is larger than the available cache memory, then a \n** single leaf that is modified more than once as part of the transaction \n** may be loaded from or written to the persistent media multiple times.\n** Additionally, because the index updates are likely to be applied in\n** random order, access to pages within the database is also likely to be in \n** random order, which is itself quite inefficient.\n**\n** One way to improve the situation is to sort the operations on each index\n** by index key before applying them to the b-tree. This leads to an IO\n** pattern that resembles a single linear scan through the index b-tree,\n** and all but guarantees each modified leaf page is loaded and stored \n** exactly once. SQLite uses this trick to improve the performance of\n** CREATE INDEX commands. This extension allows it to be used to improve\n** the performance of large transactions on existing databases.\n**\n** Additionally, this extension allows the work involved in writing the \n** large transaction to be broken down into sub-transactions performed \n** sequentially by separate processes. This is useful if the system cannot \n** guarantee that a single update process will run for long enough to apply \n** the entire update, for example because the update is being applied on a \n** mobile device that is frequently rebooted. Even after the writer process \n** has committed one or more sub-transactions, other database clients continue\n** to read from the original database snapshot. In other words, partially \n** applied transactions are not visible to other clients. \n**\n** \"RBU\" stands for \"Resumable Bulk Update\". As in a large database update\n** transmitted via a wireless network to a mobile device. A transaction\n** applied using this extension is hence refered to as an \"RBU update\".\n**\n**\n** LIMITATIONS\n**\n** An \"RBU update\" transaction is subject to the following limitations:\n**\n**   * The transaction must consist of INSERT, UPDATE and DELETE operations\n**     only.\n**\n**   * INSERT statements may not use any default values.\n**\n**   * UPDATE and DELETE statements must identify their target rows by \n**     non-NULL PRIMARY KEY values. Rows with NULL values stored in PRIMARY\n**     KEY fields may not be updated or deleted. If the table being written \n**     has no PRIMARY KEY, affected rows must be identified by rowid.\n**\n**   * UPDATE statements may not modify PRIMARY KEY columns.\n**\n**   * No triggers will be fired.\n**\n**   * No foreign key violations are detected or reported.\n**\n**   * CHECK constraints are not enforced.\n**\n**   * No constraint handling mode except for \"OR ROLLBACK\" is supported.\n**\n**\n** PREPARATION\n**\n** An \"RBU update\" is stored as a separate SQLite database. A database\n** containing an RBU update is an \"RBU database\". For each table in the \n** target database to be updated, the RBU database should contain a table\n** named \"data_<target name>\" containing the same set of columns as the\n** target table, and one more - \"rbu_control\". The data_% table should \n** have no PRIMARY KEY or UNIQUE constraints, but each column should have\n** the same type as the corresponding column in the target database.\n** The \"rbu_control\" column should have no type at all. For example, if\n** the target database contains:\n**\n**   CREATE TABLE t1(a INTEGER PRIMARY KEY, b TEXT, c UNIQUE);\n**\n** Then the RBU database should contain:\n**\n**   CREATE TABLE data_t1(a INTEGER, b TEXT, c, rbu_control);\n**\n** The order of the columns in the data_% table does not matter.\n**\n** Instead of a regular table, the RBU database may also contain virtual\n** tables or view named using the data_<target> naming scheme. \n**\n** Instead of the plain data_<target> naming scheme, RBU database tables \n** may also be named data<integer>_<target>, where <integer> is any sequence\n** of zero or more numeric characters (0-9). This can be significant because\n** tables within the RBU database are always processed in order sorted by \n** name. By judicious selection of the <integer> portion of the names\n** of the RBU tables the user can therefore control the order in which they\n** are processed. This can be useful, for example, to ensure that \"external\n** content\" FTS4 tables are updated before their underlying content tables.\n**\n** If the target database table is a virtual table or a table that has no\n** PRIMARY KEY declaration, the data_% table must also contain a column \n** named \"rbu_rowid\". This column is mapped to the tables implicit primary \n** key column - \"rowid\". Virtual tables for which the \"rowid\" column does \n** not function like a primary key value cannot be updated using RBU. For \n** example, if the target db contains either of the following:\n**\n**   CREATE VIRTUAL TABLE x1 USING fts3(a, b);\n**   CREATE TABLE x1(a, b)\n**\n** then the RBU database should contain:\n**\n**   CREATE TABLE data_x1(a, b, rbu_rowid, rbu_control);\n**\n** All non-hidden columns (i.e. all columns matched by \"SELECT *\") of the\n** target table must be present in the input table. For virtual tables,\n** hidden columns are optional - they are updated by RBU if present in\n** the input table, or not otherwise. For example, to write to an fts4\n** table with a hidden languageid column such as:\n**\n**   CREATE VIRTUAL TABLE ft1 USING fts4(a, b, languageid='langid');\n**\n** Either of the following input table schemas may be used:\n**\n**   CREATE TABLE data_ft1(a, b, langid, rbu_rowid, rbu_control);\n**   CREATE TABLE data_ft1(a, b, rbu_rowid, rbu_control);\n**\n** For each row to INSERT into the target database as part of the RBU \n** update, the corresponding data_% table should contain a single record\n** with the \"rbu_control\" column set to contain integer value 0. The\n** other columns should be set to the values that make up the new record \n** to insert. \n**\n** If the target database table has an INTEGER PRIMARY KEY, it is not \n** possible to insert a NULL value into the IPK column. Attempting to \n** do so results in an SQLITE_MISMATCH error.\n**\n** For each row to DELETE from the target database as part of the RBU \n** update, the corresponding data_% table should contain a single record\n** with the \"rbu_control\" column set to contain integer value 1. The\n** real primary key values of the row to delete should be stored in the\n** corresponding columns of the data_% table. The values stored in the\n** other columns are not used.\n**\n** For each row to UPDATE from the target database as part of the RBU \n** update, the corresponding data_% table should contain a single record\n** with the \"rbu_control\" column set to contain a value of type text.\n** The real primary key values identifying the row to update should be \n** stored in the corresponding columns of the data_% table row, as should\n** the new values of all columns being update. The text value in the \n** \"rbu_control\" column must contain the same number of characters as\n** there are columns in the target database table, and must consist entirely\n** of 'x' and '.' characters (or in some special cases 'd' - see below). For \n** each column that is being updated, the corresponding character is set to\n** 'x'. For those that remain as they are, the corresponding character of the\n** rbu_control value should be set to '.'. For example, given the tables \n** above, the update statement:\n**\n**   UPDATE t1 SET c = 'usa' WHERE a = 4;\n**\n** is represented by the data_t1 row created by:\n**\n**   INSERT INTO data_t1(a, b, c, rbu_control) VALUES(4, NULL, 'usa', '..x');\n**\n** Instead of an 'x' character, characters of the rbu_control value specified\n** for UPDATEs may also be set to 'd'. In this case, instead of updating the\n** target table with the value stored in the corresponding data_% column, the\n** user-defined SQL function \"rbu_delta()\" is invoked and the result stored in\n** the target table column. rbu_delta() is invoked with two arguments - the\n** original value currently stored in the target table column and the \n** value specified in the data_xxx table.\n**\n** For example, this row:\n**\n**   INSERT INTO data_t1(a, b, c, rbu_control) VALUES(4, NULL, 'usa', '..d');\n**\n** is similar to an UPDATE statement such as: \n**\n**   UPDATE t1 SET c = rbu_delta(c, 'usa') WHERE a = 4;\n**\n** Finally, if an 'f' character appears in place of a 'd' or 's' in an \n** ota_control string, the contents of the data_xxx table column is assumed\n** to be a \"fossil delta\" - a patch to be applied to a blob value in the\n** format used by the fossil source-code management system. In this case\n** the existing value within the target database table must be of type BLOB. \n** It is replaced by the result of applying the specified fossil delta to\n** itself.\n**\n** If the target database table is a virtual table or a table with no PRIMARY\n** KEY, the rbu_control value should not include a character corresponding \n** to the rbu_rowid value. For example, this:\n**\n**   INSERT INTO data_ft1(a, b, rbu_rowid, rbu_control) \n**       VALUES(NULL, 'usa', 12, '.x');\n**\n** causes a result similar to:\n**\n**   UPDATE ft1 SET b = 'usa' WHERE rowid = 12;\n**\n** The data_xxx tables themselves should have no PRIMARY KEY declarations.\n** However, RBU is more efficient if reading the rows in from each data_xxx\n** table in \"rowid\" order is roughly the same as reading them sorted by\n** the PRIMARY KEY of the corresponding target database table. In other \n** words, rows should be sorted using the destination table PRIMARY KEY \n** fields before they are inserted into the data_xxx tables.\n**\n** USAGE\n**\n** The API declared below allows an application to apply an RBU update \n** stored on disk to an existing target database. Essentially, the \n** application:\n**\n**     1) Opens an RBU handle using the sqlite3rbu_open() function.\n**\n**     2) Registers any required virtual table modules with the database\n**        handle returned by sqlite3rbu_db(). Also, if required, register\n**        the rbu_delta() implementation.\n**\n**     3) Calls the sqlite3rbu_step() function one or more times on\n**        the new handle. Each call to sqlite3rbu_step() performs a single\n**        b-tree operation, so thousands of calls may be required to apply \n**        a complete update.\n**\n**     4) Calls sqlite3rbu_close() to close the RBU update handle. If\n**        sqlite3rbu_step() has been called enough times to completely\n**        apply the update to the target database, then the RBU database\n**        is marked as fully applied. Otherwise, the state of the RBU \n**        update application is saved in the RBU database for later \n**        resumption.\n**\n** See comments below for more detail on APIs.\n**\n** If an update is only partially applied to the target database by the\n** time sqlite3rbu_close() is called, various state information is saved \n** within the RBU database. This allows subsequent processes to automatically\n** resume the RBU update from where it left off.\n**\n** To remove all RBU extension state information, returning an RBU database \n** to its original contents, it is sufficient to drop all tables that begin\n** with the prefix \"rbu_\"\n**\n** DATABASE LOCKING\n**\n** An RBU update may not be applied to a database in WAL mode. Attempting\n** to do so is an error (SQLITE_ERROR).\n**\n** While an RBU handle is open, a SHARED lock may be held on the target\n** database file. This means it is possible for other clients to read the\n** database, but not to write it.\n**\n** If an RBU update is started and then suspended before it is completed,\n** then an external client writes to the database, then attempting to resume\n** the suspended RBU update is also an error (SQLITE_BUSY).\n*/\n\n#ifndef _SQLITE3RBU_H\n#define _SQLITE3RBU_H\n\n/* #include \"sqlite3.h\"              ** Required for error code definitions ** */\n\n#if 0\nextern \"C\" {\n#endif\n\ntypedef struct sqlite3rbu sqlite3rbu;\n\n/*\n** Open an RBU handle.\n**\n** Argument zTarget is the path to the target database. Argument zRbu is\n** the path to the RBU database. Each call to this function must be matched\n** by a call to sqlite3rbu_close(). When opening the databases, RBU passes\n** the SQLITE_CONFIG_URI flag to sqlite3_open_v2(). So if either zTarget\n** or zRbu begin with \"file:\", it will be interpreted as an SQLite \n** database URI, not a regular file name.\n**\n** If the zState argument is passed a NULL value, the RBU extension stores \n** the current state of the update (how many rows have been updated, which \n** indexes are yet to be updated etc.) within the RBU database itself. This\n** can be convenient, as it means that the RBU application does not need to\n** organize removing a separate state file after the update is concluded. \n** Or, if zState is non-NULL, it must be a path to a database file in which \n** the RBU extension can store the state of the update.\n**\n** When resuming an RBU update, the zState argument must be passed the same\n** value as when the RBU update was started.\n**\n** Once the RBU update is finished, the RBU extension does not \n** automatically remove any zState database file, even if it created it.\n**\n** By default, RBU uses the default VFS to access the files on disk. To\n** use a VFS other than the default, an SQLite \"file:\" URI containing a\n** \"vfs=...\" option may be passed as the zTarget option.\n**\n** IMPORTANT NOTE FOR ZIPVFS USERS: The RBU extension works with all of\n** SQLite's built-in VFSs, including the multiplexor VFS. However it does\n** not work out of the box with zipvfs. Refer to the comment describing\n** the zipvfs_create_vfs() API below for details on using RBU with zipvfs.\n*/\nSQLITE_API sqlite3rbu *sqlite3rbu_open(\n  const char *zTarget, \n  const char *zRbu,\n  const char *zState\n);\n\n/*\n** Open an RBU handle to perform an RBU vacuum on database file zTarget.\n** An RBU vacuum is similar to SQLite's built-in VACUUM command, except\n** that it can be suspended and resumed like an RBU update.\n**\n** The second argument to this function identifies a database in which \n** to store the state of the RBU vacuum operation if it is suspended. The \n** first time sqlite3rbu_vacuum() is called, to start an RBU vacuum\n** operation, the state database should either not exist or be empty\n** (contain no tables). If an RBU vacuum is suspended by calling \n** sqlite3rbu_close() on the RBU handle before sqlite3rbu_step() has\n** returned SQLITE_DONE, the vacuum state is stored in the state database. \n** The vacuum can be resumed by calling this function to open a new RBU\n** handle specifying the same target and state databases.\n**\n** If the second argument passed to this function is NULL, then the\n** name of the state database is \"<database>-vacuum\", where <database>\n** is the name of the target database file. In this case, on UNIX, if the\n** state database is not already present in the file-system, it is created\n** with the same permissions as the target db is made. \n**\n** With an RBU vacuum, it is an SQLITE_MISUSE error if the name of the \n** state database ends with \"-vactmp\". This name is reserved for internal \n** use.\n**\n** This function does not delete the state database after an RBU vacuum\n** is completed, even if it created it. However, if the call to\n** sqlite3rbu_close() returns any value other than SQLITE_OK, the contents\n** of the state tables within the state database are zeroed. This way,\n** the next call to sqlite3rbu_vacuum() opens a handle that starts a \n** new RBU vacuum operation.\n**\n** As with sqlite3rbu_open(), Zipvfs users should rever to the comment\n** describing the sqlite3rbu_create_vfs() API function below for \n** a description of the complications associated with using RBU with \n** zipvfs databases.\n*/\nSQLITE_API sqlite3rbu *sqlite3rbu_vacuum(\n  const char *zTarget, \n  const char *zState\n);\n\n/*\n** Configure a limit for the amount of temp space that may be used by\n** the RBU handle passed as the first argument. The new limit is specified\n** in bytes by the second parameter. If it is positive, the limit is updated.\n** If the second parameter to this function is passed zero, then the limit\n** is removed entirely. If the second parameter is negative, the limit is\n** not modified (this is useful for querying the current limit).\n**\n** In all cases the returned value is the current limit in bytes (zero \n** indicates unlimited).\n**\n** If the temp space limit is exceeded during operation, an SQLITE_FULL\n** error is returned.\n*/\nSQLITE_API sqlite3_int64 sqlite3rbu_temp_size_limit(sqlite3rbu*, sqlite3_int64);\n\n/*\n** Return the current amount of temp file space, in bytes, currently used by \n** the RBU handle passed as the only argument.\n*/\nSQLITE_API sqlite3_int64 sqlite3rbu_temp_size(sqlite3rbu*);\n\n/*\n** Internally, each RBU connection uses a separate SQLite database \n** connection to access the target and rbu update databases. This\n** API allows the application direct access to these database handles.\n**\n** The first argument passed to this function must be a valid, open, RBU\n** handle. The second argument should be passed zero to access the target\n** database handle, or non-zero to access the rbu update database handle.\n** Accessing the underlying database handles may be useful in the\n** following scenarios:\n**\n**   * If any target tables are virtual tables, it may be necessary to\n**     call sqlite3_create_module() on the target database handle to \n**     register the required virtual table implementations.\n**\n**   * If the data_xxx tables in the RBU source database are virtual \n**     tables, the application may need to call sqlite3_create_module() on\n**     the rbu update db handle to any required virtual table\n**     implementations.\n**\n**   * If the application uses the \"rbu_delta()\" feature described above,\n**     it must use sqlite3_create_function() or similar to register the\n**     rbu_delta() implementation with the target database handle.\n**\n** If an error has occurred, either while opening or stepping the RBU object,\n** this function may return NULL. The error code and message may be collected\n** when sqlite3rbu_close() is called.\n**\n** Database handles returned by this function remain valid until the next\n** call to any sqlite3rbu_xxx() function other than sqlite3rbu_db().\n*/\nSQLITE_API sqlite3 *sqlite3rbu_db(sqlite3rbu*, int bRbu);\n\n/*\n** Do some work towards applying the RBU update to the target db. \n**\n** Return SQLITE_DONE if the update has been completely applied, or \n** SQLITE_OK if no error occurs but there remains work to do to apply\n** the RBU update. If an error does occur, some other error code is \n** returned. \n**\n** Once a call to sqlite3rbu_step() has returned a value other than\n** SQLITE_OK, all subsequent calls on the same RBU handle are no-ops\n** that immediately return the same value.\n*/\nSQLITE_API int sqlite3rbu_step(sqlite3rbu *pRbu);\n\n/*\n** Force RBU to save its state to disk.\n**\n** If a power failure or application crash occurs during an update, following\n** system recovery RBU may resume the update from the point at which the state\n** was last saved. In other words, from the most recent successful call to \n** sqlite3rbu_close() or this function.\n**\n** SQLITE_OK is returned if successful, or an SQLite error code otherwise.\n*/\nSQLITE_API int sqlite3rbu_savestate(sqlite3rbu *pRbu);\n\n/*\n** Close an RBU handle. \n**\n** If the RBU update has been completely applied, mark the RBU database\n** as fully applied. Otherwise, assuming no error has occurred, save the\n** current state of the RBU update appliation to the RBU database.\n**\n** If an error has already occurred as part of an sqlite3rbu_step()\n** or sqlite3rbu_open() call, or if one occurs within this function, an\n** SQLite error code is returned. Additionally, if pzErrmsg is not NULL,\n** *pzErrmsg may be set to point to a buffer containing a utf-8 formatted\n** English language error message. It is the responsibility of the caller to\n** eventually free any such buffer using sqlite3_free().\n**\n** Otherwise, if no error occurs, this function returns SQLITE_OK if the\n** update has been partially applied, or SQLITE_DONE if it has been \n** completely applied.\n*/\nSQLITE_API int sqlite3rbu_close(sqlite3rbu *pRbu, char **pzErrmsg);\n\n/*\n** Return the total number of key-value operations (inserts, deletes or \n** updates) that have been performed on the target database since the\n** current RBU update was started.\n*/\nSQLITE_API sqlite3_int64 sqlite3rbu_progress(sqlite3rbu *pRbu);\n\n/*\n** Obtain permyriadage (permyriadage is to 10000 as percentage is to 100) \n** progress indications for the two stages of an RBU update. This API may\n** be useful for driving GUI progress indicators and similar.\n**\n** An RBU update is divided into two stages:\n**\n**   * Stage 1, in which changes are accumulated in an oal/wal file, and\n**   * Stage 2, in which the contents of the wal file are copied into the\n**     main database.\n**\n** The update is visible to non-RBU clients during stage 2. During stage 1\n** non-RBU reader clients may see the original database.\n**\n** If this API is called during stage 2 of the update, output variable \n** (*pnOne) is set to 10000 to indicate that stage 1 has finished and (*pnTwo)\n** to a value between 0 and 10000 to indicate the permyriadage progress of\n** stage 2. A value of 5000 indicates that stage 2 is half finished, \n** 9000 indicates that it is 90% finished, and so on.\n**\n** If this API is called during stage 1 of the update, output variable \n** (*pnTwo) is set to 0 to indicate that stage 2 has not yet started. The\n** value to which (*pnOne) is set depends on whether or not the RBU \n** database contains an \"rbu_count\" table. The rbu_count table, if it \n** exists, must contain the same columns as the following:\n**\n**   CREATE TABLE rbu_count(tbl TEXT PRIMARY KEY, cnt INTEGER) WITHOUT ROWID;\n**\n** There must be one row in the table for each source (data_xxx) table within\n** the RBU database. The 'tbl' column should contain the name of the source\n** table. The 'cnt' column should contain the number of rows within the\n** source table.\n**\n** If the rbu_count table is present and populated correctly and this\n** API is called during stage 1, the *pnOne output variable is set to the\n** permyriadage progress of the same stage. If the rbu_count table does\n** not exist, then (*pnOne) is set to -1 during stage 1. If the rbu_count\n** table exists but is not correctly populated, the value of the *pnOne\n** output variable during stage 1 is undefined.\n*/\nSQLITE_API void sqlite3rbu_bp_progress(sqlite3rbu *pRbu, int *pnOne, int*pnTwo);\n\n/*\n** Obtain an indication as to the current stage of an RBU update or vacuum.\n** This function always returns one of the SQLITE_RBU_STATE_XXX constants\n** defined in this file. Return values should be interpreted as follows:\n**\n** SQLITE_RBU_STATE_OAL:\n**   RBU is currently building a *-oal file. The next call to sqlite3rbu_step()\n**   may either add further data to the *-oal file, or compute data that will\n**   be added by a subsequent call.\n**\n** SQLITE_RBU_STATE_MOVE:\n**   RBU has finished building the *-oal file. The next call to sqlite3rbu_step()\n**   will move the *-oal file to the equivalent *-wal path. If the current\n**   operation is an RBU update, then the updated version of the database\n**   file will become visible to ordinary SQLite clients following the next\n**   call to sqlite3rbu_step().\n**\n** SQLITE_RBU_STATE_CHECKPOINT:\n**   RBU is currently performing an incremental checkpoint. The next call to\n**   sqlite3rbu_step() will copy a page of data from the *-wal file into\n**   the target database file.\n**\n** SQLITE_RBU_STATE_DONE:\n**   The RBU operation has finished. Any subsequent calls to sqlite3rbu_step()\n**   will immediately return SQLITE_DONE.\n**\n** SQLITE_RBU_STATE_ERROR:\n**   An error has occurred. Any subsequent calls to sqlite3rbu_step() will\n**   immediately return the SQLite error code associated with the error.\n*/\n#define SQLITE_RBU_STATE_OAL        1\n#define SQLITE_RBU_STATE_MOVE       2\n#define SQLITE_RBU_STATE_CHECKPOINT 3\n#define SQLITE_RBU_STATE_DONE       4\n#define SQLITE_RBU_STATE_ERROR      5\n\nSQLITE_API int sqlite3rbu_state(sqlite3rbu *pRbu);\n\n/*\n** Create an RBU VFS named zName that accesses the underlying file-system\n** via existing VFS zParent. Or, if the zParent parameter is passed NULL, \n** then the new RBU VFS uses the default system VFS to access the file-system.\n** The new object is registered as a non-default VFS with SQLite before \n** returning.\n**\n** Part of the RBU implementation uses a custom VFS object. Usually, this\n** object is created and deleted automatically by RBU. \n**\n** The exception is for applications that also use zipvfs. In this case,\n** the custom VFS must be explicitly created by the user before the RBU\n** handle is opened. The RBU VFS should be installed so that the zipvfs\n** VFS uses the RBU VFS, which in turn uses any other VFS layers in use \n** (for example multiplexor) to access the file-system. For example,\n** to assemble an RBU enabled VFS stack that uses both zipvfs and \n** multiplexor (error checking omitted):\n**\n**     // Create a VFS named \"multiplex\" (not the default).\n**     sqlite3_multiplex_initialize(0, 0);\n**\n**     // Create an rbu VFS named \"rbu\" that uses multiplexor. If the\n**     // second argument were replaced with NULL, the \"rbu\" VFS would\n**     // access the file-system via the system default VFS, bypassing the\n**     // multiplexor.\n**     sqlite3rbu_create_vfs(\"rbu\", \"multiplex\");\n**\n**     // Create a zipvfs VFS named \"zipvfs\" that uses rbu.\n**     zipvfs_create_vfs_v3(\"zipvfs\", \"rbu\", 0, xCompressorAlgorithmDetector);\n**\n**     // Make zipvfs the default VFS.\n**     sqlite3_vfs_register(sqlite3_vfs_find(\"zipvfs\"), 1);\n**\n** Because the default VFS created above includes a RBU functionality, it\n** may be used by RBU clients. Attempting to use RBU with a zipvfs VFS stack\n** that does not include the RBU layer results in an error.\n**\n** The overhead of adding the \"rbu\" VFS to the system is negligible for \n** non-RBU users. There is no harm in an application accessing the \n** file-system via \"rbu\" all the time, even if it only uses RBU functionality \n** occasionally.\n*/\nSQLITE_API int sqlite3rbu_create_vfs(const char *zName, const char *zParent);\n\n/*\n** Deregister and destroy an RBU vfs created by an earlier call to\n** sqlite3rbu_create_vfs().\n**\n** VFS objects are not reference counted. If a VFS object is destroyed\n** before all database handles that use it have been closed, the results\n** are undefined.\n*/\nSQLITE_API void sqlite3rbu_destroy_vfs(const char *zName);\n\n#if 0\n}  /* end of the 'extern \"C\"' block */\n#endif\n\n#endif /* _SQLITE3RBU_H */\n\n/************** End of sqlite3rbu.h ******************************************/\n/************** Continuing where we left off in sqlite3rbu.c *****************/\n\n#if defined(_WIN32_WCE)\n/* #include \"windows.h\" */\n#endif\n\n/* Maximum number of prepared UPDATE statements held by this module */\n#define SQLITE_RBU_UPDATE_CACHESIZE 16\n\n/* Delta checksums disabled by default.  Compile with -DRBU_ENABLE_DELTA_CKSUM\n** to enable checksum verification.\n*/\n#ifndef RBU_ENABLE_DELTA_CKSUM\n# define RBU_ENABLE_DELTA_CKSUM 0\n#endif\n\n/*\n** Swap two objects of type TYPE.\n*/\n#if !defined(SQLITE_AMALGAMATION)\n# define SWAP(TYPE,A,B) {TYPE t=A; A=B; B=t;}\n#endif\n\n/*\n** The rbu_state table is used to save the state of a partially applied\n** update so that it can be resumed later. The table consists of integer\n** keys mapped to values as follows:\n**\n** RBU_STATE_STAGE:\n**   May be set to integer values 1, 2, 4 or 5. As follows:\n**       1: the *-rbu file is currently under construction.\n**       2: the *-rbu file has been constructed, but not yet moved \n**          to the *-wal path.\n**       4: the checkpoint is underway.\n**       5: the rbu update has been checkpointed.\n**\n** RBU_STATE_TBL:\n**   Only valid if STAGE==1. The target database name of the table \n**   currently being written.\n**\n** RBU_STATE_IDX:\n**   Only valid if STAGE==1. The target database name of the index \n**   currently being written, or NULL if the main table is currently being\n**   updated.\n**\n** RBU_STATE_ROW:\n**   Only valid if STAGE==1. Number of rows already processed for the current\n**   table/index.\n**\n** RBU_STATE_PROGRESS:\n**   Trbul number of sqlite3rbu_step() calls made so far as part of this\n**   rbu update.\n**\n** RBU_STATE_CKPT:\n**   Valid if STAGE==4. The 64-bit checksum associated with the wal-index\n**   header created by recovering the *-wal file. This is used to detect\n**   cases when another client appends frames to the *-wal file in the\n**   middle of an incremental checkpoint (an incremental checkpoint cannot\n**   be continued if this happens).\n**\n** RBU_STATE_COOKIE:\n**   Valid if STAGE==1. The current change-counter cookie value in the \n**   target db file.\n**\n** RBU_STATE_OALSZ:\n**   Valid if STAGE==1. The size in bytes of the *-oal file.\n**\n** RBU_STATE_DATATBL:\n**   Only valid if STAGE==1. The RBU database name of the table \n**   currently being read.\n*/\n#define RBU_STATE_STAGE        1\n#define RBU_STATE_TBL          2\n#define RBU_STATE_IDX          3\n#define RBU_STATE_ROW          4\n#define RBU_STATE_PROGRESS     5\n#define RBU_STATE_CKPT         6\n#define RBU_STATE_COOKIE       7\n#define RBU_STATE_OALSZ        8\n#define RBU_STATE_PHASEONESTEP 9\n#define RBU_STATE_DATATBL     10\n\n#define RBU_STAGE_OAL         1\n#define RBU_STAGE_MOVE        2\n#define RBU_STAGE_CAPTURE     3\n#define RBU_STAGE_CKPT        4\n#define RBU_STAGE_DONE        5\n\n\n#define RBU_CREATE_STATE \\\n  \"CREATE TABLE IF NOT EXISTS %s.rbu_state(k INTEGER PRIMARY KEY, v)\"\n\ntypedef struct RbuFrame RbuFrame;\ntypedef struct RbuObjIter RbuObjIter;\ntypedef struct RbuState RbuState;\ntypedef struct rbu_vfs rbu_vfs;\ntypedef struct rbu_file rbu_file;\ntypedef struct RbuUpdateStmt RbuUpdateStmt;\n\n#if !defined(SQLITE_AMALGAMATION)\ntypedef unsigned int u32;\ntypedef unsigned short u16;\ntypedef unsigned char u8;\ntypedef sqlite3_int64 i64;\n#endif\n\n/*\n** These values must match the values defined in wal.c for the equivalent\n** locks. These are not magic numbers as they are part of the SQLite file\n** format.\n*/\n#define WAL_LOCK_WRITE  0\n#define WAL_LOCK_CKPT   1\n#define WAL_LOCK_READ0  3\n\n#define SQLITE_FCNTL_RBUCNT    5149216\n\n/*\n** A structure to store values read from the rbu_state table in memory.\n*/\nstruct RbuState {\n  int eStage;\n  char *zTbl;\n  char *zDataTbl;\n  char *zIdx;\n  i64 iWalCksum;\n  int nRow;\n  i64 nProgress;\n  u32 iCookie;\n  i64 iOalSz;\n  i64 nPhaseOneStep;\n};\n\nstruct RbuUpdateStmt {\n  char *zMask;                    /* Copy of update mask used with pUpdate */\n  sqlite3_stmt *pUpdate;          /* Last update statement (or NULL) */\n  RbuUpdateStmt *pNext;\n};\n\n/*\n** An iterator of this type is used to iterate through all objects in\n** the target database that require updating. For each such table, the\n** iterator visits, in order:\n**\n**     * the table itself, \n**     * each index of the table (zero or more points to visit), and\n**     * a special \"cleanup table\" state.\n**\n** abIndexed:\n**   If the table has no indexes on it, abIndexed is set to NULL. Otherwise,\n**   it points to an array of flags nTblCol elements in size. The flag is\n**   set for each column that is either a part of the PK or a part of an\n**   index. Or clear otherwise.\n**   \n*/\nstruct RbuObjIter {\n  sqlite3_stmt *pTblIter;         /* Iterate through tables */\n  sqlite3_stmt *pIdxIter;         /* Index iterator */\n  int nTblCol;                    /* Size of azTblCol[] array */\n  char **azTblCol;                /* Array of unquoted target column names */\n  char **azTblType;               /* Array of target column types */\n  int *aiSrcOrder;                /* src table col -> target table col */\n  u8 *abTblPk;                    /* Array of flags, set on target PK columns */\n  u8 *abNotNull;                  /* Array of flags, set on NOT NULL columns */\n  u8 *abIndexed;                  /* Array of flags, set on indexed & PK cols */\n  int eType;                      /* Table type - an RBU_PK_XXX value */\n\n  /* Output variables. zTbl==0 implies EOF. */\n  int bCleanup;                   /* True in \"cleanup\" state */\n  const char *zTbl;               /* Name of target db table */\n  const char *zDataTbl;           /* Name of rbu db table (or null) */\n  const char *zIdx;               /* Name of target db index (or null) */\n  int iTnum;                      /* Root page of current object */\n  int iPkTnum;                    /* If eType==EXTERNAL, root of PK index */\n  int bUnique;                    /* Current index is unique */\n  int nIndex;                     /* Number of aux. indexes on table zTbl */\n\n  /* Statements created by rbuObjIterPrepareAll() */\n  int nCol;                       /* Number of columns in current object */\n  sqlite3_stmt *pSelect;          /* Source data */\n  sqlite3_stmt *pInsert;          /* Statement for INSERT operations */\n  sqlite3_stmt *pDelete;          /* Statement for DELETE ops */\n  sqlite3_stmt *pTmpInsert;       /* Insert into rbu_tmp_$zDataTbl */\n\n  /* Last UPDATE used (for PK b-tree updates only), or NULL. */\n  RbuUpdateStmt *pRbuUpdate;\n};\n\n/*\n** Values for RbuObjIter.eType\n**\n**     0: Table does not exist (error)\n**     1: Table has an implicit rowid.\n**     2: Table has an explicit IPK column.\n**     3: Table has an external PK index.\n**     4: Table is WITHOUT ROWID.\n**     5: Table is a virtual table.\n*/\n#define RBU_PK_NOTABLE        0\n#define RBU_PK_NONE           1\n#define RBU_PK_IPK            2\n#define RBU_PK_EXTERNAL       3\n#define RBU_PK_WITHOUT_ROWID  4\n#define RBU_PK_VTAB           5\n\n\n/*\n** Within the RBU_STAGE_OAL stage, each call to sqlite3rbu_step() performs\n** one of the following operations.\n*/\n#define RBU_INSERT     1          /* Insert on a main table b-tree */\n#define RBU_DELETE     2          /* Delete a row from a main table b-tree */\n#define RBU_REPLACE    3          /* Delete and then insert a row */\n#define RBU_IDX_DELETE 4          /* Delete a row from an aux. index b-tree */\n#define RBU_IDX_INSERT 5          /* Insert on an aux. index b-tree */\n\n#define RBU_UPDATE     6          /* Update a row in a main table b-tree */\n\n/*\n** A single step of an incremental checkpoint - frame iWalFrame of the wal\n** file should be copied to page iDbPage of the database file.\n*/\nstruct RbuFrame {\n  u32 iDbPage;\n  u32 iWalFrame;\n};\n\n/*\n** RBU handle.\n**\n** nPhaseOneStep:\n**   If the RBU database contains an rbu_count table, this value is set to\n**   a running estimate of the number of b-tree operations required to \n**   finish populating the *-oal file. This allows the sqlite3_bp_progress()\n**   API to calculate the permyriadage progress of populating the *-oal file\n**   using the formula:\n**\n**     permyriadage = (10000 * nProgress) / nPhaseOneStep\n**\n**   nPhaseOneStep is initialized to the sum of:\n**\n**     nRow * (nIndex + 1)\n**\n**   for all source tables in the RBU database, where nRow is the number\n**   of rows in the source table and nIndex the number of indexes on the\n**   corresponding target database table.\n**\n**   This estimate is accurate if the RBU update consists entirely of\n**   INSERT operations. However, it is inaccurate if:\n**\n**     * the RBU update contains any UPDATE operations. If the PK specified\n**       for an UPDATE operation does not exist in the target table, then\n**       no b-tree operations are required on index b-trees. Or if the \n**       specified PK does exist, then (nIndex*2) such operations are\n**       required (one delete and one insert on each index b-tree).\n**\n**     * the RBU update contains any DELETE operations for which the specified\n**       PK does not exist. In this case no operations are required on index\n**       b-trees.\n**\n**     * the RBU update contains REPLACE operations. These are similar to\n**       UPDATE operations.\n**\n**   nPhaseOneStep is updated to account for the conditions above during the\n**   first pass of each source table. The updated nPhaseOneStep value is\n**   stored in the rbu_state table if the RBU update is suspended.\n*/\nstruct sqlite3rbu {\n  int eStage;                     /* Value of RBU_STATE_STAGE field */\n  sqlite3 *dbMain;                /* target database handle */\n  sqlite3 *dbRbu;                 /* rbu database handle */\n  char *zTarget;                  /* Path to target db */\n  char *zRbu;                     /* Path to rbu db */\n  char *zState;                   /* Path to state db (or NULL if zRbu) */\n  char zStateDb[5];               /* Db name for state (\"stat\" or \"main\") */\n  int rc;                         /* Value returned by last rbu_step() call */\n  char *zErrmsg;                  /* Error message if rc!=SQLITE_OK */\n  int nStep;                      /* Rows processed for current object */\n  int nProgress;                  /* Rows processed for all objects */\n  RbuObjIter objiter;             /* Iterator for skipping through tbl/idx */\n  const char *zVfsName;           /* Name of automatically created rbu vfs */\n  rbu_file *pTargetFd;            /* File handle open on target db */\n  int nPagePerSector;             /* Pages per sector for pTargetFd */\n  i64 iOalSz;\n  i64 nPhaseOneStep;\n\n  /* The following state variables are used as part of the incremental\n  ** checkpoint stage (eStage==RBU_STAGE_CKPT). See comments surrounding\n  ** function rbuSetupCheckpoint() for details.  */\n  u32 iMaxFrame;                  /* Largest iWalFrame value in aFrame[] */\n  u32 mLock;\n  int nFrame;                     /* Entries in aFrame[] array */\n  int nFrameAlloc;                /* Allocated size of aFrame[] array */\n  RbuFrame *aFrame;\n  int pgsz;\n  u8 *aBuf;\n  i64 iWalCksum;\n  i64 szTemp;                     /* Current size of all temp files in use */\n  i64 szTempLimit;                /* Total size limit for temp files */\n\n  /* Used in RBU vacuum mode only */\n  int nRbu;                       /* Number of RBU VFS in the stack */\n  rbu_file *pRbuFd;               /* Fd for main db of dbRbu */\n};\n\n/*\n** An rbu VFS is implemented using an instance of this structure.\n**\n** Variable pRbu is only non-NULL for automatically created RBU VFS objects.\n** It is NULL for RBU VFS objects created explicitly using\n** sqlite3rbu_create_vfs(). It is used to track the total amount of temp\n** space used by the RBU handle.\n*/\nstruct rbu_vfs {\n  sqlite3_vfs base;               /* rbu VFS shim methods */\n  sqlite3_vfs *pRealVfs;          /* Underlying VFS */\n  sqlite3_mutex *mutex;           /* Mutex to protect pMain */\n  sqlite3rbu *pRbu;               /* Owner RBU object */\n  rbu_file *pMain;                /* List of main db files */\n  rbu_file *pMainRbu;             /* List of main db files with pRbu!=0 */\n};\n\n/*\n** Each file opened by an rbu VFS is represented by an instance of\n** the following structure.\n**\n** If this is a temporary file (pRbu!=0 && flags&DELETE_ON_CLOSE), variable\n** \"sz\" is set to the current size of the database file.\n*/\nstruct rbu_file {\n  sqlite3_file base;              /* sqlite3_file methods */\n  sqlite3_file *pReal;            /* Underlying file handle */\n  rbu_vfs *pRbuVfs;               /* Pointer to the rbu_vfs object */\n  sqlite3rbu *pRbu;               /* Pointer to rbu object (rbu target only) */\n  i64 sz;                         /* Size of file in bytes (temp only) */\n\n  int openFlags;                  /* Flags this file was opened with */\n  u32 iCookie;                    /* Cookie value for main db files */\n  u8 iWriteVer;                   /* \"write-version\" value for main db files */\n  u8 bNolock;                     /* True to fail EXCLUSIVE locks */\n\n  int nShm;                       /* Number of entries in apShm[] array */\n  char **apShm;                   /* Array of mmap'd *-shm regions */\n  char *zDel;                     /* Delete this when closing file */\n\n  const char *zWal;               /* Wal filename for this main db file */\n  rbu_file *pWalFd;               /* Wal file descriptor for this main db */\n  rbu_file *pMainNext;            /* Next MAIN_DB file */\n  rbu_file *pMainRbuNext;         /* Next MAIN_DB file with pRbu!=0 */\n};\n\n/*\n** True for an RBU vacuum handle, or false otherwise.\n*/\n#define rbuIsVacuum(p) ((p)->zTarget==0)\n\n\n/*************************************************************************\n** The following three functions, found below:\n**\n**   rbuDeltaGetInt()\n**   rbuDeltaChecksum()\n**   rbuDeltaApply()\n**\n** are lifted from the fossil source code (http://fossil-scm.org). They\n** are used to implement the scalar SQL function rbu_fossil_delta().\n*/\n\n/*\n** Read bytes from *pz and convert them into a positive integer.  When\n** finished, leave *pz pointing to the first character past the end of\n** the integer.  The *pLen parameter holds the length of the string\n** in *pz and is decremented once for each character in the integer.\n*/\nstatic unsigned int rbuDeltaGetInt(const char **pz, int *pLen){\n  static const signed char zValue[] = {\n    -1, -1, -1, -1, -1, -1, -1, -1,   -1, -1, -1, -1, -1, -1, -1, -1,\n    -1, -1, -1, -1, -1, -1, -1, -1,   -1, -1, -1, -1, -1, -1, -1, -1,\n    -1, -1, -1, -1, -1, -1, -1, -1,   -1, -1, -1, -1, -1, -1, -1, -1,\n     0,  1,  2,  3,  4,  5,  6,  7,    8,  9, -1, -1, -1, -1, -1, -1,\n    -1, 10, 11, 12, 13, 14, 15, 16,   17, 18, 19, 20, 21, 22, 23, 24,\n    25, 26, 27, 28, 29, 30, 31, 32,   33, 34, 35, -1, -1, -1, -1, 36,\n    -1, 37, 38, 39, 40, 41, 42, 43,   44, 45, 46, 47, 48, 49, 50, 51,\n    52, 53, 54, 55, 56, 57, 58, 59,   60, 61, 62, -1, -1, -1, 63, -1,\n  };\n  unsigned int v = 0;\n  int c;\n  unsigned char *z = (unsigned char*)*pz;\n  unsigned char *zStart = z;\n  while( (c = zValue[0x7f&*(z++)])>=0 ){\n     v = (v<<6) + c;\n  }\n  z--;\n  *pLen -= z - zStart;\n  *pz = (char*)z;\n  return v;\n}\n\n#if RBU_ENABLE_DELTA_CKSUM\n/*\n** Compute a 32-bit checksum on the N-byte buffer.  Return the result.\n*/\nstatic unsigned int rbuDeltaChecksum(const char *zIn, size_t N){\n  const unsigned char *z = (const unsigned char *)zIn;\n  unsigned sum0 = 0;\n  unsigned sum1 = 0;\n  unsigned sum2 = 0;\n  unsigned sum3 = 0;\n  while(N >= 16){\n    sum0 += ((unsigned)z[0] + z[4] + z[8] + z[12]);\n    sum1 += ((unsigned)z[1] + z[5] + z[9] + z[13]);\n    sum2 += ((unsigned)z[2] + z[6] + z[10]+ z[14]);\n    sum3 += ((unsigned)z[3] + z[7] + z[11]+ z[15]);\n    z += 16;\n    N -= 16;\n  }\n  while(N >= 4){\n    sum0 += z[0];\n    sum1 += z[1];\n    sum2 += z[2];\n    sum3 += z[3];\n    z += 4;\n    N -= 4;\n  }\n  sum3 += (sum2 << 8) + (sum1 << 16) + (sum0 << 24);\n  switch(N){\n    case 3:   sum3 += (z[2] << 8);\n    case 2:   sum3 += (z[1] << 16);\n    case 1:   sum3 += (z[0] << 24);\n    default:  ;\n  }\n  return sum3;\n}\n#endif\n\n/*\n** Apply a delta.\n**\n** The output buffer should be big enough to hold the whole output\n** file and a NUL terminator at the end.  The delta_output_size()\n** routine will determine this size for you.\n**\n** The delta string should be null-terminated.  But the delta string\n** may contain embedded NUL characters (if the input and output are\n** binary files) so we also have to pass in the length of the delta in\n** the lenDelta parameter.\n**\n** This function returns the size of the output file in bytes (excluding\n** the final NUL terminator character).  Except, if the delta string is\n** malformed or intended for use with a source file other than zSrc,\n** then this routine returns -1.\n**\n** Refer to the delta_create() documentation above for a description\n** of the delta file format.\n*/\nstatic int rbuDeltaApply(\n  const char *zSrc,      /* The source or pattern file */\n  int lenSrc,            /* Length of the source file */\n  const char *zDelta,    /* Delta to apply to the pattern */\n  int lenDelta,          /* Length of the delta */\n  char *zOut             /* Write the output into this preallocated buffer */\n){\n  unsigned int limit;\n  unsigned int total = 0;\n#if RBU_ENABLE_DELTA_CKSUM\n  char *zOrigOut = zOut;\n#endif\n\n  limit = rbuDeltaGetInt(&zDelta, &lenDelta);\n  if( *zDelta!='\\n' ){\n    /* ERROR: size integer not terminated by \"\\n\" */\n    return -1;\n  }\n  zDelta++; lenDelta--;\n  while( *zDelta && lenDelta>0 ){\n    unsigned int cnt, ofst;\n    cnt = rbuDeltaGetInt(&zDelta, &lenDelta);\n    switch( zDelta[0] ){\n      case '@': {\n        zDelta++; lenDelta--;\n        ofst = rbuDeltaGetInt(&zDelta, &lenDelta);\n        if( lenDelta>0 && zDelta[0]!=',' ){\n          /* ERROR: copy command not terminated by ',' */\n          return -1;\n        }\n        zDelta++; lenDelta--;\n        total += cnt;\n        if( total>limit ){\n          /* ERROR: copy exceeds output file size */\n          return -1;\n        }\n        if( (int)(ofst+cnt) > lenSrc ){\n          /* ERROR: copy extends past end of input */\n          return -1;\n        }\n        memcpy(zOut, &zSrc[ofst], cnt);\n        zOut += cnt;\n        break;\n      }\n      case ':': {\n        zDelta++; lenDelta--;\n        total += cnt;\n        if( total>limit ){\n          /* ERROR:  insert command gives an output larger than predicted */\n          return -1;\n        }\n        if( (int)cnt>lenDelta ){\n          /* ERROR: insert count exceeds size of delta */\n          return -1;\n        }\n        memcpy(zOut, zDelta, cnt);\n        zOut += cnt;\n        zDelta += cnt;\n        lenDelta -= cnt;\n        break;\n      }\n      case ';': {\n        zDelta++; lenDelta--;\n        zOut[0] = 0;\n#if RBU_ENABLE_DELTA_CKSUM\n        if( cnt!=rbuDeltaChecksum(zOrigOut, total) ){\n          /* ERROR:  bad checksum */\n          return -1;\n        }\n#endif\n        if( total!=limit ){\n          /* ERROR: generated size does not match predicted size */\n          return -1;\n        }\n        return total;\n      }\n      default: {\n        /* ERROR: unknown delta operator */\n        return -1;\n      }\n    }\n  }\n  /* ERROR: unterminated delta */\n  return -1;\n}\n\nstatic int rbuDeltaOutputSize(const char *zDelta, int lenDelta){\n  int size;\n  size = rbuDeltaGetInt(&zDelta, &lenDelta);\n  if( *zDelta!='\\n' ){\n    /* ERROR: size integer not terminated by \"\\n\" */\n    return -1;\n  }\n  return size;\n}\n\n/*\n** End of code taken from fossil.\n*************************************************************************/\n\n/*\n** Implementation of SQL scalar function rbu_fossil_delta().\n**\n** This function applies a fossil delta patch to a blob. Exactly two\n** arguments must be passed to this function. The first is the blob to\n** patch and the second the patch to apply. If no error occurs, this\n** function returns the patched blob.\n*/\nstatic void rbuFossilDeltaFunc(\n  sqlite3_context *context,\n  int argc,\n  sqlite3_value **argv\n){\n  const char *aDelta;\n  int nDelta;\n  const char *aOrig;\n  int nOrig;\n\n  int nOut;\n  int nOut2;\n  char *aOut;\n\n  assert( argc==2 );\n\n  nOrig = sqlite3_value_bytes(argv[0]);\n  aOrig = (const char*)sqlite3_value_blob(argv[0]);\n  nDelta = sqlite3_value_bytes(argv[1]);\n  aDelta = (const char*)sqlite3_value_blob(argv[1]);\n\n  /* Figure out the size of the output */\n  nOut = rbuDeltaOutputSize(aDelta, nDelta);\n  if( nOut<0 ){\n    sqlite3_result_error(context, \"corrupt fossil delta\", -1);\n    return;\n  }\n\n  aOut = sqlite3_malloc(nOut+1);\n  if( aOut==0 ){\n    sqlite3_result_error_nomem(context);\n  }else{\n    nOut2 = rbuDeltaApply(aOrig, nOrig, aDelta, nDelta, aOut);\n    if( nOut2!=nOut ){\n      sqlite3_result_error(context, \"corrupt fossil delta\", -1);\n    }else{\n      sqlite3_result_blob(context, aOut, nOut, sqlite3_free);\n    }\n  }\n}\n\n\n/*\n** Prepare the SQL statement in buffer zSql against database handle db.\n** If successful, set *ppStmt to point to the new statement and return\n** SQLITE_OK. \n**\n** Otherwise, if an error does occur, set *ppStmt to NULL and return\n** an SQLite error code. Additionally, set output variable *pzErrmsg to\n** point to a buffer containing an error message. It is the responsibility\n** of the caller to (eventually) free this buffer using sqlite3_free().\n*/\nstatic int prepareAndCollectError(\n  sqlite3 *db, \n  sqlite3_stmt **ppStmt,\n  char **pzErrmsg,\n  const char *zSql\n){\n  int rc = sqlite3_prepare_v2(db, zSql, -1, ppStmt, 0);\n  if( rc!=SQLITE_OK ){\n    *pzErrmsg = sqlite3_mprintf(\"%s\", sqlite3_errmsg(db));\n    *ppStmt = 0;\n  }\n  return rc;\n}\n\n/*\n** Reset the SQL statement passed as the first argument. Return a copy\n** of the value returned by sqlite3_reset().\n**\n** If an error has occurred, then set *pzErrmsg to point to a buffer\n** containing an error message. It is the responsibility of the caller\n** to eventually free this buffer using sqlite3_free().\n*/\nstatic int resetAndCollectError(sqlite3_stmt *pStmt, char **pzErrmsg){\n  int rc = sqlite3_reset(pStmt);\n  if( rc!=SQLITE_OK ){\n    *pzErrmsg = sqlite3_mprintf(\"%s\", sqlite3_errmsg(sqlite3_db_handle(pStmt)));\n  }\n  return rc;\n}\n\n/*\n** Unless it is NULL, argument zSql points to a buffer allocated using\n** sqlite3_malloc containing an SQL statement. This function prepares the SQL\n** statement against database db and frees the buffer. If statement \n** compilation is successful, *ppStmt is set to point to the new statement \n** handle and SQLITE_OK is returned. \n**\n** Otherwise, if an error occurs, *ppStmt is set to NULL and an error code\n** returned. In this case, *pzErrmsg may also be set to point to an error\n** message. It is the responsibility of the caller to free this error message\n** buffer using sqlite3_free().\n**\n** If argument zSql is NULL, this function assumes that an OOM has occurred.\n** In this case SQLITE_NOMEM is returned and *ppStmt set to NULL.\n*/\nstatic int prepareFreeAndCollectError(\n  sqlite3 *db, \n  sqlite3_stmt **ppStmt,\n  char **pzErrmsg,\n  char *zSql\n){\n  int rc;\n  assert( *pzErrmsg==0 );\n  if( zSql==0 ){\n    rc = SQLITE_NOMEM;\n    *ppStmt = 0;\n  }else{\n    rc = prepareAndCollectError(db, ppStmt, pzErrmsg, zSql);\n    sqlite3_free(zSql);\n  }\n  return rc;\n}\n\n/*\n** Free the RbuObjIter.azTblCol[] and RbuObjIter.abTblPk[] arrays allocated\n** by an earlier call to rbuObjIterCacheTableInfo().\n*/\nstatic void rbuObjIterFreeCols(RbuObjIter *pIter){\n  int i;\n  for(i=0; i<pIter->nTblCol; i++){\n    sqlite3_free(pIter->azTblCol[i]);\n    sqlite3_free(pIter->azTblType[i]);\n  }\n  sqlite3_free(pIter->azTblCol);\n  pIter->azTblCol = 0;\n  pIter->azTblType = 0;\n  pIter->aiSrcOrder = 0;\n  pIter->abTblPk = 0;\n  pIter->abNotNull = 0;\n  pIter->nTblCol = 0;\n  pIter->eType = 0;               /* Invalid value */\n}\n\n/*\n** Finalize all statements and free all allocations that are specific to\n** the current object (table/index pair).\n*/\nstatic void rbuObjIterClearStatements(RbuObjIter *pIter){\n  RbuUpdateStmt *pUp;\n\n  sqlite3_finalize(pIter->pSelect);\n  sqlite3_finalize(pIter->pInsert);\n  sqlite3_finalize(pIter->pDelete);\n  sqlite3_finalize(pIter->pTmpInsert);\n  pUp = pIter->pRbuUpdate;\n  while( pUp ){\n    RbuUpdateStmt *pTmp = pUp->pNext;\n    sqlite3_finalize(pUp->pUpdate);\n    sqlite3_free(pUp);\n    pUp = pTmp;\n  }\n  \n  pIter->pSelect = 0;\n  pIter->pInsert = 0;\n  pIter->pDelete = 0;\n  pIter->pRbuUpdate = 0;\n  pIter->pTmpInsert = 0;\n  pIter->nCol = 0;\n}\n\n/*\n** Clean up any resources allocated as part of the iterator object passed\n** as the only argument.\n*/\nstatic void rbuObjIterFinalize(RbuObjIter *pIter){\n  rbuObjIterClearStatements(pIter);\n  sqlite3_finalize(pIter->pTblIter);\n  sqlite3_finalize(pIter->pIdxIter);\n  rbuObjIterFreeCols(pIter);\n  memset(pIter, 0, sizeof(RbuObjIter));\n}\n\n/*\n** Advance the iterator to the next position.\n**\n** If no error occurs, SQLITE_OK is returned and the iterator is left \n** pointing to the next entry. Otherwise, an error code and message is \n** left in the RBU handle passed as the first argument. A copy of the \n** error code is returned.\n*/\nstatic int rbuObjIterNext(sqlite3rbu *p, RbuObjIter *pIter){\n  int rc = p->rc;\n  if( rc==SQLITE_OK ){\n\n    /* Free any SQLite statements used while processing the previous object */ \n    rbuObjIterClearStatements(pIter);\n    if( pIter->zIdx==0 ){\n      rc = sqlite3_exec(p->dbMain,\n          \"DROP TRIGGER IF EXISTS temp.rbu_insert_tr;\"\n          \"DROP TRIGGER IF EXISTS temp.rbu_update1_tr;\"\n          \"DROP TRIGGER IF EXISTS temp.rbu_update2_tr;\"\n          \"DROP TRIGGER IF EXISTS temp.rbu_delete_tr;\"\n          , 0, 0, &p->zErrmsg\n      );\n    }\n\n    if( rc==SQLITE_OK ){\n      if( pIter->bCleanup ){\n        rbuObjIterFreeCols(pIter);\n        pIter->bCleanup = 0;\n        rc = sqlite3_step(pIter->pTblIter);\n        if( rc!=SQLITE_ROW ){\n          rc = resetAndCollectError(pIter->pTblIter, &p->zErrmsg);\n          pIter->zTbl = 0;\n        }else{\n          pIter->zTbl = (const char*)sqlite3_column_text(pIter->pTblIter, 0);\n          pIter->zDataTbl = (const char*)sqlite3_column_text(pIter->pTblIter,1);\n          rc = (pIter->zDataTbl && pIter->zTbl) ? SQLITE_OK : SQLITE_NOMEM;\n        }\n      }else{\n        if( pIter->zIdx==0 ){\n          sqlite3_stmt *pIdx = pIter->pIdxIter;\n          rc = sqlite3_bind_text(pIdx, 1, pIter->zTbl, -1, SQLITE_STATIC);\n        }\n        if( rc==SQLITE_OK ){\n          rc = sqlite3_step(pIter->pIdxIter);\n          if( rc!=SQLITE_ROW ){\n            rc = resetAndCollectError(pIter->pIdxIter, &p->zErrmsg);\n            pIter->bCleanup = 1;\n            pIter->zIdx = 0;\n          }else{\n            pIter->zIdx = (const char*)sqlite3_column_text(pIter->pIdxIter, 0);\n            pIter->iTnum = sqlite3_column_int(pIter->pIdxIter, 1);\n            pIter->bUnique = sqlite3_column_int(pIter->pIdxIter, 2);\n            rc = pIter->zIdx ? SQLITE_OK : SQLITE_NOMEM;\n          }\n        }\n      }\n    }\n  }\n\n  if( rc!=SQLITE_OK ){\n    rbuObjIterFinalize(pIter);\n    p->rc = rc;\n  }\n  return rc;\n}\n\n\n/*\n** The implementation of the rbu_target_name() SQL function. This function\n** accepts one or two arguments. The first argument is the name of a table -\n** the name of a table in the RBU database.  The second, if it is present, is 1\n** for a view or 0 for a table. \n**\n** For a non-vacuum RBU handle, if the table name matches the pattern:\n**\n**     data[0-9]_<name>\n**\n** where <name> is any sequence of 1 or more characters, <name> is returned.\n** Otherwise, if the only argument does not match the above pattern, an SQL\n** NULL is returned.\n**\n**     \"data_t1\"     -> \"t1\"\n**     \"data0123_t2\" -> \"t2\"\n**     \"dataAB_t3\"   -> NULL\n**\n** For an rbu vacuum handle, a copy of the first argument is returned if\n** the second argument is either missing or 0 (not a view).\n*/\nstatic void rbuTargetNameFunc(\n  sqlite3_context *pCtx,\n  int argc,\n  sqlite3_value **argv\n){\n  sqlite3rbu *p = sqlite3_user_data(pCtx);\n  const char *zIn;\n  assert( argc==1 || argc==2 );\n\n  zIn = (const char*)sqlite3_value_text(argv[0]);\n  if( zIn ){\n    if( rbuIsVacuum(p) ){\n      if( argc==1 || 0==sqlite3_value_int(argv[1]) ){\n        sqlite3_result_text(pCtx, zIn, -1, SQLITE_STATIC);\n      }\n    }else{\n      if( strlen(zIn)>4 && memcmp(\"data\", zIn, 4)==0 ){\n        int i;\n        for(i=4; zIn[i]>='0' && zIn[i]<='9'; i++);\n        if( zIn[i]=='_' && zIn[i+1] ){\n          sqlite3_result_text(pCtx, &zIn[i+1], -1, SQLITE_STATIC);\n        }\n      }\n    }\n  }\n}\n\n/*\n** Initialize the iterator structure passed as the second argument.\n**\n** If no error occurs, SQLITE_OK is returned and the iterator is left \n** pointing to the first entry. Otherwise, an error code and message is \n** left in the RBU handle passed as the first argument. A copy of the \n** error code is returned.\n*/\nstatic int rbuObjIterFirst(sqlite3rbu *p, RbuObjIter *pIter){\n  int rc;\n  memset(pIter, 0, sizeof(RbuObjIter));\n\n  rc = prepareFreeAndCollectError(p->dbRbu, &pIter->pTblIter, &p->zErrmsg, \n    sqlite3_mprintf(\n      \"SELECT rbu_target_name(name, type='view') AS target, name \"\n      \"FROM sqlite_master \"\n      \"WHERE type IN ('table', 'view') AND target IS NOT NULL \"\n      \" %s \"\n      \"ORDER BY name\"\n  , rbuIsVacuum(p) ? \"AND rootpage!=0 AND rootpage IS NOT NULL\" : \"\"));\n\n  if( rc==SQLITE_OK ){\n    rc = prepareAndCollectError(p->dbMain, &pIter->pIdxIter, &p->zErrmsg,\n        \"SELECT name, rootpage, sql IS NULL OR substr(8, 6)=='UNIQUE' \"\n        \"  FROM main.sqlite_master \"\n        \"  WHERE type='index' AND tbl_name = ?\"\n    );\n  }\n\n  pIter->bCleanup = 1;\n  p->rc = rc;\n  return rbuObjIterNext(p, pIter);\n}\n\n/*\n** This is a wrapper around \"sqlite3_mprintf(zFmt, ...)\". If an OOM occurs,\n** an error code is stored in the RBU handle passed as the first argument.\n**\n** If an error has already occurred (p->rc is already set to something other\n** than SQLITE_OK), then this function returns NULL without modifying the\n** stored error code. In this case it still calls sqlite3_free() on any \n** printf() parameters associated with %z conversions.\n*/\nstatic char *rbuMPrintf(sqlite3rbu *p, const char *zFmt, ...){\n  char *zSql = 0;\n  va_list ap;\n  va_start(ap, zFmt);\n  zSql = sqlite3_vmprintf(zFmt, ap);\n  if( p->rc==SQLITE_OK ){\n    if( zSql==0 ) p->rc = SQLITE_NOMEM;\n  }else{\n    sqlite3_free(zSql);\n    zSql = 0;\n  }\n  va_end(ap);\n  return zSql;\n}\n\n/*\n** Argument zFmt is a sqlite3_mprintf() style format string. The trailing\n** arguments are the usual subsitution values. This function performs\n** the printf() style substitutions and executes the result as an SQL\n** statement on the RBU handles database.\n**\n** If an error occurs, an error code and error message is stored in the\n** RBU handle. If an error has already occurred when this function is\n** called, it is a no-op.\n*/\nstatic int rbuMPrintfExec(sqlite3rbu *p, sqlite3 *db, const char *zFmt, ...){\n  va_list ap;\n  char *zSql;\n  va_start(ap, zFmt);\n  zSql = sqlite3_vmprintf(zFmt, ap);\n  if( p->rc==SQLITE_OK ){\n    if( zSql==0 ){\n      p->rc = SQLITE_NOMEM;\n    }else{\n      p->rc = sqlite3_exec(db, zSql, 0, 0, &p->zErrmsg);\n    }\n  }\n  sqlite3_free(zSql);\n  va_end(ap);\n  return p->rc;\n}\n\n/*\n** Attempt to allocate and return a pointer to a zeroed block of nByte \n** bytes. \n**\n** If an error (i.e. an OOM condition) occurs, return NULL and leave an \n** error code in the rbu handle passed as the first argument. Or, if an \n** error has already occurred when this function is called, return NULL \n** immediately without attempting the allocation or modifying the stored\n** error code.\n*/\nstatic void *rbuMalloc(sqlite3rbu *p, int nByte){\n  void *pRet = 0;\n  if( p->rc==SQLITE_OK ){\n    assert( nByte>0 );\n    pRet = sqlite3_malloc64(nByte);\n    if( pRet==0 ){\n      p->rc = SQLITE_NOMEM;\n    }else{\n      memset(pRet, 0, nByte);\n    }\n  }\n  return pRet;\n}\n\n\n/*\n** Allocate and zero the pIter->azTblCol[] and abTblPk[] arrays so that\n** there is room for at least nCol elements. If an OOM occurs, store an\n** error code in the RBU handle passed as the first argument.\n*/\nstatic void rbuAllocateIterArrays(sqlite3rbu *p, RbuObjIter *pIter, int nCol){\n  int nByte = (2*sizeof(char*) + sizeof(int) + 3*sizeof(u8)) * nCol;\n  char **azNew;\n\n  azNew = (char**)rbuMalloc(p, nByte);\n  if( azNew ){\n    pIter->azTblCol = azNew;\n    pIter->azTblType = &azNew[nCol];\n    pIter->aiSrcOrder = (int*)&pIter->azTblType[nCol];\n    pIter->abTblPk = (u8*)&pIter->aiSrcOrder[nCol];\n    pIter->abNotNull = (u8*)&pIter->abTblPk[nCol];\n    pIter->abIndexed = (u8*)&pIter->abNotNull[nCol];\n  }\n}\n\n/*\n** The first argument must be a nul-terminated string. This function\n** returns a copy of the string in memory obtained from sqlite3_malloc().\n** It is the responsibility of the caller to eventually free this memory\n** using sqlite3_free().\n**\n** If an OOM condition is encountered when attempting to allocate memory,\n** output variable (*pRc) is set to SQLITE_NOMEM before returning. Otherwise,\n** if the allocation succeeds, (*pRc) is left unchanged.\n*/\nstatic char *rbuStrndup(const char *zStr, int *pRc){\n  char *zRet = 0;\n\n  assert( *pRc==SQLITE_OK );\n  if( zStr ){\n    size_t nCopy = strlen(zStr) + 1;\n    zRet = (char*)sqlite3_malloc64(nCopy);\n    if( zRet ){\n      memcpy(zRet, zStr, nCopy);\n    }else{\n      *pRc = SQLITE_NOMEM;\n    }\n  }\n\n  return zRet;\n}\n\n/*\n** Finalize the statement passed as the second argument.\n**\n** If the sqlite3_finalize() call indicates that an error occurs, and the\n** rbu handle error code is not already set, set the error code and error\n** message accordingly.\n*/\nstatic void rbuFinalize(sqlite3rbu *p, sqlite3_stmt *pStmt){\n  sqlite3 *db = sqlite3_db_handle(pStmt);\n  int rc = sqlite3_finalize(pStmt);\n  if( p->rc==SQLITE_OK && rc!=SQLITE_OK ){\n    p->rc = rc;\n    p->zErrmsg = sqlite3_mprintf(\"%s\", sqlite3_errmsg(db));\n  }\n}\n\n/* Determine the type of a table.\n**\n**   peType is of type (int*), a pointer to an output parameter of type\n**   (int). This call sets the output parameter as follows, depending\n**   on the type of the table specified by parameters dbName and zTbl.\n**\n**     RBU_PK_NOTABLE:       No such table.\n**     RBU_PK_NONE:          Table has an implicit rowid.\n**     RBU_PK_IPK:           Table has an explicit IPK column.\n**     RBU_PK_EXTERNAL:      Table has an external PK index.\n**     RBU_PK_WITHOUT_ROWID: Table is WITHOUT ROWID.\n**     RBU_PK_VTAB:          Table is a virtual table.\n**\n**   Argument *piPk is also of type (int*), and also points to an output\n**   parameter. Unless the table has an external primary key index \n**   (i.e. unless *peType is set to 3), then *piPk is set to zero. Or,\n**   if the table does have an external primary key index, then *piPk\n**   is set to the root page number of the primary key index before\n**   returning.\n**\n** ALGORITHM:\n**\n**   if( no entry exists in sqlite_master ){\n**     return RBU_PK_NOTABLE\n**   }else if( sql for the entry starts with \"CREATE VIRTUAL\" ){\n**     return RBU_PK_VTAB\n**   }else if( \"PRAGMA index_list()\" for the table contains a \"pk\" index ){\n**     if( the index that is the pk exists in sqlite_master ){\n**       *piPK = rootpage of that index.\n**       return RBU_PK_EXTERNAL\n**     }else{\n**       return RBU_PK_WITHOUT_ROWID\n**     }\n**   }else if( \"PRAGMA table_info()\" lists one or more \"pk\" columns ){\n**     return RBU_PK_IPK\n**   }else{\n**     return RBU_PK_NONE\n**   }\n*/\nstatic void rbuTableType(\n  sqlite3rbu *p,\n  const char *zTab,\n  int *peType,\n  int *piTnum,\n  int *piPk\n){\n  /*\n  ** 0) SELECT count(*) FROM sqlite_master where name=%Q AND IsVirtual(%Q)\n  ** 1) PRAGMA index_list = ?\n  ** 2) SELECT count(*) FROM sqlite_master where name=%Q \n  ** 3) PRAGMA table_info = ?\n  */\n  sqlite3_stmt *aStmt[4] = {0, 0, 0, 0};\n\n  *peType = RBU_PK_NOTABLE;\n  *piPk = 0;\n\n  assert( p->rc==SQLITE_OK );\n  p->rc = prepareFreeAndCollectError(p->dbMain, &aStmt[0], &p->zErrmsg, \n    sqlite3_mprintf(\n          \"SELECT (sql LIKE 'create virtual%%'), rootpage\"\n          \"  FROM sqlite_master\"\n          \" WHERE name=%Q\", zTab\n  ));\n  if( p->rc!=SQLITE_OK || sqlite3_step(aStmt[0])!=SQLITE_ROW ){\n    /* Either an error, or no such table. */\n    goto rbuTableType_end;\n  }\n  if( sqlite3_column_int(aStmt[0], 0) ){\n    *peType = RBU_PK_VTAB;                     /* virtual table */\n    goto rbuTableType_end;\n  }\n  *piTnum = sqlite3_column_int(aStmt[0], 1);\n\n  p->rc = prepareFreeAndCollectError(p->dbMain, &aStmt[1], &p->zErrmsg, \n    sqlite3_mprintf(\"PRAGMA index_list=%Q\",zTab)\n  );\n  if( p->rc ) goto rbuTableType_end;\n  while( sqlite3_step(aStmt[1])==SQLITE_ROW ){\n    const u8 *zOrig = sqlite3_column_text(aStmt[1], 3);\n    const u8 *zIdx = sqlite3_column_text(aStmt[1], 1);\n    if( zOrig && zIdx && zOrig[0]=='p' ){\n      p->rc = prepareFreeAndCollectError(p->dbMain, &aStmt[2], &p->zErrmsg, \n          sqlite3_mprintf(\n            \"SELECT rootpage FROM sqlite_master WHERE name = %Q\", zIdx\n      ));\n      if( p->rc==SQLITE_OK ){\n        if( sqlite3_step(aStmt[2])==SQLITE_ROW ){\n          *piPk = sqlite3_column_int(aStmt[2], 0);\n          *peType = RBU_PK_EXTERNAL;\n        }else{\n          *peType = RBU_PK_WITHOUT_ROWID;\n        }\n      }\n      goto rbuTableType_end;\n    }\n  }\n\n  p->rc = prepareFreeAndCollectError(p->dbMain, &aStmt[3], &p->zErrmsg, \n    sqlite3_mprintf(\"PRAGMA table_info=%Q\",zTab)\n  );\n  if( p->rc==SQLITE_OK ){\n    while( sqlite3_step(aStmt[3])==SQLITE_ROW ){\n      if( sqlite3_column_int(aStmt[3],5)>0 ){\n        *peType = RBU_PK_IPK;                /* explicit IPK column */\n        goto rbuTableType_end;\n      }\n    }\n    *peType = RBU_PK_NONE;\n  }\n\nrbuTableType_end: {\n    unsigned int i;\n    for(i=0; i<sizeof(aStmt)/sizeof(aStmt[0]); i++){\n      rbuFinalize(p, aStmt[i]);\n    }\n  }\n}\n\n/*\n** This is a helper function for rbuObjIterCacheTableInfo(). It populates\n** the pIter->abIndexed[] array.\n*/\nstatic void rbuObjIterCacheIndexedCols(sqlite3rbu *p, RbuObjIter *pIter){\n  sqlite3_stmt *pList = 0;\n  int bIndex = 0;\n\n  if( p->rc==SQLITE_OK ){\n    memcpy(pIter->abIndexed, pIter->abTblPk, sizeof(u8)*pIter->nTblCol);\n    p->rc = prepareFreeAndCollectError(p->dbMain, &pList, &p->zErrmsg,\n        sqlite3_mprintf(\"PRAGMA main.index_list = %Q\", pIter->zTbl)\n    );\n  }\n\n  pIter->nIndex = 0;\n  while( p->rc==SQLITE_OK && SQLITE_ROW==sqlite3_step(pList) ){\n    const char *zIdx = (const char*)sqlite3_column_text(pList, 1);\n    sqlite3_stmt *pXInfo = 0;\n    if( zIdx==0 ) break;\n    p->rc = prepareFreeAndCollectError(p->dbMain, &pXInfo, &p->zErrmsg,\n        sqlite3_mprintf(\"PRAGMA main.index_xinfo = %Q\", zIdx)\n    );\n    while( p->rc==SQLITE_OK && SQLITE_ROW==sqlite3_step(pXInfo) ){\n      int iCid = sqlite3_column_int(pXInfo, 1);\n      if( iCid>=0 ) pIter->abIndexed[iCid] = 1;\n    }\n    rbuFinalize(p, pXInfo);\n    bIndex = 1;\n    pIter->nIndex++;\n  }\n\n  if( pIter->eType==RBU_PK_WITHOUT_ROWID ){\n    /* \"PRAGMA index_list\" includes the main PK b-tree */\n    pIter->nIndex--;\n  }\n\n  rbuFinalize(p, pList);\n  if( bIndex==0 ) pIter->abIndexed = 0;\n}\n\n\n/*\n** If they are not already populated, populate the pIter->azTblCol[],\n** pIter->abTblPk[], pIter->nTblCol and pIter->bRowid variables according to\n** the table (not index) that the iterator currently points to.\n**\n** Return SQLITE_OK if successful, or an SQLite error code otherwise. If\n** an error does occur, an error code and error message are also left in \n** the RBU handle.\n*/\nstatic int rbuObjIterCacheTableInfo(sqlite3rbu *p, RbuObjIter *pIter){\n  if( pIter->azTblCol==0 ){\n    sqlite3_stmt *pStmt = 0;\n    int nCol = 0;\n    int i;                        /* for() loop iterator variable */\n    int bRbuRowid = 0;            /* If input table has column \"rbu_rowid\" */\n    int iOrder = 0;\n    int iTnum = 0;\n\n    /* Figure out the type of table this step will deal with. */\n    assert( pIter->eType==0 );\n    rbuTableType(p, pIter->zTbl, &pIter->eType, &iTnum, &pIter->iPkTnum);\n    if( p->rc==SQLITE_OK && pIter->eType==RBU_PK_NOTABLE ){\n      p->rc = SQLITE_ERROR;\n      p->zErrmsg = sqlite3_mprintf(\"no such table: %s\", pIter->zTbl);\n    }\n    if( p->rc ) return p->rc;\n    if( pIter->zIdx==0 ) pIter->iTnum = iTnum;\n\n    assert( pIter->eType==RBU_PK_NONE || pIter->eType==RBU_PK_IPK \n         || pIter->eType==RBU_PK_EXTERNAL || pIter->eType==RBU_PK_WITHOUT_ROWID\n         || pIter->eType==RBU_PK_VTAB\n    );\n\n    /* Populate the azTblCol[] and nTblCol variables based on the columns\n    ** of the input table. Ignore any input table columns that begin with\n    ** \"rbu_\".  */\n    p->rc = prepareFreeAndCollectError(p->dbRbu, &pStmt, &p->zErrmsg, \n        sqlite3_mprintf(\"SELECT * FROM '%q'\", pIter->zDataTbl)\n    );\n    if( p->rc==SQLITE_OK ){\n      nCol = sqlite3_column_count(pStmt);\n      rbuAllocateIterArrays(p, pIter, nCol);\n    }\n    for(i=0; p->rc==SQLITE_OK && i<nCol; i++){\n      const char *zName = (const char*)sqlite3_column_name(pStmt, i);\n      if( sqlite3_strnicmp(\"rbu_\", zName, 4) ){\n        char *zCopy = rbuStrndup(zName, &p->rc);\n        pIter->aiSrcOrder[pIter->nTblCol] = pIter->nTblCol;\n        pIter->azTblCol[pIter->nTblCol++] = zCopy;\n      }\n      else if( 0==sqlite3_stricmp(\"rbu_rowid\", zName) ){\n        bRbuRowid = 1;\n      }\n    }\n    sqlite3_finalize(pStmt);\n    pStmt = 0;\n\n    if( p->rc==SQLITE_OK\n     && rbuIsVacuum(p)==0\n     && bRbuRowid!=(pIter->eType==RBU_PK_VTAB || pIter->eType==RBU_PK_NONE)\n    ){\n      p->rc = SQLITE_ERROR;\n      p->zErrmsg = sqlite3_mprintf(\n          \"table %q %s rbu_rowid column\", pIter->zDataTbl,\n          (bRbuRowid ? \"may not have\" : \"requires\")\n      );\n    }\n\n    /* Check that all non-HIDDEN columns in the destination table are also\n    ** present in the input table. Populate the abTblPk[], azTblType[] and\n    ** aiTblOrder[] arrays at the same time.  */\n    if( p->rc==SQLITE_OK ){\n      p->rc = prepareFreeAndCollectError(p->dbMain, &pStmt, &p->zErrmsg, \n          sqlite3_mprintf(\"PRAGMA table_info(%Q)\", pIter->zTbl)\n      );\n    }\n    while( p->rc==SQLITE_OK && SQLITE_ROW==sqlite3_step(pStmt) ){\n      const char *zName = (const char*)sqlite3_column_text(pStmt, 1);\n      if( zName==0 ) break;  /* An OOM - finalize() below returns S_NOMEM */\n      for(i=iOrder; i<pIter->nTblCol; i++){\n        if( 0==strcmp(zName, pIter->azTblCol[i]) ) break;\n      }\n      if( i==pIter->nTblCol ){\n        p->rc = SQLITE_ERROR;\n        p->zErrmsg = sqlite3_mprintf(\"column missing from %q: %s\",\n            pIter->zDataTbl, zName\n        );\n      }else{\n        int iPk = sqlite3_column_int(pStmt, 5);\n        int bNotNull = sqlite3_column_int(pStmt, 3);\n        const char *zType = (const char*)sqlite3_column_text(pStmt, 2);\n\n        if( i!=iOrder ){\n          SWAP(int, pIter->aiSrcOrder[i], pIter->aiSrcOrder[iOrder]);\n          SWAP(char*, pIter->azTblCol[i], pIter->azTblCol[iOrder]);\n        }\n\n        pIter->azTblType[iOrder] = rbuStrndup(zType, &p->rc);\n        pIter->abTblPk[iOrder] = (iPk!=0);\n        pIter->abNotNull[iOrder] = (u8)bNotNull || (iPk!=0);\n        iOrder++;\n      }\n    }\n\n    rbuFinalize(p, pStmt);\n    rbuObjIterCacheIndexedCols(p, pIter);\n    assert( pIter->eType!=RBU_PK_VTAB || pIter->abIndexed==0 );\n    assert( pIter->eType!=RBU_PK_VTAB || pIter->nIndex==0 );\n  }\n\n  return p->rc;\n}\n\n/*\n** This function constructs and returns a pointer to a nul-terminated \n** string containing some SQL clause or list based on one or more of the \n** column names currently stored in the pIter->azTblCol[] array.\n*/\nstatic char *rbuObjIterGetCollist(\n  sqlite3rbu *p,                  /* RBU object */\n  RbuObjIter *pIter               /* Object iterator for column names */\n){\n  char *zList = 0;\n  const char *zSep = \"\";\n  int i;\n  for(i=0; i<pIter->nTblCol; i++){\n    const char *z = pIter->azTblCol[i];\n    zList = rbuMPrintf(p, \"%z%s\\\"%w\\\"\", zList, zSep, z);\n    zSep = \", \";\n  }\n  return zList;\n}\n\n/*\n** This function is used to create a SELECT list (the list of SQL \n** expressions that follows a SELECT keyword) for a SELECT statement \n** used to read from an data_xxx or rbu_tmp_xxx table while updating the \n** index object currently indicated by the iterator object passed as the \n** second argument. A \"PRAGMA index_xinfo = <idxname>\" statement is used \n** to obtain the required information.\n**\n** If the index is of the following form:\n**\n**   CREATE INDEX i1 ON t1(c, b COLLATE nocase);\n**\n** and \"t1\" is a table with an explicit INTEGER PRIMARY KEY column \n** \"ipk\", the returned string is:\n**\n**   \"`c` COLLATE 'BINARY', `b` COLLATE 'NOCASE', `ipk` COLLATE 'BINARY'\"\n**\n** As well as the returned string, three other malloc'd strings are \n** returned via output parameters. As follows:\n**\n**   pzImposterCols: ...\n**   pzImposterPk: ...\n**   pzWhere: ...\n*/\nstatic char *rbuObjIterGetIndexCols(\n  sqlite3rbu *p,                  /* RBU object */\n  RbuObjIter *pIter,              /* Object iterator for column names */\n  char **pzImposterCols,          /* OUT: Columns for imposter table */\n  char **pzImposterPk,            /* OUT: Imposter PK clause */\n  char **pzWhere,                 /* OUT: WHERE clause */\n  int *pnBind                     /* OUT: Trbul number of columns */\n){\n  int rc = p->rc;                 /* Error code */\n  int rc2;                        /* sqlite3_finalize() return code */\n  char *zRet = 0;                 /* String to return */\n  char *zImpCols = 0;             /* String to return via *pzImposterCols */\n  char *zImpPK = 0;               /* String to return via *pzImposterPK */\n  char *zWhere = 0;               /* String to return via *pzWhere */\n  int nBind = 0;                  /* Value to return via *pnBind */\n  const char *zCom = \"\";          /* Set to \", \" later on */\n  const char *zAnd = \"\";          /* Set to \" AND \" later on */\n  sqlite3_stmt *pXInfo = 0;       /* PRAGMA index_xinfo = ? */\n\n  if( rc==SQLITE_OK ){\n    assert( p->zErrmsg==0 );\n    rc = prepareFreeAndCollectError(p->dbMain, &pXInfo, &p->zErrmsg,\n        sqlite3_mprintf(\"PRAGMA main.index_xinfo = %Q\", pIter->zIdx)\n    );\n  }\n\n  while( rc==SQLITE_OK && SQLITE_ROW==sqlite3_step(pXInfo) ){\n    int iCid = sqlite3_column_int(pXInfo, 1);\n    int bDesc = sqlite3_column_int(pXInfo, 3);\n    const char *zCollate = (const char*)sqlite3_column_text(pXInfo, 4);\n    const char *zCol;\n    const char *zType;\n\n    if( iCid<0 ){\n      /* An integer primary key. If the table has an explicit IPK, use\n      ** its name. Otherwise, use \"rbu_rowid\".  */\n      if( pIter->eType==RBU_PK_IPK ){\n        int i;\n        for(i=0; pIter->abTblPk[i]==0; i++);\n        assert( i<pIter->nTblCol );\n        zCol = pIter->azTblCol[i];\n      }else if( rbuIsVacuum(p) ){\n        zCol = \"_rowid_\";\n      }else{\n        zCol = \"rbu_rowid\";\n      }\n      zType = \"INTEGER\";\n    }else{\n      zCol = pIter->azTblCol[iCid];\n      zType = pIter->azTblType[iCid];\n    }\n\n    zRet = sqlite3_mprintf(\"%z%s\\\"%w\\\" COLLATE %Q\", zRet, zCom, zCol, zCollate);\n    if( pIter->bUnique==0 || sqlite3_column_int(pXInfo, 5) ){\n      const char *zOrder = (bDesc ? \" DESC\" : \"\");\n      zImpPK = sqlite3_mprintf(\"%z%s\\\"rbu_imp_%d%w\\\"%s\", \n          zImpPK, zCom, nBind, zCol, zOrder\n      );\n    }\n    zImpCols = sqlite3_mprintf(\"%z%s\\\"rbu_imp_%d%w\\\" %s COLLATE %Q\", \n        zImpCols, zCom, nBind, zCol, zType, zCollate\n    );\n    zWhere = sqlite3_mprintf(\n        \"%z%s\\\"rbu_imp_%d%w\\\" IS ?\", zWhere, zAnd, nBind, zCol\n    );\n    if( zRet==0 || zImpPK==0 || zImpCols==0 || zWhere==0 ) rc = SQLITE_NOMEM;\n    zCom = \", \";\n    zAnd = \" AND \";\n    nBind++;\n  }\n\n  rc2 = sqlite3_finalize(pXInfo);\n  if( rc==SQLITE_OK ) rc = rc2;\n\n  if( rc!=SQLITE_OK ){\n    sqlite3_free(zRet);\n    sqlite3_free(zImpCols);\n    sqlite3_free(zImpPK);\n    sqlite3_free(zWhere);\n    zRet = 0;\n    zImpCols = 0;\n    zImpPK = 0;\n    zWhere = 0;\n    p->rc = rc;\n  }\n\n  *pzImposterCols = zImpCols;\n  *pzImposterPk = zImpPK;\n  *pzWhere = zWhere;\n  *pnBind = nBind;\n  return zRet;\n}\n\n/*\n** Assuming the current table columns are \"a\", \"b\" and \"c\", and the zObj\n** paramter is passed \"old\", return a string of the form:\n**\n**     \"old.a, old.b, old.b\"\n**\n** With the column names escaped.\n**\n** For tables with implicit rowids - RBU_PK_EXTERNAL and RBU_PK_NONE, append\n** the text \", old._rowid_\" to the returned value.\n*/\nstatic char *rbuObjIterGetOldlist(\n  sqlite3rbu *p, \n  RbuObjIter *pIter,\n  const char *zObj\n){\n  char *zList = 0;\n  if( p->rc==SQLITE_OK && pIter->abIndexed ){\n    const char *zS = \"\";\n    int i;\n    for(i=0; i<pIter->nTblCol; i++){\n      if( pIter->abIndexed[i] ){\n        const char *zCol = pIter->azTblCol[i];\n        zList = sqlite3_mprintf(\"%z%s%s.\\\"%w\\\"\", zList, zS, zObj, zCol);\n      }else{\n        zList = sqlite3_mprintf(\"%z%sNULL\", zList, zS);\n      }\n      zS = \", \";\n      if( zList==0 ){\n        p->rc = SQLITE_NOMEM;\n        break;\n      }\n    }\n\n    /* For a table with implicit rowids, append \"old._rowid_\" to the list. */\n    if( pIter->eType==RBU_PK_EXTERNAL || pIter->eType==RBU_PK_NONE ){\n      zList = rbuMPrintf(p, \"%z, %s._rowid_\", zList, zObj);\n    }\n  }\n  return zList;\n}\n\n/*\n** Return an expression that can be used in a WHERE clause to match the\n** primary key of the current table. For example, if the table is:\n**\n**   CREATE TABLE t1(a, b, c, PRIMARY KEY(b, c));\n**\n** Return the string:\n**\n**   \"b = ?1 AND c = ?2\"\n*/\nstatic char *rbuObjIterGetWhere(\n  sqlite3rbu *p, \n  RbuObjIter *pIter\n){\n  char *zList = 0;\n  if( pIter->eType==RBU_PK_VTAB || pIter->eType==RBU_PK_NONE ){\n    zList = rbuMPrintf(p, \"_rowid_ = ?%d\", pIter->nTblCol+1);\n  }else if( pIter->eType==RBU_PK_EXTERNAL ){\n    const char *zSep = \"\";\n    int i;\n    for(i=0; i<pIter->nTblCol; i++){\n      if( pIter->abTblPk[i] ){\n        zList = rbuMPrintf(p, \"%z%sc%d=?%d\", zList, zSep, i, i+1);\n        zSep = \" AND \";\n      }\n    }\n    zList = rbuMPrintf(p, \n        \"_rowid_ = (SELECT id FROM rbu_imposter2 WHERE %z)\", zList\n    );\n\n  }else{\n    const char *zSep = \"\";\n    int i;\n    for(i=0; i<pIter->nTblCol; i++){\n      if( pIter->abTblPk[i] ){\n        const char *zCol = pIter->azTblCol[i];\n        zList = rbuMPrintf(p, \"%z%s\\\"%w\\\"=?%d\", zList, zSep, zCol, i+1);\n        zSep = \" AND \";\n      }\n    }\n  }\n  return zList;\n}\n\n/*\n** The SELECT statement iterating through the keys for the current object\n** (p->objiter.pSelect) currently points to a valid row. However, there\n** is something wrong with the rbu_control value in the rbu_control value\n** stored in the (p->nCol+1)'th column. Set the error code and error message\n** of the RBU handle to something reflecting this.\n*/\nstatic void rbuBadControlError(sqlite3rbu *p){\n  p->rc = SQLITE_ERROR;\n  p->zErrmsg = sqlite3_mprintf(\"invalid rbu_control value\");\n}\n\n\n/*\n** Return a nul-terminated string containing the comma separated list of\n** assignments that should be included following the \"SET\" keyword of\n** an UPDATE statement used to update the table object that the iterator\n** passed as the second argument currently points to if the rbu_control\n** column of the data_xxx table entry is set to zMask.\n**\n** The memory for the returned string is obtained from sqlite3_malloc().\n** It is the responsibility of the caller to eventually free it using\n** sqlite3_free(). \n**\n** If an OOM error is encountered when allocating space for the new\n** string, an error code is left in the rbu handle passed as the first\n** argument and NULL is returned. Or, if an error has already occurred\n** when this function is called, NULL is returned immediately, without\n** attempting the allocation or modifying the stored error code.\n*/\nstatic char *rbuObjIterGetSetlist(\n  sqlite3rbu *p,\n  RbuObjIter *pIter,\n  const char *zMask\n){\n  char *zList = 0;\n  if( p->rc==SQLITE_OK ){\n    int i;\n\n    if( (int)strlen(zMask)!=pIter->nTblCol ){\n      rbuBadControlError(p);\n    }else{\n      const char *zSep = \"\";\n      for(i=0; i<pIter->nTblCol; i++){\n        char c = zMask[pIter->aiSrcOrder[i]];\n        if( c=='x' ){\n          zList = rbuMPrintf(p, \"%z%s\\\"%w\\\"=?%d\", \n              zList, zSep, pIter->azTblCol[i], i+1\n          );\n          zSep = \", \";\n        }\n        else if( c=='d' ){\n          zList = rbuMPrintf(p, \"%z%s\\\"%w\\\"=rbu_delta(\\\"%w\\\", ?%d)\", \n              zList, zSep, pIter->azTblCol[i], pIter->azTblCol[i], i+1\n          );\n          zSep = \", \";\n        }\n        else if( c=='f' ){\n          zList = rbuMPrintf(p, \"%z%s\\\"%w\\\"=rbu_fossil_delta(\\\"%w\\\", ?%d)\", \n              zList, zSep, pIter->azTblCol[i], pIter->azTblCol[i], i+1\n          );\n          zSep = \", \";\n        }\n      }\n    }\n  }\n  return zList;\n}\n\n/*\n** Return a nul-terminated string consisting of nByte comma separated\n** \"?\" expressions. For example, if nByte is 3, return a pointer to\n** a buffer containing the string \"?,?,?\".\n**\n** The memory for the returned string is obtained from sqlite3_malloc().\n** It is the responsibility of the caller to eventually free it using\n** sqlite3_free(). \n**\n** If an OOM error is encountered when allocating space for the new\n** string, an error code is left in the rbu handle passed as the first\n** argument and NULL is returned. Or, if an error has already occurred\n** when this function is called, NULL is returned immediately, without\n** attempting the allocation or modifying the stored error code.\n*/\nstatic char *rbuObjIterGetBindlist(sqlite3rbu *p, int nBind){\n  char *zRet = 0;\n  int nByte = nBind*2 + 1;\n\n  zRet = (char*)rbuMalloc(p, nByte);\n  if( zRet ){\n    int i;\n    for(i=0; i<nBind; i++){\n      zRet[i*2] = '?';\n      zRet[i*2+1] = (i+1==nBind) ? '\\0' : ',';\n    }\n  }\n  return zRet;\n}\n\n/*\n** The iterator currently points to a table (not index) of type \n** RBU_PK_WITHOUT_ROWID. This function creates the PRIMARY KEY \n** declaration for the corresponding imposter table. For example,\n** if the iterator points to a table created as:\n**\n**   CREATE TABLE t1(a, b, c, PRIMARY KEY(b, a DESC)) WITHOUT ROWID\n**\n** this function returns:\n**\n**   PRIMARY KEY(\"b\", \"a\" DESC)\n*/\nstatic char *rbuWithoutRowidPK(sqlite3rbu *p, RbuObjIter *pIter){\n  char *z = 0;\n  assert( pIter->zIdx==0 );\n  if( p->rc==SQLITE_OK ){\n    const char *zSep = \"PRIMARY KEY(\";\n    sqlite3_stmt *pXList = 0;     /* PRAGMA index_list = (pIter->zTbl) */\n    sqlite3_stmt *pXInfo = 0;     /* PRAGMA index_xinfo = <pk-index> */\n   \n    p->rc = prepareFreeAndCollectError(p->dbMain, &pXList, &p->zErrmsg,\n        sqlite3_mprintf(\"PRAGMA main.index_list = %Q\", pIter->zTbl)\n    );\n    while( p->rc==SQLITE_OK && SQLITE_ROW==sqlite3_step(pXList) ){\n      const char *zOrig = (const char*)sqlite3_column_text(pXList,3);\n      if( zOrig && strcmp(zOrig, \"pk\")==0 ){\n        const char *zIdx = (const char*)sqlite3_column_text(pXList,1);\n        if( zIdx ){\n          p->rc = prepareFreeAndCollectError(p->dbMain, &pXInfo, &p->zErrmsg,\n              sqlite3_mprintf(\"PRAGMA main.index_xinfo = %Q\", zIdx)\n          );\n        }\n        break;\n      }\n    }\n    rbuFinalize(p, pXList);\n\n    while( p->rc==SQLITE_OK && SQLITE_ROW==sqlite3_step(pXInfo) ){\n      if( sqlite3_column_int(pXInfo, 5) ){\n        /* int iCid = sqlite3_column_int(pXInfo, 0); */\n        const char *zCol = (const char*)sqlite3_column_text(pXInfo, 2);\n        const char *zDesc = sqlite3_column_int(pXInfo, 3) ? \" DESC\" : \"\";\n        z = rbuMPrintf(p, \"%z%s\\\"%w\\\"%s\", z, zSep, zCol, zDesc);\n        zSep = \", \";\n      }\n    }\n    z = rbuMPrintf(p, \"%z)\", z);\n    rbuFinalize(p, pXInfo);\n  }\n  return z;\n}\n\n/*\n** This function creates the second imposter table used when writing to\n** a table b-tree where the table has an external primary key. If the\n** iterator passed as the second argument does not currently point to\n** a table (not index) with an external primary key, this function is a\n** no-op. \n**\n** Assuming the iterator does point to a table with an external PK, this\n** function creates a WITHOUT ROWID imposter table named \"rbu_imposter2\"\n** used to access that PK index. For example, if the target table is\n** declared as follows:\n**\n**   CREATE TABLE t1(a, b TEXT, c REAL, PRIMARY KEY(b, c));\n**\n** then the imposter table schema is:\n**\n**   CREATE TABLE rbu_imposter2(c1 TEXT, c2 REAL, id INTEGER) WITHOUT ROWID;\n**\n*/\nstatic void rbuCreateImposterTable2(sqlite3rbu *p, RbuObjIter *pIter){\n  if( p->rc==SQLITE_OK && pIter->eType==RBU_PK_EXTERNAL ){\n    int tnum = pIter->iPkTnum;    /* Root page of PK index */\n    sqlite3_stmt *pQuery = 0;     /* SELECT name ... WHERE rootpage = $tnum */\n    const char *zIdx = 0;         /* Name of PK index */\n    sqlite3_stmt *pXInfo = 0;     /* PRAGMA main.index_xinfo = $zIdx */\n    const char *zComma = \"\";\n    char *zCols = 0;              /* Used to build up list of table cols */\n    char *zPk = 0;                /* Used to build up table PK declaration */\n\n    /* Figure out the name of the primary key index for the current table.\n    ** This is needed for the argument to \"PRAGMA index_xinfo\". Set\n    ** zIdx to point to a nul-terminated string containing this name. */\n    p->rc = prepareAndCollectError(p->dbMain, &pQuery, &p->zErrmsg, \n        \"SELECT name FROM sqlite_master WHERE rootpage = ?\"\n    );\n    if( p->rc==SQLITE_OK ){\n      sqlite3_bind_int(pQuery, 1, tnum);\n      if( SQLITE_ROW==sqlite3_step(pQuery) ){\n        zIdx = (const char*)sqlite3_column_text(pQuery, 0);\n      }\n    }\n    if( zIdx ){\n      p->rc = prepareFreeAndCollectError(p->dbMain, &pXInfo, &p->zErrmsg,\n          sqlite3_mprintf(\"PRAGMA main.index_xinfo = %Q\", zIdx)\n      );\n    }\n    rbuFinalize(p, pQuery);\n\n    while( p->rc==SQLITE_OK && SQLITE_ROW==sqlite3_step(pXInfo) ){\n      int bKey = sqlite3_column_int(pXInfo, 5);\n      if( bKey ){\n        int iCid = sqlite3_column_int(pXInfo, 1);\n        int bDesc = sqlite3_column_int(pXInfo, 3);\n        const char *zCollate = (const char*)sqlite3_column_text(pXInfo, 4);\n        zCols = rbuMPrintf(p, \"%z%sc%d %s COLLATE %Q\", zCols, zComma, \n            iCid, pIter->azTblType[iCid], zCollate\n        );\n        zPk = rbuMPrintf(p, \"%z%sc%d%s\", zPk, zComma, iCid, bDesc?\" DESC\":\"\");\n        zComma = \", \";\n      }\n    }\n    zCols = rbuMPrintf(p, \"%z, id INTEGER\", zCols);\n    rbuFinalize(p, pXInfo);\n\n    sqlite3_test_control(SQLITE_TESTCTRL_IMPOSTER, p->dbMain, \"main\", 1, tnum);\n    rbuMPrintfExec(p, p->dbMain,\n        \"CREATE TABLE rbu_imposter2(%z, PRIMARY KEY(%z)) WITHOUT ROWID\", \n        zCols, zPk\n    );\n    sqlite3_test_control(SQLITE_TESTCTRL_IMPOSTER, p->dbMain, \"main\", 0, 0);\n  }\n}\n\n/*\n** If an error has already occurred when this function is called, it \n** immediately returns zero (without doing any work). Or, if an error\n** occurs during the execution of this function, it sets the error code\n** in the sqlite3rbu object indicated by the first argument and returns\n** zero.\n**\n** The iterator passed as the second argument is guaranteed to point to\n** a table (not an index) when this function is called. This function\n** attempts to create any imposter table required to write to the main\n** table b-tree of the table before returning. Non-zero is returned if\n** an imposter table are created, or zero otherwise.\n**\n** An imposter table is required in all cases except RBU_PK_VTAB. Only\n** virtual tables are written to directly. The imposter table has the \n** same schema as the actual target table (less any UNIQUE constraints). \n** More precisely, the \"same schema\" means the same columns, types, \n** collation sequences. For tables that do not have an external PRIMARY\n** KEY, it also means the same PRIMARY KEY declaration.\n*/\nstatic void rbuCreateImposterTable(sqlite3rbu *p, RbuObjIter *pIter){\n  if( p->rc==SQLITE_OK && pIter->eType!=RBU_PK_VTAB ){\n    int tnum = pIter->iTnum;\n    const char *zComma = \"\";\n    char *zSql = 0;\n    int iCol;\n    sqlite3_test_control(SQLITE_TESTCTRL_IMPOSTER, p->dbMain, \"main\", 0, 1);\n\n    for(iCol=0; p->rc==SQLITE_OK && iCol<pIter->nTblCol; iCol++){\n      const char *zPk = \"\";\n      const char *zCol = pIter->azTblCol[iCol];\n      const char *zColl = 0;\n\n      p->rc = sqlite3_table_column_metadata(\n          p->dbMain, \"main\", pIter->zTbl, zCol, 0, &zColl, 0, 0, 0\n      );\n\n      if( pIter->eType==RBU_PK_IPK && pIter->abTblPk[iCol] ){\n        /* If the target table column is an \"INTEGER PRIMARY KEY\", add\n        ** \"PRIMARY KEY\" to the imposter table column declaration. */\n        zPk = \"PRIMARY KEY \";\n      }\n      zSql = rbuMPrintf(p, \"%z%s\\\"%w\\\" %s %sCOLLATE %Q%s\", \n          zSql, zComma, zCol, pIter->azTblType[iCol], zPk, zColl,\n          (pIter->abNotNull[iCol] ? \" NOT NULL\" : \"\")\n      );\n      zComma = \", \";\n    }\n\n    if( pIter->eType==RBU_PK_WITHOUT_ROWID ){\n      char *zPk = rbuWithoutRowidPK(p, pIter);\n      if( zPk ){\n        zSql = rbuMPrintf(p, \"%z, %z\", zSql, zPk);\n      }\n    }\n\n    sqlite3_test_control(SQLITE_TESTCTRL_IMPOSTER, p->dbMain, \"main\", 1, tnum);\n    rbuMPrintfExec(p, p->dbMain, \"CREATE TABLE \\\"rbu_imp_%w\\\"(%z)%s\", \n        pIter->zTbl, zSql, \n        (pIter->eType==RBU_PK_WITHOUT_ROWID ? \" WITHOUT ROWID\" : \"\")\n    );\n    sqlite3_test_control(SQLITE_TESTCTRL_IMPOSTER, p->dbMain, \"main\", 0, 0);\n  }\n}\n\n/*\n** Prepare a statement used to insert rows into the \"rbu_tmp_xxx\" table.\n** Specifically a statement of the form:\n**\n**     INSERT INTO rbu_tmp_xxx VALUES(?, ?, ? ...);\n**\n** The number of bound variables is equal to the number of columns in\n** the target table, plus one (for the rbu_control column), plus one more \n** (for the rbu_rowid column) if the target table is an implicit IPK or \n** virtual table.\n*/\nstatic void rbuObjIterPrepareTmpInsert(\n  sqlite3rbu *p, \n  RbuObjIter *pIter,\n  const char *zCollist,\n  const char *zRbuRowid\n){\n  int bRbuRowid = (pIter->eType==RBU_PK_EXTERNAL || pIter->eType==RBU_PK_NONE);\n  char *zBind = rbuObjIterGetBindlist(p, pIter->nTblCol + 1 + bRbuRowid);\n  if( zBind ){\n    assert( pIter->pTmpInsert==0 );\n    p->rc = prepareFreeAndCollectError(\n        p->dbRbu, &pIter->pTmpInsert, &p->zErrmsg, sqlite3_mprintf(\n          \"INSERT INTO %s.'rbu_tmp_%q'(rbu_control,%s%s) VALUES(%z)\", \n          p->zStateDb, pIter->zDataTbl, zCollist, zRbuRowid, zBind\n    ));\n  }\n}\n\nstatic void rbuTmpInsertFunc(\n  sqlite3_context *pCtx, \n  int nVal,\n  sqlite3_value **apVal\n){\n  sqlite3rbu *p = sqlite3_user_data(pCtx);\n  int rc = SQLITE_OK;\n  int i;\n\n  assert( sqlite3_value_int(apVal[0])!=0\n      || p->objiter.eType==RBU_PK_EXTERNAL \n      || p->objiter.eType==RBU_PK_NONE \n  );\n  if( sqlite3_value_int(apVal[0])!=0 ){\n    p->nPhaseOneStep += p->objiter.nIndex;\n  }\n\n  for(i=0; rc==SQLITE_OK && i<nVal; i++){\n    rc = sqlite3_bind_value(p->objiter.pTmpInsert, i+1, apVal[i]);\n  }\n  if( rc==SQLITE_OK ){\n    sqlite3_step(p->objiter.pTmpInsert);\n    rc = sqlite3_reset(p->objiter.pTmpInsert);\n  }\n\n  if( rc!=SQLITE_OK ){\n    sqlite3_result_error_code(pCtx, rc);\n  }\n}\n\n/*\n** Ensure that the SQLite statement handles required to update the \n** target database object currently indicated by the iterator passed \n** as the second argument are available.\n*/\nstatic int rbuObjIterPrepareAll(\n  sqlite3rbu *p, \n  RbuObjIter *pIter,\n  int nOffset                     /* Add \"LIMIT -1 OFFSET $nOffset\" to SELECT */\n){\n  assert( pIter->bCleanup==0 );\n  if( pIter->pSelect==0 && rbuObjIterCacheTableInfo(p, pIter)==SQLITE_OK ){\n    const int tnum = pIter->iTnum;\n    char *zCollist = 0;           /* List of indexed columns */\n    char **pz = &p->zErrmsg;\n    const char *zIdx = pIter->zIdx;\n    char *zLimit = 0;\n\n    if( nOffset ){\n      zLimit = sqlite3_mprintf(\" LIMIT -1 OFFSET %d\", nOffset);\n      if( !zLimit ) p->rc = SQLITE_NOMEM;\n    }\n\n    if( zIdx ){\n      const char *zTbl = pIter->zTbl;\n      char *zImposterCols = 0;    /* Columns for imposter table */\n      char *zImposterPK = 0;      /* Primary key declaration for imposter */\n      char *zWhere = 0;           /* WHERE clause on PK columns */\n      char *zBind = 0;\n      int nBind = 0;\n\n      assert( pIter->eType!=RBU_PK_VTAB );\n      zCollist = rbuObjIterGetIndexCols(\n          p, pIter, &zImposterCols, &zImposterPK, &zWhere, &nBind\n      );\n      zBind = rbuObjIterGetBindlist(p, nBind);\n\n      /* Create the imposter table used to write to this index. */\n      sqlite3_test_control(SQLITE_TESTCTRL_IMPOSTER, p->dbMain, \"main\", 0, 1);\n      sqlite3_test_control(SQLITE_TESTCTRL_IMPOSTER, p->dbMain, \"main\", 1,tnum);\n      rbuMPrintfExec(p, p->dbMain,\n          \"CREATE TABLE \\\"rbu_imp_%w\\\"( %s, PRIMARY KEY( %s ) ) WITHOUT ROWID\",\n          zTbl, zImposterCols, zImposterPK\n      );\n      sqlite3_test_control(SQLITE_TESTCTRL_IMPOSTER, p->dbMain, \"main\", 0, 0);\n\n      /* Create the statement to insert index entries */\n      pIter->nCol = nBind;\n      if( p->rc==SQLITE_OK ){\n        p->rc = prepareFreeAndCollectError(\n            p->dbMain, &pIter->pInsert, &p->zErrmsg,\n          sqlite3_mprintf(\"INSERT INTO \\\"rbu_imp_%w\\\" VALUES(%s)\", zTbl, zBind)\n        );\n      }\n\n      /* And to delete index entries */\n      if( rbuIsVacuum(p)==0 && p->rc==SQLITE_OK ){\n        p->rc = prepareFreeAndCollectError(\n            p->dbMain, &pIter->pDelete, &p->zErrmsg,\n          sqlite3_mprintf(\"DELETE FROM \\\"rbu_imp_%w\\\" WHERE %s\", zTbl, zWhere)\n        );\n      }\n\n      /* Create the SELECT statement to read keys in sorted order */\n      if( p->rc==SQLITE_OK ){\n        char *zSql;\n        if( rbuIsVacuum(p) ){\n          zSql = sqlite3_mprintf(\n              \"SELECT %s, 0 AS rbu_control FROM '%q' ORDER BY %s%s\",\n              zCollist, \n              pIter->zDataTbl,\n              zCollist, zLimit\n          );\n        }else\n\n        if( pIter->eType==RBU_PK_EXTERNAL || pIter->eType==RBU_PK_NONE ){\n          zSql = sqlite3_mprintf(\n              \"SELECT %s, rbu_control FROM %s.'rbu_tmp_%q' ORDER BY %s%s\",\n              zCollist, p->zStateDb, pIter->zDataTbl,\n              zCollist, zLimit\n          );\n        }else{\n          zSql = sqlite3_mprintf(\n              \"SELECT %s, rbu_control FROM %s.'rbu_tmp_%q' \"\n              \"UNION ALL \"\n              \"SELECT %s, rbu_control FROM '%q' \"\n              \"WHERE typeof(rbu_control)='integer' AND rbu_control!=1 \"\n              \"ORDER BY %s%s\",\n              zCollist, p->zStateDb, pIter->zDataTbl, \n              zCollist, pIter->zDataTbl, \n              zCollist, zLimit\n          );\n        }\n        p->rc = prepareFreeAndCollectError(p->dbRbu, &pIter->pSelect, pz, zSql);\n      }\n\n      sqlite3_free(zImposterCols);\n      sqlite3_free(zImposterPK);\n      sqlite3_free(zWhere);\n      sqlite3_free(zBind);\n    }else{\n      int bRbuRowid = (pIter->eType==RBU_PK_VTAB)\n                    ||(pIter->eType==RBU_PK_NONE)\n                    ||(pIter->eType==RBU_PK_EXTERNAL && rbuIsVacuum(p));\n      const char *zTbl = pIter->zTbl;       /* Table this step applies to */\n      const char *zWrite;                   /* Imposter table name */\n\n      char *zBindings = rbuObjIterGetBindlist(p, pIter->nTblCol + bRbuRowid);\n      char *zWhere = rbuObjIterGetWhere(p, pIter);\n      char *zOldlist = rbuObjIterGetOldlist(p, pIter, \"old\");\n      char *zNewlist = rbuObjIterGetOldlist(p, pIter, \"new\");\n\n      zCollist = rbuObjIterGetCollist(p, pIter);\n      pIter->nCol = pIter->nTblCol;\n\n      /* Create the imposter table or tables (if required). */\n      rbuCreateImposterTable(p, pIter);\n      rbuCreateImposterTable2(p, pIter);\n      zWrite = (pIter->eType==RBU_PK_VTAB ? \"\" : \"rbu_imp_\");\n\n      /* Create the INSERT statement to write to the target PK b-tree */\n      if( p->rc==SQLITE_OK ){\n        p->rc = prepareFreeAndCollectError(p->dbMain, &pIter->pInsert, pz,\n            sqlite3_mprintf(\n              \"INSERT INTO \\\"%s%w\\\"(%s%s) VALUES(%s)\", \n              zWrite, zTbl, zCollist, (bRbuRowid ? \", _rowid_\" : \"\"), zBindings\n            )\n        );\n      }\n\n      /* Create the DELETE statement to write to the target PK b-tree.\n      ** Because it only performs INSERT operations, this is not required for\n      ** an rbu vacuum handle.  */\n      if( rbuIsVacuum(p)==0 && p->rc==SQLITE_OK ){\n        p->rc = prepareFreeAndCollectError(p->dbMain, &pIter->pDelete, pz,\n            sqlite3_mprintf(\n              \"DELETE FROM \\\"%s%w\\\" WHERE %s\", zWrite, zTbl, zWhere\n            )\n        );\n      }\n\n      if( rbuIsVacuum(p)==0 && pIter->abIndexed ){\n        const char *zRbuRowid = \"\";\n        if( pIter->eType==RBU_PK_EXTERNAL || pIter->eType==RBU_PK_NONE ){\n          zRbuRowid = \", rbu_rowid\";\n        }\n\n        /* Create the rbu_tmp_xxx table and the triggers to populate it. */\n        rbuMPrintfExec(p, p->dbRbu,\n            \"CREATE TABLE IF NOT EXISTS %s.'rbu_tmp_%q' AS \"\n            \"SELECT *%s FROM '%q' WHERE 0;\"\n            , p->zStateDb, pIter->zDataTbl\n            , (pIter->eType==RBU_PK_EXTERNAL ? \", 0 AS rbu_rowid\" : \"\")\n            , pIter->zDataTbl\n        );\n\n        rbuMPrintfExec(p, p->dbMain,\n            \"CREATE TEMP TRIGGER rbu_delete_tr BEFORE DELETE ON \\\"%s%w\\\" \"\n            \"BEGIN \"\n            \"  SELECT rbu_tmp_insert(3, %s);\"\n            \"END;\"\n\n            \"CREATE TEMP TRIGGER rbu_update1_tr BEFORE UPDATE ON \\\"%s%w\\\" \"\n            \"BEGIN \"\n            \"  SELECT rbu_tmp_insert(3, %s);\"\n            \"END;\"\n\n            \"CREATE TEMP TRIGGER rbu_update2_tr AFTER UPDATE ON \\\"%s%w\\\" \"\n            \"BEGIN \"\n            \"  SELECT rbu_tmp_insert(4, %s);\"\n            \"END;\",\n            zWrite, zTbl, zOldlist,\n            zWrite, zTbl, zOldlist,\n            zWrite, zTbl, zNewlist\n        );\n\n        if( pIter->eType==RBU_PK_EXTERNAL || pIter->eType==RBU_PK_NONE ){\n          rbuMPrintfExec(p, p->dbMain,\n              \"CREATE TEMP TRIGGER rbu_insert_tr AFTER INSERT ON \\\"%s%w\\\" \"\n              \"BEGIN \"\n              \"  SELECT rbu_tmp_insert(0, %s);\"\n              \"END;\",\n              zWrite, zTbl, zNewlist\n          );\n        }\n\n        rbuObjIterPrepareTmpInsert(p, pIter, zCollist, zRbuRowid);\n      }\n\n      /* Create the SELECT statement to read keys from data_xxx */\n      if( p->rc==SQLITE_OK ){\n        const char *zRbuRowid = \"\";\n        if( bRbuRowid ){\n          zRbuRowid = rbuIsVacuum(p) ? \",_rowid_ \" : \",rbu_rowid\";\n        }\n        p->rc = prepareFreeAndCollectError(p->dbRbu, &pIter->pSelect, pz,\n            sqlite3_mprintf(\n              \"SELECT %s,%s rbu_control%s FROM '%q'%s\", \n              zCollist, \n              (rbuIsVacuum(p) ? \"0 AS \" : \"\"),\n              zRbuRowid,\n              pIter->zDataTbl, zLimit\n            )\n        );\n      }\n\n      sqlite3_free(zWhere);\n      sqlite3_free(zOldlist);\n      sqlite3_free(zNewlist);\n      sqlite3_free(zBindings);\n    }\n    sqlite3_free(zCollist);\n    sqlite3_free(zLimit);\n  }\n  \n  return p->rc;\n}\n\n/*\n** Set output variable *ppStmt to point to an UPDATE statement that may\n** be used to update the imposter table for the main table b-tree of the\n** table object that pIter currently points to, assuming that the \n** rbu_control column of the data_xyz table contains zMask.\n** \n** If the zMask string does not specify any columns to update, then this\n** is not an error. Output variable *ppStmt is set to NULL in this case.\n*/\nstatic int rbuGetUpdateStmt(\n  sqlite3rbu *p,                  /* RBU handle */\n  RbuObjIter *pIter,              /* Object iterator */\n  const char *zMask,              /* rbu_control value ('x.x.') */\n  sqlite3_stmt **ppStmt           /* OUT: UPDATE statement handle */\n){\n  RbuUpdateStmt **pp;\n  RbuUpdateStmt *pUp = 0;\n  int nUp = 0;\n\n  /* In case an error occurs */\n  *ppStmt = 0;\n\n  /* Search for an existing statement. If one is found, shift it to the front\n  ** of the LRU queue and return immediately. Otherwise, leave nUp pointing\n  ** to the number of statements currently in the cache and pUp to the\n  ** last object in the list.  */\n  for(pp=&pIter->pRbuUpdate; *pp; pp=&((*pp)->pNext)){\n    pUp = *pp;\n    if( strcmp(pUp->zMask, zMask)==0 ){\n      *pp = pUp->pNext;\n      pUp->pNext = pIter->pRbuUpdate;\n      pIter->pRbuUpdate = pUp;\n      *ppStmt = pUp->pUpdate; \n      return SQLITE_OK;\n    }\n    nUp++;\n  }\n  assert( pUp==0 || pUp->pNext==0 );\n\n  if( nUp>=SQLITE_RBU_UPDATE_CACHESIZE ){\n    for(pp=&pIter->pRbuUpdate; *pp!=pUp; pp=&((*pp)->pNext));\n    *pp = 0;\n    sqlite3_finalize(pUp->pUpdate);\n    pUp->pUpdate = 0;\n  }else{\n    pUp = (RbuUpdateStmt*)rbuMalloc(p, sizeof(RbuUpdateStmt)+pIter->nTblCol+1);\n  }\n\n  if( pUp ){\n    char *zWhere = rbuObjIterGetWhere(p, pIter);\n    char *zSet = rbuObjIterGetSetlist(p, pIter, zMask);\n    char *zUpdate = 0;\n\n    pUp->zMask = (char*)&pUp[1];\n    memcpy(pUp->zMask, zMask, pIter->nTblCol);\n    pUp->pNext = pIter->pRbuUpdate;\n    pIter->pRbuUpdate = pUp;\n\n    if( zSet ){\n      const char *zPrefix = \"\";\n\n      if( pIter->eType!=RBU_PK_VTAB ) zPrefix = \"rbu_imp_\";\n      zUpdate = sqlite3_mprintf(\"UPDATE \\\"%s%w\\\" SET %s WHERE %s\", \n          zPrefix, pIter->zTbl, zSet, zWhere\n      );\n      p->rc = prepareFreeAndCollectError(\n          p->dbMain, &pUp->pUpdate, &p->zErrmsg, zUpdate\n      );\n      *ppStmt = pUp->pUpdate;\n    }\n    sqlite3_free(zWhere);\n    sqlite3_free(zSet);\n  }\n\n  return p->rc;\n}\n\nstatic sqlite3 *rbuOpenDbhandle(\n  sqlite3rbu *p, \n  const char *zName, \n  int bUseVfs\n){\n  sqlite3 *db = 0;\n  if( p->rc==SQLITE_OK ){\n    const int flags = SQLITE_OPEN_READWRITE|SQLITE_OPEN_CREATE|SQLITE_OPEN_URI;\n    p->rc = sqlite3_open_v2(zName, &db, flags, bUseVfs ? p->zVfsName : 0);\n    if( p->rc ){\n      p->zErrmsg = sqlite3_mprintf(\"%s\", sqlite3_errmsg(db));\n      sqlite3_close(db);\n      db = 0;\n    }\n  }\n  return db;\n}\n\n/*\n** Free an RbuState object allocated by rbuLoadState().\n*/\nstatic void rbuFreeState(RbuState *p){\n  if( p ){\n    sqlite3_free(p->zTbl);\n    sqlite3_free(p->zDataTbl);\n    sqlite3_free(p->zIdx);\n    sqlite3_free(p);\n  }\n}\n\n/*\n** Allocate an RbuState object and load the contents of the rbu_state \n** table into it. Return a pointer to the new object. It is the \n** responsibility of the caller to eventually free the object using\n** sqlite3_free().\n**\n** If an error occurs, leave an error code and message in the rbu handle\n** and return NULL.\n*/\nstatic RbuState *rbuLoadState(sqlite3rbu *p){\n  RbuState *pRet = 0;\n  sqlite3_stmt *pStmt = 0;\n  int rc;\n  int rc2;\n\n  pRet = (RbuState*)rbuMalloc(p, sizeof(RbuState));\n  if( pRet==0 ) return 0;\n\n  rc = prepareFreeAndCollectError(p->dbRbu, &pStmt, &p->zErrmsg, \n      sqlite3_mprintf(\"SELECT k, v FROM %s.rbu_state\", p->zStateDb)\n  );\n  while( rc==SQLITE_OK && SQLITE_ROW==sqlite3_step(pStmt) ){\n    switch( sqlite3_column_int(pStmt, 0) ){\n      case RBU_STATE_STAGE:\n        pRet->eStage = sqlite3_column_int(pStmt, 1);\n        if( pRet->eStage!=RBU_STAGE_OAL\n         && pRet->eStage!=RBU_STAGE_MOVE\n         && pRet->eStage!=RBU_STAGE_CKPT\n        ){\n          p->rc = SQLITE_CORRUPT;\n        }\n        break;\n\n      case RBU_STATE_TBL:\n        pRet->zTbl = rbuStrndup((char*)sqlite3_column_text(pStmt, 1), &rc);\n        break;\n\n      case RBU_STATE_IDX:\n        pRet->zIdx = rbuStrndup((char*)sqlite3_column_text(pStmt, 1), &rc);\n        break;\n\n      case RBU_STATE_ROW:\n        pRet->nRow = sqlite3_column_int(pStmt, 1);\n        break;\n\n      case RBU_STATE_PROGRESS:\n        pRet->nProgress = sqlite3_column_int64(pStmt, 1);\n        break;\n\n      case RBU_STATE_CKPT:\n        pRet->iWalCksum = sqlite3_column_int64(pStmt, 1);\n        break;\n\n      case RBU_STATE_COOKIE:\n        pRet->iCookie = (u32)sqlite3_column_int64(pStmt, 1);\n        break;\n\n      case RBU_STATE_OALSZ:\n        pRet->iOalSz = (u32)sqlite3_column_int64(pStmt, 1);\n        break;\n\n      case RBU_STATE_PHASEONESTEP:\n        pRet->nPhaseOneStep = sqlite3_column_int64(pStmt, 1);\n        break;\n\n      case RBU_STATE_DATATBL:\n        pRet->zDataTbl = rbuStrndup((char*)sqlite3_column_text(pStmt, 1), &rc);\n        break;\n\n      default:\n        rc = SQLITE_CORRUPT;\n        break;\n    }\n  }\n  rc2 = sqlite3_finalize(pStmt);\n  if( rc==SQLITE_OK ) rc = rc2;\n\n  p->rc = rc;\n  return pRet;\n}\n\n\n/*\n** Open the database handle and attach the RBU database as \"rbu\". If an\n** error occurs, leave an error code and message in the RBU handle.\n*/\nstatic void rbuOpenDatabase(sqlite3rbu *p, int *pbRetry){\n  assert( p->rc || (p->dbMain==0 && p->dbRbu==0) );\n  assert( p->rc || rbuIsVacuum(p) || p->zTarget!=0 );\n\n  /* Open the RBU database */\n  p->dbRbu = rbuOpenDbhandle(p, p->zRbu, 1);\n\n  if( p->rc==SQLITE_OK && rbuIsVacuum(p) ){\n    sqlite3_file_control(p->dbRbu, \"main\", SQLITE_FCNTL_RBUCNT, (void*)p);\n    if( p->zState==0 ){\n      const char *zFile = sqlite3_db_filename(p->dbRbu, \"main\");\n      p->zState = rbuMPrintf(p, \"file://%s-vacuum?modeof=%s\", zFile, zFile);\n    }\n  }\n\n  /* If using separate RBU and state databases, attach the state database to\n  ** the RBU db handle now.  */\n  if( p->zState ){\n    rbuMPrintfExec(p, p->dbRbu, \"ATTACH %Q AS stat\", p->zState);\n    memcpy(p->zStateDb, \"stat\", 4);\n  }else{\n    memcpy(p->zStateDb, \"main\", 4);\n  }\n\n#if 0\n  if( p->rc==SQLITE_OK && rbuIsVacuum(p) ){\n    p->rc = sqlite3_exec(p->dbRbu, \"BEGIN\", 0, 0, 0);\n  }\n#endif\n\n  /* If it has not already been created, create the rbu_state table */\n  rbuMPrintfExec(p, p->dbRbu, RBU_CREATE_STATE, p->zStateDb);\n\n#if 0\n  if( rbuIsVacuum(p) ){\n    if( p->rc==SQLITE_OK ){\n      int rc2;\n      int bOk = 0;\n      sqlite3_stmt *pCnt = 0;\n      p->rc = prepareAndCollectError(p->dbRbu, &pCnt, &p->zErrmsg,\n          \"SELECT count(*) FROM stat.sqlite_master\"\n      );\n      if( p->rc==SQLITE_OK \n       && sqlite3_step(pCnt)==SQLITE_ROW\n       && 1==sqlite3_column_int(pCnt, 0)\n      ){\n        bOk = 1;\n      }\n      rc2 = sqlite3_finalize(pCnt);\n      if( p->rc==SQLITE_OK ) p->rc = rc2;\n\n      if( p->rc==SQLITE_OK && bOk==0 ){\n        p->rc = SQLITE_ERROR;\n        p->zErrmsg = sqlite3_mprintf(\"invalid state database\");\n      }\n    \n      if( p->rc==SQLITE_OK ){\n        p->rc = sqlite3_exec(p->dbRbu, \"COMMIT\", 0, 0, 0);\n      }\n    }\n  }\n#endif\n\n  if( p->rc==SQLITE_OK && rbuIsVacuum(p) ){\n    int bOpen = 0;\n    int rc;\n    p->nRbu = 0;\n    p->pRbuFd = 0;\n    rc = sqlite3_file_control(p->dbRbu, \"main\", SQLITE_FCNTL_RBUCNT, (void*)p);\n    if( rc!=SQLITE_NOTFOUND ) p->rc = rc;\n    if( p->eStage>=RBU_STAGE_MOVE ){\n      bOpen = 1;\n    }else{\n      RbuState *pState = rbuLoadState(p);\n      if( pState ){\n        bOpen = (pState->eStage>=RBU_STAGE_MOVE);\n        rbuFreeState(pState);\n      }\n    }\n    if( bOpen ) p->dbMain = rbuOpenDbhandle(p, p->zRbu, p->nRbu<=1);\n  }\n\n  p->eStage = 0;\n  if( p->rc==SQLITE_OK && p->dbMain==0 ){\n    if( !rbuIsVacuum(p) ){\n      p->dbMain = rbuOpenDbhandle(p, p->zTarget, 1);\n    }else if( p->pRbuFd->pWalFd ){\n      if( pbRetry ){\n        p->pRbuFd->bNolock = 0;\n        sqlite3_close(p->dbRbu);\n        sqlite3_close(p->dbMain);\n        p->dbMain = 0;\n        p->dbRbu = 0;\n        *pbRetry = 1;\n        return;\n      }\n      p->rc = SQLITE_ERROR;\n      p->zErrmsg = sqlite3_mprintf(\"cannot vacuum wal mode database\");\n    }else{\n      char *zTarget;\n      char *zExtra = 0;\n      if( strlen(p->zRbu)>=5 && 0==memcmp(\"file:\", p->zRbu, 5) ){\n        zExtra = &p->zRbu[5];\n        while( *zExtra ){\n          if( *zExtra++=='?' ) break;\n        }\n        if( *zExtra=='\\0' ) zExtra = 0;\n      }\n\n      zTarget = sqlite3_mprintf(\"file:%s-vactmp?rbu_memory=1%s%s\", \n          sqlite3_db_filename(p->dbRbu, \"main\"),\n          (zExtra==0 ? \"\" : \"&\"), (zExtra==0 ? \"\" : zExtra)\n      );\n\n      if( zTarget==0 ){\n        p->rc = SQLITE_NOMEM;\n        return;\n      }\n      p->dbMain = rbuOpenDbhandle(p, zTarget, p->nRbu<=1);\n      sqlite3_free(zTarget);\n    }\n  }\n\n  if( p->rc==SQLITE_OK ){\n    p->rc = sqlite3_create_function(p->dbMain, \n        \"rbu_tmp_insert\", -1, SQLITE_UTF8, (void*)p, rbuTmpInsertFunc, 0, 0\n    );\n  }\n\n  if( p->rc==SQLITE_OK ){\n    p->rc = sqlite3_create_function(p->dbMain, \n        \"rbu_fossil_delta\", 2, SQLITE_UTF8, 0, rbuFossilDeltaFunc, 0, 0\n    );\n  }\n\n  if( p->rc==SQLITE_OK ){\n    p->rc = sqlite3_create_function(p->dbRbu, \n        \"rbu_target_name\", -1, SQLITE_UTF8, (void*)p, rbuTargetNameFunc, 0, 0\n    );\n  }\n\n  if( p->rc==SQLITE_OK ){\n    p->rc = sqlite3_file_control(p->dbMain, \"main\", SQLITE_FCNTL_RBU, (void*)p);\n  }\n  rbuMPrintfExec(p, p->dbMain, \"SELECT * FROM sqlite_master\");\n\n  /* Mark the database file just opened as an RBU target database. If \n  ** this call returns SQLITE_NOTFOUND, then the RBU vfs is not in use.\n  ** This is an error.  */\n  if( p->rc==SQLITE_OK ){\n    p->rc = sqlite3_file_control(p->dbMain, \"main\", SQLITE_FCNTL_RBU, (void*)p);\n  }\n\n  if( p->rc==SQLITE_NOTFOUND ){\n    p->rc = SQLITE_ERROR;\n    p->zErrmsg = sqlite3_mprintf(\"rbu vfs not found\");\n  }\n}\n\n/*\n** This routine is a copy of the sqlite3FileSuffix3() routine from the core.\n** It is a no-op unless SQLITE_ENABLE_8_3_NAMES is defined.\n**\n** If SQLITE_ENABLE_8_3_NAMES is set at compile-time and if the database\n** filename in zBaseFilename is a URI with the \"8_3_names=1\" parameter and\n** if filename in z[] has a suffix (a.k.a. \"extension\") that is longer than\n** three characters, then shorten the suffix on z[] to be the last three\n** characters of the original suffix.\n**\n** If SQLITE_ENABLE_8_3_NAMES is set to 2 at compile-time, then always\n** do the suffix shortening regardless of URI parameter.\n**\n** Examples:\n**\n**     test.db-journal    =>   test.nal\n**     test.db-wal        =>   test.wal\n**     test.db-shm        =>   test.shm\n**     test.db-mj7f3319fa =>   test.9fa\n*/\nstatic void rbuFileSuffix3(const char *zBase, char *z){\n#ifdef SQLITE_ENABLE_8_3_NAMES\n#if SQLITE_ENABLE_8_3_NAMES<2\n  if( sqlite3_uri_boolean(zBase, \"8_3_names\", 0) )\n#endif\n  {\n    int i, sz;\n    sz = (int)strlen(z)&0xffffff;\n    for(i=sz-1; i>0 && z[i]!='/' && z[i]!='.'; i--){}\n    if( z[i]=='.' && sz>i+4 ) memmove(&z[i+1], &z[sz-3], 4);\n  }\n#endif\n}\n\n/*\n** Return the current wal-index header checksum for the target database \n** as a 64-bit integer.\n**\n** The checksum is store in the first page of xShmMap memory as an 8-byte \n** blob starting at byte offset 40.\n*/\nstatic i64 rbuShmChecksum(sqlite3rbu *p){\n  i64 iRet = 0;\n  if( p->rc==SQLITE_OK ){\n    sqlite3_file *pDb = p->pTargetFd->pReal;\n    u32 volatile *ptr;\n    p->rc = pDb->pMethods->xShmMap(pDb, 0, 32*1024, 0, (void volatile**)&ptr);\n    if( p->rc==SQLITE_OK ){\n      iRet = ((i64)ptr[10] << 32) + ptr[11];\n    }\n  }\n  return iRet;\n}\n\n/*\n** This function is called as part of initializing or reinitializing an\n** incremental checkpoint. \n**\n** It populates the sqlite3rbu.aFrame[] array with the set of \n** (wal frame -> db page) copy operations required to checkpoint the \n** current wal file, and obtains the set of shm locks required to safely \n** perform the copy operations directly on the file-system.\n**\n** If argument pState is not NULL, then the incremental checkpoint is\n** being resumed. In this case, if the checksum of the wal-index-header\n** following recovery is not the same as the checksum saved in the RbuState\n** object, then the rbu handle is set to DONE state. This occurs if some\n** other client appends a transaction to the wal file in the middle of\n** an incremental checkpoint.\n*/\nstatic void rbuSetupCheckpoint(sqlite3rbu *p, RbuState *pState){\n\n  /* If pState is NULL, then the wal file may not have been opened and\n  ** recovered. Running a read-statement here to ensure that doing so\n  ** does not interfere with the \"capture\" process below.  */\n  if( pState==0 ){\n    p->eStage = 0;\n    if( p->rc==SQLITE_OK ){\n      p->rc = sqlite3_exec(p->dbMain, \"SELECT * FROM sqlite_master\", 0, 0, 0);\n    }\n  }\n\n  /* Assuming no error has occurred, run a \"restart\" checkpoint with the\n  ** sqlite3rbu.eStage variable set to CAPTURE. This turns on the following\n  ** special behaviour in the rbu VFS:\n  **\n  **   * If the exclusive shm WRITER or READ0 lock cannot be obtained,\n  **     the checkpoint fails with SQLITE_BUSY (normally SQLite would\n  **     proceed with running a passive checkpoint instead of failing).\n  **\n  **   * Attempts to read from the *-wal file or write to the database file\n  **     do not perform any IO. Instead, the frame/page combinations that\n  **     would be read/written are recorded in the sqlite3rbu.aFrame[]\n  **     array.\n  **\n  **   * Calls to xShmLock(UNLOCK) to release the exclusive shm WRITER, \n  **     READ0 and CHECKPOINT locks taken as part of the checkpoint are\n  **     no-ops. These locks will not be released until the connection\n  **     is closed.\n  **\n  **   * Attempting to xSync() the database file causes an SQLITE_INTERNAL \n  **     error.\n  **\n  ** As a result, unless an error (i.e. OOM or SQLITE_BUSY) occurs, the\n  ** checkpoint below fails with SQLITE_INTERNAL, and leaves the aFrame[]\n  ** array populated with a set of (frame -> page) mappings. Because the \n  ** WRITER, CHECKPOINT and READ0 locks are still held, it is safe to copy \n  ** data from the wal file into the database file according to the \n  ** contents of aFrame[].\n  */\n  if( p->rc==SQLITE_OK ){\n    int rc2;\n    p->eStage = RBU_STAGE_CAPTURE;\n    rc2 = sqlite3_exec(p->dbMain, \"PRAGMA main.wal_checkpoint=restart\", 0, 0,0);\n    if( rc2!=SQLITE_INTERNAL ) p->rc = rc2;\n  }\n\n  if( p->rc==SQLITE_OK && p->nFrame>0 ){\n    p->eStage = RBU_STAGE_CKPT;\n    p->nStep = (pState ? pState->nRow : 0);\n    p->aBuf = rbuMalloc(p, p->pgsz);\n    p->iWalCksum = rbuShmChecksum(p);\n  }\n\n  if( p->rc==SQLITE_OK ){\n    if( p->nFrame==0 || (pState && pState->iWalCksum!=p->iWalCksum) ){\n      p->rc = SQLITE_DONE;\n      p->eStage = RBU_STAGE_DONE;\n    }else{\n      int nSectorSize;\n      sqlite3_file *pDb = p->pTargetFd->pReal;\n      sqlite3_file *pWal = p->pTargetFd->pWalFd->pReal;\n      assert( p->nPagePerSector==0 );\n      nSectorSize = pDb->pMethods->xSectorSize(pDb);\n      if( nSectorSize>p->pgsz ){\n        p->nPagePerSector = nSectorSize / p->pgsz;\n      }else{\n        p->nPagePerSector = 1;\n      }\n\n      /* Call xSync() on the wal file. This causes SQLite to sync the \n      ** directory in which the target database and the wal file reside, in \n      ** case it has not been synced since the rename() call in \n      ** rbuMoveOalFile(). */\n      p->rc = pWal->pMethods->xSync(pWal, SQLITE_SYNC_NORMAL);\n    }\n  }\n}\n\n/*\n** Called when iAmt bytes are read from offset iOff of the wal file while\n** the rbu object is in capture mode. Record the frame number of the frame\n** being read in the aFrame[] array.\n*/\nstatic int rbuCaptureWalRead(sqlite3rbu *pRbu, i64 iOff, int iAmt){\n  const u32 mReq = (1<<WAL_LOCK_WRITE)|(1<<WAL_LOCK_CKPT)|(1<<WAL_LOCK_READ0);\n  u32 iFrame;\n\n  if( pRbu->mLock!=mReq ){\n    pRbu->rc = SQLITE_BUSY;\n    return SQLITE_INTERNAL;\n  }\n\n  pRbu->pgsz = iAmt;\n  if( pRbu->nFrame==pRbu->nFrameAlloc ){\n    int nNew = (pRbu->nFrameAlloc ? pRbu->nFrameAlloc : 64) * 2;\n    RbuFrame *aNew;\n    aNew = (RbuFrame*)sqlite3_realloc64(pRbu->aFrame, nNew * sizeof(RbuFrame));\n    if( aNew==0 ) return SQLITE_NOMEM;\n    pRbu->aFrame = aNew;\n    pRbu->nFrameAlloc = nNew;\n  }\n\n  iFrame = (u32)((iOff-32) / (i64)(iAmt+24)) + 1;\n  if( pRbu->iMaxFrame<iFrame ) pRbu->iMaxFrame = iFrame;\n  pRbu->aFrame[pRbu->nFrame].iWalFrame = iFrame;\n  pRbu->aFrame[pRbu->nFrame].iDbPage = 0;\n  pRbu->nFrame++;\n  return SQLITE_OK;\n}\n\n/*\n** Called when a page of data is written to offset iOff of the database\n** file while the rbu handle is in capture mode. Record the page number \n** of the page being written in the aFrame[] array.\n*/\nstatic int rbuCaptureDbWrite(sqlite3rbu *pRbu, i64 iOff){\n  pRbu->aFrame[pRbu->nFrame-1].iDbPage = (u32)(iOff / pRbu->pgsz) + 1;\n  return SQLITE_OK;\n}\n\n/*\n** This is called as part of an incremental checkpoint operation. Copy\n** a single frame of data from the wal file into the database file, as\n** indicated by the RbuFrame object.\n*/\nstatic void rbuCheckpointFrame(sqlite3rbu *p, RbuFrame *pFrame){\n  sqlite3_file *pWal = p->pTargetFd->pWalFd->pReal;\n  sqlite3_file *pDb = p->pTargetFd->pReal;\n  i64 iOff;\n\n  assert( p->rc==SQLITE_OK );\n  iOff = (i64)(pFrame->iWalFrame-1) * (p->pgsz + 24) + 32 + 24;\n  p->rc = pWal->pMethods->xRead(pWal, p->aBuf, p->pgsz, iOff);\n  if( p->rc ) return;\n\n  iOff = (i64)(pFrame->iDbPage-1) * p->pgsz;\n  p->rc = pDb->pMethods->xWrite(pDb, p->aBuf, p->pgsz, iOff);\n}\n\n\n/*\n** Take an EXCLUSIVE lock on the database file.\n*/\nstatic void rbuLockDatabase(sqlite3rbu *p){\n  sqlite3_file *pReal = p->pTargetFd->pReal;\n  assert( p->rc==SQLITE_OK );\n  p->rc = pReal->pMethods->xLock(pReal, SQLITE_LOCK_SHARED);\n  if( p->rc==SQLITE_OK ){\n    p->rc = pReal->pMethods->xLock(pReal, SQLITE_LOCK_EXCLUSIVE);\n  }\n}\n\n#if defined(_WIN32_WCE)\nstatic LPWSTR rbuWinUtf8ToUnicode(const char *zFilename){\n  int nChar;\n  LPWSTR zWideFilename;\n\n  nChar = MultiByteToWideChar(CP_UTF8, 0, zFilename, -1, NULL, 0);\n  if( nChar==0 ){\n    return 0;\n  }\n  zWideFilename = sqlite3_malloc64( nChar*sizeof(zWideFilename[0]) );\n  if( zWideFilename==0 ){\n    return 0;\n  }\n  memset(zWideFilename, 0, nChar*sizeof(zWideFilename[0]));\n  nChar = MultiByteToWideChar(CP_UTF8, 0, zFilename, -1, zWideFilename,\n                                nChar);\n  if( nChar==0 ){\n    sqlite3_free(zWideFilename);\n    zWideFilename = 0;\n  }\n  return zWideFilename;\n}\n#endif\n\n/*\n** The RBU handle is currently in RBU_STAGE_OAL state, with a SHARED lock\n** on the database file. This proc moves the *-oal file to the *-wal path,\n** then reopens the database file (this time in vanilla, non-oal, WAL mode).\n** If an error occurs, leave an error code and error message in the rbu \n** handle.\n*/\nstatic void rbuMoveOalFile(sqlite3rbu *p){\n  const char *zBase = sqlite3_db_filename(p->dbMain, \"main\");\n  const char *zMove = zBase;\n  char *zOal;\n  char *zWal;\n\n  if( rbuIsVacuum(p) ){\n    zMove = sqlite3_db_filename(p->dbRbu, \"main\");\n  }\n  zOal = sqlite3_mprintf(\"%s-oal\", zMove);\n  zWal = sqlite3_mprintf(\"%s-wal\", zMove);\n\n  assert( p->eStage==RBU_STAGE_MOVE );\n  assert( p->rc==SQLITE_OK && p->zErrmsg==0 );\n  if( zWal==0 || zOal==0 ){\n    p->rc = SQLITE_NOMEM;\n  }else{\n    /* Move the *-oal file to *-wal. At this point connection p->db is\n    ** holding a SHARED lock on the target database file (because it is\n    ** in WAL mode). So no other connection may be writing the db. \n    **\n    ** In order to ensure that there are no database readers, an EXCLUSIVE\n    ** lock is obtained here before the *-oal is moved to *-wal.\n    */\n    rbuLockDatabase(p);\n    if( p->rc==SQLITE_OK ){\n      rbuFileSuffix3(zBase, zWal);\n      rbuFileSuffix3(zBase, zOal);\n\n      /* Re-open the databases. */\n      rbuObjIterFinalize(&p->objiter);\n      sqlite3_close(p->dbRbu);\n      sqlite3_close(p->dbMain);\n      p->dbMain = 0;\n      p->dbRbu = 0;\n\n#if defined(_WIN32_WCE)\n      {\n        LPWSTR zWideOal;\n        LPWSTR zWideWal;\n\n        zWideOal = rbuWinUtf8ToUnicode(zOal);\n        if( zWideOal ){\n          zWideWal = rbuWinUtf8ToUnicode(zWal);\n          if( zWideWal ){\n            if( MoveFileW(zWideOal, zWideWal) ){\n              p->rc = SQLITE_OK;\n            }else{\n              p->rc = SQLITE_IOERR;\n            }\n            sqlite3_free(zWideWal);\n          }else{\n            p->rc = SQLITE_IOERR_NOMEM;\n          }\n          sqlite3_free(zWideOal);\n        }else{\n          p->rc = SQLITE_IOERR_NOMEM;\n        }\n      }\n#else\n      p->rc = rename(zOal, zWal) ? SQLITE_IOERR : SQLITE_OK;\n#endif\n\n      if( p->rc==SQLITE_OK ){\n        rbuOpenDatabase(p, 0);\n        rbuSetupCheckpoint(p, 0);\n      }\n    }\n  }\n\n  sqlite3_free(zWal);\n  sqlite3_free(zOal);\n}\n\n/*\n** The SELECT statement iterating through the keys for the current object\n** (p->objiter.pSelect) currently points to a valid row. This function\n** determines the type of operation requested by this row and returns\n** one of the following values to indicate the result:\n**\n**     * RBU_INSERT\n**     * RBU_DELETE\n**     * RBU_IDX_DELETE\n**     * RBU_UPDATE\n**\n** If RBU_UPDATE is returned, then output variable *pzMask is set to\n** point to the text value indicating the columns to update.\n**\n** If the rbu_control field contains an invalid value, an error code and\n** message are left in the RBU handle and zero returned.\n*/\nstatic int rbuStepType(sqlite3rbu *p, const char **pzMask){\n  int iCol = p->objiter.nCol;     /* Index of rbu_control column */\n  int res = 0;                    /* Return value */\n\n  switch( sqlite3_column_type(p->objiter.pSelect, iCol) ){\n    case SQLITE_INTEGER: {\n      int iVal = sqlite3_column_int(p->objiter.pSelect, iCol);\n      switch( iVal ){\n        case 0: res = RBU_INSERT;     break;\n        case 1: res = RBU_DELETE;     break;\n        case 2: res = RBU_REPLACE;    break;\n        case 3: res = RBU_IDX_DELETE; break;\n        case 4: res = RBU_IDX_INSERT; break;\n      }\n      break;\n    }\n\n    case SQLITE_TEXT: {\n      const unsigned char *z = sqlite3_column_text(p->objiter.pSelect, iCol);\n      if( z==0 ){\n        p->rc = SQLITE_NOMEM;\n      }else{\n        *pzMask = (const char*)z;\n      }\n      res = RBU_UPDATE;\n\n      break;\n    }\n\n    default:\n      break;\n  }\n\n  if( res==0 ){\n    rbuBadControlError(p);\n  }\n  return res;\n}\n\n#ifdef SQLITE_DEBUG\n/*\n** Assert that column iCol of statement pStmt is named zName.\n*/\nstatic void assertColumnName(sqlite3_stmt *pStmt, int iCol, const char *zName){\n  const char *zCol = sqlite3_column_name(pStmt, iCol);\n  assert( 0==sqlite3_stricmp(zName, zCol) );\n}\n#else\n# define assertColumnName(x,y,z)\n#endif\n\n/*\n** Argument eType must be one of RBU_INSERT, RBU_DELETE, RBU_IDX_INSERT or\n** RBU_IDX_DELETE. This function performs the work of a single\n** sqlite3rbu_step() call for the type of operation specified by eType.\n*/\nstatic void rbuStepOneOp(sqlite3rbu *p, int eType){\n  RbuObjIter *pIter = &p->objiter;\n  sqlite3_value *pVal;\n  sqlite3_stmt *pWriter;\n  int i;\n\n  assert( p->rc==SQLITE_OK );\n  assert( eType!=RBU_DELETE || pIter->zIdx==0 );\n  assert( eType==RBU_DELETE || eType==RBU_IDX_DELETE\n       || eType==RBU_INSERT || eType==RBU_IDX_INSERT\n  );\n\n  /* If this is a delete, decrement nPhaseOneStep by nIndex. If the DELETE\n  ** statement below does actually delete a row, nPhaseOneStep will be\n  ** incremented by the same amount when SQL function rbu_tmp_insert()\n  ** is invoked by the trigger.  */\n  if( eType==RBU_DELETE ){\n    p->nPhaseOneStep -= p->objiter.nIndex;\n  }\n\n  if( eType==RBU_IDX_DELETE || eType==RBU_DELETE ){\n    pWriter = pIter->pDelete;\n  }else{\n    pWriter = pIter->pInsert;\n  }\n\n  for(i=0; i<pIter->nCol; i++){\n    /* If this is an INSERT into a table b-tree and the table has an\n    ** explicit INTEGER PRIMARY KEY, check that this is not an attempt\n    ** to write a NULL into the IPK column. That is not permitted.  */\n    if( eType==RBU_INSERT \n     && pIter->zIdx==0 && pIter->eType==RBU_PK_IPK && pIter->abTblPk[i] \n     && sqlite3_column_type(pIter->pSelect, i)==SQLITE_NULL\n    ){\n      p->rc = SQLITE_MISMATCH;\n      p->zErrmsg = sqlite3_mprintf(\"datatype mismatch\");\n      return;\n    }\n\n    if( eType==RBU_DELETE && pIter->abTblPk[i]==0 ){\n      continue;\n    }\n\n    pVal = sqlite3_column_value(pIter->pSelect, i);\n    p->rc = sqlite3_bind_value(pWriter, i+1, pVal);\n    if( p->rc ) return;\n  }\n  if( pIter->zIdx==0 ){\n    if( pIter->eType==RBU_PK_VTAB \n     || pIter->eType==RBU_PK_NONE \n     || (pIter->eType==RBU_PK_EXTERNAL && rbuIsVacuum(p)) \n    ){\n      /* For a virtual table, or a table with no primary key, the \n      ** SELECT statement is:\n      **\n      **   SELECT <cols>, rbu_control, rbu_rowid FROM ....\n      **\n      ** Hence column_value(pIter->nCol+1).\n      */\n      assertColumnName(pIter->pSelect, pIter->nCol+1, \n          rbuIsVacuum(p) ? \"rowid\" : \"rbu_rowid\"\n      );\n      pVal = sqlite3_column_value(pIter->pSelect, pIter->nCol+1);\n      p->rc = sqlite3_bind_value(pWriter, pIter->nCol+1, pVal);\n    }\n  }\n  if( p->rc==SQLITE_OK ){\n    sqlite3_step(pWriter);\n    p->rc = resetAndCollectError(pWriter, &p->zErrmsg);\n  }\n}\n\n/*\n** This function does the work for an sqlite3rbu_step() call.\n**\n** The object-iterator (p->objiter) currently points to a valid object,\n** and the input cursor (p->objiter.pSelect) currently points to a valid\n** input row. Perform whatever processing is required and return.\n**\n** If no  error occurs, SQLITE_OK is returned. Otherwise, an error code\n** and message is left in the RBU handle and a copy of the error code\n** returned.\n*/\nstatic int rbuStep(sqlite3rbu *p){\n  RbuObjIter *pIter = &p->objiter;\n  const char *zMask = 0;\n  int eType = rbuStepType(p, &zMask);\n\n  if( eType ){\n    assert( eType==RBU_INSERT     || eType==RBU_DELETE\n         || eType==RBU_REPLACE    || eType==RBU_IDX_DELETE\n         || eType==RBU_IDX_INSERT || eType==RBU_UPDATE\n    );\n    assert( eType!=RBU_UPDATE || pIter->zIdx==0 );\n\n    if( pIter->zIdx==0 && (eType==RBU_IDX_DELETE || eType==RBU_IDX_INSERT) ){\n      rbuBadControlError(p);\n    }\n    else if( eType==RBU_REPLACE ){\n      if( pIter->zIdx==0 ){\n        p->nPhaseOneStep += p->objiter.nIndex;\n        rbuStepOneOp(p, RBU_DELETE);\n      }\n      if( p->rc==SQLITE_OK ) rbuStepOneOp(p, RBU_INSERT);\n    }\n    else if( eType!=RBU_UPDATE ){\n      rbuStepOneOp(p, eType);\n    }\n    else{\n      sqlite3_value *pVal;\n      sqlite3_stmt *pUpdate = 0;\n      assert( eType==RBU_UPDATE );\n      p->nPhaseOneStep -= p->objiter.nIndex;\n      rbuGetUpdateStmt(p, pIter, zMask, &pUpdate);\n      if( pUpdate ){\n        int i;\n        for(i=0; p->rc==SQLITE_OK && i<pIter->nCol; i++){\n          char c = zMask[pIter->aiSrcOrder[i]];\n          pVal = sqlite3_column_value(pIter->pSelect, i);\n          if( pIter->abTblPk[i] || c!='.' ){\n            p->rc = sqlite3_bind_value(pUpdate, i+1, pVal);\n          }\n        }\n        if( p->rc==SQLITE_OK \n         && (pIter->eType==RBU_PK_VTAB || pIter->eType==RBU_PK_NONE) \n        ){\n          /* Bind the rbu_rowid value to column _rowid_ */\n          assertColumnName(pIter->pSelect, pIter->nCol+1, \"rbu_rowid\");\n          pVal = sqlite3_column_value(pIter->pSelect, pIter->nCol+1);\n          p->rc = sqlite3_bind_value(pUpdate, pIter->nCol+1, pVal);\n        }\n        if( p->rc==SQLITE_OK ){\n          sqlite3_step(pUpdate);\n          p->rc = resetAndCollectError(pUpdate, &p->zErrmsg);\n        }\n      }\n    }\n  }\n  return p->rc;\n}\n\n/*\n** Increment the schema cookie of the main database opened by p->dbMain.\n**\n** Or, if this is an RBU vacuum, set the schema cookie of the main db\n** opened by p->dbMain to one more than the schema cookie of the main\n** db opened by p->dbRbu.\n*/\nstatic void rbuIncrSchemaCookie(sqlite3rbu *p){\n  if( p->rc==SQLITE_OK ){\n    sqlite3 *dbread = (rbuIsVacuum(p) ? p->dbRbu : p->dbMain);\n    int iCookie = 1000000;\n    sqlite3_stmt *pStmt;\n\n    p->rc = prepareAndCollectError(dbread, &pStmt, &p->zErrmsg, \n        \"PRAGMA schema_version\"\n    );\n    if( p->rc==SQLITE_OK ){\n      /* Coverage: it may be that this sqlite3_step() cannot fail. There\n      ** is already a transaction open, so the prepared statement cannot\n      ** throw an SQLITE_SCHEMA exception. The only database page the\n      ** statement reads is page 1, which is guaranteed to be in the cache.\n      ** And no memory allocations are required.  */\n      if( SQLITE_ROW==sqlite3_step(pStmt) ){\n        iCookie = sqlite3_column_int(pStmt, 0);\n      }\n      rbuFinalize(p, pStmt);\n    }\n    if( p->rc==SQLITE_OK ){\n      rbuMPrintfExec(p, p->dbMain, \"PRAGMA schema_version = %d\", iCookie+1);\n    }\n  }\n}\n\n/*\n** Update the contents of the rbu_state table within the rbu database. The\n** value stored in the RBU_STATE_STAGE column is eStage. All other values\n** are determined by inspecting the rbu handle passed as the first argument.\n*/\nstatic void rbuSaveState(sqlite3rbu *p, int eStage){\n  if( p->rc==SQLITE_OK || p->rc==SQLITE_DONE ){\n    sqlite3_stmt *pInsert = 0;\n    rbu_file *pFd = (rbuIsVacuum(p) ? p->pRbuFd : p->pTargetFd);\n    int rc;\n\n    assert( p->zErrmsg==0 );\n    rc = prepareFreeAndCollectError(p->dbRbu, &pInsert, &p->zErrmsg, \n        sqlite3_mprintf(\n          \"INSERT OR REPLACE INTO %s.rbu_state(k, v) VALUES \"\n          \"(%d, %d), \"\n          \"(%d, %Q), \"\n          \"(%d, %Q), \"\n          \"(%d, %d), \"\n          \"(%d, %d), \"\n          \"(%d, %lld), \"\n          \"(%d, %lld), \"\n          \"(%d, %lld), \"\n          \"(%d, %lld), \"\n          \"(%d, %Q)  \",\n          p->zStateDb,\n          RBU_STATE_STAGE, eStage,\n          RBU_STATE_TBL, p->objiter.zTbl, \n          RBU_STATE_IDX, p->objiter.zIdx, \n          RBU_STATE_ROW, p->nStep, \n          RBU_STATE_PROGRESS, p->nProgress,\n          RBU_STATE_CKPT, p->iWalCksum,\n          RBU_STATE_COOKIE, (i64)pFd->iCookie,\n          RBU_STATE_OALSZ, p->iOalSz,\n          RBU_STATE_PHASEONESTEP, p->nPhaseOneStep,\n          RBU_STATE_DATATBL, p->objiter.zDataTbl\n      )\n    );\n    assert( pInsert==0 || rc==SQLITE_OK );\n\n    if( rc==SQLITE_OK ){\n      sqlite3_step(pInsert);\n      rc = sqlite3_finalize(pInsert);\n    }\n    if( rc!=SQLITE_OK ) p->rc = rc;\n  }\n}\n\n\n/*\n** The second argument passed to this function is the name of a PRAGMA \n** setting - \"page_size\", \"auto_vacuum\", \"user_version\" or \"application_id\".\n** This function executes the following on sqlite3rbu.dbRbu:\n**\n**   \"PRAGMA main.$zPragma\"\n**\n** where $zPragma is the string passed as the second argument, then\n** on sqlite3rbu.dbMain:\n**\n**   \"PRAGMA main.$zPragma = $val\"\n**\n** where $val is the value returned by the first PRAGMA invocation.\n**\n** In short, it copies the value  of the specified PRAGMA setting from\n** dbRbu to dbMain.\n*/\nstatic void rbuCopyPragma(sqlite3rbu *p, const char *zPragma){\n  if( p->rc==SQLITE_OK ){\n    sqlite3_stmt *pPragma = 0;\n    p->rc = prepareFreeAndCollectError(p->dbRbu, &pPragma, &p->zErrmsg, \n        sqlite3_mprintf(\"PRAGMA main.%s\", zPragma)\n    );\n    if( p->rc==SQLITE_OK && SQLITE_ROW==sqlite3_step(pPragma) ){\n      p->rc = rbuMPrintfExec(p, p->dbMain, \"PRAGMA main.%s = %d\",\n          zPragma, sqlite3_column_int(pPragma, 0)\n      );\n    }\n    rbuFinalize(p, pPragma);\n  }\n}\n\n/*\n** The RBU handle passed as the only argument has just been opened and \n** the state database is empty. If this RBU handle was opened for an\n** RBU vacuum operation, create the schema in the target db.\n*/\nstatic void rbuCreateTargetSchema(sqlite3rbu *p){\n  sqlite3_stmt *pSql = 0;\n  sqlite3_stmt *pInsert = 0;\n\n  assert( rbuIsVacuum(p) );\n  p->rc = sqlite3_exec(p->dbMain, \"PRAGMA writable_schema=1\", 0,0, &p->zErrmsg);\n  if( p->rc==SQLITE_OK ){\n    p->rc = prepareAndCollectError(p->dbRbu, &pSql, &p->zErrmsg, \n      \"SELECT sql FROM sqlite_master WHERE sql!='' AND rootpage!=0\"\n      \" AND name!='sqlite_sequence' \"\n      \" ORDER BY type DESC\"\n    );\n  }\n\n  while( p->rc==SQLITE_OK && sqlite3_step(pSql)==SQLITE_ROW ){\n    const char *zSql = (const char*)sqlite3_column_text(pSql, 0);\n    p->rc = sqlite3_exec(p->dbMain, zSql, 0, 0, &p->zErrmsg);\n  }\n  rbuFinalize(p, pSql);\n  if( p->rc!=SQLITE_OK ) return;\n\n  if( p->rc==SQLITE_OK ){\n    p->rc = prepareAndCollectError(p->dbRbu, &pSql, &p->zErrmsg, \n        \"SELECT * FROM sqlite_master WHERE rootpage=0 OR rootpage IS NULL\" \n    );\n  }\n\n  if( p->rc==SQLITE_OK ){\n    p->rc = prepareAndCollectError(p->dbMain, &pInsert, &p->zErrmsg, \n        \"INSERT INTO sqlite_master VALUES(?,?,?,?,?)\"\n    );\n  }\n\n  while( p->rc==SQLITE_OK && sqlite3_step(pSql)==SQLITE_ROW ){\n    int i;\n    for(i=0; i<5; i++){\n      sqlite3_bind_value(pInsert, i+1, sqlite3_column_value(pSql, i));\n    }\n    sqlite3_step(pInsert);\n    p->rc = sqlite3_reset(pInsert);\n  }\n  if( p->rc==SQLITE_OK ){\n    p->rc = sqlite3_exec(p->dbMain, \"PRAGMA writable_schema=0\",0,0,&p->zErrmsg);\n  }\n\n  rbuFinalize(p, pSql);\n  rbuFinalize(p, pInsert);\n}\n\n/*\n** Step the RBU object.\n*/\nSQLITE_API int sqlite3rbu_step(sqlite3rbu *p){\n  if( p ){\n    switch( p->eStage ){\n      case RBU_STAGE_OAL: {\n        RbuObjIter *pIter = &p->objiter;\n\n        /* If this is an RBU vacuum operation and the state table was empty\n        ** when this handle was opened, create the target database schema. */\n        if( rbuIsVacuum(p) && p->nProgress==0 && p->rc==SQLITE_OK ){\n          rbuCreateTargetSchema(p);\n          rbuCopyPragma(p, \"user_version\");\n          rbuCopyPragma(p, \"application_id\");\n        }\n\n        while( p->rc==SQLITE_OK && pIter->zTbl ){\n\n          if( pIter->bCleanup ){\n            /* Clean up the rbu_tmp_xxx table for the previous table. It \n            ** cannot be dropped as there are currently active SQL statements.\n            ** But the contents can be deleted.  */\n            if( rbuIsVacuum(p)==0 && pIter->abIndexed ){\n              rbuMPrintfExec(p, p->dbRbu, \n                  \"DELETE FROM %s.'rbu_tmp_%q'\", p->zStateDb, pIter->zDataTbl\n              );\n            }\n          }else{\n            rbuObjIterPrepareAll(p, pIter, 0);\n\n            /* Advance to the next row to process. */\n            if( p->rc==SQLITE_OK ){\n              int rc = sqlite3_step(pIter->pSelect);\n              if( rc==SQLITE_ROW ){\n                p->nProgress++;\n                p->nStep++;\n                return rbuStep(p);\n              }\n              p->rc = sqlite3_reset(pIter->pSelect);\n              p->nStep = 0;\n            }\n          }\n\n          rbuObjIterNext(p, pIter);\n        }\n\n        if( p->rc==SQLITE_OK ){\n          assert( pIter->zTbl==0 );\n          rbuSaveState(p, RBU_STAGE_MOVE);\n          rbuIncrSchemaCookie(p);\n          if( p->rc==SQLITE_OK ){\n            p->rc = sqlite3_exec(p->dbMain, \"COMMIT\", 0, 0, &p->zErrmsg);\n          }\n          if( p->rc==SQLITE_OK ){\n            p->rc = sqlite3_exec(p->dbRbu, \"COMMIT\", 0, 0, &p->zErrmsg);\n          }\n          p->eStage = RBU_STAGE_MOVE;\n        }\n        break;\n      }\n\n      case RBU_STAGE_MOVE: {\n        if( p->rc==SQLITE_OK ){\n          rbuMoveOalFile(p);\n          p->nProgress++;\n        }\n        break;\n      }\n\n      case RBU_STAGE_CKPT: {\n        if( p->rc==SQLITE_OK ){\n          if( p->nStep>=p->nFrame ){\n            sqlite3_file *pDb = p->pTargetFd->pReal;\n  \n            /* Sync the db file */\n            p->rc = pDb->pMethods->xSync(pDb, SQLITE_SYNC_NORMAL);\n  \n            /* Update nBackfill */\n            if( p->rc==SQLITE_OK ){\n              void volatile *ptr;\n              p->rc = pDb->pMethods->xShmMap(pDb, 0, 32*1024, 0, &ptr);\n              if( p->rc==SQLITE_OK ){\n                ((u32 volatile*)ptr)[24] = p->iMaxFrame;\n              }\n            }\n  \n            if( p->rc==SQLITE_OK ){\n              p->eStage = RBU_STAGE_DONE;\n              p->rc = SQLITE_DONE;\n            }\n          }else{\n            /* At one point the following block copied a single frame from the\n            ** wal file to the database file. So that one call to sqlite3rbu_step()\n            ** checkpointed a single frame. \n            **\n            ** However, if the sector-size is larger than the page-size, and the\n            ** application calls sqlite3rbu_savestate() or close() immediately\n            ** after this step, then rbu_step() again, then a power failure occurs,\n            ** then the database page written here may be damaged. Work around\n            ** this by checkpointing frames until the next page in the aFrame[]\n            ** lies on a different disk sector to the current one. */\n            u32 iSector;\n            do{\n              RbuFrame *pFrame = &p->aFrame[p->nStep];\n              iSector = (pFrame->iDbPage-1) / p->nPagePerSector;\n              rbuCheckpointFrame(p, pFrame);\n              p->nStep++;\n            }while( p->nStep<p->nFrame \n                 && iSector==((p->aFrame[p->nStep].iDbPage-1) / p->nPagePerSector)\n                 && p->rc==SQLITE_OK\n            );\n          }\n          p->nProgress++;\n        }\n        break;\n      }\n\n      default:\n        break;\n    }\n    return p->rc;\n  }else{\n    return SQLITE_NOMEM;\n  }\n}\n\n/*\n** Compare strings z1 and z2, returning 0 if they are identical, or non-zero\n** otherwise. Either or both argument may be NULL. Two NULL values are\n** considered equal, and NULL is considered distinct from all other values.\n*/\nstatic int rbuStrCompare(const char *z1, const char *z2){\n  if( z1==0 && z2==0 ) return 0;\n  if( z1==0 || z2==0 ) return 1;\n  return (sqlite3_stricmp(z1, z2)!=0);\n}\n\n/*\n** This function is called as part of sqlite3rbu_open() when initializing\n** an rbu handle in OAL stage. If the rbu update has not started (i.e.\n** the rbu_state table was empty) it is a no-op. Otherwise, it arranges\n** things so that the next call to sqlite3rbu_step() continues on from\n** where the previous rbu handle left off.\n**\n** If an error occurs, an error code and error message are left in the\n** rbu handle passed as the first argument.\n*/\nstatic void rbuSetupOal(sqlite3rbu *p, RbuState *pState){\n  assert( p->rc==SQLITE_OK );\n  if( pState->zTbl ){\n    RbuObjIter *pIter = &p->objiter;\n    int rc = SQLITE_OK;\n\n    while( rc==SQLITE_OK && pIter->zTbl && (pIter->bCleanup \n       || rbuStrCompare(pIter->zIdx, pState->zIdx)\n       || (pState->zDataTbl==0 && rbuStrCompare(pIter->zTbl, pState->zTbl))\n       || (pState->zDataTbl && rbuStrCompare(pIter->zDataTbl, pState->zDataTbl))\n    )){\n      rc = rbuObjIterNext(p, pIter);\n    }\n\n    if( rc==SQLITE_OK && !pIter->zTbl ){\n      rc = SQLITE_ERROR;\n      p->zErrmsg = sqlite3_mprintf(\"rbu_state mismatch error\");\n    }\n\n    if( rc==SQLITE_OK ){\n      p->nStep = pState->nRow;\n      rc = rbuObjIterPrepareAll(p, &p->objiter, p->nStep);\n    }\n\n    p->rc = rc;\n  }\n}\n\n/*\n** If there is a \"*-oal\" file in the file-system corresponding to the\n** target database in the file-system, delete it. If an error occurs,\n** leave an error code and error message in the rbu handle.\n*/\nstatic void rbuDeleteOalFile(sqlite3rbu *p){\n  char *zOal = rbuMPrintf(p, \"%s-oal\", p->zTarget);\n  if( zOal ){\n    sqlite3_vfs *pVfs = sqlite3_vfs_find(0);\n    assert( pVfs && p->rc==SQLITE_OK && p->zErrmsg==0 );\n    pVfs->xDelete(pVfs, zOal, 0);\n    sqlite3_free(zOal);\n  }\n}\n\n/*\n** Allocate a private rbu VFS for the rbu handle passed as the only\n** argument. This VFS will be used unless the call to sqlite3rbu_open()\n** specified a URI with a vfs=? option in place of a target database\n** file name.\n*/\nstatic void rbuCreateVfs(sqlite3rbu *p){\n  int rnd;\n  char zRnd[64];\n\n  assert( p->rc==SQLITE_OK );\n  sqlite3_randomness(sizeof(int), (void*)&rnd);\n  sqlite3_snprintf(sizeof(zRnd), zRnd, \"rbu_vfs_%d\", rnd);\n  p->rc = sqlite3rbu_create_vfs(zRnd, 0);\n  if( p->rc==SQLITE_OK ){\n    sqlite3_vfs *pVfs = sqlite3_vfs_find(zRnd);\n    assert( pVfs );\n    p->zVfsName = pVfs->zName;\n    ((rbu_vfs*)pVfs)->pRbu = p;\n  }\n}\n\n/*\n** Destroy the private VFS created for the rbu handle passed as the only\n** argument by an earlier call to rbuCreateVfs().\n*/\nstatic void rbuDeleteVfs(sqlite3rbu *p){\n  if( p->zVfsName ){\n    sqlite3rbu_destroy_vfs(p->zVfsName);\n    p->zVfsName = 0;\n  }\n}\n\n/*\n** This user-defined SQL function is invoked with a single argument - the\n** name of a table expected to appear in the target database. It returns\n** the number of auxilliary indexes on the table.\n*/\nstatic void rbuIndexCntFunc(\n  sqlite3_context *pCtx, \n  int nVal,\n  sqlite3_value **apVal\n){\n  sqlite3rbu *p = (sqlite3rbu*)sqlite3_user_data(pCtx);\n  sqlite3_stmt *pStmt = 0;\n  char *zErrmsg = 0;\n  int rc;\n\n  assert( nVal==1 );\n  \n  rc = prepareFreeAndCollectError(p->dbMain, &pStmt, &zErrmsg, \n      sqlite3_mprintf(\"SELECT count(*) FROM sqlite_master \"\n        \"WHERE type='index' AND tbl_name = %Q\", sqlite3_value_text(apVal[0]))\n  );\n  if( rc!=SQLITE_OK ){\n    sqlite3_result_error(pCtx, zErrmsg, -1);\n  }else{\n    int nIndex = 0;\n    if( SQLITE_ROW==sqlite3_step(pStmt) ){\n      nIndex = sqlite3_column_int(pStmt, 0);\n    }\n    rc = sqlite3_finalize(pStmt);\n    if( rc==SQLITE_OK ){\n      sqlite3_result_int(pCtx, nIndex);\n    }else{\n      sqlite3_result_error(pCtx, sqlite3_errmsg(p->dbMain), -1);\n    }\n  }\n\n  sqlite3_free(zErrmsg);\n}\n\n/*\n** If the RBU database contains the rbu_count table, use it to initialize\n** the sqlite3rbu.nPhaseOneStep variable. The schema of the rbu_count table\n** is assumed to contain the same columns as:\n**\n**   CREATE TABLE rbu_count(tbl TEXT PRIMARY KEY, cnt INTEGER) WITHOUT ROWID;\n**\n** There should be one row in the table for each data_xxx table in the\n** database. The 'tbl' column should contain the name of a data_xxx table,\n** and the cnt column the number of rows it contains.\n**\n** sqlite3rbu.nPhaseOneStep is initialized to the sum of (1 + nIndex) * cnt\n** for all rows in the rbu_count table, where nIndex is the number of \n** indexes on the corresponding target database table.\n*/\nstatic void rbuInitPhaseOneSteps(sqlite3rbu *p){\n  if( p->rc==SQLITE_OK ){\n    sqlite3_stmt *pStmt = 0;\n    int bExists = 0;                /* True if rbu_count exists */\n\n    p->nPhaseOneStep = -1;\n\n    p->rc = sqlite3_create_function(p->dbRbu, \n        \"rbu_index_cnt\", 1, SQLITE_UTF8, (void*)p, rbuIndexCntFunc, 0, 0\n    );\n  \n    /* Check for the rbu_count table. If it does not exist, or if an error\n    ** occurs, nPhaseOneStep will be left set to -1. */\n    if( p->rc==SQLITE_OK ){\n      p->rc = prepareAndCollectError(p->dbRbu, &pStmt, &p->zErrmsg,\n          \"SELECT 1 FROM sqlite_master WHERE tbl_name = 'rbu_count'\"\n      );\n    }\n    if( p->rc==SQLITE_OK ){\n      if( SQLITE_ROW==sqlite3_step(pStmt) ){\n        bExists = 1;\n      }\n      p->rc = sqlite3_finalize(pStmt);\n    }\n  \n    if( p->rc==SQLITE_OK && bExists ){\n      p->rc = prepareAndCollectError(p->dbRbu, &pStmt, &p->zErrmsg,\n          \"SELECT sum(cnt * (1 + rbu_index_cnt(rbu_target_name(tbl))))\"\n          \"FROM rbu_count\"\n      );\n      if( p->rc==SQLITE_OK ){\n        if( SQLITE_ROW==sqlite3_step(pStmt) ){\n          p->nPhaseOneStep = sqlite3_column_int64(pStmt, 0);\n        }\n        p->rc = sqlite3_finalize(pStmt);\n      }\n    }\n  }\n}\n\n\nstatic sqlite3rbu *openRbuHandle(\n  const char *zTarget, \n  const char *zRbu,\n  const char *zState\n){\n  sqlite3rbu *p;\n  size_t nTarget = zTarget ? strlen(zTarget) : 0;\n  size_t nRbu = strlen(zRbu);\n  size_t nByte = sizeof(sqlite3rbu) + nTarget+1 + nRbu+1;\n\n  p = (sqlite3rbu*)sqlite3_malloc64(nByte);\n  if( p ){\n    RbuState *pState = 0;\n\n    /* Create the custom VFS. */\n    memset(p, 0, sizeof(sqlite3rbu));\n    rbuCreateVfs(p);\n\n    /* Open the target, RBU and state databases */\n    if( p->rc==SQLITE_OK ){\n      char *pCsr = (char*)&p[1];\n      int bRetry = 0;\n      if( zTarget ){\n        p->zTarget = pCsr;\n        memcpy(p->zTarget, zTarget, nTarget+1);\n        pCsr += nTarget+1;\n      }\n      p->zRbu = pCsr;\n      memcpy(p->zRbu, zRbu, nRbu+1);\n      pCsr += nRbu+1;\n      if( zState ){\n        p->zState = rbuMPrintf(p, \"%s\", zState);\n      }\n\n      /* If the first attempt to open the database file fails and the bRetry\n      ** flag it set, this means that the db was not opened because it seemed\n      ** to be a wal-mode db. But, this may have happened due to an earlier\n      ** RBU vacuum operation leaving an old wal file in the directory.\n      ** If this is the case, it will have been checkpointed and deleted\n      ** when the handle was closed and a second attempt to open the \n      ** database may succeed.  */\n      rbuOpenDatabase(p, &bRetry);\n      if( bRetry ){\n        rbuOpenDatabase(p, 0);\n      }\n    }\n\n    if( p->rc==SQLITE_OK ){\n      pState = rbuLoadState(p);\n      assert( pState || p->rc!=SQLITE_OK );\n      if( p->rc==SQLITE_OK ){\n\n        if( pState->eStage==0 ){ \n          rbuDeleteOalFile(p);\n          rbuInitPhaseOneSteps(p);\n          p->eStage = RBU_STAGE_OAL;\n        }else{\n          p->eStage = pState->eStage;\n          p->nPhaseOneStep = pState->nPhaseOneStep;\n        }\n        p->nProgress = pState->nProgress;\n        p->iOalSz = pState->iOalSz;\n      }\n    }\n    assert( p->rc!=SQLITE_OK || p->eStage!=0 );\n\n    if( p->rc==SQLITE_OK && p->pTargetFd->pWalFd ){\n      if( p->eStage==RBU_STAGE_OAL ){\n        p->rc = SQLITE_ERROR;\n        p->zErrmsg = sqlite3_mprintf(\"cannot update wal mode database\");\n      }else if( p->eStage==RBU_STAGE_MOVE ){\n        p->eStage = RBU_STAGE_CKPT;\n        p->nStep = 0;\n      }\n    }\n\n    if( p->rc==SQLITE_OK \n     && (p->eStage==RBU_STAGE_OAL || p->eStage==RBU_STAGE_MOVE)\n     && pState->eStage!=0\n    ){\n      rbu_file *pFd = (rbuIsVacuum(p) ? p->pRbuFd : p->pTargetFd);\n      if( pFd->iCookie!=pState->iCookie ){   \n        /* At this point (pTargetFd->iCookie) contains the value of the\n        ** change-counter cookie (the thing that gets incremented when a \n        ** transaction is committed in rollback mode) currently stored on \n        ** page 1 of the database file. */\n        p->rc = SQLITE_BUSY;\n        p->zErrmsg = sqlite3_mprintf(\"database modified during rbu %s\",\n            (rbuIsVacuum(p) ? \"vacuum\" : \"update\")\n        );\n      }\n    }\n\n    if( p->rc==SQLITE_OK ){\n      if( p->eStage==RBU_STAGE_OAL ){\n        sqlite3 *db = p->dbMain;\n        p->rc = sqlite3_exec(p->dbRbu, \"BEGIN\", 0, 0, &p->zErrmsg);\n\n        /* Point the object iterator at the first object */\n        if( p->rc==SQLITE_OK ){\n          p->rc = rbuObjIterFirst(p, &p->objiter);\n        }\n\n        /* If the RBU database contains no data_xxx tables, declare the RBU\n        ** update finished.  */\n        if( p->rc==SQLITE_OK && p->objiter.zTbl==0 ){\n          p->rc = SQLITE_DONE;\n          p->eStage = RBU_STAGE_DONE;\n        }else{\n          if( p->rc==SQLITE_OK && pState->eStage==0 && rbuIsVacuum(p) ){\n            rbuCopyPragma(p, \"page_size\");\n            rbuCopyPragma(p, \"auto_vacuum\");\n          }\n\n          /* Open transactions both databases. The *-oal file is opened or\n          ** created at this point. */\n          if( p->rc==SQLITE_OK ){\n            p->rc = sqlite3_exec(db, \"BEGIN IMMEDIATE\", 0, 0, &p->zErrmsg);\n          }\n\n          /* Check if the main database is a zipvfs db. If it is, set the upper\n          ** level pager to use \"journal_mode=off\". This prevents it from \n          ** generating a large journal using a temp file.  */\n          if( p->rc==SQLITE_OK ){\n            int frc = sqlite3_file_control(db, \"main\", SQLITE_FCNTL_ZIPVFS, 0);\n            if( frc==SQLITE_OK ){\n              p->rc = sqlite3_exec(\n                db, \"PRAGMA journal_mode=off\",0,0,&p->zErrmsg);\n            }\n          }\n\n          if( p->rc==SQLITE_OK ){\n            rbuSetupOal(p, pState);\n          }\n        }\n      }else if( p->eStage==RBU_STAGE_MOVE ){\n        /* no-op */\n      }else if( p->eStage==RBU_STAGE_CKPT ){\n        rbuSetupCheckpoint(p, pState);\n      }else if( p->eStage==RBU_STAGE_DONE ){\n        p->rc = SQLITE_DONE;\n      }else{\n        p->rc = SQLITE_CORRUPT;\n      }\n    }\n\n    rbuFreeState(pState);\n  }\n\n  return p;\n}\n\n/*\n** Allocate and return an RBU handle with all fields zeroed except for the\n** error code, which is set to SQLITE_MISUSE.\n*/\nstatic sqlite3rbu *rbuMisuseError(void){\n  sqlite3rbu *pRet;\n  pRet = sqlite3_malloc64(sizeof(sqlite3rbu));\n  if( pRet ){\n    memset(pRet, 0, sizeof(sqlite3rbu));\n    pRet->rc = SQLITE_MISUSE;\n  }\n  return pRet;\n}\n\n/*\n** Open and return a new RBU handle. \n*/\nSQLITE_API sqlite3rbu *sqlite3rbu_open(\n  const char *zTarget, \n  const char *zRbu,\n  const char *zState\n){\n  if( zTarget==0 || zRbu==0 ){ return rbuMisuseError(); }\n  /* TODO: Check that zTarget and zRbu are non-NULL */\n  return openRbuHandle(zTarget, zRbu, zState);\n}\n\n/*\n** Open a handle to begin or resume an RBU VACUUM operation.\n*/\nSQLITE_API sqlite3rbu *sqlite3rbu_vacuum(\n  const char *zTarget, \n  const char *zState\n){\n  if( zTarget==0 ){ return rbuMisuseError(); }\n  if( zState ){\n    int n = strlen(zState);\n    if( n>=7 && 0==memcmp(\"-vactmp\", &zState[n-7], 7) ){\n      return rbuMisuseError();\n    }\n  }\n  /* TODO: Check that both arguments are non-NULL */\n  return openRbuHandle(0, zTarget, zState);\n}\n\n/*\n** Return the database handle used by pRbu.\n*/\nSQLITE_API sqlite3 *sqlite3rbu_db(sqlite3rbu *pRbu, int bRbu){\n  sqlite3 *db = 0;\n  if( pRbu ){\n    db = (bRbu ? pRbu->dbRbu : pRbu->dbMain);\n  }\n  return db;\n}\n\n\n/*\n** If the error code currently stored in the RBU handle is SQLITE_CONSTRAINT,\n** then edit any error message string so as to remove all occurrences of\n** the pattern \"rbu_imp_[0-9]*\".\n*/\nstatic void rbuEditErrmsg(sqlite3rbu *p){\n  if( p->rc==SQLITE_CONSTRAINT && p->zErrmsg ){\n    unsigned int i;\n    size_t nErrmsg = strlen(p->zErrmsg);\n    for(i=0; i<(nErrmsg-8); i++){\n      if( memcmp(&p->zErrmsg[i], \"rbu_imp_\", 8)==0 ){\n        int nDel = 8;\n        while( p->zErrmsg[i+nDel]>='0' && p->zErrmsg[i+nDel]<='9' ) nDel++;\n        memmove(&p->zErrmsg[i], &p->zErrmsg[i+nDel], nErrmsg + 1 - i - nDel);\n        nErrmsg -= nDel;\n      }\n    }\n  }\n}\n\n/*\n** Close the RBU handle.\n*/\nSQLITE_API int sqlite3rbu_close(sqlite3rbu *p, char **pzErrmsg){\n  int rc;\n  if( p ){\n\n    /* Commit the transaction to the *-oal file. */\n    if( p->rc==SQLITE_OK && p->eStage==RBU_STAGE_OAL ){\n      p->rc = sqlite3_exec(p->dbMain, \"COMMIT\", 0, 0, &p->zErrmsg);\n    }\n\n    /* Sync the db file if currently doing an incremental checkpoint */\n    if( p->rc==SQLITE_OK && p->eStage==RBU_STAGE_CKPT ){\n      sqlite3_file *pDb = p->pTargetFd->pReal;\n      p->rc = pDb->pMethods->xSync(pDb, SQLITE_SYNC_NORMAL);\n    }\n\n    rbuSaveState(p, p->eStage);\n\n    if( p->rc==SQLITE_OK && p->eStage==RBU_STAGE_OAL ){\n      p->rc = sqlite3_exec(p->dbRbu, \"COMMIT\", 0, 0, &p->zErrmsg);\n    }\n\n    /* Close any open statement handles. */\n    rbuObjIterFinalize(&p->objiter);\n\n    /* If this is an RBU vacuum handle and the vacuum has either finished\n    ** successfully or encountered an error, delete the contents of the \n    ** state table. This causes the next call to sqlite3rbu_vacuum() \n    ** specifying the current target and state databases to start a new\n    ** vacuum from scratch.  */\n    if( rbuIsVacuum(p) && p->rc!=SQLITE_OK && p->dbRbu ){\n      int rc2 = sqlite3_exec(p->dbRbu, \"DELETE FROM stat.rbu_state\", 0, 0, 0);\n      if( p->rc==SQLITE_DONE && rc2!=SQLITE_OK ) p->rc = rc2;\n    }\n\n    /* Close the open database handle and VFS object. */\n    sqlite3_close(p->dbRbu);\n    sqlite3_close(p->dbMain);\n    assert( p->szTemp==0 );\n    rbuDeleteVfs(p);\n    sqlite3_free(p->aBuf);\n    sqlite3_free(p->aFrame);\n\n    rbuEditErrmsg(p);\n    rc = p->rc;\n    if( pzErrmsg ){\n      *pzErrmsg = p->zErrmsg;\n    }else{\n      sqlite3_free(p->zErrmsg);\n    }\n    sqlite3_free(p->zState);\n    sqlite3_free(p);\n  }else{\n    rc = SQLITE_NOMEM;\n    *pzErrmsg = 0;\n  }\n  return rc;\n}\n\n/*\n** Return the total number of key-value operations (inserts, deletes or \n** updates) that have been performed on the target database since the\n** current RBU update was started.\n*/\nSQLITE_API sqlite3_int64 sqlite3rbu_progress(sqlite3rbu *pRbu){\n  return pRbu->nProgress;\n}\n\n/*\n** Return permyriadage progress indications for the two main stages of\n** an RBU update.\n*/\nSQLITE_API void sqlite3rbu_bp_progress(sqlite3rbu *p, int *pnOne, int *pnTwo){\n  const int MAX_PROGRESS = 10000;\n  switch( p->eStage ){\n    case RBU_STAGE_OAL:\n      if( p->nPhaseOneStep>0 ){\n        *pnOne = (int)(MAX_PROGRESS * (i64)p->nProgress/(i64)p->nPhaseOneStep);\n      }else{\n        *pnOne = -1;\n      }\n      *pnTwo = 0;\n      break;\n\n    case RBU_STAGE_MOVE:\n      *pnOne = MAX_PROGRESS;\n      *pnTwo = 0;\n      break;\n\n    case RBU_STAGE_CKPT:\n      *pnOne = MAX_PROGRESS;\n      *pnTwo = (int)(MAX_PROGRESS * (i64)p->nStep / (i64)p->nFrame);\n      break;\n\n    case RBU_STAGE_DONE:\n      *pnOne = MAX_PROGRESS;\n      *pnTwo = MAX_PROGRESS;\n      break;\n\n    default:\n      assert( 0 );\n  }\n}\n\n/*\n** Return the current state of the RBU vacuum or update operation.\n*/\nSQLITE_API int sqlite3rbu_state(sqlite3rbu *p){\n  int aRes[] = {\n    0, SQLITE_RBU_STATE_OAL, SQLITE_RBU_STATE_MOVE,\n    0, SQLITE_RBU_STATE_CHECKPOINT, SQLITE_RBU_STATE_DONE\n  };\n\n  assert( RBU_STAGE_OAL==1 );\n  assert( RBU_STAGE_MOVE==2 );\n  assert( RBU_STAGE_CKPT==4 );\n  assert( RBU_STAGE_DONE==5 );\n  assert( aRes[RBU_STAGE_OAL]==SQLITE_RBU_STATE_OAL );\n  assert( aRes[RBU_STAGE_MOVE]==SQLITE_RBU_STATE_MOVE );\n  assert( aRes[RBU_STAGE_CKPT]==SQLITE_RBU_STATE_CHECKPOINT );\n  assert( aRes[RBU_STAGE_DONE]==SQLITE_RBU_STATE_DONE );\n\n  if( p->rc!=SQLITE_OK && p->rc!=SQLITE_DONE ){\n    return SQLITE_RBU_STATE_ERROR;\n  }else{\n    assert( p->rc!=SQLITE_DONE || p->eStage==RBU_STAGE_DONE );\n    assert( p->eStage==RBU_STAGE_OAL\n         || p->eStage==RBU_STAGE_MOVE\n         || p->eStage==RBU_STAGE_CKPT\n         || p->eStage==RBU_STAGE_DONE\n    );\n    return aRes[p->eStage];\n  }\n}\n\nSQLITE_API int sqlite3rbu_savestate(sqlite3rbu *p){\n  int rc = p->rc;\n  if( rc==SQLITE_DONE ) return SQLITE_OK;\n\n  assert( p->eStage>=RBU_STAGE_OAL && p->eStage<=RBU_STAGE_DONE );\n  if( p->eStage==RBU_STAGE_OAL ){\n    assert( rc!=SQLITE_DONE );\n    if( rc==SQLITE_OK ) rc = sqlite3_exec(p->dbMain, \"COMMIT\", 0, 0, 0);\n  }\n\n  /* Sync the db file */\n  if( rc==SQLITE_OK && p->eStage==RBU_STAGE_CKPT ){\n    sqlite3_file *pDb = p->pTargetFd->pReal;\n    rc = pDb->pMethods->xSync(pDb, SQLITE_SYNC_NORMAL);\n  }\n\n  p->rc = rc;\n  rbuSaveState(p, p->eStage);\n  rc = p->rc;\n\n  if( p->eStage==RBU_STAGE_OAL ){\n    assert( rc!=SQLITE_DONE );\n    if( rc==SQLITE_OK ) rc = sqlite3_exec(p->dbRbu, \"COMMIT\", 0, 0, 0);\n    if( rc==SQLITE_OK ){ \n      const char *zBegin = rbuIsVacuum(p) ? \"BEGIN\" : \"BEGIN IMMEDIATE\";\n      rc = sqlite3_exec(p->dbRbu, zBegin, 0, 0, 0);\n    }\n    if( rc==SQLITE_OK ) rc = sqlite3_exec(p->dbMain, \"BEGIN IMMEDIATE\", 0, 0,0);\n  }\n\n  p->rc = rc;\n  return rc;\n}\n\n/**************************************************************************\n** Beginning of RBU VFS shim methods. The VFS shim modifies the behaviour\n** of a standard VFS in the following ways:\n**\n** 1. Whenever the first page of a main database file is read or \n**    written, the value of the change-counter cookie is stored in\n**    rbu_file.iCookie. Similarly, the value of the \"write-version\"\n**    database header field is stored in rbu_file.iWriteVer. This ensures\n**    that the values are always trustworthy within an open transaction.\n**\n** 2. Whenever an SQLITE_OPEN_WAL file is opened, the (rbu_file.pWalFd)\n**    member variable of the associated database file descriptor is set\n**    to point to the new file. A mutex protected linked list of all main \n**    db fds opened using a particular RBU VFS is maintained at \n**    rbu_vfs.pMain to facilitate this.\n**\n** 3. Using a new file-control \"SQLITE_FCNTL_RBU\", a main db rbu_file \n**    object can be marked as the target database of an RBU update. This\n**    turns on the following extra special behaviour:\n**\n** 3a. If xAccess() is called to check if there exists a *-wal file \n**     associated with an RBU target database currently in RBU_STAGE_OAL\n**     stage (preparing the *-oal file), the following special handling\n**     applies:\n**\n**      * if the *-wal file does exist, return SQLITE_CANTOPEN. An RBU\n**        target database may not be in wal mode already.\n**\n**      * if the *-wal file does not exist, set the output parameter to\n**        non-zero (to tell SQLite that it does exist) anyway.\n**\n**     Then, when xOpen() is called to open the *-wal file associated with\n**     the RBU target in RBU_STAGE_OAL stage, instead of opening the *-wal\n**     file, the rbu vfs opens the corresponding *-oal file instead. \n**\n** 3b. The *-shm pages returned by xShmMap() for a target db file in\n**     RBU_STAGE_OAL mode are actually stored in heap memory. This is to\n**     avoid creating a *-shm file on disk. Additionally, xShmLock() calls\n**     are no-ops on target database files in RBU_STAGE_OAL mode. This is\n**     because assert() statements in some VFS implementations fail if \n**     xShmLock() is called before xShmMap().\n**\n** 3c. If an EXCLUSIVE lock is attempted on a target database file in any\n**     mode except RBU_STAGE_DONE (all work completed and checkpointed), it \n**     fails with an SQLITE_BUSY error. This is to stop RBU connections\n**     from automatically checkpointing a *-wal (or *-oal) file from within\n**     sqlite3_close().\n**\n** 3d. In RBU_STAGE_CAPTURE mode, all xRead() calls on the wal file, and\n**     all xWrite() calls on the target database file perform no IO. \n**     Instead the frame and page numbers that would be read and written\n**     are recorded. Additionally, successful attempts to obtain exclusive\n**     xShmLock() WRITER, CHECKPOINTER and READ0 locks on the target \n**     database file are recorded. xShmLock() calls to unlock the same\n**     locks are no-ops (so that once obtained, these locks are never\n**     relinquished). Finally, calls to xSync() on the target database\n**     file fail with SQLITE_INTERNAL errors.\n*/\n\nstatic void rbuUnlockShm(rbu_file *p){\n  assert( p->openFlags & SQLITE_OPEN_MAIN_DB );\n  if( p->pRbu ){\n    int (*xShmLock)(sqlite3_file*,int,int,int) = p->pReal->pMethods->xShmLock;\n    int i;\n    for(i=0; i<SQLITE_SHM_NLOCK;i++){\n      if( (1<<i) & p->pRbu->mLock ){\n        xShmLock(p->pReal, i, 1, SQLITE_SHM_UNLOCK|SQLITE_SHM_EXCLUSIVE);\n      }\n    }\n    p->pRbu->mLock = 0;\n  }\n}\n\n/*\n*/\nstatic int rbuUpdateTempSize(rbu_file *pFd, sqlite3_int64 nNew){\n  sqlite3rbu *pRbu = pFd->pRbu;\n  i64 nDiff = nNew - pFd->sz;\n  pRbu->szTemp += nDiff;\n  pFd->sz = nNew;\n  assert( pRbu->szTemp>=0 );\n  if( pRbu->szTempLimit && pRbu->szTemp>pRbu->szTempLimit ) return SQLITE_FULL;\n  return SQLITE_OK;\n}\n\n/*\n** Add an item to the main-db lists, if it is not already present.\n**\n** There are two main-db lists. One for all file descriptors, and one\n** for all file descriptors with rbu_file.pDb!=0. If the argument has\n** rbu_file.pDb!=0, then it is assumed to already be present on the\n** main list and is only added to the pDb!=0 list.\n*/\nstatic void rbuMainlistAdd(rbu_file *p){\n  rbu_vfs *pRbuVfs = p->pRbuVfs;\n  rbu_file *pIter;\n  assert( (p->openFlags & SQLITE_OPEN_MAIN_DB) );\n  sqlite3_mutex_enter(pRbuVfs->mutex);\n  if( p->pRbu==0 ){\n    for(pIter=pRbuVfs->pMain; pIter; pIter=pIter->pMainNext);\n    p->pMainNext = pRbuVfs->pMain;\n    pRbuVfs->pMain = p;\n  }else{\n    for(pIter=pRbuVfs->pMainRbu; pIter && pIter!=p; pIter=pIter->pMainRbuNext){}\n    if( pIter==0 ){\n      p->pMainRbuNext = pRbuVfs->pMainRbu;\n      pRbuVfs->pMainRbu = p;\n    }\n  }\n  sqlite3_mutex_leave(pRbuVfs->mutex);\n}\n\n/*\n** Remove an item from the main-db lists.\n*/\nstatic void rbuMainlistRemove(rbu_file *p){\n  rbu_file **pp;\n  sqlite3_mutex_enter(p->pRbuVfs->mutex);\n  for(pp=&p->pRbuVfs->pMain; *pp && *pp!=p; pp=&((*pp)->pMainNext)){}\n  if( *pp ) *pp = p->pMainNext;\n  p->pMainNext = 0;\n  for(pp=&p->pRbuVfs->pMainRbu; *pp && *pp!=p; pp=&((*pp)->pMainRbuNext)){}\n  if( *pp ) *pp = p->pMainRbuNext;\n  p->pMainRbuNext = 0;\n  sqlite3_mutex_leave(p->pRbuVfs->mutex);\n}\n\n/*\n** Given that zWal points to a buffer containing a wal file name passed to \n** either the xOpen() or xAccess() VFS method, search the main-db list for\n** a file-handle opened by the same database connection on the corresponding\n** database file.\n**\n** If parameter bRbu is true, only search for file-descriptors with\n** rbu_file.pDb!=0.\n*/\nstatic rbu_file *rbuFindMaindb(rbu_vfs *pRbuVfs, const char *zWal, int bRbu){\n  rbu_file *pDb;\n  sqlite3_mutex_enter(pRbuVfs->mutex);\n  if( bRbu ){\n    for(pDb=pRbuVfs->pMainRbu; pDb && pDb->zWal!=zWal; pDb=pDb->pMainRbuNext){}\n  }else{\n    for(pDb=pRbuVfs->pMain; pDb && pDb->zWal!=zWal; pDb=pDb->pMainNext){}\n  }\n  sqlite3_mutex_leave(pRbuVfs->mutex);\n  return pDb;\n}\n\n/*\n** Close an rbu file.\n*/\nstatic int rbuVfsClose(sqlite3_file *pFile){\n  rbu_file *p = (rbu_file*)pFile;\n  int rc;\n  int i;\n\n  /* Free the contents of the apShm[] array. And the array itself. */\n  for(i=0; i<p->nShm; i++){\n    sqlite3_free(p->apShm[i]);\n  }\n  sqlite3_free(p->apShm);\n  p->apShm = 0;\n  sqlite3_free(p->zDel);\n\n  if( p->openFlags & SQLITE_OPEN_MAIN_DB ){\n    rbuMainlistRemove(p);\n    rbuUnlockShm(p);\n    p->pReal->pMethods->xShmUnmap(p->pReal, 0);\n  }\n  else if( (p->openFlags & SQLITE_OPEN_DELETEONCLOSE) && p->pRbu ){\n    rbuUpdateTempSize(p, 0);\n  }\n  assert( p->pMainNext==0 && p->pRbuVfs->pMain!=p );\n\n  /* Close the underlying file handle */\n  rc = p->pReal->pMethods->xClose(p->pReal);\n  return rc;\n}\n\n\n/*\n** Read and return an unsigned 32-bit big-endian integer from the buffer \n** passed as the only argument.\n*/\nstatic u32 rbuGetU32(u8 *aBuf){\n  return ((u32)aBuf[0] << 24)\n       + ((u32)aBuf[1] << 16)\n       + ((u32)aBuf[2] <<  8)\n       + ((u32)aBuf[3]);\n}\n\n/*\n** Write an unsigned 32-bit value in big-endian format to the supplied\n** buffer.\n*/\nstatic void rbuPutU32(u8 *aBuf, u32 iVal){\n  aBuf[0] = (iVal >> 24) & 0xFF;\n  aBuf[1] = (iVal >> 16) & 0xFF;\n  aBuf[2] = (iVal >>  8) & 0xFF;\n  aBuf[3] = (iVal >>  0) & 0xFF;\n}\n\nstatic void rbuPutU16(u8 *aBuf, u16 iVal){\n  aBuf[0] = (iVal >>  8) & 0xFF;\n  aBuf[1] = (iVal >>  0) & 0xFF;\n}\n\n/*\n** Read data from an rbuVfs-file.\n*/\nstatic int rbuVfsRead(\n  sqlite3_file *pFile, \n  void *zBuf, \n  int iAmt, \n  sqlite_int64 iOfst\n){\n  rbu_file *p = (rbu_file*)pFile;\n  sqlite3rbu *pRbu = p->pRbu;\n  int rc;\n\n  if( pRbu && pRbu->eStage==RBU_STAGE_CAPTURE ){\n    assert( p->openFlags & SQLITE_OPEN_WAL );\n    rc = rbuCaptureWalRead(p->pRbu, iOfst, iAmt);\n  }else{\n    if( pRbu && pRbu->eStage==RBU_STAGE_OAL \n     && (p->openFlags & SQLITE_OPEN_WAL) \n     && iOfst>=pRbu->iOalSz \n    ){\n      rc = SQLITE_OK;\n      memset(zBuf, 0, iAmt);\n    }else{\n      rc = p->pReal->pMethods->xRead(p->pReal, zBuf, iAmt, iOfst);\n#if 1\n      /* If this is being called to read the first page of the target \n      ** database as part of an rbu vacuum operation, synthesize the \n      ** contents of the first page if it does not yet exist. Otherwise,\n      ** SQLite will not check for a *-wal file.  */\n      if( pRbu && rbuIsVacuum(pRbu) \n          && rc==SQLITE_IOERR_SHORT_READ && iOfst==0\n          && (p->openFlags & SQLITE_OPEN_MAIN_DB)\n          && pRbu->rc==SQLITE_OK\n      ){\n        sqlite3_file *pFd = (sqlite3_file*)pRbu->pRbuFd;\n        rc = pFd->pMethods->xRead(pFd, zBuf, iAmt, iOfst);\n        if( rc==SQLITE_OK ){\n          u8 *aBuf = (u8*)zBuf;\n          u32 iRoot = rbuGetU32(&aBuf[52]) ? 1 : 0;\n          rbuPutU32(&aBuf[52], iRoot);      /* largest root page number */\n          rbuPutU32(&aBuf[36], 0);          /* number of free pages */\n          rbuPutU32(&aBuf[32], 0);          /* first page on free list trunk */\n          rbuPutU32(&aBuf[28], 1);          /* size of db file in pages */\n          rbuPutU32(&aBuf[24], pRbu->pRbuFd->iCookie+1);  /* Change counter */\n\n          if( iAmt>100 ){\n            memset(&aBuf[100], 0, iAmt-100);\n            rbuPutU16(&aBuf[105], iAmt & 0xFFFF);\n            aBuf[100] = 0x0D;\n          }\n        }\n      }\n#endif\n    }\n    if( rc==SQLITE_OK && iOfst==0 && (p->openFlags & SQLITE_OPEN_MAIN_DB) ){\n      /* These look like magic numbers. But they are stable, as they are part\n       ** of the definition of the SQLite file format, which may not change. */\n      u8 *pBuf = (u8*)zBuf;\n      p->iCookie = rbuGetU32(&pBuf[24]);\n      p->iWriteVer = pBuf[19];\n    }\n  }\n  return rc;\n}\n\n/*\n** Write data to an rbuVfs-file.\n*/\nstatic int rbuVfsWrite(\n  sqlite3_file *pFile, \n  const void *zBuf, \n  int iAmt, \n  sqlite_int64 iOfst\n){\n  rbu_file *p = (rbu_file*)pFile;\n  sqlite3rbu *pRbu = p->pRbu;\n  int rc;\n\n  if( pRbu && pRbu->eStage==RBU_STAGE_CAPTURE ){\n    assert( p->openFlags & SQLITE_OPEN_MAIN_DB );\n    rc = rbuCaptureDbWrite(p->pRbu, iOfst);\n  }else{\n    if( pRbu ){\n      if( pRbu->eStage==RBU_STAGE_OAL \n       && (p->openFlags & SQLITE_OPEN_WAL) \n       && iOfst>=pRbu->iOalSz\n      ){\n        pRbu->iOalSz = iAmt + iOfst;\n      }else if( p->openFlags & SQLITE_OPEN_DELETEONCLOSE ){\n        i64 szNew = iAmt+iOfst;\n        if( szNew>p->sz ){\n          rc = rbuUpdateTempSize(p, szNew);\n          if( rc!=SQLITE_OK ) return rc;\n        }\n      }\n    }\n    rc = p->pReal->pMethods->xWrite(p->pReal, zBuf, iAmt, iOfst);\n    if( rc==SQLITE_OK && iOfst==0 && (p->openFlags & SQLITE_OPEN_MAIN_DB) ){\n      /* These look like magic numbers. But they are stable, as they are part\n      ** of the definition of the SQLite file format, which may not change. */\n      u8 *pBuf = (u8*)zBuf;\n      p->iCookie = rbuGetU32(&pBuf[24]);\n      p->iWriteVer = pBuf[19];\n    }\n  }\n  return rc;\n}\n\n/*\n** Truncate an rbuVfs-file.\n*/\nstatic int rbuVfsTruncate(sqlite3_file *pFile, sqlite_int64 size){\n  rbu_file *p = (rbu_file*)pFile;\n  if( (p->openFlags & SQLITE_OPEN_DELETEONCLOSE) && p->pRbu ){\n    int rc = rbuUpdateTempSize(p, size);\n    if( rc!=SQLITE_OK ) return rc;\n  }\n  return p->pReal->pMethods->xTruncate(p->pReal, size);\n}\n\n/*\n** Sync an rbuVfs-file.\n*/\nstatic int rbuVfsSync(sqlite3_file *pFile, int flags){\n  rbu_file *p = (rbu_file *)pFile;\n  if( p->pRbu && p->pRbu->eStage==RBU_STAGE_CAPTURE ){\n    if( p->openFlags & SQLITE_OPEN_MAIN_DB ){\n      return SQLITE_INTERNAL;\n    }\n    return SQLITE_OK;\n  }\n  return p->pReal->pMethods->xSync(p->pReal, flags);\n}\n\n/*\n** Return the current file-size of an rbuVfs-file.\n*/\nstatic int rbuVfsFileSize(sqlite3_file *pFile, sqlite_int64 *pSize){\n  rbu_file *p = (rbu_file *)pFile;\n  int rc;\n  rc = p->pReal->pMethods->xFileSize(p->pReal, pSize);\n\n  /* If this is an RBU vacuum operation and this is the target database,\n  ** pretend that it has at least one page. Otherwise, SQLite will not\n  ** check for the existance of a *-wal file. rbuVfsRead() contains \n  ** similar logic.  */\n  if( rc==SQLITE_OK && *pSize==0 \n   && p->pRbu && rbuIsVacuum(p->pRbu) \n   && (p->openFlags & SQLITE_OPEN_MAIN_DB)\n  ){\n    *pSize = 1024;\n  }\n  return rc;\n}\n\n/*\n** Lock an rbuVfs-file.\n*/\nstatic int rbuVfsLock(sqlite3_file *pFile, int eLock){\n  rbu_file *p = (rbu_file*)pFile;\n  sqlite3rbu *pRbu = p->pRbu;\n  int rc = SQLITE_OK;\n\n  assert( p->openFlags & (SQLITE_OPEN_MAIN_DB|SQLITE_OPEN_TEMP_DB) );\n  if( eLock==SQLITE_LOCK_EXCLUSIVE \n   && (p->bNolock || (pRbu && pRbu->eStage!=RBU_STAGE_DONE))\n  ){\n    /* Do not allow EXCLUSIVE locks. Preventing SQLite from taking this \n    ** prevents it from checkpointing the database from sqlite3_close(). */\n    rc = SQLITE_BUSY;\n  }else{\n    rc = p->pReal->pMethods->xLock(p->pReal, eLock);\n  }\n\n  return rc;\n}\n\n/*\n** Unlock an rbuVfs-file.\n*/\nstatic int rbuVfsUnlock(sqlite3_file *pFile, int eLock){\n  rbu_file *p = (rbu_file *)pFile;\n  return p->pReal->pMethods->xUnlock(p->pReal, eLock);\n}\n\n/*\n** Check if another file-handle holds a RESERVED lock on an rbuVfs-file.\n*/\nstatic int rbuVfsCheckReservedLock(sqlite3_file *pFile, int *pResOut){\n  rbu_file *p = (rbu_file *)pFile;\n  return p->pReal->pMethods->xCheckReservedLock(p->pReal, pResOut);\n}\n\n/*\n** File control method. For custom operations on an rbuVfs-file.\n*/\nstatic int rbuVfsFileControl(sqlite3_file *pFile, int op, void *pArg){\n  rbu_file *p = (rbu_file *)pFile;\n  int (*xControl)(sqlite3_file*,int,void*) = p->pReal->pMethods->xFileControl;\n  int rc;\n\n  assert( p->openFlags & (SQLITE_OPEN_MAIN_DB|SQLITE_OPEN_TEMP_DB)\n       || p->openFlags & (SQLITE_OPEN_TRANSIENT_DB|SQLITE_OPEN_TEMP_JOURNAL)\n  );\n  if( op==SQLITE_FCNTL_RBU ){\n    sqlite3rbu *pRbu = (sqlite3rbu*)pArg;\n\n    /* First try to find another RBU vfs lower down in the vfs stack. If\n    ** one is found, this vfs will operate in pass-through mode. The lower\n    ** level vfs will do the special RBU handling.  */\n    rc = xControl(p->pReal, op, pArg);\n\n    if( rc==SQLITE_NOTFOUND ){\n      /* Now search for a zipvfs instance lower down in the VFS stack. If\n      ** one is found, this is an error.  */\n      void *dummy = 0;\n      rc = xControl(p->pReal, SQLITE_FCNTL_ZIPVFS, &dummy);\n      if( rc==SQLITE_OK ){\n        rc = SQLITE_ERROR;\n        pRbu->zErrmsg = sqlite3_mprintf(\"rbu/zipvfs setup error\");\n      }else if( rc==SQLITE_NOTFOUND ){\n        pRbu->pTargetFd = p;\n        p->pRbu = pRbu;\n        if( p->openFlags & SQLITE_OPEN_MAIN_DB ){\n          rbuMainlistAdd(p);\n        }\n        if( p->pWalFd ) p->pWalFd->pRbu = pRbu;\n        rc = SQLITE_OK;\n      }\n    }\n    return rc;\n  }\n  else if( op==SQLITE_FCNTL_RBUCNT ){\n    sqlite3rbu *pRbu = (sqlite3rbu*)pArg;\n    pRbu->nRbu++;\n    pRbu->pRbuFd = p;\n    p->bNolock = 1;\n  }\n\n  rc = xControl(p->pReal, op, pArg);\n  if( rc==SQLITE_OK && op==SQLITE_FCNTL_VFSNAME ){\n    rbu_vfs *pRbuVfs = p->pRbuVfs;\n    char *zIn = *(char**)pArg;\n    char *zOut = sqlite3_mprintf(\"rbu(%s)/%z\", pRbuVfs->base.zName, zIn);\n    *(char**)pArg = zOut;\n    if( zOut==0 ) rc = SQLITE_NOMEM;\n  }\n\n  return rc;\n}\n\n/*\n** Return the sector-size in bytes for an rbuVfs-file.\n*/\nstatic int rbuVfsSectorSize(sqlite3_file *pFile){\n  rbu_file *p = (rbu_file *)pFile;\n  return p->pReal->pMethods->xSectorSize(p->pReal);\n}\n\n/*\n** Return the device characteristic flags supported by an rbuVfs-file.\n*/\nstatic int rbuVfsDeviceCharacteristics(sqlite3_file *pFile){\n  rbu_file *p = (rbu_file *)pFile;\n  return p->pReal->pMethods->xDeviceCharacteristics(p->pReal);\n}\n\n/*\n** Take or release a shared-memory lock.\n*/\nstatic int rbuVfsShmLock(sqlite3_file *pFile, int ofst, int n, int flags){\n  rbu_file *p = (rbu_file*)pFile;\n  sqlite3rbu *pRbu = p->pRbu;\n  int rc = SQLITE_OK;\n\n#ifdef SQLITE_AMALGAMATION\n    assert( WAL_CKPT_LOCK==1 );\n#endif\n\n  assert( p->openFlags & (SQLITE_OPEN_MAIN_DB|SQLITE_OPEN_TEMP_DB) );\n  if( pRbu && (pRbu->eStage==RBU_STAGE_OAL || pRbu->eStage==RBU_STAGE_MOVE) ){\n    /* Magic number 1 is the WAL_CKPT_LOCK lock. Preventing SQLite from\n    ** taking this lock also prevents any checkpoints from occurring. \n    ** todo: really, it's not clear why this might occur, as \n    ** wal_autocheckpoint ought to be turned off.  */\n    if( ofst==WAL_LOCK_CKPT && n==1 ) rc = SQLITE_BUSY;\n  }else{\n    int bCapture = 0;\n    if( n==1 && (flags & SQLITE_SHM_EXCLUSIVE)\n     && pRbu && pRbu->eStage==RBU_STAGE_CAPTURE\n     && (ofst==WAL_LOCK_WRITE || ofst==WAL_LOCK_CKPT || ofst==WAL_LOCK_READ0)\n    ){\n      bCapture = 1;\n    }\n\n    if( bCapture==0 || 0==(flags & SQLITE_SHM_UNLOCK) ){\n      rc = p->pReal->pMethods->xShmLock(p->pReal, ofst, n, flags);\n      if( bCapture && rc==SQLITE_OK ){\n        pRbu->mLock |= (1 << ofst);\n      }\n    }\n  }\n\n  return rc;\n}\n\n/*\n** Obtain a pointer to a mapping of a single 32KiB page of the *-shm file.\n*/\nstatic int rbuVfsShmMap(\n  sqlite3_file *pFile, \n  int iRegion, \n  int szRegion, \n  int isWrite, \n  void volatile **pp\n){\n  rbu_file *p = (rbu_file*)pFile;\n  int rc = SQLITE_OK;\n  int eStage = (p->pRbu ? p->pRbu->eStage : 0);\n\n  /* If not in RBU_STAGE_OAL, allow this call to pass through. Or, if this\n  ** rbu is in the RBU_STAGE_OAL state, use heap memory for *-shm space \n  ** instead of a file on disk.  */\n  assert( p->openFlags & (SQLITE_OPEN_MAIN_DB|SQLITE_OPEN_TEMP_DB) );\n  if( eStage==RBU_STAGE_OAL || eStage==RBU_STAGE_MOVE ){\n    if( iRegion<=p->nShm ){\n      int nByte = (iRegion+1) * sizeof(char*);\n      char **apNew = (char**)sqlite3_realloc64(p->apShm, nByte);\n      if( apNew==0 ){\n        rc = SQLITE_NOMEM;\n      }else{\n        memset(&apNew[p->nShm], 0, sizeof(char*) * (1 + iRegion - p->nShm));\n        p->apShm = apNew;\n        p->nShm = iRegion+1;\n      }\n    }\n\n    if( rc==SQLITE_OK && p->apShm[iRegion]==0 ){\n      char *pNew = (char*)sqlite3_malloc64(szRegion);\n      if( pNew==0 ){\n        rc = SQLITE_NOMEM;\n      }else{\n        memset(pNew, 0, szRegion);\n        p->apShm[iRegion] = pNew;\n      }\n    }\n\n    if( rc==SQLITE_OK ){\n      *pp = p->apShm[iRegion];\n    }else{\n      *pp = 0;\n    }\n  }else{\n    assert( p->apShm==0 );\n    rc = p->pReal->pMethods->xShmMap(p->pReal, iRegion, szRegion, isWrite, pp);\n  }\n\n  return rc;\n}\n\n/*\n** Memory barrier.\n*/\nstatic void rbuVfsShmBarrier(sqlite3_file *pFile){\n  rbu_file *p = (rbu_file *)pFile;\n  p->pReal->pMethods->xShmBarrier(p->pReal);\n}\n\n/*\n** The xShmUnmap method.\n*/\nstatic int rbuVfsShmUnmap(sqlite3_file *pFile, int delFlag){\n  rbu_file *p = (rbu_file*)pFile;\n  int rc = SQLITE_OK;\n  int eStage = (p->pRbu ? p->pRbu->eStage : 0);\n\n  assert( p->openFlags & (SQLITE_OPEN_MAIN_DB|SQLITE_OPEN_TEMP_DB) );\n  if( eStage==RBU_STAGE_OAL || eStage==RBU_STAGE_MOVE ){\n    /* no-op */\n  }else{\n    /* Release the checkpointer and writer locks */\n    rbuUnlockShm(p);\n    rc = p->pReal->pMethods->xShmUnmap(p->pReal, delFlag);\n  }\n  return rc;\n}\n\n/* \n** A main database named zName has just been opened. The following \n** function returns a pointer to a buffer owned by SQLite that contains\n** the name of the *-wal file this db connection will use. SQLite\n** happens to pass a pointer to this buffer when using xAccess()\n** or xOpen() to operate on the *-wal file.  \n*/\nstatic const char *rbuMainToWal(const char *zName, int flags){\n  int n = (int)strlen(zName);\n  const char *z = &zName[n];\n  if( flags & SQLITE_OPEN_URI ){\n    int odd = 0;\n    while( 1 ){\n      if( z[0]==0 ){\n        odd = 1 - odd;\n        if( odd && z[1]==0 ) break;\n      }\n      z++;\n    }\n    z += 2;\n  }else{\n    while( *z==0 ) z++;\n  }\n  z += (n + 8 + 1);\n  return z;\n}\n\n/*\n** Open an rbu file handle.\n*/\nstatic int rbuVfsOpen(\n  sqlite3_vfs *pVfs,\n  const char *zName,\n  sqlite3_file *pFile,\n  int flags,\n  int *pOutFlags\n){\n  static sqlite3_io_methods rbuvfs_io_methods = {\n    2,                            /* iVersion */\n    rbuVfsClose,                  /* xClose */\n    rbuVfsRead,                   /* xRead */\n    rbuVfsWrite,                  /* xWrite */\n    rbuVfsTruncate,               /* xTruncate */\n    rbuVfsSync,                   /* xSync */\n    rbuVfsFileSize,               /* xFileSize */\n    rbuVfsLock,                   /* xLock */\n    rbuVfsUnlock,                 /* xUnlock */\n    rbuVfsCheckReservedLock,      /* xCheckReservedLock */\n    rbuVfsFileControl,            /* xFileControl */\n    rbuVfsSectorSize,             /* xSectorSize */\n    rbuVfsDeviceCharacteristics,  /* xDeviceCharacteristics */\n    rbuVfsShmMap,                 /* xShmMap */\n    rbuVfsShmLock,                /* xShmLock */\n    rbuVfsShmBarrier,             /* xShmBarrier */\n    rbuVfsShmUnmap,               /* xShmUnmap */\n    0, 0                          /* xFetch, xUnfetch */\n  };\n  rbu_vfs *pRbuVfs = (rbu_vfs*)pVfs;\n  sqlite3_vfs *pRealVfs = pRbuVfs->pRealVfs;\n  rbu_file *pFd = (rbu_file *)pFile;\n  int rc = SQLITE_OK;\n  const char *zOpen = zName;\n  int oflags = flags;\n\n  memset(pFd, 0, sizeof(rbu_file));\n  pFd->pReal = (sqlite3_file*)&pFd[1];\n  pFd->pRbuVfs = pRbuVfs;\n  pFd->openFlags = flags;\n  if( zName ){\n    if( flags & SQLITE_OPEN_MAIN_DB ){\n      /* A main database has just been opened. The following block sets\n      ** (pFd->zWal) to point to a buffer owned by SQLite that contains\n      ** the name of the *-wal file this db connection will use. SQLite\n      ** happens to pass a pointer to this buffer when using xAccess()\n      ** or xOpen() to operate on the *-wal file.  */\n      pFd->zWal = rbuMainToWal(zName, flags);\n    }\n    else if( flags & SQLITE_OPEN_WAL ){\n      rbu_file *pDb = rbuFindMaindb(pRbuVfs, zName, 0);\n      if( pDb ){\n        if( pDb->pRbu && pDb->pRbu->eStage==RBU_STAGE_OAL ){\n          /* This call is to open a *-wal file. Intead, open the *-oal. This\n          ** code ensures that the string passed to xOpen() is terminated by a\n          ** pair of '\\0' bytes in case the VFS attempts to extract a URI \n          ** parameter from it.  */\n          const char *zBase = zName;\n          size_t nCopy;\n          char *zCopy;\n          if( rbuIsVacuum(pDb->pRbu) ){\n            zBase = sqlite3_db_filename(pDb->pRbu->dbRbu, \"main\");\n            zBase = rbuMainToWal(zBase, SQLITE_OPEN_URI);\n          }\n          nCopy = strlen(zBase);\n          zCopy = sqlite3_malloc64(nCopy+2);\n          if( zCopy ){\n            memcpy(zCopy, zBase, nCopy);\n            zCopy[nCopy-3] = 'o';\n            zCopy[nCopy] = '\\0';\n            zCopy[nCopy+1] = '\\0';\n            zOpen = (const char*)(pFd->zDel = zCopy);\n          }else{\n            rc = SQLITE_NOMEM;\n          }\n          pFd->pRbu = pDb->pRbu;\n        }\n        pDb->pWalFd = pFd;\n      }\n    }\n  }else{\n    pFd->pRbu = pRbuVfs->pRbu;\n  }\n\n  if( oflags & SQLITE_OPEN_MAIN_DB \n   && sqlite3_uri_boolean(zName, \"rbu_memory\", 0) \n  ){\n    assert( oflags & SQLITE_OPEN_MAIN_DB );\n    oflags =  SQLITE_OPEN_TEMP_DB | SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE |\n              SQLITE_OPEN_EXCLUSIVE | SQLITE_OPEN_DELETEONCLOSE;\n    zOpen = 0;\n  }\n\n  if( rc==SQLITE_OK ){\n    rc = pRealVfs->xOpen(pRealVfs, zOpen, pFd->pReal, oflags, pOutFlags);\n  }\n  if( pFd->pReal->pMethods ){\n    /* The xOpen() operation has succeeded. Set the sqlite3_file.pMethods\n    ** pointer and, if the file is a main database file, link it into the\n    ** mutex protected linked list of all such files.  */\n    pFile->pMethods = &rbuvfs_io_methods;\n    if( flags & SQLITE_OPEN_MAIN_DB ){\n      rbuMainlistAdd(pFd);\n    }\n  }else{\n    sqlite3_free(pFd->zDel);\n  }\n\n  return rc;\n}\n\n/*\n** Delete the file located at zPath.\n*/\nstatic int rbuVfsDelete(sqlite3_vfs *pVfs, const char *zPath, int dirSync){\n  sqlite3_vfs *pRealVfs = ((rbu_vfs*)pVfs)->pRealVfs;\n  return pRealVfs->xDelete(pRealVfs, zPath, dirSync);\n}\n\n/*\n** Test for access permissions. Return true if the requested permission\n** is available, or false otherwise.\n*/\nstatic int rbuVfsAccess(\n  sqlite3_vfs *pVfs, \n  const char *zPath, \n  int flags, \n  int *pResOut\n){\n  rbu_vfs *pRbuVfs = (rbu_vfs*)pVfs;\n  sqlite3_vfs *pRealVfs = pRbuVfs->pRealVfs;\n  int rc;\n\n  rc = pRealVfs->xAccess(pRealVfs, zPath, flags, pResOut);\n\n  /* If this call is to check if a *-wal file associated with an RBU target\n  ** database connection exists, and the RBU update is in RBU_STAGE_OAL,\n  ** the following special handling is activated:\n  **\n  **   a) if the *-wal file does exist, return SQLITE_CANTOPEN. This\n  **      ensures that the RBU extension never tries to update a database\n  **      in wal mode, even if the first page of the database file has\n  **      been damaged. \n  **\n  **   b) if the *-wal file does not exist, claim that it does anyway,\n  **      causing SQLite to call xOpen() to open it. This call will also\n  **      be intercepted (see the rbuVfsOpen() function) and the *-oal\n  **      file opened instead.\n  */\n  if( rc==SQLITE_OK && flags==SQLITE_ACCESS_EXISTS ){\n    rbu_file *pDb = rbuFindMaindb(pRbuVfs, zPath, 1);\n    if( pDb && pDb->pRbu && pDb->pRbu->eStage==RBU_STAGE_OAL ){\n      if( *pResOut ){\n        rc = SQLITE_CANTOPEN;\n      }else{\n        sqlite3_int64 sz = 0;\n        rc = rbuVfsFileSize(&pDb->base, &sz);\n        *pResOut = (sz>0);\n      }\n    }\n  }\n\n  return rc;\n}\n\n/*\n** Populate buffer zOut with the full canonical pathname corresponding\n** to the pathname in zPath. zOut is guaranteed to point to a buffer\n** of at least (DEVSYM_MAX_PATHNAME+1) bytes.\n*/\nstatic int rbuVfsFullPathname(\n  sqlite3_vfs *pVfs, \n  const char *zPath, \n  int nOut, \n  char *zOut\n){\n  sqlite3_vfs *pRealVfs = ((rbu_vfs*)pVfs)->pRealVfs;\n  return pRealVfs->xFullPathname(pRealVfs, zPath, nOut, zOut);\n}\n\n#ifndef SQLITE_OMIT_LOAD_EXTENSION\n/*\n** Open the dynamic library located at zPath and return a handle.\n*/\nstatic void *rbuVfsDlOpen(sqlite3_vfs *pVfs, const char *zPath){\n  sqlite3_vfs *pRealVfs = ((rbu_vfs*)pVfs)->pRealVfs;\n  return pRealVfs->xDlOpen(pRealVfs, zPath);\n}\n\n/*\n** Populate the buffer zErrMsg (size nByte bytes) with a human readable\n** utf-8 string describing the most recent error encountered associated \n** with dynamic libraries.\n*/\nstatic void rbuVfsDlError(sqlite3_vfs *pVfs, int nByte, char *zErrMsg){\n  sqlite3_vfs *pRealVfs = ((rbu_vfs*)pVfs)->pRealVfs;\n  pRealVfs->xDlError(pRealVfs, nByte, zErrMsg);\n}\n\n/*\n** Return a pointer to the symbol zSymbol in the dynamic library pHandle.\n*/\nstatic void (*rbuVfsDlSym(\n  sqlite3_vfs *pVfs, \n  void *pArg, \n  const char *zSym\n))(void){\n  sqlite3_vfs *pRealVfs = ((rbu_vfs*)pVfs)->pRealVfs;\n  return pRealVfs->xDlSym(pRealVfs, pArg, zSym);\n}\n\n/*\n** Close the dynamic library handle pHandle.\n*/\nstatic void rbuVfsDlClose(sqlite3_vfs *pVfs, void *pHandle){\n  sqlite3_vfs *pRealVfs = ((rbu_vfs*)pVfs)->pRealVfs;\n  pRealVfs->xDlClose(pRealVfs, pHandle);\n}\n#endif /* SQLITE_OMIT_LOAD_EXTENSION */\n\n/*\n** Populate the buffer pointed to by zBufOut with nByte bytes of \n** random data.\n*/\nstatic int rbuVfsRandomness(sqlite3_vfs *pVfs, int nByte, char *zBufOut){\n  sqlite3_vfs *pRealVfs = ((rbu_vfs*)pVfs)->pRealVfs;\n  return pRealVfs->xRandomness(pRealVfs, nByte, zBufOut);\n}\n\n/*\n** Sleep for nMicro microseconds. Return the number of microseconds \n** actually slept.\n*/\nstatic int rbuVfsSleep(sqlite3_vfs *pVfs, int nMicro){\n  sqlite3_vfs *pRealVfs = ((rbu_vfs*)pVfs)->pRealVfs;\n  return pRealVfs->xSleep(pRealVfs, nMicro);\n}\n\n/*\n** Return the current time as a Julian Day number in *pTimeOut.\n*/\nstatic int rbuVfsCurrentTime(sqlite3_vfs *pVfs, double *pTimeOut){\n  sqlite3_vfs *pRealVfs = ((rbu_vfs*)pVfs)->pRealVfs;\n  return pRealVfs->xCurrentTime(pRealVfs, pTimeOut);\n}\n\n/*\n** No-op.\n*/\nstatic int rbuVfsGetLastError(sqlite3_vfs *pVfs, int a, char *b){\n  return 0;\n}\n\n/*\n** Deregister and destroy an RBU vfs created by an earlier call to\n** sqlite3rbu_create_vfs().\n*/\nSQLITE_API void sqlite3rbu_destroy_vfs(const char *zName){\n  sqlite3_vfs *pVfs = sqlite3_vfs_find(zName);\n  if( pVfs && pVfs->xOpen==rbuVfsOpen ){\n    sqlite3_mutex_free(((rbu_vfs*)pVfs)->mutex);\n    sqlite3_vfs_unregister(pVfs);\n    sqlite3_free(pVfs);\n  }\n}\n\n/*\n** Create an RBU VFS named zName that accesses the underlying file-system\n** via existing VFS zParent. The new object is registered as a non-default\n** VFS with SQLite before returning.\n*/\nSQLITE_API int sqlite3rbu_create_vfs(const char *zName, const char *zParent){\n\n  /* Template for VFS */\n  static sqlite3_vfs vfs_template = {\n    1,                            /* iVersion */\n    0,                            /* szOsFile */\n    0,                            /* mxPathname */\n    0,                            /* pNext */\n    0,                            /* zName */\n    0,                            /* pAppData */\n    rbuVfsOpen,                   /* xOpen */\n    rbuVfsDelete,                 /* xDelete */\n    rbuVfsAccess,                 /* xAccess */\n    rbuVfsFullPathname,           /* xFullPathname */\n\n#ifndef SQLITE_OMIT_LOAD_EXTENSION\n    rbuVfsDlOpen,                 /* xDlOpen */\n    rbuVfsDlError,                /* xDlError */\n    rbuVfsDlSym,                  /* xDlSym */\n    rbuVfsDlClose,                /* xDlClose */\n#else\n    0, 0, 0, 0,\n#endif\n\n    rbuVfsRandomness,             /* xRandomness */\n    rbuVfsSleep,                  /* xSleep */\n    rbuVfsCurrentTime,            /* xCurrentTime */\n    rbuVfsGetLastError,           /* xGetLastError */\n    0,                            /* xCurrentTimeInt64 (version 2) */\n    0, 0, 0                       /* Unimplemented version 3 methods */\n  };\n\n  rbu_vfs *pNew = 0;              /* Newly allocated VFS */\n  int rc = SQLITE_OK;\n  size_t nName;\n  size_t nByte;\n\n  nName = strlen(zName);\n  nByte = sizeof(rbu_vfs) + nName + 1;\n  pNew = (rbu_vfs*)sqlite3_malloc64(nByte);\n  if( pNew==0 ){\n    rc = SQLITE_NOMEM;\n  }else{\n    sqlite3_vfs *pParent;           /* Parent VFS */\n    memset(pNew, 0, nByte);\n    pParent = sqlite3_vfs_find(zParent);\n    if( pParent==0 ){\n      rc = SQLITE_NOTFOUND;\n    }else{\n      char *zSpace;\n      memcpy(&pNew->base, &vfs_template, sizeof(sqlite3_vfs));\n      pNew->base.mxPathname = pParent->mxPathname;\n      pNew->base.szOsFile = sizeof(rbu_file) + pParent->szOsFile;\n      pNew->pRealVfs = pParent;\n      pNew->base.zName = (const char*)(zSpace = (char*)&pNew[1]);\n      memcpy(zSpace, zName, nName);\n\n      /* Allocate the mutex and register the new VFS (not as the default) */\n      pNew->mutex = sqlite3_mutex_alloc(SQLITE_MUTEX_RECURSIVE);\n      if( pNew->mutex==0 ){\n        rc = SQLITE_NOMEM;\n      }else{\n        rc = sqlite3_vfs_register(&pNew->base, 0);\n      }\n    }\n\n    if( rc!=SQLITE_OK ){\n      sqlite3_mutex_free(pNew->mutex);\n      sqlite3_free(pNew);\n    }\n  }\n\n  return rc;\n}\n\n/*\n** Configure the aggregate temp file size limit for this RBU handle.\n*/\nSQLITE_API sqlite3_int64 sqlite3rbu_temp_size_limit(sqlite3rbu *pRbu, sqlite3_int64 n){\n  if( n>=0 ){\n    pRbu->szTempLimit = n;\n  }\n  return pRbu->szTempLimit;\n}\n\nSQLITE_API sqlite3_int64 sqlite3rbu_temp_size(sqlite3rbu *pRbu){\n  return pRbu->szTemp;\n}\n\n\n/**************************************************************************/\n\n#endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_RBU) */\n\n/************** End of sqlite3rbu.c ******************************************/\n/************** Begin file dbstat.c ******************************************/\n/*\n** 2010 July 12\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n******************************************************************************\n**\n** This file contains an implementation of the \"dbstat\" virtual table.\n**\n** The dbstat virtual table is used to extract low-level formatting\n** information from an SQLite database in order to implement the\n** \"sqlite3_analyzer\" utility.  See the ../tool/spaceanal.tcl script\n** for an example implementation.\n**\n** Additional information is available on the \"dbstat.html\" page of the\n** official SQLite documentation.\n*/\n\n/* #include \"sqliteInt.h\"   ** Requires access to internal data structures ** */\n#if (defined(SQLITE_ENABLE_DBSTAT_VTAB) || defined(SQLITE_TEST)) \\\n    && !defined(SQLITE_OMIT_VIRTUALTABLE)\n\n/*\n** Page paths:\n** \n**   The value of the 'path' column describes the path taken from the \n**   root-node of the b-tree structure to each page. The value of the \n**   root-node path is '/'.\n**\n**   The value of the path for the left-most child page of the root of\n**   a b-tree is '/000/'. (Btrees store content ordered from left to right\n**   so the pages to the left have smaller keys than the pages to the right.)\n**   The next to left-most child of the root page is\n**   '/001', and so on, each sibling page identified by a 3-digit hex \n**   value. The children of the 451st left-most sibling have paths such\n**   as '/1c2/000/, '/1c2/001/' etc.\n**\n**   Overflow pages are specified by appending a '+' character and a \n**   six-digit hexadecimal value to the path to the cell they are linked\n**   from. For example, the three overflow pages in a chain linked from \n**   the left-most cell of the 450th child of the root page are identified\n**   by the paths:\n**\n**      '/1c2/000+000000'         // First page in overflow chain\n**      '/1c2/000+000001'         // Second page in overflow chain\n**      '/1c2/000+000002'         // Third page in overflow chain\n**\n**   If the paths are sorted using the BINARY collation sequence, then\n**   the overflow pages associated with a cell will appear earlier in the\n**   sort-order than its child page:\n**\n**      '/1c2/000/'               // Left-most child of 451st child of root\n*/\n#define VTAB_SCHEMA                                                         \\\n  \"CREATE TABLE xx( \"                                                       \\\n  \"  name       TEXT,             /* Name of table or index */\"             \\\n  \"  path       TEXT,             /* Path to page from root */\"             \\\n  \"  pageno     INTEGER,          /* Page number */\"                        \\\n  \"  pagetype   TEXT,             /* 'internal', 'leaf' or 'overflow' */\"   \\\n  \"  ncell      INTEGER,          /* Cells on page (0 for overflow) */\"     \\\n  \"  payload    INTEGER,          /* Bytes of payload on this page */\"      \\\n  \"  unused     INTEGER,          /* Bytes of unused space on this page */\" \\\n  \"  mx_payload INTEGER,          /* Largest payload size of all cells */\"  \\\n  \"  pgoffset   INTEGER,          /* Offset of page in file */\"             \\\n  \"  pgsize     INTEGER,          /* Size of the page */\"                   \\\n  \"  schema     TEXT HIDDEN       /* Database schema being analyzed */\"     \\\n  \");\"\n\n\ntypedef struct StatTable StatTable;\ntypedef struct StatCursor StatCursor;\ntypedef struct StatPage StatPage;\ntypedef struct StatCell StatCell;\n\nstruct StatCell {\n  int nLocal;                     /* Bytes of local payload */\n  u32 iChildPg;                   /* Child node (or 0 if this is a leaf) */\n  int nOvfl;                      /* Entries in aOvfl[] */\n  u32 *aOvfl;                     /* Array of overflow page numbers */\n  int nLastOvfl;                  /* Bytes of payload on final overflow page */\n  int iOvfl;                      /* Iterates through aOvfl[] */\n};\n\nstruct StatPage {\n  u32 iPgno;\n  DbPage *pPg;\n  int iCell;\n\n  char *zPath;                    /* Path to this page */\n\n  /* Variables populated by statDecodePage(): */\n  u8 flags;                       /* Copy of flags byte */\n  int nCell;                      /* Number of cells on page */\n  int nUnused;                    /* Number of unused bytes on page */\n  StatCell *aCell;                /* Array of parsed cells */\n  u32 iRightChildPg;              /* Right-child page number (or 0) */\n  int nMxPayload;                 /* Largest payload of any cell on this page */\n};\n\nstruct StatCursor {\n  sqlite3_vtab_cursor base;\n  sqlite3_stmt *pStmt;            /* Iterates through set of root pages */\n  int isEof;                      /* After pStmt has returned SQLITE_DONE */\n  int iDb;                        /* Schema used for this query */\n\n  StatPage aPage[32];\n  int iPage;                      /* Current entry in aPage[] */\n\n  /* Values to return. */\n  char *zName;                    /* Value of 'name' column */\n  char *zPath;                    /* Value of 'path' column */\n  u32 iPageno;                    /* Value of 'pageno' column */\n  char *zPagetype;                /* Value of 'pagetype' column */\n  int nCell;                      /* Value of 'ncell' column */\n  int nPayload;                   /* Value of 'payload' column */\n  int nUnused;                    /* Value of 'unused' column */\n  int nMxPayload;                 /* Value of 'mx_payload' column */\n  i64 iOffset;                    /* Value of 'pgOffset' column */\n  int szPage;                     /* Value of 'pgSize' column */\n};\n\nstruct StatTable {\n  sqlite3_vtab base;\n  sqlite3 *db;\n  int iDb;                        /* Index of database to analyze */\n};\n\n#ifndef get2byte\n# define get2byte(x)   ((x)[0]<<8 | (x)[1])\n#endif\n\n/*\n** Connect to or create a statvfs virtual table.\n*/\nstatic int statConnect(\n  sqlite3 *db,\n  void *pAux,\n  int argc, const char *const*argv,\n  sqlite3_vtab **ppVtab,\n  char **pzErr\n){\n  StatTable *pTab = 0;\n  int rc = SQLITE_OK;\n  int iDb;\n\n  if( argc>=4 ){\n    Token nm;\n    sqlite3TokenInit(&nm, (char*)argv[3]);\n    iDb = sqlite3FindDb(db, &nm);\n    if( iDb<0 ){\n      *pzErr = sqlite3_mprintf(\"no such database: %s\", argv[3]);\n      return SQLITE_ERROR;\n    }\n  }else{\n    iDb = 0;\n  }\n  rc = sqlite3_declare_vtab(db, VTAB_SCHEMA);\n  if( rc==SQLITE_OK ){\n    pTab = (StatTable *)sqlite3_malloc64(sizeof(StatTable));\n    if( pTab==0 ) rc = SQLITE_NOMEM_BKPT;\n  }\n\n  assert( rc==SQLITE_OK || pTab==0 );\n  if( rc==SQLITE_OK ){\n    memset(pTab, 0, sizeof(StatTable));\n    pTab->db = db;\n    pTab->iDb = iDb;\n  }\n\n  *ppVtab = (sqlite3_vtab*)pTab;\n  return rc;\n}\n\n/*\n** Disconnect from or destroy a statvfs virtual table.\n*/\nstatic int statDisconnect(sqlite3_vtab *pVtab){\n  sqlite3_free(pVtab);\n  return SQLITE_OK;\n}\n\n/*\n** There is no \"best-index\". This virtual table always does a linear\n** scan.  However, a schema=? constraint should cause this table to\n** operate on a different database schema, so check for it.\n**\n** idxNum is normally 0, but will be 1 if a schema=? constraint exists.\n*/\nstatic int statBestIndex(sqlite3_vtab *tab, sqlite3_index_info *pIdxInfo){\n  int i;\n\n  /* Look for a valid schema=? constraint.  If found, change the idxNum to\n  ** 1 and request the value of that constraint be sent to xFilter.  And\n  ** lower the cost estimate to encourage the constrained version to be\n  ** used.\n  */\n  for(i=0; i<pIdxInfo->nConstraint; i++){\n    if( pIdxInfo->aConstraint[i].iColumn!=10 ) continue;\n    if( pIdxInfo->aConstraint[i].usable==0 ) return SQLITE_CONSTRAINT;\n    if( pIdxInfo->aConstraint[i].op!=SQLITE_INDEX_CONSTRAINT_EQ ) continue;\n    pIdxInfo->idxNum = 1;\n    pIdxInfo->estimatedCost = 1.0;\n    pIdxInfo->aConstraintUsage[i].argvIndex = 1;\n    pIdxInfo->aConstraintUsage[i].omit = 1;\n    break;\n  }\n\n\n  /* Records are always returned in ascending order of (name, path). \n  ** If this will satisfy the client, set the orderByConsumed flag so that \n  ** SQLite does not do an external sort.\n  */\n  if( ( pIdxInfo->nOrderBy==1\n     && pIdxInfo->aOrderBy[0].iColumn==0\n     && pIdxInfo->aOrderBy[0].desc==0\n     ) ||\n      ( pIdxInfo->nOrderBy==2\n     && pIdxInfo->aOrderBy[0].iColumn==0\n     && pIdxInfo->aOrderBy[0].desc==0\n     && pIdxInfo->aOrderBy[1].iColumn==1\n     && pIdxInfo->aOrderBy[1].desc==0\n     )\n  ){\n    pIdxInfo->orderByConsumed = 1;\n  }\n\n  return SQLITE_OK;\n}\n\n/*\n** Open a new statvfs cursor.\n*/\nstatic int statOpen(sqlite3_vtab *pVTab, sqlite3_vtab_cursor **ppCursor){\n  StatTable *pTab = (StatTable *)pVTab;\n  StatCursor *pCsr;\n\n  pCsr = (StatCursor *)sqlite3_malloc64(sizeof(StatCursor));\n  if( pCsr==0 ){\n    return SQLITE_NOMEM_BKPT;\n  }else{\n    memset(pCsr, 0, sizeof(StatCursor));\n    pCsr->base.pVtab = pVTab;\n    pCsr->iDb = pTab->iDb;\n  }\n\n  *ppCursor = (sqlite3_vtab_cursor *)pCsr;\n  return SQLITE_OK;\n}\n\nstatic void statClearCells(StatPage *p){\n  int i;\n  if( p->aCell ){\n    for(i=0; i<p->nCell; i++){\n      sqlite3_free(p->aCell[i].aOvfl);\n    }\n    sqlite3_free(p->aCell);\n  }\n  p->nCell = 0;\n  p->aCell = 0;\n}\n\nstatic void statClearPage(StatPage *p){\n  statClearCells(p);\n  sqlite3PagerUnref(p->pPg);\n  sqlite3_free(p->zPath);\n  memset(p, 0, sizeof(StatPage));\n}\n\nstatic void statResetCsr(StatCursor *pCsr){\n  int i;\n  sqlite3_reset(pCsr->pStmt);\n  for(i=0; i<ArraySize(pCsr->aPage); i++){\n    statClearPage(&pCsr->aPage[i]);\n  }\n  pCsr->iPage = 0;\n  sqlite3_free(pCsr->zPath);\n  pCsr->zPath = 0;\n  pCsr->isEof = 0;\n}\n\n/*\n** Close a statvfs cursor.\n*/\nstatic int statClose(sqlite3_vtab_cursor *pCursor){\n  StatCursor *pCsr = (StatCursor *)pCursor;\n  statResetCsr(pCsr);\n  sqlite3_finalize(pCsr->pStmt);\n  sqlite3_free(pCsr);\n  return SQLITE_OK;\n}\n\nstatic void getLocalPayload(\n  int nUsable,                    /* Usable bytes per page */\n  u8 flags,                       /* Page flags */\n  int nTotal,                     /* Total record (payload) size */\n  int *pnLocal                    /* OUT: Bytes stored locally */\n){\n  int nLocal;\n  int nMinLocal;\n  int nMaxLocal;\n \n  if( flags==0x0D ){              /* Table leaf node */\n    nMinLocal = (nUsable - 12) * 32 / 255 - 23;\n    nMaxLocal = nUsable - 35;\n  }else{                          /* Index interior and leaf nodes */\n    nMinLocal = (nUsable - 12) * 32 / 255 - 23;\n    nMaxLocal = (nUsable - 12) * 64 / 255 - 23;\n  }\n\n  nLocal = nMinLocal + (nTotal - nMinLocal) % (nUsable - 4);\n  if( nLocal>nMaxLocal ) nLocal = nMinLocal;\n  *pnLocal = nLocal;\n}\n\nstatic int statDecodePage(Btree *pBt, StatPage *p){\n  int nUnused;\n  int iOff;\n  int nHdr;\n  int isLeaf;\n  int szPage;\n\n  u8 *aData = sqlite3PagerGetData(p->pPg);\n  u8 *aHdr = &aData[p->iPgno==1 ? 100 : 0];\n\n  p->flags = aHdr[0];\n  if( p->flags==0x0A || p->flags==0x0D ){\n    isLeaf = 1;\n    nHdr = 8;\n  }else if( p->flags==0x05 || p->flags==0x02 ){\n    isLeaf = 0;\n    nHdr = 12;\n  }else{\n    goto statPageIsCorrupt;\n  }\n  if( p->iPgno==1 ) nHdr += 100;\n  p->nCell = get2byte(&aHdr[3]);\n  p->nMxPayload = 0;\n  szPage = sqlite3BtreeGetPageSize(pBt);\n\n  nUnused = get2byte(&aHdr[5]) - nHdr - 2*p->nCell;\n  nUnused += (int)aHdr[7];\n  iOff = get2byte(&aHdr[1]);\n  while( iOff ){\n    int iNext;\n    if( iOff>=szPage ) goto statPageIsCorrupt;\n    nUnused += get2byte(&aData[iOff+2]);\n    iNext = get2byte(&aData[iOff]);\n    if( iNext<iOff+4 && iNext>0 ) goto statPageIsCorrupt;\n    iOff = iNext;\n  }\n  p->nUnused = nUnused;\n  p->iRightChildPg = isLeaf ? 0 : sqlite3Get4byte(&aHdr[8]);\n\n  if( p->nCell ){\n    int i;                        /* Used to iterate through cells */\n    int nUsable;                  /* Usable bytes per page */\n\n    sqlite3BtreeEnter(pBt);\n    nUsable = szPage - sqlite3BtreeGetReserveNoMutex(pBt);\n    sqlite3BtreeLeave(pBt);\n    p->aCell = sqlite3_malloc64((p->nCell+1) * sizeof(StatCell));\n    if( p->aCell==0 ) return SQLITE_NOMEM_BKPT;\n    memset(p->aCell, 0, (p->nCell+1) * sizeof(StatCell));\n\n    for(i=0; i<p->nCell; i++){\n      StatCell *pCell = &p->aCell[i];\n\n      iOff = get2byte(&aData[nHdr+i*2]);\n      if( iOff<nHdr || iOff>=szPage ) goto statPageIsCorrupt;\n      if( !isLeaf ){\n        pCell->iChildPg = sqlite3Get4byte(&aData[iOff]);\n        iOff += 4;\n      }\n      if( p->flags==0x05 ){\n        /* A table interior node. nPayload==0. */\n      }else{\n        u32 nPayload;             /* Bytes of payload total (local+overflow) */\n        int nLocal;               /* Bytes of payload stored locally */\n        iOff += getVarint32(&aData[iOff], nPayload);\n        if( p->flags==0x0D ){\n          u64 dummy;\n          iOff += sqlite3GetVarint(&aData[iOff], &dummy);\n        }\n        if( nPayload>(u32)p->nMxPayload ) p->nMxPayload = nPayload;\n        getLocalPayload(nUsable, p->flags, nPayload, &nLocal);\n        if( nLocal<0 ) goto statPageIsCorrupt;\n        pCell->nLocal = nLocal;\n        assert( nPayload>=(u32)nLocal );\n        assert( nLocal<=(nUsable-35) );\n        if( nPayload>(u32)nLocal ){\n          int j;\n          int nOvfl = ((nPayload - nLocal) + nUsable-4 - 1) / (nUsable - 4);\n          if( iOff+nLocal>nUsable ) goto statPageIsCorrupt;\n          pCell->nLastOvfl = (nPayload-nLocal) - (nOvfl-1) * (nUsable-4);\n          pCell->nOvfl = nOvfl;\n          pCell->aOvfl = sqlite3_malloc64(sizeof(u32)*nOvfl);\n          if( pCell->aOvfl==0 ) return SQLITE_NOMEM_BKPT;\n          pCell->aOvfl[0] = sqlite3Get4byte(&aData[iOff+nLocal]);\n          for(j=1; j<nOvfl; j++){\n            int rc;\n            u32 iPrev = pCell->aOvfl[j-1];\n            DbPage *pPg = 0;\n            rc = sqlite3PagerGet(sqlite3BtreePager(pBt), iPrev, &pPg, 0);\n            if( rc!=SQLITE_OK ){\n              assert( pPg==0 );\n              return rc;\n            } \n            pCell->aOvfl[j] = sqlite3Get4byte(sqlite3PagerGetData(pPg));\n            sqlite3PagerUnref(pPg);\n          }\n        }\n      }\n    }\n  }\n\n  return SQLITE_OK;\n\nstatPageIsCorrupt:\n  p->flags = 0;\n  statClearCells(p);\n  return SQLITE_OK;\n}\n\n/*\n** Populate the pCsr->iOffset and pCsr->szPage member variables. Based on\n** the current value of pCsr->iPageno.\n*/\nstatic void statSizeAndOffset(StatCursor *pCsr){\n  StatTable *pTab = (StatTable *)((sqlite3_vtab_cursor *)pCsr)->pVtab;\n  Btree *pBt = pTab->db->aDb[pTab->iDb].pBt;\n  Pager *pPager = sqlite3BtreePager(pBt);\n  sqlite3_file *fd;\n  sqlite3_int64 x[2];\n\n  /* The default page size and offset */\n  pCsr->szPage = sqlite3BtreeGetPageSize(pBt);\n  pCsr->iOffset = (i64)pCsr->szPage * (pCsr->iPageno - 1);\n\n  /* If connected to a ZIPVFS backend, override the page size and\n  ** offset with actual values obtained from ZIPVFS.\n  */\n  fd = sqlite3PagerFile(pPager);\n  x[0] = pCsr->iPageno;\n  if( sqlite3OsFileControl(fd, 230440, &x)==SQLITE_OK ){\n    pCsr->iOffset = x[0];\n    pCsr->szPage = (int)x[1];\n  }\n}\n\n/*\n** Move a statvfs cursor to the next entry in the file.\n*/\nstatic int statNext(sqlite3_vtab_cursor *pCursor){\n  int rc;\n  int nPayload;\n  char *z;\n  StatCursor *pCsr = (StatCursor *)pCursor;\n  StatTable *pTab = (StatTable *)pCursor->pVtab;\n  Btree *pBt = pTab->db->aDb[pCsr->iDb].pBt;\n  Pager *pPager = sqlite3BtreePager(pBt);\n\n  sqlite3_free(pCsr->zPath);\n  pCsr->zPath = 0;\n\nstatNextRestart:\n  if( pCsr->aPage[0].pPg==0 ){\n    rc = sqlite3_step(pCsr->pStmt);\n    if( rc==SQLITE_ROW ){\n      int nPage;\n      u32 iRoot = (u32)sqlite3_column_int64(pCsr->pStmt, 1);\n      sqlite3PagerPagecount(pPager, &nPage);\n      if( nPage==0 ){\n        pCsr->isEof = 1;\n        return sqlite3_reset(pCsr->pStmt);\n      }\n      rc = sqlite3PagerGet(pPager, iRoot, &pCsr->aPage[0].pPg, 0);\n      pCsr->aPage[0].iPgno = iRoot;\n      pCsr->aPage[0].iCell = 0;\n      pCsr->aPage[0].zPath = z = sqlite3_mprintf(\"/\");\n      pCsr->iPage = 0;\n      if( z==0 ) rc = SQLITE_NOMEM_BKPT;\n    }else{\n      pCsr->isEof = 1;\n      return sqlite3_reset(pCsr->pStmt);\n    }\n  }else{\n\n    /* Page p itself has already been visited. */\n    StatPage *p = &pCsr->aPage[pCsr->iPage];\n\n    while( p->iCell<p->nCell ){\n      StatCell *pCell = &p->aCell[p->iCell];\n      if( pCell->iOvfl<pCell->nOvfl ){\n        int nUsable;\n        sqlite3BtreeEnter(pBt);\n        nUsable = sqlite3BtreeGetPageSize(pBt) - \n                        sqlite3BtreeGetReserveNoMutex(pBt);\n        sqlite3BtreeLeave(pBt);\n        pCsr->zName = (char *)sqlite3_column_text(pCsr->pStmt, 0);\n        pCsr->iPageno = pCell->aOvfl[pCell->iOvfl];\n        pCsr->zPagetype = \"overflow\";\n        pCsr->nCell = 0;\n        pCsr->nMxPayload = 0;\n        pCsr->zPath = z = sqlite3_mprintf(\n            \"%s%.3x+%.6x\", p->zPath, p->iCell, pCell->iOvfl\n        );\n        if( pCell->iOvfl<pCell->nOvfl-1 ){\n          pCsr->nUnused = 0;\n          pCsr->nPayload = nUsable - 4;\n        }else{\n          pCsr->nPayload = pCell->nLastOvfl;\n          pCsr->nUnused = nUsable - 4 - pCsr->nPayload;\n        }\n        pCell->iOvfl++;\n        statSizeAndOffset(pCsr);\n        return z==0 ? SQLITE_NOMEM_BKPT : SQLITE_OK;\n      }\n      if( p->iRightChildPg ) break;\n      p->iCell++;\n    }\n\n    if( !p->iRightChildPg || p->iCell>p->nCell ){\n      statClearPage(p);\n      if( pCsr->iPage==0 ) return statNext(pCursor);\n      pCsr->iPage--;\n      goto statNextRestart; /* Tail recursion */\n    }\n    pCsr->iPage++;\n    if( pCsr->iPage>=ArraySize(pCsr->aPage) ){\n      statResetCsr(pCsr);\n      return SQLITE_CORRUPT_BKPT;\n    }\n    assert( p==&pCsr->aPage[pCsr->iPage-1] );\n\n    if( p->iCell==p->nCell ){\n      p[1].iPgno = p->iRightChildPg;\n    }else{\n      p[1].iPgno = p->aCell[p->iCell].iChildPg;\n    }\n    rc = sqlite3PagerGet(pPager, p[1].iPgno, &p[1].pPg, 0);\n    p[1].iCell = 0;\n    p[1].zPath = z = sqlite3_mprintf(\"%s%.3x/\", p->zPath, p->iCell);\n    p->iCell++;\n    if( z==0 ) rc = SQLITE_NOMEM_BKPT;\n  }\n\n\n  /* Populate the StatCursor fields with the values to be returned\n  ** by the xColumn() and xRowid() methods.\n  */\n  if( rc==SQLITE_OK ){\n    int i;\n    StatPage *p = &pCsr->aPage[pCsr->iPage];\n    pCsr->zName = (char *)sqlite3_column_text(pCsr->pStmt, 0);\n    pCsr->iPageno = p->iPgno;\n\n    rc = statDecodePage(pBt, p);\n    if( rc==SQLITE_OK ){\n      statSizeAndOffset(pCsr);\n\n      switch( p->flags ){\n        case 0x05:             /* table internal */\n        case 0x02:             /* index internal */\n          pCsr->zPagetype = \"internal\";\n          break;\n        case 0x0D:             /* table leaf */\n        case 0x0A:             /* index leaf */\n          pCsr->zPagetype = \"leaf\";\n          break;\n        default:\n          pCsr->zPagetype = \"corrupted\";\n          break;\n      }\n      pCsr->nCell = p->nCell;\n      pCsr->nUnused = p->nUnused;\n      pCsr->nMxPayload = p->nMxPayload;\n      pCsr->zPath = z = sqlite3_mprintf(\"%s\", p->zPath);\n      if( z==0 ) rc = SQLITE_NOMEM_BKPT;\n      nPayload = 0;\n      for(i=0; i<p->nCell; i++){\n        nPayload += p->aCell[i].nLocal;\n      }\n      pCsr->nPayload = nPayload;\n    }\n  }\n\n  return rc;\n}\n\nstatic int statEof(sqlite3_vtab_cursor *pCursor){\n  StatCursor *pCsr = (StatCursor *)pCursor;\n  return pCsr->isEof;\n}\n\nstatic int statFilter(\n  sqlite3_vtab_cursor *pCursor, \n  int idxNum, const char *idxStr,\n  int argc, sqlite3_value **argv\n){\n  StatCursor *pCsr = (StatCursor *)pCursor;\n  StatTable *pTab = (StatTable*)(pCursor->pVtab);\n  char *zSql;\n  int rc = SQLITE_OK;\n\n  if( idxNum==1 ){\n    const char *zDbase = (const char*)sqlite3_value_text(argv[0]);\n    pCsr->iDb = sqlite3FindDbName(pTab->db, zDbase);\n    if( pCsr->iDb<0 ){\n      sqlite3_free(pCursor->pVtab->zErrMsg);\n      pCursor->pVtab->zErrMsg = sqlite3_mprintf(\"no such schema: %s\", zDbase);\n      return pCursor->pVtab->zErrMsg ? SQLITE_ERROR : SQLITE_NOMEM_BKPT;\n    }\n  }else{\n    pCsr->iDb = pTab->iDb;\n  }\n  statResetCsr(pCsr);\n  sqlite3_finalize(pCsr->pStmt);\n  pCsr->pStmt = 0;\n  zSql = sqlite3_mprintf(\n      \"SELECT 'sqlite_master' AS name, 1 AS rootpage, 'table' AS type\"\n      \"  UNION ALL  \"\n      \"SELECT name, rootpage, type\"\n      \"  FROM \\\"%w\\\".sqlite_master WHERE rootpage!=0\"\n      \"  ORDER BY name\", pTab->db->aDb[pCsr->iDb].zDbSName);\n  if( zSql==0 ){\n    return SQLITE_NOMEM_BKPT;\n  }else{\n    rc = sqlite3_prepare_v2(pTab->db, zSql, -1, &pCsr->pStmt, 0);\n    sqlite3_free(zSql);\n  }\n\n  if( rc==SQLITE_OK ){\n    rc = statNext(pCursor);\n  }\n  return rc;\n}\n\nstatic int statColumn(\n  sqlite3_vtab_cursor *pCursor, \n  sqlite3_context *ctx, \n  int i\n){\n  StatCursor *pCsr = (StatCursor *)pCursor;\n  switch( i ){\n    case 0:            /* name */\n      sqlite3_result_text(ctx, pCsr->zName, -1, SQLITE_TRANSIENT);\n      break;\n    case 1:            /* path */\n      sqlite3_result_text(ctx, pCsr->zPath, -1, SQLITE_TRANSIENT);\n      break;\n    case 2:            /* pageno */\n      sqlite3_result_int64(ctx, pCsr->iPageno);\n      break;\n    case 3:            /* pagetype */\n      sqlite3_result_text(ctx, pCsr->zPagetype, -1, SQLITE_STATIC);\n      break;\n    case 4:            /* ncell */\n      sqlite3_result_int(ctx, pCsr->nCell);\n      break;\n    case 5:            /* payload */\n      sqlite3_result_int(ctx, pCsr->nPayload);\n      break;\n    case 6:            /* unused */\n      sqlite3_result_int(ctx, pCsr->nUnused);\n      break;\n    case 7:            /* mx_payload */\n      sqlite3_result_int(ctx, pCsr->nMxPayload);\n      break;\n    case 8:            /* pgoffset */\n      sqlite3_result_int64(ctx, pCsr->iOffset);\n      break;\n    case 9:            /* pgsize */\n      sqlite3_result_int(ctx, pCsr->szPage);\n      break;\n    default: {          /* schema */\n      sqlite3 *db = sqlite3_context_db_handle(ctx);\n      int iDb = pCsr->iDb;\n      sqlite3_result_text(ctx, db->aDb[iDb].zDbSName, -1, SQLITE_STATIC);\n      break;\n    }\n  }\n  return SQLITE_OK;\n}\n\nstatic int statRowid(sqlite3_vtab_cursor *pCursor, sqlite_int64 *pRowid){\n  StatCursor *pCsr = (StatCursor *)pCursor;\n  *pRowid = pCsr->iPageno;\n  return SQLITE_OK;\n}\n\n/*\n** Invoke this routine to register the \"dbstat\" virtual table module\n*/\nSQLITE_PRIVATE int sqlite3DbstatRegister(sqlite3 *db){\n  static sqlite3_module dbstat_module = {\n    0,                            /* iVersion */\n    statConnect,                  /* xCreate */\n    statConnect,                  /* xConnect */\n    statBestIndex,                /* xBestIndex */\n    statDisconnect,               /* xDisconnect */\n    statDisconnect,               /* xDestroy */\n    statOpen,                     /* xOpen - open a cursor */\n    statClose,                    /* xClose - close a cursor */\n    statFilter,                   /* xFilter - configure scan constraints */\n    statNext,                     /* xNext - advance a cursor */\n    statEof,                      /* xEof - check for end of scan */\n    statColumn,                   /* xColumn - read data */\n    statRowid,                    /* xRowid - read data */\n    0,                            /* xUpdate */\n    0,                            /* xBegin */\n    0,                            /* xSync */\n    0,                            /* xCommit */\n    0,                            /* xRollback */\n    0,                            /* xFindMethod */\n    0,                            /* xRename */\n    0,                            /* xSavepoint */\n    0,                            /* xRelease */\n    0,                            /* xRollbackTo */\n    0                             /* xShadowName */\n  };\n  return sqlite3_create_module(db, \"dbstat\", &dbstat_module, 0);\n}\n#elif defined(SQLITE_ENABLE_DBSTAT_VTAB)\nSQLITE_PRIVATE int sqlite3DbstatRegister(sqlite3 *db){ return SQLITE_OK; }\n#endif /* SQLITE_ENABLE_DBSTAT_VTAB */\n\n/************** End of dbstat.c **********************************************/\n/************** Begin file dbpage.c ******************************************/\n/*\n** 2017-10-11\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n******************************************************************************\n**\n** This file contains an implementation of the \"sqlite_dbpage\" virtual table.\n**\n** The sqlite_dbpage virtual table is used to read or write whole raw\n** pages of the database file.  The pager interface is used so that \n** uncommitted changes and changes recorded in the WAL file are correctly\n** retrieved.\n**\n** Usage example:\n**\n**    SELECT data FROM sqlite_dbpage('aux1') WHERE pgno=123;\n**\n** This is an eponymous virtual table so it does not need to be created before\n** use.  The optional argument to the sqlite_dbpage() table name is the\n** schema for the database file that is to be read.  The default schema is\n** \"main\".\n**\n** The data field of sqlite_dbpage table can be updated.  The new\n** value must be a BLOB which is the correct page size, otherwise the\n** update fails.  Rows may not be deleted or inserted.\n*/\n\n/* #include \"sqliteInt.h\"   ** Requires access to internal data structures ** */\n#if (defined(SQLITE_ENABLE_DBPAGE_VTAB) || defined(SQLITE_TEST)) \\\n    && !defined(SQLITE_OMIT_VIRTUALTABLE)\n\ntypedef struct DbpageTable DbpageTable;\ntypedef struct DbpageCursor DbpageCursor;\n\nstruct DbpageCursor {\n  sqlite3_vtab_cursor base;       /* Base class.  Must be first */\n  int pgno;                       /* Current page number */\n  int mxPgno;                     /* Last page to visit on this scan */\n  Pager *pPager;                  /* Pager being read/written */\n  DbPage *pPage1;                 /* Page 1 of the database */\n  int iDb;                        /* Index of database to analyze */\n  int szPage;                     /* Size of each page in bytes */\n};\n\nstruct DbpageTable {\n  sqlite3_vtab base;              /* Base class.  Must be first */\n  sqlite3 *db;                    /* The database */\n};\n\n/* Columns */\n#define DBPAGE_COLUMN_PGNO    0\n#define DBPAGE_COLUMN_DATA    1\n#define DBPAGE_COLUMN_SCHEMA  2\n\n\n\n/*\n** Connect to or create a dbpagevfs virtual table.\n*/\nstatic int dbpageConnect(\n  sqlite3 *db,\n  void *pAux,\n  int argc, const char *const*argv,\n  sqlite3_vtab **ppVtab,\n  char **pzErr\n){\n  DbpageTable *pTab = 0;\n  int rc = SQLITE_OK;\n\n  rc = sqlite3_declare_vtab(db, \n          \"CREATE TABLE x(pgno INTEGER PRIMARY KEY, data BLOB, schema HIDDEN)\");\n  if( rc==SQLITE_OK ){\n    pTab = (DbpageTable *)sqlite3_malloc64(sizeof(DbpageTable));\n    if( pTab==0 ) rc = SQLITE_NOMEM_BKPT;\n  }\n\n  assert( rc==SQLITE_OK || pTab==0 );\n  if( rc==SQLITE_OK ){\n    memset(pTab, 0, sizeof(DbpageTable));\n    pTab->db = db;\n  }\n\n  *ppVtab = (sqlite3_vtab*)pTab;\n  return rc;\n}\n\n/*\n** Disconnect from or destroy a dbpagevfs virtual table.\n*/\nstatic int dbpageDisconnect(sqlite3_vtab *pVtab){\n  sqlite3_free(pVtab);\n  return SQLITE_OK;\n}\n\n/*\n** idxNum:\n**\n**     0     schema=main, full table scan\n**     1     schema=main, pgno=?1\n**     2     schema=?1, full table scan\n**     3     schema=?1, pgno=?2\n*/\nstatic int dbpageBestIndex(sqlite3_vtab *tab, sqlite3_index_info *pIdxInfo){\n  int i;\n  int iPlan = 0;\n\n  /* If there is a schema= constraint, it must be honored.  Report a\n  ** ridiculously large estimated cost if the schema= constraint is\n  ** unavailable\n  */\n  for(i=0; i<pIdxInfo->nConstraint; i++){\n    struct sqlite3_index_constraint *p = &pIdxInfo->aConstraint[i];\n    if( p->iColumn!=DBPAGE_COLUMN_SCHEMA ) continue;\n    if( p->op!=SQLITE_INDEX_CONSTRAINT_EQ ) continue;\n    if( !p->usable ){\n      /* No solution. */\n      return SQLITE_CONSTRAINT;\n    }\n    iPlan = 2;\n    pIdxInfo->aConstraintUsage[i].argvIndex = 1;\n    pIdxInfo->aConstraintUsage[i].omit = 1;\n    break;\n  }\n\n  /* If we reach this point, it means that either there is no schema=\n  ** constraint (in which case we use the \"main\" schema) or else the\n  ** schema constraint was accepted.  Lower the estimated cost accordingly\n  */\n  pIdxInfo->estimatedCost = 1.0e6;\n\n  /* Check for constraints against pgno */\n  for(i=0; i<pIdxInfo->nConstraint; i++){\n    struct sqlite3_index_constraint *p = &pIdxInfo->aConstraint[i];\n    if( p->usable && p->iColumn<=0 && p->op==SQLITE_INDEX_CONSTRAINT_EQ ){\n      pIdxInfo->estimatedRows = 1;\n      pIdxInfo->idxFlags = SQLITE_INDEX_SCAN_UNIQUE;\n      pIdxInfo->estimatedCost = 1.0;\n      pIdxInfo->aConstraintUsage[i].argvIndex = iPlan ? 2 : 1;\n      pIdxInfo->aConstraintUsage[i].omit = 1;\n      iPlan |= 1;\n      break;\n    }\n  }\n  pIdxInfo->idxNum = iPlan;\n\n  if( pIdxInfo->nOrderBy>=1\n   && pIdxInfo->aOrderBy[0].iColumn<=0\n   && pIdxInfo->aOrderBy[0].desc==0\n  ){\n    pIdxInfo->orderByConsumed = 1;\n  }\n  return SQLITE_OK;\n}\n\n/*\n** Open a new dbpagevfs cursor.\n*/\nstatic int dbpageOpen(sqlite3_vtab *pVTab, sqlite3_vtab_cursor **ppCursor){\n  DbpageCursor *pCsr;\n\n  pCsr = (DbpageCursor *)sqlite3_malloc64(sizeof(DbpageCursor));\n  if( pCsr==0 ){\n    return SQLITE_NOMEM_BKPT;\n  }else{\n    memset(pCsr, 0, sizeof(DbpageCursor));\n    pCsr->base.pVtab = pVTab;\n    pCsr->pgno = -1;\n  }\n\n  *ppCursor = (sqlite3_vtab_cursor *)pCsr;\n  return SQLITE_OK;\n}\n\n/*\n** Close a dbpagevfs cursor.\n*/\nstatic int dbpageClose(sqlite3_vtab_cursor *pCursor){\n  DbpageCursor *pCsr = (DbpageCursor *)pCursor;\n  if( pCsr->pPage1 ) sqlite3PagerUnrefPageOne(pCsr->pPage1);\n  sqlite3_free(pCsr);\n  return SQLITE_OK;\n}\n\n/*\n** Move a dbpagevfs cursor to the next entry in the file.\n*/\nstatic int dbpageNext(sqlite3_vtab_cursor *pCursor){\n  int rc = SQLITE_OK;\n  DbpageCursor *pCsr = (DbpageCursor *)pCursor;\n  pCsr->pgno++;\n  return rc;\n}\n\nstatic int dbpageEof(sqlite3_vtab_cursor *pCursor){\n  DbpageCursor *pCsr = (DbpageCursor *)pCursor;\n  return pCsr->pgno > pCsr->mxPgno;\n}\n\n/*\n** idxNum:\n**\n**     0     schema=main, full table scan\n**     1     schema=main, pgno=?1\n**     2     schema=?1, full table scan\n**     3     schema=?1, pgno=?2\n**\n** idxStr is not used\n*/\nstatic int dbpageFilter(\n  sqlite3_vtab_cursor *pCursor, \n  int idxNum, const char *idxStr,\n  int argc, sqlite3_value **argv\n){\n  DbpageCursor *pCsr = (DbpageCursor *)pCursor;\n  DbpageTable *pTab = (DbpageTable *)pCursor->pVtab;\n  int rc;\n  sqlite3 *db = pTab->db;\n  Btree *pBt;\n\n  /* Default setting is no rows of result */\n  pCsr->pgno = 1; \n  pCsr->mxPgno = 0;\n\n  if( idxNum & 2 ){\n    const char *zSchema;\n    assert( argc>=1 );\n    zSchema = (const char*)sqlite3_value_text(argv[0]);\n    pCsr->iDb = sqlite3FindDbName(db, zSchema);\n    if( pCsr->iDb<0 ) return SQLITE_OK;\n  }else{\n    pCsr->iDb = 0;\n  }\n  pBt = db->aDb[pCsr->iDb].pBt;\n  if( pBt==0 ) return SQLITE_OK;\n  pCsr->pPager = sqlite3BtreePager(pBt);\n  pCsr->szPage = sqlite3BtreeGetPageSize(pBt);\n  pCsr->mxPgno = sqlite3BtreeLastPage(pBt);\n  if( idxNum & 1 ){\n    assert( argc>(idxNum>>1) );\n    pCsr->pgno = sqlite3_value_int(argv[idxNum>>1]);\n    if( pCsr->pgno<1 || pCsr->pgno>pCsr->mxPgno ){\n      pCsr->pgno = 1;\n      pCsr->mxPgno = 0;\n    }else{\n      pCsr->mxPgno = pCsr->pgno;\n    }\n  }else{\n    assert( pCsr->pgno==1 );\n  }\n  if( pCsr->pPage1 ) sqlite3PagerUnrefPageOne(pCsr->pPage1);\n  rc = sqlite3PagerGet(pCsr->pPager, 1, &pCsr->pPage1, 0);\n  return rc;\n}\n\nstatic int dbpageColumn(\n  sqlite3_vtab_cursor *pCursor, \n  sqlite3_context *ctx, \n  int i\n){\n  DbpageCursor *pCsr = (DbpageCursor *)pCursor;\n  int rc = SQLITE_OK;\n  switch( i ){\n    case 0: {           /* pgno */\n      sqlite3_result_int(ctx, pCsr->pgno);\n      break;\n    }\n    case 1: {           /* data */\n      DbPage *pDbPage = 0;\n      rc = sqlite3PagerGet(pCsr->pPager, pCsr->pgno, (DbPage**)&pDbPage, 0);\n      if( rc==SQLITE_OK ){\n        sqlite3_result_blob(ctx, sqlite3PagerGetData(pDbPage), pCsr->szPage,\n                            SQLITE_TRANSIENT);\n      }\n      sqlite3PagerUnref(pDbPage);\n      break;\n    }\n    default: {          /* schema */\n      sqlite3 *db = sqlite3_context_db_handle(ctx);\n      sqlite3_result_text(ctx, db->aDb[pCsr->iDb].zDbSName, -1, SQLITE_STATIC);\n      break;\n    }\n  }\n  return SQLITE_OK;\n}\n\nstatic int dbpageRowid(sqlite3_vtab_cursor *pCursor, sqlite_int64 *pRowid){\n  DbpageCursor *pCsr = (DbpageCursor *)pCursor;\n  *pRowid = pCsr->pgno;\n  return SQLITE_OK;\n}\n\nstatic int dbpageUpdate(\n  sqlite3_vtab *pVtab,\n  int argc,\n  sqlite3_value **argv,\n  sqlite_int64 *pRowid\n){\n  DbpageTable *pTab = (DbpageTable *)pVtab;\n  Pgno pgno;\n  DbPage *pDbPage = 0;\n  int rc = SQLITE_OK;\n  char *zErr = 0;\n  const char *zSchema;\n  int iDb;\n  Btree *pBt;\n  Pager *pPager;\n  int szPage;\n\n  if( pTab->db->flags & SQLITE_Defensive ){\n    zErr = \"read-only\";\n    goto update_fail;\n  }\n  if( argc==1 ){\n    zErr = \"cannot delete\";\n    goto update_fail;\n  }\n  pgno = sqlite3_value_int(argv[0]);\n  if( (Pgno)sqlite3_value_int(argv[1])!=pgno ){\n    zErr = \"cannot insert\";\n    goto update_fail;\n  }\n  zSchema = (const char*)sqlite3_value_text(argv[4]);\n  iDb = zSchema ? sqlite3FindDbName(pTab->db, zSchema) : -1;\n  if( iDb<0 ){\n    zErr = \"no such schema\";\n    goto update_fail;\n  }\n  pBt = pTab->db->aDb[iDb].pBt;\n  if( pgno<1 || pBt==0 || pgno>(int)sqlite3BtreeLastPage(pBt) ){\n    zErr = \"bad page number\";\n    goto update_fail;\n  }\n  szPage = sqlite3BtreeGetPageSize(pBt);\n  if( sqlite3_value_type(argv[3])!=SQLITE_BLOB \n   || sqlite3_value_bytes(argv[3])!=szPage\n  ){\n    zErr = \"bad page value\";\n    goto update_fail;\n  }\n  pPager = sqlite3BtreePager(pBt);\n  rc = sqlite3PagerGet(pPager, pgno, (DbPage**)&pDbPage, 0);\n  if( rc==SQLITE_OK ){\n    rc = sqlite3PagerWrite(pDbPage);\n    if( rc==SQLITE_OK ){\n      memcpy(sqlite3PagerGetData(pDbPage),\n             sqlite3_value_blob(argv[3]),\n             szPage);\n    }\n  }\n  sqlite3PagerUnref(pDbPage);\n  return rc;\n\nupdate_fail:\n  sqlite3_free(pVtab->zErrMsg);\n  pVtab->zErrMsg = sqlite3_mprintf(\"%s\", zErr);\n  return SQLITE_ERROR;\n}\n\n/* Since we do not know in advance which database files will be\n** written by the sqlite_dbpage virtual table, start a write transaction\n** on them all.\n*/\nstatic int dbpageBegin(sqlite3_vtab *pVtab){\n  DbpageTable *pTab = (DbpageTable *)pVtab;\n  sqlite3 *db = pTab->db;\n  int i;\n  for(i=0; i<db->nDb; i++){\n    Btree *pBt = db->aDb[i].pBt;\n    if( pBt ) sqlite3BtreeBeginTrans(pBt, 1, 0);\n  }\n  return SQLITE_OK;\n}\n\n\n/*\n** Invoke this routine to register the \"dbpage\" virtual table module\n*/\nSQLITE_PRIVATE int sqlite3DbpageRegister(sqlite3 *db){\n  static sqlite3_module dbpage_module = {\n    0,                            /* iVersion */\n    dbpageConnect,                /* xCreate */\n    dbpageConnect,                /* xConnect */\n    dbpageBestIndex,              /* xBestIndex */\n    dbpageDisconnect,             /* xDisconnect */\n    dbpageDisconnect,             /* xDestroy */\n    dbpageOpen,                   /* xOpen - open a cursor */\n    dbpageClose,                  /* xClose - close a cursor */\n    dbpageFilter,                 /* xFilter - configure scan constraints */\n    dbpageNext,                   /* xNext - advance a cursor */\n    dbpageEof,                    /* xEof - check for end of scan */\n    dbpageColumn,                 /* xColumn - read data */\n    dbpageRowid,                  /* xRowid - read data */\n    dbpageUpdate,                 /* xUpdate */\n    dbpageBegin,                  /* xBegin */\n    0,                            /* xSync */\n    0,                            /* xCommit */\n    0,                            /* xRollback */\n    0,                            /* xFindMethod */\n    0,                            /* xRename */\n    0,                            /* xSavepoint */\n    0,                            /* xRelease */\n    0,                            /* xRollbackTo */\n    0                             /* xShadowName */\n  };\n  return sqlite3_create_module(db, \"sqlite_dbpage\", &dbpage_module, 0);\n}\n#elif defined(SQLITE_ENABLE_DBPAGE_VTAB)\nSQLITE_PRIVATE int sqlite3DbpageRegister(sqlite3 *db){ return SQLITE_OK; }\n#endif /* SQLITE_ENABLE_DBSTAT_VTAB */\n\n/************** End of dbpage.c **********************************************/\n/************** Begin file sqlite3session.c **********************************/\n\n#if defined(SQLITE_ENABLE_SESSION) && defined(SQLITE_ENABLE_PREUPDATE_HOOK)\n/* #include \"sqlite3session.h\" */\n/* #include <assert.h> */\n/* #include <string.h> */\n\n#ifndef SQLITE_AMALGAMATION\n/* # include \"sqliteInt.h\" */\n/* # include \"vdbeInt.h\" */\n#endif\n\ntypedef struct SessionTable SessionTable;\ntypedef struct SessionChange SessionChange;\ntypedef struct SessionBuffer SessionBuffer;\ntypedef struct SessionInput SessionInput;\n\n/*\n** Minimum chunk size used by streaming versions of functions.\n*/\n#ifndef SESSIONS_STRM_CHUNK_SIZE\n# ifdef SQLITE_TEST\n#   define SESSIONS_STRM_CHUNK_SIZE 64\n# else\n#   define SESSIONS_STRM_CHUNK_SIZE 1024\n# endif\n#endif\n\nstatic int sessions_strm_chunk_size = SESSIONS_STRM_CHUNK_SIZE;\n\ntypedef struct SessionHook SessionHook;\nstruct SessionHook {\n  void *pCtx;\n  int (*xOld)(void*,int,sqlite3_value**);\n  int (*xNew)(void*,int,sqlite3_value**);\n  int (*xCount)(void*);\n  int (*xDepth)(void*);\n};\n\n/*\n** Session handle structure.\n*/\nstruct sqlite3_session {\n  sqlite3 *db;                    /* Database handle session is attached to */\n  char *zDb;                      /* Name of database session is attached to */\n  int bEnable;                    /* True if currently recording */\n  int bIndirect;                  /* True if all changes are indirect */\n  int bAutoAttach;                /* True to auto-attach tables */\n  int rc;                         /* Non-zero if an error has occurred */\n  void *pFilterCtx;               /* First argument to pass to xTableFilter */\n  int (*xTableFilter)(void *pCtx, const char *zTab);\n  sqlite3_value *pZeroBlob;       /* Value containing X'' */\n  sqlite3_session *pNext;         /* Next session object on same db. */\n  SessionTable *pTable;           /* List of attached tables */\n  SessionHook hook;               /* APIs to grab new and old data with */\n};\n\n/*\n** Instances of this structure are used to build strings or binary records.\n*/\nstruct SessionBuffer {\n  u8 *aBuf;                       /* Pointer to changeset buffer */\n  int nBuf;                       /* Size of buffer aBuf */\n  int nAlloc;                     /* Size of allocation containing aBuf */\n};\n\n/*\n** An object of this type is used internally as an abstraction for \n** input data. Input data may be supplied either as a single large buffer\n** (e.g. sqlite3changeset_start()) or using a stream function (e.g.\n**  sqlite3changeset_start_strm()).\n*/\nstruct SessionInput {\n  int bNoDiscard;                 /* If true, do not discard in InputBuffer() */\n  int iCurrent;                   /* Offset in aData[] of current change */\n  int iNext;                      /* Offset in aData[] of next change */\n  u8 *aData;                      /* Pointer to buffer containing changeset */\n  int nData;                      /* Number of bytes in aData */\n\n  SessionBuffer buf;              /* Current read buffer */\n  int (*xInput)(void*, void*, int*);        /* Input stream call (or NULL) */\n  void *pIn;                                /* First argument to xInput */\n  int bEof;                       /* Set to true after xInput finished */\n};\n\n/*\n** Structure for changeset iterators.\n*/\nstruct sqlite3_changeset_iter {\n  SessionInput in;                /* Input buffer or stream */\n  SessionBuffer tblhdr;           /* Buffer to hold apValue/zTab/abPK/ */\n  int bPatchset;                  /* True if this is a patchset */\n  int bInvert;                    /* True to invert changeset */\n  int rc;                         /* Iterator error code */\n  sqlite3_stmt *pConflict;        /* Points to conflicting row, if any */\n  char *zTab;                     /* Current table */\n  int nCol;                       /* Number of columns in zTab */\n  int op;                         /* Current operation */\n  int bIndirect;                  /* True if current change was indirect */\n  u8 *abPK;                       /* Primary key array */\n  sqlite3_value **apValue;        /* old.* and new.* values */\n};\n\n/*\n** Each session object maintains a set of the following structures, one\n** for each table the session object is monitoring. The structures are\n** stored in a linked list starting at sqlite3_session.pTable.\n**\n** The keys of the SessionTable.aChange[] hash table are all rows that have\n** been modified in any way since the session object was attached to the\n** table.\n**\n** The data associated with each hash-table entry is a structure containing\n** a subset of the initial values that the modified row contained at the\n** start of the session. Or no initial values if the row was inserted.\n*/\nstruct SessionTable {\n  SessionTable *pNext;\n  char *zName;                    /* Local name of table */\n  int nCol;                       /* Number of columns in table zName */\n  int bStat1;                     /* True if this is sqlite_stat1 */\n  const char **azCol;             /* Column names */\n  u8 *abPK;                       /* Array of primary key flags */\n  int nEntry;                     /* Total number of entries in hash table */\n  int nChange;                    /* Size of apChange[] array */\n  SessionChange **apChange;       /* Hash table buckets */\n};\n\n/* \n** RECORD FORMAT:\n**\n** The following record format is similar to (but not compatible with) that \n** used in SQLite database files. This format is used as part of the \n** change-set binary format, and so must be architecture independent.\n**\n** Unlike the SQLite database record format, each field is self-contained -\n** there is no separation of header and data. Each field begins with a\n** single byte describing its type, as follows:\n**\n**       0x00: Undefined value.\n**       0x01: Integer value.\n**       0x02: Real value.\n**       0x03: Text value.\n**       0x04: Blob value.\n**       0x05: SQL NULL value.\n**\n** Note that the above match the definitions of SQLITE_INTEGER, SQLITE_TEXT\n** and so on in sqlite3.h. For undefined and NULL values, the field consists\n** only of the single type byte. For other types of values, the type byte\n** is followed by:\n**\n**   Text values:\n**     A varint containing the number of bytes in the value (encoded using\n**     UTF-8). Followed by a buffer containing the UTF-8 representation\n**     of the text value. There is no nul terminator.\n**\n**   Blob values:\n**     A varint containing the number of bytes in the value, followed by\n**     a buffer containing the value itself.\n**\n**   Integer values:\n**     An 8-byte big-endian integer value.\n**\n**   Real values:\n**     An 8-byte big-endian IEEE 754-2008 real value.\n**\n** Varint values are encoded in the same way as varints in the SQLite \n** record format.\n**\n** CHANGESET FORMAT:\n**\n** A changeset is a collection of DELETE, UPDATE and INSERT operations on\n** one or more tables. Operations on a single table are grouped together,\n** but may occur in any order (i.e. deletes, updates and inserts are all\n** mixed together).\n**\n** Each group of changes begins with a table header:\n**\n**   1 byte: Constant 0x54 (capital 'T')\n**   Varint: Number of columns in the table.\n**   nCol bytes: 0x01 for PK columns, 0x00 otherwise.\n**   N bytes: Unqualified table name (encoded using UTF-8). Nul-terminated.\n**\n** Followed by one or more changes to the table.\n**\n**   1 byte: Either SQLITE_INSERT (0x12), UPDATE (0x17) or DELETE (0x09).\n**   1 byte: The \"indirect-change\" flag.\n**   old.* record: (delete and update only)\n**   new.* record: (insert and update only)\n**\n** The \"old.*\" and \"new.*\" records, if present, are N field records in the\n** format described above under \"RECORD FORMAT\", where N is the number of\n** columns in the table. The i'th field of each record is associated with\n** the i'th column of the table, counting from left to right in the order\n** in which columns were declared in the CREATE TABLE statement.\n**\n** The new.* record that is part of each INSERT change contains the values\n** that make up the new row. Similarly, the old.* record that is part of each\n** DELETE change contains the values that made up the row that was deleted \n** from the database. In the changeset format, the records that are part\n** of INSERT or DELETE changes never contain any undefined (type byte 0x00)\n** fields.\n**\n** Within the old.* record associated with an UPDATE change, all fields\n** associated with table columns that are not PRIMARY KEY columns and are\n** not modified by the UPDATE change are set to \"undefined\". Other fields\n** are set to the values that made up the row before the UPDATE that the\n** change records took place. Within the new.* record, fields associated \n** with table columns modified by the UPDATE change contain the new \n** values. Fields associated with table columns that are not modified\n** are set to \"undefined\".\n**\n** PATCHSET FORMAT:\n**\n** A patchset is also a collection of changes. It is similar to a changeset,\n** but leaves undefined those fields that are not useful if no conflict\n** resolution is required when applying the changeset.\n**\n** Each group of changes begins with a table header:\n**\n**   1 byte: Constant 0x50 (capital 'P')\n**   Varint: Number of columns in the table.\n**   nCol bytes: 0x01 for PK columns, 0x00 otherwise.\n**   N bytes: Unqualified table name (encoded using UTF-8). Nul-terminated.\n**\n** Followed by one or more changes to the table.\n**\n**   1 byte: Either SQLITE_INSERT (0x12), UPDATE (0x17) or DELETE (0x09).\n**   1 byte: The \"indirect-change\" flag.\n**   single record: (PK fields for DELETE, PK and modified fields for UPDATE,\n**                   full record for INSERT).\n**\n** As in the changeset format, each field of the single record that is part\n** of a patchset change is associated with the correspondingly positioned\n** table column, counting from left to right within the CREATE TABLE \n** statement.\n**\n** For a DELETE change, all fields within the record except those associated\n** with PRIMARY KEY columns are omitted. The PRIMARY KEY fields contain the\n** values identifying the row to delete.\n**\n** For an UPDATE change, all fields except those associated with PRIMARY KEY\n** columns and columns that are modified by the UPDATE are set to \"undefined\".\n** PRIMARY KEY fields contain the values identifying the table row to update,\n** and fields associated with modified columns contain the new column values.\n**\n** The records associated with INSERT changes are in the same format as for\n** changesets. It is not possible for a record associated with an INSERT\n** change to contain a field set to \"undefined\".\n**\n** REBASE BLOB FORMAT:\n**\n** A rebase blob may be output by sqlite3changeset_apply_v2() and its \n** streaming equivalent for use with the sqlite3_rebaser APIs to rebase\n** existing changesets. A rebase blob contains one entry for each conflict\n** resolved using either the OMIT or REPLACE strategies within the apply_v2()\n** call.\n**\n** The format used for a rebase blob is very similar to that used for\n** changesets. All entries related to a single table are grouped together.\n**\n** Each group of entries begins with a table header in changeset format:\n**\n**   1 byte: Constant 0x54 (capital 'T')\n**   Varint: Number of columns in the table.\n**   nCol bytes: 0x01 for PK columns, 0x00 otherwise.\n**   N bytes: Unqualified table name (encoded using UTF-8). Nul-terminated.\n**\n** Followed by one or more entries associated with the table.\n**\n**   1 byte: Either SQLITE_INSERT (0x12), DELETE (0x09).\n**   1 byte: Flag. 0x01 for REPLACE, 0x00 for OMIT.\n**   record: (in the record format defined above).\n**\n** In a rebase blob, the first field is set to SQLITE_INSERT if the change\n** that caused the conflict was an INSERT or UPDATE, or to SQLITE_DELETE if\n** it was a DELETE. The second field is set to 0x01 if the conflict \n** resolution strategy was REPLACE, or 0x00 if it was OMIT.\n**\n** If the change that caused the conflict was a DELETE, then the single\n** record is a copy of the old.* record from the original changeset. If it\n** was an INSERT, then the single record is a copy of the new.* record. If\n** the conflicting change was an UPDATE, then the single record is a copy\n** of the new.* record with the PK fields filled in based on the original\n** old.* record.\n*/\n\n/*\n** For each row modified during a session, there exists a single instance of\n** this structure stored in a SessionTable.aChange[] hash table.\n*/\nstruct SessionChange {\n  int op;                         /* One of UPDATE, DELETE, INSERT */\n  int bIndirect;                  /* True if this change is \"indirect\" */\n  int nRecord;                    /* Number of bytes in buffer aRecord[] */\n  u8 *aRecord;                    /* Buffer containing old.* record */\n  SessionChange *pNext;           /* For hash-table collisions */\n};\n\n/*\n** Write a varint with value iVal into the buffer at aBuf. Return the \n** number of bytes written.\n*/\nstatic int sessionVarintPut(u8 *aBuf, int iVal){\n  return putVarint32(aBuf, iVal);\n}\n\n/*\n** Return the number of bytes required to store value iVal as a varint.\n*/\nstatic int sessionVarintLen(int iVal){\n  return sqlite3VarintLen(iVal);\n}\n\n/*\n** Read a varint value from aBuf[] into *piVal. Return the number of \n** bytes read.\n*/\nstatic int sessionVarintGet(u8 *aBuf, int *piVal){\n  return getVarint32(aBuf, *piVal);\n}\n\n/* Load an unaligned and unsigned 32-bit integer */\n#define SESSION_UINT32(x) (((u32)(x)[0]<<24)|((x)[1]<<16)|((x)[2]<<8)|(x)[3])\n\n/*\n** Read a 64-bit big-endian integer value from buffer aRec[]. Return\n** the value read.\n*/\nstatic sqlite3_int64 sessionGetI64(u8 *aRec){\n  u64 x = SESSION_UINT32(aRec);\n  u32 y = SESSION_UINT32(aRec+4);\n  x = (x<<32) + y;\n  return (sqlite3_int64)x;\n}\n\n/*\n** Write a 64-bit big-endian integer value to the buffer aBuf[].\n*/\nstatic void sessionPutI64(u8 *aBuf, sqlite3_int64 i){\n  aBuf[0] = (i>>56) & 0xFF;\n  aBuf[1] = (i>>48) & 0xFF;\n  aBuf[2] = (i>>40) & 0xFF;\n  aBuf[3] = (i>>32) & 0xFF;\n  aBuf[4] = (i>>24) & 0xFF;\n  aBuf[5] = (i>>16) & 0xFF;\n  aBuf[6] = (i>> 8) & 0xFF;\n  aBuf[7] = (i>> 0) & 0xFF;\n}\n\n/*\n** This function is used to serialize the contents of value pValue (see\n** comment titled \"RECORD FORMAT\" above).\n**\n** If it is non-NULL, the serialized form of the value is written to \n** buffer aBuf. *pnWrite is set to the number of bytes written before\n** returning. Or, if aBuf is NULL, the only thing this function does is\n** set *pnWrite.\n**\n** If no error occurs, SQLITE_OK is returned. Or, if an OOM error occurs\n** within a call to sqlite3_value_text() (may fail if the db is utf-16)) \n** SQLITE_NOMEM is returned.\n*/\nstatic int sessionSerializeValue(\n  u8 *aBuf,                       /* If non-NULL, write serialized value here */\n  sqlite3_value *pValue,          /* Value to serialize */\n  sqlite3_int64 *pnWrite          /* IN/OUT: Increment by bytes written */\n){\n  int nByte;                      /* Size of serialized value in bytes */\n\n  if( pValue ){\n    int eType;                    /* Value type (SQLITE_NULL, TEXT etc.) */\n  \n    eType = sqlite3_value_type(pValue);\n    if( aBuf ) aBuf[0] = eType;\n  \n    switch( eType ){\n      case SQLITE_NULL: \n        nByte = 1;\n        break;\n  \n      case SQLITE_INTEGER: \n      case SQLITE_FLOAT:\n        if( aBuf ){\n          /* TODO: SQLite does something special to deal with mixed-endian\n          ** floating point values (e.g. ARM7). This code probably should\n          ** too.  */\n          u64 i;\n          if( eType==SQLITE_INTEGER ){\n            i = (u64)sqlite3_value_int64(pValue);\n          }else{\n            double r;\n            assert( sizeof(double)==8 && sizeof(u64)==8 );\n            r = sqlite3_value_double(pValue);\n            memcpy(&i, &r, 8);\n          }\n          sessionPutI64(&aBuf[1], i);\n        }\n        nByte = 9; \n        break;\n  \n      default: {\n        u8 *z;\n        int n;\n        int nVarint;\n  \n        assert( eType==SQLITE_TEXT || eType==SQLITE_BLOB );\n        if( eType==SQLITE_TEXT ){\n          z = (u8 *)sqlite3_value_text(pValue);\n        }else{\n          z = (u8 *)sqlite3_value_blob(pValue);\n        }\n        n = sqlite3_value_bytes(pValue);\n        if( z==0 && (eType!=SQLITE_BLOB || n>0) ) return SQLITE_NOMEM;\n        nVarint = sessionVarintLen(n);\n  \n        if( aBuf ){\n          sessionVarintPut(&aBuf[1], n);\n          if( n ) memcpy(&aBuf[nVarint + 1], z, n);\n        }\n  \n        nByte = 1 + nVarint + n;\n        break;\n      }\n    }\n  }else{\n    nByte = 1;\n    if( aBuf ) aBuf[0] = '\\0';\n  }\n\n  if( pnWrite ) *pnWrite += nByte;\n  return SQLITE_OK;\n}\n\n\n/*\n** This macro is used to calculate hash key values for data structures. In\n** order to use this macro, the entire data structure must be represented\n** as a series of unsigned integers. In order to calculate a hash-key value\n** for a data structure represented as three such integers, the macro may\n** then be used as follows:\n**\n**    int hash_key_value;\n**    hash_key_value = HASH_APPEND(0, <value 1>);\n**    hash_key_value = HASH_APPEND(hash_key_value, <value 2>);\n**    hash_key_value = HASH_APPEND(hash_key_value, <value 3>);\n**\n** In practice, the data structures this macro is used for are the primary\n** key values of modified rows.\n*/\n#define HASH_APPEND(hash, add) ((hash) << 3) ^ (hash) ^ (unsigned int)(add)\n\n/*\n** Append the hash of the 64-bit integer passed as the second argument to the\n** hash-key value passed as the first. Return the new hash-key value.\n*/\nstatic unsigned int sessionHashAppendI64(unsigned int h, i64 i){\n  h = HASH_APPEND(h, i & 0xFFFFFFFF);\n  return HASH_APPEND(h, (i>>32)&0xFFFFFFFF);\n}\n\n/*\n** Append the hash of the blob passed via the second and third arguments to \n** the hash-key value passed as the first. Return the new hash-key value.\n*/\nstatic unsigned int sessionHashAppendBlob(unsigned int h, int n, const u8 *z){\n  int i;\n  for(i=0; i<n; i++) h = HASH_APPEND(h, z[i]);\n  return h;\n}\n\n/*\n** Append the hash of the data type passed as the second argument to the\n** hash-key value passed as the first. Return the new hash-key value.\n*/\nstatic unsigned int sessionHashAppendType(unsigned int h, int eType){\n  return HASH_APPEND(h, eType);\n}\n\n/*\n** This function may only be called from within a pre-update callback.\n** It calculates a hash based on the primary key values of the old.* or \n** new.* row currently available and, assuming no error occurs, writes it to\n** *piHash before returning. If the primary key contains one or more NULL\n** values, *pbNullPK is set to true before returning.\n**\n** If an error occurs, an SQLite error code is returned and the final values\n** of *piHash asn *pbNullPK are undefined. Otherwise, SQLITE_OK is returned\n** and the output variables are set as described above.\n*/\nstatic int sessionPreupdateHash(\n  sqlite3_session *pSession,      /* Session object that owns pTab */\n  SessionTable *pTab,             /* Session table handle */\n  int bNew,                       /* True to hash the new.* PK */\n  int *piHash,                    /* OUT: Hash value */\n  int *pbNullPK                   /* OUT: True if there are NULL values in PK */\n){\n  unsigned int h = 0;             /* Hash value to return */\n  int i;                          /* Used to iterate through columns */\n\n  assert( *pbNullPK==0 );\n  assert( pTab->nCol==pSession->hook.xCount(pSession->hook.pCtx) );\n  for(i=0; i<pTab->nCol; i++){\n    if( pTab->abPK[i] ){\n      int rc;\n      int eType;\n      sqlite3_value *pVal;\n\n      if( bNew ){\n        rc = pSession->hook.xNew(pSession->hook.pCtx, i, &pVal);\n      }else{\n        rc = pSession->hook.xOld(pSession->hook.pCtx, i, &pVal);\n      }\n      if( rc!=SQLITE_OK ) return rc;\n\n      eType = sqlite3_value_type(pVal);\n      h = sessionHashAppendType(h, eType);\n      if( eType==SQLITE_INTEGER || eType==SQLITE_FLOAT ){\n        i64 iVal;\n        if( eType==SQLITE_INTEGER ){\n          iVal = sqlite3_value_int64(pVal);\n        }else{\n          double rVal = sqlite3_value_double(pVal);\n          assert( sizeof(iVal)==8 && sizeof(rVal)==8 );\n          memcpy(&iVal, &rVal, 8);\n        }\n        h = sessionHashAppendI64(h, iVal);\n      }else if( eType==SQLITE_TEXT || eType==SQLITE_BLOB ){\n        const u8 *z;\n        int n;\n        if( eType==SQLITE_TEXT ){\n          z = (const u8 *)sqlite3_value_text(pVal);\n        }else{\n          z = (const u8 *)sqlite3_value_blob(pVal);\n        }\n        n = sqlite3_value_bytes(pVal);\n        if( !z && (eType!=SQLITE_BLOB || n>0) ) return SQLITE_NOMEM;\n        h = sessionHashAppendBlob(h, n, z);\n      }else{\n        assert( eType==SQLITE_NULL );\n        assert( pTab->bStat1==0 || i!=1 );\n        *pbNullPK = 1;\n      }\n    }\n  }\n\n  *piHash = (h % pTab->nChange);\n  return SQLITE_OK;\n}\n\n/*\n** The buffer that the argument points to contains a serialized SQL value.\n** Return the number of bytes of space occupied by the value (including\n** the type byte).\n*/\nstatic int sessionSerialLen(u8 *a){\n  int e = *a;\n  int n;\n  if( e==0 || e==0xFF ) return 1;\n  if( e==SQLITE_NULL ) return 1;\n  if( e==SQLITE_INTEGER || e==SQLITE_FLOAT ) return 9;\n  return sessionVarintGet(&a[1], &n) + 1 + n;\n}\n\n/*\n** Based on the primary key values stored in change aRecord, calculate a\n** hash key. Assume the has table has nBucket buckets. The hash keys\n** calculated by this function are compatible with those calculated by\n** sessionPreupdateHash().\n**\n** The bPkOnly argument is non-zero if the record at aRecord[] is from\n** a patchset DELETE. In this case the non-PK fields are omitted entirely.\n*/\nstatic unsigned int sessionChangeHash(\n  SessionTable *pTab,             /* Table handle */\n  int bPkOnly,                    /* Record consists of PK fields only */\n  u8 *aRecord,                    /* Change record */\n  int nBucket                     /* Assume this many buckets in hash table */\n){\n  unsigned int h = 0;             /* Value to return */\n  int i;                          /* Used to iterate through columns */\n  u8 *a = aRecord;                /* Used to iterate through change record */\n\n  for(i=0; i<pTab->nCol; i++){\n    int eType = *a;\n    int isPK = pTab->abPK[i];\n    if( bPkOnly && isPK==0 ) continue;\n\n    /* It is not possible for eType to be SQLITE_NULL here. The session \n    ** module does not record changes for rows with NULL values stored in\n    ** primary key columns. */\n    assert( eType==SQLITE_INTEGER || eType==SQLITE_FLOAT \n         || eType==SQLITE_TEXT || eType==SQLITE_BLOB \n         || eType==SQLITE_NULL || eType==0 \n    );\n    assert( !isPK || (eType!=0 && eType!=SQLITE_NULL) );\n\n    if( isPK ){\n      a++;\n      h = sessionHashAppendType(h, eType);\n      if( eType==SQLITE_INTEGER || eType==SQLITE_FLOAT ){\n        h = sessionHashAppendI64(h, sessionGetI64(a));\n        a += 8;\n      }else{\n        int n; \n        a += sessionVarintGet(a, &n);\n        h = sessionHashAppendBlob(h, n, a);\n        a += n;\n      }\n    }else{\n      a += sessionSerialLen(a);\n    }\n  }\n  return (h % nBucket);\n}\n\n/*\n** Arguments aLeft and aRight are pointers to change records for table pTab.\n** This function returns true if the two records apply to the same row (i.e.\n** have the same values stored in the primary key columns), or false \n** otherwise.\n*/\nstatic int sessionChangeEqual(\n  SessionTable *pTab,             /* Table used for PK definition */\n  int bLeftPkOnly,                /* True if aLeft[] contains PK fields only */\n  u8 *aLeft,                      /* Change record */\n  int bRightPkOnly,               /* True if aRight[] contains PK fields only */\n  u8 *aRight                      /* Change record */\n){\n  u8 *a1 = aLeft;                 /* Cursor to iterate through aLeft */\n  u8 *a2 = aRight;                /* Cursor to iterate through aRight */\n  int iCol;                       /* Used to iterate through table columns */\n\n  for(iCol=0; iCol<pTab->nCol; iCol++){\n    if( pTab->abPK[iCol] ){\n      int n1 = sessionSerialLen(a1);\n      int n2 = sessionSerialLen(a2);\n\n      if( n1!=n2 || memcmp(a1, a2, n1) ){\n        return 0;\n      }\n      a1 += n1;\n      a2 += n2;\n    }else{\n      if( bLeftPkOnly==0 ) a1 += sessionSerialLen(a1);\n      if( bRightPkOnly==0 ) a2 += sessionSerialLen(a2);\n    }\n  }\n\n  return 1;\n}\n\n/*\n** Arguments aLeft and aRight both point to buffers containing change\n** records with nCol columns. This function \"merges\" the two records into\n** a single records which is written to the buffer at *paOut. *paOut is\n** then set to point to one byte after the last byte written before \n** returning.\n**\n** The merging of records is done as follows: For each column, if the \n** aRight record contains a value for the column, copy the value from\n** their. Otherwise, if aLeft contains a value, copy it. If neither\n** record contains a value for a given column, then neither does the\n** output record.\n*/\nstatic void sessionMergeRecord(\n  u8 **paOut, \n  int nCol,\n  u8 *aLeft,\n  u8 *aRight\n){\n  u8 *a1 = aLeft;                 /* Cursor used to iterate through aLeft */\n  u8 *a2 = aRight;                /* Cursor used to iterate through aRight */\n  u8 *aOut = *paOut;              /* Output cursor */\n  int iCol;                       /* Used to iterate from 0 to nCol */\n\n  for(iCol=0; iCol<nCol; iCol++){\n    int n1 = sessionSerialLen(a1);\n    int n2 = sessionSerialLen(a2);\n    if( *a2 ){\n      memcpy(aOut, a2, n2);\n      aOut += n2;\n    }else{\n      memcpy(aOut, a1, n1);\n      aOut += n1;\n    }\n    a1 += n1;\n    a2 += n2;\n  }\n\n  *paOut = aOut;\n}\n\n/*\n** This is a helper function used by sessionMergeUpdate().\n**\n** When this function is called, both *paOne and *paTwo point to a value \n** within a change record. Before it returns, both have been advanced so \n** as to point to the next value in the record.\n**\n** If, when this function is called, *paTwo points to a valid value (i.e.\n** *paTwo[0] is not 0x00 - the \"no value\" placeholder), a copy of the *paTwo\n** pointer is returned and *pnVal is set to the number of bytes in the \n** serialized value. Otherwise, a copy of *paOne is returned and *pnVal\n** set to the number of bytes in the value at *paOne. If *paOne points\n** to the \"no value\" placeholder, *pnVal is set to 1. In other words:\n**\n**   if( *paTwo is valid ) return *paTwo;\n**   return *paOne;\n**\n*/\nstatic u8 *sessionMergeValue(\n  u8 **paOne,                     /* IN/OUT: Left-hand buffer pointer */\n  u8 **paTwo,                     /* IN/OUT: Right-hand buffer pointer */\n  int *pnVal                      /* OUT: Bytes in returned value */\n){\n  u8 *a1 = *paOne;\n  u8 *a2 = *paTwo;\n  u8 *pRet = 0;\n  int n1;\n\n  assert( a1 );\n  if( a2 ){\n    int n2 = sessionSerialLen(a2);\n    if( *a2 ){\n      *pnVal = n2;\n      pRet = a2;\n    }\n    *paTwo = &a2[n2];\n  }\n\n  n1 = sessionSerialLen(a1);\n  if( pRet==0 ){\n    *pnVal = n1;\n    pRet = a1;\n  }\n  *paOne = &a1[n1];\n\n  return pRet;\n}\n\n/*\n** This function is used by changeset_concat() to merge two UPDATE changes\n** on the same row.\n*/\nstatic int sessionMergeUpdate(\n  u8 **paOut,                     /* IN/OUT: Pointer to output buffer */\n  SessionTable *pTab,             /* Table change pertains to */\n  int bPatchset,                  /* True if records are patchset records */\n  u8 *aOldRecord1,                /* old.* record for first change */\n  u8 *aOldRecord2,                /* old.* record for second change */\n  u8 *aNewRecord1,                /* new.* record for first change */\n  u8 *aNewRecord2                 /* new.* record for second change */\n){\n  u8 *aOld1 = aOldRecord1;\n  u8 *aOld2 = aOldRecord2;\n  u8 *aNew1 = aNewRecord1;\n  u8 *aNew2 = aNewRecord2;\n\n  u8 *aOut = *paOut;\n  int i;\n\n  if( bPatchset==0 ){\n    int bRequired = 0;\n\n    assert( aOldRecord1 && aNewRecord1 );\n\n    /* Write the old.* vector first. */\n    for(i=0; i<pTab->nCol; i++){\n      int nOld;\n      u8 *aOld;\n      int nNew;\n      u8 *aNew;\n\n      aOld = sessionMergeValue(&aOld1, &aOld2, &nOld);\n      aNew = sessionMergeValue(&aNew1, &aNew2, &nNew);\n      if( pTab->abPK[i] || nOld!=nNew || memcmp(aOld, aNew, nNew) ){\n        if( pTab->abPK[i]==0 ) bRequired = 1;\n        memcpy(aOut, aOld, nOld);\n        aOut += nOld;\n      }else{\n        *(aOut++) = '\\0';\n      }\n    }\n\n    if( !bRequired ) return 0;\n  }\n\n  /* Write the new.* vector */\n  aOld1 = aOldRecord1;\n  aOld2 = aOldRecord2;\n  aNew1 = aNewRecord1;\n  aNew2 = aNewRecord2;\n  for(i=0; i<pTab->nCol; i++){\n    int nOld;\n    u8 *aOld;\n    int nNew;\n    u8 *aNew;\n\n    aOld = sessionMergeValue(&aOld1, &aOld2, &nOld);\n    aNew = sessionMergeValue(&aNew1, &aNew2, &nNew);\n    if( bPatchset==0 \n     && (pTab->abPK[i] || (nOld==nNew && 0==memcmp(aOld, aNew, nNew))) \n    ){\n      *(aOut++) = '\\0';\n    }else{\n      memcpy(aOut, aNew, nNew);\n      aOut += nNew;\n    }\n  }\n\n  *paOut = aOut;\n  return 1;\n}\n\n/*\n** This function is only called from within a pre-update-hook callback.\n** It determines if the current pre-update-hook change affects the same row\n** as the change stored in argument pChange. If so, it returns true. Otherwise\n** if the pre-update-hook does not affect the same row as pChange, it returns\n** false.\n*/\nstatic int sessionPreupdateEqual(\n  sqlite3_session *pSession,      /* Session object that owns SessionTable */\n  SessionTable *pTab,             /* Table associated with change */\n  SessionChange *pChange,         /* Change to compare to */\n  int op                          /* Current pre-update operation */\n){\n  int iCol;                       /* Used to iterate through columns */\n  u8 *a = pChange->aRecord;       /* Cursor used to scan change record */\n\n  assert( op==SQLITE_INSERT || op==SQLITE_UPDATE || op==SQLITE_DELETE );\n  for(iCol=0; iCol<pTab->nCol; iCol++){\n    if( !pTab->abPK[iCol] ){\n      a += sessionSerialLen(a);\n    }else{\n      sqlite3_value *pVal;        /* Value returned by preupdate_new/old */\n      int rc;                     /* Error code from preupdate_new/old */\n      int eType = *a++;           /* Type of value from change record */\n\n      /* The following calls to preupdate_new() and preupdate_old() can not\n      ** fail. This is because they cache their return values, and by the\n      ** time control flows to here they have already been called once from\n      ** within sessionPreupdateHash(). The first two asserts below verify\n      ** this (that the method has already been called). */\n      if( op==SQLITE_INSERT ){\n        /* assert( db->pPreUpdate->pNewUnpacked || db->pPreUpdate->aNew ); */\n        rc = pSession->hook.xNew(pSession->hook.pCtx, iCol, &pVal);\n      }else{\n        /* assert( db->pPreUpdate->pUnpacked ); */\n        rc = pSession->hook.xOld(pSession->hook.pCtx, iCol, &pVal);\n      }\n      assert( rc==SQLITE_OK );\n      if( sqlite3_value_type(pVal)!=eType ) return 0;\n\n      /* A SessionChange object never has a NULL value in a PK column */\n      assert( eType==SQLITE_INTEGER || eType==SQLITE_FLOAT\n           || eType==SQLITE_BLOB    || eType==SQLITE_TEXT\n      );\n\n      if( eType==SQLITE_INTEGER || eType==SQLITE_FLOAT ){\n        i64 iVal = sessionGetI64(a);\n        a += 8;\n        if( eType==SQLITE_INTEGER ){\n          if( sqlite3_value_int64(pVal)!=iVal ) return 0;\n        }else{\n          double rVal;\n          assert( sizeof(iVal)==8 && sizeof(rVal)==8 );\n          memcpy(&rVal, &iVal, 8);\n          if( sqlite3_value_double(pVal)!=rVal ) return 0;\n        }\n      }else{\n        int n;\n        const u8 *z;\n        a += sessionVarintGet(a, &n);\n        if( sqlite3_value_bytes(pVal)!=n ) return 0;\n        if( eType==SQLITE_TEXT ){\n          z = sqlite3_value_text(pVal);\n        }else{\n          z = sqlite3_value_blob(pVal);\n        }\n        if( n>0 && memcmp(a, z, n) ) return 0;\n        a += n;\n      }\n    }\n  }\n\n  return 1;\n}\n\n/*\n** If required, grow the hash table used to store changes on table pTab \n** (part of the session pSession). If a fatal OOM error occurs, set the\n** session object to failed and return SQLITE_ERROR. Otherwise, return\n** SQLITE_OK.\n**\n** It is possible that a non-fatal OOM error occurs in this function. In\n** that case the hash-table does not grow, but SQLITE_OK is returned anyway.\n** Growing the hash table in this case is a performance optimization only,\n** it is not required for correct operation.\n*/\nstatic int sessionGrowHash(int bPatchset, SessionTable *pTab){\n  if( pTab->nChange==0 || pTab->nEntry>=(pTab->nChange/2) ){\n    int i;\n    SessionChange **apNew;\n    int nNew = (pTab->nChange ? pTab->nChange : 128) * 2;\n\n    apNew = (SessionChange **)sqlite3_malloc64(sizeof(SessionChange *) * nNew);\n    if( apNew==0 ){\n      if( pTab->nChange==0 ){\n        return SQLITE_ERROR;\n      }\n      return SQLITE_OK;\n    }\n    memset(apNew, 0, sizeof(SessionChange *) * nNew);\n\n    for(i=0; i<pTab->nChange; i++){\n      SessionChange *p;\n      SessionChange *pNext;\n      for(p=pTab->apChange[i]; p; p=pNext){\n        int bPkOnly = (p->op==SQLITE_DELETE && bPatchset);\n        int iHash = sessionChangeHash(pTab, bPkOnly, p->aRecord, nNew);\n        pNext = p->pNext;\n        p->pNext = apNew[iHash];\n        apNew[iHash] = p;\n      }\n    }\n\n    sqlite3_free(pTab->apChange);\n    pTab->nChange = nNew;\n    pTab->apChange = apNew;\n  }\n\n  return SQLITE_OK;\n}\n\n/*\n** This function queries the database for the names of the columns of table\n** zThis, in schema zDb.\n**\n** Otherwise, if they are not NULL, variable *pnCol is set to the number\n** of columns in the database table and variable *pzTab is set to point to a\n** nul-terminated copy of the table name. *pazCol (if not NULL) is set to\n** point to an array of pointers to column names. And *pabPK (again, if not\n** NULL) is set to point to an array of booleans - true if the corresponding\n** column is part of the primary key.\n**\n** For example, if the table is declared as:\n**\n**     CREATE TABLE tbl1(w, x, y, z, PRIMARY KEY(w, z));\n**\n** Then the four output variables are populated as follows:\n**\n**     *pnCol  = 4\n**     *pzTab  = \"tbl1\"\n**     *pazCol = {\"w\", \"x\", \"y\", \"z\"}\n**     *pabPK  = {1, 0, 0, 1}\n**\n** All returned buffers are part of the same single allocation, which must\n** be freed using sqlite3_free() by the caller\n*/\nstatic int sessionTableInfo(\n  sqlite3 *db,                    /* Database connection */\n  const char *zDb,                /* Name of attached database (e.g. \"main\") */\n  const char *zThis,              /* Table name */\n  int *pnCol,                     /* OUT: number of columns */\n  const char **pzTab,             /* OUT: Copy of zThis */\n  const char ***pazCol,           /* OUT: Array of column names for table */\n  u8 **pabPK                      /* OUT: Array of booleans - true for PK col */\n){\n  char *zPragma;\n  sqlite3_stmt *pStmt;\n  int rc;\n  sqlite3_int64 nByte;\n  int nDbCol = 0;\n  int nThis;\n  int i;\n  u8 *pAlloc = 0;\n  char **azCol = 0;\n  u8 *abPK = 0;\n\n  assert( pazCol && pabPK );\n\n  nThis = sqlite3Strlen30(zThis);\n  if( nThis==12 && 0==sqlite3_stricmp(\"sqlite_stat1\", zThis) ){\n    rc = sqlite3_table_column_metadata(db, zDb, zThis, 0, 0, 0, 0, 0, 0);\n    if( rc==SQLITE_OK ){\n      /* For sqlite_stat1, pretend that (tbl,idx) is the PRIMARY KEY. */\n      zPragma = sqlite3_mprintf(\n          \"SELECT 0, 'tbl',  '', 0, '', 1     UNION ALL \"\n          \"SELECT 1, 'idx',  '', 0, '', 2     UNION ALL \"\n          \"SELECT 2, 'stat', '', 0, '', 0\"\n      );\n    }else if( rc==SQLITE_ERROR ){\n      zPragma = sqlite3_mprintf(\"\");\n    }else{\n      return rc;\n    }\n  }else{\n    zPragma = sqlite3_mprintf(\"PRAGMA '%q'.table_info('%q')\", zDb, zThis);\n  }\n  if( !zPragma ) return SQLITE_NOMEM;\n\n  rc = sqlite3_prepare_v2(db, zPragma, -1, &pStmt, 0);\n  sqlite3_free(zPragma);\n  if( rc!=SQLITE_OK ) return rc;\n\n  nByte = nThis + 1;\n  while( SQLITE_ROW==sqlite3_step(pStmt) ){\n    nByte += sqlite3_column_bytes(pStmt, 1);\n    nDbCol++;\n  }\n  rc = sqlite3_reset(pStmt);\n\n  if( rc==SQLITE_OK ){\n    nByte += nDbCol * (sizeof(const char *) + sizeof(u8) + 1);\n    pAlloc = sqlite3_malloc64(nByte);\n    if( pAlloc==0 ){\n      rc = SQLITE_NOMEM;\n    }\n  }\n  if( rc==SQLITE_OK ){\n    azCol = (char **)pAlloc;\n    pAlloc = (u8 *)&azCol[nDbCol];\n    abPK = (u8 *)pAlloc;\n    pAlloc = &abPK[nDbCol];\n    if( pzTab ){\n      memcpy(pAlloc, zThis, nThis+1);\n      *pzTab = (char *)pAlloc;\n      pAlloc += nThis+1;\n    }\n  \n    i = 0;\n    while( SQLITE_ROW==sqlite3_step(pStmt) ){\n      int nName = sqlite3_column_bytes(pStmt, 1);\n      const unsigned char *zName = sqlite3_column_text(pStmt, 1);\n      if( zName==0 ) break;\n      memcpy(pAlloc, zName, nName+1);\n      azCol[i] = (char *)pAlloc;\n      pAlloc += nName+1;\n      abPK[i] = sqlite3_column_int(pStmt, 5);\n      i++;\n    }\n    rc = sqlite3_reset(pStmt);\n  \n  }\n\n  /* If successful, populate the output variables. Otherwise, zero them and\n  ** free any allocation made. An error code will be returned in this case.\n  */\n  if( rc==SQLITE_OK ){\n    *pazCol = (const char **)azCol;\n    *pabPK = abPK;\n    *pnCol = nDbCol;\n  }else{\n    *pazCol = 0;\n    *pabPK = 0;\n    *pnCol = 0;\n    if( pzTab ) *pzTab = 0;\n    sqlite3_free(azCol);\n  }\n  sqlite3_finalize(pStmt);\n  return rc;\n}\n\n/*\n** This function is only called from within a pre-update handler for a\n** write to table pTab, part of session pSession. If this is the first\n** write to this table, initalize the SessionTable.nCol, azCol[] and\n** abPK[] arrays accordingly.\n**\n** If an error occurs, an error code is stored in sqlite3_session.rc and\n** non-zero returned. Or, if no error occurs but the table has no primary\n** key, sqlite3_session.rc is left set to SQLITE_OK and non-zero returned to\n** indicate that updates on this table should be ignored. SessionTable.abPK \n** is set to NULL in this case.\n*/\nstatic int sessionInitTable(sqlite3_session *pSession, SessionTable *pTab){\n  if( pTab->nCol==0 ){\n    u8 *abPK;\n    assert( pTab->azCol==0 || pTab->abPK==0 );\n    pSession->rc = sessionTableInfo(pSession->db, pSession->zDb, \n        pTab->zName, &pTab->nCol, 0, &pTab->azCol, &abPK\n    );\n    if( pSession->rc==SQLITE_OK ){\n      int i;\n      for(i=0; i<pTab->nCol; i++){\n        if( abPK[i] ){\n          pTab->abPK = abPK;\n          break;\n        }\n      }\n      if( 0==sqlite3_stricmp(\"sqlite_stat1\", pTab->zName) ){\n        pTab->bStat1 = 1;\n      }\n    }\n  }\n  return (pSession->rc || pTab->abPK==0);\n}\n\n/*\n** Versions of the four methods in object SessionHook for use with the\n** sqlite_stat1 table. The purpose of this is to substitute a zero-length\n** blob each time a NULL value is read from the \"idx\" column of the\n** sqlite_stat1 table.\n*/\ntypedef struct SessionStat1Ctx SessionStat1Ctx;\nstruct SessionStat1Ctx {\n  SessionHook hook;\n  sqlite3_session *pSession;\n};\nstatic int sessionStat1Old(void *pCtx, int iCol, sqlite3_value **ppVal){\n  SessionStat1Ctx *p = (SessionStat1Ctx*)pCtx;\n  sqlite3_value *pVal = 0;\n  int rc = p->hook.xOld(p->hook.pCtx, iCol, &pVal);\n  if( rc==SQLITE_OK && iCol==1 && sqlite3_value_type(pVal)==SQLITE_NULL ){\n    pVal = p->pSession->pZeroBlob;\n  }\n  *ppVal = pVal;\n  return rc;\n}\nstatic int sessionStat1New(void *pCtx, int iCol, sqlite3_value **ppVal){\n  SessionStat1Ctx *p = (SessionStat1Ctx*)pCtx;\n  sqlite3_value *pVal = 0;\n  int rc = p->hook.xNew(p->hook.pCtx, iCol, &pVal);\n  if( rc==SQLITE_OK && iCol==1 && sqlite3_value_type(pVal)==SQLITE_NULL ){\n    pVal = p->pSession->pZeroBlob;\n  }\n  *ppVal = pVal;\n  return rc;\n}\nstatic int sessionStat1Count(void *pCtx){\n  SessionStat1Ctx *p = (SessionStat1Ctx*)pCtx;\n  return p->hook.xCount(p->hook.pCtx);\n}\nstatic int sessionStat1Depth(void *pCtx){\n  SessionStat1Ctx *p = (SessionStat1Ctx*)pCtx;\n  return p->hook.xDepth(p->hook.pCtx);\n}\n\n\n/*\n** This function is only called from with a pre-update-hook reporting a \n** change on table pTab (attached to session pSession). The type of change\n** (UPDATE, INSERT, DELETE) is specified by the first argument.\n**\n** Unless one is already present or an error occurs, an entry is added\n** to the changed-rows hash table associated with table pTab.\n*/\nstatic void sessionPreupdateOneChange(\n  int op,                         /* One of SQLITE_UPDATE, INSERT, DELETE */\n  sqlite3_session *pSession,      /* Session object pTab is attached to */\n  SessionTable *pTab              /* Table that change applies to */\n){\n  int iHash; \n  int bNull = 0; \n  int rc = SQLITE_OK;\n  SessionStat1Ctx stat1 = {{0,0,0,0,0},0};\n\n  if( pSession->rc ) return;\n\n  /* Load table details if required */\n  if( sessionInitTable(pSession, pTab) ) return;\n\n  /* Check the number of columns in this xPreUpdate call matches the \n  ** number of columns in the table.  */\n  if( pTab->nCol!=pSession->hook.xCount(pSession->hook.pCtx) ){\n    pSession->rc = SQLITE_SCHEMA;\n    return;\n  }\n\n  /* Grow the hash table if required */\n  if( sessionGrowHash(0, pTab) ){\n    pSession->rc = SQLITE_NOMEM;\n    return;\n  }\n\n  if( pTab->bStat1 ){\n    stat1.hook = pSession->hook;\n    stat1.pSession = pSession;\n    pSession->hook.pCtx = (void*)&stat1;\n    pSession->hook.xNew = sessionStat1New;\n    pSession->hook.xOld = sessionStat1Old;\n    pSession->hook.xCount = sessionStat1Count;\n    pSession->hook.xDepth = sessionStat1Depth;\n    if( pSession->pZeroBlob==0 ){\n      sqlite3_value *p = sqlite3ValueNew(0);\n      if( p==0 ){\n        rc = SQLITE_NOMEM;\n        goto error_out;\n      }\n      sqlite3ValueSetStr(p, 0, \"\", 0, SQLITE_STATIC);\n      pSession->pZeroBlob = p;\n    }\n  }\n\n  /* Calculate the hash-key for this change. If the primary key of the row\n  ** includes a NULL value, exit early. Such changes are ignored by the\n  ** session module. */\n  rc = sessionPreupdateHash(pSession, pTab, op==SQLITE_INSERT, &iHash, &bNull);\n  if( rc!=SQLITE_OK ) goto error_out;\n\n  if( bNull==0 ){\n    /* Search the hash table for an existing record for this row. */\n    SessionChange *pC;\n    for(pC=pTab->apChange[iHash]; pC; pC=pC->pNext){\n      if( sessionPreupdateEqual(pSession, pTab, pC, op) ) break;\n    }\n\n    if( pC==0 ){\n      /* Create a new change object containing all the old values (if\n      ** this is an SQLITE_UPDATE or SQLITE_DELETE), or just the PK\n      ** values (if this is an INSERT). */\n      SessionChange *pChange; /* New change object */\n      sqlite3_int64 nByte;    /* Number of bytes to allocate */\n      int i;                  /* Used to iterate through columns */\n  \n      assert( rc==SQLITE_OK );\n      pTab->nEntry++;\n  \n      /* Figure out how large an allocation is required */\n      nByte = sizeof(SessionChange);\n      for(i=0; i<pTab->nCol; i++){\n        sqlite3_value *p = 0;\n        if( op!=SQLITE_INSERT ){\n          TESTONLY(int trc = ) pSession->hook.xOld(pSession->hook.pCtx, i, &p);\n          assert( trc==SQLITE_OK );\n        }else if( pTab->abPK[i] ){\n          TESTONLY(int trc = ) pSession->hook.xNew(pSession->hook.pCtx, i, &p);\n          assert( trc==SQLITE_OK );\n        }\n\n        /* This may fail if SQLite value p contains a utf-16 string that must\n        ** be converted to utf-8 and an OOM error occurs while doing so. */\n        rc = sessionSerializeValue(0, p, &nByte);\n        if( rc!=SQLITE_OK ) goto error_out;\n      }\n  \n      /* Allocate the change object */\n      pChange = (SessionChange *)sqlite3_malloc64(nByte);\n      if( !pChange ){\n        rc = SQLITE_NOMEM;\n        goto error_out;\n      }else{\n        memset(pChange, 0, sizeof(SessionChange));\n        pChange->aRecord = (u8 *)&pChange[1];\n      }\n  \n      /* Populate the change object. None of the preupdate_old(),\n      ** preupdate_new() or SerializeValue() calls below may fail as all\n      ** required values and encodings have already been cached in memory.\n      ** It is not possible for an OOM to occur in this block. */\n      nByte = 0;\n      for(i=0; i<pTab->nCol; i++){\n        sqlite3_value *p = 0;\n        if( op!=SQLITE_INSERT ){\n          pSession->hook.xOld(pSession->hook.pCtx, i, &p);\n        }else if( pTab->abPK[i] ){\n          pSession->hook.xNew(pSession->hook.pCtx, i, &p);\n        }\n        sessionSerializeValue(&pChange->aRecord[nByte], p, &nByte);\n      }\n\n      /* Add the change to the hash-table */\n      if( pSession->bIndirect || pSession->hook.xDepth(pSession->hook.pCtx) ){\n        pChange->bIndirect = 1;\n      }\n      pChange->nRecord = nByte;\n      pChange->op = op;\n      pChange->pNext = pTab->apChange[iHash];\n      pTab->apChange[iHash] = pChange;\n\n    }else if( pC->bIndirect ){\n      /* If the existing change is considered \"indirect\", but this current\n      ** change is \"direct\", mark the change object as direct. */\n      if( pSession->hook.xDepth(pSession->hook.pCtx)==0 \n       && pSession->bIndirect==0 \n      ){\n        pC->bIndirect = 0;\n      }\n    }\n  }\n\n  /* If an error has occurred, mark the session object as failed. */\n error_out:\n  if( pTab->bStat1 ){\n    pSession->hook = stat1.hook;\n  }\n  if( rc!=SQLITE_OK ){\n    pSession->rc = rc;\n  }\n}\n\nstatic int sessionFindTable(\n  sqlite3_session *pSession, \n  const char *zName,\n  SessionTable **ppTab\n){\n  int rc = SQLITE_OK;\n  int nName = sqlite3Strlen30(zName);\n  SessionTable *pRet;\n\n  /* Search for an existing table */\n  for(pRet=pSession->pTable; pRet; pRet=pRet->pNext){\n    if( 0==sqlite3_strnicmp(pRet->zName, zName, nName+1) ) break;\n  }\n\n  if( pRet==0 && pSession->bAutoAttach ){\n    /* If there is a table-filter configured, invoke it. If it returns 0,\n    ** do not automatically add the new table. */\n    if( pSession->xTableFilter==0\n     || pSession->xTableFilter(pSession->pFilterCtx, zName) \n    ){\n      rc = sqlite3session_attach(pSession, zName);\n      if( rc==SQLITE_OK ){\n        for(pRet=pSession->pTable; pRet->pNext; pRet=pRet->pNext);\n        assert( 0==sqlite3_strnicmp(pRet->zName, zName, nName+1) );\n      }\n    }\n  }\n\n  assert( rc==SQLITE_OK || pRet==0 );\n  *ppTab = pRet;\n  return rc;\n}\n\n/*\n** The 'pre-update' hook registered by this module with SQLite databases.\n*/\nstatic void xPreUpdate(\n  void *pCtx,                     /* Copy of third arg to preupdate_hook() */\n  sqlite3 *db,                    /* Database handle */\n  int op,                         /* SQLITE_UPDATE, DELETE or INSERT */\n  char const *zDb,                /* Database name */\n  char const *zName,              /* Table name */\n  sqlite3_int64 iKey1,            /* Rowid of row about to be deleted/updated */\n  sqlite3_int64 iKey2             /* New rowid value (for a rowid UPDATE) */\n){\n  sqlite3_session *pSession;\n  int nDb = sqlite3Strlen30(zDb);\n\n  assert( sqlite3_mutex_held(db->mutex) );\n\n  for(pSession=(sqlite3_session *)pCtx; pSession; pSession=pSession->pNext){\n    SessionTable *pTab;\n\n    /* If this session is attached to a different database (\"main\", \"temp\" \n    ** etc.), or if it is not currently enabled, there is nothing to do. Skip \n    ** to the next session object attached to this database. */\n    if( pSession->bEnable==0 ) continue;\n    if( pSession->rc ) continue;\n    if( sqlite3_strnicmp(zDb, pSession->zDb, nDb+1) ) continue;\n\n    pSession->rc = sessionFindTable(pSession, zName, &pTab);\n    if( pTab ){\n      assert( pSession->rc==SQLITE_OK );\n      sessionPreupdateOneChange(op, pSession, pTab);\n      if( op==SQLITE_UPDATE ){\n        sessionPreupdateOneChange(SQLITE_INSERT, pSession, pTab);\n      }\n    }\n  }\n}\n\n/*\n** The pre-update hook implementations.\n*/\nstatic int sessionPreupdateOld(void *pCtx, int iVal, sqlite3_value **ppVal){\n  return sqlite3_preupdate_old((sqlite3*)pCtx, iVal, ppVal);\n}\nstatic int sessionPreupdateNew(void *pCtx, int iVal, sqlite3_value **ppVal){\n  return sqlite3_preupdate_new((sqlite3*)pCtx, iVal, ppVal);\n}\nstatic int sessionPreupdateCount(void *pCtx){\n  return sqlite3_preupdate_count((sqlite3*)pCtx);\n}\nstatic int sessionPreupdateDepth(void *pCtx){\n  return sqlite3_preupdate_depth((sqlite3*)pCtx);\n}\n\n/*\n** Install the pre-update hooks on the session object passed as the only\n** argument.\n*/\nstatic void sessionPreupdateHooks(\n  sqlite3_session *pSession\n){\n  pSession->hook.pCtx = (void*)pSession->db;\n  pSession->hook.xOld = sessionPreupdateOld;\n  pSession->hook.xNew = sessionPreupdateNew;\n  pSession->hook.xCount = sessionPreupdateCount;\n  pSession->hook.xDepth = sessionPreupdateDepth;\n}\n\ntypedef struct SessionDiffCtx SessionDiffCtx;\nstruct SessionDiffCtx {\n  sqlite3_stmt *pStmt;\n  int nOldOff;\n};\n\n/*\n** The diff hook implementations.\n*/\nstatic int sessionDiffOld(void *pCtx, int iVal, sqlite3_value **ppVal){\n  SessionDiffCtx *p = (SessionDiffCtx*)pCtx;\n  *ppVal = sqlite3_column_value(p->pStmt, iVal+p->nOldOff);\n  return SQLITE_OK;\n}\nstatic int sessionDiffNew(void *pCtx, int iVal, sqlite3_value **ppVal){\n  SessionDiffCtx *p = (SessionDiffCtx*)pCtx;\n  *ppVal = sqlite3_column_value(p->pStmt, iVal);\n   return SQLITE_OK;\n}\nstatic int sessionDiffCount(void *pCtx){\n  SessionDiffCtx *p = (SessionDiffCtx*)pCtx;\n  return p->nOldOff ? p->nOldOff : sqlite3_column_count(p->pStmt);\n}\nstatic int sessionDiffDepth(void *pCtx){\n  return 0;\n}\n\n/*\n** Install the diff hooks on the session object passed as the only\n** argument.\n*/\nstatic void sessionDiffHooks(\n  sqlite3_session *pSession,\n  SessionDiffCtx *pDiffCtx\n){\n  pSession->hook.pCtx = (void*)pDiffCtx;\n  pSession->hook.xOld = sessionDiffOld;\n  pSession->hook.xNew = sessionDiffNew;\n  pSession->hook.xCount = sessionDiffCount;\n  pSession->hook.xDepth = sessionDiffDepth;\n}\n\nstatic char *sessionExprComparePK(\n  int nCol,\n  const char *zDb1, const char *zDb2, \n  const char *zTab,\n  const char **azCol, u8 *abPK\n){\n  int i;\n  const char *zSep = \"\";\n  char *zRet = 0;\n\n  for(i=0; i<nCol; i++){\n    if( abPK[i] ){\n      zRet = sqlite3_mprintf(\"%z%s\\\"%w\\\".\\\"%w\\\".\\\"%w\\\"=\\\"%w\\\".\\\"%w\\\".\\\"%w\\\"\",\n          zRet, zSep, zDb1, zTab, azCol[i], zDb2, zTab, azCol[i]\n      );\n      zSep = \" AND \";\n      if( zRet==0 ) break;\n    }\n  }\n\n  return zRet;\n}\n\nstatic char *sessionExprCompareOther(\n  int nCol,\n  const char *zDb1, const char *zDb2, \n  const char *zTab,\n  const char **azCol, u8 *abPK\n){\n  int i;\n  const char *zSep = \"\";\n  char *zRet = 0;\n  int bHave = 0;\n\n  for(i=0; i<nCol; i++){\n    if( abPK[i]==0 ){\n      bHave = 1;\n      zRet = sqlite3_mprintf(\n          \"%z%s\\\"%w\\\".\\\"%w\\\".\\\"%w\\\" IS NOT \\\"%w\\\".\\\"%w\\\".\\\"%w\\\"\",\n          zRet, zSep, zDb1, zTab, azCol[i], zDb2, zTab, azCol[i]\n      );\n      zSep = \" OR \";\n      if( zRet==0 ) break;\n    }\n  }\n\n  if( bHave==0 ){\n    assert( zRet==0 );\n    zRet = sqlite3_mprintf(\"0\");\n  }\n\n  return zRet;\n}\n\nstatic char *sessionSelectFindNew(\n  int nCol,\n  const char *zDb1,      /* Pick rows in this db only */\n  const char *zDb2,      /* But not in this one */\n  const char *zTbl,      /* Table name */\n  const char *zExpr\n){\n  char *zRet = sqlite3_mprintf(\n      \"SELECT * FROM \\\"%w\\\".\\\"%w\\\" WHERE NOT EXISTS (\"\n      \"  SELECT 1 FROM \\\"%w\\\".\\\"%w\\\" WHERE %s\"\n      \")\",\n      zDb1, zTbl, zDb2, zTbl, zExpr\n  );\n  return zRet;\n}\n\nstatic int sessionDiffFindNew(\n  int op,\n  sqlite3_session *pSession,\n  SessionTable *pTab,\n  const char *zDb1,\n  const char *zDb2,\n  char *zExpr\n){\n  int rc = SQLITE_OK;\n  char *zStmt = sessionSelectFindNew(pTab->nCol, zDb1, zDb2, pTab->zName,zExpr);\n\n  if( zStmt==0 ){\n    rc = SQLITE_NOMEM;\n  }else{\n    sqlite3_stmt *pStmt;\n    rc = sqlite3_prepare(pSession->db, zStmt, -1, &pStmt, 0);\n    if( rc==SQLITE_OK ){\n      SessionDiffCtx *pDiffCtx = (SessionDiffCtx*)pSession->hook.pCtx;\n      pDiffCtx->pStmt = pStmt;\n      pDiffCtx->nOldOff = 0;\n      while( SQLITE_ROW==sqlite3_step(pStmt) ){\n        sessionPreupdateOneChange(op, pSession, pTab);\n      }\n      rc = sqlite3_finalize(pStmt);\n    }\n    sqlite3_free(zStmt);\n  }\n\n  return rc;\n}\n\nstatic int sessionDiffFindModified(\n  sqlite3_session *pSession, \n  SessionTable *pTab, \n  const char *zFrom, \n  const char *zExpr\n){\n  int rc = SQLITE_OK;\n\n  char *zExpr2 = sessionExprCompareOther(pTab->nCol,\n      pSession->zDb, zFrom, pTab->zName, pTab->azCol, pTab->abPK\n  );\n  if( zExpr2==0 ){\n    rc = SQLITE_NOMEM;\n  }else{\n    char *zStmt = sqlite3_mprintf(\n        \"SELECT * FROM \\\"%w\\\".\\\"%w\\\", \\\"%w\\\".\\\"%w\\\" WHERE %s AND (%z)\",\n        pSession->zDb, pTab->zName, zFrom, pTab->zName, zExpr, zExpr2\n    );\n    if( zStmt==0 ){\n      rc = SQLITE_NOMEM;\n    }else{\n      sqlite3_stmt *pStmt;\n      rc = sqlite3_prepare(pSession->db, zStmt, -1, &pStmt, 0);\n\n      if( rc==SQLITE_OK ){\n        SessionDiffCtx *pDiffCtx = (SessionDiffCtx*)pSession->hook.pCtx;\n        pDiffCtx->pStmt = pStmt;\n        pDiffCtx->nOldOff = pTab->nCol;\n        while( SQLITE_ROW==sqlite3_step(pStmt) ){\n          sessionPreupdateOneChange(SQLITE_UPDATE, pSession, pTab);\n        }\n        rc = sqlite3_finalize(pStmt);\n      }\n      sqlite3_free(zStmt);\n    }\n  }\n\n  return rc;\n}\n\nSQLITE_API int sqlite3session_diff(\n  sqlite3_session *pSession,\n  const char *zFrom,\n  const char *zTbl,\n  char **pzErrMsg\n){\n  const char *zDb = pSession->zDb;\n  int rc = pSession->rc;\n  SessionDiffCtx d;\n\n  memset(&d, 0, sizeof(d));\n  sessionDiffHooks(pSession, &d);\n\n  sqlite3_mutex_enter(sqlite3_db_mutex(pSession->db));\n  if( pzErrMsg ) *pzErrMsg = 0;\n  if( rc==SQLITE_OK ){\n    char *zExpr = 0;\n    sqlite3 *db = pSession->db;\n    SessionTable *pTo;            /* Table zTbl */\n\n    /* Locate and if necessary initialize the target table object */\n    rc = sessionFindTable(pSession, zTbl, &pTo);\n    if( pTo==0 ) goto diff_out;\n    if( sessionInitTable(pSession, pTo) ){\n      rc = pSession->rc;\n      goto diff_out;\n    }\n\n    /* Check the table schemas match */\n    if( rc==SQLITE_OK ){\n      int bHasPk = 0;\n      int bMismatch = 0;\n      int nCol;                   /* Columns in zFrom.zTbl */\n      u8 *abPK;\n      const char **azCol = 0;\n      rc = sessionTableInfo(db, zFrom, zTbl, &nCol, 0, &azCol, &abPK);\n      if( rc==SQLITE_OK ){\n        if( pTo->nCol!=nCol ){\n          bMismatch = 1;\n        }else{\n          int i;\n          for(i=0; i<nCol; i++){\n            if( pTo->abPK[i]!=abPK[i] ) bMismatch = 1;\n            if( sqlite3_stricmp(azCol[i], pTo->azCol[i]) ) bMismatch = 1;\n            if( abPK[i] ) bHasPk = 1;\n          }\n        }\n      }\n      sqlite3_free((char*)azCol);\n      if( bMismatch ){\n        *pzErrMsg = sqlite3_mprintf(\"table schemas do not match\");\n        rc = SQLITE_SCHEMA;\n      }\n      if( bHasPk==0 ){\n        /* Ignore tables with no primary keys */\n        goto diff_out;\n      }\n    }\n\n    if( rc==SQLITE_OK ){\n      zExpr = sessionExprComparePK(pTo->nCol, \n          zDb, zFrom, pTo->zName, pTo->azCol, pTo->abPK\n      );\n    }\n\n    /* Find new rows */\n    if( rc==SQLITE_OK ){\n      rc = sessionDiffFindNew(SQLITE_INSERT, pSession, pTo, zDb, zFrom, zExpr);\n    }\n\n    /* Find old rows */\n    if( rc==SQLITE_OK ){\n      rc = sessionDiffFindNew(SQLITE_DELETE, pSession, pTo, zFrom, zDb, zExpr);\n    }\n\n    /* Find modified rows */\n    if( rc==SQLITE_OK ){\n      rc = sessionDiffFindModified(pSession, pTo, zFrom, zExpr);\n    }\n\n    sqlite3_free(zExpr);\n  }\n\n diff_out:\n  sessionPreupdateHooks(pSession);\n  sqlite3_mutex_leave(sqlite3_db_mutex(pSession->db));\n  return rc;\n}\n\n/*\n** Create a session object. This session object will record changes to\n** database zDb attached to connection db.\n*/\nSQLITE_API int sqlite3session_create(\n  sqlite3 *db,                    /* Database handle */\n  const char *zDb,                /* Name of db (e.g. \"main\") */\n  sqlite3_session **ppSession     /* OUT: New session object */\n){\n  sqlite3_session *pNew;          /* Newly allocated session object */\n  sqlite3_session *pOld;          /* Session object already attached to db */\n  int nDb = sqlite3Strlen30(zDb); /* Length of zDb in bytes */\n\n  /* Zero the output value in case an error occurs. */\n  *ppSession = 0;\n\n  /* Allocate and populate the new session object. */\n  pNew = (sqlite3_session *)sqlite3_malloc64(sizeof(sqlite3_session) + nDb + 1);\n  if( !pNew ) return SQLITE_NOMEM;\n  memset(pNew, 0, sizeof(sqlite3_session));\n  pNew->db = db;\n  pNew->zDb = (char *)&pNew[1];\n  pNew->bEnable = 1;\n  memcpy(pNew->zDb, zDb, nDb+1);\n  sessionPreupdateHooks(pNew);\n\n  /* Add the new session object to the linked list of session objects \n  ** attached to database handle $db. Do this under the cover of the db\n  ** handle mutex.  */\n  sqlite3_mutex_enter(sqlite3_db_mutex(db));\n  pOld = (sqlite3_session*)sqlite3_preupdate_hook(db, xPreUpdate, (void*)pNew);\n  pNew->pNext = pOld;\n  sqlite3_mutex_leave(sqlite3_db_mutex(db));\n\n  *ppSession = pNew;\n  return SQLITE_OK;\n}\n\n/*\n** Free the list of table objects passed as the first argument. The contents\n** of the changed-rows hash tables are also deleted.\n*/\nstatic void sessionDeleteTable(SessionTable *pList){\n  SessionTable *pNext;\n  SessionTable *pTab;\n\n  for(pTab=pList; pTab; pTab=pNext){\n    int i;\n    pNext = pTab->pNext;\n    for(i=0; i<pTab->nChange; i++){\n      SessionChange *p;\n      SessionChange *pNextChange;\n      for(p=pTab->apChange[i]; p; p=pNextChange){\n        pNextChange = p->pNext;\n        sqlite3_free(p);\n      }\n    }\n    sqlite3_free((char*)pTab->azCol);  /* cast works around VC++ bug */\n    sqlite3_free(pTab->apChange);\n    sqlite3_free(pTab);\n  }\n}\n\n/*\n** Delete a session object previously allocated using sqlite3session_create().\n*/\nSQLITE_API void sqlite3session_delete(sqlite3_session *pSession){\n  sqlite3 *db = pSession->db;\n  sqlite3_session *pHead;\n  sqlite3_session **pp;\n\n  /* Unlink the session from the linked list of sessions attached to the\n  ** database handle. Hold the db mutex while doing so.  */\n  sqlite3_mutex_enter(sqlite3_db_mutex(db));\n  pHead = (sqlite3_session*)sqlite3_preupdate_hook(db, 0, 0);\n  for(pp=&pHead; ALWAYS((*pp)!=0); pp=&((*pp)->pNext)){\n    if( (*pp)==pSession ){\n      *pp = (*pp)->pNext;\n      if( pHead ) sqlite3_preupdate_hook(db, xPreUpdate, (void*)pHead);\n      break;\n    }\n  }\n  sqlite3_mutex_leave(sqlite3_db_mutex(db));\n  sqlite3ValueFree(pSession->pZeroBlob);\n\n  /* Delete all attached table objects. And the contents of their \n  ** associated hash-tables. */\n  sessionDeleteTable(pSession->pTable);\n\n  /* Free the session object itself. */\n  sqlite3_free(pSession);\n}\n\n/*\n** Set a table filter on a Session Object.\n*/\nSQLITE_API void sqlite3session_table_filter(\n  sqlite3_session *pSession, \n  int(*xFilter)(void*, const char*),\n  void *pCtx                      /* First argument passed to xFilter */\n){\n  pSession->bAutoAttach = 1;\n  pSession->pFilterCtx = pCtx;\n  pSession->xTableFilter = xFilter;\n}\n\n/*\n** Attach a table to a session. All subsequent changes made to the table\n** while the session object is enabled will be recorded.\n**\n** Only tables that have a PRIMARY KEY defined may be attached. It does\n** not matter if the PRIMARY KEY is an \"INTEGER PRIMARY KEY\" (rowid alias)\n** or not.\n*/\nSQLITE_API int sqlite3session_attach(\n  sqlite3_session *pSession,      /* Session object */\n  const char *zName               /* Table name */\n){\n  int rc = SQLITE_OK;\n  sqlite3_mutex_enter(sqlite3_db_mutex(pSession->db));\n\n  if( !zName ){\n    pSession->bAutoAttach = 1;\n  }else{\n    SessionTable *pTab;           /* New table object (if required) */\n    int nName;                    /* Number of bytes in string zName */\n\n    /* First search for an existing entry. If one is found, this call is\n    ** a no-op. Return early. */\n    nName = sqlite3Strlen30(zName);\n    for(pTab=pSession->pTable; pTab; pTab=pTab->pNext){\n      if( 0==sqlite3_strnicmp(pTab->zName, zName, nName+1) ) break;\n    }\n\n    if( !pTab ){\n      /* Allocate new SessionTable object. */\n      pTab = (SessionTable *)sqlite3_malloc64(sizeof(SessionTable) + nName + 1);\n      if( !pTab ){\n        rc = SQLITE_NOMEM;\n      }else{\n        /* Populate the new SessionTable object and link it into the list.\n        ** The new object must be linked onto the end of the list, not \n        ** simply added to the start of it in order to ensure that tables\n        ** appear in the correct order when a changeset or patchset is\n        ** eventually generated. */\n        SessionTable **ppTab;\n        memset(pTab, 0, sizeof(SessionTable));\n        pTab->zName = (char *)&pTab[1];\n        memcpy(pTab->zName, zName, nName+1);\n        for(ppTab=&pSession->pTable; *ppTab; ppTab=&(*ppTab)->pNext);\n        *ppTab = pTab;\n      }\n    }\n  }\n\n  sqlite3_mutex_leave(sqlite3_db_mutex(pSession->db));\n  return rc;\n}\n\n/*\n** Ensure that there is room in the buffer to append nByte bytes of data.\n** If not, use sqlite3_realloc() to grow the buffer so that there is.\n**\n** If successful, return zero. Otherwise, if an OOM condition is encountered,\n** set *pRc to SQLITE_NOMEM and return non-zero.\n*/\nstatic int sessionBufferGrow(SessionBuffer *p, int nByte, int *pRc){\n  if( *pRc==SQLITE_OK && p->nAlloc-p->nBuf<nByte ){\n    u8 *aNew;\n    i64 nNew = p->nAlloc ? p->nAlloc : 128;\n    do {\n      nNew = nNew*2;\n    }while( (nNew-p->nBuf)<nByte );\n\n    aNew = (u8 *)sqlite3_realloc64(p->aBuf, nNew);\n    if( 0==aNew ){\n      *pRc = SQLITE_NOMEM;\n    }else{\n      p->aBuf = aNew;\n      p->nAlloc = nNew;\n    }\n  }\n  return (*pRc!=SQLITE_OK);\n}\n\n/*\n** Append the value passed as the second argument to the buffer passed\n** as the first.\n**\n** This function is a no-op if *pRc is non-zero when it is called.\n** Otherwise, if an error occurs, *pRc is set to an SQLite error code\n** before returning.\n*/\nstatic void sessionAppendValue(SessionBuffer *p, sqlite3_value *pVal, int *pRc){\n  int rc = *pRc;\n  if( rc==SQLITE_OK ){\n    sqlite3_int64 nByte = 0;\n    rc = sessionSerializeValue(0, pVal, &nByte);\n    sessionBufferGrow(p, nByte, &rc);\n    if( rc==SQLITE_OK ){\n      rc = sessionSerializeValue(&p->aBuf[p->nBuf], pVal, 0);\n      p->nBuf += nByte;\n    }else{\n      *pRc = rc;\n    }\n  }\n}\n\n/*\n** This function is a no-op if *pRc is other than SQLITE_OK when it is \n** called. Otherwise, append a single byte to the buffer. \n**\n** If an OOM condition is encountered, set *pRc to SQLITE_NOMEM before\n** returning.\n*/\nstatic void sessionAppendByte(SessionBuffer *p, u8 v, int *pRc){\n  if( 0==sessionBufferGrow(p, 1, pRc) ){\n    p->aBuf[p->nBuf++] = v;\n  }\n}\n\n/*\n** This function is a no-op if *pRc is other than SQLITE_OK when it is \n** called. Otherwise, append a single varint to the buffer. \n**\n** If an OOM condition is encountered, set *pRc to SQLITE_NOMEM before\n** returning.\n*/\nstatic void sessionAppendVarint(SessionBuffer *p, int v, int *pRc){\n  if( 0==sessionBufferGrow(p, 9, pRc) ){\n    p->nBuf += sessionVarintPut(&p->aBuf[p->nBuf], v);\n  }\n}\n\n/*\n** This function is a no-op if *pRc is other than SQLITE_OK when it is \n** called. Otherwise, append a blob of data to the buffer. \n**\n** If an OOM condition is encountered, set *pRc to SQLITE_NOMEM before\n** returning.\n*/\nstatic void sessionAppendBlob(\n  SessionBuffer *p, \n  const u8 *aBlob, \n  int nBlob, \n  int *pRc\n){\n  if( nBlob>0 && 0==sessionBufferGrow(p, nBlob, pRc) ){\n    memcpy(&p->aBuf[p->nBuf], aBlob, nBlob);\n    p->nBuf += nBlob;\n  }\n}\n\n/*\n** This function is a no-op if *pRc is other than SQLITE_OK when it is \n** called. Otherwise, append a string to the buffer. All bytes in the string\n** up to (but not including) the nul-terminator are written to the buffer.\n**\n** If an OOM condition is encountered, set *pRc to SQLITE_NOMEM before\n** returning.\n*/\nstatic void sessionAppendStr(\n  SessionBuffer *p, \n  const char *zStr, \n  int *pRc\n){\n  int nStr = sqlite3Strlen30(zStr);\n  if( 0==sessionBufferGrow(p, nStr, pRc) ){\n    memcpy(&p->aBuf[p->nBuf], zStr, nStr);\n    p->nBuf += nStr;\n  }\n}\n\n/*\n** This function is a no-op if *pRc is other than SQLITE_OK when it is \n** called. Otherwise, append the string representation of integer iVal\n** to the buffer. No nul-terminator is written.\n**\n** If an OOM condition is encountered, set *pRc to SQLITE_NOMEM before\n** returning.\n*/\nstatic void sessionAppendInteger(\n  SessionBuffer *p,               /* Buffer to append to */\n  int iVal,                       /* Value to write the string rep. of */\n  int *pRc                        /* IN/OUT: Error code */\n){\n  char aBuf[24];\n  sqlite3_snprintf(sizeof(aBuf)-1, aBuf, \"%d\", iVal);\n  sessionAppendStr(p, aBuf, pRc);\n}\n\n/*\n** This function is a no-op if *pRc is other than SQLITE_OK when it is \n** called. Otherwise, append the string zStr enclosed in quotes (\") and\n** with any embedded quote characters escaped to the buffer. No \n** nul-terminator byte is written.\n**\n** If an OOM condition is encountered, set *pRc to SQLITE_NOMEM before\n** returning.\n*/\nstatic void sessionAppendIdent(\n  SessionBuffer *p,               /* Buffer to a append to */\n  const char *zStr,               /* String to quote, escape and append */\n  int *pRc                        /* IN/OUT: Error code */\n){\n  int nStr = sqlite3Strlen30(zStr)*2 + 2 + 1;\n  if( 0==sessionBufferGrow(p, nStr, pRc) ){\n    char *zOut = (char *)&p->aBuf[p->nBuf];\n    const char *zIn = zStr;\n    *zOut++ = '\"';\n    while( *zIn ){\n      if( *zIn=='\"' ) *zOut++ = '\"';\n      *zOut++ = *(zIn++);\n    }\n    *zOut++ = '\"';\n    p->nBuf = (int)((u8 *)zOut - p->aBuf);\n  }\n}\n\n/*\n** This function is a no-op if *pRc is other than SQLITE_OK when it is\n** called. Otherwse, it appends the serialized version of the value stored\n** in column iCol of the row that SQL statement pStmt currently points\n** to to the buffer.\n*/\nstatic void sessionAppendCol(\n  SessionBuffer *p,               /* Buffer to append to */\n  sqlite3_stmt *pStmt,            /* Handle pointing to row containing value */\n  int iCol,                       /* Column to read value from */\n  int *pRc                        /* IN/OUT: Error code */\n){\n  if( *pRc==SQLITE_OK ){\n    int eType = sqlite3_column_type(pStmt, iCol);\n    sessionAppendByte(p, (u8)eType, pRc);\n    if( eType==SQLITE_INTEGER || eType==SQLITE_FLOAT ){\n      sqlite3_int64 i;\n      u8 aBuf[8];\n      if( eType==SQLITE_INTEGER ){\n        i = sqlite3_column_int64(pStmt, iCol);\n      }else{\n        double r = sqlite3_column_double(pStmt, iCol);\n        memcpy(&i, &r, 8);\n      }\n      sessionPutI64(aBuf, i);\n      sessionAppendBlob(p, aBuf, 8, pRc);\n    }\n    if( eType==SQLITE_BLOB || eType==SQLITE_TEXT ){\n      u8 *z;\n      int nByte;\n      if( eType==SQLITE_BLOB ){\n        z = (u8 *)sqlite3_column_blob(pStmt, iCol);\n      }else{\n        z = (u8 *)sqlite3_column_text(pStmt, iCol);\n      }\n      nByte = sqlite3_column_bytes(pStmt, iCol);\n      if( z || (eType==SQLITE_BLOB && nByte==0) ){\n        sessionAppendVarint(p, nByte, pRc);\n        sessionAppendBlob(p, z, nByte, pRc);\n      }else{\n        *pRc = SQLITE_NOMEM;\n      }\n    }\n  }\n}\n\n/*\n**\n** This function appends an update change to the buffer (see the comments \n** under \"CHANGESET FORMAT\" at the top of the file). An update change \n** consists of:\n**\n**   1 byte:  SQLITE_UPDATE (0x17)\n**   n bytes: old.* record (see RECORD FORMAT)\n**   m bytes: new.* record (see RECORD FORMAT)\n**\n** The SessionChange object passed as the third argument contains the\n** values that were stored in the row when the session began (the old.*\n** values). The statement handle passed as the second argument points\n** at the current version of the row (the new.* values).\n**\n** If all of the old.* values are equal to their corresponding new.* value\n** (i.e. nothing has changed), then no data at all is appended to the buffer.\n**\n** Otherwise, the old.* record contains all primary key values and the \n** original values of any fields that have been modified. The new.* record \n** contains the new values of only those fields that have been modified.\n*/ \nstatic int sessionAppendUpdate(\n  SessionBuffer *pBuf,            /* Buffer to append to */\n  int bPatchset,                  /* True for \"patchset\", 0 for \"changeset\" */\n  sqlite3_stmt *pStmt,            /* Statement handle pointing at new row */\n  SessionChange *p,               /* Object containing old values */\n  u8 *abPK                        /* Boolean array - true for PK columns */\n){\n  int rc = SQLITE_OK;\n  SessionBuffer buf2 = {0,0,0}; /* Buffer to accumulate new.* record in */\n  int bNoop = 1;                /* Set to zero if any values are modified */\n  int nRewind = pBuf->nBuf;     /* Set to zero if any values are modified */\n  int i;                        /* Used to iterate through columns */\n  u8 *pCsr = p->aRecord;        /* Used to iterate through old.* values */\n\n  sessionAppendByte(pBuf, SQLITE_UPDATE, &rc);\n  sessionAppendByte(pBuf, p->bIndirect, &rc);\n  for(i=0; i<sqlite3_column_count(pStmt); i++){\n    int bChanged = 0;\n    int nAdvance;\n    int eType = *pCsr;\n    switch( eType ){\n      case SQLITE_NULL:\n        nAdvance = 1;\n        if( sqlite3_column_type(pStmt, i)!=SQLITE_NULL ){\n          bChanged = 1;\n        }\n        break;\n\n      case SQLITE_FLOAT:\n      case SQLITE_INTEGER: {\n        nAdvance = 9;\n        if( eType==sqlite3_column_type(pStmt, i) ){\n          sqlite3_int64 iVal = sessionGetI64(&pCsr[1]);\n          if( eType==SQLITE_INTEGER ){\n            if( iVal==sqlite3_column_int64(pStmt, i) ) break;\n          }else{\n            double dVal;\n            memcpy(&dVal, &iVal, 8);\n            if( dVal==sqlite3_column_double(pStmt, i) ) break;\n          }\n        }\n        bChanged = 1;\n        break;\n      }\n\n      default: {\n        int n;\n        int nHdr = 1 + sessionVarintGet(&pCsr[1], &n);\n        assert( eType==SQLITE_TEXT || eType==SQLITE_BLOB );\n        nAdvance = nHdr + n;\n        if( eType==sqlite3_column_type(pStmt, i) \n         && n==sqlite3_column_bytes(pStmt, i) \n         && (n==0 || 0==memcmp(&pCsr[nHdr], sqlite3_column_blob(pStmt, i), n))\n        ){\n          break;\n        }\n        bChanged = 1;\n      }\n    }\n\n    /* If at least one field has been modified, this is not a no-op. */\n    if( bChanged ) bNoop = 0;\n\n    /* Add a field to the old.* record. This is omitted if this modules is\n    ** currently generating a patchset. */\n    if( bPatchset==0 ){\n      if( bChanged || abPK[i] ){\n        sessionAppendBlob(pBuf, pCsr, nAdvance, &rc);\n      }else{\n        sessionAppendByte(pBuf, 0, &rc);\n      }\n    }\n\n    /* Add a field to the new.* record. Or the only record if currently\n    ** generating a patchset.  */\n    if( bChanged || (bPatchset && abPK[i]) ){\n      sessionAppendCol(&buf2, pStmt, i, &rc);\n    }else{\n      sessionAppendByte(&buf2, 0, &rc);\n    }\n\n    pCsr += nAdvance;\n  }\n\n  if( bNoop ){\n    pBuf->nBuf = nRewind;\n  }else{\n    sessionAppendBlob(pBuf, buf2.aBuf, buf2.nBuf, &rc);\n  }\n  sqlite3_free(buf2.aBuf);\n\n  return rc;\n}\n\n/*\n** Append a DELETE change to the buffer passed as the first argument. Use\n** the changeset format if argument bPatchset is zero, or the patchset\n** format otherwise.\n*/\nstatic int sessionAppendDelete(\n  SessionBuffer *pBuf,            /* Buffer to append to */\n  int bPatchset,                  /* True for \"patchset\", 0 for \"changeset\" */\n  SessionChange *p,               /* Object containing old values */\n  int nCol,                       /* Number of columns in table */\n  u8 *abPK                        /* Boolean array - true for PK columns */\n){\n  int rc = SQLITE_OK;\n\n  sessionAppendByte(pBuf, SQLITE_DELETE, &rc);\n  sessionAppendByte(pBuf, p->bIndirect, &rc);\n\n  if( bPatchset==0 ){\n    sessionAppendBlob(pBuf, p->aRecord, p->nRecord, &rc);\n  }else{\n    int i;\n    u8 *a = p->aRecord;\n    for(i=0; i<nCol; i++){\n      u8 *pStart = a;\n      int eType = *a++;\n\n      switch( eType ){\n        case 0:\n        case SQLITE_NULL:\n          assert( abPK[i]==0 );\n          break;\n\n        case SQLITE_FLOAT:\n        case SQLITE_INTEGER:\n          a += 8;\n          break;\n\n        default: {\n          int n;\n          a += sessionVarintGet(a, &n);\n          a += n;\n          break;\n        }\n      }\n      if( abPK[i] ){\n        sessionAppendBlob(pBuf, pStart, (int)(a-pStart), &rc);\n      }\n    }\n    assert( (a - p->aRecord)==p->nRecord );\n  }\n\n  return rc;\n}\n\n/*\n** Formulate and prepare a SELECT statement to retrieve a row from table\n** zTab in database zDb based on its primary key. i.e.\n**\n**   SELECT * FROM zDb.zTab WHERE pk1 = ? AND pk2 = ? AND ...\n*/\nstatic int sessionSelectStmt(\n  sqlite3 *db,                    /* Database handle */\n  const char *zDb,                /* Database name */\n  const char *zTab,               /* Table name */\n  int nCol,                       /* Number of columns in table */\n  const char **azCol,             /* Names of table columns */\n  u8 *abPK,                       /* PRIMARY KEY  array */\n  sqlite3_stmt **ppStmt           /* OUT: Prepared SELECT statement */\n){\n  int rc = SQLITE_OK;\n  char *zSql = 0;\n  int nSql = -1;\n\n  if( 0==sqlite3_stricmp(\"sqlite_stat1\", zTab) ){\n    zSql = sqlite3_mprintf(\n        \"SELECT tbl, ?2, stat FROM %Q.sqlite_stat1 WHERE tbl IS ?1 AND \"\n        \"idx IS (CASE WHEN ?2=X'' THEN NULL ELSE ?2 END)\", zDb\n    );\n    if( zSql==0 ) rc = SQLITE_NOMEM;\n  }else{\n    int i;\n    const char *zSep = \"\";\n    SessionBuffer buf = {0, 0, 0};\n\n    sessionAppendStr(&buf, \"SELECT * FROM \", &rc);\n    sessionAppendIdent(&buf, zDb, &rc);\n    sessionAppendStr(&buf, \".\", &rc);\n    sessionAppendIdent(&buf, zTab, &rc);\n    sessionAppendStr(&buf, \" WHERE \", &rc);\n    for(i=0; i<nCol; i++){\n      if( abPK[i] ){\n        sessionAppendStr(&buf, zSep, &rc);\n        sessionAppendIdent(&buf, azCol[i], &rc);\n        sessionAppendStr(&buf, \" IS ?\", &rc);\n        sessionAppendInteger(&buf, i+1, &rc);\n        zSep = \" AND \";\n      }\n    }\n    zSql = (char*)buf.aBuf;\n    nSql = buf.nBuf;\n  }\n\n  if( rc==SQLITE_OK ){\n    rc = sqlite3_prepare_v2(db, zSql, nSql, ppStmt, 0);\n  }\n  sqlite3_free(zSql);\n  return rc;\n}\n\n/*\n** Bind the PRIMARY KEY values from the change passed in argument pChange\n** to the SELECT statement passed as the first argument. The SELECT statement\n** is as prepared by function sessionSelectStmt().\n**\n** Return SQLITE_OK if all PK values are successfully bound, or an SQLite\n** error code (e.g. SQLITE_NOMEM) otherwise.\n*/\nstatic int sessionSelectBind(\n  sqlite3_stmt *pSelect,          /* SELECT from sessionSelectStmt() */\n  int nCol,                       /* Number of columns in table */\n  u8 *abPK,                       /* PRIMARY KEY array */\n  SessionChange *pChange          /* Change structure */\n){\n  int i;\n  int rc = SQLITE_OK;\n  u8 *a = pChange->aRecord;\n\n  for(i=0; i<nCol && rc==SQLITE_OK; i++){\n    int eType = *a++;\n\n    switch( eType ){\n      case 0:\n      case SQLITE_NULL:\n        assert( abPK[i]==0 );\n        break;\n\n      case SQLITE_INTEGER: {\n        if( abPK[i] ){\n          i64 iVal = sessionGetI64(a);\n          rc = sqlite3_bind_int64(pSelect, i+1, iVal);\n        }\n        a += 8;\n        break;\n      }\n\n      case SQLITE_FLOAT: {\n        if( abPK[i] ){\n          double rVal;\n          i64 iVal = sessionGetI64(a);\n          memcpy(&rVal, &iVal, 8);\n          rc = sqlite3_bind_double(pSelect, i+1, rVal);\n        }\n        a += 8;\n        break;\n      }\n\n      case SQLITE_TEXT: {\n        int n;\n        a += sessionVarintGet(a, &n);\n        if( abPK[i] ){\n          rc = sqlite3_bind_text(pSelect, i+1, (char *)a, n, SQLITE_TRANSIENT);\n        }\n        a += n;\n        break;\n      }\n\n      default: {\n        int n;\n        assert( eType==SQLITE_BLOB );\n        a += sessionVarintGet(a, &n);\n        if( abPK[i] ){\n          rc = sqlite3_bind_blob(pSelect, i+1, a, n, SQLITE_TRANSIENT);\n        }\n        a += n;\n        break;\n      }\n    }\n  }\n\n  return rc;\n}\n\n/*\n** This function is a no-op if *pRc is set to other than SQLITE_OK when it\n** is called. Otherwise, append a serialized table header (part of the binary \n** changeset format) to buffer *pBuf. If an error occurs, set *pRc to an\n** SQLite error code before returning.\n*/\nstatic void sessionAppendTableHdr(\n  SessionBuffer *pBuf,            /* Append header to this buffer */\n  int bPatchset,                  /* Use the patchset format if true */\n  SessionTable *pTab,             /* Table object to append header for */\n  int *pRc                        /* IN/OUT: Error code */\n){\n  /* Write a table header */\n  sessionAppendByte(pBuf, (bPatchset ? 'P' : 'T'), pRc);\n  sessionAppendVarint(pBuf, pTab->nCol, pRc);\n  sessionAppendBlob(pBuf, pTab->abPK, pTab->nCol, pRc);\n  sessionAppendBlob(pBuf, (u8 *)pTab->zName, (int)strlen(pTab->zName)+1, pRc);\n}\n\n/*\n** Generate either a changeset (if argument bPatchset is zero) or a patchset\n** (if it is non-zero) based on the current contents of the session object\n** passed as the first argument.\n**\n** If no error occurs, SQLITE_OK is returned and the new changeset/patchset\n** stored in output variables *pnChangeset and *ppChangeset. Or, if an error\n** occurs, an SQLite error code is returned and both output variables set \n** to 0.\n*/\nstatic int sessionGenerateChangeset(\n  sqlite3_session *pSession,      /* Session object */\n  int bPatchset,                  /* True for patchset, false for changeset */\n  int (*xOutput)(void *pOut, const void *pData, int nData),\n  void *pOut,                     /* First argument for xOutput */\n  int *pnChangeset,               /* OUT: Size of buffer at *ppChangeset */\n  void **ppChangeset              /* OUT: Buffer containing changeset */\n){\n  sqlite3 *db = pSession->db;     /* Source database handle */\n  SessionTable *pTab;             /* Used to iterate through attached tables */\n  SessionBuffer buf = {0,0,0};    /* Buffer in which to accumlate changeset */\n  int rc;                         /* Return code */\n\n  assert( xOutput==0 || (pnChangeset==0 && ppChangeset==0 ) );\n\n  /* Zero the output variables in case an error occurs. If this session\n  ** object is already in the error state (sqlite3_session.rc != SQLITE_OK),\n  ** this call will be a no-op.  */\n  if( xOutput==0 ){\n    *pnChangeset = 0;\n    *ppChangeset = 0;\n  }\n\n  if( pSession->rc ) return pSession->rc;\n  rc = sqlite3_exec(pSession->db, \"SAVEPOINT changeset\", 0, 0, 0);\n  if( rc!=SQLITE_OK ) return rc;\n\n  sqlite3_mutex_enter(sqlite3_db_mutex(db));\n\n  for(pTab=pSession->pTable; rc==SQLITE_OK && pTab; pTab=pTab->pNext){\n    if( pTab->nEntry ){\n      const char *zName = pTab->zName;\n      int nCol;                   /* Number of columns in table */\n      u8 *abPK;                   /* Primary key array */\n      const char **azCol = 0;     /* Table columns */\n      int i;                      /* Used to iterate through hash buckets */\n      sqlite3_stmt *pSel = 0;     /* SELECT statement to query table pTab */\n      int nRewind = buf.nBuf;     /* Initial size of write buffer */\n      int nNoop;                  /* Size of buffer after writing tbl header */\n\n      /* Check the table schema is still Ok. */\n      rc = sessionTableInfo(db, pSession->zDb, zName, &nCol, 0, &azCol, &abPK);\n      if( !rc && (pTab->nCol!=nCol || memcmp(abPK, pTab->abPK, nCol)) ){\n        rc = SQLITE_SCHEMA;\n      }\n\n      /* Write a table header */\n      sessionAppendTableHdr(&buf, bPatchset, pTab, &rc);\n\n      /* Build and compile a statement to execute: */\n      if( rc==SQLITE_OK ){\n        rc = sessionSelectStmt(\n            db, pSession->zDb, zName, nCol, azCol, abPK, &pSel);\n      }\n\n      nNoop = buf.nBuf;\n      for(i=0; i<pTab->nChange && rc==SQLITE_OK; i++){\n        SessionChange *p;         /* Used to iterate through changes */\n\n        for(p=pTab->apChange[i]; rc==SQLITE_OK && p; p=p->pNext){\n          rc = sessionSelectBind(pSel, nCol, abPK, p);\n          if( rc!=SQLITE_OK ) continue;\n          if( sqlite3_step(pSel)==SQLITE_ROW ){\n            if( p->op==SQLITE_INSERT ){\n              int iCol;\n              sessionAppendByte(&buf, SQLITE_INSERT, &rc);\n              sessionAppendByte(&buf, p->bIndirect, &rc);\n              for(iCol=0; iCol<nCol; iCol++){\n                sessionAppendCol(&buf, pSel, iCol, &rc);\n              }\n            }else{\n              rc = sessionAppendUpdate(&buf, bPatchset, pSel, p, abPK);\n            }\n          }else if( p->op!=SQLITE_INSERT ){\n            rc = sessionAppendDelete(&buf, bPatchset, p, nCol, abPK);\n          }\n          if( rc==SQLITE_OK ){\n            rc = sqlite3_reset(pSel);\n          }\n\n          /* If the buffer is now larger than sessions_strm_chunk_size, pass\n          ** its contents to the xOutput() callback. */\n          if( xOutput \n           && rc==SQLITE_OK \n           && buf.nBuf>nNoop \n           && buf.nBuf>sessions_strm_chunk_size \n          ){\n            rc = xOutput(pOut, (void*)buf.aBuf, buf.nBuf);\n            nNoop = -1;\n            buf.nBuf = 0;\n          }\n\n        }\n      }\n\n      sqlite3_finalize(pSel);\n      if( buf.nBuf==nNoop ){\n        buf.nBuf = nRewind;\n      }\n      sqlite3_free((char*)azCol);  /* cast works around VC++ bug */\n    }\n  }\n\n  if( rc==SQLITE_OK ){\n    if( xOutput==0 ){\n      *pnChangeset = buf.nBuf;\n      *ppChangeset = buf.aBuf;\n      buf.aBuf = 0;\n    }else if( buf.nBuf>0 ){\n      rc = xOutput(pOut, (void*)buf.aBuf, buf.nBuf);\n    }\n  }\n\n  sqlite3_free(buf.aBuf);\n  sqlite3_exec(db, \"RELEASE changeset\", 0, 0, 0);\n  sqlite3_mutex_leave(sqlite3_db_mutex(db));\n  return rc;\n}\n\n/*\n** Obtain a changeset object containing all changes recorded by the \n** session object passed as the first argument.\n**\n** It is the responsibility of the caller to eventually free the buffer \n** using sqlite3_free().\n*/\nSQLITE_API int sqlite3session_changeset(\n  sqlite3_session *pSession,      /* Session object */\n  int *pnChangeset,               /* OUT: Size of buffer at *ppChangeset */\n  void **ppChangeset              /* OUT: Buffer containing changeset */\n){\n  return sessionGenerateChangeset(pSession, 0, 0, 0, pnChangeset, ppChangeset);\n}\n\n/*\n** Streaming version of sqlite3session_changeset().\n*/\nSQLITE_API int sqlite3session_changeset_strm(\n  sqlite3_session *pSession,\n  int (*xOutput)(void *pOut, const void *pData, int nData),\n  void *pOut\n){\n  return sessionGenerateChangeset(pSession, 0, xOutput, pOut, 0, 0);\n}\n\n/*\n** Streaming version of sqlite3session_patchset().\n*/\nSQLITE_API int sqlite3session_patchset_strm(\n  sqlite3_session *pSession,\n  int (*xOutput)(void *pOut, const void *pData, int nData),\n  void *pOut\n){\n  return sessionGenerateChangeset(pSession, 1, xOutput, pOut, 0, 0);\n}\n\n/*\n** Obtain a patchset object containing all changes recorded by the \n** session object passed as the first argument.\n**\n** It is the responsibility of the caller to eventually free the buffer \n** using sqlite3_free().\n*/\nSQLITE_API int sqlite3session_patchset(\n  sqlite3_session *pSession,      /* Session object */\n  int *pnPatchset,                /* OUT: Size of buffer at *ppChangeset */\n  void **ppPatchset               /* OUT: Buffer containing changeset */\n){\n  return sessionGenerateChangeset(pSession, 1, 0, 0, pnPatchset, ppPatchset);\n}\n\n/*\n** Enable or disable the session object passed as the first argument.\n*/\nSQLITE_API int sqlite3session_enable(sqlite3_session *pSession, int bEnable){\n  int ret;\n  sqlite3_mutex_enter(sqlite3_db_mutex(pSession->db));\n  if( bEnable>=0 ){\n    pSession->bEnable = bEnable;\n  }\n  ret = pSession->bEnable;\n  sqlite3_mutex_leave(sqlite3_db_mutex(pSession->db));\n  return ret;\n}\n\n/*\n** Enable or disable the session object passed as the first argument.\n*/\nSQLITE_API int sqlite3session_indirect(sqlite3_session *pSession, int bIndirect){\n  int ret;\n  sqlite3_mutex_enter(sqlite3_db_mutex(pSession->db));\n  if( bIndirect>=0 ){\n    pSession->bIndirect = bIndirect;\n  }\n  ret = pSession->bIndirect;\n  sqlite3_mutex_leave(sqlite3_db_mutex(pSession->db));\n  return ret;\n}\n\n/*\n** Return true if there have been no changes to monitored tables recorded\n** by the session object passed as the only argument.\n*/\nSQLITE_API int sqlite3session_isempty(sqlite3_session *pSession){\n  int ret = 0;\n  SessionTable *pTab;\n\n  sqlite3_mutex_enter(sqlite3_db_mutex(pSession->db));\n  for(pTab=pSession->pTable; pTab && ret==0; pTab=pTab->pNext){\n    ret = (pTab->nEntry>0);\n  }\n  sqlite3_mutex_leave(sqlite3_db_mutex(pSession->db));\n\n  return (ret==0);\n}\n\n/*\n** Do the work for either sqlite3changeset_start() or start_strm().\n*/\nstatic int sessionChangesetStart(\n  sqlite3_changeset_iter **pp,    /* OUT: Changeset iterator handle */\n  int (*xInput)(void *pIn, void *pData, int *pnData),\n  void *pIn,\n  int nChangeset,                 /* Size of buffer pChangeset in bytes */\n  void *pChangeset,               /* Pointer to buffer containing changeset */\n  int bInvert                     /* True to invert changeset */\n){\n  sqlite3_changeset_iter *pRet;   /* Iterator to return */\n  int nByte;                      /* Number of bytes to allocate for iterator */\n\n  assert( xInput==0 || (pChangeset==0 && nChangeset==0) );\n\n  /* Zero the output variable in case an error occurs. */\n  *pp = 0;\n\n  /* Allocate and initialize the iterator structure. */\n  nByte = sizeof(sqlite3_changeset_iter);\n  pRet = (sqlite3_changeset_iter *)sqlite3_malloc(nByte);\n  if( !pRet ) return SQLITE_NOMEM;\n  memset(pRet, 0, sizeof(sqlite3_changeset_iter));\n  pRet->in.aData = (u8 *)pChangeset;\n  pRet->in.nData = nChangeset;\n  pRet->in.xInput = xInput;\n  pRet->in.pIn = pIn;\n  pRet->in.bEof = (xInput ? 0 : 1);\n  pRet->bInvert = bInvert;\n\n  /* Populate the output variable and return success. */\n  *pp = pRet;\n  return SQLITE_OK;\n}\n\n/*\n** Create an iterator used to iterate through the contents of a changeset.\n*/\nSQLITE_API int sqlite3changeset_start(\n  sqlite3_changeset_iter **pp,    /* OUT: Changeset iterator handle */\n  int nChangeset,                 /* Size of buffer pChangeset in bytes */\n  void *pChangeset                /* Pointer to buffer containing changeset */\n){\n  return sessionChangesetStart(pp, 0, 0, nChangeset, pChangeset, 0);\n}\nSQLITE_API int sqlite3changeset_start_v2(\n  sqlite3_changeset_iter **pp,    /* OUT: Changeset iterator handle */\n  int nChangeset,                 /* Size of buffer pChangeset in bytes */\n  void *pChangeset,               /* Pointer to buffer containing changeset */\n  int flags\n){\n  int bInvert = !!(flags & SQLITE_CHANGESETSTART_INVERT);\n  return sessionChangesetStart(pp, 0, 0, nChangeset, pChangeset, bInvert);\n}\n\n/*\n** Streaming version of sqlite3changeset_start().\n*/\nSQLITE_API int sqlite3changeset_start_strm(\n  sqlite3_changeset_iter **pp,    /* OUT: Changeset iterator handle */\n  int (*xInput)(void *pIn, void *pData, int *pnData),\n  void *pIn\n){\n  return sessionChangesetStart(pp, xInput, pIn, 0, 0, 0);\n}\nSQLITE_API int sqlite3changeset_start_v2_strm(\n  sqlite3_changeset_iter **pp,    /* OUT: Changeset iterator handle */\n  int (*xInput)(void *pIn, void *pData, int *pnData),\n  void *pIn,\n  int flags\n){\n  int bInvert = !!(flags & SQLITE_CHANGESETSTART_INVERT);\n  return sessionChangesetStart(pp, xInput, pIn, 0, 0, bInvert);\n}\n\n/*\n** If the SessionInput object passed as the only argument is a streaming\n** object and the buffer is full, discard some data to free up space.\n*/\nstatic void sessionDiscardData(SessionInput *pIn){\n  if( pIn->xInput && pIn->iNext>=sessions_strm_chunk_size ){\n    int nMove = pIn->buf.nBuf - pIn->iNext;\n    assert( nMove>=0 );\n    if( nMove>0 ){\n      memmove(pIn->buf.aBuf, &pIn->buf.aBuf[pIn->iNext], nMove);\n    }\n    pIn->buf.nBuf -= pIn->iNext;\n    pIn->iNext = 0;\n    pIn->nData = pIn->buf.nBuf;\n  }\n}\n\n/*\n** Ensure that there are at least nByte bytes available in the buffer. Or,\n** if there are not nByte bytes remaining in the input, that all available\n** data is in the buffer.\n**\n** Return an SQLite error code if an error occurs, or SQLITE_OK otherwise.\n*/\nstatic int sessionInputBuffer(SessionInput *pIn, int nByte){\n  int rc = SQLITE_OK;\n  if( pIn->xInput ){\n    while( !pIn->bEof && (pIn->iNext+nByte)>=pIn->nData && rc==SQLITE_OK ){\n      int nNew = sessions_strm_chunk_size;\n\n      if( pIn->bNoDiscard==0 ) sessionDiscardData(pIn);\n      if( SQLITE_OK==sessionBufferGrow(&pIn->buf, nNew, &rc) ){\n        rc = pIn->xInput(pIn->pIn, &pIn->buf.aBuf[pIn->buf.nBuf], &nNew);\n        if( nNew==0 ){\n          pIn->bEof = 1;\n        }else{\n          pIn->buf.nBuf += nNew;\n        }\n      }\n\n      pIn->aData = pIn->buf.aBuf;\n      pIn->nData = pIn->buf.nBuf;\n    }\n  }\n  return rc;\n}\n\n/*\n** When this function is called, *ppRec points to the start of a record\n** that contains nCol values. This function advances the pointer *ppRec\n** until it points to the byte immediately following that record.\n*/\nstatic void sessionSkipRecord(\n  u8 **ppRec,                     /* IN/OUT: Record pointer */\n  int nCol                        /* Number of values in record */\n){\n  u8 *aRec = *ppRec;\n  int i;\n  for(i=0; i<nCol; i++){\n    int eType = *aRec++;\n    if( eType==SQLITE_TEXT || eType==SQLITE_BLOB ){\n      int nByte;\n      aRec += sessionVarintGet((u8*)aRec, &nByte);\n      aRec += nByte;\n    }else if( eType==SQLITE_INTEGER || eType==SQLITE_FLOAT ){\n      aRec += 8;\n    }\n  }\n\n  *ppRec = aRec;\n}\n\n/*\n** This function sets the value of the sqlite3_value object passed as the\n** first argument to a copy of the string or blob held in the aData[] \n** buffer. SQLITE_OK is returned if successful, or SQLITE_NOMEM if an OOM\n** error occurs.\n*/\nstatic int sessionValueSetStr(\n  sqlite3_value *pVal,            /* Set the value of this object */\n  u8 *aData,                      /* Buffer containing string or blob data */\n  int nData,                      /* Size of buffer aData[] in bytes */\n  u8 enc                          /* String encoding (0 for blobs) */\n){\n  /* In theory this code could just pass SQLITE_TRANSIENT as the final\n  ** argument to sqlite3ValueSetStr() and have the copy created \n  ** automatically. But doing so makes it difficult to detect any OOM\n  ** error. Hence the code to create the copy externally. */\n  u8 *aCopy = sqlite3_malloc64((sqlite3_int64)nData+1);\n  if( aCopy==0 ) return SQLITE_NOMEM;\n  memcpy(aCopy, aData, nData);\n  sqlite3ValueSetStr(pVal, nData, (char*)aCopy, enc, sqlite3_free);\n  return SQLITE_OK;\n}\n\n/*\n** Deserialize a single record from a buffer in memory. See \"RECORD FORMAT\"\n** for details.\n**\n** When this function is called, *paChange points to the start of the record\n** to deserialize. Assuming no error occurs, *paChange is set to point to\n** one byte after the end of the same record before this function returns.\n** If the argument abPK is NULL, then the record contains nCol values. Or,\n** if abPK is other than NULL, then the record contains only the PK fields\n** (in other words, it is a patchset DELETE record).\n**\n** If successful, each element of the apOut[] array (allocated by the caller)\n** is set to point to an sqlite3_value object containing the value read\n** from the corresponding position in the record. If that value is not\n** included in the record (i.e. because the record is part of an UPDATE change\n** and the field was not modified), the corresponding element of apOut[] is\n** set to NULL.\n**\n** It is the responsibility of the caller to free all sqlite_value structures\n** using sqlite3_free().\n**\n** If an error occurs, an SQLite error code (e.g. SQLITE_NOMEM) is returned.\n** The apOut[] array may have been partially populated in this case.\n*/\nstatic int sessionReadRecord(\n  SessionInput *pIn,              /* Input data */\n  int nCol,                       /* Number of values in record */\n  u8 *abPK,                       /* Array of primary key flags, or NULL */\n  sqlite3_value **apOut           /* Write values to this array */\n){\n  int i;                          /* Used to iterate through columns */\n  int rc = SQLITE_OK;\n\n  for(i=0; i<nCol && rc==SQLITE_OK; i++){\n    int eType = 0;                /* Type of value (SQLITE_NULL, TEXT etc.) */\n    if( abPK && abPK[i]==0 ) continue;\n    rc = sessionInputBuffer(pIn, 9);\n    if( rc==SQLITE_OK ){\n      if( pIn->iNext>=pIn->nData ){\n        rc = SQLITE_CORRUPT_BKPT;\n      }else{\n        eType = pIn->aData[pIn->iNext++];\n        assert( apOut[i]==0 );\n        if( eType ){\n          apOut[i] = sqlite3ValueNew(0);\n          if( !apOut[i] ) rc = SQLITE_NOMEM;\n        }\n      }\n    }\n\n    if( rc==SQLITE_OK ){\n      u8 *aVal = &pIn->aData[pIn->iNext];\n      if( eType==SQLITE_TEXT || eType==SQLITE_BLOB ){\n        int nByte;\n        pIn->iNext += sessionVarintGet(aVal, &nByte);\n        rc = sessionInputBuffer(pIn, nByte);\n        if( rc==SQLITE_OK ){\n          if( nByte<0 || nByte>pIn->nData-pIn->iNext ){\n            rc = SQLITE_CORRUPT_BKPT;\n          }else{\n            u8 enc = (eType==SQLITE_TEXT ? SQLITE_UTF8 : 0);\n            rc = sessionValueSetStr(apOut[i],&pIn->aData[pIn->iNext],nByte,enc);\n            pIn->iNext += nByte;\n          }\n        }\n      }\n      if( eType==SQLITE_INTEGER || eType==SQLITE_FLOAT ){\n        sqlite3_int64 v = sessionGetI64(aVal);\n        if( eType==SQLITE_INTEGER ){\n          sqlite3VdbeMemSetInt64(apOut[i], v);\n        }else{\n          double d;\n          memcpy(&d, &v, 8);\n          sqlite3VdbeMemSetDouble(apOut[i], d);\n        }\n        pIn->iNext += 8;\n      }\n    }\n  }\n\n  return rc;\n}\n\n/*\n** The input pointer currently points to the second byte of a table-header.\n** Specifically, to the following:\n**\n**   + number of columns in table (varint)\n**   + array of PK flags (1 byte per column),\n**   + table name (nul terminated).\n**\n** This function ensures that all of the above is present in the input \n** buffer (i.e. that it can be accessed without any calls to xInput()).\n** If successful, SQLITE_OK is returned. Otherwise, an SQLite error code.\n** The input pointer is not moved.\n*/\nstatic int sessionChangesetBufferTblhdr(SessionInput *pIn, int *pnByte){\n  int rc = SQLITE_OK;\n  int nCol = 0;\n  int nRead = 0;\n\n  rc = sessionInputBuffer(pIn, 9);\n  if( rc==SQLITE_OK ){\n    nRead += sessionVarintGet(&pIn->aData[pIn->iNext + nRead], &nCol);\n    /* The hard upper limit for the number of columns in an SQLite\n    ** database table is, according to sqliteLimit.h, 32676. So \n    ** consider any table-header that purports to have more than 65536 \n    ** columns to be corrupt. This is convenient because otherwise, \n    ** if the (nCol>65536) condition below were omitted, a sufficiently \n    ** large value for nCol may cause nRead to wrap around and become \n    ** negative. Leading to a crash. */\n    if( nCol<0 || nCol>65536 ){\n      rc = SQLITE_CORRUPT_BKPT;\n    }else{\n      rc = sessionInputBuffer(pIn, nRead+nCol+100);\n      nRead += nCol;\n    }\n  }\n\n  while( rc==SQLITE_OK ){\n    while( (pIn->iNext + nRead)<pIn->nData && pIn->aData[pIn->iNext + nRead] ){\n      nRead++;\n    }\n    if( (pIn->iNext + nRead)<pIn->nData ) break;\n    rc = sessionInputBuffer(pIn, nRead + 100);\n  }\n  *pnByte = nRead+1;\n  return rc;\n}\n\n/*\n** The input pointer currently points to the first byte of the first field\n** of a record consisting of nCol columns. This function ensures the entire\n** record is buffered. It does not move the input pointer.\n**\n** If successful, SQLITE_OK is returned and *pnByte is set to the size of\n** the record in bytes. Otherwise, an SQLite error code is returned. The\n** final value of *pnByte is undefined in this case.\n*/\nstatic int sessionChangesetBufferRecord(\n  SessionInput *pIn,              /* Input data */\n  int nCol,                       /* Number of columns in record */\n  int *pnByte                     /* OUT: Size of record in bytes */\n){\n  int rc = SQLITE_OK;\n  int nByte = 0;\n  int i;\n  for(i=0; rc==SQLITE_OK && i<nCol; i++){\n    int eType;\n    rc = sessionInputBuffer(pIn, nByte + 10);\n    if( rc==SQLITE_OK ){\n      eType = pIn->aData[pIn->iNext + nByte++];\n      if( eType==SQLITE_TEXT || eType==SQLITE_BLOB ){\n        int n;\n        nByte += sessionVarintGet(&pIn->aData[pIn->iNext+nByte], &n);\n        nByte += n;\n        rc = sessionInputBuffer(pIn, nByte);\n      }else if( eType==SQLITE_INTEGER || eType==SQLITE_FLOAT ){\n        nByte += 8;\n      }\n    }\n  }\n  *pnByte = nByte;\n  return rc;\n}\n\n/*\n** The input pointer currently points to the second byte of a table-header.\n** Specifically, to the following:\n**\n**   + number of columns in table (varint)\n**   + array of PK flags (1 byte per column),\n**   + table name (nul terminated).\n**\n** This function decodes the table-header and populates the p->nCol, \n** p->zTab and p->abPK[] variables accordingly. The p->apValue[] array is \n** also allocated or resized according to the new value of p->nCol. The\n** input pointer is left pointing to the byte following the table header.\n**\n** If successful, SQLITE_OK is returned. Otherwise, an SQLite error code\n** is returned and the final values of the various fields enumerated above\n** are undefined.\n*/\nstatic int sessionChangesetReadTblhdr(sqlite3_changeset_iter *p){\n  int rc;\n  int nCopy;\n  assert( p->rc==SQLITE_OK );\n\n  rc = sessionChangesetBufferTblhdr(&p->in, &nCopy);\n  if( rc==SQLITE_OK ){\n    int nByte;\n    int nVarint;\n    nVarint = sessionVarintGet(&p->in.aData[p->in.iNext], &p->nCol);\n    if( p->nCol>0 ){\n      nCopy -= nVarint;\n      p->in.iNext += nVarint;\n      nByte = p->nCol * sizeof(sqlite3_value*) * 2 + nCopy;\n      p->tblhdr.nBuf = 0;\n      sessionBufferGrow(&p->tblhdr, nByte, &rc);\n    }else{\n      rc = SQLITE_CORRUPT_BKPT;\n    }\n  }\n\n  if( rc==SQLITE_OK ){\n    int iPK = sizeof(sqlite3_value*)*p->nCol*2;\n    memset(p->tblhdr.aBuf, 0, iPK);\n    memcpy(&p->tblhdr.aBuf[iPK], &p->in.aData[p->in.iNext], nCopy);\n    p->in.iNext += nCopy;\n  }\n\n  p->apValue = (sqlite3_value**)p->tblhdr.aBuf;\n  p->abPK = (u8*)&p->apValue[p->nCol*2];\n  p->zTab = (char*)&p->abPK[p->nCol];\n  return (p->rc = rc);\n}\n\n/*\n** Advance the changeset iterator to the next change.\n**\n** If both paRec and pnRec are NULL, then this function works like the public\n** API sqlite3changeset_next(). If SQLITE_ROW is returned, then the\n** sqlite3changeset_new() and old() APIs may be used to query for values.\n**\n** Otherwise, if paRec and pnRec are not NULL, then a pointer to the change\n** record is written to *paRec before returning and the number of bytes in\n** the record to *pnRec.\n**\n** Either way, this function returns SQLITE_ROW if the iterator is \n** successfully advanced to the next change in the changeset, an SQLite \n** error code if an error occurs, or SQLITE_DONE if there are no further \n** changes in the changeset.\n*/\nstatic int sessionChangesetNext(\n  sqlite3_changeset_iter *p,      /* Changeset iterator */\n  u8 **paRec,                     /* If non-NULL, store record pointer here */\n  int *pnRec,                     /* If non-NULL, store size of record here */\n  int *pbNew                      /* If non-NULL, true if new table */\n){\n  int i;\n  u8 op;\n\n  assert( (paRec==0 && pnRec==0) || (paRec && pnRec) );\n\n  /* If the iterator is in the error-state, return immediately. */\n  if( p->rc!=SQLITE_OK ) return p->rc;\n\n  /* Free the current contents of p->apValue[], if any. */\n  if( p->apValue ){\n    for(i=0; i<p->nCol*2; i++){\n      sqlite3ValueFree(p->apValue[i]);\n    }\n    memset(p->apValue, 0, sizeof(sqlite3_value*)*p->nCol*2);\n  }\n\n  /* Make sure the buffer contains at least 10 bytes of input data, or all\n  ** remaining data if there are less than 10 bytes available. This is\n  ** sufficient either for the 'T' or 'P' byte and the varint that follows\n  ** it, or for the two single byte values otherwise. */\n  p->rc = sessionInputBuffer(&p->in, 2);\n  if( p->rc!=SQLITE_OK ) return p->rc;\n\n  /* If the iterator is already at the end of the changeset, return DONE. */\n  if( p->in.iNext>=p->in.nData ){\n    return SQLITE_DONE;\n  }\n\n  sessionDiscardData(&p->in);\n  p->in.iCurrent = p->in.iNext;\n\n  op = p->in.aData[p->in.iNext++];\n  while( op=='T' || op=='P' ){\n    if( pbNew ) *pbNew = 1;\n    p->bPatchset = (op=='P');\n    if( sessionChangesetReadTblhdr(p) ) return p->rc;\n    if( (p->rc = sessionInputBuffer(&p->in, 2)) ) return p->rc;\n    p->in.iCurrent = p->in.iNext;\n    if( p->in.iNext>=p->in.nData ) return SQLITE_DONE;\n    op = p->in.aData[p->in.iNext++];\n  }\n\n  if( p->zTab==0 || (p->bPatchset && p->bInvert) ){\n    /* The first record in the changeset is not a table header. Must be a\n    ** corrupt changeset. */\n    assert( p->in.iNext==1 || p->zTab );\n    return (p->rc = SQLITE_CORRUPT_BKPT);\n  }\n\n  p->op = op;\n  p->bIndirect = p->in.aData[p->in.iNext++];\n  if( p->op!=SQLITE_UPDATE && p->op!=SQLITE_DELETE && p->op!=SQLITE_INSERT ){\n    return (p->rc = SQLITE_CORRUPT_BKPT);\n  }\n\n  if( paRec ){ \n    int nVal;                     /* Number of values to buffer */\n    if( p->bPatchset==0 && op==SQLITE_UPDATE ){\n      nVal = p->nCol * 2;\n    }else if( p->bPatchset && op==SQLITE_DELETE ){\n      nVal = 0;\n      for(i=0; i<p->nCol; i++) if( p->abPK[i] ) nVal++;\n    }else{\n      nVal = p->nCol;\n    }\n    p->rc = sessionChangesetBufferRecord(&p->in, nVal, pnRec);\n    if( p->rc!=SQLITE_OK ) return p->rc;\n    *paRec = &p->in.aData[p->in.iNext];\n    p->in.iNext += *pnRec;\n  }else{\n    sqlite3_value **apOld = (p->bInvert ? &p->apValue[p->nCol] : p->apValue);\n    sqlite3_value **apNew = (p->bInvert ? p->apValue : &p->apValue[p->nCol]);\n\n    /* If this is an UPDATE or DELETE, read the old.* record. */\n    if( p->op!=SQLITE_INSERT && (p->bPatchset==0 || p->op==SQLITE_DELETE) ){\n      u8 *abPK = p->bPatchset ? p->abPK : 0;\n      p->rc = sessionReadRecord(&p->in, p->nCol, abPK, apOld);\n      if( p->rc!=SQLITE_OK ) return p->rc;\n    }\n\n    /* If this is an INSERT or UPDATE, read the new.* record. */\n    if( p->op!=SQLITE_DELETE ){\n      p->rc = sessionReadRecord(&p->in, p->nCol, 0, apNew);\n      if( p->rc!=SQLITE_OK ) return p->rc;\n    }\n\n    if( (p->bPatchset || p->bInvert) && p->op==SQLITE_UPDATE ){\n      /* If this is an UPDATE that is part of a patchset, then all PK and\n      ** modified fields are present in the new.* record. The old.* record\n      ** is currently completely empty. This block shifts the PK fields from\n      ** new.* to old.*, to accommodate the code that reads these arrays.  */\n      for(i=0; i<p->nCol; i++){\n        assert( p->bPatchset==0 || p->apValue[i]==0 );\n        if( p->abPK[i] ){\n          assert( p->apValue[i]==0 );\n          p->apValue[i] = p->apValue[i+p->nCol];\n          if( p->apValue[i]==0 ) return (p->rc = SQLITE_CORRUPT_BKPT);\n          p->apValue[i+p->nCol] = 0;\n        }\n      }\n    }else if( p->bInvert ){\n      if( p->op==SQLITE_INSERT ) p->op = SQLITE_DELETE;\n      else if( p->op==SQLITE_DELETE ) p->op = SQLITE_INSERT;\n    }\n  }\n\n  return SQLITE_ROW;\n}\n\n/*\n** Advance an iterator created by sqlite3changeset_start() to the next\n** change in the changeset. This function may return SQLITE_ROW, SQLITE_DONE\n** or SQLITE_CORRUPT.\n**\n** This function may not be called on iterators passed to a conflict handler\n** callback by changeset_apply().\n*/\nSQLITE_API int sqlite3changeset_next(sqlite3_changeset_iter *p){\n  return sessionChangesetNext(p, 0, 0, 0);\n}\n\n/*\n** The following function extracts information on the current change\n** from a changeset iterator. It may only be called after changeset_next()\n** has returned SQLITE_ROW.\n*/\nSQLITE_API int sqlite3changeset_op(\n  sqlite3_changeset_iter *pIter,  /* Iterator handle */\n  const char **pzTab,             /* OUT: Pointer to table name */\n  int *pnCol,                     /* OUT: Number of columns in table */\n  int *pOp,                       /* OUT: SQLITE_INSERT, DELETE or UPDATE */\n  int *pbIndirect                 /* OUT: True if change is indirect */\n){\n  *pOp = pIter->op;\n  *pnCol = pIter->nCol;\n  *pzTab = pIter->zTab;\n  if( pbIndirect ) *pbIndirect = pIter->bIndirect;\n  return SQLITE_OK;\n}\n\n/*\n** Return information regarding the PRIMARY KEY and number of columns in\n** the database table affected by the change that pIter currently points\n** to. This function may only be called after changeset_next() returns\n** SQLITE_ROW.\n*/\nSQLITE_API int sqlite3changeset_pk(\n  sqlite3_changeset_iter *pIter,  /* Iterator object */\n  unsigned char **pabPK,          /* OUT: Array of boolean - true for PK cols */\n  int *pnCol                      /* OUT: Number of entries in output array */\n){\n  *pabPK = pIter->abPK;\n  if( pnCol ) *pnCol = pIter->nCol;\n  return SQLITE_OK;\n}\n\n/*\n** This function may only be called while the iterator is pointing to an\n** SQLITE_UPDATE or SQLITE_DELETE change (see sqlite3changeset_op()).\n** Otherwise, SQLITE_MISUSE is returned.\n**\n** It sets *ppValue to point to an sqlite3_value structure containing the\n** iVal'th value in the old.* record. Or, if that particular value is not\n** included in the record (because the change is an UPDATE and the field\n** was not modified and is not a PK column), set *ppValue to NULL.\n**\n** If value iVal is out-of-range, SQLITE_RANGE is returned and *ppValue is\n** not modified. Otherwise, SQLITE_OK.\n*/\nSQLITE_API int sqlite3changeset_old(\n  sqlite3_changeset_iter *pIter,  /* Changeset iterator */\n  int iVal,                       /* Index of old.* value to retrieve */\n  sqlite3_value **ppValue         /* OUT: Old value (or NULL pointer) */\n){\n  if( pIter->op!=SQLITE_UPDATE && pIter->op!=SQLITE_DELETE ){\n    return SQLITE_MISUSE;\n  }\n  if( iVal<0 || iVal>=pIter->nCol ){\n    return SQLITE_RANGE;\n  }\n  *ppValue = pIter->apValue[iVal];\n  return SQLITE_OK;\n}\n\n/*\n** This function may only be called while the iterator is pointing to an\n** SQLITE_UPDATE or SQLITE_INSERT change (see sqlite3changeset_op()).\n** Otherwise, SQLITE_MISUSE is returned.\n**\n** It sets *ppValue to point to an sqlite3_value structure containing the\n** iVal'th value in the new.* record. Or, if that particular value is not\n** included in the record (because the change is an UPDATE and the field\n** was not modified), set *ppValue to NULL.\n**\n** If value iVal is out-of-range, SQLITE_RANGE is returned and *ppValue is\n** not modified. Otherwise, SQLITE_OK.\n*/\nSQLITE_API int sqlite3changeset_new(\n  sqlite3_changeset_iter *pIter,  /* Changeset iterator */\n  int iVal,                       /* Index of new.* value to retrieve */\n  sqlite3_value **ppValue         /* OUT: New value (or NULL pointer) */\n){\n  if( pIter->op!=SQLITE_UPDATE && pIter->op!=SQLITE_INSERT ){\n    return SQLITE_MISUSE;\n  }\n  if( iVal<0 || iVal>=pIter->nCol ){\n    return SQLITE_RANGE;\n  }\n  *ppValue = pIter->apValue[pIter->nCol+iVal];\n  return SQLITE_OK;\n}\n\n/*\n** The following two macros are used internally. They are similar to the\n** sqlite3changeset_new() and sqlite3changeset_old() functions, except that\n** they omit all error checking and return a pointer to the requested value.\n*/\n#define sessionChangesetNew(pIter, iVal) (pIter)->apValue[(pIter)->nCol+(iVal)]\n#define sessionChangesetOld(pIter, iVal) (pIter)->apValue[(iVal)]\n\n/*\n** This function may only be called with a changeset iterator that has been\n** passed to an SQLITE_CHANGESET_DATA or SQLITE_CHANGESET_CONFLICT \n** conflict-handler function. Otherwise, SQLITE_MISUSE is returned.\n**\n** If successful, *ppValue is set to point to an sqlite3_value structure\n** containing the iVal'th value of the conflicting record.\n**\n** If value iVal is out-of-range or some other error occurs, an SQLite error\n** code is returned. Otherwise, SQLITE_OK.\n*/\nSQLITE_API int sqlite3changeset_conflict(\n  sqlite3_changeset_iter *pIter,  /* Changeset iterator */\n  int iVal,                       /* Index of conflict record value to fetch */\n  sqlite3_value **ppValue         /* OUT: Value from conflicting row */\n){\n  if( !pIter->pConflict ){\n    return SQLITE_MISUSE;\n  }\n  if( iVal<0 || iVal>=pIter->nCol ){\n    return SQLITE_RANGE;\n  }\n  *ppValue = sqlite3_column_value(pIter->pConflict, iVal);\n  return SQLITE_OK;\n}\n\n/*\n** This function may only be called with an iterator passed to an\n** SQLITE_CHANGESET_FOREIGN_KEY conflict handler callback. In this case\n** it sets the output variable to the total number of known foreign key\n** violations in the destination database and returns SQLITE_OK.\n**\n** In all other cases this function returns SQLITE_MISUSE.\n*/\nSQLITE_API int sqlite3changeset_fk_conflicts(\n  sqlite3_changeset_iter *pIter,  /* Changeset iterator */\n  int *pnOut                      /* OUT: Number of FK violations */\n){\n  if( pIter->pConflict || pIter->apValue ){\n    return SQLITE_MISUSE;\n  }\n  *pnOut = pIter->nCol;\n  return SQLITE_OK;\n}\n\n\n/*\n** Finalize an iterator allocated with sqlite3changeset_start().\n**\n** This function may not be called on iterators passed to a conflict handler\n** callback by changeset_apply().\n*/\nSQLITE_API int sqlite3changeset_finalize(sqlite3_changeset_iter *p){\n  int rc = SQLITE_OK;\n  if( p ){\n    int i;                        /* Used to iterate through p->apValue[] */\n    rc = p->rc;\n    if( p->apValue ){\n      for(i=0; i<p->nCol*2; i++) sqlite3ValueFree(p->apValue[i]);\n    }\n    sqlite3_free(p->tblhdr.aBuf);\n    sqlite3_free(p->in.buf.aBuf);\n    sqlite3_free(p);\n  }\n  return rc;\n}\n\nstatic int sessionChangesetInvert(\n  SessionInput *pInput,           /* Input changeset */\n  int (*xOutput)(void *pOut, const void *pData, int nData),\n  void *pOut,\n  int *pnInverted,                /* OUT: Number of bytes in output changeset */\n  void **ppInverted               /* OUT: Inverse of pChangeset */\n){\n  int rc = SQLITE_OK;             /* Return value */\n  SessionBuffer sOut;             /* Output buffer */\n  int nCol = 0;                   /* Number of cols in current table */\n  u8 *abPK = 0;                   /* PK array for current table */\n  sqlite3_value **apVal = 0;      /* Space for values for UPDATE inversion */\n  SessionBuffer sPK = {0, 0, 0};  /* PK array for current table */\n\n  /* Initialize the output buffer */\n  memset(&sOut, 0, sizeof(SessionBuffer));\n\n  /* Zero the output variables in case an error occurs. */\n  if( ppInverted ){\n    *ppInverted = 0;\n    *pnInverted = 0;\n  }\n\n  while( 1 ){\n    u8 eType;\n\n    /* Test for EOF. */\n    if( (rc = sessionInputBuffer(pInput, 2)) ) goto finished_invert;\n    if( pInput->iNext>=pInput->nData ) break;\n    eType = pInput->aData[pInput->iNext];\n\n    switch( eType ){\n      case 'T': {\n        /* A 'table' record consists of:\n        **\n        **   * A constant 'T' character,\n        **   * Number of columns in said table (a varint),\n        **   * An array of nCol bytes (sPK),\n        **   * A nul-terminated table name.\n        */\n        int nByte;\n        int nVar;\n        pInput->iNext++;\n        if( (rc = sessionChangesetBufferTblhdr(pInput, &nByte)) ){\n          goto finished_invert;\n        }\n        nVar = sessionVarintGet(&pInput->aData[pInput->iNext], &nCol);\n        sPK.nBuf = 0;\n        sessionAppendBlob(&sPK, &pInput->aData[pInput->iNext+nVar], nCol, &rc);\n        sessionAppendByte(&sOut, eType, &rc);\n        sessionAppendBlob(&sOut, &pInput->aData[pInput->iNext], nByte, &rc);\n        if( rc ) goto finished_invert;\n\n        pInput->iNext += nByte;\n        sqlite3_free(apVal);\n        apVal = 0;\n        abPK = sPK.aBuf;\n        break;\n      }\n\n      case SQLITE_INSERT:\n      case SQLITE_DELETE: {\n        int nByte;\n        int bIndirect = pInput->aData[pInput->iNext+1];\n        int eType2 = (eType==SQLITE_DELETE ? SQLITE_INSERT : SQLITE_DELETE);\n        pInput->iNext += 2;\n        assert( rc==SQLITE_OK );\n        rc = sessionChangesetBufferRecord(pInput, nCol, &nByte);\n        sessionAppendByte(&sOut, eType2, &rc);\n        sessionAppendByte(&sOut, bIndirect, &rc);\n        sessionAppendBlob(&sOut, &pInput->aData[pInput->iNext], nByte, &rc);\n        pInput->iNext += nByte;\n        if( rc ) goto finished_invert;\n        break;\n      }\n\n      case SQLITE_UPDATE: {\n        int iCol;\n\n        if( 0==apVal ){\n          apVal = (sqlite3_value **)sqlite3_malloc64(sizeof(apVal[0])*nCol*2);\n          if( 0==apVal ){\n            rc = SQLITE_NOMEM;\n            goto finished_invert;\n          }\n          memset(apVal, 0, sizeof(apVal[0])*nCol*2);\n        }\n\n        /* Write the header for the new UPDATE change. Same as the original. */\n        sessionAppendByte(&sOut, eType, &rc);\n        sessionAppendByte(&sOut, pInput->aData[pInput->iNext+1], &rc);\n\n        /* Read the old.* and new.* records for the update change. */\n        pInput->iNext += 2;\n        rc = sessionReadRecord(pInput, nCol, 0, &apVal[0]);\n        if( rc==SQLITE_OK ){\n          rc = sessionReadRecord(pInput, nCol, 0, &apVal[nCol]);\n        }\n\n        /* Write the new old.* record. Consists of the PK columns from the\n        ** original old.* record, and the other values from the original\n        ** new.* record. */\n        for(iCol=0; iCol<nCol; iCol++){\n          sqlite3_value *pVal = apVal[iCol + (abPK[iCol] ? 0 : nCol)];\n          sessionAppendValue(&sOut, pVal, &rc);\n        }\n\n        /* Write the new new.* record. Consists of a copy of all values\n        ** from the original old.* record, except for the PK columns, which\n        ** are set to \"undefined\". */\n        for(iCol=0; iCol<nCol; iCol++){\n          sqlite3_value *pVal = (abPK[iCol] ? 0 : apVal[iCol]);\n          sessionAppendValue(&sOut, pVal, &rc);\n        }\n\n        for(iCol=0; iCol<nCol*2; iCol++){\n          sqlite3ValueFree(apVal[iCol]);\n        }\n        memset(apVal, 0, sizeof(apVal[0])*nCol*2);\n        if( rc!=SQLITE_OK ){\n          goto finished_invert;\n        }\n\n        break;\n      }\n\n      default:\n        rc = SQLITE_CORRUPT_BKPT;\n        goto finished_invert;\n    }\n\n    assert( rc==SQLITE_OK );\n    if( xOutput && sOut.nBuf>=sessions_strm_chunk_size ){\n      rc = xOutput(pOut, sOut.aBuf, sOut.nBuf);\n      sOut.nBuf = 0;\n      if( rc!=SQLITE_OK ) goto finished_invert;\n    }\n  }\n\n  assert( rc==SQLITE_OK );\n  if( pnInverted ){\n    *pnInverted = sOut.nBuf;\n    *ppInverted = sOut.aBuf;\n    sOut.aBuf = 0;\n  }else if( sOut.nBuf>0 ){\n    rc = xOutput(pOut, sOut.aBuf, sOut.nBuf);\n  }\n\n finished_invert:\n  sqlite3_free(sOut.aBuf);\n  sqlite3_free(apVal);\n  sqlite3_free(sPK.aBuf);\n  return rc;\n}\n\n\n/*\n** Invert a changeset object.\n*/\nSQLITE_API int sqlite3changeset_invert(\n  int nChangeset,                 /* Number of bytes in input */\n  const void *pChangeset,         /* Input changeset */\n  int *pnInverted,                /* OUT: Number of bytes in output changeset */\n  void **ppInverted               /* OUT: Inverse of pChangeset */\n){\n  SessionInput sInput;\n\n  /* Set up the input stream */\n  memset(&sInput, 0, sizeof(SessionInput));\n  sInput.nData = nChangeset;\n  sInput.aData = (u8*)pChangeset;\n\n  return sessionChangesetInvert(&sInput, 0, 0, pnInverted, ppInverted);\n}\n\n/*\n** Streaming version of sqlite3changeset_invert().\n*/\nSQLITE_API int sqlite3changeset_invert_strm(\n  int (*xInput)(void *pIn, void *pData, int *pnData),\n  void *pIn,\n  int (*xOutput)(void *pOut, const void *pData, int nData),\n  void *pOut\n){\n  SessionInput sInput;\n  int rc;\n\n  /* Set up the input stream */\n  memset(&sInput, 0, sizeof(SessionInput));\n  sInput.xInput = xInput;\n  sInput.pIn = pIn;\n\n  rc = sessionChangesetInvert(&sInput, xOutput, pOut, 0, 0);\n  sqlite3_free(sInput.buf.aBuf);\n  return rc;\n}\n\ntypedef struct SessionApplyCtx SessionApplyCtx;\nstruct SessionApplyCtx {\n  sqlite3 *db;\n  sqlite3_stmt *pDelete;          /* DELETE statement */\n  sqlite3_stmt *pUpdate;          /* UPDATE statement */\n  sqlite3_stmt *pInsert;          /* INSERT statement */\n  sqlite3_stmt *pSelect;          /* SELECT statement */\n  int nCol;                       /* Size of azCol[] and abPK[] arrays */\n  const char **azCol;             /* Array of column names */\n  u8 *abPK;                       /* Boolean array - true if column is in PK */\n  int bStat1;                     /* True if table is sqlite_stat1 */\n  int bDeferConstraints;          /* True to defer constraints */\n  SessionBuffer constraints;      /* Deferred constraints are stored here */\n  SessionBuffer rebase;           /* Rebase information (if any) here */\n  u8 bRebaseStarted;              /* If table header is already in rebase */\n  u8 bRebase;                     /* True to collect rebase information */\n};\n\n/*\n** Formulate a statement to DELETE a row from database db. Assuming a table\n** structure like this:\n**\n**     CREATE TABLE x(a, b, c, d, PRIMARY KEY(a, c));\n**\n** The DELETE statement looks like this:\n**\n**     DELETE FROM x WHERE a = :1 AND c = :3 AND (:5 OR b IS :2 AND d IS :4)\n**\n** Variable :5 (nCol+1) is a boolean. It should be set to 0 if we require\n** matching b and d values, or 1 otherwise. The second case comes up if the\n** conflict handler is invoked with NOTFOUND and returns CHANGESET_REPLACE.\n**\n** If successful, SQLITE_OK is returned and SessionApplyCtx.pDelete is left\n** pointing to the prepared version of the SQL statement.\n*/\nstatic int sessionDeleteRow(\n  sqlite3 *db,                    /* Database handle */\n  const char *zTab,               /* Table name */\n  SessionApplyCtx *p              /* Session changeset-apply context */\n){\n  int i;\n  const char *zSep = \"\";\n  int rc = SQLITE_OK;\n  SessionBuffer buf = {0, 0, 0};\n  int nPk = 0;\n\n  sessionAppendStr(&buf, \"DELETE FROM \", &rc);\n  sessionAppendIdent(&buf, zTab, &rc);\n  sessionAppendStr(&buf, \" WHERE \", &rc);\n\n  for(i=0; i<p->nCol; i++){\n    if( p->abPK[i] ){\n      nPk++;\n      sessionAppendStr(&buf, zSep, &rc);\n      sessionAppendIdent(&buf, p->azCol[i], &rc);\n      sessionAppendStr(&buf, \" = ?\", &rc);\n      sessionAppendInteger(&buf, i+1, &rc);\n      zSep = \" AND \";\n    }\n  }\n\n  if( nPk<p->nCol ){\n    sessionAppendStr(&buf, \" AND (?\", &rc);\n    sessionAppendInteger(&buf, p->nCol+1, &rc);\n    sessionAppendStr(&buf, \" OR \", &rc);\n\n    zSep = \"\";\n    for(i=0; i<p->nCol; i++){\n      if( !p->abPK[i] ){\n        sessionAppendStr(&buf, zSep, &rc);\n        sessionAppendIdent(&buf, p->azCol[i], &rc);\n        sessionAppendStr(&buf, \" IS ?\", &rc);\n        sessionAppendInteger(&buf, i+1, &rc);\n        zSep = \"AND \";\n      }\n    }\n    sessionAppendStr(&buf, \")\", &rc);\n  }\n\n  if( rc==SQLITE_OK ){\n    rc = sqlite3_prepare_v2(db, (char *)buf.aBuf, buf.nBuf, &p->pDelete, 0);\n  }\n  sqlite3_free(buf.aBuf);\n\n  return rc;\n}\n\n/*\n** Formulate and prepare a statement to UPDATE a row from database db. \n** Assuming a table structure like this:\n**\n**     CREATE TABLE x(a, b, c, d, PRIMARY KEY(a, c));\n**\n** The UPDATE statement looks like this:\n**\n**     UPDATE x SET\n**     a = CASE WHEN ?2  THEN ?3  ELSE a END,\n**     b = CASE WHEN ?5  THEN ?6  ELSE b END,\n**     c = CASE WHEN ?8  THEN ?9  ELSE c END,\n**     d = CASE WHEN ?11 THEN ?12 ELSE d END\n**     WHERE a = ?1 AND c = ?7 AND (?13 OR \n**       (?5==0 OR b IS ?4) AND (?11==0 OR d IS ?10) AND\n**     )\n**\n** For each column in the table, there are three variables to bind:\n**\n**     ?(i*3+1)    The old.* value of the column, if any.\n**     ?(i*3+2)    A boolean flag indicating that the value is being modified.\n**     ?(i*3+3)    The new.* value of the column, if any.\n**\n** Also, a boolean flag that, if set to true, causes the statement to update\n** a row even if the non-PK values do not match. This is required if the\n** conflict-handler is invoked with CHANGESET_DATA and returns\n** CHANGESET_REPLACE. This is variable \"?(nCol*3+1)\".\n**\n** If successful, SQLITE_OK is returned and SessionApplyCtx.pUpdate is left\n** pointing to the prepared version of the SQL statement.\n*/\nstatic int sessionUpdateRow(\n  sqlite3 *db,                    /* Database handle */\n  const char *zTab,               /* Table name */\n  SessionApplyCtx *p              /* Session changeset-apply context */\n){\n  int rc = SQLITE_OK;\n  int i;\n  const char *zSep = \"\";\n  SessionBuffer buf = {0, 0, 0};\n\n  /* Append \"UPDATE tbl SET \" */\n  sessionAppendStr(&buf, \"UPDATE \", &rc);\n  sessionAppendIdent(&buf, zTab, &rc);\n  sessionAppendStr(&buf, \" SET \", &rc);\n\n  /* Append the assignments */\n  for(i=0; i<p->nCol; i++){\n    sessionAppendStr(&buf, zSep, &rc);\n    sessionAppendIdent(&buf, p->azCol[i], &rc);\n    sessionAppendStr(&buf, \" = CASE WHEN ?\", &rc);\n    sessionAppendInteger(&buf, i*3+2, &rc);\n    sessionAppendStr(&buf, \" THEN ?\", &rc);\n    sessionAppendInteger(&buf, i*3+3, &rc);\n    sessionAppendStr(&buf, \" ELSE \", &rc);\n    sessionAppendIdent(&buf, p->azCol[i], &rc);\n    sessionAppendStr(&buf, \" END\", &rc);\n    zSep = \", \";\n  }\n\n  /* Append the PK part of the WHERE clause */\n  sessionAppendStr(&buf, \" WHERE \", &rc);\n  for(i=0; i<p->nCol; i++){\n    if( p->abPK[i] ){\n      sessionAppendIdent(&buf, p->azCol[i], &rc);\n      sessionAppendStr(&buf, \" = ?\", &rc);\n      sessionAppendInteger(&buf, i*3+1, &rc);\n      sessionAppendStr(&buf, \" AND \", &rc);\n    }\n  }\n\n  /* Append the non-PK part of the WHERE clause */\n  sessionAppendStr(&buf, \" (?\", &rc);\n  sessionAppendInteger(&buf, p->nCol*3+1, &rc);\n  sessionAppendStr(&buf, \" OR 1\", &rc);\n  for(i=0; i<p->nCol; i++){\n    if( !p->abPK[i] ){\n      sessionAppendStr(&buf, \" AND (?\", &rc);\n      sessionAppendInteger(&buf, i*3+2, &rc);\n      sessionAppendStr(&buf, \"=0 OR \", &rc);\n      sessionAppendIdent(&buf, p->azCol[i], &rc);\n      sessionAppendStr(&buf, \" IS ?\", &rc);\n      sessionAppendInteger(&buf, i*3+1, &rc);\n      sessionAppendStr(&buf, \")\", &rc);\n    }\n  }\n  sessionAppendStr(&buf, \")\", &rc);\n\n  if( rc==SQLITE_OK ){\n    rc = sqlite3_prepare_v2(db, (char *)buf.aBuf, buf.nBuf, &p->pUpdate, 0);\n  }\n  sqlite3_free(buf.aBuf);\n\n  return rc;\n}\n\n\n/*\n** Formulate and prepare an SQL statement to query table zTab by primary\n** key. Assuming the following table structure:\n**\n**     CREATE TABLE x(a, b, c, d, PRIMARY KEY(a, c));\n**\n** The SELECT statement looks like this:\n**\n**     SELECT * FROM x WHERE a = ?1 AND c = ?3\n**\n** If successful, SQLITE_OK is returned and SessionApplyCtx.pSelect is left\n** pointing to the prepared version of the SQL statement.\n*/\nstatic int sessionSelectRow(\n  sqlite3 *db,                    /* Database handle */\n  const char *zTab,               /* Table name */\n  SessionApplyCtx *p              /* Session changeset-apply context */\n){\n  return sessionSelectStmt(\n      db, \"main\", zTab, p->nCol, p->azCol, p->abPK, &p->pSelect);\n}\n\n/*\n** Formulate and prepare an INSERT statement to add a record to table zTab.\n** For example:\n**\n**     INSERT INTO main.\"zTab\" VALUES(?1, ?2, ?3 ...);\n**\n** If successful, SQLITE_OK is returned and SessionApplyCtx.pInsert is left\n** pointing to the prepared version of the SQL statement.\n*/\nstatic int sessionInsertRow(\n  sqlite3 *db,                    /* Database handle */\n  const char *zTab,               /* Table name */\n  SessionApplyCtx *p              /* Session changeset-apply context */\n){\n  int rc = SQLITE_OK;\n  int i;\n  SessionBuffer buf = {0, 0, 0};\n\n  sessionAppendStr(&buf, \"INSERT INTO main.\", &rc);\n  sessionAppendIdent(&buf, zTab, &rc);\n  sessionAppendStr(&buf, \"(\", &rc);\n  for(i=0; i<p->nCol; i++){\n    if( i!=0 ) sessionAppendStr(&buf, \", \", &rc);\n    sessionAppendIdent(&buf, p->azCol[i], &rc);\n  }\n\n  sessionAppendStr(&buf, \") VALUES(?\", &rc);\n  for(i=1; i<p->nCol; i++){\n    sessionAppendStr(&buf, \", ?\", &rc);\n  }\n  sessionAppendStr(&buf, \")\", &rc);\n\n  if( rc==SQLITE_OK ){\n    rc = sqlite3_prepare_v2(db, (char *)buf.aBuf, buf.nBuf, &p->pInsert, 0);\n  }\n  sqlite3_free(buf.aBuf);\n  return rc;\n}\n\nstatic int sessionPrepare(sqlite3 *db, sqlite3_stmt **pp, const char *zSql){\n  return sqlite3_prepare_v2(db, zSql, -1, pp, 0);\n}\n\n/*\n** Prepare statements for applying changes to the sqlite_stat1 table.\n** These are similar to those created by sessionSelectRow(),\n** sessionInsertRow(), sessionUpdateRow() and sessionDeleteRow() for \n** other tables.\n*/\nstatic int sessionStat1Sql(sqlite3 *db, SessionApplyCtx *p){\n  int rc = sessionSelectRow(db, \"sqlite_stat1\", p);\n  if( rc==SQLITE_OK ){\n    rc = sessionPrepare(db, &p->pInsert,\n        \"INSERT INTO main.sqlite_stat1 VALUES(?1, \"\n        \"CASE WHEN length(?2)=0 AND typeof(?2)='blob' THEN NULL ELSE ?2 END, \"\n        \"?3)\"\n    );\n  }\n  if( rc==SQLITE_OK ){\n    rc = sessionPrepare(db, &p->pUpdate,\n        \"UPDATE main.sqlite_stat1 SET \"\n        \"tbl = CASE WHEN ?2 THEN ?3 ELSE tbl END, \"\n        \"idx = CASE WHEN ?5 THEN ?6 ELSE idx END, \"\n        \"stat = CASE WHEN ?8 THEN ?9 ELSE stat END  \"\n        \"WHERE tbl=?1 AND idx IS \"\n        \"CASE WHEN length(?4)=0 AND typeof(?4)='blob' THEN NULL ELSE ?4 END \"\n        \"AND (?10 OR ?8=0 OR stat IS ?7)\"\n    );\n  }\n  if( rc==SQLITE_OK ){\n    rc = sessionPrepare(db, &p->pDelete,\n        \"DELETE FROM main.sqlite_stat1 WHERE tbl=?1 AND idx IS \"\n        \"CASE WHEN length(?2)=0 AND typeof(?2)='blob' THEN NULL ELSE ?2 END \"\n        \"AND (?4 OR stat IS ?3)\"\n    );\n  }\n  return rc;\n}\n\n/*\n** A wrapper around sqlite3_bind_value() that detects an extra problem. \n** See comments in the body of this function for details.\n*/\nstatic int sessionBindValue(\n  sqlite3_stmt *pStmt,            /* Statement to bind value to */\n  int i,                          /* Parameter number to bind to */\n  sqlite3_value *pVal             /* Value to bind */\n){\n  int eType = sqlite3_value_type(pVal);\n  /* COVERAGE: The (pVal->z==0) branch is never true using current versions\n  ** of SQLite. If a malloc fails in an sqlite3_value_xxx() function, either\n  ** the (pVal->z) variable remains as it was or the type of the value is\n  ** set to SQLITE_NULL.  */\n  if( (eType==SQLITE_TEXT || eType==SQLITE_BLOB) && pVal->z==0 ){\n    /* This condition occurs when an earlier OOM in a call to\n    ** sqlite3_value_text() or sqlite3_value_blob() (perhaps from within\n    ** a conflict-handler) has zeroed the pVal->z pointer. Return NOMEM. */\n    return SQLITE_NOMEM;\n  }\n  return sqlite3_bind_value(pStmt, i, pVal);\n}\n\n/*\n** Iterator pIter must point to an SQLITE_INSERT entry. This function \n** transfers new.* values from the current iterator entry to statement\n** pStmt. The table being inserted into has nCol columns.\n**\n** New.* value $i from the iterator is bound to variable ($i+1) of \n** statement pStmt. If parameter abPK is NULL, all values from 0 to (nCol-1)\n** are transfered to the statement. Otherwise, if abPK is not NULL, it points\n** to an array nCol elements in size. In this case only those values for \n** which abPK[$i] is true are read from the iterator and bound to the \n** statement.\n**\n** An SQLite error code is returned if an error occurs. Otherwise, SQLITE_OK.\n*/\nstatic int sessionBindRow(\n  sqlite3_changeset_iter *pIter,  /* Iterator to read values from */\n  int(*xValue)(sqlite3_changeset_iter *, int, sqlite3_value **),\n  int nCol,                       /* Number of columns */\n  u8 *abPK,                       /* If not NULL, bind only if true */\n  sqlite3_stmt *pStmt             /* Bind values to this statement */\n){\n  int i;\n  int rc = SQLITE_OK;\n\n  /* Neither sqlite3changeset_old or sqlite3changeset_new can fail if the\n  ** argument iterator points to a suitable entry. Make sure that xValue \n  ** is one of these to guarantee that it is safe to ignore the return \n  ** in the code below. */\n  assert( xValue==sqlite3changeset_old || xValue==sqlite3changeset_new );\n\n  for(i=0; rc==SQLITE_OK && i<nCol; i++){\n    if( !abPK || abPK[i] ){\n      sqlite3_value *pVal;\n      (void)xValue(pIter, i, &pVal);\n      if( pVal==0 ){\n        /* The value in the changeset was \"undefined\". This indicates a\n        ** corrupt changeset blob.  */\n        rc = SQLITE_CORRUPT_BKPT;\n      }else{\n        rc = sessionBindValue(pStmt, i+1, pVal);\n      }\n    }\n  }\n  return rc;\n}\n\n/*\n** SQL statement pSelect is as generated by the sessionSelectRow() function.\n** This function binds the primary key values from the change that changeset\n** iterator pIter points to to the SELECT and attempts to seek to the table\n** entry. If a row is found, the SELECT statement left pointing at the row \n** and SQLITE_ROW is returned. Otherwise, if no row is found and no error\n** has occured, the statement is reset and SQLITE_OK is returned. If an\n** error occurs, the statement is reset and an SQLite error code is returned.\n**\n** If this function returns SQLITE_ROW, the caller must eventually reset() \n** statement pSelect. If any other value is returned, the statement does\n** not require a reset().\n**\n** If the iterator currently points to an INSERT record, bind values from the\n** new.* record to the SELECT statement. Or, if it points to a DELETE or\n** UPDATE, bind values from the old.* record. \n*/\nstatic int sessionSeekToRow(\n  sqlite3 *db,                    /* Database handle */\n  sqlite3_changeset_iter *pIter,  /* Changeset iterator */\n  u8 *abPK,                       /* Primary key flags array */\n  sqlite3_stmt *pSelect           /* SELECT statement from sessionSelectRow() */\n){\n  int rc;                         /* Return code */\n  int nCol;                       /* Number of columns in table */\n  int op;                         /* Changset operation (SQLITE_UPDATE etc.) */\n  const char *zDummy;             /* Unused */\n\n  sqlite3changeset_op(pIter, &zDummy, &nCol, &op, 0);\n  rc = sessionBindRow(pIter, \n      op==SQLITE_INSERT ? sqlite3changeset_new : sqlite3changeset_old,\n      nCol, abPK, pSelect\n  );\n\n  if( rc==SQLITE_OK ){\n    rc = sqlite3_step(pSelect);\n    if( rc!=SQLITE_ROW ) rc = sqlite3_reset(pSelect);\n  }\n\n  return rc;\n}\n\n/*\n** This function is called from within sqlite3changset_apply_v2() when\n** a conflict is encountered and resolved using conflict resolution\n** mode eType (either SQLITE_CHANGESET_OMIT or SQLITE_CHANGESET_REPLACE)..\n** It adds a conflict resolution record to the buffer in \n** SessionApplyCtx.rebase, which will eventually be returned to the caller\n** of apply_v2() as the \"rebase\" buffer.\n**\n** Return SQLITE_OK if successful, or an SQLite error code otherwise.\n*/\nstatic int sessionRebaseAdd(\n  SessionApplyCtx *p,             /* Apply context */\n  int eType,                      /* Conflict resolution (OMIT or REPLACE) */\n  sqlite3_changeset_iter *pIter   /* Iterator pointing at current change */\n){\n  int rc = SQLITE_OK;\n  if( p->bRebase ){\n    int i;\n    int eOp = pIter->op;\n    if( p->bRebaseStarted==0 ){\n      /* Append a table-header to the rebase buffer */\n      const char *zTab = pIter->zTab;\n      sessionAppendByte(&p->rebase, 'T', &rc);\n      sessionAppendVarint(&p->rebase, p->nCol, &rc);\n      sessionAppendBlob(&p->rebase, p->abPK, p->nCol, &rc);\n      sessionAppendBlob(&p->rebase, (u8*)zTab, (int)strlen(zTab)+1, &rc);\n      p->bRebaseStarted = 1;\n    }\n\n    assert( eType==SQLITE_CHANGESET_REPLACE||eType==SQLITE_CHANGESET_OMIT );\n    assert( eOp==SQLITE_DELETE || eOp==SQLITE_INSERT || eOp==SQLITE_UPDATE );\n\n    sessionAppendByte(&p->rebase, \n        (eOp==SQLITE_DELETE ? SQLITE_DELETE : SQLITE_INSERT), &rc\n        );\n    sessionAppendByte(&p->rebase, (eType==SQLITE_CHANGESET_REPLACE), &rc);\n    for(i=0; i<p->nCol; i++){\n      sqlite3_value *pVal = 0;\n      if( eOp==SQLITE_DELETE || (eOp==SQLITE_UPDATE && p->abPK[i]) ){\n        sqlite3changeset_old(pIter, i, &pVal);\n      }else{\n        sqlite3changeset_new(pIter, i, &pVal);\n      }\n      sessionAppendValue(&p->rebase, pVal, &rc);\n    }\n  }\n  return rc;\n}\n\n/*\n** Invoke the conflict handler for the change that the changeset iterator\n** currently points to.\n**\n** Argument eType must be either CHANGESET_DATA or CHANGESET_CONFLICT.\n** If argument pbReplace is NULL, then the type of conflict handler invoked\n** depends solely on eType, as follows:\n**\n**    eType value                 Value passed to xConflict\n**    -------------------------------------------------\n**    CHANGESET_DATA              CHANGESET_NOTFOUND\n**    CHANGESET_CONFLICT          CHANGESET_CONSTRAINT\n**\n** Or, if pbReplace is not NULL, then an attempt is made to find an existing\n** record with the same primary key as the record about to be deleted, updated\n** or inserted. If such a record can be found, it is available to the conflict\n** handler as the \"conflicting\" record. In this case the type of conflict\n** handler invoked is as follows:\n**\n**    eType value         PK Record found?   Value passed to xConflict\n**    ----------------------------------------------------------------\n**    CHANGESET_DATA      Yes                CHANGESET_DATA\n**    CHANGESET_DATA      No                 CHANGESET_NOTFOUND\n**    CHANGESET_CONFLICT  Yes                CHANGESET_CONFLICT\n**    CHANGESET_CONFLICT  No                 CHANGESET_CONSTRAINT\n**\n** If pbReplace is not NULL, and a record with a matching PK is found, and\n** the conflict handler function returns SQLITE_CHANGESET_REPLACE, *pbReplace\n** is set to non-zero before returning SQLITE_OK.\n**\n** If the conflict handler returns SQLITE_CHANGESET_ABORT, SQLITE_ABORT is\n** returned. Or, if the conflict handler returns an invalid value, \n** SQLITE_MISUSE. If the conflict handler returns SQLITE_CHANGESET_OMIT,\n** this function returns SQLITE_OK.\n*/\nstatic int sessionConflictHandler(\n  int eType,                      /* Either CHANGESET_DATA or CONFLICT */\n  SessionApplyCtx *p,             /* changeset_apply() context */\n  sqlite3_changeset_iter *pIter,  /* Changeset iterator */\n  int(*xConflict)(void *, int, sqlite3_changeset_iter*),\n  void *pCtx,                     /* First argument for conflict handler */\n  int *pbReplace                  /* OUT: Set to true if PK row is found */\n){\n  int res = 0;                    /* Value returned by conflict handler */\n  int rc;\n  int nCol;\n  int op;\n  const char *zDummy;\n\n  sqlite3changeset_op(pIter, &zDummy, &nCol, &op, 0);\n\n  assert( eType==SQLITE_CHANGESET_CONFLICT || eType==SQLITE_CHANGESET_DATA );\n  assert( SQLITE_CHANGESET_CONFLICT+1==SQLITE_CHANGESET_CONSTRAINT );\n  assert( SQLITE_CHANGESET_DATA+1==SQLITE_CHANGESET_NOTFOUND );\n\n  /* Bind the new.* PRIMARY KEY values to the SELECT statement. */\n  if( pbReplace ){\n    rc = sessionSeekToRow(p->db, pIter, p->abPK, p->pSelect);\n  }else{\n    rc = SQLITE_OK;\n  }\n\n  if( rc==SQLITE_ROW ){\n    /* There exists another row with the new.* primary key. */\n    pIter->pConflict = p->pSelect;\n    res = xConflict(pCtx, eType, pIter);\n    pIter->pConflict = 0;\n    rc = sqlite3_reset(p->pSelect);\n  }else if( rc==SQLITE_OK ){\n    if( p->bDeferConstraints && eType==SQLITE_CHANGESET_CONFLICT ){\n      /* Instead of invoking the conflict handler, append the change blob\n      ** to the SessionApplyCtx.constraints buffer. */\n      u8 *aBlob = &pIter->in.aData[pIter->in.iCurrent];\n      int nBlob = pIter->in.iNext - pIter->in.iCurrent;\n      sessionAppendBlob(&p->constraints, aBlob, nBlob, &rc);\n      return SQLITE_OK;\n    }else{\n      /* No other row with the new.* primary key. */\n      res = xConflict(pCtx, eType+1, pIter);\n      if( res==SQLITE_CHANGESET_REPLACE ) rc = SQLITE_MISUSE;\n    }\n  }\n\n  if( rc==SQLITE_OK ){\n    switch( res ){\n      case SQLITE_CHANGESET_REPLACE:\n        assert( pbReplace );\n        *pbReplace = 1;\n        break;\n\n      case SQLITE_CHANGESET_OMIT:\n        break;\n\n      case SQLITE_CHANGESET_ABORT:\n        rc = SQLITE_ABORT;\n        break;\n\n      default:\n        rc = SQLITE_MISUSE;\n        break;\n    }\n    if( rc==SQLITE_OK ){\n      rc = sessionRebaseAdd(p, res, pIter);\n    }\n  }\n\n  return rc;\n}\n\n/*\n** Attempt to apply the change that the iterator passed as the first argument\n** currently points to to the database. If a conflict is encountered, invoke\n** the conflict handler callback.\n**\n** If argument pbRetry is NULL, then ignore any CHANGESET_DATA conflict. If\n** one is encountered, update or delete the row with the matching primary key\n** instead. Or, if pbRetry is not NULL and a CHANGESET_DATA conflict occurs,\n** invoke the conflict handler. If it returns CHANGESET_REPLACE, set *pbRetry\n** to true before returning. In this case the caller will invoke this function\n** again, this time with pbRetry set to NULL.\n**\n** If argument pbReplace is NULL and a CHANGESET_CONFLICT conflict is \n** encountered invoke the conflict handler with CHANGESET_CONSTRAINT instead.\n** Or, if pbReplace is not NULL, invoke it with CHANGESET_CONFLICT. If such\n** an invocation returns SQLITE_CHANGESET_REPLACE, set *pbReplace to true\n** before retrying. In this case the caller attempts to remove the conflicting\n** row before invoking this function again, this time with pbReplace set \n** to NULL.\n**\n** If any conflict handler returns SQLITE_CHANGESET_ABORT, this function\n** returns SQLITE_ABORT. Otherwise, if no error occurs, SQLITE_OK is \n** returned.\n*/\nstatic int sessionApplyOneOp(\n  sqlite3_changeset_iter *pIter,  /* Changeset iterator */\n  SessionApplyCtx *p,             /* changeset_apply() context */\n  int(*xConflict)(void *, int, sqlite3_changeset_iter *),\n  void *pCtx,                     /* First argument for the conflict handler */\n  int *pbReplace,                 /* OUT: True to remove PK row and retry */\n  int *pbRetry                    /* OUT: True to retry. */\n){\n  const char *zDummy;\n  int op;\n  int nCol;\n  int rc = SQLITE_OK;\n\n  assert( p->pDelete && p->pUpdate && p->pInsert && p->pSelect );\n  assert( p->azCol && p->abPK );\n  assert( !pbReplace || *pbReplace==0 );\n\n  sqlite3changeset_op(pIter, &zDummy, &nCol, &op, 0);\n\n  if( op==SQLITE_DELETE ){\n\n    /* Bind values to the DELETE statement. If conflict handling is required,\n    ** bind values for all columns and set bound variable (nCol+1) to true.\n    ** Or, if conflict handling is not required, bind just the PK column\n    ** values and, if it exists, set (nCol+1) to false. Conflict handling\n    ** is not required if:\n    **\n    **   * this is a patchset, or\n    **   * (pbRetry==0), or\n    **   * all columns of the table are PK columns (in this case there is\n    **     no (nCol+1) variable to bind to).\n    */\n    u8 *abPK = (pIter->bPatchset ? p->abPK : 0);\n    rc = sessionBindRow(pIter, sqlite3changeset_old, nCol, abPK, p->pDelete);\n    if( rc==SQLITE_OK && sqlite3_bind_parameter_count(p->pDelete)>nCol ){\n      rc = sqlite3_bind_int(p->pDelete, nCol+1, (pbRetry==0 || abPK));\n    }\n    if( rc!=SQLITE_OK ) return rc;\n\n    sqlite3_step(p->pDelete);\n    rc = sqlite3_reset(p->pDelete);\n    if( rc==SQLITE_OK && sqlite3_changes(p->db)==0 ){\n      rc = sessionConflictHandler(\n          SQLITE_CHANGESET_DATA, p, pIter, xConflict, pCtx, pbRetry\n      );\n    }else if( (rc&0xff)==SQLITE_CONSTRAINT ){\n      rc = sessionConflictHandler(\n          SQLITE_CHANGESET_CONFLICT, p, pIter, xConflict, pCtx, 0\n      );\n    }\n\n  }else if( op==SQLITE_UPDATE ){\n    int i;\n\n    /* Bind values to the UPDATE statement. */\n    for(i=0; rc==SQLITE_OK && i<nCol; i++){\n      sqlite3_value *pOld = sessionChangesetOld(pIter, i);\n      sqlite3_value *pNew = sessionChangesetNew(pIter, i);\n\n      sqlite3_bind_int(p->pUpdate, i*3+2, !!pNew);\n      if( pOld ){\n        rc = sessionBindValue(p->pUpdate, i*3+1, pOld);\n      }\n      if( rc==SQLITE_OK && pNew ){\n        rc = sessionBindValue(p->pUpdate, i*3+3, pNew);\n      }\n    }\n    if( rc==SQLITE_OK ){\n      sqlite3_bind_int(p->pUpdate, nCol*3+1, pbRetry==0 || pIter->bPatchset);\n    }\n    if( rc!=SQLITE_OK ) return rc;\n\n    /* Attempt the UPDATE. In the case of a NOTFOUND or DATA conflict,\n    ** the result will be SQLITE_OK with 0 rows modified. */\n    sqlite3_step(p->pUpdate);\n    rc = sqlite3_reset(p->pUpdate);\n\n    if( rc==SQLITE_OK && sqlite3_changes(p->db)==0 ){\n      /* A NOTFOUND or DATA error. Search the table to see if it contains\n      ** a row with a matching primary key. If so, this is a DATA conflict.\n      ** Otherwise, if there is no primary key match, it is a NOTFOUND. */\n\n      rc = sessionConflictHandler(\n          SQLITE_CHANGESET_DATA, p, pIter, xConflict, pCtx, pbRetry\n      );\n\n    }else if( (rc&0xff)==SQLITE_CONSTRAINT ){\n      /* This is always a CONSTRAINT conflict. */\n      rc = sessionConflictHandler(\n          SQLITE_CHANGESET_CONFLICT, p, pIter, xConflict, pCtx, 0\n      );\n    }\n\n  }else{\n    assert( op==SQLITE_INSERT );\n    if( p->bStat1 ){\n      /* Check if there is a conflicting row. For sqlite_stat1, this needs\n      ** to be done using a SELECT, as there is no PRIMARY KEY in the \n      ** database schema to throw an exception if a duplicate is inserted.  */\n      rc = sessionSeekToRow(p->db, pIter, p->abPK, p->pSelect);\n      if( rc==SQLITE_ROW ){\n        rc = SQLITE_CONSTRAINT;\n        sqlite3_reset(p->pSelect);\n      }\n    }\n\n    if( rc==SQLITE_OK ){\n      rc = sessionBindRow(pIter, sqlite3changeset_new, nCol, 0, p->pInsert);\n      if( rc!=SQLITE_OK ) return rc;\n\n      sqlite3_step(p->pInsert);\n      rc = sqlite3_reset(p->pInsert);\n    }\n\n    if( (rc&0xff)==SQLITE_CONSTRAINT ){\n      rc = sessionConflictHandler(\n          SQLITE_CHANGESET_CONFLICT, p, pIter, xConflict, pCtx, pbReplace\n      );\n    }\n  }\n\n  return rc;\n}\n\n/*\n** Attempt to apply the change that the iterator passed as the first argument\n** currently points to to the database. If a conflict is encountered, invoke\n** the conflict handler callback.\n**\n** The difference between this function and sessionApplyOne() is that this\n** function handles the case where the conflict-handler is invoked and \n** returns SQLITE_CHANGESET_REPLACE - indicating that the change should be\n** retried in some manner.\n*/\nstatic int sessionApplyOneWithRetry(\n  sqlite3 *db,                    /* Apply change to \"main\" db of this handle */\n  sqlite3_changeset_iter *pIter,  /* Changeset iterator to read change from */\n  SessionApplyCtx *pApply,        /* Apply context */\n  int(*xConflict)(void*, int, sqlite3_changeset_iter*),\n  void *pCtx                      /* First argument passed to xConflict */\n){\n  int bReplace = 0;\n  int bRetry = 0;\n  int rc;\n\n  rc = sessionApplyOneOp(pIter, pApply, xConflict, pCtx, &bReplace, &bRetry);\n  if( rc==SQLITE_OK ){\n    /* If the bRetry flag is set, the change has not been applied due to an\n    ** SQLITE_CHANGESET_DATA problem (i.e. this is an UPDATE or DELETE and\n    ** a row with the correct PK is present in the db, but one or more other\n    ** fields do not contain the expected values) and the conflict handler \n    ** returned SQLITE_CHANGESET_REPLACE. In this case retry the operation,\n    ** but pass NULL as the final argument so that sessionApplyOneOp() ignores\n    ** the SQLITE_CHANGESET_DATA problem.  */\n    if( bRetry ){\n      assert( pIter->op==SQLITE_UPDATE || pIter->op==SQLITE_DELETE );\n      rc = sessionApplyOneOp(pIter, pApply, xConflict, pCtx, 0, 0);\n    }\n\n    /* If the bReplace flag is set, the change is an INSERT that has not\n    ** been performed because the database already contains a row with the\n    ** specified primary key and the conflict handler returned\n    ** SQLITE_CHANGESET_REPLACE. In this case remove the conflicting row\n    ** before reattempting the INSERT.  */\n    else if( bReplace ){\n      assert( pIter->op==SQLITE_INSERT );\n      rc = sqlite3_exec(db, \"SAVEPOINT replace_op\", 0, 0, 0);\n      if( rc==SQLITE_OK ){\n        rc = sessionBindRow(pIter, \n            sqlite3changeset_new, pApply->nCol, pApply->abPK, pApply->pDelete);\n        sqlite3_bind_int(pApply->pDelete, pApply->nCol+1, 1);\n      }\n      if( rc==SQLITE_OK ){\n        sqlite3_step(pApply->pDelete);\n        rc = sqlite3_reset(pApply->pDelete);\n      }\n      if( rc==SQLITE_OK ){\n        rc = sessionApplyOneOp(pIter, pApply, xConflict, pCtx, 0, 0);\n      }\n      if( rc==SQLITE_OK ){\n        rc = sqlite3_exec(db, \"RELEASE replace_op\", 0, 0, 0);\n      }\n    }\n  }\n\n  return rc;\n}\n\n/*\n** Retry the changes accumulated in the pApply->constraints buffer.\n*/\nstatic int sessionRetryConstraints(\n  sqlite3 *db, \n  int bPatchset,\n  const char *zTab,\n  SessionApplyCtx *pApply,\n  int(*xConflict)(void*, int, sqlite3_changeset_iter*),\n  void *pCtx                      /* First argument passed to xConflict */\n){\n  int rc = SQLITE_OK;\n\n  while( pApply->constraints.nBuf ){\n    sqlite3_changeset_iter *pIter2 = 0;\n    SessionBuffer cons = pApply->constraints;\n    memset(&pApply->constraints, 0, sizeof(SessionBuffer));\n\n    rc = sessionChangesetStart(&pIter2, 0, 0, cons.nBuf, cons.aBuf, 0);\n    if( rc==SQLITE_OK ){\n      int nByte = 2*pApply->nCol*sizeof(sqlite3_value*);\n      int rc2;\n      pIter2->bPatchset = bPatchset;\n      pIter2->zTab = (char*)zTab;\n      pIter2->nCol = pApply->nCol;\n      pIter2->abPK = pApply->abPK;\n      sessionBufferGrow(&pIter2->tblhdr, nByte, &rc);\n      pIter2->apValue = (sqlite3_value**)pIter2->tblhdr.aBuf;\n      if( rc==SQLITE_OK ) memset(pIter2->apValue, 0, nByte);\n\n      while( rc==SQLITE_OK && SQLITE_ROW==sqlite3changeset_next(pIter2) ){\n        rc = sessionApplyOneWithRetry(db, pIter2, pApply, xConflict, pCtx);\n      }\n\n      rc2 = sqlite3changeset_finalize(pIter2);\n      if( rc==SQLITE_OK ) rc = rc2;\n    }\n    assert( pApply->bDeferConstraints || pApply->constraints.nBuf==0 );\n\n    sqlite3_free(cons.aBuf);\n    if( rc!=SQLITE_OK ) break;\n    if( pApply->constraints.nBuf>=cons.nBuf ){\n      /* No progress was made on the last round. */\n      pApply->bDeferConstraints = 0;\n    }\n  }\n\n  return rc;\n}\n\n/*\n** Argument pIter is a changeset iterator that has been initialized, but\n** not yet passed to sqlite3changeset_next(). This function applies the \n** changeset to the main database attached to handle \"db\". The supplied\n** conflict handler callback is invoked to resolve any conflicts encountered\n** while applying the change.\n*/\nstatic int sessionChangesetApply(\n  sqlite3 *db,                    /* Apply change to \"main\" db of this handle */\n  sqlite3_changeset_iter *pIter,  /* Changeset to apply */\n  int(*xFilter)(\n    void *pCtx,                   /* Copy of sixth arg to _apply() */\n    const char *zTab              /* Table name */\n  ),\n  int(*xConflict)(\n    void *pCtx,                   /* Copy of fifth arg to _apply() */\n    int eConflict,                /* DATA, MISSING, CONFLICT, CONSTRAINT */\n    sqlite3_changeset_iter *p     /* Handle describing change and conflict */\n  ),\n  void *pCtx,                     /* First argument passed to xConflict */\n  void **ppRebase, int *pnRebase, /* OUT: Rebase information */\n  int flags                       /* SESSION_APPLY_XXX flags */\n){\n  int schemaMismatch = 0;\n  int rc = SQLITE_OK;             /* Return code */\n  const char *zTab = 0;           /* Name of current table */\n  int nTab = 0;                   /* Result of sqlite3Strlen30(zTab) */\n  SessionApplyCtx sApply;         /* changeset_apply() context object */\n  int bPatchset;\n\n  assert( xConflict!=0 );\n\n  pIter->in.bNoDiscard = 1;\n  memset(&sApply, 0, sizeof(sApply));\n  sApply.bRebase = (ppRebase && pnRebase);\n  sqlite3_mutex_enter(sqlite3_db_mutex(db));\n  if( (flags & SQLITE_CHANGESETAPPLY_NOSAVEPOINT)==0 ){\n    rc = sqlite3_exec(db, \"SAVEPOINT changeset_apply\", 0, 0, 0);\n  }\n  if( rc==SQLITE_OK ){\n    rc = sqlite3_exec(db, \"PRAGMA defer_foreign_keys = 1\", 0, 0, 0);\n  }\n  while( rc==SQLITE_OK && SQLITE_ROW==sqlite3changeset_next(pIter) ){\n    int nCol;\n    int op;\n    const char *zNew;\n    \n    sqlite3changeset_op(pIter, &zNew, &nCol, &op, 0);\n\n    if( zTab==0 || sqlite3_strnicmp(zNew, zTab, nTab+1) ){\n      u8 *abPK;\n\n      rc = sessionRetryConstraints(\n          db, pIter->bPatchset, zTab, &sApply, xConflict, pCtx\n      );\n      if( rc!=SQLITE_OK ) break;\n\n      sqlite3_free((char*)sApply.azCol);  /* cast works around VC++ bug */\n      sqlite3_finalize(sApply.pDelete);\n      sqlite3_finalize(sApply.pUpdate); \n      sqlite3_finalize(sApply.pInsert);\n      sqlite3_finalize(sApply.pSelect);\n      sApply.db = db;\n      sApply.pDelete = 0;\n      sApply.pUpdate = 0;\n      sApply.pInsert = 0;\n      sApply.pSelect = 0;\n      sApply.nCol = 0;\n      sApply.azCol = 0;\n      sApply.abPK = 0;\n      sApply.bStat1 = 0;\n      sApply.bDeferConstraints = 1;\n      sApply.bRebaseStarted = 0;\n      memset(&sApply.constraints, 0, sizeof(SessionBuffer));\n\n      /* If an xFilter() callback was specified, invoke it now. If the \n      ** xFilter callback returns zero, skip this table. If it returns\n      ** non-zero, proceed. */\n      schemaMismatch = (xFilter && (0==xFilter(pCtx, zNew)));\n      if( schemaMismatch ){\n        zTab = sqlite3_mprintf(\"%s\", zNew);\n        if( zTab==0 ){\n          rc = SQLITE_NOMEM;\n          break;\n        }\n        nTab = (int)strlen(zTab);\n        sApply.azCol = (const char **)zTab;\n      }else{\n        int nMinCol = 0;\n        int i;\n\n        sqlite3changeset_pk(pIter, &abPK, 0);\n        rc = sessionTableInfo(\n            db, \"main\", zNew, &sApply.nCol, &zTab, &sApply.azCol, &sApply.abPK\n        );\n        if( rc!=SQLITE_OK ) break;\n        for(i=0; i<sApply.nCol; i++){\n          if( sApply.abPK[i] ) nMinCol = i+1;\n        }\n  \n        if( sApply.nCol==0 ){\n          schemaMismatch = 1;\n          sqlite3_log(SQLITE_SCHEMA, \n              \"sqlite3changeset_apply(): no such table: %s\", zTab\n          );\n        }\n        else if( sApply.nCol<nCol ){\n          schemaMismatch = 1;\n          sqlite3_log(SQLITE_SCHEMA, \n              \"sqlite3changeset_apply(): table %s has %d columns, \"\n              \"expected %d or more\", \n              zTab, sApply.nCol, nCol\n          );\n        }\n        else if( nCol<nMinCol || memcmp(sApply.abPK, abPK, nCol)!=0 ){\n          schemaMismatch = 1;\n          sqlite3_log(SQLITE_SCHEMA, \"sqlite3changeset_apply(): \"\n              \"primary key mismatch for table %s\", zTab\n          );\n        }\n        else{\n          sApply.nCol = nCol;\n          if( 0==sqlite3_stricmp(zTab, \"sqlite_stat1\") ){\n            if( (rc = sessionStat1Sql(db, &sApply) ) ){\n              break;\n            }\n            sApply.bStat1 = 1;\n          }else{\n            if((rc = sessionSelectRow(db, zTab, &sApply))\n                || (rc = sessionUpdateRow(db, zTab, &sApply))\n                || (rc = sessionDeleteRow(db, zTab, &sApply))\n                || (rc = sessionInsertRow(db, zTab, &sApply))\n              ){\n              break;\n            }\n            sApply.bStat1 = 0;\n          }\n        }\n        nTab = sqlite3Strlen30(zTab);\n      }\n    }\n\n    /* If there is a schema mismatch on the current table, proceed to the\n    ** next change. A log message has already been issued. */\n    if( schemaMismatch ) continue;\n\n    rc = sessionApplyOneWithRetry(db, pIter, &sApply, xConflict, pCtx);\n  }\n\n  bPatchset = pIter->bPatchset;\n  if( rc==SQLITE_OK ){\n    rc = sqlite3changeset_finalize(pIter);\n  }else{\n    sqlite3changeset_finalize(pIter);\n  }\n\n  if( rc==SQLITE_OK ){\n    rc = sessionRetryConstraints(db, bPatchset, zTab, &sApply, xConflict, pCtx);\n  }\n\n  if( rc==SQLITE_OK ){\n    int nFk, notUsed;\n    sqlite3_db_status(db, SQLITE_DBSTATUS_DEFERRED_FKS, &nFk, &notUsed, 0);\n    if( nFk!=0 ){\n      int res = SQLITE_CHANGESET_ABORT;\n      sqlite3_changeset_iter sIter;\n      memset(&sIter, 0, sizeof(sIter));\n      sIter.nCol = nFk;\n      res = xConflict(pCtx, SQLITE_CHANGESET_FOREIGN_KEY, &sIter);\n      if( res!=SQLITE_CHANGESET_OMIT ){\n        rc = SQLITE_CONSTRAINT;\n      }\n    }\n  }\n  sqlite3_exec(db, \"PRAGMA defer_foreign_keys = 0\", 0, 0, 0);\n\n  if( (flags & SQLITE_CHANGESETAPPLY_NOSAVEPOINT)==0 ){\n    if( rc==SQLITE_OK ){\n      rc = sqlite3_exec(db, \"RELEASE changeset_apply\", 0, 0, 0);\n    }else{\n      sqlite3_exec(db, \"ROLLBACK TO changeset_apply\", 0, 0, 0);\n      sqlite3_exec(db, \"RELEASE changeset_apply\", 0, 0, 0);\n    }\n  }\n\n  assert( sApply.bRebase || sApply.rebase.nBuf==0 );\n  if( rc==SQLITE_OK && bPatchset==0 && sApply.bRebase ){\n    *ppRebase = (void*)sApply.rebase.aBuf;\n    *pnRebase = sApply.rebase.nBuf;\n    sApply.rebase.aBuf = 0;\n  }\n  sqlite3_finalize(sApply.pInsert);\n  sqlite3_finalize(sApply.pDelete);\n  sqlite3_finalize(sApply.pUpdate);\n  sqlite3_finalize(sApply.pSelect);\n  sqlite3_free((char*)sApply.azCol);  /* cast works around VC++ bug */\n  sqlite3_free((char*)sApply.constraints.aBuf);\n  sqlite3_free((char*)sApply.rebase.aBuf);\n  sqlite3_mutex_leave(sqlite3_db_mutex(db));\n  return rc;\n}\n\n/*\n** Apply the changeset passed via pChangeset/nChangeset to the main \n** database attached to handle \"db\".\n*/\nSQLITE_API int sqlite3changeset_apply_v2(\n  sqlite3 *db,                    /* Apply change to \"main\" db of this handle */\n  int nChangeset,                 /* Size of changeset in bytes */\n  void *pChangeset,               /* Changeset blob */\n  int(*xFilter)(\n    void *pCtx,                   /* Copy of sixth arg to _apply() */\n    const char *zTab              /* Table name */\n  ),\n  int(*xConflict)(\n    void *pCtx,                   /* Copy of sixth arg to _apply() */\n    int eConflict,                /* DATA, MISSING, CONFLICT, CONSTRAINT */\n    sqlite3_changeset_iter *p     /* Handle describing change and conflict */\n  ),\n  void *pCtx,                     /* First argument passed to xConflict */\n  void **ppRebase, int *pnRebase,\n  int flags\n){\n  sqlite3_changeset_iter *pIter;  /* Iterator to skip through changeset */  \n  int bInverse = !!(flags & SQLITE_CHANGESETAPPLY_INVERT);\n  int rc = sessionChangesetStart(&pIter, 0, 0, nChangeset, pChangeset,bInverse);\n  if( rc==SQLITE_OK ){\n    rc = sessionChangesetApply(\n        db, pIter, xFilter, xConflict, pCtx, ppRebase, pnRebase, flags\n    );\n  }\n  return rc;\n}\n\n/*\n** Apply the changeset passed via pChangeset/nChangeset to the main database\n** attached to handle \"db\". Invoke the supplied conflict handler callback\n** to resolve any conflicts encountered while applying the change.\n*/\nSQLITE_API int sqlite3changeset_apply(\n  sqlite3 *db,                    /* Apply change to \"main\" db of this handle */\n  int nChangeset,                 /* Size of changeset in bytes */\n  void *pChangeset,               /* Changeset blob */\n  int(*xFilter)(\n    void *pCtx,                   /* Copy of sixth arg to _apply() */\n    const char *zTab              /* Table name */\n  ),\n  int(*xConflict)(\n    void *pCtx,                   /* Copy of fifth arg to _apply() */\n    int eConflict,                /* DATA, MISSING, CONFLICT, CONSTRAINT */\n    sqlite3_changeset_iter *p     /* Handle describing change and conflict */\n  ),\n  void *pCtx                      /* First argument passed to xConflict */\n){\n  return sqlite3changeset_apply_v2(\n      db, nChangeset, pChangeset, xFilter, xConflict, pCtx, 0, 0, 0\n  );\n}\n\n/*\n** Apply the changeset passed via xInput/pIn to the main database\n** attached to handle \"db\". Invoke the supplied conflict handler callback\n** to resolve any conflicts encountered while applying the change.\n*/\nSQLITE_API int sqlite3changeset_apply_v2_strm(\n  sqlite3 *db,                    /* Apply change to \"main\" db of this handle */\n  int (*xInput)(void *pIn, void *pData, int *pnData), /* Input function */\n  void *pIn,                                          /* First arg for xInput */\n  int(*xFilter)(\n    void *pCtx,                   /* Copy of sixth arg to _apply() */\n    const char *zTab              /* Table name */\n  ),\n  int(*xConflict)(\n    void *pCtx,                   /* Copy of sixth arg to _apply() */\n    int eConflict,                /* DATA, MISSING, CONFLICT, CONSTRAINT */\n    sqlite3_changeset_iter *p     /* Handle describing change and conflict */\n  ),\n  void *pCtx,                     /* First argument passed to xConflict */\n  void **ppRebase, int *pnRebase,\n  int flags\n){\n  sqlite3_changeset_iter *pIter;  /* Iterator to skip through changeset */  \n  int bInverse = !!(flags & SQLITE_CHANGESETAPPLY_INVERT);\n  int rc = sessionChangesetStart(&pIter, xInput, pIn, 0, 0, bInverse);\n  if( rc==SQLITE_OK ){\n    rc = sessionChangesetApply(\n        db, pIter, xFilter, xConflict, pCtx, ppRebase, pnRebase, flags\n    );\n  }\n  return rc;\n}\nSQLITE_API int sqlite3changeset_apply_strm(\n  sqlite3 *db,                    /* Apply change to \"main\" db of this handle */\n  int (*xInput)(void *pIn, void *pData, int *pnData), /* Input function */\n  void *pIn,                                          /* First arg for xInput */\n  int(*xFilter)(\n    void *pCtx,                   /* Copy of sixth arg to _apply() */\n    const char *zTab              /* Table name */\n  ),\n  int(*xConflict)(\n    void *pCtx,                   /* Copy of sixth arg to _apply() */\n    int eConflict,                /* DATA, MISSING, CONFLICT, CONSTRAINT */\n    sqlite3_changeset_iter *p     /* Handle describing change and conflict */\n  ),\n  void *pCtx                      /* First argument passed to xConflict */\n){\n  return sqlite3changeset_apply_v2_strm(\n      db, xInput, pIn, xFilter, xConflict, pCtx, 0, 0, 0\n  );\n}\n\n/*\n** sqlite3_changegroup handle.\n*/\nstruct sqlite3_changegroup {\n  int rc;                         /* Error code */\n  int bPatch;                     /* True to accumulate patchsets */\n  SessionTable *pList;            /* List of tables in current patch */\n};\n\n/*\n** This function is called to merge two changes to the same row together as\n** part of an sqlite3changeset_concat() operation. A new change object is\n** allocated and a pointer to it stored in *ppNew.\n*/\nstatic int sessionChangeMerge(\n  SessionTable *pTab,             /* Table structure */\n  int bRebase,                    /* True for a rebase hash-table */\n  int bPatchset,                  /* True for patchsets */\n  SessionChange *pExist,          /* Existing change */\n  int op2,                        /* Second change operation */\n  int bIndirect,                  /* True if second change is indirect */\n  u8 *aRec,                       /* Second change record */\n  int nRec,                       /* Number of bytes in aRec */\n  SessionChange **ppNew           /* OUT: Merged change */\n){\n  SessionChange *pNew = 0;\n  int rc = SQLITE_OK;\n\n  if( !pExist ){\n    pNew = (SessionChange *)sqlite3_malloc64(sizeof(SessionChange) + nRec);\n    if( !pNew ){\n      return SQLITE_NOMEM;\n    }\n    memset(pNew, 0, sizeof(SessionChange));\n    pNew->op = op2;\n    pNew->bIndirect = bIndirect;\n    pNew->aRecord = (u8*)&pNew[1];\n    if( bIndirect==0 || bRebase==0 ){\n      pNew->nRecord = nRec;\n      memcpy(pNew->aRecord, aRec, nRec);\n    }else{\n      int i;\n      u8 *pIn = aRec;\n      u8 *pOut = pNew->aRecord;\n      for(i=0; i<pTab->nCol; i++){\n        int nIn = sessionSerialLen(pIn);\n        if( *pIn==0 ){\n          *pOut++ = 0;\n        }else if( pTab->abPK[i]==0 ){\n          *pOut++ = 0xFF;\n        }else{\n          memcpy(pOut, pIn, nIn);\n          pOut += nIn;\n        }\n        pIn += nIn;\n      }\n      pNew->nRecord = pOut - pNew->aRecord;\n    }\n  }else if( bRebase ){\n    if( pExist->op==SQLITE_DELETE && pExist->bIndirect ){\n      *ppNew = pExist;\n    }else{\n      sqlite3_int64 nByte = nRec + pExist->nRecord + sizeof(SessionChange);\n      pNew = (SessionChange*)sqlite3_malloc64(nByte);\n      if( pNew==0 ){\n        rc = SQLITE_NOMEM;\n      }else{\n        int i;\n        u8 *a1 = pExist->aRecord;\n        u8 *a2 = aRec;\n        u8 *pOut;\n\n        memset(pNew, 0, nByte);\n        pNew->bIndirect = bIndirect || pExist->bIndirect;\n        pNew->op = op2;\n        pOut = pNew->aRecord = (u8*)&pNew[1];\n\n        for(i=0; i<pTab->nCol; i++){\n          int n1 = sessionSerialLen(a1);\n          int n2 = sessionSerialLen(a2);\n          if( *a1==0xFF || (pTab->abPK[i]==0 && bIndirect) ){\n            *pOut++ = 0xFF;\n          }else if( *a2==0 ){\n            memcpy(pOut, a1, n1);\n            pOut += n1;\n          }else{\n            memcpy(pOut, a2, n2);\n            pOut += n2;\n          }\n          a1 += n1;\n          a2 += n2;\n        }\n        pNew->nRecord = pOut - pNew->aRecord;\n      }\n      sqlite3_free(pExist);\n    }\n  }else{\n    int op1 = pExist->op;\n\n    /* \n    **   op1=INSERT, op2=INSERT      ->      Unsupported. Discard op2.\n    **   op1=INSERT, op2=UPDATE      ->      INSERT.\n    **   op1=INSERT, op2=DELETE      ->      (none)\n    **\n    **   op1=UPDATE, op2=INSERT      ->      Unsupported. Discard op2.\n    **   op1=UPDATE, op2=UPDATE      ->      UPDATE.\n    **   op1=UPDATE, op2=DELETE      ->      DELETE.\n    **\n    **   op1=DELETE, op2=INSERT      ->      UPDATE.\n    **   op1=DELETE, op2=UPDATE      ->      Unsupported. Discard op2.\n    **   op1=DELETE, op2=DELETE      ->      Unsupported. Discard op2.\n    */   \n    if( (op1==SQLITE_INSERT && op2==SQLITE_INSERT)\n     || (op1==SQLITE_UPDATE && op2==SQLITE_INSERT)\n     || (op1==SQLITE_DELETE && op2==SQLITE_UPDATE)\n     || (op1==SQLITE_DELETE && op2==SQLITE_DELETE)\n    ){\n      pNew = pExist;\n    }else if( op1==SQLITE_INSERT && op2==SQLITE_DELETE ){\n      sqlite3_free(pExist);\n      assert( pNew==0 );\n    }else{\n      u8 *aExist = pExist->aRecord;\n      sqlite3_int64 nByte;\n      u8 *aCsr;\n\n      /* Allocate a new SessionChange object. Ensure that the aRecord[]\n      ** buffer of the new object is large enough to hold any record that\n      ** may be generated by combining the input records.  */\n      nByte = sizeof(SessionChange) + pExist->nRecord + nRec;\n      pNew = (SessionChange *)sqlite3_malloc64(nByte);\n      if( !pNew ){\n        sqlite3_free(pExist);\n        return SQLITE_NOMEM;\n      }\n      memset(pNew, 0, sizeof(SessionChange));\n      pNew->bIndirect = (bIndirect && pExist->bIndirect);\n      aCsr = pNew->aRecord = (u8 *)&pNew[1];\n\n      if( op1==SQLITE_INSERT ){             /* INSERT + UPDATE */\n        u8 *a1 = aRec;\n        assert( op2==SQLITE_UPDATE );\n        pNew->op = SQLITE_INSERT;\n        if( bPatchset==0 ) sessionSkipRecord(&a1, pTab->nCol);\n        sessionMergeRecord(&aCsr, pTab->nCol, aExist, a1);\n      }else if( op1==SQLITE_DELETE ){       /* DELETE + INSERT */\n        assert( op2==SQLITE_INSERT );\n        pNew->op = SQLITE_UPDATE;\n        if( bPatchset ){\n          memcpy(aCsr, aRec, nRec);\n          aCsr += nRec;\n        }else{\n          if( 0==sessionMergeUpdate(&aCsr, pTab, bPatchset, aExist, 0,aRec,0) ){\n            sqlite3_free(pNew);\n            pNew = 0;\n          }\n        }\n      }else if( op2==SQLITE_UPDATE ){       /* UPDATE + UPDATE */\n        u8 *a1 = aExist;\n        u8 *a2 = aRec;\n        assert( op1==SQLITE_UPDATE );\n        if( bPatchset==0 ){\n          sessionSkipRecord(&a1, pTab->nCol);\n          sessionSkipRecord(&a2, pTab->nCol);\n        }\n        pNew->op = SQLITE_UPDATE;\n        if( 0==sessionMergeUpdate(&aCsr, pTab, bPatchset, aRec, aExist,a1,a2) ){\n          sqlite3_free(pNew);\n          pNew = 0;\n        }\n      }else{                                /* UPDATE + DELETE */\n        assert( op1==SQLITE_UPDATE && op2==SQLITE_DELETE );\n        pNew->op = SQLITE_DELETE;\n        if( bPatchset ){\n          memcpy(aCsr, aRec, nRec);\n          aCsr += nRec;\n        }else{\n          sessionMergeRecord(&aCsr, pTab->nCol, aRec, aExist);\n        }\n      }\n\n      if( pNew ){\n        pNew->nRecord = (int)(aCsr - pNew->aRecord);\n      }\n      sqlite3_free(pExist);\n    }\n  }\n\n  *ppNew = pNew;\n  return rc;\n}\n\n/*\n** Add all changes in the changeset traversed by the iterator passed as\n** the first argument to the changegroup hash tables.\n*/\nstatic int sessionChangesetToHash(\n  sqlite3_changeset_iter *pIter,   /* Iterator to read from */\n  sqlite3_changegroup *pGrp,       /* Changegroup object to add changeset to */\n  int bRebase                      /* True if hash table is for rebasing */\n){\n  u8 *aRec;\n  int nRec;\n  int rc = SQLITE_OK;\n  SessionTable *pTab = 0;\n\n  while( SQLITE_ROW==sessionChangesetNext(pIter, &aRec, &nRec, 0) ){\n    const char *zNew;\n    int nCol;\n    int op;\n    int iHash;\n    int bIndirect;\n    SessionChange *pChange;\n    SessionChange *pExist = 0;\n    SessionChange **pp;\n\n    if( pGrp->pList==0 ){\n      pGrp->bPatch = pIter->bPatchset;\n    }else if( pIter->bPatchset!=pGrp->bPatch ){\n      rc = SQLITE_ERROR;\n      break;\n    }\n\n    sqlite3changeset_op(pIter, &zNew, &nCol, &op, &bIndirect);\n    if( !pTab || sqlite3_stricmp(zNew, pTab->zName) ){\n      /* Search the list for a matching table */\n      int nNew = (int)strlen(zNew);\n      u8 *abPK;\n\n      sqlite3changeset_pk(pIter, &abPK, 0);\n      for(pTab = pGrp->pList; pTab; pTab=pTab->pNext){\n        if( 0==sqlite3_strnicmp(pTab->zName, zNew, nNew+1) ) break;\n      }\n      if( !pTab ){\n        SessionTable **ppTab;\n\n        pTab = sqlite3_malloc64(sizeof(SessionTable) + nCol + nNew+1);\n        if( !pTab ){\n          rc = SQLITE_NOMEM;\n          break;\n        }\n        memset(pTab, 0, sizeof(SessionTable));\n        pTab->nCol = nCol;\n        pTab->abPK = (u8*)&pTab[1];\n        memcpy(pTab->abPK, abPK, nCol);\n        pTab->zName = (char*)&pTab->abPK[nCol];\n        memcpy(pTab->zName, zNew, nNew+1);\n\n        /* The new object must be linked on to the end of the list, not\n        ** simply added to the start of it. This is to ensure that the\n        ** tables within the output of sqlite3changegroup_output() are in \n        ** the right order.  */\n        for(ppTab=&pGrp->pList; *ppTab; ppTab=&(*ppTab)->pNext);\n        *ppTab = pTab;\n      }else if( pTab->nCol!=nCol || memcmp(pTab->abPK, abPK, nCol) ){\n        rc = SQLITE_SCHEMA;\n        break;\n      }\n    }\n\n    if( sessionGrowHash(pIter->bPatchset, pTab) ){\n      rc = SQLITE_NOMEM;\n      break;\n    }\n    iHash = sessionChangeHash(\n        pTab, (pIter->bPatchset && op==SQLITE_DELETE), aRec, pTab->nChange\n    );\n\n    /* Search for existing entry. If found, remove it from the hash table. \n    ** Code below may link it back in.\n    */\n    for(pp=&pTab->apChange[iHash]; *pp; pp=&(*pp)->pNext){\n      int bPkOnly1 = 0;\n      int bPkOnly2 = 0;\n      if( pIter->bPatchset ){\n        bPkOnly1 = (*pp)->op==SQLITE_DELETE;\n        bPkOnly2 = op==SQLITE_DELETE;\n      }\n      if( sessionChangeEqual(pTab, bPkOnly1, (*pp)->aRecord, bPkOnly2, aRec) ){\n        pExist = *pp;\n        *pp = (*pp)->pNext;\n        pTab->nEntry--;\n        break;\n      }\n    }\n\n    rc = sessionChangeMerge(pTab, bRebase, \n        pIter->bPatchset, pExist, op, bIndirect, aRec, nRec, &pChange\n    );\n    if( rc ) break;\n    if( pChange ){\n      pChange->pNext = pTab->apChange[iHash];\n      pTab->apChange[iHash] = pChange;\n      pTab->nEntry++;\n    }\n  }\n\n  if( rc==SQLITE_OK ) rc = pIter->rc;\n  return rc;\n}\n\n/*\n** Serialize a changeset (or patchset) based on all changesets (or patchsets)\n** added to the changegroup object passed as the first argument.\n**\n** If xOutput is not NULL, then the changeset/patchset is returned to the\n** user via one or more calls to xOutput, as with the other streaming\n** interfaces. \n**\n** Or, if xOutput is NULL, then (*ppOut) is populated with a pointer to a\n** buffer containing the output changeset before this function returns. In\n** this case (*pnOut) is set to the size of the output buffer in bytes. It\n** is the responsibility of the caller to free the output buffer using\n** sqlite3_free() when it is no longer required.\n**\n** If successful, SQLITE_OK is returned. Or, if an error occurs, an SQLite\n** error code. If an error occurs and xOutput is NULL, (*ppOut) and (*pnOut)\n** are both set to 0 before returning.\n*/\nstatic int sessionChangegroupOutput(\n  sqlite3_changegroup *pGrp,\n  int (*xOutput)(void *pOut, const void *pData, int nData),\n  void *pOut,\n  int *pnOut,\n  void **ppOut\n){\n  int rc = SQLITE_OK;\n  SessionBuffer buf = {0, 0, 0};\n  SessionTable *pTab;\n  assert( xOutput==0 || (ppOut==0 && pnOut==0) );\n\n  /* Create the serialized output changeset based on the contents of the\n  ** hash tables attached to the SessionTable objects in list p->pList. \n  */\n  for(pTab=pGrp->pList; rc==SQLITE_OK && pTab; pTab=pTab->pNext){\n    int i;\n    if( pTab->nEntry==0 ) continue;\n\n    sessionAppendTableHdr(&buf, pGrp->bPatch, pTab, &rc);\n    for(i=0; i<pTab->nChange; i++){\n      SessionChange *p;\n      for(p=pTab->apChange[i]; p; p=p->pNext){\n        sessionAppendByte(&buf, p->op, &rc);\n        sessionAppendByte(&buf, p->bIndirect, &rc);\n        sessionAppendBlob(&buf, p->aRecord, p->nRecord, &rc);\n        if( rc==SQLITE_OK && xOutput && buf.nBuf>=sessions_strm_chunk_size ){\n          rc = xOutput(pOut, buf.aBuf, buf.nBuf);\n          buf.nBuf = 0;\n        }\n      }\n    }\n  }\n\n  if( rc==SQLITE_OK ){\n    if( xOutput ){\n      if( buf.nBuf>0 ) rc = xOutput(pOut, buf.aBuf, buf.nBuf);\n    }else{\n      *ppOut = buf.aBuf;\n      *pnOut = buf.nBuf;\n      buf.aBuf = 0;\n    }\n  }\n  sqlite3_free(buf.aBuf);\n\n  return rc;\n}\n\n/*\n** Allocate a new, empty, sqlite3_changegroup.\n*/\nSQLITE_API int sqlite3changegroup_new(sqlite3_changegroup **pp){\n  int rc = SQLITE_OK;             /* Return code */\n  sqlite3_changegroup *p;         /* New object */\n  p = (sqlite3_changegroup*)sqlite3_malloc(sizeof(sqlite3_changegroup));\n  if( p==0 ){\n    rc = SQLITE_NOMEM;\n  }else{\n    memset(p, 0, sizeof(sqlite3_changegroup));\n  }\n  *pp = p;\n  return rc;\n}\n\n/*\n** Add the changeset currently stored in buffer pData, size nData bytes,\n** to changeset-group p.\n*/\nSQLITE_API int sqlite3changegroup_add(sqlite3_changegroup *pGrp, int nData, void *pData){\n  sqlite3_changeset_iter *pIter;  /* Iterator opened on pData/nData */\n  int rc;                         /* Return code */\n\n  rc = sqlite3changeset_start(&pIter, nData, pData);\n  if( rc==SQLITE_OK ){\n    rc = sessionChangesetToHash(pIter, pGrp, 0);\n  }\n  sqlite3changeset_finalize(pIter);\n  return rc;\n}\n\n/*\n** Obtain a buffer containing a changeset representing the concatenation\n** of all changesets added to the group so far.\n*/\nSQLITE_API int sqlite3changegroup_output(\n    sqlite3_changegroup *pGrp,\n    int *pnData,\n    void **ppData\n){\n  return sessionChangegroupOutput(pGrp, 0, 0, pnData, ppData);\n}\n\n/*\n** Streaming versions of changegroup_add().\n*/\nSQLITE_API int sqlite3changegroup_add_strm(\n  sqlite3_changegroup *pGrp,\n  int (*xInput)(void *pIn, void *pData, int *pnData),\n  void *pIn\n){\n  sqlite3_changeset_iter *pIter;  /* Iterator opened on pData/nData */\n  int rc;                         /* Return code */\n\n  rc = sqlite3changeset_start_strm(&pIter, xInput, pIn);\n  if( rc==SQLITE_OK ){\n    rc = sessionChangesetToHash(pIter, pGrp, 0);\n  }\n  sqlite3changeset_finalize(pIter);\n  return rc;\n}\n\n/*\n** Streaming versions of changegroup_output().\n*/\nSQLITE_API int sqlite3changegroup_output_strm(\n  sqlite3_changegroup *pGrp,\n  int (*xOutput)(void *pOut, const void *pData, int nData), \n  void *pOut\n){\n  return sessionChangegroupOutput(pGrp, xOutput, pOut, 0, 0);\n}\n\n/*\n** Delete a changegroup object.\n*/\nSQLITE_API void sqlite3changegroup_delete(sqlite3_changegroup *pGrp){\n  if( pGrp ){\n    sessionDeleteTable(pGrp->pList);\n    sqlite3_free(pGrp);\n  }\n}\n\n/* \n** Combine two changesets together.\n*/\nSQLITE_API int sqlite3changeset_concat(\n  int nLeft,                      /* Number of bytes in lhs input */\n  void *pLeft,                    /* Lhs input changeset */\n  int nRight                      /* Number of bytes in rhs input */,\n  void *pRight,                   /* Rhs input changeset */\n  int *pnOut,                     /* OUT: Number of bytes in output changeset */\n  void **ppOut                    /* OUT: changeset (left <concat> right) */\n){\n  sqlite3_changegroup *pGrp;\n  int rc;\n\n  rc = sqlite3changegroup_new(&pGrp);\n  if( rc==SQLITE_OK ){\n    rc = sqlite3changegroup_add(pGrp, nLeft, pLeft);\n  }\n  if( rc==SQLITE_OK ){\n    rc = sqlite3changegroup_add(pGrp, nRight, pRight);\n  }\n  if( rc==SQLITE_OK ){\n    rc = sqlite3changegroup_output(pGrp, pnOut, ppOut);\n  }\n  sqlite3changegroup_delete(pGrp);\n\n  return rc;\n}\n\n/*\n** Streaming version of sqlite3changeset_concat().\n*/\nSQLITE_API int sqlite3changeset_concat_strm(\n  int (*xInputA)(void *pIn, void *pData, int *pnData),\n  void *pInA,\n  int (*xInputB)(void *pIn, void *pData, int *pnData),\n  void *pInB,\n  int (*xOutput)(void *pOut, const void *pData, int nData),\n  void *pOut\n){\n  sqlite3_changegroup *pGrp;\n  int rc;\n\n  rc = sqlite3changegroup_new(&pGrp);\n  if( rc==SQLITE_OK ){\n    rc = sqlite3changegroup_add_strm(pGrp, xInputA, pInA);\n  }\n  if( rc==SQLITE_OK ){\n    rc = sqlite3changegroup_add_strm(pGrp, xInputB, pInB);\n  }\n  if( rc==SQLITE_OK ){\n    rc = sqlite3changegroup_output_strm(pGrp, xOutput, pOut);\n  }\n  sqlite3changegroup_delete(pGrp);\n\n  return rc;\n}\n\n/*\n** Changeset rebaser handle.\n*/\nstruct sqlite3_rebaser {\n  sqlite3_changegroup grp;        /* Hash table */\n};\n\n/*\n** Buffers a1 and a2 must both contain a sessions module record nCol\n** fields in size. This function appends an nCol sessions module \n** record to buffer pBuf that is a copy of a1, except that for\n** each field that is undefined in a1[], swap in the field from a2[].\n*/\nstatic void sessionAppendRecordMerge(\n  SessionBuffer *pBuf,            /* Buffer to append to */\n  int nCol,                       /* Number of columns in each record */\n  u8 *a1, int n1,                 /* Record 1 */\n  u8 *a2, int n2,                 /* Record 2 */\n  int *pRc                        /* IN/OUT: error code */\n){\n  sessionBufferGrow(pBuf, n1+n2, pRc);\n  if( *pRc==SQLITE_OK ){\n    int i;\n    u8 *pOut = &pBuf->aBuf[pBuf->nBuf];\n    for(i=0; i<nCol; i++){\n      int nn1 = sessionSerialLen(a1);\n      int nn2 = sessionSerialLen(a2);\n      if( *a1==0 || *a1==0xFF ){\n        memcpy(pOut, a2, nn2);\n        pOut += nn2;\n      }else{\n        memcpy(pOut, a1, nn1);\n        pOut += nn1;\n      }\n      a1 += nn1;\n      a2 += nn2;\n    }\n\n    pBuf->nBuf = pOut-pBuf->aBuf;\n    assert( pBuf->nBuf<=pBuf->nAlloc );\n  }\n}\n\n/*\n** This function is called when rebasing a local UPDATE change against one \n** or more remote UPDATE changes. The aRec/nRec buffer contains the current\n** old.* and new.* records for the change. The rebase buffer (a single\n** record) is in aChange/nChange. The rebased change is appended to buffer\n** pBuf.\n**\n** Rebasing the UPDATE involves: \n**\n**   * Removing any changes to fields for which the corresponding field\n**     in the rebase buffer is set to \"replaced\" (type 0xFF). If this\n**     means the UPDATE change updates no fields, nothing is appended\n**     to the output buffer.\n**\n**   * For each field modified by the local change for which the \n**     corresponding field in the rebase buffer is not \"undefined\" (0x00)\n**     or \"replaced\" (0xFF), the old.* value is replaced by the value\n**     in the rebase buffer.\n*/\nstatic void sessionAppendPartialUpdate(\n  SessionBuffer *pBuf,            /* Append record here */\n  sqlite3_changeset_iter *pIter,  /* Iterator pointed at local change */\n  u8 *aRec, int nRec,             /* Local change */\n  u8 *aChange, int nChange,       /* Record to rebase against */\n  int *pRc                        /* IN/OUT: Return Code */\n){\n  sessionBufferGrow(pBuf, 2+nRec+nChange, pRc);\n  if( *pRc==SQLITE_OK ){\n    int bData = 0;\n    u8 *pOut = &pBuf->aBuf[pBuf->nBuf];\n    int i;\n    u8 *a1 = aRec;\n    u8 *a2 = aChange;\n\n    *pOut++ = SQLITE_UPDATE;\n    *pOut++ = pIter->bIndirect;\n    for(i=0; i<pIter->nCol; i++){\n      int n1 = sessionSerialLen(a1);\n      int n2 = sessionSerialLen(a2);\n      if( pIter->abPK[i] || a2[0]==0 ){\n        if( !pIter->abPK[i] ) bData = 1;\n        memcpy(pOut, a1, n1);\n        pOut += n1;\n      }else if( a2[0]!=0xFF ){\n        bData = 1;\n        memcpy(pOut, a2, n2);\n        pOut += n2;\n      }else{\n        *pOut++ = '\\0';\n      }\n      a1 += n1;\n      a2 += n2;\n    }\n    if( bData ){\n      a2 = aChange;\n      for(i=0; i<pIter->nCol; i++){\n        int n1 = sessionSerialLen(a1);\n        int n2 = sessionSerialLen(a2);\n        if( pIter->abPK[i] || a2[0]!=0xFF ){\n          memcpy(pOut, a1, n1);\n          pOut += n1;\n        }else{\n          *pOut++ = '\\0';\n        }\n        a1 += n1;\n        a2 += n2;\n      }\n      pBuf->nBuf = (pOut - pBuf->aBuf);\n    }\n  }\n}\n\n/*\n** pIter is configured to iterate through a changeset. This function rebases \n** that changeset according to the current configuration of the rebaser \n** object passed as the first argument. If no error occurs and argument xOutput\n** is not NULL, then the changeset is returned to the caller by invoking\n** xOutput zero or more times and SQLITE_OK returned. Or, if xOutput is NULL,\n** then (*ppOut) is set to point to a buffer containing the rebased changeset\n** before this function returns. In this case (*pnOut) is set to the size of\n** the buffer in bytes.  It is the responsibility of the caller to eventually\n** free the (*ppOut) buffer using sqlite3_free(). \n**\n** If an error occurs, an SQLite error code is returned. If ppOut and\n** pnOut are not NULL, then the two output parameters are set to 0 before\n** returning.\n*/\nstatic int sessionRebase(\n  sqlite3_rebaser *p,             /* Rebaser hash table */\n  sqlite3_changeset_iter *pIter,  /* Input data */\n  int (*xOutput)(void *pOut, const void *pData, int nData),\n  void *pOut,                     /* Context for xOutput callback */\n  int *pnOut,                     /* OUT: Number of bytes in output changeset */\n  void **ppOut                    /* OUT: Inverse of pChangeset */\n){\n  int rc = SQLITE_OK;\n  u8 *aRec = 0;\n  int nRec = 0;\n  int bNew = 0;\n  SessionTable *pTab = 0;\n  SessionBuffer sOut = {0,0,0};\n\n  while( SQLITE_ROW==sessionChangesetNext(pIter, &aRec, &nRec, &bNew) ){\n    SessionChange *pChange = 0;\n    int bDone = 0;\n\n    if( bNew ){\n      const char *zTab = pIter->zTab;\n      for(pTab=p->grp.pList; pTab; pTab=pTab->pNext){\n        if( 0==sqlite3_stricmp(pTab->zName, zTab) ) break;\n      }\n      bNew = 0;\n\n      /* A patchset may not be rebased */\n      if( pIter->bPatchset ){\n        rc = SQLITE_ERROR;\n      }\n\n      /* Append a table header to the output for this new table */\n      sessionAppendByte(&sOut, pIter->bPatchset ? 'P' : 'T', &rc);\n      sessionAppendVarint(&sOut, pIter->nCol, &rc);\n      sessionAppendBlob(&sOut, pIter->abPK, pIter->nCol, &rc);\n      sessionAppendBlob(&sOut,(u8*)pIter->zTab,(int)strlen(pIter->zTab)+1,&rc);\n    }\n\n    if( pTab && rc==SQLITE_OK ){\n      int iHash = sessionChangeHash(pTab, 0, aRec, pTab->nChange);\n\n      for(pChange=pTab->apChange[iHash]; pChange; pChange=pChange->pNext){\n        if( sessionChangeEqual(pTab, 0, aRec, 0, pChange->aRecord) ){\n          break;\n        }\n      }\n    }\n\n    if( pChange ){\n      assert( pChange->op==SQLITE_DELETE || pChange->op==SQLITE_INSERT );\n      switch( pIter->op ){\n        case SQLITE_INSERT:\n          if( pChange->op==SQLITE_INSERT ){\n            bDone = 1;\n            if( pChange->bIndirect==0 ){\n              sessionAppendByte(&sOut, SQLITE_UPDATE, &rc);\n              sessionAppendByte(&sOut, pIter->bIndirect, &rc);\n              sessionAppendBlob(&sOut, pChange->aRecord, pChange->nRecord, &rc);\n              sessionAppendBlob(&sOut, aRec, nRec, &rc);\n            }\n          }\n          break;\n\n        case SQLITE_UPDATE:\n          bDone = 1;\n          if( pChange->op==SQLITE_DELETE ){\n            if( pChange->bIndirect==0 ){\n              u8 *pCsr = aRec;\n              sessionSkipRecord(&pCsr, pIter->nCol);\n              sessionAppendByte(&sOut, SQLITE_INSERT, &rc);\n              sessionAppendByte(&sOut, pIter->bIndirect, &rc);\n              sessionAppendRecordMerge(&sOut, pIter->nCol,\n                  pCsr, nRec-(pCsr-aRec), \n                  pChange->aRecord, pChange->nRecord, &rc\n              );\n            }\n          }else{\n            sessionAppendPartialUpdate(&sOut, pIter,\n                aRec, nRec, pChange->aRecord, pChange->nRecord, &rc\n            );\n          }\n          break;\n\n        default:\n          assert( pIter->op==SQLITE_DELETE );\n          bDone = 1;\n          if( pChange->op==SQLITE_INSERT ){\n            sessionAppendByte(&sOut, SQLITE_DELETE, &rc);\n            sessionAppendByte(&sOut, pIter->bIndirect, &rc);\n            sessionAppendRecordMerge(&sOut, pIter->nCol,\n                pChange->aRecord, pChange->nRecord, aRec, nRec, &rc\n            );\n          }\n          break;\n      }\n    }\n\n    if( bDone==0 ){\n      sessionAppendByte(&sOut, pIter->op, &rc);\n      sessionAppendByte(&sOut, pIter->bIndirect, &rc);\n      sessionAppendBlob(&sOut, aRec, nRec, &rc);\n    }\n    if( rc==SQLITE_OK && xOutput && sOut.nBuf>sessions_strm_chunk_size ){\n      rc = xOutput(pOut, sOut.aBuf, sOut.nBuf);\n      sOut.nBuf = 0;\n    }\n    if( rc ) break;\n  }\n\n  if( rc!=SQLITE_OK ){\n    sqlite3_free(sOut.aBuf);\n    memset(&sOut, 0, sizeof(sOut));\n  }\n\n  if( rc==SQLITE_OK ){\n    if( xOutput ){\n      if( sOut.nBuf>0 ){\n        rc = xOutput(pOut, sOut.aBuf, sOut.nBuf);\n      }\n    }else{\n      *ppOut = (void*)sOut.aBuf;\n      *pnOut = sOut.nBuf;\n      sOut.aBuf = 0;\n    }\n  }\n  sqlite3_free(sOut.aBuf);\n  return rc;\n}\n\n/* \n** Create a new rebaser object.\n*/\nSQLITE_API int sqlite3rebaser_create(sqlite3_rebaser **ppNew){\n  int rc = SQLITE_OK;\n  sqlite3_rebaser *pNew;\n\n  pNew = sqlite3_malloc(sizeof(sqlite3_rebaser));\n  if( pNew==0 ){\n    rc = SQLITE_NOMEM;\n  }else{\n    memset(pNew, 0, sizeof(sqlite3_rebaser));\n  }\n  *ppNew = pNew;\n  return rc;\n}\n\n/* \n** Call this one or more times to configure a rebaser.\n*/\nSQLITE_API int sqlite3rebaser_configure(\n  sqlite3_rebaser *p, \n  int nRebase, const void *pRebase\n){\n  sqlite3_changeset_iter *pIter = 0;   /* Iterator opened on pData/nData */\n  int rc;                              /* Return code */\n  rc = sqlite3changeset_start(&pIter, nRebase, (void*)pRebase);\n  if( rc==SQLITE_OK ){\n    rc = sessionChangesetToHash(pIter, &p->grp, 1);\n  }\n  sqlite3changeset_finalize(pIter);\n  return rc;\n}\n\n/* \n** Rebase a changeset according to current rebaser configuration \n*/\nSQLITE_API int sqlite3rebaser_rebase(\n  sqlite3_rebaser *p,\n  int nIn, const void *pIn, \n  int *pnOut, void **ppOut \n){\n  sqlite3_changeset_iter *pIter = 0;   /* Iterator to skip through input */  \n  int rc = sqlite3changeset_start(&pIter, nIn, (void*)pIn);\n\n  if( rc==SQLITE_OK ){\n    rc = sessionRebase(p, pIter, 0, 0, pnOut, ppOut);\n    sqlite3changeset_finalize(pIter);\n  }\n\n  return rc;\n}\n\n/* \n** Rebase a changeset according to current rebaser configuration \n*/\nSQLITE_API int sqlite3rebaser_rebase_strm(\n  sqlite3_rebaser *p,\n  int (*xInput)(void *pIn, void *pData, int *pnData),\n  void *pIn,\n  int (*xOutput)(void *pOut, const void *pData, int nData),\n  void *pOut\n){\n  sqlite3_changeset_iter *pIter = 0;   /* Iterator to skip through input */  \n  int rc = sqlite3changeset_start_strm(&pIter, xInput, pIn);\n\n  if( rc==SQLITE_OK ){\n    rc = sessionRebase(p, pIter, xOutput, pOut, 0, 0);\n    sqlite3changeset_finalize(pIter);\n  }\n\n  return rc;\n}\n\n/* \n** Destroy a rebaser object \n*/\nSQLITE_API void sqlite3rebaser_delete(sqlite3_rebaser *p){\n  if( p ){\n    sessionDeleteTable(p->grp.pList);\n    sqlite3_free(p);\n  }\n}\n\n/* \n** Global configuration\n*/\nSQLITE_API int sqlite3session_config(int op, void *pArg){\n  int rc = SQLITE_OK;\n  switch( op ){\n    case SQLITE_SESSION_CONFIG_STRMSIZE: {\n      int *pInt = (int*)pArg;\n      if( *pInt>0 ){\n        sessions_strm_chunk_size = *pInt;\n      }\n      *pInt = sessions_strm_chunk_size;\n      break;\n    }\n    default:\n      rc = SQLITE_MISUSE;\n      break;\n  }\n  return rc;\n}\n\n#endif /* SQLITE_ENABLE_SESSION && SQLITE_ENABLE_PREUPDATE_HOOK */\n\n/************** End of sqlite3session.c **************************************/\n/************** Begin file fts5.c ********************************************/\n\n\n#if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS5) \n\n#if !defined(NDEBUG) && !defined(SQLITE_DEBUG) \n# define NDEBUG 1\n#endif\n#if defined(NDEBUG) && defined(SQLITE_DEBUG)\n# undef NDEBUG\n#endif\n\n/*\n** 2014 May 31\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n******************************************************************************\n**\n** Interfaces to extend FTS5. Using the interfaces defined in this file, \n** FTS5 may be extended with:\n**\n**     * custom tokenizers, and\n**     * custom auxiliary functions.\n*/\n\n\n#ifndef _FTS5_H\n#define _FTS5_H\n\n/* #include \"sqlite3.h\" */\n\n#if 0\nextern \"C\" {\n#endif\n\n/*************************************************************************\n** CUSTOM AUXILIARY FUNCTIONS\n**\n** Virtual table implementations may overload SQL functions by implementing\n** the sqlite3_module.xFindFunction() method.\n*/\n\ntypedef struct Fts5ExtensionApi Fts5ExtensionApi;\ntypedef struct Fts5Context Fts5Context;\ntypedef struct Fts5PhraseIter Fts5PhraseIter;\n\ntypedef void (*fts5_extension_function)(\n  const Fts5ExtensionApi *pApi,   /* API offered by current FTS version */\n  Fts5Context *pFts,              /* First arg to pass to pApi functions */\n  sqlite3_context *pCtx,          /* Context for returning result/error */\n  int nVal,                       /* Number of values in apVal[] array */\n  sqlite3_value **apVal           /* Array of trailing arguments */\n);\n\nstruct Fts5PhraseIter {\n  const unsigned char *a;\n  const unsigned char *b;\n};\n\n/*\n** EXTENSION API FUNCTIONS\n**\n** xUserData(pFts):\n**   Return a copy of the context pointer the extension function was \n**   registered with.\n**\n** xColumnTotalSize(pFts, iCol, pnToken):\n**   If parameter iCol is less than zero, set output variable *pnToken\n**   to the total number of tokens in the FTS5 table. Or, if iCol is\n**   non-negative but less than the number of columns in the table, return\n**   the total number of tokens in column iCol, considering all rows in \n**   the FTS5 table.\n**\n**   If parameter iCol is greater than or equal to the number of columns\n**   in the table, SQLITE_RANGE is returned. Or, if an error occurs (e.g.\n**   an OOM condition or IO error), an appropriate SQLite error code is \n**   returned.\n**\n** xColumnCount(pFts):\n**   Return the number of columns in the table.\n**\n** xColumnSize(pFts, iCol, pnToken):\n**   If parameter iCol is less than zero, set output variable *pnToken\n**   to the total number of tokens in the current row. Or, if iCol is\n**   non-negative but less than the number of columns in the table, set\n**   *pnToken to the number of tokens in column iCol of the current row.\n**\n**   If parameter iCol is greater than or equal to the number of columns\n**   in the table, SQLITE_RANGE is returned. Or, if an error occurs (e.g.\n**   an OOM condition or IO error), an appropriate SQLite error code is \n**   returned.\n**\n**   This function may be quite inefficient if used with an FTS5 table\n**   created with the \"columnsize=0\" option.\n**\n** xColumnText:\n**   This function attempts to retrieve the text of column iCol of the\n**   current document. If successful, (*pz) is set to point to a buffer\n**   containing the text in utf-8 encoding, (*pn) is set to the size in bytes\n**   (not characters) of the buffer and SQLITE_OK is returned. Otherwise,\n**   if an error occurs, an SQLite error code is returned and the final values\n**   of (*pz) and (*pn) are undefined.\n**\n** xPhraseCount:\n**   Returns the number of phrases in the current query expression.\n**\n** xPhraseSize:\n**   Returns the number of tokens in phrase iPhrase of the query. Phrases\n**   are numbered starting from zero.\n**\n** xInstCount:\n**   Set *pnInst to the total number of occurrences of all phrases within\n**   the query within the current row. Return SQLITE_OK if successful, or\n**   an error code (i.e. SQLITE_NOMEM) if an error occurs.\n**\n**   This API can be quite slow if used with an FTS5 table created with the\n**   \"detail=none\" or \"detail=column\" option. If the FTS5 table is created \n**   with either \"detail=none\" or \"detail=column\" and \"content=\" option \n**   (i.e. if it is a contentless table), then this API always returns 0.\n**\n** xInst:\n**   Query for the details of phrase match iIdx within the current row.\n**   Phrase matches are numbered starting from zero, so the iIdx argument\n**   should be greater than or equal to zero and smaller than the value\n**   output by xInstCount().\n**\n**   Usually, output parameter *piPhrase is set to the phrase number, *piCol\n**   to the column in which it occurs and *piOff the token offset of the\n**   first token of the phrase. Returns SQLITE_OK if successful, or an error\n**   code (i.e. SQLITE_NOMEM) if an error occurs.\n**\n**   This API can be quite slow if used with an FTS5 table created with the\n**   \"detail=none\" or \"detail=column\" option. \n**\n** xRowid:\n**   Returns the rowid of the current row.\n**\n** xTokenize:\n**   Tokenize text using the tokenizer belonging to the FTS5 table.\n**\n** xQueryPhrase(pFts5, iPhrase, pUserData, xCallback):\n**   This API function is used to query the FTS table for phrase iPhrase\n**   of the current query. Specifically, a query equivalent to:\n**\n**       ... FROM ftstable WHERE ftstable MATCH $p ORDER BY rowid\n**\n**   with $p set to a phrase equivalent to the phrase iPhrase of the\n**   current query is executed. Any column filter that applies to\n**   phrase iPhrase of the current query is included in $p. For each \n**   row visited, the callback function passed as the fourth argument \n**   is invoked. The context and API objects passed to the callback \n**   function may be used to access the properties of each matched row.\n**   Invoking Api.xUserData() returns a copy of the pointer passed as \n**   the third argument to pUserData.\n**\n**   If the callback function returns any value other than SQLITE_OK, the\n**   query is abandoned and the xQueryPhrase function returns immediately.\n**   If the returned value is SQLITE_DONE, xQueryPhrase returns SQLITE_OK.\n**   Otherwise, the error code is propagated upwards.\n**\n**   If the query runs to completion without incident, SQLITE_OK is returned.\n**   Or, if some error occurs before the query completes or is aborted by\n**   the callback, an SQLite error code is returned.\n**\n**\n** xSetAuxdata(pFts5, pAux, xDelete)\n**\n**   Save the pointer passed as the second argument as the extension functions \n**   \"auxiliary data\". The pointer may then be retrieved by the current or any\n**   future invocation of the same fts5 extension function made as part of\n**   of the same MATCH query using the xGetAuxdata() API.\n**\n**   Each extension function is allocated a single auxiliary data slot for\n**   each FTS query (MATCH expression). If the extension function is invoked \n**   more than once for a single FTS query, then all invocations share a \n**   single auxiliary data context.\n**\n**   If there is already an auxiliary data pointer when this function is\n**   invoked, then it is replaced by the new pointer. If an xDelete callback\n**   was specified along with the original pointer, it is invoked at this\n**   point.\n**\n**   The xDelete callback, if one is specified, is also invoked on the\n**   auxiliary data pointer after the FTS5 query has finished.\n**\n**   If an error (e.g. an OOM condition) occurs within this function, an\n**   the auxiliary data is set to NULL and an error code returned. If the\n**   xDelete parameter was not NULL, it is invoked on the auxiliary data\n**   pointer before returning.\n**\n**\n** xGetAuxdata(pFts5, bClear)\n**\n**   Returns the current auxiliary data pointer for the fts5 extension \n**   function. See the xSetAuxdata() method for details.\n**\n**   If the bClear argument is non-zero, then the auxiliary data is cleared\n**   (set to NULL) before this function returns. In this case the xDelete,\n**   if any, is not invoked.\n**\n**\n** xRowCount(pFts5, pnRow)\n**\n**   This function is used to retrieve the total number of rows in the table.\n**   In other words, the same value that would be returned by:\n**\n**        SELECT count(*) FROM ftstable;\n**\n** xPhraseFirst()\n**   This function is used, along with type Fts5PhraseIter and the xPhraseNext\n**   method, to iterate through all instances of a single query phrase within\n**   the current row. This is the same information as is accessible via the\n**   xInstCount/xInst APIs. While the xInstCount/xInst APIs are more convenient\n**   to use, this API may be faster under some circumstances. To iterate \n**   through instances of phrase iPhrase, use the following code:\n**\n**       Fts5PhraseIter iter;\n**       int iCol, iOff;\n**       for(pApi->xPhraseFirst(pFts, iPhrase, &iter, &iCol, &iOff);\n**           iCol>=0;\n**           pApi->xPhraseNext(pFts, &iter, &iCol, &iOff)\n**       ){\n**         // An instance of phrase iPhrase at offset iOff of column iCol\n**       }\n**\n**   The Fts5PhraseIter structure is defined above. Applications should not\n**   modify this structure directly - it should only be used as shown above\n**   with the xPhraseFirst() and xPhraseNext() API methods (and by\n**   xPhraseFirstColumn() and xPhraseNextColumn() as illustrated below).\n**\n**   This API can be quite slow if used with an FTS5 table created with the\n**   \"detail=none\" or \"detail=column\" option. If the FTS5 table is created \n**   with either \"detail=none\" or \"detail=column\" and \"content=\" option \n**   (i.e. if it is a contentless table), then this API always iterates\n**   through an empty set (all calls to xPhraseFirst() set iCol to -1).\n**\n** xPhraseNext()\n**   See xPhraseFirst above.\n**\n** xPhraseFirstColumn()\n**   This function and xPhraseNextColumn() are similar to the xPhraseFirst()\n**   and xPhraseNext() APIs described above. The difference is that instead\n**   of iterating through all instances of a phrase in the current row, these\n**   APIs are used to iterate through the set of columns in the current row\n**   that contain one or more instances of a specified phrase. For example:\n**\n**       Fts5PhraseIter iter;\n**       int iCol;\n**       for(pApi->xPhraseFirstColumn(pFts, iPhrase, &iter, &iCol);\n**           iCol>=0;\n**           pApi->xPhraseNextColumn(pFts, &iter, &iCol)\n**       ){\n**         // Column iCol contains at least one instance of phrase iPhrase\n**       }\n**\n**   This API can be quite slow if used with an FTS5 table created with the\n**   \"detail=none\" option. If the FTS5 table is created with either \n**   \"detail=none\" \"content=\" option (i.e. if it is a contentless table), \n**   then this API always iterates through an empty set (all calls to \n**   xPhraseFirstColumn() set iCol to -1).\n**\n**   The information accessed using this API and its companion\n**   xPhraseFirstColumn() may also be obtained using xPhraseFirst/xPhraseNext\n**   (or xInst/xInstCount). The chief advantage of this API is that it is\n**   significantly more efficient than those alternatives when used with\n**   \"detail=column\" tables.  \n**\n** xPhraseNextColumn()\n**   See xPhraseFirstColumn above.\n*/\nstruct Fts5ExtensionApi {\n  int iVersion;                   /* Currently always set to 3 */\n\n  void *(*xUserData)(Fts5Context*);\n\n  int (*xColumnCount)(Fts5Context*);\n  int (*xRowCount)(Fts5Context*, sqlite3_int64 *pnRow);\n  int (*xColumnTotalSize)(Fts5Context*, int iCol, sqlite3_int64 *pnToken);\n\n  int (*xTokenize)(Fts5Context*, \n    const char *pText, int nText, /* Text to tokenize */\n    void *pCtx,                   /* Context passed to xToken() */\n    int (*xToken)(void*, int, const char*, int, int, int)       /* Callback */\n  );\n\n  int (*xPhraseCount)(Fts5Context*);\n  int (*xPhraseSize)(Fts5Context*, int iPhrase);\n\n  int (*xInstCount)(Fts5Context*, int *pnInst);\n  int (*xInst)(Fts5Context*, int iIdx, int *piPhrase, int *piCol, int *piOff);\n\n  sqlite3_int64 (*xRowid)(Fts5Context*);\n  int (*xColumnText)(Fts5Context*, int iCol, const char **pz, int *pn);\n  int (*xColumnSize)(Fts5Context*, int iCol, int *pnToken);\n\n  int (*xQueryPhrase)(Fts5Context*, int iPhrase, void *pUserData,\n    int(*)(const Fts5ExtensionApi*,Fts5Context*,void*)\n  );\n  int (*xSetAuxdata)(Fts5Context*, void *pAux, void(*xDelete)(void*));\n  void *(*xGetAuxdata)(Fts5Context*, int bClear);\n\n  int (*xPhraseFirst)(Fts5Context*, int iPhrase, Fts5PhraseIter*, int*, int*);\n  void (*xPhraseNext)(Fts5Context*, Fts5PhraseIter*, int *piCol, int *piOff);\n\n  int (*xPhraseFirstColumn)(Fts5Context*, int iPhrase, Fts5PhraseIter*, int*);\n  void (*xPhraseNextColumn)(Fts5Context*, Fts5PhraseIter*, int *piCol);\n};\n\n/* \n** CUSTOM AUXILIARY FUNCTIONS\n*************************************************************************/\n\n/*************************************************************************\n** CUSTOM TOKENIZERS\n**\n** Applications may also register custom tokenizer types. A tokenizer \n** is registered by providing fts5 with a populated instance of the \n** following structure. All structure methods must be defined, setting\n** any member of the fts5_tokenizer struct to NULL leads to undefined\n** behaviour. The structure methods are expected to function as follows:\n**\n** xCreate:\n**   This function is used to allocate and initialize a tokenizer instance.\n**   A tokenizer instance is required to actually tokenize text.\n**\n**   The first argument passed to this function is a copy of the (void*)\n**   pointer provided by the application when the fts5_tokenizer object\n**   was registered with FTS5 (the third argument to xCreateTokenizer()). \n**   The second and third arguments are an array of nul-terminated strings\n**   containing the tokenizer arguments, if any, specified following the\n**   tokenizer name as part of the CREATE VIRTUAL TABLE statement used\n**   to create the FTS5 table.\n**\n**   The final argument is an output variable. If successful, (*ppOut) \n**   should be set to point to the new tokenizer handle and SQLITE_OK\n**   returned. If an error occurs, some value other than SQLITE_OK should\n**   be returned. In this case, fts5 assumes that the final value of *ppOut \n**   is undefined.\n**\n** xDelete:\n**   This function is invoked to delete a tokenizer handle previously\n**   allocated using xCreate(). Fts5 guarantees that this function will\n**   be invoked exactly once for each successful call to xCreate().\n**\n** xTokenize:\n**   This function is expected to tokenize the nText byte string indicated \n**   by argument pText. pText may or may not be nul-terminated. The first\n**   argument passed to this function is a pointer to an Fts5Tokenizer object\n**   returned by an earlier call to xCreate().\n**\n**   The second argument indicates the reason that FTS5 is requesting\n**   tokenization of the supplied text. This is always one of the following\n**   four values:\n**\n**   <ul><li> <b>FTS5_TOKENIZE_DOCUMENT</b> - A document is being inserted into\n**            or removed from the FTS table. The tokenizer is being invoked to\n**            determine the set of tokens to add to (or delete from) the\n**            FTS index.\n**\n**       <li> <b>FTS5_TOKENIZE_QUERY</b> - A MATCH query is being executed \n**            against the FTS index. The tokenizer is being called to tokenize \n**            a bareword or quoted string specified as part of the query.\n**\n**       <li> <b>(FTS5_TOKENIZE_QUERY | FTS5_TOKENIZE_PREFIX)</b> - Same as\n**            FTS5_TOKENIZE_QUERY, except that the bareword or quoted string is\n**            followed by a \"*\" character, indicating that the last token\n**            returned by the tokenizer will be treated as a token prefix.\n**\n**       <li> <b>FTS5_TOKENIZE_AUX</b> - The tokenizer is being invoked to \n**            satisfy an fts5_api.xTokenize() request made by an auxiliary\n**            function. Or an fts5_api.xColumnSize() request made by the same\n**            on a columnsize=0 database.  \n**   </ul>\n**\n**   For each token in the input string, the supplied callback xToken() must\n**   be invoked. The first argument to it should be a copy of the pointer\n**   passed as the second argument to xTokenize(). The third and fourth\n**   arguments are a pointer to a buffer containing the token text, and the\n**   size of the token in bytes. The 4th and 5th arguments are the byte offsets\n**   of the first byte of and first byte immediately following the text from\n**   which the token is derived within the input.\n**\n**   The second argument passed to the xToken() callback (\"tflags\") should\n**   normally be set to 0. The exception is if the tokenizer supports \n**   synonyms. In this case see the discussion below for details.\n**\n**   FTS5 assumes the xToken() callback is invoked for each token in the \n**   order that they occur within the input text.\n**\n**   If an xToken() callback returns any value other than SQLITE_OK, then\n**   the tokenization should be abandoned and the xTokenize() method should\n**   immediately return a copy of the xToken() return value. Or, if the\n**   input buffer is exhausted, xTokenize() should return SQLITE_OK. Finally,\n**   if an error occurs with the xTokenize() implementation itself, it\n**   may abandon the tokenization and return any error code other than\n**   SQLITE_OK or SQLITE_DONE.\n**\n** SYNONYM SUPPORT\n**\n**   Custom tokenizers may also support synonyms. Consider a case in which a\n**   user wishes to query for a phrase such as \"first place\". Using the \n**   built-in tokenizers, the FTS5 query 'first + place' will match instances\n**   of \"first place\" within the document set, but not alternative forms\n**   such as \"1st place\". In some applications, it would be better to match\n**   all instances of \"first place\" or \"1st place\" regardless of which form\n**   the user specified in the MATCH query text.\n**\n**   There are several ways to approach this in FTS5:\n**\n**   <ol><li> By mapping all synonyms to a single token. In this case, the \n**            In the above example, this means that the tokenizer returns the\n**            same token for inputs \"first\" and \"1st\". Say that token is in\n**            fact \"first\", so that when the user inserts the document \"I won\n**            1st place\" entries are added to the index for tokens \"i\", \"won\",\n**            \"first\" and \"place\". If the user then queries for '1st + place',\n**            the tokenizer substitutes \"first\" for \"1st\" and the query works\n**            as expected.\n**\n**       <li> By querying the index for all synonyms of each query term\n**            separately. In this case, when tokenizing query text, the\n**            tokenizer may provide multiple synonyms for a single term \n**            within the document. FTS5 then queries the index for each \n**            synonym individually. For example, faced with the query:\n**\n**   <codeblock>\n**     ... MATCH 'first place'</codeblock>\n**\n**            the tokenizer offers both \"1st\" and \"first\" as synonyms for the\n**            first token in the MATCH query and FTS5 effectively runs a query \n**            similar to:\n**\n**   <codeblock>\n**     ... MATCH '(first OR 1st) place'</codeblock>\n**\n**            except that, for the purposes of auxiliary functions, the query\n**            still appears to contain just two phrases - \"(first OR 1st)\" \n**            being treated as a single phrase.\n**\n**       <li> By adding multiple synonyms for a single term to the FTS index.\n**            Using this method, when tokenizing document text, the tokenizer\n**            provides multiple synonyms for each token. So that when a \n**            document such as \"I won first place\" is tokenized, entries are\n**            added to the FTS index for \"i\", \"won\", \"first\", \"1st\" and\n**            \"place\".\n**\n**            This way, even if the tokenizer does not provide synonyms\n**            when tokenizing query text (it should not - to do so would be\n**            inefficient), it doesn't matter if the user queries for \n**            'first + place' or '1st + place', as there are entries in the\n**            FTS index corresponding to both forms of the first token.\n**   </ol>\n**\n**   Whether it is parsing document or query text, any call to xToken that\n**   specifies a <i>tflags</i> argument with the FTS5_TOKEN_COLOCATED bit\n**   is considered to supply a synonym for the previous token. For example,\n**   when parsing the document \"I won first place\", a tokenizer that supports\n**   synonyms would call xToken() 5 times, as follows:\n**\n**   <codeblock>\n**       xToken(pCtx, 0, \"i\",                      1,  0,  1);\n**       xToken(pCtx, 0, \"won\",                    3,  2,  5);\n**       xToken(pCtx, 0, \"first\",                  5,  6, 11);\n**       xToken(pCtx, FTS5_TOKEN_COLOCATED, \"1st\", 3,  6, 11);\n**       xToken(pCtx, 0, \"place\",                  5, 12, 17);\n**</codeblock>\n**\n**   It is an error to specify the FTS5_TOKEN_COLOCATED flag the first time\n**   xToken() is called. Multiple synonyms may be specified for a single token\n**   by making multiple calls to xToken(FTS5_TOKEN_COLOCATED) in sequence. \n**   There is no limit to the number of synonyms that may be provided for a\n**   single token.\n**\n**   In many cases, method (1) above is the best approach. It does not add \n**   extra data to the FTS index or require FTS5 to query for multiple terms,\n**   so it is efficient in terms of disk space and query speed. However, it\n**   does not support prefix queries very well. If, as suggested above, the\n**   token \"first\" is substituted for \"1st\" by the tokenizer, then the query:\n**\n**   <codeblock>\n**     ... MATCH '1s*'</codeblock>\n**\n**   will not match documents that contain the token \"1st\" (as the tokenizer\n**   will probably not map \"1s\" to any prefix of \"first\").\n**\n**   For full prefix support, method (3) may be preferred. In this case, \n**   because the index contains entries for both \"first\" and \"1st\", prefix\n**   queries such as 'fi*' or '1s*' will match correctly. However, because\n**   extra entries are added to the FTS index, this method uses more space\n**   within the database.\n**\n**   Method (2) offers a midpoint between (1) and (3). Using this method,\n**   a query such as '1s*' will match documents that contain the literal \n**   token \"1st\", but not \"first\" (assuming the tokenizer is not able to\n**   provide synonyms for prefixes). However, a non-prefix query like '1st'\n**   will match against \"1st\" and \"first\". This method does not require\n**   extra disk space, as no extra entries are added to the FTS index. \n**   On the other hand, it may require more CPU cycles to run MATCH queries,\n**   as separate queries of the FTS index are required for each synonym.\n**\n**   When using methods (2) or (3), it is important that the tokenizer only\n**   provide synonyms when tokenizing document text (method (2)) or query\n**   text (method (3)), not both. Doing so will not cause any errors, but is\n**   inefficient.\n*/\ntypedef struct Fts5Tokenizer Fts5Tokenizer;\ntypedef struct fts5_tokenizer fts5_tokenizer;\nstruct fts5_tokenizer {\n  int (*xCreate)(void*, const char **azArg, int nArg, Fts5Tokenizer **ppOut);\n  void (*xDelete)(Fts5Tokenizer*);\n  int (*xTokenize)(Fts5Tokenizer*, \n      void *pCtx,\n      int flags,            /* Mask of FTS5_TOKENIZE_* flags */\n      const char *pText, int nText, \n      int (*xToken)(\n        void *pCtx,         /* Copy of 2nd argument to xTokenize() */\n        int tflags,         /* Mask of FTS5_TOKEN_* flags */\n        const char *pToken, /* Pointer to buffer containing token */\n        int nToken,         /* Size of token in bytes */\n        int iStart,         /* Byte offset of token within input text */\n        int iEnd            /* Byte offset of end of token within input text */\n      )\n  );\n};\n\n/* Flags that may be passed as the third argument to xTokenize() */\n#define FTS5_TOKENIZE_QUERY     0x0001\n#define FTS5_TOKENIZE_PREFIX    0x0002\n#define FTS5_TOKENIZE_DOCUMENT  0x0004\n#define FTS5_TOKENIZE_AUX       0x0008\n\n/* Flags that may be passed by the tokenizer implementation back to FTS5\n** as the third argument to the supplied xToken callback. */\n#define FTS5_TOKEN_COLOCATED    0x0001      /* Same position as prev. token */\n\n/*\n** END OF CUSTOM TOKENIZERS\n*************************************************************************/\n\n/*************************************************************************\n** FTS5 EXTENSION REGISTRATION API\n*/\ntypedef struct fts5_api fts5_api;\nstruct fts5_api {\n  int iVersion;                   /* Currently always set to 2 */\n\n  /* Create a new tokenizer */\n  int (*xCreateTokenizer)(\n    fts5_api *pApi,\n    const char *zName,\n    void *pContext,\n    fts5_tokenizer *pTokenizer,\n    void (*xDestroy)(void*)\n  );\n\n  /* Find an existing tokenizer */\n  int (*xFindTokenizer)(\n    fts5_api *pApi,\n    const char *zName,\n    void **ppContext,\n    fts5_tokenizer *pTokenizer\n  );\n\n  /* Create a new auxiliary function */\n  int (*xCreateFunction)(\n    fts5_api *pApi,\n    const char *zName,\n    void *pContext,\n    fts5_extension_function xFunction,\n    void (*xDestroy)(void*)\n  );\n};\n\n/*\n** END OF REGISTRATION API\n*************************************************************************/\n\n#if 0\n}  /* end of the 'extern \"C\"' block */\n#endif\n\n#endif /* _FTS5_H */\n\n/*\n** 2014 May 31\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n******************************************************************************\n**\n*/\n#ifndef _FTS5INT_H\n#define _FTS5INT_H\n\n/* #include \"fts5.h\" */\n/* #include \"sqlite3ext.h\" */\nSQLITE_EXTENSION_INIT1\n\n/* #include <string.h> */\n/* #include <assert.h> */\n\n#ifndef SQLITE_AMALGAMATION\n\ntypedef unsigned char  u8;\ntypedef unsigned int   u32;\ntypedef unsigned short u16;\ntypedef short i16;\ntypedef sqlite3_int64 i64;\ntypedef sqlite3_uint64 u64;\n\n#ifndef ArraySize\n# define ArraySize(x) ((int)(sizeof(x) / sizeof(x[0])))\n#endif\n\n#define testcase(x)\n#define ALWAYS(x) 1\n#define NEVER(x) 0\n\n#define MIN(x,y) (((x) < (y)) ? (x) : (y))\n#define MAX(x,y) (((x) > (y)) ? (x) : (y))\n\n/*\n** Constants for the largest and smallest possible 64-bit signed integers.\n*/\n# define LARGEST_INT64  (0xffffffff|(((i64)0x7fffffff)<<32))\n# define SMALLEST_INT64 (((i64)-1) - LARGEST_INT64)\n\n#endif\n\n/* Truncate very long tokens to this many bytes. Hard limit is \n** (65536-1-1-4-9)==65521 bytes. The limiting factor is the 16-bit offset\n** field that occurs at the start of each leaf page (see fts5_index.c). */\n#define FTS5_MAX_TOKEN_SIZE 32768\n\n/*\n** Maximum number of prefix indexes on single FTS5 table. This must be\n** less than 32. If it is set to anything large than that, an #error\n** directive in fts5_index.c will cause the build to fail.\n*/\n#define FTS5_MAX_PREFIX_INDEXES 31\n\n#define FTS5_DEFAULT_NEARDIST 10\n#define FTS5_DEFAULT_RANK     \"bm25\"\n\n/* Name of rank and rowid columns */\n#define FTS5_RANK_NAME \"rank\"\n#define FTS5_ROWID_NAME \"rowid\"\n\n#ifdef SQLITE_DEBUG\n# define FTS5_CORRUPT sqlite3Fts5Corrupt()\nstatic int sqlite3Fts5Corrupt(void);\n#else\n# define FTS5_CORRUPT SQLITE_CORRUPT_VTAB\n#endif\n\n/*\n** The assert_nc() macro is similar to the assert() macro, except that it\n** is used for assert() conditions that are true only if it can be \n** guranteed that the database is not corrupt.\n*/\n#ifdef SQLITE_DEBUG\nSQLITE_API extern int sqlite3_fts5_may_be_corrupt;\n# define assert_nc(x) assert(sqlite3_fts5_may_be_corrupt || (x))\n#else\n# define assert_nc(x) assert(x)\n#endif\n\n/*\n** A version of memcmp() that does not cause asan errors if one of the pointer\n** parameters is NULL and the number of bytes to compare is zero.\n*/\n#define fts5Memcmp(s1, s2, n) ((n)==0 ? 0 : memcmp((s1), (s2), (n)))\n\n/* Mark a function parameter as unused, to suppress nuisance compiler\n** warnings. */\n#ifndef UNUSED_PARAM\n# define UNUSED_PARAM(X)  (void)(X)\n#endif\n\n#ifndef UNUSED_PARAM2\n# define UNUSED_PARAM2(X, Y)  (void)(X), (void)(Y)\n#endif\n\ntypedef struct Fts5Global Fts5Global;\ntypedef struct Fts5Colset Fts5Colset;\n\n/* If a NEAR() clump or phrase may only match a specific set of columns, \n** then an object of the following type is used to record the set of columns.\n** Each entry in the aiCol[] array is a column that may be matched.\n**\n** This object is used by fts5_expr.c and fts5_index.c.\n*/\nstruct Fts5Colset {\n  int nCol;\n  int aiCol[1];\n};\n\n\n\n/**************************************************************************\n** Interface to code in fts5_config.c. fts5_config.c contains contains code\n** to parse the arguments passed to the CREATE VIRTUAL TABLE statement.\n*/\n\ntypedef struct Fts5Config Fts5Config;\n\n/*\n** An instance of the following structure encodes all information that can\n** be gleaned from the CREATE VIRTUAL TABLE statement.\n**\n** And all information loaded from the %_config table.\n**\n** nAutomerge:\n**   The minimum number of segments that an auto-merge operation should\n**   attempt to merge together. A value of 1 sets the object to use the \n**   compile time default. Zero disables auto-merge altogether.\n**\n** zContent:\n**\n** zContentRowid:\n**   The value of the content_rowid= option, if one was specified. Or \n**   the string \"rowid\" otherwise. This text is not quoted - if it is\n**   used as part of an SQL statement it needs to be quoted appropriately.\n**\n** zContentExprlist:\n**\n** pzErrmsg:\n**   This exists in order to allow the fts5_index.c module to return a \n**   decent error message if it encounters a file-format version it does\n**   not understand.\n**\n** bColumnsize:\n**   True if the %_docsize table is created.\n**\n** bPrefixIndex:\n**   This is only used for debugging. If set to false, any prefix indexes\n**   are ignored. This value is configured using:\n**\n**       INSERT INTO tbl(tbl, rank) VALUES('prefix-index', $bPrefixIndex);\n**\n*/\nstruct Fts5Config {\n  sqlite3 *db;                    /* Database handle */\n  char *zDb;                      /* Database holding FTS index (e.g. \"main\") */\n  char *zName;                    /* Name of FTS index */\n  int nCol;                       /* Number of columns */\n  char **azCol;                   /* Column names */\n  u8 *abUnindexed;                /* True for unindexed columns */\n  int nPrefix;                    /* Number of prefix indexes */\n  int *aPrefix;                   /* Sizes in bytes of nPrefix prefix indexes */\n  int eContent;                   /* An FTS5_CONTENT value */\n  char *zContent;                 /* content table */ \n  char *zContentRowid;            /* \"content_rowid=\" option value */ \n  int bColumnsize;                /* \"columnsize=\" option value (dflt==1) */\n  int eDetail;                    /* FTS5_DETAIL_XXX value */\n  char *zContentExprlist;\n  Fts5Tokenizer *pTok;\n  fts5_tokenizer *pTokApi;\n\n  /* Values loaded from the %_config table */\n  int iCookie;                    /* Incremented when %_config is modified */\n  int pgsz;                       /* Approximate page size used in %_data */\n  int nAutomerge;                 /* 'automerge' setting */\n  int nCrisisMerge;               /* Maximum allowed segments per level */\n  int nUsermerge;                 /* 'usermerge' setting */\n  int nHashSize;                  /* Bytes of memory for in-memory hash */\n  char *zRank;                    /* Name of rank function */\n  char *zRankArgs;                /* Arguments to rank function */\n\n  /* If non-NULL, points to sqlite3_vtab.base.zErrmsg. Often NULL. */\n  char **pzErrmsg;\n\n#ifdef SQLITE_DEBUG\n  int bPrefixIndex;               /* True to use prefix-indexes */\n#endif\n};\n\n/* Current expected value of %_config table 'version' field */\n#define FTS5_CURRENT_VERSION 4\n\n#define FTS5_CONTENT_NORMAL   0\n#define FTS5_CONTENT_NONE     1\n#define FTS5_CONTENT_EXTERNAL 2\n\n#define FTS5_DETAIL_FULL    0\n#define FTS5_DETAIL_NONE    1\n#define FTS5_DETAIL_COLUMNS 2\n\n\n\nstatic int sqlite3Fts5ConfigParse(\n    Fts5Global*, sqlite3*, int, const char **, Fts5Config**, char**\n);\nstatic void sqlite3Fts5ConfigFree(Fts5Config*);\n\nstatic int sqlite3Fts5ConfigDeclareVtab(Fts5Config *pConfig);\n\nstatic int sqlite3Fts5Tokenize(\n  Fts5Config *pConfig,            /* FTS5 Configuration object */\n  int flags,                      /* FTS5_TOKENIZE_* flags */\n  const char *pText, int nText,   /* Text to tokenize */\n  void *pCtx,                     /* Context passed to xToken() */\n  int (*xToken)(void*, int, const char*, int, int, int)    /* Callback */\n);\n\nstatic void sqlite3Fts5Dequote(char *z);\n\n/* Load the contents of the %_config table */\nstatic int sqlite3Fts5ConfigLoad(Fts5Config*, int);\n\n/* Set the value of a single config attribute */\nstatic int sqlite3Fts5ConfigSetValue(Fts5Config*, const char*, sqlite3_value*, int*);\n\nstatic int sqlite3Fts5ConfigParseRank(const char*, char**, char**);\n\n/*\n** End of interface to code in fts5_config.c.\n**************************************************************************/\n\n/**************************************************************************\n** Interface to code in fts5_buffer.c.\n*/\n\n/*\n** Buffer object for the incremental building of string data.\n*/\ntypedef struct Fts5Buffer Fts5Buffer;\nstruct Fts5Buffer {\n  u8 *p;\n  int n;\n  int nSpace;\n};\n\nstatic int sqlite3Fts5BufferSize(int*, Fts5Buffer*, u32);\nstatic void sqlite3Fts5BufferAppendVarint(int*, Fts5Buffer*, i64);\nstatic void sqlite3Fts5BufferAppendBlob(int*, Fts5Buffer*, u32, const u8*);\nstatic void sqlite3Fts5BufferAppendString(int *, Fts5Buffer*, const char*);\nstatic void sqlite3Fts5BufferFree(Fts5Buffer*);\nstatic void sqlite3Fts5BufferZero(Fts5Buffer*);\nstatic void sqlite3Fts5BufferSet(int*, Fts5Buffer*, int, const u8*);\nstatic void sqlite3Fts5BufferAppendPrintf(int *, Fts5Buffer*, char *zFmt, ...);\n\nstatic char *sqlite3Fts5Mprintf(int *pRc, const char *zFmt, ...);\n\n#define fts5BufferZero(x)             sqlite3Fts5BufferZero(x)\n#define fts5BufferAppendVarint(a,b,c) sqlite3Fts5BufferAppendVarint(a,b,c)\n#define fts5BufferFree(a)             sqlite3Fts5BufferFree(a)\n#define fts5BufferAppendBlob(a,b,c,d) sqlite3Fts5BufferAppendBlob(a,b,c,d)\n#define fts5BufferSet(a,b,c,d)        sqlite3Fts5BufferSet(a,b,c,d)\n\n#define fts5BufferGrow(pRc,pBuf,nn) ( \\\n  (u32)((pBuf)->n) + (u32)(nn) <= (u32)((pBuf)->nSpace) ? 0 : \\\n    sqlite3Fts5BufferSize((pRc),(pBuf),(nn)+(pBuf)->n) \\\n)\n\n/* Write and decode big-endian 32-bit integer values */\nstatic void sqlite3Fts5Put32(u8*, int);\nstatic int sqlite3Fts5Get32(const u8*);\n\n#define FTS5_POS2COLUMN(iPos) (int)(iPos >> 32)\n#define FTS5_POS2OFFSET(iPos) (int)(iPos & 0x7FFFFFFF)\n\ntypedef struct Fts5PoslistReader Fts5PoslistReader;\nstruct Fts5PoslistReader {\n  /* Variables used only by sqlite3Fts5PoslistIterXXX() functions. */\n  const u8 *a;                    /* Position list to iterate through */\n  int n;                          /* Size of buffer at a[] in bytes */\n  int i;                          /* Current offset in a[] */\n\n  u8 bFlag;                       /* For client use (any custom purpose) */\n\n  /* Output variables */\n  u8 bEof;                        /* Set to true at EOF */\n  i64 iPos;                       /* (iCol<<32) + iPos */\n};\nstatic int sqlite3Fts5PoslistReaderInit(\n  const u8 *a, int n,             /* Poslist buffer to iterate through */\n  Fts5PoslistReader *pIter        /* Iterator object to initialize */\n);\nstatic int sqlite3Fts5PoslistReaderNext(Fts5PoslistReader*);\n\ntypedef struct Fts5PoslistWriter Fts5PoslistWriter;\nstruct Fts5PoslistWriter {\n  i64 iPrev;\n};\nstatic int sqlite3Fts5PoslistWriterAppend(Fts5Buffer*, Fts5PoslistWriter*, i64);\nstatic void sqlite3Fts5PoslistSafeAppend(Fts5Buffer*, i64*, i64);\n\nstatic int sqlite3Fts5PoslistNext64(\n  const u8 *a, int n,             /* Buffer containing poslist */\n  int *pi,                        /* IN/OUT: Offset within a[] */\n  i64 *piOff                      /* IN/OUT: Current offset */\n);\n\n/* Malloc utility */\nstatic void *sqlite3Fts5MallocZero(int *pRc, sqlite3_int64 nByte);\nstatic char *sqlite3Fts5Strndup(int *pRc, const char *pIn, int nIn);\n\n/* Character set tests (like isspace(), isalpha() etc.) */\nstatic int sqlite3Fts5IsBareword(char t);\n\n\n/* Bucket of terms object used by the integrity-check in offsets=0 mode. */\ntypedef struct Fts5Termset Fts5Termset;\nstatic int sqlite3Fts5TermsetNew(Fts5Termset**);\nstatic int sqlite3Fts5TermsetAdd(Fts5Termset*, int, const char*, int, int *pbPresent);\nstatic void sqlite3Fts5TermsetFree(Fts5Termset*);\n\n/*\n** End of interface to code in fts5_buffer.c.\n**************************************************************************/\n\n/**************************************************************************\n** Interface to code in fts5_index.c. fts5_index.c contains contains code\n** to access the data stored in the %_data table.\n*/\n\ntypedef struct Fts5Index Fts5Index;\ntypedef struct Fts5IndexIter Fts5IndexIter;\n\nstruct Fts5IndexIter {\n  i64 iRowid;\n  const u8 *pData;\n  int nData;\n  u8 bEof;\n};\n\n#define sqlite3Fts5IterEof(x) ((x)->bEof)\n\n/*\n** Values used as part of the flags argument passed to IndexQuery().\n*/\n#define FTS5INDEX_QUERY_PREFIX     0x0001   /* Prefix query */\n#define FTS5INDEX_QUERY_DESC       0x0002   /* Docs in descending rowid order */\n#define FTS5INDEX_QUERY_TEST_NOIDX 0x0004   /* Do not use prefix index */\n#define FTS5INDEX_QUERY_SCAN       0x0008   /* Scan query (fts5vocab) */\n\n/* The following are used internally by the fts5_index.c module. They are\n** defined here only to make it easier to avoid clashes with the flags\n** above. */\n#define FTS5INDEX_QUERY_SKIPEMPTY  0x0010\n#define FTS5INDEX_QUERY_NOOUTPUT   0x0020\n\n/*\n** Create/destroy an Fts5Index object.\n*/\nstatic int sqlite3Fts5IndexOpen(Fts5Config *pConfig, int bCreate, Fts5Index**, char**);\nstatic int sqlite3Fts5IndexClose(Fts5Index *p);\n\n/*\n** Return a simple checksum value based on the arguments.\n*/\nstatic u64 sqlite3Fts5IndexEntryCksum(\n  i64 iRowid, \n  int iCol, \n  int iPos, \n  int iIdx,\n  const char *pTerm,\n  int nTerm\n);\n\n/*\n** Argument p points to a buffer containing utf-8 text that is n bytes in \n** size. Return the number of bytes in the nChar character prefix of the\n** buffer, or 0 if there are less than nChar characters in total.\n*/\nstatic int sqlite3Fts5IndexCharlenToBytelen(\n  const char *p, \n  int nByte, \n  int nChar\n);\n\n/*\n** Open a new iterator to iterate though all rowids that match the \n** specified token or token prefix.\n*/\nstatic int sqlite3Fts5IndexQuery(\n  Fts5Index *p,                   /* FTS index to query */\n  const char *pToken, int nToken, /* Token (or prefix) to query for */\n  int flags,                      /* Mask of FTS5INDEX_QUERY_X flags */\n  Fts5Colset *pColset,            /* Match these columns only */\n  Fts5IndexIter **ppIter          /* OUT: New iterator object */\n);\n\n/*\n** The various operations on open token or token prefix iterators opened\n** using sqlite3Fts5IndexQuery().\n*/\nstatic int sqlite3Fts5IterNext(Fts5IndexIter*);\nstatic int sqlite3Fts5IterNextFrom(Fts5IndexIter*, i64 iMatch);\n\n/*\n** Close an iterator opened by sqlite3Fts5IndexQuery().\n*/\nstatic void sqlite3Fts5IterClose(Fts5IndexIter*);\n\n/*\n** This interface is used by the fts5vocab module.\n*/\nstatic const char *sqlite3Fts5IterTerm(Fts5IndexIter*, int*);\nstatic int sqlite3Fts5IterNextScan(Fts5IndexIter*);\n\n\n/*\n** Insert or remove data to or from the index. Each time a document is \n** added to or removed from the index, this function is called one or more\n** times.\n**\n** For an insert, it must be called once for each token in the new document.\n** If the operation is a delete, it must be called (at least) once for each\n** unique token in the document with an iCol value less than zero. The iPos\n** argument is ignored for a delete.\n*/\nstatic int sqlite3Fts5IndexWrite(\n  Fts5Index *p,                   /* Index to write to */\n  int iCol,                       /* Column token appears in (-ve -> delete) */\n  int iPos,                       /* Position of token within column */\n  const char *pToken, int nToken  /* Token to add or remove to or from index */\n);\n\n/*\n** Indicate that subsequent calls to sqlite3Fts5IndexWrite() pertain to\n** document iDocid.\n*/\nstatic int sqlite3Fts5IndexBeginWrite(\n  Fts5Index *p,                   /* Index to write to */\n  int bDelete,                    /* True if current operation is a delete */\n  i64 iDocid                      /* Docid to add or remove data from */\n);\n\n/*\n** Flush any data stored in the in-memory hash tables to the database.\n** Also close any open blob handles.\n*/\nstatic int sqlite3Fts5IndexSync(Fts5Index *p);\n\n/*\n** Discard any data stored in the in-memory hash tables. Do not write it\n** to the database. Additionally, assume that the contents of the %_data\n** table may have changed on disk. So any in-memory caches of %_data \n** records must be invalidated.\n*/\nstatic int sqlite3Fts5IndexRollback(Fts5Index *p);\n\n/*\n** Get or set the \"averages\" values.\n*/\nstatic int sqlite3Fts5IndexGetAverages(Fts5Index *p, i64 *pnRow, i64 *anSize);\nstatic int sqlite3Fts5IndexSetAverages(Fts5Index *p, const u8*, int);\n\n/*\n** Functions called by the storage module as part of integrity-check.\n*/\nstatic int sqlite3Fts5IndexIntegrityCheck(Fts5Index*, u64 cksum);\n\n/* \n** Called during virtual module initialization to register UDF \n** fts5_decode() with SQLite \n*/\nstatic int sqlite3Fts5IndexInit(sqlite3*);\n\nstatic int sqlite3Fts5IndexSetCookie(Fts5Index*, int);\n\n/*\n** Return the total number of entries read from the %_data table by \n** this connection since it was created.\n*/\nstatic int sqlite3Fts5IndexReads(Fts5Index *p);\n\nstatic int sqlite3Fts5IndexReinit(Fts5Index *p);\nstatic int sqlite3Fts5IndexOptimize(Fts5Index *p);\nstatic int sqlite3Fts5IndexMerge(Fts5Index *p, int nMerge);\nstatic int sqlite3Fts5IndexReset(Fts5Index *p);\n\nstatic int sqlite3Fts5IndexLoadConfig(Fts5Index *p);\n\n/*\n** End of interface to code in fts5_index.c.\n**************************************************************************/\n\n/**************************************************************************\n** Interface to code in fts5_varint.c. \n*/\nstatic int sqlite3Fts5GetVarint32(const unsigned char *p, u32 *v);\nstatic int sqlite3Fts5GetVarintLen(u32 iVal);\nstatic u8 sqlite3Fts5GetVarint(const unsigned char*, u64*);\nstatic int sqlite3Fts5PutVarint(unsigned char *p, u64 v);\n\n#define fts5GetVarint32(a,b) sqlite3Fts5GetVarint32(a,(u32*)&b)\n#define fts5GetVarint    sqlite3Fts5GetVarint\n\n#define fts5FastGetVarint32(a, iOff, nVal) {      \\\n  nVal = (a)[iOff++];                             \\\n  if( nVal & 0x80 ){                              \\\n    iOff--;                                       \\\n    iOff += fts5GetVarint32(&(a)[iOff], nVal);    \\\n  }                                               \\\n}\n\n\n/*\n** End of interface to code in fts5_varint.c.\n**************************************************************************/\n\n\n/**************************************************************************\n** Interface to code in fts5_main.c. \n*/\n\n/*\n** Virtual-table object.\n*/\ntypedef struct Fts5Table Fts5Table;\nstruct Fts5Table {\n  sqlite3_vtab base;              /* Base class used by SQLite core */\n  Fts5Config *pConfig;            /* Virtual table configuration */\n  Fts5Index *pIndex;              /* Full-text index */\n};\n\nstatic int sqlite3Fts5GetTokenizer(\n  Fts5Global*, \n  const char **azArg,\n  int nArg,\n  Fts5Tokenizer**,\n  fts5_tokenizer**,\n  char **pzErr\n);\n\nstatic Fts5Table *sqlite3Fts5TableFromCsrid(Fts5Global*, i64);\n\nstatic int sqlite3Fts5FlushToDisk(Fts5Table*);\n\n/*\n** End of interface to code in fts5.c.\n**************************************************************************/\n\n/**************************************************************************\n** Interface to code in fts5_hash.c. \n*/\ntypedef struct Fts5Hash Fts5Hash;\n\n/*\n** Create a hash table, free a hash table.\n*/\nstatic int sqlite3Fts5HashNew(Fts5Config*, Fts5Hash**, int *pnSize);\nstatic void sqlite3Fts5HashFree(Fts5Hash*);\n\nstatic int sqlite3Fts5HashWrite(\n  Fts5Hash*,\n  i64 iRowid,                     /* Rowid for this entry */\n  int iCol,                       /* Column token appears in (-ve -> delete) */\n  int iPos,                       /* Position of token within column */\n  char bByte,\n  const char *pToken, int nToken  /* Token to add or remove to or from index */\n);\n\n/*\n** Empty (but do not delete) a hash table.\n*/\nstatic void sqlite3Fts5HashClear(Fts5Hash*);\n\nstatic int sqlite3Fts5HashQuery(\n  Fts5Hash*,                      /* Hash table to query */\n  const char *pTerm, int nTerm,   /* Query term */\n  const u8 **ppDoclist,           /* OUT: Pointer to doclist for pTerm */\n  int *pnDoclist                  /* OUT: Size of doclist in bytes */\n);\n\nstatic int sqlite3Fts5HashScanInit(\n  Fts5Hash*,                      /* Hash table to query */\n  const char *pTerm, int nTerm    /* Query prefix */\n);\nstatic void sqlite3Fts5HashScanNext(Fts5Hash*);\nstatic int sqlite3Fts5HashScanEof(Fts5Hash*);\nstatic void sqlite3Fts5HashScanEntry(Fts5Hash *,\n  const char **pzTerm,            /* OUT: term (nul-terminated) */\n  const u8 **ppDoclist,           /* OUT: pointer to doclist */\n  int *pnDoclist                  /* OUT: size of doclist in bytes */\n);\n\n\n/*\n** End of interface to code in fts5_hash.c.\n**************************************************************************/\n\n/**************************************************************************\n** Interface to code in fts5_storage.c. fts5_storage.c contains contains \n** code to access the data stored in the %_content and %_docsize tables.\n*/\n\n#define FTS5_STMT_SCAN_ASC  0     /* SELECT rowid, * FROM ... ORDER BY 1 ASC */\n#define FTS5_STMT_SCAN_DESC 1     /* SELECT rowid, * FROM ... ORDER BY 1 DESC */\n#define FTS5_STMT_LOOKUP    2     /* SELECT rowid, * FROM ... WHERE rowid=? */\n\ntypedef struct Fts5Storage Fts5Storage;\n\nstatic int sqlite3Fts5StorageOpen(Fts5Config*, Fts5Index*, int, Fts5Storage**, char**);\nstatic int sqlite3Fts5StorageClose(Fts5Storage *p);\nstatic int sqlite3Fts5StorageRename(Fts5Storage*, const char *zName);\n\nstatic int sqlite3Fts5DropAll(Fts5Config*);\nstatic int sqlite3Fts5CreateTable(Fts5Config*, const char*, const char*, int, char **);\n\nstatic int sqlite3Fts5StorageDelete(Fts5Storage *p, i64, sqlite3_value**);\nstatic int sqlite3Fts5StorageContentInsert(Fts5Storage *p, sqlite3_value**, i64*);\nstatic int sqlite3Fts5StorageIndexInsert(Fts5Storage *p, sqlite3_value**, i64);\n\nstatic int sqlite3Fts5StorageIntegrity(Fts5Storage *p);\n\nstatic int sqlite3Fts5StorageStmt(Fts5Storage *p, int eStmt, sqlite3_stmt**, char**);\nstatic void sqlite3Fts5StorageStmtRelease(Fts5Storage *p, int eStmt, sqlite3_stmt*);\n\nstatic int sqlite3Fts5StorageDocsize(Fts5Storage *p, i64 iRowid, int *aCol);\nstatic int sqlite3Fts5StorageSize(Fts5Storage *p, int iCol, i64 *pnAvg);\nstatic int sqlite3Fts5StorageRowCount(Fts5Storage *p, i64 *pnRow);\n\nstatic int sqlite3Fts5StorageSync(Fts5Storage *p);\nstatic int sqlite3Fts5StorageRollback(Fts5Storage *p);\n\nstatic int sqlite3Fts5StorageConfigValue(\n    Fts5Storage *p, const char*, sqlite3_value*, int\n);\n\nstatic int sqlite3Fts5StorageDeleteAll(Fts5Storage *p);\nstatic int sqlite3Fts5StorageRebuild(Fts5Storage *p);\nstatic int sqlite3Fts5StorageOptimize(Fts5Storage *p);\nstatic int sqlite3Fts5StorageMerge(Fts5Storage *p, int nMerge);\nstatic int sqlite3Fts5StorageReset(Fts5Storage *p);\n\n/*\n** End of interface to code in fts5_storage.c.\n**************************************************************************/\n\n\n/**************************************************************************\n** Interface to code in fts5_expr.c. \n*/\ntypedef struct Fts5Expr Fts5Expr;\ntypedef struct Fts5ExprNode Fts5ExprNode;\ntypedef struct Fts5Parse Fts5Parse;\ntypedef struct Fts5Token Fts5Token;\ntypedef struct Fts5ExprPhrase Fts5ExprPhrase;\ntypedef struct Fts5ExprNearset Fts5ExprNearset;\n\nstruct Fts5Token {\n  const char *p;                  /* Token text (not NULL terminated) */\n  int n;                          /* Size of buffer p in bytes */\n};\n\n/* Parse a MATCH expression. */\nstatic int sqlite3Fts5ExprNew(\n  Fts5Config *pConfig, \n  int iCol,                       /* Column on LHS of MATCH operator */\n  const char *zExpr,\n  Fts5Expr **ppNew, \n  char **pzErr\n);\n\n/*\n** for(rc = sqlite3Fts5ExprFirst(pExpr, pIdx, bDesc);\n**     rc==SQLITE_OK && 0==sqlite3Fts5ExprEof(pExpr);\n**     rc = sqlite3Fts5ExprNext(pExpr)\n** ){\n**   // The document with rowid iRowid matches the expression!\n**   i64 iRowid = sqlite3Fts5ExprRowid(pExpr);\n** }\n*/\nstatic int sqlite3Fts5ExprFirst(Fts5Expr*, Fts5Index *pIdx, i64 iMin, int bDesc);\nstatic int sqlite3Fts5ExprNext(Fts5Expr*, i64 iMax);\nstatic int sqlite3Fts5ExprEof(Fts5Expr*);\nstatic i64 sqlite3Fts5ExprRowid(Fts5Expr*);\n\nstatic void sqlite3Fts5ExprFree(Fts5Expr*);\n\n/* Called during startup to register a UDF with SQLite */\nstatic int sqlite3Fts5ExprInit(Fts5Global*, sqlite3*);\n\nstatic int sqlite3Fts5ExprPhraseCount(Fts5Expr*);\nstatic int sqlite3Fts5ExprPhraseSize(Fts5Expr*, int iPhrase);\nstatic int sqlite3Fts5ExprPoslist(Fts5Expr*, int, const u8 **);\n\ntypedef struct Fts5PoslistPopulator Fts5PoslistPopulator;\nstatic Fts5PoslistPopulator *sqlite3Fts5ExprClearPoslists(Fts5Expr*, int);\nstatic int sqlite3Fts5ExprPopulatePoslists(\n    Fts5Config*, Fts5Expr*, Fts5PoslistPopulator*, int, const char*, int\n);\nstatic void sqlite3Fts5ExprCheckPoslists(Fts5Expr*, i64);\n\nstatic int sqlite3Fts5ExprClonePhrase(Fts5Expr*, int, Fts5Expr**);\n\nstatic int sqlite3Fts5ExprPhraseCollist(Fts5Expr *, int, const u8 **, int *);\n\n/*******************************************\n** The fts5_expr.c API above this point is used by the other hand-written\n** C code in this module. The interfaces below this point are called by\n** the parser code in fts5parse.y.  */\n\nstatic void sqlite3Fts5ParseError(Fts5Parse *pParse, const char *zFmt, ...);\n\nstatic Fts5ExprNode *sqlite3Fts5ParseNode(\n  Fts5Parse *pParse,\n  int eType,\n  Fts5ExprNode *pLeft,\n  Fts5ExprNode *pRight,\n  Fts5ExprNearset *pNear\n);\n\nstatic Fts5ExprNode *sqlite3Fts5ParseImplicitAnd(\n  Fts5Parse *pParse,\n  Fts5ExprNode *pLeft,\n  Fts5ExprNode *pRight\n);\n\nstatic Fts5ExprPhrase *sqlite3Fts5ParseTerm(\n  Fts5Parse *pParse, \n  Fts5ExprPhrase *pPhrase, \n  Fts5Token *pToken,\n  int bPrefix\n);\n\nstatic void sqlite3Fts5ParseSetCaret(Fts5ExprPhrase*);\n\nstatic Fts5ExprNearset *sqlite3Fts5ParseNearset(\n  Fts5Parse*, \n  Fts5ExprNearset*,\n  Fts5ExprPhrase* \n);\n\nstatic Fts5Colset *sqlite3Fts5ParseColset(\n  Fts5Parse*, \n  Fts5Colset*, \n  Fts5Token *\n);\n\nstatic void sqlite3Fts5ParsePhraseFree(Fts5ExprPhrase*);\nstatic void sqlite3Fts5ParseNearsetFree(Fts5ExprNearset*);\nstatic void sqlite3Fts5ParseNodeFree(Fts5ExprNode*);\n\nstatic void sqlite3Fts5ParseSetDistance(Fts5Parse*, Fts5ExprNearset*, Fts5Token*);\nstatic void sqlite3Fts5ParseSetColset(Fts5Parse*, Fts5ExprNode*, Fts5Colset*);\nstatic Fts5Colset *sqlite3Fts5ParseColsetInvert(Fts5Parse*, Fts5Colset*);\nstatic void sqlite3Fts5ParseFinished(Fts5Parse *pParse, Fts5ExprNode *p);\nstatic void sqlite3Fts5ParseNear(Fts5Parse *pParse, Fts5Token*);\n\n/*\n** End of interface to code in fts5_expr.c.\n**************************************************************************/\n\n\n\n/**************************************************************************\n** Interface to code in fts5_aux.c. \n*/\n\nstatic int sqlite3Fts5AuxInit(fts5_api*);\n/*\n** End of interface to code in fts5_aux.c.\n**************************************************************************/\n\n/**************************************************************************\n** Interface to code in fts5_tokenizer.c. \n*/\n\nstatic int sqlite3Fts5TokenizerInit(fts5_api*);\n/*\n** End of interface to code in fts5_tokenizer.c.\n**************************************************************************/\n\n/**************************************************************************\n** Interface to code in fts5_vocab.c. \n*/\n\nstatic int sqlite3Fts5VocabInit(Fts5Global*, sqlite3*);\n\n/*\n** End of interface to code in fts5_vocab.c.\n**************************************************************************/\n\n\n/**************************************************************************\n** Interface to automatically generated code in fts5_unicode2.c. \n*/\nstatic int sqlite3Fts5UnicodeIsdiacritic(int c);\nstatic int sqlite3Fts5UnicodeFold(int c, int bRemoveDiacritic);\n\nstatic int sqlite3Fts5UnicodeCatParse(const char*, u8*);\nstatic int sqlite3Fts5UnicodeCategory(u32 iCode);\nstatic void sqlite3Fts5UnicodeAscii(u8*, u8*);\n/*\n** End of interface to code in fts5_unicode2.c.\n**************************************************************************/\n\n#endif\n\n#define FTS5_OR                               1\n#define FTS5_AND                              2\n#define FTS5_NOT                              3\n#define FTS5_TERM                             4\n#define FTS5_COLON                            5\n#define FTS5_MINUS                            6\n#define FTS5_LCP                              7\n#define FTS5_RCP                              8\n#define FTS5_STRING                           9\n#define FTS5_LP                              10\n#define FTS5_RP                              11\n#define FTS5_CARET                           12\n#define FTS5_COMMA                           13\n#define FTS5_PLUS                            14\n#define FTS5_STAR                            15\n\n/*\n** 2000-05-29\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** Driver template for the LEMON parser generator.\n**\n** The \"lemon\" program processes an LALR(1) input grammar file, then uses\n** this template to construct a parser.  The \"lemon\" program inserts text\n** at each \"%%\" line.  Also, any \"P-a-r-s-e\" identifer prefix (without the\n** interstitial \"-\" characters) contained in this template is changed into\n** the value of the %name directive from the grammar.  Otherwise, the content\n** of this template is copied straight through into the generate parser\n** source file.\n**\n** The following is the concatenation of all %include directives from the\n** input grammar file:\n*/\n/* #include <stdio.h> */\n/* #include <assert.h> */\n/************ Begin %include sections from the grammar ************************/\n\n/* #include \"fts5Int.h\" */\n/* #include \"fts5parse.h\" */\n\n/*\n** Disable all error recovery processing in the parser push-down\n** automaton.\n*/\n#define fts5YYNOERRORRECOVERY 1\n\n/*\n** Make fts5yytestcase() the same as testcase()\n*/\n#define fts5yytestcase(X) testcase(X)\n\n/*\n** Indicate that sqlite3ParserFree() will never be called with a null\n** pointer.\n*/\n#define fts5YYPARSEFREENOTNULL 1\n\n/*\n** Alternative datatype for the argument to the malloc() routine passed\n** into sqlite3ParserAlloc().  The default is size_t.\n*/\n#define fts5YYMALLOCARGTYPE  u64\n\n/**************** End of %include directives **********************************/\n/* These constants specify the various numeric values for terminal symbols\n** in a format understandable to \"makeheaders\".  This section is blank unless\n** \"lemon\" is run with the \"-m\" command-line option.\n***************** Begin makeheaders token definitions *************************/\n/**************** End makeheaders token definitions ***************************/\n\n/* The next sections is a series of control #defines.\n** various aspects of the generated parser.\n**    fts5YYCODETYPE         is the data type used to store the integer codes\n**                       that represent terminal and non-terminal symbols.\n**                       \"unsigned char\" is used if there are fewer than\n**                       256 symbols.  Larger types otherwise.\n**    fts5YYNOCODE           is a number of type fts5YYCODETYPE that is not used for\n**                       any terminal or nonterminal symbol.\n**    fts5YYFALLBACK         If defined, this indicates that one or more tokens\n**                       (also known as: \"terminal symbols\") have fall-back\n**                       values which should be used if the original symbol\n**                       would not parse.  This permits keywords to sometimes\n**                       be used as identifiers, for example.\n**    fts5YYACTIONTYPE       is the data type used for \"action codes\" - numbers\n**                       that indicate what to do in response to the next\n**                       token.\n**    sqlite3Fts5ParserFTS5TOKENTYPE     is the data type used for minor type for terminal\n**                       symbols.  Background: A \"minor type\" is a semantic\n**                       value associated with a terminal or non-terminal\n**                       symbols.  For example, for an \"ID\" terminal symbol,\n**                       the minor type might be the name of the identifier.\n**                       Each non-terminal can have a different minor type.\n**                       Terminal symbols all have the same minor type, though.\n**                       This macros defines the minor type for terminal \n**                       symbols.\n**    fts5YYMINORTYPE        is the data type used for all minor types.\n**                       This is typically a union of many types, one of\n**                       which is sqlite3Fts5ParserFTS5TOKENTYPE.  The entry in the union\n**                       for terminal symbols is called \"fts5yy0\".\n**    fts5YYSTACKDEPTH       is the maximum depth of the parser's stack.  If\n**                       zero the stack is dynamically sized using realloc()\n**    sqlite3Fts5ParserARG_SDECL     A static variable declaration for the %extra_argument\n**    sqlite3Fts5ParserARG_PDECL     A parameter declaration for the %extra_argument\n**    sqlite3Fts5ParserARG_PARAM     Code to pass %extra_argument as a subroutine parameter\n**    sqlite3Fts5ParserARG_STORE     Code to store %extra_argument into fts5yypParser\n**    sqlite3Fts5ParserARG_FETCH     Code to extract %extra_argument from fts5yypParser\n**    sqlite3Fts5ParserCTX_*         As sqlite3Fts5ParserARG_ except for %extra_context\n**    fts5YYERRORSYMBOL      is the code number of the error symbol.  If not\n**                       defined, then do no error processing.\n**    fts5YYNSTATE           the combined number of states.\n**    fts5YYNRULE            the number of rules in the grammar\n**    fts5YYNFTS5TOKEN           Number of terminal symbols\n**    fts5YY_MAX_SHIFT       Maximum value for shift actions\n**    fts5YY_MIN_SHIFTREDUCE Minimum value for shift-reduce actions\n**    fts5YY_MAX_SHIFTREDUCE Maximum value for shift-reduce actions\n**    fts5YY_ERROR_ACTION    The fts5yy_action[] code for syntax error\n**    fts5YY_ACCEPT_ACTION   The fts5yy_action[] code for accept\n**    fts5YY_NO_ACTION       The fts5yy_action[] code for no-op\n**    fts5YY_MIN_REDUCE      Minimum value for reduce actions\n**    fts5YY_MAX_REDUCE      Maximum value for reduce actions\n*/\n#ifndef INTERFACE\n# define INTERFACE 1\n#endif\n/************* Begin control #defines *****************************************/\n#define fts5YYCODETYPE unsigned char\n#define fts5YYNOCODE 27\n#define fts5YYACTIONTYPE unsigned char\n#define sqlite3Fts5ParserFTS5TOKENTYPE Fts5Token\ntypedef union {\n  int fts5yyinit;\n  sqlite3Fts5ParserFTS5TOKENTYPE fts5yy0;\n  int fts5yy4;\n  Fts5Colset* fts5yy11;\n  Fts5ExprNode* fts5yy24;\n  Fts5ExprNearset* fts5yy46;\n  Fts5ExprPhrase* fts5yy53;\n} fts5YYMINORTYPE;\n#ifndef fts5YYSTACKDEPTH\n#define fts5YYSTACKDEPTH 100\n#endif\n#define sqlite3Fts5ParserARG_SDECL Fts5Parse *pParse;\n#define sqlite3Fts5ParserARG_PDECL ,Fts5Parse *pParse\n#define sqlite3Fts5ParserARG_PARAM ,pParse\n#define sqlite3Fts5ParserARG_FETCH Fts5Parse *pParse=fts5yypParser->pParse;\n#define sqlite3Fts5ParserARG_STORE fts5yypParser->pParse=pParse;\n#define sqlite3Fts5ParserCTX_SDECL\n#define sqlite3Fts5ParserCTX_PDECL\n#define sqlite3Fts5ParserCTX_PARAM\n#define sqlite3Fts5ParserCTX_FETCH\n#define sqlite3Fts5ParserCTX_STORE\n#define fts5YYNSTATE             35\n#define fts5YYNRULE              28\n#define fts5YYNFTS5TOKEN             16\n#define fts5YY_MAX_SHIFT         34\n#define fts5YY_MIN_SHIFTREDUCE   52\n#define fts5YY_MAX_SHIFTREDUCE   79\n#define fts5YY_ERROR_ACTION      80\n#define fts5YY_ACCEPT_ACTION     81\n#define fts5YY_NO_ACTION         82\n#define fts5YY_MIN_REDUCE        83\n#define fts5YY_MAX_REDUCE        110\n/************* End control #defines *******************************************/\n#define fts5YY_NLOOKAHEAD ((int)(sizeof(fts5yy_lookahead)/sizeof(fts5yy_lookahead[0])))\n\n/* Define the fts5yytestcase() macro to be a no-op if is not already defined\n** otherwise.\n**\n** Applications can choose to define fts5yytestcase() in the %include section\n** to a macro that can assist in verifying code coverage.  For production\n** code the fts5yytestcase() macro should be turned off.  But it is useful\n** for testing.\n*/\n#ifndef fts5yytestcase\n# define fts5yytestcase(X)\n#endif\n\n\n/* Next are the tables used to determine what action to take based on the\n** current state and lookahead token.  These tables are used to implement\n** functions that take a state number and lookahead value and return an\n** action integer.  \n**\n** Suppose the action integer is N.  Then the action is determined as\n** follows\n**\n**   0 <= N <= fts5YY_MAX_SHIFT             Shift N.  That is, push the lookahead\n**                                      token onto the stack and goto state N.\n**\n**   N between fts5YY_MIN_SHIFTREDUCE       Shift to an arbitrary state then\n**     and fts5YY_MAX_SHIFTREDUCE           reduce by rule N-fts5YY_MIN_SHIFTREDUCE.\n**\n**   N == fts5YY_ERROR_ACTION               A syntax error has occurred.\n**\n**   N == fts5YY_ACCEPT_ACTION              The parser accepts its input.\n**\n**   N == fts5YY_NO_ACTION                  No such action.  Denotes unused\n**                                      slots in the fts5yy_action[] table.\n**\n**   N between fts5YY_MIN_REDUCE            Reduce by rule N-fts5YY_MIN_REDUCE\n**     and fts5YY_MAX_REDUCE\n**\n** The action table is constructed as a single large table named fts5yy_action[].\n** Given state S and lookahead X, the action is computed as either:\n**\n**    (A)   N = fts5yy_action[ fts5yy_shift_ofst[S] + X ]\n**    (B)   N = fts5yy_default[S]\n**\n** The (A) formula is preferred.  The B formula is used instead if\n** fts5yy_lookahead[fts5yy_shift_ofst[S]+X] is not equal to X.\n**\n** The formulas above are for computing the action when the lookahead is\n** a terminal symbol.  If the lookahead is a non-terminal (as occurs after\n** a reduce action) then the fts5yy_reduce_ofst[] array is used in place of\n** the fts5yy_shift_ofst[] array.\n**\n** The following are the tables generated in this section:\n**\n**  fts5yy_action[]        A single table containing all actions.\n**  fts5yy_lookahead[]     A table containing the lookahead for each entry in\n**                     fts5yy_action.  Used to detect hash collisions.\n**  fts5yy_shift_ofst[]    For each state, the offset into fts5yy_action for\n**                     shifting terminals.\n**  fts5yy_reduce_ofst[]   For each state, the offset into fts5yy_action for\n**                     shifting non-terminals after a reduce.\n**  fts5yy_default[]       Default action for each state.\n**\n*********** Begin parsing tables **********************************************/\n#define fts5YY_ACTTAB_COUNT (105)\nstatic const fts5YYACTIONTYPE fts5yy_action[] = {\n /*     0 */    81,   20,   96,    6,   28,   99,   98,   26,   26,   18,\n /*    10 */    96,    6,   28,   17,   98,   56,   26,   19,   96,    6,\n /*    20 */    28,   14,   98,   14,   26,   31,   92,   96,    6,   28,\n /*    30 */   108,   98,   25,   26,   21,   96,    6,   28,   78,   98,\n /*    40 */    58,   26,   29,   96,    6,   28,  107,   98,   22,   26,\n /*    50 */    24,   16,   12,   11,    1,   13,   13,   24,   16,   23,\n /*    60 */    11,   33,   34,   13,   97,    8,   27,   32,   98,    7,\n /*    70 */    26,    3,    4,    5,    3,    4,    5,    3,   83,    4,\n /*    80 */     5,    3,   63,    5,    3,   62,   12,    2,   86,   13,\n /*    90 */     9,   30,   10,   10,   54,   57,   75,   78,   78,   53,\n /*   100 */    57,   15,   82,   82,   71,\n};\nstatic const fts5YYCODETYPE fts5yy_lookahead[] = {\n /*     0 */    16,   17,   18,   19,   20,   22,   22,   24,   24,   17,\n /*    10 */    18,   19,   20,    7,   22,    9,   24,   17,   18,   19,\n /*    20 */    20,    9,   22,    9,   24,   13,   17,   18,   19,   20,\n /*    30 */    26,   22,   24,   24,   17,   18,   19,   20,   15,   22,\n /*    40 */     9,   24,   17,   18,   19,   20,   26,   22,   21,   24,\n /*    50 */     6,    7,    9,    9,   10,   12,   12,    6,    7,   21,\n /*    60 */     9,   24,   25,   12,   18,    5,   20,   14,   22,    5,\n /*    70 */    24,    3,    1,    2,    3,    1,    2,    3,    0,    1,\n /*    80 */     2,    3,   11,    2,    3,   11,    9,   10,    5,   12,\n /*    90 */    23,   24,   10,   10,    8,    9,    9,   15,   15,    8,\n /*   100 */     9,    9,   27,   27,   11,   27,   27,   27,   27,   27,\n /*   110 */    27,   27,   27,   27,   27,   27,   27,   27,   27,   27,\n /*   120 */    27,\n};\n#define fts5YY_SHIFT_COUNT    (34)\n#define fts5YY_SHIFT_MIN      (0)\n#define fts5YY_SHIFT_MAX      (93)\nstatic const unsigned char fts5yy_shift_ofst[] = {\n /*     0 */    44,   44,   44,   44,   44,   44,   51,   77,   43,   12,\n /*    10 */    14,   83,   82,   14,   23,   23,   31,   31,   71,   74,\n /*    20 */    78,   81,   86,   91,    6,   53,   53,   60,   64,   68,\n /*    30 */    53,   87,   92,   53,   93,\n};\n#define fts5YY_REDUCE_COUNT (17)\n#define fts5YY_REDUCE_MIN   (-17)\n#define fts5YY_REDUCE_MAX   (67)\nstatic const signed char fts5yy_reduce_ofst[] = {\n /*     0 */   -16,   -8,    0,    9,   17,   25,   46,  -17,  -17,   37,\n /*    10 */    67,    4,    4,    8,    4,   20,   27,   38,\n};\nstatic const fts5YYACTIONTYPE fts5yy_default[] = {\n /*     0 */    80,   80,   80,   80,   80,   80,   95,   80,   80,  105,\n /*    10 */    80,  110,  110,   80,  110,  110,   80,   80,   80,   80,\n /*    20 */    80,   91,   80,   80,   80,  101,  100,   80,   80,   90,\n /*    30 */   103,   80,   80,  104,   80,\n};\n/********** End of lemon-generated parsing tables *****************************/\n\n/* The next table maps tokens (terminal symbols) into fallback tokens.  \n** If a construct like the following:\n** \n**      %fallback ID X Y Z.\n**\n** appears in the grammar, then ID becomes a fallback token for X, Y,\n** and Z.  Whenever one of the tokens X, Y, or Z is input to the parser\n** but it does not parse, the type of the token is changed to ID and\n** the parse is retried before an error is thrown.\n**\n** This feature can be used, for example, to cause some keywords in a language\n** to revert to identifiers if they keyword does not apply in the context where\n** it appears.\n*/\n#ifdef fts5YYFALLBACK\nstatic const fts5YYCODETYPE fts5yyFallback[] = {\n};\n#endif /* fts5YYFALLBACK */\n\n/* The following structure represents a single element of the\n** parser's stack.  Information stored includes:\n**\n**   +  The state number for the parser at this level of the stack.\n**\n**   +  The value of the token stored at this level of the stack.\n**      (In other words, the \"major\" token.)\n**\n**   +  The semantic value stored at this level of the stack.  This is\n**      the information used by the action routines in the grammar.\n**      It is sometimes called the \"minor\" token.\n**\n** After the \"shift\" half of a SHIFTREDUCE action, the stateno field\n** actually contains the reduce action for the second half of the\n** SHIFTREDUCE.\n*/\nstruct fts5yyStackEntry {\n  fts5YYACTIONTYPE stateno;  /* The state-number, or reduce action in SHIFTREDUCE */\n  fts5YYCODETYPE major;      /* The major token value.  This is the code\n                         ** number for the token at this stack level */\n  fts5YYMINORTYPE minor;     /* The user-supplied minor token value.  This\n                         ** is the value of the token  */\n};\ntypedef struct fts5yyStackEntry fts5yyStackEntry;\n\n/* The state of the parser is completely contained in an instance of\n** the following structure */\nstruct fts5yyParser {\n  fts5yyStackEntry *fts5yytos;          /* Pointer to top element of the stack */\n#ifdef fts5YYTRACKMAXSTACKDEPTH\n  int fts5yyhwm;                    /* High-water mark of the stack */\n#endif\n#ifndef fts5YYNOERRORRECOVERY\n  int fts5yyerrcnt;                 /* Shifts left before out of the error */\n#endif\n  sqlite3Fts5ParserARG_SDECL                /* A place to hold %extra_argument */\n  sqlite3Fts5ParserCTX_SDECL                /* A place to hold %extra_context */\n#if fts5YYSTACKDEPTH<=0\n  int fts5yystksz;                  /* Current side of the stack */\n  fts5yyStackEntry *fts5yystack;        /* The parser's stack */\n  fts5yyStackEntry fts5yystk0;          /* First stack entry */\n#else\n  fts5yyStackEntry fts5yystack[fts5YYSTACKDEPTH];  /* The parser's stack */\n  fts5yyStackEntry *fts5yystackEnd;            /* Last entry in the stack */\n#endif\n};\ntypedef struct fts5yyParser fts5yyParser;\n\n#ifndef NDEBUG\n/* #include <stdio.h> */\nstatic FILE *fts5yyTraceFILE = 0;\nstatic char *fts5yyTracePrompt = 0;\n#endif /* NDEBUG */\n\n#ifndef NDEBUG\n/* \n** Turn parser tracing on by giving a stream to which to write the trace\n** and a prompt to preface each trace message.  Tracing is turned off\n** by making either argument NULL \n**\n** Inputs:\n** <ul>\n** <li> A FILE* to which trace output should be written.\n**      If NULL, then tracing is turned off.\n** <li> A prefix string written at the beginning of every\n**      line of trace output.  If NULL, then tracing is\n**      turned off.\n** </ul>\n**\n** Outputs:\n** None.\n*/\nstatic void sqlite3Fts5ParserTrace(FILE *TraceFILE, char *zTracePrompt){\n  fts5yyTraceFILE = TraceFILE;\n  fts5yyTracePrompt = zTracePrompt;\n  if( fts5yyTraceFILE==0 ) fts5yyTracePrompt = 0;\n  else if( fts5yyTracePrompt==0 ) fts5yyTraceFILE = 0;\n}\n#endif /* NDEBUG */\n\n#if defined(fts5YYCOVERAGE) || !defined(NDEBUG)\n/* For tracing shifts, the names of all terminals and nonterminals\n** are required.  The following table supplies these names */\nstatic const char *const fts5yyTokenName[] = { \n  /*    0 */ \"$\",\n  /*    1 */ \"OR\",\n  /*    2 */ \"AND\",\n  /*    3 */ \"NOT\",\n  /*    4 */ \"TERM\",\n  /*    5 */ \"COLON\",\n  /*    6 */ \"MINUS\",\n  /*    7 */ \"LCP\",\n  /*    8 */ \"RCP\",\n  /*    9 */ \"STRING\",\n  /*   10 */ \"LP\",\n  /*   11 */ \"RP\",\n  /*   12 */ \"CARET\",\n  /*   13 */ \"COMMA\",\n  /*   14 */ \"PLUS\",\n  /*   15 */ \"STAR\",\n  /*   16 */ \"input\",\n  /*   17 */ \"expr\",\n  /*   18 */ \"cnearset\",\n  /*   19 */ \"exprlist\",\n  /*   20 */ \"colset\",\n  /*   21 */ \"colsetlist\",\n  /*   22 */ \"nearset\",\n  /*   23 */ \"nearphrases\",\n  /*   24 */ \"phrase\",\n  /*   25 */ \"neardist_opt\",\n  /*   26 */ \"star_opt\",\n};\n#endif /* defined(fts5YYCOVERAGE) || !defined(NDEBUG) */\n\n#ifndef NDEBUG\n/* For tracing reduce actions, the names of all rules are required.\n*/\nstatic const char *const fts5yyRuleName[] = {\n /*   0 */ \"input ::= expr\",\n /*   1 */ \"colset ::= MINUS LCP colsetlist RCP\",\n /*   2 */ \"colset ::= LCP colsetlist RCP\",\n /*   3 */ \"colset ::= STRING\",\n /*   4 */ \"colset ::= MINUS STRING\",\n /*   5 */ \"colsetlist ::= colsetlist STRING\",\n /*   6 */ \"colsetlist ::= STRING\",\n /*   7 */ \"expr ::= expr AND expr\",\n /*   8 */ \"expr ::= expr OR expr\",\n /*   9 */ \"expr ::= expr NOT expr\",\n /*  10 */ \"expr ::= colset COLON LP expr RP\",\n /*  11 */ \"expr ::= LP expr RP\",\n /*  12 */ \"expr ::= exprlist\",\n /*  13 */ \"exprlist ::= cnearset\",\n /*  14 */ \"exprlist ::= exprlist cnearset\",\n /*  15 */ \"cnearset ::= nearset\",\n /*  16 */ \"cnearset ::= colset COLON nearset\",\n /*  17 */ \"nearset ::= phrase\",\n /*  18 */ \"nearset ::= CARET phrase\",\n /*  19 */ \"nearset ::= STRING LP nearphrases neardist_opt RP\",\n /*  20 */ \"nearphrases ::= phrase\",\n /*  21 */ \"nearphrases ::= nearphrases phrase\",\n /*  22 */ \"neardist_opt ::=\",\n /*  23 */ \"neardist_opt ::= COMMA STRING\",\n /*  24 */ \"phrase ::= phrase PLUS STRING star_opt\",\n /*  25 */ \"phrase ::= STRING star_opt\",\n /*  26 */ \"star_opt ::= STAR\",\n /*  27 */ \"star_opt ::=\",\n};\n#endif /* NDEBUG */\n\n\n#if fts5YYSTACKDEPTH<=0\n/*\n** Try to increase the size of the parser stack.  Return the number\n** of errors.  Return 0 on success.\n*/\nstatic int fts5yyGrowStack(fts5yyParser *p){\n  int newSize;\n  int idx;\n  fts5yyStackEntry *pNew;\n\n  newSize = p->fts5yystksz*2 + 100;\n  idx = p->fts5yytos ? (int)(p->fts5yytos - p->fts5yystack) : 0;\n  if( p->fts5yystack==&p->fts5yystk0 ){\n    pNew = malloc(newSize*sizeof(pNew[0]));\n    if( pNew ) pNew[0] = p->fts5yystk0;\n  }else{\n    pNew = realloc(p->fts5yystack, newSize*sizeof(pNew[0]));\n  }\n  if( pNew ){\n    p->fts5yystack = pNew;\n    p->fts5yytos = &p->fts5yystack[idx];\n#ifndef NDEBUG\n    if( fts5yyTraceFILE ){\n      fprintf(fts5yyTraceFILE,\"%sStack grows from %d to %d entries.\\n\",\n              fts5yyTracePrompt, p->fts5yystksz, newSize);\n    }\n#endif\n    p->fts5yystksz = newSize;\n  }\n  return pNew==0; \n}\n#endif\n\n/* Datatype of the argument to the memory allocated passed as the\n** second argument to sqlite3Fts5ParserAlloc() below.  This can be changed by\n** putting an appropriate #define in the %include section of the input\n** grammar.\n*/\n#ifndef fts5YYMALLOCARGTYPE\n# define fts5YYMALLOCARGTYPE size_t\n#endif\n\n/* Initialize a new parser that has already been allocated.\n*/\nstatic void sqlite3Fts5ParserInit(void *fts5yypRawParser sqlite3Fts5ParserCTX_PDECL){\n  fts5yyParser *fts5yypParser = (fts5yyParser*)fts5yypRawParser;\n  sqlite3Fts5ParserCTX_STORE\n#ifdef fts5YYTRACKMAXSTACKDEPTH\n  fts5yypParser->fts5yyhwm = 0;\n#endif\n#if fts5YYSTACKDEPTH<=0\n  fts5yypParser->fts5yytos = NULL;\n  fts5yypParser->fts5yystack = NULL;\n  fts5yypParser->fts5yystksz = 0;\n  if( fts5yyGrowStack(fts5yypParser) ){\n    fts5yypParser->fts5yystack = &fts5yypParser->fts5yystk0;\n    fts5yypParser->fts5yystksz = 1;\n  }\n#endif\n#ifndef fts5YYNOERRORRECOVERY\n  fts5yypParser->fts5yyerrcnt = -1;\n#endif\n  fts5yypParser->fts5yytos = fts5yypParser->fts5yystack;\n  fts5yypParser->fts5yystack[0].stateno = 0;\n  fts5yypParser->fts5yystack[0].major = 0;\n#if fts5YYSTACKDEPTH>0\n  fts5yypParser->fts5yystackEnd = &fts5yypParser->fts5yystack[fts5YYSTACKDEPTH-1];\n#endif\n}\n\n#ifndef sqlite3Fts5Parser_ENGINEALWAYSONSTACK\n/* \n** This function allocates a new parser.\n** The only argument is a pointer to a function which works like\n** malloc.\n**\n** Inputs:\n** A pointer to the function used to allocate memory.\n**\n** Outputs:\n** A pointer to a parser.  This pointer is used in subsequent calls\n** to sqlite3Fts5Parser and sqlite3Fts5ParserFree.\n*/\nstatic void *sqlite3Fts5ParserAlloc(void *(*mallocProc)(fts5YYMALLOCARGTYPE) sqlite3Fts5ParserCTX_PDECL){\n  fts5yyParser *fts5yypParser;\n  fts5yypParser = (fts5yyParser*)(*mallocProc)( (fts5YYMALLOCARGTYPE)sizeof(fts5yyParser) );\n  if( fts5yypParser ){\n    sqlite3Fts5ParserCTX_STORE\n    sqlite3Fts5ParserInit(fts5yypParser sqlite3Fts5ParserCTX_PARAM);\n  }\n  return (void*)fts5yypParser;\n}\n#endif /* sqlite3Fts5Parser_ENGINEALWAYSONSTACK */\n\n\n/* The following function deletes the \"minor type\" or semantic value\n** associated with a symbol.  The symbol can be either a terminal\n** or nonterminal. \"fts5yymajor\" is the symbol code, and \"fts5yypminor\" is\n** a pointer to the value to be deleted.  The code used to do the \n** deletions is derived from the %destructor and/or %token_destructor\n** directives of the input grammar.\n*/\nstatic void fts5yy_destructor(\n  fts5yyParser *fts5yypParser,    /* The parser */\n  fts5YYCODETYPE fts5yymajor,     /* Type code for object to destroy */\n  fts5YYMINORTYPE *fts5yypminor   /* The object to be destroyed */\n){\n  sqlite3Fts5ParserARG_FETCH\n  sqlite3Fts5ParserCTX_FETCH\n  switch( fts5yymajor ){\n    /* Here is inserted the actions which take place when a\n    ** terminal or non-terminal is destroyed.  This can happen\n    ** when the symbol is popped from the stack during a\n    ** reduce or during error processing or when a parser is \n    ** being destroyed before it is finished parsing.\n    **\n    ** Note: during a reduce, the only symbols destroyed are those\n    ** which appear on the RHS of the rule, but which are *not* used\n    ** inside the C code.\n    */\n/********* Begin destructor definitions ***************************************/\n    case 16: /* input */\n{\n (void)pParse; \n}\n      break;\n    case 17: /* expr */\n    case 18: /* cnearset */\n    case 19: /* exprlist */\n{\n sqlite3Fts5ParseNodeFree((fts5yypminor->fts5yy24)); \n}\n      break;\n    case 20: /* colset */\n    case 21: /* colsetlist */\n{\n sqlite3_free((fts5yypminor->fts5yy11)); \n}\n      break;\n    case 22: /* nearset */\n    case 23: /* nearphrases */\n{\n sqlite3Fts5ParseNearsetFree((fts5yypminor->fts5yy46)); \n}\n      break;\n    case 24: /* phrase */\n{\n sqlite3Fts5ParsePhraseFree((fts5yypminor->fts5yy53)); \n}\n      break;\n/********* End destructor definitions *****************************************/\n    default:  break;   /* If no destructor action specified: do nothing */\n  }\n}\n\n/*\n** Pop the parser's stack once.\n**\n** If there is a destructor routine associated with the token which\n** is popped from the stack, then call it.\n*/\nstatic void fts5yy_pop_parser_stack(fts5yyParser *pParser){\n  fts5yyStackEntry *fts5yytos;\n  assert( pParser->fts5yytos!=0 );\n  assert( pParser->fts5yytos > pParser->fts5yystack );\n  fts5yytos = pParser->fts5yytos--;\n#ifndef NDEBUG\n  if( fts5yyTraceFILE ){\n    fprintf(fts5yyTraceFILE,\"%sPopping %s\\n\",\n      fts5yyTracePrompt,\n      fts5yyTokenName[fts5yytos->major]);\n  }\n#endif\n  fts5yy_destructor(pParser, fts5yytos->major, &fts5yytos->minor);\n}\n\n/*\n** Clear all secondary memory allocations from the parser\n*/\nstatic void sqlite3Fts5ParserFinalize(void *p){\n  fts5yyParser *pParser = (fts5yyParser*)p;\n  while( pParser->fts5yytos>pParser->fts5yystack ) fts5yy_pop_parser_stack(pParser);\n#if fts5YYSTACKDEPTH<=0\n  if( pParser->fts5yystack!=&pParser->fts5yystk0 ) free(pParser->fts5yystack);\n#endif\n}\n\n#ifndef sqlite3Fts5Parser_ENGINEALWAYSONSTACK\n/* \n** Deallocate and destroy a parser.  Destructors are called for\n** all stack elements before shutting the parser down.\n**\n** If the fts5YYPARSEFREENEVERNULL macro exists (for example because it\n** is defined in a %include section of the input grammar) then it is\n** assumed that the input pointer is never NULL.\n*/\nstatic void sqlite3Fts5ParserFree(\n  void *p,                    /* The parser to be deleted */\n  void (*freeProc)(void*)     /* Function used to reclaim memory */\n){\n#ifndef fts5YYPARSEFREENEVERNULL\n  if( p==0 ) return;\n#endif\n  sqlite3Fts5ParserFinalize(p);\n  (*freeProc)(p);\n}\n#endif /* sqlite3Fts5Parser_ENGINEALWAYSONSTACK */\n\n/*\n** Return the peak depth of the stack for a parser.\n*/\n#ifdef fts5YYTRACKMAXSTACKDEPTH\nstatic int sqlite3Fts5ParserStackPeak(void *p){\n  fts5yyParser *pParser = (fts5yyParser*)p;\n  return pParser->fts5yyhwm;\n}\n#endif\n\n/* This array of booleans keeps track of the parser statement\n** coverage.  The element fts5yycoverage[X][Y] is set when the parser\n** is in state X and has a lookahead token Y.  In a well-tested\n** systems, every element of this matrix should end up being set.\n*/\n#if defined(fts5YYCOVERAGE)\nstatic unsigned char fts5yycoverage[fts5YYNSTATE][fts5YYNFTS5TOKEN];\n#endif\n\n/*\n** Write into out a description of every state/lookahead combination that\n**\n**   (1)  has not been used by the parser, and\n**   (2)  is not a syntax error.\n**\n** Return the number of missed state/lookahead combinations.\n*/\n#if defined(fts5YYCOVERAGE)\nstatic int sqlite3Fts5ParserCoverage(FILE *out){\n  int stateno, iLookAhead, i;\n  int nMissed = 0;\n  for(stateno=0; stateno<fts5YYNSTATE; stateno++){\n    i = fts5yy_shift_ofst[stateno];\n    for(iLookAhead=0; iLookAhead<fts5YYNFTS5TOKEN; iLookAhead++){\n      if( fts5yy_lookahead[i+iLookAhead]!=iLookAhead ) continue;\n      if( fts5yycoverage[stateno][iLookAhead]==0 ) nMissed++;\n      if( out ){\n        fprintf(out,\"State %d lookahead %s %s\\n\", stateno,\n                fts5yyTokenName[iLookAhead],\n                fts5yycoverage[stateno][iLookAhead] ? \"ok\" : \"missed\");\n      }\n    }\n  }\n  return nMissed;\n}\n#endif\n\n/*\n** Find the appropriate action for a parser given the terminal\n** look-ahead token iLookAhead.\n*/\nstatic fts5YYACTIONTYPE fts5yy_find_shift_action(\n  fts5YYCODETYPE iLookAhead,    /* The look-ahead token */\n  fts5YYACTIONTYPE stateno      /* Current state number */\n){\n  int i;\n\n  if( stateno>fts5YY_MAX_SHIFT ) return stateno;\n  assert( stateno <= fts5YY_SHIFT_COUNT );\n#if defined(fts5YYCOVERAGE)\n  fts5yycoverage[stateno][iLookAhead] = 1;\n#endif\n  do{\n    i = fts5yy_shift_ofst[stateno];\n    assert( i>=0 );\n    /* assert( i+fts5YYNFTS5TOKEN<=(int)fts5YY_NLOOKAHEAD ); */\n    assert( iLookAhead!=fts5YYNOCODE );\n    assert( iLookAhead < fts5YYNFTS5TOKEN );\n    i += iLookAhead;\n    if( i>=fts5YY_NLOOKAHEAD || fts5yy_lookahead[i]!=iLookAhead ){\n#ifdef fts5YYFALLBACK\n      fts5YYCODETYPE iFallback;            /* Fallback token */\n      if( iLookAhead<sizeof(fts5yyFallback)/sizeof(fts5yyFallback[0])\n             && (iFallback = fts5yyFallback[iLookAhead])!=0 ){\n#ifndef NDEBUG\n        if( fts5yyTraceFILE ){\n          fprintf(fts5yyTraceFILE, \"%sFALLBACK %s => %s\\n\",\n             fts5yyTracePrompt, fts5yyTokenName[iLookAhead], fts5yyTokenName[iFallback]);\n        }\n#endif\n        assert( fts5yyFallback[iFallback]==0 ); /* Fallback loop must terminate */\n        iLookAhead = iFallback;\n        continue;\n      }\n#endif\n#ifdef fts5YYWILDCARD\n      {\n        int j = i - iLookAhead + fts5YYWILDCARD;\n        if( \n#if fts5YY_SHIFT_MIN+fts5YYWILDCARD<0\n          j>=0 &&\n#endif\n#if fts5YY_SHIFT_MAX+fts5YYWILDCARD>=fts5YY_ACTTAB_COUNT\n          j<fts5YY_ACTTAB_COUNT &&\n#endif\n          j<(int)(sizeof(fts5yy_lookahead)/sizeof(fts5yy_lookahead[0])) &&\n          fts5yy_lookahead[j]==fts5YYWILDCARD && iLookAhead>0\n        ){\n#ifndef NDEBUG\n          if( fts5yyTraceFILE ){\n            fprintf(fts5yyTraceFILE, \"%sWILDCARD %s => %s\\n\",\n               fts5yyTracePrompt, fts5yyTokenName[iLookAhead],\n               fts5yyTokenName[fts5YYWILDCARD]);\n          }\n#endif /* NDEBUG */\n          return fts5yy_action[j];\n        }\n      }\n#endif /* fts5YYWILDCARD */\n      return fts5yy_default[stateno];\n    }else{\n      return fts5yy_action[i];\n    }\n  }while(1);\n}\n\n/*\n** Find the appropriate action for a parser given the non-terminal\n** look-ahead token iLookAhead.\n*/\nstatic fts5YYACTIONTYPE fts5yy_find_reduce_action(\n  fts5YYACTIONTYPE stateno,     /* Current state number */\n  fts5YYCODETYPE iLookAhead     /* The look-ahead token */\n){\n  int i;\n#ifdef fts5YYERRORSYMBOL\n  if( stateno>fts5YY_REDUCE_COUNT ){\n    return fts5yy_default[stateno];\n  }\n#else\n  assert( stateno<=fts5YY_REDUCE_COUNT );\n#endif\n  i = fts5yy_reduce_ofst[stateno];\n  assert( iLookAhead!=fts5YYNOCODE );\n  i += iLookAhead;\n#ifdef fts5YYERRORSYMBOL\n  if( i<0 || i>=fts5YY_ACTTAB_COUNT || fts5yy_lookahead[i]!=iLookAhead ){\n    return fts5yy_default[stateno];\n  }\n#else\n  assert( i>=0 && i<fts5YY_ACTTAB_COUNT );\n  assert( fts5yy_lookahead[i]==iLookAhead );\n#endif\n  return fts5yy_action[i];\n}\n\n/*\n** The following routine is called if the stack overflows.\n*/\nstatic void fts5yyStackOverflow(fts5yyParser *fts5yypParser){\n   sqlite3Fts5ParserARG_FETCH\n   sqlite3Fts5ParserCTX_FETCH\n#ifndef NDEBUG\n   if( fts5yyTraceFILE ){\n     fprintf(fts5yyTraceFILE,\"%sStack Overflow!\\n\",fts5yyTracePrompt);\n   }\n#endif\n   while( fts5yypParser->fts5yytos>fts5yypParser->fts5yystack ) fts5yy_pop_parser_stack(fts5yypParser);\n   /* Here code is inserted which will execute if the parser\n   ** stack every overflows */\n/******** Begin %stack_overflow code ******************************************/\n\n  sqlite3Fts5ParseError(pParse, \"fts5: parser stack overflow\");\n/******** End %stack_overflow code ********************************************/\n   sqlite3Fts5ParserARG_STORE /* Suppress warning about unused %extra_argument var */\n   sqlite3Fts5ParserCTX_STORE\n}\n\n/*\n** Print tracing information for a SHIFT action\n*/\n#ifndef NDEBUG\nstatic void fts5yyTraceShift(fts5yyParser *fts5yypParser, int fts5yyNewState, const char *zTag){\n  if( fts5yyTraceFILE ){\n    if( fts5yyNewState<fts5YYNSTATE ){\n      fprintf(fts5yyTraceFILE,\"%s%s '%s', go to state %d\\n\",\n         fts5yyTracePrompt, zTag, fts5yyTokenName[fts5yypParser->fts5yytos->major],\n         fts5yyNewState);\n    }else{\n      fprintf(fts5yyTraceFILE,\"%s%s '%s', pending reduce %d\\n\",\n         fts5yyTracePrompt, zTag, fts5yyTokenName[fts5yypParser->fts5yytos->major],\n         fts5yyNewState - fts5YY_MIN_REDUCE);\n    }\n  }\n}\n#else\n# define fts5yyTraceShift(X,Y,Z)\n#endif\n\n/*\n** Perform a shift action.\n*/\nstatic void fts5yy_shift(\n  fts5yyParser *fts5yypParser,          /* The parser to be shifted */\n  fts5YYACTIONTYPE fts5yyNewState,      /* The new state to shift in */\n  fts5YYCODETYPE fts5yyMajor,           /* The major token to shift in */\n  sqlite3Fts5ParserFTS5TOKENTYPE fts5yyMinor        /* The minor token to shift in */\n){\n  fts5yyStackEntry *fts5yytos;\n  fts5yypParser->fts5yytos++;\n#ifdef fts5YYTRACKMAXSTACKDEPTH\n  if( (int)(fts5yypParser->fts5yytos - fts5yypParser->fts5yystack)>fts5yypParser->fts5yyhwm ){\n    fts5yypParser->fts5yyhwm++;\n    assert( fts5yypParser->fts5yyhwm == (int)(fts5yypParser->fts5yytos - fts5yypParser->fts5yystack) );\n  }\n#endif\n#if fts5YYSTACKDEPTH>0 \n  if( fts5yypParser->fts5yytos>fts5yypParser->fts5yystackEnd ){\n    fts5yypParser->fts5yytos--;\n    fts5yyStackOverflow(fts5yypParser);\n    return;\n  }\n#else\n  if( fts5yypParser->fts5yytos>=&fts5yypParser->fts5yystack[fts5yypParser->fts5yystksz] ){\n    if( fts5yyGrowStack(fts5yypParser) ){\n      fts5yypParser->fts5yytos--;\n      fts5yyStackOverflow(fts5yypParser);\n      return;\n    }\n  }\n#endif\n  if( fts5yyNewState > fts5YY_MAX_SHIFT ){\n    fts5yyNewState += fts5YY_MIN_REDUCE - fts5YY_MIN_SHIFTREDUCE;\n  }\n  fts5yytos = fts5yypParser->fts5yytos;\n  fts5yytos->stateno = fts5yyNewState;\n  fts5yytos->major = fts5yyMajor;\n  fts5yytos->minor.fts5yy0 = fts5yyMinor;\n  fts5yyTraceShift(fts5yypParser, fts5yyNewState, \"Shift\");\n}\n\n/* For rule J, fts5yyRuleInfoLhs[J] contains the symbol on the left-hand side\n** of that rule */\nstatic const fts5YYCODETYPE fts5yyRuleInfoLhs[] = {\n    16,  /* (0) input ::= expr */\n    20,  /* (1) colset ::= MINUS LCP colsetlist RCP */\n    20,  /* (2) colset ::= LCP colsetlist RCP */\n    20,  /* (3) colset ::= STRING */\n    20,  /* (4) colset ::= MINUS STRING */\n    21,  /* (5) colsetlist ::= colsetlist STRING */\n    21,  /* (6) colsetlist ::= STRING */\n    17,  /* (7) expr ::= expr AND expr */\n    17,  /* (8) expr ::= expr OR expr */\n    17,  /* (9) expr ::= expr NOT expr */\n    17,  /* (10) expr ::= colset COLON LP expr RP */\n    17,  /* (11) expr ::= LP expr RP */\n    17,  /* (12) expr ::= exprlist */\n    19,  /* (13) exprlist ::= cnearset */\n    19,  /* (14) exprlist ::= exprlist cnearset */\n    18,  /* (15) cnearset ::= nearset */\n    18,  /* (16) cnearset ::= colset COLON nearset */\n    22,  /* (17) nearset ::= phrase */\n    22,  /* (18) nearset ::= CARET phrase */\n    22,  /* (19) nearset ::= STRING LP nearphrases neardist_opt RP */\n    23,  /* (20) nearphrases ::= phrase */\n    23,  /* (21) nearphrases ::= nearphrases phrase */\n    25,  /* (22) neardist_opt ::= */\n    25,  /* (23) neardist_opt ::= COMMA STRING */\n    24,  /* (24) phrase ::= phrase PLUS STRING star_opt */\n    24,  /* (25) phrase ::= STRING star_opt */\n    26,  /* (26) star_opt ::= STAR */\n    26,  /* (27) star_opt ::= */\n};\n\n/* For rule J, fts5yyRuleInfoNRhs[J] contains the negative of the number\n** of symbols on the right-hand side of that rule. */\nstatic const signed char fts5yyRuleInfoNRhs[] = {\n   -1,  /* (0) input ::= expr */\n   -4,  /* (1) colset ::= MINUS LCP colsetlist RCP */\n   -3,  /* (2) colset ::= LCP colsetlist RCP */\n   -1,  /* (3) colset ::= STRING */\n   -2,  /* (4) colset ::= MINUS STRING */\n   -2,  /* (5) colsetlist ::= colsetlist STRING */\n   -1,  /* (6) colsetlist ::= STRING */\n   -3,  /* (7) expr ::= expr AND expr */\n   -3,  /* (8) expr ::= expr OR expr */\n   -3,  /* (9) expr ::= expr NOT expr */\n   -5,  /* (10) expr ::= colset COLON LP expr RP */\n   -3,  /* (11) expr ::= LP expr RP */\n   -1,  /* (12) expr ::= exprlist */\n   -1,  /* (13) exprlist ::= cnearset */\n   -2,  /* (14) exprlist ::= exprlist cnearset */\n   -1,  /* (15) cnearset ::= nearset */\n   -3,  /* (16) cnearset ::= colset COLON nearset */\n   -1,  /* (17) nearset ::= phrase */\n   -2,  /* (18) nearset ::= CARET phrase */\n   -5,  /* (19) nearset ::= STRING LP nearphrases neardist_opt RP */\n   -1,  /* (20) nearphrases ::= phrase */\n   -2,  /* (21) nearphrases ::= nearphrases phrase */\n    0,  /* (22) neardist_opt ::= */\n   -2,  /* (23) neardist_opt ::= COMMA STRING */\n   -4,  /* (24) phrase ::= phrase PLUS STRING star_opt */\n   -2,  /* (25) phrase ::= STRING star_opt */\n   -1,  /* (26) star_opt ::= STAR */\n    0,  /* (27) star_opt ::= */\n};\n\nstatic void fts5yy_accept(fts5yyParser*);  /* Forward Declaration */\n\n/*\n** Perform a reduce action and the shift that must immediately\n** follow the reduce.\n**\n** The fts5yyLookahead and fts5yyLookaheadToken parameters provide reduce actions\n** access to the lookahead token (if any).  The fts5yyLookahead will be fts5YYNOCODE\n** if the lookahead token has already been consumed.  As this procedure is\n** only called from one place, optimizing compilers will in-line it, which\n** means that the extra parameters have no performance impact.\n*/\nstatic fts5YYACTIONTYPE fts5yy_reduce(\n  fts5yyParser *fts5yypParser,         /* The parser */\n  unsigned int fts5yyruleno,       /* Number of the rule by which to reduce */\n  int fts5yyLookahead,             /* Lookahead token, or fts5YYNOCODE if none */\n  sqlite3Fts5ParserFTS5TOKENTYPE fts5yyLookaheadToken  /* Value of the lookahead token */\n  sqlite3Fts5ParserCTX_PDECL                   /* %extra_context */\n){\n  int fts5yygoto;                     /* The next state */\n  fts5YYACTIONTYPE fts5yyact;             /* The next action */\n  fts5yyStackEntry *fts5yymsp;            /* The top of the parser's stack */\n  int fts5yysize;                     /* Amount to pop the stack */\n  sqlite3Fts5ParserARG_FETCH\n  (void)fts5yyLookahead;\n  (void)fts5yyLookaheadToken;\n  fts5yymsp = fts5yypParser->fts5yytos;\n#ifndef NDEBUG\n  if( fts5yyTraceFILE && fts5yyruleno<(int)(sizeof(fts5yyRuleName)/sizeof(fts5yyRuleName[0])) ){\n    fts5yysize = fts5yyRuleInfoNRhs[fts5yyruleno];\n    if( fts5yysize ){\n      fprintf(fts5yyTraceFILE, \"%sReduce %d [%s], go to state %d.\\n\",\n        fts5yyTracePrompt,\n        fts5yyruleno, fts5yyRuleName[fts5yyruleno], fts5yymsp[fts5yysize].stateno);\n    }else{\n      fprintf(fts5yyTraceFILE, \"%sReduce %d [%s].\\n\",\n        fts5yyTracePrompt, fts5yyruleno, fts5yyRuleName[fts5yyruleno]);\n    }\n  }\n#endif /* NDEBUG */\n\n  /* Check that the stack is large enough to grow by a single entry\n  ** if the RHS of the rule is empty.  This ensures that there is room\n  ** enough on the stack to push the LHS value */\n  if( fts5yyRuleInfoNRhs[fts5yyruleno]==0 ){\n#ifdef fts5YYTRACKMAXSTACKDEPTH\n    if( (int)(fts5yypParser->fts5yytos - fts5yypParser->fts5yystack)>fts5yypParser->fts5yyhwm ){\n      fts5yypParser->fts5yyhwm++;\n      assert( fts5yypParser->fts5yyhwm == (int)(fts5yypParser->fts5yytos - fts5yypParser->fts5yystack));\n    }\n#endif\n#if fts5YYSTACKDEPTH>0 \n    if( fts5yypParser->fts5yytos>=fts5yypParser->fts5yystackEnd ){\n      fts5yyStackOverflow(fts5yypParser);\n      /* The call to fts5yyStackOverflow() above pops the stack until it is\n      ** empty, causing the main parser loop to exit.  So the return value\n      ** is never used and does not matter. */\n      return 0;\n    }\n#else\n    if( fts5yypParser->fts5yytos>=&fts5yypParser->fts5yystack[fts5yypParser->fts5yystksz-1] ){\n      if( fts5yyGrowStack(fts5yypParser) ){\n        fts5yyStackOverflow(fts5yypParser);\n        /* The call to fts5yyStackOverflow() above pops the stack until it is\n        ** empty, causing the main parser loop to exit.  So the return value\n        ** is never used and does not matter. */\n        return 0;\n      }\n      fts5yymsp = fts5yypParser->fts5yytos;\n    }\n#endif\n  }\n\n  switch( fts5yyruleno ){\n  /* Beginning here are the reduction cases.  A typical example\n  ** follows:\n  **   case 0:\n  **  #line <lineno> <grammarfile>\n  **     { ... }           // User supplied code\n  **  #line <lineno> <thisfile>\n  **     break;\n  */\n/********** Begin reduce actions **********************************************/\n        fts5YYMINORTYPE fts5yylhsminor;\n      case 0: /* input ::= expr */\n{ sqlite3Fts5ParseFinished(pParse, fts5yymsp[0].minor.fts5yy24); }\n        break;\n      case 1: /* colset ::= MINUS LCP colsetlist RCP */\n{ \n    fts5yymsp[-3].minor.fts5yy11 = sqlite3Fts5ParseColsetInvert(pParse, fts5yymsp[-1].minor.fts5yy11);\n}\n        break;\n      case 2: /* colset ::= LCP colsetlist RCP */\n{ fts5yymsp[-2].minor.fts5yy11 = fts5yymsp[-1].minor.fts5yy11; }\n        break;\n      case 3: /* colset ::= STRING */\n{\n  fts5yylhsminor.fts5yy11 = sqlite3Fts5ParseColset(pParse, 0, &fts5yymsp[0].minor.fts5yy0);\n}\n  fts5yymsp[0].minor.fts5yy11 = fts5yylhsminor.fts5yy11;\n        break;\n      case 4: /* colset ::= MINUS STRING */\n{\n  fts5yymsp[-1].minor.fts5yy11 = sqlite3Fts5ParseColset(pParse, 0, &fts5yymsp[0].minor.fts5yy0);\n  fts5yymsp[-1].minor.fts5yy11 = sqlite3Fts5ParseColsetInvert(pParse, fts5yymsp[-1].minor.fts5yy11);\n}\n        break;\n      case 5: /* colsetlist ::= colsetlist STRING */\n{ \n  fts5yylhsminor.fts5yy11 = sqlite3Fts5ParseColset(pParse, fts5yymsp[-1].minor.fts5yy11, &fts5yymsp[0].minor.fts5yy0); }\n  fts5yymsp[-1].minor.fts5yy11 = fts5yylhsminor.fts5yy11;\n        break;\n      case 6: /* colsetlist ::= STRING */\n{ \n  fts5yylhsminor.fts5yy11 = sqlite3Fts5ParseColset(pParse, 0, &fts5yymsp[0].minor.fts5yy0); \n}\n  fts5yymsp[0].minor.fts5yy11 = fts5yylhsminor.fts5yy11;\n        break;\n      case 7: /* expr ::= expr AND expr */\n{\n  fts5yylhsminor.fts5yy24 = sqlite3Fts5ParseNode(pParse, FTS5_AND, fts5yymsp[-2].minor.fts5yy24, fts5yymsp[0].minor.fts5yy24, 0);\n}\n  fts5yymsp[-2].minor.fts5yy24 = fts5yylhsminor.fts5yy24;\n        break;\n      case 8: /* expr ::= expr OR expr */\n{\n  fts5yylhsminor.fts5yy24 = sqlite3Fts5ParseNode(pParse, FTS5_OR, fts5yymsp[-2].minor.fts5yy24, fts5yymsp[0].minor.fts5yy24, 0);\n}\n  fts5yymsp[-2].minor.fts5yy24 = fts5yylhsminor.fts5yy24;\n        break;\n      case 9: /* expr ::= expr NOT expr */\n{\n  fts5yylhsminor.fts5yy24 = sqlite3Fts5ParseNode(pParse, FTS5_NOT, fts5yymsp[-2].minor.fts5yy24, fts5yymsp[0].minor.fts5yy24, 0);\n}\n  fts5yymsp[-2].minor.fts5yy24 = fts5yylhsminor.fts5yy24;\n        break;\n      case 10: /* expr ::= colset COLON LP expr RP */\n{\n  sqlite3Fts5ParseSetColset(pParse, fts5yymsp[-1].minor.fts5yy24, fts5yymsp[-4].minor.fts5yy11);\n  fts5yylhsminor.fts5yy24 = fts5yymsp[-1].minor.fts5yy24;\n}\n  fts5yymsp[-4].minor.fts5yy24 = fts5yylhsminor.fts5yy24;\n        break;\n      case 11: /* expr ::= LP expr RP */\n{fts5yymsp[-2].minor.fts5yy24 = fts5yymsp[-1].minor.fts5yy24;}\n        break;\n      case 12: /* expr ::= exprlist */\n      case 13: /* exprlist ::= cnearset */ fts5yytestcase(fts5yyruleno==13);\n{fts5yylhsminor.fts5yy24 = fts5yymsp[0].minor.fts5yy24;}\n  fts5yymsp[0].minor.fts5yy24 = fts5yylhsminor.fts5yy24;\n        break;\n      case 14: /* exprlist ::= exprlist cnearset */\n{\n  fts5yylhsminor.fts5yy24 = sqlite3Fts5ParseImplicitAnd(pParse, fts5yymsp[-1].minor.fts5yy24, fts5yymsp[0].minor.fts5yy24);\n}\n  fts5yymsp[-1].minor.fts5yy24 = fts5yylhsminor.fts5yy24;\n        break;\n      case 15: /* cnearset ::= nearset */\n{ \n  fts5yylhsminor.fts5yy24 = sqlite3Fts5ParseNode(pParse, FTS5_STRING, 0, 0, fts5yymsp[0].minor.fts5yy46); \n}\n  fts5yymsp[0].minor.fts5yy24 = fts5yylhsminor.fts5yy24;\n        break;\n      case 16: /* cnearset ::= colset COLON nearset */\n{ \n  fts5yylhsminor.fts5yy24 = sqlite3Fts5ParseNode(pParse, FTS5_STRING, 0, 0, fts5yymsp[0].minor.fts5yy46); \n  sqlite3Fts5ParseSetColset(pParse, fts5yylhsminor.fts5yy24, fts5yymsp[-2].minor.fts5yy11);\n}\n  fts5yymsp[-2].minor.fts5yy24 = fts5yylhsminor.fts5yy24;\n        break;\n      case 17: /* nearset ::= phrase */\n{ fts5yylhsminor.fts5yy46 = sqlite3Fts5ParseNearset(pParse, 0, fts5yymsp[0].minor.fts5yy53); }\n  fts5yymsp[0].minor.fts5yy46 = fts5yylhsminor.fts5yy46;\n        break;\n      case 18: /* nearset ::= CARET phrase */\n{ \n  sqlite3Fts5ParseSetCaret(fts5yymsp[0].minor.fts5yy53);\n  fts5yymsp[-1].minor.fts5yy46 = sqlite3Fts5ParseNearset(pParse, 0, fts5yymsp[0].minor.fts5yy53); \n}\n        break;\n      case 19: /* nearset ::= STRING LP nearphrases neardist_opt RP */\n{\n  sqlite3Fts5ParseNear(pParse, &fts5yymsp[-4].minor.fts5yy0);\n  sqlite3Fts5ParseSetDistance(pParse, fts5yymsp[-2].minor.fts5yy46, &fts5yymsp[-1].minor.fts5yy0);\n  fts5yylhsminor.fts5yy46 = fts5yymsp[-2].minor.fts5yy46;\n}\n  fts5yymsp[-4].minor.fts5yy46 = fts5yylhsminor.fts5yy46;\n        break;\n      case 20: /* nearphrases ::= phrase */\n{ \n  fts5yylhsminor.fts5yy46 = sqlite3Fts5ParseNearset(pParse, 0, fts5yymsp[0].minor.fts5yy53); \n}\n  fts5yymsp[0].minor.fts5yy46 = fts5yylhsminor.fts5yy46;\n        break;\n      case 21: /* nearphrases ::= nearphrases phrase */\n{\n  fts5yylhsminor.fts5yy46 = sqlite3Fts5ParseNearset(pParse, fts5yymsp[-1].minor.fts5yy46, fts5yymsp[0].minor.fts5yy53);\n}\n  fts5yymsp[-1].minor.fts5yy46 = fts5yylhsminor.fts5yy46;\n        break;\n      case 22: /* neardist_opt ::= */\n{ fts5yymsp[1].minor.fts5yy0.p = 0; fts5yymsp[1].minor.fts5yy0.n = 0; }\n        break;\n      case 23: /* neardist_opt ::= COMMA STRING */\n{ fts5yymsp[-1].minor.fts5yy0 = fts5yymsp[0].minor.fts5yy0; }\n        break;\n      case 24: /* phrase ::= phrase PLUS STRING star_opt */\n{ \n  fts5yylhsminor.fts5yy53 = sqlite3Fts5ParseTerm(pParse, fts5yymsp[-3].minor.fts5yy53, &fts5yymsp[-1].minor.fts5yy0, fts5yymsp[0].minor.fts5yy4);\n}\n  fts5yymsp[-3].minor.fts5yy53 = fts5yylhsminor.fts5yy53;\n        break;\n      case 25: /* phrase ::= STRING star_opt */\n{ \n  fts5yylhsminor.fts5yy53 = sqlite3Fts5ParseTerm(pParse, 0, &fts5yymsp[-1].minor.fts5yy0, fts5yymsp[0].minor.fts5yy4);\n}\n  fts5yymsp[-1].minor.fts5yy53 = fts5yylhsminor.fts5yy53;\n        break;\n      case 26: /* star_opt ::= STAR */\n{ fts5yymsp[0].minor.fts5yy4 = 1; }\n        break;\n      case 27: /* star_opt ::= */\n{ fts5yymsp[1].minor.fts5yy4 = 0; }\n        break;\n      default:\n        break;\n/********** End reduce actions ************************************************/\n  };\n  assert( fts5yyruleno<sizeof(fts5yyRuleInfoLhs)/sizeof(fts5yyRuleInfoLhs[0]) );\n  fts5yygoto = fts5yyRuleInfoLhs[fts5yyruleno];\n  fts5yysize = fts5yyRuleInfoNRhs[fts5yyruleno];\n  fts5yyact = fts5yy_find_reduce_action(fts5yymsp[fts5yysize].stateno,(fts5YYCODETYPE)fts5yygoto);\n\n  /* There are no SHIFTREDUCE actions on nonterminals because the table\n  ** generator has simplified them to pure REDUCE actions. */\n  assert( !(fts5yyact>fts5YY_MAX_SHIFT && fts5yyact<=fts5YY_MAX_SHIFTREDUCE) );\n\n  /* It is not possible for a REDUCE to be followed by an error */\n  assert( fts5yyact!=fts5YY_ERROR_ACTION );\n\n  fts5yymsp += fts5yysize+1;\n  fts5yypParser->fts5yytos = fts5yymsp;\n  fts5yymsp->stateno = (fts5YYACTIONTYPE)fts5yyact;\n  fts5yymsp->major = (fts5YYCODETYPE)fts5yygoto;\n  fts5yyTraceShift(fts5yypParser, fts5yyact, \"... then shift\");\n  return fts5yyact;\n}\n\n/*\n** The following code executes when the parse fails\n*/\n#ifndef fts5YYNOERRORRECOVERY\nstatic void fts5yy_parse_failed(\n  fts5yyParser *fts5yypParser           /* The parser */\n){\n  sqlite3Fts5ParserARG_FETCH\n  sqlite3Fts5ParserCTX_FETCH\n#ifndef NDEBUG\n  if( fts5yyTraceFILE ){\n    fprintf(fts5yyTraceFILE,\"%sFail!\\n\",fts5yyTracePrompt);\n  }\n#endif\n  while( fts5yypParser->fts5yytos>fts5yypParser->fts5yystack ) fts5yy_pop_parser_stack(fts5yypParser);\n  /* Here code is inserted which will be executed whenever the\n  ** parser fails */\n/************ Begin %parse_failure code ***************************************/\n/************ End %parse_failure code *****************************************/\n  sqlite3Fts5ParserARG_STORE /* Suppress warning about unused %extra_argument variable */\n  sqlite3Fts5ParserCTX_STORE\n}\n#endif /* fts5YYNOERRORRECOVERY */\n\n/*\n** The following code executes when a syntax error first occurs.\n*/\nstatic void fts5yy_syntax_error(\n  fts5yyParser *fts5yypParser,           /* The parser */\n  int fts5yymajor,                   /* The major type of the error token */\n  sqlite3Fts5ParserFTS5TOKENTYPE fts5yyminor         /* The minor type of the error token */\n){\n  sqlite3Fts5ParserARG_FETCH\n  sqlite3Fts5ParserCTX_FETCH\n#define FTS5TOKEN fts5yyminor\n/************ Begin %syntax_error code ****************************************/\n\n  UNUSED_PARAM(fts5yymajor); /* Silence a compiler warning */\n  sqlite3Fts5ParseError(\n    pParse, \"fts5: syntax error near \\\"%.*s\\\"\",FTS5TOKEN.n,FTS5TOKEN.p\n  );\n/************ End %syntax_error code ******************************************/\n  sqlite3Fts5ParserARG_STORE /* Suppress warning about unused %extra_argument variable */\n  sqlite3Fts5ParserCTX_STORE\n}\n\n/*\n** The following is executed when the parser accepts\n*/\nstatic void fts5yy_accept(\n  fts5yyParser *fts5yypParser           /* The parser */\n){\n  sqlite3Fts5ParserARG_FETCH\n  sqlite3Fts5ParserCTX_FETCH\n#ifndef NDEBUG\n  if( fts5yyTraceFILE ){\n    fprintf(fts5yyTraceFILE,\"%sAccept!\\n\",fts5yyTracePrompt);\n  }\n#endif\n#ifndef fts5YYNOERRORRECOVERY\n  fts5yypParser->fts5yyerrcnt = -1;\n#endif\n  assert( fts5yypParser->fts5yytos==fts5yypParser->fts5yystack );\n  /* Here code is inserted which will be executed whenever the\n  ** parser accepts */\n/*********** Begin %parse_accept code *****************************************/\n/*********** End %parse_accept code *******************************************/\n  sqlite3Fts5ParserARG_STORE /* Suppress warning about unused %extra_argument variable */\n  sqlite3Fts5ParserCTX_STORE\n}\n\n/* The main parser program.\n** The first argument is a pointer to a structure obtained from\n** \"sqlite3Fts5ParserAlloc\" which describes the current state of the parser.\n** The second argument is the major token number.  The third is\n** the minor token.  The fourth optional argument is whatever the\n** user wants (and specified in the grammar) and is available for\n** use by the action routines.\n**\n** Inputs:\n** <ul>\n** <li> A pointer to the parser (an opaque structure.)\n** <li> The major token number.\n** <li> The minor token number.\n** <li> An option argument of a grammar-specified type.\n** </ul>\n**\n** Outputs:\n** None.\n*/\nstatic void sqlite3Fts5Parser(\n  void *fts5yyp,                   /* The parser */\n  int fts5yymajor,                 /* The major token code number */\n  sqlite3Fts5ParserFTS5TOKENTYPE fts5yyminor       /* The value for the token */\n  sqlite3Fts5ParserARG_PDECL               /* Optional %extra_argument parameter */\n){\n  fts5YYMINORTYPE fts5yyminorunion;\n  fts5YYACTIONTYPE fts5yyact;   /* The parser action. */\n#if !defined(fts5YYERRORSYMBOL) && !defined(fts5YYNOERRORRECOVERY)\n  int fts5yyendofinput;     /* True if we are at the end of input */\n#endif\n#ifdef fts5YYERRORSYMBOL\n  int fts5yyerrorhit = 0;   /* True if fts5yymajor has invoked an error */\n#endif\n  fts5yyParser *fts5yypParser = (fts5yyParser*)fts5yyp;  /* The parser */\n  sqlite3Fts5ParserCTX_FETCH\n  sqlite3Fts5ParserARG_STORE\n\n  assert( fts5yypParser->fts5yytos!=0 );\n#if !defined(fts5YYERRORSYMBOL) && !defined(fts5YYNOERRORRECOVERY)\n  fts5yyendofinput = (fts5yymajor==0);\n#endif\n\n  fts5yyact = fts5yypParser->fts5yytos->stateno;\n#ifndef NDEBUG\n  if( fts5yyTraceFILE ){\n    if( fts5yyact < fts5YY_MIN_REDUCE ){\n      fprintf(fts5yyTraceFILE,\"%sInput '%s' in state %d\\n\",\n              fts5yyTracePrompt,fts5yyTokenName[fts5yymajor],fts5yyact);\n    }else{\n      fprintf(fts5yyTraceFILE,\"%sInput '%s' with pending reduce %d\\n\",\n              fts5yyTracePrompt,fts5yyTokenName[fts5yymajor],fts5yyact-fts5YY_MIN_REDUCE);\n    }\n  }\n#endif\n\n  do{\n    assert( fts5yyact==fts5yypParser->fts5yytos->stateno );\n    fts5yyact = fts5yy_find_shift_action((fts5YYCODETYPE)fts5yymajor,fts5yyact);\n    if( fts5yyact >= fts5YY_MIN_REDUCE ){\n      fts5yyact = fts5yy_reduce(fts5yypParser,fts5yyact-fts5YY_MIN_REDUCE,fts5yymajor,\n                        fts5yyminor sqlite3Fts5ParserCTX_PARAM);\n    }else if( fts5yyact <= fts5YY_MAX_SHIFTREDUCE ){\n      fts5yy_shift(fts5yypParser,fts5yyact,(fts5YYCODETYPE)fts5yymajor,fts5yyminor);\n#ifndef fts5YYNOERRORRECOVERY\n      fts5yypParser->fts5yyerrcnt--;\n#endif\n      break;\n    }else if( fts5yyact==fts5YY_ACCEPT_ACTION ){\n      fts5yypParser->fts5yytos--;\n      fts5yy_accept(fts5yypParser);\n      return;\n    }else{\n      assert( fts5yyact == fts5YY_ERROR_ACTION );\n      fts5yyminorunion.fts5yy0 = fts5yyminor;\n#ifdef fts5YYERRORSYMBOL\n      int fts5yymx;\n#endif\n#ifndef NDEBUG\n      if( fts5yyTraceFILE ){\n        fprintf(fts5yyTraceFILE,\"%sSyntax Error!\\n\",fts5yyTracePrompt);\n      }\n#endif\n#ifdef fts5YYERRORSYMBOL\n      /* A syntax error has occurred.\n      ** The response to an error depends upon whether or not the\n      ** grammar defines an error token \"ERROR\".  \n      **\n      ** This is what we do if the grammar does define ERROR:\n      **\n      **  * Call the %syntax_error function.\n      **\n      **  * Begin popping the stack until we enter a state where\n      **    it is legal to shift the error symbol, then shift\n      **    the error symbol.\n      **\n      **  * Set the error count to three.\n      **\n      **  * Begin accepting and shifting new tokens.  No new error\n      **    processing will occur until three tokens have been\n      **    shifted successfully.\n      **\n      */\n      if( fts5yypParser->fts5yyerrcnt<0 ){\n        fts5yy_syntax_error(fts5yypParser,fts5yymajor,fts5yyminor);\n      }\n      fts5yymx = fts5yypParser->fts5yytos->major;\n      if( fts5yymx==fts5YYERRORSYMBOL || fts5yyerrorhit ){\n#ifndef NDEBUG\n        if( fts5yyTraceFILE ){\n          fprintf(fts5yyTraceFILE,\"%sDiscard input token %s\\n\",\n             fts5yyTracePrompt,fts5yyTokenName[fts5yymajor]);\n        }\n#endif\n        fts5yy_destructor(fts5yypParser, (fts5YYCODETYPE)fts5yymajor, &fts5yyminorunion);\n        fts5yymajor = fts5YYNOCODE;\n      }else{\n        while( fts5yypParser->fts5yytos >= fts5yypParser->fts5yystack\n            && (fts5yyact = fts5yy_find_reduce_action(\n                        fts5yypParser->fts5yytos->stateno,\n                        fts5YYERRORSYMBOL)) > fts5YY_MAX_SHIFTREDUCE\n        ){\n          fts5yy_pop_parser_stack(fts5yypParser);\n        }\n        if( fts5yypParser->fts5yytos < fts5yypParser->fts5yystack || fts5yymajor==0 ){\n          fts5yy_destructor(fts5yypParser,(fts5YYCODETYPE)fts5yymajor,&fts5yyminorunion);\n          fts5yy_parse_failed(fts5yypParser);\n#ifndef fts5YYNOERRORRECOVERY\n          fts5yypParser->fts5yyerrcnt = -1;\n#endif\n          fts5yymajor = fts5YYNOCODE;\n        }else if( fts5yymx!=fts5YYERRORSYMBOL ){\n          fts5yy_shift(fts5yypParser,fts5yyact,fts5YYERRORSYMBOL,fts5yyminor);\n        }\n      }\n      fts5yypParser->fts5yyerrcnt = 3;\n      fts5yyerrorhit = 1;\n      if( fts5yymajor==fts5YYNOCODE ) break;\n      fts5yyact = fts5yypParser->fts5yytos->stateno;\n#elif defined(fts5YYNOERRORRECOVERY)\n      /* If the fts5YYNOERRORRECOVERY macro is defined, then do not attempt to\n      ** do any kind of error recovery.  Instead, simply invoke the syntax\n      ** error routine and continue going as if nothing had happened.\n      **\n      ** Applications can set this macro (for example inside %include) if\n      ** they intend to abandon the parse upon the first syntax error seen.\n      */\n      fts5yy_syntax_error(fts5yypParser,fts5yymajor, fts5yyminor);\n      fts5yy_destructor(fts5yypParser,(fts5YYCODETYPE)fts5yymajor,&fts5yyminorunion);\n      break;\n#else  /* fts5YYERRORSYMBOL is not defined */\n      /* This is what we do if the grammar does not define ERROR:\n      **\n      **  * Report an error message, and throw away the input token.\n      **\n      **  * If the input token is $, then fail the parse.\n      **\n      ** As before, subsequent error messages are suppressed until\n      ** three input tokens have been successfully shifted.\n      */\n      if( fts5yypParser->fts5yyerrcnt<=0 ){\n        fts5yy_syntax_error(fts5yypParser,fts5yymajor, fts5yyminor);\n      }\n      fts5yypParser->fts5yyerrcnt = 3;\n      fts5yy_destructor(fts5yypParser,(fts5YYCODETYPE)fts5yymajor,&fts5yyminorunion);\n      if( fts5yyendofinput ){\n        fts5yy_parse_failed(fts5yypParser);\n#ifndef fts5YYNOERRORRECOVERY\n        fts5yypParser->fts5yyerrcnt = -1;\n#endif\n      }\n      break;\n#endif\n    }\n  }while( fts5yypParser->fts5yytos>fts5yypParser->fts5yystack );\n#ifndef NDEBUG\n  if( fts5yyTraceFILE ){\n    fts5yyStackEntry *i;\n    char cDiv = '[';\n    fprintf(fts5yyTraceFILE,\"%sReturn. Stack=\",fts5yyTracePrompt);\n    for(i=&fts5yypParser->fts5yystack[1]; i<=fts5yypParser->fts5yytos; i++){\n      fprintf(fts5yyTraceFILE,\"%c%s\", cDiv, fts5yyTokenName[i->major]);\n      cDiv = ' ';\n    }\n    fprintf(fts5yyTraceFILE,\"]\\n\");\n  }\n#endif\n  return;\n}\n\n/*\n** Return the fallback token corresponding to canonical token iToken, or\n** 0 if iToken has no fallback.\n*/\nstatic int sqlite3Fts5ParserFallback(int iToken){\n#ifdef fts5YYFALLBACK\n  if( iToken<(int)(sizeof(fts5yyFallback)/sizeof(fts5yyFallback[0])) ){\n    return fts5yyFallback[iToken];\n  }\n#else\n  (void)iToken;\n#endif\n  return 0;\n}\n\n/*\n** 2014 May 31\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n******************************************************************************\n*/\n\n\n/* #include \"fts5Int.h\" */\n#include <math.h>                 /* amalgamator: keep */\n\n/*\n** Object used to iterate through all \"coalesced phrase instances\" in \n** a single column of the current row. If the phrase instances in the\n** column being considered do not overlap, this object simply iterates\n** through them. Or, if they do overlap (share one or more tokens in\n** common), each set of overlapping instances is treated as a single\n** match. See documentation for the highlight() auxiliary function for\n** details.\n**\n** Usage is:\n**\n**   for(rc = fts5CInstIterNext(pApi, pFts, iCol, &iter);\n**      (rc==SQLITE_OK && 0==fts5CInstIterEof(&iter);\n**      rc = fts5CInstIterNext(&iter)\n**   ){\n**     printf(\"instance starts at %d, ends at %d\\n\", iter.iStart, iter.iEnd);\n**   }\n**\n*/\ntypedef struct CInstIter CInstIter;\nstruct CInstIter {\n  const Fts5ExtensionApi *pApi;   /* API offered by current FTS version */\n  Fts5Context *pFts;              /* First arg to pass to pApi functions */\n  int iCol;                       /* Column to search */\n  int iInst;                      /* Next phrase instance index */\n  int nInst;                      /* Total number of phrase instances */\n\n  /* Output variables */\n  int iStart;                     /* First token in coalesced phrase instance */\n  int iEnd;                       /* Last token in coalesced phrase instance */\n};\n\n/*\n** Advance the iterator to the next coalesced phrase instance. Return\n** an SQLite error code if an error occurs, or SQLITE_OK otherwise.\n*/\nstatic int fts5CInstIterNext(CInstIter *pIter){\n  int rc = SQLITE_OK;\n  pIter->iStart = -1;\n  pIter->iEnd = -1;\n\n  while( rc==SQLITE_OK && pIter->iInst<pIter->nInst ){\n    int ip; int ic; int io;\n    rc = pIter->pApi->xInst(pIter->pFts, pIter->iInst, &ip, &ic, &io);\n    if( rc==SQLITE_OK ){\n      if( ic==pIter->iCol ){\n        int iEnd = io - 1 + pIter->pApi->xPhraseSize(pIter->pFts, ip);\n        if( pIter->iStart<0 ){\n          pIter->iStart = io;\n          pIter->iEnd = iEnd;\n        }else if( io<=pIter->iEnd ){\n          if( iEnd>pIter->iEnd ) pIter->iEnd = iEnd;\n        }else{\n          break;\n        }\n      }\n      pIter->iInst++;\n    }\n  }\n\n  return rc;\n}\n\n/*\n** Initialize the iterator object indicated by the final parameter to \n** iterate through coalesced phrase instances in column iCol.\n*/\nstatic int fts5CInstIterInit(\n  const Fts5ExtensionApi *pApi,\n  Fts5Context *pFts,\n  int iCol,\n  CInstIter *pIter\n){\n  int rc;\n\n  memset(pIter, 0, sizeof(CInstIter));\n  pIter->pApi = pApi;\n  pIter->pFts = pFts;\n  pIter->iCol = iCol;\n  rc = pApi->xInstCount(pFts, &pIter->nInst);\n\n  if( rc==SQLITE_OK ){\n    rc = fts5CInstIterNext(pIter);\n  }\n\n  return rc;\n}\n\n\n\n/*************************************************************************\n** Start of highlight() implementation.\n*/\ntypedef struct HighlightContext HighlightContext;\nstruct HighlightContext {\n  CInstIter iter;                 /* Coalesced Instance Iterator */\n  int iPos;                       /* Current token offset in zIn[] */\n  int iRangeStart;                /* First token to include */\n  int iRangeEnd;                  /* If non-zero, last token to include */\n  const char *zOpen;              /* Opening highlight */\n  const char *zClose;             /* Closing highlight */\n  const char *zIn;                /* Input text */\n  int nIn;                        /* Size of input text in bytes */\n  int iOff;                       /* Current offset within zIn[] */\n  char *zOut;                     /* Output value */\n};\n\n/*\n** Append text to the HighlightContext output string - p->zOut. Argument\n** z points to a buffer containing n bytes of text to append. If n is \n** negative, everything up until the first '\\0' is appended to the output.\n**\n** If *pRc is set to any value other than SQLITE_OK when this function is \n** called, it is a no-op. If an error (i.e. an OOM condition) is encountered, \n** *pRc is set to an error code before returning. \n*/\nstatic void fts5HighlightAppend(\n  int *pRc, \n  HighlightContext *p, \n  const char *z, int n\n){\n  if( *pRc==SQLITE_OK && z ){\n    if( n<0 ) n = (int)strlen(z);\n    p->zOut = sqlite3_mprintf(\"%z%.*s\", p->zOut, n, z);\n    if( p->zOut==0 ) *pRc = SQLITE_NOMEM;\n  }\n}\n\n/*\n** Tokenizer callback used by implementation of highlight() function.\n*/\nstatic int fts5HighlightCb(\n  void *pContext,                 /* Pointer to HighlightContext object */\n  int tflags,                     /* Mask of FTS5_TOKEN_* flags */\n  const char *pToken,             /* Buffer containing token */\n  int nToken,                     /* Size of token in bytes */\n  int iStartOff,                  /* Start offset of token */\n  int iEndOff                     /* End offset of token */\n){\n  HighlightContext *p = (HighlightContext*)pContext;\n  int rc = SQLITE_OK;\n  int iPos;\n\n  UNUSED_PARAM2(pToken, nToken);\n\n  if( tflags & FTS5_TOKEN_COLOCATED ) return SQLITE_OK;\n  iPos = p->iPos++;\n\n  if( p->iRangeEnd>0 ){\n    if( iPos<p->iRangeStart || iPos>p->iRangeEnd ) return SQLITE_OK;\n    if( p->iRangeStart && iPos==p->iRangeStart ) p->iOff = iStartOff;\n  }\n\n  if( iPos==p->iter.iStart ){\n    fts5HighlightAppend(&rc, p, &p->zIn[p->iOff], iStartOff - p->iOff);\n    fts5HighlightAppend(&rc, p, p->zOpen, -1);\n    p->iOff = iStartOff;\n  }\n\n  if( iPos==p->iter.iEnd ){\n    if( p->iRangeEnd && p->iter.iStart<p->iRangeStart ){\n      fts5HighlightAppend(&rc, p, p->zOpen, -1);\n    }\n    fts5HighlightAppend(&rc, p, &p->zIn[p->iOff], iEndOff - p->iOff);\n    fts5HighlightAppend(&rc, p, p->zClose, -1);\n    p->iOff = iEndOff;\n    if( rc==SQLITE_OK ){\n      rc = fts5CInstIterNext(&p->iter);\n    }\n  }\n\n  if( p->iRangeEnd>0 && iPos==p->iRangeEnd ){\n    fts5HighlightAppend(&rc, p, &p->zIn[p->iOff], iEndOff - p->iOff);\n    p->iOff = iEndOff;\n    if( iPos>=p->iter.iStart && iPos<p->iter.iEnd ){\n      fts5HighlightAppend(&rc, p, p->zClose, -1);\n    }\n  }\n\n  return rc;\n}\n\n/*\n** Implementation of highlight() function.\n*/\nstatic void fts5HighlightFunction(\n  const Fts5ExtensionApi *pApi,   /* API offered by current FTS version */\n  Fts5Context *pFts,              /* First arg to pass to pApi functions */\n  sqlite3_context *pCtx,          /* Context for returning result/error */\n  int nVal,                       /* Number of values in apVal[] array */\n  sqlite3_value **apVal           /* Array of trailing arguments */\n){\n  HighlightContext ctx;\n  int rc;\n  int iCol;\n\n  if( nVal!=3 ){\n    const char *zErr = \"wrong number of arguments to function highlight()\";\n    sqlite3_result_error(pCtx, zErr, -1);\n    return;\n  }\n\n  iCol = sqlite3_value_int(apVal[0]);\n  memset(&ctx, 0, sizeof(HighlightContext));\n  ctx.zOpen = (const char*)sqlite3_value_text(apVal[1]);\n  ctx.zClose = (const char*)sqlite3_value_text(apVal[2]);\n  rc = pApi->xColumnText(pFts, iCol, &ctx.zIn, &ctx.nIn);\n\n  if( ctx.zIn ){\n    if( rc==SQLITE_OK ){\n      rc = fts5CInstIterInit(pApi, pFts, iCol, &ctx.iter);\n    }\n\n    if( rc==SQLITE_OK ){\n      rc = pApi->xTokenize(pFts, ctx.zIn, ctx.nIn, (void*)&ctx,fts5HighlightCb);\n    }\n    fts5HighlightAppend(&rc, &ctx, &ctx.zIn[ctx.iOff], ctx.nIn - ctx.iOff);\n\n    if( rc==SQLITE_OK ){\n      sqlite3_result_text(pCtx, (const char*)ctx.zOut, -1, SQLITE_TRANSIENT);\n    }\n    sqlite3_free(ctx.zOut);\n  }\n  if( rc!=SQLITE_OK ){\n    sqlite3_result_error_code(pCtx, rc);\n  }\n}\n/*\n** End of highlight() implementation.\n**************************************************************************/\n\n/*\n** Context object passed to the fts5SentenceFinderCb() function.\n*/\ntypedef struct Fts5SFinder Fts5SFinder;\nstruct Fts5SFinder {\n  int iPos;                       /* Current token position */\n  int nFirstAlloc;                /* Allocated size of aFirst[] */\n  int nFirst;                     /* Number of entries in aFirst[] */\n  int *aFirst;                    /* Array of first token in each sentence */\n  const char *zDoc;               /* Document being tokenized */\n};\n\n/*\n** Add an entry to the Fts5SFinder.aFirst[] array. Grow the array if\n** necessary. Return SQLITE_OK if successful, or SQLITE_NOMEM if an\n** error occurs.\n*/\nstatic int fts5SentenceFinderAdd(Fts5SFinder *p, int iAdd){\n  if( p->nFirstAlloc==p->nFirst ){\n    int nNew = p->nFirstAlloc ? p->nFirstAlloc*2 : 64;\n    int *aNew;\n\n    aNew = (int*)sqlite3_realloc64(p->aFirst, nNew*sizeof(int));\n    if( aNew==0 ) return SQLITE_NOMEM;\n    p->aFirst = aNew;\n    p->nFirstAlloc = nNew;\n  }\n  p->aFirst[p->nFirst++] = iAdd;\n  return SQLITE_OK;\n}\n\n/*\n** This function is an xTokenize() callback used by the auxiliary snippet()\n** function. Its job is to identify tokens that are the first in a sentence.\n** For each such token, an entry is added to the SFinder.aFirst[] array.\n*/\nstatic int fts5SentenceFinderCb(\n  void *pContext,                 /* Pointer to HighlightContext object */\n  int tflags,                     /* Mask of FTS5_TOKEN_* flags */\n  const char *pToken,             /* Buffer containing token */\n  int nToken,                     /* Size of token in bytes */\n  int iStartOff,                  /* Start offset of token */\n  int iEndOff                     /* End offset of token */\n){\n  int rc = SQLITE_OK;\n\n  UNUSED_PARAM2(pToken, nToken);\n  UNUSED_PARAM(iEndOff);\n\n  if( (tflags & FTS5_TOKEN_COLOCATED)==0 ){\n    Fts5SFinder *p = (Fts5SFinder*)pContext;\n    if( p->iPos>0 ){\n      int i;\n      char c = 0;\n      for(i=iStartOff-1; i>=0; i--){\n        c = p->zDoc[i];\n        if( c!=' ' && c!='\\t' && c!='\\n' && c!='\\r' ) break;\n      }\n      if( i!=iStartOff-1 && (c=='.' || c==':') ){\n        rc = fts5SentenceFinderAdd(p, p->iPos);\n      }\n    }else{\n      rc = fts5SentenceFinderAdd(p, 0);\n    }\n    p->iPos++;\n  }\n  return rc;\n}\n\nstatic int fts5SnippetScore(\n  const Fts5ExtensionApi *pApi,   /* API offered by current FTS version */\n  Fts5Context *pFts,              /* First arg to pass to pApi functions */\n  int nDocsize,                   /* Size of column in tokens */\n  unsigned char *aSeen,           /* Array with one element per query phrase */\n  int iCol,                       /* Column to score */\n  int iPos,                       /* Starting offset to score */\n  int nToken,                     /* Max tokens per snippet */\n  int *pnScore,                   /* OUT: Score */\n  int *piPos                      /* OUT: Adjusted offset */\n){\n  int rc;\n  int i;\n  int ip = 0;\n  int ic = 0;\n  int iOff = 0;\n  int iFirst = -1;\n  int nInst;\n  int nScore = 0;\n  int iLast = 0;\n  sqlite3_int64 iEnd = (sqlite3_int64)iPos + nToken;\n\n  rc = pApi->xInstCount(pFts, &nInst);\n  for(i=0; i<nInst && rc==SQLITE_OK; i++){\n    rc = pApi->xInst(pFts, i, &ip, &ic, &iOff);\n    if( rc==SQLITE_OK && ic==iCol && iOff>=iPos && iOff<iEnd ){\n      nScore += (aSeen[ip] ? 1 : 1000);\n      aSeen[ip] = 1;\n      if( iFirst<0 ) iFirst = iOff;\n      iLast = iOff + pApi->xPhraseSize(pFts, ip);\n    }\n  }\n\n  *pnScore = nScore;\n  if( piPos ){\n    sqlite3_int64 iAdj = iFirst - (nToken - (iLast-iFirst)) / 2;\n    if( (iAdj+nToken)>nDocsize ) iAdj = nDocsize - nToken;\n    if( iAdj<0 ) iAdj = 0;\n    *piPos = iAdj;\n  }\n\n  return rc;\n}\n\n/*\n** Return the value in pVal interpreted as utf-8 text. Except, if pVal \n** contains a NULL value, return a pointer to a static string zero\n** bytes in length instead of a NULL pointer.\n*/\nstatic const char *fts5ValueToText(sqlite3_value *pVal){\n  const char *zRet = (const char*)sqlite3_value_text(pVal);\n  return zRet ? zRet : \"\";\n}\n\n/*\n** Implementation of snippet() function.\n*/\nstatic void fts5SnippetFunction(\n  const Fts5ExtensionApi *pApi,   /* API offered by current FTS version */\n  Fts5Context *pFts,              /* First arg to pass to pApi functions */\n  sqlite3_context *pCtx,          /* Context for returning result/error */\n  int nVal,                       /* Number of values in apVal[] array */\n  sqlite3_value **apVal           /* Array of trailing arguments */\n){\n  HighlightContext ctx;\n  int rc = SQLITE_OK;             /* Return code */\n  int iCol;                       /* 1st argument to snippet() */\n  const char *zEllips;            /* 4th argument to snippet() */\n  int nToken;                     /* 5th argument to snippet() */\n  int nInst = 0;                  /* Number of instance matches this row */\n  int i;                          /* Used to iterate through instances */\n  int nPhrase;                    /* Number of phrases in query */\n  unsigned char *aSeen;           /* Array of \"seen instance\" flags */\n  int iBestCol;                   /* Column containing best snippet */\n  int iBestStart = 0;             /* First token of best snippet */\n  int nBestScore = 0;             /* Score of best snippet */\n  int nColSize = 0;               /* Total size of iBestCol in tokens */\n  Fts5SFinder sFinder;            /* Used to find the beginnings of sentences */\n  int nCol;\n\n  if( nVal!=5 ){\n    const char *zErr = \"wrong number of arguments to function snippet()\";\n    sqlite3_result_error(pCtx, zErr, -1);\n    return;\n  }\n\n  nCol = pApi->xColumnCount(pFts);\n  memset(&ctx, 0, sizeof(HighlightContext));\n  iCol = sqlite3_value_int(apVal[0]);\n  ctx.zOpen = fts5ValueToText(apVal[1]);\n  ctx.zClose = fts5ValueToText(apVal[2]);\n  zEllips = fts5ValueToText(apVal[3]);\n  nToken = sqlite3_value_int(apVal[4]);\n\n  iBestCol = (iCol>=0 ? iCol : 0);\n  nPhrase = pApi->xPhraseCount(pFts);\n  aSeen = sqlite3_malloc(nPhrase);\n  if( aSeen==0 ){\n    rc = SQLITE_NOMEM;\n  }\n  if( rc==SQLITE_OK ){\n    rc = pApi->xInstCount(pFts, &nInst);\n  }\n\n  memset(&sFinder, 0, sizeof(Fts5SFinder));\n  for(i=0; i<nCol; i++){\n    if( iCol<0 || iCol==i ){\n      int nDoc;\n      int nDocsize;\n      int ii;\n      sFinder.iPos = 0;\n      sFinder.nFirst = 0;\n      rc = pApi->xColumnText(pFts, i, &sFinder.zDoc, &nDoc);\n      if( rc!=SQLITE_OK ) break;\n      rc = pApi->xTokenize(pFts, \n          sFinder.zDoc, nDoc, (void*)&sFinder,fts5SentenceFinderCb\n      );\n      if( rc!=SQLITE_OK ) break;\n      rc = pApi->xColumnSize(pFts, i, &nDocsize);\n      if( rc!=SQLITE_OK ) break;\n\n      for(ii=0; rc==SQLITE_OK && ii<nInst; ii++){\n        int ip, ic, io;\n        int iAdj;\n        int nScore;\n        int jj;\n\n        rc = pApi->xInst(pFts, ii, &ip, &ic, &io);\n        if( ic!=i ) continue;\n        if( io>nDocsize ) rc = FTS5_CORRUPT;\n        if( rc!=SQLITE_OK ) continue;\n        memset(aSeen, 0, nPhrase);\n        rc = fts5SnippetScore(pApi, pFts, nDocsize, aSeen, i,\n            io, nToken, &nScore, &iAdj\n        );\n        if( rc==SQLITE_OK && nScore>nBestScore ){\n          nBestScore = nScore;\n          iBestCol = i;\n          iBestStart = iAdj;\n          nColSize = nDocsize;\n        }\n\n        if( rc==SQLITE_OK && sFinder.nFirst && nDocsize>nToken ){\n          for(jj=0; jj<(sFinder.nFirst-1); jj++){\n            if( sFinder.aFirst[jj+1]>io ) break;\n          }\n\n          if( sFinder.aFirst[jj]<io ){\n            memset(aSeen, 0, nPhrase);\n            rc = fts5SnippetScore(pApi, pFts, nDocsize, aSeen, i, \n              sFinder.aFirst[jj], nToken, &nScore, 0\n            );\n\n            nScore += (sFinder.aFirst[jj]==0 ? 120 : 100);\n            if( rc==SQLITE_OK && nScore>nBestScore ){\n              nBestScore = nScore;\n              iBestCol = i;\n              iBestStart = sFinder.aFirst[jj];\n              nColSize = nDocsize;\n            }\n          }\n        }\n      }\n    }\n  }\n\n  if( rc==SQLITE_OK ){\n    rc = pApi->xColumnText(pFts, iBestCol, &ctx.zIn, &ctx.nIn);\n  }\n  if( rc==SQLITE_OK && nColSize==0 ){\n    rc = pApi->xColumnSize(pFts, iBestCol, &nColSize);\n  }\n  if( ctx.zIn ){\n    if( rc==SQLITE_OK ){\n      rc = fts5CInstIterInit(pApi, pFts, iBestCol, &ctx.iter);\n    }\n\n    ctx.iRangeStart = iBestStart;\n    ctx.iRangeEnd = iBestStart + nToken - 1;\n\n    if( iBestStart>0 ){\n      fts5HighlightAppend(&rc, &ctx, zEllips, -1);\n    }\n\n    /* Advance iterator ctx.iter so that it points to the first coalesced\n    ** phrase instance at or following position iBestStart. */\n    while( ctx.iter.iStart>=0 && ctx.iter.iStart<iBestStart && rc==SQLITE_OK ){\n      rc = fts5CInstIterNext(&ctx.iter);\n    }\n\n    if( rc==SQLITE_OK ){\n      rc = pApi->xTokenize(pFts, ctx.zIn, ctx.nIn, (void*)&ctx,fts5HighlightCb);\n    }\n    if( ctx.iRangeEnd>=(nColSize-1) ){\n      fts5HighlightAppend(&rc, &ctx, &ctx.zIn[ctx.iOff], ctx.nIn - ctx.iOff);\n    }else{\n      fts5HighlightAppend(&rc, &ctx, zEllips, -1);\n    }\n  }\n  if( rc==SQLITE_OK ){\n    sqlite3_result_text(pCtx, (const char*)ctx.zOut, -1, SQLITE_TRANSIENT);\n  }else{\n    sqlite3_result_error_code(pCtx, rc);\n  }\n  sqlite3_free(ctx.zOut);\n  sqlite3_free(aSeen);\n  sqlite3_free(sFinder.aFirst);\n}\n\n/************************************************************************/\n\n/*\n** The first time the bm25() function is called for a query, an instance\n** of the following structure is allocated and populated.\n*/\ntypedef struct Fts5Bm25Data Fts5Bm25Data;\nstruct Fts5Bm25Data {\n  int nPhrase;                    /* Number of phrases in query */\n  double avgdl;                   /* Average number of tokens in each row */\n  double *aIDF;                   /* IDF for each phrase */\n  double *aFreq;                  /* Array used to calculate phrase freq. */\n};\n\n/*\n** Callback used by fts5Bm25GetData() to count the number of rows in the\n** table matched by each individual phrase within the query.\n*/\nstatic int fts5CountCb(\n  const Fts5ExtensionApi *pApi, \n  Fts5Context *pFts,\n  void *pUserData                 /* Pointer to sqlite3_int64 variable */\n){\n  sqlite3_int64 *pn = (sqlite3_int64*)pUserData;\n  UNUSED_PARAM2(pApi, pFts);\n  (*pn)++;\n  return SQLITE_OK;\n}\n\n/*\n** Set *ppData to point to the Fts5Bm25Data object for the current query. \n** If the object has not already been allocated, allocate and populate it\n** now.\n*/\nstatic int fts5Bm25GetData(\n  const Fts5ExtensionApi *pApi, \n  Fts5Context *pFts,\n  Fts5Bm25Data **ppData           /* OUT: bm25-data object for this query */\n){\n  int rc = SQLITE_OK;             /* Return code */\n  Fts5Bm25Data *p;                /* Object to return */\n\n  p = pApi->xGetAuxdata(pFts, 0);\n  if( p==0 ){\n    int nPhrase;                  /* Number of phrases in query */\n    sqlite3_int64 nRow = 0;       /* Number of rows in table */\n    sqlite3_int64 nToken = 0;     /* Number of tokens in table */\n    sqlite3_int64 nByte;          /* Bytes of space to allocate */\n    int i;\n\n    /* Allocate the Fts5Bm25Data object */\n    nPhrase = pApi->xPhraseCount(pFts);\n    nByte = sizeof(Fts5Bm25Data) + nPhrase*2*sizeof(double);\n    p = (Fts5Bm25Data*)sqlite3_malloc64(nByte);\n    if( p==0 ){\n      rc = SQLITE_NOMEM;\n    }else{\n      memset(p, 0, nByte);\n      p->nPhrase = nPhrase;\n      p->aIDF = (double*)&p[1];\n      p->aFreq = &p->aIDF[nPhrase];\n    }\n\n    /* Calculate the average document length for this FTS5 table */\n    if( rc==SQLITE_OK ) rc = pApi->xRowCount(pFts, &nRow);\n    assert( rc!=SQLITE_OK || nRow>0 );\n    if( rc==SQLITE_OK ) rc = pApi->xColumnTotalSize(pFts, -1, &nToken);\n    if( rc==SQLITE_OK ) p->avgdl = (double)nToken  / (double)nRow;\n\n    /* Calculate an IDF for each phrase in the query */\n    for(i=0; rc==SQLITE_OK && i<nPhrase; i++){\n      sqlite3_int64 nHit = 0;\n      rc = pApi->xQueryPhrase(pFts, i, (void*)&nHit, fts5CountCb);\n      if( rc==SQLITE_OK ){\n        /* Calculate the IDF (Inverse Document Frequency) for phrase i.\n        ** This is done using the standard BM25 formula as found on wikipedia:\n        **\n        **   IDF = log( (N - nHit + 0.5) / (nHit + 0.5) )\n        **\n        ** where \"N\" is the total number of documents in the set and nHit\n        ** is the number that contain at least one instance of the phrase\n        ** under consideration.\n        **\n        ** The problem with this is that if (N < 2*nHit), the IDF is \n        ** negative. Which is undesirable. So the mimimum allowable IDF is\n        ** (1e-6) - roughly the same as a term that appears in just over\n        ** half of set of 5,000,000 documents.  */\n        double idf = log( (nRow - nHit + 0.5) / (nHit + 0.5) );\n        if( idf<=0.0 ) idf = 1e-6;\n        p->aIDF[i] = idf;\n      }\n    }\n\n    if( rc!=SQLITE_OK ){\n      sqlite3_free(p);\n    }else{\n      rc = pApi->xSetAuxdata(pFts, p, sqlite3_free);\n    }\n    if( rc!=SQLITE_OK ) p = 0;\n  }\n  *ppData = p;\n  return rc;\n}\n\n/*\n** Implementation of bm25() function.\n*/\nstatic void fts5Bm25Function(\n  const Fts5ExtensionApi *pApi,   /* API offered by current FTS version */\n  Fts5Context *pFts,              /* First arg to pass to pApi functions */\n  sqlite3_context *pCtx,          /* Context for returning result/error */\n  int nVal,                       /* Number of values in apVal[] array */\n  sqlite3_value **apVal           /* Array of trailing arguments */\n){\n  const double k1 = 1.2;          /* Constant \"k1\" from BM25 formula */\n  const double b = 0.75;          /* Constant \"b\" from BM25 formula */\n  int rc = SQLITE_OK;             /* Error code */\n  double score = 0.0;             /* SQL function return value */\n  Fts5Bm25Data *pData;            /* Values allocated/calculated once only */\n  int i;                          /* Iterator variable */\n  int nInst = 0;                  /* Value returned by xInstCount() */\n  double D = 0.0;                 /* Total number of tokens in row */\n  double *aFreq = 0;              /* Array of phrase freq. for current row */\n\n  /* Calculate the phrase frequency (symbol \"f(qi,D)\" in the documentation)\n  ** for each phrase in the query for the current row. */\n  rc = fts5Bm25GetData(pApi, pFts, &pData);\n  if( rc==SQLITE_OK ){\n    aFreq = pData->aFreq;\n    memset(aFreq, 0, sizeof(double) * pData->nPhrase);\n    rc = pApi->xInstCount(pFts, &nInst);\n  }\n  for(i=0; rc==SQLITE_OK && i<nInst; i++){\n    int ip; int ic; int io;\n    rc = pApi->xInst(pFts, i, &ip, &ic, &io);\n    if( rc==SQLITE_OK ){\n      double w = (nVal > ic) ? sqlite3_value_double(apVal[ic]) : 1.0;\n      aFreq[ip] += w;\n    }\n  }\n\n  /* Figure out the total size of the current row in tokens. */\n  if( rc==SQLITE_OK ){\n    int nTok;\n    rc = pApi->xColumnSize(pFts, -1, &nTok);\n    D = (double)nTok;\n  }\n\n  /* Determine the BM25 score for the current row. */\n  for(i=0; rc==SQLITE_OK && i<pData->nPhrase; i++){\n    score += pData->aIDF[i] * (\n      ( aFreq[i] * (k1 + 1.0) ) / \n      ( aFreq[i] + k1 * (1 - b + b * D / pData->avgdl) )\n    );\n  }\n  \n  /* If no error has occurred, return the calculated score. Otherwise,\n  ** throw an SQL exception.  */\n  if( rc==SQLITE_OK ){\n    sqlite3_result_double(pCtx, -1.0 * score);\n  }else{\n    sqlite3_result_error_code(pCtx, rc);\n  }\n}\n\nstatic int sqlite3Fts5AuxInit(fts5_api *pApi){\n  struct Builtin {\n    const char *zFunc;            /* Function name (nul-terminated) */\n    void *pUserData;              /* User-data pointer */\n    fts5_extension_function xFunc;/* Callback function */\n    void (*xDestroy)(void*);      /* Destructor function */\n  } aBuiltin [] = {\n    { \"snippet\",   0, fts5SnippetFunction, 0 },\n    { \"highlight\", 0, fts5HighlightFunction, 0 },\n    { \"bm25\",      0, fts5Bm25Function,    0 },\n  };\n  int rc = SQLITE_OK;             /* Return code */\n  int i;                          /* To iterate through builtin functions */\n\n  for(i=0; rc==SQLITE_OK && i<ArraySize(aBuiltin); i++){\n    rc = pApi->xCreateFunction(pApi,\n        aBuiltin[i].zFunc,\n        aBuiltin[i].pUserData,\n        aBuiltin[i].xFunc,\n        aBuiltin[i].xDestroy\n    );\n  }\n\n  return rc;\n}\n\n/*\n** 2014 May 31\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n******************************************************************************\n*/\n\n\n\n/* #include \"fts5Int.h\" */\n\nstatic int sqlite3Fts5BufferSize(int *pRc, Fts5Buffer *pBuf, u32 nByte){\n  if( (u32)pBuf->nSpace<nByte ){\n    u64 nNew = pBuf->nSpace ? pBuf->nSpace : 64;\n    u8 *pNew;\n    while( nNew<nByte ){\n      nNew = nNew * 2;\n    }\n    pNew = sqlite3_realloc64(pBuf->p, nNew);\n    if( pNew==0 ){\n      *pRc = SQLITE_NOMEM;\n      return 1;\n    }else{\n      pBuf->nSpace = nNew;\n      pBuf->p = pNew;\n    }\n  }\n  return 0;\n}\n\n\n/*\n** Encode value iVal as an SQLite varint and append it to the buffer object\n** pBuf. If an OOM error occurs, set the error code in p.\n*/\nstatic void sqlite3Fts5BufferAppendVarint(int *pRc, Fts5Buffer *pBuf, i64 iVal){\n  if( fts5BufferGrow(pRc, pBuf, 9) ) return;\n  pBuf->n += sqlite3Fts5PutVarint(&pBuf->p[pBuf->n], iVal);\n}\n\nstatic void sqlite3Fts5Put32(u8 *aBuf, int iVal){\n  aBuf[0] = (iVal>>24) & 0x00FF;\n  aBuf[1] = (iVal>>16) & 0x00FF;\n  aBuf[2] = (iVal>> 8) & 0x00FF;\n  aBuf[3] = (iVal>> 0) & 0x00FF;\n}\n\nstatic int sqlite3Fts5Get32(const u8 *aBuf){\n  return (int)((((u32)aBuf[0])<<24) + (aBuf[1]<<16) + (aBuf[2]<<8) + aBuf[3]);\n}\n\n/*\n** Append buffer nData/pData to buffer pBuf. If an OOM error occurs, set \n** the error code in p. If an error has already occurred when this function\n** is called, it is a no-op.\n*/\nstatic void sqlite3Fts5BufferAppendBlob(\n  int *pRc,\n  Fts5Buffer *pBuf, \n  u32 nData, \n  const u8 *pData\n){\n  assert_nc( *pRc || nData>=0 );\n  if( nData ){\n    if( fts5BufferGrow(pRc, pBuf, nData) ) return;\n    memcpy(&pBuf->p[pBuf->n], pData, nData);\n    pBuf->n += nData;\n  }\n}\n\n/*\n** Append the nul-terminated string zStr to the buffer pBuf. This function\n** ensures that the byte following the buffer data is set to 0x00, even \n** though this byte is not included in the pBuf->n count.\n*/\nstatic void sqlite3Fts5BufferAppendString(\n  int *pRc,\n  Fts5Buffer *pBuf, \n  const char *zStr\n){\n  int nStr = (int)strlen(zStr);\n  sqlite3Fts5BufferAppendBlob(pRc, pBuf, nStr+1, (const u8*)zStr);\n  pBuf->n--;\n}\n\n/*\n** Argument zFmt is a printf() style format string. This function performs\n** the printf() style processing, then appends the results to buffer pBuf.\n**\n** Like sqlite3Fts5BufferAppendString(), this function ensures that the byte \n** following the buffer data is set to 0x00, even though this byte is not\n** included in the pBuf->n count.\n*/ \nstatic void sqlite3Fts5BufferAppendPrintf(\n  int *pRc,\n  Fts5Buffer *pBuf, \n  char *zFmt, ...\n){\n  if( *pRc==SQLITE_OK ){\n    char *zTmp;\n    va_list ap;\n    va_start(ap, zFmt);\n    zTmp = sqlite3_vmprintf(zFmt, ap);\n    va_end(ap);\n\n    if( zTmp==0 ){\n      *pRc = SQLITE_NOMEM;\n    }else{\n      sqlite3Fts5BufferAppendString(pRc, pBuf, zTmp);\n      sqlite3_free(zTmp);\n    }\n  }\n}\n\nstatic char *sqlite3Fts5Mprintf(int *pRc, const char *zFmt, ...){\n  char *zRet = 0;\n  if( *pRc==SQLITE_OK ){\n    va_list ap;\n    va_start(ap, zFmt);\n    zRet = sqlite3_vmprintf(zFmt, ap);\n    va_end(ap);\n    if( zRet==0 ){\n      *pRc = SQLITE_NOMEM; \n    }\n  }\n  return zRet;\n}\n \n\n/*\n** Free any buffer allocated by pBuf. Zero the structure before returning.\n*/\nstatic void sqlite3Fts5BufferFree(Fts5Buffer *pBuf){\n  sqlite3_free(pBuf->p);\n  memset(pBuf, 0, sizeof(Fts5Buffer));\n}\n\n/*\n** Zero the contents of the buffer object. But do not free the associated \n** memory allocation.\n*/\nstatic void sqlite3Fts5BufferZero(Fts5Buffer *pBuf){\n  pBuf->n = 0;\n}\n\n/*\n** Set the buffer to contain nData/pData. If an OOM error occurs, leave an\n** the error code in p. If an error has already occurred when this function\n** is called, it is a no-op.\n*/\nstatic void sqlite3Fts5BufferSet(\n  int *pRc,\n  Fts5Buffer *pBuf, \n  int nData, \n  const u8 *pData\n){\n  pBuf->n = 0;\n  sqlite3Fts5BufferAppendBlob(pRc, pBuf, nData, pData);\n}\n\nstatic int sqlite3Fts5PoslistNext64(\n  const u8 *a, int n,             /* Buffer containing poslist */\n  int *pi,                        /* IN/OUT: Offset within a[] */\n  i64 *piOff                      /* IN/OUT: Current offset */\n){\n  int i = *pi;\n  if( i>=n ){\n    /* EOF */\n    *piOff = -1;\n    return 1;  \n  }else{\n    i64 iOff = *piOff;\n    int iVal;\n    fts5FastGetVarint32(a, i, iVal);\n    if( iVal==1 ){\n      fts5FastGetVarint32(a, i, iVal);\n      iOff = ((i64)iVal) << 32;\n      fts5FastGetVarint32(a, i, iVal);\n    }\n    *piOff = iOff + ((iVal-2) & 0x7FFFFFFF);\n    *pi = i;\n    return 0;\n  }\n}\n\n\n/*\n** Advance the iterator object passed as the only argument. Return true\n** if the iterator reaches EOF, or false otherwise.\n*/\nstatic int sqlite3Fts5PoslistReaderNext(Fts5PoslistReader *pIter){\n  if( sqlite3Fts5PoslistNext64(pIter->a, pIter->n, &pIter->i, &pIter->iPos) ){\n    pIter->bEof = 1;\n  }\n  return pIter->bEof;\n}\n\nstatic int sqlite3Fts5PoslistReaderInit(\n  const u8 *a, int n,             /* Poslist buffer to iterate through */\n  Fts5PoslistReader *pIter        /* Iterator object to initialize */\n){\n  memset(pIter, 0, sizeof(*pIter));\n  pIter->a = a;\n  pIter->n = n;\n  sqlite3Fts5PoslistReaderNext(pIter);\n  return pIter->bEof;\n}\n\n/*\n** Append position iPos to the position list being accumulated in buffer\n** pBuf, which must be already be large enough to hold the new data.\n** The previous position written to this list is *piPrev. *piPrev is set\n** to iPos before returning.\n*/\nstatic void sqlite3Fts5PoslistSafeAppend(\n  Fts5Buffer *pBuf, \n  i64 *piPrev, \n  i64 iPos\n){\n  static const i64 colmask = ((i64)(0x7FFFFFFF)) << 32;\n  if( (iPos & colmask) != (*piPrev & colmask) ){\n    pBuf->p[pBuf->n++] = 1;\n    pBuf->n += sqlite3Fts5PutVarint(&pBuf->p[pBuf->n], (iPos>>32));\n    *piPrev = (iPos & colmask);\n  }\n  pBuf->n += sqlite3Fts5PutVarint(&pBuf->p[pBuf->n], (iPos-*piPrev)+2);\n  *piPrev = iPos;\n}\n\nstatic int sqlite3Fts5PoslistWriterAppend(\n  Fts5Buffer *pBuf, \n  Fts5PoslistWriter *pWriter,\n  i64 iPos\n){\n  int rc = 0;   /* Initialized only to suppress erroneous warning from Clang */\n  if( fts5BufferGrow(&rc, pBuf, 5+5+5) ) return rc;\n  sqlite3Fts5PoslistSafeAppend(pBuf, &pWriter->iPrev, iPos);\n  return SQLITE_OK;\n}\n\nstatic void *sqlite3Fts5MallocZero(int *pRc, sqlite3_int64 nByte){\n  void *pRet = 0;\n  if( *pRc==SQLITE_OK ){\n    pRet = sqlite3_malloc64(nByte);\n    if( pRet==0 ){\n      if( nByte>0 ) *pRc = SQLITE_NOMEM;\n    }else{\n      memset(pRet, 0, nByte);\n    }\n  }\n  return pRet;\n}\n\n/*\n** Return a nul-terminated copy of the string indicated by pIn. If nIn\n** is non-negative, then it is the length of the string in bytes. Otherwise,\n** the length of the string is determined using strlen().\n**\n** It is the responsibility of the caller to eventually free the returned\n** buffer using sqlite3_free(). If an OOM error occurs, NULL is returned. \n*/\nstatic char *sqlite3Fts5Strndup(int *pRc, const char *pIn, int nIn){\n  char *zRet = 0;\n  if( *pRc==SQLITE_OK ){\n    if( nIn<0 ){\n      nIn = (int)strlen(pIn);\n    }\n    zRet = (char*)sqlite3_malloc(nIn+1);\n    if( zRet ){\n      memcpy(zRet, pIn, nIn);\n      zRet[nIn] = '\\0';\n    }else{\n      *pRc = SQLITE_NOMEM;\n    }\n  }\n  return zRet;\n}\n\n\n/*\n** Return true if character 't' may be part of an FTS5 bareword, or false\n** otherwise. Characters that may be part of barewords:\n**\n**   * All non-ASCII characters,\n**   * The 52 upper and lower case ASCII characters, and\n**   * The 10 integer ASCII characters.\n**   * The underscore character \"_\" (0x5F).\n**   * The unicode \"subsitute\" character (0x1A).\n*/\nstatic int sqlite3Fts5IsBareword(char t){\n  u8 aBareword[128] = {\n    0, 0, 0, 0, 0, 0, 0, 0,    0, 0, 0, 0, 0, 0, 0, 0,   /* 0x00 .. 0x0F */\n    0, 0, 0, 0, 0, 0, 0, 0,    0, 0, 1, 0, 0, 0, 0, 0,   /* 0x10 .. 0x1F */\n    0, 0, 0, 0, 0, 0, 0, 0,    0, 0, 0, 0, 0, 0, 0, 0,   /* 0x20 .. 0x2F */\n    1, 1, 1, 1, 1, 1, 1, 1,    1, 1, 0, 0, 0, 0, 0, 0,   /* 0x30 .. 0x3F */\n    0, 1, 1, 1, 1, 1, 1, 1,    1, 1, 1, 1, 1, 1, 1, 1,   /* 0x40 .. 0x4F */\n    1, 1, 1, 1, 1, 1, 1, 1,    1, 1, 1, 0, 0, 0, 0, 1,   /* 0x50 .. 0x5F */\n    0, 1, 1, 1, 1, 1, 1, 1,    1, 1, 1, 1, 1, 1, 1, 1,   /* 0x60 .. 0x6F */\n    1, 1, 1, 1, 1, 1, 1, 1,    1, 1, 1, 0, 0, 0, 0, 0    /* 0x70 .. 0x7F */\n  };\n\n  return (t & 0x80) || aBareword[(int)t];\n}\n\n\n/*************************************************************************\n*/\ntypedef struct Fts5TermsetEntry Fts5TermsetEntry;\nstruct Fts5TermsetEntry {\n  char *pTerm;\n  int nTerm;\n  int iIdx;                       /* Index (main or aPrefix[] entry) */\n  Fts5TermsetEntry *pNext;\n};\n\nstruct Fts5Termset {\n  Fts5TermsetEntry *apHash[512];\n};\n\nstatic int sqlite3Fts5TermsetNew(Fts5Termset **pp){\n  int rc = SQLITE_OK;\n  *pp = sqlite3Fts5MallocZero(&rc, sizeof(Fts5Termset));\n  return rc;\n}\n\nstatic int sqlite3Fts5TermsetAdd(\n  Fts5Termset *p, \n  int iIdx,\n  const char *pTerm, int nTerm, \n  int *pbPresent\n){\n  int rc = SQLITE_OK;\n  *pbPresent = 0;\n  if( p ){\n    int i;\n    u32 hash = 13;\n    Fts5TermsetEntry *pEntry;\n\n    /* Calculate a hash value for this term. This is the same hash checksum\n    ** used by the fts5_hash.c module. This is not important for correct\n    ** operation of the module, but is necessary to ensure that some tests\n    ** designed to produce hash table collisions really do work.  */\n    for(i=nTerm-1; i>=0; i--){\n      hash = (hash << 3) ^ hash ^ pTerm[i];\n    }\n    hash = (hash << 3) ^ hash ^ iIdx;\n    hash = hash % ArraySize(p->apHash);\n\n    for(pEntry=p->apHash[hash]; pEntry; pEntry=pEntry->pNext){\n      if( pEntry->iIdx==iIdx \n          && pEntry->nTerm==nTerm \n          && memcmp(pEntry->pTerm, pTerm, nTerm)==0 \n      ){\n        *pbPresent = 1;\n        break;\n      }\n    }\n\n    if( pEntry==0 ){\n      pEntry = sqlite3Fts5MallocZero(&rc, sizeof(Fts5TermsetEntry) + nTerm);\n      if( pEntry ){\n        pEntry->pTerm = (char*)&pEntry[1];\n        pEntry->nTerm = nTerm;\n        pEntry->iIdx = iIdx;\n        memcpy(pEntry->pTerm, pTerm, nTerm);\n        pEntry->pNext = p->apHash[hash];\n        p->apHash[hash] = pEntry;\n      }\n    }\n  }\n\n  return rc;\n}\n\nstatic void sqlite3Fts5TermsetFree(Fts5Termset *p){\n  if( p ){\n    u32 i;\n    for(i=0; i<ArraySize(p->apHash); i++){\n      Fts5TermsetEntry *pEntry = p->apHash[i];\n      while( pEntry ){\n        Fts5TermsetEntry *pDel = pEntry;\n        pEntry = pEntry->pNext;\n        sqlite3_free(pDel);\n      }\n    }\n    sqlite3_free(p);\n  }\n}\n\n/*\n** 2014 Jun 09\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n******************************************************************************\n**\n** This is an SQLite module implementing full-text search.\n*/\n\n\n/* #include \"fts5Int.h\" */\n\n#define FTS5_DEFAULT_PAGE_SIZE   4050\n#define FTS5_DEFAULT_AUTOMERGE      4\n#define FTS5_DEFAULT_USERMERGE      4\n#define FTS5_DEFAULT_CRISISMERGE   16\n#define FTS5_DEFAULT_HASHSIZE    (1024*1024)\n\n/* Maximum allowed page size */\n#define FTS5_MAX_PAGE_SIZE (128*1024)\n\nstatic int fts5_iswhitespace(char x){\n  return (x==' ');\n}\n\nstatic int fts5_isopenquote(char x){\n  return (x=='\"' || x=='\\'' || x=='[' || x=='`');\n}\n\n/*\n** Argument pIn points to a character that is part of a nul-terminated \n** string. Return a pointer to the first character following *pIn in \n** the string that is not a white-space character.\n*/\nstatic const char *fts5ConfigSkipWhitespace(const char *pIn){\n  const char *p = pIn;\n  if( p ){\n    while( fts5_iswhitespace(*p) ){ p++; }\n  }\n  return p;\n}\n\n/*\n** Argument pIn points to a character that is part of a nul-terminated \n** string. Return a pointer to the first character following *pIn in \n** the string that is not a \"bareword\" character.\n*/\nstatic const char *fts5ConfigSkipBareword(const char *pIn){\n  const char *p = pIn;\n  while ( sqlite3Fts5IsBareword(*p) ) p++;\n  if( p==pIn ) p = 0;\n  return p;\n}\n\nstatic int fts5_isdigit(char a){\n  return (a>='0' && a<='9');\n}\n\n\n\nstatic const char *fts5ConfigSkipLiteral(const char *pIn){\n  const char *p = pIn;\n  switch( *p ){\n    case 'n': case 'N':\n      if( sqlite3_strnicmp(\"null\", p, 4)==0 ){\n        p = &p[4];\n      }else{\n        p = 0;\n      }\n      break;\n\n    case 'x': case 'X':\n      p++;\n      if( *p=='\\'' ){\n        p++;\n        while( (*p>='a' && *p<='f') \n            || (*p>='A' && *p<='F') \n            || (*p>='0' && *p<='9') \n            ){\n          p++;\n        }\n        if( *p=='\\'' && 0==((p-pIn)%2) ){\n          p++;\n        }else{\n          p = 0;\n        }\n      }else{\n        p = 0;\n      }\n      break;\n\n    case '\\'':\n      p++;\n      while( p ){\n        if( *p=='\\'' ){\n          p++;\n          if( *p!='\\'' ) break;\n        }\n        p++;\n        if( *p==0 ) p = 0;\n      }\n      break;\n\n    default:\n      /* maybe a number */\n      if( *p=='+' || *p=='-' ) p++;\n      while( fts5_isdigit(*p) ) p++;\n\n      /* At this point, if the literal was an integer, the parse is \n      ** finished. Or, if it is a floating point value, it may continue\n      ** with either a decimal point or an 'E' character. */\n      if( *p=='.' && fts5_isdigit(p[1]) ){\n        p += 2;\n        while( fts5_isdigit(*p) ) p++;\n      }\n      if( p==pIn ) p = 0;\n\n      break;\n  }\n\n  return p;\n}\n\n/*\n** The first character of the string pointed to by argument z is guaranteed\n** to be an open-quote character (see function fts5_isopenquote()).\n**\n** This function searches for the corresponding close-quote character within\n** the string and, if found, dequotes the string in place and adds a new\n** nul-terminator byte.\n**\n** If the close-quote is found, the value returned is the byte offset of\n** the character immediately following it. Or, if the close-quote is not \n** found, -1 is returned. If -1 is returned, the buffer is left in an \n** undefined state.\n*/\nstatic int fts5Dequote(char *z){\n  char q;\n  int iIn = 1;\n  int iOut = 0;\n  q = z[0];\n\n  /* Set stack variable q to the close-quote character */\n  assert( q=='[' || q=='\\'' || q=='\"' || q=='`' );\n  if( q=='[' ) q = ']';  \n\n  while( ALWAYS(z[iIn]) ){\n    if( z[iIn]==q ){\n      if( z[iIn+1]!=q ){\n        /* Character iIn was the close quote. */\n        iIn++;\n        break;\n      }else{\n        /* Character iIn and iIn+1 form an escaped quote character. Skip\n        ** the input cursor past both and copy a single quote character \n        ** to the output buffer. */\n        iIn += 2;\n        z[iOut++] = q;\n      }\n    }else{\n      z[iOut++] = z[iIn++];\n    }\n  }\n\n  z[iOut] = '\\0';\n  return iIn;\n}\n\n/*\n** Convert an SQL-style quoted string into a normal string by removing\n** the quote characters.  The conversion is done in-place.  If the\n** input does not begin with a quote character, then this routine\n** is a no-op.\n**\n** Examples:\n**\n**     \"abc\"   becomes   abc\n**     'xyz'   becomes   xyz\n**     [pqr]   becomes   pqr\n**     `mno`   becomes   mno\n*/\nstatic void sqlite3Fts5Dequote(char *z){\n  char quote;                     /* Quote character (if any ) */\n\n  assert( 0==fts5_iswhitespace(z[0]) );\n  quote = z[0];\n  if( quote=='[' || quote=='\\'' || quote=='\"' || quote=='`' ){\n    fts5Dequote(z);\n  }\n}\n\n\nstruct Fts5Enum {\n  const char *zName;\n  int eVal;\n};\ntypedef struct Fts5Enum Fts5Enum;\n\nstatic int fts5ConfigSetEnum(\n  const Fts5Enum *aEnum, \n  const char *zEnum, \n  int *peVal\n){\n  int nEnum = (int)strlen(zEnum);\n  int i;\n  int iVal = -1;\n\n  for(i=0; aEnum[i].zName; i++){\n    if( sqlite3_strnicmp(aEnum[i].zName, zEnum, nEnum)==0 ){\n      if( iVal>=0 ) return SQLITE_ERROR;\n      iVal = aEnum[i].eVal;\n    }\n  }\n\n  *peVal = iVal;\n  return iVal<0 ? SQLITE_ERROR : SQLITE_OK;\n}\n\n/*\n** Parse a \"special\" CREATE VIRTUAL TABLE directive and update\n** configuration object pConfig as appropriate.\n**\n** If successful, object pConfig is updated and SQLITE_OK returned. If\n** an error occurs, an SQLite error code is returned and an error message\n** may be left in *pzErr. It is the responsibility of the caller to\n** eventually free any such error message using sqlite3_free().\n*/\nstatic int fts5ConfigParseSpecial(\n  Fts5Global *pGlobal,\n  Fts5Config *pConfig,            /* Configuration object to update */\n  const char *zCmd,               /* Special command to parse */\n  const char *zArg,               /* Argument to parse */\n  char **pzErr                    /* OUT: Error message */\n){\n  int rc = SQLITE_OK;\n  int nCmd = (int)strlen(zCmd);\n  if( sqlite3_strnicmp(\"prefix\", zCmd, nCmd)==0 ){\n    const int nByte = sizeof(int) * FTS5_MAX_PREFIX_INDEXES;\n    const char *p;\n    int bFirst = 1;\n    if( pConfig->aPrefix==0 ){\n      pConfig->aPrefix = sqlite3Fts5MallocZero(&rc, nByte);\n      if( rc ) return rc;\n    }\n\n    p = zArg;\n    while( 1 ){\n      int nPre = 0;\n\n      while( p[0]==' ' ) p++;\n      if( bFirst==0 && p[0]==',' ){\n        p++;\n        while( p[0]==' ' ) p++;\n      }else if( p[0]=='\\0' ){\n        break;\n      }\n      if( p[0]<'0' || p[0]>'9' ){\n        *pzErr = sqlite3_mprintf(\"malformed prefix=... directive\");\n        rc = SQLITE_ERROR;\n        break;\n      }\n\n      if( pConfig->nPrefix==FTS5_MAX_PREFIX_INDEXES ){\n        *pzErr = sqlite3_mprintf(\n            \"too many prefix indexes (max %d)\", FTS5_MAX_PREFIX_INDEXES\n        );\n        rc = SQLITE_ERROR;\n        break;\n      }\n\n      while( p[0]>='0' && p[0]<='9' && nPre<1000 ){\n        nPre = nPre*10 + (p[0] - '0');\n        p++;\n      }\n\n      if( nPre<=0 || nPre>=1000 ){\n        *pzErr = sqlite3_mprintf(\"prefix length out of range (max 999)\");\n        rc = SQLITE_ERROR;\n        break;\n      }\n\n      pConfig->aPrefix[pConfig->nPrefix] = nPre;\n      pConfig->nPrefix++;\n      bFirst = 0;\n    }\n    assert( pConfig->nPrefix<=FTS5_MAX_PREFIX_INDEXES );\n    return rc;\n  }\n\n  if( sqlite3_strnicmp(\"tokenize\", zCmd, nCmd)==0 ){\n    const char *p = (const char*)zArg;\n    sqlite3_int64 nArg = strlen(zArg) + 1;\n    char **azArg = sqlite3Fts5MallocZero(&rc, sizeof(char*) * nArg);\n    char *pDel = sqlite3Fts5MallocZero(&rc, nArg * 2);\n    char *pSpace = pDel;\n\n    if( azArg && pSpace ){\n      if( pConfig->pTok ){\n        *pzErr = sqlite3_mprintf(\"multiple tokenize=... directives\");\n        rc = SQLITE_ERROR;\n      }else{\n        for(nArg=0; p && *p; nArg++){\n          const char *p2 = fts5ConfigSkipWhitespace(p);\n          if( *p2=='\\'' ){\n            p = fts5ConfigSkipLiteral(p2);\n          }else{\n            p = fts5ConfigSkipBareword(p2);\n          }\n          if( p ){\n            memcpy(pSpace, p2, p-p2);\n            azArg[nArg] = pSpace;\n            sqlite3Fts5Dequote(pSpace);\n            pSpace += (p - p2) + 1;\n            p = fts5ConfigSkipWhitespace(p);\n          }\n        }\n        if( p==0 ){\n          *pzErr = sqlite3_mprintf(\"parse error in tokenize directive\");\n          rc = SQLITE_ERROR;\n        }else{\n          rc = sqlite3Fts5GetTokenizer(pGlobal, \n              (const char**)azArg, nArg, &pConfig->pTok, &pConfig->pTokApi,\n              pzErr\n          );\n        }\n      }\n    }\n\n    sqlite3_free(azArg);\n    sqlite3_free(pDel);\n    return rc;\n  }\n\n  if( sqlite3_strnicmp(\"content\", zCmd, nCmd)==0 ){\n    if( pConfig->eContent!=FTS5_CONTENT_NORMAL ){\n      *pzErr = sqlite3_mprintf(\"multiple content=... directives\");\n      rc = SQLITE_ERROR;\n    }else{\n      if( zArg[0] ){\n        pConfig->eContent = FTS5_CONTENT_EXTERNAL;\n        pConfig->zContent = sqlite3Fts5Mprintf(&rc, \"%Q.%Q\", pConfig->zDb,zArg);\n      }else{\n        pConfig->eContent = FTS5_CONTENT_NONE;\n      }\n    }\n    return rc;\n  }\n\n  if( sqlite3_strnicmp(\"content_rowid\", zCmd, nCmd)==0 ){\n    if( pConfig->zContentRowid ){\n      *pzErr = sqlite3_mprintf(\"multiple content_rowid=... directives\");\n      rc = SQLITE_ERROR;\n    }else{\n      pConfig->zContentRowid = sqlite3Fts5Strndup(&rc, zArg, -1);\n    }\n    return rc;\n  }\n\n  if( sqlite3_strnicmp(\"columnsize\", zCmd, nCmd)==0 ){\n    if( (zArg[0]!='0' && zArg[0]!='1') || zArg[1]!='\\0' ){\n      *pzErr = sqlite3_mprintf(\"malformed columnsize=... directive\");\n      rc = SQLITE_ERROR;\n    }else{\n      pConfig->bColumnsize = (zArg[0]=='1');\n    }\n    return rc;\n  }\n\n  if( sqlite3_strnicmp(\"detail\", zCmd, nCmd)==0 ){\n    const Fts5Enum aDetail[] = {\n      { \"none\", FTS5_DETAIL_NONE },\n      { \"full\", FTS5_DETAIL_FULL },\n      { \"columns\", FTS5_DETAIL_COLUMNS },\n      { 0, 0 }\n    };\n\n    if( (rc = fts5ConfigSetEnum(aDetail, zArg, &pConfig->eDetail)) ){\n      *pzErr = sqlite3_mprintf(\"malformed detail=... directive\");\n    }\n    return rc;\n  }\n\n  *pzErr = sqlite3_mprintf(\"unrecognized option: \\\"%.*s\\\"\", nCmd, zCmd);\n  return SQLITE_ERROR;\n}\n\n/*\n** Allocate an instance of the default tokenizer (\"simple\") at \n** Fts5Config.pTokenizer. Return SQLITE_OK if successful, or an SQLite error\n** code if an error occurs.\n*/\nstatic int fts5ConfigDefaultTokenizer(Fts5Global *pGlobal, Fts5Config *pConfig){\n  assert( pConfig->pTok==0 && pConfig->pTokApi==0 );\n  return sqlite3Fts5GetTokenizer(\n      pGlobal, 0, 0, &pConfig->pTok, &pConfig->pTokApi, 0\n  );\n}\n\n/*\n** Gobble up the first bareword or quoted word from the input buffer zIn.\n** Return a pointer to the character immediately following the last in\n** the gobbled word if successful, or a NULL pointer otherwise (failed\n** to find close-quote character).\n**\n** Before returning, set pzOut to point to a new buffer containing a\n** nul-terminated, dequoted copy of the gobbled word. If the word was\n** quoted, *pbQuoted is also set to 1 before returning.\n**\n** If *pRc is other than SQLITE_OK when this function is called, it is\n** a no-op (NULL is returned). Otherwise, if an OOM occurs within this\n** function, *pRc is set to SQLITE_NOMEM before returning. *pRc is *not*\n** set if a parse error (failed to find close quote) occurs.\n*/\nstatic const char *fts5ConfigGobbleWord(\n  int *pRc,                       /* IN/OUT: Error code */\n  const char *zIn,                /* Buffer to gobble string/bareword from */\n  char **pzOut,                   /* OUT: malloc'd buffer containing str/bw */\n  int *pbQuoted                   /* OUT: Set to true if dequoting required */\n){\n  const char *zRet = 0;\n\n  sqlite3_int64 nIn = strlen(zIn);\n  char *zOut = sqlite3_malloc64(nIn+1);\n\n  assert( *pRc==SQLITE_OK );\n  *pbQuoted = 0;\n  *pzOut = 0;\n\n  if( zOut==0 ){\n    *pRc = SQLITE_NOMEM;\n  }else{\n    memcpy(zOut, zIn, nIn+1);\n    if( fts5_isopenquote(zOut[0]) ){\n      int ii = fts5Dequote(zOut);\n      zRet = &zIn[ii];\n      *pbQuoted = 1;\n    }else{\n      zRet = fts5ConfigSkipBareword(zIn);\n      if( zRet ){\n        zOut[zRet-zIn] = '\\0';\n      }\n    }\n  }\n\n  if( zRet==0 ){\n    sqlite3_free(zOut);\n  }else{\n    *pzOut = zOut;\n  }\n\n  return zRet;\n}\n\nstatic int fts5ConfigParseColumn(\n  Fts5Config *p, \n  char *zCol, \n  char *zArg, \n  char **pzErr\n){\n  int rc = SQLITE_OK;\n  if( 0==sqlite3_stricmp(zCol, FTS5_RANK_NAME) \n   || 0==sqlite3_stricmp(zCol, FTS5_ROWID_NAME) \n  ){\n    *pzErr = sqlite3_mprintf(\"reserved fts5 column name: %s\", zCol);\n    rc = SQLITE_ERROR;\n  }else if( zArg ){\n    if( 0==sqlite3_stricmp(zArg, \"unindexed\") ){\n      p->abUnindexed[p->nCol] = 1;\n    }else{\n      *pzErr = sqlite3_mprintf(\"unrecognized column option: %s\", zArg);\n      rc = SQLITE_ERROR;\n    }\n  }\n\n  p->azCol[p->nCol++] = zCol;\n  return rc;\n}\n\n/*\n** Populate the Fts5Config.zContentExprlist string.\n*/\nstatic int fts5ConfigMakeExprlist(Fts5Config *p){\n  int i;\n  int rc = SQLITE_OK;\n  Fts5Buffer buf = {0, 0, 0};\n\n  sqlite3Fts5BufferAppendPrintf(&rc, &buf, \"T.%Q\", p->zContentRowid);\n  if( p->eContent!=FTS5_CONTENT_NONE ){\n    for(i=0; i<p->nCol; i++){\n      if( p->eContent==FTS5_CONTENT_EXTERNAL ){\n        sqlite3Fts5BufferAppendPrintf(&rc, &buf, \", T.%Q\", p->azCol[i]);\n      }else{\n        sqlite3Fts5BufferAppendPrintf(&rc, &buf, \", T.c%d\", i);\n      }\n    }\n  }\n\n  assert( p->zContentExprlist==0 );\n  p->zContentExprlist = (char*)buf.p;\n  return rc;\n}\n\n/*\n** Arguments nArg/azArg contain the string arguments passed to the xCreate\n** or xConnect method of the virtual table. This function attempts to \n** allocate an instance of Fts5Config containing the results of parsing\n** those arguments.\n**\n** If successful, SQLITE_OK is returned and *ppOut is set to point to the\n** new Fts5Config object. If an error occurs, an SQLite error code is \n** returned, *ppOut is set to NULL and an error message may be left in\n** *pzErr. It is the responsibility of the caller to eventually free any \n** such error message using sqlite3_free().\n*/\nstatic int sqlite3Fts5ConfigParse(\n  Fts5Global *pGlobal,\n  sqlite3 *db,\n  int nArg,                       /* Number of arguments */\n  const char **azArg,             /* Array of nArg CREATE VIRTUAL TABLE args */\n  Fts5Config **ppOut,             /* OUT: Results of parse */\n  char **pzErr                    /* OUT: Error message */\n){\n  int rc = SQLITE_OK;             /* Return code */\n  Fts5Config *pRet;               /* New object to return */\n  int i;\n  sqlite3_int64 nByte;\n\n  *ppOut = pRet = (Fts5Config*)sqlite3_malloc(sizeof(Fts5Config));\n  if( pRet==0 ) return SQLITE_NOMEM;\n  memset(pRet, 0, sizeof(Fts5Config));\n  pRet->db = db;\n  pRet->iCookie = -1;\n\n  nByte = nArg * (sizeof(char*) + sizeof(u8));\n  pRet->azCol = (char**)sqlite3Fts5MallocZero(&rc, nByte);\n  pRet->abUnindexed = (u8*)&pRet->azCol[nArg];\n  pRet->zDb = sqlite3Fts5Strndup(&rc, azArg[1], -1);\n  pRet->zName = sqlite3Fts5Strndup(&rc, azArg[2], -1);\n  pRet->bColumnsize = 1;\n  pRet->eDetail = FTS5_DETAIL_FULL;\n#ifdef SQLITE_DEBUG\n  pRet->bPrefixIndex = 1;\n#endif\n  if( rc==SQLITE_OK && sqlite3_stricmp(pRet->zName, FTS5_RANK_NAME)==0 ){\n    *pzErr = sqlite3_mprintf(\"reserved fts5 table name: %s\", pRet->zName);\n    rc = SQLITE_ERROR;\n  }\n\n  for(i=3; rc==SQLITE_OK && i<nArg; i++){\n    const char *zOrig = azArg[i];\n    const char *z;\n    char *zOne = 0;\n    char *zTwo = 0;\n    int bOption = 0;\n    int bMustBeCol = 0;\n\n    z = fts5ConfigGobbleWord(&rc, zOrig, &zOne, &bMustBeCol);\n    z = fts5ConfigSkipWhitespace(z);\n    if( z && *z=='=' ){\n      bOption = 1;\n      z++;\n      if( bMustBeCol ) z = 0;\n    }\n    z = fts5ConfigSkipWhitespace(z);\n    if( z && z[0] ){\n      int bDummy;\n      z = fts5ConfigGobbleWord(&rc, z, &zTwo, &bDummy);\n      if( z && z[0] ) z = 0;\n    }\n\n    if( rc==SQLITE_OK ){\n      if( z==0 ){\n        *pzErr = sqlite3_mprintf(\"parse error in \\\"%s\\\"\", zOrig);\n        rc = SQLITE_ERROR;\n      }else{\n        if( bOption ){\n          rc = fts5ConfigParseSpecial(pGlobal, pRet, zOne, zTwo?zTwo:\"\", pzErr);\n        }else{\n          rc = fts5ConfigParseColumn(pRet, zOne, zTwo, pzErr);\n          zOne = 0;\n        }\n      }\n    }\n\n    sqlite3_free(zOne);\n    sqlite3_free(zTwo);\n  }\n\n  /* If a tokenizer= option was successfully parsed, the tokenizer has\n  ** already been allocated. Otherwise, allocate an instance of the default\n  ** tokenizer (unicode61) now.  */\n  if( rc==SQLITE_OK && pRet->pTok==0 ){\n    rc = fts5ConfigDefaultTokenizer(pGlobal, pRet);\n  }\n\n  /* If no zContent option was specified, fill in the default values. */\n  if( rc==SQLITE_OK && pRet->zContent==0 ){\n    const char *zTail = 0;\n    assert( pRet->eContent==FTS5_CONTENT_NORMAL \n         || pRet->eContent==FTS5_CONTENT_NONE \n    );\n    if( pRet->eContent==FTS5_CONTENT_NORMAL ){\n      zTail = \"content\";\n    }else if( pRet->bColumnsize ){\n      zTail = \"docsize\";\n    }\n\n    if( zTail ){\n      pRet->zContent = sqlite3Fts5Mprintf(\n          &rc, \"%Q.'%q_%s'\", pRet->zDb, pRet->zName, zTail\n      );\n    }\n  }\n\n  if( rc==SQLITE_OK && pRet->zContentRowid==0 ){\n    pRet->zContentRowid = sqlite3Fts5Strndup(&rc, \"rowid\", -1);\n  }\n\n  /* Formulate the zContentExprlist text */\n  if( rc==SQLITE_OK ){\n    rc = fts5ConfigMakeExprlist(pRet);\n  }\n\n  if( rc!=SQLITE_OK ){\n    sqlite3Fts5ConfigFree(pRet);\n    *ppOut = 0;\n  }\n  return rc;\n}\n\n/*\n** Free the configuration object passed as the only argument.\n*/\nstatic void sqlite3Fts5ConfigFree(Fts5Config *pConfig){\n  if( pConfig ){\n    int i;\n    if( pConfig->pTok ){\n      pConfig->pTokApi->xDelete(pConfig->pTok);\n    }\n    sqlite3_free(pConfig->zDb);\n    sqlite3_free(pConfig->zName);\n    for(i=0; i<pConfig->nCol; i++){\n      sqlite3_free(pConfig->azCol[i]);\n    }\n    sqlite3_free(pConfig->azCol);\n    sqlite3_free(pConfig->aPrefix);\n    sqlite3_free(pConfig->zRank);\n    sqlite3_free(pConfig->zRankArgs);\n    sqlite3_free(pConfig->zContent);\n    sqlite3_free(pConfig->zContentRowid);\n    sqlite3_free(pConfig->zContentExprlist);\n    sqlite3_free(pConfig);\n  }\n}\n\n/*\n** Call sqlite3_declare_vtab() based on the contents of the configuration\n** object passed as the only argument. Return SQLITE_OK if successful, or\n** an SQLite error code if an error occurs.\n*/\nstatic int sqlite3Fts5ConfigDeclareVtab(Fts5Config *pConfig){\n  int i;\n  int rc = SQLITE_OK;\n  char *zSql;\n\n  zSql = sqlite3Fts5Mprintf(&rc, \"CREATE TABLE x(\");\n  for(i=0; zSql && i<pConfig->nCol; i++){\n    const char *zSep = (i==0?\"\":\", \");\n    zSql = sqlite3Fts5Mprintf(&rc, \"%z%s%Q\", zSql, zSep, pConfig->azCol[i]);\n  }\n  zSql = sqlite3Fts5Mprintf(&rc, \"%z, %Q HIDDEN, %s HIDDEN)\", \n      zSql, pConfig->zName, FTS5_RANK_NAME\n  );\n\n  assert( zSql || rc==SQLITE_NOMEM );\n  if( zSql ){\n    rc = sqlite3_declare_vtab(pConfig->db, zSql);\n    sqlite3_free(zSql);\n  }\n  \n  return rc;\n}\n\n/*\n** Tokenize the text passed via the second and third arguments.\n**\n** The callback is invoked once for each token in the input text. The\n** arguments passed to it are, in order:\n**\n**     void *pCtx          // Copy of 4th argument to sqlite3Fts5Tokenize()\n**     const char *pToken  // Pointer to buffer containing token\n**     int nToken          // Size of token in bytes\n**     int iStart          // Byte offset of start of token within input text\n**     int iEnd            // Byte offset of end of token within input text\n**     int iPos            // Position of token in input (first token is 0)\n**\n** If the callback returns a non-zero value the tokenization is abandoned\n** and no further callbacks are issued. \n**\n** This function returns SQLITE_OK if successful or an SQLite error code\n** if an error occurs. If the tokenization was abandoned early because\n** the callback returned SQLITE_DONE, this is not an error and this function\n** still returns SQLITE_OK. Or, if the tokenization was abandoned early\n** because the callback returned another non-zero value, it is assumed\n** to be an SQLite error code and returned to the caller.\n*/\nstatic int sqlite3Fts5Tokenize(\n  Fts5Config *pConfig,            /* FTS5 Configuration object */\n  int flags,                      /* FTS5_TOKENIZE_* flags */\n  const char *pText, int nText,   /* Text to tokenize */\n  void *pCtx,                     /* Context passed to xToken() */\n  int (*xToken)(void*, int, const char*, int, int, int)    /* Callback */\n){\n  if( pText==0 ) return SQLITE_OK;\n  return pConfig->pTokApi->xTokenize(\n      pConfig->pTok, pCtx, flags, pText, nText, xToken\n  );\n}\n\n/*\n** Argument pIn points to the first character in what is expected to be\n** a comma-separated list of SQL literals followed by a ')' character.\n** If it actually is this, return a pointer to the ')'. Otherwise, return\n** NULL to indicate a parse error.\n*/\nstatic const char *fts5ConfigSkipArgs(const char *pIn){\n  const char *p = pIn;\n  \n  while( 1 ){\n    p = fts5ConfigSkipWhitespace(p);\n    p = fts5ConfigSkipLiteral(p);\n    p = fts5ConfigSkipWhitespace(p);\n    if( p==0 || *p==')' ) break;\n    if( *p!=',' ){\n      p = 0;\n      break;\n    }\n    p++;\n  }\n\n  return p;\n}\n\n/*\n** Parameter zIn contains a rank() function specification. The format of \n** this is:\n**\n**   + Bareword (function name)\n**   + Open parenthesis - \"(\"\n**   + Zero or more SQL literals in a comma separated list\n**   + Close parenthesis - \")\"\n*/\nstatic int sqlite3Fts5ConfigParseRank(\n  const char *zIn,                /* Input string */\n  char **pzRank,                  /* OUT: Rank function name */\n  char **pzRankArgs               /* OUT: Rank function arguments */\n){\n  const char *p = zIn;\n  const char *pRank;\n  char *zRank = 0;\n  char *zRankArgs = 0;\n  int rc = SQLITE_OK;\n\n  *pzRank = 0;\n  *pzRankArgs = 0;\n\n  if( p==0 ){\n    rc = SQLITE_ERROR;\n  }else{\n    p = fts5ConfigSkipWhitespace(p);\n    pRank = p;\n    p = fts5ConfigSkipBareword(p);\n\n    if( p ){\n      zRank = sqlite3Fts5MallocZero(&rc, 1 + p - pRank);\n      if( zRank ) memcpy(zRank, pRank, p-pRank);\n    }else{\n      rc = SQLITE_ERROR;\n    }\n\n    if( rc==SQLITE_OK ){\n      p = fts5ConfigSkipWhitespace(p);\n      if( *p!='(' ) rc = SQLITE_ERROR;\n      p++;\n    }\n    if( rc==SQLITE_OK ){\n      const char *pArgs; \n      p = fts5ConfigSkipWhitespace(p);\n      pArgs = p;\n      if( *p!=')' ){\n        p = fts5ConfigSkipArgs(p);\n        if( p==0 ){\n          rc = SQLITE_ERROR;\n        }else{\n          zRankArgs = sqlite3Fts5MallocZero(&rc, 1 + p - pArgs);\n          if( zRankArgs ) memcpy(zRankArgs, pArgs, p-pArgs);\n        }\n      }\n    }\n  }\n\n  if( rc!=SQLITE_OK ){\n    sqlite3_free(zRank);\n    assert( zRankArgs==0 );\n  }else{\n    *pzRank = zRank;\n    *pzRankArgs = zRankArgs;\n  }\n  return rc;\n}\n\nstatic int sqlite3Fts5ConfigSetValue(\n  Fts5Config *pConfig, \n  const char *zKey, \n  sqlite3_value *pVal,\n  int *pbBadkey\n){\n  int rc = SQLITE_OK;\n\n  if( 0==sqlite3_stricmp(zKey, \"pgsz\") ){\n    int pgsz = 0;\n    if( SQLITE_INTEGER==sqlite3_value_numeric_type(pVal) ){\n      pgsz = sqlite3_value_int(pVal);\n    }\n    if( pgsz<=0 || pgsz>FTS5_MAX_PAGE_SIZE ){\n      *pbBadkey = 1;\n    }else{\n      pConfig->pgsz = pgsz;\n    }\n  }\n\n  else if( 0==sqlite3_stricmp(zKey, \"hashsize\") ){\n    int nHashSize = -1;\n    if( SQLITE_INTEGER==sqlite3_value_numeric_type(pVal) ){\n      nHashSize = sqlite3_value_int(pVal);\n    }\n    if( nHashSize<=0 ){\n      *pbBadkey = 1;\n    }else{\n      pConfig->nHashSize = nHashSize;\n    }\n  }\n\n  else if( 0==sqlite3_stricmp(zKey, \"automerge\") ){\n    int nAutomerge = -1;\n    if( SQLITE_INTEGER==sqlite3_value_numeric_type(pVal) ){\n      nAutomerge = sqlite3_value_int(pVal);\n    }\n    if( nAutomerge<0 || nAutomerge>64 ){\n      *pbBadkey = 1;\n    }else{\n      if( nAutomerge==1 ) nAutomerge = FTS5_DEFAULT_AUTOMERGE;\n      pConfig->nAutomerge = nAutomerge;\n    }\n  }\n\n  else if( 0==sqlite3_stricmp(zKey, \"usermerge\") ){\n    int nUsermerge = -1;\n    if( SQLITE_INTEGER==sqlite3_value_numeric_type(pVal) ){\n      nUsermerge = sqlite3_value_int(pVal);\n    }\n    if( nUsermerge<2 || nUsermerge>16 ){\n      *pbBadkey = 1;\n    }else{\n      pConfig->nUsermerge = nUsermerge;\n    }\n  }\n\n  else if( 0==sqlite3_stricmp(zKey, \"crisismerge\") ){\n    int nCrisisMerge = -1;\n    if( SQLITE_INTEGER==sqlite3_value_numeric_type(pVal) ){\n      nCrisisMerge = sqlite3_value_int(pVal);\n    }\n    if( nCrisisMerge<0 ){\n      *pbBadkey = 1;\n    }else{\n      if( nCrisisMerge<=1 ) nCrisisMerge = FTS5_DEFAULT_CRISISMERGE;\n      pConfig->nCrisisMerge = nCrisisMerge;\n    }\n  }\n\n  else if( 0==sqlite3_stricmp(zKey, \"rank\") ){\n    const char *zIn = (const char*)sqlite3_value_text(pVal);\n    char *zRank;\n    char *zRankArgs;\n    rc = sqlite3Fts5ConfigParseRank(zIn, &zRank, &zRankArgs);\n    if( rc==SQLITE_OK ){\n      sqlite3_free(pConfig->zRank);\n      sqlite3_free(pConfig->zRankArgs);\n      pConfig->zRank = zRank;\n      pConfig->zRankArgs = zRankArgs;\n    }else if( rc==SQLITE_ERROR ){\n      rc = SQLITE_OK;\n      *pbBadkey = 1;\n    }\n  }else{\n    *pbBadkey = 1;\n  }\n  return rc;\n}\n\n/*\n** Load the contents of the %_config table into memory.\n*/\nstatic int sqlite3Fts5ConfigLoad(Fts5Config *pConfig, int iCookie){\n  const char *zSelect = \"SELECT k, v FROM %Q.'%q_config'\";\n  char *zSql;\n  sqlite3_stmt *p = 0;\n  int rc = SQLITE_OK;\n  int iVersion = 0;\n\n  /* Set default values */\n  pConfig->pgsz = FTS5_DEFAULT_PAGE_SIZE;\n  pConfig->nAutomerge = FTS5_DEFAULT_AUTOMERGE;\n  pConfig->nUsermerge = FTS5_DEFAULT_USERMERGE;\n  pConfig->nCrisisMerge = FTS5_DEFAULT_CRISISMERGE;\n  pConfig->nHashSize = FTS5_DEFAULT_HASHSIZE;\n\n  zSql = sqlite3Fts5Mprintf(&rc, zSelect, pConfig->zDb, pConfig->zName);\n  if( zSql ){\n    rc = sqlite3_prepare_v2(pConfig->db, zSql, -1, &p, 0);\n    sqlite3_free(zSql);\n  }\n\n  assert( rc==SQLITE_OK || p==0 );\n  if( rc==SQLITE_OK ){\n    while( SQLITE_ROW==sqlite3_step(p) ){\n      const char *zK = (const char*)sqlite3_column_text(p, 0);\n      sqlite3_value *pVal = sqlite3_column_value(p, 1);\n      if( 0==sqlite3_stricmp(zK, \"version\") ){\n        iVersion = sqlite3_value_int(pVal);\n      }else{\n        int bDummy = 0;\n        sqlite3Fts5ConfigSetValue(pConfig, zK, pVal, &bDummy);\n      }\n    }\n    rc = sqlite3_finalize(p);\n  }\n  \n  if( rc==SQLITE_OK && iVersion!=FTS5_CURRENT_VERSION ){\n    rc = SQLITE_ERROR;\n    if( pConfig->pzErrmsg ){\n      assert( 0==*pConfig->pzErrmsg );\n      *pConfig->pzErrmsg = sqlite3_mprintf(\n          \"invalid fts5 file format (found %d, expected %d) - run 'rebuild'\",\n          iVersion, FTS5_CURRENT_VERSION\n      );\n    }\n  }\n\n  if( rc==SQLITE_OK ){\n    pConfig->iCookie = iCookie;\n  }\n  return rc;\n}\n\n/*\n** 2014 May 31\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n******************************************************************************\n**\n*/\n\n\n\n/* #include \"fts5Int.h\" */\n/* #include \"fts5parse.h\" */\n\n/*\n** All token types in the generated fts5parse.h file are greater than 0.\n*/\n#define FTS5_EOF 0\n\n#define FTS5_LARGEST_INT64  (0xffffffff|(((i64)0x7fffffff)<<32))\n\ntypedef struct Fts5ExprTerm Fts5ExprTerm;\n\n/*\n** Functions generated by lemon from fts5parse.y.\n*/\nstatic void *sqlite3Fts5ParserAlloc(void *(*mallocProc)(u64));\nstatic void sqlite3Fts5ParserFree(void*, void (*freeProc)(void*));\nstatic void sqlite3Fts5Parser(void*, int, Fts5Token, Fts5Parse*);\n#ifndef NDEBUG\n/* #include <stdio.h> */\nstatic void sqlite3Fts5ParserTrace(FILE*, char*);\n#endif\nstatic int sqlite3Fts5ParserFallback(int);\n\n\nstruct Fts5Expr {\n  Fts5Index *pIndex;\n  Fts5Config *pConfig;\n  Fts5ExprNode *pRoot;\n  int bDesc;                      /* Iterate in descending rowid order */\n  int nPhrase;                    /* Number of phrases in expression */\n  Fts5ExprPhrase **apExprPhrase;  /* Pointers to phrase objects */\n};\n\n/*\n** eType:\n**   Expression node type. Always one of:\n**\n**       FTS5_AND                 (nChild, apChild valid)\n**       FTS5_OR                  (nChild, apChild valid)\n**       FTS5_NOT                 (nChild, apChild valid)\n**       FTS5_STRING              (pNear valid)\n**       FTS5_TERM                (pNear valid)\n*/\nstruct Fts5ExprNode {\n  int eType;                      /* Node type */\n  int bEof;                       /* True at EOF */\n  int bNomatch;                   /* True if entry is not a match */\n\n  /* Next method for this node. */\n  int (*xNext)(Fts5Expr*, Fts5ExprNode*, int, i64);\n\n  i64 iRowid;                     /* Current rowid */\n  Fts5ExprNearset *pNear;         /* For FTS5_STRING - cluster of phrases */\n\n  /* Child nodes. For a NOT node, this array always contains 2 entries. For \n  ** AND or OR nodes, it contains 2 or more entries.  */\n  int nChild;                     /* Number of child nodes */\n  Fts5ExprNode *apChild[1];       /* Array of child nodes */\n};\n\n#define Fts5NodeIsString(p) ((p)->eType==FTS5_TERM || (p)->eType==FTS5_STRING)\n\n/*\n** Invoke the xNext method of an Fts5ExprNode object. This macro should be\n** used as if it has the same signature as the xNext() methods themselves.\n*/\n#define fts5ExprNodeNext(a,b,c,d) (b)->xNext((a), (b), (c), (d))\n\n/*\n** An instance of the following structure represents a single search term\n** or term prefix.\n*/\nstruct Fts5ExprTerm {\n  u8 bPrefix;                     /* True for a prefix term */\n  u8 bFirst;                      /* True if token must be first in column */\n  char *zTerm;                    /* nul-terminated term */\n  Fts5IndexIter *pIter;           /* Iterator for this term */\n  Fts5ExprTerm *pSynonym;         /* Pointer to first in list of synonyms */\n};\n\n/*\n** A phrase. One or more terms that must appear in a contiguous sequence\n** within a document for it to match.\n*/\nstruct Fts5ExprPhrase {\n  Fts5ExprNode *pNode;            /* FTS5_STRING node this phrase is part of */\n  Fts5Buffer poslist;             /* Current position list */\n  int nTerm;                      /* Number of entries in aTerm[] */\n  Fts5ExprTerm aTerm[1];          /* Terms that make up this phrase */\n};\n\n/*\n** One or more phrases that must appear within a certain token distance of\n** each other within each matching document.\n*/\nstruct Fts5ExprNearset {\n  int nNear;                      /* NEAR parameter */\n  Fts5Colset *pColset;            /* Columns to search (NULL -> all columns) */\n  int nPhrase;                    /* Number of entries in aPhrase[] array */\n  Fts5ExprPhrase *apPhrase[1];    /* Array of phrase pointers */\n};\n\n\n/*\n** Parse context.\n*/\nstruct Fts5Parse {\n  Fts5Config *pConfig;\n  char *zErr;\n  int rc;\n  int nPhrase;                    /* Size of apPhrase array */\n  Fts5ExprPhrase **apPhrase;      /* Array of all phrases */\n  Fts5ExprNode *pExpr;            /* Result of a successful parse */\n};\n\nstatic void sqlite3Fts5ParseError(Fts5Parse *pParse, const char *zFmt, ...){\n  va_list ap;\n  va_start(ap, zFmt);\n  if( pParse->rc==SQLITE_OK ){\n    pParse->zErr = sqlite3_vmprintf(zFmt, ap);\n    pParse->rc = SQLITE_ERROR;\n  }\n  va_end(ap);\n}\n\nstatic int fts5ExprIsspace(char t){\n  return t==' ' || t=='\\t' || t=='\\n' || t=='\\r';\n}\n\n/*\n** Read the first token from the nul-terminated string at *pz.\n*/\nstatic int fts5ExprGetToken(\n  Fts5Parse *pParse, \n  const char **pz,                /* IN/OUT: Pointer into buffer */\n  Fts5Token *pToken\n){\n  const char *z = *pz;\n  int tok;\n\n  /* Skip past any whitespace */\n  while( fts5ExprIsspace(*z) ) z++;\n\n  pToken->p = z;\n  pToken->n = 1;\n  switch( *z ){\n    case '(':  tok = FTS5_LP;    break;\n    case ')':  tok = FTS5_RP;    break;\n    case '{':  tok = FTS5_LCP;   break;\n    case '}':  tok = FTS5_RCP;   break;\n    case ':':  tok = FTS5_COLON; break;\n    case ',':  tok = FTS5_COMMA; break;\n    case '+':  tok = FTS5_PLUS;  break;\n    case '*':  tok = FTS5_STAR;  break;\n    case '-':  tok = FTS5_MINUS; break;\n    case '^':  tok = FTS5_CARET; break;\n    case '\\0': tok = FTS5_EOF;   break;\n\n    case '\"': {\n      const char *z2;\n      tok = FTS5_STRING;\n\n      for(z2=&z[1]; 1; z2++){\n        if( z2[0]=='\"' ){\n          z2++;\n          if( z2[0]!='\"' ) break;\n        }\n        if( z2[0]=='\\0' ){\n          sqlite3Fts5ParseError(pParse, \"unterminated string\");\n          return FTS5_EOF;\n        }\n      }\n      pToken->n = (z2 - z);\n      break;\n    }\n\n    default: {\n      const char *z2;\n      if( sqlite3Fts5IsBareword(z[0])==0 ){\n        sqlite3Fts5ParseError(pParse, \"fts5: syntax error near \\\"%.1s\\\"\", z);\n        return FTS5_EOF;\n      }\n      tok = FTS5_STRING;\n      for(z2=&z[1]; sqlite3Fts5IsBareword(*z2); z2++);\n      pToken->n = (z2 - z);\n      if( pToken->n==2 && memcmp(pToken->p, \"OR\", 2)==0 )  tok = FTS5_OR;\n      if( pToken->n==3 && memcmp(pToken->p, \"NOT\", 3)==0 ) tok = FTS5_NOT;\n      if( pToken->n==3 && memcmp(pToken->p, \"AND\", 3)==0 ) tok = FTS5_AND;\n      break;\n    }\n  }\n\n  *pz = &pToken->p[pToken->n];\n  return tok;\n}\n\nstatic void *fts5ParseAlloc(u64 t){ return sqlite3_malloc64((sqlite3_int64)t);}\nstatic void fts5ParseFree(void *p){ sqlite3_free(p); }\n\nstatic int sqlite3Fts5ExprNew(\n  Fts5Config *pConfig,            /* FTS5 Configuration */\n  int iCol,\n  const char *zExpr,              /* Expression text */\n  Fts5Expr **ppNew, \n  char **pzErr\n){\n  Fts5Parse sParse;\n  Fts5Token token;\n  const char *z = zExpr;\n  int t;                          /* Next token type */\n  void *pEngine;\n  Fts5Expr *pNew;\n\n  *ppNew = 0;\n  *pzErr = 0;\n  memset(&sParse, 0, sizeof(sParse));\n  pEngine = sqlite3Fts5ParserAlloc(fts5ParseAlloc);\n  if( pEngine==0 ){ return SQLITE_NOMEM; }\n  sParse.pConfig = pConfig;\n\n  do {\n    t = fts5ExprGetToken(&sParse, &z, &token);\n    sqlite3Fts5Parser(pEngine, t, token, &sParse);\n  }while( sParse.rc==SQLITE_OK && t!=FTS5_EOF );\n  sqlite3Fts5ParserFree(pEngine, fts5ParseFree);\n\n  /* If the LHS of the MATCH expression was a user column, apply the\n  ** implicit column-filter.  */\n  if( iCol<pConfig->nCol && sParse.pExpr && sParse.rc==SQLITE_OK ){\n    int n = sizeof(Fts5Colset);\n    Fts5Colset *pColset = (Fts5Colset*)sqlite3Fts5MallocZero(&sParse.rc, n);\n    if( pColset ){\n      pColset->nCol = 1;\n      pColset->aiCol[0] = iCol;\n      sqlite3Fts5ParseSetColset(&sParse, sParse.pExpr, pColset);\n    }\n  }\n\n  assert( sParse.rc!=SQLITE_OK || sParse.zErr==0 );\n  if( sParse.rc==SQLITE_OK ){\n    *ppNew = pNew = sqlite3_malloc(sizeof(Fts5Expr));\n    if( pNew==0 ){\n      sParse.rc = SQLITE_NOMEM;\n      sqlite3Fts5ParseNodeFree(sParse.pExpr);\n    }else{\n      if( !sParse.pExpr ){\n        const int nByte = sizeof(Fts5ExprNode);\n        pNew->pRoot = (Fts5ExprNode*)sqlite3Fts5MallocZero(&sParse.rc, nByte);\n        if( pNew->pRoot ){\n          pNew->pRoot->bEof = 1;\n        }\n      }else{\n        pNew->pRoot = sParse.pExpr;\n      }\n      pNew->pIndex = 0;\n      pNew->pConfig = pConfig;\n      pNew->apExprPhrase = sParse.apPhrase;\n      pNew->nPhrase = sParse.nPhrase;\n      sParse.apPhrase = 0;\n    }\n  }else{\n    sqlite3Fts5ParseNodeFree(sParse.pExpr);\n  }\n\n  sqlite3_free(sParse.apPhrase);\n  *pzErr = sParse.zErr;\n  return sParse.rc;\n}\n\n/*\n** Free the expression node object passed as the only argument.\n*/\nstatic void sqlite3Fts5ParseNodeFree(Fts5ExprNode *p){\n  if( p ){\n    int i;\n    for(i=0; i<p->nChild; i++){\n      sqlite3Fts5ParseNodeFree(p->apChild[i]);\n    }\n    sqlite3Fts5ParseNearsetFree(p->pNear);\n    sqlite3_free(p);\n  }\n}\n\n/*\n** Free the expression object passed as the only argument.\n*/\nstatic void sqlite3Fts5ExprFree(Fts5Expr *p){\n  if( p ){\n    sqlite3Fts5ParseNodeFree(p->pRoot);\n    sqlite3_free(p->apExprPhrase);\n    sqlite3_free(p);\n  }\n}\n\n/*\n** Argument pTerm must be a synonym iterator. Return the current rowid\n** that it points to.\n*/\nstatic i64 fts5ExprSynonymRowid(Fts5ExprTerm *pTerm, int bDesc, int *pbEof){\n  i64 iRet = 0;\n  int bRetValid = 0;\n  Fts5ExprTerm *p;\n\n  assert( pTerm->pSynonym );\n  assert( bDesc==0 || bDesc==1 );\n  for(p=pTerm; p; p=p->pSynonym){\n    if( 0==sqlite3Fts5IterEof(p->pIter) ){\n      i64 iRowid = p->pIter->iRowid;\n      if( bRetValid==0 || (bDesc!=(iRowid<iRet)) ){\n        iRet = iRowid;\n        bRetValid = 1;\n      }\n    }\n  }\n\n  if( pbEof && bRetValid==0 ) *pbEof = 1;\n  return iRet;\n}\n\n/*\n** Argument pTerm must be a synonym iterator.\n*/\nstatic int fts5ExprSynonymList(\n  Fts5ExprTerm *pTerm, \n  i64 iRowid,\n  Fts5Buffer *pBuf,               /* Use this buffer for space if required */\n  u8 **pa, int *pn\n){\n  Fts5PoslistReader aStatic[4];\n  Fts5PoslistReader *aIter = aStatic;\n  int nIter = 0;\n  int nAlloc = 4;\n  int rc = SQLITE_OK;\n  Fts5ExprTerm *p;\n\n  assert( pTerm->pSynonym );\n  for(p=pTerm; p; p=p->pSynonym){\n    Fts5IndexIter *pIter = p->pIter;\n    if( sqlite3Fts5IterEof(pIter)==0 && pIter->iRowid==iRowid ){\n      if( pIter->nData==0 ) continue;\n      if( nIter==nAlloc ){\n        sqlite3_int64 nByte = sizeof(Fts5PoslistReader) * nAlloc * 2;\n        Fts5PoslistReader *aNew = (Fts5PoslistReader*)sqlite3_malloc64(nByte);\n        if( aNew==0 ){\n          rc = SQLITE_NOMEM;\n          goto synonym_poslist_out;\n        }\n        memcpy(aNew, aIter, sizeof(Fts5PoslistReader) * nIter);\n        nAlloc = nAlloc*2;\n        if( aIter!=aStatic ) sqlite3_free(aIter);\n        aIter = aNew;\n      }\n      sqlite3Fts5PoslistReaderInit(pIter->pData, pIter->nData, &aIter[nIter]);\n      assert( aIter[nIter].bEof==0 );\n      nIter++;\n    }\n  }\n\n  if( nIter==1 ){\n    *pa = (u8*)aIter[0].a;\n    *pn = aIter[0].n;\n  }else{\n    Fts5PoslistWriter writer = {0};\n    i64 iPrev = -1;\n    fts5BufferZero(pBuf);\n    while( 1 ){\n      int i;\n      i64 iMin = FTS5_LARGEST_INT64;\n      for(i=0; i<nIter; i++){\n        if( aIter[i].bEof==0 ){\n          if( aIter[i].iPos==iPrev ){\n            if( sqlite3Fts5PoslistReaderNext(&aIter[i]) ) continue;\n          }\n          if( aIter[i].iPos<iMin ){\n            iMin = aIter[i].iPos;\n          }\n        }\n      }\n      if( iMin==FTS5_LARGEST_INT64 || rc!=SQLITE_OK ) break;\n      rc = sqlite3Fts5PoslistWriterAppend(pBuf, &writer, iMin);\n      iPrev = iMin;\n    }\n    if( rc==SQLITE_OK ){\n      *pa = pBuf->p;\n      *pn = pBuf->n;\n    }\n  }\n\n synonym_poslist_out:\n  if( aIter!=aStatic ) sqlite3_free(aIter);\n  return rc;\n}\n\n\n/*\n** All individual term iterators in pPhrase are guaranteed to be valid and\n** pointing to the same rowid when this function is called. This function \n** checks if the current rowid really is a match, and if so populates\n** the pPhrase->poslist buffer accordingly. Output parameter *pbMatch\n** is set to true if this is really a match, or false otherwise.\n**\n** SQLITE_OK is returned if an error occurs, or an SQLite error code \n** otherwise. It is not considered an error code if the current rowid is \n** not a match.\n*/\nstatic int fts5ExprPhraseIsMatch(\n  Fts5ExprNode *pNode,            /* Node pPhrase belongs to */\n  Fts5ExprPhrase *pPhrase,        /* Phrase object to initialize */\n  int *pbMatch                    /* OUT: Set to true if really a match */\n){\n  Fts5PoslistWriter writer = {0};\n  Fts5PoslistReader aStatic[4];\n  Fts5PoslistReader *aIter = aStatic;\n  int i;\n  int rc = SQLITE_OK;\n  int bFirst = pPhrase->aTerm[0].bFirst;\n  \n  fts5BufferZero(&pPhrase->poslist);\n\n  /* If the aStatic[] array is not large enough, allocate a large array\n  ** using sqlite3_malloc(). This approach could be improved upon. */\n  if( pPhrase->nTerm>ArraySize(aStatic) ){\n    sqlite3_int64 nByte = sizeof(Fts5PoslistReader) * pPhrase->nTerm;\n    aIter = (Fts5PoslistReader*)sqlite3_malloc64(nByte);\n    if( !aIter ) return SQLITE_NOMEM;\n  }\n  memset(aIter, 0, sizeof(Fts5PoslistReader) * pPhrase->nTerm);\n\n  /* Initialize a term iterator for each term in the phrase */\n  for(i=0; i<pPhrase->nTerm; i++){\n    Fts5ExprTerm *pTerm = &pPhrase->aTerm[i];\n    int n = 0;\n    int bFlag = 0;\n    u8 *a = 0;\n    if( pTerm->pSynonym ){\n      Fts5Buffer buf = {0, 0, 0};\n      rc = fts5ExprSynonymList(pTerm, pNode->iRowid, &buf, &a, &n);\n      if( rc ){\n        sqlite3_free(a);\n        goto ismatch_out;\n      }\n      if( a==buf.p ) bFlag = 1;\n    }else{\n      a = (u8*)pTerm->pIter->pData;\n      n = pTerm->pIter->nData;\n    }\n    sqlite3Fts5PoslistReaderInit(a, n, &aIter[i]);\n    aIter[i].bFlag = (u8)bFlag;\n    if( aIter[i].bEof ) goto ismatch_out;\n  }\n\n  while( 1 ){\n    int bMatch;\n    i64 iPos = aIter[0].iPos;\n    do {\n      bMatch = 1;\n      for(i=0; i<pPhrase->nTerm; i++){\n        Fts5PoslistReader *pPos = &aIter[i];\n        i64 iAdj = iPos + i;\n        if( pPos->iPos!=iAdj ){\n          bMatch = 0;\n          while( pPos->iPos<iAdj ){\n            if( sqlite3Fts5PoslistReaderNext(pPos) ) goto ismatch_out;\n          }\n          if( pPos->iPos>iAdj ) iPos = pPos->iPos-i;\n        }\n      }\n    }while( bMatch==0 );\n\n    /* Append position iPos to the output */\n    if( bFirst==0 || FTS5_POS2OFFSET(iPos)==0 ){\n      rc = sqlite3Fts5PoslistWriterAppend(&pPhrase->poslist, &writer, iPos);\n      if( rc!=SQLITE_OK ) goto ismatch_out;\n    }\n\n    for(i=0; i<pPhrase->nTerm; i++){\n      if( sqlite3Fts5PoslistReaderNext(&aIter[i]) ) goto ismatch_out;\n    }\n  }\n\n ismatch_out:\n  *pbMatch = (pPhrase->poslist.n>0);\n  for(i=0; i<pPhrase->nTerm; i++){\n    if( aIter[i].bFlag ) sqlite3_free((u8*)aIter[i].a);\n  }\n  if( aIter!=aStatic ) sqlite3_free(aIter);\n  return rc;\n}\n\ntypedef struct Fts5LookaheadReader Fts5LookaheadReader;\nstruct Fts5LookaheadReader {\n  const u8 *a;                    /* Buffer containing position list */\n  int n;                          /* Size of buffer a[] in bytes */\n  int i;                          /* Current offset in position list */\n  i64 iPos;                       /* Current position */\n  i64 iLookahead;                 /* Next position */\n};\n\n#define FTS5_LOOKAHEAD_EOF (((i64)1) << 62)\n\nstatic int fts5LookaheadReaderNext(Fts5LookaheadReader *p){\n  p->iPos = p->iLookahead;\n  if( sqlite3Fts5PoslistNext64(p->a, p->n, &p->i, &p->iLookahead) ){\n    p->iLookahead = FTS5_LOOKAHEAD_EOF;\n  }\n  return (p->iPos==FTS5_LOOKAHEAD_EOF);\n}\n\nstatic int fts5LookaheadReaderInit(\n  const u8 *a, int n,             /* Buffer to read position list from */\n  Fts5LookaheadReader *p          /* Iterator object to initialize */\n){\n  memset(p, 0, sizeof(Fts5LookaheadReader));\n  p->a = a;\n  p->n = n;\n  fts5LookaheadReaderNext(p);\n  return fts5LookaheadReaderNext(p);\n}\n\ntypedef struct Fts5NearTrimmer Fts5NearTrimmer;\nstruct Fts5NearTrimmer {\n  Fts5LookaheadReader reader;     /* Input iterator */\n  Fts5PoslistWriter writer;       /* Writer context */\n  Fts5Buffer *pOut;               /* Output poslist */\n};\n\n/*\n** The near-set object passed as the first argument contains more than\n** one phrase. All phrases currently point to the same row. The\n** Fts5ExprPhrase.poslist buffers are populated accordingly. This function\n** tests if the current row contains instances of each phrase sufficiently\n** close together to meet the NEAR constraint. Non-zero is returned if it\n** does, or zero otherwise.\n**\n** If in/out parameter (*pRc) is set to other than SQLITE_OK when this\n** function is called, it is a no-op. Or, if an error (e.g. SQLITE_NOMEM)\n** occurs within this function (*pRc) is set accordingly before returning.\n** The return value is undefined in both these cases.\n** \n** If no error occurs and non-zero (a match) is returned, the position-list\n** of each phrase object is edited to contain only those entries that\n** meet the constraint before returning.\n*/\nstatic int fts5ExprNearIsMatch(int *pRc, Fts5ExprNearset *pNear){\n  Fts5NearTrimmer aStatic[4];\n  Fts5NearTrimmer *a = aStatic;\n  Fts5ExprPhrase **apPhrase = pNear->apPhrase;\n\n  int i;\n  int rc = *pRc;\n  int bMatch;\n\n  assert( pNear->nPhrase>1 );\n\n  /* If the aStatic[] array is not large enough, allocate a large array\n  ** using sqlite3_malloc(). This approach could be improved upon. */\n  if( pNear->nPhrase>ArraySize(aStatic) ){\n    sqlite3_int64 nByte = sizeof(Fts5NearTrimmer) * pNear->nPhrase;\n    a = (Fts5NearTrimmer*)sqlite3Fts5MallocZero(&rc, nByte);\n  }else{\n    memset(aStatic, 0, sizeof(aStatic));\n  }\n  if( rc!=SQLITE_OK ){\n    *pRc = rc;\n    return 0;\n  }\n\n  /* Initialize a lookahead iterator for each phrase. After passing the\n  ** buffer and buffer size to the lookaside-reader init function, zero\n  ** the phrase poslist buffer. The new poslist for the phrase (containing\n  ** the same entries as the original with some entries removed on account \n  ** of the NEAR constraint) is written over the original even as it is\n  ** being read. This is safe as the entries for the new poslist are a\n  ** subset of the old, so it is not possible for data yet to be read to\n  ** be overwritten.  */\n  for(i=0; i<pNear->nPhrase; i++){\n    Fts5Buffer *pPoslist = &apPhrase[i]->poslist;\n    fts5LookaheadReaderInit(pPoslist->p, pPoslist->n, &a[i].reader);\n    pPoslist->n = 0;\n    a[i].pOut = pPoslist;\n  }\n\n  while( 1 ){\n    int iAdv;\n    i64 iMin;\n    i64 iMax;\n\n    /* This block advances the phrase iterators until they point to a set of\n    ** entries that together comprise a match.  */\n    iMax = a[0].reader.iPos;\n    do {\n      bMatch = 1;\n      for(i=0; i<pNear->nPhrase; i++){\n        Fts5LookaheadReader *pPos = &a[i].reader;\n        iMin = iMax - pNear->apPhrase[i]->nTerm - pNear->nNear;\n        if( pPos->iPos<iMin || pPos->iPos>iMax ){\n          bMatch = 0;\n          while( pPos->iPos<iMin ){\n            if( fts5LookaheadReaderNext(pPos) ) goto ismatch_out;\n          }\n          if( pPos->iPos>iMax ) iMax = pPos->iPos;\n        }\n      }\n    }while( bMatch==0 );\n\n    /* Add an entry to each output position list */\n    for(i=0; i<pNear->nPhrase; i++){\n      i64 iPos = a[i].reader.iPos;\n      Fts5PoslistWriter *pWriter = &a[i].writer;\n      if( a[i].pOut->n==0 || iPos!=pWriter->iPrev ){\n        sqlite3Fts5PoslistWriterAppend(a[i].pOut, pWriter, iPos);\n      }\n    }\n\n    iAdv = 0;\n    iMin = a[0].reader.iLookahead;\n    for(i=0; i<pNear->nPhrase; i++){\n      if( a[i].reader.iLookahead < iMin ){\n        iMin = a[i].reader.iLookahead;\n        iAdv = i;\n      }\n    }\n    if( fts5LookaheadReaderNext(&a[iAdv].reader) ) goto ismatch_out;\n  }\n\n  ismatch_out: {\n    int bRet = a[0].pOut->n>0;\n    *pRc = rc;\n    if( a!=aStatic ) sqlite3_free(a);\n    return bRet;\n  }\n}\n\n/*\n** Advance iterator pIter until it points to a value equal to or laster\n** than the initial value of *piLast. If this means the iterator points\n** to a value laster than *piLast, update *piLast to the new lastest value.\n**\n** If the iterator reaches EOF, set *pbEof to true before returning. If\n** an error occurs, set *pRc to an error code. If either *pbEof or *pRc\n** are set, return a non-zero value. Otherwise, return zero.\n*/\nstatic int fts5ExprAdvanceto(\n  Fts5IndexIter *pIter,           /* Iterator to advance */\n  int bDesc,                      /* True if iterator is \"rowid DESC\" */\n  i64 *piLast,                    /* IN/OUT: Lastest rowid seen so far */\n  int *pRc,                       /* OUT: Error code */\n  int *pbEof                      /* OUT: Set to true if EOF */\n){\n  i64 iLast = *piLast;\n  i64 iRowid;\n\n  iRowid = pIter->iRowid;\n  if( (bDesc==0 && iLast>iRowid) || (bDesc && iLast<iRowid) ){\n    int rc = sqlite3Fts5IterNextFrom(pIter, iLast);\n    if( rc || sqlite3Fts5IterEof(pIter) ){\n      *pRc = rc;\n      *pbEof = 1;\n      return 1;\n    }\n    iRowid = pIter->iRowid;\n    assert( (bDesc==0 && iRowid>=iLast) || (bDesc==1 && iRowid<=iLast) );\n  }\n  *piLast = iRowid;\n\n  return 0;\n}\n\nstatic int fts5ExprSynonymAdvanceto(\n  Fts5ExprTerm *pTerm,            /* Term iterator to advance */\n  int bDesc,                      /* True if iterator is \"rowid DESC\" */\n  i64 *piLast,                    /* IN/OUT: Lastest rowid seen so far */\n  int *pRc                        /* OUT: Error code */\n){\n  int rc = SQLITE_OK;\n  i64 iLast = *piLast;\n  Fts5ExprTerm *p;\n  int bEof = 0;\n\n  for(p=pTerm; rc==SQLITE_OK && p; p=p->pSynonym){\n    if( sqlite3Fts5IterEof(p->pIter)==0 ){\n      i64 iRowid = p->pIter->iRowid;\n      if( (bDesc==0 && iLast>iRowid) || (bDesc && iLast<iRowid) ){\n        rc = sqlite3Fts5IterNextFrom(p->pIter, iLast);\n      }\n    }\n  }\n\n  if( rc!=SQLITE_OK ){\n    *pRc = rc;\n    bEof = 1;\n  }else{\n    *piLast = fts5ExprSynonymRowid(pTerm, bDesc, &bEof);\n  }\n  return bEof;\n}\n\n\nstatic int fts5ExprNearTest(\n  int *pRc,\n  Fts5Expr *pExpr,                /* Expression that pNear is a part of */\n  Fts5ExprNode *pNode             /* The \"NEAR\" node (FTS5_STRING) */\n){\n  Fts5ExprNearset *pNear = pNode->pNear;\n  int rc = *pRc;\n\n  if( pExpr->pConfig->eDetail!=FTS5_DETAIL_FULL ){\n    Fts5ExprTerm *pTerm;\n    Fts5ExprPhrase *pPhrase = pNear->apPhrase[0];\n    pPhrase->poslist.n = 0;\n    for(pTerm=&pPhrase->aTerm[0]; pTerm; pTerm=pTerm->pSynonym){\n      Fts5IndexIter *pIter = pTerm->pIter;\n      if( sqlite3Fts5IterEof(pIter)==0 ){\n        if( pIter->iRowid==pNode->iRowid && pIter->nData>0 ){\n          pPhrase->poslist.n = 1;\n        }\n      }\n    }\n    return pPhrase->poslist.n;\n  }else{\n    int i;\n\n    /* Check that each phrase in the nearset matches the current row.\n    ** Populate the pPhrase->poslist buffers at the same time. If any\n    ** phrase is not a match, break out of the loop early.  */\n    for(i=0; rc==SQLITE_OK && i<pNear->nPhrase; i++){\n      Fts5ExprPhrase *pPhrase = pNear->apPhrase[i];\n      if( pPhrase->nTerm>1 || pPhrase->aTerm[0].pSynonym \n       || pNear->pColset || pPhrase->aTerm[0].bFirst\n      ){\n        int bMatch = 0;\n        rc = fts5ExprPhraseIsMatch(pNode, pPhrase, &bMatch);\n        if( bMatch==0 ) break;\n      }else{\n        Fts5IndexIter *pIter = pPhrase->aTerm[0].pIter;\n        fts5BufferSet(&rc, &pPhrase->poslist, pIter->nData, pIter->pData);\n      }\n    }\n\n    *pRc = rc;\n    if( i==pNear->nPhrase && (i==1 || fts5ExprNearIsMatch(pRc, pNear)) ){\n      return 1;\n    }\n    return 0;\n  }\n}\n\n\n/*\n** Initialize all term iterators in the pNear object. If any term is found\n** to match no documents at all, return immediately without initializing any\n** further iterators.\n**\n** If an error occurs, return an SQLite error code. Otherwise, return\n** SQLITE_OK. It is not considered an error if some term matches zero\n** documents.\n*/\nstatic int fts5ExprNearInitAll(\n  Fts5Expr *pExpr,\n  Fts5ExprNode *pNode\n){\n  Fts5ExprNearset *pNear = pNode->pNear;\n  int i;\n\n  assert( pNode->bNomatch==0 );\n  for(i=0; i<pNear->nPhrase; i++){\n    Fts5ExprPhrase *pPhrase = pNear->apPhrase[i];\n    if( pPhrase->nTerm==0 ){\n      pNode->bEof = 1;\n      return SQLITE_OK;\n    }else{\n      int j;\n      for(j=0; j<pPhrase->nTerm; j++){\n        Fts5ExprTerm *pTerm = &pPhrase->aTerm[j];\n        Fts5ExprTerm *p;\n        int bHit = 0;\n\n        for(p=pTerm; p; p=p->pSynonym){\n          int rc;\n          if( p->pIter ){\n            sqlite3Fts5IterClose(p->pIter);\n            p->pIter = 0;\n          }\n          rc = sqlite3Fts5IndexQuery(\n              pExpr->pIndex, p->zTerm, (int)strlen(p->zTerm),\n              (pTerm->bPrefix ? FTS5INDEX_QUERY_PREFIX : 0) |\n              (pExpr->bDesc ? FTS5INDEX_QUERY_DESC : 0),\n              pNear->pColset,\n              &p->pIter\n          );\n          assert( (rc==SQLITE_OK)==(p->pIter!=0) );\n          if( rc!=SQLITE_OK ) return rc;\n          if( 0==sqlite3Fts5IterEof(p->pIter) ){\n            bHit = 1;\n          }\n        }\n\n        if( bHit==0 ){\n          pNode->bEof = 1;\n          return SQLITE_OK;\n        }\n      }\n    }\n  }\n\n  pNode->bEof = 0;\n  return SQLITE_OK;\n}\n\n/*\n** If pExpr is an ASC iterator, this function returns a value with the\n** same sign as:\n**\n**   (iLhs - iRhs)\n**\n** Otherwise, if this is a DESC iterator, the opposite is returned:\n**\n**   (iRhs - iLhs)\n*/\nstatic int fts5RowidCmp(\n  Fts5Expr *pExpr,\n  i64 iLhs,\n  i64 iRhs\n){\n  assert( pExpr->bDesc==0 || pExpr->bDesc==1 );\n  if( pExpr->bDesc==0 ){\n    if( iLhs<iRhs ) return -1;\n    return (iLhs > iRhs);\n  }else{\n    if( iLhs>iRhs ) return -1;\n    return (iLhs < iRhs);\n  }\n}\n\nstatic void fts5ExprSetEof(Fts5ExprNode *pNode){\n  int i;\n  pNode->bEof = 1;\n  pNode->bNomatch = 0;\n  for(i=0; i<pNode->nChild; i++){\n    fts5ExprSetEof(pNode->apChild[i]);\n  }\n}\n\nstatic void fts5ExprNodeZeroPoslist(Fts5ExprNode *pNode){\n  if( pNode->eType==FTS5_STRING || pNode->eType==FTS5_TERM ){\n    Fts5ExprNearset *pNear = pNode->pNear;\n    int i;\n    for(i=0; i<pNear->nPhrase; i++){\n      Fts5ExprPhrase *pPhrase = pNear->apPhrase[i];\n      pPhrase->poslist.n = 0;\n    }\n  }else{\n    int i;\n    for(i=0; i<pNode->nChild; i++){\n      fts5ExprNodeZeroPoslist(pNode->apChild[i]);\n    }\n  }\n}\n\n\n\n/*\n** Compare the values currently indicated by the two nodes as follows:\n**\n**    res = (*p1) - (*p2)\n**\n** Nodes that point to values that come later in the iteration order are\n** considered to be larger. Nodes at EOF are the largest of all.\n**\n** This means that if the iteration order is ASC, then numerically larger\n** rowids are considered larger. Or if it is the default DESC, numerically\n** smaller rowids are larger.\n*/\nstatic int fts5NodeCompare(\n  Fts5Expr *pExpr,\n  Fts5ExprNode *p1, \n  Fts5ExprNode *p2\n){\n  if( p2->bEof ) return -1;\n  if( p1->bEof ) return +1;\n  return fts5RowidCmp(pExpr, p1->iRowid, p2->iRowid);\n}\n\n/*\n** All individual term iterators in pNear are guaranteed to be valid when\n** this function is called. This function checks if all term iterators\n** point to the same rowid, and if not, advances them until they do.\n** If an EOF is reached before this happens, *pbEof is set to true before\n** returning.\n**\n** SQLITE_OK is returned if an error occurs, or an SQLite error code \n** otherwise. It is not considered an error code if an iterator reaches\n** EOF.\n*/\nstatic int fts5ExprNodeTest_STRING(\n  Fts5Expr *pExpr,                /* Expression pPhrase belongs to */\n  Fts5ExprNode *pNode\n){\n  Fts5ExprNearset *pNear = pNode->pNear;\n  Fts5ExprPhrase *pLeft = pNear->apPhrase[0];\n  int rc = SQLITE_OK;\n  i64 iLast;                      /* Lastest rowid any iterator points to */\n  int i, j;                       /* Phrase and token index, respectively */\n  int bMatch;                     /* True if all terms are at the same rowid */\n  const int bDesc = pExpr->bDesc;\n\n  /* Check that this node should not be FTS5_TERM */\n  assert( pNear->nPhrase>1 \n       || pNear->apPhrase[0]->nTerm>1 \n       || pNear->apPhrase[0]->aTerm[0].pSynonym\n       || pNear->apPhrase[0]->aTerm[0].bFirst\n  );\n\n  /* Initialize iLast, the \"lastest\" rowid any iterator points to. If the\n  ** iterator skips through rowids in the default ascending order, this means\n  ** the maximum rowid. Or, if the iterator is \"ORDER BY rowid DESC\", then it\n  ** means the minimum rowid.  */\n  if( pLeft->aTerm[0].pSynonym ){\n    iLast = fts5ExprSynonymRowid(&pLeft->aTerm[0], bDesc, 0);\n  }else{\n    iLast = pLeft->aTerm[0].pIter->iRowid;\n  }\n\n  do {\n    bMatch = 1;\n    for(i=0; i<pNear->nPhrase; i++){\n      Fts5ExprPhrase *pPhrase = pNear->apPhrase[i];\n      for(j=0; j<pPhrase->nTerm; j++){\n        Fts5ExprTerm *pTerm = &pPhrase->aTerm[j];\n        if( pTerm->pSynonym ){\n          i64 iRowid = fts5ExprSynonymRowid(pTerm, bDesc, 0);\n          if( iRowid==iLast ) continue;\n          bMatch = 0;\n          if( fts5ExprSynonymAdvanceto(pTerm, bDesc, &iLast, &rc) ){\n            pNode->bNomatch = 0;\n            pNode->bEof = 1;\n            return rc;\n          }\n        }else{\n          Fts5IndexIter *pIter = pPhrase->aTerm[j].pIter;\n          if( pIter->iRowid==iLast || pIter->bEof ) continue;\n          bMatch = 0;\n          if( fts5ExprAdvanceto(pIter, bDesc, &iLast, &rc, &pNode->bEof) ){\n            return rc;\n          }\n        }\n      }\n    }\n  }while( bMatch==0 );\n\n  pNode->iRowid = iLast;\n  pNode->bNomatch = ((0==fts5ExprNearTest(&rc, pExpr, pNode)) && rc==SQLITE_OK);\n  assert( pNode->bEof==0 || pNode->bNomatch==0 );\n\n  return rc;\n}\n\n/*\n** Advance the first term iterator in the first phrase of pNear. Set output\n** variable *pbEof to true if it reaches EOF or if an error occurs.\n**\n** Return SQLITE_OK if successful, or an SQLite error code if an error\n** occurs.\n*/\nstatic int fts5ExprNodeNext_STRING(\n  Fts5Expr *pExpr,                /* Expression pPhrase belongs to */\n  Fts5ExprNode *pNode,            /* FTS5_STRING or FTS5_TERM node */\n  int bFromValid,\n  i64 iFrom \n){\n  Fts5ExprTerm *pTerm = &pNode->pNear->apPhrase[0]->aTerm[0];\n  int rc = SQLITE_OK;\n\n  pNode->bNomatch = 0;\n  if( pTerm->pSynonym ){\n    int bEof = 1;\n    Fts5ExprTerm *p;\n\n    /* Find the firstest rowid any synonym points to. */\n    i64 iRowid = fts5ExprSynonymRowid(pTerm, pExpr->bDesc, 0);\n\n    /* Advance each iterator that currently points to iRowid. Or, if iFrom\n    ** is valid - each iterator that points to a rowid before iFrom.  */\n    for(p=pTerm; p; p=p->pSynonym){\n      if( sqlite3Fts5IterEof(p->pIter)==0 ){\n        i64 ii = p->pIter->iRowid;\n        if( ii==iRowid \n         || (bFromValid && ii!=iFrom && (ii>iFrom)==pExpr->bDesc) \n        ){\n          if( bFromValid ){\n            rc = sqlite3Fts5IterNextFrom(p->pIter, iFrom);\n          }else{\n            rc = sqlite3Fts5IterNext(p->pIter);\n          }\n          if( rc!=SQLITE_OK ) break;\n          if( sqlite3Fts5IterEof(p->pIter)==0 ){\n            bEof = 0;\n          }\n        }else{\n          bEof = 0;\n        }\n      }\n    }\n\n    /* Set the EOF flag if either all synonym iterators are at EOF or an\n    ** error has occurred.  */\n    pNode->bEof = (rc || bEof);\n  }else{\n    Fts5IndexIter *pIter = pTerm->pIter;\n\n    assert( Fts5NodeIsString(pNode) );\n    if( bFromValid ){\n      rc = sqlite3Fts5IterNextFrom(pIter, iFrom);\n    }else{\n      rc = sqlite3Fts5IterNext(pIter);\n    }\n\n    pNode->bEof = (rc || sqlite3Fts5IterEof(pIter));\n  }\n\n  if( pNode->bEof==0 ){\n    assert( rc==SQLITE_OK );\n    rc = fts5ExprNodeTest_STRING(pExpr, pNode);\n  }\n\n  return rc;\n}\n\n\nstatic int fts5ExprNodeTest_TERM(\n  Fts5Expr *pExpr,                /* Expression that pNear is a part of */\n  Fts5ExprNode *pNode             /* The \"NEAR\" node (FTS5_TERM) */\n){\n  /* As this \"NEAR\" object is actually a single phrase that consists \n  ** of a single term only, grab pointers into the poslist managed by the\n  ** fts5_index.c iterator object. This is much faster than synthesizing \n  ** a new poslist the way we have to for more complicated phrase or NEAR\n  ** expressions.  */\n  Fts5ExprPhrase *pPhrase = pNode->pNear->apPhrase[0];\n  Fts5IndexIter *pIter = pPhrase->aTerm[0].pIter;\n\n  assert( pNode->eType==FTS5_TERM );\n  assert( pNode->pNear->nPhrase==1 && pPhrase->nTerm==1 );\n  assert( pPhrase->aTerm[0].pSynonym==0 );\n\n  pPhrase->poslist.n = pIter->nData;\n  if( pExpr->pConfig->eDetail==FTS5_DETAIL_FULL ){\n    pPhrase->poslist.p = (u8*)pIter->pData;\n  }\n  pNode->iRowid = pIter->iRowid;\n  pNode->bNomatch = (pPhrase->poslist.n==0);\n  return SQLITE_OK;\n}\n\n/*\n** xNext() method for a node of type FTS5_TERM.\n*/\nstatic int fts5ExprNodeNext_TERM(\n  Fts5Expr *pExpr, \n  Fts5ExprNode *pNode,\n  int bFromValid,\n  i64 iFrom\n){\n  int rc;\n  Fts5IndexIter *pIter = pNode->pNear->apPhrase[0]->aTerm[0].pIter;\n\n  assert( pNode->bEof==0 );\n  if( bFromValid ){\n    rc = sqlite3Fts5IterNextFrom(pIter, iFrom);\n  }else{\n    rc = sqlite3Fts5IterNext(pIter);\n  }\n  if( rc==SQLITE_OK && sqlite3Fts5IterEof(pIter)==0 ){\n    rc = fts5ExprNodeTest_TERM(pExpr, pNode);\n  }else{\n    pNode->bEof = 1;\n    pNode->bNomatch = 0;\n  }\n  return rc;\n}\n\nstatic void fts5ExprNodeTest_OR(\n  Fts5Expr *pExpr,                /* Expression of which pNode is a part */\n  Fts5ExprNode *pNode             /* Expression node to test */\n){\n  Fts5ExprNode *pNext = pNode->apChild[0];\n  int i;\n\n  for(i=1; i<pNode->nChild; i++){\n    Fts5ExprNode *pChild = pNode->apChild[i];\n    int cmp = fts5NodeCompare(pExpr, pNext, pChild);\n    if( cmp>0 || (cmp==0 && pChild->bNomatch==0) ){\n      pNext = pChild;\n    }\n  }\n  pNode->iRowid = pNext->iRowid;\n  pNode->bEof = pNext->bEof;\n  pNode->bNomatch = pNext->bNomatch;\n}\n\nstatic int fts5ExprNodeNext_OR(\n  Fts5Expr *pExpr, \n  Fts5ExprNode *pNode,\n  int bFromValid,\n  i64 iFrom\n){\n  int i;\n  i64 iLast = pNode->iRowid;\n\n  for(i=0; i<pNode->nChild; i++){\n    Fts5ExprNode *p1 = pNode->apChild[i];\n    assert( p1->bEof || fts5RowidCmp(pExpr, p1->iRowid, iLast)>=0 );\n    if( p1->bEof==0 ){\n      if( (p1->iRowid==iLast) \n       || (bFromValid && fts5RowidCmp(pExpr, p1->iRowid, iFrom)<0)\n      ){\n        int rc = fts5ExprNodeNext(pExpr, p1, bFromValid, iFrom);\n        if( rc!=SQLITE_OK ){\n          pNode->bNomatch = 0;\n          return rc;\n        }\n      }\n    }\n  }\n\n  fts5ExprNodeTest_OR(pExpr, pNode);\n  return SQLITE_OK;\n}\n\n/*\n** Argument pNode is an FTS5_AND node.\n*/\nstatic int fts5ExprNodeTest_AND(\n  Fts5Expr *pExpr,                /* Expression pPhrase belongs to */\n  Fts5ExprNode *pAnd              /* FTS5_AND node to advance */\n){\n  int iChild;\n  i64 iLast = pAnd->iRowid;\n  int rc = SQLITE_OK;\n  int bMatch;\n\n  assert( pAnd->bEof==0 );\n  do {\n    pAnd->bNomatch = 0;\n    bMatch = 1;\n    for(iChild=0; iChild<pAnd->nChild; iChild++){\n      Fts5ExprNode *pChild = pAnd->apChild[iChild];\n      int cmp = fts5RowidCmp(pExpr, iLast, pChild->iRowid);\n      if( cmp>0 ){\n        /* Advance pChild until it points to iLast or laster */\n        rc = fts5ExprNodeNext(pExpr, pChild, 1, iLast);\n        if( rc!=SQLITE_OK ){\n          pAnd->bNomatch = 0;\n          return rc;\n        }\n      }\n\n      /* If the child node is now at EOF, so is the parent AND node. Otherwise,\n      ** the child node is guaranteed to have advanced at least as far as\n      ** rowid iLast. So if it is not at exactly iLast, pChild->iRowid is the\n      ** new lastest rowid seen so far.  */\n      assert( pChild->bEof || fts5RowidCmp(pExpr, iLast, pChild->iRowid)<=0 );\n      if( pChild->bEof ){\n        fts5ExprSetEof(pAnd);\n        bMatch = 1;\n        break;\n      }else if( iLast!=pChild->iRowid ){\n        bMatch = 0;\n        iLast = pChild->iRowid;\n      }\n\n      if( pChild->bNomatch ){\n        pAnd->bNomatch = 1;\n      }\n    }\n  }while( bMatch==0 );\n\n  if( pAnd->bNomatch && pAnd!=pExpr->pRoot ){\n    fts5ExprNodeZeroPoslist(pAnd);\n  }\n  pAnd->iRowid = iLast;\n  return SQLITE_OK;\n}\n\nstatic int fts5ExprNodeNext_AND(\n  Fts5Expr *pExpr, \n  Fts5ExprNode *pNode,\n  int bFromValid,\n  i64 iFrom\n){\n  int rc = fts5ExprNodeNext(pExpr, pNode->apChild[0], bFromValid, iFrom);\n  if( rc==SQLITE_OK ){\n    rc = fts5ExprNodeTest_AND(pExpr, pNode);\n  }else{\n    pNode->bNomatch = 0;\n  }\n  return rc;\n}\n\nstatic int fts5ExprNodeTest_NOT(\n  Fts5Expr *pExpr,                /* Expression pPhrase belongs to */\n  Fts5ExprNode *pNode             /* FTS5_NOT node to advance */\n){\n  int rc = SQLITE_OK;\n  Fts5ExprNode *p1 = pNode->apChild[0];\n  Fts5ExprNode *p2 = pNode->apChild[1];\n  assert( pNode->nChild==2 );\n\n  while( rc==SQLITE_OK && p1->bEof==0 ){\n    int cmp = fts5NodeCompare(pExpr, p1, p2);\n    if( cmp>0 ){\n      rc = fts5ExprNodeNext(pExpr, p2, 1, p1->iRowid);\n      cmp = fts5NodeCompare(pExpr, p1, p2);\n    }\n    assert( rc!=SQLITE_OK || cmp<=0 );\n    if( cmp || p2->bNomatch ) break;\n    rc = fts5ExprNodeNext(pExpr, p1, 0, 0);\n  }\n  pNode->bEof = p1->bEof;\n  pNode->bNomatch = p1->bNomatch;\n  pNode->iRowid = p1->iRowid;\n  if( p1->bEof ){\n    fts5ExprNodeZeroPoslist(p2);\n  }\n  return rc;\n}\n\nstatic int fts5ExprNodeNext_NOT(\n  Fts5Expr *pExpr, \n  Fts5ExprNode *pNode,\n  int bFromValid,\n  i64 iFrom\n){\n  int rc = fts5ExprNodeNext(pExpr, pNode->apChild[0], bFromValid, iFrom);\n  if( rc==SQLITE_OK ){\n    rc = fts5ExprNodeTest_NOT(pExpr, pNode);\n  }\n  if( rc!=SQLITE_OK ){\n    pNode->bNomatch = 0;\n  }\n  return rc;\n}\n\n/*\n** If pNode currently points to a match, this function returns SQLITE_OK\n** without modifying it. Otherwise, pNode is advanced until it does point\n** to a match or EOF is reached.\n*/\nstatic int fts5ExprNodeTest(\n  Fts5Expr *pExpr,                /* Expression of which pNode is a part */\n  Fts5ExprNode *pNode             /* Expression node to test */\n){\n  int rc = SQLITE_OK;\n  if( pNode->bEof==0 ){\n    switch( pNode->eType ){\n\n      case FTS5_STRING: {\n        rc = fts5ExprNodeTest_STRING(pExpr, pNode);\n        break;\n      }\n\n      case FTS5_TERM: {\n        rc = fts5ExprNodeTest_TERM(pExpr, pNode);\n        break;\n      }\n\n      case FTS5_AND: {\n        rc = fts5ExprNodeTest_AND(pExpr, pNode);\n        break;\n      }\n\n      case FTS5_OR: {\n        fts5ExprNodeTest_OR(pExpr, pNode);\n        break;\n      }\n\n      default: assert( pNode->eType==FTS5_NOT ); {\n        rc = fts5ExprNodeTest_NOT(pExpr, pNode);\n        break;\n      }\n    }\n  }\n  return rc;\n}\n\n \n/*\n** Set node pNode, which is part of expression pExpr, to point to the first\n** match. If there are no matches, set the Node.bEof flag to indicate EOF.\n**\n** Return an SQLite error code if an error occurs, or SQLITE_OK otherwise.\n** It is not an error if there are no matches.\n*/\nstatic int fts5ExprNodeFirst(Fts5Expr *pExpr, Fts5ExprNode *pNode){\n  int rc = SQLITE_OK;\n  pNode->bEof = 0;\n  pNode->bNomatch = 0;\n\n  if( Fts5NodeIsString(pNode) ){\n    /* Initialize all term iterators in the NEAR object. */\n    rc = fts5ExprNearInitAll(pExpr, pNode);\n  }else if( pNode->xNext==0 ){\n    pNode->bEof = 1;\n  }else{\n    int i;\n    int nEof = 0;\n    for(i=0; i<pNode->nChild && rc==SQLITE_OK; i++){\n      Fts5ExprNode *pChild = pNode->apChild[i];\n      rc = fts5ExprNodeFirst(pExpr, pNode->apChild[i]);\n      assert( pChild->bEof==0 || pChild->bEof==1 );\n      nEof += pChild->bEof;\n    }\n    pNode->iRowid = pNode->apChild[0]->iRowid;\n\n    switch( pNode->eType ){\n      case FTS5_AND:\n        if( nEof>0 ) fts5ExprSetEof(pNode);\n        break;\n\n      case FTS5_OR:\n        if( pNode->nChild==nEof ) fts5ExprSetEof(pNode);\n        break;\n\n      default:\n        assert( pNode->eType==FTS5_NOT );\n        pNode->bEof = pNode->apChild[0]->bEof;\n        break;\n    }\n  }\n\n  if( rc==SQLITE_OK ){\n    rc = fts5ExprNodeTest(pExpr, pNode);\n  }\n  return rc;\n}\n\n\n/*\n** Begin iterating through the set of documents in index pIdx matched by\n** the MATCH expression passed as the first argument. If the \"bDesc\" \n** parameter is passed a non-zero value, iteration is in descending rowid \n** order. Or, if it is zero, in ascending order.\n**\n** If iterating in ascending rowid order (bDesc==0), the first document\n** visited is that with the smallest rowid that is larger than or equal\n** to parameter iFirst. Or, if iterating in ascending order (bDesc==1),\n** then the first document visited must have a rowid smaller than or\n** equal to iFirst.\n**\n** Return SQLITE_OK if successful, or an SQLite error code otherwise. It\n** is not considered an error if the query does not match any documents.\n*/\nstatic int sqlite3Fts5ExprFirst(Fts5Expr *p, Fts5Index *pIdx, i64 iFirst, int bDesc){\n  Fts5ExprNode *pRoot = p->pRoot;\n  int rc;                         /* Return code */\n\n  p->pIndex = pIdx;\n  p->bDesc = bDesc;\n  rc = fts5ExprNodeFirst(p, pRoot);\n\n  /* If not at EOF but the current rowid occurs earlier than iFirst in\n  ** the iteration order, move to document iFirst or later. */\n  if( rc==SQLITE_OK \n   && 0==pRoot->bEof \n   && fts5RowidCmp(p, pRoot->iRowid, iFirst)<0 \n  ){\n    rc = fts5ExprNodeNext(p, pRoot, 1, iFirst);\n  }\n\n  /* If the iterator is not at a real match, skip forward until it is. */\n  while( pRoot->bNomatch ){\n    assert( pRoot->bEof==0 && rc==SQLITE_OK );\n    rc = fts5ExprNodeNext(p, pRoot, 0, 0);\n  }\n  return rc;\n}\n\n/*\n** Move to the next document \n**\n** Return SQLITE_OK if successful, or an SQLite error code otherwise. It\n** is not considered an error if the query does not match any documents.\n*/\nstatic int sqlite3Fts5ExprNext(Fts5Expr *p, i64 iLast){\n  int rc;\n  Fts5ExprNode *pRoot = p->pRoot;\n  assert( pRoot->bEof==0 && pRoot->bNomatch==0 );\n  do {\n    rc = fts5ExprNodeNext(p, pRoot, 0, 0);\n    assert( pRoot->bNomatch==0 || (rc==SQLITE_OK && pRoot->bEof==0) );\n  }while( pRoot->bNomatch );\n  if( fts5RowidCmp(p, pRoot->iRowid, iLast)>0 ){\n    pRoot->bEof = 1;\n  }\n  return rc;\n}\n\nstatic int sqlite3Fts5ExprEof(Fts5Expr *p){\n  return p->pRoot->bEof;\n}\n\nstatic i64 sqlite3Fts5ExprRowid(Fts5Expr *p){\n  return p->pRoot->iRowid;\n}\n\nstatic int fts5ParseStringFromToken(Fts5Token *pToken, char **pz){\n  int rc = SQLITE_OK;\n  *pz = sqlite3Fts5Strndup(&rc, pToken->p, pToken->n);\n  return rc;\n}\n\n/*\n** Free the phrase object passed as the only argument.\n*/\nstatic void fts5ExprPhraseFree(Fts5ExprPhrase *pPhrase){\n  if( pPhrase ){\n    int i;\n    for(i=0; i<pPhrase->nTerm; i++){\n      Fts5ExprTerm *pSyn;\n      Fts5ExprTerm *pNext;\n      Fts5ExprTerm *pTerm = &pPhrase->aTerm[i];\n      sqlite3_free(pTerm->zTerm);\n      sqlite3Fts5IterClose(pTerm->pIter);\n      for(pSyn=pTerm->pSynonym; pSyn; pSyn=pNext){\n        pNext = pSyn->pSynonym;\n        sqlite3Fts5IterClose(pSyn->pIter);\n        fts5BufferFree((Fts5Buffer*)&pSyn[1]);\n        sqlite3_free(pSyn);\n      }\n    }\n    if( pPhrase->poslist.nSpace>0 ) fts5BufferFree(&pPhrase->poslist);\n    sqlite3_free(pPhrase);\n  }\n}\n\n/*\n** Set the \"bFirst\" flag on the first token of the phrase passed as the\n** only argument.\n*/\nstatic void sqlite3Fts5ParseSetCaret(Fts5ExprPhrase *pPhrase){\n  if( pPhrase && pPhrase->nTerm ){\n    pPhrase->aTerm[0].bFirst = 1;\n  }\n}\n\n/*\n** If argument pNear is NULL, then a new Fts5ExprNearset object is allocated\n** and populated with pPhrase. Or, if pNear is not NULL, phrase pPhrase is\n** appended to it and the results returned.\n**\n** If an OOM error occurs, both the pNear and pPhrase objects are freed and\n** NULL returned.\n*/\nstatic Fts5ExprNearset *sqlite3Fts5ParseNearset(\n  Fts5Parse *pParse,              /* Parse context */\n  Fts5ExprNearset *pNear,         /* Existing nearset, or NULL */\n  Fts5ExprPhrase *pPhrase         /* Recently parsed phrase */\n){\n  const int SZALLOC = 8;\n  Fts5ExprNearset *pRet = 0;\n\n  if( pParse->rc==SQLITE_OK ){\n    if( pPhrase==0 ){\n      return pNear;\n    }\n    if( pNear==0 ){\n      sqlite3_int64 nByte;\n      nByte = sizeof(Fts5ExprNearset) + SZALLOC * sizeof(Fts5ExprPhrase*);\n      pRet = sqlite3_malloc64(nByte);\n      if( pRet==0 ){\n        pParse->rc = SQLITE_NOMEM;\n      }else{\n        memset(pRet, 0, nByte);\n      }\n    }else if( (pNear->nPhrase % SZALLOC)==0 ){\n      int nNew = pNear->nPhrase + SZALLOC;\n      sqlite3_int64 nByte;\n\n      nByte = sizeof(Fts5ExprNearset) + nNew * sizeof(Fts5ExprPhrase*);\n      pRet = (Fts5ExprNearset*)sqlite3_realloc64(pNear, nByte);\n      if( pRet==0 ){\n        pParse->rc = SQLITE_NOMEM;\n      }\n    }else{\n      pRet = pNear;\n    }\n  }\n\n  if( pRet==0 ){\n    assert( pParse->rc!=SQLITE_OK );\n    sqlite3Fts5ParseNearsetFree(pNear);\n    sqlite3Fts5ParsePhraseFree(pPhrase);\n  }else{\n    if( pRet->nPhrase>0 ){\n      Fts5ExprPhrase *pLast = pRet->apPhrase[pRet->nPhrase-1];\n      assert( pLast==pParse->apPhrase[pParse->nPhrase-2] );\n      if( pPhrase->nTerm==0 ){\n        fts5ExprPhraseFree(pPhrase);\n        pRet->nPhrase--;\n        pParse->nPhrase--;\n        pPhrase = pLast;\n      }else if( pLast->nTerm==0 ){\n        fts5ExprPhraseFree(pLast);\n        pParse->apPhrase[pParse->nPhrase-2] = pPhrase;\n        pParse->nPhrase--;\n        pRet->nPhrase--;\n      }\n    }\n    pRet->apPhrase[pRet->nPhrase++] = pPhrase;\n  }\n  return pRet;\n}\n\ntypedef struct TokenCtx TokenCtx;\nstruct TokenCtx {\n  Fts5ExprPhrase *pPhrase;\n  int rc;\n};\n\n/*\n** Callback for tokenizing terms used by ParseTerm().\n*/\nstatic int fts5ParseTokenize(\n  void *pContext,                 /* Pointer to Fts5InsertCtx object */\n  int tflags,                     /* Mask of FTS5_TOKEN_* flags */\n  const char *pToken,             /* Buffer containing token */\n  int nToken,                     /* Size of token in bytes */\n  int iUnused1,                   /* Start offset of token */\n  int iUnused2                    /* End offset of token */\n){\n  int rc = SQLITE_OK;\n  const int SZALLOC = 8;\n  TokenCtx *pCtx = (TokenCtx*)pContext;\n  Fts5ExprPhrase *pPhrase = pCtx->pPhrase;\n\n  UNUSED_PARAM2(iUnused1, iUnused2);\n\n  /* If an error has already occurred, this is a no-op */\n  if( pCtx->rc!=SQLITE_OK ) return pCtx->rc;\n  if( nToken>FTS5_MAX_TOKEN_SIZE ) nToken = FTS5_MAX_TOKEN_SIZE;\n\n  if( pPhrase && pPhrase->nTerm>0 && (tflags & FTS5_TOKEN_COLOCATED) ){\n    Fts5ExprTerm *pSyn;\n    sqlite3_int64 nByte = sizeof(Fts5ExprTerm) + sizeof(Fts5Buffer) + nToken+1;\n    pSyn = (Fts5ExprTerm*)sqlite3_malloc64(nByte);\n    if( pSyn==0 ){\n      rc = SQLITE_NOMEM;\n    }else{\n      memset(pSyn, 0, nByte);\n      pSyn->zTerm = ((char*)pSyn) + sizeof(Fts5ExprTerm) + sizeof(Fts5Buffer);\n      memcpy(pSyn->zTerm, pToken, nToken);\n      pSyn->pSynonym = pPhrase->aTerm[pPhrase->nTerm-1].pSynonym;\n      pPhrase->aTerm[pPhrase->nTerm-1].pSynonym = pSyn;\n    }\n  }else{\n    Fts5ExprTerm *pTerm;\n    if( pPhrase==0 || (pPhrase->nTerm % SZALLOC)==0 ){\n      Fts5ExprPhrase *pNew;\n      int nNew = SZALLOC + (pPhrase ? pPhrase->nTerm : 0);\n\n      pNew = (Fts5ExprPhrase*)sqlite3_realloc64(pPhrase, \n          sizeof(Fts5ExprPhrase) + sizeof(Fts5ExprTerm) * nNew\n      );\n      if( pNew==0 ){\n        rc = SQLITE_NOMEM;\n      }else{\n        if( pPhrase==0 ) memset(pNew, 0, sizeof(Fts5ExprPhrase));\n        pCtx->pPhrase = pPhrase = pNew;\n        pNew->nTerm = nNew - SZALLOC;\n      }\n    }\n\n    if( rc==SQLITE_OK ){\n      pTerm = &pPhrase->aTerm[pPhrase->nTerm++];\n      memset(pTerm, 0, sizeof(Fts5ExprTerm));\n      pTerm->zTerm = sqlite3Fts5Strndup(&rc, pToken, nToken);\n    }\n  }\n\n  pCtx->rc = rc;\n  return rc;\n}\n\n\n/*\n** Free the phrase object passed as the only argument.\n*/\nstatic void sqlite3Fts5ParsePhraseFree(Fts5ExprPhrase *pPhrase){\n  fts5ExprPhraseFree(pPhrase);\n}\n\n/*\n** Free the phrase object passed as the second argument.\n*/\nstatic void sqlite3Fts5ParseNearsetFree(Fts5ExprNearset *pNear){\n  if( pNear ){\n    int i;\n    for(i=0; i<pNear->nPhrase; i++){\n      fts5ExprPhraseFree(pNear->apPhrase[i]);\n    }\n    sqlite3_free(pNear->pColset);\n    sqlite3_free(pNear);\n  }\n}\n\nstatic void sqlite3Fts5ParseFinished(Fts5Parse *pParse, Fts5ExprNode *p){\n  assert( pParse->pExpr==0 );\n  pParse->pExpr = p;\n}\n\n/*\n** This function is called by the parser to process a string token. The\n** string may or may not be quoted. In any case it is tokenized and a\n** phrase object consisting of all tokens returned.\n*/\nstatic Fts5ExprPhrase *sqlite3Fts5ParseTerm(\n  Fts5Parse *pParse,              /* Parse context */\n  Fts5ExprPhrase *pAppend,        /* Phrase to append to */\n  Fts5Token *pToken,              /* String to tokenize */\n  int bPrefix                     /* True if there is a trailing \"*\" */\n){\n  Fts5Config *pConfig = pParse->pConfig;\n  TokenCtx sCtx;                  /* Context object passed to callback */\n  int rc;                         /* Tokenize return code */\n  char *z = 0;\n\n  memset(&sCtx, 0, sizeof(TokenCtx));\n  sCtx.pPhrase = pAppend;\n\n  rc = fts5ParseStringFromToken(pToken, &z);\n  if( rc==SQLITE_OK ){\n    int flags = FTS5_TOKENIZE_QUERY | (bPrefix ? FTS5_TOKENIZE_PREFIX : 0);\n    int n;\n    sqlite3Fts5Dequote(z);\n    n = (int)strlen(z);\n    rc = sqlite3Fts5Tokenize(pConfig, flags, z, n, &sCtx, fts5ParseTokenize);\n  }\n  sqlite3_free(z);\n  if( rc || (rc = sCtx.rc) ){\n    pParse->rc = rc;\n    fts5ExprPhraseFree(sCtx.pPhrase);\n    sCtx.pPhrase = 0;\n  }else{\n\n    if( pAppend==0 ){\n      if( (pParse->nPhrase % 8)==0 ){\n        sqlite3_int64 nByte = sizeof(Fts5ExprPhrase*) * (pParse->nPhrase + 8);\n        Fts5ExprPhrase **apNew;\n        apNew = (Fts5ExprPhrase**)sqlite3_realloc64(pParse->apPhrase, nByte);\n        if( apNew==0 ){\n          pParse->rc = SQLITE_NOMEM;\n          fts5ExprPhraseFree(sCtx.pPhrase);\n          return 0;\n        }\n        pParse->apPhrase = apNew;\n      }\n      pParse->nPhrase++;\n    }\n\n    if( sCtx.pPhrase==0 ){\n      /* This happens when parsing a token or quoted phrase that contains\n      ** no token characters at all. (e.g ... MATCH '\"\"'). */\n      sCtx.pPhrase = sqlite3Fts5MallocZero(&pParse->rc, sizeof(Fts5ExprPhrase));\n    }else if( sCtx.pPhrase->nTerm ){\n      sCtx.pPhrase->aTerm[sCtx.pPhrase->nTerm-1].bPrefix = (u8)bPrefix;\n    }\n    pParse->apPhrase[pParse->nPhrase-1] = sCtx.pPhrase;\n  }\n\n  return sCtx.pPhrase;\n}\n\n/*\n** Create a new FTS5 expression by cloning phrase iPhrase of the\n** expression passed as the second argument.\n*/\nstatic int sqlite3Fts5ExprClonePhrase(\n  Fts5Expr *pExpr, \n  int iPhrase, \n  Fts5Expr **ppNew\n){\n  int rc = SQLITE_OK;             /* Return code */\n  Fts5ExprPhrase *pOrig;          /* The phrase extracted from pExpr */\n  Fts5Expr *pNew = 0;             /* Expression to return via *ppNew */\n  TokenCtx sCtx = {0,0};          /* Context object for fts5ParseTokenize */\n\n  pOrig = pExpr->apExprPhrase[iPhrase];\n  pNew = (Fts5Expr*)sqlite3Fts5MallocZero(&rc, sizeof(Fts5Expr));\n  if( rc==SQLITE_OK ){\n    pNew->apExprPhrase = (Fts5ExprPhrase**)sqlite3Fts5MallocZero(&rc, \n        sizeof(Fts5ExprPhrase*));\n  }\n  if( rc==SQLITE_OK ){\n    pNew->pRoot = (Fts5ExprNode*)sqlite3Fts5MallocZero(&rc, \n        sizeof(Fts5ExprNode));\n  }\n  if( rc==SQLITE_OK ){\n    pNew->pRoot->pNear = (Fts5ExprNearset*)sqlite3Fts5MallocZero(&rc, \n        sizeof(Fts5ExprNearset) + sizeof(Fts5ExprPhrase*));\n  }\n  if( rc==SQLITE_OK ){\n    Fts5Colset *pColsetOrig = pOrig->pNode->pNear->pColset;\n    if( pColsetOrig ){\n      sqlite3_int64 nByte;\n      Fts5Colset *pColset;\n      nByte = sizeof(Fts5Colset) + (pColsetOrig->nCol-1) * sizeof(int);\n      pColset = (Fts5Colset*)sqlite3Fts5MallocZero(&rc, nByte);\n      if( pColset ){ \n        memcpy(pColset, pColsetOrig, nByte);\n      }\n      pNew->pRoot->pNear->pColset = pColset;\n    }\n  }\n\n  if( pOrig->nTerm ){\n    int i;                          /* Used to iterate through phrase terms */\n    for(i=0; rc==SQLITE_OK && i<pOrig->nTerm; i++){\n      int tflags = 0;\n      Fts5ExprTerm *p;\n      for(p=&pOrig->aTerm[i]; p && rc==SQLITE_OK; p=p->pSynonym){\n        const char *zTerm = p->zTerm;\n        rc = fts5ParseTokenize((void*)&sCtx, tflags, zTerm, (int)strlen(zTerm),\n            0, 0);\n        tflags = FTS5_TOKEN_COLOCATED;\n      }\n      if( rc==SQLITE_OK ){\n        sCtx.pPhrase->aTerm[i].bPrefix = pOrig->aTerm[i].bPrefix;\n        sCtx.pPhrase->aTerm[i].bFirst = pOrig->aTerm[i].bFirst;\n      }\n    }\n  }else{\n    /* This happens when parsing a token or quoted phrase that contains\n    ** no token characters at all. (e.g ... MATCH '\"\"'). */\n    sCtx.pPhrase = sqlite3Fts5MallocZero(&rc, sizeof(Fts5ExprPhrase));\n  }\n\n  if( rc==SQLITE_OK ){\n    /* All the allocations succeeded. Put the expression object together. */\n    pNew->pIndex = pExpr->pIndex;\n    pNew->pConfig = pExpr->pConfig;\n    pNew->nPhrase = 1;\n    pNew->apExprPhrase[0] = sCtx.pPhrase;\n    pNew->pRoot->pNear->apPhrase[0] = sCtx.pPhrase;\n    pNew->pRoot->pNear->nPhrase = 1;\n    sCtx.pPhrase->pNode = pNew->pRoot;\n\n    if( pOrig->nTerm==1 \n     && pOrig->aTerm[0].pSynonym==0 \n     && pOrig->aTerm[0].bFirst==0 \n    ){\n      pNew->pRoot->eType = FTS5_TERM;\n      pNew->pRoot->xNext = fts5ExprNodeNext_TERM;\n    }else{\n      pNew->pRoot->eType = FTS5_STRING;\n      pNew->pRoot->xNext = fts5ExprNodeNext_STRING;\n    }\n  }else{\n    sqlite3Fts5ExprFree(pNew);\n    fts5ExprPhraseFree(sCtx.pPhrase);\n    pNew = 0;\n  }\n\n  *ppNew = pNew;\n  return rc;\n}\n\n\n/*\n** Token pTok has appeared in a MATCH expression where the NEAR operator\n** is expected. If token pTok does not contain \"NEAR\", store an error\n** in the pParse object.\n*/\nstatic void sqlite3Fts5ParseNear(Fts5Parse *pParse, Fts5Token *pTok){\n  if( pTok->n!=4 || memcmp(\"NEAR\", pTok->p, 4) ){\n    sqlite3Fts5ParseError(\n        pParse, \"fts5: syntax error near \\\"%.*s\\\"\", pTok->n, pTok->p\n    );\n  }\n}\n\nstatic void sqlite3Fts5ParseSetDistance(\n  Fts5Parse *pParse, \n  Fts5ExprNearset *pNear,\n  Fts5Token *p\n){\n  if( pNear ){\n    int nNear = 0;\n    int i;\n    if( p->n ){\n      for(i=0; i<p->n; i++){\n        char c = (char)p->p[i];\n        if( c<'0' || c>'9' ){\n          sqlite3Fts5ParseError(\n              pParse, \"expected integer, got \\\"%.*s\\\"\", p->n, p->p\n              );\n          return;\n        }\n        nNear = nNear * 10 + (p->p[i] - '0');\n      }\n    }else{\n      nNear = FTS5_DEFAULT_NEARDIST;\n    }\n    pNear->nNear = nNear;\n  }\n}\n\n/*\n** The second argument passed to this function may be NULL, or it may be\n** an existing Fts5Colset object. This function returns a pointer to\n** a new colset object containing the contents of (p) with new value column\n** number iCol appended. \n**\n** If an OOM error occurs, store an error code in pParse and return NULL.\n** The old colset object (if any) is not freed in this case.\n*/\nstatic Fts5Colset *fts5ParseColset(\n  Fts5Parse *pParse,              /* Store SQLITE_NOMEM here if required */\n  Fts5Colset *p,                  /* Existing colset object */\n  int iCol                        /* New column to add to colset object */\n){\n  int nCol = p ? p->nCol : 0;     /* Num. columns already in colset object */\n  Fts5Colset *pNew;               /* New colset object to return */\n\n  assert( pParse->rc==SQLITE_OK );\n  assert( iCol>=0 && iCol<pParse->pConfig->nCol );\n\n  pNew = sqlite3_realloc64(p, sizeof(Fts5Colset) + sizeof(int)*nCol);\n  if( pNew==0 ){\n    pParse->rc = SQLITE_NOMEM;\n  }else{\n    int *aiCol = pNew->aiCol;\n    int i, j;\n    for(i=0; i<nCol; i++){\n      if( aiCol[i]==iCol ) return pNew;\n      if( aiCol[i]>iCol ) break;\n    }\n    for(j=nCol; j>i; j--){\n      aiCol[j] = aiCol[j-1];\n    }\n    aiCol[i] = iCol;\n    pNew->nCol = nCol+1;\n\n#ifndef NDEBUG\n    /* Check that the array is in order and contains no duplicate entries. */\n    for(i=1; i<pNew->nCol; i++) assert( pNew->aiCol[i]>pNew->aiCol[i-1] );\n#endif\n  }\n\n  return pNew;\n}\n\n/*\n** Allocate and return an Fts5Colset object specifying the inverse of\n** the colset passed as the second argument. Free the colset passed\n** as the second argument before returning.\n*/\nstatic Fts5Colset *sqlite3Fts5ParseColsetInvert(Fts5Parse *pParse, Fts5Colset *p){\n  Fts5Colset *pRet;\n  int nCol = pParse->pConfig->nCol;\n\n  pRet = (Fts5Colset*)sqlite3Fts5MallocZero(&pParse->rc, \n      sizeof(Fts5Colset) + sizeof(int)*nCol\n  );\n  if( pRet ){\n    int i;\n    int iOld = 0;\n    for(i=0; i<nCol; i++){\n      if( iOld>=p->nCol || p->aiCol[iOld]!=i ){\n        pRet->aiCol[pRet->nCol++] = i;\n      }else{\n        iOld++;\n      }\n    }\n  }\n\n  sqlite3_free(p);\n  return pRet;\n}\n\nstatic Fts5Colset *sqlite3Fts5ParseColset(\n  Fts5Parse *pParse,              /* Store SQLITE_NOMEM here if required */\n  Fts5Colset *pColset,            /* Existing colset object */\n  Fts5Token *p\n){\n  Fts5Colset *pRet = 0;\n  int iCol;\n  char *z;                        /* Dequoted copy of token p */\n\n  z = sqlite3Fts5Strndup(&pParse->rc, p->p, p->n);\n  if( pParse->rc==SQLITE_OK ){\n    Fts5Config *pConfig = pParse->pConfig;\n    sqlite3Fts5Dequote(z);\n    for(iCol=0; iCol<pConfig->nCol; iCol++){\n      if( 0==sqlite3_stricmp(pConfig->azCol[iCol], z) ) break;\n    }\n    if( iCol==pConfig->nCol ){\n      sqlite3Fts5ParseError(pParse, \"no such column: %s\", z);\n    }else{\n      pRet = fts5ParseColset(pParse, pColset, iCol);\n    }\n    sqlite3_free(z);\n  }\n\n  if( pRet==0 ){\n    assert( pParse->rc!=SQLITE_OK );\n    sqlite3_free(pColset);\n  }\n\n  return pRet;\n}\n\n/*\n** If argument pOrig is NULL, or if (*pRc) is set to anything other than\n** SQLITE_OK when this function is called, NULL is returned. \n**\n** Otherwise, a copy of (*pOrig) is made into memory obtained from\n** sqlite3Fts5MallocZero() and a pointer to it returned. If the allocation\n** fails, (*pRc) is set to SQLITE_NOMEM and NULL is returned.\n*/\nstatic Fts5Colset *fts5CloneColset(int *pRc, Fts5Colset *pOrig){\n  Fts5Colset *pRet;\n  if( pOrig ){\n    sqlite3_int64 nByte = sizeof(Fts5Colset) + (pOrig->nCol-1) * sizeof(int);\n    pRet = (Fts5Colset*)sqlite3Fts5MallocZero(pRc, nByte);\n    if( pRet ){ \n      memcpy(pRet, pOrig, nByte);\n    }\n  }else{\n    pRet = 0;\n  }\n  return pRet;\n}\n\n/*\n** Remove from colset pColset any columns that are not also in colset pMerge.\n*/\nstatic void fts5MergeColset(Fts5Colset *pColset, Fts5Colset *pMerge){\n  int iIn = 0;          /* Next input in pColset */\n  int iMerge = 0;       /* Next input in pMerge */\n  int iOut = 0;         /* Next output slot in pColset */\n\n  while( iIn<pColset->nCol && iMerge<pMerge->nCol ){\n    int iDiff = pColset->aiCol[iIn] - pMerge->aiCol[iMerge];\n    if( iDiff==0 ){\n      pColset->aiCol[iOut++] = pMerge->aiCol[iMerge];\n      iMerge++;\n      iIn++;\n    }else if( iDiff>0 ){\n      iMerge++;\n    }else{\n      iIn++;\n    }\n  }\n  pColset->nCol = iOut;\n}\n\n/*\n** Recursively apply colset pColset to expression node pNode and all of\n** its decendents. If (*ppFree) is not NULL, it contains a spare copy\n** of pColset. This function may use the spare copy and set (*ppFree) to\n** zero, or it may create copies of pColset using fts5CloneColset().\n*/\nstatic void fts5ParseSetColset(\n  Fts5Parse *pParse, \n  Fts5ExprNode *pNode, \n  Fts5Colset *pColset,\n  Fts5Colset **ppFree\n){\n  if( pParse->rc==SQLITE_OK ){\n    assert( pNode->eType==FTS5_TERM || pNode->eType==FTS5_STRING \n         || pNode->eType==FTS5_AND  || pNode->eType==FTS5_OR\n         || pNode->eType==FTS5_NOT  || pNode->eType==FTS5_EOF\n    );\n    if( pNode->eType==FTS5_STRING || pNode->eType==FTS5_TERM ){\n      Fts5ExprNearset *pNear = pNode->pNear;\n      if( pNear->pColset ){\n        fts5MergeColset(pNear->pColset, pColset);\n        if( pNear->pColset->nCol==0 ){\n          pNode->eType = FTS5_EOF;\n          pNode->xNext = 0;\n        }\n      }else if( *ppFree ){\n        pNear->pColset = pColset;\n        *ppFree = 0;\n      }else{\n        pNear->pColset = fts5CloneColset(&pParse->rc, pColset);\n      }\n    }else{\n      int i;\n      assert( pNode->eType!=FTS5_EOF || pNode->nChild==0 );\n      for(i=0; i<pNode->nChild; i++){\n        fts5ParseSetColset(pParse, pNode->apChild[i], pColset, ppFree);\n      }\n    }\n  }\n}\n\n/*\n** Apply colset pColset to expression node pExpr and all of its descendents.\n*/\nstatic void sqlite3Fts5ParseSetColset(\n  Fts5Parse *pParse, \n  Fts5ExprNode *pExpr, \n  Fts5Colset *pColset \n){\n  Fts5Colset *pFree = pColset;\n  if( pParse->pConfig->eDetail==FTS5_DETAIL_NONE ){\n    pParse->rc = SQLITE_ERROR;\n    pParse->zErr = sqlite3_mprintf(\n      \"fts5: column queries are not supported (detail=none)\"\n    );\n  }else{\n    fts5ParseSetColset(pParse, pExpr, pColset, &pFree);\n  }\n  sqlite3_free(pFree);\n}\n\nstatic void fts5ExprAssignXNext(Fts5ExprNode *pNode){\n  switch( pNode->eType ){\n    case FTS5_STRING: {\n      Fts5ExprNearset *pNear = pNode->pNear;\n      if( pNear->nPhrase==1 && pNear->apPhrase[0]->nTerm==1 \n       && pNear->apPhrase[0]->aTerm[0].pSynonym==0\n       && pNear->apPhrase[0]->aTerm[0].bFirst==0\n      ){\n        pNode->eType = FTS5_TERM;\n        pNode->xNext = fts5ExprNodeNext_TERM;\n      }else{\n        pNode->xNext = fts5ExprNodeNext_STRING;\n      }\n      break;\n    };\n\n    case FTS5_OR: {\n      pNode->xNext = fts5ExprNodeNext_OR;\n      break;\n    };\n\n    case FTS5_AND: {\n      pNode->xNext = fts5ExprNodeNext_AND;\n      break;\n    };\n\n    default: assert( pNode->eType==FTS5_NOT ); {\n      pNode->xNext = fts5ExprNodeNext_NOT;\n      break;\n    };\n  }\n}\n\nstatic void fts5ExprAddChildren(Fts5ExprNode *p, Fts5ExprNode *pSub){\n  if( p->eType!=FTS5_NOT && pSub->eType==p->eType ){\n    int nByte = sizeof(Fts5ExprNode*) * pSub->nChild;\n    memcpy(&p->apChild[p->nChild], pSub->apChild, nByte);\n    p->nChild += pSub->nChild;\n    sqlite3_free(pSub);\n  }else{\n    p->apChild[p->nChild++] = pSub;\n  }\n}\n\n/*\n** Allocate and return a new expression object. If anything goes wrong (i.e.\n** OOM error), leave an error code in pParse and return NULL.\n*/\nstatic Fts5ExprNode *sqlite3Fts5ParseNode(\n  Fts5Parse *pParse,              /* Parse context */\n  int eType,                      /* FTS5_STRING, AND, OR or NOT */\n  Fts5ExprNode *pLeft,            /* Left hand child expression */\n  Fts5ExprNode *pRight,           /* Right hand child expression */\n  Fts5ExprNearset *pNear          /* For STRING expressions, the near cluster */\n){\n  Fts5ExprNode *pRet = 0;\n\n  if( pParse->rc==SQLITE_OK ){\n    int nChild = 0;               /* Number of children of returned node */\n    sqlite3_int64 nByte;          /* Bytes of space to allocate for this node */\n \n    assert( (eType!=FTS5_STRING && !pNear)\n         || (eType==FTS5_STRING && !pLeft && !pRight)\n    );\n    if( eType==FTS5_STRING && pNear==0 ) return 0;\n    if( eType!=FTS5_STRING && pLeft==0 ) return pRight;\n    if( eType!=FTS5_STRING && pRight==0 ) return pLeft;\n\n    if( eType==FTS5_NOT ){\n      nChild = 2;\n    }else if( eType==FTS5_AND || eType==FTS5_OR ){\n      nChild = 2;\n      if( pLeft->eType==eType ) nChild += pLeft->nChild-1;\n      if( pRight->eType==eType ) nChild += pRight->nChild-1;\n    }\n\n    nByte = sizeof(Fts5ExprNode) + sizeof(Fts5ExprNode*)*(nChild-1);\n    pRet = (Fts5ExprNode*)sqlite3Fts5MallocZero(&pParse->rc, nByte);\n\n    if( pRet ){\n      pRet->eType = eType;\n      pRet->pNear = pNear;\n      fts5ExprAssignXNext(pRet);\n      if( eType==FTS5_STRING ){\n        int iPhrase;\n        for(iPhrase=0; iPhrase<pNear->nPhrase; iPhrase++){\n          pNear->apPhrase[iPhrase]->pNode = pRet;\n          if( pNear->apPhrase[iPhrase]->nTerm==0 ){\n            pRet->xNext = 0;\n            pRet->eType = FTS5_EOF;\n          }\n        }\n\n        if( pParse->pConfig->eDetail!=FTS5_DETAIL_FULL ){\n          Fts5ExprPhrase *pPhrase = pNear->apPhrase[0];\n          if( pNear->nPhrase!=1 \n           || pPhrase->nTerm>1\n           || (pPhrase->nTerm>0 && pPhrase->aTerm[0].bFirst)\n          ){\n            assert( pParse->rc==SQLITE_OK );\n            pParse->rc = SQLITE_ERROR;\n            assert( pParse->zErr==0 );\n            pParse->zErr = sqlite3_mprintf(\n                \"fts5: %s queries are not supported (detail!=full)\", \n                pNear->nPhrase==1 ? \"phrase\": \"NEAR\"\n                );\n            sqlite3_free(pRet);\n            pRet = 0;\n          }\n        }\n      }else{\n        fts5ExprAddChildren(pRet, pLeft);\n        fts5ExprAddChildren(pRet, pRight);\n      }\n    }\n  }\n\n  if( pRet==0 ){\n    assert( pParse->rc!=SQLITE_OK );\n    sqlite3Fts5ParseNodeFree(pLeft);\n    sqlite3Fts5ParseNodeFree(pRight);\n    sqlite3Fts5ParseNearsetFree(pNear);\n  }\n  return pRet;\n}\n\nstatic Fts5ExprNode *sqlite3Fts5ParseImplicitAnd(\n  Fts5Parse *pParse,              /* Parse context */\n  Fts5ExprNode *pLeft,            /* Left hand child expression */\n  Fts5ExprNode *pRight            /* Right hand child expression */\n){\n  Fts5ExprNode *pRet = 0;\n  Fts5ExprNode *pPrev;\n\n  if( pParse->rc ){\n    sqlite3Fts5ParseNodeFree(pLeft);\n    sqlite3Fts5ParseNodeFree(pRight);\n  }else{\n\n    assert( pLeft->eType==FTS5_STRING \n        || pLeft->eType==FTS5_TERM\n        || pLeft->eType==FTS5_EOF\n        || pLeft->eType==FTS5_AND\n    );\n    assert( pRight->eType==FTS5_STRING \n        || pRight->eType==FTS5_TERM \n        || pRight->eType==FTS5_EOF \n    );\n\n    if( pLeft->eType==FTS5_AND ){\n      pPrev = pLeft->apChild[pLeft->nChild-1];\n    }else{\n      pPrev = pLeft;\n    }\n    assert( pPrev->eType==FTS5_STRING \n        || pPrev->eType==FTS5_TERM \n        || pPrev->eType==FTS5_EOF \n        );\n\n    if( pRight->eType==FTS5_EOF ){\n      assert( pParse->apPhrase[pParse->nPhrase-1]==pRight->pNear->apPhrase[0] );\n      sqlite3Fts5ParseNodeFree(pRight);\n      pRet = pLeft;\n      pParse->nPhrase--;\n    }\n    else if( pPrev->eType==FTS5_EOF ){\n      Fts5ExprPhrase **ap;\n\n      if( pPrev==pLeft ){\n        pRet = pRight;\n      }else{\n        pLeft->apChild[pLeft->nChild-1] = pRight;\n        pRet = pLeft;\n      }\n\n      ap = &pParse->apPhrase[pParse->nPhrase-1-pRight->pNear->nPhrase];\n      assert( ap[0]==pPrev->pNear->apPhrase[0] );\n      memmove(ap, &ap[1], sizeof(Fts5ExprPhrase*)*pRight->pNear->nPhrase);\n      pParse->nPhrase--;\n\n      sqlite3Fts5ParseNodeFree(pPrev);\n    }\n    else{\n      pRet = sqlite3Fts5ParseNode(pParse, FTS5_AND, pLeft, pRight, 0);\n    }\n  }\n\n  return pRet;\n}\n\nstatic char *fts5ExprTermPrint(Fts5ExprTerm *pTerm){\n  sqlite3_int64 nByte = 0;\n  Fts5ExprTerm *p;\n  char *zQuoted;\n\n  /* Determine the maximum amount of space required. */\n  for(p=pTerm; p; p=p->pSynonym){\n    nByte += (int)strlen(pTerm->zTerm) * 2 + 3 + 2;\n  }\n  zQuoted = sqlite3_malloc64(nByte);\n\n  if( zQuoted ){\n    int i = 0;\n    for(p=pTerm; p; p=p->pSynonym){\n      char *zIn = p->zTerm;\n      zQuoted[i++] = '\"';\n      while( *zIn ){\n        if( *zIn=='\"' ) zQuoted[i++] = '\"';\n        zQuoted[i++] = *zIn++;\n      }\n      zQuoted[i++] = '\"';\n      if( p->pSynonym ) zQuoted[i++] = '|';\n    }\n    if( pTerm->bPrefix ){\n      zQuoted[i++] = ' ';\n      zQuoted[i++] = '*';\n    }\n    zQuoted[i++] = '\\0';\n  }\n  return zQuoted;\n}\n\nstatic char *fts5PrintfAppend(char *zApp, const char *zFmt, ...){\n  char *zNew;\n  va_list ap;\n  va_start(ap, zFmt);\n  zNew = sqlite3_vmprintf(zFmt, ap);\n  va_end(ap);\n  if( zApp && zNew ){\n    char *zNew2 = sqlite3_mprintf(\"%s%s\", zApp, zNew);\n    sqlite3_free(zNew);\n    zNew = zNew2;\n  }\n  sqlite3_free(zApp);\n  return zNew;\n}\n\n/*\n** Compose a tcl-readable representation of expression pExpr. Return a \n** pointer to a buffer containing that representation. It is the \n** responsibility of the caller to at some point free the buffer using \n** sqlite3_free().\n*/\nstatic char *fts5ExprPrintTcl(\n  Fts5Config *pConfig, \n  const char *zNearsetCmd,\n  Fts5ExprNode *pExpr\n){\n  char *zRet = 0;\n  if( pExpr->eType==FTS5_STRING || pExpr->eType==FTS5_TERM ){\n    Fts5ExprNearset *pNear = pExpr->pNear;\n    int i; \n    int iTerm;\n\n    zRet = fts5PrintfAppend(zRet, \"%s \", zNearsetCmd);\n    if( zRet==0 ) return 0;\n    if( pNear->pColset ){\n      int *aiCol = pNear->pColset->aiCol;\n      int nCol = pNear->pColset->nCol;\n      if( nCol==1 ){\n        zRet = fts5PrintfAppend(zRet, \"-col %d \", aiCol[0]);\n      }else{\n        zRet = fts5PrintfAppend(zRet, \"-col {%d\", aiCol[0]);\n        for(i=1; i<pNear->pColset->nCol; i++){\n          zRet = fts5PrintfAppend(zRet, \" %d\", aiCol[i]);\n        }\n        zRet = fts5PrintfAppend(zRet, \"} \");\n      }\n      if( zRet==0 ) return 0;\n    }\n\n    if( pNear->nPhrase>1 ){\n      zRet = fts5PrintfAppend(zRet, \"-near %d \", pNear->nNear);\n      if( zRet==0 ) return 0;\n    }\n\n    zRet = fts5PrintfAppend(zRet, \"--\");\n    if( zRet==0 ) return 0;\n\n    for(i=0; i<pNear->nPhrase; i++){\n      Fts5ExprPhrase *pPhrase = pNear->apPhrase[i];\n\n      zRet = fts5PrintfAppend(zRet, \" {\");\n      for(iTerm=0; zRet && iTerm<pPhrase->nTerm; iTerm++){\n        char *zTerm = pPhrase->aTerm[iTerm].zTerm;\n        zRet = fts5PrintfAppend(zRet, \"%s%s\", iTerm==0?\"\":\" \", zTerm);\n        if( pPhrase->aTerm[iTerm].bPrefix ){\n          zRet = fts5PrintfAppend(zRet, \"*\");\n        }\n      }\n\n      if( zRet ) zRet = fts5PrintfAppend(zRet, \"}\");\n      if( zRet==0 ) return 0;\n    }\n\n  }else{\n    char const *zOp = 0;\n    int i;\n    switch( pExpr->eType ){\n      case FTS5_AND: zOp = \"AND\"; break;\n      case FTS5_NOT: zOp = \"NOT\"; break;\n      default: \n        assert( pExpr->eType==FTS5_OR );\n        zOp = \"OR\"; \n        break;\n    }\n\n    zRet = sqlite3_mprintf(\"%s\", zOp);\n    for(i=0; zRet && i<pExpr->nChild; i++){\n      char *z = fts5ExprPrintTcl(pConfig, zNearsetCmd, pExpr->apChild[i]);\n      if( !z ){\n        sqlite3_free(zRet);\n        zRet = 0;\n      }else{\n        zRet = fts5PrintfAppend(zRet, \" [%z]\", z);\n      }\n    }\n  }\n\n  return zRet;\n}\n\nstatic char *fts5ExprPrint(Fts5Config *pConfig, Fts5ExprNode *pExpr){\n  char *zRet = 0;\n  if( pExpr->eType==0 ){\n    return sqlite3_mprintf(\"\\\"\\\"\");\n  }else\n  if( pExpr->eType==FTS5_STRING || pExpr->eType==FTS5_TERM ){\n    Fts5ExprNearset *pNear = pExpr->pNear;\n    int i; \n    int iTerm;\n\n    if( pNear->pColset ){\n      int iCol = pNear->pColset->aiCol[0];\n      zRet = fts5PrintfAppend(zRet, \"%s : \", pConfig->azCol[iCol]);\n      if( zRet==0 ) return 0;\n    }\n\n    if( pNear->nPhrase>1 ){\n      zRet = fts5PrintfAppend(zRet, \"NEAR(\");\n      if( zRet==0 ) return 0;\n    }\n\n    for(i=0; i<pNear->nPhrase; i++){\n      Fts5ExprPhrase *pPhrase = pNear->apPhrase[i];\n      if( i!=0 ){\n        zRet = fts5PrintfAppend(zRet, \" \");\n        if( zRet==0 ) return 0;\n      }\n      for(iTerm=0; iTerm<pPhrase->nTerm; iTerm++){\n        char *zTerm = fts5ExprTermPrint(&pPhrase->aTerm[iTerm]);\n        if( zTerm ){\n          zRet = fts5PrintfAppend(zRet, \"%s%s\", iTerm==0?\"\":\" + \", zTerm);\n          sqlite3_free(zTerm);\n        }\n        if( zTerm==0 || zRet==0 ){\n          sqlite3_free(zRet);\n          return 0;\n        }\n      }\n    }\n\n    if( pNear->nPhrase>1 ){\n      zRet = fts5PrintfAppend(zRet, \", %d)\", pNear->nNear);\n      if( zRet==0 ) return 0;\n    }\n\n  }else{\n    char const *zOp = 0;\n    int i;\n\n    switch( pExpr->eType ){\n      case FTS5_AND: zOp = \" AND \"; break;\n      case FTS5_NOT: zOp = \" NOT \"; break;\n      default:  \n        assert( pExpr->eType==FTS5_OR );\n        zOp = \" OR \"; \n        break;\n    }\n\n    for(i=0; i<pExpr->nChild; i++){\n      char *z = fts5ExprPrint(pConfig, pExpr->apChild[i]);\n      if( z==0 ){\n        sqlite3_free(zRet);\n        zRet = 0;\n      }else{\n        int e = pExpr->apChild[i]->eType;\n        int b = (e!=FTS5_STRING && e!=FTS5_TERM && e!=FTS5_EOF);\n        zRet = fts5PrintfAppend(zRet, \"%s%s%z%s\", \n            (i==0 ? \"\" : zOp),\n            (b?\"(\":\"\"), z, (b?\")\":\"\")\n        );\n      }\n      if( zRet==0 ) break;\n    }\n  }\n\n  return zRet;\n}\n\n/*\n** The implementation of user-defined scalar functions fts5_expr() (bTcl==0)\n** and fts5_expr_tcl() (bTcl!=0).\n*/\nstatic void fts5ExprFunction(\n  sqlite3_context *pCtx,          /* Function call context */\n  int nArg,                       /* Number of args */\n  sqlite3_value **apVal,          /* Function arguments */\n  int bTcl\n){\n  Fts5Global *pGlobal = (Fts5Global*)sqlite3_user_data(pCtx);\n  sqlite3 *db = sqlite3_context_db_handle(pCtx);\n  const char *zExpr = 0;\n  char *zErr = 0;\n  Fts5Expr *pExpr = 0;\n  int rc;\n  int i;\n\n  const char **azConfig;          /* Array of arguments for Fts5Config */\n  const char *zNearsetCmd = \"nearset\";\n  int nConfig;                    /* Size of azConfig[] */\n  Fts5Config *pConfig = 0;\n  int iArg = 1;\n\n  if( nArg<1 ){\n    zErr = sqlite3_mprintf(\"wrong number of arguments to function %s\",\n        bTcl ? \"fts5_expr_tcl\" : \"fts5_expr\"\n    );\n    sqlite3_result_error(pCtx, zErr, -1);\n    sqlite3_free(zErr);\n    return;\n  }\n\n  if( bTcl && nArg>1 ){\n    zNearsetCmd = (const char*)sqlite3_value_text(apVal[1]);\n    iArg = 2;\n  }\n\n  nConfig = 3 + (nArg-iArg);\n  azConfig = (const char**)sqlite3_malloc64(sizeof(char*) * nConfig);\n  if( azConfig==0 ){\n    sqlite3_result_error_nomem(pCtx);\n    return;\n  }\n  azConfig[0] = 0;\n  azConfig[1] = \"main\";\n  azConfig[2] = \"tbl\";\n  for(i=3; iArg<nArg; iArg++){\n    azConfig[i++] = (const char*)sqlite3_value_text(apVal[iArg]);\n  }\n\n  zExpr = (const char*)sqlite3_value_text(apVal[0]);\n\n  rc = sqlite3Fts5ConfigParse(pGlobal, db, nConfig, azConfig, &pConfig, &zErr);\n  if( rc==SQLITE_OK ){\n    rc = sqlite3Fts5ExprNew(pConfig, pConfig->nCol, zExpr, &pExpr, &zErr);\n  }\n  if( rc==SQLITE_OK ){\n    char *zText;\n    if( pExpr->pRoot->xNext==0 ){\n      zText = sqlite3_mprintf(\"\");\n    }else if( bTcl ){\n      zText = fts5ExprPrintTcl(pConfig, zNearsetCmd, pExpr->pRoot);\n    }else{\n      zText = fts5ExprPrint(pConfig, pExpr->pRoot);\n    }\n    if( zText==0 ){\n      rc = SQLITE_NOMEM;\n    }else{\n      sqlite3_result_text(pCtx, zText, -1, SQLITE_TRANSIENT);\n      sqlite3_free(zText);\n    }\n  }\n\n  if( rc!=SQLITE_OK ){\n    if( zErr ){\n      sqlite3_result_error(pCtx, zErr, -1);\n      sqlite3_free(zErr);\n    }else{\n      sqlite3_result_error_code(pCtx, rc);\n    }\n  }\n  sqlite3_free((void *)azConfig);\n  sqlite3Fts5ConfigFree(pConfig);\n  sqlite3Fts5ExprFree(pExpr);\n}\n\nstatic void fts5ExprFunctionHr(\n  sqlite3_context *pCtx,          /* Function call context */\n  int nArg,                       /* Number of args */\n  sqlite3_value **apVal           /* Function arguments */\n){\n  fts5ExprFunction(pCtx, nArg, apVal, 0);\n}\nstatic void fts5ExprFunctionTcl(\n  sqlite3_context *pCtx,          /* Function call context */\n  int nArg,                       /* Number of args */\n  sqlite3_value **apVal           /* Function arguments */\n){\n  fts5ExprFunction(pCtx, nArg, apVal, 1);\n}\n\n/*\n** The implementation of an SQLite user-defined-function that accepts a\n** single integer as an argument. If the integer is an alpha-numeric \n** unicode code point, 1 is returned. Otherwise 0.\n*/\nstatic void fts5ExprIsAlnum(\n  sqlite3_context *pCtx,          /* Function call context */\n  int nArg,                       /* Number of args */\n  sqlite3_value **apVal           /* Function arguments */\n){\n  int iCode;\n  u8 aArr[32];\n  if( nArg!=1 ){\n    sqlite3_result_error(pCtx, \n        \"wrong number of arguments to function fts5_isalnum\", -1\n    );\n    return;\n  }\n  memset(aArr, 0, sizeof(aArr));\n  sqlite3Fts5UnicodeCatParse(\"L*\", aArr);\n  sqlite3Fts5UnicodeCatParse(\"N*\", aArr);\n  sqlite3Fts5UnicodeCatParse(\"Co\", aArr);\n  iCode = sqlite3_value_int(apVal[0]);\n  sqlite3_result_int(pCtx, aArr[sqlite3Fts5UnicodeCategory((u32)iCode)]);\n}\n\nstatic void fts5ExprFold(\n  sqlite3_context *pCtx,          /* Function call context */\n  int nArg,                       /* Number of args */\n  sqlite3_value **apVal           /* Function arguments */\n){\n  if( nArg!=1 && nArg!=2 ){\n    sqlite3_result_error(pCtx, \n        \"wrong number of arguments to function fts5_fold\", -1\n    );\n  }else{\n    int iCode;\n    int bRemoveDiacritics = 0;\n    iCode = sqlite3_value_int(apVal[0]);\n    if( nArg==2 ) bRemoveDiacritics = sqlite3_value_int(apVal[1]);\n    sqlite3_result_int(pCtx, sqlite3Fts5UnicodeFold(iCode, bRemoveDiacritics));\n  }\n}\n\n/*\n** This is called during initialization to register the fts5_expr() scalar\n** UDF with the SQLite handle passed as the only argument.\n*/\nstatic int sqlite3Fts5ExprInit(Fts5Global *pGlobal, sqlite3 *db){\n  struct Fts5ExprFunc {\n    const char *z;\n    void (*x)(sqlite3_context*,int,sqlite3_value**);\n  } aFunc[] = {\n    { \"fts5_expr\",     fts5ExprFunctionHr },\n    { \"fts5_expr_tcl\", fts5ExprFunctionTcl },\n    { \"fts5_isalnum\",  fts5ExprIsAlnum },\n    { \"fts5_fold\",     fts5ExprFold },\n  };\n  int i;\n  int rc = SQLITE_OK;\n  void *pCtx = (void*)pGlobal;\n\n  for(i=0; rc==SQLITE_OK && i<ArraySize(aFunc); i++){\n    struct Fts5ExprFunc *p = &aFunc[i];\n    rc = sqlite3_create_function(db, p->z, -1, SQLITE_UTF8, pCtx, p->x, 0, 0);\n  }\n\n  /* Avoid warnings indicating that sqlite3Fts5ParserTrace() and\n  ** sqlite3Fts5ParserFallback() are unused */\n#ifndef NDEBUG\n  (void)sqlite3Fts5ParserTrace;\n#endif\n  (void)sqlite3Fts5ParserFallback;\n\n  return rc;\n}\n\n/*\n** Return the number of phrases in expression pExpr.\n*/\nstatic int sqlite3Fts5ExprPhraseCount(Fts5Expr *pExpr){\n  return (pExpr ? pExpr->nPhrase : 0);\n}\n\n/*\n** Return the number of terms in the iPhrase'th phrase in pExpr.\n*/\nstatic int sqlite3Fts5ExprPhraseSize(Fts5Expr *pExpr, int iPhrase){\n  if( iPhrase<0 || iPhrase>=pExpr->nPhrase ) return 0;\n  return pExpr->apExprPhrase[iPhrase]->nTerm;\n}\n\n/*\n** This function is used to access the current position list for phrase\n** iPhrase.\n*/\nstatic int sqlite3Fts5ExprPoslist(Fts5Expr *pExpr, int iPhrase, const u8 **pa){\n  int nRet;\n  Fts5ExprPhrase *pPhrase = pExpr->apExprPhrase[iPhrase];\n  Fts5ExprNode *pNode = pPhrase->pNode;\n  if( pNode->bEof==0 && pNode->iRowid==pExpr->pRoot->iRowid ){\n    *pa = pPhrase->poslist.p;\n    nRet = pPhrase->poslist.n;\n  }else{\n    *pa = 0;\n    nRet = 0;\n  }\n  return nRet;\n}\n\nstruct Fts5PoslistPopulator {\n  Fts5PoslistWriter writer;\n  int bOk;                        /* True if ok to populate */\n  int bMiss;\n};\n\nstatic Fts5PoslistPopulator *sqlite3Fts5ExprClearPoslists(Fts5Expr *pExpr, int bLive){\n  Fts5PoslistPopulator *pRet;\n  pRet = sqlite3_malloc64(sizeof(Fts5PoslistPopulator)*pExpr->nPhrase);\n  if( pRet ){\n    int i;\n    memset(pRet, 0, sizeof(Fts5PoslistPopulator)*pExpr->nPhrase);\n    for(i=0; i<pExpr->nPhrase; i++){\n      Fts5Buffer *pBuf = &pExpr->apExprPhrase[i]->poslist;\n      Fts5ExprNode *pNode = pExpr->apExprPhrase[i]->pNode;\n      assert( pExpr->apExprPhrase[i]->nTerm==1 );\n      if( bLive && \n          (pBuf->n==0 || pNode->iRowid!=pExpr->pRoot->iRowid || pNode->bEof)\n      ){\n        pRet[i].bMiss = 1;\n      }else{\n        pBuf->n = 0;\n      }\n    }\n  }\n  return pRet;\n}\n\nstruct Fts5ExprCtx {\n  Fts5Expr *pExpr;\n  Fts5PoslistPopulator *aPopulator;\n  i64 iOff;\n};\ntypedef struct Fts5ExprCtx Fts5ExprCtx;\n\n/*\n** TODO: Make this more efficient!\n*/\nstatic int fts5ExprColsetTest(Fts5Colset *pColset, int iCol){\n  int i;\n  for(i=0; i<pColset->nCol; i++){\n    if( pColset->aiCol[i]==iCol ) return 1;\n  }\n  return 0;\n}\n\nstatic int fts5ExprPopulatePoslistsCb(\n  void *pCtx,                /* Copy of 2nd argument to xTokenize() */\n  int tflags,                /* Mask of FTS5_TOKEN_* flags */\n  const char *pToken,        /* Pointer to buffer containing token */\n  int nToken,                /* Size of token in bytes */\n  int iUnused1,              /* Byte offset of token within input text */\n  int iUnused2               /* Byte offset of end of token within input text */\n){\n  Fts5ExprCtx *p = (Fts5ExprCtx*)pCtx;\n  Fts5Expr *pExpr = p->pExpr;\n  int i;\n\n  UNUSED_PARAM2(iUnused1, iUnused2);\n\n  if( nToken>FTS5_MAX_TOKEN_SIZE ) nToken = FTS5_MAX_TOKEN_SIZE;\n  if( (tflags & FTS5_TOKEN_COLOCATED)==0 ) p->iOff++;\n  for(i=0; i<pExpr->nPhrase; i++){\n    Fts5ExprTerm *pTerm;\n    if( p->aPopulator[i].bOk==0 ) continue;\n    for(pTerm=&pExpr->apExprPhrase[i]->aTerm[0]; pTerm; pTerm=pTerm->pSynonym){\n      int nTerm = (int)strlen(pTerm->zTerm);\n      if( (nTerm==nToken || (nTerm<nToken && pTerm->bPrefix))\n       && memcmp(pTerm->zTerm, pToken, nTerm)==0\n      ){\n        int rc = sqlite3Fts5PoslistWriterAppend(\n            &pExpr->apExprPhrase[i]->poslist, &p->aPopulator[i].writer, p->iOff\n        );\n        if( rc ) return rc;\n        break;\n      }\n    }\n  }\n  return SQLITE_OK;\n}\n\nstatic int sqlite3Fts5ExprPopulatePoslists(\n  Fts5Config *pConfig,\n  Fts5Expr *pExpr, \n  Fts5PoslistPopulator *aPopulator,\n  int iCol, \n  const char *z, int n\n){\n  int i;\n  Fts5ExprCtx sCtx;\n  sCtx.pExpr = pExpr;\n  sCtx.aPopulator = aPopulator;\n  sCtx.iOff = (((i64)iCol) << 32) - 1;\n\n  for(i=0; i<pExpr->nPhrase; i++){\n    Fts5ExprNode *pNode = pExpr->apExprPhrase[i]->pNode;\n    Fts5Colset *pColset = pNode->pNear->pColset;\n    if( (pColset && 0==fts5ExprColsetTest(pColset, iCol)) \n     || aPopulator[i].bMiss\n    ){\n      aPopulator[i].bOk = 0;\n    }else{\n      aPopulator[i].bOk = 1;\n    }\n  }\n\n  return sqlite3Fts5Tokenize(pConfig, \n      FTS5_TOKENIZE_DOCUMENT, z, n, (void*)&sCtx, fts5ExprPopulatePoslistsCb\n  );\n}\n\nstatic void fts5ExprClearPoslists(Fts5ExprNode *pNode){\n  if( pNode->eType==FTS5_TERM || pNode->eType==FTS5_STRING ){\n    pNode->pNear->apPhrase[0]->poslist.n = 0;\n  }else{\n    int i;\n    for(i=0; i<pNode->nChild; i++){\n      fts5ExprClearPoslists(pNode->apChild[i]);\n    }\n  }\n}\n\nstatic int fts5ExprCheckPoslists(Fts5ExprNode *pNode, i64 iRowid){\n  pNode->iRowid = iRowid;\n  pNode->bEof = 0;\n  switch( pNode->eType ){\n    case FTS5_TERM:\n    case FTS5_STRING:\n      return (pNode->pNear->apPhrase[0]->poslist.n>0);\n\n    case FTS5_AND: {\n      int i;\n      for(i=0; i<pNode->nChild; i++){\n        if( fts5ExprCheckPoslists(pNode->apChild[i], iRowid)==0 ){\n          fts5ExprClearPoslists(pNode);\n          return 0;\n        }\n      }\n      break;\n    }\n\n    case FTS5_OR: {\n      int i;\n      int bRet = 0;\n      for(i=0; i<pNode->nChild; i++){\n        if( fts5ExprCheckPoslists(pNode->apChild[i], iRowid) ){\n          bRet = 1;\n        }\n      }\n      return bRet;\n    }\n\n    default: {\n      assert( pNode->eType==FTS5_NOT );\n      if( 0==fts5ExprCheckPoslists(pNode->apChild[0], iRowid)\n          || 0!=fts5ExprCheckPoslists(pNode->apChild[1], iRowid)\n        ){\n        fts5ExprClearPoslists(pNode);\n        return 0;\n      }\n      break;\n    }\n  }\n  return 1;\n}\n\nstatic void sqlite3Fts5ExprCheckPoslists(Fts5Expr *pExpr, i64 iRowid){\n  fts5ExprCheckPoslists(pExpr->pRoot, iRowid);\n}\n\n/*\n** This function is only called for detail=columns tables. \n*/\nstatic int sqlite3Fts5ExprPhraseCollist(\n  Fts5Expr *pExpr, \n  int iPhrase, \n  const u8 **ppCollist, \n  int *pnCollist\n){\n  Fts5ExprPhrase *pPhrase = pExpr->apExprPhrase[iPhrase];\n  Fts5ExprNode *pNode = pPhrase->pNode;\n  int rc = SQLITE_OK;\n\n  assert( iPhrase>=0 && iPhrase<pExpr->nPhrase );\n  assert( pExpr->pConfig->eDetail==FTS5_DETAIL_COLUMNS );\n\n  if( pNode->bEof==0 \n   && pNode->iRowid==pExpr->pRoot->iRowid \n   && pPhrase->poslist.n>0\n  ){\n    Fts5ExprTerm *pTerm = &pPhrase->aTerm[0];\n    if( pTerm->pSynonym ){\n      Fts5Buffer *pBuf = (Fts5Buffer*)&pTerm->pSynonym[1];\n      rc = fts5ExprSynonymList(\n          pTerm, pNode->iRowid, pBuf, (u8**)ppCollist, pnCollist\n      );\n    }else{\n      *ppCollist = pPhrase->aTerm[0].pIter->pData;\n      *pnCollist = pPhrase->aTerm[0].pIter->nData;\n    }\n  }else{\n    *ppCollist = 0;\n    *pnCollist = 0;\n  }\n\n  return rc;\n}\n\n/*\n** 2014 August 11\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n******************************************************************************\n**\n*/\n\n\n\n/* #include \"fts5Int.h\" */\n\ntypedef struct Fts5HashEntry Fts5HashEntry;\n\n/*\n** This file contains the implementation of an in-memory hash table used\n** to accumuluate \"term -> doclist\" content before it is flused to a level-0\n** segment.\n*/\n\n\nstruct Fts5Hash {\n  int eDetail;                    /* Copy of Fts5Config.eDetail */\n  int *pnByte;                    /* Pointer to bytes counter */\n  int nEntry;                     /* Number of entries currently in hash */\n  int nSlot;                      /* Size of aSlot[] array */\n  Fts5HashEntry *pScan;           /* Current ordered scan item */\n  Fts5HashEntry **aSlot;          /* Array of hash slots */\n};\n\n/*\n** Each entry in the hash table is represented by an object of the \n** following type. Each object, its key (a nul-terminated string) and \n** its current data are stored in a single memory allocation. The \n** key immediately follows the object in memory. The position list\n** data immediately follows the key data in memory.\n**\n** The data that follows the key is in a similar, but not identical format\n** to the doclist data stored in the database. It is:\n**\n**   * Rowid, as a varint\n**   * Position list, without 0x00 terminator.\n**   * Size of previous position list and rowid, as a 4 byte\n**     big-endian integer.\n**\n** iRowidOff:\n**   Offset of last rowid written to data area. Relative to first byte of\n**   structure.\n**\n** nData:\n**   Bytes of data written since iRowidOff.\n*/\nstruct Fts5HashEntry {\n  Fts5HashEntry *pHashNext;       /* Next hash entry with same hash-key */\n  Fts5HashEntry *pScanNext;       /* Next entry in sorted order */\n  \n  int nAlloc;                     /* Total size of allocation */\n  int iSzPoslist;                 /* Offset of space for 4-byte poslist size */\n  int nData;                      /* Total bytes of data (incl. structure) */\n  int nKey;                       /* Length of key in bytes */\n  u8 bDel;                        /* Set delete-flag @ iSzPoslist */\n  u8 bContent;                    /* Set content-flag (detail=none mode) */\n  i16 iCol;                       /* Column of last value written */\n  int iPos;                       /* Position of last value written */\n  i64 iRowid;                     /* Rowid of last value written */\n};\n\n/*\n** Eqivalent to:\n**\n**   char *fts5EntryKey(Fts5HashEntry *pEntry){ return zKey; }\n*/\n#define fts5EntryKey(p) ( ((char *)(&(p)[1])) )\n\n\n/*\n** Allocate a new hash table.\n*/\nstatic int sqlite3Fts5HashNew(Fts5Config *pConfig, Fts5Hash **ppNew, int *pnByte){\n  int rc = SQLITE_OK;\n  Fts5Hash *pNew;\n\n  *ppNew = pNew = (Fts5Hash*)sqlite3_malloc(sizeof(Fts5Hash));\n  if( pNew==0 ){\n    rc = SQLITE_NOMEM;\n  }else{\n    sqlite3_int64 nByte;\n    memset(pNew, 0, sizeof(Fts5Hash));\n    pNew->pnByte = pnByte;\n    pNew->eDetail = pConfig->eDetail;\n\n    pNew->nSlot = 1024;\n    nByte = sizeof(Fts5HashEntry*) * pNew->nSlot;\n    pNew->aSlot = (Fts5HashEntry**)sqlite3_malloc64(nByte);\n    if( pNew->aSlot==0 ){\n      sqlite3_free(pNew);\n      *ppNew = 0;\n      rc = SQLITE_NOMEM;\n    }else{\n      memset(pNew->aSlot, 0, nByte);\n    }\n  }\n  return rc;\n}\n\n/*\n** Free a hash table object.\n*/\nstatic void sqlite3Fts5HashFree(Fts5Hash *pHash){\n  if( pHash ){\n    sqlite3Fts5HashClear(pHash);\n    sqlite3_free(pHash->aSlot);\n    sqlite3_free(pHash);\n  }\n}\n\n/*\n** Empty (but do not delete) a hash table.\n*/\nstatic void sqlite3Fts5HashClear(Fts5Hash *pHash){\n  int i;\n  for(i=0; i<pHash->nSlot; i++){\n    Fts5HashEntry *pNext;\n    Fts5HashEntry *pSlot;\n    for(pSlot=pHash->aSlot[i]; pSlot; pSlot=pNext){\n      pNext = pSlot->pHashNext;\n      sqlite3_free(pSlot);\n    }\n  }\n  memset(pHash->aSlot, 0, pHash->nSlot * sizeof(Fts5HashEntry*));\n  pHash->nEntry = 0;\n}\n\nstatic unsigned int fts5HashKey(int nSlot, const u8 *p, int n){\n  int i;\n  unsigned int h = 13;\n  for(i=n-1; i>=0; i--){\n    h = (h << 3) ^ h ^ p[i];\n  }\n  return (h % nSlot);\n}\n\nstatic unsigned int fts5HashKey2(int nSlot, u8 b, const u8 *p, int n){\n  int i;\n  unsigned int h = 13;\n  for(i=n-1; i>=0; i--){\n    h = (h << 3) ^ h ^ p[i];\n  }\n  h = (h << 3) ^ h ^ b;\n  return (h % nSlot);\n}\n\n/*\n** Resize the hash table by doubling the number of slots.\n*/\nstatic int fts5HashResize(Fts5Hash *pHash){\n  int nNew = pHash->nSlot*2;\n  int i;\n  Fts5HashEntry **apNew;\n  Fts5HashEntry **apOld = pHash->aSlot;\n\n  apNew = (Fts5HashEntry**)sqlite3_malloc64(nNew*sizeof(Fts5HashEntry*));\n  if( !apNew ) return SQLITE_NOMEM;\n  memset(apNew, 0, nNew*sizeof(Fts5HashEntry*));\n\n  for(i=0; i<pHash->nSlot; i++){\n    while( apOld[i] ){\n      unsigned int iHash;\n      Fts5HashEntry *p = apOld[i];\n      apOld[i] = p->pHashNext;\n      iHash = fts5HashKey(nNew, (u8*)fts5EntryKey(p),\n                          (int)strlen(fts5EntryKey(p)));\n      p->pHashNext = apNew[iHash];\n      apNew[iHash] = p;\n    }\n  }\n\n  sqlite3_free(apOld);\n  pHash->nSlot = nNew;\n  pHash->aSlot = apNew;\n  return SQLITE_OK;\n}\n\nstatic void fts5HashAddPoslistSize(Fts5Hash *pHash, Fts5HashEntry *p){\n  if( p->iSzPoslist ){\n    u8 *pPtr = (u8*)p;\n    if( pHash->eDetail==FTS5_DETAIL_NONE ){\n      assert( p->nData==p->iSzPoslist );\n      if( p->bDel ){\n        pPtr[p->nData++] = 0x00;\n        if( p->bContent ){\n          pPtr[p->nData++] = 0x00;\n        }\n      }\n    }else{\n      int nSz = (p->nData - p->iSzPoslist - 1);       /* Size in bytes */\n      int nPos = nSz*2 + p->bDel;                     /* Value of nPos field */\n\n      assert( p->bDel==0 || p->bDel==1 );\n      if( nPos<=127 ){\n        pPtr[p->iSzPoslist] = (u8)nPos;\n      }else{\n        int nByte = sqlite3Fts5GetVarintLen((u32)nPos);\n        memmove(&pPtr[p->iSzPoslist + nByte], &pPtr[p->iSzPoslist + 1], nSz);\n        sqlite3Fts5PutVarint(&pPtr[p->iSzPoslist], nPos);\n        p->nData += (nByte-1);\n      }\n    }\n\n    p->iSzPoslist = 0;\n    p->bDel = 0;\n    p->bContent = 0;\n  }\n}\n\n/*\n** Add an entry to the in-memory hash table. The key is the concatenation\n** of bByte and (pToken/nToken). The value is (iRowid/iCol/iPos).\n**\n**     (bByte || pToken) -> (iRowid,iCol,iPos)\n**\n** Or, if iCol is negative, then the value is a delete marker.\n*/\nstatic int sqlite3Fts5HashWrite(\n  Fts5Hash *pHash,\n  i64 iRowid,                     /* Rowid for this entry */\n  int iCol,                       /* Column token appears in (-ve -> delete) */\n  int iPos,                       /* Position of token within column */\n  char bByte,                     /* First byte of token */\n  const char *pToken, int nToken  /* Token to add or remove to or from index */\n){\n  unsigned int iHash;\n  Fts5HashEntry *p;\n  u8 *pPtr;\n  int nIncr = 0;                  /* Amount to increment (*pHash->pnByte) by */\n  int bNew;                       /* If non-delete entry should be written */\n  \n  bNew = (pHash->eDetail==FTS5_DETAIL_FULL);\n\n  /* Attempt to locate an existing hash entry */\n  iHash = fts5HashKey2(pHash->nSlot, (u8)bByte, (const u8*)pToken, nToken);\n  for(p=pHash->aSlot[iHash]; p; p=p->pHashNext){\n    char *zKey = fts5EntryKey(p);\n    if( zKey[0]==bByte \n     && p->nKey==nToken\n     && memcmp(&zKey[1], pToken, nToken)==0 \n    ){\n      break;\n    }\n  }\n\n  /* If an existing hash entry cannot be found, create a new one. */\n  if( p==0 ){\n    /* Figure out how much space to allocate */\n    char *zKey;\n    sqlite3_int64 nByte = sizeof(Fts5HashEntry) + (nToken+1) + 1 + 64;\n    if( nByte<128 ) nByte = 128;\n\n    /* Grow the Fts5Hash.aSlot[] array if necessary. */\n    if( (pHash->nEntry*2)>=pHash->nSlot ){\n      int rc = fts5HashResize(pHash);\n      if( rc!=SQLITE_OK ) return rc;\n      iHash = fts5HashKey2(pHash->nSlot, (u8)bByte, (const u8*)pToken, nToken);\n    }\n\n    /* Allocate new Fts5HashEntry and add it to the hash table. */\n    p = (Fts5HashEntry*)sqlite3_malloc64(nByte);\n    if( !p ) return SQLITE_NOMEM;\n    memset(p, 0, sizeof(Fts5HashEntry));\n    p->nAlloc = nByte;\n    zKey = fts5EntryKey(p);\n    zKey[0] = bByte;\n    memcpy(&zKey[1], pToken, nToken);\n    assert( iHash==fts5HashKey(pHash->nSlot, (u8*)zKey, nToken+1) );\n    p->nKey = nToken;\n    zKey[nToken+1] = '\\0';\n    p->nData = nToken+1 + 1 + sizeof(Fts5HashEntry);\n    p->pHashNext = pHash->aSlot[iHash];\n    pHash->aSlot[iHash] = p;\n    pHash->nEntry++;\n\n    /* Add the first rowid field to the hash-entry */\n    p->nData += sqlite3Fts5PutVarint(&((u8*)p)[p->nData], iRowid);\n    p->iRowid = iRowid;\n\n    p->iSzPoslist = p->nData;\n    if( pHash->eDetail!=FTS5_DETAIL_NONE ){\n      p->nData += 1;\n      p->iCol = (pHash->eDetail==FTS5_DETAIL_FULL ? 0 : -1);\n    }\n\n    nIncr += p->nData;\n  }else{\n\n    /* Appending to an existing hash-entry. Check that there is enough \n    ** space to append the largest possible new entry. Worst case scenario \n    ** is:\n    **\n    **     + 9 bytes for a new rowid,\n    **     + 4 byte reserved for the \"poslist size\" varint.\n    **     + 1 byte for a \"new column\" byte,\n    **     + 3 bytes for a new column number (16-bit max) as a varint,\n    **     + 5 bytes for the new position offset (32-bit max).\n    */\n    if( (p->nAlloc - p->nData) < (9 + 4 + 1 + 3 + 5) ){\n      sqlite3_int64 nNew = p->nAlloc * 2;\n      Fts5HashEntry *pNew;\n      Fts5HashEntry **pp;\n      pNew = (Fts5HashEntry*)sqlite3_realloc64(p, nNew);\n      if( pNew==0 ) return SQLITE_NOMEM;\n      pNew->nAlloc = (int)nNew;\n      for(pp=&pHash->aSlot[iHash]; *pp!=p; pp=&(*pp)->pHashNext);\n      *pp = pNew;\n      p = pNew;\n    }\n    nIncr -= p->nData;\n  }\n  assert( (p->nAlloc - p->nData) >= (9 + 4 + 1 + 3 + 5) );\n\n  pPtr = (u8*)p;\n\n  /* If this is a new rowid, append the 4-byte size field for the previous\n  ** entry, and the new rowid for this entry.  */\n  if( iRowid!=p->iRowid ){\n    fts5HashAddPoslistSize(pHash, p);\n    p->nData += sqlite3Fts5PutVarint(&pPtr[p->nData], iRowid - p->iRowid);\n    p->iRowid = iRowid;\n    bNew = 1;\n    p->iSzPoslist = p->nData;\n    if( pHash->eDetail!=FTS5_DETAIL_NONE ){\n      p->nData += 1;\n      p->iCol = (pHash->eDetail==FTS5_DETAIL_FULL ? 0 : -1);\n      p->iPos = 0;\n    }\n  }\n\n  if( iCol>=0 ){\n    if( pHash->eDetail==FTS5_DETAIL_NONE ){\n      p->bContent = 1;\n    }else{\n      /* Append a new column value, if necessary */\n      assert( iCol>=p->iCol );\n      if( iCol!=p->iCol ){\n        if( pHash->eDetail==FTS5_DETAIL_FULL ){\n          pPtr[p->nData++] = 0x01;\n          p->nData += sqlite3Fts5PutVarint(&pPtr[p->nData], iCol);\n          p->iCol = (i16)iCol;\n          p->iPos = 0;\n        }else{\n          bNew = 1;\n          p->iCol = (i16)(iPos = iCol);\n        }\n      }\n\n      /* Append the new position offset, if necessary */\n      if( bNew ){\n        p->nData += sqlite3Fts5PutVarint(&pPtr[p->nData], iPos - p->iPos + 2);\n        p->iPos = iPos;\n      }\n    }\n  }else{\n    /* This is a delete. Set the delete flag. */\n    p->bDel = 1;\n  }\n\n  nIncr += p->nData;\n  *pHash->pnByte += nIncr;\n  return SQLITE_OK;\n}\n\n\n/*\n** Arguments pLeft and pRight point to linked-lists of hash-entry objects,\n** each sorted in key order. This function merges the two lists into a\n** single list and returns a pointer to its first element.\n*/\nstatic Fts5HashEntry *fts5HashEntryMerge(\n  Fts5HashEntry *pLeft,\n  Fts5HashEntry *pRight\n){\n  Fts5HashEntry *p1 = pLeft;\n  Fts5HashEntry *p2 = pRight;\n  Fts5HashEntry *pRet = 0;\n  Fts5HashEntry **ppOut = &pRet;\n\n  while( p1 || p2 ){\n    if( p1==0 ){\n      *ppOut = p2;\n      p2 = 0;\n    }else if( p2==0 ){\n      *ppOut = p1;\n      p1 = 0;\n    }else{\n      int i = 0;\n      char *zKey1 = fts5EntryKey(p1);\n      char *zKey2 = fts5EntryKey(p2);\n      while( zKey1[i]==zKey2[i] ) i++;\n\n      if( ((u8)zKey1[i])>((u8)zKey2[i]) ){\n        /* p2 is smaller */\n        *ppOut = p2;\n        ppOut = &p2->pScanNext;\n        p2 = p2->pScanNext;\n      }else{\n        /* p1 is smaller */\n        *ppOut = p1;\n        ppOut = &p1->pScanNext;\n        p1 = p1->pScanNext;\n      }\n      *ppOut = 0;\n    }\n  }\n\n  return pRet;\n}\n\n/*\n** Extract all tokens from hash table iHash and link them into a list\n** in sorted order. The hash table is cleared before returning. It is\n** the responsibility of the caller to free the elements of the returned\n** list.\n*/\nstatic int fts5HashEntrySort(\n  Fts5Hash *pHash, \n  const char *pTerm, int nTerm,   /* Query prefix, if any */\n  Fts5HashEntry **ppSorted\n){\n  const int nMergeSlot = 32;\n  Fts5HashEntry **ap;\n  Fts5HashEntry *pList;\n  int iSlot;\n  int i;\n\n  *ppSorted = 0;\n  ap = sqlite3_malloc64(sizeof(Fts5HashEntry*) * nMergeSlot);\n  if( !ap ) return SQLITE_NOMEM;\n  memset(ap, 0, sizeof(Fts5HashEntry*) * nMergeSlot);\n\n  for(iSlot=0; iSlot<pHash->nSlot; iSlot++){\n    Fts5HashEntry *pIter;\n    for(pIter=pHash->aSlot[iSlot]; pIter; pIter=pIter->pHashNext){\n      if( pTerm==0 || 0==memcmp(fts5EntryKey(pIter), pTerm, nTerm) ){\n        Fts5HashEntry *pEntry = pIter;\n        pEntry->pScanNext = 0;\n        for(i=0; ap[i]; i++){\n          pEntry = fts5HashEntryMerge(pEntry, ap[i]);\n          ap[i] = 0;\n        }\n        ap[i] = pEntry;\n      }\n    }\n  }\n\n  pList = 0;\n  for(i=0; i<nMergeSlot; i++){\n    pList = fts5HashEntryMerge(pList, ap[i]);\n  }\n\n  pHash->nEntry = 0;\n  sqlite3_free(ap);\n  *ppSorted = pList;\n  return SQLITE_OK;\n}\n\n/*\n** Query the hash table for a doclist associated with term pTerm/nTerm.\n*/\nstatic int sqlite3Fts5HashQuery(\n  Fts5Hash *pHash,                /* Hash table to query */\n  const char *pTerm, int nTerm,   /* Query term */\n  const u8 **ppDoclist,           /* OUT: Pointer to doclist for pTerm */\n  int *pnDoclist                  /* OUT: Size of doclist in bytes */\n){\n  unsigned int iHash = fts5HashKey(pHash->nSlot, (const u8*)pTerm, nTerm);\n  char *zKey = 0;\n  Fts5HashEntry *p;\n\n  for(p=pHash->aSlot[iHash]; p; p=p->pHashNext){\n    zKey = fts5EntryKey(p);\n    assert( p->nKey+1==(int)strlen(zKey) );\n    if( nTerm==p->nKey+1 && memcmp(zKey, pTerm, nTerm)==0 ) break;\n  }\n\n  if( p ){\n    fts5HashAddPoslistSize(pHash, p);\n    *ppDoclist = (const u8*)&zKey[nTerm+1];\n    *pnDoclist = p->nData - (sizeof(Fts5HashEntry) + nTerm + 1);\n  }else{\n    *ppDoclist = 0;\n    *pnDoclist = 0;\n  }\n\n  return SQLITE_OK;\n}\n\nstatic int sqlite3Fts5HashScanInit(\n  Fts5Hash *p,                    /* Hash table to query */\n  const char *pTerm, int nTerm    /* Query prefix */\n){\n  return fts5HashEntrySort(p, pTerm, nTerm, &p->pScan);\n}\n\nstatic void sqlite3Fts5HashScanNext(Fts5Hash *p){\n  assert( !sqlite3Fts5HashScanEof(p) );\n  p->pScan = p->pScan->pScanNext;\n}\n\nstatic int sqlite3Fts5HashScanEof(Fts5Hash *p){\n  return (p->pScan==0);\n}\n\nstatic void sqlite3Fts5HashScanEntry(\n  Fts5Hash *pHash,\n  const char **pzTerm,            /* OUT: term (nul-terminated) */\n  const u8 **ppDoclist,           /* OUT: pointer to doclist */\n  int *pnDoclist                  /* OUT: size of doclist in bytes */\n){\n  Fts5HashEntry *p;\n  if( (p = pHash->pScan) ){\n    char *zKey = fts5EntryKey(p);\n    int nTerm = (int)strlen(zKey);\n    fts5HashAddPoslistSize(pHash, p);\n    *pzTerm = zKey;\n    *ppDoclist = (const u8*)&zKey[nTerm+1];\n    *pnDoclist = p->nData - (sizeof(Fts5HashEntry) + nTerm + 1);\n  }else{\n    *pzTerm = 0;\n    *ppDoclist = 0;\n    *pnDoclist = 0;\n  }\n}\n\n/*\n** 2014 May 31\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n******************************************************************************\n**\n** Low level access to the FTS index stored in the database file. The \n** routines in this file file implement all read and write access to the\n** %_data table. Other parts of the system access this functionality via\n** the interface defined in fts5Int.h.\n*/\n\n\n/* #include \"fts5Int.h\" */\n\n/*\n** Overview:\n**\n** The %_data table contains all the FTS indexes for an FTS5 virtual table.\n** As well as the main term index, there may be up to 31 prefix indexes.\n** The format is similar to FTS3/4, except that:\n**\n**   * all segment b-tree leaf data is stored in fixed size page records \n**     (e.g. 1000 bytes). A single doclist may span multiple pages. Care is \n**     taken to ensure it is possible to iterate in either direction through \n**     the entries in a doclist, or to seek to a specific entry within a \n**     doclist, without loading it into memory.\n**\n**   * large doclists that span many pages have associated \"doclist index\"\n**     records that contain a copy of the first rowid on each page spanned by\n**     the doclist. This is used to speed up seek operations, and merges of\n**     large doclists with very small doclists.\n**\n**   * extra fields in the \"structure record\" record the state of ongoing\n**     incremental merge operations.\n**\n*/\n\n\n#define FTS5_OPT_WORK_UNIT  1000  /* Number of leaf pages per optimize step */\n#define FTS5_WORK_UNIT      64    /* Number of leaf pages in unit of work */\n\n#define FTS5_MIN_DLIDX_SIZE 4     /* Add dlidx if this many empty pages */\n\n#define FTS5_MAIN_PREFIX '0'\n\n#if FTS5_MAX_PREFIX_INDEXES > 31\n# error \"FTS5_MAX_PREFIX_INDEXES is too large\"\n#endif\n\n/*\n** Details:\n**\n** The %_data table managed by this module,\n**\n**     CREATE TABLE %_data(id INTEGER PRIMARY KEY, block BLOB);\n**\n** , contains the following 5 types of records. See the comments surrounding\n** the FTS5_*_ROWID macros below for a description of how %_data rowids are \n** assigned to each fo them.\n**\n** 1. Structure Records:\n**\n**   The set of segments that make up an index - the index structure - are\n**   recorded in a single record within the %_data table. The record consists\n**   of a single 32-bit configuration cookie value followed by a list of \n**   SQLite varints. If the FTS table features more than one index (because\n**   there are one or more prefix indexes), it is guaranteed that all share\n**   the same cookie value.\n**\n**   Immediately following the configuration cookie, the record begins with\n**   three varints:\n**\n**     + number of levels,\n**     + total number of segments on all levels,\n**     + value of write counter.\n**\n**   Then, for each level from 0 to nMax:\n**\n**     + number of input segments in ongoing merge.\n**     + total number of segments in level.\n**     + for each segment from oldest to newest:\n**         + segment id (always > 0)\n**         + first leaf page number (often 1, always greater than 0)\n**         + final leaf page number\n**\n** 2. The Averages Record:\n**\n**   A single record within the %_data table. The data is a list of varints.\n**   The first value is the number of rows in the index. Then, for each column\n**   from left to right, the total number of tokens in the column for all\n**   rows of the table.\n**\n** 3. Segment leaves:\n**\n**   TERM/DOCLIST FORMAT:\n**\n**     Most of each segment leaf is taken up by term/doclist data. The \n**     general format of term/doclist, starting with the first term\n**     on the leaf page, is:\n**\n**         varint : size of first term\n**         blob:    first term data\n**         doclist: first doclist\n**         zero-or-more {\n**           varint:  number of bytes in common with previous term\n**           varint:  number of bytes of new term data (nNew)\n**           blob:    nNew bytes of new term data\n**           doclist: next doclist\n**         }\n**\n**     doclist format:\n**\n**         varint:  first rowid\n**         poslist: first poslist\n**         zero-or-more {\n**           varint:  rowid delta (always > 0)\n**           poslist: next poslist\n**         }\n**\n**     poslist format:\n**\n**         varint: size of poslist in bytes multiplied by 2, not including\n**                 this field. Plus 1 if this entry carries the \"delete\" flag.\n**         collist: collist for column 0\n**         zero-or-more {\n**           0x01 byte\n**           varint: column number (I)\n**           collist: collist for column I\n**         }\n**\n**     collist format:\n**\n**         varint: first offset + 2\n**         zero-or-more {\n**           varint: offset delta + 2\n**         }\n**\n**   PAGE FORMAT\n**\n**     Each leaf page begins with a 4-byte header containing 2 16-bit \n**     unsigned integer fields in big-endian format. They are:\n**\n**       * The byte offset of the first rowid on the page, if it exists\n**         and occurs before the first term (otherwise 0).\n**\n**       * The byte offset of the start of the page footer. If the page\n**         footer is 0 bytes in size, then this field is the same as the\n**         size of the leaf page in bytes.\n**\n**     The page footer consists of a single varint for each term located\n**     on the page. Each varint is the byte offset of the current term\n**     within the page, delta-compressed against the previous value. In\n**     other words, the first varint in the footer is the byte offset of\n**     the first term, the second is the byte offset of the second less that\n**     of the first, and so on.\n**\n**     The term/doclist format described above is accurate if the entire\n**     term/doclist data fits on a single leaf page. If this is not the case,\n**     the format is changed in two ways:\n**\n**       + if the first rowid on a page occurs before the first term, it\n**         is stored as a literal value:\n**\n**             varint:  first rowid\n**\n**       + the first term on each page is stored in the same way as the\n**         very first term of the segment:\n**\n**             varint : size of first term\n**             blob:    first term data\n**\n** 5. Segment doclist indexes:\n**\n**   Doclist indexes are themselves b-trees, however they usually consist of\n**   a single leaf record only. The format of each doclist index leaf page \n**   is:\n**\n**     * Flags byte. Bits are:\n**         0x01: Clear if leaf is also the root page, otherwise set.\n**\n**     * Page number of fts index leaf page. As a varint.\n**\n**     * First rowid on page indicated by previous field. As a varint.\n**\n**     * A list of varints, one for each subsequent termless page. A \n**       positive delta if the termless page contains at least one rowid, \n**       or an 0x00 byte otherwise.\n**\n**   Internal doclist index nodes are:\n**\n**     * Flags byte. Bits are:\n**         0x01: Clear for root page, otherwise set.\n**\n**     * Page number of first child page. As a varint.\n**\n**     * Copy of first rowid on page indicated by previous field. As a varint.\n**\n**     * A list of delta-encoded varints - the first rowid on each subsequent\n**       child page. \n**\n*/\n\n/*\n** Rowids for the averages and structure records in the %_data table.\n*/\n#define FTS5_AVERAGES_ROWID     1    /* Rowid used for the averages record */\n#define FTS5_STRUCTURE_ROWID   10    /* The structure record */\n\n/*\n** Macros determining the rowids used by segment leaves and dlidx leaves\n** and nodes. All nodes and leaves are stored in the %_data table with large\n** positive rowids.\n**\n** Each segment has a unique non-zero 16-bit id.\n**\n** The rowid for each segment leaf is found by passing the segment id and \n** the leaf page number to the FTS5_SEGMENT_ROWID macro. Leaves are numbered\n** sequentially starting from 1.\n*/\n#define FTS5_DATA_ID_B     16     /* Max seg id number 65535 */\n#define FTS5_DATA_DLI_B     1     /* Doclist-index flag (1 bit) */\n#define FTS5_DATA_HEIGHT_B  5     /* Max dlidx tree height of 32 */\n#define FTS5_DATA_PAGE_B   31     /* Max page number of 2147483648 */\n\n#define fts5_dri(segid, dlidx, height, pgno) (                                 \\\n ((i64)(segid)  << (FTS5_DATA_PAGE_B+FTS5_DATA_HEIGHT_B+FTS5_DATA_DLI_B)) +    \\\n ((i64)(dlidx)  << (FTS5_DATA_PAGE_B + FTS5_DATA_HEIGHT_B)) +                  \\\n ((i64)(height) << (FTS5_DATA_PAGE_B)) +                                       \\\n ((i64)(pgno))                                                                 \\\n)\n\n#define FTS5_SEGMENT_ROWID(segid, pgno)       fts5_dri(segid, 0, 0, pgno)\n#define FTS5_DLIDX_ROWID(segid, height, pgno) fts5_dri(segid, 1, height, pgno)\n\n/*\n** Maximum segments permitted in a single index \n*/\n#define FTS5_MAX_SEGMENT 2000\n\n#ifdef SQLITE_DEBUG\nstatic int sqlite3Fts5Corrupt() { return SQLITE_CORRUPT_VTAB; }\n#endif\n\n\n/*\n** Each time a blob is read from the %_data table, it is padded with this\n** many zero bytes. This makes it easier to decode the various record formats\n** without overreading if the records are corrupt.\n*/\n#define FTS5_DATA_ZERO_PADDING 8\n#define FTS5_DATA_PADDING 20\n\ntypedef struct Fts5Data Fts5Data;\ntypedef struct Fts5DlidxIter Fts5DlidxIter;\ntypedef struct Fts5DlidxLvl Fts5DlidxLvl;\ntypedef struct Fts5DlidxWriter Fts5DlidxWriter;\ntypedef struct Fts5Iter Fts5Iter;\ntypedef struct Fts5PageWriter Fts5PageWriter;\ntypedef struct Fts5SegIter Fts5SegIter;\ntypedef struct Fts5DoclistIter Fts5DoclistIter;\ntypedef struct Fts5SegWriter Fts5SegWriter;\ntypedef struct Fts5Structure Fts5Structure;\ntypedef struct Fts5StructureLevel Fts5StructureLevel;\ntypedef struct Fts5StructureSegment Fts5StructureSegment;\n\nstruct Fts5Data {\n  u8 *p;                          /* Pointer to buffer containing record */\n  int nn;                         /* Size of record in bytes */\n  int szLeaf;                     /* Size of leaf without page-index */\n};\n\n/*\n** One object per %_data table.\n*/\nstruct Fts5Index {\n  Fts5Config *pConfig;            /* Virtual table configuration */\n  char *zDataTbl;                 /* Name of %_data table */\n  int nWorkUnit;                  /* Leaf pages in a \"unit\" of work */\n\n  /*\n  ** Variables related to the accumulation of tokens and doclists within the\n  ** in-memory hash tables before they are flushed to disk.\n  */\n  Fts5Hash *pHash;                /* Hash table for in-memory data */\n  int nPendingData;               /* Current bytes of pending data */\n  i64 iWriteRowid;                /* Rowid for current doc being written */\n  int bDelete;                    /* Current write is a delete */\n\n  /* Error state. */\n  int rc;                         /* Current error code */\n\n  /* State used by the fts5DataXXX() functions. */\n  sqlite3_blob *pReader;          /* RO incr-blob open on %_data table */\n  sqlite3_stmt *pWriter;          /* \"INSERT ... %_data VALUES(?,?)\" */\n  sqlite3_stmt *pDeleter;         /* \"DELETE FROM %_data ... id>=? AND id<=?\" */\n  sqlite3_stmt *pIdxWriter;       /* \"INSERT ... %_idx VALUES(?,?,?,?)\" */\n  sqlite3_stmt *pIdxDeleter;      /* \"DELETE FROM %_idx WHERE segid=? */\n  sqlite3_stmt *pIdxSelect;\n  int nRead;                      /* Total number of blocks read */\n\n  sqlite3_stmt *pDataVersion;\n  i64 iStructVersion;             /* data_version when pStruct read */\n  Fts5Structure *pStruct;         /* Current db structure (or NULL) */\n};\n\nstruct Fts5DoclistIter {\n  u8 *aEof;                       /* Pointer to 1 byte past end of doclist */\n\n  /* Output variables. aPoslist==0 at EOF */\n  i64 iRowid;\n  u8 *aPoslist;\n  int nPoslist;\n  int nSize;\n};\n\n/*\n** The contents of the \"structure\" record for each index are represented\n** using an Fts5Structure record in memory. Which uses instances of the \n** other Fts5StructureXXX types as components.\n*/\nstruct Fts5StructureSegment {\n  int iSegid;                     /* Segment id */\n  int pgnoFirst;                  /* First leaf page number in segment */\n  int pgnoLast;                   /* Last leaf page number in segment */\n};\nstruct Fts5StructureLevel {\n  int nMerge;                     /* Number of segments in incr-merge */\n  int nSeg;                       /* Total number of segments on level */\n  Fts5StructureSegment *aSeg;     /* Array of segments. aSeg[0] is oldest. */\n};\nstruct Fts5Structure {\n  int nRef;                       /* Object reference count */\n  u64 nWriteCounter;              /* Total leaves written to level 0 */\n  int nSegment;                   /* Total segments in this structure */\n  int nLevel;                     /* Number of levels in this index */\n  Fts5StructureLevel aLevel[1];   /* Array of nLevel level objects */\n};\n\n/*\n** An object of type Fts5SegWriter is used to write to segments.\n*/\nstruct Fts5PageWriter {\n  int pgno;                       /* Page number for this page */\n  int iPrevPgidx;                 /* Previous value written into pgidx */\n  Fts5Buffer buf;                 /* Buffer containing leaf data */\n  Fts5Buffer pgidx;               /* Buffer containing page-index */\n  Fts5Buffer term;                /* Buffer containing previous term on page */\n};\nstruct Fts5DlidxWriter {\n  int pgno;                       /* Page number for this page */\n  int bPrevValid;                 /* True if iPrev is valid */\n  i64 iPrev;                      /* Previous rowid value written to page */\n  Fts5Buffer buf;                 /* Buffer containing page data */\n};\nstruct Fts5SegWriter {\n  int iSegid;                     /* Segid to write to */\n  Fts5PageWriter writer;          /* PageWriter object */\n  i64 iPrevRowid;                 /* Previous rowid written to current leaf */\n  u8 bFirstRowidInDoclist;        /* True if next rowid is first in doclist */\n  u8 bFirstRowidInPage;           /* True if next rowid is first in page */\n  /* TODO1: Can use (writer.pgidx.n==0) instead of bFirstTermInPage */\n  u8 bFirstTermInPage;            /* True if next term will be first in leaf */\n  int nLeafWritten;               /* Number of leaf pages written */\n  int nEmpty;                     /* Number of contiguous term-less nodes */\n\n  int nDlidx;                     /* Allocated size of aDlidx[] array */\n  Fts5DlidxWriter *aDlidx;        /* Array of Fts5DlidxWriter objects */\n\n  /* Values to insert into the %_idx table */\n  Fts5Buffer btterm;              /* Next term to insert into %_idx table */\n  int iBtPage;                    /* Page number corresponding to btterm */\n};\n\ntypedef struct Fts5CResult Fts5CResult;\nstruct Fts5CResult {\n  u16 iFirst;                     /* aSeg[] index of firstest iterator */\n  u8 bTermEq;                     /* True if the terms are equal */\n};\n\n/*\n** Object for iterating through a single segment, visiting each term/rowid\n** pair in the segment.\n**\n** pSeg:\n**   The segment to iterate through.\n**\n** iLeafPgno:\n**   Current leaf page number within segment.\n**\n** iLeafOffset:\n**   Byte offset within the current leaf that is the first byte of the \n**   position list data (one byte passed the position-list size field).\n**   rowid field of the current entry. Usually this is the size field of the\n**   position list data. The exception is if the rowid for the current entry \n**   is the last thing on the leaf page.\n**\n** pLeaf:\n**   Buffer containing current leaf page data. Set to NULL at EOF.\n**\n** iTermLeafPgno, iTermLeafOffset:\n**   Leaf page number containing the last term read from the segment. And\n**   the offset immediately following the term data.\n**\n** flags:\n**   Mask of FTS5_SEGITER_XXX values. Interpreted as follows:\n**\n**   FTS5_SEGITER_ONETERM:\n**     If set, set the iterator to point to EOF after the current doclist \n**     has been exhausted. Do not proceed to the next term in the segment.\n**\n**   FTS5_SEGITER_REVERSE:\n**     This flag is only ever set if FTS5_SEGITER_ONETERM is also set. If\n**     it is set, iterate through rowid in descending order instead of the\n**     default ascending order.\n**\n** iRowidOffset/nRowidOffset/aRowidOffset:\n**     These are used if the FTS5_SEGITER_REVERSE flag is set.\n**\n**     For each rowid on the page corresponding to the current term, the\n**     corresponding aRowidOffset[] entry is set to the byte offset of the\n**     start of the \"position-list-size\" field within the page.\n**\n** iTermIdx:\n**     Index of current term on iTermLeafPgno.\n*/\nstruct Fts5SegIter {\n  Fts5StructureSegment *pSeg;     /* Segment to iterate through */\n  int flags;                      /* Mask of configuration flags */\n  int iLeafPgno;                  /* Current leaf page number */\n  Fts5Data *pLeaf;                /* Current leaf data */\n  Fts5Data *pNextLeaf;            /* Leaf page (iLeafPgno+1) */\n  int iLeafOffset;                /* Byte offset within current leaf */\n\n  /* Next method */\n  void (*xNext)(Fts5Index*, Fts5SegIter*, int*);\n\n  /* The page and offset from which the current term was read. The offset \n  ** is the offset of the first rowid in the current doclist.  */\n  int iTermLeafPgno;\n  int iTermLeafOffset;\n\n  int iPgidxOff;                  /* Next offset in pgidx */\n  int iEndofDoclist;\n\n  /* The following are only used if the FTS5_SEGITER_REVERSE flag is set. */\n  int iRowidOffset;               /* Current entry in aRowidOffset[] */\n  int nRowidOffset;               /* Allocated size of aRowidOffset[] array */\n  int *aRowidOffset;              /* Array of offset to rowid fields */\n\n  Fts5DlidxIter *pDlidx;          /* If there is a doclist-index */\n\n  /* Variables populated based on current entry. */\n  Fts5Buffer term;                /* Current term */\n  i64 iRowid;                     /* Current rowid */\n  int nPos;                       /* Number of bytes in current position list */\n  u8 bDel;                        /* True if the delete flag is set */\n};\n\n/*\n** Argument is a pointer to an Fts5Data structure that contains a \n** leaf page.\n*/\n#define ASSERT_SZLEAF_OK(x) assert( \\\n    (x)->szLeaf==(x)->nn || (x)->szLeaf==fts5GetU16(&(x)->p[2]) \\\n)\n\n#define FTS5_SEGITER_ONETERM 0x01\n#define FTS5_SEGITER_REVERSE 0x02\n\n/* \n** Argument is a pointer to an Fts5Data structure that contains a leaf\n** page. This macro evaluates to true if the leaf contains no terms, or\n** false if it contains at least one term.\n*/\n#define fts5LeafIsTermless(x) ((x)->szLeaf >= (x)->nn)\n\n#define fts5LeafTermOff(x, i) (fts5GetU16(&(x)->p[(x)->szLeaf + (i)*2]))\n\n#define fts5LeafFirstRowidOff(x) (fts5GetU16((x)->p))\n\n/*\n** Object for iterating through the merged results of one or more segments,\n** visiting each term/rowid pair in the merged data.\n**\n** nSeg is always a power of two greater than or equal to the number of\n** segments that this object is merging data from. Both the aSeg[] and\n** aFirst[] arrays are sized at nSeg entries. The aSeg[] array is padded\n** with zeroed objects - these are handled as if they were iterators opened\n** on empty segments.\n**\n** The results of comparing segments aSeg[N] and aSeg[N+1], where N is an\n** even number, is stored in aFirst[(nSeg+N)/2]. The \"result\" of the \n** comparison in this context is the index of the iterator that currently\n** points to the smaller term/rowid combination. Iterators at EOF are\n** considered to be greater than all other iterators.\n**\n** aFirst[1] contains the index in aSeg[] of the iterator that points to\n** the smallest key overall. aFirst[0] is unused. \n**\n** poslist:\n**   Used by sqlite3Fts5IterPoslist() when the poslist needs to be buffered.\n**   There is no way to tell if this is populated or not.\n*/\nstruct Fts5Iter {\n  Fts5IndexIter base;             /* Base class containing output vars */\n\n  Fts5Index *pIndex;              /* Index that owns this iterator */\n  Fts5Buffer poslist;             /* Buffer containing current poslist */\n  Fts5Colset *pColset;            /* Restrict matches to these columns */\n\n  /* Invoked to set output variables. */\n  void (*xSetOutputs)(Fts5Iter*, Fts5SegIter*);\n\n  int nSeg;                       /* Size of aSeg[] array */\n  int bRev;                       /* True to iterate in reverse order */\n  u8 bSkipEmpty;                  /* True to skip deleted entries */\n\n  i64 iSwitchRowid;               /* Firstest rowid of other than aFirst[1] */\n  Fts5CResult *aFirst;            /* Current merge state (see above) */\n  Fts5SegIter aSeg[1];            /* Array of segment iterators */\n};\n\n\n/*\n** An instance of the following type is used to iterate through the contents\n** of a doclist-index record.\n**\n** pData:\n**   Record containing the doclist-index data.\n**\n** bEof:\n**   Set to true once iterator has reached EOF.\n**\n** iOff:\n**   Set to the current offset within record pData.\n*/\nstruct Fts5DlidxLvl {\n  Fts5Data *pData;              /* Data for current page of this level */\n  int iOff;                     /* Current offset into pData */\n  int bEof;                     /* At EOF already */\n  int iFirstOff;                /* Used by reverse iterators */\n\n  /* Output variables */\n  int iLeafPgno;                /* Page number of current leaf page */\n  i64 iRowid;                   /* First rowid on leaf iLeafPgno */\n};\nstruct Fts5DlidxIter {\n  int nLvl;\n  int iSegid;\n  Fts5DlidxLvl aLvl[1];\n};\n\nstatic void fts5PutU16(u8 *aOut, u16 iVal){\n  aOut[0] = (iVal>>8);\n  aOut[1] = (iVal&0xFF);\n}\n\nstatic u16 fts5GetU16(const u8 *aIn){\n  return ((u16)aIn[0] << 8) + aIn[1];\n} \n\n/*\n** Allocate and return a buffer at least nByte bytes in size.\n**\n** If an OOM error is encountered, return NULL and set the error code in\n** the Fts5Index handle passed as the first argument.\n*/\nstatic void *fts5IdxMalloc(Fts5Index *p, sqlite3_int64 nByte){\n  return sqlite3Fts5MallocZero(&p->rc, nByte);\n}\n\n/*\n** Compare the contents of the pLeft buffer with the pRight/nRight blob.\n**\n** Return -ve if pLeft is smaller than pRight, 0 if they are equal or\n** +ve if pRight is smaller than pLeft. In other words:\n**\n**     res = *pLeft - *pRight\n*/\n#ifdef SQLITE_DEBUG\nstatic int fts5BufferCompareBlob(\n  Fts5Buffer *pLeft,              /* Left hand side of comparison */\n  const u8 *pRight, int nRight    /* Right hand side of comparison */\n){\n  int nCmp = MIN(pLeft->n, nRight);\n  int res = memcmp(pLeft->p, pRight, nCmp);\n  return (res==0 ? (pLeft->n - nRight) : res);\n}\n#endif\n\n/*\n** Compare the contents of the two buffers using memcmp(). If one buffer\n** is a prefix of the other, it is considered the lesser.\n**\n** Return -ve if pLeft is smaller than pRight, 0 if they are equal or\n** +ve if pRight is smaller than pLeft. In other words:\n**\n**     res = *pLeft - *pRight\n*/\nstatic int fts5BufferCompare(Fts5Buffer *pLeft, Fts5Buffer *pRight){\n  int nCmp = MIN(pLeft->n, pRight->n);\n  int res = fts5Memcmp(pLeft->p, pRight->p, nCmp);\n  return (res==0 ? (pLeft->n - pRight->n) : res);\n}\n\nstatic int fts5LeafFirstTermOff(Fts5Data *pLeaf){\n  int ret;\n  fts5GetVarint32(&pLeaf->p[pLeaf->szLeaf], ret);\n  return ret;\n}\n\n/*\n** Close the read-only blob handle, if it is open.\n*/\nstatic void fts5CloseReader(Fts5Index *p){\n  if( p->pReader ){\n    sqlite3_blob *pReader = p->pReader;\n    p->pReader = 0;\n    sqlite3_blob_close(pReader);\n  }\n}\n\n/*\n** Retrieve a record from the %_data table.\n**\n** If an error occurs, NULL is returned and an error left in the \n** Fts5Index object.\n*/\nstatic Fts5Data *fts5DataRead(Fts5Index *p, i64 iRowid){\n  Fts5Data *pRet = 0;\n  if( p->rc==SQLITE_OK ){\n    int rc = SQLITE_OK;\n\n    if( p->pReader ){\n      /* This call may return SQLITE_ABORT if there has been a savepoint\n      ** rollback since it was last used. In this case a new blob handle\n      ** is required.  */\n      sqlite3_blob *pBlob = p->pReader;\n      p->pReader = 0;\n      rc = sqlite3_blob_reopen(pBlob, iRowid);\n      assert( p->pReader==0 );\n      p->pReader = pBlob;\n      if( rc!=SQLITE_OK ){\n        fts5CloseReader(p);\n      }\n      if( rc==SQLITE_ABORT ) rc = SQLITE_OK;\n    }\n\n    /* If the blob handle is not open at this point, open it and seek \n    ** to the requested entry.  */\n    if( p->pReader==0 && rc==SQLITE_OK ){\n      Fts5Config *pConfig = p->pConfig;\n      rc = sqlite3_blob_open(pConfig->db, \n          pConfig->zDb, p->zDataTbl, \"block\", iRowid, 0, &p->pReader\n      );\n    }\n\n    /* If either of the sqlite3_blob_open() or sqlite3_blob_reopen() calls\n    ** above returned SQLITE_ERROR, return SQLITE_CORRUPT_VTAB instead.\n    ** All the reasons those functions might return SQLITE_ERROR - missing\n    ** table, missing row, non-blob/text in block column - indicate \n    ** backing store corruption.  */\n    if( rc==SQLITE_ERROR ) rc = FTS5_CORRUPT;\n\n    if( rc==SQLITE_OK ){\n      u8 *aOut = 0;               /* Read blob data into this buffer */\n      int nByte = sqlite3_blob_bytes(p->pReader);\n      sqlite3_int64 nAlloc = sizeof(Fts5Data) + nByte + FTS5_DATA_PADDING;\n      pRet = (Fts5Data*)sqlite3_malloc64(nAlloc);\n      if( pRet ){\n        pRet->nn = nByte;\n        aOut = pRet->p = (u8*)&pRet[1];\n      }else{\n        rc = SQLITE_NOMEM;\n      }\n\n      if( rc==SQLITE_OK ){\n        rc = sqlite3_blob_read(p->pReader, aOut, nByte, 0);\n      }\n      if( rc!=SQLITE_OK ){\n        sqlite3_free(pRet);\n        pRet = 0;\n      }else{\n        /* TODO1: Fix this */\n        pRet->p[nByte] = 0x00;\n        pRet->szLeaf = fts5GetU16(&pRet->p[2]);\n      }\n    }\n    p->rc = rc;\n    p->nRead++;\n  }\n\n  assert( (pRet==0)==(p->rc!=SQLITE_OK) );\n  return pRet;\n}\n\n/*\n** Release a reference to data record returned by an earlier call to\n** fts5DataRead().\n*/\nstatic void fts5DataRelease(Fts5Data *pData){\n  sqlite3_free(pData);\n}\n\nstatic Fts5Data *fts5LeafRead(Fts5Index *p, i64 iRowid){\n  Fts5Data *pRet = fts5DataRead(p, iRowid);\n  if( pRet ){\n    if( pRet->szLeaf>pRet->nn ){\n      p->rc = FTS5_CORRUPT;\n      fts5DataRelease(pRet);\n      pRet = 0;\n    }\n  }\n  return pRet;\n}\n\nstatic int fts5IndexPrepareStmt(\n  Fts5Index *p,\n  sqlite3_stmt **ppStmt,\n  char *zSql\n){\n  if( p->rc==SQLITE_OK ){\n    if( zSql ){\n      p->rc = sqlite3_prepare_v3(p->pConfig->db, zSql, -1,\n          SQLITE_PREPARE_PERSISTENT|SQLITE_PREPARE_NO_VTAB,\n          ppStmt, 0);\n    }else{\n      p->rc = SQLITE_NOMEM;\n    }\n  }\n  sqlite3_free(zSql);\n  return p->rc;\n}\n\n\n/*\n** INSERT OR REPLACE a record into the %_data table.\n*/\nstatic void fts5DataWrite(Fts5Index *p, i64 iRowid, const u8 *pData, int nData){\n  if( p->rc!=SQLITE_OK ) return;\n\n  if( p->pWriter==0 ){\n    Fts5Config *pConfig = p->pConfig;\n    fts5IndexPrepareStmt(p, &p->pWriter, sqlite3_mprintf(\n          \"REPLACE INTO '%q'.'%q_data'(id, block) VALUES(?,?)\", \n          pConfig->zDb, pConfig->zName\n    ));\n    if( p->rc ) return;\n  }\n\n  sqlite3_bind_int64(p->pWriter, 1, iRowid);\n  sqlite3_bind_blob(p->pWriter, 2, pData, nData, SQLITE_STATIC);\n  sqlite3_step(p->pWriter);\n  p->rc = sqlite3_reset(p->pWriter);\n  sqlite3_bind_null(p->pWriter, 2);\n}\n\n/*\n** Execute the following SQL:\n**\n**     DELETE FROM %_data WHERE id BETWEEN $iFirst AND $iLast\n*/\nstatic void fts5DataDelete(Fts5Index *p, i64 iFirst, i64 iLast){\n  if( p->rc!=SQLITE_OK ) return;\n\n  if( p->pDeleter==0 ){\n    Fts5Config *pConfig = p->pConfig;\n    char *zSql = sqlite3_mprintf(\n        \"DELETE FROM '%q'.'%q_data' WHERE id>=? AND id<=?\", \n          pConfig->zDb, pConfig->zName\n    );\n    if( fts5IndexPrepareStmt(p, &p->pDeleter, zSql) ) return;\n  }\n\n  sqlite3_bind_int64(p->pDeleter, 1, iFirst);\n  sqlite3_bind_int64(p->pDeleter, 2, iLast);\n  sqlite3_step(p->pDeleter);\n  p->rc = sqlite3_reset(p->pDeleter);\n}\n\n/*\n** Remove all records associated with segment iSegid.\n*/\nstatic void fts5DataRemoveSegment(Fts5Index *p, int iSegid){\n  i64 iFirst = FTS5_SEGMENT_ROWID(iSegid, 0);\n  i64 iLast = FTS5_SEGMENT_ROWID(iSegid+1, 0)-1;\n  fts5DataDelete(p, iFirst, iLast);\n  if( p->pIdxDeleter==0 ){\n    Fts5Config *pConfig = p->pConfig;\n    fts5IndexPrepareStmt(p, &p->pIdxDeleter, sqlite3_mprintf(\n          \"DELETE FROM '%q'.'%q_idx' WHERE segid=?\",\n          pConfig->zDb, pConfig->zName\n    ));\n  }\n  if( p->rc==SQLITE_OK ){\n    sqlite3_bind_int(p->pIdxDeleter, 1, iSegid);\n    sqlite3_step(p->pIdxDeleter);\n    p->rc = sqlite3_reset(p->pIdxDeleter);\n  }\n}\n\n/*\n** Release a reference to an Fts5Structure object returned by an earlier \n** call to fts5StructureRead() or fts5StructureDecode().\n*/\nstatic void fts5StructureRelease(Fts5Structure *pStruct){\n  if( pStruct && 0>=(--pStruct->nRef) ){\n    int i;\n    assert( pStruct->nRef==0 );\n    for(i=0; i<pStruct->nLevel; i++){\n      sqlite3_free(pStruct->aLevel[i].aSeg);\n    }\n    sqlite3_free(pStruct);\n  }\n}\n\nstatic void fts5StructureRef(Fts5Structure *pStruct){\n  pStruct->nRef++;\n}\n\n/*\n** Deserialize and return the structure record currently stored in serialized\n** form within buffer pData/nData.\n**\n** The Fts5Structure.aLevel[] and each Fts5StructureLevel.aSeg[] array\n** are over-allocated by one slot. This allows the structure contents\n** to be more easily edited.\n**\n** If an error occurs, *ppOut is set to NULL and an SQLite error code\n** returned. Otherwise, *ppOut is set to point to the new object and\n** SQLITE_OK returned.\n*/\nstatic int fts5StructureDecode(\n  const u8 *pData,                /* Buffer containing serialized structure */\n  int nData,                      /* Size of buffer pData in bytes */\n  int *piCookie,                  /* Configuration cookie value */\n  Fts5Structure **ppOut           /* OUT: Deserialized object */\n){\n  int rc = SQLITE_OK;\n  int i = 0;\n  int iLvl;\n  int nLevel = 0;\n  int nSegment = 0;\n  sqlite3_int64 nByte;            /* Bytes of space to allocate at pRet */\n  Fts5Structure *pRet = 0;        /* Structure object to return */\n\n  /* Grab the cookie value */\n  if( piCookie ) *piCookie = sqlite3Fts5Get32(pData);\n  i = 4;\n\n  /* Read the total number of levels and segments from the start of the\n  ** structure record.  */\n  i += fts5GetVarint32(&pData[i], nLevel);\n  i += fts5GetVarint32(&pData[i], nSegment);\n  if( nLevel>FTS5_MAX_SEGMENT   || nLevel<0\n   || nSegment>FTS5_MAX_SEGMENT || nSegment<0\n  ){\n    return FTS5_CORRUPT;\n  }\n  nByte = (\n      sizeof(Fts5Structure) +                    /* Main structure */\n      sizeof(Fts5StructureLevel) * (nLevel-1)    /* aLevel[] array */\n  );\n  pRet = (Fts5Structure*)sqlite3Fts5MallocZero(&rc, nByte);\n\n  if( pRet ){\n    pRet->nRef = 1;\n    pRet->nLevel = nLevel;\n    pRet->nSegment = nSegment;\n    i += sqlite3Fts5GetVarint(&pData[i], &pRet->nWriteCounter);\n\n    for(iLvl=0; rc==SQLITE_OK && iLvl<nLevel; iLvl++){\n      Fts5StructureLevel *pLvl = &pRet->aLevel[iLvl];\n      int nTotal = 0;\n      int iSeg;\n\n      if( i>=nData ){\n        rc = FTS5_CORRUPT;\n      }else{\n        i += fts5GetVarint32(&pData[i], pLvl->nMerge);\n        i += fts5GetVarint32(&pData[i], nTotal);\n        if( nTotal<pLvl->nMerge ) rc = FTS5_CORRUPT;\n        pLvl->aSeg = (Fts5StructureSegment*)sqlite3Fts5MallocZero(&rc, \n            nTotal * sizeof(Fts5StructureSegment)\n        );\n        nSegment -= nTotal;\n      }\n\n      if( rc==SQLITE_OK ){\n        pLvl->nSeg = nTotal;\n        for(iSeg=0; iSeg<nTotal; iSeg++){\n          Fts5StructureSegment *pSeg = &pLvl->aSeg[iSeg];\n          if( i>=nData ){\n            rc = FTS5_CORRUPT;\n            break;\n          }\n          i += fts5GetVarint32(&pData[i], pSeg->iSegid);\n          i += fts5GetVarint32(&pData[i], pSeg->pgnoFirst);\n          i += fts5GetVarint32(&pData[i], pSeg->pgnoLast);\n          if( pSeg->pgnoLast<pSeg->pgnoFirst ){\n            rc = FTS5_CORRUPT;\n            break;\n          }\n        }\n        if( iLvl>0 && pLvl[-1].nMerge && nTotal==0 ) rc = FTS5_CORRUPT;\n        if( iLvl==nLevel-1 && pLvl->nMerge ) rc = FTS5_CORRUPT;\n      }\n    }\n    if( nSegment!=0 && rc==SQLITE_OK ) rc = FTS5_CORRUPT;\n\n    if( rc!=SQLITE_OK ){\n      fts5StructureRelease(pRet);\n      pRet = 0;\n    }\n  }\n\n  *ppOut = pRet;\n  return rc;\n}\n\n/*\n**\n*/\nstatic void fts5StructureAddLevel(int *pRc, Fts5Structure **ppStruct){\n  if( *pRc==SQLITE_OK ){\n    Fts5Structure *pStruct = *ppStruct;\n    int nLevel = pStruct->nLevel;\n    sqlite3_int64 nByte = (\n        sizeof(Fts5Structure) +                  /* Main structure */\n        sizeof(Fts5StructureLevel) * (nLevel+1)  /* aLevel[] array */\n    );\n\n    pStruct = sqlite3_realloc64(pStruct, nByte);\n    if( pStruct ){\n      memset(&pStruct->aLevel[nLevel], 0, sizeof(Fts5StructureLevel));\n      pStruct->nLevel++;\n      *ppStruct = pStruct;\n    }else{\n      *pRc = SQLITE_NOMEM;\n    }\n  }\n}\n\n/*\n** Extend level iLvl so that there is room for at least nExtra more\n** segments.\n*/\nstatic void fts5StructureExtendLevel(\n  int *pRc, \n  Fts5Structure *pStruct, \n  int iLvl, \n  int nExtra, \n  int bInsert\n){\n  if( *pRc==SQLITE_OK ){\n    Fts5StructureLevel *pLvl = &pStruct->aLevel[iLvl];\n    Fts5StructureSegment *aNew;\n    sqlite3_int64 nByte;\n\n    nByte = (pLvl->nSeg + nExtra) * sizeof(Fts5StructureSegment);\n    aNew = sqlite3_realloc64(pLvl->aSeg, nByte);\n    if( aNew ){\n      if( bInsert==0 ){\n        memset(&aNew[pLvl->nSeg], 0, sizeof(Fts5StructureSegment) * nExtra);\n      }else{\n        int nMove = pLvl->nSeg * sizeof(Fts5StructureSegment);\n        memmove(&aNew[nExtra], aNew, nMove);\n        memset(aNew, 0, sizeof(Fts5StructureSegment) * nExtra);\n      }\n      pLvl->aSeg = aNew;\n    }else{\n      *pRc = SQLITE_NOMEM;\n    }\n  }\n}\n\nstatic Fts5Structure *fts5StructureReadUncached(Fts5Index *p){\n  Fts5Structure *pRet = 0;\n  Fts5Config *pConfig = p->pConfig;\n  int iCookie;                    /* Configuration cookie */\n  Fts5Data *pData;\n\n  pData = fts5DataRead(p, FTS5_STRUCTURE_ROWID);\n  if( p->rc==SQLITE_OK ){\n    /* TODO: Do we need this if the leaf-index is appended? Probably... */\n    memset(&pData->p[pData->nn], 0, FTS5_DATA_PADDING);\n    p->rc = fts5StructureDecode(pData->p, pData->nn, &iCookie, &pRet);\n    if( p->rc==SQLITE_OK && pConfig->iCookie!=iCookie ){\n      p->rc = sqlite3Fts5ConfigLoad(pConfig, iCookie);\n    }\n    fts5DataRelease(pData);\n    if( p->rc!=SQLITE_OK ){\n      fts5StructureRelease(pRet);\n      pRet = 0;\n    }\n  }\n\n  return pRet;\n}\n\nstatic i64 fts5IndexDataVersion(Fts5Index *p){\n  i64 iVersion = 0;\n\n  if( p->rc==SQLITE_OK ){\n    if( p->pDataVersion==0 ){\n      p->rc = fts5IndexPrepareStmt(p, &p->pDataVersion, \n          sqlite3_mprintf(\"PRAGMA %Q.data_version\", p->pConfig->zDb)\n          );\n      if( p->rc ) return 0;\n    }\n\n    if( SQLITE_ROW==sqlite3_step(p->pDataVersion) ){\n      iVersion = sqlite3_column_int64(p->pDataVersion, 0);\n    }\n    p->rc = sqlite3_reset(p->pDataVersion);\n  }\n\n  return iVersion;\n}\n\n/*\n** Read, deserialize and return the structure record.\n**\n** The Fts5Structure.aLevel[] and each Fts5StructureLevel.aSeg[] array\n** are over-allocated as described for function fts5StructureDecode() \n** above.\n**\n** If an error occurs, NULL is returned and an error code left in the\n** Fts5Index handle. If an error has already occurred when this function\n** is called, it is a no-op.\n*/\nstatic Fts5Structure *fts5StructureRead(Fts5Index *p){\n\n  if( p->pStruct==0 ){\n    p->iStructVersion = fts5IndexDataVersion(p);\n    if( p->rc==SQLITE_OK ){\n      p->pStruct = fts5StructureReadUncached(p);\n    }\n  }\n\n#if 0\n  else{\n    Fts5Structure *pTest = fts5StructureReadUncached(p);\n    if( pTest ){\n      int i, j;\n      assert_nc( p->pStruct->nSegment==pTest->nSegment );\n      assert_nc( p->pStruct->nLevel==pTest->nLevel );\n      for(i=0; i<pTest->nLevel; i++){\n        assert_nc( p->pStruct->aLevel[i].nMerge==pTest->aLevel[i].nMerge );\n        assert_nc( p->pStruct->aLevel[i].nSeg==pTest->aLevel[i].nSeg );\n        for(j=0; j<pTest->aLevel[i].nSeg; j++){\n          Fts5StructureSegment *p1 = &pTest->aLevel[i].aSeg[j];\n          Fts5StructureSegment *p2 = &p->pStruct->aLevel[i].aSeg[j];\n          assert_nc( p1->iSegid==p2->iSegid );\n          assert_nc( p1->pgnoFirst==p2->pgnoFirst );\n          assert_nc( p1->pgnoLast==p2->pgnoLast );\n        }\n      }\n      fts5StructureRelease(pTest);\n    }\n  }\n#endif\n\n  if( p->rc!=SQLITE_OK ) return 0;\n  assert( p->iStructVersion!=0 );\n  assert( p->pStruct!=0 );\n  fts5StructureRef(p->pStruct);\n  return p->pStruct;\n}\n\nstatic void fts5StructureInvalidate(Fts5Index *p){\n  if( p->pStruct ){\n    fts5StructureRelease(p->pStruct);\n    p->pStruct = 0;\n  }\n}\n\n/*\n** Return the total number of segments in index structure pStruct. This\n** function is only ever used as part of assert() conditions.\n*/\n#ifdef SQLITE_DEBUG\nstatic int fts5StructureCountSegments(Fts5Structure *pStruct){\n  int nSegment = 0;               /* Total number of segments */\n  if( pStruct ){\n    int iLvl;                     /* Used to iterate through levels */\n    for(iLvl=0; iLvl<pStruct->nLevel; iLvl++){\n      nSegment += pStruct->aLevel[iLvl].nSeg;\n    }\n  }\n\n  return nSegment;\n}\n#endif\n\n#define fts5BufferSafeAppendBlob(pBuf, pBlob, nBlob) {     \\\n  assert( (pBuf)->nSpace>=((pBuf)->n+nBlob) );             \\\n  memcpy(&(pBuf)->p[(pBuf)->n], pBlob, nBlob);             \\\n  (pBuf)->n += nBlob;                                      \\\n}\n\n#define fts5BufferSafeAppendVarint(pBuf, iVal) {                \\\n  (pBuf)->n += sqlite3Fts5PutVarint(&(pBuf)->p[(pBuf)->n], (iVal));  \\\n  assert( (pBuf)->nSpace>=(pBuf)->n );                          \\\n}\n\n\n/*\n** Serialize and store the \"structure\" record.\n**\n** If an error occurs, leave an error code in the Fts5Index object. If an\n** error has already occurred, this function is a no-op.\n*/\nstatic void fts5StructureWrite(Fts5Index *p, Fts5Structure *pStruct){\n  if( p->rc==SQLITE_OK ){\n    Fts5Buffer buf;               /* Buffer to serialize record into */\n    int iLvl;                     /* Used to iterate through levels */\n    int iCookie;                  /* Cookie value to store */\n\n    assert( pStruct->nSegment==fts5StructureCountSegments(pStruct) );\n    memset(&buf, 0, sizeof(Fts5Buffer));\n\n    /* Append the current configuration cookie */\n    iCookie = p->pConfig->iCookie;\n    if( iCookie<0 ) iCookie = 0;\n\n    if( 0==sqlite3Fts5BufferSize(&p->rc, &buf, 4+9+9+9) ){\n      sqlite3Fts5Put32(buf.p, iCookie);\n      buf.n = 4;\n      fts5BufferSafeAppendVarint(&buf, pStruct->nLevel);\n      fts5BufferSafeAppendVarint(&buf, pStruct->nSegment);\n      fts5BufferSafeAppendVarint(&buf, (i64)pStruct->nWriteCounter);\n    }\n\n    for(iLvl=0; iLvl<pStruct->nLevel; iLvl++){\n      int iSeg;                     /* Used to iterate through segments */\n      Fts5StructureLevel *pLvl = &pStruct->aLevel[iLvl];\n      fts5BufferAppendVarint(&p->rc, &buf, pLvl->nMerge);\n      fts5BufferAppendVarint(&p->rc, &buf, pLvl->nSeg);\n      assert( pLvl->nMerge<=pLvl->nSeg );\n\n      for(iSeg=0; iSeg<pLvl->nSeg; iSeg++){\n        fts5BufferAppendVarint(&p->rc, &buf, pLvl->aSeg[iSeg].iSegid);\n        fts5BufferAppendVarint(&p->rc, &buf, pLvl->aSeg[iSeg].pgnoFirst);\n        fts5BufferAppendVarint(&p->rc, &buf, pLvl->aSeg[iSeg].pgnoLast);\n      }\n    }\n\n    fts5DataWrite(p, FTS5_STRUCTURE_ROWID, buf.p, buf.n);\n    fts5BufferFree(&buf);\n  }\n}\n\n#if 0\nstatic void fts5DebugStructure(int*,Fts5Buffer*,Fts5Structure*);\nstatic void fts5PrintStructure(const char *zCaption, Fts5Structure *pStruct){\n  int rc = SQLITE_OK;\n  Fts5Buffer buf;\n  memset(&buf, 0, sizeof(buf));\n  fts5DebugStructure(&rc, &buf, pStruct);\n  fprintf(stdout, \"%s: %s\\n\", zCaption, buf.p);\n  fflush(stdout);\n  fts5BufferFree(&buf);\n}\n#else\n# define fts5PrintStructure(x,y)\n#endif\n\nstatic int fts5SegmentSize(Fts5StructureSegment *pSeg){\n  return 1 + pSeg->pgnoLast - pSeg->pgnoFirst;\n}\n\n/*\n** Return a copy of index structure pStruct. Except, promote as many \n** segments as possible to level iPromote. If an OOM occurs, NULL is \n** returned.\n*/\nstatic void fts5StructurePromoteTo(\n  Fts5Index *p,\n  int iPromote,\n  int szPromote,\n  Fts5Structure *pStruct\n){\n  int il, is;\n  Fts5StructureLevel *pOut = &pStruct->aLevel[iPromote];\n\n  if( pOut->nMerge==0 ){\n    for(il=iPromote+1; il<pStruct->nLevel; il++){\n      Fts5StructureLevel *pLvl = &pStruct->aLevel[il];\n      if( pLvl->nMerge ) return;\n      for(is=pLvl->nSeg-1; is>=0; is--){\n        int sz = fts5SegmentSize(&pLvl->aSeg[is]);\n        if( sz>szPromote ) return;\n        fts5StructureExtendLevel(&p->rc, pStruct, iPromote, 1, 1);\n        if( p->rc ) return;\n        memcpy(pOut->aSeg, &pLvl->aSeg[is], sizeof(Fts5StructureSegment));\n        pOut->nSeg++;\n        pLvl->nSeg--;\n      }\n    }\n  }\n}\n\n/*\n** A new segment has just been written to level iLvl of index structure\n** pStruct. This function determines if any segments should be promoted\n** as a result. Segments are promoted in two scenarios:\n**\n**   a) If the segment just written is smaller than one or more segments\n**      within the previous populated level, it is promoted to the previous\n**      populated level.\n**\n**   b) If the segment just written is larger than the newest segment on\n**      the next populated level, then that segment, and any other adjacent\n**      segments that are also smaller than the one just written, are \n**      promoted. \n**\n** If one or more segments are promoted, the structure object is updated\n** to reflect this.\n*/\nstatic void fts5StructurePromote(\n  Fts5Index *p,                   /* FTS5 backend object */\n  int iLvl,                       /* Index level just updated */\n  Fts5Structure *pStruct          /* Index structure */\n){\n  if( p->rc==SQLITE_OK ){\n    int iTst;\n    int iPromote = -1;\n    int szPromote = 0;            /* Promote anything this size or smaller */\n    Fts5StructureSegment *pSeg;   /* Segment just written */\n    int szSeg;                    /* Size of segment just written */\n    int nSeg = pStruct->aLevel[iLvl].nSeg;\n\n    if( nSeg==0 ) return;\n    pSeg = &pStruct->aLevel[iLvl].aSeg[pStruct->aLevel[iLvl].nSeg-1];\n    szSeg = (1 + pSeg->pgnoLast - pSeg->pgnoFirst);\n\n    /* Check for condition (a) */\n    for(iTst=iLvl-1; iTst>=0 && pStruct->aLevel[iTst].nSeg==0; iTst--);\n    if( iTst>=0 ){\n      int i;\n      int szMax = 0;\n      Fts5StructureLevel *pTst = &pStruct->aLevel[iTst];\n      assert( pTst->nMerge==0 );\n      for(i=0; i<pTst->nSeg; i++){\n        int sz = pTst->aSeg[i].pgnoLast - pTst->aSeg[i].pgnoFirst + 1;\n        if( sz>szMax ) szMax = sz;\n      }\n      if( szMax>=szSeg ){\n        /* Condition (a) is true. Promote the newest segment on level \n        ** iLvl to level iTst.  */\n        iPromote = iTst;\n        szPromote = szMax;\n      }\n    }\n\n    /* If condition (a) is not met, assume (b) is true. StructurePromoteTo()\n    ** is a no-op if it is not.  */\n    if( iPromote<0 ){\n      iPromote = iLvl;\n      szPromote = szSeg;\n    }\n    fts5StructurePromoteTo(p, iPromote, szPromote, pStruct);\n  }\n}\n\n\n/*\n** Advance the iterator passed as the only argument. If the end of the \n** doclist-index page is reached, return non-zero.\n*/\nstatic int fts5DlidxLvlNext(Fts5DlidxLvl *pLvl){\n  Fts5Data *pData = pLvl->pData;\n\n  if( pLvl->iOff==0 ){\n    assert( pLvl->bEof==0 );\n    pLvl->iOff = 1;\n    pLvl->iOff += fts5GetVarint32(&pData->p[1], pLvl->iLeafPgno);\n    pLvl->iOff += fts5GetVarint(&pData->p[pLvl->iOff], (u64*)&pLvl->iRowid);\n    pLvl->iFirstOff = pLvl->iOff;\n  }else{\n    int iOff;\n    for(iOff=pLvl->iOff; iOff<pData->nn; iOff++){\n      if( pData->p[iOff] ) break; \n    }\n\n    if( iOff<pData->nn ){\n      i64 iVal;\n      pLvl->iLeafPgno += (iOff - pLvl->iOff) + 1;\n      iOff += fts5GetVarint(&pData->p[iOff], (u64*)&iVal);\n      pLvl->iRowid += iVal;\n      pLvl->iOff = iOff;\n    }else{\n      pLvl->bEof = 1;\n    }\n  }\n\n  return pLvl->bEof;\n}\n\n/*\n** Advance the iterator passed as the only argument.\n*/\nstatic int fts5DlidxIterNextR(Fts5Index *p, Fts5DlidxIter *pIter, int iLvl){\n  Fts5DlidxLvl *pLvl = &pIter->aLvl[iLvl];\n\n  assert( iLvl<pIter->nLvl );\n  if( fts5DlidxLvlNext(pLvl) ){\n    if( (iLvl+1) < pIter->nLvl ){\n      fts5DlidxIterNextR(p, pIter, iLvl+1);\n      if( pLvl[1].bEof==0 ){\n        fts5DataRelease(pLvl->pData);\n        memset(pLvl, 0, sizeof(Fts5DlidxLvl));\n        pLvl->pData = fts5DataRead(p, \n            FTS5_DLIDX_ROWID(pIter->iSegid, iLvl, pLvl[1].iLeafPgno)\n        );\n        if( pLvl->pData ) fts5DlidxLvlNext(pLvl);\n      }\n    }\n  }\n\n  return pIter->aLvl[0].bEof;\n}\nstatic int fts5DlidxIterNext(Fts5Index *p, Fts5DlidxIter *pIter){\n  return fts5DlidxIterNextR(p, pIter, 0);\n}\n\n/*\n** The iterator passed as the first argument has the following fields set\n** as follows. This function sets up the rest of the iterator so that it\n** points to the first rowid in the doclist-index.\n**\n**   pData:\n**     pointer to doclist-index record, \n**\n** When this function is called pIter->iLeafPgno is the page number the\n** doclist is associated with (the one featuring the term).\n*/\nstatic int fts5DlidxIterFirst(Fts5DlidxIter *pIter){\n  int i;\n  for(i=0; i<pIter->nLvl; i++){\n    fts5DlidxLvlNext(&pIter->aLvl[i]);\n  }\n  return pIter->aLvl[0].bEof;\n}\n\n\nstatic int fts5DlidxIterEof(Fts5Index *p, Fts5DlidxIter *pIter){\n  return p->rc!=SQLITE_OK || pIter->aLvl[0].bEof;\n}\n\nstatic void fts5DlidxIterLast(Fts5Index *p, Fts5DlidxIter *pIter){\n  int i;\n\n  /* Advance each level to the last entry on the last page */\n  for(i=pIter->nLvl-1; p->rc==SQLITE_OK && i>=0; i--){\n    Fts5DlidxLvl *pLvl = &pIter->aLvl[i];\n    while( fts5DlidxLvlNext(pLvl)==0 );\n    pLvl->bEof = 0;\n\n    if( i>0 ){\n      Fts5DlidxLvl *pChild = &pLvl[-1];\n      fts5DataRelease(pChild->pData);\n      memset(pChild, 0, sizeof(Fts5DlidxLvl));\n      pChild->pData = fts5DataRead(p, \n          FTS5_DLIDX_ROWID(pIter->iSegid, i-1, pLvl->iLeafPgno)\n      );\n    }\n  }\n}\n\n/*\n** Move the iterator passed as the only argument to the previous entry.\n*/\nstatic int fts5DlidxLvlPrev(Fts5DlidxLvl *pLvl){\n  int iOff = pLvl->iOff;\n\n  assert( pLvl->bEof==0 );\n  if( iOff<=pLvl->iFirstOff ){\n    pLvl->bEof = 1;\n  }else{\n    u8 *a = pLvl->pData->p;\n    i64 iVal;\n    int iLimit;\n    int ii;\n    int nZero = 0;\n\n    /* Currently iOff points to the first byte of a varint. This block \n    ** decrements iOff until it points to the first byte of the previous \n    ** varint. Taking care not to read any memory locations that occur\n    ** before the buffer in memory.  */\n    iLimit = (iOff>9 ? iOff-9 : 0);\n    for(iOff--; iOff>iLimit; iOff--){\n      if( (a[iOff-1] & 0x80)==0 ) break;\n    }\n\n    fts5GetVarint(&a[iOff], (u64*)&iVal);\n    pLvl->iRowid -= iVal;\n    pLvl->iLeafPgno--;\n\n    /* Skip backwards past any 0x00 varints. */\n    for(ii=iOff-1; ii>=pLvl->iFirstOff && a[ii]==0x00; ii--){\n      nZero++;\n    }\n    if( ii>=pLvl->iFirstOff && (a[ii] & 0x80) ){\n      /* The byte immediately before the last 0x00 byte has the 0x80 bit\n      ** set. So the last 0x00 is only a varint 0 if there are 8 more 0x80\n      ** bytes before a[ii]. */\n      int bZero = 0;              /* True if last 0x00 counts */\n      if( (ii-8)>=pLvl->iFirstOff ){\n        int j;\n        for(j=1; j<=8 && (a[ii-j] & 0x80); j++);\n        bZero = (j>8);\n      }\n      if( bZero==0 ) nZero--;\n    }\n    pLvl->iLeafPgno -= nZero;\n    pLvl->iOff = iOff - nZero;\n  }\n\n  return pLvl->bEof;\n}\n\nstatic int fts5DlidxIterPrevR(Fts5Index *p, Fts5DlidxIter *pIter, int iLvl){\n  Fts5DlidxLvl *pLvl = &pIter->aLvl[iLvl];\n\n  assert( iLvl<pIter->nLvl );\n  if( fts5DlidxLvlPrev(pLvl) ){\n    if( (iLvl+1) < pIter->nLvl ){\n      fts5DlidxIterPrevR(p, pIter, iLvl+1);\n      if( pLvl[1].bEof==0 ){\n        fts5DataRelease(pLvl->pData);\n        memset(pLvl, 0, sizeof(Fts5DlidxLvl));\n        pLvl->pData = fts5DataRead(p, \n            FTS5_DLIDX_ROWID(pIter->iSegid, iLvl, pLvl[1].iLeafPgno)\n        );\n        if( pLvl->pData ){\n          while( fts5DlidxLvlNext(pLvl)==0 );\n          pLvl->bEof = 0;\n        }\n      }\n    }\n  }\n\n  return pIter->aLvl[0].bEof;\n}\nstatic int fts5DlidxIterPrev(Fts5Index *p, Fts5DlidxIter *pIter){\n  return fts5DlidxIterPrevR(p, pIter, 0);\n}\n\n/*\n** Free a doclist-index iterator object allocated by fts5DlidxIterInit().\n*/\nstatic void fts5DlidxIterFree(Fts5DlidxIter *pIter){\n  if( pIter ){\n    int i;\n    for(i=0; i<pIter->nLvl; i++){\n      fts5DataRelease(pIter->aLvl[i].pData);\n    }\n    sqlite3_free(pIter);\n  }\n}\n\nstatic Fts5DlidxIter *fts5DlidxIterInit(\n  Fts5Index *p,                   /* Fts5 Backend to iterate within */\n  int bRev,                       /* True for ORDER BY ASC */\n  int iSegid,                     /* Segment id */\n  int iLeafPg                     /* Leaf page number to load dlidx for */\n){\n  Fts5DlidxIter *pIter = 0;\n  int i;\n  int bDone = 0;\n\n  for(i=0; p->rc==SQLITE_OK && bDone==0; i++){\n    sqlite3_int64 nByte = sizeof(Fts5DlidxIter) + i * sizeof(Fts5DlidxLvl);\n    Fts5DlidxIter *pNew;\n\n    pNew = (Fts5DlidxIter*)sqlite3_realloc64(pIter, nByte);\n    if( pNew==0 ){\n      p->rc = SQLITE_NOMEM;\n    }else{\n      i64 iRowid = FTS5_DLIDX_ROWID(iSegid, i, iLeafPg);\n      Fts5DlidxLvl *pLvl = &pNew->aLvl[i];\n      pIter = pNew;\n      memset(pLvl, 0, sizeof(Fts5DlidxLvl));\n      pLvl->pData = fts5DataRead(p, iRowid);\n      if( pLvl->pData && (pLvl->pData->p[0] & 0x0001)==0 ){\n        bDone = 1;\n      }\n      pIter->nLvl = i+1;\n    }\n  }\n\n  if( p->rc==SQLITE_OK ){\n    pIter->iSegid = iSegid;\n    if( bRev==0 ){\n      fts5DlidxIterFirst(pIter);\n    }else{\n      fts5DlidxIterLast(p, pIter);\n    }\n  }\n\n  if( p->rc!=SQLITE_OK ){\n    fts5DlidxIterFree(pIter);\n    pIter = 0;\n  }\n\n  return pIter;\n}\n\nstatic i64 fts5DlidxIterRowid(Fts5DlidxIter *pIter){\n  return pIter->aLvl[0].iRowid;\n}\nstatic int fts5DlidxIterPgno(Fts5DlidxIter *pIter){\n  return pIter->aLvl[0].iLeafPgno;\n}\n\n/*\n** Load the next leaf page into the segment iterator.\n*/\nstatic void fts5SegIterNextPage(\n  Fts5Index *p,                   /* FTS5 backend object */\n  Fts5SegIter *pIter              /* Iterator to advance to next page */\n){\n  Fts5Data *pLeaf;\n  Fts5StructureSegment *pSeg = pIter->pSeg;\n  fts5DataRelease(pIter->pLeaf);\n  pIter->iLeafPgno++;\n  if( pIter->pNextLeaf ){\n    pIter->pLeaf = pIter->pNextLeaf;\n    pIter->pNextLeaf = 0;\n  }else if( pIter->iLeafPgno<=pSeg->pgnoLast ){\n    pIter->pLeaf = fts5LeafRead(p, \n        FTS5_SEGMENT_ROWID(pSeg->iSegid, pIter->iLeafPgno)\n    );\n  }else{\n    pIter->pLeaf = 0;\n  }\n  pLeaf = pIter->pLeaf;\n\n  if( pLeaf ){\n    pIter->iPgidxOff = pLeaf->szLeaf;\n    if( fts5LeafIsTermless(pLeaf) ){\n      pIter->iEndofDoclist = pLeaf->nn+1;\n    }else{\n      pIter->iPgidxOff += fts5GetVarint32(&pLeaf->p[pIter->iPgidxOff],\n          pIter->iEndofDoclist\n      );\n    }\n  }\n}\n\n/*\n** Argument p points to a buffer containing a varint to be interpreted as a\n** position list size field. Read the varint and return the number of bytes\n** read. Before returning, set *pnSz to the number of bytes in the position\n** list, and *pbDel to true if the delete flag is set, or false otherwise.\n*/\nstatic int fts5GetPoslistSize(const u8 *p, int *pnSz, int *pbDel){\n  int nSz;\n  int n = 0;\n  fts5FastGetVarint32(p, n, nSz);\n  assert_nc( nSz>=0 );\n  *pnSz = nSz/2;\n  *pbDel = nSz & 0x0001;\n  return n;\n}\n\n/*\n** Fts5SegIter.iLeafOffset currently points to the first byte of a\n** position-list size field. Read the value of the field and store it\n** in the following variables:\n**\n**   Fts5SegIter.nPos\n**   Fts5SegIter.bDel\n**\n** Leave Fts5SegIter.iLeafOffset pointing to the first byte of the \n** position list content (if any).\n*/\nstatic void fts5SegIterLoadNPos(Fts5Index *p, Fts5SegIter *pIter){\n  if( p->rc==SQLITE_OK ){\n    int iOff = pIter->iLeafOffset;  /* Offset to read at */\n    ASSERT_SZLEAF_OK(pIter->pLeaf);\n    if( p->pConfig->eDetail==FTS5_DETAIL_NONE ){\n      int iEod = MIN(pIter->iEndofDoclist, pIter->pLeaf->szLeaf);\n      pIter->bDel = 0;\n      pIter->nPos = 1;\n      if( iOff<iEod && pIter->pLeaf->p[iOff]==0 ){\n        pIter->bDel = 1;\n        iOff++;\n        if( iOff<iEod && pIter->pLeaf->p[iOff]==0 ){\n          pIter->nPos = 1;\n          iOff++;\n        }else{\n          pIter->nPos = 0;\n        }\n      }\n    }else{\n      int nSz;\n      fts5FastGetVarint32(pIter->pLeaf->p, iOff, nSz);\n      pIter->bDel = (nSz & 0x0001);\n      pIter->nPos = nSz>>1;\n      assert_nc( pIter->nPos>=0 );\n    }\n    pIter->iLeafOffset = iOff;\n  }\n}\n\nstatic void fts5SegIterLoadRowid(Fts5Index *p, Fts5SegIter *pIter){\n  u8 *a = pIter->pLeaf->p;        /* Buffer to read data from */\n  int iOff = pIter->iLeafOffset;\n\n  ASSERT_SZLEAF_OK(pIter->pLeaf);\n  if( iOff>=pIter->pLeaf->szLeaf ){\n    fts5SegIterNextPage(p, pIter);\n    if( pIter->pLeaf==0 ){\n      if( p->rc==SQLITE_OK ) p->rc = FTS5_CORRUPT;\n      return;\n    }\n    iOff = 4;\n    a = pIter->pLeaf->p;\n  }\n  iOff += sqlite3Fts5GetVarint(&a[iOff], (u64*)&pIter->iRowid);\n  pIter->iLeafOffset = iOff;\n}\n\n/*\n** Fts5SegIter.iLeafOffset currently points to the first byte of the \n** \"nSuffix\" field of a term. Function parameter nKeep contains the value\n** of the \"nPrefix\" field (if there was one - it is passed 0 if this is\n** the first term in the segment).\n**\n** This function populates:\n**\n**   Fts5SegIter.term\n**   Fts5SegIter.rowid\n**\n** accordingly and leaves (Fts5SegIter.iLeafOffset) set to the content of\n** the first position list. The position list belonging to document \n** (Fts5SegIter.iRowid).\n*/\nstatic void fts5SegIterLoadTerm(Fts5Index *p, Fts5SegIter *pIter, int nKeep){\n  u8 *a = pIter->pLeaf->p;        /* Buffer to read data from */\n  int iOff = pIter->iLeafOffset;  /* Offset to read at */\n  int nNew;                       /* Bytes of new data */\n\n  iOff += fts5GetVarint32(&a[iOff], nNew);\n  if( iOff+nNew>pIter->pLeaf->szLeaf || nKeep>pIter->term.n || nNew==0 ){\n    p->rc = FTS5_CORRUPT;\n    return;\n  }\n  pIter->term.n = nKeep;\n  fts5BufferAppendBlob(&p->rc, &pIter->term, nNew, &a[iOff]);\n  assert( pIter->term.n<=pIter->term.nSpace );\n  iOff += nNew;\n  pIter->iTermLeafOffset = iOff;\n  pIter->iTermLeafPgno = pIter->iLeafPgno;\n  pIter->iLeafOffset = iOff;\n\n  if( pIter->iPgidxOff>=pIter->pLeaf->nn ){\n    pIter->iEndofDoclist = pIter->pLeaf->nn+1;\n  }else{\n    int nExtra;\n    pIter->iPgidxOff += fts5GetVarint32(&a[pIter->iPgidxOff], nExtra);\n    pIter->iEndofDoclist += nExtra;\n  }\n\n  fts5SegIterLoadRowid(p, pIter);\n}\n\nstatic void fts5SegIterNext(Fts5Index*, Fts5SegIter*, int*);\nstatic void fts5SegIterNext_Reverse(Fts5Index*, Fts5SegIter*, int*);\nstatic void fts5SegIterNext_None(Fts5Index*, Fts5SegIter*, int*);\n\nstatic void fts5SegIterSetNext(Fts5Index *p, Fts5SegIter *pIter){\n  if( pIter->flags & FTS5_SEGITER_REVERSE ){\n    pIter->xNext = fts5SegIterNext_Reverse;\n  }else if( p->pConfig->eDetail==FTS5_DETAIL_NONE ){\n    pIter->xNext = fts5SegIterNext_None;\n  }else{\n    pIter->xNext = fts5SegIterNext;\n  }\n}\n\n/*\n** Initialize the iterator object pIter to iterate through the entries in\n** segment pSeg. The iterator is left pointing to the first entry when \n** this function returns.\n**\n** If an error occurs, Fts5Index.rc is set to an appropriate error code. If \n** an error has already occurred when this function is called, it is a no-op.\n*/\nstatic void fts5SegIterInit(\n  Fts5Index *p,                   /* FTS index object */\n  Fts5StructureSegment *pSeg,     /* Description of segment */\n  Fts5SegIter *pIter              /* Object to populate */\n){\n  if( pSeg->pgnoFirst==0 ){\n    /* This happens if the segment is being used as an input to an incremental\n    ** merge and all data has already been \"trimmed\". See function\n    ** fts5TrimSegments() for details. In this case leave the iterator empty.\n    ** The caller will see the (pIter->pLeaf==0) and assume the iterator is\n    ** at EOF already. */\n    assert( pIter->pLeaf==0 );\n    return;\n  }\n\n  if( p->rc==SQLITE_OK ){\n    memset(pIter, 0, sizeof(*pIter));\n    fts5SegIterSetNext(p, pIter);\n    pIter->pSeg = pSeg;\n    pIter->iLeafPgno = pSeg->pgnoFirst-1;\n    fts5SegIterNextPage(p, pIter);\n  }\n\n  if( p->rc==SQLITE_OK ){\n    pIter->iLeafOffset = 4;\n    assert_nc( pIter->pLeaf->nn>4 );\n    assert_nc( fts5LeafFirstTermOff(pIter->pLeaf)==4 );\n    pIter->iPgidxOff = pIter->pLeaf->szLeaf+1;\n    fts5SegIterLoadTerm(p, pIter, 0);\n    fts5SegIterLoadNPos(p, pIter);\n  }\n}\n\n/*\n** This function is only ever called on iterators created by calls to\n** Fts5IndexQuery() with the FTS5INDEX_QUERY_DESC flag set.\n**\n** The iterator is in an unusual state when this function is called: the\n** Fts5SegIter.iLeafOffset variable is set to the offset of the start of\n** the position-list size field for the first relevant rowid on the page.\n** Fts5SegIter.rowid is set, but nPos and bDel are not.\n**\n** This function advances the iterator so that it points to the last \n** relevant rowid on the page and, if necessary, initializes the \n** aRowidOffset[] and iRowidOffset variables. At this point the iterator\n** is in its regular state - Fts5SegIter.iLeafOffset points to the first\n** byte of the position list content associated with said rowid.\n*/\nstatic void fts5SegIterReverseInitPage(Fts5Index *p, Fts5SegIter *pIter){\n  int eDetail = p->pConfig->eDetail;\n  int n = pIter->pLeaf->szLeaf;\n  int i = pIter->iLeafOffset;\n  u8 *a = pIter->pLeaf->p;\n  int iRowidOffset = 0;\n\n  if( n>pIter->iEndofDoclist ){\n    n = pIter->iEndofDoclist;\n  }\n\n  ASSERT_SZLEAF_OK(pIter->pLeaf);\n  while( 1 ){\n    i64 iDelta = 0;\n\n    if( eDetail==FTS5_DETAIL_NONE ){\n      /* todo */\n      if( i<n && a[i]==0 ){\n        i++;\n        if( i<n && a[i]==0 ) i++;\n      }\n    }else{\n      int nPos;\n      int bDummy;\n      i += fts5GetPoslistSize(&a[i], &nPos, &bDummy);\n      i += nPos;\n    }\n    if( i>=n ) break;\n    i += fts5GetVarint(&a[i], (u64*)&iDelta);\n    pIter->iRowid += iDelta;\n\n    /* If necessary, grow the pIter->aRowidOffset[] array. */\n    if( iRowidOffset>=pIter->nRowidOffset ){\n      int nNew = pIter->nRowidOffset + 8;\n      int *aNew = (int*)sqlite3_realloc64(pIter->aRowidOffset,nNew*sizeof(int));\n      if( aNew==0 ){\n        p->rc = SQLITE_NOMEM;\n        break;\n      }\n      pIter->aRowidOffset = aNew;\n      pIter->nRowidOffset = nNew;\n    }\n\n    pIter->aRowidOffset[iRowidOffset++] = pIter->iLeafOffset;\n    pIter->iLeafOffset = i;\n  }\n  pIter->iRowidOffset = iRowidOffset;\n  fts5SegIterLoadNPos(p, pIter);\n}\n\n/*\n**\n*/\nstatic void fts5SegIterReverseNewPage(Fts5Index *p, Fts5SegIter *pIter){\n  assert( pIter->flags & FTS5_SEGITER_REVERSE );\n  assert( pIter->flags & FTS5_SEGITER_ONETERM );\n\n  fts5DataRelease(pIter->pLeaf);\n  pIter->pLeaf = 0;\n  while( p->rc==SQLITE_OK && pIter->iLeafPgno>pIter->iTermLeafPgno ){\n    Fts5Data *pNew;\n    pIter->iLeafPgno--;\n    pNew = fts5DataRead(p, FTS5_SEGMENT_ROWID(\n          pIter->pSeg->iSegid, pIter->iLeafPgno\n    ));\n    if( pNew ){\n      /* iTermLeafOffset may be equal to szLeaf if the term is the last\n      ** thing on the page - i.e. the first rowid is on the following page.\n      ** In this case leave pIter->pLeaf==0, this iterator is at EOF. */\n      if( pIter->iLeafPgno==pIter->iTermLeafPgno ){\n        assert( pIter->pLeaf==0 );\n        if( pIter->iTermLeafOffset<pNew->szLeaf ){\n          pIter->pLeaf = pNew;\n          pIter->iLeafOffset = pIter->iTermLeafOffset;\n        }\n      }else{\n        int iRowidOff;\n        iRowidOff = fts5LeafFirstRowidOff(pNew);\n        if( iRowidOff ){\n          pIter->pLeaf = pNew;\n          pIter->iLeafOffset = iRowidOff;\n        }\n      }\n\n      if( pIter->pLeaf ){\n        u8 *a = &pIter->pLeaf->p[pIter->iLeafOffset];\n        pIter->iLeafOffset += fts5GetVarint(a, (u64*)&pIter->iRowid);\n        break;\n      }else{\n        fts5DataRelease(pNew);\n      }\n    }\n  }\n\n  if( pIter->pLeaf ){\n    pIter->iEndofDoclist = pIter->pLeaf->nn+1;\n    fts5SegIterReverseInitPage(p, pIter);\n  }\n}\n\n/*\n** Return true if the iterator passed as the second argument currently\n** points to a delete marker. A delete marker is an entry with a 0 byte\n** position-list.\n*/\nstatic int fts5MultiIterIsEmpty(Fts5Index *p, Fts5Iter *pIter){\n  Fts5SegIter *pSeg = &pIter->aSeg[pIter->aFirst[1].iFirst];\n  return (p->rc==SQLITE_OK && pSeg->pLeaf && pSeg->nPos==0);\n}\n\n/*\n** Advance iterator pIter to the next entry.\n**\n** This version of fts5SegIterNext() is only used by reverse iterators.\n*/\nstatic void fts5SegIterNext_Reverse(\n  Fts5Index *p,                   /* FTS5 backend object */\n  Fts5SegIter *pIter,             /* Iterator to advance */\n  int *pbUnused                   /* Unused */\n){\n  assert( pIter->flags & FTS5_SEGITER_REVERSE );\n  assert( pIter->pNextLeaf==0 );\n  UNUSED_PARAM(pbUnused);\n\n  if( pIter->iRowidOffset>0 ){\n    u8 *a = pIter->pLeaf->p;\n    int iOff;\n    i64 iDelta;\n\n    pIter->iRowidOffset--;\n    pIter->iLeafOffset = pIter->aRowidOffset[pIter->iRowidOffset];\n    fts5SegIterLoadNPos(p, pIter);\n    iOff = pIter->iLeafOffset;\n    if( p->pConfig->eDetail!=FTS5_DETAIL_NONE ){\n      iOff += pIter->nPos;\n    }\n    fts5GetVarint(&a[iOff], (u64*)&iDelta);\n    pIter->iRowid -= iDelta;\n  }else{\n    fts5SegIterReverseNewPage(p, pIter);\n  }\n}\n\n/*\n** Advance iterator pIter to the next entry.\n**\n** This version of fts5SegIterNext() is only used if detail=none and the\n** iterator is not a reverse direction iterator.\n*/\nstatic void fts5SegIterNext_None(\n  Fts5Index *p,                   /* FTS5 backend object */\n  Fts5SegIter *pIter,             /* Iterator to advance */\n  int *pbNewTerm                  /* OUT: Set for new term */\n){\n  int iOff;\n\n  assert( p->rc==SQLITE_OK );\n  assert( (pIter->flags & FTS5_SEGITER_REVERSE)==0 );\n  assert( p->pConfig->eDetail==FTS5_DETAIL_NONE );\n\n  ASSERT_SZLEAF_OK(pIter->pLeaf);\n  iOff = pIter->iLeafOffset;\n\n  /* Next entry is on the next page */\n  if( pIter->pSeg && iOff>=pIter->pLeaf->szLeaf ){\n    fts5SegIterNextPage(p, pIter);\n    if( p->rc || pIter->pLeaf==0 ) return;\n    pIter->iRowid = 0;\n    iOff = 4;\n  }\n\n  if( iOff<pIter->iEndofDoclist ){\n    /* Next entry is on the current page */\n    i64 iDelta;\n    iOff += sqlite3Fts5GetVarint(&pIter->pLeaf->p[iOff], (u64*)&iDelta);\n    pIter->iLeafOffset = iOff;\n    pIter->iRowid += iDelta;\n  }else if( (pIter->flags & FTS5_SEGITER_ONETERM)==0 ){\n    if( pIter->pSeg ){\n      int nKeep = 0;\n      if( iOff!=fts5LeafFirstTermOff(pIter->pLeaf) ){\n        iOff += fts5GetVarint32(&pIter->pLeaf->p[iOff], nKeep);\n      }\n      pIter->iLeafOffset = iOff;\n      fts5SegIterLoadTerm(p, pIter, nKeep);\n    }else{\n      const u8 *pList = 0;\n      const char *zTerm = 0;\n      int nList;\n      sqlite3Fts5HashScanNext(p->pHash);\n      sqlite3Fts5HashScanEntry(p->pHash, &zTerm, &pList, &nList);\n      if( pList==0 ) goto next_none_eof;\n      pIter->pLeaf->p = (u8*)pList;\n      pIter->pLeaf->nn = nList;\n      pIter->pLeaf->szLeaf = nList;\n      pIter->iEndofDoclist = nList;\n      sqlite3Fts5BufferSet(&p->rc,&pIter->term, (int)strlen(zTerm), (u8*)zTerm);\n      pIter->iLeafOffset = fts5GetVarint(pList, (u64*)&pIter->iRowid);\n    }\n\n    if( pbNewTerm ) *pbNewTerm = 1;\n  }else{\n    goto next_none_eof;\n  }\n\n  fts5SegIterLoadNPos(p, pIter);\n\n  return;\n next_none_eof:\n  fts5DataRelease(pIter->pLeaf);\n  pIter->pLeaf = 0;\n}\n\n\n/*\n** Advance iterator pIter to the next entry. \n**\n** If an error occurs, Fts5Index.rc is set to an appropriate error code. It \n** is not considered an error if the iterator reaches EOF. If an error has \n** already occurred when this function is called, it is a no-op.\n*/\nstatic void fts5SegIterNext(\n  Fts5Index *p,                   /* FTS5 backend object */\n  Fts5SegIter *pIter,             /* Iterator to advance */\n  int *pbNewTerm                  /* OUT: Set for new term */\n){\n  Fts5Data *pLeaf = pIter->pLeaf;\n  int iOff;\n  int bNewTerm = 0;\n  int nKeep = 0;\n  u8 *a;\n  int n;\n\n  assert( pbNewTerm==0 || *pbNewTerm==0 );\n  assert( p->pConfig->eDetail!=FTS5_DETAIL_NONE );\n\n  /* Search for the end of the position list within the current page. */\n  a = pLeaf->p;\n  n = pLeaf->szLeaf;\n\n  ASSERT_SZLEAF_OK(pLeaf);\n  iOff = pIter->iLeafOffset + pIter->nPos;\n\n  if( iOff<n ){\n    /* The next entry is on the current page. */\n    assert_nc( iOff<=pIter->iEndofDoclist );\n    if( iOff>=pIter->iEndofDoclist ){\n      bNewTerm = 1;\n      if( iOff!=fts5LeafFirstTermOff(pLeaf) ){\n        iOff += fts5GetVarint32(&a[iOff], nKeep);\n      }\n    }else{\n      u64 iDelta;\n      iOff += sqlite3Fts5GetVarint(&a[iOff], &iDelta);\n      pIter->iRowid += iDelta;\n      assert_nc( iDelta>0 );\n    }\n    pIter->iLeafOffset = iOff;\n\n  }else if( pIter->pSeg==0 ){\n    const u8 *pList = 0;\n    const char *zTerm = 0;\n    int nList = 0;\n    assert( (pIter->flags & FTS5_SEGITER_ONETERM) || pbNewTerm );\n    if( 0==(pIter->flags & FTS5_SEGITER_ONETERM) ){\n      sqlite3Fts5HashScanNext(p->pHash);\n      sqlite3Fts5HashScanEntry(p->pHash, &zTerm, &pList, &nList);\n    }\n    if( pList==0 ){\n      fts5DataRelease(pIter->pLeaf);\n      pIter->pLeaf = 0;\n    }else{\n      pIter->pLeaf->p = (u8*)pList;\n      pIter->pLeaf->nn = nList;\n      pIter->pLeaf->szLeaf = nList;\n      pIter->iEndofDoclist = nList+1;\n      sqlite3Fts5BufferSet(&p->rc, &pIter->term, (int)strlen(zTerm),\n          (u8*)zTerm);\n      pIter->iLeafOffset = fts5GetVarint(pList, (u64*)&pIter->iRowid);\n      *pbNewTerm = 1;\n    }\n  }else{\n    iOff = 0;\n    /* Next entry is not on the current page */\n    while( iOff==0 ){\n      fts5SegIterNextPage(p, pIter);\n      pLeaf = pIter->pLeaf;\n      if( pLeaf==0 ) break;\n      ASSERT_SZLEAF_OK(pLeaf);\n      if( (iOff = fts5LeafFirstRowidOff(pLeaf)) && iOff<pLeaf->szLeaf ){\n        iOff += sqlite3Fts5GetVarint(&pLeaf->p[iOff], (u64*)&pIter->iRowid);\n        pIter->iLeafOffset = iOff;\n\n        if( pLeaf->nn>pLeaf->szLeaf ){\n          pIter->iPgidxOff = pLeaf->szLeaf + fts5GetVarint32(\n              &pLeaf->p[pLeaf->szLeaf], pIter->iEndofDoclist\n          );\n        }\n      }\n      else if( pLeaf->nn>pLeaf->szLeaf ){\n        pIter->iPgidxOff = pLeaf->szLeaf + fts5GetVarint32(\n            &pLeaf->p[pLeaf->szLeaf], iOff\n        );\n        pIter->iLeafOffset = iOff;\n        pIter->iEndofDoclist = iOff;\n        bNewTerm = 1;\n      }\n      assert_nc( iOff<pLeaf->szLeaf );\n      if( iOff>pLeaf->szLeaf ){\n        p->rc = FTS5_CORRUPT;\n        return;\n      }\n    }\n  }\n\n  /* Check if the iterator is now at EOF. If so, return early. */\n  if( pIter->pLeaf ){\n    if( bNewTerm ){\n      if( pIter->flags & FTS5_SEGITER_ONETERM ){\n        fts5DataRelease(pIter->pLeaf);\n        pIter->pLeaf = 0;\n      }else{\n        fts5SegIterLoadTerm(p, pIter, nKeep);\n        fts5SegIterLoadNPos(p, pIter);\n        if( pbNewTerm ) *pbNewTerm = 1;\n      }\n    }else{\n      /* The following could be done by calling fts5SegIterLoadNPos(). But\n      ** this block is particularly performance critical, so equivalent\n      ** code is inlined. \n      **\n      ** Later: Switched back to fts5SegIterLoadNPos() because it supports\n      ** detail=none mode. Not ideal.\n      */\n      int nSz;\n      assert( p->rc==SQLITE_OK );\n      assert( pIter->iLeafOffset<=pIter->pLeaf->nn );\n      fts5FastGetVarint32(pIter->pLeaf->p, pIter->iLeafOffset, nSz);\n      pIter->bDel = (nSz & 0x0001);\n      pIter->nPos = nSz>>1;\n      assert_nc( pIter->nPos>=0 );\n    }\n  }\n}\n\n#define SWAPVAL(T, a, b) { T tmp; tmp=a; a=b; b=tmp; }\n\n#define fts5IndexSkipVarint(a, iOff) {            \\\n  int iEnd = iOff+9;                              \\\n  while( (a[iOff++] & 0x80) && iOff<iEnd );       \\\n}\n\n/*\n** Iterator pIter currently points to the first rowid in a doclist. This\n** function sets the iterator up so that iterates in reverse order through\n** the doclist.\n*/\nstatic void fts5SegIterReverse(Fts5Index *p, Fts5SegIter *pIter){\n  Fts5DlidxIter *pDlidx = pIter->pDlidx;\n  Fts5Data *pLast = 0;\n  int pgnoLast = 0;\n\n  if( pDlidx ){\n    int iSegid = pIter->pSeg->iSegid;\n    pgnoLast = fts5DlidxIterPgno(pDlidx);\n    pLast = fts5DataRead(p, FTS5_SEGMENT_ROWID(iSegid, pgnoLast));\n  }else{\n    Fts5Data *pLeaf = pIter->pLeaf;         /* Current leaf data */\n\n    /* Currently, Fts5SegIter.iLeafOffset points to the first byte of\n    ** position-list content for the current rowid. Back it up so that it\n    ** points to the start of the position-list size field. */\n    int iPoslist;\n    if( pIter->iTermLeafPgno==pIter->iLeafPgno ){\n      iPoslist = pIter->iTermLeafOffset;\n    }else{\n      iPoslist = 4;\n    }\n    fts5IndexSkipVarint(pLeaf->p, iPoslist);\n    pIter->iLeafOffset = iPoslist;\n\n    /* If this condition is true then the largest rowid for the current\n    ** term may not be stored on the current page. So search forward to\n    ** see where said rowid really is.  */\n    if( pIter->iEndofDoclist>=pLeaf->szLeaf ){\n      int pgno;\n      Fts5StructureSegment *pSeg = pIter->pSeg;\n\n      /* The last rowid in the doclist may not be on the current page. Search\n      ** forward to find the page containing the last rowid.  */\n      for(pgno=pIter->iLeafPgno+1; !p->rc && pgno<=pSeg->pgnoLast; pgno++){\n        i64 iAbs = FTS5_SEGMENT_ROWID(pSeg->iSegid, pgno);\n        Fts5Data *pNew = fts5DataRead(p, iAbs);\n        if( pNew ){\n          int iRowid, bTermless;\n          iRowid = fts5LeafFirstRowidOff(pNew);\n          bTermless = fts5LeafIsTermless(pNew);\n          if( iRowid ){\n            SWAPVAL(Fts5Data*, pNew, pLast);\n            pgnoLast = pgno;\n          }\n          fts5DataRelease(pNew);\n          if( bTermless==0 ) break;\n        }\n      }\n    }\n  }\n\n  /* If pLast is NULL at this point, then the last rowid for this doclist\n  ** lies on the page currently indicated by the iterator. In this case \n  ** pIter->iLeafOffset is already set to point to the position-list size\n  ** field associated with the first relevant rowid on the page.\n  **\n  ** Or, if pLast is non-NULL, then it is the page that contains the last\n  ** rowid. In this case configure the iterator so that it points to the\n  ** first rowid on this page.\n  */\n  if( pLast ){\n    int iOff;\n    fts5DataRelease(pIter->pLeaf);\n    pIter->pLeaf = pLast;\n    pIter->iLeafPgno = pgnoLast;\n    iOff = fts5LeafFirstRowidOff(pLast);\n    iOff += fts5GetVarint(&pLast->p[iOff], (u64*)&pIter->iRowid);\n    pIter->iLeafOffset = iOff;\n\n    if( fts5LeafIsTermless(pLast) ){\n      pIter->iEndofDoclist = pLast->nn+1;\n    }else{\n      pIter->iEndofDoclist = fts5LeafFirstTermOff(pLast);\n    }\n\n  }\n\n  fts5SegIterReverseInitPage(p, pIter);\n}\n\n/*\n** Iterator pIter currently points to the first rowid of a doclist.\n** There is a doclist-index associated with the final term on the current \n** page. If the current term is the last term on the page, load the \n** doclist-index from disk and initialize an iterator at (pIter->pDlidx).\n*/\nstatic void fts5SegIterLoadDlidx(Fts5Index *p, Fts5SegIter *pIter){\n  int iSeg = pIter->pSeg->iSegid;\n  int bRev = (pIter->flags & FTS5_SEGITER_REVERSE);\n  Fts5Data *pLeaf = pIter->pLeaf; /* Current leaf data */\n\n  assert( pIter->flags & FTS5_SEGITER_ONETERM );\n  assert( pIter->pDlidx==0 );\n\n  /* Check if the current doclist ends on this page. If it does, return\n  ** early without loading the doclist-index (as it belongs to a different\n  ** term. */\n  if( pIter->iTermLeafPgno==pIter->iLeafPgno \n   && pIter->iEndofDoclist<pLeaf->szLeaf \n  ){\n    return;\n  }\n\n  pIter->pDlidx = fts5DlidxIterInit(p, bRev, iSeg, pIter->iTermLeafPgno);\n}\n\n/*\n** The iterator object passed as the second argument currently contains\n** no valid values except for the Fts5SegIter.pLeaf member variable. This\n** function searches the leaf page for a term matching (pTerm/nTerm).\n**\n** If the specified term is found on the page, then the iterator is left\n** pointing to it. If argument bGe is zero and the term is not found,\n** the iterator is left pointing at EOF.\n**\n** If bGe is non-zero and the specified term is not found, then the\n** iterator is left pointing to the smallest term in the segment that\n** is larger than the specified term, even if this term is not on the\n** current page.\n*/\nstatic void fts5LeafSeek(\n  Fts5Index *p,                   /* Leave any error code here */\n  int bGe,                        /* True for a >= search */\n  Fts5SegIter *pIter,             /* Iterator to seek */\n  const u8 *pTerm, int nTerm      /* Term to search for */\n){\n  int iOff;\n  const u8 *a = pIter->pLeaf->p;\n  int szLeaf = pIter->pLeaf->szLeaf;\n  int n = pIter->pLeaf->nn;\n\n  u32 nMatch = 0;\n  u32 nKeep = 0;\n  u32 nNew = 0;\n  u32 iTermOff;\n  int iPgidx;                     /* Current offset in pgidx */\n  int bEndOfPage = 0;\n\n  assert( p->rc==SQLITE_OK );\n\n  iPgidx = szLeaf;\n  iPgidx += fts5GetVarint32(&a[iPgidx], iTermOff);\n  iOff = iTermOff;\n  if( iOff>n ){\n    p->rc = FTS5_CORRUPT;\n    return;\n  }\n\n  while( 1 ){\n\n    /* Figure out how many new bytes are in this term */\n    fts5FastGetVarint32(a, iOff, nNew);\n    if( nKeep<nMatch ){\n      goto search_failed;\n    }\n\n    assert( nKeep>=nMatch );\n    if( nKeep==nMatch ){\n      u32 nCmp;\n      u32 i;\n      nCmp = (u32)MIN(nNew, nTerm-nMatch);\n      for(i=0; i<nCmp; i++){\n        if( a[iOff+i]!=pTerm[nMatch+i] ) break;\n      }\n      nMatch += i;\n\n      if( (u32)nTerm==nMatch ){\n        if( i==nNew ){\n          goto search_success;\n        }else{\n          goto search_failed;\n        }\n      }else if( i<nNew && a[iOff+i]>pTerm[nMatch] ){\n        goto search_failed;\n      }\n    }\n\n    if( iPgidx>=n ){\n      bEndOfPage = 1;\n      break;\n    }\n\n    iPgidx += fts5GetVarint32(&a[iPgidx], nKeep);\n    iTermOff += nKeep;\n    iOff = iTermOff;\n\n    if( iOff>=n ){\n      p->rc = FTS5_CORRUPT;\n      return;\n    }\n\n    /* Read the nKeep field of the next term. */\n    fts5FastGetVarint32(a, iOff, nKeep);\n  }\n\n search_failed:\n  if( bGe==0 ){\n    fts5DataRelease(pIter->pLeaf);\n    pIter->pLeaf = 0;\n    return;\n  }else if( bEndOfPage ){\n    do {\n      fts5SegIterNextPage(p, pIter);\n      if( pIter->pLeaf==0 ) return;\n      a = pIter->pLeaf->p;\n      if( fts5LeafIsTermless(pIter->pLeaf)==0 ){\n        iPgidx = pIter->pLeaf->szLeaf;\n        iPgidx += fts5GetVarint32(&pIter->pLeaf->p[iPgidx], iOff);\n        if( iOff<4 || iOff>=pIter->pLeaf->szLeaf ){\n          p->rc = FTS5_CORRUPT;\n          return;\n        }else{\n          nKeep = 0;\n          iTermOff = iOff;\n          n = pIter->pLeaf->nn;\n          iOff += fts5GetVarint32(&a[iOff], nNew);\n          break;\n        }\n      }\n    }while( 1 );\n  }\n\n search_success:\n  pIter->iLeafOffset = iOff + nNew;\n  if( pIter->iLeafOffset>n || nNew<1 ){\n    p->rc = FTS5_CORRUPT;\n    return;\n  }\n  pIter->iTermLeafOffset = pIter->iLeafOffset;\n  pIter->iTermLeafPgno = pIter->iLeafPgno;\n\n  fts5BufferSet(&p->rc, &pIter->term, nKeep, pTerm);\n  fts5BufferAppendBlob(&p->rc, &pIter->term, nNew, &a[iOff]);\n\n  if( iPgidx>=n ){\n    pIter->iEndofDoclist = pIter->pLeaf->nn+1;\n  }else{\n    int nExtra;\n    iPgidx += fts5GetVarint32(&a[iPgidx], nExtra);\n    pIter->iEndofDoclist = iTermOff + nExtra;\n  }\n  pIter->iPgidxOff = iPgidx;\n\n  fts5SegIterLoadRowid(p, pIter);\n  fts5SegIterLoadNPos(p, pIter);\n}\n\nstatic sqlite3_stmt *fts5IdxSelectStmt(Fts5Index *p){\n  if( p->pIdxSelect==0 ){\n    Fts5Config *pConfig = p->pConfig;\n    fts5IndexPrepareStmt(p, &p->pIdxSelect, sqlite3_mprintf(\n          \"SELECT pgno FROM '%q'.'%q_idx' WHERE \"\n          \"segid=? AND term<=? ORDER BY term DESC LIMIT 1\",\n          pConfig->zDb, pConfig->zName\n    ));\n  }\n  return p->pIdxSelect;\n}\n\n/*\n** Initialize the object pIter to point to term pTerm/nTerm within segment\n** pSeg. If there is no such term in the index, the iterator is set to EOF.\n**\n** If an error occurs, Fts5Index.rc is set to an appropriate error code. If \n** an error has already occurred when this function is called, it is a no-op.\n*/\nstatic void fts5SegIterSeekInit(\n  Fts5Index *p,                   /* FTS5 backend */\n  const u8 *pTerm, int nTerm,     /* Term to seek to */\n  int flags,                      /* Mask of FTS5INDEX_XXX flags */\n  Fts5StructureSegment *pSeg,     /* Description of segment */\n  Fts5SegIter *pIter              /* Object to populate */\n){\n  int iPg = 1;\n  int bGe = (flags & FTS5INDEX_QUERY_SCAN);\n  int bDlidx = 0;                 /* True if there is a doclist-index */\n  sqlite3_stmt *pIdxSelect = 0;\n\n  assert( bGe==0 || (flags & FTS5INDEX_QUERY_DESC)==0 );\n  assert( pTerm && nTerm );\n  memset(pIter, 0, sizeof(*pIter));\n  pIter->pSeg = pSeg;\n\n  /* This block sets stack variable iPg to the leaf page number that may\n  ** contain term (pTerm/nTerm), if it is present in the segment. */\n  pIdxSelect = fts5IdxSelectStmt(p);\n  if( p->rc ) return;\n  sqlite3_bind_int(pIdxSelect, 1, pSeg->iSegid);\n  sqlite3_bind_blob(pIdxSelect, 2, pTerm, nTerm, SQLITE_STATIC);\n  if( SQLITE_ROW==sqlite3_step(pIdxSelect) ){\n    i64 val = sqlite3_column_int(pIdxSelect, 0);\n    iPg = (int)(val>>1);\n    bDlidx = (val & 0x0001);\n  }\n  p->rc = sqlite3_reset(pIdxSelect);\n  sqlite3_bind_null(pIdxSelect, 2);\n\n  if( iPg<pSeg->pgnoFirst ){\n    iPg = pSeg->pgnoFirst;\n    bDlidx = 0;\n  }\n\n  pIter->iLeafPgno = iPg - 1;\n  fts5SegIterNextPage(p, pIter);\n\n  if( pIter->pLeaf ){\n    fts5LeafSeek(p, bGe, pIter, pTerm, nTerm);\n  }\n\n  if( p->rc==SQLITE_OK && bGe==0 ){\n    pIter->flags |= FTS5_SEGITER_ONETERM;\n    if( pIter->pLeaf ){\n      if( flags & FTS5INDEX_QUERY_DESC ){\n        pIter->flags |= FTS5_SEGITER_REVERSE;\n      }\n      if( bDlidx ){\n        fts5SegIterLoadDlidx(p, pIter);\n      }\n      if( flags & FTS5INDEX_QUERY_DESC ){\n        fts5SegIterReverse(p, pIter);\n      }\n    }\n  }\n\n  fts5SegIterSetNext(p, pIter);\n\n  /* Either:\n  **\n  **   1) an error has occurred, or\n  **   2) the iterator points to EOF, or\n  **   3) the iterator points to an entry with term (pTerm/nTerm), or\n  **   4) the FTS5INDEX_QUERY_SCAN flag was set and the iterator points\n  **      to an entry with a term greater than or equal to (pTerm/nTerm).\n  */\n  assert_nc( p->rc!=SQLITE_OK                                       /* 1 */\n   || pIter->pLeaf==0                                               /* 2 */\n   || fts5BufferCompareBlob(&pIter->term, pTerm, nTerm)==0          /* 3 */\n   || (bGe && fts5BufferCompareBlob(&pIter->term, pTerm, nTerm)>0)  /* 4 */\n  );\n}\n\n/*\n** Initialize the object pIter to point to term pTerm/nTerm within the\n** in-memory hash table. If there is no such term in the hash-table, the \n** iterator is set to EOF.\n**\n** If an error occurs, Fts5Index.rc is set to an appropriate error code. If \n** an error has already occurred when this function is called, it is a no-op.\n*/\nstatic void fts5SegIterHashInit(\n  Fts5Index *p,                   /* FTS5 backend */\n  const u8 *pTerm, int nTerm,     /* Term to seek to */\n  int flags,                      /* Mask of FTS5INDEX_XXX flags */\n  Fts5SegIter *pIter              /* Object to populate */\n){\n  const u8 *pList = 0;\n  int nList = 0;\n  const u8 *z = 0;\n  int n = 0;\n\n  assert( p->pHash );\n  assert( p->rc==SQLITE_OK );\n\n  if( pTerm==0 || (flags & FTS5INDEX_QUERY_SCAN) ){\n    p->rc = sqlite3Fts5HashScanInit(p->pHash, (const char*)pTerm, nTerm);\n    sqlite3Fts5HashScanEntry(p->pHash, (const char**)&z, &pList, &nList);\n    n = (z ? (int)strlen((const char*)z) : 0);\n  }else{\n    pIter->flags |= FTS5_SEGITER_ONETERM;\n    sqlite3Fts5HashQuery(p->pHash, (const char*)pTerm, nTerm, &pList, &nList);\n    z = pTerm;\n    n = nTerm;\n  }\n\n  if( pList ){\n    Fts5Data *pLeaf;\n    sqlite3Fts5BufferSet(&p->rc, &pIter->term, n, z);\n    pLeaf = fts5IdxMalloc(p, sizeof(Fts5Data));\n    if( pLeaf==0 ) return;\n    pLeaf->p = (u8*)pList;\n    pLeaf->nn = pLeaf->szLeaf = nList;\n    pIter->pLeaf = pLeaf;\n    pIter->iLeafOffset = fts5GetVarint(pLeaf->p, (u64*)&pIter->iRowid);\n    pIter->iEndofDoclist = pLeaf->nn;\n\n    if( flags & FTS5INDEX_QUERY_DESC ){\n      pIter->flags |= FTS5_SEGITER_REVERSE;\n      fts5SegIterReverseInitPage(p, pIter);\n    }else{\n      fts5SegIterLoadNPos(p, pIter);\n    }\n  }\n\n  fts5SegIterSetNext(p, pIter);\n}\n\n/*\n** Zero the iterator passed as the only argument.\n*/\nstatic void fts5SegIterClear(Fts5SegIter *pIter){\n  fts5BufferFree(&pIter->term);\n  fts5DataRelease(pIter->pLeaf);\n  fts5DataRelease(pIter->pNextLeaf);\n  fts5DlidxIterFree(pIter->pDlidx);\n  sqlite3_free(pIter->aRowidOffset);\n  memset(pIter, 0, sizeof(Fts5SegIter));\n}\n\n#ifdef SQLITE_DEBUG\n\n/*\n** This function is used as part of the big assert() procedure implemented by\n** fts5AssertMultiIterSetup(). It ensures that the result currently stored\n** in *pRes is the correct result of comparing the current positions of the\n** two iterators.\n*/\nstatic void fts5AssertComparisonResult(\n  Fts5Iter *pIter, \n  Fts5SegIter *p1,\n  Fts5SegIter *p2,\n  Fts5CResult *pRes\n){\n  int i1 = p1 - pIter->aSeg;\n  int i2 = p2 - pIter->aSeg;\n\n  if( p1->pLeaf || p2->pLeaf ){\n    if( p1->pLeaf==0 ){\n      assert( pRes->iFirst==i2 );\n    }else if( p2->pLeaf==0 ){\n      assert( pRes->iFirst==i1 );\n    }else{\n      int nMin = MIN(p1->term.n, p2->term.n);\n      int res = fts5Memcmp(p1->term.p, p2->term.p, nMin);\n      if( res==0 ) res = p1->term.n - p2->term.n;\n\n      if( res==0 ){\n        assert( pRes->bTermEq==1 );\n        assert( p1->iRowid!=p2->iRowid );\n        res = ((p1->iRowid > p2->iRowid)==pIter->bRev) ? -1 : 1;\n      }else{\n        assert( pRes->bTermEq==0 );\n      }\n\n      if( res<0 ){\n        assert( pRes->iFirst==i1 );\n      }else{\n        assert( pRes->iFirst==i2 );\n      }\n    }\n  }\n}\n\n/*\n** This function is a no-op unless SQLITE_DEBUG is defined when this module\n** is compiled. In that case, this function is essentially an assert() \n** statement used to verify that the contents of the pIter->aFirst[] array\n** are correct.\n*/\nstatic void fts5AssertMultiIterSetup(Fts5Index *p, Fts5Iter *pIter){\n  if( p->rc==SQLITE_OK ){\n    Fts5SegIter *pFirst = &pIter->aSeg[ pIter->aFirst[1].iFirst ];\n    int i;\n\n    assert( (pFirst->pLeaf==0)==pIter->base.bEof );\n\n    /* Check that pIter->iSwitchRowid is set correctly. */\n    for(i=0; i<pIter->nSeg; i++){\n      Fts5SegIter *p1 = &pIter->aSeg[i];\n      assert( p1==pFirst \n           || p1->pLeaf==0 \n           || fts5BufferCompare(&pFirst->term, &p1->term) \n           || p1->iRowid==pIter->iSwitchRowid\n           || (p1->iRowid<pIter->iSwitchRowid)==pIter->bRev\n      );\n    }\n\n    for(i=0; i<pIter->nSeg; i+=2){\n      Fts5SegIter *p1 = &pIter->aSeg[i];\n      Fts5SegIter *p2 = &pIter->aSeg[i+1];\n      Fts5CResult *pRes = &pIter->aFirst[(pIter->nSeg + i) / 2];\n      fts5AssertComparisonResult(pIter, p1, p2, pRes);\n    }\n\n    for(i=1; i<(pIter->nSeg / 2); i+=2){\n      Fts5SegIter *p1 = &pIter->aSeg[ pIter->aFirst[i*2].iFirst ];\n      Fts5SegIter *p2 = &pIter->aSeg[ pIter->aFirst[i*2+1].iFirst ];\n      Fts5CResult *pRes = &pIter->aFirst[i];\n      fts5AssertComparisonResult(pIter, p1, p2, pRes);\n    }\n  }\n}\n#else\n# define fts5AssertMultiIterSetup(x,y)\n#endif\n\n/*\n** Do the comparison necessary to populate pIter->aFirst[iOut].\n**\n** If the returned value is non-zero, then it is the index of an entry\n** in the pIter->aSeg[] array that is (a) not at EOF, and (b) pointing\n** to a key that is a duplicate of another, higher priority, \n** segment-iterator in the pSeg->aSeg[] array.\n*/\nstatic int fts5MultiIterDoCompare(Fts5Iter *pIter, int iOut){\n  int i1;                         /* Index of left-hand Fts5SegIter */\n  int i2;                         /* Index of right-hand Fts5SegIter */\n  int iRes;\n  Fts5SegIter *p1;                /* Left-hand Fts5SegIter */\n  Fts5SegIter *p2;                /* Right-hand Fts5SegIter */\n  Fts5CResult *pRes = &pIter->aFirst[iOut];\n\n  assert( iOut<pIter->nSeg && iOut>0 );\n  assert( pIter->bRev==0 || pIter->bRev==1 );\n\n  if( iOut>=(pIter->nSeg/2) ){\n    i1 = (iOut - pIter->nSeg/2) * 2;\n    i2 = i1 + 1;\n  }else{\n    i1 = pIter->aFirst[iOut*2].iFirst;\n    i2 = pIter->aFirst[iOut*2+1].iFirst;\n  }\n  p1 = &pIter->aSeg[i1];\n  p2 = &pIter->aSeg[i2];\n\n  pRes->bTermEq = 0;\n  if( p1->pLeaf==0 ){           /* If p1 is at EOF */\n    iRes = i2;\n  }else if( p2->pLeaf==0 ){     /* If p2 is at EOF */\n    iRes = i1;\n  }else{\n    int res = fts5BufferCompare(&p1->term, &p2->term);\n    if( res==0 ){\n      assert( i2>i1 );\n      assert( i2!=0 );\n      pRes->bTermEq = 1;\n      if( p1->iRowid==p2->iRowid ){\n        p1->bDel = p2->bDel;\n        return i2;\n      }\n      res = ((p1->iRowid > p2->iRowid)==pIter->bRev) ? -1 : +1;\n    }\n    assert( res!=0 );\n    if( res<0 ){\n      iRes = i1;\n    }else{\n      iRes = i2;\n    }\n  }\n\n  pRes->iFirst = (u16)iRes;\n  return 0;\n}\n\n/*\n** Move the seg-iter so that it points to the first rowid on page iLeafPgno.\n** It is an error if leaf iLeafPgno does not exist or contains no rowids.\n*/\nstatic void fts5SegIterGotoPage(\n  Fts5Index *p,                   /* FTS5 backend object */\n  Fts5SegIter *pIter,             /* Iterator to advance */\n  int iLeafPgno\n){\n  assert( iLeafPgno>pIter->iLeafPgno );\n\n  if( iLeafPgno>pIter->pSeg->pgnoLast ){\n    p->rc = FTS5_CORRUPT;\n  }else{\n    fts5DataRelease(pIter->pNextLeaf);\n    pIter->pNextLeaf = 0;\n    pIter->iLeafPgno = iLeafPgno-1;\n    fts5SegIterNextPage(p, pIter);\n    assert( p->rc!=SQLITE_OK || pIter->iLeafPgno==iLeafPgno );\n\n    if( p->rc==SQLITE_OK ){\n      int iOff;\n      u8 *a = pIter->pLeaf->p;\n      int n = pIter->pLeaf->szLeaf;\n\n      iOff = fts5LeafFirstRowidOff(pIter->pLeaf);\n      if( iOff<4 || iOff>=n ){\n        p->rc = FTS5_CORRUPT;\n      }else{\n        iOff += fts5GetVarint(&a[iOff], (u64*)&pIter->iRowid);\n        pIter->iLeafOffset = iOff;\n        fts5SegIterLoadNPos(p, pIter);\n      }\n    }\n  }\n}\n\n/*\n** Advance the iterator passed as the second argument until it is at or \n** past rowid iFrom. Regardless of the value of iFrom, the iterator is\n** always advanced at least once.\n*/\nstatic void fts5SegIterNextFrom(\n  Fts5Index *p,                   /* FTS5 backend object */\n  Fts5SegIter *pIter,             /* Iterator to advance */\n  i64 iMatch                      /* Advance iterator at least this far */\n){\n  int bRev = (pIter->flags & FTS5_SEGITER_REVERSE);\n  Fts5DlidxIter *pDlidx = pIter->pDlidx;\n  int iLeafPgno = pIter->iLeafPgno;\n  int bMove = 1;\n\n  assert( pIter->flags & FTS5_SEGITER_ONETERM );\n  assert( pIter->pDlidx );\n  assert( pIter->pLeaf );\n\n  if( bRev==0 ){\n    while( !fts5DlidxIterEof(p, pDlidx) && iMatch>fts5DlidxIterRowid(pDlidx) ){\n      iLeafPgno = fts5DlidxIterPgno(pDlidx);\n      fts5DlidxIterNext(p, pDlidx);\n    }\n    assert_nc( iLeafPgno>=pIter->iLeafPgno || p->rc );\n    if( iLeafPgno>pIter->iLeafPgno ){\n      fts5SegIterGotoPage(p, pIter, iLeafPgno);\n      bMove = 0;\n    }\n  }else{\n    assert( pIter->pNextLeaf==0 );\n    assert( iMatch<pIter->iRowid );\n    while( !fts5DlidxIterEof(p, pDlidx) && iMatch<fts5DlidxIterRowid(pDlidx) ){\n      fts5DlidxIterPrev(p, pDlidx);\n    }\n    iLeafPgno = fts5DlidxIterPgno(pDlidx);\n\n    assert( fts5DlidxIterEof(p, pDlidx) || iLeafPgno<=pIter->iLeafPgno );\n\n    if( iLeafPgno<pIter->iLeafPgno ){\n      pIter->iLeafPgno = iLeafPgno+1;\n      fts5SegIterReverseNewPage(p, pIter);\n      bMove = 0;\n    }\n  }\n\n  do{\n    if( bMove && p->rc==SQLITE_OK ) pIter->xNext(p, pIter, 0);\n    if( pIter->pLeaf==0 ) break;\n    if( bRev==0 && pIter->iRowid>=iMatch ) break;\n    if( bRev!=0 && pIter->iRowid<=iMatch ) break;\n    bMove = 1;\n  }while( p->rc==SQLITE_OK );\n}\n\n\n/*\n** Free the iterator object passed as the second argument.\n*/\nstatic void fts5MultiIterFree(Fts5Iter *pIter){\n  if( pIter ){\n    int i;\n    for(i=0; i<pIter->nSeg; i++){\n      fts5SegIterClear(&pIter->aSeg[i]);\n    }\n    fts5BufferFree(&pIter->poslist);\n    sqlite3_free(pIter);\n  }\n}\n\nstatic void fts5MultiIterAdvanced(\n  Fts5Index *p,                   /* FTS5 backend to iterate within */\n  Fts5Iter *pIter,                /* Iterator to update aFirst[] array for */\n  int iChanged,                   /* Index of sub-iterator just advanced */\n  int iMinset                     /* Minimum entry in aFirst[] to set */\n){\n  int i;\n  for(i=(pIter->nSeg+iChanged)/2; i>=iMinset && p->rc==SQLITE_OK; i=i/2){\n    int iEq;\n    if( (iEq = fts5MultiIterDoCompare(pIter, i)) ){\n      Fts5SegIter *pSeg = &pIter->aSeg[iEq];\n      assert( p->rc==SQLITE_OK );\n      pSeg->xNext(p, pSeg, 0);\n      i = pIter->nSeg + iEq;\n    }\n  }\n}\n\n/*\n** Sub-iterator iChanged of iterator pIter has just been advanced. It still\n** points to the same term though - just a different rowid. This function\n** attempts to update the contents of the pIter->aFirst[] accordingly.\n** If it does so successfully, 0 is returned. Otherwise 1.\n**\n** If non-zero is returned, the caller should call fts5MultiIterAdvanced()\n** on the iterator instead. That function does the same as this one, except\n** that it deals with more complicated cases as well.\n*/ \nstatic int fts5MultiIterAdvanceRowid(\n  Fts5Iter *pIter,                /* Iterator to update aFirst[] array for */\n  int iChanged,                   /* Index of sub-iterator just advanced */\n  Fts5SegIter **ppFirst\n){\n  Fts5SegIter *pNew = &pIter->aSeg[iChanged];\n\n  if( pNew->iRowid==pIter->iSwitchRowid\n   || (pNew->iRowid<pIter->iSwitchRowid)==pIter->bRev\n  ){\n    int i;\n    Fts5SegIter *pOther = &pIter->aSeg[iChanged ^ 0x0001];\n    pIter->iSwitchRowid = pIter->bRev ? SMALLEST_INT64 : LARGEST_INT64;\n    for(i=(pIter->nSeg+iChanged)/2; 1; i=i/2){\n      Fts5CResult *pRes = &pIter->aFirst[i];\n\n      assert( pNew->pLeaf );\n      assert( pRes->bTermEq==0 || pOther->pLeaf );\n\n      if( pRes->bTermEq ){\n        if( pNew->iRowid==pOther->iRowid ){\n          return 1;\n        }else if( (pOther->iRowid>pNew->iRowid)==pIter->bRev ){\n          pIter->iSwitchRowid = pOther->iRowid;\n          pNew = pOther;\n        }else if( (pOther->iRowid>pIter->iSwitchRowid)==pIter->bRev ){\n          pIter->iSwitchRowid = pOther->iRowid;\n        }\n      }\n      pRes->iFirst = (u16)(pNew - pIter->aSeg);\n      if( i==1 ) break;\n\n      pOther = &pIter->aSeg[ pIter->aFirst[i ^ 0x0001].iFirst ];\n    }\n  }\n\n  *ppFirst = pNew;\n  return 0;\n}\n\n/*\n** Set the pIter->bEof variable based on the state of the sub-iterators.\n*/\nstatic void fts5MultiIterSetEof(Fts5Iter *pIter){\n  Fts5SegIter *pSeg = &pIter->aSeg[ pIter->aFirst[1].iFirst ];\n  pIter->base.bEof = pSeg->pLeaf==0;\n  pIter->iSwitchRowid = pSeg->iRowid;\n}\n\n/*\n** Move the iterator to the next entry. \n**\n** If an error occurs, an error code is left in Fts5Index.rc. It is not \n** considered an error if the iterator reaches EOF, or if it is already at \n** EOF when this function is called.\n*/\nstatic void fts5MultiIterNext(\n  Fts5Index *p, \n  Fts5Iter *pIter,\n  int bFrom,                      /* True if argument iFrom is valid */\n  i64 iFrom                       /* Advance at least as far as this */\n){\n  int bUseFrom = bFrom;\n  assert( pIter->base.bEof==0 );\n  while( p->rc==SQLITE_OK ){\n    int iFirst = pIter->aFirst[1].iFirst;\n    int bNewTerm = 0;\n    Fts5SegIter *pSeg = &pIter->aSeg[iFirst];\n    assert( p->rc==SQLITE_OK );\n    if( bUseFrom && pSeg->pDlidx ){\n      fts5SegIterNextFrom(p, pSeg, iFrom);\n    }else{\n      pSeg->xNext(p, pSeg, &bNewTerm);\n    }\n\n    if( pSeg->pLeaf==0 || bNewTerm \n     || fts5MultiIterAdvanceRowid(pIter, iFirst, &pSeg)\n    ){\n      fts5MultiIterAdvanced(p, pIter, iFirst, 1);\n      fts5MultiIterSetEof(pIter);\n      pSeg = &pIter->aSeg[pIter->aFirst[1].iFirst];\n      if( pSeg->pLeaf==0 ) return;\n    }\n\n    fts5AssertMultiIterSetup(p, pIter);\n    assert( pSeg==&pIter->aSeg[pIter->aFirst[1].iFirst] && pSeg->pLeaf );\n    if( pIter->bSkipEmpty==0 || pSeg->nPos ){\n      pIter->xSetOutputs(pIter, pSeg);\n      return;\n    }\n    bUseFrom = 0;\n  }\n}\n\nstatic void fts5MultiIterNext2(\n  Fts5Index *p, \n  Fts5Iter *pIter,\n  int *pbNewTerm                  /* OUT: True if *might* be new term */\n){\n  assert( pIter->bSkipEmpty );\n  if( p->rc==SQLITE_OK ){\n    *pbNewTerm = 0;\n    do{\n      int iFirst = pIter->aFirst[1].iFirst;\n      Fts5SegIter *pSeg = &pIter->aSeg[iFirst];\n      int bNewTerm = 0;\n\n      assert( p->rc==SQLITE_OK );\n      pSeg->xNext(p, pSeg, &bNewTerm);\n      if( pSeg->pLeaf==0 || bNewTerm \n       || fts5MultiIterAdvanceRowid(pIter, iFirst, &pSeg)\n      ){\n        fts5MultiIterAdvanced(p, pIter, iFirst, 1);\n        fts5MultiIterSetEof(pIter);\n        *pbNewTerm = 1;\n      }\n      fts5AssertMultiIterSetup(p, pIter);\n\n    }while( fts5MultiIterIsEmpty(p, pIter) );\n  }\n}\n\nstatic void fts5IterSetOutputs_Noop(Fts5Iter *pUnused1, Fts5SegIter *pUnused2){\n  UNUSED_PARAM2(pUnused1, pUnused2);\n}\n\nstatic Fts5Iter *fts5MultiIterAlloc(\n  Fts5Index *p,                   /* FTS5 backend to iterate within */\n  int nSeg\n){\n  Fts5Iter *pNew;\n  int nSlot;                      /* Power of two >= nSeg */\n\n  for(nSlot=2; nSlot<nSeg; nSlot=nSlot*2);\n  pNew = fts5IdxMalloc(p, \n      sizeof(Fts5Iter) +                  /* pNew */\n      sizeof(Fts5SegIter) * (nSlot-1) +   /* pNew->aSeg[] */\n      sizeof(Fts5CResult) * nSlot         /* pNew->aFirst[] */\n  );\n  if( pNew ){\n    pNew->nSeg = nSlot;\n    pNew->aFirst = (Fts5CResult*)&pNew->aSeg[nSlot];\n    pNew->pIndex = p;\n    pNew->xSetOutputs = fts5IterSetOutputs_Noop;\n  }\n  return pNew;\n}\n\nstatic void fts5PoslistCallback(\n  Fts5Index *pUnused, \n  void *pContext, \n  const u8 *pChunk, int nChunk\n){\n  UNUSED_PARAM(pUnused);\n  assert_nc( nChunk>=0 );\n  if( nChunk>0 ){\n    fts5BufferSafeAppendBlob((Fts5Buffer*)pContext, pChunk, nChunk);\n  }\n}\n\ntypedef struct PoslistCallbackCtx PoslistCallbackCtx;\nstruct PoslistCallbackCtx {\n  Fts5Buffer *pBuf;               /* Append to this buffer */\n  Fts5Colset *pColset;            /* Restrict matches to this column */\n  int eState;                     /* See above */\n};\n\ntypedef struct PoslistOffsetsCtx PoslistOffsetsCtx;\nstruct PoslistOffsetsCtx {\n  Fts5Buffer *pBuf;               /* Append to this buffer */\n  Fts5Colset *pColset;            /* Restrict matches to this column */\n  int iRead;\n  int iWrite;\n};\n\n/*\n** TODO: Make this more efficient!\n*/\nstatic int fts5IndexColsetTest(Fts5Colset *pColset, int iCol){\n  int i;\n  for(i=0; i<pColset->nCol; i++){\n    if( pColset->aiCol[i]==iCol ) return 1;\n  }\n  return 0;\n}\n\nstatic void fts5PoslistOffsetsCallback(\n  Fts5Index *pUnused, \n  void *pContext, \n  const u8 *pChunk, int nChunk\n){\n  PoslistOffsetsCtx *pCtx = (PoslistOffsetsCtx*)pContext;\n  UNUSED_PARAM(pUnused);\n  assert_nc( nChunk>=0 );\n  if( nChunk>0 ){\n    int i = 0;\n    while( i<nChunk ){\n      int iVal;\n      i += fts5GetVarint32(&pChunk[i], iVal);\n      iVal += pCtx->iRead - 2;\n      pCtx->iRead = iVal;\n      if( fts5IndexColsetTest(pCtx->pColset, iVal) ){\n        fts5BufferSafeAppendVarint(pCtx->pBuf, iVal + 2 - pCtx->iWrite);\n        pCtx->iWrite = iVal;\n      }\n    }\n  }\n}\n\nstatic void fts5PoslistFilterCallback(\n  Fts5Index *pUnused,\n  void *pContext, \n  const u8 *pChunk, int nChunk\n){\n  PoslistCallbackCtx *pCtx = (PoslistCallbackCtx*)pContext;\n  UNUSED_PARAM(pUnused);\n  assert_nc( nChunk>=0 );\n  if( nChunk>0 ){\n    /* Search through to find the first varint with value 1. This is the\n    ** start of the next columns hits. */\n    int i = 0;\n    int iStart = 0;\n\n    if( pCtx->eState==2 ){\n      int iCol;\n      fts5FastGetVarint32(pChunk, i, iCol);\n      if( fts5IndexColsetTest(pCtx->pColset, iCol) ){\n        pCtx->eState = 1;\n        fts5BufferSafeAppendVarint(pCtx->pBuf, 1);\n      }else{\n        pCtx->eState = 0;\n      }\n    }\n\n    do {\n      while( i<nChunk && pChunk[i]!=0x01 ){\n        while( pChunk[i] & 0x80 ) i++;\n        i++;\n      }\n      if( pCtx->eState ){\n        fts5BufferSafeAppendBlob(pCtx->pBuf, &pChunk[iStart], i-iStart);\n      }\n      if( i<nChunk ){\n        int iCol;\n        iStart = i;\n        i++;\n        if( i>=nChunk ){\n          pCtx->eState = 2;\n        }else{\n          fts5FastGetVarint32(pChunk, i, iCol);\n          pCtx->eState = fts5IndexColsetTest(pCtx->pColset, iCol);\n          if( pCtx->eState ){\n            fts5BufferSafeAppendBlob(pCtx->pBuf, &pChunk[iStart], i-iStart);\n            iStart = i;\n          }\n        }\n      }\n    }while( i<nChunk );\n  }\n}\n\nstatic void fts5ChunkIterate(\n  Fts5Index *p,                   /* Index object */\n  Fts5SegIter *pSeg,              /* Poslist of this iterator */\n  void *pCtx,                     /* Context pointer for xChunk callback */\n  void (*xChunk)(Fts5Index*, void*, const u8*, int)\n){\n  int nRem = pSeg->nPos;          /* Number of bytes still to come */\n  Fts5Data *pData = 0;\n  u8 *pChunk = &pSeg->pLeaf->p[pSeg->iLeafOffset];\n  int nChunk = MIN(nRem, pSeg->pLeaf->szLeaf - pSeg->iLeafOffset);\n  int pgno = pSeg->iLeafPgno;\n  int pgnoSave = 0;\n\n  /* This function does notmwork with detail=none databases. */\n  assert( p->pConfig->eDetail!=FTS5_DETAIL_NONE );\n\n  if( (pSeg->flags & FTS5_SEGITER_REVERSE)==0 ){\n    pgnoSave = pgno+1;\n  }\n\n  while( 1 ){\n    xChunk(p, pCtx, pChunk, nChunk);\n    nRem -= nChunk;\n    fts5DataRelease(pData);\n    if( nRem<=0 ){\n      break;\n    }else{\n      pgno++;\n      pData = fts5LeafRead(p, FTS5_SEGMENT_ROWID(pSeg->pSeg->iSegid, pgno));\n      if( pData==0 ) break;\n      pChunk = &pData->p[4];\n      nChunk = MIN(nRem, pData->szLeaf - 4);\n      if( pgno==pgnoSave ){\n        assert( pSeg->pNextLeaf==0 );\n        pSeg->pNextLeaf = pData;\n        pData = 0;\n      }\n    }\n  }\n}\n\n/*\n** Iterator pIter currently points to a valid entry (not EOF). This\n** function appends the position list data for the current entry to\n** buffer pBuf. It does not make a copy of the position-list size\n** field.\n*/\nstatic void fts5SegiterPoslist(\n  Fts5Index *p,\n  Fts5SegIter *pSeg,\n  Fts5Colset *pColset,\n  Fts5Buffer *pBuf\n){\n  if( 0==fts5BufferGrow(&p->rc, pBuf, pSeg->nPos+FTS5_DATA_ZERO_PADDING) ){\n    memset(&pBuf->p[pBuf->n+pSeg->nPos], 0, FTS5_DATA_ZERO_PADDING);\n    if( pColset==0 ){\n      fts5ChunkIterate(p, pSeg, (void*)pBuf, fts5PoslistCallback);\n    }else{\n      if( p->pConfig->eDetail==FTS5_DETAIL_FULL ){\n        PoslistCallbackCtx sCtx;\n        sCtx.pBuf = pBuf;\n        sCtx.pColset = pColset;\n        sCtx.eState = fts5IndexColsetTest(pColset, 0);\n        assert( sCtx.eState==0 || sCtx.eState==1 );\n        fts5ChunkIterate(p, pSeg, (void*)&sCtx, fts5PoslistFilterCallback);\n      }else{\n        PoslistOffsetsCtx sCtx;\n        memset(&sCtx, 0, sizeof(sCtx));\n        sCtx.pBuf = pBuf;\n        sCtx.pColset = pColset;\n        fts5ChunkIterate(p, pSeg, (void*)&sCtx, fts5PoslistOffsetsCallback);\n      }\n    }\n  }\n}\n\n/*\n** IN/OUT parameter (*pa) points to a position list n bytes in size. If\n** the position list contains entries for column iCol, then (*pa) is set\n** to point to the sub-position-list for that column and the number of\n** bytes in it returned. Or, if the argument position list does not\n** contain any entries for column iCol, return 0.\n*/\nstatic int fts5IndexExtractCol(\n  const u8 **pa,                  /* IN/OUT: Pointer to poslist */\n  int n,                          /* IN: Size of poslist in bytes */\n  int iCol                        /* Column to extract from poslist */\n){\n  int iCurrent = 0;               /* Anything before the first 0x01 is col 0 */\n  const u8 *p = *pa;\n  const u8 *pEnd = &p[n];         /* One byte past end of position list */\n\n  while( iCol>iCurrent ){\n    /* Advance pointer p until it points to pEnd or an 0x01 byte that is\n    ** not part of a varint. Note that it is not possible for a negative\n    ** or extremely large varint to occur within an uncorrupted position \n    ** list. So the last byte of each varint may be assumed to have a clear\n    ** 0x80 bit.  */\n    while( *p!=0x01 ){\n      while( *p++ & 0x80 );\n      if( p>=pEnd ) return 0;\n    }\n    *pa = p++;\n    iCurrent = *p++;\n    if( iCurrent & 0x80 ){\n      p--;\n      p += fts5GetVarint32(p, iCurrent);\n    }\n  }\n  if( iCol!=iCurrent ) return 0;\n\n  /* Advance pointer p until it points to pEnd or an 0x01 byte that is\n  ** not part of a varint */\n  while( p<pEnd && *p!=0x01 ){\n    while( *p++ & 0x80 );\n  }\n\n  return p - (*pa);\n}\n\nstatic void fts5IndexExtractColset(\n  int *pRc,\n  Fts5Colset *pColset,            /* Colset to filter on */\n  const u8 *pPos, int nPos,       /* Position list */\n  Fts5Buffer *pBuf                /* Output buffer */\n){\n  if( *pRc==SQLITE_OK ){\n    int i;\n    fts5BufferZero(pBuf);\n    for(i=0; i<pColset->nCol; i++){\n      const u8 *pSub = pPos;\n      int nSub = fts5IndexExtractCol(&pSub, nPos, pColset->aiCol[i]);\n      if( nSub ){\n        fts5BufferAppendBlob(pRc, pBuf, nSub, pSub);\n      }\n    }\n  }\n}\n\n/*\n** xSetOutputs callback used by detail=none tables.\n*/\nstatic void fts5IterSetOutputs_None(Fts5Iter *pIter, Fts5SegIter *pSeg){\n  assert( pIter->pIndex->pConfig->eDetail==FTS5_DETAIL_NONE );\n  pIter->base.iRowid = pSeg->iRowid;\n  pIter->base.nData = pSeg->nPos;\n}\n\n/*\n** xSetOutputs callback used by detail=full and detail=col tables when no\n** column filters are specified.\n*/\nstatic void fts5IterSetOutputs_Nocolset(Fts5Iter *pIter, Fts5SegIter *pSeg){\n  pIter->base.iRowid = pSeg->iRowid;\n  pIter->base.nData = pSeg->nPos;\n\n  assert( pIter->pIndex->pConfig->eDetail!=FTS5_DETAIL_NONE );\n  assert( pIter->pColset==0 );\n\n  if( pSeg->iLeafOffset+pSeg->nPos<=pSeg->pLeaf->szLeaf ){\n    /* All data is stored on the current page. Populate the output \n    ** variables to point into the body of the page object. */\n    pIter->base.pData = &pSeg->pLeaf->p[pSeg->iLeafOffset];\n  }else{\n    /* The data is distributed over two or more pages. Copy it into the\n    ** Fts5Iter.poslist buffer and then set the output pointer to point\n    ** to this buffer.  */\n    fts5BufferZero(&pIter->poslist);\n    fts5SegiterPoslist(pIter->pIndex, pSeg, 0, &pIter->poslist);\n    pIter->base.pData = pIter->poslist.p;\n  }\n}\n\n/*\n** xSetOutputs callback used when the Fts5Colset object has nCol==0 (match\n** against no columns at all).\n*/\nstatic void fts5IterSetOutputs_ZeroColset(Fts5Iter *pIter, Fts5SegIter *pSeg){\n  UNUSED_PARAM(pSeg);\n  pIter->base.nData = 0;\n}\n\n/*\n** xSetOutputs callback used by detail=col when there is a column filter\n** and there are 100 or more columns. Also called as a fallback from\n** fts5IterSetOutputs_Col100 if the column-list spans more than one page.\n*/\nstatic void fts5IterSetOutputs_Col(Fts5Iter *pIter, Fts5SegIter *pSeg){\n  fts5BufferZero(&pIter->poslist);\n  fts5SegiterPoslist(pIter->pIndex, pSeg, pIter->pColset, &pIter->poslist);\n  pIter->base.iRowid = pSeg->iRowid;\n  pIter->base.pData = pIter->poslist.p;\n  pIter->base.nData = pIter->poslist.n;\n}\n\n/*\n** xSetOutputs callback used when: \n**\n**   * detail=col,\n**   * there is a column filter, and\n**   * the table contains 100 or fewer columns. \n**\n** The last point is to ensure all column numbers are stored as \n** single-byte varints.\n*/\nstatic void fts5IterSetOutputs_Col100(Fts5Iter *pIter, Fts5SegIter *pSeg){\n\n  assert( pIter->pIndex->pConfig->eDetail==FTS5_DETAIL_COLUMNS );\n  assert( pIter->pColset );\n\n  if( pSeg->iLeafOffset+pSeg->nPos>pSeg->pLeaf->szLeaf ){\n    fts5IterSetOutputs_Col(pIter, pSeg);\n  }else{\n    u8 *a = (u8*)&pSeg->pLeaf->p[pSeg->iLeafOffset];\n    u8 *pEnd = (u8*)&a[pSeg->nPos]; \n    int iPrev = 0;\n    int *aiCol = pIter->pColset->aiCol;\n    int *aiColEnd = &aiCol[pIter->pColset->nCol];\n\n    u8 *aOut = pIter->poslist.p;\n    int iPrevOut = 0;\n\n    pIter->base.iRowid = pSeg->iRowid;\n\n    while( a<pEnd ){\n      iPrev += (int)a++[0] - 2;\n      while( *aiCol<iPrev ){\n        aiCol++;\n        if( aiCol==aiColEnd ) goto setoutputs_col_out;\n      }\n      if( *aiCol==iPrev ){\n        *aOut++ = (u8)((iPrev - iPrevOut) + 2);\n        iPrevOut = iPrev;\n      }\n    }\n\nsetoutputs_col_out:\n    pIter->base.pData = pIter->poslist.p;\n    pIter->base.nData = aOut - pIter->poslist.p;\n  }\n}\n\n/*\n** xSetOutputs callback used by detail=full when there is a column filter.\n*/\nstatic void fts5IterSetOutputs_Full(Fts5Iter *pIter, Fts5SegIter *pSeg){\n  Fts5Colset *pColset = pIter->pColset;\n  pIter->base.iRowid = pSeg->iRowid;\n\n  assert( pIter->pIndex->pConfig->eDetail==FTS5_DETAIL_FULL );\n  assert( pColset );\n\n  if( pSeg->iLeafOffset+pSeg->nPos<=pSeg->pLeaf->szLeaf ){\n    /* All data is stored on the current page. Populate the output \n    ** variables to point into the body of the page object. */\n    const u8 *a = &pSeg->pLeaf->p[pSeg->iLeafOffset];\n    if( pColset->nCol==1 ){\n      pIter->base.nData = fts5IndexExtractCol(&a, pSeg->nPos,pColset->aiCol[0]);\n      pIter->base.pData = a;\n    }else{\n      int *pRc = &pIter->pIndex->rc;\n      fts5BufferZero(&pIter->poslist);\n      fts5IndexExtractColset(pRc, pColset, a, pSeg->nPos, &pIter->poslist);\n      pIter->base.pData = pIter->poslist.p;\n      pIter->base.nData = pIter->poslist.n;\n    }\n  }else{\n    /* The data is distributed over two or more pages. Copy it into the\n    ** Fts5Iter.poslist buffer and then set the output pointer to point\n    ** to this buffer.  */\n    fts5BufferZero(&pIter->poslist);\n    fts5SegiterPoslist(pIter->pIndex, pSeg, pColset, &pIter->poslist);\n    pIter->base.pData = pIter->poslist.p;\n    pIter->base.nData = pIter->poslist.n;\n  }\n}\n\nstatic void fts5IterSetOutputCb(int *pRc, Fts5Iter *pIter){\n  if( *pRc==SQLITE_OK ){\n    Fts5Config *pConfig = pIter->pIndex->pConfig;\n    if( pConfig->eDetail==FTS5_DETAIL_NONE ){\n      pIter->xSetOutputs = fts5IterSetOutputs_None;\n    }\n\n    else if( pIter->pColset==0 ){\n      pIter->xSetOutputs = fts5IterSetOutputs_Nocolset;\n    }\n\n    else if( pIter->pColset->nCol==0 ){\n      pIter->xSetOutputs = fts5IterSetOutputs_ZeroColset;\n    }\n\n    else if( pConfig->eDetail==FTS5_DETAIL_FULL ){\n      pIter->xSetOutputs = fts5IterSetOutputs_Full;\n    }\n\n    else{\n      assert( pConfig->eDetail==FTS5_DETAIL_COLUMNS );\n      if( pConfig->nCol<=100 ){\n        pIter->xSetOutputs = fts5IterSetOutputs_Col100;\n        sqlite3Fts5BufferSize(pRc, &pIter->poslist, pConfig->nCol);\n      }else{\n        pIter->xSetOutputs = fts5IterSetOutputs_Col;\n      }\n    }\n  }\n}\n\n\n/*\n** Allocate a new Fts5Iter object.\n**\n** The new object will be used to iterate through data in structure pStruct.\n** If iLevel is -ve, then all data in all segments is merged. Or, if iLevel\n** is zero or greater, data from the first nSegment segments on level iLevel\n** is merged.\n**\n** The iterator initially points to the first term/rowid entry in the \n** iterated data.\n*/\nstatic void fts5MultiIterNew(\n  Fts5Index *p,                   /* FTS5 backend to iterate within */\n  Fts5Structure *pStruct,         /* Structure of specific index */\n  int flags,                      /* FTS5INDEX_QUERY_XXX flags */\n  Fts5Colset *pColset,            /* Colset to filter on (or NULL) */\n  const u8 *pTerm, int nTerm,     /* Term to seek to (or NULL/0) */\n  int iLevel,                     /* Level to iterate (-1 for all) */\n  int nSegment,                   /* Number of segments to merge (iLevel>=0) */\n  Fts5Iter **ppOut                /* New object */\n){\n  int nSeg = 0;                   /* Number of segment-iters in use */\n  int iIter = 0;                  /* */\n  int iSeg;                       /* Used to iterate through segments */\n  Fts5StructureLevel *pLvl;\n  Fts5Iter *pNew;\n\n  assert( (pTerm==0 && nTerm==0) || iLevel<0 );\n\n  /* Allocate space for the new multi-seg-iterator. */\n  if( p->rc==SQLITE_OK ){\n    if( iLevel<0 ){\n      assert( pStruct->nSegment==fts5StructureCountSegments(pStruct) );\n      nSeg = pStruct->nSegment;\n      nSeg += (p->pHash ? 1 : 0);\n    }else{\n      nSeg = MIN(pStruct->aLevel[iLevel].nSeg, nSegment);\n    }\n  }\n  *ppOut = pNew = fts5MultiIterAlloc(p, nSeg);\n  if( pNew==0 ) return;\n  pNew->bRev = (0!=(flags & FTS5INDEX_QUERY_DESC));\n  pNew->bSkipEmpty = (0!=(flags & FTS5INDEX_QUERY_SKIPEMPTY));\n  pNew->pColset = pColset;\n  if( (flags & FTS5INDEX_QUERY_NOOUTPUT)==0 ){\n    fts5IterSetOutputCb(&p->rc, pNew);\n  }\n\n  /* Initialize each of the component segment iterators. */\n  if( p->rc==SQLITE_OK ){\n    if( iLevel<0 ){\n      Fts5StructureLevel *pEnd = &pStruct->aLevel[pStruct->nLevel];\n      if( p->pHash ){\n        /* Add a segment iterator for the current contents of the hash table. */\n        Fts5SegIter *pIter = &pNew->aSeg[iIter++];\n        fts5SegIterHashInit(p, pTerm, nTerm, flags, pIter);\n      }\n      for(pLvl=&pStruct->aLevel[0]; pLvl<pEnd; pLvl++){\n        for(iSeg=pLvl->nSeg-1; iSeg>=0; iSeg--){\n          Fts5StructureSegment *pSeg = &pLvl->aSeg[iSeg];\n          Fts5SegIter *pIter = &pNew->aSeg[iIter++];\n          if( pTerm==0 ){\n            fts5SegIterInit(p, pSeg, pIter);\n          }else{\n            fts5SegIterSeekInit(p, pTerm, nTerm, flags, pSeg, pIter);\n          }\n        }\n      }\n    }else{\n      pLvl = &pStruct->aLevel[iLevel];\n      for(iSeg=nSeg-1; iSeg>=0; iSeg--){\n        fts5SegIterInit(p, &pLvl->aSeg[iSeg], &pNew->aSeg[iIter++]);\n      }\n    }\n    assert( iIter==nSeg );\n  }\n\n  /* If the above was successful, each component iterators now points \n  ** to the first entry in its segment. In this case initialize the \n  ** aFirst[] array. Or, if an error has occurred, free the iterator\n  ** object and set the output variable to NULL.  */\n  if( p->rc==SQLITE_OK ){\n    for(iIter=pNew->nSeg-1; iIter>0; iIter--){\n      int iEq;\n      if( (iEq = fts5MultiIterDoCompare(pNew, iIter)) ){\n        Fts5SegIter *pSeg = &pNew->aSeg[iEq];\n        if( p->rc==SQLITE_OK ) pSeg->xNext(p, pSeg, 0);\n        fts5MultiIterAdvanced(p, pNew, iEq, iIter);\n      }\n    }\n    fts5MultiIterSetEof(pNew);\n    fts5AssertMultiIterSetup(p, pNew);\n\n    if( pNew->bSkipEmpty && fts5MultiIterIsEmpty(p, pNew) ){\n      fts5MultiIterNext(p, pNew, 0, 0);\n    }else if( pNew->base.bEof==0 ){\n      Fts5SegIter *pSeg = &pNew->aSeg[pNew->aFirst[1].iFirst];\n      pNew->xSetOutputs(pNew, pSeg);\n    }\n\n  }else{\n    fts5MultiIterFree(pNew);\n    *ppOut = 0;\n  }\n}\n\n/*\n** Create an Fts5Iter that iterates through the doclist provided\n** as the second argument.\n*/\nstatic void fts5MultiIterNew2(\n  Fts5Index *p,                   /* FTS5 backend to iterate within */\n  Fts5Data *pData,                /* Doclist to iterate through */\n  int bDesc,                      /* True for descending rowid order */\n  Fts5Iter **ppOut                /* New object */\n){\n  Fts5Iter *pNew;\n  pNew = fts5MultiIterAlloc(p, 2);\n  if( pNew ){\n    Fts5SegIter *pIter = &pNew->aSeg[1];\n\n    pIter->flags = FTS5_SEGITER_ONETERM;\n    if( pData->szLeaf>0 ){\n      pIter->pLeaf = pData;\n      pIter->iLeafOffset = fts5GetVarint(pData->p, (u64*)&pIter->iRowid);\n      pIter->iEndofDoclist = pData->nn;\n      pNew->aFirst[1].iFirst = 1;\n      if( bDesc ){\n        pNew->bRev = 1;\n        pIter->flags |= FTS5_SEGITER_REVERSE;\n        fts5SegIterReverseInitPage(p, pIter);\n      }else{\n        fts5SegIterLoadNPos(p, pIter);\n      }\n      pData = 0;\n    }else{\n      pNew->base.bEof = 1;\n    }\n    fts5SegIterSetNext(p, pIter);\n\n    *ppOut = pNew;\n  }\n\n  fts5DataRelease(pData);\n}\n\n/*\n** Return true if the iterator is at EOF or if an error has occurred. \n** False otherwise.\n*/\nstatic int fts5MultiIterEof(Fts5Index *p, Fts5Iter *pIter){\n  assert( p->rc \n      || (pIter->aSeg[ pIter->aFirst[1].iFirst ].pLeaf==0)==pIter->base.bEof \n  );\n  return (p->rc || pIter->base.bEof);\n}\n\n/*\n** Return the rowid of the entry that the iterator currently points\n** to. If the iterator points to EOF when this function is called the\n** results are undefined.\n*/\nstatic i64 fts5MultiIterRowid(Fts5Iter *pIter){\n  assert( pIter->aSeg[ pIter->aFirst[1].iFirst ].pLeaf );\n  return pIter->aSeg[ pIter->aFirst[1].iFirst ].iRowid;\n}\n\n/*\n** Move the iterator to the next entry at or following iMatch.\n*/\nstatic void fts5MultiIterNextFrom(\n  Fts5Index *p, \n  Fts5Iter *pIter, \n  i64 iMatch\n){\n  while( 1 ){\n    i64 iRowid;\n    fts5MultiIterNext(p, pIter, 1, iMatch);\n    if( fts5MultiIterEof(p, pIter) ) break;\n    iRowid = fts5MultiIterRowid(pIter);\n    if( pIter->bRev==0 && iRowid>=iMatch ) break;\n    if( pIter->bRev!=0 && iRowid<=iMatch ) break;\n  }\n}\n\n/*\n** Return a pointer to a buffer containing the term associated with the \n** entry that the iterator currently points to.\n*/\nstatic const u8 *fts5MultiIterTerm(Fts5Iter *pIter, int *pn){\n  Fts5SegIter *p = &pIter->aSeg[ pIter->aFirst[1].iFirst ];\n  *pn = p->term.n;\n  return p->term.p;\n}\n\n/*\n** Allocate a new segment-id for the structure pStruct. The new segment\n** id must be between 1 and 65335 inclusive, and must not be used by \n** any currently existing segment. If a free segment id cannot be found,\n** SQLITE_FULL is returned.\n**\n** If an error has already occurred, this function is a no-op. 0 is \n** returned in this case.\n*/\nstatic int fts5AllocateSegid(Fts5Index *p, Fts5Structure *pStruct){\n  int iSegid = 0;\n\n  if( p->rc==SQLITE_OK ){\n    if( pStruct->nSegment>=FTS5_MAX_SEGMENT ){\n      p->rc = SQLITE_FULL;\n    }else{\n      /* FTS5_MAX_SEGMENT is currently defined as 2000. So the following\n      ** array is 63 elements, or 252 bytes, in size.  */\n      u32 aUsed[(FTS5_MAX_SEGMENT+31) / 32];\n      int iLvl, iSeg;\n      int i;\n      u32 mask;\n      memset(aUsed, 0, sizeof(aUsed));\n      for(iLvl=0; iLvl<pStruct->nLevel; iLvl++){\n        for(iSeg=0; iSeg<pStruct->aLevel[iLvl].nSeg; iSeg++){\n          int iId = pStruct->aLevel[iLvl].aSeg[iSeg].iSegid;\n          if( iId<=FTS5_MAX_SEGMENT && iId>0 ){\n            aUsed[(iId-1) / 32] |= (u32)1 << ((iId-1) % 32);\n          }\n        }\n      }\n\n      for(i=0; aUsed[i]==0xFFFFFFFF; i++);\n      mask = aUsed[i];\n      for(iSegid=0; mask & ((u32)1 << iSegid); iSegid++);\n      iSegid += 1 + i*32;\n\n#ifdef SQLITE_DEBUG\n      for(iLvl=0; iLvl<pStruct->nLevel; iLvl++){\n        for(iSeg=0; iSeg<pStruct->aLevel[iLvl].nSeg; iSeg++){\n          assert_nc( iSegid!=pStruct->aLevel[iLvl].aSeg[iSeg].iSegid );\n        }\n      }\n      assert_nc( iSegid>0 && iSegid<=FTS5_MAX_SEGMENT );\n\n      {\n        sqlite3_stmt *pIdxSelect = fts5IdxSelectStmt(p);\n        if( p->rc==SQLITE_OK ){\n          u8 aBlob[2] = {0xff, 0xff};\n          sqlite3_bind_int(pIdxSelect, 1, iSegid);\n          sqlite3_bind_blob(pIdxSelect, 2, aBlob, 2, SQLITE_STATIC);\n          assert_nc( sqlite3_step(pIdxSelect)!=SQLITE_ROW );\n          p->rc = sqlite3_reset(pIdxSelect);\n          sqlite3_bind_null(pIdxSelect, 2);\n        }\n      }\n#endif\n    }\n  }\n\n  return iSegid;\n}\n\n/*\n** Discard all data currently cached in the hash-tables.\n*/\nstatic void fts5IndexDiscardData(Fts5Index *p){\n  assert( p->pHash || p->nPendingData==0 );\n  if( p->pHash ){\n    sqlite3Fts5HashClear(p->pHash);\n    p->nPendingData = 0;\n  }\n}\n\n/*\n** Return the size of the prefix, in bytes, that buffer \n** (pNew/<length-unknown>) shares with buffer (pOld/nOld).\n**\n** Buffer (pNew/<length-unknown>) is guaranteed to be greater \n** than buffer (pOld/nOld).\n*/\nstatic int fts5PrefixCompress(int nOld, const u8 *pOld, const u8 *pNew){\n  int i;\n  for(i=0; i<nOld; i++){\n    if( pOld[i]!=pNew[i] ) break;\n  }\n  return i;\n}\n\nstatic void fts5WriteDlidxClear(\n  Fts5Index *p, \n  Fts5SegWriter *pWriter,\n  int bFlush                      /* If true, write dlidx to disk */\n){\n  int i;\n  assert( bFlush==0 || (pWriter->nDlidx>0 && pWriter->aDlidx[0].buf.n>0) );\n  for(i=0; i<pWriter->nDlidx; i++){\n    Fts5DlidxWriter *pDlidx = &pWriter->aDlidx[i];\n    if( pDlidx->buf.n==0 ) break;\n    if( bFlush ){\n      assert( pDlidx->pgno!=0 );\n      fts5DataWrite(p, \n          FTS5_DLIDX_ROWID(pWriter->iSegid, i, pDlidx->pgno),\n          pDlidx->buf.p, pDlidx->buf.n\n      );\n    }\n    sqlite3Fts5BufferZero(&pDlidx->buf);\n    pDlidx->bPrevValid = 0;\n  }\n}\n\n/*\n** Grow the pWriter->aDlidx[] array to at least nLvl elements in size.\n** Any new array elements are zeroed before returning.\n*/\nstatic int fts5WriteDlidxGrow(\n  Fts5Index *p,\n  Fts5SegWriter *pWriter,\n  int nLvl\n){\n  if( p->rc==SQLITE_OK && nLvl>=pWriter->nDlidx ){\n    Fts5DlidxWriter *aDlidx = (Fts5DlidxWriter*)sqlite3_realloc64(\n        pWriter->aDlidx, sizeof(Fts5DlidxWriter) * nLvl\n    );\n    if( aDlidx==0 ){\n      p->rc = SQLITE_NOMEM;\n    }else{\n      int nByte = sizeof(Fts5DlidxWriter) * (nLvl - pWriter->nDlidx);\n      memset(&aDlidx[pWriter->nDlidx], 0, nByte);\n      pWriter->aDlidx = aDlidx;\n      pWriter->nDlidx = nLvl;\n    }\n  }\n  return p->rc;\n}\n\n/*\n** If the current doclist-index accumulating in pWriter->aDlidx[] is large\n** enough, flush it to disk and return 1. Otherwise discard it and return\n** zero.\n*/\nstatic int fts5WriteFlushDlidx(Fts5Index *p, Fts5SegWriter *pWriter){\n  int bFlag = 0;\n\n  /* If there were FTS5_MIN_DLIDX_SIZE or more empty leaf pages written\n  ** to the database, also write the doclist-index to disk.  */\n  if( pWriter->aDlidx[0].buf.n>0 && pWriter->nEmpty>=FTS5_MIN_DLIDX_SIZE ){\n    bFlag = 1;\n  }\n  fts5WriteDlidxClear(p, pWriter, bFlag);\n  pWriter->nEmpty = 0;\n  return bFlag;\n}\n\n/*\n** This function is called whenever processing of the doclist for the \n** last term on leaf page (pWriter->iBtPage) is completed. \n**\n** The doclist-index for that term is currently stored in-memory within the\n** Fts5SegWriter.aDlidx[] array. If it is large enough, this function\n** writes it out to disk. Or, if it is too small to bother with, discards\n** it.\n**\n** Fts5SegWriter.btterm currently contains the first term on page iBtPage.\n*/\nstatic void fts5WriteFlushBtree(Fts5Index *p, Fts5SegWriter *pWriter){\n  int bFlag;\n\n  assert( pWriter->iBtPage || pWriter->nEmpty==0 );\n  if( pWriter->iBtPage==0 ) return;\n  bFlag = fts5WriteFlushDlidx(p, pWriter);\n\n  if( p->rc==SQLITE_OK ){\n    const char *z = (pWriter->btterm.n>0?(const char*)pWriter->btterm.p:\"\");\n    /* The following was already done in fts5WriteInit(): */\n    /* sqlite3_bind_int(p->pIdxWriter, 1, pWriter->iSegid); */\n    sqlite3_bind_blob(p->pIdxWriter, 2, z, pWriter->btterm.n, SQLITE_STATIC);\n    sqlite3_bind_int64(p->pIdxWriter, 3, bFlag + ((i64)pWriter->iBtPage<<1));\n    sqlite3_step(p->pIdxWriter);\n    p->rc = sqlite3_reset(p->pIdxWriter);\n    sqlite3_bind_null(p->pIdxWriter, 2);\n  }\n  pWriter->iBtPage = 0;\n}\n\n/*\n** This is called once for each leaf page except the first that contains\n** at least one term. Argument (nTerm/pTerm) is the split-key - a term that\n** is larger than all terms written to earlier leaves, and equal to or\n** smaller than the first term on the new leaf.\n**\n** If an error occurs, an error code is left in Fts5Index.rc. If an error\n** has already occurred when this function is called, it is a no-op.\n*/\nstatic void fts5WriteBtreeTerm(\n  Fts5Index *p,                   /* FTS5 backend object */\n  Fts5SegWriter *pWriter,         /* Writer object */\n  int nTerm, const u8 *pTerm      /* First term on new page */\n){\n  fts5WriteFlushBtree(p, pWriter);\n  if( p->rc==SQLITE_OK ){\n    fts5BufferSet(&p->rc, &pWriter->btterm, nTerm, pTerm);\n    pWriter->iBtPage = pWriter->writer.pgno;\n  }\n}\n\n/*\n** This function is called when flushing a leaf page that contains no\n** terms at all to disk.\n*/\nstatic void fts5WriteBtreeNoTerm(\n  Fts5Index *p,                   /* FTS5 backend object */\n  Fts5SegWriter *pWriter          /* Writer object */\n){\n  /* If there were no rowids on the leaf page either and the doclist-index\n  ** has already been started, append an 0x00 byte to it.  */\n  if( pWriter->bFirstRowidInPage && pWriter->aDlidx[0].buf.n>0 ){\n    Fts5DlidxWriter *pDlidx = &pWriter->aDlidx[0];\n    assert( pDlidx->bPrevValid );\n    sqlite3Fts5BufferAppendVarint(&p->rc, &pDlidx->buf, 0);\n  }\n\n  /* Increment the \"number of sequential leaves without a term\" counter. */\n  pWriter->nEmpty++;\n}\n\nstatic i64 fts5DlidxExtractFirstRowid(Fts5Buffer *pBuf){\n  i64 iRowid;\n  int iOff;\n\n  iOff = 1 + fts5GetVarint(&pBuf->p[1], (u64*)&iRowid);\n  fts5GetVarint(&pBuf->p[iOff], (u64*)&iRowid);\n  return iRowid;\n}\n\n/*\n** Rowid iRowid has just been appended to the current leaf page. It is the\n** first on the page. This function appends an appropriate entry to the current\n** doclist-index.\n*/\nstatic void fts5WriteDlidxAppend(\n  Fts5Index *p, \n  Fts5SegWriter *pWriter, \n  i64 iRowid\n){\n  int i;\n  int bDone = 0;\n\n  for(i=0; p->rc==SQLITE_OK && bDone==0; i++){\n    i64 iVal;\n    Fts5DlidxWriter *pDlidx = &pWriter->aDlidx[i];\n\n    if( pDlidx->buf.n>=p->pConfig->pgsz ){\n      /* The current doclist-index page is full. Write it to disk and push\n      ** a copy of iRowid (which will become the first rowid on the next\n      ** doclist-index leaf page) up into the next level of the b-tree \n      ** hierarchy. If the node being flushed is currently the root node,\n      ** also push its first rowid upwards. */\n      pDlidx->buf.p[0] = 0x01;    /* Not the root node */\n      fts5DataWrite(p, \n          FTS5_DLIDX_ROWID(pWriter->iSegid, i, pDlidx->pgno),\n          pDlidx->buf.p, pDlidx->buf.n\n      );\n      fts5WriteDlidxGrow(p, pWriter, i+2);\n      pDlidx = &pWriter->aDlidx[i];\n      if( p->rc==SQLITE_OK && pDlidx[1].buf.n==0 ){\n        i64 iFirst = fts5DlidxExtractFirstRowid(&pDlidx->buf);\n\n        /* This was the root node. Push its first rowid up to the new root. */\n        pDlidx[1].pgno = pDlidx->pgno;\n        sqlite3Fts5BufferAppendVarint(&p->rc, &pDlidx[1].buf, 0);\n        sqlite3Fts5BufferAppendVarint(&p->rc, &pDlidx[1].buf, pDlidx->pgno);\n        sqlite3Fts5BufferAppendVarint(&p->rc, &pDlidx[1].buf, iFirst);\n        pDlidx[1].bPrevValid = 1;\n        pDlidx[1].iPrev = iFirst;\n      }\n\n      sqlite3Fts5BufferZero(&pDlidx->buf);\n      pDlidx->bPrevValid = 0;\n      pDlidx->pgno++;\n    }else{\n      bDone = 1;\n    }\n\n    if( pDlidx->bPrevValid ){\n      iVal = iRowid - pDlidx->iPrev;\n    }else{\n      i64 iPgno = (i==0 ? pWriter->writer.pgno : pDlidx[-1].pgno);\n      assert( pDlidx->buf.n==0 );\n      sqlite3Fts5BufferAppendVarint(&p->rc, &pDlidx->buf, !bDone);\n      sqlite3Fts5BufferAppendVarint(&p->rc, &pDlidx->buf, iPgno);\n      iVal = iRowid;\n    }\n\n    sqlite3Fts5BufferAppendVarint(&p->rc, &pDlidx->buf, iVal);\n    pDlidx->bPrevValid = 1;\n    pDlidx->iPrev = iRowid;\n  }\n}\n\nstatic void fts5WriteFlushLeaf(Fts5Index *p, Fts5SegWriter *pWriter){\n  static const u8 zero[] = { 0x00, 0x00, 0x00, 0x00 };\n  Fts5PageWriter *pPage = &pWriter->writer;\n  i64 iRowid;\n\n  assert( (pPage->pgidx.n==0)==(pWriter->bFirstTermInPage) );\n\n  /* Set the szLeaf header field. */\n  assert( 0==fts5GetU16(&pPage->buf.p[2]) );\n  fts5PutU16(&pPage->buf.p[2], (u16)pPage->buf.n);\n\n  if( pWriter->bFirstTermInPage ){\n    /* No term was written to this page. */\n    assert( pPage->pgidx.n==0 );\n    fts5WriteBtreeNoTerm(p, pWriter);\n  }else{\n    /* Append the pgidx to the page buffer. Set the szLeaf header field. */\n    fts5BufferAppendBlob(&p->rc, &pPage->buf, pPage->pgidx.n, pPage->pgidx.p);\n  }\n\n  /* Write the page out to disk */\n  iRowid = FTS5_SEGMENT_ROWID(pWriter->iSegid, pPage->pgno);\n  fts5DataWrite(p, iRowid, pPage->buf.p, pPage->buf.n);\n\n  /* Initialize the next page. */\n  fts5BufferZero(&pPage->buf);\n  fts5BufferZero(&pPage->pgidx);\n  fts5BufferAppendBlob(&p->rc, &pPage->buf, 4, zero);\n  pPage->iPrevPgidx = 0;\n  pPage->pgno++;\n\n  /* Increase the leaves written counter */\n  pWriter->nLeafWritten++;\n\n  /* The new leaf holds no terms or rowids */\n  pWriter->bFirstTermInPage = 1;\n  pWriter->bFirstRowidInPage = 1;\n}\n\n/*\n** Append term pTerm/nTerm to the segment being written by the writer passed\n** as the second argument.\n**\n** If an error occurs, set the Fts5Index.rc error code. If an error has \n** already occurred, this function is a no-op.\n*/\nstatic void fts5WriteAppendTerm(\n  Fts5Index *p, \n  Fts5SegWriter *pWriter,\n  int nTerm, const u8 *pTerm \n){\n  int nPrefix;                    /* Bytes of prefix compression for term */\n  Fts5PageWriter *pPage = &pWriter->writer;\n  Fts5Buffer *pPgidx = &pWriter->writer.pgidx;\n  int nMin = MIN(pPage->term.n, nTerm);\n\n  assert( p->rc==SQLITE_OK );\n  assert( pPage->buf.n>=4 );\n  assert( pPage->buf.n>4 || pWriter->bFirstTermInPage );\n\n  /* If the current leaf page is full, flush it to disk. */\n  if( (pPage->buf.n + pPgidx->n + nTerm + 2)>=p->pConfig->pgsz ){\n    if( pPage->buf.n>4 ){\n      fts5WriteFlushLeaf(p, pWriter);\n      if( p->rc!=SQLITE_OK ) return;\n    }\n    fts5BufferGrow(&p->rc, &pPage->buf, nTerm+FTS5_DATA_PADDING);\n  }\n  \n  /* TODO1: Updating pgidx here. */\n  pPgidx->n += sqlite3Fts5PutVarint(\n      &pPgidx->p[pPgidx->n], pPage->buf.n - pPage->iPrevPgidx\n  );\n  pPage->iPrevPgidx = pPage->buf.n;\n#if 0\n  fts5PutU16(&pPgidx->p[pPgidx->n], pPage->buf.n);\n  pPgidx->n += 2;\n#endif\n\n  if( pWriter->bFirstTermInPage ){\n    nPrefix = 0;\n    if( pPage->pgno!=1 ){\n      /* This is the first term on a leaf that is not the leftmost leaf in\n      ** the segment b-tree. In this case it is necessary to add a term to\n      ** the b-tree hierarchy that is (a) larger than the largest term \n      ** already written to the segment and (b) smaller than or equal to\n      ** this term. In other words, a prefix of (pTerm/nTerm) that is one\n      ** byte longer than the longest prefix (pTerm/nTerm) shares with the\n      ** previous term. \n      **\n      ** Usually, the previous term is available in pPage->term. The exception\n      ** is if this is the first term written in an incremental-merge step.\n      ** In this case the previous term is not available, so just write a\n      ** copy of (pTerm/nTerm) into the parent node. This is slightly\n      ** inefficient, but still correct.  */\n      int n = nTerm;\n      if( pPage->term.n ){\n        n = 1 + fts5PrefixCompress(nMin, pPage->term.p, pTerm);\n      }\n      fts5WriteBtreeTerm(p, pWriter, n, pTerm);\n      if( p->rc!=SQLITE_OK ) return;\n      pPage = &pWriter->writer;\n    }\n  }else{\n    nPrefix = fts5PrefixCompress(nMin, pPage->term.p, pTerm);\n    fts5BufferAppendVarint(&p->rc, &pPage->buf, nPrefix);\n  }\n\n  /* Append the number of bytes of new data, then the term data itself\n  ** to the page. */\n  fts5BufferAppendVarint(&p->rc, &pPage->buf, nTerm - nPrefix);\n  fts5BufferAppendBlob(&p->rc, &pPage->buf, nTerm - nPrefix, &pTerm[nPrefix]);\n\n  /* Update the Fts5PageWriter.term field. */\n  fts5BufferSet(&p->rc, &pPage->term, nTerm, pTerm);\n  pWriter->bFirstTermInPage = 0;\n\n  pWriter->bFirstRowidInPage = 0;\n  pWriter->bFirstRowidInDoclist = 1;\n\n  assert( p->rc || (pWriter->nDlidx>0 && pWriter->aDlidx[0].buf.n==0) );\n  pWriter->aDlidx[0].pgno = pPage->pgno;\n}\n\n/*\n** Append a rowid and position-list size field to the writers output. \n*/\nstatic void fts5WriteAppendRowid(\n  Fts5Index *p, \n  Fts5SegWriter *pWriter,\n  i64 iRowid\n){\n  if( p->rc==SQLITE_OK ){\n    Fts5PageWriter *pPage = &pWriter->writer;\n\n    if( (pPage->buf.n + pPage->pgidx.n)>=p->pConfig->pgsz ){\n      fts5WriteFlushLeaf(p, pWriter);\n    }\n\n    /* If this is to be the first rowid written to the page, set the \n    ** rowid-pointer in the page-header. Also append a value to the dlidx\n    ** buffer, in case a doclist-index is required.  */\n    if( pWriter->bFirstRowidInPage ){\n      fts5PutU16(pPage->buf.p, (u16)pPage->buf.n);\n      fts5WriteDlidxAppend(p, pWriter, iRowid);\n    }\n\n    /* Write the rowid. */\n    if( pWriter->bFirstRowidInDoclist || pWriter->bFirstRowidInPage ){\n      fts5BufferAppendVarint(&p->rc, &pPage->buf, iRowid);\n    }else{\n      assert_nc( p->rc || iRowid>pWriter->iPrevRowid );\n      fts5BufferAppendVarint(&p->rc, &pPage->buf, iRowid - pWriter->iPrevRowid);\n    }\n    pWriter->iPrevRowid = iRowid;\n    pWriter->bFirstRowidInDoclist = 0;\n    pWriter->bFirstRowidInPage = 0;\n  }\n}\n\nstatic void fts5WriteAppendPoslistData(\n  Fts5Index *p, \n  Fts5SegWriter *pWriter, \n  const u8 *aData, \n  int nData\n){\n  Fts5PageWriter *pPage = &pWriter->writer;\n  const u8 *a = aData;\n  int n = nData;\n  \n  assert( p->pConfig->pgsz>0 );\n  while( p->rc==SQLITE_OK \n     && (pPage->buf.n + pPage->pgidx.n + n)>=p->pConfig->pgsz \n  ){\n    int nReq = p->pConfig->pgsz - pPage->buf.n - pPage->pgidx.n;\n    int nCopy = 0;\n    while( nCopy<nReq ){\n      i64 dummy;\n      nCopy += fts5GetVarint(&a[nCopy], (u64*)&dummy);\n    }\n    fts5BufferAppendBlob(&p->rc, &pPage->buf, nCopy, a);\n    a += nCopy;\n    n -= nCopy;\n    fts5WriteFlushLeaf(p, pWriter);\n  }\n  if( n>0 ){\n    fts5BufferAppendBlob(&p->rc, &pPage->buf, n, a);\n  }\n}\n\n/*\n** Flush any data cached by the writer object to the database. Free any\n** allocations associated with the writer.\n*/\nstatic void fts5WriteFinish(\n  Fts5Index *p, \n  Fts5SegWriter *pWriter,         /* Writer object */\n  int *pnLeaf                     /* OUT: Number of leaf pages in b-tree */\n){\n  int i;\n  Fts5PageWriter *pLeaf = &pWriter->writer;\n  if( p->rc==SQLITE_OK ){\n    assert( pLeaf->pgno>=1 );\n    if( pLeaf->buf.n>4 ){\n      fts5WriteFlushLeaf(p, pWriter);\n    }\n    *pnLeaf = pLeaf->pgno-1;\n    if( pLeaf->pgno>1 ){\n      fts5WriteFlushBtree(p, pWriter);\n    }\n  }\n  fts5BufferFree(&pLeaf->term);\n  fts5BufferFree(&pLeaf->buf);\n  fts5BufferFree(&pLeaf->pgidx);\n  fts5BufferFree(&pWriter->btterm);\n\n  for(i=0; i<pWriter->nDlidx; i++){\n    sqlite3Fts5BufferFree(&pWriter->aDlidx[i].buf);\n  }\n  sqlite3_free(pWriter->aDlidx);\n}\n\nstatic void fts5WriteInit(\n  Fts5Index *p, \n  Fts5SegWriter *pWriter, \n  int iSegid\n){\n  const int nBuffer = p->pConfig->pgsz + FTS5_DATA_PADDING;\n\n  memset(pWriter, 0, sizeof(Fts5SegWriter));\n  pWriter->iSegid = iSegid;\n\n  fts5WriteDlidxGrow(p, pWriter, 1);\n  pWriter->writer.pgno = 1;\n  pWriter->bFirstTermInPage = 1;\n  pWriter->iBtPage = 1;\n\n  assert( pWriter->writer.buf.n==0 );\n  assert( pWriter->writer.pgidx.n==0 );\n\n  /* Grow the two buffers to pgsz + padding bytes in size. */\n  sqlite3Fts5BufferSize(&p->rc, &pWriter->writer.pgidx, nBuffer);\n  sqlite3Fts5BufferSize(&p->rc, &pWriter->writer.buf, nBuffer);\n\n  if( p->pIdxWriter==0 ){\n    Fts5Config *pConfig = p->pConfig;\n    fts5IndexPrepareStmt(p, &p->pIdxWriter, sqlite3_mprintf(\n          \"INSERT INTO '%q'.'%q_idx'(segid,term,pgno) VALUES(?,?,?)\", \n          pConfig->zDb, pConfig->zName\n    ));\n  }\n\n  if( p->rc==SQLITE_OK ){\n    /* Initialize the 4-byte leaf-page header to 0x00. */\n    memset(pWriter->writer.buf.p, 0, 4);\n    pWriter->writer.buf.n = 4;\n\n    /* Bind the current output segment id to the index-writer. This is an\n    ** optimization over binding the same value over and over as rows are\n    ** inserted into %_idx by the current writer.  */\n    sqlite3_bind_int(p->pIdxWriter, 1, pWriter->iSegid);\n  }\n}\n\n/*\n** Iterator pIter was used to iterate through the input segments of on an\n** incremental merge operation. This function is called if the incremental\n** merge step has finished but the input has not been completely exhausted.\n*/\nstatic void fts5TrimSegments(Fts5Index *p, Fts5Iter *pIter){\n  int i;\n  Fts5Buffer buf;\n  memset(&buf, 0, sizeof(Fts5Buffer));\n  for(i=0; i<pIter->nSeg && p->rc==SQLITE_OK; i++){\n    Fts5SegIter *pSeg = &pIter->aSeg[i];\n    if( pSeg->pSeg==0 ){\n      /* no-op */\n    }else if( pSeg->pLeaf==0 ){\n      /* All keys from this input segment have been transfered to the output.\n      ** Set both the first and last page-numbers to 0 to indicate that the\n      ** segment is now empty. */\n      pSeg->pSeg->pgnoLast = 0;\n      pSeg->pSeg->pgnoFirst = 0;\n    }else{\n      int iOff = pSeg->iTermLeafOffset;     /* Offset on new first leaf page */\n      i64 iLeafRowid;\n      Fts5Data *pData;\n      int iId = pSeg->pSeg->iSegid;\n      u8 aHdr[4] = {0x00, 0x00, 0x00, 0x00};\n\n      iLeafRowid = FTS5_SEGMENT_ROWID(iId, pSeg->iTermLeafPgno);\n      pData = fts5LeafRead(p, iLeafRowid);\n      if( pData ){\n        if( iOff>pData->szLeaf ){\n          /* This can occur if the pages that the segments occupy overlap - if\n          ** a single page has been assigned to more than one segment. In\n          ** this case a prior iteration of this loop may have corrupted the\n          ** segment currently being trimmed.  */\n          p->rc = FTS5_CORRUPT;\n        }else{\n          fts5BufferZero(&buf);\n          fts5BufferGrow(&p->rc, &buf, pData->nn);\n          fts5BufferAppendBlob(&p->rc, &buf, sizeof(aHdr), aHdr);\n          fts5BufferAppendVarint(&p->rc, &buf, pSeg->term.n);\n          fts5BufferAppendBlob(&p->rc, &buf, pSeg->term.n, pSeg->term.p);\n          fts5BufferAppendBlob(&p->rc, &buf, pData->szLeaf-iOff,&pData->p[iOff]);\n          if( p->rc==SQLITE_OK ){\n            /* Set the szLeaf field */\n            fts5PutU16(&buf.p[2], (u16)buf.n);\n          }\n\n          /* Set up the new page-index array */\n          fts5BufferAppendVarint(&p->rc, &buf, 4);\n          if( pSeg->iLeafPgno==pSeg->iTermLeafPgno \n              && pSeg->iEndofDoclist<pData->szLeaf \n            ){\n            int nDiff = pData->szLeaf - pSeg->iEndofDoclist;\n            fts5BufferAppendVarint(&p->rc, &buf, buf.n - 1 - nDiff - 4);\n            fts5BufferAppendBlob(&p->rc, &buf, \n                pData->nn - pSeg->iPgidxOff, &pData->p[pSeg->iPgidxOff]\n                );\n          }\n\n          pSeg->pSeg->pgnoFirst = pSeg->iTermLeafPgno;\n          fts5DataDelete(p, FTS5_SEGMENT_ROWID(iId, 1), iLeafRowid);\n          fts5DataWrite(p, iLeafRowid, buf.p, buf.n);\n        }\n        fts5DataRelease(pData);\n      }\n    }\n  }\n  fts5BufferFree(&buf);\n}\n\nstatic void fts5MergeChunkCallback(\n  Fts5Index *p, \n  void *pCtx, \n  const u8 *pChunk, int nChunk\n){\n  Fts5SegWriter *pWriter = (Fts5SegWriter*)pCtx;\n  fts5WriteAppendPoslistData(p, pWriter, pChunk, nChunk);\n}\n\n/*\n**\n*/\nstatic void fts5IndexMergeLevel(\n  Fts5Index *p,                   /* FTS5 backend object */\n  Fts5Structure **ppStruct,       /* IN/OUT: Stucture of index */\n  int iLvl,                       /* Level to read input from */\n  int *pnRem                      /* Write up to this many output leaves */\n){\n  Fts5Structure *pStruct = *ppStruct;\n  Fts5StructureLevel *pLvl = &pStruct->aLevel[iLvl];\n  Fts5StructureLevel *pLvlOut;\n  Fts5Iter *pIter = 0;       /* Iterator to read input data */\n  int nRem = pnRem ? *pnRem : 0;  /* Output leaf pages left to write */\n  int nInput;                     /* Number of input segments */\n  Fts5SegWriter writer;           /* Writer object */\n  Fts5StructureSegment *pSeg;     /* Output segment */\n  Fts5Buffer term;\n  int bOldest;                    /* True if the output segment is the oldest */\n  int eDetail = p->pConfig->eDetail;\n  const int flags = FTS5INDEX_QUERY_NOOUTPUT;\n  int bTermWritten = 0;           /* True if current term already output */\n\n  assert( iLvl<pStruct->nLevel );\n  assert( pLvl->nMerge<=pLvl->nSeg );\n\n  memset(&writer, 0, sizeof(Fts5SegWriter));\n  memset(&term, 0, sizeof(Fts5Buffer));\n  if( pLvl->nMerge ){\n    pLvlOut = &pStruct->aLevel[iLvl+1];\n    assert( pLvlOut->nSeg>0 );\n    nInput = pLvl->nMerge;\n    pSeg = &pLvlOut->aSeg[pLvlOut->nSeg-1];\n\n    fts5WriteInit(p, &writer, pSeg->iSegid);\n    writer.writer.pgno = pSeg->pgnoLast+1;\n    writer.iBtPage = 0;\n  }else{\n    int iSegid = fts5AllocateSegid(p, pStruct);\n\n    /* Extend the Fts5Structure object as required to ensure the output\n    ** segment exists. */\n    if( iLvl==pStruct->nLevel-1 ){\n      fts5StructureAddLevel(&p->rc, ppStruct);\n      pStruct = *ppStruct;\n    }\n    fts5StructureExtendLevel(&p->rc, pStruct, iLvl+1, 1, 0);\n    if( p->rc ) return;\n    pLvl = &pStruct->aLevel[iLvl];\n    pLvlOut = &pStruct->aLevel[iLvl+1];\n\n    fts5WriteInit(p, &writer, iSegid);\n\n    /* Add the new segment to the output level */\n    pSeg = &pLvlOut->aSeg[pLvlOut->nSeg];\n    pLvlOut->nSeg++;\n    pSeg->pgnoFirst = 1;\n    pSeg->iSegid = iSegid;\n    pStruct->nSegment++;\n\n    /* Read input from all segments in the input level */\n    nInput = pLvl->nSeg;\n  }\n  bOldest = (pLvlOut->nSeg==1 && pStruct->nLevel==iLvl+2);\n\n  assert( iLvl>=0 );\n  for(fts5MultiIterNew(p, pStruct, flags, 0, 0, 0, iLvl, nInput, &pIter);\n      fts5MultiIterEof(p, pIter)==0;\n      fts5MultiIterNext(p, pIter, 0, 0)\n  ){\n    Fts5SegIter *pSegIter = &pIter->aSeg[ pIter->aFirst[1].iFirst ];\n    int nPos;                     /* position-list size field value */\n    int nTerm;\n    const u8 *pTerm;\n\n    pTerm = fts5MultiIterTerm(pIter, &nTerm);\n    if( nTerm!=term.n || fts5Memcmp(pTerm, term.p, nTerm) ){\n      if( pnRem && writer.nLeafWritten>nRem ){\n        break;\n      }\n      fts5BufferSet(&p->rc, &term, nTerm, pTerm);\n      bTermWritten =0;\n    }\n\n    /* Check for key annihilation. */\n    if( pSegIter->nPos==0 && (bOldest || pSegIter->bDel==0) ) continue;\n\n    if( p->rc==SQLITE_OK && bTermWritten==0 ){\n      /* This is a new term. Append a term to the output segment. */\n      fts5WriteAppendTerm(p, &writer, nTerm, pTerm);\n      bTermWritten = 1;\n    }\n\n    /* Append the rowid to the output */\n    /* WRITEPOSLISTSIZE */\n    fts5WriteAppendRowid(p, &writer, fts5MultiIterRowid(pIter));\n\n    if( eDetail==FTS5_DETAIL_NONE ){\n      if( pSegIter->bDel ){\n        fts5BufferAppendVarint(&p->rc, &writer.writer.buf, 0);\n        if( pSegIter->nPos>0 ){\n          fts5BufferAppendVarint(&p->rc, &writer.writer.buf, 0);\n        }\n      }\n    }else{\n      /* Append the position-list data to the output */\n      nPos = pSegIter->nPos*2 + pSegIter->bDel;\n      fts5BufferAppendVarint(&p->rc, &writer.writer.buf, nPos);\n      fts5ChunkIterate(p, pSegIter, (void*)&writer, fts5MergeChunkCallback);\n    }\n  }\n\n  /* Flush the last leaf page to disk. Set the output segment b-tree height\n  ** and last leaf page number at the same time.  */\n  fts5WriteFinish(p, &writer, &pSeg->pgnoLast);\n\n  if( fts5MultiIterEof(p, pIter) ){\n    int i;\n\n    /* Remove the redundant segments from the %_data table */\n    for(i=0; i<nInput; i++){\n      fts5DataRemoveSegment(p, pLvl->aSeg[i].iSegid);\n    }\n\n    /* Remove the redundant segments from the input level */\n    if( pLvl->nSeg!=nInput ){\n      int nMove = (pLvl->nSeg - nInput) * sizeof(Fts5StructureSegment);\n      memmove(pLvl->aSeg, &pLvl->aSeg[nInput], nMove);\n    }\n    pStruct->nSegment -= nInput;\n    pLvl->nSeg -= nInput;\n    pLvl->nMerge = 0;\n    if( pSeg->pgnoLast==0 ){\n      pLvlOut->nSeg--;\n      pStruct->nSegment--;\n    }\n  }else{\n    assert( pSeg->pgnoLast>0 );\n    fts5TrimSegments(p, pIter);\n    pLvl->nMerge = nInput;\n  }\n\n  fts5MultiIterFree(pIter);\n  fts5BufferFree(&term);\n  if( pnRem ) *pnRem -= writer.nLeafWritten;\n}\n\n/*\n** Do up to nPg pages of automerge work on the index.\n**\n** Return true if any changes were actually made, or false otherwise.\n*/\nstatic int fts5IndexMerge(\n  Fts5Index *p,                   /* FTS5 backend object */\n  Fts5Structure **ppStruct,       /* IN/OUT: Current structure of index */\n  int nPg,                        /* Pages of work to do */\n  int nMin                        /* Minimum number of segments to merge */\n){\n  int nRem = nPg;\n  int bRet = 0;\n  Fts5Structure *pStruct = *ppStruct;\n  while( nRem>0 && p->rc==SQLITE_OK ){\n    int iLvl;                   /* To iterate through levels */\n    int iBestLvl = 0;           /* Level offering the most input segments */\n    int nBest = 0;              /* Number of input segments on best level */\n\n    /* Set iBestLvl to the level to read input segments from. */\n    assert( pStruct->nLevel>0 );\n    for(iLvl=0; iLvl<pStruct->nLevel; iLvl++){\n      Fts5StructureLevel *pLvl = &pStruct->aLevel[iLvl];\n      if( pLvl->nMerge ){\n        if( pLvl->nMerge>nBest ){\n          iBestLvl = iLvl;\n          nBest = pLvl->nMerge;\n        }\n        break;\n      }\n      if( pLvl->nSeg>nBest ){\n        nBest = pLvl->nSeg;\n        iBestLvl = iLvl;\n      }\n    }\n\n    /* If nBest is still 0, then the index must be empty. */\n#ifdef SQLITE_DEBUG\n    for(iLvl=0; nBest==0 && iLvl<pStruct->nLevel; iLvl++){\n      assert( pStruct->aLevel[iLvl].nSeg==0 );\n    }\n#endif\n\n    if( nBest<nMin && pStruct->aLevel[iBestLvl].nMerge==0 ){\n      break;\n    }\n    bRet = 1;\n    fts5IndexMergeLevel(p, &pStruct, iBestLvl, &nRem);\n    if( p->rc==SQLITE_OK && pStruct->aLevel[iBestLvl].nMerge==0 ){\n      fts5StructurePromote(p, iBestLvl+1, pStruct);\n    }\n  }\n  *ppStruct = pStruct;\n  return bRet;\n}\n\n/*\n** A total of nLeaf leaf pages of data has just been flushed to a level-0\n** segment. This function updates the write-counter accordingly and, if\n** necessary, performs incremental merge work.\n**\n** If an error occurs, set the Fts5Index.rc error code. If an error has \n** already occurred, this function is a no-op.\n*/\nstatic void fts5IndexAutomerge(\n  Fts5Index *p,                   /* FTS5 backend object */\n  Fts5Structure **ppStruct,       /* IN/OUT: Current structure of index */\n  int nLeaf                       /* Number of output leaves just written */\n){\n  if( p->rc==SQLITE_OK && p->pConfig->nAutomerge>0 ){\n    Fts5Structure *pStruct = *ppStruct;\n    u64 nWrite;                   /* Initial value of write-counter */\n    int nWork;                    /* Number of work-quanta to perform */\n    int nRem;                     /* Number of leaf pages left to write */\n\n    /* Update the write-counter. While doing so, set nWork. */\n    nWrite = pStruct->nWriteCounter;\n    nWork = (int)(((nWrite + nLeaf) / p->nWorkUnit) - (nWrite / p->nWorkUnit));\n    pStruct->nWriteCounter += nLeaf;\n    nRem = (int)(p->nWorkUnit * nWork * pStruct->nLevel);\n\n    fts5IndexMerge(p, ppStruct, nRem, p->pConfig->nAutomerge);\n  }\n}\n\nstatic void fts5IndexCrisismerge(\n  Fts5Index *p,                   /* FTS5 backend object */\n  Fts5Structure **ppStruct        /* IN/OUT: Current structure of index */\n){\n  const int nCrisis = p->pConfig->nCrisisMerge;\n  Fts5Structure *pStruct = *ppStruct;\n  int iLvl = 0;\n\n  assert( p->rc!=SQLITE_OK || pStruct->nLevel>0 );\n  while( p->rc==SQLITE_OK && pStruct->aLevel[iLvl].nSeg>=nCrisis ){\n    fts5IndexMergeLevel(p, &pStruct, iLvl, 0);\n    assert( p->rc!=SQLITE_OK || pStruct->nLevel>(iLvl+1) );\n    fts5StructurePromote(p, iLvl+1, pStruct);\n    iLvl++;\n  }\n  *ppStruct = pStruct;\n}\n\nstatic int fts5IndexReturn(Fts5Index *p){\n  int rc = p->rc;\n  p->rc = SQLITE_OK;\n  return rc;\n}\n\ntypedef struct Fts5FlushCtx Fts5FlushCtx;\nstruct Fts5FlushCtx {\n  Fts5Index *pIdx;\n  Fts5SegWriter writer; \n};\n\n/*\n** Buffer aBuf[] contains a list of varints, all small enough to fit\n** in a 32-bit integer. Return the size of the largest prefix of this \n** list nMax bytes or less in size.\n*/\nstatic int fts5PoslistPrefix(const u8 *aBuf, int nMax){\n  int ret;\n  u32 dummy;\n  ret = fts5GetVarint32(aBuf, dummy);\n  if( ret<nMax ){\n    while( 1 ){\n      int i = fts5GetVarint32(&aBuf[ret], dummy);\n      if( (ret + i) > nMax ) break;\n      ret += i;\n    }\n  }\n  return ret;\n}\n\n/*\n** Flush the contents of in-memory hash table iHash to a new level-0 \n** segment on disk. Also update the corresponding structure record.\n**\n** If an error occurs, set the Fts5Index.rc error code. If an error has \n** already occurred, this function is a no-op.\n*/\nstatic void fts5FlushOneHash(Fts5Index *p){\n  Fts5Hash *pHash = p->pHash;\n  Fts5Structure *pStruct;\n  int iSegid;\n  int pgnoLast = 0;                 /* Last leaf page number in segment */\n\n  /* Obtain a reference to the index structure and allocate a new segment-id\n  ** for the new level-0 segment.  */\n  pStruct = fts5StructureRead(p);\n  iSegid = fts5AllocateSegid(p, pStruct);\n  fts5StructureInvalidate(p);\n\n  if( iSegid ){\n    const int pgsz = p->pConfig->pgsz;\n    int eDetail = p->pConfig->eDetail;\n    Fts5StructureSegment *pSeg;   /* New segment within pStruct */\n    Fts5Buffer *pBuf;             /* Buffer in which to assemble leaf page */\n    Fts5Buffer *pPgidx;           /* Buffer in which to assemble pgidx */\n\n    Fts5SegWriter writer;\n    fts5WriteInit(p, &writer, iSegid);\n\n    pBuf = &writer.writer.buf;\n    pPgidx = &writer.writer.pgidx;\n\n    /* fts5WriteInit() should have initialized the buffers to (most likely)\n    ** the maximum space required. */\n    assert( p->rc || pBuf->nSpace>=(pgsz + FTS5_DATA_PADDING) );\n    assert( p->rc || pPgidx->nSpace>=(pgsz + FTS5_DATA_PADDING) );\n\n    /* Begin scanning through hash table entries. This loop runs once for each\n    ** term/doclist currently stored within the hash table. */\n    if( p->rc==SQLITE_OK ){\n      p->rc = sqlite3Fts5HashScanInit(pHash, 0, 0);\n    }\n    while( p->rc==SQLITE_OK && 0==sqlite3Fts5HashScanEof(pHash) ){\n      const char *zTerm;          /* Buffer containing term */\n      const u8 *pDoclist;         /* Pointer to doclist for this term */\n      int nDoclist;               /* Size of doclist in bytes */\n\n      /* Write the term for this entry to disk. */\n      sqlite3Fts5HashScanEntry(pHash, &zTerm, &pDoclist, &nDoclist);\n      fts5WriteAppendTerm(p, &writer, (int)strlen(zTerm), (const u8*)zTerm);\n      if( p->rc!=SQLITE_OK ) break;\n\n      assert( writer.bFirstRowidInPage==0 );\n      if( pgsz>=(pBuf->n + pPgidx->n + nDoclist + 1) ){\n        /* The entire doclist will fit on the current leaf. */\n        fts5BufferSafeAppendBlob(pBuf, pDoclist, nDoclist);\n      }else{\n        i64 iRowid = 0;\n        i64 iDelta = 0;\n        int iOff = 0;\n\n        /* The entire doclist will not fit on this leaf. The following \n        ** loop iterates through the poslists that make up the current \n        ** doclist.  */\n        while( p->rc==SQLITE_OK && iOff<nDoclist ){\n          iOff += fts5GetVarint(&pDoclist[iOff], (u64*)&iDelta);\n          iRowid += iDelta;\n          \n          if( writer.bFirstRowidInPage ){\n            fts5PutU16(&pBuf->p[0], (u16)pBuf->n);   /* first rowid on page */\n            pBuf->n += sqlite3Fts5PutVarint(&pBuf->p[pBuf->n], iRowid);\n            writer.bFirstRowidInPage = 0;\n            fts5WriteDlidxAppend(p, &writer, iRowid);\n            if( p->rc!=SQLITE_OK ) break;\n          }else{\n            pBuf->n += sqlite3Fts5PutVarint(&pBuf->p[pBuf->n], iDelta);\n          }\n          assert( pBuf->n<=pBuf->nSpace );\n\n          if( eDetail==FTS5_DETAIL_NONE ){\n            if( iOff<nDoclist && pDoclist[iOff]==0 ){\n              pBuf->p[pBuf->n++] = 0;\n              iOff++;\n              if( iOff<nDoclist && pDoclist[iOff]==0 ){\n                pBuf->p[pBuf->n++] = 0;\n                iOff++;\n              }\n            }\n            if( (pBuf->n + pPgidx->n)>=pgsz ){\n              fts5WriteFlushLeaf(p, &writer);\n            }\n          }else{\n            int bDummy;\n            int nPos;\n            int nCopy = fts5GetPoslistSize(&pDoclist[iOff], &nPos, &bDummy);\n            nCopy += nPos;\n            if( (pBuf->n + pPgidx->n + nCopy) <= pgsz ){\n              /* The entire poslist will fit on the current leaf. So copy\n              ** it in one go. */\n              fts5BufferSafeAppendBlob(pBuf, &pDoclist[iOff], nCopy);\n            }else{\n              /* The entire poslist will not fit on this leaf. So it needs\n              ** to be broken into sections. The only qualification being\n              ** that each varint must be stored contiguously.  */\n              const u8 *pPoslist = &pDoclist[iOff];\n              int iPos = 0;\n              while( p->rc==SQLITE_OK ){\n                int nSpace = pgsz - pBuf->n - pPgidx->n;\n                int n = 0;\n                if( (nCopy - iPos)<=nSpace ){\n                  n = nCopy - iPos;\n                }else{\n                  n = fts5PoslistPrefix(&pPoslist[iPos], nSpace);\n                }\n                assert( n>0 );\n                fts5BufferSafeAppendBlob(pBuf, &pPoslist[iPos], n);\n                iPos += n;\n                if( (pBuf->n + pPgidx->n)>=pgsz ){\n                  fts5WriteFlushLeaf(p, &writer);\n                }\n                if( iPos>=nCopy ) break;\n              }\n            }\n            iOff += nCopy;\n          }\n        }\n      }\n\n      /* TODO2: Doclist terminator written here. */\n      /* pBuf->p[pBuf->n++] = '\\0'; */\n      assert( pBuf->n<=pBuf->nSpace );\n      if( p->rc==SQLITE_OK ) sqlite3Fts5HashScanNext(pHash);\n    }\n    sqlite3Fts5HashClear(pHash);\n    fts5WriteFinish(p, &writer, &pgnoLast);\n\n    /* Update the Fts5Structure. It is written back to the database by the\n    ** fts5StructureRelease() call below.  */\n    if( pStruct->nLevel==0 ){\n      fts5StructureAddLevel(&p->rc, &pStruct);\n    }\n    fts5StructureExtendLevel(&p->rc, pStruct, 0, 1, 0);\n    if( p->rc==SQLITE_OK ){\n      pSeg = &pStruct->aLevel[0].aSeg[ pStruct->aLevel[0].nSeg++ ];\n      pSeg->iSegid = iSegid;\n      pSeg->pgnoFirst = 1;\n      pSeg->pgnoLast = pgnoLast;\n      pStruct->nSegment++;\n    }\n    fts5StructurePromote(p, 0, pStruct);\n  }\n\n  fts5IndexAutomerge(p, &pStruct, pgnoLast);\n  fts5IndexCrisismerge(p, &pStruct);\n  fts5StructureWrite(p, pStruct);\n  fts5StructureRelease(pStruct);\n}\n\n/*\n** Flush any data stored in the in-memory hash tables to the database.\n*/\nstatic void fts5IndexFlush(Fts5Index *p){\n  /* Unless it is empty, flush the hash table to disk */\n  if( p->nPendingData ){\n    assert( p->pHash );\n    p->nPendingData = 0;\n    fts5FlushOneHash(p);\n  }\n}\n\nstatic Fts5Structure *fts5IndexOptimizeStruct(\n  Fts5Index *p, \n  Fts5Structure *pStruct\n){\n  Fts5Structure *pNew = 0;\n  sqlite3_int64 nByte = sizeof(Fts5Structure);\n  int nSeg = pStruct->nSegment;\n  int i;\n\n  /* Figure out if this structure requires optimization. A structure does\n  ** not require optimization if either:\n  **\n  **  + it consists of fewer than two segments, or \n  **  + all segments are on the same level, or\n  **  + all segments except one are currently inputs to a merge operation.\n  **\n  ** In the first case, return NULL. In the second, increment the ref-count\n  ** on *pStruct and return a copy of the pointer to it.\n  */\n  if( nSeg<2 ) return 0;\n  for(i=0; i<pStruct->nLevel; i++){\n    int nThis = pStruct->aLevel[i].nSeg;\n    if( nThis==nSeg || (nThis==nSeg-1 && pStruct->aLevel[i].nMerge==nThis) ){\n      fts5StructureRef(pStruct);\n      return pStruct;\n    }\n    assert( pStruct->aLevel[i].nMerge<=nThis );\n  }\n\n  nByte += (pStruct->nLevel+1) * sizeof(Fts5StructureLevel);\n  pNew = (Fts5Structure*)sqlite3Fts5MallocZero(&p->rc, nByte);\n\n  if( pNew ){\n    Fts5StructureLevel *pLvl;\n    nByte = nSeg * sizeof(Fts5StructureSegment);\n    pNew->nLevel = pStruct->nLevel+1;\n    pNew->nRef = 1;\n    pNew->nWriteCounter = pStruct->nWriteCounter;\n    pLvl = &pNew->aLevel[pStruct->nLevel];\n    pLvl->aSeg = (Fts5StructureSegment*)sqlite3Fts5MallocZero(&p->rc, nByte);\n    if( pLvl->aSeg ){\n      int iLvl, iSeg;\n      int iSegOut = 0;\n      /* Iterate through all segments, from oldest to newest. Add them to\n      ** the new Fts5Level object so that pLvl->aSeg[0] is the oldest\n      ** segment in the data structure.  */\n      for(iLvl=pStruct->nLevel-1; iLvl>=0; iLvl--){\n        for(iSeg=0; iSeg<pStruct->aLevel[iLvl].nSeg; iSeg++){\n          pLvl->aSeg[iSegOut] = pStruct->aLevel[iLvl].aSeg[iSeg];\n          iSegOut++;\n        }\n      }\n      pNew->nSegment = pLvl->nSeg = nSeg;\n    }else{\n      sqlite3_free(pNew);\n      pNew = 0;\n    }\n  }\n\n  return pNew;\n}\n\nstatic int sqlite3Fts5IndexOptimize(Fts5Index *p){\n  Fts5Structure *pStruct;\n  Fts5Structure *pNew = 0;\n\n  assert( p->rc==SQLITE_OK );\n  fts5IndexFlush(p);\n  pStruct = fts5StructureRead(p);\n  fts5StructureInvalidate(p);\n\n  if( pStruct ){\n    pNew = fts5IndexOptimizeStruct(p, pStruct);\n  }\n  fts5StructureRelease(pStruct);\n\n  assert( pNew==0 || pNew->nSegment>0 );\n  if( pNew ){\n    int iLvl;\n    for(iLvl=0; pNew->aLevel[iLvl].nSeg==0; iLvl++){}\n    while( p->rc==SQLITE_OK && pNew->aLevel[iLvl].nSeg>0 ){\n      int nRem = FTS5_OPT_WORK_UNIT;\n      fts5IndexMergeLevel(p, &pNew, iLvl, &nRem);\n    }\n\n    fts5StructureWrite(p, pNew);\n    fts5StructureRelease(pNew);\n  }\n\n  return fts5IndexReturn(p); \n}\n\n/*\n** This is called to implement the special \"VALUES('merge', $nMerge)\"\n** INSERT command.\n*/\nstatic int sqlite3Fts5IndexMerge(Fts5Index *p, int nMerge){\n  Fts5Structure *pStruct = fts5StructureRead(p);\n  if( pStruct ){\n    int nMin = p->pConfig->nUsermerge;\n    fts5StructureInvalidate(p);\n    if( nMerge<0 ){\n      Fts5Structure *pNew = fts5IndexOptimizeStruct(p, pStruct);\n      fts5StructureRelease(pStruct);\n      pStruct = pNew;\n      nMin = 2;\n      nMerge = nMerge*-1;\n    }\n    if( pStruct && pStruct->nLevel ){\n      if( fts5IndexMerge(p, &pStruct, nMerge, nMin) ){\n        fts5StructureWrite(p, pStruct);\n      }\n    }\n    fts5StructureRelease(pStruct);\n  }\n  return fts5IndexReturn(p);\n}\n\nstatic void fts5AppendRowid(\n  Fts5Index *p,\n  i64 iDelta,\n  Fts5Iter *pUnused,\n  Fts5Buffer *pBuf\n){\n  UNUSED_PARAM(pUnused);\n  fts5BufferAppendVarint(&p->rc, pBuf, iDelta);\n}\n\nstatic void fts5AppendPoslist(\n  Fts5Index *p,\n  i64 iDelta,\n  Fts5Iter *pMulti,\n  Fts5Buffer *pBuf\n){\n  int nData = pMulti->base.nData;\n  int nByte = nData + 9 + 9 + FTS5_DATA_ZERO_PADDING;\n  assert( nData>0 );\n  if( p->rc==SQLITE_OK && 0==fts5BufferGrow(&p->rc, pBuf, nByte) ){\n    fts5BufferSafeAppendVarint(pBuf, iDelta);\n    fts5BufferSafeAppendVarint(pBuf, nData*2);\n    fts5BufferSafeAppendBlob(pBuf, pMulti->base.pData, nData);\n    memset(&pBuf->p[pBuf->n], 0, FTS5_DATA_ZERO_PADDING);\n  }\n}\n\n\nstatic void fts5DoclistIterNext(Fts5DoclistIter *pIter){\n  u8 *p = pIter->aPoslist + pIter->nSize + pIter->nPoslist;\n\n  assert( pIter->aPoslist );\n  if( p>=pIter->aEof ){\n    pIter->aPoslist = 0;\n  }else{\n    i64 iDelta;\n\n    p += fts5GetVarint(p, (u64*)&iDelta);\n    pIter->iRowid += iDelta;\n\n    /* Read position list size */\n    if( p[0] & 0x80 ){\n      int nPos;\n      pIter->nSize = fts5GetVarint32(p, nPos);\n      pIter->nPoslist = (nPos>>1);\n    }else{\n      pIter->nPoslist = ((int)(p[0])) >> 1;\n      pIter->nSize = 1;\n    }\n\n    pIter->aPoslist = p;\n  }\n}\n\nstatic void fts5DoclistIterInit(\n  Fts5Buffer *pBuf, \n  Fts5DoclistIter *pIter\n){\n  memset(pIter, 0, sizeof(*pIter));\n  pIter->aPoslist = pBuf->p;\n  pIter->aEof = &pBuf->p[pBuf->n];\n  fts5DoclistIterNext(pIter);\n}\n\n#if 0\n/*\n** Append a doclist to buffer pBuf.\n**\n** This function assumes that space within the buffer has already been\n** allocated.\n*/\nstatic void fts5MergeAppendDocid(\n  Fts5Buffer *pBuf,               /* Buffer to write to */\n  i64 *piLastRowid,               /* IN/OUT: Previous rowid written (if any) */\n  i64 iRowid                      /* Rowid to append */\n){\n  assert( pBuf->n!=0 || (*piLastRowid)==0 );\n  fts5BufferSafeAppendVarint(pBuf, iRowid - *piLastRowid);\n  *piLastRowid = iRowid;\n}\n#endif\n\n#define fts5MergeAppendDocid(pBuf, iLastRowid, iRowid) {       \\\n  assert( (pBuf)->n!=0 || (iLastRowid)==0 );                   \\\n  fts5BufferSafeAppendVarint((pBuf), (iRowid) - (iLastRowid)); \\\n  (iLastRowid) = (iRowid);                                     \\\n}\n\n/*\n** Swap the contents of buffer *p1 with that of *p2.\n*/\nstatic void fts5BufferSwap(Fts5Buffer *p1, Fts5Buffer *p2){\n  Fts5Buffer tmp = *p1;\n  *p1 = *p2;\n  *p2 = tmp;\n}\n\nstatic void fts5NextRowid(Fts5Buffer *pBuf, int *piOff, i64 *piRowid){\n  int i = *piOff;\n  if( i>=pBuf->n ){\n    *piOff = -1;\n  }else{\n    u64 iVal;\n    *piOff = i + sqlite3Fts5GetVarint(&pBuf->p[i], &iVal);\n    *piRowid += iVal;\n  }\n}\n\n/*\n** This is the equivalent of fts5MergePrefixLists() for detail=none mode.\n** In this case the buffers consist of a delta-encoded list of rowids only.\n*/\nstatic void fts5MergeRowidLists(\n  Fts5Index *p,                   /* FTS5 backend object */\n  Fts5Buffer *p1,                 /* First list to merge */\n  Fts5Buffer *p2                  /* Second list to merge */\n){\n  int i1 = 0;\n  int i2 = 0;\n  i64 iRowid1 = 0;\n  i64 iRowid2 = 0;\n  i64 iOut = 0;\n\n  Fts5Buffer out;\n  memset(&out, 0, sizeof(out));\n  sqlite3Fts5BufferSize(&p->rc, &out, p1->n + p2->n);\n  if( p->rc ) return;\n\n  fts5NextRowid(p1, &i1, &iRowid1);\n  fts5NextRowid(p2, &i2, &iRowid2);\n  while( i1>=0 || i2>=0 ){\n    if( i1>=0 && (i2<0 || iRowid1<iRowid2) ){\n      assert( iOut==0 || iRowid1>iOut );\n      fts5BufferSafeAppendVarint(&out, iRowid1 - iOut);\n      iOut = iRowid1;\n      fts5NextRowid(p1, &i1, &iRowid1);\n    }else{\n      assert( iOut==0 || iRowid2>iOut );\n      fts5BufferSafeAppendVarint(&out, iRowid2 - iOut);\n      iOut = iRowid2;\n      if( i1>=0 && iRowid1==iRowid2 ){\n        fts5NextRowid(p1, &i1, &iRowid1);\n      }\n      fts5NextRowid(p2, &i2, &iRowid2);\n    }\n  }\n\n  fts5BufferSwap(&out, p1);\n  fts5BufferFree(&out);\n}\n\n/*\n** Buffers p1 and p2 contain doclists. This function merges the content\n** of the two doclists together and sets buffer p1 to the result before\n** returning.\n**\n** If an error occurs, an error code is left in p->rc. If an error has\n** already occurred, this function is a no-op.\n*/\nstatic void fts5MergePrefixLists(\n  Fts5Index *p,                   /* FTS5 backend object */\n  Fts5Buffer *p1,                 /* First list to merge */\n  Fts5Buffer *p2                  /* Second list to merge */\n){\n  if( p2->n ){\n    i64 iLastRowid = 0;\n    Fts5DoclistIter i1;\n    Fts5DoclistIter i2;\n    Fts5Buffer out = {0, 0, 0};\n    Fts5Buffer tmp = {0, 0, 0};\n\n    /* The maximum size of the output is equal to the sum of the two \n    ** input sizes + 1 varint (9 bytes). The extra varint is because if the\n    ** first rowid in one input is a large negative number, and the first in\n    ** the other a non-negative number, the delta for the non-negative\n    ** number will be larger on disk than the literal integer value\n    ** was.  */\n    if( sqlite3Fts5BufferSize(&p->rc, &out, p1->n + p2->n + 9) ) return;\n    fts5DoclistIterInit(p1, &i1);\n    fts5DoclistIterInit(p2, &i2);\n\n    while( 1 ){\n      if( i1.iRowid<i2.iRowid ){\n        /* Copy entry from i1 */\n        fts5MergeAppendDocid(&out, iLastRowid, i1.iRowid);\n        fts5BufferSafeAppendBlob(&out, i1.aPoslist, i1.nPoslist+i1.nSize);\n        fts5DoclistIterNext(&i1);\n        if( i1.aPoslist==0 ) break;\n      }\n      else if( i2.iRowid!=i1.iRowid ){\n        /* Copy entry from i2 */\n        fts5MergeAppendDocid(&out, iLastRowid, i2.iRowid);\n        fts5BufferSafeAppendBlob(&out, i2.aPoslist, i2.nPoslist+i2.nSize);\n        fts5DoclistIterNext(&i2);\n        if( i2.aPoslist==0 ) break;\n      }\n      else{\n        /* Merge the two position lists. */ \n        i64 iPos1 = 0;\n        i64 iPos2 = 0;\n        int iOff1 = 0;\n        int iOff2 = 0;\n        u8 *a1 = &i1.aPoslist[i1.nSize];\n        u8 *a2 = &i2.aPoslist[i2.nSize];\n        int nCopy;\n        u8 *aCopy;\n\n        i64 iPrev = 0;\n        Fts5PoslistWriter writer;\n        memset(&writer, 0, sizeof(writer));\n\n        fts5MergeAppendDocid(&out, iLastRowid, i2.iRowid);\n        fts5BufferZero(&tmp);\n        sqlite3Fts5BufferSize(&p->rc, &tmp, i1.nPoslist + i2.nPoslist);\n        if( p->rc ) break;\n\n        sqlite3Fts5PoslistNext64(a1, i1.nPoslist, &iOff1, &iPos1);\n        sqlite3Fts5PoslistNext64(a2, i2.nPoslist, &iOff2, &iPos2);\n        assert( iPos1>=0 && iPos2>=0 );\n\n        if( iPos1<iPos2 ){\n          sqlite3Fts5PoslistSafeAppend(&tmp, &iPrev, iPos1);\n          sqlite3Fts5PoslistNext64(a1, i1.nPoslist, &iOff1, &iPos1);\n        }else{\n          sqlite3Fts5PoslistSafeAppend(&tmp, &iPrev, iPos2);\n          sqlite3Fts5PoslistNext64(a2, i2.nPoslist, &iOff2, &iPos2);\n        }\n\n        if( iPos1>=0 && iPos2>=0 ){\n          while( 1 ){\n            if( iPos1<iPos2 ){\n              if( iPos1!=iPrev ){\n                sqlite3Fts5PoslistSafeAppend(&tmp, &iPrev, iPos1);\n              }\n              sqlite3Fts5PoslistNext64(a1, i1.nPoslist, &iOff1, &iPos1);\n              if( iPos1<0 ) break;\n            }else{\n              assert_nc( iPos2!=iPrev );\n              sqlite3Fts5PoslistSafeAppend(&tmp, &iPrev, iPos2);\n              sqlite3Fts5PoslistNext64(a2, i2.nPoslist, &iOff2, &iPos2);\n              if( iPos2<0 ) break;\n            }\n          }\n        }\n\n        if( iPos1>=0 ){\n          if( iPos1!=iPrev ){\n            sqlite3Fts5PoslistSafeAppend(&tmp, &iPrev, iPos1);\n          }\n          aCopy = &a1[iOff1];\n          nCopy = i1.nPoslist - iOff1;\n        }else{\n          assert( iPos2>=0 && iPos2!=iPrev );\n          sqlite3Fts5PoslistSafeAppend(&tmp, &iPrev, iPos2);\n          aCopy = &a2[iOff2];\n          nCopy = i2.nPoslist - iOff2;\n        }\n        if( nCopy>0 ){\n          fts5BufferSafeAppendBlob(&tmp, aCopy, nCopy);\n        }\n\n        /* WRITEPOSLISTSIZE */\n        fts5BufferSafeAppendVarint(&out, tmp.n * 2);\n        fts5BufferSafeAppendBlob(&out, tmp.p, tmp.n);\n        fts5DoclistIterNext(&i1);\n        fts5DoclistIterNext(&i2);\n        assert( out.n<=(p1->n+p2->n+9) );\n        if( i1.aPoslist==0 || i2.aPoslist==0 ) break;\n      }\n    }\n\n    if( i1.aPoslist ){\n      fts5MergeAppendDocid(&out, iLastRowid, i1.iRowid);\n      fts5BufferSafeAppendBlob(&out, i1.aPoslist, i1.aEof - i1.aPoslist);\n    }\n    else if( i2.aPoslist ){\n      fts5MergeAppendDocid(&out, iLastRowid, i2.iRowid);\n      fts5BufferSafeAppendBlob(&out, i2.aPoslist, i2.aEof - i2.aPoslist);\n    }\n    assert( out.n<=(p1->n+p2->n+9) );\n\n    fts5BufferSet(&p->rc, p1, out.n, out.p);\n    fts5BufferFree(&tmp);\n    fts5BufferFree(&out);\n  }\n}\n\nstatic void fts5SetupPrefixIter(\n  Fts5Index *p,                   /* Index to read from */\n  int bDesc,                      /* True for \"ORDER BY rowid DESC\" */\n  const u8 *pToken,               /* Buffer containing prefix to match */\n  int nToken,                     /* Size of buffer pToken in bytes */\n  Fts5Colset *pColset,            /* Restrict matches to these columns */\n  Fts5Iter **ppIter          /* OUT: New iterator */\n){\n  Fts5Structure *pStruct;\n  Fts5Buffer *aBuf;\n  const int nBuf = 32;\n\n  void (*xMerge)(Fts5Index*, Fts5Buffer*, Fts5Buffer*);\n  void (*xAppend)(Fts5Index*, i64, Fts5Iter*, Fts5Buffer*);\n  if( p->pConfig->eDetail==FTS5_DETAIL_NONE ){\n    xMerge = fts5MergeRowidLists;\n    xAppend = fts5AppendRowid;\n  }else{\n    xMerge = fts5MergePrefixLists;\n    xAppend = fts5AppendPoslist;\n  }\n\n  aBuf = (Fts5Buffer*)fts5IdxMalloc(p, sizeof(Fts5Buffer)*nBuf);\n  pStruct = fts5StructureRead(p);\n\n  if( aBuf && pStruct ){\n    const int flags = FTS5INDEX_QUERY_SCAN \n                    | FTS5INDEX_QUERY_SKIPEMPTY \n                    | FTS5INDEX_QUERY_NOOUTPUT;\n    int i;\n    i64 iLastRowid = 0;\n    Fts5Iter *p1 = 0;     /* Iterator used to gather data from index */\n    Fts5Data *pData;\n    Fts5Buffer doclist;\n    int bNewTerm = 1;\n\n    memset(&doclist, 0, sizeof(doclist));\n    fts5MultiIterNew(p, pStruct, flags, pColset, pToken, nToken, -1, 0, &p1);\n    fts5IterSetOutputCb(&p->rc, p1);\n    for( /* no-op */ ;\n        fts5MultiIterEof(p, p1)==0;\n        fts5MultiIterNext2(p, p1, &bNewTerm)\n    ){\n      Fts5SegIter *pSeg = &p1->aSeg[ p1->aFirst[1].iFirst ];\n      int nTerm = pSeg->term.n;\n      const u8 *pTerm = pSeg->term.p;\n      p1->xSetOutputs(p1, pSeg);\n\n      assert_nc( memcmp(pToken, pTerm, MIN(nToken, nTerm))<=0 );\n      if( bNewTerm ){\n        if( nTerm<nToken || memcmp(pToken, pTerm, nToken) ) break;\n      }\n\n      if( p1->base.nData==0 ) continue;\n\n      if( p1->base.iRowid<=iLastRowid && doclist.n>0 ){\n        for(i=0; p->rc==SQLITE_OK && doclist.n; i++){\n          assert( i<nBuf );\n          if( aBuf[i].n==0 ){\n            fts5BufferSwap(&doclist, &aBuf[i]);\n            fts5BufferZero(&doclist);\n          }else{\n            xMerge(p, &doclist, &aBuf[i]);\n            fts5BufferZero(&aBuf[i]);\n          }\n        }\n        iLastRowid = 0;\n      }\n\n      xAppend(p, p1->base.iRowid-iLastRowid, p1, &doclist);\n      iLastRowid = p1->base.iRowid;\n    }\n\n    for(i=0; i<nBuf; i++){\n      if( p->rc==SQLITE_OK ){\n        xMerge(p, &doclist, &aBuf[i]);\n      }\n      fts5BufferFree(&aBuf[i]);\n    }\n    fts5MultiIterFree(p1);\n\n    pData = fts5IdxMalloc(p, sizeof(Fts5Data)+doclist.n+FTS5_DATA_ZERO_PADDING);\n    if( pData ){\n      pData->p = (u8*)&pData[1];\n      pData->nn = pData->szLeaf = doclist.n;\n      if( doclist.n ) memcpy(pData->p, doclist.p, doclist.n);\n      fts5MultiIterNew2(p, pData, bDesc, ppIter);\n    }\n    fts5BufferFree(&doclist);\n  }\n\n  fts5StructureRelease(pStruct);\n  sqlite3_free(aBuf);\n}\n\n\n/*\n** Indicate that all subsequent calls to sqlite3Fts5IndexWrite() pertain\n** to the document with rowid iRowid.\n*/\nstatic int sqlite3Fts5IndexBeginWrite(Fts5Index *p, int bDelete, i64 iRowid){\n  assert( p->rc==SQLITE_OK );\n\n  /* Allocate the hash table if it has not already been allocated */\n  if( p->pHash==0 ){\n    p->rc = sqlite3Fts5HashNew(p->pConfig, &p->pHash, &p->nPendingData);\n  }\n\n  /* Flush the hash table to disk if required */\n  if( iRowid<p->iWriteRowid \n   || (iRowid==p->iWriteRowid && p->bDelete==0)\n   || (p->nPendingData > p->pConfig->nHashSize) \n  ){\n    fts5IndexFlush(p);\n  }\n\n  p->iWriteRowid = iRowid;\n  p->bDelete = bDelete;\n  return fts5IndexReturn(p);\n}\n\n/*\n** Commit data to disk.\n*/\nstatic int sqlite3Fts5IndexSync(Fts5Index *p){\n  assert( p->rc==SQLITE_OK );\n  fts5IndexFlush(p);\n  fts5CloseReader(p);\n  return fts5IndexReturn(p);\n}\n\n/*\n** Discard any data stored in the in-memory hash tables. Do not write it\n** to the database. Additionally, assume that the contents of the %_data\n** table may have changed on disk. So any in-memory caches of %_data \n** records must be invalidated.\n*/\nstatic int sqlite3Fts5IndexRollback(Fts5Index *p){\n  fts5CloseReader(p);\n  fts5IndexDiscardData(p);\n  fts5StructureInvalidate(p);\n  /* assert( p->rc==SQLITE_OK ); */\n  return SQLITE_OK;\n}\n\n/*\n** The %_data table is completely empty when this function is called. This\n** function populates it with the initial structure objects for each index,\n** and the initial version of the \"averages\" record (a zero-byte blob).\n*/\nstatic int sqlite3Fts5IndexReinit(Fts5Index *p){\n  Fts5Structure s;\n  fts5StructureInvalidate(p);\n  memset(&s, 0, sizeof(Fts5Structure));\n  fts5DataWrite(p, FTS5_AVERAGES_ROWID, (const u8*)\"\", 0);\n  fts5StructureWrite(p, &s);\n  return fts5IndexReturn(p);\n}\n\n/*\n** Open a new Fts5Index handle. If the bCreate argument is true, create\n** and initialize the underlying %_data table.\n**\n** If successful, set *pp to point to the new object and return SQLITE_OK.\n** Otherwise, set *pp to NULL and return an SQLite error code.\n*/\nstatic int sqlite3Fts5IndexOpen(\n  Fts5Config *pConfig, \n  int bCreate, \n  Fts5Index **pp,\n  char **pzErr\n){\n  int rc = SQLITE_OK;\n  Fts5Index *p;                   /* New object */\n\n  *pp = p = (Fts5Index*)sqlite3Fts5MallocZero(&rc, sizeof(Fts5Index));\n  if( rc==SQLITE_OK ){\n    p->pConfig = pConfig;\n    p->nWorkUnit = FTS5_WORK_UNIT;\n    p->zDataTbl = sqlite3Fts5Mprintf(&rc, \"%s_data\", pConfig->zName);\n    if( p->zDataTbl && bCreate ){\n      rc = sqlite3Fts5CreateTable(\n          pConfig, \"data\", \"id INTEGER PRIMARY KEY, block BLOB\", 0, pzErr\n      );\n      if( rc==SQLITE_OK ){\n        rc = sqlite3Fts5CreateTable(pConfig, \"idx\", \n            \"segid, term, pgno, PRIMARY KEY(segid, term)\", \n            1, pzErr\n        );\n      }\n      if( rc==SQLITE_OK ){\n        rc = sqlite3Fts5IndexReinit(p);\n      }\n    }\n  }\n\n  assert( rc!=SQLITE_OK || p->rc==SQLITE_OK );\n  if( rc ){\n    sqlite3Fts5IndexClose(p);\n    *pp = 0;\n  }\n  return rc;\n}\n\n/*\n** Close a handle opened by an earlier call to sqlite3Fts5IndexOpen().\n*/\nstatic int sqlite3Fts5IndexClose(Fts5Index *p){\n  int rc = SQLITE_OK;\n  if( p ){\n    assert( p->pReader==0 );\n    fts5StructureInvalidate(p);\n    sqlite3_finalize(p->pWriter);\n    sqlite3_finalize(p->pDeleter);\n    sqlite3_finalize(p->pIdxWriter);\n    sqlite3_finalize(p->pIdxDeleter);\n    sqlite3_finalize(p->pIdxSelect);\n    sqlite3_finalize(p->pDataVersion);\n    sqlite3Fts5HashFree(p->pHash);\n    sqlite3_free(p->zDataTbl);\n    sqlite3_free(p);\n  }\n  return rc;\n}\n\n/*\n** Argument p points to a buffer containing utf-8 text that is n bytes in \n** size. Return the number of bytes in the nChar character prefix of the\n** buffer, or 0 if there are less than nChar characters in total.\n*/\nstatic int sqlite3Fts5IndexCharlenToBytelen(\n  const char *p, \n  int nByte, \n  int nChar\n){\n  int n = 0;\n  int i;\n  for(i=0; i<nChar; i++){\n    if( n>=nByte ) return 0;      /* Input contains fewer than nChar chars */\n    if( (unsigned char)p[n++]>=0xc0 ){\n      while( (p[n] & 0xc0)==0x80 ){\n        n++;\n        if( n>=nByte ) break;\n      }\n    }\n  }\n  return n;\n}\n\n/*\n** pIn is a UTF-8 encoded string, nIn bytes in size. Return the number of\n** unicode characters in the string.\n*/\nstatic int fts5IndexCharlen(const char *pIn, int nIn){\n  int nChar = 0;            \n  int i = 0;\n  while( i<nIn ){\n    if( (unsigned char)pIn[i++]>=0xc0 ){\n      while( i<nIn && (pIn[i] & 0xc0)==0x80 ) i++;\n    }\n    nChar++;\n  }\n  return nChar;\n}\n\n/*\n** Insert or remove data to or from the index. Each time a document is \n** added to or removed from the index, this function is called one or more\n** times.\n**\n** For an insert, it must be called once for each token in the new document.\n** If the operation is a delete, it must be called (at least) once for each\n** unique token in the document with an iCol value less than zero. The iPos\n** argument is ignored for a delete.\n*/\nstatic int sqlite3Fts5IndexWrite(\n  Fts5Index *p,                   /* Index to write to */\n  int iCol,                       /* Column token appears in (-ve -> delete) */\n  int iPos,                       /* Position of token within column */\n  const char *pToken, int nToken  /* Token to add or remove to or from index */\n){\n  int i;                          /* Used to iterate through indexes */\n  int rc = SQLITE_OK;             /* Return code */\n  Fts5Config *pConfig = p->pConfig;\n\n  assert( p->rc==SQLITE_OK );\n  assert( (iCol<0)==p->bDelete );\n\n  /* Add the entry to the main terms index. */\n  rc = sqlite3Fts5HashWrite(\n      p->pHash, p->iWriteRowid, iCol, iPos, FTS5_MAIN_PREFIX, pToken, nToken\n  );\n\n  for(i=0; i<pConfig->nPrefix && rc==SQLITE_OK; i++){\n    const int nChar = pConfig->aPrefix[i];\n    int nByte = sqlite3Fts5IndexCharlenToBytelen(pToken, nToken, nChar);\n    if( nByte ){\n      rc = sqlite3Fts5HashWrite(p->pHash, \n          p->iWriteRowid, iCol, iPos, (char)(FTS5_MAIN_PREFIX+i+1), pToken,\n          nByte\n      );\n    }\n  }\n\n  return rc;\n}\n\n/*\n** Open a new iterator to iterate though all rowid that match the \n** specified token or token prefix.\n*/\nstatic int sqlite3Fts5IndexQuery(\n  Fts5Index *p,                   /* FTS index to query */\n  const char *pToken, int nToken, /* Token (or prefix) to query for */\n  int flags,                      /* Mask of FTS5INDEX_QUERY_X flags */\n  Fts5Colset *pColset,            /* Match these columns only */\n  Fts5IndexIter **ppIter          /* OUT: New iterator object */\n){\n  Fts5Config *pConfig = p->pConfig;\n  Fts5Iter *pRet = 0;\n  Fts5Buffer buf = {0, 0, 0};\n\n  /* If the QUERY_SCAN flag is set, all other flags must be clear. */\n  assert( (flags & FTS5INDEX_QUERY_SCAN)==0 || flags==FTS5INDEX_QUERY_SCAN );\n\n  if( sqlite3Fts5BufferSize(&p->rc, &buf, nToken+1)==0 ){\n    int iIdx = 0;                 /* Index to search */\n    if( nToken ) memcpy(&buf.p[1], pToken, nToken);\n\n    /* Figure out which index to search and set iIdx accordingly. If this\n    ** is a prefix query for which there is no prefix index, set iIdx to\n    ** greater than pConfig->nPrefix to indicate that the query will be\n    ** satisfied by scanning multiple terms in the main index.\n    **\n    ** If the QUERY_TEST_NOIDX flag was specified, then this must be a\n    ** prefix-query. Instead of using a prefix-index (if one exists), \n    ** evaluate the prefix query using the main FTS index. This is used\n    ** for internal sanity checking by the integrity-check in debug \n    ** mode only.  */\n#ifdef SQLITE_DEBUG\n    if( pConfig->bPrefixIndex==0 || (flags & FTS5INDEX_QUERY_TEST_NOIDX) ){\n      assert( flags & FTS5INDEX_QUERY_PREFIX );\n      iIdx = 1+pConfig->nPrefix;\n    }else\n#endif\n    if( flags & FTS5INDEX_QUERY_PREFIX ){\n      int nChar = fts5IndexCharlen(pToken, nToken);\n      for(iIdx=1; iIdx<=pConfig->nPrefix; iIdx++){\n        if( pConfig->aPrefix[iIdx-1]==nChar ) break;\n      }\n    }\n\n    if( iIdx<=pConfig->nPrefix ){\n      /* Straight index lookup */\n      Fts5Structure *pStruct = fts5StructureRead(p);\n      buf.p[0] = (u8)(FTS5_MAIN_PREFIX + iIdx);\n      if( pStruct ){\n        fts5MultiIterNew(p, pStruct, flags | FTS5INDEX_QUERY_SKIPEMPTY, \n            pColset, buf.p, nToken+1, -1, 0, &pRet\n        );\n        fts5StructureRelease(pStruct);\n      }\n    }else{\n      /* Scan multiple terms in the main index */\n      int bDesc = (flags & FTS5INDEX_QUERY_DESC)!=0;\n      buf.p[0] = FTS5_MAIN_PREFIX;\n      fts5SetupPrefixIter(p, bDesc, buf.p, nToken+1, pColset, &pRet);\n      assert( p->rc!=SQLITE_OK || pRet->pColset==0 );\n      fts5IterSetOutputCb(&p->rc, pRet);\n      if( p->rc==SQLITE_OK ){\n        Fts5SegIter *pSeg = &pRet->aSeg[pRet->aFirst[1].iFirst];\n        if( pSeg->pLeaf ) pRet->xSetOutputs(pRet, pSeg);\n      }\n    }\n\n    if( p->rc ){\n      sqlite3Fts5IterClose((Fts5IndexIter*)pRet);\n      pRet = 0;\n      fts5CloseReader(p);\n    }\n\n    *ppIter = (Fts5IndexIter*)pRet;\n    sqlite3Fts5BufferFree(&buf);\n  }\n  return fts5IndexReturn(p);\n}\n\n/*\n** Return true if the iterator passed as the only argument is at EOF.\n*/\n/*\n** Move to the next matching rowid. \n*/\nstatic int sqlite3Fts5IterNext(Fts5IndexIter *pIndexIter){\n  Fts5Iter *pIter = (Fts5Iter*)pIndexIter;\n  assert( pIter->pIndex->rc==SQLITE_OK );\n  fts5MultiIterNext(pIter->pIndex, pIter, 0, 0);\n  return fts5IndexReturn(pIter->pIndex);\n}\n\n/*\n** Move to the next matching term/rowid. Used by the fts5vocab module.\n*/\nstatic int sqlite3Fts5IterNextScan(Fts5IndexIter *pIndexIter){\n  Fts5Iter *pIter = (Fts5Iter*)pIndexIter;\n  Fts5Index *p = pIter->pIndex;\n\n  assert( pIter->pIndex->rc==SQLITE_OK );\n\n  fts5MultiIterNext(p, pIter, 0, 0);\n  if( p->rc==SQLITE_OK ){\n    Fts5SegIter *pSeg = &pIter->aSeg[ pIter->aFirst[1].iFirst ];\n    if( pSeg->pLeaf && pSeg->term.p[0]!=FTS5_MAIN_PREFIX ){\n      fts5DataRelease(pSeg->pLeaf);\n      pSeg->pLeaf = 0;\n      pIter->base.bEof = 1;\n    }\n  }\n\n  return fts5IndexReturn(pIter->pIndex);\n}\n\n/*\n** Move to the next matching rowid that occurs at or after iMatch. The\n** definition of \"at or after\" depends on whether this iterator iterates\n** in ascending or descending rowid order.\n*/\nstatic int sqlite3Fts5IterNextFrom(Fts5IndexIter *pIndexIter, i64 iMatch){\n  Fts5Iter *pIter = (Fts5Iter*)pIndexIter;\n  fts5MultiIterNextFrom(pIter->pIndex, pIter, iMatch);\n  return fts5IndexReturn(pIter->pIndex);\n}\n\n/*\n** Return the current term.\n*/\nstatic const char *sqlite3Fts5IterTerm(Fts5IndexIter *pIndexIter, int *pn){\n  int n;\n  const char *z = (const char*)fts5MultiIterTerm((Fts5Iter*)pIndexIter, &n);\n  *pn = n-1;\n  return &z[1];\n}\n\n/*\n** Close an iterator opened by an earlier call to sqlite3Fts5IndexQuery().\n*/\nstatic void sqlite3Fts5IterClose(Fts5IndexIter *pIndexIter){\n  if( pIndexIter ){\n    Fts5Iter *pIter = (Fts5Iter*)pIndexIter;\n    Fts5Index *pIndex = pIter->pIndex;\n    fts5MultiIterFree(pIter);\n    fts5CloseReader(pIndex);\n  }\n}\n\n/*\n** Read and decode the \"averages\" record from the database. \n**\n** Parameter anSize must point to an array of size nCol, where nCol is\n** the number of user defined columns in the FTS table.\n*/\nstatic int sqlite3Fts5IndexGetAverages(Fts5Index *p, i64 *pnRow, i64 *anSize){\n  int nCol = p->pConfig->nCol;\n  Fts5Data *pData;\n\n  *pnRow = 0;\n  memset(anSize, 0, sizeof(i64) * nCol);\n  pData = fts5DataRead(p, FTS5_AVERAGES_ROWID);\n  if( p->rc==SQLITE_OK && pData->nn ){\n    int i = 0;\n    int iCol;\n    i += fts5GetVarint(&pData->p[i], (u64*)pnRow);\n    for(iCol=0; i<pData->nn && iCol<nCol; iCol++){\n      i += fts5GetVarint(&pData->p[i], (u64*)&anSize[iCol]);\n    }\n  }\n\n  fts5DataRelease(pData);\n  return fts5IndexReturn(p);\n}\n\n/*\n** Replace the current \"averages\" record with the contents of the buffer \n** supplied as the second argument.\n*/\nstatic int sqlite3Fts5IndexSetAverages(Fts5Index *p, const u8 *pData, int nData){\n  assert( p->rc==SQLITE_OK );\n  fts5DataWrite(p, FTS5_AVERAGES_ROWID, pData, nData);\n  return fts5IndexReturn(p);\n}\n\n/*\n** Return the total number of blocks this module has read from the %_data\n** table since it was created.\n*/\nstatic int sqlite3Fts5IndexReads(Fts5Index *p){\n  return p->nRead;\n}\n\n/*\n** Set the 32-bit cookie value stored at the start of all structure \n** records to the value passed as the second argument.\n**\n** Return SQLITE_OK if successful, or an SQLite error code if an error\n** occurs.\n*/\nstatic int sqlite3Fts5IndexSetCookie(Fts5Index *p, int iNew){\n  int rc;                              /* Return code */\n  Fts5Config *pConfig = p->pConfig;    /* Configuration object */\n  u8 aCookie[4];                       /* Binary representation of iNew */\n  sqlite3_blob *pBlob = 0;\n\n  assert( p->rc==SQLITE_OK );\n  sqlite3Fts5Put32(aCookie, iNew);\n\n  rc = sqlite3_blob_open(pConfig->db, pConfig->zDb, p->zDataTbl, \n      \"block\", FTS5_STRUCTURE_ROWID, 1, &pBlob\n  );\n  if( rc==SQLITE_OK ){\n    sqlite3_blob_write(pBlob, aCookie, 4, 0);\n    rc = sqlite3_blob_close(pBlob);\n  }\n\n  return rc;\n}\n\nstatic int sqlite3Fts5IndexLoadConfig(Fts5Index *p){\n  Fts5Structure *pStruct;\n  pStruct = fts5StructureRead(p);\n  fts5StructureRelease(pStruct);\n  return fts5IndexReturn(p);\n}\n\n\n/*************************************************************************\n**************************************************************************\n** Below this point is the implementation of the integrity-check \n** functionality.\n*/\n\n/*\n** Return a simple checksum value based on the arguments.\n*/\nstatic u64 sqlite3Fts5IndexEntryCksum(\n  i64 iRowid, \n  int iCol, \n  int iPos, \n  int iIdx,\n  const char *pTerm,\n  int nTerm\n){\n  int i;\n  u64 ret = iRowid;\n  ret += (ret<<3) + iCol;\n  ret += (ret<<3) + iPos;\n  if( iIdx>=0 ) ret += (ret<<3) + (FTS5_MAIN_PREFIX + iIdx);\n  for(i=0; i<nTerm; i++) ret += (ret<<3) + pTerm[i];\n  return ret;\n}\n\n#ifdef SQLITE_DEBUG\n/*\n** This function is purely an internal test. It does not contribute to \n** FTS functionality, or even the integrity-check, in any way.\n**\n** Instead, it tests that the same set of pgno/rowid combinations are \n** visited regardless of whether the doclist-index identified by parameters\n** iSegid/iLeaf is iterated in forwards or reverse order.\n*/\nstatic void fts5TestDlidxReverse(\n  Fts5Index *p, \n  int iSegid,                     /* Segment id to load from */\n  int iLeaf                       /* Load doclist-index for this leaf */\n){\n  Fts5DlidxIter *pDlidx = 0;\n  u64 cksum1 = 13;\n  u64 cksum2 = 13;\n\n  for(pDlidx=fts5DlidxIterInit(p, 0, iSegid, iLeaf);\n      fts5DlidxIterEof(p, pDlidx)==0;\n      fts5DlidxIterNext(p, pDlidx)\n  ){\n    i64 iRowid = fts5DlidxIterRowid(pDlidx);\n    int pgno = fts5DlidxIterPgno(pDlidx);\n    assert( pgno>iLeaf );\n    cksum1 += iRowid + ((i64)pgno<<32);\n  }\n  fts5DlidxIterFree(pDlidx);\n  pDlidx = 0;\n\n  for(pDlidx=fts5DlidxIterInit(p, 1, iSegid, iLeaf);\n      fts5DlidxIterEof(p, pDlidx)==0;\n      fts5DlidxIterPrev(p, pDlidx)\n  ){\n    i64 iRowid = fts5DlidxIterRowid(pDlidx);\n    int pgno = fts5DlidxIterPgno(pDlidx);\n    assert( fts5DlidxIterPgno(pDlidx)>iLeaf );\n    cksum2 += iRowid + ((i64)pgno<<32);\n  }\n  fts5DlidxIterFree(pDlidx);\n  pDlidx = 0;\n\n  if( p->rc==SQLITE_OK && cksum1!=cksum2 ) p->rc = FTS5_CORRUPT;\n}\n\nstatic int fts5QueryCksum(\n  Fts5Index *p,                   /* Fts5 index object */\n  int iIdx,\n  const char *z,                  /* Index key to query for */\n  int n,                          /* Size of index key in bytes */\n  int flags,                      /* Flags for Fts5IndexQuery */\n  u64 *pCksum                     /* IN/OUT: Checksum value */\n){\n  int eDetail = p->pConfig->eDetail;\n  u64 cksum = *pCksum;\n  Fts5IndexIter *pIter = 0;\n  int rc = sqlite3Fts5IndexQuery(p, z, n, flags, 0, &pIter);\n\n  while( rc==SQLITE_OK && 0==sqlite3Fts5IterEof(pIter) ){\n    i64 rowid = pIter->iRowid;\n\n    if( eDetail==FTS5_DETAIL_NONE ){\n      cksum ^= sqlite3Fts5IndexEntryCksum(rowid, 0, 0, iIdx, z, n);\n    }else{\n      Fts5PoslistReader sReader;\n      for(sqlite3Fts5PoslistReaderInit(pIter->pData, pIter->nData, &sReader);\n          sReader.bEof==0;\n          sqlite3Fts5PoslistReaderNext(&sReader)\n      ){\n        int iCol = FTS5_POS2COLUMN(sReader.iPos);\n        int iOff = FTS5_POS2OFFSET(sReader.iPos);\n        cksum ^= sqlite3Fts5IndexEntryCksum(rowid, iCol, iOff, iIdx, z, n);\n      }\n    }\n    if( rc==SQLITE_OK ){\n      rc = sqlite3Fts5IterNext(pIter);\n    }\n  }\n  sqlite3Fts5IterClose(pIter);\n\n  *pCksum = cksum;\n  return rc;\n}\n\n\n/*\n** This function is also purely an internal test. It does not contribute to \n** FTS functionality, or even the integrity-check, in any way.\n*/\nstatic void fts5TestTerm(\n  Fts5Index *p, \n  Fts5Buffer *pPrev,              /* Previous term */\n  const char *z, int n,           /* Possibly new term to test */\n  u64 expected,\n  u64 *pCksum\n){\n  int rc = p->rc;\n  if( pPrev->n==0 ){\n    fts5BufferSet(&rc, pPrev, n, (const u8*)z);\n  }else\n  if( rc==SQLITE_OK && (pPrev->n!=n || memcmp(pPrev->p, z, n)) ){\n    u64 cksum3 = *pCksum;\n    const char *zTerm = (const char*)&pPrev->p[1];  /* term sans prefix-byte */\n    int nTerm = pPrev->n-1;            /* Size of zTerm in bytes */\n    int iIdx = (pPrev->p[0] - FTS5_MAIN_PREFIX);\n    int flags = (iIdx==0 ? 0 : FTS5INDEX_QUERY_PREFIX);\n    u64 ck1 = 0;\n    u64 ck2 = 0;\n\n    /* Check that the results returned for ASC and DESC queries are\n    ** the same. If not, call this corruption.  */\n    rc = fts5QueryCksum(p, iIdx, zTerm, nTerm, flags, &ck1);\n    if( rc==SQLITE_OK ){\n      int f = flags|FTS5INDEX_QUERY_DESC;\n      rc = fts5QueryCksum(p, iIdx, zTerm, nTerm, f, &ck2);\n    }\n    if( rc==SQLITE_OK && ck1!=ck2 ) rc = FTS5_CORRUPT;\n\n    /* If this is a prefix query, check that the results returned if the\n    ** the index is disabled are the same. In both ASC and DESC order. \n    **\n    ** This check may only be performed if the hash table is empty. This\n    ** is because the hash table only supports a single scan query at\n    ** a time, and the multi-iter loop from which this function is called\n    ** is already performing such a scan. */\n    if( p->nPendingData==0 ){\n      if( iIdx>0 && rc==SQLITE_OK ){\n        int f = flags|FTS5INDEX_QUERY_TEST_NOIDX;\n        ck2 = 0;\n        rc = fts5QueryCksum(p, iIdx, zTerm, nTerm, f, &ck2);\n        if( rc==SQLITE_OK && ck1!=ck2 ) rc = FTS5_CORRUPT;\n      }\n      if( iIdx>0 && rc==SQLITE_OK ){\n        int f = flags|FTS5INDEX_QUERY_TEST_NOIDX|FTS5INDEX_QUERY_DESC;\n        ck2 = 0;\n        rc = fts5QueryCksum(p, iIdx, zTerm, nTerm, f, &ck2);\n        if( rc==SQLITE_OK && ck1!=ck2 ) rc = FTS5_CORRUPT;\n      }\n    }\n\n    cksum3 ^= ck1;\n    fts5BufferSet(&rc, pPrev, n, (const u8*)z);\n\n    if( rc==SQLITE_OK && cksum3!=expected ){\n      rc = FTS5_CORRUPT;\n    }\n    *pCksum = cksum3;\n  }\n  p->rc = rc;\n}\n \n#else\n# define fts5TestDlidxReverse(x,y,z)\n# define fts5TestTerm(u,v,w,x,y,z)\n#endif\n\n/*\n** Check that:\n**\n**   1) All leaves of pSeg between iFirst and iLast (inclusive) exist and\n**      contain zero terms.\n**   2) All leaves of pSeg between iNoRowid and iLast (inclusive) exist and\n**      contain zero rowids.\n*/\nstatic void fts5IndexIntegrityCheckEmpty(\n  Fts5Index *p,\n  Fts5StructureSegment *pSeg,     /* Segment to check internal consistency */\n  int iFirst,\n  int iNoRowid,\n  int iLast\n){\n  int i;\n\n  /* Now check that the iter.nEmpty leaves following the current leaf\n  ** (a) exist and (b) contain no terms. */\n  for(i=iFirst; p->rc==SQLITE_OK && i<=iLast; i++){\n    Fts5Data *pLeaf = fts5DataRead(p, FTS5_SEGMENT_ROWID(pSeg->iSegid, i));\n    if( pLeaf ){\n      if( !fts5LeafIsTermless(pLeaf) ) p->rc = FTS5_CORRUPT;\n      if( i>=iNoRowid && 0!=fts5LeafFirstRowidOff(pLeaf) ) p->rc = FTS5_CORRUPT;\n    }\n    fts5DataRelease(pLeaf);\n  }\n}\n\nstatic void fts5IntegrityCheckPgidx(Fts5Index *p, Fts5Data *pLeaf){\n  int iTermOff = 0;\n  int ii;\n\n  Fts5Buffer buf1 = {0,0,0};\n  Fts5Buffer buf2 = {0,0,0};\n\n  ii = pLeaf->szLeaf;\n  while( ii<pLeaf->nn && p->rc==SQLITE_OK ){\n    int res;\n    int iOff;\n    int nIncr;\n\n    ii += fts5GetVarint32(&pLeaf->p[ii], nIncr);\n    iTermOff += nIncr;\n    iOff = iTermOff;\n\n    if( iOff>=pLeaf->szLeaf ){\n      p->rc = FTS5_CORRUPT;\n    }else if( iTermOff==nIncr ){\n      int nByte;\n      iOff += fts5GetVarint32(&pLeaf->p[iOff], nByte);\n      if( (iOff+nByte)>pLeaf->szLeaf ){\n        p->rc = FTS5_CORRUPT;\n      }else{\n        fts5BufferSet(&p->rc, &buf1, nByte, &pLeaf->p[iOff]);\n      }\n    }else{\n      int nKeep, nByte;\n      iOff += fts5GetVarint32(&pLeaf->p[iOff], nKeep);\n      iOff += fts5GetVarint32(&pLeaf->p[iOff], nByte);\n      if( nKeep>buf1.n || (iOff+nByte)>pLeaf->szLeaf ){\n        p->rc = FTS5_CORRUPT;\n      }else{\n        buf1.n = nKeep;\n        fts5BufferAppendBlob(&p->rc, &buf1, nByte, &pLeaf->p[iOff]);\n      }\n\n      if( p->rc==SQLITE_OK ){\n        res = fts5BufferCompare(&buf1, &buf2);\n        if( res<=0 ) p->rc = FTS5_CORRUPT;\n      }\n    }\n    fts5BufferSet(&p->rc, &buf2, buf1.n, buf1.p);\n  }\n\n  fts5BufferFree(&buf1);\n  fts5BufferFree(&buf2);\n}\n\nstatic void fts5IndexIntegrityCheckSegment(\n  Fts5Index *p,                   /* FTS5 backend object */\n  Fts5StructureSegment *pSeg      /* Segment to check internal consistency */\n){\n  Fts5Config *pConfig = p->pConfig;\n  sqlite3_stmt *pStmt = 0;\n  int rc2;\n  int iIdxPrevLeaf = pSeg->pgnoFirst-1;\n  int iDlidxPrevLeaf = pSeg->pgnoLast;\n\n  if( pSeg->pgnoFirst==0 ) return;\n\n  fts5IndexPrepareStmt(p, &pStmt, sqlite3_mprintf(\n      \"SELECT segid, term, (pgno>>1), (pgno&1) FROM %Q.'%q_idx' WHERE segid=%d\",\n      pConfig->zDb, pConfig->zName, pSeg->iSegid\n  ));\n\n  /* Iterate through the b-tree hierarchy.  */\n  while( p->rc==SQLITE_OK && SQLITE_ROW==sqlite3_step(pStmt) ){\n    i64 iRow;                     /* Rowid for this leaf */\n    Fts5Data *pLeaf;              /* Data for this leaf */\n\n    int nIdxTerm = sqlite3_column_bytes(pStmt, 1);\n    const char *zIdxTerm = (const char*)sqlite3_column_text(pStmt, 1);\n    int iIdxLeaf = sqlite3_column_int(pStmt, 2);\n    int bIdxDlidx = sqlite3_column_int(pStmt, 3);\n\n    /* If the leaf in question has already been trimmed from the segment, \n    ** ignore this b-tree entry. Otherwise, load it into memory. */\n    if( iIdxLeaf<pSeg->pgnoFirst ) continue;\n    iRow = FTS5_SEGMENT_ROWID(pSeg->iSegid, iIdxLeaf);\n    pLeaf = fts5LeafRead(p, iRow);\n    if( pLeaf==0 ) break;\n\n    /* Check that the leaf contains at least one term, and that it is equal\n    ** to or larger than the split-key in zIdxTerm.  Also check that if there\n    ** is also a rowid pointer within the leaf page header, it points to a\n    ** location before the term.  */\n    if( pLeaf->nn<=pLeaf->szLeaf ){\n      p->rc = FTS5_CORRUPT;\n    }else{\n      int iOff;                   /* Offset of first term on leaf */\n      int iRowidOff;              /* Offset of first rowid on leaf */\n      int nTerm;                  /* Size of term on leaf in bytes */\n      int res;                    /* Comparison of term and split-key */\n\n      iOff = fts5LeafFirstTermOff(pLeaf);\n      iRowidOff = fts5LeafFirstRowidOff(pLeaf);\n      if( iRowidOff>=iOff || iOff>=pLeaf->szLeaf ){\n        p->rc = FTS5_CORRUPT;\n      }else{\n        iOff += fts5GetVarint32(&pLeaf->p[iOff], nTerm);\n        res = fts5Memcmp(&pLeaf->p[iOff], zIdxTerm, MIN(nTerm, nIdxTerm));\n        if( res==0 ) res = nTerm - nIdxTerm;\n        if( res<0 ) p->rc = FTS5_CORRUPT;\n      }\n\n      fts5IntegrityCheckPgidx(p, pLeaf);\n    }\n    fts5DataRelease(pLeaf);\n    if( p->rc ) break;\n\n    /* Now check that the iter.nEmpty leaves following the current leaf\n    ** (a) exist and (b) contain no terms. */\n    fts5IndexIntegrityCheckEmpty(\n        p, pSeg, iIdxPrevLeaf+1, iDlidxPrevLeaf+1, iIdxLeaf-1\n    );\n    if( p->rc ) break;\n\n    /* If there is a doclist-index, check that it looks right. */\n    if( bIdxDlidx ){\n      Fts5DlidxIter *pDlidx = 0;  /* For iterating through doclist index */\n      int iPrevLeaf = iIdxLeaf;\n      int iSegid = pSeg->iSegid;\n      int iPg = 0;\n      i64 iKey;\n\n      for(pDlidx=fts5DlidxIterInit(p, 0, iSegid, iIdxLeaf);\n          fts5DlidxIterEof(p, pDlidx)==0;\n          fts5DlidxIterNext(p, pDlidx)\n      ){\n\n        /* Check any rowid-less pages that occur before the current leaf. */\n        for(iPg=iPrevLeaf+1; iPg<fts5DlidxIterPgno(pDlidx); iPg++){\n          iKey = FTS5_SEGMENT_ROWID(iSegid, iPg);\n          pLeaf = fts5DataRead(p, iKey);\n          if( pLeaf ){\n            if( fts5LeafFirstRowidOff(pLeaf)!=0 ) p->rc = FTS5_CORRUPT;\n            fts5DataRelease(pLeaf);\n          }\n        }\n        iPrevLeaf = fts5DlidxIterPgno(pDlidx);\n\n        /* Check that the leaf page indicated by the iterator really does\n        ** contain the rowid suggested by the same. */\n        iKey = FTS5_SEGMENT_ROWID(iSegid, iPrevLeaf);\n        pLeaf = fts5DataRead(p, iKey);\n        if( pLeaf ){\n          i64 iRowid;\n          int iRowidOff = fts5LeafFirstRowidOff(pLeaf);\n          ASSERT_SZLEAF_OK(pLeaf);\n          if( iRowidOff>=pLeaf->szLeaf ){\n            p->rc = FTS5_CORRUPT;\n          }else{\n            fts5GetVarint(&pLeaf->p[iRowidOff], (u64*)&iRowid);\n            if( iRowid!=fts5DlidxIterRowid(pDlidx) ) p->rc = FTS5_CORRUPT;\n          }\n          fts5DataRelease(pLeaf);\n        }\n      }\n\n      iDlidxPrevLeaf = iPg;\n      fts5DlidxIterFree(pDlidx);\n      fts5TestDlidxReverse(p, iSegid, iIdxLeaf);\n    }else{\n      iDlidxPrevLeaf = pSeg->pgnoLast;\n      /* TODO: Check there is no doclist index */\n    }\n\n    iIdxPrevLeaf = iIdxLeaf;\n  }\n\n  rc2 = sqlite3_finalize(pStmt);\n  if( p->rc==SQLITE_OK ) p->rc = rc2;\n\n  /* Page iter.iLeaf must now be the rightmost leaf-page in the segment */\n#if 0\n  if( p->rc==SQLITE_OK && iter.iLeaf!=pSeg->pgnoLast ){\n    p->rc = FTS5_CORRUPT;\n  }\n#endif\n}\n\n\n/*\n** Run internal checks to ensure that the FTS index (a) is internally \n** consistent and (b) contains entries for which the XOR of the checksums\n** as calculated by sqlite3Fts5IndexEntryCksum() is cksum.\n**\n** Return SQLITE_CORRUPT if any of the internal checks fail, or if the\n** checksum does not match. Return SQLITE_OK if all checks pass without\n** error, or some other SQLite error code if another error (e.g. OOM)\n** occurs.\n*/\nstatic int sqlite3Fts5IndexIntegrityCheck(Fts5Index *p, u64 cksum){\n  int eDetail = p->pConfig->eDetail;\n  u64 cksum2 = 0;                 /* Checksum based on contents of indexes */\n  Fts5Buffer poslist = {0,0,0};   /* Buffer used to hold a poslist */\n  Fts5Iter *pIter;                /* Used to iterate through entire index */\n  Fts5Structure *pStruct;         /* Index structure */\n\n#ifdef SQLITE_DEBUG\n  /* Used by extra internal tests only run if NDEBUG is not defined */\n  u64 cksum3 = 0;                 /* Checksum based on contents of indexes */\n  Fts5Buffer term = {0,0,0};      /* Buffer used to hold most recent term */\n#endif\n  const int flags = FTS5INDEX_QUERY_NOOUTPUT;\n  \n  /* Load the FTS index structure */\n  pStruct = fts5StructureRead(p);\n\n  /* Check that the internal nodes of each segment match the leaves */\n  if( pStruct ){\n    int iLvl, iSeg;\n    for(iLvl=0; iLvl<pStruct->nLevel; iLvl++){\n      for(iSeg=0; iSeg<pStruct->aLevel[iLvl].nSeg; iSeg++){\n        Fts5StructureSegment *pSeg = &pStruct->aLevel[iLvl].aSeg[iSeg];\n        fts5IndexIntegrityCheckSegment(p, pSeg);\n      }\n    }\n  }\n\n  /* The cksum argument passed to this function is a checksum calculated\n  ** based on all expected entries in the FTS index (including prefix index\n  ** entries). This block checks that a checksum calculated based on the\n  ** actual contents of FTS index is identical.\n  **\n  ** Two versions of the same checksum are calculated. The first (stack\n  ** variable cksum2) based on entries extracted from the full-text index\n  ** while doing a linear scan of each individual index in turn. \n  **\n  ** As each term visited by the linear scans, a separate query for the\n  ** same term is performed. cksum3 is calculated based on the entries\n  ** extracted by these queries.\n  */\n  for(fts5MultiIterNew(p, pStruct, flags, 0, 0, 0, -1, 0, &pIter);\n      fts5MultiIterEof(p, pIter)==0;\n      fts5MultiIterNext(p, pIter, 0, 0)\n  ){\n    int n;                      /* Size of term in bytes */\n    i64 iPos = 0;               /* Position read from poslist */\n    int iOff = 0;               /* Offset within poslist */\n    i64 iRowid = fts5MultiIterRowid(pIter);\n    char *z = (char*)fts5MultiIterTerm(pIter, &n);\n\n    /* If this is a new term, query for it. Update cksum3 with the results. */\n    fts5TestTerm(p, &term, z, n, cksum2, &cksum3);\n\n    if( eDetail==FTS5_DETAIL_NONE ){\n      if( 0==fts5MultiIterIsEmpty(p, pIter) ){\n        cksum2 ^= sqlite3Fts5IndexEntryCksum(iRowid, 0, 0, -1, z, n);\n      }\n    }else{\n      poslist.n = 0;\n      fts5SegiterPoslist(p, &pIter->aSeg[pIter->aFirst[1].iFirst], 0, &poslist);\n      while( 0==sqlite3Fts5PoslistNext64(poslist.p, poslist.n, &iOff, &iPos) ){\n        int iCol = FTS5_POS2COLUMN(iPos);\n        int iTokOff = FTS5_POS2OFFSET(iPos);\n        cksum2 ^= sqlite3Fts5IndexEntryCksum(iRowid, iCol, iTokOff, -1, z, n);\n      }\n    }\n  }\n  fts5TestTerm(p, &term, 0, 0, cksum2, &cksum3);\n\n  fts5MultiIterFree(pIter);\n  if( p->rc==SQLITE_OK && cksum!=cksum2 ) p->rc = FTS5_CORRUPT;\n\n  fts5StructureRelease(pStruct);\n#ifdef SQLITE_DEBUG\n  fts5BufferFree(&term);\n#endif\n  fts5BufferFree(&poslist);\n  return fts5IndexReturn(p);\n}\n\n/*************************************************************************\n**************************************************************************\n** Below this point is the implementation of the fts5_decode() scalar\n** function only.\n*/\n\n/*\n** Decode a segment-data rowid from the %_data table. This function is\n** the opposite of macro FTS5_SEGMENT_ROWID().\n*/\nstatic void fts5DecodeRowid(\n  i64 iRowid,                     /* Rowid from %_data table */\n  int *piSegid,                   /* OUT: Segment id */\n  int *pbDlidx,                   /* OUT: Dlidx flag */\n  int *piHeight,                  /* OUT: Height */\n  int *piPgno                     /* OUT: Page number */\n){\n  *piPgno = (int)(iRowid & (((i64)1 << FTS5_DATA_PAGE_B) - 1));\n  iRowid >>= FTS5_DATA_PAGE_B;\n\n  *piHeight = (int)(iRowid & (((i64)1 << FTS5_DATA_HEIGHT_B) - 1));\n  iRowid >>= FTS5_DATA_HEIGHT_B;\n\n  *pbDlidx = (int)(iRowid & 0x0001);\n  iRowid >>= FTS5_DATA_DLI_B;\n\n  *piSegid = (int)(iRowid & (((i64)1 << FTS5_DATA_ID_B) - 1));\n}\n\nstatic void fts5DebugRowid(int *pRc, Fts5Buffer *pBuf, i64 iKey){\n  int iSegid, iHeight, iPgno, bDlidx;       /* Rowid compenents */\n  fts5DecodeRowid(iKey, &iSegid, &bDlidx, &iHeight, &iPgno);\n\n  if( iSegid==0 ){\n    if( iKey==FTS5_AVERAGES_ROWID ){\n      sqlite3Fts5BufferAppendPrintf(pRc, pBuf, \"{averages} \");\n    }else{\n      sqlite3Fts5BufferAppendPrintf(pRc, pBuf, \"{structure}\");\n    }\n  }\n  else{\n    sqlite3Fts5BufferAppendPrintf(pRc, pBuf, \"{%ssegid=%d h=%d pgno=%d}\",\n        bDlidx ? \"dlidx \" : \"\", iSegid, iHeight, iPgno\n    );\n  }\n}\n\nstatic void fts5DebugStructure(\n  int *pRc,                       /* IN/OUT: error code */\n  Fts5Buffer *pBuf,\n  Fts5Structure *p\n){\n  int iLvl, iSeg;                 /* Iterate through levels, segments */\n\n  for(iLvl=0; iLvl<p->nLevel; iLvl++){\n    Fts5StructureLevel *pLvl = &p->aLevel[iLvl];\n    sqlite3Fts5BufferAppendPrintf(pRc, pBuf, \n        \" {lvl=%d nMerge=%d nSeg=%d\", iLvl, pLvl->nMerge, pLvl->nSeg\n    );\n    for(iSeg=0; iSeg<pLvl->nSeg; iSeg++){\n      Fts5StructureSegment *pSeg = &pLvl->aSeg[iSeg];\n      sqlite3Fts5BufferAppendPrintf(pRc, pBuf, \" {id=%d leaves=%d..%d}\", \n          pSeg->iSegid, pSeg->pgnoFirst, pSeg->pgnoLast\n      );\n    }\n    sqlite3Fts5BufferAppendPrintf(pRc, pBuf, \"}\");\n  }\n}\n\n/*\n** This is part of the fts5_decode() debugging aid.\n**\n** Arguments pBlob/nBlob contain a serialized Fts5Structure object. This\n** function appends a human-readable representation of the same object\n** to the buffer passed as the second argument. \n*/\nstatic void fts5DecodeStructure(\n  int *pRc,                       /* IN/OUT: error code */\n  Fts5Buffer *pBuf,\n  const u8 *pBlob, int nBlob\n){\n  int rc;                         /* Return code */\n  Fts5Structure *p = 0;           /* Decoded structure object */\n\n  rc = fts5StructureDecode(pBlob, nBlob, 0, &p);\n  if( rc!=SQLITE_OK ){\n    *pRc = rc;\n    return;\n  }\n\n  fts5DebugStructure(pRc, pBuf, p);\n  fts5StructureRelease(p);\n}\n\n/*\n** This is part of the fts5_decode() debugging aid.\n**\n** Arguments pBlob/nBlob contain an \"averages\" record. This function \n** appends a human-readable representation of record to the buffer passed \n** as the second argument. \n*/\nstatic void fts5DecodeAverages(\n  int *pRc,                       /* IN/OUT: error code */\n  Fts5Buffer *pBuf,\n  const u8 *pBlob, int nBlob\n){\n  int i = 0;\n  const char *zSpace = \"\";\n\n  while( i<nBlob ){\n    u64 iVal;\n    i += sqlite3Fts5GetVarint(&pBlob[i], &iVal);\n    sqlite3Fts5BufferAppendPrintf(pRc, pBuf, \"%s%d\", zSpace, (int)iVal);\n    zSpace = \" \";\n  }\n}\n\n/*\n** Buffer (a/n) is assumed to contain a list of serialized varints. Read\n** each varint and append its string representation to buffer pBuf. Return\n** after either the input buffer is exhausted or a 0 value is read.\n**\n** The return value is the number of bytes read from the input buffer.\n*/\nstatic int fts5DecodePoslist(int *pRc, Fts5Buffer *pBuf, const u8 *a, int n){\n  int iOff = 0;\n  while( iOff<n ){\n    int iVal;\n    iOff += fts5GetVarint32(&a[iOff], iVal);\n    sqlite3Fts5BufferAppendPrintf(pRc, pBuf, \" %d\", iVal);\n  }\n  return iOff;\n}\n\n/*\n** The start of buffer (a/n) contains the start of a doclist. The doclist\n** may or may not finish within the buffer. This function appends a text\n** representation of the part of the doclist that is present to buffer\n** pBuf. \n**\n** The return value is the number of bytes read from the input buffer.\n*/\nstatic int fts5DecodeDoclist(int *pRc, Fts5Buffer *pBuf, const u8 *a, int n){\n  i64 iDocid = 0;\n  int iOff = 0;\n\n  if( n>0 ){\n    iOff = sqlite3Fts5GetVarint(a, (u64*)&iDocid);\n    sqlite3Fts5BufferAppendPrintf(pRc, pBuf, \" id=%lld\", iDocid);\n  }\n  while( iOff<n ){\n    int nPos;\n    int bDel;\n    iOff += fts5GetPoslistSize(&a[iOff], &nPos, &bDel);\n    sqlite3Fts5BufferAppendPrintf(pRc, pBuf, \" nPos=%d%s\", nPos, bDel?\"*\":\"\");\n    iOff += fts5DecodePoslist(pRc, pBuf, &a[iOff], MIN(n-iOff, nPos));\n    if( iOff<n ){\n      i64 iDelta;\n      iOff += sqlite3Fts5GetVarint(&a[iOff], (u64*)&iDelta);\n      iDocid += iDelta;\n      sqlite3Fts5BufferAppendPrintf(pRc, pBuf, \" id=%lld\", iDocid);\n    }\n  }\n\n  return iOff;\n}\n\n/*\n** This function is part of the fts5_decode() debugging function. It is \n** only ever used with detail=none tables.\n**\n** Buffer (pData/nData) contains a doclist in the format used by detail=none\n** tables. This function appends a human-readable version of that list to\n** buffer pBuf.\n**\n** If *pRc is other than SQLITE_OK when this function is called, it is a\n** no-op. If an OOM or other error occurs within this function, *pRc is\n** set to an SQLite error code before returning. The final state of buffer\n** pBuf is undefined in this case.\n*/\nstatic void fts5DecodeRowidList(\n  int *pRc,                       /* IN/OUT: Error code */\n  Fts5Buffer *pBuf,               /* Buffer to append text to */\n  const u8 *pData, int nData      /* Data to decode list-of-rowids from */\n){\n  int i = 0;\n  i64 iRowid = 0;\n\n  while( i<nData ){\n    const char *zApp = \"\";\n    u64 iVal;\n    i += sqlite3Fts5GetVarint(&pData[i], &iVal);\n    iRowid += iVal;\n\n    if( i<nData && pData[i]==0x00 ){\n      i++;\n      if( i<nData && pData[i]==0x00 ){\n        i++;\n        zApp = \"+\";\n      }else{\n        zApp = \"*\";\n      }\n    }\n\n    sqlite3Fts5BufferAppendPrintf(pRc, pBuf, \" %lld%s\", iRowid, zApp);\n  }\n}\n\n/*\n** The implementation of user-defined scalar function fts5_decode().\n*/\nstatic void fts5DecodeFunction(\n  sqlite3_context *pCtx,          /* Function call context */\n  int nArg,                       /* Number of args (always 2) */\n  sqlite3_value **apVal           /* Function arguments */\n){\n  i64 iRowid;                     /* Rowid for record being decoded */\n  int iSegid,iHeight,iPgno,bDlidx;/* Rowid components */\n  const u8 *aBlob; int n;         /* Record to decode */\n  u8 *a = 0;\n  Fts5Buffer s;                   /* Build up text to return here */\n  int rc = SQLITE_OK;             /* Return code */\n  sqlite3_int64 nSpace = 0;\n  int eDetailNone = (sqlite3_user_data(pCtx)!=0);\n\n  assert( nArg==2 );\n  UNUSED_PARAM(nArg);\n  memset(&s, 0, sizeof(Fts5Buffer));\n  iRowid = sqlite3_value_int64(apVal[0]);\n\n  /* Make a copy of the second argument (a blob) in aBlob[]. The aBlob[]\n  ** copy is followed by FTS5_DATA_ZERO_PADDING 0x00 bytes, which prevents\n  ** buffer overreads even if the record is corrupt.  */\n  n = sqlite3_value_bytes(apVal[1]);\n  aBlob = sqlite3_value_blob(apVal[1]);\n  nSpace = n + FTS5_DATA_ZERO_PADDING;\n  a = (u8*)sqlite3Fts5MallocZero(&rc, nSpace);\n  if( a==0 ) goto decode_out;\n  if( n>0 ) memcpy(a, aBlob, n);\n\n  fts5DecodeRowid(iRowid, &iSegid, &bDlidx, &iHeight, &iPgno);\n\n  fts5DebugRowid(&rc, &s, iRowid);\n  if( bDlidx ){\n    Fts5Data dlidx;\n    Fts5DlidxLvl lvl;\n\n    dlidx.p = a;\n    dlidx.nn = n;\n\n    memset(&lvl, 0, sizeof(Fts5DlidxLvl));\n    lvl.pData = &dlidx;\n    lvl.iLeafPgno = iPgno;\n\n    for(fts5DlidxLvlNext(&lvl); lvl.bEof==0; fts5DlidxLvlNext(&lvl)){\n      sqlite3Fts5BufferAppendPrintf(&rc, &s, \n          \" %d(%lld)\", lvl.iLeafPgno, lvl.iRowid\n      );\n    }\n  }else if( iSegid==0 ){\n    if( iRowid==FTS5_AVERAGES_ROWID ){\n      fts5DecodeAverages(&rc, &s, a, n);\n    }else{\n      fts5DecodeStructure(&rc, &s, a, n);\n    }\n  }else if( eDetailNone ){\n    Fts5Buffer term;              /* Current term read from page */\n    int szLeaf;\n    int iPgidxOff = szLeaf = fts5GetU16(&a[2]);\n    int iTermOff;\n    int nKeep = 0;\n    int iOff;\n\n    memset(&term, 0, sizeof(Fts5Buffer));\n\n    /* Decode any entries that occur before the first term. */\n    if( szLeaf<n ){\n      iPgidxOff += fts5GetVarint32(&a[iPgidxOff], iTermOff);\n    }else{\n      iTermOff = szLeaf;\n    }\n    fts5DecodeRowidList(&rc, &s, &a[4], iTermOff-4);\n\n    iOff = iTermOff;\n    while( iOff<szLeaf ){\n      int nAppend;\n\n      /* Read the term data for the next term*/\n      iOff += fts5GetVarint32(&a[iOff], nAppend);\n      term.n = nKeep;\n      fts5BufferAppendBlob(&rc, &term, nAppend, &a[iOff]);\n      sqlite3Fts5BufferAppendPrintf(\n          &rc, &s, \" term=%.*s\", term.n, (const char*)term.p\n      );\n      iOff += nAppend;\n\n      /* Figure out where the doclist for this term ends */\n      if( iPgidxOff<n ){\n        int nIncr;\n        iPgidxOff += fts5GetVarint32(&a[iPgidxOff], nIncr);\n        iTermOff += nIncr;\n      }else{\n        iTermOff = szLeaf;\n      }\n\n      fts5DecodeRowidList(&rc, &s, &a[iOff], iTermOff-iOff);\n      iOff = iTermOff;\n      if( iOff<szLeaf ){\n        iOff += fts5GetVarint32(&a[iOff], nKeep);\n      }\n    }\n\n    fts5BufferFree(&term);\n  }else{\n    Fts5Buffer term;              /* Current term read from page */\n    int szLeaf;                   /* Offset of pgidx in a[] */\n    int iPgidxOff;\n    int iPgidxPrev = 0;           /* Previous value read from pgidx */\n    int iTermOff = 0;\n    int iRowidOff = 0;\n    int iOff;\n    int nDoclist;\n\n    memset(&term, 0, sizeof(Fts5Buffer));\n\n    if( n<4 ){\n      sqlite3Fts5BufferSet(&rc, &s, 7, (const u8*)\"corrupt\");\n      goto decode_out;\n    }else{\n      iRowidOff = fts5GetU16(&a[0]);\n      iPgidxOff = szLeaf = fts5GetU16(&a[2]);\n      if( iPgidxOff<n ){\n        fts5GetVarint32(&a[iPgidxOff], iTermOff);\n      }else if( iPgidxOff>n ){\n        rc = FTS5_CORRUPT;\n        goto decode_out;\n      }\n    }\n\n    /* Decode the position list tail at the start of the page */\n    if( iRowidOff!=0 ){\n      iOff = iRowidOff;\n    }else if( iTermOff!=0 ){\n      iOff = iTermOff;\n    }else{\n      iOff = szLeaf;\n    }\n    if( iOff>n ){\n      rc = FTS5_CORRUPT;\n      goto decode_out;\n    }\n    fts5DecodePoslist(&rc, &s, &a[4], iOff-4);\n\n    /* Decode any more doclist data that appears on the page before the\n    ** first term. */\n    nDoclist = (iTermOff ? iTermOff : szLeaf) - iOff;\n    if( nDoclist+iOff>n ){\n      rc = FTS5_CORRUPT;\n      goto decode_out;\n    }\n    fts5DecodeDoclist(&rc, &s, &a[iOff], nDoclist);\n\n    while( iPgidxOff<n && rc==SQLITE_OK ){\n      int bFirst = (iPgidxOff==szLeaf);     /* True for first term on page */\n      int nByte;                            /* Bytes of data */\n      int iEnd;\n      \n      iPgidxOff += fts5GetVarint32(&a[iPgidxOff], nByte);\n      iPgidxPrev += nByte;\n      iOff = iPgidxPrev;\n\n      if( iPgidxOff<n ){\n        fts5GetVarint32(&a[iPgidxOff], nByte);\n        iEnd = iPgidxPrev + nByte;\n      }else{\n        iEnd = szLeaf;\n      }\n      if( iEnd>szLeaf ){\n        rc = FTS5_CORRUPT;\n        break;\n      }\n\n      if( bFirst==0 ){\n        iOff += fts5GetVarint32(&a[iOff], nByte);\n        if( nByte>term.n ){\n          rc = FTS5_CORRUPT;\n          break;\n        }\n        term.n = nByte;\n      }\n      iOff += fts5GetVarint32(&a[iOff], nByte);\n      if( iOff+nByte>n ){\n        rc = FTS5_CORRUPT;\n        break;\n      }\n      fts5BufferAppendBlob(&rc, &term, nByte, &a[iOff]);\n      iOff += nByte;\n\n      sqlite3Fts5BufferAppendPrintf(\n          &rc, &s, \" term=%.*s\", term.n, (const char*)term.p\n      );\n      iOff += fts5DecodeDoclist(&rc, &s, &a[iOff], iEnd-iOff);\n    }\n\n    fts5BufferFree(&term);\n  }\n  \n decode_out:\n  sqlite3_free(a);\n  if( rc==SQLITE_OK ){\n    sqlite3_result_text(pCtx, (const char*)s.p, s.n, SQLITE_TRANSIENT);\n  }else{\n    sqlite3_result_error_code(pCtx, rc);\n  }\n  fts5BufferFree(&s);\n}\n\n/*\n** The implementation of user-defined scalar function fts5_rowid().\n*/\nstatic void fts5RowidFunction(\n  sqlite3_context *pCtx,          /* Function call context */\n  int nArg,                       /* Number of args (always 2) */\n  sqlite3_value **apVal           /* Function arguments */\n){\n  const char *zArg;\n  if( nArg==0 ){\n    sqlite3_result_error(pCtx, \"should be: fts5_rowid(subject, ....)\", -1);\n  }else{\n    zArg = (const char*)sqlite3_value_text(apVal[0]);\n    if( 0==sqlite3_stricmp(zArg, \"segment\") ){\n      i64 iRowid;\n      int segid, pgno;\n      if( nArg!=3 ){\n        sqlite3_result_error(pCtx, \n            \"should be: fts5_rowid('segment', segid, pgno))\", -1\n        );\n      }else{\n        segid = sqlite3_value_int(apVal[1]);\n        pgno = sqlite3_value_int(apVal[2]);\n        iRowid = FTS5_SEGMENT_ROWID(segid, pgno);\n        sqlite3_result_int64(pCtx, iRowid);\n      }\n    }else{\n      sqlite3_result_error(pCtx, \n        \"first arg to fts5_rowid() must be 'segment'\" , -1\n      );\n    }\n  }\n}\n\n/*\n** This is called as part of registering the FTS5 module with database\n** connection db. It registers several user-defined scalar functions useful\n** with FTS5.\n**\n** If successful, SQLITE_OK is returned. If an error occurs, some other\n** SQLite error code is returned instead.\n*/\nstatic int sqlite3Fts5IndexInit(sqlite3 *db){\n  int rc = sqlite3_create_function(\n      db, \"fts5_decode\", 2, SQLITE_UTF8, 0, fts5DecodeFunction, 0, 0\n  );\n\n  if( rc==SQLITE_OK ){\n    rc = sqlite3_create_function(\n        db, \"fts5_decode_none\", 2, \n        SQLITE_UTF8, (void*)db, fts5DecodeFunction, 0, 0\n    );\n  }\n\n  if( rc==SQLITE_OK ){\n    rc = sqlite3_create_function(\n        db, \"fts5_rowid\", -1, SQLITE_UTF8, 0, fts5RowidFunction, 0, 0\n    );\n  }\n  return rc;\n}\n\n\nstatic int sqlite3Fts5IndexReset(Fts5Index *p){\n  assert( p->pStruct==0 || p->iStructVersion!=0 );\n  if( fts5IndexDataVersion(p)!=p->iStructVersion ){\n    fts5StructureInvalidate(p);\n  }\n  return fts5IndexReturn(p);\n}\n\n/*\n** 2014 Jun 09\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n******************************************************************************\n**\n** This is an SQLite module implementing full-text search.\n*/\n\n\n/* #include \"fts5Int.h\" */\n\n/*\n** This variable is set to false when running tests for which the on disk\n** structures should not be corrupt. Otherwise, true. If it is false, extra\n** assert() conditions in the fts5 code are activated - conditions that are\n** only true if it is guaranteed that the fts5 database is not corrupt.\n*/\nSQLITE_API int sqlite3_fts5_may_be_corrupt = 1;\n\n\ntypedef struct Fts5Auxdata Fts5Auxdata;\ntypedef struct Fts5Auxiliary Fts5Auxiliary;\ntypedef struct Fts5Cursor Fts5Cursor;\ntypedef struct Fts5FullTable Fts5FullTable;\ntypedef struct Fts5Sorter Fts5Sorter;\ntypedef struct Fts5TokenizerModule Fts5TokenizerModule;\n\n/*\n** NOTES ON TRANSACTIONS: \n**\n** SQLite invokes the following virtual table methods as transactions are \n** opened and closed by the user:\n**\n**     xBegin():    Start of a new transaction.\n**     xSync():     Initial part of two-phase commit.\n**     xCommit():   Final part of two-phase commit.\n**     xRollback(): Rollback the transaction.\n**\n** Anything that is required as part of a commit that may fail is performed\n** in the xSync() callback. Current versions of SQLite ignore any errors \n** returned by xCommit().\n**\n** And as sub-transactions are opened/closed:\n**\n**     xSavepoint(int S):  Open savepoint S.\n**     xRelease(int S):    Commit and close savepoint S.\n**     xRollbackTo(int S): Rollback to start of savepoint S.\n**\n** During a write-transaction the fts5_index.c module may cache some data \n** in-memory. It is flushed to disk whenever xSync(), xRelease() or\n** xSavepoint() is called. And discarded whenever xRollback() or xRollbackTo() \n** is called.\n**\n** Additionally, if SQLITE_DEBUG is defined, an instance of the following\n** structure is used to record the current transaction state. This information\n** is not required, but it is used in the assert() statements executed by\n** function fts5CheckTransactionState() (see below).\n*/\nstruct Fts5TransactionState {\n  int eState;                     /* 0==closed, 1==open, 2==synced */\n  int iSavepoint;                 /* Number of open savepoints (0 -> none) */\n};\n\n/*\n** A single object of this type is allocated when the FTS5 module is \n** registered with a database handle. It is used to store pointers to\n** all registered FTS5 extensions - tokenizers and auxiliary functions.\n*/\nstruct Fts5Global {\n  fts5_api api;                   /* User visible part of object (see fts5.h) */\n  sqlite3 *db;                    /* Associated database connection */ \n  i64 iNextId;                    /* Used to allocate unique cursor ids */\n  Fts5Auxiliary *pAux;            /* First in list of all aux. functions */\n  Fts5TokenizerModule *pTok;      /* First in list of all tokenizer modules */\n  Fts5TokenizerModule *pDfltTok;  /* Default tokenizer module */\n  Fts5Cursor *pCsr;               /* First in list of all open cursors */\n};\n\n/*\n** Each auxiliary function registered with the FTS5 module is represented\n** by an object of the following type. All such objects are stored as part\n** of the Fts5Global.pAux list.\n*/\nstruct Fts5Auxiliary {\n  Fts5Global *pGlobal;            /* Global context for this function */\n  char *zFunc;                    /* Function name (nul-terminated) */\n  void *pUserData;                /* User-data pointer */\n  fts5_extension_function xFunc;  /* Callback function */\n  void (*xDestroy)(void*);        /* Destructor function */\n  Fts5Auxiliary *pNext;           /* Next registered auxiliary function */\n};\n\n/*\n** Each tokenizer module registered with the FTS5 module is represented\n** by an object of the following type. All such objects are stored as part\n** of the Fts5Global.pTok list.\n*/\nstruct Fts5TokenizerModule {\n  char *zName;                    /* Name of tokenizer */\n  void *pUserData;                /* User pointer passed to xCreate() */\n  fts5_tokenizer x;               /* Tokenizer functions */\n  void (*xDestroy)(void*);        /* Destructor function */\n  Fts5TokenizerModule *pNext;     /* Next registered tokenizer module */\n};\n\nstruct Fts5FullTable {\n  Fts5Table p;                    /* Public class members from fts5Int.h */\n  Fts5Storage *pStorage;          /* Document store */\n  Fts5Global *pGlobal;            /* Global (connection wide) data */\n  Fts5Cursor *pSortCsr;           /* Sort data from this cursor */\n#ifdef SQLITE_DEBUG\n  struct Fts5TransactionState ts;\n#endif\n};\n\nstruct Fts5MatchPhrase {\n  Fts5Buffer *pPoslist;           /* Pointer to current poslist */\n  int nTerm;                      /* Size of phrase in terms */\n};\n\n/*\n** pStmt:\n**   SELECT rowid, <fts> FROM <fts> ORDER BY +rank;\n**\n** aIdx[]:\n**   There is one entry in the aIdx[] array for each phrase in the query,\n**   the value of which is the offset within aPoslist[] following the last \n**   byte of the position list for the corresponding phrase.\n*/\nstruct Fts5Sorter {\n  sqlite3_stmt *pStmt;\n  i64 iRowid;                     /* Current rowid */\n  const u8 *aPoslist;             /* Position lists for current row */\n  int nIdx;                       /* Number of entries in aIdx[] */\n  int aIdx[1];                    /* Offsets into aPoslist for current row */\n};\n\n\n/*\n** Virtual-table cursor object.\n**\n** iSpecial:\n**   If this is a 'special' query (refer to function fts5SpecialMatch()), \n**   then this variable contains the result of the query. \n**\n** iFirstRowid, iLastRowid:\n**   These variables are only used for FTS5_PLAN_MATCH cursors. Assuming the\n**   cursor iterates in ascending order of rowids, iFirstRowid is the lower\n**   limit of rowids to return, and iLastRowid the upper. In other words, the\n**   WHERE clause in the user's query might have been:\n**\n**       <tbl> MATCH <expr> AND rowid BETWEEN $iFirstRowid AND $iLastRowid\n**\n**   If the cursor iterates in descending order of rowid, iFirstRowid\n**   is the upper limit (i.e. the \"first\" rowid visited) and iLastRowid\n**   the lower.\n*/\nstruct Fts5Cursor {\n  sqlite3_vtab_cursor base;       /* Base class used by SQLite core */\n  Fts5Cursor *pNext;              /* Next cursor in Fts5Cursor.pCsr list */\n  int *aColumnSize;               /* Values for xColumnSize() */\n  i64 iCsrId;                     /* Cursor id */\n\n  /* Zero from this point onwards on cursor reset */\n  int ePlan;                      /* FTS5_PLAN_XXX value */\n  int bDesc;                      /* True for \"ORDER BY rowid DESC\" queries */\n  i64 iFirstRowid;                /* Return no rowids earlier than this */\n  i64 iLastRowid;                 /* Return no rowids later than this */\n  sqlite3_stmt *pStmt;            /* Statement used to read %_content */\n  Fts5Expr *pExpr;                /* Expression for MATCH queries */\n  Fts5Sorter *pSorter;            /* Sorter for \"ORDER BY rank\" queries */\n  int csrflags;                   /* Mask of cursor flags (see below) */\n  i64 iSpecial;                   /* Result of special query */\n\n  /* \"rank\" function. Populated on demand from vtab.xColumn(). */\n  char *zRank;                    /* Custom rank function */\n  char *zRankArgs;                /* Custom rank function args */\n  Fts5Auxiliary *pRank;           /* Rank callback (or NULL) */\n  int nRankArg;                   /* Number of trailing arguments for rank() */\n  sqlite3_value **apRankArg;      /* Array of trailing arguments */\n  sqlite3_stmt *pRankArgStmt;     /* Origin of objects in apRankArg[] */\n\n  /* Auxiliary data storage */\n  Fts5Auxiliary *pAux;            /* Currently executing extension function */\n  Fts5Auxdata *pAuxdata;          /* First in linked list of saved aux-data */\n\n  /* Cache used by auxiliary functions xInst() and xInstCount() */\n  Fts5PoslistReader *aInstIter;   /* One for each phrase */\n  int nInstAlloc;                 /* Size of aInst[] array (entries / 3) */\n  int nInstCount;                 /* Number of phrase instances */\n  int *aInst;                     /* 3 integers per phrase instance */\n};\n\n/*\n** Bits that make up the \"idxNum\" parameter passed indirectly by \n** xBestIndex() to xFilter().\n*/\n#define FTS5_BI_MATCH        0x0001         /* <tbl> MATCH ? */\n#define FTS5_BI_RANK         0x0002         /* rank MATCH ? */\n#define FTS5_BI_ROWID_EQ     0x0004         /* rowid == ? */\n#define FTS5_BI_ROWID_LE     0x0008         /* rowid <= ? */\n#define FTS5_BI_ROWID_GE     0x0010         /* rowid >= ? */\n\n#define FTS5_BI_ORDER_RANK   0x0020\n#define FTS5_BI_ORDER_ROWID  0x0040\n#define FTS5_BI_ORDER_DESC   0x0080\n\n/*\n** Values for Fts5Cursor.csrflags\n*/\n#define FTS5CSR_EOF               0x01\n#define FTS5CSR_REQUIRE_CONTENT   0x02\n#define FTS5CSR_REQUIRE_DOCSIZE   0x04\n#define FTS5CSR_REQUIRE_INST      0x08\n#define FTS5CSR_FREE_ZRANK        0x10\n#define FTS5CSR_REQUIRE_RESEEK    0x20\n#define FTS5CSR_REQUIRE_POSLIST   0x40\n\n#define BitFlagAllTest(x,y) (((x) & (y))==(y))\n#define BitFlagTest(x,y)    (((x) & (y))!=0)\n\n\n/*\n** Macros to Set(), Clear() and Test() cursor flags.\n*/\n#define CsrFlagSet(pCsr, flag)   ((pCsr)->csrflags |= (flag))\n#define CsrFlagClear(pCsr, flag) ((pCsr)->csrflags &= ~(flag))\n#define CsrFlagTest(pCsr, flag)  ((pCsr)->csrflags & (flag))\n\nstruct Fts5Auxdata {\n  Fts5Auxiliary *pAux;            /* Extension to which this belongs */\n  void *pPtr;                     /* Pointer value */\n  void(*xDelete)(void*);          /* Destructor */\n  Fts5Auxdata *pNext;             /* Next object in linked list */\n};\n\n#ifdef SQLITE_DEBUG\n#define FTS5_BEGIN      1\n#define FTS5_SYNC       2\n#define FTS5_COMMIT     3\n#define FTS5_ROLLBACK   4\n#define FTS5_SAVEPOINT  5\n#define FTS5_RELEASE    6\n#define FTS5_ROLLBACKTO 7\nstatic void fts5CheckTransactionState(Fts5FullTable *p, int op, int iSavepoint){\n  switch( op ){\n    case FTS5_BEGIN:\n      assert( p->ts.eState==0 );\n      p->ts.eState = 1;\n      p->ts.iSavepoint = -1;\n      break;\n\n    case FTS5_SYNC:\n      assert( p->ts.eState==1 );\n      p->ts.eState = 2;\n      break;\n\n    case FTS5_COMMIT:\n      assert( p->ts.eState==2 );\n      p->ts.eState = 0;\n      break;\n\n    case FTS5_ROLLBACK:\n      assert( p->ts.eState==1 || p->ts.eState==2 || p->ts.eState==0 );\n      p->ts.eState = 0;\n      break;\n\n    case FTS5_SAVEPOINT:\n      assert( p->ts.eState==1 );\n      assert( iSavepoint>=0 );\n      assert( iSavepoint>=p->ts.iSavepoint );\n      p->ts.iSavepoint = iSavepoint;\n      break;\n      \n    case FTS5_RELEASE:\n      assert( p->ts.eState==1 );\n      assert( iSavepoint>=0 );\n      assert( iSavepoint<=p->ts.iSavepoint );\n      p->ts.iSavepoint = iSavepoint-1;\n      break;\n\n    case FTS5_ROLLBACKTO:\n      assert( p->ts.eState==1 );\n      assert( iSavepoint>=-1 );\n      assert( iSavepoint<=p->ts.iSavepoint );\n      p->ts.iSavepoint = iSavepoint;\n      break;\n  }\n}\n#else\n# define fts5CheckTransactionState(x,y,z)\n#endif\n\n/*\n** Return true if pTab is a contentless table.\n*/\nstatic int fts5IsContentless(Fts5FullTable *pTab){\n  return pTab->p.pConfig->eContent==FTS5_CONTENT_NONE;\n}\n\n/*\n** Delete a virtual table handle allocated by fts5InitVtab(). \n*/\nstatic void fts5FreeVtab(Fts5FullTable *pTab){\n  if( pTab ){\n    sqlite3Fts5IndexClose(pTab->p.pIndex);\n    sqlite3Fts5StorageClose(pTab->pStorage);\n    sqlite3Fts5ConfigFree(pTab->p.pConfig);\n    sqlite3_free(pTab);\n  }\n}\n\n/*\n** The xDisconnect() virtual table method.\n*/\nstatic int fts5DisconnectMethod(sqlite3_vtab *pVtab){\n  fts5FreeVtab((Fts5FullTable*)pVtab);\n  return SQLITE_OK;\n}\n\n/*\n** The xDestroy() virtual table method.\n*/\nstatic int fts5DestroyMethod(sqlite3_vtab *pVtab){\n  Fts5Table *pTab = (Fts5Table*)pVtab;\n  int rc = sqlite3Fts5DropAll(pTab->pConfig);\n  if( rc==SQLITE_OK ){\n    fts5FreeVtab((Fts5FullTable*)pVtab);\n  }\n  return rc;\n}\n\n/*\n** This function is the implementation of both the xConnect and xCreate\n** methods of the FTS3 virtual table.\n**\n** The argv[] array contains the following:\n**\n**   argv[0]   -> module name  (\"fts5\")\n**   argv[1]   -> database name\n**   argv[2]   -> table name\n**   argv[...] -> \"column name\" and other module argument fields.\n*/\nstatic int fts5InitVtab(\n  int bCreate,                    /* True for xCreate, false for xConnect */\n  sqlite3 *db,                    /* The SQLite database connection */\n  void *pAux,                     /* Hash table containing tokenizers */\n  int argc,                       /* Number of elements in argv array */\n  const char * const *argv,       /* xCreate/xConnect argument array */\n  sqlite3_vtab **ppVTab,          /* Write the resulting vtab structure here */\n  char **pzErr                    /* Write any error message here */\n){\n  Fts5Global *pGlobal = (Fts5Global*)pAux;\n  const char **azConfig = (const char**)argv;\n  int rc = SQLITE_OK;             /* Return code */\n  Fts5Config *pConfig = 0;        /* Results of parsing argc/argv */\n  Fts5FullTable *pTab = 0;        /* New virtual table object */\n\n  /* Allocate the new vtab object and parse the configuration */\n  pTab = (Fts5FullTable*)sqlite3Fts5MallocZero(&rc, sizeof(Fts5FullTable));\n  if( rc==SQLITE_OK ){\n    rc = sqlite3Fts5ConfigParse(pGlobal, db, argc, azConfig, &pConfig, pzErr);\n    assert( (rc==SQLITE_OK && *pzErr==0) || pConfig==0 );\n  }\n  if( rc==SQLITE_OK ){\n    pTab->p.pConfig = pConfig;\n    pTab->pGlobal = pGlobal;\n  }\n\n  /* Open the index sub-system */\n  if( rc==SQLITE_OK ){\n    rc = sqlite3Fts5IndexOpen(pConfig, bCreate, &pTab->p.pIndex, pzErr);\n  }\n\n  /* Open the storage sub-system */\n  if( rc==SQLITE_OK ){\n    rc = sqlite3Fts5StorageOpen(\n        pConfig, pTab->p.pIndex, bCreate, &pTab->pStorage, pzErr\n    );\n  }\n\n  /* Call sqlite3_declare_vtab() */\n  if( rc==SQLITE_OK ){\n    rc = sqlite3Fts5ConfigDeclareVtab(pConfig);\n  }\n\n  /* Load the initial configuration */\n  if( rc==SQLITE_OK ){\n    assert( pConfig->pzErrmsg==0 );\n    pConfig->pzErrmsg = pzErr;\n    rc = sqlite3Fts5IndexLoadConfig(pTab->p.pIndex);\n    sqlite3Fts5IndexRollback(pTab->p.pIndex);\n    pConfig->pzErrmsg = 0;\n  }\n\n  if( rc!=SQLITE_OK ){\n    fts5FreeVtab(pTab);\n    pTab = 0;\n  }else if( bCreate ){\n    fts5CheckTransactionState(pTab, FTS5_BEGIN, 0);\n  }\n  *ppVTab = (sqlite3_vtab*)pTab;\n  return rc;\n}\n\n/*\n** The xConnect() and xCreate() methods for the virtual table. All the\n** work is done in function fts5InitVtab().\n*/\nstatic int fts5ConnectMethod(\n  sqlite3 *db,                    /* Database connection */\n  void *pAux,                     /* Pointer to tokenizer hash table */\n  int argc,                       /* Number of elements in argv array */\n  const char * const *argv,       /* xCreate/xConnect argument array */\n  sqlite3_vtab **ppVtab,          /* OUT: New sqlite3_vtab object */\n  char **pzErr                    /* OUT: sqlite3_malloc'd error message */\n){\n  return fts5InitVtab(0, db, pAux, argc, argv, ppVtab, pzErr);\n}\nstatic int fts5CreateMethod(\n  sqlite3 *db,                    /* Database connection */\n  void *pAux,                     /* Pointer to tokenizer hash table */\n  int argc,                       /* Number of elements in argv array */\n  const char * const *argv,       /* xCreate/xConnect argument array */\n  sqlite3_vtab **ppVtab,          /* OUT: New sqlite3_vtab object */\n  char **pzErr                    /* OUT: sqlite3_malloc'd error message */\n){\n  return fts5InitVtab(1, db, pAux, argc, argv, ppVtab, pzErr);\n}\n\n/*\n** The different query plans.\n*/\n#define FTS5_PLAN_MATCH          1       /* (<tbl> MATCH ?) */\n#define FTS5_PLAN_SOURCE         2       /* A source cursor for SORTED_MATCH */\n#define FTS5_PLAN_SPECIAL        3       /* An internal query */\n#define FTS5_PLAN_SORTED_MATCH   4       /* (<tbl> MATCH ? ORDER BY rank) */\n#define FTS5_PLAN_SCAN           5       /* No usable constraint */\n#define FTS5_PLAN_ROWID          6       /* (rowid = ?) */\n\n/*\n** Set the SQLITE_INDEX_SCAN_UNIQUE flag in pIdxInfo->flags. Unless this\n** extension is currently being used by a version of SQLite too old to\n** support index-info flags. In that case this function is a no-op.\n*/\nstatic void fts5SetUniqueFlag(sqlite3_index_info *pIdxInfo){\n#if SQLITE_VERSION_NUMBER>=3008012\n#ifndef SQLITE_CORE\n  if( sqlite3_libversion_number()>=3008012 )\n#endif\n  {\n    pIdxInfo->idxFlags |= SQLITE_INDEX_SCAN_UNIQUE;\n  }\n#endif\n}\n\n/*\n** Implementation of the xBestIndex method for FTS5 tables. Within the \n** WHERE constraint, it searches for the following:\n**\n**   1. A MATCH constraint against the special column.\n**   2. A MATCH constraint against the \"rank\" column.\n**   3. An == constraint against the rowid column.\n**   4. A < or <= constraint against the rowid column.\n**   5. A > or >= constraint against the rowid column.\n**\n** Within the ORDER BY, either:\n**\n**   5. ORDER BY rank [ASC|DESC]\n**   6. ORDER BY rowid [ASC|DESC]\n**\n** Costs are assigned as follows:\n**\n**  a) If an unusable MATCH operator is present in the WHERE clause, the\n**     cost is unconditionally set to 1e50 (a really big number).\n**\n**  a) If a MATCH operator is present, the cost depends on the other\n**     constraints also present. As follows:\n**\n**       * No other constraints:         cost=1000.0\n**       * One rowid range constraint:   cost=750.0\n**       * Both rowid range constraints: cost=500.0\n**       * An == rowid constraint:       cost=100.0\n**\n**  b) Otherwise, if there is no MATCH:\n**\n**       * No other constraints:         cost=1000000.0\n**       * One rowid range constraint:   cost=750000.0\n**       * Both rowid range constraints: cost=250000.0\n**       * An == rowid constraint:       cost=10.0\n**\n** Costs are not modified by the ORDER BY clause.\n*/\nstatic int fts5BestIndexMethod(sqlite3_vtab *pVTab, sqlite3_index_info *pInfo){\n  Fts5Table *pTab = (Fts5Table*)pVTab;\n  Fts5Config *pConfig = pTab->pConfig;\n  const int nCol = pConfig->nCol;\n  int idxFlags = 0;               /* Parameter passed through to xFilter() */\n  int bHasMatch;\n  int iNext;\n  int i;\n\n  struct Constraint {\n    int op;                       /* Mask against sqlite3_index_constraint.op */\n    int fts5op;                   /* FTS5 mask for idxFlags */\n    int iCol;                     /* 0==rowid, 1==tbl, 2==rank */\n    int omit;                     /* True to omit this if found */\n    int iConsIndex;               /* Index in pInfo->aConstraint[] */\n  } aConstraint[] = {\n    {SQLITE_INDEX_CONSTRAINT_MATCH|SQLITE_INDEX_CONSTRAINT_EQ, \n                                    FTS5_BI_MATCH,    1, 1, -1},\n    {SQLITE_INDEX_CONSTRAINT_MATCH|SQLITE_INDEX_CONSTRAINT_EQ, \n                                    FTS5_BI_RANK,     2, 1, -1},\n    {SQLITE_INDEX_CONSTRAINT_EQ,    FTS5_BI_ROWID_EQ, 0, 0, -1},\n    {SQLITE_INDEX_CONSTRAINT_LT|SQLITE_INDEX_CONSTRAINT_LE, \n                                    FTS5_BI_ROWID_LE, 0, 0, -1},\n    {SQLITE_INDEX_CONSTRAINT_GT|SQLITE_INDEX_CONSTRAINT_GE, \n                                    FTS5_BI_ROWID_GE, 0, 0, -1},\n  };\n\n  int aColMap[3];\n  aColMap[0] = -1;\n  aColMap[1] = nCol;\n  aColMap[2] = nCol+1;\n\n  assert( SQLITE_INDEX_CONSTRAINT_EQ<SQLITE_INDEX_CONSTRAINT_MATCH );\n  assert( SQLITE_INDEX_CONSTRAINT_GT<SQLITE_INDEX_CONSTRAINT_MATCH );\n  assert( SQLITE_INDEX_CONSTRAINT_LE<SQLITE_INDEX_CONSTRAINT_MATCH );\n  assert( SQLITE_INDEX_CONSTRAINT_GE<SQLITE_INDEX_CONSTRAINT_MATCH );\n  assert( SQLITE_INDEX_CONSTRAINT_LE<SQLITE_INDEX_CONSTRAINT_MATCH );\n\n  /* Set idxFlags flags for all WHERE clause terms that will be used. */\n  for(i=0; i<pInfo->nConstraint; i++){\n    struct sqlite3_index_constraint *p = &pInfo->aConstraint[i];\n    int iCol = p->iColumn;\n\n    if( (p->op==SQLITE_INDEX_CONSTRAINT_MATCH && iCol>=0 && iCol<=nCol)\n     || (p->op==SQLITE_INDEX_CONSTRAINT_EQ && iCol==nCol)\n    ){\n      /* A MATCH operator or equivalent */\n      if( p->usable ){\n        idxFlags = (idxFlags & 0xFFFF) | FTS5_BI_MATCH | (iCol << 16);\n        aConstraint[0].iConsIndex = i;\n      }else{\n        /* As there exists an unusable MATCH constraint this is an \n        ** unusable plan. Set a prohibitively high cost. */\n        pInfo->estimatedCost = 1e50;\n        return SQLITE_OK;\n      }\n    }else if( p->op<=SQLITE_INDEX_CONSTRAINT_MATCH ){\n      int j;\n      for(j=1; j<ArraySize(aConstraint); j++){\n        struct Constraint *pC = &aConstraint[j];\n        if( iCol==aColMap[pC->iCol] && (p->op & pC->op) && p->usable ){\n          pC->iConsIndex = i;\n          idxFlags |= pC->fts5op;\n        }\n      }\n    }\n  }\n\n  /* Set idxFlags flags for the ORDER BY clause */\n  if( pInfo->nOrderBy==1 ){\n    int iSort = pInfo->aOrderBy[0].iColumn;\n    if( iSort==(pConfig->nCol+1) && BitFlagTest(idxFlags, FTS5_BI_MATCH) ){\n      idxFlags |= FTS5_BI_ORDER_RANK;\n    }else if( iSort==-1 ){\n      idxFlags |= FTS5_BI_ORDER_ROWID;\n    }\n    if( BitFlagTest(idxFlags, FTS5_BI_ORDER_RANK|FTS5_BI_ORDER_ROWID) ){\n      pInfo->orderByConsumed = 1;\n      if( pInfo->aOrderBy[0].desc ){\n        idxFlags |= FTS5_BI_ORDER_DESC;\n      }\n    }\n  }\n\n  /* Calculate the estimated cost based on the flags set in idxFlags. */\n  bHasMatch = BitFlagTest(idxFlags, FTS5_BI_MATCH);\n  if( BitFlagTest(idxFlags, FTS5_BI_ROWID_EQ) ){\n    pInfo->estimatedCost = bHasMatch ? 100.0 : 10.0;\n    if( bHasMatch==0 ) fts5SetUniqueFlag(pInfo);\n  }else if( BitFlagAllTest(idxFlags, FTS5_BI_ROWID_LE|FTS5_BI_ROWID_GE) ){\n    pInfo->estimatedCost = bHasMatch ? 500.0 : 250000.0;\n  }else if( BitFlagTest(idxFlags, FTS5_BI_ROWID_LE|FTS5_BI_ROWID_GE) ){\n    pInfo->estimatedCost = bHasMatch ? 750.0 : 750000.0;\n  }else{\n    pInfo->estimatedCost = bHasMatch ? 1000.0 : 1000000.0;\n  }\n\n  /* Assign argvIndex values to each constraint in use. */\n  iNext = 1;\n  for(i=0; i<ArraySize(aConstraint); i++){\n    struct Constraint *pC = &aConstraint[i];\n    if( pC->iConsIndex>=0 ){\n      pInfo->aConstraintUsage[pC->iConsIndex].argvIndex = iNext++;\n      pInfo->aConstraintUsage[pC->iConsIndex].omit = (unsigned char)pC->omit;\n    }\n  }\n\n  pInfo->idxNum = idxFlags;\n  return SQLITE_OK;\n}\n\nstatic int fts5NewTransaction(Fts5FullTable *pTab){\n  Fts5Cursor *pCsr;\n  for(pCsr=pTab->pGlobal->pCsr; pCsr; pCsr=pCsr->pNext){\n    if( pCsr->base.pVtab==(sqlite3_vtab*)pTab ) return SQLITE_OK;\n  }\n  return sqlite3Fts5StorageReset(pTab->pStorage);\n}\n\n/*\n** Implementation of xOpen method.\n*/\nstatic int fts5OpenMethod(sqlite3_vtab *pVTab, sqlite3_vtab_cursor **ppCsr){\n  Fts5FullTable *pTab = (Fts5FullTable*)pVTab;\n  Fts5Config *pConfig = pTab->p.pConfig;\n  Fts5Cursor *pCsr = 0;           /* New cursor object */\n  sqlite3_int64 nByte;            /* Bytes of space to allocate */\n  int rc;                         /* Return code */\n\n  rc = fts5NewTransaction(pTab);\n  if( rc==SQLITE_OK ){\n    nByte = sizeof(Fts5Cursor) + pConfig->nCol * sizeof(int);\n    pCsr = (Fts5Cursor*)sqlite3_malloc64(nByte);\n    if( pCsr ){\n      Fts5Global *pGlobal = pTab->pGlobal;\n      memset(pCsr, 0, nByte);\n      pCsr->aColumnSize = (int*)&pCsr[1];\n      pCsr->pNext = pGlobal->pCsr;\n      pGlobal->pCsr = pCsr;\n      pCsr->iCsrId = ++pGlobal->iNextId;\n    }else{\n      rc = SQLITE_NOMEM;\n    }\n  }\n  *ppCsr = (sqlite3_vtab_cursor*)pCsr;\n  return rc;\n}\n\nstatic int fts5StmtType(Fts5Cursor *pCsr){\n  if( pCsr->ePlan==FTS5_PLAN_SCAN ){\n    return (pCsr->bDesc) ? FTS5_STMT_SCAN_DESC : FTS5_STMT_SCAN_ASC;\n  }\n  return FTS5_STMT_LOOKUP;\n}\n\n/*\n** This function is called after the cursor passed as the only argument\n** is moved to point at a different row. It clears all cached data \n** specific to the previous row stored by the cursor object.\n*/\nstatic void fts5CsrNewrow(Fts5Cursor *pCsr){\n  CsrFlagSet(pCsr, \n      FTS5CSR_REQUIRE_CONTENT \n    | FTS5CSR_REQUIRE_DOCSIZE \n    | FTS5CSR_REQUIRE_INST \n    | FTS5CSR_REQUIRE_POSLIST \n  );\n}\n\nstatic void fts5FreeCursorComponents(Fts5Cursor *pCsr){\n  Fts5FullTable *pTab = (Fts5FullTable*)(pCsr->base.pVtab);\n  Fts5Auxdata *pData;\n  Fts5Auxdata *pNext;\n\n  sqlite3_free(pCsr->aInstIter);\n  sqlite3_free(pCsr->aInst);\n  if( pCsr->pStmt ){\n    int eStmt = fts5StmtType(pCsr);\n    sqlite3Fts5StorageStmtRelease(pTab->pStorage, eStmt, pCsr->pStmt);\n  }\n  if( pCsr->pSorter ){\n    Fts5Sorter *pSorter = pCsr->pSorter;\n    sqlite3_finalize(pSorter->pStmt);\n    sqlite3_free(pSorter);\n  }\n\n  if( pCsr->ePlan!=FTS5_PLAN_SOURCE ){\n    sqlite3Fts5ExprFree(pCsr->pExpr);\n  }\n\n  for(pData=pCsr->pAuxdata; pData; pData=pNext){\n    pNext = pData->pNext;\n    if( pData->xDelete ) pData->xDelete(pData->pPtr);\n    sqlite3_free(pData);\n  }\n\n  sqlite3_finalize(pCsr->pRankArgStmt);\n  sqlite3_free(pCsr->apRankArg);\n\n  if( CsrFlagTest(pCsr, FTS5CSR_FREE_ZRANK) ){\n    sqlite3_free(pCsr->zRank);\n    sqlite3_free(pCsr->zRankArgs);\n  }\n\n  memset(&pCsr->ePlan, 0, sizeof(Fts5Cursor) - ((u8*)&pCsr->ePlan - (u8*)pCsr));\n}\n\n\n/*\n** Close the cursor.  For additional information see the documentation\n** on the xClose method of the virtual table interface.\n*/\nstatic int fts5CloseMethod(sqlite3_vtab_cursor *pCursor){\n  if( pCursor ){\n    Fts5FullTable *pTab = (Fts5FullTable*)(pCursor->pVtab);\n    Fts5Cursor *pCsr = (Fts5Cursor*)pCursor;\n    Fts5Cursor **pp;\n\n    fts5FreeCursorComponents(pCsr);\n    /* Remove the cursor from the Fts5Global.pCsr list */\n    for(pp=&pTab->pGlobal->pCsr; (*pp)!=pCsr; pp=&(*pp)->pNext);\n    *pp = pCsr->pNext;\n\n    sqlite3_free(pCsr);\n  }\n  return SQLITE_OK;\n}\n\nstatic int fts5SorterNext(Fts5Cursor *pCsr){\n  Fts5Sorter *pSorter = pCsr->pSorter;\n  int rc;\n\n  rc = sqlite3_step(pSorter->pStmt);\n  if( rc==SQLITE_DONE ){\n    rc = SQLITE_OK;\n    CsrFlagSet(pCsr, FTS5CSR_EOF);\n  }else if( rc==SQLITE_ROW ){\n    const u8 *a;\n    const u8 *aBlob;\n    int nBlob;\n    int i;\n    int iOff = 0;\n    rc = SQLITE_OK;\n\n    pSorter->iRowid = sqlite3_column_int64(pSorter->pStmt, 0);\n    nBlob = sqlite3_column_bytes(pSorter->pStmt, 1);\n    aBlob = a = sqlite3_column_blob(pSorter->pStmt, 1);\n\n    /* nBlob==0 in detail=none mode. */\n    if( nBlob>0 ){\n      for(i=0; i<(pSorter->nIdx-1); i++){\n        int iVal;\n        a += fts5GetVarint32(a, iVal);\n        iOff += iVal;\n        pSorter->aIdx[i] = iOff;\n      }\n      pSorter->aIdx[i] = &aBlob[nBlob] - a;\n      pSorter->aPoslist = a;\n    }\n\n    fts5CsrNewrow(pCsr);\n  }\n\n  return rc;\n}\n\n\n/*\n** Set the FTS5CSR_REQUIRE_RESEEK flag on all FTS5_PLAN_MATCH cursors \n** open on table pTab.\n*/\nstatic void fts5TripCursors(Fts5FullTable *pTab){\n  Fts5Cursor *pCsr;\n  for(pCsr=pTab->pGlobal->pCsr; pCsr; pCsr=pCsr->pNext){\n    if( pCsr->ePlan==FTS5_PLAN_MATCH\n     && pCsr->base.pVtab==(sqlite3_vtab*)pTab \n    ){\n      CsrFlagSet(pCsr, FTS5CSR_REQUIRE_RESEEK);\n    }\n  }\n}\n\n/*\n** If the REQUIRE_RESEEK flag is set on the cursor passed as the first\n** argument, close and reopen all Fts5IndexIter iterators that the cursor \n** is using. Then attempt to move the cursor to a rowid equal to or laster\n** (in the cursors sort order - ASC or DESC) than the current rowid. \n**\n** If the new rowid is not equal to the old, set output parameter *pbSkip\n** to 1 before returning. Otherwise, leave it unchanged.\n**\n** Return SQLITE_OK if successful or if no reseek was required, or an \n** error code if an error occurred.\n*/\nstatic int fts5CursorReseek(Fts5Cursor *pCsr, int *pbSkip){\n  int rc = SQLITE_OK;\n  assert( *pbSkip==0 );\n  if( CsrFlagTest(pCsr, FTS5CSR_REQUIRE_RESEEK) ){\n    Fts5FullTable *pTab = (Fts5FullTable*)(pCsr->base.pVtab);\n    int bDesc = pCsr->bDesc;\n    i64 iRowid = sqlite3Fts5ExprRowid(pCsr->pExpr);\n\n    rc = sqlite3Fts5ExprFirst(pCsr->pExpr, pTab->p.pIndex, iRowid, bDesc);\n    if( rc==SQLITE_OK &&  iRowid!=sqlite3Fts5ExprRowid(pCsr->pExpr) ){\n      *pbSkip = 1;\n    }\n\n    CsrFlagClear(pCsr, FTS5CSR_REQUIRE_RESEEK);\n    fts5CsrNewrow(pCsr);\n    if( sqlite3Fts5ExprEof(pCsr->pExpr) ){\n      CsrFlagSet(pCsr, FTS5CSR_EOF);\n      *pbSkip = 1;\n    }\n  }\n  return rc;\n}\n\n\n/*\n** Advance the cursor to the next row in the table that matches the \n** search criteria.\n**\n** Return SQLITE_OK if nothing goes wrong.  SQLITE_OK is returned\n** even if we reach end-of-file.  The fts5EofMethod() will be called\n** subsequently to determine whether or not an EOF was hit.\n*/\nstatic int fts5NextMethod(sqlite3_vtab_cursor *pCursor){\n  Fts5Cursor *pCsr = (Fts5Cursor*)pCursor;\n  int rc;\n\n  assert( (pCsr->ePlan<3)==\n          (pCsr->ePlan==FTS5_PLAN_MATCH || pCsr->ePlan==FTS5_PLAN_SOURCE) \n  );\n  assert( !CsrFlagTest(pCsr, FTS5CSR_EOF) );\n\n  if( pCsr->ePlan<3 ){\n    int bSkip = 0;\n    if( (rc = fts5CursorReseek(pCsr, &bSkip)) || bSkip ) return rc;\n    rc = sqlite3Fts5ExprNext(pCsr->pExpr, pCsr->iLastRowid);\n    CsrFlagSet(pCsr, sqlite3Fts5ExprEof(pCsr->pExpr));\n    fts5CsrNewrow(pCsr);\n  }else{\n    switch( pCsr->ePlan ){\n      case FTS5_PLAN_SPECIAL: {\n        CsrFlagSet(pCsr, FTS5CSR_EOF);\n        rc = SQLITE_OK;\n        break;\n      }\n  \n      case FTS5_PLAN_SORTED_MATCH: {\n        rc = fts5SorterNext(pCsr);\n        break;\n      }\n  \n      default:\n        rc = sqlite3_step(pCsr->pStmt);\n        if( rc!=SQLITE_ROW ){\n          CsrFlagSet(pCsr, FTS5CSR_EOF);\n          rc = sqlite3_reset(pCsr->pStmt);\n        }else{\n          rc = SQLITE_OK;\n        }\n        break;\n    }\n  }\n  \n  return rc;\n}\n\n\nstatic int fts5PrepareStatement(\n  sqlite3_stmt **ppStmt,\n  Fts5Config *pConfig, \n  const char *zFmt,\n  ...\n){\n  sqlite3_stmt *pRet = 0;\n  int rc;\n  char *zSql;\n  va_list ap;\n\n  va_start(ap, zFmt);\n  zSql = sqlite3_vmprintf(zFmt, ap);\n  if( zSql==0 ){\n    rc = SQLITE_NOMEM; \n  }else{\n    rc = sqlite3_prepare_v3(pConfig->db, zSql, -1, \n                            SQLITE_PREPARE_PERSISTENT, &pRet, 0);\n    if( rc!=SQLITE_OK ){\n      *pConfig->pzErrmsg = sqlite3_mprintf(\"%s\", sqlite3_errmsg(pConfig->db));\n    }\n    sqlite3_free(zSql);\n  }\n\n  va_end(ap);\n  *ppStmt = pRet;\n  return rc;\n} \n\nstatic int fts5CursorFirstSorted(\n  Fts5FullTable *pTab, \n  Fts5Cursor *pCsr, \n  int bDesc\n){\n  Fts5Config *pConfig = pTab->p.pConfig;\n  Fts5Sorter *pSorter;\n  int nPhrase;\n  sqlite3_int64 nByte;\n  int rc;\n  const char *zRank = pCsr->zRank;\n  const char *zRankArgs = pCsr->zRankArgs;\n  \n  nPhrase = sqlite3Fts5ExprPhraseCount(pCsr->pExpr);\n  nByte = sizeof(Fts5Sorter) + sizeof(int) * (nPhrase-1);\n  pSorter = (Fts5Sorter*)sqlite3_malloc64(nByte);\n  if( pSorter==0 ) return SQLITE_NOMEM;\n  memset(pSorter, 0, nByte);\n  pSorter->nIdx = nPhrase;\n\n  /* TODO: It would be better to have some system for reusing statement\n  ** handles here, rather than preparing a new one for each query. But that\n  ** is not possible as SQLite reference counts the virtual table objects.\n  ** And since the statement required here reads from this very virtual \n  ** table, saving it creates a circular reference.\n  **\n  ** If SQLite a built-in statement cache, this wouldn't be a problem. */\n  rc = fts5PrepareStatement(&pSorter->pStmt, pConfig,\n      \"SELECT rowid, rank FROM %Q.%Q ORDER BY %s(%s%s%s) %s\",\n      pConfig->zDb, pConfig->zName, zRank, pConfig->zName,\n      (zRankArgs ? \", \" : \"\"),\n      (zRankArgs ? zRankArgs : \"\"),\n      bDesc ? \"DESC\" : \"ASC\"\n  );\n\n  pCsr->pSorter = pSorter;\n  if( rc==SQLITE_OK ){\n    assert( pTab->pSortCsr==0 );\n    pTab->pSortCsr = pCsr;\n    rc = fts5SorterNext(pCsr);\n    pTab->pSortCsr = 0;\n  }\n\n  if( rc!=SQLITE_OK ){\n    sqlite3_finalize(pSorter->pStmt);\n    sqlite3_free(pSorter);\n    pCsr->pSorter = 0;\n  }\n\n  return rc;\n}\n\nstatic int fts5CursorFirst(Fts5FullTable *pTab, Fts5Cursor *pCsr, int bDesc){\n  int rc;\n  Fts5Expr *pExpr = pCsr->pExpr;\n  rc = sqlite3Fts5ExprFirst(pExpr, pTab->p.pIndex, pCsr->iFirstRowid, bDesc);\n  if( sqlite3Fts5ExprEof(pExpr) ){\n    CsrFlagSet(pCsr, FTS5CSR_EOF);\n  }\n  fts5CsrNewrow(pCsr);\n  return rc;\n}\n\n/*\n** Process a \"special\" query. A special query is identified as one with a\n** MATCH expression that begins with a '*' character. The remainder of\n** the text passed to the MATCH operator are used as  the special query\n** parameters.\n*/\nstatic int fts5SpecialMatch(\n  Fts5FullTable *pTab, \n  Fts5Cursor *pCsr, \n  const char *zQuery\n){\n  int rc = SQLITE_OK;             /* Return code */\n  const char *z = zQuery;         /* Special query text */\n  int n;                          /* Number of bytes in text at z */\n\n  while( z[0]==' ' ) z++;\n  for(n=0; z[n] && z[n]!=' '; n++);\n\n  assert( pTab->p.base.zErrMsg==0 );\n  pCsr->ePlan = FTS5_PLAN_SPECIAL;\n\n  if( 0==sqlite3_strnicmp(\"reads\", z, n) ){\n    pCsr->iSpecial = sqlite3Fts5IndexReads(pTab->p.pIndex);\n  }\n  else if( 0==sqlite3_strnicmp(\"id\", z, n) ){\n    pCsr->iSpecial = pCsr->iCsrId;\n  }\n  else{\n    /* An unrecognized directive. Return an error message. */\n    pTab->p.base.zErrMsg = sqlite3_mprintf(\"unknown special query: %.*s\", n, z);\n    rc = SQLITE_ERROR;\n  }\n\n  return rc;\n}\n\n/*\n** Search for an auxiliary function named zName that can be used with table\n** pTab. If one is found, return a pointer to the corresponding Fts5Auxiliary\n** structure. Otherwise, if no such function exists, return NULL.\n*/\nstatic Fts5Auxiliary *fts5FindAuxiliary(Fts5FullTable *pTab, const char *zName){\n  Fts5Auxiliary *pAux;\n\n  for(pAux=pTab->pGlobal->pAux; pAux; pAux=pAux->pNext){\n    if( sqlite3_stricmp(zName, pAux->zFunc)==0 ) return pAux;\n  }\n\n  /* No function of the specified name was found. Return 0. */\n  return 0;\n}\n\n\nstatic int fts5FindRankFunction(Fts5Cursor *pCsr){\n  Fts5FullTable *pTab = (Fts5FullTable*)(pCsr->base.pVtab);\n  Fts5Config *pConfig = pTab->p.pConfig;\n  int rc = SQLITE_OK;\n  Fts5Auxiliary *pAux = 0;\n  const char *zRank = pCsr->zRank;\n  const char *zRankArgs = pCsr->zRankArgs;\n\n  if( zRankArgs ){\n    char *zSql = sqlite3Fts5Mprintf(&rc, \"SELECT %s\", zRankArgs);\n    if( zSql ){\n      sqlite3_stmt *pStmt = 0;\n      rc = sqlite3_prepare_v3(pConfig->db, zSql, -1,\n                              SQLITE_PREPARE_PERSISTENT, &pStmt, 0);\n      sqlite3_free(zSql);\n      assert( rc==SQLITE_OK || pCsr->pRankArgStmt==0 );\n      if( rc==SQLITE_OK ){\n        if( SQLITE_ROW==sqlite3_step(pStmt) ){\n          sqlite3_int64 nByte;\n          pCsr->nRankArg = sqlite3_column_count(pStmt);\n          nByte = sizeof(sqlite3_value*)*pCsr->nRankArg;\n          pCsr->apRankArg = (sqlite3_value**)sqlite3Fts5MallocZero(&rc, nByte);\n          if( rc==SQLITE_OK ){\n            int i;\n            for(i=0; i<pCsr->nRankArg; i++){\n              pCsr->apRankArg[i] = sqlite3_column_value(pStmt, i);\n            }\n          }\n          pCsr->pRankArgStmt = pStmt;\n        }else{\n          rc = sqlite3_finalize(pStmt);\n          assert( rc!=SQLITE_OK );\n        }\n      }\n    }\n  }\n\n  if( rc==SQLITE_OK ){\n    pAux = fts5FindAuxiliary(pTab, zRank);\n    if( pAux==0 ){\n      assert( pTab->p.base.zErrMsg==0 );\n      pTab->p.base.zErrMsg = sqlite3_mprintf(\"no such function: %s\", zRank);\n      rc = SQLITE_ERROR;\n    }\n  }\n\n  pCsr->pRank = pAux;\n  return rc;\n}\n\n\nstatic int fts5CursorParseRank(\n  Fts5Config *pConfig,\n  Fts5Cursor *pCsr, \n  sqlite3_value *pRank\n){\n  int rc = SQLITE_OK;\n  if( pRank ){\n    const char *z = (const char*)sqlite3_value_text(pRank);\n    char *zRank = 0;\n    char *zRankArgs = 0;\n\n    if( z==0 ){\n      if( sqlite3_value_type(pRank)==SQLITE_NULL ) rc = SQLITE_ERROR;\n    }else{\n      rc = sqlite3Fts5ConfigParseRank(z, &zRank, &zRankArgs);\n    }\n    if( rc==SQLITE_OK ){\n      pCsr->zRank = zRank;\n      pCsr->zRankArgs = zRankArgs;\n      CsrFlagSet(pCsr, FTS5CSR_FREE_ZRANK);\n    }else if( rc==SQLITE_ERROR ){\n      pCsr->base.pVtab->zErrMsg = sqlite3_mprintf(\n          \"parse error in rank function: %s\", z\n      );\n    }\n  }else{\n    if( pConfig->zRank ){\n      pCsr->zRank = (char*)pConfig->zRank;\n      pCsr->zRankArgs = (char*)pConfig->zRankArgs;\n    }else{\n      pCsr->zRank = (char*)FTS5_DEFAULT_RANK;\n      pCsr->zRankArgs = 0;\n    }\n  }\n  return rc;\n}\n\nstatic i64 fts5GetRowidLimit(sqlite3_value *pVal, i64 iDefault){\n  if( pVal ){\n    int eType = sqlite3_value_numeric_type(pVal);\n    if( eType==SQLITE_INTEGER ){\n      return sqlite3_value_int64(pVal);\n    }\n  }\n  return iDefault;\n}\n\n/*\n** This is the xFilter interface for the virtual table.  See\n** the virtual table xFilter method documentation for additional\n** information.\n** \n** There are three possible query strategies:\n**\n**   1. Full-text search using a MATCH operator.\n**   2. A by-rowid lookup.\n**   3. A full-table scan.\n*/\nstatic int fts5FilterMethod(\n  sqlite3_vtab_cursor *pCursor,   /* The cursor used for this query */\n  int idxNum,                     /* Strategy index */\n  const char *zUnused,            /* Unused */\n  int nVal,                       /* Number of elements in apVal */\n  sqlite3_value **apVal           /* Arguments for the indexing scheme */\n){\n  Fts5FullTable *pTab = (Fts5FullTable*)(pCursor->pVtab);\n  Fts5Config *pConfig = pTab->p.pConfig;\n  Fts5Cursor *pCsr = (Fts5Cursor*)pCursor;\n  int rc = SQLITE_OK;             /* Error code */\n  int iVal = 0;                   /* Counter for apVal[] */\n  int bDesc;                      /* True if ORDER BY [rank|rowid] DESC */\n  int bOrderByRank;               /* True if ORDER BY rank */\n  sqlite3_value *pMatch = 0;      /* <tbl> MATCH ? expression (or NULL) */\n  sqlite3_value *pRank = 0;       /* rank MATCH ? expression (or NULL) */\n  sqlite3_value *pRowidEq = 0;    /* rowid = ? expression (or NULL) */\n  sqlite3_value *pRowidLe = 0;    /* rowid <= ? expression (or NULL) */\n  sqlite3_value *pRowidGe = 0;    /* rowid >= ? expression (or NULL) */\n  int iCol;                       /* Column on LHS of MATCH operator */\n  char **pzErrmsg = pConfig->pzErrmsg;\n\n  UNUSED_PARAM(zUnused);\n  UNUSED_PARAM(nVal);\n\n  if( pCsr->ePlan ){\n    fts5FreeCursorComponents(pCsr);\n    memset(&pCsr->ePlan, 0, sizeof(Fts5Cursor) - ((u8*)&pCsr->ePlan-(u8*)pCsr));\n  }\n\n  assert( pCsr->pStmt==0 );\n  assert( pCsr->pExpr==0 );\n  assert( pCsr->csrflags==0 );\n  assert( pCsr->pRank==0 );\n  assert( pCsr->zRank==0 );\n  assert( pCsr->zRankArgs==0 );\n\n  assert( pzErrmsg==0 || pzErrmsg==&pTab->p.base.zErrMsg );\n  pConfig->pzErrmsg = &pTab->p.base.zErrMsg;\n\n  /* Decode the arguments passed through to this function.\n  **\n  ** Note: The following set of if(...) statements must be in the same\n  ** order as the corresponding entries in the struct at the top of\n  ** fts5BestIndexMethod().  */\n  if( BitFlagTest(idxNum, FTS5_BI_MATCH) ) pMatch = apVal[iVal++];\n  if( BitFlagTest(idxNum, FTS5_BI_RANK) ) pRank = apVal[iVal++];\n  if( BitFlagTest(idxNum, FTS5_BI_ROWID_EQ) ) pRowidEq = apVal[iVal++];\n  if( BitFlagTest(idxNum, FTS5_BI_ROWID_LE) ) pRowidLe = apVal[iVal++];\n  if( BitFlagTest(idxNum, FTS5_BI_ROWID_GE) ) pRowidGe = apVal[iVal++];\n  iCol = (idxNum>>16);\n  assert( iCol>=0 && iCol<=pConfig->nCol );\n  assert( iVal==nVal );\n  bOrderByRank = ((idxNum & FTS5_BI_ORDER_RANK) ? 1 : 0);\n  pCsr->bDesc = bDesc = ((idxNum & FTS5_BI_ORDER_DESC) ? 1 : 0);\n\n  /* Set the cursor upper and lower rowid limits. Only some strategies \n  ** actually use them. This is ok, as the xBestIndex() method leaves the\n  ** sqlite3_index_constraint.omit flag clear for range constraints\n  ** on the rowid field.  */\n  if( pRowidEq ){\n    pRowidLe = pRowidGe = pRowidEq;\n  }\n  if( bDesc ){\n    pCsr->iFirstRowid = fts5GetRowidLimit(pRowidLe, LARGEST_INT64);\n    pCsr->iLastRowid = fts5GetRowidLimit(pRowidGe, SMALLEST_INT64);\n  }else{\n    pCsr->iLastRowid = fts5GetRowidLimit(pRowidLe, LARGEST_INT64);\n    pCsr->iFirstRowid = fts5GetRowidLimit(pRowidGe, SMALLEST_INT64);\n  }\n\n  if( pTab->pSortCsr ){\n    /* If pSortCsr is non-NULL, then this call is being made as part of \n    ** processing for a \"... MATCH <expr> ORDER BY rank\" query (ePlan is\n    ** set to FTS5_PLAN_SORTED_MATCH). pSortCsr is the cursor that will\n    ** return results to the user for this query. The current cursor \n    ** (pCursor) is used to execute the query issued by function \n    ** fts5CursorFirstSorted() above.  */\n    assert( pRowidEq==0 && pRowidLe==0 && pRowidGe==0 && pRank==0 );\n    assert( nVal==0 && pMatch==0 && bOrderByRank==0 && bDesc==0 );\n    assert( pCsr->iLastRowid==LARGEST_INT64 );\n    assert( pCsr->iFirstRowid==SMALLEST_INT64 );\n    if( pTab->pSortCsr->bDesc ){\n      pCsr->iLastRowid = pTab->pSortCsr->iFirstRowid;\n      pCsr->iFirstRowid = pTab->pSortCsr->iLastRowid;\n    }else{\n      pCsr->iLastRowid = pTab->pSortCsr->iLastRowid;\n      pCsr->iFirstRowid = pTab->pSortCsr->iFirstRowid;\n    }\n    pCsr->ePlan = FTS5_PLAN_SOURCE;\n    pCsr->pExpr = pTab->pSortCsr->pExpr;\n    rc = fts5CursorFirst(pTab, pCsr, bDesc);\n  }else if( pMatch ){\n    const char *zExpr = (const char*)sqlite3_value_text(apVal[0]);\n    if( zExpr==0 ) zExpr = \"\";\n\n    rc = fts5CursorParseRank(pConfig, pCsr, pRank);\n    if( rc==SQLITE_OK ){\n      if( zExpr[0]=='*' ){\n        /* The user has issued a query of the form \"MATCH '*...'\". This\n        ** indicates that the MATCH expression is not a full text query,\n        ** but a request for an internal parameter.  */\n        rc = fts5SpecialMatch(pTab, pCsr, &zExpr[1]);\n      }else{\n        char **pzErr = &pTab->p.base.zErrMsg;\n        rc = sqlite3Fts5ExprNew(pConfig, iCol, zExpr, &pCsr->pExpr, pzErr);\n        if( rc==SQLITE_OK ){\n          if( bOrderByRank ){\n            pCsr->ePlan = FTS5_PLAN_SORTED_MATCH;\n            rc = fts5CursorFirstSorted(pTab, pCsr, bDesc);\n          }else{\n            pCsr->ePlan = FTS5_PLAN_MATCH;\n            rc = fts5CursorFirst(pTab, pCsr, bDesc);\n          }\n        }\n      }\n    }\n  }else if( pConfig->zContent==0 ){\n    *pConfig->pzErrmsg = sqlite3_mprintf(\n        \"%s: table does not support scanning\", pConfig->zName\n    );\n    rc = SQLITE_ERROR;\n  }else{\n    /* This is either a full-table scan (ePlan==FTS5_PLAN_SCAN) or a lookup\n    ** by rowid (ePlan==FTS5_PLAN_ROWID).  */\n    pCsr->ePlan = (pRowidEq ? FTS5_PLAN_ROWID : FTS5_PLAN_SCAN);\n    rc = sqlite3Fts5StorageStmt(\n        pTab->pStorage, fts5StmtType(pCsr), &pCsr->pStmt, &pTab->p.base.zErrMsg\n    );\n    if( rc==SQLITE_OK ){\n      if( pCsr->ePlan==FTS5_PLAN_ROWID ){\n        sqlite3_bind_value(pCsr->pStmt, 1, apVal[0]);\n      }else{\n        sqlite3_bind_int64(pCsr->pStmt, 1, pCsr->iFirstRowid);\n        sqlite3_bind_int64(pCsr->pStmt, 2, pCsr->iLastRowid);\n      }\n      rc = fts5NextMethod(pCursor);\n    }\n  }\n\n  pConfig->pzErrmsg = pzErrmsg;\n  return rc;\n}\n\n/* \n** This is the xEof method of the virtual table. SQLite calls this \n** routine to find out if it has reached the end of a result set.\n*/\nstatic int fts5EofMethod(sqlite3_vtab_cursor *pCursor){\n  Fts5Cursor *pCsr = (Fts5Cursor*)pCursor;\n  return (CsrFlagTest(pCsr, FTS5CSR_EOF) ? 1 : 0);\n}\n\n/*\n** Return the rowid that the cursor currently points to.\n*/\nstatic i64 fts5CursorRowid(Fts5Cursor *pCsr){\n  assert( pCsr->ePlan==FTS5_PLAN_MATCH \n       || pCsr->ePlan==FTS5_PLAN_SORTED_MATCH \n       || pCsr->ePlan==FTS5_PLAN_SOURCE \n  );\n  if( pCsr->pSorter ){\n    return pCsr->pSorter->iRowid;\n  }else{\n    return sqlite3Fts5ExprRowid(pCsr->pExpr);\n  }\n}\n\n/* \n** This is the xRowid method. The SQLite core calls this routine to\n** retrieve the rowid for the current row of the result set. fts5\n** exposes %_content.rowid as the rowid for the virtual table. The\n** rowid should be written to *pRowid.\n*/\nstatic int fts5RowidMethod(sqlite3_vtab_cursor *pCursor, sqlite_int64 *pRowid){\n  Fts5Cursor *pCsr = (Fts5Cursor*)pCursor;\n  int ePlan = pCsr->ePlan;\n  \n  assert( CsrFlagTest(pCsr, FTS5CSR_EOF)==0 );\n  switch( ePlan ){\n    case FTS5_PLAN_SPECIAL:\n      *pRowid = 0;\n      break;\n\n    case FTS5_PLAN_SOURCE:\n    case FTS5_PLAN_MATCH:\n    case FTS5_PLAN_SORTED_MATCH:\n      *pRowid = fts5CursorRowid(pCsr);\n      break;\n\n    default:\n      *pRowid = sqlite3_column_int64(pCsr->pStmt, 0);\n      break;\n  }\n\n  return SQLITE_OK;\n}\n\n/*\n** If the cursor requires seeking (bSeekRequired flag is set), seek it.\n** Return SQLITE_OK if no error occurs, or an SQLite error code otherwise.\n**\n** If argument bErrormsg is true and an error occurs, an error message may\n** be left in sqlite3_vtab.zErrMsg.\n*/\nstatic int fts5SeekCursor(Fts5Cursor *pCsr, int bErrormsg){\n  int rc = SQLITE_OK;\n\n  /* If the cursor does not yet have a statement handle, obtain one now. */ \n  if( pCsr->pStmt==0 ){\n    Fts5FullTable *pTab = (Fts5FullTable*)(pCsr->base.pVtab);\n    int eStmt = fts5StmtType(pCsr);\n    rc = sqlite3Fts5StorageStmt(\n        pTab->pStorage, eStmt, &pCsr->pStmt, (bErrormsg?&pTab->p.base.zErrMsg:0)\n    );\n    assert( rc!=SQLITE_OK || pTab->p.base.zErrMsg==0 );\n    assert( CsrFlagTest(pCsr, FTS5CSR_REQUIRE_CONTENT) );\n  }\n\n  if( rc==SQLITE_OK && CsrFlagTest(pCsr, FTS5CSR_REQUIRE_CONTENT) ){\n    assert( pCsr->pExpr );\n    sqlite3_reset(pCsr->pStmt);\n    sqlite3_bind_int64(pCsr->pStmt, 1, fts5CursorRowid(pCsr));\n    rc = sqlite3_step(pCsr->pStmt);\n    if( rc==SQLITE_ROW ){\n      rc = SQLITE_OK;\n      CsrFlagClear(pCsr, FTS5CSR_REQUIRE_CONTENT);\n    }else{\n      rc = sqlite3_reset(pCsr->pStmt);\n      if( rc==SQLITE_OK ){\n        rc = FTS5_CORRUPT;\n      }\n    }\n  }\n  return rc;\n}\n\nstatic void fts5SetVtabError(Fts5FullTable *p, const char *zFormat, ...){\n  va_list ap;                     /* ... printf arguments */\n  va_start(ap, zFormat);\n  assert( p->p.base.zErrMsg==0 );\n  p->p.base.zErrMsg = sqlite3_vmprintf(zFormat, ap);\n  va_end(ap);\n}\n\n/*\n** This function is called to handle an FTS INSERT command. In other words,\n** an INSERT statement of the form:\n**\n**     INSERT INTO fts(fts) VALUES($pCmd)\n**     INSERT INTO fts(fts, rank) VALUES($pCmd, $pVal)\n**\n** Argument pVal is the value assigned to column \"fts\" by the INSERT \n** statement. This function returns SQLITE_OK if successful, or an SQLite\n** error code if an error occurs.\n**\n** The commands implemented by this function are documented in the \"Special\n** INSERT Directives\" section of the documentation. It should be updated if\n** more commands are added to this function.\n*/\nstatic int fts5SpecialInsert(\n  Fts5FullTable *pTab,            /* Fts5 table object */\n  const char *zCmd,               /* Text inserted into table-name column */\n  sqlite3_value *pVal             /* Value inserted into rank column */\n){\n  Fts5Config *pConfig = pTab->p.pConfig;\n  int rc = SQLITE_OK;\n  int bError = 0;\n\n  if( 0==sqlite3_stricmp(\"delete-all\", zCmd) ){\n    if( pConfig->eContent==FTS5_CONTENT_NORMAL ){\n      fts5SetVtabError(pTab, \n          \"'delete-all' may only be used with a \"\n          \"contentless or external content fts5 table\"\n      );\n      rc = SQLITE_ERROR;\n    }else{\n      rc = sqlite3Fts5StorageDeleteAll(pTab->pStorage);\n    }\n  }else if( 0==sqlite3_stricmp(\"rebuild\", zCmd) ){\n    if( pConfig->eContent==FTS5_CONTENT_NONE ){\n      fts5SetVtabError(pTab, \n          \"'rebuild' may not be used with a contentless fts5 table\"\n      );\n      rc = SQLITE_ERROR;\n    }else{\n      rc = sqlite3Fts5StorageRebuild(pTab->pStorage);\n    }\n  }else if( 0==sqlite3_stricmp(\"optimize\", zCmd) ){\n    rc = sqlite3Fts5StorageOptimize(pTab->pStorage);\n  }else if( 0==sqlite3_stricmp(\"merge\", zCmd) ){\n    int nMerge = sqlite3_value_int(pVal);\n    rc = sqlite3Fts5StorageMerge(pTab->pStorage, nMerge);\n  }else if( 0==sqlite3_stricmp(\"integrity-check\", zCmd) ){\n    rc = sqlite3Fts5StorageIntegrity(pTab->pStorage);\n#ifdef SQLITE_DEBUG\n  }else if( 0==sqlite3_stricmp(\"prefix-index\", zCmd) ){\n    pConfig->bPrefixIndex = sqlite3_value_int(pVal);\n#endif\n  }else{\n    rc = sqlite3Fts5IndexLoadConfig(pTab->p.pIndex);\n    if( rc==SQLITE_OK ){\n      rc = sqlite3Fts5ConfigSetValue(pTab->p.pConfig, zCmd, pVal, &bError);\n    }\n    if( rc==SQLITE_OK ){\n      if( bError ){\n        rc = SQLITE_ERROR;\n      }else{\n        rc = sqlite3Fts5StorageConfigValue(pTab->pStorage, zCmd, pVal, 0);\n      }\n    }\n  }\n  return rc;\n}\n\nstatic int fts5SpecialDelete(\n  Fts5FullTable *pTab, \n  sqlite3_value **apVal\n){\n  int rc = SQLITE_OK;\n  int eType1 = sqlite3_value_type(apVal[1]);\n  if( eType1==SQLITE_INTEGER ){\n    sqlite3_int64 iDel = sqlite3_value_int64(apVal[1]);\n    rc = sqlite3Fts5StorageDelete(pTab->pStorage, iDel, &apVal[2]);\n  }\n  return rc;\n}\n\nstatic void fts5StorageInsert(\n  int *pRc, \n  Fts5FullTable *pTab, \n  sqlite3_value **apVal, \n  i64 *piRowid\n){\n  int rc = *pRc;\n  if( rc==SQLITE_OK ){\n    rc = sqlite3Fts5StorageContentInsert(pTab->pStorage, apVal, piRowid);\n  }\n  if( rc==SQLITE_OK ){\n    rc = sqlite3Fts5StorageIndexInsert(pTab->pStorage, apVal, *piRowid);\n  }\n  *pRc = rc;\n}\n\n/* \n** This function is the implementation of the xUpdate callback used by \n** FTS3 virtual tables. It is invoked by SQLite each time a row is to be\n** inserted, updated or deleted.\n**\n** A delete specifies a single argument - the rowid of the row to remove.\n** \n** Update and insert operations pass:\n**\n**   1. The \"old\" rowid, or NULL.\n**   2. The \"new\" rowid.\n**   3. Values for each of the nCol matchable columns.\n**   4. Values for the two hidden columns (<tablename> and \"rank\").\n*/\nstatic int fts5UpdateMethod(\n  sqlite3_vtab *pVtab,            /* Virtual table handle */\n  int nArg,                       /* Size of argument array */\n  sqlite3_value **apVal,          /* Array of arguments */\n  sqlite_int64 *pRowid            /* OUT: The affected (or effected) rowid */\n){\n  Fts5FullTable *pTab = (Fts5FullTable*)pVtab;\n  Fts5Config *pConfig = pTab->p.pConfig;\n  int eType0;                     /* value_type() of apVal[0] */\n  int rc = SQLITE_OK;             /* Return code */\n\n  /* A transaction must be open when this is called. */\n  assert( pTab->ts.eState==1 );\n\n  assert( pVtab->zErrMsg==0 );\n  assert( nArg==1 || nArg==(2+pConfig->nCol+2) );\n  assert( sqlite3_value_type(apVal[0])==SQLITE_INTEGER \n       || sqlite3_value_type(apVal[0])==SQLITE_NULL \n  );\n  assert( pTab->p.pConfig->pzErrmsg==0 );\n  pTab->p.pConfig->pzErrmsg = &pTab->p.base.zErrMsg;\n\n  /* Put any active cursors into REQUIRE_SEEK state. */\n  fts5TripCursors(pTab);\n\n  eType0 = sqlite3_value_type(apVal[0]);\n  if( eType0==SQLITE_NULL \n   && sqlite3_value_type(apVal[2+pConfig->nCol])!=SQLITE_NULL \n  ){\n    /* A \"special\" INSERT op. These are handled separately. */\n    const char *z = (const char*)sqlite3_value_text(apVal[2+pConfig->nCol]);\n    if( pConfig->eContent!=FTS5_CONTENT_NORMAL \n      && 0==sqlite3_stricmp(\"delete\", z) \n    ){\n      rc = fts5SpecialDelete(pTab, apVal);\n    }else{\n      rc = fts5SpecialInsert(pTab, z, apVal[2 + pConfig->nCol + 1]);\n    }\n  }else{\n    /* A regular INSERT, UPDATE or DELETE statement. The trick here is that\n    ** any conflict on the rowid value must be detected before any \n    ** modifications are made to the database file. There are 4 cases:\n    **\n    **   1) DELETE\n    **   2) UPDATE (rowid not modified)\n    **   3) UPDATE (rowid modified)\n    **   4) INSERT\n    **\n    ** Cases 3 and 4 may violate the rowid constraint.\n    */\n    int eConflict = SQLITE_ABORT;\n    if( pConfig->eContent==FTS5_CONTENT_NORMAL ){\n      eConflict = sqlite3_vtab_on_conflict(pConfig->db);\n    }\n\n    assert( eType0==SQLITE_INTEGER || eType0==SQLITE_NULL );\n    assert( nArg!=1 || eType0==SQLITE_INTEGER );\n\n    /* Filter out attempts to run UPDATE or DELETE on contentless tables.\n    ** This is not suported.  */\n    if( eType0==SQLITE_INTEGER && fts5IsContentless(pTab) ){\n      pTab->p.base.zErrMsg = sqlite3_mprintf(\n          \"cannot %s contentless fts5 table: %s\", \n          (nArg>1 ? \"UPDATE\" : \"DELETE from\"), pConfig->zName\n      );\n      rc = SQLITE_ERROR;\n    }\n\n    /* DELETE */\n    else if( nArg==1 ){\n      i64 iDel = sqlite3_value_int64(apVal[0]);  /* Rowid to delete */\n      rc = sqlite3Fts5StorageDelete(pTab->pStorage, iDel, 0);\n    }\n\n    /* INSERT or UPDATE */\n    else{\n      int eType1 = sqlite3_value_numeric_type(apVal[1]);\n\n      if( eType1!=SQLITE_INTEGER && eType1!=SQLITE_NULL ){\n        rc = SQLITE_MISMATCH;\n      }\n\n      else if( eType0!=SQLITE_INTEGER ){     \n        /* If this is a REPLACE, first remove the current entry (if any) */\n        if( eConflict==SQLITE_REPLACE && eType1==SQLITE_INTEGER ){\n          i64 iNew = sqlite3_value_int64(apVal[1]);  /* Rowid to delete */\n          rc = sqlite3Fts5StorageDelete(pTab->pStorage, iNew, 0);\n        }\n        fts5StorageInsert(&rc, pTab, apVal, pRowid);\n      }\n\n      /* UPDATE */\n      else{\n        i64 iOld = sqlite3_value_int64(apVal[0]);  /* Old rowid */\n        i64 iNew = sqlite3_value_int64(apVal[1]);  /* New rowid */\n        if( eType1==SQLITE_INTEGER && iOld!=iNew ){\n          if( eConflict==SQLITE_REPLACE ){\n            rc = sqlite3Fts5StorageDelete(pTab->pStorage, iOld, 0);\n            if( rc==SQLITE_OK ){\n              rc = sqlite3Fts5StorageDelete(pTab->pStorage, iNew, 0);\n            }\n            fts5StorageInsert(&rc, pTab, apVal, pRowid);\n          }else{\n            rc = sqlite3Fts5StorageContentInsert(pTab->pStorage, apVal, pRowid);\n            if( rc==SQLITE_OK ){\n              rc = sqlite3Fts5StorageDelete(pTab->pStorage, iOld, 0);\n            }\n            if( rc==SQLITE_OK ){\n              rc = sqlite3Fts5StorageIndexInsert(pTab->pStorage, apVal,*pRowid);\n            }\n          }\n        }else{\n          rc = sqlite3Fts5StorageDelete(pTab->pStorage, iOld, 0);\n          fts5StorageInsert(&rc, pTab, apVal, pRowid);\n        }\n      }\n    }\n  }\n\n  pTab->p.pConfig->pzErrmsg = 0;\n  return rc;\n}\n\n/*\n** Implementation of xSync() method. \n*/\nstatic int fts5SyncMethod(sqlite3_vtab *pVtab){\n  int rc;\n  Fts5FullTable *pTab = (Fts5FullTable*)pVtab;\n  fts5CheckTransactionState(pTab, FTS5_SYNC, 0);\n  pTab->p.pConfig->pzErrmsg = &pTab->p.base.zErrMsg;\n  fts5TripCursors(pTab);\n  rc = sqlite3Fts5StorageSync(pTab->pStorage);\n  pTab->p.pConfig->pzErrmsg = 0;\n  return rc;\n}\n\n/*\n** Implementation of xBegin() method. \n*/\nstatic int fts5BeginMethod(sqlite3_vtab *pVtab){\n  fts5CheckTransactionState((Fts5FullTable*)pVtab, FTS5_BEGIN, 0);\n  fts5NewTransaction((Fts5FullTable*)pVtab);\n  return SQLITE_OK;\n}\n\n/*\n** Implementation of xCommit() method. This is a no-op. The contents of\n** the pending-terms hash-table have already been flushed into the database\n** by fts5SyncMethod().\n*/\nstatic int fts5CommitMethod(sqlite3_vtab *pVtab){\n  UNUSED_PARAM(pVtab);  /* Call below is a no-op for NDEBUG builds */\n  fts5CheckTransactionState((Fts5FullTable*)pVtab, FTS5_COMMIT, 0);\n  return SQLITE_OK;\n}\n\n/*\n** Implementation of xRollback(). Discard the contents of the pending-terms\n** hash-table. Any changes made to the database are reverted by SQLite.\n*/\nstatic int fts5RollbackMethod(sqlite3_vtab *pVtab){\n  int rc;\n  Fts5FullTable *pTab = (Fts5FullTable*)pVtab;\n  fts5CheckTransactionState(pTab, FTS5_ROLLBACK, 0);\n  rc = sqlite3Fts5StorageRollback(pTab->pStorage);\n  return rc;\n}\n\nstatic int fts5CsrPoslist(Fts5Cursor*, int, const u8**, int*);\n\nstatic void *fts5ApiUserData(Fts5Context *pCtx){\n  Fts5Cursor *pCsr = (Fts5Cursor*)pCtx;\n  return pCsr->pAux->pUserData;\n}\n\nstatic int fts5ApiColumnCount(Fts5Context *pCtx){\n  Fts5Cursor *pCsr = (Fts5Cursor*)pCtx;\n  return ((Fts5Table*)(pCsr->base.pVtab))->pConfig->nCol;\n}\n\nstatic int fts5ApiColumnTotalSize(\n  Fts5Context *pCtx, \n  int iCol, \n  sqlite3_int64 *pnToken\n){\n  Fts5Cursor *pCsr = (Fts5Cursor*)pCtx;\n  Fts5FullTable *pTab = (Fts5FullTable*)(pCsr->base.pVtab);\n  return sqlite3Fts5StorageSize(pTab->pStorage, iCol, pnToken);\n}\n\nstatic int fts5ApiRowCount(Fts5Context *pCtx, i64 *pnRow){\n  Fts5Cursor *pCsr = (Fts5Cursor*)pCtx;\n  Fts5FullTable *pTab = (Fts5FullTable*)(pCsr->base.pVtab);\n  return sqlite3Fts5StorageRowCount(pTab->pStorage, pnRow);\n}\n\nstatic int fts5ApiTokenize(\n  Fts5Context *pCtx, \n  const char *pText, int nText, \n  void *pUserData,\n  int (*xToken)(void*, int, const char*, int, int, int)\n){\n  Fts5Cursor *pCsr = (Fts5Cursor*)pCtx;\n  Fts5Table *pTab = (Fts5Table*)(pCsr->base.pVtab);\n  return sqlite3Fts5Tokenize(\n      pTab->pConfig, FTS5_TOKENIZE_AUX, pText, nText, pUserData, xToken\n  );\n}\n\nstatic int fts5ApiPhraseCount(Fts5Context *pCtx){\n  Fts5Cursor *pCsr = (Fts5Cursor*)pCtx;\n  return sqlite3Fts5ExprPhraseCount(pCsr->pExpr);\n}\n\nstatic int fts5ApiPhraseSize(Fts5Context *pCtx, int iPhrase){\n  Fts5Cursor *pCsr = (Fts5Cursor*)pCtx;\n  return sqlite3Fts5ExprPhraseSize(pCsr->pExpr, iPhrase);\n}\n\nstatic int fts5ApiColumnText(\n  Fts5Context *pCtx, \n  int iCol, \n  const char **pz, \n  int *pn\n){\n  int rc = SQLITE_OK;\n  Fts5Cursor *pCsr = (Fts5Cursor*)pCtx;\n  if( fts5IsContentless((Fts5FullTable*)(pCsr->base.pVtab)) \n   || pCsr->ePlan==FTS5_PLAN_SPECIAL \n  ){\n    *pz = 0;\n    *pn = 0;\n  }else{\n    rc = fts5SeekCursor(pCsr, 0);\n    if( rc==SQLITE_OK ){\n      *pz = (const char*)sqlite3_column_text(pCsr->pStmt, iCol+1);\n      *pn = sqlite3_column_bytes(pCsr->pStmt, iCol+1);\n    }\n  }\n  return rc;\n}\n\nstatic int fts5CsrPoslist(\n  Fts5Cursor *pCsr, \n  int iPhrase, \n  const u8 **pa,\n  int *pn\n){\n  Fts5Config *pConfig = ((Fts5Table*)(pCsr->base.pVtab))->pConfig;\n  int rc = SQLITE_OK;\n  int bLive = (pCsr->pSorter==0);\n\n  if( CsrFlagTest(pCsr, FTS5CSR_REQUIRE_POSLIST) ){\n\n    if( pConfig->eDetail!=FTS5_DETAIL_FULL ){\n      Fts5PoslistPopulator *aPopulator;\n      int i;\n      aPopulator = sqlite3Fts5ExprClearPoslists(pCsr->pExpr, bLive);\n      if( aPopulator==0 ) rc = SQLITE_NOMEM;\n      for(i=0; i<pConfig->nCol && rc==SQLITE_OK; i++){\n        int n; const char *z;\n        rc = fts5ApiColumnText((Fts5Context*)pCsr, i, &z, &n);\n        if( rc==SQLITE_OK ){\n          rc = sqlite3Fts5ExprPopulatePoslists(\n              pConfig, pCsr->pExpr, aPopulator, i, z, n\n          );\n        }\n      }\n      sqlite3_free(aPopulator);\n\n      if( pCsr->pSorter ){\n        sqlite3Fts5ExprCheckPoslists(pCsr->pExpr, pCsr->pSorter->iRowid);\n      }\n    }\n    CsrFlagClear(pCsr, FTS5CSR_REQUIRE_POSLIST);\n  }\n\n  if( pCsr->pSorter && pConfig->eDetail==FTS5_DETAIL_FULL ){\n    Fts5Sorter *pSorter = pCsr->pSorter;\n    int i1 = (iPhrase==0 ? 0 : pSorter->aIdx[iPhrase-1]);\n    *pn = pSorter->aIdx[iPhrase] - i1;\n    *pa = &pSorter->aPoslist[i1];\n  }else{\n    *pn = sqlite3Fts5ExprPoslist(pCsr->pExpr, iPhrase, pa);\n  }\n\n  return rc;\n}\n\n/*\n** Ensure that the Fts5Cursor.nInstCount and aInst[] variables are populated\n** correctly for the current view. Return SQLITE_OK if successful, or an\n** SQLite error code otherwise.\n*/\nstatic int fts5CacheInstArray(Fts5Cursor *pCsr){\n  int rc = SQLITE_OK;\n  Fts5PoslistReader *aIter;       /* One iterator for each phrase */\n  int nIter;                      /* Number of iterators/phrases */\n  int nCol = ((Fts5Table*)pCsr->base.pVtab)->pConfig->nCol;\n  \n  nIter = sqlite3Fts5ExprPhraseCount(pCsr->pExpr);\n  if( pCsr->aInstIter==0 ){\n    sqlite3_int64 nByte = sizeof(Fts5PoslistReader) * nIter;\n    pCsr->aInstIter = (Fts5PoslistReader*)sqlite3Fts5MallocZero(&rc, nByte);\n  }\n  aIter = pCsr->aInstIter;\n\n  if( aIter ){\n    int nInst = 0;                /* Number instances seen so far */\n    int i;\n\n    /* Initialize all iterators */\n    for(i=0; i<nIter && rc==SQLITE_OK; i++){\n      const u8 *a;\n      int n; \n      rc = fts5CsrPoslist(pCsr, i, &a, &n);\n      if( rc==SQLITE_OK ){\n        sqlite3Fts5PoslistReaderInit(a, n, &aIter[i]);\n      }\n    }\n\n    if( rc==SQLITE_OK ){\n      while( 1 ){\n        int *aInst;\n        int iBest = -1;\n        for(i=0; i<nIter; i++){\n          if( (aIter[i].bEof==0) \n              && (iBest<0 || aIter[i].iPos<aIter[iBest].iPos) \n            ){\n            iBest = i;\n          }\n        }\n        if( iBest<0 ) break;\n\n        nInst++;\n        if( nInst>=pCsr->nInstAlloc ){\n          pCsr->nInstAlloc = pCsr->nInstAlloc ? pCsr->nInstAlloc*2 : 32;\n          aInst = (int*)sqlite3_realloc64(\n              pCsr->aInst, pCsr->nInstAlloc*sizeof(int)*3\n              );\n          if( aInst ){\n            pCsr->aInst = aInst;\n          }else{\n            rc = SQLITE_NOMEM;\n            break;\n          }\n        }\n\n        aInst = &pCsr->aInst[3 * (nInst-1)];\n        aInst[0] = iBest;\n        aInst[1] = FTS5_POS2COLUMN(aIter[iBest].iPos);\n        aInst[2] = FTS5_POS2OFFSET(aIter[iBest].iPos);\n        if( aInst[1]<0 || aInst[1]>=nCol ){\n          rc = FTS5_CORRUPT;\n          break;\n        }\n        sqlite3Fts5PoslistReaderNext(&aIter[iBest]);\n      }\n    }\n\n    pCsr->nInstCount = nInst;\n    CsrFlagClear(pCsr, FTS5CSR_REQUIRE_INST);\n  }\n  return rc;\n}\n\nstatic int fts5ApiInstCount(Fts5Context *pCtx, int *pnInst){\n  Fts5Cursor *pCsr = (Fts5Cursor*)pCtx;\n  int rc = SQLITE_OK;\n  if( CsrFlagTest(pCsr, FTS5CSR_REQUIRE_INST)==0 \n   || SQLITE_OK==(rc = fts5CacheInstArray(pCsr)) ){\n    *pnInst = pCsr->nInstCount;\n  }\n  return rc;\n}\n\nstatic int fts5ApiInst(\n  Fts5Context *pCtx, \n  int iIdx, \n  int *piPhrase, \n  int *piCol, \n  int *piOff\n){\n  Fts5Cursor *pCsr = (Fts5Cursor*)pCtx;\n  int rc = SQLITE_OK;\n  if( CsrFlagTest(pCsr, FTS5CSR_REQUIRE_INST)==0 \n   || SQLITE_OK==(rc = fts5CacheInstArray(pCsr)) \n  ){\n    if( iIdx<0 || iIdx>=pCsr->nInstCount ){\n      rc = SQLITE_RANGE;\n#if 0\n    }else if( fts5IsOffsetless((Fts5Table*)pCsr->base.pVtab) ){\n      *piPhrase = pCsr->aInst[iIdx*3];\n      *piCol = pCsr->aInst[iIdx*3 + 2];\n      *piOff = -1;\n#endif\n    }else{\n      *piPhrase = pCsr->aInst[iIdx*3];\n      *piCol = pCsr->aInst[iIdx*3 + 1];\n      *piOff = pCsr->aInst[iIdx*3 + 2];\n    }\n  }\n  return rc;\n}\n\nstatic sqlite3_int64 fts5ApiRowid(Fts5Context *pCtx){\n  return fts5CursorRowid((Fts5Cursor*)pCtx);\n}\n\nstatic int fts5ColumnSizeCb(\n  void *pContext,                 /* Pointer to int */\n  int tflags,\n  const char *pUnused,            /* Buffer containing token */\n  int nUnused,                    /* Size of token in bytes */\n  int iUnused1,                   /* Start offset of token */\n  int iUnused2                    /* End offset of token */\n){\n  int *pCnt = (int*)pContext;\n  UNUSED_PARAM2(pUnused, nUnused);\n  UNUSED_PARAM2(iUnused1, iUnused2);\n  if( (tflags & FTS5_TOKEN_COLOCATED)==0 ){\n    (*pCnt)++;\n  }\n  return SQLITE_OK;\n}\n\nstatic int fts5ApiColumnSize(Fts5Context *pCtx, int iCol, int *pnToken){\n  Fts5Cursor *pCsr = (Fts5Cursor*)pCtx;\n  Fts5FullTable *pTab = (Fts5FullTable*)(pCsr->base.pVtab);\n  Fts5Config *pConfig = pTab->p.pConfig;\n  int rc = SQLITE_OK;\n\n  if( CsrFlagTest(pCsr, FTS5CSR_REQUIRE_DOCSIZE) ){\n    if( pConfig->bColumnsize ){\n      i64 iRowid = fts5CursorRowid(pCsr);\n      rc = sqlite3Fts5StorageDocsize(pTab->pStorage, iRowid, pCsr->aColumnSize);\n    }else if( pConfig->zContent==0 ){\n      int i;\n      for(i=0; i<pConfig->nCol; i++){\n        if( pConfig->abUnindexed[i]==0 ){\n          pCsr->aColumnSize[i] = -1;\n        }\n      }\n    }else{\n      int i;\n      for(i=0; rc==SQLITE_OK && i<pConfig->nCol; i++){\n        if( pConfig->abUnindexed[i]==0 ){\n          const char *z; int n;\n          void *p = (void*)(&pCsr->aColumnSize[i]);\n          pCsr->aColumnSize[i] = 0;\n          rc = fts5ApiColumnText(pCtx, i, &z, &n);\n          if( rc==SQLITE_OK ){\n            rc = sqlite3Fts5Tokenize(\n                pConfig, FTS5_TOKENIZE_AUX, z, n, p, fts5ColumnSizeCb\n            );\n          }\n        }\n      }\n    }\n    CsrFlagClear(pCsr, FTS5CSR_REQUIRE_DOCSIZE);\n  }\n  if( iCol<0 ){\n    int i;\n    *pnToken = 0;\n    for(i=0; i<pConfig->nCol; i++){\n      *pnToken += pCsr->aColumnSize[i];\n    }\n  }else if( iCol<pConfig->nCol ){\n    *pnToken = pCsr->aColumnSize[iCol];\n  }else{\n    *pnToken = 0;\n    rc = SQLITE_RANGE;\n  }\n  return rc;\n}\n\n/*\n** Implementation of the xSetAuxdata() method.\n*/\nstatic int fts5ApiSetAuxdata(\n  Fts5Context *pCtx,              /* Fts5 context */\n  void *pPtr,                     /* Pointer to save as auxdata */\n  void(*xDelete)(void*)           /* Destructor for pPtr (or NULL) */\n){\n  Fts5Cursor *pCsr = (Fts5Cursor*)pCtx;\n  Fts5Auxdata *pData;\n\n  /* Search through the cursors list of Fts5Auxdata objects for one that\n  ** corresponds to the currently executing auxiliary function.  */\n  for(pData=pCsr->pAuxdata; pData; pData=pData->pNext){\n    if( pData->pAux==pCsr->pAux ) break;\n  }\n\n  if( pData ){\n    if( pData->xDelete ){\n      pData->xDelete(pData->pPtr);\n    }\n  }else{\n    int rc = SQLITE_OK;\n    pData = (Fts5Auxdata*)sqlite3Fts5MallocZero(&rc, sizeof(Fts5Auxdata));\n    if( pData==0 ){\n      if( xDelete ) xDelete(pPtr);\n      return rc;\n    }\n    pData->pAux = pCsr->pAux;\n    pData->pNext = pCsr->pAuxdata;\n    pCsr->pAuxdata = pData;\n  }\n\n  pData->xDelete = xDelete;\n  pData->pPtr = pPtr;\n  return SQLITE_OK;\n}\n\nstatic void *fts5ApiGetAuxdata(Fts5Context *pCtx, int bClear){\n  Fts5Cursor *pCsr = (Fts5Cursor*)pCtx;\n  Fts5Auxdata *pData;\n  void *pRet = 0;\n\n  for(pData=pCsr->pAuxdata; pData; pData=pData->pNext){\n    if( pData->pAux==pCsr->pAux ) break;\n  }\n\n  if( pData ){\n    pRet = pData->pPtr;\n    if( bClear ){\n      pData->pPtr = 0;\n      pData->xDelete = 0;\n    }\n  }\n\n  return pRet;\n}\n\nstatic void fts5ApiPhraseNext(\n  Fts5Context *pUnused, \n  Fts5PhraseIter *pIter, \n  int *piCol, int *piOff\n){\n  UNUSED_PARAM(pUnused);\n  if( pIter->a>=pIter->b ){\n    *piCol = -1;\n    *piOff = -1;\n  }else{\n    int iVal;\n    pIter->a += fts5GetVarint32(pIter->a, iVal);\n    if( iVal==1 ){\n      pIter->a += fts5GetVarint32(pIter->a, iVal);\n      *piCol = iVal;\n      *piOff = 0;\n      pIter->a += fts5GetVarint32(pIter->a, iVal);\n    }\n    *piOff += (iVal-2);\n  }\n}\n\nstatic int fts5ApiPhraseFirst(\n  Fts5Context *pCtx, \n  int iPhrase, \n  Fts5PhraseIter *pIter, \n  int *piCol, int *piOff\n){\n  Fts5Cursor *pCsr = (Fts5Cursor*)pCtx;\n  int n;\n  int rc = fts5CsrPoslist(pCsr, iPhrase, &pIter->a, &n);\n  if( rc==SQLITE_OK ){\n    pIter->b = &pIter->a[n];\n    *piCol = 0;\n    *piOff = 0;\n    fts5ApiPhraseNext(pCtx, pIter, piCol, piOff);\n  }\n  return rc;\n}\n\nstatic void fts5ApiPhraseNextColumn(\n  Fts5Context *pCtx, \n  Fts5PhraseIter *pIter, \n  int *piCol\n){\n  Fts5Cursor *pCsr = (Fts5Cursor*)pCtx;\n  Fts5Config *pConfig = ((Fts5Table*)(pCsr->base.pVtab))->pConfig;\n\n  if( pConfig->eDetail==FTS5_DETAIL_COLUMNS ){\n    if( pIter->a>=pIter->b ){\n      *piCol = -1;\n    }else{\n      int iIncr;\n      pIter->a += fts5GetVarint32(&pIter->a[0], iIncr);\n      *piCol += (iIncr-2);\n    }\n  }else{\n    while( 1 ){\n      int dummy;\n      if( pIter->a>=pIter->b ){\n        *piCol = -1;\n        return;\n      }\n      if( pIter->a[0]==0x01 ) break;\n      pIter->a += fts5GetVarint32(pIter->a, dummy);\n    }\n    pIter->a += 1 + fts5GetVarint32(&pIter->a[1], *piCol);\n  }\n}\n\nstatic int fts5ApiPhraseFirstColumn(\n  Fts5Context *pCtx, \n  int iPhrase, \n  Fts5PhraseIter *pIter, \n  int *piCol\n){\n  int rc = SQLITE_OK;\n  Fts5Cursor *pCsr = (Fts5Cursor*)pCtx;\n  Fts5Config *pConfig = ((Fts5Table*)(pCsr->base.pVtab))->pConfig;\n\n  if( pConfig->eDetail==FTS5_DETAIL_COLUMNS ){\n    Fts5Sorter *pSorter = pCsr->pSorter;\n    int n;\n    if( pSorter ){\n      int i1 = (iPhrase==0 ? 0 : pSorter->aIdx[iPhrase-1]);\n      n = pSorter->aIdx[iPhrase] - i1;\n      pIter->a = &pSorter->aPoslist[i1];\n    }else{\n      rc = sqlite3Fts5ExprPhraseCollist(pCsr->pExpr, iPhrase, &pIter->a, &n);\n    }\n    if( rc==SQLITE_OK ){\n      pIter->b = &pIter->a[n];\n      *piCol = 0;\n      fts5ApiPhraseNextColumn(pCtx, pIter, piCol);\n    }\n  }else{\n    int n;\n    rc = fts5CsrPoslist(pCsr, iPhrase, &pIter->a, &n);\n    if( rc==SQLITE_OK ){\n      pIter->b = &pIter->a[n];\n      if( n<=0 ){\n        *piCol = -1;\n      }else if( pIter->a[0]==0x01 ){\n        pIter->a += 1 + fts5GetVarint32(&pIter->a[1], *piCol);\n      }else{\n        *piCol = 0;\n      }\n    }\n  }\n\n  return rc;\n}\n\n\nstatic int fts5ApiQueryPhrase(Fts5Context*, int, void*, \n    int(*)(const Fts5ExtensionApi*, Fts5Context*, void*)\n);\n\nstatic const Fts5ExtensionApi sFts5Api = {\n  2,                            /* iVersion */\n  fts5ApiUserData,\n  fts5ApiColumnCount,\n  fts5ApiRowCount,\n  fts5ApiColumnTotalSize,\n  fts5ApiTokenize,\n  fts5ApiPhraseCount,\n  fts5ApiPhraseSize,\n  fts5ApiInstCount,\n  fts5ApiInst,\n  fts5ApiRowid,\n  fts5ApiColumnText,\n  fts5ApiColumnSize,\n  fts5ApiQueryPhrase,\n  fts5ApiSetAuxdata,\n  fts5ApiGetAuxdata,\n  fts5ApiPhraseFirst,\n  fts5ApiPhraseNext,\n  fts5ApiPhraseFirstColumn,\n  fts5ApiPhraseNextColumn,\n};\n\n/*\n** Implementation of API function xQueryPhrase().\n*/\nstatic int fts5ApiQueryPhrase(\n  Fts5Context *pCtx, \n  int iPhrase, \n  void *pUserData,\n  int(*xCallback)(const Fts5ExtensionApi*, Fts5Context*, void*)\n){\n  Fts5Cursor *pCsr = (Fts5Cursor*)pCtx;\n  Fts5FullTable *pTab = (Fts5FullTable*)(pCsr->base.pVtab);\n  int rc;\n  Fts5Cursor *pNew = 0;\n\n  rc = fts5OpenMethod(pCsr->base.pVtab, (sqlite3_vtab_cursor**)&pNew);\n  if( rc==SQLITE_OK ){\n    pNew->ePlan = FTS5_PLAN_MATCH;\n    pNew->iFirstRowid = SMALLEST_INT64;\n    pNew->iLastRowid = LARGEST_INT64;\n    pNew->base.pVtab = (sqlite3_vtab*)pTab;\n    rc = sqlite3Fts5ExprClonePhrase(pCsr->pExpr, iPhrase, &pNew->pExpr);\n  }\n\n  if( rc==SQLITE_OK ){\n    for(rc = fts5CursorFirst(pTab, pNew, 0);\n        rc==SQLITE_OK && CsrFlagTest(pNew, FTS5CSR_EOF)==0;\n        rc = fts5NextMethod((sqlite3_vtab_cursor*)pNew)\n    ){\n      rc = xCallback(&sFts5Api, (Fts5Context*)pNew, pUserData);\n      if( rc!=SQLITE_OK ){\n        if( rc==SQLITE_DONE ) rc = SQLITE_OK;\n        break;\n      }\n    }\n  }\n\n  fts5CloseMethod((sqlite3_vtab_cursor*)pNew);\n  return rc;\n}\n\nstatic void fts5ApiInvoke(\n  Fts5Auxiliary *pAux,\n  Fts5Cursor *pCsr,\n  sqlite3_context *context,\n  int argc,\n  sqlite3_value **argv\n){\n  assert( pCsr->pAux==0 );\n  pCsr->pAux = pAux;\n  pAux->xFunc(&sFts5Api, (Fts5Context*)pCsr, context, argc, argv);\n  pCsr->pAux = 0;\n}\n\nstatic Fts5Cursor *fts5CursorFromCsrid(Fts5Global *pGlobal, i64 iCsrId){\n  Fts5Cursor *pCsr;\n  for(pCsr=pGlobal->pCsr; pCsr; pCsr=pCsr->pNext){\n    if( pCsr->iCsrId==iCsrId ) break;\n  }\n  return pCsr;\n}\n\nstatic void fts5ApiCallback(\n  sqlite3_context *context,\n  int argc,\n  sqlite3_value **argv\n){\n\n  Fts5Auxiliary *pAux;\n  Fts5Cursor *pCsr;\n  i64 iCsrId;\n\n  assert( argc>=1 );\n  pAux = (Fts5Auxiliary*)sqlite3_user_data(context);\n  iCsrId = sqlite3_value_int64(argv[0]);\n\n  pCsr = fts5CursorFromCsrid(pAux->pGlobal, iCsrId);\n  if( pCsr==0 ){\n    char *zErr = sqlite3_mprintf(\"no such cursor: %lld\", iCsrId);\n    sqlite3_result_error(context, zErr, -1);\n    sqlite3_free(zErr);\n  }else{\n    fts5ApiInvoke(pAux, pCsr, context, argc-1, &argv[1]);\n  }\n}\n\n\n/*\n** Given cursor id iId, return a pointer to the corresponding Fts5Table \n** object. Or NULL If the cursor id does not exist.\n*/\nstatic Fts5Table *sqlite3Fts5TableFromCsrid(\n  Fts5Global *pGlobal,            /* FTS5 global context for db handle */\n  i64 iCsrId                      /* Id of cursor to find */\n){\n  Fts5Cursor *pCsr;\n  pCsr = fts5CursorFromCsrid(pGlobal, iCsrId);\n  if( pCsr ){\n    return (Fts5Table*)pCsr->base.pVtab;\n  }\n  return 0;\n}\n\n/*\n** Return a \"position-list blob\" corresponding to the current position of\n** cursor pCsr via sqlite3_result_blob(). A position-list blob contains\n** the current position-list for each phrase in the query associated with\n** cursor pCsr.\n**\n** A position-list blob begins with (nPhrase-1) varints, where nPhrase is\n** the number of phrases in the query. Following the varints are the\n** concatenated position lists for each phrase, in order.\n**\n** The first varint (if it exists) contains the size of the position list\n** for phrase 0. The second (same disclaimer) contains the size of position\n** list 1. And so on. There is no size field for the final position list,\n** as it can be derived from the total size of the blob.\n*/\nstatic int fts5PoslistBlob(sqlite3_context *pCtx, Fts5Cursor *pCsr){\n  int i;\n  int rc = SQLITE_OK;\n  int nPhrase = sqlite3Fts5ExprPhraseCount(pCsr->pExpr);\n  Fts5Buffer val;\n\n  memset(&val, 0, sizeof(Fts5Buffer));\n  switch( ((Fts5Table*)(pCsr->base.pVtab))->pConfig->eDetail ){\n    case FTS5_DETAIL_FULL:\n\n      /* Append the varints */\n      for(i=0; i<(nPhrase-1); i++){\n        const u8 *dummy;\n        int nByte = sqlite3Fts5ExprPoslist(pCsr->pExpr, i, &dummy);\n        sqlite3Fts5BufferAppendVarint(&rc, &val, nByte);\n      }\n\n      /* Append the position lists */\n      for(i=0; i<nPhrase; i++){\n        const u8 *pPoslist;\n        int nPoslist;\n        nPoslist = sqlite3Fts5ExprPoslist(pCsr->pExpr, i, &pPoslist);\n        sqlite3Fts5BufferAppendBlob(&rc, &val, nPoslist, pPoslist);\n      }\n      break;\n\n    case FTS5_DETAIL_COLUMNS:\n\n      /* Append the varints */\n      for(i=0; rc==SQLITE_OK && i<(nPhrase-1); i++){\n        const u8 *dummy;\n        int nByte;\n        rc = sqlite3Fts5ExprPhraseCollist(pCsr->pExpr, i, &dummy, &nByte);\n        sqlite3Fts5BufferAppendVarint(&rc, &val, nByte);\n      }\n\n      /* Append the position lists */\n      for(i=0; rc==SQLITE_OK && i<nPhrase; i++){\n        const u8 *pPoslist;\n        int nPoslist;\n        rc = sqlite3Fts5ExprPhraseCollist(pCsr->pExpr, i, &pPoslist, &nPoslist);\n        sqlite3Fts5BufferAppendBlob(&rc, &val, nPoslist, pPoslist);\n      }\n      break;\n\n    default:\n      break;\n  }\n\n  sqlite3_result_blob(pCtx, val.p, val.n, sqlite3_free);\n  return rc;\n}\n\n/* \n** This is the xColumn method, called by SQLite to request a value from\n** the row that the supplied cursor currently points to.\n*/\nstatic int fts5ColumnMethod(\n  sqlite3_vtab_cursor *pCursor,   /* Cursor to retrieve value from */\n  sqlite3_context *pCtx,          /* Context for sqlite3_result_xxx() calls */\n  int iCol                        /* Index of column to read value from */\n){\n  Fts5FullTable *pTab = (Fts5FullTable*)(pCursor->pVtab);\n  Fts5Config *pConfig = pTab->p.pConfig;\n  Fts5Cursor *pCsr = (Fts5Cursor*)pCursor;\n  int rc = SQLITE_OK;\n  \n  assert( CsrFlagTest(pCsr, FTS5CSR_EOF)==0 );\n\n  if( pCsr->ePlan==FTS5_PLAN_SPECIAL ){\n    if( iCol==pConfig->nCol ){\n      sqlite3_result_int64(pCtx, pCsr->iSpecial);\n    }\n  }else\n\n  if( iCol==pConfig->nCol ){\n    /* User is requesting the value of the special column with the same name\n    ** as the table. Return the cursor integer id number. This value is only\n    ** useful in that it may be passed as the first argument to an FTS5\n    ** auxiliary function.  */\n    sqlite3_result_int64(pCtx, pCsr->iCsrId);\n  }else if( iCol==pConfig->nCol+1 ){\n\n    /* The value of the \"rank\" column. */\n    if( pCsr->ePlan==FTS5_PLAN_SOURCE ){\n      fts5PoslistBlob(pCtx, pCsr);\n    }else if( \n        pCsr->ePlan==FTS5_PLAN_MATCH\n     || pCsr->ePlan==FTS5_PLAN_SORTED_MATCH\n    ){\n      if( pCsr->pRank || SQLITE_OK==(rc = fts5FindRankFunction(pCsr)) ){\n        fts5ApiInvoke(pCsr->pRank, pCsr, pCtx, pCsr->nRankArg, pCsr->apRankArg);\n      }\n    }\n  }else if( !fts5IsContentless(pTab) ){\n    rc = fts5SeekCursor(pCsr, 1);\n    if( rc==SQLITE_OK ){\n      sqlite3_result_value(pCtx, sqlite3_column_value(pCsr->pStmt, iCol+1));\n    }\n  }\n  return rc;\n}\n\n\n/*\n** This routine implements the xFindFunction method for the FTS3\n** virtual table.\n*/\nstatic int fts5FindFunctionMethod(\n  sqlite3_vtab *pVtab,            /* Virtual table handle */\n  int nUnused,                    /* Number of SQL function arguments */\n  const char *zName,              /* Name of SQL function */\n  void (**pxFunc)(sqlite3_context*,int,sqlite3_value**), /* OUT: Result */\n  void **ppArg                    /* OUT: User data for *pxFunc */\n){\n  Fts5FullTable *pTab = (Fts5FullTable*)pVtab;\n  Fts5Auxiliary *pAux;\n\n  UNUSED_PARAM(nUnused);\n  pAux = fts5FindAuxiliary(pTab, zName);\n  if( pAux ){\n    *pxFunc = fts5ApiCallback;\n    *ppArg = (void*)pAux;\n    return 1;\n  }\n\n  /* No function of the specified name was found. Return 0. */\n  return 0;\n}\n\n/*\n** Implementation of FTS5 xRename method. Rename an fts5 table.\n*/\nstatic int fts5RenameMethod(\n  sqlite3_vtab *pVtab,            /* Virtual table handle */\n  const char *zName               /* New name of table */\n){\n  Fts5FullTable *pTab = (Fts5FullTable*)pVtab;\n  return sqlite3Fts5StorageRename(pTab->pStorage, zName);\n}\n\nstatic int sqlite3Fts5FlushToDisk(Fts5Table *pTab){\n  fts5TripCursors((Fts5FullTable*)pTab);\n  return sqlite3Fts5StorageSync(((Fts5FullTable*)pTab)->pStorage);\n}\n\n/*\n** The xSavepoint() method.\n**\n** Flush the contents of the pending-terms table to disk.\n*/\nstatic int fts5SavepointMethod(sqlite3_vtab *pVtab, int iSavepoint){\n  UNUSED_PARAM(iSavepoint);  /* Call below is a no-op for NDEBUG builds */\n  fts5CheckTransactionState((Fts5FullTable*)pVtab, FTS5_SAVEPOINT, iSavepoint);\n  return sqlite3Fts5FlushToDisk((Fts5Table*)pVtab);\n}\n\n/*\n** The xRelease() method.\n**\n** This is a no-op.\n*/\nstatic int fts5ReleaseMethod(sqlite3_vtab *pVtab, int iSavepoint){\n  UNUSED_PARAM(iSavepoint);  /* Call below is a no-op for NDEBUG builds */\n  fts5CheckTransactionState((Fts5FullTable*)pVtab, FTS5_RELEASE, iSavepoint);\n  return sqlite3Fts5FlushToDisk((Fts5Table*)pVtab);\n}\n\n/*\n** The xRollbackTo() method.\n**\n** Discard the contents of the pending terms table.\n*/\nstatic int fts5RollbackToMethod(sqlite3_vtab *pVtab, int iSavepoint){\n  Fts5FullTable *pTab = (Fts5FullTable*)pVtab;\n  UNUSED_PARAM(iSavepoint);  /* Call below is a no-op for NDEBUG builds */\n  fts5CheckTransactionState(pTab, FTS5_ROLLBACKTO, iSavepoint);\n  fts5TripCursors(pTab);\n  return sqlite3Fts5StorageRollback(pTab->pStorage);\n}\n\n/*\n** Register a new auxiliary function with global context pGlobal.\n*/\nstatic int fts5CreateAux(\n  fts5_api *pApi,                 /* Global context (one per db handle) */\n  const char *zName,              /* Name of new function */\n  void *pUserData,                /* User data for aux. function */\n  fts5_extension_function xFunc,  /* Aux. function implementation */\n  void(*xDestroy)(void*)          /* Destructor for pUserData */\n){\n  Fts5Global *pGlobal = (Fts5Global*)pApi;\n  int rc = sqlite3_overload_function(pGlobal->db, zName, -1);\n  if( rc==SQLITE_OK ){\n    Fts5Auxiliary *pAux;\n    int nName;                      /* Size of zName in bytes, including \\0 */\n    int nByte;                      /* Bytes of space to allocate */\n\n    nName = (int)strlen(zName) + 1;\n    nByte = sizeof(Fts5Auxiliary) + nName;\n    pAux = (Fts5Auxiliary*)sqlite3_malloc(nByte);\n    if( pAux ){\n      memset(pAux, 0, nByte);\n      pAux->zFunc = (char*)&pAux[1];\n      memcpy(pAux->zFunc, zName, nName);\n      pAux->pGlobal = pGlobal;\n      pAux->pUserData = pUserData;\n      pAux->xFunc = xFunc;\n      pAux->xDestroy = xDestroy;\n      pAux->pNext = pGlobal->pAux;\n      pGlobal->pAux = pAux;\n    }else{\n      rc = SQLITE_NOMEM;\n    }\n  }\n\n  return rc;\n}\n\n/*\n** Register a new tokenizer. This is the implementation of the \n** fts5_api.xCreateTokenizer() method.\n*/\nstatic int fts5CreateTokenizer(\n  fts5_api *pApi,                 /* Global context (one per db handle) */\n  const char *zName,              /* Name of new function */\n  void *pUserData,                /* User data for aux. function */\n  fts5_tokenizer *pTokenizer,     /* Tokenizer implementation */\n  void(*xDestroy)(void*)          /* Destructor for pUserData */\n){\n  Fts5Global *pGlobal = (Fts5Global*)pApi;\n  Fts5TokenizerModule *pNew;\n  int nName;                      /* Size of zName and its \\0 terminator */\n  int nByte;                      /* Bytes of space to allocate */\n  int rc = SQLITE_OK;\n\n  nName = (int)strlen(zName) + 1;\n  nByte = sizeof(Fts5TokenizerModule) + nName;\n  pNew = (Fts5TokenizerModule*)sqlite3_malloc(nByte);\n  if( pNew ){\n    memset(pNew, 0, nByte);\n    pNew->zName = (char*)&pNew[1];\n    memcpy(pNew->zName, zName, nName);\n    pNew->pUserData = pUserData;\n    pNew->x = *pTokenizer;\n    pNew->xDestroy = xDestroy;\n    pNew->pNext = pGlobal->pTok;\n    pGlobal->pTok = pNew;\n    if( pNew->pNext==0 ){\n      pGlobal->pDfltTok = pNew;\n    }\n  }else{\n    rc = SQLITE_NOMEM;\n  }\n\n  return rc;\n}\n\nstatic Fts5TokenizerModule *fts5LocateTokenizer(\n  Fts5Global *pGlobal, \n  const char *zName\n){\n  Fts5TokenizerModule *pMod = 0;\n\n  if( zName==0 ){\n    pMod = pGlobal->pDfltTok;\n  }else{\n    for(pMod=pGlobal->pTok; pMod; pMod=pMod->pNext){\n      if( sqlite3_stricmp(zName, pMod->zName)==0 ) break;\n    }\n  }\n\n  return pMod;\n}\n\n/*\n** Find a tokenizer. This is the implementation of the \n** fts5_api.xFindTokenizer() method.\n*/\nstatic int fts5FindTokenizer(\n  fts5_api *pApi,                 /* Global context (one per db handle) */\n  const char *zName,              /* Name of new function */\n  void **ppUserData,\n  fts5_tokenizer *pTokenizer      /* Populate this object */\n){\n  int rc = SQLITE_OK;\n  Fts5TokenizerModule *pMod;\n\n  pMod = fts5LocateTokenizer((Fts5Global*)pApi, zName);\n  if( pMod ){\n    *pTokenizer = pMod->x;\n    *ppUserData = pMod->pUserData;\n  }else{\n    memset(pTokenizer, 0, sizeof(fts5_tokenizer));\n    rc = SQLITE_ERROR;\n  }\n\n  return rc;\n}\n\nstatic int sqlite3Fts5GetTokenizer(\n  Fts5Global *pGlobal, \n  const char **azArg,\n  int nArg,\n  Fts5Tokenizer **ppTok,\n  fts5_tokenizer **ppTokApi,\n  char **pzErr\n){\n  Fts5TokenizerModule *pMod;\n  int rc = SQLITE_OK;\n\n  pMod = fts5LocateTokenizer(pGlobal, nArg==0 ? 0 : azArg[0]);\n  if( pMod==0 ){\n    assert( nArg>0 );\n    rc = SQLITE_ERROR;\n    *pzErr = sqlite3_mprintf(\"no such tokenizer: %s\", azArg[0]);\n  }else{\n    rc = pMod->x.xCreate(pMod->pUserData, &azArg[1], (nArg?nArg-1:0), ppTok);\n    *ppTokApi = &pMod->x;\n    if( rc!=SQLITE_OK && pzErr ){\n      *pzErr = sqlite3_mprintf(\"error in tokenizer constructor\");\n    }\n  }\n\n  if( rc!=SQLITE_OK ){\n    *ppTokApi = 0;\n    *ppTok = 0;\n  }\n\n  return rc;\n}\n\nstatic void fts5ModuleDestroy(void *pCtx){\n  Fts5TokenizerModule *pTok, *pNextTok;\n  Fts5Auxiliary *pAux, *pNextAux;\n  Fts5Global *pGlobal = (Fts5Global*)pCtx;\n\n  for(pAux=pGlobal->pAux; pAux; pAux=pNextAux){\n    pNextAux = pAux->pNext;\n    if( pAux->xDestroy ) pAux->xDestroy(pAux->pUserData);\n    sqlite3_free(pAux);\n  }\n\n  for(pTok=pGlobal->pTok; pTok; pTok=pNextTok){\n    pNextTok = pTok->pNext;\n    if( pTok->xDestroy ) pTok->xDestroy(pTok->pUserData);\n    sqlite3_free(pTok);\n  }\n\n  sqlite3_free(pGlobal);\n}\n\nstatic void fts5Fts5Func(\n  sqlite3_context *pCtx,          /* Function call context */\n  int nArg,                       /* Number of args */\n  sqlite3_value **apArg           /* Function arguments */\n){\n  Fts5Global *pGlobal = (Fts5Global*)sqlite3_user_data(pCtx);\n  fts5_api **ppApi;\n  UNUSED_PARAM(nArg);\n  assert( nArg==1 );\n  ppApi = (fts5_api**)sqlite3_value_pointer(apArg[0], \"fts5_api_ptr\");\n  if( ppApi ) *ppApi = &pGlobal->api;\n}\n\n/*\n** Implementation of fts5_source_id() function.\n*/\nstatic void fts5SourceIdFunc(\n  sqlite3_context *pCtx,          /* Function call context */\n  int nArg,                       /* Number of args */\n  sqlite3_value **apUnused        /* Function arguments */\n){\n  assert( nArg==0 );\n  UNUSED_PARAM2(nArg, apUnused);\n  sqlite3_result_text(pCtx, \"fts5: 2019-02-25 16:06:06 bd49a8271d650fa89e446b42e513b595a717b9212c91dd384aab871fc1d0f6d7\", -1, SQLITE_TRANSIENT);\n}\n\n/*\n** Return true if zName is the extension on one of the shadow tables used\n** by this module.\n*/\nstatic int fts5ShadowName(const char *zName){\n  static const char *azName[] = {\n    \"config\", \"content\", \"data\", \"docsize\", \"idx\"\n  };\n  unsigned int i;\n  for(i=0; i<sizeof(azName)/sizeof(azName[0]); i++){\n    if( sqlite3_stricmp(zName, azName[i])==0 ) return 1;\n  }\n  return 0;\n}\n\nstatic int fts5Init(sqlite3 *db){\n  static const sqlite3_module fts5Mod = {\n    /* iVersion      */ 3,\n    /* xCreate       */ fts5CreateMethod,\n    /* xConnect      */ fts5ConnectMethod,\n    /* xBestIndex    */ fts5BestIndexMethod,\n    /* xDisconnect   */ fts5DisconnectMethod,\n    /* xDestroy      */ fts5DestroyMethod,\n    /* xOpen         */ fts5OpenMethod,\n    /* xClose        */ fts5CloseMethod,\n    /* xFilter       */ fts5FilterMethod,\n    /* xNext         */ fts5NextMethod,\n    /* xEof          */ fts5EofMethod,\n    /* xColumn       */ fts5ColumnMethod,\n    /* xRowid        */ fts5RowidMethod,\n    /* xUpdate       */ fts5UpdateMethod,\n    /* xBegin        */ fts5BeginMethod,\n    /* xSync         */ fts5SyncMethod,\n    /* xCommit       */ fts5CommitMethod,\n    /* xRollback     */ fts5RollbackMethod,\n    /* xFindFunction */ fts5FindFunctionMethod,\n    /* xRename       */ fts5RenameMethod,\n    /* xSavepoint    */ fts5SavepointMethod,\n    /* xRelease      */ fts5ReleaseMethod,\n    /* xRollbackTo   */ fts5RollbackToMethod,\n    /* xShadowName   */ fts5ShadowName\n  };\n\n  int rc;\n  Fts5Global *pGlobal = 0;\n\n  pGlobal = (Fts5Global*)sqlite3_malloc(sizeof(Fts5Global));\n  if( pGlobal==0 ){\n    rc = SQLITE_NOMEM;\n  }else{\n    void *p = (void*)pGlobal;\n    memset(pGlobal, 0, sizeof(Fts5Global));\n    pGlobal->db = db;\n    pGlobal->api.iVersion = 2;\n    pGlobal->api.xCreateFunction = fts5CreateAux;\n    pGlobal->api.xCreateTokenizer = fts5CreateTokenizer;\n    pGlobal->api.xFindTokenizer = fts5FindTokenizer;\n    rc = sqlite3_create_module_v2(db, \"fts5\", &fts5Mod, p, fts5ModuleDestroy);\n    if( rc==SQLITE_OK ) rc = sqlite3Fts5IndexInit(db);\n    if( rc==SQLITE_OK ) rc = sqlite3Fts5ExprInit(pGlobal, db);\n    if( rc==SQLITE_OK ) rc = sqlite3Fts5AuxInit(&pGlobal->api);\n    if( rc==SQLITE_OK ) rc = sqlite3Fts5TokenizerInit(&pGlobal->api);\n    if( rc==SQLITE_OK ) rc = sqlite3Fts5VocabInit(pGlobal, db);\n    if( rc==SQLITE_OK ){\n      rc = sqlite3_create_function(\n          db, \"fts5\", 1, SQLITE_UTF8, p, fts5Fts5Func, 0, 0\n      );\n    }\n    if( rc==SQLITE_OK ){\n      rc = sqlite3_create_function(\n          db, \"fts5_source_id\", 0, SQLITE_UTF8, p, fts5SourceIdFunc, 0, 0\n      );\n    }\n  }\n\n  /* If SQLITE_FTS5_ENABLE_TEST_MI is defined, assume that the file\n  ** fts5_test_mi.c is compiled and linked into the executable. And call\n  ** its entry point to enable the matchinfo() demo.  */\n#ifdef SQLITE_FTS5_ENABLE_TEST_MI\n  if( rc==SQLITE_OK ){\n    extern int sqlite3Fts5TestRegisterMatchinfo(sqlite3*);\n    rc = sqlite3Fts5TestRegisterMatchinfo(db);\n  }\n#endif\n\n  return rc;\n}\n\n/*\n** The following functions are used to register the module with SQLite. If\n** this module is being built as part of the SQLite core (SQLITE_CORE is\n** defined), then sqlite3_open() will call sqlite3Fts5Init() directly.\n**\n** Or, if this module is being built as a loadable extension, \n** sqlite3Fts5Init() is omitted and the two standard entry points\n** sqlite3_fts_init() and sqlite3_fts5_init() defined instead.\n*/\n#ifndef SQLITE_CORE\n#ifdef _WIN32\n__declspec(dllexport)\n#endif\nSQLITE_API int sqlite3_fts_init(\n  sqlite3 *db,\n  char **pzErrMsg,\n  const sqlite3_api_routines *pApi\n){\n  SQLITE_EXTENSION_INIT2(pApi);\n  (void)pzErrMsg;  /* Unused parameter */\n  return fts5Init(db);\n}\n\n#ifdef _WIN32\n__declspec(dllexport)\n#endif\nSQLITE_API int sqlite3_fts5_init(\n  sqlite3 *db,\n  char **pzErrMsg,\n  const sqlite3_api_routines *pApi\n){\n  SQLITE_EXTENSION_INIT2(pApi);\n  (void)pzErrMsg;  /* Unused parameter */\n  return fts5Init(db);\n}\n#else\nSQLITE_PRIVATE int sqlite3Fts5Init(sqlite3 *db){\n  return fts5Init(db);\n}\n#endif\n\n/*\n** 2014 May 31\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n******************************************************************************\n**\n*/\n\n\n\n/* #include \"fts5Int.h\" */\n\nstruct Fts5Storage {\n  Fts5Config *pConfig;\n  Fts5Index *pIndex;\n  int bTotalsValid;               /* True if nTotalRow/aTotalSize[] are valid */\n  i64 nTotalRow;                  /* Total number of rows in FTS table */\n  i64 *aTotalSize;                /* Total sizes of each column */ \n  sqlite3_stmt *aStmt[11];\n};\n\n\n#if FTS5_STMT_SCAN_ASC!=0 \n# error \"FTS5_STMT_SCAN_ASC mismatch\" \n#endif\n#if FTS5_STMT_SCAN_DESC!=1 \n# error \"FTS5_STMT_SCAN_DESC mismatch\" \n#endif\n#if FTS5_STMT_LOOKUP!=2\n# error \"FTS5_STMT_LOOKUP mismatch\" \n#endif\n\n#define FTS5_STMT_INSERT_CONTENT  3\n#define FTS5_STMT_REPLACE_CONTENT 4\n#define FTS5_STMT_DELETE_CONTENT  5\n#define FTS5_STMT_REPLACE_DOCSIZE  6\n#define FTS5_STMT_DELETE_DOCSIZE  7\n#define FTS5_STMT_LOOKUP_DOCSIZE  8\n#define FTS5_STMT_REPLACE_CONFIG 9\n#define FTS5_STMT_SCAN 10\n\n/*\n** Prepare the two insert statements - Fts5Storage.pInsertContent and\n** Fts5Storage.pInsertDocsize - if they have not already been prepared.\n** Return SQLITE_OK if successful, or an SQLite error code if an error\n** occurs.\n*/\nstatic int fts5StorageGetStmt(\n  Fts5Storage *p,                 /* Storage handle */\n  int eStmt,                      /* FTS5_STMT_XXX constant */\n  sqlite3_stmt **ppStmt,          /* OUT: Prepared statement handle */\n  char **pzErrMsg                 /* OUT: Error message (if any) */\n){\n  int rc = SQLITE_OK;\n\n  /* If there is no %_docsize table, there should be no requests for \n  ** statements to operate on it.  */\n  assert( p->pConfig->bColumnsize || (\n        eStmt!=FTS5_STMT_REPLACE_DOCSIZE \n     && eStmt!=FTS5_STMT_DELETE_DOCSIZE \n     && eStmt!=FTS5_STMT_LOOKUP_DOCSIZE \n  ));\n\n  assert( eStmt>=0 && eStmt<ArraySize(p->aStmt) );\n  if( p->aStmt[eStmt]==0 ){\n    const char *azStmt[] = {\n      \"SELECT %s FROM %s T WHERE T.%Q >= ? AND T.%Q <= ? ORDER BY T.%Q ASC\",\n      \"SELECT %s FROM %s T WHERE T.%Q <= ? AND T.%Q >= ? ORDER BY T.%Q DESC\",\n      \"SELECT %s FROM %s T WHERE T.%Q=?\",               /* LOOKUP  */\n\n      \"INSERT INTO %Q.'%q_content' VALUES(%s)\",         /* INSERT_CONTENT  */\n      \"REPLACE INTO %Q.'%q_content' VALUES(%s)\",        /* REPLACE_CONTENT */\n      \"DELETE FROM %Q.'%q_content' WHERE id=?\",         /* DELETE_CONTENT  */\n      \"REPLACE INTO %Q.'%q_docsize' VALUES(?,?)\",       /* REPLACE_DOCSIZE  */\n      \"DELETE FROM %Q.'%q_docsize' WHERE id=?\",         /* DELETE_DOCSIZE  */\n\n      \"SELECT sz FROM %Q.'%q_docsize' WHERE id=?\",      /* LOOKUP_DOCSIZE  */\n\n      \"REPLACE INTO %Q.'%q_config' VALUES(?,?)\",        /* REPLACE_CONFIG */\n      \"SELECT %s FROM %s AS T\",                         /* SCAN */\n    };\n    Fts5Config *pC = p->pConfig;\n    char *zSql = 0;\n\n    switch( eStmt ){\n      case FTS5_STMT_SCAN:\n        zSql = sqlite3_mprintf(azStmt[eStmt], \n            pC->zContentExprlist, pC->zContent\n        );\n        break;\n\n      case FTS5_STMT_SCAN_ASC:\n      case FTS5_STMT_SCAN_DESC:\n        zSql = sqlite3_mprintf(azStmt[eStmt], pC->zContentExprlist, \n            pC->zContent, pC->zContentRowid, pC->zContentRowid,\n            pC->zContentRowid\n        );\n        break;\n\n      case FTS5_STMT_LOOKUP:\n        zSql = sqlite3_mprintf(azStmt[eStmt], \n            pC->zContentExprlist, pC->zContent, pC->zContentRowid\n        );\n        break;\n\n      case FTS5_STMT_INSERT_CONTENT: \n      case FTS5_STMT_REPLACE_CONTENT: {\n        int nCol = pC->nCol + 1;\n        char *zBind;\n        int i;\n\n        zBind = sqlite3_malloc64(1 + nCol*2);\n        if( zBind ){\n          for(i=0; i<nCol; i++){\n            zBind[i*2] = '?';\n            zBind[i*2 + 1] = ',';\n          }\n          zBind[i*2-1] = '\\0';\n          zSql = sqlite3_mprintf(azStmt[eStmt], pC->zDb, pC->zName, zBind);\n          sqlite3_free(zBind);\n        }\n        break;\n      }\n\n      default:\n        zSql = sqlite3_mprintf(azStmt[eStmt], pC->zDb, pC->zName);\n        break;\n    }\n\n    if( zSql==0 ){\n      rc = SQLITE_NOMEM;\n    }else{\n      int f = SQLITE_PREPARE_PERSISTENT;\n      if( eStmt>FTS5_STMT_LOOKUP ) f |= SQLITE_PREPARE_NO_VTAB;\n      rc = sqlite3_prepare_v3(pC->db, zSql, -1, f, &p->aStmt[eStmt], 0);\n      sqlite3_free(zSql);\n      if( rc!=SQLITE_OK && pzErrMsg ){\n        *pzErrMsg = sqlite3_mprintf(\"%s\", sqlite3_errmsg(pC->db));\n      }\n    }\n  }\n\n  *ppStmt = p->aStmt[eStmt];\n  sqlite3_reset(*ppStmt);\n  return rc;\n}\n\n\nstatic int fts5ExecPrintf(\n  sqlite3 *db,\n  char **pzErr,\n  const char *zFormat,\n  ...\n){\n  int rc;\n  va_list ap;                     /* ... printf arguments */\n  char *zSql;\n\n  va_start(ap, zFormat);\n  zSql = sqlite3_vmprintf(zFormat, ap);\n\n  if( zSql==0 ){\n    rc = SQLITE_NOMEM;\n  }else{\n    rc = sqlite3_exec(db, zSql, 0, 0, pzErr);\n    sqlite3_free(zSql);\n  }\n\n  va_end(ap);\n  return rc;\n}\n\n/*\n** Drop all shadow tables. Return SQLITE_OK if successful or an SQLite error\n** code otherwise.\n*/\nstatic int sqlite3Fts5DropAll(Fts5Config *pConfig){\n  int rc = fts5ExecPrintf(pConfig->db, 0, \n      \"DROP TABLE IF EXISTS %Q.'%q_data';\"\n      \"DROP TABLE IF EXISTS %Q.'%q_idx';\"\n      \"DROP TABLE IF EXISTS %Q.'%q_config';\",\n      pConfig->zDb, pConfig->zName,\n      pConfig->zDb, pConfig->zName,\n      pConfig->zDb, pConfig->zName\n  );\n  if( rc==SQLITE_OK && pConfig->bColumnsize ){\n    rc = fts5ExecPrintf(pConfig->db, 0, \n        \"DROP TABLE IF EXISTS %Q.'%q_docsize';\",\n        pConfig->zDb, pConfig->zName\n    );\n  }\n  if( rc==SQLITE_OK && pConfig->eContent==FTS5_CONTENT_NORMAL ){\n    rc = fts5ExecPrintf(pConfig->db, 0, \n        \"DROP TABLE IF EXISTS %Q.'%q_content';\",\n        pConfig->zDb, pConfig->zName\n    );\n  }\n  return rc;\n}\n\nstatic void fts5StorageRenameOne(\n  Fts5Config *pConfig,            /* Current FTS5 configuration */\n  int *pRc,                       /* IN/OUT: Error code */\n  const char *zTail,              /* Tail of table name e.g. \"data\", \"config\" */\n  const char *zName               /* New name of FTS5 table */\n){\n  if( *pRc==SQLITE_OK ){\n    *pRc = fts5ExecPrintf(pConfig->db, 0, \n        \"ALTER TABLE %Q.'%q_%s' RENAME TO '%q_%s';\",\n        pConfig->zDb, pConfig->zName, zTail, zName, zTail\n    );\n  }\n}\n\nstatic int sqlite3Fts5StorageRename(Fts5Storage *pStorage, const char *zName){\n  Fts5Config *pConfig = pStorage->pConfig;\n  int rc = sqlite3Fts5StorageSync(pStorage);\n\n  fts5StorageRenameOne(pConfig, &rc, \"data\", zName);\n  fts5StorageRenameOne(pConfig, &rc, \"idx\", zName);\n  fts5StorageRenameOne(pConfig, &rc, \"config\", zName);\n  if( pConfig->bColumnsize ){\n    fts5StorageRenameOne(pConfig, &rc, \"docsize\", zName);\n  }\n  if( pConfig->eContent==FTS5_CONTENT_NORMAL ){\n    fts5StorageRenameOne(pConfig, &rc, \"content\", zName);\n  }\n  return rc;\n}\n\n/*\n** Create the shadow table named zPost, with definition zDefn. Return\n** SQLITE_OK if successful, or an SQLite error code otherwise.\n*/\nstatic int sqlite3Fts5CreateTable(\n  Fts5Config *pConfig,            /* FTS5 configuration */\n  const char *zPost,              /* Shadow table to create (e.g. \"content\") */\n  const char *zDefn,              /* Columns etc. for shadow table */\n  int bWithout,                   /* True for without rowid */\n  char **pzErr                    /* OUT: Error message */\n){\n  int rc;\n  char *zErr = 0;\n\n  rc = fts5ExecPrintf(pConfig->db, &zErr, \"CREATE TABLE %Q.'%q_%q'(%s)%s\",\n      pConfig->zDb, pConfig->zName, zPost, zDefn, \n#ifndef SQLITE_FTS5_NO_WITHOUT_ROWID\n      bWithout?\" WITHOUT ROWID\":\n#endif\n      \"\"\n  );\n  if( zErr ){\n    *pzErr = sqlite3_mprintf(\n        \"fts5: error creating shadow table %q_%s: %s\", \n        pConfig->zName, zPost, zErr\n    );\n    sqlite3_free(zErr);\n  }\n\n  return rc;\n}\n\n/*\n** Open a new Fts5Index handle. If the bCreate argument is true, create\n** and initialize the underlying tables \n**\n** If successful, set *pp to point to the new object and return SQLITE_OK.\n** Otherwise, set *pp to NULL and return an SQLite error code.\n*/\nstatic int sqlite3Fts5StorageOpen(\n  Fts5Config *pConfig, \n  Fts5Index *pIndex, \n  int bCreate, \n  Fts5Storage **pp,\n  char **pzErr                    /* OUT: Error message */\n){\n  int rc = SQLITE_OK;\n  Fts5Storage *p;                 /* New object */\n  sqlite3_int64 nByte;            /* Bytes of space to allocate */\n\n  nByte = sizeof(Fts5Storage)               /* Fts5Storage object */\n        + pConfig->nCol * sizeof(i64);      /* Fts5Storage.aTotalSize[] */\n  *pp = p = (Fts5Storage*)sqlite3_malloc64(nByte);\n  if( !p ) return SQLITE_NOMEM;\n\n  memset(p, 0, nByte);\n  p->aTotalSize = (i64*)&p[1];\n  p->pConfig = pConfig;\n  p->pIndex = pIndex;\n\n  if( bCreate ){\n    if( pConfig->eContent==FTS5_CONTENT_NORMAL ){\n      int nDefn = 32 + pConfig->nCol*10;\n      char *zDefn = sqlite3_malloc64(32 + (sqlite3_int64)pConfig->nCol * 10);\n      if( zDefn==0 ){\n        rc = SQLITE_NOMEM;\n      }else{\n        int i;\n        int iOff;\n        sqlite3_snprintf(nDefn, zDefn, \"id INTEGER PRIMARY KEY\");\n        iOff = (int)strlen(zDefn);\n        for(i=0; i<pConfig->nCol; i++){\n          sqlite3_snprintf(nDefn-iOff, &zDefn[iOff], \", c%d\", i);\n          iOff += (int)strlen(&zDefn[iOff]);\n        }\n        rc = sqlite3Fts5CreateTable(pConfig, \"content\", zDefn, 0, pzErr);\n      }\n      sqlite3_free(zDefn);\n    }\n\n    if( rc==SQLITE_OK && pConfig->bColumnsize ){\n      rc = sqlite3Fts5CreateTable(\n          pConfig, \"docsize\", \"id INTEGER PRIMARY KEY, sz BLOB\", 0, pzErr\n      );\n    }\n    if( rc==SQLITE_OK ){\n      rc = sqlite3Fts5CreateTable(\n          pConfig, \"config\", \"k PRIMARY KEY, v\", 1, pzErr\n      );\n    }\n    if( rc==SQLITE_OK ){\n      rc = sqlite3Fts5StorageConfigValue(p, \"version\", 0, FTS5_CURRENT_VERSION);\n    }\n  }\n\n  if( rc ){\n    sqlite3Fts5StorageClose(p);\n    *pp = 0;\n  }\n  return rc;\n}\n\n/*\n** Close a handle opened by an earlier call to sqlite3Fts5StorageOpen().\n*/\nstatic int sqlite3Fts5StorageClose(Fts5Storage *p){\n  int rc = SQLITE_OK;\n  if( p ){\n    int i;\n\n    /* Finalize all SQL statements */\n    for(i=0; i<ArraySize(p->aStmt); i++){\n      sqlite3_finalize(p->aStmt[i]);\n    }\n\n    sqlite3_free(p);\n  }\n  return rc;\n}\n\ntypedef struct Fts5InsertCtx Fts5InsertCtx;\nstruct Fts5InsertCtx {\n  Fts5Storage *pStorage;\n  int iCol;\n  int szCol;                      /* Size of column value in tokens */\n};\n\n/*\n** Tokenization callback used when inserting tokens into the FTS index.\n*/\nstatic int fts5StorageInsertCallback(\n  void *pContext,                 /* Pointer to Fts5InsertCtx object */\n  int tflags,\n  const char *pToken,             /* Buffer containing token */\n  int nToken,                     /* Size of token in bytes */\n  int iUnused1,                   /* Start offset of token */\n  int iUnused2                    /* End offset of token */\n){\n  Fts5InsertCtx *pCtx = (Fts5InsertCtx*)pContext;\n  Fts5Index *pIdx = pCtx->pStorage->pIndex;\n  UNUSED_PARAM2(iUnused1, iUnused2);\n  if( nToken>FTS5_MAX_TOKEN_SIZE ) nToken = FTS5_MAX_TOKEN_SIZE;\n  if( (tflags & FTS5_TOKEN_COLOCATED)==0 || pCtx->szCol==0 ){\n    pCtx->szCol++;\n  }\n  return sqlite3Fts5IndexWrite(pIdx, pCtx->iCol, pCtx->szCol-1, pToken, nToken);\n}\n\n/*\n** If a row with rowid iDel is present in the %_content table, add the\n** delete-markers to the FTS index necessary to delete it. Do not actually\n** remove the %_content row at this time though.\n*/\nstatic int fts5StorageDeleteFromIndex(\n  Fts5Storage *p, \n  i64 iDel, \n  sqlite3_value **apVal\n){\n  Fts5Config *pConfig = p->pConfig;\n  sqlite3_stmt *pSeek = 0;        /* SELECT to read row iDel from %_data */\n  int rc;                         /* Return code */\n  int rc2;                        /* sqlite3_reset() return code */\n  int iCol;\n  Fts5InsertCtx ctx;\n\n  if( apVal==0 ){\n    rc = fts5StorageGetStmt(p, FTS5_STMT_LOOKUP, &pSeek, 0);\n    if( rc!=SQLITE_OK ) return rc;\n    sqlite3_bind_int64(pSeek, 1, iDel);\n    if( sqlite3_step(pSeek)!=SQLITE_ROW ){\n      return sqlite3_reset(pSeek);\n    }\n  }\n\n  ctx.pStorage = p;\n  ctx.iCol = -1;\n  rc = sqlite3Fts5IndexBeginWrite(p->pIndex, 1, iDel);\n  for(iCol=1; rc==SQLITE_OK && iCol<=pConfig->nCol; iCol++){\n    if( pConfig->abUnindexed[iCol-1]==0 ){\n      const char *zText;\n      int nText;\n      if( pSeek ){\n        zText = (const char*)sqlite3_column_text(pSeek, iCol);\n        nText = sqlite3_column_bytes(pSeek, iCol);\n      }else{\n        zText = (const char*)sqlite3_value_text(apVal[iCol-1]);\n        nText = sqlite3_value_bytes(apVal[iCol-1]);\n      }\n      ctx.szCol = 0;\n      rc = sqlite3Fts5Tokenize(pConfig, FTS5_TOKENIZE_DOCUMENT, \n          zText, nText, (void*)&ctx, fts5StorageInsertCallback\n      );\n      p->aTotalSize[iCol-1] -= (i64)ctx.szCol;\n    }\n  }\n  p->nTotalRow--;\n\n  rc2 = sqlite3_reset(pSeek);\n  if( rc==SQLITE_OK ) rc = rc2;\n  return rc;\n}\n\n\n/*\n** Insert a record into the %_docsize table. Specifically, do:\n**\n**   INSERT OR REPLACE INTO %_docsize(id, sz) VALUES(iRowid, pBuf);\n**\n** If there is no %_docsize table (as happens if the columnsize=0 option\n** is specified when the FTS5 table is created), this function is a no-op.\n*/\nstatic int fts5StorageInsertDocsize(\n  Fts5Storage *p,                 /* Storage module to write to */\n  i64 iRowid,                     /* id value */\n  Fts5Buffer *pBuf                /* sz value */\n){\n  int rc = SQLITE_OK;\n  if( p->pConfig->bColumnsize ){\n    sqlite3_stmt *pReplace = 0;\n    rc = fts5StorageGetStmt(p, FTS5_STMT_REPLACE_DOCSIZE, &pReplace, 0);\n    if( rc==SQLITE_OK ){\n      sqlite3_bind_int64(pReplace, 1, iRowid);\n      sqlite3_bind_blob(pReplace, 2, pBuf->p, pBuf->n, SQLITE_STATIC);\n      sqlite3_step(pReplace);\n      rc = sqlite3_reset(pReplace);\n      sqlite3_bind_null(pReplace, 2);\n    }\n  }\n  return rc;\n}\n\n/*\n** Load the contents of the \"averages\" record from disk into the \n** p->nTotalRow and p->aTotalSize[] variables. If successful, and if\n** argument bCache is true, set the p->bTotalsValid flag to indicate\n** that the contents of aTotalSize[] and nTotalRow are valid until\n** further notice.\n**\n** Return SQLITE_OK if successful, or an SQLite error code if an error\n** occurs.\n*/\nstatic int fts5StorageLoadTotals(Fts5Storage *p, int bCache){\n  int rc = SQLITE_OK;\n  if( p->bTotalsValid==0 ){\n    rc = sqlite3Fts5IndexGetAverages(p->pIndex, &p->nTotalRow, p->aTotalSize);\n    p->bTotalsValid = bCache;\n  }\n  return rc;\n}\n\n/*\n** Store the current contents of the p->nTotalRow and p->aTotalSize[] \n** variables in the \"averages\" record on disk.\n**\n** Return SQLITE_OK if successful, or an SQLite error code if an error\n** occurs.\n*/\nstatic int fts5StorageSaveTotals(Fts5Storage *p){\n  int nCol = p->pConfig->nCol;\n  int i;\n  Fts5Buffer buf;\n  int rc = SQLITE_OK;\n  memset(&buf, 0, sizeof(buf));\n\n  sqlite3Fts5BufferAppendVarint(&rc, &buf, p->nTotalRow);\n  for(i=0; i<nCol; i++){\n    sqlite3Fts5BufferAppendVarint(&rc, &buf, p->aTotalSize[i]);\n  }\n  if( rc==SQLITE_OK ){\n    rc = sqlite3Fts5IndexSetAverages(p->pIndex, buf.p, buf.n);\n  }\n  sqlite3_free(buf.p);\n\n  return rc;\n}\n\n/*\n** Remove a row from the FTS table.\n*/\nstatic int sqlite3Fts5StorageDelete(Fts5Storage *p, i64 iDel, sqlite3_value **apVal){\n  Fts5Config *pConfig = p->pConfig;\n  int rc;\n  sqlite3_stmt *pDel = 0;\n\n  assert( pConfig->eContent!=FTS5_CONTENT_NORMAL || apVal==0 );\n  rc = fts5StorageLoadTotals(p, 1);\n\n  /* Delete the index records */\n  if( rc==SQLITE_OK ){\n    rc = fts5StorageDeleteFromIndex(p, iDel, apVal);\n  }\n\n  /* Delete the %_docsize record */\n  if( rc==SQLITE_OK && pConfig->bColumnsize ){\n    rc = fts5StorageGetStmt(p, FTS5_STMT_DELETE_DOCSIZE, &pDel, 0);\n    if( rc==SQLITE_OK ){\n      sqlite3_bind_int64(pDel, 1, iDel);\n      sqlite3_step(pDel);\n      rc = sqlite3_reset(pDel);\n    }\n  }\n\n  /* Delete the %_content record */\n  if( pConfig->eContent==FTS5_CONTENT_NORMAL ){\n    if( rc==SQLITE_OK ){\n      rc = fts5StorageGetStmt(p, FTS5_STMT_DELETE_CONTENT, &pDel, 0);\n    }\n    if( rc==SQLITE_OK ){\n      sqlite3_bind_int64(pDel, 1, iDel);\n      sqlite3_step(pDel);\n      rc = sqlite3_reset(pDel);\n    }\n  }\n\n  return rc;\n}\n\n/*\n** Delete all entries in the FTS5 index.\n*/\nstatic int sqlite3Fts5StorageDeleteAll(Fts5Storage *p){\n  Fts5Config *pConfig = p->pConfig;\n  int rc;\n\n  /* Delete the contents of the %_data and %_docsize tables. */\n  rc = fts5ExecPrintf(pConfig->db, 0,\n      \"DELETE FROM %Q.'%q_data';\" \n      \"DELETE FROM %Q.'%q_idx';\",\n      pConfig->zDb, pConfig->zName,\n      pConfig->zDb, pConfig->zName\n  );\n  if( rc==SQLITE_OK && pConfig->bColumnsize ){\n    rc = fts5ExecPrintf(pConfig->db, 0,\n        \"DELETE FROM %Q.'%q_docsize';\",\n        pConfig->zDb, pConfig->zName\n    );\n  }\n\n  /* Reinitialize the %_data table. This call creates the initial structure\n  ** and averages records.  */\n  if( rc==SQLITE_OK ){\n    rc = sqlite3Fts5IndexReinit(p->pIndex);\n  }\n  if( rc==SQLITE_OK ){\n    rc = sqlite3Fts5StorageConfigValue(p, \"version\", 0, FTS5_CURRENT_VERSION);\n  }\n  return rc;\n}\n\nstatic int sqlite3Fts5StorageRebuild(Fts5Storage *p){\n  Fts5Buffer buf = {0,0,0};\n  Fts5Config *pConfig = p->pConfig;\n  sqlite3_stmt *pScan = 0;\n  Fts5InsertCtx ctx;\n  int rc, rc2;\n\n  memset(&ctx, 0, sizeof(Fts5InsertCtx));\n  ctx.pStorage = p;\n  rc = sqlite3Fts5StorageDeleteAll(p);\n  if( rc==SQLITE_OK ){\n    rc = fts5StorageLoadTotals(p, 1);\n  }\n\n  if( rc==SQLITE_OK ){\n    rc = fts5StorageGetStmt(p, FTS5_STMT_SCAN, &pScan, 0);\n  }\n\n  while( rc==SQLITE_OK && SQLITE_ROW==sqlite3_step(pScan) ){\n    i64 iRowid = sqlite3_column_int64(pScan, 0);\n\n    sqlite3Fts5BufferZero(&buf);\n    rc = sqlite3Fts5IndexBeginWrite(p->pIndex, 0, iRowid);\n    for(ctx.iCol=0; rc==SQLITE_OK && ctx.iCol<pConfig->nCol; ctx.iCol++){\n      ctx.szCol = 0;\n      if( pConfig->abUnindexed[ctx.iCol]==0 ){\n        rc = sqlite3Fts5Tokenize(pConfig, \n            FTS5_TOKENIZE_DOCUMENT,\n            (const char*)sqlite3_column_text(pScan, ctx.iCol+1),\n            sqlite3_column_bytes(pScan, ctx.iCol+1),\n            (void*)&ctx,\n            fts5StorageInsertCallback\n        );\n      }\n      sqlite3Fts5BufferAppendVarint(&rc, &buf, ctx.szCol);\n      p->aTotalSize[ctx.iCol] += (i64)ctx.szCol;\n    }\n    p->nTotalRow++;\n\n    if( rc==SQLITE_OK ){\n      rc = fts5StorageInsertDocsize(p, iRowid, &buf);\n    }\n  }\n  sqlite3_free(buf.p);\n  rc2 = sqlite3_reset(pScan);\n  if( rc==SQLITE_OK ) rc = rc2;\n\n  /* Write the averages record */\n  if( rc==SQLITE_OK ){\n    rc = fts5StorageSaveTotals(p);\n  }\n  return rc;\n}\n\nstatic int sqlite3Fts5StorageOptimize(Fts5Storage *p){\n  return sqlite3Fts5IndexOptimize(p->pIndex);\n}\n\nstatic int sqlite3Fts5StorageMerge(Fts5Storage *p, int nMerge){\n  return sqlite3Fts5IndexMerge(p->pIndex, nMerge);\n}\n\nstatic int sqlite3Fts5StorageReset(Fts5Storage *p){\n  return sqlite3Fts5IndexReset(p->pIndex);\n}\n\n/*\n** Allocate a new rowid. This is used for \"external content\" tables when\n** a NULL value is inserted into the rowid column. The new rowid is allocated\n** by inserting a dummy row into the %_docsize table. The dummy will be\n** overwritten later.\n**\n** If the %_docsize table does not exist, SQLITE_MISMATCH is returned. In\n** this case the user is required to provide a rowid explicitly.\n*/\nstatic int fts5StorageNewRowid(Fts5Storage *p, i64 *piRowid){\n  int rc = SQLITE_MISMATCH;\n  if( p->pConfig->bColumnsize ){\n    sqlite3_stmt *pReplace = 0;\n    rc = fts5StorageGetStmt(p, FTS5_STMT_REPLACE_DOCSIZE, &pReplace, 0);\n    if( rc==SQLITE_OK ){\n      sqlite3_bind_null(pReplace, 1);\n      sqlite3_bind_null(pReplace, 2);\n      sqlite3_step(pReplace);\n      rc = sqlite3_reset(pReplace);\n    }\n    if( rc==SQLITE_OK ){\n      *piRowid = sqlite3_last_insert_rowid(p->pConfig->db);\n    }\n  }\n  return rc;\n}\n\n/*\n** Insert a new row into the FTS content table.\n*/\nstatic int sqlite3Fts5StorageContentInsert(\n  Fts5Storage *p, \n  sqlite3_value **apVal, \n  i64 *piRowid\n){\n  Fts5Config *pConfig = p->pConfig;\n  int rc = SQLITE_OK;\n\n  /* Insert the new row into the %_content table. */\n  if( pConfig->eContent!=FTS5_CONTENT_NORMAL ){\n    if( sqlite3_value_type(apVal[1])==SQLITE_INTEGER ){\n      *piRowid = sqlite3_value_int64(apVal[1]);\n    }else{\n      rc = fts5StorageNewRowid(p, piRowid);\n    }\n  }else{\n    sqlite3_stmt *pInsert = 0;    /* Statement to write %_content table */\n    int i;                        /* Counter variable */\n    rc = fts5StorageGetStmt(p, FTS5_STMT_INSERT_CONTENT, &pInsert, 0);\n    for(i=1; rc==SQLITE_OK && i<=pConfig->nCol+1; i++){\n      rc = sqlite3_bind_value(pInsert, i, apVal[i]);\n    }\n    if( rc==SQLITE_OK ){\n      sqlite3_step(pInsert);\n      rc = sqlite3_reset(pInsert);\n    }\n    *piRowid = sqlite3_last_insert_rowid(pConfig->db);\n  }\n\n  return rc;\n}\n\n/*\n** Insert new entries into the FTS index and %_docsize table.\n*/\nstatic int sqlite3Fts5StorageIndexInsert(\n  Fts5Storage *p, \n  sqlite3_value **apVal, \n  i64 iRowid\n){\n  Fts5Config *pConfig = p->pConfig;\n  int rc = SQLITE_OK;             /* Return code */\n  Fts5InsertCtx ctx;              /* Tokenization callback context object */\n  Fts5Buffer buf;                 /* Buffer used to build up %_docsize blob */\n\n  memset(&buf, 0, sizeof(Fts5Buffer));\n  ctx.pStorage = p;\n  rc = fts5StorageLoadTotals(p, 1);\n\n  if( rc==SQLITE_OK ){\n    rc = sqlite3Fts5IndexBeginWrite(p->pIndex, 0, iRowid);\n  }\n  for(ctx.iCol=0; rc==SQLITE_OK && ctx.iCol<pConfig->nCol; ctx.iCol++){\n    ctx.szCol = 0;\n    if( pConfig->abUnindexed[ctx.iCol]==0 ){\n      rc = sqlite3Fts5Tokenize(pConfig, \n          FTS5_TOKENIZE_DOCUMENT,\n          (const char*)sqlite3_value_text(apVal[ctx.iCol+2]),\n          sqlite3_value_bytes(apVal[ctx.iCol+2]),\n          (void*)&ctx,\n          fts5StorageInsertCallback\n      );\n    }\n    sqlite3Fts5BufferAppendVarint(&rc, &buf, ctx.szCol);\n    p->aTotalSize[ctx.iCol] += (i64)ctx.szCol;\n  }\n  p->nTotalRow++;\n\n  /* Write the %_docsize record */\n  if( rc==SQLITE_OK ){\n    rc = fts5StorageInsertDocsize(p, iRowid, &buf);\n  }\n  sqlite3_free(buf.p);\n\n  return rc;\n}\n\nstatic int fts5StorageCount(Fts5Storage *p, const char *zSuffix, i64 *pnRow){\n  Fts5Config *pConfig = p->pConfig;\n  char *zSql;\n  int rc;\n\n  zSql = sqlite3_mprintf(\"SELECT count(*) FROM %Q.'%q_%s'\", \n      pConfig->zDb, pConfig->zName, zSuffix\n  );\n  if( zSql==0 ){\n    rc = SQLITE_NOMEM;\n  }else{\n    sqlite3_stmt *pCnt = 0;\n    rc = sqlite3_prepare_v2(pConfig->db, zSql, -1, &pCnt, 0);\n    if( rc==SQLITE_OK ){\n      if( SQLITE_ROW==sqlite3_step(pCnt) ){\n        *pnRow = sqlite3_column_int64(pCnt, 0);\n      }\n      rc = sqlite3_finalize(pCnt);\n    }\n  }\n\n  sqlite3_free(zSql);\n  return rc;\n}\n\n/*\n** Context object used by sqlite3Fts5StorageIntegrity().\n*/\ntypedef struct Fts5IntegrityCtx Fts5IntegrityCtx;\nstruct Fts5IntegrityCtx {\n  i64 iRowid;\n  int iCol;\n  int szCol;\n  u64 cksum;\n  Fts5Termset *pTermset;\n  Fts5Config *pConfig;\n};\n\n\n/*\n** Tokenization callback used by integrity check.\n*/\nstatic int fts5StorageIntegrityCallback(\n  void *pContext,                 /* Pointer to Fts5IntegrityCtx object */\n  int tflags,\n  const char *pToken,             /* Buffer containing token */\n  int nToken,                     /* Size of token in bytes */\n  int iUnused1,                   /* Start offset of token */\n  int iUnused2                    /* End offset of token */\n){\n  Fts5IntegrityCtx *pCtx = (Fts5IntegrityCtx*)pContext;\n  Fts5Termset *pTermset = pCtx->pTermset;\n  int bPresent;\n  int ii;\n  int rc = SQLITE_OK;\n  int iPos;\n  int iCol;\n\n  UNUSED_PARAM2(iUnused1, iUnused2);\n  if( nToken>FTS5_MAX_TOKEN_SIZE ) nToken = FTS5_MAX_TOKEN_SIZE;\n\n  if( (tflags & FTS5_TOKEN_COLOCATED)==0 || pCtx->szCol==0 ){\n    pCtx->szCol++;\n  }\n\n  switch( pCtx->pConfig->eDetail ){\n    case FTS5_DETAIL_FULL:\n      iPos = pCtx->szCol-1;\n      iCol = pCtx->iCol;\n      break;\n\n    case FTS5_DETAIL_COLUMNS:\n      iPos = pCtx->iCol;\n      iCol = 0;\n      break;\n\n    default:\n      assert( pCtx->pConfig->eDetail==FTS5_DETAIL_NONE );\n      iPos = 0;\n      iCol = 0;\n      break;\n  }\n\n  rc = sqlite3Fts5TermsetAdd(pTermset, 0, pToken, nToken, &bPresent);\n  if( rc==SQLITE_OK && bPresent==0 ){\n    pCtx->cksum ^= sqlite3Fts5IndexEntryCksum(\n        pCtx->iRowid, iCol, iPos, 0, pToken, nToken\n    );\n  }\n\n  for(ii=0; rc==SQLITE_OK && ii<pCtx->pConfig->nPrefix; ii++){\n    const int nChar = pCtx->pConfig->aPrefix[ii];\n    int nByte = sqlite3Fts5IndexCharlenToBytelen(pToken, nToken, nChar);\n    if( nByte ){\n      rc = sqlite3Fts5TermsetAdd(pTermset, ii+1, pToken, nByte, &bPresent);\n      if( bPresent==0 ){\n        pCtx->cksum ^= sqlite3Fts5IndexEntryCksum(\n            pCtx->iRowid, iCol, iPos, ii+1, pToken, nByte\n        );\n      }\n    }\n  }\n\n  return rc;\n}\n\n/*\n** Check that the contents of the FTS index match that of the %_content\n** table. Return SQLITE_OK if they do, or SQLITE_CORRUPT if not. Return\n** some other SQLite error code if an error occurs while attempting to\n** determine this.\n*/\nstatic int sqlite3Fts5StorageIntegrity(Fts5Storage *p){\n  Fts5Config *pConfig = p->pConfig;\n  int rc;                         /* Return code */\n  int *aColSize;                  /* Array of size pConfig->nCol */\n  i64 *aTotalSize;                /* Array of size pConfig->nCol */\n  Fts5IntegrityCtx ctx;\n  sqlite3_stmt *pScan;\n\n  memset(&ctx, 0, sizeof(Fts5IntegrityCtx));\n  ctx.pConfig = p->pConfig;\n  aTotalSize = (i64*)sqlite3_malloc64(pConfig->nCol*(sizeof(int)+sizeof(i64)));\n  if( !aTotalSize ) return SQLITE_NOMEM;\n  aColSize = (int*)&aTotalSize[pConfig->nCol];\n  memset(aTotalSize, 0, sizeof(i64) * pConfig->nCol);\n\n  /* Generate the expected index checksum based on the contents of the\n  ** %_content table. This block stores the checksum in ctx.cksum. */\n  rc = fts5StorageGetStmt(p, FTS5_STMT_SCAN, &pScan, 0);\n  if( rc==SQLITE_OK ){\n    int rc2;\n    while( SQLITE_ROW==sqlite3_step(pScan) ){\n      int i;\n      ctx.iRowid = sqlite3_column_int64(pScan, 0);\n      ctx.szCol = 0;\n      if( pConfig->bColumnsize ){\n        rc = sqlite3Fts5StorageDocsize(p, ctx.iRowid, aColSize);\n      }\n      if( rc==SQLITE_OK && pConfig->eDetail==FTS5_DETAIL_NONE ){\n        rc = sqlite3Fts5TermsetNew(&ctx.pTermset);\n      }\n      for(i=0; rc==SQLITE_OK && i<pConfig->nCol; i++){\n        if( pConfig->abUnindexed[i] ) continue;\n        ctx.iCol = i;\n        ctx.szCol = 0;\n        if( pConfig->eDetail==FTS5_DETAIL_COLUMNS ){\n          rc = sqlite3Fts5TermsetNew(&ctx.pTermset);\n        }\n        if( rc==SQLITE_OK ){\n          rc = sqlite3Fts5Tokenize(pConfig, \n              FTS5_TOKENIZE_DOCUMENT,\n              (const char*)sqlite3_column_text(pScan, i+1),\n              sqlite3_column_bytes(pScan, i+1),\n              (void*)&ctx,\n              fts5StorageIntegrityCallback\n          );\n        }\n        if( rc==SQLITE_OK && pConfig->bColumnsize && ctx.szCol!=aColSize[i] ){\n          rc = FTS5_CORRUPT;\n        }\n        aTotalSize[i] += ctx.szCol;\n        if( pConfig->eDetail==FTS5_DETAIL_COLUMNS ){\n          sqlite3Fts5TermsetFree(ctx.pTermset);\n          ctx.pTermset = 0;\n        }\n      }\n      sqlite3Fts5TermsetFree(ctx.pTermset);\n      ctx.pTermset = 0;\n\n      if( rc!=SQLITE_OK ) break;\n    }\n    rc2 = sqlite3_reset(pScan);\n    if( rc==SQLITE_OK ) rc = rc2;\n  }\n\n  /* Test that the \"totals\" (sometimes called \"averages\") record looks Ok */\n  if( rc==SQLITE_OK ){\n    int i;\n    rc = fts5StorageLoadTotals(p, 0);\n    for(i=0; rc==SQLITE_OK && i<pConfig->nCol; i++){\n      if( p->aTotalSize[i]!=aTotalSize[i] ) rc = FTS5_CORRUPT;\n    }\n  }\n\n  /* Check that the %_docsize and %_content tables contain the expected\n  ** number of rows.  */\n  if( rc==SQLITE_OK && pConfig->eContent==FTS5_CONTENT_NORMAL ){\n    i64 nRow = 0;\n    rc = fts5StorageCount(p, \"content\", &nRow);\n    if( rc==SQLITE_OK && nRow!=p->nTotalRow ) rc = FTS5_CORRUPT;\n  }\n  if( rc==SQLITE_OK && pConfig->bColumnsize ){\n    i64 nRow = 0;\n    rc = fts5StorageCount(p, \"docsize\", &nRow);\n    if( rc==SQLITE_OK && nRow!=p->nTotalRow ) rc = FTS5_CORRUPT;\n  }\n\n  /* Pass the expected checksum down to the FTS index module. It will\n  ** verify, amongst other things, that it matches the checksum generated by\n  ** inspecting the index itself.  */\n  if( rc==SQLITE_OK ){\n    rc = sqlite3Fts5IndexIntegrityCheck(p->pIndex, ctx.cksum);\n  }\n\n  sqlite3_free(aTotalSize);\n  return rc;\n}\n\n/*\n** Obtain an SQLite statement handle that may be used to read data from the\n** %_content table.\n*/\nstatic int sqlite3Fts5StorageStmt(\n  Fts5Storage *p, \n  int eStmt, \n  sqlite3_stmt **pp, \n  char **pzErrMsg\n){\n  int rc;\n  assert( eStmt==FTS5_STMT_SCAN_ASC \n       || eStmt==FTS5_STMT_SCAN_DESC\n       || eStmt==FTS5_STMT_LOOKUP\n  );\n  rc = fts5StorageGetStmt(p, eStmt, pp, pzErrMsg);\n  if( rc==SQLITE_OK ){\n    assert( p->aStmt[eStmt]==*pp );\n    p->aStmt[eStmt] = 0;\n  }\n  return rc;\n}\n\n/*\n** Release an SQLite statement handle obtained via an earlier call to\n** sqlite3Fts5StorageStmt(). The eStmt parameter passed to this function\n** must match that passed to the sqlite3Fts5StorageStmt() call.\n*/\nstatic void sqlite3Fts5StorageStmtRelease(\n  Fts5Storage *p, \n  int eStmt, \n  sqlite3_stmt *pStmt\n){\n  assert( eStmt==FTS5_STMT_SCAN_ASC\n       || eStmt==FTS5_STMT_SCAN_DESC\n       || eStmt==FTS5_STMT_LOOKUP\n  );\n  if( p->aStmt[eStmt]==0 ){\n    sqlite3_reset(pStmt);\n    p->aStmt[eStmt] = pStmt;\n  }else{\n    sqlite3_finalize(pStmt);\n  }\n}\n\nstatic int fts5StorageDecodeSizeArray(\n  int *aCol, int nCol,            /* Array to populate */\n  const u8 *aBlob, int nBlob      /* Record to read varints from */\n){\n  int i;\n  int iOff = 0;\n  for(i=0; i<nCol; i++){\n    if( iOff>=nBlob ) return 1;\n    iOff += fts5GetVarint32(&aBlob[iOff], aCol[i]);\n  }\n  return (iOff!=nBlob);\n}\n\n/*\n** Argument aCol points to an array of integers containing one entry for\n** each table column. This function reads the %_docsize record for the\n** specified rowid and populates aCol[] with the results.\n**\n** An SQLite error code is returned if an error occurs, or SQLITE_OK\n** otherwise.\n*/\nstatic int sqlite3Fts5StorageDocsize(Fts5Storage *p, i64 iRowid, int *aCol){\n  int nCol = p->pConfig->nCol;    /* Number of user columns in table */\n  sqlite3_stmt *pLookup = 0;      /* Statement to query %_docsize */\n  int rc;                         /* Return Code */\n\n  assert( p->pConfig->bColumnsize );\n  rc = fts5StorageGetStmt(p, FTS5_STMT_LOOKUP_DOCSIZE, &pLookup, 0);\n  if( rc==SQLITE_OK ){\n    int bCorrupt = 1;\n    sqlite3_bind_int64(pLookup, 1, iRowid);\n    if( SQLITE_ROW==sqlite3_step(pLookup) ){\n      const u8 *aBlob = sqlite3_column_blob(pLookup, 0);\n      int nBlob = sqlite3_column_bytes(pLookup, 0);\n      if( 0==fts5StorageDecodeSizeArray(aCol, nCol, aBlob, nBlob) ){\n        bCorrupt = 0;\n      }\n    }\n    rc = sqlite3_reset(pLookup);\n    if( bCorrupt && rc==SQLITE_OK ){\n      rc = FTS5_CORRUPT;\n    }\n  }\n\n  return rc;\n}\n\nstatic int sqlite3Fts5StorageSize(Fts5Storage *p, int iCol, i64 *pnToken){\n  int rc = fts5StorageLoadTotals(p, 0);\n  if( rc==SQLITE_OK ){\n    *pnToken = 0;\n    if( iCol<0 ){\n      int i;\n      for(i=0; i<p->pConfig->nCol; i++){\n        *pnToken += p->aTotalSize[i];\n      }\n    }else if( iCol<p->pConfig->nCol ){\n      *pnToken = p->aTotalSize[iCol];\n    }else{\n      rc = SQLITE_RANGE;\n    }\n  }\n  return rc;\n}\n\nstatic int sqlite3Fts5StorageRowCount(Fts5Storage *p, i64 *pnRow){\n  int rc = fts5StorageLoadTotals(p, 0);\n  if( rc==SQLITE_OK ){\n    /* nTotalRow being zero does not necessarily indicate a corrupt \n    ** database - it might be that the FTS5 table really does contain zero\n    ** rows. However this function is only called from the xRowCount() API,\n    ** and there is no way for that API to be invoked if the table contains\n    ** no rows. Hence the FTS5_CORRUPT return.  */\n    *pnRow = p->nTotalRow;\n    if( p->nTotalRow<=0 ) rc = FTS5_CORRUPT;\n  }\n  return rc;\n}\n\n/*\n** Flush any data currently held in-memory to disk.\n*/\nstatic int sqlite3Fts5StorageSync(Fts5Storage *p){\n  int rc = SQLITE_OK;\n  i64 iLastRowid = sqlite3_last_insert_rowid(p->pConfig->db);\n  if( p->bTotalsValid ){\n    rc = fts5StorageSaveTotals(p);\n    p->bTotalsValid = 0;\n  }\n  if( rc==SQLITE_OK ){\n    rc = sqlite3Fts5IndexSync(p->pIndex);\n  }\n  sqlite3_set_last_insert_rowid(p->pConfig->db, iLastRowid);\n  return rc;\n}\n\nstatic int sqlite3Fts5StorageRollback(Fts5Storage *p){\n  p->bTotalsValid = 0;\n  return sqlite3Fts5IndexRollback(p->pIndex);\n}\n\nstatic int sqlite3Fts5StorageConfigValue(\n  Fts5Storage *p, \n  const char *z,\n  sqlite3_value *pVal,\n  int iVal\n){\n  sqlite3_stmt *pReplace = 0;\n  int rc = fts5StorageGetStmt(p, FTS5_STMT_REPLACE_CONFIG, &pReplace, 0);\n  if( rc==SQLITE_OK ){\n    sqlite3_bind_text(pReplace, 1, z, -1, SQLITE_STATIC);\n    if( pVal ){\n      sqlite3_bind_value(pReplace, 2, pVal);\n    }else{\n      sqlite3_bind_int(pReplace, 2, iVal);\n    }\n    sqlite3_step(pReplace);\n    rc = sqlite3_reset(pReplace);\n    sqlite3_bind_null(pReplace, 1);\n  }\n  if( rc==SQLITE_OK && pVal ){\n    int iNew = p->pConfig->iCookie + 1;\n    rc = sqlite3Fts5IndexSetCookie(p->pIndex, iNew);\n    if( rc==SQLITE_OK ){\n      p->pConfig->iCookie = iNew;\n    }\n  }\n  return rc;\n}\n\n/*\n** 2014 May 31\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n******************************************************************************\n*/\n\n\n/* #include \"fts5Int.h\" */\n\n/**************************************************************************\n** Start of ascii tokenizer implementation.\n*/\n\n/*\n** For tokenizers with no \"unicode\" modifier, the set of token characters\n** is the same as the set of ASCII range alphanumeric characters. \n*/\nstatic unsigned char aAsciiTokenChar[128] = {\n  0, 0, 0, 0, 0, 0, 0, 0,   0, 0, 0, 0, 0, 0, 0, 0,   /* 0x00..0x0F */\n  0, 0, 0, 0, 0, 0, 0, 0,   0, 0, 0, 0, 0, 0, 0, 0,   /* 0x10..0x1F */\n  0, 0, 0, 0, 0, 0, 0, 0,   0, 0, 0, 0, 0, 0, 0, 0,   /* 0x20..0x2F */\n  1, 1, 1, 1, 1, 1, 1, 1,   1, 1, 0, 0, 0, 0, 0, 0,   /* 0x30..0x3F */\n  0, 1, 1, 1, 1, 1, 1, 1,   1, 1, 1, 1, 1, 1, 1, 1,   /* 0x40..0x4F */\n  1, 1, 1, 1, 1, 1, 1, 1,   1, 1, 1, 0, 0, 0, 0, 0,   /* 0x50..0x5F */\n  0, 1, 1, 1, 1, 1, 1, 1,   1, 1, 1, 1, 1, 1, 1, 1,   /* 0x60..0x6F */\n  1, 1, 1, 1, 1, 1, 1, 1,   1, 1, 1, 0, 0, 0, 0, 0,   /* 0x70..0x7F */\n};\n\ntypedef struct AsciiTokenizer AsciiTokenizer;\nstruct AsciiTokenizer {\n  unsigned char aTokenChar[128];\n};\n\nstatic void fts5AsciiAddExceptions(\n  AsciiTokenizer *p, \n  const char *zArg, \n  int bTokenChars\n){\n  int i;\n  for(i=0; zArg[i]; i++){\n    if( (zArg[i] & 0x80)==0 ){\n      p->aTokenChar[(int)zArg[i]] = (unsigned char)bTokenChars;\n    }\n  }\n}\n\n/*\n** Delete a \"ascii\" tokenizer.\n*/\nstatic void fts5AsciiDelete(Fts5Tokenizer *p){\n  sqlite3_free(p);\n}\n\n/*\n** Create an \"ascii\" tokenizer.\n*/\nstatic int fts5AsciiCreate(\n  void *pUnused, \n  const char **azArg, int nArg,\n  Fts5Tokenizer **ppOut\n){\n  int rc = SQLITE_OK;\n  AsciiTokenizer *p = 0;\n  UNUSED_PARAM(pUnused);\n  if( nArg%2 ){\n    rc = SQLITE_ERROR;\n  }else{\n    p = sqlite3_malloc(sizeof(AsciiTokenizer));\n    if( p==0 ){\n      rc = SQLITE_NOMEM;\n    }else{\n      int i;\n      memset(p, 0, sizeof(AsciiTokenizer));\n      memcpy(p->aTokenChar, aAsciiTokenChar, sizeof(aAsciiTokenChar));\n      for(i=0; rc==SQLITE_OK && i<nArg; i+=2){\n        const char *zArg = azArg[i+1];\n        if( 0==sqlite3_stricmp(azArg[i], \"tokenchars\") ){\n          fts5AsciiAddExceptions(p, zArg, 1);\n        }else\n        if( 0==sqlite3_stricmp(azArg[i], \"separators\") ){\n          fts5AsciiAddExceptions(p, zArg, 0);\n        }else{\n          rc = SQLITE_ERROR;\n        }\n      }\n      if( rc!=SQLITE_OK ){\n        fts5AsciiDelete((Fts5Tokenizer*)p);\n        p = 0;\n      }\n    }\n  }\n\n  *ppOut = (Fts5Tokenizer*)p;\n  return rc;\n}\n\n\nstatic void asciiFold(char *aOut, const char *aIn, int nByte){\n  int i;\n  for(i=0; i<nByte; i++){\n    char c = aIn[i];\n    if( c>='A' && c<='Z' ) c += 32;\n    aOut[i] = c;\n  }\n}\n\n/*\n** Tokenize some text using the ascii tokenizer.\n*/\nstatic int fts5AsciiTokenize(\n  Fts5Tokenizer *pTokenizer,\n  void *pCtx,\n  int iUnused,\n  const char *pText, int nText,\n  int (*xToken)(void*, int, const char*, int nToken, int iStart, int iEnd)\n){\n  AsciiTokenizer *p = (AsciiTokenizer*)pTokenizer;\n  int rc = SQLITE_OK;\n  int ie;\n  int is = 0;\n\n  char aFold[64];\n  int nFold = sizeof(aFold);\n  char *pFold = aFold;\n  unsigned char *a = p->aTokenChar;\n\n  UNUSED_PARAM(iUnused);\n\n  while( is<nText && rc==SQLITE_OK ){\n    int nByte;\n\n    /* Skip any leading divider characters. */\n    while( is<nText && ((pText[is]&0x80)==0 && a[(int)pText[is]]==0) ){\n      is++;\n    }\n    if( is==nText ) break;\n\n    /* Count the token characters */\n    ie = is+1;\n    while( ie<nText && ((pText[ie]&0x80) || a[(int)pText[ie]] ) ){\n      ie++;\n    }\n\n    /* Fold to lower case */\n    nByte = ie-is;\n    if( nByte>nFold ){\n      if( pFold!=aFold ) sqlite3_free(pFold);\n      pFold = sqlite3_malloc64((sqlite3_int64)nByte*2);\n      if( pFold==0 ){\n        rc = SQLITE_NOMEM;\n        break;\n      }\n      nFold = nByte*2;\n    }\n    asciiFold(pFold, &pText[is], nByte);\n\n    /* Invoke the token callback */\n    rc = xToken(pCtx, 0, pFold, nByte, is, ie);\n    is = ie+1;\n  }\n  \n  if( pFold!=aFold ) sqlite3_free(pFold);\n  if( rc==SQLITE_DONE ) rc = SQLITE_OK;\n  return rc;\n}\n\n/**************************************************************************\n** Start of unicode61 tokenizer implementation.\n*/\n\n\n/*\n** The following two macros - READ_UTF8 and WRITE_UTF8 - have been copied\n** from the sqlite3 source file utf.c. If this file is compiled as part\n** of the amalgamation, they are not required.\n*/\n#ifndef SQLITE_AMALGAMATION\n\nstatic const unsigned char sqlite3Utf8Trans1[] = {\n  0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,\n  0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,\n  0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,\n  0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,\n  0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,\n  0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,\n  0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,\n  0x00, 0x01, 0x02, 0x03, 0x00, 0x01, 0x00, 0x00,\n};\n\n#define READ_UTF8(zIn, zTerm, c)                           \\\n  c = *(zIn++);                                            \\\n  if( c>=0xc0 ){                                           \\\n    c = sqlite3Utf8Trans1[c-0xc0];                         \\\n    while( zIn!=zTerm && (*zIn & 0xc0)==0x80 ){            \\\n      c = (c<<6) + (0x3f & *(zIn++));                      \\\n    }                                                      \\\n    if( c<0x80                                             \\\n        || (c&0xFFFFF800)==0xD800                          \\\n        || (c&0xFFFFFFFE)==0xFFFE ){  c = 0xFFFD; }        \\\n  }\n\n\n#define WRITE_UTF8(zOut, c) {                          \\\n  if( c<0x00080 ){                                     \\\n    *zOut++ = (unsigned char)(c&0xFF);                 \\\n  }                                                    \\\n  else if( c<0x00800 ){                                \\\n    *zOut++ = 0xC0 + (unsigned char)((c>>6)&0x1F);     \\\n    *zOut++ = 0x80 + (unsigned char)(c & 0x3F);        \\\n  }                                                    \\\n  else if( c<0x10000 ){                                \\\n    *zOut++ = 0xE0 + (unsigned char)((c>>12)&0x0F);    \\\n    *zOut++ = 0x80 + (unsigned char)((c>>6) & 0x3F);   \\\n    *zOut++ = 0x80 + (unsigned char)(c & 0x3F);        \\\n  }else{                                               \\\n    *zOut++ = 0xF0 + (unsigned char)((c>>18) & 0x07);  \\\n    *zOut++ = 0x80 + (unsigned char)((c>>12) & 0x3F);  \\\n    *zOut++ = 0x80 + (unsigned char)((c>>6) & 0x3F);   \\\n    *zOut++ = 0x80 + (unsigned char)(c & 0x3F);        \\\n  }                                                    \\\n}\n\n#endif /* ifndef SQLITE_AMALGAMATION */\n\ntypedef struct Unicode61Tokenizer Unicode61Tokenizer;\nstruct Unicode61Tokenizer {\n  unsigned char aTokenChar[128];  /* ASCII range token characters */\n  char *aFold;                    /* Buffer to fold text into */\n  int nFold;                      /* Size of aFold[] in bytes */\n  int eRemoveDiacritic;           /* True if remove_diacritics=1 is set */\n  int nException;\n  int *aiException;\n\n  unsigned char aCategory[32];    /* True for token char categories */\n};\n\n/* Values for eRemoveDiacritic (must match internals of fts5_unicode2.c) */\n#define FTS5_REMOVE_DIACRITICS_NONE    0\n#define FTS5_REMOVE_DIACRITICS_SIMPLE  1\n#define FTS5_REMOVE_DIACRITICS_COMPLEX 2\n\nstatic int fts5UnicodeAddExceptions(\n  Unicode61Tokenizer *p,          /* Tokenizer object */\n  const char *z,                  /* Characters to treat as exceptions */\n  int bTokenChars                 /* 1 for 'tokenchars', 0 for 'separators' */\n){\n  int rc = SQLITE_OK;\n  int n = (int)strlen(z);\n  int *aNew;\n\n  if( n>0 ){\n    aNew = (int*)sqlite3_realloc64(p->aiException,\n                                   (n+p->nException)*sizeof(int));\n    if( aNew ){\n      int nNew = p->nException;\n      const unsigned char *zCsr = (const unsigned char*)z;\n      const unsigned char *zTerm = (const unsigned char*)&z[n];\n      while( zCsr<zTerm ){\n        u32 iCode;\n        int bToken;\n        READ_UTF8(zCsr, zTerm, iCode);\n        if( iCode<128 ){\n          p->aTokenChar[iCode] = (unsigned char)bTokenChars;\n        }else{\n          bToken = p->aCategory[sqlite3Fts5UnicodeCategory(iCode)];\n          assert( (bToken==0 || bToken==1) ); \n          assert( (bTokenChars==0 || bTokenChars==1) );\n          if( bToken!=bTokenChars && sqlite3Fts5UnicodeIsdiacritic(iCode)==0 ){\n            int i;\n            for(i=0; i<nNew; i++){\n              if( (u32)aNew[i]>iCode ) break;\n            }\n            memmove(&aNew[i+1], &aNew[i], (nNew-i)*sizeof(int));\n            aNew[i] = iCode;\n            nNew++;\n          }\n        }\n      }\n      p->aiException = aNew;\n      p->nException = nNew;\n    }else{\n      rc = SQLITE_NOMEM;\n    }\n  }\n\n  return rc;\n}\n\n/*\n** Return true if the p->aiException[] array contains the value iCode.\n*/\nstatic int fts5UnicodeIsException(Unicode61Tokenizer *p, int iCode){\n  if( p->nException>0 ){\n    int *a = p->aiException;\n    int iLo = 0;\n    int iHi = p->nException-1;\n\n    while( iHi>=iLo ){\n      int iTest = (iHi + iLo) / 2;\n      if( iCode==a[iTest] ){\n        return 1;\n      }else if( iCode>a[iTest] ){\n        iLo = iTest+1;\n      }else{\n        iHi = iTest-1;\n      }\n    }\n  }\n\n  return 0;\n}\n\n/*\n** Delete a \"unicode61\" tokenizer.\n*/\nstatic void fts5UnicodeDelete(Fts5Tokenizer *pTok){\n  if( pTok ){\n    Unicode61Tokenizer *p = (Unicode61Tokenizer*)pTok;\n    sqlite3_free(p->aiException);\n    sqlite3_free(p->aFold);\n    sqlite3_free(p);\n  }\n  return;\n}\n\nstatic int unicodeSetCategories(Unicode61Tokenizer *p, const char *zCat){\n  const char *z = zCat;\n\n  while( *z ){\n    while( *z==' ' || *z=='\\t' ) z++;\n    if( *z && sqlite3Fts5UnicodeCatParse(z, p->aCategory) ){\n      return SQLITE_ERROR;\n    }\n    while( *z!=' ' && *z!='\\t' && *z!='\\0' ) z++;\n  }\n\n  sqlite3Fts5UnicodeAscii(p->aCategory, p->aTokenChar);\n  return SQLITE_OK;\n}\n\n/*\n** Create a \"unicode61\" tokenizer.\n*/\nstatic int fts5UnicodeCreate(\n  void *pUnused, \n  const char **azArg, int nArg,\n  Fts5Tokenizer **ppOut\n){\n  int rc = SQLITE_OK;             /* Return code */\n  Unicode61Tokenizer *p = 0;      /* New tokenizer object */ \n\n  UNUSED_PARAM(pUnused);\n\n  if( nArg%2 ){\n    rc = SQLITE_ERROR;\n  }else{\n    p = (Unicode61Tokenizer*)sqlite3_malloc(sizeof(Unicode61Tokenizer));\n    if( p ){\n      const char *zCat = \"L* N* Co\";\n      int i;\n      memset(p, 0, sizeof(Unicode61Tokenizer));\n\n      p->eRemoveDiacritic = FTS5_REMOVE_DIACRITICS_SIMPLE;\n      p->nFold = 64;\n      p->aFold = sqlite3_malloc(p->nFold * sizeof(char));\n      if( p->aFold==0 ){\n        rc = SQLITE_NOMEM;\n      }\n\n      /* Search for a \"categories\" argument */\n      for(i=0; rc==SQLITE_OK && i<nArg; i+=2){\n        if( 0==sqlite3_stricmp(azArg[i], \"categories\") ){\n          zCat = azArg[i+1];\n        }\n      }\n\n      if( rc==SQLITE_OK ){\n        rc = unicodeSetCategories(p, zCat);\n      }\n\n      for(i=0; rc==SQLITE_OK && i<nArg; i+=2){\n        const char *zArg = azArg[i+1];\n        if( 0==sqlite3_stricmp(azArg[i], \"remove_diacritics\") ){\n          if( (zArg[0]!='0' && zArg[0]!='1' && zArg[0]!='2') || zArg[1] ){\n            rc = SQLITE_ERROR;\n          }else{\n            p->eRemoveDiacritic = (zArg[0] - '0');\n            assert( p->eRemoveDiacritic==FTS5_REMOVE_DIACRITICS_NONE\n                 || p->eRemoveDiacritic==FTS5_REMOVE_DIACRITICS_SIMPLE\n                 || p->eRemoveDiacritic==FTS5_REMOVE_DIACRITICS_COMPLEX\n            );\n          }\n        }else\n        if( 0==sqlite3_stricmp(azArg[i], \"tokenchars\") ){\n          rc = fts5UnicodeAddExceptions(p, zArg, 1);\n        }else\n        if( 0==sqlite3_stricmp(azArg[i], \"separators\") ){\n          rc = fts5UnicodeAddExceptions(p, zArg, 0);\n        }else\n        if( 0==sqlite3_stricmp(azArg[i], \"categories\") ){\n          /* no-op */\n        }else{\n          rc = SQLITE_ERROR;\n        }\n      }\n\n    }else{\n      rc = SQLITE_NOMEM;\n    }\n    if( rc!=SQLITE_OK ){\n      fts5UnicodeDelete((Fts5Tokenizer*)p);\n      p = 0;\n    }\n    *ppOut = (Fts5Tokenizer*)p;\n  }\n  return rc;\n}\n\n/*\n** Return true if, for the purposes of tokenizing with the tokenizer\n** passed as the first argument, codepoint iCode is considered a token \n** character (not a separator).\n*/\nstatic int fts5UnicodeIsAlnum(Unicode61Tokenizer *p, int iCode){\n  return (\n    p->aCategory[sqlite3Fts5UnicodeCategory((u32)iCode)]\n    ^ fts5UnicodeIsException(p, iCode)\n  );\n}\n\nstatic int fts5UnicodeTokenize(\n  Fts5Tokenizer *pTokenizer,\n  void *pCtx,\n  int iUnused,\n  const char *pText, int nText,\n  int (*xToken)(void*, int, const char*, int nToken, int iStart, int iEnd)\n){\n  Unicode61Tokenizer *p = (Unicode61Tokenizer*)pTokenizer;\n  int rc = SQLITE_OK;\n  unsigned char *a = p->aTokenChar;\n\n  unsigned char *zTerm = (unsigned char*)&pText[nText];\n  unsigned char *zCsr = (unsigned char *)pText;\n\n  /* Output buffer */\n  char *aFold = p->aFold;\n  int nFold = p->nFold;\n  const char *pEnd = &aFold[nFold-6];\n\n  UNUSED_PARAM(iUnused);\n\n  /* Each iteration of this loop gobbles up a contiguous run of separators,\n  ** then the next token.  */\n  while( rc==SQLITE_OK ){\n    u32 iCode;                    /* non-ASCII codepoint read from input */\n    char *zOut = aFold;\n    int is;\n    int ie;\n\n    /* Skip any separator characters. */\n    while( 1 ){\n      if( zCsr>=zTerm ) goto tokenize_done;\n      if( *zCsr & 0x80 ) {\n        /* A character outside of the ascii range. Skip past it if it is\n        ** a separator character. Or break out of the loop if it is not. */\n        is = zCsr - (unsigned char*)pText;\n        READ_UTF8(zCsr, zTerm, iCode);\n        if( fts5UnicodeIsAlnum(p, iCode) ){\n          goto non_ascii_tokenchar;\n        }\n      }else{\n        if( a[*zCsr] ){\n          is = zCsr - (unsigned char*)pText;\n          goto ascii_tokenchar;\n        }\n        zCsr++;\n      }\n    }\n\n    /* Run through the tokenchars. Fold them into the output buffer along\n    ** the way.  */\n    while( zCsr<zTerm ){\n\n      /* Grow the output buffer so that there is sufficient space to fit the\n      ** largest possible utf-8 character.  */\n      if( zOut>pEnd ){\n        aFold = sqlite3_malloc64((sqlite3_int64)nFold*2);\n        if( aFold==0 ){\n          rc = SQLITE_NOMEM;\n          goto tokenize_done;\n        }\n        zOut = &aFold[zOut - p->aFold];\n        memcpy(aFold, p->aFold, nFold);\n        sqlite3_free(p->aFold);\n        p->aFold = aFold;\n        p->nFold = nFold = nFold*2;\n        pEnd = &aFold[nFold-6];\n      }\n\n      if( *zCsr & 0x80 ){\n        /* An non-ascii-range character. Fold it into the output buffer if\n        ** it is a token character, or break out of the loop if it is not. */\n        READ_UTF8(zCsr, zTerm, iCode);\n        if( fts5UnicodeIsAlnum(p,iCode)||sqlite3Fts5UnicodeIsdiacritic(iCode) ){\n non_ascii_tokenchar:\n          iCode = sqlite3Fts5UnicodeFold(iCode, p->eRemoveDiacritic);\n          if( iCode ) WRITE_UTF8(zOut, iCode);\n        }else{\n          break;\n        }\n      }else if( a[*zCsr]==0 ){\n        /* An ascii-range separator character. End of token. */\n        break; \n      }else{\n ascii_tokenchar:\n        if( *zCsr>='A' && *zCsr<='Z' ){\n          *zOut++ = *zCsr + 32;\n        }else{\n          *zOut++ = *zCsr;\n        }\n        zCsr++;\n      }\n      ie = zCsr - (unsigned char*)pText;\n    }\n\n    /* Invoke the token callback */\n    rc = xToken(pCtx, 0, aFold, zOut-aFold, is, ie); \n  }\n  \n tokenize_done:\n  if( rc==SQLITE_DONE ) rc = SQLITE_OK;\n  return rc;\n}\n\n/**************************************************************************\n** Start of porter stemmer implementation.\n*/\n\n/* Any tokens larger than this (in bytes) are passed through without\n** stemming. */\n#define FTS5_PORTER_MAX_TOKEN 64\n\ntypedef struct PorterTokenizer PorterTokenizer;\nstruct PorterTokenizer {\n  fts5_tokenizer tokenizer;       /* Parent tokenizer module */\n  Fts5Tokenizer *pTokenizer;      /* Parent tokenizer instance */\n  char aBuf[FTS5_PORTER_MAX_TOKEN + 64];\n};\n\n/*\n** Delete a \"porter\" tokenizer.\n*/\nstatic void fts5PorterDelete(Fts5Tokenizer *pTok){\n  if( pTok ){\n    PorterTokenizer *p = (PorterTokenizer*)pTok;\n    if( p->pTokenizer ){\n      p->tokenizer.xDelete(p->pTokenizer);\n    }\n    sqlite3_free(p);\n  }\n}\n\n/*\n** Create a \"porter\" tokenizer.\n*/\nstatic int fts5PorterCreate(\n  void *pCtx, \n  const char **azArg, int nArg,\n  Fts5Tokenizer **ppOut\n){\n  fts5_api *pApi = (fts5_api*)pCtx;\n  int rc = SQLITE_OK;\n  PorterTokenizer *pRet;\n  void *pUserdata = 0;\n  const char *zBase = \"unicode61\";\n\n  if( nArg>0 ){\n    zBase = azArg[0];\n  }\n\n  pRet = (PorterTokenizer*)sqlite3_malloc(sizeof(PorterTokenizer));\n  if( pRet ){\n    memset(pRet, 0, sizeof(PorterTokenizer));\n    rc = pApi->xFindTokenizer(pApi, zBase, &pUserdata, &pRet->tokenizer);\n  }else{\n    rc = SQLITE_NOMEM;\n  }\n  if( rc==SQLITE_OK ){\n    int nArg2 = (nArg>0 ? nArg-1 : 0);\n    const char **azArg2 = (nArg2 ? &azArg[1] : 0);\n    rc = pRet->tokenizer.xCreate(pUserdata, azArg2, nArg2, &pRet->pTokenizer);\n  }\n\n  if( rc!=SQLITE_OK ){\n    fts5PorterDelete((Fts5Tokenizer*)pRet);\n    pRet = 0;\n  }\n  *ppOut = (Fts5Tokenizer*)pRet;\n  return rc;\n}\n\ntypedef struct PorterContext PorterContext;\nstruct PorterContext {\n  void *pCtx;\n  int (*xToken)(void*, int, const char*, int, int, int);\n  char *aBuf;\n};\n\ntypedef struct PorterRule PorterRule;\nstruct PorterRule {\n  const char *zSuffix;\n  int nSuffix;\n  int (*xCond)(char *zStem, int nStem);\n  const char *zOutput;\n  int nOutput;\n};\n\n#if 0\nstatic int fts5PorterApply(char *aBuf, int *pnBuf, PorterRule *aRule){\n  int ret = -1;\n  int nBuf = *pnBuf;\n  PorterRule *p;\n\n  for(p=aRule; p->zSuffix; p++){\n    assert( strlen(p->zSuffix)==p->nSuffix );\n    assert( strlen(p->zOutput)==p->nOutput );\n    if( nBuf<p->nSuffix ) continue;\n    if( 0==memcmp(&aBuf[nBuf - p->nSuffix], p->zSuffix, p->nSuffix) ) break;\n  }\n\n  if( p->zSuffix ){\n    int nStem = nBuf - p->nSuffix;\n    if( p->xCond==0 || p->xCond(aBuf, nStem) ){\n      memcpy(&aBuf[nStem], p->zOutput, p->nOutput);\n      *pnBuf = nStem + p->nOutput;\n      ret = p - aRule;\n    }\n  }\n\n  return ret;\n}\n#endif\n\nstatic int fts5PorterIsVowel(char c, int bYIsVowel){\n  return (\n      c=='a' || c=='e' || c=='i' || c=='o' || c=='u' || (bYIsVowel && c=='y')\n  );\n}\n\nstatic int fts5PorterGobbleVC(char *zStem, int nStem, int bPrevCons){\n  int i;\n  int bCons = bPrevCons;\n\n  /* Scan for a vowel */\n  for(i=0; i<nStem; i++){\n    if( 0==(bCons = !fts5PorterIsVowel(zStem[i], bCons)) ) break;\n  }\n\n  /* Scan for a consonent */\n  for(i++; i<nStem; i++){\n    if( (bCons = !fts5PorterIsVowel(zStem[i], bCons)) ) return i+1;\n  }\n  return 0;\n}\n\n/* porter rule condition: (m > 0) */\nstatic int fts5Porter_MGt0(char *zStem, int nStem){\n  return !!fts5PorterGobbleVC(zStem, nStem, 0);\n}\n\n/* porter rule condition: (m > 1) */\nstatic int fts5Porter_MGt1(char *zStem, int nStem){\n  int n;\n  n = fts5PorterGobbleVC(zStem, nStem, 0);\n  if( n && fts5PorterGobbleVC(&zStem[n], nStem-n, 1) ){\n    return 1;\n  }\n  return 0;\n}\n\n/* porter rule condition: (m = 1) */\nstatic int fts5Porter_MEq1(char *zStem, int nStem){\n  int n;\n  n = fts5PorterGobbleVC(zStem, nStem, 0);\n  if( n && 0==fts5PorterGobbleVC(&zStem[n], nStem-n, 1) ){\n    return 1;\n  }\n  return 0;\n}\n\n/* porter rule condition: (*o) */\nstatic int fts5Porter_Ostar(char *zStem, int nStem){\n  if( zStem[nStem-1]=='w' || zStem[nStem-1]=='x' || zStem[nStem-1]=='y' ){\n    return 0;\n  }else{\n    int i;\n    int mask = 0;\n    int bCons = 0;\n    for(i=0; i<nStem; i++){\n      bCons = !fts5PorterIsVowel(zStem[i], bCons);\n      assert( bCons==0 || bCons==1 );\n      mask = (mask << 1) + bCons;\n    }\n    return ((mask & 0x0007)==0x0005);\n  }\n}\n\n/* porter rule condition: (m > 1 and (*S or *T)) */\nstatic int fts5Porter_MGt1_and_S_or_T(char *zStem, int nStem){\n  assert( nStem>0 );\n  return (zStem[nStem-1]=='s' || zStem[nStem-1]=='t') \n      && fts5Porter_MGt1(zStem, nStem);\n}\n\n/* porter rule condition: (*v*) */\nstatic int fts5Porter_Vowel(char *zStem, int nStem){\n  int i;\n  for(i=0; i<nStem; i++){\n    if( fts5PorterIsVowel(zStem[i], i>0) ){\n      return 1;\n    }\n  }\n  return 0;\n}\n\n\n/**************************************************************************\n***************************************************************************\n** GENERATED CODE STARTS HERE (mkportersteps.tcl)\n*/\n\nstatic int fts5PorterStep4(char *aBuf, int *pnBuf){\n  int ret = 0;\n  int nBuf = *pnBuf;\n  switch( aBuf[nBuf-2] ){\n    \n    case 'a': \n      if( nBuf>2 && 0==memcmp(\"al\", &aBuf[nBuf-2], 2) ){\n        if( fts5Porter_MGt1(aBuf, nBuf-2) ){\n          *pnBuf = nBuf - 2;\n        }\n      }\n      break;\n  \n    case 'c': \n      if( nBuf>4 && 0==memcmp(\"ance\", &aBuf[nBuf-4], 4) ){\n        if( fts5Porter_MGt1(aBuf, nBuf-4) ){\n          *pnBuf = nBuf - 4;\n        }\n      }else if( nBuf>4 && 0==memcmp(\"ence\", &aBuf[nBuf-4], 4) ){\n        if( fts5Porter_MGt1(aBuf, nBuf-4) ){\n          *pnBuf = nBuf - 4;\n        }\n      }\n      break;\n  \n    case 'e': \n      if( nBuf>2 && 0==memcmp(\"er\", &aBuf[nBuf-2], 2) ){\n        if( fts5Porter_MGt1(aBuf, nBuf-2) ){\n          *pnBuf = nBuf - 2;\n        }\n      }\n      break;\n  \n    case 'i': \n      if( nBuf>2 && 0==memcmp(\"ic\", &aBuf[nBuf-2], 2) ){\n        if( fts5Porter_MGt1(aBuf, nBuf-2) ){\n          *pnBuf = nBuf - 2;\n        }\n      }\n      break;\n  \n    case 'l': \n      if( nBuf>4 && 0==memcmp(\"able\", &aBuf[nBuf-4], 4) ){\n        if( fts5Porter_MGt1(aBuf, nBuf-4) ){\n          *pnBuf = nBuf - 4;\n        }\n      }else if( nBuf>4 && 0==memcmp(\"ible\", &aBuf[nBuf-4], 4) ){\n        if( fts5Porter_MGt1(aBuf, nBuf-4) ){\n          *pnBuf = nBuf - 4;\n        }\n      }\n      break;\n  \n    case 'n': \n      if( nBuf>3 && 0==memcmp(\"ant\", &aBuf[nBuf-3], 3) ){\n        if( fts5Porter_MGt1(aBuf, nBuf-3) ){\n          *pnBuf = nBuf - 3;\n        }\n      }else if( nBuf>5 && 0==memcmp(\"ement\", &aBuf[nBuf-5], 5) ){\n        if( fts5Porter_MGt1(aBuf, nBuf-5) ){\n          *pnBuf = nBuf - 5;\n        }\n      }else if( nBuf>4 && 0==memcmp(\"ment\", &aBuf[nBuf-4], 4) ){\n        if( fts5Porter_MGt1(aBuf, nBuf-4) ){\n          *pnBuf = nBuf - 4;\n        }\n      }else if( nBuf>3 && 0==memcmp(\"ent\", &aBuf[nBuf-3], 3) ){\n        if( fts5Porter_MGt1(aBuf, nBuf-3) ){\n          *pnBuf = nBuf - 3;\n        }\n      }\n      break;\n  \n    case 'o': \n      if( nBuf>3 && 0==memcmp(\"ion\", &aBuf[nBuf-3], 3) ){\n        if( fts5Porter_MGt1_and_S_or_T(aBuf, nBuf-3) ){\n          *pnBuf = nBuf - 3;\n        }\n      }else if( nBuf>2 && 0==memcmp(\"ou\", &aBuf[nBuf-2], 2) ){\n        if( fts5Porter_MGt1(aBuf, nBuf-2) ){\n          *pnBuf = nBuf - 2;\n        }\n      }\n      break;\n  \n    case 's': \n      if( nBuf>3 && 0==memcmp(\"ism\", &aBuf[nBuf-3], 3) ){\n        if( fts5Porter_MGt1(aBuf, nBuf-3) ){\n          *pnBuf = nBuf - 3;\n        }\n      }\n      break;\n  \n    case 't': \n      if( nBuf>3 && 0==memcmp(\"ate\", &aBuf[nBuf-3], 3) ){\n        if( fts5Porter_MGt1(aBuf, nBuf-3) ){\n          *pnBuf = nBuf - 3;\n        }\n      }else if( nBuf>3 && 0==memcmp(\"iti\", &aBuf[nBuf-3], 3) ){\n        if( fts5Porter_MGt1(aBuf, nBuf-3) ){\n          *pnBuf = nBuf - 3;\n        }\n      }\n      break;\n  \n    case 'u': \n      if( nBuf>3 && 0==memcmp(\"ous\", &aBuf[nBuf-3], 3) ){\n        if( fts5Porter_MGt1(aBuf, nBuf-3) ){\n          *pnBuf = nBuf - 3;\n        }\n      }\n      break;\n  \n    case 'v': \n      if( nBuf>3 && 0==memcmp(\"ive\", &aBuf[nBuf-3], 3) ){\n        if( fts5Porter_MGt1(aBuf, nBuf-3) ){\n          *pnBuf = nBuf - 3;\n        }\n      }\n      break;\n  \n    case 'z': \n      if( nBuf>3 && 0==memcmp(\"ize\", &aBuf[nBuf-3], 3) ){\n        if( fts5Porter_MGt1(aBuf, nBuf-3) ){\n          *pnBuf = nBuf - 3;\n        }\n      }\n      break;\n  \n  }\n  return ret;\n}\n  \n\nstatic int fts5PorterStep1B2(char *aBuf, int *pnBuf){\n  int ret = 0;\n  int nBuf = *pnBuf;\n  switch( aBuf[nBuf-2] ){\n    \n    case 'a': \n      if( nBuf>2 && 0==memcmp(\"at\", &aBuf[nBuf-2], 2) ){\n        memcpy(&aBuf[nBuf-2], \"ate\", 3);\n        *pnBuf = nBuf - 2 + 3;\n        ret = 1;\n      }\n      break;\n  \n    case 'b': \n      if( nBuf>2 && 0==memcmp(\"bl\", &aBuf[nBuf-2], 2) ){\n        memcpy(&aBuf[nBuf-2], \"ble\", 3);\n        *pnBuf = nBuf - 2 + 3;\n        ret = 1;\n      }\n      break;\n  \n    case 'i': \n      if( nBuf>2 && 0==memcmp(\"iz\", &aBuf[nBuf-2], 2) ){\n        memcpy(&aBuf[nBuf-2], \"ize\", 3);\n        *pnBuf = nBuf - 2 + 3;\n        ret = 1;\n      }\n      break;\n  \n  }\n  return ret;\n}\n  \n\nstatic int fts5PorterStep2(char *aBuf, int *pnBuf){\n  int ret = 0;\n  int nBuf = *pnBuf;\n  switch( aBuf[nBuf-2] ){\n    \n    case 'a': \n      if( nBuf>7 && 0==memcmp(\"ational\", &aBuf[nBuf-7], 7) ){\n        if( fts5Porter_MGt0(aBuf, nBuf-7) ){\n          memcpy(&aBuf[nBuf-7], \"ate\", 3);\n          *pnBuf = nBuf - 7 + 3;\n        }\n      }else if( nBuf>6 && 0==memcmp(\"tional\", &aBuf[nBuf-6], 6) ){\n        if( fts5Porter_MGt0(aBuf, nBuf-6) ){\n          memcpy(&aBuf[nBuf-6], \"tion\", 4);\n          *pnBuf = nBuf - 6 + 4;\n        }\n      }\n      break;\n  \n    case 'c': \n      if( nBuf>4 && 0==memcmp(\"enci\", &aBuf[nBuf-4], 4) ){\n        if( fts5Porter_MGt0(aBuf, nBuf-4) ){\n          memcpy(&aBuf[nBuf-4], \"ence\", 4);\n          *pnBuf = nBuf - 4 + 4;\n        }\n      }else if( nBuf>4 && 0==memcmp(\"anci\", &aBuf[nBuf-4], 4) ){\n        if( fts5Porter_MGt0(aBuf, nBuf-4) ){\n          memcpy(&aBuf[nBuf-4], \"ance\", 4);\n          *pnBuf = nBuf - 4 + 4;\n        }\n      }\n      break;\n  \n    case 'e': \n      if( nBuf>4 && 0==memcmp(\"izer\", &aBuf[nBuf-4], 4) ){\n        if( fts5Porter_MGt0(aBuf, nBuf-4) ){\n          memcpy(&aBuf[nBuf-4], \"ize\", 3);\n          *pnBuf = nBuf - 4 + 3;\n        }\n      }\n      break;\n  \n    case 'g': \n      if( nBuf>4 && 0==memcmp(\"logi\", &aBuf[nBuf-4], 4) ){\n        if( fts5Porter_MGt0(aBuf, nBuf-4) ){\n          memcpy(&aBuf[nBuf-4], \"log\", 3);\n          *pnBuf = nBuf - 4 + 3;\n        }\n      }\n      break;\n  \n    case 'l': \n      if( nBuf>3 && 0==memcmp(\"bli\", &aBuf[nBuf-3], 3) ){\n        if( fts5Porter_MGt0(aBuf, nBuf-3) ){\n          memcpy(&aBuf[nBuf-3], \"ble\", 3);\n          *pnBuf = nBuf - 3 + 3;\n        }\n      }else if( nBuf>4 && 0==memcmp(\"alli\", &aBuf[nBuf-4], 4) ){\n        if( fts5Porter_MGt0(aBuf, nBuf-4) ){\n          memcpy(&aBuf[nBuf-4], \"al\", 2);\n          *pnBuf = nBuf - 4 + 2;\n        }\n      }else if( nBuf>5 && 0==memcmp(\"entli\", &aBuf[nBuf-5], 5) ){\n        if( fts5Porter_MGt0(aBuf, nBuf-5) ){\n          memcpy(&aBuf[nBuf-5], \"ent\", 3);\n          *pnBuf = nBuf - 5 + 3;\n        }\n      }else if( nBuf>3 && 0==memcmp(\"eli\", &aBuf[nBuf-3], 3) ){\n        if( fts5Porter_MGt0(aBuf, nBuf-3) ){\n          memcpy(&aBuf[nBuf-3], \"e\", 1);\n          *pnBuf = nBuf - 3 + 1;\n        }\n      }else if( nBuf>5 && 0==memcmp(\"ousli\", &aBuf[nBuf-5], 5) ){\n        if( fts5Porter_MGt0(aBuf, nBuf-5) ){\n          memcpy(&aBuf[nBuf-5], \"ous\", 3);\n          *pnBuf = nBuf - 5 + 3;\n        }\n      }\n      break;\n  \n    case 'o': \n      if( nBuf>7 && 0==memcmp(\"ization\", &aBuf[nBuf-7], 7) ){\n        if( fts5Porter_MGt0(aBuf, nBuf-7) ){\n          memcpy(&aBuf[nBuf-7], \"ize\", 3);\n          *pnBuf = nBuf - 7 + 3;\n        }\n      }else if( nBuf>5 && 0==memcmp(\"ation\", &aBuf[nBuf-5], 5) ){\n        if( fts5Porter_MGt0(aBuf, nBuf-5) ){\n          memcpy(&aBuf[nBuf-5], \"ate\", 3);\n          *pnBuf = nBuf - 5 + 3;\n        }\n      }else if( nBuf>4 && 0==memcmp(\"ator\", &aBuf[nBuf-4], 4) ){\n        if( fts5Porter_MGt0(aBuf, nBuf-4) ){\n          memcpy(&aBuf[nBuf-4], \"ate\", 3);\n          *pnBuf = nBuf - 4 + 3;\n        }\n      }\n      break;\n  \n    case 's': \n      if( nBuf>5 && 0==memcmp(\"alism\", &aBuf[nBuf-5], 5) ){\n        if( fts5Porter_MGt0(aBuf, nBuf-5) ){\n          memcpy(&aBuf[nBuf-5], \"al\", 2);\n          *pnBuf = nBuf - 5 + 2;\n        }\n      }else if( nBuf>7 && 0==memcmp(\"iveness\", &aBuf[nBuf-7], 7) ){\n        if( fts5Porter_MGt0(aBuf, nBuf-7) ){\n          memcpy(&aBuf[nBuf-7], \"ive\", 3);\n          *pnBuf = nBuf - 7 + 3;\n        }\n      }else if( nBuf>7 && 0==memcmp(\"fulness\", &aBuf[nBuf-7], 7) ){\n        if( fts5Porter_MGt0(aBuf, nBuf-7) ){\n          memcpy(&aBuf[nBuf-7], \"ful\", 3);\n          *pnBuf = nBuf - 7 + 3;\n        }\n      }else if( nBuf>7 && 0==memcmp(\"ousness\", &aBuf[nBuf-7], 7) ){\n        if( fts5Porter_MGt0(aBuf, nBuf-7) ){\n          memcpy(&aBuf[nBuf-7], \"ous\", 3);\n          *pnBuf = nBuf - 7 + 3;\n        }\n      }\n      break;\n  \n    case 't': \n      if( nBuf>5 && 0==memcmp(\"aliti\", &aBuf[nBuf-5], 5) ){\n        if( fts5Porter_MGt0(aBuf, nBuf-5) ){\n          memcpy(&aBuf[nBuf-5], \"al\", 2);\n          *pnBuf = nBuf - 5 + 2;\n        }\n      }else if( nBuf>5 && 0==memcmp(\"iviti\", &aBuf[nBuf-5], 5) ){\n        if( fts5Porter_MGt0(aBuf, nBuf-5) ){\n          memcpy(&aBuf[nBuf-5], \"ive\", 3);\n          *pnBuf = nBuf - 5 + 3;\n        }\n      }else if( nBuf>6 && 0==memcmp(\"biliti\", &aBuf[nBuf-6], 6) ){\n        if( fts5Porter_MGt0(aBuf, nBuf-6) ){\n          memcpy(&aBuf[nBuf-6], \"ble\", 3);\n          *pnBuf = nBuf - 6 + 3;\n        }\n      }\n      break;\n  \n  }\n  return ret;\n}\n  \n\nstatic int fts5PorterStep3(char *aBuf, int *pnBuf){\n  int ret = 0;\n  int nBuf = *pnBuf;\n  switch( aBuf[nBuf-2] ){\n    \n    case 'a': \n      if( nBuf>4 && 0==memcmp(\"ical\", &aBuf[nBuf-4], 4) ){\n        if( fts5Porter_MGt0(aBuf, nBuf-4) ){\n          memcpy(&aBuf[nBuf-4], \"ic\", 2);\n          *pnBuf = nBuf - 4 + 2;\n        }\n      }\n      break;\n  \n    case 's': \n      if( nBuf>4 && 0==memcmp(\"ness\", &aBuf[nBuf-4], 4) ){\n        if( fts5Porter_MGt0(aBuf, nBuf-4) ){\n          *pnBuf = nBuf - 4;\n        }\n      }\n      break;\n  \n    case 't': \n      if( nBuf>5 && 0==memcmp(\"icate\", &aBuf[nBuf-5], 5) ){\n        if( fts5Porter_MGt0(aBuf, nBuf-5) ){\n          memcpy(&aBuf[nBuf-5], \"ic\", 2);\n          *pnBuf = nBuf - 5 + 2;\n        }\n      }else if( nBuf>5 && 0==memcmp(\"iciti\", &aBuf[nBuf-5], 5) ){\n        if( fts5Porter_MGt0(aBuf, nBuf-5) ){\n          memcpy(&aBuf[nBuf-5], \"ic\", 2);\n          *pnBuf = nBuf - 5 + 2;\n        }\n      }\n      break;\n  \n    case 'u': \n      if( nBuf>3 && 0==memcmp(\"ful\", &aBuf[nBuf-3], 3) ){\n        if( fts5Porter_MGt0(aBuf, nBuf-3) ){\n          *pnBuf = nBuf - 3;\n        }\n      }\n      break;\n  \n    case 'v': \n      if( nBuf>5 && 0==memcmp(\"ative\", &aBuf[nBuf-5], 5) ){\n        if( fts5Porter_MGt0(aBuf, nBuf-5) ){\n          *pnBuf = nBuf - 5;\n        }\n      }\n      break;\n  \n    case 'z': \n      if( nBuf>5 && 0==memcmp(\"alize\", &aBuf[nBuf-5], 5) ){\n        if( fts5Porter_MGt0(aBuf, nBuf-5) ){\n          memcpy(&aBuf[nBuf-5], \"al\", 2);\n          *pnBuf = nBuf - 5 + 2;\n        }\n      }\n      break;\n  \n  }\n  return ret;\n}\n  \n\nstatic int fts5PorterStep1B(char *aBuf, int *pnBuf){\n  int ret = 0;\n  int nBuf = *pnBuf;\n  switch( aBuf[nBuf-2] ){\n    \n    case 'e': \n      if( nBuf>3 && 0==memcmp(\"eed\", &aBuf[nBuf-3], 3) ){\n        if( fts5Porter_MGt0(aBuf, nBuf-3) ){\n          memcpy(&aBuf[nBuf-3], \"ee\", 2);\n          *pnBuf = nBuf - 3 + 2;\n        }\n      }else if( nBuf>2 && 0==memcmp(\"ed\", &aBuf[nBuf-2], 2) ){\n        if( fts5Porter_Vowel(aBuf, nBuf-2) ){\n          *pnBuf = nBuf - 2;\n          ret = 1;\n        }\n      }\n      break;\n  \n    case 'n': \n      if( nBuf>3 && 0==memcmp(\"ing\", &aBuf[nBuf-3], 3) ){\n        if( fts5Porter_Vowel(aBuf, nBuf-3) ){\n          *pnBuf = nBuf - 3;\n          ret = 1;\n        }\n      }\n      break;\n  \n  }\n  return ret;\n}\n  \n/* \n** GENERATED CODE ENDS HERE (mkportersteps.tcl)\n***************************************************************************\n**************************************************************************/\n\nstatic void fts5PorterStep1A(char *aBuf, int *pnBuf){\n  int nBuf = *pnBuf;\n  if( aBuf[nBuf-1]=='s' ){\n    if( aBuf[nBuf-2]=='e' ){\n      if( (nBuf>4 && aBuf[nBuf-4]=='s' && aBuf[nBuf-3]=='s') \n       || (nBuf>3 && aBuf[nBuf-3]=='i' )\n      ){\n        *pnBuf = nBuf-2;\n      }else{\n        *pnBuf = nBuf-1;\n      }\n    }\n    else if( aBuf[nBuf-2]!='s' ){\n      *pnBuf = nBuf-1;\n    }\n  }\n}\n\nstatic int fts5PorterCb(\n  void *pCtx, \n  int tflags,\n  const char *pToken, \n  int nToken, \n  int iStart, \n  int iEnd\n){\n  PorterContext *p = (PorterContext*)pCtx;\n\n  char *aBuf;\n  int nBuf;\n\n  if( nToken>FTS5_PORTER_MAX_TOKEN || nToken<3 ) goto pass_through;\n  aBuf = p->aBuf;\n  nBuf = nToken;\n  memcpy(aBuf, pToken, nBuf);\n\n  /* Step 1. */\n  fts5PorterStep1A(aBuf, &nBuf);\n  if( fts5PorterStep1B(aBuf, &nBuf) ){\n    if( fts5PorterStep1B2(aBuf, &nBuf)==0 ){\n      char c = aBuf[nBuf-1];\n      if( fts5PorterIsVowel(c, 0)==0 \n       && c!='l' && c!='s' && c!='z' && c==aBuf[nBuf-2] \n      ){\n        nBuf--;\n      }else if( fts5Porter_MEq1(aBuf, nBuf) && fts5Porter_Ostar(aBuf, nBuf) ){\n        aBuf[nBuf++] = 'e';\n      }\n    }\n  }\n\n  /* Step 1C. */\n  if( aBuf[nBuf-1]=='y' && fts5Porter_Vowel(aBuf, nBuf-1) ){\n    aBuf[nBuf-1] = 'i';\n  }\n\n  /* Steps 2 through 4. */\n  fts5PorterStep2(aBuf, &nBuf);\n  fts5PorterStep3(aBuf, &nBuf);\n  fts5PorterStep4(aBuf, &nBuf);\n\n  /* Step 5a. */\n  assert( nBuf>0 );\n  if( aBuf[nBuf-1]=='e' ){\n    if( fts5Porter_MGt1(aBuf, nBuf-1) \n     || (fts5Porter_MEq1(aBuf, nBuf-1) && !fts5Porter_Ostar(aBuf, nBuf-1))\n    ){\n      nBuf--;\n    }\n  }\n\n  /* Step 5b. */\n  if( nBuf>1 && aBuf[nBuf-1]=='l' \n   && aBuf[nBuf-2]=='l' && fts5Porter_MGt1(aBuf, nBuf-1) \n  ){\n    nBuf--;\n  }\n\n  return p->xToken(p->pCtx, tflags, aBuf, nBuf, iStart, iEnd);\n\n pass_through:\n  return p->xToken(p->pCtx, tflags, pToken, nToken, iStart, iEnd);\n}\n\n/*\n** Tokenize using the porter tokenizer.\n*/\nstatic int fts5PorterTokenize(\n  Fts5Tokenizer *pTokenizer,\n  void *pCtx,\n  int flags,\n  const char *pText, int nText,\n  int (*xToken)(void*, int, const char*, int nToken, int iStart, int iEnd)\n){\n  PorterTokenizer *p = (PorterTokenizer*)pTokenizer;\n  PorterContext sCtx;\n  sCtx.xToken = xToken;\n  sCtx.pCtx = pCtx;\n  sCtx.aBuf = p->aBuf;\n  return p->tokenizer.xTokenize(\n      p->pTokenizer, (void*)&sCtx, flags, pText, nText, fts5PorterCb\n  );\n}\n\n/*\n** Register all built-in tokenizers with FTS5.\n*/\nstatic int sqlite3Fts5TokenizerInit(fts5_api *pApi){\n  struct BuiltinTokenizer {\n    const char *zName;\n    fts5_tokenizer x;\n  } aBuiltin[] = {\n    { \"unicode61\", {fts5UnicodeCreate, fts5UnicodeDelete, fts5UnicodeTokenize}},\n    { \"ascii\",     {fts5AsciiCreate, fts5AsciiDelete, fts5AsciiTokenize }},\n    { \"porter\",    {fts5PorterCreate, fts5PorterDelete, fts5PorterTokenize }},\n  };\n  \n  int rc = SQLITE_OK;             /* Return code */\n  int i;                          /* To iterate through builtin functions */\n\n  for(i=0; rc==SQLITE_OK && i<ArraySize(aBuiltin); i++){\n    rc = pApi->xCreateTokenizer(pApi,\n        aBuiltin[i].zName,\n        (void*)pApi,\n        &aBuiltin[i].x,\n        0\n    );\n  }\n\n  return rc;\n}\n\n/*\n** 2012-05-25\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n******************************************************************************\n*/\n\n/*\n** DO NOT EDIT THIS MACHINE GENERATED FILE.\n*/\n\n\n/* #include <assert.h> */\n\n\n\n/*\n** If the argument is a codepoint corresponding to a lowercase letter\n** in the ASCII range with a diacritic added, return the codepoint\n** of the ASCII letter only. For example, if passed 235 - \"LATIN\n** SMALL LETTER E WITH DIAERESIS\" - return 65 (\"LATIN SMALL LETTER\n** E\"). The resuls of passing a codepoint that corresponds to an\n** uppercase letter are undefined.\n*/\nstatic int fts5_remove_diacritic(int c, int bComplex){\n  unsigned short aDia[] = {\n        0,  1797,  1848,  1859,  1891,  1928,  1940,  1995, \n     2024,  2040,  2060,  2110,  2168,  2206,  2264,  2286, \n     2344,  2383,  2472,  2488,  2516,  2596,  2668,  2732, \n     2782,  2842,  2894,  2954,  2984,  3000,  3028,  3336, \n     3456,  3696,  3712,  3728,  3744,  3766,  3832,  3896, \n     3912,  3928,  3944,  3968,  4008,  4040,  4056,  4106, \n     4138,  4170,  4202,  4234,  4266,  4296,  4312,  4344, \n     4408,  4424,  4442,  4472,  4488,  4504,  6148,  6198, \n     6264,  6280,  6360,  6429,  6505,  6529, 61448, 61468, \n    61512, 61534, 61592, 61610, 61642, 61672, 61688, 61704, \n    61726, 61784, 61800, 61816, 61836, 61880, 61896, 61914, \n    61948, 61998, 62062, 62122, 62154, 62184, 62200, 62218, \n    62252, 62302, 62364, 62410, 62442, 62478, 62536, 62554, \n    62584, 62604, 62640, 62648, 62656, 62664, 62730, 62766, \n    62830, 62890, 62924, 62974, 63032, 63050, 63082, 63118, \n    63182, 63242, 63274, 63310, 63368, 63390, \n  };\n#define HIBIT ((unsigned char)0x80)\n  unsigned char aChar[] = {\n    '\\0',      'a',       'c',       'e',       'i',       'n',       \n    'o',       'u',       'y',       'y',       'a',       'c',       \n    'd',       'e',       'e',       'g',       'h',       'i',       \n    'j',       'k',       'l',       'n',       'o',       'r',       \n    's',       't',       'u',       'u',       'w',       'y',       \n    'z',       'o',       'u',       'a',       'i',       'o',       \n    'u',       'u'|HIBIT, 'a'|HIBIT, 'g',       'k',       'o',       \n    'o'|HIBIT, 'j',       'g',       'n',       'a'|HIBIT, 'a',       \n    'e',       'i',       'o',       'r',       'u',       's',       \n    't',       'h',       'a',       'e',       'o'|HIBIT, 'o',       \n    'o'|HIBIT, 'y',       '\\0',      '\\0',      '\\0',      '\\0',      \n    '\\0',      '\\0',      '\\0',      '\\0',      'a',       'b',       \n    'c'|HIBIT, 'd',       'd',       'e'|HIBIT, 'e',       'e'|HIBIT, \n    'f',       'g',       'h',       'h',       'i',       'i'|HIBIT, \n    'k',       'l',       'l'|HIBIT, 'l',       'm',       'n',       \n    'o'|HIBIT, 'p',       'r',       'r'|HIBIT, 'r',       's',       \n    's'|HIBIT, 't',       'u',       'u'|HIBIT, 'v',       'w',       \n    'w',       'x',       'y',       'z',       'h',       't',       \n    'w',       'y',       'a',       'a'|HIBIT, 'a'|HIBIT, 'a'|HIBIT, \n    'e',       'e'|HIBIT, 'e'|HIBIT, 'i',       'o',       'o'|HIBIT, \n    'o'|HIBIT, 'o'|HIBIT, 'u',       'u'|HIBIT, 'u'|HIBIT, 'y',       \n  };\n\n  unsigned int key = (((unsigned int)c)<<3) | 0x00000007;\n  int iRes = 0;\n  int iHi = sizeof(aDia)/sizeof(aDia[0]) - 1;\n  int iLo = 0;\n  while( iHi>=iLo ){\n    int iTest = (iHi + iLo) / 2;\n    if( key >= aDia[iTest] ){\n      iRes = iTest;\n      iLo = iTest+1;\n    }else{\n      iHi = iTest-1;\n    }\n  }\n  assert( key>=aDia[iRes] );\n  if( bComplex==0 && (aChar[iRes] & 0x80) ) return c;\n  return (c > (aDia[iRes]>>3) + (aDia[iRes]&0x07)) ? c : ((int)aChar[iRes] & 0x7F);\n}\n\n\n/*\n** Return true if the argument interpreted as a unicode codepoint\n** is a diacritical modifier character.\n*/\nstatic int sqlite3Fts5UnicodeIsdiacritic(int c){\n  unsigned int mask0 = 0x08029FDF;\n  unsigned int mask1 = 0x000361F8;\n  if( c<768 || c>817 ) return 0;\n  return (c < 768+32) ?\n      (mask0 & ((unsigned int)1 << (c-768))) :\n      (mask1 & ((unsigned int)1 << (c-768-32)));\n}\n\n\n/*\n** Interpret the argument as a unicode codepoint. If the codepoint\n** is an upper case character that has a lower case equivalent,\n** return the codepoint corresponding to the lower case version.\n** Otherwise, return a copy of the argument.\n**\n** The results are undefined if the value passed to this function\n** is less than zero.\n*/\nstatic int sqlite3Fts5UnicodeFold(int c, int eRemoveDiacritic){\n  /* Each entry in the following array defines a rule for folding a range\n  ** of codepoints to lower case. The rule applies to a range of nRange\n  ** codepoints starting at codepoint iCode.\n  **\n  ** If the least significant bit in flags is clear, then the rule applies\n  ** to all nRange codepoints (i.e. all nRange codepoints are upper case and\n  ** need to be folded). Or, if it is set, then the rule only applies to\n  ** every second codepoint in the range, starting with codepoint C.\n  **\n  ** The 7 most significant bits in flags are an index into the aiOff[]\n  ** array. If a specific codepoint C does require folding, then its lower\n  ** case equivalent is ((C + aiOff[flags>>1]) & 0xFFFF).\n  **\n  ** The contents of this array are generated by parsing the CaseFolding.txt\n  ** file distributed as part of the \"Unicode Character Database\". See\n  ** http://www.unicode.org for details.\n  */\n  static const struct TableEntry {\n    unsigned short iCode;\n    unsigned char flags;\n    unsigned char nRange;\n  } aEntry[] = {\n    {65, 14, 26},          {181, 64, 1},          {192, 14, 23},\n    {216, 14, 7},          {256, 1, 48},          {306, 1, 6},\n    {313, 1, 16},          {330, 1, 46},          {376, 116, 1},\n    {377, 1, 6},           {383, 104, 1},         {385, 50, 1},\n    {386, 1, 4},           {390, 44, 1},          {391, 0, 1},\n    {393, 42, 2},          {395, 0, 1},           {398, 32, 1},\n    {399, 38, 1},          {400, 40, 1},          {401, 0, 1},\n    {403, 42, 1},          {404, 46, 1},          {406, 52, 1},\n    {407, 48, 1},          {408, 0, 1},           {412, 52, 1},\n    {413, 54, 1},          {415, 56, 1},          {416, 1, 6},\n    {422, 60, 1},          {423, 0, 1},           {425, 60, 1},\n    {428, 0, 1},           {430, 60, 1},          {431, 0, 1},\n    {433, 58, 2},          {435, 1, 4},           {439, 62, 1},\n    {440, 0, 1},           {444, 0, 1},           {452, 2, 1},\n    {453, 0, 1},           {455, 2, 1},           {456, 0, 1},\n    {458, 2, 1},           {459, 1, 18},          {478, 1, 18},\n    {497, 2, 1},           {498, 1, 4},           {502, 122, 1},\n    {503, 134, 1},         {504, 1, 40},          {544, 110, 1},\n    {546, 1, 18},          {570, 70, 1},          {571, 0, 1},\n    {573, 108, 1},         {574, 68, 1},          {577, 0, 1},\n    {579, 106, 1},         {580, 28, 1},          {581, 30, 1},\n    {582, 1, 10},          {837, 36, 1},          {880, 1, 4},\n    {886, 0, 1},           {902, 18, 1},          {904, 16, 3},\n    {908, 26, 1},          {910, 24, 2},          {913, 14, 17},\n    {931, 14, 9},          {962, 0, 1},           {975, 4, 1},\n    {976, 140, 1},         {977, 142, 1},         {981, 146, 1},\n    {982, 144, 1},         {984, 1, 24},          {1008, 136, 1},\n    {1009, 138, 1},        {1012, 130, 1},        {1013, 128, 1},\n    {1015, 0, 1},          {1017, 152, 1},        {1018, 0, 1},\n    {1021, 110, 3},        {1024, 34, 16},        {1040, 14, 32},\n    {1120, 1, 34},         {1162, 1, 54},         {1216, 6, 1},\n    {1217, 1, 14},         {1232, 1, 88},         {1329, 22, 38},\n    {4256, 66, 38},        {4295, 66, 1},         {4301, 66, 1},\n    {7680, 1, 150},        {7835, 132, 1},        {7838, 96, 1},\n    {7840, 1, 96},         {7944, 150, 8},        {7960, 150, 6},\n    {7976, 150, 8},        {7992, 150, 8},        {8008, 150, 6},\n    {8025, 151, 8},        {8040, 150, 8},        {8072, 150, 8},\n    {8088, 150, 8},        {8104, 150, 8},        {8120, 150, 2},\n    {8122, 126, 2},        {8124, 148, 1},        {8126, 100, 1},\n    {8136, 124, 4},        {8140, 148, 1},        {8152, 150, 2},\n    {8154, 120, 2},        {8168, 150, 2},        {8170, 118, 2},\n    {8172, 152, 1},        {8184, 112, 2},        {8186, 114, 2},\n    {8188, 148, 1},        {8486, 98, 1},         {8490, 92, 1},\n    {8491, 94, 1},         {8498, 12, 1},         {8544, 8, 16},\n    {8579, 0, 1},          {9398, 10, 26},        {11264, 22, 47},\n    {11360, 0, 1},         {11362, 88, 1},        {11363, 102, 1},\n    {11364, 90, 1},        {11367, 1, 6},         {11373, 84, 1},\n    {11374, 86, 1},        {11375, 80, 1},        {11376, 82, 1},\n    {11378, 0, 1},         {11381, 0, 1},         {11390, 78, 2},\n    {11392, 1, 100},       {11499, 1, 4},         {11506, 0, 1},\n    {42560, 1, 46},        {42624, 1, 24},        {42786, 1, 14},\n    {42802, 1, 62},        {42873, 1, 4},         {42877, 76, 1},\n    {42878, 1, 10},        {42891, 0, 1},         {42893, 74, 1},\n    {42896, 1, 4},         {42912, 1, 10},        {42922, 72, 1},\n    {65313, 14, 26},       \n  };\n  static const unsigned short aiOff[] = {\n   1,     2,     8,     15,    16,    26,    28,    32,    \n   37,    38,    40,    48,    63,    64,    69,    71,    \n   79,    80,    116,   202,   203,   205,   206,   207,   \n   209,   210,   211,   213,   214,   217,   218,   219,   \n   775,   7264,  10792, 10795, 23228, 23256, 30204, 54721, \n   54753, 54754, 54756, 54787, 54793, 54809, 57153, 57274, \n   57921, 58019, 58363, 61722, 65268, 65341, 65373, 65406, \n   65408, 65410, 65415, 65424, 65436, 65439, 65450, 65462, \n   65472, 65476, 65478, 65480, 65482, 65488, 65506, 65511, \n   65514, 65521, 65527, 65528, 65529, \n  };\n\n  int ret = c;\n\n  assert( sizeof(unsigned short)==2 && sizeof(unsigned char)==1 );\n\n  if( c<128 ){\n    if( c>='A' && c<='Z' ) ret = c + ('a' - 'A');\n  }else if( c<65536 ){\n    const struct TableEntry *p;\n    int iHi = sizeof(aEntry)/sizeof(aEntry[0]) - 1;\n    int iLo = 0;\n    int iRes = -1;\n\n    assert( c>aEntry[0].iCode );\n    while( iHi>=iLo ){\n      int iTest = (iHi + iLo) / 2;\n      int cmp = (c - aEntry[iTest].iCode);\n      if( cmp>=0 ){\n        iRes = iTest;\n        iLo = iTest+1;\n      }else{\n        iHi = iTest-1;\n      }\n    }\n\n    assert( iRes>=0 && c>=aEntry[iRes].iCode );\n    p = &aEntry[iRes];\n    if( c<(p->iCode + p->nRange) && 0==(0x01 & p->flags & (p->iCode ^ c)) ){\n      ret = (c + (aiOff[p->flags>>1])) & 0x0000FFFF;\n      assert( ret>0 );\n    }\n\n    if( eRemoveDiacritic ){\n      ret = fts5_remove_diacritic(ret, eRemoveDiacritic==2);\n    }\n  }\n  \n  else if( c>=66560 && c<66600 ){\n    ret = c + 40;\n  }\n\n  return ret;\n}\n\n\nstatic int sqlite3Fts5UnicodeCatParse(const char *zCat, u8 *aArray){ \n  aArray[0] = 1;\n  switch( zCat[0] ){\n    case 'C':\n          switch( zCat[1] ){\n            case 'c': aArray[1] = 1; break;\n            case 'f': aArray[2] = 1; break;\n            case 'n': aArray[3] = 1; break;\n            case 's': aArray[4] = 1; break;\n            case 'o': aArray[31] = 1; break;\n            case '*': \n              aArray[1] = 1;\n              aArray[2] = 1;\n              aArray[3] = 1;\n              aArray[4] = 1;\n              aArray[31] = 1;\n              break;\n            default: return 1;          }\n          break;\n\n    case 'L':\n          switch( zCat[1] ){\n            case 'l': aArray[5] = 1; break;\n            case 'm': aArray[6] = 1; break;\n            case 'o': aArray[7] = 1; break;\n            case 't': aArray[8] = 1; break;\n            case 'u': aArray[9] = 1; break;\n            case 'C': aArray[30] = 1; break;\n            case '*': \n              aArray[5] = 1;\n              aArray[6] = 1;\n              aArray[7] = 1;\n              aArray[8] = 1;\n              aArray[9] = 1;\n              aArray[30] = 1;\n              break;\n            default: return 1;          }\n          break;\n\n    case 'M':\n          switch( zCat[1] ){\n            case 'c': aArray[10] = 1; break;\n            case 'e': aArray[11] = 1; break;\n            case 'n': aArray[12] = 1; break;\n            case '*': \n              aArray[10] = 1;\n              aArray[11] = 1;\n              aArray[12] = 1;\n              break;\n            default: return 1;          }\n          break;\n\n    case 'N':\n          switch( zCat[1] ){\n            case 'd': aArray[13] = 1; break;\n            case 'l': aArray[14] = 1; break;\n            case 'o': aArray[15] = 1; break;\n            case '*': \n              aArray[13] = 1;\n              aArray[14] = 1;\n              aArray[15] = 1;\n              break;\n            default: return 1;          }\n          break;\n\n    case 'P':\n          switch( zCat[1] ){\n            case 'c': aArray[16] = 1; break;\n            case 'd': aArray[17] = 1; break;\n            case 'e': aArray[18] = 1; break;\n            case 'f': aArray[19] = 1; break;\n            case 'i': aArray[20] = 1; break;\n            case 'o': aArray[21] = 1; break;\n            case 's': aArray[22] = 1; break;\n            case '*': \n              aArray[16] = 1;\n              aArray[17] = 1;\n              aArray[18] = 1;\n              aArray[19] = 1;\n              aArray[20] = 1;\n              aArray[21] = 1;\n              aArray[22] = 1;\n              break;\n            default: return 1;          }\n          break;\n\n    case 'S':\n          switch( zCat[1] ){\n            case 'c': aArray[23] = 1; break;\n            case 'k': aArray[24] = 1; break;\n            case 'm': aArray[25] = 1; break;\n            case 'o': aArray[26] = 1; break;\n            case '*': \n              aArray[23] = 1;\n              aArray[24] = 1;\n              aArray[25] = 1;\n              aArray[26] = 1;\n              break;\n            default: return 1;          }\n          break;\n\n    case 'Z':\n          switch( zCat[1] ){\n            case 'l': aArray[27] = 1; break;\n            case 'p': aArray[28] = 1; break;\n            case 's': aArray[29] = 1; break;\n            case '*': \n              aArray[27] = 1;\n              aArray[28] = 1;\n              aArray[29] = 1;\n              break;\n            default: return 1;          }\n          break;\n\n  }\n  return 0;\n}\n\nstatic u16 aFts5UnicodeBlock[] = {\n    0,     1471,  1753,  1760,  1760,  1760,  1760,  1760,  1760,  1760,  \n    1760,  1760,  1760,  1760,  1760,  1763,  1765,  \n  };\nstatic u16 aFts5UnicodeMap[] = {\n    0,     32,    33,    36,    37,    40,    41,    42,    43,    44,    \n    45,    46,    48,    58,    60,    63,    65,    91,    92,    93,    \n    94,    95,    96,    97,    123,   124,   125,   126,   127,   160,   \n    161,   162,   166,   167,   168,   169,   170,   171,   172,   173,   \n    174,   175,   176,   177,   178,   180,   181,   182,   184,   185,   \n    186,   187,   188,   191,   192,   215,   216,   223,   247,   248,   \n    256,   312,   313,   329,   330,   377,   383,   385,   387,   388,   \n    391,   394,   396,   398,   402,   403,   405,   406,   409,   412,   \n    414,   415,   417,   418,   423,   427,   428,   431,   434,   436,   \n    437,   440,   442,   443,   444,   446,   448,   452,   453,   454,   \n    455,   456,   457,   458,   459,   460,   461,   477,   478,   496,   \n    497,   498,   499,   500,   503,   505,   506,   564,   570,   572,   \n    573,   575,   577,   580,   583,   584,   592,   660,   661,   688,   \n    706,   710,   722,   736,   741,   748,   749,   750,   751,   768,   \n    880,   884,   885,   886,   890,   891,   894,   900,   902,   903,   \n    904,   908,   910,   912,   913,   931,   940,   975,   977,   978,   \n    981,   984,   1008,  1012,  1014,  1015,  1018,  1020,  1021,  1072,  \n    1120,  1154,  1155,  1160,  1162,  1217,  1231,  1232,  1329,  1369,  \n    1370,  1377,  1417,  1418,  1423,  1425,  1470,  1471,  1472,  1473,  \n    1475,  1476,  1478,  1479,  1488,  1520,  1523,  1536,  1542,  1545,  \n    1547,  1548,  1550,  1552,  1563,  1566,  1568,  1600,  1601,  1611,  \n    1632,  1642,  1646,  1648,  1649,  1748,  1749,  1750,  1757,  1758,  \n    1759,  1765,  1767,  1769,  1770,  1774,  1776,  1786,  1789,  1791,  \n    1792,  1807,  1808,  1809,  1810,  1840,  1869,  1958,  1969,  1984,  \n    1994,  2027,  2036,  2038,  2039,  2042,  2048,  2070,  2074,  2075,  \n    2084,  2085,  2088,  2089,  2096,  2112,  2137,  2142,  2208,  2210,  \n    2276,  2304,  2307,  2308,  2362,  2363,  2364,  2365,  2366,  2369,  \n    2377,  2381,  2382,  2384,  2385,  2392,  2402,  2404,  2406,  2416,  \n    2417,  2418,  2425,  2433,  2434,  2437,  2447,  2451,  2474,  2482,  \n    2486,  2492,  2493,  2494,  2497,  2503,  2507,  2509,  2510,  2519,  \n    2524,  2527,  2530,  2534,  2544,  2546,  2548,  2554,  2555,  2561,  \n    2563,  2565,  2575,  2579,  2602,  2610,  2613,  2616,  2620,  2622,  \n    2625,  2631,  2635,  2641,  2649,  2654,  2662,  2672,  2674,  2677,  \n    2689,  2691,  2693,  2703,  2707,  2730,  2738,  2741,  2748,  2749,  \n    2750,  2753,  2759,  2761,  2763,  2765,  2768,  2784,  2786,  2790,  \n    2800,  2801,  2817,  2818,  2821,  2831,  2835,  2858,  2866,  2869,  \n    2876,  2877,  2878,  2879,  2880,  2881,  2887,  2891,  2893,  2902,  \n    2903,  2908,  2911,  2914,  2918,  2928,  2929,  2930,  2946,  2947,  \n    2949,  2958,  2962,  2969,  2972,  2974,  2979,  2984,  2990,  3006,  \n    3008,  3009,  3014,  3018,  3021,  3024,  3031,  3046,  3056,  3059,  \n    3065,  3066,  3073,  3077,  3086,  3090,  3114,  3125,  3133,  3134,  \n    3137,  3142,  3146,  3157,  3160,  3168,  3170,  3174,  3192,  3199,  \n    3202,  3205,  3214,  3218,  3242,  3253,  3260,  3261,  3262,  3263,  \n    3264,  3270,  3271,  3274,  3276,  3285,  3294,  3296,  3298,  3302,  \n    3313,  3330,  3333,  3342,  3346,  3389,  3390,  3393,  3398,  3402,  \n    3405,  3406,  3415,  3424,  3426,  3430,  3440,  3449,  3450,  3458,  \n    3461,  3482,  3507,  3517,  3520,  3530,  3535,  3538,  3542,  3544,  \n    3570,  3572,  3585,  3633,  3634,  3636,  3647,  3648,  3654,  3655,  \n    3663,  3664,  3674,  3713,  3716,  3719,  3722,  3725,  3732,  3737,  \n    3745,  3749,  3751,  3754,  3757,  3761,  3762,  3764,  3771,  3773,  \n    3776,  3782,  3784,  3792,  3804,  3840,  3841,  3844,  3859,  3860,  \n    3861,  3864,  3866,  3872,  3882,  3892,  3893,  3894,  3895,  3896,  \n    3897,  3898,  3899,  3900,  3901,  3902,  3904,  3913,  3953,  3967,  \n    3968,  3973,  3974,  3976,  3981,  3993,  4030,  4038,  4039,  4046,  \n    4048,  4053,  4057,  4096,  4139,  4141,  4145,  4146,  4152,  4153,  \n    4155,  4157,  4159,  4160,  4170,  4176,  4182,  4184,  4186,  4190,  \n    4193,  4194,  4197,  4199,  4206,  4209,  4213,  4226,  4227,  4229,  \n    4231,  4237,  4238,  4239,  4240,  4250,  4253,  4254,  4256,  4295,  \n    4301,  4304,  4347,  4348,  4349,  4682,  4688,  4696,  4698,  4704,  \n    4746,  4752,  4786,  4792,  4800,  4802,  4808,  4824,  4882,  4888,  \n    4957,  4960,  4969,  4992,  5008,  5024,  5120,  5121,  5741,  5743,  \n    5760,  5761,  5787,  5788,  5792,  5867,  5870,  5888,  5902,  5906,  \n    5920,  5938,  5941,  5952,  5970,  5984,  5998,  6002,  6016,  6068,  \n    6070,  6071,  6078,  6086,  6087,  6089,  6100,  6103,  6104,  6107,  \n    6108,  6109,  6112,  6128,  6144,  6150,  6151,  6155,  6158,  6160,  \n    6176,  6211,  6212,  6272,  6313,  6314,  6320,  6400,  6432,  6435,  \n    6439,  6441,  6448,  6450,  6451,  6457,  6464,  6468,  6470,  6480,  \n    6512,  6528,  6576,  6593,  6600,  6608,  6618,  6622,  6656,  6679,  \n    6681,  6686,  6688,  6741,  6742,  6743,  6744,  6752,  6753,  6754,  \n    6755,  6757,  6765,  6771,  6783,  6784,  6800,  6816,  6823,  6824,  \n    6912,  6916,  6917,  6964,  6965,  6966,  6971,  6972,  6973,  6978,  \n    6979,  6981,  6992,  7002,  7009,  7019,  7028,  7040,  7042,  7043,  \n    7073,  7074,  7078,  7080,  7082,  7083,  7084,  7086,  7088,  7098,  \n    7142,  7143,  7144,  7146,  7149,  7150,  7151,  7154,  7164,  7168,  \n    7204,  7212,  7220,  7222,  7227,  7232,  7245,  7248,  7258,  7288,  \n    7294,  7360,  7376,  7379,  7380,  7393,  7394,  7401,  7405,  7406,  \n    7410,  7412,  7413,  7424,  7468,  7531,  7544,  7545,  7579,  7616,  \n    7676,  7680,  7830,  7838,  7936,  7944,  7952,  7960,  7968,  7976,  \n    7984,  7992,  8000,  8008,  8016,  8025,  8027,  8029,  8031,  8033,  \n    8040,  8048,  8064,  8072,  8080,  8088,  8096,  8104,  8112,  8118,  \n    8120,  8124,  8125,  8126,  8127,  8130,  8134,  8136,  8140,  8141,  \n    8144,  8150,  8152,  8157,  8160,  8168,  8173,  8178,  8182,  8184,  \n    8188,  8189,  8192,  8203,  8208,  8214,  8216,  8217,  8218,  8219,  \n    8221,  8222,  8223,  8224,  8232,  8233,  8234,  8239,  8240,  8249,  \n    8250,  8251,  8255,  8257,  8260,  8261,  8262,  8263,  8274,  8275,  \n    8276,  8277,  8287,  8288,  8298,  8304,  8305,  8308,  8314,  8317,  \n    8318,  8319,  8320,  8330,  8333,  8334,  8336,  8352,  8400,  8413,  \n    8417,  8418,  8421,  8448,  8450,  8451,  8455,  8456,  8458,  8459,  \n    8462,  8464,  8467,  8468,  8469,  8470,  8472,  8473,  8478,  8484,  \n    8485,  8486,  8487,  8488,  8489,  8490,  8494,  8495,  8496,  8500,  \n    8501,  8505,  8506,  8508,  8510,  8512,  8517,  8519,  8522,  8523,  \n    8524,  8526,  8527,  8528,  8544,  8579,  8581,  8585,  8592,  8597,  \n    8602,  8604,  8608,  8609,  8611,  8612,  8614,  8615,  8622,  8623,  \n    8654,  8656,  8658,  8659,  8660,  8661,  8692,  8960,  8968,  8972,  \n    8992,  8994,  9001,  9002,  9003,  9084,  9085,  9115,  9140,  9180,  \n    9186,  9216,  9280,  9312,  9372,  9450,  9472,  9655,  9656,  9665,  \n    9666,  9720,  9728,  9839,  9840,  9985,  10088, 10089, 10090, 10091, \n    10092, 10093, 10094, 10095, 10096, 10097, 10098, 10099, 10100, 10101, \n    10102, 10132, 10176, 10181, 10182, 10183, 10214, 10215, 10216, 10217, \n    10218, 10219, 10220, 10221, 10222, 10223, 10224, 10240, 10496, 10627, \n    10628, 10629, 10630, 10631, 10632, 10633, 10634, 10635, 10636, 10637, \n    10638, 10639, 10640, 10641, 10642, 10643, 10644, 10645, 10646, 10647, \n    10648, 10649, 10712, 10713, 10714, 10715, 10716, 10748, 10749, 10750, \n    11008, 11056, 11077, 11079, 11088, 11264, 11312, 11360, 11363, 11365, \n    11367, 11374, 11377, 11378, 11380, 11381, 11383, 11388, 11390, 11393, \n    11394, 11492, 11493, 11499, 11503, 11506, 11513, 11517, 11518, 11520, \n    11559, 11565, 11568, 11631, 11632, 11647, 11648, 11680, 11688, 11696, \n    11704, 11712, 11720, 11728, 11736, 11744, 11776, 11778, 11779, 11780, \n    11781, 11782, 11785, 11786, 11787, 11788, 11789, 11790, 11799, 11800, \n    11802, 11803, 11804, 11805, 11806, 11808, 11809, 11810, 11811, 11812, \n    11813, 11814, 11815, 11816, 11817, 11818, 11823, 11824, 11834, 11904, \n    11931, 12032, 12272, 12288, 12289, 12292, 12293, 12294, 12295, 12296, \n    12297, 12298, 12299, 12300, 12301, 12302, 12303, 12304, 12305, 12306, \n    12308, 12309, 12310, 12311, 12312, 12313, 12314, 12315, 12316, 12317, \n    12318, 12320, 12321, 12330, 12334, 12336, 12337, 12342, 12344, 12347, \n    12348, 12349, 12350, 12353, 12441, 12443, 12445, 12447, 12448, 12449, \n    12539, 12540, 12543, 12549, 12593, 12688, 12690, 12694, 12704, 12736, \n    12784, 12800, 12832, 12842, 12872, 12880, 12881, 12896, 12928, 12938, \n    12977, 12992, 13056, 13312, 19893, 19904, 19968, 40908, 40960, 40981, \n    40982, 42128, 42192, 42232, 42238, 42240, 42508, 42509, 42512, 42528, \n    42538, 42560, 42606, 42607, 42608, 42611, 42612, 42622, 42623, 42624, \n    42655, 42656, 42726, 42736, 42738, 42752, 42775, 42784, 42786, 42800, \n    42802, 42864, 42865, 42873, 42878, 42888, 42889, 42891, 42896, 42912, \n    43000, 43002, 43003, 43010, 43011, 43014, 43015, 43019, 43020, 43043, \n    43045, 43047, 43048, 43056, 43062, 43064, 43065, 43072, 43124, 43136, \n    43138, 43188, 43204, 43214, 43216, 43232, 43250, 43256, 43259, 43264, \n    43274, 43302, 43310, 43312, 43335, 43346, 43359, 43360, 43392, 43395, \n    43396, 43443, 43444, 43446, 43450, 43452, 43453, 43457, 43471, 43472, \n    43486, 43520, 43561, 43567, 43569, 43571, 43573, 43584, 43587, 43588, \n    43596, 43597, 43600, 43612, 43616, 43632, 43633, 43639, 43642, 43643, \n    43648, 43696, 43697, 43698, 43701, 43703, 43705, 43710, 43712, 43713, \n    43714, 43739, 43741, 43742, 43744, 43755, 43756, 43758, 43760, 43762, \n    43763, 43765, 43766, 43777, 43785, 43793, 43808, 43816, 43968, 44003, \n    44005, 44006, 44008, 44009, 44011, 44012, 44013, 44016, 44032, 55203, \n    55216, 55243, 55296, 56191, 56319, 57343, 57344, 63743, 63744, 64112, \n    64256, 64275, 64285, 64286, 64287, 64297, 64298, 64312, 64318, 64320, \n    64323, 64326, 64434, 64467, 64830, 64831, 64848, 64914, 65008, 65020, \n    65021, 65024, 65040, 65047, 65048, 65049, 65056, 65072, 65073, 65075, \n    65077, 65078, 65079, 65080, 65081, 65082, 65083, 65084, 65085, 65086, \n    65087, 65088, 65089, 65090, 65091, 65092, 65093, 65095, 65096, 65097, \n    65101, 65104, 65108, 65112, 65113, 65114, 65115, 65116, 65117, 65118, \n    65119, 65122, 65123, 65124, 65128, 65129, 65130, 65136, 65142, 65279, \n    65281, 65284, 65285, 65288, 65289, 65290, 65291, 65292, 65293, 65294, \n    65296, 65306, 65308, 65311, 65313, 65339, 65340, 65341, 65342, 65343, \n    65344, 65345, 65371, 65372, 65373, 65374, 65375, 65376, 65377, 65378, \n    65379, 65380, 65382, 65392, 65393, 65438, 65440, 65474, 65482, 65490, \n    65498, 65504, 65506, 65507, 65508, 65509, 65512, 65513, 65517, 65529, \n    65532, 0,     13,    40,    60,    63,    80,    128,   256,   263,   \n    311,   320,   373,   377,   394,   400,   464,   509,   640,   672,   \n    768,   800,   816,   833,   834,   842,   896,   927,   928,   968,   \n    976,   977,   1024,  1064,  1104,  1184,  2048,  2056,  2058,  2103,  \n    2108,  2111,  2135,  2136,  2304,  2326,  2335,  2336,  2367,  2432,  \n    2494,  2560,  2561,  2565,  2572,  2576,  2581,  2585,  2616,  2623,  \n    2624,  2640,  2656,  2685,  2687,  2816,  2873,  2880,  2904,  2912,  \n    2936,  3072,  3680,  4096,  4097,  4098,  4099,  4152,  4167,  4178,  \n    4198,  4224,  4226,  4227,  4272,  4275,  4279,  4281,  4283,  4285,  \n    4286,  4304,  4336,  4352,  4355,  4391,  4396,  4397,  4406,  4416,  \n    4480,  4482,  4483,  4531,  4534,  4543,  4545,  4549,  4560,  5760,  \n    5803,  5804,  5805,  5806,  5808,  5814,  5815,  5824,  8192,  9216,  \n    9328,  12288, 26624, 28416, 28496, 28497, 28559, 28563, 45056, 53248, \n    53504, 53545, 53605, 53607, 53610, 53613, 53619, 53627, 53635, 53637, \n    53644, 53674, 53678, 53760, 53826, 53829, 54016, 54112, 54272, 54298, \n    54324, 54350, 54358, 54376, 54402, 54428, 54430, 54434, 54437, 54441, \n    54446, 54454, 54459, 54461, 54469, 54480, 54506, 54532, 54535, 54541, \n    54550, 54558, 54584, 54587, 54592, 54598, 54602, 54610, 54636, 54662, \n    54688, 54714, 54740, 54766, 54792, 54818, 54844, 54870, 54896, 54922, \n    54952, 54977, 54978, 55003, 55004, 55010, 55035, 55036, 55061, 55062, \n    55068, 55093, 55094, 55119, 55120, 55126, 55151, 55152, 55177, 55178, \n    55184, 55209, 55210, 55235, 55236, 55242, 55246, 60928, 60933, 60961, \n    60964, 60967, 60969, 60980, 60985, 60987, 60994, 60999, 61001, 61003, \n    61005, 61009, 61012, 61015, 61017, 61019, 61021, 61023, 61025, 61028, \n    61031, 61036, 61044, 61049, 61054, 61056, 61067, 61089, 61093, 61099, \n    61168, 61440, 61488, 61600, 61617, 61633, 61649, 61696, 61712, 61744, \n    61808, 61926, 61968, 62016, 62032, 62208, 62256, 62263, 62336, 62368, \n    62406, 62432, 62464, 62528, 62530, 62713, 62720, 62784, 62800, 62971, \n    63045, 63104, 63232, 0,     42710, 42752, 46900, 46912, 47133, 63488, \n    1,     32,    256,   0,     65533, \n  };\nstatic u16 aFts5UnicodeData[] = {\n    1025,  61,    117,   55,    117,   54,    50,    53,    57,    53,    \n    49,    85,    333,   85,    121,   85,    841,   54,    53,    50,    \n    56,    48,    56,    837,   54,    57,    50,    57,    1057,  61,    \n    53,    151,   58,    53,    56,    58,    39,    52,    57,    34,    \n    58,    56,    58,    57,    79,    56,    37,    85,    56,    47,    \n    39,    51,    111,   53,    745,   57,    233,   773,   57,    261,   \n    1822,  37,    542,   37,    1534,  222,   69,    73,    37,    126,   \n    126,   73,    69,    137,   37,    73,    37,    105,   101,   73,    \n    37,    73,    37,    190,   158,   37,    126,   126,   73,    37,    \n    126,   94,    37,    39,    94,    69,    135,   41,    40,    37,    \n    41,    40,    37,    41,    40,    37,    542,   37,    606,   37,    \n    41,    40,    37,    126,   73,    37,    1886,  197,   73,    37,    \n    73,    69,    126,   105,   37,    286,   2181,  39,    869,   582,   \n    152,   390,   472,   166,   248,   38,    56,    38,    568,   3596,  \n    158,   38,    56,    94,    38,    101,   53,    88,    41,    53,    \n    105,   41,    73,    37,    553,   297,   1125,  94,    37,    105,   \n    101,   798,   133,   94,    57,    126,   94,    37,    1641,  1541,  \n    1118,  58,    172,   75,    1790,  478,   37,    2846,  1225,  38,    \n    213,   1253,  53,    49,    55,    1452,  49,    44,    53,    76,    \n    53,    76,    53,    44,    871,   103,   85,    162,   121,   85,    \n    55,    85,    90,    364,   53,    85,    1031,  38,    327,   684,   \n    333,   149,   71,    44,    3175,  53,    39,    236,   34,    58,    \n    204,   70,    76,    58,    140,   71,    333,   103,   90,    39,    \n    469,   34,    39,    44,    967,   876,   2855,  364,   39,    333,   \n    1063,  300,   70,    58,    117,   38,    711,   140,   38,    300,   \n    38,    108,   38,    172,   501,   807,   108,   53,    39,    359,   \n    876,   108,   42,    1735,  44,    42,    44,    39,    106,   268,   \n    138,   44,    74,    39,    236,   327,   76,    85,    333,   53,    \n    38,    199,   231,   44,    74,    263,   71,    711,   231,   39,    \n    135,   44,    39,    106,   140,   74,    74,    44,    39,    42,    \n    71,    103,   76,    333,   71,    87,    207,   58,    55,    76,    \n    42,    199,   71,    711,   231,   71,    71,    71,    44,    106,   \n    76,    76,    108,   44,    135,   39,    333,   76,    103,   44,    \n    76,    42,    295,   103,   711,   231,   71,    167,   44,    39,    \n    106,   172,   76,    42,    74,    44,    39,    71,    76,    333,   \n    53,    55,    44,    74,    263,   71,    711,   231,   71,    167,   \n    44,    39,    42,    44,    42,    140,   74,    74,    44,    44,    \n    42,    71,    103,   76,    333,   58,    39,    207,   44,    39,    \n    199,   103,   135,   71,    39,    71,    71,    103,   391,   74,    \n    44,    74,    106,   106,   44,    39,    42,    333,   111,   218,   \n    55,    58,    106,   263,   103,   743,   327,   167,   39,    108,   \n    138,   108,   140,   76,    71,    71,    76,    333,   239,   58,    \n    74,    263,   103,   743,   327,   167,   44,    39,    42,    44,    \n    170,   44,    74,    74,    76,    74,    39,    71,    76,    333,   \n    71,    74,    263,   103,   1319,  39,    106,   140,   106,   106,   \n    44,    39,    42,    71,    76,    333,   207,   58,    199,   74,    \n    583,   775,   295,   39,    231,   44,    106,   108,   44,    266,   \n    74,    53,    1543,  44,    71,    236,   55,    199,   38,    268,   \n    53,    333,   85,    71,    39,    71,    39,    39,    135,   231,   \n    103,   39,    39,    71,    135,   44,    71,    204,   76,    39,    \n    167,   38,    204,   333,   135,   39,    122,   501,   58,    53,    \n    122,   76,    218,   333,   335,   58,    44,    58,    44,    58,    \n    44,    54,    50,    54,    50,    74,    263,   1159,  460,   42,    \n    172,   53,    76,    167,   364,   1164,  282,   44,    218,   90,    \n    181,   154,   85,    1383,  74,    140,   42,    204,   42,    76,    \n    74,    76,    39,    333,   213,   199,   74,    76,    135,   108,   \n    39,    106,   71,    234,   103,   140,   423,   44,    74,    76,    \n    202,   44,    39,    42,    333,   106,   44,    90,    1225,  41,    \n    41,    1383,  53,    38,    10631, 135,   231,   39,    135,   1319,  \n    135,   1063,  135,   231,   39,    135,   487,   1831,  135,   2151,  \n    108,   309,   655,   519,   346,   2727,  49,    19847, 85,    551,   \n    61,    839,   54,    50,    2407,  117,   110,   423,   135,   108,   \n    583,   108,   85,    583,   76,    423,   103,   76,    1671,  76,    \n    42,    236,   266,   44,    74,    364,   117,   38,    117,   55,    \n    39,    44,    333,   335,   213,   49,    149,   108,   61,    333,   \n    1127,  38,    1671,  1319,  44,    39,    2247,  935,   108,   138,   \n    76,    106,   74,    44,    202,   108,   58,    85,    333,   967,   \n    167,   1415,  554,   231,   74,    333,   47,    1114,  743,   76,    \n    106,   85,    1703,  42,    44,    42,    236,   44,    42,    44,    \n    74,    268,   202,   332,   44,    333,   333,   245,   38,    213,   \n    140,   42,    1511,  44,    42,    172,   42,    44,    170,   44,    \n    74,    231,   333,   245,   346,   300,   314,   76,    42,    967,   \n    42,    140,   74,    76,    42,    44,    74,    71,    333,   1415,  \n    44,    42,    76,    106,   44,    42,    108,   74,    149,   1159,  \n    266,   268,   74,    76,    181,   333,   103,   333,   967,   198,   \n    85,    277,   108,   53,    428,   42,    236,   135,   44,    135,   \n    74,    44,    71,    1413,  2022,  421,   38,    1093,  1190,  1260,  \n    140,   4830,  261,   3166,  261,   265,   197,   201,   261,   265,   \n    261,   265,   197,   201,   261,   41,    41,    41,    94,    229,   \n    265,   453,   261,   264,   261,   264,   261,   264,   165,   69,    \n    137,   40,    56,    37,    120,   101,   69,    137,   40,    120,   \n    133,   69,    137,   120,   261,   169,   120,   101,   69,    137,   \n    40,    88,    381,   162,   209,   85,    52,    51,    54,    84,    \n    51,    54,    52,    277,   59,    60,    162,   61,    309,   52,    \n    51,    149,   80,    117,   57,    54,    50,    373,   57,    53,    \n    48,    341,   61,    162,   194,   47,    38,    207,   121,   54,    \n    50,    38,    335,   121,   54,    50,    422,   855,   428,   139,   \n    44,    107,   396,   90,    41,    154,   41,    90,    37,    105,   \n    69,    105,   37,    58,    41,    90,    57,    169,   218,   41,    \n    58,    41,    58,    41,    58,    137,   58,    37,    137,   37,    \n    135,   37,    90,    69,    73,    185,   94,    101,   58,    57,    \n    90,    37,    58,    527,   1134,  94,    142,   47,    185,   186,   \n    89,    154,   57,    90,    57,    90,    57,    250,   57,    1018,  \n    89,    90,    57,    58,    57,    1018,  8601,  282,   153,   666,   \n    89,    250,   54,    50,    2618,  57,    986,   825,   1306,  217,   \n    602,   1274,  378,   1935,  2522,  719,   5882,  57,    314,   57,    \n    1754,  281,   3578,  57,    4634,  3322,  54,    50,    54,    50,    \n    54,    50,    54,    50,    54,    50,    54,    50,    54,    50,    \n    975,   1434,  185,   54,    50,    1017,  54,    50,    54,    50,    \n    54,    50,    54,    50,    54,    50,    537,   8218,  4217,  54,    \n    50,    54,    50,    54,    50,    54,    50,    54,    50,    54,    \n    50,    54,    50,    54,    50,    54,    50,    54,    50,    54,    \n    50,    2041,  54,    50,    54,    50,    1049,  54,    50,    8281,  \n    1562,  697,   90,    217,   346,   1513,  1509,  126,   73,    69,    \n    254,   105,   37,    94,    37,    94,    165,   70,    105,   37,    \n    3166,  37,    218,   158,   108,   94,    149,   47,    85,    1221,  \n    37,    37,    1799,  38,    53,    44,    743,   231,   231,   231,   \n    231,   231,   231,   231,   231,   1036,  85,    52,    51,    52,    \n    51,    117,   52,    51,    53,    52,    51,    309,   49,    85,    \n    49,    53,    52,    51,    85,    52,    51,    54,    50,    54,    \n    50,    54,    50,    54,    50,    181,   38,    341,   81,    858,   \n    2874,  6874,  410,   61,    117,   58,    38,    39,    46,    54,    \n    50,    54,    50,    54,    50,    54,    50,    54,    50,    90,    \n    54,    50,    54,    50,    54,    50,    54,    50,    49,    54,    \n    82,    58,    302,   140,   74,    49,    166,   90,    110,   38,    \n    39,    53,    90,    2759,  76,    88,    70,    39,    49,    2887,  \n    53,    102,   39,    1319,  3015,  90,    143,   346,   871,   1178,  \n    519,   1018,  335,   986,   271,   58,    495,   1050,  335,   1274,  \n    495,   2042,  8218,  39,    39,    2074,  39,    39,    679,   38,    \n    36583, 1786,  1287,  198,   85,    8583,  38,    117,   519,   333,   \n    71,    1502,  39,    44,    107,   53,    332,   53,    38,    798,   \n    44,    2247,  334,   76,    213,   760,   294,   88,    478,   69,    \n    2014,  38,    261,   190,   350,   38,    88,    158,   158,   382,   \n    70,    37,    231,   44,    103,   44,    135,   44,    743,   74,    \n    76,    42,    154,   207,   90,    55,    58,    1671,  149,   74,    \n    1607,  522,   44,    85,    333,   588,   199,   117,   39,    333,   \n    903,   268,   85,    743,   364,   74,    53,    935,   108,   42,    \n    1511,  44,    74,    140,   74,    44,    138,   437,   38,    333,   \n    85,    1319,  204,   74,    76,    74,    76,    103,   44,    263,   \n    44,    42,    333,   149,   519,   38,    199,   122,   39,    42,    \n    1543,  44,    39,    108,   71,    76,    167,   76,    39,    44,    \n    39,    71,    38,    85,    359,   42,    76,    74,    85,    39,    \n    70,    42,    44,    199,   199,   199,   231,   231,   1127,  74,    \n    44,    74,    44,    74,    53,    42,    44,    333,   39,    39,    \n    743,   1575,  36,    68,    68,    36,    63,    63,    11719, 3399,  \n    229,   165,   39,    44,    327,   57,    423,   167,   39,    71,    \n    71,    3463,  536,   11623, 54,    50,    2055,  1735,  391,   55,    \n    58,    524,   245,   54,    50,    53,    236,   53,    81,    80,    \n    54,    50,    54,    50,    54,    50,    54,    50,    54,    50,    \n    54,    50,    54,    50,    54,    50,    85,    54,    50,    149,   \n    112,   117,   149,   49,    54,    50,    54,    50,    54,    50,    \n    117,   57,    49,    121,   53,    55,    85,    167,   4327,  34,    \n    117,   55,    117,   54,    50,    53,    57,    53,    49,    85,    \n    333,   85,    121,   85,    841,   54,    53,    50,    56,    48,    \n    56,    837,   54,    57,    50,    57,    54,    50,    53,    54,    \n    50,    85,    327,   38,    1447,  70,    999,   199,   199,   199,   \n    103,   87,    57,    56,    58,    87,    58,    153,   90,    98,    \n    90,    391,   839,   615,   71,    487,   455,   3943,  117,   1455,  \n    314,   1710,  143,   570,   47,    410,   1466,  44,    935,   1575,  \n    999,   143,   551,   46,    263,   46,    967,   53,    1159,  263,   \n    53,    174,   1289,  1285,  2503,  333,   199,   39,    1415,  71,    \n    39,    743,   53,    271,   711,   207,   53,    839,   53,    1799,  \n    71,    39,    108,   76,    140,   135,   103,   871,   108,   44,    \n    271,   309,   935,   79,    53,    1735,  245,   711,   271,   615,   \n    271,   2343,  1007,  42,    44,    42,    1703,  492,   245,   655,   \n    333,   76,    42,    1447,  106,   140,   74,    76,    85,    34,    \n    149,   807,   333,   108,   1159,  172,   42,    268,   333,   149,   \n    76,    42,    1543,  106,   300,   74,    135,   149,   333,   1383,  \n    44,    42,    44,    74,    204,   42,    44,    333,   28135, 3182,  \n    149,   34279, 18215, 2215,  39,    1482,  140,   422,   71,    7898,  \n    1274,  1946,  74,    108,   122,   202,   258,   268,   90,    236,   \n    986,   140,   1562,  2138,  108,   58,    2810,  591,   841,   837,   \n    841,   229,   581,   841,   837,   41,    73,    41,    73,    137,   \n    265,   133,   37,    229,   357,   841,   837,   73,    137,   265,   \n    233,   837,   73,    137,   169,   41,    233,   837,   841,   837,   \n    841,   837,   841,   837,   841,   837,   841,   837,   841,   901,   \n    809,   57,    805,   57,    197,   809,   57,    805,   57,    197,   \n    809,   57,    805,   57,    197,   809,   57,    805,   57,    197,   \n    809,   57,    805,   57,    197,   94,    1613,  135,   871,   71,    \n    39,    39,    327,   135,   39,    39,    39,    39,    39,    39,    \n    103,   71,    39,    39,    39,    39,    39,    39,    71,    39,    \n    135,   231,   135,   135,   39,    327,   551,   103,   167,   551,   \n    89,    1434,  3226,  506,   474,   506,   506,   367,   1018,  1946,  \n    1402,  954,   1402,  314,   90,    1082,  218,   2266,  666,   1210,  \n    186,   570,   2042,  58,    5850,  154,   2010,  154,   794,   2266,  \n    378,   2266,  3738,  39,    39,    39,    39,    39,    39,    17351, \n    34,    3074,  7692,  63,    63,    \n  };\n\nstatic int sqlite3Fts5UnicodeCategory(u32 iCode) { \n  int iRes = -1;\n  int iHi;\n  int iLo;\n  int ret;\n  u16 iKey;\n\n  if( iCode>=(1<<20) ){\n    return 0;\n  }\n  iLo = aFts5UnicodeBlock[(iCode>>16)];\n  iHi = aFts5UnicodeBlock[1+(iCode>>16)];\n  iKey = (iCode & 0xFFFF);\n  while( iHi>iLo ){\n    int iTest = (iHi + iLo) / 2;\n    assert( iTest>=iLo && iTest<iHi );\n    if( iKey>=aFts5UnicodeMap[iTest] ){\n      iRes = iTest;\n      iLo = iTest+1;\n    }else{\n      iHi = iTest;\n    }\n  }\n\n  if( iRes<0 ) return 0;\n  if( iKey>=(aFts5UnicodeMap[iRes]+(aFts5UnicodeData[iRes]>>5)) ) return 0;\n  ret = aFts5UnicodeData[iRes] & 0x1F;\n  if( ret!=30 ) return ret;\n  return ((iKey - aFts5UnicodeMap[iRes]) & 0x01) ? 5 : 9;\n}\n\nstatic void sqlite3Fts5UnicodeAscii(u8 *aArray, u8 *aAscii){\n  int i = 0;\n  int iTbl = 0;\n  while( i<128 ){\n    int bToken = aArray[ aFts5UnicodeData[iTbl] & 0x1F ];\n    int n = (aFts5UnicodeData[iTbl] >> 5) + i;\n    for(; i<128 && i<n; i++){\n      aAscii[i] = bToken;\n    }\n    iTbl++;\n  }\n}\n\n/*\n** 2015 May 30\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n******************************************************************************\n**\n** Routines for varint serialization and deserialization.\n*/\n\n\n/* #include \"fts5Int.h\" */\n\n/*\n** This is a copy of the sqlite3GetVarint32() routine from the SQLite core.\n** Except, this version does handle the single byte case that the core\n** version depends on being handled before its function is called.\n*/\nstatic int sqlite3Fts5GetVarint32(const unsigned char *p, u32 *v){\n  u32 a,b;\n\n  /* The 1-byte case. Overwhelmingly the most common. */\n  a = *p;\n  /* a: p0 (unmasked) */\n  if (!(a&0x80))\n  {\n    /* Values between 0 and 127 */\n    *v = a;\n    return 1;\n  }\n\n  /* The 2-byte case */\n  p++;\n  b = *p;\n  /* b: p1 (unmasked) */\n  if (!(b&0x80))\n  {\n    /* Values between 128 and 16383 */\n    a &= 0x7f;\n    a = a<<7;\n    *v = a | b;\n    return 2;\n  }\n\n  /* The 3-byte case */\n  p++;\n  a = a<<14;\n  a |= *p;\n  /* a: p0<<14 | p2 (unmasked) */\n  if (!(a&0x80))\n  {\n    /* Values between 16384 and 2097151 */\n    a &= (0x7f<<14)|(0x7f);\n    b &= 0x7f;\n    b = b<<7;\n    *v = a | b;\n    return 3;\n  }\n\n  /* A 32-bit varint is used to store size information in btrees.\n  ** Objects are rarely larger than 2MiB limit of a 3-byte varint.\n  ** A 3-byte varint is sufficient, for example, to record the size\n  ** of a 1048569-byte BLOB or string.\n  **\n  ** We only unroll the first 1-, 2-, and 3- byte cases.  The very\n  ** rare larger cases can be handled by the slower 64-bit varint\n  ** routine.\n  */\n  {\n    u64 v64;\n    u8 n;\n    p -= 2;\n    n = sqlite3Fts5GetVarint(p, &v64);\n    *v = ((u32)v64) & 0x7FFFFFFF;\n    assert( n>3 && n<=9 );\n    return n;\n  }\n}\n\n\n/*\n** Bitmasks used by sqlite3GetVarint().  These precomputed constants\n** are defined here rather than simply putting the constant expressions\n** inline in order to work around bugs in the RVT compiler.\n**\n** SLOT_2_0     A mask for  (0x7f<<14) | 0x7f\n**\n** SLOT_4_2_0   A mask for  (0x7f<<28) | SLOT_2_0\n*/\n#define SLOT_2_0     0x001fc07f\n#define SLOT_4_2_0   0xf01fc07f\n\n/*\n** Read a 64-bit variable-length integer from memory starting at p[0].\n** Return the number of bytes read.  The value is stored in *v.\n*/\nstatic u8 sqlite3Fts5GetVarint(const unsigned char *p, u64 *v){\n  u32 a,b,s;\n\n  a = *p;\n  /* a: p0 (unmasked) */\n  if (!(a&0x80))\n  {\n    *v = a;\n    return 1;\n  }\n\n  p++;\n  b = *p;\n  /* b: p1 (unmasked) */\n  if (!(b&0x80))\n  {\n    a &= 0x7f;\n    a = a<<7;\n    a |= b;\n    *v = a;\n    return 2;\n  }\n\n  /* Verify that constants are precomputed correctly */\n  assert( SLOT_2_0 == ((0x7f<<14) | (0x7f)) );\n  assert( SLOT_4_2_0 == ((0xfU<<28) | (0x7f<<14) | (0x7f)) );\n\n  p++;\n  a = a<<14;\n  a |= *p;\n  /* a: p0<<14 | p2 (unmasked) */\n  if (!(a&0x80))\n  {\n    a &= SLOT_2_0;\n    b &= 0x7f;\n    b = b<<7;\n    a |= b;\n    *v = a;\n    return 3;\n  }\n\n  /* CSE1 from below */\n  a &= SLOT_2_0;\n  p++;\n  b = b<<14;\n  b |= *p;\n  /* b: p1<<14 | p3 (unmasked) */\n  if (!(b&0x80))\n  {\n    b &= SLOT_2_0;\n    /* moved CSE1 up */\n    /* a &= (0x7f<<14)|(0x7f); */\n    a = a<<7;\n    a |= b;\n    *v = a;\n    return 4;\n  }\n\n  /* a: p0<<14 | p2 (masked) */\n  /* b: p1<<14 | p3 (unmasked) */\n  /* 1:save off p0<<21 | p1<<14 | p2<<7 | p3 (masked) */\n  /* moved CSE1 up */\n  /* a &= (0x7f<<14)|(0x7f); */\n  b &= SLOT_2_0;\n  s = a;\n  /* s: p0<<14 | p2 (masked) */\n\n  p++;\n  a = a<<14;\n  a |= *p;\n  /* a: p0<<28 | p2<<14 | p4 (unmasked) */\n  if (!(a&0x80))\n  {\n    /* we can skip these cause they were (effectively) done above in calc'ing s */\n    /* a &= (0x7f<<28)|(0x7f<<14)|(0x7f); */\n    /* b &= (0x7f<<14)|(0x7f); */\n    b = b<<7;\n    a |= b;\n    s = s>>18;\n    *v = ((u64)s)<<32 | a;\n    return 5;\n  }\n\n  /* 2:save off p0<<21 | p1<<14 | p2<<7 | p3 (masked) */\n  s = s<<7;\n  s |= b;\n  /* s: p0<<21 | p1<<14 | p2<<7 | p3 (masked) */\n\n  p++;\n  b = b<<14;\n  b |= *p;\n  /* b: p1<<28 | p3<<14 | p5 (unmasked) */\n  if (!(b&0x80))\n  {\n    /* we can skip this cause it was (effectively) done above in calc'ing s */\n    /* b &= (0x7f<<28)|(0x7f<<14)|(0x7f); */\n    a &= SLOT_2_0;\n    a = a<<7;\n    a |= b;\n    s = s>>18;\n    *v = ((u64)s)<<32 | a;\n    return 6;\n  }\n\n  p++;\n  a = a<<14;\n  a |= *p;\n  /* a: p2<<28 | p4<<14 | p6 (unmasked) */\n  if (!(a&0x80))\n  {\n    a &= SLOT_4_2_0;\n    b &= SLOT_2_0;\n    b = b<<7;\n    a |= b;\n    s = s>>11;\n    *v = ((u64)s)<<32 | a;\n    return 7;\n  }\n\n  /* CSE2 from below */\n  a &= SLOT_2_0;\n  p++;\n  b = b<<14;\n  b |= *p;\n  /* b: p3<<28 | p5<<14 | p7 (unmasked) */\n  if (!(b&0x80))\n  {\n    b &= SLOT_4_2_0;\n    /* moved CSE2 up */\n    /* a &= (0x7f<<14)|(0x7f); */\n    a = a<<7;\n    a |= b;\n    s = s>>4;\n    *v = ((u64)s)<<32 | a;\n    return 8;\n  }\n\n  p++;\n  a = a<<15;\n  a |= *p;\n  /* a: p4<<29 | p6<<15 | p8 (unmasked) */\n\n  /* moved CSE2 up */\n  /* a &= (0x7f<<29)|(0x7f<<15)|(0xff); */\n  b &= SLOT_2_0;\n  b = b<<8;\n  a |= b;\n\n  s = s<<4;\n  b = p[-4];\n  b &= 0x7f;\n  b = b>>3;\n  s |= b;\n\n  *v = ((u64)s)<<32 | a;\n\n  return 9;\n}\n\n/*\n** The variable-length integer encoding is as follows:\n**\n** KEY:\n**         A = 0xxxxxxx    7 bits of data and one flag bit\n**         B = 1xxxxxxx    7 bits of data and one flag bit\n**         C = xxxxxxxx    8 bits of data\n**\n**  7 bits - A\n** 14 bits - BA\n** 21 bits - BBA\n** 28 bits - BBBA\n** 35 bits - BBBBA\n** 42 bits - BBBBBA\n** 49 bits - BBBBBBA\n** 56 bits - BBBBBBBA\n** 64 bits - BBBBBBBBC\n*/\n\n#ifdef SQLITE_NOINLINE\n# define FTS5_NOINLINE SQLITE_NOINLINE\n#else\n# define FTS5_NOINLINE\n#endif\n\n/*\n** Write a 64-bit variable-length integer to memory starting at p[0].\n** The length of data write will be between 1 and 9 bytes.  The number\n** of bytes written is returned.\n**\n** A variable-length integer consists of the lower 7 bits of each byte\n** for all bytes that have the 8th bit set and one byte with the 8th\n** bit clear.  Except, if we get to the 9th byte, it stores the full\n** 8 bits and is the last byte.\n*/\nstatic int FTS5_NOINLINE fts5PutVarint64(unsigned char *p, u64 v){\n  int i, j, n;\n  u8 buf[10];\n  if( v & (((u64)0xff000000)<<32) ){\n    p[8] = (u8)v;\n    v >>= 8;\n    for(i=7; i>=0; i--){\n      p[i] = (u8)((v & 0x7f) | 0x80);\n      v >>= 7;\n    }\n    return 9;\n  }    \n  n = 0;\n  do{\n    buf[n++] = (u8)((v & 0x7f) | 0x80);\n    v >>= 7;\n  }while( v!=0 );\n  buf[0] &= 0x7f;\n  assert( n<=9 );\n  for(i=0, j=n-1; j>=0; j--, i++){\n    p[i] = buf[j];\n  }\n  return n;\n}\n\nstatic int sqlite3Fts5PutVarint(unsigned char *p, u64 v){\n  if( v<=0x7f ){\n    p[0] = v&0x7f;\n    return 1;\n  }\n  if( v<=0x3fff ){\n    p[0] = ((v>>7)&0x7f)|0x80;\n    p[1] = v&0x7f;\n    return 2;\n  }\n  return fts5PutVarint64(p,v);\n}\n\n\nstatic int sqlite3Fts5GetVarintLen(u32 iVal){\n#if 0\n  if( iVal<(1 << 7 ) ) return 1;\n#endif\n  assert( iVal>=(1 << 7) );\n  if( iVal<(1 << 14) ) return 2;\n  if( iVal<(1 << 21) ) return 3;\n  if( iVal<(1 << 28) ) return 4;\n  return 5;\n}\n\n/*\n** 2015 May 08\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n******************************************************************************\n**\n** This is an SQLite virtual table module implementing direct access to an\n** existing FTS5 index. The module may create several different types of \n** tables:\n**\n** col:\n**     CREATE TABLE vocab(term, col, doc, cnt, PRIMARY KEY(term, col));\n**\n**   One row for each term/column combination. The value of $doc is set to\n**   the number of fts5 rows that contain at least one instance of term\n**   $term within column $col. Field $cnt is set to the total number of \n**   instances of term $term in column $col (in any row of the fts5 table). \n**\n** row:\n**     CREATE TABLE vocab(term, doc, cnt, PRIMARY KEY(term));\n**\n**   One row for each term in the database. The value of $doc is set to\n**   the number of fts5 rows that contain at least one instance of term\n**   $term. Field $cnt is set to the total number of instances of term \n**   $term in the database.\n**\n** instance:\n**     CREATE TABLE vocab(term, doc, col, offset, PRIMARY KEY(<all-fields>));\n**\n**   One row for each term instance in the database. \n*/\n\n\n/* #include \"fts5Int.h\" */\n\n\ntypedef struct Fts5VocabTable Fts5VocabTable;\ntypedef struct Fts5VocabCursor Fts5VocabCursor;\n\nstruct Fts5VocabTable {\n  sqlite3_vtab base;\n  char *zFts5Tbl;                 /* Name of fts5 table */\n  char *zFts5Db;                  /* Db containing fts5 table */\n  sqlite3 *db;                    /* Database handle */\n  Fts5Global *pGlobal;            /* FTS5 global object for this database */\n  int eType;                      /* FTS5_VOCAB_COL, ROW or INSTANCE */\n};\n\nstruct Fts5VocabCursor {\n  sqlite3_vtab_cursor base;\n  sqlite3_stmt *pStmt;            /* Statement holding lock on pIndex */\n  Fts5Table *pFts5;               /* Associated FTS5 table */\n\n  int bEof;                       /* True if this cursor is at EOF */\n  Fts5IndexIter *pIter;           /* Term/rowid iterator object */\n\n  int nLeTerm;                    /* Size of zLeTerm in bytes */\n  char *zLeTerm;                  /* (term <= $zLeTerm) paramater, or NULL */\n\n  /* These are used by 'col' tables only */\n  int iCol;\n  i64 *aCnt;\n  i64 *aDoc;\n\n  /* Output values used by all tables. */\n  i64 rowid;                      /* This table's current rowid value */\n  Fts5Buffer term;                /* Current value of 'term' column */\n\n  /* Output values Used by 'instance' tables only */\n  i64 iInstPos;\n  int iInstOff;\n};\n\n#define FTS5_VOCAB_COL      0\n#define FTS5_VOCAB_ROW      1\n#define FTS5_VOCAB_INSTANCE 2\n\n#define FTS5_VOCAB_COL_SCHEMA  \"term, col, doc, cnt\"\n#define FTS5_VOCAB_ROW_SCHEMA  \"term, doc, cnt\"\n#define FTS5_VOCAB_INST_SCHEMA \"term, doc, col, offset\"\n\n/*\n** Bits for the mask used as the idxNum value by xBestIndex/xFilter.\n*/\n#define FTS5_VOCAB_TERM_EQ 0x01\n#define FTS5_VOCAB_TERM_GE 0x02\n#define FTS5_VOCAB_TERM_LE 0x04\n\n\n/*\n** Translate a string containing an fts5vocab table type to an \n** FTS5_VOCAB_XXX constant. If successful, set *peType to the output\n** value and return SQLITE_OK. Otherwise, set *pzErr to an error message\n** and return SQLITE_ERROR.\n*/\nstatic int fts5VocabTableType(const char *zType, char **pzErr, int *peType){\n  int rc = SQLITE_OK;\n  char *zCopy = sqlite3Fts5Strndup(&rc, zType, -1);\n  if( rc==SQLITE_OK ){\n    sqlite3Fts5Dequote(zCopy);\n    if( sqlite3_stricmp(zCopy, \"col\")==0 ){\n      *peType = FTS5_VOCAB_COL;\n    }else\n\n    if( sqlite3_stricmp(zCopy, \"row\")==0 ){\n      *peType = FTS5_VOCAB_ROW;\n    }else\n    if( sqlite3_stricmp(zCopy, \"instance\")==0 ){\n      *peType = FTS5_VOCAB_INSTANCE;\n    }else\n    {\n      *pzErr = sqlite3_mprintf(\"fts5vocab: unknown table type: %Q\", zCopy);\n      rc = SQLITE_ERROR;\n    }\n    sqlite3_free(zCopy);\n  }\n\n  return rc;\n}\n\n\n/*\n** The xDisconnect() virtual table method.\n*/\nstatic int fts5VocabDisconnectMethod(sqlite3_vtab *pVtab){\n  Fts5VocabTable *pTab = (Fts5VocabTable*)pVtab;\n  sqlite3_free(pTab);\n  return SQLITE_OK;\n}\n\n/*\n** The xDestroy() virtual table method.\n*/\nstatic int fts5VocabDestroyMethod(sqlite3_vtab *pVtab){\n  Fts5VocabTable *pTab = (Fts5VocabTable*)pVtab;\n  sqlite3_free(pTab);\n  return SQLITE_OK;\n}\n\n/*\n** This function is the implementation of both the xConnect and xCreate\n** methods of the FTS3 virtual table.\n**\n** The argv[] array contains the following:\n**\n**   argv[0]   -> module name  (\"fts5vocab\")\n**   argv[1]   -> database name\n**   argv[2]   -> table name\n**\n** then:\n**\n**   argv[3]   -> name of fts5 table\n**   argv[4]   -> type of fts5vocab table\n**\n** or, for tables in the TEMP schema only.\n**\n**   argv[3]   -> name of fts5 tables database\n**   argv[4]   -> name of fts5 table\n**   argv[5]   -> type of fts5vocab table\n*/\nstatic int fts5VocabInitVtab(\n  sqlite3 *db,                    /* The SQLite database connection */\n  void *pAux,                     /* Pointer to Fts5Global object */\n  int argc,                       /* Number of elements in argv array */\n  const char * const *argv,       /* xCreate/xConnect argument array */\n  sqlite3_vtab **ppVTab,          /* Write the resulting vtab structure here */\n  char **pzErr                    /* Write any error message here */\n){\n  const char *azSchema[] = { \n    \"CREATE TABlE vocab(\" FTS5_VOCAB_COL_SCHEMA  \")\", \n    \"CREATE TABlE vocab(\" FTS5_VOCAB_ROW_SCHEMA  \")\",\n    \"CREATE TABlE vocab(\" FTS5_VOCAB_INST_SCHEMA \")\"\n  };\n\n  Fts5VocabTable *pRet = 0;\n  int rc = SQLITE_OK;             /* Return code */\n  int bDb;\n\n  bDb = (argc==6 && strlen(argv[1])==4 && memcmp(\"temp\", argv[1], 4)==0);\n\n  if( argc!=5 && bDb==0 ){\n    *pzErr = sqlite3_mprintf(\"wrong number of vtable arguments\");\n    rc = SQLITE_ERROR;\n  }else{\n    int nByte;                      /* Bytes of space to allocate */\n    const char *zDb = bDb ? argv[3] : argv[1];\n    const char *zTab = bDb ? argv[4] : argv[3];\n    const char *zType = bDb ? argv[5] : argv[4];\n    int nDb = (int)strlen(zDb)+1; \n    int nTab = (int)strlen(zTab)+1;\n    int eType = 0;\n    \n    rc = fts5VocabTableType(zType, pzErr, &eType);\n    if( rc==SQLITE_OK ){\n      assert( eType>=0 && eType<ArraySize(azSchema) );\n      rc = sqlite3_declare_vtab(db, azSchema[eType]);\n    }\n\n    nByte = sizeof(Fts5VocabTable) + nDb + nTab;\n    pRet = sqlite3Fts5MallocZero(&rc, nByte);\n    if( pRet ){\n      pRet->pGlobal = (Fts5Global*)pAux;\n      pRet->eType = eType;\n      pRet->db = db;\n      pRet->zFts5Tbl = (char*)&pRet[1];\n      pRet->zFts5Db = &pRet->zFts5Tbl[nTab];\n      memcpy(pRet->zFts5Tbl, zTab, nTab);\n      memcpy(pRet->zFts5Db, zDb, nDb);\n      sqlite3Fts5Dequote(pRet->zFts5Tbl);\n      sqlite3Fts5Dequote(pRet->zFts5Db);\n    }\n  }\n\n  *ppVTab = (sqlite3_vtab*)pRet;\n  return rc;\n}\n\n\n/*\n** The xConnect() and xCreate() methods for the virtual table. All the\n** work is done in function fts5VocabInitVtab().\n*/\nstatic int fts5VocabConnectMethod(\n  sqlite3 *db,                    /* Database connection */\n  void *pAux,                     /* Pointer to tokenizer hash table */\n  int argc,                       /* Number of elements in argv array */\n  const char * const *argv,       /* xCreate/xConnect argument array */\n  sqlite3_vtab **ppVtab,          /* OUT: New sqlite3_vtab object */\n  char **pzErr                    /* OUT: sqlite3_malloc'd error message */\n){\n  return fts5VocabInitVtab(db, pAux, argc, argv, ppVtab, pzErr);\n}\nstatic int fts5VocabCreateMethod(\n  sqlite3 *db,                    /* Database connection */\n  void *pAux,                     /* Pointer to tokenizer hash table */\n  int argc,                       /* Number of elements in argv array */\n  const char * const *argv,       /* xCreate/xConnect argument array */\n  sqlite3_vtab **ppVtab,          /* OUT: New sqlite3_vtab object */\n  char **pzErr                    /* OUT: sqlite3_malloc'd error message */\n){\n  return fts5VocabInitVtab(db, pAux, argc, argv, ppVtab, pzErr);\n}\n\n/* \n** Implementation of the xBestIndex method.\n**\n** Only constraints of the form:\n**\n**     term <= ?\n**     term == ?\n**     term >= ?\n**\n** are interpreted. Less-than and less-than-or-equal are treated \n** identically, as are greater-than and greater-than-or-equal.\n*/\nstatic int fts5VocabBestIndexMethod(\n  sqlite3_vtab *pUnused,\n  sqlite3_index_info *pInfo\n){\n  int i;\n  int iTermEq = -1;\n  int iTermGe = -1;\n  int iTermLe = -1;\n  int idxNum = 0;\n  int nArg = 0;\n\n  UNUSED_PARAM(pUnused);\n\n  for(i=0; i<pInfo->nConstraint; i++){\n    struct sqlite3_index_constraint *p = &pInfo->aConstraint[i];\n    if( p->usable==0 ) continue;\n    if( p->iColumn==0 ){          /* term column */\n      if( p->op==SQLITE_INDEX_CONSTRAINT_EQ ) iTermEq = i;\n      if( p->op==SQLITE_INDEX_CONSTRAINT_LE ) iTermLe = i;\n      if( p->op==SQLITE_INDEX_CONSTRAINT_LT ) iTermLe = i;\n      if( p->op==SQLITE_INDEX_CONSTRAINT_GE ) iTermGe = i;\n      if( p->op==SQLITE_INDEX_CONSTRAINT_GT ) iTermGe = i;\n    }\n  }\n\n  if( iTermEq>=0 ){\n    idxNum |= FTS5_VOCAB_TERM_EQ;\n    pInfo->aConstraintUsage[iTermEq].argvIndex = ++nArg;\n    pInfo->estimatedCost = 100;\n  }else{\n    pInfo->estimatedCost = 1000000;\n    if( iTermGe>=0 ){\n      idxNum |= FTS5_VOCAB_TERM_GE;\n      pInfo->aConstraintUsage[iTermGe].argvIndex = ++nArg;\n      pInfo->estimatedCost = pInfo->estimatedCost / 2;\n    }\n    if( iTermLe>=0 ){\n      idxNum |= FTS5_VOCAB_TERM_LE;\n      pInfo->aConstraintUsage[iTermLe].argvIndex = ++nArg;\n      pInfo->estimatedCost = pInfo->estimatedCost / 2;\n    }\n  }\n\n  /* This virtual table always delivers results in ascending order of\n  ** the \"term\" column (column 0). So if the user has requested this\n  ** specifically - \"ORDER BY term\" or \"ORDER BY term ASC\" - set the\n  ** sqlite3_index_info.orderByConsumed flag to tell the core the results\n  ** are already in sorted order.  */\n  if( pInfo->nOrderBy==1 \n   && pInfo->aOrderBy[0].iColumn==0 \n   && pInfo->aOrderBy[0].desc==0\n  ){\n    pInfo->orderByConsumed = 1;\n  }\n\n  pInfo->idxNum = idxNum;\n  return SQLITE_OK;\n}\n\n/*\n** Implementation of xOpen method.\n*/\nstatic int fts5VocabOpenMethod(\n  sqlite3_vtab *pVTab, \n  sqlite3_vtab_cursor **ppCsr\n){\n  Fts5VocabTable *pTab = (Fts5VocabTable*)pVTab;\n  Fts5Table *pFts5 = 0;\n  Fts5VocabCursor *pCsr = 0;\n  int rc = SQLITE_OK;\n  sqlite3_stmt *pStmt = 0;\n  char *zSql = 0;\n\n  zSql = sqlite3Fts5Mprintf(&rc,\n      \"SELECT t.%Q FROM %Q.%Q AS t WHERE t.%Q MATCH '*id'\",\n      pTab->zFts5Tbl, pTab->zFts5Db, pTab->zFts5Tbl, pTab->zFts5Tbl\n  );\n  if( zSql ){\n    rc = sqlite3_prepare_v2(pTab->db, zSql, -1, &pStmt, 0);\n  }\n  sqlite3_free(zSql);\n  assert( rc==SQLITE_OK || pStmt==0 );\n  if( rc==SQLITE_ERROR ) rc = SQLITE_OK;\n\n  if( pStmt && sqlite3_step(pStmt)==SQLITE_ROW ){\n    i64 iId = sqlite3_column_int64(pStmt, 0);\n    pFts5 = sqlite3Fts5TableFromCsrid(pTab->pGlobal, iId);\n  }\n\n  if( rc==SQLITE_OK ){\n    if( pFts5==0 ){\n      rc = sqlite3_finalize(pStmt);\n      pStmt = 0;\n      if( rc==SQLITE_OK ){\n        pVTab->zErrMsg = sqlite3_mprintf(\n            \"no such fts5 table: %s.%s\", pTab->zFts5Db, pTab->zFts5Tbl\n            );\n        rc = SQLITE_ERROR;\n      }\n    }else{\n      rc = sqlite3Fts5FlushToDisk(pFts5);\n    }\n  }\n\n  if( rc==SQLITE_OK ){\n    int nByte = pFts5->pConfig->nCol * sizeof(i64)*2 + sizeof(Fts5VocabCursor);\n    pCsr = (Fts5VocabCursor*)sqlite3Fts5MallocZero(&rc, nByte);\n  }\n\n  if( pCsr ){\n    pCsr->pFts5 = pFts5;\n    pCsr->pStmt = pStmt;\n    pCsr->aCnt = (i64*)&pCsr[1];\n    pCsr->aDoc = &pCsr->aCnt[pFts5->pConfig->nCol];\n  }else{\n    sqlite3_finalize(pStmt);\n  }\n\n  *ppCsr = (sqlite3_vtab_cursor*)pCsr;\n  return rc;\n}\n\nstatic void fts5VocabResetCursor(Fts5VocabCursor *pCsr){\n  pCsr->rowid = 0;\n  sqlite3Fts5IterClose(pCsr->pIter);\n  pCsr->pIter = 0;\n  sqlite3_free(pCsr->zLeTerm);\n  pCsr->nLeTerm = -1;\n  pCsr->zLeTerm = 0;\n  pCsr->bEof = 0;\n}\n\n/*\n** Close the cursor.  For additional information see the documentation\n** on the xClose method of the virtual table interface.\n*/\nstatic int fts5VocabCloseMethod(sqlite3_vtab_cursor *pCursor){\n  Fts5VocabCursor *pCsr = (Fts5VocabCursor*)pCursor;\n  fts5VocabResetCursor(pCsr);\n  sqlite3Fts5BufferFree(&pCsr->term);\n  sqlite3_finalize(pCsr->pStmt);\n  sqlite3_free(pCsr);\n  return SQLITE_OK;\n}\n\nstatic int fts5VocabInstanceNewTerm(Fts5VocabCursor *pCsr){\n  int rc = SQLITE_OK;\n  \n  if( sqlite3Fts5IterEof(pCsr->pIter) ){\n    pCsr->bEof = 1;\n  }else{\n    const char *zTerm;\n    int nTerm;\n    zTerm = sqlite3Fts5IterTerm(pCsr->pIter, &nTerm);\n    if( pCsr->nLeTerm>=0 ){\n      int nCmp = MIN(nTerm, pCsr->nLeTerm);\n      int bCmp = memcmp(pCsr->zLeTerm, zTerm, nCmp);\n      if( bCmp<0 || (bCmp==0 && pCsr->nLeTerm<nTerm) ){\n        pCsr->bEof = 1;\n      }\n    }\n\n    sqlite3Fts5BufferSet(&rc, &pCsr->term, nTerm, (const u8*)zTerm);\n  }\n  return rc;\n}\n\nstatic int fts5VocabInstanceNext(Fts5VocabCursor *pCsr){\n  int eDetail = pCsr->pFts5->pConfig->eDetail;\n  int rc = SQLITE_OK;\n  Fts5IndexIter *pIter = pCsr->pIter;\n  i64 *pp = &pCsr->iInstPos;\n  int *po = &pCsr->iInstOff;\n  \n  assert( sqlite3Fts5IterEof(pIter)==0 );\n  assert( pCsr->bEof==0 );\n  while( eDetail==FTS5_DETAIL_NONE\n      || sqlite3Fts5PoslistNext64(pIter->pData, pIter->nData, po, pp) \n  ){\n    pCsr->iInstPos = 0;\n    pCsr->iInstOff = 0;\n\n    rc = sqlite3Fts5IterNextScan(pCsr->pIter);\n    if( rc==SQLITE_OK ){\n      rc = fts5VocabInstanceNewTerm(pCsr);\n      if( pCsr->bEof || eDetail==FTS5_DETAIL_NONE ) break;\n    }\n    if( rc ){\n      pCsr->bEof = 1;\n      break;\n    }\n  }\n\n  return rc;\n}\n\n/*\n** Advance the cursor to the next row in the table.\n*/\nstatic int fts5VocabNextMethod(sqlite3_vtab_cursor *pCursor){\n  Fts5VocabCursor *pCsr = (Fts5VocabCursor*)pCursor;\n  Fts5VocabTable *pTab = (Fts5VocabTable*)pCursor->pVtab;\n  int rc = SQLITE_OK;\n  int nCol = pCsr->pFts5->pConfig->nCol;\n\n  pCsr->rowid++;\n\n  if( pTab->eType==FTS5_VOCAB_INSTANCE ){\n    return fts5VocabInstanceNext(pCsr);\n  }\n\n  if( pTab->eType==FTS5_VOCAB_COL ){\n    for(pCsr->iCol++; pCsr->iCol<nCol; pCsr->iCol++){\n      if( pCsr->aDoc[pCsr->iCol] ) break;\n    }\n  }\n\n  if( pTab->eType!=FTS5_VOCAB_COL || pCsr->iCol>=nCol ){\n    if( sqlite3Fts5IterEof(pCsr->pIter) ){\n      pCsr->bEof = 1;\n    }else{\n      const char *zTerm;\n      int nTerm;\n\n      zTerm = sqlite3Fts5IterTerm(pCsr->pIter, &nTerm);\n      assert( nTerm>=0 );\n      if( pCsr->nLeTerm>=0 ){\n        int nCmp = MIN(nTerm, pCsr->nLeTerm);\n        int bCmp = memcmp(pCsr->zLeTerm, zTerm, nCmp);\n        if( bCmp<0 || (bCmp==0 && pCsr->nLeTerm<nTerm) ){\n          pCsr->bEof = 1;\n          return SQLITE_OK;\n        }\n      }\n\n      sqlite3Fts5BufferSet(&rc, &pCsr->term, nTerm, (const u8*)zTerm);\n      memset(pCsr->aCnt, 0, nCol * sizeof(i64));\n      memset(pCsr->aDoc, 0, nCol * sizeof(i64));\n      pCsr->iCol = 0;\n\n      assert( pTab->eType==FTS5_VOCAB_COL || pTab->eType==FTS5_VOCAB_ROW );\n      while( rc==SQLITE_OK ){\n        int eDetail = pCsr->pFts5->pConfig->eDetail;\n        const u8 *pPos; int nPos;   /* Position list */\n        i64 iPos = 0;               /* 64-bit position read from poslist */\n        int iOff = 0;               /* Current offset within position list */\n\n        pPos = pCsr->pIter->pData;\n        nPos = pCsr->pIter->nData;\n\n        switch( pTab->eType ){\n          case FTS5_VOCAB_ROW:\n            if( eDetail==FTS5_DETAIL_FULL ){\n              while( 0==sqlite3Fts5PoslistNext64(pPos, nPos, &iOff, &iPos) ){\n                pCsr->aCnt[0]++;\n              }\n            }\n            pCsr->aDoc[0]++;\n            break;\n\n          case FTS5_VOCAB_COL:\n            if( eDetail==FTS5_DETAIL_FULL ){\n              int iCol = -1;\n              while( 0==sqlite3Fts5PoslistNext64(pPos, nPos, &iOff, &iPos) ){\n                int ii = FTS5_POS2COLUMN(iPos);\n                if( iCol!=ii ){\n                  if( ii>=nCol ){\n                    rc = FTS5_CORRUPT;\n                    break;\n                  }\n                  pCsr->aDoc[ii]++;\n                  iCol = ii;\n                }\n                pCsr->aCnt[ii]++;\n              }\n            }else if( eDetail==FTS5_DETAIL_COLUMNS ){\n              while( 0==sqlite3Fts5PoslistNext64(pPos, nPos, &iOff,&iPos) ){\n                assert_nc( iPos>=0 && iPos<nCol );\n                if( iPos>=nCol ){\n                  rc = FTS5_CORRUPT;\n                  break;\n                }\n                pCsr->aDoc[iPos]++;\n              }\n            }else{\n              assert( eDetail==FTS5_DETAIL_NONE );\n              pCsr->aDoc[0]++;\n            }\n            break;\n\n          default:\n            assert( pTab->eType==FTS5_VOCAB_INSTANCE );\n            break;\n        }\n\n        if( rc==SQLITE_OK ){\n          rc = sqlite3Fts5IterNextScan(pCsr->pIter);\n        }\n        if( pTab->eType==FTS5_VOCAB_INSTANCE ) break;\n\n        if( rc==SQLITE_OK ){\n          zTerm = sqlite3Fts5IterTerm(pCsr->pIter, &nTerm);\n          if( nTerm!=pCsr->term.n \n          || (nTerm>0 && memcmp(zTerm, pCsr->term.p, nTerm)) \n          ){\n            break;\n          }\n          if( sqlite3Fts5IterEof(pCsr->pIter) ) break;\n        }\n      }\n    }\n  }\n\n  if( rc==SQLITE_OK && pCsr->bEof==0 && pTab->eType==FTS5_VOCAB_COL ){\n    while( pCsr->aDoc[pCsr->iCol]==0 ) pCsr->iCol++;\n    assert( pCsr->iCol<pCsr->pFts5->pConfig->nCol );\n  }\n  return rc;\n}\n\n/*\n** This is the xFilter implementation for the virtual table.\n*/\nstatic int fts5VocabFilterMethod(\n  sqlite3_vtab_cursor *pCursor,   /* The cursor used for this query */\n  int idxNum,                     /* Strategy index */\n  const char *zUnused,            /* Unused */\n  int nUnused,                    /* Number of elements in apVal */\n  sqlite3_value **apVal           /* Arguments for the indexing scheme */\n){\n  Fts5VocabTable *pTab = (Fts5VocabTable*)pCursor->pVtab;\n  Fts5VocabCursor *pCsr = (Fts5VocabCursor*)pCursor;\n  int eType = pTab->eType;\n  int rc = SQLITE_OK;\n\n  int iVal = 0;\n  int f = FTS5INDEX_QUERY_SCAN;\n  const char *zTerm = 0;\n  int nTerm = 0;\n\n  sqlite3_value *pEq = 0;\n  sqlite3_value *pGe = 0;\n  sqlite3_value *pLe = 0;\n\n  UNUSED_PARAM2(zUnused, nUnused);\n\n  fts5VocabResetCursor(pCsr);\n  if( idxNum & FTS5_VOCAB_TERM_EQ ) pEq = apVal[iVal++];\n  if( idxNum & FTS5_VOCAB_TERM_GE ) pGe = apVal[iVal++];\n  if( idxNum & FTS5_VOCAB_TERM_LE ) pLe = apVal[iVal++];\n\n  if( pEq ){\n    zTerm = (const char *)sqlite3_value_text(pEq);\n    nTerm = sqlite3_value_bytes(pEq);\n    f = 0;\n  }else{\n    if( pGe ){\n      zTerm = (const char *)sqlite3_value_text(pGe);\n      nTerm = sqlite3_value_bytes(pGe);\n    }\n    if( pLe ){\n      const char *zCopy = (const char *)sqlite3_value_text(pLe);\n      if( zCopy==0 ) zCopy = \"\";\n      pCsr->nLeTerm = sqlite3_value_bytes(pLe);\n      pCsr->zLeTerm = sqlite3_malloc(pCsr->nLeTerm+1);\n      if( pCsr->zLeTerm==0 ){\n        rc = SQLITE_NOMEM;\n      }else{\n        memcpy(pCsr->zLeTerm, zCopy, pCsr->nLeTerm+1);\n      }\n    }\n  }\n\n  if( rc==SQLITE_OK ){\n    Fts5Index *pIndex = pCsr->pFts5->pIndex;\n    rc = sqlite3Fts5IndexQuery(pIndex, zTerm, nTerm, f, 0, &pCsr->pIter);\n  }\n  if( rc==SQLITE_OK && eType==FTS5_VOCAB_INSTANCE ){\n    rc = fts5VocabInstanceNewTerm(pCsr);\n  }\n  if( rc==SQLITE_OK && !pCsr->bEof \n   && (eType!=FTS5_VOCAB_INSTANCE \n    || pCsr->pFts5->pConfig->eDetail!=FTS5_DETAIL_NONE)\n  ){\n    rc = fts5VocabNextMethod(pCursor);\n  }\n\n  return rc;\n}\n\n/* \n** This is the xEof method of the virtual table. SQLite calls this \n** routine to find out if it has reached the end of a result set.\n*/\nstatic int fts5VocabEofMethod(sqlite3_vtab_cursor *pCursor){\n  Fts5VocabCursor *pCsr = (Fts5VocabCursor*)pCursor;\n  return pCsr->bEof;\n}\n\nstatic int fts5VocabColumnMethod(\n  sqlite3_vtab_cursor *pCursor,   /* Cursor to retrieve value from */\n  sqlite3_context *pCtx,          /* Context for sqlite3_result_xxx() calls */\n  int iCol                        /* Index of column to read value from */\n){\n  Fts5VocabCursor *pCsr = (Fts5VocabCursor*)pCursor;\n  int eDetail = pCsr->pFts5->pConfig->eDetail;\n  int eType = ((Fts5VocabTable*)(pCursor->pVtab))->eType;\n  i64 iVal = 0;\n\n  if( iCol==0 ){\n    sqlite3_result_text(\n        pCtx, (const char*)pCsr->term.p, pCsr->term.n, SQLITE_TRANSIENT\n    );\n  }else if( eType==FTS5_VOCAB_COL ){\n    assert( iCol==1 || iCol==2 || iCol==3 );\n    if( iCol==1 ){\n      if( eDetail!=FTS5_DETAIL_NONE ){\n        const char *z = pCsr->pFts5->pConfig->azCol[pCsr->iCol];\n        sqlite3_result_text(pCtx, z, -1, SQLITE_STATIC);\n      }\n    }else if( iCol==2 ){\n      iVal = pCsr->aDoc[pCsr->iCol];\n    }else{\n      iVal = pCsr->aCnt[pCsr->iCol];\n    }\n  }else if( eType==FTS5_VOCAB_ROW ){\n    assert( iCol==1 || iCol==2 );\n    if( iCol==1 ){\n      iVal = pCsr->aDoc[0];\n    }else{\n      iVal = pCsr->aCnt[0];\n    }\n  }else{\n    assert( eType==FTS5_VOCAB_INSTANCE );\n    switch( iCol ){\n      case 1:\n        sqlite3_result_int64(pCtx, pCsr->pIter->iRowid);\n        break;\n      case 2: {\n        int ii = -1;\n        if( eDetail==FTS5_DETAIL_FULL ){\n          ii = FTS5_POS2COLUMN(pCsr->iInstPos);\n        }else if( eDetail==FTS5_DETAIL_COLUMNS ){\n          ii = (int)pCsr->iInstPos;\n        }\n        if( ii>=0 && ii<pCsr->pFts5->pConfig->nCol ){\n          const char *z = pCsr->pFts5->pConfig->azCol[ii];\n          sqlite3_result_text(pCtx, z, -1, SQLITE_STATIC);\n        }\n        break;\n      }\n      default: {\n        assert( iCol==3 );\n        if( eDetail==FTS5_DETAIL_FULL ){\n          int ii = FTS5_POS2OFFSET(pCsr->iInstPos);\n          sqlite3_result_int(pCtx, ii);\n        }\n        break;\n      }\n    }\n  }\n\n  if( iVal>0 ) sqlite3_result_int64(pCtx, iVal);\n  return SQLITE_OK;\n}\n\n/* \n** This is the xRowid method. The SQLite core calls this routine to\n** retrieve the rowid for the current row of the result set. The\n** rowid should be written to *pRowid.\n*/\nstatic int fts5VocabRowidMethod(\n  sqlite3_vtab_cursor *pCursor, \n  sqlite_int64 *pRowid\n){\n  Fts5VocabCursor *pCsr = (Fts5VocabCursor*)pCursor;\n  *pRowid = pCsr->rowid;\n  return SQLITE_OK;\n}\n\nstatic int sqlite3Fts5VocabInit(Fts5Global *pGlobal, sqlite3 *db){\n  static const sqlite3_module fts5Vocab = {\n    /* iVersion      */ 2,\n    /* xCreate       */ fts5VocabCreateMethod,\n    /* xConnect      */ fts5VocabConnectMethod,\n    /* xBestIndex    */ fts5VocabBestIndexMethod,\n    /* xDisconnect   */ fts5VocabDisconnectMethod,\n    /* xDestroy      */ fts5VocabDestroyMethod,\n    /* xOpen         */ fts5VocabOpenMethod,\n    /* xClose        */ fts5VocabCloseMethod,\n    /* xFilter       */ fts5VocabFilterMethod,\n    /* xNext         */ fts5VocabNextMethod,\n    /* xEof          */ fts5VocabEofMethod,\n    /* xColumn       */ fts5VocabColumnMethod,\n    /* xRowid        */ fts5VocabRowidMethod,\n    /* xUpdate       */ 0,\n    /* xBegin        */ 0,\n    /* xSync         */ 0,\n    /* xCommit       */ 0,\n    /* xRollback     */ 0,\n    /* xFindFunction */ 0,\n    /* xRename       */ 0,\n    /* xSavepoint    */ 0,\n    /* xRelease      */ 0,\n    /* xRollbackTo   */ 0,\n    /* xShadowName   */ 0\n  };\n  void *p = (void*)pGlobal;\n\n  return sqlite3_create_module_v2(db, \"fts5vocab\", &fts5Vocab, p, 0);\n}\n\n\n    \n#endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS5) */\n\n/************** End of fts5.c ************************************************/\n/************** Begin file stmt.c ********************************************/\n/*\n** 2017-05-31\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n**\n** This file demonstrates an eponymous virtual table that returns information\n** about all prepared statements for the database connection.\n**\n** Usage example:\n**\n**     .load ./stmt\n**     .mode line\n**     .header on\n**     SELECT * FROM stmt;\n*/\n#if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_STMTVTAB)\n#if !defined(SQLITEINT_H)\n/* #include \"sqlite3ext.h\" */\n#endif\nSQLITE_EXTENSION_INIT1\n/* #include <assert.h> */\n/* #include <string.h> */\n\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n\n/* stmt_vtab is a subclass of sqlite3_vtab which will\n** serve as the underlying representation of a stmt virtual table\n*/\ntypedef struct stmt_vtab stmt_vtab;\nstruct stmt_vtab {\n  sqlite3_vtab base;  /* Base class - must be first */\n  sqlite3 *db;        /* Database connection for this stmt vtab */\n};\n\n/* stmt_cursor is a subclass of sqlite3_vtab_cursor which will\n** serve as the underlying representation of a cursor that scans\n** over rows of the result\n*/\ntypedef struct stmt_cursor stmt_cursor;\nstruct stmt_cursor {\n  sqlite3_vtab_cursor base;  /* Base class - must be first */\n  sqlite3 *db;               /* Database connection for this cursor */\n  sqlite3_stmt *pStmt;       /* Statement cursor is currently pointing at */\n  sqlite3_int64 iRowid;      /* The rowid */\n};\n\n/*\n** The stmtConnect() method is invoked to create a new\n** stmt_vtab that describes the stmt virtual table.\n**\n** Think of this routine as the constructor for stmt_vtab objects.\n**\n** All this routine needs to do is:\n**\n**    (1) Allocate the stmt_vtab object and initialize all fields.\n**\n**    (2) Tell SQLite (via the sqlite3_declare_vtab() interface) what the\n**        result set of queries against stmt will look like.\n*/\nstatic int stmtConnect(\n  sqlite3 *db,\n  void *pAux,\n  int argc, const char *const*argv,\n  sqlite3_vtab **ppVtab,\n  char **pzErr\n){\n  stmt_vtab *pNew;\n  int rc;\n\n/* Column numbers */\n#define STMT_COLUMN_SQL     0   /* SQL for the statement */\n#define STMT_COLUMN_NCOL    1   /* Number of result columns */\n#define STMT_COLUMN_RO      2   /* True if read-only */\n#define STMT_COLUMN_BUSY    3   /* True if currently busy */\n#define STMT_COLUMN_NSCAN   4   /* SQLITE_STMTSTATUS_FULLSCAN_STEP */\n#define STMT_COLUMN_NSORT   5   /* SQLITE_STMTSTATUS_SORT */\n#define STMT_COLUMN_NAIDX   6   /* SQLITE_STMTSTATUS_AUTOINDEX */\n#define STMT_COLUMN_NSTEP   7   /* SQLITE_STMTSTATUS_VM_STEP */\n#define STMT_COLUMN_REPREP  8   /* SQLITE_STMTSTATUS_REPREPARE */\n#define STMT_COLUMN_RUN     9   /* SQLITE_STMTSTATUS_RUN */\n#define STMT_COLUMN_MEM    10   /* SQLITE_STMTSTATUS_MEMUSED */\n\n\n  rc = sqlite3_declare_vtab(db,\n     \"CREATE TABLE x(sql,ncol,ro,busy,nscan,nsort,naidx,nstep,\"\n                    \"reprep,run,mem)\");\n  if( rc==SQLITE_OK ){\n    pNew = sqlite3_malloc( sizeof(*pNew) );\n    *ppVtab = (sqlite3_vtab*)pNew;\n    if( pNew==0 ) return SQLITE_NOMEM;\n    memset(pNew, 0, sizeof(*pNew));\n    pNew->db = db;\n  }\n  return rc;\n}\n\n/*\n** This method is the destructor for stmt_cursor objects.\n*/\nstatic int stmtDisconnect(sqlite3_vtab *pVtab){\n  sqlite3_free(pVtab);\n  return SQLITE_OK;\n}\n\n/*\n** Constructor for a new stmt_cursor object.\n*/\nstatic int stmtOpen(sqlite3_vtab *p, sqlite3_vtab_cursor **ppCursor){\n  stmt_cursor *pCur;\n  pCur = sqlite3_malloc( sizeof(*pCur) );\n  if( pCur==0 ) return SQLITE_NOMEM;\n  memset(pCur, 0, sizeof(*pCur));\n  pCur->db = ((stmt_vtab*)p)->db;\n  *ppCursor = &pCur->base;\n  return SQLITE_OK;\n}\n\n/*\n** Destructor for a stmt_cursor.\n*/\nstatic int stmtClose(sqlite3_vtab_cursor *cur){\n  sqlite3_free(cur);\n  return SQLITE_OK;\n}\n\n\n/*\n** Advance a stmt_cursor to its next row of output.\n*/\nstatic int stmtNext(sqlite3_vtab_cursor *cur){\n  stmt_cursor *pCur = (stmt_cursor*)cur;\n  pCur->iRowid++;\n  pCur->pStmt = sqlite3_next_stmt(pCur->db, pCur->pStmt);\n  return SQLITE_OK;\n}\n\n/*\n** Return values of columns for the row at which the stmt_cursor\n** is currently pointing.\n*/\nstatic int stmtColumn(\n  sqlite3_vtab_cursor *cur,   /* The cursor */\n  sqlite3_context *ctx,       /* First argument to sqlite3_result_...() */\n  int i                       /* Which column to return */\n){\n  stmt_cursor *pCur = (stmt_cursor*)cur;\n  switch( i ){\n    case STMT_COLUMN_SQL: {\n      sqlite3_result_text(ctx, sqlite3_sql(pCur->pStmt), -1, SQLITE_TRANSIENT);\n      break;\n    }\n    case STMT_COLUMN_NCOL: {\n      sqlite3_result_int(ctx, sqlite3_column_count(pCur->pStmt));\n      break;\n    }\n    case STMT_COLUMN_RO: {\n      sqlite3_result_int(ctx, sqlite3_stmt_readonly(pCur->pStmt));\n      break;\n    }\n    case STMT_COLUMN_BUSY: {\n      sqlite3_result_int(ctx, sqlite3_stmt_busy(pCur->pStmt));\n      break;\n    }\n    case STMT_COLUMN_MEM: {\n      i = SQLITE_STMTSTATUS_MEMUSED + \n            STMT_COLUMN_NSCAN - SQLITE_STMTSTATUS_FULLSCAN_STEP;\n      /* Fall thru */\n    }\n    case STMT_COLUMN_NSCAN:\n    case STMT_COLUMN_NSORT:\n    case STMT_COLUMN_NAIDX:\n    case STMT_COLUMN_NSTEP:\n    case STMT_COLUMN_REPREP:\n    case STMT_COLUMN_RUN: {\n      sqlite3_result_int(ctx, sqlite3_stmt_status(pCur->pStmt,\n                      i-STMT_COLUMN_NSCAN+SQLITE_STMTSTATUS_FULLSCAN_STEP, 0));\n      break;\n    }\n  }\n  return SQLITE_OK;\n}\n\n/*\n** Return the rowid for the current row.  In this implementation, the\n** rowid is the same as the output value.\n*/\nstatic int stmtRowid(sqlite3_vtab_cursor *cur, sqlite_int64 *pRowid){\n  stmt_cursor *pCur = (stmt_cursor*)cur;\n  *pRowid = pCur->iRowid;\n  return SQLITE_OK;\n}\n\n/*\n** Return TRUE if the cursor has been moved off of the last\n** row of output.\n*/\nstatic int stmtEof(sqlite3_vtab_cursor *cur){\n  stmt_cursor *pCur = (stmt_cursor*)cur;\n  return pCur->pStmt==0;\n}\n\n/*\n** This method is called to \"rewind\" the stmt_cursor object back\n** to the first row of output.  This method is always called at least\n** once prior to any call to stmtColumn() or stmtRowid() or \n** stmtEof().\n*/\nstatic int stmtFilter(\n  sqlite3_vtab_cursor *pVtabCursor, \n  int idxNum, const char *idxStr,\n  int argc, sqlite3_value **argv\n){\n  stmt_cursor *pCur = (stmt_cursor *)pVtabCursor;\n  pCur->pStmt = 0;\n  pCur->iRowid = 0;\n  return stmtNext(pVtabCursor);\n}\n\n/*\n** SQLite will invoke this method one or more times while planning a query\n** that uses the stmt virtual table.  This routine needs to create\n** a query plan for each invocation and compute an estimated cost for that\n** plan.\n*/\nstatic int stmtBestIndex(\n  sqlite3_vtab *tab,\n  sqlite3_index_info *pIdxInfo\n){\n  pIdxInfo->estimatedCost = (double)500;\n  pIdxInfo->estimatedRows = 500;\n  return SQLITE_OK;\n}\n\n/*\n** This following structure defines all the methods for the \n** stmt virtual table.\n*/\nstatic sqlite3_module stmtModule = {\n  0,                         /* iVersion */\n  0,                         /* xCreate */\n  stmtConnect,               /* xConnect */\n  stmtBestIndex,             /* xBestIndex */\n  stmtDisconnect,            /* xDisconnect */\n  0,                         /* xDestroy */\n  stmtOpen,                  /* xOpen - open a cursor */\n  stmtClose,                 /* xClose - close a cursor */\n  stmtFilter,                /* xFilter - configure scan constraints */\n  stmtNext,                  /* xNext - advance a cursor */\n  stmtEof,                   /* xEof - check for end of scan */\n  stmtColumn,                /* xColumn - read data */\n  stmtRowid,                 /* xRowid - read data */\n  0,                         /* xUpdate */\n  0,                         /* xBegin */\n  0,                         /* xSync */\n  0,                         /* xCommit */\n  0,                         /* xRollback */\n  0,                         /* xFindMethod */\n  0,                         /* xRename */\n  0,                         /* xSavepoint */\n  0,                         /* xRelease */\n  0,                         /* xRollbackTo */\n  0,                         /* xShadowName */\n};\n\n#endif /* SQLITE_OMIT_VIRTUALTABLE */\n\nSQLITE_PRIVATE int sqlite3StmtVtabInit(sqlite3 *db){\n  int rc = SQLITE_OK;\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n  rc = sqlite3_create_module(db, \"sqlite_stmt\", &stmtModule, 0);\n#endif\n  return rc;\n}\n\n#ifndef SQLITE_CORE\n#ifdef _WIN32\n__declspec(dllexport)\n#endif\nSQLITE_API int sqlite3_stmt_init(\n  sqlite3 *db, \n  char **pzErrMsg, \n  const sqlite3_api_routines *pApi\n){\n  int rc = SQLITE_OK;\n  SQLITE_EXTENSION_INIT2(pApi);\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n  rc = sqlite3StmtVtabInit(db);\n#endif\n  return rc;\n}\n#endif /* SQLITE_CORE */\n#endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_STMTVTAB) */\n\n/************** End of stmt.c ************************************************/\n#if __LINE__!=226660\n#undef SQLITE_SOURCE_ID\n#define SQLITE_SOURCE_ID      \"2019-02-25 16:06:06 bd49a8271d650fa89e446b42e513b595a717b9212c91dd384aab871fc1d0alt2\"\n#endif\n/* Return the source-id for this library */\nSQLITE_API const char *sqlite3_sourceid(void){ return SQLITE_SOURCE_ID; }\n/************************** End of sqlite3.c ******************************/\n"
  },
  {
    "path": "deprecated/android/sqlcipher/sqlite3.h",
    "content": "/*\n** 2001-09-15\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This header file defines the interface that the SQLite library\n** presents to client programs.  If a C-function, structure, datatype,\n** or constant definition does not appear in this file, then it is\n** not a published API of SQLite, is subject to change without\n** notice, and should not be referenced by programs that use SQLite.\n**\n** Some of the definitions that are in this file are marked as\n** \"experimental\".  Experimental interfaces are normally new\n** features recently added to SQLite.  We do not anticipate changes\n** to experimental interfaces but reserve the right to make minor changes\n** if experience from use \"in the wild\" suggest such changes are prudent.\n**\n** The official C-language API documentation for SQLite is derived\n** from comments in this file.  This file is the authoritative source\n** on how SQLite interfaces are supposed to operate.\n**\n** The name of this file under configuration management is \"sqlite.h.in\".\n** The makefile makes some minor changes to this file (such as inserting\n** the version number) and changes its name to \"sqlite3.h\" as\n** part of the build process.\n*/\n#ifndef SQLITE3_H\n#define SQLITE3_H\n#include <stdarg.h>     /* Needed for the definition of va_list */\n\n/*\n** Make sure we can call this stuff from C++.\n*/\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n\n/*\n** Provide the ability to override linkage features of the interface.\n*/\n#ifndef SQLITE_EXTERN\n# define SQLITE_EXTERN extern\n#endif\n#ifndef SQLITE_API\n# define SQLITE_API\n#endif\n#ifndef SQLITE_CDECL\n# define SQLITE_CDECL\n#endif\n#ifndef SQLITE_APICALL\n# define SQLITE_APICALL\n#endif\n#ifndef SQLITE_STDCALL\n# define SQLITE_STDCALL SQLITE_APICALL\n#endif\n#ifndef SQLITE_CALLBACK\n# define SQLITE_CALLBACK\n#endif\n#ifndef SQLITE_SYSAPI\n# define SQLITE_SYSAPI\n#endif\n\n/*\n** These no-op macros are used in front of interfaces to mark those\n** interfaces as either deprecated or experimental.  New applications\n** should not use deprecated interfaces - they are supported for backwards\n** compatibility only.  Application writers should be aware that\n** experimental interfaces are subject to change in point releases.\n**\n** These macros used to resolve to various kinds of compiler magic that\n** would generate warning messages when they were used.  But that\n** compiler magic ended up generating such a flurry of bug reports\n** that we have taken it all out and gone back to using simple\n** noop macros.\n*/\n#define SQLITE_DEPRECATED\n#define SQLITE_EXPERIMENTAL\n\n/*\n** Ensure these symbols were not defined by some previous header file.\n*/\n#ifdef SQLITE_VERSION\n# undef SQLITE_VERSION\n#endif\n#ifdef SQLITE_VERSION_NUMBER\n# undef SQLITE_VERSION_NUMBER\n#endif\n\n/*\n** CAPI3REF: Compile-Time Library Version Numbers\n**\n** ^(The [SQLITE_VERSION] C preprocessor macro in the sqlite3.h header\n** evaluates to a string literal that is the SQLite version in the\n** format \"X.Y.Z\" where X is the major version number (always 3 for\n** SQLite3) and Y is the minor version number and Z is the release number.)^\n** ^(The [SQLITE_VERSION_NUMBER] C preprocessor macro resolves to an integer\n** with the value (X*1000000 + Y*1000 + Z) where X, Y, and Z are the same\n** numbers used in [SQLITE_VERSION].)^\n** The SQLITE_VERSION_NUMBER for any given release of SQLite will also\n** be larger than the release from which it is derived.  Either Y will\n** be held constant and Z will be incremented or else Y will be incremented\n** and Z will be reset to zero.\n**\n** Since [version 3.6.18] ([dateof:3.6.18]), \n** SQLite source code has been stored in the\n** <a href=\"http://www.fossil-scm.org/\">Fossil configuration management\n** system</a>.  ^The SQLITE_SOURCE_ID macro evaluates to\n** a string which identifies a particular check-in of SQLite\n** within its configuration management system.  ^The SQLITE_SOURCE_ID\n** string contains the date and time of the check-in (UTC) and a SHA1\n** or SHA3-256 hash of the entire source tree.  If the source code has\n** been edited in any way since it was last checked in, then the last\n** four hexadecimal digits of the hash may be modified.\n**\n** See also: [sqlite3_libversion()],\n** [sqlite3_libversion_number()], [sqlite3_sourceid()],\n** [sqlite_version()] and [sqlite_source_id()].\n*/\n#define SQLITE_VERSION        \"3.27.2\"\n#define SQLITE_VERSION_NUMBER 3027002\n#define SQLITE_SOURCE_ID      \"2019-02-25 16:06:06 bd49a8271d650fa89e446b42e513b595a717b9212c91dd384aab871fc1d0alt1\"\n\n/*\n** CAPI3REF: Run-Time Library Version Numbers\n** KEYWORDS: sqlite3_version sqlite3_sourceid\n**\n** These interfaces provide the same information as the [SQLITE_VERSION],\n** [SQLITE_VERSION_NUMBER], and [SQLITE_SOURCE_ID] C preprocessor macros\n** but are associated with the library instead of the header file.  ^(Cautious\n** programmers might include assert() statements in their application to\n** verify that values returned by these interfaces match the macros in\n** the header, and thus ensure that the application is\n** compiled with matching library and header files.\n**\n** <blockquote><pre>\n** assert( sqlite3_libversion_number()==SQLITE_VERSION_NUMBER );\n** assert( strncmp(sqlite3_sourceid(),SQLITE_SOURCE_ID,80)==0 );\n** assert( strcmp(sqlite3_libversion(),SQLITE_VERSION)==0 );\n** </pre></blockquote>)^\n**\n** ^The sqlite3_version[] string constant contains the text of [SQLITE_VERSION]\n** macro.  ^The sqlite3_libversion() function returns a pointer to the\n** to the sqlite3_version[] string constant.  The sqlite3_libversion()\n** function is provided for use in DLLs since DLL users usually do not have\n** direct access to string constants within the DLL.  ^The\n** sqlite3_libversion_number() function returns an integer equal to\n** [SQLITE_VERSION_NUMBER].  ^(The sqlite3_sourceid() function returns \n** a pointer to a string constant whose value is the same as the \n** [SQLITE_SOURCE_ID] C preprocessor macro.  Except if SQLite is built\n** using an edited copy of [the amalgamation], then the last four characters\n** of the hash might be different from [SQLITE_SOURCE_ID].)^\n**\n** See also: [sqlite_version()] and [sqlite_source_id()].\n*/\nSQLITE_API SQLITE_EXTERN const char sqlite3_version[];\nSQLITE_API const char *sqlite3_libversion(void);\nSQLITE_API const char *sqlite3_sourceid(void);\nSQLITE_API int sqlite3_libversion_number(void);\n\n/*\n** CAPI3REF: Run-Time Library Compilation Options Diagnostics\n**\n** ^The sqlite3_compileoption_used() function returns 0 or 1 \n** indicating whether the specified option was defined at \n** compile time.  ^The SQLITE_ prefix may be omitted from the \n** option name passed to sqlite3_compileoption_used().  \n**\n** ^The sqlite3_compileoption_get() function allows iterating\n** over the list of options that were defined at compile time by\n** returning the N-th compile time option string.  ^If N is out of range,\n** sqlite3_compileoption_get() returns a NULL pointer.  ^The SQLITE_ \n** prefix is omitted from any strings returned by \n** sqlite3_compileoption_get().\n**\n** ^Support for the diagnostic functions sqlite3_compileoption_used()\n** and sqlite3_compileoption_get() may be omitted by specifying the \n** [SQLITE_OMIT_COMPILEOPTION_DIAGS] option at compile time.\n**\n** See also: SQL functions [sqlite_compileoption_used()] and\n** [sqlite_compileoption_get()] and the [compile_options pragma].\n*/\n#ifndef SQLITE_OMIT_COMPILEOPTION_DIAGS\nSQLITE_API int sqlite3_compileoption_used(const char *zOptName);\nSQLITE_API const char *sqlite3_compileoption_get(int N);\n#endif\n\n/*\n** CAPI3REF: Test To See If The Library Is Threadsafe\n**\n** ^The sqlite3_threadsafe() function returns zero if and only if\n** SQLite was compiled with mutexing code omitted due to the\n** [SQLITE_THREADSAFE] compile-time option being set to 0.\n**\n** SQLite can be compiled with or without mutexes.  When\n** the [SQLITE_THREADSAFE] C preprocessor macro is 1 or 2, mutexes\n** are enabled and SQLite is threadsafe.  When the\n** [SQLITE_THREADSAFE] macro is 0, \n** the mutexes are omitted.  Without the mutexes, it is not safe\n** to use SQLite concurrently from more than one thread.\n**\n** Enabling mutexes incurs a measurable performance penalty.\n** So if speed is of utmost importance, it makes sense to disable\n** the mutexes.  But for maximum safety, mutexes should be enabled.\n** ^The default behavior is for mutexes to be enabled.\n**\n** This interface can be used by an application to make sure that the\n** version of SQLite that it is linking against was compiled with\n** the desired setting of the [SQLITE_THREADSAFE] macro.\n**\n** This interface only reports on the compile-time mutex setting\n** of the [SQLITE_THREADSAFE] flag.  If SQLite is compiled with\n** SQLITE_THREADSAFE=1 or =2 then mutexes are enabled by default but\n** can be fully or partially disabled using a call to [sqlite3_config()]\n** with the verbs [SQLITE_CONFIG_SINGLETHREAD], [SQLITE_CONFIG_MULTITHREAD],\n** or [SQLITE_CONFIG_SERIALIZED].  ^(The return value of the\n** sqlite3_threadsafe() function shows only the compile-time setting of\n** thread safety, not any run-time changes to that setting made by\n** sqlite3_config(). In other words, the return value from sqlite3_threadsafe()\n** is unchanged by calls to sqlite3_config().)^\n**\n** See the [threading mode] documentation for additional information.\n*/\nSQLITE_API int sqlite3_threadsafe(void);\n\n/*\n** CAPI3REF: Database Connection Handle\n** KEYWORDS: {database connection} {database connections}\n**\n** Each open SQLite database is represented by a pointer to an instance of\n** the opaque structure named \"sqlite3\".  It is useful to think of an sqlite3\n** pointer as an object.  The [sqlite3_open()], [sqlite3_open16()], and\n** [sqlite3_open_v2()] interfaces are its constructors, and [sqlite3_close()]\n** and [sqlite3_close_v2()] are its destructors.  There are many other\n** interfaces (such as\n** [sqlite3_prepare_v2()], [sqlite3_create_function()], and\n** [sqlite3_busy_timeout()] to name but three) that are methods on an\n** sqlite3 object.\n*/\ntypedef struct sqlite3 sqlite3;\n\n/*\n** CAPI3REF: 64-Bit Integer Types\n** KEYWORDS: sqlite_int64 sqlite_uint64\n**\n** Because there is no cross-platform way to specify 64-bit integer types\n** SQLite includes typedefs for 64-bit signed and unsigned integers.\n**\n** The sqlite3_int64 and sqlite3_uint64 are the preferred type definitions.\n** The sqlite_int64 and sqlite_uint64 types are supported for backwards\n** compatibility only.\n**\n** ^The sqlite3_int64 and sqlite_int64 types can store integer values\n** between -9223372036854775808 and +9223372036854775807 inclusive.  ^The\n** sqlite3_uint64 and sqlite_uint64 types can store integer values \n** between 0 and +18446744073709551615 inclusive.\n*/\n#ifdef SQLITE_INT64_TYPE\n  typedef SQLITE_INT64_TYPE sqlite_int64;\n# ifdef SQLITE_UINT64_TYPE\n    typedef SQLITE_UINT64_TYPE sqlite_uint64;\n# else  \n    typedef unsigned SQLITE_INT64_TYPE sqlite_uint64;\n# endif\n#elif defined(_MSC_VER) || defined(__BORLANDC__)\n  typedef __int64 sqlite_int64;\n  typedef unsigned __int64 sqlite_uint64;\n#else\n  typedef long long int sqlite_int64;\n  typedef unsigned long long int sqlite_uint64;\n#endif\ntypedef sqlite_int64 sqlite3_int64;\ntypedef sqlite_uint64 sqlite3_uint64;\n\n/*\n** If compiling for a processor that lacks floating point support,\n** substitute integer for floating-point.\n*/\n#ifdef SQLITE_OMIT_FLOATING_POINT\n# define double sqlite3_int64\n#endif\n\n/*\n** CAPI3REF: Closing A Database Connection\n** DESTRUCTOR: sqlite3\n**\n** ^The sqlite3_close() and sqlite3_close_v2() routines are destructors\n** for the [sqlite3] object.\n** ^Calls to sqlite3_close() and sqlite3_close_v2() return [SQLITE_OK] if\n** the [sqlite3] object is successfully destroyed and all associated\n** resources are deallocated.\n**\n** ^If the database connection is associated with unfinalized prepared\n** statements or unfinished sqlite3_backup objects then sqlite3_close()\n** will leave the database connection open and return [SQLITE_BUSY].\n** ^If sqlite3_close_v2() is called with unfinalized prepared statements\n** and/or unfinished sqlite3_backups, then the database connection becomes\n** an unusable \"zombie\" which will automatically be deallocated when the\n** last prepared statement is finalized or the last sqlite3_backup is\n** finished.  The sqlite3_close_v2() interface is intended for use with\n** host languages that are garbage collected, and where the order in which\n** destructors are called is arbitrary.\n**\n** Applications should [sqlite3_finalize | finalize] all [prepared statements],\n** [sqlite3_blob_close | close] all [BLOB handles], and \n** [sqlite3_backup_finish | finish] all [sqlite3_backup] objects associated\n** with the [sqlite3] object prior to attempting to close the object.  ^If\n** sqlite3_close_v2() is called on a [database connection] that still has\n** outstanding [prepared statements], [BLOB handles], and/or\n** [sqlite3_backup] objects then it returns [SQLITE_OK] and the deallocation\n** of resources is deferred until all [prepared statements], [BLOB handles],\n** and [sqlite3_backup] objects are also destroyed.\n**\n** ^If an [sqlite3] object is destroyed while a transaction is open,\n** the transaction is automatically rolled back.\n**\n** The C parameter to [sqlite3_close(C)] and [sqlite3_close_v2(C)]\n** must be either a NULL\n** pointer or an [sqlite3] object pointer obtained\n** from [sqlite3_open()], [sqlite3_open16()], or\n** [sqlite3_open_v2()], and not previously closed.\n** ^Calling sqlite3_close() or sqlite3_close_v2() with a NULL pointer\n** argument is a harmless no-op.\n*/\nSQLITE_API int sqlite3_close(sqlite3*);\nSQLITE_API int sqlite3_close_v2(sqlite3*);\n\n/*\n** The type for a callback function.\n** This is legacy and deprecated.  It is included for historical\n** compatibility and is not documented.\n*/\ntypedef int (*sqlite3_callback)(void*,int,char**, char**);\n\n/*\n** CAPI3REF: One-Step Query Execution Interface\n** METHOD: sqlite3\n**\n** The sqlite3_exec() interface is a convenience wrapper around\n** [sqlite3_prepare_v2()], [sqlite3_step()], and [sqlite3_finalize()],\n** that allows an application to run multiple statements of SQL\n** without having to use a lot of C code. \n**\n** ^The sqlite3_exec() interface runs zero or more UTF-8 encoded,\n** semicolon-separate SQL statements passed into its 2nd argument,\n** in the context of the [database connection] passed in as its 1st\n** argument.  ^If the callback function of the 3rd argument to\n** sqlite3_exec() is not NULL, then it is invoked for each result row\n** coming out of the evaluated SQL statements.  ^The 4th argument to\n** sqlite3_exec() is relayed through to the 1st argument of each\n** callback invocation.  ^If the callback pointer to sqlite3_exec()\n** is NULL, then no callback is ever invoked and result rows are\n** ignored.\n**\n** ^If an error occurs while evaluating the SQL statements passed into\n** sqlite3_exec(), then execution of the current statement stops and\n** subsequent statements are skipped.  ^If the 5th parameter to sqlite3_exec()\n** is not NULL then any error message is written into memory obtained\n** from [sqlite3_malloc()] and passed back through the 5th parameter.\n** To avoid memory leaks, the application should invoke [sqlite3_free()]\n** on error message strings returned through the 5th parameter of\n** sqlite3_exec() after the error message string is no longer needed.\n** ^If the 5th parameter to sqlite3_exec() is not NULL and no errors\n** occur, then sqlite3_exec() sets the pointer in its 5th parameter to\n** NULL before returning.\n**\n** ^If an sqlite3_exec() callback returns non-zero, the sqlite3_exec()\n** routine returns SQLITE_ABORT without invoking the callback again and\n** without running any subsequent SQL statements.\n**\n** ^The 2nd argument to the sqlite3_exec() callback function is the\n** number of columns in the result.  ^The 3rd argument to the sqlite3_exec()\n** callback is an array of pointers to strings obtained as if from\n** [sqlite3_column_text()], one for each column.  ^If an element of a\n** result row is NULL then the corresponding string pointer for the\n** sqlite3_exec() callback is a NULL pointer.  ^The 4th argument to the\n** sqlite3_exec() callback is an array of pointers to strings where each\n** entry represents the name of corresponding result column as obtained\n** from [sqlite3_column_name()].\n**\n** ^If the 2nd parameter to sqlite3_exec() is a NULL pointer, a pointer\n** to an empty string, or a pointer that contains only whitespace and/or \n** SQL comments, then no SQL statements are evaluated and the database\n** is not changed.\n**\n** Restrictions:\n**\n** <ul>\n** <li> The application must ensure that the 1st parameter to sqlite3_exec()\n**      is a valid and open [database connection].\n** <li> The application must not close the [database connection] specified by\n**      the 1st parameter to sqlite3_exec() while sqlite3_exec() is running.\n** <li> The application must not modify the SQL statement text passed into\n**      the 2nd parameter of sqlite3_exec() while sqlite3_exec() is running.\n** </ul>\n*/\nSQLITE_API int sqlite3_exec(\n  sqlite3*,                                  /* An open database */\n  const char *sql,                           /* SQL to be evaluated */\n  int (*callback)(void*,int,char**,char**),  /* Callback function */\n  void *,                                    /* 1st argument to callback */\n  char **errmsg                              /* Error msg written here */\n);\n\n/*\n** CAPI3REF: Result Codes\n** KEYWORDS: {result code definitions}\n**\n** Many SQLite functions return an integer result code from the set shown\n** here in order to indicate success or failure.\n**\n** New error codes may be added in future versions of SQLite.\n**\n** See also: [extended result code definitions]\n*/\n#define SQLITE_OK           0   /* Successful result */\n/* beginning-of-error-codes */\n#define SQLITE_ERROR        1   /* Generic error */\n#define SQLITE_INTERNAL     2   /* Internal logic error in SQLite */\n#define SQLITE_PERM         3   /* Access permission denied */\n#define SQLITE_ABORT        4   /* Callback routine requested an abort */\n#define SQLITE_BUSY         5   /* The database file is locked */\n#define SQLITE_LOCKED       6   /* A table in the database is locked */\n#define SQLITE_NOMEM        7   /* A malloc() failed */\n#define SQLITE_READONLY     8   /* Attempt to write a readonly database */\n#define SQLITE_INTERRUPT    9   /* Operation terminated by sqlite3_interrupt()*/\n#define SQLITE_IOERR       10   /* Some kind of disk I/O error occurred */\n#define SQLITE_CORRUPT     11   /* The database disk image is malformed */\n#define SQLITE_NOTFOUND    12   /* Unknown opcode in sqlite3_file_control() */\n#define SQLITE_FULL        13   /* Insertion failed because database is full */\n#define SQLITE_CANTOPEN    14   /* Unable to open the database file */\n#define SQLITE_PROTOCOL    15   /* Database lock protocol error */\n#define SQLITE_EMPTY       16   /* Internal use only */\n#define SQLITE_SCHEMA      17   /* The database schema changed */\n#define SQLITE_TOOBIG      18   /* String or BLOB exceeds size limit */\n#define SQLITE_CONSTRAINT  19   /* Abort due to constraint violation */\n#define SQLITE_MISMATCH    20   /* Data type mismatch */\n#define SQLITE_MISUSE      21   /* Library used incorrectly */\n#define SQLITE_NOLFS       22   /* Uses OS features not supported on host */\n#define SQLITE_AUTH        23   /* Authorization denied */\n#define SQLITE_FORMAT      24   /* Not used */\n#define SQLITE_RANGE       25   /* 2nd parameter to sqlite3_bind out of range */\n#define SQLITE_NOTADB      26   /* File opened that is not a database file */\n#define SQLITE_NOTICE      27   /* Notifications from sqlite3_log() */\n#define SQLITE_WARNING     28   /* Warnings from sqlite3_log() */\n#define SQLITE_ROW         100  /* sqlite3_step() has another row ready */\n#define SQLITE_DONE        101  /* sqlite3_step() has finished executing */\n/* end-of-error-codes */\n\n/*\n** CAPI3REF: Extended Result Codes\n** KEYWORDS: {extended result code definitions}\n**\n** In its default configuration, SQLite API routines return one of 30 integer\n** [result codes].  However, experience has shown that many of\n** these result codes are too coarse-grained.  They do not provide as\n** much information about problems as programmers might like.  In an effort to\n** address this, newer versions of SQLite (version 3.3.8 [dateof:3.3.8]\n** and later) include\n** support for additional result codes that provide more detailed information\n** about errors. These [extended result codes] are enabled or disabled\n** on a per database connection basis using the\n** [sqlite3_extended_result_codes()] API.  Or, the extended code for\n** the most recent error can be obtained using\n** [sqlite3_extended_errcode()].\n*/\n#define SQLITE_ERROR_MISSING_COLLSEQ   (SQLITE_ERROR | (1<<8))\n#define SQLITE_ERROR_RETRY             (SQLITE_ERROR | (2<<8))\n#define SQLITE_ERROR_SNAPSHOT          (SQLITE_ERROR | (3<<8))\n#define SQLITE_IOERR_READ              (SQLITE_IOERR | (1<<8))\n#define SQLITE_IOERR_SHORT_READ        (SQLITE_IOERR | (2<<8))\n#define SQLITE_IOERR_WRITE             (SQLITE_IOERR | (3<<8))\n#define SQLITE_IOERR_FSYNC             (SQLITE_IOERR | (4<<8))\n#define SQLITE_IOERR_DIR_FSYNC         (SQLITE_IOERR | (5<<8))\n#define SQLITE_IOERR_TRUNCATE          (SQLITE_IOERR | (6<<8))\n#define SQLITE_IOERR_FSTAT             (SQLITE_IOERR | (7<<8))\n#define SQLITE_IOERR_UNLOCK            (SQLITE_IOERR | (8<<8))\n#define SQLITE_IOERR_RDLOCK            (SQLITE_IOERR | (9<<8))\n#define SQLITE_IOERR_DELETE            (SQLITE_IOERR | (10<<8))\n#define SQLITE_IOERR_BLOCKED           (SQLITE_IOERR | (11<<8))\n#define SQLITE_IOERR_NOMEM             (SQLITE_IOERR | (12<<8))\n#define SQLITE_IOERR_ACCESS            (SQLITE_IOERR | (13<<8))\n#define SQLITE_IOERR_CHECKRESERVEDLOCK (SQLITE_IOERR | (14<<8))\n#define SQLITE_IOERR_LOCK              (SQLITE_IOERR | (15<<8))\n#define SQLITE_IOERR_CLOSE             (SQLITE_IOERR | (16<<8))\n#define SQLITE_IOERR_DIR_CLOSE         (SQLITE_IOERR | (17<<8))\n#define SQLITE_IOERR_SHMOPEN           (SQLITE_IOERR | (18<<8))\n#define SQLITE_IOERR_SHMSIZE           (SQLITE_IOERR | (19<<8))\n#define SQLITE_IOERR_SHMLOCK           (SQLITE_IOERR | (20<<8))\n#define SQLITE_IOERR_SHMMAP            (SQLITE_IOERR | (21<<8))\n#define SQLITE_IOERR_SEEK              (SQLITE_IOERR | (22<<8))\n#define SQLITE_IOERR_DELETE_NOENT      (SQLITE_IOERR | (23<<8))\n#define SQLITE_IOERR_MMAP              (SQLITE_IOERR | (24<<8))\n#define SQLITE_IOERR_GETTEMPPATH       (SQLITE_IOERR | (25<<8))\n#define SQLITE_IOERR_CONVPATH          (SQLITE_IOERR | (26<<8))\n#define SQLITE_IOERR_VNODE             (SQLITE_IOERR | (27<<8))\n#define SQLITE_IOERR_AUTH              (SQLITE_IOERR | (28<<8))\n#define SQLITE_IOERR_BEGIN_ATOMIC      (SQLITE_IOERR | (29<<8))\n#define SQLITE_IOERR_COMMIT_ATOMIC     (SQLITE_IOERR | (30<<8))\n#define SQLITE_IOERR_ROLLBACK_ATOMIC   (SQLITE_IOERR | (31<<8))\n#define SQLITE_LOCKED_SHAREDCACHE      (SQLITE_LOCKED |  (1<<8))\n#define SQLITE_LOCKED_VTAB             (SQLITE_LOCKED |  (2<<8))\n#define SQLITE_BUSY_RECOVERY           (SQLITE_BUSY   |  (1<<8))\n#define SQLITE_BUSY_SNAPSHOT           (SQLITE_BUSY   |  (2<<8))\n#define SQLITE_CANTOPEN_NOTEMPDIR      (SQLITE_CANTOPEN | (1<<8))\n#define SQLITE_CANTOPEN_ISDIR          (SQLITE_CANTOPEN | (2<<8))\n#define SQLITE_CANTOPEN_FULLPATH       (SQLITE_CANTOPEN | (3<<8))\n#define SQLITE_CANTOPEN_CONVPATH       (SQLITE_CANTOPEN | (4<<8))\n#define SQLITE_CANTOPEN_DIRTYWAL       (SQLITE_CANTOPEN | (5<<8)) /* Not Used */\n#define SQLITE_CORRUPT_VTAB            (SQLITE_CORRUPT | (1<<8))\n#define SQLITE_CORRUPT_SEQUENCE        (SQLITE_CORRUPT | (2<<8))\n#define SQLITE_READONLY_RECOVERY       (SQLITE_READONLY | (1<<8))\n#define SQLITE_READONLY_CANTLOCK       (SQLITE_READONLY | (2<<8))\n#define SQLITE_READONLY_ROLLBACK       (SQLITE_READONLY | (3<<8))\n#define SQLITE_READONLY_DBMOVED        (SQLITE_READONLY | (4<<8))\n#define SQLITE_READONLY_CANTINIT       (SQLITE_READONLY | (5<<8))\n#define SQLITE_READONLY_DIRECTORY      (SQLITE_READONLY | (6<<8))\n#define SQLITE_ABORT_ROLLBACK          (SQLITE_ABORT | (2<<8))\n#define SQLITE_CONSTRAINT_CHECK        (SQLITE_CONSTRAINT | (1<<8))\n#define SQLITE_CONSTRAINT_COMMITHOOK   (SQLITE_CONSTRAINT | (2<<8))\n#define SQLITE_CONSTRAINT_FOREIGNKEY   (SQLITE_CONSTRAINT | (3<<8))\n#define SQLITE_CONSTRAINT_FUNCTION     (SQLITE_CONSTRAINT | (4<<8))\n#define SQLITE_CONSTRAINT_NOTNULL      (SQLITE_CONSTRAINT | (5<<8))\n#define SQLITE_CONSTRAINT_PRIMARYKEY   (SQLITE_CONSTRAINT | (6<<8))\n#define SQLITE_CONSTRAINT_TRIGGER      (SQLITE_CONSTRAINT | (7<<8))\n#define SQLITE_CONSTRAINT_UNIQUE       (SQLITE_CONSTRAINT | (8<<8))\n#define SQLITE_CONSTRAINT_VTAB         (SQLITE_CONSTRAINT | (9<<8))\n#define SQLITE_CONSTRAINT_ROWID        (SQLITE_CONSTRAINT |(10<<8))\n#define SQLITE_NOTICE_RECOVER_WAL      (SQLITE_NOTICE | (1<<8))\n#define SQLITE_NOTICE_RECOVER_ROLLBACK (SQLITE_NOTICE | (2<<8))\n#define SQLITE_WARNING_AUTOINDEX       (SQLITE_WARNING | (1<<8))\n#define SQLITE_AUTH_USER               (SQLITE_AUTH | (1<<8))\n#define SQLITE_OK_LOAD_PERMANENTLY     (SQLITE_OK | (1<<8))\n\n/*\n** CAPI3REF: Flags For File Open Operations\n**\n** These bit values are intended for use in the\n** 3rd parameter to the [sqlite3_open_v2()] interface and\n** in the 4th parameter to the [sqlite3_vfs.xOpen] method.\n*/\n#define SQLITE_OPEN_READONLY         0x00000001  /* Ok for sqlite3_open_v2() */\n#define SQLITE_OPEN_READWRITE        0x00000002  /* Ok for sqlite3_open_v2() */\n#define SQLITE_OPEN_CREATE           0x00000004  /* Ok for sqlite3_open_v2() */\n#define SQLITE_OPEN_DELETEONCLOSE    0x00000008  /* VFS only */\n#define SQLITE_OPEN_EXCLUSIVE        0x00000010  /* VFS only */\n#define SQLITE_OPEN_AUTOPROXY        0x00000020  /* VFS only */\n#define SQLITE_OPEN_URI              0x00000040  /* Ok for sqlite3_open_v2() */\n#define SQLITE_OPEN_MEMORY           0x00000080  /* Ok for sqlite3_open_v2() */\n#define SQLITE_OPEN_MAIN_DB          0x00000100  /* VFS only */\n#define SQLITE_OPEN_TEMP_DB          0x00000200  /* VFS only */\n#define SQLITE_OPEN_TRANSIENT_DB     0x00000400  /* VFS only */\n#define SQLITE_OPEN_MAIN_JOURNAL     0x00000800  /* VFS only */\n#define SQLITE_OPEN_TEMP_JOURNAL     0x00001000  /* VFS only */\n#define SQLITE_OPEN_SUBJOURNAL       0x00002000  /* VFS only */\n#define SQLITE_OPEN_MASTER_JOURNAL   0x00004000  /* VFS only */\n#define SQLITE_OPEN_NOMUTEX          0x00008000  /* Ok for sqlite3_open_v2() */\n#define SQLITE_OPEN_FULLMUTEX        0x00010000  /* Ok for sqlite3_open_v2() */\n#define SQLITE_OPEN_SHAREDCACHE      0x00020000  /* Ok for sqlite3_open_v2() */\n#define SQLITE_OPEN_PRIVATECACHE     0x00040000  /* Ok for sqlite3_open_v2() */\n#define SQLITE_OPEN_WAL              0x00080000  /* VFS only */\n#define SQLITE_OPEN_MAINDB_READONLY  0x00100000  /* Main db readonly */\n\n/* Reserved:                         0x00F00000 */\n\n/*\n** CAPI3REF: Device Characteristics\n**\n** The xDeviceCharacteristics method of the [sqlite3_io_methods]\n** object returns an integer which is a vector of these\n** bit values expressing I/O characteristics of the mass storage\n** device that holds the file that the [sqlite3_io_methods]\n** refers to.\n**\n** The SQLITE_IOCAP_ATOMIC property means that all writes of\n** any size are atomic.  The SQLITE_IOCAP_ATOMICnnn values\n** mean that writes of blocks that are nnn bytes in size and\n** are aligned to an address which is an integer multiple of\n** nnn are atomic.  The SQLITE_IOCAP_SAFE_APPEND value means\n** that when data is appended to a file, the data is appended\n** first then the size of the file is extended, never the other\n** way around.  The SQLITE_IOCAP_SEQUENTIAL property means that\n** information is written to disk in the same order as calls\n** to xWrite().  The SQLITE_IOCAP_POWERSAFE_OVERWRITE property means that\n** after reboot following a crash or power loss, the only bytes in a\n** file that were written at the application level might have changed\n** and that adjacent bytes, even bytes within the same sector are\n** guaranteed to be unchanged.  The SQLITE_IOCAP_UNDELETABLE_WHEN_OPEN\n** flag indicates that a file cannot be deleted when open.  The\n** SQLITE_IOCAP_IMMUTABLE flag indicates that the file is on\n** read-only media and cannot be changed even by processes with\n** elevated privileges.\n**\n** The SQLITE_IOCAP_BATCH_ATOMIC property means that the underlying\n** filesystem supports doing multiple write operations atomically when those\n** write operations are bracketed by [SQLITE_FCNTL_BEGIN_ATOMIC_WRITE] and\n** [SQLITE_FCNTL_COMMIT_ATOMIC_WRITE].\n*/\n#define SQLITE_IOCAP_ATOMIC                 0x00000001\n#define SQLITE_IOCAP_ATOMIC512              0x00000002\n#define SQLITE_IOCAP_ATOMIC1K               0x00000004\n#define SQLITE_IOCAP_ATOMIC2K               0x00000008\n#define SQLITE_IOCAP_ATOMIC4K               0x00000010\n#define SQLITE_IOCAP_ATOMIC8K               0x00000020\n#define SQLITE_IOCAP_ATOMIC16K              0x00000040\n#define SQLITE_IOCAP_ATOMIC32K              0x00000080\n#define SQLITE_IOCAP_ATOMIC64K              0x00000100\n#define SQLITE_IOCAP_SAFE_APPEND            0x00000200\n#define SQLITE_IOCAP_SEQUENTIAL             0x00000400\n#define SQLITE_IOCAP_UNDELETABLE_WHEN_OPEN  0x00000800\n#define SQLITE_IOCAP_POWERSAFE_OVERWRITE    0x00001000\n#define SQLITE_IOCAP_IMMUTABLE              0x00002000\n#define SQLITE_IOCAP_BATCH_ATOMIC           0x00004000\n\n/*\n** CAPI3REF: File Locking Levels\n**\n** SQLite uses one of these integer values as the second\n** argument to calls it makes to the xLock() and xUnlock() methods\n** of an [sqlite3_io_methods] object.\n*/\n#define SQLITE_LOCK_NONE          0\n#define SQLITE_LOCK_SHARED        1\n#define SQLITE_LOCK_RESERVED      2\n#define SQLITE_LOCK_PENDING       3\n#define SQLITE_LOCK_EXCLUSIVE     4\n\n/*\n** CAPI3REF: Synchronization Type Flags\n**\n** When SQLite invokes the xSync() method of an\n** [sqlite3_io_methods] object it uses a combination of\n** these integer values as the second argument.\n**\n** When the SQLITE_SYNC_DATAONLY flag is used, it means that the\n** sync operation only needs to flush data to mass storage.  Inode\n** information need not be flushed. If the lower four bits of the flag\n** equal SQLITE_SYNC_NORMAL, that means to use normal fsync() semantics.\n** If the lower four bits equal SQLITE_SYNC_FULL, that means\n** to use Mac OS X style fullsync instead of fsync().\n**\n** Do not confuse the SQLITE_SYNC_NORMAL and SQLITE_SYNC_FULL flags\n** with the [PRAGMA synchronous]=NORMAL and [PRAGMA synchronous]=FULL\n** settings.  The [synchronous pragma] determines when calls to the\n** xSync VFS method occur and applies uniformly across all platforms.\n** The SQLITE_SYNC_NORMAL and SQLITE_SYNC_FULL flags determine how\n** energetic or rigorous or forceful the sync operations are and\n** only make a difference on Mac OSX for the default SQLite code.\n** (Third-party VFS implementations might also make the distinction\n** between SQLITE_SYNC_NORMAL and SQLITE_SYNC_FULL, but among the\n** operating systems natively supported by SQLite, only Mac OSX\n** cares about the difference.)\n*/\n#define SQLITE_SYNC_NORMAL        0x00002\n#define SQLITE_SYNC_FULL          0x00003\n#define SQLITE_SYNC_DATAONLY      0x00010\n\n/*\n** CAPI3REF: OS Interface Open File Handle\n**\n** An [sqlite3_file] object represents an open file in the \n** [sqlite3_vfs | OS interface layer].  Individual OS interface\n** implementations will\n** want to subclass this object by appending additional fields\n** for their own use.  The pMethods entry is a pointer to an\n** [sqlite3_io_methods] object that defines methods for performing\n** I/O operations on the open file.\n*/\ntypedef struct sqlite3_file sqlite3_file;\nstruct sqlite3_file {\n  const struct sqlite3_io_methods *pMethods;  /* Methods for an open file */\n};\n\n/*\n** CAPI3REF: OS Interface File Virtual Methods Object\n**\n** Every file opened by the [sqlite3_vfs.xOpen] method populates an\n** [sqlite3_file] object (or, more commonly, a subclass of the\n** [sqlite3_file] object) with a pointer to an instance of this object.\n** This object defines the methods used to perform various operations\n** against the open file represented by the [sqlite3_file] object.\n**\n** If the [sqlite3_vfs.xOpen] method sets the sqlite3_file.pMethods element \n** to a non-NULL pointer, then the sqlite3_io_methods.xClose method\n** may be invoked even if the [sqlite3_vfs.xOpen] reported that it failed.  The\n** only way to prevent a call to xClose following a failed [sqlite3_vfs.xOpen]\n** is for the [sqlite3_vfs.xOpen] to set the sqlite3_file.pMethods element\n** to NULL.\n**\n** The flags argument to xSync may be one of [SQLITE_SYNC_NORMAL] or\n** [SQLITE_SYNC_FULL].  The first choice is the normal fsync().\n** The second choice is a Mac OS X style fullsync.  The [SQLITE_SYNC_DATAONLY]\n** flag may be ORed in to indicate that only the data of the file\n** and not its inode needs to be synced.\n**\n** The integer values to xLock() and xUnlock() are one of\n** <ul>\n** <li> [SQLITE_LOCK_NONE],\n** <li> [SQLITE_LOCK_SHARED],\n** <li> [SQLITE_LOCK_RESERVED],\n** <li> [SQLITE_LOCK_PENDING], or\n** <li> [SQLITE_LOCK_EXCLUSIVE].\n** </ul>\n** xLock() increases the lock. xUnlock() decreases the lock.\n** The xCheckReservedLock() method checks whether any database connection,\n** either in this process or in some other process, is holding a RESERVED,\n** PENDING, or EXCLUSIVE lock on the file.  It returns true\n** if such a lock exists and false otherwise.\n**\n** The xFileControl() method is a generic interface that allows custom\n** VFS implementations to directly control an open file using the\n** [sqlite3_file_control()] interface.  The second \"op\" argument is an\n** integer opcode.  The third argument is a generic pointer intended to\n** point to a structure that may contain arguments or space in which to\n** write return values.  Potential uses for xFileControl() might be\n** functions to enable blocking locks with timeouts, to change the\n** locking strategy (for example to use dot-file locks), to inquire\n** about the status of a lock, or to break stale locks.  The SQLite\n** core reserves all opcodes less than 100 for its own use.\n** A [file control opcodes | list of opcodes] less than 100 is available.\n** Applications that define a custom xFileControl method should use opcodes\n** greater than 100 to avoid conflicts.  VFS implementations should\n** return [SQLITE_NOTFOUND] for file control opcodes that they do not\n** recognize.\n**\n** The xSectorSize() method returns the sector size of the\n** device that underlies the file.  The sector size is the\n** minimum write that can be performed without disturbing\n** other bytes in the file.  The xDeviceCharacteristics()\n** method returns a bit vector describing behaviors of the\n** underlying device:\n**\n** <ul>\n** <li> [SQLITE_IOCAP_ATOMIC]\n** <li> [SQLITE_IOCAP_ATOMIC512]\n** <li> [SQLITE_IOCAP_ATOMIC1K]\n** <li> [SQLITE_IOCAP_ATOMIC2K]\n** <li> [SQLITE_IOCAP_ATOMIC4K]\n** <li> [SQLITE_IOCAP_ATOMIC8K]\n** <li> [SQLITE_IOCAP_ATOMIC16K]\n** <li> [SQLITE_IOCAP_ATOMIC32K]\n** <li> [SQLITE_IOCAP_ATOMIC64K]\n** <li> [SQLITE_IOCAP_SAFE_APPEND]\n** <li> [SQLITE_IOCAP_SEQUENTIAL]\n** <li> [SQLITE_IOCAP_UNDELETABLE_WHEN_OPEN]\n** <li> [SQLITE_IOCAP_POWERSAFE_OVERWRITE]\n** <li> [SQLITE_IOCAP_IMMUTABLE]\n** <li> [SQLITE_IOCAP_BATCH_ATOMIC]\n** </ul>\n**\n** The SQLITE_IOCAP_ATOMIC property means that all writes of\n** any size are atomic.  The SQLITE_IOCAP_ATOMICnnn values\n** mean that writes of blocks that are nnn bytes in size and\n** are aligned to an address which is an integer multiple of\n** nnn are atomic.  The SQLITE_IOCAP_SAFE_APPEND value means\n** that when data is appended to a file, the data is appended\n** first then the size of the file is extended, never the other\n** way around.  The SQLITE_IOCAP_SEQUENTIAL property means that\n** information is written to disk in the same order as calls\n** to xWrite().\n**\n** If xRead() returns SQLITE_IOERR_SHORT_READ it must also fill\n** in the unread portions of the buffer with zeros.  A VFS that\n** fails to zero-fill short reads might seem to work.  However,\n** failure to zero-fill short reads will eventually lead to\n** database corruption.\n*/\ntypedef struct sqlite3_io_methods sqlite3_io_methods;\nstruct sqlite3_io_methods {\n  int iVersion;\n  int (*xClose)(sqlite3_file*);\n  int (*xRead)(sqlite3_file*, void*, int iAmt, sqlite3_int64 iOfst);\n  int (*xWrite)(sqlite3_file*, const void*, int iAmt, sqlite3_int64 iOfst);\n  int (*xTruncate)(sqlite3_file*, sqlite3_int64 size);\n  int (*xSync)(sqlite3_file*, int flags);\n  int (*xFileSize)(sqlite3_file*, sqlite3_int64 *pSize);\n  int (*xLock)(sqlite3_file*, int);\n  int (*xUnlock)(sqlite3_file*, int);\n  int (*xCheckReservedLock)(sqlite3_file*, int *pResOut);\n  int (*xFileControl)(sqlite3_file*, int op, void *pArg);\n  int (*xSectorSize)(sqlite3_file*);\n  int (*xDeviceCharacteristics)(sqlite3_file*);\n  /* Methods above are valid for version 1 */\n  int (*xShmMap)(sqlite3_file*, int iPg, int pgsz, int, void volatile**);\n  int (*xShmLock)(sqlite3_file*, int offset, int n, int flags);\n  void (*xShmBarrier)(sqlite3_file*);\n  int (*xShmUnmap)(sqlite3_file*, int deleteFlag);\n  /* Methods above are valid for version 2 */\n  int (*xFetch)(sqlite3_file*, sqlite3_int64 iOfst, int iAmt, void **pp);\n  int (*xUnfetch)(sqlite3_file*, sqlite3_int64 iOfst, void *p);\n  /* Methods above are valid for version 3 */\n  /* Additional methods may be added in future releases */\n};\n\n/*\n** CAPI3REF: Standard File Control Opcodes\n** KEYWORDS: {file control opcodes} {file control opcode}\n**\n** These integer constants are opcodes for the xFileControl method\n** of the [sqlite3_io_methods] object and for the [sqlite3_file_control()]\n** interface.\n**\n** <ul>\n** <li>[[SQLITE_FCNTL_LOCKSTATE]]\n** The [SQLITE_FCNTL_LOCKSTATE] opcode is used for debugging.  This\n** opcode causes the xFileControl method to write the current state of\n** the lock (one of [SQLITE_LOCK_NONE], [SQLITE_LOCK_SHARED],\n** [SQLITE_LOCK_RESERVED], [SQLITE_LOCK_PENDING], or [SQLITE_LOCK_EXCLUSIVE])\n** into an integer that the pArg argument points to. This capability\n** is used during testing and is only available when the SQLITE_TEST\n** compile-time option is used.\n**\n** <li>[[SQLITE_FCNTL_SIZE_HINT]]\n** The [SQLITE_FCNTL_SIZE_HINT] opcode is used by SQLite to give the VFS\n** layer a hint of how large the database file will grow to be during the\n** current transaction.  This hint is not guaranteed to be accurate but it\n** is often close.  The underlying VFS might choose to preallocate database\n** file space based on this hint in order to help writes to the database\n** file run faster.\n**\n** <li>[[SQLITE_FCNTL_SIZE_LIMIT]]\n** The [SQLITE_FCNTL_SIZE_LIMIT] opcode is used by in-memory VFS that\n** implements [sqlite3_deserialize()] to set an upper bound on the size\n** of the in-memory database.  The argument is a pointer to a [sqlite3_int64].\n** If the integer pointed to is negative, then it is filled in with the\n** current limit.  Otherwise the limit is set to the larger of the value\n** of the integer pointed to and the current database size.  The integer\n** pointed to is set to the new limit.\n**\n** <li>[[SQLITE_FCNTL_CHUNK_SIZE]]\n** The [SQLITE_FCNTL_CHUNK_SIZE] opcode is used to request that the VFS\n** extends and truncates the database file in chunks of a size specified\n** by the user. The fourth argument to [sqlite3_file_control()] should \n** point to an integer (type int) containing the new chunk-size to use\n** for the nominated database. Allocating database file space in large\n** chunks (say 1MB at a time), may reduce file-system fragmentation and\n** improve performance on some systems.\n**\n** <li>[[SQLITE_FCNTL_FILE_POINTER]]\n** The [SQLITE_FCNTL_FILE_POINTER] opcode is used to obtain a pointer\n** to the [sqlite3_file] object associated with a particular database\n** connection.  See also [SQLITE_FCNTL_JOURNAL_POINTER].\n**\n** <li>[[SQLITE_FCNTL_JOURNAL_POINTER]]\n** The [SQLITE_FCNTL_JOURNAL_POINTER] opcode is used to obtain a pointer\n** to the [sqlite3_file] object associated with the journal file (either\n** the [rollback journal] or the [write-ahead log]) for a particular database\n** connection.  See also [SQLITE_FCNTL_FILE_POINTER].\n**\n** <li>[[SQLITE_FCNTL_SYNC_OMITTED]]\n** No longer in use.\n**\n** <li>[[SQLITE_FCNTL_SYNC]]\n** The [SQLITE_FCNTL_SYNC] opcode is generated internally by SQLite and\n** sent to the VFS immediately before the xSync method is invoked on a\n** database file descriptor. Or, if the xSync method is not invoked \n** because the user has configured SQLite with \n** [PRAGMA synchronous | PRAGMA synchronous=OFF] it is invoked in place \n** of the xSync method. In most cases, the pointer argument passed with\n** this file-control is NULL. However, if the database file is being synced\n** as part of a multi-database commit, the argument points to a nul-terminated\n** string containing the transactions master-journal file name. VFSes that \n** do not need this signal should silently ignore this opcode. Applications \n** should not call [sqlite3_file_control()] with this opcode as doing so may \n** disrupt the operation of the specialized VFSes that do require it.  \n**\n** <li>[[SQLITE_FCNTL_COMMIT_PHASETWO]]\n** The [SQLITE_FCNTL_COMMIT_PHASETWO] opcode is generated internally by SQLite\n** and sent to the VFS after a transaction has been committed immediately\n** but before the database is unlocked. VFSes that do not need this signal\n** should silently ignore this opcode. Applications should not call\n** [sqlite3_file_control()] with this opcode as doing so may disrupt the \n** operation of the specialized VFSes that do require it.  \n**\n** <li>[[SQLITE_FCNTL_WIN32_AV_RETRY]]\n** ^The [SQLITE_FCNTL_WIN32_AV_RETRY] opcode is used to configure automatic\n** retry counts and intervals for certain disk I/O operations for the\n** windows [VFS] in order to provide robustness in the presence of\n** anti-virus programs.  By default, the windows VFS will retry file read,\n** file write, and file delete operations up to 10 times, with a delay\n** of 25 milliseconds before the first retry and with the delay increasing\n** by an additional 25 milliseconds with each subsequent retry.  This\n** opcode allows these two values (10 retries and 25 milliseconds of delay)\n** to be adjusted.  The values are changed for all database connections\n** within the same process.  The argument is a pointer to an array of two\n** integers where the first integer is the new retry count and the second\n** integer is the delay.  If either integer is negative, then the setting\n** is not changed but instead the prior value of that setting is written\n** into the array entry, allowing the current retry settings to be\n** interrogated.  The zDbName parameter is ignored.\n**\n** <li>[[SQLITE_FCNTL_PERSIST_WAL]]\n** ^The [SQLITE_FCNTL_PERSIST_WAL] opcode is used to set or query the\n** persistent [WAL | Write Ahead Log] setting.  By default, the auxiliary\n** write ahead log ([WAL file]) and shared memory\n** files used for transaction control\n** are automatically deleted when the latest connection to the database\n** closes.  Setting persistent WAL mode causes those files to persist after\n** close.  Persisting the files is useful when other processes that do not\n** have write permission on the directory containing the database file want\n** to read the database file, as the WAL and shared memory files must exist\n** in order for the database to be readable.  The fourth parameter to\n** [sqlite3_file_control()] for this opcode should be a pointer to an integer.\n** That integer is 0 to disable persistent WAL mode or 1 to enable persistent\n** WAL mode.  If the integer is -1, then it is overwritten with the current\n** WAL persistence setting.\n**\n** <li>[[SQLITE_FCNTL_POWERSAFE_OVERWRITE]]\n** ^The [SQLITE_FCNTL_POWERSAFE_OVERWRITE] opcode is used to set or query the\n** persistent \"powersafe-overwrite\" or \"PSOW\" setting.  The PSOW setting\n** determines the [SQLITE_IOCAP_POWERSAFE_OVERWRITE] bit of the\n** xDeviceCharacteristics methods. The fourth parameter to\n** [sqlite3_file_control()] for this opcode should be a pointer to an integer.\n** That integer is 0 to disable zero-damage mode or 1 to enable zero-damage\n** mode.  If the integer is -1, then it is overwritten with the current\n** zero-damage mode setting.\n**\n** <li>[[SQLITE_FCNTL_OVERWRITE]]\n** ^The [SQLITE_FCNTL_OVERWRITE] opcode is invoked by SQLite after opening\n** a write transaction to indicate that, unless it is rolled back for some\n** reason, the entire database file will be overwritten by the current \n** transaction. This is used by VACUUM operations.\n**\n** <li>[[SQLITE_FCNTL_VFSNAME]]\n** ^The [SQLITE_FCNTL_VFSNAME] opcode can be used to obtain the names of\n** all [VFSes] in the VFS stack.  The names are of all VFS shims and the\n** final bottom-level VFS are written into memory obtained from \n** [sqlite3_malloc()] and the result is stored in the char* variable\n** that the fourth parameter of [sqlite3_file_control()] points to.\n** The caller is responsible for freeing the memory when done.  As with\n** all file-control actions, there is no guarantee that this will actually\n** do anything.  Callers should initialize the char* variable to a NULL\n** pointer in case this file-control is not implemented.  This file-control\n** is intended for diagnostic use only.\n**\n** <li>[[SQLITE_FCNTL_VFS_POINTER]]\n** ^The [SQLITE_FCNTL_VFS_POINTER] opcode finds a pointer to the top-level\n** [VFSes] currently in use.  ^(The argument X in\n** sqlite3_file_control(db,SQLITE_FCNTL_VFS_POINTER,X) must be\n** of type \"[sqlite3_vfs] **\".  This opcodes will set *X\n** to a pointer to the top-level VFS.)^\n** ^When there are multiple VFS shims in the stack, this opcode finds the\n** upper-most shim only.\n**\n** <li>[[SQLITE_FCNTL_PRAGMA]]\n** ^Whenever a [PRAGMA] statement is parsed, an [SQLITE_FCNTL_PRAGMA] \n** file control is sent to the open [sqlite3_file] object corresponding\n** to the database file to which the pragma statement refers. ^The argument\n** to the [SQLITE_FCNTL_PRAGMA] file control is an array of\n** pointers to strings (char**) in which the second element of the array\n** is the name of the pragma and the third element is the argument to the\n** pragma or NULL if the pragma has no argument.  ^The handler for an\n** [SQLITE_FCNTL_PRAGMA] file control can optionally make the first element\n** of the char** argument point to a string obtained from [sqlite3_mprintf()]\n** or the equivalent and that string will become the result of the pragma or\n** the error message if the pragma fails. ^If the\n** [SQLITE_FCNTL_PRAGMA] file control returns [SQLITE_NOTFOUND], then normal \n** [PRAGMA] processing continues.  ^If the [SQLITE_FCNTL_PRAGMA]\n** file control returns [SQLITE_OK], then the parser assumes that the\n** VFS has handled the PRAGMA itself and the parser generates a no-op\n** prepared statement if result string is NULL, or that returns a copy\n** of the result string if the string is non-NULL.\n** ^If the [SQLITE_FCNTL_PRAGMA] file control returns\n** any result code other than [SQLITE_OK] or [SQLITE_NOTFOUND], that means\n** that the VFS encountered an error while handling the [PRAGMA] and the\n** compilation of the PRAGMA fails with an error.  ^The [SQLITE_FCNTL_PRAGMA]\n** file control occurs at the beginning of pragma statement analysis and so\n** it is able to override built-in [PRAGMA] statements.\n**\n** <li>[[SQLITE_FCNTL_BUSYHANDLER]]\n** ^The [SQLITE_FCNTL_BUSYHANDLER]\n** file-control may be invoked by SQLite on the database file handle\n** shortly after it is opened in order to provide a custom VFS with access\n** to the connections busy-handler callback. The argument is of type (void **)\n** - an array of two (void *) values. The first (void *) actually points\n** to a function of type (int (*)(void *)). In order to invoke the connections\n** busy-handler, this function should be invoked with the second (void *) in\n** the array as the only argument. If it returns non-zero, then the operation\n** should be retried. If it returns zero, the custom VFS should abandon the\n** current operation.\n**\n** <li>[[SQLITE_FCNTL_TEMPFILENAME]]\n** ^Application can invoke the [SQLITE_FCNTL_TEMPFILENAME] file-control\n** to have SQLite generate a\n** temporary filename using the same algorithm that is followed to generate\n** temporary filenames for TEMP tables and other internal uses.  The\n** argument should be a char** which will be filled with the filename\n** written into memory obtained from [sqlite3_malloc()].  The caller should\n** invoke [sqlite3_free()] on the result to avoid a memory leak.\n**\n** <li>[[SQLITE_FCNTL_MMAP_SIZE]]\n** The [SQLITE_FCNTL_MMAP_SIZE] file control is used to query or set the\n** maximum number of bytes that will be used for memory-mapped I/O.\n** The argument is a pointer to a value of type sqlite3_int64 that\n** is an advisory maximum number of bytes in the file to memory map.  The\n** pointer is overwritten with the old value.  The limit is not changed if\n** the value originally pointed to is negative, and so the current limit \n** can be queried by passing in a pointer to a negative number.  This\n** file-control is used internally to implement [PRAGMA mmap_size].\n**\n** <li>[[SQLITE_FCNTL_TRACE]]\n** The [SQLITE_FCNTL_TRACE] file control provides advisory information\n** to the VFS about what the higher layers of the SQLite stack are doing.\n** This file control is used by some VFS activity tracing [shims].\n** The argument is a zero-terminated string.  Higher layers in the\n** SQLite stack may generate instances of this file control if\n** the [SQLITE_USE_FCNTL_TRACE] compile-time option is enabled.\n**\n** <li>[[SQLITE_FCNTL_HAS_MOVED]]\n** The [SQLITE_FCNTL_HAS_MOVED] file control interprets its argument as a\n** pointer to an integer and it writes a boolean into that integer depending\n** on whether or not the file has been renamed, moved, or deleted since it\n** was first opened.\n**\n** <li>[[SQLITE_FCNTL_WIN32_GET_HANDLE]]\n** The [SQLITE_FCNTL_WIN32_GET_HANDLE] opcode can be used to obtain the\n** underlying native file handle associated with a file handle.  This file\n** control interprets its argument as a pointer to a native file handle and\n** writes the resulting value there.\n**\n** <li>[[SQLITE_FCNTL_WIN32_SET_HANDLE]]\n** The [SQLITE_FCNTL_WIN32_SET_HANDLE] opcode is used for debugging.  This\n** opcode causes the xFileControl method to swap the file handle with the one\n** pointed to by the pArg argument.  This capability is used during testing\n** and only needs to be supported when SQLITE_TEST is defined.\n**\n** <li>[[SQLITE_FCNTL_WAL_BLOCK]]\n** The [SQLITE_FCNTL_WAL_BLOCK] is a signal to the VFS layer that it might\n** be advantageous to block on the next WAL lock if the lock is not immediately\n** available.  The WAL subsystem issues this signal during rare\n** circumstances in order to fix a problem with priority inversion.\n** Applications should <em>not</em> use this file-control.\n**\n** <li>[[SQLITE_FCNTL_ZIPVFS]]\n** The [SQLITE_FCNTL_ZIPVFS] opcode is implemented by zipvfs only. All other\n** VFS should return SQLITE_NOTFOUND for this opcode.\n**\n** <li>[[SQLITE_FCNTL_RBU]]\n** The [SQLITE_FCNTL_RBU] opcode is implemented by the special VFS used by\n** the RBU extension only.  All other VFS should return SQLITE_NOTFOUND for\n** this opcode.  \n**\n** <li>[[SQLITE_FCNTL_BEGIN_ATOMIC_WRITE]]\n** If the [SQLITE_FCNTL_BEGIN_ATOMIC_WRITE] opcode returns SQLITE_OK, then\n** the file descriptor is placed in \"batch write mode\", which\n** means all subsequent write operations will be deferred and done\n** atomically at the next [SQLITE_FCNTL_COMMIT_ATOMIC_WRITE].  Systems\n** that do not support batch atomic writes will return SQLITE_NOTFOUND.\n** ^Following a successful SQLITE_FCNTL_BEGIN_ATOMIC_WRITE and prior to\n** the closing [SQLITE_FCNTL_COMMIT_ATOMIC_WRITE] or\n** [SQLITE_FCNTL_ROLLBACK_ATOMIC_WRITE], SQLite will make\n** no VFS interface calls on the same [sqlite3_file] file descriptor\n** except for calls to the xWrite method and the xFileControl method\n** with [SQLITE_FCNTL_SIZE_HINT].\n**\n** <li>[[SQLITE_FCNTL_COMMIT_ATOMIC_WRITE]]\n** The [SQLITE_FCNTL_COMMIT_ATOMIC_WRITE] opcode causes all write\n** operations since the previous successful call to \n** [SQLITE_FCNTL_BEGIN_ATOMIC_WRITE] to be performed atomically.\n** This file control returns [SQLITE_OK] if and only if the writes were\n** all performed successfully and have been committed to persistent storage.\n** ^Regardless of whether or not it is successful, this file control takes\n** the file descriptor out of batch write mode so that all subsequent\n** write operations are independent.\n** ^SQLite will never invoke SQLITE_FCNTL_COMMIT_ATOMIC_WRITE without\n** a prior successful call to [SQLITE_FCNTL_BEGIN_ATOMIC_WRITE].\n**\n** <li>[[SQLITE_FCNTL_ROLLBACK_ATOMIC_WRITE]]\n** The [SQLITE_FCNTL_ROLLBACK_ATOMIC_WRITE] opcode causes all write\n** operations since the previous successful call to \n** [SQLITE_FCNTL_BEGIN_ATOMIC_WRITE] to be rolled back.\n** ^This file control takes the file descriptor out of batch write mode\n** so that all subsequent write operations are independent.\n** ^SQLite will never invoke SQLITE_FCNTL_ROLLBACK_ATOMIC_WRITE without\n** a prior successful call to [SQLITE_FCNTL_BEGIN_ATOMIC_WRITE].\n**\n** <li>[[SQLITE_FCNTL_LOCK_TIMEOUT]]\n** The [SQLITE_FCNTL_LOCK_TIMEOUT] opcode causes attempts to obtain\n** a file lock using the xLock or xShmLock methods of the VFS to wait\n** for up to M milliseconds before failing, where M is the single \n** unsigned integer parameter.\n**\n** <li>[[SQLITE_FCNTL_DATA_VERSION]]\n** The [SQLITE_FCNTL_DATA_VERSION] opcode is used to detect changes to\n** a database file.  The argument is a pointer to a 32-bit unsigned integer.\n** The \"data version\" for the pager is written into the pointer.  The\n** \"data version\" changes whenever any change occurs to the corresponding\n** database file, either through SQL statements on the same database\n** connection or through transactions committed by separate database\n** connections possibly in other processes. The [sqlite3_total_changes()]\n** interface can be used to find if any database on the connection has changed,\n** but that interface responds to changes on TEMP as well as MAIN and does\n** not provide a mechanism to detect changes to MAIN only.  Also, the\n** [sqlite3_total_changes()] interface responds to internal changes only and\n** omits changes made by other database connections.  The\n** [PRAGMA data_version] command provide a mechanism to detect changes to\n** a single attached database that occur due to other database connections,\n** but omits changes implemented by the database connection on which it is\n** called.  This file control is the only mechanism to detect changes that\n** happen either internally or externally and that are associated with\n** a particular attached database.\n** </ul>\n*/\n#define SQLITE_FCNTL_LOCKSTATE               1\n#define SQLITE_FCNTL_GET_LOCKPROXYFILE       2\n#define SQLITE_FCNTL_SET_LOCKPROXYFILE       3\n#define SQLITE_FCNTL_LAST_ERRNO              4\n#define SQLITE_FCNTL_SIZE_HINT               5\n#define SQLITE_FCNTL_CHUNK_SIZE              6\n#define SQLITE_FCNTL_FILE_POINTER            7\n#define SQLITE_FCNTL_SYNC_OMITTED            8\n#define SQLITE_FCNTL_WIN32_AV_RETRY          9\n#define SQLITE_FCNTL_PERSIST_WAL            10\n#define SQLITE_FCNTL_OVERWRITE              11\n#define SQLITE_FCNTL_VFSNAME                12\n#define SQLITE_FCNTL_POWERSAFE_OVERWRITE    13\n#define SQLITE_FCNTL_PRAGMA                 14\n#define SQLITE_FCNTL_BUSYHANDLER            15\n#define SQLITE_FCNTL_TEMPFILENAME           16\n#define SQLITE_FCNTL_MMAP_SIZE              18\n#define SQLITE_FCNTL_TRACE                  19\n#define SQLITE_FCNTL_HAS_MOVED              20\n#define SQLITE_FCNTL_SYNC                   21\n#define SQLITE_FCNTL_COMMIT_PHASETWO        22\n#define SQLITE_FCNTL_WIN32_SET_HANDLE       23\n#define SQLITE_FCNTL_WAL_BLOCK              24\n#define SQLITE_FCNTL_ZIPVFS                 25\n#define SQLITE_FCNTL_RBU                    26\n#define SQLITE_FCNTL_VFS_POINTER            27\n#define SQLITE_FCNTL_JOURNAL_POINTER        28\n#define SQLITE_FCNTL_WIN32_GET_HANDLE       29\n#define SQLITE_FCNTL_PDB                    30\n#define SQLITE_FCNTL_BEGIN_ATOMIC_WRITE     31\n#define SQLITE_FCNTL_COMMIT_ATOMIC_WRITE    32\n#define SQLITE_FCNTL_ROLLBACK_ATOMIC_WRITE  33\n#define SQLITE_FCNTL_LOCK_TIMEOUT           34\n#define SQLITE_FCNTL_DATA_VERSION           35\n#define SQLITE_FCNTL_SIZE_LIMIT             36\n\n/* deprecated names */\n#define SQLITE_GET_LOCKPROXYFILE      SQLITE_FCNTL_GET_LOCKPROXYFILE\n#define SQLITE_SET_LOCKPROXYFILE      SQLITE_FCNTL_SET_LOCKPROXYFILE\n#define SQLITE_LAST_ERRNO             SQLITE_FCNTL_LAST_ERRNO\n\n\n/*\n** CAPI3REF: Mutex Handle\n**\n** The mutex module within SQLite defines [sqlite3_mutex] to be an\n** abstract type for a mutex object.  The SQLite core never looks\n** at the internal representation of an [sqlite3_mutex].  It only\n** deals with pointers to the [sqlite3_mutex] object.\n**\n** Mutexes are created using [sqlite3_mutex_alloc()].\n*/\ntypedef struct sqlite3_mutex sqlite3_mutex;\n\n/*\n** CAPI3REF: Loadable Extension Thunk\n**\n** A pointer to the opaque sqlite3_api_routines structure is passed as\n** the third parameter to entry points of [loadable extensions].  This\n** structure must be typedefed in order to work around compiler warnings\n** on some platforms.\n*/\ntypedef struct sqlite3_api_routines sqlite3_api_routines;\n\n/*\n** CAPI3REF: OS Interface Object\n**\n** An instance of the sqlite3_vfs object defines the interface between\n** the SQLite core and the underlying operating system.  The \"vfs\"\n** in the name of the object stands for \"virtual file system\".  See\n** the [VFS | VFS documentation] for further information.\n**\n** The VFS interface is sometimes extended by adding new methods onto\n** the end.  Each time such an extension occurs, the iVersion field\n** is incremented.  The iVersion value started out as 1 in\n** SQLite [version 3.5.0] on [dateof:3.5.0], then increased to 2\n** with SQLite [version 3.7.0] on [dateof:3.7.0], and then increased\n** to 3 with SQLite [version 3.7.6] on [dateof:3.7.6].  Additional fields\n** may be appended to the sqlite3_vfs object and the iVersion value\n** may increase again in future versions of SQLite.\n** Note that the structure\n** of the sqlite3_vfs object changes in the transition from\n** SQLite [version 3.5.9] to [version 3.6.0] on [dateof:3.6.0]\n** and yet the iVersion field was not modified.\n**\n** The szOsFile field is the size of the subclassed [sqlite3_file]\n** structure used by this VFS.  mxPathname is the maximum length of\n** a pathname in this VFS.\n**\n** Registered sqlite3_vfs objects are kept on a linked list formed by\n** the pNext pointer.  The [sqlite3_vfs_register()]\n** and [sqlite3_vfs_unregister()] interfaces manage this list\n** in a thread-safe way.  The [sqlite3_vfs_find()] interface\n** searches the list.  Neither the application code nor the VFS\n** implementation should use the pNext pointer.\n**\n** The pNext field is the only field in the sqlite3_vfs\n** structure that SQLite will ever modify.  SQLite will only access\n** or modify this field while holding a particular static mutex.\n** The application should never modify anything within the sqlite3_vfs\n** object once the object has been registered.\n**\n** The zName field holds the name of the VFS module.  The name must\n** be unique across all VFS modules.\n**\n** [[sqlite3_vfs.xOpen]]\n** ^SQLite guarantees that the zFilename parameter to xOpen\n** is either a NULL pointer or string obtained\n** from xFullPathname() with an optional suffix added.\n** ^If a suffix is added to the zFilename parameter, it will\n** consist of a single \"-\" character followed by no more than\n** 11 alphanumeric and/or \"-\" characters.\n** ^SQLite further guarantees that\n** the string will be valid and unchanged until xClose() is\n** called. Because of the previous sentence,\n** the [sqlite3_file] can safely store a pointer to the\n** filename if it needs to remember the filename for some reason.\n** If the zFilename parameter to xOpen is a NULL pointer then xOpen\n** must invent its own temporary name for the file.  ^Whenever the \n** xFilename parameter is NULL it will also be the case that the\n** flags parameter will include [SQLITE_OPEN_DELETEONCLOSE].\n**\n** The flags argument to xOpen() includes all bits set in\n** the flags argument to [sqlite3_open_v2()].  Or if [sqlite3_open()]\n** or [sqlite3_open16()] is used, then flags includes at least\n** [SQLITE_OPEN_READWRITE] | [SQLITE_OPEN_CREATE]. \n** If xOpen() opens a file read-only then it sets *pOutFlags to\n** include [SQLITE_OPEN_READONLY].  Other bits in *pOutFlags may be set.\n**\n** ^(SQLite will also add one of the following flags to the xOpen()\n** call, depending on the object being opened:\n**\n** <ul>\n** <li>  [SQLITE_OPEN_MAIN_DB]\n** <li>  [SQLITE_OPEN_MAIN_JOURNAL]\n** <li>  [SQLITE_OPEN_TEMP_DB]\n** <li>  [SQLITE_OPEN_TEMP_JOURNAL]\n** <li>  [SQLITE_OPEN_TRANSIENT_DB]\n** <li>  [SQLITE_OPEN_SUBJOURNAL]\n** <li>  [SQLITE_OPEN_MASTER_JOURNAL]\n** <li>  [SQLITE_OPEN_WAL]\n** </ul>)^\n**\n** The file I/O implementation can use the object type flags to\n** change the way it deals with files.  For example, an application\n** that does not care about crash recovery or rollback might make\n** the open of a journal file a no-op.  Writes to this journal would\n** also be no-ops, and any attempt to read the journal would return\n** SQLITE_IOERR.  Or the implementation might recognize that a database\n** file will be doing page-aligned sector reads and writes in a random\n** order and set up its I/O subsystem accordingly.\n**\n** SQLite might also add one of the following flags to the xOpen method:\n**\n** <ul>\n** <li> [SQLITE_OPEN_DELETEONCLOSE]\n** <li> [SQLITE_OPEN_EXCLUSIVE]\n** </ul>\n**\n** The [SQLITE_OPEN_DELETEONCLOSE] flag means the file should be\n** deleted when it is closed.  ^The [SQLITE_OPEN_DELETEONCLOSE]\n** will be set for TEMP databases and their journals, transient\n** databases, and subjournals.\n**\n** ^The [SQLITE_OPEN_EXCLUSIVE] flag is always used in conjunction\n** with the [SQLITE_OPEN_CREATE] flag, which are both directly\n** analogous to the O_EXCL and O_CREAT flags of the POSIX open()\n** API.  The SQLITE_OPEN_EXCLUSIVE flag, when paired with the \n** SQLITE_OPEN_CREATE, is used to indicate that file should always\n** be created, and that it is an error if it already exists.\n** It is <i>not</i> used to indicate the file should be opened \n** for exclusive access.\n**\n** ^At least szOsFile bytes of memory are allocated by SQLite\n** to hold the  [sqlite3_file] structure passed as the third\n** argument to xOpen.  The xOpen method does not have to\n** allocate the structure; it should just fill it in.  Note that\n** the xOpen method must set the sqlite3_file.pMethods to either\n** a valid [sqlite3_io_methods] object or to NULL.  xOpen must do\n** this even if the open fails.  SQLite expects that the sqlite3_file.pMethods\n** element will be valid after xOpen returns regardless of the success\n** or failure of the xOpen call.\n**\n** [[sqlite3_vfs.xAccess]]\n** ^The flags argument to xAccess() may be [SQLITE_ACCESS_EXISTS]\n** to test for the existence of a file, or [SQLITE_ACCESS_READWRITE] to\n** test whether a file is readable and writable, or [SQLITE_ACCESS_READ]\n** to test whether a file is at least readable.   The file can be a\n** directory.\n**\n** ^SQLite will always allocate at least mxPathname+1 bytes for the\n** output buffer xFullPathname.  The exact size of the output buffer\n** is also passed as a parameter to both  methods. If the output buffer\n** is not large enough, [SQLITE_CANTOPEN] should be returned. Since this is\n** handled as a fatal error by SQLite, vfs implementations should endeavor\n** to prevent this by setting mxPathname to a sufficiently large value.\n**\n** The xRandomness(), xSleep(), xCurrentTime(), and xCurrentTimeInt64()\n** interfaces are not strictly a part of the filesystem, but they are\n** included in the VFS structure for completeness.\n** The xRandomness() function attempts to return nBytes bytes\n** of good-quality randomness into zOut.  The return value is\n** the actual number of bytes of randomness obtained.\n** The xSleep() method causes the calling thread to sleep for at\n** least the number of microseconds given.  ^The xCurrentTime()\n** method returns a Julian Day Number for the current date and time as\n** a floating point value.\n** ^The xCurrentTimeInt64() method returns, as an integer, the Julian\n** Day Number multiplied by 86400000 (the number of milliseconds in \n** a 24-hour day).  \n** ^SQLite will use the xCurrentTimeInt64() method to get the current\n** date and time if that method is available (if iVersion is 2 or \n** greater and the function pointer is not NULL) and will fall back\n** to xCurrentTime() if xCurrentTimeInt64() is unavailable.\n**\n** ^The xSetSystemCall(), xGetSystemCall(), and xNestSystemCall() interfaces\n** are not used by the SQLite core.  These optional interfaces are provided\n** by some VFSes to facilitate testing of the VFS code. By overriding \n** system calls with functions under its control, a test program can\n** simulate faults and error conditions that would otherwise be difficult\n** or impossible to induce.  The set of system calls that can be overridden\n** varies from one VFS to another, and from one version of the same VFS to the\n** next.  Applications that use these interfaces must be prepared for any\n** or all of these interfaces to be NULL or for their behavior to change\n** from one release to the next.  Applications must not attempt to access\n** any of these methods if the iVersion of the VFS is less than 3.\n*/\ntypedef struct sqlite3_vfs sqlite3_vfs;\ntypedef void (*sqlite3_syscall_ptr)(void);\nstruct sqlite3_vfs {\n  int iVersion;            /* Structure version number (currently 3) */\n  int szOsFile;            /* Size of subclassed sqlite3_file */\n  int mxPathname;          /* Maximum file pathname length */\n  sqlite3_vfs *pNext;      /* Next registered VFS */\n  const char *zName;       /* Name of this virtual file system */\n  void *pAppData;          /* Pointer to application-specific data */\n  int (*xOpen)(sqlite3_vfs*, const char *zName, sqlite3_file*,\n               int flags, int *pOutFlags);\n  int (*xDelete)(sqlite3_vfs*, const char *zName, int syncDir);\n  int (*xAccess)(sqlite3_vfs*, const char *zName, int flags, int *pResOut);\n  int (*xFullPathname)(sqlite3_vfs*, const char *zName, int nOut, char *zOut);\n  void *(*xDlOpen)(sqlite3_vfs*, const char *zFilename);\n  void (*xDlError)(sqlite3_vfs*, int nByte, char *zErrMsg);\n  void (*(*xDlSym)(sqlite3_vfs*,void*, const char *zSymbol))(void);\n  void (*xDlClose)(sqlite3_vfs*, void*);\n  int (*xRandomness)(sqlite3_vfs*, int nByte, char *zOut);\n  int (*xSleep)(sqlite3_vfs*, int microseconds);\n  int (*xCurrentTime)(sqlite3_vfs*, double*);\n  int (*xGetLastError)(sqlite3_vfs*, int, char *);\n  /*\n  ** The methods above are in version 1 of the sqlite_vfs object\n  ** definition.  Those that follow are added in version 2 or later\n  */\n  int (*xCurrentTimeInt64)(sqlite3_vfs*, sqlite3_int64*);\n  /*\n  ** The methods above are in versions 1 and 2 of the sqlite_vfs object.\n  ** Those below are for version 3 and greater.\n  */\n  int (*xSetSystemCall)(sqlite3_vfs*, const char *zName, sqlite3_syscall_ptr);\n  sqlite3_syscall_ptr (*xGetSystemCall)(sqlite3_vfs*, const char *zName);\n  const char *(*xNextSystemCall)(sqlite3_vfs*, const char *zName);\n  /*\n  ** The methods above are in versions 1 through 3 of the sqlite_vfs object.\n  ** New fields may be appended in future versions.  The iVersion\n  ** value will increment whenever this happens. \n  */\n};\n\n/*\n** CAPI3REF: Flags for the xAccess VFS method\n**\n** These integer constants can be used as the third parameter to\n** the xAccess method of an [sqlite3_vfs] object.  They determine\n** what kind of permissions the xAccess method is looking for.\n** With SQLITE_ACCESS_EXISTS, the xAccess method\n** simply checks whether the file exists.\n** With SQLITE_ACCESS_READWRITE, the xAccess method\n** checks whether the named directory is both readable and writable\n** (in other words, if files can be added, removed, and renamed within\n** the directory).\n** The SQLITE_ACCESS_READWRITE constant is currently used only by the\n** [temp_store_directory pragma], though this could change in a future\n** release of SQLite.\n** With SQLITE_ACCESS_READ, the xAccess method\n** checks whether the file is readable.  The SQLITE_ACCESS_READ constant is\n** currently unused, though it might be used in a future release of\n** SQLite.\n*/\n#define SQLITE_ACCESS_EXISTS    0\n#define SQLITE_ACCESS_READWRITE 1   /* Used by PRAGMA temp_store_directory */\n#define SQLITE_ACCESS_READ      2   /* Unused */\n\n/*\n** CAPI3REF: Flags for the xShmLock VFS method\n**\n** These integer constants define the various locking operations\n** allowed by the xShmLock method of [sqlite3_io_methods].  The\n** following are the only legal combinations of flags to the\n** xShmLock method:\n**\n** <ul>\n** <li>  SQLITE_SHM_LOCK | SQLITE_SHM_SHARED\n** <li>  SQLITE_SHM_LOCK | SQLITE_SHM_EXCLUSIVE\n** <li>  SQLITE_SHM_UNLOCK | SQLITE_SHM_SHARED\n** <li>  SQLITE_SHM_UNLOCK | SQLITE_SHM_EXCLUSIVE\n** </ul>\n**\n** When unlocking, the same SHARED or EXCLUSIVE flag must be supplied as\n** was given on the corresponding lock.  \n**\n** The xShmLock method can transition between unlocked and SHARED or\n** between unlocked and EXCLUSIVE.  It cannot transition between SHARED\n** and EXCLUSIVE.\n*/\n#define SQLITE_SHM_UNLOCK       1\n#define SQLITE_SHM_LOCK         2\n#define SQLITE_SHM_SHARED       4\n#define SQLITE_SHM_EXCLUSIVE    8\n\n/*\n** CAPI3REF: Maximum xShmLock index\n**\n** The xShmLock method on [sqlite3_io_methods] may use values\n** between 0 and this upper bound as its \"offset\" argument.\n** The SQLite core will never attempt to acquire or release a\n** lock outside of this range\n*/\n#define SQLITE_SHM_NLOCK        8\n\n\n/*\n** CAPI3REF: Initialize The SQLite Library\n**\n** ^The sqlite3_initialize() routine initializes the\n** SQLite library.  ^The sqlite3_shutdown() routine\n** deallocates any resources that were allocated by sqlite3_initialize().\n** These routines are designed to aid in process initialization and\n** shutdown on embedded systems.  Workstation applications using\n** SQLite normally do not need to invoke either of these routines.\n**\n** A call to sqlite3_initialize() is an \"effective\" call if it is\n** the first time sqlite3_initialize() is invoked during the lifetime of\n** the process, or if it is the first time sqlite3_initialize() is invoked\n** following a call to sqlite3_shutdown().  ^(Only an effective call\n** of sqlite3_initialize() does any initialization.  All other calls\n** are harmless no-ops.)^\n**\n** A call to sqlite3_shutdown() is an \"effective\" call if it is the first\n** call to sqlite3_shutdown() since the last sqlite3_initialize().  ^(Only\n** an effective call to sqlite3_shutdown() does any deinitialization.\n** All other valid calls to sqlite3_shutdown() are harmless no-ops.)^\n**\n** The sqlite3_initialize() interface is threadsafe, but sqlite3_shutdown()\n** is not.  The sqlite3_shutdown() interface must only be called from a\n** single thread.  All open [database connections] must be closed and all\n** other SQLite resources must be deallocated prior to invoking\n** sqlite3_shutdown().\n**\n** Among other things, ^sqlite3_initialize() will invoke\n** sqlite3_os_init().  Similarly, ^sqlite3_shutdown()\n** will invoke sqlite3_os_end().\n**\n** ^The sqlite3_initialize() routine returns [SQLITE_OK] on success.\n** ^If for some reason, sqlite3_initialize() is unable to initialize\n** the library (perhaps it is unable to allocate a needed resource such\n** as a mutex) it returns an [error code] other than [SQLITE_OK].\n**\n** ^The sqlite3_initialize() routine is called internally by many other\n** SQLite interfaces so that an application usually does not need to\n** invoke sqlite3_initialize() directly.  For example, [sqlite3_open()]\n** calls sqlite3_initialize() so the SQLite library will be automatically\n** initialized when [sqlite3_open()] is called if it has not be initialized\n** already.  ^However, if SQLite is compiled with the [SQLITE_OMIT_AUTOINIT]\n** compile-time option, then the automatic calls to sqlite3_initialize()\n** are omitted and the application must call sqlite3_initialize() directly\n** prior to using any other SQLite interface.  For maximum portability,\n** it is recommended that applications always invoke sqlite3_initialize()\n** directly prior to using any other SQLite interface.  Future releases\n** of SQLite may require this.  In other words, the behavior exhibited\n** when SQLite is compiled with [SQLITE_OMIT_AUTOINIT] might become the\n** default behavior in some future release of SQLite.\n**\n** The sqlite3_os_init() routine does operating-system specific\n** initialization of the SQLite library.  The sqlite3_os_end()\n** routine undoes the effect of sqlite3_os_init().  Typical tasks\n** performed by these routines include allocation or deallocation\n** of static resources, initialization of global variables,\n** setting up a default [sqlite3_vfs] module, or setting up\n** a default configuration using [sqlite3_config()].\n**\n** The application should never invoke either sqlite3_os_init()\n** or sqlite3_os_end() directly.  The application should only invoke\n** sqlite3_initialize() and sqlite3_shutdown().  The sqlite3_os_init()\n** interface is called automatically by sqlite3_initialize() and\n** sqlite3_os_end() is called by sqlite3_shutdown().  Appropriate\n** implementations for sqlite3_os_init() and sqlite3_os_end()\n** are built into SQLite when it is compiled for Unix, Windows, or OS/2.\n** When [custom builds | built for other platforms]\n** (using the [SQLITE_OS_OTHER=1] compile-time\n** option) the application must supply a suitable implementation for\n** sqlite3_os_init() and sqlite3_os_end().  An application-supplied\n** implementation of sqlite3_os_init() or sqlite3_os_end()\n** must return [SQLITE_OK] on success and some other [error code] upon\n** failure.\n*/\nSQLITE_API int sqlite3_initialize(void);\nSQLITE_API int sqlite3_shutdown(void);\nSQLITE_API int sqlite3_os_init(void);\nSQLITE_API int sqlite3_os_end(void);\n\n/*\n** CAPI3REF: Configuring The SQLite Library\n**\n** The sqlite3_config() interface is used to make global configuration\n** changes to SQLite in order to tune SQLite to the specific needs of\n** the application.  The default configuration is recommended for most\n** applications and so this routine is usually not necessary.  It is\n** provided to support rare applications with unusual needs.\n**\n** <b>The sqlite3_config() interface is not threadsafe. The application\n** must ensure that no other SQLite interfaces are invoked by other\n** threads while sqlite3_config() is running.</b>\n**\n** The sqlite3_config() interface\n** may only be invoked prior to library initialization using\n** [sqlite3_initialize()] or after shutdown by [sqlite3_shutdown()].\n** ^If sqlite3_config() is called after [sqlite3_initialize()] and before\n** [sqlite3_shutdown()] then it will return SQLITE_MISUSE.\n** Note, however, that ^sqlite3_config() can be called as part of the\n** implementation of an application-defined [sqlite3_os_init()].\n**\n** The first argument to sqlite3_config() is an integer\n** [configuration option] that determines\n** what property of SQLite is to be configured.  Subsequent arguments\n** vary depending on the [configuration option]\n** in the first argument.\n**\n** ^When a configuration option is set, sqlite3_config() returns [SQLITE_OK].\n** ^If the option is unknown or SQLite is unable to set the option\n** then this routine returns a non-zero [error code].\n*/\nSQLITE_API int sqlite3_config(int, ...);\n\n/*\n** CAPI3REF: Configure database connections\n** METHOD: sqlite3\n**\n** The sqlite3_db_config() interface is used to make configuration\n** changes to a [database connection].  The interface is similar to\n** [sqlite3_config()] except that the changes apply to a single\n** [database connection] (specified in the first argument).\n**\n** The second argument to sqlite3_db_config(D,V,...)  is the\n** [SQLITE_DBCONFIG_LOOKASIDE | configuration verb] - an integer code \n** that indicates what aspect of the [database connection] is being configured.\n** Subsequent arguments vary depending on the configuration verb.\n**\n** ^Calls to sqlite3_db_config() return SQLITE_OK if and only if\n** the call is considered successful.\n*/\nSQLITE_API int sqlite3_db_config(sqlite3*, int op, ...);\n\n/*\n** CAPI3REF: Memory Allocation Routines\n**\n** An instance of this object defines the interface between SQLite\n** and low-level memory allocation routines.\n**\n** This object is used in only one place in the SQLite interface.\n** A pointer to an instance of this object is the argument to\n** [sqlite3_config()] when the configuration option is\n** [SQLITE_CONFIG_MALLOC] or [SQLITE_CONFIG_GETMALLOC].  \n** By creating an instance of this object\n** and passing it to [sqlite3_config]([SQLITE_CONFIG_MALLOC])\n** during configuration, an application can specify an alternative\n** memory allocation subsystem for SQLite to use for all of its\n** dynamic memory needs.\n**\n** Note that SQLite comes with several [built-in memory allocators]\n** that are perfectly adequate for the overwhelming majority of applications\n** and that this object is only useful to a tiny minority of applications\n** with specialized memory allocation requirements.  This object is\n** also used during testing of SQLite in order to specify an alternative\n** memory allocator that simulates memory out-of-memory conditions in\n** order to verify that SQLite recovers gracefully from such\n** conditions.\n**\n** The xMalloc, xRealloc, and xFree methods must work like the\n** malloc(), realloc() and free() functions from the standard C library.\n** ^SQLite guarantees that the second argument to\n** xRealloc is always a value returned by a prior call to xRoundup.\n**\n** xSize should return the allocated size of a memory allocation\n** previously obtained from xMalloc or xRealloc.  The allocated size\n** is always at least as big as the requested size but may be larger.\n**\n** The xRoundup method returns what would be the allocated size of\n** a memory allocation given a particular requested size.  Most memory\n** allocators round up memory allocations at least to the next multiple\n** of 8.  Some allocators round up to a larger multiple or to a power of 2.\n** Every memory allocation request coming in through [sqlite3_malloc()]\n** or [sqlite3_realloc()] first calls xRoundup.  If xRoundup returns 0, \n** that causes the corresponding memory allocation to fail.\n**\n** The xInit method initializes the memory allocator.  For example,\n** it might allocate any require mutexes or initialize internal data\n** structures.  The xShutdown method is invoked (indirectly) by\n** [sqlite3_shutdown()] and should deallocate any resources acquired\n** by xInit.  The pAppData pointer is used as the only parameter to\n** xInit and xShutdown.\n**\n** SQLite holds the [SQLITE_MUTEX_STATIC_MASTER] mutex when it invokes\n** the xInit method, so the xInit method need not be threadsafe.  The\n** xShutdown method is only called from [sqlite3_shutdown()] so it does\n** not need to be threadsafe either.  For all other methods, SQLite\n** holds the [SQLITE_MUTEX_STATIC_MEM] mutex as long as the\n** [SQLITE_CONFIG_MEMSTATUS] configuration option is turned on (which\n** it is by default) and so the methods are automatically serialized.\n** However, if [SQLITE_CONFIG_MEMSTATUS] is disabled, then the other\n** methods must be threadsafe or else make their own arrangements for\n** serialization.\n**\n** SQLite will never invoke xInit() more than once without an intervening\n** call to xShutdown().\n*/\ntypedef struct sqlite3_mem_methods sqlite3_mem_methods;\nstruct sqlite3_mem_methods {\n  void *(*xMalloc)(int);         /* Memory allocation function */\n  void (*xFree)(void*);          /* Free a prior allocation */\n  void *(*xRealloc)(void*,int);  /* Resize an allocation */\n  int (*xSize)(void*);           /* Return the size of an allocation */\n  int (*xRoundup)(int);          /* Round up request size to allocation size */\n  int (*xInit)(void*);           /* Initialize the memory allocator */\n  void (*xShutdown)(void*);      /* Deinitialize the memory allocator */\n  void *pAppData;                /* Argument to xInit() and xShutdown() */\n};\n\n/*\n** CAPI3REF: Configuration Options\n** KEYWORDS: {configuration option}\n**\n** These constants are the available integer configuration options that\n** can be passed as the first argument to the [sqlite3_config()] interface.\n**\n** New configuration options may be added in future releases of SQLite.\n** Existing configuration options might be discontinued.  Applications\n** should check the return code from [sqlite3_config()] to make sure that\n** the call worked.  The [sqlite3_config()] interface will return a\n** non-zero [error code] if a discontinued or unsupported configuration option\n** is invoked.\n**\n** <dl>\n** [[SQLITE_CONFIG_SINGLETHREAD]] <dt>SQLITE_CONFIG_SINGLETHREAD</dt>\n** <dd>There are no arguments to this option.  ^This option sets the\n** [threading mode] to Single-thread.  In other words, it disables\n** all mutexing and puts SQLite into a mode where it can only be used\n** by a single thread.   ^If SQLite is compiled with\n** the [SQLITE_THREADSAFE | SQLITE_THREADSAFE=0] compile-time option then\n** it is not possible to change the [threading mode] from its default\n** value of Single-thread and so [sqlite3_config()] will return \n** [SQLITE_ERROR] if called with the SQLITE_CONFIG_SINGLETHREAD\n** configuration option.</dd>\n**\n** [[SQLITE_CONFIG_MULTITHREAD]] <dt>SQLITE_CONFIG_MULTITHREAD</dt>\n** <dd>There are no arguments to this option.  ^This option sets the\n** [threading mode] to Multi-thread.  In other words, it disables\n** mutexing on [database connection] and [prepared statement] objects.\n** The application is responsible for serializing access to\n** [database connections] and [prepared statements].  But other mutexes\n** are enabled so that SQLite will be safe to use in a multi-threaded\n** environment as long as no two threads attempt to use the same\n** [database connection] at the same time.  ^If SQLite is compiled with\n** the [SQLITE_THREADSAFE | SQLITE_THREADSAFE=0] compile-time option then\n** it is not possible to set the Multi-thread [threading mode] and\n** [sqlite3_config()] will return [SQLITE_ERROR] if called with the\n** SQLITE_CONFIG_MULTITHREAD configuration option.</dd>\n**\n** [[SQLITE_CONFIG_SERIALIZED]] <dt>SQLITE_CONFIG_SERIALIZED</dt>\n** <dd>There are no arguments to this option.  ^This option sets the\n** [threading mode] to Serialized. In other words, this option enables\n** all mutexes including the recursive\n** mutexes on [database connection] and [prepared statement] objects.\n** In this mode (which is the default when SQLite is compiled with\n** [SQLITE_THREADSAFE=1]) the SQLite library will itself serialize access\n** to [database connections] and [prepared statements] so that the\n** application is free to use the same [database connection] or the\n** same [prepared statement] in different threads at the same time.\n** ^If SQLite is compiled with\n** the [SQLITE_THREADSAFE | SQLITE_THREADSAFE=0] compile-time option then\n** it is not possible to set the Serialized [threading mode] and\n** [sqlite3_config()] will return [SQLITE_ERROR] if called with the\n** SQLITE_CONFIG_SERIALIZED configuration option.</dd>\n**\n** [[SQLITE_CONFIG_MALLOC]] <dt>SQLITE_CONFIG_MALLOC</dt>\n** <dd> ^(The SQLITE_CONFIG_MALLOC option takes a single argument which is \n** a pointer to an instance of the [sqlite3_mem_methods] structure.\n** The argument specifies\n** alternative low-level memory allocation routines to be used in place of\n** the memory allocation routines built into SQLite.)^ ^SQLite makes\n** its own private copy of the content of the [sqlite3_mem_methods] structure\n** before the [sqlite3_config()] call returns.</dd>\n**\n** [[SQLITE_CONFIG_GETMALLOC]] <dt>SQLITE_CONFIG_GETMALLOC</dt>\n** <dd> ^(The SQLITE_CONFIG_GETMALLOC option takes a single argument which\n** is a pointer to an instance of the [sqlite3_mem_methods] structure.\n** The [sqlite3_mem_methods]\n** structure is filled with the currently defined memory allocation routines.)^\n** This option can be used to overload the default memory allocation\n** routines with a wrapper that simulations memory allocation failure or\n** tracks memory usage, for example. </dd>\n**\n** [[SQLITE_CONFIG_SMALL_MALLOC]] <dt>SQLITE_CONFIG_SMALL_MALLOC</dt>\n** <dd> ^The SQLITE_CONFIG_SMALL_MALLOC option takes single argument of\n** type int, interpreted as a boolean, which if true provides a hint to\n** SQLite that it should avoid large memory allocations if possible.\n** SQLite will run faster if it is free to make large memory allocations,\n** but some application might prefer to run slower in exchange for\n** guarantees about memory fragmentation that are possible if large\n** allocations are avoided.  This hint is normally off.\n** </dd>\n**\n** [[SQLITE_CONFIG_MEMSTATUS]] <dt>SQLITE_CONFIG_MEMSTATUS</dt>\n** <dd> ^The SQLITE_CONFIG_MEMSTATUS option takes single argument of type int,\n** interpreted as a boolean, which enables or disables the collection of\n** memory allocation statistics. ^(When memory allocation statistics are\n** disabled, the following SQLite interfaces become non-operational:\n**   <ul>\n**   <li> [sqlite3_memory_used()]\n**   <li> [sqlite3_memory_highwater()]\n**   <li> [sqlite3_soft_heap_limit64()]\n**   <li> [sqlite3_status64()]\n**   </ul>)^\n** ^Memory allocation statistics are enabled by default unless SQLite is\n** compiled with [SQLITE_DEFAULT_MEMSTATUS]=0 in which case memory\n** allocation statistics are disabled by default.\n** </dd>\n**\n** [[SQLITE_CONFIG_SCRATCH]] <dt>SQLITE_CONFIG_SCRATCH</dt>\n** <dd> The SQLITE_CONFIG_SCRATCH option is no longer used.\n** </dd>\n**\n** [[SQLITE_CONFIG_PAGECACHE]] <dt>SQLITE_CONFIG_PAGECACHE</dt>\n** <dd> ^The SQLITE_CONFIG_PAGECACHE option specifies a memory pool\n** that SQLite can use for the database page cache with the default page\n** cache implementation.  \n** This configuration option is a no-op if an application-define page\n** cache implementation is loaded using the [SQLITE_CONFIG_PCACHE2].\n** ^There are three arguments to SQLITE_CONFIG_PAGECACHE: A pointer to\n** 8-byte aligned memory (pMem), the size of each page cache line (sz),\n** and the number of cache lines (N).\n** The sz argument should be the size of the largest database page\n** (a power of two between 512 and 65536) plus some extra bytes for each\n** page header.  ^The number of extra bytes needed by the page header\n** can be determined using [SQLITE_CONFIG_PCACHE_HDRSZ].\n** ^It is harmless, apart from the wasted memory,\n** for the sz parameter to be larger than necessary.  The pMem\n** argument must be either a NULL pointer or a pointer to an 8-byte\n** aligned block of memory of at least sz*N bytes, otherwise\n** subsequent behavior is undefined.\n** ^When pMem is not NULL, SQLite will strive to use the memory provided\n** to satisfy page cache needs, falling back to [sqlite3_malloc()] if\n** a page cache line is larger than sz bytes or if all of the pMem buffer\n** is exhausted.\n** ^If pMem is NULL and N is non-zero, then each database connection\n** does an initial bulk allocation for page cache memory\n** from [sqlite3_malloc()] sufficient for N cache lines if N is positive or\n** of -1024*N bytes if N is negative, . ^If additional\n** page cache memory is needed beyond what is provided by the initial\n** allocation, then SQLite goes to [sqlite3_malloc()] separately for each\n** additional cache line. </dd>\n**\n** [[SQLITE_CONFIG_HEAP]] <dt>SQLITE_CONFIG_HEAP</dt>\n** <dd> ^The SQLITE_CONFIG_HEAP option specifies a static memory buffer \n** that SQLite will use for all of its dynamic memory allocation needs\n** beyond those provided for by [SQLITE_CONFIG_PAGECACHE].\n** ^The SQLITE_CONFIG_HEAP option is only available if SQLite is compiled\n** with either [SQLITE_ENABLE_MEMSYS3] or [SQLITE_ENABLE_MEMSYS5] and returns\n** [SQLITE_ERROR] if invoked otherwise.\n** ^There are three arguments to SQLITE_CONFIG_HEAP:\n** An 8-byte aligned pointer to the memory,\n** the number of bytes in the memory buffer, and the minimum allocation size.\n** ^If the first pointer (the memory pointer) is NULL, then SQLite reverts\n** to using its default memory allocator (the system malloc() implementation),\n** undoing any prior invocation of [SQLITE_CONFIG_MALLOC].  ^If the\n** memory pointer is not NULL then the alternative memory\n** allocator is engaged to handle all of SQLites memory allocation needs.\n** The first pointer (the memory pointer) must be aligned to an 8-byte\n** boundary or subsequent behavior of SQLite will be undefined.\n** The minimum allocation size is capped at 2**12. Reasonable values\n** for the minimum allocation size are 2**5 through 2**8.</dd>\n**\n** [[SQLITE_CONFIG_MUTEX]] <dt>SQLITE_CONFIG_MUTEX</dt>\n** <dd> ^(The SQLITE_CONFIG_MUTEX option takes a single argument which is a\n** pointer to an instance of the [sqlite3_mutex_methods] structure.\n** The argument specifies alternative low-level mutex routines to be used\n** in place the mutex routines built into SQLite.)^  ^SQLite makes a copy of\n** the content of the [sqlite3_mutex_methods] structure before the call to\n** [sqlite3_config()] returns. ^If SQLite is compiled with\n** the [SQLITE_THREADSAFE | SQLITE_THREADSAFE=0] compile-time option then\n** the entire mutexing subsystem is omitted from the build and hence calls to\n** [sqlite3_config()] with the SQLITE_CONFIG_MUTEX configuration option will\n** return [SQLITE_ERROR].</dd>\n**\n** [[SQLITE_CONFIG_GETMUTEX]] <dt>SQLITE_CONFIG_GETMUTEX</dt>\n** <dd> ^(The SQLITE_CONFIG_GETMUTEX option takes a single argument which\n** is a pointer to an instance of the [sqlite3_mutex_methods] structure.  The\n** [sqlite3_mutex_methods]\n** structure is filled with the currently defined mutex routines.)^\n** This option can be used to overload the default mutex allocation\n** routines with a wrapper used to track mutex usage for performance\n** profiling or testing, for example.   ^If SQLite is compiled with\n** the [SQLITE_THREADSAFE | SQLITE_THREADSAFE=0] compile-time option then\n** the entire mutexing subsystem is omitted from the build and hence calls to\n** [sqlite3_config()] with the SQLITE_CONFIG_GETMUTEX configuration option will\n** return [SQLITE_ERROR].</dd>\n**\n** [[SQLITE_CONFIG_LOOKASIDE]] <dt>SQLITE_CONFIG_LOOKASIDE</dt>\n** <dd> ^(The SQLITE_CONFIG_LOOKASIDE option takes two arguments that determine\n** the default size of lookaside memory on each [database connection].\n** The first argument is the\n** size of each lookaside buffer slot and the second is the number of\n** slots allocated to each database connection.)^  ^(SQLITE_CONFIG_LOOKASIDE\n** sets the <i>default</i> lookaside size. The [SQLITE_DBCONFIG_LOOKASIDE]\n** option to [sqlite3_db_config()] can be used to change the lookaside\n** configuration on individual connections.)^ </dd>\n**\n** [[SQLITE_CONFIG_PCACHE2]] <dt>SQLITE_CONFIG_PCACHE2</dt>\n** <dd> ^(The SQLITE_CONFIG_PCACHE2 option takes a single argument which is \n** a pointer to an [sqlite3_pcache_methods2] object.  This object specifies\n** the interface to a custom page cache implementation.)^\n** ^SQLite makes a copy of the [sqlite3_pcache_methods2] object.</dd>\n**\n** [[SQLITE_CONFIG_GETPCACHE2]] <dt>SQLITE_CONFIG_GETPCACHE2</dt>\n** <dd> ^(The SQLITE_CONFIG_GETPCACHE2 option takes a single argument which\n** is a pointer to an [sqlite3_pcache_methods2] object.  SQLite copies of\n** the current page cache implementation into that object.)^ </dd>\n**\n** [[SQLITE_CONFIG_LOG]] <dt>SQLITE_CONFIG_LOG</dt>\n** <dd> The SQLITE_CONFIG_LOG option is used to configure the SQLite\n** global [error log].\n** (^The SQLITE_CONFIG_LOG option takes two arguments: a pointer to a\n** function with a call signature of void(*)(void*,int,const char*), \n** and a pointer to void. ^If the function pointer is not NULL, it is\n** invoked by [sqlite3_log()] to process each logging event.  ^If the\n** function pointer is NULL, the [sqlite3_log()] interface becomes a no-op.\n** ^The void pointer that is the second argument to SQLITE_CONFIG_LOG is\n** passed through as the first parameter to the application-defined logger\n** function whenever that function is invoked.  ^The second parameter to\n** the logger function is a copy of the first parameter to the corresponding\n** [sqlite3_log()] call and is intended to be a [result code] or an\n** [extended result code].  ^The third parameter passed to the logger is\n** log message after formatting via [sqlite3_snprintf()].\n** The SQLite logging interface is not reentrant; the logger function\n** supplied by the application must not invoke any SQLite interface.\n** In a multi-threaded application, the application-defined logger\n** function must be threadsafe. </dd>\n**\n** [[SQLITE_CONFIG_URI]] <dt>SQLITE_CONFIG_URI\n** <dd>^(The SQLITE_CONFIG_URI option takes a single argument of type int.\n** If non-zero, then URI handling is globally enabled. If the parameter is zero,\n** then URI handling is globally disabled.)^ ^If URI handling is globally\n** enabled, all filenames passed to [sqlite3_open()], [sqlite3_open_v2()],\n** [sqlite3_open16()] or\n** specified as part of [ATTACH] commands are interpreted as URIs, regardless\n** of whether or not the [SQLITE_OPEN_URI] flag is set when the database\n** connection is opened. ^If it is globally disabled, filenames are\n** only interpreted as URIs if the SQLITE_OPEN_URI flag is set when the\n** database connection is opened. ^(By default, URI handling is globally\n** disabled. The default value may be changed by compiling with the\n** [SQLITE_USE_URI] symbol defined.)^\n**\n** [[SQLITE_CONFIG_COVERING_INDEX_SCAN]] <dt>SQLITE_CONFIG_COVERING_INDEX_SCAN\n** <dd>^The SQLITE_CONFIG_COVERING_INDEX_SCAN option takes a single integer\n** argument which is interpreted as a boolean in order to enable or disable\n** the use of covering indices for full table scans in the query optimizer.\n** ^The default setting is determined\n** by the [SQLITE_ALLOW_COVERING_INDEX_SCAN] compile-time option, or is \"on\"\n** if that compile-time option is omitted.\n** The ability to disable the use of covering indices for full table scans\n** is because some incorrectly coded legacy applications might malfunction\n** when the optimization is enabled.  Providing the ability to\n** disable the optimization allows the older, buggy application code to work\n** without change even with newer versions of SQLite.\n**\n** [[SQLITE_CONFIG_PCACHE]] [[SQLITE_CONFIG_GETPCACHE]]\n** <dt>SQLITE_CONFIG_PCACHE and SQLITE_CONFIG_GETPCACHE\n** <dd> These options are obsolete and should not be used by new code.\n** They are retained for backwards compatibility but are now no-ops.\n** </dd>\n**\n** [[SQLITE_CONFIG_SQLLOG]]\n** <dt>SQLITE_CONFIG_SQLLOG\n** <dd>This option is only available if sqlite is compiled with the\n** [SQLITE_ENABLE_SQLLOG] pre-processor macro defined. The first argument should\n** be a pointer to a function of type void(*)(void*,sqlite3*,const char*, int).\n** The second should be of type (void*). The callback is invoked by the library\n** in three separate circumstances, identified by the value passed as the\n** fourth parameter. If the fourth parameter is 0, then the database connection\n** passed as the second argument has just been opened. The third argument\n** points to a buffer containing the name of the main database file. If the\n** fourth parameter is 1, then the SQL statement that the third parameter\n** points to has just been executed. Or, if the fourth parameter is 2, then\n** the connection being passed as the second parameter is being closed. The\n** third parameter is passed NULL In this case.  An example of using this\n** configuration option can be seen in the \"test_sqllog.c\" source file in\n** the canonical SQLite source tree.</dd>\n**\n** [[SQLITE_CONFIG_MMAP_SIZE]]\n** <dt>SQLITE_CONFIG_MMAP_SIZE\n** <dd>^SQLITE_CONFIG_MMAP_SIZE takes two 64-bit integer (sqlite3_int64) values\n** that are the default mmap size limit (the default setting for\n** [PRAGMA mmap_size]) and the maximum allowed mmap size limit.\n** ^The default setting can be overridden by each database connection using\n** either the [PRAGMA mmap_size] command, or by using the\n** [SQLITE_FCNTL_MMAP_SIZE] file control.  ^(The maximum allowed mmap size\n** will be silently truncated if necessary so that it does not exceed the\n** compile-time maximum mmap size set by the\n** [SQLITE_MAX_MMAP_SIZE] compile-time option.)^\n** ^If either argument to this option is negative, then that argument is\n** changed to its compile-time default.\n**\n** [[SQLITE_CONFIG_WIN32_HEAPSIZE]]\n** <dt>SQLITE_CONFIG_WIN32_HEAPSIZE\n** <dd>^The SQLITE_CONFIG_WIN32_HEAPSIZE option is only available if SQLite is\n** compiled for Windows with the [SQLITE_WIN32_MALLOC] pre-processor macro\n** defined. ^SQLITE_CONFIG_WIN32_HEAPSIZE takes a 32-bit unsigned integer value\n** that specifies the maximum size of the created heap.\n**\n** [[SQLITE_CONFIG_PCACHE_HDRSZ]]\n** <dt>SQLITE_CONFIG_PCACHE_HDRSZ\n** <dd>^The SQLITE_CONFIG_PCACHE_HDRSZ option takes a single parameter which\n** is a pointer to an integer and writes into that integer the number of extra\n** bytes per page required for each page in [SQLITE_CONFIG_PAGECACHE].\n** The amount of extra space required can change depending on the compiler,\n** target platform, and SQLite version.\n**\n** [[SQLITE_CONFIG_PMASZ]]\n** <dt>SQLITE_CONFIG_PMASZ\n** <dd>^The SQLITE_CONFIG_PMASZ option takes a single parameter which\n** is an unsigned integer and sets the \"Minimum PMA Size\" for the multithreaded\n** sorter to that integer.  The default minimum PMA Size is set by the\n** [SQLITE_SORTER_PMASZ] compile-time option.  New threads are launched\n** to help with sort operations when multithreaded sorting\n** is enabled (using the [PRAGMA threads] command) and the amount of content\n** to be sorted exceeds the page size times the minimum of the\n** [PRAGMA cache_size] setting and this value.\n**\n** [[SQLITE_CONFIG_STMTJRNL_SPILL]]\n** <dt>SQLITE_CONFIG_STMTJRNL_SPILL\n** <dd>^The SQLITE_CONFIG_STMTJRNL_SPILL option takes a single parameter which\n** becomes the [statement journal] spill-to-disk threshold.  \n** [Statement journals] are held in memory until their size (in bytes)\n** exceeds this threshold, at which point they are written to disk.\n** Or if the threshold is -1, statement journals are always held\n** exclusively in memory.\n** Since many statement journals never become large, setting the spill\n** threshold to a value such as 64KiB can greatly reduce the amount of\n** I/O required to support statement rollback.\n** The default value for this setting is controlled by the\n** [SQLITE_STMTJRNL_SPILL] compile-time option.\n**\n** [[SQLITE_CONFIG_SORTERREF_SIZE]]\n** <dt>SQLITE_CONFIG_SORTERREF_SIZE\n** <dd>The SQLITE_CONFIG_SORTERREF_SIZE option accepts a single parameter\n** of type (int) - the new value of the sorter-reference size threshold.\n** Usually, when SQLite uses an external sort to order records according\n** to an ORDER BY clause, all fields required by the caller are present in the\n** sorted records. However, if SQLite determines based on the declared type\n** of a table column that its values are likely to be very large - larger\n** than the configured sorter-reference size threshold - then a reference\n** is stored in each sorted record and the required column values loaded\n** from the database as records are returned in sorted order. The default\n** value for this option is to never use this optimization. Specifying a \n** negative value for this option restores the default behaviour.\n** This option is only available if SQLite is compiled with the\n** [SQLITE_ENABLE_SORTER_REFERENCES] compile-time option.\n**\n** [[SQLITE_CONFIG_MEMDB_MAXSIZE]]\n** <dt>SQLITE_CONFIG_MEMDB_MAXSIZE\n** <dd>The SQLITE_CONFIG_MEMDB_MAXSIZE option accepts a single parameter\n** [sqlite3_int64] parameter which is the default maximum size for an in-memory\n** database created using [sqlite3_deserialize()].  This default maximum\n** size can be adjusted up or down for individual databases using the\n** [SQLITE_FCNTL_SIZE_LIMIT] [sqlite3_file_control|file-control].  If this\n** configuration setting is never used, then the default maximum is determined\n** by the [SQLITE_MEMDB_DEFAULT_MAXSIZE] compile-time option.  If that\n** compile-time option is not set, then the default maximum is 1073741824.\n** </dl>\n*/\n#define SQLITE_CONFIG_SINGLETHREAD  1  /* nil */\n#define SQLITE_CONFIG_MULTITHREAD   2  /* nil */\n#define SQLITE_CONFIG_SERIALIZED    3  /* nil */\n#define SQLITE_CONFIG_MALLOC        4  /* sqlite3_mem_methods* */\n#define SQLITE_CONFIG_GETMALLOC     5  /* sqlite3_mem_methods* */\n#define SQLITE_CONFIG_SCRATCH       6  /* No longer used */\n#define SQLITE_CONFIG_PAGECACHE     7  /* void*, int sz, int N */\n#define SQLITE_CONFIG_HEAP          8  /* void*, int nByte, int min */\n#define SQLITE_CONFIG_MEMSTATUS     9  /* boolean */\n#define SQLITE_CONFIG_MUTEX        10  /* sqlite3_mutex_methods* */\n#define SQLITE_CONFIG_GETMUTEX     11  /* sqlite3_mutex_methods* */\n/* previously SQLITE_CONFIG_CHUNKALLOC 12 which is now unused. */ \n#define SQLITE_CONFIG_LOOKASIDE    13  /* int int */\n#define SQLITE_CONFIG_PCACHE       14  /* no-op */\n#define SQLITE_CONFIG_GETPCACHE    15  /* no-op */\n#define SQLITE_CONFIG_LOG          16  /* xFunc, void* */\n#define SQLITE_CONFIG_URI          17  /* int */\n#define SQLITE_CONFIG_PCACHE2      18  /* sqlite3_pcache_methods2* */\n#define SQLITE_CONFIG_GETPCACHE2   19  /* sqlite3_pcache_methods2* */\n#define SQLITE_CONFIG_COVERING_INDEX_SCAN 20  /* int */\n#define SQLITE_CONFIG_SQLLOG       21  /* xSqllog, void* */\n#define SQLITE_CONFIG_MMAP_SIZE    22  /* sqlite3_int64, sqlite3_int64 */\n#define SQLITE_CONFIG_WIN32_HEAPSIZE      23  /* int nByte */\n#define SQLITE_CONFIG_PCACHE_HDRSZ        24  /* int *psz */\n#define SQLITE_CONFIG_PMASZ               25  /* unsigned int szPma */\n#define SQLITE_CONFIG_STMTJRNL_SPILL      26  /* int nByte */\n#define SQLITE_CONFIG_SMALL_MALLOC        27  /* boolean */\n#define SQLITE_CONFIG_SORTERREF_SIZE      28  /* int nByte */\n#define SQLITE_CONFIG_MEMDB_MAXSIZE       29  /* sqlite3_int64 */\n\n/*\n** CAPI3REF: Database Connection Configuration Options\n**\n** These constants are the available integer configuration options that\n** can be passed as the second argument to the [sqlite3_db_config()] interface.\n**\n** New configuration options may be added in future releases of SQLite.\n** Existing configuration options might be discontinued.  Applications\n** should check the return code from [sqlite3_db_config()] to make sure that\n** the call worked.  ^The [sqlite3_db_config()] interface will return a\n** non-zero [error code] if a discontinued or unsupported configuration option\n** is invoked.\n**\n** <dl>\n** [[SQLITE_DBCONFIG_LOOKASIDE]]\n** <dt>SQLITE_DBCONFIG_LOOKASIDE</dt>\n** <dd> ^This option takes three additional arguments that determine the \n** [lookaside memory allocator] configuration for the [database connection].\n** ^The first argument (the third parameter to [sqlite3_db_config()] is a\n** pointer to a memory buffer to use for lookaside memory.\n** ^The first argument after the SQLITE_DBCONFIG_LOOKASIDE verb\n** may be NULL in which case SQLite will allocate the\n** lookaside buffer itself using [sqlite3_malloc()]. ^The second argument is the\n** size of each lookaside buffer slot.  ^The third argument is the number of\n** slots.  The size of the buffer in the first argument must be greater than\n** or equal to the product of the second and third arguments.  The buffer\n** must be aligned to an 8-byte boundary.  ^If the second argument to\n** SQLITE_DBCONFIG_LOOKASIDE is not a multiple of 8, it is internally\n** rounded down to the next smaller multiple of 8.  ^(The lookaside memory\n** configuration for a database connection can only be changed when that\n** connection is not currently using lookaside memory, or in other words\n** when the \"current value\" returned by\n** [sqlite3_db_status](D,[SQLITE_CONFIG_LOOKASIDE],...) is zero.\n** Any attempt to change the lookaside memory configuration when lookaside\n** memory is in use leaves the configuration unchanged and returns \n** [SQLITE_BUSY].)^</dd>\n**\n** [[SQLITE_DBCONFIG_ENABLE_FKEY]]\n** <dt>SQLITE_DBCONFIG_ENABLE_FKEY</dt>\n** <dd> ^This option is used to enable or disable the enforcement of\n** [foreign key constraints].  There should be two additional arguments.\n** The first argument is an integer which is 0 to disable FK enforcement,\n** positive to enable FK enforcement or negative to leave FK enforcement\n** unchanged.  The second parameter is a pointer to an integer into which\n** is written 0 or 1 to indicate whether FK enforcement is off or on\n** following this call.  The second parameter may be a NULL pointer, in\n** which case the FK enforcement setting is not reported back. </dd>\n**\n** [[SQLITE_DBCONFIG_ENABLE_TRIGGER]]\n** <dt>SQLITE_DBCONFIG_ENABLE_TRIGGER</dt>\n** <dd> ^This option is used to enable or disable [CREATE TRIGGER | triggers].\n** There should be two additional arguments.\n** The first argument is an integer which is 0 to disable triggers,\n** positive to enable triggers or negative to leave the setting unchanged.\n** The second parameter is a pointer to an integer into which\n** is written 0 or 1 to indicate whether triggers are disabled or enabled\n** following this call.  The second parameter may be a NULL pointer, in\n** which case the trigger setting is not reported back. </dd>\n**\n** [[SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER]]\n** <dt>SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER</dt>\n** <dd> ^This option is used to enable or disable the two-argument\n** version of the [fts3_tokenizer()] function which is part of the\n** [FTS3] full-text search engine extension.\n** There should be two additional arguments.\n** The first argument is an integer which is 0 to disable fts3_tokenizer() or\n** positive to enable fts3_tokenizer() or negative to leave the setting\n** unchanged.\n** The second parameter is a pointer to an integer into which\n** is written 0 or 1 to indicate whether fts3_tokenizer is disabled or enabled\n** following this call.  The second parameter may be a NULL pointer, in\n** which case the new setting is not reported back. </dd>\n**\n** [[SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION]]\n** <dt>SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION</dt>\n** <dd> ^This option is used to enable or disable the [sqlite3_load_extension()]\n** interface independently of the [load_extension()] SQL function.\n** The [sqlite3_enable_load_extension()] API enables or disables both the\n** C-API [sqlite3_load_extension()] and the SQL function [load_extension()].\n** There should be two additional arguments.\n** When the first argument to this interface is 1, then only the C-API is\n** enabled and the SQL function remains disabled.  If the first argument to\n** this interface is 0, then both the C-API and the SQL function are disabled.\n** If the first argument is -1, then no changes are made to state of either the\n** C-API or the SQL function.\n** The second parameter is a pointer to an integer into which\n** is written 0 or 1 to indicate whether [sqlite3_load_extension()] interface\n** is disabled or enabled following this call.  The second parameter may\n** be a NULL pointer, in which case the new setting is not reported back.\n** </dd>\n**\n** [[SQLITE_DBCONFIG_MAINDBNAME]] <dt>SQLITE_DBCONFIG_MAINDBNAME</dt>\n** <dd> ^This option is used to change the name of the \"main\" database\n** schema.  ^The sole argument is a pointer to a constant UTF8 string\n** which will become the new schema name in place of \"main\".  ^SQLite\n** does not make a copy of the new main schema name string, so the application\n** must ensure that the argument passed into this DBCONFIG option is unchanged\n** until after the database connection closes.\n** </dd>\n**\n** [[SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE]] \n** <dt>SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE</dt>\n** <dd> Usually, when a database in wal mode is closed or detached from a \n** database handle, SQLite checks if this will mean that there are now no \n** connections at all to the database. If so, it performs a checkpoint \n** operation before closing the connection. This option may be used to\n** override this behaviour. The first parameter passed to this operation\n** is an integer - positive to disable checkpoints-on-close, or zero (the\n** default) to enable them, and negative to leave the setting unchanged.\n** The second parameter is a pointer to an integer\n** into which is written 0 or 1 to indicate whether checkpoints-on-close\n** have been disabled - 0 if they are not disabled, 1 if they are.\n** </dd>\n**\n** [[SQLITE_DBCONFIG_ENABLE_QPSG]] <dt>SQLITE_DBCONFIG_ENABLE_QPSG</dt>\n** <dd>^(The SQLITE_DBCONFIG_ENABLE_QPSG option activates or deactivates\n** the [query planner stability guarantee] (QPSG).  When the QPSG is active,\n** a single SQL query statement will always use the same algorithm regardless\n** of values of [bound parameters].)^ The QPSG disables some query optimizations\n** that look at the values of bound parameters, which can make some queries\n** slower.  But the QPSG has the advantage of more predictable behavior.  With\n** the QPSG active, SQLite will always use the same query plan in the field as\n** was used during testing in the lab.\n** The first argument to this setting is an integer which is 0 to disable \n** the QPSG, positive to enable QPSG, or negative to leave the setting\n** unchanged. The second parameter is a pointer to an integer into which\n** is written 0 or 1 to indicate whether the QPSG is disabled or enabled\n** following this call.\n** </dd>\n**\n** [[SQLITE_DBCONFIG_TRIGGER_EQP]] <dt>SQLITE_DBCONFIG_TRIGGER_EQP</dt>\n** <dd> By default, the output of EXPLAIN QUERY PLAN commands does not \n** include output for any operations performed by trigger programs. This\n** option is used to set or clear (the default) a flag that governs this\n** behavior. The first parameter passed to this operation is an integer -\n** positive to enable output for trigger programs, or zero to disable it,\n** or negative to leave the setting unchanged.\n** The second parameter is a pointer to an integer into which is written \n** 0 or 1 to indicate whether output-for-triggers has been disabled - 0 if \n** it is not disabled, 1 if it is.  \n** </dd>\n**\n** [[SQLITE_DBCONFIG_RESET_DATABASE]] <dt>SQLITE_DBCONFIG_RESET_DATABASE</dt>\n** <dd> Set the SQLITE_DBCONFIG_RESET_DATABASE flag and then run\n** [VACUUM] in order to reset a database back to an empty database\n** with no schema and no content. The following process works even for\n** a badly corrupted database file:\n** <ol>\n** <li> If the database connection is newly opened, make sure it has read the\n**      database schema by preparing then discarding some query against the\n**      database, or calling sqlite3_table_column_metadata(), ignoring any\n**      errors.  This step is only necessary if the application desires to keep\n**      the database in WAL mode after the reset if it was in WAL mode before\n**      the reset.  \n** <li> sqlite3_db_config(db, SQLITE_DBCONFIG_RESET_DATABASE, 1, 0);\n** <li> [sqlite3_exec](db, \"[VACUUM]\", 0, 0, 0);\n** <li> sqlite3_db_config(db, SQLITE_DBCONFIG_RESET_DATABASE, 0, 0);\n** </ol>\n** Because resetting a database is destructive and irreversible, the\n** process requires the use of this obscure API and multiple steps to help\n** ensure that it does not happen by accident.\n**\n** [[SQLITE_DBCONFIG_DEFENSIVE]] <dt>SQLITE_DBCONFIG_DEFENSIVE</dt>\n** <dd>The SQLITE_DBCONFIG_DEFENSIVE option activates or deactivates the\n** \"defensive\" flag for a database connection.  When the defensive\n** flag is enabled, language features that allow ordinary SQL to \n** deliberately corrupt the database file are disabled.  The disabled\n** features include but are not limited to the following:\n** <ul>\n** <li> The [PRAGMA writable_schema=ON] statement.\n** <li> Writes to the [sqlite_dbpage] virtual table.\n** <li> Direct writes to [shadow tables].\n** </ul>\n** </dd>\n** </dl>\n*/\n#define SQLITE_DBCONFIG_MAINDBNAME            1000 /* const char* */\n#define SQLITE_DBCONFIG_LOOKASIDE             1001 /* void* int int */\n#define SQLITE_DBCONFIG_ENABLE_FKEY           1002 /* int int* */\n#define SQLITE_DBCONFIG_ENABLE_TRIGGER        1003 /* int int* */\n#define SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER 1004 /* int int* */\n#define SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION 1005 /* int int* */\n#define SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE      1006 /* int int* */\n#define SQLITE_DBCONFIG_ENABLE_QPSG           1007 /* int int* */\n#define SQLITE_DBCONFIG_TRIGGER_EQP           1008 /* int int* */\n#define SQLITE_DBCONFIG_RESET_DATABASE        1009 /* int int* */\n#define SQLITE_DBCONFIG_DEFENSIVE             1010 /* int int* */\n#define SQLITE_DBCONFIG_MAX                   1010 /* Largest DBCONFIG */\n\n/*\n** CAPI3REF: Enable Or Disable Extended Result Codes\n** METHOD: sqlite3\n**\n** ^The sqlite3_extended_result_codes() routine enables or disables the\n** [extended result codes] feature of SQLite. ^The extended result\n** codes are disabled by default for historical compatibility.\n*/\nSQLITE_API int sqlite3_extended_result_codes(sqlite3*, int onoff);\n\n/*\n** CAPI3REF: Last Insert Rowid\n** METHOD: sqlite3\n**\n** ^Each entry in most SQLite tables (except for [WITHOUT ROWID] tables)\n** has a unique 64-bit signed\n** integer key called the [ROWID | \"rowid\"]. ^The rowid is always available\n** as an undeclared column named ROWID, OID, or _ROWID_ as long as those\n** names are not also used by explicitly declared columns. ^If\n** the table has a column of type [INTEGER PRIMARY KEY] then that column\n** is another alias for the rowid.\n**\n** ^The sqlite3_last_insert_rowid(D) interface usually returns the [rowid] of\n** the most recent successful [INSERT] into a rowid table or [virtual table]\n** on database connection D. ^Inserts into [WITHOUT ROWID] tables are not\n** recorded. ^If no successful [INSERT]s into rowid tables have ever occurred \n** on the database connection D, then sqlite3_last_insert_rowid(D) returns \n** zero.\n**\n** As well as being set automatically as rows are inserted into database\n** tables, the value returned by this function may be set explicitly by\n** [sqlite3_set_last_insert_rowid()]\n**\n** Some virtual table implementations may INSERT rows into rowid tables as\n** part of committing a transaction (e.g. to flush data accumulated in memory\n** to disk). In this case subsequent calls to this function return the rowid\n** associated with these internal INSERT operations, which leads to \n** unintuitive results. Virtual table implementations that do write to rowid\n** tables in this way can avoid this problem by restoring the original \n** rowid value using [sqlite3_set_last_insert_rowid()] before returning \n** control to the user.\n**\n** ^(If an [INSERT] occurs within a trigger then this routine will \n** return the [rowid] of the inserted row as long as the trigger is \n** running. Once the trigger program ends, the value returned \n** by this routine reverts to what it was before the trigger was fired.)^\n**\n** ^An [INSERT] that fails due to a constraint violation is not a\n** successful [INSERT] and does not change the value returned by this\n** routine.  ^Thus INSERT OR FAIL, INSERT OR IGNORE, INSERT OR ROLLBACK,\n** and INSERT OR ABORT make no changes to the return value of this\n** routine when their insertion fails.  ^(When INSERT OR REPLACE\n** encounters a constraint violation, it does not fail.  The\n** INSERT continues to completion after deleting rows that caused\n** the constraint problem so INSERT OR REPLACE will always change\n** the return value of this interface.)^\n**\n** ^For the purposes of this routine, an [INSERT] is considered to\n** be successful even if it is subsequently rolled back.\n**\n** This function is accessible to SQL statements via the\n** [last_insert_rowid() SQL function].\n**\n** If a separate thread performs a new [INSERT] on the same\n** database connection while the [sqlite3_last_insert_rowid()]\n** function is running and thus changes the last insert [rowid],\n** then the value returned by [sqlite3_last_insert_rowid()] is\n** unpredictable and might not equal either the old or the new\n** last insert [rowid].\n*/\nSQLITE_API sqlite3_int64 sqlite3_last_insert_rowid(sqlite3*);\n\n/*\n** CAPI3REF: Set the Last Insert Rowid value.\n** METHOD: sqlite3\n**\n** The sqlite3_set_last_insert_rowid(D, R) method allows the application to\n** set the value returned by calling sqlite3_last_insert_rowid(D) to R \n** without inserting a row into the database.\n*/\nSQLITE_API void sqlite3_set_last_insert_rowid(sqlite3*,sqlite3_int64);\n\n/*\n** CAPI3REF: Count The Number Of Rows Modified\n** METHOD: sqlite3\n**\n** ^This function returns the number of rows modified, inserted or\n** deleted by the most recently completed INSERT, UPDATE or DELETE\n** statement on the database connection specified by the only parameter.\n** ^Executing any other type of SQL statement does not modify the value\n** returned by this function.\n**\n** ^Only changes made directly by the INSERT, UPDATE or DELETE statement are\n** considered - auxiliary changes caused by [CREATE TRIGGER | triggers], \n** [foreign key actions] or [REPLACE] constraint resolution are not counted.\n** \n** Changes to a view that are intercepted by \n** [INSTEAD OF trigger | INSTEAD OF triggers] are not counted. ^The value \n** returned by sqlite3_changes() immediately after an INSERT, UPDATE or \n** DELETE statement run on a view is always zero. Only changes made to real \n** tables are counted.\n**\n** Things are more complicated if the sqlite3_changes() function is\n** executed while a trigger program is running. This may happen if the\n** program uses the [changes() SQL function], or if some other callback\n** function invokes sqlite3_changes() directly. Essentially:\n** \n** <ul>\n**   <li> ^(Before entering a trigger program the value returned by\n**        sqlite3_changes() function is saved. After the trigger program \n**        has finished, the original value is restored.)^\n** \n**   <li> ^(Within a trigger program each INSERT, UPDATE and DELETE \n**        statement sets the value returned by sqlite3_changes() \n**        upon completion as normal. Of course, this value will not include \n**        any changes performed by sub-triggers, as the sqlite3_changes() \n**        value will be saved and restored after each sub-trigger has run.)^\n** </ul>\n** \n** ^This means that if the changes() SQL function (or similar) is used\n** by the first INSERT, UPDATE or DELETE statement within a trigger, it \n** returns the value as set when the calling statement began executing.\n** ^If it is used by the second or subsequent such statement within a trigger \n** program, the value returned reflects the number of rows modified by the \n** previous INSERT, UPDATE or DELETE statement within the same trigger.\n**\n** If a separate thread makes changes on the same database connection\n** while [sqlite3_changes()] is running then the value returned\n** is unpredictable and not meaningful.\n**\n** See also:\n** <ul>\n** <li> the [sqlite3_total_changes()] interface\n** <li> the [count_changes pragma]\n** <li> the [changes() SQL function]\n** <li> the [data_version pragma]\n** </ul>\n*/\nSQLITE_API int sqlite3_changes(sqlite3*);\n\n/*\n** CAPI3REF: Total Number Of Rows Modified\n** METHOD: sqlite3\n**\n** ^This function returns the total number of rows inserted, modified or\n** deleted by all [INSERT], [UPDATE] or [DELETE] statements completed\n** since the database connection was opened, including those executed as\n** part of trigger programs. ^Executing any other type of SQL statement\n** does not affect the value returned by sqlite3_total_changes().\n** \n** ^Changes made as part of [foreign key actions] are included in the\n** count, but those made as part of REPLACE constraint resolution are\n** not. ^Changes to a view that are intercepted by INSTEAD OF triggers \n** are not counted.\n**\n** The [sqlite3_total_changes(D)] interface only reports the number\n** of rows that changed due to SQL statement run against database\n** connection D.  Any changes by other database connections are ignored.\n** To detect changes against a database file from other database\n** connections use the [PRAGMA data_version] command or the\n** [SQLITE_FCNTL_DATA_VERSION] [file control].\n** \n** If a separate thread makes changes on the same database connection\n** while [sqlite3_total_changes()] is running then the value\n** returned is unpredictable and not meaningful.\n**\n** See also:\n** <ul>\n** <li> the [sqlite3_changes()] interface\n** <li> the [count_changes pragma]\n** <li> the [changes() SQL function]\n** <li> the [data_version pragma]\n** <li> the [SQLITE_FCNTL_DATA_VERSION] [file control]\n** </ul>\n*/\nSQLITE_API int sqlite3_total_changes(sqlite3*);\n\n/*\n** CAPI3REF: Interrupt A Long-Running Query\n** METHOD: sqlite3\n**\n** ^This function causes any pending database operation to abort and\n** return at its earliest opportunity. This routine is typically\n** called in response to a user action such as pressing \"Cancel\"\n** or Ctrl-C where the user wants a long query operation to halt\n** immediately.\n**\n** ^It is safe to call this routine from a thread different from the\n** thread that is currently running the database operation.  But it\n** is not safe to call this routine with a [database connection] that\n** is closed or might close before sqlite3_interrupt() returns.\n**\n** ^If an SQL operation is very nearly finished at the time when\n** sqlite3_interrupt() is called, then it might not have an opportunity\n** to be interrupted and might continue to completion.\n**\n** ^An SQL operation that is interrupted will return [SQLITE_INTERRUPT].\n** ^If the interrupted SQL operation is an INSERT, UPDATE, or DELETE\n** that is inside an explicit transaction, then the entire transaction\n** will be rolled back automatically.\n**\n** ^The sqlite3_interrupt(D) call is in effect until all currently running\n** SQL statements on [database connection] D complete.  ^Any new SQL statements\n** that are started after the sqlite3_interrupt() call and before the \n** running statements reaches zero are interrupted as if they had been\n** running prior to the sqlite3_interrupt() call.  ^New SQL statements\n** that are started after the running statement count reaches zero are\n** not effected by the sqlite3_interrupt().\n** ^A call to sqlite3_interrupt(D) that occurs when there are no running\n** SQL statements is a no-op and has no effect on SQL statements\n** that are started after the sqlite3_interrupt() call returns.\n*/\nSQLITE_API void sqlite3_interrupt(sqlite3*);\n\n/*\n** CAPI3REF: Determine If An SQL Statement Is Complete\n**\n** These routines are useful during command-line input to determine if the\n** currently entered text seems to form a complete SQL statement or\n** if additional input is needed before sending the text into\n** SQLite for parsing.  ^These routines return 1 if the input string\n** appears to be a complete SQL statement.  ^A statement is judged to be\n** complete if it ends with a semicolon token and is not a prefix of a\n** well-formed CREATE TRIGGER statement.  ^Semicolons that are embedded within\n** string literals or quoted identifier names or comments are not\n** independent tokens (they are part of the token in which they are\n** embedded) and thus do not count as a statement terminator.  ^Whitespace\n** and comments that follow the final semicolon are ignored.\n**\n** ^These routines return 0 if the statement is incomplete.  ^If a\n** memory allocation fails, then SQLITE_NOMEM is returned.\n**\n** ^These routines do not parse the SQL statements thus\n** will not detect syntactically incorrect SQL.\n**\n** ^(If SQLite has not been initialized using [sqlite3_initialize()] prior \n** to invoking sqlite3_complete16() then sqlite3_initialize() is invoked\n** automatically by sqlite3_complete16().  If that initialization fails,\n** then the return value from sqlite3_complete16() will be non-zero\n** regardless of whether or not the input SQL is complete.)^\n**\n** The input to [sqlite3_complete()] must be a zero-terminated\n** UTF-8 string.\n**\n** The input to [sqlite3_complete16()] must be a zero-terminated\n** UTF-16 string in native byte order.\n*/\nSQLITE_API int sqlite3_complete(const char *sql);\nSQLITE_API int sqlite3_complete16(const void *sql);\n\n/*\n** CAPI3REF: Register A Callback To Handle SQLITE_BUSY Errors\n** KEYWORDS: {busy-handler callback} {busy handler}\n** METHOD: sqlite3\n**\n** ^The sqlite3_busy_handler(D,X,P) routine sets a callback function X\n** that might be invoked with argument P whenever\n** an attempt is made to access a database table associated with\n** [database connection] D when another thread\n** or process has the table locked.\n** The sqlite3_busy_handler() interface is used to implement\n** [sqlite3_busy_timeout()] and [PRAGMA busy_timeout].\n**\n** ^If the busy callback is NULL, then [SQLITE_BUSY]\n** is returned immediately upon encountering the lock.  ^If the busy callback\n** is not NULL, then the callback might be invoked with two arguments.\n**\n** ^The first argument to the busy handler is a copy of the void* pointer which\n** is the third argument to sqlite3_busy_handler().  ^The second argument to\n** the busy handler callback is the number of times that the busy handler has\n** been invoked previously for the same locking event.  ^If the\n** busy callback returns 0, then no additional attempts are made to\n** access the database and [SQLITE_BUSY] is returned\n** to the application.\n** ^If the callback returns non-zero, then another attempt\n** is made to access the database and the cycle repeats.\n**\n** The presence of a busy handler does not guarantee that it will be invoked\n** when there is lock contention. ^If SQLite determines that invoking the busy\n** handler could result in a deadlock, it will go ahead and return [SQLITE_BUSY]\n** to the application instead of invoking the \n** busy handler.\n** Consider a scenario where one process is holding a read lock that\n** it is trying to promote to a reserved lock and\n** a second process is holding a reserved lock that it is trying\n** to promote to an exclusive lock.  The first process cannot proceed\n** because it is blocked by the second and the second process cannot\n** proceed because it is blocked by the first.  If both processes\n** invoke the busy handlers, neither will make any progress.  Therefore,\n** SQLite returns [SQLITE_BUSY] for the first process, hoping that this\n** will induce the first process to release its read lock and allow\n** the second process to proceed.\n**\n** ^The default busy callback is NULL.\n**\n** ^(There can only be a single busy handler defined for each\n** [database connection].  Setting a new busy handler clears any\n** previously set handler.)^  ^Note that calling [sqlite3_busy_timeout()]\n** or evaluating [PRAGMA busy_timeout=N] will change the\n** busy handler and thus clear any previously set busy handler.\n**\n** The busy callback should not take any actions which modify the\n** database connection that invoked the busy handler.  In other words,\n** the busy handler is not reentrant.  Any such actions\n** result in undefined behavior.\n** \n** A busy handler must not close the database connection\n** or [prepared statement] that invoked the busy handler.\n*/\nSQLITE_API int sqlite3_busy_handler(sqlite3*,int(*)(void*,int),void*);\n\n/*\n** CAPI3REF: Set A Busy Timeout\n** METHOD: sqlite3\n**\n** ^This routine sets a [sqlite3_busy_handler | busy handler] that sleeps\n** for a specified amount of time when a table is locked.  ^The handler\n** will sleep multiple times until at least \"ms\" milliseconds of sleeping\n** have accumulated.  ^After at least \"ms\" milliseconds of sleeping,\n** the handler returns 0 which causes [sqlite3_step()] to return\n** [SQLITE_BUSY].\n**\n** ^Calling this routine with an argument less than or equal to zero\n** turns off all busy handlers.\n**\n** ^(There can only be a single busy handler for a particular\n** [database connection] at any given moment.  If another busy handler\n** was defined  (using [sqlite3_busy_handler()]) prior to calling\n** this routine, that other busy handler is cleared.)^\n**\n** See also:  [PRAGMA busy_timeout]\n*/\nSQLITE_API int sqlite3_busy_timeout(sqlite3*, int ms);\n\n/*\n** CAPI3REF: Convenience Routines For Running Queries\n** METHOD: sqlite3\n**\n** This is a legacy interface that is preserved for backwards compatibility.\n** Use of this interface is not recommended.\n**\n** Definition: A <b>result table</b> is memory data structure created by the\n** [sqlite3_get_table()] interface.  A result table records the\n** complete query results from one or more queries.\n**\n** The table conceptually has a number of rows and columns.  But\n** these numbers are not part of the result table itself.  These\n** numbers are obtained separately.  Let N be the number of rows\n** and M be the number of columns.\n**\n** A result table is an array of pointers to zero-terminated UTF-8 strings.\n** There are (N+1)*M elements in the array.  The first M pointers point\n** to zero-terminated strings that  contain the names of the columns.\n** The remaining entries all point to query results.  NULL values result\n** in NULL pointers.  All other values are in their UTF-8 zero-terminated\n** string representation as returned by [sqlite3_column_text()].\n**\n** A result table might consist of one or more memory allocations.\n** It is not safe to pass a result table directly to [sqlite3_free()].\n** A result table should be deallocated using [sqlite3_free_table()].\n**\n** ^(As an example of the result table format, suppose a query result\n** is as follows:\n**\n** <blockquote><pre>\n**        Name        | Age\n**        -----------------------\n**        Alice       | 43\n**        Bob         | 28\n**        Cindy       | 21\n** </pre></blockquote>\n**\n** There are two column (M==2) and three rows (N==3).  Thus the\n** result table has 8 entries.  Suppose the result table is stored\n** in an array names azResult.  Then azResult holds this content:\n**\n** <blockquote><pre>\n**        azResult&#91;0] = \"Name\";\n**        azResult&#91;1] = \"Age\";\n**        azResult&#91;2] = \"Alice\";\n**        azResult&#91;3] = \"43\";\n**        azResult&#91;4] = \"Bob\";\n**        azResult&#91;5] = \"28\";\n**        azResult&#91;6] = \"Cindy\";\n**        azResult&#91;7] = \"21\";\n** </pre></blockquote>)^\n**\n** ^The sqlite3_get_table() function evaluates one or more\n** semicolon-separated SQL statements in the zero-terminated UTF-8\n** string of its 2nd parameter and returns a result table to the\n** pointer given in its 3rd parameter.\n**\n** After the application has finished with the result from sqlite3_get_table(),\n** it must pass the result table pointer to sqlite3_free_table() in order to\n** release the memory that was malloced.  Because of the way the\n** [sqlite3_malloc()] happens within sqlite3_get_table(), the calling\n** function must not try to call [sqlite3_free()] directly.  Only\n** [sqlite3_free_table()] is able to release the memory properly and safely.\n**\n** The sqlite3_get_table() interface is implemented as a wrapper around\n** [sqlite3_exec()].  The sqlite3_get_table() routine does not have access\n** to any internal data structures of SQLite.  It uses only the public\n** interface defined here.  As a consequence, errors that occur in the\n** wrapper layer outside of the internal [sqlite3_exec()] call are not\n** reflected in subsequent calls to [sqlite3_errcode()] or\n** [sqlite3_errmsg()].\n*/\nSQLITE_API int sqlite3_get_table(\n  sqlite3 *db,          /* An open database */\n  const char *zSql,     /* SQL to be evaluated */\n  char ***pazResult,    /* Results of the query */\n  int *pnRow,           /* Number of result rows written here */\n  int *pnColumn,        /* Number of result columns written here */\n  char **pzErrmsg       /* Error msg written here */\n);\nSQLITE_API void sqlite3_free_table(char **result);\n\n/*\n** CAPI3REF: Formatted String Printing Functions\n**\n** These routines are work-alikes of the \"printf()\" family of functions\n** from the standard C library.\n** These routines understand most of the common formatting options from\n** the standard library printf() \n** plus some additional non-standard formats ([%q], [%Q], [%w], and [%z]).\n** See the [built-in printf()] documentation for details.\n**\n** ^The sqlite3_mprintf() and sqlite3_vmprintf() routines write their\n** results into memory obtained from [sqlite3_malloc64()].\n** The strings returned by these two routines should be\n** released by [sqlite3_free()].  ^Both routines return a\n** NULL pointer if [sqlite3_malloc64()] is unable to allocate enough\n** memory to hold the resulting string.\n**\n** ^(The sqlite3_snprintf() routine is similar to \"snprintf()\" from\n** the standard C library.  The result is written into the\n** buffer supplied as the second parameter whose size is given by\n** the first parameter. Note that the order of the\n** first two parameters is reversed from snprintf().)^  This is an\n** historical accident that cannot be fixed without breaking\n** backwards compatibility.  ^(Note also that sqlite3_snprintf()\n** returns a pointer to its buffer instead of the number of\n** characters actually written into the buffer.)^  We admit that\n** the number of characters written would be a more useful return\n** value but we cannot change the implementation of sqlite3_snprintf()\n** now without breaking compatibility.\n**\n** ^As long as the buffer size is greater than zero, sqlite3_snprintf()\n** guarantees that the buffer is always zero-terminated.  ^The first\n** parameter \"n\" is the total size of the buffer, including space for\n** the zero terminator.  So the longest string that can be completely\n** written will be n-1 characters.\n**\n** ^The sqlite3_vsnprintf() routine is a varargs version of sqlite3_snprintf().\n**\n** See also:  [built-in printf()], [printf() SQL function]\n*/\nSQLITE_API char *sqlite3_mprintf(const char*,...);\nSQLITE_API char *sqlite3_vmprintf(const char*, va_list);\nSQLITE_API char *sqlite3_snprintf(int,char*,const char*, ...);\nSQLITE_API char *sqlite3_vsnprintf(int,char*,const char*, va_list);\n\n/*\n** CAPI3REF: Memory Allocation Subsystem\n**\n** The SQLite core uses these three routines for all of its own\n** internal memory allocation needs. \"Core\" in the previous sentence\n** does not include operating-system specific VFS implementation.  The\n** Windows VFS uses native malloc() and free() for some operations.\n**\n** ^The sqlite3_malloc() routine returns a pointer to a block\n** of memory at least N bytes in length, where N is the parameter.\n** ^If sqlite3_malloc() is unable to obtain sufficient free\n** memory, it returns a NULL pointer.  ^If the parameter N to\n** sqlite3_malloc() is zero or negative then sqlite3_malloc() returns\n** a NULL pointer.\n**\n** ^The sqlite3_malloc64(N) routine works just like\n** sqlite3_malloc(N) except that N is an unsigned 64-bit integer instead\n** of a signed 32-bit integer.\n**\n** ^Calling sqlite3_free() with a pointer previously returned\n** by sqlite3_malloc() or sqlite3_realloc() releases that memory so\n** that it might be reused.  ^The sqlite3_free() routine is\n** a no-op if is called with a NULL pointer.  Passing a NULL pointer\n** to sqlite3_free() is harmless.  After being freed, memory\n** should neither be read nor written.  Even reading previously freed\n** memory might result in a segmentation fault or other severe error.\n** Memory corruption, a segmentation fault, or other severe error\n** might result if sqlite3_free() is called with a non-NULL pointer that\n** was not obtained from sqlite3_malloc() or sqlite3_realloc().\n**\n** ^The sqlite3_realloc(X,N) interface attempts to resize a\n** prior memory allocation X to be at least N bytes.\n** ^If the X parameter to sqlite3_realloc(X,N)\n** is a NULL pointer then its behavior is identical to calling\n** sqlite3_malloc(N).\n** ^If the N parameter to sqlite3_realloc(X,N) is zero or\n** negative then the behavior is exactly the same as calling\n** sqlite3_free(X).\n** ^sqlite3_realloc(X,N) returns a pointer to a memory allocation\n** of at least N bytes in size or NULL if insufficient memory is available.\n** ^If M is the size of the prior allocation, then min(N,M) bytes\n** of the prior allocation are copied into the beginning of buffer returned\n** by sqlite3_realloc(X,N) and the prior allocation is freed.\n** ^If sqlite3_realloc(X,N) returns NULL and N is positive, then the\n** prior allocation is not freed.\n**\n** ^The sqlite3_realloc64(X,N) interfaces works the same as\n** sqlite3_realloc(X,N) except that N is a 64-bit unsigned integer instead\n** of a 32-bit signed integer.\n**\n** ^If X is a memory allocation previously obtained from sqlite3_malloc(),\n** sqlite3_malloc64(), sqlite3_realloc(), or sqlite3_realloc64(), then\n** sqlite3_msize(X) returns the size of that memory allocation in bytes.\n** ^The value returned by sqlite3_msize(X) might be larger than the number\n** of bytes requested when X was allocated.  ^If X is a NULL pointer then\n** sqlite3_msize(X) returns zero.  If X points to something that is not\n** the beginning of memory allocation, or if it points to a formerly\n** valid memory allocation that has now been freed, then the behavior\n** of sqlite3_msize(X) is undefined and possibly harmful.\n**\n** ^The memory returned by sqlite3_malloc(), sqlite3_realloc(),\n** sqlite3_malloc64(), and sqlite3_realloc64()\n** is always aligned to at least an 8 byte boundary, or to a\n** 4 byte boundary if the [SQLITE_4_BYTE_ALIGNED_MALLOC] compile-time\n** option is used.\n**\n** In SQLite version 3.5.0 and 3.5.1, it was possible to define\n** the SQLITE_OMIT_MEMORY_ALLOCATION which would cause the built-in\n** implementation of these routines to be omitted.  That capability\n** is no longer provided.  Only built-in memory allocators can be used.\n**\n** Prior to SQLite version 3.7.10, the Windows OS interface layer called\n** the system malloc() and free() directly when converting\n** filenames between the UTF-8 encoding used by SQLite\n** and whatever filename encoding is used by the particular Windows\n** installation.  Memory allocation errors were detected, but\n** they were reported back as [SQLITE_CANTOPEN] or\n** [SQLITE_IOERR] rather than [SQLITE_NOMEM].\n**\n** The pointer arguments to [sqlite3_free()] and [sqlite3_realloc()]\n** must be either NULL or else pointers obtained from a prior\n** invocation of [sqlite3_malloc()] or [sqlite3_realloc()] that have\n** not yet been released.\n**\n** The application must not read or write any part of\n** a block of memory after it has been released using\n** [sqlite3_free()] or [sqlite3_realloc()].\n*/\nSQLITE_API void *sqlite3_malloc(int);\nSQLITE_API void *sqlite3_malloc64(sqlite3_uint64);\nSQLITE_API void *sqlite3_realloc(void*, int);\nSQLITE_API void *sqlite3_realloc64(void*, sqlite3_uint64);\nSQLITE_API void sqlite3_free(void*);\nSQLITE_API sqlite3_uint64 sqlite3_msize(void*);\n\n/*\n** CAPI3REF: Memory Allocator Statistics\n**\n** SQLite provides these two interfaces for reporting on the status\n** of the [sqlite3_malloc()], [sqlite3_free()], and [sqlite3_realloc()]\n** routines, which form the built-in memory allocation subsystem.\n**\n** ^The [sqlite3_memory_used()] routine returns the number of bytes\n** of memory currently outstanding (malloced but not freed).\n** ^The [sqlite3_memory_highwater()] routine returns the maximum\n** value of [sqlite3_memory_used()] since the high-water mark\n** was last reset.  ^The values returned by [sqlite3_memory_used()] and\n** [sqlite3_memory_highwater()] include any overhead\n** added by SQLite in its implementation of [sqlite3_malloc()],\n** but not overhead added by the any underlying system library\n** routines that [sqlite3_malloc()] may call.\n**\n** ^The memory high-water mark is reset to the current value of\n** [sqlite3_memory_used()] if and only if the parameter to\n** [sqlite3_memory_highwater()] is true.  ^The value returned\n** by [sqlite3_memory_highwater(1)] is the high-water mark\n** prior to the reset.\n*/\nSQLITE_API sqlite3_int64 sqlite3_memory_used(void);\nSQLITE_API sqlite3_int64 sqlite3_memory_highwater(int resetFlag);\n\n/*\n** CAPI3REF: Pseudo-Random Number Generator\n**\n** SQLite contains a high-quality pseudo-random number generator (PRNG) used to\n** select random [ROWID | ROWIDs] when inserting new records into a table that\n** already uses the largest possible [ROWID].  The PRNG is also used for\n** the build-in random() and randomblob() SQL functions.  This interface allows\n** applications to access the same PRNG for other purposes.\n**\n** ^A call to this routine stores N bytes of randomness into buffer P.\n** ^The P parameter can be a NULL pointer.\n**\n** ^If this routine has not been previously called or if the previous\n** call had N less than one or a NULL pointer for P, then the PRNG is\n** seeded using randomness obtained from the xRandomness method of\n** the default [sqlite3_vfs] object.\n** ^If the previous call to this routine had an N of 1 or more and a\n** non-NULL P then the pseudo-randomness is generated\n** internally and without recourse to the [sqlite3_vfs] xRandomness\n** method.\n*/\nSQLITE_API void sqlite3_randomness(int N, void *P);\n\n/*\n** CAPI3REF: Compile-Time Authorization Callbacks\n** METHOD: sqlite3\n** KEYWORDS: {authorizer callback}\n**\n** ^This routine registers an authorizer callback with a particular\n** [database connection], supplied in the first argument.\n** ^The authorizer callback is invoked as SQL statements are being compiled\n** by [sqlite3_prepare()] or its variants [sqlite3_prepare_v2()],\n** [sqlite3_prepare_v3()], [sqlite3_prepare16()], [sqlite3_prepare16_v2()],\n** and [sqlite3_prepare16_v3()].  ^At various\n** points during the compilation process, as logic is being created\n** to perform various actions, the authorizer callback is invoked to\n** see if those actions are allowed.  ^The authorizer callback should\n** return [SQLITE_OK] to allow the action, [SQLITE_IGNORE] to disallow the\n** specific action but allow the SQL statement to continue to be\n** compiled, or [SQLITE_DENY] to cause the entire SQL statement to be\n** rejected with an error.  ^If the authorizer callback returns\n** any value other than [SQLITE_IGNORE], [SQLITE_OK], or [SQLITE_DENY]\n** then the [sqlite3_prepare_v2()] or equivalent call that triggered\n** the authorizer will fail with an error message.\n**\n** When the callback returns [SQLITE_OK], that means the operation\n** requested is ok.  ^When the callback returns [SQLITE_DENY], the\n** [sqlite3_prepare_v2()] or equivalent call that triggered the\n** authorizer will fail with an error message explaining that\n** access is denied. \n**\n** ^The first parameter to the authorizer callback is a copy of the third\n** parameter to the sqlite3_set_authorizer() interface. ^The second parameter\n** to the callback is an integer [SQLITE_COPY | action code] that specifies\n** the particular action to be authorized. ^The third through sixth parameters\n** to the callback are either NULL pointers or zero-terminated strings\n** that contain additional details about the action to be authorized.\n** Applications must always be prepared to encounter a NULL pointer in any\n** of the third through the sixth parameters of the authorization callback.\n**\n** ^If the action code is [SQLITE_READ]\n** and the callback returns [SQLITE_IGNORE] then the\n** [prepared statement] statement is constructed to substitute\n** a NULL value in place of the table column that would have\n** been read if [SQLITE_OK] had been returned.  The [SQLITE_IGNORE]\n** return can be used to deny an untrusted user access to individual\n** columns of a table.\n** ^When a table is referenced by a [SELECT] but no column values are\n** extracted from that table (for example in a query like\n** \"SELECT count(*) FROM tab\") then the [SQLITE_READ] authorizer callback\n** is invoked once for that table with a column name that is an empty string.\n** ^If the action code is [SQLITE_DELETE] and the callback returns\n** [SQLITE_IGNORE] then the [DELETE] operation proceeds but the\n** [truncate optimization] is disabled and all rows are deleted individually.\n**\n** An authorizer is used when [sqlite3_prepare | preparing]\n** SQL statements from an untrusted source, to ensure that the SQL statements\n** do not try to access data they are not allowed to see, or that they do not\n** try to execute malicious statements that damage the database.  For\n** example, an application may allow a user to enter arbitrary\n** SQL queries for evaluation by a database.  But the application does\n** not want the user to be able to make arbitrary changes to the\n** database.  An authorizer could then be put in place while the\n** user-entered SQL is being [sqlite3_prepare | prepared] that\n** disallows everything except [SELECT] statements.\n**\n** Applications that need to process SQL from untrusted sources\n** might also consider lowering resource limits using [sqlite3_limit()]\n** and limiting database size using the [max_page_count] [PRAGMA]\n** in addition to using an authorizer.\n**\n** ^(Only a single authorizer can be in place on a database connection\n** at a time.  Each call to sqlite3_set_authorizer overrides the\n** previous call.)^  ^Disable the authorizer by installing a NULL callback.\n** The authorizer is disabled by default.\n**\n** The authorizer callback must not do anything that will modify\n** the database connection that invoked the authorizer callback.\n** Note that [sqlite3_prepare_v2()] and [sqlite3_step()] both modify their\n** database connections for the meaning of \"modify\" in this paragraph.\n**\n** ^When [sqlite3_prepare_v2()] is used to prepare a statement, the\n** statement might be re-prepared during [sqlite3_step()] due to a \n** schema change.  Hence, the application should ensure that the\n** correct authorizer callback remains in place during the [sqlite3_step()].\n**\n** ^Note that the authorizer callback is invoked only during\n** [sqlite3_prepare()] or its variants.  Authorization is not\n** performed during statement evaluation in [sqlite3_step()], unless\n** as stated in the previous paragraph, sqlite3_step() invokes\n** sqlite3_prepare_v2() to reprepare a statement after a schema change.\n*/\nSQLITE_API int sqlite3_set_authorizer(\n  sqlite3*,\n  int (*xAuth)(void*,int,const char*,const char*,const char*,const char*),\n  void *pUserData\n);\n\n/*\n** CAPI3REF: Authorizer Return Codes\n**\n** The [sqlite3_set_authorizer | authorizer callback function] must\n** return either [SQLITE_OK] or one of these two constants in order\n** to signal SQLite whether or not the action is permitted.  See the\n** [sqlite3_set_authorizer | authorizer documentation] for additional\n** information.\n**\n** Note that SQLITE_IGNORE is also used as a [conflict resolution mode]\n** returned from the [sqlite3_vtab_on_conflict()] interface.\n*/\n#define SQLITE_DENY   1   /* Abort the SQL statement with an error */\n#define SQLITE_IGNORE 2   /* Don't allow access, but don't generate an error */\n\n/*\n** CAPI3REF: Authorizer Action Codes\n**\n** The [sqlite3_set_authorizer()] interface registers a callback function\n** that is invoked to authorize certain SQL statement actions.  The\n** second parameter to the callback is an integer code that specifies\n** what action is being authorized.  These are the integer action codes that\n** the authorizer callback may be passed.\n**\n** These action code values signify what kind of operation is to be\n** authorized.  The 3rd and 4th parameters to the authorization\n** callback function will be parameters or NULL depending on which of these\n** codes is used as the second parameter.  ^(The 5th parameter to the\n** authorizer callback is the name of the database (\"main\", \"temp\",\n** etc.) if applicable.)^  ^The 6th parameter to the authorizer callback\n** is the name of the inner-most trigger or view that is responsible for\n** the access attempt or NULL if this access attempt is directly from\n** top-level SQL code.\n*/\n/******************************************* 3rd ************ 4th ***********/\n#define SQLITE_CREATE_INDEX          1   /* Index Name      Table Name      */\n#define SQLITE_CREATE_TABLE          2   /* Table Name      NULL            */\n#define SQLITE_CREATE_TEMP_INDEX     3   /* Index Name      Table Name      */\n#define SQLITE_CREATE_TEMP_TABLE     4   /* Table Name      NULL            */\n#define SQLITE_CREATE_TEMP_TRIGGER   5   /* Trigger Name    Table Name      */\n#define SQLITE_CREATE_TEMP_VIEW      6   /* View Name       NULL            */\n#define SQLITE_CREATE_TRIGGER        7   /* Trigger Name    Table Name      */\n#define SQLITE_CREATE_VIEW           8   /* View Name       NULL            */\n#define SQLITE_DELETE                9   /* Table Name      NULL            */\n#define SQLITE_DROP_INDEX           10   /* Index Name      Table Name      */\n#define SQLITE_DROP_TABLE           11   /* Table Name      NULL            */\n#define SQLITE_DROP_TEMP_INDEX      12   /* Index Name      Table Name      */\n#define SQLITE_DROP_TEMP_TABLE      13   /* Table Name      NULL            */\n#define SQLITE_DROP_TEMP_TRIGGER    14   /* Trigger Name    Table Name      */\n#define SQLITE_DROP_TEMP_VIEW       15   /* View Name       NULL            */\n#define SQLITE_DROP_TRIGGER         16   /* Trigger Name    Table Name      */\n#define SQLITE_DROP_VIEW            17   /* View Name       NULL            */\n#define SQLITE_INSERT               18   /* Table Name      NULL            */\n#define SQLITE_PRAGMA               19   /* Pragma Name     1st arg or NULL */\n#define SQLITE_READ                 20   /* Table Name      Column Name     */\n#define SQLITE_SELECT               21   /* NULL            NULL            */\n#define SQLITE_TRANSACTION          22   /* Operation       NULL            */\n#define SQLITE_UPDATE               23   /* Table Name      Column Name     */\n#define SQLITE_ATTACH               24   /* Filename        NULL            */\n#define SQLITE_DETACH               25   /* Database Name   NULL            */\n#define SQLITE_ALTER_TABLE          26   /* Database Name   Table Name      */\n#define SQLITE_REINDEX              27   /* Index Name      NULL            */\n#define SQLITE_ANALYZE              28   /* Table Name      NULL            */\n#define SQLITE_CREATE_VTABLE        29   /* Table Name      Module Name     */\n#define SQLITE_DROP_VTABLE          30   /* Table Name      Module Name     */\n#define SQLITE_FUNCTION             31   /* NULL            Function Name   */\n#define SQLITE_SAVEPOINT            32   /* Operation       Savepoint Name  */\n#define SQLITE_COPY                  0   /* No longer used */\n#define SQLITE_RECURSIVE            33   /* NULL            NULL            */\n\n/*\n** CAPI3REF: Tracing And Profiling Functions\n** METHOD: sqlite3\n**\n** These routines are deprecated. Use the [sqlite3_trace_v2()] interface\n** instead of the routines described here.\n**\n** These routines register callback functions that can be used for\n** tracing and profiling the execution of SQL statements.\n**\n** ^The callback function registered by sqlite3_trace() is invoked at\n** various times when an SQL statement is being run by [sqlite3_step()].\n** ^The sqlite3_trace() callback is invoked with a UTF-8 rendering of the\n** SQL statement text as the statement first begins executing.\n** ^(Additional sqlite3_trace() callbacks might occur\n** as each triggered subprogram is entered.  The callbacks for triggers\n** contain a UTF-8 SQL comment that identifies the trigger.)^\n**\n** The [SQLITE_TRACE_SIZE_LIMIT] compile-time option can be used to limit\n** the length of [bound parameter] expansion in the output of sqlite3_trace().\n**\n** ^The callback function registered by sqlite3_profile() is invoked\n** as each SQL statement finishes.  ^The profile callback contains\n** the original statement text and an estimate of wall-clock time\n** of how long that statement took to run.  ^The profile callback\n** time is in units of nanoseconds, however the current implementation\n** is only capable of millisecond resolution so the six least significant\n** digits in the time are meaningless.  Future versions of SQLite\n** might provide greater resolution on the profiler callback.  Invoking\n** either [sqlite3_trace()] or [sqlite3_trace_v2()] will cancel the\n** profile callback.\n*/\nSQLITE_API SQLITE_DEPRECATED void *sqlite3_trace(sqlite3*,\n   void(*xTrace)(void*,const char*), void*);\nSQLITE_API SQLITE_DEPRECATED void *sqlite3_profile(sqlite3*,\n   void(*xProfile)(void*,const char*,sqlite3_uint64), void*);\n\n/*\n** CAPI3REF: SQL Trace Event Codes\n** KEYWORDS: SQLITE_TRACE\n**\n** These constants identify classes of events that can be monitored\n** using the [sqlite3_trace_v2()] tracing logic.  The M argument\n** to [sqlite3_trace_v2(D,M,X,P)] is an OR-ed combination of one or more of\n** the following constants.  ^The first argument to the trace callback\n** is one of the following constants.\n**\n** New tracing constants may be added in future releases.\n**\n** ^A trace callback has four arguments: xCallback(T,C,P,X).\n** ^The T argument is one of the integer type codes above.\n** ^The C argument is a copy of the context pointer passed in as the\n** fourth argument to [sqlite3_trace_v2()].\n** The P and X arguments are pointers whose meanings depend on T.\n**\n** <dl>\n** [[SQLITE_TRACE_STMT]] <dt>SQLITE_TRACE_STMT</dt>\n** <dd>^An SQLITE_TRACE_STMT callback is invoked when a prepared statement\n** first begins running and possibly at other times during the\n** execution of the prepared statement, such as at the start of each\n** trigger subprogram. ^The P argument is a pointer to the\n** [prepared statement]. ^The X argument is a pointer to a string which\n** is the unexpanded SQL text of the prepared statement or an SQL comment \n** that indicates the invocation of a trigger.  ^The callback can compute\n** the same text that would have been returned by the legacy [sqlite3_trace()]\n** interface by using the X argument when X begins with \"--\" and invoking\n** [sqlite3_expanded_sql(P)] otherwise.\n**\n** [[SQLITE_TRACE_PROFILE]] <dt>SQLITE_TRACE_PROFILE</dt>\n** <dd>^An SQLITE_TRACE_PROFILE callback provides approximately the same\n** information as is provided by the [sqlite3_profile()] callback.\n** ^The P argument is a pointer to the [prepared statement] and the\n** X argument points to a 64-bit integer which is the estimated of\n** the number of nanosecond that the prepared statement took to run.\n** ^The SQLITE_TRACE_PROFILE callback is invoked when the statement finishes.\n**\n** [[SQLITE_TRACE_ROW]] <dt>SQLITE_TRACE_ROW</dt>\n** <dd>^An SQLITE_TRACE_ROW callback is invoked whenever a prepared\n** statement generates a single row of result.  \n** ^The P argument is a pointer to the [prepared statement] and the\n** X argument is unused.\n**\n** [[SQLITE_TRACE_CLOSE]] <dt>SQLITE_TRACE_CLOSE</dt>\n** <dd>^An SQLITE_TRACE_CLOSE callback is invoked when a database\n** connection closes.\n** ^The P argument is a pointer to the [database connection] object\n** and the X argument is unused.\n** </dl>\n*/\n#define SQLITE_TRACE_STMT       0x01\n#define SQLITE_TRACE_PROFILE    0x02\n#define SQLITE_TRACE_ROW        0x04\n#define SQLITE_TRACE_CLOSE      0x08\n\n/*\n** CAPI3REF: SQL Trace Hook\n** METHOD: sqlite3\n**\n** ^The sqlite3_trace_v2(D,M,X,P) interface registers a trace callback\n** function X against [database connection] D, using property mask M\n** and context pointer P.  ^If the X callback is\n** NULL or if the M mask is zero, then tracing is disabled.  The\n** M argument should be the bitwise OR-ed combination of\n** zero or more [SQLITE_TRACE] constants.\n**\n** ^Each call to either sqlite3_trace() or sqlite3_trace_v2() overrides \n** (cancels) any prior calls to sqlite3_trace() or sqlite3_trace_v2().\n**\n** ^The X callback is invoked whenever any of the events identified by \n** mask M occur.  ^The integer return value from the callback is currently\n** ignored, though this may change in future releases.  Callback\n** implementations should return zero to ensure future compatibility.\n**\n** ^A trace callback is invoked with four arguments: callback(T,C,P,X).\n** ^The T argument is one of the [SQLITE_TRACE]\n** constants to indicate why the callback was invoked.\n** ^The C argument is a copy of the context pointer.\n** The P and X arguments are pointers whose meanings depend on T.\n**\n** The sqlite3_trace_v2() interface is intended to replace the legacy\n** interfaces [sqlite3_trace()] and [sqlite3_profile()], both of which\n** are deprecated.\n*/\nSQLITE_API int sqlite3_trace_v2(\n  sqlite3*,\n  unsigned uMask,\n  int(*xCallback)(unsigned,void*,void*,void*),\n  void *pCtx\n);\n\n/*\n** CAPI3REF: Query Progress Callbacks\n** METHOD: sqlite3\n**\n** ^The sqlite3_progress_handler(D,N,X,P) interface causes the callback\n** function X to be invoked periodically during long running calls to\n** [sqlite3_exec()], [sqlite3_step()] and [sqlite3_get_table()] for\n** database connection D.  An example use for this\n** interface is to keep a GUI updated during a large query.\n**\n** ^The parameter P is passed through as the only parameter to the \n** callback function X.  ^The parameter N is the approximate number of \n** [virtual machine instructions] that are evaluated between successive\n** invocations of the callback X.  ^If N is less than one then the progress\n** handler is disabled.\n**\n** ^Only a single progress handler may be defined at one time per\n** [database connection]; setting a new progress handler cancels the\n** old one.  ^Setting parameter X to NULL disables the progress handler.\n** ^The progress handler is also disabled by setting N to a value less\n** than 1.\n**\n** ^If the progress callback returns non-zero, the operation is\n** interrupted.  This feature can be used to implement a\n** \"Cancel\" button on a GUI progress dialog box.\n**\n** The progress handler callback must not do anything that will modify\n** the database connection that invoked the progress handler.\n** Note that [sqlite3_prepare_v2()] and [sqlite3_step()] both modify their\n** database connections for the meaning of \"modify\" in this paragraph.\n**\n*/\nSQLITE_API void sqlite3_progress_handler(sqlite3*, int, int(*)(void*), void*);\n\n/*\n** CAPI3REF: Opening A New Database Connection\n** CONSTRUCTOR: sqlite3\n**\n** ^These routines open an SQLite database file as specified by the \n** filename argument. ^The filename argument is interpreted as UTF-8 for\n** sqlite3_open() and sqlite3_open_v2() and as UTF-16 in the native byte\n** order for sqlite3_open16(). ^(A [database connection] handle is usually\n** returned in *ppDb, even if an error occurs.  The only exception is that\n** if SQLite is unable to allocate memory to hold the [sqlite3] object,\n** a NULL will be written into *ppDb instead of a pointer to the [sqlite3]\n** object.)^ ^(If the database is opened (and/or created) successfully, then\n** [SQLITE_OK] is returned.  Otherwise an [error code] is returned.)^ ^The\n** [sqlite3_errmsg()] or [sqlite3_errmsg16()] routines can be used to obtain\n** an English language description of the error following a failure of any\n** of the sqlite3_open() routines.\n**\n** ^The default encoding will be UTF-8 for databases created using\n** sqlite3_open() or sqlite3_open_v2().  ^The default encoding for databases\n** created using sqlite3_open16() will be UTF-16 in the native byte order.\n**\n** Whether or not an error occurs when it is opened, resources\n** associated with the [database connection] handle should be released by\n** passing it to [sqlite3_close()] when it is no longer required.\n**\n** The sqlite3_open_v2() interface works like sqlite3_open()\n** except that it accepts two additional parameters for additional control\n** over the new database connection.  ^(The flags parameter to\n** sqlite3_open_v2() can take one of\n** the following three values, optionally combined with the \n** [SQLITE_OPEN_NOMUTEX], [SQLITE_OPEN_FULLMUTEX], [SQLITE_OPEN_SHAREDCACHE],\n** [SQLITE_OPEN_PRIVATECACHE], and/or [SQLITE_OPEN_URI] flags:)^\n**\n** <dl>\n** ^(<dt>[SQLITE_OPEN_READONLY]</dt>\n** <dd>The database is opened in read-only mode.  If the database does not\n** already exist, an error is returned.</dd>)^\n**\n** ^(<dt>[SQLITE_OPEN_READWRITE]</dt>\n** <dd>The database is opened for reading and writing if possible, or reading\n** only if the file is write protected by the operating system.  In either\n** case the database must already exist, otherwise an error is returned.</dd>)^\n**\n** ^(<dt>[SQLITE_OPEN_READWRITE] | [SQLITE_OPEN_CREATE]</dt>\n** <dd>The database is opened for reading and writing, and is created if\n** it does not already exist. This is the behavior that is always used for\n** sqlite3_open() and sqlite3_open16().</dd>)^\n** </dl>\n**\n** If the 3rd parameter to sqlite3_open_v2() is not one of the\n** combinations shown above optionally combined with other\n** [SQLITE_OPEN_READONLY | SQLITE_OPEN_* bits]\n** then the behavior is undefined.\n**\n** ^If the [SQLITE_OPEN_NOMUTEX] flag is set, then the database connection\n** opens in the multi-thread [threading mode] as long as the single-thread\n** mode has not been set at compile-time or start-time.  ^If the\n** [SQLITE_OPEN_FULLMUTEX] flag is set then the database connection opens\n** in the serialized [threading mode] unless single-thread was\n** previously selected at compile-time or start-time.\n** ^The [SQLITE_OPEN_SHAREDCACHE] flag causes the database connection to be\n** eligible to use [shared cache mode], regardless of whether or not shared\n** cache is enabled using [sqlite3_enable_shared_cache()].  ^The\n** [SQLITE_OPEN_PRIVATECACHE] flag causes the database connection to not\n** participate in [shared cache mode] even if it is enabled.\n**\n** ^The fourth parameter to sqlite3_open_v2() is the name of the\n** [sqlite3_vfs] object that defines the operating system interface that\n** the new database connection should use.  ^If the fourth parameter is\n** a NULL pointer then the default [sqlite3_vfs] object is used.\n**\n** ^If the filename is \":memory:\", then a private, temporary in-memory database\n** is created for the connection.  ^This in-memory database will vanish when\n** the database connection is closed.  Future versions of SQLite might\n** make use of additional special filenames that begin with the \":\" character.\n** It is recommended that when a database filename actually does begin with\n** a \":\" character you should prefix the filename with a pathname such as\n** \"./\" to avoid ambiguity.\n**\n** ^If the filename is an empty string, then a private, temporary\n** on-disk database will be created.  ^This private database will be\n** automatically deleted as soon as the database connection is closed.\n**\n** [[URI filenames in sqlite3_open()]] <h3>URI Filenames</h3>\n**\n** ^If [URI filename] interpretation is enabled, and the filename argument\n** begins with \"file:\", then the filename is interpreted as a URI. ^URI\n** filename interpretation is enabled if the [SQLITE_OPEN_URI] flag is\n** set in the third argument to sqlite3_open_v2(), or if it has\n** been enabled globally using the [SQLITE_CONFIG_URI] option with the\n** [sqlite3_config()] method or by the [SQLITE_USE_URI] compile-time option.\n** URI filename interpretation is turned off\n** by default, but future releases of SQLite might enable URI filename\n** interpretation by default.  See \"[URI filenames]\" for additional\n** information.\n**\n** URI filenames are parsed according to RFC 3986. ^If the URI contains an\n** authority, then it must be either an empty string or the string \n** \"localhost\". ^If the authority is not an empty string or \"localhost\", an \n** error is returned to the caller. ^The fragment component of a URI, if \n** present, is ignored.\n**\n** ^SQLite uses the path component of the URI as the name of the disk file\n** which contains the database. ^If the path begins with a '/' character, \n** then it is interpreted as an absolute path. ^If the path does not begin \n** with a '/' (meaning that the authority section is omitted from the URI)\n** then the path is interpreted as a relative path. \n** ^(On windows, the first component of an absolute path \n** is a drive specification (e.g. \"C:\").)^\n**\n** [[core URI query parameters]]\n** The query component of a URI may contain parameters that are interpreted\n** either by SQLite itself, or by a [VFS | custom VFS implementation].\n** SQLite and its built-in [VFSes] interpret the\n** following query parameters:\n**\n** <ul>\n**   <li> <b>vfs</b>: ^The \"vfs\" parameter may be used to specify the name of\n**     a VFS object that provides the operating system interface that should\n**     be used to access the database file on disk. ^If this option is set to\n**     an empty string the default VFS object is used. ^Specifying an unknown\n**     VFS is an error. ^If sqlite3_open_v2() is used and the vfs option is\n**     present, then the VFS specified by the option takes precedence over\n**     the value passed as the fourth parameter to sqlite3_open_v2().\n**\n**   <li> <b>mode</b>: ^(The mode parameter may be set to either \"ro\", \"rw\",\n**     \"rwc\", or \"memory\". Attempting to set it to any other value is\n**     an error)^. \n**     ^If \"ro\" is specified, then the database is opened for read-only \n**     access, just as if the [SQLITE_OPEN_READONLY] flag had been set in the \n**     third argument to sqlite3_open_v2(). ^If the mode option is set to \n**     \"rw\", then the database is opened for read-write (but not create) \n**     access, as if SQLITE_OPEN_READWRITE (but not SQLITE_OPEN_CREATE) had \n**     been set. ^Value \"rwc\" is equivalent to setting both \n**     SQLITE_OPEN_READWRITE and SQLITE_OPEN_CREATE.  ^If the mode option is\n**     set to \"memory\" then a pure [in-memory database] that never reads\n**     or writes from disk is used. ^It is an error to specify a value for\n**     the mode parameter that is less restrictive than that specified by\n**     the flags passed in the third parameter to sqlite3_open_v2().\n**\n**   <li> <b>cache</b>: ^The cache parameter may be set to either \"shared\" or\n**     \"private\". ^Setting it to \"shared\" is equivalent to setting the\n**     SQLITE_OPEN_SHAREDCACHE bit in the flags argument passed to\n**     sqlite3_open_v2(). ^Setting the cache parameter to \"private\" is \n**     equivalent to setting the SQLITE_OPEN_PRIVATECACHE bit.\n**     ^If sqlite3_open_v2() is used and the \"cache\" parameter is present in\n**     a URI filename, its value overrides any behavior requested by setting\n**     SQLITE_OPEN_PRIVATECACHE or SQLITE_OPEN_SHAREDCACHE flag.\n**\n**  <li> <b>psow</b>: ^The psow parameter indicates whether or not the\n**     [powersafe overwrite] property does or does not apply to the\n**     storage media on which the database file resides.\n**\n**  <li> <b>nolock</b>: ^The nolock parameter is a boolean query parameter\n**     which if set disables file locking in rollback journal modes.  This\n**     is useful for accessing a database on a filesystem that does not\n**     support locking.  Caution:  Database corruption might result if two\n**     or more processes write to the same database and any one of those\n**     processes uses nolock=1.\n**\n**  <li> <b>immutable</b>: ^The immutable parameter is a boolean query\n**     parameter that indicates that the database file is stored on\n**     read-only media.  ^When immutable is set, SQLite assumes that the\n**     database file cannot be changed, even by a process with higher\n**     privilege, and so the database is opened read-only and all locking\n**     and change detection is disabled.  Caution: Setting the immutable\n**     property on a database file that does in fact change can result\n**     in incorrect query results and/or [SQLITE_CORRUPT] errors.\n**     See also: [SQLITE_IOCAP_IMMUTABLE].\n**       \n** </ul>\n**\n** ^Specifying an unknown parameter in the query component of a URI is not an\n** error.  Future versions of SQLite might understand additional query\n** parameters.  See \"[query parameters with special meaning to SQLite]\" for\n** additional information.\n**\n** [[URI filename examples]] <h3>URI filename examples</h3>\n**\n** <table border=\"1\" align=center cellpadding=5>\n** <tr><th> URI filenames <th> Results\n** <tr><td> file:data.db <td> \n**          Open the file \"data.db\" in the current directory.\n** <tr><td> file:/home/fred/data.db<br>\n**          file:///home/fred/data.db <br> \n**          file://localhost/home/fred/data.db <br> <td> \n**          Open the database file \"/home/fred/data.db\".\n** <tr><td> file://darkstar/home/fred/data.db <td> \n**          An error. \"darkstar\" is not a recognized authority.\n** <tr><td style=\"white-space:nowrap\"> \n**          file:///C:/Documents%20and%20Settings/fred/Desktop/data.db\n**     <td> Windows only: Open the file \"data.db\" on fred's desktop on drive\n**          C:. Note that the %20 escaping in this example is not strictly \n**          necessary - space characters can be used literally\n**          in URI filenames.\n** <tr><td> file:data.db?mode=ro&cache=private <td> \n**          Open file \"data.db\" in the current directory for read-only access.\n**          Regardless of whether or not shared-cache mode is enabled by\n**          default, use a private cache.\n** <tr><td> file:/home/fred/data.db?vfs=unix-dotfile <td>\n**          Open file \"/home/fred/data.db\". Use the special VFS \"unix-dotfile\"\n**          that uses dot-files in place of posix advisory locking.\n** <tr><td> file:data.db?mode=readonly <td> \n**          An error. \"readonly\" is not a valid option for the \"mode\" parameter.\n** </table>\n**\n** ^URI hexadecimal escape sequences (%HH) are supported within the path and\n** query components of a URI. A hexadecimal escape sequence consists of a\n** percent sign - \"%\" - followed by exactly two hexadecimal digits \n** specifying an octet value. ^Before the path or query components of a\n** URI filename are interpreted, they are encoded using UTF-8 and all \n** hexadecimal escape sequences replaced by a single byte containing the\n** corresponding octet. If this process generates an invalid UTF-8 encoding,\n** the results are undefined.\n**\n** <b>Note to Windows users:</b>  The encoding used for the filename argument\n** of sqlite3_open() and sqlite3_open_v2() must be UTF-8, not whatever\n** codepage is currently defined.  Filenames containing international\n** characters must be converted to UTF-8 prior to passing them into\n** sqlite3_open() or sqlite3_open_v2().\n**\n** <b>Note to Windows Runtime users:</b>  The temporary directory must be set\n** prior to calling sqlite3_open() or sqlite3_open_v2().  Otherwise, various\n** features that require the use of temporary files may fail.\n**\n** See also: [sqlite3_temp_directory]\n*/\nSQLITE_API int sqlite3_open(\n  const char *filename,   /* Database filename (UTF-8) */\n  sqlite3 **ppDb          /* OUT: SQLite db handle */\n);\nSQLITE_API int sqlite3_open16(\n  const void *filename,   /* Database filename (UTF-16) */\n  sqlite3 **ppDb          /* OUT: SQLite db handle */\n);\nSQLITE_API int sqlite3_open_v2(\n  const char *filename,   /* Database filename (UTF-8) */\n  sqlite3 **ppDb,         /* OUT: SQLite db handle */\n  int flags,              /* Flags */\n  const char *zVfs        /* Name of VFS module to use */\n);\n\n/*\n** CAPI3REF: Obtain Values For URI Parameters\n**\n** These are utility routines, useful to VFS implementations, that check\n** to see if a database file was a URI that contained a specific query \n** parameter, and if so obtains the value of that query parameter.\n**\n** If F is the database filename pointer passed into the xOpen() method of \n** a VFS implementation when the flags parameter to xOpen() has one or \n** more of the [SQLITE_OPEN_URI] or [SQLITE_OPEN_MAIN_DB] bits set and\n** P is the name of the query parameter, then\n** sqlite3_uri_parameter(F,P) returns the value of the P\n** parameter if it exists or a NULL pointer if P does not appear as a \n** query parameter on F.  If P is a query parameter of F\n** has no explicit value, then sqlite3_uri_parameter(F,P) returns\n** a pointer to an empty string.\n**\n** The sqlite3_uri_boolean(F,P,B) routine assumes that P is a boolean\n** parameter and returns true (1) or false (0) according to the value\n** of P.  The sqlite3_uri_boolean(F,P,B) routine returns true (1) if the\n** value of query parameter P is one of \"yes\", \"true\", or \"on\" in any\n** case or if the value begins with a non-zero number.  The \n** sqlite3_uri_boolean(F,P,B) routines returns false (0) if the value of\n** query parameter P is one of \"no\", \"false\", or \"off\" in any case or\n** if the value begins with a numeric zero.  If P is not a query\n** parameter on F or if the value of P is does not match any of the\n** above, then sqlite3_uri_boolean(F,P,B) returns (B!=0).\n**\n** The sqlite3_uri_int64(F,P,D) routine converts the value of P into a\n** 64-bit signed integer and returns that integer, or D if P does not\n** exist.  If the value of P is something other than an integer, then\n** zero is returned.\n** \n** If F is a NULL pointer, then sqlite3_uri_parameter(F,P) returns NULL and\n** sqlite3_uri_boolean(F,P,B) returns B.  If F is not a NULL pointer and\n** is not a database file pathname pointer that SQLite passed into the xOpen\n** VFS method, then the behavior of this routine is undefined and probably\n** undesirable.\n**\n** See the [URI filename] documentation for additional information.\n*/\nSQLITE_API const char *sqlite3_uri_parameter(const char *zFilename, const char *zParam);\nSQLITE_API int sqlite3_uri_boolean(const char *zFile, const char *zParam, int bDefault);\nSQLITE_API sqlite3_int64 sqlite3_uri_int64(const char*, const char*, sqlite3_int64);\n\n\n/*\n** CAPI3REF: Error Codes And Messages\n** METHOD: sqlite3\n**\n** ^If the most recent sqlite3_* API call associated with \n** [database connection] D failed, then the sqlite3_errcode(D) interface\n** returns the numeric [result code] or [extended result code] for that\n** API call.\n** ^The sqlite3_extended_errcode()\n** interface is the same except that it always returns the \n** [extended result code] even when extended result codes are\n** disabled.\n**\n** The values returned by sqlite3_errcode() and/or\n** sqlite3_extended_errcode() might change with each API call.\n** Except, there are some interfaces that are guaranteed to never\n** change the value of the error code.  The error-code preserving\n** interfaces are:\n**\n** <ul>\n** <li> sqlite3_errcode()\n** <li> sqlite3_extended_errcode()\n** <li> sqlite3_errmsg()\n** <li> sqlite3_errmsg16()\n** </ul>\n**\n** ^The sqlite3_errmsg() and sqlite3_errmsg16() return English-language\n** text that describes the error, as either UTF-8 or UTF-16 respectively.\n** ^(Memory to hold the error message string is managed internally.\n** The application does not need to worry about freeing the result.\n** However, the error string might be overwritten or deallocated by\n** subsequent calls to other SQLite interface functions.)^\n**\n** ^The sqlite3_errstr() interface returns the English-language text\n** that describes the [result code], as UTF-8.\n** ^(Memory to hold the error message string is managed internally\n** and must not be freed by the application)^.\n**\n** When the serialized [threading mode] is in use, it might be the\n** case that a second error occurs on a separate thread in between\n** the time of the first error and the call to these interfaces.\n** When that happens, the second error will be reported since these\n** interfaces always report the most recent result.  To avoid\n** this, each thread can obtain exclusive use of the [database connection] D\n** by invoking [sqlite3_mutex_enter]([sqlite3_db_mutex](D)) before beginning\n** to use D and invoking [sqlite3_mutex_leave]([sqlite3_db_mutex](D)) after\n** all calls to the interfaces listed here are completed.\n**\n** If an interface fails with SQLITE_MISUSE, that means the interface\n** was invoked incorrectly by the application.  In that case, the\n** error code and message may or may not be set.\n*/\nSQLITE_API int sqlite3_errcode(sqlite3 *db);\nSQLITE_API int sqlite3_extended_errcode(sqlite3 *db);\nSQLITE_API const char *sqlite3_errmsg(sqlite3*);\nSQLITE_API const void *sqlite3_errmsg16(sqlite3*);\nSQLITE_API const char *sqlite3_errstr(int);\n\n/*\n** CAPI3REF: Prepared Statement Object\n** KEYWORDS: {prepared statement} {prepared statements}\n**\n** An instance of this object represents a single SQL statement that\n** has been compiled into binary form and is ready to be evaluated.\n**\n** Think of each SQL statement as a separate computer program.  The\n** original SQL text is source code.  A prepared statement object \n** is the compiled object code.  All SQL must be converted into a\n** prepared statement before it can be run.\n**\n** The life-cycle of a prepared statement object usually goes like this:\n**\n** <ol>\n** <li> Create the prepared statement object using [sqlite3_prepare_v2()].\n** <li> Bind values to [parameters] using the sqlite3_bind_*()\n**      interfaces.\n** <li> Run the SQL by calling [sqlite3_step()] one or more times.\n** <li> Reset the prepared statement using [sqlite3_reset()] then go back\n**      to step 2.  Do this zero or more times.\n** <li> Destroy the object using [sqlite3_finalize()].\n** </ol>\n*/\ntypedef struct sqlite3_stmt sqlite3_stmt;\n\n/*\n** CAPI3REF: Run-time Limits\n** METHOD: sqlite3\n**\n** ^(This interface allows the size of various constructs to be limited\n** on a connection by connection basis.  The first parameter is the\n** [database connection] whose limit is to be set or queried.  The\n** second parameter is one of the [limit categories] that define a\n** class of constructs to be size limited.  The third parameter is the\n** new limit for that construct.)^\n**\n** ^If the new limit is a negative number, the limit is unchanged.\n** ^(For each limit category SQLITE_LIMIT_<i>NAME</i> there is a \n** [limits | hard upper bound]\n** set at compile-time by a C preprocessor macro called\n** [limits | SQLITE_MAX_<i>NAME</i>].\n** (The \"_LIMIT_\" in the name is changed to \"_MAX_\".))^\n** ^Attempts to increase a limit above its hard upper bound are\n** silently truncated to the hard upper bound.\n**\n** ^Regardless of whether or not the limit was changed, the \n** [sqlite3_limit()] interface returns the prior value of the limit.\n** ^Hence, to find the current value of a limit without changing it,\n** simply invoke this interface with the third parameter set to -1.\n**\n** Run-time limits are intended for use in applications that manage\n** both their own internal database and also databases that are controlled\n** by untrusted external sources.  An example application might be a\n** web browser that has its own databases for storing history and\n** separate databases controlled by JavaScript applications downloaded\n** off the Internet.  The internal databases can be given the\n** large, default limits.  Databases managed by external sources can\n** be given much smaller limits designed to prevent a denial of service\n** attack.  Developers might also want to use the [sqlite3_set_authorizer()]\n** interface to further control untrusted SQL.  The size of the database\n** created by an untrusted script can be contained using the\n** [max_page_count] [PRAGMA].\n**\n** New run-time limit categories may be added in future releases.\n*/\nSQLITE_API int sqlite3_limit(sqlite3*, int id, int newVal);\n\n/*\n** CAPI3REF: Run-Time Limit Categories\n** KEYWORDS: {limit category} {*limit categories}\n**\n** These constants define various performance limits\n** that can be lowered at run-time using [sqlite3_limit()].\n** The synopsis of the meanings of the various limits is shown below.\n** Additional information is available at [limits | Limits in SQLite].\n**\n** <dl>\n** [[SQLITE_LIMIT_LENGTH]] ^(<dt>SQLITE_LIMIT_LENGTH</dt>\n** <dd>The maximum size of any string or BLOB or table row, in bytes.<dd>)^\n**\n** [[SQLITE_LIMIT_SQL_LENGTH]] ^(<dt>SQLITE_LIMIT_SQL_LENGTH</dt>\n** <dd>The maximum length of an SQL statement, in bytes.</dd>)^\n**\n** [[SQLITE_LIMIT_COLUMN]] ^(<dt>SQLITE_LIMIT_COLUMN</dt>\n** <dd>The maximum number of columns in a table definition or in the\n** result set of a [SELECT] or the maximum number of columns in an index\n** or in an ORDER BY or GROUP BY clause.</dd>)^\n**\n** [[SQLITE_LIMIT_EXPR_DEPTH]] ^(<dt>SQLITE_LIMIT_EXPR_DEPTH</dt>\n** <dd>The maximum depth of the parse tree on any expression.</dd>)^\n**\n** [[SQLITE_LIMIT_COMPOUND_SELECT]] ^(<dt>SQLITE_LIMIT_COMPOUND_SELECT</dt>\n** <dd>The maximum number of terms in a compound SELECT statement.</dd>)^\n**\n** [[SQLITE_LIMIT_VDBE_OP]] ^(<dt>SQLITE_LIMIT_VDBE_OP</dt>\n** <dd>The maximum number of instructions in a virtual machine program\n** used to implement an SQL statement.  If [sqlite3_prepare_v2()] or\n** the equivalent tries to allocate space for more than this many opcodes\n** in a single prepared statement, an SQLITE_NOMEM error is returned.</dd>)^\n**\n** [[SQLITE_LIMIT_FUNCTION_ARG]] ^(<dt>SQLITE_LIMIT_FUNCTION_ARG</dt>\n** <dd>The maximum number of arguments on a function.</dd>)^\n**\n** [[SQLITE_LIMIT_ATTACHED]] ^(<dt>SQLITE_LIMIT_ATTACHED</dt>\n** <dd>The maximum number of [ATTACH | attached databases].)^</dd>\n**\n** [[SQLITE_LIMIT_LIKE_PATTERN_LENGTH]]\n** ^(<dt>SQLITE_LIMIT_LIKE_PATTERN_LENGTH</dt>\n** <dd>The maximum length of the pattern argument to the [LIKE] or\n** [GLOB] operators.</dd>)^\n**\n** [[SQLITE_LIMIT_VARIABLE_NUMBER]]\n** ^(<dt>SQLITE_LIMIT_VARIABLE_NUMBER</dt>\n** <dd>The maximum index number of any [parameter] in an SQL statement.)^\n**\n** [[SQLITE_LIMIT_TRIGGER_DEPTH]] ^(<dt>SQLITE_LIMIT_TRIGGER_DEPTH</dt>\n** <dd>The maximum depth of recursion for triggers.</dd>)^\n**\n** [[SQLITE_LIMIT_WORKER_THREADS]] ^(<dt>SQLITE_LIMIT_WORKER_THREADS</dt>\n** <dd>The maximum number of auxiliary worker threads that a single\n** [prepared statement] may start.</dd>)^\n** </dl>\n*/\n#define SQLITE_LIMIT_LENGTH                    0\n#define SQLITE_LIMIT_SQL_LENGTH                1\n#define SQLITE_LIMIT_COLUMN                    2\n#define SQLITE_LIMIT_EXPR_DEPTH                3\n#define SQLITE_LIMIT_COMPOUND_SELECT           4\n#define SQLITE_LIMIT_VDBE_OP                   5\n#define SQLITE_LIMIT_FUNCTION_ARG              6\n#define SQLITE_LIMIT_ATTACHED                  7\n#define SQLITE_LIMIT_LIKE_PATTERN_LENGTH       8\n#define SQLITE_LIMIT_VARIABLE_NUMBER           9\n#define SQLITE_LIMIT_TRIGGER_DEPTH            10\n#define SQLITE_LIMIT_WORKER_THREADS           11\n\n/*\n** CAPI3REF: Prepare Flags\n**\n** These constants define various flags that can be passed into\n** \"prepFlags\" parameter of the [sqlite3_prepare_v3()] and\n** [sqlite3_prepare16_v3()] interfaces.\n**\n** New flags may be added in future releases of SQLite.\n**\n** <dl>\n** [[SQLITE_PREPARE_PERSISTENT]] ^(<dt>SQLITE_PREPARE_PERSISTENT</dt>\n** <dd>The SQLITE_PREPARE_PERSISTENT flag is a hint to the query planner\n** that the prepared statement will be retained for a long time and\n** probably reused many times.)^ ^Without this flag, [sqlite3_prepare_v3()]\n** and [sqlite3_prepare16_v3()] assume that the prepared statement will \n** be used just once or at most a few times and then destroyed using\n** [sqlite3_finalize()] relatively soon. The current implementation acts\n** on this hint by avoiding the use of [lookaside memory] so as not to\n** deplete the limited store of lookaside memory. Future versions of\n** SQLite may act on this hint differently.\n**\n** [[SQLITE_PREPARE_NORMALIZE]] <dt>SQLITE_PREPARE_NORMALIZE</dt>\n** <dd>The SQLITE_PREPARE_NORMALIZE flag is a no-op. This flag used\n** to be required for any prepared statement that wanted to use the\n** [sqlite3_normalized_sql()] interface.  However, the\n** [sqlite3_normalized_sql()] interface is now available to all\n** prepared statements, regardless of whether or not they use this\n** flag.\n**\n** [[SQLITE_PREPARE_NO_VTAB]] <dt>SQLITE_PREPARE_NO_VTAB</dt>\n** <dd>The SQLITE_PREPARE_NO_VTAB flag causes the SQL compiler\n** to return an error (error code SQLITE_ERROR) if the statement uses\n** any virtual tables.\n** </dl>\n*/\n#define SQLITE_PREPARE_PERSISTENT              0x01\n#define SQLITE_PREPARE_NORMALIZE               0x02\n#define SQLITE_PREPARE_NO_VTAB                 0x04\n\n/*\n** CAPI3REF: Compiling An SQL Statement\n** KEYWORDS: {SQL statement compiler}\n** METHOD: sqlite3\n** CONSTRUCTOR: sqlite3_stmt\n**\n** To execute an SQL statement, it must first be compiled into a byte-code\n** program using one of these routines.  Or, in other words, these routines\n** are constructors for the [prepared statement] object.\n**\n** The preferred routine to use is [sqlite3_prepare_v2()].  The\n** [sqlite3_prepare()] interface is legacy and should be avoided.\n** [sqlite3_prepare_v3()] has an extra \"prepFlags\" option that is used\n** for special purposes.\n**\n** The use of the UTF-8 interfaces is preferred, as SQLite currently\n** does all parsing using UTF-8.  The UTF-16 interfaces are provided\n** as a convenience.  The UTF-16 interfaces work by converting the\n** input text into UTF-8, then invoking the corresponding UTF-8 interface.\n**\n** The first argument, \"db\", is a [database connection] obtained from a\n** prior successful call to [sqlite3_open()], [sqlite3_open_v2()] or\n** [sqlite3_open16()].  The database connection must not have been closed.\n**\n** The second argument, \"zSql\", is the statement to be compiled, encoded\n** as either UTF-8 or UTF-16.  The sqlite3_prepare(), sqlite3_prepare_v2(),\n** and sqlite3_prepare_v3()\n** interfaces use UTF-8, and sqlite3_prepare16(), sqlite3_prepare16_v2(),\n** and sqlite3_prepare16_v3() use UTF-16.\n**\n** ^If the nByte argument is negative, then zSql is read up to the\n** first zero terminator. ^If nByte is positive, then it is the\n** number of bytes read from zSql.  ^If nByte is zero, then no prepared\n** statement is generated.\n** If the caller knows that the supplied string is nul-terminated, then\n** there is a small performance advantage to passing an nByte parameter that\n** is the number of bytes in the input string <i>including</i>\n** the nul-terminator.\n**\n** ^If pzTail is not NULL then *pzTail is made to point to the first byte\n** past the end of the first SQL statement in zSql.  These routines only\n** compile the first statement in zSql, so *pzTail is left pointing to\n** what remains uncompiled.\n**\n** ^*ppStmt is left pointing to a compiled [prepared statement] that can be\n** executed using [sqlite3_step()].  ^If there is an error, *ppStmt is set\n** to NULL.  ^If the input text contains no SQL (if the input is an empty\n** string or a comment) then *ppStmt is set to NULL.\n** The calling procedure is responsible for deleting the compiled\n** SQL statement using [sqlite3_finalize()] after it has finished with it.\n** ppStmt may not be NULL.\n**\n** ^On success, the sqlite3_prepare() family of routines return [SQLITE_OK];\n** otherwise an [error code] is returned.\n**\n** The sqlite3_prepare_v2(), sqlite3_prepare_v3(), sqlite3_prepare16_v2(),\n** and sqlite3_prepare16_v3() interfaces are recommended for all new programs.\n** The older interfaces (sqlite3_prepare() and sqlite3_prepare16())\n** are retained for backwards compatibility, but their use is discouraged.\n** ^In the \"vX\" interfaces, the prepared statement\n** that is returned (the [sqlite3_stmt] object) contains a copy of the\n** original SQL text. This causes the [sqlite3_step()] interface to\n** behave differently in three ways:\n**\n** <ol>\n** <li>\n** ^If the database schema changes, instead of returning [SQLITE_SCHEMA] as it\n** always used to do, [sqlite3_step()] will automatically recompile the SQL\n** statement and try to run it again. As many as [SQLITE_MAX_SCHEMA_RETRY]\n** retries will occur before sqlite3_step() gives up and returns an error.\n** </li>\n**\n** <li>\n** ^When an error occurs, [sqlite3_step()] will return one of the detailed\n** [error codes] or [extended error codes].  ^The legacy behavior was that\n** [sqlite3_step()] would only return a generic [SQLITE_ERROR] result code\n** and the application would have to make a second call to [sqlite3_reset()]\n** in order to find the underlying cause of the problem. With the \"v2\" prepare\n** interfaces, the underlying reason for the error is returned immediately.\n** </li>\n**\n** <li>\n** ^If the specific value bound to [parameter | host parameter] in the \n** WHERE clause might influence the choice of query plan for a statement,\n** then the statement will be automatically recompiled, as if there had been \n** a schema change, on the first  [sqlite3_step()] call following any change\n** to the [sqlite3_bind_text | bindings] of that [parameter]. \n** ^The specific value of WHERE-clause [parameter] might influence the \n** choice of query plan if the parameter is the left-hand side of a [LIKE]\n** or [GLOB] operator or if the parameter is compared to an indexed column\n** and the [SQLITE_ENABLE_STAT3] compile-time option is enabled.\n** </li>\n** </ol>\n**\n** <p>^sqlite3_prepare_v3() differs from sqlite3_prepare_v2() only in having\n** the extra prepFlags parameter, which is a bit array consisting of zero or\n** more of the [SQLITE_PREPARE_PERSISTENT|SQLITE_PREPARE_*] flags.  ^The\n** sqlite3_prepare_v2() interface works exactly the same as\n** sqlite3_prepare_v3() with a zero prepFlags parameter.\n*/\nSQLITE_API int sqlite3_prepare(\n  sqlite3 *db,            /* Database handle */\n  const char *zSql,       /* SQL statement, UTF-8 encoded */\n  int nByte,              /* Maximum length of zSql in bytes. */\n  sqlite3_stmt **ppStmt,  /* OUT: Statement handle */\n  const char **pzTail     /* OUT: Pointer to unused portion of zSql */\n);\nSQLITE_API int sqlite3_prepare_v2(\n  sqlite3 *db,            /* Database handle */\n  const char *zSql,       /* SQL statement, UTF-8 encoded */\n  int nByte,              /* Maximum length of zSql in bytes. */\n  sqlite3_stmt **ppStmt,  /* OUT: Statement handle */\n  const char **pzTail     /* OUT: Pointer to unused portion of zSql */\n);\nSQLITE_API int sqlite3_prepare_v3(\n  sqlite3 *db,            /* Database handle */\n  const char *zSql,       /* SQL statement, UTF-8 encoded */\n  int nByte,              /* Maximum length of zSql in bytes. */\n  unsigned int prepFlags, /* Zero or more SQLITE_PREPARE_ flags */\n  sqlite3_stmt **ppStmt,  /* OUT: Statement handle */\n  const char **pzTail     /* OUT: Pointer to unused portion of zSql */\n);\nSQLITE_API int sqlite3_prepare16(\n  sqlite3 *db,            /* Database handle */\n  const void *zSql,       /* SQL statement, UTF-16 encoded */\n  int nByte,              /* Maximum length of zSql in bytes. */\n  sqlite3_stmt **ppStmt,  /* OUT: Statement handle */\n  const void **pzTail     /* OUT: Pointer to unused portion of zSql */\n);\nSQLITE_API int sqlite3_prepare16_v2(\n  sqlite3 *db,            /* Database handle */\n  const void *zSql,       /* SQL statement, UTF-16 encoded */\n  int nByte,              /* Maximum length of zSql in bytes. */\n  sqlite3_stmt **ppStmt,  /* OUT: Statement handle */\n  const void **pzTail     /* OUT: Pointer to unused portion of zSql */\n);\nSQLITE_API int sqlite3_prepare16_v3(\n  sqlite3 *db,            /* Database handle */\n  const void *zSql,       /* SQL statement, UTF-16 encoded */\n  int nByte,              /* Maximum length of zSql in bytes. */\n  unsigned int prepFlags, /* Zero or more SQLITE_PREPARE_ flags */\n  sqlite3_stmt **ppStmt,  /* OUT: Statement handle */\n  const void **pzTail     /* OUT: Pointer to unused portion of zSql */\n);\n\n/*\n** CAPI3REF: Retrieving Statement SQL\n** METHOD: sqlite3_stmt\n**\n** ^The sqlite3_sql(P) interface returns a pointer to a copy of the UTF-8\n** SQL text used to create [prepared statement] P if P was\n** created by [sqlite3_prepare_v2()], [sqlite3_prepare_v3()],\n** [sqlite3_prepare16_v2()], or [sqlite3_prepare16_v3()].\n** ^The sqlite3_expanded_sql(P) interface returns a pointer to a UTF-8\n** string containing the SQL text of prepared statement P with\n** [bound parameters] expanded.\n** ^The sqlite3_normalized_sql(P) interface returns a pointer to a UTF-8\n** string containing the normalized SQL text of prepared statement P.  The\n** semantics used to normalize a SQL statement are unspecified and subject\n** to change.  At a minimum, literal values will be replaced with suitable\n** placeholders.\n**\n** ^(For example, if a prepared statement is created using the SQL\n** text \"SELECT $abc,:xyz\" and if parameter $abc is bound to integer 2345\n** and parameter :xyz is unbound, then sqlite3_sql() will return\n** the original string, \"SELECT $abc,:xyz\" but sqlite3_expanded_sql()\n** will return \"SELECT 2345,NULL\".)^\n**\n** ^The sqlite3_expanded_sql() interface returns NULL if insufficient memory\n** is available to hold the result, or if the result would exceed the\n** the maximum string length determined by the [SQLITE_LIMIT_LENGTH].\n**\n** ^The [SQLITE_TRACE_SIZE_LIMIT] compile-time option limits the size of\n** bound parameter expansions.  ^The [SQLITE_OMIT_TRACE] compile-time\n** option causes sqlite3_expanded_sql() to always return NULL.\n**\n** ^The strings returned by sqlite3_sql(P) and sqlite3_normalized_sql(P)\n** are managed by SQLite and are automatically freed when the prepared\n** statement is finalized.\n** ^The string returned by sqlite3_expanded_sql(P), on the other hand,\n** is obtained from [sqlite3_malloc()] and must be free by the application\n** by passing it to [sqlite3_free()].\n*/\nSQLITE_API const char *sqlite3_sql(sqlite3_stmt *pStmt);\nSQLITE_API char *sqlite3_expanded_sql(sqlite3_stmt *pStmt);\nSQLITE_API const char *sqlite3_normalized_sql(sqlite3_stmt *pStmt);\n\n/*\n** CAPI3REF: Determine If An SQL Statement Writes The Database\n** METHOD: sqlite3_stmt\n**\n** ^The sqlite3_stmt_readonly(X) interface returns true (non-zero) if\n** and only if the [prepared statement] X makes no direct changes to\n** the content of the database file.\n**\n** Note that [application-defined SQL functions] or\n** [virtual tables] might change the database indirectly as a side effect.  \n** ^(For example, if an application defines a function \"eval()\" that \n** calls [sqlite3_exec()], then the following SQL statement would\n** change the database file through side-effects:\n**\n** <blockquote><pre>\n**    SELECT eval('DELETE FROM t1') FROM t2;\n** </pre></blockquote>\n**\n** But because the [SELECT] statement does not change the database file\n** directly, sqlite3_stmt_readonly() would still return true.)^\n**\n** ^Transaction control statements such as [BEGIN], [COMMIT], [ROLLBACK],\n** [SAVEPOINT], and [RELEASE] cause sqlite3_stmt_readonly() to return true,\n** since the statements themselves do not actually modify the database but\n** rather they control the timing of when other statements modify the \n** database.  ^The [ATTACH] and [DETACH] statements also cause\n** sqlite3_stmt_readonly() to return true since, while those statements\n** change the configuration of a database connection, they do not make \n** changes to the content of the database files on disk.\n** ^The sqlite3_stmt_readonly() interface returns true for [BEGIN] since\n** [BEGIN] merely sets internal flags, but the [BEGIN|BEGIN IMMEDIATE] and\n** [BEGIN|BEGIN EXCLUSIVE] commands do touch the database and so\n** sqlite3_stmt_readonly() returns false for those commands.\n*/\nSQLITE_API int sqlite3_stmt_readonly(sqlite3_stmt *pStmt);\n\n/*\n** CAPI3REF: Determine If A Prepared Statement Has Been Reset\n** METHOD: sqlite3_stmt\n**\n** ^The sqlite3_stmt_busy(S) interface returns true (non-zero) if the\n** [prepared statement] S has been stepped at least once using \n** [sqlite3_step(S)] but has neither run to completion (returned\n** [SQLITE_DONE] from [sqlite3_step(S)]) nor\n** been reset using [sqlite3_reset(S)].  ^The sqlite3_stmt_busy(S)\n** interface returns false if S is a NULL pointer.  If S is not a \n** NULL pointer and is not a pointer to a valid [prepared statement]\n** object, then the behavior is undefined and probably undesirable.\n**\n** This interface can be used in combination [sqlite3_next_stmt()]\n** to locate all prepared statements associated with a database \n** connection that are in need of being reset.  This can be used,\n** for example, in diagnostic routines to search for prepared \n** statements that are holding a transaction open.\n*/\nSQLITE_API int sqlite3_stmt_busy(sqlite3_stmt*);\n\n/*\n** CAPI3REF: Dynamically Typed Value Object\n** KEYWORDS: {protected sqlite3_value} {unprotected sqlite3_value}\n**\n** SQLite uses the sqlite3_value object to represent all values\n** that can be stored in a database table. SQLite uses dynamic typing\n** for the values it stores.  ^Values stored in sqlite3_value objects\n** can be integers, floating point values, strings, BLOBs, or NULL.\n**\n** An sqlite3_value object may be either \"protected\" or \"unprotected\".\n** Some interfaces require a protected sqlite3_value.  Other interfaces\n** will accept either a protected or an unprotected sqlite3_value.\n** Every interface that accepts sqlite3_value arguments specifies\n** whether or not it requires a protected sqlite3_value.  The\n** [sqlite3_value_dup()] interface can be used to construct a new \n** protected sqlite3_value from an unprotected sqlite3_value.\n**\n** The terms \"protected\" and \"unprotected\" refer to whether or not\n** a mutex is held.  An internal mutex is held for a protected\n** sqlite3_value object but no mutex is held for an unprotected\n** sqlite3_value object.  If SQLite is compiled to be single-threaded\n** (with [SQLITE_THREADSAFE=0] and with [sqlite3_threadsafe()] returning 0)\n** or if SQLite is run in one of reduced mutex modes \n** [SQLITE_CONFIG_SINGLETHREAD] or [SQLITE_CONFIG_MULTITHREAD]\n** then there is no distinction between protected and unprotected\n** sqlite3_value objects and they can be used interchangeably.  However,\n** for maximum code portability it is recommended that applications\n** still make the distinction between protected and unprotected\n** sqlite3_value objects even when not strictly required.\n**\n** ^The sqlite3_value objects that are passed as parameters into the\n** implementation of [application-defined SQL functions] are protected.\n** ^The sqlite3_value object returned by\n** [sqlite3_column_value()] is unprotected.\n** Unprotected sqlite3_value objects may only be used as arguments\n** to [sqlite3_result_value()], [sqlite3_bind_value()], and\n** [sqlite3_value_dup()].\n** The [sqlite3_value_blob | sqlite3_value_type()] family of\n** interfaces require protected sqlite3_value objects.\n*/\ntypedef struct sqlite3_value sqlite3_value;\n\n/*\n** CAPI3REF: SQL Function Context Object\n**\n** The context in which an SQL function executes is stored in an\n** sqlite3_context object.  ^A pointer to an sqlite3_context object\n** is always first parameter to [application-defined SQL functions].\n** The application-defined SQL function implementation will pass this\n** pointer through into calls to [sqlite3_result_int | sqlite3_result()],\n** [sqlite3_aggregate_context()], [sqlite3_user_data()],\n** [sqlite3_context_db_handle()], [sqlite3_get_auxdata()],\n** and/or [sqlite3_set_auxdata()].\n*/\ntypedef struct sqlite3_context sqlite3_context;\n\n/*\n** CAPI3REF: Binding Values To Prepared Statements\n** KEYWORDS: {host parameter} {host parameters} {host parameter name}\n** KEYWORDS: {SQL parameter} {SQL parameters} {parameter binding}\n** METHOD: sqlite3_stmt\n**\n** ^(In the SQL statement text input to [sqlite3_prepare_v2()] and its variants,\n** literals may be replaced by a [parameter] that matches one of following\n** templates:\n**\n** <ul>\n** <li>  ?\n** <li>  ?NNN\n** <li>  :VVV\n** <li>  @VVV\n** <li>  $VVV\n** </ul>\n**\n** In the templates above, NNN represents an integer literal,\n** and VVV represents an alphanumeric identifier.)^  ^The values of these\n** parameters (also called \"host parameter names\" or \"SQL parameters\")\n** can be set using the sqlite3_bind_*() routines defined here.\n**\n** ^The first argument to the sqlite3_bind_*() routines is always\n** a pointer to the [sqlite3_stmt] object returned from\n** [sqlite3_prepare_v2()] or its variants.\n**\n** ^The second argument is the index of the SQL parameter to be set.\n** ^The leftmost SQL parameter has an index of 1.  ^When the same named\n** SQL parameter is used more than once, second and subsequent\n** occurrences have the same index as the first occurrence.\n** ^The index for named parameters can be looked up using the\n** [sqlite3_bind_parameter_index()] API if desired.  ^The index\n** for \"?NNN\" parameters is the value of NNN.\n** ^The NNN value must be between 1 and the [sqlite3_limit()]\n** parameter [SQLITE_LIMIT_VARIABLE_NUMBER] (default value: 999).\n**\n** ^The third argument is the value to bind to the parameter.\n** ^If the third parameter to sqlite3_bind_text() or sqlite3_bind_text16()\n** or sqlite3_bind_blob() is a NULL pointer then the fourth parameter\n** is ignored and the end result is the same as sqlite3_bind_null().\n**\n** ^(In those routines that have a fourth argument, its value is the\n** number of bytes in the parameter.  To be clear: the value is the\n** number of <u>bytes</u> in the value, not the number of characters.)^\n** ^If the fourth parameter to sqlite3_bind_text() or sqlite3_bind_text16()\n** is negative, then the length of the string is\n** the number of bytes up to the first zero terminator.\n** If the fourth parameter to sqlite3_bind_blob() is negative, then\n** the behavior is undefined.\n** If a non-negative fourth parameter is provided to sqlite3_bind_text()\n** or sqlite3_bind_text16() or sqlite3_bind_text64() then\n** that parameter must be the byte offset\n** where the NUL terminator would occur assuming the string were NUL\n** terminated.  If any NUL characters occur at byte offsets less than \n** the value of the fourth parameter then the resulting string value will\n** contain embedded NULs.  The result of expressions involving strings\n** with embedded NULs is undefined.\n**\n** ^The fifth argument to the BLOB and string binding interfaces\n** is a destructor used to dispose of the BLOB or\n** string after SQLite has finished with it.  ^The destructor is called\n** to dispose of the BLOB or string even if the call to bind API fails.\n** ^If the fifth argument is\n** the special value [SQLITE_STATIC], then SQLite assumes that the\n** information is in static, unmanaged space and does not need to be freed.\n** ^If the fifth argument has the value [SQLITE_TRANSIENT], then\n** SQLite makes its own private copy of the data immediately, before\n** the sqlite3_bind_*() routine returns.\n**\n** ^The sixth argument to sqlite3_bind_text64() must be one of\n** [SQLITE_UTF8], [SQLITE_UTF16], [SQLITE_UTF16BE], or [SQLITE_UTF16LE]\n** to specify the encoding of the text in the third parameter.  If\n** the sixth argument to sqlite3_bind_text64() is not one of the\n** allowed values shown above, or if the text encoding is different\n** from the encoding specified by the sixth parameter, then the behavior\n** is undefined.\n**\n** ^The sqlite3_bind_zeroblob() routine binds a BLOB of length N that\n** is filled with zeroes.  ^A zeroblob uses a fixed amount of memory\n** (just an integer to hold its size) while it is being processed.\n** Zeroblobs are intended to serve as placeholders for BLOBs whose\n** content is later written using\n** [sqlite3_blob_open | incremental BLOB I/O] routines.\n** ^A negative value for the zeroblob results in a zero-length BLOB.\n**\n** ^The sqlite3_bind_pointer(S,I,P,T,D) routine causes the I-th parameter in\n** [prepared statement] S to have an SQL value of NULL, but to also be\n** associated with the pointer P of type T.  ^D is either a NULL pointer or\n** a pointer to a destructor function for P. ^SQLite will invoke the\n** destructor D with a single argument of P when it is finished using\n** P.  The T parameter should be a static string, preferably a string\n** literal. The sqlite3_bind_pointer() routine is part of the\n** [pointer passing interface] added for SQLite 3.20.0.\n**\n** ^If any of the sqlite3_bind_*() routines are called with a NULL pointer\n** for the [prepared statement] or with a prepared statement for which\n** [sqlite3_step()] has been called more recently than [sqlite3_reset()],\n** then the call will return [SQLITE_MISUSE].  If any sqlite3_bind_()\n** routine is passed a [prepared statement] that has been finalized, the\n** result is undefined and probably harmful.\n**\n** ^Bindings are not cleared by the [sqlite3_reset()] routine.\n** ^Unbound parameters are interpreted as NULL.\n**\n** ^The sqlite3_bind_* routines return [SQLITE_OK] on success or an\n** [error code] if anything goes wrong.\n** ^[SQLITE_TOOBIG] might be returned if the size of a string or BLOB\n** exceeds limits imposed by [sqlite3_limit]([SQLITE_LIMIT_LENGTH]) or\n** [SQLITE_MAX_LENGTH].\n** ^[SQLITE_RANGE] is returned if the parameter\n** index is out of range.  ^[SQLITE_NOMEM] is returned if malloc() fails.\n**\n** See also: [sqlite3_bind_parameter_count()],\n** [sqlite3_bind_parameter_name()], and [sqlite3_bind_parameter_index()].\n*/\nSQLITE_API int sqlite3_bind_blob(sqlite3_stmt*, int, const void*, int n, void(*)(void*));\nSQLITE_API int sqlite3_bind_blob64(sqlite3_stmt*, int, const void*, sqlite3_uint64,\n                        void(*)(void*));\nSQLITE_API int sqlite3_bind_double(sqlite3_stmt*, int, double);\nSQLITE_API int sqlite3_bind_int(sqlite3_stmt*, int, int);\nSQLITE_API int sqlite3_bind_int64(sqlite3_stmt*, int, sqlite3_int64);\nSQLITE_API int sqlite3_bind_null(sqlite3_stmt*, int);\nSQLITE_API int sqlite3_bind_text(sqlite3_stmt*,int,const char*,int,void(*)(void*));\nSQLITE_API int sqlite3_bind_text16(sqlite3_stmt*, int, const void*, int, void(*)(void*));\nSQLITE_API int sqlite3_bind_text64(sqlite3_stmt*, int, const char*, sqlite3_uint64,\n                         void(*)(void*), unsigned char encoding);\nSQLITE_API int sqlite3_bind_value(sqlite3_stmt*, int, const sqlite3_value*);\nSQLITE_API int sqlite3_bind_pointer(sqlite3_stmt*, int, void*, const char*,void(*)(void*));\nSQLITE_API int sqlite3_bind_zeroblob(sqlite3_stmt*, int, int n);\nSQLITE_API int sqlite3_bind_zeroblob64(sqlite3_stmt*, int, sqlite3_uint64);\n\n/*\n** CAPI3REF: Number Of SQL Parameters\n** METHOD: sqlite3_stmt\n**\n** ^This routine can be used to find the number of [SQL parameters]\n** in a [prepared statement].  SQL parameters are tokens of the\n** form \"?\", \"?NNN\", \":AAA\", \"$AAA\", or \"@AAA\" that serve as\n** placeholders for values that are [sqlite3_bind_blob | bound]\n** to the parameters at a later time.\n**\n** ^(This routine actually returns the index of the largest (rightmost)\n** parameter. For all forms except ?NNN, this will correspond to the\n** number of unique parameters.  If parameters of the ?NNN form are used,\n** there may be gaps in the list.)^\n**\n** See also: [sqlite3_bind_blob|sqlite3_bind()],\n** [sqlite3_bind_parameter_name()], and\n** [sqlite3_bind_parameter_index()].\n*/\nSQLITE_API int sqlite3_bind_parameter_count(sqlite3_stmt*);\n\n/*\n** CAPI3REF: Name Of A Host Parameter\n** METHOD: sqlite3_stmt\n**\n** ^The sqlite3_bind_parameter_name(P,N) interface returns\n** the name of the N-th [SQL parameter] in the [prepared statement] P.\n** ^(SQL parameters of the form \"?NNN\" or \":AAA\" or \"@AAA\" or \"$AAA\"\n** have a name which is the string \"?NNN\" or \":AAA\" or \"@AAA\" or \"$AAA\"\n** respectively.\n** In other words, the initial \":\" or \"$\" or \"@\" or \"?\"\n** is included as part of the name.)^\n** ^Parameters of the form \"?\" without a following integer have no name\n** and are referred to as \"nameless\" or \"anonymous parameters\".\n**\n** ^The first host parameter has an index of 1, not 0.\n**\n** ^If the value N is out of range or if the N-th parameter is\n** nameless, then NULL is returned.  ^The returned string is\n** always in UTF-8 encoding even if the named parameter was\n** originally specified as UTF-16 in [sqlite3_prepare16()],\n** [sqlite3_prepare16_v2()], or [sqlite3_prepare16_v3()].\n**\n** See also: [sqlite3_bind_blob|sqlite3_bind()],\n** [sqlite3_bind_parameter_count()], and\n** [sqlite3_bind_parameter_index()].\n*/\nSQLITE_API const char *sqlite3_bind_parameter_name(sqlite3_stmt*, int);\n\n/*\n** CAPI3REF: Index Of A Parameter With A Given Name\n** METHOD: sqlite3_stmt\n**\n** ^Return the index of an SQL parameter given its name.  ^The\n** index value returned is suitable for use as the second\n** parameter to [sqlite3_bind_blob|sqlite3_bind()].  ^A zero\n** is returned if no matching parameter is found.  ^The parameter\n** name must be given in UTF-8 even if the original statement\n** was prepared from UTF-16 text using [sqlite3_prepare16_v2()] or\n** [sqlite3_prepare16_v3()].\n**\n** See also: [sqlite3_bind_blob|sqlite3_bind()],\n** [sqlite3_bind_parameter_count()], and\n** [sqlite3_bind_parameter_name()].\n*/\nSQLITE_API int sqlite3_bind_parameter_index(sqlite3_stmt*, const char *zName);\n\n/*\n** CAPI3REF: Reset All Bindings On A Prepared Statement\n** METHOD: sqlite3_stmt\n**\n** ^Contrary to the intuition of many, [sqlite3_reset()] does not reset\n** the [sqlite3_bind_blob | bindings] on a [prepared statement].\n** ^Use this routine to reset all host parameters to NULL.\n*/\nSQLITE_API int sqlite3_clear_bindings(sqlite3_stmt*);\n\n/*\n** CAPI3REF: Number Of Columns In A Result Set\n** METHOD: sqlite3_stmt\n**\n** ^Return the number of columns in the result set returned by the\n** [prepared statement]. ^If this routine returns 0, that means the \n** [prepared statement] returns no data (for example an [UPDATE]).\n** ^However, just because this routine returns a positive number does not\n** mean that one or more rows of data will be returned.  ^A SELECT statement\n** will always have a positive sqlite3_column_count() but depending on the\n** WHERE clause constraints and the table content, it might return no rows.\n**\n** See also: [sqlite3_data_count()]\n*/\nSQLITE_API int sqlite3_column_count(sqlite3_stmt *pStmt);\n\n/*\n** CAPI3REF: Column Names In A Result Set\n** METHOD: sqlite3_stmt\n**\n** ^These routines return the name assigned to a particular column\n** in the result set of a [SELECT] statement.  ^The sqlite3_column_name()\n** interface returns a pointer to a zero-terminated UTF-8 string\n** and sqlite3_column_name16() returns a pointer to a zero-terminated\n** UTF-16 string.  ^The first parameter is the [prepared statement]\n** that implements the [SELECT] statement. ^The second parameter is the\n** column number.  ^The leftmost column is number 0.\n**\n** ^The returned string pointer is valid until either the [prepared statement]\n** is destroyed by [sqlite3_finalize()] or until the statement is automatically\n** reprepared by the first call to [sqlite3_step()] for a particular run\n** or until the next call to\n** sqlite3_column_name() or sqlite3_column_name16() on the same column.\n**\n** ^If sqlite3_malloc() fails during the processing of either routine\n** (for example during a conversion from UTF-8 to UTF-16) then a\n** NULL pointer is returned.\n**\n** ^The name of a result column is the value of the \"AS\" clause for\n** that column, if there is an AS clause.  If there is no AS clause\n** then the name of the column is unspecified and may change from\n** one release of SQLite to the next.\n*/\nSQLITE_API const char *sqlite3_column_name(sqlite3_stmt*, int N);\nSQLITE_API const void *sqlite3_column_name16(sqlite3_stmt*, int N);\n\n/*\n** CAPI3REF: Source Of Data In A Query Result\n** METHOD: sqlite3_stmt\n**\n** ^These routines provide a means to determine the database, table, and\n** table column that is the origin of a particular result column in\n** [SELECT] statement.\n** ^The name of the database or table or column can be returned as\n** either a UTF-8 or UTF-16 string.  ^The _database_ routines return\n** the database name, the _table_ routines return the table name, and\n** the origin_ routines return the column name.\n** ^The returned string is valid until the [prepared statement] is destroyed\n** using [sqlite3_finalize()] or until the statement is automatically\n** reprepared by the first call to [sqlite3_step()] for a particular run\n** or until the same information is requested\n** again in a different encoding.\n**\n** ^The names returned are the original un-aliased names of the\n** database, table, and column.\n**\n** ^The first argument to these interfaces is a [prepared statement].\n** ^These functions return information about the Nth result column returned by\n** the statement, where N is the second function argument.\n** ^The left-most column is column 0 for these routines.\n**\n** ^If the Nth column returned by the statement is an expression or\n** subquery and is not a column value, then all of these functions return\n** NULL.  ^These routine might also return NULL if a memory allocation error\n** occurs.  ^Otherwise, they return the name of the attached database, table,\n** or column that query result column was extracted from.\n**\n** ^As with all other SQLite APIs, those whose names end with \"16\" return\n** UTF-16 encoded strings and the other functions return UTF-8.\n**\n** ^These APIs are only available if the library was compiled with the\n** [SQLITE_ENABLE_COLUMN_METADATA] C-preprocessor symbol.\n**\n** If two or more threads call one or more of these routines against the same\n** prepared statement and column at the same time then the results are\n** undefined.\n**\n** If two or more threads call one or more\n** [sqlite3_column_database_name | column metadata interfaces]\n** for the same [prepared statement] and result column\n** at the same time then the results are undefined.\n*/\nSQLITE_API const char *sqlite3_column_database_name(sqlite3_stmt*,int);\nSQLITE_API const void *sqlite3_column_database_name16(sqlite3_stmt*,int);\nSQLITE_API const char *sqlite3_column_table_name(sqlite3_stmt*,int);\nSQLITE_API const void *sqlite3_column_table_name16(sqlite3_stmt*,int);\nSQLITE_API const char *sqlite3_column_origin_name(sqlite3_stmt*,int);\nSQLITE_API const void *sqlite3_column_origin_name16(sqlite3_stmt*,int);\n\n/*\n** CAPI3REF: Declared Datatype Of A Query Result\n** METHOD: sqlite3_stmt\n**\n** ^(The first parameter is a [prepared statement].\n** If this statement is a [SELECT] statement and the Nth column of the\n** returned result set of that [SELECT] is a table column (not an\n** expression or subquery) then the declared type of the table\n** column is returned.)^  ^If the Nth column of the result set is an\n** expression or subquery, then a NULL pointer is returned.\n** ^The returned string is always UTF-8 encoded.\n**\n** ^(For example, given the database schema:\n**\n** CREATE TABLE t1(c1 VARIANT);\n**\n** and the following statement to be compiled:\n**\n** SELECT c1 + 1, c1 FROM t1;\n**\n** this routine would return the string \"VARIANT\" for the second result\n** column (i==1), and a NULL pointer for the first result column (i==0).)^\n**\n** ^SQLite uses dynamic run-time typing.  ^So just because a column\n** is declared to contain a particular type does not mean that the\n** data stored in that column is of the declared type.  SQLite is\n** strongly typed, but the typing is dynamic not static.  ^Type\n** is associated with individual values, not with the containers\n** used to hold those values.\n*/\nSQLITE_API const char *sqlite3_column_decltype(sqlite3_stmt*,int);\nSQLITE_API const void *sqlite3_column_decltype16(sqlite3_stmt*,int);\n\n/*\n** CAPI3REF: Evaluate An SQL Statement\n** METHOD: sqlite3_stmt\n**\n** After a [prepared statement] has been prepared using any of\n** [sqlite3_prepare_v2()], [sqlite3_prepare_v3()], [sqlite3_prepare16_v2()],\n** or [sqlite3_prepare16_v3()] or one of the legacy\n** interfaces [sqlite3_prepare()] or [sqlite3_prepare16()], this function\n** must be called one or more times to evaluate the statement.\n**\n** The details of the behavior of the sqlite3_step() interface depend\n** on whether the statement was prepared using the newer \"vX\" interfaces\n** [sqlite3_prepare_v3()], [sqlite3_prepare_v2()], [sqlite3_prepare16_v3()],\n** [sqlite3_prepare16_v2()] or the older legacy\n** interfaces [sqlite3_prepare()] and [sqlite3_prepare16()].  The use of the\n** new \"vX\" interface is recommended for new applications but the legacy\n** interface will continue to be supported.\n**\n** ^In the legacy interface, the return value will be either [SQLITE_BUSY],\n** [SQLITE_DONE], [SQLITE_ROW], [SQLITE_ERROR], or [SQLITE_MISUSE].\n** ^With the \"v2\" interface, any of the other [result codes] or\n** [extended result codes] might be returned as well.\n**\n** ^[SQLITE_BUSY] means that the database engine was unable to acquire the\n** database locks it needs to do its job.  ^If the statement is a [COMMIT]\n** or occurs outside of an explicit transaction, then you can retry the\n** statement.  If the statement is not a [COMMIT] and occurs within an\n** explicit transaction then you should rollback the transaction before\n** continuing.\n**\n** ^[SQLITE_DONE] means that the statement has finished executing\n** successfully.  sqlite3_step() should not be called again on this virtual\n** machine without first calling [sqlite3_reset()] to reset the virtual\n** machine back to its initial state.\n**\n** ^If the SQL statement being executed returns any data, then [SQLITE_ROW]\n** is returned each time a new row of data is ready for processing by the\n** caller. The values may be accessed using the [column access functions].\n** sqlite3_step() is called again to retrieve the next row of data.\n**\n** ^[SQLITE_ERROR] means that a run-time error (such as a constraint\n** violation) has occurred.  sqlite3_step() should not be called again on\n** the VM. More information may be found by calling [sqlite3_errmsg()].\n** ^With the legacy interface, a more specific error code (for example,\n** [SQLITE_INTERRUPT], [SQLITE_SCHEMA], [SQLITE_CORRUPT], and so forth)\n** can be obtained by calling [sqlite3_reset()] on the\n** [prepared statement].  ^In the \"v2\" interface,\n** the more specific error code is returned directly by sqlite3_step().\n**\n** [SQLITE_MISUSE] means that the this routine was called inappropriately.\n** Perhaps it was called on a [prepared statement] that has\n** already been [sqlite3_finalize | finalized] or on one that had\n** previously returned [SQLITE_ERROR] or [SQLITE_DONE].  Or it could\n** be the case that the same database connection is being used by two or\n** more threads at the same moment in time.\n**\n** For all versions of SQLite up to and including 3.6.23.1, a call to\n** [sqlite3_reset()] was required after sqlite3_step() returned anything\n** other than [SQLITE_ROW] before any subsequent invocation of\n** sqlite3_step().  Failure to reset the prepared statement using \n** [sqlite3_reset()] would result in an [SQLITE_MISUSE] return from\n** sqlite3_step().  But after [version 3.6.23.1] ([dateof:3.6.23.1],\n** sqlite3_step() began\n** calling [sqlite3_reset()] automatically in this circumstance rather\n** than returning [SQLITE_MISUSE].  This is not considered a compatibility\n** break because any application that ever receives an SQLITE_MISUSE error\n** is broken by definition.  The [SQLITE_OMIT_AUTORESET] compile-time option\n** can be used to restore the legacy behavior.\n**\n** <b>Goofy Interface Alert:</b> In the legacy interface, the sqlite3_step()\n** API always returns a generic error code, [SQLITE_ERROR], following any\n** error other than [SQLITE_BUSY] and [SQLITE_MISUSE].  You must call\n** [sqlite3_reset()] or [sqlite3_finalize()] in order to find one of the\n** specific [error codes] that better describes the error.\n** We admit that this is a goofy design.  The problem has been fixed\n** with the \"v2\" interface.  If you prepare all of your SQL statements\n** using [sqlite3_prepare_v3()] or [sqlite3_prepare_v2()]\n** or [sqlite3_prepare16_v2()] or [sqlite3_prepare16_v3()] instead\n** of the legacy [sqlite3_prepare()] and [sqlite3_prepare16()] interfaces,\n** then the more specific [error codes] are returned directly\n** by sqlite3_step().  The use of the \"vX\" interfaces is recommended.\n*/\nSQLITE_API int sqlite3_step(sqlite3_stmt*);\n\n/*\n** CAPI3REF: Number of columns in a result set\n** METHOD: sqlite3_stmt\n**\n** ^The sqlite3_data_count(P) interface returns the number of columns in the\n** current row of the result set of [prepared statement] P.\n** ^If prepared statement P does not have results ready to return\n** (via calls to the [sqlite3_column_int | sqlite3_column_*()] of\n** interfaces) then sqlite3_data_count(P) returns 0.\n** ^The sqlite3_data_count(P) routine also returns 0 if P is a NULL pointer.\n** ^The sqlite3_data_count(P) routine returns 0 if the previous call to\n** [sqlite3_step](P) returned [SQLITE_DONE].  ^The sqlite3_data_count(P)\n** will return non-zero if previous call to [sqlite3_step](P) returned\n** [SQLITE_ROW], except in the case of the [PRAGMA incremental_vacuum]\n** where it always returns zero since each step of that multi-step\n** pragma returns 0 columns of data.\n**\n** See also: [sqlite3_column_count()]\n*/\nSQLITE_API int sqlite3_data_count(sqlite3_stmt *pStmt);\n\n/*\n** CAPI3REF: Fundamental Datatypes\n** KEYWORDS: SQLITE_TEXT\n**\n** ^(Every value in SQLite has one of five fundamental datatypes:\n**\n** <ul>\n** <li> 64-bit signed integer\n** <li> 64-bit IEEE floating point number\n** <li> string\n** <li> BLOB\n** <li> NULL\n** </ul>)^\n**\n** These constants are codes for each of those types.\n**\n** Note that the SQLITE_TEXT constant was also used in SQLite version 2\n** for a completely different meaning.  Software that links against both\n** SQLite version 2 and SQLite version 3 should use SQLITE3_TEXT, not\n** SQLITE_TEXT.\n*/\n#define SQLITE_INTEGER  1\n#define SQLITE_FLOAT    2\n#define SQLITE_BLOB     4\n#define SQLITE_NULL     5\n#ifdef SQLITE_TEXT\n# undef SQLITE_TEXT\n#else\n# define SQLITE_TEXT     3\n#endif\n#define SQLITE3_TEXT     3\n\n/*\n** CAPI3REF: Result Values From A Query\n** KEYWORDS: {column access functions}\n** METHOD: sqlite3_stmt\n**\n** <b>Summary:</b>\n** <blockquote><table border=0 cellpadding=0 cellspacing=0>\n** <tr><td><b>sqlite3_column_blob</b><td>&rarr;<td>BLOB result\n** <tr><td><b>sqlite3_column_double</b><td>&rarr;<td>REAL result\n** <tr><td><b>sqlite3_column_int</b><td>&rarr;<td>32-bit INTEGER result\n** <tr><td><b>sqlite3_column_int64</b><td>&rarr;<td>64-bit INTEGER result\n** <tr><td><b>sqlite3_column_text</b><td>&rarr;<td>UTF-8 TEXT result\n** <tr><td><b>sqlite3_column_text16</b><td>&rarr;<td>UTF-16 TEXT result\n** <tr><td><b>sqlite3_column_value</b><td>&rarr;<td>The result as an \n** [sqlite3_value|unprotected sqlite3_value] object.\n** <tr><td>&nbsp;<td>&nbsp;<td>&nbsp;\n** <tr><td><b>sqlite3_column_bytes</b><td>&rarr;<td>Size of a BLOB\n** or a UTF-8 TEXT result in bytes\n** <tr><td><b>sqlite3_column_bytes16&nbsp;&nbsp;</b>\n** <td>&rarr;&nbsp;&nbsp;<td>Size of UTF-16\n** TEXT in bytes\n** <tr><td><b>sqlite3_column_type</b><td>&rarr;<td>Default\n** datatype of the result\n** </table></blockquote>\n**\n** <b>Details:</b>\n**\n** ^These routines return information about a single column of the current\n** result row of a query.  ^In every case the first argument is a pointer\n** to the [prepared statement] that is being evaluated (the [sqlite3_stmt*]\n** that was returned from [sqlite3_prepare_v2()] or one of its variants)\n** and the second argument is the index of the column for which information\n** should be returned. ^The leftmost column of the result set has the index 0.\n** ^The number of columns in the result can be determined using\n** [sqlite3_column_count()].\n**\n** If the SQL statement does not currently point to a valid row, or if the\n** column index is out of range, the result is undefined.\n** These routines may only be called when the most recent call to\n** [sqlite3_step()] has returned [SQLITE_ROW] and neither\n** [sqlite3_reset()] nor [sqlite3_finalize()] have been called subsequently.\n** If any of these routines are called after [sqlite3_reset()] or\n** [sqlite3_finalize()] or after [sqlite3_step()] has returned\n** something other than [SQLITE_ROW], the results are undefined.\n** If [sqlite3_step()] or [sqlite3_reset()] or [sqlite3_finalize()]\n** are called from a different thread while any of these routines\n** are pending, then the results are undefined.\n**\n** The first six interfaces (_blob, _double, _int, _int64, _text, and _text16)\n** each return the value of a result column in a specific data format.  If\n** the result column is not initially in the requested format (for example,\n** if the query returns an integer but the sqlite3_column_text() interface\n** is used to extract the value) then an automatic type conversion is performed.\n**\n** ^The sqlite3_column_type() routine returns the\n** [SQLITE_INTEGER | datatype code] for the initial data type\n** of the result column.  ^The returned value is one of [SQLITE_INTEGER],\n** [SQLITE_FLOAT], [SQLITE_TEXT], [SQLITE_BLOB], or [SQLITE_NULL].\n** The return value of sqlite3_column_type() can be used to decide which\n** of the first six interface should be used to extract the column value.\n** The value returned by sqlite3_column_type() is only meaningful if no\n** automatic type conversions have occurred for the value in question.  \n** After a type conversion, the result of calling sqlite3_column_type()\n** is undefined, though harmless.  Future\n** versions of SQLite may change the behavior of sqlite3_column_type()\n** following a type conversion.\n**\n** If the result is a BLOB or a TEXT string, then the sqlite3_column_bytes()\n** or sqlite3_column_bytes16() interfaces can be used to determine the size\n** of that BLOB or string.\n**\n** ^If the result is a BLOB or UTF-8 string then the sqlite3_column_bytes()\n** routine returns the number of bytes in that BLOB or string.\n** ^If the result is a UTF-16 string, then sqlite3_column_bytes() converts\n** the string to UTF-8 and then returns the number of bytes.\n** ^If the result is a numeric value then sqlite3_column_bytes() uses\n** [sqlite3_snprintf()] to convert that value to a UTF-8 string and returns\n** the number of bytes in that string.\n** ^If the result is NULL, then sqlite3_column_bytes() returns zero.\n**\n** ^If the result is a BLOB or UTF-16 string then the sqlite3_column_bytes16()\n** routine returns the number of bytes in that BLOB or string.\n** ^If the result is a UTF-8 string, then sqlite3_column_bytes16() converts\n** the string to UTF-16 and then returns the number of bytes.\n** ^If the result is a numeric value then sqlite3_column_bytes16() uses\n** [sqlite3_snprintf()] to convert that value to a UTF-16 string and returns\n** the number of bytes in that string.\n** ^If the result is NULL, then sqlite3_column_bytes16() returns zero.\n**\n** ^The values returned by [sqlite3_column_bytes()] and \n** [sqlite3_column_bytes16()] do not include the zero terminators at the end\n** of the string.  ^For clarity: the values returned by\n** [sqlite3_column_bytes()] and [sqlite3_column_bytes16()] are the number of\n** bytes in the string, not the number of characters.\n**\n** ^Strings returned by sqlite3_column_text() and sqlite3_column_text16(),\n** even empty strings, are always zero-terminated.  ^The return\n** value from sqlite3_column_blob() for a zero-length BLOB is a NULL pointer.\n**\n** <b>Warning:</b> ^The object returned by [sqlite3_column_value()] is an\n** [unprotected sqlite3_value] object.  In a multithreaded environment,\n** an unprotected sqlite3_value object may only be used safely with\n** [sqlite3_bind_value()] and [sqlite3_result_value()].\n** If the [unprotected sqlite3_value] object returned by\n** [sqlite3_column_value()] is used in any other way, including calls\n** to routines like [sqlite3_value_int()], [sqlite3_value_text()],\n** or [sqlite3_value_bytes()], the behavior is not threadsafe.\n** Hence, the sqlite3_column_value() interface\n** is normally only useful within the implementation of \n** [application-defined SQL functions] or [virtual tables], not within\n** top-level application code.\n**\n** The these routines may attempt to convert the datatype of the result.\n** ^For example, if the internal representation is FLOAT and a text result\n** is requested, [sqlite3_snprintf()] is used internally to perform the\n** conversion automatically.  ^(The following table details the conversions\n** that are applied:\n**\n** <blockquote>\n** <table border=\"1\">\n** <tr><th> Internal<br>Type <th> Requested<br>Type <th>  Conversion\n**\n** <tr><td>  NULL    <td> INTEGER   <td> Result is 0\n** <tr><td>  NULL    <td>  FLOAT    <td> Result is 0.0\n** <tr><td>  NULL    <td>   TEXT    <td> Result is a NULL pointer\n** <tr><td>  NULL    <td>   BLOB    <td> Result is a NULL pointer\n** <tr><td> INTEGER  <td>  FLOAT    <td> Convert from integer to float\n** <tr><td> INTEGER  <td>   TEXT    <td> ASCII rendering of the integer\n** <tr><td> INTEGER  <td>   BLOB    <td> Same as INTEGER->TEXT\n** <tr><td>  FLOAT   <td> INTEGER   <td> [CAST] to INTEGER\n** <tr><td>  FLOAT   <td>   TEXT    <td> ASCII rendering of the float\n** <tr><td>  FLOAT   <td>   BLOB    <td> [CAST] to BLOB\n** <tr><td>  TEXT    <td> INTEGER   <td> [CAST] to INTEGER\n** <tr><td>  TEXT    <td>  FLOAT    <td> [CAST] to REAL\n** <tr><td>  TEXT    <td>   BLOB    <td> No change\n** <tr><td>  BLOB    <td> INTEGER   <td> [CAST] to INTEGER\n** <tr><td>  BLOB    <td>  FLOAT    <td> [CAST] to REAL\n** <tr><td>  BLOB    <td>   TEXT    <td> Add a zero terminator if needed\n** </table>\n** </blockquote>)^\n**\n** Note that when type conversions occur, pointers returned by prior\n** calls to sqlite3_column_blob(), sqlite3_column_text(), and/or\n** sqlite3_column_text16() may be invalidated.\n** Type conversions and pointer invalidations might occur\n** in the following cases:\n**\n** <ul>\n** <li> The initial content is a BLOB and sqlite3_column_text() or\n**      sqlite3_column_text16() is called.  A zero-terminator might\n**      need to be added to the string.</li>\n** <li> The initial content is UTF-8 text and sqlite3_column_bytes16() or\n**      sqlite3_column_text16() is called.  The content must be converted\n**      to UTF-16.</li>\n** <li> The initial content is UTF-16 text and sqlite3_column_bytes() or\n**      sqlite3_column_text() is called.  The content must be converted\n**      to UTF-8.</li>\n** </ul>\n**\n** ^Conversions between UTF-16be and UTF-16le are always done in place and do\n** not invalidate a prior pointer, though of course the content of the buffer\n** that the prior pointer references will have been modified.  Other kinds\n** of conversion are done in place when it is possible, but sometimes they\n** are not possible and in those cases prior pointers are invalidated.\n**\n** The safest policy is to invoke these routines\n** in one of the following ways:\n**\n** <ul>\n**  <li>sqlite3_column_text() followed by sqlite3_column_bytes()</li>\n**  <li>sqlite3_column_blob() followed by sqlite3_column_bytes()</li>\n**  <li>sqlite3_column_text16() followed by sqlite3_column_bytes16()</li>\n** </ul>\n**\n** In other words, you should call sqlite3_column_text(),\n** sqlite3_column_blob(), or sqlite3_column_text16() first to force the result\n** into the desired format, then invoke sqlite3_column_bytes() or\n** sqlite3_column_bytes16() to find the size of the result.  Do not mix calls\n** to sqlite3_column_text() or sqlite3_column_blob() with calls to\n** sqlite3_column_bytes16(), and do not mix calls to sqlite3_column_text16()\n** with calls to sqlite3_column_bytes().\n**\n** ^The pointers returned are valid until a type conversion occurs as\n** described above, or until [sqlite3_step()] or [sqlite3_reset()] or\n** [sqlite3_finalize()] is called.  ^The memory space used to hold strings\n** and BLOBs is freed automatically.  Do not pass the pointers returned\n** from [sqlite3_column_blob()], [sqlite3_column_text()], etc. into\n** [sqlite3_free()].\n**\n** As long as the input parameters are correct, these routines will only\n** fail if an out-of-memory error occurs during a format conversion.\n** Only the following subset of interfaces are subject to out-of-memory\n** errors:\n**\n** <ul>\n** <li> sqlite3_column_blob()\n** <li> sqlite3_column_text()\n** <li> sqlite3_column_text16()\n** <li> sqlite3_column_bytes()\n** <li> sqlite3_column_bytes16()\n** </ul>\n**\n** If an out-of-memory error occurs, then the return value from these\n** routines is the same as if the column had contained an SQL NULL value.\n** Valid SQL NULL returns can be distinguished from out-of-memory errors\n** by invoking the [sqlite3_errcode()] immediately after the suspect\n** return value is obtained and before any\n** other SQLite interface is called on the same [database connection].\n*/\nSQLITE_API const void *sqlite3_column_blob(sqlite3_stmt*, int iCol);\nSQLITE_API double sqlite3_column_double(sqlite3_stmt*, int iCol);\nSQLITE_API int sqlite3_column_int(sqlite3_stmt*, int iCol);\nSQLITE_API sqlite3_int64 sqlite3_column_int64(sqlite3_stmt*, int iCol);\nSQLITE_API const unsigned char *sqlite3_column_text(sqlite3_stmt*, int iCol);\nSQLITE_API const void *sqlite3_column_text16(sqlite3_stmt*, int iCol);\nSQLITE_API sqlite3_value *sqlite3_column_value(sqlite3_stmt*, int iCol);\nSQLITE_API int sqlite3_column_bytes(sqlite3_stmt*, int iCol);\nSQLITE_API int sqlite3_column_bytes16(sqlite3_stmt*, int iCol);\nSQLITE_API int sqlite3_column_type(sqlite3_stmt*, int iCol);\n\n/*\n** CAPI3REF: Destroy A Prepared Statement Object\n** DESTRUCTOR: sqlite3_stmt\n**\n** ^The sqlite3_finalize() function is called to delete a [prepared statement].\n** ^If the most recent evaluation of the statement encountered no errors\n** or if the statement is never been evaluated, then sqlite3_finalize() returns\n** SQLITE_OK.  ^If the most recent evaluation of statement S failed, then\n** sqlite3_finalize(S) returns the appropriate [error code] or\n** [extended error code].\n**\n** ^The sqlite3_finalize(S) routine can be called at any point during\n** the life cycle of [prepared statement] S:\n** before statement S is ever evaluated, after\n** one or more calls to [sqlite3_reset()], or after any call\n** to [sqlite3_step()] regardless of whether or not the statement has\n** completed execution.\n**\n** ^Invoking sqlite3_finalize() on a NULL pointer is a harmless no-op.\n**\n** The application must finalize every [prepared statement] in order to avoid\n** resource leaks.  It is a grievous error for the application to try to use\n** a prepared statement after it has been finalized.  Any use of a prepared\n** statement after it has been finalized can result in undefined and\n** undesirable behavior such as segfaults and heap corruption.\n*/\nSQLITE_API int sqlite3_finalize(sqlite3_stmt *pStmt);\n\n/*\n** CAPI3REF: Reset A Prepared Statement Object\n** METHOD: sqlite3_stmt\n**\n** The sqlite3_reset() function is called to reset a [prepared statement]\n** object back to its initial state, ready to be re-executed.\n** ^Any SQL statement variables that had values bound to them using\n** the [sqlite3_bind_blob | sqlite3_bind_*() API] retain their values.\n** Use [sqlite3_clear_bindings()] to reset the bindings.\n**\n** ^The [sqlite3_reset(S)] interface resets the [prepared statement] S\n** back to the beginning of its program.\n**\n** ^If the most recent call to [sqlite3_step(S)] for the\n** [prepared statement] S returned [SQLITE_ROW] or [SQLITE_DONE],\n** or if [sqlite3_step(S)] has never before been called on S,\n** then [sqlite3_reset(S)] returns [SQLITE_OK].\n**\n** ^If the most recent call to [sqlite3_step(S)] for the\n** [prepared statement] S indicated an error, then\n** [sqlite3_reset(S)] returns an appropriate [error code].\n**\n** ^The [sqlite3_reset(S)] interface does not change the values\n** of any [sqlite3_bind_blob|bindings] on the [prepared statement] S.\n*/\nSQLITE_API int sqlite3_reset(sqlite3_stmt *pStmt);\n\n/*\n** CAPI3REF: Create Or Redefine SQL Functions\n** KEYWORDS: {function creation routines}\n** KEYWORDS: {application-defined SQL function}\n** KEYWORDS: {application-defined SQL functions}\n** METHOD: sqlite3\n**\n** ^These functions (collectively known as \"function creation routines\")\n** are used to add SQL functions or aggregates or to redefine the behavior\n** of existing SQL functions or aggregates. The only differences between\n** the three \"sqlite3_create_function*\" routines are the text encoding \n** expected for the second parameter (the name of the function being \n** created) and the presence or absence of a destructor callback for\n** the application data pointer. Function sqlite3_create_window_function()\n** is similar, but allows the user to supply the extra callback functions\n** needed by [aggregate window functions].\n**\n** ^The first parameter is the [database connection] to which the SQL\n** function is to be added.  ^If an application uses more than one database\n** connection then application-defined SQL functions must be added\n** to each database connection separately.\n**\n** ^The second parameter is the name of the SQL function to be created or\n** redefined.  ^The length of the name is limited to 255 bytes in a UTF-8\n** representation, exclusive of the zero-terminator.  ^Note that the name\n** length limit is in UTF-8 bytes, not characters nor UTF-16 bytes.  \n** ^Any attempt to create a function with a longer name\n** will result in [SQLITE_MISUSE] being returned.\n**\n** ^The third parameter (nArg)\n** is the number of arguments that the SQL function or\n** aggregate takes. ^If this parameter is -1, then the SQL function or\n** aggregate may take any number of arguments between 0 and the limit\n** set by [sqlite3_limit]([SQLITE_LIMIT_FUNCTION_ARG]).  If the third\n** parameter is less than -1 or greater than 127 then the behavior is\n** undefined.\n**\n** ^The fourth parameter, eTextRep, specifies what\n** [SQLITE_UTF8 | text encoding] this SQL function prefers for\n** its parameters.  The application should set this parameter to\n** [SQLITE_UTF16LE] if the function implementation invokes \n** [sqlite3_value_text16le()] on an input, or [SQLITE_UTF16BE] if the\n** implementation invokes [sqlite3_value_text16be()] on an input, or\n** [SQLITE_UTF16] if [sqlite3_value_text16()] is used, or [SQLITE_UTF8]\n** otherwise.  ^The same SQL function may be registered multiple times using\n** different preferred text encodings, with different implementations for\n** each encoding.\n** ^When multiple implementations of the same function are available, SQLite\n** will pick the one that involves the least amount of data conversion.\n**\n** ^The fourth parameter may optionally be ORed with [SQLITE_DETERMINISTIC]\n** to signal that the function will always return the same result given\n** the same inputs within a single SQL statement.  Most SQL functions are\n** deterministic.  The built-in [random()] SQL function is an example of a\n** function that is not deterministic.  The SQLite query planner is able to\n** perform additional optimizations on deterministic functions, so use\n** of the [SQLITE_DETERMINISTIC] flag is recommended where possible.\n**\n** ^(The fifth parameter is an arbitrary pointer.  The implementation of the\n** function can gain access to this pointer using [sqlite3_user_data()].)^\n**\n** ^The sixth, seventh and eighth parameters passed to the three\n** \"sqlite3_create_function*\" functions, xFunc, xStep and xFinal, are\n** pointers to C-language functions that implement the SQL function or\n** aggregate. ^A scalar SQL function requires an implementation of the xFunc\n** callback only; NULL pointers must be passed as the xStep and xFinal\n** parameters. ^An aggregate SQL function requires an implementation of xStep\n** and xFinal and NULL pointer must be passed for xFunc. ^To delete an existing\n** SQL function or aggregate, pass NULL pointers for all three function\n** callbacks.\n**\n** ^The sixth, seventh, eighth and ninth parameters (xStep, xFinal, xValue \n** and xInverse) passed to sqlite3_create_window_function are pointers to\n** C-language callbacks that implement the new function. xStep and xFinal\n** must both be non-NULL. xValue and xInverse may either both be NULL, in\n** which case a regular aggregate function is created, or must both be \n** non-NULL, in which case the new function may be used as either an aggregate\n** or aggregate window function. More details regarding the implementation\n** of aggregate window functions are \n** [user-defined window functions|available here].\n**\n** ^(If the final parameter to sqlite3_create_function_v2() or\n** sqlite3_create_window_function() is not NULL, then it is destructor for\n** the application data pointer. The destructor is invoked when the function \n** is deleted, either by being overloaded or when the database connection \n** closes.)^ ^The destructor is also invoked if the call to \n** sqlite3_create_function_v2() fails.  ^When the destructor callback is\n** invoked, it is passed a single argument which is a copy of the application\n** data pointer which was the fifth parameter to sqlite3_create_function_v2().\n**\n** ^It is permitted to register multiple implementations of the same\n** functions with the same name but with either differing numbers of\n** arguments or differing preferred text encodings.  ^SQLite will use\n** the implementation that most closely matches the way in which the\n** SQL function is used.  ^A function implementation with a non-negative\n** nArg parameter is a better match than a function implementation with\n** a negative nArg.  ^A function where the preferred text encoding\n** matches the database encoding is a better\n** match than a function where the encoding is different.  \n** ^A function where the encoding difference is between UTF16le and UTF16be\n** is a closer match than a function where the encoding difference is\n** between UTF8 and UTF16.\n**\n** ^Built-in functions may be overloaded by new application-defined functions.\n**\n** ^An application-defined function is permitted to call other\n** SQLite interfaces.  However, such calls must not\n** close the database connection nor finalize or reset the prepared\n** statement in which the function is running.\n*/\nSQLITE_API int sqlite3_create_function(\n  sqlite3 *db,\n  const char *zFunctionName,\n  int nArg,\n  int eTextRep,\n  void *pApp,\n  void (*xFunc)(sqlite3_context*,int,sqlite3_value**),\n  void (*xStep)(sqlite3_context*,int,sqlite3_value**),\n  void (*xFinal)(sqlite3_context*)\n);\nSQLITE_API int sqlite3_create_function16(\n  sqlite3 *db,\n  const void *zFunctionName,\n  int nArg,\n  int eTextRep,\n  void *pApp,\n  void (*xFunc)(sqlite3_context*,int,sqlite3_value**),\n  void (*xStep)(sqlite3_context*,int,sqlite3_value**),\n  void (*xFinal)(sqlite3_context*)\n);\nSQLITE_API int sqlite3_create_function_v2(\n  sqlite3 *db,\n  const char *zFunctionName,\n  int nArg,\n  int eTextRep,\n  void *pApp,\n  void (*xFunc)(sqlite3_context*,int,sqlite3_value**),\n  void (*xStep)(sqlite3_context*,int,sqlite3_value**),\n  void (*xFinal)(sqlite3_context*),\n  void(*xDestroy)(void*)\n);\nSQLITE_API int sqlite3_create_window_function(\n  sqlite3 *db,\n  const char *zFunctionName,\n  int nArg,\n  int eTextRep,\n  void *pApp,\n  void (*xStep)(sqlite3_context*,int,sqlite3_value**),\n  void (*xFinal)(sqlite3_context*),\n  void (*xValue)(sqlite3_context*),\n  void (*xInverse)(sqlite3_context*,int,sqlite3_value**),\n  void(*xDestroy)(void*)\n);\n\n/*\n** CAPI3REF: Text Encodings\n**\n** These constant define integer codes that represent the various\n** text encodings supported by SQLite.\n*/\n#define SQLITE_UTF8           1    /* IMP: R-37514-35566 */\n#define SQLITE_UTF16LE        2    /* IMP: R-03371-37637 */\n#define SQLITE_UTF16BE        3    /* IMP: R-51971-34154 */\n#define SQLITE_UTF16          4    /* Use native byte order */\n#define SQLITE_ANY            5    /* Deprecated */\n#define SQLITE_UTF16_ALIGNED  8    /* sqlite3_create_collation only */\n\n/*\n** CAPI3REF: Function Flags\n**\n** These constants may be ORed together with the \n** [SQLITE_UTF8 | preferred text encoding] as the fourth argument\n** to [sqlite3_create_function()], [sqlite3_create_function16()], or\n** [sqlite3_create_function_v2()].\n*/\n#define SQLITE_DETERMINISTIC    0x800\n\n/*\n** CAPI3REF: Deprecated Functions\n** DEPRECATED\n**\n** These functions are [deprecated].  In order to maintain\n** backwards compatibility with older code, these functions continue \n** to be supported.  However, new applications should avoid\n** the use of these functions.  To encourage programmers to avoid\n** these functions, we will not explain what they do.\n*/\n#ifndef SQLITE_OMIT_DEPRECATED\nSQLITE_API SQLITE_DEPRECATED int sqlite3_aggregate_count(sqlite3_context*);\nSQLITE_API SQLITE_DEPRECATED int sqlite3_expired(sqlite3_stmt*);\nSQLITE_API SQLITE_DEPRECATED int sqlite3_transfer_bindings(sqlite3_stmt*, sqlite3_stmt*);\nSQLITE_API SQLITE_DEPRECATED int sqlite3_global_recover(void);\nSQLITE_API SQLITE_DEPRECATED void sqlite3_thread_cleanup(void);\nSQLITE_API SQLITE_DEPRECATED int sqlite3_memory_alarm(void(*)(void*,sqlite3_int64,int),\n                      void*,sqlite3_int64);\n#endif\n\n/*\n** CAPI3REF: Obtaining SQL Values\n** METHOD: sqlite3_value\n**\n** <b>Summary:</b>\n** <blockquote><table border=0 cellpadding=0 cellspacing=0>\n** <tr><td><b>sqlite3_value_blob</b><td>&rarr;<td>BLOB value\n** <tr><td><b>sqlite3_value_double</b><td>&rarr;<td>REAL value\n** <tr><td><b>sqlite3_value_int</b><td>&rarr;<td>32-bit INTEGER value\n** <tr><td><b>sqlite3_value_int64</b><td>&rarr;<td>64-bit INTEGER value\n** <tr><td><b>sqlite3_value_pointer</b><td>&rarr;<td>Pointer value\n** <tr><td><b>sqlite3_value_text</b><td>&rarr;<td>UTF-8 TEXT value\n** <tr><td><b>sqlite3_value_text16</b><td>&rarr;<td>UTF-16 TEXT value in\n** the native byteorder\n** <tr><td><b>sqlite3_value_text16be</b><td>&rarr;<td>UTF-16be TEXT value\n** <tr><td><b>sqlite3_value_text16le</b><td>&rarr;<td>UTF-16le TEXT value\n** <tr><td>&nbsp;<td>&nbsp;<td>&nbsp;\n** <tr><td><b>sqlite3_value_bytes</b><td>&rarr;<td>Size of a BLOB\n** or a UTF-8 TEXT in bytes\n** <tr><td><b>sqlite3_value_bytes16&nbsp;&nbsp;</b>\n** <td>&rarr;&nbsp;&nbsp;<td>Size of UTF-16\n** TEXT in bytes\n** <tr><td><b>sqlite3_value_type</b><td>&rarr;<td>Default\n** datatype of the value\n** <tr><td><b>sqlite3_value_numeric_type&nbsp;&nbsp;</b>\n** <td>&rarr;&nbsp;&nbsp;<td>Best numeric datatype of the value\n** <tr><td><b>sqlite3_value_nochange&nbsp;&nbsp;</b>\n** <td>&rarr;&nbsp;&nbsp;<td>True if the column is unchanged in an UPDATE\n** against a virtual table.\n** </table></blockquote>\n**\n** <b>Details:</b>\n**\n** These routines extract type, size, and content information from\n** [protected sqlite3_value] objects.  Protected sqlite3_value objects\n** are used to pass parameter information into implementation of\n** [application-defined SQL functions] and [virtual tables].\n**\n** These routines work only with [protected sqlite3_value] objects.\n** Any attempt to use these routines on an [unprotected sqlite3_value]\n** is not threadsafe.\n**\n** ^These routines work just like the corresponding [column access functions]\n** except that these routines take a single [protected sqlite3_value] object\n** pointer instead of a [sqlite3_stmt*] pointer and an integer column number.\n**\n** ^The sqlite3_value_text16() interface extracts a UTF-16 string\n** in the native byte-order of the host machine.  ^The\n** sqlite3_value_text16be() and sqlite3_value_text16le() interfaces\n** extract UTF-16 strings as big-endian and little-endian respectively.\n**\n** ^If [sqlite3_value] object V was initialized \n** using [sqlite3_bind_pointer(S,I,P,X,D)] or [sqlite3_result_pointer(C,P,X,D)]\n** and if X and Y are strings that compare equal according to strcmp(X,Y),\n** then sqlite3_value_pointer(V,Y) will return the pointer P.  ^Otherwise,\n** sqlite3_value_pointer(V,Y) returns a NULL. The sqlite3_bind_pointer() \n** routine is part of the [pointer passing interface] added for SQLite 3.20.0.\n**\n** ^(The sqlite3_value_type(V) interface returns the\n** [SQLITE_INTEGER | datatype code] for the initial datatype of the\n** [sqlite3_value] object V. The returned value is one of [SQLITE_INTEGER],\n** [SQLITE_FLOAT], [SQLITE_TEXT], [SQLITE_BLOB], or [SQLITE_NULL].)^\n** Other interfaces might change the datatype for an sqlite3_value object.\n** For example, if the datatype is initially SQLITE_INTEGER and\n** sqlite3_value_text(V) is called to extract a text value for that\n** integer, then subsequent calls to sqlite3_value_type(V) might return\n** SQLITE_TEXT.  Whether or not a persistent internal datatype conversion\n** occurs is undefined and may change from one release of SQLite to the next.\n**\n** ^(The sqlite3_value_numeric_type() interface attempts to apply\n** numeric affinity to the value.  This means that an attempt is\n** made to convert the value to an integer or floating point.  If\n** such a conversion is possible without loss of information (in other\n** words, if the value is a string that looks like a number)\n** then the conversion is performed.  Otherwise no conversion occurs.\n** The [SQLITE_INTEGER | datatype] after conversion is returned.)^\n**\n** ^Within the [xUpdate] method of a [virtual table], the\n** sqlite3_value_nochange(X) interface returns true if and only if\n** the column corresponding to X is unchanged by the UPDATE operation\n** that the xUpdate method call was invoked to implement and if\n** and the prior [xColumn] method call that was invoked to extracted\n** the value for that column returned without setting a result (probably\n** because it queried [sqlite3_vtab_nochange()] and found that the column\n** was unchanging).  ^Within an [xUpdate] method, any value for which\n** sqlite3_value_nochange(X) is true will in all other respects appear\n** to be a NULL value.  If sqlite3_value_nochange(X) is invoked anywhere other\n** than within an [xUpdate] method call for an UPDATE statement, then\n** the return value is arbitrary and meaningless.\n**\n** Please pay particular attention to the fact that the pointer returned\n** from [sqlite3_value_blob()], [sqlite3_value_text()], or\n** [sqlite3_value_text16()] can be invalidated by a subsequent call to\n** [sqlite3_value_bytes()], [sqlite3_value_bytes16()], [sqlite3_value_text()],\n** or [sqlite3_value_text16()].\n**\n** These routines must be called from the same thread as\n** the SQL function that supplied the [sqlite3_value*] parameters.\n**\n** As long as the input parameter is correct, these routines can only\n** fail if an out-of-memory error occurs during a format conversion.\n** Only the following subset of interfaces are subject to out-of-memory\n** errors:\n**\n** <ul>\n** <li> sqlite3_value_blob()\n** <li> sqlite3_value_text()\n** <li> sqlite3_value_text16()\n** <li> sqlite3_value_text16le()\n** <li> sqlite3_value_text16be()\n** <li> sqlite3_value_bytes()\n** <li> sqlite3_value_bytes16()\n** </ul>\n**\n** If an out-of-memory error occurs, then the return value from these\n** routines is the same as if the column had contained an SQL NULL value.\n** Valid SQL NULL returns can be distinguished from out-of-memory errors\n** by invoking the [sqlite3_errcode()] immediately after the suspect\n** return value is obtained and before any\n** other SQLite interface is called on the same [database connection].\n*/\nSQLITE_API const void *sqlite3_value_blob(sqlite3_value*);\nSQLITE_API double sqlite3_value_double(sqlite3_value*);\nSQLITE_API int sqlite3_value_int(sqlite3_value*);\nSQLITE_API sqlite3_int64 sqlite3_value_int64(sqlite3_value*);\nSQLITE_API void *sqlite3_value_pointer(sqlite3_value*, const char*);\nSQLITE_API const unsigned char *sqlite3_value_text(sqlite3_value*);\nSQLITE_API const void *sqlite3_value_text16(sqlite3_value*);\nSQLITE_API const void *sqlite3_value_text16le(sqlite3_value*);\nSQLITE_API const void *sqlite3_value_text16be(sqlite3_value*);\nSQLITE_API int sqlite3_value_bytes(sqlite3_value*);\nSQLITE_API int sqlite3_value_bytes16(sqlite3_value*);\nSQLITE_API int sqlite3_value_type(sqlite3_value*);\nSQLITE_API int sqlite3_value_numeric_type(sqlite3_value*);\nSQLITE_API int sqlite3_value_nochange(sqlite3_value*);\n\n/*\n** CAPI3REF: Finding The Subtype Of SQL Values\n** METHOD: sqlite3_value\n**\n** The sqlite3_value_subtype(V) function returns the subtype for\n** an [application-defined SQL function] argument V.  The subtype\n** information can be used to pass a limited amount of context from\n** one SQL function to another.  Use the [sqlite3_result_subtype()]\n** routine to set the subtype for the return value of an SQL function.\n*/\nSQLITE_API unsigned int sqlite3_value_subtype(sqlite3_value*);\n\n/*\n** CAPI3REF: Copy And Free SQL Values\n** METHOD: sqlite3_value\n**\n** ^The sqlite3_value_dup(V) interface makes a copy of the [sqlite3_value]\n** object D and returns a pointer to that copy.  ^The [sqlite3_value] returned\n** is a [protected sqlite3_value] object even if the input is not.\n** ^The sqlite3_value_dup(V) interface returns NULL if V is NULL or if a\n** memory allocation fails.\n**\n** ^The sqlite3_value_free(V) interface frees an [sqlite3_value] object\n** previously obtained from [sqlite3_value_dup()].  ^If V is a NULL pointer\n** then sqlite3_value_free(V) is a harmless no-op.\n*/\nSQLITE_API sqlite3_value *sqlite3_value_dup(const sqlite3_value*);\nSQLITE_API void sqlite3_value_free(sqlite3_value*);\n\n/*\n** CAPI3REF: Obtain Aggregate Function Context\n** METHOD: sqlite3_context\n**\n** Implementations of aggregate SQL functions use this\n** routine to allocate memory for storing their state.\n**\n** ^The first time the sqlite3_aggregate_context(C,N) routine is called \n** for a particular aggregate function, SQLite\n** allocates N of memory, zeroes out that memory, and returns a pointer\n** to the new memory. ^On second and subsequent calls to\n** sqlite3_aggregate_context() for the same aggregate function instance,\n** the same buffer is returned.  Sqlite3_aggregate_context() is normally\n** called once for each invocation of the xStep callback and then one\n** last time when the xFinal callback is invoked.  ^(When no rows match\n** an aggregate query, the xStep() callback of the aggregate function\n** implementation is never called and xFinal() is called exactly once.\n** In those cases, sqlite3_aggregate_context() might be called for the\n** first time from within xFinal().)^\n**\n** ^The sqlite3_aggregate_context(C,N) routine returns a NULL pointer \n** when first called if N is less than or equal to zero or if a memory\n** allocate error occurs.\n**\n** ^(The amount of space allocated by sqlite3_aggregate_context(C,N) is\n** determined by the N parameter on first successful call.  Changing the\n** value of N in subsequent call to sqlite3_aggregate_context() within\n** the same aggregate function instance will not resize the memory\n** allocation.)^  Within the xFinal callback, it is customary to set\n** N=0 in calls to sqlite3_aggregate_context(C,N) so that no \n** pointless memory allocations occur.\n**\n** ^SQLite automatically frees the memory allocated by \n** sqlite3_aggregate_context() when the aggregate query concludes.\n**\n** The first parameter must be a copy of the\n** [sqlite3_context | SQL function context] that is the first parameter\n** to the xStep or xFinal callback routine that implements the aggregate\n** function.\n**\n** This routine must be called from the same thread in which\n** the aggregate SQL function is running.\n*/\nSQLITE_API void *sqlite3_aggregate_context(sqlite3_context*, int nBytes);\n\n/*\n** CAPI3REF: User Data For Functions\n** METHOD: sqlite3_context\n**\n** ^The sqlite3_user_data() interface returns a copy of\n** the pointer that was the pUserData parameter (the 5th parameter)\n** of the [sqlite3_create_function()]\n** and [sqlite3_create_function16()] routines that originally\n** registered the application defined function.\n**\n** This routine must be called from the same thread in which\n** the application-defined function is running.\n*/\nSQLITE_API void *sqlite3_user_data(sqlite3_context*);\n\n/*\n** CAPI3REF: Database Connection For Functions\n** METHOD: sqlite3_context\n**\n** ^The sqlite3_context_db_handle() interface returns a copy of\n** the pointer to the [database connection] (the 1st parameter)\n** of the [sqlite3_create_function()]\n** and [sqlite3_create_function16()] routines that originally\n** registered the application defined function.\n*/\nSQLITE_API sqlite3 *sqlite3_context_db_handle(sqlite3_context*);\n\n/*\n** CAPI3REF: Function Auxiliary Data\n** METHOD: sqlite3_context\n**\n** These functions may be used by (non-aggregate) SQL functions to\n** associate metadata with argument values. If the same value is passed to\n** multiple invocations of the same SQL function during query execution, under\n** some circumstances the associated metadata may be preserved.  An example\n** of where this might be useful is in a regular-expression matching\n** function. The compiled version of the regular expression can be stored as\n** metadata associated with the pattern string.  \n** Then as long as the pattern string remains the same,\n** the compiled regular expression can be reused on multiple\n** invocations of the same function.\n**\n** ^The sqlite3_get_auxdata(C,N) interface returns a pointer to the metadata\n** associated by the sqlite3_set_auxdata(C,N,P,X) function with the Nth argument\n** value to the application-defined function.  ^N is zero for the left-most\n** function argument.  ^If there is no metadata\n** associated with the function argument, the sqlite3_get_auxdata(C,N) interface\n** returns a NULL pointer.\n**\n** ^The sqlite3_set_auxdata(C,N,P,X) interface saves P as metadata for the N-th\n** argument of the application-defined function.  ^Subsequent\n** calls to sqlite3_get_auxdata(C,N) return P from the most recent\n** sqlite3_set_auxdata(C,N,P,X) call if the metadata is still valid or\n** NULL if the metadata has been discarded.\n** ^After each call to sqlite3_set_auxdata(C,N,P,X) where X is not NULL,\n** SQLite will invoke the destructor function X with parameter P exactly\n** once, when the metadata is discarded.\n** SQLite is free to discard the metadata at any time, including: <ul>\n** <li> ^(when the corresponding function parameter changes)^, or\n** <li> ^(when [sqlite3_reset()] or [sqlite3_finalize()] is called for the\n**      SQL statement)^, or\n** <li> ^(when sqlite3_set_auxdata() is invoked again on the same\n**       parameter)^, or\n** <li> ^(during the original sqlite3_set_auxdata() call when a memory \n**      allocation error occurs.)^ </ul>\n**\n** Note the last bullet in particular.  The destructor X in \n** sqlite3_set_auxdata(C,N,P,X) might be called immediately, before the\n** sqlite3_set_auxdata() interface even returns.  Hence sqlite3_set_auxdata()\n** should be called near the end of the function implementation and the\n** function implementation should not make any use of P after\n** sqlite3_set_auxdata() has been called.\n**\n** ^(In practice, metadata is preserved between function calls for\n** function parameters that are compile-time constants, including literal\n** values and [parameters] and expressions composed from the same.)^\n**\n** The value of the N parameter to these interfaces should be non-negative.\n** Future enhancements may make use of negative N values to define new\n** kinds of function caching behavior.\n**\n** These routines must be called from the same thread in which\n** the SQL function is running.\n*/\nSQLITE_API void *sqlite3_get_auxdata(sqlite3_context*, int N);\nSQLITE_API void sqlite3_set_auxdata(sqlite3_context*, int N, void*, void (*)(void*));\n\n\n/*\n** CAPI3REF: Constants Defining Special Destructor Behavior\n**\n** These are special values for the destructor that is passed in as the\n** final argument to routines like [sqlite3_result_blob()].  ^If the destructor\n** argument is SQLITE_STATIC, it means that the content pointer is constant\n** and will never change.  It does not need to be destroyed.  ^The\n** SQLITE_TRANSIENT value means that the content will likely change in\n** the near future and that SQLite should make its own private copy of\n** the content before returning.\n**\n** The typedef is necessary to work around problems in certain\n** C++ compilers.\n*/\ntypedef void (*sqlite3_destructor_type)(void*);\n#define SQLITE_STATIC      ((sqlite3_destructor_type)0)\n#define SQLITE_TRANSIENT   ((sqlite3_destructor_type)-1)\n\n/*\n** CAPI3REF: Setting The Result Of An SQL Function\n** METHOD: sqlite3_context\n**\n** These routines are used by the xFunc or xFinal callbacks that\n** implement SQL functions and aggregates.  See\n** [sqlite3_create_function()] and [sqlite3_create_function16()]\n** for additional information.\n**\n** These functions work very much like the [parameter binding] family of\n** functions used to bind values to host parameters in prepared statements.\n** Refer to the [SQL parameter] documentation for additional information.\n**\n** ^The sqlite3_result_blob() interface sets the result from\n** an application-defined function to be the BLOB whose content is pointed\n** to by the second parameter and which is N bytes long where N is the\n** third parameter.\n**\n** ^The sqlite3_result_zeroblob(C,N) and sqlite3_result_zeroblob64(C,N)\n** interfaces set the result of the application-defined function to be\n** a BLOB containing all zero bytes and N bytes in size.\n**\n** ^The sqlite3_result_double() interface sets the result from\n** an application-defined function to be a floating point value specified\n** by its 2nd argument.\n**\n** ^The sqlite3_result_error() and sqlite3_result_error16() functions\n** cause the implemented SQL function to throw an exception.\n** ^SQLite uses the string pointed to by the\n** 2nd parameter of sqlite3_result_error() or sqlite3_result_error16()\n** as the text of an error message.  ^SQLite interprets the error\n** message string from sqlite3_result_error() as UTF-8. ^SQLite\n** interprets the string from sqlite3_result_error16() as UTF-16 in native\n** byte order.  ^If the third parameter to sqlite3_result_error()\n** or sqlite3_result_error16() is negative then SQLite takes as the error\n** message all text up through the first zero character.\n** ^If the third parameter to sqlite3_result_error() or\n** sqlite3_result_error16() is non-negative then SQLite takes that many\n** bytes (not characters) from the 2nd parameter as the error message.\n** ^The sqlite3_result_error() and sqlite3_result_error16()\n** routines make a private copy of the error message text before\n** they return.  Hence, the calling function can deallocate or\n** modify the text after they return without harm.\n** ^The sqlite3_result_error_code() function changes the error code\n** returned by SQLite as a result of an error in a function.  ^By default,\n** the error code is SQLITE_ERROR.  ^A subsequent call to sqlite3_result_error()\n** or sqlite3_result_error16() resets the error code to SQLITE_ERROR.\n**\n** ^The sqlite3_result_error_toobig() interface causes SQLite to throw an\n** error indicating that a string or BLOB is too long to represent.\n**\n** ^The sqlite3_result_error_nomem() interface causes SQLite to throw an\n** error indicating that a memory allocation failed.\n**\n** ^The sqlite3_result_int() interface sets the return value\n** of the application-defined function to be the 32-bit signed integer\n** value given in the 2nd argument.\n** ^The sqlite3_result_int64() interface sets the return value\n** of the application-defined function to be the 64-bit signed integer\n** value given in the 2nd argument.\n**\n** ^The sqlite3_result_null() interface sets the return value\n** of the application-defined function to be NULL.\n**\n** ^The sqlite3_result_text(), sqlite3_result_text16(),\n** sqlite3_result_text16le(), and sqlite3_result_text16be() interfaces\n** set the return value of the application-defined function to be\n** a text string which is represented as UTF-8, UTF-16 native byte order,\n** UTF-16 little endian, or UTF-16 big endian, respectively.\n** ^The sqlite3_result_text64() interface sets the return value of an\n** application-defined function to be a text string in an encoding\n** specified by the fifth (and last) parameter, which must be one\n** of [SQLITE_UTF8], [SQLITE_UTF16], [SQLITE_UTF16BE], or [SQLITE_UTF16LE].\n** ^SQLite takes the text result from the application from\n** the 2nd parameter of the sqlite3_result_text* interfaces.\n** ^If the 3rd parameter to the sqlite3_result_text* interfaces\n** is negative, then SQLite takes result text from the 2nd parameter\n** through the first zero character.\n** ^If the 3rd parameter to the sqlite3_result_text* interfaces\n** is non-negative, then as many bytes (not characters) of the text\n** pointed to by the 2nd parameter are taken as the application-defined\n** function result.  If the 3rd parameter is non-negative, then it\n** must be the byte offset into the string where the NUL terminator would\n** appear if the string where NUL terminated.  If any NUL characters occur\n** in the string at a byte offset that is less than the value of the 3rd\n** parameter, then the resulting string will contain embedded NULs and the\n** result of expressions operating on strings with embedded NULs is undefined.\n** ^If the 4th parameter to the sqlite3_result_text* interfaces\n** or sqlite3_result_blob is a non-NULL pointer, then SQLite calls that\n** function as the destructor on the text or BLOB result when it has\n** finished using that result.\n** ^If the 4th parameter to the sqlite3_result_text* interfaces or to\n** sqlite3_result_blob is the special constant SQLITE_STATIC, then SQLite\n** assumes that the text or BLOB result is in constant space and does not\n** copy the content of the parameter nor call a destructor on the content\n** when it has finished using that result.\n** ^If the 4th parameter to the sqlite3_result_text* interfaces\n** or sqlite3_result_blob is the special constant SQLITE_TRANSIENT\n** then SQLite makes a copy of the result into space obtained\n** from [sqlite3_malloc()] before it returns.\n**\n** ^The sqlite3_result_value() interface sets the result of\n** the application-defined function to be a copy of the\n** [unprotected sqlite3_value] object specified by the 2nd parameter.  ^The\n** sqlite3_result_value() interface makes a copy of the [sqlite3_value]\n** so that the [sqlite3_value] specified in the parameter may change or\n** be deallocated after sqlite3_result_value() returns without harm.\n** ^A [protected sqlite3_value] object may always be used where an\n** [unprotected sqlite3_value] object is required, so either\n** kind of [sqlite3_value] object can be used with this interface.\n**\n** ^The sqlite3_result_pointer(C,P,T,D) interface sets the result to an\n** SQL NULL value, just like [sqlite3_result_null(C)], except that it\n** also associates the host-language pointer P or type T with that \n** NULL value such that the pointer can be retrieved within an\n** [application-defined SQL function] using [sqlite3_value_pointer()].\n** ^If the D parameter is not NULL, then it is a pointer to a destructor\n** for the P parameter.  ^SQLite invokes D with P as its only argument\n** when SQLite is finished with P.  The T parameter should be a static\n** string and preferably a string literal. The sqlite3_result_pointer()\n** routine is part of the [pointer passing interface] added for SQLite 3.20.0.\n**\n** If these routines are called from within the different thread\n** than the one containing the application-defined function that received\n** the [sqlite3_context] pointer, the results are undefined.\n*/\nSQLITE_API void sqlite3_result_blob(sqlite3_context*, const void*, int, void(*)(void*));\nSQLITE_API void sqlite3_result_blob64(sqlite3_context*,const void*,\n                           sqlite3_uint64,void(*)(void*));\nSQLITE_API void sqlite3_result_double(sqlite3_context*, double);\nSQLITE_API void sqlite3_result_error(sqlite3_context*, const char*, int);\nSQLITE_API void sqlite3_result_error16(sqlite3_context*, const void*, int);\nSQLITE_API void sqlite3_result_error_toobig(sqlite3_context*);\nSQLITE_API void sqlite3_result_error_nomem(sqlite3_context*);\nSQLITE_API void sqlite3_result_error_code(sqlite3_context*, int);\nSQLITE_API void sqlite3_result_int(sqlite3_context*, int);\nSQLITE_API void sqlite3_result_int64(sqlite3_context*, sqlite3_int64);\nSQLITE_API void sqlite3_result_null(sqlite3_context*);\nSQLITE_API void sqlite3_result_text(sqlite3_context*, const char*, int, void(*)(void*));\nSQLITE_API void sqlite3_result_text64(sqlite3_context*, const char*,sqlite3_uint64,\n                           void(*)(void*), unsigned char encoding);\nSQLITE_API void sqlite3_result_text16(sqlite3_context*, const void*, int, void(*)(void*));\nSQLITE_API void sqlite3_result_text16le(sqlite3_context*, const void*, int,void(*)(void*));\nSQLITE_API void sqlite3_result_text16be(sqlite3_context*, const void*, int,void(*)(void*));\nSQLITE_API void sqlite3_result_value(sqlite3_context*, sqlite3_value*);\nSQLITE_API void sqlite3_result_pointer(sqlite3_context*, void*,const char*,void(*)(void*));\nSQLITE_API void sqlite3_result_zeroblob(sqlite3_context*, int n);\nSQLITE_API int sqlite3_result_zeroblob64(sqlite3_context*, sqlite3_uint64 n);\n\n\n/*\n** CAPI3REF: Setting The Subtype Of An SQL Function\n** METHOD: sqlite3_context\n**\n** The sqlite3_result_subtype(C,T) function causes the subtype of\n** the result from the [application-defined SQL function] with \n** [sqlite3_context] C to be the value T.  Only the lower 8 bits \n** of the subtype T are preserved in current versions of SQLite;\n** higher order bits are discarded.\n** The number of subtype bytes preserved by SQLite might increase\n** in future releases of SQLite.\n*/\nSQLITE_API void sqlite3_result_subtype(sqlite3_context*,unsigned int);\n\n/*\n** CAPI3REF: Define New Collating Sequences\n** METHOD: sqlite3\n**\n** ^These functions add, remove, or modify a [collation] associated\n** with the [database connection] specified as the first argument.\n**\n** ^The name of the collation is a UTF-8 string\n** for sqlite3_create_collation() and sqlite3_create_collation_v2()\n** and a UTF-16 string in native byte order for sqlite3_create_collation16().\n** ^Collation names that compare equal according to [sqlite3_strnicmp()] are\n** considered to be the same name.\n**\n** ^(The third argument (eTextRep) must be one of the constants:\n** <ul>\n** <li> [SQLITE_UTF8],\n** <li> [SQLITE_UTF16LE],\n** <li> [SQLITE_UTF16BE],\n** <li> [SQLITE_UTF16], or\n** <li> [SQLITE_UTF16_ALIGNED].\n** </ul>)^\n** ^The eTextRep argument determines the encoding of strings passed\n** to the collating function callback, xCallback.\n** ^The [SQLITE_UTF16] and [SQLITE_UTF16_ALIGNED] values for eTextRep\n** force strings to be UTF16 with native byte order.\n** ^The [SQLITE_UTF16_ALIGNED] value for eTextRep forces strings to begin\n** on an even byte address.\n**\n** ^The fourth argument, pArg, is an application data pointer that is passed\n** through as the first argument to the collating function callback.\n**\n** ^The fifth argument, xCallback, is a pointer to the collating function.\n** ^Multiple collating functions can be registered using the same name but\n** with different eTextRep parameters and SQLite will use whichever\n** function requires the least amount of data transformation.\n** ^If the xCallback argument is NULL then the collating function is\n** deleted.  ^When all collating functions having the same name are deleted,\n** that collation is no longer usable.\n**\n** ^The collating function callback is invoked with a copy of the pArg \n** application data pointer and with two strings in the encoding specified\n** by the eTextRep argument.  The collating function must return an\n** integer that is negative, zero, or positive\n** if the first string is less than, equal to, or greater than the second,\n** respectively.  A collating function must always return the same answer\n** given the same inputs.  If two or more collating functions are registered\n** to the same collation name (using different eTextRep values) then all\n** must give an equivalent answer when invoked with equivalent strings.\n** The collating function must obey the following properties for all\n** strings A, B, and C:\n**\n** <ol>\n** <li> If A==B then B==A.\n** <li> If A==B and B==C then A==C.\n** <li> If A&lt;B THEN B&gt;A.\n** <li> If A&lt;B and B&lt;C then A&lt;C.\n** </ol>\n**\n** If a collating function fails any of the above constraints and that\n** collating function is  registered and used, then the behavior of SQLite\n** is undefined.\n**\n** ^The sqlite3_create_collation_v2() works like sqlite3_create_collation()\n** with the addition that the xDestroy callback is invoked on pArg when\n** the collating function is deleted.\n** ^Collating functions are deleted when they are overridden by later\n** calls to the collation creation functions or when the\n** [database connection] is closed using [sqlite3_close()].\n**\n** ^The xDestroy callback is <u>not</u> called if the \n** sqlite3_create_collation_v2() function fails.  Applications that invoke\n** sqlite3_create_collation_v2() with a non-NULL xDestroy argument should \n** check the return code and dispose of the application data pointer\n** themselves rather than expecting SQLite to deal with it for them.\n** This is different from every other SQLite interface.  The inconsistency \n** is unfortunate but cannot be changed without breaking backwards \n** compatibility.\n**\n** See also:  [sqlite3_collation_needed()] and [sqlite3_collation_needed16()].\n*/\nSQLITE_API int sqlite3_create_collation(\n  sqlite3*, \n  const char *zName, \n  int eTextRep, \n  void *pArg,\n  int(*xCompare)(void*,int,const void*,int,const void*)\n);\nSQLITE_API int sqlite3_create_collation_v2(\n  sqlite3*, \n  const char *zName, \n  int eTextRep, \n  void *pArg,\n  int(*xCompare)(void*,int,const void*,int,const void*),\n  void(*xDestroy)(void*)\n);\nSQLITE_API int sqlite3_create_collation16(\n  sqlite3*, \n  const void *zName,\n  int eTextRep, \n  void *pArg,\n  int(*xCompare)(void*,int,const void*,int,const void*)\n);\n\n/*\n** CAPI3REF: Collation Needed Callbacks\n** METHOD: sqlite3\n**\n** ^To avoid having to register all collation sequences before a database\n** can be used, a single callback function may be registered with the\n** [database connection] to be invoked whenever an undefined collation\n** sequence is required.\n**\n** ^If the function is registered using the sqlite3_collation_needed() API,\n** then it is passed the names of undefined collation sequences as strings\n** encoded in UTF-8. ^If sqlite3_collation_needed16() is used,\n** the names are passed as UTF-16 in machine native byte order.\n** ^A call to either function replaces the existing collation-needed callback.\n**\n** ^(When the callback is invoked, the first argument passed is a copy\n** of the second argument to sqlite3_collation_needed() or\n** sqlite3_collation_needed16().  The second argument is the database\n** connection.  The third argument is one of [SQLITE_UTF8], [SQLITE_UTF16BE],\n** or [SQLITE_UTF16LE], indicating the most desirable form of the collation\n** sequence function required.  The fourth parameter is the name of the\n** required collation sequence.)^\n**\n** The callback function should register the desired collation using\n** [sqlite3_create_collation()], [sqlite3_create_collation16()], or\n** [sqlite3_create_collation_v2()].\n*/\nSQLITE_API int sqlite3_collation_needed(\n  sqlite3*, \n  void*, \n  void(*)(void*,sqlite3*,int eTextRep,const char*)\n);\nSQLITE_API int sqlite3_collation_needed16(\n  sqlite3*, \n  void*,\n  void(*)(void*,sqlite3*,int eTextRep,const void*)\n);\n\n#ifdef SQLITE_HAS_CODEC\n/*\n** Specify the key for an encrypted database.  This routine should be\n** called right after sqlite3_open().\n**\n** The code to implement this API is not available in the public release\n** of SQLite.\n*/\nSQLITE_API int sqlite3_key(\n  sqlite3 *db,                   /* Database to be rekeyed */\n  const void *pKey, int nKey     /* The key */\n);\nSQLITE_API int sqlite3_key_v2(\n  sqlite3 *db,                   /* Database to be rekeyed */\n  const char *zDbName,           /* Name of the database */\n  const void *pKey, int nKey     /* The key */\n);\n\n/*\n** Change the key on an open database.  If the current database is not\n** encrypted, this routine will encrypt it.  If pNew==0 or nNew==0, the\n** database is decrypted.\n**\n** The code to implement this API is not available in the public release\n** of SQLite.\n*/\n/* BEGIN SQLCIPHER\n   SQLCipher usage note:\n\n   If the current database is plaintext SQLCipher will NOT encrypt it.\n   If the current database is encrypted and pNew==0 or nNew==0, SQLCipher\n   will NOT decrypt it.\n\n   This routine will ONLY work on an already encrypted database in order\n   to change the key.\n\n   Conversion from plaintext-to-encrypted or encrypted-to-plaintext should\n   use an ATTACHed database and the sqlcipher_export() convenience function\n   as per the SQLCipher Documentation.\n\n   END SQLCIPHER\n*/\nSQLITE_API int sqlite3_rekey(\n  sqlite3 *db,                   /* Database to be rekeyed */\n  const void *pKey, int nKey     /* The new key */\n);\nSQLITE_API int sqlite3_rekey_v2(\n  sqlite3 *db,                   /* Database to be rekeyed */\n  const char *zDbName,           /* Name of the database */\n  const void *pKey, int nKey     /* The new key */\n);\n\n/*\n** Specify the activation key for a SEE database.  Unless \n** activated, none of the SEE routines will work.\n*/\nSQLITE_API void sqlite3_activate_see(\n  const char *zPassPhrase        /* Activation phrase */\n);\n#endif\n\n#ifdef SQLITE_ENABLE_CEROD\n/*\n** Specify the activation key for a CEROD database.  Unless \n** activated, none of the CEROD routines will work.\n*/\nSQLITE_API void sqlite3_activate_cerod(\n  const char *zPassPhrase        /* Activation phrase */\n);\n#endif\n\n/*\n** CAPI3REF: Suspend Execution For A Short Time\n**\n** The sqlite3_sleep() function causes the current thread to suspend execution\n** for at least a number of milliseconds specified in its parameter.\n**\n** If the operating system does not support sleep requests with\n** millisecond time resolution, then the time will be rounded up to\n** the nearest second. The number of milliseconds of sleep actually\n** requested from the operating system is returned.\n**\n** ^SQLite implements this interface by calling the xSleep()\n** method of the default [sqlite3_vfs] object.  If the xSleep() method\n** of the default VFS is not implemented correctly, or not implemented at\n** all, then the behavior of sqlite3_sleep() may deviate from the description\n** in the previous paragraphs.\n*/\nSQLITE_API int sqlite3_sleep(int);\n\n/*\n** CAPI3REF: Name Of The Folder Holding Temporary Files\n**\n** ^(If this global variable is made to point to a string which is\n** the name of a folder (a.k.a. directory), then all temporary files\n** created by SQLite when using a built-in [sqlite3_vfs | VFS]\n** will be placed in that directory.)^  ^If this variable\n** is a NULL pointer, then SQLite performs a search for an appropriate\n** temporary file directory.\n**\n** Applications are strongly discouraged from using this global variable.\n** It is required to set a temporary folder on Windows Runtime (WinRT).\n** But for all other platforms, it is highly recommended that applications\n** neither read nor write this variable.  This global variable is a relic\n** that exists for backwards compatibility of legacy applications and should\n** be avoided in new projects.\n**\n** It is not safe to read or modify this variable in more than one\n** thread at a time.  It is not safe to read or modify this variable\n** if a [database connection] is being used at the same time in a separate\n** thread.\n** It is intended that this variable be set once\n** as part of process initialization and before any SQLite interface\n** routines have been called and that this variable remain unchanged\n** thereafter.\n**\n** ^The [temp_store_directory pragma] may modify this variable and cause\n** it to point to memory obtained from [sqlite3_malloc].  ^Furthermore,\n** the [temp_store_directory pragma] always assumes that any string\n** that this variable points to is held in memory obtained from \n** [sqlite3_malloc] and the pragma may attempt to free that memory\n** using [sqlite3_free].\n** Hence, if this variable is modified directly, either it should be\n** made NULL or made to point to memory obtained from [sqlite3_malloc]\n** or else the use of the [temp_store_directory pragma] should be avoided.\n** Except when requested by the [temp_store_directory pragma], SQLite\n** does not free the memory that sqlite3_temp_directory points to.  If\n** the application wants that memory to be freed, it must do\n** so itself, taking care to only do so after all [database connection]\n** objects have been destroyed.\n**\n** <b>Note to Windows Runtime users:</b>  The temporary directory must be set\n** prior to calling [sqlite3_open] or [sqlite3_open_v2].  Otherwise, various\n** features that require the use of temporary files may fail.  Here is an\n** example of how to do this using C++ with the Windows Runtime:\n**\n** <blockquote><pre>\n** LPCWSTR zPath = Windows::Storage::ApplicationData::Current->\n** &nbsp;     TemporaryFolder->Path->Data();\n** char zPathBuf&#91;MAX_PATH + 1&#93;;\n** memset(zPathBuf, 0, sizeof(zPathBuf));\n** WideCharToMultiByte(CP_UTF8, 0, zPath, -1, zPathBuf, sizeof(zPathBuf),\n** &nbsp;     NULL, NULL);\n** sqlite3_temp_directory = sqlite3_mprintf(\"%s\", zPathBuf);\n** </pre></blockquote>\n*/\nSQLITE_API SQLITE_EXTERN char *sqlite3_temp_directory;\n\n/*\n** CAPI3REF: Name Of The Folder Holding Database Files\n**\n** ^(If this global variable is made to point to a string which is\n** the name of a folder (a.k.a. directory), then all database files\n** specified with a relative pathname and created or accessed by\n** SQLite when using a built-in windows [sqlite3_vfs | VFS] will be assumed\n** to be relative to that directory.)^ ^If this variable is a NULL\n** pointer, then SQLite assumes that all database files specified\n** with a relative pathname are relative to the current directory\n** for the process.  Only the windows VFS makes use of this global\n** variable; it is ignored by the unix VFS.\n**\n** Changing the value of this variable while a database connection is\n** open can result in a corrupt database.\n**\n** It is not safe to read or modify this variable in more than one\n** thread at a time.  It is not safe to read or modify this variable\n** if a [database connection] is being used at the same time in a separate\n** thread.\n** It is intended that this variable be set once\n** as part of process initialization and before any SQLite interface\n** routines have been called and that this variable remain unchanged\n** thereafter.\n**\n** ^The [data_store_directory pragma] may modify this variable and cause\n** it to point to memory obtained from [sqlite3_malloc].  ^Furthermore,\n** the [data_store_directory pragma] always assumes that any string\n** that this variable points to is held in memory obtained from \n** [sqlite3_malloc] and the pragma may attempt to free that memory\n** using [sqlite3_free].\n** Hence, if this variable is modified directly, either it should be\n** made NULL or made to point to memory obtained from [sqlite3_malloc]\n** or else the use of the [data_store_directory pragma] should be avoided.\n*/\nSQLITE_API SQLITE_EXTERN char *sqlite3_data_directory;\n\n/*\n** CAPI3REF: Win32 Specific Interface\n**\n** These interfaces are available only on Windows.  The\n** [sqlite3_win32_set_directory] interface is used to set the value associated\n** with the [sqlite3_temp_directory] or [sqlite3_data_directory] variable, to\n** zValue, depending on the value of the type parameter.  The zValue parameter\n** should be NULL to cause the previous value to be freed via [sqlite3_free];\n** a non-NULL value will be copied into memory obtained from [sqlite3_malloc]\n** prior to being used.  The [sqlite3_win32_set_directory] interface returns\n** [SQLITE_OK] to indicate success, [SQLITE_ERROR] if the type is unsupported,\n** or [SQLITE_NOMEM] if memory could not be allocated.  The value of the\n** [sqlite3_data_directory] variable is intended to act as a replacement for\n** the current directory on the sub-platforms of Win32 where that concept is\n** not present, e.g. WinRT and UWP.  The [sqlite3_win32_set_directory8] and\n** [sqlite3_win32_set_directory16] interfaces behave exactly the same as the\n** sqlite3_win32_set_directory interface except the string parameter must be\n** UTF-8 or UTF-16, respectively.\n*/\nSQLITE_API int sqlite3_win32_set_directory(\n  unsigned long type, /* Identifier for directory being set or reset */\n  void *zValue        /* New value for directory being set or reset */\n);\nSQLITE_API int sqlite3_win32_set_directory8(unsigned long type, const char *zValue);\nSQLITE_API int sqlite3_win32_set_directory16(unsigned long type, const void *zValue);\n\n/*\n** CAPI3REF: Win32 Directory Types\n**\n** These macros are only available on Windows.  They define the allowed values\n** for the type argument to the [sqlite3_win32_set_directory] interface.\n*/\n#define SQLITE_WIN32_DATA_DIRECTORY_TYPE  1\n#define SQLITE_WIN32_TEMP_DIRECTORY_TYPE  2\n\n/*\n** CAPI3REF: Test For Auto-Commit Mode\n** KEYWORDS: {autocommit mode}\n** METHOD: sqlite3\n**\n** ^The sqlite3_get_autocommit() interface returns non-zero or\n** zero if the given database connection is or is not in autocommit mode,\n** respectively.  ^Autocommit mode is on by default.\n** ^Autocommit mode is disabled by a [BEGIN] statement.\n** ^Autocommit mode is re-enabled by a [COMMIT] or [ROLLBACK].\n**\n** If certain kinds of errors occur on a statement within a multi-statement\n** transaction (errors including [SQLITE_FULL], [SQLITE_IOERR],\n** [SQLITE_NOMEM], [SQLITE_BUSY], and [SQLITE_INTERRUPT]) then the\n** transaction might be rolled back automatically.  The only way to\n** find out whether SQLite automatically rolled back the transaction after\n** an error is to use this function.\n**\n** If another thread changes the autocommit status of the database\n** connection while this routine is running, then the return value\n** is undefined.\n*/\nSQLITE_API int sqlite3_get_autocommit(sqlite3*);\n\n/*\n** CAPI3REF: Find The Database Handle Of A Prepared Statement\n** METHOD: sqlite3_stmt\n**\n** ^The sqlite3_db_handle interface returns the [database connection] handle\n** to which a [prepared statement] belongs.  ^The [database connection]\n** returned by sqlite3_db_handle is the same [database connection]\n** that was the first argument\n** to the [sqlite3_prepare_v2()] call (or its variants) that was used to\n** create the statement in the first place.\n*/\nSQLITE_API sqlite3 *sqlite3_db_handle(sqlite3_stmt*);\n\n/*\n** CAPI3REF: Return The Filename For A Database Connection\n** METHOD: sqlite3\n**\n** ^The sqlite3_db_filename(D,N) interface returns a pointer to a filename\n** associated with database N of connection D.  ^The main database file\n** has the name \"main\".  If there is no attached database N on the database\n** connection D, or if database N is a temporary or in-memory database, then\n** a NULL pointer is returned.\n**\n** ^The filename returned by this function is the output of the\n** xFullPathname method of the [VFS].  ^In other words, the filename\n** will be an absolute pathname, even if the filename used\n** to open the database originally was a URI or relative pathname.\n*/\nSQLITE_API const char *sqlite3_db_filename(sqlite3 *db, const char *zDbName);\n\n/*\n** CAPI3REF: Determine if a database is read-only\n** METHOD: sqlite3\n**\n** ^The sqlite3_db_readonly(D,N) interface returns 1 if the database N\n** of connection D is read-only, 0 if it is read/write, or -1 if N is not\n** the name of a database on connection D.\n*/\nSQLITE_API int sqlite3_db_readonly(sqlite3 *db, const char *zDbName);\n\n/*\n** CAPI3REF: Find the next prepared statement\n** METHOD: sqlite3\n**\n** ^This interface returns a pointer to the next [prepared statement] after\n** pStmt associated with the [database connection] pDb.  ^If pStmt is NULL\n** then this interface returns a pointer to the first prepared statement\n** associated with the database connection pDb.  ^If no prepared statement\n** satisfies the conditions of this routine, it returns NULL.\n**\n** The [database connection] pointer D in a call to\n** [sqlite3_next_stmt(D,S)] must refer to an open database\n** connection and in particular must not be a NULL pointer.\n*/\nSQLITE_API sqlite3_stmt *sqlite3_next_stmt(sqlite3 *pDb, sqlite3_stmt *pStmt);\n\n/*\n** CAPI3REF: Commit And Rollback Notification Callbacks\n** METHOD: sqlite3\n**\n** ^The sqlite3_commit_hook() interface registers a callback\n** function to be invoked whenever a transaction is [COMMIT | committed].\n** ^Any callback set by a previous call to sqlite3_commit_hook()\n** for the same database connection is overridden.\n** ^The sqlite3_rollback_hook() interface registers a callback\n** function to be invoked whenever a transaction is [ROLLBACK | rolled back].\n** ^Any callback set by a previous call to sqlite3_rollback_hook()\n** for the same database connection is overridden.\n** ^The pArg argument is passed through to the callback.\n** ^If the callback on a commit hook function returns non-zero,\n** then the commit is converted into a rollback.\n**\n** ^The sqlite3_commit_hook(D,C,P) and sqlite3_rollback_hook(D,C,P) functions\n** return the P argument from the previous call of the same function\n** on the same [database connection] D, or NULL for\n** the first call for each function on D.\n**\n** The commit and rollback hook callbacks are not reentrant.\n** The callback implementation must not do anything that will modify\n** the database connection that invoked the callback.  Any actions\n** to modify the database connection must be deferred until after the\n** completion of the [sqlite3_step()] call that triggered the commit\n** or rollback hook in the first place.\n** Note that running any other SQL statements, including SELECT statements,\n** or merely calling [sqlite3_prepare_v2()] and [sqlite3_step()] will modify\n** the database connections for the meaning of \"modify\" in this paragraph.\n**\n** ^Registering a NULL function disables the callback.\n**\n** ^When the commit hook callback routine returns zero, the [COMMIT]\n** operation is allowed to continue normally.  ^If the commit hook\n** returns non-zero, then the [COMMIT] is converted into a [ROLLBACK].\n** ^The rollback hook is invoked on a rollback that results from a commit\n** hook returning non-zero, just as it would be with any other rollback.\n**\n** ^For the purposes of this API, a transaction is said to have been\n** rolled back if an explicit \"ROLLBACK\" statement is executed, or\n** an error or constraint causes an implicit rollback to occur.\n** ^The rollback callback is not invoked if a transaction is\n** automatically rolled back because the database connection is closed.\n**\n** See also the [sqlite3_update_hook()] interface.\n*/\nSQLITE_API void *sqlite3_commit_hook(sqlite3*, int(*)(void*), void*);\nSQLITE_API void *sqlite3_rollback_hook(sqlite3*, void(*)(void *), void*);\n\n/*\n** CAPI3REF: Data Change Notification Callbacks\n** METHOD: sqlite3\n**\n** ^The sqlite3_update_hook() interface registers a callback function\n** with the [database connection] identified by the first argument\n** to be invoked whenever a row is updated, inserted or deleted in\n** a [rowid table].\n** ^Any callback set by a previous call to this function\n** for the same database connection is overridden.\n**\n** ^The second argument is a pointer to the function to invoke when a\n** row is updated, inserted or deleted in a rowid table.\n** ^The first argument to the callback is a copy of the third argument\n** to sqlite3_update_hook().\n** ^The second callback argument is one of [SQLITE_INSERT], [SQLITE_DELETE],\n** or [SQLITE_UPDATE], depending on the operation that caused the callback\n** to be invoked.\n** ^The third and fourth arguments to the callback contain pointers to the\n** database and table name containing the affected row.\n** ^The final callback parameter is the [rowid] of the row.\n** ^In the case of an update, this is the [rowid] after the update takes place.\n**\n** ^(The update hook is not invoked when internal system tables are\n** modified (i.e. sqlite_master and sqlite_sequence).)^\n** ^The update hook is not invoked when [WITHOUT ROWID] tables are modified.\n**\n** ^In the current implementation, the update hook\n** is not invoked when conflicting rows are deleted because of an\n** [ON CONFLICT | ON CONFLICT REPLACE] clause.  ^Nor is the update hook\n** invoked when rows are deleted using the [truncate optimization].\n** The exceptions defined in this paragraph might change in a future\n** release of SQLite.\n**\n** The update hook implementation must not do anything that will modify\n** the database connection that invoked the update hook.  Any actions\n** to modify the database connection must be deferred until after the\n** completion of the [sqlite3_step()] call that triggered the update hook.\n** Note that [sqlite3_prepare_v2()] and [sqlite3_step()] both modify their\n** database connections for the meaning of \"modify\" in this paragraph.\n**\n** ^The sqlite3_update_hook(D,C,P) function\n** returns the P argument from the previous call\n** on the same [database connection] D, or NULL for\n** the first call on D.\n**\n** See also the [sqlite3_commit_hook()], [sqlite3_rollback_hook()],\n** and [sqlite3_preupdate_hook()] interfaces.\n*/\nSQLITE_API void *sqlite3_update_hook(\n  sqlite3*, \n  void(*)(void *,int ,char const *,char const *,sqlite3_int64),\n  void*\n);\n\n/*\n** CAPI3REF: Enable Or Disable Shared Pager Cache\n**\n** ^(This routine enables or disables the sharing of the database cache\n** and schema data structures between [database connection | connections]\n** to the same database. Sharing is enabled if the argument is true\n** and disabled if the argument is false.)^\n**\n** ^Cache sharing is enabled and disabled for an entire process.\n** This is a change as of SQLite [version 3.5.0] ([dateof:3.5.0]). \n** In prior versions of SQLite,\n** sharing was enabled or disabled for each thread separately.\n**\n** ^(The cache sharing mode set by this interface effects all subsequent\n** calls to [sqlite3_open()], [sqlite3_open_v2()], and [sqlite3_open16()].\n** Existing database connections continue use the sharing mode\n** that was in effect at the time they were opened.)^\n**\n** ^(This routine returns [SQLITE_OK] if shared cache was enabled or disabled\n** successfully.  An [error code] is returned otherwise.)^\n**\n** ^Shared cache is disabled by default. But this might change in\n** future releases of SQLite.  Applications that care about shared\n** cache setting should set it explicitly.\n**\n** Note: This method is disabled on MacOS X 10.7 and iOS version 5.0\n** and will always return SQLITE_MISUSE. On those systems, \n** shared cache mode should be enabled per-database connection via \n** [sqlite3_open_v2()] with [SQLITE_OPEN_SHAREDCACHE].\n**\n** This interface is threadsafe on processors where writing a\n** 32-bit integer is atomic.\n**\n** See Also:  [SQLite Shared-Cache Mode]\n*/\nSQLITE_API int sqlite3_enable_shared_cache(int);\n\n/*\n** CAPI3REF: Attempt To Free Heap Memory\n**\n** ^The sqlite3_release_memory() interface attempts to free N bytes\n** of heap memory by deallocating non-essential memory allocations\n** held by the database library.   Memory used to cache database\n** pages to improve performance is an example of non-essential memory.\n** ^sqlite3_release_memory() returns the number of bytes actually freed,\n** which might be more or less than the amount requested.\n** ^The sqlite3_release_memory() routine is a no-op returning zero\n** if SQLite is not compiled with [SQLITE_ENABLE_MEMORY_MANAGEMENT].\n**\n** See also: [sqlite3_db_release_memory()]\n*/\nSQLITE_API int sqlite3_release_memory(int);\n\n/*\n** CAPI3REF: Free Memory Used By A Database Connection\n** METHOD: sqlite3\n**\n** ^The sqlite3_db_release_memory(D) interface attempts to free as much heap\n** memory as possible from database connection D. Unlike the\n** [sqlite3_release_memory()] interface, this interface is in effect even\n** when the [SQLITE_ENABLE_MEMORY_MANAGEMENT] compile-time option is\n** omitted.\n**\n** See also: [sqlite3_release_memory()]\n*/\nSQLITE_API int sqlite3_db_release_memory(sqlite3*);\n\n/*\n** CAPI3REF: Impose A Limit On Heap Size\n**\n** ^The sqlite3_soft_heap_limit64() interface sets and/or queries the\n** soft limit on the amount of heap memory that may be allocated by SQLite.\n** ^SQLite strives to keep heap memory utilization below the soft heap\n** limit by reducing the number of pages held in the page cache\n** as heap memory usages approaches the limit.\n** ^The soft heap limit is \"soft\" because even though SQLite strives to stay\n** below the limit, it will exceed the limit rather than generate\n** an [SQLITE_NOMEM] error.  In other words, the soft heap limit \n** is advisory only.\n**\n** ^The return value from sqlite3_soft_heap_limit64() is the size of\n** the soft heap limit prior to the call, or negative in the case of an\n** error.  ^If the argument N is negative\n** then no change is made to the soft heap limit.  Hence, the current\n** size of the soft heap limit can be determined by invoking\n** sqlite3_soft_heap_limit64() with a negative argument.\n**\n** ^If the argument N is zero then the soft heap limit is disabled.\n**\n** ^(The soft heap limit is not enforced in the current implementation\n** if one or more of following conditions are true:\n**\n** <ul>\n** <li> The soft heap limit is set to zero.\n** <li> Memory accounting is disabled using a combination of the\n**      [sqlite3_config]([SQLITE_CONFIG_MEMSTATUS],...) start-time option and\n**      the [SQLITE_DEFAULT_MEMSTATUS] compile-time option.\n** <li> An alternative page cache implementation is specified using\n**      [sqlite3_config]([SQLITE_CONFIG_PCACHE2],...).\n** <li> The page cache allocates from its own memory pool supplied\n**      by [sqlite3_config]([SQLITE_CONFIG_PAGECACHE],...) rather than\n**      from the heap.\n** </ul>)^\n**\n** Beginning with SQLite [version 3.7.3] ([dateof:3.7.3]), \n** the soft heap limit is enforced\n** regardless of whether or not the [SQLITE_ENABLE_MEMORY_MANAGEMENT]\n** compile-time option is invoked.  With [SQLITE_ENABLE_MEMORY_MANAGEMENT],\n** the soft heap limit is enforced on every memory allocation.  Without\n** [SQLITE_ENABLE_MEMORY_MANAGEMENT], the soft heap limit is only enforced\n** when memory is allocated by the page cache.  Testing suggests that because\n** the page cache is the predominate memory user in SQLite, most\n** applications will achieve adequate soft heap limit enforcement without\n** the use of [SQLITE_ENABLE_MEMORY_MANAGEMENT].\n**\n** The circumstances under which SQLite will enforce the soft heap limit may\n** changes in future releases of SQLite.\n*/\nSQLITE_API sqlite3_int64 sqlite3_soft_heap_limit64(sqlite3_int64 N);\n\n/*\n** CAPI3REF: Deprecated Soft Heap Limit Interface\n** DEPRECATED\n**\n** This is a deprecated version of the [sqlite3_soft_heap_limit64()]\n** interface.  This routine is provided for historical compatibility\n** only.  All new applications should use the\n** [sqlite3_soft_heap_limit64()] interface rather than this one.\n*/\nSQLITE_API SQLITE_DEPRECATED void sqlite3_soft_heap_limit(int N);\n\n\n/*\n** CAPI3REF: Extract Metadata About A Column Of A Table\n** METHOD: sqlite3\n**\n** ^(The sqlite3_table_column_metadata(X,D,T,C,....) routine returns\n** information about column C of table T in database D\n** on [database connection] X.)^  ^The sqlite3_table_column_metadata()\n** interface returns SQLITE_OK and fills in the non-NULL pointers in\n** the final five arguments with appropriate values if the specified\n** column exists.  ^The sqlite3_table_column_metadata() interface returns\n** SQLITE_ERROR and if the specified column does not exist.\n** ^If the column-name parameter to sqlite3_table_column_metadata() is a\n** NULL pointer, then this routine simply checks for the existence of the\n** table and returns SQLITE_OK if the table exists and SQLITE_ERROR if it\n** does not.  If the table name parameter T in a call to\n** sqlite3_table_column_metadata(X,D,T,C,...) is NULL then the result is\n** undefined behavior.\n**\n** ^The column is identified by the second, third and fourth parameters to\n** this function. ^(The second parameter is either the name of the database\n** (i.e. \"main\", \"temp\", or an attached database) containing the specified\n** table or NULL.)^ ^If it is NULL, then all attached databases are searched\n** for the table using the same algorithm used by the database engine to\n** resolve unqualified table references.\n**\n** ^The third and fourth parameters to this function are the table and column\n** name of the desired column, respectively.\n**\n** ^Metadata is returned by writing to the memory locations passed as the 5th\n** and subsequent parameters to this function. ^Any of these arguments may be\n** NULL, in which case the corresponding element of metadata is omitted.\n**\n** ^(<blockquote>\n** <table border=\"1\">\n** <tr><th> Parameter <th> Output<br>Type <th>  Description\n**\n** <tr><td> 5th <td> const char* <td> Data type\n** <tr><td> 6th <td> const char* <td> Name of default collation sequence\n** <tr><td> 7th <td> int         <td> True if column has a NOT NULL constraint\n** <tr><td> 8th <td> int         <td> True if column is part of the PRIMARY KEY\n** <tr><td> 9th <td> int         <td> True if column is [AUTOINCREMENT]\n** </table>\n** </blockquote>)^\n**\n** ^The memory pointed to by the character pointers returned for the\n** declaration type and collation sequence is valid until the next\n** call to any SQLite API function.\n**\n** ^If the specified table is actually a view, an [error code] is returned.\n**\n** ^If the specified column is \"rowid\", \"oid\" or \"_rowid_\" and the table \n** is not a [WITHOUT ROWID] table and an\n** [INTEGER PRIMARY KEY] column has been explicitly declared, then the output\n** parameters are set for the explicitly declared column. ^(If there is no\n** [INTEGER PRIMARY KEY] column, then the outputs\n** for the [rowid] are set as follows:\n**\n** <pre>\n**     data type: \"INTEGER\"\n**     collation sequence: \"BINARY\"\n**     not null: 0\n**     primary key: 1\n**     auto increment: 0\n** </pre>)^\n**\n** ^This function causes all database schemas to be read from disk and\n** parsed, if that has not already been done, and returns an error if\n** any errors are encountered while loading the schema.\n*/\nSQLITE_API int sqlite3_table_column_metadata(\n  sqlite3 *db,                /* Connection handle */\n  const char *zDbName,        /* Database name or NULL */\n  const char *zTableName,     /* Table name */\n  const char *zColumnName,    /* Column name */\n  char const **pzDataType,    /* OUTPUT: Declared data type */\n  char const **pzCollSeq,     /* OUTPUT: Collation sequence name */\n  int *pNotNull,              /* OUTPUT: True if NOT NULL constraint exists */\n  int *pPrimaryKey,           /* OUTPUT: True if column part of PK */\n  int *pAutoinc               /* OUTPUT: True if column is auto-increment */\n);\n\n/*\n** CAPI3REF: Load An Extension\n** METHOD: sqlite3\n**\n** ^This interface loads an SQLite extension library from the named file.\n**\n** ^The sqlite3_load_extension() interface attempts to load an\n** [SQLite extension] library contained in the file zFile.  If\n** the file cannot be loaded directly, attempts are made to load\n** with various operating-system specific extensions added.\n** So for example, if \"samplelib\" cannot be loaded, then names like\n** \"samplelib.so\" or \"samplelib.dylib\" or \"samplelib.dll\" might\n** be tried also.\n**\n** ^The entry point is zProc.\n** ^(zProc may be 0, in which case SQLite will try to come up with an\n** entry point name on its own.  It first tries \"sqlite3_extension_init\".\n** If that does not work, it constructs a name \"sqlite3_X_init\" where the\n** X is consists of the lower-case equivalent of all ASCII alphabetic\n** characters in the filename from the last \"/\" to the first following\n** \".\" and omitting any initial \"lib\".)^\n** ^The sqlite3_load_extension() interface returns\n** [SQLITE_OK] on success and [SQLITE_ERROR] if something goes wrong.\n** ^If an error occurs and pzErrMsg is not 0, then the\n** [sqlite3_load_extension()] interface shall attempt to\n** fill *pzErrMsg with error message text stored in memory\n** obtained from [sqlite3_malloc()]. The calling function\n** should free this memory by calling [sqlite3_free()].\n**\n** ^Extension loading must be enabled using\n** [sqlite3_enable_load_extension()] or\n** [sqlite3_db_config](db,[SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION],1,NULL)\n** prior to calling this API,\n** otherwise an error will be returned.\n**\n** <b>Security warning:</b> It is recommended that the \n** [SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION] method be used to enable only this\n** interface.  The use of the [sqlite3_enable_load_extension()] interface\n** should be avoided.  This will keep the SQL function [load_extension()]\n** disabled and prevent SQL injections from giving attackers\n** access to extension loading capabilities.\n**\n** See also the [load_extension() SQL function].\n*/\nSQLITE_API int sqlite3_load_extension(\n  sqlite3 *db,          /* Load the extension into this database connection */\n  const char *zFile,    /* Name of the shared library containing extension */\n  const char *zProc,    /* Entry point.  Derived from zFile if 0 */\n  char **pzErrMsg       /* Put error message here if not 0 */\n);\n\n/*\n** CAPI3REF: Enable Or Disable Extension Loading\n** METHOD: sqlite3\n**\n** ^So as not to open security holes in older applications that are\n** unprepared to deal with [extension loading], and as a means of disabling\n** [extension loading] while evaluating user-entered SQL, the following API\n** is provided to turn the [sqlite3_load_extension()] mechanism on and off.\n**\n** ^Extension loading is off by default.\n** ^Call the sqlite3_enable_load_extension() routine with onoff==1\n** to turn extension loading on and call it with onoff==0 to turn\n** it back off again.\n**\n** ^This interface enables or disables both the C-API\n** [sqlite3_load_extension()] and the SQL function [load_extension()].\n** ^(Use [sqlite3_db_config](db,[SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION],..)\n** to enable or disable only the C-API.)^\n**\n** <b>Security warning:</b> It is recommended that extension loading\n** be disabled using the [SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION] method\n** rather than this interface, so the [load_extension()] SQL function\n** remains disabled. This will prevent SQL injections from giving attackers\n** access to extension loading capabilities.\n*/\nSQLITE_API int sqlite3_enable_load_extension(sqlite3 *db, int onoff);\n\n/*\n** CAPI3REF: Automatically Load Statically Linked Extensions\n**\n** ^This interface causes the xEntryPoint() function to be invoked for\n** each new [database connection] that is created.  The idea here is that\n** xEntryPoint() is the entry point for a statically linked [SQLite extension]\n** that is to be automatically loaded into all new database connections.\n**\n** ^(Even though the function prototype shows that xEntryPoint() takes\n** no arguments and returns void, SQLite invokes xEntryPoint() with three\n** arguments and expects an integer result as if the signature of the\n** entry point where as follows:\n**\n** <blockquote><pre>\n** &nbsp;  int xEntryPoint(\n** &nbsp;    sqlite3 *db,\n** &nbsp;    const char **pzErrMsg,\n** &nbsp;    const struct sqlite3_api_routines *pThunk\n** &nbsp;  );\n** </pre></blockquote>)^\n**\n** If the xEntryPoint routine encounters an error, it should make *pzErrMsg\n** point to an appropriate error message (obtained from [sqlite3_mprintf()])\n** and return an appropriate [error code].  ^SQLite ensures that *pzErrMsg\n** is NULL before calling the xEntryPoint().  ^SQLite will invoke\n** [sqlite3_free()] on *pzErrMsg after xEntryPoint() returns.  ^If any\n** xEntryPoint() returns an error, the [sqlite3_open()], [sqlite3_open16()],\n** or [sqlite3_open_v2()] call that provoked the xEntryPoint() will fail.\n**\n** ^Calling sqlite3_auto_extension(X) with an entry point X that is already\n** on the list of automatic extensions is a harmless no-op. ^No entry point\n** will be called more than once for each database connection that is opened.\n**\n** See also: [sqlite3_reset_auto_extension()]\n** and [sqlite3_cancel_auto_extension()]\n*/\nSQLITE_API int sqlite3_auto_extension(void(*xEntryPoint)(void));\n\n/*\n** CAPI3REF: Cancel Automatic Extension Loading\n**\n** ^The [sqlite3_cancel_auto_extension(X)] interface unregisters the\n** initialization routine X that was registered using a prior call to\n** [sqlite3_auto_extension(X)].  ^The [sqlite3_cancel_auto_extension(X)]\n** routine returns 1 if initialization routine X was successfully \n** unregistered and it returns 0 if X was not on the list of initialization\n** routines.\n*/\nSQLITE_API int sqlite3_cancel_auto_extension(void(*xEntryPoint)(void));\n\n/*\n** CAPI3REF: Reset Automatic Extension Loading\n**\n** ^This interface disables all automatic extensions previously\n** registered using [sqlite3_auto_extension()].\n*/\nSQLITE_API void sqlite3_reset_auto_extension(void);\n\n/*\n** The interface to the virtual-table mechanism is currently considered\n** to be experimental.  The interface might change in incompatible ways.\n** If this is a problem for you, do not use the interface at this time.\n**\n** When the virtual-table mechanism stabilizes, we will declare the\n** interface fixed, support it indefinitely, and remove this comment.\n*/\n\n/*\n** Structures used by the virtual table interface\n*/\ntypedef struct sqlite3_vtab sqlite3_vtab;\ntypedef struct sqlite3_index_info sqlite3_index_info;\ntypedef struct sqlite3_vtab_cursor sqlite3_vtab_cursor;\ntypedef struct sqlite3_module sqlite3_module;\n\n/*\n** CAPI3REF: Virtual Table Object\n** KEYWORDS: sqlite3_module {virtual table module}\n**\n** This structure, sometimes called a \"virtual table module\", \n** defines the implementation of a [virtual tables].  \n** This structure consists mostly of methods for the module.\n**\n** ^A virtual table module is created by filling in a persistent\n** instance of this structure and passing a pointer to that instance\n** to [sqlite3_create_module()] or [sqlite3_create_module_v2()].\n** ^The registration remains valid until it is replaced by a different\n** module or until the [database connection] closes.  The content\n** of this structure must not change while it is registered with\n** any database connection.\n*/\nstruct sqlite3_module {\n  int iVersion;\n  int (*xCreate)(sqlite3*, void *pAux,\n               int argc, const char *const*argv,\n               sqlite3_vtab **ppVTab, char**);\n  int (*xConnect)(sqlite3*, void *pAux,\n               int argc, const char *const*argv,\n               sqlite3_vtab **ppVTab, char**);\n  int (*xBestIndex)(sqlite3_vtab *pVTab, sqlite3_index_info*);\n  int (*xDisconnect)(sqlite3_vtab *pVTab);\n  int (*xDestroy)(sqlite3_vtab *pVTab);\n  int (*xOpen)(sqlite3_vtab *pVTab, sqlite3_vtab_cursor **ppCursor);\n  int (*xClose)(sqlite3_vtab_cursor*);\n  int (*xFilter)(sqlite3_vtab_cursor*, int idxNum, const char *idxStr,\n                int argc, sqlite3_value **argv);\n  int (*xNext)(sqlite3_vtab_cursor*);\n  int (*xEof)(sqlite3_vtab_cursor*);\n  int (*xColumn)(sqlite3_vtab_cursor*, sqlite3_context*, int);\n  int (*xRowid)(sqlite3_vtab_cursor*, sqlite3_int64 *pRowid);\n  int (*xUpdate)(sqlite3_vtab *, int, sqlite3_value **, sqlite3_int64 *);\n  int (*xBegin)(sqlite3_vtab *pVTab);\n  int (*xSync)(sqlite3_vtab *pVTab);\n  int (*xCommit)(sqlite3_vtab *pVTab);\n  int (*xRollback)(sqlite3_vtab *pVTab);\n  int (*xFindFunction)(sqlite3_vtab *pVtab, int nArg, const char *zName,\n                       void (**pxFunc)(sqlite3_context*,int,sqlite3_value**),\n                       void **ppArg);\n  int (*xRename)(sqlite3_vtab *pVtab, const char *zNew);\n  /* The methods above are in version 1 of the sqlite_module object. Those \n  ** below are for version 2 and greater. */\n  int (*xSavepoint)(sqlite3_vtab *pVTab, int);\n  int (*xRelease)(sqlite3_vtab *pVTab, int);\n  int (*xRollbackTo)(sqlite3_vtab *pVTab, int);\n  /* The methods above are in versions 1 and 2 of the sqlite_module object.\n  ** Those below are for version 3 and greater. */\n  int (*xShadowName)(const char*);\n};\n\n/*\n** CAPI3REF: Virtual Table Indexing Information\n** KEYWORDS: sqlite3_index_info\n**\n** The sqlite3_index_info structure and its substructures is used as part\n** of the [virtual table] interface to\n** pass information into and receive the reply from the [xBestIndex]\n** method of a [virtual table module].  The fields under **Inputs** are the\n** inputs to xBestIndex and are read-only.  xBestIndex inserts its\n** results into the **Outputs** fields.\n**\n** ^(The aConstraint[] array records WHERE clause constraints of the form:\n**\n** <blockquote>column OP expr</blockquote>\n**\n** where OP is =, &lt;, &lt;=, &gt;, or &gt;=.)^  ^(The particular operator is\n** stored in aConstraint[].op using one of the\n** [SQLITE_INDEX_CONSTRAINT_EQ | SQLITE_INDEX_CONSTRAINT_ values].)^\n** ^(The index of the column is stored in\n** aConstraint[].iColumn.)^  ^(aConstraint[].usable is TRUE if the\n** expr on the right-hand side can be evaluated (and thus the constraint\n** is usable) and false if it cannot.)^\n**\n** ^The optimizer automatically inverts terms of the form \"expr OP column\"\n** and makes other simplifications to the WHERE clause in an attempt to\n** get as many WHERE clause terms into the form shown above as possible.\n** ^The aConstraint[] array only reports WHERE clause terms that are\n** relevant to the particular virtual table being queried.\n**\n** ^Information about the ORDER BY clause is stored in aOrderBy[].\n** ^Each term of aOrderBy records a column of the ORDER BY clause.\n**\n** The colUsed field indicates which columns of the virtual table may be\n** required by the current scan. Virtual table columns are numbered from\n** zero in the order in which they appear within the CREATE TABLE statement\n** passed to sqlite3_declare_vtab(). For the first 63 columns (columns 0-62),\n** the corresponding bit is set within the colUsed mask if the column may be\n** required by SQLite. If the table has at least 64 columns and any column\n** to the right of the first 63 is required, then bit 63 of colUsed is also\n** set. In other words, column iCol may be required if the expression\n** (colUsed & ((sqlite3_uint64)1 << (iCol>=63 ? 63 : iCol))) evaluates to \n** non-zero.\n**\n** The [xBestIndex] method must fill aConstraintUsage[] with information\n** about what parameters to pass to xFilter.  ^If argvIndex>0 then\n** the right-hand side of the corresponding aConstraint[] is evaluated\n** and becomes the argvIndex-th entry in argv.  ^(If aConstraintUsage[].omit\n** is true, then the constraint is assumed to be fully handled by the\n** virtual table and is not checked again by SQLite.)^\n**\n** ^The idxNum and idxPtr values are recorded and passed into the\n** [xFilter] method.\n** ^[sqlite3_free()] is used to free idxPtr if and only if\n** needToFreeIdxPtr is true.\n**\n** ^The orderByConsumed means that output from [xFilter]/[xNext] will occur in\n** the correct order to satisfy the ORDER BY clause so that no separate\n** sorting step is required.\n**\n** ^The estimatedCost value is an estimate of the cost of a particular\n** strategy. A cost of N indicates that the cost of the strategy is similar\n** to a linear scan of an SQLite table with N rows. A cost of log(N) \n** indicates that the expense of the operation is similar to that of a\n** binary search on a unique indexed field of an SQLite table with N rows.\n**\n** ^The estimatedRows value is an estimate of the number of rows that\n** will be returned by the strategy.\n**\n** The xBestIndex method may optionally populate the idxFlags field with a \n** mask of SQLITE_INDEX_SCAN_* flags. Currently there is only one such flag -\n** SQLITE_INDEX_SCAN_UNIQUE. If the xBestIndex method sets this flag, SQLite\n** assumes that the strategy may visit at most one row. \n**\n** Additionally, if xBestIndex sets the SQLITE_INDEX_SCAN_UNIQUE flag, then\n** SQLite also assumes that if a call to the xUpdate() method is made as\n** part of the same statement to delete or update a virtual table row and the\n** implementation returns SQLITE_CONSTRAINT, then there is no need to rollback\n** any database changes. In other words, if the xUpdate() returns\n** SQLITE_CONSTRAINT, the database contents must be exactly as they were\n** before xUpdate was called. By contrast, if SQLITE_INDEX_SCAN_UNIQUE is not\n** set and xUpdate returns SQLITE_CONSTRAINT, any database changes made by\n** the xUpdate method are automatically rolled back by SQLite.\n**\n** IMPORTANT: The estimatedRows field was added to the sqlite3_index_info\n** structure for SQLite [version 3.8.2] ([dateof:3.8.2]). \n** If a virtual table extension is\n** used with an SQLite version earlier than 3.8.2, the results of attempting \n** to read or write the estimatedRows field are undefined (but are likely \n** to included crashing the application). The estimatedRows field should\n** therefore only be used if [sqlite3_libversion_number()] returns a\n** value greater than or equal to 3008002. Similarly, the idxFlags field\n** was added for [version 3.9.0] ([dateof:3.9.0]). \n** It may therefore only be used if\n** sqlite3_libversion_number() returns a value greater than or equal to\n** 3009000.\n*/\nstruct sqlite3_index_info {\n  /* Inputs */\n  int nConstraint;           /* Number of entries in aConstraint */\n  struct sqlite3_index_constraint {\n     int iColumn;              /* Column constrained.  -1 for ROWID */\n     unsigned char op;         /* Constraint operator */\n     unsigned char usable;     /* True if this constraint is usable */\n     int iTermOffset;          /* Used internally - xBestIndex should ignore */\n  } *aConstraint;            /* Table of WHERE clause constraints */\n  int nOrderBy;              /* Number of terms in the ORDER BY clause */\n  struct sqlite3_index_orderby {\n     int iColumn;              /* Column number */\n     unsigned char desc;       /* True for DESC.  False for ASC. */\n  } *aOrderBy;               /* The ORDER BY clause */\n  /* Outputs */\n  struct sqlite3_index_constraint_usage {\n    int argvIndex;           /* if >0, constraint is part of argv to xFilter */\n    unsigned char omit;      /* Do not code a test for this constraint */\n  } *aConstraintUsage;\n  int idxNum;                /* Number used to identify the index */\n  char *idxStr;              /* String, possibly obtained from sqlite3_malloc */\n  int needToFreeIdxStr;      /* Free idxStr using sqlite3_free() if true */\n  int orderByConsumed;       /* True if output is already ordered */\n  double estimatedCost;           /* Estimated cost of using this index */\n  /* Fields below are only available in SQLite 3.8.2 and later */\n  sqlite3_int64 estimatedRows;    /* Estimated number of rows returned */\n  /* Fields below are only available in SQLite 3.9.0 and later */\n  int idxFlags;              /* Mask of SQLITE_INDEX_SCAN_* flags */\n  /* Fields below are only available in SQLite 3.10.0 and later */\n  sqlite3_uint64 colUsed;    /* Input: Mask of columns used by statement */\n};\n\n/*\n** CAPI3REF: Virtual Table Scan Flags\n**\n** Virtual table implementations are allowed to set the \n** [sqlite3_index_info].idxFlags field to some combination of\n** these bits.\n*/\n#define SQLITE_INDEX_SCAN_UNIQUE      1     /* Scan visits at most 1 row */\n\n/*\n** CAPI3REF: Virtual Table Constraint Operator Codes\n**\n** These macros defined the allowed values for the\n** [sqlite3_index_info].aConstraint[].op field.  Each value represents\n** an operator that is part of a constraint term in the wHERE clause of\n** a query that uses a [virtual table].\n*/\n#define SQLITE_INDEX_CONSTRAINT_EQ         2\n#define SQLITE_INDEX_CONSTRAINT_GT         4\n#define SQLITE_INDEX_CONSTRAINT_LE         8\n#define SQLITE_INDEX_CONSTRAINT_LT        16\n#define SQLITE_INDEX_CONSTRAINT_GE        32\n#define SQLITE_INDEX_CONSTRAINT_MATCH     64\n#define SQLITE_INDEX_CONSTRAINT_LIKE      65\n#define SQLITE_INDEX_CONSTRAINT_GLOB      66\n#define SQLITE_INDEX_CONSTRAINT_REGEXP    67\n#define SQLITE_INDEX_CONSTRAINT_NE        68\n#define SQLITE_INDEX_CONSTRAINT_ISNOT     69\n#define SQLITE_INDEX_CONSTRAINT_ISNOTNULL 70\n#define SQLITE_INDEX_CONSTRAINT_ISNULL    71\n#define SQLITE_INDEX_CONSTRAINT_IS        72\n#define SQLITE_INDEX_CONSTRAINT_FUNCTION 150\n\n/*\n** CAPI3REF: Register A Virtual Table Implementation\n** METHOD: sqlite3\n**\n** ^These routines are used to register a new [virtual table module] name.\n** ^Module names must be registered before\n** creating a new [virtual table] using the module and before using a\n** preexisting [virtual table] for the module.\n**\n** ^The module name is registered on the [database connection] specified\n** by the first parameter.  ^The name of the module is given by the \n** second parameter.  ^The third parameter is a pointer to\n** the implementation of the [virtual table module].   ^The fourth\n** parameter is an arbitrary client data pointer that is passed through\n** into the [xCreate] and [xConnect] methods of the virtual table module\n** when a new virtual table is be being created or reinitialized.\n**\n** ^The sqlite3_create_module_v2() interface has a fifth parameter which\n** is a pointer to a destructor for the pClientData.  ^SQLite will\n** invoke the destructor function (if it is not NULL) when SQLite\n** no longer needs the pClientData pointer.  ^The destructor will also\n** be invoked if the call to sqlite3_create_module_v2() fails.\n** ^The sqlite3_create_module()\n** interface is equivalent to sqlite3_create_module_v2() with a NULL\n** destructor.\n*/\nSQLITE_API int sqlite3_create_module(\n  sqlite3 *db,               /* SQLite connection to register module with */\n  const char *zName,         /* Name of the module */\n  const sqlite3_module *p,   /* Methods for the module */\n  void *pClientData          /* Client data for xCreate/xConnect */\n);\nSQLITE_API int sqlite3_create_module_v2(\n  sqlite3 *db,               /* SQLite connection to register module with */\n  const char *zName,         /* Name of the module */\n  const sqlite3_module *p,   /* Methods for the module */\n  void *pClientData,         /* Client data for xCreate/xConnect */\n  void(*xDestroy)(void*)     /* Module destructor function */\n);\n\n/*\n** CAPI3REF: Virtual Table Instance Object\n** KEYWORDS: sqlite3_vtab\n**\n** Every [virtual table module] implementation uses a subclass\n** of this object to describe a particular instance\n** of the [virtual table].  Each subclass will\n** be tailored to the specific needs of the module implementation.\n** The purpose of this superclass is to define certain fields that are\n** common to all module implementations.\n**\n** ^Virtual tables methods can set an error message by assigning a\n** string obtained from [sqlite3_mprintf()] to zErrMsg.  The method should\n** take care that any prior string is freed by a call to [sqlite3_free()]\n** prior to assigning a new string to zErrMsg.  ^After the error message\n** is delivered up to the client application, the string will be automatically\n** freed by sqlite3_free() and the zErrMsg field will be zeroed.\n*/\nstruct sqlite3_vtab {\n  const sqlite3_module *pModule;  /* The module for this virtual table */\n  int nRef;                       /* Number of open cursors */\n  char *zErrMsg;                  /* Error message from sqlite3_mprintf() */\n  /* Virtual table implementations will typically add additional fields */\n};\n\n/*\n** CAPI3REF: Virtual Table Cursor Object\n** KEYWORDS: sqlite3_vtab_cursor {virtual table cursor}\n**\n** Every [virtual table module] implementation uses a subclass of the\n** following structure to describe cursors that point into the\n** [virtual table] and are used\n** to loop through the virtual table.  Cursors are created using the\n** [sqlite3_module.xOpen | xOpen] method of the module and are destroyed\n** by the [sqlite3_module.xClose | xClose] method.  Cursors are used\n** by the [xFilter], [xNext], [xEof], [xColumn], and [xRowid] methods\n** of the module.  Each module implementation will define\n** the content of a cursor structure to suit its own needs.\n**\n** This superclass exists in order to define fields of the cursor that\n** are common to all implementations.\n*/\nstruct sqlite3_vtab_cursor {\n  sqlite3_vtab *pVtab;      /* Virtual table of this cursor */\n  /* Virtual table implementations will typically add additional fields */\n};\n\n/*\n** CAPI3REF: Declare The Schema Of A Virtual Table\n**\n** ^The [xCreate] and [xConnect] methods of a\n** [virtual table module] call this interface\n** to declare the format (the names and datatypes of the columns) of\n** the virtual tables they implement.\n*/\nSQLITE_API int sqlite3_declare_vtab(sqlite3*, const char *zSQL);\n\n/*\n** CAPI3REF: Overload A Function For A Virtual Table\n** METHOD: sqlite3\n**\n** ^(Virtual tables can provide alternative implementations of functions\n** using the [xFindFunction] method of the [virtual table module].  \n** But global versions of those functions\n** must exist in order to be overloaded.)^\n**\n** ^(This API makes sure a global version of a function with a particular\n** name and number of parameters exists.  If no such function exists\n** before this API is called, a new function is created.)^  ^The implementation\n** of the new function always causes an exception to be thrown.  So\n** the new function is not good for anything by itself.  Its only\n** purpose is to be a placeholder function that can be overloaded\n** by a [virtual table].\n*/\nSQLITE_API int sqlite3_overload_function(sqlite3*, const char *zFuncName, int nArg);\n\n/*\n** The interface to the virtual-table mechanism defined above (back up\n** to a comment remarkably similar to this one) is currently considered\n** to be experimental.  The interface might change in incompatible ways.\n** If this is a problem for you, do not use the interface at this time.\n**\n** When the virtual-table mechanism stabilizes, we will declare the\n** interface fixed, support it indefinitely, and remove this comment.\n*/\n\n/*\n** CAPI3REF: A Handle To An Open BLOB\n** KEYWORDS: {BLOB handle} {BLOB handles}\n**\n** An instance of this object represents an open BLOB on which\n** [sqlite3_blob_open | incremental BLOB I/O] can be performed.\n** ^Objects of this type are created by [sqlite3_blob_open()]\n** and destroyed by [sqlite3_blob_close()].\n** ^The [sqlite3_blob_read()] and [sqlite3_blob_write()] interfaces\n** can be used to read or write small subsections of the BLOB.\n** ^The [sqlite3_blob_bytes()] interface returns the size of the BLOB in bytes.\n*/\ntypedef struct sqlite3_blob sqlite3_blob;\n\n/*\n** CAPI3REF: Open A BLOB For Incremental I/O\n** METHOD: sqlite3\n** CONSTRUCTOR: sqlite3_blob\n**\n** ^(This interfaces opens a [BLOB handle | handle] to the BLOB located\n** in row iRow, column zColumn, table zTable in database zDb;\n** in other words, the same BLOB that would be selected by:\n**\n** <pre>\n**     SELECT zColumn FROM zDb.zTable WHERE [rowid] = iRow;\n** </pre>)^\n**\n** ^(Parameter zDb is not the filename that contains the database, but \n** rather the symbolic name of the database. For attached databases, this is\n** the name that appears after the AS keyword in the [ATTACH] statement.\n** For the main database file, the database name is \"main\". For TEMP\n** tables, the database name is \"temp\".)^\n**\n** ^If the flags parameter is non-zero, then the BLOB is opened for read\n** and write access. ^If the flags parameter is zero, the BLOB is opened for\n** read-only access.\n**\n** ^(On success, [SQLITE_OK] is returned and the new [BLOB handle] is stored\n** in *ppBlob. Otherwise an [error code] is returned and, unless the error\n** code is SQLITE_MISUSE, *ppBlob is set to NULL.)^ ^This means that, provided\n** the API is not misused, it is always safe to call [sqlite3_blob_close()] \n** on *ppBlob after this function it returns.\n**\n** This function fails with SQLITE_ERROR if any of the following are true:\n** <ul>\n**   <li> ^(Database zDb does not exist)^, \n**   <li> ^(Table zTable does not exist within database zDb)^, \n**   <li> ^(Table zTable is a WITHOUT ROWID table)^, \n**   <li> ^(Column zColumn does not exist)^,\n**   <li> ^(Row iRow is not present in the table)^,\n**   <li> ^(The specified column of row iRow contains a value that is not\n**         a TEXT or BLOB value)^,\n**   <li> ^(Column zColumn is part of an index, PRIMARY KEY or UNIQUE \n**         constraint and the blob is being opened for read/write access)^,\n**   <li> ^([foreign key constraints | Foreign key constraints] are enabled, \n**         column zColumn is part of a [child key] definition and the blob is\n**         being opened for read/write access)^.\n** </ul>\n**\n** ^Unless it returns SQLITE_MISUSE, this function sets the \n** [database connection] error code and message accessible via \n** [sqlite3_errcode()] and [sqlite3_errmsg()] and related functions. \n**\n** A BLOB referenced by sqlite3_blob_open() may be read using the\n** [sqlite3_blob_read()] interface and modified by using\n** [sqlite3_blob_write()].  The [BLOB handle] can be moved to a\n** different row of the same table using the [sqlite3_blob_reopen()]\n** interface.  However, the column, table, or database of a [BLOB handle]\n** cannot be changed after the [BLOB handle] is opened.\n**\n** ^(If the row that a BLOB handle points to is modified by an\n** [UPDATE], [DELETE], or by [ON CONFLICT] side-effects\n** then the BLOB handle is marked as \"expired\".\n** This is true if any column of the row is changed, even a column\n** other than the one the BLOB handle is open on.)^\n** ^Calls to [sqlite3_blob_read()] and [sqlite3_blob_write()] for\n** an expired BLOB handle fail with a return code of [SQLITE_ABORT].\n** ^(Changes written into a BLOB prior to the BLOB expiring are not\n** rolled back by the expiration of the BLOB.  Such changes will eventually\n** commit if the transaction continues to completion.)^\n**\n** ^Use the [sqlite3_blob_bytes()] interface to determine the size of\n** the opened blob.  ^The size of a blob may not be changed by this\n** interface.  Use the [UPDATE] SQL command to change the size of a\n** blob.\n**\n** ^The [sqlite3_bind_zeroblob()] and [sqlite3_result_zeroblob()] interfaces\n** and the built-in [zeroblob] SQL function may be used to create a \n** zero-filled blob to read or write using the incremental-blob interface.\n**\n** To avoid a resource leak, every open [BLOB handle] should eventually\n** be released by a call to [sqlite3_blob_close()].\n**\n** See also: [sqlite3_blob_close()],\n** [sqlite3_blob_reopen()], [sqlite3_blob_read()],\n** [sqlite3_blob_bytes()], [sqlite3_blob_write()].\n*/\nSQLITE_API int sqlite3_blob_open(\n  sqlite3*,\n  const char *zDb,\n  const char *zTable,\n  const char *zColumn,\n  sqlite3_int64 iRow,\n  int flags,\n  sqlite3_blob **ppBlob\n);\n\n/*\n** CAPI3REF: Move a BLOB Handle to a New Row\n** METHOD: sqlite3_blob\n**\n** ^This function is used to move an existing [BLOB handle] so that it points\n** to a different row of the same database table. ^The new row is identified\n** by the rowid value passed as the second argument. Only the row can be\n** changed. ^The database, table and column on which the blob handle is open\n** remain the same. Moving an existing [BLOB handle] to a new row is\n** faster than closing the existing handle and opening a new one.\n**\n** ^(The new row must meet the same criteria as for [sqlite3_blob_open()] -\n** it must exist and there must be either a blob or text value stored in\n** the nominated column.)^ ^If the new row is not present in the table, or if\n** it does not contain a blob or text value, or if another error occurs, an\n** SQLite error code is returned and the blob handle is considered aborted.\n** ^All subsequent calls to [sqlite3_blob_read()], [sqlite3_blob_write()] or\n** [sqlite3_blob_reopen()] on an aborted blob handle immediately return\n** SQLITE_ABORT. ^Calling [sqlite3_blob_bytes()] on an aborted blob handle\n** always returns zero.\n**\n** ^This function sets the database handle error code and message.\n*/\nSQLITE_API int sqlite3_blob_reopen(sqlite3_blob *, sqlite3_int64);\n\n/*\n** CAPI3REF: Close A BLOB Handle\n** DESTRUCTOR: sqlite3_blob\n**\n** ^This function closes an open [BLOB handle]. ^(The BLOB handle is closed\n** unconditionally.  Even if this routine returns an error code, the \n** handle is still closed.)^\n**\n** ^If the blob handle being closed was opened for read-write access, and if\n** the database is in auto-commit mode and there are no other open read-write\n** blob handles or active write statements, the current transaction is\n** committed. ^If an error occurs while committing the transaction, an error\n** code is returned and the transaction rolled back.\n**\n** Calling this function with an argument that is not a NULL pointer or an\n** open blob handle results in undefined behaviour. ^Calling this routine \n** with a null pointer (such as would be returned by a failed call to \n** [sqlite3_blob_open()]) is a harmless no-op. ^Otherwise, if this function\n** is passed a valid open blob handle, the values returned by the \n** sqlite3_errcode() and sqlite3_errmsg() functions are set before returning.\n*/\nSQLITE_API int sqlite3_blob_close(sqlite3_blob *);\n\n/*\n** CAPI3REF: Return The Size Of An Open BLOB\n** METHOD: sqlite3_blob\n**\n** ^Returns the size in bytes of the BLOB accessible via the \n** successfully opened [BLOB handle] in its only argument.  ^The\n** incremental blob I/O routines can only read or overwriting existing\n** blob content; they cannot change the size of a blob.\n**\n** This routine only works on a [BLOB handle] which has been created\n** by a prior successful call to [sqlite3_blob_open()] and which has not\n** been closed by [sqlite3_blob_close()].  Passing any other pointer in\n** to this routine results in undefined and probably undesirable behavior.\n*/\nSQLITE_API int sqlite3_blob_bytes(sqlite3_blob *);\n\n/*\n** CAPI3REF: Read Data From A BLOB Incrementally\n** METHOD: sqlite3_blob\n**\n** ^(This function is used to read data from an open [BLOB handle] into a\n** caller-supplied buffer. N bytes of data are copied into buffer Z\n** from the open BLOB, starting at offset iOffset.)^\n**\n** ^If offset iOffset is less than N bytes from the end of the BLOB,\n** [SQLITE_ERROR] is returned and no data is read.  ^If N or iOffset is\n** less than zero, [SQLITE_ERROR] is returned and no data is read.\n** ^The size of the blob (and hence the maximum value of N+iOffset)\n** can be determined using the [sqlite3_blob_bytes()] interface.\n**\n** ^An attempt to read from an expired [BLOB handle] fails with an\n** error code of [SQLITE_ABORT].\n**\n** ^(On success, sqlite3_blob_read() returns SQLITE_OK.\n** Otherwise, an [error code] or an [extended error code] is returned.)^\n**\n** This routine only works on a [BLOB handle] which has been created\n** by a prior successful call to [sqlite3_blob_open()] and which has not\n** been closed by [sqlite3_blob_close()].  Passing any other pointer in\n** to this routine results in undefined and probably undesirable behavior.\n**\n** See also: [sqlite3_blob_write()].\n*/\nSQLITE_API int sqlite3_blob_read(sqlite3_blob *, void *Z, int N, int iOffset);\n\n/*\n** CAPI3REF: Write Data Into A BLOB Incrementally\n** METHOD: sqlite3_blob\n**\n** ^(This function is used to write data into an open [BLOB handle] from a\n** caller-supplied buffer. N bytes of data are copied from the buffer Z\n** into the open BLOB, starting at offset iOffset.)^\n**\n** ^(On success, sqlite3_blob_write() returns SQLITE_OK.\n** Otherwise, an  [error code] or an [extended error code] is returned.)^\n** ^Unless SQLITE_MISUSE is returned, this function sets the \n** [database connection] error code and message accessible via \n** [sqlite3_errcode()] and [sqlite3_errmsg()] and related functions. \n**\n** ^If the [BLOB handle] passed as the first argument was not opened for\n** writing (the flags parameter to [sqlite3_blob_open()] was zero),\n** this function returns [SQLITE_READONLY].\n**\n** This function may only modify the contents of the BLOB; it is\n** not possible to increase the size of a BLOB using this API.\n** ^If offset iOffset is less than N bytes from the end of the BLOB,\n** [SQLITE_ERROR] is returned and no data is written. The size of the \n** BLOB (and hence the maximum value of N+iOffset) can be determined \n** using the [sqlite3_blob_bytes()] interface. ^If N or iOffset are less \n** than zero [SQLITE_ERROR] is returned and no data is written.\n**\n** ^An attempt to write to an expired [BLOB handle] fails with an\n** error code of [SQLITE_ABORT].  ^Writes to the BLOB that occurred\n** before the [BLOB handle] expired are not rolled back by the\n** expiration of the handle, though of course those changes might\n** have been overwritten by the statement that expired the BLOB handle\n** or by other independent statements.\n**\n** This routine only works on a [BLOB handle] which has been created\n** by a prior successful call to [sqlite3_blob_open()] and which has not\n** been closed by [sqlite3_blob_close()].  Passing any other pointer in\n** to this routine results in undefined and probably undesirable behavior.\n**\n** See also: [sqlite3_blob_read()].\n*/\nSQLITE_API int sqlite3_blob_write(sqlite3_blob *, const void *z, int n, int iOffset);\n\n/*\n** CAPI3REF: Virtual File System Objects\n**\n** A virtual filesystem (VFS) is an [sqlite3_vfs] object\n** that SQLite uses to interact\n** with the underlying operating system.  Most SQLite builds come with a\n** single default VFS that is appropriate for the host computer.\n** New VFSes can be registered and existing VFSes can be unregistered.\n** The following interfaces are provided.\n**\n** ^The sqlite3_vfs_find() interface returns a pointer to a VFS given its name.\n** ^Names are case sensitive.\n** ^Names are zero-terminated UTF-8 strings.\n** ^If there is no match, a NULL pointer is returned.\n** ^If zVfsName is NULL then the default VFS is returned.\n**\n** ^New VFSes are registered with sqlite3_vfs_register().\n** ^Each new VFS becomes the default VFS if the makeDflt flag is set.\n** ^The same VFS can be registered multiple times without injury.\n** ^To make an existing VFS into the default VFS, register it again\n** with the makeDflt flag set.  If two different VFSes with the\n** same name are registered, the behavior is undefined.  If a\n** VFS is registered with a name that is NULL or an empty string,\n** then the behavior is undefined.\n**\n** ^Unregister a VFS with the sqlite3_vfs_unregister() interface.\n** ^(If the default VFS is unregistered, another VFS is chosen as\n** the default.  The choice for the new VFS is arbitrary.)^\n*/\nSQLITE_API sqlite3_vfs *sqlite3_vfs_find(const char *zVfsName);\nSQLITE_API int sqlite3_vfs_register(sqlite3_vfs*, int makeDflt);\nSQLITE_API int sqlite3_vfs_unregister(sqlite3_vfs*);\n\n/*\n** CAPI3REF: Mutexes\n**\n** The SQLite core uses these routines for thread\n** synchronization. Though they are intended for internal\n** use by SQLite, code that links against SQLite is\n** permitted to use any of these routines.\n**\n** The SQLite source code contains multiple implementations\n** of these mutex routines.  An appropriate implementation\n** is selected automatically at compile-time.  The following\n** implementations are available in the SQLite core:\n**\n** <ul>\n** <li>   SQLITE_MUTEX_PTHREADS\n** <li>   SQLITE_MUTEX_W32\n** <li>   SQLITE_MUTEX_NOOP\n** </ul>\n**\n** The SQLITE_MUTEX_NOOP implementation is a set of routines\n** that does no real locking and is appropriate for use in\n** a single-threaded application.  The SQLITE_MUTEX_PTHREADS and\n** SQLITE_MUTEX_W32 implementations are appropriate for use on Unix\n** and Windows.\n**\n** If SQLite is compiled with the SQLITE_MUTEX_APPDEF preprocessor\n** macro defined (with \"-DSQLITE_MUTEX_APPDEF=1\"), then no mutex\n** implementation is included with the library. In this case the\n** application must supply a custom mutex implementation using the\n** [SQLITE_CONFIG_MUTEX] option of the sqlite3_config() function\n** before calling sqlite3_initialize() or any other public sqlite3_\n** function that calls sqlite3_initialize().\n**\n** ^The sqlite3_mutex_alloc() routine allocates a new\n** mutex and returns a pointer to it. ^The sqlite3_mutex_alloc()\n** routine returns NULL if it is unable to allocate the requested\n** mutex.  The argument to sqlite3_mutex_alloc() must one of these\n** integer constants:\n**\n** <ul>\n** <li>  SQLITE_MUTEX_FAST\n** <li>  SQLITE_MUTEX_RECURSIVE\n** <li>  SQLITE_MUTEX_STATIC_MASTER\n** <li>  SQLITE_MUTEX_STATIC_MEM\n** <li>  SQLITE_MUTEX_STATIC_OPEN\n** <li>  SQLITE_MUTEX_STATIC_PRNG\n** <li>  SQLITE_MUTEX_STATIC_LRU\n** <li>  SQLITE_MUTEX_STATIC_PMEM\n** <li>  SQLITE_MUTEX_STATIC_APP1\n** <li>  SQLITE_MUTEX_STATIC_APP2\n** <li>  SQLITE_MUTEX_STATIC_APP3\n** <li>  SQLITE_MUTEX_STATIC_VFS1\n** <li>  SQLITE_MUTEX_STATIC_VFS2\n** <li>  SQLITE_MUTEX_STATIC_VFS3\n** </ul>\n**\n** ^The first two constants (SQLITE_MUTEX_FAST and SQLITE_MUTEX_RECURSIVE)\n** cause sqlite3_mutex_alloc() to create\n** a new mutex.  ^The new mutex is recursive when SQLITE_MUTEX_RECURSIVE\n** is used but not necessarily so when SQLITE_MUTEX_FAST is used.\n** The mutex implementation does not need to make a distinction\n** between SQLITE_MUTEX_RECURSIVE and SQLITE_MUTEX_FAST if it does\n** not want to.  SQLite will only request a recursive mutex in\n** cases where it really needs one.  If a faster non-recursive mutex\n** implementation is available on the host platform, the mutex subsystem\n** might return such a mutex in response to SQLITE_MUTEX_FAST.\n**\n** ^The other allowed parameters to sqlite3_mutex_alloc() (anything other\n** than SQLITE_MUTEX_FAST and SQLITE_MUTEX_RECURSIVE) each return\n** a pointer to a static preexisting mutex.  ^Nine static mutexes are\n** used by the current version of SQLite.  Future versions of SQLite\n** may add additional static mutexes.  Static mutexes are for internal\n** use by SQLite only.  Applications that use SQLite mutexes should\n** use only the dynamic mutexes returned by SQLITE_MUTEX_FAST or\n** SQLITE_MUTEX_RECURSIVE.\n**\n** ^Note that if one of the dynamic mutex parameters (SQLITE_MUTEX_FAST\n** or SQLITE_MUTEX_RECURSIVE) is used then sqlite3_mutex_alloc()\n** returns a different mutex on every call.  ^For the static\n** mutex types, the same mutex is returned on every call that has\n** the same type number.\n**\n** ^The sqlite3_mutex_free() routine deallocates a previously\n** allocated dynamic mutex.  Attempting to deallocate a static\n** mutex results in undefined behavior.\n**\n** ^The sqlite3_mutex_enter() and sqlite3_mutex_try() routines attempt\n** to enter a mutex.  ^If another thread is already within the mutex,\n** sqlite3_mutex_enter() will block and sqlite3_mutex_try() will return\n** SQLITE_BUSY.  ^The sqlite3_mutex_try() interface returns [SQLITE_OK]\n** upon successful entry.  ^(Mutexes created using\n** SQLITE_MUTEX_RECURSIVE can be entered multiple times by the same thread.\n** In such cases, the\n** mutex must be exited an equal number of times before another thread\n** can enter.)^  If the same thread tries to enter any mutex other\n** than an SQLITE_MUTEX_RECURSIVE more than once, the behavior is undefined.\n**\n** ^(Some systems (for example, Windows 95) do not support the operation\n** implemented by sqlite3_mutex_try().  On those systems, sqlite3_mutex_try()\n** will always return SQLITE_BUSY. The SQLite core only ever uses\n** sqlite3_mutex_try() as an optimization so this is acceptable \n** behavior.)^\n**\n** ^The sqlite3_mutex_leave() routine exits a mutex that was\n** previously entered by the same thread.   The behavior\n** is undefined if the mutex is not currently entered by the\n** calling thread or is not currently allocated.\n**\n** ^If the argument to sqlite3_mutex_enter(), sqlite3_mutex_try(), or\n** sqlite3_mutex_leave() is a NULL pointer, then all three routines\n** behave as no-ops.\n**\n** See also: [sqlite3_mutex_held()] and [sqlite3_mutex_notheld()].\n*/\nSQLITE_API sqlite3_mutex *sqlite3_mutex_alloc(int);\nSQLITE_API void sqlite3_mutex_free(sqlite3_mutex*);\nSQLITE_API void sqlite3_mutex_enter(sqlite3_mutex*);\nSQLITE_API int sqlite3_mutex_try(sqlite3_mutex*);\nSQLITE_API void sqlite3_mutex_leave(sqlite3_mutex*);\n\n/*\n** CAPI3REF: Mutex Methods Object\n**\n** An instance of this structure defines the low-level routines\n** used to allocate and use mutexes.\n**\n** Usually, the default mutex implementations provided by SQLite are\n** sufficient, however the application has the option of substituting a custom\n** implementation for specialized deployments or systems for which SQLite\n** does not provide a suitable implementation. In this case, the application\n** creates and populates an instance of this structure to pass\n** to sqlite3_config() along with the [SQLITE_CONFIG_MUTEX] option.\n** Additionally, an instance of this structure can be used as an\n** output variable when querying the system for the current mutex\n** implementation, using the [SQLITE_CONFIG_GETMUTEX] option.\n**\n** ^The xMutexInit method defined by this structure is invoked as\n** part of system initialization by the sqlite3_initialize() function.\n** ^The xMutexInit routine is called by SQLite exactly once for each\n** effective call to [sqlite3_initialize()].\n**\n** ^The xMutexEnd method defined by this structure is invoked as\n** part of system shutdown by the sqlite3_shutdown() function. The\n** implementation of this method is expected to release all outstanding\n** resources obtained by the mutex methods implementation, especially\n** those obtained by the xMutexInit method.  ^The xMutexEnd()\n** interface is invoked exactly once for each call to [sqlite3_shutdown()].\n**\n** ^(The remaining seven methods defined by this structure (xMutexAlloc,\n** xMutexFree, xMutexEnter, xMutexTry, xMutexLeave, xMutexHeld and\n** xMutexNotheld) implement the following interfaces (respectively):\n**\n** <ul>\n**   <li>  [sqlite3_mutex_alloc()] </li>\n**   <li>  [sqlite3_mutex_free()] </li>\n**   <li>  [sqlite3_mutex_enter()] </li>\n**   <li>  [sqlite3_mutex_try()] </li>\n**   <li>  [sqlite3_mutex_leave()] </li>\n**   <li>  [sqlite3_mutex_held()] </li>\n**   <li>  [sqlite3_mutex_notheld()] </li>\n** </ul>)^\n**\n** The only difference is that the public sqlite3_XXX functions enumerated\n** above silently ignore any invocations that pass a NULL pointer instead\n** of a valid mutex handle. The implementations of the methods defined\n** by this structure are not required to handle this case, the results\n** of passing a NULL pointer instead of a valid mutex handle are undefined\n** (i.e. it is acceptable to provide an implementation that segfaults if\n** it is passed a NULL pointer).\n**\n** The xMutexInit() method must be threadsafe.  It must be harmless to\n** invoke xMutexInit() multiple times within the same process and without\n** intervening calls to xMutexEnd().  Second and subsequent calls to\n** xMutexInit() must be no-ops.\n**\n** xMutexInit() must not use SQLite memory allocation ([sqlite3_malloc()]\n** and its associates).  Similarly, xMutexAlloc() must not use SQLite memory\n** allocation for a static mutex.  ^However xMutexAlloc() may use SQLite\n** memory allocation for a fast or recursive mutex.\n**\n** ^SQLite will invoke the xMutexEnd() method when [sqlite3_shutdown()] is\n** called, but only if the prior call to xMutexInit returned SQLITE_OK.\n** If xMutexInit fails in any way, it is expected to clean up after itself\n** prior to returning.\n*/\ntypedef struct sqlite3_mutex_methods sqlite3_mutex_methods;\nstruct sqlite3_mutex_methods {\n  int (*xMutexInit)(void);\n  int (*xMutexEnd)(void);\n  sqlite3_mutex *(*xMutexAlloc)(int);\n  void (*xMutexFree)(sqlite3_mutex *);\n  void (*xMutexEnter)(sqlite3_mutex *);\n  int (*xMutexTry)(sqlite3_mutex *);\n  void (*xMutexLeave)(sqlite3_mutex *);\n  int (*xMutexHeld)(sqlite3_mutex *);\n  int (*xMutexNotheld)(sqlite3_mutex *);\n};\n\n/*\n** CAPI3REF: Mutex Verification Routines\n**\n** The sqlite3_mutex_held() and sqlite3_mutex_notheld() routines\n** are intended for use inside assert() statements.  The SQLite core\n** never uses these routines except inside an assert() and applications\n** are advised to follow the lead of the core.  The SQLite core only\n** provides implementations for these routines when it is compiled\n** with the SQLITE_DEBUG flag.  External mutex implementations\n** are only required to provide these routines if SQLITE_DEBUG is\n** defined and if NDEBUG is not defined.\n**\n** These routines should return true if the mutex in their argument\n** is held or not held, respectively, by the calling thread.\n**\n** The implementation is not required to provide versions of these\n** routines that actually work. If the implementation does not provide working\n** versions of these routines, it should at least provide stubs that always\n** return true so that one does not get spurious assertion failures.\n**\n** If the argument to sqlite3_mutex_held() is a NULL pointer then\n** the routine should return 1.   This seems counter-intuitive since\n** clearly the mutex cannot be held if it does not exist.  But\n** the reason the mutex does not exist is because the build is not\n** using mutexes.  And we do not want the assert() containing the\n** call to sqlite3_mutex_held() to fail, so a non-zero return is\n** the appropriate thing to do.  The sqlite3_mutex_notheld()\n** interface should also return 1 when given a NULL pointer.\n*/\n#ifndef NDEBUG\nSQLITE_API int sqlite3_mutex_held(sqlite3_mutex*);\nSQLITE_API int sqlite3_mutex_notheld(sqlite3_mutex*);\n#endif\n\n/*\n** CAPI3REF: Mutex Types\n**\n** The [sqlite3_mutex_alloc()] interface takes a single argument\n** which is one of these integer constants.\n**\n** The set of static mutexes may change from one SQLite release to the\n** next.  Applications that override the built-in mutex logic must be\n** prepared to accommodate additional static mutexes.\n*/\n#define SQLITE_MUTEX_FAST             0\n#define SQLITE_MUTEX_RECURSIVE        1\n#define SQLITE_MUTEX_STATIC_MASTER    2\n#define SQLITE_MUTEX_STATIC_MEM       3  /* sqlite3_malloc() */\n#define SQLITE_MUTEX_STATIC_MEM2      4  /* NOT USED */\n#define SQLITE_MUTEX_STATIC_OPEN      4  /* sqlite3BtreeOpen() */\n#define SQLITE_MUTEX_STATIC_PRNG      5  /* sqlite3_randomness() */\n#define SQLITE_MUTEX_STATIC_LRU       6  /* lru page list */\n#define SQLITE_MUTEX_STATIC_LRU2      7  /* NOT USED */\n#define SQLITE_MUTEX_STATIC_PMEM      7  /* sqlite3PageMalloc() */\n#define SQLITE_MUTEX_STATIC_APP1      8  /* For use by application */\n#define SQLITE_MUTEX_STATIC_APP2      9  /* For use by application */\n#define SQLITE_MUTEX_STATIC_APP3     10  /* For use by application */\n#define SQLITE_MUTEX_STATIC_VFS1     11  /* For use by built-in VFS */\n#define SQLITE_MUTEX_STATIC_VFS2     12  /* For use by extension VFS */\n#define SQLITE_MUTEX_STATIC_VFS3     13  /* For use by application VFS */\n\n/*\n** CAPI3REF: Retrieve the mutex for a database connection\n** METHOD: sqlite3\n**\n** ^This interface returns a pointer the [sqlite3_mutex] object that \n** serializes access to the [database connection] given in the argument\n** when the [threading mode] is Serialized.\n** ^If the [threading mode] is Single-thread or Multi-thread then this\n** routine returns a NULL pointer.\n*/\nSQLITE_API sqlite3_mutex *sqlite3_db_mutex(sqlite3*);\n\n/*\n** CAPI3REF: Low-Level Control Of Database Files\n** METHOD: sqlite3\n** KEYWORDS: {file control}\n**\n** ^The [sqlite3_file_control()] interface makes a direct call to the\n** xFileControl method for the [sqlite3_io_methods] object associated\n** with a particular database identified by the second argument. ^The\n** name of the database is \"main\" for the main database or \"temp\" for the\n** TEMP database, or the name that appears after the AS keyword for\n** databases that are added using the [ATTACH] SQL command.\n** ^A NULL pointer can be used in place of \"main\" to refer to the\n** main database file.\n** ^The third and fourth parameters to this routine\n** are passed directly through to the second and third parameters of\n** the xFileControl method.  ^The return value of the xFileControl\n** method becomes the return value of this routine.\n**\n** A few opcodes for [sqlite3_file_control()] are handled directly\n** by the SQLite core and never invoke the \n** sqlite3_io_methods.xFileControl method.\n** ^The [SQLITE_FCNTL_FILE_POINTER] value for the op parameter causes\n** a pointer to the underlying [sqlite3_file] object to be written into\n** the space pointed to by the 4th parameter.  The\n** [SQLITE_FCNTL_JOURNAL_POINTER] works similarly except that it returns\n** the [sqlite3_file] object associated with the journal file instead of\n** the main database.  The [SQLITE_FCNTL_VFS_POINTER] opcode returns\n** a pointer to the underlying [sqlite3_vfs] object for the file.\n** The [SQLITE_FCNTL_DATA_VERSION] returns the data version counter\n** from the pager.\n**\n** ^If the second parameter (zDbName) does not match the name of any\n** open database file, then SQLITE_ERROR is returned.  ^This error\n** code is not remembered and will not be recalled by [sqlite3_errcode()]\n** or [sqlite3_errmsg()].  The underlying xFileControl method might\n** also return SQLITE_ERROR.  There is no way to distinguish between\n** an incorrect zDbName and an SQLITE_ERROR return from the underlying\n** xFileControl method.\n**\n** See also: [file control opcodes]\n*/\nSQLITE_API int sqlite3_file_control(sqlite3*, const char *zDbName, int op, void*);\n\n/*\n** CAPI3REF: Testing Interface\n**\n** ^The sqlite3_test_control() interface is used to read out internal\n** state of SQLite and to inject faults into SQLite for testing\n** purposes.  ^The first parameter is an operation code that determines\n** the number, meaning, and operation of all subsequent parameters.\n**\n** This interface is not for use by applications.  It exists solely\n** for verifying the correct operation of the SQLite library.  Depending\n** on how the SQLite library is compiled, this interface might not exist.\n**\n** The details of the operation codes, their meanings, the parameters\n** they take, and what they do are all subject to change without notice.\n** Unlike most of the SQLite API, this function is not guaranteed to\n** operate consistently from one release to the next.\n*/\nSQLITE_API int sqlite3_test_control(int op, ...);\n\n/*\n** CAPI3REF: Testing Interface Operation Codes\n**\n** These constants are the valid operation code parameters used\n** as the first argument to [sqlite3_test_control()].\n**\n** These parameters and their meanings are subject to change\n** without notice.  These values are for testing purposes only.\n** Applications should not use any of these parameters or the\n** [sqlite3_test_control()] interface.\n*/\n#define SQLITE_TESTCTRL_FIRST                    5\n#define SQLITE_TESTCTRL_PRNG_SAVE                5\n#define SQLITE_TESTCTRL_PRNG_RESTORE             6\n#define SQLITE_TESTCTRL_PRNG_RESET               7\n#define SQLITE_TESTCTRL_BITVEC_TEST              8\n#define SQLITE_TESTCTRL_FAULT_INSTALL            9\n#define SQLITE_TESTCTRL_BENIGN_MALLOC_HOOKS     10\n#define SQLITE_TESTCTRL_PENDING_BYTE            11\n#define SQLITE_TESTCTRL_ASSERT                  12\n#define SQLITE_TESTCTRL_ALWAYS                  13\n#define SQLITE_TESTCTRL_RESERVE                 14\n#define SQLITE_TESTCTRL_OPTIMIZATIONS           15\n#define SQLITE_TESTCTRL_ISKEYWORD               16  /* NOT USED */\n#define SQLITE_TESTCTRL_SCRATCHMALLOC           17  /* NOT USED */\n#define SQLITE_TESTCTRL_INTERNAL_FUNCTIONS      17\n#define SQLITE_TESTCTRL_LOCALTIME_FAULT         18\n#define SQLITE_TESTCTRL_EXPLAIN_STMT            19  /* NOT USED */\n#define SQLITE_TESTCTRL_ONCE_RESET_THRESHOLD    19\n#define SQLITE_TESTCTRL_NEVER_CORRUPT           20\n#define SQLITE_TESTCTRL_VDBE_COVERAGE           21\n#define SQLITE_TESTCTRL_BYTEORDER               22\n#define SQLITE_TESTCTRL_ISINIT                  23\n#define SQLITE_TESTCTRL_SORTER_MMAP             24\n#define SQLITE_TESTCTRL_IMPOSTER                25\n#define SQLITE_TESTCTRL_PARSER_COVERAGE         26\n#define SQLITE_TESTCTRL_LAST                    26  /* Largest TESTCTRL */\n\n/*\n** CAPI3REF: SQL Keyword Checking\n**\n** These routines provide access to the set of SQL language keywords \n** recognized by SQLite.  Applications can uses these routines to determine\n** whether or not a specific identifier needs to be escaped (for example,\n** by enclosing in double-quotes) so as not to confuse the parser.\n**\n** The sqlite3_keyword_count() interface returns the number of distinct\n** keywords understood by SQLite.\n**\n** The sqlite3_keyword_name(N,Z,L) interface finds the N-th keyword and\n** makes *Z point to that keyword expressed as UTF8 and writes the number\n** of bytes in the keyword into *L.  The string that *Z points to is not\n** zero-terminated.  The sqlite3_keyword_name(N,Z,L) routine returns\n** SQLITE_OK if N is within bounds and SQLITE_ERROR if not. If either Z\n** or L are NULL or invalid pointers then calls to\n** sqlite3_keyword_name(N,Z,L) result in undefined behavior.\n**\n** The sqlite3_keyword_check(Z,L) interface checks to see whether or not\n** the L-byte UTF8 identifier that Z points to is a keyword, returning non-zero\n** if it is and zero if not.\n**\n** The parser used by SQLite is forgiving.  It is often possible to use\n** a keyword as an identifier as long as such use does not result in a\n** parsing ambiguity.  For example, the statement\n** \"CREATE TABLE BEGIN(REPLACE,PRAGMA,END);\" is accepted by SQLite, and\n** creates a new table named \"BEGIN\" with three columns named\n** \"REPLACE\", \"PRAGMA\", and \"END\".  Nevertheless, best practice is to avoid\n** using keywords as identifiers.  Common techniques used to avoid keyword\n** name collisions include:\n** <ul>\n** <li> Put all identifier names inside double-quotes.  This is the official\n**      SQL way to escape identifier names.\n** <li> Put identifier names inside &#91;...&#93;.  This is not standard SQL,\n**      but it is what SQL Server does and so lots of programmers use this\n**      technique.\n** <li> Begin every identifier with the letter \"Z\" as no SQL keywords start\n**      with \"Z\".\n** <li> Include a digit somewhere in every identifier name.\n** </ul>\n**\n** Note that the number of keywords understood by SQLite can depend on\n** compile-time options.  For example, \"VACUUM\" is not a keyword if\n** SQLite is compiled with the [-DSQLITE_OMIT_VACUUM] option.  Also,\n** new keywords may be added to future releases of SQLite.\n*/\nSQLITE_API int sqlite3_keyword_count(void);\nSQLITE_API int sqlite3_keyword_name(int,const char**,int*);\nSQLITE_API int sqlite3_keyword_check(const char*,int);\n\n/*\n** CAPI3REF: Dynamic String Object\n** KEYWORDS: {dynamic string}\n**\n** An instance of the sqlite3_str object contains a dynamically-sized\n** string under construction.\n**\n** The lifecycle of an sqlite3_str object is as follows:\n** <ol>\n** <li> ^The sqlite3_str object is created using [sqlite3_str_new()].\n** <li> ^Text is appended to the sqlite3_str object using various\n** methods, such as [sqlite3_str_appendf()].\n** <li> ^The sqlite3_str object is destroyed and the string it created\n** is returned using the [sqlite3_str_finish()] interface.\n** </ol>\n*/\ntypedef struct sqlite3_str sqlite3_str;\n\n/*\n** CAPI3REF: Create A New Dynamic String Object\n** CONSTRUCTOR: sqlite3_str\n**\n** ^The [sqlite3_str_new(D)] interface allocates and initializes\n** a new [sqlite3_str] object.  To avoid memory leaks, the object returned by\n** [sqlite3_str_new()] must be freed by a subsequent call to \n** [sqlite3_str_finish(X)].\n**\n** ^The [sqlite3_str_new(D)] interface always returns a pointer to a\n** valid [sqlite3_str] object, though in the event of an out-of-memory\n** error the returned object might be a special singleton that will\n** silently reject new text, always return SQLITE_NOMEM from \n** [sqlite3_str_errcode()], always return 0 for \n** [sqlite3_str_length()], and always return NULL from\n** [sqlite3_str_finish(X)].  It is always safe to use the value\n** returned by [sqlite3_str_new(D)] as the sqlite3_str parameter\n** to any of the other [sqlite3_str] methods.\n**\n** The D parameter to [sqlite3_str_new(D)] may be NULL.  If the\n** D parameter in [sqlite3_str_new(D)] is not NULL, then the maximum\n** length of the string contained in the [sqlite3_str] object will be\n** the value set for [sqlite3_limit](D,[SQLITE_LIMIT_LENGTH]) instead\n** of [SQLITE_MAX_LENGTH].\n*/\nSQLITE_API sqlite3_str *sqlite3_str_new(sqlite3*);\n\n/*\n** CAPI3REF: Finalize A Dynamic String\n** DESTRUCTOR: sqlite3_str\n**\n** ^The [sqlite3_str_finish(X)] interface destroys the sqlite3_str object X\n** and returns a pointer to a memory buffer obtained from [sqlite3_malloc64()]\n** that contains the constructed string.  The calling application should\n** pass the returned value to [sqlite3_free()] to avoid a memory leak.\n** ^The [sqlite3_str_finish(X)] interface may return a NULL pointer if any\n** errors were encountered during construction of the string.  ^The\n** [sqlite3_str_finish(X)] interface will also return a NULL pointer if the\n** string in [sqlite3_str] object X is zero bytes long.\n*/\nSQLITE_API char *sqlite3_str_finish(sqlite3_str*);\n\n/*\n** CAPI3REF: Add Content To A Dynamic String\n** METHOD: sqlite3_str\n**\n** These interfaces add content to an sqlite3_str object previously obtained\n** from [sqlite3_str_new()].\n**\n** ^The [sqlite3_str_appendf(X,F,...)] and \n** [sqlite3_str_vappendf(X,F,V)] interfaces uses the [built-in printf]\n** functionality of SQLite to append formatted text onto the end of \n** [sqlite3_str] object X.\n**\n** ^The [sqlite3_str_append(X,S,N)] method appends exactly N bytes from string S\n** onto the end of the [sqlite3_str] object X.  N must be non-negative.\n** S must contain at least N non-zero bytes of content.  To append a\n** zero-terminated string in its entirety, use the [sqlite3_str_appendall()]\n** method instead.\n**\n** ^The [sqlite3_str_appendall(X,S)] method appends the complete content of\n** zero-terminated string S onto the end of [sqlite3_str] object X.\n**\n** ^The [sqlite3_str_appendchar(X,N,C)] method appends N copies of the\n** single-byte character C onto the end of [sqlite3_str] object X.\n** ^This method can be used, for example, to add whitespace indentation.\n**\n** ^The [sqlite3_str_reset(X)] method resets the string under construction\n** inside [sqlite3_str] object X back to zero bytes in length.  \n**\n** These methods do not return a result code.  ^If an error occurs, that fact\n** is recorded in the [sqlite3_str] object and can be recovered by a\n** subsequent call to [sqlite3_str_errcode(X)].\n*/\nSQLITE_API void sqlite3_str_appendf(sqlite3_str*, const char *zFormat, ...);\nSQLITE_API void sqlite3_str_vappendf(sqlite3_str*, const char *zFormat, va_list);\nSQLITE_API void sqlite3_str_append(sqlite3_str*, const char *zIn, int N);\nSQLITE_API void sqlite3_str_appendall(sqlite3_str*, const char *zIn);\nSQLITE_API void sqlite3_str_appendchar(sqlite3_str*, int N, char C);\nSQLITE_API void sqlite3_str_reset(sqlite3_str*);\n\n/*\n** CAPI3REF: Status Of A Dynamic String\n** METHOD: sqlite3_str\n**\n** These interfaces return the current status of an [sqlite3_str] object.\n**\n** ^If any prior errors have occurred while constructing the dynamic string\n** in sqlite3_str X, then the [sqlite3_str_errcode(X)] method will return\n** an appropriate error code.  ^The [sqlite3_str_errcode(X)] method returns\n** [SQLITE_NOMEM] following any out-of-memory error, or\n** [SQLITE_TOOBIG] if the size of the dynamic string exceeds\n** [SQLITE_MAX_LENGTH], or [SQLITE_OK] if there have been no errors.\n**\n** ^The [sqlite3_str_length(X)] method returns the current length, in bytes,\n** of the dynamic string under construction in [sqlite3_str] object X.\n** ^The length returned by [sqlite3_str_length(X)] does not include the\n** zero-termination byte.\n**\n** ^The [sqlite3_str_value(X)] method returns a pointer to the current\n** content of the dynamic string under construction in X.  The value\n** returned by [sqlite3_str_value(X)] is managed by the sqlite3_str object X\n** and might be freed or altered by any subsequent method on the same\n** [sqlite3_str] object.  Applications must not used the pointer returned\n** [sqlite3_str_value(X)] after any subsequent method call on the same\n** object.  ^Applications may change the content of the string returned\n** by [sqlite3_str_value(X)] as long as they do not write into any bytes\n** outside the range of 0 to [sqlite3_str_length(X)] and do not read or\n** write any byte after any subsequent sqlite3_str method call.\n*/\nSQLITE_API int sqlite3_str_errcode(sqlite3_str*);\nSQLITE_API int sqlite3_str_length(sqlite3_str*);\nSQLITE_API char *sqlite3_str_value(sqlite3_str*);\n\n/*\n** CAPI3REF: SQLite Runtime Status\n**\n** ^These interfaces are used to retrieve runtime status information\n** about the performance of SQLite, and optionally to reset various\n** highwater marks.  ^The first argument is an integer code for\n** the specific parameter to measure.  ^(Recognized integer codes\n** are of the form [status parameters | SQLITE_STATUS_...].)^\n** ^The current value of the parameter is returned into *pCurrent.\n** ^The highest recorded value is returned in *pHighwater.  ^If the\n** resetFlag is true, then the highest record value is reset after\n** *pHighwater is written.  ^(Some parameters do not record the highest\n** value.  For those parameters\n** nothing is written into *pHighwater and the resetFlag is ignored.)^\n** ^(Other parameters record only the highwater mark and not the current\n** value.  For these latter parameters nothing is written into *pCurrent.)^\n**\n** ^The sqlite3_status() and sqlite3_status64() routines return\n** SQLITE_OK on success and a non-zero [error code] on failure.\n**\n** If either the current value or the highwater mark is too large to\n** be represented by a 32-bit integer, then the values returned by\n** sqlite3_status() are undefined.\n**\n** See also: [sqlite3_db_status()]\n*/\nSQLITE_API int sqlite3_status(int op, int *pCurrent, int *pHighwater, int resetFlag);\nSQLITE_API int sqlite3_status64(\n  int op,\n  sqlite3_int64 *pCurrent,\n  sqlite3_int64 *pHighwater,\n  int resetFlag\n);\n\n\n/*\n** CAPI3REF: Status Parameters\n** KEYWORDS: {status parameters}\n**\n** These integer constants designate various run-time status parameters\n** that can be returned by [sqlite3_status()].\n**\n** <dl>\n** [[SQLITE_STATUS_MEMORY_USED]] ^(<dt>SQLITE_STATUS_MEMORY_USED</dt>\n** <dd>This parameter is the current amount of memory checked out\n** using [sqlite3_malloc()], either directly or indirectly.  The\n** figure includes calls made to [sqlite3_malloc()] by the application\n** and internal memory usage by the SQLite library.  Auxiliary page-cache\n** memory controlled by [SQLITE_CONFIG_PAGECACHE] is not included in\n** this parameter.  The amount returned is the sum of the allocation\n** sizes as reported by the xSize method in [sqlite3_mem_methods].</dd>)^\n**\n** [[SQLITE_STATUS_MALLOC_SIZE]] ^(<dt>SQLITE_STATUS_MALLOC_SIZE</dt>\n** <dd>This parameter records the largest memory allocation request\n** handed to [sqlite3_malloc()] or [sqlite3_realloc()] (or their\n** internal equivalents).  Only the value returned in the\n** *pHighwater parameter to [sqlite3_status()] is of interest.  \n** The value written into the *pCurrent parameter is undefined.</dd>)^\n**\n** [[SQLITE_STATUS_MALLOC_COUNT]] ^(<dt>SQLITE_STATUS_MALLOC_COUNT</dt>\n** <dd>This parameter records the number of separate memory allocations\n** currently checked out.</dd>)^\n**\n** [[SQLITE_STATUS_PAGECACHE_USED]] ^(<dt>SQLITE_STATUS_PAGECACHE_USED</dt>\n** <dd>This parameter returns the number of pages used out of the\n** [pagecache memory allocator] that was configured using \n** [SQLITE_CONFIG_PAGECACHE].  The\n** value returned is in pages, not in bytes.</dd>)^\n**\n** [[SQLITE_STATUS_PAGECACHE_OVERFLOW]] \n** ^(<dt>SQLITE_STATUS_PAGECACHE_OVERFLOW</dt>\n** <dd>This parameter returns the number of bytes of page cache\n** allocation which could not be satisfied by the [SQLITE_CONFIG_PAGECACHE]\n** buffer and where forced to overflow to [sqlite3_malloc()].  The\n** returned value includes allocations that overflowed because they\n** where too large (they were larger than the \"sz\" parameter to\n** [SQLITE_CONFIG_PAGECACHE]) and allocations that overflowed because\n** no space was left in the page cache.</dd>)^\n**\n** [[SQLITE_STATUS_PAGECACHE_SIZE]] ^(<dt>SQLITE_STATUS_PAGECACHE_SIZE</dt>\n** <dd>This parameter records the largest memory allocation request\n** handed to [pagecache memory allocator].  Only the value returned in the\n** *pHighwater parameter to [sqlite3_status()] is of interest.  \n** The value written into the *pCurrent parameter is undefined.</dd>)^\n**\n** [[SQLITE_STATUS_SCRATCH_USED]] <dt>SQLITE_STATUS_SCRATCH_USED</dt>\n** <dd>No longer used.</dd>\n**\n** [[SQLITE_STATUS_SCRATCH_OVERFLOW]] ^(<dt>SQLITE_STATUS_SCRATCH_OVERFLOW</dt>\n** <dd>No longer used.</dd>\n**\n** [[SQLITE_STATUS_SCRATCH_SIZE]] <dt>SQLITE_STATUS_SCRATCH_SIZE</dt>\n** <dd>No longer used.</dd>\n**\n** [[SQLITE_STATUS_PARSER_STACK]] ^(<dt>SQLITE_STATUS_PARSER_STACK</dt>\n** <dd>The *pHighwater parameter records the deepest parser stack. \n** The *pCurrent value is undefined.  The *pHighwater value is only\n** meaningful if SQLite is compiled with [YYTRACKMAXSTACKDEPTH].</dd>)^\n** </dl>\n**\n** New status parameters may be added from time to time.\n*/\n#define SQLITE_STATUS_MEMORY_USED          0\n#define SQLITE_STATUS_PAGECACHE_USED       1\n#define SQLITE_STATUS_PAGECACHE_OVERFLOW   2\n#define SQLITE_STATUS_SCRATCH_USED         3  /* NOT USED */\n#define SQLITE_STATUS_SCRATCH_OVERFLOW     4  /* NOT USED */\n#define SQLITE_STATUS_MALLOC_SIZE          5\n#define SQLITE_STATUS_PARSER_STACK         6\n#define SQLITE_STATUS_PAGECACHE_SIZE       7\n#define SQLITE_STATUS_SCRATCH_SIZE         8  /* NOT USED */\n#define SQLITE_STATUS_MALLOC_COUNT         9\n\n/*\n** CAPI3REF: Database Connection Status\n** METHOD: sqlite3\n**\n** ^This interface is used to retrieve runtime status information \n** about a single [database connection].  ^The first argument is the\n** database connection object to be interrogated.  ^The second argument\n** is an integer constant, taken from the set of\n** [SQLITE_DBSTATUS options], that\n** determines the parameter to interrogate.  The set of \n** [SQLITE_DBSTATUS options] is likely\n** to grow in future releases of SQLite.\n**\n** ^The current value of the requested parameter is written into *pCur\n** and the highest instantaneous value is written into *pHiwtr.  ^If\n** the resetFlg is true, then the highest instantaneous value is\n** reset back down to the current value.\n**\n** ^The sqlite3_db_status() routine returns SQLITE_OK on success and a\n** non-zero [error code] on failure.\n**\n** See also: [sqlite3_status()] and [sqlite3_stmt_status()].\n*/\nSQLITE_API int sqlite3_db_status(sqlite3*, int op, int *pCur, int *pHiwtr, int resetFlg);\n\n/*\n** CAPI3REF: Status Parameters for database connections\n** KEYWORDS: {SQLITE_DBSTATUS options}\n**\n** These constants are the available integer \"verbs\" that can be passed as\n** the second argument to the [sqlite3_db_status()] interface.\n**\n** New verbs may be added in future releases of SQLite. Existing verbs\n** might be discontinued. Applications should check the return code from\n** [sqlite3_db_status()] to make sure that the call worked.\n** The [sqlite3_db_status()] interface will return a non-zero error code\n** if a discontinued or unsupported verb is invoked.\n**\n** <dl>\n** [[SQLITE_DBSTATUS_LOOKASIDE_USED]] ^(<dt>SQLITE_DBSTATUS_LOOKASIDE_USED</dt>\n** <dd>This parameter returns the number of lookaside memory slots currently\n** checked out.</dd>)^\n**\n** [[SQLITE_DBSTATUS_LOOKASIDE_HIT]] ^(<dt>SQLITE_DBSTATUS_LOOKASIDE_HIT</dt>\n** <dd>This parameter returns the number malloc attempts that were \n** satisfied using lookaside memory. Only the high-water value is meaningful;\n** the current value is always zero.)^\n**\n** [[SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE]]\n** ^(<dt>SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE</dt>\n** <dd>This parameter returns the number malloc attempts that might have\n** been satisfied using lookaside memory but failed due to the amount of\n** memory requested being larger than the lookaside slot size.\n** Only the high-water value is meaningful;\n** the current value is always zero.)^\n**\n** [[SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL]]\n** ^(<dt>SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL</dt>\n** <dd>This parameter returns the number malloc attempts that might have\n** been satisfied using lookaside memory but failed due to all lookaside\n** memory already being in use.\n** Only the high-water value is meaningful;\n** the current value is always zero.)^\n**\n** [[SQLITE_DBSTATUS_CACHE_USED]] ^(<dt>SQLITE_DBSTATUS_CACHE_USED</dt>\n** <dd>This parameter returns the approximate number of bytes of heap\n** memory used by all pager caches associated with the database connection.)^\n** ^The highwater mark associated with SQLITE_DBSTATUS_CACHE_USED is always 0.\n**\n** [[SQLITE_DBSTATUS_CACHE_USED_SHARED]] \n** ^(<dt>SQLITE_DBSTATUS_CACHE_USED_SHARED</dt>\n** <dd>This parameter is similar to DBSTATUS_CACHE_USED, except that if a\n** pager cache is shared between two or more connections the bytes of heap\n** memory used by that pager cache is divided evenly between the attached\n** connections.)^  In other words, if none of the pager caches associated\n** with the database connection are shared, this request returns the same\n** value as DBSTATUS_CACHE_USED. Or, if one or more or the pager caches are\n** shared, the value returned by this call will be smaller than that returned\n** by DBSTATUS_CACHE_USED. ^The highwater mark associated with\n** SQLITE_DBSTATUS_CACHE_USED_SHARED is always 0.\n**\n** [[SQLITE_DBSTATUS_SCHEMA_USED]] ^(<dt>SQLITE_DBSTATUS_SCHEMA_USED</dt>\n** <dd>This parameter returns the approximate number of bytes of heap\n** memory used to store the schema for all databases associated\n** with the connection - main, temp, and any [ATTACH]-ed databases.)^ \n** ^The full amount of memory used by the schemas is reported, even if the\n** schema memory is shared with other database connections due to\n** [shared cache mode] being enabled.\n** ^The highwater mark associated with SQLITE_DBSTATUS_SCHEMA_USED is always 0.\n**\n** [[SQLITE_DBSTATUS_STMT_USED]] ^(<dt>SQLITE_DBSTATUS_STMT_USED</dt>\n** <dd>This parameter returns the approximate number of bytes of heap\n** and lookaside memory used by all prepared statements associated with\n** the database connection.)^\n** ^The highwater mark associated with SQLITE_DBSTATUS_STMT_USED is always 0.\n** </dd>\n**\n** [[SQLITE_DBSTATUS_CACHE_HIT]] ^(<dt>SQLITE_DBSTATUS_CACHE_HIT</dt>\n** <dd>This parameter returns the number of pager cache hits that have\n** occurred.)^ ^The highwater mark associated with SQLITE_DBSTATUS_CACHE_HIT \n** is always 0.\n** </dd>\n**\n** [[SQLITE_DBSTATUS_CACHE_MISS]] ^(<dt>SQLITE_DBSTATUS_CACHE_MISS</dt>\n** <dd>This parameter returns the number of pager cache misses that have\n** occurred.)^ ^The highwater mark associated with SQLITE_DBSTATUS_CACHE_MISS \n** is always 0.\n** </dd>\n**\n** [[SQLITE_DBSTATUS_CACHE_WRITE]] ^(<dt>SQLITE_DBSTATUS_CACHE_WRITE</dt>\n** <dd>This parameter returns the number of dirty cache entries that have\n** been written to disk. Specifically, the number of pages written to the\n** wal file in wal mode databases, or the number of pages written to the\n** database file in rollback mode databases. Any pages written as part of\n** transaction rollback or database recovery operations are not included.\n** If an IO or other error occurs while writing a page to disk, the effect\n** on subsequent SQLITE_DBSTATUS_CACHE_WRITE requests is undefined.)^ ^The\n** highwater mark associated with SQLITE_DBSTATUS_CACHE_WRITE is always 0.\n** </dd>\n**\n** [[SQLITE_DBSTATUS_CACHE_SPILL]] ^(<dt>SQLITE_DBSTATUS_CACHE_SPILL</dt>\n** <dd>This parameter returns the number of dirty cache entries that have\n** been written to disk in the middle of a transaction due to the page\n** cache overflowing. Transactions are more efficient if they are written\n** to disk all at once. When pages spill mid-transaction, that introduces\n** additional overhead. This parameter can be used help identify\n** inefficiencies that can be resolve by increasing the cache size.\n** </dd>\n**\n** [[SQLITE_DBSTATUS_DEFERRED_FKS]] ^(<dt>SQLITE_DBSTATUS_DEFERRED_FKS</dt>\n** <dd>This parameter returns zero for the current value if and only if\n** all foreign key constraints (deferred or immediate) have been\n** resolved.)^  ^The highwater mark is always 0.\n** </dd>\n** </dl>\n*/\n#define SQLITE_DBSTATUS_LOOKASIDE_USED       0\n#define SQLITE_DBSTATUS_CACHE_USED           1\n#define SQLITE_DBSTATUS_SCHEMA_USED          2\n#define SQLITE_DBSTATUS_STMT_USED            3\n#define SQLITE_DBSTATUS_LOOKASIDE_HIT        4\n#define SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE  5\n#define SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL  6\n#define SQLITE_DBSTATUS_CACHE_HIT            7\n#define SQLITE_DBSTATUS_CACHE_MISS           8\n#define SQLITE_DBSTATUS_CACHE_WRITE          9\n#define SQLITE_DBSTATUS_DEFERRED_FKS        10\n#define SQLITE_DBSTATUS_CACHE_USED_SHARED   11\n#define SQLITE_DBSTATUS_CACHE_SPILL         12\n#define SQLITE_DBSTATUS_MAX                 12   /* Largest defined DBSTATUS */\n\n\n/*\n** CAPI3REF: Prepared Statement Status\n** METHOD: sqlite3_stmt\n**\n** ^(Each prepared statement maintains various\n** [SQLITE_STMTSTATUS counters] that measure the number\n** of times it has performed specific operations.)^  These counters can\n** be used to monitor the performance characteristics of the prepared\n** statements.  For example, if the number of table steps greatly exceeds\n** the number of table searches or result rows, that would tend to indicate\n** that the prepared statement is using a full table scan rather than\n** an index.  \n**\n** ^(This interface is used to retrieve and reset counter values from\n** a [prepared statement].  The first argument is the prepared statement\n** object to be interrogated.  The second argument\n** is an integer code for a specific [SQLITE_STMTSTATUS counter]\n** to be interrogated.)^\n** ^The current value of the requested counter is returned.\n** ^If the resetFlg is true, then the counter is reset to zero after this\n** interface call returns.\n**\n** See also: [sqlite3_status()] and [sqlite3_db_status()].\n*/\nSQLITE_API int sqlite3_stmt_status(sqlite3_stmt*, int op,int resetFlg);\n\n/*\n** CAPI3REF: Status Parameters for prepared statements\n** KEYWORDS: {SQLITE_STMTSTATUS counter} {SQLITE_STMTSTATUS counters}\n**\n** These preprocessor macros define integer codes that name counter\n** values associated with the [sqlite3_stmt_status()] interface.\n** The meanings of the various counters are as follows:\n**\n** <dl>\n** [[SQLITE_STMTSTATUS_FULLSCAN_STEP]] <dt>SQLITE_STMTSTATUS_FULLSCAN_STEP</dt>\n** <dd>^This is the number of times that SQLite has stepped forward in\n** a table as part of a full table scan.  Large numbers for this counter\n** may indicate opportunities for performance improvement through \n** careful use of indices.</dd>\n**\n** [[SQLITE_STMTSTATUS_SORT]] <dt>SQLITE_STMTSTATUS_SORT</dt>\n** <dd>^This is the number of sort operations that have occurred.\n** A non-zero value in this counter may indicate an opportunity to\n** improvement performance through careful use of indices.</dd>\n**\n** [[SQLITE_STMTSTATUS_AUTOINDEX]] <dt>SQLITE_STMTSTATUS_AUTOINDEX</dt>\n** <dd>^This is the number of rows inserted into transient indices that\n** were created automatically in order to help joins run faster.\n** A non-zero value in this counter may indicate an opportunity to\n** improvement performance by adding permanent indices that do not\n** need to be reinitialized each time the statement is run.</dd>\n**\n** [[SQLITE_STMTSTATUS_VM_STEP]] <dt>SQLITE_STMTSTATUS_VM_STEP</dt>\n** <dd>^This is the number of virtual machine operations executed\n** by the prepared statement if that number is less than or equal\n** to 2147483647.  The number of virtual machine operations can be \n** used as a proxy for the total work done by the prepared statement.\n** If the number of virtual machine operations exceeds 2147483647\n** then the value returned by this statement status code is undefined.\n**\n** [[SQLITE_STMTSTATUS_REPREPARE]] <dt>SQLITE_STMTSTATUS_REPREPARE</dt>\n** <dd>^This is the number of times that the prepare statement has been\n** automatically regenerated due to schema changes or change to \n** [bound parameters] that might affect the query plan.\n**\n** [[SQLITE_STMTSTATUS_RUN]] <dt>SQLITE_STMTSTATUS_RUN</dt>\n** <dd>^This is the number of times that the prepared statement has\n** been run.  A single \"run\" for the purposes of this counter is one\n** or more calls to [sqlite3_step()] followed by a call to [sqlite3_reset()].\n** The counter is incremented on the first [sqlite3_step()] call of each\n** cycle.\n**\n** [[SQLITE_STMTSTATUS_MEMUSED]] <dt>SQLITE_STMTSTATUS_MEMUSED</dt>\n** <dd>^This is the approximate number of bytes of heap memory\n** used to store the prepared statement.  ^This value is not actually\n** a counter, and so the resetFlg parameter to sqlite3_stmt_status()\n** is ignored when the opcode is SQLITE_STMTSTATUS_MEMUSED.\n** </dd>\n** </dl>\n*/\n#define SQLITE_STMTSTATUS_FULLSCAN_STEP     1\n#define SQLITE_STMTSTATUS_SORT              2\n#define SQLITE_STMTSTATUS_AUTOINDEX         3\n#define SQLITE_STMTSTATUS_VM_STEP           4\n#define SQLITE_STMTSTATUS_REPREPARE         5\n#define SQLITE_STMTSTATUS_RUN               6\n#define SQLITE_STMTSTATUS_MEMUSED           99\n\n/*\n** CAPI3REF: Custom Page Cache Object\n**\n** The sqlite3_pcache type is opaque.  It is implemented by\n** the pluggable module.  The SQLite core has no knowledge of\n** its size or internal structure and never deals with the\n** sqlite3_pcache object except by holding and passing pointers\n** to the object.\n**\n** See [sqlite3_pcache_methods2] for additional information.\n*/\ntypedef struct sqlite3_pcache sqlite3_pcache;\n\n/*\n** CAPI3REF: Custom Page Cache Object\n**\n** The sqlite3_pcache_page object represents a single page in the\n** page cache.  The page cache will allocate instances of this\n** object.  Various methods of the page cache use pointers to instances\n** of this object as parameters or as their return value.\n**\n** See [sqlite3_pcache_methods2] for additional information.\n*/\ntypedef struct sqlite3_pcache_page sqlite3_pcache_page;\nstruct sqlite3_pcache_page {\n  void *pBuf;        /* The content of the page */\n  void *pExtra;      /* Extra information associated with the page */\n};\n\n/*\n** CAPI3REF: Application Defined Page Cache.\n** KEYWORDS: {page cache}\n**\n** ^(The [sqlite3_config]([SQLITE_CONFIG_PCACHE2], ...) interface can\n** register an alternative page cache implementation by passing in an \n** instance of the sqlite3_pcache_methods2 structure.)^\n** In many applications, most of the heap memory allocated by \n** SQLite is used for the page cache.\n** By implementing a \n** custom page cache using this API, an application can better control\n** the amount of memory consumed by SQLite, the way in which \n** that memory is allocated and released, and the policies used to \n** determine exactly which parts of a database file are cached and for \n** how long.\n**\n** The alternative page cache mechanism is an\n** extreme measure that is only needed by the most demanding applications.\n** The built-in page cache is recommended for most uses.\n**\n** ^(The contents of the sqlite3_pcache_methods2 structure are copied to an\n** internal buffer by SQLite within the call to [sqlite3_config].  Hence\n** the application may discard the parameter after the call to\n** [sqlite3_config()] returns.)^\n**\n** [[the xInit() page cache method]]\n** ^(The xInit() method is called once for each effective \n** call to [sqlite3_initialize()])^\n** (usually only once during the lifetime of the process). ^(The xInit()\n** method is passed a copy of the sqlite3_pcache_methods2.pArg value.)^\n** The intent of the xInit() method is to set up global data structures \n** required by the custom page cache implementation. \n** ^(If the xInit() method is NULL, then the \n** built-in default page cache is used instead of the application defined\n** page cache.)^\n**\n** [[the xShutdown() page cache method]]\n** ^The xShutdown() method is called by [sqlite3_shutdown()].\n** It can be used to clean up \n** any outstanding resources before process shutdown, if required.\n** ^The xShutdown() method may be NULL.\n**\n** ^SQLite automatically serializes calls to the xInit method,\n** so the xInit method need not be threadsafe.  ^The\n** xShutdown method is only called from [sqlite3_shutdown()] so it does\n** not need to be threadsafe either.  All other methods must be threadsafe\n** in multithreaded applications.\n**\n** ^SQLite will never invoke xInit() more than once without an intervening\n** call to xShutdown().\n**\n** [[the xCreate() page cache methods]]\n** ^SQLite invokes the xCreate() method to construct a new cache instance.\n** SQLite will typically create one cache instance for each open database file,\n** though this is not guaranteed. ^The\n** first parameter, szPage, is the size in bytes of the pages that must\n** be allocated by the cache.  ^szPage will always a power of two.  ^The\n** second parameter szExtra is a number of bytes of extra storage \n** associated with each page cache entry.  ^The szExtra parameter will\n** a number less than 250.  SQLite will use the\n** extra szExtra bytes on each page to store metadata about the underlying\n** database page on disk.  The value passed into szExtra depends\n** on the SQLite version, the target platform, and how SQLite was compiled.\n** ^The third argument to xCreate(), bPurgeable, is true if the cache being\n** created will be used to cache database pages of a file stored on disk, or\n** false if it is used for an in-memory database. The cache implementation\n** does not have to do anything special based with the value of bPurgeable;\n** it is purely advisory.  ^On a cache where bPurgeable is false, SQLite will\n** never invoke xUnpin() except to deliberately delete a page.\n** ^In other words, calls to xUnpin() on a cache with bPurgeable set to\n** false will always have the \"discard\" flag set to true.  \n** ^Hence, a cache created with bPurgeable false will\n** never contain any unpinned pages.\n**\n** [[the xCachesize() page cache method]]\n** ^(The xCachesize() method may be called at any time by SQLite to set the\n** suggested maximum cache-size (number of pages stored by) the cache\n** instance passed as the first argument. This is the value configured using\n** the SQLite \"[PRAGMA cache_size]\" command.)^  As with the bPurgeable\n** parameter, the implementation is not required to do anything with this\n** value; it is advisory only.\n**\n** [[the xPagecount() page cache methods]]\n** The xPagecount() method must return the number of pages currently\n** stored in the cache, both pinned and unpinned.\n** \n** [[the xFetch() page cache methods]]\n** The xFetch() method locates a page in the cache and returns a pointer to \n** an sqlite3_pcache_page object associated with that page, or a NULL pointer.\n** The pBuf element of the returned sqlite3_pcache_page object will be a\n** pointer to a buffer of szPage bytes used to store the content of a \n** single database page.  The pExtra element of sqlite3_pcache_page will be\n** a pointer to the szExtra bytes of extra storage that SQLite has requested\n** for each entry in the page cache.\n**\n** The page to be fetched is determined by the key. ^The minimum key value\n** is 1.  After it has been retrieved using xFetch, the page is considered\n** to be \"pinned\".\n**\n** If the requested page is already in the page cache, then the page cache\n** implementation must return a pointer to the page buffer with its content\n** intact.  If the requested page is not already in the cache, then the\n** cache implementation should use the value of the createFlag\n** parameter to help it determined what action to take:\n**\n** <table border=1 width=85% align=center>\n** <tr><th> createFlag <th> Behavior when page is not already in cache\n** <tr><td> 0 <td> Do not allocate a new page.  Return NULL.\n** <tr><td> 1 <td> Allocate a new page if it easy and convenient to do so.\n**                 Otherwise return NULL.\n** <tr><td> 2 <td> Make every effort to allocate a new page.  Only return\n**                 NULL if allocating a new page is effectively impossible.\n** </table>\n**\n** ^(SQLite will normally invoke xFetch() with a createFlag of 0 or 1.  SQLite\n** will only use a createFlag of 2 after a prior call with a createFlag of 1\n** failed.)^  In between the to xFetch() calls, SQLite may\n** attempt to unpin one or more cache pages by spilling the content of\n** pinned pages to disk and synching the operating system disk cache.\n**\n** [[the xUnpin() page cache method]]\n** ^xUnpin() is called by SQLite with a pointer to a currently pinned page\n** as its second argument.  If the third parameter, discard, is non-zero,\n** then the page must be evicted from the cache.\n** ^If the discard parameter is\n** zero, then the page may be discarded or retained at the discretion of\n** page cache implementation. ^The page cache implementation\n** may choose to evict unpinned pages at any time.\n**\n** The cache must not perform any reference counting. A single \n** call to xUnpin() unpins the page regardless of the number of prior calls \n** to xFetch().\n**\n** [[the xRekey() page cache methods]]\n** The xRekey() method is used to change the key value associated with the\n** page passed as the second argument. If the cache\n** previously contains an entry associated with newKey, it must be\n** discarded. ^Any prior cache entry associated with newKey is guaranteed not\n** to be pinned.\n**\n** When SQLite calls the xTruncate() method, the cache must discard all\n** existing cache entries with page numbers (keys) greater than or equal\n** to the value of the iLimit parameter passed to xTruncate(). If any\n** of these pages are pinned, they are implicitly unpinned, meaning that\n** they can be safely discarded.\n**\n** [[the xDestroy() page cache method]]\n** ^The xDestroy() method is used to delete a cache allocated by xCreate().\n** All resources associated with the specified cache should be freed. ^After\n** calling the xDestroy() method, SQLite considers the [sqlite3_pcache*]\n** handle invalid, and will not use it with any other sqlite3_pcache_methods2\n** functions.\n**\n** [[the xShrink() page cache method]]\n** ^SQLite invokes the xShrink() method when it wants the page cache to\n** free up as much of heap memory as possible.  The page cache implementation\n** is not obligated to free any memory, but well-behaved implementations should\n** do their best.\n*/\ntypedef struct sqlite3_pcache_methods2 sqlite3_pcache_methods2;\nstruct sqlite3_pcache_methods2 {\n  int iVersion;\n  void *pArg;\n  int (*xInit)(void*);\n  void (*xShutdown)(void*);\n  sqlite3_pcache *(*xCreate)(int szPage, int szExtra, int bPurgeable);\n  void (*xCachesize)(sqlite3_pcache*, int nCachesize);\n  int (*xPagecount)(sqlite3_pcache*);\n  sqlite3_pcache_page *(*xFetch)(sqlite3_pcache*, unsigned key, int createFlag);\n  void (*xUnpin)(sqlite3_pcache*, sqlite3_pcache_page*, int discard);\n  void (*xRekey)(sqlite3_pcache*, sqlite3_pcache_page*, \n      unsigned oldKey, unsigned newKey);\n  void (*xTruncate)(sqlite3_pcache*, unsigned iLimit);\n  void (*xDestroy)(sqlite3_pcache*);\n  void (*xShrink)(sqlite3_pcache*);\n};\n\n/*\n** This is the obsolete pcache_methods object that has now been replaced\n** by sqlite3_pcache_methods2.  This object is not used by SQLite.  It is\n** retained in the header file for backwards compatibility only.\n*/\ntypedef struct sqlite3_pcache_methods sqlite3_pcache_methods;\nstruct sqlite3_pcache_methods {\n  void *pArg;\n  int (*xInit)(void*);\n  void (*xShutdown)(void*);\n  sqlite3_pcache *(*xCreate)(int szPage, int bPurgeable);\n  void (*xCachesize)(sqlite3_pcache*, int nCachesize);\n  int (*xPagecount)(sqlite3_pcache*);\n  void *(*xFetch)(sqlite3_pcache*, unsigned key, int createFlag);\n  void (*xUnpin)(sqlite3_pcache*, void*, int discard);\n  void (*xRekey)(sqlite3_pcache*, void*, unsigned oldKey, unsigned newKey);\n  void (*xTruncate)(sqlite3_pcache*, unsigned iLimit);\n  void (*xDestroy)(sqlite3_pcache*);\n};\n\n\n/*\n** CAPI3REF: Online Backup Object\n**\n** The sqlite3_backup object records state information about an ongoing\n** online backup operation.  ^The sqlite3_backup object is created by\n** a call to [sqlite3_backup_init()] and is destroyed by a call to\n** [sqlite3_backup_finish()].\n**\n** See Also: [Using the SQLite Online Backup API]\n*/\ntypedef struct sqlite3_backup sqlite3_backup;\n\n/*\n** CAPI3REF: Online Backup API.\n**\n** The backup API copies the content of one database into another.\n** It is useful either for creating backups of databases or\n** for copying in-memory databases to or from persistent files. \n**\n** See Also: [Using the SQLite Online Backup API]\n**\n** ^SQLite holds a write transaction open on the destination database file\n** for the duration of the backup operation.\n** ^The source database is read-locked only while it is being read;\n** it is not locked continuously for the entire backup operation.\n** ^Thus, the backup may be performed on a live source database without\n** preventing other database connections from\n** reading or writing to the source database while the backup is underway.\n** \n** ^(To perform a backup operation: \n**   <ol>\n**     <li><b>sqlite3_backup_init()</b> is called once to initialize the\n**         backup, \n**     <li><b>sqlite3_backup_step()</b> is called one or more times to transfer \n**         the data between the two databases, and finally\n**     <li><b>sqlite3_backup_finish()</b> is called to release all resources \n**         associated with the backup operation. \n**   </ol>)^\n** There should be exactly one call to sqlite3_backup_finish() for each\n** successful call to sqlite3_backup_init().\n**\n** [[sqlite3_backup_init()]] <b>sqlite3_backup_init()</b>\n**\n** ^The D and N arguments to sqlite3_backup_init(D,N,S,M) are the \n** [database connection] associated with the destination database \n** and the database name, respectively.\n** ^The database name is \"main\" for the main database, \"temp\" for the\n** temporary database, or the name specified after the AS keyword in\n** an [ATTACH] statement for an attached database.\n** ^The S and M arguments passed to \n** sqlite3_backup_init(D,N,S,M) identify the [database connection]\n** and database name of the source database, respectively.\n** ^The source and destination [database connections] (parameters S and D)\n** must be different or else sqlite3_backup_init(D,N,S,M) will fail with\n** an error.\n**\n** ^A call to sqlite3_backup_init() will fail, returning NULL, if \n** there is already a read or read-write transaction open on the \n** destination database.\n**\n** ^If an error occurs within sqlite3_backup_init(D,N,S,M), then NULL is\n** returned and an error code and error message are stored in the\n** destination [database connection] D.\n** ^The error code and message for the failed call to sqlite3_backup_init()\n** can be retrieved using the [sqlite3_errcode()], [sqlite3_errmsg()], and/or\n** [sqlite3_errmsg16()] functions.\n** ^A successful call to sqlite3_backup_init() returns a pointer to an\n** [sqlite3_backup] object.\n** ^The [sqlite3_backup] object may be used with the sqlite3_backup_step() and\n** sqlite3_backup_finish() functions to perform the specified backup \n** operation.\n**\n** [[sqlite3_backup_step()]] <b>sqlite3_backup_step()</b>\n**\n** ^Function sqlite3_backup_step(B,N) will copy up to N pages between \n** the source and destination databases specified by [sqlite3_backup] object B.\n** ^If N is negative, all remaining source pages are copied. \n** ^If sqlite3_backup_step(B,N) successfully copies N pages and there\n** are still more pages to be copied, then the function returns [SQLITE_OK].\n** ^If sqlite3_backup_step(B,N) successfully finishes copying all pages\n** from source to destination, then it returns [SQLITE_DONE].\n** ^If an error occurs while running sqlite3_backup_step(B,N),\n** then an [error code] is returned. ^As well as [SQLITE_OK] and\n** [SQLITE_DONE], a call to sqlite3_backup_step() may return [SQLITE_READONLY],\n** [SQLITE_NOMEM], [SQLITE_BUSY], [SQLITE_LOCKED], or an\n** [SQLITE_IOERR_ACCESS | SQLITE_IOERR_XXX] extended error code.\n**\n** ^(The sqlite3_backup_step() might return [SQLITE_READONLY] if\n** <ol>\n** <li> the destination database was opened read-only, or\n** <li> the destination database is using write-ahead-log journaling\n** and the destination and source page sizes differ, or\n** <li> the destination database is an in-memory database and the\n** destination and source page sizes differ.\n** </ol>)^\n**\n** ^If sqlite3_backup_step() cannot obtain a required file-system lock, then\n** the [sqlite3_busy_handler | busy-handler function]\n** is invoked (if one is specified). ^If the \n** busy-handler returns non-zero before the lock is available, then \n** [SQLITE_BUSY] is returned to the caller. ^In this case the call to\n** sqlite3_backup_step() can be retried later. ^If the source\n** [database connection]\n** is being used to write to the source database when sqlite3_backup_step()\n** is called, then [SQLITE_LOCKED] is returned immediately. ^Again, in this\n** case the call to sqlite3_backup_step() can be retried later on. ^(If\n** [SQLITE_IOERR_ACCESS | SQLITE_IOERR_XXX], [SQLITE_NOMEM], or\n** [SQLITE_READONLY] is returned, then \n** there is no point in retrying the call to sqlite3_backup_step(). These \n** errors are considered fatal.)^  The application must accept \n** that the backup operation has failed and pass the backup operation handle \n** to the sqlite3_backup_finish() to release associated resources.\n**\n** ^The first call to sqlite3_backup_step() obtains an exclusive lock\n** on the destination file. ^The exclusive lock is not released until either \n** sqlite3_backup_finish() is called or the backup operation is complete \n** and sqlite3_backup_step() returns [SQLITE_DONE].  ^Every call to\n** sqlite3_backup_step() obtains a [shared lock] on the source database that\n** lasts for the duration of the sqlite3_backup_step() call.\n** ^Because the source database is not locked between calls to\n** sqlite3_backup_step(), the source database may be modified mid-way\n** through the backup process.  ^If the source database is modified by an\n** external process or via a database connection other than the one being\n** used by the backup operation, then the backup will be automatically\n** restarted by the next call to sqlite3_backup_step(). ^If the source \n** database is modified by the using the same database connection as is used\n** by the backup operation, then the backup database is automatically\n** updated at the same time.\n**\n** [[sqlite3_backup_finish()]] <b>sqlite3_backup_finish()</b>\n**\n** When sqlite3_backup_step() has returned [SQLITE_DONE], or when the \n** application wishes to abandon the backup operation, the application\n** should destroy the [sqlite3_backup] by passing it to sqlite3_backup_finish().\n** ^The sqlite3_backup_finish() interfaces releases all\n** resources associated with the [sqlite3_backup] object. \n** ^If sqlite3_backup_step() has not yet returned [SQLITE_DONE], then any\n** active write-transaction on the destination database is rolled back.\n** The [sqlite3_backup] object is invalid\n** and may not be used following a call to sqlite3_backup_finish().\n**\n** ^The value returned by sqlite3_backup_finish is [SQLITE_OK] if no\n** sqlite3_backup_step() errors occurred, regardless or whether or not\n** sqlite3_backup_step() completed.\n** ^If an out-of-memory condition or IO error occurred during any prior\n** sqlite3_backup_step() call on the same [sqlite3_backup] object, then\n** sqlite3_backup_finish() returns the corresponding [error code].\n**\n** ^A return of [SQLITE_BUSY] or [SQLITE_LOCKED] from sqlite3_backup_step()\n** is not a permanent error and does not affect the return value of\n** sqlite3_backup_finish().\n**\n** [[sqlite3_backup_remaining()]] [[sqlite3_backup_pagecount()]]\n** <b>sqlite3_backup_remaining() and sqlite3_backup_pagecount()</b>\n**\n** ^The sqlite3_backup_remaining() routine returns the number of pages still\n** to be backed up at the conclusion of the most recent sqlite3_backup_step().\n** ^The sqlite3_backup_pagecount() routine returns the total number of pages\n** in the source database at the conclusion of the most recent\n** sqlite3_backup_step().\n** ^(The values returned by these functions are only updated by\n** sqlite3_backup_step(). If the source database is modified in a way that\n** changes the size of the source database or the number of pages remaining,\n** those changes are not reflected in the output of sqlite3_backup_pagecount()\n** and sqlite3_backup_remaining() until after the next\n** sqlite3_backup_step().)^\n**\n** <b>Concurrent Usage of Database Handles</b>\n**\n** ^The source [database connection] may be used by the application for other\n** purposes while a backup operation is underway or being initialized.\n** ^If SQLite is compiled and configured to support threadsafe database\n** connections, then the source database connection may be used concurrently\n** from within other threads.\n**\n** However, the application must guarantee that the destination \n** [database connection] is not passed to any other API (by any thread) after \n** sqlite3_backup_init() is called and before the corresponding call to\n** sqlite3_backup_finish().  SQLite does not currently check to see\n** if the application incorrectly accesses the destination [database connection]\n** and so no error code is reported, but the operations may malfunction\n** nevertheless.  Use of the destination database connection while a\n** backup is in progress might also also cause a mutex deadlock.\n**\n** If running in [shared cache mode], the application must\n** guarantee that the shared cache used by the destination database\n** is not accessed while the backup is running. In practice this means\n** that the application must guarantee that the disk file being \n** backed up to is not accessed by any connection within the process,\n** not just the specific connection that was passed to sqlite3_backup_init().\n**\n** The [sqlite3_backup] object itself is partially threadsafe. Multiple \n** threads may safely make multiple concurrent calls to sqlite3_backup_step().\n** However, the sqlite3_backup_remaining() and sqlite3_backup_pagecount()\n** APIs are not strictly speaking threadsafe. If they are invoked at the\n** same time as another thread is invoking sqlite3_backup_step() it is\n** possible that they return invalid values.\n*/\nSQLITE_API sqlite3_backup *sqlite3_backup_init(\n  sqlite3 *pDest,                        /* Destination database handle */\n  const char *zDestName,                 /* Destination database name */\n  sqlite3 *pSource,                      /* Source database handle */\n  const char *zSourceName                /* Source database name */\n);\nSQLITE_API int sqlite3_backup_step(sqlite3_backup *p, int nPage);\nSQLITE_API int sqlite3_backup_finish(sqlite3_backup *p);\nSQLITE_API int sqlite3_backup_remaining(sqlite3_backup *p);\nSQLITE_API int sqlite3_backup_pagecount(sqlite3_backup *p);\n\n/*\n** CAPI3REF: Unlock Notification\n** METHOD: sqlite3\n**\n** ^When running in shared-cache mode, a database operation may fail with\n** an [SQLITE_LOCKED] error if the required locks on the shared-cache or\n** individual tables within the shared-cache cannot be obtained. See\n** [SQLite Shared-Cache Mode] for a description of shared-cache locking. \n** ^This API may be used to register a callback that SQLite will invoke \n** when the connection currently holding the required lock relinquishes it.\n** ^This API is only available if the library was compiled with the\n** [SQLITE_ENABLE_UNLOCK_NOTIFY] C-preprocessor symbol defined.\n**\n** See Also: [Using the SQLite Unlock Notification Feature].\n**\n** ^Shared-cache locks are released when a database connection concludes\n** its current transaction, either by committing it or rolling it back. \n**\n** ^When a connection (known as the blocked connection) fails to obtain a\n** shared-cache lock and SQLITE_LOCKED is returned to the caller, the\n** identity of the database connection (the blocking connection) that\n** has locked the required resource is stored internally. ^After an \n** application receives an SQLITE_LOCKED error, it may call the\n** sqlite3_unlock_notify() method with the blocked connection handle as \n** the first argument to register for a callback that will be invoked\n** when the blocking connections current transaction is concluded. ^The\n** callback is invoked from within the [sqlite3_step] or [sqlite3_close]\n** call that concludes the blocking connections transaction.\n**\n** ^(If sqlite3_unlock_notify() is called in a multi-threaded application,\n** there is a chance that the blocking connection will have already\n** concluded its transaction by the time sqlite3_unlock_notify() is invoked.\n** If this happens, then the specified callback is invoked immediately,\n** from within the call to sqlite3_unlock_notify().)^\n**\n** ^If the blocked connection is attempting to obtain a write-lock on a\n** shared-cache table, and more than one other connection currently holds\n** a read-lock on the same table, then SQLite arbitrarily selects one of \n** the other connections to use as the blocking connection.\n**\n** ^(There may be at most one unlock-notify callback registered by a \n** blocked connection. If sqlite3_unlock_notify() is called when the\n** blocked connection already has a registered unlock-notify callback,\n** then the new callback replaces the old.)^ ^If sqlite3_unlock_notify() is\n** called with a NULL pointer as its second argument, then any existing\n** unlock-notify callback is canceled. ^The blocked connections \n** unlock-notify callback may also be canceled by closing the blocked\n** connection using [sqlite3_close()].\n**\n** The unlock-notify callback is not reentrant. If an application invokes\n** any sqlite3_xxx API functions from within an unlock-notify callback, a\n** crash or deadlock may be the result.\n**\n** ^Unless deadlock is detected (see below), sqlite3_unlock_notify() always\n** returns SQLITE_OK.\n**\n** <b>Callback Invocation Details</b>\n**\n** When an unlock-notify callback is registered, the application provides a \n** single void* pointer that is passed to the callback when it is invoked.\n** However, the signature of the callback function allows SQLite to pass\n** it an array of void* context pointers. The first argument passed to\n** an unlock-notify callback is a pointer to an array of void* pointers,\n** and the second is the number of entries in the array.\n**\n** When a blocking connections transaction is concluded, there may be\n** more than one blocked connection that has registered for an unlock-notify\n** callback. ^If two or more such blocked connections have specified the\n** same callback function, then instead of invoking the callback function\n** multiple times, it is invoked once with the set of void* context pointers\n** specified by the blocked connections bundled together into an array.\n** This gives the application an opportunity to prioritize any actions \n** related to the set of unblocked database connections.\n**\n** <b>Deadlock Detection</b>\n**\n** Assuming that after registering for an unlock-notify callback a \n** database waits for the callback to be issued before taking any further\n** action (a reasonable assumption), then using this API may cause the\n** application to deadlock. For example, if connection X is waiting for\n** connection Y's transaction to be concluded, and similarly connection\n** Y is waiting on connection X's transaction, then neither connection\n** will proceed and the system may remain deadlocked indefinitely.\n**\n** To avoid this scenario, the sqlite3_unlock_notify() performs deadlock\n** detection. ^If a given call to sqlite3_unlock_notify() would put the\n** system in a deadlocked state, then SQLITE_LOCKED is returned and no\n** unlock-notify callback is registered. The system is said to be in\n** a deadlocked state if connection A has registered for an unlock-notify\n** callback on the conclusion of connection B's transaction, and connection\n** B has itself registered for an unlock-notify callback when connection\n** A's transaction is concluded. ^Indirect deadlock is also detected, so\n** the system is also considered to be deadlocked if connection B has\n** registered for an unlock-notify callback on the conclusion of connection\n** C's transaction, where connection C is waiting on connection A. ^Any\n** number of levels of indirection are allowed.\n**\n** <b>The \"DROP TABLE\" Exception</b>\n**\n** When a call to [sqlite3_step()] returns SQLITE_LOCKED, it is almost \n** always appropriate to call sqlite3_unlock_notify(). There is however,\n** one exception. When executing a \"DROP TABLE\" or \"DROP INDEX\" statement,\n** SQLite checks if there are any currently executing SELECT statements\n** that belong to the same connection. If there are, SQLITE_LOCKED is\n** returned. In this case there is no \"blocking connection\", so invoking\n** sqlite3_unlock_notify() results in the unlock-notify callback being\n** invoked immediately. If the application then re-attempts the \"DROP TABLE\"\n** or \"DROP INDEX\" query, an infinite loop might be the result.\n**\n** One way around this problem is to check the extended error code returned\n** by an sqlite3_step() call. ^(If there is a blocking connection, then the\n** extended error code is set to SQLITE_LOCKED_SHAREDCACHE. Otherwise, in\n** the special \"DROP TABLE/INDEX\" case, the extended error code is just \n** SQLITE_LOCKED.)^\n*/\nSQLITE_API int sqlite3_unlock_notify(\n  sqlite3 *pBlocked,                          /* Waiting connection */\n  void (*xNotify)(void **apArg, int nArg),    /* Callback function to invoke */\n  void *pNotifyArg                            /* Argument to pass to xNotify */\n);\n\n\n/*\n** CAPI3REF: String Comparison\n**\n** ^The [sqlite3_stricmp()] and [sqlite3_strnicmp()] APIs allow applications\n** and extensions to compare the contents of two buffers containing UTF-8\n** strings in a case-independent fashion, using the same definition of \"case\n** independence\" that SQLite uses internally when comparing identifiers.\n*/\nSQLITE_API int sqlite3_stricmp(const char *, const char *);\nSQLITE_API int sqlite3_strnicmp(const char *, const char *, int);\n\n/*\n** CAPI3REF: String Globbing\n*\n** ^The [sqlite3_strglob(P,X)] interface returns zero if and only if\n** string X matches the [GLOB] pattern P.\n** ^The definition of [GLOB] pattern matching used in\n** [sqlite3_strglob(P,X)] is the same as for the \"X GLOB P\" operator in the\n** SQL dialect understood by SQLite.  ^The [sqlite3_strglob(P,X)] function\n** is case sensitive.\n**\n** Note that this routine returns zero on a match and non-zero if the strings\n** do not match, the same as [sqlite3_stricmp()] and [sqlite3_strnicmp()].\n**\n** See also: [sqlite3_strlike()].\n*/\nSQLITE_API int sqlite3_strglob(const char *zGlob, const char *zStr);\n\n/*\n** CAPI3REF: String LIKE Matching\n*\n** ^The [sqlite3_strlike(P,X,E)] interface returns zero if and only if\n** string X matches the [LIKE] pattern P with escape character E.\n** ^The definition of [LIKE] pattern matching used in\n** [sqlite3_strlike(P,X,E)] is the same as for the \"X LIKE P ESCAPE E\"\n** operator in the SQL dialect understood by SQLite.  ^For \"X LIKE P\" without\n** the ESCAPE clause, set the E parameter of [sqlite3_strlike(P,X,E)] to 0.\n** ^As with the LIKE operator, the [sqlite3_strlike(P,X,E)] function is case\n** insensitive - equivalent upper and lower case ASCII characters match\n** one another.\n**\n** ^The [sqlite3_strlike(P,X,E)] function matches Unicode characters, though\n** only ASCII characters are case folded.\n**\n** Note that this routine returns zero on a match and non-zero if the strings\n** do not match, the same as [sqlite3_stricmp()] and [sqlite3_strnicmp()].\n**\n** See also: [sqlite3_strglob()].\n*/\nSQLITE_API int sqlite3_strlike(const char *zGlob, const char *zStr, unsigned int cEsc);\n\n/*\n** CAPI3REF: Error Logging Interface\n**\n** ^The [sqlite3_log()] interface writes a message into the [error log]\n** established by the [SQLITE_CONFIG_LOG] option to [sqlite3_config()].\n** ^If logging is enabled, the zFormat string and subsequent arguments are\n** used with [sqlite3_snprintf()] to generate the final output string.\n**\n** The sqlite3_log() interface is intended for use by extensions such as\n** virtual tables, collating functions, and SQL functions.  While there is\n** nothing to prevent an application from calling sqlite3_log(), doing so\n** is considered bad form.\n**\n** The zFormat string must not be NULL.\n**\n** To avoid deadlocks and other threading problems, the sqlite3_log() routine\n** will not use dynamically allocated memory.  The log message is stored in\n** a fixed-length buffer on the stack.  If the log message is longer than\n** a few hundred characters, it will be truncated to the length of the\n** buffer.\n*/\nSQLITE_API void sqlite3_log(int iErrCode, const char *zFormat, ...);\n\n/*\n** CAPI3REF: Write-Ahead Log Commit Hook\n** METHOD: sqlite3\n**\n** ^The [sqlite3_wal_hook()] function is used to register a callback that\n** is invoked each time data is committed to a database in wal mode.\n**\n** ^(The callback is invoked by SQLite after the commit has taken place and \n** the associated write-lock on the database released)^, so the implementation \n** may read, write or [checkpoint] the database as required.\n**\n** ^The first parameter passed to the callback function when it is invoked\n** is a copy of the third parameter passed to sqlite3_wal_hook() when\n** registering the callback. ^The second is a copy of the database handle.\n** ^The third parameter is the name of the database that was written to -\n** either \"main\" or the name of an [ATTACH]-ed database. ^The fourth parameter\n** is the number of pages currently in the write-ahead log file,\n** including those that were just committed.\n**\n** The callback function should normally return [SQLITE_OK].  ^If an error\n** code is returned, that error will propagate back up through the\n** SQLite code base to cause the statement that provoked the callback\n** to report an error, though the commit will have still occurred. If the\n** callback returns [SQLITE_ROW] or [SQLITE_DONE], or if it returns a value\n** that does not correspond to any valid SQLite error code, the results\n** are undefined.\n**\n** A single database handle may have at most a single write-ahead log callback \n** registered at one time. ^Calling [sqlite3_wal_hook()] replaces any\n** previously registered write-ahead log callback. ^Note that the\n** [sqlite3_wal_autocheckpoint()] interface and the\n** [wal_autocheckpoint pragma] both invoke [sqlite3_wal_hook()] and will\n** overwrite any prior [sqlite3_wal_hook()] settings.\n*/\nSQLITE_API void *sqlite3_wal_hook(\n  sqlite3*, \n  int(*)(void *,sqlite3*,const char*,int),\n  void*\n);\n\n/*\n** CAPI3REF: Configure an auto-checkpoint\n** METHOD: sqlite3\n**\n** ^The [sqlite3_wal_autocheckpoint(D,N)] is a wrapper around\n** [sqlite3_wal_hook()] that causes any database on [database connection] D\n** to automatically [checkpoint]\n** after committing a transaction if there are N or\n** more frames in the [write-ahead log] file.  ^Passing zero or \n** a negative value as the nFrame parameter disables automatic\n** checkpoints entirely.\n**\n** ^The callback registered by this function replaces any existing callback\n** registered using [sqlite3_wal_hook()].  ^Likewise, registering a callback\n** using [sqlite3_wal_hook()] disables the automatic checkpoint mechanism\n** configured by this function.\n**\n** ^The [wal_autocheckpoint pragma] can be used to invoke this interface\n** from SQL.\n**\n** ^Checkpoints initiated by this mechanism are\n** [sqlite3_wal_checkpoint_v2|PASSIVE].\n**\n** ^Every new [database connection] defaults to having the auto-checkpoint\n** enabled with a threshold of 1000 or [SQLITE_DEFAULT_WAL_AUTOCHECKPOINT]\n** pages.  The use of this interface\n** is only necessary if the default setting is found to be suboptimal\n** for a particular application.\n*/\nSQLITE_API int sqlite3_wal_autocheckpoint(sqlite3 *db, int N);\n\n/*\n** CAPI3REF: Checkpoint a database\n** METHOD: sqlite3\n**\n** ^(The sqlite3_wal_checkpoint(D,X) is equivalent to\n** [sqlite3_wal_checkpoint_v2](D,X,[SQLITE_CHECKPOINT_PASSIVE],0,0).)^\n**\n** In brief, sqlite3_wal_checkpoint(D,X) causes the content in the \n** [write-ahead log] for database X on [database connection] D to be\n** transferred into the database file and for the write-ahead log to\n** be reset.  See the [checkpointing] documentation for addition\n** information.\n**\n** This interface used to be the only way to cause a checkpoint to\n** occur.  But then the newer and more powerful [sqlite3_wal_checkpoint_v2()]\n** interface was added.  This interface is retained for backwards\n** compatibility and as a convenience for applications that need to manually\n** start a callback but which do not need the full power (and corresponding\n** complication) of [sqlite3_wal_checkpoint_v2()].\n*/\nSQLITE_API int sqlite3_wal_checkpoint(sqlite3 *db, const char *zDb);\n\n/*\n** CAPI3REF: Checkpoint a database\n** METHOD: sqlite3\n**\n** ^(The sqlite3_wal_checkpoint_v2(D,X,M,L,C) interface runs a checkpoint\n** operation on database X of [database connection] D in mode M.  Status\n** information is written back into integers pointed to by L and C.)^\n** ^(The M parameter must be a valid [checkpoint mode]:)^\n**\n** <dl>\n** <dt>SQLITE_CHECKPOINT_PASSIVE<dd>\n**   ^Checkpoint as many frames as possible without waiting for any database \n**   readers or writers to finish, then sync the database file if all frames \n**   in the log were checkpointed. ^The [busy-handler callback]\n**   is never invoked in the SQLITE_CHECKPOINT_PASSIVE mode.  \n**   ^On the other hand, passive mode might leave the checkpoint unfinished\n**   if there are concurrent readers or writers.\n**\n** <dt>SQLITE_CHECKPOINT_FULL<dd>\n**   ^This mode blocks (it invokes the\n**   [sqlite3_busy_handler|busy-handler callback]) until there is no\n**   database writer and all readers are reading from the most recent database\n**   snapshot. ^It then checkpoints all frames in the log file and syncs the\n**   database file. ^This mode blocks new database writers while it is pending,\n**   but new database readers are allowed to continue unimpeded.\n**\n** <dt>SQLITE_CHECKPOINT_RESTART<dd>\n**   ^This mode works the same way as SQLITE_CHECKPOINT_FULL with the addition\n**   that after checkpointing the log file it blocks (calls the \n**   [busy-handler callback])\n**   until all readers are reading from the database file only. ^This ensures \n**   that the next writer will restart the log file from the beginning.\n**   ^Like SQLITE_CHECKPOINT_FULL, this mode blocks new\n**   database writer attempts while it is pending, but does not impede readers.\n**\n** <dt>SQLITE_CHECKPOINT_TRUNCATE<dd>\n**   ^This mode works the same way as SQLITE_CHECKPOINT_RESTART with the\n**   addition that it also truncates the log file to zero bytes just prior\n**   to a successful return.\n** </dl>\n**\n** ^If pnLog is not NULL, then *pnLog is set to the total number of frames in\n** the log file or to -1 if the checkpoint could not run because\n** of an error or because the database is not in [WAL mode]. ^If pnCkpt is not\n** NULL,then *pnCkpt is set to the total number of checkpointed frames in the\n** log file (including any that were already checkpointed before the function\n** was called) or to -1 if the checkpoint could not run due to an error or\n** because the database is not in WAL mode. ^Note that upon successful\n** completion of an SQLITE_CHECKPOINT_TRUNCATE, the log file will have been\n** truncated to zero bytes and so both *pnLog and *pnCkpt will be set to zero.\n**\n** ^All calls obtain an exclusive \"checkpoint\" lock on the database file. ^If\n** any other process is running a checkpoint operation at the same time, the \n** lock cannot be obtained and SQLITE_BUSY is returned. ^Even if there is a \n** busy-handler configured, it will not be invoked in this case.\n**\n** ^The SQLITE_CHECKPOINT_FULL, RESTART and TRUNCATE modes also obtain the \n** exclusive \"writer\" lock on the database file. ^If the writer lock cannot be\n** obtained immediately, and a busy-handler is configured, it is invoked and\n** the writer lock retried until either the busy-handler returns 0 or the lock\n** is successfully obtained. ^The busy-handler is also invoked while waiting for\n** database readers as described above. ^If the busy-handler returns 0 before\n** the writer lock is obtained or while waiting for database readers, the\n** checkpoint operation proceeds from that point in the same way as \n** SQLITE_CHECKPOINT_PASSIVE - checkpointing as many frames as possible \n** without blocking any further. ^SQLITE_BUSY is returned in this case.\n**\n** ^If parameter zDb is NULL or points to a zero length string, then the\n** specified operation is attempted on all WAL databases [attached] to \n** [database connection] db.  In this case the\n** values written to output parameters *pnLog and *pnCkpt are undefined. ^If \n** an SQLITE_BUSY error is encountered when processing one or more of the \n** attached WAL databases, the operation is still attempted on any remaining \n** attached databases and SQLITE_BUSY is returned at the end. ^If any other \n** error occurs while processing an attached database, processing is abandoned \n** and the error code is returned to the caller immediately. ^If no error \n** (SQLITE_BUSY or otherwise) is encountered while processing the attached \n** databases, SQLITE_OK is returned.\n**\n** ^If database zDb is the name of an attached database that is not in WAL\n** mode, SQLITE_OK is returned and both *pnLog and *pnCkpt set to -1. ^If\n** zDb is not NULL (or a zero length string) and is not the name of any\n** attached database, SQLITE_ERROR is returned to the caller.\n**\n** ^Unless it returns SQLITE_MISUSE,\n** the sqlite3_wal_checkpoint_v2() interface\n** sets the error information that is queried by\n** [sqlite3_errcode()] and [sqlite3_errmsg()].\n**\n** ^The [PRAGMA wal_checkpoint] command can be used to invoke this interface\n** from SQL.\n*/\nSQLITE_API int sqlite3_wal_checkpoint_v2(\n  sqlite3 *db,                    /* Database handle */\n  const char *zDb,                /* Name of attached database (or NULL) */\n  int eMode,                      /* SQLITE_CHECKPOINT_* value */\n  int *pnLog,                     /* OUT: Size of WAL log in frames */\n  int *pnCkpt                     /* OUT: Total number of frames checkpointed */\n);\n\n/*\n** CAPI3REF: Checkpoint Mode Values\n** KEYWORDS: {checkpoint mode}\n**\n** These constants define all valid values for the \"checkpoint mode\" passed\n** as the third parameter to the [sqlite3_wal_checkpoint_v2()] interface.\n** See the [sqlite3_wal_checkpoint_v2()] documentation for details on the\n** meaning of each of these checkpoint modes.\n*/\n#define SQLITE_CHECKPOINT_PASSIVE  0  /* Do as much as possible w/o blocking */\n#define SQLITE_CHECKPOINT_FULL     1  /* Wait for writers, then checkpoint */\n#define SQLITE_CHECKPOINT_RESTART  2  /* Like FULL but wait for for readers */\n#define SQLITE_CHECKPOINT_TRUNCATE 3  /* Like RESTART but also truncate WAL */\n\n/*\n** CAPI3REF: Virtual Table Interface Configuration\n**\n** This function may be called by either the [xConnect] or [xCreate] method\n** of a [virtual table] implementation to configure\n** various facets of the virtual table interface.\n**\n** If this interface is invoked outside the context of an xConnect or\n** xCreate virtual table method then the behavior is undefined.\n**\n** At present, there is only one option that may be configured using\n** this function. (See [SQLITE_VTAB_CONSTRAINT_SUPPORT].)  Further options\n** may be added in the future.\n*/\nSQLITE_API int sqlite3_vtab_config(sqlite3*, int op, ...);\n\n/*\n** CAPI3REF: Virtual Table Configuration Options\n**\n** These macros define the various options to the\n** [sqlite3_vtab_config()] interface that [virtual table] implementations\n** can use to customize and optimize their behavior.\n**\n** <dl>\n** [[SQLITE_VTAB_CONSTRAINT_SUPPORT]]\n** <dt>SQLITE_VTAB_CONSTRAINT_SUPPORT\n** <dd>Calls of the form\n** [sqlite3_vtab_config](db,SQLITE_VTAB_CONSTRAINT_SUPPORT,X) are supported,\n** where X is an integer.  If X is zero, then the [virtual table] whose\n** [xCreate] or [xConnect] method invoked [sqlite3_vtab_config()] does not\n** support constraints.  In this configuration (which is the default) if\n** a call to the [xUpdate] method returns [SQLITE_CONSTRAINT], then the entire\n** statement is rolled back as if [ON CONFLICT | OR ABORT] had been\n** specified as part of the users SQL statement, regardless of the actual\n** ON CONFLICT mode specified.\n**\n** If X is non-zero, then the virtual table implementation guarantees\n** that if [xUpdate] returns [SQLITE_CONSTRAINT], it will do so before\n** any modifications to internal or persistent data structures have been made.\n** If the [ON CONFLICT] mode is ABORT, FAIL, IGNORE or ROLLBACK, SQLite \n** is able to roll back a statement or database transaction, and abandon\n** or continue processing the current SQL statement as appropriate. \n** If the ON CONFLICT mode is REPLACE and the [xUpdate] method returns\n** [SQLITE_CONSTRAINT], SQLite handles this as if the ON CONFLICT mode\n** had been ABORT.\n**\n** Virtual table implementations that are required to handle OR REPLACE\n** must do so within the [xUpdate] method. If a call to the \n** [sqlite3_vtab_on_conflict()] function indicates that the current ON \n** CONFLICT policy is REPLACE, the virtual table implementation should \n** silently replace the appropriate rows within the xUpdate callback and\n** return SQLITE_OK. Or, if this is not possible, it may return\n** SQLITE_CONSTRAINT, in which case SQLite falls back to OR ABORT \n** constraint handling.\n** </dl>\n*/\n#define SQLITE_VTAB_CONSTRAINT_SUPPORT 1\n\n/*\n** CAPI3REF: Determine The Virtual Table Conflict Policy\n**\n** This function may only be called from within a call to the [xUpdate] method\n** of a [virtual table] implementation for an INSERT or UPDATE operation. ^The\n** value returned is one of [SQLITE_ROLLBACK], [SQLITE_IGNORE], [SQLITE_FAIL],\n** [SQLITE_ABORT], or [SQLITE_REPLACE], according to the [ON CONFLICT] mode\n** of the SQL statement that triggered the call to the [xUpdate] method of the\n** [virtual table].\n*/\nSQLITE_API int sqlite3_vtab_on_conflict(sqlite3 *);\n\n/*\n** CAPI3REF: Determine If Virtual Table Column Access Is For UPDATE\n**\n** If the sqlite3_vtab_nochange(X) routine is called within the [xColumn]\n** method of a [virtual table], then it returns true if and only if the\n** column is being fetched as part of an UPDATE operation during which the\n** column value will not change.  Applications might use this to substitute\n** a return value that is less expensive to compute and that the corresponding\n** [xUpdate] method understands as a \"no-change\" value.\n**\n** If the [xColumn] method calls sqlite3_vtab_nochange() and finds that\n** the column is not changed by the UPDATE statement, then the xColumn\n** method can optionally return without setting a result, without calling\n** any of the [sqlite3_result_int|sqlite3_result_xxxxx() interfaces].\n** In that case, [sqlite3_value_nochange(X)] will return true for the\n** same column in the [xUpdate] method.\n*/\nSQLITE_API int sqlite3_vtab_nochange(sqlite3_context*);\n\n/*\n** CAPI3REF: Determine The Collation For a Virtual Table Constraint\n**\n** This function may only be called from within a call to the [xBestIndex]\n** method of a [virtual table]. \n**\n** The first argument must be the sqlite3_index_info object that is the\n** first parameter to the xBestIndex() method. The second argument must be\n** an index into the aConstraint[] array belonging to the sqlite3_index_info\n** structure passed to xBestIndex. This function returns a pointer to a buffer \n** containing the name of the collation sequence for the corresponding\n** constraint.\n*/\nSQLITE_API SQLITE_EXPERIMENTAL const char *sqlite3_vtab_collation(sqlite3_index_info*,int);\n\n/*\n** CAPI3REF: Conflict resolution modes\n** KEYWORDS: {conflict resolution mode}\n**\n** These constants are returned by [sqlite3_vtab_on_conflict()] to\n** inform a [virtual table] implementation what the [ON CONFLICT] mode\n** is for the SQL statement being evaluated.\n**\n** Note that the [SQLITE_IGNORE] constant is also used as a potential\n** return value from the [sqlite3_set_authorizer()] callback and that\n** [SQLITE_ABORT] is also a [result code].\n*/\n#define SQLITE_ROLLBACK 1\n/* #define SQLITE_IGNORE 2 // Also used by sqlite3_authorizer() callback */\n#define SQLITE_FAIL     3\n/* #define SQLITE_ABORT 4  // Also an error code */\n#define SQLITE_REPLACE  5\n\n/*\n** CAPI3REF: Prepared Statement Scan Status Opcodes\n** KEYWORDS: {scanstatus options}\n**\n** The following constants can be used for the T parameter to the\n** [sqlite3_stmt_scanstatus(S,X,T,V)] interface.  Each constant designates a\n** different metric for sqlite3_stmt_scanstatus() to return.\n**\n** When the value returned to V is a string, space to hold that string is\n** managed by the prepared statement S and will be automatically freed when\n** S is finalized.\n**\n** <dl>\n** [[SQLITE_SCANSTAT_NLOOP]] <dt>SQLITE_SCANSTAT_NLOOP</dt>\n** <dd>^The [sqlite3_int64] variable pointed to by the T parameter will be\n** set to the total number of times that the X-th loop has run.</dd>\n**\n** [[SQLITE_SCANSTAT_NVISIT]] <dt>SQLITE_SCANSTAT_NVISIT</dt>\n** <dd>^The [sqlite3_int64] variable pointed to by the T parameter will be set\n** to the total number of rows examined by all iterations of the X-th loop.</dd>\n**\n** [[SQLITE_SCANSTAT_EST]] <dt>SQLITE_SCANSTAT_EST</dt>\n** <dd>^The \"double\" variable pointed to by the T parameter will be set to the\n** query planner's estimate for the average number of rows output from each\n** iteration of the X-th loop.  If the query planner's estimates was accurate,\n** then this value will approximate the quotient NVISIT/NLOOP and the\n** product of this value for all prior loops with the same SELECTID will\n** be the NLOOP value for the current loop.\n**\n** [[SQLITE_SCANSTAT_NAME]] <dt>SQLITE_SCANSTAT_NAME</dt>\n** <dd>^The \"const char *\" variable pointed to by the T parameter will be set\n** to a zero-terminated UTF-8 string containing the name of the index or table\n** used for the X-th loop.\n**\n** [[SQLITE_SCANSTAT_EXPLAIN]] <dt>SQLITE_SCANSTAT_EXPLAIN</dt>\n** <dd>^The \"const char *\" variable pointed to by the T parameter will be set\n** to a zero-terminated UTF-8 string containing the [EXPLAIN QUERY PLAN]\n** description for the X-th loop.\n**\n** [[SQLITE_SCANSTAT_SELECTID]] <dt>SQLITE_SCANSTAT_SELECT</dt>\n** <dd>^The \"int\" variable pointed to by the T parameter will be set to the\n** \"select-id\" for the X-th loop.  The select-id identifies which query or\n** subquery the loop is part of.  The main query has a select-id of zero.\n** The select-id is the same value as is output in the first column\n** of an [EXPLAIN QUERY PLAN] query.\n** </dl>\n*/\n#define SQLITE_SCANSTAT_NLOOP    0\n#define SQLITE_SCANSTAT_NVISIT   1\n#define SQLITE_SCANSTAT_EST      2\n#define SQLITE_SCANSTAT_NAME     3\n#define SQLITE_SCANSTAT_EXPLAIN  4\n#define SQLITE_SCANSTAT_SELECTID 5\n\n/*\n** CAPI3REF: Prepared Statement Scan Status\n** METHOD: sqlite3_stmt\n**\n** This interface returns information about the predicted and measured\n** performance for pStmt.  Advanced applications can use this\n** interface to compare the predicted and the measured performance and\n** issue warnings and/or rerun [ANALYZE] if discrepancies are found.\n**\n** Since this interface is expected to be rarely used, it is only\n** available if SQLite is compiled using the [SQLITE_ENABLE_STMT_SCANSTATUS]\n** compile-time option.\n**\n** The \"iScanStatusOp\" parameter determines which status information to return.\n** The \"iScanStatusOp\" must be one of the [scanstatus options] or the behavior\n** of this interface is undefined.\n** ^The requested measurement is written into a variable pointed to by\n** the \"pOut\" parameter.\n** Parameter \"idx\" identifies the specific loop to retrieve statistics for.\n** Loops are numbered starting from zero. ^If idx is out of range - less than\n** zero or greater than or equal to the total number of loops used to implement\n** the statement - a non-zero value is returned and the variable that pOut\n** points to is unchanged.\n**\n** ^Statistics might not be available for all loops in all statements. ^In cases\n** where there exist loops with no available statistics, this function behaves\n** as if the loop did not exist - it returns non-zero and leave the variable\n** that pOut points to unchanged.\n**\n** See also: [sqlite3_stmt_scanstatus_reset()]\n*/\nSQLITE_API int sqlite3_stmt_scanstatus(\n  sqlite3_stmt *pStmt,      /* Prepared statement for which info desired */\n  int idx,                  /* Index of loop to report on */\n  int iScanStatusOp,        /* Information desired.  SQLITE_SCANSTAT_* */\n  void *pOut                /* Result written here */\n);     \n\n/*\n** CAPI3REF: Zero Scan-Status Counters\n** METHOD: sqlite3_stmt\n**\n** ^Zero all [sqlite3_stmt_scanstatus()] related event counters.\n**\n** This API is only available if the library is built with pre-processor\n** symbol [SQLITE_ENABLE_STMT_SCANSTATUS] defined.\n*/\nSQLITE_API void sqlite3_stmt_scanstatus_reset(sqlite3_stmt*);\n\n/*\n** CAPI3REF: Flush caches to disk mid-transaction\n**\n** ^If a write-transaction is open on [database connection] D when the\n** [sqlite3_db_cacheflush(D)] interface invoked, any dirty\n** pages in the pager-cache that are not currently in use are written out \n** to disk. A dirty page may be in use if a database cursor created by an\n** active SQL statement is reading from it, or if it is page 1 of a database\n** file (page 1 is always \"in use\").  ^The [sqlite3_db_cacheflush(D)]\n** interface flushes caches for all schemas - \"main\", \"temp\", and\n** any [attached] databases.\n**\n** ^If this function needs to obtain extra database locks before dirty pages \n** can be flushed to disk, it does so. ^If those locks cannot be obtained \n** immediately and there is a busy-handler callback configured, it is invoked\n** in the usual manner. ^If the required lock still cannot be obtained, then\n** the database is skipped and an attempt made to flush any dirty pages\n** belonging to the next (if any) database. ^If any databases are skipped\n** because locks cannot be obtained, but no other error occurs, this\n** function returns SQLITE_BUSY.\n**\n** ^If any other error occurs while flushing dirty pages to disk (for\n** example an IO error or out-of-memory condition), then processing is\n** abandoned and an SQLite [error code] is returned to the caller immediately.\n**\n** ^Otherwise, if no error occurs, [sqlite3_db_cacheflush()] returns SQLITE_OK.\n**\n** ^This function does not set the database handle error code or message\n** returned by the [sqlite3_errcode()] and [sqlite3_errmsg()] functions.\n*/\nSQLITE_API int sqlite3_db_cacheflush(sqlite3*);\n\n/*\n** CAPI3REF: The pre-update hook.\n**\n** ^These interfaces are only available if SQLite is compiled using the\n** [SQLITE_ENABLE_PREUPDATE_HOOK] compile-time option.\n**\n** ^The [sqlite3_preupdate_hook()] interface registers a callback function\n** that is invoked prior to each [INSERT], [UPDATE], and [DELETE] operation\n** on a database table.\n** ^At most one preupdate hook may be registered at a time on a single\n** [database connection]; each call to [sqlite3_preupdate_hook()] overrides\n** the previous setting.\n** ^The preupdate hook is disabled by invoking [sqlite3_preupdate_hook()]\n** with a NULL pointer as the second parameter.\n** ^The third parameter to [sqlite3_preupdate_hook()] is passed through as\n** the first parameter to callbacks.\n**\n** ^The preupdate hook only fires for changes to real database tables; the\n** preupdate hook is not invoked for changes to [virtual tables] or to\n** system tables like sqlite_master or sqlite_stat1.\n**\n** ^The second parameter to the preupdate callback is a pointer to\n** the [database connection] that registered the preupdate hook.\n** ^The third parameter to the preupdate callback is one of the constants\n** [SQLITE_INSERT], [SQLITE_DELETE], or [SQLITE_UPDATE] to identify the\n** kind of update operation that is about to occur.\n** ^(The fourth parameter to the preupdate callback is the name of the\n** database within the database connection that is being modified.  This\n** will be \"main\" for the main database or \"temp\" for TEMP tables or \n** the name given after the AS keyword in the [ATTACH] statement for attached\n** databases.)^\n** ^The fifth parameter to the preupdate callback is the name of the\n** table that is being modified.\n**\n** For an UPDATE or DELETE operation on a [rowid table], the sixth\n** parameter passed to the preupdate callback is the initial [rowid] of the \n** row being modified or deleted. For an INSERT operation on a rowid table,\n** or any operation on a WITHOUT ROWID table, the value of the sixth \n** parameter is undefined. For an INSERT or UPDATE on a rowid table the\n** seventh parameter is the final rowid value of the row being inserted\n** or updated. The value of the seventh parameter passed to the callback\n** function is not defined for operations on WITHOUT ROWID tables, or for\n** INSERT operations on rowid tables.\n**\n** The [sqlite3_preupdate_old()], [sqlite3_preupdate_new()],\n** [sqlite3_preupdate_count()], and [sqlite3_preupdate_depth()] interfaces\n** provide additional information about a preupdate event. These routines\n** may only be called from within a preupdate callback.  Invoking any of\n** these routines from outside of a preupdate callback or with a\n** [database connection] pointer that is different from the one supplied\n** to the preupdate callback results in undefined and probably undesirable\n** behavior.\n**\n** ^The [sqlite3_preupdate_count(D)] interface returns the number of columns\n** in the row that is being inserted, updated, or deleted.\n**\n** ^The [sqlite3_preupdate_old(D,N,P)] interface writes into P a pointer to\n** a [protected sqlite3_value] that contains the value of the Nth column of\n** the table row before it is updated.  The N parameter must be between 0\n** and one less than the number of columns or the behavior will be\n** undefined. This must only be used within SQLITE_UPDATE and SQLITE_DELETE\n** preupdate callbacks; if it is used by an SQLITE_INSERT callback then the\n** behavior is undefined.  The [sqlite3_value] that P points to\n** will be destroyed when the preupdate callback returns.\n**\n** ^The [sqlite3_preupdate_new(D,N,P)] interface writes into P a pointer to\n** a [protected sqlite3_value] that contains the value of the Nth column of\n** the table row after it is updated.  The N parameter must be between 0\n** and one less than the number of columns or the behavior will be\n** undefined. This must only be used within SQLITE_INSERT and SQLITE_UPDATE\n** preupdate callbacks; if it is used by an SQLITE_DELETE callback then the\n** behavior is undefined.  The [sqlite3_value] that P points to\n** will be destroyed when the preupdate callback returns.\n**\n** ^The [sqlite3_preupdate_depth(D)] interface returns 0 if the preupdate\n** callback was invoked as a result of a direct insert, update, or delete\n** operation; or 1 for inserts, updates, or deletes invoked by top-level \n** triggers; or 2 for changes resulting from triggers called by top-level\n** triggers; and so forth.\n**\n** See also:  [sqlite3_update_hook()]\n*/\n#if defined(SQLITE_ENABLE_PREUPDATE_HOOK)\nSQLITE_API void *sqlite3_preupdate_hook(\n  sqlite3 *db,\n  void(*xPreUpdate)(\n    void *pCtx,                   /* Copy of third arg to preupdate_hook() */\n    sqlite3 *db,                  /* Database handle */\n    int op,                       /* SQLITE_UPDATE, DELETE or INSERT */\n    char const *zDb,              /* Database name */\n    char const *zName,            /* Table name */\n    sqlite3_int64 iKey1,          /* Rowid of row about to be deleted/updated */\n    sqlite3_int64 iKey2           /* New rowid value (for a rowid UPDATE) */\n  ),\n  void*\n);\nSQLITE_API int sqlite3_preupdate_old(sqlite3 *, int, sqlite3_value **);\nSQLITE_API int sqlite3_preupdate_count(sqlite3 *);\nSQLITE_API int sqlite3_preupdate_depth(sqlite3 *);\nSQLITE_API int sqlite3_preupdate_new(sqlite3 *, int, sqlite3_value **);\n#endif\n\n/*\n** CAPI3REF: Low-level system error code\n**\n** ^Attempt to return the underlying operating system error code or error\n** number that caused the most recent I/O error or failure to open a file.\n** The return value is OS-dependent.  For example, on unix systems, after\n** [sqlite3_open_v2()] returns [SQLITE_CANTOPEN], this interface could be\n** called to get back the underlying \"errno\" that caused the problem, such\n** as ENOSPC, EAUTH, EISDIR, and so forth.  \n*/\nSQLITE_API int sqlite3_system_errno(sqlite3*);\n\n/*\n** CAPI3REF: Database Snapshot\n** KEYWORDS: {snapshot} {sqlite3_snapshot}\n**\n** An instance of the snapshot object records the state of a [WAL mode]\n** database for some specific point in history.\n**\n** In [WAL mode], multiple [database connections] that are open on the\n** same database file can each be reading a different historical version\n** of the database file.  When a [database connection] begins a read\n** transaction, that connection sees an unchanging copy of the database\n** as it existed for the point in time when the transaction first started.\n** Subsequent changes to the database from other connections are not seen\n** by the reader until a new read transaction is started.\n**\n** The sqlite3_snapshot object records state information about an historical\n** version of the database file so that it is possible to later open a new read\n** transaction that sees that historical version of the database rather than\n** the most recent version.\n*/\ntypedef struct sqlite3_snapshot {\n  unsigned char hidden[48];\n} sqlite3_snapshot;\n\n/*\n** CAPI3REF: Record A Database Snapshot\n** CONSTRUCTOR: sqlite3_snapshot\n**\n** ^The [sqlite3_snapshot_get(D,S,P)] interface attempts to make a\n** new [sqlite3_snapshot] object that records the current state of\n** schema S in database connection D.  ^On success, the\n** [sqlite3_snapshot_get(D,S,P)] interface writes a pointer to the newly\n** created [sqlite3_snapshot] object into *P and returns SQLITE_OK.\n** If there is not already a read-transaction open on schema S when\n** this function is called, one is opened automatically. \n**\n** The following must be true for this function to succeed. If any of\n** the following statements are false when sqlite3_snapshot_get() is\n** called, SQLITE_ERROR is returned. The final value of *P is undefined\n** in this case. \n**\n** <ul>\n**   <li> The database handle must not be in [autocommit mode].\n**\n**   <li> Schema S of [database connection] D must be a [WAL mode] database.\n**\n**   <li> There must not be a write transaction open on schema S of database\n**        connection D.\n**\n**   <li> One or more transactions must have been written to the current wal\n**        file since it was created on disk (by any connection). This means\n**        that a snapshot cannot be taken on a wal mode database with no wal \n**        file immediately after it is first opened. At least one transaction\n**        must be written to it first.\n** </ul>\n**\n** This function may also return SQLITE_NOMEM.  If it is called with the\n** database handle in autocommit mode but fails for some other reason, \n** whether or not a read transaction is opened on schema S is undefined.\n**\n** The [sqlite3_snapshot] object returned from a successful call to\n** [sqlite3_snapshot_get()] must be freed using [sqlite3_snapshot_free()]\n** to avoid a memory leak.\n**\n** The [sqlite3_snapshot_get()] interface is only available when the\n** [SQLITE_ENABLE_SNAPSHOT] compile-time option is used.\n*/\nSQLITE_API SQLITE_EXPERIMENTAL int sqlite3_snapshot_get(\n  sqlite3 *db,\n  const char *zSchema,\n  sqlite3_snapshot **ppSnapshot\n);\n\n/*\n** CAPI3REF: Start a read transaction on an historical snapshot\n** METHOD: sqlite3_snapshot\n**\n** ^The [sqlite3_snapshot_open(D,S,P)] interface either starts a new read \n** transaction or upgrades an existing one for schema S of \n** [database connection] D such that the read transaction refers to \n** historical [snapshot] P, rather than the most recent change to the \n** database. ^The [sqlite3_snapshot_open()] interface returns SQLITE_OK \n** on success or an appropriate [error code] if it fails.\n**\n** ^In order to succeed, the database connection must not be in \n** [autocommit mode] when [sqlite3_snapshot_open(D,S,P)] is called. If there\n** is already a read transaction open on schema S, then the database handle\n** must have no active statements (SELECT statements that have been passed\n** to sqlite3_step() but not sqlite3_reset() or sqlite3_finalize()). \n** SQLITE_ERROR is returned if either of these conditions is violated, or\n** if schema S does not exist, or if the snapshot object is invalid.\n**\n** ^A call to sqlite3_snapshot_open() will fail to open if the specified\n** snapshot has been overwritten by a [checkpoint]. In this case \n** SQLITE_ERROR_SNAPSHOT is returned.\n**\n** If there is already a read transaction open when this function is \n** invoked, then the same read transaction remains open (on the same\n** database snapshot) if SQLITE_ERROR, SQLITE_BUSY or SQLITE_ERROR_SNAPSHOT\n** is returned. If another error code - for example SQLITE_PROTOCOL or an\n** SQLITE_IOERR error code - is returned, then the final state of the\n** read transaction is undefined. If SQLITE_OK is returned, then the \n** read transaction is now open on database snapshot P.\n**\n** ^(A call to [sqlite3_snapshot_open(D,S,P)] will fail if the\n** database connection D does not know that the database file for\n** schema S is in [WAL mode].  A database connection might not know\n** that the database file is in [WAL mode] if there has been no prior\n** I/O on that database connection, or if the database entered [WAL mode] \n** after the most recent I/O on the database connection.)^\n** (Hint: Run \"[PRAGMA application_id]\" against a newly opened\n** database connection in order to make it ready to use snapshots.)\n**\n** The [sqlite3_snapshot_open()] interface is only available when the\n** [SQLITE_ENABLE_SNAPSHOT] compile-time option is used.\n*/\nSQLITE_API SQLITE_EXPERIMENTAL int sqlite3_snapshot_open(\n  sqlite3 *db,\n  const char *zSchema,\n  sqlite3_snapshot *pSnapshot\n);\n\n/*\n** CAPI3REF: Destroy a snapshot\n** DESTRUCTOR: sqlite3_snapshot\n**\n** ^The [sqlite3_snapshot_free(P)] interface destroys [sqlite3_snapshot] P.\n** The application must eventually free every [sqlite3_snapshot] object\n** using this routine to avoid a memory leak.\n**\n** The [sqlite3_snapshot_free()] interface is only available when the\n** [SQLITE_ENABLE_SNAPSHOT] compile-time option is used.\n*/\nSQLITE_API SQLITE_EXPERIMENTAL void sqlite3_snapshot_free(sqlite3_snapshot*);\n\n/*\n** CAPI3REF: Compare the ages of two snapshot handles.\n** METHOD: sqlite3_snapshot\n**\n** The sqlite3_snapshot_cmp(P1, P2) interface is used to compare the ages\n** of two valid snapshot handles. \n**\n** If the two snapshot handles are not associated with the same database \n** file, the result of the comparison is undefined. \n**\n** Additionally, the result of the comparison is only valid if both of the\n** snapshot handles were obtained by calling sqlite3_snapshot_get() since the\n** last time the wal file was deleted. The wal file is deleted when the\n** database is changed back to rollback mode or when the number of database\n** clients drops to zero. If either snapshot handle was obtained before the \n** wal file was last deleted, the value returned by this function \n** is undefined.\n**\n** Otherwise, this API returns a negative value if P1 refers to an older\n** snapshot than P2, zero if the two handles refer to the same database\n** snapshot, and a positive value if P1 is a newer snapshot than P2.\n**\n** This interface is only available if SQLite is compiled with the\n** [SQLITE_ENABLE_SNAPSHOT] option.\n*/\nSQLITE_API SQLITE_EXPERIMENTAL int sqlite3_snapshot_cmp(\n  sqlite3_snapshot *p1,\n  sqlite3_snapshot *p2\n);\n\n/*\n** CAPI3REF: Recover snapshots from a wal file\n** METHOD: sqlite3_snapshot\n**\n** If a [WAL file] remains on disk after all database connections close\n** (either through the use of the [SQLITE_FCNTL_PERSIST_WAL] [file control]\n** or because the last process to have the database opened exited without\n** calling [sqlite3_close()]) and a new connection is subsequently opened\n** on that database and [WAL file], the [sqlite3_snapshot_open()] interface\n** will only be able to open the last transaction added to the WAL file\n** even though the WAL file contains other valid transactions.\n**\n** This function attempts to scan the WAL file associated with database zDb\n** of database handle db and make all valid snapshots available to\n** sqlite3_snapshot_open(). It is an error if there is already a read\n** transaction open on the database, or if the database is not a WAL mode\n** database.\n**\n** SQLITE_OK is returned if successful, or an SQLite error code otherwise.\n**\n** This interface is only available if SQLite is compiled with the\n** [SQLITE_ENABLE_SNAPSHOT] option.\n*/\nSQLITE_API SQLITE_EXPERIMENTAL int sqlite3_snapshot_recover(sqlite3 *db, const char *zDb);\n\n/*\n** CAPI3REF: Serialize a database\n**\n** The sqlite3_serialize(D,S,P,F) interface returns a pointer to memory\n** that is a serialization of the S database on [database connection] D.\n** If P is not a NULL pointer, then the size of the database in bytes\n** is written into *P.\n**\n** For an ordinary on-disk database file, the serialization is just a\n** copy of the disk file.  For an in-memory database or a \"TEMP\" database,\n** the serialization is the same sequence of bytes which would be written\n** to disk if that database where backed up to disk.\n**\n** The usual case is that sqlite3_serialize() copies the serialization of\n** the database into memory obtained from [sqlite3_malloc64()] and returns\n** a pointer to that memory.  The caller is responsible for freeing the\n** returned value to avoid a memory leak.  However, if the F argument\n** contains the SQLITE_SERIALIZE_NOCOPY bit, then no memory allocations\n** are made, and the sqlite3_serialize() function will return a pointer\n** to the contiguous memory representation of the database that SQLite\n** is currently using for that database, or NULL if the no such contiguous\n** memory representation of the database exists.  A contiguous memory\n** representation of the database will usually only exist if there has\n** been a prior call to [sqlite3_deserialize(D,S,...)] with the same\n** values of D and S.\n** The size of the database is written into *P even if the \n** SQLITE_SERIALIZE_NOCOPY bit is set but no contiguous copy\n** of the database exists.\n**\n** A call to sqlite3_serialize(D,S,P,F) might return NULL even if the\n** SQLITE_SERIALIZE_NOCOPY bit is omitted from argument F if a memory\n** allocation error occurs.\n**\n** This interface is only available if SQLite is compiled with the\n** [SQLITE_ENABLE_DESERIALIZE] option.\n*/\nSQLITE_API unsigned char *sqlite3_serialize(\n  sqlite3 *db,           /* The database connection */\n  const char *zSchema,   /* Which DB to serialize. ex: \"main\", \"temp\", ... */\n  sqlite3_int64 *piSize, /* Write size of the DB here, if not NULL */\n  unsigned int mFlags    /* Zero or more SQLITE_SERIALIZE_* flags */\n);\n\n/*\n** CAPI3REF: Flags for sqlite3_serialize\n**\n** Zero or more of the following constants can be OR-ed together for\n** the F argument to [sqlite3_serialize(D,S,P,F)].\n**\n** SQLITE_SERIALIZE_NOCOPY means that [sqlite3_serialize()] will return\n** a pointer to contiguous in-memory database that it is currently using,\n** without making a copy of the database.  If SQLite is not currently using\n** a contiguous in-memory database, then this option causes\n** [sqlite3_serialize()] to return a NULL pointer.  SQLite will only be\n** using a contiguous in-memory database if it has been initialized by a\n** prior call to [sqlite3_deserialize()].\n*/\n#define SQLITE_SERIALIZE_NOCOPY 0x001   /* Do no memory allocations */\n\n/*\n** CAPI3REF: Deserialize a database\n**\n** The sqlite3_deserialize(D,S,P,N,M,F) interface causes the \n** [database connection] D to disconnect from database S and then\n** reopen S as an in-memory database based on the serialization contained\n** in P.  The serialized database P is N bytes in size.  M is the size of\n** the buffer P, which might be larger than N.  If M is larger than N, and\n** the SQLITE_DESERIALIZE_READONLY bit is not set in F, then SQLite is\n** permitted to add content to the in-memory database as long as the total\n** size does not exceed M bytes.\n**\n** If the SQLITE_DESERIALIZE_FREEONCLOSE bit is set in F, then SQLite will\n** invoke sqlite3_free() on the serialization buffer when the database\n** connection closes.  If the SQLITE_DESERIALIZE_RESIZEABLE bit is set, then\n** SQLite will try to increase the buffer size using sqlite3_realloc64()\n** if writes on the database cause it to grow larger than M bytes.\n**\n** The sqlite3_deserialize() interface will fail with SQLITE_BUSY if the\n** database is currently in a read transaction or is involved in a backup\n** operation.\n**\n** If sqlite3_deserialize(D,S,P,N,M,F) fails for any reason and if the \n** SQLITE_DESERIALIZE_FREEONCLOSE bit is set in argument F, then\n** [sqlite3_free()] is invoked on argument P prior to returning.\n**\n** This interface is only available if SQLite is compiled with the\n** [SQLITE_ENABLE_DESERIALIZE] option.\n*/\nSQLITE_API int sqlite3_deserialize(\n  sqlite3 *db,            /* The database connection */\n  const char *zSchema,    /* Which DB to reopen with the deserialization */\n  unsigned char *pData,   /* The serialized database content */\n  sqlite3_int64 szDb,     /* Number bytes in the deserialization */\n  sqlite3_int64 szBuf,    /* Total size of buffer pData[] */\n  unsigned mFlags         /* Zero or more SQLITE_DESERIALIZE_* flags */\n);\n\n/*\n** CAPI3REF: Flags for sqlite3_deserialize()\n**\n** The following are allowed values for 6th argument (the F argument) to\n** the [sqlite3_deserialize(D,S,P,N,M,F)] interface.\n**\n** The SQLITE_DESERIALIZE_FREEONCLOSE means that the database serialization\n** in the P argument is held in memory obtained from [sqlite3_malloc64()]\n** and that SQLite should take ownership of this memory and automatically\n** free it when it has finished using it.  Without this flag, the caller\n** is responsible for freeing any dynamically allocated memory.\n**\n** The SQLITE_DESERIALIZE_RESIZEABLE flag means that SQLite is allowed to\n** grow the size of the database using calls to [sqlite3_realloc64()].  This\n** flag should only be used if SQLITE_DESERIALIZE_FREEONCLOSE is also used.\n** Without this flag, the deserialized database cannot increase in size beyond\n** the number of bytes specified by the M parameter.\n**\n** The SQLITE_DESERIALIZE_READONLY flag means that the deserialized database\n** should be treated as read-only.\n*/\n#define SQLITE_DESERIALIZE_FREEONCLOSE 1 /* Call sqlite3_free() on close */\n#define SQLITE_DESERIALIZE_RESIZEABLE  2 /* Resize using sqlite3_realloc64() */\n#define SQLITE_DESERIALIZE_READONLY    4 /* Database is read-only */\n\n/*\n** Undo the hack that converts floating point types to integer for\n** builds on processors without floating point support.\n*/\n#ifdef SQLITE_OMIT_FLOATING_POINT\n# undef double\n#endif\n\n#ifdef __cplusplus\n}  /* End of the 'extern \"C\"' block */\n#endif\n#endif /* SQLITE3_H */\n\n/******** Begin file sqlite3rtree.h *********/\n/*\n** 2010 August 30\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n*/\n\n#ifndef _SQLITE3RTREE_H_\n#define _SQLITE3RTREE_H_\n\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\ntypedef struct sqlite3_rtree_geometry sqlite3_rtree_geometry;\ntypedef struct sqlite3_rtree_query_info sqlite3_rtree_query_info;\n\n/* The double-precision datatype used by RTree depends on the\n** SQLITE_RTREE_INT_ONLY compile-time option.\n*/\n#ifdef SQLITE_RTREE_INT_ONLY\n  typedef sqlite3_int64 sqlite3_rtree_dbl;\n#else\n  typedef double sqlite3_rtree_dbl;\n#endif\n\n/*\n** Register a geometry callback named zGeom that can be used as part of an\n** R-Tree geometry query as follows:\n**\n**   SELECT ... FROM <rtree> WHERE <rtree col> MATCH $zGeom(... params ...)\n*/\nSQLITE_API int sqlite3_rtree_geometry_callback(\n  sqlite3 *db,\n  const char *zGeom,\n  int (*xGeom)(sqlite3_rtree_geometry*, int, sqlite3_rtree_dbl*,int*),\n  void *pContext\n);\n\n\n/*\n** A pointer to a structure of the following type is passed as the first\n** argument to callbacks registered using rtree_geometry_callback().\n*/\nstruct sqlite3_rtree_geometry {\n  void *pContext;                 /* Copy of pContext passed to s_r_g_c() */\n  int nParam;                     /* Size of array aParam[] */\n  sqlite3_rtree_dbl *aParam;      /* Parameters passed to SQL geom function */\n  void *pUser;                    /* Callback implementation user data */\n  void (*xDelUser)(void *);       /* Called by SQLite to clean up pUser */\n};\n\n/*\n** Register a 2nd-generation geometry callback named zScore that can be \n** used as part of an R-Tree geometry query as follows:\n**\n**   SELECT ... FROM <rtree> WHERE <rtree col> MATCH $zQueryFunc(... params ...)\n*/\nSQLITE_API int sqlite3_rtree_query_callback(\n  sqlite3 *db,\n  const char *zQueryFunc,\n  int (*xQueryFunc)(sqlite3_rtree_query_info*),\n  void *pContext,\n  void (*xDestructor)(void*)\n);\n\n\n/*\n** A pointer to a structure of the following type is passed as the \n** argument to scored geometry callback registered using\n** sqlite3_rtree_query_callback().\n**\n** Note that the first 5 fields of this structure are identical to\n** sqlite3_rtree_geometry.  This structure is a subclass of\n** sqlite3_rtree_geometry.\n*/\nstruct sqlite3_rtree_query_info {\n  void *pContext;                   /* pContext from when function registered */\n  int nParam;                       /* Number of function parameters */\n  sqlite3_rtree_dbl *aParam;        /* value of function parameters */\n  void *pUser;                      /* callback can use this, if desired */\n  void (*xDelUser)(void*);          /* function to free pUser */\n  sqlite3_rtree_dbl *aCoord;        /* Coordinates of node or entry to check */\n  unsigned int *anQueue;            /* Number of pending entries in the queue */\n  int nCoord;                       /* Number of coordinates */\n  int iLevel;                       /* Level of current node or entry */\n  int mxLevel;                      /* The largest iLevel value in the tree */\n  sqlite3_int64 iRowid;             /* Rowid for current entry */\n  sqlite3_rtree_dbl rParentScore;   /* Score of parent node */\n  int eParentWithin;                /* Visibility of parent node */\n  int eWithin;                      /* OUT: Visibility */\n  sqlite3_rtree_dbl rScore;         /* OUT: Write the score here */\n  /* The following fields are only available in 3.8.11 and later */\n  sqlite3_value **apSqlParam;       /* Original SQL values of parameters */\n};\n\n/*\n** Allowed values for sqlite3_rtree_query.eWithin and .eParentWithin.\n*/\n#define NOT_WITHIN       0   /* Object completely outside of query region */\n#define PARTLY_WITHIN    1   /* Object partially overlaps query region */\n#define FULLY_WITHIN     2   /* Object fully contained within query region */\n\n\n#ifdef __cplusplus\n}  /* end of the 'extern \"C\"' block */\n#endif\n\n#endif  /* ifndef _SQLITE3RTREE_H_ */\n\n/******** End of sqlite3rtree.h *********/\n/******** Begin file sqlite3session.h *********/\n\n#if !defined(__SQLITESESSION_H_) && defined(SQLITE_ENABLE_SESSION)\n#define __SQLITESESSION_H_ 1\n\n/*\n** Make sure we can call this stuff from C++.\n*/\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n\n/*\n** CAPI3REF: Session Object Handle\n**\n** An instance of this object is a [session] that can be used to\n** record changes to a database.\n*/\ntypedef struct sqlite3_session sqlite3_session;\n\n/*\n** CAPI3REF: Changeset Iterator Handle\n**\n** An instance of this object acts as a cursor for iterating\n** over the elements of a [changeset] or [patchset].\n*/\ntypedef struct sqlite3_changeset_iter sqlite3_changeset_iter;\n\n/*\n** CAPI3REF: Create A New Session Object\n** CONSTRUCTOR: sqlite3_session\n**\n** Create a new session object attached to database handle db. If successful,\n** a pointer to the new object is written to *ppSession and SQLITE_OK is\n** returned. If an error occurs, *ppSession is set to NULL and an SQLite\n** error code (e.g. SQLITE_NOMEM) is returned.\n**\n** It is possible to create multiple session objects attached to a single\n** database handle.\n**\n** Session objects created using this function should be deleted using the\n** [sqlite3session_delete()] function before the database handle that they\n** are attached to is itself closed. If the database handle is closed before\n** the session object is deleted, then the results of calling any session\n** module function, including [sqlite3session_delete()] on the session object\n** are undefined.\n**\n** Because the session module uses the [sqlite3_preupdate_hook()] API, it\n** is not possible for an application to register a pre-update hook on a\n** database handle that has one or more session objects attached. Nor is\n** it possible to create a session object attached to a database handle for\n** which a pre-update hook is already defined. The results of attempting \n** either of these things are undefined.\n**\n** The session object will be used to create changesets for tables in\n** database zDb, where zDb is either \"main\", or \"temp\", or the name of an\n** attached database. It is not an error if database zDb is not attached\n** to the database when the session object is created.\n*/\nSQLITE_API int sqlite3session_create(\n  sqlite3 *db,                    /* Database handle */\n  const char *zDb,                /* Name of db (e.g. \"main\") */\n  sqlite3_session **ppSession     /* OUT: New session object */\n);\n\n/*\n** CAPI3REF: Delete A Session Object\n** DESTRUCTOR: sqlite3_session\n**\n** Delete a session object previously allocated using \n** [sqlite3session_create()]. Once a session object has been deleted, the\n** results of attempting to use pSession with any other session module\n** function are undefined.\n**\n** Session objects must be deleted before the database handle to which they\n** are attached is closed. Refer to the documentation for \n** [sqlite3session_create()] for details.\n*/\nSQLITE_API void sqlite3session_delete(sqlite3_session *pSession);\n\n\n/*\n** CAPI3REF: Enable Or Disable A Session Object\n** METHOD: sqlite3_session\n**\n** Enable or disable the recording of changes by a session object. When\n** enabled, a session object records changes made to the database. When\n** disabled - it does not. A newly created session object is enabled.\n** Refer to the documentation for [sqlite3session_changeset()] for further\n** details regarding how enabling and disabling a session object affects\n** the eventual changesets.\n**\n** Passing zero to this function disables the session. Passing a value\n** greater than zero enables it. Passing a value less than zero is a \n** no-op, and may be used to query the current state of the session.\n**\n** The return value indicates the final state of the session object: 0 if \n** the session is disabled, or 1 if it is enabled.\n*/\nSQLITE_API int sqlite3session_enable(sqlite3_session *pSession, int bEnable);\n\n/*\n** CAPI3REF: Set Or Clear the Indirect Change Flag\n** METHOD: sqlite3_session\n**\n** Each change recorded by a session object is marked as either direct or\n** indirect. A change is marked as indirect if either:\n**\n** <ul>\n**   <li> The session object \"indirect\" flag is set when the change is\n**        made, or\n**   <li> The change is made by an SQL trigger or foreign key action \n**        instead of directly as a result of a users SQL statement.\n** </ul>\n**\n** If a single row is affected by more than one operation within a session,\n** then the change is considered indirect if all operations meet the criteria\n** for an indirect change above, or direct otherwise.\n**\n** This function is used to set, clear or query the session object indirect\n** flag.  If the second argument passed to this function is zero, then the\n** indirect flag is cleared. If it is greater than zero, the indirect flag\n** is set. Passing a value less than zero does not modify the current value\n** of the indirect flag, and may be used to query the current state of the \n** indirect flag for the specified session object.\n**\n** The return value indicates the final state of the indirect flag: 0 if \n** it is clear, or 1 if it is set.\n*/\nSQLITE_API int sqlite3session_indirect(sqlite3_session *pSession, int bIndirect);\n\n/*\n** CAPI3REF: Attach A Table To A Session Object\n** METHOD: sqlite3_session\n**\n** If argument zTab is not NULL, then it is the name of a table to attach\n** to the session object passed as the first argument. All subsequent changes \n** made to the table while the session object is enabled will be recorded. See \n** documentation for [sqlite3session_changeset()] for further details.\n**\n** Or, if argument zTab is NULL, then changes are recorded for all tables\n** in the database. If additional tables are added to the database (by \n** executing \"CREATE TABLE\" statements) after this call is made, changes for \n** the new tables are also recorded.\n**\n** Changes can only be recorded for tables that have a PRIMARY KEY explicitly\n** defined as part of their CREATE TABLE statement. It does not matter if the \n** PRIMARY KEY is an \"INTEGER PRIMARY KEY\" (rowid alias) or not. The PRIMARY\n** KEY may consist of a single column, or may be a composite key.\n** \n** It is not an error if the named table does not exist in the database. Nor\n** is it an error if the named table does not have a PRIMARY KEY. However,\n** no changes will be recorded in either of these scenarios.\n**\n** Changes are not recorded for individual rows that have NULL values stored\n** in one or more of their PRIMARY KEY columns.\n**\n** SQLITE_OK is returned if the call completes without error. Or, if an error \n** occurs, an SQLite error code (e.g. SQLITE_NOMEM) is returned.\n**\n** <h3>Special sqlite_stat1 Handling</h3>\n**\n** As of SQLite version 3.22.0, the \"sqlite_stat1\" table is an exception to \n** some of the rules above. In SQLite, the schema of sqlite_stat1 is:\n**  <pre>\n**  &nbsp;     CREATE TABLE sqlite_stat1(tbl,idx,stat)  \n**  </pre>\n**\n** Even though sqlite_stat1 does not have a PRIMARY KEY, changes are \n** recorded for it as if the PRIMARY KEY is (tbl,idx). Additionally, changes \n** are recorded for rows for which (idx IS NULL) is true. However, for such\n** rows a zero-length blob (SQL value X'') is stored in the changeset or\n** patchset instead of a NULL value. This allows such changesets to be\n** manipulated by legacy implementations of sqlite3changeset_invert(),\n** concat() and similar.\n**\n** The sqlite3changeset_apply() function automatically converts the \n** zero-length blob back to a NULL value when updating the sqlite_stat1\n** table. However, if the application calls sqlite3changeset_new(),\n** sqlite3changeset_old() or sqlite3changeset_conflict on a changeset \n** iterator directly (including on a changeset iterator passed to a\n** conflict-handler callback) then the X'' value is returned. The application\n** must translate X'' to NULL itself if required.\n**\n** Legacy (older than 3.22.0) versions of the sessions module cannot capture\n** changes made to the sqlite_stat1 table. Legacy versions of the\n** sqlite3changeset_apply() function silently ignore any modifications to the\n** sqlite_stat1 table that are part of a changeset or patchset.\n*/\nSQLITE_API int sqlite3session_attach(\n  sqlite3_session *pSession,      /* Session object */\n  const char *zTab                /* Table name */\n);\n\n/*\n** CAPI3REF: Set a table filter on a Session Object.\n** METHOD: sqlite3_session\n**\n** The second argument (xFilter) is the \"filter callback\". For changes to rows \n** in tables that are not attached to the Session object, the filter is called\n** to determine whether changes to the table's rows should be tracked or not. \n** If xFilter returns 0, changes is not tracked. Note that once a table is \n** attached, xFilter will not be called again.\n*/\nSQLITE_API void sqlite3session_table_filter(\n  sqlite3_session *pSession,      /* Session object */\n  int(*xFilter)(\n    void *pCtx,                   /* Copy of third arg to _filter_table() */\n    const char *zTab              /* Table name */\n  ),\n  void *pCtx                      /* First argument passed to xFilter */\n);\n\n/*\n** CAPI3REF: Generate A Changeset From A Session Object\n** METHOD: sqlite3_session\n**\n** Obtain a changeset containing changes to the tables attached to the \n** session object passed as the first argument. If successful, \n** set *ppChangeset to point to a buffer containing the changeset \n** and *pnChangeset to the size of the changeset in bytes before returning\n** SQLITE_OK. If an error occurs, set both *ppChangeset and *pnChangeset to\n** zero and return an SQLite error code.\n**\n** A changeset consists of zero or more INSERT, UPDATE and/or DELETE changes,\n** each representing a change to a single row of an attached table. An INSERT\n** change contains the values of each field of a new database row. A DELETE\n** contains the original values of each field of a deleted database row. An\n** UPDATE change contains the original values of each field of an updated\n** database row along with the updated values for each updated non-primary-key\n** column. It is not possible for an UPDATE change to represent a change that\n** modifies the values of primary key columns. If such a change is made, it\n** is represented in a changeset as a DELETE followed by an INSERT.\n**\n** Changes are not recorded for rows that have NULL values stored in one or \n** more of their PRIMARY KEY columns. If such a row is inserted or deleted,\n** no corresponding change is present in the changesets returned by this\n** function. If an existing row with one or more NULL values stored in\n** PRIMARY KEY columns is updated so that all PRIMARY KEY columns are non-NULL,\n** only an INSERT is appears in the changeset. Similarly, if an existing row\n** with non-NULL PRIMARY KEY values is updated so that one or more of its\n** PRIMARY KEY columns are set to NULL, the resulting changeset contains a\n** DELETE change only.\n**\n** The contents of a changeset may be traversed using an iterator created\n** using the [sqlite3changeset_start()] API. A changeset may be applied to\n** a database with a compatible schema using the [sqlite3changeset_apply()]\n** API.\n**\n** Within a changeset generated by this function, all changes related to a\n** single table are grouped together. In other words, when iterating through\n** a changeset or when applying a changeset to a database, all changes related\n** to a single table are processed before moving on to the next table. Tables\n** are sorted in the same order in which they were attached (or auto-attached)\n** to the sqlite3_session object. The order in which the changes related to\n** a single table are stored is undefined.\n**\n** Following a successful call to this function, it is the responsibility of\n** the caller to eventually free the buffer that *ppChangeset points to using\n** [sqlite3_free()].\n**\n** <h3>Changeset Generation</h3>\n**\n** Once a table has been attached to a session object, the session object\n** records the primary key values of all new rows inserted into the table.\n** It also records the original primary key and other column values of any\n** deleted or updated rows. For each unique primary key value, data is only\n** recorded once - the first time a row with said primary key is inserted,\n** updated or deleted in the lifetime of the session.\n**\n** There is one exception to the previous paragraph: when a row is inserted,\n** updated or deleted, if one or more of its primary key columns contain a\n** NULL value, no record of the change is made.\n**\n** The session object therefore accumulates two types of records - those\n** that consist of primary key values only (created when the user inserts\n** a new record) and those that consist of the primary key values and the\n** original values of other table columns (created when the users deletes\n** or updates a record).\n**\n** When this function is called, the requested changeset is created using\n** both the accumulated records and the current contents of the database\n** file. Specifically:\n**\n** <ul>\n**   <li> For each record generated by an insert, the database is queried\n**        for a row with a matching primary key. If one is found, an INSERT\n**        change is added to the changeset. If no such row is found, no change \n**        is added to the changeset.\n**\n**   <li> For each record generated by an update or delete, the database is \n**        queried for a row with a matching primary key. If such a row is\n**        found and one or more of the non-primary key fields have been\n**        modified from their original values, an UPDATE change is added to \n**        the changeset. Or, if no such row is found in the table, a DELETE \n**        change is added to the changeset. If there is a row with a matching\n**        primary key in the database, but all fields contain their original\n**        values, no change is added to the changeset.\n** </ul>\n**\n** This means, amongst other things, that if a row is inserted and then later\n** deleted while a session object is active, neither the insert nor the delete\n** will be present in the changeset. Or if a row is deleted and then later a \n** row with the same primary key values inserted while a session object is\n** active, the resulting changeset will contain an UPDATE change instead of\n** a DELETE and an INSERT.\n**\n** When a session object is disabled (see the [sqlite3session_enable()] API),\n** it does not accumulate records when rows are inserted, updated or deleted.\n** This may appear to have some counter-intuitive effects if a single row\n** is written to more than once during a session. For example, if a row\n** is inserted while a session object is enabled, then later deleted while \n** the same session object is disabled, no INSERT record will appear in the\n** changeset, even though the delete took place while the session was disabled.\n** Or, if one field of a row is updated while a session is disabled, and \n** another field of the same row is updated while the session is enabled, the\n** resulting changeset will contain an UPDATE change that updates both fields.\n*/\nSQLITE_API int sqlite3session_changeset(\n  sqlite3_session *pSession,      /* Session object */\n  int *pnChangeset,               /* OUT: Size of buffer at *ppChangeset */\n  void **ppChangeset              /* OUT: Buffer containing changeset */\n);\n\n/*\n** CAPI3REF: Load The Difference Between Tables Into A Session\n** METHOD: sqlite3_session\n**\n** If it is not already attached to the session object passed as the first\n** argument, this function attaches table zTbl in the same manner as the\n** [sqlite3session_attach()] function. If zTbl does not exist, or if it\n** does not have a primary key, this function is a no-op (but does not return\n** an error).\n**\n** Argument zFromDb must be the name of a database (\"main\", \"temp\" etc.)\n** attached to the same database handle as the session object that contains \n** a table compatible with the table attached to the session by this function.\n** A table is considered compatible if it:\n**\n** <ul>\n**   <li> Has the same name,\n**   <li> Has the same set of columns declared in the same order, and\n**   <li> Has the same PRIMARY KEY definition.\n** </ul>\n**\n** If the tables are not compatible, SQLITE_SCHEMA is returned. If the tables\n** are compatible but do not have any PRIMARY KEY columns, it is not an error\n** but no changes are added to the session object. As with other session\n** APIs, tables without PRIMARY KEYs are simply ignored.\n**\n** This function adds a set of changes to the session object that could be\n** used to update the table in database zFrom (call this the \"from-table\") \n** so that its content is the same as the table attached to the session \n** object (call this the \"to-table\"). Specifically:\n**\n** <ul>\n**   <li> For each row (primary key) that exists in the to-table but not in \n**     the from-table, an INSERT record is added to the session object.\n**\n**   <li> For each row (primary key) that exists in the to-table but not in \n**     the from-table, a DELETE record is added to the session object.\n**\n**   <li> For each row (primary key) that exists in both tables, but features \n**     different non-PK values in each, an UPDATE record is added to the\n**     session.  \n** </ul>\n**\n** To clarify, if this function is called and then a changeset constructed\n** using [sqlite3session_changeset()], then after applying that changeset to \n** database zFrom the contents of the two compatible tables would be \n** identical.\n**\n** It an error if database zFrom does not exist or does not contain the\n** required compatible table.\n**\n** If the operation successful, SQLITE_OK is returned. Otherwise, an SQLite\n** error code. In this case, if argument pzErrMsg is not NULL, *pzErrMsg\n** may be set to point to a buffer containing an English language error \n** message. It is the responsibility of the caller to free this buffer using\n** sqlite3_free().\n*/\nSQLITE_API int sqlite3session_diff(\n  sqlite3_session *pSession,\n  const char *zFromDb,\n  const char *zTbl,\n  char **pzErrMsg\n);\n\n\n/*\n** CAPI3REF: Generate A Patchset From A Session Object\n** METHOD: sqlite3_session\n**\n** The differences between a patchset and a changeset are that:\n**\n** <ul>\n**   <li> DELETE records consist of the primary key fields only. The \n**        original values of other fields are omitted.\n**   <li> The original values of any modified fields are omitted from \n**        UPDATE records.\n** </ul>\n**\n** A patchset blob may be used with up to date versions of all \n** sqlite3changeset_xxx API functions except for sqlite3changeset_invert(), \n** which returns SQLITE_CORRUPT if it is passed a patchset. Similarly,\n** attempting to use a patchset blob with old versions of the\n** sqlite3changeset_xxx APIs also provokes an SQLITE_CORRUPT error. \n**\n** Because the non-primary key \"old.*\" fields are omitted, no \n** SQLITE_CHANGESET_DATA conflicts can be detected or reported if a patchset\n** is passed to the sqlite3changeset_apply() API. Other conflict types work\n** in the same way as for changesets.\n**\n** Changes within a patchset are ordered in the same way as for changesets\n** generated by the sqlite3session_changeset() function (i.e. all changes for\n** a single table are grouped together, tables appear in the order in which\n** they were attached to the session object).\n*/\nSQLITE_API int sqlite3session_patchset(\n  sqlite3_session *pSession,      /* Session object */\n  int *pnPatchset,                /* OUT: Size of buffer at *ppPatchset */\n  void **ppPatchset               /* OUT: Buffer containing patchset */\n);\n\n/*\n** CAPI3REF: Test if a changeset has recorded any changes.\n**\n** Return non-zero if no changes to attached tables have been recorded by \n** the session object passed as the first argument. Otherwise, if one or \n** more changes have been recorded, return zero.\n**\n** Even if this function returns zero, it is possible that calling\n** [sqlite3session_changeset()] on the session handle may still return a\n** changeset that contains no changes. This can happen when a row in \n** an attached table is modified and then later on the original values \n** are restored. However, if this function returns non-zero, then it is\n** guaranteed that a call to sqlite3session_changeset() will return a \n** changeset containing zero changes.\n*/\nSQLITE_API int sqlite3session_isempty(sqlite3_session *pSession);\n\n/*\n** CAPI3REF: Create An Iterator To Traverse A Changeset \n** CONSTRUCTOR: sqlite3_changeset_iter\n**\n** Create an iterator used to iterate through the contents of a changeset.\n** If successful, *pp is set to point to the iterator handle and SQLITE_OK\n** is returned. Otherwise, if an error occurs, *pp is set to zero and an\n** SQLite error code is returned.\n**\n** The following functions can be used to advance and query a changeset \n** iterator created by this function:\n**\n** <ul>\n**   <li> [sqlite3changeset_next()]\n**   <li> [sqlite3changeset_op()]\n**   <li> [sqlite3changeset_new()]\n**   <li> [sqlite3changeset_old()]\n** </ul>\n**\n** It is the responsibility of the caller to eventually destroy the iterator\n** by passing it to [sqlite3changeset_finalize()]. The buffer containing the\n** changeset (pChangeset) must remain valid until after the iterator is\n** destroyed.\n**\n** Assuming the changeset blob was created by one of the\n** [sqlite3session_changeset()], [sqlite3changeset_concat()] or\n** [sqlite3changeset_invert()] functions, all changes within the changeset \n** that apply to a single table are grouped together. This means that when \n** an application iterates through a changeset using an iterator created by \n** this function, all changes that relate to a single table are visited \n** consecutively. There is no chance that the iterator will visit a change \n** the applies to table X, then one for table Y, and then later on visit \n** another change for table X.\n**\n** The behavior of sqlite3changeset_start_v2() and its streaming equivalent\n** may be modified by passing a combination of\n** [SQLITE_CHANGESETSTART_INVERT | supported flags] as the 4th parameter.\n**\n** Note that the sqlite3changeset_start_v2() API is still <b>experimental</b>\n** and therefore subject to change.\n*/\nSQLITE_API int sqlite3changeset_start(\n  sqlite3_changeset_iter **pp,    /* OUT: New changeset iterator handle */\n  int nChangeset,                 /* Size of changeset blob in bytes */\n  void *pChangeset                /* Pointer to blob containing changeset */\n);\nSQLITE_API int sqlite3changeset_start_v2(\n  sqlite3_changeset_iter **pp,    /* OUT: New changeset iterator handle */\n  int nChangeset,                 /* Size of changeset blob in bytes */\n  void *pChangeset,               /* Pointer to blob containing changeset */\n  int flags                       /* SESSION_CHANGESETSTART_* flags */\n);\n\n/*\n** CAPI3REF: Flags for sqlite3changeset_start_v2\n**\n** The following flags may passed via the 4th parameter to\n** [sqlite3changeset_start_v2] and [sqlite3changeset_start_v2_strm]:\n**\n** <dt>SQLITE_CHANGESETAPPLY_INVERT <dd>\n**   Invert the changeset while iterating through it. This is equivalent to\n**   inverting a changeset using sqlite3changeset_invert() before applying it.\n**   It is an error to specify this flag with a patchset.\n*/\n#define SQLITE_CHANGESETSTART_INVERT        0x0002\n\n\n/*\n** CAPI3REF: Advance A Changeset Iterator\n** METHOD: sqlite3_changeset_iter\n**\n** This function may only be used with iterators created by function\n** [sqlite3changeset_start()]. If it is called on an iterator passed to\n** a conflict-handler callback by [sqlite3changeset_apply()], SQLITE_MISUSE\n** is returned and the call has no effect.\n**\n** Immediately after an iterator is created by sqlite3changeset_start(), it\n** does not point to any change in the changeset. Assuming the changeset\n** is not empty, the first call to this function advances the iterator to\n** point to the first change in the changeset. Each subsequent call advances\n** the iterator to point to the next change in the changeset (if any). If\n** no error occurs and the iterator points to a valid change after a call\n** to sqlite3changeset_next() has advanced it, SQLITE_ROW is returned. \n** Otherwise, if all changes in the changeset have already been visited,\n** SQLITE_DONE is returned.\n**\n** If an error occurs, an SQLite error code is returned. Possible error \n** codes include SQLITE_CORRUPT (if the changeset buffer is corrupt) or \n** SQLITE_NOMEM.\n*/\nSQLITE_API int sqlite3changeset_next(sqlite3_changeset_iter *pIter);\n\n/*\n** CAPI3REF: Obtain The Current Operation From A Changeset Iterator\n** METHOD: sqlite3_changeset_iter\n**\n** The pIter argument passed to this function may either be an iterator\n** passed to a conflict-handler by [sqlite3changeset_apply()], or an iterator\n** created by [sqlite3changeset_start()]. In the latter case, the most recent\n** call to [sqlite3changeset_next()] must have returned [SQLITE_ROW]. If this\n** is not the case, this function returns [SQLITE_MISUSE].\n**\n** If argument pzTab is not NULL, then *pzTab is set to point to a\n** nul-terminated utf-8 encoded string containing the name of the table\n** affected by the current change. The buffer remains valid until either\n** sqlite3changeset_next() is called on the iterator or until the \n** conflict-handler function returns. If pnCol is not NULL, then *pnCol is \n** set to the number of columns in the table affected by the change. If\n** pbIndirect is not NULL, then *pbIndirect is set to true (1) if the change\n** is an indirect change, or false (0) otherwise. See the documentation for\n** [sqlite3session_indirect()] for a description of direct and indirect\n** changes. Finally, if pOp is not NULL, then *pOp is set to one of \n** [SQLITE_INSERT], [SQLITE_DELETE] or [SQLITE_UPDATE], depending on the \n** type of change that the iterator currently points to.\n**\n** If no error occurs, SQLITE_OK is returned. If an error does occur, an\n** SQLite error code is returned. The values of the output variables may not\n** be trusted in this case.\n*/\nSQLITE_API int sqlite3changeset_op(\n  sqlite3_changeset_iter *pIter,  /* Iterator object */\n  const char **pzTab,             /* OUT: Pointer to table name */\n  int *pnCol,                     /* OUT: Number of columns in table */\n  int *pOp,                       /* OUT: SQLITE_INSERT, DELETE or UPDATE */\n  int *pbIndirect                 /* OUT: True for an 'indirect' change */\n);\n\n/*\n** CAPI3REF: Obtain The Primary Key Definition Of A Table\n** METHOD: sqlite3_changeset_iter\n**\n** For each modified table, a changeset includes the following:\n**\n** <ul>\n**   <li> The number of columns in the table, and\n**   <li> Which of those columns make up the tables PRIMARY KEY.\n** </ul>\n**\n** This function is used to find which columns comprise the PRIMARY KEY of\n** the table modified by the change that iterator pIter currently points to.\n** If successful, *pabPK is set to point to an array of nCol entries, where\n** nCol is the number of columns in the table. Elements of *pabPK are set to\n** 0x01 if the corresponding column is part of the tables primary key, or\n** 0x00 if it is not.\n**\n** If argument pnCol is not NULL, then *pnCol is set to the number of columns\n** in the table.\n**\n** If this function is called when the iterator does not point to a valid\n** entry, SQLITE_MISUSE is returned and the output variables zeroed. Otherwise,\n** SQLITE_OK is returned and the output variables populated as described\n** above.\n*/\nSQLITE_API int sqlite3changeset_pk(\n  sqlite3_changeset_iter *pIter,  /* Iterator object */\n  unsigned char **pabPK,          /* OUT: Array of boolean - true for PK cols */\n  int *pnCol                      /* OUT: Number of entries in output array */\n);\n\n/*\n** CAPI3REF: Obtain old.* Values From A Changeset Iterator\n** METHOD: sqlite3_changeset_iter\n**\n** The pIter argument passed to this function may either be an iterator\n** passed to a conflict-handler by [sqlite3changeset_apply()], or an iterator\n** created by [sqlite3changeset_start()]. In the latter case, the most recent\n** call to [sqlite3changeset_next()] must have returned SQLITE_ROW. \n** Furthermore, it may only be called if the type of change that the iterator\n** currently points to is either [SQLITE_DELETE] or [SQLITE_UPDATE]. Otherwise,\n** this function returns [SQLITE_MISUSE] and sets *ppValue to NULL.\n**\n** Argument iVal must be greater than or equal to 0, and less than the number\n** of columns in the table affected by the current change. Otherwise,\n** [SQLITE_RANGE] is returned and *ppValue is set to NULL.\n**\n** If successful, this function sets *ppValue to point to a protected\n** sqlite3_value object containing the iVal'th value from the vector of \n** original row values stored as part of the UPDATE or DELETE change and\n** returns SQLITE_OK. The name of the function comes from the fact that this \n** is similar to the \"old.*\" columns available to update or delete triggers.\n**\n** If some other error occurs (e.g. an OOM condition), an SQLite error code\n** is returned and *ppValue is set to NULL.\n*/\nSQLITE_API int sqlite3changeset_old(\n  sqlite3_changeset_iter *pIter,  /* Changeset iterator */\n  int iVal,                       /* Column number */\n  sqlite3_value **ppValue         /* OUT: Old value (or NULL pointer) */\n);\n\n/*\n** CAPI3REF: Obtain new.* Values From A Changeset Iterator\n** METHOD: sqlite3_changeset_iter\n**\n** The pIter argument passed to this function may either be an iterator\n** passed to a conflict-handler by [sqlite3changeset_apply()], or an iterator\n** created by [sqlite3changeset_start()]. In the latter case, the most recent\n** call to [sqlite3changeset_next()] must have returned SQLITE_ROW. \n** Furthermore, it may only be called if the type of change that the iterator\n** currently points to is either [SQLITE_UPDATE] or [SQLITE_INSERT]. Otherwise,\n** this function returns [SQLITE_MISUSE] and sets *ppValue to NULL.\n**\n** Argument iVal must be greater than or equal to 0, and less than the number\n** of columns in the table affected by the current change. Otherwise,\n** [SQLITE_RANGE] is returned and *ppValue is set to NULL.\n**\n** If successful, this function sets *ppValue to point to a protected\n** sqlite3_value object containing the iVal'th value from the vector of \n** new row values stored as part of the UPDATE or INSERT change and\n** returns SQLITE_OK. If the change is an UPDATE and does not include\n** a new value for the requested column, *ppValue is set to NULL and \n** SQLITE_OK returned. The name of the function comes from the fact that \n** this is similar to the \"new.*\" columns available to update or delete \n** triggers.\n**\n** If some other error occurs (e.g. an OOM condition), an SQLite error code\n** is returned and *ppValue is set to NULL.\n*/\nSQLITE_API int sqlite3changeset_new(\n  sqlite3_changeset_iter *pIter,  /* Changeset iterator */\n  int iVal,                       /* Column number */\n  sqlite3_value **ppValue         /* OUT: New value (or NULL pointer) */\n);\n\n/*\n** CAPI3REF: Obtain Conflicting Row Values From A Changeset Iterator\n** METHOD: sqlite3_changeset_iter\n**\n** This function should only be used with iterator objects passed to a\n** conflict-handler callback by [sqlite3changeset_apply()] with either\n** [SQLITE_CHANGESET_DATA] or [SQLITE_CHANGESET_CONFLICT]. If this function\n** is called on any other iterator, [SQLITE_MISUSE] is returned and *ppValue\n** is set to NULL.\n**\n** Argument iVal must be greater than or equal to 0, and less than the number\n** of columns in the table affected by the current change. Otherwise,\n** [SQLITE_RANGE] is returned and *ppValue is set to NULL.\n**\n** If successful, this function sets *ppValue to point to a protected\n** sqlite3_value object containing the iVal'th value from the \n** \"conflicting row\" associated with the current conflict-handler callback\n** and returns SQLITE_OK.\n**\n** If some other error occurs (e.g. an OOM condition), an SQLite error code\n** is returned and *ppValue is set to NULL.\n*/\nSQLITE_API int sqlite3changeset_conflict(\n  sqlite3_changeset_iter *pIter,  /* Changeset iterator */\n  int iVal,                       /* Column number */\n  sqlite3_value **ppValue         /* OUT: Value from conflicting row */\n);\n\n/*\n** CAPI3REF: Determine The Number Of Foreign Key Constraint Violations\n** METHOD: sqlite3_changeset_iter\n**\n** This function may only be called with an iterator passed to an\n** SQLITE_CHANGESET_FOREIGN_KEY conflict handler callback. In this case\n** it sets the output variable to the total number of known foreign key\n** violations in the destination database and returns SQLITE_OK.\n**\n** In all other cases this function returns SQLITE_MISUSE.\n*/\nSQLITE_API int sqlite3changeset_fk_conflicts(\n  sqlite3_changeset_iter *pIter,  /* Changeset iterator */\n  int *pnOut                      /* OUT: Number of FK violations */\n);\n\n\n/*\n** CAPI3REF: Finalize A Changeset Iterator\n** METHOD: sqlite3_changeset_iter\n**\n** This function is used to finalize an iterator allocated with\n** [sqlite3changeset_start()].\n**\n** This function should only be called on iterators created using the\n** [sqlite3changeset_start()] function. If an application calls this\n** function with an iterator passed to a conflict-handler by\n** [sqlite3changeset_apply()], [SQLITE_MISUSE] is immediately returned and the\n** call has no effect.\n**\n** If an error was encountered within a call to an sqlite3changeset_xxx()\n** function (for example an [SQLITE_CORRUPT] in [sqlite3changeset_next()] or an \n** [SQLITE_NOMEM] in [sqlite3changeset_new()]) then an error code corresponding\n** to that error is returned by this function. Otherwise, SQLITE_OK is\n** returned. This is to allow the following pattern (pseudo-code):\n**\n** <pre>\n**   sqlite3changeset_start();\n**   while( SQLITE_ROW==sqlite3changeset_next() ){\n**     // Do something with change.\n**   }\n**   rc = sqlite3changeset_finalize();\n**   if( rc!=SQLITE_OK ){\n**     // An error has occurred \n**   }\n** </pre>\n*/\nSQLITE_API int sqlite3changeset_finalize(sqlite3_changeset_iter *pIter);\n\n/*\n** CAPI3REF: Invert A Changeset\n**\n** This function is used to \"invert\" a changeset object. Applying an inverted\n** changeset to a database reverses the effects of applying the uninverted\n** changeset. Specifically:\n**\n** <ul>\n**   <li> Each DELETE change is changed to an INSERT, and\n**   <li> Each INSERT change is changed to a DELETE, and\n**   <li> For each UPDATE change, the old.* and new.* values are exchanged.\n** </ul>\n**\n** This function does not change the order in which changes appear within\n** the changeset. It merely reverses the sense of each individual change.\n**\n** If successful, a pointer to a buffer containing the inverted changeset\n** is stored in *ppOut, the size of the same buffer is stored in *pnOut, and\n** SQLITE_OK is returned. If an error occurs, both *pnOut and *ppOut are\n** zeroed and an SQLite error code returned.\n**\n** It is the responsibility of the caller to eventually call sqlite3_free()\n** on the *ppOut pointer to free the buffer allocation following a successful \n** call to this function.\n**\n** WARNING/TODO: This function currently assumes that the input is a valid\n** changeset. If it is not, the results are undefined.\n*/\nSQLITE_API int sqlite3changeset_invert(\n  int nIn, const void *pIn,       /* Input changeset */\n  int *pnOut, void **ppOut        /* OUT: Inverse of input */\n);\n\n/*\n** CAPI3REF: Concatenate Two Changeset Objects\n**\n** This function is used to concatenate two changesets, A and B, into a \n** single changeset. The result is a changeset equivalent to applying\n** changeset A followed by changeset B. \n**\n** This function combines the two input changesets using an \n** sqlite3_changegroup object. Calling it produces similar results as the\n** following code fragment:\n**\n** <pre>\n**   sqlite3_changegroup *pGrp;\n**   rc = sqlite3_changegroup_new(&pGrp);\n**   if( rc==SQLITE_OK ) rc = sqlite3changegroup_add(pGrp, nA, pA);\n**   if( rc==SQLITE_OK ) rc = sqlite3changegroup_add(pGrp, nB, pB);\n**   if( rc==SQLITE_OK ){\n**     rc = sqlite3changegroup_output(pGrp, pnOut, ppOut);\n**   }else{\n**     *ppOut = 0;\n**     *pnOut = 0;\n**   }\n** </pre>\n**\n** Refer to the sqlite3_changegroup documentation below for details.\n*/\nSQLITE_API int sqlite3changeset_concat(\n  int nA,                         /* Number of bytes in buffer pA */\n  void *pA,                       /* Pointer to buffer containing changeset A */\n  int nB,                         /* Number of bytes in buffer pB */\n  void *pB,                       /* Pointer to buffer containing changeset B */\n  int *pnOut,                     /* OUT: Number of bytes in output changeset */\n  void **ppOut                    /* OUT: Buffer containing output changeset */\n);\n\n\n/*\n** CAPI3REF: Changegroup Handle\n**\n** A changegroup is an object used to combine two or more \n** [changesets] or [patchsets]\n*/\ntypedef struct sqlite3_changegroup sqlite3_changegroup;\n\n/*\n** CAPI3REF: Create A New Changegroup Object\n** CONSTRUCTOR: sqlite3_changegroup\n**\n** An sqlite3_changegroup object is used to combine two or more changesets\n** (or patchsets) into a single changeset (or patchset). A single changegroup\n** object may combine changesets or patchsets, but not both. The output is\n** always in the same format as the input.\n**\n** If successful, this function returns SQLITE_OK and populates (*pp) with\n** a pointer to a new sqlite3_changegroup object before returning. The caller\n** should eventually free the returned object using a call to \n** sqlite3changegroup_delete(). If an error occurs, an SQLite error code\n** (i.e. SQLITE_NOMEM) is returned and *pp is set to NULL.\n**\n** The usual usage pattern for an sqlite3_changegroup object is as follows:\n**\n** <ul>\n**   <li> It is created using a call to sqlite3changegroup_new().\n**\n**   <li> Zero or more changesets (or patchsets) are added to the object\n**        by calling sqlite3changegroup_add().\n**\n**   <li> The result of combining all input changesets together is obtained \n**        by the application via a call to sqlite3changegroup_output().\n**\n**   <li> The object is deleted using a call to sqlite3changegroup_delete().\n** </ul>\n**\n** Any number of calls to add() and output() may be made between the calls to\n** new() and delete(), and in any order.\n**\n** As well as the regular sqlite3changegroup_add() and \n** sqlite3changegroup_output() functions, also available are the streaming\n** versions sqlite3changegroup_add_strm() and sqlite3changegroup_output_strm().\n*/\nSQLITE_API int sqlite3changegroup_new(sqlite3_changegroup **pp);\n\n/*\n** CAPI3REF: Add A Changeset To A Changegroup\n** METHOD: sqlite3_changegroup\n**\n** Add all changes within the changeset (or patchset) in buffer pData (size\n** nData bytes) to the changegroup. \n**\n** If the buffer contains a patchset, then all prior calls to this function\n** on the same changegroup object must also have specified patchsets. Or, if\n** the buffer contains a changeset, so must have the earlier calls to this\n** function. Otherwise, SQLITE_ERROR is returned and no changes are added\n** to the changegroup.\n**\n** Rows within the changeset and changegroup are identified by the values in\n** their PRIMARY KEY columns. A change in the changeset is considered to\n** apply to the same row as a change already present in the changegroup if\n** the two rows have the same primary key.\n**\n** Changes to rows that do not already appear in the changegroup are\n** simply copied into it. Or, if both the new changeset and the changegroup\n** contain changes that apply to a single row, the final contents of the\n** changegroup depends on the type of each change, as follows:\n**\n** <table border=1 style=\"margin-left:8ex;margin-right:8ex\">\n**   <tr><th style=\"white-space:pre\">Existing Change  </th>\n**       <th style=\"white-space:pre\">New Change       </th>\n**       <th>Output Change\n**   <tr><td>INSERT <td>INSERT <td>\n**       The new change is ignored. This case does not occur if the new\n**       changeset was recorded immediately after the changesets already\n**       added to the changegroup.\n**   <tr><td>INSERT <td>UPDATE <td>\n**       The INSERT change remains in the changegroup. The values in the \n**       INSERT change are modified as if the row was inserted by the\n**       existing change and then updated according to the new change.\n**   <tr><td>INSERT <td>DELETE <td>\n**       The existing INSERT is removed from the changegroup. The DELETE is\n**       not added.\n**   <tr><td>UPDATE <td>INSERT <td>\n**       The new change is ignored. This case does not occur if the new\n**       changeset was recorded immediately after the changesets already\n**       added to the changegroup.\n**   <tr><td>UPDATE <td>UPDATE <td>\n**       The existing UPDATE remains within the changegroup. It is amended \n**       so that the accompanying values are as if the row was updated once \n**       by the existing change and then again by the new change.\n**   <tr><td>UPDATE <td>DELETE <td>\n**       The existing UPDATE is replaced by the new DELETE within the\n**       changegroup.\n**   <tr><td>DELETE <td>INSERT <td>\n**       If one or more of the column values in the row inserted by the\n**       new change differ from those in the row deleted by the existing \n**       change, the existing DELETE is replaced by an UPDATE within the\n**       changegroup. Otherwise, if the inserted row is exactly the same \n**       as the deleted row, the existing DELETE is simply discarded.\n**   <tr><td>DELETE <td>UPDATE <td>\n**       The new change is ignored. This case does not occur if the new\n**       changeset was recorded immediately after the changesets already\n**       added to the changegroup.\n**   <tr><td>DELETE <td>DELETE <td>\n**       The new change is ignored. This case does not occur if the new\n**       changeset was recorded immediately after the changesets already\n**       added to the changegroup.\n** </table>\n**\n** If the new changeset contains changes to a table that is already present\n** in the changegroup, then the number of columns and the position of the\n** primary key columns for the table must be consistent. If this is not the\n** case, this function fails with SQLITE_SCHEMA. If the input changeset\n** appears to be corrupt and the corruption is detected, SQLITE_CORRUPT is\n** returned. Or, if an out-of-memory condition occurs during processing, this\n** function returns SQLITE_NOMEM. In all cases, if an error occurs the\n** final contents of the changegroup is undefined.\n**\n** If no error occurs, SQLITE_OK is returned.\n*/\nSQLITE_API int sqlite3changegroup_add(sqlite3_changegroup*, int nData, void *pData);\n\n/*\n** CAPI3REF: Obtain A Composite Changeset From A Changegroup\n** METHOD: sqlite3_changegroup\n**\n** Obtain a buffer containing a changeset (or patchset) representing the\n** current contents of the changegroup. If the inputs to the changegroup\n** were themselves changesets, the output is a changeset. Or, if the\n** inputs were patchsets, the output is also a patchset.\n**\n** As with the output of the sqlite3session_changeset() and\n** sqlite3session_patchset() functions, all changes related to a single\n** table are grouped together in the output of this function. Tables appear\n** in the same order as for the very first changeset added to the changegroup.\n** If the second or subsequent changesets added to the changegroup contain\n** changes for tables that do not appear in the first changeset, they are\n** appended onto the end of the output changeset, again in the order in\n** which they are first encountered.\n**\n** If an error occurs, an SQLite error code is returned and the output\n** variables (*pnData) and (*ppData) are set to 0. Otherwise, SQLITE_OK\n** is returned and the output variables are set to the size of and a \n** pointer to the output buffer, respectively. In this case it is the\n** responsibility of the caller to eventually free the buffer using a\n** call to sqlite3_free().\n*/\nSQLITE_API int sqlite3changegroup_output(\n  sqlite3_changegroup*,\n  int *pnData,                    /* OUT: Size of output buffer in bytes */\n  void **ppData                   /* OUT: Pointer to output buffer */\n);\n\n/*\n** CAPI3REF: Delete A Changegroup Object\n** DESTRUCTOR: sqlite3_changegroup\n*/\nSQLITE_API void sqlite3changegroup_delete(sqlite3_changegroup*);\n\n/*\n** CAPI3REF: Apply A Changeset To A Database\n**\n** Apply a changeset or patchset to a database. These functions attempt to\n** update the \"main\" database attached to handle db with the changes found in\n** the changeset passed via the second and third arguments. \n**\n** The fourth argument (xFilter) passed to these functions is the \"filter\n** callback\". If it is not NULL, then for each table affected by at least one\n** change in the changeset, the filter callback is invoked with\n** the table name as the second argument, and a copy of the context pointer\n** passed as the sixth argument as the first. If the \"filter callback\"\n** returns zero, then no attempt is made to apply any changes to the table.\n** Otherwise, if the return value is non-zero or the xFilter argument to\n** is NULL, all changes related to the table are attempted.\n**\n** For each table that is not excluded by the filter callback, this function \n** tests that the target database contains a compatible table. A table is \n** considered compatible if all of the following are true:\n**\n** <ul>\n**   <li> The table has the same name as the name recorded in the \n**        changeset, and\n**   <li> The table has at least as many columns as recorded in the \n**        changeset, and\n**   <li> The table has primary key columns in the same position as \n**        recorded in the changeset.\n** </ul>\n**\n** If there is no compatible table, it is not an error, but none of the\n** changes associated with the table are applied. A warning message is issued\n** via the sqlite3_log() mechanism with the error code SQLITE_SCHEMA. At most\n** one such warning is issued for each table in the changeset.\n**\n** For each change for which there is a compatible table, an attempt is made \n** to modify the table contents according to the UPDATE, INSERT or DELETE \n** change. If a change cannot be applied cleanly, the conflict handler \n** function passed as the fifth argument to sqlite3changeset_apply() may be \n** invoked. A description of exactly when the conflict handler is invoked for \n** each type of change is below.\n**\n** Unlike the xFilter argument, xConflict may not be passed NULL. The results\n** of passing anything other than a valid function pointer as the xConflict\n** argument are undefined.\n**\n** Each time the conflict handler function is invoked, it must return one\n** of [SQLITE_CHANGESET_OMIT], [SQLITE_CHANGESET_ABORT] or \n** [SQLITE_CHANGESET_REPLACE]. SQLITE_CHANGESET_REPLACE may only be returned\n** if the second argument passed to the conflict handler is either\n** SQLITE_CHANGESET_DATA or SQLITE_CHANGESET_CONFLICT. If the conflict-handler\n** returns an illegal value, any changes already made are rolled back and\n** the call to sqlite3changeset_apply() returns SQLITE_MISUSE. Different \n** actions are taken by sqlite3changeset_apply() depending on the value\n** returned by each invocation of the conflict-handler function. Refer to\n** the documentation for the three \n** [SQLITE_CHANGESET_OMIT|available return values] for details.\n**\n** <dl>\n** <dt>DELETE Changes<dd>\n**   For each DELETE change, the function checks if the target database \n**   contains a row with the same primary key value (or values) as the \n**   original row values stored in the changeset. If it does, and the values \n**   stored in all non-primary key columns also match the values stored in \n**   the changeset the row is deleted from the target database.\n**\n**   If a row with matching primary key values is found, but one or more of\n**   the non-primary key fields contains a value different from the original\n**   row value stored in the changeset, the conflict-handler function is\n**   invoked with [SQLITE_CHANGESET_DATA] as the second argument. If the\n**   database table has more columns than are recorded in the changeset,\n**   only the values of those non-primary key fields are compared against\n**   the current database contents - any trailing database table columns\n**   are ignored.\n**\n**   If no row with matching primary key values is found in the database,\n**   the conflict-handler function is invoked with [SQLITE_CHANGESET_NOTFOUND]\n**   passed as the second argument.\n**\n**   If the DELETE operation is attempted, but SQLite returns SQLITE_CONSTRAINT\n**   (which can only happen if a foreign key constraint is violated), the\n**   conflict-handler function is invoked with [SQLITE_CHANGESET_CONSTRAINT]\n**   passed as the second argument. This includes the case where the DELETE\n**   operation is attempted because an earlier call to the conflict handler\n**   function returned [SQLITE_CHANGESET_REPLACE].\n**\n** <dt>INSERT Changes<dd>\n**   For each INSERT change, an attempt is made to insert the new row into\n**   the database. If the changeset row contains fewer fields than the\n**   database table, the trailing fields are populated with their default\n**   values.\n**\n**   If the attempt to insert the row fails because the database already \n**   contains a row with the same primary key values, the conflict handler\n**   function is invoked with the second argument set to \n**   [SQLITE_CHANGESET_CONFLICT].\n**\n**   If the attempt to insert the row fails because of some other constraint\n**   violation (e.g. NOT NULL or UNIQUE), the conflict handler function is \n**   invoked with the second argument set to [SQLITE_CHANGESET_CONSTRAINT].\n**   This includes the case where the INSERT operation is re-attempted because \n**   an earlier call to the conflict handler function returned \n**   [SQLITE_CHANGESET_REPLACE].\n**\n** <dt>UPDATE Changes<dd>\n**   For each UPDATE change, the function checks if the target database \n**   contains a row with the same primary key value (or values) as the \n**   original row values stored in the changeset. If it does, and the values \n**   stored in all modified non-primary key columns also match the values\n**   stored in the changeset the row is updated within the target database.\n**\n**   If a row with matching primary key values is found, but one or more of\n**   the modified non-primary key fields contains a value different from an\n**   original row value stored in the changeset, the conflict-handler function\n**   is invoked with [SQLITE_CHANGESET_DATA] as the second argument. Since\n**   UPDATE changes only contain values for non-primary key fields that are\n**   to be modified, only those fields need to match the original values to\n**   avoid the SQLITE_CHANGESET_DATA conflict-handler callback.\n**\n**   If no row with matching primary key values is found in the database,\n**   the conflict-handler function is invoked with [SQLITE_CHANGESET_NOTFOUND]\n**   passed as the second argument.\n**\n**   If the UPDATE operation is attempted, but SQLite returns \n**   SQLITE_CONSTRAINT, the conflict-handler function is invoked with \n**   [SQLITE_CHANGESET_CONSTRAINT] passed as the second argument.\n**   This includes the case where the UPDATE operation is attempted after \n**   an earlier call to the conflict handler function returned\n**   [SQLITE_CHANGESET_REPLACE].  \n** </dl>\n**\n** It is safe to execute SQL statements, including those that write to the\n** table that the callback related to, from within the xConflict callback.\n** This can be used to further customize the applications conflict\n** resolution strategy.\n**\n** All changes made by these functions are enclosed in a savepoint transaction.\n** If any other error (aside from a constraint failure when attempting to\n** write to the target database) occurs, then the savepoint transaction is\n** rolled back, restoring the target database to its original state, and an \n** SQLite error code returned.\n**\n** If the output parameters (ppRebase) and (pnRebase) are non-NULL and\n** the input is a changeset (not a patchset), then sqlite3changeset_apply_v2()\n** may set (*ppRebase) to point to a \"rebase\" that may be used with the \n** sqlite3_rebaser APIs buffer before returning. In this case (*pnRebase)\n** is set to the size of the buffer in bytes. It is the responsibility of the\n** caller to eventually free any such buffer using sqlite3_free(). The buffer\n** is only allocated and populated if one or more conflicts were encountered\n** while applying the patchset. See comments surrounding the sqlite3_rebaser\n** APIs for further details.\n**\n** The behavior of sqlite3changeset_apply_v2() and its streaming equivalent\n** may be modified by passing a combination of\n** [SQLITE_CHANGESETAPPLY_NOSAVEPOINT | supported flags] as the 9th parameter.\n**\n** Note that the sqlite3changeset_apply_v2() API is still <b>experimental</b>\n** and therefore subject to change.\n*/\nSQLITE_API int sqlite3changeset_apply(\n  sqlite3 *db,                    /* Apply change to \"main\" db of this handle */\n  int nChangeset,                 /* Size of changeset in bytes */\n  void *pChangeset,               /* Changeset blob */\n  int(*xFilter)(\n    void *pCtx,                   /* Copy of sixth arg to _apply() */\n    const char *zTab              /* Table name */\n  ),\n  int(*xConflict)(\n    void *pCtx,                   /* Copy of sixth arg to _apply() */\n    int eConflict,                /* DATA, MISSING, CONFLICT, CONSTRAINT */\n    sqlite3_changeset_iter *p     /* Handle describing change and conflict */\n  ),\n  void *pCtx                      /* First argument passed to xConflict */\n);\nSQLITE_API int sqlite3changeset_apply_v2(\n  sqlite3 *db,                    /* Apply change to \"main\" db of this handle */\n  int nChangeset,                 /* Size of changeset in bytes */\n  void *pChangeset,               /* Changeset blob */\n  int(*xFilter)(\n    void *pCtx,                   /* Copy of sixth arg to _apply() */\n    const char *zTab              /* Table name */\n  ),\n  int(*xConflict)(\n    void *pCtx,                   /* Copy of sixth arg to _apply() */\n    int eConflict,                /* DATA, MISSING, CONFLICT, CONSTRAINT */\n    sqlite3_changeset_iter *p     /* Handle describing change and conflict */\n  ),\n  void *pCtx,                     /* First argument passed to xConflict */\n  void **ppRebase, int *pnRebase, /* OUT: Rebase data */\n  int flags                       /* SESSION_CHANGESETAPPLY_* flags */\n);\n\n/*\n** CAPI3REF: Flags for sqlite3changeset_apply_v2\n**\n** The following flags may passed via the 9th parameter to\n** [sqlite3changeset_apply_v2] and [sqlite3changeset_apply_v2_strm]:\n**\n** <dl>\n** <dt>SQLITE_CHANGESETAPPLY_NOSAVEPOINT <dd>\n**   Usually, the sessions module encloses all operations performed by\n**   a single call to apply_v2() or apply_v2_strm() in a [SAVEPOINT]. The\n**   SAVEPOINT is committed if the changeset or patchset is successfully\n**   applied, or rolled back if an error occurs. Specifying this flag\n**   causes the sessions module to omit this savepoint. In this case, if the\n**   caller has an open transaction or savepoint when apply_v2() is called, \n**   it may revert the partially applied changeset by rolling it back.\n**\n** <dt>SQLITE_CHANGESETAPPLY_INVERT <dd>\n**   Invert the changeset before applying it. This is equivalent to inverting\n**   a changeset using sqlite3changeset_invert() before applying it. It is\n**   an error to specify this flag with a patchset.\n*/\n#define SQLITE_CHANGESETAPPLY_NOSAVEPOINT   0x0001\n#define SQLITE_CHANGESETAPPLY_INVERT        0x0002\n\n/* \n** CAPI3REF: Constants Passed To The Conflict Handler\n**\n** Values that may be passed as the second argument to a conflict-handler.\n**\n** <dl>\n** <dt>SQLITE_CHANGESET_DATA<dd>\n**   The conflict handler is invoked with CHANGESET_DATA as the second argument\n**   when processing a DELETE or UPDATE change if a row with the required\n**   PRIMARY KEY fields is present in the database, but one or more other \n**   (non primary-key) fields modified by the update do not contain the \n**   expected \"before\" values.\n** \n**   The conflicting row, in this case, is the database row with the matching\n**   primary key.\n** \n** <dt>SQLITE_CHANGESET_NOTFOUND<dd>\n**   The conflict handler is invoked with CHANGESET_NOTFOUND as the second\n**   argument when processing a DELETE or UPDATE change if a row with the\n**   required PRIMARY KEY fields is not present in the database.\n** \n**   There is no conflicting row in this case. The results of invoking the\n**   sqlite3changeset_conflict() API are undefined.\n** \n** <dt>SQLITE_CHANGESET_CONFLICT<dd>\n**   CHANGESET_CONFLICT is passed as the second argument to the conflict\n**   handler while processing an INSERT change if the operation would result \n**   in duplicate primary key values.\n** \n**   The conflicting row in this case is the database row with the matching\n**   primary key.\n**\n** <dt>SQLITE_CHANGESET_FOREIGN_KEY<dd>\n**   If foreign key handling is enabled, and applying a changeset leaves the\n**   database in a state containing foreign key violations, the conflict \n**   handler is invoked with CHANGESET_FOREIGN_KEY as the second argument\n**   exactly once before the changeset is committed. If the conflict handler\n**   returns CHANGESET_OMIT, the changes, including those that caused the\n**   foreign key constraint violation, are committed. Or, if it returns\n**   CHANGESET_ABORT, the changeset is rolled back.\n**\n**   No current or conflicting row information is provided. The only function\n**   it is possible to call on the supplied sqlite3_changeset_iter handle\n**   is sqlite3changeset_fk_conflicts().\n** \n** <dt>SQLITE_CHANGESET_CONSTRAINT<dd>\n**   If any other constraint violation occurs while applying a change (i.e. \n**   a UNIQUE, CHECK or NOT NULL constraint), the conflict handler is \n**   invoked with CHANGESET_CONSTRAINT as the second argument.\n** \n**   There is no conflicting row in this case. The results of invoking the\n**   sqlite3changeset_conflict() API are undefined.\n**\n** </dl>\n*/\n#define SQLITE_CHANGESET_DATA        1\n#define SQLITE_CHANGESET_NOTFOUND    2\n#define SQLITE_CHANGESET_CONFLICT    3\n#define SQLITE_CHANGESET_CONSTRAINT  4\n#define SQLITE_CHANGESET_FOREIGN_KEY 5\n\n/* \n** CAPI3REF: Constants Returned By The Conflict Handler\n**\n** A conflict handler callback must return one of the following three values.\n**\n** <dl>\n** <dt>SQLITE_CHANGESET_OMIT<dd>\n**   If a conflict handler returns this value no special action is taken. The\n**   change that caused the conflict is not applied. The session module \n**   continues to the next change in the changeset.\n**\n** <dt>SQLITE_CHANGESET_REPLACE<dd>\n**   This value may only be returned if the second argument to the conflict\n**   handler was SQLITE_CHANGESET_DATA or SQLITE_CHANGESET_CONFLICT. If this\n**   is not the case, any changes applied so far are rolled back and the \n**   call to sqlite3changeset_apply() returns SQLITE_MISUSE.\n**\n**   If CHANGESET_REPLACE is returned by an SQLITE_CHANGESET_DATA conflict\n**   handler, then the conflicting row is either updated or deleted, depending\n**   on the type of change.\n**\n**   If CHANGESET_REPLACE is returned by an SQLITE_CHANGESET_CONFLICT conflict\n**   handler, then the conflicting row is removed from the database and a\n**   second attempt to apply the change is made. If this second attempt fails,\n**   the original row is restored to the database before continuing.\n**\n** <dt>SQLITE_CHANGESET_ABORT<dd>\n**   If this value is returned, any changes applied so far are rolled back \n**   and the call to sqlite3changeset_apply() returns SQLITE_ABORT.\n** </dl>\n*/\n#define SQLITE_CHANGESET_OMIT       0\n#define SQLITE_CHANGESET_REPLACE    1\n#define SQLITE_CHANGESET_ABORT      2\n\n/* \n** CAPI3REF: Rebasing changesets\n** EXPERIMENTAL\n**\n** Suppose there is a site hosting a database in state S0. And that\n** modifications are made that move that database to state S1 and a\n** changeset recorded (the \"local\" changeset). Then, a changeset based\n** on S0 is received from another site (the \"remote\" changeset) and \n** applied to the database. The database is then in state \n** (S1+\"remote\"), where the exact state depends on any conflict\n** resolution decisions (OMIT or REPLACE) made while applying \"remote\".\n** Rebasing a changeset is to update it to take those conflict \n** resolution decisions into account, so that the same conflicts\n** do not have to be resolved elsewhere in the network. \n**\n** For example, if both the local and remote changesets contain an\n** INSERT of the same key on \"CREATE TABLE t1(a PRIMARY KEY, b)\":\n**\n**   local:  INSERT INTO t1 VALUES(1, 'v1');\n**   remote: INSERT INTO t1 VALUES(1, 'v2');\n**\n** and the conflict resolution is REPLACE, then the INSERT change is\n** removed from the local changeset (it was overridden). Or, if the\n** conflict resolution was \"OMIT\", then the local changeset is modified\n** to instead contain:\n**\n**           UPDATE t1 SET b = 'v2' WHERE a=1;\n**\n** Changes within the local changeset are rebased as follows:\n**\n** <dl>\n** <dt>Local INSERT<dd>\n**   This may only conflict with a remote INSERT. If the conflict \n**   resolution was OMIT, then add an UPDATE change to the rebased\n**   changeset. Or, if the conflict resolution was REPLACE, add\n**   nothing to the rebased changeset.\n**\n** <dt>Local DELETE<dd>\n**   This may conflict with a remote UPDATE or DELETE. In both cases the\n**   only possible resolution is OMIT. If the remote operation was a\n**   DELETE, then add no change to the rebased changeset. If the remote\n**   operation was an UPDATE, then the old.* fields of change are updated\n**   to reflect the new.* values in the UPDATE.\n**\n** <dt>Local UPDATE<dd>\n**   This may conflict with a remote UPDATE or DELETE. If it conflicts\n**   with a DELETE, and the conflict resolution was OMIT, then the update\n**   is changed into an INSERT. Any undefined values in the new.* record\n**   from the update change are filled in using the old.* values from\n**   the conflicting DELETE. Or, if the conflict resolution was REPLACE,\n**   the UPDATE change is simply omitted from the rebased changeset.\n**\n**   If conflict is with a remote UPDATE and the resolution is OMIT, then\n**   the old.* values are rebased using the new.* values in the remote\n**   change. Or, if the resolution is REPLACE, then the change is copied\n**   into the rebased changeset with updates to columns also updated by\n**   the conflicting remote UPDATE removed. If this means no columns would \n**   be updated, the change is omitted.\n** </dl>\n**\n** A local change may be rebased against multiple remote changes \n** simultaneously. If a single key is modified by multiple remote \n** changesets, they are combined as follows before the local changeset\n** is rebased:\n**\n** <ul>\n**    <li> If there has been one or more REPLACE resolutions on a\n**         key, it is rebased according to a REPLACE.\n**\n**    <li> If there have been no REPLACE resolutions on a key, then\n**         the local changeset is rebased according to the most recent\n**         of the OMIT resolutions.\n** </ul>\n**\n** Note that conflict resolutions from multiple remote changesets are \n** combined on a per-field basis, not per-row. This means that in the \n** case of multiple remote UPDATE operations, some fields of a single \n** local change may be rebased for REPLACE while others are rebased for \n** OMIT.\n**\n** In order to rebase a local changeset, the remote changeset must first\n** be applied to the local database using sqlite3changeset_apply_v2() and\n** the buffer of rebase information captured. Then:\n**\n** <ol>\n**   <li> An sqlite3_rebaser object is created by calling \n**        sqlite3rebaser_create().\n**   <li> The new object is configured with the rebase buffer obtained from\n**        sqlite3changeset_apply_v2() by calling sqlite3rebaser_configure().\n**        If the local changeset is to be rebased against multiple remote\n**        changesets, then sqlite3rebaser_configure() should be called\n**        multiple times, in the same order that the multiple\n**        sqlite3changeset_apply_v2() calls were made.\n**   <li> Each local changeset is rebased by calling sqlite3rebaser_rebase().\n**   <li> The sqlite3_rebaser object is deleted by calling\n**        sqlite3rebaser_delete().\n** </ol>\n*/\ntypedef struct sqlite3_rebaser sqlite3_rebaser;\n\n/*\n** CAPI3REF: Create a changeset rebaser object.\n** EXPERIMENTAL\n**\n** Allocate a new changeset rebaser object. If successful, set (*ppNew) to\n** point to the new object and return SQLITE_OK. Otherwise, if an error\n** occurs, return an SQLite error code (e.g. SQLITE_NOMEM) and set (*ppNew) \n** to NULL. \n*/\nSQLITE_API int sqlite3rebaser_create(sqlite3_rebaser **ppNew);\n\n/*\n** CAPI3REF: Configure a changeset rebaser object.\n** EXPERIMENTAL\n**\n** Configure the changeset rebaser object to rebase changesets according\n** to the conflict resolutions described by buffer pRebase (size nRebase\n** bytes), which must have been obtained from a previous call to\n** sqlite3changeset_apply_v2().\n*/\nSQLITE_API int sqlite3rebaser_configure(\n  sqlite3_rebaser*, \n  int nRebase, const void *pRebase\n); \n\n/*\n** CAPI3REF: Rebase a changeset\n** EXPERIMENTAL\n**\n** Argument pIn must point to a buffer containing a changeset nIn bytes\n** in size. This function allocates and populates a buffer with a copy\n** of the changeset rebased rebased according to the configuration of the\n** rebaser object passed as the first argument. If successful, (*ppOut)\n** is set to point to the new buffer containing the rebased changset and \n** (*pnOut) to its size in bytes and SQLITE_OK returned. It is the\n** responsibility of the caller to eventually free the new buffer using\n** sqlite3_free(). Otherwise, if an error occurs, (*ppOut) and (*pnOut)\n** are set to zero and an SQLite error code returned.\n*/\nSQLITE_API int sqlite3rebaser_rebase(\n  sqlite3_rebaser*,\n  int nIn, const void *pIn, \n  int *pnOut, void **ppOut \n);\n\n/*\n** CAPI3REF: Delete a changeset rebaser object.\n** EXPERIMENTAL\n**\n** Delete the changeset rebaser object and all associated resources. There\n** should be one call to this function for each successful invocation\n** of sqlite3rebaser_create().\n*/\nSQLITE_API void sqlite3rebaser_delete(sqlite3_rebaser *p); \n\n/*\n** CAPI3REF: Streaming Versions of API functions.\n**\n** The six streaming API xxx_strm() functions serve similar purposes to the \n** corresponding non-streaming API functions:\n**\n** <table border=1 style=\"margin-left:8ex;margin-right:8ex\">\n**   <tr><th>Streaming function<th>Non-streaming equivalent</th>\n**   <tr><td>sqlite3changeset_apply_strm<td>[sqlite3changeset_apply] \n**   <tr><td>sqlite3changeset_apply_strm_v2<td>[sqlite3changeset_apply_v2] \n**   <tr><td>sqlite3changeset_concat_strm<td>[sqlite3changeset_concat] \n**   <tr><td>sqlite3changeset_invert_strm<td>[sqlite3changeset_invert] \n**   <tr><td>sqlite3changeset_start_strm<td>[sqlite3changeset_start] \n**   <tr><td>sqlite3session_changeset_strm<td>[sqlite3session_changeset] \n**   <tr><td>sqlite3session_patchset_strm<td>[sqlite3session_patchset] \n** </table>\n**\n** Non-streaming functions that accept changesets (or patchsets) as input\n** require that the entire changeset be stored in a single buffer in memory. \n** Similarly, those that return a changeset or patchset do so by returning \n** a pointer to a single large buffer allocated using sqlite3_malloc(). \n** Normally this is convenient. However, if an application running in a \n** low-memory environment is required to handle very large changesets, the\n** large contiguous memory allocations required can become onerous.\n**\n** In order to avoid this problem, instead of a single large buffer, input\n** is passed to a streaming API functions by way of a callback function that\n** the sessions module invokes to incrementally request input data as it is\n** required. In all cases, a pair of API function parameters such as\n**\n**  <pre>\n**  &nbsp;     int nChangeset,\n**  &nbsp;     void *pChangeset,\n**  </pre>\n**\n** Is replaced by:\n**\n**  <pre>\n**  &nbsp;     int (*xInput)(void *pIn, void *pData, int *pnData),\n**  &nbsp;     void *pIn,\n**  </pre>\n**\n** Each time the xInput callback is invoked by the sessions module, the first\n** argument passed is a copy of the supplied pIn context pointer. The second \n** argument, pData, points to a buffer (*pnData) bytes in size. Assuming no \n** error occurs the xInput method should copy up to (*pnData) bytes of data \n** into the buffer and set (*pnData) to the actual number of bytes copied \n** before returning SQLITE_OK. If the input is completely exhausted, (*pnData) \n** should be set to zero to indicate this. Or, if an error occurs, an SQLite \n** error code should be returned. In all cases, if an xInput callback returns\n** an error, all processing is abandoned and the streaming API function\n** returns a copy of the error code to the caller.\n**\n** In the case of sqlite3changeset_start_strm(), the xInput callback may be\n** invoked by the sessions module at any point during the lifetime of the\n** iterator. If such an xInput callback returns an error, the iterator enters\n** an error state, whereby all subsequent calls to iterator functions \n** immediately fail with the same error code as returned by xInput.\n**\n** Similarly, streaming API functions that return changesets (or patchsets)\n** return them in chunks by way of a callback function instead of via a\n** pointer to a single large buffer. In this case, a pair of parameters such\n** as:\n**\n**  <pre>\n**  &nbsp;     int *pnChangeset,\n**  &nbsp;     void **ppChangeset,\n**  </pre>\n**\n** Is replaced by:\n**\n**  <pre>\n**  &nbsp;     int (*xOutput)(void *pOut, const void *pData, int nData),\n**  &nbsp;     void *pOut\n**  </pre>\n**\n** The xOutput callback is invoked zero or more times to return data to\n** the application. The first parameter passed to each call is a copy of the\n** pOut pointer supplied by the application. The second parameter, pData,\n** points to a buffer nData bytes in size containing the chunk of output\n** data being returned. If the xOutput callback successfully processes the\n** supplied data, it should return SQLITE_OK to indicate success. Otherwise,\n** it should return some other SQLite error code. In this case processing\n** is immediately abandoned and the streaming API function returns a copy\n** of the xOutput error code to the application.\n**\n** The sessions module never invokes an xOutput callback with the third \n** parameter set to a value less than or equal to zero. Other than this,\n** no guarantees are made as to the size of the chunks of data returned.\n*/\nSQLITE_API int sqlite3changeset_apply_strm(\n  sqlite3 *db,                    /* Apply change to \"main\" db of this handle */\n  int (*xInput)(void *pIn, void *pData, int *pnData), /* Input function */\n  void *pIn,                                          /* First arg for xInput */\n  int(*xFilter)(\n    void *pCtx,                   /* Copy of sixth arg to _apply() */\n    const char *zTab              /* Table name */\n  ),\n  int(*xConflict)(\n    void *pCtx,                   /* Copy of sixth arg to _apply() */\n    int eConflict,                /* DATA, MISSING, CONFLICT, CONSTRAINT */\n    sqlite3_changeset_iter *p     /* Handle describing change and conflict */\n  ),\n  void *pCtx                      /* First argument passed to xConflict */\n);\nSQLITE_API int sqlite3changeset_apply_v2_strm(\n  sqlite3 *db,                    /* Apply change to \"main\" db of this handle */\n  int (*xInput)(void *pIn, void *pData, int *pnData), /* Input function */\n  void *pIn,                                          /* First arg for xInput */\n  int(*xFilter)(\n    void *pCtx,                   /* Copy of sixth arg to _apply() */\n    const char *zTab              /* Table name */\n  ),\n  int(*xConflict)(\n    void *pCtx,                   /* Copy of sixth arg to _apply() */\n    int eConflict,                /* DATA, MISSING, CONFLICT, CONSTRAINT */\n    sqlite3_changeset_iter *p     /* Handle describing change and conflict */\n  ),\n  void *pCtx,                     /* First argument passed to xConflict */\n  void **ppRebase, int *pnRebase,\n  int flags\n);\nSQLITE_API int sqlite3changeset_concat_strm(\n  int (*xInputA)(void *pIn, void *pData, int *pnData),\n  void *pInA,\n  int (*xInputB)(void *pIn, void *pData, int *pnData),\n  void *pInB,\n  int (*xOutput)(void *pOut, const void *pData, int nData),\n  void *pOut\n);\nSQLITE_API int sqlite3changeset_invert_strm(\n  int (*xInput)(void *pIn, void *pData, int *pnData),\n  void *pIn,\n  int (*xOutput)(void *pOut, const void *pData, int nData),\n  void *pOut\n);\nSQLITE_API int sqlite3changeset_start_strm(\n  sqlite3_changeset_iter **pp,\n  int (*xInput)(void *pIn, void *pData, int *pnData),\n  void *pIn\n);\nSQLITE_API int sqlite3changeset_start_v2_strm(\n  sqlite3_changeset_iter **pp,\n  int (*xInput)(void *pIn, void *pData, int *pnData),\n  void *pIn,\n  int flags\n);\nSQLITE_API int sqlite3session_changeset_strm(\n  sqlite3_session *pSession,\n  int (*xOutput)(void *pOut, const void *pData, int nData),\n  void *pOut\n);\nSQLITE_API int sqlite3session_patchset_strm(\n  sqlite3_session *pSession,\n  int (*xOutput)(void *pOut, const void *pData, int nData),\n  void *pOut\n);\nSQLITE_API int sqlite3changegroup_add_strm(sqlite3_changegroup*, \n    int (*xInput)(void *pIn, void *pData, int *pnData),\n    void *pIn\n);\nSQLITE_API int sqlite3changegroup_output_strm(sqlite3_changegroup*,\n    int (*xOutput)(void *pOut, const void *pData, int nData), \n    void *pOut\n);\nSQLITE_API int sqlite3rebaser_rebase_strm(\n  sqlite3_rebaser *pRebaser,\n  int (*xInput)(void *pIn, void *pData, int *pnData),\n  void *pIn,\n  int (*xOutput)(void *pOut, const void *pData, int nData),\n  void *pOut\n);\n\n/*\n** CAPI3REF: Configure global parameters\n**\n** The sqlite3session_config() interface is used to make global configuration\n** changes to the sessions module in order to tune it to the specific needs \n** of the application.\n**\n** The sqlite3session_config() interface is not threadsafe. If it is invoked\n** while any other thread is inside any other sessions method then the\n** results are undefined. Furthermore, if it is invoked after any sessions\n** related objects have been created, the results are also undefined. \n**\n** The first argument to the sqlite3session_config() function must be one\n** of the SQLITE_SESSION_CONFIG_XXX constants defined below. The \n** interpretation of the (void*) value passed as the second parameter and\n** the effect of calling this function depends on the value of the first\n** parameter.\n**\n** <dl>\n** <dt>SQLITE_SESSION_CONFIG_STRMSIZE<dd>\n**    By default, the sessions module streaming interfaces attempt to input\n**    and output data in approximately 1 KiB chunks. This operand may be used\n**    to set and query the value of this configuration setting. The pointer\n**    passed as the second argument must point to a value of type (int).\n**    If this value is greater than 0, it is used as the new streaming data\n**    chunk size for both input and output. Before returning, the (int) value\n**    pointed to by pArg is set to the final value of the streaming interface\n**    chunk size.\n** </dl>\n**\n** This function returns SQLITE_OK if successful, or an SQLite error code\n** otherwise.\n*/\nSQLITE_API int sqlite3session_config(int op, void *pArg);\n\n/*\n** CAPI3REF: Values for sqlite3session_config().\n*/\n#define SQLITE_SESSION_CONFIG_STRMSIZE 1\n\n/*\n** Make sure we can call this stuff from C++.\n*/\n#ifdef __cplusplus\n}\n#endif\n\n#endif  /* !defined(__SQLITESESSION_H_) && defined(SQLITE_ENABLE_SESSION) */\n\n/******** End of sqlite3session.h *********/\n/******** Begin file fts5.h *********/\n/*\n** 2014 May 31\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n******************************************************************************\n**\n** Interfaces to extend FTS5. Using the interfaces defined in this file, \n** FTS5 may be extended with:\n**\n**     * custom tokenizers, and\n**     * custom auxiliary functions.\n*/\n\n\n#ifndef _FTS5_H\n#define _FTS5_H\n\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/*************************************************************************\n** CUSTOM AUXILIARY FUNCTIONS\n**\n** Virtual table implementations may overload SQL functions by implementing\n** the sqlite3_module.xFindFunction() method.\n*/\n\ntypedef struct Fts5ExtensionApi Fts5ExtensionApi;\ntypedef struct Fts5Context Fts5Context;\ntypedef struct Fts5PhraseIter Fts5PhraseIter;\n\ntypedef void (*fts5_extension_function)(\n  const Fts5ExtensionApi *pApi,   /* API offered by current FTS version */\n  Fts5Context *pFts,              /* First arg to pass to pApi functions */\n  sqlite3_context *pCtx,          /* Context for returning result/error */\n  int nVal,                       /* Number of values in apVal[] array */\n  sqlite3_value **apVal           /* Array of trailing arguments */\n);\n\nstruct Fts5PhraseIter {\n  const unsigned char *a;\n  const unsigned char *b;\n};\n\n/*\n** EXTENSION API FUNCTIONS\n**\n** xUserData(pFts):\n**   Return a copy of the context pointer the extension function was \n**   registered with.\n**\n** xColumnTotalSize(pFts, iCol, pnToken):\n**   If parameter iCol is less than zero, set output variable *pnToken\n**   to the total number of tokens in the FTS5 table. Or, if iCol is\n**   non-negative but less than the number of columns in the table, return\n**   the total number of tokens in column iCol, considering all rows in \n**   the FTS5 table.\n**\n**   If parameter iCol is greater than or equal to the number of columns\n**   in the table, SQLITE_RANGE is returned. Or, if an error occurs (e.g.\n**   an OOM condition or IO error), an appropriate SQLite error code is \n**   returned.\n**\n** xColumnCount(pFts):\n**   Return the number of columns in the table.\n**\n** xColumnSize(pFts, iCol, pnToken):\n**   If parameter iCol is less than zero, set output variable *pnToken\n**   to the total number of tokens in the current row. Or, if iCol is\n**   non-negative but less than the number of columns in the table, set\n**   *pnToken to the number of tokens in column iCol of the current row.\n**\n**   If parameter iCol is greater than or equal to the number of columns\n**   in the table, SQLITE_RANGE is returned. Or, if an error occurs (e.g.\n**   an OOM condition or IO error), an appropriate SQLite error code is \n**   returned.\n**\n**   This function may be quite inefficient if used with an FTS5 table\n**   created with the \"columnsize=0\" option.\n**\n** xColumnText:\n**   This function attempts to retrieve the text of column iCol of the\n**   current document. If successful, (*pz) is set to point to a buffer\n**   containing the text in utf-8 encoding, (*pn) is set to the size in bytes\n**   (not characters) of the buffer and SQLITE_OK is returned. Otherwise,\n**   if an error occurs, an SQLite error code is returned and the final values\n**   of (*pz) and (*pn) are undefined.\n**\n** xPhraseCount:\n**   Returns the number of phrases in the current query expression.\n**\n** xPhraseSize:\n**   Returns the number of tokens in phrase iPhrase of the query. Phrases\n**   are numbered starting from zero.\n**\n** xInstCount:\n**   Set *pnInst to the total number of occurrences of all phrases within\n**   the query within the current row. Return SQLITE_OK if successful, or\n**   an error code (i.e. SQLITE_NOMEM) if an error occurs.\n**\n**   This API can be quite slow if used with an FTS5 table created with the\n**   \"detail=none\" or \"detail=column\" option. If the FTS5 table is created \n**   with either \"detail=none\" or \"detail=column\" and \"content=\" option \n**   (i.e. if it is a contentless table), then this API always returns 0.\n**\n** xInst:\n**   Query for the details of phrase match iIdx within the current row.\n**   Phrase matches are numbered starting from zero, so the iIdx argument\n**   should be greater than or equal to zero and smaller than the value\n**   output by xInstCount().\n**\n**   Usually, output parameter *piPhrase is set to the phrase number, *piCol\n**   to the column in which it occurs and *piOff the token offset of the\n**   first token of the phrase. Returns SQLITE_OK if successful, or an error\n**   code (i.e. SQLITE_NOMEM) if an error occurs.\n**\n**   This API can be quite slow if used with an FTS5 table created with the\n**   \"detail=none\" or \"detail=column\" option. \n**\n** xRowid:\n**   Returns the rowid of the current row.\n**\n** xTokenize:\n**   Tokenize text using the tokenizer belonging to the FTS5 table.\n**\n** xQueryPhrase(pFts5, iPhrase, pUserData, xCallback):\n**   This API function is used to query the FTS table for phrase iPhrase\n**   of the current query. Specifically, a query equivalent to:\n**\n**       ... FROM ftstable WHERE ftstable MATCH $p ORDER BY rowid\n**\n**   with $p set to a phrase equivalent to the phrase iPhrase of the\n**   current query is executed. Any column filter that applies to\n**   phrase iPhrase of the current query is included in $p. For each \n**   row visited, the callback function passed as the fourth argument \n**   is invoked. The context and API objects passed to the callback \n**   function may be used to access the properties of each matched row.\n**   Invoking Api.xUserData() returns a copy of the pointer passed as \n**   the third argument to pUserData.\n**\n**   If the callback function returns any value other than SQLITE_OK, the\n**   query is abandoned and the xQueryPhrase function returns immediately.\n**   If the returned value is SQLITE_DONE, xQueryPhrase returns SQLITE_OK.\n**   Otherwise, the error code is propagated upwards.\n**\n**   If the query runs to completion without incident, SQLITE_OK is returned.\n**   Or, if some error occurs before the query completes or is aborted by\n**   the callback, an SQLite error code is returned.\n**\n**\n** xSetAuxdata(pFts5, pAux, xDelete)\n**\n**   Save the pointer passed as the second argument as the extension functions \n**   \"auxiliary data\". The pointer may then be retrieved by the current or any\n**   future invocation of the same fts5 extension function made as part of\n**   of the same MATCH query using the xGetAuxdata() API.\n**\n**   Each extension function is allocated a single auxiliary data slot for\n**   each FTS query (MATCH expression). If the extension function is invoked \n**   more than once for a single FTS query, then all invocations share a \n**   single auxiliary data context.\n**\n**   If there is already an auxiliary data pointer when this function is\n**   invoked, then it is replaced by the new pointer. If an xDelete callback\n**   was specified along with the original pointer, it is invoked at this\n**   point.\n**\n**   The xDelete callback, if one is specified, is also invoked on the\n**   auxiliary data pointer after the FTS5 query has finished.\n**\n**   If an error (e.g. an OOM condition) occurs within this function, an\n**   the auxiliary data is set to NULL and an error code returned. If the\n**   xDelete parameter was not NULL, it is invoked on the auxiliary data\n**   pointer before returning.\n**\n**\n** xGetAuxdata(pFts5, bClear)\n**\n**   Returns the current auxiliary data pointer for the fts5 extension \n**   function. See the xSetAuxdata() method for details.\n**\n**   If the bClear argument is non-zero, then the auxiliary data is cleared\n**   (set to NULL) before this function returns. In this case the xDelete,\n**   if any, is not invoked.\n**\n**\n** xRowCount(pFts5, pnRow)\n**\n**   This function is used to retrieve the total number of rows in the table.\n**   In other words, the same value that would be returned by:\n**\n**        SELECT count(*) FROM ftstable;\n**\n** xPhraseFirst()\n**   This function is used, along with type Fts5PhraseIter and the xPhraseNext\n**   method, to iterate through all instances of a single query phrase within\n**   the current row. This is the same information as is accessible via the\n**   xInstCount/xInst APIs. While the xInstCount/xInst APIs are more convenient\n**   to use, this API may be faster under some circumstances. To iterate \n**   through instances of phrase iPhrase, use the following code:\n**\n**       Fts5PhraseIter iter;\n**       int iCol, iOff;\n**       for(pApi->xPhraseFirst(pFts, iPhrase, &iter, &iCol, &iOff);\n**           iCol>=0;\n**           pApi->xPhraseNext(pFts, &iter, &iCol, &iOff)\n**       ){\n**         // An instance of phrase iPhrase at offset iOff of column iCol\n**       }\n**\n**   The Fts5PhraseIter structure is defined above. Applications should not\n**   modify this structure directly - it should only be used as shown above\n**   with the xPhraseFirst() and xPhraseNext() API methods (and by\n**   xPhraseFirstColumn() and xPhraseNextColumn() as illustrated below).\n**\n**   This API can be quite slow if used with an FTS5 table created with the\n**   \"detail=none\" or \"detail=column\" option. If the FTS5 table is created \n**   with either \"detail=none\" or \"detail=column\" and \"content=\" option \n**   (i.e. if it is a contentless table), then this API always iterates\n**   through an empty set (all calls to xPhraseFirst() set iCol to -1).\n**\n** xPhraseNext()\n**   See xPhraseFirst above.\n**\n** xPhraseFirstColumn()\n**   This function and xPhraseNextColumn() are similar to the xPhraseFirst()\n**   and xPhraseNext() APIs described above. The difference is that instead\n**   of iterating through all instances of a phrase in the current row, these\n**   APIs are used to iterate through the set of columns in the current row\n**   that contain one or more instances of a specified phrase. For example:\n**\n**       Fts5PhraseIter iter;\n**       int iCol;\n**       for(pApi->xPhraseFirstColumn(pFts, iPhrase, &iter, &iCol);\n**           iCol>=0;\n**           pApi->xPhraseNextColumn(pFts, &iter, &iCol)\n**       ){\n**         // Column iCol contains at least one instance of phrase iPhrase\n**       }\n**\n**   This API can be quite slow if used with an FTS5 table created with the\n**   \"detail=none\" option. If the FTS5 table is created with either \n**   \"detail=none\" \"content=\" option (i.e. if it is a contentless table), \n**   then this API always iterates through an empty set (all calls to \n**   xPhraseFirstColumn() set iCol to -1).\n**\n**   The information accessed using this API and its companion\n**   xPhraseFirstColumn() may also be obtained using xPhraseFirst/xPhraseNext\n**   (or xInst/xInstCount). The chief advantage of this API is that it is\n**   significantly more efficient than those alternatives when used with\n**   \"detail=column\" tables.  \n**\n** xPhraseNextColumn()\n**   See xPhraseFirstColumn above.\n*/\nstruct Fts5ExtensionApi {\n  int iVersion;                   /* Currently always set to 3 */\n\n  void *(*xUserData)(Fts5Context*);\n\n  int (*xColumnCount)(Fts5Context*);\n  int (*xRowCount)(Fts5Context*, sqlite3_int64 *pnRow);\n  int (*xColumnTotalSize)(Fts5Context*, int iCol, sqlite3_int64 *pnToken);\n\n  int (*xTokenize)(Fts5Context*, \n    const char *pText, int nText, /* Text to tokenize */\n    void *pCtx,                   /* Context passed to xToken() */\n    int (*xToken)(void*, int, const char*, int, int, int)       /* Callback */\n  );\n\n  int (*xPhraseCount)(Fts5Context*);\n  int (*xPhraseSize)(Fts5Context*, int iPhrase);\n\n  int (*xInstCount)(Fts5Context*, int *pnInst);\n  int (*xInst)(Fts5Context*, int iIdx, int *piPhrase, int *piCol, int *piOff);\n\n  sqlite3_int64 (*xRowid)(Fts5Context*);\n  int (*xColumnText)(Fts5Context*, int iCol, const char **pz, int *pn);\n  int (*xColumnSize)(Fts5Context*, int iCol, int *pnToken);\n\n  int (*xQueryPhrase)(Fts5Context*, int iPhrase, void *pUserData,\n    int(*)(const Fts5ExtensionApi*,Fts5Context*,void*)\n  );\n  int (*xSetAuxdata)(Fts5Context*, void *pAux, void(*xDelete)(void*));\n  void *(*xGetAuxdata)(Fts5Context*, int bClear);\n\n  int (*xPhraseFirst)(Fts5Context*, int iPhrase, Fts5PhraseIter*, int*, int*);\n  void (*xPhraseNext)(Fts5Context*, Fts5PhraseIter*, int *piCol, int *piOff);\n\n  int (*xPhraseFirstColumn)(Fts5Context*, int iPhrase, Fts5PhraseIter*, int*);\n  void (*xPhraseNextColumn)(Fts5Context*, Fts5PhraseIter*, int *piCol);\n};\n\n/* \n** CUSTOM AUXILIARY FUNCTIONS\n*************************************************************************/\n\n/*************************************************************************\n** CUSTOM TOKENIZERS\n**\n** Applications may also register custom tokenizer types. A tokenizer \n** is registered by providing fts5 with a populated instance of the \n** following structure. All structure methods must be defined, setting\n** any member of the fts5_tokenizer struct to NULL leads to undefined\n** behaviour. The structure methods are expected to function as follows:\n**\n** xCreate:\n**   This function is used to allocate and initialize a tokenizer instance.\n**   A tokenizer instance is required to actually tokenize text.\n**\n**   The first argument passed to this function is a copy of the (void*)\n**   pointer provided by the application when the fts5_tokenizer object\n**   was registered with FTS5 (the third argument to xCreateTokenizer()). \n**   The second and third arguments are an array of nul-terminated strings\n**   containing the tokenizer arguments, if any, specified following the\n**   tokenizer name as part of the CREATE VIRTUAL TABLE statement used\n**   to create the FTS5 table.\n**\n**   The final argument is an output variable. If successful, (*ppOut) \n**   should be set to point to the new tokenizer handle and SQLITE_OK\n**   returned. If an error occurs, some value other than SQLITE_OK should\n**   be returned. In this case, fts5 assumes that the final value of *ppOut \n**   is undefined.\n**\n** xDelete:\n**   This function is invoked to delete a tokenizer handle previously\n**   allocated using xCreate(). Fts5 guarantees that this function will\n**   be invoked exactly once for each successful call to xCreate().\n**\n** xTokenize:\n**   This function is expected to tokenize the nText byte string indicated \n**   by argument pText. pText may or may not be nul-terminated. The first\n**   argument passed to this function is a pointer to an Fts5Tokenizer object\n**   returned by an earlier call to xCreate().\n**\n**   The second argument indicates the reason that FTS5 is requesting\n**   tokenization of the supplied text. This is always one of the following\n**   four values:\n**\n**   <ul><li> <b>FTS5_TOKENIZE_DOCUMENT</b> - A document is being inserted into\n**            or removed from the FTS table. The tokenizer is being invoked to\n**            determine the set of tokens to add to (or delete from) the\n**            FTS index.\n**\n**       <li> <b>FTS5_TOKENIZE_QUERY</b> - A MATCH query is being executed \n**            against the FTS index. The tokenizer is being called to tokenize \n**            a bareword or quoted string specified as part of the query.\n**\n**       <li> <b>(FTS5_TOKENIZE_QUERY | FTS5_TOKENIZE_PREFIX)</b> - Same as\n**            FTS5_TOKENIZE_QUERY, except that the bareword or quoted string is\n**            followed by a \"*\" character, indicating that the last token\n**            returned by the tokenizer will be treated as a token prefix.\n**\n**       <li> <b>FTS5_TOKENIZE_AUX</b> - The tokenizer is being invoked to \n**            satisfy an fts5_api.xTokenize() request made by an auxiliary\n**            function. Or an fts5_api.xColumnSize() request made by the same\n**            on a columnsize=0 database.  \n**   </ul>\n**\n**   For each token in the input string, the supplied callback xToken() must\n**   be invoked. The first argument to it should be a copy of the pointer\n**   passed as the second argument to xTokenize(). The third and fourth\n**   arguments are a pointer to a buffer containing the token text, and the\n**   size of the token in bytes. The 4th and 5th arguments are the byte offsets\n**   of the first byte of and first byte immediately following the text from\n**   which the token is derived within the input.\n**\n**   The second argument passed to the xToken() callback (\"tflags\") should\n**   normally be set to 0. The exception is if the tokenizer supports \n**   synonyms. In this case see the discussion below for details.\n**\n**   FTS5 assumes the xToken() callback is invoked for each token in the \n**   order that they occur within the input text.\n**\n**   If an xToken() callback returns any value other than SQLITE_OK, then\n**   the tokenization should be abandoned and the xTokenize() method should\n**   immediately return a copy of the xToken() return value. Or, if the\n**   input buffer is exhausted, xTokenize() should return SQLITE_OK. Finally,\n**   if an error occurs with the xTokenize() implementation itself, it\n**   may abandon the tokenization and return any error code other than\n**   SQLITE_OK or SQLITE_DONE.\n**\n** SYNONYM SUPPORT\n**\n**   Custom tokenizers may also support synonyms. Consider a case in which a\n**   user wishes to query for a phrase such as \"first place\". Using the \n**   built-in tokenizers, the FTS5 query 'first + place' will match instances\n**   of \"first place\" within the document set, but not alternative forms\n**   such as \"1st place\". In some applications, it would be better to match\n**   all instances of \"first place\" or \"1st place\" regardless of which form\n**   the user specified in the MATCH query text.\n**\n**   There are several ways to approach this in FTS5:\n**\n**   <ol><li> By mapping all synonyms to a single token. In this case, the \n**            In the above example, this means that the tokenizer returns the\n**            same token for inputs \"first\" and \"1st\". Say that token is in\n**            fact \"first\", so that when the user inserts the document \"I won\n**            1st place\" entries are added to the index for tokens \"i\", \"won\",\n**            \"first\" and \"place\". If the user then queries for '1st + place',\n**            the tokenizer substitutes \"first\" for \"1st\" and the query works\n**            as expected.\n**\n**       <li> By querying the index for all synonyms of each query term\n**            separately. In this case, when tokenizing query text, the\n**            tokenizer may provide multiple synonyms for a single term \n**            within the document. FTS5 then queries the index for each \n**            synonym individually. For example, faced with the query:\n**\n**   <codeblock>\n**     ... MATCH 'first place'</codeblock>\n**\n**            the tokenizer offers both \"1st\" and \"first\" as synonyms for the\n**            first token in the MATCH query and FTS5 effectively runs a query \n**            similar to:\n**\n**   <codeblock>\n**     ... MATCH '(first OR 1st) place'</codeblock>\n**\n**            except that, for the purposes of auxiliary functions, the query\n**            still appears to contain just two phrases - \"(first OR 1st)\" \n**            being treated as a single phrase.\n**\n**       <li> By adding multiple synonyms for a single term to the FTS index.\n**            Using this method, when tokenizing document text, the tokenizer\n**            provides multiple synonyms for each token. So that when a \n**            document such as \"I won first place\" is tokenized, entries are\n**            added to the FTS index for \"i\", \"won\", \"first\", \"1st\" and\n**            \"place\".\n**\n**            This way, even if the tokenizer does not provide synonyms\n**            when tokenizing query text (it should not - to do so would be\n**            inefficient), it doesn't matter if the user queries for \n**            'first + place' or '1st + place', as there are entries in the\n**            FTS index corresponding to both forms of the first token.\n**   </ol>\n**\n**   Whether it is parsing document or query text, any call to xToken that\n**   specifies a <i>tflags</i> argument with the FTS5_TOKEN_COLOCATED bit\n**   is considered to supply a synonym for the previous token. For example,\n**   when parsing the document \"I won first place\", a tokenizer that supports\n**   synonyms would call xToken() 5 times, as follows:\n**\n**   <codeblock>\n**       xToken(pCtx, 0, \"i\",                      1,  0,  1);\n**       xToken(pCtx, 0, \"won\",                    3,  2,  5);\n**       xToken(pCtx, 0, \"first\",                  5,  6, 11);\n**       xToken(pCtx, FTS5_TOKEN_COLOCATED, \"1st\", 3,  6, 11);\n**       xToken(pCtx, 0, \"place\",                  5, 12, 17);\n**</codeblock>\n**\n**   It is an error to specify the FTS5_TOKEN_COLOCATED flag the first time\n**   xToken() is called. Multiple synonyms may be specified for a single token\n**   by making multiple calls to xToken(FTS5_TOKEN_COLOCATED) in sequence. \n**   There is no limit to the number of synonyms that may be provided for a\n**   single token.\n**\n**   In many cases, method (1) above is the best approach. It does not add \n**   extra data to the FTS index or require FTS5 to query for multiple terms,\n**   so it is efficient in terms of disk space and query speed. However, it\n**   does not support prefix queries very well. If, as suggested above, the\n**   token \"first\" is substituted for \"1st\" by the tokenizer, then the query:\n**\n**   <codeblock>\n**     ... MATCH '1s*'</codeblock>\n**\n**   will not match documents that contain the token \"1st\" (as the tokenizer\n**   will probably not map \"1s\" to any prefix of \"first\").\n**\n**   For full prefix support, method (3) may be preferred. In this case, \n**   because the index contains entries for both \"first\" and \"1st\", prefix\n**   queries such as 'fi*' or '1s*' will match correctly. However, because\n**   extra entries are added to the FTS index, this method uses more space\n**   within the database.\n**\n**   Method (2) offers a midpoint between (1) and (3). Using this method,\n**   a query such as '1s*' will match documents that contain the literal \n**   token \"1st\", but not \"first\" (assuming the tokenizer is not able to\n**   provide synonyms for prefixes). However, a non-prefix query like '1st'\n**   will match against \"1st\" and \"first\". This method does not require\n**   extra disk space, as no extra entries are added to the FTS index. \n**   On the other hand, it may require more CPU cycles to run MATCH queries,\n**   as separate queries of the FTS index are required for each synonym.\n**\n**   When using methods (2) or (3), it is important that the tokenizer only\n**   provide synonyms when tokenizing document text (method (2)) or query\n**   text (method (3)), not both. Doing so will not cause any errors, but is\n**   inefficient.\n*/\ntypedef struct Fts5Tokenizer Fts5Tokenizer;\ntypedef struct fts5_tokenizer fts5_tokenizer;\nstruct fts5_tokenizer {\n  int (*xCreate)(void*, const char **azArg, int nArg, Fts5Tokenizer **ppOut);\n  void (*xDelete)(Fts5Tokenizer*);\n  int (*xTokenize)(Fts5Tokenizer*, \n      void *pCtx,\n      int flags,            /* Mask of FTS5_TOKENIZE_* flags */\n      const char *pText, int nText, \n      int (*xToken)(\n        void *pCtx,         /* Copy of 2nd argument to xTokenize() */\n        int tflags,         /* Mask of FTS5_TOKEN_* flags */\n        const char *pToken, /* Pointer to buffer containing token */\n        int nToken,         /* Size of token in bytes */\n        int iStart,         /* Byte offset of token within input text */\n        int iEnd            /* Byte offset of end of token within input text */\n      )\n  );\n};\n\n/* Flags that may be passed as the third argument to xTokenize() */\n#define FTS5_TOKENIZE_QUERY     0x0001\n#define FTS5_TOKENIZE_PREFIX    0x0002\n#define FTS5_TOKENIZE_DOCUMENT  0x0004\n#define FTS5_TOKENIZE_AUX       0x0008\n\n/* Flags that may be passed by the tokenizer implementation back to FTS5\n** as the third argument to the supplied xToken callback. */\n#define FTS5_TOKEN_COLOCATED    0x0001      /* Same position as prev. token */\n\n/*\n** END OF CUSTOM TOKENIZERS\n*************************************************************************/\n\n/*************************************************************************\n** FTS5 EXTENSION REGISTRATION API\n*/\ntypedef struct fts5_api fts5_api;\nstruct fts5_api {\n  int iVersion;                   /* Currently always set to 2 */\n\n  /* Create a new tokenizer */\n  int (*xCreateTokenizer)(\n    fts5_api *pApi,\n    const char *zName,\n    void *pContext,\n    fts5_tokenizer *pTokenizer,\n    void (*xDestroy)(void*)\n  );\n\n  /* Find an existing tokenizer */\n  int (*xFindTokenizer)(\n    fts5_api *pApi,\n    const char *zName,\n    void **ppContext,\n    fts5_tokenizer *pTokenizer\n  );\n\n  /* Create a new auxiliary function */\n  int (*xCreateFunction)(\n    fts5_api *pApi,\n    const char *zName,\n    void *pContext,\n    fts5_extension_function xFunction,\n    void (*xDestroy)(void*)\n  );\n};\n\n/*\n** END OF REGISTRATION API\n*************************************************************************/\n\n#ifdef __cplusplus\n}  /* end of the 'extern \"C\"' block */\n#endif\n\n#endif /* _FTS5_H */\n\n/******** End of fts5.h *********/\n"
  },
  {
    "path": "deprecated/android/sqlcipher/sqlite3ext.h",
    "content": "/*\n** 2006 June 7\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This header file defines the SQLite interface for use by\n** shared libraries that want to be imported as extensions into\n** an SQLite instance.  Shared libraries that intend to be loaded\n** as extensions by SQLite should #include this file instead of \n** sqlite3.h.\n*/\n#ifndef SQLITE3EXT_H\n#define SQLITE3EXT_H\n#include \"sqlite3.h\"\n#include \"sqlcipher.h\"\n\ntypedef struct sqlcipher_api_routines sqlcipher_api_routines;\ntypedef struct sqlite3_api_routines sqlite3_api_routines;\n\n/*\n** The following structure holds pointers to all of the SQLite API\n** routines.\n**\n** WARNING:  In order to maintain backwards compatibility, add new\n** interfaces to the end of this structure only.  If you insert new\n** interfaces in the middle of this structure, then older different\n** versions of SQLite will not be able to load each other's shared\n** libraries!\n*/\n#ifdef SQLITE_HAS_CODEC\nstruct sqlcipher_api_routines {\n  int (*register_provider)(sqlcipher_provider *p);\n  sqlcipher_provider* (*get_provider)();\n  int (*key)(sqlite3 *db, const void *pKey, int nKey);\n  int (*key_v2)(sqlite3 *db, const char *zDb, const void *pKey, int nKey);\n  int (*rekey)(sqlite3 *db, const void *pKey, int nKey);\n  int (*rekey_v2)(sqlite3 *db, const char *zDb, const void *pKey, int nKey);\n\n  int (*register_custom_provider)(const char *name, const sqlcipher_provider *p);\n  int (*unregister_custom_provider)(const char *name);\n  const sqlcipher_provider* (*get_fallback_provider)();\n};\n#endif\n\nstruct sqlite3_api_routines {\n  void * (*aggregate_context)(sqlite3_context*,int nBytes);\n  int  (*aggregate_count)(sqlite3_context*);\n  int  (*bind_blob)(sqlite3_stmt*,int,const void*,int n,void(*)(void*));\n  int  (*bind_double)(sqlite3_stmt*,int,double);\n  int  (*bind_int)(sqlite3_stmt*,int,int);\n  int  (*bind_int64)(sqlite3_stmt*,int,sqlite_int64);\n  int  (*bind_null)(sqlite3_stmt*,int);\n  int  (*bind_parameter_count)(sqlite3_stmt*);\n  int  (*bind_parameter_index)(sqlite3_stmt*,const char*zName);\n  const char * (*bind_parameter_name)(sqlite3_stmt*,int);\n  int  (*bind_text)(sqlite3_stmt*,int,const char*,int n,void(*)(void*));\n  int  (*bind_text16)(sqlite3_stmt*,int,const void*,int,void(*)(void*));\n  int  (*bind_value)(sqlite3_stmt*,int,const sqlite3_value*);\n  int  (*busy_handler)(sqlite3*,int(*)(void*,int),void*);\n  int  (*busy_timeout)(sqlite3*,int ms);\n  int  (*changes)(sqlite3*);\n  int  (*close)(sqlite3*);\n  int  (*collation_needed)(sqlite3*,void*,void(*)(void*,sqlite3*,\n                           int eTextRep,const char*));\n  int  (*collation_needed16)(sqlite3*,void*,void(*)(void*,sqlite3*,\n                             int eTextRep,const void*));\n  const void * (*column_blob)(sqlite3_stmt*,int iCol);\n  int  (*column_bytes)(sqlite3_stmt*,int iCol);\n  int  (*column_bytes16)(sqlite3_stmt*,int iCol);\n  int  (*column_count)(sqlite3_stmt*pStmt);\n  const char * (*column_database_name)(sqlite3_stmt*,int);\n  const void * (*column_database_name16)(sqlite3_stmt*,int);\n  const char * (*column_decltype)(sqlite3_stmt*,int i);\n  const void * (*column_decltype16)(sqlite3_stmt*,int);\n  double  (*column_double)(sqlite3_stmt*,int iCol);\n  int  (*column_int)(sqlite3_stmt*,int iCol);\n  sqlite_int64  (*column_int64)(sqlite3_stmt*,int iCol);\n  const char * (*column_name)(sqlite3_stmt*,int);\n  const void * (*column_name16)(sqlite3_stmt*,int);\n  const char * (*column_origin_name)(sqlite3_stmt*,int);\n  const void * (*column_origin_name16)(sqlite3_stmt*,int);\n  const char * (*column_table_name)(sqlite3_stmt*,int);\n  const void * (*column_table_name16)(sqlite3_stmt*,int);\n  const unsigned char * (*column_text)(sqlite3_stmt*,int iCol);\n  const void * (*column_text16)(sqlite3_stmt*,int iCol);\n  int  (*column_type)(sqlite3_stmt*,int iCol);\n  sqlite3_value* (*column_value)(sqlite3_stmt*,int iCol);\n  void * (*commit_hook)(sqlite3*,int(*)(void*),void*);\n  int  (*complete)(const char*sql);\n  int  (*complete16)(const void*sql);\n  int  (*create_collation)(sqlite3*,const char*,int,void*,\n                           int(*)(void*,int,const void*,int,const void*));\n  int  (*create_collation16)(sqlite3*,const void*,int,void*,\n                             int(*)(void*,int,const void*,int,const void*));\n  int  (*create_function)(sqlite3*,const char*,int,int,void*,\n                          void (*xFunc)(sqlite3_context*,int,sqlite3_value**),\n                          void (*xStep)(sqlite3_context*,int,sqlite3_value**),\n                          void (*xFinal)(sqlite3_context*));\n  int  (*create_function16)(sqlite3*,const void*,int,int,void*,\n                            void (*xFunc)(sqlite3_context*,int,sqlite3_value**),\n                            void (*xStep)(sqlite3_context*,int,sqlite3_value**),\n                            void (*xFinal)(sqlite3_context*));\n  int (*create_module)(sqlite3*,const char*,const sqlite3_module*,void*);\n  int  (*data_count)(sqlite3_stmt*pStmt);\n  sqlite3 * (*db_handle)(sqlite3_stmt*);\n  int (*declare_vtab)(sqlite3*,const char*);\n  int  (*enable_shared_cache)(int);\n  int  (*errcode)(sqlite3*db);\n  const char * (*errmsg)(sqlite3*);\n  const void * (*errmsg16)(sqlite3*);\n  int  (*exec)(sqlite3*,const char*,sqlite3_callback,void*,char**);\n  int  (*expired)(sqlite3_stmt*);\n  int  (*finalize)(sqlite3_stmt*pStmt);\n  void  (*free)(void*);\n  void  (*free_table)(char**result);\n  int  (*get_autocommit)(sqlite3*);\n  void * (*get_auxdata)(sqlite3_context*,int);\n  int  (*get_table)(sqlite3*,const char*,char***,int*,int*,char**);\n\n#ifdef SQLITE_HAS_CODEC\n  /* Was `int  (*global_recover)(void);`, but no longer used.\n     Replaced with sqlcipher api pointers. */\n  const struct sqlcipher_api_routines *sqlcipher;\n#else\n  int  (*global_recover)(void);\n#endif\n\n  void  (*interruptx)(sqlite3*);\n  sqlite_int64  (*last_insert_rowid)(sqlite3*);\n  const char * (*libversion)(void);\n  int  (*libversion_number)(void);\n  void *(*malloc)(int);\n  char * (*mprintf)(const char*,...);\n  int  (*open)(const char*,sqlite3**);\n  int  (*open16)(const void*,sqlite3**);\n  int  (*prepare)(sqlite3*,const char*,int,sqlite3_stmt**,const char**);\n  int  (*prepare16)(sqlite3*,const void*,int,sqlite3_stmt**,const void**);\n  void * (*profile)(sqlite3*,void(*)(void*,const char*,sqlite_uint64),void*);\n  void  (*progress_handler)(sqlite3*,int,int(*)(void*),void*);\n  void *(*realloc)(void*,int);\n  int  (*reset)(sqlite3_stmt*pStmt);\n  void  (*result_blob)(sqlite3_context*,const void*,int,void(*)(void*));\n  void  (*result_double)(sqlite3_context*,double);\n  void  (*result_error)(sqlite3_context*,const char*,int);\n  void  (*result_error16)(sqlite3_context*,const void*,int);\n  void  (*result_int)(sqlite3_context*,int);\n  void  (*result_int64)(sqlite3_context*,sqlite_int64);\n  void  (*result_null)(sqlite3_context*);\n  void  (*result_text)(sqlite3_context*,const char*,int,void(*)(void*));\n  void  (*result_text16)(sqlite3_context*,const void*,int,void(*)(void*));\n  void  (*result_text16be)(sqlite3_context*,const void*,int,void(*)(void*));\n  void  (*result_text16le)(sqlite3_context*,const void*,int,void(*)(void*));\n  void  (*result_value)(sqlite3_context*,sqlite3_value*);\n  void * (*rollback_hook)(sqlite3*,void(*)(void*),void*);\n  int  (*set_authorizer)(sqlite3*,int(*)(void*,int,const char*,const char*,\n                         const char*,const char*),void*);\n  void  (*set_auxdata)(sqlite3_context*,int,void*,void (*)(void*));\n  char * (*xsnprintf)(int,char*,const char*,...);\n  int  (*step)(sqlite3_stmt*);\n  int  (*table_column_metadata)(sqlite3*,const char*,const char*,const char*,\n                                char const**,char const**,int*,int*,int*);\n  void  (*thread_cleanup)(void);\n  int  (*total_changes)(sqlite3*);\n  void * (*trace)(sqlite3*,void(*xTrace)(void*,const char*),void*);\n  int  (*transfer_bindings)(sqlite3_stmt*,sqlite3_stmt*);\n  void * (*update_hook)(sqlite3*,void(*)(void*,int ,char const*,char const*,\n                                         sqlite_int64),void*);\n  void * (*user_data)(sqlite3_context*);\n  const void * (*value_blob)(sqlite3_value*);\n  int  (*value_bytes)(sqlite3_value*);\n  int  (*value_bytes16)(sqlite3_value*);\n  double  (*value_double)(sqlite3_value*);\n  int  (*value_int)(sqlite3_value*);\n  sqlite_int64  (*value_int64)(sqlite3_value*);\n  int  (*value_numeric_type)(sqlite3_value*);\n  const unsigned char * (*value_text)(sqlite3_value*);\n  const void * (*value_text16)(sqlite3_value*);\n  const void * (*value_text16be)(sqlite3_value*);\n  const void * (*value_text16le)(sqlite3_value*);\n  int  (*value_type)(sqlite3_value*);\n  char *(*vmprintf)(const char*,va_list);\n  /* Added ??? */\n  int (*overload_function)(sqlite3*, const char *zFuncName, int nArg);\n  /* Added by 3.3.13 */\n  int (*prepare_v2)(sqlite3*,const char*,int,sqlite3_stmt**,const char**);\n  int (*prepare16_v2)(sqlite3*,const void*,int,sqlite3_stmt**,const void**);\n  int (*clear_bindings)(sqlite3_stmt*);\n  /* Added by 3.4.1 */\n  int (*create_module_v2)(sqlite3*,const char*,const sqlite3_module*,void*,\n                          void (*xDestroy)(void *));\n  /* Added by 3.5.0 */\n  int (*bind_zeroblob)(sqlite3_stmt*,int,int);\n  int (*blob_bytes)(sqlite3_blob*);\n  int (*blob_close)(sqlite3_blob*);\n  int (*blob_open)(sqlite3*,const char*,const char*,const char*,sqlite3_int64,\n                   int,sqlite3_blob**);\n  int (*blob_read)(sqlite3_blob*,void*,int,int);\n  int (*blob_write)(sqlite3_blob*,const void*,int,int);\n  int (*create_collation_v2)(sqlite3*,const char*,int,void*,\n                             int(*)(void*,int,const void*,int,const void*),\n                             void(*)(void*));\n  int (*file_control)(sqlite3*,const char*,int,void*);\n  sqlite3_int64 (*memory_highwater)(int);\n  sqlite3_int64 (*memory_used)(void);\n  sqlite3_mutex *(*mutex_alloc)(int);\n  void (*mutex_enter)(sqlite3_mutex*);\n  void (*mutex_free)(sqlite3_mutex*);\n  void (*mutex_leave)(sqlite3_mutex*);\n  int (*mutex_try)(sqlite3_mutex*);\n  int (*open_v2)(const char*,sqlite3**,int,const char*);\n  int (*release_memory)(int);\n  void (*result_error_nomem)(sqlite3_context*);\n  void (*result_error_toobig)(sqlite3_context*);\n  int (*sleep)(int);\n  void (*soft_heap_limit)(int);\n  sqlite3_vfs *(*vfs_find)(const char*);\n  int (*vfs_register)(sqlite3_vfs*,int);\n  int (*vfs_unregister)(sqlite3_vfs*);\n  int (*xthreadsafe)(void);\n  void (*result_zeroblob)(sqlite3_context*,int);\n  void (*result_error_code)(sqlite3_context*,int);\n  int (*test_control)(int, ...);\n  void (*randomness)(int,void*);\n  sqlite3 *(*context_db_handle)(sqlite3_context*);\n  int (*extended_result_codes)(sqlite3*,int);\n  int (*limit)(sqlite3*,int,int);\n  sqlite3_stmt *(*next_stmt)(sqlite3*,sqlite3_stmt*);\n  const char *(*sql)(sqlite3_stmt*);\n  int (*status)(int,int*,int*,int);\n  int (*backup_finish)(sqlite3_backup*);\n  sqlite3_backup *(*backup_init)(sqlite3*,const char*,sqlite3*,const char*);\n  int (*backup_pagecount)(sqlite3_backup*);\n  int (*backup_remaining)(sqlite3_backup*);\n  int (*backup_step)(sqlite3_backup*,int);\n  const char *(*compileoption_get)(int);\n  int (*compileoption_used)(const char*);\n  int (*create_function_v2)(sqlite3*,const char*,int,int,void*,\n                            void (*xFunc)(sqlite3_context*,int,sqlite3_value**),\n                            void (*xStep)(sqlite3_context*,int,sqlite3_value**),\n                            void (*xFinal)(sqlite3_context*),\n                            void(*xDestroy)(void*));\n  int (*db_config)(sqlite3*,int,...);\n  sqlite3_mutex *(*db_mutex)(sqlite3*);\n  int (*db_status)(sqlite3*,int,int*,int*,int);\n  int (*extended_errcode)(sqlite3*);\n  void (*log)(int,const char*,...);\n  sqlite3_int64 (*soft_heap_limit64)(sqlite3_int64);\n  const char *(*sourceid)(void);\n  int (*stmt_status)(sqlite3_stmt*,int,int);\n  int (*strnicmp)(const char*,const char*,int);\n  int (*unlock_notify)(sqlite3*,void(*)(void**,int),void*);\n  int (*wal_autocheckpoint)(sqlite3*,int);\n  int (*wal_checkpoint)(sqlite3*,const char*);\n  void *(*wal_hook)(sqlite3*,int(*)(void*,sqlite3*,const char*,int),void*);\n  int (*blob_reopen)(sqlite3_blob*,sqlite3_int64);\n  int (*vtab_config)(sqlite3*,int op,...);\n  int (*vtab_on_conflict)(sqlite3*);\n  /* Version 3.7.16 and later */\n  int (*close_v2)(sqlite3*);\n  const char *(*db_filename)(sqlite3*,const char*);\n  int (*db_readonly)(sqlite3*,const char*);\n  int (*db_release_memory)(sqlite3*);\n  const char *(*errstr)(int);\n  int (*stmt_busy)(sqlite3_stmt*);\n  int (*stmt_readonly)(sqlite3_stmt*);\n  int (*stricmp)(const char*,const char*);\n  int (*uri_boolean)(const char*,const char*,int);\n  sqlite3_int64 (*uri_int64)(const char*,const char*,sqlite3_int64);\n  const char *(*uri_parameter)(const char*,const char*);\n  char *(*xvsnprintf)(int,char*,const char*,va_list);\n  int (*wal_checkpoint_v2)(sqlite3*,const char*,int,int*,int*);\n  /* Version 3.8.7 and later */\n  int (*auto_extension)(void(*)(void));\n  int (*bind_blob64)(sqlite3_stmt*,int,const void*,sqlite3_uint64,\n                     void(*)(void*));\n  int (*bind_text64)(sqlite3_stmt*,int,const char*,sqlite3_uint64,\n                      void(*)(void*),unsigned char);\n  int (*cancel_auto_extension)(void(*)(void));\n  int (*load_extension)(sqlite3*,const char*,const char*,char**);\n  void *(*malloc64)(sqlite3_uint64);\n  sqlite3_uint64 (*msize)(void*);\n  void *(*realloc64)(void*,sqlite3_uint64);\n  void (*reset_auto_extension)(void);\n  void (*result_blob64)(sqlite3_context*,const void*,sqlite3_uint64,\n                        void(*)(void*));\n  void (*result_text64)(sqlite3_context*,const char*,sqlite3_uint64,\n                         void(*)(void*), unsigned char);\n  int (*strglob)(const char*,const char*);\n  /* Version 3.8.11 and later */\n  sqlite3_value *(*value_dup)(const sqlite3_value*);\n  void (*value_free)(sqlite3_value*);\n  int (*result_zeroblob64)(sqlite3_context*,sqlite3_uint64);\n  int (*bind_zeroblob64)(sqlite3_stmt*, int, sqlite3_uint64);\n  /* Version 3.9.0 and later */\n  unsigned int (*value_subtype)(sqlite3_value*);\n  void (*result_subtype)(sqlite3_context*,unsigned int);\n  /* Version 3.10.0 and later */\n  int (*status64)(int,sqlite3_int64*,sqlite3_int64*,int);\n  int (*strlike)(const char*,const char*,unsigned int);\n  int (*db_cacheflush)(sqlite3*);\n  /* Version 3.12.0 and later */\n  int (*system_errno)(sqlite3*);\n  /* Version 3.14.0 and later */\n  int (*trace_v2)(sqlite3*,unsigned,int(*)(unsigned,void*,void*,void*),void*);\n  char *(*expanded_sql)(sqlite3_stmt*);\n  /* Version 3.18.0 and later */\n  void (*set_last_insert_rowid)(sqlite3*,sqlite3_int64);\n  /* Version 3.20.0 and later */\n  int (*prepare_v3)(sqlite3*,const char*,int,unsigned int,\n                    sqlite3_stmt**,const char**);\n  int (*prepare16_v3)(sqlite3*,const void*,int,unsigned int,\n                      sqlite3_stmt**,const void**);\n  int (*bind_pointer)(sqlite3_stmt*,int,void*,const char*,void(*)(void*));\n  void (*result_pointer)(sqlite3_context*,void*,const char*,void(*)(void*));\n  void *(*value_pointer)(sqlite3_value*,const char*);\n  int (*vtab_nochange)(sqlite3_context*);\n  int (*value_nochange)(sqlite3_value*);\n  const char *(*vtab_collation)(sqlite3_index_info*,int);\n  /* Version 3.24.0 and later */\n  int (*keyword_count)(void);\n  int (*keyword_name)(int,const char**,int*);\n  int (*keyword_check)(const char*,int);\n  sqlite3_str *(*str_new)(sqlite3*);\n  char *(*str_finish)(sqlite3_str*);\n  void (*str_appendf)(sqlite3_str*, const char *zFormat, ...);\n  void (*str_vappendf)(sqlite3_str*, const char *zFormat, va_list);\n  void (*str_append)(sqlite3_str*, const char *zIn, int N);\n  void (*str_appendall)(sqlite3_str*, const char *zIn);\n  void (*str_appendchar)(sqlite3_str*, int N, char C);\n  void (*str_reset)(sqlite3_str*);\n  int (*str_errcode)(sqlite3_str*);\n  int (*str_length)(sqlite3_str*);\n  char *(*str_value)(sqlite3_str*);\n  /* Version 3.25.0 and later */\n  int (*create_window_function)(sqlite3*,const char*,int,int,void*,\n                            void (*xStep)(sqlite3_context*,int,sqlite3_value**),\n                            void (*xFinal)(sqlite3_context*),\n                            void (*xValue)(sqlite3_context*),\n                            void (*xInv)(sqlite3_context*,int,sqlite3_value**),\n                            void(*xDestroy)(void*));\n  /* Version 3.26.0 and later */\n  const char *(*normalized_sql)(sqlite3_stmt*);\n};\n\n/*\n** This is the function signature used for all extension entry points.  It\n** is also defined in the file \"loadext.c\".\n*/\ntypedef int (*sqlite3_loadext_entry)(\n  sqlite3 *db,                       /* Handle to the database. */\n  char **pzErrMsg,                   /* Used to set error string on failure. */\n  const sqlite3_api_routines *pThunk /* Extension API function pointers. */\n);\n\n/*\n** The following macros redefine the API routines so that they are\n** redirected through the global sqlite3_api structure.\n**\n** This header file is also used by the loadext.c source file\n** (part of the main SQLite library - not an extension) so that\n** it can get access to the sqlite3_api_routines structure\n** definition.  But the main library does not want to redefine\n** the API.  So the redefinition macros are only valid if the\n** SQLITE_CORE macros is undefined.\n*/\n#if !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION)\n#define sqlite3_aggregate_context      sqlite3_api->aggregate_context\n#ifndef SQLITE_OMIT_DEPRECATED\n#define sqlite3_aggregate_count        sqlite3_api->aggregate_count\n#endif\n#define sqlite3_bind_blob              sqlite3_api->bind_blob\n#define sqlite3_bind_double            sqlite3_api->bind_double\n#define sqlite3_bind_int               sqlite3_api->bind_int\n#define sqlite3_bind_int64             sqlite3_api->bind_int64\n#define sqlite3_bind_null              sqlite3_api->bind_null\n#define sqlite3_bind_parameter_count   sqlite3_api->bind_parameter_count\n#define sqlite3_bind_parameter_index   sqlite3_api->bind_parameter_index\n#define sqlite3_bind_parameter_name    sqlite3_api->bind_parameter_name\n#define sqlite3_bind_text              sqlite3_api->bind_text\n#define sqlite3_bind_text16            sqlite3_api->bind_text16\n#define sqlite3_bind_value             sqlite3_api->bind_value\n#define sqlite3_busy_handler           sqlite3_api->busy_handler\n#define sqlite3_busy_timeout           sqlite3_api->busy_timeout\n#define sqlite3_changes                sqlite3_api->changes\n#define sqlite3_close                  sqlite3_api->close\n#define sqlite3_collation_needed       sqlite3_api->collation_needed\n#define sqlite3_collation_needed16     sqlite3_api->collation_needed16\n#define sqlite3_column_blob            sqlite3_api->column_blob\n#define sqlite3_column_bytes           sqlite3_api->column_bytes\n#define sqlite3_column_bytes16         sqlite3_api->column_bytes16\n#define sqlite3_column_count           sqlite3_api->column_count\n#define sqlite3_column_database_name   sqlite3_api->column_database_name\n#define sqlite3_column_database_name16 sqlite3_api->column_database_name16\n#define sqlite3_column_decltype        sqlite3_api->column_decltype\n#define sqlite3_column_decltype16      sqlite3_api->column_decltype16\n#define sqlite3_column_double          sqlite3_api->column_double\n#define sqlite3_column_int             sqlite3_api->column_int\n#define sqlite3_column_int64           sqlite3_api->column_int64\n#define sqlite3_column_name            sqlite3_api->column_name\n#define sqlite3_column_name16          sqlite3_api->column_name16\n#define sqlite3_column_origin_name     sqlite3_api->column_origin_name\n#define sqlite3_column_origin_name16   sqlite3_api->column_origin_name16\n#define sqlite3_column_table_name      sqlite3_api->column_table_name\n#define sqlite3_column_table_name16    sqlite3_api->column_table_name16\n#define sqlite3_column_text            sqlite3_api->column_text\n#define sqlite3_column_text16          sqlite3_api->column_text16\n#define sqlite3_column_type            sqlite3_api->column_type\n#define sqlite3_column_value           sqlite3_api->column_value\n#define sqlite3_commit_hook            sqlite3_api->commit_hook\n#define sqlite3_complete               sqlite3_api->complete\n#define sqlite3_complete16             sqlite3_api->complete16\n#define sqlite3_create_collation       sqlite3_api->create_collation\n#define sqlite3_create_collation16     sqlite3_api->create_collation16\n#define sqlite3_create_function        sqlite3_api->create_function\n#define sqlite3_create_function16      sqlite3_api->create_function16\n#define sqlite3_create_module          sqlite3_api->create_module\n#define sqlite3_create_module_v2       sqlite3_api->create_module_v2\n#define sqlite3_data_count             sqlite3_api->data_count\n#define sqlite3_db_handle              sqlite3_api->db_handle\n#define sqlite3_declare_vtab           sqlite3_api->declare_vtab\n#define sqlite3_enable_shared_cache    sqlite3_api->enable_shared_cache\n#define sqlite3_errcode                sqlite3_api->errcode\n#define sqlite3_errmsg                 sqlite3_api->errmsg\n#define sqlite3_errmsg16               sqlite3_api->errmsg16\n#define sqlite3_exec                   sqlite3_api->exec\n#ifndef SQLITE_OMIT_DEPRECATED\n#define sqlite3_expired                sqlite3_api->expired\n#endif\n#define sqlite3_finalize               sqlite3_api->finalize\n#define sqlite3_free                   sqlite3_api->free\n#define sqlite3_free_table             sqlite3_api->free_table\n#define sqlite3_get_autocommit         sqlite3_api->get_autocommit\n#define sqlite3_get_auxdata            sqlite3_api->get_auxdata\n#define sqlite3_get_table              sqlite3_api->get_table\n#ifndef SQLITE_OMIT_DEPRECATED\n#define sqlite3_global_recover         sqlite3_api->global_recover\n#endif\n#define sqlite3_interrupt              sqlite3_api->interruptx\n#define sqlite3_last_insert_rowid      sqlite3_api->last_insert_rowid\n#define sqlite3_libversion             sqlite3_api->libversion\n#define sqlite3_libversion_number      sqlite3_api->libversion_number\n#define sqlite3_malloc                 sqlite3_api->malloc\n#define sqlite3_mprintf                sqlite3_api->mprintf\n#define sqlite3_open                   sqlite3_api->open\n#define sqlite3_open16                 sqlite3_api->open16\n#define sqlite3_prepare                sqlite3_api->prepare\n#define sqlite3_prepare16              sqlite3_api->prepare16\n#define sqlite3_prepare_v2             sqlite3_api->prepare_v2\n#define sqlite3_prepare16_v2           sqlite3_api->prepare16_v2\n#define sqlite3_profile                sqlite3_api->profile\n#define sqlite3_progress_handler       sqlite3_api->progress_handler\n#define sqlite3_realloc                sqlite3_api->realloc\n#define sqlite3_reset                  sqlite3_api->reset\n#define sqlite3_result_blob            sqlite3_api->result_blob\n#define sqlite3_result_double          sqlite3_api->result_double\n#define sqlite3_result_error           sqlite3_api->result_error\n#define sqlite3_result_error16         sqlite3_api->result_error16\n#define sqlite3_result_int             sqlite3_api->result_int\n#define sqlite3_result_int64           sqlite3_api->result_int64\n#define sqlite3_result_null            sqlite3_api->result_null\n#define sqlite3_result_text            sqlite3_api->result_text\n#define sqlite3_result_text16          sqlite3_api->result_text16\n#define sqlite3_result_text16be        sqlite3_api->result_text16be\n#define sqlite3_result_text16le        sqlite3_api->result_text16le\n#define sqlite3_result_value           sqlite3_api->result_value\n#define sqlite3_rollback_hook          sqlite3_api->rollback_hook\n#define sqlite3_set_authorizer         sqlite3_api->set_authorizer\n#define sqlite3_set_auxdata            sqlite3_api->set_auxdata\n#define sqlite3_snprintf               sqlite3_api->xsnprintf\n#define sqlite3_step                   sqlite3_api->step\n#define sqlite3_table_column_metadata  sqlite3_api->table_column_metadata\n#define sqlite3_thread_cleanup         sqlite3_api->thread_cleanup\n#define sqlite3_total_changes          sqlite3_api->total_changes\n#define sqlite3_trace                  sqlite3_api->trace\n#ifndef SQLITE_OMIT_DEPRECATED\n#define sqlite3_transfer_bindings      sqlite3_api->transfer_bindings\n#endif\n#define sqlite3_update_hook            sqlite3_api->update_hook\n#define sqlite3_user_data              sqlite3_api->user_data\n#define sqlite3_value_blob             sqlite3_api->value_blob\n#define sqlite3_value_bytes            sqlite3_api->value_bytes\n#define sqlite3_value_bytes16          sqlite3_api->value_bytes16\n#define sqlite3_value_double           sqlite3_api->value_double\n#define sqlite3_value_int              sqlite3_api->value_int\n#define sqlite3_value_int64            sqlite3_api->value_int64\n#define sqlite3_value_numeric_type     sqlite3_api->value_numeric_type\n#define sqlite3_value_text             sqlite3_api->value_text\n#define sqlite3_value_text16           sqlite3_api->value_text16\n#define sqlite3_value_text16be         sqlite3_api->value_text16be\n#define sqlite3_value_text16le         sqlite3_api->value_text16le\n#define sqlite3_value_type             sqlite3_api->value_type\n#define sqlite3_vmprintf               sqlite3_api->vmprintf\n#define sqlite3_vsnprintf              sqlite3_api->xvsnprintf\n#define sqlite3_overload_function      sqlite3_api->overload_function\n#define sqlite3_prepare_v2             sqlite3_api->prepare_v2\n#define sqlite3_prepare16_v2           sqlite3_api->prepare16_v2\n#define sqlite3_clear_bindings         sqlite3_api->clear_bindings\n#define sqlite3_bind_zeroblob          sqlite3_api->bind_zeroblob\n#define sqlite3_blob_bytes             sqlite3_api->blob_bytes\n#define sqlite3_blob_close             sqlite3_api->blob_close\n#define sqlite3_blob_open              sqlite3_api->blob_open\n#define sqlite3_blob_read              sqlite3_api->blob_read\n#define sqlite3_blob_write             sqlite3_api->blob_write\n#define sqlite3_create_collation_v2    sqlite3_api->create_collation_v2\n#define sqlite3_file_control           sqlite3_api->file_control\n#define sqlite3_memory_highwater       sqlite3_api->memory_highwater\n#define sqlite3_memory_used            sqlite3_api->memory_used\n#define sqlite3_mutex_alloc            sqlite3_api->mutex_alloc\n#define sqlite3_mutex_enter            sqlite3_api->mutex_enter\n#define sqlite3_mutex_free             sqlite3_api->mutex_free\n#define sqlite3_mutex_leave            sqlite3_api->mutex_leave\n#define sqlite3_mutex_try              sqlite3_api->mutex_try\n#define sqlite3_open_v2                sqlite3_api->open_v2\n#define sqlite3_release_memory         sqlite3_api->release_memory\n#define sqlite3_result_error_nomem     sqlite3_api->result_error_nomem\n#define sqlite3_result_error_toobig    sqlite3_api->result_error_toobig\n#define sqlite3_sleep                  sqlite3_api->sleep\n#define sqlite3_soft_heap_limit        sqlite3_api->soft_heap_limit\n#define sqlite3_vfs_find               sqlite3_api->vfs_find\n#define sqlite3_vfs_register           sqlite3_api->vfs_register\n#define sqlite3_vfs_unregister         sqlite3_api->vfs_unregister\n#define sqlite3_threadsafe             sqlite3_api->xthreadsafe\n#define sqlite3_result_zeroblob        sqlite3_api->result_zeroblob\n#define sqlite3_result_error_code      sqlite3_api->result_error_code\n#define sqlite3_test_control           sqlite3_api->test_control\n#define sqlite3_randomness             sqlite3_api->randomness\n#define sqlite3_context_db_handle      sqlite3_api->context_db_handle\n#define sqlite3_extended_result_codes  sqlite3_api->extended_result_codes\n#define sqlite3_limit                  sqlite3_api->limit\n#define sqlite3_next_stmt              sqlite3_api->next_stmt\n#define sqlite3_sql                    sqlite3_api->sql\n#define sqlite3_status                 sqlite3_api->status\n#define sqlite3_backup_finish          sqlite3_api->backup_finish\n#define sqlite3_backup_init            sqlite3_api->backup_init\n#define sqlite3_backup_pagecount       sqlite3_api->backup_pagecount\n#define sqlite3_backup_remaining       sqlite3_api->backup_remaining\n#define sqlite3_backup_step            sqlite3_api->backup_step\n#define sqlite3_compileoption_get      sqlite3_api->compileoption_get\n#define sqlite3_compileoption_used     sqlite3_api->compileoption_used\n#define sqlite3_create_function_v2     sqlite3_api->create_function_v2\n#define sqlite3_db_config              sqlite3_api->db_config\n#define sqlite3_db_mutex               sqlite3_api->db_mutex\n#define sqlite3_db_status              sqlite3_api->db_status\n#define sqlite3_extended_errcode       sqlite3_api->extended_errcode\n#define sqlite3_log                    sqlite3_api->log\n#define sqlite3_soft_heap_limit64      sqlite3_api->soft_heap_limit64\n#define sqlite3_sourceid               sqlite3_api->sourceid\n#define sqlite3_stmt_status            sqlite3_api->stmt_status\n#define sqlite3_strnicmp               sqlite3_api->strnicmp\n#define sqlite3_unlock_notify          sqlite3_api->unlock_notify\n#define sqlite3_wal_autocheckpoint     sqlite3_api->wal_autocheckpoint\n#define sqlite3_wal_checkpoint         sqlite3_api->wal_checkpoint\n#define sqlite3_wal_hook               sqlite3_api->wal_hook\n#define sqlite3_blob_reopen            sqlite3_api->blob_reopen\n#define sqlite3_vtab_config            sqlite3_api->vtab_config\n#define sqlite3_vtab_on_conflict       sqlite3_api->vtab_on_conflict\n/* Version 3.7.16 and later */\n#define sqlite3_close_v2               sqlite3_api->close_v2\n#define sqlite3_db_filename            sqlite3_api->db_filename\n#define sqlite3_db_readonly            sqlite3_api->db_readonly\n#define sqlite3_db_release_memory      sqlite3_api->db_release_memory\n#define sqlite3_errstr                 sqlite3_api->errstr\n#define sqlite3_stmt_busy              sqlite3_api->stmt_busy\n#define sqlite3_stmt_readonly          sqlite3_api->stmt_readonly\n#define sqlite3_stricmp                sqlite3_api->stricmp\n#define sqlite3_uri_boolean            sqlite3_api->uri_boolean\n#define sqlite3_uri_int64              sqlite3_api->uri_int64\n#define sqlite3_uri_parameter          sqlite3_api->uri_parameter\n#define sqlite3_uri_vsnprintf          sqlite3_api->xvsnprintf\n#define sqlite3_wal_checkpoint_v2      sqlite3_api->wal_checkpoint_v2\n/* Version 3.8.7 and later */\n#define sqlite3_auto_extension         sqlite3_api->auto_extension\n#define sqlite3_bind_blob64            sqlite3_api->bind_blob64\n#define sqlite3_bind_text64            sqlite3_api->bind_text64\n#define sqlite3_cancel_auto_extension  sqlite3_api->cancel_auto_extension\n#define sqlite3_load_extension         sqlite3_api->load_extension\n#define sqlite3_malloc64               sqlite3_api->malloc64\n#define sqlite3_msize                  sqlite3_api->msize\n#define sqlite3_realloc64              sqlite3_api->realloc64\n#define sqlite3_reset_auto_extension   sqlite3_api->reset_auto_extension\n#define sqlite3_result_blob64          sqlite3_api->result_blob64\n#define sqlite3_result_text64          sqlite3_api->result_text64\n#define sqlite3_strglob                sqlite3_api->strglob\n/* Version 3.8.11 and later */\n#define sqlite3_value_dup              sqlite3_api->value_dup\n#define sqlite3_value_free             sqlite3_api->value_free\n#define sqlite3_result_zeroblob64      sqlite3_api->result_zeroblob64\n#define sqlite3_bind_zeroblob64        sqlite3_api->bind_zeroblob64\n/* Version 3.9.0 and later */\n#define sqlite3_value_subtype          sqlite3_api->value_subtype\n#define sqlite3_result_subtype         sqlite3_api->result_subtype\n/* Version 3.10.0 and later */\n#define sqlite3_status64               sqlite3_api->status64\n#define sqlite3_strlike                sqlite3_api->strlike\n#define sqlite3_db_cacheflush          sqlite3_api->db_cacheflush\n/* Version 3.12.0 and later */\n#define sqlite3_system_errno           sqlite3_api->system_errno\n/* Version 3.14.0 and later */\n#define sqlite3_trace_v2               sqlite3_api->trace_v2\n#define sqlite3_expanded_sql           sqlite3_api->expanded_sql\n/* Version 3.18.0 and later */\n#define sqlite3_set_last_insert_rowid  sqlite3_api->set_last_insert_rowid\n/* Version 3.20.0 and later */\n#define sqlite3_prepare_v3             sqlite3_api->prepare_v3\n#define sqlite3_prepare16_v3           sqlite3_api->prepare16_v3\n#define sqlite3_bind_pointer           sqlite3_api->bind_pointer\n#define sqlite3_result_pointer         sqlite3_api->result_pointer\n#define sqlite3_value_pointer          sqlite3_api->value_pointer\n/* Version 3.22.0 and later */\n#define sqlite3_vtab_nochange          sqlite3_api->vtab_nochange\n#define sqlite3_value_nochange         sqlite3_api->value_nochange\n#define sqlite3_vtab_collation         sqlite3_api->vtab_collation\n/* Version 3.24.0 and later */\n#define sqlite3_keyword_count          sqlite3_api->keyword_count\n#define sqlite3_keyword_name           sqlite3_api->keyword_name\n#define sqlite3_keyword_check          sqlite3_api->keyword_check\n#define sqlite3_str_new                sqlite3_api->str_new\n#define sqlite3_str_finish             sqlite3_api->str_finish\n#define sqlite3_str_appendf            sqlite3_api->str_appendf\n#define sqlite3_str_vappendf           sqlite3_api->str_vappendf\n#define sqlite3_str_append             sqlite3_api->str_append\n#define sqlite3_str_appendall          sqlite3_api->str_appendall\n#define sqlite3_str_appendchar         sqlite3_api->str_appendchar\n#define sqlite3_str_reset              sqlite3_api->str_reset\n#define sqlite3_str_errcode            sqlite3_api->str_errcode\n#define sqlite3_str_length             sqlite3_api->str_length\n#define sqlite3_str_value              sqlite3_api->str_value\n/* Version 3.25.0 and later */\n#define sqlite3_create_window_function sqlite3_api->create_window_function\n/* Version 3.26.0 and later */\n#define sqlite3_normalized_sql         sqlite3_api->normalized_sql\n\n/* SQLCipher APIs */\n#ifdef SQLITE_HAS_CODEC\n#define sqlite3_key                    sqlite3_api->sqlcipher->key\n#define sqlite3_key_v2                 sqlite3_api->sqlcipher->key_v2\n#define sqlite3_rekey                  sqlite3_api->sqlcipher->rekey\n#define sqlite3_rekey_v2               sqlite3_api->sqlcipher->rekey_v2\n#define sqlcipher_register_provider    sqlite3_api->sqlcipher->register_provider\n#define sqlcipher_get_provider         sqlite3_api->sqlcipher->get_provider\n#ifdef SQLCIPHER_CRYPTO_CUSTOM\n#define sqlcipher_register_custom_provider    sqlite3_api->sqlcipher->register_custom_provider\n#define sqlcipher_unregister_custom_provider  sqlite3_api->sqlcipher->unregister_custom_provider\n#define sqlcipher_get_fallback_provider       sqlite3_api->sqlcipher->get_fallback_provider\n#endif\n#endif\n\n#endif /* !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION) */\n\n#if !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION)\n  /* This case when the file really is being compiled as a loadable \n  ** extension */\n# define SQLITE_EXTENSION_INIT1     const sqlite3_api_routines *sqlite3_api=0;\n# define SQLITE_EXTENSION_INIT2(v)  sqlite3_api=v;\n# define SQLITE_EXTENSION_INIT3     \\\n    extern const sqlite3_api_routines *sqlite3_api;\n#else\n  /* This case when the file is being statically linked into the \n  ** application */\n# define SQLITE_EXTENSION_INIT1     /*no-op*/\n# define SQLITE_EXTENSION_INIT2(v)  (void)v; /* unused parameter */\n# define SQLITE_EXTENSION_INIT3     /*no-op*/\n#endif\n\n#endif /* SQLITE3EXT_H */\n"
  },
  {
    "path": "deprecated/android/sqlcipher/sqlite3session.h",
    "content": "\n#if !defined(__SQLITESESSION_H_) && defined(SQLITE_ENABLE_SESSION)\n#define __SQLITESESSION_H_ 1\n\n/*\n** Make sure we can call this stuff from C++.\n*/\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n#include \"sqlite3.h\"\n\n/*\n** CAPI3REF: Session Object Handle\n**\n** An instance of this object is a [session] that can be used to\n** record changes to a database.\n*/\ntypedef struct sqlite3_session sqlite3_session;\n\n/*\n** CAPI3REF: Changeset Iterator Handle\n**\n** An instance of this object acts as a cursor for iterating\n** over the elements of a [changeset] or [patchset].\n*/\ntypedef struct sqlite3_changeset_iter sqlite3_changeset_iter;\n\n/*\n** CAPI3REF: Create A New Session Object\n** CONSTRUCTOR: sqlite3_session\n**\n** Create a new session object attached to database handle db. If successful,\n** a pointer to the new object is written to *ppSession and SQLITE_OK is\n** returned. If an error occurs, *ppSession is set to NULL and an SQLite\n** error code (e.g. SQLITE_NOMEM) is returned.\n**\n** It is possible to create multiple session objects attached to a single\n** database handle.\n**\n** Session objects created using this function should be deleted using the\n** [sqlite3session_delete()] function before the database handle that they\n** are attached to is itself closed. If the database handle is closed before\n** the session object is deleted, then the results of calling any session\n** module function, including [sqlite3session_delete()] on the session object\n** are undefined.\n**\n** Because the session module uses the [sqlite3_preupdate_hook()] API, it\n** is not possible for an application to register a pre-update hook on a\n** database handle that has one or more session objects attached. Nor is\n** it possible to create a session object attached to a database handle for\n** which a pre-update hook is already defined. The results of attempting \n** either of these things are undefined.\n**\n** The session object will be used to create changesets for tables in\n** database zDb, where zDb is either \"main\", or \"temp\", or the name of an\n** attached database. It is not an error if database zDb is not attached\n** to the database when the session object is created.\n*/\nint sqlite3session_create(\n  sqlite3 *db,                    /* Database handle */\n  const char *zDb,                /* Name of db (e.g. \"main\") */\n  sqlite3_session **ppSession     /* OUT: New session object */\n);\n\n/*\n** CAPI3REF: Delete A Session Object\n** DESTRUCTOR: sqlite3_session\n**\n** Delete a session object previously allocated using \n** [sqlite3session_create()]. Once a session object has been deleted, the\n** results of attempting to use pSession with any other session module\n** function are undefined.\n**\n** Session objects must be deleted before the database handle to which they\n** are attached is closed. Refer to the documentation for \n** [sqlite3session_create()] for details.\n*/\nvoid sqlite3session_delete(sqlite3_session *pSession);\n\n\n/*\n** CAPI3REF: Enable Or Disable A Session Object\n** METHOD: sqlite3_session\n**\n** Enable or disable the recording of changes by a session object. When\n** enabled, a session object records changes made to the database. When\n** disabled - it does not. A newly created session object is enabled.\n** Refer to the documentation for [sqlite3session_changeset()] for further\n** details regarding how enabling and disabling a session object affects\n** the eventual changesets.\n**\n** Passing zero to this function disables the session. Passing a value\n** greater than zero enables it. Passing a value less than zero is a \n** no-op, and may be used to query the current state of the session.\n**\n** The return value indicates the final state of the session object: 0 if \n** the session is disabled, or 1 if it is enabled.\n*/\nint sqlite3session_enable(sqlite3_session *pSession, int bEnable);\n\n/*\n** CAPI3REF: Set Or Clear the Indirect Change Flag\n** METHOD: sqlite3_session\n**\n** Each change recorded by a session object is marked as either direct or\n** indirect. A change is marked as indirect if either:\n**\n** <ul>\n**   <li> The session object \"indirect\" flag is set when the change is\n**        made, or\n**   <li> The change is made by an SQL trigger or foreign key action \n**        instead of directly as a result of a users SQL statement.\n** </ul>\n**\n** If a single row is affected by more than one operation within a session,\n** then the change is considered indirect if all operations meet the criteria\n** for an indirect change above, or direct otherwise.\n**\n** This function is used to set, clear or query the session object indirect\n** flag.  If the second argument passed to this function is zero, then the\n** indirect flag is cleared. If it is greater than zero, the indirect flag\n** is set. Passing a value less than zero does not modify the current value\n** of the indirect flag, and may be used to query the current state of the \n** indirect flag for the specified session object.\n**\n** The return value indicates the final state of the indirect flag: 0 if \n** it is clear, or 1 if it is set.\n*/\nint sqlite3session_indirect(sqlite3_session *pSession, int bIndirect);\n\n/*\n** CAPI3REF: Attach A Table To A Session Object\n** METHOD: sqlite3_session\n**\n** If argument zTab is not NULL, then it is the name of a table to attach\n** to the session object passed as the first argument. All subsequent changes \n** made to the table while the session object is enabled will be recorded. See \n** documentation for [sqlite3session_changeset()] for further details.\n**\n** Or, if argument zTab is NULL, then changes are recorded for all tables\n** in the database. If additional tables are added to the database (by \n** executing \"CREATE TABLE\" statements) after this call is made, changes for \n** the new tables are also recorded.\n**\n** Changes can only be recorded for tables that have a PRIMARY KEY explicitly\n** defined as part of their CREATE TABLE statement. It does not matter if the \n** PRIMARY KEY is an \"INTEGER PRIMARY KEY\" (rowid alias) or not. The PRIMARY\n** KEY may consist of a single column, or may be a composite key.\n** \n** It is not an error if the named table does not exist in the database. Nor\n** is it an error if the named table does not have a PRIMARY KEY. However,\n** no changes will be recorded in either of these scenarios.\n**\n** Changes are not recorded for individual rows that have NULL values stored\n** in one or more of their PRIMARY KEY columns.\n**\n** SQLITE_OK is returned if the call completes without error. Or, if an error \n** occurs, an SQLite error code (e.g. SQLITE_NOMEM) is returned.\n**\n** <h3>Special sqlite_stat1 Handling</h3>\n**\n** As of SQLite version 3.22.0, the \"sqlite_stat1\" table is an exception to \n** some of the rules above. In SQLite, the schema of sqlite_stat1 is:\n**  <pre>\n**  &nbsp;     CREATE TABLE sqlite_stat1(tbl,idx,stat)  \n**  </pre>\n**\n** Even though sqlite_stat1 does not have a PRIMARY KEY, changes are \n** recorded for it as if the PRIMARY KEY is (tbl,idx). Additionally, changes \n** are recorded for rows for which (idx IS NULL) is true. However, for such\n** rows a zero-length blob (SQL value X'') is stored in the changeset or\n** patchset instead of a NULL value. This allows such changesets to be\n** manipulated by legacy implementations of sqlite3changeset_invert(),\n** concat() and similar.\n**\n** The sqlite3changeset_apply() function automatically converts the \n** zero-length blob back to a NULL value when updating the sqlite_stat1\n** table. However, if the application calls sqlite3changeset_new(),\n** sqlite3changeset_old() or sqlite3changeset_conflict on a changeset \n** iterator directly (including on a changeset iterator passed to a\n** conflict-handler callback) then the X'' value is returned. The application\n** must translate X'' to NULL itself if required.\n**\n** Legacy (older than 3.22.0) versions of the sessions module cannot capture\n** changes made to the sqlite_stat1 table. Legacy versions of the\n** sqlite3changeset_apply() function silently ignore any modifications to the\n** sqlite_stat1 table that are part of a changeset or patchset.\n*/\nint sqlite3session_attach(\n  sqlite3_session *pSession,      /* Session object */\n  const char *zTab                /* Table name */\n);\n\n/*\n** CAPI3REF: Set a table filter on a Session Object.\n** METHOD: sqlite3_session\n**\n** The second argument (xFilter) is the \"filter callback\". For changes to rows \n** in tables that are not attached to the Session object, the filter is called\n** to determine whether changes to the table's rows should be tracked or not. \n** If xFilter returns 0, changes is not tracked. Note that once a table is \n** attached, xFilter will not be called again.\n*/\nvoid sqlite3session_table_filter(\n  sqlite3_session *pSession,      /* Session object */\n  int(*xFilter)(\n    void *pCtx,                   /* Copy of third arg to _filter_table() */\n    const char *zTab              /* Table name */\n  ),\n  void *pCtx                      /* First argument passed to xFilter */\n);\n\n/*\n** CAPI3REF: Generate A Changeset From A Session Object\n** METHOD: sqlite3_session\n**\n** Obtain a changeset containing changes to the tables attached to the \n** session object passed as the first argument. If successful, \n** set *ppChangeset to point to a buffer containing the changeset \n** and *pnChangeset to the size of the changeset in bytes before returning\n** SQLITE_OK. If an error occurs, set both *ppChangeset and *pnChangeset to\n** zero and return an SQLite error code.\n**\n** A changeset consists of zero or more INSERT, UPDATE and/or DELETE changes,\n** each representing a change to a single row of an attached table. An INSERT\n** change contains the values of each field of a new database row. A DELETE\n** contains the original values of each field of a deleted database row. An\n** UPDATE change contains the original values of each field of an updated\n** database row along with the updated values for each updated non-primary-key\n** column. It is not possible for an UPDATE change to represent a change that\n** modifies the values of primary key columns. If such a change is made, it\n** is represented in a changeset as a DELETE followed by an INSERT.\n**\n** Changes are not recorded for rows that have NULL values stored in one or \n** more of their PRIMARY KEY columns. If such a row is inserted or deleted,\n** no corresponding change is present in the changesets returned by this\n** function. If an existing row with one or more NULL values stored in\n** PRIMARY KEY columns is updated so that all PRIMARY KEY columns are non-NULL,\n** only an INSERT is appears in the changeset. Similarly, if an existing row\n** with non-NULL PRIMARY KEY values is updated so that one or more of its\n** PRIMARY KEY columns are set to NULL, the resulting changeset contains a\n** DELETE change only.\n**\n** The contents of a changeset may be traversed using an iterator created\n** using the [sqlite3changeset_start()] API. A changeset may be applied to\n** a database with a compatible schema using the [sqlite3changeset_apply()]\n** API.\n**\n** Within a changeset generated by this function, all changes related to a\n** single table are grouped together. In other words, when iterating through\n** a changeset or when applying a changeset to a database, all changes related\n** to a single table are processed before moving on to the next table. Tables\n** are sorted in the same order in which they were attached (or auto-attached)\n** to the sqlite3_session object. The order in which the changes related to\n** a single table are stored is undefined.\n**\n** Following a successful call to this function, it is the responsibility of\n** the caller to eventually free the buffer that *ppChangeset points to using\n** [sqlite3_free()].\n**\n** <h3>Changeset Generation</h3>\n**\n** Once a table has been attached to a session object, the session object\n** records the primary key values of all new rows inserted into the table.\n** It also records the original primary key and other column values of any\n** deleted or updated rows. For each unique primary key value, data is only\n** recorded once - the first time a row with said primary key is inserted,\n** updated or deleted in the lifetime of the session.\n**\n** There is one exception to the previous paragraph: when a row is inserted,\n** updated or deleted, if one or more of its primary key columns contain a\n** NULL value, no record of the change is made.\n**\n** The session object therefore accumulates two types of records - those\n** that consist of primary key values only (created when the user inserts\n** a new record) and those that consist of the primary key values and the\n** original values of other table columns (created when the users deletes\n** or updates a record).\n**\n** When this function is called, the requested changeset is created using\n** both the accumulated records and the current contents of the database\n** file. Specifically:\n**\n** <ul>\n**   <li> For each record generated by an insert, the database is queried\n**        for a row with a matching primary key. If one is found, an INSERT\n**        change is added to the changeset. If no such row is found, no change \n**        is added to the changeset.\n**\n**   <li> For each record generated by an update or delete, the database is \n**        queried for a row with a matching primary key. If such a row is\n**        found and one or more of the non-primary key fields have been\n**        modified from their original values, an UPDATE change is added to \n**        the changeset. Or, if no such row is found in the table, a DELETE \n**        change is added to the changeset. If there is a row with a matching\n**        primary key in the database, but all fields contain their original\n**        values, no change is added to the changeset.\n** </ul>\n**\n** This means, amongst other things, that if a row is inserted and then later\n** deleted while a session object is active, neither the insert nor the delete\n** will be present in the changeset. Or if a row is deleted and then later a \n** row with the same primary key values inserted while a session object is\n** active, the resulting changeset will contain an UPDATE change instead of\n** a DELETE and an INSERT.\n**\n** When a session object is disabled (see the [sqlite3session_enable()] API),\n** it does not accumulate records when rows are inserted, updated or deleted.\n** This may appear to have some counter-intuitive effects if a single row\n** is written to more than once during a session. For example, if a row\n** is inserted while a session object is enabled, then later deleted while \n** the same session object is disabled, no INSERT record will appear in the\n** changeset, even though the delete took place while the session was disabled.\n** Or, if one field of a row is updated while a session is disabled, and \n** another field of the same row is updated while the session is enabled, the\n** resulting changeset will contain an UPDATE change that updates both fields.\n*/\nint sqlite3session_changeset(\n  sqlite3_session *pSession,      /* Session object */\n  int *pnChangeset,               /* OUT: Size of buffer at *ppChangeset */\n  void **ppChangeset              /* OUT: Buffer containing changeset */\n);\n\n/*\n** CAPI3REF: Load The Difference Between Tables Into A Session\n** METHOD: sqlite3_session\n**\n** If it is not already attached to the session object passed as the first\n** argument, this function attaches table zTbl in the same manner as the\n** [sqlite3session_attach()] function. If zTbl does not exist, or if it\n** does not have a primary key, this function is a no-op (but does not return\n** an error).\n**\n** Argument zFromDb must be the name of a database (\"main\", \"temp\" etc.)\n** attached to the same database handle as the session object that contains \n** a table compatible with the table attached to the session by this function.\n** A table is considered compatible if it:\n**\n** <ul>\n**   <li> Has the same name,\n**   <li> Has the same set of columns declared in the same order, and\n**   <li> Has the same PRIMARY KEY definition.\n** </ul>\n**\n** If the tables are not compatible, SQLITE_SCHEMA is returned. If the tables\n** are compatible but do not have any PRIMARY KEY columns, it is not an error\n** but no changes are added to the session object. As with other session\n** APIs, tables without PRIMARY KEYs are simply ignored.\n**\n** This function adds a set of changes to the session object that could be\n** used to update the table in database zFrom (call this the \"from-table\") \n** so that its content is the same as the table attached to the session \n** object (call this the \"to-table\"). Specifically:\n**\n** <ul>\n**   <li> For each row (primary key) that exists in the to-table but not in \n**     the from-table, an INSERT record is added to the session object.\n**\n**   <li> For each row (primary key) that exists in the to-table but not in \n**     the from-table, a DELETE record is added to the session object.\n**\n**   <li> For each row (primary key) that exists in both tables, but features \n**     different non-PK values in each, an UPDATE record is added to the\n**     session.  \n** </ul>\n**\n** To clarify, if this function is called and then a changeset constructed\n** using [sqlite3session_changeset()], then after applying that changeset to \n** database zFrom the contents of the two compatible tables would be \n** identical.\n**\n** It an error if database zFrom does not exist or does not contain the\n** required compatible table.\n**\n** If the operation successful, SQLITE_OK is returned. Otherwise, an SQLite\n** error code. In this case, if argument pzErrMsg is not NULL, *pzErrMsg\n** may be set to point to a buffer containing an English language error \n** message. It is the responsibility of the caller to free this buffer using\n** sqlite3_free().\n*/\nint sqlite3session_diff(\n  sqlite3_session *pSession,\n  const char *zFromDb,\n  const char *zTbl,\n  char **pzErrMsg\n);\n\n\n/*\n** CAPI3REF: Generate A Patchset From A Session Object\n** METHOD: sqlite3_session\n**\n** The differences between a patchset and a changeset are that:\n**\n** <ul>\n**   <li> DELETE records consist of the primary key fields only. The \n**        original values of other fields are omitted.\n**   <li> The original values of any modified fields are omitted from \n**        UPDATE records.\n** </ul>\n**\n** A patchset blob may be used with up to date versions of all \n** sqlite3changeset_xxx API functions except for sqlite3changeset_invert(), \n** which returns SQLITE_CORRUPT if it is passed a patchset. Similarly,\n** attempting to use a patchset blob with old versions of the\n** sqlite3changeset_xxx APIs also provokes an SQLITE_CORRUPT error. \n**\n** Because the non-primary key \"old.*\" fields are omitted, no \n** SQLITE_CHANGESET_DATA conflicts can be detected or reported if a patchset\n** is passed to the sqlite3changeset_apply() API. Other conflict types work\n** in the same way as for changesets.\n**\n** Changes within a patchset are ordered in the same way as for changesets\n** generated by the sqlite3session_changeset() function (i.e. all changes for\n** a single table are grouped together, tables appear in the order in which\n** they were attached to the session object).\n*/\nint sqlite3session_patchset(\n  sqlite3_session *pSession,      /* Session object */\n  int *pnPatchset,                /* OUT: Size of buffer at *ppPatchset */\n  void **ppPatchset               /* OUT: Buffer containing patchset */\n);\n\n/*\n** CAPI3REF: Test if a changeset has recorded any changes.\n**\n** Return non-zero if no changes to attached tables have been recorded by \n** the session object passed as the first argument. Otherwise, if one or \n** more changes have been recorded, return zero.\n**\n** Even if this function returns zero, it is possible that calling\n** [sqlite3session_changeset()] on the session handle may still return a\n** changeset that contains no changes. This can happen when a row in \n** an attached table is modified and then later on the original values \n** are restored. However, if this function returns non-zero, then it is\n** guaranteed that a call to sqlite3session_changeset() will return a \n** changeset containing zero changes.\n*/\nint sqlite3session_isempty(sqlite3_session *pSession);\n\n/*\n** CAPI3REF: Create An Iterator To Traverse A Changeset \n** CONSTRUCTOR: sqlite3_changeset_iter\n**\n** Create an iterator used to iterate through the contents of a changeset.\n** If successful, *pp is set to point to the iterator handle and SQLITE_OK\n** is returned. Otherwise, if an error occurs, *pp is set to zero and an\n** SQLite error code is returned.\n**\n** The following functions can be used to advance and query a changeset \n** iterator created by this function:\n**\n** <ul>\n**   <li> [sqlite3changeset_next()]\n**   <li> [sqlite3changeset_op()]\n**   <li> [sqlite3changeset_new()]\n**   <li> [sqlite3changeset_old()]\n** </ul>\n**\n** It is the responsibility of the caller to eventually destroy the iterator\n** by passing it to [sqlite3changeset_finalize()]. The buffer containing the\n** changeset (pChangeset) must remain valid until after the iterator is\n** destroyed.\n**\n** Assuming the changeset blob was created by one of the\n** [sqlite3session_changeset()], [sqlite3changeset_concat()] or\n** [sqlite3changeset_invert()] functions, all changes within the changeset \n** that apply to a single table are grouped together. This means that when \n** an application iterates through a changeset using an iterator created by \n** this function, all changes that relate to a single table are visited \n** consecutively. There is no chance that the iterator will visit a change \n** the applies to table X, then one for table Y, and then later on visit \n** another change for table X.\n**\n** The behavior of sqlite3changeset_start_v2() and its streaming equivalent\n** may be modified by passing a combination of\n** [SQLITE_CHANGESETSTART_INVERT | supported flags] as the 4th parameter.\n**\n** Note that the sqlite3changeset_start_v2() API is still <b>experimental</b>\n** and therefore subject to change.\n*/\nint sqlite3changeset_start(\n  sqlite3_changeset_iter **pp,    /* OUT: New changeset iterator handle */\n  int nChangeset,                 /* Size of changeset blob in bytes */\n  void *pChangeset                /* Pointer to blob containing changeset */\n);\nint sqlite3changeset_start_v2(\n  sqlite3_changeset_iter **pp,    /* OUT: New changeset iterator handle */\n  int nChangeset,                 /* Size of changeset blob in bytes */\n  void *pChangeset,               /* Pointer to blob containing changeset */\n  int flags                       /* SESSION_CHANGESETSTART_* flags */\n);\n\n/*\n** CAPI3REF: Flags for sqlite3changeset_start_v2\n**\n** The following flags may passed via the 4th parameter to\n** [sqlite3changeset_start_v2] and [sqlite3changeset_start_v2_strm]:\n**\n** <dt>SQLITE_CHANGESETAPPLY_INVERT <dd>\n**   Invert the changeset while iterating through it. This is equivalent to\n**   inverting a changeset using sqlite3changeset_invert() before applying it.\n**   It is an error to specify this flag with a patchset.\n*/\n#define SQLITE_CHANGESETSTART_INVERT        0x0002\n\n\n/*\n** CAPI3REF: Advance A Changeset Iterator\n** METHOD: sqlite3_changeset_iter\n**\n** This function may only be used with iterators created by function\n** [sqlite3changeset_start()]. If it is called on an iterator passed to\n** a conflict-handler callback by [sqlite3changeset_apply()], SQLITE_MISUSE\n** is returned and the call has no effect.\n**\n** Immediately after an iterator is created by sqlite3changeset_start(), it\n** does not point to any change in the changeset. Assuming the changeset\n** is not empty, the first call to this function advances the iterator to\n** point to the first change in the changeset. Each subsequent call advances\n** the iterator to point to the next change in the changeset (if any). If\n** no error occurs and the iterator points to a valid change after a call\n** to sqlite3changeset_next() has advanced it, SQLITE_ROW is returned. \n** Otherwise, if all changes in the changeset have already been visited,\n** SQLITE_DONE is returned.\n**\n** If an error occurs, an SQLite error code is returned. Possible error \n** codes include SQLITE_CORRUPT (if the changeset buffer is corrupt) or \n** SQLITE_NOMEM.\n*/\nint sqlite3changeset_next(sqlite3_changeset_iter *pIter);\n\n/*\n** CAPI3REF: Obtain The Current Operation From A Changeset Iterator\n** METHOD: sqlite3_changeset_iter\n**\n** The pIter argument passed to this function may either be an iterator\n** passed to a conflict-handler by [sqlite3changeset_apply()], or an iterator\n** created by [sqlite3changeset_start()]. In the latter case, the most recent\n** call to [sqlite3changeset_next()] must have returned [SQLITE_ROW]. If this\n** is not the case, this function returns [SQLITE_MISUSE].\n**\n** If argument pzTab is not NULL, then *pzTab is set to point to a\n** nul-terminated utf-8 encoded string containing the name of the table\n** affected by the current change. The buffer remains valid until either\n** sqlite3changeset_next() is called on the iterator or until the \n** conflict-handler function returns. If pnCol is not NULL, then *pnCol is \n** set to the number of columns in the table affected by the change. If\n** pbIndirect is not NULL, then *pbIndirect is set to true (1) if the change\n** is an indirect change, or false (0) otherwise. See the documentation for\n** [sqlite3session_indirect()] for a description of direct and indirect\n** changes. Finally, if pOp is not NULL, then *pOp is set to one of \n** [SQLITE_INSERT], [SQLITE_DELETE] or [SQLITE_UPDATE], depending on the \n** type of change that the iterator currently points to.\n**\n** If no error occurs, SQLITE_OK is returned. If an error does occur, an\n** SQLite error code is returned. The values of the output variables may not\n** be trusted in this case.\n*/\nint sqlite3changeset_op(\n  sqlite3_changeset_iter *pIter,  /* Iterator object */\n  const char **pzTab,             /* OUT: Pointer to table name */\n  int *pnCol,                     /* OUT: Number of columns in table */\n  int *pOp,                       /* OUT: SQLITE_INSERT, DELETE or UPDATE */\n  int *pbIndirect                 /* OUT: True for an 'indirect' change */\n);\n\n/*\n** CAPI3REF: Obtain The Primary Key Definition Of A Table\n** METHOD: sqlite3_changeset_iter\n**\n** For each modified table, a changeset includes the following:\n**\n** <ul>\n**   <li> The number of columns in the table, and\n**   <li> Which of those columns make up the tables PRIMARY KEY.\n** </ul>\n**\n** This function is used to find which columns comprise the PRIMARY KEY of\n** the table modified by the change that iterator pIter currently points to.\n** If successful, *pabPK is set to point to an array of nCol entries, where\n** nCol is the number of columns in the table. Elements of *pabPK are set to\n** 0x01 if the corresponding column is part of the tables primary key, or\n** 0x00 if it is not.\n**\n** If argument pnCol is not NULL, then *pnCol is set to the number of columns\n** in the table.\n**\n** If this function is called when the iterator does not point to a valid\n** entry, SQLITE_MISUSE is returned and the output variables zeroed. Otherwise,\n** SQLITE_OK is returned and the output variables populated as described\n** above.\n*/\nint sqlite3changeset_pk(\n  sqlite3_changeset_iter *pIter,  /* Iterator object */\n  unsigned char **pabPK,          /* OUT: Array of boolean - true for PK cols */\n  int *pnCol                      /* OUT: Number of entries in output array */\n);\n\n/*\n** CAPI3REF: Obtain old.* Values From A Changeset Iterator\n** METHOD: sqlite3_changeset_iter\n**\n** The pIter argument passed to this function may either be an iterator\n** passed to a conflict-handler by [sqlite3changeset_apply()], or an iterator\n** created by [sqlite3changeset_start()]. In the latter case, the most recent\n** call to [sqlite3changeset_next()] must have returned SQLITE_ROW. \n** Furthermore, it may only be called if the type of change that the iterator\n** currently points to is either [SQLITE_DELETE] or [SQLITE_UPDATE]. Otherwise,\n** this function returns [SQLITE_MISUSE] and sets *ppValue to NULL.\n**\n** Argument iVal must be greater than or equal to 0, and less than the number\n** of columns in the table affected by the current change. Otherwise,\n** [SQLITE_RANGE] is returned and *ppValue is set to NULL.\n**\n** If successful, this function sets *ppValue to point to a protected\n** sqlite3_value object containing the iVal'th value from the vector of \n** original row values stored as part of the UPDATE or DELETE change and\n** returns SQLITE_OK. The name of the function comes from the fact that this \n** is similar to the \"old.*\" columns available to update or delete triggers.\n**\n** If some other error occurs (e.g. an OOM condition), an SQLite error code\n** is returned and *ppValue is set to NULL.\n*/\nint sqlite3changeset_old(\n  sqlite3_changeset_iter *pIter,  /* Changeset iterator */\n  int iVal,                       /* Column number */\n  sqlite3_value **ppValue         /* OUT: Old value (or NULL pointer) */\n);\n\n/*\n** CAPI3REF: Obtain new.* Values From A Changeset Iterator\n** METHOD: sqlite3_changeset_iter\n**\n** The pIter argument passed to this function may either be an iterator\n** passed to a conflict-handler by [sqlite3changeset_apply()], or an iterator\n** created by [sqlite3changeset_start()]. In the latter case, the most recent\n** call to [sqlite3changeset_next()] must have returned SQLITE_ROW. \n** Furthermore, it may only be called if the type of change that the iterator\n** currently points to is either [SQLITE_UPDATE] or [SQLITE_INSERT]. Otherwise,\n** this function returns [SQLITE_MISUSE] and sets *ppValue to NULL.\n**\n** Argument iVal must be greater than or equal to 0, and less than the number\n** of columns in the table affected by the current change. Otherwise,\n** [SQLITE_RANGE] is returned and *ppValue is set to NULL.\n**\n** If successful, this function sets *ppValue to point to a protected\n** sqlite3_value object containing the iVal'th value from the vector of \n** new row values stored as part of the UPDATE or INSERT change and\n** returns SQLITE_OK. If the change is an UPDATE and does not include\n** a new value for the requested column, *ppValue is set to NULL and \n** SQLITE_OK returned. The name of the function comes from the fact that \n** this is similar to the \"new.*\" columns available to update or delete \n** triggers.\n**\n** If some other error occurs (e.g. an OOM condition), an SQLite error code\n** is returned and *ppValue is set to NULL.\n*/\nint sqlite3changeset_new(\n  sqlite3_changeset_iter *pIter,  /* Changeset iterator */\n  int iVal,                       /* Column number */\n  sqlite3_value **ppValue         /* OUT: New value (or NULL pointer) */\n);\n\n/*\n** CAPI3REF: Obtain Conflicting Row Values From A Changeset Iterator\n** METHOD: sqlite3_changeset_iter\n**\n** This function should only be used with iterator objects passed to a\n** conflict-handler callback by [sqlite3changeset_apply()] with either\n** [SQLITE_CHANGESET_DATA] or [SQLITE_CHANGESET_CONFLICT]. If this function\n** is called on any other iterator, [SQLITE_MISUSE] is returned and *ppValue\n** is set to NULL.\n**\n** Argument iVal must be greater than or equal to 0, and less than the number\n** of columns in the table affected by the current change. Otherwise,\n** [SQLITE_RANGE] is returned and *ppValue is set to NULL.\n**\n** If successful, this function sets *ppValue to point to a protected\n** sqlite3_value object containing the iVal'th value from the \n** \"conflicting row\" associated with the current conflict-handler callback\n** and returns SQLITE_OK.\n**\n** If some other error occurs (e.g. an OOM condition), an SQLite error code\n** is returned and *ppValue is set to NULL.\n*/\nint sqlite3changeset_conflict(\n  sqlite3_changeset_iter *pIter,  /* Changeset iterator */\n  int iVal,                       /* Column number */\n  sqlite3_value **ppValue         /* OUT: Value from conflicting row */\n);\n\n/*\n** CAPI3REF: Determine The Number Of Foreign Key Constraint Violations\n** METHOD: sqlite3_changeset_iter\n**\n** This function may only be called with an iterator passed to an\n** SQLITE_CHANGESET_FOREIGN_KEY conflict handler callback. In this case\n** it sets the output variable to the total number of known foreign key\n** violations in the destination database and returns SQLITE_OK.\n**\n** In all other cases this function returns SQLITE_MISUSE.\n*/\nint sqlite3changeset_fk_conflicts(\n  sqlite3_changeset_iter *pIter,  /* Changeset iterator */\n  int *pnOut                      /* OUT: Number of FK violations */\n);\n\n\n/*\n** CAPI3REF: Finalize A Changeset Iterator\n** METHOD: sqlite3_changeset_iter\n**\n** This function is used to finalize an iterator allocated with\n** [sqlite3changeset_start()].\n**\n** This function should only be called on iterators created using the\n** [sqlite3changeset_start()] function. If an application calls this\n** function with an iterator passed to a conflict-handler by\n** [sqlite3changeset_apply()], [SQLITE_MISUSE] is immediately returned and the\n** call has no effect.\n**\n** If an error was encountered within a call to an sqlite3changeset_xxx()\n** function (for example an [SQLITE_CORRUPT] in [sqlite3changeset_next()] or an \n** [SQLITE_NOMEM] in [sqlite3changeset_new()]) then an error code corresponding\n** to that error is returned by this function. Otherwise, SQLITE_OK is\n** returned. This is to allow the following pattern (pseudo-code):\n**\n** <pre>\n**   sqlite3changeset_start();\n**   while( SQLITE_ROW==sqlite3changeset_next() ){\n**     // Do something with change.\n**   }\n**   rc = sqlite3changeset_finalize();\n**   if( rc!=SQLITE_OK ){\n**     // An error has occurred \n**   }\n** </pre>\n*/\nint sqlite3changeset_finalize(sqlite3_changeset_iter *pIter);\n\n/*\n** CAPI3REF: Invert A Changeset\n**\n** This function is used to \"invert\" a changeset object. Applying an inverted\n** changeset to a database reverses the effects of applying the uninverted\n** changeset. Specifically:\n**\n** <ul>\n**   <li> Each DELETE change is changed to an INSERT, and\n**   <li> Each INSERT change is changed to a DELETE, and\n**   <li> For each UPDATE change, the old.* and new.* values are exchanged.\n** </ul>\n**\n** This function does not change the order in which changes appear within\n** the changeset. It merely reverses the sense of each individual change.\n**\n** If successful, a pointer to a buffer containing the inverted changeset\n** is stored in *ppOut, the size of the same buffer is stored in *pnOut, and\n** SQLITE_OK is returned. If an error occurs, both *pnOut and *ppOut are\n** zeroed and an SQLite error code returned.\n**\n** It is the responsibility of the caller to eventually call sqlite3_free()\n** on the *ppOut pointer to free the buffer allocation following a successful \n** call to this function.\n**\n** WARNING/TODO: This function currently assumes that the input is a valid\n** changeset. If it is not, the results are undefined.\n*/\nint sqlite3changeset_invert(\n  int nIn, const void *pIn,       /* Input changeset */\n  int *pnOut, void **ppOut        /* OUT: Inverse of input */\n);\n\n/*\n** CAPI3REF: Concatenate Two Changeset Objects\n**\n** This function is used to concatenate two changesets, A and B, into a \n** single changeset. The result is a changeset equivalent to applying\n** changeset A followed by changeset B. \n**\n** This function combines the two input changesets using an \n** sqlite3_changegroup object. Calling it produces similar results as the\n** following code fragment:\n**\n** <pre>\n**   sqlite3_changegroup *pGrp;\n**   rc = sqlite3_changegroup_new(&pGrp);\n**   if( rc==SQLITE_OK ) rc = sqlite3changegroup_add(pGrp, nA, pA);\n**   if( rc==SQLITE_OK ) rc = sqlite3changegroup_add(pGrp, nB, pB);\n**   if( rc==SQLITE_OK ){\n**     rc = sqlite3changegroup_output(pGrp, pnOut, ppOut);\n**   }else{\n**     *ppOut = 0;\n**     *pnOut = 0;\n**   }\n** </pre>\n**\n** Refer to the sqlite3_changegroup documentation below for details.\n*/\nint sqlite3changeset_concat(\n  int nA,                         /* Number of bytes in buffer pA */\n  void *pA,                       /* Pointer to buffer containing changeset A */\n  int nB,                         /* Number of bytes in buffer pB */\n  void *pB,                       /* Pointer to buffer containing changeset B */\n  int *pnOut,                     /* OUT: Number of bytes in output changeset */\n  void **ppOut                    /* OUT: Buffer containing output changeset */\n);\n\n\n/*\n** CAPI3REF: Changegroup Handle\n**\n** A changegroup is an object used to combine two or more \n** [changesets] or [patchsets]\n*/\ntypedef struct sqlite3_changegroup sqlite3_changegroup;\n\n/*\n** CAPI3REF: Create A New Changegroup Object\n** CONSTRUCTOR: sqlite3_changegroup\n**\n** An sqlite3_changegroup object is used to combine two or more changesets\n** (or patchsets) into a single changeset (or patchset). A single changegroup\n** object may combine changesets or patchsets, but not both. The output is\n** always in the same format as the input.\n**\n** If successful, this function returns SQLITE_OK and populates (*pp) with\n** a pointer to a new sqlite3_changegroup object before returning. The caller\n** should eventually free the returned object using a call to \n** sqlite3changegroup_delete(). If an error occurs, an SQLite error code\n** (i.e. SQLITE_NOMEM) is returned and *pp is set to NULL.\n**\n** The usual usage pattern for an sqlite3_changegroup object is as follows:\n**\n** <ul>\n**   <li> It is created using a call to sqlite3changegroup_new().\n**\n**   <li> Zero or more changesets (or patchsets) are added to the object\n**        by calling sqlite3changegroup_add().\n**\n**   <li> The result of combining all input changesets together is obtained \n**        by the application via a call to sqlite3changegroup_output().\n**\n**   <li> The object is deleted using a call to sqlite3changegroup_delete().\n** </ul>\n**\n** Any number of calls to add() and output() may be made between the calls to\n** new() and delete(), and in any order.\n**\n** As well as the regular sqlite3changegroup_add() and \n** sqlite3changegroup_output() functions, also available are the streaming\n** versions sqlite3changegroup_add_strm() and sqlite3changegroup_output_strm().\n*/\nint sqlite3changegroup_new(sqlite3_changegroup **pp);\n\n/*\n** CAPI3REF: Add A Changeset To A Changegroup\n** METHOD: sqlite3_changegroup\n**\n** Add all changes within the changeset (or patchset) in buffer pData (size\n** nData bytes) to the changegroup. \n**\n** If the buffer contains a patchset, then all prior calls to this function\n** on the same changegroup object must also have specified patchsets. Or, if\n** the buffer contains a changeset, so must have the earlier calls to this\n** function. Otherwise, SQLITE_ERROR is returned and no changes are added\n** to the changegroup.\n**\n** Rows within the changeset and changegroup are identified by the values in\n** their PRIMARY KEY columns. A change in the changeset is considered to\n** apply to the same row as a change already present in the changegroup if\n** the two rows have the same primary key.\n**\n** Changes to rows that do not already appear in the changegroup are\n** simply copied into it. Or, if both the new changeset and the changegroup\n** contain changes that apply to a single row, the final contents of the\n** changegroup depends on the type of each change, as follows:\n**\n** <table border=1 style=\"margin-left:8ex;margin-right:8ex\">\n**   <tr><th style=\"white-space:pre\">Existing Change  </th>\n**       <th style=\"white-space:pre\">New Change       </th>\n**       <th>Output Change\n**   <tr><td>INSERT <td>INSERT <td>\n**       The new change is ignored. This case does not occur if the new\n**       changeset was recorded immediately after the changesets already\n**       added to the changegroup.\n**   <tr><td>INSERT <td>UPDATE <td>\n**       The INSERT change remains in the changegroup. The values in the \n**       INSERT change are modified as if the row was inserted by the\n**       existing change and then updated according to the new change.\n**   <tr><td>INSERT <td>DELETE <td>\n**       The existing INSERT is removed from the changegroup. The DELETE is\n**       not added.\n**   <tr><td>UPDATE <td>INSERT <td>\n**       The new change is ignored. This case does not occur if the new\n**       changeset was recorded immediately after the changesets already\n**       added to the changegroup.\n**   <tr><td>UPDATE <td>UPDATE <td>\n**       The existing UPDATE remains within the changegroup. It is amended \n**       so that the accompanying values are as if the row was updated once \n**       by the existing change and then again by the new change.\n**   <tr><td>UPDATE <td>DELETE <td>\n**       The existing UPDATE is replaced by the new DELETE within the\n**       changegroup.\n**   <tr><td>DELETE <td>INSERT <td>\n**       If one or more of the column values in the row inserted by the\n**       new change differ from those in the row deleted by the existing \n**       change, the existing DELETE is replaced by an UPDATE within the\n**       changegroup. Otherwise, if the inserted row is exactly the same \n**       as the deleted row, the existing DELETE is simply discarded.\n**   <tr><td>DELETE <td>UPDATE <td>\n**       The new change is ignored. This case does not occur if the new\n**       changeset was recorded immediately after the changesets already\n**       added to the changegroup.\n**   <tr><td>DELETE <td>DELETE <td>\n**       The new change is ignored. This case does not occur if the new\n**       changeset was recorded immediately after the changesets already\n**       added to the changegroup.\n** </table>\n**\n** If the new changeset contains changes to a table that is already present\n** in the changegroup, then the number of columns and the position of the\n** primary key columns for the table must be consistent. If this is not the\n** case, this function fails with SQLITE_SCHEMA. If the input changeset\n** appears to be corrupt and the corruption is detected, SQLITE_CORRUPT is\n** returned. Or, if an out-of-memory condition occurs during processing, this\n** function returns SQLITE_NOMEM. In all cases, if an error occurs the\n** final contents of the changegroup is undefined.\n**\n** If no error occurs, SQLITE_OK is returned.\n*/\nint sqlite3changegroup_add(sqlite3_changegroup*, int nData, void *pData);\n\n/*\n** CAPI3REF: Obtain A Composite Changeset From A Changegroup\n** METHOD: sqlite3_changegroup\n**\n** Obtain a buffer containing a changeset (or patchset) representing the\n** current contents of the changegroup. If the inputs to the changegroup\n** were themselves changesets, the output is a changeset. Or, if the\n** inputs were patchsets, the output is also a patchset.\n**\n** As with the output of the sqlite3session_changeset() and\n** sqlite3session_patchset() functions, all changes related to a single\n** table are grouped together in the output of this function. Tables appear\n** in the same order as for the very first changeset added to the changegroup.\n** If the second or subsequent changesets added to the changegroup contain\n** changes for tables that do not appear in the first changeset, they are\n** appended onto the end of the output changeset, again in the order in\n** which they are first encountered.\n**\n** If an error occurs, an SQLite error code is returned and the output\n** variables (*pnData) and (*ppData) are set to 0. Otherwise, SQLITE_OK\n** is returned and the output variables are set to the size of and a \n** pointer to the output buffer, respectively. In this case it is the\n** responsibility of the caller to eventually free the buffer using a\n** call to sqlite3_free().\n*/\nint sqlite3changegroup_output(\n  sqlite3_changegroup*,\n  int *pnData,                    /* OUT: Size of output buffer in bytes */\n  void **ppData                   /* OUT: Pointer to output buffer */\n);\n\n/*\n** CAPI3REF: Delete A Changegroup Object\n** DESTRUCTOR: sqlite3_changegroup\n*/\nvoid sqlite3changegroup_delete(sqlite3_changegroup*);\n\n/*\n** CAPI3REF: Apply A Changeset To A Database\n**\n** Apply a changeset or patchset to a database. These functions attempt to\n** update the \"main\" database attached to handle db with the changes found in\n** the changeset passed via the second and third arguments. \n**\n** The fourth argument (xFilter) passed to these functions is the \"filter\n** callback\". If it is not NULL, then for each table affected by at least one\n** change in the changeset, the filter callback is invoked with\n** the table name as the second argument, and a copy of the context pointer\n** passed as the sixth argument as the first. If the \"filter callback\"\n** returns zero, then no attempt is made to apply any changes to the table.\n** Otherwise, if the return value is non-zero or the xFilter argument to\n** is NULL, all changes related to the table are attempted.\n**\n** For each table that is not excluded by the filter callback, this function \n** tests that the target database contains a compatible table. A table is \n** considered compatible if all of the following are true:\n**\n** <ul>\n**   <li> The table has the same name as the name recorded in the \n**        changeset, and\n**   <li> The table has at least as many columns as recorded in the \n**        changeset, and\n**   <li> The table has primary key columns in the same position as \n**        recorded in the changeset.\n** </ul>\n**\n** If there is no compatible table, it is not an error, but none of the\n** changes associated with the table are applied. A warning message is issued\n** via the sqlite3_log() mechanism with the error code SQLITE_SCHEMA. At most\n** one such warning is issued for each table in the changeset.\n**\n** For each change for which there is a compatible table, an attempt is made \n** to modify the table contents according to the UPDATE, INSERT or DELETE \n** change. If a change cannot be applied cleanly, the conflict handler \n** function passed as the fifth argument to sqlite3changeset_apply() may be \n** invoked. A description of exactly when the conflict handler is invoked for \n** each type of change is below.\n**\n** Unlike the xFilter argument, xConflict may not be passed NULL. The results\n** of passing anything other than a valid function pointer as the xConflict\n** argument are undefined.\n**\n** Each time the conflict handler function is invoked, it must return one\n** of [SQLITE_CHANGESET_OMIT], [SQLITE_CHANGESET_ABORT] or \n** [SQLITE_CHANGESET_REPLACE]. SQLITE_CHANGESET_REPLACE may only be returned\n** if the second argument passed to the conflict handler is either\n** SQLITE_CHANGESET_DATA or SQLITE_CHANGESET_CONFLICT. If the conflict-handler\n** returns an illegal value, any changes already made are rolled back and\n** the call to sqlite3changeset_apply() returns SQLITE_MISUSE. Different \n** actions are taken by sqlite3changeset_apply() depending on the value\n** returned by each invocation of the conflict-handler function. Refer to\n** the documentation for the three \n** [SQLITE_CHANGESET_OMIT|available return values] for details.\n**\n** <dl>\n** <dt>DELETE Changes<dd>\n**   For each DELETE change, the function checks if the target database \n**   contains a row with the same primary key value (or values) as the \n**   original row values stored in the changeset. If it does, and the values \n**   stored in all non-primary key columns also match the values stored in \n**   the changeset the row is deleted from the target database.\n**\n**   If a row with matching primary key values is found, but one or more of\n**   the non-primary key fields contains a value different from the original\n**   row value stored in the changeset, the conflict-handler function is\n**   invoked with [SQLITE_CHANGESET_DATA] as the second argument. If the\n**   database table has more columns than are recorded in the changeset,\n**   only the values of those non-primary key fields are compared against\n**   the current database contents - any trailing database table columns\n**   are ignored.\n**\n**   If no row with matching primary key values is found in the database,\n**   the conflict-handler function is invoked with [SQLITE_CHANGESET_NOTFOUND]\n**   passed as the second argument.\n**\n**   If the DELETE operation is attempted, but SQLite returns SQLITE_CONSTRAINT\n**   (which can only happen if a foreign key constraint is violated), the\n**   conflict-handler function is invoked with [SQLITE_CHANGESET_CONSTRAINT]\n**   passed as the second argument. This includes the case where the DELETE\n**   operation is attempted because an earlier call to the conflict handler\n**   function returned [SQLITE_CHANGESET_REPLACE].\n**\n** <dt>INSERT Changes<dd>\n**   For each INSERT change, an attempt is made to insert the new row into\n**   the database. If the changeset row contains fewer fields than the\n**   database table, the trailing fields are populated with their default\n**   values.\n**\n**   If the attempt to insert the row fails because the database already \n**   contains a row with the same primary key values, the conflict handler\n**   function is invoked with the second argument set to \n**   [SQLITE_CHANGESET_CONFLICT].\n**\n**   If the attempt to insert the row fails because of some other constraint\n**   violation (e.g. NOT NULL or UNIQUE), the conflict handler function is \n**   invoked with the second argument set to [SQLITE_CHANGESET_CONSTRAINT].\n**   This includes the case where the INSERT operation is re-attempted because \n**   an earlier call to the conflict handler function returned \n**   [SQLITE_CHANGESET_REPLACE].\n**\n** <dt>UPDATE Changes<dd>\n**   For each UPDATE change, the function checks if the target database \n**   contains a row with the same primary key value (or values) as the \n**   original row values stored in the changeset. If it does, and the values \n**   stored in all modified non-primary key columns also match the values\n**   stored in the changeset the row is updated within the target database.\n**\n**   If a row with matching primary key values is found, but one or more of\n**   the modified non-primary key fields contains a value different from an\n**   original row value stored in the changeset, the conflict-handler function\n**   is invoked with [SQLITE_CHANGESET_DATA] as the second argument. Since\n**   UPDATE changes only contain values for non-primary key fields that are\n**   to be modified, only those fields need to match the original values to\n**   avoid the SQLITE_CHANGESET_DATA conflict-handler callback.\n**\n**   If no row with matching primary key values is found in the database,\n**   the conflict-handler function is invoked with [SQLITE_CHANGESET_NOTFOUND]\n**   passed as the second argument.\n**\n**   If the UPDATE operation is attempted, but SQLite returns \n**   SQLITE_CONSTRAINT, the conflict-handler function is invoked with \n**   [SQLITE_CHANGESET_CONSTRAINT] passed as the second argument.\n**   This includes the case where the UPDATE operation is attempted after \n**   an earlier call to the conflict handler function returned\n**   [SQLITE_CHANGESET_REPLACE].  \n** </dl>\n**\n** It is safe to execute SQL statements, including those that write to the\n** table that the callback related to, from within the xConflict callback.\n** This can be used to further customize the applications conflict\n** resolution strategy.\n**\n** All changes made by these functions are enclosed in a savepoint transaction.\n** If any other error (aside from a constraint failure when attempting to\n** write to the target database) occurs, then the savepoint transaction is\n** rolled back, restoring the target database to its original state, and an \n** SQLite error code returned.\n**\n** If the output parameters (ppRebase) and (pnRebase) are non-NULL and\n** the input is a changeset (not a patchset), then sqlite3changeset_apply_v2()\n** may set (*ppRebase) to point to a \"rebase\" that may be used with the \n** sqlite3_rebaser APIs buffer before returning. In this case (*pnRebase)\n** is set to the size of the buffer in bytes. It is the responsibility of the\n** caller to eventually free any such buffer using sqlite3_free(). The buffer\n** is only allocated and populated if one or more conflicts were encountered\n** while applying the patchset. See comments surrounding the sqlite3_rebaser\n** APIs for further details.\n**\n** The behavior of sqlite3changeset_apply_v2() and its streaming equivalent\n** may be modified by passing a combination of\n** [SQLITE_CHANGESETAPPLY_NOSAVEPOINT | supported flags] as the 9th parameter.\n**\n** Note that the sqlite3changeset_apply_v2() API is still <b>experimental</b>\n** and therefore subject to change.\n*/\nint sqlite3changeset_apply(\n  sqlite3 *db,                    /* Apply change to \"main\" db of this handle */\n  int nChangeset,                 /* Size of changeset in bytes */\n  void *pChangeset,               /* Changeset blob */\n  int(*xFilter)(\n    void *pCtx,                   /* Copy of sixth arg to _apply() */\n    const char *zTab              /* Table name */\n  ),\n  int(*xConflict)(\n    void *pCtx,                   /* Copy of sixth arg to _apply() */\n    int eConflict,                /* DATA, MISSING, CONFLICT, CONSTRAINT */\n    sqlite3_changeset_iter *p     /* Handle describing change and conflict */\n  ),\n  void *pCtx                      /* First argument passed to xConflict */\n);\nint sqlite3changeset_apply_v2(\n  sqlite3 *db,                    /* Apply change to \"main\" db of this handle */\n  int nChangeset,                 /* Size of changeset in bytes */\n  void *pChangeset,               /* Changeset blob */\n  int(*xFilter)(\n    void *pCtx,                   /* Copy of sixth arg to _apply() */\n    const char *zTab              /* Table name */\n  ),\n  int(*xConflict)(\n    void *pCtx,                   /* Copy of sixth arg to _apply() */\n    int eConflict,                /* DATA, MISSING, CONFLICT, CONSTRAINT */\n    sqlite3_changeset_iter *p     /* Handle describing change and conflict */\n  ),\n  void *pCtx,                     /* First argument passed to xConflict */\n  void **ppRebase, int *pnRebase, /* OUT: Rebase data */\n  int flags                       /* SESSION_CHANGESETAPPLY_* flags */\n);\n\n/*\n** CAPI3REF: Flags for sqlite3changeset_apply_v2\n**\n** The following flags may passed via the 9th parameter to\n** [sqlite3changeset_apply_v2] and [sqlite3changeset_apply_v2_strm]:\n**\n** <dl>\n** <dt>SQLITE_CHANGESETAPPLY_NOSAVEPOINT <dd>\n**   Usually, the sessions module encloses all operations performed by\n**   a single call to apply_v2() or apply_v2_strm() in a [SAVEPOINT]. The\n**   SAVEPOINT is committed if the changeset or patchset is successfully\n**   applied, or rolled back if an error occurs. Specifying this flag\n**   causes the sessions module to omit this savepoint. In this case, if the\n**   caller has an open transaction or savepoint when apply_v2() is called, \n**   it may revert the partially applied changeset by rolling it back.\n**\n** <dt>SQLITE_CHANGESETAPPLY_INVERT <dd>\n**   Invert the changeset before applying it. This is equivalent to inverting\n**   a changeset using sqlite3changeset_invert() before applying it. It is\n**   an error to specify this flag with a patchset.\n*/\n#define SQLITE_CHANGESETAPPLY_NOSAVEPOINT   0x0001\n#define SQLITE_CHANGESETAPPLY_INVERT        0x0002\n\n/* \n** CAPI3REF: Constants Passed To The Conflict Handler\n**\n** Values that may be passed as the second argument to a conflict-handler.\n**\n** <dl>\n** <dt>SQLITE_CHANGESET_DATA<dd>\n**   The conflict handler is invoked with CHANGESET_DATA as the second argument\n**   when processing a DELETE or UPDATE change if a row with the required\n**   PRIMARY KEY fields is present in the database, but one or more other \n**   (non primary-key) fields modified by the update do not contain the \n**   expected \"before\" values.\n** \n**   The conflicting row, in this case, is the database row with the matching\n**   primary key.\n** \n** <dt>SQLITE_CHANGESET_NOTFOUND<dd>\n**   The conflict handler is invoked with CHANGESET_NOTFOUND as the second\n**   argument when processing a DELETE or UPDATE change if a row with the\n**   required PRIMARY KEY fields is not present in the database.\n** \n**   There is no conflicting row in this case. The results of invoking the\n**   sqlite3changeset_conflict() API are undefined.\n** \n** <dt>SQLITE_CHANGESET_CONFLICT<dd>\n**   CHANGESET_CONFLICT is passed as the second argument to the conflict\n**   handler while processing an INSERT change if the operation would result \n**   in duplicate primary key values.\n** \n**   The conflicting row in this case is the database row with the matching\n**   primary key.\n**\n** <dt>SQLITE_CHANGESET_FOREIGN_KEY<dd>\n**   If foreign key handling is enabled, and applying a changeset leaves the\n**   database in a state containing foreign key violations, the conflict \n**   handler is invoked with CHANGESET_FOREIGN_KEY as the second argument\n**   exactly once before the changeset is committed. If the conflict handler\n**   returns CHANGESET_OMIT, the changes, including those that caused the\n**   foreign key constraint violation, are committed. Or, if it returns\n**   CHANGESET_ABORT, the changeset is rolled back.\n**\n**   No current or conflicting row information is provided. The only function\n**   it is possible to call on the supplied sqlite3_changeset_iter handle\n**   is sqlite3changeset_fk_conflicts().\n** \n** <dt>SQLITE_CHANGESET_CONSTRAINT<dd>\n**   If any other constraint violation occurs while applying a change (i.e. \n**   a UNIQUE, CHECK or NOT NULL constraint), the conflict handler is \n**   invoked with CHANGESET_CONSTRAINT as the second argument.\n** \n**   There is no conflicting row in this case. The results of invoking the\n**   sqlite3changeset_conflict() API are undefined.\n**\n** </dl>\n*/\n#define SQLITE_CHANGESET_DATA        1\n#define SQLITE_CHANGESET_NOTFOUND    2\n#define SQLITE_CHANGESET_CONFLICT    3\n#define SQLITE_CHANGESET_CONSTRAINT  4\n#define SQLITE_CHANGESET_FOREIGN_KEY 5\n\n/* \n** CAPI3REF: Constants Returned By The Conflict Handler\n**\n** A conflict handler callback must return one of the following three values.\n**\n** <dl>\n** <dt>SQLITE_CHANGESET_OMIT<dd>\n**   If a conflict handler returns this value no special action is taken. The\n**   change that caused the conflict is not applied. The session module \n**   continues to the next change in the changeset.\n**\n** <dt>SQLITE_CHANGESET_REPLACE<dd>\n**   This value may only be returned if the second argument to the conflict\n**   handler was SQLITE_CHANGESET_DATA or SQLITE_CHANGESET_CONFLICT. If this\n**   is not the case, any changes applied so far are rolled back and the \n**   call to sqlite3changeset_apply() returns SQLITE_MISUSE.\n**\n**   If CHANGESET_REPLACE is returned by an SQLITE_CHANGESET_DATA conflict\n**   handler, then the conflicting row is either updated or deleted, depending\n**   on the type of change.\n**\n**   If CHANGESET_REPLACE is returned by an SQLITE_CHANGESET_CONFLICT conflict\n**   handler, then the conflicting row is removed from the database and a\n**   second attempt to apply the change is made. If this second attempt fails,\n**   the original row is restored to the database before continuing.\n**\n** <dt>SQLITE_CHANGESET_ABORT<dd>\n**   If this value is returned, any changes applied so far are rolled back \n**   and the call to sqlite3changeset_apply() returns SQLITE_ABORT.\n** </dl>\n*/\n#define SQLITE_CHANGESET_OMIT       0\n#define SQLITE_CHANGESET_REPLACE    1\n#define SQLITE_CHANGESET_ABORT      2\n\n/* \n** CAPI3REF: Rebasing changesets\n** EXPERIMENTAL\n**\n** Suppose there is a site hosting a database in state S0. And that\n** modifications are made that move that database to state S1 and a\n** changeset recorded (the \"local\" changeset). Then, a changeset based\n** on S0 is received from another site (the \"remote\" changeset) and \n** applied to the database. The database is then in state \n** (S1+\"remote\"), where the exact state depends on any conflict\n** resolution decisions (OMIT or REPLACE) made while applying \"remote\".\n** Rebasing a changeset is to update it to take those conflict \n** resolution decisions into account, so that the same conflicts\n** do not have to be resolved elsewhere in the network. \n**\n** For example, if both the local and remote changesets contain an\n** INSERT of the same key on \"CREATE TABLE t1(a PRIMARY KEY, b)\":\n**\n**   local:  INSERT INTO t1 VALUES(1, 'v1');\n**   remote: INSERT INTO t1 VALUES(1, 'v2');\n**\n** and the conflict resolution is REPLACE, then the INSERT change is\n** removed from the local changeset (it was overridden). Or, if the\n** conflict resolution was \"OMIT\", then the local changeset is modified\n** to instead contain:\n**\n**           UPDATE t1 SET b = 'v2' WHERE a=1;\n**\n** Changes within the local changeset are rebased as follows:\n**\n** <dl>\n** <dt>Local INSERT<dd>\n**   This may only conflict with a remote INSERT. If the conflict \n**   resolution was OMIT, then add an UPDATE change to the rebased\n**   changeset. Or, if the conflict resolution was REPLACE, add\n**   nothing to the rebased changeset.\n**\n** <dt>Local DELETE<dd>\n**   This may conflict with a remote UPDATE or DELETE. In both cases the\n**   only possible resolution is OMIT. If the remote operation was a\n**   DELETE, then add no change to the rebased changeset. If the remote\n**   operation was an UPDATE, then the old.* fields of change are updated\n**   to reflect the new.* values in the UPDATE.\n**\n** <dt>Local UPDATE<dd>\n**   This may conflict with a remote UPDATE or DELETE. If it conflicts\n**   with a DELETE, and the conflict resolution was OMIT, then the update\n**   is changed into an INSERT. Any undefined values in the new.* record\n**   from the update change are filled in using the old.* values from\n**   the conflicting DELETE. Or, if the conflict resolution was REPLACE,\n**   the UPDATE change is simply omitted from the rebased changeset.\n**\n**   If conflict is with a remote UPDATE and the resolution is OMIT, then\n**   the old.* values are rebased using the new.* values in the remote\n**   change. Or, if the resolution is REPLACE, then the change is copied\n**   into the rebased changeset with updates to columns also updated by\n**   the conflicting remote UPDATE removed. If this means no columns would \n**   be updated, the change is omitted.\n** </dl>\n**\n** A local change may be rebased against multiple remote changes \n** simultaneously. If a single key is modified by multiple remote \n** changesets, they are combined as follows before the local changeset\n** is rebased:\n**\n** <ul>\n**    <li> If there has been one or more REPLACE resolutions on a\n**         key, it is rebased according to a REPLACE.\n**\n**    <li> If there have been no REPLACE resolutions on a key, then\n**         the local changeset is rebased according to the most recent\n**         of the OMIT resolutions.\n** </ul>\n**\n** Note that conflict resolutions from multiple remote changesets are \n** combined on a per-field basis, not per-row. This means that in the \n** case of multiple remote UPDATE operations, some fields of a single \n** local change may be rebased for REPLACE while others are rebased for \n** OMIT.\n**\n** In order to rebase a local changeset, the remote changeset must first\n** be applied to the local database using sqlite3changeset_apply_v2() and\n** the buffer of rebase information captured. Then:\n**\n** <ol>\n**   <li> An sqlite3_rebaser object is created by calling \n**        sqlite3rebaser_create().\n**   <li> The new object is configured with the rebase buffer obtained from\n**        sqlite3changeset_apply_v2() by calling sqlite3rebaser_configure().\n**        If the local changeset is to be rebased against multiple remote\n**        changesets, then sqlite3rebaser_configure() should be called\n**        multiple times, in the same order that the multiple\n**        sqlite3changeset_apply_v2() calls were made.\n**   <li> Each local changeset is rebased by calling sqlite3rebaser_rebase().\n**   <li> The sqlite3_rebaser object is deleted by calling\n**        sqlite3rebaser_delete().\n** </ol>\n*/\ntypedef struct sqlite3_rebaser sqlite3_rebaser;\n\n/*\n** CAPI3REF: Create a changeset rebaser object.\n** EXPERIMENTAL\n**\n** Allocate a new changeset rebaser object. If successful, set (*ppNew) to\n** point to the new object and return SQLITE_OK. Otherwise, if an error\n** occurs, return an SQLite error code (e.g. SQLITE_NOMEM) and set (*ppNew) \n** to NULL. \n*/\nint sqlite3rebaser_create(sqlite3_rebaser **ppNew);\n\n/*\n** CAPI3REF: Configure a changeset rebaser object.\n** EXPERIMENTAL\n**\n** Configure the changeset rebaser object to rebase changesets according\n** to the conflict resolutions described by buffer pRebase (size nRebase\n** bytes), which must have been obtained from a previous call to\n** sqlite3changeset_apply_v2().\n*/\nint sqlite3rebaser_configure(\n  sqlite3_rebaser*, \n  int nRebase, const void *pRebase\n); \n\n/*\n** CAPI3REF: Rebase a changeset\n** EXPERIMENTAL\n**\n** Argument pIn must point to a buffer containing a changeset nIn bytes\n** in size. This function allocates and populates a buffer with a copy\n** of the changeset rebased rebased according to the configuration of the\n** rebaser object passed as the first argument. If successful, (*ppOut)\n** is set to point to the new buffer containing the rebased changset and \n** (*pnOut) to its size in bytes and SQLITE_OK returned. It is the\n** responsibility of the caller to eventually free the new buffer using\n** sqlite3_free(). Otherwise, if an error occurs, (*ppOut) and (*pnOut)\n** are set to zero and an SQLite error code returned.\n*/\nint sqlite3rebaser_rebase(\n  sqlite3_rebaser*,\n  int nIn, const void *pIn, \n  int *pnOut, void **ppOut \n);\n\n/*\n** CAPI3REF: Delete a changeset rebaser object.\n** EXPERIMENTAL\n**\n** Delete the changeset rebaser object and all associated resources. There\n** should be one call to this function for each successful invocation\n** of sqlite3rebaser_create().\n*/\nvoid sqlite3rebaser_delete(sqlite3_rebaser *p); \n\n/*\n** CAPI3REF: Streaming Versions of API functions.\n**\n** The six streaming API xxx_strm() functions serve similar purposes to the \n** corresponding non-streaming API functions:\n**\n** <table border=1 style=\"margin-left:8ex;margin-right:8ex\">\n**   <tr><th>Streaming function<th>Non-streaming equivalent</th>\n**   <tr><td>sqlite3changeset_apply_strm<td>[sqlite3changeset_apply] \n**   <tr><td>sqlite3changeset_apply_strm_v2<td>[sqlite3changeset_apply_v2] \n**   <tr><td>sqlite3changeset_concat_strm<td>[sqlite3changeset_concat] \n**   <tr><td>sqlite3changeset_invert_strm<td>[sqlite3changeset_invert] \n**   <tr><td>sqlite3changeset_start_strm<td>[sqlite3changeset_start] \n**   <tr><td>sqlite3session_changeset_strm<td>[sqlite3session_changeset] \n**   <tr><td>sqlite3session_patchset_strm<td>[sqlite3session_patchset] \n** </table>\n**\n** Non-streaming functions that accept changesets (or patchsets) as input\n** require that the entire changeset be stored in a single buffer in memory. \n** Similarly, those that return a changeset or patchset do so by returning \n** a pointer to a single large buffer allocated using sqlite3_malloc(). \n** Normally this is convenient. However, if an application running in a \n** low-memory environment is required to handle very large changesets, the\n** large contiguous memory allocations required can become onerous.\n**\n** In order to avoid this problem, instead of a single large buffer, input\n** is passed to a streaming API functions by way of a callback function that\n** the sessions module invokes to incrementally request input data as it is\n** required. In all cases, a pair of API function parameters such as\n**\n**  <pre>\n**  &nbsp;     int nChangeset,\n**  &nbsp;     void *pChangeset,\n**  </pre>\n**\n** Is replaced by:\n**\n**  <pre>\n**  &nbsp;     int (*xInput)(void *pIn, void *pData, int *pnData),\n**  &nbsp;     void *pIn,\n**  </pre>\n**\n** Each time the xInput callback is invoked by the sessions module, the first\n** argument passed is a copy of the supplied pIn context pointer. The second \n** argument, pData, points to a buffer (*pnData) bytes in size. Assuming no \n** error occurs the xInput method should copy up to (*pnData) bytes of data \n** into the buffer and set (*pnData) to the actual number of bytes copied \n** before returning SQLITE_OK. If the input is completely exhausted, (*pnData) \n** should be set to zero to indicate this. Or, if an error occurs, an SQLite \n** error code should be returned. In all cases, if an xInput callback returns\n** an error, all processing is abandoned and the streaming API function\n** returns a copy of the error code to the caller.\n**\n** In the case of sqlite3changeset_start_strm(), the xInput callback may be\n** invoked by the sessions module at any point during the lifetime of the\n** iterator. If such an xInput callback returns an error, the iterator enters\n** an error state, whereby all subsequent calls to iterator functions \n** immediately fail with the same error code as returned by xInput.\n**\n** Similarly, streaming API functions that return changesets (or patchsets)\n** return them in chunks by way of a callback function instead of via a\n** pointer to a single large buffer. In this case, a pair of parameters such\n** as:\n**\n**  <pre>\n**  &nbsp;     int *pnChangeset,\n**  &nbsp;     void **ppChangeset,\n**  </pre>\n**\n** Is replaced by:\n**\n**  <pre>\n**  &nbsp;     int (*xOutput)(void *pOut, const void *pData, int nData),\n**  &nbsp;     void *pOut\n**  </pre>\n**\n** The xOutput callback is invoked zero or more times to return data to\n** the application. The first parameter passed to each call is a copy of the\n** pOut pointer supplied by the application. The second parameter, pData,\n** points to a buffer nData bytes in size containing the chunk of output\n** data being returned. If the xOutput callback successfully processes the\n** supplied data, it should return SQLITE_OK to indicate success. Otherwise,\n** it should return some other SQLite error code. In this case processing\n** is immediately abandoned and the streaming API function returns a copy\n** of the xOutput error code to the application.\n**\n** The sessions module never invokes an xOutput callback with the third \n** parameter set to a value less than or equal to zero. Other than this,\n** no guarantees are made as to the size of the chunks of data returned.\n*/\nint sqlite3changeset_apply_strm(\n  sqlite3 *db,                    /* Apply change to \"main\" db of this handle */\n  int (*xInput)(void *pIn, void *pData, int *pnData), /* Input function */\n  void *pIn,                                          /* First arg for xInput */\n  int(*xFilter)(\n    void *pCtx,                   /* Copy of sixth arg to _apply() */\n    const char *zTab              /* Table name */\n  ),\n  int(*xConflict)(\n    void *pCtx,                   /* Copy of sixth arg to _apply() */\n    int eConflict,                /* DATA, MISSING, CONFLICT, CONSTRAINT */\n    sqlite3_changeset_iter *p     /* Handle describing change and conflict */\n  ),\n  void *pCtx                      /* First argument passed to xConflict */\n);\nint sqlite3changeset_apply_v2_strm(\n  sqlite3 *db,                    /* Apply change to \"main\" db of this handle */\n  int (*xInput)(void *pIn, void *pData, int *pnData), /* Input function */\n  void *pIn,                                          /* First arg for xInput */\n  int(*xFilter)(\n    void *pCtx,                   /* Copy of sixth arg to _apply() */\n    const char *zTab              /* Table name */\n  ),\n  int(*xConflict)(\n    void *pCtx,                   /* Copy of sixth arg to _apply() */\n    int eConflict,                /* DATA, MISSING, CONFLICT, CONSTRAINT */\n    sqlite3_changeset_iter *p     /* Handle describing change and conflict */\n  ),\n  void *pCtx,                     /* First argument passed to xConflict */\n  void **ppRebase, int *pnRebase,\n  int flags\n);\nint sqlite3changeset_concat_strm(\n  int (*xInputA)(void *pIn, void *pData, int *pnData),\n  void *pInA,\n  int (*xInputB)(void *pIn, void *pData, int *pnData),\n  void *pInB,\n  int (*xOutput)(void *pOut, const void *pData, int nData),\n  void *pOut\n);\nint sqlite3changeset_invert_strm(\n  int (*xInput)(void *pIn, void *pData, int *pnData),\n  void *pIn,\n  int (*xOutput)(void *pOut, const void *pData, int nData),\n  void *pOut\n);\nint sqlite3changeset_start_strm(\n  sqlite3_changeset_iter **pp,\n  int (*xInput)(void *pIn, void *pData, int *pnData),\n  void *pIn\n);\nint sqlite3changeset_start_v2_strm(\n  sqlite3_changeset_iter **pp,\n  int (*xInput)(void *pIn, void *pData, int *pnData),\n  void *pIn,\n  int flags\n);\nint sqlite3session_changeset_strm(\n  sqlite3_session *pSession,\n  int (*xOutput)(void *pOut, const void *pData, int nData),\n  void *pOut\n);\nint sqlite3session_patchset_strm(\n  sqlite3_session *pSession,\n  int (*xOutput)(void *pOut, const void *pData, int nData),\n  void *pOut\n);\nint sqlite3changegroup_add_strm(sqlite3_changegroup*, \n    int (*xInput)(void *pIn, void *pData, int *pnData),\n    void *pIn\n);\nint sqlite3changegroup_output_strm(sqlite3_changegroup*,\n    int (*xOutput)(void *pOut, const void *pData, int nData), \n    void *pOut\n);\nint sqlite3rebaser_rebase_strm(\n  sqlite3_rebaser *pRebaser,\n  int (*xInput)(void *pIn, void *pData, int *pnData),\n  void *pIn,\n  int (*xOutput)(void *pOut, const void *pData, int nData),\n  void *pOut\n);\n\n/*\n** CAPI3REF: Configure global parameters\n**\n** The sqlite3session_config() interface is used to make global configuration\n** changes to the sessions module in order to tune it to the specific needs \n** of the application.\n**\n** The sqlite3session_config() interface is not threadsafe. If it is invoked\n** while any other thread is inside any other sessions method then the\n** results are undefined. Furthermore, if it is invoked after any sessions\n** related objects have been created, the results are also undefined. \n**\n** The first argument to the sqlite3session_config() function must be one\n** of the SQLITE_SESSION_CONFIG_XXX constants defined below. The \n** interpretation of the (void*) value passed as the second parameter and\n** the effect of calling this function depends on the value of the first\n** parameter.\n**\n** <dl>\n** <dt>SQLITE_SESSION_CONFIG_STRMSIZE<dd>\n**    By default, the sessions module streaming interfaces attempt to input\n**    and output data in approximately 1 KiB chunks. This operand may be used\n**    to set and query the value of this configuration setting. The pointer\n**    passed as the second argument must point to a value of type (int).\n**    If this value is greater than 0, it is used as the new streaming data\n**    chunk size for both input and output. Before returning, the (int) value\n**    pointed to by pArg is set to the final value of the streaming interface\n**    chunk size.\n** </dl>\n**\n** This function returns SQLITE_OK if successful, or an SQLite error code\n** otherwise.\n*/\nint sqlite3session_config(int op, void *pArg);\n\n/*\n** CAPI3REF: Values for sqlite3session_config().\n*/\n#define SQLITE_SESSION_CONFIG_STRMSIZE 1\n\n/*\n** Make sure we can call this stuff from C++.\n*/\n#ifdef __cplusplus\n}\n#endif\n\n#endif  /* !defined(__SQLITESESSION_H_) && defined(SQLITE_ENABLE_SESSION) */\n"
  },
  {
    "path": "deprecated/android/wcdb/.gitignore",
    "content": "/build\n"
  },
  {
    "path": "deprecated/android/wcdb/AndroidManifest.xml",
    "content": "<manifest xmlns:android=\"http://schemas.android.com/apk/res/android\"\n          package=\"com.tencent.wcdb\">\n</manifest>\n"
  },
  {
    "path": "deprecated/android/wcdb/build.gradle",
    "content": "apply plugin: 'com.android.library'\napply from: rootProject.file('gradle/WeChatPublish.gradle')\napply from: rootProject.file('gradle/WeChatArmeabiCompat.gradle')\napply from: rootProject.file('gradle/WeChatNativeDepend.gradle')\n\nartifactId = 'wcdb-android'\n\n//int ndkVersion() {\n//    if (android.ndkDirectory != null) {\n//        System.err.println(android.ndkDirectory)\n//        def propFile = new File(android.ndkDirectory, 'source.properties')\n//        if (propFile.exists()) {\n//            def props = new Properties()\n//            props.load(propFile.newInputStream())\n//            def numericVersion = (props['Pkg.Revision'] =~ /^[0-9]+/)[0]\n//            return numericVersion as int\n//        }\n//    }\n//    return 0\n//}\n\nandroid {\n//    def ndkVer = ndkVersion()\n//    def useGcc = rootProject.hasProperty('USE_GCC') &&\n//            rootProject.USE_GCC == '1' &&\n//            ndkVer < 16     // In NDK >= r16, universal header breaks mmap with _FILE_OFFSET_BITS=64\n\n    compileSdkVersion 32\n\n    defaultConfig {\n        minSdkVersion 14\n        targetSdkVersion 32\n        versionCode 1\n        versionName version\n\n        externalNativeBuild {\n            ndkBuild {\n                arguments \"-j${Runtime.getRuntime().availableProcessors()}\".toString()\n                abiFilters 'armeabi-v7a', 'arm64-v8a', 'x86', 'x86_64'\n//                if (useGcc) {\n//                    abiFilters 'armeabi'\n//                    arguments 'USE_GCC=1'   // clang generates wrong code when targeting armeabi\n//                }\n            }\n\n            // Native dependencies\n            exportHeaders {\n                from(rootProject.file('sqlcipher')) {\n                    include '*.h'\n                }\n            }\n        }\n    }\n\n    buildTypes {\n        release {\n            minifyEnabled false\n            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'\n            consumerProguardFiles 'proguard-rules.pro'\n        }\n\n        debug {\n            consumerProguardFiles 'proguard-rules.pro'\n            jniDebuggable true\n        }\n    }\n\n    sourceSets {\n        main {\n            manifest.srcFile 'AndroidManifest.xml'\n            java.srcDirs = ['src']\n            aidl.srcDirs = ['src']\n            jni.srcDirs = ['../jni']\n            jniLibs.srcDirs = []\n        }\n    }\n\n    externalNativeBuild {\n        ndkBuild {\n            path rootProject.file('Android.mk')\n        }\n    }\n\n    lintOptions {\n        disable 'OldTargetApi', 'GradleDependency'\n    }\n}\n\nwechatPublish {\n    publishAllVariants true\n    withJavadoc false\n\n    publishToBintray {\n        repo = 'wcdb'\n        name = 'wcdb-android'\n        desc = ''\n        websiteUrl = 'https://github.com/Tencent/wcdb'\n        issueTrackerUrl = 'https://github.com/Tencent/wcdb/issues'\n        vcsUrl = 'https://github.com/Tencent/wcdb.git'\n        licenses = ['BSD 3-Clause']\n    }\n}\n"
  },
  {
    "path": "deprecated/android/wcdb/proguard-rules.pro",
    "content": "# Keep all native methods, their classes and any classes in their descriptors\n-keepclasseswithmembers,includedescriptorclasses class com.tencent.wcdb.** {\n    native <methods>;\n}\n\n# Keep all exception classes\n-keep class com.tencent.wcdb.**.*Exception\n\n# Keep classes referenced in JNI code\n-keep class com.tencent.wcdb.database.WCDBInitializationProbe { <fields>; }\n-keep,includedescriptorclasses class com.tencent.wcdb.database.SQLiteCustomFunction { *; }\n-keep class com.tencent.wcdb.database.SQLiteDebug$* { *; }\n-keep class com.tencent.wcdb.database.SQLiteCipherSpec { <fields>; }\n-keep interface com.tencent.wcdb.support.Log$* { *; }\n\n# Keep methods used as callbacks from JNI code\n-keep class com.tencent.wcdb.repair.RepairKit { int onProgress(java.lang.String, int, long); }\n-keep class com.tencent.wcdb.database.SQLiteConnection { \n    void notifyCheckpoint(java.lang.String, int);\n    void notifyChange(java.lang.String, java.lang.String, long[], long[], long[]);\n}"
  },
  {
    "path": "deprecated/android/wcdb/src/com/tencent/wcdb/AbstractCursor.java",
    "content": "/*\n * Copyright (C) 2006 The Android Open Source Project\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdb;\n\nimport android.content.ContentResolver;\nimport android.database.CharArrayBuffer;\nimport android.database.ContentObservable;\nimport android.database.ContentObserver;\nimport android.database.DataSetObservable;\nimport android.database.DataSetObserver;\nimport android.net.Uri;\nimport android.os.Bundle;\nimport com.tencent.wcdb.support.Log;\n\nimport java.lang.ref.WeakReference;\nimport java.util.HashMap;\nimport java.util.Map;\n\n/**\n * This is an abstract cursor class that handles a lot of the common code\n * that all cursors need to deal with and is provided for convenience reasons.\n */\npublic abstract class AbstractCursor implements CrossProcessCursor {\n    private static final String TAG = \"Cursor\";\n\n    /**\n     * @deprecated This is never updated by this class and should not be used\n     */\n    @Deprecated\n    protected HashMap<Long, Map<String, Object>> mUpdatedRows;\n\n    protected int mPos;\n\n    /**\n     * This must be set to the index of the row ID column by any\n     * subclass that wishes to support updates.\n     *\n     * @deprecated This field should not be used.\n     */\n    @Deprecated\n    protected int mRowIdColumnIndex;\n\n    /**\n     * If {@link #mRowIdColumnIndex} is not -1 this contains contains the value of\n     * the column at {@link #mRowIdColumnIndex} for the current row this cursor is\n     * pointing at.\n     *\n     * @deprecated This field should not be used.\n     */\n    @Deprecated\n    protected Long mCurrentRowID;\n\n    protected boolean mClosed;\n    protected ContentResolver mContentResolver;\n    private Uri mNotifyUri;\n\n    private final Object mSelfObserverLock = new Object();\n    private ContentObserver mSelfObserver;\n    private boolean mSelfObserverRegistered;\n\n    private final DataSetObservable mDataSetObservable = new DataSetObservable();\n    private final ContentObservable mContentObservable = new ContentObservable();\n\n    private Bundle mExtras = Bundle.EMPTY;\n\n    /* -------------------------------------------------------- */\n    /* These need to be implemented by subclasses */\n    abstract public int getCount();\n\n    abstract public String[] getColumnNames();\n\n    abstract public String getString(int column);\n    abstract public short getShort(int column);\n    abstract public int getInt(int column);\n    abstract public long getLong(int column);\n    abstract public float getFloat(int column);\n    abstract public double getDouble(int column);\n    abstract public boolean isNull(int column);\n\n    public int getType(int column) {\n        // Reflects the assumption that all commonly used field types (meaning everything\n        // but blobs) are convertible to strings so it should be safe to call\n        // getString to retrieve them.\n        return FIELD_TYPE_STRING;\n    }\n\n    // TODO implement getBlob in all cursor types\n    public byte[] getBlob(int column) {\n        throw new UnsupportedOperationException(\"getBlob is not supported\");\n    }\n    /* -------------------------------------------------------- */\n    /* Methods that may optionally be implemented by subclasses */\n\n    /**\n     * If the cursor is backed by a {@link CursorWindow}, returns a pre-filled\n     * window with the contents of the cursor, otherwise null.\n     *\n     * @return The pre-filled window that backs this cursor, or null if none.\n     */\n    public CursorWindow getWindow() {\n        return null;\n    }\n\n    public int getColumnCount() {\n        return getColumnNames().length;\n    }\n\n    public void deactivate() {\n        onDeactivateOrClose();\n    }\n\n    /** @hide */\n    protected void onDeactivateOrClose() {\n        if (mSelfObserver != null) {\n            mContentResolver.unregisterContentObserver(mSelfObserver);\n            mSelfObserverRegistered = false;\n        }\n        mDataSetObservable.notifyInvalidated();\n    }\n\n    public boolean requery() {\n        if (mSelfObserver != null && mSelfObserverRegistered == false) {\n            mContentResolver.registerContentObserver(mNotifyUri, true, mSelfObserver);\n            mSelfObserverRegistered = true;\n        }\n        mDataSetObservable.notifyChanged();\n        return true;\n    }\n\n    public boolean isClosed() {\n        return mClosed;\n    }\n\n    public void close() {\n        mClosed = true;\n        mContentObservable.unregisterAll();\n        onDeactivateOrClose();\n    }\n\n    /**\n     * This function is called every time the cursor is successfully scrolled\n     * to a new position, giving the subclass a chance to update any state it\n     * may have. If it returns false the move function will also do so and the\n     * cursor will scroll to the beforeFirst position.\n     *\n     * @param oldPosition the position that we're moving from\n     * @param newPosition the position that we're moving to\n     * @return true if the move is successful, false otherwise\n     */\n    public boolean onMove(int oldPosition, int newPosition) {\n        return true;\n    }\n\n\n    public void copyStringToBuffer(int columnIndex, CharArrayBuffer buffer) {\n        // Default implementation, uses getString\n        String result = getString(columnIndex);\n        if (result != null) {\n            char[] data = buffer.data;\n            if (data == null || data.length < result.length()) {\n                buffer.data = result.toCharArray();\n            } else {\n                result.getChars(0, result.length(), data, 0);\n            }\n            buffer.sizeCopied = result.length();\n        } else {\n            buffer.sizeCopied = 0;\n        }\n    }\n\n    /* -------------------------------------------------------- */\n    /* Implementation */\n    public AbstractCursor() {\n        mPos = -1;\n        mRowIdColumnIndex = -1;\n        mCurrentRowID = null;\n        mUpdatedRows = new HashMap<Long, Map<String, Object>>();\n    }\n\n    public final int getPosition() {\n        return mPos;\n    }\n\n    public boolean moveToPosition(int position) {\n        // Make sure position isn't past the end of the cursor\n        final int count = getCount();\n        if (position >= count) {\n            mPos = count;\n            return false;\n        }\n\n        // Make sure position isn't before the beginning of the cursor\n        if (position < 0) {\n            mPos = -1;\n            return false;\n        }\n\n        // Check for no-op moves, and skip the rest of the work for them\n        if (position == mPos) {\n            return true;\n        }\n\n        boolean result = onMove(mPos, position);\n        if (result == false) {\n            mPos = -1;\n        } else {\n            mPos = position;\n            if (mRowIdColumnIndex != -1) {\n                mCurrentRowID = Long.valueOf(getLong(mRowIdColumnIndex));\n            }\n        }\n\n        return result;\n    }\n\n    @Override\n    public void fillWindow(int position, CursorWindow window) {\n        DatabaseUtils.cursorFillWindow(this, position, window);\n    }\n\n    public final boolean move(int offset) {\n        return moveToPosition(mPos + offset);\n    }\n\n    public final boolean moveToFirst() {\n        return moveToPosition(0);\n    }\n\n    public final boolean moveToLast() {\n        return moveToPosition(getCount() - 1);\n    }\n\n    public final boolean moveToNext() {\n        return moveToPosition(mPos + 1);\n    }\n\n    public final boolean moveToPrevious() {\n        return moveToPosition(mPos - 1);\n    }\n\n    public final boolean isFirst() {\n        return mPos == 0 && getCount() != 0;\n    }\n\n    public final boolean isLast() {\n        int cnt = getCount();\n        return mPos == (cnt - 1) && cnt != 0;\n    }\n\n    public final boolean isBeforeFirst() {\n        if (getCount() == 0) {\n            return true;\n        }\n        return mPos == -1;\n    }\n\n    public final boolean isAfterLast() {\n        if (getCount() == 0) {\n            return true;\n        }\n        return mPos == getCount();\n    }\n\n    public int getColumnIndex(String columnName) {\n        // Hack according to bug 903852\n        final int periodIndex = columnName.lastIndexOf('.');\n        if (periodIndex != -1) {\n            Exception e = new Exception();\n            Log.e(TAG, \"requesting column name with table name -- \" + columnName, e);\n            columnName = columnName.substring(periodIndex + 1);\n        }\n\n        String columnNames[] = getColumnNames();\n        int length = columnNames.length;\n        for (int i = 0; i < length; i++) {\n            if (columnNames[i].equalsIgnoreCase(columnName)) {\n                return i;\n            }\n        }\n\n        return -1;\n    }\n\n    public int getColumnIndexOrThrow(String columnName) {\n        final int index = getColumnIndex(columnName);\n        if (index < 0) {\n            throw new IllegalArgumentException(\"column '\" + columnName + \"' does not exist\");\n        }\n        return index;\n    }\n\n    public String getColumnName(int columnIndex) {\n        return getColumnNames()[columnIndex];\n    }\n\n    public void registerContentObserver(ContentObserver observer) {\n        mContentObservable.registerObserver(observer);\n    }\n\n    public void unregisterContentObserver(ContentObserver observer) {\n        // cursor will unregister all observers when it close\n        if (!mClosed) {\n            mContentObservable.unregisterObserver(observer);\n        }\n    }\n\n    public void registerDataSetObserver(DataSetObserver observer) {\n        mDataSetObservable.registerObserver(observer);\n    }\n\n    public void unregisterDataSetObserver(DataSetObserver observer) {\n        mDataSetObservable.unregisterObserver(observer);\n    }\n\n    /**\n     * Subclasses must call this method when they finish committing updates to notify all\n     * observers.\n     *\n     * @param selfChange\n     */\n    protected void onChange(boolean selfChange) {\n        synchronized (mSelfObserverLock) {\n            mContentObservable.dispatchChange(selfChange);\n            if (mNotifyUri != null && selfChange) {\n                mContentResolver.notifyChange(mNotifyUri, mSelfObserver);\n            }\n        }\n    }\n\n    /**\n     * Specifies a content URI to watch for changes.\n     *\n     * @param cr The content resolver from the caller's context.\n     * @param notifyUri The URI to watch for changes. This can be a\n     * specific row URI, or a base URI for a whole class of content.\n     */\n    public void setNotificationUri(ContentResolver cr, Uri notifyUri) {\n        synchronized (mSelfObserverLock) {\n            mNotifyUri = notifyUri;\n            mContentResolver = cr;\n            if (mSelfObserver != null) {\n                mContentResolver.unregisterContentObserver(mSelfObserver);\n            }\n            mSelfObserver = new SelfContentObserver(this);\n            mContentResolver.registerContentObserver(mNotifyUri, true, mSelfObserver);\n            mSelfObserverRegistered = true;\n        }\n    }\n\n    public Uri getNotificationUri() {\n        return mNotifyUri;\n    }\n\n    public boolean getWantsAllOnMoveCalls() {\n        return false;\n    }\n\n    /**\n     * Sets a {@link Bundle} that will be returned by {@link #getExtras()}.  <code>null</code> will\n     * be converted into {@link Bundle#EMPTY}.\n     *\n     * @param extras {@link Bundle} to set.\n     * @hide\n     */\n    public void setExtras(Bundle extras) {\n        mExtras = (extras == null) ? Bundle.EMPTY : extras;\n    }\n\n    public Bundle getExtras() {\n        return mExtras;\n    }\n\n    public Bundle respond(Bundle extras) {\n        return Bundle.EMPTY;\n    }\n\n    /**\n     * @deprecated Always returns false since Cursors do not support updating rows\n     */\n    @Deprecated\n    protected boolean isFieldUpdated(int columnIndex) {\n        return false;\n    }\n\n    /**\n     * @deprecated Always returns null since Cursors do not support updating rows\n     */\n    @Deprecated\n    protected Object getUpdatedField(int columnIndex) {\n        return null;\n    }\n\n    /**\n     * This function throws CursorIndexOutOfBoundsException if\n     * the cursor position is out of bounds. Subclass implementations of\n     * the get functions should call this before attempting\n     * to retrieve data.\n     *\n     * @throws CursorIndexOutOfBoundsException\n     */\n    protected void checkPosition() {\n        if (-1 == mPos || getCount() == mPos) {\n            throw new CursorIndexOutOfBoundsException(mPos, getCount());\n        }\n    }\n\n    @Override\n    protected void finalize() {\n        if (mSelfObserver != null && mSelfObserverRegistered == true) {\n            mContentResolver.unregisterContentObserver(mSelfObserver);\n        }\n        try {\n            if (!mClosed) close();\n        } catch(Exception e) { }\n    }\n\n    /**\n     * Cursors use this class to track changes others make to their URI.\n     */\n    protected static class SelfContentObserver extends ContentObserver {\n        WeakReference<AbstractCursor> mCursor;\n\n        public SelfContentObserver(AbstractCursor cursor) {\n            super(null);\n            mCursor = new WeakReference<AbstractCursor>(cursor);\n        }\n\n        @Override\n        public boolean deliverSelfNotifications() {\n            return false;\n        }\n\n        @Override\n        public void onChange(boolean selfChange) {\n            AbstractCursor cursor = mCursor.get();\n            if (cursor != null) {\n                cursor.onChange(false);\n            }\n        }\n    }\n}\n"
  },
  {
    "path": "deprecated/android/wcdb/src/com/tencent/wcdb/AbstractWindowedCursor.java",
    "content": "/*\n * Copyright (C) 2006 The Android Open Source Project\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdb;\n\nimport android.database.CharArrayBuffer;\n\n/**\n * A base class for Cursors that store their data in {@link CursorWindow}s.\n * <p>\n * The cursor owns the cursor window it uses.  When the cursor is closed,\n * its window is also closed.  Likewise, when the window used by the cursor is\n * changed, its old window is closed.  This policy of strict ownership ensures\n * that cursor windows are not leaked.\n * </p><p>\n * Subclasses are responsible for filling the cursor window with data during\n * {@link #onMove(int, int)}, allocating a new cursor window if necessary.\n * During {@link #requery()}, the existing cursor window should be cleared and\n * filled with new data.\n * </p><p>\n * If the contents of the cursor change or become invalid, the old window must be closed\n * (because it is owned by the cursor) and set to null.\n * </p>\n */\npublic abstract class AbstractWindowedCursor extends AbstractCursor {\n    /**\n     * The cursor window owned by this cursor.\n     */\n    protected CursorWindow mWindow;\n\n    @Override\n    public byte[] getBlob(int columnIndex) {\n        checkPosition();\n        return mWindow.getBlob(mPos, columnIndex);\n    }\n\n    @Override\n    public String getString(int columnIndex) {\n        checkPosition();\n        return mWindow.getString(mPos, columnIndex);\n    }\n\n    @Override\n    public void copyStringToBuffer(int columnIndex, CharArrayBuffer buffer) {\n        checkPosition();\n        mWindow.copyStringToBuffer(mPos, columnIndex, buffer);\n    }\n\n    @Override\n    public short getShort(int columnIndex) {\n        checkPosition();\n        return mWindow.getShort(mPos, columnIndex);\n    }\n\n    @Override\n    public int getInt(int columnIndex) {\n        checkPosition();\n        return mWindow.getInt(mPos, columnIndex);\n    }\n\n    @Override\n    public long getLong(int columnIndex) {\n        checkPosition();\n        return mWindow.getLong(mPos, columnIndex);\n    }\n\n    @Override\n    public float getFloat(int columnIndex) {\n        checkPosition();\n        return mWindow.getFloat(mPos, columnIndex);\n    }\n\n    @Override\n    public double getDouble(int columnIndex) {\n        checkPosition();\n        return mWindow.getDouble(mPos, columnIndex);\n    }\n\n    @Override\n    public boolean isNull(int columnIndex) {\n        checkPosition();\n        return mWindow.getType(mPos, columnIndex) == Cursor.FIELD_TYPE_NULL;\n    }\n\n    /**\n     * @deprecated Use {@link #getType}\n     */\n    @Deprecated\n    public boolean isBlob(int columnIndex) {\n        return getType(columnIndex) == Cursor.FIELD_TYPE_BLOB;\n    }\n\n    /**\n     * @deprecated Use {@link #getType}\n     */\n    @Deprecated\n    public boolean isString(int columnIndex) {\n        return getType(columnIndex) == Cursor.FIELD_TYPE_STRING;\n    }\n\n    /**\n     * @deprecated Use {@link #getType}\n     */\n    @Deprecated\n    public boolean isLong(int columnIndex) {\n        return getType(columnIndex) == Cursor.FIELD_TYPE_INTEGER;\n    }\n\n    /**\n     * @deprecated Use {@link #getType}\n     */\n    @Deprecated\n    public boolean isFloat(int columnIndex) {\n        return getType(columnIndex) == Cursor.FIELD_TYPE_FLOAT;\n    }\n\n    @Override\n    public int getType(int columnIndex) {\n        checkPosition();\n        return mWindow.getType(mPos, columnIndex);\n    }\n\n    @Override\n    protected void checkPosition() {\n        super.checkPosition();\n        \n        if (mWindow == null) {\n            throw new StaleDataException(\"Attempting to access a closed CursorWindow.\" +\n                    \"Most probable cause: cursor is deactivated prior to calling this method.\");\n        }\n    }\n\n    @Override\n    public CursorWindow getWindow() {\n        return mWindow;\n    }\n\n    /**\n     * Sets a new cursor window for the cursor to use.\n     * <p>\n     * The cursor takes ownership of the provided cursor window; the cursor window\n     * will be closed when the cursor is closed or when the cursor adopts a new\n     * cursor window.\n     * </p><p>\n     * If the cursor previously had a cursor window, then it is closed when the\n     * new cursor window is assigned.\n     * </p>\n     *\n     * @param window The new cursor window, typically a remote cursor window.\n     */\n    public void setWindow(CursorWindow window) {\n        if (window != mWindow) {\n            closeWindow();\n            mWindow = window;\n        }\n    }\n\n    /**\n     * Returns true if the cursor has an associated cursor window.\n     *\n     * @return True if the cursor has an associated cursor window.\n     */\n    public boolean hasWindow() {\n        return mWindow != null;\n    }\n\n    /**\n     * Closes the cursor window and sets {@link #mWindow} to null.\n     * @hide\n     */\n    protected void closeWindow() {\n        if (mWindow != null) {\n            mWindow.close();\n            mWindow = null;\n        }\n    }\n\n    /**\n     * If there is a window, clear it.\n     * Otherwise, creates a new window.\n     *\n     * @param name The window name.\n     * @hide\n     */\n    protected void clearOrCreateWindow(String name) {\n        if (mWindow == null) {\n            mWindow = new CursorWindow(name);\n        } else {\n            mWindow.clear();\n        }\n    }\n\n    /** @hide */\n    @Override\n    protected void onDeactivateOrClose() {\n        super.onDeactivateOrClose();\n        closeWindow();\n    }\n}\n"
  },
  {
    "path": "deprecated/android/wcdb/src/com/tencent/wcdb/BulkCursorDescriptor.java",
    "content": "/*\n * Copyright (C) 2012 The Android Open Source Project\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdb;\n\nimport android.os.Parcel;\nimport android.os.Parcelable;\n\n/**\n * Describes the properties of a {@link CursorToBulkCursorAdaptor} that are\n * needed to initialize its {@link BulkCursorToCursorAdaptor} counterpart on the client's end.\n *\n * {@hide}\n */\npublic final class BulkCursorDescriptor implements Parcelable {\n    public static final Parcelable.Creator<BulkCursorDescriptor> CREATOR =\n            new Parcelable.Creator<BulkCursorDescriptor>() {\n        @Override\n        public BulkCursorDescriptor createFromParcel(Parcel in) {\n            BulkCursorDescriptor d = new BulkCursorDescriptor();\n            d.readFromParcel(in);\n            return d;\n        }\n\n        @Override\n        public BulkCursorDescriptor[] newArray(int size) {\n            return new BulkCursorDescriptor[size];\n        }\n    };\n\n    public IBulkCursor cursor;\n    public String[] columnNames;\n    public boolean wantsAllOnMoveCalls;\n    public int count;\n    public CursorWindow window;\n\n    @Override\n    public int describeContents() {\n        return 0;\n    }\n\n    @Override\n    public void writeToParcel(Parcel out, int flags) {\n        out.writeStrongBinder(cursor.asBinder());\n        out.writeStringArray(columnNames);\n        out.writeInt(wantsAllOnMoveCalls ? 1 : 0);\n        out.writeInt(count);\n        if (window != null) {\n            out.writeInt(1);\n            window.writeToParcel(out, flags);\n        } else {\n            out.writeInt(0);\n        }\n    }\n\n    /**\n     * Read and return a String[] object from the parcel.\n     * {@hide}\n     */\n    public final String[] readStringArray(Parcel in) {\n        String[] array = null;\n\n        int length = in.readInt();\n        if (length >= 0)\n        {\n            array = new String[length];\n\n            for (int i = 0 ; i < length ; i++)\n            {\n                array[i] = in.readString();\n            }\n        }\n\n        return array;\n    }\n    public void readFromParcel(Parcel in) {\n        cursor = BulkCursorNative.asInterface(in.readStrongBinder());\n        columnNames = readStringArray(in);\n        wantsAllOnMoveCalls = in.readInt() != 0;\n        count = in.readInt();\n        if (in.readInt() != 0) {\n            window = CursorWindow.CREATOR.createFromParcel(in);\n        }\n    }\n}\n"
  },
  {
    "path": "deprecated/android/wcdb/src/com/tencent/wcdb/BulkCursorNative.java",
    "content": "/*\n * Copyright (C) 2006 The Android Open Source Project\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdb;\n\nimport android.os.Binder;\nimport android.os.Bundle;\nimport android.os.IBinder;\nimport android.os.Parcel;\nimport android.os.Parcelable;\nimport android.os.RemoteException;\n\n/**\n * Native implementation of the bulk cursor. This is only for use in implementing\n * IPC, application code should use the Cursor interface.\n *\n * {@hide}\n */\npublic abstract class BulkCursorNative extends Binder implements IBulkCursor\n{\n    public BulkCursorNative()\n    {\n        attachInterface(this, descriptor);\n    }\n\n    /**\n     * Cast a Binder object into a content resolver interface, generating\n     * a proxy if needed.\n     */\n    static public IBulkCursor asInterface(IBinder obj)\n    {\n        if (obj == null) {\n            return null;\n        }\n        IBulkCursor in = (IBulkCursor)obj.queryLocalInterface(descriptor);\n        if (in != null) {\n            return in;\n        }\n\n        return new BulkCursorProxy(obj);\n    }\n    \n    @Override\n    public boolean onTransact(int code, Parcel data, Parcel reply, int flags)\n            throws RemoteException {\n        try {\n            switch (code) {\n                case GET_CURSOR_WINDOW_TRANSACTION: {\n                    data.enforceInterface(IBulkCursor.descriptor);\n                    int startPos = data.readInt();\n                    CursorWindow window = getWindow(startPos);\n                    reply.writeNoException();\n                    if (window == null) {\n                        reply.writeInt(0);\n                    } else {\n                        reply.writeInt(1);\n                        window.writeToParcel(reply, Parcelable.PARCELABLE_WRITE_RETURN_VALUE);\n                    }\n                    return true;\n                }\n\n                case DEACTIVATE_TRANSACTION: {\n                    data.enforceInterface(IBulkCursor.descriptor);\n                    deactivate();\n                    reply.writeNoException();\n                    return true;\n                }\n                \n                case CLOSE_TRANSACTION: {\n                    data.enforceInterface(IBulkCursor.descriptor);\n                    close();\n                    reply.writeNoException();\n                    return true;\n                }\n\n                case REQUERY_TRANSACTION: {\n                    data.enforceInterface(IBulkCursor.descriptor);\n                    IContentObserver observer =\n                            IContentObserver.Stub.asInterface(data.readStrongBinder());\n                    int count = requery(observer);\n                    reply.writeNoException();\n                    reply.writeInt(count);\n                    reply.writeBundle(getExtras());\n                    return true;\n                }\n\n                case ON_MOVE_TRANSACTION: {\n                    data.enforceInterface(IBulkCursor.descriptor);\n                    int position = data.readInt();\n                    onMove(position);\n                    reply.writeNoException();\n                    return true;\n                }\n\n                case GET_EXTRAS_TRANSACTION: {\n                    data.enforceInterface(IBulkCursor.descriptor);\n                    Bundle extras = getExtras();\n                    reply.writeNoException();\n                    reply.writeBundle(extras);\n                    return true;\n                }\n\n                case RESPOND_TRANSACTION: {\n                    data.enforceInterface(IBulkCursor.descriptor);\n                    Bundle extras = data.readBundle(getClass().getClassLoader());\n                    Bundle returnExtras = respond(extras);\n                    reply.writeNoException();\n                    reply.writeBundle(returnExtras);\n                    return true;\n                }\n            }\n        } catch (Exception e) {\n            DatabaseUtils.writeExceptionToParcel(reply, e);\n            return true;\n        }\n\n        return super.onTransact(code, data, reply, flags);\n    }\n\n    public IBinder asBinder()\n    {\n        return this;\n    }\n}\n\n\nfinal class BulkCursorProxy implements IBulkCursor {\n    private IBinder mRemote;\n    private Bundle mExtras;\n\n    public BulkCursorProxy(IBinder remote)\n    {\n        mRemote = remote;\n        mExtras = null;\n    }\n\n    public IBinder asBinder()\n    {\n        return mRemote;\n    }\n\n    public CursorWindow getWindow(int position) throws RemoteException\n    {\n        Parcel data = Parcel.obtain();\n        Parcel reply = Parcel.obtain();\n        try {\n            data.writeInterfaceToken(IBulkCursor.descriptor);\n            data.writeInt(position);\n\n            mRemote.transact(GET_CURSOR_WINDOW_TRANSACTION, data, reply, 0);\n            DatabaseUtils.readExceptionFromParcel(reply);\n\n            CursorWindow window = null;\n            if (reply.readInt() == 1) {\n                window = CursorWindow.newFromParcel(reply);\n            }\n            return window;\n        } finally {\n            data.recycle();\n            reply.recycle();\n        }\n    }\n\n    public void onMove(int position) throws RemoteException {\n        Parcel data = Parcel.obtain();\n        Parcel reply = Parcel.obtain();\n        try {\n            data.writeInterfaceToken(IBulkCursor.descriptor);\n            data.writeInt(position);\n\n            mRemote.transact(ON_MOVE_TRANSACTION, data, reply, 0);\n            DatabaseUtils.readExceptionFromParcel(reply);\n        } finally {\n            data.recycle();\n            reply.recycle();\n        }\n    }\n\n    public void deactivate() throws RemoteException\n    {\n        Parcel data = Parcel.obtain();\n        Parcel reply = Parcel.obtain();\n        try {\n            data.writeInterfaceToken(IBulkCursor.descriptor);\n\n            mRemote.transact(DEACTIVATE_TRANSACTION, data, reply, 0);\n            DatabaseUtils.readExceptionFromParcel(reply);\n        } finally {\n            data.recycle();\n            reply.recycle();\n        }\n    }\n\n    public void close() throws RemoteException\n    {\n        Parcel data = Parcel.obtain();\n        Parcel reply = Parcel.obtain();\n        try {\n            data.writeInterfaceToken(IBulkCursor.descriptor);\n\n            mRemote.transact(CLOSE_TRANSACTION, data, reply, 0);\n            DatabaseUtils.readExceptionFromParcel(reply);\n        } finally {\n            data.recycle();\n            reply.recycle();\n        }\n    }\n    \n    public int requery(IContentObserver observer) throws RemoteException {\n        Parcel data = Parcel.obtain();\n        Parcel reply = Parcel.obtain();\n        try {\n            data.writeInterfaceToken(IBulkCursor.descriptor);\n            data.writeStrongInterface(observer);\n\n            boolean result = mRemote.transact(REQUERY_TRANSACTION, data, reply, 0);\n            DatabaseUtils.readExceptionFromParcel(reply);\n\n            int count;\n            if (!result) {\n                count = -1;\n            } else {\n                count = reply.readInt();\n                mExtras = reply.readBundle(getClass().getClassLoader());\n            }\n            return count;\n        } finally {\n            data.recycle();\n            reply.recycle();\n        }\n    }\n\n    public Bundle getExtras() throws RemoteException {\n        if (mExtras == null) {\n            Parcel data = Parcel.obtain();\n            Parcel reply = Parcel.obtain();\n            try {\n                data.writeInterfaceToken(IBulkCursor.descriptor);\n\n                mRemote.transact(GET_EXTRAS_TRANSACTION, data, reply, 0);\n                DatabaseUtils.readExceptionFromParcel(reply);\n\n                mExtras = reply.readBundle(getClass().getClassLoader());\n            } finally {\n                data.recycle();\n                reply.recycle();\n            }\n        }\n        return mExtras;\n    }\n\n    public Bundle respond(Bundle extras) throws RemoteException {\n        Parcel data = Parcel.obtain();\n        Parcel reply = Parcel.obtain();\n        try {\n            data.writeInterfaceToken(IBulkCursor.descriptor);\n            data.writeBundle(extras);\n\n            mRemote.transact(RESPOND_TRANSACTION, data, reply, 0);\n            DatabaseUtils.readExceptionFromParcel(reply);\n\n            return reply.readBundle(getClass().getClassLoader());\n        } finally {\n            data.recycle();\n            reply.recycle();\n        }\n    }\n}\n\n"
  },
  {
    "path": "deprecated/android/wcdb/src/com/tencent/wcdb/BulkCursorToCursorAdaptor.java",
    "content": "/*\n * Copyright (C) 2006 The Android Open Source Project\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdb;\n\nimport android.os.Bundle;\nimport android.os.RemoteException;\nimport com.tencent.wcdb.support.Log;\n\n/**\n * Adapts an {@link IBulkCursor} to a {@link Cursor} for use in the local process.\n *\n * {@hide}\n */\npublic final class BulkCursorToCursorAdaptor extends AbstractWindowedCursor {\n    private static final String TAG = \"BulkCursor\";\n\n    private SelfContentObserver mObserverBridge = new SelfContentObserver(this);\n    private IBulkCursor mBulkCursor;\n    private String[] mColumns;\n    private boolean mWantsAllOnMoveCalls;\n    private int mCount;\n\n    /**\n     * Initializes the adaptor.\n     * Must be called before first use.\n     */\n    @SuppressWarnings(\"deprecation\")\n\tpublic void initialize(BulkCursorDescriptor d) {\n        mBulkCursor = d.cursor;\n        mColumns = d.columnNames;\n        mRowIdColumnIndex = DatabaseUtils.findRowIdColumnIndex(mColumns);\n        mWantsAllOnMoveCalls = d.wantsAllOnMoveCalls;\n        mCount = d.count;\n        if (d.window != null) {\n            setWindow(d.window);\n        }\n    }\n\n    /**\n     * Gets a SelfDataChangeOberserver that can be sent to a remote\n     * process to receive change notifications over IPC.\n     *\n     * @return A SelfContentObserver hooked up to this Cursor\n     */\n    public IContentObserver getObserver() {\n        // getContentObserver is defined as @hide in Android SDK, needs reflection to get access.\n        try {\n            return (IContentObserver) mObserverBridge.getClass().getMethod(\"getContentObserver\")\n                    .invoke(mObserverBridge);\n        } catch (Exception e) {\n            return null;\n        }\n    }\n\n    private void throwIfCursorIsClosed() {\n        if (mBulkCursor == null) {\n            throw new StaleDataException(\"Attempted to access a cursor after it has been closed.\");\n        }\n    }\n\n    @Override\n    public int getCount() {\n        throwIfCursorIsClosed();\n        return mCount;\n    }\n\n    @Override\n    public boolean onMove(int oldPosition, int newPosition) {\n        throwIfCursorIsClosed();\n\n        try {\n            // Make sure we have the proper window\n            if (mWindow == null\n                    || newPosition < mWindow.getStartPosition()\n                    || newPosition >= mWindow.getStartPosition() + mWindow.getNumRows()) {\n                setWindow(mBulkCursor.getWindow(newPosition));\n            } else if (mWantsAllOnMoveCalls) {\n                mBulkCursor.onMove(newPosition);\n            }\n        } catch (RemoteException ex) {\n            // We tried to get a window and failed\n            Log.e(TAG, \"Unable to get window because the remote process is dead\");\n            return false;\n        }\n\n        // Couldn't obtain a window, something is wrong\n        if (mWindow == null) {\n            return false;\n        }\n\n        return true;\n    }\n\n    @Override\n    public void deactivate() {\n        // This will call onInvalidated(), so make sure to do it before calling release,\n        // which is what actually makes the data set invalid.\n        super.deactivate();\n\n        if (mBulkCursor != null) {\n            try {\n                mBulkCursor.deactivate();\n            } catch (RemoteException ex) {\n                Log.w(TAG, \"Remote process exception when deactivating\");\n            }\n        }\n    }\n    \n    @Override\n    public void close() {\n        super.close();\n\n        if (mBulkCursor != null) {\n            try {\n                mBulkCursor.close();\n            } catch (RemoteException ex) {\n                Log.w(TAG, \"Remote process exception when closing\");\n            } finally {\n                mBulkCursor = null;\n            }\n        }\n    }\n\n    @Override\n    public boolean requery() {\n        throwIfCursorIsClosed();\n\n        try {\n            mCount = mBulkCursor.requery(getObserver());\n            if (mCount != -1) {\n                mPos = -1;\n                closeWindow();\n\n                // super.requery() will call onChanged. Do it here instead of relying on the\n                // observer from the far side so that observers can see a correct value for mCount\n                // when responding to onChanged.\n                super.requery();\n                return true;\n            } else {\n                deactivate();\n                return false;\n            }\n        } catch (Exception ex) {\n            Log.e(TAG, \"Unable to requery because the remote process exception \" + ex.getMessage());\n            deactivate();\n            return false;\n        }\n    }\n\n    @Override\n    public String[] getColumnNames() {\n        throwIfCursorIsClosed();\n\n        return mColumns;\n    }\n\n    @Override\n    public Bundle getExtras() {\n        throwIfCursorIsClosed();\n\n        try {\n            return mBulkCursor.getExtras();\n        } catch (RemoteException e) {\n            // This should never happen because the system kills processes that are using remote\n            // cursors when the provider process is killed.\n            throw new RuntimeException(e);\n        }\n    }\n\n    @Override\n    public Bundle respond(Bundle extras) {\n        throwIfCursorIsClosed();\n\n        try {\n            return mBulkCursor.respond(extras);\n        } catch (RemoteException e) {\n            // the system kills processes that are using remote cursors when the provider process\n            // is killed, but this can still happen if this is being called from the system process,\n            // so, better to log and return an empty bundle.\n            Log.w(TAG, \"respond() threw RemoteException, returning an empty bundle.\", e);\n            return Bundle.EMPTY;\n        }\n    }\n\n\t@Override\n\tpublic void copyStringToBuffer(int arg0, android.database.CharArrayBuffer arg1)\n\t{\n\t\t// TODO Auto-generated method stub\n\t}\n\n\t@Override\n\tpublic void registerContentObserver(android.database.ContentObserver observer)\n\t{\n\t\t// TODO Auto-generated method stub\n\t\t\n\t}\n\n\t@Override\n\tpublic void registerDataSetObserver(android.database.DataSetObserver observer)\n\t{\n\t\t// TODO Auto-generated method stub\n\t\t\n\t}\n\n\t@Override\n\tpublic void unregisterContentObserver(android.database.ContentObserver observer)\n\t{\n\t\t// TODO Auto-generated method stub\n\t\t\n\t}\n\n\t@Override\n\tpublic void unregisterDataSetObserver(android.database.DataSetObserver observer)\n\t{\n\t\t// TODO Auto-generated method stub\n\t\t\n\t}\n}\n"
  },
  {
    "path": "deprecated/android/wcdb/src/com/tencent/wcdb/CrossProcessCursor.java",
    "content": "/*\n * Copyright (C) 2008 The Android Open Source Project\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdb;\n\n/**\n * A cross process cursor is an extension of a {@link Cursor} that also supports\n * usage from remote processes.\n * <p>\n * The contents of a cross process cursor are marshalled to the remote process by\n * filling {@link CursorWindow} objects using {@link #fillWindow}.  As an optimization,\n * the cursor can provide a pre-filled window to use via {@link #getWindow} thereby\n * obviating the need to copy the data to yet another cursor window.\n */\npublic interface CrossProcessCursor extends Cursor {\n    /**\n     * Returns a pre-filled window that contains the data within this cursor.\n     * <p>\n     * In particular, the window contains the row indicated by {@link Cursor#getPosition}.\n     * The window's contents are automatically scrolled whenever the current\n     * row moved outside the range covered by the window.\n     * </p>\n     *\n     * @return The pre-filled window, or null if none.\n     */\n    CursorWindow getWindow();\n\n    /**\n     * Copies cursor data into the window.\n     * <p>\n     * Clears the window and fills it with data beginning at the requested\n     * row position until all of the data in the cursor is exhausted\n     * or the window runs out of space.\n     * </p><p>\n     * The filled window uses the same row indices as the original cursor.\n     * For example, if you fill a window starting from row 5 from the cursor,\n     * you can query the contents of row 5 from the window just by asking it\n     * for row 5 because there is a direct correspondence between the row indices\n     * used by the cursor and the window.\n     * </p><p>\n     * The current position of the cursor, as returned by {@link #getPosition},\n     * is not changed by this method.\n     * </p>\n     *\n     * @param position The zero-based index of the first row to copy into the window.\n     * @param window The window to fill.\n     */\n    void fillWindow(int position, CursorWindow window);\n\n    /**\n     * This function is called every time the cursor is successfully scrolled\n     * to a new position, giving the subclass a chance to update any state it\n     * may have.  If it returns false the move function will also do so and the\n     * cursor will scroll to the beforeFirst position.\n     * <p>\n     * This function should be called by methods such as {@link #moveToPosition(int)},\n     * so it will typically not be called from outside of the cursor class itself.\n     * </p>\n     *\n     * @param oldPosition The position that we're moving from.\n     * @param newPosition The position that we're moving to.\n     * @return True if the move is successful, false otherwise.\n     */\n    boolean onMove(int oldPosition, int newPosition); \n}\n"
  },
  {
    "path": "deprecated/android/wcdb/src/com/tencent/wcdb/CrossProcessCursorWrapper.java",
    "content": "/*\n * Copyright (C) 2011 The Android Open Source Project\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License\n */\n\npackage com.tencent.wcdb;\n\n/**\n * Cursor wrapper that implements {@link CrossProcessCursor}.\n * <p>\n * If the wrapped cursor implements {@link CrossProcessCursor}, then the wrapper\n * delegates {@link #fillWindow}, {@link #getWindow()} and {@link #onMove} to it.\n * Otherwise, the wrapper provides default implementations of these methods that\n * traverse the contents of the cursor similar to {@link AbstractCursor#fillWindow}.\n * </p><p>\n * This wrapper can be used to adapt an ordinary {@link Cursor} into a\n * {@link CrossProcessCursor}.\n * </p>\n */\npublic class CrossProcessCursorWrapper extends CursorWrapper implements CrossProcessCursor {\n    /**\n     * Creates a cross process cursor wrapper.\n     * @param cursor The underlying cursor to wrap.\n     */\n    public CrossProcessCursorWrapper(Cursor cursor) {\n        super(cursor);\n    }\n\n    @Override\n    public void fillWindow(int position, CursorWindow window) {\n        if (mCursor instanceof CrossProcessCursor) {\n            final CrossProcessCursor crossProcessCursor = (CrossProcessCursor)mCursor;\n            crossProcessCursor.fillWindow(position, window);\n            return;\n        }\n\n        DatabaseUtils.cursorFillWindow(mCursor, position, window);\n    }\n\n    @Override\n    public CursorWindow getWindow() {\n        if (mCursor instanceof CrossProcessCursor) {\n            final CrossProcessCursor crossProcessCursor = (CrossProcessCursor)mCursor;\n            return crossProcessCursor.getWindow();\n        }\n\n        return null;\n    }\n\n    @Override\n    public boolean onMove(int oldPosition, int newPosition) {\n        if (mCursor instanceof CrossProcessCursor) {\n            final CrossProcessCursor crossProcessCursor = (CrossProcessCursor)mCursor;\n            return crossProcessCursor.onMove(oldPosition, newPosition);\n        }\n\n        return true;\n    }\n}\n"
  },
  {
    "path": "deprecated/android/wcdb/src/com/tencent/wcdb/Cursor.java",
    "content": "/*\n * Copyright (C) 2006 The Android Open Source Project\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdb;\n\nimport android.content.ContentResolver;\nimport android.database.CharArrayBuffer;\nimport android.database.ContentObserver;\nimport android.database.DataSetObserver;\nimport android.net.Uri;\nimport android.os.Bundle;\n\n/**\n * This interface provides random read-write access to the result set returned\n * by a database query.\n *\n * Cursor implementations are not required to be synchronized so code using a Cursor from multiple\n * threads should perform its own synchronization when using the Cursor.\n */\npublic interface Cursor extends android.database.Cursor {\n    /*\n     * Values returned by {@link #getType(int)}.\n     * These should be consistent with the corresponding types defined in CursorWindow.h\n     */\n    /** Value returned by {@link #getType(int)} if the specified column is null */\n    static final int FIELD_TYPE_NULL = 0;\n\n    /** Value returned by {@link #getType(int)} if the specified  column type is integer */\n    static final int FIELD_TYPE_INTEGER = 1;\n\n    /** Value returned by {@link #getType(int)} if the specified column type is float */\n    static final int FIELD_TYPE_FLOAT = 2;\n\n    /** Value returned by {@link #getType(int)} if the specified column type is string */\n    static final int FIELD_TYPE_STRING = 3;\n\n    /** Value returned by {@link #getType(int)} if the specified column type is blob */\n    static final int FIELD_TYPE_BLOB = 4;\n\n    /**\n     * Returns the numbers of rows in the cursor.\n     *\n     * @return the number of rows in the cursor.\n     */\n    int getCount();\n\n    /**\n     * Returns the current position of the cursor in the row set.\n     * The value is zero-based. When the row set is first returned the cursor\n     * will be at positon -1, which is before the first row. After the\n     * last row is returned another call to next() will leave the cursor past\n     * the last entry, at a position of count().\n     *\n     * @return the current cursor position.\n     */\n    int getPosition();\n\n    /**\n     * Move the cursor by a relative amount, forward or backward, from the\n     * current position. Positive offsets move forwards, negative offsets move\n     * backwards. If the final position is outside of the bounds of the result\n     * set then the resultant position will be pinned to -1 or count() depending\n     * on whether the value is off the front or end of the set, respectively.\n     *\n     * <p>This method will return true if the requested destination was\n     * reachable, otherwise, it returns false. For example, if the cursor is at\n     * currently on the second entry in the result set and move(-5) is called,\n     * the position will be pinned at -1, and false will be returned.\n     *\n     * @param offset the offset to be applied from the current position.\n     * @return whether the requested move fully succeeded.\n     */\n    boolean move(int offset);\n\n    /**\n     * Move the cursor to an absolute position. The valid\n     * range of values is -1 &lt;= position &lt;= count.\n     *\n     * <p>This method will return true if the request destination was reachable, \n     * otherwise, it returns false.\n     *\n     * @param position the zero-based position to move to.\n     * @return whether the requested move fully succeeded.\n     */\n    boolean moveToPosition(int position);\n\n    /**\n     * Move the cursor to the first row.\n     *\n     * <p>This method will return false if the cursor is empty.\n     *\n     * @return whether the move succeeded.\n     */\n    boolean moveToFirst();\n\n    /**\n     * Move the cursor to the last row.\n     *\n     * <p>This method will return false if the cursor is empty.\n     *\n     * @return whether the move succeeded.\n     */\n    boolean moveToLast();\n\n    /**\n     * Move the cursor to the next row.\n     *\n     * <p>This method will return false if the cursor is already past the\n     * last entry in the result set.\n     *\n     * @return whether the move succeeded.\n     */\n    boolean moveToNext();\n\n    /**\n     * Move the cursor to the previous row.\n     *\n     * <p>This method will return false if the cursor is already before the\n     * first entry in the result set.\n     *\n     * @return whether the move succeeded.\n     */\n    boolean moveToPrevious();\n\n    /**\n     * Returns whether the cursor is pointing to the first row.\n     *\n     * @return whether the cursor is pointing at the first entry.\n     */\n    boolean isFirst();\n\n    /**\n     * Returns whether the cursor is pointing to the last row.\n     *\n     * @return whether the cursor is pointing at the last entry.\n     */\n    boolean isLast();\n\n    /**\n     * Returns whether the cursor is pointing to the position before the first\n     * row.\n     *\n     * @return whether the cursor is before the first result.\n     */\n    boolean isBeforeFirst();\n\n    /**\n     * Returns whether the cursor is pointing to the position after the last\n     * row.\n     *\n     * @return whether the cursor is after the last result.\n     */\n    boolean isAfterLast();\n\n    /**\n     * Returns the zero-based index for the given column name, or -1 if the column doesn't exist.\n     * If you expect the column to exist use {@link #getColumnIndexOrThrow(String)} instead, which\n     * will make the error more clear.\n     *\n     * @param columnName the name of the target column.\n     * @return the zero-based column index for the given column name, or -1 if\n     * the column name does not exist.\n     * @see #getColumnIndexOrThrow(String)\n     */\n    int getColumnIndex(String columnName);\n\n    /**\n     * Returns the zero-based index for the given column name, or throws\n     * {@link IllegalArgumentException} if the column doesn't exist. If you're not sure if\n     * a column will exist or not use {@link #getColumnIndex(String)} and check for -1, which\n     * is more efficient than catching the exceptions.\n     *\n     * @param columnName the name of the target column.\n     * @return the zero-based column index for the given column name\n     * @see #getColumnIndex(String)\n     * @throws IllegalArgumentException if the column does not exist\n     */\n    int getColumnIndexOrThrow(String columnName) throws IllegalArgumentException;\n\n    /**\n     * Returns the column name at the given zero-based column index.\n     *\n     * @param columnIndex the zero-based index of the target column.\n     * @return the column name for the given column index.\n     */\n    String getColumnName(int columnIndex);\n\n    /**\n     * Returns a string array holding the names of all of the columns in the\n     * result set in the order in which they were listed in the result.\n     *\n     * @return the names of the columns returned in this query.\n     */\n    String[] getColumnNames();\n\n    /**\n     * Return total number of columns\n     * @return number of columns \n     */\n    int getColumnCount();\n    \n    /**\n     * Returns the value of the requested column as a byte array.\n     *\n     * <p>The result and whether this method throws an exception when the\n     * column value is null or the column type is not a blob type is\n     * implementation-defined.\n     *\n     * @param columnIndex the zero-based index of the target column.\n     * @return the value of that column as a byte array.\n     */\n    byte[] getBlob(int columnIndex);\n\n    /**\n     * Returns the value of the requested column as a String.\n     *\n     * <p>The result and whether this method throws an exception when the\n     * column value is null or the column type is not a string type is\n     * implementation-defined.\n     *\n     * @param columnIndex the zero-based index of the target column.\n     * @return the value of that column as a String.\n     */\n    String getString(int columnIndex);\n    \n    /**\n     * Retrieves the requested column text and stores it in the buffer provided.\n     * If the buffer size is not sufficient, a new char buffer will be allocated \n     * and assigned to CharArrayBuffer.data\n     * @param columnIndex the zero-based index of the target column.\n     *        if the target column is null, return buffer\n     * @param buffer the buffer to copy the text into. \n     */\n    void copyStringToBuffer(int columnIndex, CharArrayBuffer buffer);\n    \n    /**\n     * Returns the value of the requested column as a short.\n     *\n     * <p>The result and whether this method throws an exception when the\n     * column value is null, the column type is not an integral type, or the\n     * integer value is outside the range [<code>Short.MIN_VALUE</code>,\n     * <code>Short.MAX_VALUE</code>] is implementation-defined.\n     *\n     * @param columnIndex the zero-based index of the target column.\n     * @return the value of that column as a short.\n     */\n    short getShort(int columnIndex);\n\n    /**\n     * Returns the value of the requested column as an int.\n     *\n     * <p>The result and whether this method throws an exception when the\n     * column value is null, the column type is not an integral type, or the\n     * integer value is outside the range [<code>Integer.MIN_VALUE</code>,\n     * <code>Integer.MAX_VALUE</code>] is implementation-defined.\n     *\n     * @param columnIndex the zero-based index of the target column.\n     * @return the value of that column as an int.\n     */\n    int getInt(int columnIndex);\n\n    /**\n     * Returns the value of the requested column as a long.\n     *\n     * <p>The result and whether this method throws an exception when the\n     * column value is null, the column type is not an integral type, or the\n     * integer value is outside the range [<code>Long.MIN_VALUE</code>,\n     * <code>Long.MAX_VALUE</code>] is implementation-defined.\n     *\n     * @param columnIndex the zero-based index of the target column.\n     * @return the value of that column as a long.\n     */\n    long getLong(int columnIndex);\n\n    /**\n     * Returns the value of the requested column as a float.\n     *\n     * <p>The result and whether this method throws an exception when the\n     * column value is null, the column type is not a floating-point type, or the\n     * floating-point value is not representable as a <code>float</code> value is\n     * implementation-defined.\n     *\n     * @param columnIndex the zero-based index of the target column.\n     * @return the value of that column as a float.\n     */\n    float getFloat(int columnIndex);\n\n    /**\n     * Returns the value of the requested column as a double.\n     *\n     * <p>The result and whether this method throws an exception when the\n     * column value is null, the column type is not a floating-point type, or the\n     * floating-point value is not representable as a <code>double</code> value is\n     * implementation-defined.\n     *\n     * @param columnIndex the zero-based index of the target column.\n     * @return the value of that column as a double.\n     */\n    double getDouble(int columnIndex);\n\n    /**\n     * Returns data type of the given column's value.\n     * The preferred type of the column is returned but the data may be converted to other types\n     * as documented in the get-type methods such as {@link #getInt(int)}, {@link #getFloat(int)}\n     * etc.\n     *<p>\n     * Returned column types are\n     * <ul>\n     *   <li>{@link #FIELD_TYPE_NULL}</li>\n     *   <li>{@link #FIELD_TYPE_INTEGER}</li>\n     *   <li>{@link #FIELD_TYPE_FLOAT}</li>\n     *   <li>{@link #FIELD_TYPE_STRING}</li>\n     *   <li>{@link #FIELD_TYPE_BLOB}</li>\n     *</ul>\n     *</p>\n     *\n     * @param columnIndex the zero-based index of the target column.\n     * @return column value type\n     */\n    int getType(int columnIndex);\n\n    /**\n     * Returns <code>true</code> if the value in the indicated column is null.\n     *\n     * @param columnIndex the zero-based index of the target column.\n     * @return whether the column value is null.\n     */\n    boolean isNull(int columnIndex);\n\n    /**\n     * Deactivates the Cursor, making all calls on it fail until {@link #requery} is called.\n     * Inactive Cursors use fewer resources than active Cursors.\n     * Calling {@link #requery} will make the cursor active again.\n     * @deprecated Since {@link #requery()} is deprecated, so too is this.\n     */\n    void deactivate();\n\n    /**\n     * Performs the query that created the cursor again, refreshing its \n     * contents. This may be done at any time, including after a call to {@link\n     * #deactivate}.\n     *\n     * Since this method could execute a query on the database and potentially take\n     * a while, it could cause ANR if it is called on Main (UI) thread.\n     * A warning is printed if this method is being executed on Main thread.\n     *\n     * @return true if the requery succeeded, false if not, in which case the\n     *         cursor becomes invalid.\n     * @deprecated Don't use this. Just request a new cursor, so you can do this\n     * asynchronously and update your list view once the new cursor comes back.\n     */\n    @Deprecated\n    boolean requery();\n\n    /**\n     * Closes the Cursor, releasing all of its resources and making it completely invalid.\n     * Unlike {@link #deactivate()} a call to {@link #requery()} will not make the Cursor valid\n     * again.\n     */\n    void close();\n\n    /**\n     * return true if the cursor is closed\n     * @return true if the cursor is closed.\n     */\n    boolean isClosed();\n    \n    /**\n     * Register an observer that is called when changes happen to the content backing this cursor.\n     * Typically the data set won't change until {@link #requery()} is called.\n     *\n     * @param observer the object that gets notified when the content backing the cursor changes.\n     * @see #unregisterContentObserver(ContentObserver)\n     */\n    void registerContentObserver(ContentObserver observer);\n\n    /**\n     * Unregister an observer that has previously been registered with this\n     * cursor via {@link #registerContentObserver}.\n     *\n     * @param observer the object to unregister.\n     * @see #registerContentObserver(ContentObserver)\n     */\n    void unregisterContentObserver(ContentObserver observer);\n    \n    /**\n     * Register an observer that is called when changes happen to the contents\n     * of the this cursors data set, for example, when the data set is changed via\n     * {@link #requery()}, {@link #deactivate()}, or {@link #close()}.\n     *\n     * @param observer the object that gets notified when the cursors data set changes.\n     * @see #unregisterDataSetObserver(DataSetObserver)\n     */\n    void registerDataSetObserver(DataSetObserver observer);\n\n    /**\n     * Unregister an observer that has previously been registered with this\n     * cursor via {@link #registerContentObserver}.\n     *\n     * @param observer the object to unregister.\n     * @see #registerDataSetObserver(DataSetObserver)\n     */\n    void unregisterDataSetObserver(DataSetObserver observer);\n\n    /**\n     * Register to watch a content URI for changes. This can be the URI of a specific data row (for \n     * example, \"content://my_provider_type/23\"), or a a generic URI for a content type.\n     * \n     * @param cr The content resolver from the caller's context. The listener attached to \n     * this resolver will be notified.\n     * @param uri The content URI to watch.\n     */\n    void setNotificationUri(ContentResolver cr, Uri uri);\n\n    /**\n     * onMove() will only be called across processes if this method returns true.\n     * @return whether all cursor movement should result in a call to onMove().\n     */\n    boolean getWantsAllOnMoveCalls();\n\n    /**\n     * Returns a bundle of extra values. This is an optional way for cursors to provide out-of-band\n     * metadata to their users. One use of this is for reporting on the progress of network requests\n     * that are required to fetch data for the cursor.\n     *\n     * <p>These values may only change when requery is called.\n     * @return cursor-defined values, or {@link android.os.Bundle#EMPTY Bundle.EMPTY} if there\n     *         are no values. Never <code>null</code>.\n     */\n    Bundle getExtras();\n\n    /**\n     * This is an out-of-band way for the the user of a cursor to communicate with the cursor. The\n     * structure of each bundle is entirely defined by the cursor.\n     *\n     * <p>One use of this is to tell a cursor that it should retry its network request after it\n     * reported an error.\n     * @param extras extra values, or {@link android.os.Bundle#EMPTY Bundle.EMPTY}.\n     *         Never <code>null</code>.\n     * @return extra values, or {@link android.os.Bundle#EMPTY Bundle.EMPTY}.\n     *         Never <code>null</code>.\n     */\n    Bundle respond(Bundle extras);\n}\n"
  },
  {
    "path": "deprecated/android/wcdb/src/com/tencent/wcdb/CursorIndexOutOfBoundsException.java",
    "content": "/*\n * Copyright (C) 2006 The Android Open Source Project\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdb;\n\n/**\n * An exception indicating that a cursor is out of bounds.\n */\n@SuppressWarnings(\"serial\")\npublic class CursorIndexOutOfBoundsException extends IndexOutOfBoundsException {\n\n    public CursorIndexOutOfBoundsException(int index, int size) {\n        super(\"Index \" + index + \" requested, with a size of \" + size);\n    }\n\n    public CursorIndexOutOfBoundsException(String message) {\n        super(message);\n    }\n}\n"
  },
  {
    "path": "deprecated/android/wcdb/src/com/tencent/wcdb/CursorJoiner.java",
    "content": "/*\n * Copyright (C) 2008 The Android Open Source Project\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdb;\n\nimport java.util.Iterator;\n\n/**\n * Does a join on two cursors using the specified columns. The cursors must already\n * be sorted on each of the specified columns in ascending order. This joiner only\n * supports the case where the tuple of key column values is unique.\n * <p>\n * Typical usage:\n *\n * <pre>\n * CursorJoiner joiner = new CursorJoiner(cursorA, keyColumnsofA, cursorB, keyColumnsofB);\n * for (CursorJointer.Result joinerResult : joiner) {\n *     switch (joinerResult) {\n *         case LEFT:\n *             // handle case where a row in cursorA is unique\n *             break;\n *         case RIGHT:\n *             // handle case where a row in cursorB is unique\n *             break;\n *         case BOTH:\n *             // handle case where a row with the same key is in both cursors\n *             break;\n *     }\n * }\n * </pre>\n */\npublic final class CursorJoiner\n        implements Iterator<CursorJoiner.Result>, Iterable<CursorJoiner.Result> {\n    private Cursor mCursorLeft;\n    private Cursor mCursorRight;\n    private boolean mCompareResultIsValid;\n    private Result mCompareResult;\n    private int[] mColumnsLeft;\n    private int[] mColumnsRight;\n    private String[] mValues;\n\n    /**\n     * The result of a call to next().\n     */\n    public enum Result {\n        /** The row currently pointed to by the left cursor is unique */\n        RIGHT,\n        /** The row currently pointed to by the right cursor is unique */\n        LEFT,\n        /** The rows pointed to by both cursors are the same */\n        BOTH\n    }\n\n    /**\n     * Initializes the CursorJoiner and resets the cursors to the first row. The left and right\n     * column name arrays must have the same number of columns.\n     * @param cursorLeft The left cursor to compare\n     * @param columnNamesLeft The column names to compare from the left cursor\n     * @param cursorRight The right cursor to compare\n     * @param columnNamesRight The column names to compare from the right cursor\n     */\n    public CursorJoiner(\n            Cursor cursorLeft, String[] columnNamesLeft,\n            Cursor cursorRight, String[] columnNamesRight) {\n        if (columnNamesLeft.length != columnNamesRight.length) {\n            throw new IllegalArgumentException(\n                    \"you must have the same number of columns on the left and right, \"\n                            + columnNamesLeft.length + \" != \" + columnNamesRight.length);\n        }\n\n        mCursorLeft = cursorLeft;\n        mCursorRight = cursorRight;\n\n        mCursorLeft.moveToFirst();\n        mCursorRight.moveToFirst();\n\n        mCompareResultIsValid = false;\n\n        mColumnsLeft = buildColumnIndiciesArray(cursorLeft, columnNamesLeft);\n        mColumnsRight = buildColumnIndiciesArray(cursorRight, columnNamesRight);\n\n        mValues = new String[mColumnsLeft.length * 2];\n    }\n\n    public Iterator<Result> iterator() {\n        return this;\n    }\n\n    /**\n     * Lookup the indicies of the each column name and return them in an array.\n     * @param cursor the cursor that contains the columns\n     * @param columnNames the array of names to lookup\n     * @return an array of column indices\n     */\n    private int[] buildColumnIndiciesArray(Cursor cursor, String[] columnNames) {\n        int[] columns = new int[columnNames.length];\n        for (int i = 0; i < columnNames.length; i++) {\n            columns[i] = cursor.getColumnIndexOrThrow(columnNames[i]);\n        }\n        return columns;\n    }\n\n    /**\n     * Returns whether or not there are more rows to compare using next().\n     * @return true if there are more rows to compare\n     */\n    public boolean hasNext() {\n        if (mCompareResultIsValid) {\n            switch (mCompareResult) {\n                case BOTH:\n                    return !mCursorLeft.isLast() || !mCursorRight.isLast();\n\n                case LEFT:\n                    return !mCursorLeft.isLast() || !mCursorRight.isAfterLast();\n\n                case RIGHT:\n                    return !mCursorLeft.isAfterLast() || !mCursorRight.isLast();\n\n                default:\n                    throw new IllegalStateException(\"bad value for mCompareResult, \"\n                            + mCompareResult);\n            }\n        } else {\n            return !mCursorLeft.isAfterLast() || !mCursorRight.isAfterLast();\n        }\n    }\n\n    /**\n     * Returns the comparison result of the next row from each cursor. If one cursor\n     * has no more rows but the other does then subsequent calls to this will indicate that\n     * the remaining rows are unique.\n     * <p>\n     * The caller must check that hasNext() returns true before calling this.\n     * <p>\n     * Once next() has been called the cursors specified in the result of the call to\n     * next() are guaranteed to point to the row that was indicated. Reading values\n     * from the cursor that was not indicated in the call to next() will result in\n     * undefined behavior.\n     * @return LEFT, if the row pointed to by the left cursor is unique, RIGHT\n     *   if the row pointed to by the right cursor is unique, BOTH if the rows in both\n     *   cursors are the same.\n     */\n    public Result next() {\n        if (!hasNext()) {\n            throw new IllegalStateException(\"you must only call next() when hasNext() is true\");\n        }\n        incrementCursors();\n        if (BuildConfig.DEBUG && !hasNext())\n            throw new AssertionError(\"hasNext()\");\n\n        boolean hasLeft = !mCursorLeft.isAfterLast();\n        boolean hasRight = !mCursorRight.isAfterLast();\n\n        if (hasLeft && hasRight) {\n            populateValues(mValues, mCursorLeft, mColumnsLeft, 0 /* start filling at index 0 */);\n            populateValues(mValues, mCursorRight, mColumnsRight, 1 /* start filling at index 1 */);\n            switch (compareStrings(mValues)) {\n                case -1:\n                    mCompareResult = Result.LEFT;\n                    break;\n                case 0:\n                    mCompareResult = Result.BOTH;\n                    break;\n                case 1:\n                    mCompareResult = Result.RIGHT;\n                    break;\n            }\n        } else if (hasLeft) {\n            mCompareResult = Result.LEFT;\n        } else  {\n            if (BuildConfig.DEBUG && !hasRight)\n                throw new AssertionError(\"hasRight\");\n            mCompareResult = Result.RIGHT;\n        }\n        mCompareResultIsValid = true;\n        return mCompareResult;\n    }\n\n    public void remove() {\n        throw new UnsupportedOperationException(\"not implemented\");\n    }\n\n    /**\n     * Reads the strings from the cursor that are specifed in the columnIndicies\n     * array and saves them in values beginning at startingIndex, skipping a slot\n     * for each value. If columnIndicies has length 3 and startingIndex is 1, the\n     * values will be stored in slots 1, 3, and 5.\n     * @param values the String[] to populate\n     * @param cursor the cursor from which to read\n     * @param columnIndicies the indicies of the values to read from the cursor\n     * @param startingIndex the slot in which to start storing values, and must be either 0 or 1.\n     */\n    private static void populateValues(String[] values, Cursor cursor, int[] columnIndicies,\n            int startingIndex) {\n        if (BuildConfig.DEBUG && !(startingIndex == 0 || startingIndex == 1))\n            throw new AssertionError(\"startingIndex == 0 || startingIndex == 1\");\n        for (int i = 0; i < columnIndicies.length; i++) {\n            values[startingIndex + i*2] = cursor.getString(columnIndicies[i]);\n        }\n    }\n\n    /**\n     * Increment the cursors past the rows indicated in the most recent call to next().\n     * This will only have an affect once per call to next().\n     */\n    private void incrementCursors() {\n        if (mCompareResultIsValid) {\n            switch (mCompareResult) {\n                case LEFT:\n                    mCursorLeft.moveToNext();\n                    break;\n                case RIGHT:\n                    mCursorRight.moveToNext();\n                    break;\n                case BOTH:\n                    mCursorLeft.moveToNext();\n                    mCursorRight.moveToNext();\n                    break;\n            }\n            mCompareResultIsValid = false;\n        }\n    }\n\n    /**\n     * Compare the values. Values contains n pairs of strings. If all the pairs of strings match\n     * then returns 0. Otherwise returns the comparison result of the first non-matching pair\n     * of values, -1 if the first of the pair is less than the second of the pair or 1 if it\n     * is greater.\n     * @param values the n pairs of values to compare\n     * @return -1, 0, or 1 as described above.\n     */\n    private static int compareStrings(String... values) {\n        if ((values.length % 2) != 0) {\n            throw new IllegalArgumentException(\"you must specify an even number of values\");\n        }\n\n        for (int index = 0; index < values.length; index+=2) {\n            if (values[index] == null) {\n                if (values[index+1] == null) continue;\n                return -1;\n            }\n\n            if (values[index+1] == null) {\n                return 1;\n            }\n\n            int comp = values[index].compareTo(values[index+1]);\n            if (comp != 0) {\n                return comp < 0 ? -1 : 1;\n            }\n        }\n\n        return 0;\n    }\n}\n"
  },
  {
    "path": "deprecated/android/wcdb/src/com/tencent/wcdb/CursorToBulkCursorAdaptor.java",
    "content": "/*\n * Copyright (C) 2006 The Android Open Source Project\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdb;\n\nimport android.database.ContentObserver;\nimport android.net.Uri;\nimport android.os.Bundle;\nimport android.os.IBinder;\nimport android.os.RemoteException;\n\n\n/**\n * Wraps a BulkCursor around an existing Cursor making it remotable.\n * <p>\n * If the wrapped cursor returns non-null from {@link CrossProcessCursor#getWindow}\n * then it is assumed to own the window.  Otherwise, the adaptor provides a\n * window to be filled and ensures it gets closed as needed during deactivation\n * and requeries.\n * </p>\n *\n * {@hide}\n */\npublic final class CursorToBulkCursorAdaptor extends BulkCursorNative \n        implements IBinder.DeathRecipient {\n    @SuppressWarnings(\"unused\")\n\tprivate static final String TAG = \"Cursor\";\n\n    private final Object mLock = new Object();\n    private final String mProviderName;\n    private ContentObserverProxy mObserver;\n\n    /**\n     * The cursor that is being adapted.\n     * This field is set to null when the cursor is closed.\n     */\n    private CrossProcessCursor mCursor;\n\n    /**\n     * The cursor window that was filled by the cross process cursor in the\n     * case where the cursor does not support getWindow.\n     * This field is only ever non-null when the window has actually be filled.\n     */\n    private CursorWindow mFilledWindow;\n\n    private static final class ContentObserverProxy extends ContentObserver {\n        protected IContentObserver mRemote;\n\n        public ContentObserverProxy(IContentObserver remoteObserver, DeathRecipient recipient) {\n            super(null);\n            mRemote = remoteObserver;\n            try {\n                remoteObserver.asBinder().linkToDeath(recipient, 0);\n            } catch (RemoteException e) {\n                // Do nothing, the far side is dead\n            }\n        }\n        \n        public boolean unlinkToDeath(DeathRecipient recipient) {\n            return mRemote.asBinder().unlinkToDeath(recipient, 0);\n        }\n\n        @Override\n        public boolean deliverSelfNotifications() {\n            // The far side handles the self notifications.\n            return false;\n        }\n\n        @Override\n        public void onChange(boolean selfChange, Uri uri) {\n            try {\n                mRemote.onChange(selfChange, uri);\n            } catch (RemoteException ex) {\n                // Do nothing, the far side is dead\n            }\n        }\n    }\n\n    public CursorToBulkCursorAdaptor(Cursor cursor, IContentObserver observer,\n            String providerName) {\n        if (cursor instanceof CrossProcessCursor) {\n            mCursor = (CrossProcessCursor)cursor;\n        } else {\n            mCursor = new CrossProcessCursorWrapper(cursor);\n        }\n        mProviderName = providerName;\n\n        synchronized (mLock) {\n            createAndRegisterObserverProxyLocked(observer);\n        }\n    }\n\n    private void closeFilledWindowLocked() {\n        if (mFilledWindow != null) {\n            mFilledWindow.close();\n            mFilledWindow = null;\n        }\n    }\n\n    private void disposeLocked() {\n        if (mCursor != null) {\n            unregisterObserverProxyLocked();\n            mCursor.close();\n            mCursor = null;\n        }\n\n        closeFilledWindowLocked();\n    }\n\n    private void throwIfCursorIsClosed() {\n        if (mCursor == null) {\n            throw new StaleDataException(\"Attempted to access a cursor after it has been closed.\");\n        }\n    }\n\n    @Override\n    public void binderDied() {\n        synchronized (mLock) {\n            disposeLocked();\n        }\n    }\n\n    /**\n     * Returns an object that contains sufficient metadata to reconstruct\n     * the cursor remotely.  May throw if an error occurs when executing the query\n     * and obtaining the row count.\n     */\n    public BulkCursorDescriptor getBulkCursorDescriptor() {\n        synchronized (mLock) {\n            throwIfCursorIsClosed();\n\n            BulkCursorDescriptor d = new BulkCursorDescriptor();\n            d.cursor = this;\n            d.columnNames = mCursor.getColumnNames();\n            d.wantsAllOnMoveCalls = mCursor.getWantsAllOnMoveCalls();\n            d.count = mCursor.getCount();\n            d.window = mCursor.getWindow();\n            if (d.window != null) {\n                // Acquire a reference to the window because its reference count will be\n                // decremented when it is returned as part of the binder call reply parcel.\n                d.window.acquireReference();\n            }\n            return d;\n        }\n    }\n\n    @Override\n    public CursorWindow getWindow(int position) {\n        synchronized (mLock) {\n            throwIfCursorIsClosed();\n\n            if (!mCursor.moveToPosition(position)) {\n                closeFilledWindowLocked();\n                return null;\n            }\n\n            CursorWindow window = mCursor.getWindow();\n            if (window != null) {\n                closeFilledWindowLocked();\n            } else {\n                window = mFilledWindow;\n                if (window == null) {\n                    mFilledWindow = new CursorWindow(mProviderName);\n                    window = mFilledWindow;\n                } else if (position < window.getStartPosition()\n                        || position >= window.getStartPosition() + window.getNumRows()) {\n                    window.clear();\n                }\n                mCursor.fillWindow(position, window);\n            }\n\n            if (window != null) {\n                // Acquire a reference to the window because its reference count will be\n                // decremented when it is returned as part of the binder call reply parcel.\n                window.acquireReference();\n            }\n            return window;\n        }\n    }\n\n    @Override\n    public void onMove(int position) {\n        synchronized (mLock) {\n            throwIfCursorIsClosed();\n\n            mCursor.onMove(mCursor.getPosition(), position);\n        }\n    }\n\n    @SuppressWarnings(\"deprecation\")\n\t@Override\n    public void deactivate() {\n        synchronized (mLock) {\n            if (mCursor != null) {\n                unregisterObserverProxyLocked();\n                mCursor.deactivate();\n            }\n\n            closeFilledWindowLocked();\n        }\n    }\n\n    @Override\n    public void close() {\n        synchronized (mLock) {\n            disposeLocked();\n        }\n    }\n\n    @SuppressWarnings(\"deprecation\")\n\t@Override\n    public int requery(IContentObserver observer) {\n        synchronized (mLock) {\n            throwIfCursorIsClosed();\n\n            closeFilledWindowLocked();\n\n            try {\n                if (!mCursor.requery()) {\n                    return -1;\n                }\n            } catch (IllegalStateException e) {\n                IllegalStateException leakProgram = new IllegalStateException(\n                        mProviderName + \" Requery misuse db, mCursor isClosed:\" +\n                        mCursor.isClosed(), e);\n                throw leakProgram;\n            }\n\n            unregisterObserverProxyLocked();\n            createAndRegisterObserverProxyLocked(observer);\n            return mCursor.getCount();\n        }\n    }\n\n    /**\n     * Create a ContentObserver from the observer and register it as an observer on the\n     * underlying cursor.\n     * @param observer the IContentObserver that wants to monitor the cursor\n     * @throws IllegalStateException if an observer is already registered\n     */\n    private void createAndRegisterObserverProxyLocked(IContentObserver observer) {\n        if (mObserver != null) {\n            throw new IllegalStateException(\"an observer is already registered\");\n        }\n        mObserver = new ContentObserverProxy(observer, this);\n        mCursor.registerContentObserver(mObserver);\n    }\n\n    /** Unregister the observer if it is already registered. */\n    private void unregisterObserverProxyLocked() {\n        if (mObserver != null) {\n            mCursor.unregisterContentObserver(mObserver);\n            mObserver.unlinkToDeath(this);\n            mObserver = null;\n        }\n    }\n\n    @Override\n    public Bundle getExtras() {\n        synchronized (mLock) {\n            throwIfCursorIsClosed();\n\n            return mCursor.getExtras();\n        }\n    }\n\n    @Override\n    public Bundle respond(Bundle extras) {\n        synchronized (mLock) {\n            throwIfCursorIsClosed();\n\n            return mCursor.respond(extras);\n        }\n    }\n}\n"
  },
  {
    "path": "deprecated/android/wcdb/src/com/tencent/wcdb/CursorWindow.aidl",
    "content": "/*\n * Copyright (C) 2013 The Android Open Source Project\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdb;\n\nparcelable CursorWindow;\n"
  },
  {
    "path": "deprecated/android/wcdb/src/com/tencent/wcdb/CursorWindow.java",
    "content": "/*\n * Copyright (C) 2006 The Android Open Source Project\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdb;\n\nimport android.content.res.Resources;\nimport android.database.CharArrayBuffer;\nimport android.os.Parcel;\nimport android.os.Parcelable;\n\nimport com.tencent.wcdb.database.SQLiteClosable;\nimport com.tencent.wcdb.database.SQLiteException;\n\n/**\n * A buffer containing multiple cursor rows.\n * <p>\n * A {@link CursorWindow} is read-write when initially created and used locally.\n * When sent to a remote process (by writing it to a {@link Parcel}), the remote process\n * receives a read-only view of the cursor window.  Typically the cursor window\n * will be allocated by the producer, filled with data, and then sent to the\n * consumer for reading.\n * </p>\n */\npublic class CursorWindow extends SQLiteClosable implements Parcelable {\n    private static final String STATS_TAG = \"WCDB.CursorWindowStats\";\n\n    /** The cursor window size. resource xml file specifies the value in kB.\n     * convert it to bytes here by multiplying with 1024.\n     */\n    private static int sCursorWindowSize;\n    static {\n\t    // com.android.internal.R.integer.config_cursorWindowSize\n\t    int id = Resources.getSystem().getIdentifier(\"config_cursorWindowSize\", \"integer\", \"android\");\n\t    if (id != 0) {\n            sCursorWindowSize = Resources.getSystem().getInteger(id) * 1024;\n        } else {\n            sCursorWindowSize = 2048 * 1024;\n        }\n    }\n\n    /**\n     * Optionally set size for newly created {@code CursorWindow}s and return the old size.\n     *\n     * @param newSize new size to be set, or 0 if keep it unchanged\n     * @return the old size\n     */\n    public static int windowSize(int newSize) {\n        int oldSize = sCursorWindowSize;\n        if (newSize > 0) {\n            sCursorWindowSize = newSize;\n        }\n        return oldSize;\n    }\n\n    /**\n     * The native CursorWindow object pointer.  (FOR INTERNAL USE ONLY)\n     * @hide\n     */\n    public long mWindowPtr;\n\n    private int mStartPos;\n    private final String mName;\n\n    private static native long nativeCreate(String name, int cursorWindowSize);\n    private static native void nativeDispose(long windowPtr);\n\n    private static native void nativeClear(long windowPtr);\n\n    private static native int nativeGetNumRows(long windowPtr);\n    private static native boolean nativeSetNumColumns(long windowPtr, int columnNum);\n    private static native boolean nativeAllocRow(long windowPtr);\n    private static native void nativeFreeLastRow(long windowPtr);\n\n    private static native int nativeGetType(long windowPtr, int row, int column);\n    private static native byte[] nativeGetBlob(long windowPtr, int row, int column);\n    private static native String nativeGetString(long windowPtr, int row, int column);\n    private static native long nativeGetLong(long windowPtr, int row, int column);\n    private static native double nativeGetDouble(long windowPtr, int row, int column);\n    private static native void nativeCopyStringToBuffer(long windowPtr, int row, int column,\n            CharArrayBuffer buffer);\n\n    private static native boolean nativePutBlob(long windowPtr, byte[] value, int row, int column);\n    private static native boolean nativePutString(long windowPtr, String value, int row, int column);\n    private static native boolean nativePutLong(long windowPtr, long value, int row, int column);\n    private static native boolean nativePutDouble(long windowPtr, double value, int row, int column);\n    private static native boolean nativePutNull(long windowPtr, int row, int column);\n\n    /**\n     * Creates a new empty cursor window and gives it a name.\n     * <p>\n     * The cursor initially has no rows or columns.  Call {@link #setNumColumns(int)} to\n     * set the number of columns before adding any rows to the cursor.\n     * </p>\n     *\n     * @param name The name of the cursor window, or null if none.\n     */\n    public CursorWindow(String name) {\n        mStartPos = 0;\n        mName = name != null && name.length() != 0 ? name : \"<unnamed>\";\n        mWindowPtr = nativeCreate(mName, sCursorWindowSize);\n        if (mWindowPtr == 0) {\n            throw new CursorWindowAllocationException(\"Cursor window allocation of \" +\n                    (sCursorWindowSize / 1024) + \" kb failed. \");\n        }\n    }\n\n    /**\n     * Creates a new empty cursor window.\n     * <p>\n     * The cursor initially has no rows or columns.  Call {@link #setNumColumns(int)} to\n     * set the number of columns before adding any rows to the cursor.\n     * </p>\n     *\n     * @param localWindow True if this window will be used in this process only,\n     * false if it might be sent to another processes.  This argument is ignored.\n     *\n     * @deprecated There is no longer a distinction between local and remote\n     * cursor windows.  Use the {@link #CursorWindow(String)} constructor instead.\n     */\n    @Deprecated\n    public CursorWindow(boolean localWindow) {\n        this((String)null);\n    }\n\n    private CursorWindow(Parcel source) {\n        throw new UnsupportedOperationException();\n    }\n\n    @Override\n    protected void finalize() throws Throwable {\n        try {\n            dispose();\n        } finally {\n            super.finalize();\n        }\n    }\n\n    private void dispose() {\n        if (mWindowPtr != 0) {\n            nativeDispose(mWindowPtr);\n            mWindowPtr = 0;\n        }\n    }\n\n    /**\n     * Gets the name of this cursor window, never null.\n     * @hide\n     */\n    public String getName() {\n        return mName;\n    }\n\n    /**\n     * Clears out the existing contents of the window, making it safe to reuse\n     * for new data.\n     * <p>\n     * The start position ({@link #getStartPosition()}), number of rows ({@link #getNumRows()}),\n     * and number of columns in the cursor are all reset to zero.\n     * </p>\n     */\n    public void clear() {\n        acquireReference();\n        try {\n            mStartPos = 0;\n            nativeClear(mWindowPtr);\n        } finally {\n            releaseReference();\n        }\n    }\n\n    /**\n     * Gets the start position of this cursor window.\n     * <p>\n     * The start position is the zero-based index of the first row that this window contains\n     * relative to the entire result set of the {@link Cursor}.\n     * </p>\n     *\n     * @return The zero-based start position.\n     */\n    public int getStartPosition() {\n        return mStartPos;\n    }\n\n    /**\n     * Sets the start position of this cursor window.\n     * <p>\n     * The start position is the zero-based index of the first row that this window contains\n     * relative to the entire result set of the {@link Cursor}.\n     * </p>\n     *\n     * @param pos The new zero-based start position.\n     */\n    public void setStartPosition(int pos) {\n        mStartPos = pos;\n    }\n\n    /**\n     * Gets the number of rows in this window.\n     *\n     * @return The number of rows in this cursor window.\n     */\n    public int getNumRows() {\n        acquireReference();\n        try {\n            return nativeGetNumRows(mWindowPtr);\n        } finally {\n            releaseReference();\n        }\n    }\n\n    /**\n     * Sets the number of columns in this window.\n     * <p>\n     * This method must be called before any rows are added to the window, otherwise\n     * it will fail to set the number of columns if it differs from the current number\n     * of columns.\n     * </p>\n     *\n     * @param columnNum The new number of columns.\n     * @return True if successful.\n     */\n    public boolean setNumColumns(int columnNum) {\n        acquireReference();\n        try {\n            return nativeSetNumColumns(mWindowPtr, columnNum);\n        } finally {\n            releaseReference();\n        }\n    }\n\n    /**\n     * Allocates a new row at the end of this cursor window.\n     *\n     * @return True if successful, false if the cursor window is out of memory.\n     */\n    public boolean allocRow(){\n        acquireReference();\n        try {\n            return nativeAllocRow(mWindowPtr);\n        } finally {\n            releaseReference();\n        }\n    }\n\n    /**\n     * Frees the last row in this cursor window.\n     */\n    public void freeLastRow(){\n        acquireReference();\n        try {\n            nativeFreeLastRow(mWindowPtr);\n        } finally {\n            releaseReference();\n        }\n    }\n\n    /**\n     * Returns true if the field at the specified row and column index\n     * has type {@link Cursor#FIELD_TYPE_NULL}.\n     *\n     * @param row The zero-based row index.\n     * @param column The zero-based column index.\n     * @return True if the field has type {@link Cursor#FIELD_TYPE_NULL}.\n     * @deprecated Use {@link #getType(int, int)} instead.\n     */\n    @Deprecated\n    public boolean isNull(int row, int column) {\n        return getType(row, column) == Cursor.FIELD_TYPE_NULL;\n    }\n\n    /**\n     * Returns true if the field at the specified row and column index\n     * has type {@link Cursor#FIELD_TYPE_BLOB} or {@link Cursor#FIELD_TYPE_NULL}.\n     *\n     * @param row The zero-based row index.\n     * @param column The zero-based column index.\n     * @return True if the field has type {@link Cursor#FIELD_TYPE_BLOB} or\n     * {@link Cursor#FIELD_TYPE_NULL}.\n     * @deprecated Use {@link #getType(int, int)} instead.\n     */\n    @Deprecated\n    public boolean isBlob(int row, int column) {\n        int type = getType(row, column);\n        return type == Cursor.FIELD_TYPE_BLOB || type == Cursor.FIELD_TYPE_NULL;\n    }\n\n    /**\n     * Returns true if the field at the specified row and column index\n     * has type {@link Cursor#FIELD_TYPE_INTEGER}.\n     *\n     * @param row The zero-based row index.\n     * @param column The zero-based column index.\n     * @return True if the field has type {@link Cursor#FIELD_TYPE_INTEGER}.\n     * @deprecated Use {@link #getType(int, int)} instead.\n     */\n    @Deprecated\n    public boolean isLong(int row, int column) {\n        return getType(row, column) == Cursor.FIELD_TYPE_INTEGER;\n    }\n\n    /**\n     * Returns true if the field at the specified row and column index\n     * has type {@link Cursor#FIELD_TYPE_FLOAT}.\n     *\n     * @param row The zero-based row index.\n     * @param column The zero-based column index.\n     * @return True if the field has type {@link Cursor#FIELD_TYPE_FLOAT}.\n     * @deprecated Use {@link #getType(int, int)} instead.\n     */\n    @Deprecated\n    public boolean isFloat(int row, int column) {\n        return getType(row, column) == Cursor.FIELD_TYPE_FLOAT;\n    }\n\n    /**\n     * Returns true if the field at the specified row and column index\n     * has type {@link Cursor#FIELD_TYPE_STRING} or {@link Cursor#FIELD_TYPE_NULL}.\n     *\n     * @param row The zero-based row index.\n     * @param column The zero-based column index.\n     * @return True if the field has type {@link Cursor#FIELD_TYPE_STRING}\n     * or {@link Cursor#FIELD_TYPE_NULL}.\n     * @deprecated Use {@link #getType(int, int)} instead.\n     */\n    @Deprecated\n    public boolean isString(int row, int column) {\n        int type = getType(row, column);\n        return type == Cursor.FIELD_TYPE_STRING || type == Cursor.FIELD_TYPE_NULL;\n    }\n\n    /**\n     * Returns the type of the field at the specified row and column index.\n     * <p>\n     * The returned field types are:\n     * <ul>\n     * <li>{@link Cursor#FIELD_TYPE_NULL}</li>\n     * <li>{@link Cursor#FIELD_TYPE_INTEGER}</li>\n     * <li>{@link Cursor#FIELD_TYPE_FLOAT}</li>\n     * <li>{@link Cursor#FIELD_TYPE_STRING}</li>\n     * <li>{@link Cursor#FIELD_TYPE_BLOB}</li>\n     * </ul>\n     * </p>\n     *\n     * @param row The zero-based row index.\n     * @param column The zero-based column index.\n     * @return The field type.\n     */\n    public int getType(int row, int column) {\n        acquireReference();\n        try {\n            return nativeGetType(mWindowPtr, row - mStartPos, column);\n        } finally {\n            releaseReference();\n        }\n    }\n\n    /**\n     * Gets the value of the field at the specified row and column index as a byte array.\n     * <p>\n     * The result is determined as follows:\n     * <ul>\n     * <li>If the field is of type {@link Cursor#FIELD_TYPE_NULL}, then the result\n     * is <code>null</code>.</li>\n     * <li>If the field is of type {@link Cursor#FIELD_TYPE_BLOB}, then the result\n     * is the blob value.</li>\n     * <li>If the field is of type {@link Cursor#FIELD_TYPE_STRING}, then the result\n     * is the array of bytes that make up the internal representation of the\n     * string value.</li>\n     * <li>If the field is of type {@link Cursor#FIELD_TYPE_INTEGER} or\n     * {@link Cursor#FIELD_TYPE_FLOAT}, then a {@link SQLiteException} is thrown.</li>\n     * </ul>\n     * </p>\n     *\n     * @param row The zero-based row index.\n     * @param column The zero-based column index.\n     * @return The value of the field as a byte array.\n     */\n    public byte[] getBlob(int row, int column) {\n        acquireReference();\n        try {\n            return nativeGetBlob(mWindowPtr, row - mStartPos, column);\n        } finally {\n            releaseReference();\n        }\n    }\n\n    /**\n     * Gets the value of the field at the specified row and column index as a string.\n     * <p>\n     * The result is determined as follows:\n     * <ul>\n     * <li>If the field is of type {@link Cursor#FIELD_TYPE_NULL}, then the result\n     * is <code>null</code>.</li>\n     * <li>If the field is of type {@link Cursor#FIELD_TYPE_STRING}, then the result\n     * is the string value.</li>\n     * <li>If the field is of type {@link Cursor#FIELD_TYPE_INTEGER}, then the result\n     * is a string representation of the integer in decimal, obtained by formatting the\n     * value with the <code>printf</code> family of functions using\n     * format specifier <code>%lld</code>.</li>\n     * <li>If the field is of type {@link Cursor#FIELD_TYPE_FLOAT}, then the result\n     * is a string representation of the floating-point value in decimal, obtained by\n     * formatting the value with the <code>printf</code> family of functions using\n     * format specifier <code>%g</code>.</li>\n     * <li>If the field is of type {@link Cursor#FIELD_TYPE_BLOB}, then a\n     * {@link SQLiteException} is thrown.</li>\n     * </ul>\n     * </p>\n     *\n     * @param row The zero-based row index.\n     * @param column The zero-based column index.\n     * @return The value of the field as a string.\n     */\n    public String getString(int row, int column) {\n        acquireReference();\n        try {\n            return nativeGetString(mWindowPtr, row - mStartPos, column);\n        } finally {\n            releaseReference();\n        }\n    }\n\n    /**\n     * Copies the text of the field at the specified row and column index into\n     * a {@link CharArrayBuffer}.\n     * <p>\n     * The buffer is populated as follows:\n     * <ul>\n     * <li>If the buffer is too small for the value to be copied, then it is\n     * automatically resized.</li>\n     * <li>If the field is of type {@link Cursor#FIELD_TYPE_NULL}, then the buffer\n     * is set to an empty string.</li>\n     * <li>If the field is of type {@link Cursor#FIELD_TYPE_STRING}, then the buffer\n     * is set to the contents of the string.</li>\n     * <li>If the field is of type {@link Cursor#FIELD_TYPE_INTEGER}, then the buffer\n     * is set to a string representation of the integer in decimal, obtained by formatting the\n     * value with the <code>printf</code> family of functions using\n     * format specifier <code>%lld</code>.</li>\n     * <li>If the field is of type {@link Cursor#FIELD_TYPE_FLOAT}, then the buffer is\n     * set to a string representation of the floating-point value in decimal, obtained by\n     * formatting the value with the <code>printf</code> family of functions using\n     * format specifier <code>%g</code>.</li>\n     * <li>If the field is of type {@link Cursor#FIELD_TYPE_BLOB}, then a\n     * {@link SQLiteException} is thrown.</li>\n     * </ul>\n     * </p>\n     *\n     * @param row The zero-based row index.\n     * @param column The zero-based column index.\n     * @param buffer The {@link CharArrayBuffer} to hold the string.  It is automatically\n     * resized if the requested string is larger than the buffer's current capacity.\n      */\n    public void copyStringToBuffer(int row, int column, CharArrayBuffer buffer) {\n        if (buffer == null) {\n            throw new IllegalArgumentException(\"CharArrayBuffer should not be null\");\n        }\n        acquireReference();\n        try {\n            nativeCopyStringToBuffer(mWindowPtr, row - mStartPos, column, buffer);\n        } finally {\n            releaseReference();\n        }\n    }\n\n    /**\n     * Gets the value of the field at the specified row and column index as a <code>long</code>.\n     * <p>\n     * The result is determined as follows:\n     * <ul>\n     * <li>If the field is of type {@link Cursor#FIELD_TYPE_NULL}, then the result\n     * is <code>0L</code>.</li>\n     * <li>If the field is of type {@link Cursor#FIELD_TYPE_STRING}, then the result\n     * is the value obtained by parsing the string value with <code>strtoll</code>.\n     * <li>If the field is of type {@link Cursor#FIELD_TYPE_INTEGER}, then the result\n     * is the <code>long</code> value.</li>\n     * <li>If the field is of type {@link Cursor#FIELD_TYPE_FLOAT}, then the result\n     * is the floating-point value converted to a <code>long</code>.</li>\n     * <li>If the field is of type {@link Cursor#FIELD_TYPE_BLOB}, then a\n     * {@link SQLiteException} is thrown.</li>\n     * </ul>\n     * </p>\n     *\n     * @param row The zero-based row index.\n     * @param column The zero-based column index.\n     * @return The value of the field as a <code>long</code>.\n     */\n    public long getLong(int row, int column) {\n        acquireReference();\n        try {\n            return nativeGetLong(mWindowPtr, row - mStartPos, column);\n        } finally {\n            releaseReference();\n        }\n    }\n\n    /**\n     * Gets the value of the field at the specified row and column index as a\n     * <code>double</code>.\n     * <p>\n     * The result is determined as follows:\n     * <ul>\n     * <li>If the field is of type {@link Cursor#FIELD_TYPE_NULL}, then the result\n     * is <code>0.0</code>.</li>\n     * <li>If the field is of type {@link Cursor#FIELD_TYPE_STRING}, then the result\n     * is the value obtained by parsing the string value with <code>strtod</code>.\n     * <li>If the field is of type {@link Cursor#FIELD_TYPE_INTEGER}, then the result\n     * is the integer value converted to a <code>double</code>.</li>\n     * <li>If the field is of type {@link Cursor#FIELD_TYPE_FLOAT}, then the result\n     * is the <code>double</code> value.</li>\n     * <li>If the field is of type {@link Cursor#FIELD_TYPE_BLOB}, then a\n     * {@link SQLiteException} is thrown.</li>\n     * </ul>\n     * </p>\n     *\n     * @param row The zero-based row index.\n     * @param column The zero-based column index.\n     * @return The value of the field as a <code>double</code>.\n     */\n    public double getDouble(int row, int column) {\n        acquireReference();\n        try {\n            return nativeGetDouble(mWindowPtr, row - mStartPos, column);\n        } finally {\n            releaseReference();\n        }\n    }\n\n    /**\n     * Gets the value of the field at the specified row and column index as a\n     * <code>short</code>.\n     * <p>\n     * The result is determined by invoking {@link #getLong} and converting the\n     * result to <code>short</code>.\n     * </p>\n     *\n     * @param row The zero-based row index.\n     * @param column The zero-based column index.\n     * @return The value of the field as a <code>short</code>.\n     */\n    public short getShort(int row, int column) {\n        return (short) getLong(row, column);\n    }\n\n    /**\n     * Gets the value of the field at the specified row and column index as an\n     * <code>int</code>.\n     * <p>\n     * The result is determined by invoking {@link #getLong} and converting the\n     * result to <code>int</code>.\n     * </p>\n     *\n     * @param row The zero-based row index.\n     * @param column The zero-based column index.\n     * @return The value of the field as an <code>int</code>.\n     */\n    public int getInt(int row, int column) {\n        return (int) getLong(row, column);\n    }\n\n    /**\n     * Gets the value of the field at the specified row and column index as a\n     * <code>float</code>.\n     * <p>\n     * The result is determined by invoking {@link #getDouble} and converting the\n     * result to <code>float</code>.\n     * </p>\n     *\n     * @param row The zero-based row index.\n     * @param column The zero-based column index.\n     * @return The value of the field as an <code>float</code>.\n     */\n    public float getFloat(int row, int column) {\n        return (float) getDouble(row, column);\n    }\n\n    /**\n     * Copies a byte array into the field at the specified row and column index.\n     *\n     * @param value The value to store.\n     * @param row The zero-based row index.\n     * @param column The zero-based column index.\n     * @return True if successful.\n     */\n    public boolean putBlob(byte[] value, int row, int column) {\n        acquireReference();\n        try {\n            return nativePutBlob(mWindowPtr, value, row - mStartPos, column);\n        } finally {\n            releaseReference();\n        }\n    }\n\n    /**\n     * Copies a string into the field at the specified row and column index.\n     *\n     * @param value The value to store.\n     * @param row The zero-based row index.\n     * @param column The zero-based column index.\n     * @return True if successful.\n     */\n    public boolean putString(String value, int row, int column) {\n        acquireReference();\n        try {\n            return nativePutString(mWindowPtr, value, row - mStartPos, column);\n        } finally {\n            releaseReference();\n        }\n    }\n\n    /**\n     * Puts a long integer into the field at the specified row and column index.\n     *\n     * @param value The value to store.\n     * @param row The zero-based row index.\n     * @param column The zero-based column index.\n     * @return True if successful.\n     */\n    public boolean putLong(long value, int row, int column) {\n        acquireReference();\n        try {\n            return nativePutLong(mWindowPtr, value, row - mStartPos, column);\n        } finally {\n            releaseReference();\n        }\n    }\n\n    /**\n     * Puts a double-precision floating point value into the field at the\n     * specified row and column index.\n     *\n     * @param value The value to store.\n     * @param row The zero-based row index.\n     * @param column The zero-based column index.\n     * @return True if successful.\n     */\n    public boolean putDouble(double value, int row, int column) {\n        acquireReference();\n        try {\n            return nativePutDouble(mWindowPtr, value, row - mStartPos, column);\n        } finally {\n            releaseReference();\n        }\n    }\n\n    /**\n     * Puts a null value into the field at the specified row and column index.\n     *\n     * @param row The zero-based row index.\n     * @param column The zero-based column index.\n     * @return True if successful.\n     */\n    public boolean putNull(int row, int column) {\n        acquireReference();\n        try {\n            return nativePutNull(mWindowPtr, row - mStartPos, column);\n        } finally {\n            releaseReference();\n        }\n    }\n\n    public static final Parcelable.Creator<CursorWindow> CREATOR\n            = new Parcelable.Creator<CursorWindow>() {\n        public CursorWindow createFromParcel(Parcel source) {\n            return new CursorWindow(source);\n        }\n\n        public CursorWindow[] newArray(int size) {\n            return new CursorWindow[size];\n        }\n    };\n\n    public static CursorWindow newFromParcel(Parcel p) {\n        return CREATOR.createFromParcel(p);\n    }\n\n    public int describeContents() {\n        return 0;\n    }\n\n    public void writeToParcel(Parcel dest, int flags) {\n        throw new UnsupportedOperationException();\n    }\n\n    @Override\n    protected void onAllReferencesReleased() {\n        dispose();\n    }\n\n    public String toString() {\n        return getName() + \" {\" + Long.toHexString(mWindowPtr) + \"}\";\n    }\n}\n"
  },
  {
    "path": "deprecated/android/wcdb/src/com/tencent/wcdb/CursorWindowAllocationException.java",
    "content": "/*\n * Copyright (C) 2010 The Android Open Source Project\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdb;\n\n/**\n * This exception is thrown when a CursorWindow couldn't be allocated,\n * most probably due to memory not being available.\n *\n * @hide\n */\n@SuppressWarnings(\"serial\")\npublic class CursorWindowAllocationException extends RuntimeException {\n    public CursorWindowAllocationException(String description) {\n        super(description);\n    }\n}\n"
  },
  {
    "path": "deprecated/android/wcdb/src/com/tencent/wcdb/CursorWrapper.java",
    "content": "/*\n * Copyright (C) 2006 The Android Open Source Project\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdb;\n\nimport android.content.ContentResolver;\nimport android.database.CharArrayBuffer;\nimport android.database.ContentObserver;\nimport android.database.DataSetObserver;\nimport android.net.Uri;\nimport android.os.Bundle;\n\n/**\n * Wrapper class for Cursor that delegates all calls to the actual cursor object.  The primary\n * use for this class is to extend a cursor while overriding only a subset of its methods.\n */\npublic class CursorWrapper implements Cursor {\n    /** @hide */\n    protected final Cursor mCursor;\n\n    /**\n     * Creates a cursor wrapper.\n     * @param cursor The underlying cursor to wrap.\n     */\n    public CursorWrapper(Cursor cursor) {\n        mCursor = cursor;\n    }\n\n    /**\n     * Gets the underlying cursor that is wrapped by this instance.\n     *\n     * @return The wrapped cursor.\n     */\n    public Cursor getWrappedCursor() {\n        return mCursor;\n    }\n\n    public void close() {\n        mCursor.close(); \n    }\n \n    public boolean isClosed() {\n        return mCursor.isClosed();\n    }\n\n    public int getCount() {\n        return mCursor.getCount();\n    }\n\n    @SuppressWarnings(\"deprecation\")\n\tpublic void deactivate() {\n        mCursor.deactivate();\n    }\n\n    public boolean moveToFirst() {\n        return mCursor.moveToFirst();\n    }\n\n    public int getColumnCount() {\n        return mCursor.getColumnCount();\n    }\n\n    public int getColumnIndex(String columnName) {\n        return mCursor.getColumnIndex(columnName);\n    }\n\n    public int getColumnIndexOrThrow(String columnName)\n            throws IllegalArgumentException {\n        return mCursor.getColumnIndexOrThrow(columnName);\n    }\n\n    public String getColumnName(int columnIndex) {\n         return mCursor.getColumnName(columnIndex);\n    }\n\n    public String[] getColumnNames() {\n        return mCursor.getColumnNames();\n    }\n\n    public double getDouble(int columnIndex) {\n        return mCursor.getDouble(columnIndex);\n    }\n\n    public Bundle getExtras() {\n        return mCursor.getExtras();\n    }\n\n    public float getFloat(int columnIndex) {\n        return mCursor.getFloat(columnIndex);\n    }\n\n    public int getInt(int columnIndex) {\n        return mCursor.getInt(columnIndex);\n    }\n\n    public long getLong(int columnIndex) {\n        return mCursor.getLong(columnIndex);\n    }\n\n    public short getShort(int columnIndex) {\n        return mCursor.getShort(columnIndex);\n    }\n\n    public String getString(int columnIndex) {\n        return mCursor.getString(columnIndex);\n    }\n    \n    public void copyStringToBuffer(int columnIndex, CharArrayBuffer buffer) {\n        mCursor.copyStringToBuffer(columnIndex, buffer);\n    }\n\n    public byte[] getBlob(int columnIndex) {\n        return mCursor.getBlob(columnIndex);\n    }\n    \n    public boolean getWantsAllOnMoveCalls() {\n        return mCursor.getWantsAllOnMoveCalls();\n    }\n\n    public void setExtras(Bundle extras) {}\n\n    public boolean isAfterLast() {\n        return mCursor.isAfterLast();\n    }\n\n    public boolean isBeforeFirst() {\n        return mCursor.isBeforeFirst();\n    }\n\n    public boolean isFirst() {\n        return mCursor.isFirst();\n    }\n\n    public boolean isLast() {\n        return mCursor.isLast();\n    }\n\n    public int getType(int columnIndex) {\n        return mCursor.getType(columnIndex);\n    }\n\n    public boolean isNull(int columnIndex) {\n        return mCursor.isNull(columnIndex);\n    }\n\n    public boolean moveToLast() {\n        return mCursor.moveToLast();\n    }\n\n    public boolean move(int offset) {\n        return mCursor.move(offset);\n    }\n\n    public boolean moveToPosition(int position) {\n        return mCursor.moveToPosition(position);\n    }\n\n    public boolean moveToNext() {\n        return mCursor.moveToNext();\n    }\n\n    public int getPosition() {\n        return mCursor.getPosition();\n    }\n\n    public boolean moveToPrevious() {\n        return mCursor.moveToPrevious();\n    }\n\n    public void registerContentObserver(ContentObserver observer) {\n        mCursor.registerContentObserver(observer);   \n    }\n\n    public void registerDataSetObserver(DataSetObserver observer) {\n        mCursor.registerDataSetObserver(observer);   \n    }\n\n    @SuppressWarnings(\"deprecation\")\n\tpublic boolean requery() {\n        return mCursor.requery();\n    }\n\n    public Bundle respond(Bundle extras) {\n        return mCursor.respond(extras);\n    }\n\n    public void setNotificationUri(ContentResolver cr, Uri uri) {\n        mCursor.setNotificationUri(cr, uri);        \n    }\n\n    @Override\n    public Uri getNotificationUri() {\n        return null;\n    }\n\n    public void unregisterContentObserver(ContentObserver observer) {\n        mCursor.unregisterContentObserver(observer);        \n    }\n\n    public void unregisterDataSetObserver(DataSetObserver observer) {\n        mCursor.unregisterDataSetObserver(observer);\n    }\n\n}\n\n"
  },
  {
    "path": "deprecated/android/wcdb/src/com/tencent/wcdb/DatabaseErrorHandler.java",
    "content": "/*\n * Copyright (C) 2010 The Android Open Source Project\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdb;\n\nimport com.tencent.wcdb.database.SQLiteDatabase;\n\n/**\n * An interface to let the apps define the actions to take when the following errors are detected\n *   database corruption\n */\npublic interface DatabaseErrorHandler {\n\n    /**\n     * defines the method to be invoked when database corruption is detected.\n     * @param dbObj the {@link SQLiteDatabase} object representing the database on which corruption\n     * is detected.\n     */\n    void onCorruption(SQLiteDatabase dbObj);\n}\n"
  },
  {
    "path": "deprecated/android/wcdb/src/com/tencent/wcdb/DatabaseUtils.java",
    "content": "/*\n * Copyright (C) 2006 The Android Open Source Project\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdb;\n\nimport com.tencent.wcdb.database.SQLiteAbortException;\nimport com.tencent.wcdb.database.SQLiteCipherSpec;\nimport com.tencent.wcdb.database.SQLiteConstraintException;\nimport com.tencent.wcdb.database.SQLiteDatabase;\nimport com.tencent.wcdb.database.SQLiteDatabaseCorruptException;\nimport com.tencent.wcdb.database.SQLiteDiskIOException;\nimport com.tencent.wcdb.database.SQLiteException;\nimport com.tencent.wcdb.database.SQLiteFullException;\nimport com.tencent.wcdb.database.SQLiteProgram;\nimport com.tencent.wcdb.database.SQLiteStatement;\nimport com.tencent.wcdb.support.Context;\nimport com.tencent.wcdb.support.OperationCanceledException;\n\nimport android.content.ContentValues;\nimport android.content.OperationApplicationException;\nimport android.os.Parcel;\nimport android.text.TextUtils;\n\nimport com.tencent.wcdb.support.Log;\n\nimport java.io.FileNotFoundException;\nimport java.io.PrintStream;\nimport java.text.Collator;\nimport java.util.HashMap;\nimport java.util.Locale;\nimport java.util.Map;\n\n/**\n * Static utility methods for dealing with databases and {@link Cursor}s.\n */\npublic final class DatabaseUtils {\n    private static final String TAG = \"WCDB.DatabaseUtils\";\n\n    private static final boolean DEBUG = false;\n\n    /** One of the values returned by {@link #getSqlStatementType(String)}. */\n    public static final int STATEMENT_SELECT = 1;\n    /** One of the values returned by {@link #getSqlStatementType(String)}. */\n    public static final int STATEMENT_UPDATE = 2;\n    /** One of the values returned by {@link #getSqlStatementType(String)}. */\n    public static final int STATEMENT_ATTACH = 3;\n    /** One of the values returned by {@link #getSqlStatementType(String)}. */\n    public static final int STATEMENT_BEGIN = 4;\n    /** One of the values returned by {@link #getSqlStatementType(String)}. */\n    public static final int STATEMENT_COMMIT = 5;\n    /** One of the values returned by {@link #getSqlStatementType(String)}. */\n    public static final int STATEMENT_ABORT = 6;\n    /** One of the values returned by {@link #getSqlStatementType(String)}. */\n    public static final int STATEMENT_PRAGMA = 7;\n    /** One of the values returned by {@link #getSqlStatementType(String)}. */\n    public static final int STATEMENT_DDL = 8;\n    /** One of the values returned by {@link #getSqlStatementType(String)}. */\n    public static final int STATEMENT_UNPREPARED = 9;\n    /** One of the values returned by {@link #getSqlStatementType(String)}. */\n    public static final int STATEMENT_OTHER = 99;\n\n    /**\n     * Returns {@code true} if the arguments are equal to each other\n     * and {@code false} otherwise.\n     * Consequently, if both arguments are {@code null}, {@code true}\n     * is returned and if exactly one argument is {@code null}, {@code\n     * false} is returned.  Otherwise, equality is determined by using\n     * the {@link Object#equals equals} method of the first\n     * argument.\n     *\n     * @param a an object\n     * @param b an object to be compared with {@code a} for equality\n     * @return {@code true} if the arguments are equal to each other\n     * and {@code false} otherwise\n     * @see Object#equals(Object)\n     */\n    public static boolean objectEquals(Object a, Object b) {\n        return (a == b) || (a != null && a.equals(b));\n    }\n\n    /**\n     * Special function for writing an exception result at the header of\n     * a parcel, to be used when returning an exception from a transaction.\n     * exception will be re-thrown by the function in another process\n     *\n     * @param reply Parcel to write to\n     * @param e     The Exception to be written.\n     * @see Parcel#writeNoException\n     * @see Parcel#writeException\n     */\n    public static final void writeExceptionToParcel(Parcel reply, Exception e) {\n        int code = 0;\n        boolean logException = true;\n        if (e instanceof FileNotFoundException) {\n            code = 1;\n            logException = false;\n        } else if (e instanceof IllegalArgumentException) {\n            code = 2;\n        } else if (e instanceof UnsupportedOperationException) {\n            code = 3;\n        } else if (e instanceof SQLiteAbortException) {\n            code = 4;\n        } else if (e instanceof SQLiteConstraintException) {\n            code = 5;\n        } else if (e instanceof SQLiteDatabaseCorruptException) {\n            code = 6;\n        } else if (e instanceof SQLiteFullException) {\n            code = 7;\n        } else if (e instanceof SQLiteDiskIOException) {\n            code = 8;\n        } else if (e instanceof SQLiteException) {\n            code = 9;\n        } else if (e instanceof OperationApplicationException) {\n            code = 10;\n        } else if (e instanceof OperationCanceledException) {\n            code = 11;\n            logException = false;\n        } else {\n            reply.writeException(e);\n            Log.e(TAG, \"Writing exception to parcel\", e);\n            return;\n        }\n        reply.writeInt(code);\n        reply.writeString(e.getMessage());\n\n        if (logException) {\n            Log.e(TAG, \"Writing exception to parcel\", e);\n        }\n    }\n\n    private static final int EX_HAS_REPLY_HEADER = -128;  // special; see below\n\n    private static final int readExceptionCode(Parcel reply) {\n        int code = reply.readInt();\n        if (code == EX_HAS_REPLY_HEADER) {\n            int headerSize = reply.readInt();\n            if (headerSize == 0) {\n                Log.e(TAG, \"Unexpected zero-sized Parcel reply header.\");\n            }\n            // And fat response headers are currently only used when\n            // there are no exceptions, so return no error:\n            return 0;\n        }\n        return code;\n    }\n\n    /**\n     * Special function for reading an exception result from the header of\n     * a parcel, to be used after receiving the result of a transaction.  This\n     * will throw the exception for you if it had been written to the Parcel,\n     * otherwise return and let you read the normal result data from the Parcel.\n     *\n     * @param reply Parcel to read from\n     * @see Parcel#writeNoException\n     * @see Parcel#readException\n     */\n    public static final void readExceptionFromParcel(Parcel reply) {\n        int code = readExceptionCode(reply);\n        if (code == 0) return;\n        String msg = reply.readString();\n        DatabaseUtils.readExceptionFromParcel(reply, msg, code);\n    }\n\n    public static void readExceptionWithFileNotFoundExceptionFromParcel(\n            Parcel reply) throws FileNotFoundException {\n        int code = readExceptionCode(reply);\n        if (code == 0) return;\n        String msg = reply.readString();\n        if (code == 1) {\n            throw new FileNotFoundException(msg);\n        } else {\n            DatabaseUtils.readExceptionFromParcel(reply, msg, code);\n        }\n    }\n\n    public static void readExceptionWithOperationApplicationExceptionFromParcel(\n            Parcel reply) throws OperationApplicationException {\n        int code = readExceptionCode(reply);\n        if (code == 0) return;\n        String msg = reply.readString();\n        if (code == 10) {\n            throw new OperationApplicationException(msg);\n        } else {\n            DatabaseUtils.readExceptionFromParcel(reply, msg, code);\n        }\n    }\n\n    private static final void readExceptionFromParcel(Parcel reply, String msg, int code) {\n        switch (code) {\n            case 2:\n                throw new IllegalArgumentException(msg);\n            case 3:\n                throw new UnsupportedOperationException(msg);\n            case 4:\n                throw new SQLiteAbortException(msg);\n            case 5:\n                throw new SQLiteConstraintException(msg);\n            case 6:\n                throw new SQLiteDatabaseCorruptException(msg);\n            case 7:\n                throw new SQLiteFullException(msg);\n            case 8:\n                throw new SQLiteDiskIOException(msg);\n            case 9:\n                throw new SQLiteException(msg);\n            case 11:\n                throw new OperationCanceledException(msg);\n            default:\n                reply.readException(code, msg);\n        }\n    }\n\n    /**\n     * Binds the given Object to the given SQLiteProgram using the proper\n     * typing. For example, bind numbers as longs/doubles, and everything else\n     * as a string by call toString() on it.\n     *\n     * @param prog  the program to bind the object to\n     * @param index the 1-based index to bind at\n     * @param value the value to bind\n     */\n    public static void bindObjectToProgram(SQLiteProgram prog, int index,\n            Object value) {\n        if (value == null) {\n            prog.bindNull(index);\n        } else if (value instanceof Double || value instanceof Float) {\n            prog.bindDouble(index, ((Number) value).doubleValue());\n        } else if (value instanceof Number) {\n            prog.bindLong(index, ((Number) value).longValue());\n        } else if (value instanceof Boolean) {\n            Boolean bool = (Boolean) value;\n            if (bool) {\n                prog.bindLong(index, 1);\n            } else {\n                prog.bindLong(index, 0);\n            }\n        } else if (value instanceof byte[]) {\n            prog.bindBlob(index, (byte[]) value);\n        } else {\n            prog.bindString(index, value.toString());\n        }\n    }\n\n    /**\n     * Returns data type of the given object's value.\n     * <p>\n     * Returned values are\n     * <ul>\n     * <li>{@link Cursor#FIELD_TYPE_NULL}</li>\n     * <li>{@link Cursor#FIELD_TYPE_INTEGER}</li>\n     * <li>{@link Cursor#FIELD_TYPE_FLOAT}</li>\n     * <li>{@link Cursor#FIELD_TYPE_STRING}</li>\n     * <li>{@link Cursor#FIELD_TYPE_BLOB}</li>\n     * </ul>\n     * </p>\n     *\n     * @param obj the object whose value type is to be returned\n     * @return object value type\n     * @hide\n     */\n    public static int getTypeOfObject(Object obj) {\n        if (obj == null) {\n            return Cursor.FIELD_TYPE_NULL;\n        } else if (obj instanceof byte[]) {\n            return Cursor.FIELD_TYPE_BLOB;\n        } else if (obj instanceof Float || obj instanceof Double) {\n            return Cursor.FIELD_TYPE_FLOAT;\n        } else if (obj instanceof Long || obj instanceof Integer\n                || obj instanceof Short || obj instanceof Byte) {\n            return Cursor.FIELD_TYPE_INTEGER;\n        } else {\n            return Cursor.FIELD_TYPE_STRING;\n        }\n    }\n\n    /**\n     * Fills the specified cursor window by iterating over the contents of the cursor.\n     * The window is filled until the cursor is exhausted or the window runs out\n     * of space.\n     * <p/>\n     * The original position of the cursor is left unchanged by this operation.\n     *\n     * @param cursor   The cursor that contains the data to put in the window.\n     * @param position The start position for filling the window.\n     * @param window   The window to fill.\n     * @hide\n     */\n    public static void cursorFillWindow(final Cursor cursor,\n            int position, final CursorWindow window) {\n        if (position < 0 || position >= cursor.getCount()) {\n            return;\n        }\n        final int oldPos = cursor.getPosition();\n        final int numColumns = cursor.getColumnCount();\n        window.clear();\n        window.setStartPosition(position);\n        window.setNumColumns(numColumns);\n        if (cursor.moveToPosition(position)) {\n            do {\n                if (!window.allocRow()) {\n                    break;\n                }\n                for (int i = 0; i < numColumns; i++) {\n                    final int type = cursor.getType(i);\n                    final boolean success;\n                    switch (type) {\n                        case Cursor.FIELD_TYPE_NULL:\n                            success = window.putNull(position, i);\n                            break;\n\n                        case Cursor.FIELD_TYPE_INTEGER:\n                            success = window.putLong(cursor.getLong(i), position, i);\n                            break;\n\n                        case Cursor.FIELD_TYPE_FLOAT:\n                            success = window.putDouble(cursor.getDouble(i), position, i);\n                            break;\n\n                        case Cursor.FIELD_TYPE_BLOB: {\n                            final byte[] value = cursor.getBlob(i);\n                            success = value != null ? window.putBlob(value, position, i)\n                                    : window.putNull(position, i);\n                            break;\n                        }\n\n                        default: // assume value is convertible to String\n                        case Cursor.FIELD_TYPE_STRING: {\n                            final String value = cursor.getString(i);\n                            success = value != null ? window.putString(value, position, i)\n                                    : window.putNull(position, i);\n                            break;\n                        }\n                    }\n                    if (!success) {\n                        window.freeLastRow();\n                        break;\n                    }\n                }\n                position += 1;\n            } while (cursor.moveToNext());\n        }\n        cursor.moveToPosition(oldPos);\n    }\n\n    /**\n     * Appends an SQL string to the given StringBuilder, including the opening\n     * and closing single quotes. Any single quotes internal to sqlString will\n     * be escaped.\n     * <p/>\n     * This method is deprecated because we want to encourage everyone\n     * to use the \"?\" binding form.  However, when implementing a\n     * ContentProvider, one may want to add WHERE clauses that were\n     * not provided by the caller.  Since \"?\" is a positional form,\n     * using it in this case could break the caller because the\n     * indexes would be shifted to accomodate the ContentProvider's\n     * internal bindings.  In that case, it may be necessary to\n     * construct a WHERE clause manually.  This method is useful for\n     * those cases.\n     *\n     * @param sb        the StringBuilder that the SQL string will be appended to\n     * @param sqlString the raw string to be appended, which may contain single\n     *                  quotes\n     */\n    public static void appendEscapedSQLString(StringBuilder sb, String sqlString) {\n        sb.append('\\'');\n        if (sqlString.indexOf('\\'') != -1) {\n            int length = sqlString.length();\n            for (int i = 0; i < length; i++) {\n                char c = sqlString.charAt(i);\n                if (c == '\\'') {\n                    sb.append('\\'');\n                }\n                sb.append(c);\n            }\n        } else\n            sb.append(sqlString);\n        sb.append('\\'');\n    }\n\n    /**\n     * SQL-escape a string.\n     */\n    public static String sqlEscapeString(String value) {\n        StringBuilder escaper = new StringBuilder();\n\n        DatabaseUtils.appendEscapedSQLString(escaper, value);\n\n        return escaper.toString();\n    }\n\n    /**\n     * Appends an Object to an SQL string with the proper escaping, etc.\n     */\n    public static final void appendValueToSql(StringBuilder sql, Object value) {\n        if (value == null) {\n            sql.append(\"NULL\");\n        } else if (value instanceof Boolean) {\n            Boolean bool = (Boolean) value;\n            if (bool) {\n                sql.append('1');\n            } else {\n                sql.append('0');\n            }\n        } else {\n            appendEscapedSQLString(sql, value.toString());\n        }\n    }\n\n    /**\n     * Concatenates two SQL WHERE clauses, handling empty or null values.\n     */\n    public static String concatenateWhere(String a, String b) {\n        if (TextUtils.isEmpty(a)) {\n            return b;\n        }\n        if (TextUtils.isEmpty(b)) {\n            return a;\n        }\n\n        return \"(\" + a + \") AND (\" + b + \")\";\n    }\n\n    /**\n     * return the collation key\n     *\n     * @param name\n     * @return the collation key\n     */\n    public static String getCollationKey(String name) {\n        byte[] arr = getCollationKeyInBytes(name);\n        try {\n            return new String(arr, 0, getKeyLen(arr), \"ISO8859_1\");\n        } catch (Exception ex) {\n            return \"\";\n        }\n    }\n\n    private static final char[] DIGITS = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'};\n\n    private static char[] encodeHex(byte[] data) {\n        int l = data.length;\n\n        char[] out = new char[l << 1];\n\n        int i = 0; for (int j = 0; i < l; i++) {\n            out[(j++)] = DIGITS[((0xF0 & data[i]) >>> 4)];\n            out[(j++)] = DIGITS[(0xF & data[i])];\n        }\n\n        return out;\n    }\n\n    /**\n     * return the collation key in hex format\n     *\n     * @param name\n     * @return the collation key in hex format\n     */\n    public static String getHexCollationKey(String name) {\n        byte[] arr = getCollationKeyInBytes(name);\n        char[] keys = encodeHex(arr);\n        return new String(keys, 0, getKeyLen(arr) * 2);\n    }\n\n    private static int getKeyLen(byte[] arr) {\n        if (arr[arr.length - 1] != 0) {\n            return arr.length;\n        } else {\n            // remove zero \"termination\"\n            return arr.length - 1;\n        }\n    }\n\n    private static byte[] getCollationKeyInBytes(String name) {\n        if (mColl == null) {\n            mColl = Collator.getInstance();\n            mColl.setStrength(Collator.PRIMARY);\n        }\n        return mColl.getCollationKey(name).toByteArray();\n    }\n\n    private static Collator mColl = null;\n\n    /**\n     * Prints the contents of a Cursor to System.out. The position is restored\n     * after printing.\n     *\n     * @param cursor the cursor to print\n     */\n    public static void dumpCursor(Cursor cursor) {\n        dumpCursor(cursor, System.out);\n    }\n\n    /**\n     * Prints the contents of a Cursor to a PrintSteam. The position is restored\n     * after printing.\n     *\n     * @param cursor the cursor to print\n     * @param stream the stream to print to\n     */\n    public static void dumpCursor(Cursor cursor, PrintStream stream) {\n        stream.println(\">>>>> Dumping cursor \" + cursor);\n        if (cursor != null) {\n            int startPos = cursor.getPosition();\n\n            cursor.moveToPosition(-1);\n            while (cursor.moveToNext()) {\n                dumpCurrentRow(cursor, stream);\n            }\n            cursor.moveToPosition(startPos);\n        }\n        stream.println(\"<<<<<\");\n    }\n\n    /**\n     * Prints the contents of a Cursor to a StringBuilder. The position\n     * is restored after printing.\n     *\n     * @param cursor the cursor to print\n     * @param sb     the StringBuilder to print to\n     */\n    public static void dumpCursor(Cursor cursor, StringBuilder sb) {\n        sb.append(\">>>>> Dumping cursor \" + cursor + \"\\n\");\n        if (cursor != null) {\n            int startPos = cursor.getPosition();\n\n            cursor.moveToPosition(-1);\n            while (cursor.moveToNext()) {\n                dumpCurrentRow(cursor, sb);\n            }\n            cursor.moveToPosition(startPos);\n        }\n        sb.append(\"<<<<<\\n\");\n    }\n\n    /**\n     * Prints the contents of a Cursor to a String. The position is restored\n     * after printing.\n     *\n     * @param cursor the cursor to print\n     * @return a String that contains the dumped cursor\n     */\n    public static String dumpCursorToString(Cursor cursor) {\n        StringBuilder sb = new StringBuilder();\n        dumpCursor(cursor, sb);\n        return sb.toString();\n    }\n\n    /**\n     * Prints the contents of a Cursor's current row to System.out.\n     *\n     * @param cursor the cursor to print from\n     */\n    public static void dumpCurrentRow(Cursor cursor) {\n        dumpCurrentRow(cursor, System.out);\n    }\n\n    /**\n     * Prints the contents of a Cursor's current row to a PrintSteam.\n     *\n     * @param cursor the cursor to print\n     * @param stream the stream to print to\n     */\n    public static void dumpCurrentRow(Cursor cursor, PrintStream stream) {\n        String[] cols = cursor.getColumnNames();\n        stream.println(\"\" + cursor.getPosition() + \" {\");\n        int length = cols.length;\n        for (int i = 0; i < length; i++) {\n            String value;\n            try {\n                value = cursor.getString(i);\n            } catch (SQLiteException e) {\n                // assume that if the getString threw this exception then the column is not\n                // representable by a string, e.g. it is a BLOB.\n                value = \"<unprintable>\";\n            }\n            stream.println(\"   \" + cols[i] + '=' + value);\n        }\n        stream.println(\"}\");\n    }\n\n    /**\n     * Prints the contents of a Cursor's current row to a StringBuilder.\n     *\n     * @param cursor the cursor to print\n     * @param sb     the StringBuilder to print to\n     */\n    public static void dumpCurrentRow(Cursor cursor, StringBuilder sb) {\n        String[] cols = cursor.getColumnNames();\n        sb.append(\"\" + cursor.getPosition() + \" {\\n\");\n        int length = cols.length;\n        for (int i = 0; i < length; i++) {\n            String value;\n            try {\n                value = cursor.getString(i);\n            } catch (SQLiteException e) {\n                // assume that if the getString threw this exception then the column is not\n                // representable by a string, e.g. it is a BLOB.\n                value = \"<unprintable>\";\n            }\n            sb.append(\"   \" + cols[i] + '=' + value + \"\\n\");\n        }\n        sb.append(\"}\\n\");\n    }\n\n    /**\n     * Dump the contents of a Cursor's current row to a String.\n     *\n     * @param cursor the cursor to print\n     * @return a String that contains the dumped cursor row\n     */\n    public static String dumpCurrentRowToString(Cursor cursor) {\n        StringBuilder sb = new StringBuilder();\n        dumpCurrentRow(cursor, sb);\n        return sb.toString();\n    }\n\n    /**\n     * Reads a String out of a field in a Cursor and writes it to a Map.\n     *\n     * @param cursor The cursor to read from\n     * @param field  The TEXT field to read\n     * @param values The {@link ContentValues} to put the value into, with the field as the key\n     */\n    public static void cursorStringToContentValues(Cursor cursor, String field,\n            ContentValues values) {\n        cursorStringToContentValues(cursor, field, values, field);\n    }\n\n    /**\n     * Reads a String out of a field in a Cursor and writes it to an InsertHelper.\n     *\n     * @param cursor   The cursor to read from\n     * @param field    The TEXT field to read\n     * @param inserter The InsertHelper to bind into\n     * @param index    the index of the bind entry in the InsertHelper\n     */\n    public static void cursorStringToInsertHelper(Cursor cursor, String field,\n            InsertHelper inserter, int index) {\n        inserter.bind(index, cursor.getString(cursor.getColumnIndexOrThrow(field)));\n    }\n\n    /**\n     * Reads a String out of a field in a Cursor and writes it to a Map.\n     *\n     * @param cursor The cursor to read from\n     * @param field  The TEXT field to read\n     * @param values The {@link ContentValues} to put the value into, with the field as the key\n     * @param key    The key to store the value with in the map\n     */\n    public static void cursorStringToContentValues(Cursor cursor, String field,\n            ContentValues values, String key) {\n        values.put(key, cursor.getString(cursor.getColumnIndexOrThrow(field)));\n    }\n\n    /**\n     * Reads an Integer out of a field in a Cursor and writes it to a Map.\n     *\n     * @param cursor The cursor to read from\n     * @param field  The INTEGER field to read\n     * @param values The {@link ContentValues} to put the value into, with the field as the key\n     */\n    public static void cursorIntToContentValues(Cursor cursor, String field, ContentValues values) {\n        cursorIntToContentValues(cursor, field, values, field);\n    }\n\n    /**\n     * Reads a Integer out of a field in a Cursor and writes it to a Map.\n     *\n     * @param cursor The cursor to read from\n     * @param field  The INTEGER field to read\n     * @param values The {@link ContentValues} to put the value into, with the field as the key\n     * @param key    The key to store the value with in the map\n     */\n    public static void cursorIntToContentValues(Cursor cursor, String field, ContentValues values,\n            String key) {\n        int colIndex = cursor.getColumnIndex(field);\n        if (!cursor.isNull(colIndex)) {\n            values.put(key, cursor.getInt(colIndex));\n        } else {\n            values.put(key, (Integer) null);\n        }\n    }\n\n    /**\n     * Reads a Long out of a field in a Cursor and writes it to a Map.\n     *\n     * @param cursor The cursor to read from\n     * @param field  The INTEGER field to read\n     * @param values The {@link ContentValues} to put the value into, with the field as the key\n     */\n    public static void cursorLongToContentValues(Cursor cursor, String field, ContentValues values) {\n        cursorLongToContentValues(cursor, field, values, field);\n    }\n\n    /**\n     * Reads a Long out of a field in a Cursor and writes it to a Map.\n     *\n     * @param cursor The cursor to read from\n     * @param field  The INTEGER field to read\n     * @param values The {@link ContentValues} to put the value into\n     * @param key    The key to store the value with in the map\n     */\n    public static void cursorLongToContentValues(Cursor cursor, String field, ContentValues values,\n            String key) {\n        int colIndex = cursor.getColumnIndex(field);\n        if (!cursor.isNull(colIndex)) {\n            Long value = Long.valueOf(cursor.getLong(colIndex));\n            values.put(key, value);\n        } else {\n            values.put(key, (Long) null);\n        }\n    }\n\n    /**\n     * Reads a Double out of a field in a Cursor and writes it to a Map.\n     *\n     * @param cursor The cursor to read from\n     * @param field  The REAL field to read\n     * @param values The {@link ContentValues} to put the value into\n     */\n    public static void cursorDoubleToCursorValues(Cursor cursor, String field, ContentValues values) {\n        cursorDoubleToContentValues(cursor, field, values, field);\n    }\n\n    /**\n     * Reads a Double out of a field in a Cursor and writes it to a Map.\n     *\n     * @param cursor The cursor to read from\n     * @param field  The REAL field to read\n     * @param values The {@link ContentValues} to put the value into\n     * @param key    The key to store the value with in the map\n     */\n    public static void cursorDoubleToContentValues(Cursor cursor, String field,\n            ContentValues values, String key) {\n        int colIndex = cursor.getColumnIndex(field);\n        if (!cursor.isNull(colIndex)) {\n            values.put(key, cursor.getDouble(colIndex));\n        } else {\n            values.put(key, (Double) null);\n        }\n    }\n\n    /**\n     * Read the entire contents of a cursor row and store them in a ContentValues.\n     *\n     * @param cursor the cursor to read from.\n     * @param values the {@link ContentValues} to put the row into.\n     */\n    @SuppressWarnings(\"deprecation\")\n    public static void cursorRowToContentValues(Cursor cursor, ContentValues values) {\n        AbstractWindowedCursor awc =\n                (cursor instanceof AbstractWindowedCursor) ? (AbstractWindowedCursor) cursor : null;\n\n        String[] columns = cursor.getColumnNames();\n        int length = columns.length;\n        for (int i = 0; i < length; i++) {\n            if (awc != null && awc.isBlob(i)) {\n                values.put(columns[i], cursor.getBlob(i));\n            } else {\n                values.put(columns[i], cursor.getString(i));\n            }\n        }\n    }\n\n    /**\n     * Picks a start position for {@link Cursor#fillWindow} such that the\n     * window will contain the requested row and a useful range of rows\n     * around it.\n     * <p/>\n     * When the data set is too large to fit in a cursor window, seeking the\n     * cursor can become a very expensive operation since we have to run the\n     * query again when we move outside the bounds of the current window.\n     * <p/>\n     * We try to choose a start position for the cursor window such that\n     * 1/3 of the window's capacity is used to hold rows before the requested\n     * position and 2/3 of the window's capacity is used to hold rows after the\n     * requested position.\n     *\n     * @param cursorPosition       The row index of the row we want to get.\n     * @param cursorWindowCapacity The estimated number of rows that can fit in\n     *                             a cursor window, or 0 if unknown.\n     * @return The recommended start position, always less than or equal to\n     * the requested row.\n     * @hide\n     */\n    public static int cursorPickFillWindowStartPosition(\n            int cursorPosition, int cursorWindowCapacity) {\n        return Math.max(cursorPosition - cursorWindowCapacity / 3, 0);\n    }\n\n    /**\n     * Query the table for the number of rows in the table.\n     *\n     * @param db    the database the table is in\n     * @param table the name of the table to query\n     * @return the number of rows in the table\n     */\n    public static long queryNumEntries(SQLiteDatabase db, String table) {\n        return queryNumEntries(db, table, null, null);\n    }\n\n    /**\n     * Query the table for the number of rows in the table.\n     *\n     * @param db        the database the table is in\n     * @param table     the name of the table to query\n     * @param selection A filter declaring which rows to return,\n     *                  formatted as an SQL WHERE clause (excluding the WHERE itself).\n     *                  Passing null will count all rows for the given table\n     * @return the number of rows in the table filtered by the selection\n     */\n    public static long queryNumEntries(SQLiteDatabase db, String table, String selection) {\n        return queryNumEntries(db, table, selection, null);\n    }\n\n    /**\n     * Query the table for the number of rows in the table.\n     *\n     * @param db            the database the table is in\n     * @param table         the name of the table to query\n     * @param selection     A filter declaring which rows to return,\n     *                      formatted as an SQL WHERE clause (excluding the WHERE itself).\n     *                      Passing null will count all rows for the given table\n     * @param selectionArgs You may include ?s in selection,\n     *                      which will be replaced by the values from selectionArgs,\n     *                      in order that they appear in the selection.\n     *                      The values will be bound as Strings.\n     * @return the number of rows in the table filtered by the selection\n     */\n    public static long queryNumEntries(SQLiteDatabase db, String table, String selection,\n            String[] selectionArgs) {\n        String s = (!TextUtils.isEmpty(selection)) ? \" where \" + selection : \"\";\n        return longForQuery(db, \"select count(*) from \" + table + s,\n                selectionArgs);\n    }\n\n    /**\n     * Query the table to check whether a table is empty or not\n     *\n     * @param db    the database the table is in\n     * @param table the name of the table to query\n     * @return True if the table is empty\n     * @hide\n     */\n    public static boolean queryIsEmpty(SQLiteDatabase db, String table) {\n        long isEmpty = longForQuery(db, \"select exists(select 1 from \" + table + \")\", null);\n        return isEmpty == 0;\n    }\n\n    /**\n     * Utility method to run the query on the db and return the value in the\n     * first column of the first row.\n     */\n    public static long longForQuery(SQLiteDatabase db, String query, String[] selectionArgs) {\n        SQLiteStatement prog = db.compileStatement(query);\n        try {\n            return longForQuery(prog, selectionArgs);\n        } finally {\n            prog.close();\n        }\n    }\n\n    /**\n     * Utility method to run the pre-compiled query and return the value in the\n     * first column of the first row.\n     */\n    public static long longForQuery(SQLiteStatement prog, String[] selectionArgs) {\n        prog.bindAllArgsAsStrings(selectionArgs);\n        return prog.simpleQueryForLong();\n    }\n\n    /**\n     * Utility method to run the query on the db and return the value in the\n     * first column of the first row.\n     */\n    public static String stringForQuery(SQLiteDatabase db, String query, String[] selectionArgs) {\n        SQLiteStatement prog = db.compileStatement(query);\n        try {\n            return stringForQuery(prog, selectionArgs);\n        } finally {\n            prog.close();\n        }\n    }\n\n    /**\n     * Utility method to run the pre-compiled query and return the value in the\n     * first column of the first row.\n     */\n    public static String stringForQuery(SQLiteStatement prog, String[] selectionArgs) {\n        prog.bindAllArgsAsStrings(selectionArgs);\n        return prog.simpleQueryForString();\n    }\n\n    /**\n     * Reads a String out of a column in a Cursor and writes it to a ContentValues.\n     * Adds nothing to the ContentValues if the column isn't present or if its value is null.\n     *\n     * @param cursor The cursor to read from\n     * @param column The column to read\n     * @param values The {@link ContentValues} to put the value into\n     */\n    public static void cursorStringToContentValuesIfPresent(Cursor cursor, ContentValues values,\n            String column) {\n        final int index = cursor.getColumnIndex(column);\n        if (index != -1 && !cursor.isNull(index)) {\n            values.put(column, cursor.getString(index));\n        }\n    }\n\n    /**\n     * Reads a Long out of a column in a Cursor and writes it to a ContentValues.\n     * Adds nothing to the ContentValues if the column isn't present or if its value is null.\n     *\n     * @param cursor The cursor to read from\n     * @param column The column to read\n     * @param values The {@link ContentValues} to put the value into\n     */\n    public static void cursorLongToContentValuesIfPresent(Cursor cursor, ContentValues values,\n            String column) {\n        final int index = cursor.getColumnIndex(column);\n        if (index != -1 && !cursor.isNull(index)) {\n            values.put(column, cursor.getLong(index));\n        }\n    }\n\n    /**\n     * Reads a Short out of a column in a Cursor and writes it to a ContentValues.\n     * Adds nothing to the ContentValues if the column isn't present or if its value is null.\n     *\n     * @param cursor The cursor to read from\n     * @param column The column to read\n     * @param values The {@link ContentValues} to put the value into\n     */\n    public static void cursorShortToContentValuesIfPresent(Cursor cursor, ContentValues values,\n            String column) {\n        final int index = cursor.getColumnIndex(column);\n        if (index != -1 && !cursor.isNull(index)) {\n            values.put(column, cursor.getShort(index));\n        }\n    }\n\n    /**\n     * Reads a Integer out of a column in a Cursor and writes it to a ContentValues.\n     * Adds nothing to the ContentValues if the column isn't present or if its value is null.\n     *\n     * @param cursor The cursor to read from\n     * @param column The column to read\n     * @param values The {@link ContentValues} to put the value into\n     */\n    public static void cursorIntToContentValuesIfPresent(Cursor cursor, ContentValues values,\n            String column) {\n        final int index = cursor.getColumnIndex(column);\n        if (index != -1 && !cursor.isNull(index)) {\n            values.put(column, cursor.getInt(index));\n        }\n    }\n\n    /**\n     * Reads a Float out of a column in a Cursor and writes it to a ContentValues.\n     * Adds nothing to the ContentValues if the column isn't present or if its value is null.\n     *\n     * @param cursor The cursor to read from\n     * @param column The column to read\n     * @param values The {@link ContentValues} to put the value into\n     */\n    public static void cursorFloatToContentValuesIfPresent(Cursor cursor, ContentValues values,\n            String column) {\n        final int index = cursor.getColumnIndex(column);\n        if (index != -1 && !cursor.isNull(index)) {\n            values.put(column, cursor.getFloat(index));\n        }\n    }\n\n    /**\n     * Reads a Double out of a column in a Cursor and writes it to a ContentValues.\n     * Adds nothing to the ContentValues if the column isn't present or if its value is null.\n     *\n     * @param cursor The cursor to read from\n     * @param column The column to read\n     * @param values The {@link ContentValues} to put the value into\n     */\n    public static void cursorDoubleToContentValuesIfPresent(Cursor cursor, ContentValues values,\n            String column) {\n        final int index = cursor.getColumnIndex(column);\n        if (index != -1 && !cursor.isNull(index)) {\n            values.put(column, cursor.getDouble(index));\n        }\n    }\n\n    /**\n     * This class allows users to do multiple inserts into a table using\n     * the same statement.\n     * <p>\n     * This class is not thread-safe.\n     * </p>\n     *\n     * @deprecated Use {@link SQLiteStatement} instead.\n     */\n    @Deprecated\n    public static class InsertHelper {\n        private final SQLiteDatabase mDb;\n        private final String mTableName;\n        private HashMap<String, Integer> mColumns;\n        private String mInsertSQL = null;\n        private SQLiteStatement mInsertStatement = null;\n        private SQLiteStatement mReplaceStatement = null;\n        private SQLiteStatement mPreparedStatement = null;\n\n        /**\n         * {@hide}\n         * <p/>\n         * These are the columns returned by sqlite's \"PRAGMA\n         * table_info(...)\" command that we depend on.\n         */\n        public static final int TABLE_INFO_PRAGMA_COLUMNNAME_INDEX = 1;\n\n        /**\n         * This field was accidentally exposed in earlier versions of the platform\n         * so we can hide it but we can't remove it.\n         *\n         * @hide\n         */\n        public static final int TABLE_INFO_PRAGMA_DEFAULT_INDEX = 4;\n\n        /**\n         * @param db        the SQLiteDatabase to insert into\n         * @param tableName the name of the table to insert into\n         */\n        public InsertHelper(SQLiteDatabase db, String tableName) {\n            mDb = db;\n            mTableName = tableName;\n        }\n\n        private void buildSQL() throws SQLException {\n            StringBuilder sb = new StringBuilder(128);\n            sb.append(\"INSERT INTO \");\n            sb.append(mTableName);\n            sb.append(\" (\");\n\n            StringBuilder sbv = new StringBuilder(128);\n            sbv.append(\"VALUES (\");\n\n            int i = 1;\n            Cursor cur = null;\n            try {\n                cur = mDb.rawQuery(\"PRAGMA table_info(\" + mTableName + \")\", null);\n                mColumns = new HashMap<String, Integer>(cur.getCount());\n                while (cur.moveToNext()) {\n                    String columnName = cur.getString(TABLE_INFO_PRAGMA_COLUMNNAME_INDEX);\n                    String defaultValue = cur.getString(TABLE_INFO_PRAGMA_DEFAULT_INDEX);\n\n                    mColumns.put(columnName, i);\n                    sb.append(\"'\");\n                    sb.append(columnName);\n                    sb.append(\"'\");\n\n                    if (defaultValue == null) {\n                        sbv.append(\"?\");\n                    } else {\n                        sbv.append(\"COALESCE(?, \");\n                        sbv.append(defaultValue);\n                        sbv.append(\")\");\n                    }\n\n                    sb.append(i == cur.getCount() ? \") \" : \", \");\n                    sbv.append(i == cur.getCount() ? \");\" : \", \");\n                    ++i;\n                }\n            } finally {\n                if (cur != null) cur.close();\n            }\n\n            sb.append(sbv);\n\n            mInsertSQL = sb.toString();\n            if (DEBUG) Log.v(TAG, \"insert statement is \" + mInsertSQL);\n        }\n\n        private SQLiteStatement getStatement(boolean allowReplace) throws SQLException {\n            if (allowReplace) {\n                if (mReplaceStatement == null) {\n                    if (mInsertSQL == null) buildSQL();\n                    // chop \"INSERT\" off the front and prepend \"INSERT OR REPLACE\" instead.\n                    String replaceSQL = \"INSERT OR REPLACE\" + mInsertSQL.substring(6);\n                    mReplaceStatement = mDb.compileStatement(replaceSQL);\n                }\n                return mReplaceStatement;\n            } else {\n                if (mInsertStatement == null) {\n                    if (mInsertSQL == null) buildSQL();\n                    mInsertStatement = mDb.compileStatement(mInsertSQL);\n                }\n                return mInsertStatement;\n            }\n        }\n\n        /**\n         * Performs an insert, adding a new row with the given values.\n         *\n         * @param values       the set of values with which  to populate the\n         *                     new row\n         * @param allowReplace if true, the statement does \"INSERT OR\n         *                     REPLACE\" instead of \"INSERT\", silently deleting any\n         *                     previously existing rows that would cause a conflict\n         * @return the row ID of the newly inserted row, or -1 if an\n         * error occurred\n         */\n        private long insertInternal(ContentValues values, boolean allowReplace) {\n            // Start a transaction even though we don't really need one.\n            // This is to help maintain compatibility with applications that\n            // access InsertHelper from multiple threads even though they never should have.\n            // The original code used to lock the InsertHelper itself which was prone\n            // to deadlocks.  Starting a transaction achieves the same mutual exclusion\n            // effect as grabbing a lock but without the potential for deadlocks.\n            mDb.beginTransactionNonExclusive();\n            try {\n                SQLiteStatement stmt = getStatement(allowReplace);\n                stmt.clearBindings();\n                if (DEBUG) Log.v(TAG, \"--- inserting in table \" + mTableName);\n                for (Map.Entry<String, Object> e : values.valueSet()) {\n                    final String key = e.getKey();\n                    int i = getColumnIndex(key);\n                    DatabaseUtils.bindObjectToProgram(stmt, i, e.getValue());\n                    if (DEBUG) {\n                        Log.v(TAG, \"binding \" + e.getValue() + \" to column \" +\n                                i + \" (\" + key + \")\");\n                    }\n                }\n                long result = stmt.executeInsert();\n                mDb.setTransactionSuccessful();\n                return result;\n            } catch (SQLException e) {\n                Log.e(TAG, \"Error inserting \" + values + \" into table  \" + mTableName, e);\n                return -1;\n            } finally {\n                mDb.endTransaction();\n            }\n        }\n\n        /**\n         * Returns the index of the specified column. This is index is suitagble for use\n         * in calls to bind().\n         *\n         * @param key the column name\n         * @return the index of the column\n         */\n        public int getColumnIndex(String key) {\n            getStatement(false);\n            final Integer index = mColumns.get(key);\n            if (index == null) {\n                throw new IllegalArgumentException(\"column '\" + key + \"' is invalid\");\n            }\n            return index;\n        }\n\n        /**\n         * Bind the value to an index. A prepareForInsert() or prepareForReplace()\n         * without a matching execute() must have already have been called.\n         *\n         * @param index the index of the slot to which to bind\n         * @param value the value to bind\n         */\n        public void bind(int index, double value) {\n            mPreparedStatement.bindDouble(index, value);\n        }\n\n        /**\n         * Bind the value to an index. A prepareForInsert() or prepareForReplace()\n         * without a matching execute() must have already have been called.\n         *\n         * @param index the index of the slot to which to bind\n         * @param value the value to bind\n         */\n        public void bind(int index, float value) {\n            mPreparedStatement.bindDouble(index, value);\n        }\n\n        /**\n         * Bind the value to an index. A prepareForInsert() or prepareForReplace()\n         * without a matching execute() must have already have been called.\n         *\n         * @param index the index of the slot to which to bind\n         * @param value the value to bind\n         */\n        public void bind(int index, long value) {\n            mPreparedStatement.bindLong(index, value);\n        }\n\n        /**\n         * Bind the value to an index. A prepareForInsert() or prepareForReplace()\n         * without a matching execute() must have already have been called.\n         *\n         * @param index the index of the slot to which to bind\n         * @param value the value to bind\n         */\n        public void bind(int index, int value) {\n            mPreparedStatement.bindLong(index, value);\n        }\n\n        /**\n         * Bind the value to an index. A prepareForInsert() or prepareForReplace()\n         * without a matching execute() must have already have been called.\n         *\n         * @param index the index of the slot to which to bind\n         * @param value the value to bind\n         */\n        public void bind(int index, boolean value) {\n            mPreparedStatement.bindLong(index, value ? 1 : 0);\n        }\n\n        /**\n         * Bind null to an index. A prepareForInsert() or prepareForReplace()\n         * without a matching execute() must have already have been called.\n         *\n         * @param index the index of the slot to which to bind\n         */\n        public void bindNull(int index) {\n            mPreparedStatement.bindNull(index);\n        }\n\n        /**\n         * Bind the value to an index. A prepareForInsert() or prepareForReplace()\n         * without a matching execute() must have already have been called.\n         *\n         * @param index the index of the slot to which to bind\n         * @param value the value to bind\n         */\n        public void bind(int index, byte[] value) {\n            if (value == null) {\n                mPreparedStatement.bindNull(index);\n            } else {\n                mPreparedStatement.bindBlob(index, value);\n            }\n        }\n\n        /**\n         * Bind the value to an index. A prepareForInsert() or prepareForReplace()\n         * without a matching execute() must have already have been called.\n         *\n         * @param index the index of the slot to which to bind\n         * @param value the value to bind\n         */\n        public void bind(int index, String value) {\n            if (value == null) {\n                mPreparedStatement.bindNull(index);\n            } else {\n                mPreparedStatement.bindString(index, value);\n            }\n        }\n\n        /**\n         * Performs an insert, adding a new row with the given values.\n         * If the table contains conflicting rows, an error is\n         * returned.\n         *\n         * @param values the set of values with which to populate the\n         *               new row\n         * @return the row ID of the newly inserted row, or -1 if an\n         * error occurred\n         */\n        public long insert(ContentValues values) {\n            return insertInternal(values, false);\n        }\n\n        /**\n         * Execute the previously prepared insert or replace using the bound values\n         * since the last call to prepareForInsert or prepareForReplace.\n         * <p/>\n         * <p>Note that calling bind() and then execute() is not thread-safe. The only thread-safe\n         * way to use this class is to call insert() or replace().\n         *\n         * @return the row ID of the newly inserted row, or -1 if an\n         * error occurred\n         */\n        public long execute() {\n            if (mPreparedStatement == null) {\n                throw new IllegalStateException(\"you must prepare this inserter before calling \"\n                        + \"execute\");\n            }\n            try {\n                if (DEBUG) Log.v(TAG, \"--- doing insert or replace in table \" + mTableName);\n                return mPreparedStatement.executeInsert();\n            } catch (SQLException e) {\n                Log.e(TAG, \"Error executing InsertHelper with table \" + mTableName, e);\n                return -1;\n            } finally {\n                // you can only call this once per prepare\n                mPreparedStatement = null;\n            }\n        }\n\n        /**\n         * Prepare the InsertHelper for an insert. The pattern for this is:\n         * <ul>\n         * <li>prepareForInsert()\n         * <li>bind(index, value);\n         * <li>bind(index, value);\n         * <li>...\n         * <li>bind(index, value);\n         * <li>execute();\n         * </ul>\n         */\n        public void prepareForInsert() {\n            mPreparedStatement = getStatement(false);\n            mPreparedStatement.clearBindings();\n        }\n\n        /**\n         * Prepare the InsertHelper for a replace. The pattern for this is:\n         * <ul>\n         * <li>prepareForReplace()\n         * <li>bind(index, value);\n         * <li>bind(index, value);\n         * <li>...\n         * <li>bind(index, value);\n         * <li>execute();\n         * </ul>\n         */\n        public void prepareForReplace() {\n            mPreparedStatement = getStatement(true);\n            mPreparedStatement.clearBindings();\n        }\n\n        /**\n         * Performs an insert, adding a new row with the given values.\n         * If the table contains conflicting rows, they are deleted\n         * and replaced with the new row.\n         *\n         * @param values the set of values with which to populate the\n         *               new row\n         * @return the row ID of the newly inserted row, or -1 if an\n         * error occurred\n         */\n        public long replace(ContentValues values) {\n            return insertInternal(values, true);\n        }\n\n        /**\n         * Close this object and release any resources associated with\n         * it.  The behavior of calling <code>insert()</code> after\n         * calling this method is undefined.\n         */\n        public void close() {\n            if (mInsertStatement != null) {\n                mInsertStatement.close();\n                mInsertStatement = null;\n            }\n            if (mReplaceStatement != null) {\n                mReplaceStatement.close();\n                mReplaceStatement = null;\n            }\n            mInsertSQL = null;\n            mColumns = null;\n        }\n    }\n\n    /**\n     * Creates a db and populates it with the sql statements in sqlStatements.\n     *\n     * @param context       the context to use to create the db\n     * @param dbName        the name of the db to create\n     * @param dbVersion     the version to set on the db\n     * @param sqlStatements the statements to use to populate the db. This should be a single string\n     *                      of the form returned by sqlite3's <tt>.dump</tt> command (statements separated by\n     *                      semicolons)\n     */\n    static public void createDbFromSqlStatements(android.content.Context context, String dbName,\n            byte[] password, SQLiteCipherSpec cipher,\n            int dbVersion, String sqlStatements) {\n        SQLiteDatabase db = Context.openOrCreateDatabase(context, dbName, password,\n                cipher, 0, null);\n        // TODO: this is not quite safe since it assumes that all semicolons at the end of a line\n        // terminate statements. It is possible that a text field contains ;\\n. We will have to fix\n        // this if that turns out to be a problem.\n        String[] statements = TextUtils.split(sqlStatements, \";\\n\");\n        for (String statement : statements) {\n            if (TextUtils.isEmpty(statement)) continue;\n            db.execSQL(statement);\n        }\n        db.setVersion(dbVersion);\n        db.close();\n    }\n\n    static public void createDbFromSqlStatements(\n            android.content.Context context, String dbName, int dbVersion, String sqlStatements) {\n        createDbFromSqlStatements(context, dbName, null, null, dbVersion, sqlStatements);\n    }\n\n    private static int extractSqlCode(String sql) {\n        // sql must have length >= 3\n\n        int result = 0;\n        for (int i = 0; i < 3; i++) {\n            int c = sql.charAt(i);\n            if (c >= 'a' && c <= 'z')\n                c = c - 'a' + 'A';\n            else if (c >= 0x80)\n                return 0;\n\n            result |= ((c & 0x7F) << i * 8);\n        }\n        return result;\n    }\n\n    /**\n     * Returns one of the following which represent the type of the given SQL statement.\n     * <ol>\n     * <li>{@link #STATEMENT_SELECT}</li>\n     * <li>{@link #STATEMENT_UPDATE}</li>\n     * <li>{@link #STATEMENT_ATTACH}</li>\n     * <li>{@link #STATEMENT_BEGIN}</li>\n     * <li>{@link #STATEMENT_COMMIT}</li>\n     * <li>{@link #STATEMENT_ABORT}</li>\n     * <li>{@link #STATEMENT_OTHER}</li>\n     * </ol>\n     *\n     * @param sql the SQL statement whose type is returned by this method\n     * @return one of the values listed above\n     */\n    public static int getSqlStatementType(String sql) {\n        sql = sql.trim();\n        if (sql.length() < 3) {\n            return STATEMENT_OTHER;\n        }\n\n        int sqlCode = extractSqlCode(sql);\n        switch (sqlCode) {\n            case 0x4C4553:  // SEL\n                return STATEMENT_SELECT;\n            case 0x534E49:  // INS\n            case 0x445055:  // UPD\n            case 0x504552:  // REP\n            case 0x4C4544:  // DEL\n                return STATEMENT_UPDATE;\n            case 0x545441:  // ATT\n                return STATEMENT_ATTACH;\n            case 0x4D4F43:  // COM\n            case 0x444E45:  // END\n                return STATEMENT_COMMIT;\n            case 0x4C4F52:  // ROL\n                return STATEMENT_ABORT;\n            case 0x474542:  // BEG\n                return STATEMENT_BEGIN;\n            case 0x415250:  // PRA\n                return STATEMENT_PRAGMA;\n            case 0x455243:  // CRE\n            case 0x4F5244:  // DRO\n            case 0x544C41:  // ALT\n                return STATEMENT_DDL;\n            case 0x414E41:  // ANA\n            case 0x544544:  // DET\n                return STATEMENT_UNPREPARED;\n            default:\n                return STATEMENT_OTHER;\n        }\n    }\n\n    /**\n     * Appends one set of selection args to another. This is useful when adding a selection\n     * argument to a user provided set.\n     */\n    public static String[] appendSelectionArgs(String[] originalValues, String[] newValues) {\n        if (originalValues == null || originalValues.length == 0) {\n            return newValues;\n        }\n        String[] result = new String[originalValues.length + newValues.length];\n        System.arraycopy(originalValues, 0, result, 0, originalValues.length);\n        System.arraycopy(newValues, 0, result, originalValues.length, newValues.length);\n        return result;\n    }\n\n    /**\n     * Returns column index of \"_id\" column, or -1 if not found.\n     *\n     * @hide\n     */\n    public static int findRowIdColumnIndex(String[] columnNames) {\n        int length = columnNames.length;\n        for (int i = 0; i < length; i++) {\n            if (columnNames[i].equals(\"_id\")) {\n                return i;\n            }\n        }\n        return -1;\n    }\n}\n"
  },
  {
    "path": "deprecated/android/wcdb/src/com/tencent/wcdb/DefaultDatabaseErrorHandler.java",
    "content": "/*\n * Copyright (C) 2010 The Android Open Source Project\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage com.tencent.wcdb;\n\nimport java.io.File;\nimport java.util.List;\n\nimport com.tencent.wcdb.database.SQLiteDatabase;\nimport com.tencent.wcdb.database.SQLiteException;\nimport com.tencent.wcdb.database.SQLiteTrace;\nimport com.tencent.wcdb.support.Log;\n\nimport android.util.Pair;\n\n\n/**\n * Default class used to define the actions to take when the database corruption is reported\n * by sqlite.\n * <p>\n * An application can specify an implementation of {@link DatabaseErrorHandler} on the\n * following:\n * <ul>\n *   <li>{@link SQLiteDatabase#openOrCreateDatabase(String,\n *      com.tencent.wcdb.database.SQLiteDatabase.CursorFactory, DatabaseErrorHandler)}</li>\n *   <li>{@link SQLiteDatabase#openDatabase(String,\n *      com.tencent.wcdb.database.SQLiteDatabase.CursorFactory, int, DatabaseErrorHandler)}</li>\n * </ul>\n * The specified {@link DatabaseErrorHandler} is used to handle database corruption errors, if they\n * occur.\n * <p>\n * If null is specified for DatabaeErrorHandler param in the above calls, then this class is used\n * as the default {@link DatabaseErrorHandler}.\n */\npublic final class DefaultDatabaseErrorHandler implements DatabaseErrorHandler {\n\n    private static final String TAG = \"WCDB.DefaultDatabaseErrorHandler\";\n\n\tprivate final boolean mNoCorruptionBackup;\n\n    public DefaultDatabaseErrorHandler() {\n        mNoCorruptionBackup = false;\n    }\n\n    public DefaultDatabaseErrorHandler(boolean noCorruptionBackup) {\n        mNoCorruptionBackup = noCorruptionBackup;\n    }\n\n    /**\n     * defines the default method to be invoked when database corruption is detected.\n     * @param dbObj the {@link SQLiteDatabase} object representing the database on which corruption\n     * is detected.\n     */\n\t@Override\n    public void onCorruption(SQLiteDatabase dbObj) {\n        Log.e(TAG, \"Corruption reported by sqlite on database: \" + dbObj.getPath());\n\n        // is the corruption detected even before database could be 'opened'?\n        if (!dbObj.isOpen()) {\n            // database files are not even openable. delete this database file.\n            // NOTE if the database has attached databases, then any of them could be corrupt.\n            // and not deleting all of them could cause corrupted database file to remain and \n            // make the application crash on database open operation. To avoid this problem,\n            // the application should provide its own {@link DatabaseErrorHandler} impl class\n            // to delete ALL files of the database (including the attached databases).\n            deleteDatabaseFile(dbObj.getPath());\n            return;\n        }\n\n        // Close the database, which will cause subsequent operations to fail.\n        // before that, get the attached database list first.\n        List<Pair<String, String>> attachedDbs = null;\n        try { attachedDbs = dbObj.getAttachedDbs(); } catch (SQLiteException e) {}\n\n\t\t// Invoke callback.\n\t\tSQLiteTrace trace = dbObj.getTraceCallback();\n\t\tif (trace != null) {\n\t\t\ttrace.onDatabaseCorrupted(dbObj);\n\t\t}\n\n        try {\n            dbObj.close();\n        } catch (SQLiteException e) {\n        } finally {\n            // Delete all files of this corrupt database and/or attached databases\n            if (attachedDbs != null) {\n                for (Pair<String, String> p : attachedDbs) {\n                    deleteDatabaseFile(p.second);\n                }\n            } else {\n                // attachedDbs = null is possible when the database is so corrupt that even\n                // \"PRAGMA database_list;\" also fails. delete the main database file\n                deleteDatabaseFile(dbObj.getPath());\n            }\n        }\n    }\n\n    private static final String[] SUFFIX_TO_BACKUP = new String[] {\n            \"\", \"-journal\", \"-wal\", \".sm\", \".bak\", \"-vfslog\", \"-vfslo1\"\n    };\n\n\tprivate void deleteDatabaseFile(String fileName) {\n\t\tif (fileName.equalsIgnoreCase(\":memory:\") || fileName.trim().length() == 0) {\n\t\t\treturn;\n\t\t}\n\n\t\tLog.e(TAG, \"Remove database file: \" + fileName);\n\n        if (!mNoCorruptionBackup) {\n            // Save corrupted database for recovery.\n            File originFile = new File(fileName);\n            File corruptedDir = new File(originFile.getParentFile(), \"corrupted\");\n            if (!corruptedDir.mkdirs()) {\n                Log.e(TAG, \"Could not create directory for corrupted database. \" +\n                        \"Corruption backup may be unavailable.\");\n            }\n\n            String corruptedPath = corruptedDir.getPath() + \"/\" + originFile.getName();\n            for (String suffix : SUFFIX_TO_BACKUP) {\n                moveOrDeleteFile(fileName + suffix, corruptedPath + suffix);\n            }\n        } else {\n            for (String suffix : SUFFIX_TO_BACKUP) {\n                deleteFile(fileName + suffix);\n            }\n        }\n\t}\n\n\tprivate static boolean moveOrDeleteFile(String oldPath, String newPath) {\n\t\tFile oldFile = new File(oldPath);\n\t\tboolean ret = oldFile.renameTo(new File(newPath));\n\t\tif (!ret) {\n            oldFile.delete();\n        }\n\t\treturn ret;\n\t}\n\n    private static boolean deleteFile(String path) {\n        return new File(path).delete();\n    }\n}\n"
  },
  {
    "path": "deprecated/android/wcdb/src/com/tencent/wcdb/FileUtils.java",
    "content": "/*\n * Copyright (C) 2006 The Android Open Source Project\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdb;\n\n/**\n * Tools for managing files.  Not for public consumption.\n * @hide\n */\npublic class FileUtils {\n    private static final String TAG = \"FileUtils\";\n\n    public static final int S_IRWXU = 00700;\n    public static final int S_IRUSR = 00400;\n    public static final int S_IWUSR = 00200;\n    public static final int S_IXUSR = 00100;\n\n    public static final int S_IRWXG = 00070;\n    public static final int S_IRGRP = 00040;\n    public static final int S_IWGRP = 00020;\n    public static final int S_IXGRP = 00010;\n\n    public static final int S_IRWXO = 00007;\n    public static final int S_IROTH = 00004;\n    public static final int S_IWOTH = 00002;\n    public static final int S_IXOTH = 00001;\n\n    public static native int setPermissions(String file, int mode, int uid, int gid);\n}\n"
  },
  {
    "path": "deprecated/android/wcdb/src/com/tencent/wcdb/IBulkCursor.java",
    "content": "/*\n * Copyright (C) 2006 The Android Open Source Project\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdb;\n\nimport android.os.Bundle;\nimport android.os.IBinder;\nimport android.os.IInterface;\nimport android.os.RemoteException;\n\n/**\n * This interface provides a low-level way to pass bulk cursor data across\n * both process and language boundaries. Application code should use the Cursor\n * interface directly.\n *\n * {@hide}\n */\npublic interface IBulkCursor extends IInterface  {\n    /**\n     * Gets a cursor window that contains the specified position.\n     * The window will contain a range of rows around the specified position.\n     */\n    public CursorWindow getWindow(int position) throws RemoteException;\n\n    /**\n     * Notifies the cursor that the position has changed.\n     * Only called when {@link #getWantsAllOnMoveCalls()} returns true.\n     *\n     * @param position The new position\n     */\n    public void onMove(int position) throws RemoteException;\n\n    public void deactivate() throws RemoteException;\n\n    public void close() throws RemoteException;\n\n    public int requery(IContentObserver observer) throws RemoteException;\n\n    Bundle getExtras() throws RemoteException;\n\n    Bundle respond(Bundle extras) throws RemoteException;\n\n    /* IPC constants */\n    static final String descriptor = \"android.content.IBulkCursor\";\n\n    static final int GET_CURSOR_WINDOW_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION;\n    static final int DEACTIVATE_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION + 1;\n    static final int REQUERY_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION + 2;\n    static final int ON_MOVE_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION + 3;\n    static final int GET_EXTRAS_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION + 4;\n    static final int RESPOND_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION + 5;\n    static final int CLOSE_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION + 6;\n}\n"
  },
  {
    "path": "deprecated/android/wcdb/src/com/tencent/wcdb/IContentObserver.aidl",
    "content": "/*\n**\n** Copyright 2007, The Android Open Source Project\n**\n** Licensed under the Apache License, Version 2.0 (the \"License\"); \n** you may not use this file except in compliance with the License. \n** You may obtain a copy of the License at \n**\n**     http://www.apache.org/licenses/LICENSE-2.0 \n**\n** Unless required by applicable law or agreed to in writing, software \n** distributed under the License is distributed on an \"AS IS\" BASIS, \n** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. \n** See the License for the specific language governing permissions and \n** limitations under the License.\n*/\n\npackage com.tencent.wcdb;\n\nimport android.net.Uri;\n\n/**\n * @hide\n */\ninterface IContentObserver\n{\n    /**\n     * This method is called when an update occurs to the cursor that is being\n     * observed. selfUpdate is true if the update was caused by a call to\n     * commit on the cursor that is being observed.\n     */\n    oneway void onChange(boolean selfUpdate, in Uri uri);\n}\n"
  },
  {
    "path": "deprecated/android/wcdb/src/com/tencent/wcdb/MatrixCursor.java",
    "content": "/*\n * Copyright (C) 2007 The Android Open Source Project\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdb;\n\nimport java.util.ArrayList;\n\n/**\n * A mutable cursor implementation backed by an array of {@code Object}s. Use\n * {@link #newRow()} to add rows. Automatically expands internal capacity\n * as needed.\n */\npublic class MatrixCursor extends AbstractCursor {\n\n    private final String[] columnNames;\n    private Object[] data;\n    private int rowCount = 0;\n    private final int columnCount;\n\n    /**\n     * Constructs a new cursor with the given initial capacity.\n     *\n     * @param columnNames names of the columns, the ordering of which\n     *  determines column ordering elsewhere in this cursor\n     * @param initialCapacity in rows\n     */\n    public MatrixCursor(String[] columnNames, int initialCapacity) {\n        this.columnNames = columnNames;\n        this.columnCount = columnNames.length;\n\n        if (initialCapacity < 1) {\n            initialCapacity = 1;\n        }\n\n        this.data = new Object[columnCount * initialCapacity];\n    }\n\n    /**\n     * Constructs a new cursor.\n     *\n     * @param columnNames names of the columns, the ordering of which\n     *  determines column ordering elsewhere in this cursor\n     */\n    public MatrixCursor(String[] columnNames) {\n        this(columnNames, 16);\n    }\n\n    /**\n     * Gets value at the given column for the current row.\n     */\n    private Object get(int column) {\n        if (column < 0 || column >= columnCount) {\n            throw new CursorIndexOutOfBoundsException(\"Requested column: \"\n                    + column + \", # of columns: \" +  columnCount);\n        }\n        if (mPos < 0) {\n            throw new CursorIndexOutOfBoundsException(\"Before first row.\");\n        }\n        if (mPos >= rowCount) {\n            throw new CursorIndexOutOfBoundsException(\"After last row.\");\n        }\n        return data[mPos * columnCount + column];\n    }\n\n    /**\n     * Adds a new row to the end and returns a builder for that row. Not safe\n     * for concurrent use.\n     *\n     * @return builder which can be used to set the column values for the new\n     *  row\n     */\n    public RowBuilder newRow() {\n        rowCount++;\n        int endIndex = rowCount * columnCount;\n        ensureCapacity(endIndex);\n        int start = endIndex - columnCount;\n        return new RowBuilder(start, endIndex);\n    }\n\n    /**\n     * Adds a new row to the end with the given column values. Not safe\n     * for concurrent use.\n     *\n     * @throws IllegalArgumentException if {@code columnValues.length !=\n     *  columnNames.length}\n     * @param columnValues in the same order as the the column names specified\n     *  at cursor construction time\n     */\n    public void addRow(Object[] columnValues) {\n        if (columnValues.length != columnCount) {\n            throw new IllegalArgumentException(\"columnNames.length = \"\n                    + columnCount + \", columnValues.length = \"\n                    + columnValues.length);\n        }\n\n        int start = rowCount++ * columnCount;\n        ensureCapacity(start + columnCount);\n        System.arraycopy(columnValues, 0, data, start, columnCount);\n    }\n\n    /**\n     * Adds a new row to the end with the given column values. Not safe\n     * for concurrent use.\n     *\n     * @throws IllegalArgumentException if {@code columnValues.size() !=\n     *  columnNames.length}\n     * @param columnValues in the same order as the the column names specified\n     *  at cursor construction time\n     */\n    public void addRow(Iterable<?> columnValues) {\n        int start = rowCount * columnCount;\n        int end = start + columnCount;\n        ensureCapacity(end);\n\n        if (columnValues instanceof ArrayList<?>) {\n            addRow((ArrayList<?>) columnValues, start);\n            return;\n        }\n\n        int current = start;\n        Object[] localData = data;\n        for (Object columnValue : columnValues) {\n            if (current == end) {\n                // TODO: null out row?\n                throw new IllegalArgumentException(\n                        \"columnValues.size() > columnNames.length\");\n            }\n            localData[current++] = columnValue;\n        }\n\n        if (current != end) {\n            // TODO: null out row?\n            throw new IllegalArgumentException(\n                    \"columnValues.size() < columnNames.length\");\n        }\n\n        // Increase row count here in case we encounter an exception.\n        rowCount++;\n    }\n\n    /** Optimization for {@link ArrayList}. */\n    private void addRow(ArrayList<?> columnValues, int start) {\n        int size = columnValues.size();\n        if (size != columnCount) {\n            throw new IllegalArgumentException(\"columnNames.length = \"\n                    + columnCount + \", columnValues.size() = \" + size);\n        }\n\n        rowCount++;\n        Object[] localData = data;\n        for (int i = 0; i < size; i++) {\n            localData[start + i] = columnValues.get(i);\n        }\n    }\n\n    /** Ensures that this cursor has enough capacity. */\n    private void ensureCapacity(int size) {\n        if (size > data.length) {\n            Object[] oldData = this.data;\n            int newSize = data.length * 2;\n            if (newSize < size) {\n                newSize = size;\n            }\n            this.data = new Object[newSize];\n            System.arraycopy(oldData, 0, this.data, 0, oldData.length);\n        }\n    }\n\n    /**\n     * Builds a row, starting from the left-most column and adding one column\n     * value at a time. Follows the same ordering as the column names specified\n     * at cursor construction time.\n     */\n    public class RowBuilder {\n\n        private int index;\n        private final int endIndex;\n\n        RowBuilder(int index, int endIndex) {\n            this.index = index;\n            this.endIndex = endIndex;\n        }\n\n        /**\n         * Sets the next column value in this row.\n         *\n         * @throws CursorIndexOutOfBoundsException if you try to add too many\n         *  values\n         * @return this builder to support chaining\n         */\n        public RowBuilder add(Object columnValue) {\n            if (index == endIndex) {\n                throw new CursorIndexOutOfBoundsException(\n                        \"No more columns left.\");\n            }\n\n            data[index++] = columnValue;\n            return this;\n        }\n    }\n\n    // AbstractCursor implementation.\n\n    @Override\n    public int getCount() {\n        return rowCount;\n    }\n\n    @Override\n    public String[] getColumnNames() {\n        return columnNames;\n    }\n\n    @Override\n    public String getString(int column) {\n        Object value = get(column);\n        if (value == null) return null;\n        return value.toString();\n    }\n\n    @Override\n    public short getShort(int column) {\n        Object value = get(column);\n        if (value == null) return 0;\n        if (value instanceof Number) return ((Number) value).shortValue();\n        return Short.parseShort(value.toString());\n    }\n\n    @Override\n    public int getInt(int column) {\n        Object value = get(column);\n        if (value == null) return 0;\n        if (value instanceof Number) return ((Number) value).intValue();\n        return Integer.parseInt(value.toString());\n    }\n\n    @Override\n    public long getLong(int column) {\n        Object value = get(column);\n        if (value == null) return 0;\n        if (value instanceof Number) return ((Number) value).longValue();\n        return Long.parseLong(value.toString());\n    }\n\n    @Override\n    public float getFloat(int column) {\n        Object value = get(column);\n        if (value == null) return 0.0f;\n        if (value instanceof Number) return ((Number) value).floatValue();\n        return Float.parseFloat(value.toString());\n    }\n\n    @Override\n    public double getDouble(int column) {\n        Object value = get(column);\n        if (value == null) return 0.0d;\n        if (value instanceof Number) return ((Number) value).doubleValue();\n        return Double.parseDouble(value.toString());\n    }\n\n    @Override\n    public byte[] getBlob(int column) {\n        Object value = get(column);\n        return (byte[]) value;\n    }\n\n    @Override\n    public int getType(int column) {\n        return DatabaseUtils.getTypeOfObject(get(column));\n    }\n\n    @Override\n    public boolean isNull(int column) {\n        return get(column) == null;\n    }\n\n\t@Override\n\tpublic void copyStringToBuffer(int columnIndex, android.database.CharArrayBuffer buffer)\n\t{\n\t\t// TODO Auto-generated method stub\n\t}\n\n\t@Override\n\tpublic void registerContentObserver(android.database.ContentObserver observer)\n\t{\n\t\t// TODO Auto-generated method stub\n\t\t\n\t}\n\n\t@Override\n\tpublic void registerDataSetObserver(android.database.DataSetObserver observer)\n\t{\n\t\t// TODO Auto-generated method stub\n\t\t\n\t}\n\n\t@Override\n\tpublic void unregisterContentObserver(android.database.ContentObserver observer)\n\t{\n\t\t// TODO Auto-generated method stub\n\t\t\n\t}\n\n\t@Override\n\tpublic void unregisterDataSetObserver(android.database.DataSetObserver observer)\n\t{\n\t\t// TODO Auto-generated method stub\n\t\t\n\t}\n}\n"
  },
  {
    "path": "deprecated/android/wcdb/src/com/tencent/wcdb/MergeCursor.java",
    "content": "/*\n * Copyright (C) 2006 The Android Open Source Project\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdb;\n\nimport android.database.ContentObserver;\nimport android.database.DataSetObserver;\n\n/**\n * A convience class that lets you present an array of Cursors as a single linear Cursor.\n * The schema of the cursors presented is entirely up to the creator of the MergeCursor, and\n * may be different if that is desired. Calls to getColumns, getColumnIndex, etc will return the\n * value for the row that the MergeCursor is currently pointing at.\n */\npublic class MergeCursor extends AbstractCursor\n{\n    private DataSetObserver mObserver = new DataSetObserver() {\n\n        @Override\n        public void onChanged() {\n            // Reset our position so the optimizations in move-related code\n            // don't screw us over\n            mPos = -1;\n        }\n\n        @Override\n        public void onInvalidated() {\n            mPos = -1;\n        }\n    };\n    \n    public MergeCursor(Cursor[] cursors)\n    {\n        mCursors = cursors;\n        mCursor = cursors[0];\n        \n        for (int i = 0; i < mCursors.length; i++) {\n            if (mCursors[i] == null) continue;\n            \n            mCursors[i].registerDataSetObserver(mObserver);\n        }\n    }\n    \n    @Override\n    public int getCount()\n    {\n        int count = 0;\n        int length = mCursors.length;\n        for (int i = 0 ; i < length ; i++) {\n            if (mCursors[i] != null) {\n                count += mCursors[i].getCount();\n            }\n        }\n        return count;\n    }\n\n    @Override\n    public boolean onMove(int oldPosition, int newPosition)\n    {\n        /* Find the right cursor */\n        mCursor = null;\n        int cursorStartPos = 0;\n        int length = mCursors.length;\n        for (int i = 0 ; i < length; i++) {\n            if (mCursors[i] == null) {\n                continue;\n            }\n            \n            if (newPosition < (cursorStartPos + mCursors[i].getCount())) {\n                mCursor = mCursors[i];\n                break;\n            }\n\n            cursorStartPos += mCursors[i].getCount();\n        }\n\n        /* Move it to the right position */\n        if (mCursor != null) {\n            boolean ret = mCursor.moveToPosition(newPosition - cursorStartPos);\n            return ret;\n        }\n        return false;\n    }\n\n    @Override\n    public String getString(int column)\n    {\n        return mCursor.getString(column);\n    }\n\n    @Override\n    public short getShort(int column)\n    {\n        return mCursor.getShort(column);\n    }\n\n    @Override\n    public int getInt(int column)\n    {\n        return mCursor.getInt(column);\n    }\n\n    @Override\n    public long getLong(int column)\n    {\n        return mCursor.getLong(column);\n    }\n\n    @Override\n    public float getFloat(int column)\n    {\n        return mCursor.getFloat(column);\n    }\n\n    @Override\n    public double getDouble(int column)\n    {\n        return mCursor.getDouble(column);\n    }\n\n    @Override\n    public int getType(int column) {\n        return mCursor.getType(column);\n    }\n\n    @Override\n    public boolean isNull(int column)\n    {\n        return mCursor.isNull(column);\n    }\n\n    @Override\n    public byte[] getBlob(int column)\n    {\n        return mCursor.getBlob(column);   \n    }\n\n    @Override\n    public String[] getColumnNames()\n    {\n        if (mCursor != null) {\n            return mCursor.getColumnNames();\n        } else {\n            return new String[0];\n        }\n    }\n    \n    @SuppressWarnings(\"deprecation\")\n\t@Override\n    public void deactivate()\n    {\n        int length = mCursors.length;\n        for (int i = 0 ; i < length ; i++) {\n            if (mCursors[i] != null) {\n                mCursors[i].deactivate();\n            }\n        }\n        super.deactivate();\n    }\n\n    @Override\n    public void close() {\n        int length = mCursors.length;\n        for (int i = 0 ; i < length ; i++) {\n            if (mCursors[i] == null) continue;\n            mCursors[i].close();\n        }\n        super.close();\n    }\n\n    @Override\n    public void registerContentObserver(ContentObserver observer) {\n        int length = mCursors.length;\n        for (int i = 0 ; i < length ; i++) {\n            if (mCursors[i] != null) {\n                mCursors[i].registerContentObserver(observer);\n            }\n        }\n    }\n    @Override\n    public void unregisterContentObserver(ContentObserver observer) {\n        int length = mCursors.length;\n        for (int i = 0 ; i < length ; i++) {\n            if (mCursors[i] != null) {\n                mCursors[i].unregisterContentObserver(observer);\n            }\n        }\n    }\n    \n    @Override\n    public void registerDataSetObserver(DataSetObserver observer) {\n        int length = mCursors.length;\n        for (int i = 0 ; i < length ; i++) {\n            if (mCursors[i] != null) {\n                mCursors[i].registerDataSetObserver(observer);\n            }\n        }\n    }\n    \n    @Override\n    public void unregisterDataSetObserver(DataSetObserver observer) {\n        int length = mCursors.length;\n        for (int i = 0 ; i < length ; i++) {\n            if (mCursors[i] != null) {\n                mCursors[i].unregisterDataSetObserver(observer);\n            }\n        }\n    }\n\n    @SuppressWarnings(\"deprecation\")\n\t@Override\n    public boolean requery()\n    {\n        int length = mCursors.length;\n        for (int i = 0 ; i < length ; i++) {\n            if (mCursors[i] == null) {\n                continue;\n            }\n\n            if (mCursors[i].requery() == false) {\n                return false;\n            }\n        }\n\n        return true;\n    }\n\n    private Cursor mCursor; // updated in onMove\n    private Cursor[] mCursors;\n}\n"
  },
  {
    "path": "deprecated/android/wcdb/src/com/tencent/wcdb/Observable.java",
    "content": "/*\n * Copyright (C) 2007 The Android Open Source Project\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdb;\n\nimport java.util.ArrayList;\n\n/**\n * Provides methods for registering or unregistering arbitrary observers in an {@link ArrayList}.\n *\n * This abstract class is intended to be subclassed and specialized to maintain\n * a registry of observers of specific types and dispatch notifications to them.\n *\n * @param T The observer type.\n */\npublic abstract class Observable<T> {\n    /**\n     * The list of observers.  An observer can be in the list at most\n     * once and will never be null.\n     */\n    protected final ArrayList<T> mObservers = new ArrayList<T>();\n\n    /**\n     * Adds an observer to the list. The observer cannot be null and it must not already\n     * be registered.\n     * @param observer the observer to register\n     * @throws IllegalArgumentException the observer is null\n     * @throws IllegalStateException the observer is already registered\n     */\n    public void registerObserver(T observer) {\n        if (observer == null) {\n            throw new IllegalArgumentException(\"The observer is null.\");\n        }\n        synchronized(mObservers) {\n            if (mObservers.contains(observer)) {\n                throw new IllegalStateException(\"Observer \" + observer + \" is already registered.\");\n            }\n            mObservers.add(observer);\n        }\n    }\n\n    /**\n     * Removes a previously registered observer. The observer must not be null and it\n     * must already have been registered.\n     * @param observer the observer to unregister\n     * @throws IllegalArgumentException the observer is null\n     * @throws IllegalStateException the observer is not yet registered\n     */\n    public void unregisterObserver(T observer) {\n        if (observer == null) {\n            throw new IllegalArgumentException(\"The observer is null.\");\n        }\n        synchronized(mObservers) {\n            int index = mObservers.indexOf(observer);\n            if (index == -1) {\n                throw new IllegalStateException(\"Observer \" + observer + \" was not registered.\");\n            }\n            mObservers.remove(index);\n        }\n    }\n\n    /**\n     * Remove all registered observers.\n     */\n    public void unregisterAll() {\n        synchronized(mObservers) {\n            mObservers.clear();\n        }\n    }\n}\n"
  },
  {
    "path": "deprecated/android/wcdb/src/com/tencent/wcdb/SQLException.java",
    "content": "/*\n * Copyright (C) 2006 The Android Open Source Project\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdb;\n\n/**\n * An exception that indicates there was an error with SQL parsing or execution.\n */\n@SuppressWarnings(\"serial\")\npublic class SQLException extends RuntimeException {\n    public SQLException() {\n    }\n\n    public SQLException(String error) {\n        super(error);\n    }\n\n    public SQLException(String error, Throwable cause) {\n        super(error, cause);\n    }\n}\n"
  },
  {
    "path": "deprecated/android/wcdb/src/com/tencent/wcdb/StaleDataException.java",
    "content": "/*\n * Copyright (C) 2006 The Android Open Source Project\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdb;\n\n/**\n * This exception is thrown when a Cursor contains stale data and must be\n * requeried before being used again.\n */\n@SuppressWarnings(\"serial\")\npublic class StaleDataException extends java.lang.RuntimeException\n{\n    public StaleDataException()\n    {\n        super();\n    }\n\n    public StaleDataException(String description)\n    {\n        super(description);\n    }\n}\n"
  },
  {
    "path": "deprecated/android/wcdb/src/com/tencent/wcdb/database/ChunkedCursorWindow.java",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdb.database;\n\nimport com.tencent.wcdb.CursorWindowAllocationException;\n\n\n/**\n * An alternative cursor window implementation which store cursor rows\n * on different chunks.\n *\n * <p>The window size is relatively small on initial and grows when\n * more rows are filled in. This saves memory on small queries and\n * prevent row drops on large queries.</p>\n *\n * <p>This class is used in {@link SQLiteAsyncCursor} and under development.</p>\n *\n * @hide\n */\npublic class ChunkedCursorWindow extends SQLiteClosable {\n\n    public static final long CHUNK_NOT_FOUND = 0xFFFFFFFFFFFFFFFFL;\n\n    /**\n     * The native ChunkedCursorWindow object pointer.  (FOR INTERNAL USE ONLY)\n     * @hide\n     */\n    long mWindowPtr;\n\n    private int mNumColumns = 0;\n\n\n    public ChunkedCursorWindow(int capacity) {\n        mWindowPtr = nativeCreate(capacity);\n        if (mWindowPtr == 0) {\n            throw new CursorWindowAllocationException(\"Cursor window allocation failed.\");\n        }\n    }\n\n    private void dispose() {\n        if (mWindowPtr != 0) {\n            nativeDispose(mWindowPtr);\n            mWindowPtr = 0;\n        }\n    }\n\n    @Override\n    protected void finalize() throws Throwable {\n        try {\n            dispose();\n        } finally {\n            super.finalize();\n        }\n    }\n\n    @Override\n    protected void onAllReferencesReleased() {\n        dispose();\n    }\n\n    public void clear() {\n        acquireReference();\n        try {\n            nativeClear(mWindowPtr);\n        } finally {\n            releaseReference();\n        }\n    }\n\n    public long removeChunk(int pos) {\n        acquireReference();\n        try {\n            return nativeRemoveChunk(mWindowPtr, pos);\n        } finally {\n            releaseReference();\n        }\n    }\n\n    public int getNumChunks() {\n        acquireReference();\n        try {\n            return nativeGetNumChunks(mWindowPtr);\n        } finally {\n            releaseReference();\n        }\n    }\n\n    public int getNumColumns() {\n        return mNumColumns;\n    }\n\n    public boolean setNumColumns(int columnNum) {\n        acquireReference();\n        try {\n            boolean ok = nativeSetNumColumns(mWindowPtr, columnNum);\n            if (ok)\n                mNumColumns = columnNum;\n            return ok;\n        } finally {\n            releaseReference();\n        }\n    }\n\n\n    // Fast unsafe paths for SQLiteAsyncCursor only.\n    long getRowUnsafe(int pos) {\n        acquireReference();\n\n        long result = nativeGetRow(mWindowPtr, pos);\n        if (result == 0)\n            releaseReference();\n\n        return result;\n    }\n\n    void endRowUnsafe(long rowObj) {\n        if (rowObj == 0) return;\n\n        nativeEndRow(mWindowPtr, rowObj);\n        releaseReference();\n    }\n\n    int getTypeUnsafe(long rowObj, int column) {\n        return nativeGetType(rowObj, column);\n    }\n\n    byte[] getBlobUnsafe(long rowObj, int column) {\n        return nativeGetBlob(rowObj, column);\n    }\n\n    String getStringUnsafe(long rowObj, int column) {\n        return nativeGetString(rowObj, column);\n    }\n\n    long getLongUnsafe(long rowObj, int column) {\n        return nativeGetLong(rowObj, column);\n    }\n\n    double getDoubleUnsafe(long rowObj, int column) {\n        return nativeGetDouble(rowObj, column);\n    }\n\n    // Slow safe paths for general usage.\n    public int getType(int row, int column) {\n        long rowObj = getRowUnsafe(row);\n        if (rowObj == 0)\n            throw new IllegalStateException(\"Couldn't read row \" + row + \", column \" + column\n                    + \" from ChunkedCursorWindow.\");\n        try {\n            return nativeGetType(rowObj, column);\n        } finally {\n            endRowUnsafe(rowObj);\n        }\n    }\n\n    public byte[] getBlob(int row, int column) {\n        long rowObj = getRowUnsafe(row);\n        if (rowObj == 0)\n            throw new IllegalStateException(\"Couldn't read row \" + row + \", column \" + column\n                    + \" from ChunkedCursorWindow.\");\n        try {\n            return nativeGetBlob(rowObj, column);\n        } finally {\n            endRowUnsafe(rowObj);\n        }\n    }\n\n    public String getString(int row, int column) {\n        long rowObj = getRowUnsafe(row);\n        if (rowObj == 0)\n            throw new IllegalStateException(\"Couldn't read row \" + row + \", column \" + column\n                    + \" from ChunkedCursorWindow.\");\n        try {\n            return nativeGetString(rowObj, column);\n        } finally {\n            endRowUnsafe(rowObj);\n        }\n    }\n\n    public long getLong(int row, int column) {\n        long rowObj = getRowUnsafe(row);\n        if (rowObj == 0)\n            throw new IllegalStateException(\"Couldn't read row \" + row + \", column \" + column\n                    + \" from ChunkedCursorWindow.\");\n        try {\n            return nativeGetLong(rowObj, column);\n        } finally {\n            endRowUnsafe(rowObj);\n        }\n    }\n\n    public double getDouble(int row, int column) {\n        long rowObj = getRowUnsafe(row);\n        if (rowObj == 0)\n            throw new IllegalStateException(\"Couldn't read row \" + row + \", column \" + column\n                    + \" from ChunkedCursorWindow.\");\n        try {\n            return nativeGetDouble(rowObj, column);\n        } finally {\n            endRowUnsafe(rowObj);\n        }\n    }\n\n\n    private static native long nativeCreate(int capacity);\n    private static native void nativeDispose(long windowPtr);\n    private static native void nativeClear(long windowPtr);\n    private static native long nativeRemoveChunk(long windowPtr, int pos);\n    private static native int nativeGetNumChunks(long windowPtr);\n    private static native boolean nativeSetNumColumns(long windowPtr, int columnNum);\n\n    private static native long nativeGetRow(long windowPtr, int pos);\n    private static native void nativeEndRow(long windowPtr, long rowPtr);\n    private static native int nativeGetType(long rowPtr, int column);\n    private static native byte[] nativeGetBlob(long rowPtr, int column);\n    private static native String nativeGetString(long rowPtr, int column);\n    private static native long nativeGetLong(long rowPtr, int column);\n    private static native double nativeGetDouble(long rowPtr, int column);\n}\n"
  },
  {
    "path": "deprecated/android/wcdb/src/com/tencent/wcdb/database/DatabaseObjectNotClosedException.java",
    "content": "/*\n * Copyright (C) 2006 The Android Open Source Project\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdb.database;\n\n/**\n * An exception that indicates that garbage-collector is finalizing a database object\n * that is not explicitly closed\n * @hide\n */\n@SuppressWarnings(\"serial\")\npublic class DatabaseObjectNotClosedException extends RuntimeException {\n    private static final String s = \"Application did not close the cursor or database object \" +\n            \"that was opened here\";\n\n    public DatabaseObjectNotClosedException() {\n        super(s);\n    }\n    \n}\n"
  },
  {
    "path": "deprecated/android/wcdb/src/com/tencent/wcdb/database/SQLiteAbortException.java",
    "content": "/*\n * Copyright (C) 2008 The Android Open Source Project\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdb.database;\n\n/**\n * An exception that indicates that the SQLite program was aborted.\n * This can happen either through a call to ABORT in a trigger,\n * or as the result of using the ABORT conflict clause.\n */\n@SuppressWarnings(\"serial\")\npublic class SQLiteAbortException extends SQLiteException {\n    public SQLiteAbortException() {}\n\n    public SQLiteAbortException(String error) {\n        super(error);\n    }\n    \n}\n"
  },
  {
    "path": "deprecated/android/wcdb/src/com/tencent/wcdb/database/SQLiteAccessPermException.java",
    "content": "/*\n * Copyright (C) 2010 The Android Open Source Project\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdb.database;\n\n/**\n * This exception class is used when sqlite can't access the database file\n * due to lack of permissions on the file.\n */\n@SuppressWarnings(\"serial\")\npublic class SQLiteAccessPermException extends SQLiteException {\n    public SQLiteAccessPermException() {}\n\n    public SQLiteAccessPermException(String error) {\n        super(error);\n    }\n}\n"
  },
  {
    "path": "deprecated/android/wcdb/src/com/tencent/wcdb/database/SQLiteAsyncCheckpointer.java",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdb.database;\n\nimport android.os.Handler;\nimport android.os.HandlerThread;\nimport android.os.Looper;\nimport android.os.Message;\nimport android.os.SystemClock;\nimport android.util.Pair;\n\nimport java.util.HashSet;\n\n\npublic class SQLiteAsyncCheckpointer implements SQLiteCheckpointListener, Handler.Callback {\n\n    private Looper mLooper;\n    private Handler mHandler;\n    private boolean mUseDefaultLooper;\n    private int mThreshold;\n    private int mBlockingThreshold;\n    private int mLastSyncMode;\n    private final HashSet<Pair<SQLiteDatabase, String>> mPendingCheckpoints;\n\n    private static final int DEFAULT_THRESHOLD = 100;\n    private static final int DEFAULT_BLOCKING_THRESHOLD = 300;\n\n\n    public SQLiteAsyncCheckpointer() {\n        this(null, DEFAULT_THRESHOLD, DEFAULT_BLOCKING_THRESHOLD);\n    }\n\n    public SQLiteAsyncCheckpointer(Looper looper) {\n        this(looper, DEFAULT_THRESHOLD, DEFAULT_BLOCKING_THRESHOLD);\n    }\n\n    public SQLiteAsyncCheckpointer(Looper looper, int threshold, int blockingThreshold) {\n        mLooper = looper;\n        mThreshold = threshold;\n        mBlockingThreshold = blockingThreshold;\n        mPendingCheckpoints = new HashSet<>();\n    }\n\n    @Override\n    public void onAttach(SQLiteDatabase db) {\n        if (mLooper == null) {\n            mLooper = acquireDefaultLooper();\n            mUseDefaultLooper = true;\n        }\n\n        mHandler = new Handler(mLooper, this);\n\n        mLastSyncMode = db.getSynchronousMode();\n        db.setSynchronousMode(SQLiteDatabase.SYNCHRONOUS_NORMAL);\n    }\n\n    @Override\n    public void onWALCommit(SQLiteDatabase db, String dbName, int pages) {\n\n        if (pages < mThreshold)\n            return;\n        boolean blockWriting = pages >= mBlockingThreshold;\n\n        Pair<SQLiteDatabase, String> p = new Pair<>(db, dbName);\n\n        boolean newTask;\n        synchronized (mPendingCheckpoints) {\n            newTask = mPendingCheckpoints.add(p);\n        }\n        if (!newTask)\n            return;\n\n        db.acquireReference();\n        Message msg = mHandler.obtainMessage(0, blockWriting ? 1 : 0, 0, p);\n        mHandler.sendMessage(msg);\n    }\n\n    @Override\n    public void onDetach(SQLiteDatabase db) {\n        db.setSynchronousMode(mLastSyncMode);\n        mHandler = null;\n\n        if (mUseDefaultLooper) {\n            mLooper = null;\n            releaseDefaultLooper();\n            mUseDefaultLooper = false;\n        }\n    }\n\n    @Override\n    @SuppressWarnings(\"unchecked\")\n    public boolean handleMessage(Message msg) {\n        Pair<SQLiteDatabase, String> p = (Pair<SQLiteDatabase, String>) msg.obj;\n        SQLiteDatabase db = p.first;\n        String dbName = p.second;\n        boolean blockWriting = msg.arg1 != 0;\n\n        try {\n            long time = SystemClock.uptimeMillis();\n            Pair<Integer, Integer> result = db.walCheckpoint(dbName, blockWriting);\n            int walPages = result.first;\n            int checkpointedPages = result.second;\n\n            time = SystemClock.uptimeMillis() - time;\n            onCheckpointResult(db, walPages, checkpointedPages, time);\n        } finally {\n            db.releaseReference();\n        }\n\n        synchronized (mPendingCheckpoints) {\n            if (!mPendingCheckpoints.remove(p))\n                throw new AssertionError(\"mPendingCheckpoints.remove(p)\");\n        }\n\n        return true;\n    }\n\n    protected void onCheckpointResult(SQLiteDatabase db, int walPages, int checkpointedPages,\n                                      long time) {\n        // implemented by the derived class\n    }\n\n\n    private static Looper acquireDefaultLooper() {\n        synchronized (gDefaultThreadLock) {\n            if (gDefaultThreadRefCount++ == 0) {\n                // Initialize default handler thread.\n                if (gDefaultThread != null)\n                    throw new AssertionError(\"gDefaultThread == null\");\n\n                gDefaultThread = new HandlerThread(\"WCDB.AsyncCheckpointer\", 4);\n                gDefaultThread.start();\n            }\n\n            return gDefaultThread.getLooper();\n        }\n    }\n\n    private static void releaseDefaultLooper() {\n        synchronized (gDefaultThreadLock) {\n            if (--gDefaultThreadRefCount <= 0) {\n                if (gDefaultThreadRefCount < 0)\n                    throw new AssertionError(\"gDefaultThreadRefCount == 0\");\n\n                gDefaultThread.quit();\n                gDefaultThread = null;\n            }\n        }\n    }\n\n    private static HandlerThread gDefaultThread;\n    private static final Object gDefaultThreadLock = new Object();\n    private static int gDefaultThreadRefCount = 0;\n}\n"
  },
  {
    "path": "deprecated/android/wcdb/src/com/tencent/wcdb/database/SQLiteAsyncCursor.java",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdb.database;\n\nimport com.tencent.wcdb.AbstractCursor;\nimport com.tencent.wcdb.BuildConfig;\nimport com.tencent.wcdb.Cursor;\nimport com.tencent.wcdb.CursorIndexOutOfBoundsException;\nimport com.tencent.wcdb.StaleDataException;\nimport com.tencent.wcdb.support.CancellationSignal;\n\n\n/**\n * Cursor that runs query on another thread. Under development.\n * @hide\n */\npublic class SQLiteAsyncCursor extends AbstractCursor {\n\n    private static final String TAG = \"WCDB.SQLiteAsyncCursor\";\n\n    private static final int MIN_FETCH_ROWS = 32;\n    private static final int MAX_PREFETCH = 256;\n    private static final int MAX_KEEP_CHUNKS = 32;\n\n\n    private final SQLiteAsyncQuery mQuery;\n    private final SQLiteCursorDriver mDriver;\n    private final String[] mColumns;\n\n    private ChunkedCursorWindow mWindow;\n    private long mCurrentRow;\n    private volatile int mCount;\n\n    private final Object mWaitLock;\n\n    private QueryThread mQueryThread;\n\n\n    public SQLiteAsyncCursor(SQLiteCursorDriver driver, String editTable, SQLiteAsyncQuery query) {\n        if (query == null) {\n            throw new IllegalArgumentException(\"query object cannot be null\");\n        }\n\n        mQuery = query;\n        mDriver = driver;\n        mColumns = query.getColumnNames();\n\n        mCount = -1;\n\n        mWaitLock = new Object();\n        mWindow = new ChunkedCursorWindow(16 * 1024 * 1024);\n        mQueryThread = new QueryThread();\n        mQueryThread.start();\n    }\n\n    @Override\n    public void close() {\n        super.close();\n\n        mQuery.close();\n        mDriver.cursorClosed();\n    }\n\n    @Override\n    public void deactivate() {\n        super.deactivate();\n        mDriver.cursorDeactivated();\n    }\n\n    @Override\n    protected void onDeactivateOrClose() {\n        if (mCurrentRow != 0) {\n            mWindow.endRowUnsafe(mCurrentRow);\n            mCurrentRow = 0;\n        }\n\n        if (mQueryThread != null) {\n            mQueryThread.quit();\n            try {\n                mQueryThread.join();\n            } catch (InterruptedException e) {\n                // ignored\n            }\n            mQueryThread = null;\n        }\n\n        if (mWindow != null) {\n            mWindow.close();\n            mWindow = null;\n        }\n\n        mCount = -1;\n        mPos = -1;\n        super.onDeactivateOrClose();\n    }\n\n    @Override\n    public String[] getColumnNames() {\n        return mColumns;\n    }\n\n    @Override\n    public int getCount() {\n        if (mCount >= 0) return mCount;\n        if (mWindow == null) return -1;\n\n        try {\n            synchronized (mWaitLock) {\n                while (mCount < 0)\n                    mWaitLock.wait();\n            }\n        } catch (InterruptedException e) {\n            // do nothing\n        }\n        return mCount;\n    }\n\n\n    private boolean isValidPosition(int pos) {\n        return pos >= 0 && pos < getCount();\n    }\n\n    private long waitForRow(int pos) {\n        try {\n            synchronized (mWaitLock) {\n                long result;\n                while ((result = mWindow.getRowUnsafe(pos)) == 0) {\n                    // Add myself to waiter list and wait for notice, until row is\n                    // successfully got, or end of result is reached.\n                    if (!isValidPosition(pos)) {\n                        throw new CursorIndexOutOfBoundsException(mPos, mCount);\n                    }\n\n                    mWaitLock.wait();\n                }\n                return result;\n            }\n        } catch (InterruptedException e) {\n            // XXX: when thread is interrupted, should we continue waiting or just return failure?\n            return 0;\n        }\n    }\n\n    private boolean requestRow() {\n        if (mWindow == null)\n            return false;\n\n        if (BuildConfig.DEBUG && mCurrentRow != 0)\n            throw new AssertionError(\"mCurrentRow == 0\");\n\n        if (!isValidPosition(mPos))\n            return false;\n\n        mQueryThread.requestPos(mPos);\n        mCurrentRow = mWindow.getRowUnsafe(mPos);\n        if (mCurrentRow == 0) {\n            mCurrentRow = waitForRow(mPos);\n        }\n\n        return mCurrentRow != 0;\n    }\n\n    private void checkValidRow() {\n        if (mCurrentRow != 0) return;\n\n        if (!isValidPosition(mPos))\n            throw new CursorIndexOutOfBoundsException(mPos, mCount);\n        else\n            throw new StaleDataException(\"Cannot get valid Row object\");\n    }\n\n    @Override\n    public boolean moveToPosition(int position) {\n        if (position < -1)\n            position = -1;\n\n        // If position changed, release old Row object.\n        if (position != mPos) {\n            mWindow.endRowUnsafe(mCurrentRow);\n            mCurrentRow = 0;\n        }\n\n        int count = getCount();\n        if (position >= count) {\n            mPos = count;\n            return false;\n        } else {\n            mPos = position;\n            return position >= 0 && requestRow();\n        }\n    }\n\n    @Override\n    public int getType(int column) {\n        checkValidRow();\n        return mWindow.getTypeUnsafe(mCurrentRow, column);\n    }\n\n    @Override\n    public byte[] getBlob(int column) {\n        checkValidRow();\n        return mWindow.getBlobUnsafe(mCurrentRow, column);\n    }\n\n    @Override\n    public String getString(int column) {\n        checkValidRow();\n        return mWindow.getStringUnsafe(mCurrentRow, column);\n    }\n\n    @Override\n    public short getShort(int column) {\n        return (short) getLong(column);\n    }\n\n    @Override\n    public int getInt(int column) {\n        return (int) getLong(column);\n    }\n\n    @Override\n    public long getLong(int column) {\n        checkValidRow();\n        return mWindow.getLongUnsafe(mCurrentRow, column);\n    }\n\n    @Override\n    public float getFloat(int column) {\n        return (float) getDouble(column);\n    }\n\n    @Override\n    public double getDouble(int column) {\n        checkValidRow();\n        return mWindow.getDoubleUnsafe(mCurrentRow, column);\n    }\n\n    @Override\n    public boolean isNull(int column) {\n        return getType(column) == FIELD_TYPE_NULL;\n    }\n\n\n    private class QueryThread extends Thread {\n\n        private volatile int mRequestPos;\n        private int mFetchPos;\n        private int mMinPos;\n\n\n        QueryThread() {\n            super(\"SQLiteAsyncCursor.QueryThread\");\n\n            mRequestPos = 0;\n            mMinPos = 0;\n            mFetchPos = 0;\n        }\n\n        @Override\n        public void run() {\n\n            try {\n                // Iterate to get row count, then notify the main thread.\n                int count = mQuery.getCount();\n                synchronized (mWaitLock) {\n                    mCount = count;\n                    mWaitLock.notifyAll();\n                }\n\n                while (!interrupted()) {\n\n                    int pos;\n                    int targetPos;\n                    synchronized (this) {\n                        while (mRequestPos + MAX_PREFETCH <= mFetchPos && mRequestPos >= mMinPos)\n                            this.wait();\n\n                        pos = mRequestPos;\n                        targetPos = pos + MAX_PREFETCH;\n                    }\n\n                    // If backward position is forced, we have to rewind the native cursor.\n                    if (pos < mMinPos) {\n                        mQuery.reset();\n                        mFetchPos = 0;\n\n                        // XXX: It's better to keep some data here.\n                        mWindow.clear();\n                        mMinPos = 0;\n                    }\n\n                    if (mFetchPos < targetPos) {\n                        // Drop some chunks if we used up quota.\n                        if (mWindow.getNumChunks() > MAX_KEEP_CHUNKS) {\n                            long result = mWindow.removeChunk(mMinPos);\n                            if (result != ChunkedCursorWindow.CHUNK_NOT_FOUND) {\n                                mMinPos = (int) result;\n                            }\n                        }\n\n                        // Fill some rows.\n                        synchronized (mWaitLock) {\n                            count = mQuery.fillRows(mWindow, mFetchPos, MIN_FETCH_ROWS);\n\n                            // Signal the main thread if we just passed the requested position.\n                            if (mFetchPos <= pos && mFetchPos + count > pos) {\n                                mWaitLock.notifyAll();\n                            }\n                        }\n\n                        mFetchPos += count;\n                    }\n                }\n            } catch (InterruptedException e) {\n                // do nothing.\n            } finally {\n                mQuery.release();\n            }\n        }\n\n        void requestPos(int pos) {\n            synchronized (this) {\n                mRequestPos = pos;\n                this.notifyAll();\n            }\n        }\n\n        void quit() {\n            interrupt();\n        }\n    }\n\n\n    public static final SQLiteDatabase.CursorFactory FACTORY = new SQLiteDatabase.CursorFactory() {\n        @Override\n        public Cursor newCursor(SQLiteDatabase db, SQLiteCursorDriver masterQuery,\n                String editTable, SQLiteProgram query) {\n            return new SQLiteAsyncCursor(masterQuery, editTable, (SQLiteAsyncQuery) query);\n        }\n\n        @Override\n        public SQLiteProgram newQuery(SQLiteDatabase db, String query, Object[] bindArgs,\n                CancellationSignal cancellationSignalForPrepare) {\n            return new SQLiteAsyncQuery(db, query, bindArgs, cancellationSignalForPrepare);\n        }\n    };\n}\n"
  },
  {
    "path": "deprecated/android/wcdb/src/com/tencent/wcdb/database/SQLiteAsyncQuery.java",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdb.database;\n\n\nimport com.tencent.wcdb.support.CancellationSignal;\nimport com.tencent.wcdb.support.Log;\n\n\n/**\n * Query object used by {@link SQLiteAsyncCursor}. Under development.\n *\n * @hide\n */\npublic class SQLiteAsyncQuery extends SQLiteProgram {\n\n    private static final String TAG = \"WCDB.SQLiteAsyncQuery\";\n    private final int mResultColumns;\n\n\n    public SQLiteAsyncQuery(SQLiteDatabase db, String query, Object[] bindArgs,\n            CancellationSignal cancellationSignal) {\n        super(db, query, bindArgs, cancellationSignal);\n\n        mResultColumns = getColumnNames().length;\n    }\n\n    void acquire() {\n        if (mPreparedStatement == null) {\n            acquirePreparedStatement(true);\n            mPreparedStatement.bindArguments(getBindArgs());\n        }\n    }\n\n    void release() {\n        releasePreparedStatement();\n    }\n\n    int fillRows(ChunkedCursorWindow window, int startPos, int count) {\n\n        // Ensure prepared statement is acquired.\n        acquire();\n\n        // Check whether number of columns has been set.\n        if (window.getNumColumns() != mResultColumns) {\n            window.setNumColumns(mResultColumns);\n        }\n\n        try {\n            return nativeFillRows(mPreparedStatement.getPtr(), window.mWindowPtr, startPos, count);\n        } catch (SQLiteException e) {\n            Log.e(TAG, \"Got exception on fillRows: \" + e.getMessage() + \", SQL: \" + getSql());\n            checkCorruption(e);\n            throw e;\n        }\n    }\n\n    int getCount() {\n        // Ensure prepared statement is acquired.\n        acquire();\n\n        try {\n            return nativeCount(mPreparedStatement.getPtr());\n        } catch (SQLiteException e) {\n            Log.e(TAG, \"Got exception on getCount: \" + e.getMessage() + \", SQL: \" + getSql());\n            checkCorruption(e);\n            throw e;\n        }\n    }\n\n    void reset() {\n        if (mPreparedStatement != null)\n            mPreparedStatement.reset(false);\n    }\n\n    private static native int nativeFillRows(long statementPtr, long windowPtr, int startPos, int count);\n    private static native int nativeCount(long statementPtr);\n}\n"
  },
  {
    "path": "deprecated/android/wcdb/src/com/tencent/wcdb/database/SQLiteBindOrColumnIndexOutOfRangeException.java",
    "content": "/*\n * Copyright (C) 2010 The Android Open Source Project\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdb.database;\n\n/**\n * Thrown if the the bind or column parameter index is out of range\n */\n@SuppressWarnings(\"serial\")\npublic class SQLiteBindOrColumnIndexOutOfRangeException extends SQLiteException {\n    public SQLiteBindOrColumnIndexOutOfRangeException() {}\n\n    public SQLiteBindOrColumnIndexOutOfRangeException(String error) {\n        super(error);\n    }\n}\n"
  },
  {
    "path": "deprecated/android/wcdb/src/com/tencent/wcdb/database/SQLiteBlobTooBigException.java",
    "content": "/*\n * Copyright (C) 2010 The Android Open Source Project\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdb.database;\n\n@SuppressWarnings(\"serial\")\npublic class SQLiteBlobTooBigException extends SQLiteException {\n    public SQLiteBlobTooBigException() {}\n\n    public SQLiteBlobTooBigException(String error) {\n        super(error);\n    }\n}\n"
  },
  {
    "path": "deprecated/android/wcdb/src/com/tencent/wcdb/database/SQLiteCantOpenDatabaseException.java",
    "content": "/*\n * Copyright (C) 2010 The Android Open Source Project\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdb.database;\n\n@SuppressWarnings(\"serial\")\npublic class SQLiteCantOpenDatabaseException extends SQLiteException {\n    public SQLiteCantOpenDatabaseException() {}\n\n    public SQLiteCantOpenDatabaseException(String error) {\n        super(error);\n    }\n}\n"
  },
  {
    "path": "deprecated/android/wcdb/src/com/tencent/wcdb/database/SQLiteChangeListener.java",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdb.database;\n\n/**\n * Listener interface for database change notifications.\n */\npublic interface SQLiteChangeListener {\n\n    /**\n     * Called when transactions are committed and some of rows in the database\n     * is inserted, updated or deleted.\n     *\n     * When a transaction modifies more than one table, this method will be\n     * called multiple times with different arguments.\n     *\n     * It's possible that multiple threads call this method concurrently, so\n     * the implementation must be thread-safe.\n     *\n     * @param db        database object whose tables were changed\n     * @param dbName    attached database name of the changed table, \"main\" for the main database\n     * @param table     name of the changed table\n     * @param insertIds array of rowIDs of the rows inserted, or null if rowID trace is disabled\n     * @param updateIds array of rowIDs of the rows updated, or null if rowID trace is disabled\n     * @param deleteIds array of rowIDs of the rows deleted, or null if rowID trace is disabled\n     */\n    void onChange(SQLiteDatabase db, String dbName, String table,\n            long[] insertIds, long[] updateIds, long[] deleteIds);\n}\n"
  },
  {
    "path": "deprecated/android/wcdb/src/com/tencent/wcdb/database/SQLiteCheckpointListener.java",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdb.database;\n\n/**\n * A listener for WAL checkpointing.\n */\npublic interface SQLiteCheckpointListener {\n\n    /**\n     * Called immediately when this listener is set to the database. Initialization codes\n     * can be placed here, if any.\n     *\n     * @param db database object to be attached\n     */\n    void onAttach(SQLiteDatabase db);\n\n    /**\n     * Called immediately when a WAL transaction has been committed.\n     *\n     * <p>The implementation should checkpoint the database according to its strategy by executing\n     * SQL {@code PRAGMA wal_checkpoint;} or something alike. Failing to do this will result in\n     * unlimited growing WAL file and may degrade performance.</p>\n     *\n     * @param db     database object whose transaction is committed\n     * @param dbName attached database name of the committed transaction, or \"main\" for the\n     *               main database\n     * @param pages  number of frames in the WAL file after commit\n     */\n    void onWALCommit(SQLiteDatabase db, String dbName, int pages);\n\n    /**\n     * Called immediately when this listener is detached from the database. Cleanup codes\n     * can be placed here, if any.\n     *\n     * @param db database object to be detached from\n     */\n    void onDetach(SQLiteDatabase db);\n}\n"
  },
  {
    "path": "deprecated/android/wcdb/src/com/tencent/wcdb/database/SQLiteCipherSpec.java",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdb.database;\n\nimport com.tencent.wcdb.DatabaseErrorHandler;\n\n/**\n * Describes encryption options for SQLite databases.\n *\n * @see SQLiteDatabase#openDatabase(String, byte[], SQLiteCipherSpec, SQLiteDatabase.CursorFactory, int, DatabaseErrorHandler, int)\n */\npublic class SQLiteCipherSpec {\n\n    public static final int HMAC_DEFAULT = -1;\n    public static final int HMAC_SHA1 = 0;\n    public static final int HMAC_SHA256 = 1;\n    public static final int HMAC_SHA512 = 2;\n\n    /**\n     * KDF iteration times to generate encryption keys, 0 for default value.\n     *\n     * <p>Typical values are 4000 for SQLCipher version 1.x and 2.x, 64000 for\n     * version 3.x. For databases created by WCDB itself, leave it 0.</p>\n     */\n    public int kdfIteration;\n\n    /**\n     * Whether HMAC should be used.\n     *\n     * <p>Defaulted to {@code false} for SQLCipher 1.x, and {@code true} otherwise.\n     * Must be set to the same value as when the database is created, or the database\n     * cannot be opened and {@link SQLiteException} is thrown.</p>\n     */\n    public boolean hmacEnabled = true;\n\n    /**\n     * Which algorithm should be used in HMAC.\n     *\n     * <p>Defaulted to {@code HMAC_SHA1} for SQLCipher 3.x and below, {@code HMAC_SHA512}\n     * for 4.x. Must be set to the same value as when the database is created, or the database\n     * cannot be opened and {@link SQLiteException} is thrown.</p>\n     */\n    public int hmacAlgorithm = HMAC_DEFAULT;\n\n    /**\n     * Which algorithm should be used in key derivation.\n     *\n     * <p>Defaulted to {@code HMAC_SHA1} for SQLCipher 3.x and below, {@code HMAC_SHA512}\n     * for 4.x. Must be set to the same value as when the database is created, or the database\n     * cannot be opened and {@link SQLiteException} is thrown.</p>\n     */\n    public int kdfAlgorithm = HMAC_DEFAULT;\n\n    /**\n     * Page size to use.\n     *\n     * <p>Page size must be set to the same value as when the database is created, in order to\n     * open existing encrypted database. For databases created by WCDB itself, leave it to\n     * the default is preferred for most applications. If database cannot be opened and\n     * {@link SQLiteException} is thrown, try setting it to 1024 or 4096.\n     * </p>\n     */\n    public int pageSize = SQLiteGlobal.defaultPageSize;\n\n    /**\n     * Create a new object with default values.\n     */\n    public SQLiteCipherSpec() {\n    }\n\n    /**\n     * Create a new object as a copy of an existed one.\n     *\n     * @param rhs   The object to be copied\n     */\n    public SQLiteCipherSpec(SQLiteCipherSpec rhs) {\n        kdfIteration = rhs.kdfIteration;\n        hmacEnabled = rhs.hmacEnabled;\n        pageSize = rhs.pageSize;\n    }\n\n    /**\n     * Set KDF iteration times to be used.\n     *\n     * @param iter  New iteration times value\n     * @return      This object to allow for chaining of calls to set methods\n     * @see #kdfIteration\n     */\n    public SQLiteCipherSpec setKDFIteration(int iter) {\n        kdfIteration = iter; return this;\n    }\n\n    /**\n     * Set whether to use HMAC in encryption. Default to true.\n     *\n     * @param enabled   Whether to use HMAC\n     * @return          This object to allow for chaining of calls to set methods\n     * @see #hmacEnabled\n     */\n    public SQLiteCipherSpec withHMACEnabled(boolean enabled) {\n        hmacEnabled = enabled; return this;\n    }\n\n    /**\n     * Set algorithm to be used in HMAC.\n     * @param algo Algorithm defined by {@code HMAC_*}\n     * @return This object to allow for chaining of calls to set methods\n     * @see #hmacAlgorithm\n     */\n    public SQLiteCipherSpec setHmacAlgorithm(int algo) {\n        hmacAlgorithm = algo; return this;\n    }\n\n    /**\n     * Set algorithm to be used in PBKDF.\n     * @param algo Algorithm defined by {@code HMAC_*}\n     * @return This object to allow for chaining of calls to set methods\n     * @see #kdfAlgorithm\n     */\n    public SQLiteCipherSpec setKdfAlgorithm(int algo) {\n        kdfAlgorithm = algo; return this;\n    }\n\n    /**\n     * Set the page size to use. The page size should be a power of two.\n     *\n     * @param size  Page size in byte\n     * @return      This object to allow for chaining of calls to set methods\n     * @see #pageSize\n     */\n    public SQLiteCipherSpec setPageSize(int size) {\n        pageSize = size; return this;\n    }\n\n    /**\n     * Set SQLCipher version compatibility. The version should be 1-4 which\n     * represent SQLCipher 1.x to 4.x. This method overwrites HMAC and KDF\n     * iteration settings.\n     *\n     * @param version   SQLCipher version, should be within 1 to 4\n     * @return          This object to allow for chaining of calls to set methods\n     * @see #kdfIteration\n     * @see #hmacEnabled\n     * @see #hmacAlgorithm\n     * @see #kdfAlgorithm\n     */\n    public SQLiteCipherSpec setSQLCipherVersion(int version) {\n        switch (version) {\n            case 1:\n                hmacEnabled = false;\n                kdfIteration = 4000;\n                hmacAlgorithm = HMAC_SHA1;\n                kdfAlgorithm = HMAC_SHA1;\n                break;\n            case 2:\n                hmacEnabled = true;\n                kdfIteration = 4000;\n                hmacAlgorithm = HMAC_SHA1;\n                kdfAlgorithm = HMAC_SHA1;\n                break;\n            case 3:\n                hmacEnabled = true;\n                kdfIteration = 64000;\n                hmacAlgorithm = HMAC_SHA1;\n                kdfAlgorithm = HMAC_SHA1;\n                break;\n            case 4:\n                hmacEnabled = true;\n                kdfIteration = 256000;\n                hmacAlgorithm = HMAC_SHA512;\n                kdfAlgorithm = HMAC_SHA512;\n                break;\n            default:\n                throw new IllegalArgumentException(\"Unsupported SQLCipher version: \" + version);\n        }\n        return this;\n    }\n}\n"
  },
  {
    "path": "deprecated/android/wcdb/src/com/tencent/wcdb/database/SQLiteClosable.java",
    "content": "/*\n * Copyright (C) 2007 The Android Open Source Project\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdb.database;\n\nimport java.io.Closeable;\nimport java.util.concurrent.atomic.AtomicInteger;\n\n/**\n * An object created from a SQLiteDatabase that can be closed.\n *\n * This class implements a primitive reference counting scheme for database objects.\n */\npublic abstract class SQLiteClosable implements Closeable {\n    private int mReferenceCount = 1;\n\n    /**\n     * Called when the last reference to the object was released by\n     * a call to {@link #releaseReference()} or {@link #close()}.\n     */\n    protected abstract void onAllReferencesReleased();\n\n    /**\n     * Called when the last reference to the object was released by\n     * a call to {@link #releaseReferenceFromContainer()}.\n     *\n     * @deprecated Do not use.\n     */\n    @Deprecated\n    protected void onAllReferencesReleasedFromContainer() {\n        onAllReferencesReleased();\n    }\n\n    /**\n     * Acquires a reference to the object.\n     *\n     * @throws IllegalStateException if the last reference to the object has already\n     * been released.\n     */\n    public void acquireReference() {\n        synchronized (this) {\n            if (mReferenceCount <= 0) {\n                throw new IllegalStateException(\n                        \"attempt to re-open an already-closed object: \" + this);\n            }\n            mReferenceCount++;\n        }\n    }\n\n    /**\n     * Releases a reference to the object, closing the object if the last reference\n     * was released.\n     *\n     * @see #onAllReferencesReleased()\n     */\n    public void releaseReference() {\n        boolean refCountIsZero;\n        synchronized (this) {\n            refCountIsZero = --mReferenceCount == 0;\n        }\n        if (refCountIsZero) {\n            onAllReferencesReleased();\n        }\n    }\n\n    /**\n     * Releases a reference to the object that was owned by the container of the object,\n     * closing the object if the last reference was released.\n     *\n     * @see #onAllReferencesReleasedFromContainer()\n     * @deprecated Do not use.\n     */\n    @Deprecated\n    public void releaseReferenceFromContainer() {\n        boolean refCountIsZero;\n        synchronized (this) {\n            refCountIsZero = --mReferenceCount == 0;\n        }\n        if (refCountIsZero) {\n            onAllReferencesReleased();\n        }\n    }\n\n    /**\n     * Releases a reference to the object, closing the object if the last reference\n     * was released.\n     *\n     * Calling this method is equivalent to calling {@link #releaseReference}.\n     *\n     * @see #releaseReference()\n     * @see #onAllReferencesReleased()\n     */\n    public void close() {\n        releaseReference();\n    }\n}\n"
  },
  {
    "path": "deprecated/android/wcdb/src/com/tencent/wcdb/database/SQLiteConnection.java",
    "content": "/*\n * Copyright (C) 2011 The Android Open Source Project\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdb.database;\n\n\nimport android.annotation.SuppressLint;\nimport android.os.Process;\nimport android.util.Pair;\nimport android.util.Printer;\n\nimport com.tencent.wcdb.BuildConfig;\nimport com.tencent.wcdb.Cursor;\nimport com.tencent.wcdb.CursorWindow;\nimport com.tencent.wcdb.DatabaseUtils;\nimport com.tencent.wcdb.database.SQLiteDebug.DbStats;\nimport com.tencent.wcdb.extension.SQLiteExtension;\nimport com.tencent.wcdb.support.CancellationSignal;\nimport com.tencent.wcdb.support.Log;\nimport com.tencent.wcdb.support.LruCache;\nimport com.tencent.wcdb.support.OperationCanceledException;\n\nimport org.json.JSONArray;\nimport org.json.JSONException;\nimport org.json.JSONObject;\n\nimport java.lang.ref.WeakReference;\nimport java.text.SimpleDateFormat;\nimport java.util.ArrayList;\nimport java.util.Date;\nimport java.util.Map;\nimport java.util.regex.Pattern;\n\n/**\n * Represents a SQLite database connection.\n * Each connection wraps an instance of a native <code>sqlite3</code> object.\n * <p>\n * When database connection pooling is enabled, there can be multiple active\n * connections to the same database.  Otherwise there is typically only one\n * connection per database.\n * </p><p>\n * When the SQLite WAL feature is enabled, multiple readers and one writer\n * can concurrently access the database.  Without WAL, readers and writers\n * are mutually exclusive.\n * </p>\n * <p/>\n * <h2>Ownership and concurrency guarantees</h2>\n * <p>\n * Connection objects are not thread-safe.  They are acquired as needed to\n * perform a database operation and are then returned to the pool.  At any\n * given time, a connection is either owned and used by a {@link SQLiteSession}\n * object or the {@link SQLiteConnectionPool}.  Those classes are\n * responsible for serializing operations to guard against concurrent\n * use of a connection.\n * </p><p>\n * The guarantee of having a single owner allows this class to be implemented\n * without locks and greatly simplifies resource management.\n * </p>\n * <p/>\n * <h2>Encapsulation guarantees</h2>\n * <p>\n * The connection object object owns *all* of the SQLite related native\n * objects that are associated with the connection.  What's more, there are\n * no other objects in the system that are capable of obtaining handles to\n * those native objects.  Consequently, when the connection is closed, we do\n * not have to worry about what other components might have references to\n * its associated SQLite state -- there are none.\n * </p><p>\n * Encapsulation is what ensures that the connection object's\n * lifecycle does not become a tortured mess of finalizers and reference\n * queues.\n * </p>\n * <p/>\n * <h2>Reentrance</h2>\n * <p>\n * This class must tolerate reentrant execution of SQLite operations because\n * triggers may call custom SQLite functions that perform additional queries.\n * </p>\n *\n * @hide\n */\npublic final class SQLiteConnection implements CancellationSignal.OnCancelListener {\n    private static final String TAG = \"WCDB.SQLiteConnection\";\n    private static final boolean DEBUG = false;\n\n    private static final String[] EMPTY_STRING_ARRAY = new String[0];\n    private static final byte[] EMPTY_BYTE_ARRAY = new byte[0];\n\n    private static final Pattern TRIM_SQL_PATTERN = Pattern.compile(\"[\\\\s]*\\\\n+[\\\\s]*\");\n\n    private final SQLiteConnectionPool mPool;\n    private final SQLiteDatabaseConfiguration mConfiguration;\n    private final int mConnectionId;\n    private final boolean mIsPrimaryConnection;\n    private final boolean mIsReadOnlyConnection;\n    private final PreparedStatementCache mPreparedStatementCache;\n    private PreparedStatement mPreparedStatementPool;\n\n    // The recent operations log.\n    private final OperationLog mRecentOperations = new OperationLog();\n    private Thread mAcquiredThread;\n    private int mAcquiredTid;\n    private StackTraceElement[] mAcquiredStack;\n    private long mAcquiredTimestamp;\n\n    // The native SQLiteConnection pointer.  (FOR INTERNAL USE ONLY)\n    private long mConnectionPtr;\n\n    private boolean mOnlyAllowReadOnlyOperations;\n\n    // The number of times attachCancellationSignal has been called.\n    // Because SQLite statement execution can be reentrant, we keep track of how many\n    // times we have attempted to attach a cancellation signal to the connection so that\n    // we can ensure that we detach the signal at the right time.\n    private int mCancellationSignalAttachCount;\n\n    private native long nativeOpen(String path, int openFlags, String vfsName);\n    private static native void nativeClose(long connectionPtr);\n    private static native void nativeRegisterCustomFunction(long connectionPtr,\n            SQLiteCustomFunction function);\n    private static native void nativeRegisterLocalizedCollators(long connectionPtr, String locale);\n    private static native long nativePrepareStatement(long connectionPtr, String sql);\n    private static native void nativeFinalizeStatement(long connectionPtr, long statementPtr);\n    private static native int nativeGetParameterCount(long connectionPtr, long statementPtr);\n    private static native boolean nativeIsReadOnly(long connectionPtr, long statementPtr);\n    private static native int nativeGetColumnCount(long connectionPtr, long statementPtr);\n    private static native String nativeGetColumnName(long connectionPtr, long statementPtr,\n            int index);\n    private static native void nativeBindNull(long connectionPtr, long statementPtr,\n            int index);\n    private static native void nativeBindLong(long connectionPtr, long statementPtr,\n            int index, long value);\n    private static native void nativeBindDouble(long connectionPtr, long statementPtr,\n            int index, double value);\n    private static native void nativeBindString(long connectionPtr, long statementPtr,\n            int index, String value);\n    private static native void nativeBindBlob(long connectionPtr, long statementPtr,\n            int index, byte[] value);\n    private static native void nativeResetStatement(long connectionPtr, long statementPtr,\n            boolean clearBinding);\n    private static native void nativeExecute(long connectionPtr, long statementPtr);\n    private static native long nativeExecuteForLong(long connectionPtr, long statementPtr);\n    private static native String nativeExecuteForString(long connectionPtr, long statementPtr);\n    private static native int nativeExecuteForChangedRowCount(long connectionPtr, long statementPtr);\n    private static native long nativeExecuteForLastInsertedRowId(long connectionPtr, long statementPtr);\n    private static native long nativeExecuteForCursorWindow(long connectionPtr, long statementPtr,\n            long windowPtr, int startPos, int requiredPos, boolean countAllRows);\n    private static native int nativeGetDbLookaside(long connectionPtr);\n    private static native void nativeCancel(long connectionPtr);\n    private static native void nativeResetCancel(long connectionPtr, boolean cancelable);\n    private static native void nativeSetKey(long connectionPtr, byte[] password);\n    private static native void nativeSetWalHook(long connectionPtr);\n    private static native long nativeWalCheckpoint(long connectionPtr, String dbName);\n    private static native long nativeSQLiteHandle(long connectionPtr, boolean acquire);\n    private static native void nativeSetUpdateNotification(long connectionPtr, boolean enabled,\n            boolean notifyRowId);\n\n    // Password for encrypted database.\n    private byte[] mPassword;\n\n    // Cipher description for encrypted database.\n    private SQLiteCipherSpec mCipher;\n\n    // Operation record for getNativeHandle().\n    private Operation mNativeOperation;\n\n    // Recurse count for getNativeHandle().\n    private int mNativeHandleCount;\n\n\n    private SQLiteConnection(SQLiteConnectionPool pool, SQLiteDatabaseConfiguration configuration,\n            int connectionId, boolean primaryConnection, byte[] password, SQLiteCipherSpec cipher) {\n\n        mPassword = password;\n        mCipher = (cipher == null) ? null : new SQLiteCipherSpec(cipher);\n\n        mPool = pool;\n        mConfiguration = new SQLiteDatabaseConfiguration(configuration);\n        mConnectionId = connectionId;\n        mIsPrimaryConnection = primaryConnection;\n        mIsReadOnlyConnection = (configuration.openFlags & SQLiteDatabase.OPEN_READONLY) != 0;\n        mPreparedStatementCache = new PreparedStatementCache(mConfiguration.maxSqlCacheSize);\n    }\n\n    long getNativeHandle(String operation) {\n        if (mConnectionPtr == 0)\n            return 0;\n\n        if (operation != null && mNativeOperation == null) {\n            mNativeOperation = mRecentOperations.beginOperation(operation, null, null);\n            mNativeOperation.mType = DatabaseUtils.STATEMENT_OTHER;\n        }\n\n        mNativeHandleCount++;\n        return nativeSQLiteHandle(mConnectionPtr, true);\n    }\n\n    void endNativeHandle(Exception ex) {\n        if (--mNativeHandleCount == 0 && mNativeOperation != null) {\n            nativeSQLiteHandle(mConnectionPtr, false);\n\n            if (ex == null) {\n                mRecentOperations.endOperationDeferLog(mNativeOperation.mCookie);\n                // Don't log native operations for now. Drop return value.\n            } else {\n                mRecentOperations.failOperation(mNativeOperation.mCookie, ex);\n            }\n\n            mNativeOperation = null;\n        }\n    }\n\n    @Override\n    protected void finalize() throws Throwable {\n        try {\n            if (mPool != null && mConnectionPtr != 0) {\n                mPool.onConnectionLeaked();\n            }\n\n            dispose(true);\n        } finally {\n            super.finalize();\n        }\n    }\n\n    // Called by SQLiteConnectionPool only.\n    static SQLiteConnection open(SQLiteConnectionPool pool, SQLiteDatabaseConfiguration configuration,\n            int connectionId, boolean primaryConnection, byte[] password, SQLiteCipherSpec cipher) {\n\n        SQLiteConnection connection = new SQLiteConnection(pool, configuration,\n                connectionId, primaryConnection, password, cipher);\n        try {\n            connection.open();\n            return connection;\n        } catch (SQLiteException ex) {\n            SQLiteDebug.collectLastIOTraceStats(connection);\n            connection.dispose(false);\n            throw ex;\n        }\n    }\n\n    // Closes the database closes and releases all of its associated resources.\n    // Do not call methods on the connection after it is closed.  It will probably crash.\n    void close() {\n        dispose(false);\n    }\n\n    private void open() {\n        mConnectionPtr = nativeOpen(mConfiguration.path, mConfiguration.openFlags,\n                mConfiguration.vfsName);\n        if (mPassword != null && mPassword.length == 0)\n            mPassword = null;\n\n        // 1. Key must be specified first as it's the initialization to codec context.\n        if (mPassword != null) {\n            nativeSetKey(mConnectionPtr, mPassword);\n\n            // 2. Specify codec parameters such as cipher_name, kdf_iter and cipher_use_hmac.\n            setCipherSpec();\n        }\n\n        // 3. Set page size. This must be done before any I/O operations take place.\n        setPageSize();\n\n        // 4. Other initialization steps from original SQLiteConnection.\n        setReadOnlyFromConfiguration();\n        setForeignKeyModeFromConfiguration();\n        setWalModeFromConfiguration();\n        setSyncModeFromConfiguration();\n        setJournalSizeLimit();\n        setCheckpointStrategy();\n        setLocaleFromConfiguration();\n\n        // 5. Register extensions.\n        long apiEnv = WCDBInitializationProbe.apiEnv;\n        long dbPtr = nativeSQLiteHandle(mConnectionPtr, true);\n        try {\n            for (SQLiteExtension ext : mConfiguration.extensions) {\n                ext.initialize(dbPtr, apiEnv);\n            }\n        } finally {\n            nativeSQLiteHandle(mConnectionPtr, false);\n        }\n\n        setUpdateNotificationFromConfiguration();\n    }\n\n    private void dispose(boolean finalized) {\n        if (mConnectionPtr != 0) {\n            final int cookie = mRecentOperations.beginOperation(\"close\", null, null).mCookie;\n            try {\n                mPreparedStatementCache.evictAll();\n                nativeClose(mConnectionPtr);\n                mConnectionPtr = 0;\n            } finally {\n                mRecentOperations.endOperation(cookie);\n            }\n        }\n    }\n\n    private void setPageSize() {\n        if (!mConfiguration.isInMemoryDb()) {\n            String pragmaCmd;\n            long newValue;\n\n            if (mPassword != null) {\n                // For encrypted databases, call 'PRAGMA cipher_page_size' instead.\n                pragmaCmd = \"PRAGMA cipher_page_size\";\n                newValue = (mCipher == null || mCipher.pageSize <= 0) ?\n                        SQLiteGlobal.defaultPageSize : mCipher.pageSize;\n            } else {\n                pragmaCmd = \"PRAGMA page_size\";\n                newValue = SQLiteGlobal.defaultPageSize;\n            }\n\n            long value = executeForLong(pragmaCmd, null, null);\n            if (value != newValue) {\n                execute(pragmaCmd + \"=\" + newValue, null, null);\n            }\n        }\n    }\n\n    private static final String[] HMAC_ALGO_MAPPING = new String[] {\n        \"HMAC_SHA1\", \"HMAC_SHA256\", \"HMAC_SHA512\"\n    };\n    private static final String[] PBKDF2_ALGO_MAPPING = new String[] {\n        \"PBKDF2_HMAC_SHA1\", \"PBKDF2_HMAC_SHA256\", \"PBKDF2_HMAC_SHA512\"\n    };\n    private void setCipherSpec() {\n        if (mCipher != null) {\n            if (mCipher.kdfIteration != 0)\n                execute(\"PRAGMA kdf_iter=\" + mCipher.kdfIteration, null, null);\n\n            execute(\"PRAGMA cipher_use_hmac=\" + mCipher.hmacEnabled, null, null);\n\n            if (mCipher.hmacAlgorithm != SQLiteCipherSpec.HMAC_DEFAULT)\n                execute(\"PRAGMA cipher_hmac_algorithm=\" + HMAC_ALGO_MAPPING[mCipher.hmacAlgorithm],\n                        null, null);\n\n            if (mCipher.kdfAlgorithm != SQLiteCipherSpec.HMAC_DEFAULT)\n                execute(\"PRAGMA cipher_kdf_algorithm=\" + PBKDF2_ALGO_MAPPING[mCipher.kdfAlgorithm],\n                        null, null);\n        }\n    }\n\n    @SuppressWarnings(\"unused\")\n    private void notifyCheckpoint(String dbName, int pages) {\n        mPool.notifyCheckpoint(dbName, pages);\n    }\n\n    private void setCheckpointStrategy() {\n        if (!mConfiguration.isInMemoryDb() && !mIsReadOnlyConnection) {\n            if (mConfiguration.customWALHookEnabled) {\n                nativeSetWalHook(mConnectionPtr);\n            } else {\n                final long newValue = SQLiteGlobal.walAutoCheckpoint;\n                long value = executeForLong(\"PRAGMA wal_autocheckpoint\", null, null);\n                if (value != newValue) {\n                    executeForLong(\"PRAGMA wal_autocheckpoint=\" + newValue, null, null);\n                }\n            }\n        }\n    }\n\n    private void setJournalSizeLimit() {\n        if (!mConfiguration.isInMemoryDb() && !mIsReadOnlyConnection) {\n            final long newValue = SQLiteGlobal.journalSizeLimit;\n            long value = executeForLong(\"PRAGMA journal_size_limit\", null, null);\n            if (value != newValue) {\n                executeForLong(\"PRAGMA journal_size_limit=\" + newValue, null, null);\n            }\n        }\n    }\n\n    private void setForeignKeyModeFromConfiguration() {\n        if (!mIsReadOnlyConnection) {\n            final long newValue = mConfiguration.foreignKeyConstraintsEnabled ? 1 : 0;\n            long value = executeForLong(\"PRAGMA foreign_keys\", null, null);\n            if (value != newValue) {\n                execute(\"PRAGMA foreign_keys=\" + newValue, null, null);\n            }\n        }\n    }\n\n    private void setWalModeFromConfiguration() {\n        if (!mConfiguration.isInMemoryDb() && !mIsReadOnlyConnection) {\n            String journalMode;\n            if ((mConfiguration.openFlags & SQLiteDatabase.ENABLE_WRITE_AHEAD_LOGGING) != 0) {\n                journalMode = \"WAL\";\n            } else {\n                journalMode = SQLiteGlobal.defaultJournalMode;\n            }\n            setJournalMode(journalMode);\n        }\n    }\n\n    private void setSyncModeFromConfiguration() {\n        int syncMode = mConfiguration.synchronousMode;\n        execute(\"PRAGMA synchronous=\" + syncMode, null, null);\n    }\n\n    private void setJournalMode(String newValue) {\n        String value = executeForString(\"PRAGMA journal_mode\", null, null);\n        if (!value.equalsIgnoreCase(newValue)) {\n            try {\n                String result = executeForString(\"PRAGMA journal_mode=\" + newValue, null, null);\n                if (result.equalsIgnoreCase(newValue)) {\n                    return;\n                }\n                // PRAGMA journal_mode silently fails and returns the original journal\n                // mode in some cases if the journal mode could not be changed.\n            } catch (SQLiteDatabaseLockedException ex) {\n                // This error (SQLITE_BUSY) occurs if one connection has the database\n                // open in WAL mode and another tries to change it to non-WAL.\n            }\n            // Because we always disable WAL mode when a database is first opened\n            // (even if we intend to re-enable it), we can encounter problems if\n            // there is another open connection to the database somewhere.\n            // This can happen for a variety of reasons such as an application opening\n            // the same database in multiple processes at the same time or if there is a\n            // crashing content provider service that the ActivityManager has\n            // removed from its registry but whose process hasn't quite died yet\n            // by the time it is restarted in a new process.\n            //\n            // If we don't change the journal mode, nothing really bad happens.\n            // In the worst case, an application that enables WAL might not actually\n            // get it, although it can still use connection pooling.\n            Log.w(TAG, \"Could not change the database journal mode of '\"\n                    + mConfiguration.label + \"' from '\" + value + \"' to '\" + newValue\n                    + \"' because the database is locked.  This usually means that \"\n                    + \"there are other open connections to the database which prevents \"\n                    + \"the database from enabling or disabling write-ahead logging mode.  \"\n                    + \"Proceeding without changing the journal mode.\");\n        }\n    }\n\n    private void setLocaleFromConfiguration() {\n        mConfiguration.openFlags |= SQLiteDatabase.NO_LOCALIZED_COLLATORS;\n        if ((mConfiguration.openFlags & SQLiteDatabase.NO_LOCALIZED_COLLATORS) != 0) {\n            return;\n        }\n\n        // Register the localized collators.\n        final String newLocale = mConfiguration.locale.toString();\n        nativeRegisterLocalizedCollators(mConnectionPtr, newLocale);\n\n        // If the database is read-only, we cannot modify the android metadata table\n        // or existing indexes.\n        if (mIsReadOnlyConnection) {\n            return;\n        }\n\n        try {\n            // Ensure the android metadata table exists.\n            execute(\"CREATE TABLE IF NOT EXISTS android_metadata (locale TEXT)\", null, null);\n\n            // Check whether the locale was actually changed.\n            final String oldLocale = executeForString(\"SELECT locale FROM android_metadata \"\n                    + \"UNION SELECT NULL ORDER BY locale DESC LIMIT 1\", null, null);\n            if (oldLocale != null && oldLocale.equals(newLocale)) {\n                return;\n            }\n\n            // Go ahead and update the indexes using the new locale.\n            execute(\"BEGIN\", null, null);\n            boolean success = false;\n            try {\n                execute(\"DELETE FROM android_metadata\", null, null);\n                execute(\"INSERT INTO android_metadata (locale) VALUES(?)\",\n                        new Object[]{newLocale}, null);\n                execute(\"REINDEX LOCALIZED\", null, null);\n                success = true;\n            } finally {\n                execute(success ? \"COMMIT\" : \"ROLLBACK\", null, null);\n            }\n        } catch (RuntimeException ex) {\n            throw new SQLiteException(\"Failed to change locale for db '\" + mConfiguration.label\n                    + \"' to '\" + newLocale + \"'.\", ex);\n        }\n    }\n\n    private void setReadOnlyFromConfiguration() {\n        // Currently, read-only flag can only be changed via reopening connection, so no operation\n        // needed for read/write connections.\n        if (mIsReadOnlyConnection) {\n            execute(\"PRAGMA query_only = 1\", null, null);\n        }\n    }\n\n    @SuppressWarnings(\"unused\")\n    private void notifyChange(String db, String table, long[] insertIds, long[] updateIds, long[] deleteIds) {\n        mPool.notifyChanges(db, table, insertIds, updateIds, deleteIds);\n    }\n\n    private void setUpdateNotificationFromConfiguration() {\n        nativeSetUpdateNotification(mConnectionPtr,\n                mConfiguration.updateNotificationEnabled,\n                mConfiguration.updateNotificationRowID);\n    }\n\n    // Called by SQLiteConnectionPool only.\n    void reconfigure(SQLiteDatabaseConfiguration configuration) {\n        mOnlyAllowReadOnlyOperations = false;\n\n        // Register extensions.\n        long apiEnv = WCDBInitializationProbe.apiEnv;\n        long dbPtr = nativeSQLiteHandle(mConnectionPtr, true);\n        try {\n            for (SQLiteExtension ext : configuration.extensions) {\n                if (!mConfiguration.extensions.contains(ext)) {\n                    ext.initialize(dbPtr, apiEnv);\n                }\n            }\n        } finally {\n            nativeSQLiteHandle(mConnectionPtr, false);\n        }\n\n        // Remember what changed.\n        int openFlagsChanged = configuration.openFlags ^ mConfiguration.openFlags;\n        boolean walModeChanged = (openFlagsChanged & SQLiteDatabase.ENABLE_WRITE_AHEAD_LOGGING) != 0;\n        boolean foreignKeyModeChanged = configuration.foreignKeyConstraintsEnabled\n                != mConfiguration.foreignKeyConstraintsEnabled;\n        boolean localeChanged = !configuration.locale.equals(mConfiguration.locale);\n        boolean checkpointStrategyChanged = configuration.customWALHookEnabled\n                != mConfiguration.customWALHookEnabled;\n        boolean synchronousChanged = configuration.synchronousMode\n                != mConfiguration.synchronousMode;\n        boolean updateNotificationChanged =\n                (configuration.updateNotificationEnabled != mConfiguration.updateNotificationEnabled) ||\n                (configuration.updateNotificationRowID != mConfiguration.updateNotificationRowID);\n\n        // Update configuration parameters.\n        mConfiguration.updateParametersFrom(configuration);\n\n        // Update prepared statement cache size.\n        mPreparedStatementCache.resize(configuration.maxSqlCacheSize);\n\n        // Update foreign key mode.\n        if (foreignKeyModeChanged) {\n            setForeignKeyModeFromConfiguration();\n        }\n\n        // Update WAL.\n        if (walModeChanged) {\n            setWalModeFromConfiguration();\n        }\n\n        // Update synchronous mode.\n        if (synchronousChanged) {\n            setSyncModeFromConfiguration();\n        }\n\n        // Update checkpoint strategy. This must be done after setting WAL mode.\n        if (checkpointStrategyChanged) {\n            setCheckpointStrategy();\n        }\n\n        // Update locale.\n        if (localeChanged) {\n            setLocaleFromConfiguration();\n        }\n\n        // Update notification.\n        if (updateNotificationChanged) {\n            setUpdateNotificationFromConfiguration();\n        }\n    }\n\n    // Called by SQLiteConnectionPool only.\n    // When set to true, executing write operations will throw SQLiteException.\n    // Preparing statements that might write is ok, just don't execute them.\n    void setOnlyAllowReadOnlyOperations(boolean readOnly) {\n        mOnlyAllowReadOnlyOperations = readOnly;\n    }\n\n    // Called by SQLiteSession only.\n    // Mark acquisition state for debug purpose.\n    void setAcquisitionState(boolean acquired, boolean persist) {\n        if (acquired) {\n            mAcquiredThread = Thread.currentThread();\n            mAcquiredTid = Process.myTid();\n            if (persist) {\n                mAcquiredStack = mAcquiredThread.getStackTrace();\n                mAcquiredTimestamp = System.currentTimeMillis();\n            } else {\n                mAcquiredStack = null;\n                mAcquiredTimestamp = 0;\n            }\n        } else {\n            mAcquiredThread = null;\n            mAcquiredTid = 0;\n            mAcquiredStack = null;\n            mAcquiredTimestamp = 0;\n        }\n    }\n\n    // Called by SQLiteConnectionPool only.\n    // Returns true if the prepared statement cache contains the specified SQL.\n    boolean isPreparedStatementInCache(String sql) {\n        return mPreparedStatementCache.get(sql) != null;\n    }\n\n    /**\n     * Gets the unique id of this connection.\n     *\n     * @return The connection id.\n     */\n    public int getConnectionId() {\n        return mConnectionId;\n    }\n\n    /**\n     * Returns true if this is the primary database connection.\n     *\n     * @return True if this is the primary database connection.\n     */\n    public boolean isPrimaryConnection() {\n        return mIsPrimaryConnection;\n    }\n\n    /**\n     * Prepares a statement for execution but does not bind its parameters or execute it.\n     * <p>\n     * This method can be used to check for syntax errors during compilation\n     * prior to execution of the statement.  If the {@code outStatementInfo} argument\n     * is not null, the provided {@link SQLiteStatementInfo} object is populated\n     * with information about the statement.\n     * </p><p>\n     * A prepared statement makes no reference to the arguments that may eventually\n     * be bound to it, consequently it it possible to cache certain prepared statements\n     * such as SELECT or INSERT/UPDATE statements.  If the statement is cacheable,\n     * then it will be stored in the cache for later.\n     * </p><p>\n     * To take advantage of this behavior as an optimization, the connection pool\n     * provides a method to acquire a connection that already has a given SQL statement\n     * in its prepared statement cache so that it is ready for execution.\n     * </p>\n     *\n     * @param sql              The SQL statement to prepare.\n     * @param outStatementInfo The {@link SQLiteStatementInfo} object to populate\n     *                         with information about the statement, or null if none.\n     * @throws SQLiteException if an error occurs, such as a syntax error.\n     */\n    public void prepare(String sql, SQLiteStatementInfo outStatementInfo) {\n        if (sql == null) {\n            throw new IllegalArgumentException(\"sql must not be null.\");\n        }\n        Operation operation = mRecentOperations.beginOperation(\"prepare\", sql, null);\n        final int cookie = operation.mCookie;\n        try {\n            final PreparedStatement statement = acquirePreparedStatement(sql);\n            operation.mType = statement.mType;\n            try {\n                if (outStatementInfo != null) {\n                    outStatementInfo.numParameters = statement.mNumParameters;\n                    outStatementInfo.readOnly = statement.mReadOnly;\n\n                    final int columnCount = nativeGetColumnCount(\n                            mConnectionPtr, statement.getPtr());\n                    if (columnCount == 0) {\n                        outStatementInfo.columnNames = EMPTY_STRING_ARRAY;\n                    } else {\n                        outStatementInfo.columnNames = new String[columnCount];\n                        for (int i = 0; i < columnCount; i++) {\n                            outStatementInfo.columnNames[i] = nativeGetColumnName(\n                                    mConnectionPtr, statement.getPtr(), i);\n                        }\n                    }\n                }\n            } finally {\n                releasePreparedStatement(statement);\n            }\n        } catch (RuntimeException ex) {\n            mRecentOperations.failOperation(cookie, ex);\n            throw ex;\n        } finally {\n            mRecentOperations.endOperation(cookie);\n        }\n    }\n\n    /**\n     * Executes a statement that does not return a result.\n     *\n     * @param sql                The SQL statement to execute.\n     * @param bindArgs           The arguments to bind, or null if none.\n     * @param cancellationSignal A signal to cancel the operation in progress, or null if none.\n     * @throws SQLiteException            if an error occurs, such as a syntax error\n     *                                    or invalid number of bind arguments.\n     * @throws OperationCanceledException if the operation was canceled.\n     */\n    public void execute(String sql, Object[] bindArgs,\n            CancellationSignal cancellationSignal) {\n        if (sql == null) {\n            throw new IllegalArgumentException(\"sql must not be null.\");\n        }\n        Operation operation = mRecentOperations.beginOperation(\"execute\", sql, bindArgs);\n        final int cookie = operation.mCookie;\n        try {\n            final PreparedStatement statement = acquirePreparedStatement(sql);\n            operation.mType = statement.mType;\n            try {\n                throwIfStatementForbidden(statement);\n                bindArguments(statement, bindArgs);\n                applyBlockGuardPolicy(statement);\n                attachCancellationSignal(cancellationSignal);\n                try {\n                    nativeExecute(mConnectionPtr, statement.getPtr());\n                } finally {\n                    detachCancellationSignal(cancellationSignal);\n                }\n            } finally {\n                releasePreparedStatement(statement);\n            }\n        } catch (RuntimeException ex) {\n            mRecentOperations.failOperation(cookie, ex);\n            throw ex;\n        } finally {\n            mRecentOperations.endOperation(cookie);\n        }\n    }\n\n    /**\n     * Executes a statement that returns a single <code>long</code> result.\n     *\n     * @param sql                The SQL statement to execute.\n     * @param bindArgs           The arguments to bind, or null if none.\n     * @param cancellationSignal A signal to cancel the operation in progress, or null if none.\n     * @return The value of the first column in the first row of the result set\n     * as a <code>long</code>, or zero if none.\n     * @throws SQLiteException            if an error occurs, such as a syntax error\n     *                                    or invalid number of bind arguments.\n     * @throws OperationCanceledException if the operation was canceled.\n     */\n    public long executeForLong(String sql, Object[] bindArgs,\n            CancellationSignal cancellationSignal) {\n        if (sql == null) {\n            throw new IllegalArgumentException(\"sql must not be null.\");\n        }\n\n        Operation operation = mRecentOperations.beginOperation(\"executeForLong\", sql, bindArgs);\n        final int cookie = operation.mCookie;\n        try {\n            final PreparedStatement statement = acquirePreparedStatement(sql);\n            operation.mType = statement.mType;\n            try {\n                throwIfStatementForbidden(statement);\n                bindArguments(statement, bindArgs);\n                applyBlockGuardPolicy(statement);\n                attachCancellationSignal(cancellationSignal);\n                try {\n                    return nativeExecuteForLong(mConnectionPtr, statement.getPtr());\n                } finally {\n                    detachCancellationSignal(cancellationSignal);\n                }\n            } finally {\n                releasePreparedStatement(statement);\n            }\n        } catch (RuntimeException ex) {\n            mRecentOperations.failOperation(cookie, ex);\n            throw ex;\n        } finally {\n            mRecentOperations.endOperation(cookie);\n        }\n    }\n\n    /**\n     * Executes a statement that returns a single {@link String} result.\n     *\n     * @param sql                The SQL statement to execute.\n     * @param bindArgs           The arguments to bind, or null if none.\n     * @param cancellationSignal A signal to cancel the operation in progress, or null if none.\n     * @return The value of the first column in the first row of the result set\n     * as a <code>String</code>, or null if none.\n     * @throws SQLiteException            if an error occurs, such as a syntax error\n     *                                    or invalid number of bind arguments.\n     * @throws OperationCanceledException if the operation was canceled.\n     */\n    public String executeForString(String sql, Object[] bindArgs,\n            CancellationSignal cancellationSignal) {\n        if (sql == null) {\n            throw new IllegalArgumentException(\"sql must not be null.\");\n        }\n        Operation operation = mRecentOperations.beginOperation(\"executeForString\", sql, bindArgs);\n        final int cookie = operation.mCookie;\n        try {\n            final PreparedStatement statement = acquirePreparedStatement(sql);\n            operation.mType = statement.mType;\n            try {\n                throwIfStatementForbidden(statement);\n                bindArguments(statement, bindArgs);\n                applyBlockGuardPolicy(statement);\n                attachCancellationSignal(cancellationSignal);\n                try {\n                    return nativeExecuteForString(mConnectionPtr, statement.getPtr());\n                } finally {\n                    detachCancellationSignal(cancellationSignal);\n                }\n            } finally {\n                releasePreparedStatement(statement);\n            }\n        } catch (RuntimeException ex) {\n            mRecentOperations.failOperation(cookie, ex);\n            throw ex;\n        } finally {\n            mRecentOperations.endOperation(cookie);\n        }\n    }\n\n    /**\n     * Executes a statement that returns a count of the number of rows\n     * that were changed.  Use for UPDATE or DELETE SQL statements.\n     *\n     * @param sql                The SQL statement to execute.\n     * @param bindArgs           The arguments to bind, or null if none.\n     * @param cancellationSignal A signal to cancel the operation in progress, or null if none.\n     * @return The number of rows that were changed.\n     * @throws SQLiteException            if an error occurs, such as a syntax error\n     *                                    or invalid number of bind arguments.\n     * @throws OperationCanceledException if the operation was canceled.\n     */\n    public int executeForChangedRowCount(String sql, Object[] bindArgs,\n            CancellationSignal cancellationSignal) {\n        if (sql == null) {\n            throw new IllegalArgumentException(\"sql must not be null.\");\n        }\n\n        int changedRows = 0;\n        Operation operation = mRecentOperations.beginOperation(\"executeForChangedRowCount\", sql, bindArgs);\n        final int cookie = operation.mCookie;\n        try {\n            final PreparedStatement statement = acquirePreparedStatement(sql);\n            operation.mType = statement.mType;\n            try {\n                throwIfStatementForbidden(statement);\n                bindArguments(statement, bindArgs);\n                applyBlockGuardPolicy(statement);\n                attachCancellationSignal(cancellationSignal);\n                try {\n                    changedRows = nativeExecuteForChangedRowCount(\n                            mConnectionPtr, statement.getPtr());\n                    return changedRows;\n                } finally {\n                    detachCancellationSignal(cancellationSignal);\n                }\n            } finally {\n                releasePreparedStatement(statement);\n            }\n        } catch (RuntimeException ex) {\n            mRecentOperations.failOperation(cookie, ex);\n            throw ex;\n        } finally {\n            if (mRecentOperations.endOperationDeferLog(cookie)) {\n                mRecentOperations.logOperation(cookie, \"changedRows=\" + changedRows);\n            }\n        }\n    }\n\n    /**\n     * Executes a statement that returns the row id of the last row inserted\n     * by the statement.  Use for INSERT SQL statements.\n     *\n     * @param sql                The SQL statement to execute.\n     * @param bindArgs           The arguments to bind, or null if none.\n     * @param cancellationSignal A signal to cancel the operation in progress, or null if none.\n     * @return The row id of the last row that was inserted, or 0 if none.\n     * @throws SQLiteException            if an error occurs, such as a syntax error\n     *                                    or invalid number of bind arguments.\n     * @throws OperationCanceledException if the operation was canceled.\n     */\n    public long executeForLastInsertedRowId(String sql, Object[] bindArgs,\n            CancellationSignal cancellationSignal) {\n        if (sql == null) {\n            throw new IllegalArgumentException(\"sql must not be null.\");\n        }\n        Operation operation = mRecentOperations.beginOperation(\"executeForLastInsertedRowId\", sql, bindArgs);\n        final int cookie = operation.mCookie;\n        try {\n            final PreparedStatement statement = acquirePreparedStatement(sql);\n            operation.mType = statement.mType;\n            try {\n                throwIfStatementForbidden(statement);\n                bindArguments(statement, bindArgs);\n                applyBlockGuardPolicy(statement);\n                attachCancellationSignal(cancellationSignal);\n                try {\n                    return nativeExecuteForLastInsertedRowId(\n                            mConnectionPtr, statement.getPtr());\n                } finally {\n                    detachCancellationSignal(cancellationSignal);\n                }\n            } finally {\n                releasePreparedStatement(statement);\n            }\n        } catch (RuntimeException ex) {\n            mRecentOperations.failOperation(cookie, ex);\n            throw ex;\n        } finally {\n            mRecentOperations.endOperation(cookie);\n        }\n    }\n\n    public int executeForCursorWindow(String sql, Object[] bindArgs, CursorWindow window,\n            int startPos, int requiredPos, boolean countAllRows,\n            CancellationSignal cancellationSignal) {\n        if (sql == null) {\n            throw new IllegalArgumentException(\"sql must not be null.\");\n        }\n        if (window == null) {\n            throw new IllegalArgumentException(\"window must not be null.\");\n        }\n\n        window.acquireReference();\n        try {\n            int actualPos = -1;\n            int countedRows = -1;\n            int filledRows = -1;\n            Operation operation = mRecentOperations.beginOperation(\"executeForCursorWindow\", sql, bindArgs);\n            final int cookie = operation.mCookie;\n            try {\n                final PreparedStatement statement = acquirePreparedStatement(sql);\n                operation.mType = statement.mType;\n                try {\n                    throwIfStatementForbidden(statement);\n                    bindArguments(statement, bindArgs);\n                    applyBlockGuardPolicy(statement);\n                    attachCancellationSignal(cancellationSignal);\n                    try {\n                        final long result = nativeExecuteForCursorWindow(\n                                mConnectionPtr, statement.getPtr(), window.mWindowPtr,\n                                startPos, requiredPos, countAllRows);\n                        actualPos = (int) (result >> 32);\n                        countedRows = (int) result;\n                        filledRows = window.getNumRows();\n                        window.setStartPosition(actualPos);\n                        return countedRows;\n                    } finally {\n                        detachCancellationSignal(cancellationSignal);\n                    }\n                } finally {\n                    releasePreparedStatement(statement);\n                }\n            } catch (RuntimeException ex) {\n                mRecentOperations.failOperation(cookie, ex);\n                throw ex;\n            } finally {\n                if (mRecentOperations.endOperationDeferLog(cookie)) {\n                    mRecentOperations.logOperation(cookie, \"window='\" + window\n                            + \"', startPos=\" + startPos\n                            + \", actualPos=\" + actualPos\n                            + \", filledRows=\" + filledRows\n                            + \", countedRows=\" + countedRows);\n                }\n            }\n        } finally {\n            window.releaseReference();\n        }\n    }\n\n    public Pair<Integer, Integer> walCheckpoint(String dbName) {\n        if (dbName == null || dbName.isEmpty())\n            dbName = \"main\";\n\n        long result = nativeWalCheckpoint(mConnectionPtr, dbName);\n        int walPages = (int) (result >> 32);\n        int checkpointedPages = (int) (result & 0xFFFFFFFFL);\n        return new Pair<>(walPages, checkpointedPages);\n    }\n\n    /*package*/ PreparedStatement acquirePreparedStatement(String sql) {\n        PreparedStatement statement = mPreparedStatementCache.get(sql);\n        boolean skipCache = false;\n        if (statement != null) {\n            if (!statement.mInUse) {\n                statement.mInUse = true;\n                return statement;\n            }\n            // The statement is already in the cache but is in use (this statement appears\n            // to be not only re-entrant but recursive!).  So prepare a new copy of the\n            // statement but do not cache it.\n            skipCache = true;\n        }\n\n        final long statementPtr = nativePrepareStatement(mConnectionPtr, sql);\n        try {\n            final int numParameters = nativeGetParameterCount(mConnectionPtr, statementPtr);\n            final int type = DatabaseUtils.getSqlStatementType(sql);\n            final boolean readOnly = nativeIsReadOnly(mConnectionPtr, statementPtr);\n            statement = obtainPreparedStatement(sql, statementPtr, numParameters, type, readOnly);\n            if (!skipCache && isCacheable(type)) {\n                mPreparedStatementCache.put(sql, statement);\n                statement.mInCache = true;\n            }\n        } catch (RuntimeException ex) {\n            // Finalize the statement if an exception occurred and we did not add\n            // it to the cache.  If it is already in the cache, then leave it there.\n            if (statement == null || !statement.mInCache) {\n                nativeFinalizeStatement(mConnectionPtr, statementPtr);\n            }\n            throw ex;\n        }\n        statement.mInUse = true;\n        return statement;\n    }\n\n    /*package*/ void releasePreparedStatement(PreparedStatement statement) {\n        statement.mInUse = false;\n        if (statement.mInCache) {\n            try {\n                resetStatement(statement, true);\n            } catch (SQLiteException ex) {\n                // The statement could not be reset due to an error.  Remove it from the cache.\n                // When remove() is called, the cache will invoke its entryRemoved() callback,\n                // which will in turn call finalizePreparedStatement() to finalize and\n                // recycle the statement.\n                if (DEBUG) {\n                    Log.d(TAG, \"Could not reset prepared statement due to an exception.  \"\n                            + \"Removing it from the cache.  SQL: \"\n                            + trimSqlForDisplay(statement.mSql), ex);\n                }\n\n                mPreparedStatementCache.remove(statement.mSql);\n            }\n        } else {\n            finalizePreparedStatement(statement);\n        }\n    }\n\n    private void finalizePreparedStatement(PreparedStatement statement) {\n        nativeFinalizeStatement(mConnectionPtr, statement.getPtr());\n        recyclePreparedStatement(statement);\n    }\n\n    private void attachCancellationSignal(CancellationSignal cancellationSignal) {\n        if (cancellationSignal != null) {\n            cancellationSignal.throwIfCanceled();\n\n            mCancellationSignalAttachCount += 1;\n            if (mCancellationSignalAttachCount == 1) {\n                // Reset cancellation flag before executing the statement.\n                nativeResetCancel(mConnectionPtr, true /*cancelable*/);\n\n                // After this point, onCancel() may be called concurrently.\n                cancellationSignal.setOnCancelListener(this);\n            }\n        }\n    }\n\n    private void detachCancellationSignal(CancellationSignal cancellationSignal) {\n        if (cancellationSignal != null) {\n            if (BuildConfig.DEBUG && !(mCancellationSignalAttachCount > 0))\n                throw new AssertionError(\"mCancellationSignalAttachCount > 0\");\n\n            mCancellationSignalAttachCount -= 1;\n            if (mCancellationSignalAttachCount == 0) {\n                // After this point, onCancel() cannot be called concurrently.\n                cancellationSignal.setOnCancelListener(null);\n\n                // Reset cancellation flag after executing the statement.\n                nativeResetCancel(mConnectionPtr, false /*cancelable*/);\n            }\n        }\n    }\n\n    // CancellationSignal.OnCancelListener callback.\n    // This method may be called on a different thread than the executing statement.\n    // However, it will only be called between calls to attachCancellationSignal and\n    // detachCancellationSignal, while a statement is executing.  We can safely assume\n    // that the SQLite connection is still alive.\n    @Override\n    public void onCancel() {\n        nativeCancel(mConnectionPtr);\n    }\n\n    private void bindArguments(PreparedStatement statement, Object[] bindArgs) {\n        final int count = bindArgs != null ? bindArgs.length : 0;\n        if (count != statement.mNumParameters) {\n            throw new SQLiteBindOrColumnIndexOutOfRangeException(\n                    \"Expected \" + statement.mNumParameters + \" bind arguments but \"\n                            + count + \" were provided.\");\n        }\n        if (count == 0) {\n            return;\n        }\n\n        final long statementPtr = statement.getPtr();\n        for (int i = 0; i < count; i++) {\n            final Object arg = bindArgs[i];\n            switch (DatabaseUtils.getTypeOfObject(arg)) {\n                case Cursor.FIELD_TYPE_NULL:\n                    nativeBindNull(mConnectionPtr, statementPtr, i + 1);\n                    break;\n                case Cursor.FIELD_TYPE_INTEGER:\n                    nativeBindLong(mConnectionPtr, statementPtr, i + 1,\n                            ((Number) arg).longValue());\n                    break;\n                case Cursor.FIELD_TYPE_FLOAT:\n                    nativeBindDouble(mConnectionPtr, statementPtr, i + 1,\n                            ((Number) arg).doubleValue());\n                    break;\n                case Cursor.FIELD_TYPE_BLOB:\n                    nativeBindBlob(mConnectionPtr, statementPtr, i + 1, (byte[]) arg);\n                    break;\n                case Cursor.FIELD_TYPE_STRING:\n                default:\n                    if (arg instanceof Boolean) {\n                        // Provide compatibility with legacy applications which may pass\n                        // Boolean values in bind args.\n                        nativeBindLong(mConnectionPtr, statementPtr, i + 1,\n                                ((Boolean) arg).booleanValue() ? 1 : 0);\n                    } else {\n                        nativeBindString(mConnectionPtr, statementPtr, i + 1, arg.toString());\n                    }\n                    break;\n            }\n        }\n    }\n\n    private void resetStatement(PreparedStatement statement, boolean clearBindings) {\n        nativeResetStatement(mConnectionPtr, statement.getPtr(), clearBindings);\n    }\n\n    private void throwIfStatementForbidden(PreparedStatement statement) {\n        if (mOnlyAllowReadOnlyOperations && !statement.mReadOnly) {\n            throw new SQLiteException(\"Cannot execute this statement because it \"\n                    + \"might modify the database but the connection is read-only.\");\n        }\n    }\n\n    private static boolean isCacheable(int statementType) {\n        if (statementType == DatabaseUtils.STATEMENT_UPDATE\n                || statementType == DatabaseUtils.STATEMENT_SELECT) {\n            return true;\n        }\n        return false;\n    }\n\n    private void applyBlockGuardPolicy(PreparedStatement statement) {\n        // do nothing\n    }\n\n    /**\n     * Dumps debugging information about this connection, in the case where the\n     * caller might not actually own the connection.\n     * <p/>\n     * This function is written so that it may be called by a thread that does not\n     * own the connection.  We need to be very careful because the connection state is\n     * not synchronized.\n     * <p/>\n     * At worst, the method may return stale or slightly wrong data, however\n     * it should not crash.  This is ok as it is only used for diagnostic purposes.\n     *\n     * @param printer The printer to receive the dump, not null.\n     * @param verbose True to dump more verbose information.\n     */\n     void dump(Printer printer, boolean verbose) {\n        printer.println(\"Connection #\" + mConnectionId + \":\");\n        if (verbose) {\n            printer.println(\"  connectionPtr: 0x\" + Long.toHexString(mConnectionPtr));\n        }\n        printer.println(\"  isPrimaryConnection: \" + mIsPrimaryConnection);\n        printer.println(\"  onlyAllowReadOnlyOperations: \" + mOnlyAllowReadOnlyOperations);\n        if (mAcquiredThread != null) {\n            printer.println(\"  acquiredThread: \" + mAcquiredThread + \" (tid: \" + mAcquiredTid + \")\");\n        }\n\n        mRecentOperations.dump(printer, verbose);\n\n        if (verbose) {\n            mPreparedStatementCache.dump(printer);\n        }\n    }\n\n    JSONObject dumpJSON(boolean verbose) throws JSONException {\n         JSONObject o = new JSONObject()\n                 .put(\"id\", mConnectionId)\n                 .put(\"ptr\", Long.toHexString(mConnectionPtr))\n                 .put(\"primary\", mIsPrimaryConnection)\n                 .put(\"readOnly\", mOnlyAllowReadOnlyOperations)\n                 .putOpt(\"thread\", (mAcquiredThread != null) ? mAcquiredThread.toString() : null)\n                 .putOpt(\"tid\", (mAcquiredTid > 0) ? mAcquiredTid : null)\n                 .put(\"operations\", mRecentOperations.dumpJSON(verbose));\n\n         // TODO: verbose?\n         return o;\n    }\n\n    /**\n     * Describes the currently executing operation, in the case where the\n     * caller might not actually own the connection.\n     * <p/>\n     * This function is written so that it may be called by a thread that does not\n     * own the connection.  We need to be very careful because the connection state is\n     * not synchronized.\n     * <p/>\n     * At worst, the method may return stale or slightly wrong data, however\n     * it should not crash.  This is ok as it is only used for diagnostic purposes.\n     *\n     * @return A description of the current operation including how long it has been running,\n     * or null if none.\n     */\n    String describeCurrentOperationUnsafe() {\n        return mRecentOperations.describeCurrentOperation();\n    }\n\n    SQLiteTrace.TraceInfo<String> traceCurrentOperationUnsafe() {\n        return mRecentOperations.traceCurrentOperation();\n    }\n\n    SQLiteTrace.TraceInfo<StackTraceElement[]> tracePersistAcquisitionUnsafe() {\n        StackTraceElement[] stack = mAcquiredStack;\n        return (stack == null) ? null :\n                new SQLiteTrace.TraceInfo<>(stack, mAcquiredTimestamp, mAcquiredTid);\n    }\n\n    /**\n     * Collects statistics about database connection memory usage.\n     *\n     * @param dbStatsList The list to populate.\n     */\n    void collectDbStats(ArrayList<DbStats> dbStatsList) {\n        // Get information about the main database.\n        int lookaside = nativeGetDbLookaside(mConnectionPtr);\n        long pageCount = 0;\n        long pageSize = 0;\n        try {\n            pageCount = executeForLong(\"PRAGMA page_count;\", null, null);\n            pageSize = executeForLong(\"PRAGMA page_size;\", null, null);\n        } catch (SQLiteException ex) {\n            // Ignore.\n        }\n        dbStatsList.add(getMainDbStatsUnsafe(lookaside, pageCount, pageSize));\n\n        // Get information about attached databases.\n        // We ignore the first row in the database list because it corresponds to\n        // the main database which we have already described.\n        CursorWindow window = new CursorWindow(\"collectDbStats\");\n        try {\n            executeForCursorWindow(\"PRAGMA database_list;\", null, window, 0, 0, false, null);\n            for (int i = 1; i < window.getNumRows(); i++) {\n                String name = window.getString(i, 1);\n                String path = window.getString(i, 2);\n                pageCount = 0;\n                pageSize = 0;\n                try {\n                    pageCount = executeForLong(\"PRAGMA \" + name + \".page_count;\", null, null);\n                    pageSize = executeForLong(\"PRAGMA \" + name + \".page_size;\", null, null);\n                } catch (SQLiteException ex) {\n                    // Ignore.\n                }\n                String label = \"  (attached) \" + name;\n                if (path.length() != 0) {\n                    label += \": \" + path;\n                }\n                dbStatsList.add(new DbStats(label, pageCount, pageSize, 0, 0, 0, 0));\n            }\n        } catch (SQLiteException ex) {\n            // Ignore.\n        } finally {\n            window.close();\n        }\n    }\n\n    /**\n     * Collects statistics about database connection memory usage, in the case where the\n     * caller might not actually own the connection.\n     *\n     * @return The statistics object, never null.\n     */\n    void collectDbStatsUnsafe(ArrayList<DbStats> dbStatsList) {\n        dbStatsList.add(getMainDbStatsUnsafe(0, 0, 0));\n    }\n\n    private DbStats getMainDbStatsUnsafe(int lookaside, long pageCount, long pageSize) {\n        // The prepared statement cache is thread-safe so we can access its statistics\n        // even if we do not own the database connection.\n        String label = mConfiguration.path;\n        if (!mIsPrimaryConnection) {\n            label += \" (\" + mConnectionId + \")\";\n        }\n        return new DbStats(label, pageCount, pageSize, lookaside,\n                mPreparedStatementCache.hitCount(),\n                mPreparedStatementCache.missCount(),\n                mPreparedStatementCache.size());\n    }\n\n    @Override\n    public String toString() {\n        return \"SQLiteConnection: \" + mConfiguration.path + \" (\" + mConnectionId + \")\";\n    }\n\n    private PreparedStatement obtainPreparedStatement(String sql, long statementPtr,\n            int numParameters, int type, boolean readOnly) {\n        PreparedStatement statement = mPreparedStatementPool;\n        if (statement != null) {\n            mPreparedStatementPool = statement.mPoolNext;\n            statement.mPoolNext = null;\n            statement.mInCache = false;\n        } else {\n            statement = new PreparedStatement(this);\n        }\n        statement.mSql = sql;\n        statement.mStatementPtr = statementPtr;\n        statement.mNumParameters = numParameters;\n        statement.mType = type;\n        statement.mReadOnly = readOnly;\n        return statement;\n    }\n\n    private void recyclePreparedStatement(PreparedStatement statement) {\n        statement.mSql = null;\n        statement.mPoolNext = mPreparedStatementPool;\n        mPreparedStatementPool = statement;\n    }\n\n    private static String trimSqlForDisplay(String sql) {\n        return TRIM_SQL_PATTERN.matcher(sql).replaceAll(\" \");\n    }\n\n    /**\n     * Holder type for a prepared statement.\n     * <p/>\n     * Although this object holds a pointer to a native statement object, it\n     * does not have a finalizer.  This is deliberate.  The {@link SQLiteConnection}\n     * owns the statement object and will take care of freeing it when needed.\n     * In particular, closing the connection requires a guarantee of deterministic\n     * resource disposal because all native statement objects must be freed before\n     * the native database object can be closed.  So no finalizers here.\n     */\n    /*package*/ static final class PreparedStatement {\n        // Reference to owner.\n        private WeakReference<SQLiteConnection> mConnection;\n\n        // Next item in pool.\n        private PreparedStatement mPoolNext;\n\n        // The SQL from which the statement was prepared.\n        private String mSql;\n\n        // The native sqlite3_stmt object pointer.\n        // Lifetime is managed explicitly by the connection.\n        private long mStatementPtr;\n\n        // The number of parameters that the prepared statement has.\n        private int mNumParameters;\n\n        // The statement type.\n        private int mType;\n\n        // True if the statement is read-only.\n        private boolean mReadOnly;\n\n        // True if the statement is in the cache.\n        private boolean mInCache;\n\n        // True if the statement is in use (currently executing).\n        // We need this flag because due to the use of custom functions in triggers, it's\n        // possible for SQLite calls to be re-entrant.  Consequently we need to prevent\n        // in use statements from being finalized until they are no longer in use.\n        private boolean mInUse;\n\n        // Operation record.\n        private Operation mOperation;\n\n        /*package*/ PreparedStatement(SQLiteConnection connection) {\n            mConnection = new WeakReference<>(connection);\n        }\n\n        public void bindArguments(Object[] bindArgs) {\n            SQLiteConnection connection = mConnection.get();\n            if (connection == null) return;\n\n            connection.bindArguments(this, bindArgs);\n        }\n\n        public void reset(boolean clearBindings) {\n            SQLiteConnection connection = mConnection.get();\n            if (connection == null) return;\n\n            connection.resetStatement(this, clearBindings);\n        }\n\n        public long getPtr() {\n            return mStatementPtr;\n        }\n\n        public String getSQL() {\n            return mSql;\n        }\n\n        public boolean isReadOnly() {\n            return mReadOnly;\n        }\n\n        public int getType() {\n            return mType;\n        }\n\n        public void attachCancellationSignal(CancellationSignal cancellationSignal) {\n            SQLiteConnection connection = mConnection.get();\n            if (connection == null) return;\n\n            connection.attachCancellationSignal(cancellationSignal);\n        }\n\n        public void detachCancellationSignal(CancellationSignal cancellationSignal) {\n            SQLiteConnection connection = mConnection.get();\n            if (connection == null) return;\n\n            connection.detachCancellationSignal(cancellationSignal);\n        }\n\n        public void beginOperation(String kind, Object[] bindArgs) {\n            SQLiteConnection connection = mConnection.get();\n            if (connection == null) return;\n\n            mOperation = connection.mRecentOperations.beginOperation(kind, mSql, bindArgs);\n            mOperation.mType = mType;\n        }\n\n        public void failOperation(Exception ex) {\n            if (mOperation == null) return;\n            SQLiteConnection connection = mConnection.get();\n            if (connection == null) return;\n\n            connection.mRecentOperations.failOperation(mOperation.mCookie, ex);\n        }\n\n        public void endOperation(String detail) {\n            if (mOperation == null) return;\n            SQLiteConnection connection = mConnection.get();\n            if (connection == null) return;\n\n            if (connection.mRecentOperations.endOperationDeferLog(mOperation.mCookie)) {\n                connection.mRecentOperations.logOperation(mOperation.mCookie, detail);\n            }\n            mOperation = null;\n        }\n    }\n\n    private final class PreparedStatementCache\n            extends LruCache<String, PreparedStatement> {\n        public PreparedStatementCache(int size) {\n            super(size);\n        }\n\n        @Override\n        protected void entryRemoved(boolean evicted, String key,\n                PreparedStatement oldValue, PreparedStatement newValue) {\n            oldValue.mInCache = false;\n            if (!oldValue.mInUse) {\n                finalizePreparedStatement(oldValue);\n            }\n        }\n\n        public void dump(Printer printer) {\n            printer.println(\"  Prepared statement cache:\");\n            Map<String, PreparedStatement> cache = snapshot();\n            if (!cache.isEmpty()) {\n                int i = 0;\n                for (Map.Entry<String, PreparedStatement> entry : cache.entrySet()) {\n                    PreparedStatement statement = entry.getValue();\n                    if (statement.mInCache) { // might be false due to a race with entryRemoved\n                        String sql = entry.getKey();\n                        printer.println(\"    \" + i + \": statementPtr=0x\"\n                                + Long.toHexString(statement.getPtr())\n                                + \", numParameters=\" + statement.mNumParameters\n                                + \", type=\" + statement.mType\n                                + \", readOnly=\" + statement.mReadOnly\n                                + \", sql=\\\"\" + trimSqlForDisplay(sql) + \"\\\"\");\n                    }\n                    i += 1;\n                }\n            } else {\n                printer.println(\"    <none>\");\n            }\n        }\n    }\n\n    private final class OperationLog {\n        private static final int MAX_RECENT_OPERATIONS = 20;\n        private static final int COOKIE_GENERATION_SHIFT = 8;\n        private static final int COOKIE_INDEX_MASK = 0xff;\n\n        private final Operation[] mOperations = new Operation[MAX_RECENT_OPERATIONS];\n        private int mIndex;\n        private int mGeneration;\n\n        Operation beginOperation(String kind, String sql, Object[] bindArgs) {\n            synchronized (mOperations) {\n                final int index = (mIndex + 1) % MAX_RECENT_OPERATIONS;\n                Operation operation = mOperations[index];\n                if (operation == null) {\n                    operation = new Operation();\n                    mOperations[index] = operation;\n                } else {\n                    operation.mFinished = false;\n                    operation.mException = null;\n                    if (operation.mBindArgs != null) {\n                        operation.mBindArgs.clear();\n                    }\n                }\n                operation.mStartTime = System.currentTimeMillis();\n                operation.mKind = kind;\n                operation.mSql = sql;\n                if (bindArgs != null) {\n                    if (operation.mBindArgs == null) {\n                        operation.mBindArgs = new ArrayList<Object>();\n                    } else {\n                        operation.mBindArgs.clear();\n                    }\n                    for (int i = 0; i < bindArgs.length; i++) {\n                        final Object arg = bindArgs[i];\n                        if (arg != null && arg instanceof byte[]) {\n                            // Don't hold onto the real byte array longer than necessary.\n                            operation.mBindArgs.add(EMPTY_BYTE_ARRAY);\n                        } else {\n                            operation.mBindArgs.add(arg);\n                        }\n                    }\n                }\n                operation.mCookie = newOperationCookieLocked(index);\n                operation.mTid = mAcquiredTid;\n                mIndex = index;\n                return operation;\n            }\n        }\n\n\n        void failOperation(int cookie, Exception ex) {\n            synchronized (mOperations) {\n                final Operation operation = getOperationLocked(cookie);\n                if (operation != null) {\n                    operation.mException = ex;\n                }\n            }\n        }\n\n        void endOperation(int cookie) {\n            final String sql;\n            final String kind;\n            final int type;\n            final long elapsedTimeMillis;\n\n            synchronized (mOperations) {\n                Operation operation = getOperationLocked(cookie);\n                if (endOperationDeferLogLocked(operation)) {\n                    logOperationLocked(operation, null);\n                }\n\n                sql = operation.mSql;\n                kind = operation.mKind;\n                type = operation.mType;\n                elapsedTimeMillis = operation.mEndTime - operation.mStartTime;\n            }\n\n            if (!\"prepare\".equals(kind) && mAcquiredThread != null)\n                mPool.traceExecute(sql, type, elapsedTimeMillis);\n        }\n\n        boolean endOperationDeferLog(int cookie) {\n            final String sql;\n            final String kind;\n            final int type;\n            final long elapsedTimeMillis;\n            final boolean result;\n\n            synchronized (mOperations) {\n                Operation operation = getOperationLocked(cookie);\n                if (operation == null)\n                    return false;\n\n                result = endOperationDeferLogLocked(operation);\n                sql = operation.mSql;\n                kind = operation.mKind;\n                type = operation.mType;\n                elapsedTimeMillis = operation.mEndTime - operation.mStartTime;\n            }\n\n            if (!\"prepare\".equals(kind) && mAcquiredThread != null)\n                mPool.traceExecute(sql, type, elapsedTimeMillis);\n            return result;\n        }\n\n        void logOperation(int cookie, String detail) {\n            synchronized (mOperations) {\n                final Operation operation = getOperationLocked(cookie);\n                if (operation != null)\n                    logOperationLocked(operation, detail);\n            }\n        }\n\n        private boolean endOperationDeferLogLocked(final Operation operation) {\n            if (operation != null) {\n                operation.mEndTime = System.currentTimeMillis();\n                operation.mFinished = true;\n                if (operation.mException != null && operation.mException.getMessage() != null) {\n                    return true;\n                }\n\n                long elapsedTimeMillis = operation.mEndTime - operation.mStartTime;\n                return SQLiteDebug.shouldLogSlowQuery(elapsedTimeMillis);\n            }\n            return false;\n        }\n\n\n        private void logOperationLocked(final Operation operation, String detail) {\n            StringBuilder msg = new StringBuilder();\n            operation.describe(msg, false);\n            if (detail != null) {\n                msg.append(\", \").append(detail);\n            }\n            Log.i(TAG, msg.toString());\n        }\n\n        private int newOperationCookieLocked(int index) {\n            final int generation = mGeneration++;\n            return generation << COOKIE_GENERATION_SHIFT | index;\n        }\n\n        private Operation getOperationLocked(int cookie) {\n            final int index = cookie & COOKIE_INDEX_MASK;\n            final Operation operation = mOperations[index];\n            return operation.mCookie == cookie ? operation : null;\n        }\n\n        String describeCurrentOperation() {\n            synchronized (mOperations) {\n                final Operation operation = mOperations[mIndex];\n                if (operation != null && !operation.mFinished) {\n                    StringBuilder msg = new StringBuilder();\n                    operation.describe(msg, false);\n                    return msg.toString();\n                }\n                return null;\n            }\n        }\n\n        SQLiteTrace.TraceInfo<String> traceCurrentOperation() {\n            synchronized (mOperations) {\n                final Operation operation = mOperations[mIndex];\n                if (operation != null && !operation.mFinished) {\n                    return new SQLiteTrace.TraceInfo<>(operation.mSql,\n                            operation.mStartTime, operation.mTid);\n                }\n                return null;\n            }\n        }\n\n        void dump(Printer printer, boolean verbose) {\n            synchronized (mOperations) {\n                printer.println(\"  Most recently executed operations:\");\n                int index = mIndex;\n                Operation operation = mOperations[index];\n                if (operation != null) {\n                    int n = 0;\n                    do {\n                        StringBuilder msg = new StringBuilder();\n                        msg.append(\"    \").append(n).append(\": [\");\n                        msg.append(operation.getFormattedStartTime());\n                        msg.append(\"] \");\n                        operation.describe(msg, verbose);\n                        printer.println(msg.toString());\n\n                        if (index > 0) {\n                            index -= 1;\n                        } else {\n                            index = MAX_RECENT_OPERATIONS - 1;\n                        }\n                        n += 1;\n                        operation = mOperations[index];\n                    } while (operation != null && n < MAX_RECENT_OPERATIONS);\n                } else {\n                    printer.println(\"    <none>\");\n                }\n            }\n        }\n\n        JSONArray dumpJSON(boolean verbose) throws JSONException {\n            JSONArray arr = new JSONArray();\n            synchronized (mOperations) {\n                int index = mIndex;\n                int n = 0;\n                Operation operation;\n                while ((operation = mOperations[index]) != null && n++ < MAX_RECENT_OPERATIONS) {\n                    arr.put(operation.dumpJSON(verbose));\n                    index = (index > 0) ? index - 1 : MAX_RECENT_OPERATIONS - 1;\n                }\n            }\n            return arr;\n        }\n    }\n\n    @SuppressLint(\"SimpleDateFormat\")\n    private static final class Operation {\n        private static final SimpleDateFormat sDateFormat =\n                new SimpleDateFormat(\"yyyy-MM-dd HH:mm:ss.SSS\");\n\n        long mStartTime;\n        long mEndTime;\n        String mKind;\n        String mSql;\n        ArrayList<Object> mBindArgs;\n        boolean mFinished;\n        Exception mException;\n        int mCookie;\n        int mType;\n        int mTid;\n\n        public void describe(StringBuilder msg, boolean verbose) {\n            msg.append(mKind);\n            if (mFinished) {\n                msg.append(\" took \").append(mEndTime - mStartTime).append(\"ms\");\n            } else {\n                msg.append(\" started \").append(System.currentTimeMillis() - mStartTime)\n                        .append(\"ms ago\");\n            }\n            msg.append(\" - \").append(getStatus());\n            if (mSql != null) {\n                msg.append(\", sql=\\\"\").append(trimSqlForDisplay(mSql)).append(\"\\\"\");\n            }\n            if (mTid > 0) {\n                msg.append(\", tid=\").append(mTid);\n            }\n            if (verbose && mBindArgs != null && mBindArgs.size() != 0) {\n                msg.append(\", bindArgs=[\");\n                final int count = mBindArgs.size();\n                for (int i = 0; i < count; i++) {\n                    final Object arg = mBindArgs.get(i);\n                    if (i != 0) {\n                        msg.append(\", \");\n                    }\n                    if (arg == null) {\n                        msg.append(\"null\");\n                    } else if (arg instanceof byte[]) {\n                        msg.append(\"<byte[]>\");\n                    } else if (arg instanceof String) {\n                        msg.append(\"\\\"\").append((String) arg).append(\"\\\"\");\n                    } else {\n                        msg.append(arg);\n                    }\n                }\n                msg.append(\"]\");\n            }\n            if (mException != null && mException.getMessage() != null) {\n                msg.append(\", exception=\\\"\").append(mException.getMessage()).append(\"\\\"\");\n            }\n        }\n\n        JSONObject dumpJSON(boolean verbose) throws JSONException {\n            return new JSONObject()\n                    .put(\"start\", mStartTime)\n                    .put(\"kind\", mKind)\n                    .put(\"duration\", (mFinished ? mEndTime : System.currentTimeMillis())\n                            - mStartTime)\n                    .put(\"status\", getStatus())\n                    .putOpt(\"sql\", mSql)\n                    .putOpt(\"tid\", (mTid > 0) ? mTid : null)\n                    .putOpt(\"exception\", mException);\n\n            // TODO: verbose?\n        }\n\n        private String getStatus() {\n            if (!mFinished) {\n                return \"running\";\n            }\n            return mException != null ? \"failed\" : \"succeeded\";\n        }\n\n        private String getFormattedStartTime() {\n            return sDateFormat.format(new Date(mStartTime));\n        }\n    }\n\n}\n"
  },
  {
    "path": "deprecated/android/wcdb/src/com/tencent/wcdb/database/SQLiteConnectionPool.java",
    "content": "/*\n * Copyright (C) 2011 The Android Open Source Project\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdb.database;\n\nimport android.os.SystemClock;\nimport android.util.Printer;\n\nimport com.tencent.wcdb.BuildConfig;\nimport com.tencent.wcdb.DatabaseUtils;\nimport com.tencent.wcdb.database.SQLiteDebug.DbStats;\nimport com.tencent.wcdb.support.CancellationSignal;\nimport com.tencent.wcdb.support.Log;\nimport com.tencent.wcdb.support.OperationCanceledException;\nimport com.tencent.wcdb.support.PrefixPrinter;\n\nimport org.json.JSONArray;\nimport org.json.JSONException;\nimport org.json.JSONObject;\n\nimport java.io.Closeable;\nimport java.lang.ref.WeakReference;\nimport java.util.ArrayList;\nimport java.util.Map;\nimport java.util.WeakHashMap;\nimport java.util.concurrent.atomic.AtomicBoolean;\nimport java.util.concurrent.locks.LockSupport;\n\n/**\n * Maintains a pool of active SQLite database connections.\n * <p>\n * At any given time, a connection is either owned by the pool, or it has been\n * acquired by a {@link SQLiteSession}.  When the {@link SQLiteSession} is\n * finished with the connection it is using, it must return the connection\n * back to the pool.\n * </p><p>\n * The pool holds strong references to the connections it owns.  However,\n * it only holds <em>weak references</em> to the connections that sessions\n * have acquired from it.  Using weak references in the latter case ensures\n * that the connection pool can detect when connections have been improperly\n * abandoned so that it can create new connections to replace them if needed.\n * </p><p>\n * The connection pool is thread-safe (but the connections themselves are not).\n * </p>\n *\n * <h2>Exception safety</h2>\n * <p>\n * This code attempts to maintain the invariant that opened connections are\n * always owned.  Unfortunately that means it needs to handle exceptions\n * all over to ensure that broken connections get cleaned up.  Most\n * operations invokving SQLite can throw {@link SQLiteException} or other\n * runtime exceptions.  This is a bit of a pain to deal with because the compiler\n * cannot help us catch missing exception handling code.\n * </p><p>\n * The general rule for this file: If we are making calls out to\n * {@link SQLiteConnection} then we must be prepared to handle any\n * runtime exceptions it might throw at us.  Note that out-of-memory\n * is an {@link Error}, not a {@link RuntimeException}.  We don't trouble ourselves\n * handling out of memory because it is hard to do anything at all sensible then\n * and most likely the VM is about to crash.\n * </p>\n *\n * @hide\n */\npublic final class SQLiteConnectionPool implements Closeable {\n    private static final String TAG = \"WCDB.SQLiteConnectionPool\";\n\n    // Amount of time to wait in milliseconds before unblocking acquireConnection\n    // and logging a message about the connection pool being busy.\n    private static final long CONNECTION_POOL_BUSY_MILLIS = 3000; // 3 seconds\n\n    // Keep reference to SQLiteDatabase which owns this connection pool.\n    private final WeakReference<SQLiteDatabase> mDB;\n    private volatile SQLiteChangeListener mChangeListener;\n    private volatile SQLiteTrace mTraceCallback;\n    private volatile SQLiteCheckpointListener mCheckpointListener;\n\n    private byte[] mPassword;\n    private SQLiteCipherSpec mCipher;\n\n    private final Object mLock = new Object();\n    private final AtomicBoolean mConnectionLeaked = new AtomicBoolean();\n    private final SQLiteDatabaseConfiguration mConfiguration;\n    private int mMaxConnectionPoolSize;\n    private boolean mIsOpen;\n    private int mNextConnectionId;\n\n    private ConnectionWaiter mConnectionWaiterPool;\n    private ConnectionWaiter mConnectionWaiterQueue;\n\n    // Strong references to all available connections.\n    private final ArrayList<SQLiteConnection> mAvailableNonPrimaryConnections =\n            new ArrayList<SQLiteConnection>();\n    private SQLiteConnection mAvailablePrimaryConnection;\n\n    // Describes what should happen to an acquired connection when it is returned to the pool.\n    enum AcquiredConnectionStatus {\n        // The connection should be returned to the pool as usual.\n        NORMAL,\n\n        // The connection must be reconfigured before being returned.\n        RECONFIGURE,\n\n        // The connection must be closed and discarded.\n        DISCARD,\n    }\n\n    // Weak references to all acquired connections.  The associated value\n    // indicates whether the connection must be reconfigured before being\n    // returned to the available connection list or discarded.\n    // For example, the prepared statement cache size may have changed and\n    // need to be updated in preparation for the next client.\n    private final WeakHashMap<SQLiteConnection, AcquiredConnectionStatus> mAcquiredConnections =\n            new WeakHashMap<>();\n\n    private static final int OPEN_FLAG_REOPEN_MASK =\n            SQLiteDatabase.OPEN_READONLY | SQLiteDatabase.NO_LOCALIZED_COLLATORS |\n            SQLiteDatabase.CREATE_IF_NECESSARY;\n\n    /**\n     * Connection flag: Read-only.\n     * <p>\n     * This flag indicates that the connection will only be used to\n     * perform read-only operations.\n     * </p>\n     */\n    public static final int CONNECTION_FLAG_READ_ONLY = 1 << 0;\n\n    /**\n     * Connection flag: Primary connection affinity.\n     * <p>\n     * This flag indicates that the primary connection is required.\n     * This flag helps support legacy applications that expect most data modifying\n     * operations to be serialized by locking the primary database connection.\n     * Setting this flag essentially implements the old \"db lock\" concept by preventing\n     * an operation from being performed until it can obtain exclusive access to\n     * the primary connection.\n     * </p>\n     */\n    public static final int CONNECTION_FLAG_PRIMARY_CONNECTION_AFFINITY = 1 << 1;\n\n    /**\n     * Connection flag: Connection is being used interactively.\n     * <p>\n     * This flag indicates that the connection is needed by the UI thread.\n     * The connection pool can use this flag to elevate the priority\n     * of the database connection request.\n     * </p>\n     */\n    public static final int CONNECTION_FLAG_INTERACTIVE = 1 << 2;\n\n    private SQLiteConnectionPool(SQLiteDatabase db, SQLiteDatabaseConfiguration configuration,\n            int poolSize) {\n        mDB = new WeakReference<>(db);\n        mConfiguration = new SQLiteDatabaseConfiguration(configuration);\n        setMaxConnectionPoolSizeLocked(poolSize);\n    }\n\n    @Override\n    protected void finalize() throws Throwable {\n        try {\n            dispose(true);\n        } finally {\n            super.finalize();\n        }\n    }\n\n    /**\n     * Opens a connection pool for the specified database.\n     *\n     * @param configuration The database configuration.\n     * @return The connection pool.\n     *\n     * @throws SQLiteException if a database error occurs.\n     */\n    public static SQLiteConnectionPool open(SQLiteDatabase db, SQLiteDatabaseConfiguration configuration,\n    \t\tbyte[] password, SQLiteCipherSpec cipher) {\n        return open(db, configuration, password, cipher, 1);\n    }\n    \n    /**\n     * Opens a connection pool for the specified database.\n     *\n     * @param configuration The database configuration.\n     * @return The connection pool.\n     *\n     * @throws SQLiteException if a database error occurs.\n     */\n    public static SQLiteConnectionPool open(SQLiteDatabase db, SQLiteDatabaseConfiguration configuration,\n    \t\tbyte[] password, SQLiteCipherSpec cipher, int poolSize) {\n        if (configuration == null) {\n            throw new IllegalArgumentException(\"configuration must not be null.\");\n        }\n\n        // Create the pool.\n        SQLiteConnectionPool pool = new SQLiteConnectionPool(db, configuration, poolSize);\n        pool.mPassword = password;\n        pool.mCipher = (cipher == null) ? null : new SQLiteCipherSpec(cipher);\n        pool.open(); // might throw\n        return pool;\n    }\n\n    // Might throw\n    private void open() {\n        // Open the primary connection.\n        // This might throw if the database is corrupt.\n        mAvailablePrimaryConnection = openConnectionLocked(mConfiguration,\n                true /*primaryConnection*/); // might throw\n\n        // Mark the pool as being open for business.\n        mIsOpen = true;\n    }\n\n    /**\n     * Closes the connection pool.\n     * <p>\n     * When the connection pool is closed, it will refuse all further requests\n     * to acquire connections.  All connections that are currently available in\n     * the pool are closed immediately.  Any connections that are still in use\n     * will be closed as soon as they are returned to the pool.\n     * </p>\n     *\n     * @throws IllegalStateException if the pool has been closed.\n     */\n    public void close() {\n        dispose(false);\n    }\n\n    private void dispose(boolean finalized) {\n        if (!finalized) {\n            // Close all connections.  We don't need (or want) to do this\n            // when finalized because we don't know what state the connections\n            // themselves will be in.  The finalizer is really just here for CloseGuard.\n            // The connections will take care of themselves when their own finalizers run.\n            synchronized (mLock) {\n                throwIfClosedLocked();\n\n                mIsOpen = false;\n\n                closeAvailableConnectionsAndLogExceptionsLocked();\n\n                final int pendingCount = mAcquiredConnections.size();\n                if (pendingCount != 0) {\n                    Log.i(TAG, \"The connection pool for \" + mConfiguration.label\n                            + \" has been closed but there are still \"\n                            + pendingCount + \" connections in use.  They will be closed \"\n                            + \"as they are released back to the pool.\");\n                }\n\n                wakeConnectionWaitersLocked();\n            }\n        }\n    }\n\n    /**\n     * Reconfigures the database configuration of the connection pool and all of its\n     * connections.\n     * <p>\n     * Configuration changes are propagated down to connections immediately if\n     * they are available or as soon as they are released.  This includes changes\n     * that affect the size of the pool.\n     * </p>\n     *\n     * @param configuration The new configuration.\n     *\n     * @throws IllegalStateException if the pool has been closed.\n     */\n    public void reconfigure(SQLiteDatabaseConfiguration configuration) {\n        if (configuration == null) {\n            throw new IllegalArgumentException(\"configuration must not be null.\");\n        }\n\n        synchronized (mLock) {\n            throwIfClosedLocked();\n\n            boolean walModeChanged = ((configuration.openFlags ^ mConfiguration.openFlags)\n                    & SQLiteDatabase.ENABLE_WRITE_AHEAD_LOGGING) != 0;\n            if (walModeChanged) {\n                // WAL mode can only be changed if there are no acquired connections\n                // because we need to close all but the primary connection first.\n                if (!mAcquiredConnections.isEmpty()) {\n                    throw new IllegalStateException(\"Write Ahead Logging (WAL) mode cannot \"\n                            + \"be enabled or disabled while there are transactions in \"\n                            + \"progress.  Finish all transactions and release all active \"\n                            + \"database connections first.\");\n                }\n\n                // Close all non-primary connections.  This should happen immediately\n                // because none of them are in use.\n                closeAvailableNonPrimaryConnectionsAndLogExceptionsLocked();\n                if (BuildConfig.DEBUG && !mAvailableNonPrimaryConnections.isEmpty())\n                    throw new AssertionError(\"mAvailableNonPrimaryConnections.isEmpty()\");\n            }\n\n            boolean foreignKeyModeChanged = configuration.foreignKeyConstraintsEnabled\n                    != mConfiguration.foreignKeyConstraintsEnabled;\n            if (foreignKeyModeChanged) {\n                // Foreign key constraints can only be changed if there are no transactions\n                // in progress.  To make this clear, we throw an exception if there are\n                // any acquired connections.\n                if (!mAcquiredConnections.isEmpty()) {\n                    throw new IllegalStateException(\"Foreign Key Constraints cannot \"\n                            + \"be enabled or disabled while there are transactions in \"\n                            + \"progress.  Finish all transactions and release all active \"\n                            + \"database connections first.\");\n                }\n            }\n\n            if (((mConfiguration.openFlags ^ configuration.openFlags) & OPEN_FLAG_REOPEN_MASK) != 0 ||\n                    !DatabaseUtils.objectEquals(mConfiguration.vfsName, configuration.vfsName) ||\n                    !configuration.extensions.containsAll(mConfiguration.extensions)) {\n                // If we are changing open flags and WAL mode at the same time, then\n                // we have no choice but to close the primary connection beforehand\n                // because there can only be one connection open when we change WAL mode.\n                if (walModeChanged) {\n                    closeAvailableConnectionsAndLogExceptionsLocked();\n                }\n\n                // Try to reopen the primary connection using the new open flags then\n                // close and discard all existing connections.\n                // This might throw if the database is corrupt or cannot be opened in\n                // the new mode in which case existing connections will remain untouched.\n                SQLiteConnection newPrimaryConnection = openConnectionLocked(configuration,\n                        true /*primaryConnection*/); // might throw\n\n                closeAvailableConnectionsAndLogExceptionsLocked();\n                discardAcquiredConnectionsLocked();\n\n                mAvailablePrimaryConnection = newPrimaryConnection;\n                mConfiguration.updateParametersFrom(configuration);\n                setMaxConnectionPoolSizeLocked(0);\n            } else {\n                // Reconfigure the database connections in place.\n                mConfiguration.updateParametersFrom(configuration);\n                setMaxConnectionPoolSizeLocked(0);\n\n                closeExcessConnectionsAndLogExceptionsLocked();\n                reconfigureAllConnectionsLocked();\n            }\n\n            wakeConnectionWaitersLocked();\n        }\n    }\n\n    /**\n     * Acquires a connection from the pool.\n     * <p>\n     * The caller must call {@link #releaseConnection} to release the connection\n     * back to the pool when it is finished.  Failure to do so will result\n     * in much unpleasantness.\n     * </p>\n     *\n     * @param sql If not null, try to find a connection that already has\n     * the specified SQL statement in its prepared statement cache.\n     * @param connectionFlags The connection request flags.\n     * @param cancellationSignal A signal to cancel the operation in progress, or null if none.\n     * @return The connection that was acquired, never null.\n     *\n     * @throws IllegalStateException if the pool has been closed.\n     * @throws SQLiteException if a database error occurs.\n     * @throws OperationCanceledException if the operation was canceled.\n     */\n    public SQLiteConnection acquireConnection(String sql, int connectionFlags,\n            CancellationSignal cancellationSignal) {\n        long startTime = SystemClock.uptimeMillis();\n\n        SQLiteConnection connection = waitForConnection(sql, connectionFlags, cancellationSignal);\n\n        SQLiteTrace callback = mTraceCallback;\n        if (callback != null) {\n            long waitTime = SystemClock.uptimeMillis() - startTime;\n            SQLiteDatabase db = mDB.get();\n            if (db != null) {\n                final boolean isPrimary =\n                        (connectionFlags & CONNECTION_FLAG_PRIMARY_CONNECTION_AFFINITY) != 0;\n                callback.onConnectionObtained(db, sql, waitTime, isPrimary);\n            }\n        }\n\n        return connection;\n    }\n\n    /**\n     * Releases a connection back to the pool.\n     * <p>\n     * It is ok to call this method after the pool has closed, to release\n     * connections that were still in use at the time of closure.\n     * </p>\n     *\n     * @param connection The connection to release.  Must not be null.\n     *\n     * @throws IllegalStateException if the connection was not acquired\n     * from this pool or if it has already been released.\n     */\n    public void releaseConnection(SQLiteConnection connection) {\n        synchronized (mLock) {\n            AcquiredConnectionStatus status = mAcquiredConnections.remove(connection);\n            if (status == null) {\n                throw new IllegalStateException(\"Cannot perform this operation \"\n                        + \"because the specified connection was not acquired \"\n                        + \"from this pool or has already been released.\");\n            }\n\n            if (!mIsOpen) {\n                closeConnectionAndLogExceptionsLocked(connection);\n            } else if (connection.isPrimaryConnection()) {\n                if (recycleConnectionLocked(connection, status)) {\n                    assert mAvailablePrimaryConnection == null;\n                    mAvailablePrimaryConnection = connection;\n                }\n                wakeConnectionWaitersLocked();\n            } else if (mAvailableNonPrimaryConnections.size() >= mMaxConnectionPoolSize - 1) {\n                closeConnectionAndLogExceptionsLocked(connection);\n            } else {\n                if (recycleConnectionLocked(connection, status)) {\n                    mAvailableNonPrimaryConnections.add(connection);\n                }\n                wakeConnectionWaitersLocked();\n            }\n        }\n    }\n\n    // Can't throw.\n    private boolean recycleConnectionLocked(SQLiteConnection connection,\n            AcquiredConnectionStatus status) {\n        if (status == AcquiredConnectionStatus.RECONFIGURE) {\n            try {\n                connection.reconfigure(mConfiguration); // might throw\n            } catch (RuntimeException ex) {\n                Log.e(TAG, \"Failed to reconfigure released connection, closing it: \"\n                        + connection, ex);\n                status = AcquiredConnectionStatus.DISCARD;\n            }\n        }\n        if (status == AcquiredConnectionStatus.DISCARD) {\n            closeConnectionAndLogExceptionsLocked(connection);\n            return false;\n        }\n        return true;\n    }\n\n    /**\n     * Returns true if the session should yield the connection due to\n     * contention over available database connections.\n     *\n     * @param connection The connection owned by the session.\n     * @param connectionFlags The connection request flags.\n     * @return True if the session should yield its connection.\n     *\n     * @throws IllegalStateException if the connection was not acquired\n     * from this pool or if it has already been released.\n     */\n    public boolean shouldYieldConnection(SQLiteConnection connection, int connectionFlags) {\n        synchronized (mLock) {\n            if (!mAcquiredConnections.containsKey(connection)) {\n                throw new IllegalStateException(\"Cannot perform this operation \"\n                        + \"because the specified connection was not acquired \"\n                        + \"from this pool or has already been released.\");\n            }\n\n            if (!mIsOpen) {\n                return false;\n            }\n\n            return isSessionBlockingImportantConnectionWaitersLocked(\n                    connection.isPrimaryConnection(), connectionFlags);\n        }\n    }\n\n    /**\n     * Collects statistics about database connection memory usage.\n     *\n     * @param dbStatsList The list to populate.\n     */\n    public void collectDbStats(ArrayList<DbStats> dbStatsList) {\n        synchronized (mLock) {\n            if (mAvailablePrimaryConnection != null) {\n                mAvailablePrimaryConnection.collectDbStats(dbStatsList);\n            }\n\n            for (SQLiteConnection connection : mAvailableNonPrimaryConnections) {\n                connection.collectDbStats(dbStatsList);\n            }\n\n            for (SQLiteConnection connection : mAcquiredConnections.keySet()) {\n                connection.collectDbStatsUnsafe(dbStatsList);\n            }\n        }\n    }\n\n    // Might throw.\n    private SQLiteConnection openConnectionLocked(SQLiteDatabaseConfiguration configuration,\n            boolean primaryConnection) {\n        final int connectionId = mNextConnectionId++;\n        return SQLiteConnection.open(this, configuration,\n                connectionId, primaryConnection, mPassword, mCipher); // might throw\n    }\n\n    void onConnectionLeaked() {\n        // This code is running inside of the SQLiteConnection finalizer.\n        //\n        // We don't know whether it is just the connection that has been finalized (and leaked)\n        // or whether the connection pool has also been or is about to be finalized.\n        // Consequently, it would be a bad idea to try to grab any locks or to\n        // do any significant work here.  So we do the simplest possible thing and\n        // set a flag.  waitForConnection() periodically checks this flag (when it\n        // times out) so that it can recover from leaked connections and wake\n        // itself or other threads up if necessary.\n        //\n        // You might still wonder why we don't try to do more to wake up the waiters\n        // immediately.  First, as explained above, it would be hard to do safely\n        // unless we started an extra Thread to function as a reference queue.  Second,\n        // this is never supposed to happen in normal operation.  Third, there is no\n        // guarantee that the GC will actually detect the leak in a timely manner so\n        // it's not all that important that we recover from the leak in a timely manner\n        // either.  Fourth, if a badly behaved application finds itself hung waiting for\n        // several seconds while waiting for a leaked connection to be detected and recreated,\n        // then perhaps its authors will have added incentive to fix the problem!\n\n        Log.w(TAG, \"A SQLiteConnection object for database '\"\n                + mConfiguration.label + \"' was leaked!  Please fix your application \"\n                + \"to end transactions in progress properly and to close the database \"\n                + \"when it is no longer needed.\");\n\n        mConnectionLeaked.set(true);\n    }\n\n    // Can't throw.\n    private void closeAvailableConnectionsAndLogExceptionsLocked() {\n        closeAvailableNonPrimaryConnectionsAndLogExceptionsLocked();\n\n        if (mAvailablePrimaryConnection != null) {\n            closeConnectionAndLogExceptionsLocked(mAvailablePrimaryConnection);\n            mAvailablePrimaryConnection = null;\n        }\n    }\n\n    // Can't throw.\n    private void closeAvailableNonPrimaryConnectionsAndLogExceptionsLocked() {\n        final int count = mAvailableNonPrimaryConnections.size();\n        for (int i = 0; i < count; i++) {\n            closeConnectionAndLogExceptionsLocked(mAvailableNonPrimaryConnections.get(i));\n        }\n        mAvailableNonPrimaryConnections.clear();\n    }\n\n    // Can't throw.\n    private void closeExcessConnectionsAndLogExceptionsLocked() {\n        int availableCount = mAvailableNonPrimaryConnections.size();\n        while (availableCount-- > mMaxConnectionPoolSize - 1) {\n            SQLiteConnection connection =\n                    mAvailableNonPrimaryConnections.remove(availableCount);\n            closeConnectionAndLogExceptionsLocked(connection);\n        }\n    }\n    \n\n    // Can't throw.\n    private void closeConnectionAndLogExceptionsLocked(SQLiteConnection connection) {\n        try {\n            connection.close(); // might throw\n        } catch (RuntimeException ex) {\n            Log.e(TAG, \"Failed to close connection, its fate is now in the hands \"\n                    + \"of the merciful GC: \" + connection + ex.getMessage());\n        }\n    }\n\n    // Can't throw.\n    private void discardAcquiredConnectionsLocked() {\n        markAcquiredConnectionsLocked(AcquiredConnectionStatus.DISCARD);\n    }\n\n    // Can't throw.\n    private void reconfigureAllConnectionsLocked() {\n        if (mAvailablePrimaryConnection != null) {\n            try {\n                mAvailablePrimaryConnection.reconfigure(mConfiguration); // might throw\n            } catch (RuntimeException ex) {\n                Log.e(TAG, \"Failed to reconfigure available primary connection, closing it: \"\n                        + mAvailablePrimaryConnection, ex);\n                closeConnectionAndLogExceptionsLocked(mAvailablePrimaryConnection);\n                mAvailablePrimaryConnection = null;\n            }\n        }\n\n        int count = mAvailableNonPrimaryConnections.size();\n        for (int i = 0; i < count; i++) {\n            final SQLiteConnection connection = mAvailableNonPrimaryConnections.get(i);\n            try {\n                connection.reconfigure(mConfiguration); // might throw\n            } catch (RuntimeException ex) {\n                Log.e(TAG, \"Failed to reconfigure available non-primary connection, closing it: \"\n                        + connection, ex);\n                closeConnectionAndLogExceptionsLocked(connection);\n                mAvailableNonPrimaryConnections.remove(i--);\n                count -= 1;\n            }\n        }\n\n        markAcquiredConnectionsLocked(AcquiredConnectionStatus.RECONFIGURE);\n    }\n\n    // Can't throw.\n    private void markAcquiredConnectionsLocked(AcquiredConnectionStatus status) {\n        if (!mAcquiredConnections.isEmpty()) {\n            ArrayList<SQLiteConnection> keysToUpdate = new ArrayList<SQLiteConnection>(\n                    mAcquiredConnections.size());\n            for (Map.Entry<SQLiteConnection, AcquiredConnectionStatus> entry\n                    : mAcquiredConnections.entrySet()) {\n                AcquiredConnectionStatus oldStatus = entry.getValue();\n                if (status != oldStatus\n                        && oldStatus != AcquiredConnectionStatus.DISCARD) {\n                    keysToUpdate.add(entry.getKey());\n                }\n            }\n            final int updateCount = keysToUpdate.size();\n            for (int i = 0; i < updateCount; i++) {\n                mAcquiredConnections.put(keysToUpdate.get(i), status);\n            }\n        }\n    }\n\n    // Might throw.\n    private SQLiteConnection waitForConnection(String sql, int connectionFlags,\n            CancellationSignal cancellationSignal) {\n        final boolean wantPrimaryConnection =\n                (connectionFlags & CONNECTION_FLAG_PRIMARY_CONNECTION_AFFINITY) != 0;\n\n        final ConnectionWaiter waiter;\n        final int nonce;\n        synchronized (mLock) {\n            throwIfClosedLocked();\n\n            // Abort if canceled.\n            if (cancellationSignal != null) {\n                cancellationSignal.throwIfCanceled();\n            }\n\n            // Try to acquire a connection.\n            SQLiteConnection connection = null;\n            if (!wantPrimaryConnection) {\n                connection = tryAcquireNonPrimaryConnectionLocked(\n                        sql, connectionFlags); // might throw\n            }\n            if (connection == null) {\n                connection = tryAcquirePrimaryConnectionLocked(connectionFlags); // might throw\n            }\n            if (connection != null) {\n                return connection;\n            }\n\n            // No connections available.  Enqueue a waiter in priority order.\n            final int priority = getPriority(connectionFlags);\n            final long startTime = SystemClock.uptimeMillis();\n            waiter = obtainConnectionWaiterLocked(Thread.currentThread(), startTime,\n                    priority, wantPrimaryConnection, sql, connectionFlags);\n            ConnectionWaiter predecessor = null;\n            ConnectionWaiter successor = mConnectionWaiterQueue;\n            while (successor != null) {\n                if (priority > successor.mPriority) {\n                    waiter.mNext = successor;\n                    break;\n                }\n                predecessor = successor;\n                successor = successor.mNext;\n            }\n            if (predecessor != null) {\n                predecessor.mNext = waiter;\n            } else {\n                mConnectionWaiterQueue = waiter;\n            }\n\n            nonce = waiter.mNonce;\n        }\n\n        // Set up the cancellation listener.\n        if (cancellationSignal != null) {\n            cancellationSignal.setOnCancelListener(new CancellationSignal.OnCancelListener() {\n                @Override\n                public void onCancel() {\n                    synchronized (mLock) {\n                        if (waiter.mNonce == nonce) {\n                            cancelConnectionWaiterLocked(waiter);\n                        }\n                    }\n                }\n            });\n        }\n        try {\n            // Park the thread until a connection is assigned or the pool is closed.\n            // Rethrow an exception from the wait, if we got one.\n            long busyTimeoutMillis = CONNECTION_POOL_BUSY_MILLIS;\n            long nextBusyTimeoutTime = waiter.mStartTime + busyTimeoutMillis;\n            for (;;) {\n                // Detect and recover from connection leaks.\n                if (mConnectionLeaked.compareAndSet(true, false)) {\n                    synchronized (mLock) {\n                        wakeConnectionWaitersLocked();\n                    }\n                }\n\n                // Wait to be unparked (may already have happened), a timeout, or interruption.\n                LockSupport.parkNanos(busyTimeoutMillis * 1000000L);\n\n                // Clear the interrupted flag, just in case.\n                Thread.interrupted();\n\n                // Check whether we are done waiting yet.\n                ConnectionPoolBusyInfo busyInfo = null;\n                final long now;\n                synchronized (mLock) {\n                    throwIfClosedLocked();\n\n                    final SQLiteConnection connection = waiter.mAssignedConnection;\n                    final RuntimeException ex = waiter.mException;\n                    if (connection != null || ex != null) {\n                        recycleConnectionWaiterLocked(waiter);\n                        if (connection != null) {\n                            return connection;\n                        }\n                        throw ex; // rethrow!\n                    }\n\n                    now = SystemClock.uptimeMillis();\n                    if (now < nextBusyTimeoutTime) {\n                        busyTimeoutMillis = now - nextBusyTimeoutTime;\n                    } else {\n                        busyInfo = gatherConnectionPoolBusyInfoLocked();\n                        busyTimeoutMillis = CONNECTION_POOL_BUSY_MILLIS;\n                        nextBusyTimeoutTime = now + busyTimeoutMillis;\n                    }\n                }\n\n                if (busyInfo != null) {\n                    long waitMillis = now - waiter.mStartTime;\n                    logConnectionPoolBusy(busyInfo, waitMillis, connectionFlags);\n\n                    SQLiteDatabase db = mDB.get();\n                    SQLiteTrace callback = mTraceCallback;\n                    if (db != null && callback != null) {\n                        callback.onConnectionPoolBusy(db, sql, waitMillis, wantPrimaryConnection,\n                                busyInfo.activeSql, busyInfo.activeTransactions);\n                    }\n                }\n            }\n        } finally {\n            // Remove the cancellation listener.\n            if (cancellationSignal != null) {\n                cancellationSignal.setOnCancelListener(null);\n            }\n        }\n    }\n\n    // Can't throw.\n    private void cancelConnectionWaiterLocked(ConnectionWaiter waiter) {\n        if (waiter.mAssignedConnection != null || waiter.mException != null) {\n            // Waiter is done waiting but has not woken up yet.\n            return;\n        }\n\n        // Waiter must still be waiting.  Dequeue it.\n        ConnectionWaiter predecessor = null;\n        ConnectionWaiter current = mConnectionWaiterQueue;\n        while (current != waiter) {\n            assert current != null;\n            predecessor = current;\n            current = current.mNext;\n        }\n        if (predecessor != null) {\n            predecessor.mNext = waiter.mNext;\n        } else {\n            mConnectionWaiterQueue = waiter.mNext;\n        }\n\n        // Send the waiter an exception and unpark it.\n        waiter.mException = new OperationCanceledException();\n        LockSupport.unpark(waiter.mThread);\n\n        // Check whether removing this waiter will enable other waiters to make progress.\n        wakeConnectionWaitersLocked();\n    }\n\n    private static class ConnectionPoolBusyInfo {\n        String label;\n        ArrayList<String> activeOperationDescriptions = new ArrayList<>();\n        int activeConnections;\n        int idleConnections;\n        int availableConnections;\n\n        ArrayList<SQLiteTrace.TraceInfo<String>> activeSql = new ArrayList<>();\n        ArrayList<SQLiteTrace.TraceInfo<StackTraceElement[]>> activeTransactions = new ArrayList<>();\n    }\n\n    private void logConnectionPoolBusy(ConnectionPoolBusyInfo info, long waitMillis,\n                                       int connectionFlags) {\n        StringBuilder msg = new StringBuilder();\n        if (waitMillis != 0) {\n            final Thread thread = Thread.currentThread();\n            msg.append(\"The connection pool for database '\").append(info.label);\n            msg.append(\"' has been unable to grant a connection to thread \");\n            msg.append(thread.getId()).append(\" (\").append(thread.getName()).append(\") \");\n            msg.append(\"with flags 0x\").append(Integer.toHexString(connectionFlags));\n            msg.append(\" for \").append(waitMillis * 0.001f).append(\" seconds.\\n\");\n        }\n\n        msg.append(\"Connections: \").append(info.activeConnections).append(\" active, \");\n        msg.append(info.idleConnections).append(\" idle, \");\n        msg.append(info.availableConnections).append(\" available.\\n\");\n\n        if (!info.activeOperationDescriptions.isEmpty()) {\n            msg.append(\"\\nRequests in progress:\\n\");\n            for (String request : info.activeOperationDescriptions) {\n                msg.append(\"  \").append(request).append(\"\\n\");\n            }\n        }\n\n        String message = msg.toString();\n        Log.w(TAG, message);\n    }\n\n    // Can't throw.\n    private ConnectionPoolBusyInfo gatherConnectionPoolBusyInfoLocked() {\n        ConnectionPoolBusyInfo info = new ConnectionPoolBusyInfo();\n\n        info.activeConnections = 0;\n        info.idleConnections = 0;\n        if (!mAcquiredConnections.isEmpty()) {\n            for (SQLiteConnection connection : mAcquiredConnections.keySet()) {\n                SQLiteTrace.TraceInfo<StackTraceElement[]> persistTrace =\n                        connection.tracePersistAcquisitionUnsafe();\n                if (persistTrace != null) {\n                    info.activeTransactions.add(persistTrace);\n                }\n\n                SQLiteTrace.TraceInfo<String> opTrace = connection.traceCurrentOperationUnsafe();\n                if (opTrace != null) {\n                    info.activeSql.add(opTrace);\n                    String description = connection.describeCurrentOperationUnsafe();\n                    if (description != null) {\n                        info.activeOperationDescriptions.add(description);\n                    }\n                    info.activeConnections += 1;\n                } else {\n                    info.idleConnections += 1;\n                }\n            }\n        }\n\n        info.availableConnections = mAvailableNonPrimaryConnections.size();\n        if (mAvailablePrimaryConnection != null) {\n            info.availableConnections += 1;\n        }\n\n        return info;\n    }\n\n    // Can't throw.\n    private void wakeConnectionWaitersLocked() {\n        // Unpark all waiters that have requests that we can fulfill.\n        // This method is designed to not throw runtime exceptions, although we might send\n        // a waiter an exception for it to rethrow.\n        ConnectionWaiter predecessor = null;\n        ConnectionWaiter waiter = mConnectionWaiterQueue;\n        boolean primaryConnectionNotAvailable = false;\n        boolean nonPrimaryConnectionNotAvailable = false;\n        while (waiter != null) {\n            boolean unpark = false;\n            if (!mIsOpen) {\n                unpark = true;\n            } else {\n                try {\n                    SQLiteConnection connection = null;\n                    if (!waiter.mWantPrimaryConnection && !nonPrimaryConnectionNotAvailable) {\n                        connection = tryAcquireNonPrimaryConnectionLocked(\n                                waiter.mSql, waiter.mConnectionFlags); // might throw\n                        if (connection == null) {\n                            nonPrimaryConnectionNotAvailable = true;\n                        }\n                    }\n                    if (connection == null && !primaryConnectionNotAvailable) {\n                        connection = tryAcquirePrimaryConnectionLocked(\n                                waiter.mConnectionFlags); // might throw\n                        if (connection == null) {\n                            primaryConnectionNotAvailable = true;\n                        }\n                    }\n                    if (connection != null) {\n                        waiter.mAssignedConnection = connection;\n                        unpark = true;\n                    } else if (nonPrimaryConnectionNotAvailable && primaryConnectionNotAvailable) {\n                        // There are no connections available and the pool is still open.\n                        // We cannot fulfill any more connection requests, so stop here.\n                        break;\n                    }\n                } catch (RuntimeException ex) {\n                    // Let the waiter handle the exception from acquiring a connection.\n                    waiter.mException = ex;\n                    unpark = true;\n                }\n            }\n\n            final ConnectionWaiter successor = waiter.mNext;\n            if (unpark) {\n                if (predecessor != null) {\n                    predecessor.mNext = successor;\n                } else {\n                    mConnectionWaiterQueue = successor;\n                }\n                waiter.mNext = null;\n\n                LockSupport.unpark(waiter.mThread);\n            } else {\n                predecessor = waiter;\n            }\n            waiter = successor;\n        }\n    }\n\n    // Might throw.\n    private SQLiteConnection tryAcquirePrimaryConnectionLocked(int connectionFlags) {\n        // If the primary connection is available, acquire it now.\n        SQLiteConnection connection = mAvailablePrimaryConnection;\n        if (connection != null) {\n            mAvailablePrimaryConnection = null;\n            finishAcquireConnectionLocked(connection, connectionFlags); // might throw\n            return connection;\n        }\n\n        // Make sure that the primary connection actually exists and has just been acquired.\n        for (SQLiteConnection acquiredConnection : mAcquiredConnections.keySet()) {\n            if (acquiredConnection.isPrimaryConnection()) {\n                return null;\n            }\n        }\n\n        // Uhoh.  No primary connection!  Either this is the first time we asked\n        // for it, or maybe it leaked?\n        connection = openConnectionLocked(mConfiguration,\n                true /*primaryConnection*/); // might throw\n        finishAcquireConnectionLocked(connection, connectionFlags); // might throw\n        return connection;\n    }\n\n    // Might throw.\n    private SQLiteConnection tryAcquireNonPrimaryConnectionLocked(\n            String sql, int connectionFlags) {\n        // Try to acquire the next connection in the queue.\n        SQLiteConnection connection;\n        final int availableCount = mAvailableNonPrimaryConnections.size();\n        if (availableCount > 1 && sql != null) {\n            // If we have a choice, then prefer a connection that has the\n            // prepared statement in its cache.\n            for (int i = 0; i < availableCount; i++) {\n                connection = mAvailableNonPrimaryConnections.get(i);\n                if (connection.isPreparedStatementInCache(sql)) {\n                    mAvailableNonPrimaryConnections.remove(i);\n                    finishAcquireConnectionLocked(connection, connectionFlags); // might throw\n                    return connection;\n                }\n            }\n        }\n        if (availableCount > 0) {\n            // Otherwise, just grab the next one.\n            connection = mAvailableNonPrimaryConnections.remove(availableCount - 1);\n            finishAcquireConnectionLocked(connection, connectionFlags); // might throw\n            return connection;\n        }\n\n        // Expand the pool if needed.\n        int openConnections = mAcquiredConnections.size();\n        if (mAvailablePrimaryConnection != null) {\n            openConnections += 1;\n        }\n        if (openConnections >= mMaxConnectionPoolSize) {\n            return null;\n        }\n        connection = openConnectionLocked(mConfiguration,\n                false /*primaryConnection*/); // might throw\n        finishAcquireConnectionLocked(connection, connectionFlags); // might throw\n        return connection;\n    }\n\n    // Might throw.\n    private void finishAcquireConnectionLocked(SQLiteConnection connection, int connectionFlags) {\n        try {\n            final boolean readOnly = (connectionFlags & CONNECTION_FLAG_READ_ONLY) != 0;\n            connection.setOnlyAllowReadOnlyOperations(readOnly);\n\n            mAcquiredConnections.put(connection, AcquiredConnectionStatus.NORMAL);\n        } catch (RuntimeException ex) {\n            Log.e(TAG, \"Failed to prepare acquired connection for session, closing it: \"\n                    + connection +\", connectionFlags=\" + connectionFlags);\n            closeConnectionAndLogExceptionsLocked(connection);\n            throw ex; // rethrow!\n        }\n    }\n\n    private boolean isSessionBlockingImportantConnectionWaitersLocked(\n            boolean holdingPrimaryConnection, int connectionFlags) {\n        ConnectionWaiter waiter = mConnectionWaiterQueue;\n        if (waiter != null) {\n            final int priority = getPriority(connectionFlags);\n            do {\n                // Only worry about blocked connections that have same or lower priority.\n                if (priority > waiter.mPriority) {\n                    break;\n                }\n\n                // If we are holding the primary connection then we are blocking the waiter.\n                // Likewise, if we are holding a non-primary connection and the waiter\n                // would accept a non-primary connection, then we are blocking the waier.\n                if (holdingPrimaryConnection || !waiter.mWantPrimaryConnection) {\n                    return true;\n                }\n\n                waiter = waiter.mNext;\n            } while (waiter != null);\n        }\n        return false;\n    }\n\n    private static int getPriority(int connectionFlags) {\n        return (connectionFlags & CONNECTION_FLAG_INTERACTIVE) != 0 ? 1 : 0;\n    }\n\n    private void setMaxConnectionPoolSizeLocked(int poolSize) {\n        if (poolSize <= 0) {\n            if ((mConfiguration.openFlags & SQLiteDatabase.ENABLE_WRITE_AHEAD_LOGGING) != 0) {\n                poolSize = SQLiteGlobal.walConnectionPoolSize;\n            } else {\n                // TODO: We don't actually need to restrict the connection pool size to 1\n                // for non-WAL databases.  There might be reasons to use connection pooling\n                // with other journal modes.  For now, enabling connection pooling and\n                // using WAL are the same thing in the API.\n                poolSize = 1;\n            }\n        }\n\n        mMaxConnectionPoolSize = poolSize;\n        Log.i(TAG, \"Max connection pool size is %d.\", mMaxConnectionPoolSize);\n    }\n\n    private void throwIfClosedLocked() {\n        if (!mIsOpen) {\n            throw new IllegalStateException(\"Cannot perform this operation \"\n                    + \"because the connection pool has been closed.\");\n        }\n    }\n\n    private ConnectionWaiter obtainConnectionWaiterLocked(Thread thread, long startTime,\n            int priority, boolean wantPrimaryConnection, String sql, int connectionFlags) {\n        ConnectionWaiter waiter = mConnectionWaiterPool;\n        if (waiter != null) {\n            mConnectionWaiterPool = waiter.mNext;\n            waiter.mNext = null;\n        } else {\n            waiter = new ConnectionWaiter();\n        }\n        waiter.mThread = thread;\n        waiter.mStartTime = startTime;\n        waiter.mPriority = priority;\n        waiter.mWantPrimaryConnection = wantPrimaryConnection;\n        waiter.mSql = sql;\n        waiter.mConnectionFlags = connectionFlags;\n        return waiter;\n    }\n\n    private void recycleConnectionWaiterLocked(ConnectionWaiter waiter) {\n        waiter.mNext = mConnectionWaiterPool;\n        waiter.mThread = null;\n        waiter.mSql = null;\n        waiter.mAssignedConnection = null;\n        waiter.mException = null;\n        waiter.mNonce += 1;\n        mConnectionWaiterPool = waiter;\n    }\n\n    SQLiteChangeListener getChangeListener() {\n        return mChangeListener;\n    }\n\n    void setChangeListener(SQLiteChangeListener listener, boolean notifyRowId) {\n        boolean notifyEnabled = (listener != null);\n        if (!notifyEnabled)\n            notifyRowId = false;\n\n        synchronized (mLock) {\n            if (mConfiguration.updateNotificationEnabled != notifyEnabled ||\n                    mConfiguration.updateNotificationRowID != notifyRowId) {\n                mConfiguration.updateNotificationEnabled = notifyEnabled;\n                mConfiguration.updateNotificationRowID = notifyRowId;\n\n                closeExcessConnectionsAndLogExceptionsLocked();\n                reconfigureAllConnectionsLocked();\n            }\n\n            mChangeListener = listener;\n        }\n    }\n\n    void notifyChanges(String dbName, String table,\n            long[] insertIds, long[] updateIds, long[] deleteIds) {\n        SQLiteDatabase db = mDB.get();\n        SQLiteChangeListener listener = mChangeListener;\n\n        if (listener == null || db == null)\n            return;\n        listener.onChange(db, dbName, table, insertIds, updateIds, deleteIds);\n    }\n\n    SQLiteTrace getTraceCallback() {\n        return mTraceCallback;\n    }\n\n    void setTraceCallback(SQLiteTrace callback) {\n        mTraceCallback = callback;\n    }\n\n    void traceExecute(String sql, int type, long time) {\n        SQLiteDatabase db = mDB.get();\n        SQLiteTrace trace = mTraceCallback;\n\n        if (trace == null || db == null || sql == null)\n            return;\n        trace.onSQLExecuted(db, sql, type, time);\n    }\n\n    SQLiteCheckpointListener getCheckpointListener() {\n        return mCheckpointListener;\n    }\n\n    void setCheckpointListener(SQLiteCheckpointListener listener) {\n        SQLiteDatabase db = mDB.get();\n\n        if (mCheckpointListener != null)\n            mCheckpointListener.onDetach(db);\n\n        mCheckpointListener = listener;\n\n        if (mCheckpointListener != null)\n            mCheckpointListener.onAttach(db);\n    }\n\n    /*package*/ void notifyCheckpoint(String dbName, int pages) {\n        SQLiteDatabase db = mDB.get();\n        SQLiteCheckpointListener walHook = mCheckpointListener;\n\n        if (walHook == null || db == null)\n            return;\n        walHook.onWALCommit(db, dbName, pages);\n    }\n\n    /**\n     * Dumps debugging information about this connection pool.\n     *\n     * @param printer The printer to receive the dump, not null.\n     * @param verbose True to dump more verbose information.\n     */\n    void dump(Printer printer, boolean verbose) {\n        Printer indentedPrinter = PrefixPrinter.create(printer, \"    \");\n        synchronized (mLock) {\n            printer.println(\"Connection pool for \" + mConfiguration.path + \":\");\n            printer.println(\"  Open: \" + mIsOpen);\n            printer.println(\"  Max connections: \" + mMaxConnectionPoolSize);\n\n            printer.println(\"  Available primary connection:\");\n            if (mAvailablePrimaryConnection != null) {\n                mAvailablePrimaryConnection.dump(indentedPrinter, verbose);\n            } else {\n                indentedPrinter.println(\"<none>\");\n            }\n\n            printer.println(\"  Available non-primary connections:\");\n            if (!mAvailableNonPrimaryConnections.isEmpty()) {\n                final int count = mAvailableNonPrimaryConnections.size();\n                for (int i = 0; i < count; i++) {\n                    mAvailableNonPrimaryConnections.get(i).dump(indentedPrinter, verbose);\n                }\n            } else {\n                indentedPrinter.println(\"<none>\");\n            }\n\n            printer.println(\"  Acquired connections:\");\n            if (!mAcquiredConnections.isEmpty()) {\n                for (Map.Entry<SQLiteConnection, AcquiredConnectionStatus> entry :\n                        mAcquiredConnections.entrySet()) {\n                    final SQLiteConnection connection = entry.getKey();\n                    connection.dump(indentedPrinter, verbose);\n                    indentedPrinter.println(\"  Status: \" + entry.getValue());\n                }\n            } else {\n                indentedPrinter.println(\"<none>\");\n            }\n\n            printer.println(\"  Connection waiters:\");\n            if (mConnectionWaiterQueue != null) {\n                int i = 0;\n                final long now = SystemClock.uptimeMillis();\n                for (ConnectionWaiter waiter = mConnectionWaiterQueue; waiter != null;\n                        waiter = waiter.mNext, i++) {\n                    indentedPrinter.println(i + \": waited for \"\n                            + (now - waiter.mStartTime)\n                            + \" ms - thread=\" + waiter.mThread\n                            + \", priority=\" + waiter.mPriority\n                            + \", sql='\" + waiter.mSql + \"'\");\n                }\n            } else {\n                indentedPrinter.println(\"<none>\");\n            }\n        }\n    }\n\n    JSONObject dumpJSON(boolean verbose) throws JSONException {\n        synchronized (mLock) {\n            JSONArray nonPrimaryList = new JSONArray();\n            JSONArray acquiredList = new JSONArray();\n            JSONArray waiters = new JSONArray();\n            JSONObject o = new JSONObject()\n                    .put(\"path\", mConfiguration.path)\n                    .put(\"open\", mIsOpen)\n                    .put(\"maxConn\", mMaxConnectionPoolSize)\n                    .put(\"availablePrimary\", mAvailablePrimaryConnection == null ?\n                            null : null/*FIXME*/)\n                    .put(\"availableNonPrimary\", nonPrimaryList)\n                    .put(\"acquired\", acquiredList)\n                    .put(\"waiters\", waiters);\n\n            for (SQLiteConnection conn : mAvailableNonPrimaryConnections) {\n                nonPrimaryList.put(conn.dumpJSON(verbose));\n            }\n\n            for (Map.Entry<SQLiteConnection, AcquiredConnectionStatus> entry :\n                    mAcquiredConnections.entrySet()) {\n                acquiredList.put(entry.getKey().dumpJSON(verbose)\n                        .put(\"status\", entry.getValue().toString()));\n            }\n\n            for (ConnectionWaiter w = mConnectionWaiterQueue; w != null; w = w.mNext) {\n                final long now = SystemClock.uptimeMillis();\n                waiters.put(new JSONObject()\n                        .put(\"duration\", now - w.mStartTime)\n                        .put(\"thread\", w.mThread.toString())\n                        .put(\"priority\", w.mPriority)\n                        .put(\"sql\", w.mSql)\n                );\n            }\n\n            return o;\n        }\n    }\n\n    @Override\n    public String toString() {\n        return \"SQLiteConnectionPool: \" + mConfiguration.path;\n    }\n\n    private static final class ConnectionWaiter {\n        public ConnectionWaiter mNext;\n        public Thread mThread;\n        public long mStartTime;\n        public int mPriority;\n        public boolean mWantPrimaryConnection;\n        public String mSql;\n        public int mConnectionFlags;\n        public SQLiteConnection mAssignedConnection;\n        public RuntimeException mException;\n        public int mNonce;\n    }\n}\n"
  },
  {
    "path": "deprecated/android/wcdb/src/com/tencent/wcdb/database/SQLiteConstraintException.java",
    "content": "/*\n * Copyright (C) 2008 The Android Open Source Project\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdb.database;\n\n/**\n * An exception that indicates that an integrity constraint was violated.\n */\n@SuppressWarnings(\"serial\")\npublic class SQLiteConstraintException extends SQLiteException {\n    public SQLiteConstraintException() {}\n\n    public SQLiteConstraintException(String error) {\n        super(error);\n    }\n}\n"
  },
  {
    "path": "deprecated/android/wcdb/src/com/tencent/wcdb/database/SQLiteCursor.java",
    "content": "/*\n * Copyright (C) 2006 The Android Open Source Project\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdb.database;\n\nimport com.tencent.wcdb.Cursor;\nimport com.tencent.wcdb.support.CancellationSignal;\nimport com.tencent.wcdb.support.Log;\n\nimport java.util.HashMap;\nimport java.util.Map;\n\nimport com.tencent.wcdb.AbstractWindowedCursor;\nimport com.tencent.wcdb.CursorWindow;\nimport com.tencent.wcdb.DatabaseUtils;\n\n/**\n * A Cursor implementation that exposes results from a query on a\n * {@link SQLiteDatabase}.\n *\n * SQLiteCursor is not internally synchronized so code using a SQLiteCursor from multiple\n * threads should perform its own synchronization when using the SQLiteCursor.\n */\npublic class SQLiteCursor extends AbstractWindowedCursor {\n    static final String TAG = \"WCDB.SQLiteCursor\";\n    static final int NO_COUNT = -1;\n\n    /** The names of the columns in the rows */\n    private final String[] mColumns;\n\n    /** The query object for the cursor */\n    private final SQLiteQuery mQuery;\n\n    /** The compiled query this cursor came from */\n    private final SQLiteCursorDriver mDriver;\n\n    /** The number of rows in the cursor */\n    private int mCount = NO_COUNT;\n\n    /** The number of rows that can fit in the cursor window, 0 if unknown */\n    private int mCursorWindowCapacity;\n\n    /** A mapping of column names to column indices, to speed up lookups */\n    private Map<String, Integer> mColumnNameMap;\n\n    /**\n     * Execute a query and provide access to its result set through a Cursor\n     * interface. For a query such as: {@code SELECT name, birth, phone FROM\n     * myTable WHERE ... LIMIT 1,20 ORDER BY...} the column names (name, birth,\n     * phone) would be in the projection argument and everything from\n     * {@code FROM} onward would be in the params argument.\n     *\n     * @param db a reference to a Database object that is already constructed\n     *     and opened. This param is not used any longer\n     * @param editTable the name of the table used for this query\n     * @param query the rest of the query terms\n     *     cursor is finalized\n     * @deprecated use {@link #SQLiteCursor(SQLiteCursorDriver, String, SQLiteQuery)} instead\n     */\n    @Deprecated\n    public SQLiteCursor(SQLiteDatabase db, SQLiteCursorDriver driver,\n            String editTable, SQLiteQuery query) {\n        this(driver, editTable, query);\n    }\n\n    /**\n     * Execute a query and provide access to its result set through a Cursor\n     * interface. For a query such as: {@code SELECT name, birth, phone FROM\n     * myTable WHERE ... LIMIT 1,20 ORDER BY...} the column names (name, birth,\n     * phone) would be in the projection argument and everything from\n     * {@code FROM} onward would be in the params argument.\n     *\n     * @param editTable the name of the table used for this query\n     * @param query the {@link SQLiteQuery} object associated with this cursor object.\n     */\n    @SuppressWarnings(\"deprecation\")\n\tpublic SQLiteCursor(SQLiteCursorDriver driver, String editTable, SQLiteQuery query) {\n        if (query == null) {\n            throw new IllegalArgumentException(\"query object cannot be null\");\n        }\n\n        mDriver = driver;\n        mColumnNameMap = null;\n        mQuery = query;\n\n        mColumns = query.getColumnNames();\n        mRowIdColumnIndex = DatabaseUtils.findRowIdColumnIndex(mColumns);\n    }\n\n    /**\n     * Get the database that this cursor is associated with.\n     * @return the SQLiteDatabase that this cursor is associated with.\n     */\n    public SQLiteDatabase getDatabase() {\n        return mQuery.getDatabase();\n    }\n\n    @Override\n    public boolean onMove(int oldPosition, int newPosition) {\n        // Make sure the row at newPosition is present in the window\n        if (mWindow == null || newPosition < mWindow.getStartPosition() ||\n                newPosition >= (mWindow.getStartPosition() + mWindow.getNumRows())) {\n            fillWindow(newPosition);\n\n            // Update count if we are running out of rows.\n            int bound = mWindow.getStartPosition() + mWindow.getNumRows();\n            if (newPosition >= bound) {\n                mCount = bound;\n            }\n        }\n\n        return true;\n    }\n\n    @Override\n    public boolean moveToPosition(int position) {\n        if (!super.moveToPosition(position)) {\n            return false;\n        }\n\n        // Double check the case that the result set changes.\n        final int count = getCount();\n        if (position >= count) {\n            mPos = count;\n            return false;\n        }\n        return true;\n    }\n\n    @Override\n    public int getCount() {\n        if (mCount == NO_COUNT) {\n            fillWindow(0);\n        }\n        return mCount;\n    }\n\n    private void fillWindow(int requiredPos) {\n        clearOrCreateWindow(getDatabase().getPath());\n\n        try {\n            if (mCount == NO_COUNT) {\n                int startPos = DatabaseUtils.cursorPickFillWindowStartPosition(requiredPos, 0);\n                mCount = mQuery.fillWindow(mWindow, startPos, requiredPos, true);\n                mCursorWindowCapacity = mWindow.getNumRows();\n//                if (Log.isLoggable(TAG, Log.DEBUG)) {\n//                    Log.d(TAG, \"received count(*) from native_fill_window: \" + mCount);\n//                }\n            } else {\n                int startPos = DatabaseUtils.cursorPickFillWindowStartPosition(requiredPos,\n                        mCursorWindowCapacity);\n                mQuery.fillWindow(mWindow, startPos, requiredPos, false);\n            }\n        } catch (RuntimeException ex) {\n            // Close the cursor window if the query failed and therefore will\n            // not produce any results.  This helps to avoid accidentally leaking\n            // the cursor window if the client does not correctly handle exceptions\n            // and fails to close the cursor.\n            closeWindow();\n            throw ex;\n        }\n    }\n\n    @Override\n    public int getColumnIndex(String columnName) {\n        // Create mColumnNameMap on demand\n        if (mColumnNameMap == null) {\n            String[] columns = mColumns;\n            int columnCount = columns.length;\n            HashMap<String, Integer> map = new HashMap<String, Integer>(columnCount, 1);\n            for (int i = 0; i < columnCount; i++) {\n                map.put(columns[i], i);\n            }\n            mColumnNameMap = map;\n        }\n\n        // Hack according to bug 903852\n        final int periodIndex = columnName.lastIndexOf('.');\n        if (periodIndex != -1) {\n            Exception e = new Exception();\n            Log.e(TAG, \"requesting column name with table name -- \" + columnName, e);\n            columnName = columnName.substring(periodIndex + 1);\n        }\n\n        Integer i = mColumnNameMap.get(columnName);\n        if (i != null) {\n            return i.intValue();\n        } else {\n            return -1;\n        }\n    }\n\n    @Override\n    public String[] getColumnNames() {\n        return mColumns;\n    }\n\n    @Override\n    public void deactivate() {\n        super.deactivate();\n        mDriver.cursorDeactivated();\n    }\n\n    @Override\n    public void close() {\n        super.close();\n        synchronized (this) {\n            mQuery.close();\n            mDriver.cursorClosed();\n        }\n    }\n\n    @Override\n    public boolean requery() {\n        if (isClosed()) {\n            return false;\n        }\n\n        synchronized (this) {\n            if (!mQuery.getDatabase().isOpen()) {\n                return false;\n            }\n\n            if (mWindow != null) {\n                mWindow.clear();\n            }\n            mPos = -1;\n            mCount = NO_COUNT;\n\n            mDriver.cursorRequeried(this);\n        }\n\n        try {\n            return super.requery();\n        } catch (IllegalStateException e) {\n            // for backwards compatibility, just return false\n            Log.w(TAG, \"requery() failed \" + e.getMessage(), e);\n            return false;\n        }\n    }\n\n    @Override\n    public void setWindow(CursorWindow window) {\n        super.setWindow(window);\n        mCount = NO_COUNT;\n    }\n\n    /**\n     * Changes the selection arguments. The new values take effect after a call to requery().\n     */\n    public void setSelectionArguments(String[] selectionArgs) {\n        mDriver.setBindArguments(selectionArgs);\n    }\n\n    /**\n     * Release the native resources, if they haven't been released yet.\n     */\n    @Override\n    protected void finalize() {\n        try {\n            // if the cursor hasn't been closed yet, close it first\n            if (mWindow != null) {\n                close();\n            }\n        } finally {\n            super.finalize();\n        }\n    }\n\n\n    public static final SQLiteDatabase.CursorFactory FACTORY = new SQLiteDatabase.CursorFactory() {\n        @Override\n        public Cursor newCursor(SQLiteDatabase db, SQLiteCursorDriver masterQuery,\n                String editTable, SQLiteProgram query) {\n            return new SQLiteCursor(masterQuery, editTable, (SQLiteQuery) query);\n        }\n\n        @Override\n        public SQLiteProgram newQuery(SQLiteDatabase db, String query, Object[] bindArgs,\n                CancellationSignal cancellationSignalForPrepare) {\n            return new SQLiteQuery(db, query, bindArgs, cancellationSignalForPrepare);\n        }\n    };\n}\n"
  },
  {
    "path": "deprecated/android/wcdb/src/com/tencent/wcdb/database/SQLiteCursorDriver.java",
    "content": "/*\n * Copyright (C) 2007 The Android Open Source Project\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdb.database;\n\nimport com.tencent.wcdb.Cursor;\nimport com.tencent.wcdb.database.SQLiteDatabase.CursorFactory;\n\n/**\n * A driver for SQLiteCursors that is used to create them and gets notified\n * by the cursors it creates on significant events in their lifetimes.\n */\npublic interface SQLiteCursorDriver {\n    /**\n     * Executes the query returning a Cursor over the result set.\n     * \n     * @param factory The CursorFactory to use when creating the Cursors, or\n     *         null if standard SQLiteCursors should be returned.\n     * @return a Cursor over the result set\n     */\n    Cursor query(CursorFactory factory, Object[] bindArgs);\n\n    /**\n     * Called by a SQLiteCursor when it is released.\n     */\n    void cursorDeactivated();\n\n    /**\n     * Called by a SQLiteCursor when it is requeried.\n     */\n    void cursorRequeried(Cursor cursor);\n\n    /**\n     * Called by a SQLiteCursor when it it closed to destroy this object as well.\n     */\n    void cursorClosed();\n\n    /**\n     * Set new bind arguments. These will take effect in cursorRequeried().\n     * @param bindArgs the new arguments\n     */\n    public void setBindArguments(String[] bindArgs);\n}\n"
  },
  {
    "path": "deprecated/android/wcdb/src/com/tencent/wcdb/database/SQLiteCustomFunction.java",
    "content": "/*\n * Copyright (C) 2011 The Android Open Source Project\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdb.database;\n\n/**\n * Describes a custom SQL function.\n *\n * @hide\n */\npublic final class SQLiteCustomFunction {\n    public final String name;\n    public final int numArgs;\n    public final SQLiteDatabase.CustomFunction callback;\n\n    /**\n     * Create custom function.\n     *\n     * @param name The name of the sqlite3 function.\n     * @param numArgs The number of arguments for the function, or -1 to\n     * support any number of arguments.\n     * @param callback The callback to invoke when the function is executed.\n     */\n    public SQLiteCustomFunction(String name, int numArgs,\n            SQLiteDatabase.CustomFunction callback) {\n        if (name == null) {\n            throw new IllegalArgumentException(\"name must not be null.\");\n        }\n\n        this.name = name;\n        this.numArgs = numArgs;\n        this.callback = callback;\n    }\n\n    // Called from native.\n    @SuppressWarnings(\"unused\")\n    private void dispatchCallback(String[] args) {\n        callback.callback(args);\n    }\n}\n"
  },
  {
    "path": "deprecated/android/wcdb/src/com/tencent/wcdb/database/SQLiteDatabase.java",
    "content": "/*\n * Copyright (C) 2006 The Android Open Source Project\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdb.database;\n\nimport android.content.ContentValues;\nimport android.database.sqlite.SQLiteTransactionListener;\nimport android.os.Build;\nimport android.os.Looper;\nimport android.text.TextUtils;\nimport android.util.Pair;\nimport android.util.Printer;\n\nimport com.tencent.wcdb.Cursor;\nimport com.tencent.wcdb.DatabaseErrorHandler;\nimport com.tencent.wcdb.DatabaseUtils;\nimport com.tencent.wcdb.DefaultDatabaseErrorHandler;\nimport com.tencent.wcdb.SQLException;\nimport com.tencent.wcdb.database.SQLiteDebug.DbStats;\nimport com.tencent.wcdb.extension.SQLiteExtension;\nimport com.tencent.wcdb.support.CancellationSignal;\nimport com.tencent.wcdb.support.Log;\nimport com.tencent.wcdb.support.OperationCanceledException;\n\nimport org.json.JSONArray;\nimport org.json.JSONException;\nimport org.json.JSONObject;\n\nimport java.io.File;\nimport java.io.FileFilter;\nimport java.lang.reflect.Field;\nimport java.util.ArrayList;\nimport java.util.HashMap;\nimport java.util.List;\nimport java.util.Locale;\nimport java.util.Map;\nimport java.util.Set;\nimport java.util.WeakHashMap;\n\n/**\n * Exposes methods to manage a SQLite database.\n * <p/>\n * <p>\n * SQLiteDatabase has methods to create, delete, execute SQL commands, and\n * perform other common database management tasks.\n * </p><p>\n * See the Notepad sample application in the SDK for an example of creating\n * and managing a database.\n * </p><p>\n * Database names must be unique within an application, not across all applications.\n * </p>\n * <p/>\n * <h3>Localized Collation - ORDER BY</h3>\n * <p>\n * In addition to SQLite's default <code>BINARY</code> collator, Android supplies\n * two more, <code>LOCALIZED</code>, which changes with the system's current locale,\n * and <code>UNICODE</code>, which is the Unicode Collation Algorithm and not tailored\n * to the current locale.\n * </p>\n */\npublic final class SQLiteDatabase extends SQLiteClosable {\n    private static final String TAG = \"WCDB.SQLiteDatabase\";\n\n    static {\n        // Ensure libwcdb.so is loaded.\n        SQLiteGlobal.initialize();\n    }\n\n    // Stores reference to all databases opened in the current process.\n    // (The referent Object is not used at this time.)\n    // INVARIANT: Guarded by sActiveDatabases.\n    private static final WeakHashMap<SQLiteDatabase, Object> sActiveDatabases =\n            new WeakHashMap<SQLiteDatabase, Object>();\n\n    // Thread-local for database sessions that belong to this database.\n    // Each thread has its own database session.\n    // INVARIANT: Immutable.\n    private final ThreadLocal<SQLiteSession> mThreadSession = new ThreadLocal<SQLiteSession>() {\n        @Override\n        protected SQLiteSession initialValue() {\n            return createSession();\n        }\n    };\n\n    // The optional factory to use when creating new Cursors.  May be null.\n    // INVARIANT: Immutable.\n    private final CursorFactory mCursorFactory;\n\n    // Error handler to be used when SQLite returns corruption errors.\n    // INVARIANT: Immutable.\n    private final DatabaseErrorHandler mErrorHandler;\n\n    // Shared database state lock.\n    // This lock guards all of the shared state of the database, such as its\n    // configuration, whether it is open or closed, and so on.  This lock should\n    // be held for as little time as possible.\n    //\n    // The lock MUST NOT be held while attempting to acquire database connections or\n    // while executing SQL statements on behalf of the client as it can lead to deadlock.\n    //\n    // It is ok to hold the lock while reconfiguring the connection pool or dumping\n    // statistics because those operations are non-reentrant and do not try to acquire\n    // connections that might be held by other threads.\n    //\n    // Basic rule: grab the lock, access or modify global state, release the lock, then\n    // do the required SQL work.\n    private final Object mLock = new Object();\n\n    // The database configuration.\n    // INVARIANT: Guarded by mLock.\n    private final SQLiteDatabaseConfiguration mConfigurationLocked;\n\n    // The connection pool for the database, null when closed.\n    // The pool itself is thread-safe, but the reference to it can only be acquired\n    // when the lock is held.\n    // INVARIANT: Guarded by mLock.\n    private SQLiteConnectionPool mConnectionPoolLocked;\n\n    // True if the database has attached databases.\n    // INVARIANT: Guarded by mLock.\n    private boolean mHasAttachedDbsLocked;\n\n    /**\n     * When a constraint violation occurs, an immediate ROLLBACK occurs,\n     * thus ending the current transaction, and the command aborts with a\n     * return code of SQLITE_CONSTRAINT. If no transaction is active\n     * (other than the implied transaction that is created on every command)\n     * then this algorithm works the same as ABORT.\n     */\n    public static final int CONFLICT_ROLLBACK = 1;\n\n    /**\n     * When a constraint violation occurs,no ROLLBACK is executed\n     * so changes from prior commands within the same transaction\n     * are preserved. This is the default behavior.\n     */\n    public static final int CONFLICT_ABORT = 2;\n\n    /**\n     * When a constraint violation occurs, the command aborts with a return\n     * code SQLITE_CONSTRAINT. But any changes to the database that\n     * the command made prior to encountering the constraint violation\n     * are preserved and are not backed out.\n     */\n    public static final int CONFLICT_FAIL = 3;\n\n    /**\n     * When a constraint violation occurs, the one row that contains\n     * the constraint violation is not inserted or changed.\n     * But the command continues executing normally. Other rows before and\n     * after the row that contained the constraint violation continue to be\n     * inserted or updated normally. No error is returned.\n     */\n    public static final int CONFLICT_IGNORE = 4;\n\n    /**\n     * When a UNIQUE constraint violation occurs, the pre-existing rows that\n     * are causing the constraint violation are removed prior to inserting\n     * or updating the current row. Thus the insert or update always occurs.\n     * The command continues executing normally. No error is returned.\n     * If a NOT NULL constraint violation occurs, the NULL value is replaced\n     * by the default value for that column. If the column has no default\n     * value, then the ABORT algorithm is used. If a CHECK constraint\n     * violation occurs then the IGNORE algorithm is used. When this conflict\n     * resolution strategy deletes rows in order to satisfy a constraint,\n     * it does not invoke delete triggers on those rows.\n     * This behavior might change in a future release.\n     */\n    public static final int CONFLICT_REPLACE = 5;\n\n    /**\n     * Use the following when no conflict action is specified.\n     */\n    public static final int CONFLICT_NONE = 0;\n\n    private static final String[] CONFLICT_VALUES = new String[]\n            {\"\", \" OR ROLLBACK \", \" OR ABORT \", \" OR FAIL \", \" OR IGNORE \", \" OR REPLACE \"};\n\n    public static final int SYNCHRONOUS_OFF = 0;\n    public static final int SYNCHRONOUS_NORMAL = 1;\n    public static final int SYNCHRONOUS_FULL = 2;\n    public static final int SYNCHRONOUS_EXTRA = 3;\n\n    /**\n     * Maximum Length Of A LIKE Or GLOB Pattern\n     * The pattern matching algorithm used in the default LIKE and GLOB implementation\n     * of SQLite can exhibit O(N^2) performance (where N is the number of characters in\n     * the pattern) for certain pathological cases. To avoid denial-of-service attacks\n     * the length of the LIKE or GLOB pattern is limited to SQLITE_MAX_LIKE_PATTERN_LENGTH bytes.\n     * The default value of this limit is 50000. A modern workstation can evaluate\n     * even a pathological LIKE or GLOB pattern of 50000 bytes relatively quickly.\n     * The denial of service problem only comes into play when the pattern length gets\n     * into millions of bytes. Nevertheless, since most useful LIKE or GLOB patterns\n     * are at most a few dozen bytes in length, paranoid application developers may\n     * want to reduce this parameter to something in the range of a few hundred\n     * if they know that external users are able to generate arbitrary patterns.\n     */\n    public static final int SQLITE_MAX_LIKE_PATTERN_LENGTH = 50000;\n\n    /**\n     * Open flag: Flag for {@link #openDatabase} to open the database for reading and writing.\n     * If the disk is full, this may fail even before you actually write anything.\n     * <p/>\n     * {@more} Note that the value of this flag is 0, so it is the default.\n     */\n    public static final int OPEN_READWRITE = 0x00000000;          // update native code if changing\n\n    /**\n     * Open flag: Flag for {@link #openDatabase} to open the database for reading only.\n     * This is the only reliable way to open a database if the disk may be full.\n     */\n    public static final int OPEN_READONLY = 0x00000001;           // update native code if changing\n\n    private static final int OPEN_READ_MASK = 0x00000001;         // update native code if changing\n\n    /**\n     * Open flag: Flag for {@link #openDatabase} to open the database without support for\n     * localized collators.\n     * <p/>\n     * {@more} This causes the collator <code>LOCALIZED</code> not to be created.\n     * You must be consistent when using this flag to use the setting the database was\n     * created with.  If this is set, {@link #setLocale} will do nothing.\n     */\n    public static final int NO_LOCALIZED_COLLATORS = 0x00000010;  // update native code if changing\n\n    /**\n     * Open flag: Flag for {@link #openDatabase} to open the database with I/O trace enabled.\n     * <p/>\n     * This causes database to log I/O operations to file.\n     */\n    public static final int ENABLE_IO_TRACE = 0x00000100;\n\n    /**\n     * Open flag: Flag for {@link #openDatabase} to create the database file if it does not\n     * already exist.\n     */\n    public static final int CREATE_IF_NECESSARY = 0x10000000;     // update native code if changing\n\n    /**\n     * Open flag: Flag for {@link #openDatabase} to open the database file with\n     * write-ahead logging enabled by default.  Using this flag is more efficient\n     * than calling {@link #enableWriteAheadLogging}.\n     * <p/>\n     * Write-ahead logging cannot be used with read-only databases so the value of\n     * this flag is ignored if the database is opened read-only.\n     *\n     * @see #enableWriteAheadLogging\n     */\n    public static final int ENABLE_WRITE_AHEAD_LOGGING = 0x20000000;\n\n    /**\n     * Absolute max value that can be set by {@link #setMaxSqlCacheSize(int)}.\n     * <p/>\n     * Each prepared-statement is between 1K - 6K, depending on the complexity of the\n     * SQL statement & schema.  A large SQL cache may use a significant amount of memory.\n     */\n    public static final int MAX_SQL_CACHE_SIZE = 100;\n\n    private SQLiteDatabase(String path, int openFlags, CursorFactory cursorFactory,\n            DatabaseErrorHandler errorHandler) {\n        mCursorFactory = cursorFactory;\n        mErrorHandler = errorHandler != null ? errorHandler :\n                new DefaultDatabaseErrorHandler(true);\n        mConfigurationLocked = new SQLiteDatabaseConfiguration(path, openFlags);\n    }\n\n    @Override\n    protected void finalize() throws Throwable {\n        try {\n            dispose(true);\n        } finally {\n            super.finalize();\n        }\n    }\n\n    @Override\n    protected void onAllReferencesReleased() {\n        dispose(false);\n    }\n\n    private void dispose(boolean finalized) {\n        final SQLiteConnectionPool pool;\n        synchronized (mLock) {\n            pool = mConnectionPoolLocked;\n            mConnectionPoolLocked = null;\n        }\n\n        if (!finalized) {\n            synchronized (sActiveDatabases) {\n                sActiveDatabases.remove(this);\n            }\n\n            if (pool != null) {\n                pool.close();\n            }\n        }\n    }\n\n    /**\n     * Attempts to release memory that SQLite holds but does not require to\n     * operate properly. Typically this memory will come from the page cache.\n     *\n     * @return the number of bytes actually released\n     */\n    public static int releaseMemory() {\n        return SQLiteGlobal.releaseMemory();\n    }\n\n    /**\n     * Control whether or not the SQLiteDatabase is made thread-safe by using locks\n     * around critical sections. This is pretty expensive, so if you know that your\n     * DB will only be used by a single thread then you should set this to false.\n     * The default is true.\n     *\n     * @param lockingEnabled set to true to enable locks, false otherwise\n     * @deprecated This method now does nothing.  Do not use.\n     */\n    @Deprecated\n    public void setLockingEnabled(boolean lockingEnabled) {\n    }\n\n    /**\n     * Gets a label to use when describing the database in log messages.\n     *\n     * @return The label.\n     */\n    String getLabel() {\n        synchronized (mLock) {\n            return mConfigurationLocked.label;\n        }\n    }\n\n    /**\n     * Sends a corruption message to the database error handler.\n     */\n    void onCorruption() {\n        mErrorHandler.onCorruption(this);\n    }\n\n    /**\n     * Gets the {@link SQLiteSession} that belongs to this thread for this database.\n     * Once a thread has obtained a session, it will continue to obtain the same\n     * session even after the database has been closed (although the session will not\n     * be usable).  However, a thread that does not already have a session cannot\n     * obtain one after the database has been closed.\n     * <p/>\n     * The idea is that threads that have active connections to the database may still\n     * have work to complete even after the call to {@link #close}.  Active database\n     * connections are not actually disposed until they are released by the threads\n     * that own them.\n     *\n     * @return The session, never null.\n     * @throws IllegalStateException if the thread does not yet have a session and\n     *                               the database is not open.\n     */\n    SQLiteSession getThreadSession() {\n        return mThreadSession.get(); // initialValue() throws if database closed\n    }\n\n    SQLiteSession createSession() {\n        final SQLiteConnectionPool pool;\n        synchronized (mLock) {\n            throwIfNotOpenLocked();\n            pool = mConnectionPoolLocked;\n        }\n        return new SQLiteSession(pool);\n    }\n\n    /**\n     * Gets default connection flags that are appropriate for this thread, taking into\n     * account whether the thread is acting on behalf of the UI.\n     *\n     * @param readOnly True if the connection should be read-only.\n     * @return The connection flags.\n     */\n    int getThreadDefaultConnectionFlags(boolean readOnly) {\n        int flags = readOnly ? SQLiteConnectionPool.CONNECTION_FLAG_READ_ONLY :\n                SQLiteConnectionPool.CONNECTION_FLAG_PRIMARY_CONNECTION_AFFINITY;\n        if (isMainThread()) {\n            flags |= SQLiteConnectionPool.CONNECTION_FLAG_INTERACTIVE;\n        }\n        return flags;\n    }\n\n    private static boolean isMainThread() {\n        // FIXME: There should be a better way to do this.\n        // Would also be nice to have something that would work across Binder calls.\n        Looper looper = Looper.myLooper();\n        return looper != null && looper == Looper.getMainLooper();\n    }\n\n    /**\n     * Begins a transaction in EXCLUSIVE mode.\n     * <p>\n     * Transactions can be nested.\n     * When the outer transaction is ended all of\n     * the work done in that transaction and all of the nested transactions will be committed or\n     * rolled back. The changes will be rolled back if any transaction is ended without being\n     * marked as clean (by calling setTransactionSuccessful). Otherwise they will be committed.\n     * </p>\n     * <p>Here is the standard idiom for transactions:\n     * <p/>\n     * <pre>\n     *   db.beginTransaction();\n     *   try {\n     *     ...\n     *     db.setTransactionSuccessful();\n     *   } finally {\n     *     db.endTransaction();\n     *   }\n     * </pre>\n     */\n    public void beginTransaction() {\n        beginTransaction(null /* transactionStatusCallback */, true);\n    }\n\n    /**\n     * Begins a transaction in IMMEDIATE mode. Transactions can be nested. When\n     * the outer transaction is ended all of the work done in that transaction\n     * and all of the nested transactions will be committed or rolled back. The\n     * changes will be rolled back if any transaction is ended without being\n     * marked as clean (by calling setTransactionSuccessful). Otherwise they\n     * will be committed.\n     * <p/>\n     * Here is the standard idiom for transactions:\n     * <p/>\n     * <pre>\n     *   db.beginTransactionNonExclusive();\n     *   try {\n     *     ...\n     *     db.setTransactionSuccessful();\n     *   } finally {\n     *     db.endTransaction();\n     *   }\n     * </pre>\n     */\n    public void beginTransactionNonExclusive() {\n        beginTransaction(null /* transactionStatusCallback */, false);\n    }\n\n    /**\n     * Begins a transaction in EXCLUSIVE mode.\n     * <p>\n     * Transactions can be nested.\n     * When the outer transaction is ended all of\n     * the work done in that transaction and all of the nested transactions will be committed or\n     * rolled back. The changes will be rolled back if any transaction is ended without being\n     * marked as clean (by calling setTransactionSuccessful). Otherwise they will be committed.\n     * </p>\n     * <p>Here is the standard idiom for transactions:\n     * <p/>\n     * <pre>\n     *   db.beginTransactionWithListener(listener);\n     *   try {\n     *     ...\n     *     db.setTransactionSuccessful();\n     *   } finally {\n     *     db.endTransaction();\n     *   }\n     * </pre>\n     *\n     * @param transactionListener listener that should be notified when the transaction begins,\n     *                            commits, or is rolled back, either explicitly or by a call to\n     *                            {@link #yieldIfContendedSafely}.\n     */\n    public void beginTransactionWithListener(SQLiteTransactionListener transactionListener) {\n        beginTransaction(transactionListener, true);\n    }\n\n    /**\n     * Begins a transaction in IMMEDIATE mode. Transactions can be nested. When\n     * the outer transaction is ended all of the work done in that transaction\n     * and all of the nested transactions will be committed or rolled back. The\n     * changes will be rolled back if any transaction is ended without being\n     * marked as clean (by calling setTransactionSuccessful). Otherwise they\n     * will be committed.\n     * <p/>\n     * Here is the standard idiom for transactions:\n     * <p/>\n     * <pre>\n     *   db.beginTransactionWithListenerNonExclusive(listener);\n     *   try {\n     *     ...\n     *     db.setTransactionSuccessful();\n     *   } finally {\n     *     db.endTransaction();\n     *   }\n     * </pre>\n     *\n     * @param transactionListener listener that should be notified when the\n     *                            transaction begins, commits, or is rolled back, either\n     *                            explicitly or by a call to {@link #yieldIfContendedSafely}.\n     */\n    public void beginTransactionWithListenerNonExclusive(\n            SQLiteTransactionListener transactionListener) {\n        beginTransaction(transactionListener, false);\n    }\n\n    private void beginTransaction(SQLiteTransactionListener transactionListener,\n            boolean exclusive) {\n        acquireReference();\n        try {\n            getThreadSession().beginTransaction(\n                    exclusive ? SQLiteSession.TRANSACTION_MODE_EXCLUSIVE :\n                            SQLiteSession.TRANSACTION_MODE_IMMEDIATE,\n                    transactionListener,\n                    getThreadDefaultConnectionFlags(false /*readOnly*/), null);\n        } finally {\n            releaseReference();\n        }\n    }\n\n    /**\n     * End a transaction. See beginTransaction for notes about how to use this and when transactions\n     * are committed and rolled back.\n     */\n    public void endTransaction() {\n        acquireReference();\n        try {\n            getThreadSession().endTransaction(null);\n        } finally {\n            releaseReference();\n        }\n    }\n\n    /**\n     * Marks the current transaction as successful. Do not do any more database work between\n     * calling this and calling endTransaction. Do as little non-database work as possible in that\n     * situation too. If any errors are encountered between this and endTransaction the transaction\n     * will still be committed.\n     *\n     * @throws IllegalStateException if the current thread is not in a transaction or the\n     *                               transaction is already marked as successful.\n     */\n    public void setTransactionSuccessful() {\n        acquireReference();\n        try {\n            getThreadSession().setTransactionSuccessful();\n        } finally {\n            releaseReference();\n        }\n    }\n\n    /**\n     * Returns true if the current thread has a transaction pending.\n     *\n     * @return True if the current thread is in a transaction.\n     */\n    public boolean inTransaction() {\n        acquireReference();\n        try {\n            return getThreadSession().hasTransaction();\n        } finally {\n            releaseReference();\n        }\n    }\n\n    /**\n     * Returns true if the current thread is holding an active connection to the database.\n     * <p>\n     * The name of this method comes from a time when having an active connection\n     * to the database meant that the thread was holding an actual lock on the\n     * database.  Nowadays, there is no longer a true \"database lock\" although threads\n     * may block if they cannot acquire a database connection to perform a\n     * particular operation.\n     * </p>\n     *\n     * @return True if the current thread is holding an active connection to the database.\n     */\n    public boolean isDbLockedByCurrentThread() {\n        acquireReference();\n        try {\n            return getThreadSession().hasConnection();\n        } finally {\n            releaseReference();\n        }\n    }\n\n    /**\n     * Always returns false.\n     * <p>\n     * There is no longer the concept of a database lock, so this method always returns false.\n     * </p>\n     *\n     * @return False.\n     * @deprecated Always returns false.  Do not use this method.\n     */\n    @Deprecated\n    public boolean isDbLockedByOtherThreads() {\n        return false;\n    }\n\n    /**\n     * Temporarily end the transaction to let other threads run. The transaction is assumed to be\n     * successful so far. Do not call setTransactionSuccessful before calling this. When this\n     * returns a new transaction will have been created but not marked as successful.\n     *\n     * @return true if the transaction was yielded\n     * @deprecated if the db is locked more than once (becuase of nested transactions) then the lock\n     * will not be yielded. Use yieldIfContendedSafely instead.\n     */\n    @Deprecated\n    public boolean yieldIfContended() {\n        return yieldIfContendedHelper(false /* do not check yielding */,\n                -1 /* sleepAfterYieldDelay */);\n    }\n\n    /**\n     * Temporarily end the transaction to let other threads run. The transaction is assumed to be\n     * successful so far. Do not call setTransactionSuccessful before calling this. When this\n     * returns a new transaction will have been created but not marked as successful. This assumes\n     * that there are no nested transactions (beginTransaction has only been called once) and will\n     * throw an exception if that is not the case.\n     *\n     * @return true if the transaction was yielded\n     */\n    public boolean yieldIfContendedSafely() {\n        return yieldIfContendedHelper(true /* check yielding */, -1 /* sleepAfterYieldDelay*/);\n    }\n\n    /**\n     * Temporarily end the transaction to let other threads run. The transaction is assumed to be\n     * successful so far. Do not call setTransactionSuccessful before calling this. When this\n     * returns a new transaction will have been created but not marked as successful. This assumes\n     * that there are no nested transactions (beginTransaction has only been called once) and will\n     * throw an exception if that is not the case.\n     *\n     * @param sleepAfterYieldDelay if > 0, sleep this long before starting a new transaction if\n     *                             the lock was actually yielded. This will allow other background threads to make some\n     *                             more progress than they would if we started the transaction immediately.\n     * @return true if the transaction was yielded\n     */\n    public boolean yieldIfContendedSafely(long sleepAfterYieldDelay) {\n        return yieldIfContendedHelper(true /* check yielding */, sleepAfterYieldDelay);\n    }\n\n    private boolean yieldIfContendedHelper(boolean throwIfUnsafe, long sleepAfterYieldDelay) {\n        acquireReference();\n        try {\n            return getThreadSession().yieldTransaction(sleepAfterYieldDelay, throwIfUnsafe, null);\n        } finally {\n            releaseReference();\n        }\n    }\n\n    /**\n     * Deprecated.\n     *\n     * @deprecated This method no longer serves any useful purpose and has been deprecated.\n     */\n    @Deprecated\n    public Map<String, String> getSyncedTables() {\n        return new HashMap<String, String>(0);\n    }\n\n    /**\n     * Open the database according to the flags {@link #OPEN_READWRITE}\n     * {@link #OPEN_READONLY} {@link #CREATE_IF_NECESSARY} and/or {@link #NO_LOCALIZED_COLLATORS}.\n     * <p/>\n     * <p>Sets the locale of the database to the  the system's current locale.\n     * Call {@link #setLocale} if you would like something else.</p>\n     *\n     * @param path    to database file to open and/or create\n     * @param factory an optional factory class that is called to instantiate a\n     *                cursor when query is called, or null for default\n     * @param flags   to control database access mode\n     * @return the newly opened database\n     * @throws SQLiteException if the database cannot be opened\n     */\n    public static SQLiteDatabase openDatabase(String path, CursorFactory factory, int flags) {\n        return openDatabase(path, factory, flags, null);\n    }\n\n    /**\n     * Open the database according to the flags {@link #OPEN_READWRITE}\n     * {@link #OPEN_READONLY} {@link #CREATE_IF_NECESSARY} and/or {@link #NO_LOCALIZED_COLLATORS}.\n     * <p/>\n     * <p>Sets the locale of the database to the  the system's current locale.\n     * Call {@link #setLocale} if you would like something else.</p>\n     * <p/>\n     * <p>Accepts input param: a concrete instance of {@link DatabaseErrorHandler} to be\n     * used to handle corruption when sqlite reports database corruption.</p>\n     *\n     * @param path         to database file to open and/or create\n     * @param password     password to the encrypted database, or null for plain-text database\n     * @param cipher       cipher description, or null for default settings\n     * @param factory      an optional factory class that is called to instantiate a\n     *                     cursor when query is called, or null for default\n     * @param flags        to control database access mode\n     * @param errorHandler the {@link DatabaseErrorHandler} obj to be used to handle corruption\n     *                     when sqlite reports database corruption\n     * @param poolSize     size of the connection pool to the database, 0 for default size\n     * @return the newly opened database\n     * @throws SQLiteException if the database cannot be opened\n     */\n    public static SQLiteDatabase openDatabase(String path, byte[] password, SQLiteCipherSpec cipher,\n            CursorFactory factory, int flags, DatabaseErrorHandler errorHandler, int poolSize) {\n        SQLiteDatabase db = new SQLiteDatabase(path, flags, factory, errorHandler);\n        db.open(password, cipher, poolSize);\n        return db;\n    }\n\n    /**\n     * Open the database according to the flags {@link #OPEN_READWRITE}\n     * {@link #OPEN_READONLY} {@link #CREATE_IF_NECESSARY} and/or {@link #NO_LOCALIZED_COLLATORS}.\n     * <p/>\n     * <p>Sets the locale of the database to the  the system's current locale.\n     * Call {@link #setLocale} if you would like something else.</p>\n     * <p/>\n     * <p>Accepts input param: a concrete instance of {@link DatabaseErrorHandler} to be\n     * used to handle corruption when sqlite reports database corruption.</p>\n     *\n     * @param path         to database file to open and/or create\n     * @param password     password to the encrypted database, or null for plain-text database\n     * @param cipher       cipher description, or null for default settings\n     * @param factory      an optional factory class that is called to instantiate a\n     *                     cursor when query is called, or null for default\n     * @param flags        to control database access mode\n     * @param errorHandler the {@link DatabaseErrorHandler} obj to be used to handle corruption\n     *                     when sqlite reports database corruption\n     * @return the newly opened database\n     * @throws SQLiteException if the database cannot be opened\n     */\n    public static SQLiteDatabase openDatabase(String path, byte[] password, SQLiteCipherSpec cipher,\n            CursorFactory factory, int flags, DatabaseErrorHandler errorHandler) {\n        return openDatabase(path, password, cipher, factory, flags, errorHandler, 0);\n    }\n\n    /**\n     * Open the database according to the flags {@link #OPEN_READWRITE}\n     * {@link #OPEN_READONLY} {@link #CREATE_IF_NECESSARY} and/or {@link #NO_LOCALIZED_COLLATORS}.\n     * <p/>\n     * <p>Sets the locale of the database to the  the system's current locale.\n     * Call {@link #setLocale} if you would like something else.</p>\n     * <p/>\n     * <p>Accepts input param: a concrete instance of {@link DatabaseErrorHandler} to be\n     * used to handle corruption when sqlite reports database corruption.</p>\n     *\n     * @param path         to database file to open and/or create\n     * @param factory      an optional factory class that is called to instantiate a\n     *                     cursor when query is called, or null for default\n     * @param flags        to control database access mode\n     * @param errorHandler the {@link DatabaseErrorHandler} obj to be used to handle corruption\n     *                     when sqlite reports database corruption\n     * @return the newly opened database\n     * @throws SQLiteException if the database cannot be opened\n     */\n    public static SQLiteDatabase openDatabase(String path, CursorFactory factory, int flags,\n            DatabaseErrorHandler errorHandler) {\n        return openDatabase(path, null, null, factory, flags, errorHandler, 0);\n    }\n\n    /**\n     * Open the database according to the flags {@link #OPEN_READWRITE}\n     * {@link #OPEN_READONLY} {@link #CREATE_IF_NECESSARY} and/or {@link #NO_LOCALIZED_COLLATORS}.\n     * <p/>\n     * <p>Sets the locale of the database to the  the system's current locale.\n     * Call {@link #setLocale} if you would like something else.</p>\n     * <p/>\n     * <p>Accepts input param: a concrete instance of {@link DatabaseErrorHandler} to be\n     * used to handle corruption when sqlite reports database corruption.</p>\n     *\n     * @param path         to database file to open and/or create\n     * @param factory      an optional factory class that is called to instantiate a\n     *                     cursor when query is called, or null for default\n     * @param flags        to control database access mode\n     * @param errorHandler the {@link DatabaseErrorHandler} obj to be used to handle corruption\n     *                     when sqlite reports database corruption\n     * @param poolSize     size of the connection pool to the database, 0 for default size\n     * @return the newly opened database\n     * @throws SQLiteException if the database cannot be opened\n     */\n    public static SQLiteDatabase openDatabase(String path, CursorFactory factory, int flags,\n            DatabaseErrorHandler errorHandler, int poolSize) {\n        return openDatabase(path, null, null, factory, flags, errorHandler, poolSize);\n    }\n\n    /**\n     * Equivalent to openDatabase(file.getPath(), factory, CREATE_IF_NECESSARY).\n     */\n    public static SQLiteDatabase openOrCreateDatabase(File file, CursorFactory factory) {\n        return openOrCreateDatabase(file.getPath(), factory);\n    }\n\n    /**\n     * Equivalent to openDatabase(file.getPath(), password, cipher, factory, CREATE_IF_NECESSARY, errorHandler).\n     */\n    public static SQLiteDatabase openOrCreateDatabase(File file, byte[] password, SQLiteCipherSpec cipher,\n            CursorFactory factory, DatabaseErrorHandler errorHandler) {\n        return openOrCreateDatabase(file.getPath(), password, cipher, factory, errorHandler, 0);\n    }\n\n    /**\n     * Equivalent to openDatabase(file.getPath(), password, cipher, factory, CREATE_IF_NECESSARY, errorHandler, poolSize).\n     */\n    public static SQLiteDatabase openOrCreateDatabase(File file, byte[] password, SQLiteCipherSpec cipher,\n            CursorFactory factory, DatabaseErrorHandler errorHandler, int poolSize) {\n        return openOrCreateDatabase(file.getPath(), password, cipher, factory, errorHandler, poolSize);\n    }\n\n    /**\n     * Equivalent to openDatabase(file.getPath(), password, null, factory, CREATE_IF_NECESSARY, errorHandler).\n     */\n    public static SQLiteDatabase openOrCreateDatabase(File file, byte[] password, CursorFactory factory,\n            DatabaseErrorHandler errorHandler) {\n        return openOrCreateDatabase(file.getPath(), password, null, factory, errorHandler, 0);\n    }\n\n    /**\n     * Equivalent to openDatabase(file.getPath(), password, null, factory, CREATE_IF_NECESSARY, errorHandler, poolSize).\n     */\n    public static SQLiteDatabase openOrCreateDatabase(File file, byte[] password, CursorFactory factory,\n            DatabaseErrorHandler errorHandler, int poolSize) {\n        return openOrCreateDatabase(file.getPath(), password, null, factory, errorHandler, poolSize);\n    }\n\n    /**\n     * Equivalent to openDatabase(path, factory, CREATE_IF_NECESSARY, null, poolSize).\n     */\n    public static SQLiteDatabase openOrCreateDatabase(String path, CursorFactory factory, int poolSize) {\n        return openDatabase(path, null, null, factory, CREATE_IF_NECESSARY, null, poolSize);\n    }\n\n    /**\n     * Equivalent to openDatabase(path, factory, CREATE_IF_NECESSARY | ENABLE_WRITE_AHEAD_LOGGING).\n     */\n    public static SQLiteDatabase openOrCreateDatabaseInWalMode(String path, CursorFactory factory) {\n        return openDatabase(path, null, null, factory, CREATE_IF_NECESSARY | ENABLE_WRITE_AHEAD_LOGGING,\n                null, 0);\n    }\n\n    /**\n     * Equivalent to openDatabase(path, factory, CREATE_IF_NECESSARY | ENABLE_WRITE_AHEAD_LOGGING, poolSize).\n     */\n    public static SQLiteDatabase openOrCreateDatabaseInWalMode(String path, CursorFactory factory, int poolSize) {\n        return openDatabase(path, null, null, factory, CREATE_IF_NECESSARY | ENABLE_WRITE_AHEAD_LOGGING,\n                null, poolSize);\n    }\n\n    /**\n     * Equivalent to openDatabase(path, factory, CREATE_IF_NECESSARY).\n     */\n    public static SQLiteDatabase openOrCreateDatabase(String path, CursorFactory factory) {\n        return openDatabase(path, null, null, factory, CREATE_IF_NECESSARY, null, 0);\n    }\n\n    /**\n     * Equivalent to openDatabase(path, factory, CREATE_IF_NECESSARY).\n     */\n    public static SQLiteDatabase openOrCreateDatabase(String path, CursorFactory factory, boolean wal) {\n        int flag = CREATE_IF_NECESSARY;\n        if (wal) {\n            flag = flag | ENABLE_WRITE_AHEAD_LOGGING;\n        }\n        return openDatabase(path, null, null, factory, flag, null, 0);\n    }\n\n    public static SQLiteDatabase openOrCreateDatabase(String path, byte[] password, SQLiteCipherSpec cipher,\n            CursorFactory factory, DatabaseErrorHandler errorHandler, int poolSize) {\n        return openDatabase(path, password, cipher, factory, CREATE_IF_NECESSARY, errorHandler, poolSize);\n    }\n\n    public static SQLiteDatabase openOrCreateDatabaseInWalMode(String path, byte[] password, SQLiteCipherSpec cipher,\n            CursorFactory factory, DatabaseErrorHandler errorHandler, int poolSize) {\n        return openDatabase(path, password, cipher, factory, CREATE_IF_NECESSARY | ENABLE_WRITE_AHEAD_LOGGING,\n                errorHandler, poolSize);\n    }\n\n    public static SQLiteDatabase openOrCreateDatabaseInWalMode(String path, byte[] password, SQLiteCipherSpec cipher,\n            CursorFactory factory) {\n        return openDatabase(path, password, cipher, factory, CREATE_IF_NECESSARY | ENABLE_WRITE_AHEAD_LOGGING,\n                null, 0);\n    }\n\n    public static SQLiteDatabase openOrCreateMemoryDatabaseInWalMode(CursorFactory factory) {\n        return openDatabase(\":memory:\", null, null, factory, CREATE_IF_NECESSARY | ENABLE_WRITE_AHEAD_LOGGING,\n                null, 0);\n    }\n\n    public static SQLiteDatabase openOrCreateDatabase(String path, byte[] password, CursorFactory factory,\n            DatabaseErrorHandler errorHandler, int poolSize) {\n        return openOrCreateDatabase(path, password, null, factory, errorHandler, poolSize);\n    }\n\n\n    public static SQLiteDatabase openOrCreateDatabase(String path, byte[] password, CursorFactory factory,\n            DatabaseErrorHandler errorHandler) {\n        return openOrCreateDatabase(path, password, null, factory, errorHandler, 0);\n    }\n\n    /**\n     * Equivalent to openDatabase(path, factory, CREATE_IF_NECESSARY, errorHandler).\n     */\n    public static SQLiteDatabase openOrCreateDatabase(String path, CursorFactory factory,\n            DatabaseErrorHandler errorHandler) {\n        return openDatabase(path, factory, CREATE_IF_NECESSARY, errorHandler);\n    }\n\n    /**\n     * Deletes a database including its journal file and other auxiliary files\n     * that may have been created by the database engine.\n     *\n     * @param file The database file path.\n     * @return True if the database was successfully deleted.\n     */\n    public static boolean deleteDatabase(File file) {\n        if (file == null) {\n            throw new IllegalArgumentException(\"file must not be null\");\n        }\n\n        boolean deleted = file.delete();\n        deleted |= new File(file.getPath() + \"-journal\").delete();\n        deleted |= new File(file.getPath() + \"-shm\").delete();\n        deleted |= new File(file.getPath() + \"-wal\").delete();\n\n        File dir = file.getParentFile();\n        if (dir != null) {\n            final String prefix = file.getName() + \"-mj\";\n            final FileFilter filter = new FileFilter() {\n                @Override\n                public boolean accept(File candidate) {\n                    return candidate.getName().startsWith(prefix);\n                }\n            };\n\n            File[] masterJournals = dir.listFiles(filter);\n            if (masterJournals != null) {\n                for (File masterJournal : masterJournals) {\n                    deleted |= masterJournal.delete();\n                }\n            }\n        }\n        return deleted;\n    }\n\n    /**\n     * Reopens the database in read-write mode.\n     * If the database is already read-write, does nothing.\n     *\n     * @throws SQLiteException       if the database could not be reopened as requested, in which\n     *                               case it remains open in read only mode.\n     * @throws IllegalStateException if the database is not open.\n     * @hide\n     * @see #isReadOnly()\n     */\n    public void reopenReadWrite() {\n        synchronized (mLock) {\n            throwIfNotOpenLocked();\n\n            if (!isReadOnlyLocked()) {\n                return; // nothing to do\n            }\n\n            // Reopen the database in read-write mode.\n            final int oldOpenFlags = mConfigurationLocked.openFlags;\n            mConfigurationLocked.openFlags = (mConfigurationLocked.openFlags & ~OPEN_READ_MASK)\n                    | OPEN_READWRITE;\n            try {\n                mConnectionPoolLocked.reconfigure(mConfigurationLocked);\n            } catch (RuntimeException ex) {\n                mConfigurationLocked.openFlags = oldOpenFlags;\n                throw ex;\n            }\n        }\n    }\n\n    private void open(byte[] password, SQLiteCipherSpec cipher, int poolSize) {\n        try {\n            try {\n                openInner(password, cipher, poolSize);\n            } catch (SQLiteDatabaseCorruptException ex) {\n                // NOTE: For encrypted databases not using HMAC (SQLCipher version 1.x),\n                // wrong password is likely reported as SQLITE_NOTADB error code, thus\n                // SQLiteDatabaseCorruptException. No retry is possible unless using a\n                // different DatabaseErrorHandler.\n                onCorruption();\n                openInner(password, cipher, poolSize);\n            }\n        } catch (SQLiteException ex) {\n            Log.e(TAG, \"Failed to open database '\" + getLabel() + \"'.\", ex);\n            close();\n            throw ex;\n        }\n    }\n\n    private void openInner(byte[] password, SQLiteCipherSpec cipher, int poolSize) {\n        synchronized (mLock) {\n            assert mConnectionPoolLocked == null;\n            mConnectionPoolLocked = SQLiteConnectionPool.open(this, mConfigurationLocked,\n                    password, cipher, poolSize);\n        }\n\n        synchronized (sActiveDatabases) {\n            sActiveDatabases.put(this, null);\n        }\n    }\n\n    /**\n     * Create a memory backed SQLite database.  Its contents will be destroyed\n     * when the database is closed.\n     * <p/>\n     * <p>Sets the locale of the database to the  the system's current locale.\n     * Call {@link #setLocale} if you would like something else.</p>\n     *\n     * @param factory an optional factory class that is called to instantiate a\n     *                cursor when query is called\n     * @return a SQLiteDatabase object, or null if the database can't be created\n     */\n    public static SQLiteDatabase create(CursorFactory factory) {\n        // This is a magic string with special meaning for SQLite.\n        return openDatabase(SQLiteDatabaseConfiguration.MEMORY_DB_PATH,\n                factory, CREATE_IF_NECESSARY);\n    }\n\n    public void addExtension(SQLiteExtension extension) {\n        synchronized (mLock) {\n            throwIfNotOpenLocked();\n\n            if (mConfigurationLocked.extensions.add(extension)) {\n                try {\n                    mConnectionPoolLocked.reconfigure(mConfigurationLocked);\n                } catch (RuntimeException ex) {\n                    mConfigurationLocked.extensions.remove(extension);\n                    throw ex;\n                }\n            }\n        }\n    }\n\n    /**\n     * Gets the database version.\n     *\n     * @return the database version\n     */\n    public int getVersion() {\n        return ((Long) DatabaseUtils.longForQuery(this, \"PRAGMA user_version;\", null)).intValue();\n    }\n\n    /**\n     * Sets the database version.\n     *\n     * @param version the new database version\n     */\n    public void setVersion(int version) {\n        execSQL(\"PRAGMA user_version = \" + version);\n    }\n\n    /**\n     * Returns the maximum size the database may grow to.\n     *\n     * @return the new maximum database size\n     */\n    public long getMaximumSize() {\n        long pageCount = DatabaseUtils.longForQuery(this, \"PRAGMA max_page_count;\", null);\n        return pageCount * getPageSize();\n    }\n\n    /**\n     * Sets the maximum size the database will grow to. The maximum size cannot\n     * be set below the current size.\n     *\n     * @param numBytes the maximum database size, in bytes\n     * @return the new maximum database size\n     */\n    public long setMaximumSize(long numBytes) {\n        long pageSize = getPageSize();\n        long numPages = numBytes / pageSize;\n        // If numBytes isn't a multiple of pageSize, bump up a page\n        if ((numBytes % pageSize) != 0) {\n            numPages++;\n        }\n        long newPageCount = DatabaseUtils.longForQuery(this, \"PRAGMA max_page_count = \" + numPages,\n                null);\n        return newPageCount * pageSize;\n    }\n\n    /**\n     * Returns the current database page size, in bytes.\n     *\n     * @return the database page size, in bytes\n     */\n    public long getPageSize() {\n        return DatabaseUtils.longForQuery(this, \"PRAGMA page_size;\", null);\n    }\n\n    /**\n     * Sets the database page size. The page size must be a power of two. This\n     * method does not work if any data has been written to the database file,\n     * and must be called right after the database has been created.\n     *\n     * @param numBytes the database page size, in bytes\n     */\n    public void setPageSize(long numBytes) {\n        execSQL(\"PRAGMA page_size = \" + numBytes);\n    }\n\n    /**\n     * Mark this table as syncable. When an update occurs in this table the\n     * _sync_dirty field will be set to ensure proper syncing operation.\n     *\n     * @param table        the table to mark as syncable\n     * @param deletedTable The deleted table that corresponds to the\n     *                     syncable table\n     * @deprecated This method no longer serves any useful purpose and has been deprecated.\n     */\n    @Deprecated\n    public void markTableSyncable(String table, String deletedTable) {\n    }\n\n    /**\n     * Mark this table as syncable, with the _sync_dirty residing in another\n     * table. When an update occurs in this table the _sync_dirty field of the\n     * row in updateTable with the _id in foreignKey will be set to\n     * ensure proper syncing operation.\n     *\n     * @param table       an update on this table will trigger a sync time removal\n     * @param foreignKey  this is the column in table whose value is an _id in\n     *                    updateTable\n     * @param updateTable this is the table that will have its _sync_dirty\n     * @deprecated This method no longer serves any useful purpose and has been deprecated.\n     */\n    @Deprecated\n    public void markTableSyncable(String table, String foreignKey, String updateTable) {\n    }\n\n    /**\n     * Finds the name of the first table, which is editable.\n     *\n     * @param tables a list of tables\n     * @return the first table listed\n     */\n    public static String findEditTable(String tables) {\n        if (!TextUtils.isEmpty(tables)) {\n            // find the first word terminated by either a space or a comma\n            int spacepos = tables.indexOf(' ');\n            int commapos = tables.indexOf(',');\n\n            if (spacepos > 0 && (spacepos < commapos || commapos < 0)) {\n                return tables.substring(0, spacepos);\n            } else if (commapos > 0 && (commapos < spacepos || spacepos < 0)) {\n                return tables.substring(0, commapos);\n            }\n            return tables;\n        } else {\n            throw new IllegalStateException(\"Invalid tables\");\n        }\n    }\n\n    /**\n     * Compiles an SQL statement into a reusable pre-compiled statement object.\n     * The parameters are identical to {@link #execSQL(String)}. You may put ?s in the\n     * statement and fill in those values with {@link SQLiteProgram#bindString}\n     * and {@link SQLiteProgram#bindLong} each time you want to run the\n     * statement. Statements may not return result sets larger than 1x1.\n     * <p/>\n     * No two threads should be using the same {@link SQLiteStatement} at the same time.\n     *\n     * @param sql The raw SQL statement, may contain ? for unknown values to be\n     *            bound later.\n     * @return A pre-compiled {@link SQLiteStatement} object. Note that\n     * {@link SQLiteStatement}s are not synchronized, see the documentation for more details.\n     */\n    public SQLiteStatement compileStatement(String sql) throws SQLException {\n        acquireReference();\n        try {\n            return new SQLiteStatement(this, sql, null);\n        } finally {\n            releaseReference();\n        }\n    }\n\n    /**\n     * Query the given URL, returning a {@link Cursor} over the result set.\n     *\n     * @param distinct      true if you want each row to be unique, false otherwise.\n     * @param table         The table name to compile the query against.\n     * @param columns       A list of which columns to return. Passing null will\n     *                      return all columns, which is discouraged to prevent reading\n     *                      data from storage that isn't going to be used.\n     * @param selection     A filter declaring which rows to return, formatted as an\n     *                      SQL WHERE clause (excluding the WHERE itself). Passing null\n     *                      will return all rows for the given table.\n     * @param selectionArgs You may include ?s in selection, which will be\n     *                      replaced by the values from selectionArgs, in order that they\n     *                      appear in the selection. The values will be bound as Strings.\n     * @param groupBy       A filter declaring how to group rows, formatted as an SQL\n     *                      GROUP BY clause (excluding the GROUP BY itself). Passing null\n     *                      will cause the rows to not be grouped.\n     * @param having        A filter declare which row groups to include in the cursor,\n     *                      if row grouping is being used, formatted as an SQL HAVING\n     *                      clause (excluding the HAVING itself). Passing null will cause\n     *                      all row groups to be included, and is required when row\n     *                      grouping is not being used.\n     * @param orderBy       How to order the rows, formatted as an SQL ORDER BY clause\n     *                      (excluding the ORDER BY itself). Passing null will use the\n     *                      default sort order, which may be unordered.\n     * @param limit         Limits the number of rows returned by the query,\n     *                      formatted as LIMIT clause. Passing null denotes no LIMIT clause.\n     * @return A {@link Cursor} object, which is positioned before the first entry. Note that\n     * {@link Cursor}s are not synchronized, see the documentation for more details.\n     * @see Cursor\n     */\n    public Cursor query(boolean distinct, String table, String[] columns, String selection,\n            Object[] selectionArgs, String groupBy, String having, String orderBy, String limit) {\n        return queryWithFactory(null, distinct, table, columns, selection, selectionArgs,\n                groupBy, having, orderBy, limit, null);\n    }\n\n    /**\n     * Query the given URL, returning a {@link Cursor} over the result set.\n     *\n     * @param distinct           true if you want each row to be unique, false otherwise.\n     * @param table              The table name to compile the query against.\n     * @param columns            A list of which columns to return. Passing null will\n     *                           return all columns, which is discouraged to prevent reading\n     *                           data from storage that isn't going to be used.\n     * @param selection          A filter declaring which rows to return, formatted as an\n     *                           SQL WHERE clause (excluding the WHERE itself). Passing null\n     *                           will return all rows for the given table.\n     * @param selectionArgs      You may include ?s in selection, which will be\n     *                           replaced by the values from selectionArgs, in order that they\n     *                           appear in the selection. The values will be bound as Strings.\n     * @param groupBy            A filter declaring how to group rows, formatted as an SQL\n     *                           GROUP BY clause (excluding the GROUP BY itself). Passing null\n     *                           will cause the rows to not be grouped.\n     * @param having             A filter declare which row groups to include in the cursor,\n     *                           if row grouping is being used, formatted as an SQL HAVING\n     *                           clause (excluding the HAVING itself). Passing null will cause\n     *                           all row groups to be included, and is required when row\n     *                           grouping is not being used.\n     * @param orderBy            How to order the rows, formatted as an SQL ORDER BY clause\n     *                           (excluding the ORDER BY itself). Passing null will use the\n     *                           default sort order, which may be unordered.\n     * @param limit              Limits the number of rows returned by the query,\n     *                           formatted as LIMIT clause. Passing null denotes no LIMIT clause.\n     * @param cancellationSignal A signal to cancel the operation in progress, or null if none.\n     *                           If the operation is canceled, then {@link OperationCanceledException} will be thrown\n     *                           when the query is executed.\n     * @return A {@link Cursor} object, which is positioned before the first entry. Note that\n     * {@link Cursor}s are not synchronized, see the documentation for more details.\n     * @see Cursor\n     */\n    public Cursor query(boolean distinct, String table, String[] columns,\n            String selection, Object[] selectionArgs, String groupBy,\n            String having, String orderBy, String limit, CancellationSignal cancellationSignal) {\n        return queryWithFactory(null, distinct, table, columns, selection, selectionArgs, groupBy, having, orderBy, limit, cancellationSignal);\n    }\n\n    /**\n     * Query the given URL, returning a {@link Cursor} over the result set.\n     *\n     * @param cursorFactory the cursor factory to use, or null for the default factory\n     * @param distinct      true if you want each row to be unique, false otherwise.\n     * @param table         The table name to compile the query against.\n     * @param columns       A list of which columns to return. Passing null will\n     *                      return all columns, which is discouraged to prevent reading\n     *                      data from storage that isn't going to be used.\n     * @param selection     A filter declaring which rows to return, formatted as an\n     *                      SQL WHERE clause (excluding the WHERE itself). Passing null\n     *                      will return all rows for the given table.\n     * @param selectionArgs You may include ?s in selection, which will be\n     *                      replaced by the values from selectionArgs, in order that they\n     *                      appear in the selection. The values will be bound as Strings.\n     * @param groupBy       A filter declaring how to group rows, formatted as an SQL\n     *                      GROUP BY clause (excluding the GROUP BY itself). Passing null\n     *                      will cause the rows to not be grouped.\n     * @param having\n     * @param orderBy       How to order the rows, formatteA filter declare which row groups to include in the cursor,\n     *                      if row grouping is being used, formatted as an SQL HAVING\n     *                      clause (excluding the HAVING itself). Passing null will cause\n     *                      all row groups to be included, and is required when row\n     *                      grouping is not being used.d as an SQL ORDER BY clause\n     *                      (excluding the ORDER BY itself). Passing null will use the\n     *                      default sort order, which may be unordered.\n     * @param limit         Limits the number of rows returned by the query,\n     *                      formatted as LIMIT clause. Passing null denotes no LIMIT clause.\n     * @return A {@link Cursor} object, which is positioned before the first entry. Note that\n     * {@link Cursor}s are not synchronized, see the documentation for more details.\n     * @see Cursor\n     */\n    public Cursor queryWithFactory(CursorFactory cursorFactory,\n            boolean distinct, String table, String[] columns,\n            String selection, Object[] selectionArgs, String groupBy,\n            String having, String orderBy, String limit) {\n        return queryWithFactory(cursorFactory, distinct, table, columns, selection,\n                selectionArgs, groupBy, having, orderBy, limit, null);\n    }\n\n    /**\n     * Query the given URL, returning a {@link Cursor} over the result set.\n     *\n     * @param cursorFactory      the cursor factory to use, or null for the default factory\n     * @param distinct           true if you want each row to be unique, false otherwise.\n     * @param table              The table name to compile the query against.\n     * @param columns            A list of which columns to return. Passing null will\n     *                           return all columns, which is discouraged to prevent reading\n     *                           data from storage that isn't going to be used.\n     * @param selection          A filter declaring which rows to return, formatted as an\n     *                           SQL WHERE clause (excluding the WHERE itself). Passing null\n     *                           will return all rows for the given table.\n     * @param selectionArgs      You may include ?s in selection, which will be\n     *                           replaced by the values from selectionArgs, in order that they\n     *                           appear in the selection. The values will be bound as Strings.\n     * @param groupBy            A filter declaring how to group rows, formatted as an SQL\n     *                           GROUP BY clause (excluding the GROUP BY itself). Passing null\n     *                           will cause the rows to not be grouped.\n     * @param having             A filter declare which row groups to include in the cursor,\n     *                           if row grouping is being used, formatted as an SQL HAVING\n     *                           clause (excluding the HAVING itself). Passing null will cause\n     *                           all row groups to be included, and is required when row\n     *                           grouping is not being used.\n     * @param orderBy            How to order the rows, formatted as an SQL ORDER BY clause\n     *                           (excluding the ORDER BY itself). Passing null will use the\n     *                           default sort order, which may be unordered.\n     * @param limit              Limits the number of rows returned by the query,\n     *                           formatted as LIMIT clause. Passing null denotes no LIMIT clause.\n     * @param cancellationSignal A signal to cancel the operation in progress, or null if none.\n     *                           If the operation is canceled, then {@link OperationCanceledException} will be thrown\n     *                           when the query is executed.\n     * @return A {@link Cursor} object, which is positioned before the first entry. Note that\n     * {@link Cursor}s are not synchronized, see the documentation for more details.\n     * @see Cursor\n     */\n    public Cursor queryWithFactory(CursorFactory cursorFactory,\n            boolean distinct, String table, String[] columns,\n            String selection, Object[] selectionArgs, String groupBy,\n            String having, String orderBy, String limit, CancellationSignal cancellationSignal) {\n        acquireReference();\n        try {\n            String sql = SQLiteQueryBuilder.buildQueryString(\n                    distinct, table, columns, selection, groupBy, having, orderBy, limit);\n\n            return rawQueryWithFactory(cursorFactory, sql, selectionArgs,\n                    findEditTable(table), cancellationSignal);\n        } finally {\n            releaseReference();\n        }\n    }\n\n    /**\n     * Query the given table, returning a {@link Cursor} over the result set.\n     *\n     * @param table         The table name to compile the query against.\n     * @param columns       A list of which columns to return. Passing null will\n     *                      return all columns, which is discouraged to prevent reading\n     *                      data from storage that isn't going to be used.\n     * @param selection     A filter declaring which rows to return, formatted as an\n     *                      SQL WHERE clause (excluding the WHERE itself). Passing null\n     *                      will return all rows for the given table.\n     * @param selectionArgs You may include ?s in selection, which will be\n     *                      replaced by the values from selectionArgs, in order that they\n     *                      appear in the selection. The values will be bound as Strings.\n     * @param groupBy       A filter declaring how to group rows, formatted as an SQL\n     *                      GROUP BY clause (excluding the GROUP BY itself). Passing null\n     *                      will cause the rows to not be grouped.\n     * @param having        A filter declare which row groups to include in the cursor,\n     *                      if row grouping is being used, formatted as an SQL HAVING\n     *                      clause (excluding the HAVING itself). Passing null will cause\n     *                      all row groups to be included, and is required when row\n     *                      grouping is not being used.\n     * @param orderBy       How to order the rows, formatted as an SQL ORDER BY clause\n     *                      (excluding the ORDER BY itself). Passing null will use the\n     *                      default sort order, which may be unordered.\n     * @return A {@link Cursor} object, which is positioned before the first entry. Note that\n     * {@link Cursor}s are not synchronized, see the documentation for more details.\n     * @see Cursor\n     */\n    public Cursor query(String table, String[] columns, String selection,\n            Object[] selectionArgs, String groupBy, String having,\n            String orderBy) {\n\n        return query(false, table, columns, selection, selectionArgs, groupBy,\n                having, orderBy, null /* limit */);\n    }\n\n\n    /**\n     * Query the given table, returning a {@link Cursor} over the result set.\n     *\n     * @param table         The table name to compile the query against.\n     * @param columns       A list of which columns to return. Passing null will\n     *                      return all columns, which is discouraged to prevent reading\n     *                      data from storage that isn't going to be used.\n     * @param selection     A filter declaring which rows to return, formatted as an\n     *                      SQL WHERE clause (excluding the WHERE itself). Passing null\n     *                      will return all rows for the given table.\n     * @param selectionArgs You may include ?s in selection, which will be\n     *                      replaced by the values from selectionArgs, in order that they\n     *                      appear in the selection. The values will be bound as Strings.\n     * @param groupBy       A filter declaring how to group rows, formatted as an SQL\n     *                      GROUP BY clause (excluding the GROUP BY itself). Passing null\n     *                      will cause the rows to not be grouped.\n     * @param having        A filter declare which row groups to include in the cursor,\n     *                      if row grouping is being used, formatted as an SQL HAVING\n     *                      clause (excluding the HAVING itself). Passing null will cause\n     *                      all row groups to be included, and is required when row\n     *                      grouping is not being used.\n     * @param orderBy       How to order the rows, formatted as an SQL ORDER BY clause\n     *                      (excluding the ORDER BY itself). Passing null will use the\n     *                      default sort order, which may be unordered.\n     * @param limit         Limits the number of rows returned by the query,\n     *                      formatted as LIMIT clause. Passing null denotes no LIMIT clause.\n     * @return A {@link Cursor} object, which is positioned before the first entry. Note that\n     * {@link Cursor}s are not synchronized, see the documentation for more details.\n     * @see Cursor\n     */\n    public Cursor query(String table, String[] columns, String selection,\n            Object[] selectionArgs, String groupBy, String having,\n            String orderBy, String limit) {\n\n        return query(false, table, columns, selection, selectionArgs, groupBy,\n                having, orderBy, limit);\n    }\n\n    /**\n     * Runs the provided SQL and returns a {@link Cursor} over the result set.\n     *\n     * @param sql           the SQL query. The SQL string must not be ; terminated\n     * @param selectionArgs You may include ?s in where clause in the query,\n     *                      which will be replaced by the values from selectionArgs. The\n     *                      values will be bound as Strings.\n     * @return A {@link Cursor} object, which is positioned before the first entry. Note that\n     * {@link Cursor}s are not synchronized, see the documentation for more details.\n     */\n    public Cursor rawQuery(String sql, Object[] selectionArgs) {\n        return rawQueryWithFactory(null, sql, selectionArgs, null, null);\n    }\n\n    /**\n     * Runs the provided SQL and returns a {@link Cursor} over the result set.\n     *\n     * @param sql                the SQL query. The SQL string must not be ; terminated\n     * @param selectionArgs      You may include ?s in where clause in the query,\n     *                           which will be replaced by the values from selectionArgs. The\n     *                           values will be bound as Strings.\n     * @param cancellationSignal A signal to cancel the operation in progress, or null if none.\n     *                           If the operation is canceled, then {@link OperationCanceledException} will be thrown\n     *                           when the query is executed.\n     * @return A {@link Cursor} object, which is positioned before the first entry. Note that\n     * {@link Cursor}s are not synchronized, see the documentation for more details.\n     */\n    public Cursor rawQuery(String sql, Object[] selectionArgs,\n            CancellationSignal cancellationSignal) {\n        return rawQueryWithFactory(null, sql, selectionArgs, null, cancellationSignal);\n    }\n\n    /**\n     * Runs the provided SQL and returns a cursor over the result set.\n     *\n     * @param cursorFactory the cursor factory to use, or null for the default factory\n     * @param sql           the SQL query. The SQL string must not be ; terminated\n     * @param selectionArgs You may include ?s in where clause in the query,\n     *                      which will be replaced by the values from selectionArgs. The\n     *                      values will be bound as Strings.\n     * @param editTable     the name of the first table, which is editable\n     * @return A {@link Cursor} object, which is positioned before the first entry. Note that\n     * {@link Cursor}s are not synchronized, see the documentation for more details.\n     */\n    public Cursor rawQueryWithFactory(\n            CursorFactory cursorFactory, String sql, Object[] selectionArgs,\n            String editTable) {\n        return rawQueryWithFactory(cursorFactory, sql, selectionArgs, editTable, null);\n    }\n\n    /**\n     * Runs the provided SQL and returns a cursor over the result set.\n     *\n     * @param cursorFactory      the cursor factory to use, or null for the default factory\n     * @param sql                the SQL query. The SQL string must not be ; terminated\n     * @param selectionArgs      You may include ?s in where clause in the query,\n     *                           which will be replaced by the values from selectionArgs. The\n     *                           values will be bound as Strings.\n     * @param editTable          the name of the first table, which is editable\n     * @param cancellationSignal A signal to cancel the operation in progress, or null if none.\n     *                           If the operation is canceled, then {@link OperationCanceledException} will be thrown\n     *                           when the query is executed.\n     * @return A {@link Cursor} object, which is positioned before the first entry. Note that\n     * {@link Cursor}s are not synchronized, see the documentation for more details.\n     */\n    public Cursor rawQueryWithFactory(\n            CursorFactory cursorFactory, String sql, Object[] selectionArgs,\n            String editTable, CancellationSignal cancellationSignal) {\n        acquireReference();\n        try {\n            SQLiteCursorDriver driver = new SQLiteDirectCursorDriver(this, sql, editTable,\n                    cancellationSignal);\n            return driver.query(cursorFactory != null ? cursorFactory : mCursorFactory,\n                    selectionArgs);\n        } finally {\n            releaseReference();\n        }\n    }\n\n    /**\n     * Convenience method for inserting a row into the database.\n     *\n     * @param table          the table to insert the row into\n     * @param nullColumnHack optional; may be <code>null</code>.\n     *                       SQL doesn't allow inserting a completely empty row without\n     *                       naming at least one column name.  If your provided <code>values</code> is\n     *                       empty, no column names are known and an empty row can't be inserted.\n     *                       If not set to null, the <code>nullColumnHack</code> parameter\n     *                       provides the name of nullable column name to explicitly insert a NULL into\n     *                       in the case where your <code>values</code> is empty.\n     * @param values         this map contains the initial column values for the\n     *                       row. The keys should be the column names and the values the\n     *                       column values\n     * @return the row ID of the newly inserted row, or -1 if an error occurred\n     */\n    public long insert(String table, String nullColumnHack, ContentValues values) {\n        try {\n            return insertWithOnConflict(table, nullColumnHack, values, CONFLICT_NONE);\n        } catch (SQLiteDatabaseCorruptException e) {\n            throw e;\n        } catch (SQLException e) {\n            Log.e(TAG, \"Error inserting %s: %s\", values, e);\n            return -1;\n        }\n    }\n\n    /**\n     * Convenience method for inserting a row into the database.\n     *\n     * @param table          the table to insert the row into\n     * @param nullColumnHack optional; may be <code>null</code>.\n     *                       SQL doesn't allow inserting a completely empty row without\n     *                       naming at least one column name.  If your provided <code>values</code> is\n     *                       empty, no column names are known and an empty row can't be inserted.\n     *                       If not set to null, the <code>nullColumnHack</code> parameter\n     *                       provides the name of nullable column name to explicitly insert a NULL into\n     *                       in the case where your <code>values</code> is empty.\n     * @param values         this map contains the initial column values for the\n     *                       row. The keys should be the column names and the values the\n     *                       column values\n     * @return the row ID of the newly inserted row, or -1 if an error occurred\n     * @throws SQLException\n     */\n    public long insertOrThrow(String table, String nullColumnHack, ContentValues values)\n            throws SQLException {\n        return insertWithOnConflict(table, nullColumnHack, values, CONFLICT_NONE);\n    }\n\n    /**\n     * Convenience method for replacing a row in the database.\n     *\n     * @param table          the table in which to replace the row\n     * @param nullColumnHack optional; may be <code>null</code>.\n     *                       SQL doesn't allow inserting a completely empty row without\n     *                       naming at least one column name.  If your provided <code>initialValues</code> is\n     *                       empty, no column names are known and an empty row can't be inserted.\n     *                       If not set to null, the <code>nullColumnHack</code> parameter\n     *                       provides the name of nullable column name to explicitly insert a NULL into\n     *                       in the case where your <code>initialValues</code> is empty.\n     * @param initialValues  this map contains the initial column values for\n     *                       the row.\n     * @return the row ID of the newly inserted row, or -1 if an error occurred\n     */\n    public long replace(String table, String nullColumnHack, ContentValues initialValues) {\n        try {\n            return insertWithOnConflict(table, nullColumnHack, initialValues,\n                    CONFLICT_REPLACE);\n        } catch (SQLiteDatabaseCorruptException e) {\n            throw e;\n        } catch (SQLException e) {\n            Log.e(TAG, \"Error inserting \" + initialValues, e);\n            return -1;\n        }\n    }\n\n    /**\n     * Convenience method for replacing a row in the database.\n     *\n     * @param table          the table in which to replace the row\n     * @param nullColumnHack optional; may be <code>null</code>.\n     *                       SQL doesn't allow inserting a completely empty row without\n     *                       naming at least one column name.  If your provided <code>initialValues</code> is\n     *                       empty, no column names are known and an empty row can't be inserted.\n     *                       If not set to null, the <code>nullColumnHack</code> parameter\n     *                       provides the name of nullable column name to explicitly insert a NULL into\n     *                       in the case where your <code>initialValues</code> is empty.\n     * @param initialValues  this map contains the initial column values for\n     *                       the row. The key\n     * @return the row ID of the newly inserted row, or -1 if an error occurred\n     * @throws SQLException\n     */\n    public long replaceOrThrow(String table, String nullColumnHack,\n            ContentValues initialValues) throws SQLException {\n        return insertWithOnConflict(table, nullColumnHack, initialValues,\n                CONFLICT_REPLACE);\n    }\n\n    @SuppressWarnings(\"unchecked\")\n    private Set<String> keySet(ContentValues cv) {\n        if (Build.VERSION.SDK_INT < 11) {\n            try {\n                Class<?> cls = Class.forName(\"android.content.ContentValues\");\n                Field fd = cls.getDeclaredField(\"mValues\");\n                fd.setAccessible(true);\n                return ((HashMap<String, Object>) fd.get(cv)).keySet();\n            } catch (Exception e) {\n                throw new RuntimeException(e);\n            }\n        } else {\n            return cv.keySet();\n        }\n    }\n\n    /**\n     * General method for inserting a row into the database.\n     *\n     * @param table             the table to insert the row into\n     * @param nullColumnHack    optional; may be <code>null</code>.\n     *                          SQL doesn't allow inserting a completely empty row without\n     *                          naming at least one column name.  If your provided <code>initialValues</code> is\n     *                          empty, no column names are known and an empty row can't be inserted.\n     *                          If not set to null, the <code>nullColumnHack</code> parameter\n     *                          provides the name of nullable column name to explicitly insert a NULL into\n     *                          in the case where your <code>initialValues</code> is empty.\n     * @param initialValues     this map contains the initial column values for the\n     *                          row. The keys should be the column names and the values the\n     *                          column values\n     * @param conflictAlgorithm for insert conflict resolver\n     * @return the row ID of the newly inserted row\n     * OR the primary key of the existing row if the input param 'conflictAlgorithm' =\n     * {@link #CONFLICT_IGNORE}\n     * OR -1 if any error\n     */\n    public long insertWithOnConflict(String table, String nullColumnHack,\n            ContentValues initialValues, int conflictAlgorithm) {\n        acquireReference();\n        try {\n            StringBuilder sql = new StringBuilder();\n            sql.append(\"INSERT\");\n            sql.append(CONFLICT_VALUES[conflictAlgorithm]);\n            sql.append(\" INTO \");\n            sql.append(table);\n            sql.append('(');\n\n            Object[] bindArgs = null;\n            int size = (initialValues != null && initialValues.size() > 0)\n                    ? initialValues.size() : 0;\n            if (size > 0) {\n                bindArgs = new Object[size];\n                int i = 0;\n                for (String colName : keySet(initialValues)) {\n                    sql.append((i > 0) ? \",\" : \"\");\n                    sql.append(colName);\n                    bindArgs[i++] = initialValues.get(colName);\n                }\n                sql.append(')');\n                sql.append(\" VALUES (\");\n                for (i = 0; i < size; i++) {\n                    sql.append((i > 0) ? \",?\" : \"?\");\n                }\n            } else {\n                sql.append(nullColumnHack + \") VALUES (NULL\");\n            }\n            sql.append(')');\n\n            SQLiteStatement statement = new SQLiteStatement(this, sql.toString(), bindArgs);\n            try {\n                return statement.executeInsert();\n            } finally {\n                statement.close();\n            }\n        } finally {\n            releaseReference();\n        }\n    }\n\n    /**\n     * Convenience method for deleting rows in the database.\n     *\n     * @param table       the table to delete from\n     * @param whereClause the optional WHERE clause to apply when deleting.\n     *                    Passing null will delete all rows.\n     * @param whereArgs   You may include ?s in the where clause, which\n     *                    will be replaced by the values from whereArgs. The values\n     *                    will be bound as Strings.\n     * @return the number of rows affected if a whereClause is passed in, 0\n     * otherwise. To remove all rows and get a count pass \"1\" as the\n     * whereClause.\n     */\n    public int delete(String table, String whereClause, String[] whereArgs) {\n        acquireReference();\n        try {\n            SQLiteStatement statement = new SQLiteStatement(this, \"DELETE FROM \" + table +\n                    (!TextUtils.isEmpty(whereClause) ? \" WHERE \" + whereClause : \"\"), whereArgs);\n            try {\n                return statement.executeUpdateDelete();\n            } finally {\n                statement.close();\n            }\n        } finally {\n            releaseReference();\n        }\n    }\n\n    /**\n     * Convenience method for updating rows in the database.\n     *\n     * @param table       the table to update in\n     * @param values      a map from column names to new column values. null is a\n     *                    valid value that will be translated to NULL.\n     * @param whereClause the optional WHERE clause to apply when updating.\n     *                    Passing null will update all rows.\n     * @param whereArgs   You may include ?s in the where clause, which\n     *                    will be replaced by the values from whereArgs. The values\n     *                    will be bound as Strings.\n     * @return the number of rows affected\n     */\n    public int update(String table, ContentValues values, String whereClause, String[] whereArgs) {\n        return updateWithOnConflict(table, values, whereClause, whereArgs, CONFLICT_NONE);\n    }\n\n    /**\n     * Convenience method for updating rows in the database.\n     *\n     * @param table             the table to update in\n     * @param values            a map from column names to new column values. null is a\n     *                          valid value that will be translated to NULL.\n     * @param whereClause       the optional WHERE clause to apply when updating.\n     *                          Passing null will update all rows.\n     * @param whereArgs         You may include ?s in the where clause, which\n     *                          will be replaced by the values from whereArgs. The values\n     *                          will be bound as Strings.\n     * @param conflictAlgorithm for update conflict resolver\n     * @return the number of rows affected\n     */\n    public int updateWithOnConflict(String table, ContentValues values,\n            String whereClause, String[] whereArgs, int conflictAlgorithm) {\n        if (values == null || values.size() == 0) {\n            throw new IllegalArgumentException(\"Empty values\");\n        }\n\n        acquireReference();\n        try {\n            StringBuilder sql = new StringBuilder(120);\n            sql.append(\"UPDATE \");\n            sql.append(CONFLICT_VALUES[conflictAlgorithm]);\n            sql.append(table);\n            sql.append(\" SET \");\n\n            // move all bind args to one array\n            int setValuesSize = values.size();\n            int bindArgsSize = (whereArgs == null) ? setValuesSize : (setValuesSize + whereArgs.length);\n            Object[] bindArgs = new Object[bindArgsSize];\n            int i = 0;\n            for (String colName : keySet(values)) {\n                sql.append((i > 0) ? \",\" : \"\");\n                sql.append(colName);\n                bindArgs[i++] = values.get(colName);\n                sql.append(\"=?\");\n            }\n            if (whereArgs != null) {\n                for (i = setValuesSize; i < bindArgsSize; i++) {\n                    bindArgs[i] = whereArgs[i - setValuesSize];\n                }\n            }\n            if (!TextUtils.isEmpty(whereClause)) {\n                sql.append(\" WHERE \");\n                sql.append(whereClause);\n            }\n\n            SQLiteStatement statement = new SQLiteStatement(this, sql.toString(), bindArgs);\n            try {\n                return statement.executeUpdateDelete();\n            } finally {\n                statement.close();\n            }\n        } finally {\n            releaseReference();\n        }\n    }\n\n    /**\n     * Execute a single SQL statement that is NOT a SELECT\n     * or any other SQL statement that returns data.\n     * <p>\n     * It has no means to return any data (such as the number of affected rows).\n     * Instead, you're encouraged to use {@link #insert(String, String, ContentValues)},\n     * {@link #update(String, ContentValues, String, String[])}, et al, when possible.\n     * </p>\n     * <p>\n     * When using {@link #enableWriteAheadLogging()}, journal_mode is\n     * automatically managed by this class. So, do not set journal_mode\n     * using \"PRAGMA journal_mode'<value>\" statement if your app is using\n     * {@link #enableWriteAheadLogging()}\n     * </p>\n     *\n     * @param sql the SQL statement to be executed. Multiple statements separated by semicolons are\n     *            not supported.\n     * @throws SQLException if the SQL string is invalid\n     */\n    public void execSQL(String sql) throws SQLException {\n        executeSql(sql, null, null);\n    }\n\n    /**\n     * Execute a single SQL statement that is NOT a SELECT/INSERT/UPDATE/DELETE.\n     * <p>\n     * For INSERT statements, use any of the following instead.\n     * <ul>\n     * <li>{@link #insert(String, String, ContentValues)}</li>\n     * <li>{@link #insertOrThrow(String, String, ContentValues)}</li>\n     * <li>{@link #insertWithOnConflict(String, String, ContentValues, int)}</li>\n     * </ul>\n     * <p>\n     * For UPDATE statements, use any of the following instead.\n     * <ul>\n     * <li>{@link #update(String, ContentValues, String, String[])}</li>\n     * <li>{@link #updateWithOnConflict(String, ContentValues, String, String[], int)}</li>\n     * </ul>\n     * <p>\n     * For DELETE statements, use any of the following instead.\n     * <ul>\n     * <li>{@link #delete(String, String, String[])}</li>\n     * </ul>\n     * <p>\n     * For example, the following are good candidates for using this method:\n     * <ul>\n     * <li>ALTER TABLE</li>\n     * <li>CREATE or DROP table / trigger / view / index / virtual table</li>\n     * <li>REINDEX</li>\n     * <li>RELEASE</li>\n     * <li>SAVEPOINT</li>\n     * <li>PRAGMA that returns no data</li>\n     * </ul>\n     * </p>\n     * <p>\n     * When using {@link #enableWriteAheadLogging()}, journal_mode is\n     * automatically managed by this class. So, do not set journal_mode\n     * using \"PRAGMA journal_mode'<value>\" statement if your app is using\n     * {@link #enableWriteAheadLogging()}\n     * </p>\n     *\n     * @param sql      the SQL statement to be executed. Multiple statements separated by semicolons are\n     *                 not supported.\n     * @param bindArgs only byte[], String, Long and Double are supported in bindArgs.\n     * @throws SQLException if the SQL string is invalid\n     */\n    public void execSQL(String sql, Object[] bindArgs) throws SQLException {\n        executeSql(sql, bindArgs, null);\n    }\n\n    /**\n     * Execute a single SQL statement that is NOT a SELECT\n     * or any other SQL statement that returns data.\n     * <p>\n     * It has no means to return any data (such as the number of affected rows).\n     * Instead, you're encouraged to use {@link #insert(String, String, ContentValues)},\n     * {@link #update(String, ContentValues, String, String[])}, et al, when possible.\n     * </p>\n     * <p>\n     * When using {@link #enableWriteAheadLogging()}, journal_mode is\n     * automatically managed by this class. So, do not set journal_mode\n     * using \"PRAGMA journal_mode'<value>\" statement if your app is using\n     * {@link #enableWriteAheadLogging()}\n     * </p>\n     *\n     * @param sql      the SQL statement to be executed. Multiple statements separated by semicolons are\n     *                 not supported.\n     * @param bindArgs arguments to bind. Only byte[], String, Long and Double are supported.\n     * @param cancellationSignal A signal to cancel the operation in progress, or null if none.\n     *                           If the operation is canceled, then {@link OperationCanceledException} will be thrown\n     *                           when the query is executed.\n     * @throws SQLException if the SQL string is invalid\n     */\n    public void execSQL(String sql, Object[] bindArgs, CancellationSignal cancellationSignal) {\n        executeSql(sql, bindArgs, cancellationSignal);\n    }\n\n    private int executeSql(String sql, Object[] bindArgs, CancellationSignal cancellationSignal)\n            throws SQLException {\n        acquireReference();\n        try {\n            if (DatabaseUtils.getSqlStatementType(sql) == DatabaseUtils.STATEMENT_ATTACH) {\n                boolean disableWal = false;\n                synchronized (mLock) {\n                    if (!mHasAttachedDbsLocked) {\n                        mHasAttachedDbsLocked = true;\n                        disableWal = true;\n                    }\n                }\n                if (disableWal) {\n                    disableWriteAheadLogging();\n                }\n            }\n\n            SQLiteStatement statement = new SQLiteStatement(this, sql, bindArgs);\n            try {\n                return statement.executeUpdateDelete(cancellationSignal);\n            } finally {\n                statement.close();\n            }\n        } finally {\n            releaseReference();\n        }\n    }\n\n    public Pair<Integer, Integer> walCheckpoint(String dbName, boolean blockWriting) {\n        acquireReference();\n        try {\n            int connectionFlag = blockWriting ?\n                    SQLiteConnectionPool.CONNECTION_FLAG_PRIMARY_CONNECTION_AFFINITY : 0;\n            return getThreadSession().walCheckpoint(dbName, connectionFlag);\n        } finally {\n            releaseReference();\n        }\n    }\n\n    /**\n     * Returns true if the database is opened as read only.\n     *\n     * @return True if database is opened as read only.\n     */\n    public boolean isReadOnly() {\n        synchronized (mLock) {\n            return isReadOnlyLocked();\n        }\n    }\n\n    private boolean isReadOnlyLocked() {\n        return (mConfigurationLocked.openFlags & OPEN_READ_MASK) == OPEN_READONLY;\n    }\n\n    /**\n     * Returns true if the database is in-memory db.\n     *\n     * @return True if the database is in-memory.\n     */\n    public boolean isInMemoryDatabase() {\n        synchronized (mLock) {\n            return mConfigurationLocked.isInMemoryDb();\n        }\n    }\n\n    /**\n     * Returns true if the database is currently open.\n     *\n     * @return True if the database is currently open (has not been closed).\n     */\n    public boolean isOpen() {\n        synchronized (mLock) {\n            return mConnectionPoolLocked != null;\n        }\n    }\n\n    /**\n     * Returns true if the new version code is greater than the current database version.\n     *\n     * @param newVersion The new version code.\n     * @return True if the new version code is greater than the current database version.\n     */\n    public boolean needUpgrade(int newVersion) {\n        return newVersion > getVersion();\n    }\n\n    /**\n     * Gets the path to the database file.\n     *\n     * @return The path to the database file.\n     */\n    public final String getPath() {\n        synchronized (mLock) {\n            return mConfigurationLocked.path;\n        }\n    }\n\n    /**\n     * Sets the locale for this database.  Does nothing if this database has\n     * the {@link #NO_LOCALIZED_COLLATORS} flag set or was opened read only.\n     *\n     * @param locale The new locale.\n     * @throws SQLException if the locale could not be set.  The most common reason\n     *                      for this is that there is no collator available for the locale you requested.\n     *                      In this case the database remains unchanged.\n     */\n    public void setLocale(Locale locale) {\n        if (locale == null) {\n            throw new IllegalArgumentException(\"locale must not be null.\");\n        }\n\n        synchronized (mLock) {\n            throwIfNotOpenLocked();\n\n            final Locale oldLocale = mConfigurationLocked.locale;\n            mConfigurationLocked.locale = locale;\n            try {\n                mConnectionPoolLocked.reconfigure(mConfigurationLocked);\n            } catch (RuntimeException ex) {\n                mConfigurationLocked.locale = oldLocale;\n                throw ex;\n            }\n        }\n    }\n\n    /**\n     * Sets the maximum size of the prepared-statement cache for this database.\n     * (size of the cache = number of compiled-sql-statements stored in the cache).\n     * <p/>\n     * Maximum cache size can ONLY be increased from its current size (default = 10).\n     * If this method is called with smaller size than the current maximum value,\n     * then IllegalStateException is thrown.\n     * <p/>\n     * This method is thread-safe.\n     *\n     * @param cacheSize the size of the cache. can be (0 to {@link #MAX_SQL_CACHE_SIZE})\n     * @throws IllegalStateException if input cacheSize > {@link #MAX_SQL_CACHE_SIZE}.\n     */\n    public void setMaxSqlCacheSize(int cacheSize) {\n        if (cacheSize > MAX_SQL_CACHE_SIZE || cacheSize < 0) {\n            throw new IllegalStateException(\n                    \"expected value between 0 and \" + MAX_SQL_CACHE_SIZE);\n        }\n\n        synchronized (mLock) {\n            throwIfNotOpenLocked();\n\n            final int oldMaxSqlCacheSize = mConfigurationLocked.maxSqlCacheSize;\n            mConfigurationLocked.maxSqlCacheSize = cacheSize;\n            try {\n                mConnectionPoolLocked.reconfigure(mConfigurationLocked);\n            } catch (RuntimeException ex) {\n                mConfigurationLocked.maxSqlCacheSize = oldMaxSqlCacheSize;\n                throw ex;\n            }\n        }\n    }\n\n    /**\n     * Sets whether foreign key constraints are enabled for the database.\n     * <p>\n     * By default, foreign key constraints are not enforced by the database.\n     * This method allows an application to enable foreign key constraints.\n     * It must be called each time the database is opened to ensure that foreign\n     * key constraints are enabled for the session.\n     * </p><p>\n     * A good time to call this method is right after calling {@link #openOrCreateDatabase}\n     * or in the {@link SQLiteOpenHelper#onConfigure} callback.\n     * </p><p>\n     * When foreign key constraints are disabled, the database does not check whether\n     * changes to the database will violate foreign key constraints.  Likewise, when\n     * foreign key constraints are disabled, the database will not execute cascade\n     * delete or update triggers.  As a result, it is possible for the database\n     * state to become inconsistent.  To perform a database integrity check,\n     * call {@link #isDatabaseIntegrityOk}.\n     * </p><p>\n     * This method must not be called while a transaction is in progress.\n     * </p><p>\n     * See also <a href=\"http://sqlite.org/foreignkeys.html\">SQLite Foreign Key Constraints</a>\n     * for more details about foreign key constraint support.\n     * </p>\n     *\n     * @param enable True to enable foreign key constraints, false to disable them.\n     * @throws IllegalStateException if the are transactions is in progress\n     *                               when this method is called.\n     */\n    public void setForeignKeyConstraintsEnabled(boolean enable) {\n        synchronized (mLock) {\n            throwIfNotOpenLocked();\n\n            if (mConfigurationLocked.foreignKeyConstraintsEnabled == enable) {\n                return;\n            }\n\n            mConfigurationLocked.foreignKeyConstraintsEnabled = enable;\n            try {\n                mConnectionPoolLocked.reconfigure(mConfigurationLocked);\n            } catch (RuntimeException ex) {\n                mConfigurationLocked.foreignKeyConstraintsEnabled = !enable;\n                throw ex;\n            }\n        }\n    }\n\n    /**\n     * Returns {@link SQLiteCheckpointListener} object previously set.\n     *\n     * @return callback object set to the database\n     */\n    public SQLiteCheckpointListener getCheckpointCallback() {\n        synchronized (mLock) {\n            throwIfNotOpenLocked();\n            if (!mConfigurationLocked.customWALHookEnabled)\n                return null;\n\n            return mConnectionPoolLocked.getCheckpointListener();\n        }\n    }\n\n    /**\n     * Set callback object to be called on each commit in WAL mode.\n     *\n     * <p>Use this callback for customized WAL checkpoint operations for different situations an\n     * applications. For general applications, you probably want {@link #setAsyncCheckpointEnabled(boolean)}\n     * for asynchronous checkpointing on a separate thread.</p>\n     *\n     * <p>Callback object won't be called in journal modes other than WAL.</p>\n     *\n     * @param callback callback object to be set, or null to disable customized checkpointing\n     */\n    public void setCheckpointCallback(SQLiteCheckpointListener callback) {\n        boolean customWALHookEnabled = (callback != null);\n\n        synchronized (mLock) {\n            throwIfNotOpenLocked();\n\n            if (mConfigurationLocked.customWALHookEnabled != customWALHookEnabled) {\n                mConfigurationLocked.customWALHookEnabled = customWALHookEnabled;\n                try {\n                    mConnectionPoolLocked.reconfigure(mConfigurationLocked);\n                } catch (RuntimeException ex) {\n                    mConfigurationLocked.customWALHookEnabled = !customWALHookEnabled;\n                    throw ex;\n                }\n            }\n\n            mConnectionPoolLocked.setCheckpointListener(callback);\n        }\n    }\n\n    /**\n     * Returns whether asynchronous checkpointing is enabled.\n     *\n     * @return true if asynchronous checkpointing is enabled\n     */\n    public boolean getAsyncCheckpointEnabled() {\n        SQLiteCheckpointListener listener = getCheckpointCallback();\n        return (listener != null) && (listener instanceof SQLiteAsyncCheckpointer);\n    }\n\n    /**\n     * Set whether to use asynchronous checkpointing strategy in WAL mode. Asynchronous checkpointing\n     * runs checkpoint operations on a separate thread, which may improve performance in WAL mode.\n     *\n     * <p>This method calls {@link #setCheckpointCallback(SQLiteCheckpointListener)}, thus will overwrite\n     * previous callbacks set by that method.</p>\n     *\n     * @param enabled true if asynchronous checkpointing is to be enabled\n     */\n    public void setAsyncCheckpointEnabled(boolean enabled) {\n        SQLiteCheckpointListener callback = enabled ?\n                new SQLiteAsyncCheckpointer() : null;\n        setCheckpointCallback(callback);\n    }\n\n    /**\n     * This method enables parallel execution of queries from multiple threads on the\n     * same database.  It does this by opening multiple connections to the database\n     * and using a different database connection for each query.  The database\n     * journal mode is also changed to enable writes to proceed concurrently with reads.\n     * <p>\n     * When write-ahead logging is not enabled (the default), it is not possible for\n     * reads and writes to occur on the database at the same time.  Before modifying the\n     * database, the writer implicitly acquires an exclusive lock on the database which\n     * prevents readers from accessing the database until the write is completed.\n     * </p><p>\n     * In contrast, when write-ahead logging is enabled (by calling this method), write\n     * operations occur in a separate log file which allows reads to proceed concurrently.\n     * While a write is in progress, readers on other threads will perceive the state\n     * of the database as it was before the write began.  When the write completes, readers\n     * on other threads will then perceive the new state of the database.\n     * </p><p>\n     * It is a good idea to enable write-ahead logging whenever a database will be\n     * concurrently accessed and modified by multiple threads at the same time.\n     * However, write-ahead logging uses significantly more memory than ordinary\n     * journaling because there are multiple connections to the same database.\n     * So if a database will only be used by a single thread, or if optimizing\n     * concurrency is not very important, then write-ahead logging should be disabled.\n     * </p><p>\n     * After calling this method, execution of queries in parallel is enabled as long as\n     * the database remains open.  To disable execution of queries in parallel, either\n     * call {@link #disableWriteAheadLogging} or close the database and reopen it.\n     * </p><p>\n     * The maximum number of connections used to execute queries in parallel is\n     * dependent upon the device memory and possibly other properties.\n     * </p><p>\n     * If a query is part of a transaction, then it is executed on the same database handle the\n     * transaction was begun.\n     * </p><p>\n     * Writers should use {@link #beginTransactionNonExclusive()} or\n     * {@link #beginTransactionWithListenerNonExclusive(SQLiteTransactionListener)}\n     * to start a transaction.  Non-exclusive mode allows database file to be in readable\n     * by other threads executing queries.\n     * </p><p>\n     * If the database has any attached databases, then execution of queries in parallel is NOT\n     * possible.  Likewise, write-ahead logging is not supported for read-only databases\n     * or memory databases.  In such cases, {@link #enableWriteAheadLogging} returns false.\n     * </p><p>\n     * The best way to enable write-ahead logging is to pass the\n     * {@link #ENABLE_WRITE_AHEAD_LOGGING} flag to {@link #openDatabase}.  This is\n     * more efficient than calling {@link #enableWriteAheadLogging}.\n     * <code><pre>\n     *     SQLiteDatabase db = SQLiteDatabase.openDatabase(\"db_filename\", cursorFactory,\n     *             SQLiteDatabase.CREATE_IF_NECESSARY | SQLiteDatabase.ENABLE_WRITE_AHEAD_LOGGING,\n     *             myDatabaseErrorHandler);\n     *     db.enableWriteAheadLogging();\n     * </pre></code>\n     * </p><p>\n     * Another way to enable write-ahead logging is to call {@link #enableWriteAheadLogging}\n     * after opening the database.\n     * <code><pre>\n     *     SQLiteDatabase db = SQLiteDatabase.openDatabase(\"db_filename\", cursorFactory,\n     *             SQLiteDatabase.CREATE_IF_NECESSARY, myDatabaseErrorHandler);\n     *     db.enableWriteAheadLogging();\n     * </pre></code>\n     * </p><p>\n     * See also <a href=\"http://sqlite.org/wal.html\">SQLite Write-Ahead Logging</a> for\n     * more details about how write-ahead logging works.\n     * </p>\n     *\n     * @return True if write-ahead logging is enabled.\n     * @throws IllegalStateException if there are transactions in progress at the\n     *                               time this method is called.  WAL mode can only be changed when there are no\n     *                               transactions in progress.\n     * @see #ENABLE_WRITE_AHEAD_LOGGING\n     * @see #disableWriteAheadLogging\n     */\n    public boolean enableWriteAheadLogging() {\n        synchronized (mLock) {\n            throwIfNotOpenLocked();\n\n            if ((mConfigurationLocked.openFlags & ENABLE_WRITE_AHEAD_LOGGING) != 0) {\n                return true;\n            }\n\n            if (isReadOnlyLocked()) {\n                // WAL doesn't make sense for readonly-databases.\n                // TODO: True, but connection pooling does still make sense...\n                return false;\n            }\n\n            if (mConfigurationLocked.isInMemoryDb()) {\n                Log.i(TAG, \"can't enable WAL for memory databases.\");\n                return false;\n            }\n\n            // make sure this database has NO attached databases because sqlite's write-ahead-logging\n            // doesn't work for databases with attached databases\n            if (mHasAttachedDbsLocked) {\n                Log.i(TAG, \"this database: \" + mConfigurationLocked.label\n                        + \" has attached databases. can't  enable WAL.\");\n                return false;\n            }\n\n            mConfigurationLocked.openFlags |= ENABLE_WRITE_AHEAD_LOGGING;\n            try {\n                mConnectionPoolLocked.reconfigure(mConfigurationLocked);\n            } catch (RuntimeException ex) {\n                mConfigurationLocked.openFlags &= ~ENABLE_WRITE_AHEAD_LOGGING;\n                throw ex;\n            }\n        }\n        return true;\n    }\n\n    /**\n     * This method disables the features enabled by {@link #enableWriteAheadLogging()}.\n     *\n     * @throws IllegalStateException if there are transactions in progress at the\n     *                               time this method is called.  WAL mode can only be changed when there are no\n     *                               transactions in progress.\n     * @see #enableWriteAheadLogging\n     */\n    public void disableWriteAheadLogging() {\n        synchronized (mLock) {\n            throwIfNotOpenLocked();\n\n            if ((mConfigurationLocked.openFlags & ENABLE_WRITE_AHEAD_LOGGING) == 0) {\n                return;\n            }\n\n            mConfigurationLocked.openFlags &= ~ENABLE_WRITE_AHEAD_LOGGING;\n            try {\n                mConnectionPoolLocked.reconfigure(mConfigurationLocked);\n            } catch (RuntimeException ex) {\n                mConfigurationLocked.openFlags |= ENABLE_WRITE_AHEAD_LOGGING;\n                throw ex;\n            }\n        }\n    }\n\n    /**\n     * Returns true if write-ahead logging has been enabled for this database.\n     *\n     * @return True if write-ahead logging has been enabled for this database.\n     * @see #enableWriteAheadLogging\n     * @see #ENABLE_WRITE_AHEAD_LOGGING\n     */\n    public boolean isWriteAheadLoggingEnabled() {\n        synchronized (mLock) {\n            throwIfNotOpenLocked();\n\n            return (mConfigurationLocked.openFlags & ENABLE_WRITE_AHEAD_LOGGING) != 0;\n        }\n    }\n\n    public int getSynchronousMode() {\n        synchronized (mLock) {\n            throwIfNotOpenLocked();\n\n            return mConfigurationLocked.synchronousMode;\n        }\n    }\n\n    public void setSynchronousMode(int mode) {\n        synchronized (mLock) {\n            throwIfNotOpenLocked();\n\n            final int oldMode = mConfigurationLocked.synchronousMode;\n            if (oldMode != mode) {\n                mConfigurationLocked.synchronousMode = mode;\n                try {\n                    mConnectionPoolLocked.reconfigure(mConfigurationLocked);\n                } catch (RuntimeException ex) {\n                    mConfigurationLocked.synchronousMode = oldMode;\n                    throw ex;\n                }\n            }\n        }\n    }\n\n    /** Returns the {@link SQLiteChangeListener} object bound to this database.\n     *\n     * @return {@link SQLiteChangeListener} object bound to this database.\n     * @see SQLiteChangeListener\n     * @see #setChangeListener(SQLiteChangeListener, boolean)\n     */\n    public SQLiteChangeListener getChangeListener() {\n        synchronized (mLock) {\n            throwIfNotOpenLocked();\n            return mConnectionPoolLocked.getChangeListener();\n        }\n    }\n\n    /**\n     * Bind a {@link SQLiteChangeListener} object for database change notifications.\n     *\n     * @param listener      listener to be set\n     * @param notifyRowId   whether RowIDs of each modified row should be reported\n     */\n    public void setChangeListener(SQLiteChangeListener listener, boolean notifyRowId) {\n        synchronized (mLock) {\n            throwIfNotOpenLocked();\n            mConnectionPoolLocked.setChangeListener(listener, notifyRowId);\n        }\n    }\n\n    /**\n     * Returns the {@link SQLiteTrace} object bound to this database.\n     *\n     * @return {@link SQLiteTrace} object bound to this database\n     * @see SQLiteTrace\n     * @see #setTraceCallback(SQLiteTrace)\n     */\n    public SQLiteTrace getTraceCallback() {\n        synchronized (mLock) {\n            throwIfNotOpenLocked();\n            return mConnectionPoolLocked.getTraceCallback();\n        }\n    }\n\n    /**\n     * Bind a {@link SQLiteTrace} callback object for tracing database performance.\n     * When a callback object was bound, its methods will be called on various event, such as\n     * a SQL statement was executed or a database connection was granted to a thread.\n     *\n     * @param callback callback object to be set, or null to disable tracing.\n     */\n    public void setTraceCallback(SQLiteTrace callback) {\n        synchronized (mLock) {\n            throwIfNotOpenLocked();\n            mConnectionPoolLocked.setTraceCallback(callback);\n        }\n    }\n\n    /**\n     * Collect statistics about all open databases in the current process.\n     * Used by bug report.\n     */\n    static ArrayList<DbStats> getDbStats() {\n        ArrayList<DbStats> dbStatsList = new ArrayList<DbStats>();\n        for (SQLiteDatabase db : getActiveDatabases()) {\n            db.collectDbStats(dbStatsList);\n        }\n        return dbStatsList;\n    }\n\n    private void collectDbStats(ArrayList<DbStats> dbStatsList) {\n        synchronized (mLock) {\n            if (mConnectionPoolLocked != null) {\n                mConnectionPoolLocked.collectDbStats(dbStatsList);\n            }\n        }\n    }\n\n    private static ArrayList<SQLiteDatabase> getActiveDatabases() {\n        ArrayList<SQLiteDatabase> databases = new ArrayList<SQLiteDatabase>();\n        synchronized (sActiveDatabases) {\n            databases.addAll(sActiveDatabases.keySet());\n        }\n        return databases;\n    }\n\n    /**\n     * Dump detailed information about all open databases in the current process.\n     * Used by bug report.\n     *\n     * @param printer printer used to receive or output log messages\n     * @param verbose true if verbose messages is requested\n     */\n    public static void dumpAll(Printer printer, boolean verbose) {\n        for (SQLiteDatabase db : getActiveDatabases()) {\n            db.dump(printer, verbose);\n        }\n    }\n\n    public static JSONArray dumpAllJSON(boolean verbose) throws JSONException {\n        JSONArray arr = new JSONArray();\n        for (SQLiteDatabase db : getActiveDatabases()) {\n            arr.put(db.dumpJSON(verbose));\n        }\n        return arr;\n    }\n\n    /**\n     * Dump detailed information about this database.\n     *\n     * @param printer printer used to receive or output log messages\n     * @param verbose true if verbose messages is requested\n     */\n    public void dump(Printer printer, boolean verbose) {\n        synchronized (mLock) {\n            if (mConnectionPoolLocked != null) {\n                mConnectionPoolLocked.dump(printer, verbose);\n            }\n        }\n    }\n\n    public JSONObject dumpJSON(boolean verbose) throws JSONException {\n        synchronized (mLock) {\n            if (mConnectionPoolLocked != null) {\n                return mConnectionPoolLocked.dumpJSON(verbose);\n            } else {\n                return new JSONObject();\n            }\n        }\n    }\n\n    /**\n     * Returns list of full path-names of all attached databases including the main database\n     * by executing 'pragma database_list' on the database.\n     *\n     * @return ArrayList of pairs of (database name, database file path) or null if the database\n     * is not open.\n     */\n    public List<Pair<String, String>> getAttachedDbs() {\n        ArrayList<Pair<String, String>> attachedDbs = new ArrayList<Pair<String, String>>();\n        synchronized (mLock) {\n            if (mConnectionPoolLocked == null) {\n                return null; // not open\n            }\n\n            if (!mHasAttachedDbsLocked) {\n                // No attached databases.\n                // There is a small window where attached databases exist but this flag is not\n                // set yet.  This can occur when this thread is in a race condition with another\n                // thread that is executing the SQL statement: \"attach database <blah> as <foo>\"\n                // If this thread is NOT ok with such a race condition (and thus possibly not\n                // receivethe entire list of attached databases), then the caller should ensure\n                // that no thread is executing any SQL statements while a thread is calling this\n                // method.  Typically, this method is called when 'adb bugreport' is done or the\n                // caller wants to collect stats on the database and all its attached databases.\n                attachedDbs.add(new Pair<String, String>(\"main\", mConfigurationLocked.path));\n                return attachedDbs;\n            }\n\n            acquireReference();\n        }\n\n        try {\n            // has attached databases. query sqlite to get the list of attached databases.\n            Cursor c = null;\n            try {\n                c = rawQuery(\"pragma database_list;\", null);\n                while (c.moveToNext()) {\n                    // sqlite returns a row for each database in the returned list of databases.\n                    //   in each row,\n                    //       1st column is the database name such as main, or the database\n                    //                              name specified on the \"ATTACH\" command\n                    //       2nd column is the database file path.\n                    attachedDbs.add(new Pair<String, String>(c.getString(1), c.getString(2)));\n                }\n            } finally {\n                if (c != null) {\n                    c.close();\n                }\n            }\n            return attachedDbs;\n        } finally {\n            releaseReference();\n        }\n    }\n\n    /**\n     * Runs 'pragma integrity_check' on the given database (and all the attached databases)\n     * and returns true if the given database (and all its attached databases) pass integrity_check,\n     * false otherwise.\n     * <p/>\n     * If the result is false, then this method logs the errors reported by the integrity_check\n     * command execution.\n     * <p/>\n     * Note that 'pragma integrity_check' on a database can take a long time.\n     *\n     * @return true if the given database (and all its attached databases) pass integrity_check,\n     * false otherwise.\n     */\n    public boolean isDatabaseIntegrityOk() {\n        acquireReference();\n        try {\n            List<Pair<String, String>> attachedDbs = null;\n            try {\n                attachedDbs = getAttachedDbs();\n                if (attachedDbs == null) {\n                    throw new IllegalStateException(\"databaselist for: \" + getPath() + \" couldn't \" +\n                            \"be retrieved. probably because the database is closed\");\n                }\n            } catch (SQLiteException e) {\n                // can't get attachedDb list. do integrity check on the main database\n                attachedDbs = new ArrayList<Pair<String, String>>();\n                attachedDbs.add(new Pair<String, String>(\"main\", getPath()));\n            }\n\n            for (int i = 0; i < attachedDbs.size(); i++) {\n                Pair<String, String> p = attachedDbs.get(i);\n                SQLiteStatement prog = null;\n                try {\n                    prog = compileStatement(\"PRAGMA \" + p.first + \".integrity_check(1);\");\n                    String result = prog.simpleQueryForString();\n                    if (!DatabaseUtils.objectEquals(result, \"ok\")) {\n                        // integrity_checker failed on main or attached databases\n                        Log.e(TAG, \"PRAGMA integrity_check on \" + p.second + \" returned: \" + result);\n                        return false;\n                    }\n                } finally {\n                    if (prog != null) prog.close();\n                }\n            }\n        } finally {\n            releaseReference();\n        }\n        return true;\n    }\n\n    /**\n     * Acquire database connection from connection pool and return its native handle\n     * (a.k.a {@code sqlite3 *}).\n     *\n     * <p>The caller must release the returned handle when finished with it by calling\n     * {@link #releaseNativeConnection(long, Exception)} <strong>within the same thread</strong>.\n     * Failed to release the returned handle will cause connection leakage and probably\n     * ANR.</p>\n     *\n     * @param operation     string describing usage of the connection, for logging\n     * @param readOnly      whether operations on returned connection is read-only\n     * @param interactive   whether operations on returned connection is for interactive\n     * @return {@code sqlite3 *} handle casted to {@code long}\n     */\n    public long acquireNativeConnectionHandle(String operation, boolean readOnly, boolean interactive) {\n        if (operation == null)\n            operation = \"unnamedNative\";\n\n        int connectionFlags = readOnly ? SQLiteConnectionPool.CONNECTION_FLAG_READ_ONLY :\n                SQLiteConnectionPool.CONNECTION_FLAG_PRIMARY_CONNECTION_AFFINITY;\n        if (interactive)\n            connectionFlags |= SQLiteConnectionPool.CONNECTION_FLAG_INTERACTIVE;\n\n        long handle = getThreadSession().acquireConnectionForNativeHandle(connectionFlags)\n                .getNativeHandle(operation);\n        if (handle == 0)\n            throw new IllegalStateException(\"SQLiteConnection native handle not initialized.\");\n        return handle;\n    }\n\n    /**\n     * Release connection returned by {@link #acquireNativeConnectionHandle(String, boolean, boolean)}.\n     *\n     * @param nativePtr {@code sqlite3 *} handle to release\n     * @param ex        exception occurred during operations on the native handle,\n     *                  or null for successful operations\n     */\n    public void releaseNativeConnection(long nativePtr, Exception ex) {\n        getThreadSession().releaseConnectionForNativeHandle(ex);\n    }\n\n\n    @Override\n    public String toString() {\n        return \"SQLiteDatabase: \" + getPath();\n    }\n\n    private void throwIfNotOpenLocked() {\n        if (mConnectionPoolLocked == null) {\n            throw new IllegalStateException(\"The database '\" + mConfigurationLocked.label\n                    + \"' is not open.\");\n        }\n    }\n\n    /**\n     * Used to allow returning sub-classes of {@link Cursor} when calling query.\n     */\n    public interface CursorFactory {\n        /**\n         * See {@link SQLiteCursor#SQLiteCursor(SQLiteCursorDriver, String, SQLiteQuery)}.\n         */\n        Cursor newCursor(SQLiteDatabase db,\n                SQLiteCursorDriver masterQuery, String editTable,\n                SQLiteProgram query);\n\n        SQLiteProgram newQuery(SQLiteDatabase db, String query,\n                Object[] bindArgs, CancellationSignal cancellationSignalForPrepare);\n    }\n\n    /**\n     * A callback interface for a custom sqlite3 function.\n     * This can be used to create a function that can be called from\n     * sqlite3 database triggers.\n     *\n     * @hide\n     */\n    public interface CustomFunction {\n        public void callback(String[] args);\n    }\n}\n"
  },
  {
    "path": "deprecated/android/wcdb/src/com/tencent/wcdb/database/SQLiteDatabaseConfiguration.java",
    "content": "/*\n * Copyright (C) 2011 The Android Open Source Project\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdb.database;\n\nimport com.tencent.wcdb.extension.SQLiteExtension;\n\nimport java.util.LinkedHashSet;\nimport java.util.Locale;\n\n/**\n * Describes how to configure a database.\n * <p>\n * The purpose of this object is to keep track of all of the little\n * configuration settings that are applied to a database after it\n * is opened so that they can be applied to all connections in the\n * connection pool uniformly.\n * </p><p>\n * Each connection maintains its own copy of this object so it can\n * keep track of which settings have already been applied.\n * </p>\n *\n * @hide\n */\npublic final class SQLiteDatabaseConfiguration {\n\n    /**\n     * Special path used by in-memory databases.\n     */\n    public static final String MEMORY_DB_PATH = \":memory:\";\n\n    /**\n     * The database path.\n     */\n    public final String path;\n\n    /**\n     * The label to use to describe the database when it appears in logs.\n     * This is derived from the path but is stripped to remove PII.\n     */\n    public final String label;\n\n    /**\n     * Name of VFS used to open connections, or null to use default VFS.\n     *\n     * Default is null.\n     */\n    public String vfsName;\n\n    /**\n     * The flags used to open the database.\n     */\n    public int openFlags;\n\n    /**\n     * The maximum size of the prepared statement cache for each database connection.\n     * Must be non-negative.\n     *\n     * Default is 25.\n     */\n    public int maxSqlCacheSize;\n\n    /**\n     * The database locale.\n     * Default is the value returned by {@link Locale#getDefault()}.\n     */\n    public Locale locale;\n\n    /**\n     * True if foreign key constraints are enabled.\n     * Default is false.\n     */\n    public boolean foreignKeyConstraintsEnabled;\n\n    /**\n     * True if custom WAL hook, including async-checkpoint, is enabled.\n     * Default is false.\n     */\n    public boolean customWALHookEnabled;\n\n    /**\n     * Synchronize mode to be used.\n     */\n    public int synchronousMode;\n\n    /**\n     * True if SQLite should call registered callback when database is updated.\n     */\n    public boolean updateNotificationEnabled;\n\n    /**\n     * True if update notifications should contain information about modified RowID.\n     */\n    public boolean updateNotificationRowID;\n\n    /**\n     * Extensions to register.\n     */\n    public final LinkedHashSet<SQLiteExtension> extensions = new LinkedHashSet<>();\n\n    /**\n     * Creates a database configuration with the required parameters for opening a\n     * database and default values for all other parameters.\n     *\n     * @param path The database path.\n     * @param openFlags Open flags for the database, such as {@link SQLiteDatabase#OPEN_READWRITE}.\n     */\n    public SQLiteDatabaseConfiguration(String path, int openFlags) {\n        if (path == null) {\n            throw new IllegalArgumentException(\"path must not be null.\");\n        }\n\n        this.path = path;\n        label = path;\n        this.openFlags = openFlags;\n\n        // Set default values for optional parameters.\n        synchronousMode = SQLiteDatabase.SYNCHRONOUS_FULL;\n        maxSqlCacheSize = 25;\n        locale = Locale.getDefault();\n        vfsName = (openFlags & SQLiteDatabase.ENABLE_IO_TRACE) != 0 ? \"vfslog\" : null;\n    }\n\n    /**\n     * Creates a database configuration as a copy of another configuration.\n     *\n     * @param other The other configuration.\n     */\n    public SQLiteDatabaseConfiguration(SQLiteDatabaseConfiguration other) {\n        if (other == null) {\n            throw new IllegalArgumentException(\"other must not be null.\");\n        }\n\n        this.path = other.path;\n        this.label = other.label;\n        updateParametersFrom(other);\n    }\n\n    /**\n     * Updates the non-immutable parameters of this configuration object\n     * from the other configuration object.\n     *\n     * @param other The object from which to copy the parameters.\n     */\n    public void updateParametersFrom(SQLiteDatabaseConfiguration other) {\n        if (other == null) {\n            throw new IllegalArgumentException(\"other must not be null.\");\n        }\n        if (!path.equals(other.path)) {\n            throw new IllegalArgumentException(\"other configuration must refer to \"\n                    + \"the same database.\");\n        }\n\n        openFlags = other.openFlags;\n        maxSqlCacheSize = other.maxSqlCacheSize;\n        locale = other.locale;\n        foreignKeyConstraintsEnabled = other.foreignKeyConstraintsEnabled;\n        customWALHookEnabled = other.customWALHookEnabled;\n        updateNotificationEnabled = other.updateNotificationEnabled;\n        updateNotificationRowID = other.updateNotificationRowID;\n        synchronousMode = other.synchronousMode;\n        vfsName = other.vfsName;\n\n        extensions.clear();\n        extensions.addAll(other.extensions);\n    }\n\n    /**\n     * Returns true if the database is in-memory.\n     * @return True if the database is in-memory.\n     */\n    public boolean isInMemoryDb() {\n        return path.equalsIgnoreCase(MEMORY_DB_PATH);\n    }\n}\n"
  },
  {
    "path": "deprecated/android/wcdb/src/com/tencent/wcdb/database/SQLiteDatabaseCorruptException.java",
    "content": "/*\n * Copyright (C) 2006 The Android Open Source Project\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdb.database;\n\n/**\n * An exception that indicates that the SQLite database file is corrupt.\n */\n@SuppressWarnings(\"serial\")\npublic class SQLiteDatabaseCorruptException extends SQLiteException {\n    public SQLiteDatabaseCorruptException() {}\n\n    public SQLiteDatabaseCorruptException(String error) {\n        super(error);\n    }\n}\n"
  },
  {
    "path": "deprecated/android/wcdb/src/com/tencent/wcdb/database/SQLiteDatabaseLockedException.java",
    "content": "/*\n * Copyright (C) 2010 The Android Open Source Project\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdb.database;\n\n/**\n * Thrown if  the database engine was unable to acquire the\n * database locks it needs to do its job.  If the statement is a [COMMIT]\n * or occurs outside of an explicit transaction, then you can retry the\n * statement.  If the statement is not a [COMMIT] and occurs within a\n * explicit transaction then you should rollback the transaction before\n * continuing.\n */\n@SuppressWarnings(\"serial\")\npublic class SQLiteDatabaseLockedException extends SQLiteException {\n    public SQLiteDatabaseLockedException() {}\n\n    public SQLiteDatabaseLockedException(String error) {\n        super(error);\n    }\n}\n"
  },
  {
    "path": "deprecated/android/wcdb/src/com/tencent/wcdb/database/SQLiteDatatypeMismatchException.java",
    "content": "/*\n * Copyright (C) 2008 The Android Open Source Project\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdb.database;\n\n@SuppressWarnings(\"serial\")\npublic class SQLiteDatatypeMismatchException extends SQLiteException {\n    public SQLiteDatatypeMismatchException() {}\n\n    public SQLiteDatatypeMismatchException(String error) {\n        super(error);\n    }\n}\n"
  },
  {
    "path": "deprecated/android/wcdb/src/com/tencent/wcdb/database/SQLiteDebug.java",
    "content": "/*\n * Copyright (C) 2007 The Android Open Source Project\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdb.database;\n\nimport java.util.ArrayList;\n\nimport android.annotation.SuppressLint;\nimport android.util.Printer;\n\nimport com.tencent.wcdb.support.Log;\n\n/**\n * Provides debugging info about all SQLite databases running in the current process.\n *\n * {@hide}\n */\npublic final class SQLiteDebug {\n\n    private static final String TAG = \"WCDB.SQLiteDebug\";\n\n    private static native void nativeGetPagerStats(PagerStats stats);\n    private static native int nativeGetLastErrorLine();\n    private static native void nativeSetIOTraceFlags(int flags);\n    private static native void nativeGetIOTraceStats(long connectionPtr, ArrayList<IOTraceStats> statsList);\n\n    static {\n        // Ensure libwcdb.so is loaded.\n        SQLiteGlobal.initialize();\n    }\n\n    private SQLiteDebug() {}\n\n    /**\n     * Determines whether a query should be logged.\n     *\n     * Reads the \"db.log.slow_query_threshold\" system property, which can be changed\n     * by the user at any time.  If the value is zero, then all queries will\n     * be considered slow.  If the value does not exist or is negative, then no queries will\n     * be considered slow.\n     *\n     * This value can be changed dynamically while the system is running.\n     * For example, \"adb shell setprop db.log.slow_query_threshold 200\" will\n     * log all queries that take 200ms or longer to run.\n     * @hide\n     */\n    public static final boolean shouldLogSlowQuery(long elapsedTimeMillis) {\n        return elapsedTimeMillis > 300;\n    }\n\n    /**\n     * Contains statistics about the active pagers in the current process.\n     *\n     * @see #nativeGetPagerStats(PagerStats)\n     */\n    public static class PagerStats {\n        /** the current amount of memory checked out by sqlite using sqlite3_malloc().\n         * documented at http://www.sqlite.org/c3ref/c_status_malloc_size.html\n         */\n        public int memoryUsed;\n\n        /** the number of bytes of page cache allocation which could not be sattisfied by the\n         * SQLITE_CONFIG_PAGECACHE buffer and where forced to overflow to sqlite3_malloc().\n         * The returned value includes allocations that overflowed because they where too large\n         * (they were larger than the \"sz\" parameter to SQLITE_CONFIG_PAGECACHE) and allocations\n         * that overflowed because no space was left in the page cache.\n         * documented at http://www.sqlite.org/c3ref/c_status_malloc_size.html\n         */\n        public int pageCacheOverflow;\n\n        /** records the largest memory allocation request handed to sqlite3.\n         * documented at http://www.sqlite.org/c3ref/c_status_malloc_size.html\n         */\n        public int largestMemAlloc;\n\n        /** a list of {@link DbStats} - one for each main database opened by the applications\n         * running on the android device\n         */\n        public ArrayList<DbStats> dbStats;\n    }\n\n    /**\n     * contains statistics about a database\n     */\n    public static class DbStats {\n        /** name of the database */\n        public String dbName;\n\n        /** the page size for the database */\n        public long pageSize;\n\n        /** the database size */\n        public long dbSize;\n\n        /** documented here http://www.sqlite.org/c3ref/c_dbstatus_lookaside_used.html */\n        public int lookaside;\n\n        /** statement cache stats: hits/misses/cachesize */\n        public String cache;\n\n        public DbStats(String dbName, long pageCount, long pageSize, int lookaside,\n            int hits, int misses, int cachesize) {\n            this.dbName = dbName;\n            this.pageSize = pageSize / 1024;\n            dbSize = (pageCount * pageSize) / 1024;\n            this.lookaside = lookaside;\n            this.cache = hits + \"/\" + misses + \"/\" + cachesize;\n        }\n    }\n\n    /**\n     * return all pager and database stats for the current process.\n     * @return {@link PagerStats}\n     */\n    public static PagerStats getDatabaseInfo() {\n        PagerStats stats = new PagerStats();\n        nativeGetPagerStats(stats);\n        stats.dbStats = SQLiteDatabase.getDbStats();\n        return stats;\n    }\n\n\n    public static class IOTraceStats {\n        public String dbName;\n        public String path;\n        public long pageSize;\n        public long pageCount;\n        public String journalMode;\n\n        public long lastReadOffset;\n        public byte[] lastReadPage;\n        public long lastWriteOffset;\n        public byte[] lastWritePage;\n\n        public long lastJournalReadOffset;\n        public byte[] lastJournalReadPage;\n        public long lastJournalWriteOffset;\n        public byte[] lastJournalWritePage;\n\n        @SuppressLint(\"DefaultLocale\")\n        @Override\n        public String toString() {\n            return String.format(\"[%s | %s] pageSize: %d, pageCount: %d, journal: %s, lastRead: %d, lastWrite: %d, \" +\n                \"lastJournalRead: %d, lastJournalWrite: %d\",\n                    dbName, path, pageSize, pageCount, journalMode,\n                    lastReadOffset, lastWriteOffset, lastJournalReadOffset, lastJournalWriteOffset);\n        }\n    }\n\n    public static void setIOTraceFlags(int flags) {\n        nativeSetIOTraceFlags(flags);\n    }\n\n\n    private static volatile int sLastErrorLine;\n    private static volatile ArrayList<IOTraceStats> sLastIOTraceStats;\n    private static final ThreadLocal<Throwable> sLastCorruptionException = new ThreadLocal<>();\n\n    public static int getLastErrorLine() {\n        return sLastErrorLine;\n    }\n\n    public static ArrayList<IOTraceStats> getLastIOTraceStats() {\n        return sLastIOTraceStats;\n    }\n\n    static void collectLastIOTraceStats(SQLiteConnection connection) {\n        try {\n            sLastErrorLine = nativeGetLastErrorLine();\n\n            ArrayList<IOTraceStats> stats = new ArrayList<>();\n            long ptr = connection.getNativeHandle(null);\n            if (ptr != 0) {\n                nativeGetIOTraceStats(ptr, stats);\n                connection.endNativeHandle(null);\n            }\n\n            sLastIOTraceStats = stats;\n        } catch (RuntimeException e) {\n            Log.e(TAG, \"Cannot collect I/O trace statistics: \" + e.getMessage());\n        }\n    }\n\n    static void collectLastIOTraceStats(SQLiteDatabase db) {\n        try {\n            sLastErrorLine = nativeGetLastErrorLine();\n\n            ArrayList<IOTraceStats> stats = new ArrayList<>();\n            long ptr = db.acquireNativeConnectionHandle(\"collectIoStat\", false, false);\n            if (ptr != 0) {\n                nativeGetIOTraceStats(ptr, stats);\n            }\n            db.releaseNativeConnection(ptr, null);\n\n            sLastIOTraceStats = stats;\n        } catch (RuntimeException e) {\n            Log.e(TAG, \"Cannot collect I/O trace statistics: \" + e.getMessage());\n        }\n    }\n\n    static void setLastCorruptionException(Throwable ex) {\n        sLastCorruptionException.set(ex);\n    }\n\n    public static Throwable getLastCorruptionException() {\n        return sLastCorruptionException.get();\n    }\n\n\n    /**\n     * Dumps detailed information about all databases used by the process.\n     * @param printer The printer for dumping database state.\n     * @param args Command-line arguments supplied to dumpsys dbinfo\n     */\n    public static void dump(Printer printer, String[] args) {\n        boolean verbose = false;\n        for (String arg : args) {\n            if (arg.equals(\"-v\")) {\n                verbose = true;\n            }\n        }\n\n        SQLiteDatabase.dumpAll(printer, verbose);\n    }\n}\n"
  },
  {
    "path": "deprecated/android/wcdb/src/com/tencent/wcdb/database/SQLiteDirectCursor.java",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdb.database;\n\nimport com.tencent.wcdb.AbstractCursor;\nimport com.tencent.wcdb.Cursor;\nimport com.tencent.wcdb.support.CancellationSignal;\nimport com.tencent.wcdb.support.Log;\n\n\n/**\n * Cursor implementation that acts directly on the underlying SQLite statement\n * object.\n *\n * <p>Differ from the default implementation {@link SQLiteCursor}, which backed\n * with a linear buffer called CursorWindow, this implementation maps directly\n * to {@code sqlite3_stmt}, thus cost less memory and CPU time on certain situation.</p>\n */\npublic class SQLiteDirectCursor extends AbstractCursor {\n\n    private static final String TAG = \"WCDB.SQLiteDirectCursor\";\n\n\n    private final SQLiteDirectQuery mQuery;\n    private final SQLiteCursorDriver mDriver;\n    private final String[] mColumns;\n\n    private int mCount;\n    private boolean mCountFinished;\n\n    /**\n     * Execute a query and provide access to its result set through a Cursor\n     * interface. For a query such as: {@code SELECT name, birth, phone FROM\n     * myTable WHERE ... LIMIT 1,20 ORDER BY...} the column names (name, birth,\n     * phone) would be in the projection argument and everything from\n     * {@code FROM} onward would be in the params argument.\n     *\n     * @param editTable the name of the table used for this query\n     * @param query the {@link SQLiteDirectQuery} object associated with this cursor object.\n     */\n    public SQLiteDirectCursor(SQLiteCursorDriver driver, String editTable, SQLiteDirectQuery query) {\n        if (query == null) {\n            throw new IllegalArgumentException(\"query object cannot be null\");\n        }\n\n        mQuery = query;\n        mDriver = driver;\n        mColumns = query.getColumnNames();\n        mCount = -1;\n        mCountFinished = false;\n    }\n\n    @Override\n    public void close() {\n        super.close();\n\n        mQuery.close();\n        mDriver.cursorClosed();\n    }\n\n    @Override\n    public void deactivate() {\n        super.deactivate();\n        mDriver.cursorDeactivated();\n    }\n\n    @Override\n    public String[] getColumnNames() {\n        return mColumns;\n    }\n\n    @Override\n    public String getString(int column) {\n        return mQuery.getString(column);\n    }\n\n    @Override\n    public byte[] getBlob(int column) {\n        return mQuery.getBlob(column);\n    }\n\n    @Override\n    public short getShort(int column) {\n        return (short) mQuery.getLong(column);\n    }\n\n    @Override\n    public int getInt(int column) {\n        return (int) mQuery.getLong(column);\n    }\n\n    @Override\n    public long getLong(int column) {\n        return mQuery.getLong(column);\n    }\n\n    @Override\n    public float getFloat(int column) {\n        return (float) mQuery.getDouble(column);\n    }\n\n    @Override\n    public double getDouble(int column) {\n        return mQuery.getDouble(column);\n    }\n\n    @Override\n    public int getType(int column) {\n        return mQuery.getType(column);\n    }\n\n    @Override\n    public boolean isNull(int column) {\n        return getType(column) == FIELD_TYPE_NULL;\n    }\n\n    @Override\n    public boolean moveToPosition(int position) {\n        int actualPos;\n\n        if (position < 0) {\n            mQuery.reset(false);\n            mPos = -1;\n            return false;\n        }\n\n        if (mCountFinished && position >= mCount) {\n            mPos = mCount;\n            return false;\n        } else if (position < mPos) {\n            Log.w(TAG, \"Moving backward on SQLiteDirectCursor is slow. Get rid of backward movement \"\n                    + \"or use other implementations.\");\n\n            mQuery.reset(false);\n            actualPos = mQuery.step(position + 1) - 1;\n        } else if (position == mPos) {\n            return true;\n        } else { // position > mPos\n            actualPos = mPos + mQuery.step(position - mPos);\n        }\n\n        if (actualPos < position) {\n            // Returned position is smaller than requested. This is caused by reaching\n            // the end of the result, so we mark counting finished.\n            mCount = actualPos + 1;\n            mCountFinished = true;\n            mPos = mCount;\n        } else {\n            mPos = actualPos;\n            if (actualPos >= mCount) {\n                // We are not finished counting, update count accordingly.\n                mCount = actualPos + 1;\n                mCountFinished = false;\n            }\n        }\n\n        return mPos < mCount;\n    }\n\n    @Override\n    public int getCount() {\n        if (!mCountFinished) {\n            Log.w(TAG, \"Count query on SQLiteDirectCursor is slow. Iterate through the end to get count \" +\n                    \"or use other implementations.\");\n\n            int actualPos = mPos + mQuery.step(Integer.MAX_VALUE);\n            mCount = actualPos + 1;\n            mCountFinished = true;\n\n            mQuery.reset(false);\n\n            // Update mPos in case of data set changed during last query.\n            mPos = mQuery.step(mPos + 1) - 1;\n        }\n\n        return mCount;\n    }\n\n    @Override\n    public boolean requery() {\n        if (isClosed())\n            return false;\n\n        synchronized (this) {\n            if (!mQuery.getDatabase().isOpen())\n                return false;\n\n            mPos = -1;\n            mCountFinished = false;\n            mCount = -1;\n\n            mDriver.cursorRequeried(this);\n        }\n\n        mQuery.reset(false);\n\n        try {\n            return super.requery();\n        } catch (IllegalStateException e) {\n            // for backwards compatibility, just return false\n            Log.w(TAG, \"requery() failed \" + e.getMessage(), e);\n            return false;\n        }\n    }\n\n    /**\n     * Static factory object of {@link SQLiteDirectCursor}.\n     *\n     * Pass to {@link SQLiteDatabase#queryWithFactory(SQLiteDatabase.CursorFactory,\n     * boolean, String, String[], String, String[], String, String, String, String)}\n     * or {@link SQLiteDatabase#rawQueryWithFactory(SQLiteDatabase.CursorFactory, String,\n     * String[], String, CancellationSignal)} to get a cursor object of {@link SQLiteDirectCursor} .\n     */\n    public static final SQLiteDatabase.CursorFactory FACTORY = new SQLiteDatabase.CursorFactory() {\n        @Override\n        public Cursor newCursor(SQLiteDatabase db, SQLiteCursorDriver masterQuery,\n                String editTable, SQLiteProgram query) {\n            return new SQLiteDirectCursor(masterQuery, editTable, (SQLiteDirectQuery) query);\n        }\n\n        @Override\n        public SQLiteProgram newQuery(SQLiteDatabase db, String query, Object[] bindArgs,\n                CancellationSignal cancellationSignalForPrepare) {\n            return new SQLiteDirectQuery(db, query, bindArgs, cancellationSignalForPrepare);\n        }\n    };\n}\n"
  },
  {
    "path": "deprecated/android/wcdb/src/com/tencent/wcdb/database/SQLiteDirectCursorDriver.java",
    "content": "/*\n * Copyright (C) 2007 The Android Open Source Project\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdb.database;\n\nimport com.tencent.wcdb.Cursor;\nimport com.tencent.wcdb.database.SQLiteDatabase.CursorFactory;\nimport com.tencent.wcdb.support.CancellationSignal;\n\n/**\n * A cursor driver that uses the given query directly.\n * \n * @hide\n */\npublic final class SQLiteDirectCursorDriver implements SQLiteCursorDriver {\n    private final SQLiteDatabase mDatabase;\n    private final String mEditTable; \n    private final String mSql;\n    private final CancellationSignal mCancellationSignal;\n    private SQLiteProgram mQuery;\n\n    private static CursorFactory DEFAULT_FACTORY = SQLiteCursor.FACTORY;\n\n\n    public SQLiteDirectCursorDriver(SQLiteDatabase db, String sql, String editTable,\n            CancellationSignal cancellationSignal) {\n        mDatabase = db;\n        mEditTable = editTable;\n        mSql = sql;\n        mCancellationSignal = cancellationSignal;\n    }\n\n    public Cursor query(CursorFactory factory, Object[] bindArgs) {\n        if (factory == null)\n            factory = DEFAULT_FACTORY;\n\n        SQLiteProgram query = null;\n        final Cursor cursor;\n        try {\n            query = factory.newQuery(mDatabase, mSql, bindArgs, mCancellationSignal);\n            cursor = factory.newCursor(mDatabase, this, mEditTable, query);\n        } catch (RuntimeException ex) {\n            if (query != null)\n                query.close();\n            throw ex;\n        }\n\n        mQuery = query;\n        return cursor;\n    }\n\n    public void cursorClosed() {\n        // Do nothing\n    }\n\n    public void setBindArguments(String[] bindArgs) {\n        mQuery.bindAllArgsAsStrings(bindArgs);\n    }\n\n    public void cursorDeactivated() {\n        // Do nothing\n    }\n\n    public void cursorRequeried(Cursor cursor) {\n        // Do nothing\n    }\n\n    @Override\n    public String toString() {\n        return \"SQLiteDirectCursorDriver: \" + mSql;\n    }\n}\n"
  },
  {
    "path": "deprecated/android/wcdb/src/com/tencent/wcdb/database/SQLiteDirectQuery.java",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdb.database;\n\n\nimport com.tencent.wcdb.Cursor;\nimport com.tencent.wcdb.support.CancellationSignal;\nimport com.tencent.wcdb.support.Log;\n\n\n/**\n * Query class used by {@link SQLiteDirectCursor}.\n *\n * <p>This query implementation holds a database connection on the first time\n * calling {@link #step(int)}, until being closed or released.</p>\n *\n * @hide\n */\npublic class SQLiteDirectQuery extends SQLiteProgram {\n\n    private static final String TAG = \"WCDB.SQLiteDirectQuery\";\n\n    private final CancellationSignal mCancellationSignal;\n\n\n    public SQLiteDirectQuery(SQLiteDatabase db, String query, Object[] bindArgs, CancellationSignal cancellationSignal) {\n        super(db, query, bindArgs, cancellationSignal);\n        mCancellationSignal = cancellationSignal;\n    }\n\n    public long getLong(int column) {\n        return nativeGetLong(mPreparedStatement.getPtr(), column);\n    }\n\n    public double getDouble(int column) {\n        return nativeGetDouble(mPreparedStatement.getPtr(), column);\n    }\n\n    public String getString(int column) {\n        return nativeGetString(mPreparedStatement.getPtr(), column);\n    }\n\n    public byte[] getBlob(int column) {\n        return nativeGetBlob(mPreparedStatement.getPtr(), column);\n    }\n\n    public int getType(int column) {\n        return SQLITE_TYPE_MAPPING[nativeGetType(mPreparedStatement.getPtr(), column)];\n    }\n\n    public int step(int count) {\n        try {\n            if (acquirePreparedStatement(false)) {\n                mPreparedStatement.beginOperation(\"directQuery\", getBindArgs());\n                mPreparedStatement.attachCancellationSignal(mCancellationSignal);\n            }\n\n            return nativeStep(mPreparedStatement.getPtr(), count);\n        } catch (RuntimeException e) {\n            if (e instanceof SQLiteException) {\n                Log.e(TAG, \"Got exception on stepping: \" + e.getMessage() + \", SQL: \" + getSql());\n                checkCorruption((SQLiteException) e);\n            }\n\n            // Mark operation failed and release prepared statement.\n            if (mPreparedStatement != null) {\n                mPreparedStatement.detachCancellationSignal(mCancellationSignal);\n                mPreparedStatement.failOperation(e);\n            }\n            releasePreparedStatement();\n            throw e;\n        }\n    }\n\n    public synchronized void reset(boolean release) {\n        if (mPreparedStatement != null) {\n            mPreparedStatement.reset(false);\n\n            if (release) {\n                mPreparedStatement.detachCancellationSignal(mCancellationSignal);\n                mPreparedStatement.endOperation(null);\n                releasePreparedStatement();\n            }\n        }\n    }\n\n    @Override\n    protected void onAllReferencesReleased() {\n        synchronized (this) {\n            if (mPreparedStatement != null) {\n                mPreparedStatement.detachCancellationSignal(mCancellationSignal);\n                mPreparedStatement.endOperation(null);\n            }\n        }\n        super.onAllReferencesReleased();\n    }\n\n    private static final int[] SQLITE_TYPE_MAPPING = new int[] {\n            Cursor.FIELD_TYPE_STRING,      // 0, INVALID VALUE, default to STRING\n            Cursor.FIELD_TYPE_INTEGER,     // SQLITE_INTEGER = 1\n            Cursor.FIELD_TYPE_FLOAT,       // SQLITE_FLOAT = 2\n            Cursor.FIELD_TYPE_STRING,      // SQLITE_STRING = 3\n            Cursor.FIELD_TYPE_BLOB,        // SQLITE_BLOB = 4\n            Cursor.FIELD_TYPE_NULL         // SQLITE_NULL = 5\n    };\n\n    private static native long nativeGetLong(long statementPtr, int column);\n    private static native double nativeGetDouble(long statementPtr, int column);\n    private static native String nativeGetString(long statementPtr, int column);\n    private static native byte[] nativeGetBlob(long statementPtr, int column);\n    private static native int nativeGetType(long statementPtr, int column);\n    private static native int nativeStep(long statementPtr, int count);\n}\n"
  },
  {
    "path": "deprecated/android/wcdb/src/com/tencent/wcdb/database/SQLiteDiskIOException.java",
    "content": "/*\n * Copyright (C) 2006 The Android Open Source Project\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdb.database;\n\n/**\n * An exception that indicates that an IO error occured while accessing the \n * SQLite database file.\n */\n@SuppressWarnings(\"serial\")\npublic class SQLiteDiskIOException extends SQLiteException {\n    public SQLiteDiskIOException() {}\n\n    public SQLiteDiskIOException(String error) {\n        super(error);\n    }\n}\n"
  },
  {
    "path": "deprecated/android/wcdb/src/com/tencent/wcdb/database/SQLiteDoneException.java",
    "content": "/*\n * Copyright (C) 2008 The Android Open Source Project\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdb.database;\n\n/**\n * An exception that indicates that the SQLite program is done.\n * Thrown when an operation that expects a row (such as {@link\n * SQLiteStatement#simpleQueryForString} or {@link\n * SQLiteStatement#simpleQueryForLong}) does not get one.\n */\n@SuppressWarnings(\"serial\")\npublic class SQLiteDoneException extends SQLiteException {\n    public SQLiteDoneException() {}\n\n    public SQLiteDoneException(String error) {\n        super(error);\n    }\n}\n"
  },
  {
    "path": "deprecated/android/wcdb/src/com/tencent/wcdb/database/SQLiteException.java",
    "content": "/*\n * Copyright (C) 2006 The Android Open Source Project\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdb.database;\n\nimport com.tencent.wcdb.SQLException;\n\n/**\n * A SQLite exception that indicates there was an error with SQL parsing or execution.\n */\n@SuppressWarnings(\"serial\")\npublic class SQLiteException extends SQLException {\n    public SQLiteException() {\n    }\n\n    public SQLiteException(String error) {\n        super(error);\n    }\n\n    public SQLiteException(String error, Throwable cause) {\n        super(error, cause);\n    }\n}\n"
  },
  {
    "path": "deprecated/android/wcdb/src/com/tencent/wcdb/database/SQLiteFullException.java",
    "content": "/*\n * Copyright (C) 2008 The Android Open Source Project\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdb.database;\n\n/**\n * An exception that indicates that the SQLite database is full.\n */\n@SuppressWarnings(\"serial\")\npublic class SQLiteFullException extends SQLiteException {\n\t\n    public SQLiteFullException() {\n    }\n\n    public SQLiteFullException(String error) {\n        super(error);\n    }\n}\n"
  },
  {
    "path": "deprecated/android/wcdb/src/com/tencent/wcdb/database/SQLiteGlobal.java",
    "content": "/*\n * Copyright (C) 2011 The Android Open Source Project\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdb.database;\n\nimport android.os.Environment;\nimport android.os.StatFs;\n\n/**\n * Provides access to SQLite functions that affect all database connection,\n * such as memory management.\n *\n * The native code associated with SQLiteGlobal is also sets global configuration options\n * using sqlite3_config() then calls sqlite3_initialize() to ensure that the SQLite\n * library is properly initialized exactly once before any other framework or application\n * code has a chance to run.\n *\n * Verbose SQLite logging is enabled if the \"log.tag.SQLiteLog\" property is set to \"V\".\n * (per {@link SQLiteDebug#DEBUG_SQL_LOG}).\n *\n * @hide\n */\npublic final class SQLiteGlobal {\n    private static final String TAG = \"WCDB.SQLiteGlobal\";\n\n    private static native void nativeInitialize(int pageSize);\n    private static native int nativeReleaseMemory();\n\n    /** Default page size to use when creating a database. */\n    public static final int defaultPageSize;\n\n    /** Default journal mode when WAL is not in use. */\n    public static final String defaultJournalMode = \"PERSIST\";\n\n    /** Journal size limit in bytes. */\n    public static final int journalSizeLimit = 524288;  // 512 kB\n\n    /** Default database synchronization mode when WAL is not in use. */\n    public static final String defaultSyncMode = \"FULL\";\n\n    /** Database synchronization mode when in WAL mode. */\n    public static final String walSyncMode = \"FULL\";\n\n    /** WAL auto-checkpoint integer in database pages. */\n    public static final int walAutoCheckpoint = 100;\n\n    /** Connection pool size when in WAL mode. */\n    public static final int walConnectionPoolSize = 4;\n\n    static {\n        // Test if libwcdb.so is already loaded in other routines.\n        if (!WCDBInitializationProbe.libLoaded) {\n            System.loadLibrary(\"wcdb\");\n        }\n\n        int pageSize;\n        try {\n            String dataPath = Environment.getDataDirectory().getAbsolutePath();\n            pageSize = new StatFs(dataPath).getBlockSize();\n        } catch (RuntimeException e) {\n            pageSize = 4096;\n        }\n        defaultPageSize = pageSize;\n    }\n    // Dummy static method to trigger class initialization.\n    // See [JLS 12.4.1](http://docs.oracle.com/javase/specs/jls/se7/html/jls-12.html#jls-12.4.1)\n    public static void loadLib() {}\n    public static void initialize() {\n        Initializer.init();\n    }\n\n    private static class Initializer {\n        static {\n            nativeInitialize(defaultPageSize);\n        }\n        static void init() {}\n    }\n\n    private SQLiteGlobal() {}\n\n    /**\n     * Attempts to release memory by pruning the SQLite page cache and other\n     * internal data structures.\n     *\n     * @return The number of bytes that were freed.\n     */\n    public static int releaseMemory() {\n        return nativeReleaseMemory();\n    }\n}\n\n/**\n * Probe class to detect whether \"libwcdb.so\" is loaded.\n * It's set to true in JNI initialization routine.\n */\nfinal class WCDBInitializationProbe {\n    static boolean libLoaded = false;\n    static volatile long apiEnv = 0L;\n    private WCDBInitializationProbe() {}\n}\n"
  },
  {
    "path": "deprecated/android/wcdb/src/com/tencent/wcdb/database/SQLiteMisuseException.java",
    "content": "/*\n * Copyright (C) 2008 The Android Open Source Project\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdb.database;\n\n/**\n * This error can occur if the application creates a SQLiteStatement object and allows multiple\n * threads in the application use it at the same time.\n * <p>\n * SQLite returns this error if bind and execute methods on this object occur at the same time\n * from multiple threads, like so:<br>\n *     thread # 1: in {@code execute()} method of the {@link SQLiteStatement} object<br>\n *     while thread # 2: is in bind..() on the same object.<br>\n *</p>\n * <p>\n * FIX this by NEVER sharing the same {@link SQLiteStatement} object between threads.\n * Create a local instance of the SQLiteStatement whenever it is needed, use it and close it ASAP.\n * NEVER make it globally available.\n * </p>\n */\n@SuppressWarnings(\"serial\")\npublic class SQLiteMisuseException extends SQLiteException {\n    public SQLiteMisuseException() {}\n\n    public SQLiteMisuseException(String error) {\n        super(error);\n    }\n}\n"
  },
  {
    "path": "deprecated/android/wcdb/src/com/tencent/wcdb/database/SQLiteOpenHelper.java",
    "content": "/*\n * Copyright (C) 2007 The Android Open Source Project\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdb.database;\n\nimport com.tencent.wcdb.DatabaseErrorHandler;\nimport com.tencent.wcdb.database.SQLiteDatabase.CursorFactory;\nimport com.tencent.wcdb.support.Context;\n\nimport com.tencent.wcdb.support.Log;\n\n/**\n * A helper class to manage database creation and version management.\n * <p/>\n * <p>You create a subclass implementing {@link #onCreate}, {@link #onUpgrade} and\n * optionally {@link #onOpen}, and this class takes care of opening the database\n * if it exists, creating it if it does not, and upgrading it as necessary.\n * Transactions are used to make sure the database is always in a sensible state.\n * <p/>\n * <p>This class makes it easy for {@link android.content.ContentProvider}\n * implementations to defer opening and upgrading the database until first use,\n * to avoid blocking application startup with long-running database upgrades.\n * <p/>\n * <p>For an example, see the NotePadProvider class in the NotePad sample application,\n * in the <em>samples/</em> directory of the SDK.</p>\n * <p/>\n * <p class=\"note\"><strong>Note:</strong> this class assumes\n * monotonically increasing version numbers for upgrades.</p>\n */\npublic abstract class SQLiteOpenHelper {\n\n    private static final String TAG = \"WCDB.SQLiteOpenHelper\";\n\n    static {\n        // Ensure libwcdb.so is loaded.\n        SQLiteGlobal.initialize();\n    }\n\n    // When true, getReadableDatabase returns a read-only database if it is just being opened.\n    // The database handle is reopened in read/write mode when getWritableDatabase is called.\n    // We leave this behavior disabled in production because it is inefficient and breaks\n    // many applications.  For debugging purposes it can be useful to turn on strict\n    // read-only semantics to catch applications that call getReadableDatabase when they really\n    // wanted getWritableDatabase.\n    private static final boolean DEBUG_STRICT_READONLY = false;\n\n    private final android.content.Context mContext;\n    private final String mName;\n    private final CursorFactory mFactory;\n    private final int mNewVersion;\n\n    private SQLiteDatabase mDatabase;\n    private boolean mIsInitializing;\n    private boolean mEnableWriteAheadLogging;\n    private boolean mForcedSingleConnection;\n    private final DatabaseErrorHandler mErrorHandler;\n\n    private byte[] mPassword;\n    private SQLiteCipherSpec mCipher;\n    private int mMode;\n    private boolean mNeedMode;\n\n    /**\n     * Create a helper object to create, open, and/or manage a database.\n     * This method always returns very quickly.  The database is not actually\n     * created or opened until one of {@link #getWritableDatabase} or\n     * {@link #getReadableDatabase} is called.\n     *\n     * @param context to use to open or create the database\n     * @param name    of the database file, or null for an in-memory database\n     * @param factory to use for creating cursor objects, or null for the default\n     * @param version number of the database (starting at 1); if the database is older,\n     *                {@link #onUpgrade} will be used to upgrade the database; if the database is\n     *                newer, {@link #onDowngrade} will be used to downgrade the database\n     */\n    public SQLiteOpenHelper(android.content.Context context, String name, CursorFactory factory, int version) {\n        this(context, name, factory, version, null);\n    }\n\n    /**\n     * Create a helper object to create, open, and/or manage a database.\n     * The database is not actually created or opened until one of\n     * {@link #getWritableDatabase} or {@link #getReadableDatabase} is called.\n     * <p/>\n     * <p>Accepts input param: a concrete instance of {@link DatabaseErrorHandler} to be\n     * used to handle corruption when sqlite reports database corruption.</p>\n     *\n     * @param context      to use to open or create the database\n     * @param name         of the database file, or null for an in-memory database\n     * @param password     password to the encrypted database, or null for plain-text database\n     * @param cipher       cipher description, or null for default settings\n     * @param factory      to use for creating cursor objects, or null for the default\n     * @param version      number of the database (starting at 1); if the database is older,\n     *                     {@link #onUpgrade} will be used to upgrade the database; if the database is\n     *                     newer, {@link #onDowngrade} will be used to downgrade the database\n     * @param errorHandler the {@link DatabaseErrorHandler} to be used when sqlite reports database\n     *                     corruption, or null to use the default error handler.\n     */\n    public SQLiteOpenHelper(android.content.Context context, String name, byte[] password,\n            SQLiteCipherSpec cipher, CursorFactory factory, int version,\n            DatabaseErrorHandler errorHandler) {\n        if (version < 1) throw new IllegalArgumentException(\"Version must be >= 1, was \" + version);\n\n        mContext = context;\n        mName = name;\n        mFactory = factory;\n        mNewVersion = version;\n        mErrorHandler = errorHandler;\n        mPassword = password;\n        mCipher = (cipher == null) ? null : new SQLiteCipherSpec(cipher);\n        mNeedMode = false;\n    }\n\n    /**\n     * Create a helper object to create, open, and/or manage a database.\n     * The database is not actually created or opened until one of\n     * {@link #getWritableDatabase} or {@link #getReadableDatabase} is called.\n     * <p/>\n     * <p>Accepts input param: a concrete instance of {@link DatabaseErrorHandler} to be\n     * used to handle corruption when sqlite reports database corruption.</p>\n     *\n     * @param context      to use to open or create the database\n     * @param name         of the database file, or null for an in-memory database\n     * @param password     password for the encrypted database, or null for plain-text database\n     * @param factory      to use for creating cursor objects, or null for the default\n     * @param version      number of the database (starting at 1); if the database is older,\n     *                     {@link #onUpgrade} will be used to upgrade the database; if the database is\n     *                     newer, {@link #onDowngrade} will be used to downgrade the database\n     * @param errorHandler the {@link DatabaseErrorHandler} to be used when sqlite reports database\n     *                     corruption, or null to use the default error handler.\n     */\n    public SQLiteOpenHelper(android.content.Context context, String name, byte[] password,\n            CursorFactory factory, int version, DatabaseErrorHandler errorHandler) {\n        this(context, name, password, null, factory, version, errorHandler);\n    }\n\n    /**\n     * Create a helper object to create, open, and/or manage a database.\n     * The database is not actually created or opened until one of\n     * {@link #getWritableDatabase} or {@link #getReadableDatabase} is called.\n     * <p/>\n     * <p>Accepts input param: a concrete instance of {@link DatabaseErrorHandler} to be\n     * used to handle corruption when sqlite reports database corruption.</p>\n     *\n     * @param context      to use to open or create the database\n     * @param name         of the database file, or null for an in-memory database\n     * @param factory      to use for creating cursor objects, or null for the default\n     * @param version      number of the database (starting at 1); if the database is older,\n     *                     {@link #onUpgrade} will be used to upgrade the database; if the database is\n     *                     newer, {@link #onDowngrade} will be used to downgrade the database\n     * @param errorHandler the {@link DatabaseErrorHandler} to be used when sqlite reports database\n     *                     corruption, or null to use the default error handler.\n     */\n    public SQLiteOpenHelper(android.content.Context context, String name, CursorFactory factory, int version,\n            DatabaseErrorHandler errorHandler) {\n        this(context, name, null, null, factory, version, errorHandler);\n    }\n\n    /**\n     * Return the name of the SQLite database being opened, as given to\n     * the constructor.\n     */\n    public String getDatabaseName() {\n        return mName;\n    }\n\n    /**\n     * Enables or disables the use of write-ahead logging for the database.\n     * <p/>\n     * Write-ahead logging cannot be used with read-only databases so the value of\n     * this flag is ignored if the database is opened read-only.\n     *\n     * @param enabled True if write-ahead logging should be enabled, false if it\n     *                should be disabled.\n     * @see SQLiteDatabase#enableWriteAheadLogging()\n     */\n    public void setWriteAheadLoggingEnabled(boolean enabled) {\n        synchronized (this) {\n            if (mEnableWriteAheadLogging != enabled) {\n                if (mDatabase != null && mDatabase.isOpen() && !mDatabase.isReadOnly()) {\n                    if (enabled) {\n                        mDatabase.enableWriteAheadLogging();\n                    } else {\n                        mDatabase.disableWriteAheadLogging();\n                    }\n                }\n                mEnableWriteAheadLogging = enabled;\n            }\n        }\n    }\n\n    public void setForcedSingleConnection(boolean enabled) {\n        synchronized (this) {\n            mForcedSingleConnection = enabled;\n        }\n    }\n\n    /**\n     * Create and/or open a database that will be used for reading and writing.\n     * The first time this is called, the database will be opened and\n     * {@link #onCreate}, {@link #onUpgrade} and/or {@link #onOpen} will be\n     * called.\n     * <p/>\n     * <p>Once opened successfully, the database is cached, so you can\n     * call this method every time you need to write to the database.\n     * (Make sure to call {@link #close} when you no longer need the database.)\n     * Errors such as bad permissions or a full disk may cause this method\n     * to fail, but future attempts may succeed if the problem is fixed.</p>\n     * <p/>\n     * <p class=\"caution\">Database upgrade may take a long time, you\n     * should not call this method from the application main thread, including\n     * from {@link android.content.ContentProvider#onCreate ContentProvider.onCreate()}.\n     *\n     * @return a read/write database object valid until {@link #close} is called\n     * @throws SQLiteException if the database cannot be opened for writing\n     */\n    public SQLiteDatabase getWritableDatabase() {\n        synchronized (this) {\n            return getDatabaseLocked(true);\n        }\n    }\n\n    /**\n     * Create and/or open a database.  This will be the same object returned by\n     * {@link #getWritableDatabase} unless some problem, such as a full disk,\n     * requires the database to be opened read-only.  In that case, a read-only\n     * database object will be returned.  If the problem is fixed, a future call\n     * to {@link #getWritableDatabase} may succeed, in which case the read-only\n     * database object will be closed and the read/write object will be returned\n     * in the future.\n     * <p/>\n     * <p class=\"caution\">Like {@link #getWritableDatabase}, this method may\n     * take a long time to return, so you should not call it from the\n     * application main thread, including from\n     * {@link android.content.ContentProvider#onCreate ContentProvider.onCreate()}.\n     *\n     * @return a database object valid until {@link #getWritableDatabase}\n     * or {@link #close} is called.\n     * @throws SQLiteException if the database cannot be opened\n     */\n    public SQLiteDatabase getReadableDatabase() {\n        synchronized (this) {\n            return getDatabaseLocked(false);\n        }\n    }\n\n    @SuppressWarnings(\"unused\")\n    private SQLiteDatabase getDatabaseLocked(boolean writable) {\n        if (mDatabase != null) {\n            if (!mDatabase.isOpen()) {\n                // Darn!  The user closed the database by calling mDatabase.close().\n                mDatabase = null;\n            } else if (!writable || !mDatabase.isReadOnly()) {\n                // The database is already open for business.\n                return mDatabase;\n            }\n        }\n\n        if (mIsInitializing) {\n            throw new IllegalStateException(\"getDatabase called recursively\");\n        }\n\n        SQLiteDatabase db = mDatabase;\n        try {\n            mIsInitializing = true;\n\n            if (db != null) {\n                if (writable && db.isReadOnly()) {\n                    db.reopenReadWrite();\n                }\n            } else if (mName == null) {\n                db = SQLiteDatabase.create(null);\n            } else {\n                int connectionPoolSize = mForcedSingleConnection ? 1 : 0;\n                try {\n                    if (DEBUG_STRICT_READONLY && !writable) {\n                        final String path = mContext.getDatabasePath(mName).getPath();\n                        db = SQLiteDatabase.openDatabase(path, mPassword, mCipher, mFactory,\n                                SQLiteDatabase.OPEN_READONLY, mErrorHandler, connectionPoolSize);\n                    } else {\n                        mNeedMode = true;\n                        mMode = mEnableWriteAheadLogging ? Context.MODE_ENABLE_WRITE_AHEAD_LOGGING : 0;\n                        db = Context.openOrCreateDatabase(mContext, mName, mPassword, mCipher,\n                                mMode, mFactory, mErrorHandler, connectionPoolSize);\n                    }\n                } catch (SQLiteException ex) {\n                    if (writable) {\n                        throw ex;\n                    }\n                    Log.e(TAG, \"Couldn't open \" + mName\n                            + \" for writing (will try read-only):\", ex);\n                    final String path = mContext.getDatabasePath(mName).getPath();\n                    db = SQLiteDatabase.openDatabase(path, mPassword, mCipher, mFactory,\n                            SQLiteDatabase.OPEN_READONLY, mErrorHandler);\n                }\n            }\n\n            return getDatabaseLockedLast(db);\n\n        } finally {\n            mIsInitializing = false;\n            if (db != null && db != mDatabase) {\n                db.close();\n            }\n        }\n    }\n\n    private SQLiteDatabase getDatabaseLockedLast(SQLiteDatabase db) {\n        onConfigure(db);\n\n        final int version = db.getVersion();\n        if (version != mNewVersion) {\n            if (db.isReadOnly()) {\n                throw new SQLiteException(\"Can't upgrade read-only database from version \" +\n                        db.getVersion() + \" to \" + mNewVersion + \": \" + mName);\n            }\n\n            db.beginTransaction();\n            try {\n                if (version == 0) {\n                    onCreate(db);\n                } else {\n                    if (version > mNewVersion) {\n                        onDowngrade(db, version, mNewVersion);\n                    } else {\n                        onUpgrade(db, version, mNewVersion);\n                    }\n                }\n                db.setVersion(mNewVersion);\n                db.setTransactionSuccessful();\n            } finally {\n                db.endTransaction();\n            }\n        }\n\n        onOpen(db);\n\n        if (db.isReadOnly()) {\n            Log.w(TAG, \"Opened \" + mName + \" in read-only mode\");\n        }\n\n        mDatabase = db;\n        return db;\n    }\n\n    /**\n     * Close any open database object.\n     */\n    public synchronized void close() {\n        if (mIsInitializing) throw new IllegalStateException(\"Closed during initialization\");\n\n        if (mDatabase != null && mDatabase.isOpen()) {\n            mDatabase.close();\n            mDatabase = null;\n        }\n    }\n\n    /**\n     * Called when the database connection is being configured, to enable features\n     * such as write-ahead logging or foreign key support.\n     * <p>\n     * This method is called before {@link #onCreate}, {@link #onUpgrade},\n     * {@link #onDowngrade}, or {@link #onOpen} are called.  It should not modify\n     * the database except to configure the database connection as required.\n     * </p><p>\n     * This method should only call methods that configure the parameters of the\n     * database connection, such as {@link SQLiteDatabase#enableWriteAheadLogging}\n     * {@link SQLiteDatabase#setForeignKeyConstraintsEnabled},\n     * {@link SQLiteDatabase#setLocale}, {@link SQLiteDatabase#setMaximumSize},\n     * or executing PRAGMA statements.\n     * </p>\n     *\n     * @param db The database.\n     */\n    public void onConfigure(SQLiteDatabase db) {\n    }\n\n    /**\n     * Called when the database is created for the first time. This is where the\n     * creation of tables and the initial population of the tables should happen.\n     *\n     * @param db The database.\n     */\n    public abstract void onCreate(SQLiteDatabase db);\n\n    /**\n     * Called when the database needs to be upgraded. The implementation\n     * should use this method to drop tables, add tables, or do anything else it\n     * needs to upgrade to the new schema version.\n     * <p/>\n     * <p>\n     * The SQLite ALTER TABLE documentation can be found\n     * <a href=\"http://sqlite.org/lang_altertable.html\">here</a>. If you add new columns\n     * you can use ALTER TABLE to insert them into a live table. If you rename or remove columns\n     * you can use ALTER TABLE to rename the old table, then create the new table and then\n     * populate the new table with the contents of the old table.\n     * </p><p>\n     * This method executes within a transaction.  If an exception is thrown, all changes\n     * will automatically be rolled back.\n     * </p>\n     *\n     * @param db         The database.\n     * @param oldVersion The old database version.\n     * @param newVersion The new database version.\n     */\n    public abstract void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion);\n\n    /**\n     * Called when the database needs to be downgraded. This is strictly similar to\n     * {@link #onUpgrade} method, but is called whenever current version is newer than requested one.\n     * However, this method is not abstract, so it is not mandatory for a customer to\n     * implement it. If not overridden, default implementation will reject downgrade and\n     * throws SQLiteException\n     * <p/>\n     * <p>\n     * This method executes within a transaction.  If an exception is thrown, all changes\n     * will automatically be rolled back.\n     * </p>\n     *\n     * @param db         The database.\n     * @param oldVersion The old database version.\n     * @param newVersion The new database version.\n     */\n    public void onDowngrade(SQLiteDatabase db, int oldVersion, int newVersion) {\n        throw new SQLiteException(\"Can't downgrade database from version \" +\n                oldVersion + \" to \" + newVersion);\n    }\n\n    /**\n     * Called when the database has been opened.  The implementation\n     * should check {@link SQLiteDatabase#isReadOnly} before updating the\n     * database.\n     * <p>\n     * This method is called after the database connection has been configured\n     * and after the database schema has been created, upgraded or downgraded as necessary.\n     * If the database connection must be configured in some way before the schema\n     * is created, upgraded, or downgraded, do it in {@link #onConfigure} instead.\n     * </p>\n     *\n     * @param db The database.\n     */\n    public void onOpen(SQLiteDatabase db) {\n    }\n}\n"
  },
  {
    "path": "deprecated/android/wcdb/src/com/tencent/wcdb/database/SQLiteOutOfMemoryException.java",
    "content": "/*\n * Copyright (C) 2010 The Android Open Source Project\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdb.database;\n\n@SuppressWarnings(\"serial\")\npublic class SQLiteOutOfMemoryException extends SQLiteException {\n    public SQLiteOutOfMemoryException() {}\n\n    public SQLiteOutOfMemoryException(String error) {\n        super(error);\n    }\n}\n"
  },
  {
    "path": "deprecated/android/wcdb/src/com/tencent/wcdb/database/SQLiteProgram.java",
    "content": "/*\n * Copyright (C) 2006 The Android Open Source Project\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdb.database;\n\nimport java.util.Arrays;\n\nimport com.tencent.wcdb.DatabaseUtils;\nimport com.tencent.wcdb.support.CancellationSignal;\n\n/**\n * A base class for compiled SQLite programs.\n * <p>\n * This class is not thread-safe.\n * </p>\n */\npublic abstract class SQLiteProgram extends SQLiteClosable {\n    private static final String TAG = \"WCDB.SQLiteProgram\";\n    private static final String[] EMPTY_STRING_ARRAY = new String[0];\n\n    private final SQLiteDatabase mDatabase;\n    private final String mSql;\n    private final boolean mReadOnly;\n    private final String[] mColumnNames;\n    private final int mNumParameters;\n    private final Object[] mBindArgs;\n\n    protected SQLiteConnection.PreparedStatement mPreparedStatement;\n    private SQLiteSession mBoundSession;\n\n\n    protected SQLiteProgram(SQLiteDatabase db, String sql, Object[] bindArgs,\n            CancellationSignal cancellationSignalForPrepare) {\n        mDatabase = db;\n        mSql = sql.trim();\n\n        int n = DatabaseUtils.getSqlStatementType(mSql);\n        switch (n) {\n            case DatabaseUtils.STATEMENT_BEGIN:\n            case DatabaseUtils.STATEMENT_COMMIT:\n            case DatabaseUtils.STATEMENT_ABORT:\n                mReadOnly = false;\n                mColumnNames = EMPTY_STRING_ARRAY;\n                mNumParameters = 0;\n                break;\n\n            default:\n                boolean assumeReadOnly = (n == DatabaseUtils.STATEMENT_SELECT);\n                SQLiteStatementInfo info = new SQLiteStatementInfo();\n                db.getThreadSession().prepare(mSql,\n                        db.getThreadDefaultConnectionFlags(assumeReadOnly),\n                        cancellationSignalForPrepare, info);\n\n                // Always treat CREATE/DROP/ALTER statements as read-write.\n                // This fixes read-only exceptions while running CREATE xxx IF NOT EXISTS statements\n                // because we assume these statements to be read-write and prepare them using the\n                // primary connection but the results are read-only and run on non-primary connections.\n                // The non-primary connections may be using outdated cache and treat the statement as\n                // read-write.\n                mReadOnly = (n != DatabaseUtils.STATEMENT_DDL) && info.readOnly;\n                mColumnNames = info.columnNames;\n                mNumParameters = info.numParameters;\n                break;\n        }\n\n        if (bindArgs != null && bindArgs.length > mNumParameters) {\n            throw new IllegalArgumentException(\"Too many bind arguments.  \"\n                    + bindArgs.length + \" arguments were provided but the statement needs \"\n                    + mNumParameters + \" arguments.\");\n        }\n\n        if (mNumParameters != 0) {\n            mBindArgs = new Object[mNumParameters];\n            if (bindArgs != null) {\n                System.arraycopy(bindArgs, 0, mBindArgs, 0, bindArgs.length);\n            }\n        } else {\n            mBindArgs = null;\n        }\n\n        mPreparedStatement = null;\n        mBoundSession = null;\n    }\n\n    public final SQLiteDatabase getDatabase() {\n        return mDatabase;\n    }\n\n    protected final String getSql() {\n        return mSql;\n    }\n\n    protected final Object[] getBindArgs() {\n        return mBindArgs;\n    }\n\n    public final String[] getColumnNames() {\n        return mColumnNames;\n    }\n\n    /** @hide */\n    protected final SQLiteSession getSession() {\n        return mDatabase.getThreadSession();\n    }\n\n    /** @hide */\n    protected final int getConnectionFlags() {\n        return mDatabase.getThreadDefaultConnectionFlags(mReadOnly);\n    }\n\n    /** @hide */\n    protected final void checkCorruption(SQLiteException e) {\n        boolean isCorruption = false;\n        if (e instanceof SQLiteDatabaseCorruptException) {\n            isCorruption = true;\n        } else if (e instanceof SQLiteFullException) {\n            // When SQLite executing OP_Column opcode during SELECT or UPDATE statements,\n            // it may return SQLITE_FULL when trying to access unreachable pages.\n            // It's considered corruption on this scenario. We cannot distinguish such\n            // situation here, so we treat all SQLiteFullException thrown by a SELECT\n            // statement a signal on corruption.\n            if (mReadOnly) {\n                isCorruption = true;\n            }\n        }\n\n        if (isCorruption) {\n            SQLiteDebug.collectLastIOTraceStats(mDatabase);\n            SQLiteDebug.setLastCorruptionException(e);\n            mDatabase.onCorruption();\n        }\n    }\n\n    /**\n     * Unimplemented.\n     * @deprecated This method is deprecated and must not be used.\n     */\n    @Deprecated\n    public final int getUniqueId() {\n        return -1;\n    }\n\n    /**\n     * Bind a NULL value to this statement. The value remains bound until\n     * {@link #clearBindings} is called.\n     *\n     * @param index The 1-based index to the parameter to bind null to\n     */\n    public void bindNull(int index) {\n        bind(index, null);\n    }\n\n    /**\n     * Bind a long value to this statement. The value remains bound until\n     * {@link #clearBindings} is called.\n     *addToBindArgs\n     * @param index The 1-based index to the parameter to bind\n     * @param value The value to bind\n     */\n    public void bindLong(int index, long value) {\n        bind(index, value);\n    }\n\n    /**\n     * Bind a double value to this statement. The value remains bound until\n     * {@link #clearBindings} is called.\n     *\n     * @param index The 1-based index to the parameter to bind\n     * @param value The value to bind\n     */\n    public void bindDouble(int index, double value) {\n        bind(index, value);\n    }\n\n    /**\n     * Bind a String value to this statement. The value remains bound until\n     * {@link #clearBindings} is called.\n     *\n     * @param index The 1-based index to the parameter to bind\n     * @param value The value to bind, must not be null\n     */\n    public void bindString(int index, String value) {\n        if (value == null) {\n            throw new IllegalArgumentException(\"the bind value at index \" + index + \" is null\");\n        }\n        bind(index, value);\n    }\n\n    /**\n     * Bind a byte array value to this statement. The value remains bound until\n     * {@link #clearBindings} is called.\n     *\n     * @param index The 1-based index to the parameter to bind\n     * @param value The value to bind, must not be null\n     */\n    public void bindBlob(int index, byte[] value) {\n        if (value == null) {\n            throw new IllegalArgumentException(\"the bind value at index \" + index + \" is null\");\n        }\n        bind(index, value);\n    }\n\n    /**\n     * Clears all existing bindings. Unset bindings are treated as NULL.\n     */\n    public void clearBindings() {\n        if (mBindArgs != null) {\n            Arrays.fill(mBindArgs, null);\n        }\n    }\n\n    /**\n     * Given an array of String bindArgs, this method binds all of them in one single call.\n     *\n     * @param bindArgs the String array of bind args, none of which must be null.\n     */\n    public void bindAllArgsAsStrings(String[] bindArgs) {\n        if (bindArgs != null) {\n            for (int i = bindArgs.length; i != 0; i--) {\n                bindString(i, bindArgs[i - 1]);\n            }\n        }\n    }\n\n    public void bindAllArgs(Object[] bindArgs) {\n        for (int i = bindArgs.length; i != 0; i--) {\n            bind(i, bindArgs[i - 1]);\n        }\n    }\n\n    @Override\n    protected void onAllReferencesReleased() {\n        releasePreparedStatement();\n        clearBindings();\n    }\n\n    private void bind(int index, Object value) {\n        if (index < 1 || index > mNumParameters) {\n            throw new IllegalArgumentException(\"Cannot bind argument at index \"\n                    + index + \" because the index is out of range.  \"\n                    + \"The statement has \" + mNumParameters + \" parameters.\");\n        }\n        mBindArgs[index - 1] = value;\n    }\n\n    protected synchronized boolean acquirePreparedStatement(boolean persist) {\n        SQLiteSession session = mDatabase.getThreadSession();\n        if (session == mBoundSession)\n            return false;\n\n        if (mBoundSession != null) {\n            throw new IllegalStateException(\"SQLiteProgram has bound to another thread.\");\n        }\n\n        mPreparedStatement = session.acquirePreparedStatement(mSql,\n                mDatabase.getThreadDefaultConnectionFlags(mReadOnly), persist);\n        mPreparedStatement.bindArguments(mBindArgs);\n        mBoundSession = session;\n        return true;\n    }\n\n    protected synchronized void releasePreparedStatement() {\n        if (mBoundSession == null && mPreparedStatement == null)\n            return;\n\n        if (mBoundSession == null || mPreparedStatement == null) {\n            throw new IllegalStateException(\"Internal state error.\");\n        }\n\n        if (mBoundSession != mDatabase.getThreadSession()) {\n            throw new IllegalStateException(\"SQLiteProgram has bound to another thread.\");\n        }\n\n        mBoundSession.releasePreparedStatement(mPreparedStatement);\n        mPreparedStatement = null;\n        mBoundSession = null;\n    }\n\n    @Override\n    protected void finalize() throws Throwable {\n        synchronized (this) {\n            if (mBoundSession != null || mPreparedStatement != null)\n                throw new SQLiteMisuseException(\"Acquired prepared statement is not released.\");\n        }\n\n        super.finalize();\n    }\n}\n"
  },
  {
    "path": "deprecated/android/wcdb/src/com/tencent/wcdb/database/SQLiteQuery.java",
    "content": "/*\n * Copyright (C) 2006 The Android Open Source Project\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdb.database;\n\nimport com.tencent.wcdb.CursorWindow;\nimport com.tencent.wcdb.support.CancellationSignal;\nimport com.tencent.wcdb.support.OperationCanceledException;\n\nimport com.tencent.wcdb.support.Log;\n\n/**\n * Represents a query that reads the resulting rows into a {@link SQLiteQuery}.\n * This class is used by {@link SQLiteCursor} and isn't useful itself.\n * <p>\n * This class is not thread-safe.\n * </p>\n */\npublic final class SQLiteQuery extends SQLiteProgram {\n    private static final String TAG = \"WCDB.SQLiteQuery\";\n\n    private final CancellationSignal mCancellationSignal;\n\n    SQLiteQuery(SQLiteDatabase db, String query, Object[] bindArgs, CancellationSignal cancellationSignal) {\n        super(db, query, bindArgs, cancellationSignal);\n\n        mCancellationSignal = cancellationSignal;\n    }\n\n    /**\n     * Reads rows into a buffer.\n     *\n     * @param window The window to fill into\n     * @param startPos The start position for filling the window.\n     * @param requiredPos The position of a row that MUST be in the window.\n     * If it won't fit, then the query should discard part of what it filled.\n     * @param countAllRows True to count all rows that the query would\n     * return regardless of whether they fit in the window.\n     * @return Number of rows that were enumerated.  Might not be all rows\n     * unless countAllRows is true.\n     *\n     * @throws SQLiteException if an error occurs.\n     * @throws OperationCanceledException if the operation was canceled.\n     */\n    int fillWindow(CursorWindow window, int startPos, int requiredPos, boolean countAllRows) {\n        acquireReference();\n        try {\n            window.acquireReference();\n            try {\n                int numRows = getSession().executeForCursorWindow(getSql(), getBindArgs(),\n                        window, startPos, requiredPos, countAllRows, getConnectionFlags(),\n                        mCancellationSignal);\n                return numRows;\n            } catch (SQLiteException ex) {\n                Log.e(TAG, \"exception: \" + ex.getMessage() + \"; query: \" + getSql());\n                checkCorruption(ex);\n                throw ex;\n            } finally {\n                window.releaseReference();\n            }\n        } finally {\n            releaseReference();\n        }\n    }\n\n    @Override\n    public String toString() {\n        return \"SQLiteQuery: \" + getSql();\n    }\n}\n"
  },
  {
    "path": "deprecated/android/wcdb/src/com/tencent/wcdb/database/SQLiteQueryBuilder.java",
    "content": "/*\n * Copyright (C) 2006 The Android Open Source Project\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdb.database;\n\nimport android.provider.BaseColumns;\nimport android.text.TextUtils;\nimport com.tencent.wcdb.support.Log;\n\nimport java.util.Iterator;\nimport java.util.Map;\nimport java.util.Map.Entry;\nimport java.util.Set;\nimport java.util.regex.Pattern;\n\nimport com.tencent.wcdb.Cursor;\nimport com.tencent.wcdb.DatabaseUtils;\nimport com.tencent.wcdb.support.CancellationSignal;\nimport com.tencent.wcdb.support.OperationCanceledException;\n\n\n/**\n * This is a convience class that helps build SQL queries to be sent to\n * {@link SQLiteDatabase} objects.\n */\npublic class SQLiteQueryBuilder\n{\n    private static final String TAG = \"WCDB.SQLiteQueryBuilder\";\n    private static final Pattern sLimitPattern =\n            Pattern.compile(\"\\\\s*\\\\d+\\\\s*(,\\\\s*\\\\d+\\\\s*)?\");\n\n    private Map<String, String> mProjectionMap = null;\n    private String mTables = \"\";\n    private StringBuilder mWhereClause = null;  // lazily created\n    private boolean mDistinct;\n    private SQLiteDatabase.CursorFactory mFactory;\n    private boolean mStrict;\n\n    public SQLiteQueryBuilder() {\n        mDistinct = false;\n        mFactory = null;\n    }\n\n    /**\n     * Mark the query as DISTINCT.\n     *\n     * @param distinct if true the query is DISTINCT, otherwise it isn't\n     */\n    public void setDistinct(boolean distinct) {\n        mDistinct = distinct;\n    }\n\n    /**\n     * Returns the list of tables being queried\n     *\n     * @return the list of tables being queried\n     */\n    public String getTables() {\n        return mTables;\n    }\n\n    /**\n     * Sets the list of tables to query. Multiple tables can be specified to perform a join.\n     * For example:\n     *   setTables(\"foo, bar\")\n     *   setTables(\"foo LEFT OUTER JOIN bar ON (foo.id = bar.foo_id)\")\n     *\n     * @param inTables the list of tables to query on\n     */\n    public void setTables(String inTables) {\n        mTables = inTables;\n    }\n\n    /**\n     * Append a chunk to the WHERE clause of the query. All chunks appended are surrounded\n     * by parenthesis and ANDed with the selection passed to {@link #query}. The final\n     * WHERE clause looks like:\n     *\n     * WHERE (&lt;append chunk 1>&lt;append chunk2>) AND (&lt;query() selection parameter>)\n     *\n     * @param inWhere the chunk of text to append to the WHERE clause.\n     */\n    public void appendWhere(CharSequence inWhere) {\n        if (mWhereClause == null) {\n            mWhereClause = new StringBuilder(inWhere.length() + 16);\n        }\n        if (mWhereClause.length() == 0) {\n            mWhereClause.append('(');\n        }\n        mWhereClause.append(inWhere);\n    }\n\n    /**\n     * Append a chunk to the WHERE clause of the query. All chunks appended are surrounded\n     * by parenthesis and ANDed with the selection passed to {@link #query}. The final\n     * WHERE clause looks like:\n     *\n     * WHERE (&lt;append chunk 1>&lt;append chunk2>) AND (&lt;query() selection parameter>)\n     *\n     * @param inWhere the chunk of text to append to the WHERE clause. it will be escaped\n     * to avoid SQL injection attacks\n     */\n    public void appendWhereEscapeString(String inWhere) {\n        if (mWhereClause == null) {\n            mWhereClause = new StringBuilder(inWhere.length() + 16);\n        }\n        if (mWhereClause.length() == 0) {\n            mWhereClause.append('(');\n        }\n        DatabaseUtils.appendEscapedSQLString(mWhereClause, inWhere);\n    }\n\n    /**\n     * Sets the projection map for the query.  The projection map maps\n     * from column names that the caller passes into query to database\n     * column names. This is useful for renaming columns as well as\n     * disambiguating column names when doing joins. For example you\n     * could map \"name\" to \"people.name\".  If a projection map is set\n     * it must contain all column names the user may request, even if\n     * the key and value are the same.\n     *\n     * @param columnMap maps from the user column names to the database column names\n     */\n    public void setProjectionMap(Map<String, String> columnMap) {\n        mProjectionMap = columnMap;\n    }\n\n    /**\n     * Sets the cursor factory to be used for the query.  You can use\n     * one factory for all queries on a database but it is normally\n     * easier to specify the factory when doing this query.\n     *\n     * @param factory the factory to use.\n     */\n    public void setCursorFactory(SQLiteDatabase.CursorFactory factory) {\n        mFactory = factory;\n    }\n\n    /**\n     * When set, the selection is verified against malicious arguments.\n     * When using this class to create a statement using\n     * {@link #buildQueryString(boolean, String, String[], String, String, String, String, String)},\n     * non-numeric limits will raise an exception. If a projection map is specified, fields\n     * not in that map will be ignored.\n     * If this class is used to execute the statement directly using\n     * {@link #query(SQLiteDatabase, String[], String, String[], String, String, String)}\n     * or\n     * {@link #query(SQLiteDatabase, String[], String, String[], String, String, String, String)},\n     * additionally also parenthesis escaping selection are caught.\n     *\n     * To summarize: To get maximum protection against malicious third party apps (for example\n     * content provider consumers), make sure to do the following:\n     * <ul>\n     * <li>Set this value to true</li>\n     * <li>Use a projection map</li>\n     * <li>Use one of the query overloads instead of getting the statement as a sql string</li>\n     * </ul>\n     * By default, this value is false.\n     */\n    public void setStrict(boolean flag) {\n        mStrict = flag;\n    }\n\n    /**\n     * Build an SQL query string from the given clauses.\n     *\n     * @param distinct true if you want each row to be unique, false otherwise.\n     * @param tables The table names to compile the query against.\n     * @param columns A list of which columns to return. Passing null will\n     *            return all columns, which is discouraged to prevent reading\n     *            data from storage that isn't going to be used.\n     * @param where A filter declaring which rows to return, formatted as an SQL\n     *            WHERE clause (excluding the WHERE itself). Passing null will\n     *            return all rows for the given URL.\n     * @param groupBy A filter declaring how to group rows, formatted as an SQL\n     *            GROUP BY clause (excluding the GROUP BY itself). Passing null\n     *            will cause the rows to not be grouped.\n     * @param having A filter declare which row groups to include in the cursor,\n     *            if row grouping is being used, formatted as an SQL HAVING\n     *            clause (excluding the HAVING itself). Passing null will cause\n     *            all row groups to be included, and is required when row\n     *            grouping is not being used.\n     * @param orderBy How to order the rows, formatted as an SQL ORDER BY clause\n     *            (excluding the ORDER BY itself). Passing null will use the\n     *            default sort order, which may be unordered.\n     * @param limit Limits the number of rows returned by the query,\n     *            formatted as LIMIT clause. Passing null denotes no LIMIT clause.\n     * @return the SQL query string\n     */\n    public static String buildQueryString(\n            boolean distinct, String tables, String[] columns, String where,\n            String groupBy, String having, String orderBy, String limit) {\n        if (TextUtils.isEmpty(groupBy) && !TextUtils.isEmpty(having)) {\n            throw new IllegalArgumentException(\n                    \"HAVING clauses are only permitted when using a groupBy clause\");\n        }\n        if (!TextUtils.isEmpty(limit) && !sLimitPattern.matcher(limit).matches()) {\n            throw new IllegalArgumentException(\"invalid LIMIT clauses:\" + limit);\n        }\n\n        StringBuilder query = new StringBuilder(120);\n\n        query.append(\"SELECT \");\n        if (distinct) {\n            query.append(\"DISTINCT \");\n        }\n        if (columns != null && columns.length != 0) {\n            appendColumns(query, columns);\n        } else {\n            query.append(\"* \");\n        }\n        query.append(\"FROM \");\n        query.append(tables);\n        appendClause(query, \" WHERE \", where);\n        appendClause(query, \" GROUP BY \", groupBy);\n        appendClause(query, \" HAVING \", having);\n        appendClause(query, \" ORDER BY \", orderBy);\n        appendClause(query, \" LIMIT \", limit);\n\n        return query.toString();\n    }\n\n    private static void appendClause(StringBuilder s, String name, String clause) {\n        if (!TextUtils.isEmpty(clause)) {\n            s.append(name);\n            s.append(clause);\n        }\n    }\n\n    /**\n     * Add the names that are non-null in columns to s, separating\n     * them with commas.\n     */\n    public static void appendColumns(StringBuilder s, String[] columns) {\n        int n = columns.length;\n\n        for (int i = 0; i < n; i++) {\n            String column = columns[i];\n\n            if (column != null) {\n                if (i > 0) {\n                    s.append(\", \");\n                }\n                s.append(column);\n            }\n        }\n        s.append(' ');\n    }\n\n    /**\n     * Perform a query by combining all current settings and the\n     * information passed into this method.\n     *\n     * @param db the database to query on\n     * @param projectionIn A list of which columns to return. Passing\n     *   null will return all columns, which is discouraged to prevent\n     *   reading data from storage that isn't going to be used.\n     * @param selection A filter declaring which rows to return,\n     *   formatted as an SQL WHERE clause (excluding the WHERE\n     *   itself). Passing null will return all rows for the given URL.\n     * @param selectionArgs You may include ?s in selection, which\n     *   will be replaced by the values from selectionArgs, in order\n     *   that they appear in the selection. The values will be bound\n     *   as Strings.\n     * @param groupBy A filter declaring how to group rows, formatted\n     *   as an SQL GROUP BY clause (excluding the GROUP BY\n     *   itself). Passing null will cause the rows to not be grouped.\n     * @param having A filter declare which row groups to include in\n     *   the cursor, if row grouping is being used, formatted as an\n     *   SQL HAVING clause (excluding the HAVING itself).  Passing\n     *   null will cause all row groups to be included, and is\n     *   required when row grouping is not being used.\n     * @param sortOrder How to order the rows, formatted as an SQL\n     *   ORDER BY clause (excluding the ORDER BY itself). Passing null\n     *   will use the default sort order, which may be unordered.\n     * @return a cursor over the result set\n     * @see android.content.ContentResolver#query(android.net.Uri, String[],\n     *      String, String[], String)\n     */\n    public Cursor query(SQLiteDatabase db, String[] projectionIn,\n            String selection, String[] selectionArgs, String groupBy,\n            String having, String sortOrder) {\n        return query(db, projectionIn, selection, selectionArgs, groupBy, having, sortOrder,\n                null /* limit */, null /* cancellationSignal */);\n    }\n\n    /**\n     * Perform a query by combining all current settings and the\n     * information passed into this method.\n     *\n     * @param db the database to query on\n     * @param projectionIn A list of which columns to return. Passing\n     *   null will return all columns, which is discouraged to prevent\n     *   reading data from storage that isn't going to be used.\n     * @param selection A filter declaring which rows to return,\n     *   formatted as an SQL WHERE clause (excluding the WHERE\n     *   itself). Passing null will return all rows for the given URL.\n     * @param selectionArgs You may include ?s in selection, which\n     *   will be replaced by the values from selectionArgs, in order\n     *   that they appear in the selection. The values will be bound\n     *   as Strings.\n     * @param groupBy A filter declaring how to group rows, formatted\n     *   as an SQL GROUP BY clause (excluding the GROUP BY\n     *   itself). Passing null will cause the rows to not be grouped.\n     * @param having A filter declare which row groups to include in\n     *   the cursor, if row grouping is being used, formatted as an\n     *   SQL HAVING clause (excluding the HAVING itself).  Passing\n     *   null will cause all row groups to be included, and is\n     *   required when row grouping is not being used.\n     * @param sortOrder How to order the rows, formatted as an SQL\n     *   ORDER BY clause (excluding the ORDER BY itself). Passing null\n     *   will use the default sort order, which may be unordered.\n     * @param limit Limits the number of rows returned by the query,\n     *   formatted as LIMIT clause. Passing null denotes no LIMIT clause.\n     * @return a cursor over the result set\n     * @see android.content.ContentResolver#query(android.net.Uri, String[],\n     *      String, String[], String)\n     */\n    public Cursor query(SQLiteDatabase db, String[] projectionIn,\n            String selection, String[] selectionArgs, String groupBy,\n            String having, String sortOrder, String limit) {\n        return query(db, projectionIn, selection, selectionArgs,\n                groupBy, having, sortOrder, limit, null);\n    }\n\n    /**\n     * Perform a query by combining all current settings and the\n     * information passed into this method.\n     *\n     * @param db the database to query on\n     * @param projectionIn A list of which columns to return. Passing\n     *   null will return all columns, which is discouraged to prevent\n     *   reading data from storage that isn't going to be used.\n     * @param selection A filter declaring which rows to return,\n     *   formatted as an SQL WHERE clause (excluding the WHERE\n     *   itself). Passing null will return all rows for the given URL.\n     * @param selectionArgs You may include ?s in selection, which\n     *   will be replaced by the values from selectionArgs, in order\n     *   that they appear in the selection. The values will be bound\n     *   as Strings.\n     * @param groupBy A filter declaring how to group rows, formatted\n     *   as an SQL GROUP BY clause (excluding the GROUP BY\n     *   itself). Passing null will cause the rows to not be grouped.\n     * @param having A filter declare which row groups to include in\n     *   the cursor, if row grouping is being used, formatted as an\n     *   SQL HAVING clause (excluding the HAVING itself).  Passing\n     *   null will cause all row groups to be included, and is\n     *   required when row grouping is not being used.\n     * @param sortOrder How to order the rows, formatted as an SQL\n     *   ORDER BY clause (excluding the ORDER BY itself). Passing null\n     *   will use the default sort order, which may be unordered.\n     * @param limit Limits the number of rows returned by the query,\n     *   formatted as LIMIT clause. Passing null denotes no LIMIT clause.\n     * @param cancellationSignal A signal to cancel the operation in progress, or null if none.\n     * If the operation is canceled, then {@link OperationCanceledException} will be thrown\n     * when the query is executed.\n     * @return a cursor over the result set\n     * @see android.content.ContentResolver#query(android.net.Uri, String[],\n     *      String, String[], String)\n     */\n    public Cursor query(SQLiteDatabase db, String[] projectionIn,\n            String selection, String[] selectionArgs, String groupBy,\n            String having, String sortOrder, String limit, CancellationSignal cancellationSignal) {\n        if (mTables == null) {\n            return null;\n        }\n\n        if (mStrict && selection != null && selection.length() > 0) {\n            // Validate the user-supplied selection to detect syntactic anomalies\n            // in the selection string that could indicate a SQL injection attempt.\n            // The idea is to ensure that the selection clause is a valid SQL expression\n            // by compiling it twice: once wrapped in parentheses and once as\n            // originally specified. An attacker cannot create an expression that\n            // would escape the SQL expression while maintaining balanced parentheses\n            // in both the wrapped and original forms.\n            String sqlForValidation = buildQuery(projectionIn, \"(\" + selection + \")\", groupBy,\n                    having, sortOrder, limit);\n            validateQuerySql(db, sqlForValidation,\n                    cancellationSignal); // will throw if query is invalid\n        }\n\n        String sql = buildQuery(\n                projectionIn, selection, groupBy, having,\n                sortOrder, limit);\n\n//        if (Log.isLoggable(TAG, Log.DEBUG)) {\n            Log.d(TAG, \"Performing query: \" + sql);\n//        }\n        return db.rawQueryWithFactory(\n                mFactory, sql, selectionArgs,\n                SQLiteDatabase.findEditTable(mTables),\n                cancellationSignal); // will throw if query is invalid\n    }\n\n    /**\n     * Verifies that a SQL SELECT statement is valid by compiling it.\n     * If the SQL statement is not valid, this method will throw a {@link SQLiteException}.\n     */\n    private void validateQuerySql(SQLiteDatabase db, String sql,\n            CancellationSignal cancellationSignal) {\n        db.getThreadSession().prepare(sql,\n                db.getThreadDefaultConnectionFlags(true /*readOnly*/), cancellationSignal, null);\n    }\n\n    /**\n     * Construct a SELECT statement suitable for use in a group of\n     * SELECT statements that will be joined through UNION operators\n     * in buildUnionQuery.\n     *\n     * @param projectionIn A list of which columns to return. Passing\n     *    null will return all columns, which is discouraged to\n     *    prevent reading data from storage that isn't going to be\n     *    used.\n     * @param selection A filter declaring which rows to return,\n     *   formatted as an SQL WHERE clause (excluding the WHERE\n     *   itself).  Passing null will return all rows for the given\n     *   URL.\n     * @param groupBy A filter declaring how to group rows, formatted\n     *   as an SQL GROUP BY clause (excluding the GROUP BY itself).\n     *   Passing null will cause the rows to not be grouped.\n     * @param having A filter declare which row groups to include in\n     *   the cursor, if row grouping is being used, formatted as an\n     *   SQL HAVING clause (excluding the HAVING itself).  Passing\n     *   null will cause all row groups to be included, and is\n     *   required when row grouping is not being used.\n     * @param sortOrder How to order the rows, formatted as an SQL\n     *   ORDER BY clause (excluding the ORDER BY itself). Passing null\n     *   will use the default sort order, which may be unordered.\n     * @param limit Limits the number of rows returned by the query,\n     *   formatted as LIMIT clause. Passing null denotes no LIMIT clause.\n     * @return the resulting SQL SELECT statement\n     */\n    public String buildQuery(\n            String[] projectionIn, String selection, String groupBy,\n            String having, String sortOrder, String limit) {\n        String[] projection = computeProjection(projectionIn);\n\n        StringBuilder where = new StringBuilder();\n        boolean hasBaseWhereClause = mWhereClause != null && mWhereClause.length() > 0;\n\n        if (hasBaseWhereClause) {\n            where.append(mWhereClause.toString());\n            where.append(')');\n        }\n\n        // Tack on the user's selection, if present.\n        if (selection != null && selection.length() > 0) {\n            if (hasBaseWhereClause) {\n                where.append(\" AND \");\n            }\n\n            where.append('(');\n            where.append(selection);\n            where.append(')');\n        }\n\n        return buildQueryString(\n                mDistinct, mTables, projection, where.toString(),\n                groupBy, having, sortOrder, limit);\n    }\n\n    /**\n     * @deprecated This method's signature is misleading since no SQL parameter\n     * substitution is carried out.  The selection arguments parameter does not get\n     * used at all.  To avoid confusion, call\n     * {@link #buildQuery(String[], String, String, String, String, String)} instead.\n     */\n    @Deprecated\n    public String buildQuery(\n            String[] projectionIn, String selection, String[] selectionArgs,\n            String groupBy, String having, String sortOrder, String limit) {\n        return buildQuery(projectionIn, selection, groupBy, having, sortOrder, limit);\n    }\n\n    /**\n     * Construct a SELECT statement suitable for use in a group of\n     * SELECT statements that will be joined through UNION operators\n     * in buildUnionQuery.\n     *\n     * @param typeDiscriminatorColumn the name of the result column\n     *   whose cells will contain the name of the table from which\n     *   each row was drawn.\n     * @param unionColumns the names of the columns to appear in the\n     *   result.  This may include columns that do not appear in the\n     *   table this SELECT is querying (i.e. mTables), but that do\n     *   appear in one of the other tables in the UNION query that we\n     *   are constructing.\n     * @param columnsPresentInTable a Set of the names of the columns\n     *   that appear in this table (i.e. in the table whose name is\n     *   mTables).  Since columns in unionColumns include columns that\n     *   appear only in other tables, we use this array to distinguish\n     *   which ones actually are present.  Other columns will have\n     *   NULL values for results from this subquery.\n     * @param computedColumnsOffset all columns in unionColumns before\n     *   this index are included under the assumption that they're\n     *   computed and therefore won't appear in columnsPresentInTable,\n     *   e.g. \"date * 1000 as normalized_date\"\n     * @param typeDiscriminatorValue the value used for the\n     *   type-discriminator column in this subquery\n     * @param selection A filter declaring which rows to return,\n     *   formatted as an SQL WHERE clause (excluding the WHERE\n     *   itself).  Passing null will return all rows for the given\n     *   URL.\n     * @param groupBy A filter declaring how to group rows, formatted\n     *   as an SQL GROUP BY clause (excluding the GROUP BY itself).\n     *   Passing null will cause the rows to not be grouped.\n     * @param having A filter declare which row groups to include in\n     *   the cursor, if row grouping is being used, formatted as an\n     *   SQL HAVING clause (excluding the HAVING itself).  Passing\n     *   null will cause all row groups to be included, and is\n     *   required when row grouping is not being used.\n     * @return the resulting SQL SELECT statement\n     */\n    public String buildUnionSubQuery(\n            String typeDiscriminatorColumn,\n            String[] unionColumns,\n            Set<String> columnsPresentInTable,\n            int computedColumnsOffset,\n            String typeDiscriminatorValue,\n            String selection,\n            String groupBy,\n            String having) {\n        int unionColumnsCount = unionColumns.length;\n        String[] projectionIn = new String[unionColumnsCount];\n\n        for (int i = 0; i < unionColumnsCount; i++) {\n            String unionColumn = unionColumns[i];\n\n            if (unionColumn.equals(typeDiscriminatorColumn)) {\n                projectionIn[i] = \"'\" + typeDiscriminatorValue + \"' AS \"\n                        + typeDiscriminatorColumn;\n            } else if (i <= computedColumnsOffset\n                       || columnsPresentInTable.contains(unionColumn)) {\n                projectionIn[i] = unionColumn;\n            } else {\n                projectionIn[i] = \"NULL AS \" + unionColumn;\n            }\n        }\n        return buildQuery(\n                projectionIn, selection, groupBy, having,\n                null /* sortOrder */,\n                null /* limit */);\n    }\n\n    /**\n     * @deprecated This method's signature is misleading since no SQL parameter\n     * substitution is carried out.  The selection arguments parameter does not get\n     * used at all.  To avoid confusion, call\n     * {@link #buildUnionSubQuery}\n     * instead.\n     */\n    @Deprecated\n    public String buildUnionSubQuery(\n            String typeDiscriminatorColumn,\n            String[] unionColumns,\n            Set<String> columnsPresentInTable,\n            int computedColumnsOffset,\n            String typeDiscriminatorValue,\n            String selection,\n            String[] selectionArgs,\n            String groupBy,\n            String having) {\n        return buildUnionSubQuery(\n                typeDiscriminatorColumn, unionColumns, columnsPresentInTable,\n                computedColumnsOffset, typeDiscriminatorValue, selection,\n                groupBy, having);\n    }\n\n    /**\n     * Given a set of subqueries, all of which are SELECT statements,\n     * construct a query that returns the union of what those\n     * subqueries return.\n     * @param subQueries an array of SQL SELECT statements, all of\n     *   which must have the same columns as the same positions in\n     *   their results\n     * @param sortOrder How to order the rows, formatted as an SQL\n     *   ORDER BY clause (excluding the ORDER BY itself).  Passing\n     *   null will use the default sort order, which may be unordered.\n     * @param limit The limit clause, which applies to the entire union result set\n     *\n     * @return the resulting SQL SELECT statement\n     */\n    public String buildUnionQuery(String[] subQueries, String sortOrder, String limit) {\n        StringBuilder query = new StringBuilder(128);\n        int subQueryCount = subQueries.length;\n        String unionOperator = mDistinct ? \" UNION \" : \" UNION ALL \";\n\n        for (int i = 0; i < subQueryCount; i++) {\n            if (i > 0) {\n                query.append(unionOperator);\n            }\n            query.append(subQueries[i]);\n        }\n        appendClause(query, \" ORDER BY \", sortOrder);\n        appendClause(query, \" LIMIT \", limit);\n        return query.toString();\n    }\n\n    private String[] computeProjection(String[] projectionIn) {\n        if (projectionIn != null && projectionIn.length > 0) {\n            if (mProjectionMap != null) {\n                String[] projection = new String[projectionIn.length];\n                int length = projectionIn.length;\n\n                for (int i = 0; i < length; i++) {\n                    String userColumn = projectionIn[i];\n                    String column = mProjectionMap.get(userColumn);\n\n                    if (column != null) {\n                        projection[i] = column;\n                        continue;\n                    }\n\n                    if (!mStrict &&\n                            ( userColumn.contains(\" AS \") || userColumn.contains(\" as \"))) {\n                        /* A column alias already exist */\n                        projection[i] = userColumn;\n                        continue;\n                    }\n\n                    throw new IllegalArgumentException(\"Invalid column \"\n                            + projectionIn[i]);\n                }\n                return projection;\n            } else {\n                return projectionIn;\n            }\n        } else if (mProjectionMap != null) {\n            // Return all columns in projection map.\n            Set<Entry<String, String>> entrySet = mProjectionMap.entrySet();\n            String[] projection = new String[entrySet.size()];\n            Iterator<Entry<String, String>> entryIter = entrySet.iterator();\n            int i = 0;\n\n            while (entryIter.hasNext()) {\n                Entry<String, String> entry = entryIter.next();\n\n                // Don't include the _count column when people ask for no projection.\n                if (entry.getKey().equals(BaseColumns._COUNT)) {\n                    continue;\n                }\n                projection[i++] = entry.getValue();\n            }\n            return projection;\n        }\n        return null;\n    }\n}\n"
  },
  {
    "path": "deprecated/android/wcdb/src/com/tencent/wcdb/database/SQLiteReadOnlyDatabaseException.java",
    "content": "/*\n * Copyright (C) 2010 The Android Open Source Project\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdb.database;\n\n@SuppressWarnings(\"serial\")\npublic class SQLiteReadOnlyDatabaseException extends SQLiteException {\n    public SQLiteReadOnlyDatabaseException() {}\n\n    public SQLiteReadOnlyDatabaseException(String error) {\n        super(error);\n    }\n}\n"
  },
  {
    "path": "deprecated/android/wcdb/src/com/tencent/wcdb/database/SQLiteSession.java",
    "content": "/*\n * Copyright (C) 2011 The Android Open Source Project\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdb.database;\n\nimport android.database.sqlite.SQLiteTransactionListener;\nimport android.os.Process;\nimport android.util.Pair;\n\nimport com.tencent.wcdb.BuildConfig;\nimport com.tencent.wcdb.CursorWindow;\nimport com.tencent.wcdb.DatabaseUtils;\nimport com.tencent.wcdb.support.CancellationSignal;\nimport com.tencent.wcdb.support.OperationCanceledException;\n\n/**\n * Provides a single client the ability to use a database.\n * <p/>\n * <h2>About database sessions</h2>\n * <p>\n * Database access is always performed using a session.  The session\n * manages the lifecycle of transactions and database connections.\n * </p><p>\n * Sessions can be used to perform both read-only and read-write operations.\n * There is some advantage to knowing when a session is being used for\n * read-only purposes because the connection pool can optimize the use\n * of the available connections to permit multiple read-only operations\n * to execute in parallel whereas read-write operations may need to be serialized.\n * </p><p>\n * When <em>Write Ahead Logging (WAL)</em> is enabled, the database can\n * execute simultaneous read-only and read-write transactions, provided that\n * at most one read-write transaction is performed at a time.  When WAL is not\n * enabled, read-only transactions can execute in parallel but read-write\n * transactions are mutually exclusive.\n * </p>\n * <p/>\n * <h2>Ownership and concurrency guarantees</h2>\n * <p>\n * Session objects are not thread-safe.  In fact, session objects are thread-bound.\n * The {@link SQLiteDatabase} uses a thread-local variable to associate a session\n * with each thread for the use of that thread alone.  Consequently, each thread\n * has its own session object and therefore its own transaction state independent\n * of other threads.\n * </p><p>\n * A thread has at most one session per database.  This constraint ensures that\n * a thread can never use more than one database connection at a time for a\n * given database.  As the number of available database connections is limited,\n * if a single thread tried to acquire multiple connections for the same database\n * at the same time, it might deadlock.  Therefore we allow there to be only\n * one session (so, at most one connection) per thread per database.\n * </p>\n * <p/>\n * <h2>Transactions</h2>\n * <p>\n * There are two kinds of transaction: implicit transactions and explicit\n * transactions.\n * </p><p>\n * An implicit transaction is created whenever a database operation is requested\n * and there is no explicit transaction currently in progress.  An implicit transaction\n * only lasts for the duration of the database operation in question and then it\n * is ended.  If the database operation was successful, then its changes are committed.\n * </p><p>\n * An explicit transaction is started by calling {@link #beginTransaction} and\n * specifying the desired transaction mode.  Once an explicit transaction has begun,\n * all subsequent database operations will be performed as part of that transaction.\n * To end an explicit transaction, first call {@link #setTransactionSuccessful} if the\n * transaction was successful, then call {@link #endTransaction}.  If the transaction was\n * marked successful, its changes will be committed, otherwise they will be rolled back.\n * </p><p>\n * Explicit transactions can also be nested.  A nested explicit transaction is\n * started with {@link #beginTransaction}, marked successful with\n * {@link #setTransactionSuccessful}and ended with {@link #endTransaction}.\n * If any nested transaction is not marked successful, then the entire transaction\n * including all of its nested transactions will be rolled back\n * when the outermost transaction is ended.\n * </p><p>\n * To improve concurrency, an explicit transaction can be yielded by calling\n * {@link #yieldTransaction}.  If there is contention for use of the database,\n * then yielding ends the current transaction, commits its changes, releases the\n * database connection for use by another session for a little while, and starts a\n * new transaction with the same properties as the original one.\n * Changes committed by {@link #yieldTransaction} cannot be rolled back.\n * </p><p>\n * When a transaction is started, the client can provide a {@link SQLiteTransactionListener}\n * to listen for notifications of transaction-related events.\n * </p><p>\n * Recommended usage:\n * <code><pre>\n * // First, begin the transaction.\n * session.beginTransaction(SQLiteSession.TRANSACTION_MODE_DEFERRED, 0);\n * try {\n *     // Then do stuff...\n *     session.execute(\"INSERT INTO ...\", null, 0);\n * <p/>\n *     // As the very last step before ending the transaction, mark it successful.\n *     session.setTransactionSuccessful();\n * } finally {\n *     // Finally, end the transaction.\n *     // This statement will commit the transaction if it was marked successful or\n *     // roll it back otherwise.\n *     session.endTransaction();\n * }\n * </pre></code>\n * </p>\n * <p/>\n * <h2>Database connections</h2>\n * <p>\n * A {@link SQLiteDatabase} can have multiple active sessions at the same\n * time.  Each session acquires and releases connections to the database\n * as needed to perform each requested database transaction.  If all connections\n * are in use, then database transactions on some sessions will block until a\n * connection becomes available.\n * </p><p>\n * The session acquires a single database connection only for the duration\n * of a single (implicit or explicit) database transaction, then releases it.\n * This characteristic allows a small pool of database connections to be shared\n * efficiently by multiple sessions as long as they are not all trying to perform\n * database transactions at the same time.\n * </p>\n * <p/>\n * <h2>Responsiveness</h2>\n * <p>\n * Because there are a limited number of database connections and the session holds\n * a database connection for the entire duration of a database transaction,\n * it is important to keep transactions short.  This is especially important\n * for read-write transactions since they may block other transactions\n * from executing.  Consider calling {@link #yieldTransaction} periodically\n * during long-running transactions.\n * </p><p>\n * Another important consideration is that transactions that take too long to\n * run may cause the application UI to become unresponsive.  Even if the transaction\n * is executed in a background thread, the user will get bored and\n * frustrated if the application shows no data for several seconds while\n * a transaction runs.\n * </p><p>\n * Guidelines:\n * <ul>\n * <li>Do not perform database transactions on the UI thread.</li>\n * <li>Keep database transactions as short as possible.</li>\n * <li>Simple queries often run faster than complex queries.</li>\n * <li>Measure the performance of your database transactions.</li>\n * <li>Consider what will happen when the size of the data set grows.\n * A query that works well on 100 rows may struggle with 10,000.</li>\n * </ul>\n * <p/>\n * <h2>Reentrance</h2>\n * <p>\n * This class must tolerate reentrant execution of SQLite operations because\n * triggers may call custom SQLite functions that perform additional queries.\n * </p>\n *\n * @hide\n */\npublic final class SQLiteSession {\n    private final SQLiteConnectionPool mConnectionPool;\n\n    private SQLiteConnection mConnection;\n    private int mConnectionFlags;\n    private int mConnectionUseCount;\n    private Transaction mTransactionPool;\n    private Transaction mTransactionStack;\n\n    /**\n     * Transaction mode: Deferred.\n     * <p>\n     * In a deferred transaction, no locks are acquired on the database\n     * until the first operation is performed.  If the first operation is\n     * read-only, then a <code>SHARED</code> lock is acquired, otherwise\n     * a <code>RESERVED</code> lock is acquired.\n     * </p><p>\n     * While holding a <code>SHARED</code> lock, this session is only allowed to\n     * read but other sessions are allowed to read or write.\n     * While holding a <code>RESERVED</code> lock, this session is allowed to read\n     * or write but other sessions are only allowed to read.\n     * </p><p>\n     * Because the lock is only acquired when needed in a deferred transaction,\n     * it is possible for another session to write to the database first before\n     * this session has a chance to do anything.\n     * </p><p>\n     * Corresponds to the SQLite <code>BEGIN DEFERRED</code> transaction mode.\n     * </p>\n     */\n    public static final int TRANSACTION_MODE_DEFERRED = 0;\n\n    /**\n     * Transaction mode: Immediate.\n     * <p>\n     * When an immediate transaction begins, the session acquires a\n     * <code>RESERVED</code> lock.\n     * </p><p>\n     * While holding a <code>RESERVED</code> lock, this session is allowed to read\n     * or write but other sessions are only allowed to read.\n     * </p><p>\n     * Corresponds to the SQLite <code>BEGIN IMMEDIATE</code> transaction mode.\n     * </p>\n     */\n    public static final int TRANSACTION_MODE_IMMEDIATE = 1;\n\n    /**\n     * Transaction mode: Exclusive.\n     * <p>\n     * When an exclusive transaction begins, the session acquires an\n     * <code>EXCLUSIVE</code> lock.\n     * </p><p>\n     * While holding an <code>EXCLUSIVE</code> lock, this session is allowed to read\n     * or write but no other sessions are allowed to access the database.\n     * </p><p>\n     * Corresponds to the SQLite <code>BEGIN EXCLUSIVE</code> transaction mode.\n     * </p>\n     */\n    public static final int TRANSACTION_MODE_EXCLUSIVE = 2;\n\n    /**\n     * Creates a session bound to the specified connection pool.\n     *\n     * @param connectionPool The connection pool.\n     */\n    public SQLiteSession(SQLiteConnectionPool connectionPool) {\n        if (connectionPool == null) {\n            throw new IllegalArgumentException(\"connectionPool must not be null\");\n        }\n\n        mConnectionPool = connectionPool;\n    }\n\n    /**\n     * Returns true if the session has a transaction in progress.\n     *\n     * @return True if the session has a transaction in progress.\n     */\n    public boolean hasTransaction() {\n        return mTransactionStack != null;\n    }\n\n    /**\n     * Returns true if the session has a nested transaction in progress.\n     *\n     * @return True if the session has a nested transaction in progress.\n     */\n    public boolean hasNestedTransaction() {\n        return mTransactionStack != null && mTransactionStack.mParent != null;\n    }\n\n    /**\n     * Returns true if the session has an active database connection.\n     *\n     * @return True if the session has an active database connection.\n     */\n    public boolean hasConnection() {\n        return mConnection != null;\n    }\n\n    /**\n     * Begins a transaction.\n     * <p>\n     * Transactions may nest.  If the transaction is not in progress,\n     * then a database connection is obtained and a new transaction is started.\n     * Otherwise, a nested transaction is started.\n     * </p><p>\n     * Each call to {@link #beginTransaction} must be matched exactly by a call\n     * to {@link #endTransaction}.  To mark a transaction as successful,\n     * call {@link #setTransactionSuccessful} before calling {@link #endTransaction}.\n     * If the transaction is not successful, or if any of its nested\n     * transactions were not successful, then the entire transaction will\n     * be rolled back when the outermost transaction is ended.\n     * </p>\n     *\n     * @param transactionMode     The transaction mode.  One of: {@link #TRANSACTION_MODE_DEFERRED},\n     *                            {@link #TRANSACTION_MODE_IMMEDIATE}, or {@link #TRANSACTION_MODE_EXCLUSIVE}.\n     *                            Ignored when creating a nested transaction.\n     * @param transactionListener The transaction listener, or null if none.\n     * @param connectionFlags     The connection flags to use if a connection must be\n     *                            acquired by this operation.  Refer to {@link SQLiteConnectionPool}.\n     * @param cancellationSignal  A signal to cancel the operation in progress, or null if none.\n     * @throws IllegalStateException      if {@link #setTransactionSuccessful} has already been\n     *                                    called for the current transaction.\n     * @throws SQLiteException            if an error occurs.\n     * @throws OperationCanceledException if the operation was canceled.\n     * @see #setTransactionSuccessful\n     * @see #yieldTransaction\n     * @see #endTransaction\n     */\n    public void beginTransaction(int transactionMode,\n            SQLiteTransactionListener transactionListener, int connectionFlags,\n            CancellationSignal cancellationSignal) {\n        throwIfTransactionMarkedSuccessful();\n        beginTransactionUnchecked(transactionMode, transactionListener, connectionFlags,\n                cancellationSignal);\n    }\n\n    private void beginTransactionUnchecked(int transactionMode,\n                                           SQLiteTransactionListener transactionListener, int connectionFlags,\n                                           CancellationSignal cancellationSignal) {\n        if (cancellationSignal != null) {\n            cancellationSignal.throwIfCanceled();\n        }\n\n        if (mTransactionStack == null) {\n            acquireConnection(null, connectionFlags, true, cancellationSignal); // might throw\n        }\n        try {\n            // Set up the transaction such that we can back out safely\n            // in case we fail part way.\n            if (mTransactionStack == null) {\n                // Execute SQL might throw a runtime exception.\n                switch (transactionMode) {\n                    case TRANSACTION_MODE_IMMEDIATE:\n                        mConnection.execute(\"BEGIN IMMEDIATE;\", null,\n                                cancellationSignal); // might throw\n                        break;\n                    case TRANSACTION_MODE_EXCLUSIVE:\n                        mConnection.execute(\"BEGIN EXCLUSIVE;\", null,\n                                cancellationSignal); // might throw\n                        break;\n                    default:\n                        mConnection.execute(\"BEGIN;\", null, cancellationSignal); // might throw\n                        break;\n                }\n            }\n\n            // Listener might throw a runtime exception.\n            if (transactionListener != null) {\n                try {\n                    transactionListener.onBegin(); // might throw\n                } catch (RuntimeException ex) {\n                    if (mTransactionStack == null) {\n                        mConnection.execute(\"ROLLBACK;\", null, cancellationSignal); // might throw\n                    }\n                    throw ex;\n                }\n            }\n\n            // Bookkeeping can't throw, except an OOM, which is just too bad...\n            Transaction transaction = obtainTransaction(transactionMode, transactionListener);\n            transaction.mParent = mTransactionStack;\n            mTransactionStack = transaction;\n        } finally {\n            if (mTransactionStack == null) {\n                releaseConnection(); // might throw\n            }\n        }\n    }\n\n    /**\n     * Marks the current transaction as having completed successfully.\n     * <p>\n     * This method can be called at most once between {@link #beginTransaction} and\n     * {@link #endTransaction} to indicate that the changes made by the transaction should be\n     * committed.  If this method is not called, the changes will be rolled back\n     * when the transaction is ended.\n     * </p>\n     *\n     * @throws IllegalStateException if there is no current transaction, or if\n     *                               {@link #setTransactionSuccessful} has already been called for the current transaction.\n     * @see #beginTransaction\n     * @see #endTransaction\n     */\n    public void setTransactionSuccessful() {\n        throwIfNoTransaction();\n        throwIfTransactionMarkedSuccessful();\n\n        mTransactionStack.mMarkedSuccessful = true;\n    }\n\n    /**\n     * Ends the current transaction and commits or rolls back changes.\n     * <p>\n     * If this is the outermost transaction (not nested within any other\n     * transaction), then the changes are committed if {@link #setTransactionSuccessful}\n     * was called or rolled back otherwise.\n     * </p><p>\n     * This method must be called exactly once for each call to {@link #beginTransaction}.\n     * </p>\n     *\n     * @param cancellationSignal A signal to cancel the operation in progress, or null if none.\n     * @throws IllegalStateException      if there is no current transaction.\n     * @throws SQLiteException            if an error occurs.\n     * @throws OperationCanceledException if the operation was canceled.\n     * @see #beginTransaction\n     * @see #setTransactionSuccessful\n     * @see #yieldTransaction\n     */\n    public void endTransaction(CancellationSignal cancellationSignal) {\n        throwIfNoTransaction();\n        assert mConnection != null;\n\n        endTransactionUnchecked(cancellationSignal, false);\n    }\n\n    private void endTransactionUnchecked(CancellationSignal cancellationSignal, boolean yielding) {\n        if (cancellationSignal != null) {\n            cancellationSignal.throwIfCanceled();\n        }\n\n        final Transaction top = mTransactionStack;\n        boolean successful = (top.mMarkedSuccessful || yielding) && !top.mChildFailed;\n\n        RuntimeException listenerException = null;\n        final SQLiteTransactionListener listener = top.mListener;\n        if (listener != null) {\n            try {\n                if (successful) {\n                    listener.onCommit(); // might throw\n                } else {\n                    listener.onRollback(); // might throw\n                }\n            } catch (RuntimeException ex) {\n                listenerException = ex;\n                successful = false;\n            }\n        }\n\n        mTransactionStack = top.mParent;\n        recycleTransaction(top);\n\n        if (mTransactionStack != null) {\n            if (!successful) {\n                mTransactionStack.mChildFailed = true;\n            }\n        } else {\n            try {\n                if (successful) {\n                    mConnection.execute(\"COMMIT;\", null, cancellationSignal); // might throw\n                } else {\n                    mConnection.execute(\"ROLLBACK;\", null, cancellationSignal); // might throw\n                }\n            } finally {\n                releaseConnection(); // might throw\n            }\n        }\n\n        if (listenerException != null) {\n            throw listenerException;\n        }\n    }\n\n    /**\n     * Temporarily ends a transaction to let other threads have use of\n     * the database.  Begins a new transaction after a specified delay.\n     * <p>\n     * If there are other threads waiting to acquire connections,\n     * then the current transaction is committed and the database\n     * connection is released.  After a short delay, a new transaction\n     * is started.\n     * </p><p>\n     * The transaction is assumed to be successful so far.  Do not call\n     * {@link #setTransactionSuccessful()} before calling this method.\n     * This method will fail if the transaction has already been marked\n     * successful.\n     * </p><p>\n     * The changes that were committed by a yield cannot be rolled back later.\n     * </p><p>\n     * Before this method was called, there must already have been\n     * a transaction in progress.  When this method returns, there will\n     * still be a transaction in progress, either the same one as before\n     * or a new one if the transaction was actually yielded.\n     * </p><p>\n     * This method should not be called when there is a nested transaction\n     * in progress because it is not possible to yield a nested transaction.\n     * If <code>throwIfNested</code> is true, then attempting to yield\n     * a nested transaction will throw {@link IllegalStateException}, otherwise\n     * the method will return <code>false</code> in that case.\n     * </p><p>\n     * If there is no nested transaction in progress but a previous nested\n     * transaction failed, then the transaction is not yielded (because it\n     * must be rolled back) and this method returns <code>false</code>.\n     * </p>\n     *\n     * @param sleepAfterYieldDelayMillis A delay time to wait after yielding\n     *                                   the database connection to allow other threads some time to run.\n     *                                   If the value is less than or equal to zero, there will be no additional\n     *                                   delay beyond the time it will take to begin a new transaction.\n     * @param throwIfUnsafe              If true, then instead of returning false when no\n     *                                   transaction is in progress, a nested transaction is in progress, or when\n     *                                   the transaction has already been marked successful, throws {@link IllegalStateException}.\n     * @param cancellationSignal         A signal to cancel the operation in progress, or null if none.\n     * @return True if the transaction was actually yielded.\n     * @throws IllegalStateException      if <code>throwIfNested</code> is true and\n     *                                    there is no current transaction, there is a nested transaction in progress or\n     *                                    if {@link #setTransactionSuccessful} has already been called for the current transaction.\n     * @throws SQLiteException            if an error occurs.\n     * @throws OperationCanceledException if the operation was canceled.\n     * @see #beginTransaction\n     * @see #endTransaction\n     */\n    public boolean yieldTransaction(long sleepAfterYieldDelayMillis, boolean throwIfUnsafe,\n            CancellationSignal cancellationSignal) {\n        if (throwIfUnsafe) {\n            throwIfNoTransaction();\n            throwIfTransactionMarkedSuccessful();\n            throwIfNestedTransaction();\n        } else {\n            if (mTransactionStack == null || mTransactionStack.mMarkedSuccessful\n                    || mTransactionStack.mParent != null) {\n                return false;\n            }\n        }\n        assert mConnection != null;\n\n        if (mTransactionStack.mChildFailed) {\n            return false;\n        }\n\n        return yieldTransactionUnchecked(sleepAfterYieldDelayMillis,\n                cancellationSignal); // might throw\n    }\n\n    private boolean yieldTransactionUnchecked(long sleepAfterYieldDelayMillis,\n            CancellationSignal cancellationSignal) {\n        if (cancellationSignal != null) {\n            cancellationSignal.throwIfCanceled();\n        }\n\n        if (!mConnectionPool.shouldYieldConnection(mConnection, mConnectionFlags)) {\n            return false;\n        }\n\n        final int transactionMode = mTransactionStack.mMode;\n        final SQLiteTransactionListener listener = mTransactionStack.mListener;\n        final int connectionFlags = mConnectionFlags;\n        endTransactionUnchecked(cancellationSignal, true); // might throw\n\n        if (sleepAfterYieldDelayMillis > 0) {\n            try {\n                Thread.sleep(sleepAfterYieldDelayMillis);\n            } catch (InterruptedException ex) {\n                // we have been interrupted, that's all we need to do\n            }\n        }\n\n        beginTransactionUnchecked(transactionMode, listener, connectionFlags,\n                cancellationSignal); // might throw\n        return true;\n    }\n\n    /**\n     * Prepares a statement for execution but does not bind its parameters or execute it.\n     * <p>\n     * This method can be used to check for syntax errors during compilation\n     * prior to execution of the statement.  If the {@code outStatementInfo} argument\n     * is not null, the provided {@link SQLiteStatementInfo} object is populated\n     * with information about the statement.\n     * </p><p>\n     * A prepared statement makes no reference to the arguments that may eventually\n     * be bound to it, consequently it it possible to cache certain prepared statements\n     * such as SELECT or INSERT/UPDATE statements.  If the statement is cacheable,\n     * then it will be stored in the cache for later and reused if possible.\n     * </p>\n     *\n     * @param sql                The SQL statement to prepare.\n     * @param connectionFlags    The connection flags to use if a connection must be\n     *                           acquired by this operation.  Refer to {@link SQLiteConnectionPool}.\n     * @param cancellationSignal A signal to cancel the operation in progress, or null if none.\n     * @param outStatementInfo   The {@link SQLiteStatementInfo} object to populate\n     *                           with information about the statement, or null if none.\n     * @throws SQLiteException            if an error occurs, such as a syntax error.\n     * @throws OperationCanceledException if the operation was canceled.\n     */\n    public void prepare(String sql, int connectionFlags, CancellationSignal cancellationSignal,\n            SQLiteStatementInfo outStatementInfo) {\n        if (sql == null) {\n            throw new IllegalArgumentException(\"sql must not be null.\");\n        }\n\n        if (cancellationSignal != null) {\n            cancellationSignal.throwIfCanceled();\n        }\n\n        acquireConnection(sql, connectionFlags, false, cancellationSignal); // might throw\n        try {\n            mConnection.prepare(sql, outStatementInfo); // might throw\n        } finally {\n            releaseConnection(); // might throw\n        }\n    }\n\n\n    /**\n     * Executes a statement that does not return a result.\n     *\n     * @param sql                The SQL statement to execute.\n     * @param bindArgs           The arguments to bind, or null if none.\n     * @param connectionFlags    The connection flags to use if a connection must be\n     *                           acquired by this operation.  Refer to {@link SQLiteConnectionPool}.\n     * @param cancellationSignal A signal to cancel the operation in progress, or null if none.\n     * @throws SQLiteException            if an error occurs, such as a syntax error\n     *                                    or invalid number of bind arguments.\n     * @throws OperationCanceledException if the operation was canceled.\n     */\n    public void execute(String sql, Object[] bindArgs, int connectionFlags,\n            CancellationSignal cancellationSignal) {\n        if (sql == null) {\n            throw new IllegalArgumentException(\"sql must not be null.\");\n        }\n\n        if (executeSpecial(sql, bindArgs, connectionFlags, cancellationSignal)) {\n            return;\n        }\n\n        acquireConnection(sql, connectionFlags, false, cancellationSignal); // might throw\n        try {\n            mConnection.execute(sql, bindArgs, cancellationSignal); // might throw\n        } finally {\n            releaseConnection(); // might throw\n        }\n    }\n\n    /**\n     * Executes a statement that returns a single <code>long</code> result.\n     *\n     * @param sql                The SQL statement to execute.\n     * @param bindArgs           The arguments to bind, or null if none.\n     * @param connectionFlags    The connection flags to use if a connection must be\n     *                           acquired by this operation.  Refer to {@link SQLiteConnectionPool}.\n     * @param cancellationSignal A signal to cancel the operation in progress, or null if none.\n     * @return The value of the first column in the first row of the result set\n     * as a <code>long</code>, or zero if none.\n     * @throws SQLiteException            if an error occurs, such as a syntax error\n     *                                    or invalid number of bind arguments.\n     * @throws OperationCanceledException if the operation was canceled.\n     */\n    public long executeForLong(String sql, Object[] bindArgs, int connectionFlags,\n            CancellationSignal cancellationSignal) {\n        if (sql == null) {\n            throw new IllegalArgumentException(\"sql must not be null.\");\n        }\n\n        if (executeSpecial(sql, bindArgs, connectionFlags, cancellationSignal)) {\n            return 0;\n        }\n\n        acquireConnection(sql, connectionFlags, false, cancellationSignal); // might throw\n        try {\n            return mConnection.executeForLong(sql, bindArgs, cancellationSignal); // might throw\n        } finally {\n            releaseConnection(); // might throw\n        }\n    }\n\n    /**\n     * Executes a statement that returns a single {@link String} result.\n     *\n     * @param sql                The SQL statement to execute.\n     * @param bindArgs           The arguments to bind, or null if none.\n     * @param connectionFlags    The connection flags to use if a connection must be\n     *                           acquired by this operation.  Refer to {@link SQLiteConnectionPool}.\n     * @param cancellationSignal A signal to cancel the operation in progress, or null if none.\n     * @return The value of the first column in the first row of the result set\n     * as a <code>String</code>, or null if none.\n     * @throws SQLiteException            if an error occurs, such as a syntax error\n     *                                    or invalid number of bind arguments.\n     * @throws OperationCanceledException if the operation was canceled.\n     */\n    public String executeForString(String sql, Object[] bindArgs, int connectionFlags,\n            CancellationSignal cancellationSignal) {\n        if (sql == null) {\n            throw new IllegalArgumentException(\"sql must not be null.\");\n        }\n\n        if (executeSpecial(sql, bindArgs, connectionFlags, cancellationSignal)) {\n            return null;\n        }\n\n        acquireConnection(sql, connectionFlags, false, cancellationSignal); // might throw\n        try {\n            return mConnection.executeForString(sql, bindArgs, cancellationSignal); // might throw\n        } finally {\n            releaseConnection(); // might throw\n        }\n    }\n\n    /**\n     * Executes a statement that returns a count of the number of rows\n     * that were changed.  Use for UPDATE or DELETE SQL statements.\n     *\n     * @param sql                The SQL statement to execute.\n     * @param bindArgs           The arguments to bind, or null if none.\n     * @param connectionFlags    The connection flags to use if a connection must be\n     *                           acquired by this operation.  Refer to {@link SQLiteConnectionPool}.\n     * @param cancellationSignal A signal to cancel the operation in progress, or null if none.\n     * @return The number of rows that were changed.\n     * @throws SQLiteException            if an error occurs, such as a syntax error\n     *                                    or invalid number of bind arguments.\n     * @throws OperationCanceledException if the operation was canceled.\n     */\n    public int executeForChangedRowCount(String sql, Object[] bindArgs, int connectionFlags,\n            CancellationSignal cancellationSignal) {\n        if (sql == null) {\n            throw new IllegalArgumentException(\"sql must not be null.\");\n        }\n\n        if (executeSpecial(sql, bindArgs, connectionFlags, cancellationSignal)) {\n            return 0;\n        }\n\n        acquireConnection(sql, connectionFlags, false, cancellationSignal); // might throw\n        try {\n            return mConnection.executeForChangedRowCount(sql, bindArgs,\n                    cancellationSignal); // might throw\n        } finally {\n            releaseConnection(); // might throw\n        }\n    }\n\n    /**\n     * Executes a statement that returns the row id of the last row inserted\n     * by the statement.  Use for INSERT SQL statements.\n     *\n     * @param sql                The SQL statement to execute.\n     * @param bindArgs           The arguments to bind, or null if none.\n     * @param connectionFlags    The connection flags to use if a connection must be\n     *                           acquired by this operation.  Refer to {@link SQLiteConnectionPool}.\n     * @param cancellationSignal A signal to cancel the operation in progress, or null if none.\n     * @return The row id of the last row that was inserted, or 0 if none.\n     * @throws SQLiteException            if an error occurs, such as a syntax error\n     *                                    or invalid number of bind arguments.\n     * @throws OperationCanceledException if the operation was canceled.\n     */\n    public long executeForLastInsertedRowId(String sql, Object[] bindArgs, int connectionFlags,\n            CancellationSignal cancellationSignal) {\n        if (sql == null) {\n            throw new IllegalArgumentException(\"sql must not be null.\");\n        }\n\n        if (executeSpecial(sql, bindArgs, connectionFlags, cancellationSignal)) {\n            return 0;\n        }\n\n        acquireConnection(sql, connectionFlags, false, cancellationSignal); // might throw\n        try {\n            return mConnection.executeForLastInsertedRowId(sql, bindArgs,\n                    cancellationSignal); // might throw\n        } finally {\n            releaseConnection(); // might throw\n        }\n    }\n\n    /**\n     * Executes a statement and populates the specified {@link CursorWindow}\n     * with a range of results.  Returns the number of rows that were counted\n     * during query execution.\n     *\n     * @param sql                The SQL statement to execute.\n     * @param bindArgs           The arguments to bind, or null if none.\n     * @param window             The cursor window to clear and fill.\n     * @param startPos           The start position for filling the window.\n     * @param requiredPos        The position of a row that MUST be in the window.\n     *                           If it won't fit, then the query should discard part of what it filled\n     *                           so that it does.  Must be greater than or equal to <code>startPos</code>.\n     * @param countAllRows       True to count all rows that the query would return\n     *                           regagless of whether they fit in the window.\n     * @param connectionFlags    The connection flags to use if a connection must be\n     *                           acquired by this operation.  Refer to {@link SQLiteConnectionPool}.\n     * @param cancellationSignal A signal to cancel the operation in progress, or null if none.\n     * @return The number of rows that were counted during query execution.  Might\n     * not be all rows in the result set unless <code>countAllRows</code> is true.\n     * @throws SQLiteException            if an error occurs, such as a syntax error\n     *                                    or invalid number of bind arguments.\n     * @throws OperationCanceledException if the operation was canceled.\n     */\n    public int executeForCursorWindow(String sql, Object[] bindArgs,\n            CursorWindow window, int startPos, int requiredPos, boolean countAllRows,\n            int connectionFlags, CancellationSignal cancellationSignal) {\n        if (sql == null) {\n            throw new IllegalArgumentException(\"sql must not be null.\");\n        }\n        if (window == null) {\n            throw new IllegalArgumentException(\"window must not be null.\");\n        }\n\n        if (executeSpecial(sql, bindArgs, connectionFlags, cancellationSignal)) {\n            window.clear();\n            return 0;\n        }\n\n        acquireConnection(sql, connectionFlags, false, cancellationSignal); // might throw\n        try {\n            return mConnection.executeForCursorWindow(sql, bindArgs,\n                    window, startPos, requiredPos, countAllRows,\n                    cancellationSignal); // might throw\n        } finally {\n            releaseConnection(); // might throw\n        }\n    }\n\n    public Pair<Integer, Integer> walCheckpoint(String dbName, int connectionFlags) {\n        acquireConnection(null, connectionFlags, false, null);\n        try {\n            return mConnection.walCheckpoint(dbName);\n        } finally {\n            releaseConnection();\n        }\n    }\n\n\n    /**\n     * Performs special reinterpretation of certain SQL statements such as \"BEGIN\",\n     * \"COMMIT\" and \"ROLLBACK\" to ensure that transaction state invariants are\n     * maintained.\n     * <p/>\n     * This function is mainly used to support legacy apps that perform their\n     * own transactions by executing raw SQL rather than calling {@link #beginTransaction}\n     * and the like.\n     *\n     * @param sql                The SQL statement to execute.\n     * @param bindArgs           The arguments to bind, or null if none.\n     * @param connectionFlags    The connection flags to use if a connection must be\n     *                           acquired by this operation.  Refer to {@link SQLiteConnectionPool}.\n     * @param cancellationSignal A signal to cancel the operation in progress, or null if none.\n     * @return True if the statement was of a special form that was handled here,\n     * false otherwise.\n     * @throws SQLiteException            if an error occurs, such as a syntax error\n     *                                    or invalid number of bind arguments.\n     * @throws OperationCanceledException if the operation was canceled.\n     */\n    private boolean executeSpecial(String sql, Object[] bindArgs, int connectionFlags,\n            CancellationSignal cancellationSignal) {\n        if (cancellationSignal != null) {\n            cancellationSignal.throwIfCanceled();\n        }\n\n        final int type = DatabaseUtils.getSqlStatementType(sql);\n        switch (type) {\n            case DatabaseUtils.STATEMENT_BEGIN:\n                beginTransaction(TRANSACTION_MODE_EXCLUSIVE, null, connectionFlags,\n                        cancellationSignal);\n                return true;\n\n            case DatabaseUtils.STATEMENT_COMMIT:\n                setTransactionSuccessful();\n                endTransaction(cancellationSignal);\n                return true;\n\n            case DatabaseUtils.STATEMENT_ABORT:\n                endTransaction(cancellationSignal);\n                return true;\n        }\n        return false;\n    }\n\n    private void acquireConnection(String sql, int connectionFlags, boolean persist,\n            CancellationSignal cancellationSignal) {\n        if (mConnection == null) {\n            if (BuildConfig.DEBUG && !(mConnectionUseCount == 0))\n                throw new AssertionError(\"mConnectionUseCount == 0\");\n            mConnection = mConnectionPool.acquireConnection(sql, connectionFlags,\n                    cancellationSignal); // might throw\n            mConnectionFlags = connectionFlags;\n            mConnection.setAcquisitionState(true, persist);\n        }\n        mConnectionUseCount += 1;\n    }\n\n    private void releaseConnection() {\n        if (BuildConfig.DEBUG && !(mConnection != null && mConnectionUseCount > 0))\n            throw new AssertionError(\"mConnection != null && mConnectionUseCount > 0\");\n        if (--mConnectionUseCount == 0) {\n            try {\n                mConnection.setAcquisitionState(false, false);\n                mConnectionPool.releaseConnection(mConnection); // might throw\n            } finally {\n                mConnection = null;\n            }\n        }\n    }\n\n    /*package*/ SQLiteConnection acquireConnectionForNativeHandle(int connectionFlags) {\n        acquireConnection(null, connectionFlags, true, null);\n        return mConnection;\n    }\n\n    /*package*/ void releaseConnectionForNativeHandle(Exception ex) {\n        try {\n            if (mConnection != null) {\n                mConnection.endNativeHandle(ex);\n            }\n        } finally {\n            releaseConnection();\n        }\n    }\n\n    /*package*/ SQLiteConnection.PreparedStatement acquirePreparedStatement(String sql,\n                                                                            int connectionFlags,\n                                                                            boolean persist) {\n        // When we're holding a prepared statement, we're also holding its connection.\n        // This prevents database connections from being used by two or more threads.\n        acquireConnection(sql, connectionFlags, persist, null);\n\n        return mConnection.acquirePreparedStatement(sql);\n    }\n\n    /*package*/ void releasePreparedStatement(SQLiteConnection.PreparedStatement statement) {\n        // acquirePreparedStatement keeps connection as well, so we are responsible to release it.\n        if (mConnection != null) {\n            mConnection.releasePreparedStatement(statement);\n            releaseConnection();\n        }\n    }\n\n    private void throwIfNoTransaction() {\n        if (mTransactionStack == null) {\n            throw new IllegalStateException(\"Cannot perform this operation because \"\n                    + \"there is no current transaction.\");\n        }\n    }\n\n    private void throwIfTransactionMarkedSuccessful() {\n        if (mTransactionStack != null && mTransactionStack.mMarkedSuccessful) {\n            throw new IllegalStateException(\"Cannot perform this operation because \"\n                    + \"the transaction has already been marked successful.  The only \"\n                    + \"thing you can do now is call endTransaction().\");\n        }\n    }\n\n    private void throwIfNestedTransaction() {\n        if (hasNestedTransaction()) {\n            throw new IllegalStateException(\"Cannot perform this operation because \"\n                    + \"a nested transaction is in progress.\");\n        }\n    }\n\n    private Transaction obtainTransaction(int mode, SQLiteTransactionListener listener) {\n        Transaction transaction = mTransactionPool;\n        if (transaction != null) {\n            mTransactionPool = transaction.mParent;\n            transaction.mParent = null;\n            transaction.mMarkedSuccessful = false;\n            transaction.mChildFailed = false;\n        } else {\n            transaction = new Transaction();\n        }\n        transaction.mMode = mode;\n        transaction.mListener = listener;\n        return transaction;\n    }\n\n    private void recycleTransaction(Transaction transaction) {\n        transaction.mParent = mTransactionPool;\n        transaction.mListener = null;\n        mTransactionPool = transaction;\n    }\n\n    private static final class Transaction {\n        public Transaction mParent;\n        public int mMode;\n        public SQLiteTransactionListener mListener;\n        public boolean mMarkedSuccessful;\n        public boolean mChildFailed;\n    }\n}\n"
  },
  {
    "path": "deprecated/android/wcdb/src/com/tencent/wcdb/database/SQLiteStatement.java",
    "content": "/*\n * Copyright (C) 2006 The Android Open Source Project\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdb.database;\n\nimport android.database.SQLException;\nimport com.tencent.wcdb.support.CancellationSignal;\nimport com.tencent.wcdb.support.OperationCanceledException;\n\n/**\n * Represents a statement that can be executed against a database.  The statement\n * cannot return multiple rows or columns, but single value (1 x 1) result sets\n * are supported.\n * <p>\n * This class is not thread-safe.\n * </p>\n */\npublic final class SQLiteStatement extends SQLiteProgram {\n    SQLiteStatement(SQLiteDatabase db, String sql, Object[] bindArgs) {\n        super(db, sql, bindArgs, null);\n    }\n\n    /**\n     * Execute this SQL statement, if it is not a SELECT / INSERT / DELETE / UPDATE, for example\n     * CREATE / DROP table, view, trigger, index etc.\n     *\n     * @throws SQLException If the SQL string is invalid for some reason\n     */\n    public void execute() {\n        execute(null);\n    }\n\n    /**\n     * Execute this SQL statement, if it is not a SELECT / INSERT / DELETE / UPDATE, for example\n     * CREATE / DROP table, view, trigger, index etc.\n     *\n     * @param cancellationSignal A signal to cancel the operation in progress, or null if none.\n     *                           If the operation is canceled, then {@link OperationCanceledException} will be thrown\n     *                           when the query is executed.\n     * @throws SQLException If the SQL string is invalid for some reason\n     */\n    public void execute(CancellationSignal cancellationSignal) {\n        acquireReference();\n        try {\n            getSession().execute(getSql(), getBindArgs(), getConnectionFlags(), cancellationSignal);\n        } catch (SQLiteException ex) {\n            checkCorruption(ex);\n            throw ex;\n        } finally {\n            releaseReference();\n        }\n    }\n\n    /**\n     * Execute this SQL statement, if the the number of rows affected by execution of this SQL\n     * statement is of any importance to the caller - for example, UPDATE / DELETE SQL statements.\n     *\n     * @return the number of rows affected by this SQL statement execution.\n     * @throws SQLException If the SQL string is invalid for some reason\n     */\n    public int executeUpdateDelete() {\n        return executeUpdateDelete(null);\n    }\n\n    /**\n     * Execute this SQL statement, if the the number of rows affected by execution of this SQL\n     * statement is of any importance to the caller - for example, UPDATE / DELETE SQL statements.\n     *\n     * @param cancellationSignal A signal to cancel the operation in progress, or null if none.\n     *                           If the operation is canceled, then {@link OperationCanceledException} will be thrown\n     *                           when the query is executed.\n     * @return the number of rows affected by this SQL statement execution.\n     * @throws SQLException If the SQL string is invalid for some reason\n     */\n    public int executeUpdateDelete(CancellationSignal cancellationSignal) {\n        acquireReference();\n        try {\n            return getSession().executeForChangedRowCount(\n                    getSql(), getBindArgs(), getConnectionFlags(), cancellationSignal);\n        } catch (SQLiteDatabaseCorruptException ex) {\n            checkCorruption(ex);\n            throw ex;\n        } finally {\n            releaseReference();\n        }\n    }\n\n    /**\n     * Execute this SQL statement and return the ID of the row inserted due to this call.\n     * The SQL statement should be an INSERT for this to be a useful call.\n     *\n     * @return the row ID of the last row inserted, if this insert is successful. -1 otherwise.\n     *\n     * @throws SQLException If the SQL string is invalid for some reason\n     */\n    public long executeInsert() {\n        return executeInsert(null);\n    }\n\n    /**\n     * Execute this SQL statement and return the ID of the row inserted due to this call.\n     * The SQL statement should be an INSERT for this to be a useful call.\n     *\n     * @param cancellationSignal A signal to cancel the operation in progress, or null if none.\n     *                           If the operation is canceled, then {@link OperationCanceledException} will be thrown\n     *                           when the query is executed.\n     * @return the row ID of the last row inserted, if this insert is successful. -1 otherwise.\n     *\n     * @throws SQLException If the SQL string is invalid for some reason\n     */\n    public long executeInsert(CancellationSignal cancellationSignal) {\n        acquireReference();\n        try {\n            return getSession().executeForLastInsertedRowId(\n                    getSql(), getBindArgs(), getConnectionFlags(), cancellationSignal);\n        } catch (SQLiteDatabaseCorruptException ex) {\n            checkCorruption(ex);\n            throw ex;\n        } finally {\n            releaseReference();\n        }\n    }\n\n    /**\n     * Execute a statement that returns a 1 by 1 table with a numeric value.\n     * For example, SELECT COUNT(*) FROM table;\n     *\n     * @return The result of the query.\n     *\n     * @throws SQLiteDoneException if the query returns zero rows\n     */\n    public long simpleQueryForLong() {\n        return simpleQueryForLong(null);\n    }\n\n    /**\n     * Execute a statement that returns a 1 by 1 table with a numeric value.\n     * For example, SELECT COUNT(*) FROM table;\n     *\n     * @param cancellationSignal A signal to cancel the operation in progress, or null if none.\n     *                           If the operation is canceled, then {@link OperationCanceledException} will be thrown\n     *                           when the query is executed.\n     * @return The result of the query.\n     *\n     * @throws SQLiteDoneException if the query returns zero rows\n     */\n    public long simpleQueryForLong(CancellationSignal cancellationSignal) {\n        acquireReference();\n        try {\n            return getSession().executeForLong(\n                    getSql(), getBindArgs(), getConnectionFlags(), cancellationSignal);\n        } catch (SQLiteDatabaseCorruptException ex) {\n            checkCorruption(ex);\n            throw ex;\n        } finally {\n            releaseReference();\n        }\n    }\n\n    /**\n     * Execute a statement that returns a 1 by 1 table with a text value.\n     * For example, SELECT COUNT(*) FROM table;\n     *\n     * @return The result of the query.\n     *\n     * @throws SQLiteDoneException if the query returns zero rows\n     */\n    public String simpleQueryForString() {\n        return simpleQueryForString(null);\n    }\n\n    /**\n     * Execute a statement that returns a 1 by 1 table with a text value.\n     * For example, SELECT COUNT(*) FROM table;\n     *\n     * @param cancellationSignal A signal to cancel the operation in progress, or null if none.\n     *                           If the operation is canceled, then {@link OperationCanceledException} will be thrown\n     *                           when the query is executed.\n     * @return The result of the query.\n     *\n     * @throws SQLiteDoneException if the query returns zero rows\n     */\n    public String simpleQueryForString(CancellationSignal cancellationSignal) {\n        acquireReference();\n        try {\n            return getSession().executeForString(\n                    getSql(), getBindArgs(), getConnectionFlags(), cancellationSignal);\n        } catch (SQLiteDatabaseCorruptException ex) {\n            checkCorruption(ex);\n            throw ex;\n        } finally {\n            releaseReference();\n        }\n    }\n\n    @Override\n    public String toString() {\n        return \"SQLiteProgram: \" + getSql();\n    }\n}\n"
  },
  {
    "path": "deprecated/android/wcdb/src/com/tencent/wcdb/database/SQLiteStatementInfo.java",
    "content": "/*\n * Copyright (C) 2011 The Android Open Source Project\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdb.database;\n\n/**\n * Describes a SQLite statement.\n *\n * @hide\n */\npublic final class SQLiteStatementInfo {\n    /**\n     * The number of parameters that the statement has.\n     */\n    public int numParameters;\n\n    /**\n     * The names of all columns in the result set of the statement.\n     */\n    public String[] columnNames;\n\n    /**\n     * True if the statement is read-only.\n     */\n    public boolean readOnly;\n}\n"
  },
  {
    "path": "deprecated/android/wcdb/src/com/tencent/wcdb/database/SQLiteTableLockedException.java",
    "content": "/*\n * Copyright (C) 2010 The Android Open Source Project\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdb.database;\n\n@SuppressWarnings(\"serial\")\npublic class SQLiteTableLockedException extends SQLiteException {\n    public SQLiteTableLockedException() {}\n\n    public SQLiteTableLockedException(String error) {\n        super(error);\n    }\n}\n"
  },
  {
    "path": "deprecated/android/wcdb/src/com/tencent/wcdb/database/SQLiteTrace.java",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdb.database;\n\nimport java.util.List;\n\n\n/**\n * Callback interface for SQLite trace events.\n */\npublic interface SQLiteTrace {\n\n    class TraceInfo<T> {\n        public final T info;\n        public final long time;\n        public final int tid;\n\n        TraceInfo(T info_, long time_, int tid_) {\n            info = info_;\n            time = time_;\n            tid = tid_;\n        }\n    }\n\n    /**\n     * Called when a SQL statement finished execution.\n     *\n     * @param db    database on which the statement was executed\n     * @param sql   statement executed\n     * @param type  type of the statement. See {@link com.tencent.wcdb.DatabaseUtils#getSqlStatementType}\n     * @param time  time spent on execution, in milliseconds\n     */\n    void onSQLExecuted(SQLiteDatabase db, String sql, int type, long time);\n\n    /**\n     * Called when database connection is successfully obtained by a thread.\n     *\n     * @param db        database on which the connection was obtained\n     * @param sql       statement about to be executed\n     * @param waitTime  time spent on waiting for available connection, in milliseconds\n     * @param isPrimary whether the primary connection (write connection) is obtained\n     */\n    void onConnectionObtained(SQLiteDatabase db, String sql, long waitTime, boolean isPrimary);\n\n    /**\n     * Called when connection pool is blocked by other statement execution\n     * for a long time.\n     *\n     * @param db        database on which connection pool is blocked\n     * @param sql       statement to be executed\n     * @param requests  list of statement being executed\n     * @param message   message generated by the connection pool\n     */\n    void onConnectionPoolBusy(SQLiteDatabase db, String sqlWaiting, long waitTime,\n                              boolean wantPrimaryConnection,\n                              List<TraceInfo<String>> sqlRunning,\n                              List<TraceInfo<StackTraceElement[]>> longLastingActions);\n\n    /**\n     * Called on database corruption detected. This is valid on default error handler only.\n     * See {@link com.tencent.wcdb.DatabaseErrorHandler}\n     *\n     * @param db    the corrupted database\n     */\n    void onDatabaseCorrupted(SQLiteDatabase db);\n}\n"
  },
  {
    "path": "deprecated/android/wcdb/src/com/tencent/wcdb/extension/SQLiteExtension.java",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2018 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdb.extension;\n\npublic interface SQLiteExtension {\n\n    void initialize(long sqlite3Ptr, long apiPtr);\n\n}\n"
  },
  {
    "path": "deprecated/android/wcdb/src/com/tencent/wcdb/extension/fts/MMFtsTokenizer.java",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2018 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdb.extension.fts;\n\nimport com.tencent.wcdb.extension.SQLiteExtension;\n\npublic final class MMFtsTokenizer implements SQLiteExtension {\n    public static final SQLiteExtension EXTENSION = new MMFtsTokenizer();\n\n    private MMFtsTokenizer() {}\n\n    @Override\n    public void initialize(long sqlite3Ptr, long apiPtr) {\n        nativeInitialize(sqlite3Ptr, apiPtr);\n    }\n\n    private static native void nativeInitialize(long sqlite3Ptr, long apiPtr);\n}\n"
  },
  {
    "path": "deprecated/android/wcdb/src/com/tencent/wcdb/repair/BackupKit.java",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdb.repair;\n\nimport com.tencent.wcdb.database.SQLiteDatabase;\nimport com.tencent.wcdb.database.SQLiteException;\nimport com.tencent.wcdb.support.CancellationSignal;\n\nimport java.util.Arrays;\n\n\n/**\n * Data backup toolkit based on table traversal.\n */\npublic class BackupKit implements CancellationSignal.OnCancelListener {\n\n\t/*package*/ static final String TAG = \"WCDB.DBBackup\";\n\n\t/**\n\t * Result code that indicates successful operation.\n\t */\n\tpublic static final int RESULT_OK = 0;\n\n\t/**\n\t * Result code that indicates operation has been cancelled.\n\t */\n\tpublic static final int RESULT_CANCELED = 1;\n\n\t/**\n\t * Result code that indicates operation failure.\n\t */\n\tpublic static final int RESULT_FAILED = -1;\n\n\t/**\n\t * Flag indicates no encryption is used on backup data.\n\t */\n\tpublic static final int FLAG_NO_CIPHER = 0x0001;\n\n\t/**\n\t * Flag indicates no compression is used on backup data.\n\t */\n\tpublic static final int FLAG_NO_COMPRESS = 0x0002;\n\n\t/**\n\t * Flag indicates when database corruption detected, try to read more data if possible\n\t * rather than return failure immediately.\n\t */\n\tpublic static final int FLAG_FIX_CORRUPTION = 0x0004;\n\n\t/**\n\t * Flag indicates no \"CREATE TABLE\" statement should be output to backup file.\n\t * When backup file created this way is being recovered, it won't execute\n\t * \"CREATE TABLE\" or \"CREATE INDEX\" statement.\n\t */\n\tpublic static final int FLAG_NO_CREATE_TABLE = 0x0008;\n\n\t/**\n\t * Flag indicates incremental backup is performed. Incremental backup appends new data\n\t * to the end of the backup file instead of overwriting. Use this flag with conditional\n\t * backup to implement incremental backup.\n\t *\n\t * @see #BackupKit(SQLiteDatabase, String, byte[], int, String[])\n\t */\n\tpublic static final int FLAG_INCREMENTAL = 0x0010;\n\t\n\tprivate long mNativePtr;\n\tprivate SQLiteDatabase mDB;\n\tprivate String[] mTableDesc;\n\tprivate int mStatementCount;\n\tprivate String mLastError;\n\n\t/**\n\t * Create and initialize a backup task.\n\t *\n\t * <p>Conditional or incremental backup can be implemented by passing non-null\n\t * to tableDesc argument.</p>\n\t *\n\t * <p>{@code tableDesc} should be array with length of a multiple of 2. The elements with\n\t * even index are table name white-list to be backed up. Tables not listed are ignored.\n\t * The elements with odd index are condition expression used in WHERE-clause when\n\t * data to be backed up is selected, which can be null to indicate unconditional selection.</p>\n\t *\n\t * <p>For example, the array listed below tells to\n\t * backup only the whole {@code contact} table and {@code message} table with\n\t * column {@code id} greater than 100.\n\t * </p>\n\t *\n\t * <pre><code>\n\t *     new String[] {\n\t *         \"contact\", null,\n\t *         \"message\", \"id > 100\",\n\t *     };\n\t * </code></pre>\n\t *\n\t * @param db\t\tdatabase to be backed up.\n\t * @param outPath\tpath to the output backup file.\n\t * @param key\t\tkey for backup file encryption. Pass null to skip encryption.\n\t * @param flags\t\tflags to the backup operation.\n\t * @param tableDesc table description for conditional backup.\n\t * @throws SQLiteException when backup operation cannot be initialized.\n\t * @throws IllegalArgumentException when outPath is null.\n\t */\n\tpublic BackupKit(SQLiteDatabase db, String outPath, byte[] key, int flags, String[] tableDesc)\n\t\t\tthrows SQLiteException {\n\t\tmDB = db;\n\t\tmLastError = null;\n\t\tmTableDesc = (tableDesc != null) ? Arrays.copyOf(tableDesc, tableDesc.length) : null;\n\t\tif (outPath == null)\n\t\t\tthrow new IllegalArgumentException();\n\t\tmNativePtr = nativeInit(outPath, key, flags);\n\t\tif (mNativePtr == 0)\n\t\t\tthrow new SQLiteException(\"Failed initialize backup context.\");\n\t}\n\n\t/**\n\t * Run backup task.\n\t *\n\t * <p><i>Note: this method will not return until backup is finished or cancelled.\n\t * Do not call this method directly on the main thread or it will probably cause ANR.</i></p>\n\t *\n\t * @return\tresult code which is {@link #RESULT_OK}, {@link #RESULT_CANCELED} or {@link #RESULT_FAILED}.\n\t */\n\tpublic int run() {\n\t\tif (mNativePtr == 0)\n\t\t\tthrow new IllegalStateException(\"BackupKit not initialized.\");\n\n\t\tlong dbHandle = mDB.acquireNativeConnectionHandle(\"backup\", false, false);\n\t\tint result = nativeRun(mNativePtr, dbHandle, mTableDesc);\n\t\tmDB.releaseNativeConnection(dbHandle, null);\n\n\t\tmStatementCount = nativeStatementCount(mNativePtr);\n\t\tmLastError = nativeLastError(mNativePtr);\n\n\t\tnativeFinish(mNativePtr);\n\t\tmNativePtr = 0;\n\n\t\treturn result;\n\t}\n\n\tpublic int run(CancellationSignal cancellationSignal) {\n\t\tif (cancellationSignal.isCanceled())\n\t\t\treturn RESULT_CANCELED;\n\n\t\tcancellationSignal.setOnCancelListener(this);\n\t\tint result = run();\n\t\tcancellationSignal.setOnCancelListener(null);\n\n\t\treturn result;\n\t}\n\n\t/**\n\t * Retrieve total count of statements had been output during the last time {@link #run()}\n\t * was called.\n\t *\n\t * @return\tstatement count had been output.\n\t */\n\tpublic int statementCount() {\n\t\treturn mStatementCount;\n\t}\n\n\t/**\n\t * Cancel the current running backup operation.\n\t *\n\t * <p>This method can be called on threads other than the one called {@link #run()}\n\t * Calling this method causes {@link #run()} to interrupt as quickly as possible and\n\t * return {@link #RESULT_CANCELED}</p>\n\t */\n\t@Override\n\tpublic void onCancel() {\n\t\tif (mNativePtr != 0)\n\t\t\tnativeCancel(mNativePtr);\n\t}\n\n\t/**\n\t * Get the last error message.\n\t *\n\t * @return\tlast error message, can be null.\n\t */\n\tpublic String lastError() {\n\t\treturn mLastError;\n\t}\n\n\t/**\n\t * Cleanup and release this backup task. No further operations should be done on this\n\t * object after calling it.\n\t */\n\tpublic void release() {\n\t\tif (mNativePtr != 0) {\n\t\t\tnativeFinish(mNativePtr);\n\t\t\tmNativePtr = 0;\n\t\t}\n\t}\n\t\n\t@Override\n\tprotected void finalize() throws Throwable {\n\t\trelease();\n\t\tsuper.finalize();\n\t}\n\t\n\tprivate static native long nativeInit(String outPath, byte[] key, int flags);\n\tprivate static native int nativeRun(long ctxHandle, long dbHandle, String[] tableDesc);\n\tprivate static native void nativeCancel(long ctxHandle);\n\tprivate static native void nativeFinish(long ctxHandle);\n\tprivate static native int nativeStatementCount(long ctxHandle);\n\tprivate static native String nativeLastError(long ctxHandle);\n}\n"
  },
  {
    "path": "deprecated/android/wcdb/src/com/tencent/wcdb/repair/DBDumpUtil.java",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdb.repair;\n\nimport java.io.BufferedReader;\nimport java.io.File;\nimport java.io.FileInputStream;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.util.ArrayList;\nimport java.util.HashMap;\nimport java.util.List;\n\nimport android.text.TextUtils;\n\nimport com.tencent.wcdb.database.SQLiteDatabase;\nimport com.tencent.wcdb.support.Log;\n\n/**\n * Interface to database recovery dump utility from SQLite command-line tools.\n *\n * @deprecated Use {@link RepairKit} for database corruption recovery.\n */\npublic class DBDumpUtil {\n\n\tprivate static final String TAG = \"WCDB.DBDumpUtil\";\n\n\t/** @deprecated Use {@link RepairKit} for database corruption recovery. */\n\tpublic interface ExecuteSqlCallback {\n\t\tString preExecute(String sql);\n\t}\n\n\tpublic static boolean doRecoveryDb(SQLiteDatabase db, String crashDbPath, String key,\n\t\t\tString outputPath) {\n\t\treturn doRecoveryDb(db, crashDbPath, key, outputPath, null, null, null, true);\n\t}\n\n\tpublic static boolean doRecoveryDb(SQLiteDatabase db, String crashDbPath, String key,\n\t\t\tString outputPath, List<String> filterTable, List<String> destTables,\n\t\t\tExecuteSqlCallback callback, boolean needDeleteAfterSuccess) {\n\t\tif (db == null || !db.isOpen()) {\n\t\t\tLog.w(TAG, \"Database is not open\");\n\t\t\treturn false;\n\t\t}\n\n\t\tboolean dumpOk = nativeDumpDB(crashDbPath, key, outputPath);\n\t\tif (!dumpOk) {\n\t\t\treturn false;\n\t\t}\n\n\t\tBufferedReader reader;\n\t\ttry {\n\t\t\treader = new BufferedReader(new FileReader(outputPath));\n\t\t} catch (FileNotFoundException e) {\n\t\t\tLog.w(TAG, \"SQL file '%s' not found\", outputPath);\n\t\t\treturn false;\n\t\t}\n\n\t\tString line;\n\t\tdb.execSQL(\"PRAGMA foreign_keys=OFF;\");\n\t\tdb.beginTransaction();\n\t\tint failureCount = 0;\n\t\tint allCount = 0;\n\t\tint executeCount = 0;\n\t\ttry {\n\t\t\tString temp = null;\n\t\t\tboolean contact = false;\n\t\t\tHashMap<String, String> tables = new HashMap<>();\n\n\t\t\twhile ((line = reader.readLine()) != null) {\n\t\t\t\tif (contact) {\n\t\t\t\t\ttemp += \"\\n\" + line;\n\t\t\t\t\tif (!temp.endsWith(\";\") || !nativeIsSqlComplete(temp)) {\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t} else if (line.startsWith(\"INSERT\") || line.startsWith(\"CREATE TABLE\")) {\n\t\t\t\t\tif (!line.endsWith(\";\") || !nativeIsSqlComplete(line)) {\n\t\t\t\t\t\tif (TextUtils.isEmpty(temp)) {\n\t\t\t\t\t\t\ttemp = line;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\ttemp += \"\\n\" + line;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcontact = true;\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t} else {\n\t\t\t\t\t\ttemp = line;\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tcontact = false;\n\t\t\t\tString tableName = null;\n\t\t\t\tboolean needFilter = false;\n\t\t\t\tif (destTables != null && destTables.size() > 0) {\n\t\t\t\t\ttableName = getTableNameFromSql(temp);\n\t\t\t\t\tneedFilter = true;\n\t\t\t\t\tfor (String dest : destTables) {\n\t\t\t\t\t\tif (tableName.equals(dest)) {\n\t\t\t\t\t\t\tneedFilter = false;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t} else if (filterTable != null && filterTable.size() > 0) {\n\t\t\t\t\ttableName = getTableNameFromSql(temp);\n\t\t\t\t\tneedFilter = false;\n\t\t\t\t\tfor (String filter : filterTable) {\n\t\t\t\t\t\tif (tableName.equals(filter)) {\n\t\t\t\t\t\t\tneedFilter = true;\n\t\t\t\t\t\t\ttemp = \"\";\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (needFilter) {\n\t\t\t\t\tLog.i(TAG, \"filter table %s\", tableName);\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\ttry {\n\t\t\t\t\tif (temp.startsWith(\"CREATE TABLE\")) {\n\t\t\t\t\t\tArrayList<String> columns = getColumnNamesFromSql(temp);\n\t\t\t\t\t\tString bindStr = buildColumnsString(columns);\n\t\t\t\t\t\ttables.put(tableName, bindStr);\n\t\t\t\t\t} else if (temp.startsWith(\"INSERT INTO\")) {\n\t\t\t\t\t\tString bindStr = tables.get(tableName);\n\t\t\t\t\t\tif (!TextUtils.isEmpty(bindStr)) {\n\t\t\t\t\t\t\tStringBuilder sb = new StringBuilder(\"INSERT INTO \");\n\t\t\t\t\t\t\tsb.append(\"\\\"\").append(tableName).append(\"\\\"\");\n\t\t\t\t\t\t\tString prefix = sb.toString();\n\t\t\t\t\t\t\tsb.append(bindStr);\n\t\t\t\t\t\t\ttemp = temp.replace(prefix, sb.toString());\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tString tempSql = null;\n\n\t\t\t\t\tif (callback != null) {\n\t\t\t\t\t\ttempSql = callback.preExecute(temp);\n\t\t\t\t\t}\n\t\t\t\t\tif (!TextUtils.isEmpty(tempSql)) {\n\t\t\t\t\t\ttemp = tempSql;\n\t\t\t\t\t}\n\t\t\t\t\tallCount++;\n\t\t\t\t\tdb.execSQL(temp);\n\t\t\t\t\texecuteCount++;\n\t\t\t\t\tif (executeCount >= 100) {\n\t\t\t\t\t\tdb.setTransactionSuccessful();\n\t\t\t\t\t\tdb.endTransaction();\n\t\t\t\t\t\tdb.beginTransaction();\n\t\t\t\t\t\texecuteCount = 0;\n\t\t\t\t\t}\n\t\t\t\t} catch (Exception e) {\n\t\t\t\t\tfailureCount++;\n\t\t\t\t}\n\t\t\t\ttemp = null;\n\t\t\t}\n\t\t} catch (IOException e) {\n\t\t\tLog.w(TAG, \"I/O error in read sql file \");\n\t\t\treturn false;\n\t\t} finally {\n\t\t\tif (reader != null) {\n\t\t\t\ttry {\n\t\t\t\t\treader.close();\n\t\t\t\t} catch (IOException e) {\n\t\t\t\t\te.printStackTrace();\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif (allCount > failureCount) {\n\t\t\tif (db.inTransaction())\n\t\t\t\tdb.setTransactionSuccessful();\n\t\t\tif (db.inTransaction()) {\n\t\t\t\tdb.endTransaction();\n\t\t\t}\n\t\t\tif (needDeleteAfterSuccess) {\n\t\t\t\tFile file = new File(outputPath);\n\t\t\t\tif (file.exists()) {\n\t\t\t\t\tfile.delete();\n\t\t\t\t}\n\t\t\t\tFile crashFile = new File(crashDbPath);\n\t\t\t\tif (crashFile.exists()) {\n\t\t\t\t\tcrashFile.delete();\n\t\t\t\t}\n\t\t\t}\n\t\t\tLog.i(TAG, \"restore : %d , fail:%d \", allCount, failureCount);\n\t\t\treturn true;\n\t\t} else {\n\t\t\treturn false;\n\t\t}\n\t}\n\n\tpublic static String buildColumnsString(ArrayList<String> columns) {\n\t\tif (columns == null || columns.size() == 0) {\n\t\t\treturn \"\";\n\t\t}\n\t\tStringBuilder sb = new StringBuilder();\n\t\tsb.append(\"(\");\n\t\tfor (int i = 0; i < columns.size(); i++) {\n\t\t\tsb.append(columns.get(i));\n\t\t\tif (i != columns.size() - 1)\n\t\t\t\tsb.append(\",\");\n\t\t}\n\t\tsb.append(\")\");\n\n\t\tString buildStr = sb.toString();\n\t\tSystem.out.println(buildStr);\n\t\treturn buildStr;\n\t}\n\n\tpublic static String getTableNameFromSql(String sql) {\n\t\tif (sql.length() > 100) {\n\t\t\tsql = sql.substring(0, 100);\n\t\t}\n\t\tString[] str = sql.split(\"\\\\s\");\n\t\tif (str != null && str.length > 1) {\n\t\t\treturn str[2].replaceAll(\"\\\"\", \"\");\n\t\t}\n\t\treturn null;\n\t}\n\n\tpublic static byte[] readFromFile(String path) {\n\t\tFile file = new File(path);\n\t\tif (!file.exists()) {\n\t\t\tLog.w(TAG, \"readFromFile error, file is not exit, path = %s\", path);\n\t\t\treturn null;\n\t\t}\n\n\t\tFileInputStream fin = null;\n\t\ttry {\n\t\t\tint size = (int) file.length();\n\t\t\tfin = new FileInputStream(file);\n\n\t\t\tbyte[] buf = new byte[size];\n\t\t\tint count = fin.read(buf);\n\t\t\tif (count != size) {\n\t\t\t\tLog.w(TAG,\n\t\t\t\t\t\t\"readFromFile error, size is not equal, path = %s, file length is %d, count is %d\",\n\t\t\t\t\t\tpath, size, count);\n\t\t\t\treturn null;\n\n\t\t\t} else {\n\t\t\t\treturn buf;\n\t\t\t}\n\n\t\t} catch (Exception e) {\n\t\t\te.printStackTrace();\n\t\t} finally {\n\t\t\tif (fin != null) {\n\t\t\t\ttry {\n\t\t\t\t\tfin.close();\n\t\t\t\t} catch (IOException e) {\n\t\t\t\t\te.printStackTrace();\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tLog.e(TAG, \"readFromFile failed!\");\n\t\treturn null;\n\t}\n\n\tpublic static ArrayList<String> getColumnNamesFromSql(String sql) {\n\t\tArrayList<String> columns = new ArrayList<>();\n\t\tString temp = sql.substring(sql.indexOf(\"(\") + 1, sql.lastIndexOf(\")\"));\n\t\tString[] Str = temp.trim().split(\",\");\n\t\tfor (int i = 0; i < Str.length; i++) {\n\t\t\tStr[i] = Str[i].trim();\n\t\t\tint secondIndex = Str[i].indexOf(\" \");\n\t\t\tcolumns.add(Str[i].substring(0, secondIndex));\n\t\t}\n\t\treturn columns;\n\t}\n\n\tprivate static native boolean nativeDumpDB(String dbPath, String key, String outputPath);\n\tprivate static native boolean nativeIsSqlComplete(String sql);\n}\n"
  },
  {
    "path": "deprecated/android/wcdb/src/com/tencent/wcdb/repair/RecoverKit.java",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdb.repair;\n\nimport com.tencent.wcdb.database.SQLiteDatabase;\nimport com.tencent.wcdb.database.SQLiteException;\nimport com.tencent.wcdb.support.CancellationSignal;\n\n\n/**\n * Data recovery toolkit that recover data backed up by {@link BackupKit}.\n */\npublic class RecoverKit implements CancellationSignal.OnCancelListener {\n\n\t/*package*/ static final String TAG = \"WCDB.DBBackup\";\n\n\t/**\n\t * Result code that indicates successful operation.\n\t */\n\tpublic static final int RESULT_OK = 0;\n\n\t/**\n\t * Result code that indicates operation has been cancelled.\n\t */\n\tpublic static final int RESULT_CANCELED = 1;\n\n\t/**\n\t * Result code that indicates operation failure.\n\t */\n\tpublic static final int RESULT_FAILED = -1;\n\t\n\tprivate long mNativePtr;\n\tprivate SQLiteDatabase mDB;\n\tprivate int mFailedCount;\n\tprivate int mSuccessCount;\n\tprivate String mLastError;\n\n\t/**\n\t * Create and initialize a recovery task.\n\t *\n\t * @param db\t\tdatabase where recovered data is written\n\t * @param inPath\tpath to the backup file\n\t * @param key\t\tkey to the encrypted backup file, or null for plain-text backup file.\n\t * @throws SQLiteException when backup file cannot be opened.\n\t */\n\tpublic RecoverKit(SQLiteDatabase db, String inPath, byte[] key)\n\t\t\tthrows SQLiteException {\n\t\tmDB = db;\n        mLastError = null;\n\t\tmNativePtr = nativeInit(inPath, key);\n\t\tif (mNativePtr == 0)\n\t\t\tthrow new SQLiteException(\"Failed initialize recover context.\");\n\t}\n\n\t/**\n\t * Run recovery task.\n\t *\n\t * <p><i>Note: this method will not return until recovery is finished or cancelled.\n\t * Do not call this method directly on the main thread or it will probably cause ANR.</i></p>\n\t *\n\t * @param fatal\twhether or not to treat errors as fatal. When it's true and an error occurs,\n\t *              recovery will end and return {@link #RESULT_CANCELED}.\n\t * @return\t\tresult code which is {@link #RESULT_OK}, {@link #RESULT_CANCELED} or\n\t * \t\t\t\t{@link #RESULT_FAILED}.\n\t */\n\tpublic int run(final boolean fatal) {\n\t\tif (mNativePtr == 0)\n\t\t\tthrow new IllegalStateException(\"RecoverKit not initialized.\");\n\n\t\tlong dbHandle = mDB.acquireNativeConnectionHandle(\"recover\", false, false);\n\n\t\tint result = nativeRun(mNativePtr, dbHandle, fatal);\n\t\tmDB.releaseNativeConnection(dbHandle, null);\n\n\t\tmSuccessCount = nativeSuccessCount(mNativePtr);\n\t\tmFailedCount = nativeFailureCount(mNativePtr);\n        mLastError = nativeLastError(mNativePtr);\n\n        nativeFinish(mNativePtr);\n        mNativePtr = 0;\n\n\t\treturn result;\n\t}\n\n\tpublic int run(boolean fatal, CancellationSignal cancellationSignal) {\n\t\tif (cancellationSignal.isCanceled())\n\t\t\treturn RESULT_CANCELED;\n\n\t\tcancellationSignal.setOnCancelListener(this);\n\t\tint result = run(fatal);\n\t\tcancellationSignal.setOnCancelListener(null);\n\n\t\treturn result;\n\t}\n\n\t/**\n\t * Retrieve total count of successful statements had been run during the last time\n\t * {@link #run(boolean)} was called.\n\t *\n\t * @return\tcount of successful statements\n\t */\n\tpublic int successCount() {\n\t\treturn mSuccessCount;\n\t}\n\n\t/**\n\t * Retrieve total count of statements had been failed during the last time\n\t * {@link #run(boolean)} was called.\n\t *\n\t * @return\tcount of failed statements\n\t */\n\tpublic int failureCount() {\n\t\treturn mFailedCount;\n\t}\n\n\t/**\n\t * Cancel the current running recovery operation.\n\t *\n\t * <p>This method can be called on threads other than the one called {@link #run(boolean)}\n\t * Calling this method causes {@link #run(boolean)} to interrupt as quickly as possible and\n\t * return {@link #RESULT_CANCELED}</p>\n\t */\n\t@Override\n\tpublic void onCancel() {\n\t\tif (mNativePtr != 0)\n\t\t\tnativeCancel(mNativePtr);\n\t}\n\n\t/**\n\t * Get the last error message.\n\t *\n\t * @return\tlast error message, can be null.\n\t */\n\tpublic String lastError() {\n\t\treturn mLastError;\n\t}\n\n\t/**\n\t * Cleanup and release this recovery task. No further operations should be done on this\n\t * object after calling it.\n\t */\n\tpublic void release() {\n\t\tif (mNativePtr != 0) {\n\t\t\tnativeFinish(mNativePtr);\n\t\t\tmNativePtr = 0;\n\t\t}\n\t}\n\t\n\t@Override\n\tprotected void finalize() throws Throwable {\n\t\trelease();\n        super.finalize();\n\t}\n\t\n\tprivate static native long nativeInit(String inPath, byte[] key);\n\tprivate static native int nativeRun(long ctxHandle, long dbHandle, boolean fatal);\n\tprivate static native void nativeCancel(long ctxHandle);\n\tprivate static native void nativeFinish(long ctxHandle);\n\tprivate static native int nativeSuccessCount(long ctxHandle);\n\tprivate static native int nativeFailureCount(long ctxHandle);\n\tprivate static native String nativeLastError(long ctxHandle);\n}\n"
  },
  {
    "path": "deprecated/android/wcdb/src/com/tencent/wcdb/repair/RepairKit.java",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdb.repair;\n\nimport android.database.Cursor;\n\nimport com.tencent.wcdb.AbstractCursor;\nimport com.tencent.wcdb.database.SQLiteCipherSpec;\nimport com.tencent.wcdb.database.SQLiteDatabase;\nimport com.tencent.wcdb.database.SQLiteException;\nimport com.tencent.wcdb.support.CancellationSignal;\n\nimport java.io.IOException;\n\n\n/**\n * Database repair toolkit to parse a corrupted database file and\n * write its content to another (newly created) database.\n */\npublic class RepairKit implements CancellationSignal.OnCancelListener {\n    private static final String TAG = \"WCDB.RepairKit\";\n\n    /**\n     * Result code that indicates successful operation.\n     */\n    public static final int RESULT_OK = 0;\n\n    /**\n     * Result code that indicates operation has been cancelled.\n     */\n    public static final int RESULT_CANCELED = 1;\n\n    /**\n     * Result code that indicates operation failure.\n     */\n    public static final int RESULT_FAILED = -1;\n\n    public static final int RESULT_IGNORE = 2;\n\n    /**\n     * Flag indicates no {@code CREATE TABLE} or {@code CREATE INDEX} statement\n     * should be executed on the destination database.\n     */\n    public static final int FLAG_NO_CREATE_TABLES = 0x0001;\n\n    /**\n     * Flag indicates all tables and indices should be written to the destination\n     * database, regardless to how table filters are set.\n     */\n    public static final int FLAG_ALL_TABLES = 0x0002;\n\n    /**\n     * Flag indicates {@code CREATE TABLE} statements recovered from corrupted\n     * databases should be check against those in backup files.\n     */\n    public static final int FLAG_CHECK_TABLE_COLUMNS = 0x0004;\n\n\n    private static final int INTEGRITY_HEADER = 0x0001;\n    private static final int INTEGRITY_DATA = 0x0002;\n    private static final int INTEGRITY_KDF_SALT = 0x0004;\n\n    private long mNativePtr;\n    private int mIntegrityFlags;\n    private MasterInfo mMasterInfo;\n    private LeafInfo mLeafInfo;\n    private Callback mCallback;\n    private RepairCursor mCurrentCursor;\n\n\n    /**\n     * Open a corrupted database for repairing.\n     *\n     * <p>Database is successfully opened and ready to be parsed when the constructor returns\n     * without throwing exceptions. The caller should catch {@link SQLiteException} in case of\n     * failure due to file opening error, wrong password, or unrecoverable corruption.\n     * </p>\n     *\n     * <p>Backup master info can be provided for better chance of recovery.\n     * Backup master info can be saved before the database is corrupted by calling\n     * {@link MasterInfo#save(SQLiteDatabase, String, byte[])}. To use backup master info\n     * on recovery, call {@link MasterInfo#load(String, byte[], String[])} on saved info\n     * and pass it as {@code master} argument.</p>\n     *\n     * <p>Table filters can be applied to recover only selected tables. Calling {@link\n     * MasterInfo#make(String[])} or {@link MasterInfo#load(String, byte[], String[])}\n     * to generate table filters.</p>\n     *\n     * @param path          path to the corrupted database to be repaired\n     * @param key           password to the encrypted database, or null for plain-text database\n     * @param cipherSpec    cipher description, or null for default settings\n     * @param master        backup master info and/or table filters\n     * @throws SQLiteException when corrupted database cannot be opened.\n     * @throws IllegalArgumentException when path is null.\n     */\n    public RepairKit(String path, byte[] key, SQLiteCipherSpec cipherSpec, MasterInfo master) {\n        this(path, key, cipherSpec, master, null);\n    }\n\n    public RepairKit(String path, byte[] key, SQLiteCipherSpec cipherSpec, MasterInfo master,\n                     LeafInfo leaf) {\n        if (path == null)\n            throw new IllegalArgumentException();\n\n        mNativePtr = nativeInit(path, key, cipherSpec, (master == null) ? null : master.mKDFSalt);\n        if (mNativePtr == 0)\n            throw new SQLiteException(\"Failed initialize RepairKit.\");\n\n        mIntegrityFlags = nativeIntegrityFlags(mNativePtr);\n        mMasterInfo = master;\n        mLeafInfo = leaf;\n    }\n\n    /**\n     * Returns the progress callback set previously.\n     *\n     * @return the progress callback object\n     */\n    public Callback getCallback() {\n        return mCallback;\n    }\n\n    /**\n     * Set the progress callback to be called during {@link #output(SQLiteDatabase, int)}.\n     *\n     * @param callback the callback object to be set\n     */\n    public void setCallback(Callback callback) {\n        mCallback = callback;\n    }\n\n    /**\n     * Close corrupted database and release all resources. Do not call any methods\n     * after this method is called.\n     */\n    public void release() {\n        if (mLeafInfo != null) {\n            mLeafInfo.release();\n            mLeafInfo = null;\n        }\n\n        if (mMasterInfo != null) {\n            mMasterInfo.release();\n            mMasterInfo = null;\n        }\n\n        if (mNativePtr != 0) {\n            nativeFini(mNativePtr);\n            mNativePtr = 0;\n        }\n    }\n\n    /**\n     * Parse corrupted database and output its content to {@code db}.\n     *\n     * <p>This method does not return until repairing is finished. Don't\n     * call it in the main thread or it will cause ANR.</p>\n     *\n     * @param db    destination database to be written\n     * @param flags flags affects repair behavior\n     * @return      result code which is {@link #RESULT_OK}, {@link #RESULT_CANCELED}\n     *              or {@link #RESULT_FAILED}.\n     */\n    public int output(SQLiteDatabase db, int flags) {\n        if (mNativePtr == 0)\n            throw new IllegalArgumentException();\n\n        long masterPtr = (mMasterInfo == null) ? 0 : mMasterInfo.mMasterPtr;\n        long leafPtr = (mLeafInfo == null) ? 0 : mLeafInfo.mLeafPtr;\n\n        long dbPtr = db.acquireNativeConnectionHandle(\"repair\", false, false);\n        int ret = nativeOutput(mNativePtr, dbPtr, masterPtr, leafPtr, flags);\n        db.releaseNativeConnection(dbPtr, null);\n        mCurrentCursor = null;\n\n        mIntegrityFlags = nativeIntegrityFlags(mNativePtr);\n        return ret;\n    }\n\n    /**\n     * Parse corrupted database and output its content to {@code db}.\n     *\n     * <p>This method does not return until repairing is finished. Don't\n     * call it in the main thread or it will cause ANR.</p>\n     *\n     * @param db    destination database to be written\n     * @param flags flags affects repair behavior\n     * @param cancellationSignal A signal to cancel the operation in progress, or null if none\n     * @return      result code which is {@link #RESULT_OK}, {@link #RESULT_CANCELED}\n     *              or {@link #RESULT_FAILED}.\n     */\n    public int output(SQLiteDatabase db, int flags, CancellationSignal cancellationSignal) {\n        if (cancellationSignal.isCanceled())\n            return RESULT_CANCELED;\n\n        cancellationSignal.setOnCancelListener(this);\n        int result = output(db, flags);\n        cancellationSignal.setOnCancelListener(null);\n\n        return result;\n    }\n\n    @Override\n    public void onCancel() {\n        if (mNativePtr == 0)\n            return;\n        nativeCancel(mNativePtr);\n    }\n\n    @SuppressWarnings(\"unused\")\n    private int onProgress(String table, int root, long cursorPtr) {\n        if (mCallback == null)\n            return RESULT_OK;\n\n        if (mCurrentCursor == null) {\n            mCurrentCursor = new RepairCursor();\n        }\n\n        mCurrentCursor.mPtr = cursorPtr;\n        return mCallback.onProgress(table, root, mCurrentCursor);\n    }\n\n    /**\n     * Retrieve whether KDF salt is corrupted.\n     * @return {@code true} if corrupted\n     */\n    public boolean isSaltCorrupted() {\n        return (mIntegrityFlags & INTEGRITY_KDF_SALT) == 0;\n    }\n\n    /**\n     * Retrieve whether database header is corrupted.\n     * @return {@code true} if corrupted\n     */\n    public boolean isHeaderCorrupted() {\n        return (mIntegrityFlags & INTEGRITY_HEADER) == 0;\n    }\n\n    /**\n     * Retrieve whether data is corrupted.\n     * @return {@code true} if corrupted\n     */\n    public boolean isDataCorrupted() {\n        return (mIntegrityFlags & INTEGRITY_DATA) == 0;\n    }\n\n    public static class Statistics {\n        public final int totalPages;\n        public final int validPages;\n        public final int parsedPages;\n        public final int damagedPages;\n        Statistics(int[] st) {\n            totalPages = st[0];\n            validPages = st[1];\n            parsedPages = st[2];\n            damagedPages = st[3];\n        }\n    }\n    public Statistics getStatistics() {\n        if (mNativePtr == 0)\n            throw new IllegalArgumentException();\n        int[] stat = nativeGetStatistics(mNativePtr);\n        return new Statistics(stat);\n    }\n\n    /**\n     * Retrieve the last error message.\n     * @return last error message\n     */\n    public static String lastError() {\n        return nativeLastError();\n    }\n\n    @Override\n    protected void finalize() throws Throwable {\n        release();\n        super.finalize();\n    }\n\n    /**\n     * Class represent master info backed up from a {@link SQLiteDatabase}, which\n     * can be used in recovery on database file with corrupted header.\n     *\n     * <p>Table filters can be applied while loading from file or creating an\n     * empty {@code MasterInfo}.</p>\n     *\n     * @see RepairKit#RepairKit(String, byte[], SQLiteCipherSpec, MasterInfo)\n     */\n    public static class MasterInfo {\n        long mMasterPtr;\n        byte[] mKDFSalt;\n\n        private MasterInfo(long ptr, byte[] salt) {\n            mMasterPtr = ptr;\n            mKDFSalt = salt;\n        }\n\n        /**\n         * Create a {@code MasterInfo} object with no backup information.\n         * The only scenario to call this method is to apply table filters\n         * for recovery.\n         *\n         * @param tables array of table names to include in the filter\n         * @return {@code MasterInfo} object just created\n         */\n        public static MasterInfo make(String[] tables) {\n            long ptr = RepairKit.nativeMakeMaster(tables);\n            if (ptr == 0)\n                throw new SQLiteException(\"Cannot create MasterInfo.\");\n\n            return new MasterInfo(ptr, null);\n        }\n\n        /**\n         * Load backup information from file and create a {@code MasterInfo}\n         * object. Table filters can be applied while loading.\n         *\n         * @param path      path to the backup file\n         * @param key       passphrase to the encrypted backup file, or null for\n         *                  plain-text backup file\n         * @param tables    array of table names to include in the filter\n         * @return {@code MasterInfo} object just created\n         */\n        public static MasterInfo load(String path, byte[] key, String[] tables) {\n            if (path == null)\n                return make(tables);\n\n            byte[] salt = new byte[16];\n            long ptr = RepairKit.nativeLoadMaster(path, key, tables, salt);\n            if (ptr == 0)\n                throw new SQLiteException(\"Cannot create MasterInfo.\");\n\n            return new MasterInfo(ptr, salt);\n        }\n\n        /**\n         * Save backup information from an opened {@link SQLiteDatabase} for later\n         * corruption recovery.\n         *\n         * <p><strong>Call this method BEFORE database corruption.</strong> Backup\n         * data will not change unless database schema is modified, by executing,\n         * e.g. {@code CREATE TABLE}, {@code CREATE INDEX} or {@code ALTER TABLE}\n         * statements.</p>\n         *\n         * <p>Best practise would be backing up when database just finished creation\n         * or upgrade, which would be placed in\n         * {@link com.tencent.wcdb.database.SQLiteOpenHelper#onCreate(SQLiteDatabase)}\n         * or {@link com.tencent.wcdb.database.SQLiteOpenHelper#onUpgrade(SQLiteDatabase, int, int)}.</p>\n         *\n         * @param db    database to be backed up\n         * @param path  output path to the backup file\n         * @param key   passphrase to the backup file, or null for no encryption\n         * @return      true if backup is finished successfully\n         */\n        public static boolean save(SQLiteDatabase db, String path, byte[] key) {\n            long dbPtr = db.acquireNativeConnectionHandle(\"backupMaster\", true, false);\n            boolean ret = RepairKit.nativeSaveMaster(dbPtr, path, key);\n            db.releaseNativeConnection(dbPtr, null);\n            return ret;\n        }\n\n        /**\n         * Close corrupted database and release all resources. This should be\n         * called when recovery is finished. No further method calls on this\n         * object after calling.\n         */\n        public void release() {\n            if (mMasterPtr == 0) return;\n\n            RepairKit.nativeFreeMaster(mMasterPtr);\n            mMasterPtr = 0;\n        }\n\n        @Override\n        protected void finalize() throws Throwable {\n            release();\n            super.finalize();\n        }\n    }\n\n    public static class LeafInfo {\n        long mLeafPtr;\n\n        private LeafInfo(long leafPtr) {\n            mLeafPtr = leafPtr;\n        }\n\n        public void release() {\n            if (mLeafPtr == 0) return;\n\n            nativeFreeLeaf(mLeafPtr);\n            mLeafPtr = 0;\n        }\n\n        @Override\n        protected void finalize() throws Throwable {\n            release();\n            super.finalize();\n        }\n\n        public static LeafInfo scan(SQLiteDatabase db, String[] tables, CancellationSignal cs) {\n            final long[] cancelFlag = new long[1];\n\n            if (cs != null) {\n                cs.setOnCancelListener(new CancellationSignal.OnCancelListener() {\n                    @Override\n                    public void onCancel() {\n                        if (cancelFlag[0] != 0)\n                            nativeCancelScanLeaf(cancelFlag[0]);\n                    }\n                });\n            }\n\n            if (tables != null && tables.length == 0)\n                tables = null;\n            long dbPtr = db.acquireNativeConnectionHandle(\"scanLeaf\", true, false);\n            Exception ex = null;\n            try {\n                if (cs != null) {\n                    cs.throwIfCanceled();\n                }\n\n                long leafPtr = nativeScanLeaf(dbPtr, tables, (cs == null) ? null : cancelFlag);\n                if (leafPtr == 0)\n                    throw new SQLiteException(\"Cannot scan leaf info.\");\n                return new LeafInfo(leafPtr);\n            } catch (Exception e) {\n                ex = e;\n                throw e;\n            } finally {\n                if (cs != null) {\n                    cs.setOnCancelListener(null);\n                }\n                db.releaseNativeConnection(dbPtr, ex);\n            }\n        }\n\n        public void save(String path) throws IOException {\n            if (mLeafPtr == 0) return;\n\n            if (!nativeSaveLeaf(mLeafPtr, path))\n                throw new IOException(\"Cannot save leaf info.\");\n        }\n\n        public static LeafInfo load(String path) throws IOException {\n            long leafPtr = nativeLoadLeaf(path);\n            if (leafPtr == 0)\n                throw new IOException(\"Cannot load leaf info.\");\n            return new LeafInfo(leafPtr);\n        }\n    }\n\n    /**\n     * Listener for repairing progress report.\n     */\n    public interface Callback {\n\n        /**\n         * Called whenever a row of data is read from the corrupted database file.\n         *\n         * <p>The implementation can use the {@link Cursor} object from the argument to access\n         * the row data. Note that <b>no movement of the cursor is allowed</b>. The access is limited\n         * to the current row when callback method is called.</p>\n         *\n         * <p>The implementation tells the library how to deal with the current row by returning\n         * different values.\n         * <ul>\n         * <li>{@link #RESULT_OK} means output the row to the new database;</li>\n         * <li>{@link #RESULT_CANCELED} means the repairing method should return immediately with\n         * further iteration;</li>\n         * <li>{@link #RESULT_IGNORE} means ignore the current row and proceed to the next.</li>\n         * </ul></p>\n         *\n         * @param table  which table the row of data belong to\n         * @param root   root page of the table\n         * @param cursor cursor object to access the row data\n         * @return result code to tell the further operations\n         */\n        int onProgress(String table, int root, Cursor cursor);\n    }\n\n    private static class RepairCursor extends AbstractCursor {\n\n        @Override\n        public int getCount() {\n            throw new UnsupportedOperationException();\n        }\n\n        @Override\n        public String[] getColumnNames() {\n            throw new UnsupportedOperationException();\n        }\n\n        @Override\n        public int getColumnCount() {\n            return nativeGetColumnCount(mPtr);\n        }\n\n        @Override\n        public int getType(int column) {\n            return nativeGetType(mPtr, column);\n        }\n\n        @Override\n        public String getString(int column) {\n            return nativeGetString(mPtr, column);\n        }\n\n        @Override\n        public short getShort(int column) {\n            return (short) getLong(column);\n        }\n\n        @Override\n        public int getInt(int column) {\n            return (int) getLong(column);\n        }\n\n        @Override\n        public long getLong(int column) {\n            return nativeGetLong(mPtr, column);\n        }\n\n        @Override\n        public float getFloat(int column) {\n            return (float) getDouble(column);\n        }\n\n        @Override\n        public double getDouble(int column) {\n            return nativeGetDouble(mPtr, column);\n        }\n\n        @Override\n        public byte[] getBlob(int column) {\n            return nativeGetBlob(mPtr, column);\n        }\n\n        @Override\n        public boolean isNull(int column) {\n            return getType(column) == FIELD_TYPE_NULL;\n        }\n\n        long mPtr;\n        private static native int nativeGetColumnCount(long ptr);\n        private static native int nativeGetType(long ptr, int column);\n        private static native long nativeGetLong(long ptr, int column);\n        private static native double nativeGetDouble(long ptr, int column);\n        private static native String nativeGetString(long ptr, int column);\n        private static native byte[] nativeGetBlob(long ptr, int column);\n    }\n\n    private static native long nativeInit(String path, byte[] key, SQLiteCipherSpec cipherSpec,\n                                          byte[] salt);\n    private static native void nativeFini(long rkPtr);\n    private native int nativeOutput(long rkPtr, long dbPtr, long masterPtr, long leafPtr, int flags);\n    private static native void nativeCancel(long rkPtr);\n    private static native int nativeIntegrityFlags(long rkPtr);\n    private static native String nativeLastError();\n    private static native int[] nativeGetStatistics(long rkPtr);\n    private static native long nativeMakeMaster(String[] tables);\n    private static native boolean nativeSaveMaster(long dbPtr, String path, byte[] key);\n    private static native long nativeLoadMaster(String path, byte[] key, String[] tables,\n                                                byte[] outSalt);\n    private static native void nativeFreeMaster(long masterPtr);\n\n    private static native long nativeScanLeaf(long dbPtr, String[] tables, long[] outCancelFlag);\n    private static native void nativeCancelScanLeaf(long cancelFlagPtr);\n    private static native boolean nativeSaveLeaf(long leafPtr, String path);\n    private static native long nativeLoadLeaf(String path);\n    private static native void nativeFreeLeaf(long leafPtr);\n}\n"
  },
  {
    "path": "deprecated/android/wcdb/src/com/tencent/wcdb/support/CancellationSignal.java",
    "content": "/*\n * Copyright (C) 2012 The Android Open Source Project\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdb.support;\n\nimport android.os.RemoteException;\n\n/**\n * Provides the ability to cancel an operation in progress.\n */\npublic final class CancellationSignal {\n    private boolean mIsCanceled;\n    private OnCancelListener mOnCancelListener;\n    private ICancellationSignal mRemote;\n    private boolean mCancelInProgress;\n\n    /**\n     * Creates a cancellation signal, initially not canceled.\n     */\n    public CancellationSignal() {\n    }\n\n    /**\n     * Returns true if the operation has been canceled.\n     *\n     * @return True if the operation has been canceled.\n     */\n    public boolean isCanceled() {\n        synchronized (this) {\n            return mIsCanceled;\n        }\n    }\n\n    /**\n     * Throws {@link OperationCanceledException} if the operation has been canceled.\n     *\n     * @throws OperationCanceledException if the operation has been canceled.\n     */\n    public void throwIfCanceled() {\n        if (isCanceled()) {\n            throw new OperationCanceledException();\n        }\n    }\n\n    /**\n     * Cancels the operation and signals the cancellation listener.\n     * If the operation has not yet started, then it will be canceled as soon as it does.\n     */\n    public void cancel() {\n        final OnCancelListener listener;\n        final ICancellationSignal remote;\n        synchronized (this) {\n            if (mIsCanceled) {\n                return;\n            }\n            mIsCanceled = true;\n            mCancelInProgress = true;\n            listener = mOnCancelListener;\n            remote = mRemote;\n        }\n\n        try {\n            if (listener != null) {\n                listener.onCancel();\n            }\n            if (remote != null) {\n                try {\n                    remote.cancel();\n                } catch (RemoteException ex) {\n                }\n            }\n        } finally {\n            synchronized (this) {\n                mCancelInProgress = false;\n                notifyAll();\n            }\n        }\n    }\n\n    /**\n     * Sets the cancellation listener to be called when canceled.\n     *\n     * This method is intended to be used by the recipient of a cancellation signal\n     * such as a database or a content provider to handle cancellation requests\n     * while performing a long-running operation.  This method is not intended to be\n     * used by applications themselves.\n     *\n     * If {@link CancellationSignal#cancel} has already been called, then the provided\n     * listener is invoked immediately.\n     *\n     * This method is guaranteed that the listener will not be called after it\n     * has been removed.\n     *\n     * @param listener The cancellation listener, or null to remove the current listener.\n     */\n    public void setOnCancelListener(OnCancelListener listener) {\n        synchronized (this) {\n            waitForCancelFinishedLocked();\n\n            if (mOnCancelListener == listener) {\n                return;\n            }\n            mOnCancelListener = listener;\n            if (!mIsCanceled || listener == null) {\n                return;\n            }\n        }\n        listener.onCancel();\n    }\n\n    /**\n     * Sets the remote transport.\n     *\n     * If {@link CancellationSignal#cancel} has already been called, then the provided\n     * remote transport is canceled immediately.\n     *\n     * This method is guaranteed that the remote transport will not be called after it\n     * has been removed.\n     *\n     * @param remote The remote transport, or null to remove.\n     *\n     * @hide\n     */\n    public void setRemote(ICancellationSignal remote) {\n        synchronized (this) {\n            waitForCancelFinishedLocked();\n\n            if (mRemote == remote) {\n                return;\n            }\n            mRemote = remote;\n            if (!mIsCanceled || remote == null) {\n                return;\n            }\n        }\n        try {\n            remote.cancel();\n        } catch (RemoteException ex) {\n        }\n    }\n\n    private void waitForCancelFinishedLocked() {\n        while (mCancelInProgress) {\n            try {\n                wait();\n            } catch (InterruptedException ex) {\n            }\n        }\n    }\n\n    /**\n     * Creates a transport that can be returned back to the caller of\n     * a Binder function and subsequently used to dispatch a cancellation signal.\n     *\n     * @return The new cancellation signal transport.\n     *\n     * @hide\n     */\n    public static ICancellationSignal createTransport() {\n        return new Transport();\n    }\n\n    /**\n     * Given a locally created transport, returns its associated cancellation signal.\n     *\n     * @param transport The locally created transport, or null if none.\n     * @return The associated cancellation signal, or null if none.\n     *\n     * @hide\n     */\n    public static CancellationSignal fromTransport(ICancellationSignal transport) {\n        if (transport instanceof Transport) {\n            return ((Transport)transport).mCancellationSignal;\n        }\n        return null;\n    }\n\n    /**\n     * Listens for cancellation.\n     */\n    public interface OnCancelListener {\n        /**\n         * Called when {@link CancellationSignal#cancel} is invoked.\n         */\n        void onCancel();\n    }\n\n    private static final class Transport extends ICancellationSignal.Stub {\n        final CancellationSignal mCancellationSignal = new CancellationSignal();\n\n        @Override\n        public void cancel() throws RemoteException {\n            mCancellationSignal.cancel();\n        }\n    }\n}\n"
  },
  {
    "path": "deprecated/android/wcdb/src/com/tencent/wcdb/support/Context.java",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdb.support;\n\nimport java.io.File;\n\nimport com.tencent.wcdb.DatabaseErrorHandler;\nimport com.tencent.wcdb.FileUtils;\nimport com.tencent.wcdb.database.SQLiteCipherSpec;\nimport com.tencent.wcdb.database.SQLiteDatabase;\nimport com.tencent.wcdb.database.SQLiteDatabase.CursorFactory;\nimport com.tencent.wcdb.database.SQLiteGlobal;\n\n/**\n * Wrapper class to implement database opening methods as {@link android.content.Context}\n * does.\n */\npublic final class Context {\n\n\tstatic {\n\t\t// Ensure libwcdb.so is loaded.\n\t\tSQLiteGlobal.initialize();\n\t}\n\n\tprivate static File getDataDirFile(android.content.Context context) {\n\t\tif (context != null) {\n\t\t\tfinal String mDataDir = context.getApplicationInfo().dataDir;\n\t\t\tfinal File mDataDirFile = mDataDir != null ? new File(mDataDir) : null;\n\t\t\treturn mDataDirFile;\n\t\t}\n\t\tthrow new RuntimeException(\"Not supported in system context\");\n\t}\n\n\tprivate static File getDatabasesDir(android.content.Context context) {\n\t\tFile mDatabasesDir = new File(getDataDirFile(context), \"databases\");\n\t\tif (mDatabasesDir.getPath().equals(\"databases\")) {\n\t\t\tmDatabasesDir = new File(\"/data/system\");\n\t\t}\n\t\treturn mDatabasesDir;\n\t}\n\n\tprivate static File makeFilename(File base, String name) {\n\t\tif (name.indexOf(File.separatorChar) < 0) {\n\t\t\treturn new File(base, name);\n\t\t}\n\t\tthrow new IllegalArgumentException(\"File \" + name + \" contains a path separator\");\n\t}\n\n\tprivate static File validateFilePath(android.content.Context context, String name,\n\t\t\tboolean createDirectory) {\n\t\tFile dir;\n\t\tFile f;\n\n\t\tif (name.charAt(0) == File.separatorChar) {\n\t\t\tString dirPath = name.substring(0, name.lastIndexOf(File.separatorChar));\n\t\t\tdir = new File(dirPath);\n\t\t\tname = name.substring(name.lastIndexOf(File.separatorChar));\n\t\t\tf = new File(dir, name);\n\t\t} else {\n\t\t\tdir = getDatabasesDir(context);\n\t\t\tf = makeFilename(dir, name);\n\t\t}\n\n\t\tif (createDirectory && !dir.isDirectory() && dir.mkdir()) {\n\t\t\tFileUtils.setPermissions(dir.getPath(), FileUtils.S_IRWXU | FileUtils.S_IRWXG\n\t\t\t\t\t| FileUtils.S_IXOTH, -1, -1);\n\t\t}\n\n\t\treturn f;\n\t}\n\n\tprivate static void setFilePermissionsFromMode(String name, int mode, int extraPermissions) {\n\t\tint perms = FileUtils.S_IRUSR | FileUtils.S_IWUSR | FileUtils.S_IRGRP | FileUtils.S_IWGRP\n\t\t\t\t| extraPermissions;\n\t\tif ((mode & android.content.Context.MODE_WORLD_READABLE) != 0) {\n\t\t\tperms |= FileUtils.S_IROTH;\n\t\t}\n\t\tif ((mode & android.content.Context.MODE_WORLD_WRITEABLE) != 0) {\n\t\t\tperms |= FileUtils.S_IWOTH;\n\t\t}\n\t\tFileUtils.setPermissions(name, perms, -1, -1);\n\t}\n\n\tpublic static final int MODE_ENABLE_WRITE_AHEAD_LOGGING = 0x0008;\n\n\t/**\n\t * Open a new private SQLiteDatabase associated with this Context's\n\t * application package. Create the database file if it doesn't exist.\n\t *\n\t * @param name The name (unique in the application package) of the database.\n\t * @param mode Operating mode. Use 0 or {@link android.content.Context#MODE_PRIVATE} for the\n\t *            default operation. Use\n\t *            {@link android.content.Context#MODE_ENABLE_WRITE_AHEAD_LOGGING} to enable write-ahead\n\t *            logging by default. Use {@link android.content.Context#MODE_NO_LOCALIZED_COLLATORS}\n\t *            to disable localized collators.\n\t * @param factory An optional factory class that is called to instantiate a\n\t *            cursor when query is called.\n\t * @return The contents of a newly created database with the given name.\n\t * @throws android.database.sqlite.SQLiteException if the database file\n\t *             could not be opened.\n\t */\n\tpublic static SQLiteDatabase openOrCreateDatabase(android.content.Context context, String name, int mode,\n\t\t\tCursorFactory factory) {\n\t\treturn openOrCreateDatabase(context, name, null, null, mode, factory, null, 0);\n\t}\n\n\tpublic static SQLiteDatabase openOrCreateDatabase(android.content.Context context, String name, int mode,\n\t\t\tCursorFactory factory, DatabaseErrorHandler errorHandler) {\n\t\treturn openOrCreateDatabase(context, name, null, null, mode, factory, errorHandler, 0);\n\t}\n\n\tpublic static SQLiteDatabase openOrCreateDatabase(android.content.Context context, String name,\n\t\t\tbyte[] password, SQLiteCipherSpec cipher, int mode, CursorFactory factory) {\n\t\treturn openOrCreateDatabase(context, name, password, cipher, mode,\n\t\t\t\tfactory, null, 0);\n\t}\n\n\tpublic static SQLiteDatabase openOrCreateDatabase(android.content.Context context, String name,\n\t\t\tbyte[] password, SQLiteCipherSpec cipher, int mode, CursorFactory factory,\n\t\t\tDatabaseErrorHandler errorHandler) {\n\t\treturn openOrCreateDatabase(context, name, password, cipher, mode, factory, errorHandler, 0);\n\t}\n\n\tpublic static SQLiteDatabase openOrCreateDatabase(android.content.Context context, String name,\n\t\t\tbyte[] password, SQLiteCipherSpec cipher, int mode, CursorFactory factory,\n\t\t\tDatabaseErrorHandler errorHandler, int poolSize) {\n\t\tFile f = validateFilePath(context, name, true);\n\t\tint flags = SQLiteDatabase.CREATE_IF_NECESSARY;\n\t\tif ((mode & MODE_ENABLE_WRITE_AHEAD_LOGGING) != 0) {\n\t\t\tflags |= SQLiteDatabase.ENABLE_WRITE_AHEAD_LOGGING;\n\t\t}\n\n\t\tSQLiteDatabase db = SQLiteDatabase.openDatabase(f.getPath(), password, cipher, factory, flags,\n\t\t\t\terrorHandler, poolSize);\n\n\t\tsetFilePermissionsFromMode(f.getPath(), mode, 0);\n\t\treturn db;\n\t}\n}\n"
  },
  {
    "path": "deprecated/android/wcdb/src/com/tencent/wcdb/support/ICancellationSignal.aidl",
    "content": "/*\n * Copyright (C) 2012 The Android Open Source Project\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdb.support;\n\n/**\n * @hide\n */\ninterface ICancellationSignal {\n    oneway void cancel();\n}\n"
  },
  {
    "path": "deprecated/android/wcdb/src/com/tencent/wcdb/support/Log.java",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdb.support;\n\n/**\n * API for WCDB log redirection.\n *\n * <p>Typically, applications call {@link #setLogger(int)} or {@link #setLogger(LogCallback)}\n * to setup logger callback, WCDB library itself uses the rest methods to\n * send log outputs to the preset or user defined logger.</p>\n */\npublic class Log {\n\t\n\tprivate Log() {}\n\n\t/**\n\t * Preset No-op logger which drops all log outputs.\n\t * Pass it to {@link #setLogger(int)}.\n\t */\n\tpublic static final int LOGGER_NONE = 0;\n\n\t/**\n\t * Default logger which output logs to Android system log (logcat).\n\t * Pass it to {@link #setLogger(int)}.\n\t */\n\tpublic static final int LOGGER_DEFAULT = 1;\n\n\n\t/**\n\t * User defined logger interface. Implement this interface and pass\n\t * an instance to {@link #setLogger(LogCallback)} to redirect log\n\t * outputs to custom loggers.\n\t */\n\tpublic interface LogCallback {\n\n\t\t/**\n\t\t * Called whenever a log is being written.\n\t\t * @param priority\tthe priority of this log message. Use constants in Android\n\t\t *                  logging API, {@link android.util.Log}\n\t\t * @param tag\t\ttag of this log message\n\t\t * @param msg\t\tmessage content\n\t\t */\n\t\tvoid println(int priority, String tag, String msg);\n\t}\n\n\tprivate static LogCallback mCallback = null;\n\n\n\tprivate static native void nativeSetLogger(int logger, LogCallback callback);\n\tprivate static native void nativePrintLn(int priority, String tag, String msg);\n\n\t/**\n\t * Use preset logger for log outputs.\n\t *\n\t * @param logger\tpreset logger, valid values are\n\t *                  <ol>\n\t *                  <li>{@link #LOGGER_NONE}</li>\n\t *                  <li>{@link #LOGGER_DEFAULT}</li>\n\t *                  </ol>\n\t */\n\tpublic static void setLogger(int logger) {\n\t\tmCallback = null;\n\t\tnativeSetLogger(logger, null);\n\t}\n\n\t/**\n\t * Use user defined logger for log outputs.\n\t *\n\t * @param callback\tlogger callback\n\t */\n\tpublic static void setLogger(LogCallback callback) {\n\t\tmCallback = callback;\n\t\tnativeSetLogger(-1, callback);\n\t}\n\n\t/**\n\t * Low-level logging call. Typically called by WCDB library itself.\n\t *\n\t * @param priority\tthe priority of this log message. Use constants in Android\n\t *                  logging API, {@link android.util.Log}\n\t * @param tag\t\ttag of this log message\n\t * @param msg\t\tmessage content\n\t */\n\tpublic static void println(int priority, String tag, String msg) {\n\t\tif (mCallback != null)\n\t\t\tmCallback.println(priority, tag, msg);\n\t\telse\n\t\t\tnativePrintLn(priority, tag, msg);\n\t}\n\n\t/**\n\t * Send a FATAL log message. Typically called by WCDB library itself.\n \t *\n\t * @param tag\ttag of this log message\n\t * @param msg\tmessage content\n\t */\n\tpublic static void f(final String tag, final String msg) {\n\t\tprintln(android.util.Log.ASSERT, tag, msg);\n\t}\n\n\t/**\n\t * Send an ERROR log message. Typically called by WCDB library itself.\n\t *\n\t * @param tag\ttag of this log message\n\t * @param msg\tmessage content\n\t */\n\tpublic static void e(final String tag, final String msg) {\n\t\tprintln(android.util.Log.ERROR, tag, msg);\n\t}\n\n\t/**\n\t * Send a WARN log message. Typically called by WCDB library itself.\n\t *\n\t * @param tag\ttag of this log message\n\t * @param msg\tmessage content\n\t */\n\tpublic static void w(final String tag, final String msg) {\n\t\tprintln(android.util.Log.WARN, tag, msg);\n\t}\n\n\t/**\n\t * Send an INFO log message. Typically called by WCDB library itself.\n\t *\n\t * @param tag\ttag of this log message\n\t * @param msg\tmessage content\n\t */\n\tpublic static void i(final String tag, final String msg) {\n\t\tprintln(android.util.Log.INFO, tag, msg);\n\t}\n\n\t/**\n\t * Send a DEBUG log message. Typically called by WCDB library itself.\n\t *\n\t * @param tag\ttag of this log message\n\t * @param msg\tmessage content\n\t */\n\tpublic static void d(final String tag, final String msg) {\n\t\tprintln(android.util.Log.DEBUG, tag, msg);\n\t}\n\n\t/**\n\t * Send a VERBOSE log message. Typically called by WCDB library itself.\n\t *\n\t * @param tag\ttag of this log message\n\t * @param msg\tmessage content\n\t */\n\tpublic static void v(final String tag, final String msg) {\n\t\tprintln(android.util.Log.VERBOSE, tag, msg);\n\t}\n\n\t/**\n\t * Send a FATAL log message with string formatter.\n\t * Typically called by WCDB library itself.\n\t *\n\t * @param tag\t\ttag of this log message\n\t * @param format\tmessage content\n\t * @param args \t\tformat arguments\n\t */\n\tpublic static void f(final String tag, final String format, final Object... args) {\n\t\tprintln(android.util.Log.ASSERT, tag, String.format(format, args));\n\t}\n\n\t/**\n\t * Send an ERROR log message with string formatter.\n\t * Typically called by WCDB library itself.\n\t *\n\t * @param tag\t\ttag of this log message\n\t * @param format\tmessage content\n\t * @param args \t\tformat arguments\n\t */\n\tpublic static void e(final String tag, final String format, final Object... args) {\n\t\tprintln(android.util.Log.ERROR, tag, String.format(format, args));\n\t}\n\n\t/**\n\t * Send a WARN log message with string formatter.\n\t * Typically called by WCDB library itself.\n\t *\n\t * @param tag\t\ttag of this log message\n\t * @param format\tmessage content\n\t * @param args \t\tformat arguments\n\t */\n\tpublic static void w(final String tag, final String format, final Object... args) {\n\t\tprintln(android.util.Log.WARN, tag, String.format(format, args));\n\t}\n\n\t/**\n\t * Send an INFO log message with string formatter.\n\t * Typically called by WCDB library itself.\n\t *\n\t * @param tag\t\ttag of this log message\n\t * @param format\tmessage content\n\t * @param args \t\tformat arguments\n\t */\n\tpublic static void i(final String tag, final String format, final Object... args) {\n\t\tprintln(android.util.Log.INFO, tag, String.format(format, args));\n\t}\n\n\t/**\n\t * Send a DEBUG log message with string formatter.\n\t * Typically called by WCDB library itself.\n\t *\n\t * @param tag\t\ttag of this log message\n\t * @param format\tmessage content\n\t * @param args \t\tformat arguments\n\t */\n\tpublic static void d(final String tag, final String format, final Object... args) {\n\t\tprintln(android.util.Log.DEBUG, tag, String.format(format, args));\n\t}\n\n\t/**\n\t * Send a VERBOSE log message with string formatter.\n\t * Typically called by WCDB library itself.\n\t *\n\t * @param tag\t\ttag of this log message\n\t * @param format\tmessage content\n\t * @param args \t\tformat arguments\n\t */\n\tpublic static void v(final String tag, final String format, final Object... args) {\n\t\tprintln(android.util.Log.VERBOSE, tag, String.format(format, args));\n\t}\n\n}\n\n"
  },
  {
    "path": "deprecated/android/wcdb/src/com/tencent/wcdb/support/LogPrinter.java",
    "content": "/*\n * Copyright (C) 2006 The Android Open Source Project\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdb.support;\n\nimport android.util.Printer;\n\n/**\n * Implementation of a {@link android.util.Printer} that sends its output\n * to the system log.\n *\n * <p>Modified from Android source to print logs to redirection layer\n * rather than logcat.</p>\n */\npublic class LogPrinter implements Printer {\n    private final int mPriority;\n    private final String mTag;\n\n    /**\n     * Create a new Printer that sends to the log with the given priority\n     * and tag.\n     *\n     * @param priority The desired log priority:\n     * {@link android.util.Log#VERBOSE Log.VERBOSE},\n     * {@link android.util.Log#DEBUG Log.DEBUG},\n     * {@link android.util.Log#INFO Log.INFO},\n     * {@link android.util.Log#WARN Log.WARN}, or\n     * {@link android.util.Log#ERROR Log.ERROR}.\n     * @param tag A string tag to associate with each printed log statement.\n     */\n    public LogPrinter(int priority, String tag) {\n        mPriority = priority;\n        mTag = tag;\n    }\n\n    public void println(String x) {\n        Log.println(mPriority, mTag, x);\n    }\n}"
  },
  {
    "path": "deprecated/android/wcdb/src/com/tencent/wcdb/support/LruCache.java",
    "content": "/*\n * Copyright (C) 2011 The Android Open Source Project\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdb.support;\n\nimport android.annotation.SuppressLint;\n\nimport java.util.LinkedHashMap;\nimport java.util.Map;\n\n/**\n * A cache that holds strong references to a limited number of values. Each time\n * a value is accessed, it is moved to the head of a queue. When a value is\n * added to a full cache, the value at the end of that queue is evicted and may\n * become eligible for garbage collection.\n *\n * <p>If your cached values hold resources that need to be explicitly released,\n * override {@link #entryRemoved}.\n *\n * <p>If a cache miss should be computed on demand for the corresponding keys,\n * override {@link #create}. This simplifies the calling code, allowing it to\n * assume a value will always be returned, even when there's a cache miss.\n *\n * <p>By default, the cache size is measured in the number of entries. Override\n * {@link #sizeOf} to size the cache in different units. For example, this cache\n * is limited to 4MiB of bitmaps:\n * <pre>   {@code\n *   int cacheSize = 4 * 1024 * 1024; // 4MiB\n *   LruCache<String, Bitmap> bitmapCache = new LruCache<String, Bitmap>(cacheSize) {\n *       protected int sizeOf(String key, Bitmap value) {\n *           return value.getByteCount();\n *       }\n *   }}</pre>\n *\n * <p>This class is thread-safe. Perform multiple cache operations atomically by\n * synchronizing on the cache: <pre>   {@code\n *   synchronized (cache) {\n *     if (cache.get(key) == null) {\n *         cache.put(key, value);\n *     }\n *   }}</pre>\n *\n * <p>This class does not allow null to be used as a key or value. A return\n * value of null from {@link #get}, {@link #put} or {@link #remove} is\n * unambiguous: the key was not in the cache.\n *\n * <p>This class appeared in Android 3.1 (Honeycomb MR1); it's available as part\n * of <a href=\"http://developer.android.com/sdk/compatibility-library.html\">Android's\n * Support Package</a> for earlier releases.\n *\n * @hide\n */\npublic class LruCache<K, V> {\n    private final LinkedHashMap<K, V> map;\n\n    /** Size of this cache in units. Not necessarily the number of elements. */\n    private int size;\n    private int maxSize;\n\n    private int putCount;\n    private int createCount;\n    private int evictionCount;\n    private int hitCount;\n    private int missCount;\n\n    /**\n     * @param maxSize for caches that do not override {@link #sizeOf}, this is\n     *     the maximum number of entries in the cache. For all other caches,\n     *     this is the maximum sum of the sizes of the entries in this cache.\n     */\n    public LruCache(int maxSize) {\n        if (maxSize <= 0) {\n            throw new IllegalArgumentException(\"maxSize <= 0\");\n        }\n        this.maxSize = maxSize;\n        this.map = new LinkedHashMap<K, V>(0, 0.75f, true);\n    }\n\n    /**\n     * Sets the size of the cache.\n     * @param maxSize The new maximum size.\n     *\n     * @hide\n     */\n    public void resize(int maxSize) {\n        if (maxSize <= 0) {\n            throw new IllegalArgumentException(\"maxSize <= 0\");\n        }\n\n        synchronized (this) {\n            this.maxSize = maxSize;\n        }\n        trimToSize(maxSize);\n    }\n\n    /**\n     * Returns the value for {@code key} if it exists in the cache or can be\n     * created by {@code #create}. If a value was returned, it is moved to the\n     * head of the queue. This returns null if a value is not cached and cannot\n     * be created.\n     */\n    public final V get(K key) {\n        if (key == null) {\n            throw new NullPointerException(\"key == null\");\n        }\n\n        V mapValue;\n        synchronized (this) {\n            mapValue = map.get(key);\n            if (mapValue != null) {\n                hitCount++;\n                return mapValue;\n            }\n            missCount++;\n        }\n\n        /*\n         * Attempt to create a value. This may take a long time, and the map\n         * may be different when create() returns. If a conflicting value was\n         * added to the map while create() was working, we leave that value in\n         * the map and release the created value.\n         */\n\n        V createdValue = create(key);\n        if (createdValue == null) {\n            return null;\n        }\n\n        synchronized (this) {\n            createCount++;\n            mapValue = map.put(key, createdValue);\n\n            if (mapValue != null) {\n                // There was a conflict so undo that last put\n                map.put(key, mapValue);\n            } else {\n                size += safeSizeOf(key, createdValue);\n            }\n        }\n\n        if (mapValue != null) {\n            entryRemoved(false, key, createdValue, mapValue);\n            return mapValue;\n        } else {\n            trimToSize(maxSize);\n            return createdValue;\n        }\n    }\n\n    /**\n     * Caches {@code value} for {@code key}. The value is moved to the head of\n     * the queue.\n     *\n     * @return the previous value mapped by {@code key}.\n     */\n    public final V put(K key, V value) {\n        if (key == null || value == null) {\n            throw new NullPointerException(\"key == null || value == null\");\n        }\n\n        V previous;\n        synchronized (this) {\n            putCount++;\n            size += safeSizeOf(key, value);\n            previous = map.put(key, value);\n            if (previous != null) {\n                size -= safeSizeOf(key, previous);\n            }\n        }\n\n        if (previous != null) {\n            entryRemoved(false, key, previous, value);\n        }\n\n        trimToSize(maxSize);\n        return previous;\n    }\n\n    /**\n     * Remove the eldest entries until the total of remaining entries is at or\n     * below the requested size.\n     *\n     * @param maxSize the maximum size of the cache before returning. May be -1\n     *            to evict even 0-sized elements.\n     */\n    public void trimToSize(int maxSize) {\n        while (true) {\n            K key;\n            V value;\n            synchronized (this) {\n                if (size < 0 || (map.isEmpty() && size != 0)) {\n                    throw new IllegalStateException(getClass().getName()\n                            + \".sizeOf() is reporting inconsistent results!\");\n                }\n\n                if (size <= maxSize || map.isEmpty()) {\n                    break;\n                }\n\n                Map.Entry<K, V> toEvict=null;\n                if(map.entrySet().iterator().hasNext()){\n                    toEvict= map.entrySet().iterator().next();\n                }\n\n                if (toEvict == null) {\n                    break;\n                }\n\n                key = toEvict.getKey();\n                value = toEvict.getValue();\n                map.remove(key);\n                size -= safeSizeOf(key, value);\n                evictionCount++;\n            }\n\n            entryRemoved(true, key, value, null);\n        }\n    }\n\n    /**\n     * Removes the entry for {@code key} if it exists.\n     *\n     * @return the previous value mapped by {@code key}.\n     */\n    public final V remove(K key) {\n        if (key == null) {\n            throw new NullPointerException(\"key == null\");\n        }\n\n        V previous;\n        synchronized (this) {\n            previous = map.remove(key);\n            if (previous != null) {\n                size -= safeSizeOf(key, previous);\n            }\n        }\n\n        if (previous != null) {\n            entryRemoved(false, key, previous, null);\n        }\n\n        return previous;\n    }\n\n    /**\n     * Called for entries that have been evicted or removed. This method is\n     * invoked when a value is evicted to make space, removed by a call to\n     * {@link #remove}, or replaced by a call to {@link #put}. The default\n     * implementation does nothing.\n     *\n     * <p>The method is called without synchronization: other threads may\n     * access the cache while this method is executing.\n     *\n     * @param evicted true if the entry is being removed to make space, false\n     *     if the removal was caused by a {@link #put} or {@link #remove}.\n     * @param newValue the new value for {@code key}, if it exists. If non-null,\n     *     this removal was caused by a {@link #put}. Otherwise it was caused by\n     *     an eviction or a {@link #remove}.\n     */\n    protected void entryRemoved(boolean evicted, K key, V oldValue, V newValue) {}\n\n    /**\n     * Called after a cache miss to compute a value for the corresponding key.\n     * Returns the computed value or null if no value can be computed. The\n     * default implementation returns null.\n     *\n     * <p>The method is called without synchronization: other threads may\n     * access the cache while this method is executing.\n     *\n     * <p>If a value for {@code key} exists in the cache when this method\n     * returns, the created value will be released with {@link #entryRemoved}\n     * and discarded. This can occur when multiple threads request the same key\n     * at the same time (causing multiple values to be created), or when one\n     * thread calls {@link #put} while another is creating a value for the same\n     * key.\n     */\n    protected V create(K key) {\n        return null;\n    }\n\n    private int safeSizeOf(K key, V value) {\n        int result = sizeOf(key, value);\n        if (result < 0) {\n            throw new IllegalStateException(\"Negative size: \" + key + \"=\" + value);\n        }\n        return result;\n    }\n\n    /**\n     * Returns the size of the entry for {@code key} and {@code value} in\n     * user-defined units.  The default implementation returns 1 so that size\n     * is the number of entries and max size is the maximum number of entries.\n     *\n     * <p>An entry's size must not change while it is in the cache.\n     */\n    protected int sizeOf(K key, V value) {\n        return 1;\n    }\n\n    /**\n     * Clear the cache, calling {@link #entryRemoved} on each removed entry.\n     */\n    public final void evictAll() {\n        trimToSize(-1); // -1 will evict 0-sized elements\n    }\n\n    /**\n     * For caches that do not override {@link #sizeOf}, this returns the number\n     * of entries in the cache. For all other caches, this returns the sum of\n     * the sizes of the entries in this cache.\n     */\n    public synchronized final int size() {\n        return size;\n    }\n\n    /**\n     * For caches that do not override {@link #sizeOf}, this returns the maximum\n     * number of entries in the cache. For all other caches, this returns the\n     * maximum sum of the sizes of the entries in this cache.\n     */\n    public synchronized final int maxSize() {\n        return maxSize;\n    }\n\n    /**\n     * Returns the number of times {@link #get} returned a value that was\n     * already present in the cache.\n     */\n    public synchronized final int hitCount() {\n        return hitCount;\n    }\n\n    /**\n     * Returns the number of times {@link #get} returned null or required a new\n     * value to be created.\n     */\n    public synchronized final int missCount() {\n        return missCount;\n    }\n\n    /**\n     * Returns the number of times {@link #create(Object)} returned a value.\n     */\n    public synchronized final int createCount() {\n        return createCount;\n    }\n\n    /**\n     * Returns the number of times {@link #put} was called.\n     */\n    public synchronized final int putCount() {\n        return putCount;\n    }\n\n    /**\n     * Returns the number of values that have been evicted.\n     */\n    public synchronized final int evictionCount() {\n        return evictionCount;\n    }\n\n    /**\n     * Returns a copy of the current contents of the cache, ordered from least\n     * recently accessed to most recently accessed.\n     */\n    public synchronized final Map<K, V> snapshot() {\n        return new LinkedHashMap<K, V>(map);\n    }\n\n    @Override\n    @SuppressLint(\"DefaultLocale\")\n    public synchronized final String toString() {\n        int accesses = hitCount + missCount;\n        int hitPercent = accesses != 0 ? (100 * hitCount / accesses) : 0;\n        return String.format(\"LruCache[maxSize=%d,hits=%d,misses=%d,hitRate=%d%%]\",\n                maxSize, hitCount, missCount, hitPercent);\n    }\n}\n"
  },
  {
    "path": "deprecated/android/wcdb/src/com/tencent/wcdb/support/OperationCanceledException.java",
    "content": "/*\n * Copyright (C) 2012 The Android Open Source Project\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdb.support;\n\n\n/**\n * An exception type that is thrown when an operation in progress is canceled.\n *\n * @see CancellationSignal\n */\n@SuppressWarnings(\"serial\")\npublic class OperationCanceledException extends RuntimeException {\n    public OperationCanceledException() {\n        this(null);\n    }\n\n    public OperationCanceledException(String message) {\n        super(message != null ? message : \"The operation has been canceled.\");\n    }\n}\n"
  },
  {
    "path": "deprecated/android/wcdb/src/com/tencent/wcdb/support/PrefixPrinter.java",
    "content": "/*\n * Copyright (C) 2010 The Android Open Source Project\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdb.support;\n\nimport android.util.Printer;\n\n/**\n * PrefixPrinter is a Printer which prefixes all lines with a given\n * prefix.\n *\n * @hide\n */\npublic class PrefixPrinter implements Printer {\n    private final Printer mPrinter;\n    private final String mPrefix;\n\n    /**\n     * Creates a new PrefixPrinter.\n     *\n     * <p>If prefix is null or empty, the provided printer is returned, rather\n     * than making a prefixing printer.\n     */\n    public static Printer create(Printer printer, String prefix) {\n        if (prefix == null || prefix.equals(\"\")) {\n            return printer;\n        }\n        return new PrefixPrinter(printer, prefix);\n    }\n\n    private PrefixPrinter(Printer printer, String prefix) {\n        mPrinter = printer;\n        mPrefix = prefix;\n    }\n\n    public void println(String str) {\n        mPrinter.println(mPrefix + str);\n    }\n}"
  },
  {
    "path": "src/CMakeLists.txt",
    "content": "cmake_minimum_required(VERSION 3.13)\nproject(WCDB)\n\ninclude(utility.cmake)\ninclude(../sqlcipher/sqlcipher.cmake)\n\nif (NOT DEFINED WCDB_ZSTD)\n    set(WCDB_ZSTD ON CACHE BOOL \"Build WCDB with zstd\" FORCE)\nendif ()\n\nset(WCONAN_CMAKE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../WeChat/wconan.cmake)\nif (NOT SKIP_WCONAN AND EXISTS ${WCONAN_CMAKE_PATH})\n    message(STATUS \"${WCONAN_CMAKE_PATH} found.\")\n    set(WCONAN_MODE ON CACHE BOOL \"Build with wconan\" FORCE)\n    include(${WCONAN_CMAKE_PATH})\nendif ()\n\nif (NOT ANDROID OR WCONAN_MODE OR NOT DEFINED WCDB_CPP)\n    set(WCDB_CPP ON CACHE BOOL \"Build WCDB with cpp interface\" FORCE)\nendif ()\n\n# Hide symbols by default\nset(CMAKE_CXX_VISIBILITY_PRESET hidden)\nset(CMAKE_C_VISIBILITY_PRESET hidden)\n\n# Add debug info\nset(CMAKE_CXX_FLAGS \"${CMAKE_CXX_FLAGS} -g\")\nset(CMAKE_C_FLAGS \"${CMAKE_C_FLAGS} -g\")\n\nset(WCDB_SRC_DIR ${CMAKE_CURRENT_LIST_DIR})\n\nfile(GLOB_RECURSE WCDB_COMMON_SRC\n    ${WCDB_SRC_DIR}/common/*.c\n    ${WCDB_SRC_DIR}/common/*.cpp\n    ${WCDB_SRC_DIR}/common/*.h\n    ${WCDB_SRC_DIR}/common/*.hpp\n)\nrecursive_subdirs(WCDB_COMMON_INCLUDES ${WCDB_SRC_DIR}/common)\n\nfile(GLOB_RECURSE WCDB_CPP_SRC\n    ${WCDB_SRC_DIR}/cpp/*.c\n    ${WCDB_SRC_DIR}/cpp/*.cpp\n    ${WCDB_SRC_DIR}/cpp/*.h\n    ${WCDB_SRC_DIR}/cpp/*.hpp\n)\nlist(FILTER WCDB_CPP_SRC EXCLUDE REGEX \"(.*/tests/.*)\")\nrecursive_subdirs(WCDB_CPP_INCLUDES ${WCDB_SRC_DIR}/cpp)\n\nfile(GLOB_RECURSE WCDB_BRIDGE_SRC\n    ${WCDB_SRC_DIR}/bridge/base/*.[ch]\n    ${WCDB_SRC_DIR}/bridge/base/*.[ch]pp\n    ${WCDB_SRC_DIR}/bridge/cppbridge/*.[ch]\n    ${WCDB_SRC_DIR}/bridge/cppbridge/*.[ch]pp\n    ${WCDB_SRC_DIR}/bridge/winqbridge/*.[ch]\n    ${WCDB_SRC_DIR}/bridge/winqbridge/*.[ch]pp\n)\nrecursive_subdirs(WCDB_BRIDGE_INCLUDES ${WCDB_SRC_DIR}/bridge)\n\n# Copy all headers to include folder\nfile(GLOB_RECURSE WCDB_PUBLIC_HEADERS\n    ${WCDB_SRC_DIR}/common/*/AggregateFunction.hpp\n    ${WCDB_SRC_DIR}/common/*/AuxiliaryFunctionModule.hpp\n    ${WCDB_SRC_DIR}/common/*/BaseBinding.hpp\n    ${WCDB_SRC_DIR}/common/*/BaseTokenizerUtil.hpp\n    ${WCDB_SRC_DIR}/common/*/BindParameter.hpp\n    ${WCDB_SRC_DIR}/common/*/CaseInsensitiveList.hpp\n    ${WCDB_SRC_DIR}/common/*/Column.hpp\n    ${WCDB_SRC_DIR}/common/*/ColumnConstraint.hpp\n    ${WCDB_SRC_DIR}/common/*/ColumnDef.hpp\n    ${WCDB_SRC_DIR}/common/*/ColumnType.hpp\n    ${WCDB_SRC_DIR}/common/*/CommonTableExpression.hpp\n    ${WCDB_SRC_DIR}/common/*/Convertible.hpp\n    ${WCDB_SRC_DIR}/common/*/ConvertibleImplementation.hpp\n    ${WCDB_SRC_DIR}/common/*/CoreFunction.hpp\n    ${WCDB_SRC_DIR}/common/*/Data.hpp\n    ${WCDB_SRC_DIR}/common/*/WCDBError.hpp\n    ${WCDB_SRC_DIR}/common/*/Expression.hpp\n    ${WCDB_SRC_DIR}/common/*/ExpressionOperable.hpp\n    ${WCDB_SRC_DIR}/common/*/Filter.hpp\n    ${WCDB_SRC_DIR}/common/*/ForeignKey.hpp\n    ${WCDB_SRC_DIR}/common/*/FrameSpec.hpp\n    ${WCDB_SRC_DIR}/common/*/FTSFunction.hpp\n    ${WCDB_SRC_DIR}/common/*/FTS5AuxiliaryFunctionTemplate.hpp\n    ${WCDB_SRC_DIR}/common/*/FTSConst.h\n    ${WCDB_SRC_DIR}/common/*/FTSError.hpp\n    ${WCDB_SRC_DIR}/common/*/IndexedColumn.hpp\n    ${WCDB_SRC_DIR}/common/*/Join.hpp\n    ${WCDB_SRC_DIR}/common/*/JoinConstraint.hpp\n    ${WCDB_SRC_DIR}/common/*/LiteralValue.hpp\n    ${WCDB_SRC_DIR}/common/*/Macro.h\n    ${WCDB_SRC_DIR}/common/*/MemberPointer.hpp\n    ${WCDB_SRC_DIR}/common/*/OneOrBinaryTokenizer.hpp\n    ${WCDB_SRC_DIR}/common/*/OrderingTerm.hpp\n    ${WCDB_SRC_DIR}/common/*/Pragma.hpp\n    ${WCDB_SRC_DIR}/common/*/QualifiedTable.hpp\n    ${WCDB_SRC_DIR}/common/*/RaiseFunction.hpp\n    ${WCDB_SRC_DIR}/common/*/Recyclable.hpp\n    ${WCDB_SRC_DIR}/common/*/RecyclableHandle.hpp\n    ${WCDB_SRC_DIR}/common/*/ResultColumn.hpp\n    ${WCDB_SRC_DIR}/common/*/ScalarFunctionModule.hpp\n    ${WCDB_SRC_DIR}/common/*/ScalarFunctionTemplate.hpp\n    ${WCDB_SRC_DIR}/common/*/Schema.hpp\n    ${WCDB_SRC_DIR}/common/*/Shadow.hpp\n    ${WCDB_SRC_DIR}/common/*/SharedThreadedErrorProne.hpp\n    ${WCDB_SRC_DIR}/common/*/SQL.hpp\n    ${WCDB_SRC_DIR}/common/*/Statement.hpp\n    ${WCDB_SRC_DIR}/common/*/StatementAlterTable.hpp\n    ${WCDB_SRC_DIR}/common/*/StatementAnalyze.hpp\n    ${WCDB_SRC_DIR}/common/*/StatementAttach.hpp\n    ${WCDB_SRC_DIR}/common/*/StatementBegin.hpp\n    ${WCDB_SRC_DIR}/common/*/StatementCommit.hpp\n    ${WCDB_SRC_DIR}/common/*/StatementCreateIndex.hpp\n    ${WCDB_SRC_DIR}/common/*/StatementCreateTable.hpp\n    ${WCDB_SRC_DIR}/common/*/StatementCreateTrigger.hpp\n    ${WCDB_SRC_DIR}/common/*/StatementCreateView.hpp\n    ${WCDB_SRC_DIR}/common/*/StatementCreateVirtualTable.hpp\n    ${WCDB_SRC_DIR}/common/*/StatementDelete.hpp\n    ${WCDB_SRC_DIR}/common/*/StatementDetach.hpp\n    ${WCDB_SRC_DIR}/common/*/StatementDropIndex.hpp\n    ${WCDB_SRC_DIR}/common/*/StatementDropTable.hpp\n    ${WCDB_SRC_DIR}/common/*/StatementDropTrigger.hpp\n    ${WCDB_SRC_DIR}/common/*/StatementDropView.hpp\n    ${WCDB_SRC_DIR}/common/*/StatementExplain.hpp\n    ${WCDB_SRC_DIR}/common/*/StatementInsert.hpp\n    ${WCDB_SRC_DIR}/common/*/StatementPragma.hpp\n    ${WCDB_SRC_DIR}/common/*/StatementReindex.hpp\n    ${WCDB_SRC_DIR}/common/*/StatementRelease.hpp\n    ${WCDB_SRC_DIR}/common/*/StatementRollback.hpp\n    ${WCDB_SRC_DIR}/common/*/StatementSavepoint.hpp\n    ${WCDB_SRC_DIR}/common/*/StatementSelect.hpp\n    ${WCDB_SRC_DIR}/common/*/StatementUpdate.hpp\n    ${WCDB_SRC_DIR}/common/*/StatementVacuum.hpp\n    ${WCDB_SRC_DIR}/common/*/StringView.hpp\n    ${WCDB_SRC_DIR}/common/*/SubstringMatchInfo.hpp\n    ${WCDB_SRC_DIR}/common/*/Syntax.h\n    ${WCDB_SRC_DIR}/common/*/SyntaxAlterTableSTMT.hpp\n    ${WCDB_SRC_DIR}/common/*/SyntaxAnalyzeSTMT.hpp\n    ${WCDB_SRC_DIR}/common/*/SyntaxAttachSTMT.hpp\n    ${WCDB_SRC_DIR}/common/*/SyntaxBeginSTMT.hpp\n    ${WCDB_SRC_DIR}/common/*/SyntaxBindParameter.hpp\n    ${WCDB_SRC_DIR}/common/*/SyntaxColumn.hpp\n    ${WCDB_SRC_DIR}/common/*/SyntaxColumnConstraint.hpp\n    ${WCDB_SRC_DIR}/common/*/SyntaxColumnDef.hpp\n    ${WCDB_SRC_DIR}/common/*/SyntaxCommitSTMT.hpp\n    ${WCDB_SRC_DIR}/common/*/SyntaxCommonConst.hpp\n    ${WCDB_SRC_DIR}/common/*/SyntaxCommonTableExpression.hpp\n    ${WCDB_SRC_DIR}/common/*/SyntaxCreateIndexSTMT.hpp\n    ${WCDB_SRC_DIR}/common/*/SyntaxCreateTableSTMT.hpp\n    ${WCDB_SRC_DIR}/common/*/SyntaxCreateTriggerSTMT.hpp\n    ${WCDB_SRC_DIR}/common/*/SyntaxCreateViewSTMT.hpp\n    ${WCDB_SRC_DIR}/common/*/SyntaxCreateVirtualTableSTMT.hpp\n    ${WCDB_SRC_DIR}/common/*/SyntaxDeleteSTMT.hpp\n    ${WCDB_SRC_DIR}/common/*/SyntaxDetachSTMT.hpp\n    ${WCDB_SRC_DIR}/common/*/SyntaxDropIndexSTMT.hpp\n    ${WCDB_SRC_DIR}/common/*/SyntaxDropTableSTMT.hpp\n    ${WCDB_SRC_DIR}/common/*/SyntaxDropTriggerSTMT.hpp\n    ${WCDB_SRC_DIR}/common/*/SyntaxDropViewSTMT.hpp\n    ${WCDB_SRC_DIR}/common/*/SyntaxExplainSTMT.hpp\n    ${WCDB_SRC_DIR}/common/*/SyntaxExpression.hpp\n    ${WCDB_SRC_DIR}/common/*/SyntaxFilter.hpp\n    ${WCDB_SRC_DIR}/common/*/SyntaxForeignKeyClause.hpp\n    ${WCDB_SRC_DIR}/common/*/SyntaxForwardDeclaration.h\n    ${WCDB_SRC_DIR}/common/*/SyntaxFrameSpec.hpp\n    ${WCDB_SRC_DIR}/common/*/SyntaxIdentifier.hpp\n    ${WCDB_SRC_DIR}/common/*/SyntaxIndexedColumn.hpp\n    ${WCDB_SRC_DIR}/common/*/SyntaxInsertSTMT.hpp\n    ${WCDB_SRC_DIR}/common/*/SyntaxJoinClause.hpp\n    ${WCDB_SRC_DIR}/common/*/SyntaxJoinConstraint.hpp\n    ${WCDB_SRC_DIR}/common/*/SyntaxList.hpp\n    ${WCDB_SRC_DIR}/common/*/SyntaxLiteralValue.hpp\n    ${WCDB_SRC_DIR}/common/*/SyntaxOrderingTerm.hpp\n    ${WCDB_SRC_DIR}/common/*/SyntaxPragma.hpp\n    ${WCDB_SRC_DIR}/common/*/SyntaxPragmaSTMT.hpp\n    ${WCDB_SRC_DIR}/common/*/SyntaxQualifiedTableName.hpp\n    ${WCDB_SRC_DIR}/common/*/SyntaxRaiseFunction.hpp\n    ${WCDB_SRC_DIR}/common/*/SyntaxReindexSTMT.hpp\n    ${WCDB_SRC_DIR}/common/*/SyntaxReleaseSTMT.hpp\n    ${WCDB_SRC_DIR}/common/*/SyntaxResultColumn.hpp\n    ${WCDB_SRC_DIR}/common/*/SyntaxRollbackSTMT.hpp\n    ${WCDB_SRC_DIR}/common/*/SyntaxSavepointSTMT.hpp\n    ${WCDB_SRC_DIR}/common/*/SyntaxSchema.hpp\n    ${WCDB_SRC_DIR}/common/*/SyntaxSelectCore.hpp\n    ${WCDB_SRC_DIR}/common/*/SyntaxSelectSTMT.hpp\n    ${WCDB_SRC_DIR}/common/*/SyntaxTableConstraint.hpp\n    ${WCDB_SRC_DIR}/common/*/SyntaxTableOrSubquery.hpp\n    ${WCDB_SRC_DIR}/common/*/SyntaxUpdateSTMT.hpp\n    ${WCDB_SRC_DIR}/common/*/SyntaxUpsertClause.hpp\n    ${WCDB_SRC_DIR}/common/*/SyntaxVacuumSTMT.hpp\n    ${WCDB_SRC_DIR}/common/*/SyntaxWindowDef.hpp\n    ${WCDB_SRC_DIR}/common/*/TableConstraint.hpp\n    ${WCDB_SRC_DIR}/common/*/TableOrSubquery.hpp\n    ${WCDB_SRC_DIR}/common/*/Tag.hpp\n    ${WCDB_SRC_DIR}/common/*/TokenizerModule.hpp\n    ${WCDB_SRC_DIR}/common/*/TokenizerModuleTemplate.hpp\n    ${WCDB_SRC_DIR}/common/*/SysTypes.h\n    ${WCDB_SRC_DIR}/common/*/UnsafeData.hpp\n    ${WCDB_SRC_DIR}/common/*/Upsert.hpp\n    ${WCDB_SRC_DIR}/common/*/Value.hpp\n    ${WCDB_SRC_DIR}/common/*/ValueArray.hpp\n    ${WCDB_SRC_DIR}/common/*/WindowDef.hpp\n    ${WCDB_SRC_DIR}/common/*/WINQ.h\n    ${WCDB_SRC_DIR}/common/*/WCDBOptional.hpp\n    ${WCDB_SRC_DIR}/cpp/*/Accessor.hpp\n    ${WCDB_SRC_DIR}/cpp/*/BaseOperation.hpp\n    ${WCDB_SRC_DIR}/cpp/*/Binding.hpp\n    ${WCDB_SRC_DIR}/cpp/*/Builtin.h\n    ${WCDB_SRC_DIR}/cpp/*/ChainCall.hpp\n    ${WCDB_SRC_DIR}/cpp/*/CPPBindingMacro.h\n    ${WCDB_SRC_DIR}/cpp/*/CPPColumnConstraintMacro.h\n    ${WCDB_SRC_DIR}/cpp/*/CPPDeclaration.h\n    ${WCDB_SRC_DIR}/cpp/*/CPPFieldMacro.h\n    ${WCDB_SRC_DIR}/cpp/*/CPPIndexMacro.h\n    ${WCDB_SRC_DIR}/cpp/*/CppInterface.h\n    ${WCDB_SRC_DIR}/cpp/*/CPPORM.h\n    ${WCDB_SRC_DIR}/cpp/*/CPPORMMacro.h\n    ${WCDB_SRC_DIR}/cpp/*/CPPTableConstraintMacro.h\n    ${WCDB_SRC_DIR}/cpp/*/CPPVirtualTableMacro.h\n    ${WCDB_SRC_DIR}/cpp/*/Database.hpp\n    ${WCDB_SRC_DIR}/cpp/*/Delete.hpp\n    ${WCDB_SRC_DIR}/cpp/*/Field.hpp\n    ${WCDB_SRC_DIR}/cpp/*/FTSTokenizerUtil.hpp\n    ${WCDB_SRC_DIR}/cpp/*/Handle.hpp\n    ${WCDB_SRC_DIR}/cpp/*/HandleOperation.hpp\n    ${WCDB_SRC_DIR}/cpp/*/HandleORMOperation.hpp\n    ${WCDB_SRC_DIR}/cpp/*/Insert.hpp\n    ${WCDB_SRC_DIR}/cpp/*/Master.hpp\n    ${WCDB_SRC_DIR}/cpp/*/MultiObject.hpp\n    ${WCDB_SRC_DIR}/cpp/*/MultiSelect.hpp\n    ${WCDB_SRC_DIR}/cpp/*/PreparedStatement.hpp\n    ${WCDB_SRC_DIR}/cpp/*/ResultField.hpp\n    ${WCDB_SRC_DIR}/cpp/*/RunTimeAccessor.hpp\n    ${WCDB_SRC_DIR}/cpp/*/STDOptionalAccessor.hpp\n    ${WCDB_SRC_DIR}/cpp/*/WCDBOptionalAccessor.hpp\n    ${WCDB_SRC_DIR}/cpp/*/SharedPtrAccessor.hpp\n    ${WCDB_SRC_DIR}/cpp/*/Select.hpp\n    ${WCDB_SRC_DIR}/cpp/*/Sequence.hpp\n    ${WCDB_SRC_DIR}/cpp/*/StatementOperation.hpp\n    ${WCDB_SRC_DIR}/cpp/*/Table.hpp\n    ${WCDB_SRC_DIR}/cpp/*/TableOperation.hpp\n    ${WCDB_SRC_DIR}/cpp/*/TableORMOperation.hpp\n    ${WCDB_SRC_DIR}/cpp/*/Update.hpp\n    ${WCDB_SRC_DIR}/cpp/WCDBCpp.h\n)\n\nif (WCONAN_MODE)\n    set(EXPORT_PUBLIC_HEADERS_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../WeChat/export_headers)\nelse ()\n    set(EXPORT_PUBLIC_HEADERS_PATH ${CMAKE_CURRENT_BINARY_DIR}/export_headers)\nendif()\n\n# export public headers\nif (WCDB_CPP) \n    file(REMOVE_RECURSE ${EXPORT_PUBLIC_HEADERS_PATH})\n    file(MAKE_DIRECTORY ${EXPORT_PUBLIC_HEADERS_PATH}/WCDB)\n    file(COPY ${WCDB_PUBLIC_HEADERS} DESTINATION ${EXPORT_PUBLIC_HEADERS_PATH}/WCDB)\nendif()\n\n# platform define, available platforms:\n# ANDROID, APPLE(MACOS/IOS/...), WIN32, LINUX\n# for LINUX: use CMAKE_CROSSCOMPILING to distinguish normal Linux(Ubuntu, Centos, etc) and embedding Linux\n# for ANDROID: use ANDROID_ABI to distinguish different arch(\"arm64-v8a\", \"armeabi-v7a\", etc)\n# for WIN32: use CMAKE_SIZEOF_VOID_P to distinguish different arch(X86_64, x86)\nif (APPLE)\n    message(STATUS \"PLATFORM: Apple ${CMAKE_SYSTEM_NAME}\")\n    if (CMAKE_SYSTEM_NAME MATCHES \"Darwin\")\n        set(MACOS TRUE)\n    elseif (CMAKE_SYSTEM_NAME MATCHES \"watchOS\")\n        set(WATCHOS TRUE)\n    elseif (CMAKE_SYSTEM_NAME MATCHES \"tvOS\")\n        set(TVOS TRUE)\n    elseif (CMAKE_SYSTEM_NAME MATCHES \"iOS\")\n        set(IOS TRUE)\n    else ()\n        message(FATAL_ERROR \"CMAKE_SYSTEM_NAME ${CMAKE_SYSTEM_NAME} is not supported\")\n    endif ()\nelseif (ANDROID)\n    message(STATUS \"PLATFORM: ${ANDROID_PLATFORM} ${ANDROID_ABI}\")\n    set(ANDROID_ARCH_LIST armeabi-v7a arm64-v8a x86 x86_64)\n    if(NOT ${ANDROID_ABI} IN_LIST ANDROID_ARCH_LIST)\n        message(FATAL_ERROR \"unsupported ANDROID_ABI ${ANDROID_ABI}\")\n    endif()\nelseif (WIN32)\n    if (CMAKE_SIZEOF_VOID_P EQUAL 8)\n        set(X86_ARCH \"x86_64\")\n    else ()\n        set(X86_ARCH \"x86\")\n    endif ()\n    message(STATUS \"PLATFORM: Windows ${X86_ARCH}\")\nelseif (OHOS)\n    message(STATUS \"PLATFORM: OpenHarmony\")\nelseif (UNIX)\n    message(STATUS \"PLATFORM: Linux ${CMAKE_SYSTEM_PROCESSOR}\")\n    set(LINUX TRUE)\nelse ()\n    message(FATAL_ERROR \"unsupported platform\")\nendif ()\n\nif (NOT DEFINED WCONAN_LIB_NAME)\n    set(WCONAN_LIB_NAME \"WCDB\")\nendif ()\n\nif (NOT DEFINED TARGET_NAME)\n    set(TARGET_NAME ${WCONAN_LIB_NAME})\nendif ()\n\nif (NOT DEFINED CMAKE_BUILD_TYPE)\n    set(CMAKE_BUILD_TYPE \"Release\")\nendif ()\n\nif (NOT DEFINED BUILD_SHARED_LIBS)\n    set(BUILD_SHARED_LIBS ON)\nendif ()\n\nif (ANDROID AND NOT DEFINED ANDROID_STL)\n    set(ANDROID_STL \"c++_shared\")\nendif ()\n\n# set default compiler flags for each platform\nif (WIN32)\n    enable_language(C CXX ASM_MASM)\n    set(COMM_FLAGS_ \"/utf-8 /EHa\")\n    set(CMAKE_C_FLAGS \"${CMAKE_C_FLAGS} ${COMM_FLAGS_}\")\n    set(CMAKE_CXX_FLAGS \"${CMAKE_CXX_FLAGS} ${COMM_FLAGS_}\")\n    set(CMAKE_CXX_FLAGS_RELEASE \"${CMAKE_CXX_FLAGS_RELEASE} /Zi\")\n    set(CMAKE_SHARED_LINKER_FLAGS_RELEASE \"${CMAKE_SHARED_LINKER_FLAGS_RELEASE} /DEBUG /OPT:REF /OPT:ICF\")\n\n    if (CMAKE_CL_64)\n        add_definitions(-D_WIN64 -DWIN64)\n    endif ()\n\n    if (BUILD_SHARED_LIBS) \n        set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)\n        #add_definitions(-DWCDB_DLL -DWCDB_BUILD_DLL)\n    endif ()\n    \n    if (BUILD_SHARED_LIBS)\n        target_compile_options(sqlcipher PRIVATE \n            $<$<CONFIG:>:/MD> #---------|\n            $<$<CONFIG:Debug>:/MDd> #---|-- Dynamic link the runtime libraries\n            $<$<CONFIG:Release>:/MD> #--|\n            $<$<CONFIG:RelWithDebInfo>:/MD>\n        )\n    else ()\n        target_compile_options(sqlcipher PRIVATE \n            $<$<CONFIG:>:/MT> #---------|\n            $<$<CONFIG:Debug>:/MTd> #---|-- Statically link the runtime libraries\n            $<$<CONFIG:Release>:/MT> #--|\n            $<$<CONFIG:RelWithDebInfo>:/MT>\n        )\n    endif()\n    \n    add_compile_options(/MP)\n    add_compile_options(/wd4068)  # Disable unknown pragma warnings\n    add_compile_options(/wd4996)\n    add_compile_options(/wd4715)\n    add_compile_options(/wd4251)\nelse ()\n    enable_language(C CXX)\n    set(COMM_FLAGS_ \"-Wall -g\")\n    set(CMAKE_C_FLAGS \"${CMAKE_C_FLAGS} ${COMM_FLAGS_}\")\n    # xcode 14.0.1 must manually set -std=c++14 since set(CMAKE_CXX_STANDARD 14) has no effect when compiler iOS-Simulator on M1\n    set(CMAKE_CXX_FLAGS \"${CMAKE_CXX_FLAGS} ${COMM_FLAGS_} -std=c++14\")\n\n    # enable lto and no-plt (only for non-Android platforms)\n    if (NOT ANDROID)\n        set(CMAKE_C_FLAGS \"${CMAKE_C_FLAGS} -flto -fno-plt\")\n        set(CMAKE_CXX_FLAGS \"${CMAKE_CXX_FLAGS} -flto -fno-plt\")\n    endif()\n\n    if (LINUX)\n        set(CMAKE_C_FLAGS \"${CMAKE_C_FLAGS} -fPIC -pthread\")\n        set(CMAKE_CXX_FLAGS \"${CMAKE_CXX_FLAGS} -fPIC -pthread\")\n        if (\"${CMAKE_CXX_COMPILER_ID}\" STREQUAL \"GNU\")\n            set(CMAKE_C_FLAGS \"${CMAKE_C_FLAGS} -Wno-unknown-pragmas -Wno-pragmas -Wno-deprecated -Wno-unused-variable\")\n            set(CMAKE_CXX_FLAGS \"${CMAKE_CXX_FLAGS} -Wno-unknown-pragmas -Wno-pragmas -Wno-deprecated -Wno-unused-variable\")\n        endif ()\n    elseif (ANDROID)\n        set(CMAKE_C_FLAGS \"${CMAKE_C_FLAGS} -fPIC\")\n        set(CMAKE_CXX_FLAGS \"${CMAKE_CXX_FLAGS} -fPIC\")\n    endif()\n\n    if (APPLE)\n        set(CMAKE_SHARED_LINKER_FLAGS \"${CMAKE_SHARED_LINKER_FLAGS} -Wl,-dead_strip\")\n    else ()\n        set(CMAKE_C_FLAGS \"${CMAKE_C_FLAGS} -ffunction-sections -fdata-sections\")\n        set(CMAKE_CXX_FLAGS \"${CMAKE_CXX_FLAGS} -ffunction-sections -fdata-sections\")\n        set(CMAKE_SHARED_LINKER_FLAGS \"${CMAKE_SHARED_LINKER_FLAGS} -Wl,--gc-sections -Wl,-Bsymbolic\")\n    endif ()\nendif ()\n\nif (UNIX)\n    set(CMAKE_POSITION_INDEPENDENT_CODE ON)\nendif ()\n\nset(CMAKE_CXX_STANDARD 14)\nset(CMAKE_CXX_STANDARD_REQUIRED ON)\nset(CMAKE_CXX_EXTENSIONS OFF)\n\nadd_library(${TARGET_NAME} ${WCDB_COMMON_SRC})\ntarget_link_libraries(${TARGET_NAME} PRIVATE sqlcipher)\ntarget_include_directories(${TARGET_NAME} PUBLIC ${WCDB_COMMON_INCLUDES})\n\nif (WCDB_ZSTD)\n    include(zstd.cmake)\n    target_link_libraries(${TARGET_NAME} PRIVATE zstd)\n    target_compile_definitions(${TARGET_NAME} PRIVATE WCDB_ZSTD=1)\nendif ()\n\nif (WIN32)\n    target_compile_options(${TARGET_NAME} PRIVATE /EHsc)\nelse ()\n    target_compile_options(${TARGET_NAME} PRIVATE -fno-exceptions)\nendif()\n\nif (WCDB_CPP)\n    target_sources(${TARGET_NAME} PRIVATE ${WCDB_CPP_SRC})\n    target_include_directories(${TARGET_NAME} PUBLIC ${WCDB_CPP_INCLUDES})\nendif ()\n\nif (WCDB_BRIDGE)\n    target_sources(${TARGET_NAME} PRIVATE ${WCDB_BRIDGE_SRC})\n    target_include_directories(${TARGET_NAME} PUBLIC ${WCDB_BRIDGE_INCLUDES})\nendif ()\n\nif (WCONAN_MODE)\n    wconan_get_libraries_dir(\n            WCONAN_LIB_DIR\n            wconan_libs\n    )\n    target_include_directories(sqlcipher PUBLIC ${WCONAN_LIB_DIR}/include)\n    target_link_directories(sqlcipher PUBLIC ${WCONAN_LIB_DIR}/libs)\nelse ()\n    if (BUILD_SHARED_LIBS)\n        if(ANDROID)\n            target_include_directories(${TARGET_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../tools/prebuild/openssl/android_old/${CMAKE_ANDROID_ARCH}/include)\n            target_link_directories(${TARGET_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../tools/prebuild/openssl/android_old/${CMAKE_ANDROID_ARCH}/lib)\n            target_include_directories(sqlcipher PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../tools/prebuild/openssl/android_old/${CMAKE_ANDROID_ARCH}/include)\n            target_link_directories(sqlcipher PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../tools/prebuild/openssl/android_old/${CMAKE_ANDROID_ARCH}/lib)\n        elseif(LINUX)\n            target_include_directories(sqlcipher PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../tools/prebuild/openssl/include)\n            target_include_directories(${TARGET_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../tools/prebuild/openssl/include)\n            target_include_directories(${TARGET_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../tools/prebuild/zlib/include)\n            if (${CMAKE_SYSTEM_PROCESSOR} STREQUAL \"x86_64\")\n                target_link_directories(sqlcipher PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../tools/prebuild/openssl/linux/x86_64)\n                target_link_directories(${TARGET_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../tools/prebuild/openssl/linux/x86_64)\n                target_link_directories(${TARGET_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../tools/prebuild/zlib/linux/x86_64)\n            elseif (${CMAKE_SYSTEM_PROCESSOR} STREQUAL \"arm64\")\n                target_link_directories(sqlcipher PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../tools/prebuild/openssl/linux/arm64)\n                target_link_directories(${TARGET_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../tools/prebuild/openssl/linux/arm64)\n                target_link_directories(${TARGET_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../tools/prebuild/zlib/linux/arm64)\n            endif()\n        elseif(WIN32)\n            target_include_directories(sqlcipher PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../tools/prebuild/openssl/include)\n            target_include_directories(${TARGET_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../tools/prebuild/openssl/include)\n            target_include_directories(${TARGET_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../tools/prebuild/zlib/include)\n            if (CMAKE_SIZEOF_VOID_P EQUAL 8)\n                target_link_directories(${TARGET_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../tools/prebuild/zlib/windows/win64)\n                target_link_directories(sqlcipher PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../tools/prebuild/openssl/windows/win64)\n                target_link_directories(${TARGET_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../tools/prebuild/openssl/windows/win64)\n            else ()\n                target_link_directories(${TARGET_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../tools/prebuild/zlib/windows/win32)\n                target_link_directories(sqlcipher PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../tools/prebuild/openssl/windows/win32)\n                target_link_directories(${TARGET_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../tools/prebuild/openssl/windows/win32)\n            endif()\n        elseif(OHOS)\n            target_include_directories(${TARGET_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../tools/prebuild/openssl/include)\n            target_include_directories(sqlcipher PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../tools/prebuild/openssl/include)\n            if (${OHOS_ARCH} STREQUAL \"arm64-v8a\")\n                target_link_directories(${TARGET_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../tools/prebuild/openssl/ohos/arm64-v8a)\n                target_link_directories(sqlcipher PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../tools/prebuild/openssl/ohos/arm64-v8a)\n            elseif(${OHOS_ARCH} STREQUAL \"x86_64\")\n                target_link_directories(${TARGET_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../tools/prebuild/openssl/ohos/x86_64)\n                target_link_directories(sqlcipher PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../tools/prebuild/openssl/ohos/x86_64)\n            endif()\n        endif()\n    else ()\n        if(ANDROID)\n            target_include_directories(sqlcipher PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../tools/prebuild/openssl/android_old/${CMAKE_ANDROID_ARCH}/include)\n            target_link_directories(sqlcipher PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../tools/prebuild/openssl/android_old/${CMAKE_ANDROID_ARCH}/lib)\n        elseif(LINUX)\n            target_include_directories(sqlcipher PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../tools/prebuild/openssl/include)\n            target_include_directories(${TARGET_NAME} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../tools/prebuild/zlib/include)\n            target_link_directories(${TARGET_NAME} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../tools/prebuild/zlib/linux/arm64)\n            target_link_directories(${TARGET_NAME} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../tools/prebuild/zlib/linux/x86_64)\n            target_link_directories(sqlcipher PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../tools/prebuild/openssl/linux/arm64)\n            target_link_directories(sqlcipher PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../tools/prebuild/openssl/linux/x86_64)\n        elseif(WIN32)\n            target_include_directories(sqlcipher PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../tools/prebuild/openssl/include)\n            target_include_directories(${TARGET_NAME} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../tools/prebuild/zlib/include)\n            if (CMAKE_SIZEOF_VOID_P EQUAL 8)\n                target_link_directories(${TARGET_NAME} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../tools/prebuild/zlib/windows/win64)\n                target_link_directories(sqlcipher PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../tools/prebuild/openssl/windows/win64)\n            else ()\n                target_link_directories(${TARGET_NAME} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../tools/prebuild/zlib/windows/win32)\n                target_link_directories(sqlcipher PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../tools/prebuild/openssl/windows/win32)\n            endif()\n        elseif(OHOS)\n            target_include_directories(sqlcipher PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../tools/prebuild/openssl/include)\n            if (${OHOS_ARCH} STREQUAL \"arm64-v8a\")\n                target_link_directories(sqlcipher PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../tools/prebuild/openssl/ohos/arm64-v8a)\n            elseif(${OHOS_ARCH} STREQUAL \"x86_64\")\n                target_link_directories(sqlcipher PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../tools/prebuild/openssl/ohos/x86_64)\n            endif()\n        endif()\n    endif()\nendif ()\n\nif (ANDROID)\n    message(STATUS \"---- BUILD FOR ANDROID ----\")\n    find_library(z-lib z)\n    target_link_options(${TARGET_NAME} PRIVATE \"-Wl,-z,max-page-size=16384\")\n    target_link_libraries(${TARGET_NAME} PUBLIC\n            ${LINK_LIBRARIES}\n            ${z-lib})\n    if (BUILD_SHARED_LIBS)\n        target_link_libraries(${TARGET_NAME} PRIVATE crypto)\n    else()\n        target_link_libraries(${TARGET_NAME} PUBLIC crypto)\n    endif()\nelseif (APPLE AND NOT WCONAN_MODE)\n    message(STATUS \"---- BUILD FOR APPLE ----\")\n    find_library(SecurityFramework Security)\n    find_library(FoundationFrameWork Foundation)\n    find_library(z-lib z)\n    target_link_libraries(${TARGET_NAME} PUBLIC\n            ${LINK_LIBRARIES}\n            ${SecurityFramework}\n            ${FoundationFrameWork}\n            ${z-lib})\n    target_sources(${TARGET_NAME} PUBLIC ${WCDB_PUBLIC_HEADERS})\n    file(STRINGS \"../VERSION\" WCDB_VERSION)\n    message(STATUS \"Xcode ${TARGET_NAME}.framework version ${WCDB_VERSION}\")\n    set_target_properties(${TARGET_NAME} PROPERTIES\n        FRAMEWORK TRUE\n        FRAMEWORK_VERSION ${WCDB_VERSION}\n        MACOSX_FRAMEWORK_IDENTIFIER com.tencent.${TARGET_NAME}\n        PUBLIC_HEADER \"${WCDB_PUBLIC_HEADERS}\"\n    )\nelseif (OHOS)\n    message(STATUS \"---- BUILD FOR OPENHARMONY ----\")\n    target_link_libraries(${TARGET_NAME} PUBLIC\n            ${LINK_LIBRARIES}\n            pthread\n            z)\n    if (BUILD_SHARED_LIBS)\n        target_link_libraries(${TARGET_NAME} PRIVATE crypto)\n    else()\n        target_link_libraries(${TARGET_NAME} PUBLIC crypto)\n    endif()\nelseif (LINUX)\n    message(STATUS \"---- BUILD FOR LINUX ----\")\n    target_link_libraries(${TARGET_NAME} PUBLIC\n            ${LINK_LIBRARIES}\n            pthread\n            dl)\n    if (BUILD_SHARED_LIBS)\n        target_link_libraries(${TARGET_NAME} PRIVATE crypto z)\n    else()\n        target_link_libraries(${TARGET_NAME} PUBLIC crypto z)\n    endif()\nelseif (WIN32)\n    message(STATUS \"---- BUILD FOR WINDOWS ----\")\n    target_link_libraries(${TARGET_NAME} PUBLIC\n            ${LINK_LIBRARIES}\n            Crypt32\n            Ws2_32)\n    if (BUILD_SHARED_LIBS)\n        target_link_libraries(${TARGET_NAME} PRIVATE libcrypto zlibstatic)\n    else()\n        target_link_libraries(${TARGET_NAME} PUBLIC libcrypto zlibstatic)\n    endif()\nelse ()\n    message(FATAL_ERROR \"Unsupported platform!\")\nendif ()\n"
  },
  {
    "path": "src/WCDB.h",
    "content": "//\n// Created by qiuwenchen on 2022/9/22.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"WCDBCpp.h\"\n#import \"WCDBObjc.h\"\n"
  },
  {
    "path": "src/WCDB.xcodeproj/project.pbxproj",
    "content": "// !$*UTF8*$!\n{\n\tarchiveVersion = 1;\n\tclasses = {\n\t};\n\tobjectVersion = 55;\n\tobjects = {\n\n/* Begin PBXBuildFile section */\n\t\t03239D6428C60F5C00C8D691 /* CPPTableConstraintObject.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 03239D6228C60F5C00C8D691 /* CPPTableConstraintObject.cpp */; };\n\t\t03239D6628C6153F00C8D691 /* CPPORMTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 03239D6528C6153F00C8D691 /* CPPORMTests.mm */; };\n\t\t0326130D283F56BD00836E0F /* LiteralValueBridge.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0326130B283F56BD00836E0F /* LiteralValueBridge.cpp */; };\n\t\t0326130E283F56BD00836E0F /* LiteralValueBridge.h in Headers */ = {isa = PBXBuildFile; fileRef = 0326130C283F56BD00836E0F /* LiteralValueBridge.h */; settings = {ATTRIBUTES = (Private, ); }; };\n\t\t0326130F283F573C00836E0F /* WinqBridge.h in Headers */ = {isa = PBXBuildFile; fileRef = 032612BB283F279800836E0F /* WinqBridge.h */; settings = {ATTRIBUTES = (Private, ); }; };\n\t\t03261311283F5E0300836E0F /* WinqBridge.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 03261310283F5E0300836E0F /* WinqBridge.cpp */; };\n\t\t03261364283F6CFB00836E0F /* Identifier.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03261363283F6CFB00836E0F /* Identifier.swift */; };\n\t\t032613B6283F8D7E00836E0F /* ColumnBridge.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 032613B4283F8D7E00836E0F /* ColumnBridge.cpp */; };\n\t\t032613B7283F8D7E00836E0F /* ColumnBridge.h in Headers */ = {isa = PBXBuildFile; fileRef = 032613B5283F8D7E00836E0F /* ColumnBridge.h */; settings = {ATTRIBUTES = (Private, ); }; };\n\t\t032613BA283F8E4900836E0F /* ExpressionBridge.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 032613B8283F8E4900836E0F /* ExpressionBridge.cpp */; };\n\t\t032613BB283F8E4900836E0F /* ExpressionBridge.h in Headers */ = {isa = PBXBuildFile; fileRef = 032613B9283F8E4900836E0F /* ExpressionBridge.h */; settings = {ATTRIBUTES = (Private, ); }; };\n\t\t032E112428C8511E00BCACE0 /* CPPIndexObject.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 032E112228C8511E00BCACE0 /* CPPIndexObject.cpp */; };\n\t\t032E112828C8724A00BCACE0 /* CPPOldRemapObject.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 032E112628C8724A00BCACE0 /* CPPOldRemapObject.cpp */; };\n\t\t032E112B28C874F500BCACE0 /* CPPNewRemapObject.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 032E112928C874F500BCACE0 /* CPPNewRemapObject.cpp */; };\n\t\t032E112E28C8768C00BCACE0 /* CPPNewlyCreatedTableIndexObject.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 032E112C28C8768C00BCACE0 /* CPPNewlyCreatedTableIndexObject.cpp */; };\n\t\t032E113128C8782600BCACE0 /* CPPDropIndexObject.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 032E112F28C8782600BCACE0 /* CPPDropIndexObject.cpp */; };\n\t\t032E113528C88C3C00BCACE0 /* RunTimeAccessor.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 032E113328C88B8000BCACE0 /* RunTimeAccessor.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t032E113628C88C3D00BCACE0 /* RunTimeAccessor.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 032E113328C88B8000BCACE0 /* RunTimeAccessor.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t032E121528C8A3B700BCACE0 /* CPPTestCaseObject.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 032E121328C8A3B700BCACE0 /* CPPTestCaseObject.cpp */; };\n\t\t03321E8728A503F3000AFD6D /* StatementOperation.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 03321E8528A503F3000AFD6D /* StatementOperation.cpp */; };\n\t\t03321E8828A503F3000AFD6D /* StatementOperation.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 03321E8528A503F3000AFD6D /* StatementOperation.cpp */; };\n\t\t03321E8A28A503F3000AFD6D /* StatementOperation.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 03321E8628A503F3000AFD6D /* StatementOperation.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t03321E8D28A514F5000AFD6D /* HandleOperation.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 03321E8B28A514F5000AFD6D /* HandleOperation.cpp */; };\n\t\t03321E8E28A514F5000AFD6D /* HandleOperation.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 03321E8B28A514F5000AFD6D /* HandleOperation.cpp */; };\n\t\t03321E8F28A514F5000AFD6D /* HandleOperation.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 03321E8C28A514F5000AFD6D /* HandleOperation.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t03321E9028A514F5000AFD6D /* HandleOperation.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 03321E8C28A514F5000AFD6D /* HandleOperation.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t03330FFD28167ECC0094CFCF /* WCDB.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 239326611E836D7300D677CC /* WCDB.framework */; };\n\t\t03331034281681200094CFCF /* CRUDTestCase.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0333101B281681200094CFCF /* CRUDTestCase.swift */; };\n\t\t0333103F281681A80094CFCF /* Assert.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0333103C281681A80094CFCF /* Assert.swift */; };\n\t\t03331040281681A80094CFCF /* BaseTestCase.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0333103D281681A80094CFCF /* BaseTestCase.swift */; };\n\t\t03331041281681A80094CFCF /* Convenience.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0333103E281681A80094CFCF /* Convenience.swift */; };\n\t\t033310462816836C0094CFCF /* CRUDObject.mm in Sources */ = {isa = PBXBuildFile; fileRef = 033310452816836C0094CFCF /* CRUDObject.mm */; };\n\t\t033310EE2816A2F20094CFCF /* CRUDObject.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0333101A281681200094CFCF /* CRUDObject.swift */; };\n\t\t0338E0C8281920AB0094923A /* DeleteTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0338E0C7281920AB0094923A /* DeleteTests.swift */; };\n\t\t0338E0D62819226C0094923A /* SelectInterfaceTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0338E0C92819226A0094923A /* SelectInterfaceTests.swift */; };\n\t\t0338E0D72819226C0094923A /* InsertTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0338E0CA2819226B0094923A /* InsertTests.swift */; };\n\t\t0338E0D92819226C0094923A /* UpdateInterfaceTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0338E0CC2819226B0094923A /* UpdateInterfaceTests.swift */; };\n\t\t0338E0DA2819226C0094923A /* MultiSelectTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0338E0CD2819226B0094923A /* MultiSelectTests.swift */; };\n\t\t0338E0DB2819226C0094923A /* RowSelectTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0338E0CE2819226B0094923A /* RowSelectTests.swift */; };\n\t\t0338E0DD2819226C0094923A /* UpdateTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0338E0D02819226B0094923A /* UpdateTests.swift */; };\n\t\t0338E0DF2819226C0094923A /* InsertInterfaceTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0338E0D22819226C0094923A /* InsertInterfaceTests.swift */; };\n\t\t0338E0E12819226C0094923A /* DeleteInterfaceTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0338E0D42819226C0094923A /* DeleteInterfaceTests.swift */; };\n\t\t0338E0E22819226C0094923A /* AdvanceCRUDTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0338E0D52819226C0094923A /* AdvanceCRUDTests.swift */; };\n\t\t0344BA8128C9DC7D000BC154 /* ORMUpdateTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 0344BA8028C9DC7D000BC154 /* ORMUpdateTests.mm */; };\n\t\t0344BACB28CA0589000BC154 /* ChainCallTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 0344BACA28CA0589000BC154 /* ChainCallTests.mm */; };\n\t\t03450DB92738C8F800C4DC1B /* PinyinTokenizer.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 03450DB72738C8F800C4DC1B /* PinyinTokenizer.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t03450DBA2738DDE800C4DC1B /* OneOrBinaryTokenizer.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 03450DB32738BBF000C4DC1B /* OneOrBinaryTokenizer.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t03450E012738ECB800C4DC1B /* OneOrBinaryTokenizer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 03450DB22738BBF000C4DC1B /* OneOrBinaryTokenizer.cpp */; };\n\t\t03450E032738ED0200C4DC1B /* PinyinTokenizer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 03450DB62738C8F800C4DC1B /* PinyinTokenizer.cpp */; };\n\t\t036E50B728115AB8007365CD /* WCTBridgeProperty.h in Headers */ = {isa = PBXBuildFile; fileRef = 036E50B628115AB8007365CD /* WCTBridgeProperty.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t036E50B928115B1D007365CD /* WCTBridgeProperty.mm in Sources */ = {isa = PBXBuildFile; fileRef = 036E50B828115B1D007365CD /* WCTBridgeProperty.mm */; };\n\t\t036E50BB28115BA0007365CD /* WCTBridgeProperty+CPP.h in Headers */ = {isa = PBXBuildFile; fileRef = 036E50BA28115BA0007365CD /* WCTBridgeProperty+CPP.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t036E50C128116D7A007365CD /* WCTBridgeProperty.swift in Sources */ = {isa = PBXBuildFile; fileRef = 036E50C028116D7A007365CD /* WCTBridgeProperty.swift */; };\n\t\t037330C1289A909A0030C113 /* Database.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 037330BF289A909A0030C113 /* Database.cpp */; };\n\t\t037330C2289A909A0030C113 /* Database.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 037330C0289A909A0030C113 /* Database.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t0373310C289A94E00030C113 /* PreparedStatement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0373310A289A94E00030C113 /* PreparedStatement.cpp */; };\n\t\t0373310D289A94E00030C113 /* PreparedStatement.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 0373310B289A94E00030C113 /* PreparedStatement.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t03733110289A94F10030C113 /* Handle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0373310E289A94F00030C113 /* Handle.cpp */; };\n\t\t03733111289A94F10030C113 /* Handle.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 0373310F289A94F10030C113 /* Handle.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t037C38D42897E33600328EC8 /* SQL.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDBA8217DFADC006E9E73 /* SQL.cpp */; };\n\t\t037C38D52897E33600328EC8 /* HighWater.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23E7EB1B2123D58D0056B5D8 /* HighWater.cpp */; };\n\t\t037C38D62897E33600328EC8 /* ConvertibleImplementation.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDB6D217DFADC006E9E73 /* ConvertibleImplementation.cpp */; };\n\t\t037C38D72897E33600328EC8 /* Scoreable.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2376CB1920DA5D3B00A68DB5 /* Scoreable.cpp */; };\n\t\t037C38D82897E33600328EC8 /* StatementCreateView.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDBC9217DFADC006E9E73 /* StatementCreateView.cpp */; };\n\t\t037C38D92897E33600328EC8 /* MappedData.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2316D92E21057CA700707AFC /* MappedData.cpp */; };\n\t\t037C38DA2897E33600328EC8 /* Backup.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23775B3E20AD666900E21AB0 /* Backup.cpp */; };\n\t\t037C38E02897E33600328EC8 /* SQLTraceConfig.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2360A5FF20D78F2B00E4A311 /* SQLTraceConfig.cpp */; };\n\t\t037C38E12897E33600328EC8 /* SyntaxPragma.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDC18217DFADC006E9E73 /* SyntaxPragma.cpp */; };\n\t\t037C38E32897E33600328EC8 /* Factory.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23D0C34920C149D80001BFAE /* Factory.cpp */; };\n\t\t037C38E62897E33600328EC8 /* Statement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3962FFC723051429008934D4 /* Statement.cpp */; };\n\t\t037C38E72897E33600328EC8 /* FactoryBackup.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23D0C38B20C17CAE0001BFAE /* FactoryBackup.cpp */; };\n\t\t037C38E92897E33600328EC8 /* CustomConfig.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23F70FD420A07CEC00CCE3CD /* CustomConfig.cpp */; };\n\t\t037C38EA2897E33600328EC8 /* StatementDropView.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDBD7217DFADC006E9E73 /* StatementDropView.cpp */; };\n\t\t037C38EB2897E33600328EC8 /* Config.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2327BC21220944D80078A85B /* Config.cpp */; };\n\t\t037C38EE2897E33600328EC8 /* Tag.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23B4DC7C2111B39100954D71 /* Tag.cpp */; };\n\t\t037C38EF2897E33600328EC8 /* SyntaxSavepointSTMT.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDC5B217DFADC006E9E73 /* SyntaxSavepointSTMT.cpp */; };\n\t\t037C38F02897E33600328EC8 /* SyntaxDeleteSTMT.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDC45217DFADC006E9E73 /* SyntaxDeleteSTMT.cpp */; };\n\t\t037C38F12897E33600328EC8 /* SyntaxCommitSTMT.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDC39217DFADC006E9E73 /* SyntaxCommitSTMT.cpp */; };\n\t\t037C38F42897E33600328EC8 /* Notifier.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23775B3220AD666900E21AB0 /* Notifier.cpp */; };\n\t\t037C38F62897E33600328EC8 /* SyntaxDropViewSTMT.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDC4F217DFADC006E9E73 /* SyntaxDropViewSTMT.cpp */; };\n\t\t037C38F92897E33600328EC8 /* OrderingTerm.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDB9A217DFADC006E9E73 /* OrderingTerm.cpp */; };\n\t\t037C38FB2897E33600328EC8 /* ColumnType.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDB6A217DFADC006E9E73 /* ColumnType.cpp */; };\n\t\t037C38FD2897E33600328EC8 /* StatementAttach.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDBBD217DFADC006E9E73 /* StatementAttach.cpp */; };\n\t\t037C38FE2897E33600328EC8 /* Fraction.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23AD52E420DB852B00664B62 /* Fraction.cpp */; };\n\t\t037C39002897E33600328EC8 /* SyntaxTableConstraint.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDC26217DFADC006E9E73 /* SyntaxTableConstraint.cpp */; };\n\t\t037C39012897E33600328EC8 /* SequenceCrawler.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23D07CE820BE873E0043F4D4 /* SequenceCrawler.cpp */; };\n\t\t037C39062897E33600328EC8 /* StatementDropTrigger.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDBD5217DFADC006E9E73 /* StatementDropTrigger.cpp */; };\n\t\t037C39072897E33600328EC8 /* ExpressionOperable.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDB71217DFADC006E9E73 /* ExpressionOperable.cpp */; };\n\t\t037C39092897E33600328EC8 /* SQLiteLocker.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23C7558F20DCF90F00031A93 /* SQLiteLocker.cpp */; };\n\t\t037C390D2897E33600328EC8 /* StatementUpdate.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDBE7217DFADC006E9E73 /* StatementUpdate.cpp */; };\n\t\t037C390E2897E33600328EC8 /* SyntaxResultColumn.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDC20217DFADC006E9E73 /* SyntaxResultColumn.cpp */; };\n\t\t037C390F2897E33600328EC8 /* Initializeable.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23AF4E1C20CD04E20050033C /* Initializeable.cpp */; };\n\t\t037C39102897E33600328EC8 /* PageBasedFileHandle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2316D9412105D19500707AFC /* PageBasedFileHandle.cpp */; };\n\t\t037C39122897E33600328EC8 /* Progress.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23A6D4BD20BFD7F9004F2DAA /* Progress.cpp */; };\n\t\t037C39132897E33600328EC8 /* Mechanic.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23775B4220AD666900E21AB0 /* Mechanic.cpp */; };\n\t\t037C39172897E33600328EC8 /* SyntaxUpdateSTMT.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDC5F217DFADC006E9E73 /* SyntaxUpdateSTMT.cpp */; };\n\t\t037C391B2897E33600328EC8 /* StatementCreateIndex.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDBC3217DFADC006E9E73 /* StatementCreateIndex.cpp */; };\n\t\t037C391D2897E33600328EC8 /* StatementDetach.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDBCF217DFADC006E9E73 /* StatementDetach.cpp */; };\n\t\t037C391F2897E33600328EC8 /* StatementAnalyze.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDBBB217DFADC006E9E73 /* StatementAnalyze.cpp */; };\n\t\t037C39212897E33600328EC8 /* FTSFunction.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDB73217DFADC006E9E73 /* FTSFunction.cpp */; };\n\t\t037C39222897E33600328EC8 /* RecyclableHandle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2349F6241EA0D6680021EFA7 /* RecyclableHandle.cpp */; };\n\t\t037C39262897E33600328EC8 /* ResultColumn.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDBA4217DFADC006E9E73 /* ResultColumn.cpp */; };\n\t\t037C39282897E33600328EC8 /* FullCrawler.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23775B3620AD666900E21AB0 /* FullCrawler.cpp */; };\n\t\t037C39292897E33600328EC8 /* SyntaxVacuumSTMT.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDC61217DFADC006E9E73 /* SyntaxVacuumSTMT.cpp */; };\n\t\t037C392C2897E33600328EC8 /* StatementCreateTable.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDBC5217DFADC006E9E73 /* StatementCreateTable.cpp */; };\n\t\t037C392D2897E33600328EC8 /* HandleNotification.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2360A5F420D78F1B00E4A311 /* HandleNotification.cpp */; };\n\t\t037C392E2897E33600328EC8 /* SequenceItem.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23AD52DB20DB56D200664B62 /* SequenceItem.cpp */; };\n\t\t037C392F2897E33600328EC8 /* AuxiliaryFunctionModule.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7543DD84271C2FD000B533B4 /* AuxiliaryFunctionModule.cpp */; };\n\t\t037C39322897E33600328EC8 /* StatementAlterTable.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDBB9217DFADC006E9E73 /* StatementAlterTable.cpp */; };\n\t\t037C39332897E33600328EC8 /* CipherConfig.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23F70FAA20A055C300CCE3CD /* CipherConfig.cpp */; };\n\t\t037C39342897E33600328EC8 /* FactoryRelated.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23D0C36120C14ACC0001BFAE /* FactoryRelated.cpp */; };\n\t\t037C39352897E33600328EC8 /* Global.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 235FBE9322914E0D005C7723 /* Global.cpp */; };\n\t\t037C39392897E33600328EC8 /* SyntaxDropTriggerSTMT.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDC4D217DFADC006E9E73 /* SyntaxDropTriggerSTMT.cpp */; };\n\t\t037C393B2897E33600328EC8 /* AsyncQueue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23B4DCDF2112B03C00954D71 /* AsyncQueue.cpp */; };\n\t\t037C393C2897E33600328EC8 /* SyntaxUpsertClause.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDC2A217DFADC006E9E73 /* SyntaxUpsertClause.cpp */; };\n\t\t037C393F2897E33600328EC8 /* Expression.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDB86217DFADC006E9E73 /* Expression.cpp */; };\n\t\t037C39402897E33600328EC8 /* SyntaxPragmaSTMT.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDC53217DFADC006E9E73 /* SyntaxPragmaSTMT.cpp */; };\n\t\t037C394E2897E33600328EC8 /* JoinConstraint.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDB94217DFADC006E9E73 /* JoinConstraint.cpp */; };\n\t\t037C39522897E33600328EC8 /* AutoMigrateConfig.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23301BF32298FE9A00A8AB5A /* AutoMigrateConfig.cpp */; };\n\t\t037C39532897E33600328EC8 /* TableOrSubquery.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDBAC217DFADC006E9E73 /* TableOrSubquery.cpp */; };\n\t\t037C39552897E33600328EC8 /* WalRelated.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23593B7B20D3ADF80058B416 /* WalRelated.cpp */; };\n\t\t037C39562897E33600328EC8 /* SyntaxBeginSTMT.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDC37217DFADC006E9E73 /* SyntaxBeginSTMT.cpp */; };\n\t\t037C39572897E33600328EC8 /* SyntaxCommonTableExpression.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDBFC217DFADC006E9E73 /* SyntaxCommonTableExpression.cpp */; };\n\t\t037C39592897E33600328EC8 /* StatementDropTable.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDBD3217DFADC006E9E73 /* StatementDropTable.cpp */; };\n\t\t037C395C2897E33600328EC8 /* SyntaxExpression.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDC00217DFADC006E9E73 /* SyntaxExpression.cpp */; };\n\t\t037C395D2897E33600328EC8 /* StatementCreateVirtualTable.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDBCB217DFADC006E9E73 /* StatementCreateVirtualTable.cpp */; };\n\t\t037C395E2897E33600328EC8 /* SyntaxCommonConst.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23545BA12224EAA40091C981 /* SyntaxCommonConst.cpp */; };\n\t\t037C395F2897E33600328EC8 /* StatementSavepoint.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDBE3217DFADC006E9E73 /* StatementSavepoint.cpp */; };\n\t\t037C39602897E33600328EC8 /* Recyclable.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 236996B121D5C4FF00E72E81 /* Recyclable.cpp */; };\n\t\t037C39612897E33600328EC8 /* Data.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23775BCB20AD72BC00E21AB0 /* Data.cpp */; };\n\t\t037C39622897E33600328EC8 /* SyntaxForeignKeyClause.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDC04217DFADC006E9E73 /* SyntaxForeignKeyClause.cpp */; };\n\t\t037C39632897E33600328EC8 /* IndexedColumn.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDB90217DFADC006E9E73 /* IndexedColumn.cpp */; };\n\t\t037C39642897E33600328EC8 /* RaiseFunction.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDBA0217DFADC006E9E73 /* RaiseFunction.cpp */; };\n\t\t037C39662897E33600328EC8 /* ColumnConstraint.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDB7E217DFADC006E9E73 /* ColumnConstraint.cpp */; };\n\t\t037C39692897E33600328EC8 /* Range.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2314AE6F21070A1700244D39 /* Range.cpp */; };\n\t\t037C396B2897E33600328EC8 /* ThreadedErrors.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23F1698920B6638F009B5C47 /* ThreadedErrors.cpp */; };\n\t\t037C39712897E33600328EC8 /* StatementCreateTrigger.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDBC7217DFADC006E9E73 /* StatementCreateTrigger.cpp */; };\n\t\t037C39722897E33600328EC8 /* DatabasePool.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23D96B902050DED700DB5E93 /* DatabasePool.cpp */; };\n\t\t037C39752897E33600328EC8 /* TokenizerModules.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2304B42C22156E1500901953 /* TokenizerModules.cpp */; };\n\t\t037C39782897E33600328EC8 /* FactoryDepositor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23D0C34B20C149D80001BFAE /* FactoryDepositor.cpp */; };\n\t\t037C397D2897E33600328EC8 /* TokenizerConfig.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23F70FBC20A055D400CCE3CD /* TokenizerConfig.cpp */; };\n\t\t037C397E2897E33600328EC8 /* FactoryRetriever.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23D0C34F20C149D80001BFAE /* FactoryRetriever.cpp */; };\n\t\t037C39812897E33600328EC8 /* StatementRollback.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDBE1217DFADC006E9E73 /* StatementRollback.cpp */; };\n\t\t037C39822897E33600328EC8 /* Exiting.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 231C35EC21DE09E400B5D3D2 /* Exiting.cpp */; };\n\t\t037C39852897E33600328EC8 /* Migration.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23A64D0D214A4A7000ED28BB /* Migration.cpp */; };\n\t\t037C39862897E33600328EC8 /* Configs.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3962FFCE23051F71008934D4 /* Configs.cpp */; };\n\t\t037C39872897E33600328EC8 /* SyntaxCreateTriggerSTMT.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDC3F217DFADC006E9E73 /* SyntaxCreateTriggerSTMT.cpp */; };\n\t\t037C398A2897E33600328EC8 /* Column.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDB7C217DFADC006E9E73 /* Column.cpp */; };\n\t\t037C398E2897E33600328EC8 /* StatementSelect.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDBE5217DFADC006E9E73 /* StatementSelect.cpp */; };\n\t\t037C39952897E33600328EC8 /* SyntaxReindexSTMT.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDC55217DFADC006E9E73 /* SyntaxReindexSTMT.cpp */; };\n\t\t037C39982897E33600328EC8 /* SyntaxCreateViewSTMT.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDC41217DFADC006E9E73 /* SyntaxCreateViewSTMT.cpp */; };\n\t\t037C39992897E33600328EC8 /* BindParameter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDB7A217DFADC006E9E73 /* BindParameter.cpp */; };\n\t\t037C399A2897E33600328EC8 /* AutoBackupConfig.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23301BFA229A851800A8AB5A /* AutoBackupConfig.cpp */; };\n\t\t037C399D2897E33600328EC8 /* SyntaxRaiseFunction.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDC1C217DFADC006E9E73 /* SyntaxRaiseFunction.cpp */; };\n\t\t037C399E2897E33600328EC8 /* FrameSpec.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDB8C217DFADC006E9E73 /* FrameSpec.cpp */; };\n\t\t037C39A12897E33600328EC8 /* HandlePool.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2349F6221EA0D6680021EFA7 /* HandlePool.cpp */; };\n\t\t037C39A32897E33600328EC8 /* SyntaxWindowDef.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDC2C217DFADC006E9E73 /* SyntaxWindowDef.cpp */; };\n\t\t037C39A72897E33600328EC8 /* PagerRelated.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23567D5720CA823C005F1C35 /* PagerRelated.cpp */; };\n\t\t037C39AB2897E33600328EC8 /* SyntaxColumnDef.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDBFA217DFADC006E9E73 /* SyntaxColumnDef.cpp */; };\n\t\t037C39AD2897E33600328EC8 /* WindowDef.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDBB0217DFADC006E9E73 /* WindowDef.cpp */; };\n\t\t037C39AE2897E33600328EC8 /* FileManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23B9E67420AE733A00CF1683 /* FileManager.cpp */; };\n\t\t037C39AF2897E33600328EC8 /* SyntaxColumn.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDBF6217DFADC006E9E73 /* SyntaxColumn.cpp */; };\n\t\t037C39B02897E33600328EC8 /* SyntaxFilter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDC02217DFADC006E9E73 /* SyntaxFilter.cpp */; };\n\t\t037C39B12897E33600328EC8 /* StatementDelete.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDBCD217DFADC006E9E73 /* StatementDelete.cpp */; };\n\t\t037C39B32897E33600328EC8 /* ErrorProne.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23567D4620CA7DBC005F1C35 /* ErrorProne.cpp */; };\n\t\t037C39B52897E33600328EC8 /* SyntaxInsertSTMT.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDC51217DFADC006E9E73 /* SyntaxInsertSTMT.cpp */; };\n\t\t037C39B82897E33600328EC8 /* Shm.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23408F0D211897AA0071E5A7 /* Shm.cpp */; };\n\t\t037C39B92897E33600328EC8 /* InnerDatabase.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2349F61B1EA0D6680021EFA7 /* InnerDatabase.cpp */; };\n\t\t037C39BA2897E33600328EC8 /* Pragma.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDB9C217DFADC006E9E73 /* Pragma.cpp */; };\n\t\t037C39BB2897E33600328EC8 /* UpgradeableErrorProne.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23AD52F020DBAC4C00664B62 /* UpgradeableErrorProne.cpp */; };\n\t\t037C39C02897E33600328EC8 /* SharedThreadedErrorProne.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23567D7220CA91FF005F1C35 /* SharedThreadedErrorProne.cpp */; };\n\t\t037C39C12897E33600328EC8 /* LiteralValue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDB96217DFADC006E9E73 /* LiteralValue.cpp */; };\n\t\t037C39C52897E33600328EC8 /* SyntaxCreateIndexSTMT.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDC3B217DFADC006E9E73 /* SyntaxCreateIndexSTMT.cpp */; };\n\t\t037C39CC2897E33600328EC8 /* SyntaxAlterTableSTMT.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDC31217DFADC006E9E73 /* SyntaxAlterTableSTMT.cpp */; };\n\t\t037C39CD2897E33600328EC8 /* SyntaxCreateVirtualTableSTMT.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDC43217DFADC006E9E73 /* SyntaxCreateVirtualTableSTMT.cpp */; };\n\t\t037C39CE2897E33600328EC8 /* SyntaxAttachSTMT.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDC35217DFADC006E9E73 /* SyntaxAttachSTMT.cpp */; };\n\t\t037C39D02897E33600328EC8 /* SyntaxJoinClause.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDC0E217DFADC006E9E73 /* SyntaxJoinClause.cpp */; };\n\t\t037C39D32897E33600328EC8 /* SyntaxDropTableSTMT.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDC4B217DFADC006E9E73 /* SyntaxDropTableSTMT.cpp */; };\n\t\t037C39D52897E33600328EC8 /* SyntaxExplainSTMT.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3960D8992319258B00EF05D1 /* SyntaxExplainSTMT.cpp */; };\n\t\t037C39D82897E33600328EC8 /* SyntaxLiteralValue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDC12217DFADC006E9E73 /* SyntaxLiteralValue.cpp */; };\n\t\t037C39DA2897E33600328EC8 /* StringView.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 235EE9C422B6321A008F6658 /* StringView.cpp */; };\n\t\t037C39DD2897E33600328EC8 /* SyntaxRollbackSTMT.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDC59217DFADC006E9E73 /* SyntaxRollbackSTMT.cpp */; };\n\t\t037C39DE2897E33600328EC8 /* HandleStatement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2370980820590CA700E768B4 /* HandleStatement.cpp */; };\n\t\t037C39E02897E33600328EC8 /* CoreFunction.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDB6F217DFADC006E9E73 /* CoreFunction.cpp */; };\n\t\t037C39E52897E33600328EC8 /* FactoryRenewer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23DD76BB20CF78C800E9B451 /* FactoryRenewer.cpp */; };\n\t\t037C39E62897E33600328EC8 /* TokenizerModule.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2304B42622156CD700901953 /* TokenizerModule.cpp */; };\n\t\t037C39E72897E33600328EC8 /* SyntaxFrameSpec.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDC06217DFADC006E9E73 /* SyntaxFrameSpec.cpp */; };\n\t\t037C39E92897E33600328EC8 /* SyntaxTableOrSubquery.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDC28217DFADC006E9E73 /* SyntaxTableOrSubquery.cpp */; };\n\t\t037C39EC2897E33600328EC8 /* Time.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23567D7920CA93C5005F1C35 /* Time.cpp */; };\n\t\t037C39F02897E33600328EC8 /* StatementVacuum.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDBE9217DFADC006E9E73 /* StatementVacuum.cpp */; };\n\t\t037C39F12897E33600328EC8 /* AbstractHandle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2347378D21CBB3A800AD5E41 /* AbstractHandle.cpp */; };\n\t\t037C39F52897E33600328EC8 /* StatementExplain.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3960D89D2319288C00EF05D1 /* StatementExplain.cpp */; };\n\t\t037C39F62897E33600328EC8 /* CommonCore.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23B4DCBB2112A9C800954D71 /* CommonCore.cpp */; };\n\t\t037C39F72897E33600328EC8 /* SyntaxIndexedColumn.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDC0C217DFADC006E9E73 /* SyntaxIndexedColumn.cpp */; };\n\t\t037C39F92897E33600328EC8 /* Pager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23775B4920AD666900E21AB0 /* Pager.cpp */; };\n\t\t037C39FF2897E33600328EC8 /* Console.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 233A8530215E7CFE00BB8D4F /* Console.cpp */; };\n\t\t037C3A012897E33600328EC8 /* Upsert.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDBAE217DFADC006E9E73 /* Upsert.cpp */; };\n\t\t037C3A022897E33600328EC8 /* MasterItem.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23AD52D420DB4A3C00664B62 /* MasterItem.cpp */; };\n\t\t037C3A032897E33600328EC8 /* StatementDropIndex.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDBD1217DFADC006E9E73 /* StatementDropIndex.cpp */; };\n\t\t037C3A042897E33600328EC8 /* WCDBError.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23775B3020AD666900E21AB0 /* WCDBError.cpp */; };\n\t\t037C3A052897E33600328EC8 /* StatementInsert.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDBD9217DFADC006E9E73 /* StatementInsert.cpp */; };\n\t\t037C3A062897E33600328EC8 /* SubstringMatchInfo.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7543DD90271C601F00B533B4 /* SubstringMatchInfo.cpp */; };\n\t\t037C3A092897E33600328EC8 /* Assemble.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 39C70CC52313E20E002D773C /* Assemble.cpp */; };\n\t\t037C3A0A2897E33600328EC8 /* Cell.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23775B4520AD666900E21AB0 /* Cell.cpp */; };\n\t\t037C3A0C2897E33600328EC8 /* AuxiliaryFunctionConfig.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7543DD8C271C360E00B533B4 /* AuxiliaryFunctionConfig.cpp */; };\n\t\t037C3A112897E33600328EC8 /* Frame.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23567CF820CA3889005F1C35 /* Frame.cpp */; };\n\t\t037C3A132897E33600328EC8 /* Path.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23B35C7520BFE39500425033 /* Path.cpp */; };\n\t\t037C3A142897E33600328EC8 /* CommonTableExpression.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDB82217DFADC006E9E73 /* CommonTableExpression.cpp */; };\n\t\t037C3A162897E33600328EC8 /* PerformanceTraceConfig.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2360A60120D78F2B00E4A311 /* PerformanceTraceConfig.cpp */; };\n\t\t037C3A172897E33600328EC8 /* StatementCommit.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDBC1217DFADC006E9E73 /* StatementCommit.cpp */; };\n\t\t037C3A1A2897E33600328EC8 /* AutoCheckpointConfig.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23F70FB620A055CF00CCE3CD /* AutoCheckpointConfig.cpp */; };\n\t\t037C3A1D2897E33600328EC8 /* Filter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDB88217DFADC006E9E73 /* Filter.cpp */; };\n\t\t037C3A1E2897E33600328EC8 /* Thread.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 390E1C5A2296414C00C24598 /* Thread.cpp */; };\n\t\t037C3A1F2897E33600328EC8 /* OperationQueue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3934DAE9229B6659008A6AEC /* OperationQueue.cpp */; };\n\t\t037C3A202897E33600328EC8 /* AutoMergeFTSIndexConfig.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0D3AE53F25416DB4007B9D0E /* AutoMergeFTSIndexConfig.cpp */; };\n\t\t037C3A222897E33600328EC8 /* QualifiedTable.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDB9E217DFADC006E9E73 /* QualifiedTable.cpp */; };\n\t\t037C3A242897E33600328EC8 /* BasicConfig.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23F70FA420A055BD00CCE3CD /* BasicConfig.cpp */; };\n\t\t037C3A252897E33600328EC8 /* StatementPragma.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDBDB217DFADC006E9E73 /* StatementPragma.cpp */; };\n\t\t037C3A262897E33600328EC8 /* MergeFTSIndexLogic.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0D249BC82542B90600B43BD9 /* MergeFTSIndexLogic.cpp */; };\n\t\t037C3A272897E33600328EC8 /* SyntaxAnalyzeSTMT.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDC33217DFADC006E9E73 /* SyntaxAnalyzeSTMT.cpp */; };\n\t\t037C3A292897E33600328EC8 /* SyntaxQualifiedTableName.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDC1A217DFADC006E9E73 /* SyntaxQualifiedTableName.cpp */; };\n\t\t037C3A2A2897E33600328EC8 /* SyntaxSchema.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDC22217DFADC006E9E73 /* SyntaxSchema.cpp */; };\n\t\t037C3A302897E33600328EC8 /* ColumnMeta.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 237B47AE21FEEA200059227A /* ColumnMeta.cpp */; };\n\t\t037C3A312897E33600328EC8 /* UnsafeData.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2375945F210081AA00DBB721 /* UnsafeData.cpp */; };\n\t\t037C3A322897E33600328EC8 /* ColumnDef.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDB80217DFADC006E9E73 /* ColumnDef.cpp */; };\n\t\t037C3A342897E33600328EC8 /* TableConstraint.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDBAA217DFADC006E9E73 /* TableConstraint.cpp */; };\n\t\t037C3A352897E33600328EC8 /* SyntaxColumnConstraint.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDBF8217DFADC006E9E73 /* SyntaxColumnConstraint.cpp */; };\n\t\t037C3A362897E33600328EC8 /* Repairman.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EE0EB020B838E100C95998 /* Repairman.cpp */; };\n\t\t037C3A372897E33600328EC8 /* StatementBegin.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDBBF217DFADC006E9E73 /* StatementBegin.cpp */; };\n\t\t037C3A392897E33600328EC8 /* MigrationInfo.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23A64D07214A458A00ED28BB /* MigrationInfo.cpp */; };\n\t\t037C3A3A2897E33600328EC8 /* Material.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23775B4020AD666900E21AB0 /* Material.cpp */; };\n\t\t037C3A3B2897E33600328EC8 /* ForeignKey.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDB8A217DFADC006E9E73 /* ForeignKey.cpp */; };\n\t\t037C3A3D2897E33600328EC8 /* Crawlable.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23775B5020AD666900E21AB0 /* Crawlable.cpp */; };\n\t\t037C3A402897E33600328EC8 /* AggregateFunction.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDB68217DFADC006E9E73 /* AggregateFunction.cpp */; };\n\t\t037C3A412897E33600328EC8 /* SQLiteBase.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23C7559820DD17B100031A93 /* SQLiteBase.cpp */; };\n\t\t037C3A422897E33600328EC8 /* Join.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDB92217DFADC006E9E73 /* Join.cpp */; };\n\t\t037C3A432897E33600328EC8 /* SyntaxCreateTableSTMT.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDC3D217DFADC006E9E73 /* SyntaxCreateTableSTMT.cpp */; };\n\t\t037C3A452897E33600328EC8 /* FTSError.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 03EA88CF27D5F0840075C7BD /* FTSError.cpp */; };\n\t\t037C3A462897E33600328EC8 /* SyntaxDropIndexSTMT.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDC49217DFADC006E9E73 /* SyntaxDropIndexSTMT.cpp */; };\n\t\t037C3A482897E33600328EC8 /* HandleRelated.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2360A5F320D78F1B00E4A311 /* HandleRelated.cpp */; };\n\t\t037C3A492897E33600328EC8 /* SyntaxIdentifier.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDC0A217DFADC006E9E73 /* SyntaxIdentifier.cpp */; };\n\t\t037C3A4A2897E33600328EC8 /* SyntaxBindParameter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDBF4217DFADC006E9E73 /* SyntaxBindParameter.cpp */; };\n\t\t037C3A4B2897E33600328EC8 /* SyntaxDetachSTMT.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDC47217DFADC006E9E73 /* SyntaxDetachSTMT.cpp */; };\n\t\t037C3A4C2897E33600328EC8 /* Page.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23775B4720AD666900E21AB0 /* Page.cpp */; };\n\t\t037C3A502897E33600328EC8 /* SyntaxOrderingTerm.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDC16217DFADC006E9E73 /* SyntaxOrderingTerm.cpp */; };\n\t\t037C3A522897E33600328EC8 /* Serialization.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2308F84D20E32A51001CD9C3 /* Serialization.cpp */; };\n\t\t037C3A562897E33600328EC8 /* PorterStemming.c in Sources */ = {isa = PBXBuildFile; fileRef = 23E163D120FDDD8500C3F910 /* PorterStemming.c */; };\n\t\t037C3A592897E33600328EC8 /* SQLiteAssembler.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23D0C30C20C125420001BFAE /* SQLiteAssembler.cpp */; };\n\t\t037C3A5C2897E33600328EC8 /* FileHandle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2308F84B20E32A51001CD9C3 /* FileHandle.cpp */; };\n\t\t037C3A612897E33600328EC8 /* SyntaxJoinConstraint.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDC10217DFADC006E9E73 /* SyntaxJoinConstraint.cpp */; };\n\t\t037C3A632897E33600328EC8 /* SyntaxReleaseSTMT.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDC57217DFADC006E9E73 /* SyntaxReleaseSTMT.cpp */; };\n\t\t037C3A662897E33600328EC8 /* Schema.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDBA6217DFADC006E9E73 /* Schema.cpp */; };\n\t\t037C3A672897E33600328EC8 /* MasterCrawler.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23D07CE220BE87360043F4D4 /* MasterCrawler.cpp */; };\n\t\t037C3A682897E33600328EC8 /* StatementReindex.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDBDD217DFADC006E9E73 /* StatementReindex.cpp */; };\n\t\t037C3A6C2897E33600328EC8 /* Wal.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EB91DC20CA1EBE00ECF668 /* Wal.cpp */; };\n\t\t037C3A722897E33600328EC8 /* BusyRetryConfig.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 237A8D5D21EDBB2E003AF5BB /* BusyRetryConfig.cpp */; };\n\t\t037C3A742897E33600328EC8 /* SyntaxSelectSTMT.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDC5D217DFADC006E9E73 /* SyntaxSelectSTMT.cpp */; };\n\t\t037C3A752897E33600328EC8 /* InnerHandle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 39B524DC2304F9A2001DF52D /* InnerHandle.cpp */; };\n\t\t037C3A772897E33600328EC8 /* Lock.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23F0FEB3215F5E9A008399FB /* Lock.cpp */; };\n\t\t037C3A7A2897E33600328EC8 /* SyntaxSelectCore.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDC24217DFADC006E9E73 /* SyntaxSelectCore.cpp */; };\n\t\t037C3A7D2897E33600328EC8 /* StatementRelease.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDBDF217DFADC006E9E73 /* StatementRelease.cpp */; };\n\t\t037C3A812897E33600328EC8 /* Security.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 23F0FD7C215F1C92008399FB /* Security.framework */; };\n\t\t037C3A822897E33600328EC8 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 239E8A922160A81600BCB308 /* Foundation.framework */; };\n\t\t037C3A832897E33600328EC8 /* libz.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = 23C43BCC2087435800AB186D /* libz.tbd */; };\n\t\t037C3A842897E33600328EC8 /* sqlcipher.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 23F5BE0620887FD4000CCD37 /* sqlcipher.framework */; };\n\t\t037C3A862897E33600328EC8 /* AsyncQueue.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23B4DCE02112B03C00954D71 /* AsyncQueue.hpp */; };\n\t\t037C3A872897E33600328EC8 /* AutoBackupConfig.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23301BF9229A851800A8AB5A /* AutoBackupConfig.hpp */; };\n\t\t037C3A882897E33600328EC8 /* WINQ.h in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDBEB217DFADC006E9E73 /* WINQ.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t037C3A8A2897E33600328EC8 /* UnsafeData.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23759460210081AA00DBB721 /* UnsafeData.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t037C3A8C2897E33600328EC8 /* CommonCore.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 234591F5204432E400DC7D34 /* CommonCore.hpp */; };\n\t\t037C3A8F2897E33600328EC8 /* Pragma.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDB9D217DFADC006E9E73 /* Pragma.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t037C3A902897E33600328EC8 /* SequenceItem.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23AD52DC20DB56D200664B62 /* SequenceItem.hpp */; };\n\t\t037C3A912897E33600328EC8 /* MappedData.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 2316D92B21057CA600707AFC /* MappedData.hpp */; };\n\t\t037C3A922897E33600328EC8 /* SyntaxCommitSTMT.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDC3A217DFADC006E9E73 /* SyntaxCommitSTMT.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t037C3A932897E33600328EC8 /* Syntax.h in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDC65217DFADC006E9E73 /* Syntax.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t037C3A942897E33600328EC8 /* SyntaxAttachSTMT.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDC36217DFADC006E9E73 /* SyntaxAttachSTMT.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t037C3A952897E33600328EC8 /* CommonTableExpression.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDB83217DFADC006E9E73 /* CommonTableExpression.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t037C3A982897E33600328EC8 /* Console.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 233A8531215E7CFE00BB8D4F /* Console.hpp */; };\n\t\t037C3A9C2897E33600328EC8 /* CommonCore.h in Headers */ = {isa = PBXBuildFile; fileRef = 391F7C83225DE8FD0095E82D /* CommonCore.h */; };\n\t\t037C3A9D2897E33600328EC8 /* HandleNotification.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 2360A5F520D78F1B00E4A311 /* HandleNotification.hpp */; };\n\t\t037C3A9E2897E33600328EC8 /* SyntaxCreateTableSTMT.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDC3E217DFADC006E9E73 /* SyntaxCreateTableSTMT.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t037C3A9F2897E33600328EC8 /* SyntaxDropTriggerSTMT.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDC4E217DFADC006E9E73 /* SyntaxDropTriggerSTMT.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t037C3AA02897E33600328EC8 /* TokenizerModuleTemplate.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23B4DCD92112AC5600954D71 /* TokenizerModuleTemplate.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t037C3AA12897E33600328EC8 /* Convertible.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDB6C217DFADC006E9E73 /* Convertible.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t037C3AA22897E33600328EC8 /* Initializeable.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23AF4E1D20CD04E20050033C /* Initializeable.hpp */; };\n\t\t037C3AA52897E33600328EC8 /* Recyclable.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 2316D92D21057CA700707AFC /* Recyclable.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t037C3AA62897E33600328EC8 /* CoreConst.h in Headers */ = {isa = PBXBuildFile; fileRef = 237C900621D45E6700EE6E44 /* CoreConst.h */; };\n\t\t037C3AA72897E33600328EC8 /* Cell.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23775B4620AD666900E21AB0 /* Cell.hpp */; };\n\t\t037C3AA92897E33600328EC8 /* BasicConfig.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23F70FA520A055BD00CCE3CD /* BasicConfig.hpp */; };\n\t\t037C3AAA2897E33600328EC8 /* StatementDropIndex.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDBD2217DFADC006E9E73 /* StatementDropIndex.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t037C3AAB2897E33600328EC8 /* Pager.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23775B4A20AD666900E21AB0 /* Pager.hpp */; };\n\t\t037C3AAC2897E33600328EC8 /* SyntaxCreateIndexSTMT.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDC3C217DFADC006E9E73 /* SyntaxCreateIndexSTMT.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t037C3AAF2897E33600328EC8 /* Crawlable.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23775B5120AD666900E21AB0 /* Crawlable.hpp */; };\n\t\t037C3AB02897E33600328EC8 /* LiteralValue.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDB97217DFADC006E9E73 /* LiteralValue.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t037C3AB12897E33600328EC8 /* CustomConfig.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23F70FD520A07CEC00CCE3CD /* CustomConfig.hpp */; };\n\t\t037C3AB22897E33600328EC8 /* StatementCreateTable.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDBC6217DFADC006E9E73 /* StatementCreateTable.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t037C3AB32897E33600328EC8 /* ForeignKey.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDB8B217DFADC006E9E73 /* ForeignKey.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t037C3AB62897E33600328EC8 /* WCDBVersion.h in Headers */ = {isa = PBXBuildFile; fileRef = 23176A8B21B912B10051ACF9 /* WCDBVersion.h */; };\n\t\t037C3AB82897E33600328EC8 /* StatementDropTrigger.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDBD6217DFADC006E9E73 /* StatementDropTrigger.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t037C3AB92897E33600328EC8 /* FTSFunction.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDB74217DFADC006E9E73 /* FTSFunction.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t037C3ABF2897E33600328EC8 /* WalRelated.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23593B7C20D3ADF80058B416 /* WalRelated.hpp */; };\n\t\t037C3AC02897E33600328EC8 /* FactoryRelated.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23D0C36220C14ACC0001BFAE /* FactoryRelated.hpp */; };\n\t\t037C3AC12897E33600328EC8 /* SyntaxSelectSTMT.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDC5E217DFADC006E9E73 /* SyntaxSelectSTMT.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t037C3AC32897E33600328EC8 /* PerformanceTraceConfig.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 2360A60220D78F2B00E4A311 /* PerformanceTraceConfig.hpp */; };\n\t\t037C3AC42897E33600328EC8 /* ColumnMeta.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 237B47AF21FEEA200059227A /* ColumnMeta.hpp */; };\n\t\t037C3AC62897E33600328EC8 /* Macro.h in Headers */ = {isa = PBXBuildFile; fileRef = 239776D0202AF2E2000A681C /* Macro.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t037C3AC72897E33600328EC8 /* BusyRetryConfig.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 237A8D5E21EDBB2E003AF5BB /* BusyRetryConfig.hpp */; };\n\t\t037C3AC82897E33600328EC8 /* Progress.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23A6D4BE20BFD7F9004F2DAA /* Progress.hpp */; };\n\t\t037C3AC92897E33600328EC8 /* SyntaxForeignKeyClause.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDC05217DFADC006E9E73 /* SyntaxForeignKeyClause.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t037C3ACA2897E33600328EC8 /* SyntaxAssertion.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23545B962224E8270091C981 /* SyntaxAssertion.hpp */; };\n\t\t037C3ACB2897E33600328EC8 /* SyntaxSelectCore.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDC25217DFADC006E9E73 /* SyntaxSelectCore.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t037C3ACC2897E33600328EC8 /* SyntaxTableConstraint.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDC27217DFADC006E9E73 /* SyntaxTableConstraint.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t037C3ACD2897E33600328EC8 /* ThreadedErrors.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23F1698720B6638F009B5C47 /* ThreadedErrors.hpp */; };\n\t\t037C3ACE2897E33600328EC8 /* TableConstraint.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDBAB217DFADC006E9E73 /* TableConstraint.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t037C3ACF2897E33600328EC8 /* AuxiliaryFunctionConfig.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 7543DD8D271C360E00B533B4 /* AuxiliaryFunctionConfig.hpp */; };\n\t\t037C3AD12897E33600328EC8 /* SQL.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDBA9217DFADC006E9E73 /* SQL.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t037C3AD32897E33600328EC8 /* SequenceCrawler.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23D07CE920BE873E0043F4D4 /* SequenceCrawler.hpp */; };\n\t\t037C3AD42897E33600328EC8 /* PageBasedFileHandle.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 2316D9422105D19500707AFC /* PageBasedFileHandle.hpp */; };\n\t\t037C3AD52897E33600328EC8 /* SQLTraceConfig.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 2360A60020D78F2B00E4A311 /* SQLTraceConfig.hpp */; };\n\t\t037C3AD62897E33600328EC8 /* Data.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23775BCC20AD72BC00E21AB0 /* Data.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t037C3AD82897E33600328EC8 /* Assertion.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23775B2F20AD666900E21AB0 /* Assertion.hpp */; };\n\t\t037C3ADB2897E33600328EC8 /* Filter.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDB89217DFADC006E9E73 /* Filter.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t037C3ADC2897E33600328EC8 /* SyntaxDropViewSTMT.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDC50217DFADC006E9E73 /* SyntaxDropViewSTMT.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t037C3ADD2897E33600328EC8 /* Scoreable.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 2376CB1A20DA5D3B00A68DB5 /* Scoreable.hpp */; };\n\t\t037C3ADE2897E33600328EC8 /* CaseInsensitiveList.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 39411A3E22437E7B00A388F5 /* CaseInsensitiveList.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t037C3ADF2897E33600328EC8 /* SyntaxForwardDeclaration.h in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDB75217DFADC006E9E73 /* SyntaxForwardDeclaration.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t037C3AE22897E33600328EC8 /* MigrationInfo.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23A64D08214A458A00ED28BB /* MigrationInfo.hpp */; };\n\t\t037C3AE32897E33600328EC8 /* StatementCreateIndex.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDBC4217DFADC006E9E73 /* StatementCreateIndex.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t037C3AE72897E33600328EC8 /* StringView.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 235EE9C322B63219008F6658 /* StringView.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t037C3AE82897E33600328EC8 /* RepairKit.h in Headers */ = {isa = PBXBuildFile; fileRef = 23B9E66920AE6EE400CF1683 /* RepairKit.h */; };\n\t\t037C3AEA2897E33600328EC8 /* OrderingTerm.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDB9B217DFADC006E9E73 /* OrderingTerm.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t037C3AEB2897E33600328EC8 /* SyntaxUpsertClause.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDC2B217DFADC006E9E73 /* SyntaxUpsertClause.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t037C3AEC2897E33600328EC8 /* Shm.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23408F0E211897AA0071E5A7 /* Shm.hpp */; };\n\t\t037C3AED2897E33600328EC8 /* StatementDetach.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDBD0217DFADC006E9E73 /* StatementDetach.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t037C3AEE2897E33600328EC8 /* SubstringMatchInfo.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 7543DD91271C601F00B533B4 /* SubstringMatchInfo.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t037C3AF12897E33600328EC8 /* SyntaxBeginSTMT.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDC38217DFADC006E9E73 /* SyntaxBeginSTMT.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t037C3AF32897E33600328EC8 /* SyntaxUpdateSTMT.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDC60217DFADC006E9E73 /* SyntaxUpdateSTMT.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t037C3AF42897E33600328EC8 /* ResultColumn.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDBA5217DFADC006E9E73 /* ResultColumn.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t037C3AF52897E33600328EC8 /* StatementCreateTrigger.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDBC8217DFADC006E9E73 /* StatementCreateTrigger.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t037C3AF62897E33600328EC8 /* Repairman.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EE0EB120B838E100C95998 /* Repairman.hpp */; };\n\t\t037C3AF72897E33600328EC8 /* ExpressionOperable.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDB72217DFADC006E9E73 /* ExpressionOperable.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t037C3AF82897E33600328EC8 /* HandleRelated.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 2360A5F620D78F1B00E4A311 /* HandleRelated.hpp */; };\n\t\t037C3AF92897E33600328EC8 /* SyntaxOrderingTerm.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDC17217DFADC006E9E73 /* SyntaxOrderingTerm.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t037C3AFD2897E33600328EC8 /* SyntaxAlterTableSTMT.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDC32217DFADC006E9E73 /* SyntaxAlterTableSTMT.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t037C3AFF2897E33600328EC8 /* IndexedColumn.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDB91217DFADC006E9E73 /* IndexedColumn.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t037C3B012897E33600328EC8 /* TokenizerModule.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 2304B42722156CD700901953 /* TokenizerModule.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t037C3B022897E33600328EC8 /* AbstractHandle.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 2347378E21CBB3A800AD5E41 /* AbstractHandle.hpp */; };\n\t\t037C3B032897E33600328EC8 /* Factory.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23D0C34A20C149D80001BFAE /* Factory.hpp */; };\n\t\t037C3B052897E33600328EC8 /* SyntaxFrameSpec.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDC07217DFADC006E9E73 /* SyntaxFrameSpec.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t037C3B072897E33600328EC8 /* Path.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23B35C7420BFE39400425033 /* Path.hpp */; };\n\t\t037C3B092897E33600328EC8 /* Migration.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23A64D0E214A4A7000ED28BB /* Migration.hpp */; };\n\t\t037C3B0A2897E33600328EC8 /* SyntaxRaiseFunction.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDC1D217DFADC006E9E73 /* SyntaxRaiseFunction.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t037C3B0B2897E33600328EC8 /* StatementSelect.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDBE6217DFADC006E9E73 /* StatementSelect.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t037C3B0D2897E33600328EC8 /* SyntaxDropTableSTMT.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDC4C217DFADC006E9E73 /* SyntaxDropTableSTMT.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t037C3B0F2897E33600328EC8 /* SyntaxExplainSTMT.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 3960D89A2319258B00EF05D1 /* SyntaxExplainSTMT.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t037C3B102897E33600328EC8 /* StatementDropView.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDBD8217DFADC006E9E73 /* StatementDropView.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t037C3B112897E33600328EC8 /* StatementExplain.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 3960D89E2319288C00EF05D1 /* StatementExplain.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t037C3B132897E33600328EC8 /* Backup.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23775B3F20AD666900E21AB0 /* Backup.hpp */; };\n\t\t037C3B142897E33600328EC8 /* MasterItem.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23AD52D520DB4A3C00664B62 /* MasterItem.hpp */; };\n\t\t037C3B152897E33600328EC8 /* BindParameter.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDB7B217DFADC006E9E73 /* BindParameter.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t037C3B162897E33600328EC8 /* Join.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDB93217DFADC006E9E73 /* Join.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t037C3B172897E33600328EC8 /* HighWater.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23E7EB1C2123D58D0056B5D8 /* HighWater.hpp */; };\n\t\t037C3B182897E33600328EC8 /* SyntaxIdentifier.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDC0B217DFADC006E9E73 /* SyntaxIdentifier.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t037C3B192897E33600328EC8 /* Fraction.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23AD52E520DB852B00664B62 /* Fraction.hpp */; };\n\t\t037C3B1A2897E33600328EC8 /* StatementDropTable.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDBD4217DFADC006E9E73 /* StatementDropTable.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t037C3B1B2897E33600328EC8 /* SyntaxExpression.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDC01217DFADC006E9E73 /* SyntaxExpression.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t037C3B1C2897E33600328EC8 /* MasterCrawler.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23D07CE320BE87360043F4D4 /* MasterCrawler.hpp */; };\n\t\t037C3B1F2897E33600328EC8 /* TokenizerModules.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 2304B42D22156E1500901953 /* TokenizerModules.hpp */; };\n\t\t037C3B212897E33600328EC8 /* QualifiedTable.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDB9F217DFADC006E9E73 /* QualifiedTable.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t037C3B222897E33600328EC8 /* AutoMergeFTSIndexConfig.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 0D3AE53725416D99007B9D0E /* AutoMergeFTSIndexConfig.hpp */; };\n\t\t037C3B232897E33600328EC8 /* Exiting.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 231C35EA21DE090500B5D3D2 /* Exiting.hpp */; };\n\t\t037C3B242897E33600328EC8 /* Config.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23F70F9F20A055B400CCE3CD /* Config.hpp */; };\n\t\t037C3B282897E33600328EC8 /* Page.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23775B4820AD666900E21AB0 /* Page.hpp */; };\n\t\t037C3B2A2897E33600328EC8 /* SyntaxFilter.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDC03217DFADC006E9E73 /* SyntaxFilter.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t037C3B2B2897E33600328EC8 /* StatementRollback.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDBE2217DFADC006E9E73 /* StatementRollback.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t037C3B2D2897E33600328EC8 /* StatementAlterTable.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDBBA217DFADC006E9E73 /* StatementAlterTable.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t037C3B2E2897E33600328EC8 /* StatementPragma.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDBDC217DFADC006E9E73 /* StatementPragma.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t037C3B2F2897E33600328EC8 /* RecyclableHandle.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 2349F6251EA0D6680021EFA7 /* RecyclableHandle.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t037C3B302897E33600328EC8 /* SyntaxSchema.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDC23217DFADC006E9E73 /* SyntaxSchema.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t037C3B322897E33600328EC8 /* SyntaxLiteralValue.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDC13217DFADC006E9E73 /* SyntaxLiteralValue.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t037C3B332897E33600328EC8 /* StatementReindex.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDBDE217DFADC006E9E73 /* StatementReindex.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t037C3B342897E33600328EC8 /* SyntaxList.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDB76217DFADC006E9E73 /* SyntaxList.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t037C3B372897E33600328EC8 /* ColumnConstraint.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDB7F217DFADC006E9E73 /* ColumnConstraint.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t037C3B392897E33600328EC8 /* SQLiteDeclaration.h in Headers */ = {isa = PBXBuildFile; fileRef = 237A8D5721ED88DF003AF5BB /* SQLiteDeclaration.h */; };\n\t\t037C3B3A2897E33600328EC8 /* SyntaxEnum.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23545B9C2224E9C80091C981 /* SyntaxEnum.hpp */; };\n\t\t037C3B3D2897E33600328EC8 /* StatementCreateView.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDBCA217DFADC006E9E73 /* StatementCreateView.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t037C3B3E2897E33600328EC8 /* SyntaxCreateVirtualTableSTMT.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDC44217DFADC006E9E73 /* SyntaxCreateVirtualTableSTMT.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t037C3B3F2897E33600328EC8 /* Shadow.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDD5F217DFB17006E9E73 /* Shadow.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t037C3B422897E33600328EC8 /* JoinConstraint.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDB95217DFADC006E9E73 /* JoinConstraint.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t037C3B442897E33600328EC8 /* SyntaxReleaseSTMT.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDC58217DFADC006E9E73 /* SyntaxReleaseSTMT.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t037C3B452897E33600328EC8 /* Serialization.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 2308F84E20E32A51001CD9C3 /* Serialization.hpp */; };\n\t\t037C3B482897E33600328EC8 /* SyntaxColumn.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDBF7217DFADC006E9E73 /* SyntaxColumn.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t037C3B492897E33600328EC8 /* InnerDatabase.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 2349F61C1EA0D6680021EFA7 /* InnerDatabase.hpp */; };\n\t\t037C3B4C2897E33600328EC8 /* MergeFTSIndexLogic.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 0D249BC02542B8E900B43BD9 /* MergeFTSIndexLogic.hpp */; };\n\t\t037C3B4D2897E33600328EC8 /* SyntaxAnalyzeSTMT.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDC34217DFADC006E9E73 /* SyntaxAnalyzeSTMT.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t037C3B4E2897E33600328EC8 /* SyntaxColumnConstraint.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDBF9217DFADC006E9E73 /* SyntaxColumnConstraint.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t037C3B552897E33600328EC8 /* SyntaxReindexSTMT.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDC56217DFADC006E9E73 /* SyntaxReindexSTMT.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t037C3B562897E33600328EC8 /* SyntaxCommonTableExpression.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDBFD217DFADC006E9E73 /* SyntaxCommonTableExpression.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t037C3B572897E33600328EC8 /* UpgradeableErrorProne.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23AD52F120DBAC4C00664B62 /* UpgradeableErrorProne.hpp */; };\n\t\t037C3B5B2897E33600328EC8 /* PagerRelated.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23567D5820CA823C005F1C35 /* PagerRelated.hpp */; };\n\t\t037C3B5D2897E33600328EC8 /* Tag.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23B4DC7D2111B39200954D71 /* Tag.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t037C3B5E2897E33600328EC8 /* SQLite.h in Headers */ = {isa = PBXBuildFile; fileRef = 23AB898D215BA6DB00554DF1 /* SQLite.h */; };\n\t\t037C3B5F2897E33600328EC8 /* SyntaxPragma.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDC19217DFADC006E9E73 /* SyntaxPragma.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t037C3B642897E33600328EC8 /* StatementCreateVirtualTable.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDBCC217DFADC006E9E73 /* StatementCreateVirtualTable.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t037C3B652897E33600328EC8 /* SQLiteFTS3Tokenizer.h in Headers */ = {isa = PBXBuildFile; fileRef = 234F0337227A950900DD65A2 /* SQLiteFTS3Tokenizer.h */; };\n\t\t037C3B672897E33600328EC8 /* HandlePool.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 2349F6231EA0D6680021EFA7 /* HandlePool.hpp */; };\n\t\t037C3B682897E33600328EC8 /* StatementInsert.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDBDA217DFADC006E9E73 /* StatementInsert.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t037C3B6A2897E33600328EC8 /* FactoryDepositor.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23D0C34C20C149D80001BFAE /* FactoryDepositor.hpp */; };\n\t\t037C3B6C2897E33600328EC8 /* FrameSpec.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDB8D217DFADC006E9E73 /* FrameSpec.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t037C3B6D2897E33600328EC8 /* TokenizerConfig.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23F70FBD20A055D400CCE3CD /* TokenizerConfig.hpp */; };\n\t\t037C3B6E2897E33600328EC8 /* SyntaxCreateViewSTMT.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDC42217DFADC006E9E73 /* SyntaxCreateViewSTMT.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t037C3B712897E33600328EC8 /* Enum.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDD5E217DFB16006E9E73 /* Enum.hpp */; };\n\t\t037C3B732897E33600328EC8 /* SyntaxDetachSTMT.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDC48217DFADC006E9E73 /* SyntaxDetachSTMT.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t037C3B742897E33600328EC8 /* ColumnType.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDB6B217DFADC006E9E73 /* ColumnType.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t037C3B792897E33600328EC8 /* SyntaxDeleteSTMT.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDC46217DFADC006E9E73 /* SyntaxDeleteSTMT.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t037C3B7C2897E33600328EC8 /* StatementSavepoint.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDBE4217DFADC006E9E73 /* StatementSavepoint.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t037C3B7E2897E33600328EC8 /* FullCrawler.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23775B3720AD666900E21AB0 /* FullCrawler.hpp */; };\n\t\t037C3B802897E33600328EC8 /* SQLiteAssembler.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23D0C30D20C125420001BFAE /* SQLiteAssembler.hpp */; };\n\t\t037C3B842897E33600328EC8 /* StatementAttach.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDBBE217DFADC006E9E73 /* StatementAttach.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t037C3B852897E33600328EC8 /* ColumnDef.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDB81217DFADC006E9E73 /* ColumnDef.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t037C3B892897E33600328EC8 /* Wal.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EB91DD20CA1EBE00ECF668 /* Wal.hpp */; };\n\t\t037C3B8A2897E33600328EC8 /* SyntaxSavepointSTMT.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDC5C217DFADC006E9E73 /* SyntaxSavepointSTMT.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t037C3B8B2897E33600328EC8 /* AutoMigrateConfig.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23301BF42298FE9A00A8AB5A /* AutoMigrateConfig.hpp */; };\n\t\t037C3B8C2897E33600328EC8 /* UniqueList.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 237A65F220F731DF008B4771 /* UniqueList.hpp */; };\n\t\t037C3B8D2897E33600328EC8 /* HandleStatement.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 2370980920590CA700E768B4 /* HandleStatement.hpp */; };\n\t\t037C3B8E2897E33600328EC8 /* FTS5AuxiliaryFunctionTemplate.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 7543DD82271C2F3B00B533B4 /* FTS5AuxiliaryFunctionTemplate.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t037C3B912897E33600328EC8 /* SQLiteLocker.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23C7559020DCF90F00031A93 /* SQLiteLocker.hpp */; };\n\t\t037C3B942897E33600328EC8 /* ConvertibleImplementation.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDB6E217DFADC006E9E73 /* ConvertibleImplementation.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t037C3B952897E33600328EC8 /* RaiseFunction.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDBA1217DFADC006E9E73 /* RaiseFunction.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t037C3B962897E33600328EC8 /* InnerHandle.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 39B524DB2304F9A1001DF52D /* InnerHandle.hpp */; };\n\t\t037C3B982897E33600328EC8 /* Global.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 235FBE9422914E0D005C7723 /* Global.hpp */; };\n\t\t037C3B992897E33600328EC8 /* StatementBegin.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDBC0217DFADC006E9E73 /* StatementBegin.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t037C3B9A2897E33600328EC8 /* SyntaxQualifiedTableName.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDC1B217DFADC006E9E73 /* SyntaxQualifiedTableName.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t037C3B9C2897E33600328EC8 /* SyntaxJoinClause.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDC0F217DFADC006E9E73 /* SyntaxJoinClause.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t037C3B9F2897E33600328EC8 /* CoreFunction.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDB70217DFADC006E9E73 /* CoreFunction.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t037C3BA32897E33600328EC8 /* Frame.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23567CF920CA3889005F1C35 /* Frame.hpp */; };\n\t\t037C3BA72897E33600328EC8 /* Thread.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 390E1C5B2296414C00C24598 /* Thread.hpp */; };\n\t\t037C3BA92897E33600328EC8 /* FileHandle.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 2308F84C20E32A51001CD9C3 /* FileHandle.hpp */; };\n\t\t037C3BAA2897E33600328EC8 /* StatementDelete.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDBCE217DFADC006E9E73 /* StatementDelete.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t037C3BAC2897E33600328EC8 /* OperationQueue.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 3934DAEA229B6659008A6AEC /* OperationQueue.hpp */; };\n\t\t037C3BAE2897E33600328EC8 /* WindowDef.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDBB1217DFADC006E9E73 /* WindowDef.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t037C3BB32897E33600328EC8 /* SyntaxTableOrSubquery.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDC29217DFADC006E9E73 /* SyntaxTableOrSubquery.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t037C3BB42897E33600328EC8 /* StatementRelease.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDBE0217DFADC006E9E73 /* StatementRelease.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t037C3BB62897E33600328EC8 /* Notifier.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23775B3320AD666900E21AB0 /* Notifier.hpp */; };\n\t\t037C3BB72897E33600328EC8 /* SyntaxCreateTriggerSTMT.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDC40217DFADC006E9E73 /* SyntaxCreateTriggerSTMT.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t037C3BB82897E33600328EC8 /* SyntaxIndexedColumn.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDC0D217DFADC006E9E73 /* SyntaxIndexedColumn.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t037C3BB92897E33600328EC8 /* SyntaxCommonConst.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 238C177C21CA2190003B6D26 /* SyntaxCommonConst.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t037C3BBA2897E33600328EC8 /* StatementUpdate.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDBE8217DFADC006E9E73 /* StatementUpdate.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t037C3BBB2897E33600328EC8 /* SQLiteBase.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23C7559920DD17B100031A93 /* SQLiteBase.hpp */; };\n\t\t037C3BBC2897E33600328EC8 /* Expression.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDB87217DFADC006E9E73 /* Expression.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t037C3BBF2897E33600328EC8 /* SyntaxPragmaSTMT.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDC54217DFADC006E9E73 /* SyntaxPragmaSTMT.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t037C3BC02897E33600328EC8 /* Upsert.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDBAF217DFADC006E9E73 /* Upsert.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t037C3BC22897E33600328EC8 /* AuxiliaryFunctionModule.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 7543DD85271C2FD000B533B4 /* AuxiliaryFunctionModule.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t037C3BC42897E33600328EC8 /* Configs.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23F70FC320A0618100CCE3CD /* Configs.hpp */; };\n\t\t037C3BC82897E33600328EC8 /* SharedThreadedErrorProne.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23567D7420CA91FF005F1C35 /* SharedThreadedErrorProne.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t037C3BC92897E33600328EC8 /* Range.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 2314AE7021070A1700244D39 /* Range.hpp */; };\n\t\t037C3BCA2897E33600328EC8 /* SyntaxResultColumn.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDC21217DFADC006E9E73 /* SyntaxResultColumn.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t037C3BCB2897E33600328EC8 /* FTSError.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 03EA88CD27D5F05D0075C7BD /* FTSError.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t037C3BCC2897E33600328EC8 /* Mechanic.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23775B4320AD666900E21AB0 /* Mechanic.hpp */; };\n\t\t037C3BCF2897E33600328EC8 /* SyntaxJoinConstraint.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDC11217DFADC006E9E73 /* SyntaxJoinConstraint.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t037C3BD02897E33600328EC8 /* ErrorProne.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23567D4520CA7DBC005F1C35 /* ErrorProne.hpp */; };\n\t\t037C3BD52897E33600328EC8 /* StatementCommit.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDBC2217DFADC006E9E73 /* StatementCommit.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t037C3BD62897E33600328EC8 /* SyntaxColumnDef.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDBFB217DFADC006E9E73 /* SyntaxColumnDef.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t037C3BD72897E33600328EC8 /* LRUCache.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 2316D9482105D21500707AFC /* LRUCache.hpp */; };\n\t\t037C3BD92897E33600328EC8 /* StatementVacuum.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDBEA217DFADC006E9E73 /* StatementVacuum.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t037C3BDA2897E33600328EC8 /* Column.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDB7D217DFADC006E9E73 /* Column.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t037C3BDC2897E33600328EC8 /* TimedQueue.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 239776CE202AF2E2000A681C /* TimedQueue.hpp */; };\n\t\t037C3BDD2897E33600328EC8 /* Time.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23567D7A20CA93C5005F1C35 /* Time.hpp */; };\n\t\t037C3BDE2897E33600328EC8 /* FileManager.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23B9E67320AE733A00CF1683 /* FileManager.hpp */; };\n\t\t037C3BE12897E33600328EC8 /* WCDBError.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23775B3120AD666900E21AB0 /* WCDBError.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t037C3BE32897E33600328EC8 /* DatabasePool.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23D96B912050DED700DB5E93 /* DatabasePool.hpp */; };\n\t\t037C3BE42897E33600328EC8 /* SyntaxWindowDef.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDC2D217DFADC006E9E73 /* SyntaxWindowDef.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t037C3BE62897E33600328EC8 /* TableOrSubquery.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDBAD217DFADC006E9E73 /* TableOrSubquery.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t037C3BE82897E33600328EC8 /* Statement.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDBB8217DFADC006E9E73 /* Statement.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t037C3BE92897E33600328EC8 /* ThreadLocal.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23F0FEB2215F5E9A008399FB /* ThreadLocal.hpp */; };\n\t\t037C3BEA2897E33600328EC8 /* Schema.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDBA7217DFADC006E9E73 /* Schema.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t037C3BED2897E33600328EC8 /* SyntaxDropIndexSTMT.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDC4A217DFADC006E9E73 /* SyntaxDropIndexSTMT.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t037C3BEE2897E33600328EC8 /* Assemble.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 39C70CC62313E20F002D773C /* Assemble.hpp */; };\n\t\t037C3BF02897E33600328EC8 /* SyntaxBindParameter.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDBF5217DFADC006E9E73 /* SyntaxBindParameter.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t037C3BF12897E33600328EC8 /* Lock.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23F0FEB1215F5E9A008399FB /* Lock.hpp */; };\n\t\t037C3BF22897E33600328EC8 /* FactoryRetriever.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23D0C35020C149D80001BFAE /* FactoryRetriever.hpp */; };\n\t\t037C3BF52897E33600328EC8 /* AutoCheckpointConfig.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 3934DB25229B951C008A6AEC /* AutoCheckpointConfig.hpp */; };\n\t\t037C3BF92897E33600328EC8 /* SyntaxVacuumSTMT.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDC62217DFADC006E9E73 /* SyntaxVacuumSTMT.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t037C3BFA2897E33600328EC8 /* Material.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23775B4120AD666900E21AB0 /* Material.hpp */; };\n\t\t037C3BFB2897E33600328EC8 /* SyntaxInsertSTMT.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDC52217DFADC006E9E73 /* SyntaxInsertSTMT.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t037C3BFC2897E33600328EC8 /* AggregateFunction.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDB69217DFADC006E9E73 /* AggregateFunction.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t037C3BFF2897E33600328EC8 /* FactoryRenewer.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23DD76BC20CF78C800E9B451 /* FactoryRenewer.hpp */; };\n\t\t037C3C002897E33600328EC8 /* StatementAnalyze.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDBBC217DFADC006E9E73 /* StatementAnalyze.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t037C3C022897E33600328EC8 /* FactoryBackup.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23D0C38C20C17CAE0001BFAE /* FactoryBackup.hpp */; };\n\t\t037C3C042897E33600328EC8 /* CipherConfig.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23F70FAB20A055C300CCE3CD /* CipherConfig.hpp */; };\n\t\t037C3C052897E33600328EC8 /* SyntaxRollbackSTMT.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDC5A217DFADC006E9E73 /* SyntaxRollbackSTMT.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t0381A67B2817A36300E64463 /* SelectTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03331021281681200094CFCF /* SelectTests.swift */; };\n\t\t0393BEDC27F6ED860058B295 /* ErrorBridge.h in Headers */ = {isa = PBXBuildFile; fileRef = 0393BEDB27F6ED860058B295 /* ErrorBridge.h */; settings = {ATTRIBUTES = (Private, ); }; };\n\t\t0393BEE127F6EDAC0058B295 /* ErrorBridge.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0393BEDF27F6EDAC0058B295 /* ErrorBridge.cpp */; };\n\t\t0393BEE427F715180058B295 /* HandleBridge.h in Headers */ = {isa = PBXBuildFile; fileRef = 0393BEE327F715180058B295 /* HandleBridge.h */; settings = {ATTRIBUTES = (Private, ); }; };\n\t\t0393BEE627F7152F0058B295 /* HandleBridge.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0393BEE527F7152F0058B295 /* HandleBridge.cpp */; };\n\t\t0397605827F54FA10071FA8F /* ObjectBridge.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0397605727F54FA10071FA8F /* ObjectBridge.cpp */; };\n\t\t039760A827F563F00071FA8F /* ObjectBridge.swift in Sources */ = {isa = PBXBuildFile; fileRef = 039760A727F563F00071FA8F /* ObjectBridge.swift */; };\n\t\t039760AB27F5C0DD0071FA8F /* DatabaseBridge.h in Headers */ = {isa = PBXBuildFile; fileRef = 039760AA27F5C0DD0071FA8F /* DatabaseBridge.h */; settings = {ATTRIBUTES = (Private, ); }; };\n\t\t039760AE27F5C1CA0071FA8F /* DatabaseBridge.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 039760AC27F5C1CA0071FA8F /* DatabaseBridge.cpp */; };\n\t\t039BD3982845CB7C00C58BE2 /* WindowDef.swift in Sources */ = {isa = PBXBuildFile; fileRef = 039BD3972845CB7C00C58BE2 /* WindowDef.swift */; };\n\t\t039BD4362846113D00C58BE2 /* ExpressionOperatableBridge.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 039BD4342846113D00C58BE2 /* ExpressionOperatableBridge.cpp */; };\n\t\t039BD4372846113D00C58BE2 /* ExpressionOperatableBridge.h in Headers */ = {isa = PBXBuildFile; fileRef = 039BD4352846113D00C58BE2 /* ExpressionOperatableBridge.h */; settings = {ATTRIBUTES = (Private, ); }; };\n\t\t039D724A28BF773D00990803 /* Delete.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 039D724928BF773D00990803 /* Delete.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t039D724B28BF773D00990803 /* Delete.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 039D724928BF773D00990803 /* Delete.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t039D724E28BF795700990803 /* Select.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 039D724D28BF795700990803 /* Select.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t039D724F28BF795700990803 /* Select.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 039D724D28BF795700990803 /* Select.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t03A15DF928AA636A0031A50A /* ValueArray.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 03A15DF828AA636A0031A50A /* ValueArray.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t03A15DFA28AA636A0031A50A /* ValueArray.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 03A15DF828AA636A0031A50A /* ValueArray.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t03A57F16284089B800D2A4C3 /* SchemaTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03A57F15284089B800D2A4C3 /* SchemaTests.swift */; };\n\t\t03A57F192840B5A700D2A4C3 /* BindParameter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03A57F172840B5A000D2A4C3 /* BindParameter.swift */; };\n\t\t03A57F1C2840B5DC00D2A4C3 /* BindParameterBridge.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 03A57F1A2840B5DC00D2A4C3 /* BindParameterBridge.cpp */; };\n\t\t03A57F1D2840B5DC00D2A4C3 /* BindParameterBridge.h in Headers */ = {isa = PBXBuildFile; fileRef = 03A57F1B2840B5DC00D2A4C3 /* BindParameterBridge.h */; settings = {ATTRIBUTES = (Private, ); }; };\n\t\t03A57F1F2840BEFF00D2A4C3 /* BindParameterTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03A57F1E2840BEFF00D2A4C3 /* BindParameterTests.swift */; };\n\t\t03AFD33428B883E700EF5E56 /* Accessor.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 03AFD33128B883E700EF5E56 /* Accessor.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t03AFD33528B883E700EF5E56 /* Accessor.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 03AFD33128B883E700EF5E56 /* Accessor.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t03AFD33A28B8A6BD00EF5E56 /* MemberPointer.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 03AFD33928B8A6BD00EF5E56 /* MemberPointer.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t03AFD33B28B8A6BD00EF5E56 /* MemberPointer.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 03AFD33928B8A6BD00EF5E56 /* MemberPointer.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t03AFD34228B8B21B00EF5E56 /* Field.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 03AFD34128B8B21B00EF5E56 /* Field.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t03AFD34328B8B21B00EF5E56 /* Field.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 03AFD34128B8B21B00EF5E56 /* Field.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t03AFD34628B8B57600EF5E56 /* Binding.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 03AFD34528B8B57600EF5E56 /* Binding.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t03AFD34728B8B57600EF5E56 /* Binding.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 03AFD34528B8B57600EF5E56 /* Binding.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t03AFD34928B8B88300EF5E56 /* CPPORM.h in Headers */ = {isa = PBXBuildFile; fileRef = 03AFD34828B8B88300EF5E56 /* CPPORM.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t03AFD34A28B8B88300EF5E56 /* CPPORM.h in Headers */ = {isa = PBXBuildFile; fileRef = 03AFD34828B8B88300EF5E56 /* CPPORM.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t03AFD34C28B8BB7600EF5E56 /* Binding.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 03AFD34B28B8BB7600EF5E56 /* Binding.cpp */; };\n\t\t03AFD34D28B8BB7600EF5E56 /* Binding.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 03AFD34B28B8BB7600EF5E56 /* Binding.cpp */; };\n\t\t03AFD34F28B8C4EB00EF5E56 /* Field.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 03AFD34E28B8C4EB00EF5E56 /* Field.cpp */; };\n\t\t03AFD35028B8C4EB00EF5E56 /* Field.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 03AFD34E28B8C4EB00EF5E56 /* Field.cpp */; };\n\t\t03B4DB1628C98E5E00F64141 /* ORMSelectTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 03B4DB1528C98E5E00F64141 /* ORMSelectTests.mm */; };\n\t\t03B6A33C2869C51B00D83EC4 /* StatementAlterTableBridge.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 03B6A33A2869C51B00D83EC4 /* StatementAlterTableBridge.cpp */; };\n\t\t03B6A33D2869C51B00D83EC4 /* StatementAlterTableBridge.h in Headers */ = {isa = PBXBuildFile; fileRef = 03B6A33B2869C51B00D83EC4 /* StatementAlterTableBridge.h */; settings = {ATTRIBUTES = (Private, ); }; };\n\t\t03BF4B1A2888F87C00A30500 /* WCDB.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 239326611E836D7300D677CC /* WCDB.framework */; };\n\t\t03BF4B222888F8EC00A30500 /* InitializationBenchmark.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E1670B27F434E800D2C926 /* InitializationBenchmark.swift */; };\n\t\t03BF4B232888F8F800A30500 /* SyncWriteBenchmark.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E1670C27F434E800D2C926 /* SyncWriteBenchmark.swift */; };\n\t\t03BF4B242888F8FC00A30500 /* CipherWriteBenchmark.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E1670E27F434E800D2C926 /* CipherWriteBenchmark.swift */; };\n\t\t03BF4B252888F90000A30500 /* CipherReadBenchmark.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E1670F27F434E800D2C926 /* CipherReadBenchmark.swift */; };\n\t\t03BF4B262888F90400A30500 /* BaselineWriteBenchmark.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E1671127F434E800D2C926 /* BaselineWriteBenchmark.swift */; };\n\t\t03BF4B272888F90700A30500 /* BaselineBatchWriteBenchmark.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E1671227F434E800D2C926 /* BaselineBatchWriteBenchmark.swift */; };\n\t\t03BF4B282888F90A00A30500 /* BaselineReadBenchmark.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E1671327F434E800D2C926 /* BaselineReadBenchmark.swift */; };\n\t\t03BF4B292888F90E00A30500 /* BaseBenchmark.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E1671527F434E800D2C926 /* BaseBenchmark.swift */; };\n\t\t03BF4B2A2888F91100A30500 /* BenchmarkObject.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E1671627F434E800D2C926 /* BenchmarkObject.swift */; };\n\t\t03BF4B2B2888F91400A30500 /* Config.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E1671727F434E800D2C926 /* Config.swift */; };\n\t\t03BF4B2C2888F91800A30500 /* RandomData.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E1671827F434E800D2C926 /* RandomData.swift */; };\n\t\t03BF4B2D2888F91B00A30500 /* BaseMultithreadBenchmark.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E1671A27F434E800D2C926 /* BaseMultithreadBenchmark.swift */; };\n\t\t03BF4B2E2888F91F00A30500 /* MultithreadReadWriteBenchmark.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E1671B27F434E800D2C926 /* MultithreadReadWriteBenchmark.swift */; };\n\t\t03BF4B2F2888F92200A30500 /* MultithreadReadReadBenchmark.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E1671C27F434E800D2C926 /* MultithreadReadReadBenchmark.swift */; };\n\t\t03BF4B302888F92500A30500 /* MultithreadWriteWriteBenchmark.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E1671D27F434E800D2C926 /* MultithreadWriteWriteBenchmark.swift */; };\n\t\t03BF4B312888F95300A30500 /* Assert.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E1676127F434E800D2C926 /* Assert.swift */; };\n\t\t03BF4B322888F95600A30500 /* BaseTestCase.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E1676227F434E800D2C926 /* BaseTestCase.swift */; };\n\t\t03BF4B332888F95800A30500 /* Convenience.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E1676327F434E800D2C926 /* Convenience.swift */; };\n\t\t03BF4B342888F95C00A30500 /* TestObject.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E1675227F434E800D2C926 /* TestObject.swift */; };\n\t\t03BF4B352888F97F00A30500 /* ObjectsBasedBenchmark.mm in Sources */ = {isa = PBXBuildFile; fileRef = 234F057F227AA4CC00DD65A2 /* ObjectsBasedBenchmark.mm */; };\n\t\t03BF4B362888F98300A30500 /* BaselineBenchmark.mm in Sources */ = {isa = PBXBuildFile; fileRef = 234F057A227AA4CB00DD65A2 /* BaselineBenchmark.mm */; };\n\t\t03BF4B372888F98600A30500 /* CipherBenchmark.mm in Sources */ = {isa = PBXBuildFile; fileRef = 234F0580227AA4CC00DD65A2 /* CipherBenchmark.mm */; };\n\t\t03BF4B382888F98900A30500 /* RetrieveBenchmark.mm in Sources */ = {isa = PBXBuildFile; fileRef = 39327ABF22CF265600AABD4B /* RetrieveBenchmark.mm */; };\n\t\t03BF4B392888F98D00A30500 /* TableBenchmark.mm in Sources */ = {isa = PBXBuildFile; fileRef = 39327AAA22CEFD0F00AABD4B /* TableBenchmark.mm */; };\n\t\t03BF4B3A2888F99200A30500 /* MigrationBenchmark.mm in Sources */ = {isa = PBXBuildFile; fileRef = 39327BB022CF2C5400AABD4B /* MigrationBenchmark.mm */; };\n\t\t03BF4B3B2888F99500A30500 /* TableMigrationBenchmark.mm in Sources */ = {isa = PBXBuildFile; fileRef = 39327BB122CF2C5400AABD4B /* TableMigrationBenchmark.mm */; };\n\t\t03BF4B3C2888F99800A30500 /* DatabaseMigrationBenchmark.mm in Sources */ = {isa = PBXBuildFile; fileRef = 39327BB222CF2C5400AABD4B /* DatabaseMigrationBenchmark.mm */; };\n\t\t03BF4B3D2888FA3000A30500 /* Benchmark.mm in Sources */ = {isa = PBXBuildFile; fileRef = 39327AD522CF271D00AABD4B /* Benchmark.mm */; };\n\t\t03BF4B3E2888FA3800A30500 /* DatabaseTestCase.mm in Sources */ = {isa = PBXBuildFile; fileRef = 39327AE322CF271E00AABD4B /* DatabaseTestCase.mm */; };\n\t\t03BF4B3F2888FA3C00A30500 /* Benchmark.mm in Sources */ = {isa = PBXBuildFile; fileRef = 39327AD522CF271D00AABD4B /* Benchmark.mm */; };\n\t\t03BF4B402888FA4000A30500 /* CRUDTestCase.mm in Sources */ = {isa = PBXBuildFile; fileRef = 39327AE422CF271E00AABD4B /* CRUDTestCase.mm */; };\n\t\t03BF4B412888FA4300A30500 /* BaseTestCase.mm in Sources */ = {isa = PBXBuildFile; fileRef = 39327AE222CF271E00AABD4B /* BaseTestCase.mm */; };\n\t\t03BF4B422888FA4500A30500 /* TableTestCase.mm in Sources */ = {isa = PBXBuildFile; fileRef = 39327AE522CF271E00AABD4B /* TableTestCase.mm */; };\n\t\t03BF4B432888FA5C00A30500 /* PrototypeFactory.mm in Sources */ = {isa = PBXBuildFile; fileRef = 39327B9922CF276600AABD4B /* PrototypeFactory.mm */; };\n\t\t03BF4B442888FA5E00A30500 /* ObjectsBasedFactory.mm in Sources */ = {isa = PBXBuildFile; fileRef = 39327B9722CF276600AABD4B /* ObjectsBasedFactory.mm */; };\n\t\t03BF4B452888FA6100A30500 /* SizeBasedFactory.mm in Sources */ = {isa = PBXBuildFile; fileRef = 39327B9B22CF276600AABD4B /* SizeBasedFactory.mm */; };\n\t\t03BF4B462888FA6400A30500 /* TablesBasedFactory.mm in Sources */ = {isa = PBXBuildFile; fileRef = 39327B9E22CF276600AABD4B /* TablesBasedFactory.mm */; };\n\t\t03BF4B472888FA6700A30500 /* AllTypesObject.mm in Sources */ = {isa = PBXBuildFile; fileRef = 39327B8D22CF275F00AABD4B /* AllTypesObject.mm */; };\n\t\t03BF4B482888FA6B00A30500 /* TestCaseObject.mm in Sources */ = {isa = PBXBuildFile; fileRef = 39327B8922CF275F00AABD4B /* TestCaseObject.mm */; };\n\t\t03BF4B492888FA7000A30500 /* Random.mm in Sources */ = {isa = PBXBuildFile; fileRef = 39327B7A22CF275800AABD4B /* Random.mm */; };\n\t\t03BF4B4A2888FA7300A30500 /* Random+TestCaseObject.mm in Sources */ = {isa = PBXBuildFile; fileRef = 39327B7722CF275800AABD4B /* Random+TestCaseObject.mm */; };\n\t\t03BF4B4B2888FA7500A30500 /* Random+WCDB.mm in Sources */ = {isa = PBXBuildFile; fileRef = 39327B7922CF275800AABD4B /* Random+WCDB.mm */; };\n\t\t03BF4B4C2888FA7A00A30500 /* Dispatch.mm in Sources */ = {isa = PBXBuildFile; fileRef = 39327B4F22CF275000AABD4B /* Dispatch.mm */; };\n\t\t03BF4B4D2888FA7C00A30500 /* NSObject+TestCase.mm in Sources */ = {isa = PBXBuildFile; fileRef = 39327B4B22CF275000AABD4B /* NSObject+TestCase.mm */; };\n\t\t03BF4B4E2888FA7F00A30500 /* Signpost.mm in Sources */ = {isa = PBXBuildFile; fileRef = 39327B4E22CF275000AABD4B /* Signpost.mm */; };\n\t\t03BF4B4F2888FA8100A30500 /* TestCaseCounter.mm in Sources */ = {isa = PBXBuildFile; fileRef = 39327B5322CF275100AABD4B /* TestCaseCounter.mm */; };\n\t\t03BF4B502888FA8300A30500 /* TestCaseLog.mm in Sources */ = {isa = PBXBuildFile; fileRef = 39327B5422CF275100AABD4B /* TestCaseLog.mm */; };\n\t\t03BF4B512888FA8600A30500 /* TestCaseResult.mm in Sources */ = {isa = PBXBuildFile; fileRef = 39327B5222CF275100AABD4B /* TestCaseResult.mm */; };\n\t\t03BF4B522888FA8900A30500 /* WCTDatabase+TestCase.mm in Sources */ = {isa = PBXBuildFile; fileRef = 39327B5522CF275100AABD4B /* WCTDatabase+TestCase.mm */; };\n\t\t03BF4B532888FAA600A30500 /* DatabaseTestCase.mm in Sources */ = {isa = PBXBuildFile; fileRef = 39327AE322CF271E00AABD4B /* DatabaseTestCase.mm */; };\n\t\t03BFC5392852E9CB00673AE4 /* WindowDefTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03BFC5382852E9CB00673AE4 /* WindowDefTests.swift */; };\n\t\t03BFC5D72853538400673AE4 /* IndexedColumnBridge.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 03BFC5D52853538400673AE4 /* IndexedColumnBridge.cpp */; };\n\t\t03BFC5D82853538400673AE4 /* IndexedColumnBridge.h in Headers */ = {isa = PBXBuildFile; fileRef = 03BFC5D62853538400673AE4 /* IndexedColumnBridge.h */; settings = {ATTRIBUTES = (Private, ); }; };\n\t\t03C2EAED27F8382200B41169 /* ErrorBridge.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03C2EAEC27F8382200B41169 /* ErrorBridge.swift */; };\n\t\t03D077EE28C1F072009A3B18 /* TableOperation.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 03D077EC28C1F072009A3B18 /* TableOperation.cpp */; };\n\t\t03D077EF28C1F072009A3B18 /* TableOperation.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 03D077EC28C1F072009A3B18 /* TableOperation.cpp */; };\n\t\t03D077F028C1F072009A3B18 /* TableOperation.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 03D077ED28C1F072009A3B18 /* TableOperation.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t03D077F128C1F072009A3B18 /* TableOperation.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 03D077ED28C1F072009A3B18 /* TableOperation.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t03D077F328C1F611009A3B18 /* TableORMOperation.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 03D077F228C1F611009A3B18 /* TableORMOperation.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t03D077F428C1F611009A3B18 /* TableORMOperation.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 03D077F228C1F611009A3B18 /* TableORMOperation.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t03D077F628C1F951009A3B18 /* HandleORMOperation.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 03D077F528C1F951009A3B18 /* HandleORMOperation.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t03D077F728C1F951009A3B18 /* HandleORMOperation.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 03D077F528C1F951009A3B18 /* HandleORMOperation.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t03D077F928C1FB48009A3B18 /* HandleORMOperation.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 03D077F828C1FB48009A3B18 /* HandleORMOperation.cpp */; };\n\t\t03D077FA28C1FB48009A3B18 /* HandleORMOperation.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 03D077F828C1FB48009A3B18 /* HandleORMOperation.cpp */; };\n\t\t03D077FC28C20FEE009A3B18 /* Delete.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 03D077FB28C20FEE009A3B18 /* Delete.cpp */; };\n\t\t03D077FD28C20FEE009A3B18 /* Delete.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 03D077FB28C20FEE009A3B18 /* Delete.cpp */; };\n\t\t03D3A2A728A65D2F0064D4D4 /* ValueTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 03D3A2A628A65D2F0064D4D4 /* ValueTests.mm */; };\n\t\t03D3A2A828A65F3E0064D4D4 /* Lock.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E165EE27F42D6500D2C926 /* Lock.swift */; };\n\t\t03D3A2A928A6643E0064D4D4 /* PreparedStatement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0373310A289A94E00030C113 /* PreparedStatement.cpp */; };\n\t\t03DCB5E6286C2E5300CBC75D /* StatementAnalyzeBridge.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 03DCB5E4286C2E5300CBC75D /* StatementAnalyzeBridge.cpp */; };\n\t\t03DCB5E7286C2E5300CBC75D /* StatementAnalyzeBridge.h in Headers */ = {isa = PBXBuildFile; fileRef = 03DCB5E5286C2E5300CBC75D /* StatementAnalyzeBridge.h */; settings = {ATTRIBUTES = (Private, ); }; };\n\t\t03DCB5E9286C345C00CBC75D /* StatementAnalyze.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03DCB5E8286C345C00CBC75D /* StatementAnalyze.swift */; };\n\t\t03DCB5EB286C35A600CBC75D /* StatementAnalyzeTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03DCB5EA286C35A600CBC75D /* StatementAnalyzeTests.swift */; };\n\t\t03DCB5EE286C3D8E00CBC75D /* StatementAttachBridge.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 03DCB5EC286C3D8E00CBC75D /* StatementAttachBridge.cpp */; };\n\t\t03DCB5EF286C3D8E00CBC75D /* StatementAttachBridge.h in Headers */ = {isa = PBXBuildFile; fileRef = 03DCB5ED286C3D8E00CBC75D /* StatementAttachBridge.h */; settings = {ATTRIBUTES = (Private, ); }; };\n\t\t03DCB5F2286C480900CBC75D /* StatementCreateIndexBridge.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 03DCB5F0286C480900CBC75D /* StatementCreateIndexBridge.cpp */; };\n\t\t03DCB5F3286C480900CBC75D /* StatementCreateIndexBridge.h in Headers */ = {isa = PBXBuildFile; fileRef = 03DCB5F1286C480900CBC75D /* StatementCreateIndexBridge.h */; settings = {ATTRIBUTES = (Private, ); }; };\n\t\t03E165FB27F42D6500D2C926 /* Expression.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E1659127F42D6500D2C926 /* Expression.swift */; };\n\t\t03E165FC27F42D6500D2C926 /* StatementExplain.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E1659227F42D6500D2C926 /* StatementExplain.swift */; };\n\t\t03E165FD27F42D6500D2C926 /* StatementInsert.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E1659327F42D6500D2C926 /* StatementInsert.swift */; };\n\t\t03E165FE27F42D6500D2C926 /* StatementDetach.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E1659427F42D6500D2C926 /* StatementDetach.swift */; };\n\t\t03E165FF27F42D6500D2C926 /* ResultColumn.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E1659527F42D6500D2C926 /* ResultColumn.swift */; };\n\t\t03E1660027F42D6500D2C926 /* StatementDropIndex.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E1659627F42D6500D2C926 /* StatementDropIndex.swift */; };\n\t\t03E1660127F42D6500D2C926 /* Pragma.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E1659727F42D6500D2C926 /* Pragma.swift */; };\n\t\t03E1660227F42D6500D2C926 /* Operable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E1659827F42D6500D2C926 /* Operable.swift */; };\n\t\t03E1660327F42D6500D2C926 /* StatementSelect.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E1659927F42D6500D2C926 /* StatementSelect.swift */; };\n\t\t03E1660627F42D6500D2C926 /* StatementCreateVirtualTable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E1659C27F42D6500D2C926 /* StatementCreateVirtualTable.swift */; };\n\t\t03E1660727F42D6500D2C926 /* ForeignKey.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E1659D27F42D6500D2C926 /* ForeignKey.swift */; };\n\t\t03E1660827F42D6500D2C926 /* OrderingTerm.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E1659E27F42D6500D2C926 /* OrderingTerm.swift */; };\n\t\t03E1660A27F42D6500D2C926 /* TableConstraint.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E165A027F42D6500D2C926 /* TableConstraint.swift */; };\n\t\t03E1660B27F42D6500D2C926 /* Convertible.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E165A127F42D6500D2C926 /* Convertible.swift */; };\n\t\t03E1660C27F42D6500D2C926 /* IndexedColumn.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E165A227F42D6500D2C926 /* IndexedColumn.swift */; };\n\t\t03E1660D27F42D6500D2C926 /* StatementDropTable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E165A327F42D6500D2C926 /* StatementDropTable.swift */; };\n\t\t03E1660E27F42D6500D2C926 /* PreparedStatement.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E165A427F42D6500D2C926 /* PreparedStatement.swift */; };\n\t\t03E1660F27F42D6500D2C926 /* StatementSavepoint.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E165A527F42D6500D2C926 /* StatementSavepoint.swift */; };\n\t\t03E1661027F42D6500D2C926 /* Column.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E165A627F42D6500D2C926 /* Column.swift */; };\n\t\t03E1661127F42D6500D2C926 /* StatementUpdate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E165A727F42D6500D2C926 /* StatementUpdate.swift */; };\n\t\t03E1661227F42D6500D2C926 /* TableOrSubquery.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E165A827F42D6500D2C926 /* TableOrSubquery.swift */; };\n\t\t03E1661327F42D6500D2C926 /* LiteralValue.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E165A927F42D6500D2C926 /* LiteralValue.swift */; };\n\t\t03E1661427F42D6500D2C926 /* Value.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E165AA27F42D6500D2C926 /* Value.swift */; };\n\t\t03E1661527F42D6500D2C926 /* StatementCreateTable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E165AB27F42D6500D2C926 /* StatementCreateTable.swift */; };\n\t\t03E1661627F42D6500D2C926 /* Join.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E165AC27F42D6500D2C926 /* Join.swift */; };\n\t\t03E1661727F42D6500D2C926 /* StatementDelete.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E165AD27F42D6500D2C926 /* StatementDelete.swift */; };\n\t\t03E1661827F42D6500D2C926 /* StatementAttach.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E165AE27F42D6500D2C926 /* StatementAttach.swift */; };\n\t\t03E1661927F42D6500D2C926 /* StatementAlterTable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E165AF27F42D6500D2C926 /* StatementAlterTable.swift */; };\n\t\t03E1661A27F42D6500D2C926 /* StatementRollback.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E165B027F42D6500D2C926 /* StatementRollback.swift */; };\n\t\t03E1661C27F42D6500D2C926 /* StatementVacuum.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E165B227F42D6500D2C926 /* StatementVacuum.swift */; };\n\t\t03E1661D27F42D6500D2C926 /* StatementRelease.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E165B327F42D6500D2C926 /* StatementRelease.swift */; };\n\t\t03E1661E27F42D6500D2C926 /* ColumnDef.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E165B427F42D6500D2C926 /* ColumnDef.swift */; };\n\t\t03E1661F27F42D6500D2C926 /* StatementReindex.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E165B527F42D6500D2C926 /* StatementReindex.swift */; };\n\t\t03E1662027F42D6500D2C926 /* StatementCreateIndex.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E165B627F42D6500D2C926 /* StatementCreateIndex.swift */; };\n\t\t03E1662127F42D6500D2C926 /* Statement.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E165B727F42D6500D2C926 /* Statement.swift */; };\n\t\t03E1662427F42D6500D2C926 /* StatementPragma.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E165BA27F42D6500D2C926 /* StatementPragma.swift */; };\n\t\t03E1662527F42D6500D2C926 /* Handle.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E165BB27F42D6500D2C926 /* Handle.swift */; };\n\t\t03E1662727F42D6500D2C926 /* CodableType.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E165BE27F42D6500D2C926 /* CodableType.swift */; };\n\t\t03E1662827F42D6500D2C926 /* Master.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E165BF27F42D6500D2C926 /* Master.swift */; };\n\t\t03E1662927F42D6600D2C926 /* Declare.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E165C227F42D6500D2C926 /* Declare.swift */; };\n\t\t03E1662A27F42D6600D2C926 /* RowSelect.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E165C327F42D6500D2C926 /* RowSelect.swift */; };\n\t\t03E1662B27F42D6600D2C926 /* Update.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E165C427F42D6500D2C926 /* Update.swift */; };\n\t\t03E1662C27F42D6600D2C926 /* Delete.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E165C527F42D6500D2C926 /* Delete.swift */; };\n\t\t03E1662D27F42D6600D2C926 /* ChainCall.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E165C627F42D6500D2C926 /* ChainCall.swift */; };\n\t\t03E1662E27F42D6600D2C926 /* Table.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E165C727F42D6500D2C926 /* Table.swift */; };\n\t\t03E1662F27F42D6600D2C926 /* TableCRUDInterface.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E165C827F42D6500D2C926 /* TableCRUDInterface.swift */; };\n\t\t03E1663027F42D6600D2C926 /* Select.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E165C927F42D6500D2C926 /* Select.swift */; };\n\t\t03E1663227F42D6600D2C926 /* Selectable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E165CB27F42D6500D2C926 /* Selectable.swift */; };\n\t\t03E1663327F42D6600D2C926 /* MultiSelect.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E165CC27F42D6500D2C926 /* MultiSelect.swift */; };\n\t\t03E1663427F42D6600D2C926 /* Insert.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E165CD27F42D6500D2C926 /* Insert.swift */; };\n\t\t03E1663527F42D6600D2C926 /* ColumnCodable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E165CF27F42D6500D2C926 /* ColumnCodable.swift */; };\n\t\t03E1663627F42D6600D2C926 /* ColumnTypeDecoder.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E165D027F42D6500D2C926 /* ColumnTypeDecoder.swift */; };\n\t\t03E1663727F42D6600D2C926 /* TableCodable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E165D127F42D6500D2C926 /* TableCodable.swift */; };\n\t\t03E1663827F42D6600D2C926 /* CodingTableKey.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E165D227F42D6500D2C926 /* CodingTableKey.swift */; };\n\t\t03E1663927F42D6600D2C926 /* TableEncoder.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E165D327F42D6500D2C926 /* TableEncoder.swift */; };\n\t\t03E1663A27F42D6600D2C926 /* TableDecoder.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E165D427F42D6500D2C926 /* TableDecoder.swift */; };\n\t\t03E1663C27F42D6600D2C926 /* Property.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E165D727F42D6500D2C926 /* Property.swift */; };\n\t\t03E1663D27F42D6600D2C926 /* Redirectable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E165D827F42D6500D2C926 /* Redirectable.swift */; };\n\t\t03E1664127F42D6600D2C926 /* TableBinding.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E165DC27F42D6500D2C926 /* TableBinding.swift */; };\n\t\t03E1664427F42D6600D2C926 /* BaseType.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E165E127F42D6500D2C926 /* BaseType.swift */; };\n\t\t03E1664627F42D6600D2C926 /* Database.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E165E327F42D6500D2C926 /* Database.swift */; };\n\t\t03E1664A27F42D6600D2C926 /* Recyclable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E165E827F42D6500D2C926 /* Recyclable.swift */; };\n\t\t03E1664C27F42D6600D2C926 /* WCDBError.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E165EA27F42D6500D2C926 /* WCDBError.swift */; };\n\t\t03E1665827F42D6600D2C926 /* Optional.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E165F627F42D6500D2C926 /* Optional.swift */; };\n\t\t03E1665927F42D6600D2C926 /* Convenience.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E165F727F42D6500D2C926 /* Convenience.swift */; };\n\t\t03E1677327F434E900D2C926 /* TracerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E1672027F434E800D2C926 /* TracerTests.swift */; };\n\t\t03E1677427F434E900D2C926 /* RepairTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E1672127F434E800D2C926 /* RepairTests.swift */; };\n\t\t03E1677527F434E900D2C926 /* FileTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E1672227F434E800D2C926 /* FileTests.swift */; };\n\t\t03E1677627F434E900D2C926 /* StatementDetachTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E1672427F434E800D2C926 /* StatementDetachTests.swift */; };\n\t\t03E1677727F434E900D2C926 /* StatementCreateTableTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E1672527F434E800D2C926 /* StatementCreateTableTests.swift */; };\n\t\t03E1677827F434E900D2C926 /* StatementSelectTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E1672627F434E800D2C926 /* StatementSelectTests.swift */; };\n\t\t03E1677927F434E900D2C926 /* StatementCreateVirtualTableTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E1672727F434E800D2C926 /* StatementCreateVirtualTableTests.swift */; };\n\t\t03E1677A27F434E900D2C926 /* StatementUpdateTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E1672827F434E800D2C926 /* StatementUpdateTests.swift */; };\n\t\t03E1677B27F434E900D2C926 /* StatementDeleteTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E1672927F434E800D2C926 /* StatementDeleteTests.swift */; };\n\t\t03E1677C27F434E900D2C926 /* StatementExplainTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E1672A27F434E800D2C926 /* StatementExplainTests.swift */; };\n\t\t03E1677D27F434E900D2C926 /* StatementSavepointTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E1672B27F434E800D2C926 /* StatementSavepointTests.swift */; };\n\t\t03E1677E27F434E900D2C926 /* StatementDropIndexTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E1672C27F434E800D2C926 /* StatementDropIndexTests.swift */; };\n\t\t03E1677F27F434E900D2C926 /* TableConstraintTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E1672D27F434E800D2C926 /* TableConstraintTests.swift */; };\n\t\t03E1678027F434E900D2C926 /* StatementAlterTableTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E1672E27F434E800D2C926 /* StatementAlterTableTests.swift */; };\n\t\t03E1678127F434E900D2C926 /* ColumnDefTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E1672F27F434E800D2C926 /* ColumnDefTests.swift */; };\n\t\t03E1678227F434E900D2C926 /* LiteralValueTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E1673027F434E800D2C926 /* LiteralValueTests.swift */; };\n\t\t03E1678327F434E900D2C926 /* StatementAttachTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E1673127F434E800D2C926 /* StatementAttachTests.swift */; };\n\t\t03E1678527F434E900D2C926 /* TableOrSubqueryTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E1673327F434E800D2C926 /* TableOrSubqueryTests.swift */; };\n\t\t03E1678627F434E900D2C926 /* StatementReindexTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E1673427F434E800D2C926 /* StatementReindexTests.swift */; };\n\t\t03E1678727F434E900D2C926 /* OrderingTermTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E1673527F434E800D2C926 /* OrderingTermTests.swift */; };\n\t\t03E1678827F434E900D2C926 /* StatementPragmaTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E1673627F434E800D2C926 /* StatementPragmaTests.swift */; };\n\t\t03E1678927F434E900D2C926 /* ForeignKeyTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E1673727F434E800D2C926 /* ForeignKeyTests.swift */; };\n\t\t03E1678B27F434E900D2C926 /* StatementRollbackTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E1673927F434E800D2C926 /* StatementRollbackTests.swift */; };\n\t\t03E1678C27F434E900D2C926 /* ColumnTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E1673A27F434E800D2C926 /* ColumnTests.swift */; };\n\t\t03E1678D27F434E900D2C926 /* StatementReleaseTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E1673B27F434E800D2C926 /* StatementReleaseTests.swift */; };\n\t\t03E1678E27F434E900D2C926 /* StatementCreateIndexTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E1673C27F434E800D2C926 /* StatementCreateIndexTests.swift */; };\n\t\t03E1678F27F434E900D2C926 /* ExpressionTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E1673D27F434E800D2C926 /* ExpressionTests.swift */; };\n\t\t03E1679127F434E900D2C926 /* JoinTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E1673F27F434E800D2C926 /* JoinTests.swift */; };\n\t\t03E1679227F434E900D2C926 /* StatementDropTableTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E1674027F434E800D2C926 /* StatementDropTableTests.swift */; };\n\t\t03E1679327F434E900D2C926 /* StatementVacuumTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E1674127F434E800D2C926 /* StatementVacuumTests.swift */; };\n\t\t03E1679427F434E900D2C926 /* IndexedColumnTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E1674227F434E800D2C926 /* IndexedColumnTests.swift */; };\n\t\t03E1679527F434E900D2C926 /* StatementInsertTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E1674327F434E800D2C926 /* StatementInsertTests.swift */; };\n\t\t03E1679727F434E900D2C926 /* ResultColumnTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E1674527F434E800D2C926 /* ResultColumnTests.swift */; };\n\t\t03E1679827F434E900D2C926 /* ColumnTypeTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E1674627F434E800D2C926 /* ColumnTypeTests.swift */; };\n\t\t03E1679927F434E900D2C926 /* AdvanceCRUDTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E1674827F434E800D2C926 /* AdvanceCRUDTests.swift */; };\n\t\t03E1679A27F434E900D2C926 /* TableTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E1674927F434E800D2C926 /* TableTests.swift */; };\n\t\t03E1679B27F434E900D2C926 /* InsertTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E1674A27F434E800D2C926 /* InsertTests.swift */; };\n\t\t03E1679C27F434E900D2C926 /* AdvanceTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E1674B27F434E800D2C926 /* AdvanceTests.swift */; };\n\t\t03E1679D27F434E900D2C926 /* MultithreadTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E1674C27F434E800D2C926 /* MultithreadTests.swift */; };\n\t\t03E1679E27F434E900D2C926 /* RowSelectTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E1674D27F434E800D2C926 /* RowSelectTests.swift */; };\n\t\t03E1679F27F434E900D2C926 /* DatabaseTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E1674E27F434E800D2C926 /* DatabaseTests.swift */; };\n\t\t03E167A027F434E900D2C926 /* InsertInterfaceTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E1674F27F434E800D2C926 /* InsertInterfaceTests.swift */; };\n\t\t03E167A127F434E900D2C926 /* UpdateInterfaceTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E1675027F434E800D2C926 /* UpdateInterfaceTests.swift */; };\n\t\t03E167A227F434E900D2C926 /* TypedTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E1675127F434E800D2C926 /* TypedTests.swift */; };\n\t\t03E167A327F434E900D2C926 /* TestObject.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E1675227F434E800D2C926 /* TestObject.swift */; };\n\t\t03E167A427F434E900D2C926 /* CRUDTestCase.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E1675327F434E800D2C926 /* CRUDTestCase.swift */; };\n\t\t03E167A527F434E900D2C926 /* MultiSelectTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E1675427F434E800D2C926 /* MultiSelectTests.swift */; };\n\t\t03E167A627F434E900D2C926 /* SelectInterfaceTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E1675527F434E800D2C926 /* SelectInterfaceTests.swift */; };\n\t\t03E167A727F434E900D2C926 /* DeleteTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E1675627F434E800D2C926 /* DeleteTests.swift */; };\n\t\t03E167A827F434E900D2C926 /* DeleteInterfaceTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E1675727F434E800D2C926 /* DeleteInterfaceTests.swift */; };\n\t\t03E167A927F434E900D2C926 /* UpdateTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E1675827F434E800D2C926 /* UpdateTests.swift */; };\n\t\t03E167AB27F434E900D2C926 /* SelectTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E1675A27F434E800D2C926 /* SelectTests.swift */; };\n\t\t03E167AC27F434E900D2C926 /* TableConstraintBindingTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E1675C27F434E800D2C926 /* TableConstraintBindingTests.swift */; };\n\t\t03E167AD27F434E900D2C926 /* VirtualTableBindingTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E1675D27F434E800D2C926 /* VirtualTableBindingTests.swift */; };\n\t\t03E167AE27F434E900D2C926 /* ColumnConstraintBindingTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E1675E27F434E800D2C926 /* ColumnConstraintBindingTests.swift */; };\n\t\t03E167AF27F434E900D2C926 /* IndexBindingTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E1675F27F434E800D2C926 /* IndexBindingTests.swift */; };\n\t\t03E167B027F434E900D2C926 /* Assert.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E1676127F434E800D2C926 /* Assert.swift */; };\n\t\t03E167B127F434E900D2C926 /* BaseTestCase.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E1676227F434E800D2C926 /* BaseTestCase.swift */; };\n\t\t03E167B227F434E900D2C926 /* Convenience.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E1676327F434E800D2C926 /* Convenience.swift */; };\n\t\t03E167B827F46C7100D2C926 /* ObjectBridge.h in Headers */ = {isa = PBXBuildFile; fileRef = 03E167B727F46C7100D2C926 /* ObjectBridge.h */; settings = {ATTRIBUTES = (Private, ); }; };\n\t\t03E167BA27F46E2E00D2C926 /* ObjectBridge.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 03E167B927F46E2E00D2C926 /* ObjectBridge.hpp */; };\n\t\t03E3180D28A21AF800540CB1 /* CppInterface.h in Headers */ = {isa = PBXBuildFile; fileRef = 03E3180C28A21AF800540CB1 /* CppInterface.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t03E3180E28A21AF800540CB1 /* CppInterface.h in Headers */ = {isa = PBXBuildFile; fileRef = 03E3180C28A21AF800540CB1 /* CppInterface.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t03E3180F28A21B0000540CB1 /* Handle.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 0373310F289A94F10030C113 /* Handle.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t03E3181028A21B0500540CB1 /* PreparedStatement.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 0373310B289A94E00030C113 /* PreparedStatement.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t03E3181128A21B0A00540CB1 /* Database.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 037330C0289A909A0030C113 /* Database.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t03E3181228A23CBC00540CB1 /* Handle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0373310E289A94F00030C113 /* Handle.cpp */; };\n\t\t03E5CB0128A3513C005353D9 /* WCDBCpp.h in Headers */ = {isa = PBXBuildFile; fileRef = 03E5CB0028A3513C005353D9 /* WCDBCpp.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t03E5CC5228A38F0F005353D9 /* Signpost.mm in Sources */ = {isa = PBXBuildFile; fileRef = 39327B4E22CF275000AABD4B /* Signpost.mm */; };\n\t\t03E5CC5328A38F0F005353D9 /* TestCaseCounter.mm in Sources */ = {isa = PBXBuildFile; fileRef = 39327B5322CF275100AABD4B /* TestCaseCounter.mm */; };\n\t\t03E5CC5428A38F0F005353D9 /* Random.mm in Sources */ = {isa = PBXBuildFile; fileRef = 39327B7A22CF275800AABD4B /* Random.mm */; };\n\t\t03E5CC5528A38F0F005353D9 /* Dispatch.mm in Sources */ = {isa = PBXBuildFile; fileRef = 39327B4F22CF275000AABD4B /* Dispatch.mm */; };\n\t\t03E5CC5628A38F0F005353D9 /* TestCaseLog.mm in Sources */ = {isa = PBXBuildFile; fileRef = 39327B5422CF275100AABD4B /* TestCaseLog.mm */; };\n\t\t03E5CC5728A38F0F005353D9 /* TestCaseResult.mm in Sources */ = {isa = PBXBuildFile; fileRef = 39327B5222CF275100AABD4B /* TestCaseResult.mm */; };\n\t\t03E5CC5928A38FFF005353D9 /* CPPBaseTestCase.mm in Sources */ = {isa = PBXBuildFile; fileRef = 03E5CC4E28A38DDB005353D9 /* CPPBaseTestCase.mm */; };\n\t\t03E5CC5A28A39B19005353D9 /* Database.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 037330BF289A909A0030C113 /* Database.cpp */; };\n\t\t03E5CC6028A3A189005353D9 /* CPPDatabaseTestCase.mm in Sources */ = {isa = PBXBuildFile; fileRef = 03E5CC5E28A3A185005353D9 /* CPPDatabaseTestCase.mm */; };\n\t\t03E5CC6428A3A2B4005353D9 /* Random+WCDB.mm in Sources */ = {isa = PBXBuildFile; fileRef = 39327B7922CF275800AABD4B /* Random+WCDB.mm */; };\n\t\t03E5CC6728A3B083005353D9 /* CPPFileTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 03E5CC6628A3B083005353D9 /* CPPFileTests.mm */; };\n\t\t03E5CC6928A3B603005353D9 /* NSObject+TestCase.mm in Sources */ = {isa = PBXBuildFile; fileRef = 39327B4B22CF275000AABD4B /* NSObject+TestCase.mm */; };\n\t\t03E5CC6B28A3B6A4005353D9 /* CPPConfigTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 03E5CC6A28A3B6A4005353D9 /* CPPConfigTests.mm */; };\n\t\t03E5CC6E28A3BDF3005353D9 /* Value.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 03E5CC6C28A3BDF3005353D9 /* Value.cpp */; };\n\t\t03E5CC6F28A3BDF3005353D9 /* Value.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 03E5CC6C28A3BDF3005353D9 /* Value.cpp */; };\n\t\t03E5CC7028A3BDF3005353D9 /* Value.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 03E5CC6D28A3BDF3005353D9 /* Value.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t03E5CC7128A3BDF3005353D9 /* Value.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 03E5CC6D28A3BDF3005353D9 /* Value.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t03E8228028447B940072CA57 /* ColumnDefBridge.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 03E8227E28447B940072CA57 /* ColumnDefBridge.cpp */; };\n\t\t03E8228128447B940072CA57 /* ColumnDefBridge.h in Headers */ = {isa = PBXBuildFile; fileRef = 03E8227F28447B940072CA57 /* ColumnDefBridge.h */; settings = {ATTRIBUTES = (Private, ); }; };\n\t\t03E822842844B8760072CA57 /* CommonTableExpressionBridge.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 03E822822844B8760072CA57 /* CommonTableExpressionBridge.cpp */; };\n\t\t03E822852844B8760072CA57 /* CommonTableExpressionBridge.h in Headers */ = {isa = PBXBuildFile; fileRef = 03E822832844B8760072CA57 /* CommonTableExpressionBridge.h */; settings = {ATTRIBUTES = (Private, ); }; };\n\t\t03E822882844B8CD0072CA57 /* StatementSelectBridge.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 03E822862844B8CD0072CA57 /* StatementSelectBridge.cpp */; };\n\t\t03E822892844B8CD0072CA57 /* StatementSelectBridge.h in Headers */ = {isa = PBXBuildFile; fileRef = 03E822872844B8CD0072CA57 /* StatementSelectBridge.h */; settings = {ATTRIBUTES = (Private, ); }; };\n\t\t03E8228C2844BEFF0072CA57 /* CommonTableExpression.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E8228B2844BEFF0072CA57 /* CommonTableExpression.swift */; };\n\t\t03E8228E2844C0E70072CA57 /* CommonTableExpressionTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E8228D2844C0E70072CA57 /* CommonTableExpressionTests.swift */; };\n\t\t03E822912844E1AB0072CA57 /* RaiseFunctionBridge.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 03E8228F2844E1AB0072CA57 /* RaiseFunctionBridge.cpp */; };\n\t\t03E822922844E1AB0072CA57 /* RaiseFunctionBridge.h in Headers */ = {isa = PBXBuildFile; fileRef = 03E822902844E1AB0072CA57 /* RaiseFunctionBridge.h */; settings = {ATTRIBUTES = (Private, ); }; };\n\t\t03EA88CE27D5F05D0075C7BD /* FTSError.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 03EA88CD27D5F05D0075C7BD /* FTSError.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t03EA88D027D5F0840075C7BD /* FTSError.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 03EA88CF27D5F0840075C7BD /* FTSError.cpp */; };\n\t\t03EE3A51287FCECF00C8F0B3 /* StatementCreateTrigger.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03EE3A50287FCECF00C8F0B3 /* StatementCreateTrigger.swift */; };\n\t\t03EE3DA728810C2000C8F0B3 /* StatementCreateTriggerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03EE3DA628810C2000C8F0B3 /* StatementCreateTriggerTests.swift */; };\n\t\t03EE3DAA288165A700C8F0B3 /* StatementInsertBridge.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 03EE3DA8288165A700C8F0B3 /* StatementInsertBridge.cpp */; };\n\t\t03EE3DAB288165A700C8F0B3 /* StatementInsertBridge.h in Headers */ = {isa = PBXBuildFile; fileRef = 03EE3DA9288165A700C8F0B3 /* StatementInsertBridge.h */; settings = {ATTRIBUTES = (Private, ); }; };\n\t\t03EE3DAE28816DA800C8F0B3 /* StatementUpdateBridge.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 03EE3DAC28816DA800C8F0B3 /* StatementUpdateBridge.cpp */; };\n\t\t03EE3DAF28816DA800C8F0B3 /* StatementUpdateBridge.h in Headers */ = {isa = PBXBuildFile; fileRef = 03EE3DAD28816DA800C8F0B3 /* StatementUpdateBridge.h */; settings = {ATTRIBUTES = (Private, ); }; };\n\t\t03F428EB28BF686F005CE249 /* Update.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 03F428E828BF686F005CE249 /* Update.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t03F428EC28BF686F005CE249 /* Update.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 03F428E828BF686F005CE249 /* Update.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t03F54820287D8467007BCA3E /* StatementDetachBridge.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 03F5481E287D8467007BCA3E /* StatementDetachBridge.cpp */; };\n\t\t03F54821287D8467007BCA3E /* StatementDetachBridge.h in Headers */ = {isa = PBXBuildFile; fileRef = 03F5481F287D8467007BCA3E /* StatementDetachBridge.h */; settings = {ATTRIBUTES = (Private, ); }; };\n\t\t03F54824287D87F9007BCA3E /* StatementDropIndexBridge.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 03F54822287D87F9007BCA3E /* StatementDropIndexBridge.cpp */; };\n\t\t03F54825287D87F9007BCA3E /* StatementDropIndexBridge.h in Headers */ = {isa = PBXBuildFile; fileRef = 03F54823287D87F9007BCA3E /* StatementDropIndexBridge.h */; settings = {ATTRIBUTES = (Private, ); }; };\n\t\t03F54828287D93A7007BCA3E /* StatementDropTableBridge.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 03F54826287D93A7007BCA3E /* StatementDropTableBridge.cpp */; };\n\t\t03F54829287D93A7007BCA3E /* StatementDropTableBridge.h in Headers */ = {isa = PBXBuildFile; fileRef = 03F54827287D93A7007BCA3E /* StatementDropTableBridge.h */; settings = {ATTRIBUTES = (Private, ); }; };\n\t\t0D0247702B99B04500AD84E9 /* WCTCancellationSignal.mm in Sources */ = {isa = PBXBuildFile; fileRef = 0D8084232A861E9500C81BBF /* WCTCancellationSignal.mm */; };\n\t\t0D0CD79F2A6FA1A900F89C6B /* CipherMigrationTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 0D0CD79E2A6FA1A900F89C6B /* CipherMigrationTests.mm */; };\n\t\t0D0CD7A12A6FBE0C00F89C6B /* MigrateTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 0D0CD7A02A6FBE0C00F89C6B /* MigrateTests.mm */; };\n\t\t0D0D56C1254ABEAA000F16A6 /* FTS5Object.mm in Sources */ = {isa = PBXBuildFile; fileRef = 0D0D56C0254ABEAA000F16A6 /* FTS5Object.mm */; };\n\t\t0D0D56CA254AC0F0000F16A6 /* FTS5Test.mm in Sources */ = {isa = PBXBuildFile; fileRef = 0D0D56C9254AC0F0000F16A6 /* FTS5Test.mm */; };\n\t\t0D19BA0B2B0702250028F92B /* AssembleHandleOperator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0D19BA092B0702250028F92B /* AssembleHandleOperator.cpp */; };\n\t\t0D19BA0C2B0702250028F92B /* AssembleHandleOperator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0D19BA092B0702250028F92B /* AssembleHandleOperator.cpp */; };\n\t\t0D19BA0D2B0702250028F92B /* AssembleHandleOperator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0D19BA092B0702250028F92B /* AssembleHandleOperator.cpp */; };\n\t\t0D19BA0E2B0702250028F92B /* AssembleHandleOperator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0D19BA092B0702250028F92B /* AssembleHandleOperator.cpp */; };\n\t\t0D19BA0F2B0702250028F92B /* AssembleHandleOperator.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 0D19BA0A2B0702250028F92B /* AssembleHandleOperator.hpp */; };\n\t\t0D19BA102B0702250028F92B /* AssembleHandleOperator.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 0D19BA0A2B0702250028F92B /* AssembleHandleOperator.hpp */; };\n\t\t0D19BA112B0702250028F92B /* AssembleHandleOperator.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 0D19BA0A2B0702250028F92B /* AssembleHandleOperator.hpp */; };\n\t\t0D19BA122B0702250028F92B /* AssembleHandleOperator.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 0D19BA0A2B0702250028F92B /* AssembleHandleOperator.hpp */; };\n\t\t0D19BA1F2B07481B0028F92B /* IntegerityHandleOperator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0D19BA1D2B07481B0028F92B /* IntegerityHandleOperator.cpp */; };\n\t\t0D19BA202B07481B0028F92B /* IntegerityHandleOperator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0D19BA1D2B07481B0028F92B /* IntegerityHandleOperator.cpp */; };\n\t\t0D19BA212B07481B0028F92B /* IntegerityHandleOperator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0D19BA1D2B07481B0028F92B /* IntegerityHandleOperator.cpp */; };\n\t\t0D19BA222B07481B0028F92B /* IntegerityHandleOperator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0D19BA1D2B07481B0028F92B /* IntegerityHandleOperator.cpp */; };\n\t\t0D19BA232B07481B0028F92B /* IntegerityHandleOperator.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 0D19BA1E2B07481B0028F92B /* IntegerityHandleOperator.hpp */; };\n\t\t0D19BA242B07481B0028F92B /* IntegerityHandleOperator.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 0D19BA1E2B07481B0028F92B /* IntegerityHandleOperator.hpp */; };\n\t\t0D19BA252B07481B0028F92B /* IntegerityHandleOperator.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 0D19BA1E2B07481B0028F92B /* IntegerityHandleOperator.hpp */; };\n\t\t0D19BA262B07481B0028F92B /* IntegerityHandleOperator.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 0D19BA1E2B07481B0028F92B /* IntegerityHandleOperator.hpp */; };\n\t\t0D22E7AE2B298E9A00AA44D2 /* zstd.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 75EABA0D2ADA4F2600AAD3C9 /* zstd.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };\n\t\t0D22E7B12B298EA400AA44D2 /* zstd.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 75EABA0D2ADA4F2600AAD3C9 /* zstd.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };\n\t\t0D22E7B42B298EAB00AA44D2 /* zstd.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 75EABA0D2ADA4F2600AAD3C9 /* zstd.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };\n\t\t0D22E7B72B298EB200AA44D2 /* zstd.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 75EABA0D2ADA4F2600AAD3C9 /* zstd.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };\n\t\t0D249BC12542B8E900B43BD9 /* MergeFTSIndexLogic.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 0D249BC02542B8E900B43BD9 /* MergeFTSIndexLogic.hpp */; };\n\t\t0D249BC92542B90600B43BD9 /* MergeFTSIndexLogic.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0D249BC82542B90600B43BD9 /* MergeFTSIndexLogic.cpp */; };\n\t\t0D2789D92B21995800F60E2D /* CompressionTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 0D2789D82B21995800F60E2D /* CompressionTests.mm */; };\n\t\t0D28FD312DB09E6F00D85025 /* WCDB.framework in CopyFiles */ = {isa = PBXBuildFile; fileRef = 239326611E836D7300D677CC /* WCDB.framework */; platformFilter = ios; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };\n\t\t0D32815F2B04A8E60027B973 /* DecorativeHandle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0D32815D2B04A8E60027B973 /* DecorativeHandle.cpp */; };\n\t\t0D3281602B04A8E60027B973 /* DecorativeHandle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0D32815D2B04A8E60027B973 /* DecorativeHandle.cpp */; };\n\t\t0D3281612B04A8E60027B973 /* DecorativeHandle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0D32815D2B04A8E60027B973 /* DecorativeHandle.cpp */; };\n\t\t0D3281622B04A8E60027B973 /* DecorativeHandle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0D32815D2B04A8E60027B973 /* DecorativeHandle.cpp */; };\n\t\t0D3281632B04A8E60027B973 /* DecorativeHandle.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 0D32815E2B04A8E60027B973 /* DecorativeHandle.hpp */; };\n\t\t0D3281642B04A8E60027B973 /* DecorativeHandle.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 0D32815E2B04A8E60027B973 /* DecorativeHandle.hpp */; };\n\t\t0D3281652B04A8E60027B973 /* DecorativeHandle.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 0D32815E2B04A8E60027B973 /* DecorativeHandle.hpp */; };\n\t\t0D3281662B04A8E60027B973 /* DecorativeHandle.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 0D32815E2B04A8E60027B973 /* DecorativeHandle.hpp */; };\n\t\t0D3281682B04AC7A0027B973 /* FunctionContainer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0D3281672B04AC7A0027B973 /* FunctionContainer.cpp */; };\n\t\t0D3281692B04AC7A0027B973 /* FunctionContainer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0D3281672B04AC7A0027B973 /* FunctionContainer.cpp */; };\n\t\t0D32816A2B04AC7A0027B973 /* FunctionContainer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0D3281672B04AC7A0027B973 /* FunctionContainer.cpp */; };\n\t\t0D32816B2B04AC7A0027B973 /* FunctionContainer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0D3281672B04AC7A0027B973 /* FunctionContainer.cpp */; };\n\t\t0D3345912BB3FE2B004C84C5 /* WCTBridgeProperty+CPP.h in Headers */ = {isa = PBXBuildFile; fileRef = 036E50BA28115BA0007365CD /* WCTBridgeProperty+CPP.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t0D3345A52BB40C7F004C84C5 /* WCTBridgeProperty.h in Headers */ = {isa = PBXBuildFile; fileRef = 036E50B628115AB8007365CD /* WCTBridgeProperty.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t0D36C0F72AF1E00C000BC0DD /* STDOptionalAccessor.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 0D36C0F62AF1E00C000BC0DD /* STDOptionalAccessor.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t0D36C0F82AF1E00C000BC0DD /* STDOptionalAccessor.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 0D36C0F62AF1E00C000BC0DD /* STDOptionalAccessor.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t0D36C0FB2AF1E3B1000BC0DD /* CPPSTDOptionalAllTypesObject.mm in Sources */ = {isa = PBXBuildFile; fileRef = 0D36C0FA2AF1E3B1000BC0DD /* CPPSTDOptionalAllTypesObject.mm */; };\n\t\t0D36C0FD2AF1F0B6000BC0DD /* WCDBOptionalAccessor.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 0D36C0FC2AF1F0B6000BC0DD /* WCDBOptionalAccessor.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t0D36C0FE2AF1F0B6000BC0DD /* WCDBOptionalAccessor.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 0D36C0FC2AF1F0B6000BC0DD /* WCDBOptionalAccessor.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t0D36C1012AF1F492000BC0DD /* CPPWCDBOptionalAllTypesObject.mm in Sources */ = {isa = PBXBuildFile; fileRef = 0D36C1002AF1F492000BC0DD /* CPPWCDBOptionalAllTypesObject.mm */; };\n\t\t0D3AE53825416D99007B9D0E /* AutoMergeFTSIndexConfig.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 0D3AE53725416D99007B9D0E /* AutoMergeFTSIndexConfig.hpp */; };\n\t\t0D3AE54025416DB4007B9D0E /* AutoMergeFTSIndexConfig.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0D3AE53F25416DB4007B9D0E /* AutoMergeFTSIndexConfig.cpp */; };\n\t\t0D3FFA462A2F2911002DF7CD /* SysTypes.h in Headers */ = {isa = PBXBuildFile; fileRef = 0D3FFA452A2F2911002DF7CD /* SysTypes.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t0D3FFA472A2F2911002DF7CD /* SysTypes.h in Headers */ = {isa = PBXBuildFile; fileRef = 0D3FFA452A2F2911002DF7CD /* SysTypes.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t0D3FFA482A2F2911002DF7CD /* SysTypes.h in Headers */ = {isa = PBXBuildFile; fileRef = 0D3FFA452A2F2911002DF7CD /* SysTypes.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t0D3FFA492A2F2911002DF7CD /* SysTypes.h in Headers */ = {isa = PBXBuildFile; fileRef = 0D3FFA452A2F2911002DF7CD /* SysTypes.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t0D47A9772A6E333D008E9E2C /* MigrationTestObjectBase.mm in Sources */ = {isa = PBXBuildFile; fileRef = 0D47A9762A6E333D008E9E2C /* MigrationTestObjectBase.mm */; };\n\t\t0D4F0F952AC5728A0067027E /* WCTPerformanceInfo.h in Headers */ = {isa = PBXBuildFile; fileRef = 0D4F0F942AC5728A0067027E /* WCTPerformanceInfo.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t0D4F0F962AC5728A0067027E /* WCTPerformanceInfo.h in Headers */ = {isa = PBXBuildFile; fileRef = 0D4F0F942AC5728A0067027E /* WCTPerformanceInfo.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t0D4F0F982AC572B20067027E /* WCTPerformanceInfo.mm in Sources */ = {isa = PBXBuildFile; fileRef = 0D4F0F972AC572B20067027E /* WCTPerformanceInfo.mm */; };\n\t\t0D4F0F992AC572B20067027E /* WCTPerformanceInfo.mm in Sources */ = {isa = PBXBuildFile; fileRef = 0D4F0F972AC572B20067027E /* WCTPerformanceInfo.mm */; };\n\t\t0D4FE5EF29482F4D0061C3CA /* Builtin.h in Headers */ = {isa = PBXBuildFile; fileRef = 0D4FE5EE29482F4D0061C3CA /* Builtin.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t0D5363EA290A65390026A4DC /* Master.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0D5363E8290A65390026A4DC /* Master.cpp */; };\n\t\t0D5363EB290A65390026A4DC /* Master.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0D5363E8290A65390026A4DC /* Master.cpp */; };\n\t\t0D5363EC290A65390026A4DC /* Master.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 0D5363E9290A65390026A4DC /* Master.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t0D5363ED290A65390026A4DC /* Master.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 0D5363E9290A65390026A4DC /* Master.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t0D5363F0290A75F20026A4DC /* Sequence.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0D5363EE290A75F20026A4DC /* Sequence.cpp */; };\n\t\t0D5363F1290A75F20026A4DC /* Sequence.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0D5363EE290A75F20026A4DC /* Sequence.cpp */; };\n\t\t0D5363F2290A75F20026A4DC /* Sequence.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 0D5363EF290A75F20026A4DC /* Sequence.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t0D5363F3290A75F20026A4DC /* Sequence.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 0D5363EF290A75F20026A4DC /* Sequence.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t0D5403032B160693007DF415 /* CompressingStatementDecorator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0D5403012B160693007DF415 /* CompressingStatementDecorator.cpp */; };\n\t\t0D5403042B160693007DF415 /* CompressingStatementDecorator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0D5403012B160693007DF415 /* CompressingStatementDecorator.cpp */; };\n\t\t0D5403052B160693007DF415 /* CompressingStatementDecorator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0D5403012B160693007DF415 /* CompressingStatementDecorator.cpp */; };\n\t\t0D5403062B160693007DF415 /* CompressingStatementDecorator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0D5403012B160693007DF415 /* CompressingStatementDecorator.cpp */; };\n\t\t0D5403072B160693007DF415 /* CompressingStatementDecorator.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 0D5403022B160693007DF415 /* CompressingStatementDecorator.hpp */; };\n\t\t0D5403082B160693007DF415 /* CompressingStatementDecorator.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 0D5403022B160693007DF415 /* CompressingStatementDecorator.hpp */; };\n\t\t0D5403092B160693007DF415 /* CompressingStatementDecorator.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 0D5403022B160693007DF415 /* CompressingStatementDecorator.hpp */; };\n\t\t0D54030A2B160693007DF415 /* CompressingStatementDecorator.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 0D5403022B160693007DF415 /* CompressingStatementDecorator.hpp */; };\n\t\t0D54030D2B1606BC007DF415 /* CompressingHandleDecorator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0D54030B2B1606BC007DF415 /* CompressingHandleDecorator.cpp */; };\n\t\t0D54030E2B1606BC007DF415 /* CompressingHandleDecorator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0D54030B2B1606BC007DF415 /* CompressingHandleDecorator.cpp */; };\n\t\t0D54030F2B1606BC007DF415 /* CompressingHandleDecorator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0D54030B2B1606BC007DF415 /* CompressingHandleDecorator.cpp */; };\n\t\t0D5403102B1606BC007DF415 /* CompressingHandleDecorator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0D54030B2B1606BC007DF415 /* CompressingHandleDecorator.cpp */; };\n\t\t0D5403112B1606BC007DF415 /* CompressingHandleDecorator.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 0D54030C2B1606BC007DF415 /* CompressingHandleDecorator.hpp */; };\n\t\t0D5403122B1606BC007DF415 /* CompressingHandleDecorator.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 0D54030C2B1606BC007DF415 /* CompressingHandleDecorator.hpp */; };\n\t\t0D5403132B1606BC007DF415 /* CompressingHandleDecorator.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 0D54030C2B1606BC007DF415 /* CompressingHandleDecorator.hpp */; };\n\t\t0D5403142B1606BC007DF415 /* CompressingHandleDecorator.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 0D54030C2B1606BC007DF415 /* CompressingHandleDecorator.hpp */; };\n\t\t0D71F9342A8B377100F7B4F6 /* Random.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0D71F9332A8B377100F7B4F6 /* Random.swift */; };\n\t\t0D71F9352A8B377100F7B4F6 /* Random.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0D71F9332A8B377100F7B4F6 /* Random.swift */; };\n\t\t0D71F9362A8B659400F7B4F6 /* RandomData.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E1671827F434E800D2C926 /* RandomData.swift */; };\n\t\t0D8084212A861E8500C81BBF /* WCTCancellationSignal.h in Headers */ = {isa = PBXBuildFile; fileRef = 0D8084202A861E8500C81BBF /* WCTCancellationSignal.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t0D8084222A861E8500C81BBF /* WCTCancellationSignal.h in Headers */ = {isa = PBXBuildFile; fileRef = 0D8084202A861E8500C81BBF /* WCTCancellationSignal.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t0D8084242A861E9500C81BBF /* WCTCancellationSignal.mm in Sources */ = {isa = PBXBuildFile; fileRef = 0D8084232A861E9500C81BBF /* WCTCancellationSignal.mm */; };\n\t\t0D81CDAB2A569FAB0051FF8E /* ColumnConstraintEnablePrimaryAutoIncrement.mm in Sources */ = {isa = PBXBuildFile; fileRef = 0D81CDA92A569CE40051FF8E /* ColumnConstraintEnablePrimaryAutoIncrement.mm */; };\n\t\t0D81CDAE2A56DA070051FF8E /* CPPColumnConstraintEnablePrimaryAutoIncrement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0D81CDAC2A56DA070051FF8E /* CPPColumnConstraintEnablePrimaryAutoIncrement.cpp */; };\n\t\t0D8BC3082B99B3C000DE9AE5 /* WCDBBridging.h in Headers */ = {isa = PBXBuildFile; fileRef = 0D8BC3072B99B3BF00DE9AE5 /* WCDBBridging.h */; settings = {ATTRIBUTES = (Private, ); }; };\n\t\t0D8BC3092B99B3C000DE9AE5 /* WCDBBridging.h in Headers */ = {isa = PBXBuildFile; fileRef = 0D8BC3072B99B3BF00DE9AE5 /* WCDBBridging.h */; settings = {ATTRIBUTES = (Private, ); }; };\n\t\t0DAD8FF72B303D2A00372DBF /* CompressRobustyTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 0DAD8FF62B303D2A00372DBF /* CompressRobustyTests.mm */; };\n\t\t0DAD93C129FA2A1200E5788C /* TableChainCall.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0DAD93C029FA2A1200E5788C /* TableChainCall.swift */; };\n\t\t0DAD93C229FA2A1200E5788C /* TableChainCall.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0DAD93C029FA2A1200E5788C /* TableChainCall.swift */; };\n\t\t0DAD93C429FA2C4800E5788C /* TableChainCall+WCTTableCoding.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0DAD93C329FA2C4800E5788C /* TableChainCall+WCTTableCoding.swift */; };\n\t\t0DAE11D428DC6CC6003FB63A /* WCDB.h in Headers */ = {isa = PBXBuildFile; fileRef = 0DAE11D328DC6CC6003FB63A /* WCDB.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t0DAE11D528DC6D85003FB63A /* WCDBCpp.h in Headers */ = {isa = PBXBuildFile; fileRef = 03E5CB0028A3513C005353D9 /* WCDBCpp.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t0DB806A32B972E2F00D5E86D /* WCTBridgeProperty.swift in Sources */ = {isa = PBXBuildFile; fileRef = 036E50C028116D7A007365CD /* WCTBridgeProperty.swift */; };\n\t\t0DC98FD228E46049007F3796 /* DBOperationNotifier.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0DC98FD028E46049007F3796 /* DBOperationNotifier.cpp */; };\n\t\t0DC98FD328E46049007F3796 /* DBOperationNotifier.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0DC98FD028E46049007F3796 /* DBOperationNotifier.cpp */; };\n\t\t0DC98FD428E46049007F3796 /* DBOperationNotifier.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 0DC98FD128E46049007F3796 /* DBOperationNotifier.hpp */; };\n\t\t0DC98FD528E46049007F3796 /* DBOperationNotifier.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 0DC98FD128E46049007F3796 /* DBOperationNotifier.hpp */; };\n\t\t0DCD2AC32C6E210700C247EC /* AutoVacuumConfig.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0DCD2AC12C6E210700C247EC /* AutoVacuumConfig.cpp */; };\n\t\t0DCD2AC42C6E210700C247EC /* AutoVacuumConfig.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0DCD2AC12C6E210700C247EC /* AutoVacuumConfig.cpp */; };\n\t\t0DCD2AC52C6E210700C247EC /* AutoVacuumConfig.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0DCD2AC12C6E210700C247EC /* AutoVacuumConfig.cpp */; };\n\t\t0DCD2AC62C6E210700C247EC /* AutoVacuumConfig.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0DCD2AC12C6E210700C247EC /* AutoVacuumConfig.cpp */; };\n\t\t0DCD2AC72C6E210700C247EC /* AutoVacuumConfig.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 0DCD2AC22C6E210700C247EC /* AutoVacuumConfig.hpp */; };\n\t\t0DCD2AC82C6E210700C247EC /* AutoVacuumConfig.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 0DCD2AC22C6E210700C247EC /* AutoVacuumConfig.hpp */; };\n\t\t0DCD2AC92C6E210700C247EC /* AutoVacuumConfig.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 0DCD2AC22C6E210700C247EC /* AutoVacuumConfig.hpp */; };\n\t\t0DCD2ACA2C6E210700C247EC /* AutoVacuumConfig.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 0DCD2AC22C6E210700C247EC /* AutoVacuumConfig.hpp */; };\n\t\t0DD8D1172B074C47002C97D3 /* MigrateHandleOperator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0DD8D1152B074C47002C97D3 /* MigrateHandleOperator.cpp */; };\n\t\t0DD8D1182B074C47002C97D3 /* MigrateHandleOperator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0DD8D1152B074C47002C97D3 /* MigrateHandleOperator.cpp */; };\n\t\t0DD8D1192B074C47002C97D3 /* MigrateHandleOperator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0DD8D1152B074C47002C97D3 /* MigrateHandleOperator.cpp */; };\n\t\t0DD8D11A2B074C47002C97D3 /* MigrateHandleOperator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0DD8D1152B074C47002C97D3 /* MigrateHandleOperator.cpp */; };\n\t\t0DD8D11B2B074C47002C97D3 /* MigrateHandleOperator.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 0DD8D1162B074C47002C97D3 /* MigrateHandleOperator.hpp */; };\n\t\t0DD8D11C2B074C47002C97D3 /* MigrateHandleOperator.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 0DD8D1162B074C47002C97D3 /* MigrateHandleOperator.hpp */; };\n\t\t0DD8D11D2B074C47002C97D3 /* MigrateHandleOperator.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 0DD8D1162B074C47002C97D3 /* MigrateHandleOperator.hpp */; };\n\t\t0DD8D11E2B074C47002C97D3 /* MigrateHandleOperator.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 0DD8D1162B074C47002C97D3 /* MigrateHandleOperator.hpp */; };\n\t\t0DDF54292B32D18900DB3D65 /* VacuumRobustyTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 0DDF54282B32D18900DB3D65 /* VacuumRobustyTests.mm */; };\n\t\t0DDF542B2B32D3EC00DB3D65 /* RobustyTestCase.mm in Sources */ = {isa = PBXBuildFile; fileRef = 0DDF542A2B32D3EC00DB3D65 /* RobustyTestCase.mm */; };\n\t\t0DE08A2029CBE79C009A7CA3 /* CrossPlatform.h in Headers */ = {isa = PBXBuildFile; fileRef = 0DE08A1B29CBE79C009A7CA3 /* CrossPlatform.h */; };\n\t\t0DE08A2429CBE79C009A7CA3 /* CrossPlatform.c in Sources */ = {isa = PBXBuildFile; fileRef = 0DE08A1D29CBE79C009A7CA3 /* CrossPlatform.c */; };\n\t\t0DE08A2629CBE79C009A7CA3 /* WCTOperationQueue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0DE08A1E29CBE79C009A7CA3 /* WCTOperationQueue.cpp */; };\n\t\t0DE08A2B29CBEB4E009A7CA3 /* WCTFileManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0DE08A1C29CBE79C009A7CA3 /* WCTFileManager.cpp */; };\n\t\t0DE2D9A32AEB934E005420D3 /* CPPTableTest.mm in Sources */ = {isa = PBXBuildFile; fileRef = 0DE2D9A22AEB934E005420D3 /* CPPTableTest.mm */; };\n\t\t0DE68B362AB45C27008BD74C /* RepairTestObjectBase.mm in Sources */ = {isa = PBXBuildFile; fileRef = 0DE68B352AB45C27008BD74C /* RepairTestObjectBase.mm */; };\n\t\t0DE68B3B2AB45F6C008BD74C /* NormalRepairTestObject.mm in Sources */ = {isa = PBXBuildFile; fileRef = 0DE68B3A2AB45F6C008BD74C /* NormalRepairTestObject.mm */; };\n\t\t0DE68B3E2AB461AA008BD74C /* AutoIncrementRepairTestObject.mm in Sources */ = {isa = PBXBuildFile; fileRef = 0DE68B3D2AB461AA008BD74C /* AutoIncrementRepairTestObject.mm */; };\n\t\t0DE68B412AB466F1008BD74C /* WithoutRowidRepairTestObject.mm in Sources */ = {isa = PBXBuildFile; fileRef = 0DE68B402AB466F1008BD74C /* WithoutRowidRepairTestObject.mm */; };\n\t\t0DE84AD22B03295400522A4E /* FunctionContainer.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 0DE84ACD2B03295400522A4E /* FunctionContainer.hpp */; };\n\t\t0DE84AD32B03295400522A4E /* FunctionContainer.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 0DE84ACD2B03295400522A4E /* FunctionContainer.hpp */; };\n\t\t0DE84AD42B03295400522A4E /* FunctionContainer.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 0DE84ACD2B03295400522A4E /* FunctionContainer.hpp */; };\n\t\t0DE84AD52B03295400522A4E /* FunctionContainer.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 0DE84ACD2B03295400522A4E /* FunctionContainer.hpp */; };\n\t\t0DE84C7D2B03886800522A4E /* DecorativeHandleStatement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0DE84C7B2B03886800522A4E /* DecorativeHandleStatement.cpp */; };\n\t\t0DE84C7E2B03886800522A4E /* DecorativeHandleStatement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0DE84C7B2B03886800522A4E /* DecorativeHandleStatement.cpp */; };\n\t\t0DE84C7F2B03886800522A4E /* DecorativeHandleStatement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0DE84C7B2B03886800522A4E /* DecorativeHandleStatement.cpp */; };\n\t\t0DE84C802B03886800522A4E /* DecorativeHandleStatement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0DE84C7B2B03886800522A4E /* DecorativeHandleStatement.cpp */; };\n\t\t0DE84C812B03886800522A4E /* DecorativeHandleStatement.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 0DE84C7C2B03886800522A4E /* DecorativeHandleStatement.hpp */; };\n\t\t0DE84C822B03886800522A4E /* DecorativeHandleStatement.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 0DE84C7C2B03886800522A4E /* DecorativeHandleStatement.hpp */; };\n\t\t0DE84C832B03886800522A4E /* DecorativeHandleStatement.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 0DE84C7C2B03886800522A4E /* DecorativeHandleStatement.hpp */; };\n\t\t0DE84C842B03886800522A4E /* DecorativeHandleStatement.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 0DE84C7C2B03886800522A4E /* DecorativeHandleStatement.hpp */; };\n\t\t0DF1089629C05559004ED764 /* StatementSelectInterface.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0DF1089529C05559004ED764 /* StatementSelectInterface.swift */; };\n\t\t0DF1089729C05559004ED764 /* StatementSelectInterface.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0DF1089529C05559004ED764 /* StatementSelectInterface.swift */; };\n\t\t2304B42822156CD700901953 /* TokenizerModule.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2304B42622156CD700901953 /* TokenizerModule.cpp */; };\n\t\t2304B42A22156CD700901953 /* TokenizerModule.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 2304B42722156CD700901953 /* TokenizerModule.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t2304B42E22156E1500901953 /* TokenizerModules.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2304B42C22156E1500901953 /* TokenizerModules.cpp */; };\n\t\t2304B43022156E1500901953 /* TokenizerModules.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 2304B42D22156E1500901953 /* TokenizerModules.hpp */; };\n\t\t2308F84F20E32A51001CD9C3 /* FileHandle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2308F84B20E32A51001CD9C3 /* FileHandle.cpp */; };\n\t\t2308F85120E32A51001CD9C3 /* FileHandle.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 2308F84C20E32A51001CD9C3 /* FileHandle.hpp */; };\n\t\t2308F85320E32A51001CD9C3 /* Serialization.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2308F84D20E32A51001CD9C3 /* Serialization.cpp */; };\n\t\t2308F85520E32A51001CD9C3 /* Serialization.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 2308F84E20E32A51001CD9C3 /* Serialization.hpp */; };\n\t\t2308F8A820E37FB1001CD9C3 /* WCTDatabase+Repair.h in Headers */ = {isa = PBXBuildFile; fileRef = 2308F8A720E37FB0001CD9C3 /* WCTDatabase+Repair.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t2314AE7121070A1700244D39 /* Range.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2314AE6F21070A1700244D39 /* Range.cpp */; };\n\t\t2314AE7321070A1700244D39 /* Range.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 2314AE7021070A1700244D39 /* Range.hpp */; };\n\t\t2316D92F21057CA700707AFC /* MappedData.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 2316D92B21057CA600707AFC /* MappedData.hpp */; };\n\t\t2316D93121057CA700707AFC /* Recyclable.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 2316D92D21057CA700707AFC /* Recyclable.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t2316D93321057CA700707AFC /* MappedData.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2316D92E21057CA700707AFC /* MappedData.cpp */; };\n\t\t2316D93721058B5500707AFC /* WCTFileManager.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2316D93521058B5500707AFC /* WCTFileManager.mm */; };\n\t\t2316D9432105D19500707AFC /* PageBasedFileHandle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2316D9412105D19500707AFC /* PageBasedFileHandle.cpp */; };\n\t\t2316D9452105D19500707AFC /* PageBasedFileHandle.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 2316D9422105D19500707AFC /* PageBasedFileHandle.hpp */; };\n\t\t2316D94B2105D21500707AFC /* LRUCache.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 2316D9482105D21500707AFC /* LRUCache.hpp */; };\n\t\t23176A8C21B912B10051ACF9 /* WCDBVersion.h in Headers */ = {isa = PBXBuildFile; fileRef = 23176A8B21B912B10051ACF9 /* WCDBVersion.h */; };\n\t\t23176A9B21BA7D460051ACF9 /* WCTDatabase+Version.h in Headers */ = {isa = PBXBuildFile; fileRef = 23176A9921BA7D460051ACF9 /* WCTDatabase+Version.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t23176A9C21BA7D460051ACF9 /* WCTDatabase+Version.mm in Sources */ = {isa = PBXBuildFile; fileRef = 23176A9A21BA7D460051ACF9 /* WCTDatabase+Version.mm */; };\n\t\t231C35EE21DE09E800B5D3D2 /* Exiting.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 231C35EC21DE09E400B5D3D2 /* Exiting.cpp */; };\n\t\t231C35EF21DE09EC00B5D3D2 /* Exiting.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 231C35EA21DE090500B5D3D2 /* Exiting.hpp */; };\n\t\t232741501F6FBD50004E96F7 /* WCTDatabase+FTS.h in Headers */ = {isa = PBXBuildFile; fileRef = 2327414E1F6FBD50004E96F7 /* WCTDatabase+FTS.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t232741521F6FBD50004E96F7 /* WCTDatabase+FTS.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2327414F1F6FBD50004E96F7 /* WCTDatabase+FTS.mm */; };\n\t\t2327BC22220944D80078A85B /* Config.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2327BC21220944D80078A85B /* Config.cpp */; };\n\t\t232C6F03229C0A280046742F /* WCTOperationQueue.mm in Sources */ = {isa = PBXBuildFile; fileRef = 232C6F00229C0A280046742F /* WCTOperationQueue.mm */; };\n\t\t23301BF52298FE9A00A8AB5A /* AutoMigrateConfig.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23301BF32298FE9A00A8AB5A /* AutoMigrateConfig.cpp */; };\n\t\t23301BF72298FE9A00A8AB5A /* AutoMigrateConfig.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23301BF42298FE9A00A8AB5A /* AutoMigrateConfig.hpp */; };\n\t\t23301BFB229A851800A8AB5A /* AutoBackupConfig.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23301BF9229A851800A8AB5A /* AutoBackupConfig.hpp */; };\n\t\t23301BFD229A851800A8AB5A /* AutoBackupConfig.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23301BFA229A851800A8AB5A /* AutoBackupConfig.cpp */; };\n\t\t233A058B2062698E00F1A212 /* WCTHandle+ChainCall.h in Headers */ = {isa = PBXBuildFile; fileRef = 233A05892062698E00F1A212 /* WCTHandle+ChainCall.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t233A058C2062698E00F1A212 /* WCTHandle+ChainCall.mm in Sources */ = {isa = PBXBuildFile; fileRef = 233A058A2062698E00F1A212 /* WCTHandle+ChainCall.mm */; };\n\t\t233A25D3219933DB00054EC4 /* WCTBuiltin.h in Headers */ = {isa = PBXBuildFile; fileRef = 233A25D2219933D800054EC4 /* WCTBuiltin.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t233A8532215E7CFE00BB8D4F /* Console.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 233A8530215E7CFE00BB8D4F /* Console.cpp */; };\n\t\t233A8534215E7CFE00BB8D4F /* Console.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 233A8531215E7CFE00BB8D4F /* Console.hpp */; };\n\t\t23408F0F211897AA0071E5A7 /* Shm.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23408F0D211897AA0071E5A7 /* Shm.cpp */; };\n\t\t23408F11211897AA0071E5A7 /* Shm.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23408F0E211897AA0071E5A7 /* Shm.hpp */; };\n\t\t234591F6204433E200DC7D34 /* CommonCore.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 234591F5204432E400DC7D34 /* CommonCore.hpp */; };\n\t\t2347378F21CBB3A800AD5E41 /* AbstractHandle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2347378D21CBB3A800AD5E41 /* AbstractHandle.cpp */; };\n\t\t2347379021CBB3A800AD5E41 /* AbstractHandle.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 2347378E21CBB3A800AD5E41 /* AbstractHandle.hpp */; };\n\t\t2349F6FE1EA0D6680021EFA7 /* InnerDatabase.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2349F61B1EA0D6680021EFA7 /* InnerDatabase.cpp */; };\n\t\t2349F6FF1EA0D6680021EFA7 /* InnerDatabase.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 2349F61C1EA0D6680021EFA7 /* InnerDatabase.hpp */; };\n\t\t2349F7051EA0D6680021EFA7 /* HandlePool.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2349F6221EA0D6680021EFA7 /* HandlePool.cpp */; };\n\t\t2349F7061EA0D6680021EFA7 /* HandlePool.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 2349F6231EA0D6680021EFA7 /* HandlePool.hpp */; };\n\t\t2349F7071EA0D6680021EFA7 /* RecyclableHandle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2349F6241EA0D6680021EFA7 /* RecyclableHandle.cpp */; };\n\t\t2349F7081EA0D6680021EFA7 /* RecyclableHandle.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 2349F6251EA0D6680021EFA7 /* RecyclableHandle.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t2349F7201EA0D6680021EFA7 /* WCTDelete.h in Headers */ = {isa = PBXBuildFile; fileRef = 2349F6401EA0D6680021EFA7 /* WCTDelete.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t2349F7211EA0D6680021EFA7 /* WCTDelete.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2349F6411EA0D6680021EFA7 /* WCTDelete.mm */; };\n\t\t2349F7231EA0D6680021EFA7 /* WCTInsert.h in Headers */ = {isa = PBXBuildFile; fileRef = 2349F6431EA0D6680021EFA7 /* WCTInsert.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t2349F7241EA0D6680021EFA7 /* WCTInsert.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2349F6441EA0D6680021EFA7 /* WCTInsert.mm */; };\n\t\t2349F7271EA0D6680021EFA7 /* WCTMultiSelect.h in Headers */ = {isa = PBXBuildFile; fileRef = 2349F6471EA0D6680021EFA7 /* WCTMultiSelect.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t2349F7281EA0D6680021EFA7 /* WCTMultiSelect.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2349F6481EA0D6680021EFA7 /* WCTMultiSelect.mm */; };\n\t\t2349F72C1EA0D6680021EFA7 /* WCTSelect.h in Headers */ = {isa = PBXBuildFile; fileRef = 2349F64C1EA0D6680021EFA7 /* WCTSelect.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t2349F72D1EA0D6680021EFA7 /* WCTSelect.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2349F64D1EA0D6680021EFA7 /* WCTSelect.mm */; };\n\t\t2349F72E1EA0D6680021EFA7 /* WCTSelectable+Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 2349F64E1EA0D6680021EFA7 /* WCTSelectable+Private.h */; };\n\t\t2349F72F1EA0D6680021EFA7 /* WCTSelectable.h in Headers */ = {isa = PBXBuildFile; fileRef = 2349F64F1EA0D6680021EFA7 /* WCTSelectable.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t2349F7301EA0D6680021EFA7 /* WCTSelectable.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2349F6501EA0D6680021EFA7 /* WCTSelectable.mm */; };\n\t\t2349F7311EA0D6680021EFA7 /* WCTTable+ChainCall.h in Headers */ = {isa = PBXBuildFile; fileRef = 2349F6511EA0D6680021EFA7 /* WCTTable+ChainCall.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t2349F7321EA0D6680021EFA7 /* WCTTable+ChainCall.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2349F6521EA0D6680021EFA7 /* WCTTable+ChainCall.mm */; };\n\t\t2349F7341EA0D6680021EFA7 /* WCTUpdate.h in Headers */ = {isa = PBXBuildFile; fileRef = 2349F6541EA0D6680021EFA7 /* WCTUpdate.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t2349F7351EA0D6680021EFA7 /* WCTUpdate.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2349F6551EA0D6680021EFA7 /* WCTUpdate.mm */; };\n\t\t2349F7361EA0D6680021EFA7 /* WCTDatabase+Convenient.h in Headers */ = {isa = PBXBuildFile; fileRef = 2349F6571EA0D6680021EFA7 /* WCTDatabase+Convenient.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t2349F7371EA0D6680021EFA7 /* WCTDatabase+Convenient.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2349F6581EA0D6680021EFA7 /* WCTDatabase+Convenient.mm */; };\n\t\t2349F7381EA0D6680021EFA7 /* WCTTable+Convenient.h in Headers */ = {isa = PBXBuildFile; fileRef = 2349F6591EA0D6680021EFA7 /* WCTTable+Convenient.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t2349F7391EA0D6680021EFA7 /* WCTTable+Convenient.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2349F65A1EA0D6680021EFA7 /* WCTTable+Convenient.mm */; };\n\t\t2349F7481EA0D6680021EFA7 /* WCTDatabase+File.h in Headers */ = {isa = PBXBuildFile; fileRef = 2349F66B1EA0D6680021EFA7 /* WCTDatabase+File.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t2349F7491EA0D6680021EFA7 /* WCTDatabase+File.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2349F66C1EA0D6680021EFA7 /* WCTDatabase+File.mm */; };\n\t\t2349F74C1EA0D6680021EFA7 /* WCTDatabase+Repair.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2349F66F1EA0D6680021EFA7 /* WCTDatabase+Repair.mm */; };\n\t\t2349F7551EA0D6680021EFA7 /* WCTBaseAccessor.h in Headers */ = {isa = PBXBuildFile; fileRef = 2349F67B1EA0D6680021EFA7 /* WCTBaseAccessor.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t2349F7561EA0D6680021EFA7 /* WCTCppAccessor.h in Headers */ = {isa = PBXBuildFile; fileRef = 2349F67C1EA0D6680021EFA7 /* WCTCppAccessor.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t2349F7571EA0D6680021EFA7 /* WCTObjCAccessor.h in Headers */ = {isa = PBXBuildFile; fileRef = 2349F67D1EA0D6680021EFA7 /* WCTObjCAccessor.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t2349F7581EA0D6680021EFA7 /* WCTRuntimeBaseAccessor.h in Headers */ = {isa = PBXBuildFile; fileRef = 2349F67E1EA0D6680021EFA7 /* WCTRuntimeBaseAccessor.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t2349F7591EA0D6680021EFA7 /* WCTRuntimeBaseAccessor.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2349F67F1EA0D6680021EFA7 /* WCTRuntimeBaseAccessor.mm */; };\n\t\t2349F75A1EA0D6680021EFA7 /* WCTRuntimeCppAccessor.h in Headers */ = {isa = PBXBuildFile; fileRef = 2349F6801EA0D6680021EFA7 /* WCTRuntimeCppAccessor.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t2349F75B1EA0D6680021EFA7 /* WCTRuntimeObjCAccessor.h in Headers */ = {isa = PBXBuildFile; fileRef = 2349F6811EA0D6680021EFA7 /* WCTRuntimeObjCAccessor.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t2349F75C1EA0D6680021EFA7 /* WCTRuntimeObjCAccessor.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2349F6821EA0D6680021EFA7 /* WCTRuntimeObjCAccessor.mm */; };\n\t\t2349F75D1EA0D6680021EFA7 /* WCTBinding.h in Headers */ = {isa = PBXBuildFile; fileRef = 2349F6841EA0D6680021EFA7 /* WCTBinding.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t2349F75E1EA0D6680021EFA7 /* WCTBinding.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2349F6851EA0D6680021EFA7 /* WCTBinding.mm */; };\n\t\t2349F75F1EA0D6680021EFA7 /* WCTColumnBinding.h in Headers */ = {isa = PBXBuildFile; fileRef = 2349F6861EA0D6680021EFA7 /* WCTColumnBinding.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t2349F7601EA0D6680021EFA7 /* WCTColumnBinding.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2349F6871EA0D6680021EFA7 /* WCTColumnBinding.mm */; };\n\t\t2349F7651EA0D6680021EFA7 /* WCTTableCoding.h in Headers */ = {isa = PBXBuildFile; fileRef = 2349F68D1EA0D6680021EFA7 /* WCTTableCoding.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t2349F7681EA0D6680021EFA7 /* WCTProperty.h in Headers */ = {isa = PBXBuildFile; fileRef = 2349F6901EA0D6680021EFA7 /* WCTProperty.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t2349F7691EA0D6680021EFA7 /* WCTProperty.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2349F6911EA0D6680021EFA7 /* WCTProperty.mm */; };\n\t\t2349F76A1EA0D6680021EFA7 /* WCTMacro.h in Headers */ = {isa = PBXBuildFile; fileRef = 2349F6931EA0D6680021EFA7 /* WCTMacro.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t2349F76B1EA0D6680021EFA7 /* WCTPropertyMacro.h in Headers */ = {isa = PBXBuildFile; fileRef = 2349F6941EA0D6680021EFA7 /* WCTPropertyMacro.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t2349F76C1EA0D6680021EFA7 /* WCTTableConstraintMacro.h in Headers */ = {isa = PBXBuildFile; fileRef = 2349F6951EA0D6680021EFA7 /* WCTTableConstraintMacro.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t2349F76D1EA0D6680021EFA7 /* WCTIndexMacro.h in Headers */ = {isa = PBXBuildFile; fileRef = 2349F6961EA0D6680021EFA7 /* WCTIndexMacro.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t2349F76F1EA0D6680021EFA7 /* WCTORM.h in Headers */ = {isa = PBXBuildFile; fileRef = 2349F6981EA0D6680021EFA7 /* WCTORM.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t2349F7701EA0D6680021EFA7 /* WCTDatabase+Table.h in Headers */ = {isa = PBXBuildFile; fileRef = 2349F69A1EA0D6680021EFA7 /* WCTDatabase+Table.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t2349F7711EA0D6680021EFA7 /* WCTDatabase+Table.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2349F69B1EA0D6680021EFA7 /* WCTDatabase+Table.mm */; };\n\t\t2349F7741EA0D6680021EFA7 /* WCTTable+Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 2349F69E1EA0D6680021EFA7 /* WCTTable+Private.h */; };\n\t\t2349F78E1EA0D6680021EFA7 /* WCDBObjc.h in Headers */ = {isa = PBXBuildFile; fileRef = 2349F6BA1EA0D6680021EFA7 /* WCDBObjc.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t234DBCF32064DD0C000E31E8 /* WCTDatabase+Handle.h in Headers */ = {isa = PBXBuildFile; fileRef = 234DBCEC2064DD0B000E31E8 /* WCTDatabase+Handle.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t234DBCF42064DD0C000E31E8 /* WCTDatabase+Handle.mm in Sources */ = {isa = PBXBuildFile; fileRef = 234DBCED2064DD0B000E31E8 /* WCTDatabase+Handle.mm */; };\n\t\t234DBCF72064DD0C000E31E8 /* WCTHandle+Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 234DBCF02064DD0B000E31E8 /* WCTHandle+Private.h */; };\n\t\t234DBCF82064DD0C000E31E8 /* WCTHandle.h in Headers */ = {isa = PBXBuildFile; fileRef = 234DBCF12064DD0B000E31E8 /* WCTHandle.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t234DBCF92064DD0C000E31E8 /* WCTHandle.mm in Sources */ = {isa = PBXBuildFile; fileRef = 234DBCF22064DD0B000E31E8 /* WCTHandle.mm */; };\n\t\t234DBD032064DE04000E31E8 /* WCTDatabase+Transaction.h in Headers */ = {isa = PBXBuildFile; fileRef = 234DBCFF2064DE04000E31E8 /* WCTDatabase+Transaction.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t234DBD042064DE04000E31E8 /* WCTDatabase+Transaction.mm in Sources */ = {isa = PBXBuildFile; fileRef = 234DBD002064DE04000E31E8 /* WCTDatabase+Transaction.mm */; };\n\t\t234DBD052064DE04000E31E8 /* WCTHandle+Transaction.h in Headers */ = {isa = PBXBuildFile; fileRef = 234DBD012064DE04000E31E8 /* WCTHandle+Transaction.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t234DBD062064DE04000E31E8 /* WCTHandle+Transaction.mm in Sources */ = {isa = PBXBuildFile; fileRef = 234DBD022064DE04000E31E8 /* WCTHandle+Transaction.mm */; };\n\t\t234DBD092064DE23000E31E8 /* WCTTransaction.h in Headers */ = {isa = PBXBuildFile; fileRef = 234DBD072064DE23000E31E8 /* WCTTransaction.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t234DBD0D2064E045000E31E8 /* WCTChainCall.h in Headers */ = {isa = PBXBuildFile; fileRef = 234DBD0B2064E045000E31E8 /* WCTChainCall.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t234EF46E2015CFDE00B81929 /* WCTConvertible.h in Headers */ = {isa = PBXBuildFile; fileRef = 234EF46C2015CFDE00B81929 /* WCTConvertible.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t234EF46F2015CFDE00B81929 /* WCTConvertible.mm in Sources */ = {isa = PBXBuildFile; fileRef = 234EF46D2015CFDE00B81929 /* WCTConvertible.mm */; };\n\t\t234F0338227A950900DD65A2 /* SQLiteFTS3Tokenizer.h in Headers */ = {isa = PBXBuildFile; fileRef = 234F0337227A950900DD65A2 /* SQLiteFTS3Tokenizer.h */; };\n\t\t234F04B1227A9EFA00DD65A2 /* ConfigTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 234F038B227A9EFA00DD65A2 /* ConfigTests.mm */; };\n\t\t234F04FA227A9EFA00DD65A2 /* HandleTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 234F03D9227A9EFA00DD65A2 /* HandleTests.mm */; };\n\t\t234F0508227A9EFA00DD65A2 /* MultiSelectTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 234F03F6227A9EFA00DD65A2 /* MultiSelectTests.mm */; };\n\t\t234F0509227A9EFA00DD65A2 /* ChainCallTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 234F03F7227A9EFA00DD65A2 /* ChainCallTests.mm */; };\n\t\t234F0527227A9EFA00DD65A2 /* ORMTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 234F0445227A9EFA00DD65A2 /* ORMTests.mm */; };\n\t\t234F0558227A9F0900DD65A2 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 234F0388227A9EFA00DD65A2 /* main.m */; };\n\t\t234F058D227AA4D700DD65A2 /* VersionTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 234F058B227AA4D700DD65A2 /* VersionTests.mm */; };\n\t\t234F058E227AA4D700DD65A2 /* TraceTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 234F058C227AA4D700DD65A2 /* TraceTests.mm */; };\n\t\t234F0594227AA4E200DD65A2 /* DatabaseTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 234F058F227AA4E100DD65A2 /* DatabaseTests.mm */; };\n\t\t234F0595227AA4E200DD65A2 /* ObservationTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 234F0590227AA4E100DD65A2 /* ObservationTests.mm */; };\n\t\t234F0596227AA4E200DD65A2 /* FileTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 234F0591227AA4E200DD65A2 /* FileTests.mm */; };\n\t\t234F0598227AA4E200DD65A2 /* TableTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 234F0593227AA4E200DD65A2 /* TableTests.mm */; };\n\t\t234F05DD227AA4F600DD65A2 /* StatementAlterTableTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 234F0599227AA4EC00DD65A2 /* StatementAlterTableTests.mm */; };\n\t\t234F05DE227AA4F600DD65A2 /* FrameSpecTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 234F059A227AA4ED00DD65A2 /* FrameSpecTests.mm */; };\n\t\t234F05DF227AA4F600DD65A2 /* FTSFunctionTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 234F059B227AA4ED00DD65A2 /* FTSFunctionTests.mm */; };\n\t\t234F05E0227AA4F600DD65A2 /* StatementTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 234F059C227AA4ED00DD65A2 /* StatementTests.mm */; };\n\t\t234F05E1227AA4F600DD65A2 /* StatementPragmaTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 234F059D227AA4ED00DD65A2 /* StatementPragmaTests.mm */; };\n\t\t234F05E2227AA4F600DD65A2 /* ColumnConstraintTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 234F059E227AA4ED00DD65A2 /* ColumnConstraintTests.mm */; };\n\t\t234F05E5227AA4F600DD65A2 /* StatementDeleteTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 234F05A1227AA4ED00DD65A2 /* StatementDeleteTests.mm */; };\n\t\t234F05E7227AA4F600DD65A2 /* CoreFunctionTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 234F05A3227AA4EE00DD65A2 /* CoreFunctionTests.mm */; };\n\t\t234F05E8227AA4F600DD65A2 /* StatementReleaseTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 234F05A4227AA4EE00DD65A2 /* StatementReleaseTests.mm */; };\n\t\t234F05E9227AA4F600DD65A2 /* UpsertTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 234F05A5227AA4EE00DD65A2 /* UpsertTests.mm */; };\n\t\t234F05EA227AA4F600DD65A2 /* OrderingTermTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 234F05A6227AA4EE00DD65A2 /* OrderingTermTests.mm */; };\n\t\t234F05EB227AA4F600DD65A2 /* BindParameterTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 234F05A7227AA4EE00DD65A2 /* BindParameterTests.mm */; };\n\t\t234F05EC227AA4F600DD65A2 /* ConflictTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 234F05A8227AA4EE00DD65A2 /* ConflictTests.mm */; };\n\t\t234F05ED227AA4F600DD65A2 /* WCTResultColumnTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 234F05A9227AA4EF00DD65A2 /* WCTResultColumnTests.mm */; };\n\t\t234F05EE227AA4F600DD65A2 /* StatementSavepointTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 234F05AA227AA4EF00DD65A2 /* StatementSavepointTests.mm */; };\n\t\t234F05EF227AA4F600DD65A2 /* JoinConstraintTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 234F05AB227AA4EF00DD65A2 /* JoinConstraintTests.mm */; };\n\t\t234F05F0227AA4F600DD65A2 /* TableOrSubqueryTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 234F05AC227AA4EF00DD65A2 /* TableOrSubqueryTests.mm */; };\n\t\t234F05F1227AA4F600DD65A2 /* StatementCreateVirtualTableTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 234F05AD227AA4EF00DD65A2 /* StatementCreateVirtualTableTests.mm */; };\n\t\t234F05F2227AA4F600DD65A2 /* WINQAssertion.mm in Sources */ = {isa = PBXBuildFile; fileRef = 234F05AE227AA4EF00DD65A2 /* WINQAssertion.mm */; };\n\t\t234F05F3227AA4F600DD65A2 /* ExpressionTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 234F05AF227AA4EF00DD65A2 /* ExpressionTests.mm */; };\n\t\t234F05F4227AA4F600DD65A2 /* IndexedColumnTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 234F05B0227AA4EF00DD65A2 /* IndexedColumnTests.mm */; };\n\t\t234F05F5227AA4F600DD65A2 /* ExpressionOperableTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 234F05B1227AA4F000DD65A2 /* ExpressionOperableTests.mm */; };\n\t\t234F05F6227AA4F600DD65A2 /* StatementCreateTriggerTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 234F05B2227AA4F000DD65A2 /* StatementCreateTriggerTests.mm */; };\n\t\t234F05F7227AA4F600DD65A2 /* StatementCreateTableTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 234F05B3227AA4F000DD65A2 /* StatementCreateTableTests.mm */; };\n\t\t234F05F8227AA4F600DD65A2 /* ColumnTypeTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 234F05B4227AA4F000DD65A2 /* ColumnTypeTests.mm */; };\n\t\t234F05F9227AA4F600DD65A2 /* StatementDetachTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 234F05B5227AA4F000DD65A2 /* StatementDetachTests.mm */; };\n\t\t234F05FA227AA4F600DD65A2 /* StatementAnalyzeTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 234F05B6227AA4F000DD65A2 /* StatementAnalyzeTests.mm */; };\n\t\t234F05FB227AA4F600DD65A2 /* StatementVacuumTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 234F05B7227AA4F100DD65A2 /* StatementVacuumTests.mm */; };\n\t\t234F05FC227AA4F600DD65A2 /* RaiseFunctionTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 234F05B8227AA4F100DD65A2 /* RaiseFunctionTests.mm */; };\n\t\t234F05FD227AA4F600DD65A2 /* ForeignKeyTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 234F05B9227AA4F100DD65A2 /* ForeignKeyTests.mm */; };\n\t\t234F05FE227AA4F600DD65A2 /* ColumnOperableTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 234F05BB227AA4F100DD65A2 /* ColumnOperableTests.mm */; };\n\t\t234F05FF227AA4F600DD65A2 /* StatementBeginTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 234F05BC227AA4F100DD65A2 /* StatementBeginTests.mm */; };\n\t\t234F0600227AA4F600DD65A2 /* SchemaTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 234F05BD227AA4F100DD65A2 /* SchemaTests.mm */; };\n\t\t234F0601227AA4F600DD65A2 /* StatementReindexTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 234F05BE227AA4F200DD65A2 /* StatementReindexTests.mm */; };\n\t\t234F0602227AA4F600DD65A2 /* FilterTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 234F05BF227AA4F200DD65A2 /* FilterTests.mm */; };\n\t\t234F0603227AA4F600DD65A2 /* StatementSelectTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 234F05C0227AA4F200DD65A2 /* StatementSelectTests.mm */; };\n\t\t234F0604227AA4F600DD65A2 /* StatementDropViewTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 234F05C1227AA4F200DD65A2 /* StatementDropViewTests.mm */; };\n\t\t234F0605227AA4F600DD65A2 /* StoppableIterationTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 234F05C2227AA4F200DD65A2 /* StoppableIterationTests.mm */; };\n\t\t234F0606227AA4F600DD65A2 /* ColumnDefTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 234F05C3227AA4F200DD65A2 /* ColumnDefTests.mm */; };\n\t\t234F0607227AA4F600DD65A2 /* StatementDropIndexTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 234F05C4227AA4F200DD65A2 /* StatementDropIndexTests.mm */; };\n\t\t234F0608227AA4F600DD65A2 /* StatementAttachTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 234F05C5227AA4F300DD65A2 /* StatementAttachTests.mm */; };\n\t\t234F0609227AA4F600DD65A2 /* StatementCreateIndexTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 234F05C6227AA4F300DD65A2 /* StatementCreateIndexTests.mm */; };\n\t\t234F060A227AA4F600DD65A2 /* StatementUpdateTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 234F05C7227AA4F300DD65A2 /* StatementUpdateTests.mm */; };\n\t\t234F060B227AA4F600DD65A2 /* AggregateFunctionTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 234F05C8227AA4F300DD65A2 /* AggregateFunctionTests.mm */; };\n\t\t234F060C227AA4F600DD65A2 /* StatementCommitTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 234F05C9227AA4F300DD65A2 /* StatementCommitTests.mm */; };\n\t\t234F060D227AA4F600DD65A2 /* WindowDefTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 234F05CA227AA4F300DD65A2 /* WindowDefTests.mm */; };\n\t\t234F060E227AA4F600DD65A2 /* LiteralValueTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 234F05CB227AA4F300DD65A2 /* LiteralValueTests.mm */; };\n\t\t234F060F227AA4F600DD65A2 /* StatementCreateViewTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 234F05CC227AA4F400DD65A2 /* StatementCreateViewTests.mm */; };\n\t\t234F0610227AA4F600DD65A2 /* SyntaxListTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 234F05CD227AA4F400DD65A2 /* SyntaxListTests.mm */; };\n\t\t234F0611227AA4F600DD65A2 /* CommonTableExpressionTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 234F05CE227AA4F400DD65A2 /* CommonTableExpressionTests.mm */; };\n\t\t234F0612227AA4F600DD65A2 /* StatementDropTableTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 234F05CF227AA4F400DD65A2 /* StatementDropTableTests.mm */; };\n\t\t234F0613227AA4F600DD65A2 /* WCTPropertyTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 234F05D0227AA4F400DD65A2 /* WCTPropertyTests.mm */; };\n\t\t234F0615227AA4F600DD65A2 /* ColumnTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 234F05D2227AA4F400DD65A2 /* ColumnTests.mm */; };\n\t\t234F0617227AA4F600DD65A2 /* JoinTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 234F05D4227AA4F500DD65A2 /* JoinTests.mm */; };\n\t\t234F0618227AA4F600DD65A2 /* StatementInsertTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 234F05D5227AA4F500DD65A2 /* StatementInsertTests.mm */; };\n\t\t234F0619227AA4F600DD65A2 /* OrderTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 234F05D6227AA4F500DD65A2 /* OrderTests.mm */; };\n\t\t234F061A227AA4F600DD65A2 /* QualifiedTableTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 234F05D7227AA4F500DD65A2 /* QualifiedTableTests.mm */; };\n\t\t234F061B227AA4F600DD65A2 /* StatementRollbackTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 234F05D8227AA4F500DD65A2 /* StatementRollbackTests.mm */; };\n\t\t234F061C227AA4F600DD65A2 /* ResultColumnTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 234F05D9227AA4F600DD65A2 /* ResultColumnTests.mm */; };\n\t\t234F061D227AA4F600DD65A2 /* StatementDropTriggerTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 234F05DA227AA4F600DD65A2 /* StatementDropTriggerTests.mm */; };\n\t\t234F061E227AA4F600DD65A2 /* TableConstraintTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 234F05DB227AA4F600DD65A2 /* TableConstraintTests.mm */; };\n\t\t234F061F227AA4F600DD65A2 /* PragmaTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 234F05DC227AA4F600DD65A2 /* PragmaTests.mm */; };\n\t\t234F063B227AA50800DD65A2 /* IntegerCodingObject.m in Sources */ = {isa = PBXBuildFile; fileRef = 234F0621227AA50400DD65A2 /* IntegerCodingObject.m */; };\n\t\t234F063C227AA50800DD65A2 /* IntegerCodingObject+WCTColumnCoding.mm in Sources */ = {isa = PBXBuildFile; fileRef = 234F0623227AA50500DD65A2 /* IntegerCodingObject+WCTColumnCoding.mm */; };\n\t\t234F063D227AA50800DD65A2 /* ColumnCodingObject.mm in Sources */ = {isa = PBXBuildFile; fileRef = 234F0625227AA50500DD65A2 /* ColumnCodingObject.mm */; };\n\t\t234F063E227AA50800DD65A2 /* StringCodingObject+WCTColumnCoding.mm in Sources */ = {isa = PBXBuildFile; fileRef = 234F0626227AA50500DD65A2 /* StringCodingObject+WCTColumnCoding.mm */; };\n\t\t234F063F227AA50800DD65A2 /* StringCodingObject.m in Sources */ = {isa = PBXBuildFile; fileRef = 234F062C227AA50600DD65A2 /* StringCodingObject.m */; };\n\t\t234F0640227AA50800DD65A2 /* ColumnCodingTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 234F062E227AA50600DD65A2 /* ColumnCodingTests.mm */; };\n\t\t234F0641227AA50800DD65A2 /* DoubleCodingObject+WCTColumnCoding.mm in Sources */ = {isa = PBXBuildFile; fileRef = 234F0630227AA50600DD65A2 /* DoubleCodingObject+WCTColumnCoding.mm */; };\n\t\t234F0642227AA50800DD65A2 /* DoubleCodingObject.m in Sources */ = {isa = PBXBuildFile; fileRef = 234F0631227AA50700DD65A2 /* DoubleCodingObject.m */; };\n\t\t234F0643227AA50800DD65A2 /* DataCodingObject.m in Sources */ = {isa = PBXBuildFile; fileRef = 234F0632227AA50700DD65A2 /* DataCodingObject.m */; };\n\t\t234F0645227AA50800DD65A2 /* DataCodingObject+WCTColumnCoding.mm in Sources */ = {isa = PBXBuildFile; fileRef = 234F0638227AA50800DD65A2 /* DataCodingObject+WCTColumnCoding.mm */; };\n\t\t234F0646227AA50800DD65A2 /* Random+ColumnCodingObject.mm in Sources */ = {isa = PBXBuildFile; fileRef = 234F0639227AA50800DD65A2 /* Random+ColumnCodingObject.mm */; };\n\t\t234F064B227AA51500DD65A2 /* FTS3Tests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 234F0649227AA51500DD65A2 /* FTS3Tests.mm */; };\n\t\t234F064C227AA51500DD65A2 /* FTS3Object.mm in Sources */ = {isa = PBXBuildFile; fileRef = 234F064A227AA51500DD65A2 /* FTS3Object.mm */; };\n\t\t234F06A6227AA55400DD65A2 /* AdditionalORMObject.mm in Sources */ = {isa = PBXBuildFile; fileRef = 234F06A4227AA55400DD65A2 /* AdditionalORMObject.mm */; };\n\t\t234F06AD227AA56300DD65A2 /* VirtualTableFTS5Object.mm in Sources */ = {isa = PBXBuildFile; fileRef = 234F06A9227AA56300DD65A2 /* VirtualTableFTS5Object.mm */; };\n\t\t234F06AE227AA56300DD65A2 /* VirtualTableFTS4Object.mm in Sources */ = {isa = PBXBuildFile; fileRef = 234F06AB227AA56300DD65A2 /* VirtualTableFTS4Object.mm */; };\n\t\t234F06B2227AA56B00DD65A2 /* TableConstraintObject.mm in Sources */ = {isa = PBXBuildFile; fileRef = 234F06B0227AA56B00DD65A2 /* TableConstraintObject.mm */; };\n\t\t234F06B6227AA57100DD65A2 /* PropertyObject.mm in Sources */ = {isa = PBXBuildFile; fileRef = 234F06B5227AA57100DD65A2 /* PropertyObject.mm */; };\n\t\t234F06D2227AA57D00DD65A2 /* ColumnConstraintAutoIncrement.mm in Sources */ = {isa = PBXBuildFile; fileRef = 234F06B8227AA57A00DD65A2 /* ColumnConstraintAutoIncrement.mm */; };\n\t\t234F06D3227AA57D00DD65A2 /* ColumnConstraintNotNull.mm in Sources */ = {isa = PBXBuildFile; fileRef = 234F06BA227AA57A00DD65A2 /* ColumnConstraintNotNull.mm */; };\n\t\t234F06D4227AA57D00DD65A2 /* ColumnConstraintPrimaryAsc.mm in Sources */ = {isa = PBXBuildFile; fileRef = 234F06BD227AA57B00DD65A2 /* ColumnConstraintPrimaryAsc.mm */; };\n\t\t234F06D5227AA57D00DD65A2 /* ColumnConstraintAutoIncrementAsc.mm in Sources */ = {isa = PBXBuildFile; fileRef = 234F06BE227AA57B00DD65A2 /* ColumnConstraintAutoIncrementAsc.mm */; };\n\t\t234F06D6227AA57D00DD65A2 /* ColumnConstraintCheck.mm in Sources */ = {isa = PBXBuildFile; fileRef = 234F06BF227AA57B00DD65A2 /* ColumnConstraintCheck.mm */; };\n\t\t234F06D7227AA57D00DD65A2 /* ColumnConstraintPrimaryDesc.mm in Sources */ = {isa = PBXBuildFile; fileRef = 234F06C5227AA57B00DD65A2 /* ColumnConstraintPrimaryDesc.mm */; };\n\t\t234F06D8227AA57D00DD65A2 /* ColumnConstraintPrimary.mm in Sources */ = {isa = PBXBuildFile; fileRef = 234F06C6227AA57C00DD65A2 /* ColumnConstraintPrimary.mm */; };\n\t\t234F06D9227AA57D00DD65A2 /* ColumnConstraintDefault.mm in Sources */ = {isa = PBXBuildFile; fileRef = 234F06CA227AA57C00DD65A2 /* ColumnConstraintDefault.mm */; };\n\t\t234F06DA227AA57D00DD65A2 /* ColumnConstraintUnique.mm in Sources */ = {isa = PBXBuildFile; fileRef = 234F06CD227AA57D00DD65A2 /* ColumnConstraintUnique.mm */; };\n\t\t234F06DE227AA58400DD65A2 /* IndexObject.mm in Sources */ = {isa = PBXBuildFile; fileRef = 234F06DC227AA58400DD65A2 /* IndexObject.mm */; };\n\t\t234F06EB227AA58E00DD65A2 /* OldRemapObject.mm in Sources */ = {isa = PBXBuildFile; fileRef = 234F06DF227AA58C00DD65A2 /* OldRemapObject.mm */; };\n\t\t234F06EC227AA58E00DD65A2 /* DropIndexObject.mm in Sources */ = {isa = PBXBuildFile; fileRef = 234F06E6227AA58D00DD65A2 /* DropIndexObject.mm */; };\n\t\t234F06ED227AA58E00DD65A2 /* NewlyCreatedTableIndexObject.mm in Sources */ = {isa = PBXBuildFile; fileRef = 234F06E9227AA58D00DD65A2 /* NewlyCreatedTableIndexObject.mm */; };\n\t\t234F06EE227AA58E00DD65A2 /* NewRemapObject.mm in Sources */ = {isa = PBXBuildFile; fileRef = 234F06EA227AA58D00DD65A2 /* NewRemapObject.mm */; };\n\t\t234F06F3227AA59600DD65A2 /* ConvenientDeleteTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 234F06EF227AA59500DD65A2 /* ConvenientDeleteTests.mm */; };\n\t\t234F06F4227AA59600DD65A2 /* ConvenientUpdateTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 234F06F0227AA59500DD65A2 /* ConvenientUpdateTests.mm */; };\n\t\t234F06F5227AA59600DD65A2 /* ConvenientSelectTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 234F06F1227AA59600DD65A2 /* ConvenientSelectTests.mm */; };\n\t\t234F06F6227AA59600DD65A2 /* ConvenientInsertTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 234F06F2227AA59600DD65A2 /* ConvenientInsertTests.mm */; };\n\t\t234F06F9227AA59E00DD65A2 /* ThreadTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 234F06F7227AA59D00DD65A2 /* ThreadTests.mm */; };\n\t\t234F06FA227AA59E00DD65A2 /* TransactionTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 234F06F8227AA59D00DD65A2 /* TransactionTests.mm */; };\n\t\t234F0735227AA5C700DD65A2 /* BackupTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 234F072F227AA5C600DD65A2 /* BackupTests.mm */; };\n\t\t234F0736227AA5C700DD65A2 /* DepositTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 234F0730227AA5C700DD65A2 /* DepositTests.mm */; };\n\t\t234F0737227AA5C700DD65A2 /* BackupTestCase.mm in Sources */ = {isa = PBXBuildFile; fileRef = 234F0731227AA5C700DD65A2 /* BackupTestCase.mm */; };\n\t\t234F0738227AA5C700DD65A2 /* RetrieveRobustyTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 234F0732227AA5C700DD65A2 /* RetrieveRobustyTests.mm */; };\n\t\t234F0739227AA5C700DD65A2 /* RetrieveTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 234F0734227AA5C700DD65A2 /* RetrieveTests.mm */; };\n\t\t23545B992224E8270091C981 /* SyntaxAssertion.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23545B962224E8270091C981 /* SyntaxAssertion.hpp */; };\n\t\t23545B9F2224E9C80091C981 /* SyntaxEnum.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23545B9C2224E9C80091C981 /* SyntaxEnum.hpp */; };\n\t\t23545BA22224EAA40091C981 /* SyntaxCommonConst.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23545BA12224EAA40091C981 /* SyntaxCommonConst.cpp */; };\n\t\t23567CFA20CA3889005F1C35 /* Frame.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23567CF820CA3889005F1C35 /* Frame.cpp */; };\n\t\t23567CFC20CA3889005F1C35 /* Frame.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23567CF920CA3889005F1C35 /* Frame.hpp */; };\n\t\t23567D4720CA7DBC005F1C35 /* ErrorProne.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23567D4520CA7DBC005F1C35 /* ErrorProne.hpp */; };\n\t\t23567D4920CA7DBC005F1C35 /* ErrorProne.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23567D4620CA7DBC005F1C35 /* ErrorProne.cpp */; };\n\t\t23567D5920CA823C005F1C35 /* PagerRelated.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23567D5720CA823C005F1C35 /* PagerRelated.cpp */; };\n\t\t23567D5B20CA823C005F1C35 /* PagerRelated.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23567D5820CA823C005F1C35 /* PagerRelated.hpp */; };\n\t\t23567D7520CA9200005F1C35 /* SharedThreadedErrorProne.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23567D7220CA91FF005F1C35 /* SharedThreadedErrorProne.cpp */; };\n\t\t23567D7720CA9200005F1C35 /* SharedThreadedErrorProne.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23567D7420CA91FF005F1C35 /* SharedThreadedErrorProne.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t23567D7B20CA93C5005F1C35 /* Time.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23567D7920CA93C5005F1C35 /* Time.cpp */; };\n\t\t23567D7D20CA93C5005F1C35 /* Time.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23567D7A20CA93C5005F1C35 /* Time.hpp */; };\n\t\t23577F791F74F4E800D31C05 /* WCTFTSTokenizerUtil.h in Headers */ = {isa = PBXBuildFile; fileRef = 23577F771F74F4E800D31C05 /* WCTFTSTokenizerUtil.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t23577F7A1F74F4E800D31C05 /* WCTFTSTokenizerUtil.mm in Sources */ = {isa = PBXBuildFile; fileRef = 23577F781F74F4E800D31C05 /* WCTFTSTokenizerUtil.mm */; };\n\t\t23593B7D20D3ADF80058B416 /* WalRelated.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23593B7B20D3ADF80058B416 /* WalRelated.cpp */; };\n\t\t23593B7F20D3ADF80058B416 /* WalRelated.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23593B7C20D3ADF80058B416 /* WalRelated.hpp */; };\n\t\t235EE9C522B6321A008F6658 /* StringView.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 235EE9C322B63219008F6658 /* StringView.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t235EE9C722B6321A008F6658 /* StringView.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 235EE9C422B6321A008F6658 /* StringView.cpp */; };\n\t\t235FBE9522914E0D005C7723 /* Global.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 235FBE9322914E0D005C7723 /* Global.cpp */; };\n\t\t235FBE9722914E0D005C7723 /* Global.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 235FBE9422914E0D005C7723 /* Global.hpp */; };\n\t\t2360A5F720D78F1B00E4A311 /* HandleRelated.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2360A5F320D78F1B00E4A311 /* HandleRelated.cpp */; };\n\t\t2360A5F920D78F1B00E4A311 /* HandleNotification.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2360A5F420D78F1B00E4A311 /* HandleNotification.cpp */; };\n\t\t2360A5FB20D78F1B00E4A311 /* HandleNotification.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 2360A5F520D78F1B00E4A311 /* HandleNotification.hpp */; };\n\t\t2360A5FD20D78F1B00E4A311 /* HandleRelated.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 2360A5F620D78F1B00E4A311 /* HandleRelated.hpp */; };\n\t\t2360A60320D78F2C00E4A311 /* SQLTraceConfig.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2360A5FF20D78F2B00E4A311 /* SQLTraceConfig.cpp */; };\n\t\t2360A60520D78F2C00E4A311 /* SQLTraceConfig.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 2360A60020D78F2B00E4A311 /* SQLTraceConfig.hpp */; };\n\t\t2360A60720D78F2C00E4A311 /* PerformanceTraceConfig.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2360A60120D78F2B00E4A311 /* PerformanceTraceConfig.cpp */; };\n\t\t2360A60920D78F2C00E4A311 /* PerformanceTraceConfig.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 2360A60220D78F2B00E4A311 /* PerformanceTraceConfig.hpp */; };\n\t\t2366BB21221BC0D2000ED712 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 239E8A922160A81600BCB308 /* Foundation.framework */; };\n\t\t2366BB22221BC0E6000ED712 /* Security.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 23F0FD7C215F1C92008399FB /* Security.framework */; };\n\t\t236996B221D5C4FF00E72E81 /* Recyclable.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 236996B121D5C4FF00E72E81 /* Recyclable.cpp */; };\n\t\t236BACE221BF9F6400C8B4D9 /* WCTDatabase+Migration.h in Headers */ = {isa = PBXBuildFile; fileRef = 236BACE021BF9F6400C8B4D9 /* WCTDatabase+Migration.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t236BACE321BF9F6400C8B4D9 /* WCTDatabase+Migration.mm in Sources */ = {isa = PBXBuildFile; fileRef = 236BACE121BF9F6400C8B4D9 /* WCTDatabase+Migration.mm */; };\n\t\t236BACE621BF9FC900C8B4D9 /* WCTMigrationInfo.h in Headers */ = {isa = PBXBuildFile; fileRef = 236BACE421BF9FC900C8B4D9 /* WCTMigrationInfo.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t236BACE721BF9FC900C8B4D9 /* WCTMigrationInfo.mm in Sources */ = {isa = PBXBuildFile; fileRef = 236BACE521BF9FC900C8B4D9 /* WCTMigrationInfo.mm */; };\n\t\t2370980A20590CA700E768B4 /* HandleStatement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2370980820590CA700E768B4 /* HandleStatement.cpp */; };\n\t\t2370980B20590CA700E768B4 /* HandleStatement.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 2370980920590CA700E768B4 /* HandleStatement.hpp */; };\n\t\t2370B11A21914ED500D3227C /* NSDate+WCTColumnCoding.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2370B10821914ED400D3227C /* NSDate+WCTColumnCoding.mm */; };\n\t\t2370B11D21914ED500D3227C /* NSString+WCTColumnCoding.h in Headers */ = {isa = PBXBuildFile; fileRef = 2370B10B21914ED400D3227C /* NSString+WCTColumnCoding.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t2370B11E21914ED500D3227C /* NSNumber+WCTColumnCoding.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2370B10C21914ED400D3227C /* NSNumber+WCTColumnCoding.mm */; };\n\t\t2370B11F21914ED500D3227C /* NSObject+WCTColumnCoding.h in Headers */ = {isa = PBXBuildFile; fileRef = 2370B10D21914ED400D3227C /* NSObject+WCTColumnCoding.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t2370B12021914ED500D3227C /* NSObject+WCTColumnCoding.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2370B10E21914ED400D3227C /* NSObject+WCTColumnCoding.mm */; };\n\t\t2370B12121914ED500D3227C /* NSDate+WCTColumnCoding.h in Headers */ = {isa = PBXBuildFile; fileRef = 2370B10F21914ED400D3227C /* NSDate+WCTColumnCoding.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t2370B12221914ED500D3227C /* WCTMaster.h in Headers */ = {isa = PBXBuildFile; fileRef = 2370B11021914ED400D3227C /* WCTMaster.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t2370B12321914ED500D3227C /* WCTMaster+WCTTableCoding.h in Headers */ = {isa = PBXBuildFile; fileRef = 2370B11121914ED400D3227C /* WCTMaster+WCTTableCoding.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t2370B12421914ED500D3227C /* NSNumber+WCTColumnCoding.h in Headers */ = {isa = PBXBuildFile; fileRef = 2370B11221914ED400D3227C /* NSNumber+WCTColumnCoding.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t2370B12521914ED500D3227C /* NSData+WCTColumnCoding.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2370B11321914ED500D3227C /* NSData+WCTColumnCoding.mm */; };\n\t\t2370B12621914ED500D3227C /* WCTMaster.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2370B11421914ED500D3227C /* WCTMaster.mm */; };\n\t\t2370B12721914ED500D3227C /* NSData+WCTColumnCoding.h in Headers */ = {isa = PBXBuildFile; fileRef = 2370B11521914ED500D3227C /* NSData+WCTColumnCoding.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t2370B12921914ED500D3227C /* NSNull+WCTColumnCoding.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2370B11721914ED500D3227C /* NSNull+WCTColumnCoding.mm */; };\n\t\t2370B12A21914ED500D3227C /* NSNull+WCTColumnCoding.h in Headers */ = {isa = PBXBuildFile; fileRef = 2370B11821914ED500D3227C /* NSNull+WCTColumnCoding.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t2370B12B21914ED500D3227C /* NSString+WCTColumnCoding.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2370B11921914ED500D3227C /* NSString+WCTColumnCoding.mm */; };\n\t\t2370B1322191533C00D3227C /* WCTOptional.h in Headers */ = {isa = PBXBuildFile; fileRef = 2370B1302191533C00D3227C /* WCTOptional.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t2372E05921A2633800051D9A /* WCTTryDisposeGuard.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2372E05721A2633800051D9A /* WCTTryDisposeGuard.mm */; };\n\t\t2372E05A21A2633800051D9A /* WCTTryDisposeGuard.h in Headers */ = {isa = PBXBuildFile; fileRef = 2372E05821A2633800051D9A /* WCTTryDisposeGuard.h */; };\n\t\t23759461210081AA00DBB721 /* UnsafeData.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2375945F210081AA00DBB721 /* UnsafeData.cpp */; };\n\t\t23759463210081AA00DBB721 /* UnsafeData.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23759460210081AA00DBB721 /* UnsafeData.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t2376CB1B20DA5D3B00A68DB5 /* Scoreable.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2376CB1920DA5D3B00A68DB5 /* Scoreable.cpp */; };\n\t\t2376CB1D20DA5D3B00A68DB5 /* Scoreable.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 2376CB1A20DA5D3B00A68DB5 /* Scoreable.hpp */; };\n\t\t23775B6020AD666900E21AB0 /* Assertion.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23775B2F20AD666900E21AB0 /* Assertion.hpp */; };\n\t\t23775B6220AD666900E21AB0 /* WCDBError.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23775B3020AD666900E21AB0 /* WCDBError.cpp */; };\n\t\t23775B6420AD666900E21AB0 /* WCDBError.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23775B3120AD666900E21AB0 /* WCDBError.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t23775B6620AD666900E21AB0 /* Notifier.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23775B3220AD666900E21AB0 /* Notifier.cpp */; };\n\t\t23775B6820AD666900E21AB0 /* Notifier.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23775B3320AD666900E21AB0 /* Notifier.hpp */; };\n\t\t23775B6A20AD666900E21AB0 /* FullCrawler.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23775B3620AD666900E21AB0 /* FullCrawler.cpp */; };\n\t\t23775B6C20AD666900E21AB0 /* FullCrawler.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23775B3720AD666900E21AB0 /* FullCrawler.hpp */; };\n\t\t23775B7620AD666900E21AB0 /* Backup.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23775B3E20AD666900E21AB0 /* Backup.cpp */; };\n\t\t23775B7820AD666900E21AB0 /* Backup.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23775B3F20AD666900E21AB0 /* Backup.hpp */; };\n\t\t23775B7A20AD666900E21AB0 /* Material.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23775B4020AD666900E21AB0 /* Material.cpp */; };\n\t\t23775B7C20AD666900E21AB0 /* Material.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23775B4120AD666900E21AB0 /* Material.hpp */; };\n\t\t23775B7E20AD666900E21AB0 /* Mechanic.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23775B4220AD666900E21AB0 /* Mechanic.cpp */; };\n\t\t23775B8020AD666900E21AB0 /* Mechanic.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23775B4320AD666900E21AB0 /* Mechanic.hpp */; };\n\t\t23775B8220AD666900E21AB0 /* Cell.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23775B4520AD666900E21AB0 /* Cell.cpp */; };\n\t\t23775B8420AD666900E21AB0 /* Cell.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23775B4620AD666900E21AB0 /* Cell.hpp */; };\n\t\t23775B8620AD666900E21AB0 /* Page.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23775B4720AD666900E21AB0 /* Page.cpp */; };\n\t\t23775B8820AD666900E21AB0 /* Page.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23775B4820AD666900E21AB0 /* Page.hpp */; };\n\t\t23775B8A20AD666900E21AB0 /* Pager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23775B4920AD666900E21AB0 /* Pager.cpp */; };\n\t\t23775B8C20AD666900E21AB0 /* Pager.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23775B4A20AD666900E21AB0 /* Pager.hpp */; };\n\t\t23775B9620AD666900E21AB0 /* Crawlable.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23775B5020AD666900E21AB0 /* Crawlable.cpp */; };\n\t\t23775B9820AD666900E21AB0 /* Crawlable.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23775B5120AD666900E21AB0 /* Crawlable.hpp */; };\n\t\t23775BCD20AD72BC00E21AB0 /* Data.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23775BCB20AD72BC00E21AB0 /* Data.cpp */; };\n\t\t23775BCF20AD72BC00E21AB0 /* Data.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23775BCC20AD72BC00E21AB0 /* Data.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t23776CA4218C41DD00E985DC /* WCTChainCall.mm in Sources */ = {isa = PBXBuildFile; fileRef = 23776CA3218C41DD00E985DC /* WCTChainCall.mm */; };\n\t\t23776CA7218C41E600E985DC /* WCTChainCall+Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 23776CA5218C41E600E985DC /* WCTChainCall+Private.h */; };\n\t\t237908F721928C9F0098797F /* WCTObjCAccessor.mm in Sources */ = {isa = PBXBuildFile; fileRef = 237908F621928C9F0098797F /* WCTObjCAccessor.mm */; };\n\t\t23790A7F219315E50098797F /* WCTColumnConstraintMacro.h in Headers */ = {isa = PBXBuildFile; fileRef = 23790A7D219315D50098797F /* WCTColumnConstraintMacro.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t23790A80219315E50098797F /* WCTVirtualTableMacro.h in Headers */ = {isa = PBXBuildFile; fileRef = 23790A7E219315DE0098797F /* WCTVirtualTableMacro.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t237A65F520F731DF008B4771 /* UniqueList.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 237A65F220F731DF008B4771 /* UniqueList.hpp */; };\n\t\t237A8D5821ED88DF003AF5BB /* SQLiteDeclaration.h in Headers */ = {isa = PBXBuildFile; fileRef = 237A8D5721ED88DF003AF5BB /* SQLiteDeclaration.h */; };\n\t\t237A8D5F21EDBB2E003AF5BB /* BusyRetryConfig.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 237A8D5D21EDBB2E003AF5BB /* BusyRetryConfig.cpp */; };\n\t\t237A8D6021EDBB2E003AF5BB /* BusyRetryConfig.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 237A8D5E21EDBB2E003AF5BB /* BusyRetryConfig.hpp */; };\n\t\t237B47B021FEEA200059227A /* ColumnMeta.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 237B47AE21FEEA200059227A /* ColumnMeta.cpp */; };\n\t\t237B47B121FEEA200059227A /* ColumnMeta.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 237B47AF21FEEA200059227A /* ColumnMeta.hpp */; };\n\t\t237C900721D45E6700EE6E44 /* CoreConst.h in Headers */ = {isa = PBXBuildFile; fileRef = 237C900621D45E6700EE6E44 /* CoreConst.h */; };\n\t\t2386B3C51ED442FE000B72F6 /* WCTError.h in Headers */ = {isa = PBXBuildFile; fileRef = 2386B3C21ED442FE000B72F6 /* WCTError.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t2386B3C61ED442FE000B72F6 /* WCTError.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2386B3C31ED442FE000B72F6 /* WCTError.mm */; };\n\t\t2386B3C71ED442FE000B72F6 /* WCTError+Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 2386B3C41ED442FE000B72F6 /* WCTError+Private.h */; };\n\t\t238C177E21CA2190003B6D26 /* SyntaxCommonConst.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 238C177C21CA2190003B6D26 /* SyntaxCommonConst.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t23906AB9215E500100C2B717 /* WCTDatabase+Monitor.h in Headers */ = {isa = PBXBuildFile; fileRef = 23906AB7215E500100C2B717 /* WCTDatabase+Monitor.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t23906ABB215E500100C2B717 /* WCTDatabase+Monitor.mm in Sources */ = {isa = PBXBuildFile; fileRef = 23906AB8215E500100C2B717 /* WCTDatabase+Monitor.mm */; };\n\t\t2395582621C143BB000C85E1 /* WCTMigrationInfo+Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 2395582421C143BB000C85E1 /* WCTMigrationInfo+Private.h */; };\n\t\t2396EB0D21801BD60079066C /* WCTResultColumn.h in Headers */ = {isa = PBXBuildFile; fileRef = 2396EB0B21801BD60079066C /* WCTResultColumn.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t2396EB0E21801BD60079066C /* WCTResultColumn.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2396EB0C21801BD60079066C /* WCTResultColumn.mm */; };\n\t\t239776FA202AF2E3000A681C /* TimedQueue.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 239776CE202AF2E2000A681C /* TimedQueue.hpp */; };\n\t\t239776FE202AF2E3000A681C /* Macro.h in Headers */ = {isa = PBXBuildFile; fileRef = 239776D0202AF2E2000A681C /* Macro.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t23A3CFB5205FB1A800692F94 /* WCTHandle+Convenient.h in Headers */ = {isa = PBXBuildFile; fileRef = 23A3CFB3205FB1A800692F94 /* WCTHandle+Convenient.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t23A3CFB6205FB1A800692F94 /* WCTHandle+Convenient.mm in Sources */ = {isa = PBXBuildFile; fileRef = 23A3CFB4205FB1A800692F94 /* WCTHandle+Convenient.mm */; };\n\t\t23A64D09214A458A00ED28BB /* MigrationInfo.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23A64D07214A458A00ED28BB /* MigrationInfo.cpp */; };\n\t\t23A64D0B214A458A00ED28BB /* MigrationInfo.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23A64D08214A458A00ED28BB /* MigrationInfo.hpp */; };\n\t\t23A64D0F214A4A7000ED28BB /* Migration.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23A64D0D214A4A7000ED28BB /* Migration.cpp */; };\n\t\t23A64D11214A4A7000ED28BB /* Migration.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23A64D0E214A4A7000ED28BB /* Migration.hpp */; };\n\t\t23A6D4BF20BFD7F9004F2DAA /* Progress.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23A6D4BD20BFD7F9004F2DAA /* Progress.cpp */; };\n\t\t23A6D4C120BFD7F9004F2DAA /* Progress.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23A6D4BE20BFD7F9004F2DAA /* Progress.hpp */; };\n\t\t23AB898E215BA81300554DF1 /* SQLite.h in Headers */ = {isa = PBXBuildFile; fileRef = 23AB898D215BA6DB00554DF1 /* SQLite.h */; };\n\t\t23AD52D620DB4A3C00664B62 /* MasterItem.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23AD52D420DB4A3C00664B62 /* MasterItem.cpp */; };\n\t\t23AD52D820DB4A3C00664B62 /* MasterItem.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23AD52D520DB4A3C00664B62 /* MasterItem.hpp */; };\n\t\t23AD52DD20DB56D200664B62 /* SequenceItem.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23AD52DB20DB56D200664B62 /* SequenceItem.cpp */; };\n\t\t23AD52DF20DB56D200664B62 /* SequenceItem.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23AD52DC20DB56D200664B62 /* SequenceItem.hpp */; };\n\t\t23AD52E620DB852B00664B62 /* Fraction.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23AD52E420DB852B00664B62 /* Fraction.cpp */; };\n\t\t23AD52E820DB852B00664B62 /* Fraction.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23AD52E520DB852B00664B62 /* Fraction.hpp */; };\n\t\t23AD52F220DBAC4C00664B62 /* UpgradeableErrorProne.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23AD52F020DBAC4C00664B62 /* UpgradeableErrorProne.cpp */; };\n\t\t23AD52F420DBAC4C00664B62 /* UpgradeableErrorProne.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23AD52F120DBAC4C00664B62 /* UpgradeableErrorProne.hpp */; };\n\t\t23AF4E1E20CD04E20050033C /* Initializeable.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23AF4E1C20CD04E20050033C /* Initializeable.cpp */; };\n\t\t23AF4E2020CD04E20050033C /* Initializeable.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23AF4E1D20CD04E20050033C /* Initializeable.hpp */; };\n\t\t23B101E92090667E005D9DD3 /* WCTMacroUtility.h in Headers */ = {isa = PBXBuildFile; fileRef = 23B101E82090667B005D9DD3 /* WCTMacroUtility.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t23B35C7620BFE39500425033 /* Path.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23B35C7420BFE39400425033 /* Path.hpp */; };\n\t\t23B35C7820BFE39500425033 /* Path.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23B35C7520BFE39500425033 /* Path.cpp */; };\n\t\t23B4DC7E2111B39200954D71 /* Tag.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23B4DC7C2111B39100954D71 /* Tag.cpp */; };\n\t\t23B4DC802111B39200954D71 /* Tag.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23B4DC7D2111B39200954D71 /* Tag.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t23B4DCBD2112A9C800954D71 /* CommonCore.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23B4DCBB2112A9C800954D71 /* CommonCore.cpp */; };\n\t\t23B4DCDC2112AC5600954D71 /* TokenizerModuleTemplate.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23B4DCD92112AC5600954D71 /* TokenizerModuleTemplate.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t23B4DCE12112B03C00954D71 /* AsyncQueue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23B4DCDF2112B03C00954D71 /* AsyncQueue.cpp */; };\n\t\t23B4DCE32112B03C00954D71 /* AsyncQueue.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23B4DCE02112B03C00954D71 /* AsyncQueue.hpp */; };\n\t\t23B9E66B20AE6EEA00CF1683 /* RepairKit.h in Headers */ = {isa = PBXBuildFile; fileRef = 23B9E66920AE6EE400CF1683 /* RepairKit.h */; };\n\t\t23B9E67520AE733B00CF1683 /* FileManager.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23B9E67320AE733A00CF1683 /* FileManager.hpp */; };\n\t\t23B9E67720AE733B00CF1683 /* FileManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23B9E67420AE733A00CF1683 /* FileManager.cpp */; };\n\t\t23BBE2A8204955CE00C4CBB6 /* WCTCommon.h in Headers */ = {isa = PBXBuildFile; fileRef = 23BBE2A5204955CD00C4CBB6 /* WCTCommon.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t23BBE2AD2049565600C4CBB6 /* WCTDatabase+Config.h in Headers */ = {isa = PBXBuildFile; fileRef = 23BBE2AB2049565600C4CBB6 /* WCTDatabase+Config.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t23BBE2AE2049565600C4CBB6 /* WCTDatabase+Config.mm in Sources */ = {isa = PBXBuildFile; fileRef = 23BBE2AC2049565600C4CBB6 /* WCTDatabase+Config.mm */; };\n\t\t23BBE2B12049576D00C4CBB6 /* WCTDatabase+Memory.h in Headers */ = {isa = PBXBuildFile; fileRef = 23BBE2AF2049576D00C4CBB6 /* WCTDatabase+Memory.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t23BBE2B22049576D00C4CBB6 /* WCTDatabase+Memory.mm in Sources */ = {isa = PBXBuildFile; fileRef = 23BBE2B02049576D00C4CBB6 /* WCTDatabase+Memory.mm */; };\n\t\t23C7559120DCF90F00031A93 /* SQLiteLocker.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23C7558F20DCF90F00031A93 /* SQLiteLocker.cpp */; };\n\t\t23C7559320DCF90F00031A93 /* SQLiteLocker.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23C7559020DCF90F00031A93 /* SQLiteLocker.hpp */; };\n\t\t23C7559A20DD17B100031A93 /* SQLiteBase.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23C7559820DD17B100031A93 /* SQLiteBase.cpp */; };\n\t\t23C7559C20DD17B100031A93 /* SQLiteBase.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23C7559920DD17B100031A93 /* SQLiteBase.hpp */; };\n\t\t23D07CE420BE87360043F4D4 /* MasterCrawler.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23D07CE220BE87360043F4D4 /* MasterCrawler.cpp */; };\n\t\t23D07CE620BE87360043F4D4 /* MasterCrawler.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23D07CE320BE87360043F4D4 /* MasterCrawler.hpp */; };\n\t\t23D07CEA20BE873E0043F4D4 /* SequenceCrawler.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23D07CE820BE873E0043F4D4 /* SequenceCrawler.cpp */; };\n\t\t23D07CEC20BE873E0043F4D4 /* SequenceCrawler.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23D07CE920BE873E0043F4D4 /* SequenceCrawler.hpp */; };\n\t\t23D0C30E20C125420001BFAE /* SQLiteAssembler.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23D0C30C20C125420001BFAE /* SQLiteAssembler.cpp */; };\n\t\t23D0C31020C125420001BFAE /* SQLiteAssembler.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23D0C30D20C125420001BFAE /* SQLiteAssembler.hpp */; };\n\t\t23D0C35120C149D80001BFAE /* Factory.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23D0C34920C149D80001BFAE /* Factory.cpp */; };\n\t\t23D0C35320C149D80001BFAE /* Factory.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23D0C34A20C149D80001BFAE /* Factory.hpp */; };\n\t\t23D0C35520C149D80001BFAE /* FactoryDepositor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23D0C34B20C149D80001BFAE /* FactoryDepositor.cpp */; };\n\t\t23D0C35720C149D80001BFAE /* FactoryDepositor.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23D0C34C20C149D80001BFAE /* FactoryDepositor.hpp */; };\n\t\t23D0C35D20C149D80001BFAE /* FactoryRetriever.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23D0C34F20C149D80001BFAE /* FactoryRetriever.cpp */; };\n\t\t23D0C35F20C149D80001BFAE /* FactoryRetriever.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23D0C35020C149D80001BFAE /* FactoryRetriever.hpp */; };\n\t\t23D0C36320C14ACC0001BFAE /* FactoryRelated.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23D0C36120C14ACC0001BFAE /* FactoryRelated.cpp */; };\n\t\t23D0C36520C14ACC0001BFAE /* FactoryRelated.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23D0C36220C14ACC0001BFAE /* FactoryRelated.hpp */; };\n\t\t23D0C38D20C17CAE0001BFAE /* FactoryBackup.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23D0C38B20C17CAE0001BFAE /* FactoryBackup.cpp */; };\n\t\t23D0C38F20C17CAE0001BFAE /* FactoryBackup.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23D0C38C20C17CAE0001BFAE /* FactoryBackup.hpp */; };\n\t\t23D4DA452085A40A00AE6D90 /* Interface.h in Headers */ = {isa = PBXBuildFile; fileRef = 23D4DA442085A3D300AE6D90 /* Interface.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t23D96B922050DED700DB5E93 /* DatabasePool.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23D96B902050DED700DB5E93 /* DatabasePool.cpp */; };\n\t\t23D96B932050DED700DB5E93 /* DatabasePool.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23D96B912050DED700DB5E93 /* DatabasePool.hpp */; };\n\t\t23DD76BD20CF78C800E9B451 /* FactoryRenewer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23DD76BB20CF78C800E9B451 /* FactoryRenewer.cpp */; };\n\t\t23DD76BF20CF78C800E9B451 /* FactoryRenewer.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23DD76BC20CF78C800E9B451 /* FactoryRenewer.hpp */; };\n\t\t23DF0A0A2190275B00F0B2B6 /* WCTDatabase.mm in Sources */ = {isa = PBXBuildFile; fileRef = 23DF0A072190275B00F0B2B6 /* WCTDatabase.mm */; };\n\t\t23DF0A0B2190275B00F0B2B6 /* WCTDatabase.h in Headers */ = {isa = PBXBuildFile; fileRef = 23DF0A082190275B00F0B2B6 /* WCTDatabase.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t23DF0A0C2190275B00F0B2B6 /* WCTDatabase+Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 23DF0A092190275B00F0B2B6 /* WCTDatabase+Private.h */; };\n\t\t23DF0A0E219029DB00F0B2B6 /* WCTDeclaration.h in Headers */ = {isa = PBXBuildFile; fileRef = 23DF0A0D219028E900F0B2B6 /* WCTDeclaration.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t23E163D320FDDD8500C3F910 /* PorterStemming.c in Sources */ = {isa = PBXBuildFile; fileRef = 23E163D120FDDD8500C3F910 /* PorterStemming.c */; };\n\t\t23E7EB1D2123D58D0056B5D8 /* HighWater.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23E7EB1B2123D58D0056B5D8 /* HighWater.cpp */; };\n\t\t23E7EB1F2123D58D0056B5D8 /* HighWater.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23E7EB1C2123D58D0056B5D8 /* HighWater.hpp */; };\n\t\t23EABBE6206D08EC00241F3B /* WCTHandle+Table.h in Headers */ = {isa = PBXBuildFile; fileRef = 23EABBE4206D08EC00241F3B /* WCTHandle+Table.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t23EABBE7206D08EC00241F3B /* WCTHandle+Table.mm in Sources */ = {isa = PBXBuildFile; fileRef = 23EABBE5206D08EC00241F3B /* WCTHandle+Table.mm */; };\n\t\t23EB91DE20CA1EBE00ECF668 /* Wal.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EB91DC20CA1EBE00ECF668 /* Wal.cpp */; };\n\t\t23EB91E020CA1EBE00ECF668 /* Wal.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EB91DD20CA1EBE00ECF668 /* Wal.hpp */; };\n\t\t23EE0EB220B838E100C95998 /* Repairman.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EE0EB020B838E100C95998 /* Repairman.cpp */; };\n\t\t23EE0EB420B838E100C95998 /* Repairman.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EE0EB120B838E100C95998 /* Repairman.hpp */; };\n\t\t23EEDC66217DFADC006E9E73 /* AggregateFunction.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDB68217DFADC006E9E73 /* AggregateFunction.cpp */; };\n\t\t23EEDC67217DFADC006E9E73 /* AggregateFunction.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDB69217DFADC006E9E73 /* AggregateFunction.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t23EEDC68217DFADC006E9E73 /* ColumnType.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDB6A217DFADC006E9E73 /* ColumnType.cpp */; };\n\t\t23EEDC69217DFADC006E9E73 /* ColumnType.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDB6B217DFADC006E9E73 /* ColumnType.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t23EEDC6A217DFADC006E9E73 /* Convertible.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDB6C217DFADC006E9E73 /* Convertible.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t23EEDC6B217DFADC006E9E73 /* ConvertibleImplementation.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDB6D217DFADC006E9E73 /* ConvertibleImplementation.cpp */; };\n\t\t23EEDC6C217DFADC006E9E73 /* ConvertibleImplementation.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDB6E217DFADC006E9E73 /* ConvertibleImplementation.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t23EEDC6D217DFADC006E9E73 /* CoreFunction.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDB6F217DFADC006E9E73 /* CoreFunction.cpp */; };\n\t\t23EEDC6E217DFADC006E9E73 /* CoreFunction.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDB70217DFADC006E9E73 /* CoreFunction.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t23EEDC6F217DFADC006E9E73 /* ExpressionOperable.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDB71217DFADC006E9E73 /* ExpressionOperable.cpp */; };\n\t\t23EEDC70217DFADC006E9E73 /* ExpressionOperable.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDB72217DFADC006E9E73 /* ExpressionOperable.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t23EEDC71217DFADC006E9E73 /* FTSFunction.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDB73217DFADC006E9E73 /* FTSFunction.cpp */; };\n\t\t23EEDC72217DFADC006E9E73 /* FTSFunction.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDB74217DFADC006E9E73 /* FTSFunction.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t23EEDC73217DFADC006E9E73 /* SyntaxForwardDeclaration.h in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDB75217DFADC006E9E73 /* SyntaxForwardDeclaration.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t23EEDC74217DFADC006E9E73 /* SyntaxList.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDB76217DFADC006E9E73 /* SyntaxList.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t23EEDC77217DFADC006E9E73 /* BindParameter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDB7A217DFADC006E9E73 /* BindParameter.cpp */; };\n\t\t23EEDC78217DFADC006E9E73 /* BindParameter.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDB7B217DFADC006E9E73 /* BindParameter.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t23EEDC79217DFADC006E9E73 /* Column.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDB7C217DFADC006E9E73 /* Column.cpp */; };\n\t\t23EEDC7A217DFADC006E9E73 /* Column.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDB7D217DFADC006E9E73 /* Column.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t23EEDC7B217DFADC006E9E73 /* ColumnConstraint.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDB7E217DFADC006E9E73 /* ColumnConstraint.cpp */; };\n\t\t23EEDC7C217DFADC006E9E73 /* ColumnConstraint.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDB7F217DFADC006E9E73 /* ColumnConstraint.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t23EEDC7D217DFADC006E9E73 /* ColumnDef.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDB80217DFADC006E9E73 /* ColumnDef.cpp */; };\n\t\t23EEDC7E217DFADC006E9E73 /* ColumnDef.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDB81217DFADC006E9E73 /* ColumnDef.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t23EEDC7F217DFADC006E9E73 /* CommonTableExpression.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDB82217DFADC006E9E73 /* CommonTableExpression.cpp */; };\n\t\t23EEDC80217DFADC006E9E73 /* CommonTableExpression.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDB83217DFADC006E9E73 /* CommonTableExpression.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t23EEDC83217DFADC006E9E73 /* Expression.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDB86217DFADC006E9E73 /* Expression.cpp */; };\n\t\t23EEDC84217DFADC006E9E73 /* Expression.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDB87217DFADC006E9E73 /* Expression.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t23EEDC85217DFADC006E9E73 /* Filter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDB88217DFADC006E9E73 /* Filter.cpp */; };\n\t\t23EEDC86217DFADC006E9E73 /* Filter.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDB89217DFADC006E9E73 /* Filter.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t23EEDC87217DFADC006E9E73 /* ForeignKey.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDB8A217DFADC006E9E73 /* ForeignKey.cpp */; };\n\t\t23EEDC88217DFADC006E9E73 /* ForeignKey.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDB8B217DFADC006E9E73 /* ForeignKey.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t23EEDC89217DFADC006E9E73 /* FrameSpec.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDB8C217DFADC006E9E73 /* FrameSpec.cpp */; };\n\t\t23EEDC8A217DFADC006E9E73 /* FrameSpec.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDB8D217DFADC006E9E73 /* FrameSpec.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t23EEDC8D217DFADC006E9E73 /* IndexedColumn.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDB90217DFADC006E9E73 /* IndexedColumn.cpp */; };\n\t\t23EEDC8E217DFADC006E9E73 /* IndexedColumn.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDB91217DFADC006E9E73 /* IndexedColumn.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t23EEDC8F217DFADC006E9E73 /* Join.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDB92217DFADC006E9E73 /* Join.cpp */; };\n\t\t23EEDC90217DFADC006E9E73 /* Join.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDB93217DFADC006E9E73 /* Join.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t23EEDC91217DFADC006E9E73 /* JoinConstraint.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDB94217DFADC006E9E73 /* JoinConstraint.cpp */; };\n\t\t23EEDC92217DFADC006E9E73 /* JoinConstraint.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDB95217DFADC006E9E73 /* JoinConstraint.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t23EEDC93217DFADC006E9E73 /* LiteralValue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDB96217DFADC006E9E73 /* LiteralValue.cpp */; };\n\t\t23EEDC94217DFADC006E9E73 /* LiteralValue.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDB97217DFADC006E9E73 /* LiteralValue.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t23EEDC97217DFADC006E9E73 /* OrderingTerm.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDB9A217DFADC006E9E73 /* OrderingTerm.cpp */; };\n\t\t23EEDC98217DFADC006E9E73 /* OrderingTerm.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDB9B217DFADC006E9E73 /* OrderingTerm.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t23EEDC99217DFADC006E9E73 /* Pragma.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDB9C217DFADC006E9E73 /* Pragma.cpp */; };\n\t\t23EEDC9A217DFADC006E9E73 /* Pragma.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDB9D217DFADC006E9E73 /* Pragma.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t23EEDC9B217DFADC006E9E73 /* QualifiedTable.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDB9E217DFADC006E9E73 /* QualifiedTable.cpp */; };\n\t\t23EEDC9C217DFADC006E9E73 /* QualifiedTable.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDB9F217DFADC006E9E73 /* QualifiedTable.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t23EEDC9D217DFADC006E9E73 /* RaiseFunction.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDBA0217DFADC006E9E73 /* RaiseFunction.cpp */; };\n\t\t23EEDC9E217DFADC006E9E73 /* RaiseFunction.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDBA1217DFADC006E9E73 /* RaiseFunction.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t23EEDCA1217DFADC006E9E73 /* ResultColumn.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDBA4217DFADC006E9E73 /* ResultColumn.cpp */; };\n\t\t23EEDCA2217DFADC006E9E73 /* ResultColumn.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDBA5217DFADC006E9E73 /* ResultColumn.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t23EEDCA3217DFADC006E9E73 /* Schema.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDBA6217DFADC006E9E73 /* Schema.cpp */; };\n\t\t23EEDCA4217DFADC006E9E73 /* Schema.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDBA7217DFADC006E9E73 /* Schema.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t23EEDCA5217DFADC006E9E73 /* SQL.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDBA8217DFADC006E9E73 /* SQL.cpp */; };\n\t\t23EEDCA6217DFADC006E9E73 /* SQL.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDBA9217DFADC006E9E73 /* SQL.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t23EEDCA7217DFADC006E9E73 /* TableConstraint.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDBAA217DFADC006E9E73 /* TableConstraint.cpp */; };\n\t\t23EEDCA8217DFADC006E9E73 /* TableConstraint.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDBAB217DFADC006E9E73 /* TableConstraint.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t23EEDCA9217DFADC006E9E73 /* TableOrSubquery.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDBAC217DFADC006E9E73 /* TableOrSubquery.cpp */; };\n\t\t23EEDCAA217DFADC006E9E73 /* TableOrSubquery.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDBAD217DFADC006E9E73 /* TableOrSubquery.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t23EEDCAB217DFADC006E9E73 /* Upsert.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDBAE217DFADC006E9E73 /* Upsert.cpp */; };\n\t\t23EEDCAC217DFADC006E9E73 /* Upsert.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDBAF217DFADC006E9E73 /* Upsert.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t23EEDCAD217DFADC006E9E73 /* WindowDef.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDBB0217DFADC006E9E73 /* WindowDef.cpp */; };\n\t\t23EEDCAE217DFADC006E9E73 /* WindowDef.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDBB1217DFADC006E9E73 /* WindowDef.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t23EEDCB4217DFADC006E9E73 /* Statement.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDBB8217DFADC006E9E73 /* Statement.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t23EEDCB5217DFADC006E9E73 /* StatementAlterTable.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDBB9217DFADC006E9E73 /* StatementAlterTable.cpp */; };\n\t\t23EEDCB6217DFADC006E9E73 /* StatementAlterTable.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDBBA217DFADC006E9E73 /* StatementAlterTable.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t23EEDCB7217DFADC006E9E73 /* StatementAnalyze.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDBBB217DFADC006E9E73 /* StatementAnalyze.cpp */; };\n\t\t23EEDCB8217DFADC006E9E73 /* StatementAnalyze.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDBBC217DFADC006E9E73 /* StatementAnalyze.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t23EEDCB9217DFADC006E9E73 /* StatementAttach.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDBBD217DFADC006E9E73 /* StatementAttach.cpp */; };\n\t\t23EEDCBA217DFADC006E9E73 /* StatementAttach.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDBBE217DFADC006E9E73 /* StatementAttach.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t23EEDCBB217DFADC006E9E73 /* StatementBegin.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDBBF217DFADC006E9E73 /* StatementBegin.cpp */; };\n\t\t23EEDCBC217DFADC006E9E73 /* StatementBegin.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDBC0217DFADC006E9E73 /* StatementBegin.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t23EEDCBD217DFADC006E9E73 /* StatementCommit.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDBC1217DFADC006E9E73 /* StatementCommit.cpp */; };\n\t\t23EEDCBE217DFADC006E9E73 /* StatementCommit.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDBC2217DFADC006E9E73 /* StatementCommit.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t23EEDCBF217DFADC006E9E73 /* StatementCreateIndex.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDBC3217DFADC006E9E73 /* StatementCreateIndex.cpp */; };\n\t\t23EEDCC0217DFADC006E9E73 /* StatementCreateIndex.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDBC4217DFADC006E9E73 /* StatementCreateIndex.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t23EEDCC1217DFADC006E9E73 /* StatementCreateTable.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDBC5217DFADC006E9E73 /* StatementCreateTable.cpp */; };\n\t\t23EEDCC2217DFADC006E9E73 /* StatementCreateTable.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDBC6217DFADC006E9E73 /* StatementCreateTable.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t23EEDCC3217DFADC006E9E73 /* StatementCreateTrigger.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDBC7217DFADC006E9E73 /* StatementCreateTrigger.cpp */; };\n\t\t23EEDCC4217DFADC006E9E73 /* StatementCreateTrigger.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDBC8217DFADC006E9E73 /* StatementCreateTrigger.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t23EEDCC5217DFADC006E9E73 /* StatementCreateView.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDBC9217DFADC006E9E73 /* StatementCreateView.cpp */; };\n\t\t23EEDCC6217DFADC006E9E73 /* StatementCreateView.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDBCA217DFADC006E9E73 /* StatementCreateView.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t23EEDCC7217DFADC006E9E73 /* StatementCreateVirtualTable.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDBCB217DFADC006E9E73 /* StatementCreateVirtualTable.cpp */; };\n\t\t23EEDCC8217DFADC006E9E73 /* StatementCreateVirtualTable.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDBCC217DFADC006E9E73 /* StatementCreateVirtualTable.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t23EEDCC9217DFADC006E9E73 /* StatementDelete.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDBCD217DFADC006E9E73 /* StatementDelete.cpp */; };\n\t\t23EEDCCA217DFADC006E9E73 /* StatementDelete.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDBCE217DFADC006E9E73 /* StatementDelete.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t23EEDCCB217DFADC006E9E73 /* StatementDetach.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDBCF217DFADC006E9E73 /* StatementDetach.cpp */; };\n\t\t23EEDCCC217DFADC006E9E73 /* StatementDetach.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDBD0217DFADC006E9E73 /* StatementDetach.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t23EEDCCD217DFADC006E9E73 /* StatementDropIndex.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDBD1217DFADC006E9E73 /* StatementDropIndex.cpp */; };\n\t\t23EEDCCE217DFADC006E9E73 /* StatementDropIndex.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDBD2217DFADC006E9E73 /* StatementDropIndex.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t23EEDCCF217DFADC006E9E73 /* StatementDropTable.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDBD3217DFADC006E9E73 /* StatementDropTable.cpp */; };\n\t\t23EEDCD0217DFADC006E9E73 /* StatementDropTable.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDBD4217DFADC006E9E73 /* StatementDropTable.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t23EEDCD1217DFADC006E9E73 /* StatementDropTrigger.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDBD5217DFADC006E9E73 /* StatementDropTrigger.cpp */; };\n\t\t23EEDCD2217DFADC006E9E73 /* StatementDropTrigger.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDBD6217DFADC006E9E73 /* StatementDropTrigger.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t23EEDCD3217DFADC006E9E73 /* StatementDropView.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDBD7217DFADC006E9E73 /* StatementDropView.cpp */; };\n\t\t23EEDCD4217DFADC006E9E73 /* StatementDropView.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDBD8217DFADC006E9E73 /* StatementDropView.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t23EEDCD5217DFADC006E9E73 /* StatementInsert.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDBD9217DFADC006E9E73 /* StatementInsert.cpp */; };\n\t\t23EEDCD6217DFADC006E9E73 /* StatementInsert.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDBDA217DFADC006E9E73 /* StatementInsert.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t23EEDCD7217DFADC006E9E73 /* StatementPragma.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDBDB217DFADC006E9E73 /* StatementPragma.cpp */; };\n\t\t23EEDCD8217DFADC006E9E73 /* StatementPragma.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDBDC217DFADC006E9E73 /* StatementPragma.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t23EEDCD9217DFADC006E9E73 /* StatementReindex.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDBDD217DFADC006E9E73 /* StatementReindex.cpp */; };\n\t\t23EEDCDA217DFADC006E9E73 /* StatementReindex.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDBDE217DFADC006E9E73 /* StatementReindex.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t23EEDCDB217DFADC006E9E73 /* StatementRelease.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDBDF217DFADC006E9E73 /* StatementRelease.cpp */; };\n\t\t23EEDCDC217DFADC006E9E73 /* StatementRelease.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDBE0217DFADC006E9E73 /* StatementRelease.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t23EEDCDD217DFADC006E9E73 /* StatementRollback.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDBE1217DFADC006E9E73 /* StatementRollback.cpp */; };\n\t\t23EEDCDE217DFADC006E9E73 /* StatementRollback.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDBE2217DFADC006E9E73 /* StatementRollback.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t23EEDCDF217DFADC006E9E73 /* StatementSavepoint.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDBE3217DFADC006E9E73 /* StatementSavepoint.cpp */; };\n\t\t23EEDCE0217DFADC006E9E73 /* StatementSavepoint.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDBE4217DFADC006E9E73 /* StatementSavepoint.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t23EEDCE1217DFADC006E9E73 /* StatementSelect.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDBE5217DFADC006E9E73 /* StatementSelect.cpp */; };\n\t\t23EEDCE2217DFADC006E9E73 /* StatementSelect.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDBE6217DFADC006E9E73 /* StatementSelect.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t23EEDCE3217DFADC006E9E73 /* StatementUpdate.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDBE7217DFADC006E9E73 /* StatementUpdate.cpp */; };\n\t\t23EEDCE4217DFADC006E9E73 /* StatementUpdate.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDBE8217DFADC006E9E73 /* StatementUpdate.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t23EEDCE5217DFADC006E9E73 /* StatementVacuum.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDBE9217DFADC006E9E73 /* StatementVacuum.cpp */; };\n\t\t23EEDCE6217DFADC006E9E73 /* StatementVacuum.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDBEA217DFADC006E9E73 /* StatementVacuum.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t23EEDCE7217DFADC006E9E73 /* WINQ.h in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDBEB217DFADC006E9E73 /* WINQ.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t23EEDCED217DFADC006E9E73 /* SyntaxBindParameter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDBF4217DFADC006E9E73 /* SyntaxBindParameter.cpp */; };\n\t\t23EEDCEE217DFADC006E9E73 /* SyntaxBindParameter.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDBF5217DFADC006E9E73 /* SyntaxBindParameter.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t23EEDCEF217DFADC006E9E73 /* SyntaxColumn.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDBF6217DFADC006E9E73 /* SyntaxColumn.cpp */; };\n\t\t23EEDCF0217DFADC006E9E73 /* SyntaxColumn.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDBF7217DFADC006E9E73 /* SyntaxColumn.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t23EEDCF1217DFADC006E9E73 /* SyntaxColumnConstraint.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDBF8217DFADC006E9E73 /* SyntaxColumnConstraint.cpp */; };\n\t\t23EEDCF2217DFADC006E9E73 /* SyntaxColumnConstraint.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDBF9217DFADC006E9E73 /* SyntaxColumnConstraint.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t23EEDCF3217DFADC006E9E73 /* SyntaxColumnDef.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDBFA217DFADC006E9E73 /* SyntaxColumnDef.cpp */; };\n\t\t23EEDCF4217DFADC006E9E73 /* SyntaxColumnDef.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDBFB217DFADC006E9E73 /* SyntaxColumnDef.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t23EEDCF5217DFADC006E9E73 /* SyntaxCommonTableExpression.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDBFC217DFADC006E9E73 /* SyntaxCommonTableExpression.cpp */; };\n\t\t23EEDCF6217DFADC006E9E73 /* SyntaxCommonTableExpression.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDBFD217DFADC006E9E73 /* SyntaxCommonTableExpression.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t23EEDCF9217DFADC006E9E73 /* SyntaxExpression.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDC00217DFADC006E9E73 /* SyntaxExpression.cpp */; };\n\t\t23EEDCFA217DFADC006E9E73 /* SyntaxExpression.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDC01217DFADC006E9E73 /* SyntaxExpression.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t23EEDCFB217DFADC006E9E73 /* SyntaxFilter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDC02217DFADC006E9E73 /* SyntaxFilter.cpp */; };\n\t\t23EEDCFC217DFADC006E9E73 /* SyntaxFilter.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDC03217DFADC006E9E73 /* SyntaxFilter.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t23EEDCFD217DFADC006E9E73 /* SyntaxForeignKeyClause.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDC04217DFADC006E9E73 /* SyntaxForeignKeyClause.cpp */; };\n\t\t23EEDCFE217DFADC006E9E73 /* SyntaxForeignKeyClause.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDC05217DFADC006E9E73 /* SyntaxForeignKeyClause.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t23EEDCFF217DFADC006E9E73 /* SyntaxFrameSpec.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDC06217DFADC006E9E73 /* SyntaxFrameSpec.cpp */; };\n\t\t23EEDD00217DFADC006E9E73 /* SyntaxFrameSpec.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDC07217DFADC006E9E73 /* SyntaxFrameSpec.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t23EEDD03217DFADC006E9E73 /* SyntaxIdentifier.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDC0A217DFADC006E9E73 /* SyntaxIdentifier.cpp */; };\n\t\t23EEDD04217DFADC006E9E73 /* SyntaxIdentifier.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDC0B217DFADC006E9E73 /* SyntaxIdentifier.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t23EEDD05217DFADC006E9E73 /* SyntaxIndexedColumn.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDC0C217DFADC006E9E73 /* SyntaxIndexedColumn.cpp */; };\n\t\t23EEDD06217DFADC006E9E73 /* SyntaxIndexedColumn.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDC0D217DFADC006E9E73 /* SyntaxIndexedColumn.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t23EEDD07217DFADC006E9E73 /* SyntaxJoinClause.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDC0E217DFADC006E9E73 /* SyntaxJoinClause.cpp */; };\n\t\t23EEDD08217DFADC006E9E73 /* SyntaxJoinClause.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDC0F217DFADC006E9E73 /* SyntaxJoinClause.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t23EEDD09217DFADC006E9E73 /* SyntaxJoinConstraint.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDC10217DFADC006E9E73 /* SyntaxJoinConstraint.cpp */; };\n\t\t23EEDD0A217DFADC006E9E73 /* SyntaxJoinConstraint.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDC11217DFADC006E9E73 /* SyntaxJoinConstraint.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t23EEDD0B217DFADC006E9E73 /* SyntaxLiteralValue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDC12217DFADC006E9E73 /* SyntaxLiteralValue.cpp */; };\n\t\t23EEDD0C217DFADC006E9E73 /* SyntaxLiteralValue.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDC13217DFADC006E9E73 /* SyntaxLiteralValue.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t23EEDD0F217DFADC006E9E73 /* SyntaxOrderingTerm.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDC16217DFADC006E9E73 /* SyntaxOrderingTerm.cpp */; };\n\t\t23EEDD10217DFADC006E9E73 /* SyntaxOrderingTerm.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDC17217DFADC006E9E73 /* SyntaxOrderingTerm.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t23EEDD11217DFADC006E9E73 /* SyntaxPragma.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDC18217DFADC006E9E73 /* SyntaxPragma.cpp */; };\n\t\t23EEDD12217DFADC006E9E73 /* SyntaxPragma.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDC19217DFADC006E9E73 /* SyntaxPragma.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t23EEDD13217DFADC006E9E73 /* SyntaxQualifiedTableName.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDC1A217DFADC006E9E73 /* SyntaxQualifiedTableName.cpp */; };\n\t\t23EEDD14217DFADC006E9E73 /* SyntaxQualifiedTableName.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDC1B217DFADC006E9E73 /* SyntaxQualifiedTableName.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t23EEDD15217DFADC006E9E73 /* SyntaxRaiseFunction.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDC1C217DFADC006E9E73 /* SyntaxRaiseFunction.cpp */; };\n\t\t23EEDD16217DFADC006E9E73 /* SyntaxRaiseFunction.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDC1D217DFADC006E9E73 /* SyntaxRaiseFunction.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t23EEDD19217DFADC006E9E73 /* SyntaxResultColumn.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDC20217DFADC006E9E73 /* SyntaxResultColumn.cpp */; };\n\t\t23EEDD1A217DFADC006E9E73 /* SyntaxResultColumn.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDC21217DFADC006E9E73 /* SyntaxResultColumn.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t23EEDD1B217DFADC006E9E73 /* SyntaxSchema.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDC22217DFADC006E9E73 /* SyntaxSchema.cpp */; };\n\t\t23EEDD1C217DFADC006E9E73 /* SyntaxSchema.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDC23217DFADC006E9E73 /* SyntaxSchema.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t23EEDD1D217DFADC006E9E73 /* SyntaxSelectCore.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDC24217DFADC006E9E73 /* SyntaxSelectCore.cpp */; };\n\t\t23EEDD1E217DFADC006E9E73 /* SyntaxSelectCore.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDC25217DFADC006E9E73 /* SyntaxSelectCore.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t23EEDD1F217DFADC006E9E73 /* SyntaxTableConstraint.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDC26217DFADC006E9E73 /* SyntaxTableConstraint.cpp */; };\n\t\t23EEDD20217DFADC006E9E73 /* SyntaxTableConstraint.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDC27217DFADC006E9E73 /* SyntaxTableConstraint.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t23EEDD21217DFADC006E9E73 /* SyntaxTableOrSubquery.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDC28217DFADC006E9E73 /* SyntaxTableOrSubquery.cpp */; };\n\t\t23EEDD22217DFADC006E9E73 /* SyntaxTableOrSubquery.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDC29217DFADC006E9E73 /* SyntaxTableOrSubquery.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t23EEDD23217DFADC006E9E73 /* SyntaxUpsertClause.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDC2A217DFADC006E9E73 /* SyntaxUpsertClause.cpp */; };\n\t\t23EEDD24217DFADC006E9E73 /* SyntaxUpsertClause.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDC2B217DFADC006E9E73 /* SyntaxUpsertClause.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t23EEDD25217DFADC006E9E73 /* SyntaxWindowDef.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDC2C217DFADC006E9E73 /* SyntaxWindowDef.cpp */; };\n\t\t23EEDD26217DFADC006E9E73 /* SyntaxWindowDef.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDC2D217DFADC006E9E73 /* SyntaxWindowDef.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t23EEDD29217DFADC006E9E73 /* SyntaxAlterTableSTMT.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDC31217DFADC006E9E73 /* SyntaxAlterTableSTMT.cpp */; };\n\t\t23EEDD2A217DFADC006E9E73 /* SyntaxAlterTableSTMT.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDC32217DFADC006E9E73 /* SyntaxAlterTableSTMT.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t23EEDD2B217DFADC006E9E73 /* SyntaxAnalyzeSTMT.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDC33217DFADC006E9E73 /* SyntaxAnalyzeSTMT.cpp */; };\n\t\t23EEDD2C217DFADC006E9E73 /* SyntaxAnalyzeSTMT.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDC34217DFADC006E9E73 /* SyntaxAnalyzeSTMT.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t23EEDD2D217DFADC006E9E73 /* SyntaxAttachSTMT.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDC35217DFADC006E9E73 /* SyntaxAttachSTMT.cpp */; };\n\t\t23EEDD2E217DFADC006E9E73 /* SyntaxAttachSTMT.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDC36217DFADC006E9E73 /* SyntaxAttachSTMT.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t23EEDD2F217DFADC006E9E73 /* SyntaxBeginSTMT.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDC37217DFADC006E9E73 /* SyntaxBeginSTMT.cpp */; };\n\t\t23EEDD30217DFADC006E9E73 /* SyntaxBeginSTMT.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDC38217DFADC006E9E73 /* SyntaxBeginSTMT.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t23EEDD31217DFADC006E9E73 /* SyntaxCommitSTMT.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDC39217DFADC006E9E73 /* SyntaxCommitSTMT.cpp */; };\n\t\t23EEDD32217DFADC006E9E73 /* SyntaxCommitSTMT.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDC3A217DFADC006E9E73 /* SyntaxCommitSTMT.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t23EEDD33217DFADC006E9E73 /* SyntaxCreateIndexSTMT.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDC3B217DFADC006E9E73 /* SyntaxCreateIndexSTMT.cpp */; };\n\t\t23EEDD34217DFADC006E9E73 /* SyntaxCreateIndexSTMT.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDC3C217DFADC006E9E73 /* SyntaxCreateIndexSTMT.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t23EEDD35217DFADC006E9E73 /* SyntaxCreateTableSTMT.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDC3D217DFADC006E9E73 /* SyntaxCreateTableSTMT.cpp */; };\n\t\t23EEDD36217DFADC006E9E73 /* SyntaxCreateTableSTMT.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDC3E217DFADC006E9E73 /* SyntaxCreateTableSTMT.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t23EEDD37217DFADC006E9E73 /* SyntaxCreateTriggerSTMT.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDC3F217DFADC006E9E73 /* SyntaxCreateTriggerSTMT.cpp */; };\n\t\t23EEDD38217DFADC006E9E73 /* SyntaxCreateTriggerSTMT.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDC40217DFADC006E9E73 /* SyntaxCreateTriggerSTMT.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t23EEDD39217DFADC006E9E73 /* SyntaxCreateViewSTMT.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDC41217DFADC006E9E73 /* SyntaxCreateViewSTMT.cpp */; };\n\t\t23EEDD3A217DFADC006E9E73 /* SyntaxCreateViewSTMT.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDC42217DFADC006E9E73 /* SyntaxCreateViewSTMT.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t23EEDD3B217DFADC006E9E73 /* SyntaxCreateVirtualTableSTMT.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDC43217DFADC006E9E73 /* SyntaxCreateVirtualTableSTMT.cpp */; };\n\t\t23EEDD3C217DFADC006E9E73 /* SyntaxCreateVirtualTableSTMT.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDC44217DFADC006E9E73 /* SyntaxCreateVirtualTableSTMT.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t23EEDD3D217DFADC006E9E73 /* SyntaxDeleteSTMT.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDC45217DFADC006E9E73 /* SyntaxDeleteSTMT.cpp */; };\n\t\t23EEDD3E217DFADC006E9E73 /* SyntaxDeleteSTMT.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDC46217DFADC006E9E73 /* SyntaxDeleteSTMT.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t23EEDD3F217DFADC006E9E73 /* SyntaxDetachSTMT.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDC47217DFADC006E9E73 /* SyntaxDetachSTMT.cpp */; };\n\t\t23EEDD40217DFADC006E9E73 /* SyntaxDetachSTMT.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDC48217DFADC006E9E73 /* SyntaxDetachSTMT.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t23EEDD41217DFADC006E9E73 /* SyntaxDropIndexSTMT.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDC49217DFADC006E9E73 /* SyntaxDropIndexSTMT.cpp */; };\n\t\t23EEDD42217DFADC006E9E73 /* SyntaxDropIndexSTMT.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDC4A217DFADC006E9E73 /* SyntaxDropIndexSTMT.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t23EEDD43217DFADC006E9E73 /* SyntaxDropTableSTMT.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDC4B217DFADC006E9E73 /* SyntaxDropTableSTMT.cpp */; };\n\t\t23EEDD44217DFADC006E9E73 /* SyntaxDropTableSTMT.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDC4C217DFADC006E9E73 /* SyntaxDropTableSTMT.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t23EEDD45217DFADC006E9E73 /* SyntaxDropTriggerSTMT.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDC4D217DFADC006E9E73 /* SyntaxDropTriggerSTMT.cpp */; };\n\t\t23EEDD46217DFADC006E9E73 /* SyntaxDropTriggerSTMT.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDC4E217DFADC006E9E73 /* SyntaxDropTriggerSTMT.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t23EEDD47217DFADC006E9E73 /* SyntaxDropViewSTMT.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDC4F217DFADC006E9E73 /* SyntaxDropViewSTMT.cpp */; };\n\t\t23EEDD48217DFADC006E9E73 /* SyntaxDropViewSTMT.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDC50217DFADC006E9E73 /* SyntaxDropViewSTMT.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t23EEDD49217DFADC006E9E73 /* SyntaxInsertSTMT.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDC51217DFADC006E9E73 /* SyntaxInsertSTMT.cpp */; };\n\t\t23EEDD4A217DFADC006E9E73 /* SyntaxInsertSTMT.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDC52217DFADC006E9E73 /* SyntaxInsertSTMT.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t23EEDD4B217DFADC006E9E73 /* SyntaxPragmaSTMT.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDC53217DFADC006E9E73 /* SyntaxPragmaSTMT.cpp */; };\n\t\t23EEDD4C217DFADC006E9E73 /* SyntaxPragmaSTMT.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDC54217DFADC006E9E73 /* SyntaxPragmaSTMT.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t23EEDD4D217DFADC006E9E73 /* SyntaxReindexSTMT.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDC55217DFADC006E9E73 /* SyntaxReindexSTMT.cpp */; };\n\t\t23EEDD4E217DFADC006E9E73 /* SyntaxReindexSTMT.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDC56217DFADC006E9E73 /* SyntaxReindexSTMT.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t23EEDD4F217DFADC006E9E73 /* SyntaxReleaseSTMT.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDC57217DFADC006E9E73 /* SyntaxReleaseSTMT.cpp */; };\n\t\t23EEDD50217DFADC006E9E73 /* SyntaxReleaseSTMT.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDC58217DFADC006E9E73 /* SyntaxReleaseSTMT.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t23EEDD51217DFADC006E9E73 /* SyntaxRollbackSTMT.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDC59217DFADC006E9E73 /* SyntaxRollbackSTMT.cpp */; };\n\t\t23EEDD52217DFADC006E9E73 /* SyntaxRollbackSTMT.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDC5A217DFADC006E9E73 /* SyntaxRollbackSTMT.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t23EEDD53217DFADC006E9E73 /* SyntaxSavepointSTMT.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDC5B217DFADC006E9E73 /* SyntaxSavepointSTMT.cpp */; };\n\t\t23EEDD54217DFADC006E9E73 /* SyntaxSavepointSTMT.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDC5C217DFADC006E9E73 /* SyntaxSavepointSTMT.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t23EEDD55217DFADC006E9E73 /* SyntaxSelectSTMT.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDC5D217DFADC006E9E73 /* SyntaxSelectSTMT.cpp */; };\n\t\t23EEDD56217DFADC006E9E73 /* SyntaxSelectSTMT.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDC5E217DFADC006E9E73 /* SyntaxSelectSTMT.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t23EEDD57217DFADC006E9E73 /* SyntaxUpdateSTMT.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDC5F217DFADC006E9E73 /* SyntaxUpdateSTMT.cpp */; };\n\t\t23EEDD58217DFADC006E9E73 /* SyntaxUpdateSTMT.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDC60217DFADC006E9E73 /* SyntaxUpdateSTMT.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t23EEDD59217DFADC006E9E73 /* SyntaxVacuumSTMT.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDC61217DFADC006E9E73 /* SyntaxVacuumSTMT.cpp */; };\n\t\t23EEDD5A217DFADC006E9E73 /* SyntaxVacuumSTMT.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDC62217DFADC006E9E73 /* SyntaxVacuumSTMT.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t23EEDD5D217DFADC006E9E73 /* Syntax.h in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDC65217DFADC006E9E73 /* Syntax.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t23EEDD60217DFB17006E9E73 /* Enum.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDD5E217DFB16006E9E73 /* Enum.hpp */; };\n\t\t23EEDD61217DFB17006E9E73 /* Shadow.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDD5F217DFB17006E9E73 /* Shadow.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t23F0FEB5215F5E9A008399FB /* Lock.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23F0FEB1215F5E9A008399FB /* Lock.hpp */; };\n\t\t23F0FEB6215F5E9A008399FB /* ThreadLocal.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23F0FEB2215F5E9A008399FB /* ThreadLocal.hpp */; };\n\t\t23F0FEB7215F5E9A008399FB /* Lock.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23F0FEB3215F5E9A008399FB /* Lock.cpp */; };\n\t\t23F1698A20B6638F009B5C47 /* ThreadedErrors.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23F1698720B6638F009B5C47 /* ThreadedErrors.hpp */; };\n\t\t23F1698C20B6638F009B5C47 /* ThreadedErrors.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23F1698920B6638F009B5C47 /* ThreadedErrors.cpp */; };\n\t\t23F340DA204D32C3007DB8AB /* WCTTable.h in Headers */ = {isa = PBXBuildFile; fileRef = 23F340D8204D32C2007DB8AB /* WCTTable.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t23F340DB204D32C3007DB8AB /* WCTTable.mm in Sources */ = {isa = PBXBuildFile; fileRef = 23F340D9204D32C2007DB8AB /* WCTTable.mm */; };\n\t\t23F340DE204D3482007DB8AB /* WCTDatabase+ChainCall.h in Headers */ = {isa = PBXBuildFile; fileRef = 23F340DC204D3482007DB8AB /* WCTDatabase+ChainCall.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t23F340DF204D3482007DB8AB /* WCTDatabase+ChainCall.mm in Sources */ = {isa = PBXBuildFile; fileRef = 23F340DD204D3482007DB8AB /* WCTDatabase+ChainCall.mm */; };\n\t\t23F5BE1120888008000CCD37 /* sqlcipher.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 23F5BE0620887FD4000CCD37 /* sqlcipher.framework */; };\n\t\t23F5BE132088800C000CCD37 /* libz.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = 23C43BCC2087435800AB186D /* libz.tbd */; };\n\t\t23F70F7B209FF0EC00CCE3CD /* WCTValue.h in Headers */ = {isa = PBXBuildFile; fileRef = 23F70F79209FF0EC00CCE3CD /* WCTValue.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t23F70F7D209FF0EC00CCE3CD /* WCTValue.mm in Sources */ = {isa = PBXBuildFile; fileRef = 23F70F7A209FF0EC00CCE3CD /* WCTValue.mm */; };\n\t\t23F70FA220A055B400CCE3CD /* Config.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23F70F9F20A055B400CCE3CD /* Config.hpp */; };\n\t\t23F70FA620A055BE00CCE3CD /* BasicConfig.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23F70FA420A055BD00CCE3CD /* BasicConfig.cpp */; };\n\t\t23F70FA820A055BE00CCE3CD /* BasicConfig.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23F70FA520A055BD00CCE3CD /* BasicConfig.hpp */; };\n\t\t23F70FAC20A055C300CCE3CD /* CipherConfig.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23F70FAA20A055C300CCE3CD /* CipherConfig.cpp */; };\n\t\t23F70FAE20A055C300CCE3CD /* CipherConfig.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23F70FAB20A055C300CCE3CD /* CipherConfig.hpp */; };\n\t\t23F70FB820A055CF00CCE3CD /* AutoCheckpointConfig.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23F70FB620A055CF00CCE3CD /* AutoCheckpointConfig.cpp */; };\n\t\t23F70FBE20A055D400CCE3CD /* TokenizerConfig.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23F70FBC20A055D400CCE3CD /* TokenizerConfig.cpp */; };\n\t\t23F70FC020A055D400CCE3CD /* TokenizerConfig.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23F70FBD20A055D400CCE3CD /* TokenizerConfig.hpp */; };\n\t\t23F70FC620A0618100CCE3CD /* Configs.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23F70FC320A0618100CCE3CD /* Configs.hpp */; };\n\t\t23F70FD620A07CEC00CCE3CD /* CustomConfig.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23F70FD420A07CEC00CCE3CD /* CustomConfig.cpp */; };\n\t\t23F70FD820A07CEC00CCE3CD /* CustomConfig.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23F70FD520A07CEC00CCE3CD /* CustomConfig.hpp */; };\n\t\t23FEC463206B3032001E7A3B /* WCTConvenient.h in Headers */ = {isa = PBXBuildFile; fileRef = 23FEC461206B3032001E7A3B /* WCTConvenient.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t390E1C5C2296414C00C24598 /* Thread.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 390E1C5A2296414C00C24598 /* Thread.cpp */; };\n\t\t390E1C5E2296414C00C24598 /* Thread.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 390E1C5B2296414C00C24598 /* Thread.hpp */; };\n\t\t391F7C84225DE8FD0095E82D /* CommonCore.h in Headers */ = {isa = PBXBuildFile; fileRef = 391F7C83225DE8FD0095E82D /* CommonCore.h */; };\n\t\t39327B1F22CF271F00AABD4B /* BaseTestCase.mm in Sources */ = {isa = PBXBuildFile; fileRef = 39327AE222CF271E00AABD4B /* BaseTestCase.mm */; };\n\t\t39327B2722CF271F00AABD4B /* CRUDTestCase.mm in Sources */ = {isa = PBXBuildFile; fileRef = 39327AE422CF271E00AABD4B /* CRUDTestCase.mm */; };\n\t\t39327B2B22CF271F00AABD4B /* TableTestCase.mm in Sources */ = {isa = PBXBuildFile; fileRef = 39327AE522CF271E00AABD4B /* TableTestCase.mm */; };\n\t\t39327B5B22CF275200AABD4B /* NSObject+TestCase.mm in Sources */ = {isa = PBXBuildFile; fileRef = 39327B4B22CF275000AABD4B /* NSObject+TestCase.mm */; };\n\t\t39327B5F22CF275200AABD4B /* Signpost.mm in Sources */ = {isa = PBXBuildFile; fileRef = 39327B4E22CF275000AABD4B /* Signpost.mm */; };\n\t\t39327B6322CF275200AABD4B /* Dispatch.mm in Sources */ = {isa = PBXBuildFile; fileRef = 39327B4F22CF275000AABD4B /* Dispatch.mm */; };\n\t\t39327B6722CF275200AABD4B /* TestCaseResult.mm in Sources */ = {isa = PBXBuildFile; fileRef = 39327B5222CF275100AABD4B /* TestCaseResult.mm */; };\n\t\t39327B6B22CF275200AABD4B /* TestCaseCounter.mm in Sources */ = {isa = PBXBuildFile; fileRef = 39327B5322CF275100AABD4B /* TestCaseCounter.mm */; };\n\t\t39327B6F22CF275200AABD4B /* TestCaseLog.mm in Sources */ = {isa = PBXBuildFile; fileRef = 39327B5422CF275100AABD4B /* TestCaseLog.mm */; };\n\t\t39327B7322CF275200AABD4B /* WCTDatabase+TestCase.mm in Sources */ = {isa = PBXBuildFile; fileRef = 39327B5522CF275100AABD4B /* WCTDatabase+TestCase.mm */; };\n\t\t39327B7D22CF275900AABD4B /* Random+TestCaseObject.mm in Sources */ = {isa = PBXBuildFile; fileRef = 39327B7722CF275800AABD4B /* Random+TestCaseObject.mm */; };\n\t\t39327B8122CF275900AABD4B /* Random+WCDB.mm in Sources */ = {isa = PBXBuildFile; fileRef = 39327B7922CF275800AABD4B /* Random+WCDB.mm */; };\n\t\t39327B8522CF275900AABD4B /* Random.mm in Sources */ = {isa = PBXBuildFile; fileRef = 39327B7A22CF275800AABD4B /* Random.mm */; settings = {COMPILER_FLAGS = \"-fno-sanitize=signed-integer-overflow -fno-sanitize=unsigned-integer-overflow\"; }; };\n\t\t39327B8F22CF276000AABD4B /* TestCaseObject.mm in Sources */ = {isa = PBXBuildFile; fileRef = 39327B8922CF275F00AABD4B /* TestCaseObject.mm */; };\n\t\t39327B9322CF276000AABD4B /* AllTypesObject.mm in Sources */ = {isa = PBXBuildFile; fileRef = 39327B8D22CF275F00AABD4B /* AllTypesObject.mm */; };\n\t\t39327B9F22CF276600AABD4B /* ObjectsBasedFactory.mm in Sources */ = {isa = PBXBuildFile; fileRef = 39327B9722CF276600AABD4B /* ObjectsBasedFactory.mm */; };\n\t\t39327BA322CF276600AABD4B /* PrototypeFactory.mm in Sources */ = {isa = PBXBuildFile; fileRef = 39327B9922CF276600AABD4B /* PrototypeFactory.mm */; };\n\t\t39327BA722CF276600AABD4B /* SizeBasedFactory.mm in Sources */ = {isa = PBXBuildFile; fileRef = 39327B9B22CF276600AABD4B /* SizeBasedFactory.mm */; };\n\t\t39327BAB22CF276600AABD4B /* TablesBasedFactory.mm in Sources */ = {isa = PBXBuildFile; fileRef = 39327B9E22CF276600AABD4B /* TablesBasedFactory.mm */; };\n\t\t3932B9FD25232E490094F3F8 /* WCTColumnCoding.h in Headers */ = {isa = PBXBuildFile; fileRef = 3932B9FC25232D9F0094F3F8 /* WCTColumnCoding.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t3934DAEB229B6659008A6AEC /* OperationQueue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3934DAE9229B6659008A6AEC /* OperationQueue.cpp */; };\n\t\t3934DAED229B6659008A6AEC /* OperationQueue.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 3934DAEA229B6659008A6AEC /* OperationQueue.hpp */; };\n\t\t3934DB26229B951C008A6AEC /* AutoCheckpointConfig.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 3934DB25229B951C008A6AEC /* AutoCheckpointConfig.hpp */; };\n\t\t39411A4122437E7B00A388F5 /* CaseInsensitiveList.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 39411A3E22437E7B00A388F5 /* CaseInsensitiveList.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t39579858227FBC8A0069F985 /* WCTDatabase+Test.h in Headers */ = {isa = PBXBuildFile; fileRef = 39579856227FBC8A0069F985 /* WCTDatabase+Test.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t3957985A227FBC8A0069F985 /* WCTDatabase+Test.mm in Sources */ = {isa = PBXBuildFile; fileRef = 39579857227FBC8A0069F985 /* WCTDatabase+Test.mm */; };\n\t\t3960D89B2319258B00EF05D1 /* SyntaxExplainSTMT.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3960D8992319258B00EF05D1 /* SyntaxExplainSTMT.cpp */; };\n\t\t3960D89C2319258B00EF05D1 /* SyntaxExplainSTMT.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 3960D89A2319258B00EF05D1 /* SyntaxExplainSTMT.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t3960D89F2319288C00EF05D1 /* StatementExplain.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3960D89D2319288C00EF05D1 /* StatementExplain.cpp */; };\n\t\t3960D8A02319288C00EF05D1 /* StatementExplain.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 3960D89E2319288C00EF05D1 /* StatementExplain.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t3960D8A223192A9D00EF05D1 /* StatementExplainTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 3960D8A123192A9D00EF05D1 /* StatementExplainTests.mm */; };\n\t\t3962FFC82305142A008934D4 /* Statement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3962FFC723051429008934D4 /* Statement.cpp */; };\n\t\t3962FFCB230514CD008934D4 /* WCTBaseAccessor.mm in Sources */ = {isa = PBXBuildFile; fileRef = 3962FFC9230514CD008934D4 /* WCTBaseAccessor.mm */; };\n\t\t3962FFCF23051F71008934D4 /* Configs.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3962FFCE23051F71008934D4 /* Configs.cpp */; };\n\t\t3969018C233B1B2F006EEFD4 /* WCTTag.h in Headers */ = {isa = PBXBuildFile; fileRef = 3969018A233B1B2F006EEFD4 /* WCTTag.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t39690190233B20BC006EEFD4 /* WCTTableProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = 3969018E233B20BC006EEFD4 /* WCTTableProtocol.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t39690194233B2235006EEFD4 /* WCTTable+Table.h in Headers */ = {isa = PBXBuildFile; fileRef = 39690192233B2235006EEFD4 /* WCTTable+Table.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t39690195233B2235006EEFD4 /* WCTTable+Table.mm in Sources */ = {isa = PBXBuildFile; fileRef = 39690193233B2235006EEFD4 /* WCTTable+Table.mm */; };\n\t\t3995150722C2095B008394CC /* WCTOptional.mm in Sources */ = {isa = PBXBuildFile; fileRef = 3995150622C2095B008394CC /* WCTOptional.mm */; };\n\t\t39A3341922B0DD9F008EA5D5 /* WCTFoundation.h in Headers */ = {isa = PBXBuildFile; fileRef = 39A3341722B0DD9F008EA5D5 /* WCTFoundation.h */; };\n\t\t39A3341B22B0DD9F008EA5D5 /* WCTFoundation.mm in Sources */ = {isa = PBXBuildFile; fileRef = 39A3341822B0DD9F008EA5D5 /* WCTFoundation.mm */; };\n\t\t39B524DD2304F9A2001DF52D /* InnerHandle.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 39B524DB2304F9A1001DF52D /* InnerHandle.hpp */; };\n\t\t39B524DE2304F9A2001DF52D /* InnerHandle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 39B524DC2304F9A2001DF52D /* InnerHandle.cpp */; };\n\t\t39C70CC72313E20F002D773C /* Assemble.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 39C70CC52313E20E002D773C /* Assemble.cpp */; };\n\t\t39C70CC82313E20F002D773C /* Assemble.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 39C70CC62313E20F002D773C /* Assemble.hpp */; };\n\t\t750080D92920DCFF009C0F38 /* WCTFileManager.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2316D93521058B5500707AFC /* WCTFileManager.mm */; };\n\t\t750080DA2920DD1B009C0F38 /* WCTOperationQueue.mm in Sources */ = {isa = PBXBuildFile; fileRef = 232C6F00229C0A280046742F /* WCTOperationQueue.mm */; };\n\t\t750080E22920E4A1009C0F38 /* WCTFTSTokenizerUtil.mm in Sources */ = {isa = PBXBuildFile; fileRef = 23577F781F74F4E800D31C05 /* WCTFTSTokenizerUtil.mm */; };\n\t\t750080EC2920EDA2009C0F38 /* WCDB.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 239326611E836D7300D677CC /* WCDB.framework */; };\n\t\t750080EF2920EDC0009C0F38 /* WCDB.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 239326611E836D7300D677CC /* WCDB.framework */; };\n\t\t750080F32920F3D5009C0F38 /* WCTFoundation.mm in Sources */ = {isa = PBXBuildFile; fileRef = 39A3341822B0DD9F008EA5D5 /* WCTFoundation.mm */; };\n\t\t750080F42920F4E9009C0F38 /* WCTFoundation.h in Headers */ = {isa = PBXBuildFile; fileRef = 39A3341722B0DD9F008EA5D5 /* WCTFoundation.h */; };\n\t\t7500828C29222A93009C0F38 /* WCTAPIBridge.mm in Sources */ = {isa = PBXBuildFile; fileRef = 75CE3EFF2812E1A400E132F6 /* WCTAPIBridge.mm */; };\n\t\t7500829329223463009C0F38 /* WCTBridgeMacro.h in Headers */ = {isa = PBXBuildFile; fileRef = 7500829229223463009C0F38 /* WCTBridgeMacro.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t75067CC1293F82B4005DA25B /* AutoAddColumnTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75067CC0293F82B4005DA25B /* AutoAddColumnTests.swift */; };\n\t\t75067CC3293F8300005DA25B /* DatabaseTestCase.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75067CC2293F8300005DA25B /* DatabaseTestCase.swift */; };\n\t\t75067CC4293F8576005DA25B /* AutoAddColumnObject.mm in Sources */ = {isa = PBXBuildFile; fileRef = 75067CBD293F8192005DA25B /* AutoAddColumnObject.mm */; };\n\t\t750DC06C2913DE7300F19044 /* FTSBridge.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 750DC0692913DE7300F19044 /* FTSBridge.cpp */; };\n\t\t750DC06E2913DE7300F19044 /* FTSBridge.h in Headers */ = {isa = PBXBuildFile; fileRef = 750DC06A2913DE7300F19044 /* FTSBridge.h */; settings = {ATTRIBUTES = (Private, ); }; };\n\t\t7511EA50293CDAFB00FB033B /* NewPropertyObject.mm in Sources */ = {isa = PBXBuildFile; fileRef = 7511EA4F293CDAFB00FB033B /* NewPropertyObject.mm */; };\n\t\t75195E812852454700EC8C1F /* FrameSpecTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75195E802852454700EC8C1F /* FrameSpecTests.swift */; };\n\t\t751BFFCD2B9A31BD00B63FD3 /* WCTBridgeProperty.mm in Sources */ = {isa = PBXBuildFile; fileRef = 036E50B828115B1D007365CD /* WCTBridgeProperty.mm */; };\n\t\t751CA67728C64B7B00874A7A /* CPPAllTypesObject.mm in Sources */ = {isa = PBXBuildFile; fileRef = 751CA67528C64B7B00874A7A /* CPPAllTypesObject.mm */; };\n\t\t751FE4E72B1E10F200BFC7AD /* CompressingCRUDTest.mm in Sources */ = {isa = PBXBuildFile; fileRef = 751FE4E62B1E10F200BFC7AD /* CompressingCRUDTest.mm */; };\n\t\t75204AE8283FD6DC0002E40C /* Schema.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75204AE7283FD6DC0002E40C /* Schema.swift */; };\n\t\t75204AEB283FD7410002E40C /* SchemaBridge.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 75204AE9283FD7410002E40C /* SchemaBridge.cpp */; };\n\t\t75204AEC283FD7410002E40C /* SchemaBridge.h in Headers */ = {isa = PBXBuildFile; fileRef = 75204AEA283FD7410002E40C /* SchemaBridge.h */; settings = {ATTRIBUTES = (Private, ); }; };\n\t\t7521D39228BD1187009C33D0 /* ChainCall.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7521D39028BD1187009C33D0 /* ChainCall.cpp */; };\n\t\t7521D39328BD1187009C33D0 /* ChainCall.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7521D39028BD1187009C33D0 /* ChainCall.cpp */; };\n\t\t7521D39428BD1187009C33D0 /* ChainCall.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 7521D39128BD1187009C33D0 /* ChainCall.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521D39528BD1187009C33D0 /* ChainCall.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 7521D39128BD1187009C33D0 /* ChainCall.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521D6C2291E9ABB009642EF /* SQL.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDBA8217DFADC006E9E73 /* SQL.cpp */; };\n\t\t7521D6C3291E9ABB009642EF /* HighWater.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23E7EB1B2123D58D0056B5D8 /* HighWater.cpp */; };\n\t\t7521D6C4291E9ABB009642EF /* ConvertibleImplementation.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDB6D217DFADC006E9E73 /* ConvertibleImplementation.cpp */; };\n\t\t7521D6C5291E9ABB009642EF /* Scoreable.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2376CB1920DA5D3B00A68DB5 /* Scoreable.cpp */; };\n\t\t7521D6C6291E9ABB009642EF /* StatementCreateView.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDBC9217DFADC006E9E73 /* StatementCreateView.cpp */; };\n\t\t7521D6C7291E9ABB009642EF /* MappedData.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2316D92E21057CA700707AFC /* MappedData.cpp */; };\n\t\t7521D6C8291E9ABB009642EF /* Backup.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23775B3E20AD666900E21AB0 /* Backup.cpp */; };\n\t\t7521D6CB291E9ABB009642EF /* PinyinTokenizer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 03450DB62738C8F800C4DC1B /* PinyinTokenizer.cpp */; };\n\t\t7521D6CE291E9ABB009642EF /* SQLTraceConfig.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2360A5FF20D78F2B00E4A311 /* SQLTraceConfig.cpp */; };\n\t\t7521D6D0291E9ABB009642EF /* SyntaxPragma.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDC18217DFADC006E9E73 /* SyntaxPragma.cpp */; };\n\t\t7521D6D2291E9ABB009642EF /* Factory.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23D0C34920C149D80001BFAE /* Factory.cpp */; };\n\t\t7521D6D3291E9ABB009642EF /* WCTDatabase+Transaction.mm in Sources */ = {isa = PBXBuildFile; fileRef = 234DBD002064DE04000E31E8 /* WCTDatabase+Transaction.mm */; };\n\t\t7521D6D4291E9ABB009642EF /* WCTResultColumn.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2396EB0C21801BD60079066C /* WCTResultColumn.mm */; };\n\t\t7521D6D5291E9ABB009642EF /* Statement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3962FFC723051429008934D4 /* Statement.cpp */; };\n\t\t7521D6D6291E9ABB009642EF /* FactoryBackup.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23D0C38B20C17CAE0001BFAE /* FactoryBackup.cpp */; };\n\t\t7521D6D8291E9ABB009642EF /* CustomConfig.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23F70FD420A07CEC00CCE3CD /* CustomConfig.cpp */; };\n\t\t7521D6D9291E9ABB009642EF /* StatementDropView.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDBD7217DFADC006E9E73 /* StatementDropView.cpp */; };\n\t\t7521D6DA291E9ABB009642EF /* Config.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2327BC21220944D80078A85B /* Config.cpp */; };\n\t\t7521D6DB291E9ABB009642EF /* WCTDatabase.mm in Sources */ = {isa = PBXBuildFile; fileRef = 23DF0A072190275B00F0B2B6 /* WCTDatabase.mm */; };\n\t\t7521D6DC291E9ABB009642EF /* WCTOperationQueue.mm in Sources */ = {isa = PBXBuildFile; fileRef = 232C6F00229C0A280046742F /* WCTOperationQueue.mm */; };\n\t\t7521D6DD291E9ABB009642EF /* Tag.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23B4DC7C2111B39100954D71 /* Tag.cpp */; };\n\t\t7521D6DE291E9ABB009642EF /* SyntaxSavepointSTMT.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDC5B217DFADC006E9E73 /* SyntaxSavepointSTMT.cpp */; };\n\t\t7521D6DF291E9ABB009642EF /* SyntaxDeleteSTMT.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDC45217DFADC006E9E73 /* SyntaxDeleteSTMT.cpp */; };\n\t\t7521D6E0291E9ABB009642EF /* SyntaxCommitSTMT.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDC39217DFADC006E9E73 /* SyntaxCommitSTMT.cpp */; };\n\t\t7521D6E4291E9ABB009642EF /* Notifier.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23775B3220AD666900E21AB0 /* Notifier.cpp */; };\n\t\t7521D6E6291E9ABB009642EF /* SyntaxDropViewSTMT.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDC4F217DFADC006E9E73 /* SyntaxDropViewSTMT.cpp */; };\n\t\t7521D6E9291E9ABB009642EF /* OrderingTerm.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDB9A217DFADC006E9E73 /* OrderingTerm.cpp */; };\n\t\t7521D6EB291E9ABB009642EF /* ColumnType.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDB6A217DFADC006E9E73 /* ColumnType.cpp */; };\n\t\t7521D6EC291E9ABB009642EF /* WCTTryDisposeGuard.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2372E05721A2633800051D9A /* WCTTryDisposeGuard.mm */; };\n\t\t7521D6ED291E9ABB009642EF /* StatementAttach.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDBBD217DFADC006E9E73 /* StatementAttach.cpp */; };\n\t\t7521D6EE291E9ABB009642EF /* Fraction.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23AD52E420DB852B00664B62 /* Fraction.cpp */; };\n\t\t7521D6F0291E9ABB009642EF /* SyntaxTableConstraint.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDC26217DFADC006E9E73 /* SyntaxTableConstraint.cpp */; };\n\t\t7521D6F1291E9ABB009642EF /* SequenceCrawler.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23D07CE820BE873E0043F4D4 /* SequenceCrawler.cpp */; };\n\t\t7521D6F7291E9ABB009642EF /* StatementDropTrigger.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDBD5217DFADC006E9E73 /* StatementDropTrigger.cpp */; };\n\t\t7521D6F8291E9ABB009642EF /* ExpressionOperable.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDB71217DFADC006E9E73 /* ExpressionOperable.cpp */; };\n\t\t7521D6FA291E9ABB009642EF /* SQLiteLocker.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23C7558F20DCF90F00031A93 /* SQLiteLocker.cpp */; };\n\t\t7521D6FC291E9ABB009642EF /* NSNumber+WCTColumnCoding.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2370B10C21914ED400D3227C /* NSNumber+WCTColumnCoding.mm */; };\n\t\t7521D6FE291E9ABB009642EF /* StatementUpdate.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDBE7217DFADC006E9E73 /* StatementUpdate.cpp */; };\n\t\t7521D6FF291E9ABB009642EF /* SyntaxResultColumn.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDC20217DFADC006E9E73 /* SyntaxResultColumn.cpp */; };\n\t\t7521D700291E9ABB009642EF /* Initializeable.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23AF4E1C20CD04E20050033C /* Initializeable.cpp */; };\n\t\t7521D701291E9ABB009642EF /* PageBasedFileHandle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2316D9412105D19500707AFC /* PageBasedFileHandle.cpp */; };\n\t\t7521D703291E9ABB009642EF /* Progress.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23A6D4BD20BFD7F9004F2DAA /* Progress.cpp */; };\n\t\t7521D704291E9ABB009642EF /* Mechanic.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23775B4220AD666900E21AB0 /* Mechanic.cpp */; };\n\t\t7521D705291E9ABB009642EF /* WCTDatabase+Table.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2349F69B1EA0D6680021EFA7 /* WCTDatabase+Table.mm */; };\n\t\t7521D707291E9ABB009642EF /* SyntaxUpdateSTMT.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDC5F217DFADC006E9E73 /* SyntaxUpdateSTMT.cpp */; };\n\t\t7521D70A291E9ABB009642EF /* NSDate+WCTColumnCoding.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2370B10821914ED400D3227C /* NSDate+WCTColumnCoding.mm */; };\n\t\t7521D70B291E9ABB009642EF /* StatementCreateIndex.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDBC3217DFADC006E9E73 /* StatementCreateIndex.cpp */; };\n\t\t7521D70C291E9ABB009642EF /* WCTTable.mm in Sources */ = {isa = PBXBuildFile; fileRef = 23F340D9204D32C2007DB8AB /* WCTTable.mm */; };\n\t\t7521D70D291E9ABB009642EF /* StatementDetach.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDBCF217DFADC006E9E73 /* StatementDetach.cpp */; };\n\t\t7521D70F291E9ABB009642EF /* StatementAnalyze.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDBBB217DFADC006E9E73 /* StatementAnalyze.cpp */; };\n\t\t7521D712291E9ABB009642EF /* FTSFunction.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDB73217DFADC006E9E73 /* FTSFunction.cpp */; };\n\t\t7521D713291E9ABB009642EF /* RecyclableHandle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2349F6241EA0D6680021EFA7 /* RecyclableHandle.cpp */; };\n\t\t7521D717291E9ABB009642EF /* ResultColumn.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDBA4217DFADC006E9E73 /* ResultColumn.cpp */; };\n\t\t7521D719291E9ABB009642EF /* FullCrawler.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23775B3620AD666900E21AB0 /* FullCrawler.cpp */; };\n\t\t7521D71A291E9ABB009642EF /* SyntaxVacuumSTMT.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDC61217DFADC006E9E73 /* SyntaxVacuumSTMT.cpp */; };\n\t\t7521D71D291E9ABB009642EF /* StatementCreateTable.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDBC5217DFADC006E9E73 /* StatementCreateTable.cpp */; };\n\t\t7521D71E291E9ABB009642EF /* HandleNotification.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2360A5F420D78F1B00E4A311 /* HandleNotification.cpp */; };\n\t\t7521D71F291E9ABB009642EF /* SequenceItem.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23AD52DB20DB56D200664B62 /* SequenceItem.cpp */; };\n\t\t7521D720291E9ABB009642EF /* AuxiliaryFunctionModule.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7543DD84271C2FD000B533B4 /* AuxiliaryFunctionModule.cpp */; };\n\t\t7521D722291E9ABB009642EF /* WCTConvertible.mm in Sources */ = {isa = PBXBuildFile; fileRef = 234EF46D2015CFDE00B81929 /* WCTConvertible.mm */; };\n\t\t7521D724291E9ABB009642EF /* StatementAlterTable.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDBB9217DFADC006E9E73 /* StatementAlterTable.cpp */; };\n\t\t7521D725291E9ABB009642EF /* CipherConfig.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23F70FAA20A055C300CCE3CD /* CipherConfig.cpp */; };\n\t\t7521D726291E9ABB009642EF /* FactoryRelated.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23D0C36120C14ACC0001BFAE /* FactoryRelated.cpp */; };\n\t\t7521D728291E9ABB009642EF /* Global.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 235FBE9322914E0D005C7723 /* Global.cpp */; };\n\t\t7521D729291E9ABB009642EF /* WCTHandle+ChainCall.mm in Sources */ = {isa = PBXBuildFile; fileRef = 233A058A2062698E00F1A212 /* WCTHandle+ChainCall.mm */; };\n\t\t7521D72E291E9ABB009642EF /* SyntaxDropTriggerSTMT.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDC4D217DFADC006E9E73 /* SyntaxDropTriggerSTMT.cpp */; };\n\t\t7521D730291E9ABB009642EF /* AsyncQueue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23B4DCDF2112B03C00954D71 /* AsyncQueue.cpp */; };\n\t\t7521D731291E9ABB009642EF /* SyntaxUpsertClause.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDC2A217DFADC006E9E73 /* SyntaxUpsertClause.cpp */; };\n\t\t7521D732291E9ABB009642EF /* WCTTable+Table.mm in Sources */ = {isa = PBXBuildFile; fileRef = 39690193233B2235006EEFD4 /* WCTTable+Table.mm */; };\n\t\t7521D734291E9ABB009642EF /* Expression.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDB86217DFADC006E9E73 /* Expression.cpp */; };\n\t\t7521D736291E9ABB009642EF /* SyntaxPragmaSTMT.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDC53217DFADC006E9E73 /* SyntaxPragmaSTMT.cpp */; };\n\t\t7521D738291E9ABB009642EF /* WCTFoundation.mm in Sources */ = {isa = PBXBuildFile; fileRef = 39A3341822B0DD9F008EA5D5 /* WCTFoundation.mm */; };\n\t\t7521D73F291E9ABB009642EF /* WCTOptional.mm in Sources */ = {isa = PBXBuildFile; fileRef = 3995150622C2095B008394CC /* WCTOptional.mm */; };\n\t\t7521D743291E9ABB009642EF /* JoinConstraint.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDB94217DFADC006E9E73 /* JoinConstraint.cpp */; };\n\t\t7521D745291E9ABB009642EF /* WCTRuntimeObjCAccessor.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2349F6821EA0D6680021EFA7 /* WCTRuntimeObjCAccessor.mm */; };\n\t\t7521D747291E9ABB009642EF /* AutoMigrateConfig.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23301BF32298FE9A00A8AB5A /* AutoMigrateConfig.cpp */; };\n\t\t7521D748291E9ABB009642EF /* TableOrSubquery.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDBAC217DFADC006E9E73 /* TableOrSubquery.cpp */; };\n\t\t7521D74A291E9ABB009642EF /* WalRelated.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23593B7B20D3ADF80058B416 /* WalRelated.cpp */; };\n\t\t7521D74B291E9ABB009642EF /* SyntaxBeginSTMT.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDC37217DFADC006E9E73 /* SyntaxBeginSTMT.cpp */; };\n\t\t7521D74C291E9ABB009642EF /* SyntaxCommonTableExpression.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDBFC217DFADC006E9E73 /* SyntaxCommonTableExpression.cpp */; };\n\t\t7521D74E291E9ABB009642EF /* StatementDropTable.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDBD3217DFADC006E9E73 /* StatementDropTable.cpp */; };\n\t\t7521D751291E9ABB009642EF /* SyntaxExpression.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDC00217DFADC006E9E73 /* SyntaxExpression.cpp */; };\n\t\t7521D752291E9ABB009642EF /* StatementCreateVirtualTable.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDBCB217DFADC006E9E73 /* StatementCreateVirtualTable.cpp */; };\n\t\t7521D753291E9ABB009642EF /* SyntaxCommonConst.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23545BA12224EAA40091C981 /* SyntaxCommonConst.cpp */; };\n\t\t7521D754291E9ABB009642EF /* StatementSavepoint.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDBE3217DFADC006E9E73 /* StatementSavepoint.cpp */; };\n\t\t7521D755291E9ABB009642EF /* Recyclable.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 236996B121D5C4FF00E72E81 /* Recyclable.cpp */; };\n\t\t7521D756291E9ABB009642EF /* Data.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23775BCB20AD72BC00E21AB0 /* Data.cpp */; };\n\t\t7521D758291E9ABB009642EF /* SyntaxForeignKeyClause.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDC04217DFADC006E9E73 /* SyntaxForeignKeyClause.cpp */; };\n\t\t7521D759291E9ABB009642EF /* IndexedColumn.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDB90217DFADC006E9E73 /* IndexedColumn.cpp */; };\n\t\t7521D75A291E9ABB009642EF /* BaseTokenizerUtil.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 75B698D3290AD4C0006E1F8F /* BaseTokenizerUtil.cpp */; };\n\t\t7521D75B291E9ABB009642EF /* RaiseFunction.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDBA0217DFADC006E9E73 /* RaiseFunction.cpp */; };\n\t\t7521D75E291E9ABB009642EF /* ColumnConstraint.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDB7E217DFADC006E9E73 /* ColumnConstraint.cpp */; };\n\t\t7521D75F291E9ABB009642EF /* WCTRuntimeBaseAccessor.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2349F67F1EA0D6680021EFA7 /* WCTRuntimeBaseAccessor.mm */; };\n\t\t7521D762291E9ABB009642EF /* Range.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2314AE6F21070A1700244D39 /* Range.cpp */; };\n\t\t7521D763291E9ABB009642EF /* WCTHandle.mm in Sources */ = {isa = PBXBuildFile; fileRef = 234DBCF22064DD0B000E31E8 /* WCTHandle.mm */; };\n\t\t7521D764291E9ABB009642EF /* ThreadedErrors.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23F1698920B6638F009B5C47 /* ThreadedErrors.cpp */; };\n\t\t7521D769291E9ABB009642EF /* WCTObjCAccessor.mm in Sources */ = {isa = PBXBuildFile; fileRef = 237908F621928C9F0098797F /* WCTObjCAccessor.mm */; };\n\t\t7521D76A291E9ABB009642EF /* StatementCreateTrigger.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDBC7217DFADC006E9E73 /* StatementCreateTrigger.cpp */; };\n\t\t7521D76B291E9ABB009642EF /* DatabasePool.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23D96B902050DED700DB5E93 /* DatabasePool.cpp */; };\n\t\t7521D76D291E9ABB009642EF /* WCTMigrationInfo.mm in Sources */ = {isa = PBXBuildFile; fileRef = 236BACE521BF9FC900C8B4D9 /* WCTMigrationInfo.mm */; };\n\t\t7521D76E291E9ABB009642EF /* TokenizerModules.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2304B42C22156E1500901953 /* TokenizerModules.cpp */; };\n\t\t7521D771291E9ABB009642EF /* FactoryDepositor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23D0C34B20C149D80001BFAE /* FactoryDepositor.cpp */; };\n\t\t7521D773291E9ABB009642EF /* WCTHandle+Convenient.mm in Sources */ = {isa = PBXBuildFile; fileRef = 23A3CFB4205FB1A800692F94 /* WCTHandle+Convenient.mm */; };\n\t\t7521D777291E9ABB009642EF /* TokenizerConfig.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23F70FBC20A055D400CCE3CD /* TokenizerConfig.cpp */; };\n\t\t7521D778291E9ABB009642EF /* FactoryRetriever.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23D0C34F20C149D80001BFAE /* FactoryRetriever.cpp */; };\n\t\t7521D779291E9ABB009642EF /* WCTPreparedStatement.mm in Sources */ = {isa = PBXBuildFile; fileRef = 755391D52403B3DB00036918 /* WCTPreparedStatement.mm */; };\n\t\t7521D77B291E9ABB009642EF /* StatementRollback.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDBE1217DFADC006E9E73 /* StatementRollback.cpp */; };\n\t\t7521D77C291E9ABB009642EF /* Exiting.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 231C35EC21DE09E400B5D3D2 /* Exiting.cpp */; };\n\t\t7521D77E291E9ABB009642EF /* NSNull+WCTColumnCoding.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2370B11721914ED500D3227C /* NSNull+WCTColumnCoding.mm */; };\n\t\t7521D77F291E9ABB009642EF /* Migration.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23A64D0D214A4A7000ED28BB /* Migration.cpp */; };\n\t\t7521D780291E9ABB009642EF /* Configs.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3962FFCE23051F71008934D4 /* Configs.cpp */; };\n\t\t7521D782291E9ABB009642EF /* SyntaxCreateTriggerSTMT.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDC3F217DFADC006E9E73 /* SyntaxCreateTriggerSTMT.cpp */; };\n\t\t7521D784291E9ABB009642EF /* Column.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDB7C217DFADC006E9E73 /* Column.cpp */; };\n\t\t7521D786291E9ABB009642EF /* WCTDatabase+Test.mm in Sources */ = {isa = PBXBuildFile; fileRef = 39579857227FBC8A0069F985 /* WCTDatabase+Test.mm */; };\n\t\t7521D788291E9ABB009642EF /* StatementSelect.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDBE5217DFADC006E9E73 /* StatementSelect.cpp */; };\n\t\t7521D78B291E9ABB009642EF /* OneOrBinaryTokenizer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 03450DB22738BBF000C4DC1B /* OneOrBinaryTokenizer.cpp */; };\n\t\t7521D78E291E9ABB009642EF /* WCTMaster.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2370B11421914ED500D3227C /* WCTMaster.mm */; };\n\t\t7521D78F291E9ABB009642EF /* SyntaxReindexSTMT.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDC55217DFADC006E9E73 /* SyntaxReindexSTMT.cpp */; };\n\t\t7521D793291E9ABB009642EF /* SyntaxCreateViewSTMT.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDC41217DFADC006E9E73 /* SyntaxCreateViewSTMT.cpp */; };\n\t\t7521D794291E9ABB009642EF /* BindParameter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDB7A217DFADC006E9E73 /* BindParameter.cpp */; };\n\t\t7521D795291E9ABB009642EF /* AutoBackupConfig.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23301BFA229A851800A8AB5A /* AutoBackupConfig.cpp */; };\n\t\t7521D797291E9ABB009642EF /* WCTDatabase+Memory.mm in Sources */ = {isa = PBXBuildFile; fileRef = 23BBE2B02049576D00C4CBB6 /* WCTDatabase+Memory.mm */; };\n\t\t7521D799291E9ABB009642EF /* SyntaxRaiseFunction.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDC1C217DFADC006E9E73 /* SyntaxRaiseFunction.cpp */; };\n\t\t7521D79A291E9ABB009642EF /* FrameSpec.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDB8C217DFADC006E9E73 /* FrameSpec.cpp */; };\n\t\t7521D79D291E9ABB009642EF /* HandlePool.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2349F6221EA0D6680021EFA7 /* HandlePool.cpp */; };\n\t\t7521D79F291E9ABB009642EF /* SyntaxWindowDef.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDC2C217DFADC006E9E73 /* SyntaxWindowDef.cpp */; };\n\t\t7521D7A0291E9ABB009642EF /* WCTValue.mm in Sources */ = {isa = PBXBuildFile; fileRef = 23F70F7A209FF0EC00CCE3CD /* WCTValue.mm */; };\n\t\t7521D7A1291E9ABB009642EF /* WCTDatabase+File.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2349F66C1EA0D6680021EFA7 /* WCTDatabase+File.mm */; };\n\t\t7521D7A3291E9ABB009642EF /* WCTDatabase+Monitor.mm in Sources */ = {isa = PBXBuildFile; fileRef = 23906AB8215E500100C2B717 /* WCTDatabase+Monitor.mm */; };\n\t\t7521D7A4291E9ABB009642EF /* PagerRelated.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23567D5720CA823C005F1C35 /* PagerRelated.cpp */; };\n\t\t7521D7A9291E9ABB009642EF /* SyntaxColumnDef.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDBFA217DFADC006E9E73 /* SyntaxColumnDef.cpp */; };\n\t\t7521D7AB291E9ABB009642EF /* WindowDef.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDBB0217DFADC006E9E73 /* WindowDef.cpp */; };\n\t\t7521D7AC291E9ABB009642EF /* FileManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23B9E67420AE733A00CF1683 /* FileManager.cpp */; };\n\t\t7521D7AD291E9ABB009642EF /* SyntaxColumn.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDBF6217DFADC006E9E73 /* SyntaxColumn.cpp */; };\n\t\t7521D7AE291E9ABB009642EF /* SyntaxFilter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDC02217DFADC006E9E73 /* SyntaxFilter.cpp */; };\n\t\t7521D7AF291E9ABB009642EF /* StatementDelete.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDBCD217DFADC006E9E73 /* StatementDelete.cpp */; };\n\t\t7521D7B0291E9ABB009642EF /* ErrorProne.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23567D4620CA7DBC005F1C35 /* ErrorProne.cpp */; };\n\t\t7521D7B1291E9ABB009642EF /* WCTMultiSelect.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2349F6481EA0D6680021EFA7 /* WCTMultiSelect.mm */; };\n\t\t7521D7B2291E9ABB009642EF /* SyntaxInsertSTMT.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDC51217DFADC006E9E73 /* SyntaxInsertSTMT.cpp */; };\n\t\t7521D7B5291E9ABB009642EF /* Shm.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23408F0D211897AA0071E5A7 /* Shm.cpp */; };\n\t\t7521D7B6291E9ABB009642EF /* InnerDatabase.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2349F61B1EA0D6680021EFA7 /* InnerDatabase.cpp */; };\n\t\t7521D7B7291E9ABB009642EF /* Pragma.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDB9C217DFADC006E9E73 /* Pragma.cpp */; };\n\t\t7521D7B8291E9ABB009642EF /* UpgradeableErrorProne.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23AD52F020DBAC4C00664B62 /* UpgradeableErrorProne.cpp */; };\n\t\t7521D7BA291E9ABB009642EF /* WCTDatabase+Version.mm in Sources */ = {isa = PBXBuildFile; fileRef = 23176A9A21BA7D460051ACF9 /* WCTDatabase+Version.mm */; };\n\t\t7521D7BD291E9ABB009642EF /* SharedThreadedErrorProne.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23567D7220CA91FF005F1C35 /* SharedThreadedErrorProne.cpp */; };\n\t\t7521D7BE291E9ABB009642EF /* LiteralValue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDB96217DFADC006E9E73 /* LiteralValue.cpp */; };\n\t\t7521D7C3291E9ABB009642EF /* SyntaxCreateIndexSTMT.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDC3B217DFADC006E9E73 /* SyntaxCreateIndexSTMT.cpp */; };\n\t\t7521D7C7291E9ABB009642EF /* WCTInsert.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2349F6441EA0D6680021EFA7 /* WCTInsert.mm */; };\n\t\t7521D7C8291E9ABB009642EF /* WCTColumnBinding.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2349F6871EA0D6680021EFA7 /* WCTColumnBinding.mm */; };\n\t\t7521D7C9291E9ABB009642EF /* WCTSelect.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2349F64D1EA0D6680021EFA7 /* WCTSelect.mm */; };\n\t\t7521D7CC291E9ABB009642EF /* SyntaxAlterTableSTMT.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDC31217DFADC006E9E73 /* SyntaxAlterTableSTMT.cpp */; };\n\t\t7521D7CD291E9ABB009642EF /* SyntaxCreateVirtualTableSTMT.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDC43217DFADC006E9E73 /* SyntaxCreateVirtualTableSTMT.cpp */; };\n\t\t7521D7CE291E9ABB009642EF /* SyntaxAttachSTMT.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDC35217DFADC006E9E73 /* SyntaxAttachSTMT.cpp */; };\n\t\t7521D7D0291E9ABB009642EF /* SyntaxJoinClause.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDC0E217DFADC006E9E73 /* SyntaxJoinClause.cpp */; };\n\t\t7521D7D1291E9ABB009642EF /* WCTDatabase+FTS.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2327414F1F6FBD50004E96F7 /* WCTDatabase+FTS.mm */; };\n\t\t7521D7D2291E9ABB009642EF /* SyntaxDropTableSTMT.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDC4B217DFADC006E9E73 /* SyntaxDropTableSTMT.cpp */; };\n\t\t7521D7D5291E9ABB009642EF /* SyntaxExplainSTMT.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3960D8992319258B00EF05D1 /* SyntaxExplainSTMT.cpp */; };\n\t\t7521D7D9291E9ABB009642EF /* NSData+WCTColumnCoding.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2370B11321914ED500D3227C /* NSData+WCTColumnCoding.mm */; };\n\t\t7521D7DA291E9ABB009642EF /* SyntaxLiteralValue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDC12217DFADC006E9E73 /* SyntaxLiteralValue.cpp */; };\n\t\t7521D7DC291E9ABB009642EF /* StringView.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 235EE9C422B6321A008F6658 /* StringView.cpp */; };\n\t\t7521D7DF291E9ABB009642EF /* SyntaxRollbackSTMT.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDC59217DFADC006E9E73 /* SyntaxRollbackSTMT.cpp */; };\n\t\t7521D7E0291E9ABB009642EF /* HandleStatement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2370980820590CA700E768B4 /* HandleStatement.cpp */; };\n\t\t7521D7E3291E9ABB009642EF /* CoreFunction.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDB6F217DFADC006E9E73 /* CoreFunction.cpp */; };\n\t\t7521D7E4291E9ABB009642EF /* WCTBinding.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2349F6851EA0D6680021EFA7 /* WCTBinding.mm */; };\n\t\t7521D7E5291E9ABB009642EF /* WCTDatabase+Convenient.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2349F6581EA0D6680021EFA7 /* WCTDatabase+Convenient.mm */; };\n\t\t7521D7E8291E9ABB009642EF /* FactoryRenewer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23DD76BB20CF78C800E9B451 /* FactoryRenewer.cpp */; };\n\t\t7521D7E9291E9ABB009642EF /* TokenizerModule.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2304B42622156CD700901953 /* TokenizerModule.cpp */; };\n\t\t7521D7EA291E9ABB009642EF /* SyntaxFrameSpec.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDC06217DFADC006E9E73 /* SyntaxFrameSpec.cpp */; };\n\t\t7521D7EB291E9ABB009642EF /* WCTDatabase+Handle.mm in Sources */ = {isa = PBXBuildFile; fileRef = 234DBCED2064DD0B000E31E8 /* WCTDatabase+Handle.mm */; };\n\t\t7521D7EC291E9ABB009642EF /* SyntaxTableOrSubquery.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDC28217DFADC006E9E73 /* SyntaxTableOrSubquery.cpp */; };\n\t\t7521D7F0291E9ABB009642EF /* Time.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23567D7920CA93C5005F1C35 /* Time.cpp */; };\n\t\t7521D7F1291E9ABB009642EF /* WCTTable+Convenient.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2349F65A1EA0D6680021EFA7 /* WCTTable+Convenient.mm */; };\n\t\t7521D7F3291E9ABB009642EF /* WCTHandle+Transaction.mm in Sources */ = {isa = PBXBuildFile; fileRef = 234DBD022064DE04000E31E8 /* WCTHandle+Transaction.mm */; };\n\t\t7521D7F4291E9ABB009642EF /* StatementVacuum.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDBE9217DFADC006E9E73 /* StatementVacuum.cpp */; };\n\t\t7521D7F5291E9ABB009642EF /* AbstractHandle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2347378D21CBB3A800AD5E41 /* AbstractHandle.cpp */; };\n\t\t7521D7F6291E9ABB009642EF /* WCTChainCall.mm in Sources */ = {isa = PBXBuildFile; fileRef = 23776CA3218C41DD00E985DC /* WCTChainCall.mm */; };\n\t\t7521D7F7291E9ABB009642EF /* WCTHandle+Table.mm in Sources */ = {isa = PBXBuildFile; fileRef = 23EABBE5206D08EC00241F3B /* WCTHandle+Table.mm */; };\n\t\t7521D7F8291E9ABB009642EF /* WCTUpdate.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2349F6551EA0D6680021EFA7 /* WCTUpdate.mm */; };\n\t\t7521D7F9291E9ABB009642EF /* StatementExplain.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3960D89D2319288C00EF05D1 /* StatementExplain.cpp */; };\n\t\t7521D7FA291E9ABB009642EF /* CommonCore.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23B4DCBB2112A9C800954D71 /* CommonCore.cpp */; };\n\t\t7521D7FB291E9ABB009642EF /* SyntaxIndexedColumn.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDC0C217DFADC006E9E73 /* SyntaxIndexedColumn.cpp */; };\n\t\t7521D7FD291E9ABB009642EF /* Pager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23775B4920AD666900E21AB0 /* Pager.cpp */; };\n\t\t7521D803291E9ABB009642EF /* Console.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 233A8530215E7CFE00BB8D4F /* Console.cpp */; };\n\t\t7521D805291E9ABB009642EF /* Upsert.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDBAE217DFADC006E9E73 /* Upsert.cpp */; };\n\t\t7521D806291E9ABB009642EF /* MasterItem.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23AD52D420DB4A3C00664B62 /* MasterItem.cpp */; };\n\t\t7521D807291E9ABB009642EF /* StatementDropIndex.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDBD1217DFADC006E9E73 /* StatementDropIndex.cpp */; };\n\t\t7521D808291E9ABB009642EF /* WCDBError.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23775B3020AD666900E21AB0 /* WCDBError.cpp */; };\n\t\t7521D809291E9ABB009642EF /* StatementInsert.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDBD9217DFADC006E9E73 /* StatementInsert.cpp */; };\n\t\t7521D80A291E9ABB009642EF /* SubstringMatchInfo.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7543DD90271C601F00B533B4 /* SubstringMatchInfo.cpp */; };\n\t\t7521D80D291E9ABB009642EF /* Assemble.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 39C70CC52313E20E002D773C /* Assemble.cpp */; };\n\t\t7521D80E291E9ABB009642EF /* Cell.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23775B4520AD666900E21AB0 /* Cell.cpp */; };\n\t\t7521D810291E9ABB009642EF /* AuxiliaryFunctionConfig.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7543DD8C271C360E00B533B4 /* AuxiliaryFunctionConfig.cpp */; };\n\t\t7521D812291E9ABB009642EF /* WCTDatabase+Migration.mm in Sources */ = {isa = PBXBuildFile; fileRef = 236BACE121BF9F6400C8B4D9 /* WCTDatabase+Migration.mm */; };\n\t\t7521D814291E9ABB009642EF /* Frame.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23567CF820CA3889005F1C35 /* Frame.cpp */; };\n\t\t7521D816291E9ABB009642EF /* Path.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23B35C7520BFE39500425033 /* Path.cpp */; };\n\t\t7521D817291E9ABB009642EF /* CommonTableExpression.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDB82217DFADC006E9E73 /* CommonTableExpression.cpp */; };\n\t\t7521D819291E9ABB009642EF /* PerformanceTraceConfig.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2360A60120D78F2B00E4A311 /* PerformanceTraceConfig.cpp */; };\n\t\t7521D81A291E9ABB009642EF /* StatementCommit.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDBC1217DFADC006E9E73 /* StatementCommit.cpp */; };\n\t\t7521D81B291E9ABB009642EF /* WCTSelectable.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2349F6501EA0D6680021EFA7 /* WCTSelectable.mm */; };\n\t\t7521D81D291E9ABB009642EF /* AutoCheckpointConfig.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23F70FB620A055CF00CCE3CD /* AutoCheckpointConfig.cpp */; };\n\t\t7521D820291E9ABB009642EF /* Filter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDB88217DFADC006E9E73 /* Filter.cpp */; };\n\t\t7521D821291E9ABB009642EF /* Thread.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 390E1C5A2296414C00C24598 /* Thread.cpp */; };\n\t\t7521D822291E9ABB009642EF /* OperationQueue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3934DAE9229B6659008A6AEC /* OperationQueue.cpp */; };\n\t\t7521D823291E9ABB009642EF /* AutoMergeFTSIndexConfig.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0D3AE53F25416DB4007B9D0E /* AutoMergeFTSIndexConfig.cpp */; };\n\t\t7521D825291E9ABB009642EF /* QualifiedTable.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDB9E217DFADC006E9E73 /* QualifiedTable.cpp */; };\n\t\t7521D827291E9ABB009642EF /* BasicConfig.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23F70FA420A055BD00CCE3CD /* BasicConfig.cpp */; };\n\t\t7521D828291E9ABB009642EF /* StatementPragma.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDBDB217DFADC006E9E73 /* StatementPragma.cpp */; };\n\t\t7521D829291E9ABB009642EF /* MergeFTSIndexLogic.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0D249BC82542B90600B43BD9 /* MergeFTSIndexLogic.cpp */; };\n\t\t7521D82A291E9ABB009642EF /* SyntaxAnalyzeSTMT.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDC33217DFADC006E9E73 /* SyntaxAnalyzeSTMT.cpp */; };\n\t\t7521D82C291E9ABB009642EF /* SyntaxQualifiedTableName.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDC1A217DFADC006E9E73 /* SyntaxQualifiedTableName.cpp */; };\n\t\t7521D82D291E9ABB009642EF /* SyntaxSchema.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDC22217DFADC006E9E73 /* SyntaxSchema.cpp */; };\n\t\t7521D82E291E9ABB009642EF /* WCTProperty.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2349F6911EA0D6680021EFA7 /* WCTProperty.mm */; };\n\t\t7521D833291E9ABB009642EF /* WCTError.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2386B3C31ED442FE000B72F6 /* WCTError.mm */; };\n\t\t7521D835291E9ABB009642EF /* ColumnMeta.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 237B47AE21FEEA200059227A /* ColumnMeta.cpp */; };\n\t\t7521D836291E9ABB009642EF /* UnsafeData.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2375945F210081AA00DBB721 /* UnsafeData.cpp */; };\n\t\t7521D837291E9ABB009642EF /* ColumnDef.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDB80217DFADC006E9E73 /* ColumnDef.cpp */; };\n\t\t7521D838291E9ABB009642EF /* NSString+WCTColumnCoding.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2370B11921914ED500D3227C /* NSString+WCTColumnCoding.mm */; };\n\t\t7521D839291E9ABB009642EF /* TableConstraint.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDBAA217DFADC006E9E73 /* TableConstraint.cpp */; };\n\t\t7521D83A291E9ABB009642EF /* SyntaxColumnConstraint.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDBF8217DFADC006E9E73 /* SyntaxColumnConstraint.cpp */; };\n\t\t7521D83B291E9ABB009642EF /* Repairman.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EE0EB020B838E100C95998 /* Repairman.cpp */; };\n\t\t7521D83C291E9ABB009642EF /* StatementBegin.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDBBF217DFADC006E9E73 /* StatementBegin.cpp */; };\n\t\t7521D83D291E9ABB009642EF /* WCTFileManager.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2316D93521058B5500707AFC /* WCTFileManager.mm */; };\n\t\t7521D83E291E9ABB009642EF /* MigrationInfo.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23A64D07214A458A00ED28BB /* MigrationInfo.cpp */; };\n\t\t7521D83F291E9ABB009642EF /* Material.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23775B4020AD666900E21AB0 /* Material.cpp */; };\n\t\t7521D840291E9ABB009642EF /* ForeignKey.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDB8A217DFADC006E9E73 /* ForeignKey.cpp */; };\n\t\t7521D841291E9ABB009642EF /* Crawlable.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23775B5020AD666900E21AB0 /* Crawlable.cpp */; };\n\t\t7521D843291E9ABB009642EF /* AggregateFunction.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDB68217DFADC006E9E73 /* AggregateFunction.cpp */; };\n\t\t7521D845291E9ABB009642EF /* SQLiteBase.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23C7559820DD17B100031A93 /* SQLiteBase.cpp */; };\n\t\t7521D846291E9ABB009642EF /* Join.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDB92217DFADC006E9E73 /* Join.cpp */; };\n\t\t7521D847291E9ABB009642EF /* SyntaxCreateTableSTMT.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDC3D217DFADC006E9E73 /* SyntaxCreateTableSTMT.cpp */; };\n\t\t7521D84A291E9ABB009642EF /* FTSError.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 03EA88CF27D5F0840075C7BD /* FTSError.cpp */; };\n\t\t7521D84B291E9ABB009642EF /* SyntaxDropIndexSTMT.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDC49217DFADC006E9E73 /* SyntaxDropIndexSTMT.cpp */; };\n\t\t7521D84D291E9ABB009642EF /* HandleRelated.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2360A5F320D78F1B00E4A311 /* HandleRelated.cpp */; };\n\t\t7521D84E291E9ABB009642EF /* SyntaxIdentifier.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDC0A217DFADC006E9E73 /* SyntaxIdentifier.cpp */; };\n\t\t7521D84F291E9ABB009642EF /* SyntaxBindParameter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDBF4217DFADC006E9E73 /* SyntaxBindParameter.cpp */; };\n\t\t7521D850291E9ABB009642EF /* SyntaxDetachSTMT.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDC47217DFADC006E9E73 /* SyntaxDetachSTMT.cpp */; };\n\t\t7521D851291E9ABB009642EF /* Page.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23775B4720AD666900E21AB0 /* Page.cpp */; };\n\t\t7521D854291E9ABB009642EF /* SyntaxOrderingTerm.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDC16217DFADC006E9E73 /* SyntaxOrderingTerm.cpp */; };\n\t\t7521D856291E9ABB009642EF /* Serialization.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2308F84D20E32A51001CD9C3 /* Serialization.cpp */; };\n\t\t7521D85A291E9ABB009642EF /* DBOperationNotifier.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0DC98FD028E46049007F3796 /* DBOperationNotifier.cpp */; };\n\t\t7521D85B291E9ABB009642EF /* PorterStemming.c in Sources */ = {isa = PBXBuildFile; fileRef = 23E163D120FDDD8500C3F910 /* PorterStemming.c */; };\n\t\t7521D85E291E9ABB009642EF /* SQLiteAssembler.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23D0C30C20C125420001BFAE /* SQLiteAssembler.cpp */; };\n\t\t7521D863291E9ABB009642EF /* FileHandle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2308F84B20E32A51001CD9C3 /* FileHandle.cpp */; };\n\t\t7521D868291E9ABB009642EF /* SyntaxJoinConstraint.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDC10217DFADC006E9E73 /* SyntaxJoinConstraint.cpp */; };\n\t\t7521D869291E9ABB009642EF /* WCTDatabase+Config.mm in Sources */ = {isa = PBXBuildFile; fileRef = 23BBE2AC2049565600C4CBB6 /* WCTDatabase+Config.mm */; };\n\t\t7521D86A291E9ABB009642EF /* SyntaxReleaseSTMT.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDC57217DFADC006E9E73 /* SyntaxReleaseSTMT.cpp */; };\n\t\t7521D86B291E9ABB009642EF /* WCTDatabase+Repair.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2349F66F1EA0D6680021EFA7 /* WCTDatabase+Repair.mm */; };\n\t\t7521D86D291E9ABB009642EF /* Schema.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDBA6217DFADC006E9E73 /* Schema.cpp */; };\n\t\t7521D86E291E9ABB009642EF /* MasterCrawler.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23D07CE220BE87360043F4D4 /* MasterCrawler.cpp */; };\n\t\t7521D86F291E9ABB009642EF /* StatementReindex.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDBDD217DFADC006E9E73 /* StatementReindex.cpp */; };\n\t\t7521D870291E9ABB009642EF /* NSObject+WCTColumnCoding.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2370B10E21914ED400D3227C /* NSObject+WCTColumnCoding.mm */; };\n\t\t7521D871291E9ABB009642EF /* WCTTable+ChainCall.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2349F6521EA0D6680021EFA7 /* WCTTable+ChainCall.mm */; };\n\t\t7521D872291E9ABB009642EF /* Wal.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EB91DC20CA1EBE00ECF668 /* Wal.cpp */; };\n\t\t7521D873291E9ABB009642EF /* WCTFTSTokenizerUtil.mm in Sources */ = {isa = PBXBuildFile; fileRef = 23577F781F74F4E800D31C05 /* WCTFTSTokenizerUtil.mm */; };\n\t\t7521D877291E9ABB009642EF /* WCTDelete.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2349F6411EA0D6680021EFA7 /* WCTDelete.mm */; };\n\t\t7521D878291E9ABB009642EF /* BusyRetryConfig.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 237A8D5D21EDBB2E003AF5BB /* BusyRetryConfig.cpp */; };\n\t\t7521D87B291E9ABB009642EF /* SyntaxSelectSTMT.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDC5D217DFADC006E9E73 /* SyntaxSelectSTMT.cpp */; };\n\t\t7521D87C291E9ABB009642EF /* InnerHandle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 39B524DC2304F9A2001DF52D /* InnerHandle.cpp */; };\n\t\t7521D87F291E9ABB009642EF /* WCTDatabase+ChainCall.mm in Sources */ = {isa = PBXBuildFile; fileRef = 23F340DD204D3482007DB8AB /* WCTDatabase+ChainCall.mm */; };\n\t\t7521D880291E9ABB009642EF /* Lock.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23F0FEB3215F5E9A008399FB /* Lock.cpp */; };\n\t\t7521D882291E9ABB009642EF /* WCTBaseAccessor.mm in Sources */ = {isa = PBXBuildFile; fileRef = 3962FFC9230514CD008934D4 /* WCTBaseAccessor.mm */; };\n\t\t7521D884291E9ABB009642EF /* BaseBinding.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7537E5CF28B939240077D92B /* BaseBinding.cpp */; };\n\t\t7521D885291E9ABB009642EF /* SyntaxSelectCore.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDC24217DFADC006E9E73 /* SyntaxSelectCore.cpp */; };\n\t\t7521D888291E9ABB009642EF /* Value.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 03E5CC6C28A3BDF3005353D9 /* Value.cpp */; };\n\t\t7521D889291E9ABB009642EF /* StatementRelease.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDBDF217DFADC006E9E73 /* StatementRelease.cpp */; };\n\t\t7521D88E291E9ABB009642EF /* Security.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 23F0FD7C215F1C92008399FB /* Security.framework */; };\n\t\t7521D88F291E9ABB009642EF /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 239E8A922160A81600BCB308 /* Foundation.framework */; };\n\t\t7521D890291E9ABB009642EF /* libz.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = 23C43BCC2087435800AB186D /* libz.tbd */; };\n\t\t7521D891291E9ABB009642EF /* sqlcipher.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 23F5BE0620887FD4000CCD37 /* sqlcipher.framework */; };\n\t\t7521D893291E9ABB009642EF /* AsyncQueue.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23B4DCE02112B03C00954D71 /* AsyncQueue.hpp */; };\n\t\t7521D894291E9ABB009642EF /* AutoBackupConfig.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23301BF9229A851800A8AB5A /* AutoBackupConfig.hpp */; };\n\t\t7521D895291E9ABB009642EF /* WINQ.h in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDBEB217DFADC006E9E73 /* WINQ.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521D896291E9ABB009642EF /* UnsafeData.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23759460210081AA00DBB721 /* UnsafeData.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521D898291E9ABB009642EF /* WCTDeclaration.h in Headers */ = {isa = PBXBuildFile; fileRef = 23DF0A0D219028E900F0B2B6 /* WCTDeclaration.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521D899291E9ABB009642EF /* CommonCore.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 234591F5204432E400DC7D34 /* CommonCore.hpp */; };\n\t\t7521D89C291E9ABB009642EF /* WCTHandle+ChainCall.h in Headers */ = {isa = PBXBuildFile; fileRef = 233A05892062698E00F1A212 /* WCTHandle+ChainCall.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521D89E291E9ABB009642EF /* Pragma.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDB9D217DFADC006E9E73 /* Pragma.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521D89F291E9ABB009642EF /* SequenceItem.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23AD52DC20DB56D200664B62 /* SequenceItem.hpp */; };\n\t\t7521D8A0291E9ABB009642EF /* MappedData.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 2316D92B21057CA600707AFC /* MappedData.hpp */; };\n\t\t7521D8A1291E9ABB009642EF /* SyntaxCommitSTMT.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDC3A217DFADC006E9E73 /* SyntaxCommitSTMT.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521D8A3291E9ABB009642EF /* Syntax.h in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDC65217DFADC006E9E73 /* Syntax.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521D8A4291E9ABB009642EF /* SyntaxAttachSTMT.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDC36217DFADC006E9E73 /* SyntaxAttachSTMT.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521D8A5291E9ABB009642EF /* CommonTableExpression.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDB83217DFADC006E9E73 /* CommonTableExpression.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521D8A6291E9ABB009642EF /* ValueArray.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 03A15DF828AA636A0031A50A /* ValueArray.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521D8A7291E9ABB009642EF /* WCTTable+Table.h in Headers */ = {isa = PBXBuildFile; fileRef = 39690192233B2235006EEFD4 /* WCTTable+Table.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521D8A8291E9ABB009642EF /* Console.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 233A8531215E7CFE00BB8D4F /* Console.hpp */; };\n\t\t7521D8A9291E9ABB009642EF /* NSObject+WCTColumnCoding.h in Headers */ = {isa = PBXBuildFile; fileRef = 2370B10D21914ED400D3227C /* NSObject+WCTColumnCoding.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521D8AA291E9ABB009642EF /* WCTDatabase+Test.h in Headers */ = {isa = PBXBuildFile; fileRef = 39579856227FBC8A0069F985 /* WCTDatabase+Test.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521D8AB291E9ABB009642EF /* CommonCore.h in Headers */ = {isa = PBXBuildFile; fileRef = 391F7C83225DE8FD0095E82D /* CommonCore.h */; };\n\t\t7521D8AC291E9ABB009642EF /* HandleNotification.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 2360A5F520D78F1B00E4A311 /* HandleNotification.hpp */; };\n\t\t7521D8AD291E9ABB009642EF /* SyntaxCreateTableSTMT.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDC3E217DFADC006E9E73 /* SyntaxCreateTableSTMT.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521D8AE291E9ABB009642EF /* SyntaxDropTriggerSTMT.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDC4E217DFADC006E9E73 /* SyntaxDropTriggerSTMT.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521D8AF291E9ABB009642EF /* TokenizerModuleTemplate.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23B4DCD92112AC5600954D71 /* TokenizerModuleTemplate.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521D8B0291E9ABB009642EF /* Convertible.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDB6C217DFADC006E9E73 /* Convertible.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521D8B1291E9ABB009642EF /* Initializeable.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23AF4E1D20CD04E20050033C /* Initializeable.hpp */; };\n\t\t7521D8B3291E9ABB009642EF /* Recyclable.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 2316D92D21057CA700707AFC /* Recyclable.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521D8B4291E9ABB009642EF /* CoreConst.h in Headers */ = {isa = PBXBuildFile; fileRef = 237C900621D45E6700EE6E44 /* CoreConst.h */; };\n\t\t7521D8B5291E9ABB009642EF /* Cell.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23775B4620AD666900E21AB0 /* Cell.hpp */; };\n\t\t7521D8B7291E9ABB009642EF /* BasicConfig.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23F70FA520A055BD00CCE3CD /* BasicConfig.hpp */; };\n\t\t7521D8B8291E9ABB009642EF /* StatementDropIndex.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDBD2217DFADC006E9E73 /* StatementDropIndex.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521D8B9291E9ABB009642EF /* Pager.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23775B4A20AD666900E21AB0 /* Pager.hpp */; };\n\t\t7521D8BA291E9ABB009642EF /* SyntaxCreateIndexSTMT.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDC3C217DFADC006E9E73 /* SyntaxCreateIndexSTMT.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521D8BB291E9ABB009642EF /* WCTMacroUtility.h in Headers */ = {isa = PBXBuildFile; fileRef = 23B101E82090667B005D9DD3 /* WCTMacroUtility.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521D8BC291E9ABB009642EF /* Crawlable.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23775B5120AD666900E21AB0 /* Crawlable.hpp */; };\n\t\t7521D8BD291E9ABB009642EF /* LiteralValue.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDB97217DFADC006E9E73 /* LiteralValue.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521D8BF291E9ABB009642EF /* CustomConfig.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23F70FD520A07CEC00CCE3CD /* CustomConfig.hpp */; };\n\t\t7521D8C0291E9ABB009642EF /* StatementCreateTable.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDBC6217DFADC006E9E73 /* StatementCreateTable.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521D8C1291E9ABB009642EF /* ForeignKey.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDB8B217DFADC006E9E73 /* ForeignKey.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521D8C2291E9ABB009642EF /* WCTTryDisposeGuard.h in Headers */ = {isa = PBXBuildFile; fileRef = 2372E05821A2633800051D9A /* WCTTryDisposeGuard.h */; };\n\t\t7521D8C3291E9ABB009642EF /* WCDBVersion.h in Headers */ = {isa = PBXBuildFile; fileRef = 23176A8B21B912B10051ACF9 /* WCDBVersion.h */; };\n\t\t7521D8C5291E9ABB009642EF /* WCTHandle+Convenient.h in Headers */ = {isa = PBXBuildFile; fileRef = 23A3CFB3205FB1A800692F94 /* WCTHandle+Convenient.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521D8C6291E9ABB009642EF /* StatementDropTrigger.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDBD6217DFADC006E9E73 /* StatementDropTrigger.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521D8C8291E9ABB009642EF /* FTSFunction.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDB74217DFADC006E9E73 /* FTSFunction.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521D8C9291E9ABB009642EF /* WCTTransaction.h in Headers */ = {isa = PBXBuildFile; fileRef = 234DBD072064DE23000E31E8 /* WCTTransaction.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521D8CA291E9ABB009642EF /* WalRelated.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23593B7C20D3ADF80058B416 /* WalRelated.hpp */; };\n\t\t7521D8CB291E9ABB009642EF /* FactoryRelated.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23D0C36220C14ACC0001BFAE /* FactoryRelated.hpp */; };\n\t\t7521D8CC291E9ABB009642EF /* SyntaxSelectSTMT.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDC5E217DFADC006E9E73 /* SyntaxSelectSTMT.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521D8CD291E9ABB009642EF /* WCTPreparedStatement+Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 755391E02403CB9700036918 /* WCTPreparedStatement+Private.h */; };\n\t\t7521D8CE291E9ABB009642EF /* PerformanceTraceConfig.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 2360A60220D78F2B00E4A311 /* PerformanceTraceConfig.hpp */; };\n\t\t7521D8CF291E9ABB009642EF /* ColumnMeta.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 237B47AF21FEEA200059227A /* ColumnMeta.hpp */; };\n\t\t7521D8D0291E9ABB009642EF /* WCTHandle+Table.h in Headers */ = {isa = PBXBuildFile; fileRef = 23EABBE4206D08EC00241F3B /* WCTHandle+Table.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521D8D1291E9ABB009642EF /* Macro.h in Headers */ = {isa = PBXBuildFile; fileRef = 239776D0202AF2E2000A681C /* Macro.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521D8D3291E9ABB009642EF /* BusyRetryConfig.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 237A8D5E21EDBB2E003AF5BB /* BusyRetryConfig.hpp */; };\n\t\t7521D8D4291E9ABB009642EF /* Progress.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23A6D4BE20BFD7F9004F2DAA /* Progress.hpp */; };\n\t\t7521D8D5291E9ABB009642EF /* SyntaxForeignKeyClause.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDC05217DFADC006E9E73 /* SyntaxForeignKeyClause.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521D8D6291E9ABB009642EF /* SyntaxAssertion.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23545B962224E8270091C981 /* SyntaxAssertion.hpp */; };\n\t\t7521D8D8291E9ABB009642EF /* SyntaxSelectCore.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDC25217DFADC006E9E73 /* SyntaxSelectCore.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521D8D9291E9ABB009642EF /* SyntaxTableConstraint.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDC27217DFADC006E9E73 /* SyntaxTableConstraint.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521D8DA291E9ABB009642EF /* ThreadedErrors.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23F1698720B6638F009B5C47 /* ThreadedErrors.hpp */; };\n\t\t7521D8DB291E9ABB009642EF /* TableConstraint.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDBAB217DFADC006E9E73 /* TableConstraint.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521D8DC291E9ABB009642EF /* AuxiliaryFunctionConfig.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 7543DD8D271C360E00B533B4 /* AuxiliaryFunctionConfig.hpp */; };\n\t\t7521D8DD291E9ABB009642EF /* SQL.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDBA9217DFADC006E9E73 /* SQL.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521D8DF291E9ABB009642EF /* SequenceCrawler.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23D07CE920BE873E0043F4D4 /* SequenceCrawler.hpp */; };\n\t\t7521D8E0291E9ABB009642EF /* PageBasedFileHandle.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 2316D9422105D19500707AFC /* PageBasedFileHandle.hpp */; };\n\t\t7521D8E1291E9ABB009642EF /* SQLTraceConfig.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 2360A60020D78F2B00E4A311 /* SQLTraceConfig.hpp */; };\n\t\t7521D8E2291E9ABB009642EF /* Data.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23775BCC20AD72BC00E21AB0 /* Data.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521D8E3291E9ABB009642EF /* WCTDatabase.h in Headers */ = {isa = PBXBuildFile; fileRef = 23DF0A082190275B00F0B2B6 /* WCTDatabase.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521D8E4291E9ABB009642EF /* Assertion.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23775B2F20AD666900E21AB0 /* Assertion.hpp */; };\n\t\t7521D8E5291E9ABB009642EF /* WCTDatabase+Monitor.h in Headers */ = {isa = PBXBuildFile; fileRef = 23906AB7215E500100C2B717 /* WCTDatabase+Monitor.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521D8E6291E9ABB009642EF /* Filter.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDB89217DFADC006E9E73 /* Filter.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521D8E7291E9ABB009642EF /* SyntaxDropViewSTMT.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDC50217DFADC006E9E73 /* SyntaxDropViewSTMT.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521D8E8291E9ABB009642EF /* Scoreable.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 2376CB1A20DA5D3B00A68DB5 /* Scoreable.hpp */; };\n\t\t7521D8E9291E9ABB009642EF /* CaseInsensitiveList.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 39411A3E22437E7B00A388F5 /* CaseInsensitiveList.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521D8EB291E9ABB009642EF /* SyntaxForwardDeclaration.h in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDB75217DFADC006E9E73 /* SyntaxForwardDeclaration.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521D8EC291E9ABB009642EF /* WCTDatabase+Config.h in Headers */ = {isa = PBXBuildFile; fileRef = 23BBE2AB2049565600C4CBB6 /* WCTDatabase+Config.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521D8ED291E9ABB009642EF /* WCTDatabase+Repair.h in Headers */ = {isa = PBXBuildFile; fileRef = 2308F8A720E37FB0001CD9C3 /* WCTDatabase+Repair.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521D8EE291E9ABB009642EF /* MigrationInfo.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23A64D08214A458A00ED28BB /* MigrationInfo.hpp */; };\n\t\t7521D8F0291E9ABB009642EF /* StatementCreateIndex.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDBC4217DFADC006E9E73 /* StatementCreateIndex.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521D8F1291E9ABB009642EF /* WCTMigrationInfo.h in Headers */ = {isa = PBXBuildFile; fileRef = 236BACE421BF9FC900C8B4D9 /* WCTMigrationInfo.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521D8F3291E9ABB009642EF /* Interface.h in Headers */ = {isa = PBXBuildFile; fileRef = 23D4DA442085A3D300AE6D90 /* Interface.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521D8F4291E9ABB009642EF /* StringView.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 235EE9C322B63219008F6658 /* StringView.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521D8F5291E9ABB009642EF /* RepairKit.h in Headers */ = {isa = PBXBuildFile; fileRef = 23B9E66920AE6EE400CF1683 /* RepairKit.h */; };\n\t\t7521D8F6291E9ABB009642EF /* WCTTable.h in Headers */ = {isa = PBXBuildFile; fileRef = 23F340D8204D32C2007DB8AB /* WCTTable.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521D8F7291E9ABB009642EF /* OrderingTerm.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDB9B217DFADC006E9E73 /* OrderingTerm.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521D8F8291E9ABB009642EF /* SyntaxUpsertClause.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDC2B217DFADC006E9E73 /* SyntaxUpsertClause.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521D8F9291E9ABB009642EF /* Shm.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23408F0E211897AA0071E5A7 /* Shm.hpp */; };\n\t\t7521D8FA291E9ABB009642EF /* StatementDetach.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDBD0217DFADC006E9E73 /* StatementDetach.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521D8FC291E9ABB009642EF /* SubstringMatchInfo.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 7543DD91271C601F00B533B4 /* SubstringMatchInfo.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521D8FD291E9ABB009642EF /* SyntaxBeginSTMT.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDC38217DFADC006E9E73 /* SyntaxBeginSTMT.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521D8FE291E9ABB009642EF /* SyntaxUpdateSTMT.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDC60217DFADC006E9E73 /* SyntaxUpdateSTMT.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521D8FF291E9ABB009642EF /* ResultColumn.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDBA5217DFADC006E9E73 /* ResultColumn.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521D900291E9ABB009642EF /* StatementCreateTrigger.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDBC8217DFADC006E9E73 /* StatementCreateTrigger.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521D901291E9ABB009642EF /* Repairman.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EE0EB120B838E100C95998 /* Repairman.hpp */; };\n\t\t7521D902291E9ABB009642EF /* ExpressionOperable.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDB72217DFADC006E9E73 /* ExpressionOperable.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521D903291E9ABB009642EF /* HandleRelated.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 2360A5F620D78F1B00E4A311 /* HandleRelated.hpp */; };\n\t\t7521D904291E9ABB009642EF /* SyntaxOrderingTerm.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDC17217DFADC006E9E73 /* SyntaxOrderingTerm.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521D906291E9ABB009642EF /* WCTValue.h in Headers */ = {isa = PBXBuildFile; fileRef = 23F70F79209FF0EC00CCE3CD /* WCTValue.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521D907291E9ABB009642EF /* WCTDatabase+Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 23DF0A092190275B00F0B2B6 /* WCTDatabase+Private.h */; };\n\t\t7521D909291E9ABB009642EF /* WCTHandle.h in Headers */ = {isa = PBXBuildFile; fileRef = 234DBCF12064DD0B000E31E8 /* WCTHandle.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521D90A291E9ABB009642EF /* SyntaxAlterTableSTMT.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDC32217DFADC006E9E73 /* SyntaxAlterTableSTMT.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521D90B291E9ABB009642EF /* OneOrBinaryTokenizer.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 03450DB32738BBF000C4DC1B /* OneOrBinaryTokenizer.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521D90C291E9ABB009642EF /* IndexedColumn.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDB91217DFADC006E9E73 /* IndexedColumn.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521D90E291E9ABB009642EF /* WCTDatabase+Version.h in Headers */ = {isa = PBXBuildFile; fileRef = 23176A9921BA7D460051ACF9 /* WCTDatabase+Version.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521D90F291E9ABB009642EF /* TokenizerModule.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 2304B42722156CD700901953 /* TokenizerModule.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521D910291E9ABB009642EF /* AbstractHandle.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 2347378E21CBB3A800AD5E41 /* AbstractHandle.hpp */; };\n\t\t7521D911291E9ABB009642EF /* Factory.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23D0C34A20C149D80001BFAE /* Factory.hpp */; };\n\t\t7521D912291E9ABB009642EF /* WCTConvenient.h in Headers */ = {isa = PBXBuildFile; fileRef = 23FEC461206B3032001E7A3B /* WCTConvenient.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521D913291E9ABB009642EF /* SyntaxFrameSpec.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDC07217DFADC006E9E73 /* SyntaxFrameSpec.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521D914291E9ABB009642EF /* Path.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23B35C7420BFE39400425033 /* Path.hpp */; };\n\t\t7521D915291E9ABB009642EF /* Migration.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23A64D0E214A4A7000ED28BB /* Migration.hpp */; };\n\t\t7521D917291E9ABB009642EF /* SyntaxRaiseFunction.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDC1D217DFADC006E9E73 /* SyntaxRaiseFunction.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521D918291E9ABB009642EF /* StatementSelect.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDBE6217DFADC006E9E73 /* StatementSelect.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521D919291E9ABB009642EF /* SyntaxDropTableSTMT.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDC4C217DFADC006E9E73 /* SyntaxDropTableSTMT.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521D91A291E9ABB009642EF /* WCTDatabase+ChainCall.h in Headers */ = {isa = PBXBuildFile; fileRef = 23F340DC204D3482007DB8AB /* WCTDatabase+ChainCall.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521D91B291E9ABB009642EF /* SyntaxExplainSTMT.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 3960D89A2319258B00EF05D1 /* SyntaxExplainSTMT.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521D91C291E9ABB009642EF /* StatementDropView.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDBD8217DFADC006E9E73 /* StatementDropView.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521D91D291E9ABB009642EF /* StatementExplain.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 3960D89E2319288C00EF05D1 /* StatementExplain.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521D91E291E9ABB009642EF /* Backup.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23775B3F20AD666900E21AB0 /* Backup.hpp */; };\n\t\t7521D91F291E9ABB009642EF /* MasterItem.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23AD52D520DB4A3C00664B62 /* MasterItem.hpp */; };\n\t\t7521D921291E9ABB009642EF /* BindParameter.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDB7B217DFADC006E9E73 /* BindParameter.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521D922291E9ABB009642EF /* Join.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDB93217DFADC006E9E73 /* Join.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521D923291E9ABB009642EF /* HighWater.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23E7EB1C2123D58D0056B5D8 /* HighWater.hpp */; };\n\t\t7521D924291E9ABB009642EF /* SyntaxIdentifier.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDC0B217DFADC006E9E73 /* SyntaxIdentifier.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521D925291E9ABB009642EF /* Fraction.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23AD52E520DB852B00664B62 /* Fraction.hpp */; };\n\t\t7521D926291E9ABB009642EF /* StatementDropTable.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDBD4217DFADC006E9E73 /* StatementDropTable.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521D927291E9ABB009642EF /* SyntaxExpression.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDC01217DFADC006E9E73 /* SyntaxExpression.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521D928291E9ABB009642EF /* MasterCrawler.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23D07CE320BE87360043F4D4 /* MasterCrawler.hpp */; };\n\t\t7521D929291E9ABB009642EF /* WCTColumnConstraintMacro.h in Headers */ = {isa = PBXBuildFile; fileRef = 23790A7D219315D50098797F /* WCTColumnConstraintMacro.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521D92A291E9ABB009642EF /* TokenizerModules.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 2304B42D22156E1500901953 /* TokenizerModules.hpp */; };\n\t\t7521D92B291E9ABB009642EF /* QualifiedTable.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDB9F217DFADC006E9E73 /* QualifiedTable.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521D92C291E9ABB009642EF /* AutoMergeFTSIndexConfig.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 0D3AE53725416D99007B9D0E /* AutoMergeFTSIndexConfig.hpp */; };\n\t\t7521D92D291E9ABB009642EF /* Exiting.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 231C35EA21DE090500B5D3D2 /* Exiting.hpp */; };\n\t\t7521D92E291E9ABB009642EF /* Config.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23F70F9F20A055B400CCE3CD /* Config.hpp */; };\n\t\t7521D92F291E9ABB009642EF /* WCTDatabase+Handle.h in Headers */ = {isa = PBXBuildFile; fileRef = 234DBCEC2064DD0B000E31E8 /* WCTDatabase+Handle.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521D930291E9ABB009642EF /* WCTMacro.h in Headers */ = {isa = PBXBuildFile; fileRef = 2349F6931EA0D6680021EFA7 /* WCTMacro.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521D931291E9ABB009642EF /* Page.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23775B4820AD666900E21AB0 /* Page.hpp */; };\n\t\t7521D932291E9ABB009642EF /* SyntaxFilter.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDC03217DFADC006E9E73 /* SyntaxFilter.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521D933291E9ABB009642EF /* StatementRollback.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDBE2217DFADC006E9E73 /* StatementRollback.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521D934291E9ABB009642EF /* StatementAlterTable.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDBBA217DFADC006E9E73 /* StatementAlterTable.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521D935291E9ABB009642EF /* StatementPragma.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDBDC217DFADC006E9E73 /* StatementPragma.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521D936291E9ABB009642EF /* RecyclableHandle.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 2349F6251EA0D6680021EFA7 /* RecyclableHandle.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521D937291E9ABB009642EF /* SyntaxSchema.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDC23217DFADC006E9E73 /* SyntaxSchema.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521D939291E9ABB009642EF /* WCTTable+ChainCall.h in Headers */ = {isa = PBXBuildFile; fileRef = 2349F6511EA0D6680021EFA7 /* WCTTable+ChainCall.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521D93A291E9ABB009642EF /* SyntaxLiteralValue.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDC13217DFADC006E9E73 /* SyntaxLiteralValue.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521D93C291E9ABB009642EF /* StatementReindex.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDBDE217DFADC006E9E73 /* StatementReindex.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521D93D291E9ABB009642EF /* SyntaxList.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDB76217DFADC006E9E73 /* SyntaxList.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521D93E291E9ABB009642EF /* WCTTableConstraintMacro.h in Headers */ = {isa = PBXBuildFile; fileRef = 2349F6951EA0D6680021EFA7 /* WCTTableConstraintMacro.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521D940291E9ABB009642EF /* ColumnConstraint.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDB7F217DFADC006E9E73 /* ColumnConstraint.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521D941291E9ABB009642EF /* SQLiteDeclaration.h in Headers */ = {isa = PBXBuildFile; fileRef = 237A8D5721ED88DF003AF5BB /* SQLiteDeclaration.h */; };\n\t\t7521D942291E9ABB009642EF /* SyntaxEnum.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23545B9C2224E9C80091C981 /* SyntaxEnum.hpp */; };\n\t\t7521D943291E9ABB009642EF /* DBOperationNotifier.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 0DC98FD128E46049007F3796 /* DBOperationNotifier.hpp */; };\n\t\t7521D944291E9ABB009642EF /* StatementCreateView.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDBCA217DFADC006E9E73 /* StatementCreateView.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521D945291E9ABB009642EF /* SyntaxCreateVirtualTableSTMT.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDC44217DFADC006E9E73 /* SyntaxCreateVirtualTableSTMT.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521D946291E9ABB009642EF /* Shadow.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDD5F217DFB17006E9E73 /* Shadow.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521D947291E9ABB009642EF /* WCTTableCoding.h in Headers */ = {isa = PBXBuildFile; fileRef = 2349F68D1EA0D6680021EFA7 /* WCTTableCoding.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521D949291E9ABB009642EF /* WCTInsert.h in Headers */ = {isa = PBXBuildFile; fileRef = 2349F6431EA0D6680021EFA7 /* WCTInsert.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521D94A291E9ABB009642EF /* JoinConstraint.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDB95217DFADC006E9E73 /* JoinConstraint.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521D94B291E9ABB009642EF /* SyntaxReleaseSTMT.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDC58217DFADC006E9E73 /* SyntaxReleaseSTMT.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521D94C291E9ABB009642EF /* Serialization.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 2308F84E20E32A51001CD9C3 /* Serialization.hpp */; };\n\t\t7521D94D291E9ABB009642EF /* WCTIndexMacro.h in Headers */ = {isa = PBXBuildFile; fileRef = 2349F6961EA0D6680021EFA7 /* WCTIndexMacro.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521D94E291E9ABB009642EF /* WCTFoundation.h in Headers */ = {isa = PBXBuildFile; fileRef = 39A3341722B0DD9F008EA5D5 /* WCTFoundation.h */; };\n\t\t7521D94F291E9ABB009642EF /* SyntaxColumn.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDBF7217DFADC006E9E73 /* SyntaxColumn.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521D950291E9ABB009642EF /* InnerDatabase.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 2349F61C1EA0D6680021EFA7 /* InnerDatabase.hpp */; };\n\t\t7521D951291E9ABB009642EF /* WCTTag.h in Headers */ = {isa = PBXBuildFile; fileRef = 3969018A233B1B2F006EEFD4 /* WCTTag.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521D953291E9ABB009642EF /* MergeFTSIndexLogic.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 0D249BC02542B8E900B43BD9 /* MergeFTSIndexLogic.hpp */; };\n\t\t7521D954291E9ABB009642EF /* SyntaxAnalyzeSTMT.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDC34217DFADC006E9E73 /* SyntaxAnalyzeSTMT.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521D955291E9ABB009642EF /* SyntaxColumnConstraint.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDBF9217DFADC006E9E73 /* SyntaxColumnConstraint.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521D958291E9ABB009642EF /* WCTVirtualTableMacro.h in Headers */ = {isa = PBXBuildFile; fileRef = 23790A7E219315DE0098797F /* WCTVirtualTableMacro.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521D959291E9ABB009642EF /* WCTError+Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 2386B3C41ED442FE000B72F6 /* WCTError+Private.h */; };\n\t\t7521D95A291E9ABB009642EF /* SyntaxReindexSTMT.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDC56217DFADC006E9E73 /* SyntaxReindexSTMT.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521D95B291E9ABB009642EF /* SyntaxCommonTableExpression.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDBFD217DFADC006E9E73 /* SyntaxCommonTableExpression.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521D95C291E9ABB009642EF /* UpgradeableErrorProne.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23AD52F120DBAC4C00664B62 /* UpgradeableErrorProne.hpp */; };\n\t\t7521D95D291E9ABB009642EF /* WCTDelete.h in Headers */ = {isa = PBXBuildFile; fileRef = 2349F6401EA0D6680021EFA7 /* WCTDelete.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521D95E291E9ABB009642EF /* PagerRelated.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23567D5820CA823C005F1C35 /* PagerRelated.hpp */; };\n\t\t7521D95F291E9ABB009642EF /* WCTColumnBinding.h in Headers */ = {isa = PBXBuildFile; fileRef = 2349F6861EA0D6680021EFA7 /* WCTColumnBinding.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521D961291E9ABB009642EF /* Tag.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23B4DC7D2111B39200954D71 /* Tag.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521D962291E9ABB009642EF /* SQLite.h in Headers */ = {isa = PBXBuildFile; fileRef = 23AB898D215BA6DB00554DF1 /* SQLite.h */; };\n\t\t7521D963291E9ABB009642EF /* SyntaxPragma.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDC19217DFADC006E9E73 /* SyntaxPragma.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521D964291E9ABB009642EF /* WCTBinding.h in Headers */ = {isa = PBXBuildFile; fileRef = 2349F6841EA0D6680021EFA7 /* WCTBinding.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521D965291E9ABB009642EF /* WCTDatabase+Migration.h in Headers */ = {isa = PBXBuildFile; fileRef = 236BACE021BF9F6400C8B4D9 /* WCTDatabase+Migration.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521D966291E9ABB009642EF /* WCTDatabase+Convenient.h in Headers */ = {isa = PBXBuildFile; fileRef = 2349F6571EA0D6680021EFA7 /* WCTDatabase+Convenient.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521D968291E9ABB009642EF /* WCTSelect.h in Headers */ = {isa = PBXBuildFile; fileRef = 2349F64C1EA0D6680021EFA7 /* WCTSelect.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521D969291E9ABB009642EF /* StatementCreateVirtualTable.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDBCC217DFADC006E9E73 /* StatementCreateVirtualTable.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521D96A291E9ABB009642EF /* SQLiteFTS3Tokenizer.h in Headers */ = {isa = PBXBuildFile; fileRef = 234F0337227A950900DD65A2 /* SQLiteFTS3Tokenizer.h */; };\n\t\t7521D96B291E9ABB009642EF /* WCTUpdate.h in Headers */ = {isa = PBXBuildFile; fileRef = 2349F6541EA0D6680021EFA7 /* WCTUpdate.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521D96C291E9ABB009642EF /* HandlePool.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 2349F6231EA0D6680021EFA7 /* HandlePool.hpp */; };\n\t\t7521D96D291E9ABB009642EF /* StatementInsert.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDBDA217DFADC006E9E73 /* StatementInsert.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521D96E291E9ABB009642EF /* FactoryDepositor.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23D0C34C20C149D80001BFAE /* FactoryDepositor.hpp */; };\n\t\t7521D970291E9ABB009642EF /* FrameSpec.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDB8D217DFADC006E9E73 /* FrameSpec.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521D971291E9ABB009642EF /* TokenizerConfig.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23F70FBD20A055D400CCE3CD /* TokenizerConfig.hpp */; };\n\t\t7521D972291E9ABB009642EF /* SyntaxCreateViewSTMT.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDC42217DFADC006E9E73 /* SyntaxCreateViewSTMT.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521D973291E9ABB009642EF /* NSNumber+WCTColumnCoding.h in Headers */ = {isa = PBXBuildFile; fileRef = 2370B11221914ED400D3227C /* NSNumber+WCTColumnCoding.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521D975291E9ABB009642EF /* WCDBObjc.h in Headers */ = {isa = PBXBuildFile; fileRef = 2349F6BA1EA0D6680021EFA7 /* WCDBObjc.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521D976291E9ABB009642EF /* Enum.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDD5E217DFB16006E9E73 /* Enum.hpp */; };\n\t\t7521D977291E9ABB009642EF /* SyntaxDetachSTMT.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDC48217DFADC006E9E73 /* SyntaxDetachSTMT.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521D978291E9ABB009642EF /* ColumnType.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDB6B217DFADC006E9E73 /* ColumnType.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521D979291E9ABB009642EF /* WCTOptional.h in Headers */ = {isa = PBXBuildFile; fileRef = 2370B1302191533C00D3227C /* WCTOptional.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521D97A291E9ABB009642EF /* WCTMultiSelect.h in Headers */ = {isa = PBXBuildFile; fileRef = 2349F6471EA0D6680021EFA7 /* WCTMultiSelect.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521D97B291E9ABB009642EF /* SyntaxDeleteSTMT.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDC46217DFADC006E9E73 /* SyntaxDeleteSTMT.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521D97C291E9ABB009642EF /* WCTMigrationInfo+Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 2395582421C143BB000C85E1 /* WCTMigrationInfo+Private.h */; };\n\t\t7521D97E291E9ABB009642EF /* StatementSavepoint.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDBE4217DFADC006E9E73 /* StatementSavepoint.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521D982291E9ABB009642EF /* FullCrawler.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23775B3720AD666900E21AB0 /* FullCrawler.hpp */; };\n\t\t7521D983291E9ABB009642EF /* WCTDatabase+Table.h in Headers */ = {isa = PBXBuildFile; fileRef = 2349F69A1EA0D6680021EFA7 /* WCTDatabase+Table.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521D984291E9ABB009642EF /* SQLiteAssembler.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23D0C30D20C125420001BFAE /* SQLiteAssembler.hpp */; };\n\t\t7521D985291E9ABB009642EF /* WCTSelectable.h in Headers */ = {isa = PBXBuildFile; fileRef = 2349F64F1EA0D6680021EFA7 /* WCTSelectable.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521D986291E9ABB009642EF /* WCTRuntimeObjCAccessor.h in Headers */ = {isa = PBXBuildFile; fileRef = 2349F6811EA0D6680021EFA7 /* WCTRuntimeObjCAccessor.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521D987291E9ABB009642EF /* PinyinTokenizer.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 03450DB72738C8F800C4DC1B /* PinyinTokenizer.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521D988291E9ABB009642EF /* StatementAttach.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDBBE217DFADC006E9E73 /* StatementAttach.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521D989291E9ABB009642EF /* ColumnDef.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDB81217DFADC006E9E73 /* ColumnDef.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521D98A291E9ABB009642EF /* WCTRuntimeCppAccessor.h in Headers */ = {isa = PBXBuildFile; fileRef = 2349F6801EA0D6680021EFA7 /* WCTRuntimeCppAccessor.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521D98B291E9ABB009642EF /* WCTTableProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = 3969018E233B20BC006EEFD4 /* WCTTableProtocol.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521D98C291E9ABB009642EF /* Wal.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EB91DD20CA1EBE00ECF668 /* Wal.hpp */; };\n\t\t7521D98D291E9ABB009642EF /* SyntaxSavepointSTMT.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDC5C217DFADC006E9E73 /* SyntaxSavepointSTMT.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521D98E291E9ABB009642EF /* AutoMigrateConfig.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23301BF42298FE9A00A8AB5A /* AutoMigrateConfig.hpp */; };\n\t\t7521D990291E9ABB009642EF /* UniqueList.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 237A65F220F731DF008B4771 /* UniqueList.hpp */; };\n\t\t7521D991291E9ABB009642EF /* HandleStatement.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 2370980920590CA700E768B4 /* HandleStatement.hpp */; };\n\t\t7521D992291E9ABB009642EF /* FTS5AuxiliaryFunctionTemplate.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 7543DD82271C2F3B00B533B4 /* FTS5AuxiliaryFunctionTemplate.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521D993291E9ABB009642EF /* WCTCommon.h in Headers */ = {isa = PBXBuildFile; fileRef = 23BBE2A5204955CD00C4CBB6 /* WCTCommon.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521D994291E9ABB009642EF /* SQLiteLocker.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23C7559020DCF90F00031A93 /* SQLiteLocker.hpp */; };\n\t\t7521D995291E9ABB009642EF /* NSData+WCTColumnCoding.h in Headers */ = {isa = PBXBuildFile; fileRef = 2370B11521914ED500D3227C /* NSData+WCTColumnCoding.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521D996291E9ABB009642EF /* WCTTable+Convenient.h in Headers */ = {isa = PBXBuildFile; fileRef = 2349F6591EA0D6680021EFA7 /* WCTTable+Convenient.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521D997291E9ABB009642EF /* ConvertibleImplementation.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDB6E217DFADC006E9E73 /* ConvertibleImplementation.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521D998291E9ABB009642EF /* Value.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 03E5CC6D28A3BDF3005353D9 /* Value.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521D999291E9ABB009642EF /* RaiseFunction.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDBA1217DFADC006E9E73 /* RaiseFunction.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521D99A291E9ABB009642EF /* InnerHandle.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 39B524DB2304F9A1001DF52D /* InnerHandle.hpp */; };\n\t\t7521D99B291E9ABB009642EF /* WCTFTSTokenizerUtil.h in Headers */ = {isa = PBXBuildFile; fileRef = 23577F771F74F4E800D31C05 /* WCTFTSTokenizerUtil.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521D99C291E9ABB009642EF /* Global.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 235FBE9422914E0D005C7723 /* Global.hpp */; };\n\t\t7521D99D291E9ABB009642EF /* StatementBegin.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDBC0217DFADC006E9E73 /* StatementBegin.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521D99E291E9ABB009642EF /* SyntaxQualifiedTableName.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDC1B217DFADC006E9E73 /* SyntaxQualifiedTableName.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521D99F291E9ABB009642EF /* WCTBaseAccessor.h in Headers */ = {isa = PBXBuildFile; fileRef = 2349F67B1EA0D6680021EFA7 /* WCTBaseAccessor.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521D9A0291E9ABB009642EF /* SyntaxJoinClause.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDC0F217DFADC006E9E73 /* SyntaxJoinClause.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521D9DE291E9ABB009642EF /* NSString+WCTColumnCoding.h in Headers */ = {isa = PBXBuildFile; fileRef = 2370B10B21914ED400D3227C /* NSString+WCTColumnCoding.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521D9DF291E9ABB009642EF /* WCTObjCAccessor.h in Headers */ = {isa = PBXBuildFile; fileRef = 2349F67D1EA0D6680021EFA7 /* WCTObjCAccessor.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521D9E0291E9ABB009642EF /* CoreFunction.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDB70217DFADC006E9E73 /* CoreFunction.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521D9E1291E9ABB009642EF /* Frame.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23567CF920CA3889005F1C35 /* Frame.hpp */; };\n\t\t7521D9E2291E9ABB009642EF /* FTSConst.h in Headers */ = {isa = PBXBuildFile; fileRef = 754014C2290BEDA600EA8D33 /* FTSConst.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521D9E3291E9ABB009642EF /* WCTChainCall+Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 23776CA5218C41E600E985DC /* WCTChainCall+Private.h */; };\n\t\t7521D9E6291E9ABB009642EF /* WCTProperty.h in Headers */ = {isa = PBXBuildFile; fileRef = 2349F6901EA0D6680021EFA7 /* WCTProperty.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521D9E7291E9ABB009642EF /* Thread.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 390E1C5B2296414C00C24598 /* Thread.hpp */; };\n\t\t7521D9E8291E9ABB009642EF /* WCTCppAccessor.h in Headers */ = {isa = PBXBuildFile; fileRef = 2349F67C1EA0D6680021EFA7 /* WCTCppAccessor.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521D9E9291E9ABB009642EF /* BaseBinding.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 7537E5D028B939240077D92B /* BaseBinding.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521D9EA291E9ABB009642EF /* FileHandle.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 2308F84C20E32A51001CD9C3 /* FileHandle.hpp */; };\n\t\t7521D9EC291E9ABB009642EF /* StatementDelete.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDBCE217DFADC006E9E73 /* StatementDelete.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521D9EF291E9ABB009642EF /* OperationQueue.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 3934DAEA229B6659008A6AEC /* OperationQueue.hpp */; };\n\t\t7521D9F0291E9ABB009642EF /* WindowDef.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDBB1217DFADC006E9E73 /* WindowDef.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521D9F1291E9ABB009642EF /* WCTDatabase+FTS.h in Headers */ = {isa = PBXBuildFile; fileRef = 2327414E1F6FBD50004E96F7 /* WCTDatabase+FTS.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521D9F3291E9ABB009642EF /* WCTPropertyMacro.h in Headers */ = {isa = PBXBuildFile; fileRef = 2349F6941EA0D6680021EFA7 /* WCTPropertyMacro.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521D9F4291E9ABB009642EF /* SyntaxTableOrSubquery.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDC29217DFADC006E9E73 /* SyntaxTableOrSubquery.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521D9F5291E9ABB009642EF /* StatementRelease.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDBE0217DFADC006E9E73 /* StatementRelease.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521D9F6291E9ABB009642EF /* WCTORM.h in Headers */ = {isa = PBXBuildFile; fileRef = 2349F6981EA0D6680021EFA7 /* WCTORM.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521D9F7291E9ABB009642EF /* Notifier.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23775B3320AD666900E21AB0 /* Notifier.hpp */; };\n\t\t7521D9F8291E9ABB009642EF /* SyntaxCreateTriggerSTMT.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDC40217DFADC006E9E73 /* SyntaxCreateTriggerSTMT.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521D9FA291E9ABB009642EF /* SyntaxIndexedColumn.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDC0D217DFADC006E9E73 /* SyntaxIndexedColumn.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521D9FB291E9ABB009642EF /* SyntaxCommonConst.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 238C177C21CA2190003B6D26 /* SyntaxCommonConst.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521D9FC291E9ABB009642EF /* StatementUpdate.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDBE8217DFADC006E9E73 /* StatementUpdate.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521D9FD291E9ABB009642EF /* SQLiteBase.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23C7559920DD17B100031A93 /* SQLiteBase.hpp */; };\n\t\t7521D9FE291E9ABB009642EF /* Expression.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDB87217DFADC006E9E73 /* Expression.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521D9FF291E9ABB009642EF /* WCTDatabase+File.h in Headers */ = {isa = PBXBuildFile; fileRef = 2349F66B1EA0D6680021EFA7 /* WCTDatabase+File.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521DA00291E9ABB009642EF /* SyntaxPragmaSTMT.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDC54217DFADC006E9E73 /* SyntaxPragmaSTMT.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521DA01291E9ABB009642EF /* Upsert.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDBAF217DFADC006E9E73 /* Upsert.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521DA02291E9ABB009642EF /* AuxiliaryFunctionModule.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 7543DD85271C2FD000B533B4 /* AuxiliaryFunctionModule.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521DA03291E9ABB009642EF /* WCTChainCall.h in Headers */ = {isa = PBXBuildFile; fileRef = 234DBD0B2064E045000E31E8 /* WCTChainCall.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521DA04291E9ABB009642EF /* BaseTokenizerUtil.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 75B698D4290AD4C0006E1F8F /* BaseTokenizerUtil.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521DA05291E9ABB009642EF /* Configs.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23F70FC320A0618100CCE3CD /* Configs.hpp */; };\n\t\t7521DA06291E9ABB009642EF /* WCTBuiltin.h in Headers */ = {isa = PBXBuildFile; fileRef = 233A25D2219933D800054EC4 /* WCTBuiltin.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521DA07291E9ABB009642EF /* WCTDatabase+Memory.h in Headers */ = {isa = PBXBuildFile; fileRef = 23BBE2AF2049576D00C4CBB6 /* WCTDatabase+Memory.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521DA08291E9ABB009642EF /* SharedThreadedErrorProne.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23567D7420CA91FF005F1C35 /* SharedThreadedErrorProne.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521DA09291E9ABB009642EF /* Range.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 2314AE7021070A1700244D39 /* Range.hpp */; };\n\t\t7521DA0A291E9ABB009642EF /* SyntaxResultColumn.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDC21217DFADC006E9E73 /* SyntaxResultColumn.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521DA0B291E9ABB009642EF /* FTSError.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 03EA88CD27D5F05D0075C7BD /* FTSError.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521DA0C291E9ABB009642EF /* Mechanic.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23775B4320AD666900E21AB0 /* Mechanic.hpp */; };\n\t\t7521DA0D291E9ABB009642EF /* WCTMaster+WCTTableCoding.h in Headers */ = {isa = PBXBuildFile; fileRef = 2370B11121914ED400D3227C /* WCTMaster+WCTTableCoding.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521DA0F291E9ABB009642EF /* WCTPreparedStatement.h in Headers */ = {isa = PBXBuildFile; fileRef = 757457032402D614005E3682 /* WCTPreparedStatement.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521DA11291E9ABB009642EF /* SyntaxJoinConstraint.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDC11217DFADC006E9E73 /* SyntaxJoinConstraint.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521DA12291E9ABB009642EF /* ErrorProne.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23567D4520CA7DBC005F1C35 /* ErrorProne.hpp */; };\n\t\t7521DA13291E9ABB009642EF /* WCTRuntimeBaseAccessor.h in Headers */ = {isa = PBXBuildFile; fileRef = 2349F67E1EA0D6680021EFA7 /* WCTRuntimeBaseAccessor.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521DA14291E9ABB009642EF /* StatementCommit.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDBC2217DFADC006E9E73 /* StatementCommit.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521DA15291E9ABB009642EF /* SyntaxColumnDef.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDBFB217DFADC006E9E73 /* SyntaxColumnDef.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521DA16291E9ABB009642EF /* LRUCache.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 2316D9482105D21500707AFC /* LRUCache.hpp */; };\n\t\t7521DA17291E9ABB009642EF /* WCTHandle+Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 234DBCF02064DD0B000E31E8 /* WCTHandle+Private.h */; };\n\t\t7521DA18291E9ABB009642EF /* StatementVacuum.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDBEA217DFADC006E9E73 /* StatementVacuum.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521DA19291E9ABB009642EF /* Column.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDB7D217DFADC006E9E73 /* Column.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521DA1A291E9ABB009642EF /* NSNull+WCTColumnCoding.h in Headers */ = {isa = PBXBuildFile; fileRef = 2370B11821914ED500D3227C /* NSNull+WCTColumnCoding.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521DA1B291E9ABB009642EF /* TimedQueue.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 239776CE202AF2E2000A681C /* TimedQueue.hpp */; };\n\t\t7521DA1D291E9ABB009642EF /* Time.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23567D7A20CA93C5005F1C35 /* Time.hpp */; };\n\t\t7521DA1E291E9ABB009642EF /* FileManager.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23B9E67320AE733A00CF1683 /* FileManager.hpp */; };\n\t\t7521DA1F291E9ABB009642EF /* WCTConvertible.h in Headers */ = {isa = PBXBuildFile; fileRef = 234EF46C2015CFDE00B81929 /* WCTConvertible.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521DA20291E9ABB009642EF /* WCTTable+Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 2349F69E1EA0D6680021EFA7 /* WCTTable+Private.h */; };\n\t\t7521DA21291E9ABB009642EF /* WCDBError.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23775B3120AD666900E21AB0 /* WCDBError.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521DA22291E9ABB009642EF /* DatabasePool.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23D96B912050DED700DB5E93 /* DatabasePool.hpp */; };\n\t\t7521DA23291E9ABB009642EF /* SyntaxWindowDef.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDC2D217DFADC006E9E73 /* SyntaxWindowDef.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521DA24291E9ABB009642EF /* WCTMaster.h in Headers */ = {isa = PBXBuildFile; fileRef = 2370B11021914ED400D3227C /* WCTMaster.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521DA25291E9ABB009642EF /* TableOrSubquery.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDBAD217DFADC006E9E73 /* TableOrSubquery.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521DA26291E9ABB009642EF /* NSDate+WCTColumnCoding.h in Headers */ = {isa = PBXBuildFile; fileRef = 2370B10F21914ED400D3227C /* NSDate+WCTColumnCoding.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521DA27291E9ABB009642EF /* Statement.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDBB8217DFADC006E9E73 /* Statement.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521DA28291E9ABB009642EF /* ThreadLocal.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23F0FEB2215F5E9A008399FB /* ThreadLocal.hpp */; };\n\t\t7521DA29291E9ABB009642EF /* Schema.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDBA7217DFADC006E9E73 /* Schema.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521DA2A291E9ABB009642EF /* SyntaxDropIndexSTMT.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDC4A217DFADC006E9E73 /* SyntaxDropIndexSTMT.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521DA2B291E9ABB009642EF /* Assemble.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 39C70CC62313E20F002D773C /* Assemble.hpp */; };\n\t\t7521DA2C291E9ABB009642EF /* WCTDatabase+Transaction.h in Headers */ = {isa = PBXBuildFile; fileRef = 234DBCFF2064DE04000E31E8 /* WCTDatabase+Transaction.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521DA2E291E9ABB009642EF /* SyntaxBindParameter.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDBF5217DFADC006E9E73 /* SyntaxBindParameter.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521DA2F291E9ABB009642EF /* Lock.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23F0FEB1215F5E9A008399FB /* Lock.hpp */; };\n\t\t7521DA30291E9ABB009642EF /* FactoryRetriever.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23D0C35020C149D80001BFAE /* FactoryRetriever.hpp */; };\n\t\t7521DA31291E9ABB009642EF /* WCTResultColumn.h in Headers */ = {isa = PBXBuildFile; fileRef = 2396EB0B21801BD60079066C /* WCTResultColumn.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521DA32291E9ABB009642EF /* WCTHandle+Transaction.h in Headers */ = {isa = PBXBuildFile; fileRef = 234DBD012064DE04000E31E8 /* WCTHandle+Transaction.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521DA33291E9ABB009642EF /* AutoCheckpointConfig.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 3934DB25229B951C008A6AEC /* AutoCheckpointConfig.hpp */; };\n\t\t7521DA34291E9ABB009642EF /* WCTColumnCoding.h in Headers */ = {isa = PBXBuildFile; fileRef = 3932B9FC25232D9F0094F3F8 /* WCTColumnCoding.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521DA35291E9ABB009642EF /* SyntaxVacuumSTMT.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDC62217DFADC006E9E73 /* SyntaxVacuumSTMT.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521DA36291E9ABB009642EF /* Material.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23775B4120AD666900E21AB0 /* Material.hpp */; };\n\t\t7521DA37291E9ABB009642EF /* SyntaxInsertSTMT.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDC52217DFADC006E9E73 /* SyntaxInsertSTMT.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521DA38291E9ABB009642EF /* AggregateFunction.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDB69217DFADC006E9E73 /* AggregateFunction.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521DA39291E9ABB009642EF /* WCTError.h in Headers */ = {isa = PBXBuildFile; fileRef = 2386B3C21ED442FE000B72F6 /* WCTError.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521DA3A291E9ABB009642EF /* WCTSelectable+Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 2349F64E1EA0D6680021EFA7 /* WCTSelectable+Private.h */; };\n\t\t7521DA3B291E9ABB009642EF /* FactoryRenewer.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23DD76BC20CF78C800E9B451 /* FactoryRenewer.hpp */; };\n\t\t7521DA3C291E9ABB009642EF /* StatementAnalyze.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDBBC217DFADC006E9E73 /* StatementAnalyze.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521DA3D291E9ABB009642EF /* FactoryBackup.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23D0C38C20C17CAE0001BFAE /* FactoryBackup.hpp */; };\n\t\t7521DA3E291E9ABB009642EF /* CipherConfig.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23F70FAB20A055C300CCE3CD /* CipherConfig.hpp */; };\n\t\t7521DA3F291E9ABB009642EF /* SyntaxRollbackSTMT.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDC5A217DFADC006E9E73 /* SyntaxRollbackSTMT.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521DA58291EA349009642EF /* SQL.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDBA8217DFADC006E9E73 /* SQL.cpp */; };\n\t\t7521DA59291EA349009642EF /* HighWater.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23E7EB1B2123D58D0056B5D8 /* HighWater.cpp */; };\n\t\t7521DA5A291EA349009642EF /* ConvertibleImplementation.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDB6D217DFADC006E9E73 /* ConvertibleImplementation.cpp */; };\n\t\t7521DA5B291EA349009642EF /* Scoreable.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2376CB1920DA5D3B00A68DB5 /* Scoreable.cpp */; };\n\t\t7521DA5C291EA349009642EF /* StatementCreateView.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDBC9217DFADC006E9E73 /* StatementCreateView.cpp */; };\n\t\t7521DA5D291EA349009642EF /* MappedData.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2316D92E21057CA700707AFC /* MappedData.cpp */; };\n\t\t7521DA5E291EA349009642EF /* Backup.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23775B3E20AD666900E21AB0 /* Backup.cpp */; };\n\t\t7521DA5F291EA349009642EF /* Operable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E1659827F42D6500D2C926 /* Operable.swift */; };\n\t\t7521DA60291EA349009642EF /* Master.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E165BF27F42D6500D2C926 /* Master.swift */; };\n\t\t7521DA61291EA349009642EF /* PinyinTokenizer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 03450DB62738C8F800C4DC1B /* PinyinTokenizer.cpp */; };\n\t\t7521DA62291EA349009642EF /* TableOrSubquery.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E165A827F42D6500D2C926 /* TableOrSubquery.swift */; };\n\t\t7521DA63291EA349009642EF /* ColumnConstraint.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75A46C062843273A00B58207 /* ColumnConstraint.swift */; };\n\t\t7521DA64291EA349009642EF /* SQLTraceConfig.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2360A5FF20D78F2B00E4A311 /* SQLTraceConfig.cpp */; };\n\t\t7521DA66291EA349009642EF /* SyntaxPragma.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDC18217DFADC006E9E73 /* SyntaxPragma.cpp */; };\n\t\t7521DA67291EA349009642EF /* ResultColumn.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E1659527F42D6500D2C926 /* ResultColumn.swift */; };\n\t\t7521DA68291EA349009642EF /* Factory.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23D0C34920C149D80001BFAE /* Factory.cpp */; };\n\t\t7521DA6B291EA349009642EF /* Statement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3962FFC723051429008934D4 /* Statement.cpp */; };\n\t\t7521DA6C291EA349009642EF /* FactoryBackup.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23D0C38B20C17CAE0001BFAE /* FactoryBackup.cpp */; };\n\t\t7521DA6D291EA349009642EF /* FrameSpecBridge.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 752594E3285226C00068A602 /* FrameSpecBridge.cpp */; };\n\t\t7521DA6E291EA349009642EF /* CustomConfig.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23F70FD420A07CEC00CCE3CD /* CustomConfig.cpp */; };\n\t\t7521DA6F291EA349009642EF /* StatementDropView.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDBD7217DFADC006E9E73 /* StatementDropView.cpp */; };\n\t\t7521DA70291EA349009642EF /* Config.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2327BC21220944D80078A85B /* Config.cpp */; };\n\t\t7521DA73291EA349009642EF /* Tag.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23B4DC7C2111B39100954D71 /* Tag.cpp */; };\n\t\t7521DA74291EA349009642EF /* SyntaxSavepointSTMT.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDC5B217DFADC006E9E73 /* SyntaxSavepointSTMT.cpp */; };\n\t\t7521DA75291EA349009642EF /* SyntaxDeleteSTMT.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDC45217DFADC006E9E73 /* SyntaxDeleteSTMT.cpp */; };\n\t\t7521DA76291EA349009642EF /* SyntaxCommitSTMT.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDC39217DFADC006E9E73 /* SyntaxCommitSTMT.cpp */; };\n\t\t7521DA77291EA349009642EF /* UpdateInterface.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75CD026A28CF8EF90071B6C3 /* UpdateInterface.swift */; };\n\t\t7521DA78291EA349009642EF /* StatementCreateViewBridge.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 75EB1A08287F0BDA00AA62F7 /* StatementCreateViewBridge.cpp */; };\n\t\t7521DA79291EA349009642EF /* TableCodable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E165D127F42D6500D2C926 /* TableCodable.swift */; };\n\t\t7521DA7A291EA349009642EF /* Notifier.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23775B3220AD666900E21AB0 /* Notifier.cpp */; };\n\t\t7521DA7B291EA349009642EF /* StatementInsert.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E1659327F42D6500D2C926 /* StatementInsert.swift */; };\n\t\t7521DA7C291EA349009642EF /* SyntaxDropViewSTMT.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDC4F217DFADC006E9E73 /* SyntaxDropViewSTMT.cpp */; };\n\t\t7521DA7D291EA349009642EF /* StatementPragma.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E165BA27F42D6500D2C926 /* StatementPragma.swift */; };\n\t\t7521DA7E291EA349009642EF /* Value.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E165AA27F42D6500D2C926 /* Value.swift */; };\n\t\t7521DA7F291EA349009642EF /* OrderingTerm.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDB9A217DFADC006E9E73 /* OrderingTerm.cpp */; };\n\t\t7521DA80291EA349009642EF /* StatementRollback.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E165B027F42D6500D2C926 /* StatementRollback.swift */; };\n\t\t7521DA81291EA349009642EF /* ColumnType.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDB6A217DFADC006E9E73 /* ColumnType.cpp */; };\n\t\t7521DA83291EA349009642EF /* StatementAttach.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDBBD217DFADC006E9E73 /* StatementAttach.cpp */; };\n\t\t7521DA84291EA349009642EF /* Fraction.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23AD52E420DB852B00664B62 /* Fraction.cpp */; };\n\t\t7521DA85291EA349009642EF /* ColumnDefBridge.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 03E8227E28447B940072CA57 /* ColumnDefBridge.cpp */; };\n\t\t7521DA86291EA349009642EF /* SyntaxTableConstraint.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDC26217DFADC006E9E73 /* SyntaxTableConstraint.cpp */; };\n\t\t7521DA87291EA349009642EF /* SequenceCrawler.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23D07CE820BE873E0043F4D4 /* SequenceCrawler.cpp */; };\n\t\t7521DA88291EA349009642EF /* VirtualTableConfig.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75C440A1291D116C00D74EB7 /* VirtualTableConfig.swift */; };\n\t\t7521DA89291EA349009642EF /* StatementReleaseBridge.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 75F4DE412883FD6A00760DC3 /* StatementReleaseBridge.cpp */; };\n\t\t7521DA8A291EA349009642EF /* StatementDropView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75EB1970287F0A2600AA62F7 /* StatementDropView.swift */; };\n\t\t7521DA8B291EA349009642EF /* TableDecoder.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E165D427F42D6500D2C926 /* TableDecoder.swift */; };\n\t\t7521DA8C291EA349009642EF /* TableEncoder.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E165D327F42D6500D2C926 /* TableEncoder.swift */; };\n\t\t7521DA8D291EA349009642EF /* StatementDropTrigger.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDBD5217DFADC006E9E73 /* StatementDropTrigger.cpp */; };\n\t\t7521DA8E291EA349009642EF /* ExpressionOperable.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDB71217DFADC006E9E73 /* ExpressionOperable.cpp */; };\n\t\t7521DA8F291EA349009642EF /* StatementDetach.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E1659427F42D6500D2C926 /* StatementDetach.swift */; };\n\t\t7521DA90291EA349009642EF /* SQLiteLocker.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23C7558F20DCF90F00031A93 /* SQLiteLocker.cpp */; };\n\t\t7521DA91291EA349009642EF /* PreparedStatement.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E165A427F42D6500D2C926 /* PreparedStatement.swift */; };\n\t\t7521DA93291EA349009642EF /* Column.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E165A627F42D6500D2C926 /* Column.swift */; };\n\t\t7521DA94291EA349009642EF /* StatementUpdate.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDBE7217DFADC006E9E73 /* StatementUpdate.cpp */; };\n\t\t7521DA95291EA349009642EF /* SyntaxResultColumn.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDC20217DFADC006E9E73 /* SyntaxResultColumn.cpp */; };\n\t\t7521DA96291EA349009642EF /* Initializeable.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23AF4E1C20CD04E20050033C /* Initializeable.cpp */; };\n\t\t7521DA97291EA349009642EF /* PageBasedFileHandle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2316D9412105D19500707AFC /* PageBasedFileHandle.cpp */; };\n\t\t7521DA98291EA349009642EF /* OrderingTerm.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E1659E27F42D6500D2C926 /* OrderingTerm.swift */; };\n\t\t7521DA99291EA349009642EF /* Progress.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23A6D4BD20BFD7F9004F2DAA /* Progress.cpp */; };\n\t\t7521DA9A291EA349009642EF /* Mechanic.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23775B4220AD666900E21AB0 /* Mechanic.cpp */; };\n\t\t7521DA9D291EA349009642EF /* SyntaxUpdateSTMT.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDC5F217DFADC006E9E73 /* SyntaxUpdateSTMT.cpp */; };\n\t\t7521DA9E291EA349009642EF /* StatementReindexBridge.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 75F4DE3D2883F0A800760DC3 /* StatementReindexBridge.cpp */; };\n\t\t7521DA9F291EA349009642EF /* Selectable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E165CB27F42D6500D2C926 /* Selectable.swift */; };\n\t\t7521DAA1291EA349009642EF /* StatementCreateIndex.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDBC3217DFADC006E9E73 /* StatementCreateIndex.cpp */; };\n\t\t7521DAA3291EA349009642EF /* StatementDetach.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDBCF217DFADC006E9E73 /* StatementDetach.cpp */; };\n\t\t7521DAA4291EA349009642EF /* ColumnConstraintBridge.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 75A46BFE284310CE00B58207 /* ColumnConstraintBridge.cpp */; };\n\t\t7521DAA5291EA349009642EF /* StatementAnalyze.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDBBB217DFADC006E9E73 /* StatementAnalyze.cpp */; };\n\t\t7521DAA6291EA349009642EF /* IndexConfig.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75C44097291CE24900D74EB7 /* IndexConfig.swift */; };\n\t\t7521DAA8291EA349009642EF /* FTSFunction.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDB73217DFADC006E9E73 /* FTSFunction.cpp */; };\n\t\t7521DAA9291EA349009642EF /* RecyclableHandle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2349F6241EA0D6680021EFA7 /* RecyclableHandle.cpp */; };\n\t\t7521DAAA291EA349009642EF /* ErrorBridge.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03C2EAEC27F8382200B41169 /* ErrorBridge.swift */; };\n\t\t7521DAAC291EA349009642EF /* StatementExplain.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E1659227F42D6500D2C926 /* StatementExplain.swift */; };\n\t\t7521DAAD291EA349009642EF /* ResultColumn.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDBA4217DFADC006E9E73 /* ResultColumn.cpp */; };\n\t\t7521DAAE291EA349009642EF /* StatementRollbackBridge.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 75F4DE452884032600760DC3 /* StatementRollbackBridge.cpp */; };\n\t\t7521DAAF291EA349009642EF /* FullCrawler.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23775B3620AD666900E21AB0 /* FullCrawler.cpp */; };\n\t\t7521DAB0291EA349009642EF /* SyntaxVacuumSTMT.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDC61217DFADC006E9E73 /* SyntaxVacuumSTMT.cpp */; };\n\t\t7521DAB1291EA349009642EF /* ForeignKey.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E1659D27F42D6500D2C926 /* ForeignKey.swift */; };\n\t\t7521DAB2291EA349009642EF /* TableCRUDInterface.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E165C827F42D6500D2C926 /* TableCRUDInterface.swift */; };\n\t\t7521DAB3291EA349009642EF /* StatementCreateTable.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDBC5217DFADC006E9E73 /* StatementCreateTable.cpp */; };\n\t\t7521DAB4291EA349009642EF /* HandleNotification.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2360A5F420D78F1B00E4A311 /* HandleNotification.cpp */; };\n\t\t7521DAB5291EA349009642EF /* SequenceItem.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23AD52DB20DB56D200664B62 /* SequenceItem.cpp */; };\n\t\t7521DAB6291EA349009642EF /* AuxiliaryFunctionModule.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7543DD84271C2FD000B533B4 /* AuxiliaryFunctionModule.cpp */; };\n\t\t7521DAB9291EA349009642EF /* StatementDropTable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E165A327F42D6500D2C926 /* StatementDropTable.swift */; };\n\t\t7521DABA291EA349009642EF /* StatementAlterTable.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDBB9217DFADC006E9E73 /* StatementAlterTable.cpp */; };\n\t\t7521DABB291EA349009642EF /* CipherConfig.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23F70FAA20A055C300CCE3CD /* CipherConfig.cpp */; };\n\t\t7521DABC291EA349009642EF /* FactoryRelated.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23D0C36120C14ACC0001BFAE /* FactoryRelated.cpp */; };\n\t\t7521DABD291EA349009642EF /* ForeignKeyConfig.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75C4409F291D108D00D74EB7 /* ForeignKeyConfig.swift */; };\n\t\t7521DABE291EA349009642EF /* Global.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 235FBE9322914E0D005C7723 /* Global.cpp */; };\n\t\t7521DAC0291EA349009642EF /* FTSBridge.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 750DC0692913DE7300F19044 /* FTSBridge.cpp */; };\n\t\t7521DAC1291EA349009642EF /* MultiUniqueConfig.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75C4409B291D0B4F00D74EB7 /* MultiUniqueConfig.swift */; };\n\t\t7521DAC2291EA349009642EF /* ResultColumnBridge.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 75AF6AE7285594A100A7C43D /* ResultColumnBridge.cpp */; };\n\t\t7521DAC3291EA349009642EF /* StatementCreateTrigger.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03EE3A50287FCECF00C8F0B3 /* StatementCreateTrigger.swift */; };\n\t\t7521DAC4291EA349009642EF /* SyntaxDropTriggerSTMT.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDC4D217DFADC006E9E73 /* SyntaxDropTriggerSTMT.cpp */; };\n\t\t7521DAC5291EA349009642EF /* UpsertBridge.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 75AF6AEF2855C8BF00A7C43D /* UpsertBridge.cpp */; };\n\t\t7521DAC6291EA349009642EF /* AsyncQueue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23B4DCDF2112B03C00954D71 /* AsyncQueue.cpp */; };\n\t\t7521DAC7291EA349009642EF /* SyntaxUpsertClause.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDC2A217DFADC006E9E73 /* SyntaxUpsertClause.cpp */; };\n\t\t7521DAC9291EA349009642EF /* OrderingTermBridge.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 75A46C0D2843B3BC00B58207 /* OrderingTermBridge.cpp */; };\n\t\t7521DACA291EA349009642EF /* Expression.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDB86217DFADC006E9E73 /* Expression.cpp */; };\n\t\t7521DACB291EA349009642EF /* Lock.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E165EE27F42D6500D2C926 /* Lock.swift */; };\n\t\t7521DACC291EA349009642EF /* SyntaxPragmaSTMT.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDC53217DFADC006E9E73 /* SyntaxPragmaSTMT.cpp */; };\n\t\t7521DACD291EA349009642EF /* CodingTableKey.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E165D227F42D6500D2C926 /* CodingTableKey.swift */; };\n\t\t7521DAD0291EA349009642EF /* WinqBridge.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 03261310283F5E0300836E0F /* WinqBridge.cpp */; };\n\t\t7521DAD1291EA349009642EF /* ErrorBridge.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0393BEDF27F6EDAC0058B295 /* ErrorBridge.cpp */; };\n\t\t7521DAD2291EA349009642EF /* Identifier.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03261363283F6CFB00836E0F /* Identifier.swift */; };\n\t\t7521DAD3291EA349009642EF /* RaiseFunction.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75C10344284530BF0006BBCB /* RaiseFunction.swift */; };\n\t\t7521DAD4291EA349009642EF /* StatementAnalyzeBridge.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 03DCB5E4286C2E5300CBC75D /* StatementAnalyzeBridge.cpp */; };\n\t\t7521DAD6291EA349009642EF /* ColumnTypeDecoder.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E165D027F42D6500D2C926 /* ColumnTypeDecoder.swift */; };\n\t\t7521DAD7291EA349009642EF /* Redirectable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E165D827F42D6500D2C926 /* Redirectable.swift */; };\n\t\t7521DAD8291EA349009642EF /* StatementExplainBridge.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 75F4DE312883E43C00760DC3 /* StatementExplainBridge.cpp */; };\n\t\t7521DAD9291EA349009642EF /* JoinConstraint.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDB94217DFADC006E9E73 /* JoinConstraint.cpp */; };\n\t\t7521DADA291EA349009642EF /* StatementDropTriggerBridge.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 75EB1963287F068200AA62F7 /* StatementDropTriggerBridge.cpp */; };\n\t\t7521DADC291EA349009642EF /* StatementCreateIndexBridge.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 03DCB5F0286C480900CBC75D /* StatementCreateIndexBridge.cpp */; };\n\t\t7521DADD291EA349009642EF /* AutoMigrateConfig.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23301BF32298FE9A00A8AB5A /* AutoMigrateConfig.cpp */; };\n\t\t7521DADE291EA349009642EF /* TableOrSubquery.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDBAC217DFADC006E9E73 /* TableOrSubquery.cpp */; };\n\t\t7521DAE0291EA349009642EF /* WalRelated.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23593B7B20D3ADF80058B416 /* WalRelated.cpp */; };\n\t\t7521DAE1291EA349009642EF /* SyntaxBeginSTMT.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDC37217DFADC006E9E73 /* SyntaxBeginSTMT.cpp */; };\n\t\t7521DAE2291EA349009642EF /* SyntaxCommonTableExpression.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDBFC217DFADC006E9E73 /* SyntaxCommonTableExpression.cpp */; };\n\t\t7521DAE3291EA349009642EF /* StatementCreateVirtualTable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E1659C27F42D6500D2C926 /* StatementCreateVirtualTable.swift */; };\n\t\t7521DAE4291EA349009642EF /* StatementDropTable.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDBD3217DFADC006E9E73 /* StatementDropTable.cpp */; };\n\t\t7521DAE5291EA349009642EF /* Insert.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E165CD27F42D6500D2C926 /* Insert.swift */; };\n\t\t7521DAE7291EA349009642EF /* SyntaxExpression.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDC00217DFADC006E9E73 /* SyntaxExpression.cpp */; };\n\t\t7521DAE8291EA349009642EF /* StatementCreateVirtualTable.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDBCB217DFADC006E9E73 /* StatementCreateVirtualTable.cpp */; };\n\t\t7521DAE9291EA349009642EF /* SyntaxCommonConst.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23545BA12224EAA40091C981 /* SyntaxCommonConst.cpp */; };\n\t\t7521DAEA291EA349009642EF /* StatementSavepoint.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDBE3217DFADC006E9E73 /* StatementSavepoint.cpp */; };\n\t\t7521DAEB291EA349009642EF /* Recyclable.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 236996B121D5C4FF00E72E81 /* Recyclable.cpp */; };\n\t\t7521DAEC291EA349009642EF /* Data.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23775BCB20AD72BC00E21AB0 /* Data.cpp */; };\n\t\t7521DAED291EA349009642EF /* TransactionInterface.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75C17A9228D0D3DD009C342E /* TransactionInterface.swift */; };\n\t\t7521DAEE291EA349009642EF /* SyntaxForeignKeyClause.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDC04217DFADC006E9E73 /* SyntaxForeignKeyClause.cpp */; };\n\t\t7521DAEF291EA349009642EF /* IndexedColumn.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDB90217DFADC006E9E73 /* IndexedColumn.cpp */; };\n\t\t7521DAF0291EA349009642EF /* BaseTokenizerUtil.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 75B698D3290AD4C0006E1F8F /* BaseTokenizerUtil.cpp */; };\n\t\t7521DAF1291EA349009642EF /* RaiseFunction.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDBA0217DFADC006E9E73 /* RaiseFunction.cpp */; };\n\t\t7521DAF2291EA349009642EF /* TableOrSubqueryBridge.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 75AF6AD528544C8800A7C43D /* TableOrSubqueryBridge.cpp */; };\n\t\t7521DAF4291EA349009642EF /* ColumnConstraint.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDB7E217DFADC006E9E73 /* ColumnConstraint.cpp */; };\n\t\t7521DAF7291EA349009642EF /* Table.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E165C727F42D6500D2C926 /* Table.swift */; };\n\t\t7521DAF8291EA349009642EF /* Range.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2314AE6F21070A1700244D39 /* Range.cpp */; };\n\t\t7521DAFA291EA349009642EF /* ThreadedErrors.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23F1698920B6638F009B5C47 /* ThreadedErrors.cpp */; };\n\t\t7521DAFB291EA349009642EF /* StatementAlterTableBridge.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 03B6A33A2869C51B00D83EC4 /* StatementAlterTableBridge.cpp */; };\n\t\t7521DAFC291EA349009642EF /* TableConstraintBridge.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 75AF6AEB28559F4800A7C43D /* TableConstraintBridge.cpp */; };\n\t\t7521DAFD291EA349009642EF /* StatementDropViewBridge.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 75EB196C287F093B00AA62F7 /* StatementDropViewBridge.cpp */; };\n\t\t7521DAFE291EA349009642EF /* StatementCommit.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75F4DE612884161200760DC3 /* StatementCommit.swift */; };\n\t\t7521DB00291EA349009642EF /* StatementCreateTrigger.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDBC7217DFADC006E9E73 /* StatementCreateTrigger.cpp */; };\n\t\t7521DB01291EA349009642EF /* DatabasePool.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23D96B902050DED700DB5E93 /* DatabasePool.cpp */; };\n\t\t7521DB02291EA349009642EF /* IndexedColumnBridge.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 03BFC5D52853538400673AE4 /* IndexedColumnBridge.cpp */; };\n\t\t7521DB04291EA349009642EF /* TokenizerModules.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2304B42C22156E1500901953 /* TokenizerModules.cpp */; };\n\t\t7521DB05291EA349009642EF /* MultiSelect.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E165CC27F42D6500D2C926 /* MultiSelect.swift */; };\n\t\t7521DB06291EA349009642EF /* StatementUpdate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E165A727F42D6500D2C926 /* StatementUpdate.swift */; };\n\t\t7521DB07291EA349009642EF /* FactoryDepositor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23D0C34B20C149D80001BFAE /* FactoryDepositor.cpp */; };\n\t\t7521DB08291EA349009642EF /* Update.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E165C427F42D6500D2C926 /* Update.swift */; };\n\t\t7521DB0A291EA349009642EF /* SelectInterface.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75CD026E28CF8F5F0071B6C3 /* SelectInterface.swift */; };\n\t\t7521DB0B291EA349009642EF /* StatementDropTrigger.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75EB1967287F078E00AA62F7 /* StatementDropTrigger.swift */; };\n\t\t7521DB0C291EA349009642EF /* SyntaxConst.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75A46C0828432A5D00B58207 /* SyntaxConst.swift */; };\n\t\t7521DB0D291EA349009642EF /* TokenizerConfig.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23F70FBC20A055D400CCE3CD /* TokenizerConfig.cpp */; };\n\t\t7521DB0E291EA349009642EF /* FactoryRetriever.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23D0C34F20C149D80001BFAE /* FactoryRetriever.cpp */; };\n\t\t7521DB10291EA349009642EF /* StatementAttachBridge.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 03DCB5EC286C3D8E00CBC75D /* StatementAttachBridge.cpp */; };\n\t\t7521DB11291EA349009642EF /* StatementRollback.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDBE1217DFADC006E9E73 /* StatementRollback.cpp */; };\n\t\t7521DB12291EA349009642EF /* Exiting.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 231C35EC21DE09E400B5D3D2 /* Exiting.cpp */; };\n\t\t7521DB13291EA349009642EF /* BindParameterBridge.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 03A57F1A2840B5DC00D2A4C3 /* BindParameterBridge.cpp */; };\n\t\t7521DB15291EA349009642EF /* Migration.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23A64D0D214A4A7000ED28BB /* Migration.cpp */; };\n\t\t7521DB16291EA349009642EF /* Configs.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3962FFCE23051F71008934D4 /* Configs.cpp */; };\n\t\t7521DB18291EA349009642EF /* SyntaxCreateTriggerSTMT.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDC3F217DFADC006E9E73 /* SyntaxCreateTriggerSTMT.cpp */; };\n\t\t7521DB19291EA349009642EF /* StatementReindex.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E165B527F42D6500D2C926 /* StatementReindex.swift */; };\n\t\t7521DB1A291EA349009642EF /* Column.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDB7C217DFADC006E9E73 /* Column.cpp */; };\n\t\t7521DB1B291EA349009642EF /* StatementPragmaBridge.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 75F4DE352883E88100760DC3 /* StatementPragmaBridge.cpp */; };\n\t\t7521DB1D291EA349009642EF /* HandleBridge.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0393BEE527F7152F0058B295 /* HandleBridge.cpp */; };\n\t\t7521DB1E291EA349009642EF /* StatementSelect.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDBE5217DFADC006E9E73 /* StatementSelect.cpp */; };\n\t\t7521DB1F291EA349009642EF /* StatementCreateIndex.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E165B627F42D6500D2C926 /* StatementCreateIndex.swift */; };\n\t\t7521DB20291EA349009642EF /* StatementCreateTable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E165AB27F42D6500D2C926 /* StatementCreateTable.swift */; };\n\t\t7521DB21291EA349009642EF /* OneOrBinaryTokenizer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 03450DB22738BBF000C4DC1B /* OneOrBinaryTokenizer.cpp */; };\n\t\t7521DB22291EA349009642EF /* Pragma.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E1659727F42D6500D2C926 /* Pragma.swift */; };\n\t\t7521DB23291EA349009642EF /* QualifiedTable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75AF6AE12854F19800A7C43D /* QualifiedTable.swift */; };\n\t\t7521DB25291EA349009642EF /* SyntaxReindexSTMT.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDC55217DFADC006E9E73 /* SyntaxReindexSTMT.cpp */; };\n\t\t7521DB26291EA349009642EF /* StatementDetachBridge.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 03F5481E287D8467007BCA3E /* StatementDetachBridge.cpp */; };\n\t\t7521DB28291EA349009642EF /* ColumnBridge.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 032613B4283F8D7E00836E0F /* ColumnBridge.cpp */; };\n\t\t7521DB29291EA349009642EF /* SyntaxCreateViewSTMT.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDC41217DFADC006E9E73 /* SyntaxCreateViewSTMT.cpp */; };\n\t\t7521DB2A291EA349009642EF /* BindParameter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDB7A217DFADC006E9E73 /* BindParameter.cpp */; };\n\t\t7521DB2B291EA349009642EF /* AutoBackupConfig.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23301BFA229A851800A8AB5A /* AutoBackupConfig.cpp */; };\n\t\t7521DB2C291EA349009642EF /* TableInterface.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75CD027028CF900C0071B6C3 /* TableInterface.swift */; };\n\t\t7521DB2E291EA349009642EF /* ChainCall.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E165C627F42D6500D2C926 /* ChainCall.swift */; };\n\t\t7521DB2F291EA349009642EF /* SyntaxRaiseFunction.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDC1C217DFADC006E9E73 /* SyntaxRaiseFunction.cpp */; };\n\t\t7521DB30291EA349009642EF /* FrameSpec.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDB8C217DFADC006E9E73 /* FrameSpec.cpp */; };\n\t\t7521DB31291EA349009642EF /* FrameSpec.swift in Sources */ = {isa = PBXBuildFile; fileRef = 752594E728522A4A0068A602 /* FrameSpec.swift */; };\n\t\t7521DB32291EA349009642EF /* Recyclable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E165E827F42D6500D2C926 /* Recyclable.swift */; };\n\t\t7521DB33291EA349009642EF /* HandlePool.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2349F6221EA0D6680021EFA7 /* HandlePool.cpp */; };\n\t\t7521DB35291EA349009642EF /* SyntaxWindowDef.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDC2C217DFADC006E9E73 /* SyntaxWindowDef.cpp */; };\n\t\t7521DB3A291EA349009642EF /* PagerRelated.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23567D5720CA823C005F1C35 /* PagerRelated.cpp */; };\n\t\t7521DB3B291EA349009642EF /* Statement.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E165B727F42D6500D2C926 /* Statement.swift */; };\n\t\t7521DB3D291EA349009642EF /* WindowDef.swift in Sources */ = {isa = PBXBuildFile; fileRef = 039BD3972845CB7C00C58BE2 /* WindowDef.swift */; };\n\t\t7521DB3E291EA349009642EF /* ExpressionBridge.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 032613B8283F8E4900836E0F /* ExpressionBridge.cpp */; };\n\t\t7521DB3F291EA349009642EF /* SyntaxColumnDef.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDBFA217DFADC006E9E73 /* SyntaxColumnDef.cpp */; };\n\t\t7521DB40291EA349009642EF /* Upsert.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75AF6AF32855CCDD00A7C43D /* Upsert.swift */; };\n\t\t7521DB41291EA349009642EF /* WindowDef.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDBB0217DFADC006E9E73 /* WindowDef.cpp */; };\n\t\t7521DB42291EA349009642EF /* FileManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23B9E67420AE733A00CF1683 /* FileManager.cpp */; };\n\t\t7521DB43291EA349009642EF /* SyntaxColumn.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDBF6217DFADC006E9E73 /* SyntaxColumn.cpp */; };\n\t\t7521DB44291EA349009642EF /* SyntaxFilter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDC02217DFADC006E9E73 /* SyntaxFilter.cpp */; };\n\t\t7521DB45291EA349009642EF /* StatementDelete.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDBCD217DFADC006E9E73 /* StatementDelete.cpp */; };\n\t\t7521DB46291EA349009642EF /* ErrorProne.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23567D4620CA7DBC005F1C35 /* ErrorProne.cpp */; };\n\t\t7521DB48291EA349009642EF /* SyntaxInsertSTMT.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDC51217DFADC006E9E73 /* SyntaxInsertSTMT.cpp */; };\n\t\t7521DB4A291EA349009642EF /* JoinBridge.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 75AF6AD92854C5ED00A7C43D /* JoinBridge.cpp */; };\n\t\t7521DB4B291EA349009642EF /* Shm.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23408F0D211897AA0071E5A7 /* Shm.cpp */; };\n\t\t7521DB4C291EA349009642EF /* InnerDatabase.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2349F61B1EA0D6680021EFA7 /* InnerDatabase.cpp */; };\n\t\t7521DB4D291EA349009642EF /* Pragma.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDB9C217DFADC006E9E73 /* Pragma.cpp */; };\n\t\t7521DB4E291EA349009642EF /* UpgradeableErrorProne.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23AD52F020DBAC4C00664B62 /* UpgradeableErrorProne.cpp */; };\n\t\t7521DB4F291EA349009642EF /* StatementAlterTable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E165AF27F42D6500D2C926 /* StatementAlterTable.swift */; };\n\t\t7521DB51291EA349009642EF /* ExpressionOperatableBridge.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 039BD4342846113D00C58BE2 /* ExpressionOperatableBridge.cpp */; };\n\t\t7521DB53291EA349009642EF /* SharedThreadedErrorProne.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23567D7220CA91FF005F1C35 /* SharedThreadedErrorProne.cpp */; };\n\t\t7521DB54291EA349009642EF /* LiteralValue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDB96217DFADC006E9E73 /* LiteralValue.cpp */; };\n\t\t7521DB55291EA349009642EF /* Declare.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E165C227F42D6500D2C926 /* Declare.swift */; };\n\t\t7521DB56291EA349009642EF /* CheckExpressionConfig.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75C4409D291D0C9C00D74EB7 /* CheckExpressionConfig.swift */; };\n\t\t7521DB57291EA349009642EF /* StatementVacuumBridge.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 75F4DE4F288407F800760DC3 /* StatementVacuumBridge.cpp */; };\n\t\t7521DB58291EA349009642EF /* Select.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E165C927F42D6500D2C926 /* Select.swift */; };\n\t\t7521DB59291EA349009642EF /* SyntaxCreateIndexSTMT.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDC3B217DFADC006E9E73 /* SyntaxCreateIndexSTMT.cpp */; };\n\t\t7521DB5A291EA349009642EF /* HandleStatementBridge.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 756A773C27F9EDDE00105B7C /* HandleStatementBridge.cpp */; };\n\t\t7521DB5B291EA349009642EF /* CommonTableExpressionBridge.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 03E822822844B8760072CA57 /* CommonTableExpressionBridge.cpp */; };\n\t\t7521DB5C291EA349009642EF /* InsertInterface.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75CD026828CF8DC00071B6C3 /* InsertInterface.swift */; };\n\t\t7521DB60291EA349009642EF /* StatementCommitBridge.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 75F4DE5D2884149100760DC3 /* StatementCommitBridge.cpp */; };\n\t\t7521DB61291EA349009642EF /* ColumnConstraintConfig.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75C44093291CE12300D74EB7 /* ColumnConstraintConfig.swift */; };\n\t\t7521DB62291EA349009642EF /* SyntaxAlterTableSTMT.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDC31217DFADC006E9E73 /* SyntaxAlterTableSTMT.cpp */; };\n\t\t7521DB63291EA349009642EF /* SyntaxCreateVirtualTableSTMT.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDC43217DFADC006E9E73 /* SyntaxCreateVirtualTableSTMT.cpp */; };\n\t\t7521DB64291EA349009642EF /* SyntaxAttachSTMT.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDC35217DFADC006E9E73 /* SyntaxAttachSTMT.cpp */; };\n\t\t7521DB66291EA349009642EF /* SyntaxJoinClause.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDC0E217DFADC006E9E73 /* SyntaxJoinClause.cpp */; };\n\t\t7521DB68291EA349009642EF /* SyntaxDropTableSTMT.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDC4B217DFADC006E9E73 /* SyntaxDropTableSTMT.cpp */; };\n\t\t7521DB6A291EA349009642EF /* StatementSelect.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E1659927F42D6500D2C926 /* StatementSelect.swift */; };\n\t\t7521DB6B291EA349009642EF /* SyntaxExplainSTMT.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3960D8992319258B00EF05D1 /* SyntaxExplainSTMT.cpp */; };\n\t\t7521DB6D291EA349009642EF /* StatementVacuum.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E165B227F42D6500D2C926 /* StatementVacuum.swift */; };\n\t\t7521DB70291EA349009642EF /* SyntaxLiteralValue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDC12217DFADC006E9E73 /* SyntaxLiteralValue.cpp */; };\n\t\t7521DB71291EA349009642EF /* StatementUpdateBridge.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 03EE3DAC28816DA800C8F0B3 /* StatementUpdateBridge.cpp */; };\n\t\t7521DB72291EA349009642EF /* StringView.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 235EE9C422B6321A008F6658 /* StringView.cpp */; };\n\t\t7521DB73291EA349009642EF /* LiteralValue.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E165A927F42D6500D2C926 /* LiteralValue.swift */; };\n\t\t7521DB74291EA349009642EF /* StatementDropIndexBridge.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 03F54822287D87F9007BCA3E /* StatementDropIndexBridge.cpp */; };\n\t\t7521DB75291EA349009642EF /* SyntaxRollbackSTMT.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDC59217DFADC006E9E73 /* SyntaxRollbackSTMT.cpp */; };\n\t\t7521DB76291EA349009642EF /* HandleStatement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2370980820590CA700E768B4 /* HandleStatement.cpp */; };\n\t\t7521DB78291EA349009642EF /* LiteralValueBridge.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0326130B283F56BD00836E0F /* LiteralValueBridge.cpp */; };\n\t\t7521DB79291EA349009642EF /* CoreFunction.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDB6F217DFADC006E9E73 /* CoreFunction.cpp */; };\n\t\t7521DB7C291EA349009642EF /* StatementCreateTriggerBridge.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 75EB1A11287F10BF00AA62F7 /* StatementCreateTriggerBridge.cpp */; };\n\t\t7521DB7D291EA349009642EF /* StatementCreateTableBridge.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 757821DF286DF5EB0092F858 /* StatementCreateTableBridge.cpp */; };\n\t\t7521DB7E291EA349009642EF /* FactoryRenewer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23DD76BB20CF78C800E9B451 /* FactoryRenewer.cpp */; };\n\t\t7521DB7F291EA349009642EF /* TokenizerModule.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2304B42622156CD700901953 /* TokenizerModule.cpp */; };\n\t\t7521DB80291EA349009642EF /* SyntaxFrameSpec.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDC06217DFADC006E9E73 /* SyntaxFrameSpec.cpp */; };\n\t\t7521DB82291EA349009642EF /* SyntaxTableOrSubquery.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDC28217DFADC006E9E73 /* SyntaxTableOrSubquery.cpp */; };\n\t\t7521DB84291EA349009642EF /* StatementAttach.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E165AE27F42D6500D2C926 /* StatementAttach.swift */; };\n\t\t7521DB85291EA349009642EF /* Expression.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E1659127F42D6500D2C926 /* Expression.swift */; };\n\t\t7521DB86291EA349009642EF /* Time.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23567D7920CA93C5005F1C35 /* Time.cpp */; };\n\t\t7521DB8A291EA349009642EF /* StatementVacuum.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDBE9217DFADC006E9E73 /* StatementVacuum.cpp */; };\n\t\t7521DB8B291EA349009642EF /* AbstractHandle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2347378D21CBB3A800AD5E41 /* AbstractHandle.cpp */; };\n\t\t7521DB8F291EA349009642EF /* StatementExplain.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3960D89D2319288C00EF05D1 /* StatementExplain.cpp */; };\n\t\t7521DB90291EA349009642EF /* CommonCore.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23B4DCBB2112A9C800954D71 /* CommonCore.cpp */; };\n\t\t7521DB91291EA349009642EF /* SyntaxIndexedColumn.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDC0C217DFADC006E9E73 /* SyntaxIndexedColumn.cpp */; };\n\t\t7521DB92291EA349009642EF /* TableConstraint.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E165A027F42D6500D2C926 /* TableConstraint.swift */; };\n\t\t7521DB93291EA349009642EF /* Pager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23775B4920AD666900E21AB0 /* Pager.cpp */; };\n\t\t7521DB94291EA349009642EF /* StatementInterface.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75CD026028CECD610071B6C3 /* StatementInterface.swift */; };\n\t\t7521DB95291EA349009642EF /* StatementAnalyze.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03DCB5E8286C345C00CBC75D /* StatementAnalyze.swift */; };\n\t\t7521DB96291EA349009642EF /* StatementBegin.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75F4DE57288411DB00760DC3 /* StatementBegin.swift */; };\n\t\t7521DB97291EA349009642EF /* StatementSavepointBridge.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 75F4DE49288405DD00760DC3 /* StatementSavepointBridge.cpp */; };\n\t\t7521DB98291EA349009642EF /* Handle.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E165BB27F42D6500D2C926 /* Handle.swift */; };\n\t\t7521DB99291EA349009642EF /* Console.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 233A8530215E7CFE00BB8D4F /* Console.cpp */; };\n\t\t7521DB9A291EA349009642EF /* IndexedColumn.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E165A227F42D6500D2C926 /* IndexedColumn.swift */; };\n\t\t7521DB9B291EA349009642EF /* Upsert.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDBAE217DFADC006E9E73 /* Upsert.cpp */; };\n\t\t7521DB9C291EA349009642EF /* MasterItem.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23AD52D420DB4A3C00664B62 /* MasterItem.cpp */; };\n\t\t7521DB9D291EA349009642EF /* StatementDropIndex.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDBD1217DFADC006E9E73 /* StatementDropIndex.cpp */; };\n\t\t7521DB9E291EA349009642EF /* WCDBError.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23775B3020AD666900E21AB0 /* WCDBError.cpp */; };\n\t\t7521DB9F291EA349009642EF /* StatementInsert.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDBD9217DFADC006E9E73 /* StatementInsert.cpp */; };\n\t\t7521DBA0291EA349009642EF /* SubstringMatchInfo.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7543DD90271C601F00B533B4 /* SubstringMatchInfo.cpp */; };\n\t\t7521DBA1291EA349009642EF /* CommonTableExpression.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E8228B2844BEFF0072CA57 /* CommonTableExpression.swift */; };\n\t\t7521DBA2291EA349009642EF /* StatementCreateVirtualTableBridge.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 75F1A3042871DE9A008503A2 /* StatementCreateVirtualTableBridge.cpp */; };\n\t\t7521DBA3291EA349009642EF /* Assemble.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 39C70CC52313E20E002D773C /* Assemble.cpp */; };\n\t\t7521DBA4291EA349009642EF /* Cell.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23775B4520AD666900E21AB0 /* Cell.cpp */; };\n\t\t7521DBA5291EA349009642EF /* RaiseFunctionBridge.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 03E8228F2844E1AB0072CA57 /* RaiseFunctionBridge.cpp */; };\n\t\t7521DBA6291EA349009642EF /* AuxiliaryFunctionConfig.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7543DD8C271C360E00B533B4 /* AuxiliaryFunctionConfig.cpp */; };\n\t\t7521DBA7291EA349009642EF /* Optional.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E165F627F42D6500D2C926 /* Optional.swift */; };\n\t\t7521DBA9291EA349009642EF /* RowSelect.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E165C327F42D6500D2C926 /* RowSelect.swift */; };\n\t\t7521DBAA291EA349009642EF /* Frame.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23567CF820CA3889005F1C35 /* Frame.cpp */; };\n\t\t7521DBAB291EA349009642EF /* ObjectBridge.swift in Sources */ = {isa = PBXBuildFile; fileRef = 039760A727F563F00071FA8F /* ObjectBridge.swift */; };\n\t\t7521DBAC291EA349009642EF /* Path.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23B35C7520BFE39500425033 /* Path.cpp */; };\n\t\t7521DBAD291EA349009642EF /* CommonTableExpression.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDB82217DFADC006E9E73 /* CommonTableExpression.cpp */; };\n\t\t7521DBAE291EA349009642EF /* SchemaBridge.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 75204AE9283FD7410002E40C /* SchemaBridge.cpp */; };\n\t\t7521DBAF291EA349009642EF /* PerformanceTraceConfig.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2360A60120D78F2B00E4A311 /* PerformanceTraceConfig.cpp */; };\n\t\t7521DBB0291EA349009642EF /* StatementCommit.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDBC1217DFADC006E9E73 /* StatementCommit.cpp */; };\n\t\t7521DBB3291EA349009642EF /* AutoCheckpointConfig.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23F70FB620A055CF00CCE3CD /* AutoCheckpointConfig.cpp */; };\n\t\t7521DBB4291EA349009642EF /* ColumnDef.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E165B427F42D6500D2C926 /* ColumnDef.swift */; };\n\t\t7521DBB5291EA349009642EF /* ObjectBridge.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0397605727F54FA10071FA8F /* ObjectBridge.cpp */; };\n\t\t7521DBB6291EA349009642EF /* Filter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDB88217DFADC006E9E73 /* Filter.cpp */; };\n\t\t7521DBB7291EA349009642EF /* Thread.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 390E1C5A2296414C00C24598 /* Thread.cpp */; };\n\t\t7521DBB8291EA349009642EF /* OperationQueue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3934DAE9229B6659008A6AEC /* OperationQueue.cpp */; };\n\t\t7521DBB9291EA349009642EF /* AutoMergeFTSIndexConfig.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0D3AE53F25416DB4007B9D0E /* AutoMergeFTSIndexConfig.cpp */; };\n\t\t7521DBBA291EA349009642EF /* ForeignKeyBridge.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 75A46C0228431D6300B58207 /* ForeignKeyBridge.cpp */; };\n\t\t7521DBBB291EA349009642EF /* QualifiedTable.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDB9E217DFADC006E9E73 /* QualifiedTable.cpp */; };\n\t\t7521DBBC291EA349009642EF /* QualifiedTableBridge.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 75AF6ADD2854EF6D00A7C43D /* QualifiedTableBridge.cpp */; };\n\t\t7521DBBD291EA349009642EF /* BasicConfig.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23F70FA420A055BD00CCE3CD /* BasicConfig.cpp */; };\n\t\t7521DBBE291EA349009642EF /* StatementPragma.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDBDB217DFADC006E9E73 /* StatementPragma.cpp */; };\n\t\t7521DBBF291EA349009642EF /* MergeFTSIndexLogic.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0D249BC82542B90600B43BD9 /* MergeFTSIndexLogic.cpp */; };\n\t\t7521DBC0291EA349009642EF /* SyntaxAnalyzeSTMT.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDC33217DFADC006E9E73 /* SyntaxAnalyzeSTMT.cpp */; };\n\t\t7521DBC1291EA349009642EF /* StatementSelectBridge.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 03E822862844B8CD0072CA57 /* StatementSelectBridge.cpp */; };\n\t\t7521DBC2291EA349009642EF /* SyntaxQualifiedTableName.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDC1A217DFADC006E9E73 /* SyntaxQualifiedTableName.cpp */; };\n\t\t7521DBC3291EA349009642EF /* SyntaxSchema.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDC22217DFADC006E9E73 /* SyntaxSchema.cpp */; };\n\t\t7521DBC5291EA349009642EF /* Database.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E165E327F42D6500D2C926 /* Database.swift */; };\n\t\t7521DBC6291EA349009642EF /* TableConfiguration.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75C44095291CE1FB00D74EB7 /* TableConfiguration.swift */; };\n\t\t7521DBC7291EA349009642EF /* Convertible.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E165A127F42D6500D2C926 /* Convertible.swift */; };\n\t\t7521DBCA291EA349009642EF /* Schema.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75204AE7283FD6DC0002E40C /* Schema.swift */; };\n\t\t7521DBCB291EA349009642EF /* ColumnMeta.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 237B47AE21FEEA200059227A /* ColumnMeta.cpp */; };\n\t\t7521DBCC291EA349009642EF /* UnsafeData.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2375945F210081AA00DBB721 /* UnsafeData.cpp */; };\n\t\t7521DBCD291EA349009642EF /* ColumnDef.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDB80217DFADC006E9E73 /* ColumnDef.cpp */; };\n\t\t7521DBCF291EA349009642EF /* TableConstraint.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDBAA217DFADC006E9E73 /* TableConstraint.cpp */; };\n\t\t7521DBD0291EA349009642EF /* SyntaxColumnConstraint.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDBF8217DFADC006E9E73 /* SyntaxColumnConstraint.cpp */; };\n\t\t7521DBD1291EA349009642EF /* Repairman.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EE0EB020B838E100C95998 /* Repairman.cpp */; };\n\t\t7521DBD2291EA349009642EF /* StatementBegin.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDBBF217DFADC006E9E73 /* StatementBegin.cpp */; };\n\t\t7521DBD4291EA349009642EF /* MigrationInfo.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23A64D07214A458A00ED28BB /* MigrationInfo.cpp */; };\n\t\t7521DBD5291EA349009642EF /* Material.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23775B4020AD666900E21AB0 /* Material.cpp */; };\n\t\t7521DBD6291EA349009642EF /* ForeignKey.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDB8A217DFADC006E9E73 /* ForeignKey.cpp */; };\n\t\t7521DBD7291EA349009642EF /* Crawlable.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23775B5020AD666900E21AB0 /* Crawlable.cpp */; };\n\t\t7521DBD9291EA349009642EF /* AggregateFunction.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDB68217DFADC006E9E73 /* AggregateFunction.cpp */; };\n\t\t7521DBDA291EA349009642EF /* MultiPrimaryConfig.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75C44099291CE7E200D74EB7 /* MultiPrimaryConfig.swift */; };\n\t\t7521DBDB291EA349009642EF /* SQLiteBase.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23C7559820DD17B100031A93 /* SQLiteBase.cpp */; };\n\t\t7521DBDC291EA349009642EF /* Join.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDB92217DFADC006E9E73 /* Join.cpp */; };\n\t\t7521DBDD291EA349009642EF /* SyntaxCreateTableSTMT.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDC3D217DFADC006E9E73 /* SyntaxCreateTableSTMT.cpp */; };\n\t\t7521DBDE291EA349009642EF /* StatementCreateView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75EB1A0C287F0DE200AA62F7 /* StatementCreateView.swift */; };\n\t\t7521DBE0291EA349009642EF /* FTSError.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 03EA88CF27D5F0840075C7BD /* FTSError.cpp */; };\n\t\t7521DBE1291EA349009642EF /* SyntaxDropIndexSTMT.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDC49217DFADC006E9E73 /* SyntaxDropIndexSTMT.cpp */; };\n\t\t7521DBE2291EA349009642EF /* Delete.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E165C527F42D6500D2C926 /* Delete.swift */; };\n\t\t7521DBE3291EA349009642EF /* HandleRelated.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2360A5F320D78F1B00E4A311 /* HandleRelated.cpp */; };\n\t\t7521DBE4291EA349009642EF /* SyntaxIdentifier.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDC0A217DFADC006E9E73 /* SyntaxIdentifier.cpp */; };\n\t\t7521DBE5291EA349009642EF /* SyntaxBindParameter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDBF4217DFADC006E9E73 /* SyntaxBindParameter.cpp */; };\n\t\t7521DBE6291EA349009642EF /* SyntaxDetachSTMT.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDC47217DFADC006E9E73 /* SyntaxDetachSTMT.cpp */; };\n\t\t7521DBE7291EA349009642EF /* Page.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23775B4720AD666900E21AB0 /* Page.cpp */; };\n\t\t7521DBE8291EA349009642EF /* WCDBError.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E165EA27F42D6500D2C926 /* WCDBError.swift */; };\n\t\t7521DBE9291EA349009642EF /* StatementRelease.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E165B327F42D6500D2C926 /* StatementRelease.swift */; };\n\t\t7521DBEA291EA349009642EF /* SyntaxOrderingTerm.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDC16217DFADC006E9E73 /* SyntaxOrderingTerm.cpp */; };\n\t\t7521DBEB291EA349009642EF /* StatementDropIndex.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E1659627F42D6500D2C926 /* StatementDropIndex.swift */; };\n\t\t7521DBEC291EA349009642EF /* Serialization.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2308F84D20E32A51001CD9C3 /* Serialization.cpp */; };\n\t\t7521DBEE291EA349009642EF /* Convenience.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E165F727F42D6500D2C926 /* Convenience.swift */; };\n\t\t7521DBEF291EA349009642EF /* StatementDeleteBridge.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 75F1A3082871E764008503A2 /* StatementDeleteBridge.cpp */; };\n\t\t7521DBF0291EA349009642EF /* DBOperationNotifier.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0DC98FD028E46049007F3796 /* DBOperationNotifier.cpp */; };\n\t\t7521DBF1291EA349009642EF /* PorterStemming.c in Sources */ = {isa = PBXBuildFile; fileRef = 23E163D120FDDD8500C3F910 /* PorterStemming.c */; };\n\t\t7521DBF2291EA349009642EF /* StatementDelete.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E165AD27F42D6500D2C926 /* StatementDelete.swift */; };\n\t\t7521DBF3291EA349009642EF /* StatementInsertBridge.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 03EE3DA8288165A700C8F0B3 /* StatementInsertBridge.cpp */; };\n\t\t7521DBF4291EA349009642EF /* SQLiteAssembler.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23D0C30C20C125420001BFAE /* SQLiteAssembler.cpp */; };\n\t\t7521DBF5291EA349009642EF /* DeleteInterface.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75CD026C28CF8F360071B6C3 /* DeleteInterface.swift */; };\n\t\t7521DBF6291EA349009642EF /* StatementBeginBridge.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 75F4DE5328840C4800760DC3 /* StatementBeginBridge.cpp */; };\n\t\t7521DBF7291EA349009642EF /* BindParameter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03A57F172840B5A000D2A4C3 /* BindParameter.swift */; };\n\t\t7521DBF8291EA349009642EF /* FTSBridge.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75E76AD329161EE400073CCA /* FTSBridge.swift */; };\n\t\t7521DBF9291EA349009642EF /* FileHandle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2308F84B20E32A51001CD9C3 /* FileHandle.cpp */; };\n\t\t7521DBFA291EA349009642EF /* Join.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E165AC27F42D6500D2C926 /* Join.swift */; };\n\t\t7521DBFB291EA349009642EF /* PragmaBridge.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 75AF6AF82856303700A7C43D /* PragmaBridge.cpp */; };\n\t\t7521DBFC291EA349009642EF /* WindowDefBridge.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 75C1034028450D840006BBCB /* WindowDefBridge.cpp */; };\n\t\t7521DBFD291EA349009642EF /* ColumnCodable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E165CF27F42D6500D2C926 /* ColumnCodable.swift */; };\n\t\t7521DBFE291EA349009642EF /* SyntaxJoinConstraint.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDC10217DFADC006E9E73 /* SyntaxJoinConstraint.cpp */; };\n\t\t7521DC00291EA349009642EF /* SyntaxReleaseSTMT.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDC57217DFADC006E9E73 /* SyntaxReleaseSTMT.cpp */; };\n\t\t7521DC02291EA349009642EF /* CoreBridge.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 756A774227FAC1D900105B7C /* CoreBridge.cpp */; };\n\t\t7521DC03291EA349009642EF /* Schema.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDBA6217DFADC006E9E73 /* Schema.cpp */; };\n\t\t7521DC04291EA349009642EF /* MasterCrawler.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23D07CE220BE87360043F4D4 /* MasterCrawler.cpp */; };\n\t\t7521DC05291EA349009642EF /* StatementReindex.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDBDD217DFADC006E9E73 /* StatementReindex.cpp */; };\n\t\t7521DC08291EA349009642EF /* Wal.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EB91DC20CA1EBE00ECF668 /* Wal.cpp */; };\n\t\t7521DC0A291EA349009642EF /* TableBinding.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E165DC27F42D6500D2C926 /* TableBinding.swift */; };\n\t\t7521DC0B291EA349009642EF /* CodableType.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E165BE27F42D6500D2C926 /* CodableType.swift */; };\n\t\t7521DC0E291EA349009642EF /* BusyRetryConfig.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 237A8D5D21EDBB2E003AF5BB /* BusyRetryConfig.cpp */; };\n\t\t7521DC0F291EA349009642EF /* Property.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E165D727F42D6500D2C926 /* Property.swift */; };\n\t\t7521DC11291EA349009642EF /* SyntaxSelectSTMT.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDC5D217DFADC006E9E73 /* SyntaxSelectSTMT.cpp */; };\n\t\t7521DC12291EA349009642EF /* InnerHandle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 39B524DC2304F9A2001DF52D /* InnerHandle.cpp */; };\n\t\t7521DC16291EA349009642EF /* Lock.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23F0FEB3215F5E9A008399FB /* Lock.cpp */; };\n\t\t7521DC17291EA349009642EF /* DatabaseBridge.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 039760AC27F5C1CA0071FA8F /* DatabaseBridge.cpp */; };\n\t\t7521DC1A291EA349009642EF /* BaseBinding.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7537E5CF28B939240077D92B /* BaseBinding.cpp */; };\n\t\t7521DC1B291EA349009642EF /* SyntaxSelectCore.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDC24217DFADC006E9E73 /* SyntaxSelectCore.cpp */; };\n\t\t7521DC1C291EA349009642EF /* BaseType.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E165E127F42D6500D2C926 /* BaseType.swift */; };\n\t\t7521DC1D291EA349009642EF /* StatementSavepoint.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E165A527F42D6500D2C926 /* StatementSavepoint.swift */; };\n\t\t7521DC1E291EA349009642EF /* Value.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 03E5CC6C28A3BDF3005353D9 /* Value.cpp */; };\n\t\t7521DC1F291EA349009642EF /* StatementRelease.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 23EEDBDF217DFADC006E9E73 /* StatementRelease.cpp */; };\n\t\t7521DC22291EA349009642EF /* StatementDropTableBridge.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 03F54826287D93A7007BCA3E /* StatementDropTableBridge.cpp */; };\n\t\t7521DC24291EA349009642EF /* Security.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 23F0FD7C215F1C92008399FB /* Security.framework */; };\n\t\t7521DC25291EA349009642EF /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 239E8A922160A81600BCB308 /* Foundation.framework */; };\n\t\t7521DC26291EA349009642EF /* libz.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = 23C43BCC2087435800AB186D /* libz.tbd */; };\n\t\t7521DC27291EA349009642EF /* sqlcipher.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 23F5BE0620887FD4000CCD37 /* sqlcipher.framework */; };\n\t\t7521DC29291EA349009642EF /* AsyncQueue.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23B4DCE02112B03C00954D71 /* AsyncQueue.hpp */; };\n\t\t7521DC2A291EA349009642EF /* AutoBackupConfig.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23301BF9229A851800A8AB5A /* AutoBackupConfig.hpp */; };\n\t\t7521DC2B291EA349009642EF /* WINQ.h in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDBEB217DFADC006E9E73 /* WINQ.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521DC2C291EA349009642EF /* UnsafeData.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23759460210081AA00DBB721 /* UnsafeData.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521DC2F291EA349009642EF /* CommonCore.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 234591F5204432E400DC7D34 /* CommonCore.hpp */; };\n\t\t7521DC34291EA349009642EF /* Pragma.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDB9D217DFADC006E9E73 /* Pragma.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521DC35291EA349009642EF /* SequenceItem.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23AD52DC20DB56D200664B62 /* SequenceItem.hpp */; };\n\t\t7521DC36291EA349009642EF /* MappedData.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 2316D92B21057CA600707AFC /* MappedData.hpp */; };\n\t\t7521DC37291EA349009642EF /* SyntaxCommitSTMT.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDC3A217DFADC006E9E73 /* SyntaxCommitSTMT.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521DC39291EA349009642EF /* Syntax.h in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDC65217DFADC006E9E73 /* Syntax.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521DC3A291EA349009642EF /* SyntaxAttachSTMT.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDC36217DFADC006E9E73 /* SyntaxAttachSTMT.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521DC3B291EA349009642EF /* CommonTableExpression.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDB83217DFADC006E9E73 /* CommonTableExpression.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521DC3C291EA349009642EF /* ValueArray.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 03A15DF828AA636A0031A50A /* ValueArray.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521DC3E291EA349009642EF /* Console.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 233A8531215E7CFE00BB8D4F /* Console.hpp */; };\n\t\t7521DC41291EA349009642EF /* CommonCore.h in Headers */ = {isa = PBXBuildFile; fileRef = 391F7C83225DE8FD0095E82D /* CommonCore.h */; };\n\t\t7521DC42291EA349009642EF /* HandleNotification.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 2360A5F520D78F1B00E4A311 /* HandleNotification.hpp */; };\n\t\t7521DC43291EA349009642EF /* SyntaxCreateTableSTMT.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDC3E217DFADC006E9E73 /* SyntaxCreateTableSTMT.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521DC44291EA349009642EF /* SyntaxDropTriggerSTMT.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDC4E217DFADC006E9E73 /* SyntaxDropTriggerSTMT.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521DC45291EA349009642EF /* TokenizerModuleTemplate.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23B4DCD92112AC5600954D71 /* TokenizerModuleTemplate.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521DC46291EA349009642EF /* Convertible.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDB6C217DFADC006E9E73 /* Convertible.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521DC47291EA349009642EF /* Initializeable.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23AF4E1D20CD04E20050033C /* Initializeable.hpp */; };\n\t\t7521DC48291EA349009642EF /* WinqBridge.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 75A46C102843B73C00B58207 /* WinqBridge.hpp */; };\n\t\t7521DC49291EA349009642EF /* Recyclable.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 2316D92D21057CA700707AFC /* Recyclable.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521DC4A291EA349009642EF /* CoreConst.h in Headers */ = {isa = PBXBuildFile; fileRef = 237C900621D45E6700EE6E44 /* CoreConst.h */; };\n\t\t7521DC4B291EA349009642EF /* Cell.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23775B4620AD666900E21AB0 /* Cell.hpp */; };\n\t\t7521DC4D291EA349009642EF /* BasicConfig.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23F70FA520A055BD00CCE3CD /* BasicConfig.hpp */; };\n\t\t7521DC4E291EA349009642EF /* StatementDropIndex.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDBD2217DFADC006E9E73 /* StatementDropIndex.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521DC4F291EA349009642EF /* Pager.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23775B4A20AD666900E21AB0 /* Pager.hpp */; };\n\t\t7521DC50291EA349009642EF /* SyntaxCreateIndexSTMT.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDC3C217DFADC006E9E73 /* SyntaxCreateIndexSTMT.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521DC52291EA349009642EF /* Crawlable.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23775B5120AD666900E21AB0 /* Crawlable.hpp */; };\n\t\t7521DC53291EA349009642EF /* LiteralValue.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDB97217DFADC006E9E73 /* LiteralValue.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521DC55291EA349009642EF /* CustomConfig.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23F70FD520A07CEC00CCE3CD /* CustomConfig.hpp */; };\n\t\t7521DC56291EA349009642EF /* StatementCreateTable.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDBC6217DFADC006E9E73 /* StatementCreateTable.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521DC57291EA349009642EF /* ForeignKey.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDB8B217DFADC006E9E73 /* ForeignKey.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521DC59291EA349009642EF /* WCDBVersion.h in Headers */ = {isa = PBXBuildFile; fileRef = 23176A8B21B912B10051ACF9 /* WCDBVersion.h */; };\n\t\t7521DC5C291EA349009642EF /* StatementDropTrigger.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDBD6217DFADC006E9E73 /* StatementDropTrigger.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521DC5E291EA349009642EF /* FTSFunction.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDB74217DFADC006E9E73 /* FTSFunction.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521DC60291EA349009642EF /* WalRelated.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23593B7C20D3ADF80058B416 /* WalRelated.hpp */; };\n\t\t7521DC61291EA349009642EF /* FactoryRelated.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23D0C36220C14ACC0001BFAE /* FactoryRelated.hpp */; };\n\t\t7521DC62291EA349009642EF /* SyntaxSelectSTMT.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDC5E217DFADC006E9E73 /* SyntaxSelectSTMT.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521DC64291EA349009642EF /* PerformanceTraceConfig.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 2360A60220D78F2B00E4A311 /* PerformanceTraceConfig.hpp */; };\n\t\t7521DC65291EA349009642EF /* ColumnMeta.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 237B47AF21FEEA200059227A /* ColumnMeta.hpp */; };\n\t\t7521DC67291EA349009642EF /* Macro.h in Headers */ = {isa = PBXBuildFile; fileRef = 239776D0202AF2E2000A681C /* Macro.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521DC69291EA349009642EF /* BusyRetryConfig.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 237A8D5E21EDBB2E003AF5BB /* BusyRetryConfig.hpp */; };\n\t\t7521DC6A291EA349009642EF /* Progress.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23A6D4BE20BFD7F9004F2DAA /* Progress.hpp */; };\n\t\t7521DC6B291EA349009642EF /* SyntaxForeignKeyClause.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDC05217DFADC006E9E73 /* SyntaxForeignKeyClause.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521DC6C291EA349009642EF /* SyntaxAssertion.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23545B962224E8270091C981 /* SyntaxAssertion.hpp */; };\n\t\t7521DC6E291EA349009642EF /* SyntaxSelectCore.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDC25217DFADC006E9E73 /* SyntaxSelectCore.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521DC6F291EA349009642EF /* SyntaxTableConstraint.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDC27217DFADC006E9E73 /* SyntaxTableConstraint.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521DC70291EA349009642EF /* ThreadedErrors.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23F1698720B6638F009B5C47 /* ThreadedErrors.hpp */; };\n\t\t7521DC71291EA349009642EF /* TableConstraint.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDBAB217DFADC006E9E73 /* TableConstraint.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521DC72291EA349009642EF /* AuxiliaryFunctionConfig.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 7543DD8D271C360E00B533B4 /* AuxiliaryFunctionConfig.hpp */; };\n\t\t7521DC73291EA349009642EF /* SQL.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDBA9217DFADC006E9E73 /* SQL.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521DC75291EA349009642EF /* SequenceCrawler.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23D07CE920BE873E0043F4D4 /* SequenceCrawler.hpp */; };\n\t\t7521DC76291EA349009642EF /* PageBasedFileHandle.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 2316D9422105D19500707AFC /* PageBasedFileHandle.hpp */; };\n\t\t7521DC77291EA349009642EF /* SQLTraceConfig.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 2360A60020D78F2B00E4A311 /* SQLTraceConfig.hpp */; };\n\t\t7521DC78291EA349009642EF /* Data.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23775BCC20AD72BC00E21AB0 /* Data.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521DC7A291EA349009642EF /* Assertion.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23775B2F20AD666900E21AB0 /* Assertion.hpp */; };\n\t\t7521DC7C291EA349009642EF /* Filter.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDB89217DFADC006E9E73 /* Filter.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521DC7D291EA349009642EF /* SyntaxDropViewSTMT.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDC50217DFADC006E9E73 /* SyntaxDropViewSTMT.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521DC7E291EA349009642EF /* Scoreable.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 2376CB1A20DA5D3B00A68DB5 /* Scoreable.hpp */; };\n\t\t7521DC7F291EA349009642EF /* CaseInsensitiveList.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 39411A3E22437E7B00A388F5 /* CaseInsensitiveList.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521DC81291EA349009642EF /* SyntaxForwardDeclaration.h in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDB75217DFADC006E9E73 /* SyntaxForwardDeclaration.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521DC84291EA349009642EF /* MigrationInfo.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23A64D08214A458A00ED28BB /* MigrationInfo.hpp */; };\n\t\t7521DC86291EA349009642EF /* StatementCreateIndex.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDBC4217DFADC006E9E73 /* StatementCreateIndex.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521DC8A291EA349009642EF /* StringView.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 235EE9C322B63219008F6658 /* StringView.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521DC8B291EA349009642EF /* RepairKit.h in Headers */ = {isa = PBXBuildFile; fileRef = 23B9E66920AE6EE400CF1683 /* RepairKit.h */; };\n\t\t7521DC8D291EA349009642EF /* OrderingTerm.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDB9B217DFADC006E9E73 /* OrderingTerm.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521DC8E291EA349009642EF /* SyntaxUpsertClause.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDC2B217DFADC006E9E73 /* SyntaxUpsertClause.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521DC8F291EA349009642EF /* Shm.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23408F0E211897AA0071E5A7 /* Shm.hpp */; };\n\t\t7521DC90291EA349009642EF /* StatementDetach.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDBD0217DFADC006E9E73 /* StatementDetach.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521DC92291EA349009642EF /* SubstringMatchInfo.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 7543DD91271C601F00B533B4 /* SubstringMatchInfo.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521DC93291EA349009642EF /* SyntaxBeginSTMT.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDC38217DFADC006E9E73 /* SyntaxBeginSTMT.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521DC94291EA349009642EF /* SyntaxUpdateSTMT.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDC60217DFADC006E9E73 /* SyntaxUpdateSTMT.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521DC95291EA349009642EF /* ResultColumn.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDBA5217DFADC006E9E73 /* ResultColumn.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521DC96291EA349009642EF /* StatementCreateTrigger.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDBC8217DFADC006E9E73 /* StatementCreateTrigger.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521DC97291EA349009642EF /* Repairman.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EE0EB120B838E100C95998 /* Repairman.hpp */; };\n\t\t7521DC98291EA349009642EF /* ExpressionOperable.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDB72217DFADC006E9E73 /* ExpressionOperable.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521DC99291EA349009642EF /* HandleRelated.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 2360A5F620D78F1B00E4A311 /* HandleRelated.hpp */; };\n\t\t7521DC9A291EA349009642EF /* SyntaxOrderingTerm.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDC17217DFADC006E9E73 /* SyntaxOrderingTerm.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521DCA0291EA349009642EF /* SyntaxAlterTableSTMT.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDC32217DFADC006E9E73 /* SyntaxAlterTableSTMT.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521DCA1291EA349009642EF /* OneOrBinaryTokenizer.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 03450DB32738BBF000C4DC1B /* OneOrBinaryTokenizer.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521DCA2291EA349009642EF /* IndexedColumn.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDB91217DFADC006E9E73 /* IndexedColumn.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521DCA5291EA349009642EF /* TokenizerModule.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 2304B42722156CD700901953 /* TokenizerModule.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521DCA6291EA349009642EF /* AbstractHandle.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 2347378E21CBB3A800AD5E41 /* AbstractHandle.hpp */; };\n\t\t7521DCA7291EA349009642EF /* Factory.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23D0C34A20C149D80001BFAE /* Factory.hpp */; };\n\t\t7521DCA9291EA349009642EF /* SyntaxFrameSpec.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDC07217DFADC006E9E73 /* SyntaxFrameSpec.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521DCAA291EA349009642EF /* Path.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23B35C7420BFE39400425033 /* Path.hpp */; };\n\t\t7521DCAB291EA349009642EF /* Migration.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23A64D0E214A4A7000ED28BB /* Migration.hpp */; };\n\t\t7521DCAD291EA349009642EF /* SyntaxRaiseFunction.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDC1D217DFADC006E9E73 /* SyntaxRaiseFunction.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521DCAE291EA349009642EF /* StatementSelect.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDBE6217DFADC006E9E73 /* StatementSelect.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521DCAF291EA349009642EF /* SyntaxDropTableSTMT.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDC4C217DFADC006E9E73 /* SyntaxDropTableSTMT.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521DCB1291EA349009642EF /* SyntaxExplainSTMT.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 3960D89A2319258B00EF05D1 /* SyntaxExplainSTMT.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521DCB2291EA349009642EF /* StatementDropView.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDBD8217DFADC006E9E73 /* StatementDropView.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521DCB3291EA349009642EF /* StatementExplain.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 3960D89E2319288C00EF05D1 /* StatementExplain.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521DCB4291EA349009642EF /* Backup.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23775B3F20AD666900E21AB0 /* Backup.hpp */; };\n\t\t7521DCB5291EA349009642EF /* MasterItem.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23AD52D520DB4A3C00664B62 /* MasterItem.hpp */; };\n\t\t7521DCB7291EA349009642EF /* BindParameter.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDB7B217DFADC006E9E73 /* BindParameter.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521DCB8291EA349009642EF /* Join.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDB93217DFADC006E9E73 /* Join.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521DCB9291EA349009642EF /* HighWater.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23E7EB1C2123D58D0056B5D8 /* HighWater.hpp */; };\n\t\t7521DCBA291EA349009642EF /* SyntaxIdentifier.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDC0B217DFADC006E9E73 /* SyntaxIdentifier.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521DCBB291EA349009642EF /* Fraction.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23AD52E520DB852B00664B62 /* Fraction.hpp */; };\n\t\t7521DCBC291EA349009642EF /* StatementDropTable.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDBD4217DFADC006E9E73 /* StatementDropTable.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521DCBD291EA349009642EF /* SyntaxExpression.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDC01217DFADC006E9E73 /* SyntaxExpression.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521DCBE291EA349009642EF /* MasterCrawler.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23D07CE320BE87360043F4D4 /* MasterCrawler.hpp */; };\n\t\t7521DCC0291EA349009642EF /* TokenizerModules.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 2304B42D22156E1500901953 /* TokenizerModules.hpp */; };\n\t\t7521DCC1291EA349009642EF /* QualifiedTable.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDB9F217DFADC006E9E73 /* QualifiedTable.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521DCC2291EA349009642EF /* AutoMergeFTSIndexConfig.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 0D3AE53725416D99007B9D0E /* AutoMergeFTSIndexConfig.hpp */; };\n\t\t7521DCC3291EA349009642EF /* Exiting.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 231C35EA21DE090500B5D3D2 /* Exiting.hpp */; };\n\t\t7521DCC4291EA349009642EF /* Config.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23F70F9F20A055B400CCE3CD /* Config.hpp */; };\n\t\t7521DCC7291EA349009642EF /* Page.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23775B4820AD666900E21AB0 /* Page.hpp */; };\n\t\t7521DCC8291EA349009642EF /* SyntaxFilter.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDC03217DFADC006E9E73 /* SyntaxFilter.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521DCC9291EA349009642EF /* StatementRollback.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDBE2217DFADC006E9E73 /* StatementRollback.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521DCCA291EA349009642EF /* StatementAlterTable.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDBBA217DFADC006E9E73 /* StatementAlterTable.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521DCCB291EA349009642EF /* StatementPragma.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDBDC217DFADC006E9E73 /* StatementPragma.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521DCCC291EA349009642EF /* RecyclableHandle.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 2349F6251EA0D6680021EFA7 /* RecyclableHandle.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521DCCD291EA349009642EF /* SyntaxSchema.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDC23217DFADC006E9E73 /* SyntaxSchema.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521DCD0291EA349009642EF /* SyntaxLiteralValue.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDC13217DFADC006E9E73 /* SyntaxLiteralValue.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521DCD2291EA349009642EF /* StatementReindex.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDBDE217DFADC006E9E73 /* StatementReindex.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521DCD3291EA349009642EF /* SyntaxList.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDB76217DFADC006E9E73 /* SyntaxList.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521DCD6291EA349009642EF /* ColumnConstraint.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDB7F217DFADC006E9E73 /* ColumnConstraint.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521DCD7291EA349009642EF /* SQLiteDeclaration.h in Headers */ = {isa = PBXBuildFile; fileRef = 237A8D5721ED88DF003AF5BB /* SQLiteDeclaration.h */; };\n\t\t7521DCD8291EA349009642EF /* SyntaxEnum.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23545B9C2224E9C80091C981 /* SyntaxEnum.hpp */; };\n\t\t7521DCD9291EA349009642EF /* DBOperationNotifier.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 0DC98FD128E46049007F3796 /* DBOperationNotifier.hpp */; };\n\t\t7521DCDA291EA349009642EF /* StatementCreateView.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDBCA217DFADC006E9E73 /* StatementCreateView.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521DCDB291EA349009642EF /* SyntaxCreateVirtualTableSTMT.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDC44217DFADC006E9E73 /* SyntaxCreateVirtualTableSTMT.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521DCDC291EA349009642EF /* Shadow.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDD5F217DFB17006E9E73 /* Shadow.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521DCE0291EA349009642EF /* JoinConstraint.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDB95217DFADC006E9E73 /* JoinConstraint.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521DCE1291EA349009642EF /* SyntaxReleaseSTMT.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDC58217DFADC006E9E73 /* SyntaxReleaseSTMT.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521DCE2291EA349009642EF /* Serialization.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 2308F84E20E32A51001CD9C3 /* Serialization.hpp */; };\n\t\t7521DCE5291EA349009642EF /* SyntaxColumn.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDBF7217DFADC006E9E73 /* SyntaxColumn.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521DCE6291EA349009642EF /* InnerDatabase.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 2349F61C1EA0D6680021EFA7 /* InnerDatabase.hpp */; };\n\t\t7521DCE9291EA349009642EF /* MergeFTSIndexLogic.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 0D249BC02542B8E900B43BD9 /* MergeFTSIndexLogic.hpp */; };\n\t\t7521DCEA291EA349009642EF /* SyntaxAnalyzeSTMT.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDC34217DFADC006E9E73 /* SyntaxAnalyzeSTMT.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521DCEB291EA349009642EF /* SyntaxColumnConstraint.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDBF9217DFADC006E9E73 /* SyntaxColumnConstraint.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521DCF0291EA349009642EF /* SyntaxReindexSTMT.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDC56217DFADC006E9E73 /* SyntaxReindexSTMT.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521DCF1291EA349009642EF /* SyntaxCommonTableExpression.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDBFD217DFADC006E9E73 /* SyntaxCommonTableExpression.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521DCF2291EA349009642EF /* UpgradeableErrorProne.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23AD52F120DBAC4C00664B62 /* UpgradeableErrorProne.hpp */; };\n\t\t7521DCF4291EA349009642EF /* PagerRelated.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23567D5820CA823C005F1C35 /* PagerRelated.hpp */; };\n\t\t7521DCF7291EA349009642EF /* Tag.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23B4DC7D2111B39200954D71 /* Tag.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521DCF8291EA349009642EF /* SQLite.h in Headers */ = {isa = PBXBuildFile; fileRef = 23AB898D215BA6DB00554DF1 /* SQLite.h */; };\n\t\t7521DCF9291EA349009642EF /* SyntaxPragma.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDC19217DFADC006E9E73 /* SyntaxPragma.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521DCFF291EA349009642EF /* StatementCreateVirtualTable.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDBCC217DFADC006E9E73 /* StatementCreateVirtualTable.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521DD00291EA349009642EF /* SQLiteFTS3Tokenizer.h in Headers */ = {isa = PBXBuildFile; fileRef = 234F0337227A950900DD65A2 /* SQLiteFTS3Tokenizer.h */; };\n\t\t7521DD02291EA349009642EF /* HandlePool.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 2349F6231EA0D6680021EFA7 /* HandlePool.hpp */; };\n\t\t7521DD03291EA349009642EF /* StatementInsert.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDBDA217DFADC006E9E73 /* StatementInsert.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521DD04291EA349009642EF /* FactoryDepositor.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23D0C34C20C149D80001BFAE /* FactoryDepositor.hpp */; };\n\t\t7521DD06291EA349009642EF /* FrameSpec.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDB8D217DFADC006E9E73 /* FrameSpec.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521DD07291EA349009642EF /* TokenizerConfig.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23F70FBD20A055D400CCE3CD /* TokenizerConfig.hpp */; };\n\t\t7521DD08291EA349009642EF /* SyntaxCreateViewSTMT.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDC42217DFADC006E9E73 /* SyntaxCreateViewSTMT.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521DD0C291EA349009642EF /* Enum.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDD5E217DFB16006E9E73 /* Enum.hpp */; };\n\t\t7521DD0D291EA349009642EF /* SyntaxDetachSTMT.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDC48217DFADC006E9E73 /* SyntaxDetachSTMT.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521DD0E291EA349009642EF /* ColumnType.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDB6B217DFADC006E9E73 /* ColumnType.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521DD11291EA349009642EF /* SyntaxDeleteSTMT.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDC46217DFADC006E9E73 /* SyntaxDeleteSTMT.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521DD14291EA349009642EF /* StatementSavepoint.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDBE4217DFADC006E9E73 /* StatementSavepoint.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521DD18291EA349009642EF /* FullCrawler.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23775B3720AD666900E21AB0 /* FullCrawler.hpp */; };\n\t\t7521DD1A291EA349009642EF /* SQLiteAssembler.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23D0C30D20C125420001BFAE /* SQLiteAssembler.hpp */; };\n\t\t7521DD1D291EA349009642EF /* PinyinTokenizer.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 03450DB72738C8F800C4DC1B /* PinyinTokenizer.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521DD1E291EA349009642EF /* StatementAttach.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDBBE217DFADC006E9E73 /* StatementAttach.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521DD1F291EA349009642EF /* ColumnDef.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDB81217DFADC006E9E73 /* ColumnDef.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521DD22291EA349009642EF /* Wal.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EB91DD20CA1EBE00ECF668 /* Wal.hpp */; };\n\t\t7521DD23291EA349009642EF /* SyntaxSavepointSTMT.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDC5C217DFADC006E9E73 /* SyntaxSavepointSTMT.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521DD24291EA349009642EF /* AutoMigrateConfig.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23301BF42298FE9A00A8AB5A /* AutoMigrateConfig.hpp */; };\n\t\t7521DD26291EA349009642EF /* UniqueList.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 237A65F220F731DF008B4771 /* UniqueList.hpp */; };\n\t\t7521DD27291EA349009642EF /* HandleStatement.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 2370980920590CA700E768B4 /* HandleStatement.hpp */; };\n\t\t7521DD28291EA349009642EF /* FTS5AuxiliaryFunctionTemplate.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 7543DD82271C2F3B00B533B4 /* FTS5AuxiliaryFunctionTemplate.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521DD2A291EA349009642EF /* SQLiteLocker.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23C7559020DCF90F00031A93 /* SQLiteLocker.hpp */; };\n\t\t7521DD2D291EA349009642EF /* ConvertibleImplementation.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDB6E217DFADC006E9E73 /* ConvertibleImplementation.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521DD2E291EA349009642EF /* Value.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 03E5CC6D28A3BDF3005353D9 /* Value.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521DD2F291EA349009642EF /* RaiseFunction.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDBA1217DFADC006E9E73 /* RaiseFunction.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521DD30291EA349009642EF /* InnerHandle.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 39B524DB2304F9A1001DF52D /* InnerHandle.hpp */; };\n\t\t7521DD32291EA349009642EF /* Global.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 235FBE9422914E0D005C7723 /* Global.hpp */; };\n\t\t7521DD33291EA349009642EF /* StatementBegin.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDBC0217DFADC006E9E73 /* StatementBegin.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521DD34291EA349009642EF /* SyntaxQualifiedTableName.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDC1B217DFADC006E9E73 /* SyntaxQualifiedTableName.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521DD36291EA349009642EF /* SyntaxJoinClause.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDC0F217DFADC006E9E73 /* SyntaxJoinClause.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521DD37291EA349009642EF /* ObjectBridge.h in Headers */ = {isa = PBXBuildFile; fileRef = 03E167B727F46C7100D2C926 /* ObjectBridge.h */; settings = {ATTRIBUTES = (Private, ); }; };\n\t\t7521DD38291EA349009642EF /* StatementCreateTriggerBridge.h in Headers */ = {isa = PBXBuildFile; fileRef = 75EB1A12287F10BF00AA62F7 /* StatementCreateTriggerBridge.h */; settings = {ATTRIBUTES = (Private, ); }; };\n\t\t7521DD39291EA349009642EF /* UpsertBridge.h in Headers */ = {isa = PBXBuildFile; fileRef = 75AF6AF02855C8BF00A7C43D /* UpsertBridge.h */; settings = {ATTRIBUTES = (Private, ); }; };\n\t\t7521DD3B291EA349009642EF /* FrameSpecBridge.h in Headers */ = {isa = PBXBuildFile; fileRef = 752594E4285226C00068A602 /* FrameSpecBridge.h */; settings = {ATTRIBUTES = (Private, ); }; };\n\t\t7521DD3C291EA349009642EF /* PragmaBridge.h in Headers */ = {isa = PBXBuildFile; fileRef = 75AF6AF92856303700A7C43D /* PragmaBridge.h */; settings = {ATTRIBUTES = (Private, ); }; };\n\t\t7521DD3E291EA349009642EF /* StatementInsertBridge.h in Headers */ = {isa = PBXBuildFile; fileRef = 03EE3DA9288165A700C8F0B3 /* StatementInsertBridge.h */; settings = {ATTRIBUTES = (Private, ); }; };\n\t\t7521DD3F291EA349009642EF /* JoinBridge.h in Headers */ = {isa = PBXBuildFile; fileRef = 75AF6ADA2854C5ED00A7C43D /* JoinBridge.h */; settings = {ATTRIBUTES = (Private, ); }; };\n\t\t7521DD40291EA349009642EF /* RaiseFunctionBridge.h in Headers */ = {isa = PBXBuildFile; fileRef = 03E822902844E1AB0072CA57 /* RaiseFunctionBridge.h */; settings = {ATTRIBUTES = (Private, ); }; };\n\t\t7521DD41291EA349009642EF /* StatementCreateTableBridge.h in Headers */ = {isa = PBXBuildFile; fileRef = 757821E0286DF5EB0092F858 /* StatementCreateTableBridge.h */; settings = {ATTRIBUTES = (Private, ); }; };\n\t\t7521DD42291EA349009642EF /* StatementRollbackBridge.h in Headers */ = {isa = PBXBuildFile; fileRef = 75F4DE462884032600760DC3 /* StatementRollbackBridge.h */; settings = {ATTRIBUTES = (Private, ); }; };\n\t\t7521DD43291EA349009642EF /* IndexedColumnBridge.h in Headers */ = {isa = PBXBuildFile; fileRef = 03BFC5D62853538400673AE4 /* IndexedColumnBridge.h */; settings = {ATTRIBUTES = (Private, ); }; };\n\t\t7521DD44291EA349009642EF /* CoreBridge.h in Headers */ = {isa = PBXBuildFile; fileRef = 756A773F27FAC17F00105B7C /* CoreBridge.h */; settings = {ATTRIBUTES = (Private, ); }; };\n\t\t7521DD45291EA349009642EF /* StatementAttachBridge.h in Headers */ = {isa = PBXBuildFile; fileRef = 03DCB5ED286C3D8E00CBC75D /* StatementAttachBridge.h */; settings = {ATTRIBUTES = (Private, ); }; };\n\t\t7521DD46291EA349009642EF /* TableOrSubqueryBridge.h in Headers */ = {isa = PBXBuildFile; fileRef = 75AF6AD628544C8800A7C43D /* TableOrSubqueryBridge.h */; settings = {ATTRIBUTES = (Private, ); }; };\n\t\t7521DD47291EA349009642EF /* StatementCommitBridge.h in Headers */ = {isa = PBXBuildFile; fileRef = 75F4DE5E2884149100760DC3 /* StatementCommitBridge.h */; settings = {ATTRIBUTES = (Private, ); }; };\n\t\t7521DD48291EA349009642EF /* QualifiedTableBridge.h in Headers */ = {isa = PBXBuildFile; fileRef = 75AF6ADE2854EF6D00A7C43D /* QualifiedTableBridge.h */; settings = {ATTRIBUTES = (Private, ); }; };\n\t\t7521DD49291EA349009642EF /* HandleStatementBridge.h in Headers */ = {isa = PBXBuildFile; fileRef = 756A773727F9EDCA00105B7C /* HandleStatementBridge.h */; settings = {ATTRIBUTES = (Private, ); }; };\n\t\t7521DD4B291EA349009642EF /* TableConstraintBridge.h in Headers */ = {isa = PBXBuildFile; fileRef = 75AF6AEC28559F4800A7C43D /* TableConstraintBridge.h */; settings = {ATTRIBUTES = (Private, ); }; };\n\t\t7521DD4C291EA349009642EF /* StatementPragmaBridge.h in Headers */ = {isa = PBXBuildFile; fileRef = 75F4DE362883E88100760DC3 /* StatementPragmaBridge.h */; settings = {ATTRIBUTES = (Private, ); }; };\n\t\t7521DD4D291EA349009642EF /* StatementDetachBridge.h in Headers */ = {isa = PBXBuildFile; fileRef = 03F5481F287D8467007BCA3E /* StatementDetachBridge.h */; settings = {ATTRIBUTES = (Private, ); }; };\n\t\t7521DD4E291EA349009642EF /* StatementBeginBridge.h in Headers */ = {isa = PBXBuildFile; fileRef = 75F4DE5428840C4800760DC3 /* StatementBeginBridge.h */; settings = {ATTRIBUTES = (Private, ); }; };\n\t\t7521DD4F291EA349009642EF /* StatementCreateVirtualTableBridge.h in Headers */ = {isa = PBXBuildFile; fileRef = 75F1A3052871DE9A008503A2 /* StatementCreateVirtualTableBridge.h */; settings = {ATTRIBUTES = (Private, ); }; };\n\t\t7521DD50291EA349009642EF /* StatementCreateIndexBridge.h in Headers */ = {isa = PBXBuildFile; fileRef = 03DCB5F1286C480900CBC75D /* StatementCreateIndexBridge.h */; settings = {ATTRIBUTES = (Private, ); }; };\n\t\t7521DD51291EA349009642EF /* StatementDropIndexBridge.h in Headers */ = {isa = PBXBuildFile; fileRef = 03F54823287D87F9007BCA3E /* StatementDropIndexBridge.h */; settings = {ATTRIBUTES = (Private, ); }; };\n\t\t7521DD52291EA349009642EF /* StatementVacuumBridge.h in Headers */ = {isa = PBXBuildFile; fileRef = 75F4DE50288407F800760DC3 /* StatementVacuumBridge.h */; settings = {ATTRIBUTES = (Private, ); }; };\n\t\t7521DD54291EA349009642EF /* WinqBridge.h in Headers */ = {isa = PBXBuildFile; fileRef = 032612BB283F279800836E0F /* WinqBridge.h */; settings = {ATTRIBUTES = (Private, ); }; };\n\t\t7521DD55291EA349009642EF /* StatementDropViewBridge.h in Headers */ = {isa = PBXBuildFile; fileRef = 75EB196D287F093B00AA62F7 /* StatementDropViewBridge.h */; settings = {ATTRIBUTES = (Private, ); }; };\n\t\t7521DD56291EA349009642EF /* StatementSelectBridge.h in Headers */ = {isa = PBXBuildFile; fileRef = 03E822872844B8CD0072CA57 /* StatementSelectBridge.h */; settings = {ATTRIBUTES = (Private, ); }; };\n\t\t7521DD57291EA349009642EF /* BindParameterBridge.h in Headers */ = {isa = PBXBuildFile; fileRef = 03A57F1B2840B5DC00D2A4C3 /* BindParameterBridge.h */; settings = {ATTRIBUTES = (Private, ); }; };\n\t\t7521DD58291EA349009642EF /* StatementDropTriggerBridge.h in Headers */ = {isa = PBXBuildFile; fileRef = 75EB1964287F068200AA62F7 /* StatementDropTriggerBridge.h */; settings = {ATTRIBUTES = (Private, ); }; };\n\t\t7521DD59291EA349009642EF /* ErrorBridge.h in Headers */ = {isa = PBXBuildFile; fileRef = 0393BEDB27F6ED860058B295 /* ErrorBridge.h */; settings = {ATTRIBUTES = (Private, ); }; };\n\t\t7521DD5A291EA349009642EF /* ColumnDefBridge.h in Headers */ = {isa = PBXBuildFile; fileRef = 03E8227F28447B940072CA57 /* ColumnDefBridge.h */; settings = {ATTRIBUTES = (Private, ); }; };\n\t\t7521DD5B291EA349009642EF /* StatementReleaseBridge.h in Headers */ = {isa = PBXBuildFile; fileRef = 75F4DE422883FD6A00760DC3 /* StatementReleaseBridge.h */; settings = {ATTRIBUTES = (Private, ); }; };\n\t\t7521DD5D291EA349009642EF /* StatementCreateViewBridge.h in Headers */ = {isa = PBXBuildFile; fileRef = 75EB1A09287F0BDA00AA62F7 /* StatementCreateViewBridge.h */; settings = {ATTRIBUTES = (Private, ); }; };\n\t\t7521DD5E291EA349009642EF /* ColumnBridge.h in Headers */ = {isa = PBXBuildFile; fileRef = 032613B5283F8D7E00836E0F /* ColumnBridge.h */; settings = {ATTRIBUTES = (Private, ); }; };\n\t\t7521DD5F291EA349009642EF /* OrderingTermBridge.h in Headers */ = {isa = PBXBuildFile; fileRef = 75A46C0C2843B3BC00B58207 /* OrderingTermBridge.h */; settings = {ATTRIBUTES = (Private, ); }; };\n\t\t7521DD60291EA349009642EF /* StatementAlterTableBridge.h in Headers */ = {isa = PBXBuildFile; fileRef = 03B6A33B2869C51B00D83EC4 /* StatementAlterTableBridge.h */; settings = {ATTRIBUTES = (Private, ); }; };\n\t\t7521DD61291EA349009642EF /* HandleBridge.h in Headers */ = {isa = PBXBuildFile; fileRef = 0393BEE327F715180058B295 /* HandleBridge.h */; settings = {ATTRIBUTES = (Private, ); }; };\n\t\t7521DD62291EA349009642EF /* SchemaBridge.h in Headers */ = {isa = PBXBuildFile; fileRef = 75204AEA283FD7410002E40C /* SchemaBridge.h */; settings = {ATTRIBUTES = (Private, ); }; };\n\t\t7521DD63291EA349009642EF /* WindowDefBridge.h in Headers */ = {isa = PBXBuildFile; fileRef = 75C1034128450D840006BBCB /* WindowDefBridge.h */; settings = {ATTRIBUTES = (Private, ); }; };\n\t\t7521DD64291EA349009642EF /* FTSBridge.h in Headers */ = {isa = PBXBuildFile; fileRef = 750DC06A2913DE7300F19044 /* FTSBridge.h */; settings = {ATTRIBUTES = (Private, ); }; };\n\t\t7521DD65291EA349009642EF /* ExpressionBridge.h in Headers */ = {isa = PBXBuildFile; fileRef = 032613B9283F8E4900836E0F /* ExpressionBridge.h */; settings = {ATTRIBUTES = (Private, ); }; };\n\t\t7521DD66291EA349009642EF /* StatementExplainBridge.h in Headers */ = {isa = PBXBuildFile; fileRef = 75F4DE322883E43C00760DC3 /* StatementExplainBridge.h */; settings = {ATTRIBUTES = (Private, ); }; };\n\t\t7521DD67291EA349009642EF /* ColumnConstraintBridge.h in Headers */ = {isa = PBXBuildFile; fileRef = 75A46BFF284310CE00B58207 /* ColumnConstraintBridge.h */; settings = {ATTRIBUTES = (Private, ); }; };\n\t\t7521DD68291EA349009642EF /* DatabaseBridge.h in Headers */ = {isa = PBXBuildFile; fileRef = 039760AA27F5C0DD0071FA8F /* DatabaseBridge.h */; settings = {ATTRIBUTES = (Private, ); }; };\n\t\t7521DD69291EA349009642EF /* StatementDropTableBridge.h in Headers */ = {isa = PBXBuildFile; fileRef = 03F54827287D93A7007BCA3E /* StatementDropTableBridge.h */; settings = {ATTRIBUTES = (Private, ); }; };\n\t\t7521DD6A291EA349009642EF /* ExpressionOperatableBridge.h in Headers */ = {isa = PBXBuildFile; fileRef = 039BD4352846113D00C58BE2 /* ExpressionOperatableBridge.h */; settings = {ATTRIBUTES = (Private, ); }; };\n\t\t7521DD6B291EA349009642EF /* StatementReindexBridge.h in Headers */ = {isa = PBXBuildFile; fileRef = 75F4DE3E2883F0A800760DC3 /* StatementReindexBridge.h */; settings = {ATTRIBUTES = (Private, ); }; };\n\t\t7521DD6C291EA349009642EF /* StatementSavepointBridge.h in Headers */ = {isa = PBXBuildFile; fileRef = 75F4DE4A288405DD00760DC3 /* StatementSavepointBridge.h */; settings = {ATTRIBUTES = (Private, ); }; };\n\t\t7521DD6D291EA349009642EF /* CommonTableExpressionBridge.h in Headers */ = {isa = PBXBuildFile; fileRef = 03E822832844B8760072CA57 /* CommonTableExpressionBridge.h */; settings = {ATTRIBUTES = (Private, ); }; };\n\t\t7521DD6E291EA349009642EF /* StatementAnalyzeBridge.h in Headers */ = {isa = PBXBuildFile; fileRef = 03DCB5E5286C2E5300CBC75D /* StatementAnalyzeBridge.h */; settings = {ATTRIBUTES = (Private, ); }; };\n\t\t7521DD6F291EA349009642EF /* ForeignKeyBridge.h in Headers */ = {isa = PBXBuildFile; fileRef = 75A46C0328431D6300B58207 /* ForeignKeyBridge.h */; settings = {ATTRIBUTES = (Private, ); }; };\n\t\t7521DD70291EA349009642EF /* ResultColumnBridge.h in Headers */ = {isa = PBXBuildFile; fileRef = 75AF6AE8285594A100A7C43D /* ResultColumnBridge.h */; settings = {ATTRIBUTES = (Private, ); }; };\n\t\t7521DD71291EA349009642EF /* LiteralValueBridge.h in Headers */ = {isa = PBXBuildFile; fileRef = 0326130C283F56BD00836E0F /* LiteralValueBridge.h */; settings = {ATTRIBUTES = (Private, ); }; };\n\t\t7521DD72291EA349009642EF /* StatementDeleteBridge.h in Headers */ = {isa = PBXBuildFile; fileRef = 75F1A3092871E764008503A2 /* StatementDeleteBridge.h */; settings = {ATTRIBUTES = (Private, ); }; };\n\t\t7521DD73291EA349009642EF /* StatementUpdateBridge.h in Headers */ = {isa = PBXBuildFile; fileRef = 03EE3DAD28816DA800C8F0B3 /* StatementUpdateBridge.h */; settings = {ATTRIBUTES = (Private, ); }; };\n\t\t7521DD76291EA349009642EF /* CoreFunction.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDB70217DFADC006E9E73 /* CoreFunction.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521DD77291EA349009642EF /* Frame.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23567CF920CA3889005F1C35 /* Frame.hpp */; };\n\t\t7521DD78291EA349009642EF /* FTSConst.h in Headers */ = {isa = PBXBuildFile; fileRef = 754014C2290BEDA600EA8D33 /* FTSConst.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521DD7D291EA349009642EF /* Thread.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 390E1C5B2296414C00C24598 /* Thread.hpp */; };\n\t\t7521DD7F291EA349009642EF /* BaseBinding.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 7537E5D028B939240077D92B /* BaseBinding.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521DD80291EA349009642EF /* FileHandle.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 2308F84C20E32A51001CD9C3 /* FileHandle.hpp */; };\n\t\t7521DD82291EA349009642EF /* StatementDelete.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDBCE217DFADC006E9E73 /* StatementDelete.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521DD85291EA349009642EF /* OperationQueue.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 3934DAEA229B6659008A6AEC /* OperationQueue.hpp */; };\n\t\t7521DD86291EA349009642EF /* WindowDef.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDBB1217DFADC006E9E73 /* WindowDef.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521DD88291EA349009642EF /* ObjectBridge.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 03E167B927F46E2E00D2C926 /* ObjectBridge.hpp */; };\n\t\t7521DD8A291EA349009642EF /* SyntaxTableOrSubquery.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDC29217DFADC006E9E73 /* SyntaxTableOrSubquery.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521DD8B291EA349009642EF /* StatementRelease.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDBE0217DFADC006E9E73 /* StatementRelease.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521DD8D291EA349009642EF /* Notifier.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23775B3320AD666900E21AB0 /* Notifier.hpp */; };\n\t\t7521DD8E291EA349009642EF /* SyntaxCreateTriggerSTMT.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDC40217DFADC006E9E73 /* SyntaxCreateTriggerSTMT.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521DD90291EA349009642EF /* SyntaxIndexedColumn.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDC0D217DFADC006E9E73 /* SyntaxIndexedColumn.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521DD91291EA349009642EF /* SyntaxCommonConst.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 238C177C21CA2190003B6D26 /* SyntaxCommonConst.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521DD92291EA349009642EF /* StatementUpdate.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDBE8217DFADC006E9E73 /* StatementUpdate.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521DD93291EA349009642EF /* SQLiteBase.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23C7559920DD17B100031A93 /* SQLiteBase.hpp */; };\n\t\t7521DD94291EA349009642EF /* Expression.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDB87217DFADC006E9E73 /* Expression.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521DD96291EA349009642EF /* SyntaxPragmaSTMT.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDC54217DFADC006E9E73 /* SyntaxPragmaSTMT.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521DD97291EA349009642EF /* Upsert.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDBAF217DFADC006E9E73 /* Upsert.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521DD98291EA349009642EF /* AuxiliaryFunctionModule.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 7543DD85271C2FD000B533B4 /* AuxiliaryFunctionModule.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521DD9A291EA349009642EF /* BaseTokenizerUtil.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 75B698D4290AD4C0006E1F8F /* BaseTokenizerUtil.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521DD9B291EA349009642EF /* Configs.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23F70FC320A0618100CCE3CD /* Configs.hpp */; };\n\t\t7521DD9E291EA349009642EF /* SharedThreadedErrorProne.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23567D7420CA91FF005F1C35 /* SharedThreadedErrorProne.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521DD9F291EA349009642EF /* Range.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 2314AE7021070A1700244D39 /* Range.hpp */; };\n\t\t7521DDA0291EA349009642EF /* SyntaxResultColumn.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDC21217DFADC006E9E73 /* SyntaxResultColumn.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521DDA1291EA349009642EF /* FTSError.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 03EA88CD27D5F05D0075C7BD /* FTSError.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521DDA2291EA349009642EF /* Mechanic.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23775B4320AD666900E21AB0 /* Mechanic.hpp */; };\n\t\t7521DDA7291EA349009642EF /* SyntaxJoinConstraint.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDC11217DFADC006E9E73 /* SyntaxJoinConstraint.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521DDA8291EA349009642EF /* ErrorProne.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23567D4520CA7DBC005F1C35 /* ErrorProne.hpp */; };\n\t\t7521DDAA291EA349009642EF /* StatementCommit.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDBC2217DFADC006E9E73 /* StatementCommit.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521DDAB291EA349009642EF /* SyntaxColumnDef.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDBFB217DFADC006E9E73 /* SyntaxColumnDef.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521DDAC291EA349009642EF /* LRUCache.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 2316D9482105D21500707AFC /* LRUCache.hpp */; };\n\t\t7521DDAE291EA349009642EF /* StatementVacuum.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDBEA217DFADC006E9E73 /* StatementVacuum.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521DDAF291EA349009642EF /* Column.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDB7D217DFADC006E9E73 /* Column.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521DDB1291EA349009642EF /* TimedQueue.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 239776CE202AF2E2000A681C /* TimedQueue.hpp */; };\n\t\t7521DDB3291EA349009642EF /* Time.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23567D7A20CA93C5005F1C35 /* Time.hpp */; };\n\t\t7521DDB4291EA349009642EF /* FileManager.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23B9E67320AE733A00CF1683 /* FileManager.hpp */; };\n\t\t7521DDB7291EA349009642EF /* WCDBError.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23775B3120AD666900E21AB0 /* WCDBError.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521DDB8291EA349009642EF /* DatabasePool.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23D96B912050DED700DB5E93 /* DatabasePool.hpp */; };\n\t\t7521DDB9291EA349009642EF /* SyntaxWindowDef.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDC2D217DFADC006E9E73 /* SyntaxWindowDef.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521DDBB291EA349009642EF /* TableOrSubquery.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDBAD217DFADC006E9E73 /* TableOrSubquery.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521DDBD291EA349009642EF /* Statement.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDBB8217DFADC006E9E73 /* Statement.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521DDBE291EA349009642EF /* ThreadLocal.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23F0FEB2215F5E9A008399FB /* ThreadLocal.hpp */; };\n\t\t7521DDBF291EA349009642EF /* Schema.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDBA7217DFADC006E9E73 /* Schema.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521DDC0291EA349009642EF /* SyntaxDropIndexSTMT.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDC4A217DFADC006E9E73 /* SyntaxDropIndexSTMT.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521DDC1291EA349009642EF /* Assemble.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 39C70CC62313E20F002D773C /* Assemble.hpp */; };\n\t\t7521DDC4291EA349009642EF /* SyntaxBindParameter.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDBF5217DFADC006E9E73 /* SyntaxBindParameter.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521DDC5291EA349009642EF /* Lock.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23F0FEB1215F5E9A008399FB /* Lock.hpp */; };\n\t\t7521DDC6291EA349009642EF /* FactoryRetriever.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23D0C35020C149D80001BFAE /* FactoryRetriever.hpp */; };\n\t\t7521DDC9291EA349009642EF /* AutoCheckpointConfig.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 3934DB25229B951C008A6AEC /* AutoCheckpointConfig.hpp */; };\n\t\t7521DDCB291EA349009642EF /* SyntaxVacuumSTMT.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDC62217DFADC006E9E73 /* SyntaxVacuumSTMT.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521DDCC291EA349009642EF /* Material.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23775B4120AD666900E21AB0 /* Material.hpp */; };\n\t\t7521DDCD291EA349009642EF /* SyntaxInsertSTMT.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDC52217DFADC006E9E73 /* SyntaxInsertSTMT.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521DDCE291EA349009642EF /* AggregateFunction.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDB69217DFADC006E9E73 /* AggregateFunction.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521DDD1291EA349009642EF /* FactoryRenewer.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23DD76BC20CF78C800E9B451 /* FactoryRenewer.hpp */; };\n\t\t7521DDD2291EA349009642EF /* StatementAnalyze.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDBBC217DFADC006E9E73 /* StatementAnalyze.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521DDD3291EA349009642EF /* FactoryBackup.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23D0C38C20C17CAE0001BFAE /* FactoryBackup.hpp */; };\n\t\t7521DDD4291EA349009642EF /* CipherConfig.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23F70FAB20A055C300CCE3CD /* CipherConfig.hpp */; };\n\t\t7521DDD5291EA349009642EF /* SyntaxRollbackSTMT.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 23EEDC5A217DFADC006E9E73 /* SyntaxRollbackSTMT.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521DDDF291EA729009642EF /* StatementOperation.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 03321E8628A503F3000AFD6D /* StatementOperation.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7521DDE229208EB6009642EF /* WCTAPIBridge.h in Headers */ = {isa = PBXBuildFile; fileRef = 75CE3EFD2812D95100E132F6 /* WCTAPIBridge.h */; settings = {ATTRIBUTES = (Private, ); }; };\n\t\t7521DDE529209B8D009642EF /* ChainCall+WCTTableCoding.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7521DDE429209B8D009642EF /* ChainCall+WCTTableCoding.swift */; };\n\t\t7521DDE829209C90009642EF /* Handle+WCTTableCoding.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7521DDE729209C90009642EF /* Handle+WCTTableCoding.swift */; };\n\t\t7521DDEB29209D04009642EF /* Insert+WCTTableCoding.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7521DDEA29209D04009642EF /* Insert+WCTTableCoding.swift */; };\n\t\t7521DDEE29209DCE009642EF /* Update+WCTTableCoding.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7521DDED29209DCE009642EF /* Update+WCTTableCoding.swift */; };\n\t\t7521DDF029209E4E009642EF /* Select+WCTTableCoding.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7521DDEF29209E4E009642EF /* Select+WCTTableCoding.swift */; };\n\t\t7521DDF229209F45009642EF /* StatementInterface+WCTTableCoding.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7521DDF129209F45009642EF /* StatementInterface+WCTTableCoding.swift */; };\n\t\t7521DDF42920A0E3009642EF /* HandleStatement+WCTTableCoding.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7521DDF32920A0E3009642EF /* HandleStatement+WCTTableCoding.swift */; };\n\t\t7521DDF62920A12E009642EF /* InsertInterface+WCTTableCoding.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7521DDF52920A12E009642EF /* InsertInterface+WCTTableCoding.swift */; };\n\t\t7521DDF82920A623009642EF /* Database+WCTTableCoding.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7521DDF72920A623009642EF /* Database+WCTTableCoding.swift */; };\n\t\t7521DDFA2920A680009642EF /* UpdateInterface+WCTTableCoding.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7521DDF92920A680009642EF /* UpdateInterface+WCTTableCoding.swift */; };\n\t\t7522B4BF2A6D2EA900B465D6 /* MigrationTestObject.h in Sources */ = {isa = PBXBuildFile; fileRef = 7522B4BE2A6D2EA900B465D6 /* MigrationTestObject.h */; };\n\t\t7522B5172A6D38D800B465D6 /* NormalMigrationSourceObject.mm in Sources */ = {isa = PBXBuildFile; fileRef = 7522B5162A6D38D800B465D6 /* NormalMigrationSourceObject.mm */; };\n\t\t7522B51A2A6D3B3300B465D6 /* IntegerPrimaryKeyMigrationSourceObject.mm in Sources */ = {isa = PBXBuildFile; fileRef = 7522B5192A6D3B3300B465D6 /* IntegerPrimaryKeyMigrationSourceObject.mm */; };\n\t\t7522B51E2A6D3C8600B465D6 /* AutoIncrementMigrationSourceObject.mm in Sources */ = {isa = PBXBuildFile; fileRef = 7522B51D2A6D3C8600B465D6 /* AutoIncrementMigrationSourceObject.mm */; };\n\t\t7522B5212A6D592800B465D6 /* MigrationTestCase.mm in Sources */ = {isa = PBXBuildFile; fileRef = 7522B5202A6D592800B465D6 /* MigrationTestCase.mm */; };\n\t\t7522B5242A6D5DD600B465D6 /* Random+MigrationTestObject.mm in Sources */ = {isa = PBXBuildFile; fileRef = 7522B5232A6D5DD600B465D6 /* Random+MigrationTestObject.mm */; };\n\t\t7522B5272A6D6F6700B465D6 /* MigratingCRUDTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 7522B5262A6D6F6700B465D6 /* MigratingCRUDTests.mm */; };\n\t\t7522B5312A6D78BB00B465D6 /* IntegerPrimaryKeyMigrationObject.mm in Sources */ = {isa = PBXBuildFile; fileRef = 7522B52D2A6D78BA00B465D6 /* IntegerPrimaryKeyMigrationObject.mm */; };\n\t\t7522B5322A6D78BB00B465D6 /* NormalMigrationObject.mm in Sources */ = {isa = PBXBuildFile; fileRef = 7522B52F2A6D78BB00B465D6 /* NormalMigrationObject.mm */; };\n\t\t7522B5332A6D78BB00B465D6 /* AutoIncrementMigrationObject.mm in Sources */ = {isa = PBXBuildFile; fileRef = 7522B5302A6D78BB00B465D6 /* AutoIncrementMigrationObject.mm */; };\n\t\t7525175B2B12D43700485175 /* DecompressFunction.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 752517592B12D43700485175 /* DecompressFunction.cpp */; };\n\t\t7525175C2B12D43700485175 /* DecompressFunction.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 752517592B12D43700485175 /* DecompressFunction.cpp */; };\n\t\t7525175D2B12D43700485175 /* DecompressFunction.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 752517592B12D43700485175 /* DecompressFunction.cpp */; };\n\t\t7525175E2B12D43700485175 /* DecompressFunction.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 752517592B12D43700485175 /* DecompressFunction.cpp */; };\n\t\t7525175F2B12D43700485175 /* DecompressFunction.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 7525175A2B12D43700485175 /* DecompressFunction.hpp */; };\n\t\t752517602B12D43700485175 /* DecompressFunction.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 7525175A2B12D43700485175 /* DecompressFunction.hpp */; };\n\t\t752517612B12D43700485175 /* DecompressFunction.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 7525175A2B12D43700485175 /* DecompressFunction.hpp */; };\n\t\t752517622B12D43700485175 /* DecompressFunction.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 7525175A2B12D43700485175 /* DecompressFunction.hpp */; };\n\t\t752517662B12F13C00485175 /* CompressionConst.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 752517652B12F13C00485175 /* CompressionConst.hpp */; };\n\t\t752517672B12F13C00485175 /* CompressionConst.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 752517652B12F13C00485175 /* CompressionConst.hpp */; };\n\t\t752517682B12F13C00485175 /* CompressionConst.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 752517652B12F13C00485175 /* CompressionConst.hpp */; };\n\t\t752517692B12F13C00485175 /* CompressionConst.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 752517652B12F13C00485175 /* CompressionConst.hpp */; };\n\t\t7525176C2B12FDC700485175 /* ZSTDContext.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7525176A2B12FDC700485175 /* ZSTDContext.cpp */; };\n\t\t7525176D2B12FDC700485175 /* ZSTDContext.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7525176A2B12FDC700485175 /* ZSTDContext.cpp */; };\n\t\t7525176E2B12FDC700485175 /* ZSTDContext.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7525176A2B12FDC700485175 /* ZSTDContext.cpp */; };\n\t\t7525176F2B12FDC700485175 /* ZSTDContext.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7525176A2B12FDC700485175 /* ZSTDContext.cpp */; };\n\t\t752517702B12FDC700485175 /* ZSTDContext.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 7525176B2B12FDC700485175 /* ZSTDContext.hpp */; };\n\t\t752517712B12FDC700485175 /* ZSTDContext.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 7525176B2B12FDC700485175 /* ZSTDContext.hpp */; };\n\t\t752517722B12FDC700485175 /* ZSTDContext.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 7525176B2B12FDC700485175 /* ZSTDContext.hpp */; };\n\t\t752517732B12FDC700485175 /* ZSTDContext.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 7525176B2B12FDC700485175 /* ZSTDContext.hpp */; };\n\t\t752517752B132DAB00485175 /* CompressionConst.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 752517742B132DAB00485175 /* CompressionConst.cpp */; };\n\t\t752517762B132DAB00485175 /* CompressionConst.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 752517742B132DAB00485175 /* CompressionConst.cpp */; };\n\t\t752517772B132DAB00485175 /* CompressionConst.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 752517742B132DAB00485175 /* CompressionConst.cpp */; };\n\t\t752517782B132DAB00485175 /* CompressionConst.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 752517742B132DAB00485175 /* CompressionConst.cpp */; };\n\t\t752517812B1338AF00485175 /* CompressionRecord.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7525177F2B1338AF00485175 /* CompressionRecord.cpp */; };\n\t\t752517822B1338AF00485175 /* CompressionRecord.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7525177F2B1338AF00485175 /* CompressionRecord.cpp */; };\n\t\t752517832B1338AF00485175 /* CompressionRecord.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7525177F2B1338AF00485175 /* CompressionRecord.cpp */; };\n\t\t752517842B1338AF00485175 /* CompressionRecord.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7525177F2B1338AF00485175 /* CompressionRecord.cpp */; };\n\t\t752517852B1338AF00485175 /* CompressionRecord.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 752517802B1338AF00485175 /* CompressionRecord.hpp */; };\n\t\t752517862B1338AF00485175 /* CompressionRecord.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 752517802B1338AF00485175 /* CompressionRecord.hpp */; };\n\t\t752517872B1338AF00485175 /* CompressionRecord.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 752517802B1338AF00485175 /* CompressionRecord.hpp */; };\n\t\t752517882B1338AF00485175 /* CompressionRecord.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 752517802B1338AF00485175 /* CompressionRecord.hpp */; };\n\t\t7525178D2B133DB700485175 /* CompressHandleOperator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7525178B2B133DB700485175 /* CompressHandleOperator.cpp */; };\n\t\t7525178E2B133DB700485175 /* CompressHandleOperator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7525178B2B133DB700485175 /* CompressHandleOperator.cpp */; };\n\t\t7525178F2B133DB700485175 /* CompressHandleOperator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7525178B2B133DB700485175 /* CompressHandleOperator.cpp */; };\n\t\t752517902B133DB700485175 /* CompressHandleOperator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7525178B2B133DB700485175 /* CompressHandleOperator.cpp */; };\n\t\t752517912B133DB700485175 /* CompressHandleOperator.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 7525178C2B133DB700485175 /* CompressHandleOperator.hpp */; };\n\t\t752517922B133DB700485175 /* CompressHandleOperator.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 7525178C2B133DB700485175 /* CompressHandleOperator.hpp */; };\n\t\t752517932B133DB700485175 /* CompressHandleOperator.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 7525178C2B133DB700485175 /* CompressHandleOperator.hpp */; };\n\t\t752517942B133DB700485175 /* CompressHandleOperator.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 7525178C2B133DB700485175 /* CompressHandleOperator.hpp */; };\n\t\t752594932851FCEF0068A602 /* RaiseFunctionTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 752594922851FCEF0068A602 /* RaiseFunctionTests.swift */; };\n\t\t752594E5285226C00068A602 /* FrameSpecBridge.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 752594E3285226C00068A602 /* FrameSpecBridge.cpp */; };\n\t\t752594E6285226C00068A602 /* FrameSpecBridge.h in Headers */ = {isa = PBXBuildFile; fileRef = 752594E4285226C00068A602 /* FrameSpecBridge.h */; settings = {ATTRIBUTES = (Private, ); }; };\n\t\t752594E828522A4A0068A602 /* FrameSpec.swift in Sources */ = {isa = PBXBuildFile; fileRef = 752594E728522A4A0068A602 /* FrameSpec.swift */; };\n\t\t7525C1532920AB1900FD34C7 /* SelectInterface+WCTTableCoding.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7525C1522920AB1900FD34C7 /* SelectInterface+WCTTableCoding.swift */; };\n\t\t7525C1562920ACD700FD34C7 /* TableInterface+WCTTableCoding.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7525C1552920ACD700FD34C7 /* TableInterface+WCTTableCoding.swift */; };\n\t\t7525C1592920AD7900FD34C7 /* Table+WCTTableCoding.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7525C1582920AD7900FD34C7 /* Table+WCTTableCoding.swift */; };\n\t\t7525C15C2920D22300FD34C7 /* TableCRUDInterface+WCTTableCoding.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7525C15B2920D22300FD34C7 /* TableCRUDInterface+WCTTableCoding.swift */; };\n\t\t75294DAF29C75058005E7FC0 /* OperationQueueForMemory.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 75294DAD29C75058005E7FC0 /* OperationQueueForMemory.cpp */; };\n\t\t75294DB029C75058005E7FC0 /* OperationQueueForMemory.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 75294DAD29C75058005E7FC0 /* OperationQueueForMemory.cpp */; };\n\t\t75294DB129C75058005E7FC0 /* OperationQueueForMemory.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 75294DAD29C75058005E7FC0 /* OperationQueueForMemory.cpp */; };\n\t\t75294DB229C75058005E7FC0 /* OperationQueueForMemory.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 75294DAD29C75058005E7FC0 /* OperationQueueForMemory.cpp */; };\n\t\t75294DB329C75058005E7FC0 /* OperationQueueForMemory.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 75294DAE29C75058005E7FC0 /* OperationQueueForMemory.hpp */; };\n\t\t75294DB429C75058005E7FC0 /* OperationQueueForMemory.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 75294DAE29C75058005E7FC0 /* OperationQueueForMemory.hpp */; };\n\t\t75294DB529C75058005E7FC0 /* OperationQueueForMemory.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 75294DAE29C75058005E7FC0 /* OperationQueueForMemory.hpp */; };\n\t\t75294DB629C75058005E7FC0 /* OperationQueueForMemory.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 75294DAE29C75058005E7FC0 /* OperationQueueForMemory.hpp */; };\n\t\t7529C7702ABC4D6600518293 /* CipherHandle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 75F3140B2AAC067B007FFDFB /* CipherHandle.cpp */; };\n\t\t7529C7712ABC4D6A00518293 /* CipherHandle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 75F3140B2AAC067B007FFDFB /* CipherHandle.cpp */; };\n\t\t7529C7722ABC4D6D00518293 /* CipherHandle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 75F3140B2AAC067B007FFDFB /* CipherHandle.cpp */; };\n\t\t7529C7792ABC4D9900518293 /* CipherHandle.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 75F3140C2AAC067B007FFDFB /* CipherHandle.hpp */; };\n\t\t7529C77A2ABC4D9900518293 /* CipherHandle.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 75F3140C2AAC067B007FFDFB /* CipherHandle.hpp */; };\n\t\t7529C77B2ABC4D9A00518293 /* CipherHandle.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 75F3140C2AAC067B007FFDFB /* CipherHandle.hpp */; };\n\t\t752C7E3D28C8E16800C9FFA6 /* ORMDeleteTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 752C7E3C28C8E16800C9FFA6 /* ORMDeleteTests.mm */; };\n\t\t752C7E4028C8E94200C9FFA6 /* ORMInsertTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 752C7E3F28C8E94200C9FFA6 /* ORMInsertTests.mm */; };\n\t\t752CF3F8293A490F009ED8FB /* BindingBridge.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 752CF3F6293A490F009ED8FB /* BindingBridge.cpp */; };\n\t\t752CF3F9293A490F009ED8FB /* BindingBridge.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 752CF3F6293A490F009ED8FB /* BindingBridge.cpp */; };\n\t\t752CF3FA293A490F009ED8FB /* BindingBridge.h in Headers */ = {isa = PBXBuildFile; fileRef = 752CF3F7293A490F009ED8FB /* BindingBridge.h */; settings = {ATTRIBUTES = (Private, ); }; };\n\t\t752CF3FB293A490F009ED8FB /* BindingBridge.h in Headers */ = {isa = PBXBuildFile; fileRef = 752CF3F7293A490F009ED8FB /* BindingBridge.h */; settings = {ATTRIBUTES = (Private, ); }; };\n\t\t7533CB4F2B050FA300C8B47D /* MigratingHandleDecorator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7533CB4D2B050FA300C8B47D /* MigratingHandleDecorator.cpp */; };\n\t\t7533CB502B050FA300C8B47D /* MigratingHandleDecorator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7533CB4D2B050FA300C8B47D /* MigratingHandleDecorator.cpp */; };\n\t\t7533CB512B050FA300C8B47D /* MigratingHandleDecorator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7533CB4D2B050FA300C8B47D /* MigratingHandleDecorator.cpp */; };\n\t\t7533CB522B050FA300C8B47D /* MigratingHandleDecorator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7533CB4D2B050FA300C8B47D /* MigratingHandleDecorator.cpp */; };\n\t\t7533CB532B050FA300C8B47D /* MigratingHandleDecorator.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 7533CB4E2B050FA300C8B47D /* MigratingHandleDecorator.hpp */; };\n\t\t7533CB542B050FA300C8B47D /* MigratingHandleDecorator.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 7533CB4E2B050FA300C8B47D /* MigratingHandleDecorator.hpp */; };\n\t\t7533CB552B050FA300C8B47D /* MigratingHandleDecorator.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 7533CB4E2B050FA300C8B47D /* MigratingHandleDecorator.hpp */; };\n\t\t7533CB562B050FA300C8B47D /* MigratingHandleDecorator.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 7533CB4E2B050FA300C8B47D /* MigratingHandleDecorator.hpp */; };\n\t\t7533CB592B050FB200C8B47D /* MigratingStatementDecorator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7533CB572B050FB200C8B47D /* MigratingStatementDecorator.cpp */; };\n\t\t7533CB5A2B050FB200C8B47D /* MigratingStatementDecorator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7533CB572B050FB200C8B47D /* MigratingStatementDecorator.cpp */; };\n\t\t7533CB5B2B050FB200C8B47D /* MigratingStatementDecorator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7533CB572B050FB200C8B47D /* MigratingStatementDecorator.cpp */; };\n\t\t7533CB5C2B050FB200C8B47D /* MigratingStatementDecorator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7533CB572B050FB200C8B47D /* MigratingStatementDecorator.cpp */; };\n\t\t7533CB5D2B050FB200C8B47D /* MigratingStatementDecorator.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 7533CB582B050FB200C8B47D /* MigratingStatementDecorator.hpp */; };\n\t\t7533CB5E2B050FB200C8B47D /* MigratingStatementDecorator.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 7533CB582B050FB200C8B47D /* MigratingStatementDecorator.hpp */; };\n\t\t7533CB5F2B050FB200C8B47D /* MigratingStatementDecorator.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 7533CB582B050FB200C8B47D /* MigratingStatementDecorator.hpp */; };\n\t\t7533CB602B050FB200C8B47D /* MigratingStatementDecorator.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 7533CB582B050FB200C8B47D /* MigratingStatementDecorator.hpp */; };\n\t\t7533CB612B0516A600C8B47D /* MemberPointer.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 03AFD33928B8A6BD00EF5E56 /* MemberPointer.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7533CB682B051C4F00C8B47D /* ClassDecorator.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 7533CB632B051C4F00C8B47D /* ClassDecorator.hpp */; };\n\t\t7533CB692B051C4F00C8B47D /* ClassDecorator.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 7533CB632B051C4F00C8B47D /* ClassDecorator.hpp */; };\n\t\t7533CB6A2B051C4F00C8B47D /* ClassDecorator.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 7533CB632B051C4F00C8B47D /* ClassDecorator.hpp */; };\n\t\t7533CB6B2B051C4F00C8B47D /* ClassDecorator.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 7533CB632B051C4F00C8B47D /* ClassDecorator.hpp */; };\n\t\t753473602935C1E400911FCA /* DatabaseTestCase.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7534735F2935C1E400911FCA /* DatabaseTestCase.swift */; };\n\t\t753473612935C1E400911FCA /* DatabaseTestCase.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7534735F2935C1E400911FCA /* DatabaseTestCase.swift */; };\n\t\t753636DC28BBC3820025C2C4 /* Table.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 753636DA28BBC3820025C2C4 /* Table.cpp */; };\n\t\t753636DD28BBC3820025C2C4 /* Table.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 753636DA28BBC3820025C2C4 /* Table.cpp */; };\n\t\t753636DE28BBC3820025C2C4 /* Table.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 753636DB28BBC3820025C2C4 /* Table.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t753636DF28BBC3820025C2C4 /* Table.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 753636DB28BBC3820025C2C4 /* Table.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7537E58528B91F510077D92B /* Accessor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7537E58428B91F510077D92B /* Accessor.cpp */; };\n\t\t7537E58628B91F510077D92B /* Accessor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7537E58428B91F510077D92B /* Accessor.cpp */; };\n\t\t7537E5D128B939240077D92B /* BaseBinding.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7537E5CF28B939240077D92B /* BaseBinding.cpp */; };\n\t\t7537E5D228B939240077D92B /* BaseBinding.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7537E5CF28B939240077D92B /* BaseBinding.cpp */; };\n\t\t7537E5D328B939240077D92B /* BaseBinding.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 7537E5D028B939240077D92B /* BaseBinding.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7537E5D428B939240077D92B /* BaseBinding.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 7537E5D028B939240077D92B /* BaseBinding.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t753C084A28A8B0110042C427 /* CPPDatabaseTest.mm in Sources */ = {isa = PBXBuildFile; fileRef = 753C084928A8B0110042C427 /* CPPDatabaseTest.mm */; };\n\t\t753C084D28A8D4560042C427 /* StatementOperationTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 753C084C28A8D4560042C427 /* StatementOperationTests.mm */; };\n\t\t753C085028A8D5F70042C427 /* CPPCRUDTestCase.mm in Sources */ = {isa = PBXBuildFile; fileRef = 753C084F28A8D5F70042C427 /* CPPCRUDTestCase.mm */; };\n\t\t75401478290BE51400EA8D33 /* PinyinTokenizer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 03450DB62738C8F800C4DC1B /* PinyinTokenizer.cpp */; };\n\t\t754014C3290BEDA600EA8D33 /* FTSConst.h in Headers */ = {isa = PBXBuildFile; fileRef = 754014C2290BEDA600EA8D33 /* FTSConst.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t754014C4290BEDA600EA8D33 /* FTSConst.h in Headers */ = {isa = PBXBuildFile; fileRef = 754014C2290BEDA600EA8D33 /* FTSConst.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t754211DC2B11FE9200A2FF4D /* ScalarFunctionModule.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 754211DA2B11FE9200A2FF4D /* ScalarFunctionModule.cpp */; };\n\t\t754211DD2B11FE9200A2FF4D /* ScalarFunctionModule.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 754211DA2B11FE9200A2FF4D /* ScalarFunctionModule.cpp */; };\n\t\t754211DE2B11FE9200A2FF4D /* ScalarFunctionModule.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 754211DA2B11FE9200A2FF4D /* ScalarFunctionModule.cpp */; };\n\t\t754211DF2B11FE9200A2FF4D /* ScalarFunctionModule.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 754211DA2B11FE9200A2FF4D /* ScalarFunctionModule.cpp */; };\n\t\t754211E02B11FE9200A2FF4D /* ScalarFunctionModule.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 754211DB2B11FE9200A2FF4D /* ScalarFunctionModule.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t754211E12B11FE9200A2FF4D /* ScalarFunctionModule.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 754211DB2B11FE9200A2FF4D /* ScalarFunctionModule.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t754211E22B11FE9200A2FF4D /* ScalarFunctionModule.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 754211DB2B11FE9200A2FF4D /* ScalarFunctionModule.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t754211E32B11FE9200A2FF4D /* ScalarFunctionModule.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 754211DB2B11FE9200A2FF4D /* ScalarFunctionModule.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t754211EE2B12331900A2FF4D /* FunctionModules.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 754211E92B12331900A2FF4D /* FunctionModules.hpp */; };\n\t\t754211EF2B12331900A2FF4D /* FunctionModules.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 754211E92B12331900A2FF4D /* FunctionModules.hpp */; };\n\t\t754211F02B12331900A2FF4D /* FunctionModules.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 754211E92B12331900A2FF4D /* FunctionModules.hpp */; };\n\t\t754211F12B12331900A2FF4D /* FunctionModules.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 754211E92B12331900A2FF4D /* FunctionModules.hpp */; };\n\t\t754211F52B12359400A2FF4D /* ScalarFunctionConfig.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 754211F32B12359400A2FF4D /* ScalarFunctionConfig.cpp */; };\n\t\t754211F62B12359400A2FF4D /* ScalarFunctionConfig.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 754211F32B12359400A2FF4D /* ScalarFunctionConfig.cpp */; };\n\t\t754211F72B12359400A2FF4D /* ScalarFunctionConfig.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 754211F32B12359400A2FF4D /* ScalarFunctionConfig.cpp */; };\n\t\t754211F82B12359400A2FF4D /* ScalarFunctionConfig.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 754211F32B12359400A2FF4D /* ScalarFunctionConfig.cpp */; };\n\t\t754211F92B12359400A2FF4D /* ScalarFunctionConfig.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 754211F42B12359400A2FF4D /* ScalarFunctionConfig.hpp */; };\n\t\t754211FA2B12359400A2FF4D /* ScalarFunctionConfig.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 754211F42B12359400A2FF4D /* ScalarFunctionConfig.hpp */; };\n\t\t754211FB2B12359400A2FF4D /* ScalarFunctionConfig.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 754211F42B12359400A2FF4D /* ScalarFunctionConfig.hpp */; };\n\t\t754211FC2B12359400A2FF4D /* ScalarFunctionConfig.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 754211F42B12359400A2FF4D /* ScalarFunctionConfig.hpp */; };\n\t\t754212032B123E3200A2FF4D /* ScalarFunctionTemplate.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 754211FE2B123E3200A2FF4D /* ScalarFunctionTemplate.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t754212042B123E3200A2FF4D /* ScalarFunctionTemplate.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 754211FE2B123E3200A2FF4D /* ScalarFunctionTemplate.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t754212052B123E3200A2FF4D /* ScalarFunctionTemplate.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 754211FE2B123E3200A2FF4D /* ScalarFunctionTemplate.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t754212062B123E3200A2FF4D /* ScalarFunctionTemplate.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 754211FE2B123E3200A2FF4D /* ScalarFunctionTemplate.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t754212122B124CFF00A2FF4D /* CompressionCenter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7542120A2B124CFF00A2FF4D /* CompressionCenter.cpp */; };\n\t\t754212132B124CFF00A2FF4D /* CompressionCenter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7542120A2B124CFF00A2FF4D /* CompressionCenter.cpp */; };\n\t\t754212142B124CFF00A2FF4D /* CompressionCenter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7542120A2B124CFF00A2FF4D /* CompressionCenter.cpp */; };\n\t\t754212152B124CFF00A2FF4D /* CompressionCenter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7542120A2B124CFF00A2FF4D /* CompressionCenter.cpp */; };\n\t\t754212162B124CFF00A2FF4D /* ZSTDDict.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7542120B2B124CFF00A2FF4D /* ZSTDDict.cpp */; };\n\t\t754212172B124CFF00A2FF4D /* ZSTDDict.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7542120B2B124CFF00A2FF4D /* ZSTDDict.cpp */; };\n\t\t754212182B124CFF00A2FF4D /* ZSTDDict.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7542120B2B124CFF00A2FF4D /* ZSTDDict.cpp */; };\n\t\t754212192B124CFF00A2FF4D /* ZSTDDict.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7542120B2B124CFF00A2FF4D /* ZSTDDict.cpp */; };\n\t\t7542121A2B124CFF00A2FF4D /* CompressionInfo.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7542120C2B124CFF00A2FF4D /* CompressionInfo.cpp */; };\n\t\t7542121B2B124CFF00A2FF4D /* CompressionInfo.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7542120C2B124CFF00A2FF4D /* CompressionInfo.cpp */; };\n\t\t7542121C2B124CFF00A2FF4D /* CompressionInfo.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7542120C2B124CFF00A2FF4D /* CompressionInfo.cpp */; };\n\t\t7542121D2B124CFF00A2FF4D /* CompressionInfo.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7542120C2B124CFF00A2FF4D /* CompressionInfo.cpp */; };\n\t\t7542121E2B124CFF00A2FF4D /* Compression.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7542120D2B124CFF00A2FF4D /* Compression.cpp */; };\n\t\t7542121F2B124CFF00A2FF4D /* Compression.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7542120D2B124CFF00A2FF4D /* Compression.cpp */; };\n\t\t754212202B124CFF00A2FF4D /* Compression.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7542120D2B124CFF00A2FF4D /* Compression.cpp */; };\n\t\t754212212B124CFF00A2FF4D /* Compression.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7542120D2B124CFF00A2FF4D /* Compression.cpp */; };\n\t\t754212222B124CFF00A2FF4D /* CompressionCenter.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 7542120E2B124CFF00A2FF4D /* CompressionCenter.hpp */; };\n\t\t754212232B124CFF00A2FF4D /* CompressionCenter.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 7542120E2B124CFF00A2FF4D /* CompressionCenter.hpp */; };\n\t\t754212242B124CFF00A2FF4D /* CompressionCenter.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 7542120E2B124CFF00A2FF4D /* CompressionCenter.hpp */; };\n\t\t754212252B124CFF00A2FF4D /* CompressionCenter.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 7542120E2B124CFF00A2FF4D /* CompressionCenter.hpp */; };\n\t\t754212262B124CFF00A2FF4D /* ZSTDDict.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 7542120F2B124CFF00A2FF4D /* ZSTDDict.hpp */; };\n\t\t754212272B124CFF00A2FF4D /* ZSTDDict.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 7542120F2B124CFF00A2FF4D /* ZSTDDict.hpp */; };\n\t\t754212282B124CFF00A2FF4D /* ZSTDDict.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 7542120F2B124CFF00A2FF4D /* ZSTDDict.hpp */; };\n\t\t754212292B124CFF00A2FF4D /* ZSTDDict.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 7542120F2B124CFF00A2FF4D /* ZSTDDict.hpp */; };\n\t\t7542122A2B124CFF00A2FF4D /* CompressionInfo.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 754212102B124CFF00A2FF4D /* CompressionInfo.hpp */; };\n\t\t7542122B2B124CFF00A2FF4D /* CompressionInfo.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 754212102B124CFF00A2FF4D /* CompressionInfo.hpp */; };\n\t\t7542122C2B124CFF00A2FF4D /* CompressionInfo.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 754212102B124CFF00A2FF4D /* CompressionInfo.hpp */; };\n\t\t7542122D2B124CFF00A2FF4D /* CompressionInfo.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 754212102B124CFF00A2FF4D /* CompressionInfo.hpp */; };\n\t\t7542122E2B124CFF00A2FF4D /* Compression.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 754212112B124CFF00A2FF4D /* Compression.hpp */; };\n\t\t7542122F2B124CFF00A2FF4D /* Compression.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 754212112B124CFF00A2FF4D /* Compression.hpp */; };\n\t\t754212302B124CFF00A2FF4D /* Compression.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 754212112B124CFF00A2FF4D /* Compression.hpp */; };\n\t\t754212312B124CFF00A2FF4D /* Compression.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 754212112B124CFF00A2FF4D /* Compression.hpp */; };\n\t\t754359462B066DBD00CDF232 /* HandleOperator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 754359442B066DBD00CDF232 /* HandleOperator.cpp */; };\n\t\t754359472B066DBD00CDF232 /* HandleOperator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 754359442B066DBD00CDF232 /* HandleOperator.cpp */; };\n\t\t754359482B066DBD00CDF232 /* HandleOperator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 754359442B066DBD00CDF232 /* HandleOperator.cpp */; };\n\t\t754359492B066DBD00CDF232 /* HandleOperator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 754359442B066DBD00CDF232 /* HandleOperator.cpp */; };\n\t\t7543594A2B066DBD00CDF232 /* HandleOperator.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 754359452B066DBD00CDF232 /* HandleOperator.hpp */; };\n\t\t7543594B2B066DBD00CDF232 /* HandleOperator.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 754359452B066DBD00CDF232 /* HandleOperator.hpp */; };\n\t\t7543594C2B066DBD00CDF232 /* HandleOperator.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 754359452B066DBD00CDF232 /* HandleOperator.hpp */; };\n\t\t7543594D2B066DBD00CDF232 /* HandleOperator.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 754359452B066DBD00CDF232 /* HandleOperator.hpp */; };\n\t\t754359502B0671DE00CDF232 /* BackupHandleOperator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7543594E2B0671DE00CDF232 /* BackupHandleOperator.cpp */; };\n\t\t754359512B0671DE00CDF232 /* BackupHandleOperator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7543594E2B0671DE00CDF232 /* BackupHandleOperator.cpp */; };\n\t\t754359522B0671DE00CDF232 /* BackupHandleOperator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7543594E2B0671DE00CDF232 /* BackupHandleOperator.cpp */; };\n\t\t754359532B0671DE00CDF232 /* BackupHandleOperator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7543594E2B0671DE00CDF232 /* BackupHandleOperator.cpp */; };\n\t\t754359542B0671DE00CDF232 /* BackupHandleOperator.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 7543594F2B0671DE00CDF232 /* BackupHandleOperator.hpp */; };\n\t\t754359552B0671DE00CDF232 /* BackupHandleOperator.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 7543594F2B0671DE00CDF232 /* BackupHandleOperator.hpp */; };\n\t\t754359562B0671DE00CDF232 /* BackupHandleOperator.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 7543594F2B0671DE00CDF232 /* BackupHandleOperator.hpp */; };\n\t\t754359572B0671DE00CDF232 /* BackupHandleOperator.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 7543594F2B0671DE00CDF232 /* BackupHandleOperator.hpp */; };\n\t\t7543DD83271C2F3B00B533B4 /* FTS5AuxiliaryFunctionTemplate.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 7543DD82271C2F3B00B533B4 /* FTS5AuxiliaryFunctionTemplate.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7543DD86271C2FD000B533B4 /* AuxiliaryFunctionModule.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7543DD84271C2FD000B533B4 /* AuxiliaryFunctionModule.cpp */; };\n\t\t7543DD87271C2FD000B533B4 /* AuxiliaryFunctionModule.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 7543DD85271C2FD000B533B4 /* AuxiliaryFunctionModule.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7543DD8E271C360E00B533B4 /* AuxiliaryFunctionConfig.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7543DD8C271C360E00B533B4 /* AuxiliaryFunctionConfig.cpp */; };\n\t\t7543DD8F271C360E00B533B4 /* AuxiliaryFunctionConfig.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 7543DD8D271C360E00B533B4 /* AuxiliaryFunctionConfig.hpp */; };\n\t\t7543DD92271C601F00B533B4 /* SubstringMatchInfo.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7543DD90271C601F00B533B4 /* SubstringMatchInfo.cpp */; };\n\t\t7543DD93271C601F00B533B4 /* SubstringMatchInfo.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 7543DD91271C601F00B533B4 /* SubstringMatchInfo.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7543EDE3293B49CB00336DA9 /* ORMTestCase.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7543EDE2293B49CB00336DA9 /* ORMTestCase.swift */; };\n\t\t7546D45629D02BB6001B5611 /* WCDB.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 239326611E836D7300D677CC /* WCDB.framework */; };\n\t\t7547A3CD290D28A200AFA132 /* OneOrBinaryTokenizer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 03450DB22738BBF000C4DC1B /* OneOrBinaryTokenizer.cpp */; };\n\t\t7547A3CF290D2B2600AFA132 /* CPPFTS3Tests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 7547A3CE290D2B2600AFA132 /* CPPFTS3Tests.mm */; };\n\t\t75535243290E620F008376AB /* CPPFTS5Object.mm in Sources */ = {isa = PBXBuildFile; fileRef = 75535242290E620F008376AB /* CPPFTS5Object.mm */; };\n\t\t75535246290E63E5008376AB /* CPPFTS5Tests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 75535245290E63E5008376AB /* CPPFTS5Tests.mm */; };\n\t\t755391D62403B3DB00036918 /* WCTPreparedStatement.mm in Sources */ = {isa = PBXBuildFile; fileRef = 755391D52403B3DB00036918 /* WCTPreparedStatement.mm */; };\n\t\t755391E12403CB9E00036918 /* WCTPreparedStatement+Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 755391E02403CB9700036918 /* WCTPreparedStatement+Private.h */; };\n\t\t755B5A6929154361006955AF /* OneOrBinaryTokenizer.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 03450DB32738BBF000C4DC1B /* OneOrBinaryTokenizer.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t756A773827F9EDCA00105B7C /* HandleStatementBridge.h in Headers */ = {isa = PBXBuildFile; fileRef = 756A773727F9EDCA00105B7C /* HandleStatementBridge.h */; settings = {ATTRIBUTES = (Private, ); }; };\n\t\t756A773D27F9EDDE00105B7C /* HandleStatementBridge.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 756A773C27F9EDDE00105B7C /* HandleStatementBridge.cpp */; };\n\t\t756A774027FAC18000105B7C /* CoreBridge.h in Headers */ = {isa = PBXBuildFile; fileRef = 756A773F27FAC17F00105B7C /* CoreBridge.h */; settings = {ATTRIBUTES = (Private, ); }; };\n\t\t756A774327FAC1D900105B7C /* CoreBridge.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 756A774227FAC1D900105B7C /* CoreBridge.cpp */; };\n\t\t756E89032AF13FDB00A54DB2 /* CPPSharedPtrAllTypesObject.mm in Sources */ = {isa = PBXBuildFile; fileRef = 0D435A602AF1092100FABDAF /* CPPSharedPtrAllTypesObject.mm */; };\n\t\t756F7F642B2CA4B5002AEA0A /* FactoryVacuum.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 756F7F622B2CA4B5002AEA0A /* FactoryVacuum.cpp */; };\n\t\t756F7F652B2CA4B5002AEA0A /* FactoryVacuum.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 756F7F622B2CA4B5002AEA0A /* FactoryVacuum.cpp */; };\n\t\t756F7F662B2CA4B5002AEA0A /* FactoryVacuum.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 756F7F622B2CA4B5002AEA0A /* FactoryVacuum.cpp */; };\n\t\t756F7F672B2CA4B5002AEA0A /* FactoryVacuum.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 756F7F622B2CA4B5002AEA0A /* FactoryVacuum.cpp */; };\n\t\t756F7F682B2CA4B5002AEA0A /* FactoryVacuum.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 756F7F632B2CA4B5002AEA0A /* FactoryVacuum.hpp */; };\n\t\t756F7F692B2CA4B5002AEA0A /* FactoryVacuum.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 756F7F632B2CA4B5002AEA0A /* FactoryVacuum.hpp */; };\n\t\t756F7F6A2B2CA4B5002AEA0A /* FactoryVacuum.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 756F7F632B2CA4B5002AEA0A /* FactoryVacuum.hpp */; };\n\t\t756F7F6B2B2CA4B5002AEA0A /* FactoryVacuum.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 756F7F632B2CA4B5002AEA0A /* FactoryVacuum.hpp */; };\n\t\t757457042402D614005E3682 /* WCTPreparedStatement.h in Headers */ = {isa = PBXBuildFile; fileRef = 757457032402D614005E3682 /* WCTPreparedStatement.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t757821E1286DF5EB0092F858 /* StatementCreateTableBridge.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 757821DF286DF5EB0092F858 /* StatementCreateTableBridge.cpp */; };\n\t\t757821E2286DF5EB0092F858 /* StatementCreateTableBridge.h in Headers */ = {isa = PBXBuildFile; fileRef = 757821E0286DF5EB0092F858 /* StatementCreateTableBridge.h */; settings = {ATTRIBUTES = (Private, ); }; };\n\t\t7587F21C2EC2DF3300CC5224 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 7587F21B2EC2DF3300CC5224 /* UIKit.framework */; platformFilters = (ios, maccatalyst, tvos, watchos, ); };\n\t\t7587F21D2EC2DF4500CC5224 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 7587F21B2EC2DF3300CC5224 /* UIKit.framework */; platformFilters = (ios, maccatalyst, tvos, watchos, ); };\n\t\t7587F21E2EC2DF5200CC5224 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 7587F21B2EC2DF3300CC5224 /* UIKit.framework */; platformFilters = (ios, maccatalyst, tvos, watchos, ); };\n\t\t7587F21F2EC2DF7400CC5224 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 7587F21B2EC2DF3300CC5224 /* UIKit.framework */; platformFilters = (ios, maccatalyst, tvos, watchos, ); };\n\t\t75882C7D28C7C2EF00F95947 /* CPPColumnConstraintPrimary.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 75882C7B28C7C2EF00F95947 /* CPPColumnConstraintPrimary.cpp */; };\n\t\t75882C8128C7C3E600F95947 /* CPPColumnConstraintPrimaryAsc.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 75882C7F28C7C3E600F95947 /* CPPColumnConstraintPrimaryAsc.cpp */; };\n\t\t75882C8428C7C4A300F95947 /* CPPColumnConstraintPrimaryDesc.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 75882C8228C7C4A300F95947 /* CPPColumnConstraintPrimaryDesc.cpp */; };\n\t\t75882C8728C7C55200F95947 /* CPPColumnConstraintAutoIncrement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 75882C8528C7C55200F95947 /* CPPColumnConstraintAutoIncrement.cpp */; };\n\t\t75882C8A28C7C60C00F95947 /* CPPColumnConstraintAutoIncrementAsc.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 75882C8828C7C60C00F95947 /* CPPColumnConstraintAutoIncrementAsc.cpp */; };\n\t\t75882C8D28C7C6CF00F95947 /* CPPColumnConstraintUnique.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 75882C8B28C7C6CF00F95947 /* CPPColumnConstraintUnique.cpp */; };\n\t\t75882C9028C7C78200F95947 /* CPPColumnConstraintDefault.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 75882C8E28C7C78200F95947 /* CPPColumnConstraintDefault.cpp */; };\n\t\t758D9D0128BA6AF8001B3D2D /* HandleOperationTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 758D9D0028BA6AF8001B3D2D /* HandleOperationTests.mm */; };\n\t\t758D9D0328BA7265001B3D2D /* CPPTableConstraintMacro.h in Headers */ = {isa = PBXBuildFile; fileRef = 758D9D0228BA7265001B3D2D /* CPPTableConstraintMacro.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t758D9D0428BA7265001B3D2D /* CPPTableConstraintMacro.h in Headers */ = {isa = PBXBuildFile; fileRef = 758D9D0228BA7265001B3D2D /* CPPTableConstraintMacro.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t758D9D0628BA7F06001B3D2D /* CPPColumnConstraintMacro.h in Headers */ = {isa = PBXBuildFile; fileRef = 758D9D0528BA7F06001B3D2D /* CPPColumnConstraintMacro.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t758D9D0728BA7F06001B3D2D /* CPPColumnConstraintMacro.h in Headers */ = {isa = PBXBuildFile; fileRef = 758D9D0528BA7F06001B3D2D /* CPPColumnConstraintMacro.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t758D9D0928BA819A001B3D2D /* CPPVirtualTableMacro.h in Headers */ = {isa = PBXBuildFile; fileRef = 758D9D0828BA819A001B3D2D /* CPPVirtualTableMacro.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t758D9D0A28BA819A001B3D2D /* CPPVirtualTableMacro.h in Headers */ = {isa = PBXBuildFile; fileRef = 758D9D0828BA819A001B3D2D /* CPPVirtualTableMacro.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t758DC8022B255EBF00E71D9B /* CompressionBenchmark.mm in Sources */ = {isa = PBXBuildFile; fileRef = 758DC8012B255EBF00E71D9B /* CompressionBenchmark.mm */; };\n\t\t758DC8052B25671E00E71D9B /* NormalCompressionBenchmark.mm in Sources */ = {isa = PBXBuildFile; fileRef = 758DC8042B25671E00E71D9B /* NormalCompressionBenchmark.mm */; };\n\t\t758DC8072B25678800E71D9B /* DictCompressionBenchmark.mm in Sources */ = {isa = PBXBuildFile; fileRef = 758DC8062B25678800E71D9B /* DictCompressionBenchmark.mm */; };\n\t\t758E7EB82B1B24AD00319991 /* AutoCompressConfig.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 758E7EB62B1B24AD00319991 /* AutoCompressConfig.cpp */; };\n\t\t758E7EB92B1B24AD00319991 /* AutoCompressConfig.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 758E7EB62B1B24AD00319991 /* AutoCompressConfig.cpp */; };\n\t\t758E7EBA2B1B24AD00319991 /* AutoCompressConfig.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 758E7EB62B1B24AD00319991 /* AutoCompressConfig.cpp */; };\n\t\t758E7EBB2B1B24AD00319991 /* AutoCompressConfig.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 758E7EB62B1B24AD00319991 /* AutoCompressConfig.cpp */; };\n\t\t758E7EBC2B1B24AD00319991 /* AutoCompressConfig.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 758E7EB72B1B24AD00319991 /* AutoCompressConfig.hpp */; };\n\t\t758E7EBD2B1B24AD00319991 /* AutoCompressConfig.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 758E7EB72B1B24AD00319991 /* AutoCompressConfig.hpp */; };\n\t\t758E7EBE2B1B24AD00319991 /* AutoCompressConfig.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 758E7EB72B1B24AD00319991 /* AutoCompressConfig.hpp */; };\n\t\t758E7EBF2B1B24AD00319991 /* AutoCompressConfig.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 758E7EB72B1B24AD00319991 /* AutoCompressConfig.hpp */; };\n\t\t758E7EC22B1B41AA00319991 /* WCTCompressionInfo.mm in Sources */ = {isa = PBXBuildFile; fileRef = 758E7EC12B1B41AA00319991 /* WCTCompressionInfo.mm */; };\n\t\t758E7EC32B1B41AA00319991 /* WCTCompressionInfo.mm in Sources */ = {isa = PBXBuildFile; fileRef = 758E7EC12B1B41AA00319991 /* WCTCompressionInfo.mm */; };\n\t\t758E7EC72B1B41C500319991 /* WCTCompressionInfo.h in Headers */ = {isa = PBXBuildFile; fileRef = 758E7EC62B1B41C500319991 /* WCTCompressionInfo.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t758E7EC82B1B41C500319991 /* WCTCompressionInfo.h in Headers */ = {isa = PBXBuildFile; fileRef = 758E7EC62B1B41C500319991 /* WCTCompressionInfo.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t758E7ECA2B1B423200319991 /* WCTCompressionInfo+Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 758E7EC92B1B423200319991 /* WCTCompressionInfo+Private.h */; };\n\t\t758E7ECB2B1B423200319991 /* WCTCompressionInfo+Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 758E7EC92B1B423200319991 /* WCTCompressionInfo+Private.h */; };\n\t\t758E7ECD2B1B49E300319991 /* WCTDatabase+Compression.h in Headers */ = {isa = PBXBuildFile; fileRef = 758E7ECC2B1B49E300319991 /* WCTDatabase+Compression.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t758E7ECE2B1B49E300319991 /* WCTDatabase+Compression.h in Headers */ = {isa = PBXBuildFile; fileRef = 758E7ECC2B1B49E300319991 /* WCTDatabase+Compression.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t758E7ED02B1B49EF00319991 /* WCTDatabase+Compression.mm in Sources */ = {isa = PBXBuildFile; fileRef = 758E7ECF2B1B49EF00319991 /* WCTDatabase+Compression.mm */; };\n\t\t758E7ED12B1B49EF00319991 /* WCTDatabase+Compression.mm in Sources */ = {isa = PBXBuildFile; fileRef = 758E7ECF2B1B49EF00319991 /* WCTDatabase+Compression.mm */; };\n\t\t758E7F312B1C82F400319991 /* CompressionTestObject.mm in Sources */ = {isa = PBXBuildFile; fileRef = 758E7F2F2B1C82EC00319991 /* CompressionTestObject.mm */; };\n\t\t758E7F392B1C864700319991 /* Random+CompressionTestObject.mm in Sources */ = {isa = PBXBuildFile; fileRef = 758E7F382B1C864700319991 /* Random+CompressionTestObject.mm */; };\n\t\t758E7F3E2B1C99C700319991 /* CompressionTestCase.mm in Sources */ = {isa = PBXBuildFile; fileRef = 758E7F3D2B1C99C700319991 /* CompressionTestCase.mm */; };\n\t\t759362CC2B368D87000AF163 /* VacuumBenchmark.mm in Sources */ = {isa = PBXBuildFile; fileRef = 759362CB2B368D87000AF163 /* VacuumBenchmark.mm */; };\n\t\t759362CF2B36D450000AF163 /* Vacuum.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 759362CD2B36D450000AF163 /* Vacuum.cpp */; };\n\t\t759362D02B36D450000AF163 /* Vacuum.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 759362CD2B36D450000AF163 /* Vacuum.cpp */; };\n\t\t759362D12B36D450000AF163 /* Vacuum.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 759362CD2B36D450000AF163 /* Vacuum.cpp */; };\n\t\t759362D22B36D450000AF163 /* Vacuum.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 759362CD2B36D450000AF163 /* Vacuum.cpp */; };\n\t\t759362D32B36D450000AF163 /* Vacuum.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 759362CE2B36D450000AF163 /* Vacuum.hpp */; };\n\t\t759362D42B36D450000AF163 /* Vacuum.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 759362CE2B36D450000AF163 /* Vacuum.hpp */; };\n\t\t759362D52B36D450000AF163 /* Vacuum.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 759362CE2B36D450000AF163 /* Vacuum.hpp */; };\n\t\t759362D62B36D450000AF163 /* Vacuum.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 759362CE2B36D450000AF163 /* Vacuum.hpp */; };\n\t\t759362DA2B36D756000AF163 /* VacuumHandleOperator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 759362D82B36D756000AF163 /* VacuumHandleOperator.cpp */; };\n\t\t759362DB2B36D756000AF163 /* VacuumHandleOperator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 759362D82B36D756000AF163 /* VacuumHandleOperator.cpp */; };\n\t\t759362DC2B36D756000AF163 /* VacuumHandleOperator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 759362D82B36D756000AF163 /* VacuumHandleOperator.cpp */; };\n\t\t759362DD2B36D756000AF163 /* VacuumHandleOperator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 759362D82B36D756000AF163 /* VacuumHandleOperator.cpp */; };\n\t\t759362DE2B36D756000AF163 /* VacuumHandleOperator.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 759362D92B36D756000AF163 /* VacuumHandleOperator.hpp */; };\n\t\t759362DF2B36D756000AF163 /* VacuumHandleOperator.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 759362D92B36D756000AF163 /* VacuumHandleOperator.hpp */; };\n\t\t759362E02B36D756000AF163 /* VacuumHandleOperator.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 759362D92B36D756000AF163 /* VacuumHandleOperator.hpp */; };\n\t\t759362E12B36D756000AF163 /* VacuumHandleOperator.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 759362D92B36D756000AF163 /* VacuumHandleOperator.hpp */; };\n\t\t7596162328BFB05100AE86BA /* CPPDeclaration.h in Headers */ = {isa = PBXBuildFile; fileRef = 7596162228BFB05100AE86BA /* CPPDeclaration.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t7596162428BFB05100AE86BA /* CPPDeclaration.h in Headers */ = {isa = PBXBuildFile; fileRef = 7596162228BFB05100AE86BA /* CPPDeclaration.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t75A46C00284310CE00B58207 /* ColumnConstraintBridge.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 75A46BFE284310CE00B58207 /* ColumnConstraintBridge.cpp */; };\n\t\t75A46C01284310CE00B58207 /* ColumnConstraintBridge.h in Headers */ = {isa = PBXBuildFile; fileRef = 75A46BFF284310CE00B58207 /* ColumnConstraintBridge.h */; settings = {ATTRIBUTES = (Private, ); }; };\n\t\t75A46C0428431D6300B58207 /* ForeignKeyBridge.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 75A46C0228431D6300B58207 /* ForeignKeyBridge.cpp */; };\n\t\t75A46C0528431D6300B58207 /* ForeignKeyBridge.h in Headers */ = {isa = PBXBuildFile; fileRef = 75A46C0328431D6300B58207 /* ForeignKeyBridge.h */; settings = {ATTRIBUTES = (Private, ); }; };\n\t\t75A46C072843273A00B58207 /* ColumnConstraint.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75A46C062843273A00B58207 /* ColumnConstraint.swift */; };\n\t\t75A46C0928432A5D00B58207 /* SyntaxConst.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75A46C0828432A5D00B58207 /* SyntaxConst.swift */; };\n\t\t75A46C0B2843709500B58207 /* ColumnConstraintTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75A46C0A2843709500B58207 /* ColumnConstraintTests.swift */; };\n\t\t75A46C0E2843B3BC00B58207 /* OrderingTermBridge.h in Headers */ = {isa = PBXBuildFile; fileRef = 75A46C0C2843B3BC00B58207 /* OrderingTermBridge.h */; settings = {ATTRIBUTES = (Private, ); }; };\n\t\t75A46C0F2843B3BC00B58207 /* OrderingTermBridge.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 75A46C0D2843B3BC00B58207 /* OrderingTermBridge.cpp */; };\n\t\t75A46C112843B73C00B58207 /* WinqBridge.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 75A46C102843B73C00B58207 /* WinqBridge.hpp */; };\n\t\t75A60AAF29345A38009C1B3C /* Cipher.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 75A60AAD29345A38009C1B3C /* Cipher.cpp */; };\n\t\t75A60AB029345A38009C1B3C /* Cipher.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 75A60AAD29345A38009C1B3C /* Cipher.cpp */; };\n\t\t75A60AB129345A38009C1B3C /* Cipher.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 75A60AAD29345A38009C1B3C /* Cipher.cpp */; };\n\t\t75A60AB229345A38009C1B3C /* Cipher.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 75A60AAD29345A38009C1B3C /* Cipher.cpp */; };\n\t\t75A60AB329345A38009C1B3C /* Cipher.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 75A60AAE29345A38009C1B3C /* Cipher.hpp */; };\n\t\t75A60AB429345A38009C1B3C /* Cipher.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 75A60AAE29345A38009C1B3C /* Cipher.hpp */; };\n\t\t75A60AB529345A38009C1B3C /* Cipher.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 75A60AAE29345A38009C1B3C /* Cipher.hpp */; };\n\t\t75A60AB629345A38009C1B3C /* Cipher.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 75A60AAE29345A38009C1B3C /* Cipher.hpp */; };\n\t\t75ADC5642A8D1C2D00D0AC47 /* TableAttribute.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 75ADC5622A8D1C2D00D0AC47 /* TableAttribute.cpp */; };\n\t\t75ADC5652A8D1C2D00D0AC47 /* TableAttribute.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 75ADC5622A8D1C2D00D0AC47 /* TableAttribute.cpp */; };\n\t\t75ADC5662A8D1C2D00D0AC47 /* TableAttribute.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 75ADC5622A8D1C2D00D0AC47 /* TableAttribute.cpp */; };\n\t\t75ADC5672A8D1C2D00D0AC47 /* TableAttribute.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 75ADC5622A8D1C2D00D0AC47 /* TableAttribute.cpp */; };\n\t\t75ADC5682A8D1C2D00D0AC47 /* TableAttribute.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 75ADC5632A8D1C2D00D0AC47 /* TableAttribute.hpp */; };\n\t\t75ADC5692A8D1C2D00D0AC47 /* TableAttribute.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 75ADC5632A8D1C2D00D0AC47 /* TableAttribute.hpp */; };\n\t\t75ADC56A2A8D1C2D00D0AC47 /* TableAttribute.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 75ADC5632A8D1C2D00D0AC47 /* TableAttribute.hpp */; };\n\t\t75ADC56B2A8D1C2D00D0AC47 /* TableAttribute.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 75ADC5632A8D1C2D00D0AC47 /* TableAttribute.hpp */; };\n\t\t75AF6AD728544C8800A7C43D /* TableOrSubqueryBridge.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 75AF6AD528544C8800A7C43D /* TableOrSubqueryBridge.cpp */; };\n\t\t75AF6AD828544C8800A7C43D /* TableOrSubqueryBridge.h in Headers */ = {isa = PBXBuildFile; fileRef = 75AF6AD628544C8800A7C43D /* TableOrSubqueryBridge.h */; settings = {ATTRIBUTES = (Private, ); }; };\n\t\t75AF6ADB2854C5ED00A7C43D /* JoinBridge.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 75AF6AD92854C5ED00A7C43D /* JoinBridge.cpp */; };\n\t\t75AF6ADC2854C5ED00A7C43D /* JoinBridge.h in Headers */ = {isa = PBXBuildFile; fileRef = 75AF6ADA2854C5ED00A7C43D /* JoinBridge.h */; settings = {ATTRIBUTES = (Private, ); }; };\n\t\t75AF6ADF2854EF6D00A7C43D /* QualifiedTableBridge.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 75AF6ADD2854EF6D00A7C43D /* QualifiedTableBridge.cpp */; };\n\t\t75AF6AE02854EF6D00A7C43D /* QualifiedTableBridge.h in Headers */ = {isa = PBXBuildFile; fileRef = 75AF6ADE2854EF6D00A7C43D /* QualifiedTableBridge.h */; settings = {ATTRIBUTES = (Private, ); }; };\n\t\t75AF6AE22854F19800A7C43D /* QualifiedTable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75AF6AE12854F19800A7C43D /* QualifiedTable.swift */; };\n\t\t75AF6AE52854F32200A7C43D /* QualifiedTableTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75AF6AE32854F2FC00A7C43D /* QualifiedTableTests.swift */; };\n\t\t75AF6AE9285594A100A7C43D /* ResultColumnBridge.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 75AF6AE7285594A100A7C43D /* ResultColumnBridge.cpp */; };\n\t\t75AF6AEA285594A100A7C43D /* ResultColumnBridge.h in Headers */ = {isa = PBXBuildFile; fileRef = 75AF6AE8285594A100A7C43D /* ResultColumnBridge.h */; settings = {ATTRIBUTES = (Private, ); }; };\n\t\t75AF6AED28559F4800A7C43D /* TableConstraintBridge.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 75AF6AEB28559F4800A7C43D /* TableConstraintBridge.cpp */; };\n\t\t75AF6AEE28559F4800A7C43D /* TableConstraintBridge.h in Headers */ = {isa = PBXBuildFile; fileRef = 75AF6AEC28559F4800A7C43D /* TableConstraintBridge.h */; settings = {ATTRIBUTES = (Private, ); }; };\n\t\t75AF6AF12855C8BF00A7C43D /* UpsertBridge.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 75AF6AEF2855C8BF00A7C43D /* UpsertBridge.cpp */; };\n\t\t75AF6AF22855C8BF00A7C43D /* UpsertBridge.h in Headers */ = {isa = PBXBuildFile; fileRef = 75AF6AF02855C8BF00A7C43D /* UpsertBridge.h */; settings = {ATTRIBUTES = (Private, ); }; };\n\t\t75AF6AF42855CCDD00A7C43D /* Upsert.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75AF6AF32855CCDD00A7C43D /* Upsert.swift */; };\n\t\t75AF6AF62855D21000A7C43D /* UpsertTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75AF6AF52855D21000A7C43D /* UpsertTests.swift */; };\n\t\t75AF6AFA2856303700A7C43D /* PragmaBridge.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 75AF6AF82856303700A7C43D /* PragmaBridge.cpp */; };\n\t\t75AF6AFB2856303700A7C43D /* PragmaBridge.h in Headers */ = {isa = PBXBuildFile; fileRef = 75AF6AF92856303700A7C43D /* PragmaBridge.h */; settings = {ATTRIBUTES = (Private, ); }; };\n\t\t75B698D5290AD4C0006E1F8F /* BaseTokenizerUtil.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 75B698D3290AD4C0006E1F8F /* BaseTokenizerUtil.cpp */; };\n\t\t75B698D6290AD4C0006E1F8F /* BaseTokenizerUtil.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 75B698D3290AD4C0006E1F8F /* BaseTokenizerUtil.cpp */; };\n\t\t75B698D7290AD4C0006E1F8F /* BaseTokenizerUtil.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 75B698D4290AD4C0006E1F8F /* BaseTokenizerUtil.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t75B698D8290AD4C0006E1F8F /* BaseTokenizerUtil.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 75B698D4290AD4C0006E1F8F /* BaseTokenizerUtil.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t75C075342A8921C600B4A0D4 /* CPPHandleTest.mm in Sources */ = {isa = PBXBuildFile; fileRef = 75C075332A8921C600B4A0D4 /* CPPHandleTest.mm */; };\n\t\t75C075372A89234300B4A0D4 /* HandleTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75C075352A8922CA00B4A0D4 /* HandleTest.swift */; };\n\t\t75C1034228450D840006BBCB /* WindowDefBridge.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 75C1034028450D840006BBCB /* WindowDefBridge.cpp */; };\n\t\t75C1034328450D840006BBCB /* WindowDefBridge.h in Headers */ = {isa = PBXBuildFile; fileRef = 75C1034128450D840006BBCB /* WindowDefBridge.h */; settings = {ATTRIBUTES = (Private, ); }; };\n\t\t75C10345284530BF0006BBCB /* RaiseFunction.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75C10344284530BF0006BBCB /* RaiseFunction.swift */; };\n\t\t75C17A9328D0D3DD009C342E /* TransactionInterface.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75C17A9228D0D3DD009C342E /* TransactionInterface.swift */; };\n\t\t75C44094291CE12300D74EB7 /* ColumnConstraintConfig.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75C44093291CE12300D74EB7 /* ColumnConstraintConfig.swift */; };\n\t\t75C44096291CE1FB00D74EB7 /* TableConfiguration.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75C44095291CE1FB00D74EB7 /* TableConfiguration.swift */; };\n\t\t75C44098291CE24900D74EB7 /* IndexConfig.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75C44097291CE24900D74EB7 /* IndexConfig.swift */; };\n\t\t75C4409A291CE7E200D74EB7 /* MultiPrimaryConfig.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75C44099291CE7E200D74EB7 /* MultiPrimaryConfig.swift */; };\n\t\t75C4409C291D0B4F00D74EB7 /* MultiUniqueConfig.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75C4409B291D0B4F00D74EB7 /* MultiUniqueConfig.swift */; };\n\t\t75C4409E291D0C9C00D74EB7 /* CheckExpressionConfig.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75C4409D291D0C9C00D74EB7 /* CheckExpressionConfig.swift */; };\n\t\t75C440A0291D108D00D74EB7 /* ForeignKeyConfig.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75C4409F291D108D00D74EB7 /* ForeignKeyConfig.swift */; };\n\t\t75C440A2291D116C00D74EB7 /* VirtualTableConfig.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75C440A1291D116C00D74EB7 /* VirtualTableConfig.swift */; };\n\t\t75C6E413299E80D3002579A5 /* WCDBOptional.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 75C6E412299E80D3002579A5 /* WCDBOptional.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t75C6E414299E80D3002579A5 /* WCDBOptional.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 75C6E412299E80D3002579A5 /* WCDBOptional.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t75C6E415299E80D3002579A5 /* WCDBOptional.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 75C6E412299E80D3002579A5 /* WCDBOptional.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t75C6E41729A0C2F0002579A5 /* WCDBOptional.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 75C6E41629A0C2F0002579A5 /* WCDBOptional.cpp */; };\n\t\t75C6E41829A0C2F0002579A5 /* WCDBOptional.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 75C6E41629A0C2F0002579A5 /* WCDBOptional.cpp */; };\n\t\t75C6E41929A0C2F0002579A5 /* WCDBOptional.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 75C6E41629A0C2F0002579A5 /* WCDBOptional.cpp */; };\n\t\t75C6E41A29A0C2F0002579A5 /* WCDBOptional.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 75C6E41629A0C2F0002579A5 /* WCDBOptional.cpp */; };\n\t\t75C6E41B29A124B4002579A5 /* WCDBOptional.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 75C6E412299E80D3002579A5 /* WCDBOptional.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t75CB08CB2A88B9A300429364 /* HandleCounter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 75CB08C92A88B9A300429364 /* HandleCounter.cpp */; };\n\t\t75CB08CC2A88B9A300429364 /* HandleCounter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 75CB08C92A88B9A300429364 /* HandleCounter.cpp */; };\n\t\t75CB08CD2A88B9A300429364 /* HandleCounter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 75CB08C92A88B9A300429364 /* HandleCounter.cpp */; };\n\t\t75CB08CE2A88B9A300429364 /* HandleCounter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 75CB08C92A88B9A300429364 /* HandleCounter.cpp */; };\n\t\t75CB08CF2A88B9A300429364 /* HandleCounter.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 75CB08CA2A88B9A300429364 /* HandleCounter.hpp */; };\n\t\t75CB08D02A88B9A300429364 /* HandleCounter.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 75CB08CA2A88B9A300429364 /* HandleCounter.hpp */; };\n\t\t75CB08D12A88B9A300429364 /* HandleCounter.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 75CB08CA2A88B9A300429364 /* HandleCounter.hpp */; };\n\t\t75CB08D22A88B9A300429364 /* HandleCounter.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 75CB08CA2A88B9A300429364 /* HandleCounter.hpp */; };\n\t\t75CD026128CECD610071B6C3 /* StatementInterface.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75CD026028CECD610071B6C3 /* StatementInterface.swift */; };\n\t\t75CD026928CF8DC00071B6C3 /* InsertInterface.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75CD026828CF8DC00071B6C3 /* InsertInterface.swift */; };\n\t\t75CD026B28CF8EF90071B6C3 /* UpdateInterface.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75CD026A28CF8EF90071B6C3 /* UpdateInterface.swift */; };\n\t\t75CD026D28CF8F360071B6C3 /* DeleteInterface.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75CD026C28CF8F360071B6C3 /* DeleteInterface.swift */; };\n\t\t75CD026F28CF8F5F0071B6C3 /* SelectInterface.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75CD026E28CF8F5F0071B6C3 /* SelectInterface.swift */; };\n\t\t75CD027128CF900C0071B6C3 /* TableInterface.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75CD027028CF900C0071B6C3 /* TableInterface.swift */; };\n\t\t75CD724F290D2449008583A3 /* CPPFTS3Object.mm in Sources */ = {isa = PBXBuildFile; fileRef = 75CD724D290D2449008583A3 /* CPPFTS3Object.mm */; };\n\t\t75CE3EFE2812D95100E132F6 /* WCTAPIBridge.h in Headers */ = {isa = PBXBuildFile; fileRef = 75CE3EFD2812D95100E132F6 /* WCTAPIBridge.h */; settings = {ATTRIBUTES = (Private, ); }; };\n\t\t75CE3F002812E1A400E132F6 /* WCTAPIBridge.mm in Sources */ = {isa = PBXBuildFile; fileRef = 75CE3EFF2812E1A400E132F6 /* WCTAPIBridge.mm */; };\n\t\t75CFB5DC293F30A200F97FA5 /* AutoAddColumnTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75CFB5DB293F30A200F97FA5 /* AutoAddColumnTests.swift */; };\n\t\t75D2A9BE2AB49C890024B8B2 /* Random+RepairTestObject.mm in Sources */ = {isa = PBXBuildFile; fileRef = 75D2A9BC2AB49B2D0024B8B2 /* Random+RepairTestObject.mm */; };\n\t\t75D4834228A79AD3004FDD3C /* CPPTraceTest.mm in Sources */ = {isa = PBXBuildFile; fileRef = 75D4834128A79AD3004FDD3C /* CPPTraceTest.mm */; };\n\t\t75D4834528A7A827004FDD3C /* CPPTableTestCase.mm in Sources */ = {isa = PBXBuildFile; fileRef = 75D4834428A7A827004FDD3C /* CPPTableTestCase.mm */; };\n\t\t75D4834928A7C42F004FDD3C /* Random+CPPTestObject.mm in Sources */ = {isa = PBXBuildFile; fileRef = 75D4834828A7C42F004FDD3C /* Random+CPPTestObject.mm */; };\n\t\t75D566FB2951B7DE00098DD9 /* WCTSequence.h in Headers */ = {isa = PBXBuildFile; fileRef = 75D566FA2951B7DE00098DD9 /* WCTSequence.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t75D566FC2951B7DE00098DD9 /* WCTSequence.h in Headers */ = {isa = PBXBuildFile; fileRef = 75D566FA2951B7DE00098DD9 /* WCTSequence.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t75D566FE2951B7EA00098DD9 /* WCTSequence.mm in Sources */ = {isa = PBXBuildFile; fileRef = 75D566FD2951B7EA00098DD9 /* WCTSequence.mm */; };\n\t\t75D566FF2951B7EA00098DD9 /* WCTSequence.mm in Sources */ = {isa = PBXBuildFile; fileRef = 75D566FD2951B7EA00098DD9 /* WCTSequence.mm */; };\n\t\t75D567012951B90E00098DD9 /* WCTSequence+WCTTableCoding.h in Headers */ = {isa = PBXBuildFile; fileRef = 75D567002951B80B00098DD9 /* WCTSequence+WCTTableCoding.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t75D567022951B90F00098DD9 /* WCTSequence+WCTTableCoding.h in Headers */ = {isa = PBXBuildFile; fileRef = 75D567002951B80B00098DD9 /* WCTSequence+WCTTableCoding.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t75D99B8028CA441E00BEC8B5 /* BaseOperation.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 75D99B7F28CA441E00BEC8B5 /* BaseOperation.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t75D99B8128CA441E00BEC8B5 /* BaseOperation.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 75D99B7F28CA441E00BEC8B5 /* BaseOperation.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t75D99B8328CA46A400BEC8B5 /* BaseOperation.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 75D99B8228CA46A400BEC8B5 /* BaseOperation.cpp */; };\n\t\t75D99B8428CA46A400BEC8B5 /* BaseOperation.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 75D99B8228CA46A400BEC8B5 /* BaseOperation.cpp */; };\n\t\t75DF22962AEE8409006A3311 /* CPPInheritObject.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 75DF22942AEE8409006A3311 /* CPPInheritObject.hpp */; };\n\t\t75DF22972AEE8483006A3311 /* CPPInheritObject.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 75DF22932AEE8409006A3311 /* CPPInheritObject.cpp */; };\n\t\t75DF229A2AEFF995006A3311 /* SharedPtrAccessor.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 75DF22992AEFF995006A3311 /* SharedPtrAccessor.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t75DF229B2AEFF995006A3311 /* SharedPtrAccessor.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 75DF22992AEFF995006A3311 /* SharedPtrAccessor.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t75E0A5C02A7F4EEE00D4FE9A /* CoreConst.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 75E0A5BF2A7F4EEE00D4FE9A /* CoreConst.cpp */; };\n\t\t75E0A5C12A7F4EEE00D4FE9A /* CoreConst.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 75E0A5BF2A7F4EEE00D4FE9A /* CoreConst.cpp */; };\n\t\t75E0A5C22A7F4EEE00D4FE9A /* CoreConst.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 75E0A5BF2A7F4EEE00D4FE9A /* CoreConst.cpp */; };\n\t\t75E0A5C32A7F4EEE00D4FE9A /* CoreConst.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 75E0A5BF2A7F4EEE00D4FE9A /* CoreConst.cpp */; };\n\t\t75E0A5D62A7FE2A200D4FE9A /* ContainerBridge.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 75E0A5D42A7FE2A200D4FE9A /* ContainerBridge.cpp */; };\n\t\t75E0A5D72A7FE2A200D4FE9A /* ContainerBridge.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 75E0A5D42A7FE2A200D4FE9A /* ContainerBridge.cpp */; };\n\t\t75E0A5D82A7FE2A200D4FE9A /* ContainerBridge.h in Headers */ = {isa = PBXBuildFile; fileRef = 75E0A5D52A7FE2A200D4FE9A /* ContainerBridge.h */; settings = {ATTRIBUTES = (Private, ); }; };\n\t\t75E0A5D92A7FE2A200D4FE9A /* ContainerBridge.h in Headers */ = {isa = PBXBuildFile; fileRef = 75E0A5D52A7FE2A200D4FE9A /* ContainerBridge.h */; settings = {ATTRIBUTES = (Private, ); }; };\n\t\t75E29CAF2B2F2F20003340FF /* VacuumTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 75E29CAE2B2F2F20003340FF /* VacuumTests.mm */; };\n\t\t75E50A0B29067BC800B73E62 /* MultiObject.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 75E50A0929067BC800B73E62 /* MultiObject.cpp */; };\n\t\t75E50A0C29067BC800B73E62 /* MultiObject.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 75E50A0929067BC800B73E62 /* MultiObject.cpp */; };\n\t\t75E50A0D29067BC800B73E62 /* MultiObject.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 75E50A0A29067BC800B73E62 /* MultiObject.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t75E50A0E29067BC800B73E62 /* MultiObject.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 75E50A0A29067BC800B73E62 /* MultiObject.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t75E50A2D2907921600B73E62 /* MultiSelect.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 75E50A2B2907921600B73E62 /* MultiSelect.cpp */; };\n\t\t75E50A2E2907921600B73E62 /* MultiSelect.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 75E50A2B2907921600B73E62 /* MultiSelect.cpp */; };\n\t\t75E50A2F2907921600B73E62 /* MultiSelect.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 75E50A2C2907921600B73E62 /* MultiSelect.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t75E50A302907921600B73E62 /* MultiSelect.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 75E50A2C2907921600B73E62 /* MultiSelect.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t75E50AC22908EC7100B73E62 /* ORMMultiSelectTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 75E50AC12908EC7100B73E62 /* ORMMultiSelectTests.mm */; };\n\t\t75E76AD429161EE400073CCA /* FTSBridge.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75E76AD329161EE400073CCA /* FTSBridge.swift */; };\n\t\t75E76AE029176FA600073CCA /* TokenizerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75E76ADF29176FA600073CCA /* TokenizerTests.swift */; };\n\t\t75E76AE42917AE2A00073CCA /* CPPVirtualTableFTS4Object.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 75E76AE22917AE2A00073CCA /* CPPVirtualTableFTS4Object.cpp */; };\n\t\t75E76AE72917B07E00073CCA /* CPPVirtualTableFTS5Object.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 75E76AE52917B07E00073CCA /* CPPVirtualTableFTS5Object.cpp */; };\n\t\t75EB1965287F068200AA62F7 /* StatementDropTriggerBridge.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 75EB1963287F068200AA62F7 /* StatementDropTriggerBridge.cpp */; };\n\t\t75EB1966287F068200AA62F7 /* StatementDropTriggerBridge.h in Headers */ = {isa = PBXBuildFile; fileRef = 75EB1964287F068200AA62F7 /* StatementDropTriggerBridge.h */; settings = {ATTRIBUTES = (Private, ); }; };\n\t\t75EB1968287F078E00AA62F7 /* StatementDropTrigger.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75EB1967287F078E00AA62F7 /* StatementDropTrigger.swift */; };\n\t\t75EB196B287F08A300AA62F7 /* StatementDropTriggerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75EB1969287F086D00AA62F7 /* StatementDropTriggerTests.swift */; };\n\t\t75EB196E287F093B00AA62F7 /* StatementDropViewBridge.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 75EB196C287F093B00AA62F7 /* StatementDropViewBridge.cpp */; };\n\t\t75EB196F287F093B00AA62F7 /* StatementDropViewBridge.h in Headers */ = {isa = PBXBuildFile; fileRef = 75EB196D287F093B00AA62F7 /* StatementDropViewBridge.h */; settings = {ATTRIBUTES = (Private, ); }; };\n\t\t75EB1971287F0A2600AA62F7 /* StatementDropView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75EB1970287F0A2600AA62F7 /* StatementDropView.swift */; };\n\t\t75EB1A07287F0AFA00AA62F7 /* StatementDropViewTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75EB1A05287F0AF700AA62F7 /* StatementDropViewTests.swift */; };\n\t\t75EB1A0A287F0BDA00AA62F7 /* StatementCreateViewBridge.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 75EB1A08287F0BDA00AA62F7 /* StatementCreateViewBridge.cpp */; };\n\t\t75EB1A0B287F0BDA00AA62F7 /* StatementCreateViewBridge.h in Headers */ = {isa = PBXBuildFile; fileRef = 75EB1A09287F0BDA00AA62F7 /* StatementCreateViewBridge.h */; settings = {ATTRIBUTES = (Private, ); }; };\n\t\t75EB1A0D287F0DE200AA62F7 /* StatementCreateView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75EB1A0C287F0DE200AA62F7 /* StatementCreateView.swift */; };\n\t\t75EB1A10287F0EB900AA62F7 /* StatementCreateViewTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75EB1A0E287F0E3700AA62F7 /* StatementCreateViewTests.swift */; };\n\t\t75EB1A13287F10BF00AA62F7 /* StatementCreateTriggerBridge.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 75EB1A11287F10BF00AA62F7 /* StatementCreateTriggerBridge.cpp */; };\n\t\t75EB1A14287F10BF00AA62F7 /* StatementCreateTriggerBridge.h in Headers */ = {isa = PBXBuildFile; fileRef = 75EB1A12287F10BF00AA62F7 /* StatementCreateTriggerBridge.h */; settings = {ATTRIBUTES = (Private, ); }; };\n\t\t75EF25002AA33FEB0009C99F /* IncrementalMaterial.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 75EF24FE2AA33FEB0009C99F /* IncrementalMaterial.cpp */; };\n\t\t75EF25012AA33FEB0009C99F /* IncrementalMaterial.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 75EF24FE2AA33FEB0009C99F /* IncrementalMaterial.cpp */; };\n\t\t75EF25022AA33FEB0009C99F /* IncrementalMaterial.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 75EF24FE2AA33FEB0009C99F /* IncrementalMaterial.cpp */; };\n\t\t75EF25032AA33FEB0009C99F /* IncrementalMaterial.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 75EF24FE2AA33FEB0009C99F /* IncrementalMaterial.cpp */; };\n\t\t75EF25042AA33FEB0009C99F /* IncrementalMaterial.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 75EF24FF2AA33FEB0009C99F /* IncrementalMaterial.hpp */; };\n\t\t75EF25052AA33FEB0009C99F /* IncrementalMaterial.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 75EF24FF2AA33FEB0009C99F /* IncrementalMaterial.hpp */; };\n\t\t75EF25062AA33FEB0009C99F /* IncrementalMaterial.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 75EF24FF2AA33FEB0009C99F /* IncrementalMaterial.hpp */; };\n\t\t75EF25072AA33FEB0009C99F /* IncrementalMaterial.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 75EF24FF2AA33FEB0009C99F /* IncrementalMaterial.hpp */; };\n\t\t75EF250A2AA42DD90009C99F /* EncryptedSerialization.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 75EF25082AA42DD90009C99F /* EncryptedSerialization.cpp */; };\n\t\t75EF250B2AA42DD90009C99F /* EncryptedSerialization.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 75EF25082AA42DD90009C99F /* EncryptedSerialization.cpp */; };\n\t\t75EF250C2AA42DD90009C99F /* EncryptedSerialization.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 75EF25082AA42DD90009C99F /* EncryptedSerialization.cpp */; };\n\t\t75EF250D2AA42DD90009C99F /* EncryptedSerialization.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 75EF25082AA42DD90009C99F /* EncryptedSerialization.cpp */; };\n\t\t75EF250E2AA42DD90009C99F /* EncryptedSerialization.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 75EF25092AA42DD90009C99F /* EncryptedSerialization.hpp */; };\n\t\t75EF250F2AA42DD90009C99F /* EncryptedSerialization.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 75EF25092AA42DD90009C99F /* EncryptedSerialization.hpp */; };\n\t\t75EF25102AA42DD90009C99F /* EncryptedSerialization.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 75EF25092AA42DD90009C99F /* EncryptedSerialization.hpp */; };\n\t\t75EF25112AA42DD90009C99F /* EncryptedSerialization.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 75EF25092AA42DD90009C99F /* EncryptedSerialization.hpp */; };\n\t\t75F1A3062871DE9A008503A2 /* StatementCreateVirtualTableBridge.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 75F1A3042871DE9A008503A2 /* StatementCreateVirtualTableBridge.cpp */; };\n\t\t75F1A3072871DE9A008503A2 /* StatementCreateVirtualTableBridge.h in Headers */ = {isa = PBXBuildFile; fileRef = 75F1A3052871DE9A008503A2 /* StatementCreateVirtualTableBridge.h */; settings = {ATTRIBUTES = (Private, ); }; };\n\t\t75F1A30A2871E764008503A2 /* StatementDeleteBridge.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 75F1A3082871E764008503A2 /* StatementDeleteBridge.cpp */; };\n\t\t75F1A30B2871E764008503A2 /* StatementDeleteBridge.h in Headers */ = {isa = PBXBuildFile; fileRef = 75F1A3092871E764008503A2 /* StatementDeleteBridge.h */; settings = {ATTRIBUTES = (Private, ); }; };\n\t\t75F3140D2AAC067B007FFDFB /* CipherHandle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 75F3140B2AAC067B007FFDFB /* CipherHandle.cpp */; };\n\t\t75F3140E2AAC067B007FFDFB /* CipherHandle.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 75F3140C2AAC067B007FFDFB /* CipherHandle.hpp */; };\n\t\t75F32F0928B9CE8E00A72697 /* CPPORMMacro.h in Headers */ = {isa = PBXBuildFile; fileRef = 75F32F0828B9CE8E00A72697 /* CPPORMMacro.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t75F32F0A28B9CE8E00A72697 /* CPPORMMacro.h in Headers */ = {isa = PBXBuildFile; fileRef = 75F32F0828B9CE8E00A72697 /* CPPORMMacro.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t75F32F0D28B9F90900A72697 /* FTSTokenizerUtil.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 75F32F0B28B9F90900A72697 /* FTSTokenizerUtil.cpp */; };\n\t\t75F32F0E28B9F90900A72697 /* FTSTokenizerUtil.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 75F32F0B28B9F90900A72697 /* FTSTokenizerUtil.cpp */; };\n\t\t75F32F0F28B9F90900A72697 /* FTSTokenizerUtil.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 75F32F0C28B9F90900A72697 /* FTSTokenizerUtil.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t75F32F1028B9F90900A72697 /* FTSTokenizerUtil.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 75F32F0C28B9F90900A72697 /* FTSTokenizerUtil.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t75F32F1328BA039D00A72697 /* CPPFieldMacro.h in Headers */ = {isa = PBXBuildFile; fileRef = 75F32F1228BA039D00A72697 /* CPPFieldMacro.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t75F32F1428BA039D00A72697 /* CPPFieldMacro.h in Headers */ = {isa = PBXBuildFile; fileRef = 75F32F1228BA039D00A72697 /* CPPFieldMacro.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t75F32F1628BA066400A72697 /* CPPBindingMacro.h in Headers */ = {isa = PBXBuildFile; fileRef = 75F32F1528BA066400A72697 /* CPPBindingMacro.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t75F32F1728BA066400A72697 /* CPPBindingMacro.h in Headers */ = {isa = PBXBuildFile; fileRef = 75F32F1528BA066400A72697 /* CPPBindingMacro.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t75F32F1928BA083E00A72697 /* CPPIndexMacro.h in Headers */ = {isa = PBXBuildFile; fileRef = 75F32F1828BA083E00A72697 /* CPPIndexMacro.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t75F32F1A28BA083E00A72697 /* CPPIndexMacro.h in Headers */ = {isa = PBXBuildFile; fileRef = 75F32F1828BA083E00A72697 /* CPPIndexMacro.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t75F32F2828BA31CD00A72697 /* ResultField.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 75F32F2628BA31CD00A72697 /* ResultField.cpp */; };\n\t\t75F32F2928BA31CD00A72697 /* ResultField.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 75F32F2628BA31CD00A72697 /* ResultField.cpp */; };\n\t\t75F32F2A28BA31CD00A72697 /* ResultField.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 75F32F2728BA31CD00A72697 /* ResultField.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t75F32F2B28BA31CD00A72697 /* ResultField.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 75F32F2728BA31CD00A72697 /* ResultField.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t75F4DE332883E43C00760DC3 /* StatementExplainBridge.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 75F4DE312883E43C00760DC3 /* StatementExplainBridge.cpp */; };\n\t\t75F4DE342883E43C00760DC3 /* StatementExplainBridge.h in Headers */ = {isa = PBXBuildFile; fileRef = 75F4DE322883E43C00760DC3 /* StatementExplainBridge.h */; settings = {ATTRIBUTES = (Private, ); }; };\n\t\t75F4DE372883E88100760DC3 /* StatementPragmaBridge.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 75F4DE352883E88100760DC3 /* StatementPragmaBridge.cpp */; };\n\t\t75F4DE382883E88100760DC3 /* StatementPragmaBridge.h in Headers */ = {isa = PBXBuildFile; fileRef = 75F4DE362883E88100760DC3 /* StatementPragmaBridge.h */; settings = {ATTRIBUTES = (Private, ); }; };\n\t\t75F4DE3F2883F0A800760DC3 /* StatementReindexBridge.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 75F4DE3D2883F0A800760DC3 /* StatementReindexBridge.cpp */; };\n\t\t75F4DE402883F0A800760DC3 /* StatementReindexBridge.h in Headers */ = {isa = PBXBuildFile; fileRef = 75F4DE3E2883F0A800760DC3 /* StatementReindexBridge.h */; settings = {ATTRIBUTES = (Private, ); }; };\n\t\t75F4DE432883FD6A00760DC3 /* StatementReleaseBridge.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 75F4DE412883FD6A00760DC3 /* StatementReleaseBridge.cpp */; };\n\t\t75F4DE442883FD6A00760DC3 /* StatementReleaseBridge.h in Headers */ = {isa = PBXBuildFile; fileRef = 75F4DE422883FD6A00760DC3 /* StatementReleaseBridge.h */; settings = {ATTRIBUTES = (Private, ); }; };\n\t\t75F4DE472884032600760DC3 /* StatementRollbackBridge.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 75F4DE452884032600760DC3 /* StatementRollbackBridge.cpp */; };\n\t\t75F4DE482884032600760DC3 /* StatementRollbackBridge.h in Headers */ = {isa = PBXBuildFile; fileRef = 75F4DE462884032600760DC3 /* StatementRollbackBridge.h */; settings = {ATTRIBUTES = (Private, ); }; };\n\t\t75F4DE4B288405DD00760DC3 /* StatementSavepointBridge.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 75F4DE49288405DD00760DC3 /* StatementSavepointBridge.cpp */; };\n\t\t75F4DE4C288405DD00760DC3 /* StatementSavepointBridge.h in Headers */ = {isa = PBXBuildFile; fileRef = 75F4DE4A288405DD00760DC3 /* StatementSavepointBridge.h */; settings = {ATTRIBUTES = (Private, ); }; };\n\t\t75F4DE51288407F800760DC3 /* StatementVacuumBridge.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 75F4DE4F288407F800760DC3 /* StatementVacuumBridge.cpp */; };\n\t\t75F4DE52288407F800760DC3 /* StatementVacuumBridge.h in Headers */ = {isa = PBXBuildFile; fileRef = 75F4DE50288407F800760DC3 /* StatementVacuumBridge.h */; settings = {ATTRIBUTES = (Private, ); }; };\n\t\t75F4DE5528840C4800760DC3 /* StatementBeginBridge.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 75F4DE5328840C4800760DC3 /* StatementBeginBridge.cpp */; };\n\t\t75F4DE5628840C4800760DC3 /* StatementBeginBridge.h in Headers */ = {isa = PBXBuildFile; fileRef = 75F4DE5428840C4800760DC3 /* StatementBeginBridge.h */; settings = {ATTRIBUTES = (Private, ); }; };\n\t\t75F4DE58288411DB00760DC3 /* StatementBegin.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75F4DE57288411DB00760DC3 /* StatementBegin.swift */; };\n\t\t75F4DE5A2884132F00760DC3 /* StatementBeginTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75F4DE592884132F00760DC3 /* StatementBeginTests.swift */; };\n\t\t75F4DE5F2884149100760DC3 /* StatementCommitBridge.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 75F4DE5D2884149100760DC3 /* StatementCommitBridge.cpp */; };\n\t\t75F4DE602884149100760DC3 /* StatementCommitBridge.h in Headers */ = {isa = PBXBuildFile; fileRef = 75F4DE5E2884149100760DC3 /* StatementCommitBridge.h */; settings = {ATTRIBUTES = (Private, ); }; };\n\t\t75F4DE622884161200760DC3 /* StatementCommit.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75F4DE612884161200760DC3 /* StatementCommit.swift */; };\n\t\t75F4DE642884164E00760DC3 /* StatementCommitTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75F4DE632884164E00760DC3 /* StatementCommitTests.swift */; };\n\t\t75FFD33028BE5BB70051DB07 /* Insert.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 75FFD32D28BE5BB70051DB07 /* Insert.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t75FFD33128BE5BB70051DB07 /* Insert.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 75FFD32D28BE5BB70051DB07 /* Insert.hpp */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\tDDADC4742949F7C20057AEDB /* Builtin.h in Headers */ = {isa = PBXBuildFile; fileRef = 0D4FE5EE29482F4D0061C3CA /* Builtin.h */; settings = {ATTRIBUTES = (Public, ); }; };\n/* End PBXBuildFile section */\n\n/* Begin PBXContainerItemProxy section */\n\t\t03330FAC28167ECC0094CFCF /* PBXContainerItemProxy */ = {\n\t\t\tisa = PBXContainerItemProxy;\n\t\t\tcontainerPortal = 23B5F75B1E1111C100E58396 /* Project object */;\n\t\t\tproxyType = 1;\n\t\t\tremoteGlobalIDString = 239326601E836D7300D677CC;\n\t\t\tremoteInfo = WCDB;\n\t\t};\n\t\t0338E0BC2818F6D40094923A /* PBXContainerItemProxy */ = {\n\t\t\tisa = PBXContainerItemProxy;\n\t\t\tcontainerPortal = 23B5F75B1E1111C100E58396 /* Project object */;\n\t\t\tproxyType = 1;\n\t\t\tremoteGlobalIDString = 239E8A6F2160A5B100BCB308;\n\t\t\tremoteInfo = Host;\n\t\t};\n\t\t037C38D22897E33600328EC8 /* PBXContainerItemProxy */ = {\n\t\t\tisa = PBXContainerItemProxy;\n\t\t\tcontainerPortal = 23A747BE20039675003CECFA /* sqlcipher.preprocessed.xcodeproj */;\n\t\t\tproxyType = 1;\n\t\t\tremoteGlobalIDString = 23F5BBCF20887FAB000CCD37;\n\t\t\tremoteInfo = \"sqlcipher static\";\n\t\t};\n\t\t03BF4AB92888F87C00A30500 /* PBXContainerItemProxy */ = {\n\t\t\tisa = PBXContainerItemProxy;\n\t\t\tcontainerPortal = 23B5F75B1E1111C100E58396 /* Project object */;\n\t\t\tproxyType = 1;\n\t\t\tremoteGlobalIDString = 239E8A6F2160A5B100BCB308;\n\t\t\tremoteInfo = Host;\n\t\t};\n\t\t03BF4ABB2888F87C00A30500 /* PBXContainerItemProxy */ = {\n\t\t\tisa = PBXContainerItemProxy;\n\t\t\tcontainerPortal = 23B5F75B1E1111C100E58396 /* Project object */;\n\t\t\tproxyType = 1;\n\t\t\tremoteGlobalIDString = 239326601E836D7300D677CC;\n\t\t\tremoteInfo = WCDB;\n\t\t};\n\t\t03D3A2AD28A6697F0064D4D4 /* PBXContainerItemProxy */ = {\n\t\t\tisa = PBXContainerItemProxy;\n\t\t\tcontainerPortal = 23B5F75B1E1111C100E58396 /* Project object */;\n\t\t\tproxyType = 1;\n\t\t\tremoteGlobalIDString = 239E8A6F2160A5B100BCB308;\n\t\t\tremoteInfo = Host;\n\t\t};\n\t\t03E5CB9B28A38CCA005353D9 /* PBXContainerItemProxy */ = {\n\t\t\tisa = PBXContainerItemProxy;\n\t\t\tcontainerPortal = 23B5F75B1E1111C100E58396 /* Project object */;\n\t\t\tproxyType = 1;\n\t\t\tremoteGlobalIDString = 239E8A6F2160A5B100BCB308;\n\t\t\tremoteInfo = Host;\n\t\t};\n\t\t0DACF74E2B29ABD400CB0710 /* PBXContainerItemProxy */ = {\n\t\t\tisa = PBXContainerItemProxy;\n\t\t\tcontainerPortal = 75EABA082ADA4F2600AAD3C9 /* zstd.xcodeproj */;\n\t\t\tproxyType = 1;\n\t\t\tremoteGlobalIDString = 75EAB79B2ADA376000AAD3C9;\n\t\t\tremoteInfo = zstd;\n\t\t};\n\t\t0DACF7502B29ABDB00CB0710 /* PBXContainerItemProxy */ = {\n\t\t\tisa = PBXContainerItemProxy;\n\t\t\tcontainerPortal = 75EABA082ADA4F2600AAD3C9 /* zstd.xcodeproj */;\n\t\t\tproxyType = 1;\n\t\t\tremoteGlobalIDString = 75EAB79B2ADA376000AAD3C9;\n\t\t\tremoteInfo = zstd;\n\t\t};\n\t\t0DACF7522B29ABE600CB0710 /* PBXContainerItemProxy */ = {\n\t\t\tisa = PBXContainerItemProxy;\n\t\t\tcontainerPortal = 75EABA082ADA4F2600AAD3C9 /* zstd.xcodeproj */;\n\t\t\tproxyType = 1;\n\t\t\tremoteGlobalIDString = 75EAB79B2ADA376000AAD3C9;\n\t\t\tremoteInfo = zstd;\n\t\t};\n\t\t0DACF7542B29ABEC00CB0710 /* PBXContainerItemProxy */ = {\n\t\t\tisa = PBXContainerItemProxy;\n\t\t\tcontainerPortal = 75EABA082ADA4F2600AAD3C9 /* zstd.xcodeproj */;\n\t\t\tproxyType = 1;\n\t\t\tremoteGlobalIDString = 75EAB79B2ADA376000AAD3C9;\n\t\t\tremoteInfo = zstd;\n\t\t};\n\t\t23F5BE0520887FD4000CCD37 /* PBXContainerItemProxy */ = {\n\t\t\tisa = PBXContainerItemProxy;\n\t\t\tcontainerPortal = 23A747BE20039675003CECFA /* sqlcipher.preprocessed.xcodeproj */;\n\t\t\tproxyType = 2;\n\t\t\tremoteGlobalIDString = 23F5BC4020887FAB000CCD37;\n\t\t\tremoteInfo = \"sqlcipher static\";\n\t\t};\n\t\t23F5BE0D20887FFF000CCD37 /* PBXContainerItemProxy */ = {\n\t\t\tisa = PBXContainerItemProxy;\n\t\t\tcontainerPortal = 23A747BE20039675003CECFA /* sqlcipher.preprocessed.xcodeproj */;\n\t\t\tproxyType = 1;\n\t\t\tremoteGlobalIDString = 23F5BBCF20887FAB000CCD37;\n\t\t\tremoteInfo = \"sqlcipher static\";\n\t\t};\n\t\t750080EA2920ED98009C0F38 /* PBXContainerItemProxy */ = {\n\t\t\tisa = PBXContainerItemProxy;\n\t\t\tcontainerPortal = 23B5F75B1E1111C100E58396 /* Project object */;\n\t\t\tproxyType = 1;\n\t\t\tremoteGlobalIDString = 239326601E836D7300D677CC;\n\t\t\tremoteInfo = WCDB;\n\t\t};\n\t\t750080ED2920EDBA009C0F38 /* PBXContainerItemProxy */ = {\n\t\t\tisa = PBXContainerItemProxy;\n\t\t\tcontainerPortal = 23B5F75B1E1111C100E58396 /* Project object */;\n\t\t\tproxyType = 1;\n\t\t\tremoteGlobalIDString = 239326601E836D7300D677CC;\n\t\t\tremoteInfo = WCDB;\n\t\t};\n\t\t7521D6C0291E9ABB009642EF /* PBXContainerItemProxy */ = {\n\t\t\tisa = PBXContainerItemProxy;\n\t\t\tcontainerPortal = 23A747BE20039675003CECFA /* sqlcipher.preprocessed.xcodeproj */;\n\t\t\tproxyType = 1;\n\t\t\tremoteGlobalIDString = 23F5BBCF20887FAB000CCD37;\n\t\t\tremoteInfo = \"sqlcipher static\";\n\t\t};\n\t\t7521DA56291EA349009642EF /* PBXContainerItemProxy */ = {\n\t\t\tisa = PBXContainerItemProxy;\n\t\t\tcontainerPortal = 23A747BE20039675003CECFA /* sqlcipher.preprocessed.xcodeproj */;\n\t\t\tproxyType = 1;\n\t\t\tremoteGlobalIDString = 23F5BBCF20887FAB000CCD37;\n\t\t\tremoteInfo = \"sqlcipher static\";\n\t\t};\n\t\t7546D45429D02BAE001B5611 /* PBXContainerItemProxy */ = {\n\t\t\tisa = PBXContainerItemProxy;\n\t\t\tcontainerPortal = 23B5F75B1E1111C100E58396 /* Project object */;\n\t\t\tproxyType = 1;\n\t\t\tremoteGlobalIDString = 239326601E836D7300D677CC;\n\t\t\tremoteInfo = WCDB;\n\t\t};\n\t\t7575F7AE280679C7006259E2 /* PBXContainerItemProxy */ = {\n\t\t\tisa = PBXContainerItemProxy;\n\t\t\tcontainerPortal = 23B5F75B1E1111C100E58396 /* Project object */;\n\t\t\tproxyType = 1;\n\t\t\tremoteGlobalIDString = 239E8A6F2160A5B100BCB308;\n\t\t\tremoteInfo = Host;\n\t\t};\n\t\t75EABA0C2ADA4F2600AAD3C9 /* PBXContainerItemProxy */ = {\n\t\t\tisa = PBXContainerItemProxy;\n\t\t\tcontainerPortal = 75EABA082ADA4F2600AAD3C9 /* zstd.xcodeproj */;\n\t\t\tproxyType = 2;\n\t\t\tremoteGlobalIDString = 75EAB79C2ADA376000AAD3C9;\n\t\t\tremoteInfo = zstd;\n\t\t};\n/* End PBXContainerItemProxy section */\n\n/* Begin PBXCopyFilesBuildPhase section */\n\t\t0D22E7AF2B298E9B00AA44D2 /* Embed Frameworks */ = {\n\t\t\tisa = PBXCopyFilesBuildPhase;\n\t\t\tbuildActionMask = 2147483647;\n\t\t\tdstPath = \"\";\n\t\t\tdstSubfolderSpec = 10;\n\t\t\tfiles = (\n\t\t\t\t0D22E7AE2B298E9A00AA44D2 /* zstd.framework in Embed Frameworks */,\n\t\t\t);\n\t\t\tname = \"Embed Frameworks\";\n\t\t\trunOnlyForDeploymentPostprocessing = 0;\n\t\t};\n\t\t0D22E7B22B298EA400AA44D2 /* Embed Frameworks */ = {\n\t\t\tisa = PBXCopyFilesBuildPhase;\n\t\t\tbuildActionMask = 2147483647;\n\t\t\tdstPath = \"\";\n\t\t\tdstSubfolderSpec = 10;\n\t\t\tfiles = (\n\t\t\t\t0D22E7B12B298EA400AA44D2 /* zstd.framework in Embed Frameworks */,\n\t\t\t);\n\t\t\tname = \"Embed Frameworks\";\n\t\t\trunOnlyForDeploymentPostprocessing = 0;\n\t\t};\n\t\t0D22E7B52B298EAC00AA44D2 /* Embed Frameworks */ = {\n\t\t\tisa = PBXCopyFilesBuildPhase;\n\t\t\tbuildActionMask = 2147483647;\n\t\t\tdstPath = \"\";\n\t\t\tdstSubfolderSpec = 10;\n\t\t\tfiles = (\n\t\t\t\t0D22E7B42B298EAB00AA44D2 /* zstd.framework in Embed Frameworks */,\n\t\t\t);\n\t\t\tname = \"Embed Frameworks\";\n\t\t\trunOnlyForDeploymentPostprocessing = 0;\n\t\t};\n\t\t0D22E7B82B298EB200AA44D2 /* Embed Frameworks */ = {\n\t\t\tisa = PBXCopyFilesBuildPhase;\n\t\t\tbuildActionMask = 2147483647;\n\t\t\tdstPath = \"\";\n\t\t\tdstSubfolderSpec = 10;\n\t\t\tfiles = (\n\t\t\t\t0D22E7B72B298EB200AA44D2 /* zstd.framework in Embed Frameworks */,\n\t\t\t);\n\t\t\tname = \"Embed Frameworks\";\n\t\t\trunOnlyForDeploymentPostprocessing = 0;\n\t\t};\n\t\t0D28FD302DB09E6300D85025 /* CopyFiles */ = {\n\t\t\tisa = PBXCopyFilesBuildPhase;\n\t\t\tbuildActionMask = 2147483647;\n\t\t\tdstPath = \"\";\n\t\t\tdstSubfolderSpec = 10;\n\t\t\tfiles = (\n\t\t\t\t0D28FD312DB09E6F00D85025 /* WCDB.framework in CopyFiles */,\n\t\t\t);\n\t\t\trunOnlyForDeploymentPostprocessing = 0;\n\t\t};\n/* End PBXCopyFilesBuildPhase section */\n\n/* Begin PBXFileReference section */\n\t\t03239D1828C5EE1A00C8D691 /* CPPORMTestUtil.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CPPORMTestUtil.h; sourceTree = \"<group>\"; };\n\t\t03239D6228C60F5C00C8D691 /* CPPTableConstraintObject.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = CPPTableConstraintObject.cpp; sourceTree = \"<group>\"; };\n\t\t03239D6328C60F5C00C8D691 /* CPPTableConstraintObject.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = CPPTableConstraintObject.hpp; sourceTree = \"<group>\"; };\n\t\t03239D6528C6153F00C8D691 /* CPPORMTests.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = CPPORMTests.mm; sourceTree = \"<group>\"; };\n\t\t032612BB283F279800836E0F /* WinqBridge.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WinqBridge.h; sourceTree = \"<group>\"; };\n\t\t0326130B283F56BD00836E0F /* LiteralValueBridge.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = LiteralValueBridge.cpp; sourceTree = \"<group>\"; };\n\t\t0326130C283F56BD00836E0F /* LiteralValueBridge.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = LiteralValueBridge.h; sourceTree = \"<group>\"; };\n\t\t03261310283F5E0300836E0F /* WinqBridge.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = WinqBridge.cpp; sourceTree = \"<group>\"; };\n\t\t03261363283F6CFB00836E0F /* Identifier.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Identifier.swift; sourceTree = \"<group>\"; };\n\t\t032613B4283F8D7E00836E0F /* ColumnBridge.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = ColumnBridge.cpp; sourceTree = \"<group>\"; };\n\t\t032613B5283F8D7E00836E0F /* ColumnBridge.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ColumnBridge.h; sourceTree = \"<group>\"; };\n\t\t032613B8283F8E4900836E0F /* ExpressionBridge.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = ExpressionBridge.cpp; sourceTree = \"<group>\"; };\n\t\t032613B9283F8E4900836E0F /* ExpressionBridge.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ExpressionBridge.h; sourceTree = \"<group>\"; };\n\t\t032E112228C8511E00BCACE0 /* CPPIndexObject.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = CPPIndexObject.cpp; sourceTree = \"<group>\"; };\n\t\t032E112328C8511E00BCACE0 /* CPPIndexObject.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = CPPIndexObject.hpp; sourceTree = \"<group>\"; };\n\t\t032E112628C8724A00BCACE0 /* CPPOldRemapObject.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = CPPOldRemapObject.cpp; sourceTree = \"<group>\"; };\n\t\t032E112728C8724A00BCACE0 /* CPPOldRemapObject.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = CPPOldRemapObject.hpp; sourceTree = \"<group>\"; };\n\t\t032E112928C874F500BCACE0 /* CPPNewRemapObject.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = CPPNewRemapObject.cpp; sourceTree = \"<group>\"; };\n\t\t032E112A28C874F500BCACE0 /* CPPNewRemapObject.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = CPPNewRemapObject.hpp; sourceTree = \"<group>\"; };\n\t\t032E112C28C8768C00BCACE0 /* CPPNewlyCreatedTableIndexObject.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = CPPNewlyCreatedTableIndexObject.cpp; sourceTree = \"<group>\"; };\n\t\t032E112D28C8768C00BCACE0 /* CPPNewlyCreatedTableIndexObject.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = CPPNewlyCreatedTableIndexObject.hpp; sourceTree = \"<group>\"; };\n\t\t032E112F28C8782600BCACE0 /* CPPDropIndexObject.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = CPPDropIndexObject.cpp; sourceTree = \"<group>\"; };\n\t\t032E113028C8782600BCACE0 /* CPPDropIndexObject.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = CPPDropIndexObject.hpp; sourceTree = \"<group>\"; };\n\t\t032E113328C88B8000BCACE0 /* RunTimeAccessor.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = RunTimeAccessor.hpp; sourceTree = \"<group>\"; };\n\t\t032E121328C8A3B700BCACE0 /* CPPTestCaseObject.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = CPPTestCaseObject.cpp; sourceTree = \"<group>\"; };\n\t\t032E121428C8A3B700BCACE0 /* CPPTestCaseObject.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CPPTestCaseObject.h; sourceTree = \"<group>\"; };\n\t\t03321E8528A503F3000AFD6D /* StatementOperation.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = StatementOperation.cpp; sourceTree = \"<group>\"; };\n\t\t03321E8628A503F3000AFD6D /* StatementOperation.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = StatementOperation.hpp; sourceTree = \"<group>\"; };\n\t\t03321E8B28A514F5000AFD6D /* HandleOperation.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = HandleOperation.cpp; sourceTree = \"<group>\"; };\n\t\t03321E8C28A514F5000AFD6D /* HandleOperation.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = HandleOperation.hpp; sourceTree = \"<group>\"; };\n\t\t0333100228167ECC0094CFCF /* SwiftBridgeObjcTest.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = SwiftBridgeObjcTest.xctest; sourceTree = BUILT_PRODUCTS_DIR; };\n\t\t0333101A281681200094CFCF /* CRUDObject.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CRUDObject.swift; sourceTree = \"<group>\"; };\n\t\t0333101B281681200094CFCF /* CRUDTestCase.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CRUDTestCase.swift; sourceTree = \"<group>\"; };\n\t\t03331021281681200094CFCF /* SelectTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SelectTests.swift; sourceTree = \"<group>\"; };\n\t\t0333103C281681A80094CFCF /* Assert.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Assert.swift; sourceTree = \"<group>\"; };\n\t\t0333103D281681A80094CFCF /* BaseTestCase.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BaseTestCase.swift; sourceTree = \"<group>\"; };\n\t\t0333103E281681A80094CFCF /* Convenience.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Convenience.swift; sourceTree = \"<group>\"; };\n\t\t03331043281683450094CFCF /* CRUDObject.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CRUDObject.h; sourceTree = \"<group>\"; };\n\t\t033310452816836C0094CFCF /* CRUDObject.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = CRUDObject.mm; sourceTree = \"<group>\"; };\n\t\t033310ED2816A2700094CFCF /* SwiftBridgeObjcTest-Bridging-Header.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = \"SwiftBridgeObjcTest-Bridging-Header.h\"; sourceTree = \"<group>\"; };\n\t\t0338E0C7281920AB0094923A /* DeleteTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DeleteTests.swift; sourceTree = \"<group>\"; };\n\t\t0338E0C92819226A0094923A /* SelectInterfaceTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SelectInterfaceTests.swift; sourceTree = \"<group>\"; };\n\t\t0338E0CA2819226B0094923A /* InsertTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = InsertTests.swift; sourceTree = \"<group>\"; };\n\t\t0338E0CC2819226B0094923A /* UpdateInterfaceTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UpdateInterfaceTests.swift; sourceTree = \"<group>\"; };\n\t\t0338E0CD2819226B0094923A /* MultiSelectTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MultiSelectTests.swift; sourceTree = \"<group>\"; };\n\t\t0338E0CE2819226B0094923A /* RowSelectTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RowSelectTests.swift; sourceTree = \"<group>\"; };\n\t\t0338E0D02819226B0094923A /* UpdateTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UpdateTests.swift; sourceTree = \"<group>\"; };\n\t\t0338E0D22819226C0094923A /* InsertInterfaceTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = InsertInterfaceTests.swift; sourceTree = \"<group>\"; };\n\t\t0338E0D42819226C0094923A /* DeleteInterfaceTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DeleteInterfaceTests.swift; sourceTree = \"<group>\"; };\n\t\t0338E0D52819226C0094923A /* AdvanceCRUDTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AdvanceCRUDTests.swift; sourceTree = \"<group>\"; };\n\t\t0344BA8028C9DC7D000BC154 /* ORMUpdateTests.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = ORMUpdateTests.mm; sourceTree = \"<group>\"; };\n\t\t0344BACA28CA0589000BC154 /* ChainCallTests.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = ChainCallTests.mm; sourceTree = \"<group>\"; };\n\t\t03450DB22738BBF000C4DC1B /* OneOrBinaryTokenizer.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = OneOrBinaryTokenizer.cpp; sourceTree = \"<group>\"; };\n\t\t03450DB32738BBF000C4DC1B /* OneOrBinaryTokenizer.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = OneOrBinaryTokenizer.hpp; sourceTree = \"<group>\"; };\n\t\t03450DB62738C8F800C4DC1B /* PinyinTokenizer.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = PinyinTokenizer.cpp; sourceTree = \"<group>\"; };\n\t\t03450DB72738C8F800C4DC1B /* PinyinTokenizer.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = PinyinTokenizer.hpp; sourceTree = \"<group>\"; };\n\t\t036E50B628115AB8007365CD /* WCTBridgeProperty.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WCTBridgeProperty.h; sourceTree = \"<group>\"; };\n\t\t036E50B828115B1D007365CD /* WCTBridgeProperty.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = WCTBridgeProperty.mm; sourceTree = \"<group>\"; };\n\t\t036E50BA28115BA0007365CD /* WCTBridgeProperty+CPP.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = \"WCTBridgeProperty+CPP.h\"; sourceTree = \"<group>\"; };\n\t\t036E50C028116D7A007365CD /* WCTBridgeProperty.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WCTBridgeProperty.swift; sourceTree = \"<group>\"; };\n\t\t037330BF289A909A0030C113 /* Database.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = Database.cpp; sourceTree = \"<group>\"; };\n\t\t037330C0289A909A0030C113 /* Database.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = Database.hpp; sourceTree = \"<group>\"; };\n\t\t0373310A289A94E00030C113 /* PreparedStatement.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = PreparedStatement.cpp; sourceTree = \"<group>\"; };\n\t\t0373310B289A94E00030C113 /* PreparedStatement.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = PreparedStatement.hpp; sourceTree = \"<group>\"; };\n\t\t0373310E289A94F00030C113 /* Handle.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = Handle.cpp; sourceTree = \"<group>\"; };\n\t\t0373310F289A94F10030C113 /* Handle.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = Handle.hpp; sourceTree = \"<group>\"; };\n\t\t037C3C0C2897E33600328EC8 /* WCDBCpp.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = WCDBCpp.framework; sourceTree = BUILT_PRODUCTS_DIR; };\n\t\t0393BEDB27F6ED860058B295 /* ErrorBridge.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ErrorBridge.h; sourceTree = \"<group>\"; };\n\t\t0393BEDF27F6EDAC0058B295 /* ErrorBridge.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = ErrorBridge.cpp; sourceTree = \"<group>\"; };\n\t\t0393BEE327F715180058B295 /* HandleBridge.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = HandleBridge.h; sourceTree = \"<group>\"; };\n\t\t0393BEE527F7152F0058B295 /* HandleBridge.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = HandleBridge.cpp; sourceTree = \"<group>\"; };\n\t\t0397605727F54FA10071FA8F /* ObjectBridge.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = ObjectBridge.cpp; sourceTree = \"<group>\"; };\n\t\t039760A727F563F00071FA8F /* ObjectBridge.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ObjectBridge.swift; sourceTree = \"<group>\"; };\n\t\t039760AA27F5C0DD0071FA8F /* DatabaseBridge.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = DatabaseBridge.h; sourceTree = \"<group>\"; };\n\t\t039760AC27F5C1CA0071FA8F /* DatabaseBridge.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = DatabaseBridge.cpp; sourceTree = \"<group>\"; };\n\t\t039BD3972845CB7C00C58BE2 /* WindowDef.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WindowDef.swift; sourceTree = \"<group>\"; };\n\t\t039BD4342846113D00C58BE2 /* ExpressionOperatableBridge.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = ExpressionOperatableBridge.cpp; sourceTree = \"<group>\"; };\n\t\t039BD4352846113D00C58BE2 /* ExpressionOperatableBridge.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ExpressionOperatableBridge.h; sourceTree = \"<group>\"; };\n\t\t039D724928BF773D00990803 /* Delete.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = Delete.hpp; sourceTree = \"<group>\"; };\n\t\t039D724D28BF795700990803 /* Select.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = Select.hpp; sourceTree = \"<group>\"; };\n\t\t03A15DF828AA636A0031A50A /* ValueArray.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = ValueArray.hpp; sourceTree = \"<group>\"; };\n\t\t03A57F15284089B800D2A4C3 /* SchemaTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SchemaTests.swift; sourceTree = \"<group>\"; };\n\t\t03A57F172840B5A000D2A4C3 /* BindParameter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BindParameter.swift; sourceTree = \"<group>\"; };\n\t\t03A57F1A2840B5DC00D2A4C3 /* BindParameterBridge.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = BindParameterBridge.cpp; sourceTree = \"<group>\"; };\n\t\t03A57F1B2840B5DC00D2A4C3 /* BindParameterBridge.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = BindParameterBridge.h; sourceTree = \"<group>\"; };\n\t\t03A57F1E2840BEFF00D2A4C3 /* BindParameterTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BindParameterTests.swift; sourceTree = \"<group>\"; };\n\t\t03AFD33128B883E700EF5E56 /* Accessor.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = Accessor.hpp; sourceTree = \"<group>\"; };\n\t\t03AFD33928B8A6BD00EF5E56 /* MemberPointer.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = MemberPointer.hpp; sourceTree = \"<group>\"; };\n\t\t03AFD34128B8B21B00EF5E56 /* Field.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = Field.hpp; sourceTree = \"<group>\"; };\n\t\t03AFD34528B8B57600EF5E56 /* Binding.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = Binding.hpp; sourceTree = \"<group>\"; };\n\t\t03AFD34828B8B88300EF5E56 /* CPPORM.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CPPORM.h; sourceTree = \"<group>\"; };\n\t\t03AFD34B28B8BB7600EF5E56 /* Binding.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = Binding.cpp; sourceTree = \"<group>\"; };\n\t\t03AFD34E28B8C4EB00EF5E56 /* Field.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = Field.cpp; sourceTree = \"<group>\"; };\n\t\t03B4DB1528C98E5E00F64141 /* ORMSelectTests.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = ORMSelectTests.mm; sourceTree = \"<group>\"; };\n\t\t03B6A33A2869C51B00D83EC4 /* StatementAlterTableBridge.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = StatementAlterTableBridge.cpp; sourceTree = \"<group>\"; };\n\t\t03B6A33B2869C51B00D83EC4 /* StatementAlterTableBridge.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = StatementAlterTableBridge.h; sourceTree = \"<group>\"; };\n\t\t03BF4B1F2888F87C00A30500 /* BenchmarkTest.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = BenchmarkTest.xctest; sourceTree = BUILT_PRODUCTS_DIR; };\n\t\t03BFC5382852E9CB00673AE4 /* WindowDefTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WindowDefTests.swift; sourceTree = \"<group>\"; };\n\t\t03BFC5D52853538400673AE4 /* IndexedColumnBridge.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = IndexedColumnBridge.cpp; sourceTree = \"<group>\"; };\n\t\t03BFC5D62853538400673AE4 /* IndexedColumnBridge.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = IndexedColumnBridge.h; sourceTree = \"<group>\"; };\n\t\t03C2EAEC27F8382200B41169 /* ErrorBridge.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ErrorBridge.swift; sourceTree = \"<group>\"; };\n\t\t03D077EC28C1F072009A3B18 /* TableOperation.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = TableOperation.cpp; path = cpp/Operation/TableOperation.cpp; sourceTree = SOURCE_ROOT; };\n\t\t03D077ED28C1F072009A3B18 /* TableOperation.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; name = TableOperation.hpp; path = cpp/Operation/TableOperation.hpp; sourceTree = SOURCE_ROOT; };\n\t\t03D077F228C1F611009A3B18 /* TableORMOperation.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; name = TableORMOperation.hpp; path = cpp/Operation/TableORMOperation.hpp; sourceTree = SOURCE_ROOT; };\n\t\t03D077F528C1F951009A3B18 /* HandleORMOperation.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; name = HandleORMOperation.hpp; path = cpp/Operation/HandleORMOperation.hpp; sourceTree = SOURCE_ROOT; };\n\t\t03D077F828C1FB48009A3B18 /* HandleORMOperation.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = HandleORMOperation.cpp; path = cpp/Operation/HandleORMOperation.cpp; sourceTree = SOURCE_ROOT; };\n\t\t03D077FB28C20FEE009A3B18 /* Delete.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = Delete.cpp; sourceTree = \"<group>\"; };\n\t\t03D3A2A628A65D2F0064D4D4 /* ValueTests.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = ValueTests.mm; sourceTree = \"<group>\"; };\n\t\t03DCB5E4286C2E5300CBC75D /* StatementAnalyzeBridge.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = StatementAnalyzeBridge.cpp; sourceTree = \"<group>\"; };\n\t\t03DCB5E5286C2E5300CBC75D /* StatementAnalyzeBridge.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = StatementAnalyzeBridge.h; sourceTree = \"<group>\"; };\n\t\t03DCB5E8286C345C00CBC75D /* StatementAnalyze.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StatementAnalyze.swift; sourceTree = \"<group>\"; };\n\t\t03DCB5EA286C35A600CBC75D /* StatementAnalyzeTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StatementAnalyzeTests.swift; sourceTree = \"<group>\"; };\n\t\t03DCB5EC286C3D8E00CBC75D /* StatementAttachBridge.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = StatementAttachBridge.cpp; sourceTree = \"<group>\"; };\n\t\t03DCB5ED286C3D8E00CBC75D /* StatementAttachBridge.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = StatementAttachBridge.h; sourceTree = \"<group>\"; };\n\t\t03DCB5F0286C480900CBC75D /* StatementCreateIndexBridge.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = StatementCreateIndexBridge.cpp; sourceTree = \"<group>\"; };\n\t\t03DCB5F1286C480900CBC75D /* StatementCreateIndexBridge.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = StatementCreateIndexBridge.h; sourceTree = \"<group>\"; };\n\t\t03E1659127F42D6500D2C926 /* Expression.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Expression.swift; sourceTree = \"<group>\"; };\n\t\t03E1659227F42D6500D2C926 /* StatementExplain.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StatementExplain.swift; sourceTree = \"<group>\"; };\n\t\t03E1659327F42D6500D2C926 /* StatementInsert.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StatementInsert.swift; sourceTree = \"<group>\"; };\n\t\t03E1659427F42D6500D2C926 /* StatementDetach.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StatementDetach.swift; sourceTree = \"<group>\"; };\n\t\t03E1659527F42D6500D2C926 /* ResultColumn.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ResultColumn.swift; sourceTree = \"<group>\"; };\n\t\t03E1659627F42D6500D2C926 /* StatementDropIndex.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StatementDropIndex.swift; sourceTree = \"<group>\"; };\n\t\t03E1659727F42D6500D2C926 /* Pragma.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Pragma.swift; sourceTree = \"<group>\"; };\n\t\t03E1659827F42D6500D2C926 /* Operable.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Operable.swift; sourceTree = \"<group>\"; };\n\t\t03E1659927F42D6500D2C926 /* StatementSelect.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StatementSelect.swift; sourceTree = \"<group>\"; };\n\t\t03E1659C27F42D6500D2C926 /* StatementCreateVirtualTable.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StatementCreateVirtualTable.swift; sourceTree = \"<group>\"; };\n\t\t03E1659D27F42D6500D2C926 /* ForeignKey.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ForeignKey.swift; sourceTree = \"<group>\"; };\n\t\t03E1659E27F42D6500D2C926 /* OrderingTerm.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = OrderingTerm.swift; sourceTree = \"<group>\"; };\n\t\t03E165A027F42D6500D2C926 /* TableConstraint.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TableConstraint.swift; sourceTree = \"<group>\"; };\n\t\t03E165A127F42D6500D2C926 /* Convertible.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Convertible.swift; sourceTree = \"<group>\"; };\n\t\t03E165A227F42D6500D2C926 /* IndexedColumn.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = IndexedColumn.swift; sourceTree = \"<group>\"; };\n\t\t03E165A327F42D6500D2C926 /* StatementDropTable.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StatementDropTable.swift; sourceTree = \"<group>\"; };\n\t\t03E165A427F42D6500D2C926 /* PreparedStatement.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PreparedStatement.swift; sourceTree = \"<group>\"; };\n\t\t03E165A527F42D6500D2C926 /* StatementSavepoint.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StatementSavepoint.swift; sourceTree = \"<group>\"; };\n\t\t03E165A627F42D6500D2C926 /* Column.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Column.swift; sourceTree = \"<group>\"; };\n\t\t03E165A727F42D6500D2C926 /* StatementUpdate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StatementUpdate.swift; sourceTree = \"<group>\"; };\n\t\t03E165A827F42D6500D2C926 /* TableOrSubquery.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TableOrSubquery.swift; sourceTree = \"<group>\"; };\n\t\t03E165A927F42D6500D2C926 /* LiteralValue.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LiteralValue.swift; sourceTree = \"<group>\"; };\n\t\t03E165AA27F42D6500D2C926 /* Value.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Value.swift; sourceTree = \"<group>\"; };\n\t\t03E165AB27F42D6500D2C926 /* StatementCreateTable.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StatementCreateTable.swift; sourceTree = \"<group>\"; };\n\t\t03E165AC27F42D6500D2C926 /* Join.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Join.swift; sourceTree = \"<group>\"; };\n\t\t03E165AD27F42D6500D2C926 /* StatementDelete.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StatementDelete.swift; sourceTree = \"<group>\"; };\n\t\t03E165AE27F42D6500D2C926 /* StatementAttach.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StatementAttach.swift; sourceTree = \"<group>\"; };\n\t\t03E165AF27F42D6500D2C926 /* StatementAlterTable.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StatementAlterTable.swift; sourceTree = \"<group>\"; };\n\t\t03E165B027F42D6500D2C926 /* StatementRollback.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StatementRollback.swift; sourceTree = \"<group>\"; };\n\t\t03E165B227F42D6500D2C926 /* StatementVacuum.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StatementVacuum.swift; sourceTree = \"<group>\"; };\n\t\t03E165B327F42D6500D2C926 /* StatementRelease.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StatementRelease.swift; sourceTree = \"<group>\"; };\n\t\t03E165B427F42D6500D2C926 /* ColumnDef.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ColumnDef.swift; sourceTree = \"<group>\"; };\n\t\t03E165B527F42D6500D2C926 /* StatementReindex.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StatementReindex.swift; sourceTree = \"<group>\"; };\n\t\t03E165B627F42D6500D2C926 /* StatementCreateIndex.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StatementCreateIndex.swift; sourceTree = \"<group>\"; };\n\t\t03E165B727F42D6500D2C926 /* Statement.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Statement.swift; sourceTree = \"<group>\"; };\n\t\t03E165BA27F42D6500D2C926 /* StatementPragma.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StatementPragma.swift; sourceTree = \"<group>\"; };\n\t\t03E165BB27F42D6500D2C926 /* Handle.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Handle.swift; sourceTree = \"<group>\"; };\n\t\t03E165BE27F42D6500D2C926 /* CodableType.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CodableType.swift; sourceTree = \"<group>\"; };\n\t\t03E165BF27F42D6500D2C926 /* Master.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Master.swift; sourceTree = \"<group>\"; };\n\t\t03E165C227F42D6500D2C926 /* Declare.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Declare.swift; sourceTree = \"<group>\"; };\n\t\t03E165C327F42D6500D2C926 /* RowSelect.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RowSelect.swift; sourceTree = \"<group>\"; };\n\t\t03E165C427F42D6500D2C926 /* Update.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Update.swift; sourceTree = \"<group>\"; };\n\t\t03E165C527F42D6500D2C926 /* Delete.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Delete.swift; sourceTree = \"<group>\"; };\n\t\t03E165C627F42D6500D2C926 /* ChainCall.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ChainCall.swift; sourceTree = \"<group>\"; };\n\t\t03E165C727F42D6500D2C926 /* Table.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Table.swift; sourceTree = \"<group>\"; };\n\t\t03E165C827F42D6500D2C926 /* TableCRUDInterface.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TableCRUDInterface.swift; sourceTree = \"<group>\"; };\n\t\t03E165C927F42D6500D2C926 /* Select.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Select.swift; sourceTree = \"<group>\"; };\n\t\t03E165CB27F42D6500D2C926 /* Selectable.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Selectable.swift; sourceTree = \"<group>\"; };\n\t\t03E165CC27F42D6500D2C926 /* MultiSelect.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MultiSelect.swift; sourceTree = \"<group>\"; };\n\t\t03E165CD27F42D6500D2C926 /* Insert.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Insert.swift; sourceTree = \"<group>\"; };\n\t\t03E165CF27F42D6500D2C926 /* ColumnCodable.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ColumnCodable.swift; sourceTree = \"<group>\"; };\n\t\t03E165D027F42D6500D2C926 /* ColumnTypeDecoder.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ColumnTypeDecoder.swift; sourceTree = \"<group>\"; };\n\t\t03E165D127F42D6500D2C926 /* TableCodable.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TableCodable.swift; sourceTree = \"<group>\"; };\n\t\t03E165D227F42D6500D2C926 /* CodingTableKey.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CodingTableKey.swift; sourceTree = \"<group>\"; };\n\t\t03E165D327F42D6500D2C926 /* TableEncoder.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TableEncoder.swift; sourceTree = \"<group>\"; };\n\t\t03E165D427F42D6500D2C926 /* TableDecoder.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TableDecoder.swift; sourceTree = \"<group>\"; };\n\t\t03E165D727F42D6500D2C926 /* Property.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Property.swift; sourceTree = \"<group>\"; };\n\t\t03E165D827F42D6500D2C926 /* Redirectable.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Redirectable.swift; sourceTree = \"<group>\"; };\n\t\t03E165DC27F42D6500D2C926 /* TableBinding.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TableBinding.swift; sourceTree = \"<group>\"; };\n\t\t03E165E127F42D6500D2C926 /* BaseType.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BaseType.swift; sourceTree = \"<group>\"; };\n\t\t03E165E327F42D6500D2C926 /* Database.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Database.swift; sourceTree = \"<group>\"; };\n\t\t03E165E827F42D6500D2C926 /* Recyclable.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Recyclable.swift; sourceTree = \"<group>\"; };\n\t\t03E165EA27F42D6500D2C926 /* WCDBError.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = WCDBError.swift; sourceTree = \"<group>\"; };\n\t\t03E165EE27F42D6500D2C926 /* Lock.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Lock.swift; sourceTree = \"<group>\"; };\n\t\t03E165F627F42D6500D2C926 /* Optional.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Optional.swift; sourceTree = \"<group>\"; };\n\t\t03E165F727F42D6500D2C926 /* Convenience.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Convenience.swift; sourceTree = \"<group>\"; };\n\t\t03E1670B27F434E800D2C926 /* InitializationBenchmark.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = InitializationBenchmark.swift; sourceTree = \"<group>\"; };\n\t\t03E1670C27F434E800D2C926 /* SyncWriteBenchmark.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SyncWriteBenchmark.swift; sourceTree = \"<group>\"; };\n\t\t03E1670E27F434E800D2C926 /* CipherWriteBenchmark.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CipherWriteBenchmark.swift; sourceTree = \"<group>\"; };\n\t\t03E1670F27F434E800D2C926 /* CipherReadBenchmark.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CipherReadBenchmark.swift; sourceTree = \"<group>\"; };\n\t\t03E1671127F434E800D2C926 /* BaselineWriteBenchmark.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BaselineWriteBenchmark.swift; sourceTree = \"<group>\"; };\n\t\t03E1671227F434E800D2C926 /* BaselineBatchWriteBenchmark.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BaselineBatchWriteBenchmark.swift; sourceTree = \"<group>\"; };\n\t\t03E1671327F434E800D2C926 /* BaselineReadBenchmark.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BaselineReadBenchmark.swift; sourceTree = \"<group>\"; };\n\t\t03E1671527F434E800D2C926 /* BaseBenchmark.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BaseBenchmark.swift; sourceTree = \"<group>\"; };\n\t\t03E1671627F434E800D2C926 /* BenchmarkObject.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BenchmarkObject.swift; sourceTree = \"<group>\"; };\n\t\t03E1671727F434E800D2C926 /* Config.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Config.swift; sourceTree = \"<group>\"; };\n\t\t03E1671827F434E800D2C926 /* RandomData.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RandomData.swift; sourceTree = \"<group>\"; };\n\t\t03E1671A27F434E800D2C926 /* BaseMultithreadBenchmark.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BaseMultithreadBenchmark.swift; sourceTree = \"<group>\"; };\n\t\t03E1671B27F434E800D2C926 /* MultithreadReadWriteBenchmark.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MultithreadReadWriteBenchmark.swift; sourceTree = \"<group>\"; };\n\t\t03E1671C27F434E800D2C926 /* MultithreadReadReadBenchmark.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MultithreadReadReadBenchmark.swift; sourceTree = \"<group>\"; };\n\t\t03E1671D27F434E800D2C926 /* MultithreadWriteWriteBenchmark.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MultithreadWriteWriteBenchmark.swift; sourceTree = \"<group>\"; };\n\t\t03E1672027F434E800D2C926 /* TracerTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TracerTests.swift; sourceTree = \"<group>\"; };\n\t\t03E1672127F434E800D2C926 /* RepairTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RepairTests.swift; sourceTree = \"<group>\"; };\n\t\t03E1672227F434E800D2C926 /* FileTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FileTests.swift; sourceTree = \"<group>\"; };\n\t\t03E1672427F434E800D2C926 /* StatementDetachTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StatementDetachTests.swift; sourceTree = \"<group>\"; };\n\t\t03E1672527F434E800D2C926 /* StatementCreateTableTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StatementCreateTableTests.swift; sourceTree = \"<group>\"; };\n\t\t03E1672627F434E800D2C926 /* StatementSelectTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StatementSelectTests.swift; sourceTree = \"<group>\"; };\n\t\t03E1672727F434E800D2C926 /* StatementCreateVirtualTableTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StatementCreateVirtualTableTests.swift; sourceTree = \"<group>\"; };\n\t\t03E1672827F434E800D2C926 /* StatementUpdateTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StatementUpdateTests.swift; sourceTree = \"<group>\"; };\n\t\t03E1672927F434E800D2C926 /* StatementDeleteTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StatementDeleteTests.swift; sourceTree = \"<group>\"; };\n\t\t03E1672A27F434E800D2C926 /* StatementExplainTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StatementExplainTests.swift; sourceTree = \"<group>\"; };\n\t\t03E1672B27F434E800D2C926 /* StatementSavepointTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StatementSavepointTests.swift; sourceTree = \"<group>\"; };\n\t\t03E1672C27F434E800D2C926 /* StatementDropIndexTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StatementDropIndexTests.swift; sourceTree = \"<group>\"; };\n\t\t03E1672D27F434E800D2C926 /* TableConstraintTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TableConstraintTests.swift; sourceTree = \"<group>\"; };\n\t\t03E1672E27F434E800D2C926 /* StatementAlterTableTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StatementAlterTableTests.swift; sourceTree = \"<group>\"; };\n\t\t03E1672F27F434E800D2C926 /* ColumnDefTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ColumnDefTests.swift; sourceTree = \"<group>\"; };\n\t\t03E1673027F434E800D2C926 /* LiteralValueTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LiteralValueTests.swift; sourceTree = \"<group>\"; };\n\t\t03E1673127F434E800D2C926 /* StatementAttachTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StatementAttachTests.swift; sourceTree = \"<group>\"; };\n\t\t03E1673327F434E800D2C926 /* TableOrSubqueryTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TableOrSubqueryTests.swift; sourceTree = \"<group>\"; };\n\t\t03E1673427F434E800D2C926 /* StatementReindexTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StatementReindexTests.swift; sourceTree = \"<group>\"; };\n\t\t03E1673527F434E800D2C926 /* OrderingTermTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = OrderingTermTests.swift; sourceTree = \"<group>\"; };\n\t\t03E1673627F434E800D2C926 /* StatementPragmaTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StatementPragmaTests.swift; sourceTree = \"<group>\"; };\n\t\t03E1673727F434E800D2C926 /* ForeignKeyTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ForeignKeyTests.swift; sourceTree = \"<group>\"; };\n\t\t03E1673927F434E800D2C926 /* StatementRollbackTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StatementRollbackTests.swift; sourceTree = \"<group>\"; };\n\t\t03E1673A27F434E800D2C926 /* ColumnTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ColumnTests.swift; sourceTree = \"<group>\"; };\n\t\t03E1673B27F434E800D2C926 /* StatementReleaseTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StatementReleaseTests.swift; sourceTree = \"<group>\"; };\n\t\t03E1673C27F434E800D2C926 /* StatementCreateIndexTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StatementCreateIndexTests.swift; sourceTree = \"<group>\"; };\n\t\t03E1673D27F434E800D2C926 /* ExpressionTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ExpressionTests.swift; sourceTree = \"<group>\"; };\n\t\t03E1673F27F434E800D2C926 /* JoinTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = JoinTests.swift; sourceTree = \"<group>\"; };\n\t\t03E1674027F434E800D2C926 /* StatementDropTableTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StatementDropTableTests.swift; sourceTree = \"<group>\"; };\n\t\t03E1674127F434E800D2C926 /* StatementVacuumTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StatementVacuumTests.swift; sourceTree = \"<group>\"; };\n\t\t03E1674227F434E800D2C926 /* IndexedColumnTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = IndexedColumnTests.swift; sourceTree = \"<group>\"; };\n\t\t03E1674327F434E800D2C926 /* StatementInsertTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StatementInsertTests.swift; sourceTree = \"<group>\"; };\n\t\t03E1674527F434E800D2C926 /* ResultColumnTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ResultColumnTests.swift; sourceTree = \"<group>\"; };\n\t\t03E1674627F434E800D2C926 /* ColumnTypeTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ColumnTypeTests.swift; sourceTree = \"<group>\"; };\n\t\t03E1674827F434E800D2C926 /* AdvanceCRUDTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AdvanceCRUDTests.swift; sourceTree = \"<group>\"; };\n\t\t03E1674927F434E800D2C926 /* TableTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TableTests.swift; sourceTree = \"<group>\"; };\n\t\t03E1674A27F434E800D2C926 /* InsertTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = InsertTests.swift; sourceTree = \"<group>\"; };\n\t\t03E1674B27F434E800D2C926 /* AdvanceTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AdvanceTests.swift; sourceTree = \"<group>\"; };\n\t\t03E1674C27F434E800D2C926 /* MultithreadTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MultithreadTests.swift; sourceTree = \"<group>\"; };\n\t\t03E1674D27F434E800D2C926 /* RowSelectTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RowSelectTests.swift; sourceTree = \"<group>\"; };\n\t\t03E1674E27F434E800D2C926 /* DatabaseTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DatabaseTests.swift; sourceTree = \"<group>\"; };\n\t\t03E1674F27F434E800D2C926 /* InsertInterfaceTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = InsertInterfaceTests.swift; sourceTree = \"<group>\"; };\n\t\t03E1675027F434E800D2C926 /* UpdateInterfaceTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UpdateInterfaceTests.swift; sourceTree = \"<group>\"; };\n\t\t03E1675127F434E800D2C926 /* TypedTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TypedTests.swift; sourceTree = \"<group>\"; };\n\t\t03E1675227F434E800D2C926 /* TestObject.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TestObject.swift; sourceTree = \"<group>\"; };\n\t\t03E1675327F434E800D2C926 /* CRUDTestCase.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CRUDTestCase.swift; sourceTree = \"<group>\"; };\n\t\t03E1675427F434E800D2C926 /* MultiSelectTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MultiSelectTests.swift; sourceTree = \"<group>\"; };\n\t\t03E1675527F434E800D2C926 /* SelectInterfaceTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SelectInterfaceTests.swift; sourceTree = \"<group>\"; };\n\t\t03E1675627F434E800D2C926 /* DeleteTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DeleteTests.swift; sourceTree = \"<group>\"; };\n\t\t03E1675727F434E800D2C926 /* DeleteInterfaceTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DeleteInterfaceTests.swift; sourceTree = \"<group>\"; };\n\t\t03E1675827F434E800D2C926 /* UpdateTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UpdateTests.swift; sourceTree = \"<group>\"; };\n\t\t03E1675A27F434E800D2C926 /* SelectTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SelectTests.swift; sourceTree = \"<group>\"; };\n\t\t03E1675C27F434E800D2C926 /* TableConstraintBindingTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TableConstraintBindingTests.swift; sourceTree = \"<group>\"; };\n\t\t03E1675D27F434E800D2C926 /* VirtualTableBindingTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = VirtualTableBindingTests.swift; sourceTree = \"<group>\"; };\n\t\t03E1675E27F434E800D2C926 /* ColumnConstraintBindingTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ColumnConstraintBindingTests.swift; sourceTree = \"<group>\"; };\n\t\t03E1675F27F434E800D2C926 /* IndexBindingTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = IndexBindingTests.swift; sourceTree = \"<group>\"; };\n\t\t03E1676127F434E800D2C926 /* Assert.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Assert.swift; sourceTree = \"<group>\"; };\n\t\t03E1676227F434E800D2C926 /* BaseTestCase.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BaseTestCase.swift; sourceTree = \"<group>\"; };\n\t\t03E1676327F434E800D2C926 /* Convenience.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Convenience.swift; sourceTree = \"<group>\"; };\n\t\t03E167B727F46C7100D2C926 /* ObjectBridge.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ObjectBridge.h; sourceTree = \"<group>\"; };\n\t\t03E167B927F46E2E00D2C926 /* ObjectBridge.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = ObjectBridge.hpp; sourceTree = \"<group>\"; };\n\t\t03E3180C28A21AF800540CB1 /* CppInterface.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CppInterface.h; sourceTree = \"<group>\"; };\n\t\t03E5CB0028A3513C005353D9 /* WCDBCpp.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WCDBCpp.h; sourceTree = \"<group>\"; };\n\t\t03E5CC4928A38CCA005353D9 /* CppTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = CppTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };\n\t\t03E5CC4E28A38DDB005353D9 /* CPPBaseTestCase.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = CPPBaseTestCase.mm; sourceTree = \"<group>\"; };\n\t\t03E5CC5028A38DEB005353D9 /* CPPBaseTestCase.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CPPBaseTestCase.h; sourceTree = \"<group>\"; };\n\t\t03E5CC5C28A3A16F005353D9 /* CPPDatabaseTestCase.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CPPDatabaseTestCase.h; sourceTree = \"<group>\"; };\n\t\t03E5CC5E28A3A185005353D9 /* CPPDatabaseTestCase.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = CPPDatabaseTestCase.mm; sourceTree = \"<group>\"; };\n\t\t03E5CC6628A3B083005353D9 /* CPPFileTests.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = CPPFileTests.mm; sourceTree = \"<group>\"; };\n\t\t03E5CC6828A3B09E005353D9 /* CPPTestCase.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CPPTestCase.h; sourceTree = \"<group>\"; };\n\t\t03E5CC6A28A3B6A4005353D9 /* CPPConfigTests.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = CPPConfigTests.mm; sourceTree = \"<group>\"; };\n\t\t03E5CC6C28A3BDF3005353D9 /* Value.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = Value.cpp; sourceTree = \"<group>\"; };\n\t\t03E5CC6D28A3BDF3005353D9 /* Value.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = Value.hpp; sourceTree = \"<group>\"; };\n\t\t03E8227E28447B940072CA57 /* ColumnDefBridge.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = ColumnDefBridge.cpp; sourceTree = \"<group>\"; };\n\t\t03E8227F28447B940072CA57 /* ColumnDefBridge.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ColumnDefBridge.h; sourceTree = \"<group>\"; };\n\t\t03E822822844B8760072CA57 /* CommonTableExpressionBridge.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = CommonTableExpressionBridge.cpp; sourceTree = \"<group>\"; };\n\t\t03E822832844B8760072CA57 /* CommonTableExpressionBridge.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CommonTableExpressionBridge.h; sourceTree = \"<group>\"; };\n\t\t03E822862844B8CD0072CA57 /* StatementSelectBridge.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = StatementSelectBridge.cpp; sourceTree = \"<group>\"; };\n\t\t03E822872844B8CD0072CA57 /* StatementSelectBridge.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = StatementSelectBridge.h; sourceTree = \"<group>\"; };\n\t\t03E8228B2844BEFF0072CA57 /* CommonTableExpression.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CommonTableExpression.swift; sourceTree = \"<group>\"; };\n\t\t03E8228D2844C0E70072CA57 /* CommonTableExpressionTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CommonTableExpressionTests.swift; sourceTree = \"<group>\"; };\n\t\t03E8228F2844E1AB0072CA57 /* RaiseFunctionBridge.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = RaiseFunctionBridge.cpp; sourceTree = \"<group>\"; };\n\t\t03E822902844E1AB0072CA57 /* RaiseFunctionBridge.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RaiseFunctionBridge.h; sourceTree = \"<group>\"; };\n\t\t03EA88CD27D5F05D0075C7BD /* FTSError.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = FTSError.hpp; sourceTree = \"<group>\"; };\n\t\t03EA88CF27D5F0840075C7BD /* FTSError.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = FTSError.cpp; sourceTree = \"<group>\"; };\n\t\t03EE3A50287FCECF00C8F0B3 /* StatementCreateTrigger.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StatementCreateTrigger.swift; sourceTree = \"<group>\"; };\n\t\t03EE3DA628810C2000C8F0B3 /* StatementCreateTriggerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StatementCreateTriggerTests.swift; sourceTree = \"<group>\"; };\n\t\t03EE3DA8288165A700C8F0B3 /* StatementInsertBridge.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = StatementInsertBridge.cpp; sourceTree = \"<group>\"; };\n\t\t03EE3DA9288165A700C8F0B3 /* StatementInsertBridge.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = StatementInsertBridge.h; sourceTree = \"<group>\"; };\n\t\t03EE3DAC28816DA800C8F0B3 /* StatementUpdateBridge.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = StatementUpdateBridge.cpp; sourceTree = \"<group>\"; };\n\t\t03EE3DAD28816DA800C8F0B3 /* StatementUpdateBridge.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = StatementUpdateBridge.h; sourceTree = \"<group>\"; };\n\t\t03F428E828BF686F005CE249 /* Update.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = Update.hpp; sourceTree = \"<group>\"; };\n\t\t03F5481E287D8467007BCA3E /* StatementDetachBridge.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = StatementDetachBridge.cpp; sourceTree = \"<group>\"; };\n\t\t03F5481F287D8467007BCA3E /* StatementDetachBridge.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = StatementDetachBridge.h; sourceTree = \"<group>\"; };\n\t\t03F54822287D87F9007BCA3E /* StatementDropIndexBridge.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = StatementDropIndexBridge.cpp; sourceTree = \"<group>\"; };\n\t\t03F54823287D87F9007BCA3E /* StatementDropIndexBridge.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = StatementDropIndexBridge.h; sourceTree = \"<group>\"; };\n\t\t03F54826287D93A7007BCA3E /* StatementDropTableBridge.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = StatementDropTableBridge.cpp; sourceTree = \"<group>\"; };\n\t\t03F54827287D93A7007BCA3E /* StatementDropTableBridge.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = StatementDropTableBridge.h; sourceTree = \"<group>\"; };\n\t\t0D0CD79E2A6FA1A900F89C6B /* CipherMigrationTests.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = CipherMigrationTests.mm; sourceTree = \"<group>\"; };\n\t\t0D0CD7A02A6FBE0C00F89C6B /* MigrateTests.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = MigrateTests.mm; sourceTree = \"<group>\"; };\n\t\t0D0D56BF254ABE9B000F16A6 /* FTS5Object.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = FTS5Object.h; sourceTree = \"<group>\"; };\n\t\t0D0D56C0254ABEAA000F16A6 /* FTS5Object.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = FTS5Object.mm; sourceTree = \"<group>\"; };\n\t\t0D0D56C9254AC0F0000F16A6 /* FTS5Test.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = FTS5Test.mm; sourceTree = \"<group>\"; };\n\t\t0D19BA092B0702250028F92B /* AssembleHandleOperator.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = AssembleHandleOperator.cpp; sourceTree = \"<group>\"; };\n\t\t0D19BA0A2B0702250028F92B /* AssembleHandleOperator.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = AssembleHandleOperator.hpp; sourceTree = \"<group>\"; };\n\t\t0D19BA1D2B07481B0028F92B /* IntegerityHandleOperator.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = IntegerityHandleOperator.cpp; sourceTree = \"<group>\"; };\n\t\t0D19BA1E2B07481B0028F92B /* IntegerityHandleOperator.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = IntegerityHandleOperator.hpp; sourceTree = \"<group>\"; };\n\t\t0D249BC02542B8E900B43BD9 /* MergeFTSIndexLogic.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = MergeFTSIndexLogic.hpp; sourceTree = \"<group>\"; };\n\t\t0D249BC82542B90600B43BD9 /* MergeFTSIndexLogic.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = MergeFTSIndexLogic.cpp; sourceTree = \"<group>\"; };\n\t\t0D2789D82B21995800F60E2D /* CompressionTests.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = CompressionTests.mm; sourceTree = \"<group>\"; };\n\t\t0D32815D2B04A8E60027B973 /* DecorativeHandle.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = DecorativeHandle.cpp; sourceTree = \"<group>\"; };\n\t\t0D32815E2B04A8E60027B973 /* DecorativeHandle.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = DecorativeHandle.hpp; sourceTree = \"<group>\"; };\n\t\t0D3281672B04AC7A0027B973 /* FunctionContainer.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = FunctionContainer.cpp; sourceTree = \"<group>\"; };\n\t\t0D36C0F62AF1E00C000BC0DD /* STDOptionalAccessor.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = STDOptionalAccessor.hpp; sourceTree = \"<group>\"; };\n\t\t0D36C0F92AF1E3A1000BC0DD /* CPPSTDOptionalAllTypesObject.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CPPSTDOptionalAllTypesObject.h; sourceTree = \"<group>\"; };\n\t\t0D36C0FA2AF1E3B1000BC0DD /* CPPSTDOptionalAllTypesObject.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = CPPSTDOptionalAllTypesObject.mm; sourceTree = \"<group>\"; };\n\t\t0D36C0FC2AF1F0B6000BC0DD /* WCDBOptionalAccessor.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = WCDBOptionalAccessor.hpp; sourceTree = \"<group>\"; };\n\t\t0D36C0FF2AF1F482000BC0DD /* CPPWCDBOptionalAllTypesObject.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CPPWCDBOptionalAllTypesObject.h; sourceTree = \"<group>\"; };\n\t\t0D36C1002AF1F492000BC0DD /* CPPWCDBOptionalAllTypesObject.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = CPPWCDBOptionalAllTypesObject.mm; sourceTree = \"<group>\"; };\n\t\t0D3AE53725416D99007B9D0E /* AutoMergeFTSIndexConfig.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = AutoMergeFTSIndexConfig.hpp; sourceTree = \"<group>\"; };\n\t\t0D3AE53F25416DB4007B9D0E /* AutoMergeFTSIndexConfig.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = AutoMergeFTSIndexConfig.cpp; sourceTree = \"<group>\"; };\n\t\t0D3FFA452A2F2911002DF7CD /* SysTypes.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SysTypes.h; sourceTree = \"<group>\"; };\n\t\t0D435A602AF1092100FABDAF /* CPPSharedPtrAllTypesObject.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = CPPSharedPtrAllTypesObject.mm; sourceTree = \"<group>\"; };\n\t\t0D435A622AF1093B00FABDAF /* CPPSharedPtrAllTypesObject.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CPPSharedPtrAllTypesObject.h; sourceTree = \"<group>\"; };\n\t\t0D47A9752A6E332B008E9E2C /* MigrationTestObjectBase.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MigrationTestObjectBase.h; sourceTree = \"<group>\"; };\n\t\t0D47A9762A6E333D008E9E2C /* MigrationTestObjectBase.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = MigrationTestObjectBase.mm; sourceTree = \"<group>\"; };\n\t\t0D4F0F942AC5728A0067027E /* WCTPerformanceInfo.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WCTPerformanceInfo.h; sourceTree = \"<group>\"; };\n\t\t0D4F0F972AC572B20067027E /* WCTPerformanceInfo.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = WCTPerformanceInfo.mm; sourceTree = \"<group>\"; };\n\t\t0D4F0F9A2AC576560067027E /* WCTPerformanceInfo+Private.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = \"WCTPerformanceInfo+Private.h\"; sourceTree = \"<group>\"; };\n\t\t0D4FE5EE29482F4D0061C3CA /* Builtin.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Builtin.h; sourceTree = \"<group>\"; };\n\t\t0D5363E8290A65390026A4DC /* Master.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = Master.cpp; sourceTree = \"<group>\"; };\n\t\t0D5363E9290A65390026A4DC /* Master.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = Master.hpp; sourceTree = \"<group>\"; };\n\t\t0D5363EE290A75F20026A4DC /* Sequence.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = Sequence.cpp; sourceTree = \"<group>\"; };\n\t\t0D5363EF290A75F20026A4DC /* Sequence.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = Sequence.hpp; sourceTree = \"<group>\"; };\n\t\t0D5403012B160693007DF415 /* CompressingStatementDecorator.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = CompressingStatementDecorator.cpp; sourceTree = \"<group>\"; };\n\t\t0D5403022B160693007DF415 /* CompressingStatementDecorator.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = CompressingStatementDecorator.hpp; sourceTree = \"<group>\"; };\n\t\t0D54030B2B1606BC007DF415 /* CompressingHandleDecorator.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = CompressingHandleDecorator.cpp; sourceTree = \"<group>\"; };\n\t\t0D54030C2B1606BC007DF415 /* CompressingHandleDecorator.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = CompressingHandleDecorator.hpp; sourceTree = \"<group>\"; };\n\t\t0D71F9332A8B377100F7B4F6 /* Random.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Random.swift; sourceTree = \"<group>\"; };\n\t\t0D8084202A861E8500C81BBF /* WCTCancellationSignal.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WCTCancellationSignal.h; sourceTree = \"<group>\"; };\n\t\t0D8084232A861E9500C81BBF /* WCTCancellationSignal.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = WCTCancellationSignal.mm; sourceTree = \"<group>\"; };\n\t\t0D8084262A861FDB00C81BBF /* WCTCancellationSignal+Private.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = \"WCTCancellationSignal+Private.h\"; sourceTree = \"<group>\"; };\n\t\t0D81CDA82A569CB40051FF8E /* ColumnConstraintEnablePrimaryAutoIncrement.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ColumnConstraintEnablePrimaryAutoIncrement.h; sourceTree = \"<group>\"; };\n\t\t0D81CDA92A569CE40051FF8E /* ColumnConstraintEnablePrimaryAutoIncrement.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = ColumnConstraintEnablePrimaryAutoIncrement.mm; sourceTree = \"<group>\"; };\n\t\t0D81CDAA2A569CFC0051FF8E /* ColumnConstraintEnablePrimaryAutoIncrement+WCTTableCoding.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = \"ColumnConstraintEnablePrimaryAutoIncrement+WCTTableCoding.h\"; sourceTree = \"<group>\"; };\n\t\t0D81CDAC2A56DA070051FF8E /* CPPColumnConstraintEnablePrimaryAutoIncrement.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = CPPColumnConstraintEnablePrimaryAutoIncrement.cpp; sourceTree = \"<group>\"; };\n\t\t0D81CDAD2A56DA070051FF8E /* CPPColumnConstraintEnablePrimaryAutoIncrement.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = CPPColumnConstraintEnablePrimaryAutoIncrement.hpp; sourceTree = \"<group>\"; };\n\t\t0D8BC3072B99B3BF00DE9AE5 /* WCDBBridging.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WCDBBridging.h; sourceTree = \"<group>\"; };\n\t\t0DACF8B22B2ADC7700CB0710 /* WCDB.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = WCDB.xcconfig; sourceTree = \"<group>\"; };\n\t\t0DAD8FF62B303D2A00372DBF /* CompressRobustyTests.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = CompressRobustyTests.mm; sourceTree = \"<group>\"; };\n\t\t0DAD93C029FA2A1200E5788C /* TableChainCall.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TableChainCall.swift; sourceTree = \"<group>\"; };\n\t\t0DAD93C329FA2C4800E5788C /* TableChainCall+WCTTableCoding.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = \"TableChainCall+WCTTableCoding.swift\"; sourceTree = \"<group>\"; };\n\t\t0DAE11D328DC6CC6003FB63A /* WCDB.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WCDB.h; sourceTree = \"<group>\"; };\n\t\t0DC98FD028E46049007F3796 /* DBOperationNotifier.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = DBOperationNotifier.cpp; sourceTree = \"<group>\"; };\n\t\t0DC98FD128E46049007F3796 /* DBOperationNotifier.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = DBOperationNotifier.hpp; sourceTree = \"<group>\"; };\n\t\t0DCD2AC12C6E210700C247EC /* AutoVacuumConfig.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = AutoVacuumConfig.cpp; sourceTree = \"<group>\"; };\n\t\t0DCD2AC22C6E210700C247EC /* AutoVacuumConfig.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = AutoVacuumConfig.hpp; sourceTree = \"<group>\"; };\n\t\t0DD8D1152B074C47002C97D3 /* MigrateHandleOperator.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = MigrateHandleOperator.cpp; sourceTree = \"<group>\"; };\n\t\t0DD8D1162B074C47002C97D3 /* MigrateHandleOperator.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = MigrateHandleOperator.hpp; sourceTree = \"<group>\"; };\n\t\t0DDF54282B32D18900DB3D65 /* VacuumRobustyTests.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = VacuumRobustyTests.mm; sourceTree = \"<group>\"; };\n\t\t0DDF542A2B32D3EC00DB3D65 /* RobustyTestCase.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = RobustyTestCase.mm; sourceTree = \"<group>\"; };\n\t\t0DDF542C2B32D3FF00DB3D65 /* RobustyTestCase.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RobustyTestCase.h; sourceTree = \"<group>\"; };\n\t\t0DE08A1B29CBE79C009A7CA3 /* CrossPlatform.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CrossPlatform.h; sourceTree = \"<group>\"; };\n\t\t0DE08A1C29CBE79C009A7CA3 /* WCTFileManager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WCTFileManager.cpp; sourceTree = \"<group>\"; };\n\t\t0DE08A1D29CBE79C009A7CA3 /* CrossPlatform.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = CrossPlatform.c; sourceTree = \"<group>\"; };\n\t\t0DE08A1E29CBE79C009A7CA3 /* WCTOperationQueue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WCTOperationQueue.cpp; sourceTree = \"<group>\"; };\n\t\t0DE2D9A22AEB934E005420D3 /* CPPTableTest.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = CPPTableTest.mm; sourceTree = \"<group>\"; };\n\t\t0DE68B352AB45C27008BD74C /* RepairTestObjectBase.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = RepairTestObjectBase.mm; sourceTree = \"<group>\"; };\n\t\t0DE68B372AB45C36008BD74C /* RepairTestObjectBase.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RepairTestObjectBase.h; sourceTree = \"<group>\"; };\n\t\t0DE68B382AB45EE8008BD74C /* RepairTestObject.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RepairTestObject.h; sourceTree = \"<group>\"; };\n\t\t0DE68B392AB45F5F008BD74C /* NormalRepairTestObject.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = NormalRepairTestObject.h; sourceTree = \"<group>\"; };\n\t\t0DE68B3A2AB45F6C008BD74C /* NormalRepairTestObject.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = NormalRepairTestObject.mm; sourceTree = \"<group>\"; };\n\t\t0DE68B3C2AB461A0008BD74C /* AutoIncrementRepairTestObject.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AutoIncrementRepairTestObject.h; sourceTree = \"<group>\"; };\n\t\t0DE68B3D2AB461AA008BD74C /* AutoIncrementRepairTestObject.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = AutoIncrementRepairTestObject.mm; sourceTree = \"<group>\"; };\n\t\t0DE68B3F2AB466E5008BD74C /* WithoutRowidRepairTestObject.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WithoutRowidRepairTestObject.h; sourceTree = \"<group>\"; };\n\t\t0DE68B402AB466F1008BD74C /* WithoutRowidRepairTestObject.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = WithoutRowidRepairTestObject.mm; sourceTree = \"<group>\"; };\n\t\t0DE84ACD2B03295400522A4E /* FunctionContainer.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = FunctionContainer.hpp; sourceTree = \"<group>\"; };\n\t\t0DE84C7B2B03886800522A4E /* DecorativeHandleStatement.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = DecorativeHandleStatement.cpp; sourceTree = \"<group>\"; };\n\t\t0DE84C7C2B03886800522A4E /* DecorativeHandleStatement.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = DecorativeHandleStatement.hpp; sourceTree = \"<group>\"; };\n\t\t0DF1089529C05559004ED764 /* StatementSelectInterface.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StatementSelectInterface.swift; sourceTree = \"<group>\"; };\n\t\t2304B42622156CD700901953 /* TokenizerModule.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = TokenizerModule.cpp; sourceTree = \"<group>\"; };\n\t\t2304B42722156CD700901953 /* TokenizerModule.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = TokenizerModule.hpp; sourceTree = \"<group>\"; };\n\t\t2304B42C22156E1500901953 /* TokenizerModules.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = TokenizerModules.cpp; sourceTree = \"<group>\"; };\n\t\t2304B42D22156E1500901953 /* TokenizerModules.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = TokenizerModules.hpp; sourceTree = \"<group>\"; };\n\t\t2308F84B20E32A51001CD9C3 /* FileHandle.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FileHandle.cpp; sourceTree = \"<group>\"; };\n\t\t2308F84C20E32A51001CD9C3 /* FileHandle.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = FileHandle.hpp; sourceTree = \"<group>\"; };\n\t\t2308F84D20E32A51001CD9C3 /* Serialization.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Serialization.cpp; sourceTree = \"<group>\"; };\n\t\t2308F84E20E32A51001CD9C3 /* Serialization.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = Serialization.hpp; sourceTree = \"<group>\"; };\n\t\t2308F8A720E37FB0001CD9C3 /* WCTDatabase+Repair.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = \"WCTDatabase+Repair.h\"; sourceTree = \"<group>\"; };\n\t\t2314AE6F21070A1700244D39 /* Range.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = Range.cpp; sourceTree = \"<group>\"; };\n\t\t2314AE7021070A1700244D39 /* Range.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = Range.hpp; sourceTree = \"<group>\"; };\n\t\t2316D92B21057CA600707AFC /* MappedData.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = MappedData.hpp; sourceTree = \"<group>\"; };\n\t\t2316D92D21057CA700707AFC /* Recyclable.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = Recyclable.hpp; sourceTree = \"<group>\"; };\n\t\t2316D92E21057CA700707AFC /* MappedData.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MappedData.cpp; sourceTree = \"<group>\"; };\n\t\t2316D93521058B5500707AFC /* WCTFileManager.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = WCTFileManager.mm; sourceTree = \"<group>\"; };\n\t\t2316D9412105D19500707AFC /* PageBasedFileHandle.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = PageBasedFileHandle.cpp; sourceTree = \"<group>\"; };\n\t\t2316D9422105D19500707AFC /* PageBasedFileHandle.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = PageBasedFileHandle.hpp; sourceTree = \"<group>\"; };\n\t\t2316D9482105D21500707AFC /* LRUCache.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = LRUCache.hpp; sourceTree = \"<group>\"; };\n\t\t23176A8B21B912B10051ACF9 /* WCDBVersion.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WCDBVersion.h; sourceTree = \"<group>\"; };\n\t\t23176A9921BA7D460051ACF9 /* WCTDatabase+Version.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = \"WCTDatabase+Version.h\"; sourceTree = \"<group>\"; };\n\t\t23176A9A21BA7D460051ACF9 /* WCTDatabase+Version.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = \"WCTDatabase+Version.mm\"; sourceTree = \"<group>\"; };\n\t\t231C35EA21DE090500B5D3D2 /* Exiting.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = Exiting.hpp; sourceTree = \"<group>\"; };\n\t\t231C35EC21DE09E400B5D3D2 /* Exiting.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = Exiting.cpp; sourceTree = \"<group>\"; };\n\t\t2327414E1F6FBD50004E96F7 /* WCTDatabase+FTS.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = \"WCTDatabase+FTS.h\"; sourceTree = \"<group>\"; };\n\t\t2327414F1F6FBD50004E96F7 /* WCTDatabase+FTS.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = \"WCTDatabase+FTS.mm\"; sourceTree = \"<group>\"; };\n\t\t2327BC21220944D80078A85B /* Config.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = Config.cpp; sourceTree = \"<group>\"; };\n\t\t232C6F00229C0A280046742F /* WCTOperationQueue.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = WCTOperationQueue.mm; sourceTree = \"<group>\"; };\n\t\t23301BF32298FE9A00A8AB5A /* AutoMigrateConfig.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = AutoMigrateConfig.cpp; sourceTree = \"<group>\"; };\n\t\t23301BF42298FE9A00A8AB5A /* AutoMigrateConfig.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = AutoMigrateConfig.hpp; sourceTree = \"<group>\"; };\n\t\t23301BF9229A851800A8AB5A /* AutoBackupConfig.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = AutoBackupConfig.hpp; sourceTree = \"<group>\"; };\n\t\t23301BFA229A851800A8AB5A /* AutoBackupConfig.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AutoBackupConfig.cpp; sourceTree = \"<group>\"; };\n\t\t233A05892062698E00F1A212 /* WCTHandle+ChainCall.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = \"WCTHandle+ChainCall.h\"; sourceTree = \"<group>\"; };\n\t\t233A058A2062698E00F1A212 /* WCTHandle+ChainCall.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = \"WCTHandle+ChainCall.mm\"; sourceTree = \"<group>\"; };\n\t\t233A25D2219933D800054EC4 /* WCTBuiltin.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WCTBuiltin.h; sourceTree = \"<group>\"; };\n\t\t233A8530215E7CFE00BB8D4F /* Console.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = Console.cpp; sourceTree = \"<group>\"; };\n\t\t233A8531215E7CFE00BB8D4F /* Console.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = Console.hpp; sourceTree = \"<group>\"; };\n\t\t23408F0D211897AA0071E5A7 /* Shm.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = Shm.cpp; sourceTree = \"<group>\"; };\n\t\t23408F0E211897AA0071E5A7 /* Shm.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = Shm.hpp; sourceTree = \"<group>\"; };\n\t\t234591F5204432E400DC7D34 /* CommonCore.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = CommonCore.hpp; sourceTree = \"<group>\"; };\n\t\t2347378D21CBB3A800AD5E41 /* AbstractHandle.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = AbstractHandle.cpp; sourceTree = \"<group>\"; };\n\t\t2347378E21CBB3A800AD5E41 /* AbstractHandle.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = AbstractHandle.hpp; sourceTree = \"<group>\"; };\n\t\t2349F61B1EA0D6680021EFA7 /* InnerDatabase.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InnerDatabase.cpp; sourceTree = \"<group>\"; };\n\t\t2349F61C1EA0D6680021EFA7 /* InnerDatabase.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = InnerDatabase.hpp; sourceTree = \"<group>\"; };\n\t\t2349F6221EA0D6680021EFA7 /* HandlePool.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = HandlePool.cpp; sourceTree = \"<group>\"; };\n\t\t2349F6231EA0D6680021EFA7 /* HandlePool.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = HandlePool.hpp; sourceTree = \"<group>\"; };\n\t\t2349F6241EA0D6680021EFA7 /* RecyclableHandle.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RecyclableHandle.cpp; sourceTree = \"<group>\"; };\n\t\t2349F6251EA0D6680021EFA7 /* RecyclableHandle.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = RecyclableHandle.hpp; sourceTree = \"<group>\"; };\n\t\t2349F6401EA0D6680021EFA7 /* WCTDelete.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WCTDelete.h; sourceTree = \"<group>\"; };\n\t\t2349F6411EA0D6680021EFA7 /* WCTDelete.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WCTDelete.mm; sourceTree = \"<group>\"; };\n\t\t2349F6431EA0D6680021EFA7 /* WCTInsert.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WCTInsert.h; sourceTree = \"<group>\"; };\n\t\t2349F6441EA0D6680021EFA7 /* WCTInsert.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WCTInsert.mm; sourceTree = \"<group>\"; };\n\t\t2349F6471EA0D6680021EFA7 /* WCTMultiSelect.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WCTMultiSelect.h; sourceTree = \"<group>\"; };\n\t\t2349F6481EA0D6680021EFA7 /* WCTMultiSelect.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WCTMultiSelect.mm; sourceTree = \"<group>\"; };\n\t\t2349F64C1EA0D6680021EFA7 /* WCTSelect.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WCTSelect.h; sourceTree = \"<group>\"; };\n\t\t2349F64D1EA0D6680021EFA7 /* WCTSelect.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WCTSelect.mm; sourceTree = \"<group>\"; };\n\t\t2349F64E1EA0D6680021EFA7 /* WCTSelectable+Private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = \"WCTSelectable+Private.h\"; sourceTree = \"<group>\"; };\n\t\t2349F64F1EA0D6680021EFA7 /* WCTSelectable.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WCTSelectable.h; sourceTree = \"<group>\"; };\n\t\t2349F6501EA0D6680021EFA7 /* WCTSelectable.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WCTSelectable.mm; sourceTree = \"<group>\"; };\n\t\t2349F6511EA0D6680021EFA7 /* WCTTable+ChainCall.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = \"WCTTable+ChainCall.h\"; sourceTree = \"<group>\"; };\n\t\t2349F6521EA0D6680021EFA7 /* WCTTable+ChainCall.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = \"WCTTable+ChainCall.mm\"; sourceTree = \"<group>\"; };\n\t\t2349F6541EA0D6680021EFA7 /* WCTUpdate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WCTUpdate.h; sourceTree = \"<group>\"; };\n\t\t2349F6551EA0D6680021EFA7 /* WCTUpdate.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WCTUpdate.mm; sourceTree = \"<group>\"; };\n\t\t2349F6571EA0D6680021EFA7 /* WCTDatabase+Convenient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = \"WCTDatabase+Convenient.h\"; sourceTree = \"<group>\"; };\n\t\t2349F6581EA0D6680021EFA7 /* WCTDatabase+Convenient.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = \"WCTDatabase+Convenient.mm\"; sourceTree = \"<group>\"; };\n\t\t2349F6591EA0D6680021EFA7 /* WCTTable+Convenient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = \"WCTTable+Convenient.h\"; sourceTree = \"<group>\"; };\n\t\t2349F65A1EA0D6680021EFA7 /* WCTTable+Convenient.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = \"WCTTable+Convenient.mm\"; sourceTree = \"<group>\"; };\n\t\t2349F66B1EA0D6680021EFA7 /* WCTDatabase+File.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = \"WCTDatabase+File.h\"; sourceTree = \"<group>\"; };\n\t\t2349F66C1EA0D6680021EFA7 /* WCTDatabase+File.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = \"WCTDatabase+File.mm\"; sourceTree = \"<group>\"; };\n\t\t2349F66F1EA0D6680021EFA7 /* WCTDatabase+Repair.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = \"WCTDatabase+Repair.mm\"; sourceTree = \"<group>\"; };\n\t\t2349F67B1EA0D6680021EFA7 /* WCTBaseAccessor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WCTBaseAccessor.h; sourceTree = \"<group>\"; };\n\t\t2349F67C1EA0D6680021EFA7 /* WCTCppAccessor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WCTCppAccessor.h; sourceTree = \"<group>\"; };\n\t\t2349F67D1EA0D6680021EFA7 /* WCTObjCAccessor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WCTObjCAccessor.h; sourceTree = \"<group>\"; };\n\t\t2349F67E1EA0D6680021EFA7 /* WCTRuntimeBaseAccessor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WCTRuntimeBaseAccessor.h; sourceTree = \"<group>\"; };\n\t\t2349F67F1EA0D6680021EFA7 /* WCTRuntimeBaseAccessor.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WCTRuntimeBaseAccessor.mm; sourceTree = \"<group>\"; };\n\t\t2349F6801EA0D6680021EFA7 /* WCTRuntimeCppAccessor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WCTRuntimeCppAccessor.h; sourceTree = \"<group>\"; };\n\t\t2349F6811EA0D6680021EFA7 /* WCTRuntimeObjCAccessor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WCTRuntimeObjCAccessor.h; sourceTree = \"<group>\"; };\n\t\t2349F6821EA0D6680021EFA7 /* WCTRuntimeObjCAccessor.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WCTRuntimeObjCAccessor.mm; sourceTree = \"<group>\"; };\n\t\t2349F6841EA0D6680021EFA7 /* WCTBinding.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WCTBinding.h; sourceTree = \"<group>\"; };\n\t\t2349F6851EA0D6680021EFA7 /* WCTBinding.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WCTBinding.mm; sourceTree = \"<group>\"; };\n\t\t2349F6861EA0D6680021EFA7 /* WCTColumnBinding.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WCTColumnBinding.h; sourceTree = \"<group>\"; };\n\t\t2349F6871EA0D6680021EFA7 /* WCTColumnBinding.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WCTColumnBinding.mm; sourceTree = \"<group>\"; };\n\t\t2349F68D1EA0D6680021EFA7 /* WCTTableCoding.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WCTTableCoding.h; sourceTree = \"<group>\"; };\n\t\t2349F6901EA0D6680021EFA7 /* WCTProperty.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WCTProperty.h; sourceTree = \"<group>\"; };\n\t\t2349F6911EA0D6680021EFA7 /* WCTProperty.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WCTProperty.mm; sourceTree = \"<group>\"; };\n\t\t2349F6931EA0D6680021EFA7 /* WCTMacro.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WCTMacro.h; sourceTree = \"<group>\"; };\n\t\t2349F6941EA0D6680021EFA7 /* WCTPropertyMacro.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WCTPropertyMacro.h; sourceTree = \"<group>\"; };\n\t\t2349F6951EA0D6680021EFA7 /* WCTTableConstraintMacro.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WCTTableConstraintMacro.h; sourceTree = \"<group>\"; };\n\t\t2349F6961EA0D6680021EFA7 /* WCTIndexMacro.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WCTIndexMacro.h; sourceTree = \"<group>\"; };\n\t\t2349F6981EA0D6680021EFA7 /* WCTORM.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WCTORM.h; sourceTree = \"<group>\"; };\n\t\t2349F69A1EA0D6680021EFA7 /* WCTDatabase+Table.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = \"WCTDatabase+Table.h\"; sourceTree = \"<group>\"; };\n\t\t2349F69B1EA0D6680021EFA7 /* WCTDatabase+Table.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = \"WCTDatabase+Table.mm\"; sourceTree = \"<group>\"; };\n\t\t2349F69E1EA0D6680021EFA7 /* WCTTable+Private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = \"WCTTable+Private.h\"; sourceTree = \"<group>\"; };\n\t\t2349F6BA1EA0D6680021EFA7 /* WCDBObjc.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WCDBObjc.h; sourceTree = \"<group>\"; };\n\t\t234DBCEC2064DD0B000E31E8 /* WCTDatabase+Handle.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = \"WCTDatabase+Handle.h\"; sourceTree = \"<group>\"; };\n\t\t234DBCED2064DD0B000E31E8 /* WCTDatabase+Handle.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = \"WCTDatabase+Handle.mm\"; sourceTree = \"<group>\"; };\n\t\t234DBCF02064DD0B000E31E8 /* WCTHandle+Private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = \"WCTHandle+Private.h\"; sourceTree = \"<group>\"; };\n\t\t234DBCF12064DD0B000E31E8 /* WCTHandle.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WCTHandle.h; sourceTree = \"<group>\"; };\n\t\t234DBCF22064DD0B000E31E8 /* WCTHandle.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WCTHandle.mm; sourceTree = \"<group>\"; };\n\t\t234DBCFF2064DE04000E31E8 /* WCTDatabase+Transaction.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = \"WCTDatabase+Transaction.h\"; sourceTree = \"<group>\"; };\n\t\t234DBD002064DE04000E31E8 /* WCTDatabase+Transaction.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = \"WCTDatabase+Transaction.mm\"; sourceTree = \"<group>\"; };\n\t\t234DBD012064DE04000E31E8 /* WCTHandle+Transaction.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = \"WCTHandle+Transaction.h\"; sourceTree = \"<group>\"; };\n\t\t234DBD022064DE04000E31E8 /* WCTHandle+Transaction.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = \"WCTHandle+Transaction.mm\"; sourceTree = \"<group>\"; };\n\t\t234DBD072064DE23000E31E8 /* WCTTransaction.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WCTTransaction.h; sourceTree = \"<group>\"; };\n\t\t234DBD0B2064E045000E31E8 /* WCTChainCall.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WCTChainCall.h; sourceTree = \"<group>\"; };\n\t\t234EF46C2015CFDE00B81929 /* WCTConvertible.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WCTConvertible.h; sourceTree = \"<group>\"; };\n\t\t234EF46D2015CFDE00B81929 /* WCTConvertible.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = WCTConvertible.mm; sourceTree = \"<group>\"; };\n\t\t234F0337227A950900DD65A2 /* SQLiteFTS3Tokenizer.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SQLiteFTS3Tokenizer.h; sourceTree = \"<group>\"; };\n\t\t234F035C227A9CFE00DD65A2 /* ObjcTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = ObjcTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };\n\t\t234F0369227A9E3C00DD65A2 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = file.bplist; path = Info.plist; sourceTree = \"<group>\"; };\n\t\t234F036A227A9E3C00DD65A2 /* Debug.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Debug.xcconfig; sourceTree = \"<group>\"; };\n\t\t234F036C227A9E3D00DD65A2 /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Release.xcconfig; sourceTree = \"<group>\"; };\n\t\t234F036D227A9E3D00DD65A2 /* Base.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Base.xcconfig; sourceTree = \"<group>\"; };\n\t\t234F036E227A9E3D00DD65A2 /* WCDB.modulemap */ = {isa = PBXFileReference; lastKnownFileType = \"sourcecode.module-map\"; path = WCDB.modulemap; sourceTree = \"<group>\"; };\n\t\t234F0370227A9E3D00DD65A2 /* WCDBWithoutCompression.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = WCDBWithoutCompression.xcconfig; sourceTree = \"<group>\"; };\n\t\t234F0388227A9EFA00DD65A2 /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = \"<group>\"; };\n\t\t234F0389227A9EFA00DD65A2 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = file.bplist; path = Info.plist; sourceTree = \"<group>\"; };\n\t\t234F038B227A9EFA00DD65A2 /* ConfigTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ConfigTests.mm; sourceTree = \"<group>\"; };\n\t\t234F03D9227A9EFA00DD65A2 /* HandleTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = HandleTests.mm; sourceTree = \"<group>\"; };\n\t\t234F03F6227A9EFA00DD65A2 /* MultiSelectTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MultiSelectTests.mm; sourceTree = \"<group>\"; };\n\t\t234F03F7227A9EFA00DD65A2 /* ChainCallTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ChainCallTests.mm; sourceTree = \"<group>\"; };\n\t\t234F042F227A9EFA00DD65A2 /* Tests.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Tests.xcconfig; sourceTree = \"<group>\"; };\n\t\t234F0445227A9EFA00DD65A2 /* ORMTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ORMTests.mm; sourceTree = \"<group>\"; };\n\t\t234F057A227AA4CB00DD65A2 /* BaselineBenchmark.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = BaselineBenchmark.mm; sourceTree = \"<group>\"; };\n\t\t234F057B227AA4CB00DD65A2 /* ObjectsBasedBenchmark.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ObjectsBasedBenchmark.h; sourceTree = \"<group>\"; };\n\t\t234F057F227AA4CC00DD65A2 /* ObjectsBasedBenchmark.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ObjectsBasedBenchmark.mm; sourceTree = \"<group>\"; };\n\t\t234F0580227AA4CC00DD65A2 /* CipherBenchmark.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = CipherBenchmark.mm; sourceTree = \"<group>\"; };\n\t\t234F058B227AA4D700DD65A2 /* VersionTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = VersionTests.mm; sourceTree = \"<group>\"; };\n\t\t234F058C227AA4D700DD65A2 /* TraceTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = TraceTests.mm; sourceTree = \"<group>\"; };\n\t\t234F058F227AA4E100DD65A2 /* DatabaseTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = DatabaseTests.mm; sourceTree = \"<group>\"; };\n\t\t234F0590227AA4E100DD65A2 /* ObservationTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ObservationTests.mm; sourceTree = \"<group>\"; };\n\t\t234F0591227AA4E200DD65A2 /* FileTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = FileTests.mm; sourceTree = \"<group>\"; };\n\t\t234F0593227AA4E200DD65A2 /* TableTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = TableTests.mm; sourceTree = \"<group>\"; };\n\t\t234F0599227AA4EC00DD65A2 /* StatementAlterTableTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = StatementAlterTableTests.mm; sourceTree = \"<group>\"; };\n\t\t234F059A227AA4ED00DD65A2 /* FrameSpecTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = FrameSpecTests.mm; sourceTree = \"<group>\"; };\n\t\t234F059B227AA4ED00DD65A2 /* FTSFunctionTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = FTSFunctionTests.mm; sourceTree = \"<group>\"; };\n\t\t234F059C227AA4ED00DD65A2 /* StatementTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = StatementTests.mm; sourceTree = \"<group>\"; };\n\t\t234F059D227AA4ED00DD65A2 /* StatementPragmaTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = StatementPragmaTests.mm; sourceTree = \"<group>\"; };\n\t\t234F059E227AA4ED00DD65A2 /* ColumnConstraintTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ColumnConstraintTests.mm; sourceTree = \"<group>\"; };\n\t\t234F05A1227AA4ED00DD65A2 /* StatementDeleteTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = StatementDeleteTests.mm; sourceTree = \"<group>\"; };\n\t\t234F05A3227AA4EE00DD65A2 /* CoreFunctionTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = CoreFunctionTests.mm; sourceTree = \"<group>\"; };\n\t\t234F05A4227AA4EE00DD65A2 /* StatementReleaseTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = StatementReleaseTests.mm; sourceTree = \"<group>\"; };\n\t\t234F05A5227AA4EE00DD65A2 /* UpsertTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = UpsertTests.mm; sourceTree = \"<group>\"; };\n\t\t234F05A6227AA4EE00DD65A2 /* OrderingTermTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = OrderingTermTests.mm; sourceTree = \"<group>\"; };\n\t\t234F05A7227AA4EE00DD65A2 /* BindParameterTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = BindParameterTests.mm; sourceTree = \"<group>\"; };\n\t\t234F05A8227AA4EE00DD65A2 /* ConflictTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ConflictTests.mm; sourceTree = \"<group>\"; };\n\t\t234F05A9227AA4EF00DD65A2 /* WCTResultColumnTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WCTResultColumnTests.mm; sourceTree = \"<group>\"; };\n\t\t234F05AA227AA4EF00DD65A2 /* StatementSavepointTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = StatementSavepointTests.mm; sourceTree = \"<group>\"; };\n\t\t234F05AB227AA4EF00DD65A2 /* JoinConstraintTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = JoinConstraintTests.mm; sourceTree = \"<group>\"; };\n\t\t234F05AC227AA4EF00DD65A2 /* TableOrSubqueryTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = TableOrSubqueryTests.mm; sourceTree = \"<group>\"; };\n\t\t234F05AD227AA4EF00DD65A2 /* StatementCreateVirtualTableTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = StatementCreateVirtualTableTests.mm; sourceTree = \"<group>\"; };\n\t\t234F05AE227AA4EF00DD65A2 /* WINQAssertion.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WINQAssertion.mm; sourceTree = \"<group>\"; };\n\t\t234F05AF227AA4EF00DD65A2 /* ExpressionTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ExpressionTests.mm; sourceTree = \"<group>\"; };\n\t\t234F05B0227AA4EF00DD65A2 /* IndexedColumnTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = IndexedColumnTests.mm; sourceTree = \"<group>\"; };\n\t\t234F05B1227AA4F000DD65A2 /* ExpressionOperableTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ExpressionOperableTests.mm; sourceTree = \"<group>\"; };\n\t\t234F05B2227AA4F000DD65A2 /* StatementCreateTriggerTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = StatementCreateTriggerTests.mm; sourceTree = \"<group>\"; };\n\t\t234F05B3227AA4F000DD65A2 /* StatementCreateTableTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = StatementCreateTableTests.mm; sourceTree = \"<group>\"; };\n\t\t234F05B4227AA4F000DD65A2 /* ColumnTypeTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ColumnTypeTests.mm; sourceTree = \"<group>\"; };\n\t\t234F05B5227AA4F000DD65A2 /* StatementDetachTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = StatementDetachTests.mm; sourceTree = \"<group>\"; };\n\t\t234F05B6227AA4F000DD65A2 /* StatementAnalyzeTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = StatementAnalyzeTests.mm; sourceTree = \"<group>\"; };\n\t\t234F05B7227AA4F100DD65A2 /* StatementVacuumTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = StatementVacuumTests.mm; sourceTree = \"<group>\"; };\n\t\t234F05B8227AA4F100DD65A2 /* RaiseFunctionTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = RaiseFunctionTests.mm; sourceTree = \"<group>\"; };\n\t\t234F05B9227AA4F100DD65A2 /* ForeignKeyTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ForeignKeyTests.mm; sourceTree = \"<group>\"; };\n\t\t234F05BA227AA4F100DD65A2 /* WINQAssertion.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WINQAssertion.h; sourceTree = \"<group>\"; };\n\t\t234F05BB227AA4F100DD65A2 /* ColumnOperableTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ColumnOperableTests.mm; sourceTree = \"<group>\"; };\n\t\t234F05BC227AA4F100DD65A2 /* StatementBeginTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = StatementBeginTests.mm; sourceTree = \"<group>\"; };\n\t\t234F05BD227AA4F100DD65A2 /* SchemaTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = SchemaTests.mm; sourceTree = \"<group>\"; };\n\t\t234F05BE227AA4F200DD65A2 /* StatementReindexTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = StatementReindexTests.mm; sourceTree = \"<group>\"; };\n\t\t234F05BF227AA4F200DD65A2 /* FilterTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = FilterTests.mm; sourceTree = \"<group>\"; };\n\t\t234F05C0227AA4F200DD65A2 /* StatementSelectTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = StatementSelectTests.mm; sourceTree = \"<group>\"; };\n\t\t234F05C1227AA4F200DD65A2 /* StatementDropViewTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = StatementDropViewTests.mm; sourceTree = \"<group>\"; };\n\t\t234F05C2227AA4F200DD65A2 /* StoppableIterationTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = StoppableIterationTests.mm; sourceTree = \"<group>\"; };\n\t\t234F05C3227AA4F200DD65A2 /* ColumnDefTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ColumnDefTests.mm; sourceTree = \"<group>\"; };\n\t\t234F05C4227AA4F200DD65A2 /* StatementDropIndexTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = StatementDropIndexTests.mm; sourceTree = \"<group>\"; };\n\t\t234F05C5227AA4F300DD65A2 /* StatementAttachTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = StatementAttachTests.mm; sourceTree = \"<group>\"; };\n\t\t234F05C6227AA4F300DD65A2 /* StatementCreateIndexTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = StatementCreateIndexTests.mm; sourceTree = \"<group>\"; };\n\t\t234F05C7227AA4F300DD65A2 /* StatementUpdateTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = StatementUpdateTests.mm; sourceTree = \"<group>\"; };\n\t\t234F05C8227AA4F300DD65A2 /* AggregateFunctionTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = AggregateFunctionTests.mm; sourceTree = \"<group>\"; };\n\t\t234F05C9227AA4F300DD65A2 /* StatementCommitTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = StatementCommitTests.mm; sourceTree = \"<group>\"; };\n\t\t234F05CA227AA4F300DD65A2 /* WindowDefTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WindowDefTests.mm; sourceTree = \"<group>\"; };\n\t\t234F05CB227AA4F300DD65A2 /* LiteralValueTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = LiteralValueTests.mm; sourceTree = \"<group>\"; };\n\t\t234F05CC227AA4F400DD65A2 /* StatementCreateViewTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = StatementCreateViewTests.mm; sourceTree = \"<group>\"; };\n\t\t234F05CD227AA4F400DD65A2 /* SyntaxListTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = SyntaxListTests.mm; sourceTree = \"<group>\"; };\n\t\t234F05CE227AA4F400DD65A2 /* CommonTableExpressionTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = CommonTableExpressionTests.mm; sourceTree = \"<group>\"; };\n\t\t234F05CF227AA4F400DD65A2 /* StatementDropTableTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = StatementDropTableTests.mm; sourceTree = \"<group>\"; };\n\t\t234F05D0227AA4F400DD65A2 /* WCTPropertyTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WCTPropertyTests.mm; sourceTree = \"<group>\"; };\n\t\t234F05D2227AA4F400DD65A2 /* ColumnTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ColumnTests.mm; sourceTree = \"<group>\"; };\n\t\t234F05D4227AA4F500DD65A2 /* JoinTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = JoinTests.mm; sourceTree = \"<group>\"; };\n\t\t234F05D5227AA4F500DD65A2 /* StatementInsertTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = StatementInsertTests.mm; sourceTree = \"<group>\"; };\n\t\t234F05D6227AA4F500DD65A2 /* OrderTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = OrderTests.mm; sourceTree = \"<group>\"; };\n\t\t234F05D7227AA4F500DD65A2 /* QualifiedTableTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = QualifiedTableTests.mm; sourceTree = \"<group>\"; };\n\t\t234F05D8227AA4F500DD65A2 /* StatementRollbackTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = StatementRollbackTests.mm; sourceTree = \"<group>\"; };\n\t\t234F05D9227AA4F600DD65A2 /* ResultColumnTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ResultColumnTests.mm; sourceTree = \"<group>\"; };\n\t\t234F05DA227AA4F600DD65A2 /* StatementDropTriggerTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = StatementDropTriggerTests.mm; sourceTree = \"<group>\"; };\n\t\t234F05DB227AA4F600DD65A2 /* TableConstraintTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = TableConstraintTests.mm; sourceTree = \"<group>\"; };\n\t\t234F05DC227AA4F600DD65A2 /* PragmaTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = PragmaTests.mm; sourceTree = \"<group>\"; };\n\t\t234F0621227AA50400DD65A2 /* IntegerCodingObject.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = IntegerCodingObject.m; sourceTree = \"<group>\"; };\n\t\t234F0622227AA50400DD65A2 /* ColumnCodingObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ColumnCodingObject.h; sourceTree = \"<group>\"; };\n\t\t234F0623227AA50500DD65A2 /* IntegerCodingObject+WCTColumnCoding.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = \"IntegerCodingObject+WCTColumnCoding.mm\"; sourceTree = \"<group>\"; };\n\t\t234F0625227AA50500DD65A2 /* ColumnCodingObject.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ColumnCodingObject.mm; sourceTree = \"<group>\"; };\n\t\t234F0626227AA50500DD65A2 /* StringCodingObject+WCTColumnCoding.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = \"StringCodingObject+WCTColumnCoding.mm\"; sourceTree = \"<group>\"; };\n\t\t234F0627227AA50500DD65A2 /* ColumnCodingObject+WCTTableCoding.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = \"ColumnCodingObject+WCTTableCoding.h\"; sourceTree = \"<group>\"; };\n\t\t234F0628227AA50500DD65A2 /* DataCodingObject+WCTColumnCoding.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = \"DataCodingObject+WCTColumnCoding.h\"; sourceTree = \"<group>\"; };\n\t\t234F0629227AA50500DD65A2 /* DoubleCodingObject+WCTColumnCoding.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = \"DoubleCodingObject+WCTColumnCoding.h\"; sourceTree = \"<group>\"; };\n\t\t234F062A227AA50500DD65A2 /* Random+ColumnCodingObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = \"Random+ColumnCodingObject.h\"; sourceTree = \"<group>\"; };\n\t\t234F062B227AA50600DD65A2 /* StringCodingObject+WCTColumnCoding.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = \"StringCodingObject+WCTColumnCoding.h\"; sourceTree = \"<group>\"; };\n\t\t234F062C227AA50600DD65A2 /* StringCodingObject.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = StringCodingObject.m; sourceTree = \"<group>\"; };\n\t\t234F062D227AA50600DD65A2 /* IntegerCodingObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IntegerCodingObject.h; sourceTree = \"<group>\"; };\n\t\t234F062E227AA50600DD65A2 /* ColumnCodingTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ColumnCodingTests.mm; sourceTree = \"<group>\"; };\n\t\t234F062F227AA50600DD65A2 /* DoubleCodingObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DoubleCodingObject.h; sourceTree = \"<group>\"; };\n\t\t234F0630227AA50600DD65A2 /* DoubleCodingObject+WCTColumnCoding.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = \"DoubleCodingObject+WCTColumnCoding.mm\"; sourceTree = \"<group>\"; };\n\t\t234F0631227AA50700DD65A2 /* DoubleCodingObject.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DoubleCodingObject.m; sourceTree = \"<group>\"; };\n\t\t234F0632227AA50700DD65A2 /* DataCodingObject.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DataCodingObject.m; sourceTree = \"<group>\"; };\n\t\t234F0634227AA50700DD65A2 /* DataCodingObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DataCodingObject.h; sourceTree = \"<group>\"; };\n\t\t234F0635227AA50700DD65A2 /* StringCodingObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StringCodingObject.h; sourceTree = \"<group>\"; };\n\t\t234F0637227AA50700DD65A2 /* IntegerCodingObject+WCTColumnCoding.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = \"IntegerCodingObject+WCTColumnCoding.h\"; sourceTree = \"<group>\"; };\n\t\t234F0638227AA50800DD65A2 /* DataCodingObject+WCTColumnCoding.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = \"DataCodingObject+WCTColumnCoding.mm\"; sourceTree = \"<group>\"; };\n\t\t234F0639227AA50800DD65A2 /* Random+ColumnCodingObject.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = \"Random+ColumnCodingObject.mm\"; sourceTree = \"<group>\"; };\n\t\t234F0647227AA51400DD65A2 /* FTS3Object.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FTS3Object.h; sourceTree = \"<group>\"; };\n\t\t234F0648227AA51500DD65A2 /* FTS3Object+WCTTableCoding.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = \"FTS3Object+WCTTableCoding.h\"; sourceTree = \"<group>\"; };\n\t\t234F0649227AA51500DD65A2 /* FTS3Tests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = FTS3Tests.mm; sourceTree = \"<group>\"; };\n\t\t234F064A227AA51500DD65A2 /* FTS3Object.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = FTS3Object.mm; sourceTree = \"<group>\"; };\n\t\t234F06A3227AA55400DD65A2 /* AdditionalORMObject+WCTTableCoding.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = \"AdditionalORMObject+WCTTableCoding.h\"; sourceTree = \"<group>\"; };\n\t\t234F06A4227AA55400DD65A2 /* AdditionalORMObject.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = AdditionalORMObject.mm; sourceTree = \"<group>\"; };\n\t\t234F06A5227AA55400DD65A2 /* AdditionalORMObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AdditionalORMObject.h; sourceTree = \"<group>\"; };\n\t\t234F06A7227AA56200DD65A2 /* VirtualTableFTS5Object.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VirtualTableFTS5Object.h; sourceTree = \"<group>\"; };\n\t\t234F06A8227AA56300DD65A2 /* VirtualTableFTS4Object+WCTTableCoding.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = \"VirtualTableFTS4Object+WCTTableCoding.h\"; sourceTree = \"<group>\"; };\n\t\t234F06A9227AA56300DD65A2 /* VirtualTableFTS5Object.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = VirtualTableFTS5Object.mm; sourceTree = \"<group>\"; };\n\t\t234F06AA227AA56300DD65A2 /* VirtualTableFTS5Object+WCTTableCoding.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = \"VirtualTableFTS5Object+WCTTableCoding.h\"; sourceTree = \"<group>\"; };\n\t\t234F06AB227AA56300DD65A2 /* VirtualTableFTS4Object.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = VirtualTableFTS4Object.mm; sourceTree = \"<group>\"; };\n\t\t234F06AC227AA56300DD65A2 /* VirtualTableFTS4Object.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VirtualTableFTS4Object.h; sourceTree = \"<group>\"; };\n\t\t234F06AF227AA56B00DD65A2 /* TableConstraintObject+WCTTableCoding.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = \"TableConstraintObject+WCTTableCoding.h\"; sourceTree = \"<group>\"; };\n\t\t234F06B0227AA56B00DD65A2 /* TableConstraintObject.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = TableConstraintObject.mm; sourceTree = \"<group>\"; };\n\t\t234F06B1227AA56B00DD65A2 /* TableConstraintObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TableConstraintObject.h; sourceTree = \"<group>\"; };\n\t\t234F06B3227AA57100DD65A2 /* PropertyObject+WCTTableCoding.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = \"PropertyObject+WCTTableCoding.h\"; sourceTree = \"<group>\"; };\n\t\t234F06B4227AA57100DD65A2 /* PropertyObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PropertyObject.h; sourceTree = \"<group>\"; };\n\t\t234F06B5227AA57100DD65A2 /* PropertyObject.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = PropertyObject.mm; sourceTree = \"<group>\"; };\n\t\t234F06B7227AA57A00DD65A2 /* ColumnConstraintDefault+WCTTableCoding.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = \"ColumnConstraintDefault+WCTTableCoding.h\"; sourceTree = \"<group>\"; };\n\t\t234F06B8227AA57A00DD65A2 /* ColumnConstraintAutoIncrement.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ColumnConstraintAutoIncrement.mm; sourceTree = \"<group>\"; };\n\t\t234F06B9227AA57A00DD65A2 /* ColumnConstraintAutoIncrementAsc+WCTTableCoding.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = \"ColumnConstraintAutoIncrementAsc+WCTTableCoding.h\"; sourceTree = \"<group>\"; };\n\t\t234F06BA227AA57A00DD65A2 /* ColumnConstraintNotNull.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ColumnConstraintNotNull.mm; sourceTree = \"<group>\"; };\n\t\t234F06BB227AA57A00DD65A2 /* ColumnConstraintUnique.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ColumnConstraintUnique.h; sourceTree = \"<group>\"; };\n\t\t234F06BC227AA57A00DD65A2 /* ColumnConstraintPrimaryAsc+WCTTableCoding.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = \"ColumnConstraintPrimaryAsc+WCTTableCoding.h\"; sourceTree = \"<group>\"; };\n\t\t234F06BD227AA57B00DD65A2 /* ColumnConstraintPrimaryAsc.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ColumnConstraintPrimaryAsc.mm; sourceTree = \"<group>\"; };\n\t\t234F06BE227AA57B00DD65A2 /* ColumnConstraintAutoIncrementAsc.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ColumnConstraintAutoIncrementAsc.mm; sourceTree = \"<group>\"; };\n\t\t234F06BF227AA57B00DD65A2 /* ColumnConstraintCheck.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ColumnConstraintCheck.mm; sourceTree = \"<group>\"; };\n\t\t234F06C0227AA57B00DD65A2 /* ColumnConstraintAutoIncrementAsc.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ColumnConstraintAutoIncrementAsc.h; sourceTree = \"<group>\"; };\n\t\t234F06C1227AA57B00DD65A2 /* ColumnConstraintCheck.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ColumnConstraintCheck.h; sourceTree = \"<group>\"; };\n\t\t234F06C2227AA57B00DD65A2 /* ColumnConstraintPrimaryDesc.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ColumnConstraintPrimaryDesc.h; sourceTree = \"<group>\"; };\n\t\t234F06C3227AA57B00DD65A2 /* ColumnConstraintAutoIncrement+WCTTableCoding.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = \"ColumnConstraintAutoIncrement+WCTTableCoding.h\"; sourceTree = \"<group>\"; };\n\t\t234F06C4227AA57B00DD65A2 /* ColumnConstraintPrimary+WCTTableCoding.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = \"ColumnConstraintPrimary+WCTTableCoding.h\"; sourceTree = \"<group>\"; };\n\t\t234F06C5227AA57B00DD65A2 /* ColumnConstraintPrimaryDesc.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ColumnConstraintPrimaryDesc.mm; sourceTree = \"<group>\"; };\n\t\t234F06C6227AA57C00DD65A2 /* ColumnConstraintPrimary.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ColumnConstraintPrimary.mm; sourceTree = \"<group>\"; };\n\t\t234F06C7227AA57C00DD65A2 /* ColumnConstraintNotNull+WCTTableCoding.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = \"ColumnConstraintNotNull+WCTTableCoding.h\"; sourceTree = \"<group>\"; };\n\t\t234F06C8227AA57C00DD65A2 /* ColumnConstraintPrimaryAsc.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ColumnConstraintPrimaryAsc.h; sourceTree = \"<group>\"; };\n\t\t234F06C9227AA57C00DD65A2 /* ColumnConstraintNotNull.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ColumnConstraintNotNull.h; sourceTree = \"<group>\"; };\n\t\t234F06CA227AA57C00DD65A2 /* ColumnConstraintDefault.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ColumnConstraintDefault.mm; sourceTree = \"<group>\"; };\n\t\t234F06CB227AA57C00DD65A2 /* ColumnConstraintPrimaryDesc+WCTTableCoding.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = \"ColumnConstraintPrimaryDesc+WCTTableCoding.h\"; sourceTree = \"<group>\"; };\n\t\t234F06CC227AA57D00DD65A2 /* ColumnConstraintPrimary.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ColumnConstraintPrimary.h; sourceTree = \"<group>\"; };\n\t\t234F06CD227AA57D00DD65A2 /* ColumnConstraintUnique.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ColumnConstraintUnique.mm; sourceTree = \"<group>\"; };\n\t\t234F06CE227AA57D00DD65A2 /* ColumnConstraintUnique+WCTTableCoding.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = \"ColumnConstraintUnique+WCTTableCoding.h\"; sourceTree = \"<group>\"; };\n\t\t234F06CF227AA57D00DD65A2 /* ColumnConstraintCheck+WCTTableCoding.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = \"ColumnConstraintCheck+WCTTableCoding.h\"; sourceTree = \"<group>\"; };\n\t\t234F06D0227AA57D00DD65A2 /* ColumnConstraintAutoIncrement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ColumnConstraintAutoIncrement.h; sourceTree = \"<group>\"; };\n\t\t234F06D1227AA57D00DD65A2 /* ColumnConstraintDefault.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ColumnConstraintDefault.h; sourceTree = \"<group>\"; };\n\t\t234F06DB227AA58400DD65A2 /* IndexObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IndexObject.h; sourceTree = \"<group>\"; };\n\t\t234F06DC227AA58400DD65A2 /* IndexObject.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = IndexObject.mm; sourceTree = \"<group>\"; };\n\t\t234F06DD227AA58400DD65A2 /* IndexObject+WCTTableCoding.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = \"IndexObject+WCTTableCoding.h\"; sourceTree = \"<group>\"; };\n\t\t234F06DF227AA58C00DD65A2 /* OldRemapObject.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = OldRemapObject.mm; sourceTree = \"<group>\"; };\n\t\t234F06E0227AA58C00DD65A2 /* OldRemapObject+WCTTableCoding.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = \"OldRemapObject+WCTTableCoding.h\"; sourceTree = \"<group>\"; };\n\t\t234F06E1227AA58C00DD65A2 /* NewRemapObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NewRemapObject.h; sourceTree = \"<group>\"; };\n\t\t234F06E2227AA58C00DD65A2 /* DropIndexObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DropIndexObject.h; sourceTree = \"<group>\"; };\n\t\t234F06E3227AA58D00DD65A2 /* DropIndexObject+WCTTableCoding.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = \"DropIndexObject+WCTTableCoding.h\"; sourceTree = \"<group>\"; };\n\t\t234F06E4227AA58D00DD65A2 /* OldRemapObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OldRemapObject.h; sourceTree = \"<group>\"; };\n\t\t234F06E5227AA58D00DD65A2 /* NewRemapObject+WCTTableCoding.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = \"NewRemapObject+WCTTableCoding.h\"; sourceTree = \"<group>\"; };\n\t\t234F06E6227AA58D00DD65A2 /* DropIndexObject.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = DropIndexObject.mm; sourceTree = \"<group>\"; };\n\t\t234F06E7227AA58D00DD65A2 /* NewlyCreatedTableIndexObject+WCTTableCoding.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = \"NewlyCreatedTableIndexObject+WCTTableCoding.h\"; sourceTree = \"<group>\"; };\n\t\t234F06E8227AA58D00DD65A2 /* NewlyCreatedTableIndexObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NewlyCreatedTableIndexObject.h; sourceTree = \"<group>\"; };\n\t\t234F06E9227AA58D00DD65A2 /* NewlyCreatedTableIndexObject.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = NewlyCreatedTableIndexObject.mm; sourceTree = \"<group>\"; };\n\t\t234F06EA227AA58D00DD65A2 /* NewRemapObject.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = NewRemapObject.mm; sourceTree = \"<group>\"; };\n\t\t234F06EF227AA59500DD65A2 /* ConvenientDeleteTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ConvenientDeleteTests.mm; sourceTree = \"<group>\"; };\n\t\t234F06F0227AA59500DD65A2 /* ConvenientUpdateTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ConvenientUpdateTests.mm; sourceTree = \"<group>\"; };\n\t\t234F06F1227AA59600DD65A2 /* ConvenientSelectTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ConvenientSelectTests.mm; sourceTree = \"<group>\"; };\n\t\t234F06F2227AA59600DD65A2 /* ConvenientInsertTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ConvenientInsertTests.mm; sourceTree = \"<group>\"; };\n\t\t234F06F7227AA59D00DD65A2 /* ThreadTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ThreadTests.mm; sourceTree = \"<group>\"; };\n\t\t234F06F8227AA59D00DD65A2 /* TransactionTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = TransactionTests.mm; sourceTree = \"<group>\"; };\n\t\t234F072F227AA5C600DD65A2 /* BackupTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = BackupTests.mm; sourceTree = \"<group>\"; };\n\t\t234F0730227AA5C700DD65A2 /* DepositTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = DepositTests.mm; sourceTree = \"<group>\"; };\n\t\t234F0731227AA5C700DD65A2 /* BackupTestCase.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = BackupTestCase.mm; sourceTree = \"<group>\"; };\n\t\t234F0732227AA5C700DD65A2 /* RetrieveRobustyTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = RetrieveRobustyTests.mm; sourceTree = \"<group>\"; };\n\t\t234F0733227AA5C700DD65A2 /* BackupTestCase.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BackupTestCase.h; sourceTree = \"<group>\"; };\n\t\t234F0734227AA5C700DD65A2 /* RetrieveTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = RetrieveTests.mm; sourceTree = \"<group>\"; };\n\t\t234F0753227AB18B00DD65A2 /* host.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = host.xcconfig; sourceTree = \"<group>\"; };\n\t\t234F8AD4227B0B5400791E45 /* SwiftTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = SwiftTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };\n\t\t23545B962224E8270091C981 /* SyntaxAssertion.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = SyntaxAssertion.hpp; sourceTree = \"<group>\"; };\n\t\t23545B9C2224E9C80091C981 /* SyntaxEnum.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = SyntaxEnum.hpp; sourceTree = \"<group>\"; };\n\t\t23545BA12224EAA40091C981 /* SyntaxCommonConst.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = SyntaxCommonConst.cpp; sourceTree = \"<group>\"; };\n\t\t23567CF820CA3889005F1C35 /* Frame.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = Frame.cpp; sourceTree = \"<group>\"; };\n\t\t23567CF920CA3889005F1C35 /* Frame.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = Frame.hpp; sourceTree = \"<group>\"; };\n\t\t23567D4520CA7DBC005F1C35 /* ErrorProne.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = ErrorProne.hpp; sourceTree = \"<group>\"; };\n\t\t23567D4620CA7DBC005F1C35 /* ErrorProne.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ErrorProne.cpp; sourceTree = \"<group>\"; };\n\t\t23567D5720CA823C005F1C35 /* PagerRelated.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = PagerRelated.cpp; sourceTree = \"<group>\"; };\n\t\t23567D5820CA823C005F1C35 /* PagerRelated.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = PagerRelated.hpp; sourceTree = \"<group>\"; };\n\t\t23567D7220CA91FF005F1C35 /* SharedThreadedErrorProne.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SharedThreadedErrorProne.cpp; sourceTree = \"<group>\"; };\n\t\t23567D7420CA91FF005F1C35 /* SharedThreadedErrorProne.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = SharedThreadedErrorProne.hpp; sourceTree = \"<group>\"; };\n\t\t23567D7920CA93C5005F1C35 /* Time.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = Time.cpp; sourceTree = \"<group>\"; };\n\t\t23567D7A20CA93C5005F1C35 /* Time.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = Time.hpp; sourceTree = \"<group>\"; };\n\t\t23577F771F74F4E800D31C05 /* WCTFTSTokenizerUtil.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WCTFTSTokenizerUtil.h; sourceTree = \"<group>\"; };\n\t\t23577F781F74F4E800D31C05 /* WCTFTSTokenizerUtil.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WCTFTSTokenizerUtil.mm; sourceTree = \"<group>\"; };\n\t\t23593B7B20D3ADF80058B416 /* WalRelated.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = WalRelated.cpp; sourceTree = \"<group>\"; };\n\t\t23593B7C20D3ADF80058B416 /* WalRelated.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = WalRelated.hpp; sourceTree = \"<group>\"; };\n\t\t235EE9C322B63219008F6658 /* StringView.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = StringView.hpp; sourceTree = \"<group>\"; };\n\t\t235EE9C422B6321A008F6658 /* StringView.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = StringView.cpp; sourceTree = \"<group>\"; };\n\t\t235FBE9322914E0D005C7723 /* Global.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = Global.cpp; sourceTree = \"<group>\"; };\n\t\t235FBE9422914E0D005C7723 /* Global.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = Global.hpp; sourceTree = \"<group>\"; };\n\t\t2360A5F320D78F1B00E4A311 /* HandleRelated.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = HandleRelated.cpp; sourceTree = \"<group>\"; };\n\t\t2360A5F420D78F1B00E4A311 /* HandleNotification.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = HandleNotification.cpp; sourceTree = \"<group>\"; };\n\t\t2360A5F520D78F1B00E4A311 /* HandleNotification.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = HandleNotification.hpp; sourceTree = \"<group>\"; };\n\t\t2360A5F620D78F1B00E4A311 /* HandleRelated.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = HandleRelated.hpp; sourceTree = \"<group>\"; };\n\t\t2360A5FF20D78F2B00E4A311 /* SQLTraceConfig.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SQLTraceConfig.cpp; sourceTree = \"<group>\"; };\n\t\t2360A60020D78F2B00E4A311 /* SQLTraceConfig.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = SQLTraceConfig.hpp; sourceTree = \"<group>\"; };\n\t\t2360A60120D78F2B00E4A311 /* PerformanceTraceConfig.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PerformanceTraceConfig.cpp; sourceTree = \"<group>\"; };\n\t\t2360A60220D78F2B00E4A311 /* PerformanceTraceConfig.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = PerformanceTraceConfig.hpp; sourceTree = \"<group>\"; };\n\t\t236996B121D5C4FF00E72E81 /* Recyclable.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = Recyclable.cpp; sourceTree = \"<group>\"; };\n\t\t236BACE021BF9F6400C8B4D9 /* WCTDatabase+Migration.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = \"WCTDatabase+Migration.h\"; sourceTree = \"<group>\"; };\n\t\t236BACE121BF9F6400C8B4D9 /* WCTDatabase+Migration.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = \"WCTDatabase+Migration.mm\"; sourceTree = \"<group>\"; };\n\t\t236BACE421BF9FC900C8B4D9 /* WCTMigrationInfo.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WCTMigrationInfo.h; sourceTree = \"<group>\"; };\n\t\t236BACE521BF9FC900C8B4D9 /* WCTMigrationInfo.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = WCTMigrationInfo.mm; sourceTree = \"<group>\"; };\n\t\t2370980820590CA700E768B4 /* HandleStatement.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = HandleStatement.cpp; sourceTree = \"<group>\"; };\n\t\t2370980920590CA700E768B4 /* HandleStatement.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = HandleStatement.hpp; sourceTree = \"<group>\"; };\n\t\t2370B10821914ED400D3227C /* NSDate+WCTColumnCoding.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = \"NSDate+WCTColumnCoding.mm\"; sourceTree = \"<group>\"; };\n\t\t2370B10B21914ED400D3227C /* NSString+WCTColumnCoding.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = \"NSString+WCTColumnCoding.h\"; sourceTree = \"<group>\"; };\n\t\t2370B10C21914ED400D3227C /* NSNumber+WCTColumnCoding.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = \"NSNumber+WCTColumnCoding.mm\"; sourceTree = \"<group>\"; };\n\t\t2370B10D21914ED400D3227C /* NSObject+WCTColumnCoding.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = \"NSObject+WCTColumnCoding.h\"; sourceTree = \"<group>\"; };\n\t\t2370B10E21914ED400D3227C /* NSObject+WCTColumnCoding.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = \"NSObject+WCTColumnCoding.mm\"; sourceTree = \"<group>\"; };\n\t\t2370B10F21914ED400D3227C /* NSDate+WCTColumnCoding.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = \"NSDate+WCTColumnCoding.h\"; sourceTree = \"<group>\"; };\n\t\t2370B11021914ED400D3227C /* WCTMaster.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WCTMaster.h; sourceTree = \"<group>\"; };\n\t\t2370B11121914ED400D3227C /* WCTMaster+WCTTableCoding.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = \"WCTMaster+WCTTableCoding.h\"; sourceTree = \"<group>\"; };\n\t\t2370B11221914ED400D3227C /* NSNumber+WCTColumnCoding.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = \"NSNumber+WCTColumnCoding.h\"; sourceTree = \"<group>\"; };\n\t\t2370B11321914ED500D3227C /* NSData+WCTColumnCoding.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = \"NSData+WCTColumnCoding.mm\"; sourceTree = \"<group>\"; };\n\t\t2370B11421914ED500D3227C /* WCTMaster.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WCTMaster.mm; sourceTree = \"<group>\"; };\n\t\t2370B11521914ED500D3227C /* NSData+WCTColumnCoding.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = \"NSData+WCTColumnCoding.h\"; sourceTree = \"<group>\"; };\n\t\t2370B11721914ED500D3227C /* NSNull+WCTColumnCoding.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = \"NSNull+WCTColumnCoding.mm\"; sourceTree = \"<group>\"; };\n\t\t2370B11821914ED500D3227C /* NSNull+WCTColumnCoding.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = \"NSNull+WCTColumnCoding.h\"; sourceTree = \"<group>\"; };\n\t\t2370B11921914ED500D3227C /* NSString+WCTColumnCoding.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = \"NSString+WCTColumnCoding.mm\"; sourceTree = \"<group>\"; };\n\t\t2370B1302191533C00D3227C /* WCTOptional.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WCTOptional.h; sourceTree = \"<group>\"; };\n\t\t2372E05721A2633800051D9A /* WCTTryDisposeGuard.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = WCTTryDisposeGuard.mm; sourceTree = \"<group>\"; };\n\t\t2372E05821A2633800051D9A /* WCTTryDisposeGuard.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WCTTryDisposeGuard.h; sourceTree = \"<group>\"; };\n\t\t2375945F210081AA00DBB721 /* UnsafeData.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = UnsafeData.cpp; sourceTree = \"<group>\"; };\n\t\t23759460210081AA00DBB721 /* UnsafeData.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = UnsafeData.hpp; sourceTree = \"<group>\"; };\n\t\t2376CB1920DA5D3B00A68DB5 /* Scoreable.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = Scoreable.cpp; sourceTree = \"<group>\"; };\n\t\t2376CB1A20DA5D3B00A68DB5 /* Scoreable.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = Scoreable.hpp; sourceTree = \"<group>\"; };\n\t\t23775B2F20AD666900E21AB0 /* Assertion.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = Assertion.hpp; sourceTree = \"<group>\"; };\n\t\t23775B3020AD666900E21AB0 /* WCDBError.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WCDBError.cpp; sourceTree = \"<group>\"; };\n\t\t23775B3120AD666900E21AB0 /* WCDBError.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = WCDBError.hpp; sourceTree = \"<group>\"; };\n\t\t23775B3220AD666900E21AB0 /* Notifier.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Notifier.cpp; sourceTree = \"<group>\"; };\n\t\t23775B3320AD666900E21AB0 /* Notifier.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = Notifier.hpp; sourceTree = \"<group>\"; };\n\t\t23775B3620AD666900E21AB0 /* FullCrawler.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FullCrawler.cpp; sourceTree = \"<group>\"; };\n\t\t23775B3720AD666900E21AB0 /* FullCrawler.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = FullCrawler.hpp; sourceTree = \"<group>\"; };\n\t\t23775B3E20AD666900E21AB0 /* Backup.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Backup.cpp; sourceTree = \"<group>\"; };\n\t\t23775B3F20AD666900E21AB0 /* Backup.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = Backup.hpp; sourceTree = \"<group>\"; };\n\t\t23775B4020AD666900E21AB0 /* Material.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Material.cpp; sourceTree = \"<group>\"; };\n\t\t23775B4120AD666900E21AB0 /* Material.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = Material.hpp; sourceTree = \"<group>\"; };\n\t\t23775B4220AD666900E21AB0 /* Mechanic.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Mechanic.cpp; sourceTree = \"<group>\"; };\n\t\t23775B4320AD666900E21AB0 /* Mechanic.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = Mechanic.hpp; sourceTree = \"<group>\"; };\n\t\t23775B4520AD666900E21AB0 /* Cell.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Cell.cpp; sourceTree = \"<group>\"; };\n\t\t23775B4620AD666900E21AB0 /* Cell.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = Cell.hpp; sourceTree = \"<group>\"; };\n\t\t23775B4720AD666900E21AB0 /* Page.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Page.cpp; sourceTree = \"<group>\"; };\n\t\t23775B4820AD666900E21AB0 /* Page.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = Page.hpp; sourceTree = \"<group>\"; };\n\t\t23775B4920AD666900E21AB0 /* Pager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Pager.cpp; sourceTree = \"<group>\"; };\n\t\t23775B4A20AD666900E21AB0 /* Pager.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = Pager.hpp; sourceTree = \"<group>\"; };\n\t\t23775B5020AD666900E21AB0 /* Crawlable.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Crawlable.cpp; sourceTree = \"<group>\"; };\n\t\t23775B5120AD666900E21AB0 /* Crawlable.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = Crawlable.hpp; sourceTree = \"<group>\"; };\n\t\t23775BCB20AD72BC00E21AB0 /* Data.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = Data.cpp; sourceTree = \"<group>\"; };\n\t\t23775BCC20AD72BC00E21AB0 /* Data.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = Data.hpp; sourceTree = \"<group>\"; };\n\t\t23776CA3218C41DD00E985DC /* WCTChainCall.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = WCTChainCall.mm; sourceTree = \"<group>\"; };\n\t\t23776CA5218C41E600E985DC /* WCTChainCall+Private.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = \"WCTChainCall+Private.h\"; sourceTree = \"<group>\"; };\n\t\t237908F621928C9F0098797F /* WCTObjCAccessor.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = WCTObjCAccessor.mm; sourceTree = \"<group>\"; };\n\t\t23790A7D219315D50098797F /* WCTColumnConstraintMacro.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WCTColumnConstraintMacro.h; sourceTree = \"<group>\"; };\n\t\t23790A7E219315DE0098797F /* WCTVirtualTableMacro.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WCTVirtualTableMacro.h; sourceTree = \"<group>\"; };\n\t\t237A65F220F731DF008B4771 /* UniqueList.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = UniqueList.hpp; sourceTree = \"<group>\"; };\n\t\t237A8D5721ED88DF003AF5BB /* SQLiteDeclaration.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SQLiteDeclaration.h; sourceTree = \"<group>\"; };\n\t\t237A8D5D21EDBB2E003AF5BB /* BusyRetryConfig.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = BusyRetryConfig.cpp; sourceTree = \"<group>\"; };\n\t\t237A8D5E21EDBB2E003AF5BB /* BusyRetryConfig.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = BusyRetryConfig.hpp; sourceTree = \"<group>\"; };\n\t\t237B47AE21FEEA200059227A /* ColumnMeta.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = ColumnMeta.cpp; sourceTree = \"<group>\"; };\n\t\t237B47AF21FEEA200059227A /* ColumnMeta.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = ColumnMeta.hpp; sourceTree = \"<group>\"; };\n\t\t237C900621D45E6700EE6E44 /* CoreConst.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CoreConst.h; sourceTree = \"<group>\"; };\n\t\t2386B3C21ED442FE000B72F6 /* WCTError.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WCTError.h; sourceTree = \"<group>\"; };\n\t\t2386B3C31ED442FE000B72F6 /* WCTError.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WCTError.mm; sourceTree = \"<group>\"; };\n\t\t2386B3C41ED442FE000B72F6 /* WCTError+Private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = \"WCTError+Private.h\"; sourceTree = \"<group>\"; };\n\t\t2387D8A621DF0B190028ADB9 /* XCTest.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = XCTest.framework; path = Platforms/MacOSX.platform/Developer/Library/Frameworks/XCTest.framework; sourceTree = DEVELOPER_DIR; };\n\t\t238C177C21CA2190003B6D26 /* SyntaxCommonConst.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = SyntaxCommonConst.hpp; sourceTree = \"<group>\"; };\n\t\t23906AB7215E500100C2B717 /* WCTDatabase+Monitor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = \"WCTDatabase+Monitor.h\"; sourceTree = \"<group>\"; };\n\t\t23906AB8215E500100C2B717 /* WCTDatabase+Monitor.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = \"WCTDatabase+Monitor.mm\"; sourceTree = \"<group>\"; };\n\t\t239326611E836D7300D677CC /* WCDB.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = WCDB.framework; sourceTree = BUILT_PRODUCTS_DIR; };\n\t\t2395582421C143BB000C85E1 /* WCTMigrationInfo+Private.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = \"WCTMigrationInfo+Private.h\"; sourceTree = \"<group>\"; };\n\t\t2396EB0B21801BD60079066C /* WCTResultColumn.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WCTResultColumn.h; sourceTree = \"<group>\"; };\n\t\t2396EB0C21801BD60079066C /* WCTResultColumn.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = WCTResultColumn.mm; sourceTree = \"<group>\"; };\n\t\t239776CE202AF2E2000A681C /* TimedQueue.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = TimedQueue.hpp; sourceTree = \"<group>\"; };\n\t\t239776D0202AF2E2000A681C /* Macro.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Macro.h; sourceTree = \"<group>\"; };\n\t\t239E8A702160A5B100BCB308 /* Host.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Host.app; sourceTree = BUILT_PRODUCTS_DIR; };\n\t\t239E8A922160A81600BCB308 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };\n\t\t23A3CFB3205FB1A800692F94 /* WCTHandle+Convenient.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = \"WCTHandle+Convenient.h\"; sourceTree = \"<group>\"; };\n\t\t23A3CFB4205FB1A800692F94 /* WCTHandle+Convenient.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = \"WCTHandle+Convenient.mm\"; sourceTree = \"<group>\"; };\n\t\t23A64D07214A458A00ED28BB /* MigrationInfo.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = MigrationInfo.cpp; sourceTree = \"<group>\"; };\n\t\t23A64D08214A458A00ED28BB /* MigrationInfo.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = MigrationInfo.hpp; sourceTree = \"<group>\"; };\n\t\t23A64D0D214A4A7000ED28BB /* Migration.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = Migration.cpp; sourceTree = \"<group>\"; };\n\t\t23A64D0E214A4A7000ED28BB /* Migration.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = Migration.hpp; sourceTree = \"<group>\"; };\n\t\t23A6D4BD20BFD7F9004F2DAA /* Progress.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = Progress.cpp; sourceTree = \"<group>\"; };\n\t\t23A6D4BE20BFD7F9004F2DAA /* Progress.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = Progress.hpp; sourceTree = \"<group>\"; };\n\t\t23A747BE20039675003CECFA /* sqlcipher.preprocessed.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = \"wrapper.pb-project\"; name = sqlcipher.preprocessed.xcodeproj; path = ../sqlcipher/sqlcipher.preprocessed.xcodeproj; sourceTree = \"<group>\"; };\n\t\t23AB898D215BA6DB00554DF1 /* SQLite.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SQLite.h; sourceTree = \"<group>\"; };\n\t\t23AD52D420DB4A3C00664B62 /* MasterItem.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = MasterItem.cpp; sourceTree = \"<group>\"; };\n\t\t23AD52D520DB4A3C00664B62 /* MasterItem.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = MasterItem.hpp; sourceTree = \"<group>\"; };\n\t\t23AD52DB20DB56D200664B62 /* SequenceItem.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = SequenceItem.cpp; sourceTree = \"<group>\"; };\n\t\t23AD52DC20DB56D200664B62 /* SequenceItem.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = SequenceItem.hpp; sourceTree = \"<group>\"; };\n\t\t23AD52E420DB852B00664B62 /* Fraction.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = Fraction.cpp; sourceTree = \"<group>\"; };\n\t\t23AD52E520DB852B00664B62 /* Fraction.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = Fraction.hpp; sourceTree = \"<group>\"; };\n\t\t23AD52F020DBAC4C00664B62 /* UpgradeableErrorProne.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = UpgradeableErrorProne.cpp; sourceTree = \"<group>\"; };\n\t\t23AD52F120DBAC4C00664B62 /* UpgradeableErrorProne.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = UpgradeableErrorProne.hpp; sourceTree = \"<group>\"; };\n\t\t23AF4E1C20CD04E20050033C /* Initializeable.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = Initializeable.cpp; sourceTree = \"<group>\"; };\n\t\t23AF4E1D20CD04E20050033C /* Initializeable.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = Initializeable.hpp; sourceTree = \"<group>\"; };\n\t\t23B101E82090667B005D9DD3 /* WCTMacroUtility.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WCTMacroUtility.h; sourceTree = \"<group>\"; };\n\t\t23B35C7420BFE39400425033 /* Path.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = Path.hpp; sourceTree = \"<group>\"; };\n\t\t23B35C7520BFE39500425033 /* Path.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Path.cpp; sourceTree = \"<group>\"; };\n\t\t23B4DC7C2111B39100954D71 /* Tag.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Tag.cpp; sourceTree = \"<group>\"; };\n\t\t23B4DC7D2111B39200954D71 /* Tag.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = Tag.hpp; sourceTree = \"<group>\"; };\n\t\t23B4DCBB2112A9C800954D71 /* CommonCore.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = CommonCore.cpp; sourceTree = \"<group>\"; };\n\t\t23B4DCD92112AC5600954D71 /* TokenizerModuleTemplate.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = TokenizerModuleTemplate.hpp; sourceTree = \"<group>\"; };\n\t\t23B4DCDF2112B03C00954D71 /* AsyncQueue.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = AsyncQueue.cpp; sourceTree = \"<group>\"; };\n\t\t23B4DCE02112B03C00954D71 /* AsyncQueue.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = AsyncQueue.hpp; sourceTree = \"<group>\"; };\n\t\t23B9E66920AE6EE400CF1683 /* RepairKit.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RepairKit.h; sourceTree = \"<group>\"; };\n\t\t23B9E67320AE733A00CF1683 /* FileManager.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = FileManager.hpp; sourceTree = \"<group>\"; };\n\t\t23B9E67420AE733A00CF1683 /* FileManager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FileManager.cpp; sourceTree = \"<group>\"; };\n\t\t23BBE2A5204955CD00C4CBB6 /* WCTCommon.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WCTCommon.h; sourceTree = \"<group>\"; };\n\t\t23BBE2AB2049565600C4CBB6 /* WCTDatabase+Config.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = \"WCTDatabase+Config.h\"; sourceTree = \"<group>\"; };\n\t\t23BBE2AC2049565600C4CBB6 /* WCTDatabase+Config.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = \"WCTDatabase+Config.mm\"; sourceTree = \"<group>\"; };\n\t\t23BBE2AF2049576D00C4CBB6 /* WCTDatabase+Memory.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = \"WCTDatabase+Memory.h\"; sourceTree = \"<group>\"; };\n\t\t23BBE2B02049576D00C4CBB6 /* WCTDatabase+Memory.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = \"WCTDatabase+Memory.mm\"; sourceTree = \"<group>\"; };\n\t\t23C43BCC2087435800AB186D /* libz.tbd */ = {isa = PBXFileReference; lastKnownFileType = \"sourcecode.text-based-dylib-definition\"; name = libz.tbd; path = usr/lib/libz.tbd; sourceTree = SDKROOT; };\n\t\t23C7558F20DCF90F00031A93 /* SQLiteLocker.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = SQLiteLocker.cpp; sourceTree = \"<group>\"; };\n\t\t23C7559020DCF90F00031A93 /* SQLiteLocker.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = SQLiteLocker.hpp; sourceTree = \"<group>\"; };\n\t\t23C7559820DD17B100031A93 /* SQLiteBase.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = SQLiteBase.cpp; sourceTree = \"<group>\"; };\n\t\t23C7559920DD17B100031A93 /* SQLiteBase.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = SQLiteBase.hpp; sourceTree = \"<group>\"; };\n\t\t23D07CE220BE87360043F4D4 /* MasterCrawler.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MasterCrawler.cpp; sourceTree = \"<group>\"; };\n\t\t23D07CE320BE87360043F4D4 /* MasterCrawler.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = MasterCrawler.hpp; sourceTree = \"<group>\"; };\n\t\t23D07CE820BE873E0043F4D4 /* SequenceCrawler.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = SequenceCrawler.cpp; sourceTree = \"<group>\"; };\n\t\t23D07CE920BE873E0043F4D4 /* SequenceCrawler.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = SequenceCrawler.hpp; sourceTree = \"<group>\"; };\n\t\t23D0C30C20C125420001BFAE /* SQLiteAssembler.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SQLiteAssembler.cpp; sourceTree = \"<group>\"; };\n\t\t23D0C30D20C125420001BFAE /* SQLiteAssembler.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = SQLiteAssembler.hpp; sourceTree = \"<group>\"; };\n\t\t23D0C34920C149D80001BFAE /* Factory.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Factory.cpp; sourceTree = \"<group>\"; };\n\t\t23D0C34A20C149D80001BFAE /* Factory.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = Factory.hpp; sourceTree = \"<group>\"; };\n\t\t23D0C34B20C149D80001BFAE /* FactoryDepositor.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FactoryDepositor.cpp; sourceTree = \"<group>\"; };\n\t\t23D0C34C20C149D80001BFAE /* FactoryDepositor.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = FactoryDepositor.hpp; sourceTree = \"<group>\"; };\n\t\t23D0C34F20C149D80001BFAE /* FactoryRetriever.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FactoryRetriever.cpp; sourceTree = \"<group>\"; };\n\t\t23D0C35020C149D80001BFAE /* FactoryRetriever.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = FactoryRetriever.hpp; sourceTree = \"<group>\"; };\n\t\t23D0C36120C14ACC0001BFAE /* FactoryRelated.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = FactoryRelated.cpp; sourceTree = \"<group>\"; };\n\t\t23D0C36220C14ACC0001BFAE /* FactoryRelated.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = FactoryRelated.hpp; sourceTree = \"<group>\"; };\n\t\t23D0C38B20C17CAE0001BFAE /* FactoryBackup.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = FactoryBackup.cpp; sourceTree = \"<group>\"; };\n\t\t23D0C38C20C17CAE0001BFAE /* FactoryBackup.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = FactoryBackup.hpp; sourceTree = \"<group>\"; };\n\t\t23D4DA442085A3D300AE6D90 /* Interface.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Interface.h; sourceTree = \"<group>\"; };\n\t\t23D96B902050DED700DB5E93 /* DatabasePool.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = DatabasePool.cpp; sourceTree = \"<group>\"; };\n\t\t23D96B912050DED700DB5E93 /* DatabasePool.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = DatabasePool.hpp; sourceTree = \"<group>\"; };\n\t\t23DD76BB20CF78C800E9B451 /* FactoryRenewer.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = FactoryRenewer.cpp; sourceTree = \"<group>\"; };\n\t\t23DD76BC20CF78C800E9B451 /* FactoryRenewer.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = FactoryRenewer.hpp; sourceTree = \"<group>\"; };\n\t\t23DF0A072190275B00F0B2B6 /* WCTDatabase.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WCTDatabase.mm; sourceTree = \"<group>\"; };\n\t\t23DF0A082190275B00F0B2B6 /* WCTDatabase.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WCTDatabase.h; sourceTree = \"<group>\"; };\n\t\t23DF0A092190275B00F0B2B6 /* WCTDatabase+Private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = \"WCTDatabase+Private.h\"; sourceTree = \"<group>\"; };\n\t\t23DF0A0D219028E900F0B2B6 /* WCTDeclaration.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WCTDeclaration.h; sourceTree = \"<group>\"; };\n\t\t23E163D120FDDD8500C3F910 /* PorterStemming.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = PorterStemming.c; sourceTree = \"<group>\"; };\n\t\t23E7EB1B2123D58D0056B5D8 /* HighWater.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = HighWater.cpp; sourceTree = \"<group>\"; };\n\t\t23E7EB1C2123D58D0056B5D8 /* HighWater.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = HighWater.hpp; sourceTree = \"<group>\"; };\n\t\t23EABBE4206D08EC00241F3B /* WCTHandle+Table.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = \"WCTHandle+Table.h\"; sourceTree = \"<group>\"; };\n\t\t23EABBE5206D08EC00241F3B /* WCTHandle+Table.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = \"WCTHandle+Table.mm\"; sourceTree = \"<group>\"; };\n\t\t23EB91DC20CA1EBE00ECF668 /* Wal.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = Wal.cpp; sourceTree = \"<group>\"; };\n\t\t23EB91DD20CA1EBE00ECF668 /* Wal.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = Wal.hpp; sourceTree = \"<group>\"; };\n\t\t23EE0EB020B838E100C95998 /* Repairman.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = Repairman.cpp; sourceTree = \"<group>\"; };\n\t\t23EE0EB120B838E100C95998 /* Repairman.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = Repairman.hpp; sourceTree = \"<group>\"; };\n\t\t23EEDB68217DFADC006E9E73 /* AggregateFunction.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AggregateFunction.cpp; sourceTree = \"<group>\"; };\n\t\t23EEDB69217DFADC006E9E73 /* AggregateFunction.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = AggregateFunction.hpp; sourceTree = \"<group>\"; };\n\t\t23EEDB6A217DFADC006E9E73 /* ColumnType.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ColumnType.cpp; sourceTree = \"<group>\"; };\n\t\t23EEDB6B217DFADC006E9E73 /* ColumnType.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = ColumnType.hpp; sourceTree = \"<group>\"; };\n\t\t23EEDB6C217DFADC006E9E73 /* Convertible.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = Convertible.hpp; sourceTree = \"<group>\"; };\n\t\t23EEDB6D217DFADC006E9E73 /* ConvertibleImplementation.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ConvertibleImplementation.cpp; sourceTree = \"<group>\"; };\n\t\t23EEDB6E217DFADC006E9E73 /* ConvertibleImplementation.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = ConvertibleImplementation.hpp; sourceTree = \"<group>\"; };\n\t\t23EEDB6F217DFADC006E9E73 /* CoreFunction.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CoreFunction.cpp; sourceTree = \"<group>\"; };\n\t\t23EEDB70217DFADC006E9E73 /* CoreFunction.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = CoreFunction.hpp; sourceTree = \"<group>\"; };\n\t\t23EEDB71217DFADC006E9E73 /* ExpressionOperable.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ExpressionOperable.cpp; sourceTree = \"<group>\"; };\n\t\t23EEDB72217DFADC006E9E73 /* ExpressionOperable.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = ExpressionOperable.hpp; sourceTree = \"<group>\"; };\n\t\t23EEDB73217DFADC006E9E73 /* FTSFunction.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FTSFunction.cpp; sourceTree = \"<group>\"; };\n\t\t23EEDB74217DFADC006E9E73 /* FTSFunction.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = FTSFunction.hpp; sourceTree = \"<group>\"; };\n\t\t23EEDB75217DFADC006E9E73 /* SyntaxForwardDeclaration.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SyntaxForwardDeclaration.h; sourceTree = \"<group>\"; };\n\t\t23EEDB76217DFADC006E9E73 /* SyntaxList.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = SyntaxList.hpp; sourceTree = \"<group>\"; };\n\t\t23EEDB7A217DFADC006E9E73 /* BindParameter.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = BindParameter.cpp; sourceTree = \"<group>\"; };\n\t\t23EEDB7B217DFADC006E9E73 /* BindParameter.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = BindParameter.hpp; sourceTree = \"<group>\"; };\n\t\t23EEDB7C217DFADC006E9E73 /* Column.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Column.cpp; sourceTree = \"<group>\"; };\n\t\t23EEDB7D217DFADC006E9E73 /* Column.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = Column.hpp; sourceTree = \"<group>\"; };\n\t\t23EEDB7E217DFADC006E9E73 /* ColumnConstraint.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ColumnConstraint.cpp; sourceTree = \"<group>\"; };\n\t\t23EEDB7F217DFADC006E9E73 /* ColumnConstraint.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = ColumnConstraint.hpp; sourceTree = \"<group>\"; };\n\t\t23EEDB80217DFADC006E9E73 /* ColumnDef.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ColumnDef.cpp; sourceTree = \"<group>\"; };\n\t\t23EEDB81217DFADC006E9E73 /* ColumnDef.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = ColumnDef.hpp; sourceTree = \"<group>\"; };\n\t\t23EEDB82217DFADC006E9E73 /* CommonTableExpression.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CommonTableExpression.cpp; sourceTree = \"<group>\"; };\n\t\t23EEDB83217DFADC006E9E73 /* CommonTableExpression.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = CommonTableExpression.hpp; sourceTree = \"<group>\"; };\n\t\t23EEDB86217DFADC006E9E73 /* Expression.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Expression.cpp; sourceTree = \"<group>\"; };\n\t\t23EEDB87217DFADC006E9E73 /* Expression.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = Expression.hpp; sourceTree = \"<group>\"; };\n\t\t23EEDB88217DFADC006E9E73 /* Filter.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Filter.cpp; sourceTree = \"<group>\"; };\n\t\t23EEDB89217DFADC006E9E73 /* Filter.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = Filter.hpp; sourceTree = \"<group>\"; };\n\t\t23EEDB8A217DFADC006E9E73 /* ForeignKey.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ForeignKey.cpp; sourceTree = \"<group>\"; };\n\t\t23EEDB8B217DFADC006E9E73 /* ForeignKey.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = ForeignKey.hpp; sourceTree = \"<group>\"; };\n\t\t23EEDB8C217DFADC006E9E73 /* FrameSpec.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FrameSpec.cpp; sourceTree = \"<group>\"; };\n\t\t23EEDB8D217DFADC006E9E73 /* FrameSpec.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = FrameSpec.hpp; sourceTree = \"<group>\"; };\n\t\t23EEDB90217DFADC006E9E73 /* IndexedColumn.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = IndexedColumn.cpp; sourceTree = \"<group>\"; };\n\t\t23EEDB91217DFADC006E9E73 /* IndexedColumn.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = IndexedColumn.hpp; sourceTree = \"<group>\"; };\n\t\t23EEDB92217DFADC006E9E73 /* Join.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Join.cpp; sourceTree = \"<group>\"; };\n\t\t23EEDB93217DFADC006E9E73 /* Join.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = Join.hpp; sourceTree = \"<group>\"; };\n\t\t23EEDB94217DFADC006E9E73 /* JoinConstraint.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JoinConstraint.cpp; sourceTree = \"<group>\"; };\n\t\t23EEDB95217DFADC006E9E73 /* JoinConstraint.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = JoinConstraint.hpp; sourceTree = \"<group>\"; };\n\t\t23EEDB96217DFADC006E9E73 /* LiteralValue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LiteralValue.cpp; sourceTree = \"<group>\"; };\n\t\t23EEDB97217DFADC006E9E73 /* LiteralValue.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = LiteralValue.hpp; sourceTree = \"<group>\"; };\n\t\t23EEDB9A217DFADC006E9E73 /* OrderingTerm.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = OrderingTerm.cpp; sourceTree = \"<group>\"; };\n\t\t23EEDB9B217DFADC006E9E73 /* OrderingTerm.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = OrderingTerm.hpp; sourceTree = \"<group>\"; };\n\t\t23EEDB9C217DFADC006E9E73 /* Pragma.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Pragma.cpp; sourceTree = \"<group>\"; };\n\t\t23EEDB9D217DFADC006E9E73 /* Pragma.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = Pragma.hpp; sourceTree = \"<group>\"; };\n\t\t23EEDB9E217DFADC006E9E73 /* QualifiedTable.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = QualifiedTable.cpp; sourceTree = \"<group>\"; };\n\t\t23EEDB9F217DFADC006E9E73 /* QualifiedTable.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = QualifiedTable.hpp; sourceTree = \"<group>\"; };\n\t\t23EEDBA0217DFADC006E9E73 /* RaiseFunction.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RaiseFunction.cpp; sourceTree = \"<group>\"; };\n\t\t23EEDBA1217DFADC006E9E73 /* RaiseFunction.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = RaiseFunction.hpp; sourceTree = \"<group>\"; };\n\t\t23EEDBA4217DFADC006E9E73 /* ResultColumn.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ResultColumn.cpp; sourceTree = \"<group>\"; };\n\t\t23EEDBA5217DFADC006E9E73 /* ResultColumn.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = ResultColumn.hpp; sourceTree = \"<group>\"; };\n\t\t23EEDBA6217DFADC006E9E73 /* Schema.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Schema.cpp; sourceTree = \"<group>\"; };\n\t\t23EEDBA7217DFADC006E9E73 /* Schema.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = Schema.hpp; sourceTree = \"<group>\"; };\n\t\t23EEDBA8217DFADC006E9E73 /* SQL.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SQL.cpp; sourceTree = \"<group>\"; };\n\t\t23EEDBA9217DFADC006E9E73 /* SQL.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = SQL.hpp; sourceTree = \"<group>\"; };\n\t\t23EEDBAA217DFADC006E9E73 /* TableConstraint.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TableConstraint.cpp; sourceTree = \"<group>\"; };\n\t\t23EEDBAB217DFADC006E9E73 /* TableConstraint.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = TableConstraint.hpp; sourceTree = \"<group>\"; };\n\t\t23EEDBAC217DFADC006E9E73 /* TableOrSubquery.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TableOrSubquery.cpp; sourceTree = \"<group>\"; };\n\t\t23EEDBAD217DFADC006E9E73 /* TableOrSubquery.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = TableOrSubquery.hpp; sourceTree = \"<group>\"; };\n\t\t23EEDBAE217DFADC006E9E73 /* Upsert.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Upsert.cpp; sourceTree = \"<group>\"; };\n\t\t23EEDBAF217DFADC006E9E73 /* Upsert.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = Upsert.hpp; sourceTree = \"<group>\"; };\n\t\t23EEDBB0217DFADC006E9E73 /* WindowDef.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WindowDef.cpp; sourceTree = \"<group>\"; };\n\t\t23EEDBB1217DFADC006E9E73 /* WindowDef.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = WindowDef.hpp; sourceTree = \"<group>\"; };\n\t\t23EEDBB8217DFADC006E9E73 /* Statement.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = Statement.hpp; sourceTree = \"<group>\"; };\n\t\t23EEDBB9217DFADC006E9E73 /* StatementAlterTable.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = StatementAlterTable.cpp; sourceTree = \"<group>\"; };\n\t\t23EEDBBA217DFADC006E9E73 /* StatementAlterTable.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = StatementAlterTable.hpp; sourceTree = \"<group>\"; };\n\t\t23EEDBBB217DFADC006E9E73 /* StatementAnalyze.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = StatementAnalyze.cpp; sourceTree = \"<group>\"; };\n\t\t23EEDBBC217DFADC006E9E73 /* StatementAnalyze.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = StatementAnalyze.hpp; sourceTree = \"<group>\"; };\n\t\t23EEDBBD217DFADC006E9E73 /* StatementAttach.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = StatementAttach.cpp; sourceTree = \"<group>\"; };\n\t\t23EEDBBE217DFADC006E9E73 /* StatementAttach.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = StatementAttach.hpp; sourceTree = \"<group>\"; };\n\t\t23EEDBBF217DFADC006E9E73 /* StatementBegin.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = StatementBegin.cpp; sourceTree = \"<group>\"; };\n\t\t23EEDBC0217DFADC006E9E73 /* StatementBegin.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = StatementBegin.hpp; sourceTree = \"<group>\"; };\n\t\t23EEDBC1217DFADC006E9E73 /* StatementCommit.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = StatementCommit.cpp; sourceTree = \"<group>\"; };\n\t\t23EEDBC2217DFADC006E9E73 /* StatementCommit.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = StatementCommit.hpp; sourceTree = \"<group>\"; };\n\t\t23EEDBC3217DFADC006E9E73 /* StatementCreateIndex.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = StatementCreateIndex.cpp; sourceTree = \"<group>\"; };\n\t\t23EEDBC4217DFADC006E9E73 /* StatementCreateIndex.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = StatementCreateIndex.hpp; sourceTree = \"<group>\"; };\n\t\t23EEDBC5217DFADC006E9E73 /* StatementCreateTable.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = StatementCreateTable.cpp; sourceTree = \"<group>\"; };\n\t\t23EEDBC6217DFADC006E9E73 /* StatementCreateTable.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = StatementCreateTable.hpp; sourceTree = \"<group>\"; };\n\t\t23EEDBC7217DFADC006E9E73 /* StatementCreateTrigger.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = StatementCreateTrigger.cpp; sourceTree = \"<group>\"; };\n\t\t23EEDBC8217DFADC006E9E73 /* StatementCreateTrigger.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = StatementCreateTrigger.hpp; sourceTree = \"<group>\"; };\n\t\t23EEDBC9217DFADC006E9E73 /* StatementCreateView.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = StatementCreateView.cpp; sourceTree = \"<group>\"; };\n\t\t23EEDBCA217DFADC006E9E73 /* StatementCreateView.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = StatementCreateView.hpp; sourceTree = \"<group>\"; };\n\t\t23EEDBCB217DFADC006E9E73 /* StatementCreateVirtualTable.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = StatementCreateVirtualTable.cpp; sourceTree = \"<group>\"; };\n\t\t23EEDBCC217DFADC006E9E73 /* StatementCreateVirtualTable.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = StatementCreateVirtualTable.hpp; sourceTree = \"<group>\"; };\n\t\t23EEDBCD217DFADC006E9E73 /* StatementDelete.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = StatementDelete.cpp; sourceTree = \"<group>\"; };\n\t\t23EEDBCE217DFADC006E9E73 /* StatementDelete.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = StatementDelete.hpp; sourceTree = \"<group>\"; };\n\t\t23EEDBCF217DFADC006E9E73 /* StatementDetach.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = StatementDetach.cpp; sourceTree = \"<group>\"; };\n\t\t23EEDBD0217DFADC006E9E73 /* StatementDetach.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = StatementDetach.hpp; sourceTree = \"<group>\"; };\n\t\t23EEDBD1217DFADC006E9E73 /* StatementDropIndex.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = StatementDropIndex.cpp; sourceTree = \"<group>\"; };\n\t\t23EEDBD2217DFADC006E9E73 /* StatementDropIndex.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = StatementDropIndex.hpp; sourceTree = \"<group>\"; };\n\t\t23EEDBD3217DFADC006E9E73 /* StatementDropTable.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = StatementDropTable.cpp; sourceTree = \"<group>\"; };\n\t\t23EEDBD4217DFADC006E9E73 /* StatementDropTable.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = StatementDropTable.hpp; sourceTree = \"<group>\"; };\n\t\t23EEDBD5217DFADC006E9E73 /* StatementDropTrigger.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = StatementDropTrigger.cpp; sourceTree = \"<group>\"; };\n\t\t23EEDBD6217DFADC006E9E73 /* StatementDropTrigger.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = StatementDropTrigger.hpp; sourceTree = \"<group>\"; };\n\t\t23EEDBD7217DFADC006E9E73 /* StatementDropView.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = StatementDropView.cpp; sourceTree = \"<group>\"; };\n\t\t23EEDBD8217DFADC006E9E73 /* StatementDropView.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = StatementDropView.hpp; sourceTree = \"<group>\"; };\n\t\t23EEDBD9217DFADC006E9E73 /* StatementInsert.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = StatementInsert.cpp; sourceTree = \"<group>\"; };\n\t\t23EEDBDA217DFADC006E9E73 /* StatementInsert.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = StatementInsert.hpp; sourceTree = \"<group>\"; };\n\t\t23EEDBDB217DFADC006E9E73 /* StatementPragma.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = StatementPragma.cpp; sourceTree = \"<group>\"; };\n\t\t23EEDBDC217DFADC006E9E73 /* StatementPragma.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = StatementPragma.hpp; sourceTree = \"<group>\"; };\n\t\t23EEDBDD217DFADC006E9E73 /* StatementReindex.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = StatementReindex.cpp; sourceTree = \"<group>\"; };\n\t\t23EEDBDE217DFADC006E9E73 /* StatementReindex.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = StatementReindex.hpp; sourceTree = \"<group>\"; };\n\t\t23EEDBDF217DFADC006E9E73 /* StatementRelease.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = StatementRelease.cpp; sourceTree = \"<group>\"; };\n\t\t23EEDBE0217DFADC006E9E73 /* StatementRelease.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = StatementRelease.hpp; sourceTree = \"<group>\"; };\n\t\t23EEDBE1217DFADC006E9E73 /* StatementRollback.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = StatementRollback.cpp; sourceTree = \"<group>\"; };\n\t\t23EEDBE2217DFADC006E9E73 /* StatementRollback.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = StatementRollback.hpp; sourceTree = \"<group>\"; };\n\t\t23EEDBE3217DFADC006E9E73 /* StatementSavepoint.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = StatementSavepoint.cpp; sourceTree = \"<group>\"; };\n\t\t23EEDBE4217DFADC006E9E73 /* StatementSavepoint.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = StatementSavepoint.hpp; sourceTree = \"<group>\"; };\n\t\t23EEDBE5217DFADC006E9E73 /* StatementSelect.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = StatementSelect.cpp; sourceTree = \"<group>\"; };\n\t\t23EEDBE6217DFADC006E9E73 /* StatementSelect.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = StatementSelect.hpp; sourceTree = \"<group>\"; };\n\t\t23EEDBE7217DFADC006E9E73 /* StatementUpdate.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = StatementUpdate.cpp; sourceTree = \"<group>\"; };\n\t\t23EEDBE8217DFADC006E9E73 /* StatementUpdate.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = StatementUpdate.hpp; sourceTree = \"<group>\"; };\n\t\t23EEDBE9217DFADC006E9E73 /* StatementVacuum.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = StatementVacuum.cpp; sourceTree = \"<group>\"; };\n\t\t23EEDBEA217DFADC006E9E73 /* StatementVacuum.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = StatementVacuum.hpp; sourceTree = \"<group>\"; };\n\t\t23EEDBEB217DFADC006E9E73 /* WINQ.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WINQ.h; sourceTree = \"<group>\"; };\n\t\t23EEDBF4217DFADC006E9E73 /* SyntaxBindParameter.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SyntaxBindParameter.cpp; sourceTree = \"<group>\"; };\n\t\t23EEDBF5217DFADC006E9E73 /* SyntaxBindParameter.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = SyntaxBindParameter.hpp; sourceTree = \"<group>\"; };\n\t\t23EEDBF6217DFADC006E9E73 /* SyntaxColumn.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SyntaxColumn.cpp; sourceTree = \"<group>\"; };\n\t\t23EEDBF7217DFADC006E9E73 /* SyntaxColumn.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = SyntaxColumn.hpp; sourceTree = \"<group>\"; };\n\t\t23EEDBF8217DFADC006E9E73 /* SyntaxColumnConstraint.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SyntaxColumnConstraint.cpp; sourceTree = \"<group>\"; };\n\t\t23EEDBF9217DFADC006E9E73 /* SyntaxColumnConstraint.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = SyntaxColumnConstraint.hpp; sourceTree = \"<group>\"; };\n\t\t23EEDBFA217DFADC006E9E73 /* SyntaxColumnDef.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SyntaxColumnDef.cpp; sourceTree = \"<group>\"; };\n\t\t23EEDBFB217DFADC006E9E73 /* SyntaxColumnDef.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = SyntaxColumnDef.hpp; sourceTree = \"<group>\"; };\n\t\t23EEDBFC217DFADC006E9E73 /* SyntaxCommonTableExpression.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SyntaxCommonTableExpression.cpp; sourceTree = \"<group>\"; };\n\t\t23EEDBFD217DFADC006E9E73 /* SyntaxCommonTableExpression.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = SyntaxCommonTableExpression.hpp; sourceTree = \"<group>\"; };\n\t\t23EEDC00217DFADC006E9E73 /* SyntaxExpression.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SyntaxExpression.cpp; sourceTree = \"<group>\"; };\n\t\t23EEDC01217DFADC006E9E73 /* SyntaxExpression.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = SyntaxExpression.hpp; sourceTree = \"<group>\"; };\n\t\t23EEDC02217DFADC006E9E73 /* SyntaxFilter.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SyntaxFilter.cpp; sourceTree = \"<group>\"; };\n\t\t23EEDC03217DFADC006E9E73 /* SyntaxFilter.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = SyntaxFilter.hpp; sourceTree = \"<group>\"; };\n\t\t23EEDC04217DFADC006E9E73 /* SyntaxForeignKeyClause.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SyntaxForeignKeyClause.cpp; sourceTree = \"<group>\"; };\n\t\t23EEDC05217DFADC006E9E73 /* SyntaxForeignKeyClause.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = SyntaxForeignKeyClause.hpp; sourceTree = \"<group>\"; };\n\t\t23EEDC06217DFADC006E9E73 /* SyntaxFrameSpec.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SyntaxFrameSpec.cpp; sourceTree = \"<group>\"; };\n\t\t23EEDC07217DFADC006E9E73 /* SyntaxFrameSpec.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = SyntaxFrameSpec.hpp; sourceTree = \"<group>\"; };\n\t\t23EEDC0A217DFADC006E9E73 /* SyntaxIdentifier.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SyntaxIdentifier.cpp; sourceTree = \"<group>\"; };\n\t\t23EEDC0B217DFADC006E9E73 /* SyntaxIdentifier.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = SyntaxIdentifier.hpp; sourceTree = \"<group>\"; };\n\t\t23EEDC0C217DFADC006E9E73 /* SyntaxIndexedColumn.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SyntaxIndexedColumn.cpp; sourceTree = \"<group>\"; };\n\t\t23EEDC0D217DFADC006E9E73 /* SyntaxIndexedColumn.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = SyntaxIndexedColumn.hpp; sourceTree = \"<group>\"; };\n\t\t23EEDC0E217DFADC006E9E73 /* SyntaxJoinClause.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SyntaxJoinClause.cpp; sourceTree = \"<group>\"; };\n\t\t23EEDC0F217DFADC006E9E73 /* SyntaxJoinClause.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = SyntaxJoinClause.hpp; sourceTree = \"<group>\"; };\n\t\t23EEDC10217DFADC006E9E73 /* SyntaxJoinConstraint.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SyntaxJoinConstraint.cpp; sourceTree = \"<group>\"; };\n\t\t23EEDC11217DFADC006E9E73 /* SyntaxJoinConstraint.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = SyntaxJoinConstraint.hpp; sourceTree = \"<group>\"; };\n\t\t23EEDC12217DFADC006E9E73 /* SyntaxLiteralValue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SyntaxLiteralValue.cpp; sourceTree = \"<group>\"; };\n\t\t23EEDC13217DFADC006E9E73 /* SyntaxLiteralValue.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = SyntaxLiteralValue.hpp; sourceTree = \"<group>\"; };\n\t\t23EEDC16217DFADC006E9E73 /* SyntaxOrderingTerm.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SyntaxOrderingTerm.cpp; sourceTree = \"<group>\"; };\n\t\t23EEDC17217DFADC006E9E73 /* SyntaxOrderingTerm.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = SyntaxOrderingTerm.hpp; sourceTree = \"<group>\"; };\n\t\t23EEDC18217DFADC006E9E73 /* SyntaxPragma.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SyntaxPragma.cpp; sourceTree = \"<group>\"; };\n\t\t23EEDC19217DFADC006E9E73 /* SyntaxPragma.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = SyntaxPragma.hpp; sourceTree = \"<group>\"; };\n\t\t23EEDC1A217DFADC006E9E73 /* SyntaxQualifiedTableName.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SyntaxQualifiedTableName.cpp; sourceTree = \"<group>\"; };\n\t\t23EEDC1B217DFADC006E9E73 /* SyntaxQualifiedTableName.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = SyntaxQualifiedTableName.hpp; sourceTree = \"<group>\"; };\n\t\t23EEDC1C217DFADC006E9E73 /* SyntaxRaiseFunction.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SyntaxRaiseFunction.cpp; sourceTree = \"<group>\"; };\n\t\t23EEDC1D217DFADC006E9E73 /* SyntaxRaiseFunction.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = SyntaxRaiseFunction.hpp; sourceTree = \"<group>\"; };\n\t\t23EEDC20217DFADC006E9E73 /* SyntaxResultColumn.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SyntaxResultColumn.cpp; sourceTree = \"<group>\"; };\n\t\t23EEDC21217DFADC006E9E73 /* SyntaxResultColumn.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = SyntaxResultColumn.hpp; sourceTree = \"<group>\"; };\n\t\t23EEDC22217DFADC006E9E73 /* SyntaxSchema.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SyntaxSchema.cpp; sourceTree = \"<group>\"; };\n\t\t23EEDC23217DFADC006E9E73 /* SyntaxSchema.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = SyntaxSchema.hpp; sourceTree = \"<group>\"; };\n\t\t23EEDC24217DFADC006E9E73 /* SyntaxSelectCore.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SyntaxSelectCore.cpp; sourceTree = \"<group>\"; };\n\t\t23EEDC25217DFADC006E9E73 /* SyntaxSelectCore.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = SyntaxSelectCore.hpp; sourceTree = \"<group>\"; };\n\t\t23EEDC26217DFADC006E9E73 /* SyntaxTableConstraint.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SyntaxTableConstraint.cpp; sourceTree = \"<group>\"; };\n\t\t23EEDC27217DFADC006E9E73 /* SyntaxTableConstraint.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = SyntaxTableConstraint.hpp; sourceTree = \"<group>\"; };\n\t\t23EEDC28217DFADC006E9E73 /* SyntaxTableOrSubquery.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SyntaxTableOrSubquery.cpp; sourceTree = \"<group>\"; };\n\t\t23EEDC29217DFADC006E9E73 /* SyntaxTableOrSubquery.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = SyntaxTableOrSubquery.hpp; sourceTree = \"<group>\"; };\n\t\t23EEDC2A217DFADC006E9E73 /* SyntaxUpsertClause.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SyntaxUpsertClause.cpp; sourceTree = \"<group>\"; };\n\t\t23EEDC2B217DFADC006E9E73 /* SyntaxUpsertClause.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = SyntaxUpsertClause.hpp; sourceTree = \"<group>\"; };\n\t\t23EEDC2C217DFADC006E9E73 /* SyntaxWindowDef.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SyntaxWindowDef.cpp; sourceTree = \"<group>\"; };\n\t\t23EEDC2D217DFADC006E9E73 /* SyntaxWindowDef.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = SyntaxWindowDef.hpp; sourceTree = \"<group>\"; };\n\t\t23EEDC31217DFADC006E9E73 /* SyntaxAlterTableSTMT.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SyntaxAlterTableSTMT.cpp; sourceTree = \"<group>\"; };\n\t\t23EEDC32217DFADC006E9E73 /* SyntaxAlterTableSTMT.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = SyntaxAlterTableSTMT.hpp; sourceTree = \"<group>\"; };\n\t\t23EEDC33217DFADC006E9E73 /* SyntaxAnalyzeSTMT.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SyntaxAnalyzeSTMT.cpp; sourceTree = \"<group>\"; };\n\t\t23EEDC34217DFADC006E9E73 /* SyntaxAnalyzeSTMT.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = SyntaxAnalyzeSTMT.hpp; sourceTree = \"<group>\"; };\n\t\t23EEDC35217DFADC006E9E73 /* SyntaxAttachSTMT.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SyntaxAttachSTMT.cpp; sourceTree = \"<group>\"; };\n\t\t23EEDC36217DFADC006E9E73 /* SyntaxAttachSTMT.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = SyntaxAttachSTMT.hpp; sourceTree = \"<group>\"; };\n\t\t23EEDC37217DFADC006E9E73 /* SyntaxBeginSTMT.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SyntaxBeginSTMT.cpp; sourceTree = \"<group>\"; };\n\t\t23EEDC38217DFADC006E9E73 /* SyntaxBeginSTMT.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = SyntaxBeginSTMT.hpp; sourceTree = \"<group>\"; };\n\t\t23EEDC39217DFADC006E9E73 /* SyntaxCommitSTMT.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SyntaxCommitSTMT.cpp; sourceTree = \"<group>\"; };\n\t\t23EEDC3A217DFADC006E9E73 /* SyntaxCommitSTMT.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = SyntaxCommitSTMT.hpp; sourceTree = \"<group>\"; };\n\t\t23EEDC3B217DFADC006E9E73 /* SyntaxCreateIndexSTMT.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SyntaxCreateIndexSTMT.cpp; sourceTree = \"<group>\"; };\n\t\t23EEDC3C217DFADC006E9E73 /* SyntaxCreateIndexSTMT.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = SyntaxCreateIndexSTMT.hpp; sourceTree = \"<group>\"; };\n\t\t23EEDC3D217DFADC006E9E73 /* SyntaxCreateTableSTMT.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SyntaxCreateTableSTMT.cpp; sourceTree = \"<group>\"; };\n\t\t23EEDC3E217DFADC006E9E73 /* SyntaxCreateTableSTMT.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = SyntaxCreateTableSTMT.hpp; sourceTree = \"<group>\"; };\n\t\t23EEDC3F217DFADC006E9E73 /* SyntaxCreateTriggerSTMT.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SyntaxCreateTriggerSTMT.cpp; sourceTree = \"<group>\"; };\n\t\t23EEDC40217DFADC006E9E73 /* SyntaxCreateTriggerSTMT.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = SyntaxCreateTriggerSTMT.hpp; sourceTree = \"<group>\"; };\n\t\t23EEDC41217DFADC006E9E73 /* SyntaxCreateViewSTMT.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SyntaxCreateViewSTMT.cpp; sourceTree = \"<group>\"; };\n\t\t23EEDC42217DFADC006E9E73 /* SyntaxCreateViewSTMT.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = SyntaxCreateViewSTMT.hpp; sourceTree = \"<group>\"; };\n\t\t23EEDC43217DFADC006E9E73 /* SyntaxCreateVirtualTableSTMT.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SyntaxCreateVirtualTableSTMT.cpp; sourceTree = \"<group>\"; };\n\t\t23EEDC44217DFADC006E9E73 /* SyntaxCreateVirtualTableSTMT.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = SyntaxCreateVirtualTableSTMT.hpp; sourceTree = \"<group>\"; };\n\t\t23EEDC45217DFADC006E9E73 /* SyntaxDeleteSTMT.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SyntaxDeleteSTMT.cpp; sourceTree = \"<group>\"; };\n\t\t23EEDC46217DFADC006E9E73 /* SyntaxDeleteSTMT.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = SyntaxDeleteSTMT.hpp; sourceTree = \"<group>\"; };\n\t\t23EEDC47217DFADC006E9E73 /* SyntaxDetachSTMT.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SyntaxDetachSTMT.cpp; sourceTree = \"<group>\"; };\n\t\t23EEDC48217DFADC006E9E73 /* SyntaxDetachSTMT.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = SyntaxDetachSTMT.hpp; sourceTree = \"<group>\"; };\n\t\t23EEDC49217DFADC006E9E73 /* SyntaxDropIndexSTMT.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SyntaxDropIndexSTMT.cpp; sourceTree = \"<group>\"; };\n\t\t23EEDC4A217DFADC006E9E73 /* SyntaxDropIndexSTMT.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = SyntaxDropIndexSTMT.hpp; sourceTree = \"<group>\"; };\n\t\t23EEDC4B217DFADC006E9E73 /* SyntaxDropTableSTMT.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SyntaxDropTableSTMT.cpp; sourceTree = \"<group>\"; };\n\t\t23EEDC4C217DFADC006E9E73 /* SyntaxDropTableSTMT.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = SyntaxDropTableSTMT.hpp; sourceTree = \"<group>\"; };\n\t\t23EEDC4D217DFADC006E9E73 /* SyntaxDropTriggerSTMT.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SyntaxDropTriggerSTMT.cpp; sourceTree = \"<group>\"; };\n\t\t23EEDC4E217DFADC006E9E73 /* SyntaxDropTriggerSTMT.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = SyntaxDropTriggerSTMT.hpp; sourceTree = \"<group>\"; };\n\t\t23EEDC4F217DFADC006E9E73 /* SyntaxDropViewSTMT.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SyntaxDropViewSTMT.cpp; sourceTree = \"<group>\"; };\n\t\t23EEDC50217DFADC006E9E73 /* SyntaxDropViewSTMT.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = SyntaxDropViewSTMT.hpp; sourceTree = \"<group>\"; };\n\t\t23EEDC51217DFADC006E9E73 /* SyntaxInsertSTMT.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SyntaxInsertSTMT.cpp; sourceTree = \"<group>\"; };\n\t\t23EEDC52217DFADC006E9E73 /* SyntaxInsertSTMT.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = SyntaxInsertSTMT.hpp; sourceTree = \"<group>\"; };\n\t\t23EEDC53217DFADC006E9E73 /* SyntaxPragmaSTMT.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SyntaxPragmaSTMT.cpp; sourceTree = \"<group>\"; };\n\t\t23EEDC54217DFADC006E9E73 /* SyntaxPragmaSTMT.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = SyntaxPragmaSTMT.hpp; sourceTree = \"<group>\"; };\n\t\t23EEDC55217DFADC006E9E73 /* SyntaxReindexSTMT.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SyntaxReindexSTMT.cpp; sourceTree = \"<group>\"; };\n\t\t23EEDC56217DFADC006E9E73 /* SyntaxReindexSTMT.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = SyntaxReindexSTMT.hpp; sourceTree = \"<group>\"; };\n\t\t23EEDC57217DFADC006E9E73 /* SyntaxReleaseSTMT.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SyntaxReleaseSTMT.cpp; sourceTree = \"<group>\"; };\n\t\t23EEDC58217DFADC006E9E73 /* SyntaxReleaseSTMT.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = SyntaxReleaseSTMT.hpp; sourceTree = \"<group>\"; };\n\t\t23EEDC59217DFADC006E9E73 /* SyntaxRollbackSTMT.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SyntaxRollbackSTMT.cpp; sourceTree = \"<group>\"; };\n\t\t23EEDC5A217DFADC006E9E73 /* SyntaxRollbackSTMT.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = SyntaxRollbackSTMT.hpp; sourceTree = \"<group>\"; };\n\t\t23EEDC5B217DFADC006E9E73 /* SyntaxSavepointSTMT.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SyntaxSavepointSTMT.cpp; sourceTree = \"<group>\"; };\n\t\t23EEDC5C217DFADC006E9E73 /* SyntaxSavepointSTMT.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = SyntaxSavepointSTMT.hpp; sourceTree = \"<group>\"; };\n\t\t23EEDC5D217DFADC006E9E73 /* SyntaxSelectSTMT.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SyntaxSelectSTMT.cpp; sourceTree = \"<group>\"; };\n\t\t23EEDC5E217DFADC006E9E73 /* SyntaxSelectSTMT.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = SyntaxSelectSTMT.hpp; sourceTree = \"<group>\"; };\n\t\t23EEDC5F217DFADC006E9E73 /* SyntaxUpdateSTMT.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SyntaxUpdateSTMT.cpp; sourceTree = \"<group>\"; };\n\t\t23EEDC60217DFADC006E9E73 /* SyntaxUpdateSTMT.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = SyntaxUpdateSTMT.hpp; sourceTree = \"<group>\"; };\n\t\t23EEDC61217DFADC006E9E73 /* SyntaxVacuumSTMT.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SyntaxVacuumSTMT.cpp; sourceTree = \"<group>\"; };\n\t\t23EEDC62217DFADC006E9E73 /* SyntaxVacuumSTMT.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = SyntaxVacuumSTMT.hpp; sourceTree = \"<group>\"; };\n\t\t23EEDC65217DFADC006E9E73 /* Syntax.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Syntax.h; sourceTree = \"<group>\"; };\n\t\t23EEDD5E217DFB16006E9E73 /* Enum.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = Enum.hpp; sourceTree = \"<group>\"; };\n\t\t23EEDD5F217DFB17006E9E73 /* Shadow.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = Shadow.hpp; sourceTree = \"<group>\"; };\n\t\t23F0FD7C215F1C92008399FB /* Security.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Security.framework; path = System/Library/Frameworks/Security.framework; sourceTree = SDKROOT; };\n\t\t23F0FEB1215F5E9A008399FB /* Lock.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = Lock.hpp; sourceTree = \"<group>\"; };\n\t\t23F0FEB2215F5E9A008399FB /* ThreadLocal.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = ThreadLocal.hpp; sourceTree = \"<group>\"; };\n\t\t23F0FEB3215F5E9A008399FB /* Lock.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Lock.cpp; sourceTree = \"<group>\"; };\n\t\t23F1698720B6638F009B5C47 /* ThreadedErrors.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = ThreadedErrors.hpp; sourceTree = \"<group>\"; };\n\t\t23F1698920B6638F009B5C47 /* ThreadedErrors.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ThreadedErrors.cpp; sourceTree = \"<group>\"; };\n\t\t23F340D8204D32C2007DB8AB /* WCTTable.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WCTTable.h; sourceTree = \"<group>\"; };\n\t\t23F340D9204D32C2007DB8AB /* WCTTable.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WCTTable.mm; sourceTree = \"<group>\"; };\n\t\t23F340DC204D3482007DB8AB /* WCTDatabase+ChainCall.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = \"WCTDatabase+ChainCall.h\"; sourceTree = \"<group>\"; };\n\t\t23F340DD204D3482007DB8AB /* WCTDatabase+ChainCall.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = \"WCTDatabase+ChainCall.mm\"; sourceTree = \"<group>\"; };\n\t\t23F70F79209FF0EC00CCE3CD /* WCTValue.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WCTValue.h; sourceTree = \"<group>\"; };\n\t\t23F70F7A209FF0EC00CCE3CD /* WCTValue.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = WCTValue.mm; sourceTree = \"<group>\"; };\n\t\t23F70F9F20A055B400CCE3CD /* Config.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = Config.hpp; sourceTree = \"<group>\"; };\n\t\t23F70FA420A055BD00CCE3CD /* BasicConfig.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = BasicConfig.cpp; sourceTree = \"<group>\"; };\n\t\t23F70FA520A055BD00CCE3CD /* BasicConfig.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = BasicConfig.hpp; sourceTree = \"<group>\"; };\n\t\t23F70FAA20A055C300CCE3CD /* CipherConfig.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = CipherConfig.cpp; sourceTree = \"<group>\"; };\n\t\t23F70FAB20A055C300CCE3CD /* CipherConfig.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = CipherConfig.hpp; sourceTree = \"<group>\"; };\n\t\t23F70FB620A055CF00CCE3CD /* AutoCheckpointConfig.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = AutoCheckpointConfig.cpp; sourceTree = \"<group>\"; };\n\t\t23F70FBC20A055D400CCE3CD /* TokenizerConfig.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = TokenizerConfig.cpp; sourceTree = \"<group>\"; };\n\t\t23F70FBD20A055D400CCE3CD /* TokenizerConfig.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = TokenizerConfig.hpp; sourceTree = \"<group>\"; };\n\t\t23F70FC320A0618100CCE3CD /* Configs.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = Configs.hpp; sourceTree = \"<group>\"; };\n\t\t23F70FD420A07CEC00CCE3CD /* CustomConfig.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = CustomConfig.cpp; sourceTree = \"<group>\"; };\n\t\t23F70FD520A07CEC00CCE3CD /* CustomConfig.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = CustomConfig.hpp; sourceTree = \"<group>\"; };\n\t\t23FEC461206B3032001E7A3B /* WCTConvenient.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WCTConvenient.h; sourceTree = \"<group>\"; };\n\t\t390E1C5A2296414C00C24598 /* Thread.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = Thread.cpp; sourceTree = \"<group>\"; };\n\t\t390E1C5B2296414C00C24598 /* Thread.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = Thread.hpp; sourceTree = \"<group>\"; };\n\t\t391F7C83225DE8FD0095E82D /* CommonCore.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CommonCore.h; sourceTree = \"<group>\"; };\n\t\t39327AAA22CEFD0F00AABD4B /* TableBenchmark.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = TableBenchmark.mm; sourceTree = \"<group>\"; };\n\t\t39327ABF22CF265600AABD4B /* RetrieveBenchmark.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = RetrieveBenchmark.mm; sourceTree = \"<group>\"; };\n\t\t39327AD522CF271D00AABD4B /* Benchmark.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = Benchmark.mm; sourceTree = \"<group>\"; };\n\t\t39327AD622CF271D00AABD4B /* BaseTestCase.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BaseTestCase.h; sourceTree = \"<group>\"; };\n\t\t39327AD722CF271D00AABD4B /* DatabaseTestCase.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DatabaseTestCase.h; sourceTree = \"<group>\"; };\n\t\t39327ADF22CF271D00AABD4B /* TestCase.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TestCase.h; sourceTree = \"<group>\"; };\n\t\t39327AE022CF271E00AABD4B /* TableTestCase.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TableTestCase.h; sourceTree = \"<group>\"; };\n\t\t39327AE122CF271E00AABD4B /* CRUDTestCase.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CRUDTestCase.h; sourceTree = \"<group>\"; };\n\t\t39327AE222CF271E00AABD4B /* BaseTestCase.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = BaseTestCase.mm; sourceTree = \"<group>\"; };\n\t\t39327AE322CF271E00AABD4B /* DatabaseTestCase.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = DatabaseTestCase.mm; sourceTree = \"<group>\"; };\n\t\t39327AE422CF271E00AABD4B /* CRUDTestCase.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = CRUDTestCase.mm; sourceTree = \"<group>\"; };\n\t\t39327AE522CF271E00AABD4B /* TableTestCase.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = TableTestCase.mm; sourceTree = \"<group>\"; };\n\t\t39327AED22CF271E00AABD4B /* Benchmark.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Benchmark.h; sourceTree = \"<group>\"; };\n\t\t39327B4B22CF275000AABD4B /* NSObject+TestCase.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = \"NSObject+TestCase.mm\"; sourceTree = \"<group>\"; };\n\t\t39327B4C22CF275000AABD4B /* TestCaseMacro.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TestCaseMacro.h; sourceTree = \"<group>\"; };\n\t\t39327B4D22CF275000AABD4B /* NSObject+TestCase.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = \"NSObject+TestCase.h\"; sourceTree = \"<group>\"; };\n\t\t39327B4E22CF275000AABD4B /* Signpost.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = Signpost.mm; sourceTree = \"<group>\"; };\n\t\t39327B4F22CF275000AABD4B /* Dispatch.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = Dispatch.mm; sourceTree = \"<group>\"; };\n\t\t39327B5022CF275100AABD4B /* TestCaseAssertion.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TestCaseAssertion.h; sourceTree = \"<group>\"; };\n\t\t39327B5122CF275100AABD4B /* Signpost.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Signpost.h; sourceTree = \"<group>\"; };\n\t\t39327B5222CF275100AABD4B /* TestCaseResult.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = TestCaseResult.mm; sourceTree = \"<group>\"; };\n\t\t39327B5322CF275100AABD4B /* TestCaseCounter.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = TestCaseCounter.mm; sourceTree = \"<group>\"; };\n\t\t39327B5422CF275100AABD4B /* TestCaseLog.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = TestCaseLog.mm; sourceTree = \"<group>\"; };\n\t\t39327B5522CF275100AABD4B /* WCTDatabase+TestCase.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = \"WCTDatabase+TestCase.mm\"; sourceTree = \"<group>\"; };\n\t\t39327B5622CF275100AABD4B /* TestCaseLog.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TestCaseLog.h; sourceTree = \"<group>\"; };\n\t\t39327B5722CF275100AABD4B /* Dispatch.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Dispatch.h; sourceTree = \"<group>\"; };\n\t\t39327B5822CF275100AABD4B /* TestCaseCounter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TestCaseCounter.h; sourceTree = \"<group>\"; };\n\t\t39327B5922CF275200AABD4B /* TestCaseResult.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TestCaseResult.h; sourceTree = \"<group>\"; };\n\t\t39327B5A22CF275200AABD4B /* WCTDatabase+TestCase.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = \"WCTDatabase+TestCase.h\"; sourceTree = \"<group>\"; };\n\t\t39327B7722CF275800AABD4B /* Random+TestCaseObject.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = \"Random+TestCaseObject.mm\"; sourceTree = \"<group>\"; };\n\t\t39327B7822CF275800AABD4B /* Random+WCDB.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = \"Random+WCDB.h\"; sourceTree = \"<group>\"; };\n\t\t39327B7922CF275800AABD4B /* Random+WCDB.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = \"Random+WCDB.mm\"; sourceTree = \"<group>\"; };\n\t\t39327B7A22CF275800AABD4B /* Random.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = Random.mm; sourceTree = \"<group>\"; };\n\t\t39327B7B22CF275800AABD4B /* Random.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Random.h; sourceTree = \"<group>\"; };\n\t\t39327B7C22CF275800AABD4B /* Random+TestCaseObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = \"Random+TestCaseObject.h\"; sourceTree = \"<group>\"; };\n\t\t39327B8922CF275F00AABD4B /* TestCaseObject.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = TestCaseObject.mm; sourceTree = \"<group>\"; };\n\t\t39327B8A22CF275F00AABD4B /* AllTypesObject+WCTTableCoding.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = \"AllTypesObject+WCTTableCoding.h\"; sourceTree = \"<group>\"; };\n\t\t39327B8B22CF275F00AABD4B /* AllTypesObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AllTypesObject.h; sourceTree = \"<group>\"; };\n\t\t39327B8C22CF275F00AABD4B /* TestCaseObject+WCTTableCoding.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = \"TestCaseObject+WCTTableCoding.h\"; sourceTree = \"<group>\"; };\n\t\t39327B8D22CF275F00AABD4B /* AllTypesObject.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = AllTypesObject.mm; sourceTree = \"<group>\"; };\n\t\t39327B8E22CF276000AABD4B /* TestCaseObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TestCaseObject.h; sourceTree = \"<group>\"; };\n\t\t39327B9722CF276600AABD4B /* ObjectsBasedFactory.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ObjectsBasedFactory.mm; sourceTree = \"<group>\"; };\n\t\t39327B9822CF276600AABD4B /* PrototypeFactory.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PrototypeFactory.h; sourceTree = \"<group>\"; };\n\t\t39327B9922CF276600AABD4B /* PrototypeFactory.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = PrototypeFactory.mm; sourceTree = \"<group>\"; };\n\t\t39327B9A22CF276600AABD4B /* ObjectsBasedFactory.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ObjectsBasedFactory.h; sourceTree = \"<group>\"; };\n\t\t39327B9B22CF276600AABD4B /* SizeBasedFactory.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = SizeBasedFactory.mm; sourceTree = \"<group>\"; };\n\t\t39327B9C22CF276600AABD4B /* SizeBasedFactory.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SizeBasedFactory.h; sourceTree = \"<group>\"; };\n\t\t39327B9D22CF276600AABD4B /* TablesBasedFactory.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TablesBasedFactory.h; sourceTree = \"<group>\"; };\n\t\t39327B9E22CF276600AABD4B /* TablesBasedFactory.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = TablesBasedFactory.mm; sourceTree = \"<group>\"; };\n\t\t39327BAF22CF2C5400AABD4B /* MigrationBenchmark.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MigrationBenchmark.h; sourceTree = \"<group>\"; };\n\t\t39327BB022CF2C5400AABD4B /* MigrationBenchmark.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MigrationBenchmark.mm; sourceTree = \"<group>\"; };\n\t\t39327BB122CF2C5400AABD4B /* TableMigrationBenchmark.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = TableMigrationBenchmark.mm; sourceTree = \"<group>\"; };\n\t\t39327BB222CF2C5400AABD4B /* DatabaseMigrationBenchmark.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = DatabaseMigrationBenchmark.mm; sourceTree = \"<group>\"; };\n\t\t3932B9FC25232D9F0094F3F8 /* WCTColumnCoding.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WCTColumnCoding.h; sourceTree = \"<group>\"; };\n\t\t3934DAE9229B6659008A6AEC /* OperationQueue.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = OperationQueue.cpp; sourceTree = \"<group>\"; };\n\t\t3934DAEA229B6659008A6AEC /* OperationQueue.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = OperationQueue.hpp; sourceTree = \"<group>\"; };\n\t\t3934DB25229B951C008A6AEC /* AutoCheckpointConfig.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = AutoCheckpointConfig.hpp; sourceTree = \"<group>\"; };\n\t\t39411A3E22437E7B00A388F5 /* CaseInsensitiveList.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = CaseInsensitiveList.hpp; sourceTree = \"<group>\"; };\n\t\t39579856227FBC8A0069F985 /* WCTDatabase+Test.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = \"WCTDatabase+Test.h\"; sourceTree = \"<group>\"; };\n\t\t39579857227FBC8A0069F985 /* WCTDatabase+Test.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = \"WCTDatabase+Test.mm\"; sourceTree = \"<group>\"; };\n\t\t3960D8992319258B00EF05D1 /* SyntaxExplainSTMT.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = SyntaxExplainSTMT.cpp; sourceTree = \"<group>\"; };\n\t\t3960D89A2319258B00EF05D1 /* SyntaxExplainSTMT.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = SyntaxExplainSTMT.hpp; sourceTree = \"<group>\"; };\n\t\t3960D89D2319288C00EF05D1 /* StatementExplain.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = StatementExplain.cpp; sourceTree = \"<group>\"; };\n\t\t3960D89E2319288C00EF05D1 /* StatementExplain.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = StatementExplain.hpp; sourceTree = \"<group>\"; };\n\t\t3960D8A123192A9D00EF05D1 /* StatementExplainTests.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = StatementExplainTests.mm; sourceTree = \"<group>\"; };\n\t\t3962FFC723051429008934D4 /* Statement.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = Statement.cpp; sourceTree = \"<group>\"; };\n\t\t3962FFC9230514CD008934D4 /* WCTBaseAccessor.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = WCTBaseAccessor.mm; sourceTree = \"<group>\"; };\n\t\t3962FFCE23051F71008934D4 /* Configs.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = Configs.cpp; sourceTree = \"<group>\"; };\n\t\t3969018A233B1B2F006EEFD4 /* WCTTag.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WCTTag.h; sourceTree = \"<group>\"; };\n\t\t3969018E233B20BC006EEFD4 /* WCTTableProtocol.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WCTTableProtocol.h; sourceTree = \"<group>\"; };\n\t\t39690192233B2235006EEFD4 /* WCTTable+Table.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = \"WCTTable+Table.h\"; sourceTree = \"<group>\"; };\n\t\t39690193233B2235006EEFD4 /* WCTTable+Table.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = \"WCTTable+Table.mm\"; sourceTree = \"<group>\"; };\n\t\t3995150622C2095B008394CC /* WCTOptional.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = WCTOptional.mm; sourceTree = \"<group>\"; };\n\t\t39A3341722B0DD9F008EA5D5 /* WCTFoundation.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WCTFoundation.h; sourceTree = \"<group>\"; };\n\t\t39A3341822B0DD9F008EA5D5 /* WCTFoundation.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = WCTFoundation.mm; sourceTree = \"<group>\"; };\n\t\t39B524DB2304F9A1001DF52D /* InnerHandle.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = InnerHandle.hpp; sourceTree = \"<group>\"; };\n\t\t39B524DC2304F9A2001DF52D /* InnerHandle.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InnerHandle.cpp; sourceTree = \"<group>\"; };\n\t\t39C70CC52313E20E002D773C /* Assemble.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Assemble.cpp; sourceTree = \"<group>\"; };\n\t\t39C70CC62313E20F002D773C /* Assemble.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = Assemble.hpp; sourceTree = \"<group>\"; };\n\t\t3C9A56E02EB44B9D00DA1C6E /* WCDBSwift.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = WCDBSwift.xcconfig; sourceTree = \"<group>\"; };\n\t\t7500829229223463009C0F38 /* WCTBridgeMacro.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WCTBridgeMacro.h; sourceTree = \"<group>\"; };\n\t\t75067CBD293F8192005DA25B /* AutoAddColumnObject.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = AutoAddColumnObject.mm; sourceTree = \"<group>\"; };\n\t\t75067CBF293F819B005DA25B /* AutoAddColumnObject.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AutoAddColumnObject.h; sourceTree = \"<group>\"; };\n\t\t75067CC0293F82B4005DA25B /* AutoAddColumnTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AutoAddColumnTests.swift; sourceTree = \"<group>\"; };\n\t\t75067CC2293F8300005DA25B /* DatabaseTestCase.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DatabaseTestCase.swift; sourceTree = \"<group>\"; };\n\t\t750DC0692913DE7300F19044 /* FTSBridge.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = FTSBridge.cpp; sourceTree = \"<group>\"; };\n\t\t750DC06A2913DE7300F19044 /* FTSBridge.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = FTSBridge.h; sourceTree = \"<group>\"; };\n\t\t7511EA4E293CDAE700FB033B /* NewPropertyObject.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = NewPropertyObject.h; sourceTree = \"<group>\"; };\n\t\t7511EA4F293CDAFB00FB033B /* NewPropertyObject.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = NewPropertyObject.mm; sourceTree = \"<group>\"; };\n\t\t7511EA52293CF7CA00FB033B /* CPPNewFieldObject.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CPPNewFieldObject.h; sourceTree = \"<group>\"; };\n\t\t75195E802852454700EC8C1F /* FrameSpecTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FrameSpecTests.swift; sourceTree = \"<group>\"; };\n\t\t751CA67228C6491A00874A7A /* CPPFieldObject.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CPPFieldObject.h; sourceTree = \"<group>\"; };\n\t\t751CA67528C64B7B00874A7A /* CPPAllTypesObject.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = CPPAllTypesObject.mm; sourceTree = \"<group>\"; };\n\t\t751CA67628C64B7B00874A7A /* CPPAllTypesObject.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CPPAllTypesObject.h; sourceTree = \"<group>\"; };\n\t\t751FE4E62B1E10F200BFC7AD /* CompressingCRUDTest.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = CompressingCRUDTest.mm; sourceTree = \"<group>\"; };\n\t\t75204AE7283FD6DC0002E40C /* Schema.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Schema.swift; sourceTree = \"<group>\"; };\n\t\t75204AE9283FD7410002E40C /* SchemaBridge.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = SchemaBridge.cpp; sourceTree = \"<group>\"; };\n\t\t75204AEA283FD7410002E40C /* SchemaBridge.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SchemaBridge.h; sourceTree = \"<group>\"; };\n\t\t7521D39028BD1187009C33D0 /* ChainCall.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = ChainCall.cpp; sourceTree = \"<group>\"; };\n\t\t7521D39128BD1187009C33D0 /* ChainCall.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = ChainCall.hpp; sourceTree = \"<group>\"; };\n\t\t7521D6B6291E6DFC009642EF /* WCDBSwift.modulemap */ = {isa = PBXFileReference; lastKnownFileType = \"sourcecode.module-map\"; path = WCDBSwift.modulemap; sourceTree = \"<group>\"; };\n\t\t7521DA47291E9ABB009642EF /* WCDBObjc.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = WCDBObjc.framework; sourceTree = BUILT_PRODUCTS_DIR; };\n\t\t7521DA49291E9D9E009642EF /* WCDBCpp.modulemap */ = {isa = PBXFileReference; lastKnownFileType = \"sourcecode.module-map\"; path = WCDBCpp.modulemap; sourceTree = \"<group>\"; };\n\t\t7521DA4A291E9D9E009642EF /* WCDBObjc.modulemap */ = {isa = PBXFileReference; lastKnownFileType = \"sourcecode.module-map\"; path = WCDBObjc.modulemap; sourceTree = \"<group>\"; };\n\t\t7521DDDD291EA349009642EF /* WCDBSwift.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = WCDBSwift.framework; sourceTree = BUILT_PRODUCTS_DIR; };\n\t\t7521DDE429209B8D009642EF /* ChainCall+WCTTableCoding.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = \"ChainCall+WCTTableCoding.swift\"; sourceTree = \"<group>\"; };\n\t\t7521DDE729209C90009642EF /* Handle+WCTTableCoding.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = \"Handle+WCTTableCoding.swift\"; sourceTree = \"<group>\"; };\n\t\t7521DDEA29209D04009642EF /* Insert+WCTTableCoding.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = \"Insert+WCTTableCoding.swift\"; sourceTree = \"<group>\"; };\n\t\t7521DDED29209DCE009642EF /* Update+WCTTableCoding.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = \"Update+WCTTableCoding.swift\"; sourceTree = \"<group>\"; };\n\t\t7521DDEF29209E4E009642EF /* Select+WCTTableCoding.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = \"Select+WCTTableCoding.swift\"; sourceTree = \"<group>\"; };\n\t\t7521DDF129209F45009642EF /* StatementInterface+WCTTableCoding.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = \"StatementInterface+WCTTableCoding.swift\"; sourceTree = \"<group>\"; };\n\t\t7521DDF32920A0E3009642EF /* HandleStatement+WCTTableCoding.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = \"HandleStatement+WCTTableCoding.swift\"; sourceTree = \"<group>\"; };\n\t\t7521DDF52920A12E009642EF /* InsertInterface+WCTTableCoding.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = \"InsertInterface+WCTTableCoding.swift\"; sourceTree = \"<group>\"; };\n\t\t7521DDF72920A623009642EF /* Database+WCTTableCoding.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = \"Database+WCTTableCoding.swift\"; sourceTree = \"<group>\"; };\n\t\t7521DDF92920A680009642EF /* UpdateInterface+WCTTableCoding.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = \"UpdateInterface+WCTTableCoding.swift\"; sourceTree = \"<group>\"; };\n\t\t7522B4BE2A6D2EA900B465D6 /* MigrationTestObject.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MigrationTestObject.h; sourceTree = \"<group>\"; };\n\t\t7522B4C12A6D30B000B465D6 /* NormalMigrationSourceObject.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = NormalMigrationSourceObject.h; sourceTree = \"<group>\"; };\n\t\t7522B5162A6D38D800B465D6 /* NormalMigrationSourceObject.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = NormalMigrationSourceObject.mm; sourceTree = \"<group>\"; };\n\t\t7522B5182A6D3B2A00B465D6 /* IntegerPrimaryKeyMigrationSourceObject.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = IntegerPrimaryKeyMigrationSourceObject.h; sourceTree = \"<group>\"; };\n\t\t7522B5192A6D3B3300B465D6 /* IntegerPrimaryKeyMigrationSourceObject.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = IntegerPrimaryKeyMigrationSourceObject.mm; sourceTree = \"<group>\"; };\n\t\t7522B51C2A6D3C6C00B465D6 /* AutoIncrementMigrationSourceObject.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AutoIncrementMigrationSourceObject.h; sourceTree = \"<group>\"; };\n\t\t7522B51D2A6D3C8600B465D6 /* AutoIncrementMigrationSourceObject.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = AutoIncrementMigrationSourceObject.mm; sourceTree = \"<group>\"; };\n\t\t7522B51F2A6D591A00B465D6 /* MigrationTestCase.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MigrationTestCase.h; sourceTree = \"<group>\"; };\n\t\t7522B5202A6D592800B465D6 /* MigrationTestCase.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = MigrationTestCase.mm; sourceTree = \"<group>\"; };\n\t\t7522B5222A6D5DCA00B465D6 /* Random+MigrationTestObject.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = \"Random+MigrationTestObject.h\"; sourceTree = \"<group>\"; };\n\t\t7522B5232A6D5DD600B465D6 /* Random+MigrationTestObject.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = \"Random+MigrationTestObject.mm\"; sourceTree = \"<group>\"; };\n\t\t7522B5262A6D6F6700B465D6 /* MigratingCRUDTests.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = MigratingCRUDTests.mm; sourceTree = \"<group>\"; };\n\t\t7522B5282A6D76DB00B465D6 /* MigrationTestSourceObject.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MigrationTestSourceObject.h; sourceTree = \"<group>\"; };\n\t\t7522B52B2A6D78BA00B465D6 /* AutoIncrementMigrationObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AutoIncrementMigrationObject.h; sourceTree = \"<group>\"; };\n\t\t7522B52C2A6D78BA00B465D6 /* NormalMigrationObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NormalMigrationObject.h; sourceTree = \"<group>\"; };\n\t\t7522B52D2A6D78BA00B465D6 /* IntegerPrimaryKeyMigrationObject.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = IntegerPrimaryKeyMigrationObject.mm; sourceTree = \"<group>\"; };\n\t\t7522B52E2A6D78BA00B465D6 /* IntegerPrimaryKeyMigrationObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IntegerPrimaryKeyMigrationObject.h; sourceTree = \"<group>\"; };\n\t\t7522B52F2A6D78BB00B465D6 /* NormalMigrationObject.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = NormalMigrationObject.mm; sourceTree = \"<group>\"; };\n\t\t7522B5302A6D78BB00B465D6 /* AutoIncrementMigrationObject.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = AutoIncrementMigrationObject.mm; sourceTree = \"<group>\"; };\n\t\t752517592B12D43700485175 /* DecompressFunction.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = DecompressFunction.cpp; sourceTree = \"<group>\"; };\n\t\t7525175A2B12D43700485175 /* DecompressFunction.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = DecompressFunction.hpp; sourceTree = \"<group>\"; };\n\t\t752517652B12F13C00485175 /* CompressionConst.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = CompressionConst.hpp; sourceTree = \"<group>\"; };\n\t\t7525176A2B12FDC700485175 /* ZSTDContext.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = ZSTDContext.cpp; sourceTree = \"<group>\"; };\n\t\t7525176B2B12FDC700485175 /* ZSTDContext.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = ZSTDContext.hpp; sourceTree = \"<group>\"; };\n\t\t752517742B132DAB00485175 /* CompressionConst.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = CompressionConst.cpp; sourceTree = \"<group>\"; };\n\t\t7525177F2B1338AF00485175 /* CompressionRecord.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = CompressionRecord.cpp; sourceTree = \"<group>\"; };\n\t\t752517802B1338AF00485175 /* CompressionRecord.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = CompressionRecord.hpp; sourceTree = \"<group>\"; };\n\t\t7525178B2B133DB700485175 /* CompressHandleOperator.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = CompressHandleOperator.cpp; sourceTree = \"<group>\"; };\n\t\t7525178C2B133DB700485175 /* CompressHandleOperator.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = CompressHandleOperator.hpp; sourceTree = \"<group>\"; };\n\t\t752594922851FCEF0068A602 /* RaiseFunctionTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RaiseFunctionTests.swift; sourceTree = \"<group>\"; };\n\t\t752594E3285226C00068A602 /* FrameSpecBridge.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = FrameSpecBridge.cpp; sourceTree = \"<group>\"; };\n\t\t752594E4285226C00068A602 /* FrameSpecBridge.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = FrameSpecBridge.h; sourceTree = \"<group>\"; };\n\t\t752594E728522A4A0068A602 /* FrameSpec.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FrameSpec.swift; sourceTree = \"<group>\"; };\n\t\t7525C1522920AB1900FD34C7 /* SelectInterface+WCTTableCoding.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = \"SelectInterface+WCTTableCoding.swift\"; sourceTree = \"<group>\"; };\n\t\t7525C1552920ACD700FD34C7 /* TableInterface+WCTTableCoding.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = \"TableInterface+WCTTableCoding.swift\"; sourceTree = \"<group>\"; };\n\t\t7525C1582920AD7900FD34C7 /* Table+WCTTableCoding.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = \"Table+WCTTableCoding.swift\"; sourceTree = \"<group>\"; };\n\t\t7525C15B2920D22300FD34C7 /* TableCRUDInterface+WCTTableCoding.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = \"TableCRUDInterface+WCTTableCoding.swift\"; sourceTree = \"<group>\"; };\n\t\t75294DAD29C75058005E7FC0 /* OperationQueueForMemory.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = OperationQueueForMemory.cpp; sourceTree = \"<group>\"; };\n\t\t75294DAE29C75058005E7FC0 /* OperationQueueForMemory.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = OperationQueueForMemory.hpp; sourceTree = \"<group>\"; };\n\t\t752C7E3C28C8E16800C9FFA6 /* ORMDeleteTests.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = ORMDeleteTests.mm; sourceTree = \"<group>\"; };\n\t\t752C7E3F28C8E94200C9FFA6 /* ORMInsertTests.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = ORMInsertTests.mm; sourceTree = \"<group>\"; };\n\t\t752CF3F6293A490F009ED8FB /* BindingBridge.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = BindingBridge.cpp; sourceTree = \"<group>\"; };\n\t\t752CF3F7293A490F009ED8FB /* BindingBridge.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = BindingBridge.h; sourceTree = \"<group>\"; };\n\t\t7533CB4D2B050FA300C8B47D /* MigratingHandleDecorator.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = MigratingHandleDecorator.cpp; sourceTree = \"<group>\"; };\n\t\t7533CB4E2B050FA300C8B47D /* MigratingHandleDecorator.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = MigratingHandleDecorator.hpp; sourceTree = \"<group>\"; };\n\t\t7533CB572B050FB200C8B47D /* MigratingStatementDecorator.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = MigratingStatementDecorator.cpp; sourceTree = \"<group>\"; };\n\t\t7533CB582B050FB200C8B47D /* MigratingStatementDecorator.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = MigratingStatementDecorator.hpp; sourceTree = \"<group>\"; };\n\t\t7533CB632B051C4F00C8B47D /* ClassDecorator.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = ClassDecorator.hpp; sourceTree = \"<group>\"; };\n\t\t7534735F2935C1E400911FCA /* DatabaseTestCase.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DatabaseTestCase.swift; sourceTree = \"<group>\"; };\n\t\t753636DA28BBC3820025C2C4 /* Table.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = Table.cpp; sourceTree = \"<group>\"; };\n\t\t753636DB28BBC3820025C2C4 /* Table.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = Table.hpp; sourceTree = \"<group>\"; };\n\t\t7537E58428B91F510077D92B /* Accessor.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = Accessor.cpp; sourceTree = \"<group>\"; };\n\t\t7537E5CF28B939240077D92B /* BaseBinding.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = BaseBinding.cpp; sourceTree = \"<group>\"; };\n\t\t7537E5D028B939240077D92B /* BaseBinding.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = BaseBinding.hpp; sourceTree = \"<group>\"; };\n\t\t753C084928A8B0110042C427 /* CPPDatabaseTest.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = CPPDatabaseTest.mm; sourceTree = \"<group>\"; };\n\t\t753C084C28A8D4560042C427 /* StatementOperationTests.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = StatementOperationTests.mm; sourceTree = \"<group>\"; };\n\t\t753C084E28A8D5EB0042C427 /* CPPCRUDTestCase.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CPPCRUDTestCase.h; sourceTree = \"<group>\"; };\n\t\t753C084F28A8D5F70042C427 /* CPPCRUDTestCase.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = CPPCRUDTestCase.mm; sourceTree = \"<group>\"; };\n\t\t754014C2290BEDA600EA8D33 /* FTSConst.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = FTSConst.h; sourceTree = \"<group>\"; };\n\t\t754211DA2B11FE9200A2FF4D /* ScalarFunctionModule.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = ScalarFunctionModule.cpp; sourceTree = \"<group>\"; };\n\t\t754211DB2B11FE9200A2FF4D /* ScalarFunctionModule.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = ScalarFunctionModule.hpp; sourceTree = \"<group>\"; };\n\t\t754211E92B12331900A2FF4D /* FunctionModules.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = FunctionModules.hpp; sourceTree = \"<group>\"; };\n\t\t754211F32B12359400A2FF4D /* ScalarFunctionConfig.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = ScalarFunctionConfig.cpp; sourceTree = \"<group>\"; };\n\t\t754211F42B12359400A2FF4D /* ScalarFunctionConfig.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = ScalarFunctionConfig.hpp; sourceTree = \"<group>\"; };\n\t\t754211FE2B123E3200A2FF4D /* ScalarFunctionTemplate.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = ScalarFunctionTemplate.hpp; sourceTree = \"<group>\"; };\n\t\t7542120A2B124CFF00A2FF4D /* CompressionCenter.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CompressionCenter.cpp; sourceTree = \"<group>\"; };\n\t\t7542120B2B124CFF00A2FF4D /* ZSTDDict.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ZSTDDict.cpp; sourceTree = \"<group>\"; };\n\t\t7542120C2B124CFF00A2FF4D /* CompressionInfo.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CompressionInfo.cpp; sourceTree = \"<group>\"; };\n\t\t7542120D2B124CFF00A2FF4D /* Compression.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Compression.cpp; sourceTree = \"<group>\"; };\n\t\t7542120E2B124CFF00A2FF4D /* CompressionCenter.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = CompressionCenter.hpp; sourceTree = \"<group>\"; };\n\t\t7542120F2B124CFF00A2FF4D /* ZSTDDict.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = ZSTDDict.hpp; sourceTree = \"<group>\"; };\n\t\t754212102B124CFF00A2FF4D /* CompressionInfo.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = CompressionInfo.hpp; sourceTree = \"<group>\"; };\n\t\t754212112B124CFF00A2FF4D /* Compression.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = Compression.hpp; sourceTree = \"<group>\"; };\n\t\t754359442B066DBD00CDF232 /* HandleOperator.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = HandleOperator.cpp; sourceTree = \"<group>\"; };\n\t\t754359452B066DBD00CDF232 /* HandleOperator.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = HandleOperator.hpp; sourceTree = \"<group>\"; };\n\t\t7543594E2B0671DE00CDF232 /* BackupHandleOperator.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = BackupHandleOperator.cpp; sourceTree = \"<group>\"; };\n\t\t7543594F2B0671DE00CDF232 /* BackupHandleOperator.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = BackupHandleOperator.hpp; sourceTree = \"<group>\"; };\n\t\t7543DD82271C2F3B00B533B4 /* FTS5AuxiliaryFunctionTemplate.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = FTS5AuxiliaryFunctionTemplate.hpp; sourceTree = \"<group>\"; };\n\t\t7543DD84271C2FD000B533B4 /* AuxiliaryFunctionModule.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = AuxiliaryFunctionModule.cpp; sourceTree = \"<group>\"; };\n\t\t7543DD85271C2FD000B533B4 /* AuxiliaryFunctionModule.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = AuxiliaryFunctionModule.hpp; sourceTree = \"<group>\"; };\n\t\t7543DD8C271C360E00B533B4 /* AuxiliaryFunctionConfig.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = AuxiliaryFunctionConfig.cpp; sourceTree = \"<group>\"; };\n\t\t7543DD8D271C360E00B533B4 /* AuxiliaryFunctionConfig.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = AuxiliaryFunctionConfig.hpp; sourceTree = \"<group>\"; };\n\t\t7543DD90271C601F00B533B4 /* SubstringMatchInfo.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = SubstringMatchInfo.cpp; sourceTree = \"<group>\"; };\n\t\t7543DD91271C601F00B533B4 /* SubstringMatchInfo.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = SubstringMatchInfo.hpp; sourceTree = \"<group>\"; };\n\t\t7543EDE2293B49CB00336DA9 /* ORMTestCase.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ORMTestCase.swift; sourceTree = \"<group>\"; };\n\t\t7547A3CE290D2B2600AFA132 /* CPPFTS3Tests.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = CPPFTS3Tests.mm; sourceTree = \"<group>\"; };\n\t\t75535242290E620F008376AB /* CPPFTS5Object.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = CPPFTS5Object.mm; sourceTree = \"<group>\"; };\n\t\t75535244290E621B008376AB /* CPPFTS5Object.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CPPFTS5Object.h; sourceTree = \"<group>\"; };\n\t\t75535245290E63E5008376AB /* CPPFTS5Tests.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = CPPFTS5Tests.mm; sourceTree = \"<group>\"; };\n\t\t755391D52403B3DB00036918 /* WCTPreparedStatement.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = WCTPreparedStatement.mm; sourceTree = \"<group>\"; };\n\t\t755391E02403CB9700036918 /* WCTPreparedStatement+Private.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = \"WCTPreparedStatement+Private.h\"; sourceTree = \"<group>\"; };\n\t\t756A773727F9EDCA00105B7C /* HandleStatementBridge.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = HandleStatementBridge.h; sourceTree = \"<group>\"; };\n\t\t756A773C27F9EDDE00105B7C /* HandleStatementBridge.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = HandleStatementBridge.cpp; sourceTree = \"<group>\"; };\n\t\t756A773F27FAC17F00105B7C /* CoreBridge.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CoreBridge.h; sourceTree = \"<group>\"; };\n\t\t756A774227FAC1D900105B7C /* CoreBridge.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = CoreBridge.cpp; sourceTree = \"<group>\"; };\n\t\t756F7F622B2CA4B5002AEA0A /* FactoryVacuum.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = FactoryVacuum.cpp; sourceTree = \"<group>\"; };\n\t\t756F7F632B2CA4B5002AEA0A /* FactoryVacuum.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = FactoryVacuum.hpp; sourceTree = \"<group>\"; };\n\t\t757457032402D614005E3682 /* WCTPreparedStatement.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WCTPreparedStatement.h; sourceTree = \"<group>\"; };\n\t\t757821DF286DF5EB0092F858 /* StatementCreateTableBridge.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = StatementCreateTableBridge.cpp; sourceTree = \"<group>\"; };\n\t\t757821E0286DF5EB0092F858 /* StatementCreateTableBridge.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = StatementCreateTableBridge.h; sourceTree = \"<group>\"; };\n\t\t7587F21B2EC2DF3300CC5224 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/iOSSupport/System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; };\n\t\t75882C7B28C7C2EF00F95947 /* CPPColumnConstraintPrimary.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = CPPColumnConstraintPrimary.cpp; sourceTree = \"<group>\"; };\n\t\t75882C7C28C7C2EF00F95947 /* CPPColumnConstraintPrimary.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = CPPColumnConstraintPrimary.hpp; sourceTree = \"<group>\"; };\n\t\t75882C7F28C7C3E600F95947 /* CPPColumnConstraintPrimaryAsc.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = CPPColumnConstraintPrimaryAsc.cpp; sourceTree = \"<group>\"; };\n\t\t75882C8028C7C3E600F95947 /* CPPColumnConstraintPrimaryAsc.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = CPPColumnConstraintPrimaryAsc.hpp; sourceTree = \"<group>\"; };\n\t\t75882C8228C7C4A300F95947 /* CPPColumnConstraintPrimaryDesc.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = CPPColumnConstraintPrimaryDesc.cpp; sourceTree = \"<group>\"; };\n\t\t75882C8328C7C4A300F95947 /* CPPColumnConstraintPrimaryDesc.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = CPPColumnConstraintPrimaryDesc.hpp; sourceTree = \"<group>\"; };\n\t\t75882C8528C7C55200F95947 /* CPPColumnConstraintAutoIncrement.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = CPPColumnConstraintAutoIncrement.cpp; sourceTree = \"<group>\"; };\n\t\t75882C8628C7C55200F95947 /* CPPColumnConstraintAutoIncrement.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = CPPColumnConstraintAutoIncrement.hpp; sourceTree = \"<group>\"; };\n\t\t75882C8828C7C60C00F95947 /* CPPColumnConstraintAutoIncrementAsc.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = CPPColumnConstraintAutoIncrementAsc.cpp; sourceTree = \"<group>\"; };\n\t\t75882C8928C7C60C00F95947 /* CPPColumnConstraintAutoIncrementAsc.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = CPPColumnConstraintAutoIncrementAsc.hpp; sourceTree = \"<group>\"; };\n\t\t75882C8B28C7C6CF00F95947 /* CPPColumnConstraintUnique.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = CPPColumnConstraintUnique.cpp; sourceTree = \"<group>\"; };\n\t\t75882C8C28C7C6CF00F95947 /* CPPColumnConstraintUnique.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = CPPColumnConstraintUnique.hpp; sourceTree = \"<group>\"; };\n\t\t75882C8E28C7C78200F95947 /* CPPColumnConstraintDefault.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = CPPColumnConstraintDefault.cpp; sourceTree = \"<group>\"; };\n\t\t75882C8F28C7C78200F95947 /* CPPColumnConstraintDefault.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = CPPColumnConstraintDefault.hpp; sourceTree = \"<group>\"; };\n\t\t758D9D0028BA6AF8001B3D2D /* HandleOperationTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = HandleOperationTests.mm; sourceTree = \"<group>\"; };\n\t\t758D9D0228BA7265001B3D2D /* CPPTableConstraintMacro.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CPPTableConstraintMacro.h; sourceTree = \"<group>\"; };\n\t\t758D9D0528BA7F06001B3D2D /* CPPColumnConstraintMacro.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CPPColumnConstraintMacro.h; sourceTree = \"<group>\"; };\n\t\t758D9D0828BA819A001B3D2D /* CPPVirtualTableMacro.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CPPVirtualTableMacro.h; sourceTree = \"<group>\"; };\n\t\t758DC8012B255EBF00E71D9B /* CompressionBenchmark.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = CompressionBenchmark.mm; sourceTree = \"<group>\"; };\n\t\t758DC8032B255EF900E71D9B /* CompressionBenchmark.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CompressionBenchmark.h; sourceTree = \"<group>\"; };\n\t\t758DC8042B25671E00E71D9B /* NormalCompressionBenchmark.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = NormalCompressionBenchmark.mm; sourceTree = \"<group>\"; };\n\t\t758DC8062B25678800E71D9B /* DictCompressionBenchmark.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = DictCompressionBenchmark.mm; sourceTree = \"<group>\"; };\n\t\t758E7EB62B1B24AD00319991 /* AutoCompressConfig.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = AutoCompressConfig.cpp; sourceTree = \"<group>\"; };\n\t\t758E7EB72B1B24AD00319991 /* AutoCompressConfig.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = AutoCompressConfig.hpp; sourceTree = \"<group>\"; };\n\t\t758E7EC12B1B41AA00319991 /* WCTCompressionInfo.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = WCTCompressionInfo.mm; sourceTree = \"<group>\"; };\n\t\t758E7EC62B1B41C500319991 /* WCTCompressionInfo.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WCTCompressionInfo.h; sourceTree = \"<group>\"; };\n\t\t758E7EC92B1B423200319991 /* WCTCompressionInfo+Private.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = \"WCTCompressionInfo+Private.h\"; sourceTree = \"<group>\"; };\n\t\t758E7ECC2B1B49E300319991 /* WCTDatabase+Compression.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = \"WCTDatabase+Compression.h\"; sourceTree = \"<group>\"; };\n\t\t758E7ECF2B1B49EF00319991 /* WCTDatabase+Compression.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = \"WCTDatabase+Compression.mm\"; sourceTree = \"<group>\"; };\n\t\t758E7F2F2B1C82EC00319991 /* CompressionTestObject.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = CompressionTestObject.mm; sourceTree = \"<group>\"; };\n\t\t758E7F322B1C830A00319991 /* CompressionTestObject.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CompressionTestObject.h; sourceTree = \"<group>\"; };\n\t\t758E7F372B1C85A900319991 /* Random+CompressionTestObject.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = \"Random+CompressionTestObject.h\"; sourceTree = \"<group>\"; };\n\t\t758E7F382B1C864700319991 /* Random+CompressionTestObject.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = \"Random+CompressionTestObject.mm\"; sourceTree = \"<group>\"; };\n\t\t758E7F3D2B1C99C700319991 /* CompressionTestCase.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = CompressionTestCase.mm; sourceTree = \"<group>\"; };\n\t\t758E7F3F2B1C99D200319991 /* CompressionTestCase.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CompressionTestCase.h; sourceTree = \"<group>\"; };\n\t\t759362CB2B368D87000AF163 /* VacuumBenchmark.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = VacuumBenchmark.mm; sourceTree = \"<group>\"; };\n\t\t759362CD2B36D450000AF163 /* Vacuum.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = Vacuum.cpp; sourceTree = \"<group>\"; };\n\t\t759362CE2B36D450000AF163 /* Vacuum.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = Vacuum.hpp; sourceTree = \"<group>\"; };\n\t\t759362D82B36D756000AF163 /* VacuumHandleOperator.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = VacuumHandleOperator.cpp; sourceTree = \"<group>\"; };\n\t\t759362D92B36D756000AF163 /* VacuumHandleOperator.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = VacuumHandleOperator.hpp; sourceTree = \"<group>\"; };\n\t\t7596162228BFB05100AE86BA /* CPPDeclaration.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CPPDeclaration.h; sourceTree = \"<group>\"; };\n\t\t75A46BFE284310CE00B58207 /* ColumnConstraintBridge.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = ColumnConstraintBridge.cpp; sourceTree = \"<group>\"; };\n\t\t75A46BFF284310CE00B58207 /* ColumnConstraintBridge.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ColumnConstraintBridge.h; sourceTree = \"<group>\"; };\n\t\t75A46C0228431D6300B58207 /* ForeignKeyBridge.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = ForeignKeyBridge.cpp; sourceTree = \"<group>\"; };\n\t\t75A46C0328431D6300B58207 /* ForeignKeyBridge.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ForeignKeyBridge.h; sourceTree = \"<group>\"; };\n\t\t75A46C062843273A00B58207 /* ColumnConstraint.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ColumnConstraint.swift; sourceTree = \"<group>\"; };\n\t\t75A46C0828432A5D00B58207 /* SyntaxConst.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SyntaxConst.swift; sourceTree = \"<group>\"; };\n\t\t75A46C0A2843709500B58207 /* ColumnConstraintTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ColumnConstraintTests.swift; sourceTree = \"<group>\"; };\n\t\t75A46C0C2843B3BC00B58207 /* OrderingTermBridge.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = OrderingTermBridge.h; sourceTree = \"<group>\"; };\n\t\t75A46C0D2843B3BC00B58207 /* OrderingTermBridge.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = OrderingTermBridge.cpp; sourceTree = \"<group>\"; };\n\t\t75A46C102843B73C00B58207 /* WinqBridge.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = WinqBridge.hpp; sourceTree = \"<group>\"; };\n\t\t75A60AAD29345A38009C1B3C /* Cipher.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = Cipher.cpp; sourceTree = \"<group>\"; };\n\t\t75A60AAE29345A38009C1B3C /* Cipher.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = Cipher.hpp; sourceTree = \"<group>\"; };\n\t\t75ADC5622A8D1C2D00D0AC47 /* TableAttribute.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = TableAttribute.cpp; sourceTree = \"<group>\"; };\n\t\t75ADC5632A8D1C2D00D0AC47 /* TableAttribute.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = TableAttribute.hpp; sourceTree = \"<group>\"; };\n\t\t75AF6AD528544C8800A7C43D /* TableOrSubqueryBridge.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = TableOrSubqueryBridge.cpp; sourceTree = \"<group>\"; };\n\t\t75AF6AD628544C8800A7C43D /* TableOrSubqueryBridge.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = TableOrSubqueryBridge.h; sourceTree = \"<group>\"; };\n\t\t75AF6AD92854C5ED00A7C43D /* JoinBridge.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = JoinBridge.cpp; sourceTree = \"<group>\"; };\n\t\t75AF6ADA2854C5ED00A7C43D /* JoinBridge.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = JoinBridge.h; sourceTree = \"<group>\"; };\n\t\t75AF6ADD2854EF6D00A7C43D /* QualifiedTableBridge.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = QualifiedTableBridge.cpp; sourceTree = \"<group>\"; };\n\t\t75AF6ADE2854EF6D00A7C43D /* QualifiedTableBridge.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = QualifiedTableBridge.h; sourceTree = \"<group>\"; };\n\t\t75AF6AE12854F19800A7C43D /* QualifiedTable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = QualifiedTable.swift; sourceTree = \"<group>\"; };\n\t\t75AF6AE32854F2FC00A7C43D /* QualifiedTableTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = QualifiedTableTests.swift; sourceTree = \"<group>\"; };\n\t\t75AF6AE7285594A100A7C43D /* ResultColumnBridge.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = ResultColumnBridge.cpp; sourceTree = \"<group>\"; };\n\t\t75AF6AE8285594A100A7C43D /* ResultColumnBridge.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ResultColumnBridge.h; sourceTree = \"<group>\"; };\n\t\t75AF6AEB28559F4800A7C43D /* TableConstraintBridge.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = TableConstraintBridge.cpp; sourceTree = \"<group>\"; };\n\t\t75AF6AEC28559F4800A7C43D /* TableConstraintBridge.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = TableConstraintBridge.h; sourceTree = \"<group>\"; };\n\t\t75AF6AEF2855C8BF00A7C43D /* UpsertBridge.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = UpsertBridge.cpp; sourceTree = \"<group>\"; };\n\t\t75AF6AF02855C8BF00A7C43D /* UpsertBridge.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = UpsertBridge.h; sourceTree = \"<group>\"; };\n\t\t75AF6AF32855CCDD00A7C43D /* Upsert.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Upsert.swift; sourceTree = \"<group>\"; };\n\t\t75AF6AF52855D21000A7C43D /* UpsertTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UpsertTests.swift; sourceTree = \"<group>\"; };\n\t\t75AF6AF82856303700A7C43D /* PragmaBridge.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = PragmaBridge.cpp; sourceTree = \"<group>\"; };\n\t\t75AF6AF92856303700A7C43D /* PragmaBridge.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PragmaBridge.h; sourceTree = \"<group>\"; };\n\t\t75B698D3290AD4C0006E1F8F /* BaseTokenizerUtil.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = BaseTokenizerUtil.cpp; sourceTree = \"<group>\"; };\n\t\t75B698D4290AD4C0006E1F8F /* BaseTokenizerUtil.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = BaseTokenizerUtil.hpp; sourceTree = \"<group>\"; };\n\t\t75C075332A8921C600B4A0D4 /* CPPHandleTest.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = CPPHandleTest.mm; sourceTree = \"<group>\"; };\n\t\t75C075352A8922CA00B4A0D4 /* HandleTest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HandleTest.swift; sourceTree = \"<group>\"; };\n\t\t75C1034028450D840006BBCB /* WindowDefBridge.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = WindowDefBridge.cpp; sourceTree = \"<group>\"; };\n\t\t75C1034128450D840006BBCB /* WindowDefBridge.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WindowDefBridge.h; sourceTree = \"<group>\"; };\n\t\t75C10344284530BF0006BBCB /* RaiseFunction.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RaiseFunction.swift; sourceTree = \"<group>\"; };\n\t\t75C17A9228D0D3DD009C342E /* TransactionInterface.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TransactionInterface.swift; sourceTree = \"<group>\"; };\n\t\t75C44093291CE12300D74EB7 /* ColumnConstraintConfig.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ColumnConstraintConfig.swift; sourceTree = \"<group>\"; };\n\t\t75C44095291CE1FB00D74EB7 /* TableConfiguration.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TableConfiguration.swift; sourceTree = \"<group>\"; };\n\t\t75C44097291CE24900D74EB7 /* IndexConfig.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = IndexConfig.swift; sourceTree = \"<group>\"; };\n\t\t75C44099291CE7E200D74EB7 /* MultiPrimaryConfig.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MultiPrimaryConfig.swift; sourceTree = \"<group>\"; };\n\t\t75C4409B291D0B4F00D74EB7 /* MultiUniqueConfig.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MultiUniqueConfig.swift; sourceTree = \"<group>\"; };\n\t\t75C4409D291D0C9C00D74EB7 /* CheckExpressionConfig.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CheckExpressionConfig.swift; sourceTree = \"<group>\"; };\n\t\t75C4409F291D108D00D74EB7 /* ForeignKeyConfig.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ForeignKeyConfig.swift; sourceTree = \"<group>\"; };\n\t\t75C440A1291D116C00D74EB7 /* VirtualTableConfig.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VirtualTableConfig.swift; sourceTree = \"<group>\"; };\n\t\t75C6E412299E80D3002579A5 /* WCDBOptional.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = WCDBOptional.hpp; sourceTree = \"<group>\"; };\n\t\t75C6E41629A0C2F0002579A5 /* WCDBOptional.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = WCDBOptional.cpp; sourceTree = \"<group>\"; };\n\t\t75CB08C92A88B9A300429364 /* HandleCounter.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = HandleCounter.cpp; sourceTree = \"<group>\"; };\n\t\t75CB08CA2A88B9A300429364 /* HandleCounter.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = HandleCounter.hpp; sourceTree = \"<group>\"; };\n\t\t75CD026028CECD610071B6C3 /* StatementInterface.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StatementInterface.swift; sourceTree = \"<group>\"; };\n\t\t75CD026828CF8DC00071B6C3 /* InsertInterface.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InsertInterface.swift; sourceTree = \"<group>\"; };\n\t\t75CD026A28CF8EF90071B6C3 /* UpdateInterface.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UpdateInterface.swift; sourceTree = \"<group>\"; };\n\t\t75CD026C28CF8F360071B6C3 /* DeleteInterface.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DeleteInterface.swift; sourceTree = \"<group>\"; };\n\t\t75CD026E28CF8F5F0071B6C3 /* SelectInterface.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SelectInterface.swift; sourceTree = \"<group>\"; };\n\t\t75CD027028CF900C0071B6C3 /* TableInterface.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TableInterface.swift; sourceTree = \"<group>\"; };\n\t\t75CD724D290D2449008583A3 /* CPPFTS3Object.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = CPPFTS3Object.mm; sourceTree = \"<group>\"; };\n\t\t75CD724E290D2449008583A3 /* CPPFTS3Object.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CPPFTS3Object.h; sourceTree = \"<group>\"; };\n\t\t75CE3EFD2812D95100E132F6 /* WCTAPIBridge.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WCTAPIBridge.h; sourceTree = \"<group>\"; };\n\t\t75CE3EFF2812E1A400E132F6 /* WCTAPIBridge.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = WCTAPIBridge.mm; sourceTree = \"<group>\"; };\n\t\t75CFB5DB293F30A200F97FA5 /* AutoAddColumnTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AutoAddColumnTests.swift; sourceTree = \"<group>\"; };\n\t\t75D2A9BC2AB49B2D0024B8B2 /* Random+RepairTestObject.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = \"Random+RepairTestObject.mm\"; sourceTree = \"<group>\"; };\n\t\t75D2A9BD2AB49B390024B8B2 /* Random+RepairTestObject.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = \"Random+RepairTestObject.h\"; sourceTree = \"<group>\"; };\n\t\t75D4834128A79AD3004FDD3C /* CPPTraceTest.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = CPPTraceTest.mm; sourceTree = \"<group>\"; };\n\t\t75D4834328A79CCE004FDD3C /* CPPTestCaseAssertion.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CPPTestCaseAssertion.h; sourceTree = \"<group>\"; };\n\t\t75D4834428A7A827004FDD3C /* CPPTableTestCase.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = CPPTableTestCase.mm; sourceTree = \"<group>\"; };\n\t\t75D4834628A7A83C004FDD3C /* CPPTableTestCase.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CPPTableTestCase.h; sourceTree = \"<group>\"; };\n\t\t75D4834728A7C422004FDD3C /* Random+CPPTestObject.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = \"Random+CPPTestObject.h\"; sourceTree = \"<group>\"; };\n\t\t75D4834828A7C42F004FDD3C /* Random+CPPTestObject.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = \"Random+CPPTestObject.mm\"; sourceTree = \"<group>\"; };\n\t\t75D566FA2951B7DE00098DD9 /* WCTSequence.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WCTSequence.h; sourceTree = \"<group>\"; };\n\t\t75D566FD2951B7EA00098DD9 /* WCTSequence.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = WCTSequence.mm; sourceTree = \"<group>\"; };\n\t\t75D567002951B80B00098DD9 /* WCTSequence+WCTTableCoding.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = \"WCTSequence+WCTTableCoding.h\"; sourceTree = \"<group>\"; };\n\t\t75D99B7F28CA441E00BEC8B5 /* BaseOperation.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = BaseOperation.hpp; sourceTree = \"<group>\"; };\n\t\t75D99B8228CA46A400BEC8B5 /* BaseOperation.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = BaseOperation.cpp; sourceTree = \"<group>\"; };\n\t\t75DF22932AEE8409006A3311 /* CPPInheritObject.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = CPPInheritObject.cpp; sourceTree = \"<group>\"; };\n\t\t75DF22942AEE8409006A3311 /* CPPInheritObject.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = CPPInheritObject.hpp; sourceTree = \"<group>\"; };\n\t\t75DF22992AEFF995006A3311 /* SharedPtrAccessor.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = SharedPtrAccessor.hpp; sourceTree = \"<group>\"; };\n\t\t75E0A5BF2A7F4EEE00D4FE9A /* CoreConst.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = CoreConst.cpp; sourceTree = \"<group>\"; };\n\t\t75E0A5D42A7FE2A200D4FE9A /* ContainerBridge.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = ContainerBridge.cpp; sourceTree = \"<group>\"; };\n\t\t75E0A5D52A7FE2A200D4FE9A /* ContainerBridge.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ContainerBridge.h; sourceTree = \"<group>\"; };\n\t\t75E29CAE2B2F2F20003340FF /* VacuumTests.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = VacuumTests.mm; sourceTree = \"<group>\"; };\n\t\t75E50A0929067BC800B73E62 /* MultiObject.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = MultiObject.cpp; sourceTree = \"<group>\"; };\n\t\t75E50A0A29067BC800B73E62 /* MultiObject.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = MultiObject.hpp; sourceTree = \"<group>\"; };\n\t\t75E50A2B2907921600B73E62 /* MultiSelect.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = MultiSelect.cpp; sourceTree = \"<group>\"; };\n\t\t75E50A2C2907921600B73E62 /* MultiSelect.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = MultiSelect.hpp; sourceTree = \"<group>\"; };\n\t\t75E50AC12908EC7100B73E62 /* ORMMultiSelectTests.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = ORMMultiSelectTests.mm; sourceTree = \"<group>\"; };\n\t\t75E76AD329161EE400073CCA /* FTSBridge.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FTSBridge.swift; sourceTree = \"<group>\"; };\n\t\t75E76ADF29176FA600073CCA /* TokenizerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TokenizerTests.swift; sourceTree = \"<group>\"; };\n\t\t75E76AE22917AE2A00073CCA /* CPPVirtualTableFTS4Object.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = CPPVirtualTableFTS4Object.cpp; sourceTree = \"<group>\"; };\n\t\t75E76AE32917AE2A00073CCA /* CPPVirtualTableFTS4Object.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = CPPVirtualTableFTS4Object.hpp; sourceTree = \"<group>\"; };\n\t\t75E76AE52917B07E00073CCA /* CPPVirtualTableFTS5Object.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = CPPVirtualTableFTS5Object.cpp; sourceTree = \"<group>\"; };\n\t\t75E76AE62917B07E00073CCA /* CPPVirtualTableFTS5Object.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = CPPVirtualTableFTS5Object.hpp; sourceTree = \"<group>\"; };\n\t\t75EABA082ADA4F2600AAD3C9 /* zstd.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = \"wrapper.pb-project\"; path = zstd.xcodeproj; sourceTree = \"<group>\"; };\n\t\t75EB1963287F068200AA62F7 /* StatementDropTriggerBridge.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = StatementDropTriggerBridge.cpp; sourceTree = \"<group>\"; };\n\t\t75EB1964287F068200AA62F7 /* StatementDropTriggerBridge.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = StatementDropTriggerBridge.h; sourceTree = \"<group>\"; };\n\t\t75EB1967287F078E00AA62F7 /* StatementDropTrigger.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StatementDropTrigger.swift; sourceTree = \"<group>\"; };\n\t\t75EB1969287F086D00AA62F7 /* StatementDropTriggerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StatementDropTriggerTests.swift; sourceTree = \"<group>\"; };\n\t\t75EB196C287F093B00AA62F7 /* StatementDropViewBridge.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = StatementDropViewBridge.cpp; sourceTree = \"<group>\"; };\n\t\t75EB196D287F093B00AA62F7 /* StatementDropViewBridge.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = StatementDropViewBridge.h; sourceTree = \"<group>\"; };\n\t\t75EB1970287F0A2600AA62F7 /* StatementDropView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StatementDropView.swift; sourceTree = \"<group>\"; };\n\t\t75EB1A05287F0AF700AA62F7 /* StatementDropViewTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StatementDropViewTests.swift; sourceTree = \"<group>\"; };\n\t\t75EB1A08287F0BDA00AA62F7 /* StatementCreateViewBridge.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = StatementCreateViewBridge.cpp; sourceTree = \"<group>\"; };\n\t\t75EB1A09287F0BDA00AA62F7 /* StatementCreateViewBridge.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = StatementCreateViewBridge.h; sourceTree = \"<group>\"; };\n\t\t75EB1A0C287F0DE200AA62F7 /* StatementCreateView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StatementCreateView.swift; sourceTree = \"<group>\"; };\n\t\t75EB1A0E287F0E3700AA62F7 /* StatementCreateViewTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StatementCreateViewTests.swift; sourceTree = \"<group>\"; };\n\t\t75EB1A11287F10BF00AA62F7 /* StatementCreateTriggerBridge.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = StatementCreateTriggerBridge.cpp; sourceTree = \"<group>\"; };\n\t\t75EB1A12287F10BF00AA62F7 /* StatementCreateTriggerBridge.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = StatementCreateTriggerBridge.h; sourceTree = \"<group>\"; };\n\t\t75EF24FE2AA33FEB0009C99F /* IncrementalMaterial.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = IncrementalMaterial.cpp; sourceTree = \"<group>\"; };\n\t\t75EF24FF2AA33FEB0009C99F /* IncrementalMaterial.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = IncrementalMaterial.hpp; sourceTree = \"<group>\"; };\n\t\t75EF25082AA42DD90009C99F /* EncryptedSerialization.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = EncryptedSerialization.cpp; sourceTree = \"<group>\"; };\n\t\t75EF25092AA42DD90009C99F /* EncryptedSerialization.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = EncryptedSerialization.hpp; sourceTree = \"<group>\"; };\n\t\t75F1A3042871DE9A008503A2 /* StatementCreateVirtualTableBridge.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = StatementCreateVirtualTableBridge.cpp; sourceTree = \"<group>\"; };\n\t\t75F1A3052871DE9A008503A2 /* StatementCreateVirtualTableBridge.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = StatementCreateVirtualTableBridge.h; sourceTree = \"<group>\"; };\n\t\t75F1A3082871E764008503A2 /* StatementDeleteBridge.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = StatementDeleteBridge.cpp; sourceTree = \"<group>\"; };\n\t\t75F1A3092871E764008503A2 /* StatementDeleteBridge.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = StatementDeleteBridge.h; sourceTree = \"<group>\"; };\n\t\t75F3140B2AAC067B007FFDFB /* CipherHandle.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = CipherHandle.cpp; sourceTree = \"<group>\"; };\n\t\t75F3140C2AAC067B007FFDFB /* CipherHandle.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = CipherHandle.hpp; sourceTree = \"<group>\"; };\n\t\t75F32F0828B9CE8E00A72697 /* CPPORMMacro.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CPPORMMacro.h; sourceTree = \"<group>\"; };\n\t\t75F32F0B28B9F90900A72697 /* FTSTokenizerUtil.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = FTSTokenizerUtil.cpp; sourceTree = \"<group>\"; };\n\t\t75F32F0C28B9F90900A72697 /* FTSTokenizerUtil.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = FTSTokenizerUtil.hpp; sourceTree = \"<group>\"; };\n\t\t75F32F1228BA039D00A72697 /* CPPFieldMacro.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CPPFieldMacro.h; sourceTree = \"<group>\"; };\n\t\t75F32F1528BA066400A72697 /* CPPBindingMacro.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CPPBindingMacro.h; sourceTree = \"<group>\"; };\n\t\t75F32F1828BA083E00A72697 /* CPPIndexMacro.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CPPIndexMacro.h; sourceTree = \"<group>\"; };\n\t\t75F32F2628BA31CD00A72697 /* ResultField.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = ResultField.cpp; sourceTree = \"<group>\"; };\n\t\t75F32F2728BA31CD00A72697 /* ResultField.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = ResultField.hpp; sourceTree = \"<group>\"; };\n\t\t75F4DE312883E43C00760DC3 /* StatementExplainBridge.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = StatementExplainBridge.cpp; sourceTree = \"<group>\"; };\n\t\t75F4DE322883E43C00760DC3 /* StatementExplainBridge.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = StatementExplainBridge.h; sourceTree = \"<group>\"; };\n\t\t75F4DE352883E88100760DC3 /* StatementPragmaBridge.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = StatementPragmaBridge.cpp; sourceTree = \"<group>\"; };\n\t\t75F4DE362883E88100760DC3 /* StatementPragmaBridge.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = StatementPragmaBridge.h; sourceTree = \"<group>\"; };\n\t\t75F4DE3D2883F0A800760DC3 /* StatementReindexBridge.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = StatementReindexBridge.cpp; sourceTree = \"<group>\"; };\n\t\t75F4DE3E2883F0A800760DC3 /* StatementReindexBridge.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = StatementReindexBridge.h; sourceTree = \"<group>\"; };\n\t\t75F4DE412883FD6A00760DC3 /* StatementReleaseBridge.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = StatementReleaseBridge.cpp; sourceTree = \"<group>\"; };\n\t\t75F4DE422883FD6A00760DC3 /* StatementReleaseBridge.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = StatementReleaseBridge.h; sourceTree = \"<group>\"; };\n\t\t75F4DE452884032600760DC3 /* StatementRollbackBridge.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = StatementRollbackBridge.cpp; sourceTree = \"<group>\"; };\n\t\t75F4DE462884032600760DC3 /* StatementRollbackBridge.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = StatementRollbackBridge.h; sourceTree = \"<group>\"; };\n\t\t75F4DE49288405DD00760DC3 /* StatementSavepointBridge.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = StatementSavepointBridge.cpp; sourceTree = \"<group>\"; };\n\t\t75F4DE4A288405DD00760DC3 /* StatementSavepointBridge.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = StatementSavepointBridge.h; sourceTree = \"<group>\"; };\n\t\t75F4DE4F288407F800760DC3 /* StatementVacuumBridge.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = StatementVacuumBridge.cpp; sourceTree = \"<group>\"; };\n\t\t75F4DE50288407F800760DC3 /* StatementVacuumBridge.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = StatementVacuumBridge.h; sourceTree = \"<group>\"; };\n\t\t75F4DE5328840C4800760DC3 /* StatementBeginBridge.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = StatementBeginBridge.cpp; sourceTree = \"<group>\"; };\n\t\t75F4DE5428840C4800760DC3 /* StatementBeginBridge.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = StatementBeginBridge.h; sourceTree = \"<group>\"; };\n\t\t75F4DE57288411DB00760DC3 /* StatementBegin.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StatementBegin.swift; sourceTree = \"<group>\"; };\n\t\t75F4DE592884132F00760DC3 /* StatementBeginTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StatementBeginTests.swift; sourceTree = \"<group>\"; };\n\t\t75F4DE5D2884149100760DC3 /* StatementCommitBridge.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = StatementCommitBridge.cpp; sourceTree = \"<group>\"; };\n\t\t75F4DE5E2884149100760DC3 /* StatementCommitBridge.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = StatementCommitBridge.h; sourceTree = \"<group>\"; };\n\t\t75F4DE612884161200760DC3 /* StatementCommit.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StatementCommit.swift; sourceTree = \"<group>\"; };\n\t\t75F4DE632884164E00760DC3 /* StatementCommitTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StatementCommitTests.swift; sourceTree = \"<group>\"; };\n\t\t75FFD32D28BE5BB70051DB07 /* Insert.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = Insert.hpp; sourceTree = \"<group>\"; };\n/* End PBXFileReference section */\n\n/* Begin PBXFrameworksBuildPhase section */\n\t\t03330FFC28167ECC0094CFCF /* Frameworks */ = {\n\t\t\tisa = PBXFrameworksBuildPhase;\n\t\t\tbuildActionMask = 2147483647;\n\t\t\tfiles = (\n\t\t\t\t03330FFD28167ECC0094CFCF /* WCDB.framework in Frameworks */,\n\t\t\t);\n\t\t\trunOnlyForDeploymentPostprocessing = 0;\n\t\t};\n\t\t037C3A802897E33600328EC8 /* Frameworks */ = {\n\t\t\tisa = PBXFrameworksBuildPhase;\n\t\t\tbuildActionMask = 2147483647;\n\t\t\tfiles = (\n\t\t\t\t037C3A812897E33600328EC8 /* Security.framework in Frameworks */,\n\t\t\t\t037C3A822897E33600328EC8 /* Foundation.framework in Frameworks */,\n\t\t\t\t037C3A832897E33600328EC8 /* libz.tbd in Frameworks */,\n\t\t\t\t037C3A842897E33600328EC8 /* sqlcipher.framework in Frameworks */,\n\t\t\t\t7587F21E2EC2DF5200CC5224 /* UIKit.framework in Frameworks */,\n\t\t\t);\n\t\t\trunOnlyForDeploymentPostprocessing = 0;\n\t\t};\n\t\t03BF4B192888F87C00A30500 /* Frameworks */ = {\n\t\t\tisa = PBXFrameworksBuildPhase;\n\t\t\tbuildActionMask = 2147483647;\n\t\t\tfiles = (\n\t\t\t\t03BF4B1A2888F87C00A30500 /* WCDB.framework in Frameworks */,\n\t\t\t);\n\t\t\trunOnlyForDeploymentPostprocessing = 0;\n\t\t};\n\t\t03E5CC4328A38CCA005353D9 /* Frameworks */ = {\n\t\t\tisa = PBXFrameworksBuildPhase;\n\t\t\tbuildActionMask = 2147483647;\n\t\t\tfiles = (\n\t\t\t\t750080EF2920EDC0009C0F38 /* WCDB.framework in Frameworks */,\n\t\t\t);\n\t\t\trunOnlyForDeploymentPostprocessing = 0;\n\t\t};\n\t\t234F0359227A9CFE00DD65A2 /* Frameworks */ = {\n\t\t\tisa = PBXFrameworksBuildPhase;\n\t\t\tbuildActionMask = 2147483647;\n\t\t\tfiles = (\n\t\t\t\t750080EC2920EDA2009C0F38 /* WCDB.framework in Frameworks */,\n\t\t\t);\n\t\t\trunOnlyForDeploymentPostprocessing = 0;\n\t\t};\n\t\t234F8AD1227B0B5400791E45 /* Frameworks */ = {\n\t\t\tisa = PBXFrameworksBuildPhase;\n\t\t\tbuildActionMask = 2147483647;\n\t\t\tfiles = (\n\t\t\t\t7546D45629D02BB6001B5611 /* WCDB.framework in Frameworks */,\n\t\t\t);\n\t\t\trunOnlyForDeploymentPostprocessing = 0;\n\t\t};\n\t\t2393265D1E836D7300D677CC /* Frameworks */ = {\n\t\t\tisa = PBXFrameworksBuildPhase;\n\t\t\tbuildActionMask = 2147483647;\n\t\t\tfiles = (\n\t\t\t\t2366BB22221BC0E6000ED712 /* Security.framework in Frameworks */,\n\t\t\t\t2366BB21221BC0D2000ED712 /* Foundation.framework in Frameworks */,\n\t\t\t\t23F5BE132088800C000CCD37 /* libz.tbd in Frameworks */,\n\t\t\t\t23F5BE1120888008000CCD37 /* sqlcipher.framework in Frameworks */,\n\t\t\t\t7587F21C2EC2DF3300CC5224 /* UIKit.framework in Frameworks */,\n\t\t\t);\n\t\t\trunOnlyForDeploymentPostprocessing = 0;\n\t\t};\n\t\t239E8A6D2160A5B100BCB308 /* Frameworks */ = {\n\t\t\tisa = PBXFrameworksBuildPhase;\n\t\t\tbuildActionMask = 2147483647;\n\t\t\tfiles = (\n\t\t\t);\n\t\t\trunOnlyForDeploymentPostprocessing = 0;\n\t\t};\n\t\t7521D88D291E9ABB009642EF /* Frameworks */ = {\n\t\t\tisa = PBXFrameworksBuildPhase;\n\t\t\tbuildActionMask = 2147483647;\n\t\t\tfiles = (\n\t\t\t\t7521D88E291E9ABB009642EF /* Security.framework in Frameworks */,\n\t\t\t\t7521D88F291E9ABB009642EF /* Foundation.framework in Frameworks */,\n\t\t\t\t7521D890291E9ABB009642EF /* libz.tbd in Frameworks */,\n\t\t\t\t7521D891291E9ABB009642EF /* sqlcipher.framework in Frameworks */,\n\t\t\t\t7587F21D2EC2DF4500CC5224 /* UIKit.framework in Frameworks */,\n\t\t\t);\n\t\t\trunOnlyForDeploymentPostprocessing = 0;\n\t\t};\n\t\t7521DC23291EA349009642EF /* Frameworks */ = {\n\t\t\tisa = PBXFrameworksBuildPhase;\n\t\t\tbuildActionMask = 2147483647;\n\t\t\tfiles = (\n\t\t\t\t7521DC24291EA349009642EF /* Security.framework in Frameworks */,\n\t\t\t\t7521DC25291EA349009642EF /* Foundation.framework in Frameworks */,\n\t\t\t\t7521DC26291EA349009642EF /* libz.tbd in Frameworks */,\n\t\t\t\t7521DC27291EA349009642EF /* sqlcipher.framework in Frameworks */,\n\t\t\t\t7587F21F2EC2DF7400CC5224 /* UIKit.framework in Frameworks */,\n\t\t\t);\n\t\t\trunOnlyForDeploymentPostprocessing = 0;\n\t\t};\n/* End PBXFrameworksBuildPhase section */\n\n/* Begin PBXGroup section */\n\t\t03239D6028C60E8400C8D691 /* orm */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t75DF22922AEE83D8006A3311 /* inherit */,\n\t\t\t\t75E76AE12917ADF400073CCA /* virtual_table */,\n\t\t\t\t032E112528C86E8300BCACE0 /* rebind */,\n\t\t\t\t032E112128C850E800BCACE0 /* index_object */,\n\t\t\t\t75882C7E28C7C2F500F95947 /* column_constraint */,\n\t\t\t\t751CA67428C64B3600874A7A /* alltypes */,\n\t\t\t\t751CA66F28C648F300874A7A /* field */,\n\t\t\t\t03239D6128C60F1C00C8D691 /* table_constraint */,\n\t\t\t\t03239D6528C6153F00C8D691 /* CPPORMTests.mm */,\n\t\t\t);\n\t\t\tpath = orm;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t03239D6128C60F1C00C8D691 /* table_constraint */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t03239D6328C60F5C00C8D691 /* CPPTableConstraintObject.hpp */,\n\t\t\t\t03239D6228C60F5C00C8D691 /* CPPTableConstraintObject.cpp */,\n\t\t\t);\n\t\t\tpath = table_constraint;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t032612BA283F24A000836E0F /* winqbridge */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t032612BB283F279800836E0F /* WinqBridge.h */,\n\t\t\t\t75A46C102843B73C00B58207 /* WinqBridge.hpp */,\n\t\t\t\t03261310283F5E0300836E0F /* WinqBridge.cpp */,\n\t\t\t\t03261365283F6D4F00836E0F /* identifier */,\n\t\t\t\t03261366283F6D6F00836E0F /* statement */,\n\t\t\t);\n\t\t\tpath = winqbridge;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t03261361283F6CC600836E0F /* identifier */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t03A57F172840B5A000D2A4C3 /* BindParameter.swift */,\n\t\t\t\t03E165A627F42D6500D2C926 /* Column.swift */,\n\t\t\t\t75A46C062843273A00B58207 /* ColumnConstraint.swift */,\n\t\t\t\t03E165B427F42D6500D2C926 /* ColumnDef.swift */,\n\t\t\t\t03E8228B2844BEFF0072CA57 /* CommonTableExpression.swift */,\n\t\t\t\t03E1659127F42D6500D2C926 /* Expression.swift */,\n\t\t\t\t03E1659D27F42D6500D2C926 /* ForeignKey.swift */,\n\t\t\t\t752594E728522A4A0068A602 /* FrameSpec.swift */,\n\t\t\t\t03E165A227F42D6500D2C926 /* IndexedColumn.swift */,\n\t\t\t\t03E165AC27F42D6500D2C926 /* Join.swift */,\n\t\t\t\t03E165A927F42D6500D2C926 /* LiteralValue.swift */,\n\t\t\t\t03E1659827F42D6500D2C926 /* Operable.swift */,\n\t\t\t\t03E1659E27F42D6500D2C926 /* OrderingTerm.swift */,\n\t\t\t\t03E1659727F42D6500D2C926 /* Pragma.swift */,\n\t\t\t\t75AF6AE12854F19800A7C43D /* QualifiedTable.swift */,\n\t\t\t\t75C10344284530BF0006BBCB /* RaiseFunction.swift */,\n\t\t\t\t03E1659527F42D6500D2C926 /* ResultColumn.swift */,\n\t\t\t\t75204AE7283FD6DC0002E40C /* Schema.swift */,\n\t\t\t\t03E165A027F42D6500D2C926 /* TableConstraint.swift */,\n\t\t\t\t03E165A827F42D6500D2C926 /* TableOrSubquery.swift */,\n\t\t\t\t75AF6AF32855CCDD00A7C43D /* Upsert.swift */,\n\t\t\t\t039BD3972845CB7C00C58BE2 /* WindowDef.swift */,\n\t\t\t);\n\t\t\tpath = identifier;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t03261362283F6CD300836E0F /* statement */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t03E165AF27F42D6500D2C926 /* StatementAlterTable.swift */,\n\t\t\t\t03DCB5E8286C345C00CBC75D /* StatementAnalyze.swift */,\n\t\t\t\t03E165AE27F42D6500D2C926 /* StatementAttach.swift */,\n\t\t\t\t75F4DE57288411DB00760DC3 /* StatementBegin.swift */,\n\t\t\t\t75F4DE612884161200760DC3 /* StatementCommit.swift */,\n\t\t\t\t03E165B627F42D6500D2C926 /* StatementCreateIndex.swift */,\n\t\t\t\t03E165AB27F42D6500D2C926 /* StatementCreateTable.swift */,\n\t\t\t\t03EE3A50287FCECF00C8F0B3 /* StatementCreateTrigger.swift */,\n\t\t\t\t75EB1A0C287F0DE200AA62F7 /* StatementCreateView.swift */,\n\t\t\t\t03E1659C27F42D6500D2C926 /* StatementCreateVirtualTable.swift */,\n\t\t\t\t03E165AD27F42D6500D2C926 /* StatementDelete.swift */,\n\t\t\t\t03E1659427F42D6500D2C926 /* StatementDetach.swift */,\n\t\t\t\t03E1659627F42D6500D2C926 /* StatementDropIndex.swift */,\n\t\t\t\t03E165A327F42D6500D2C926 /* StatementDropTable.swift */,\n\t\t\t\t75EB1967287F078E00AA62F7 /* StatementDropTrigger.swift */,\n\t\t\t\t75EB1970287F0A2600AA62F7 /* StatementDropView.swift */,\n\t\t\t\t03E1659227F42D6500D2C926 /* StatementExplain.swift */,\n\t\t\t\t03E1659327F42D6500D2C926 /* StatementInsert.swift */,\n\t\t\t\t03E165BA27F42D6500D2C926 /* StatementPragma.swift */,\n\t\t\t\t03E165B527F42D6500D2C926 /* StatementReindex.swift */,\n\t\t\t\t03E165B327F42D6500D2C926 /* StatementRelease.swift */,\n\t\t\t\t03E165B027F42D6500D2C926 /* StatementRollback.swift */,\n\t\t\t\t03E165A527F42D6500D2C926 /* StatementSavepoint.swift */,\n\t\t\t\t03E1659927F42D6500D2C926 /* StatementSelect.swift */,\n\t\t\t\t03E165A727F42D6500D2C926 /* StatementUpdate.swift */,\n\t\t\t\t03E165B227F42D6500D2C926 /* StatementVacuum.swift */,\n\t\t\t);\n\t\t\tpath = statement;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t03261365283F6D4F00836E0F /* identifier */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t0326130C283F56BD00836E0F /* LiteralValueBridge.h */,\n\t\t\t\t0326130B283F56BD00836E0F /* LiteralValueBridge.cpp */,\n\t\t\t\t032613B5283F8D7E00836E0F /* ColumnBridge.h */,\n\t\t\t\t032613B4283F8D7E00836E0F /* ColumnBridge.cpp */,\n\t\t\t\t032613B9283F8E4900836E0F /* ExpressionBridge.h */,\n\t\t\t\t032613B8283F8E4900836E0F /* ExpressionBridge.cpp */,\n\t\t\t\t039BD4352846113D00C58BE2 /* ExpressionOperatableBridge.h */,\n\t\t\t\t039BD4342846113D00C58BE2 /* ExpressionOperatableBridge.cpp */,\n\t\t\t\t75204AEA283FD7410002E40C /* SchemaBridge.h */,\n\t\t\t\t75204AE9283FD7410002E40C /* SchemaBridge.cpp */,\n\t\t\t\t03A57F1B2840B5DC00D2A4C3 /* BindParameterBridge.h */,\n\t\t\t\t03A57F1A2840B5DC00D2A4C3 /* BindParameterBridge.cpp */,\n\t\t\t\t75A46BFF284310CE00B58207 /* ColumnConstraintBridge.h */,\n\t\t\t\t75A46BFE284310CE00B58207 /* ColumnConstraintBridge.cpp */,\n\t\t\t\t75A46C0328431D6300B58207 /* ForeignKeyBridge.h */,\n\t\t\t\t75A46C0228431D6300B58207 /* ForeignKeyBridge.cpp */,\n\t\t\t\t75A46C0C2843B3BC00B58207 /* OrderingTermBridge.h */,\n\t\t\t\t75A46C0D2843B3BC00B58207 /* OrderingTermBridge.cpp */,\n\t\t\t\t03E8227F28447B940072CA57 /* ColumnDefBridge.h */,\n\t\t\t\t03E8227E28447B940072CA57 /* ColumnDefBridge.cpp */,\n\t\t\t\t03E822832844B8760072CA57 /* CommonTableExpressionBridge.h */,\n\t\t\t\t03E822822844B8760072CA57 /* CommonTableExpressionBridge.cpp */,\n\t\t\t\t03E822902844E1AB0072CA57 /* RaiseFunctionBridge.h */,\n\t\t\t\t03E8228F2844E1AB0072CA57 /* RaiseFunctionBridge.cpp */,\n\t\t\t\t75C1034128450D840006BBCB /* WindowDefBridge.h */,\n\t\t\t\t75C1034028450D840006BBCB /* WindowDefBridge.cpp */,\n\t\t\t\t752594E4285226C00068A602 /* FrameSpecBridge.h */,\n\t\t\t\t752594E3285226C00068A602 /* FrameSpecBridge.cpp */,\n\t\t\t\t03BFC5D62853538400673AE4 /* IndexedColumnBridge.h */,\n\t\t\t\t03BFC5D52853538400673AE4 /* IndexedColumnBridge.cpp */,\n\t\t\t\t75AF6AD628544C8800A7C43D /* TableOrSubqueryBridge.h */,\n\t\t\t\t75AF6AD528544C8800A7C43D /* TableOrSubqueryBridge.cpp */,\n\t\t\t\t75AF6ADA2854C5ED00A7C43D /* JoinBridge.h */,\n\t\t\t\t75AF6AD92854C5ED00A7C43D /* JoinBridge.cpp */,\n\t\t\t\t75AF6ADE2854EF6D00A7C43D /* QualifiedTableBridge.h */,\n\t\t\t\t75AF6ADD2854EF6D00A7C43D /* QualifiedTableBridge.cpp */,\n\t\t\t\t75AF6AE8285594A100A7C43D /* ResultColumnBridge.h */,\n\t\t\t\t75AF6AE7285594A100A7C43D /* ResultColumnBridge.cpp */,\n\t\t\t\t75AF6AEC28559F4800A7C43D /* TableConstraintBridge.h */,\n\t\t\t\t75AF6AEB28559F4800A7C43D /* TableConstraintBridge.cpp */,\n\t\t\t\t75AF6AF02855C8BF00A7C43D /* UpsertBridge.h */,\n\t\t\t\t75AF6AEF2855C8BF00A7C43D /* UpsertBridge.cpp */,\n\t\t\t\t75AF6AF92856303700A7C43D /* PragmaBridge.h */,\n\t\t\t\t75AF6AF82856303700A7C43D /* PragmaBridge.cpp */,\n\t\t\t);\n\t\t\tpath = identifier;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t03261366283F6D6F00836E0F /* statement */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t03B6A33B2869C51B00D83EC4 /* StatementAlterTableBridge.h */,\n\t\t\t\t03B6A33A2869C51B00D83EC4 /* StatementAlterTableBridge.cpp */,\n\t\t\t\t03DCB5E5286C2E5300CBC75D /* StatementAnalyzeBridge.h */,\n\t\t\t\t03DCB5E4286C2E5300CBC75D /* StatementAnalyzeBridge.cpp */,\n\t\t\t\t03DCB5ED286C3D8E00CBC75D /* StatementAttachBridge.h */,\n\t\t\t\t03DCB5EC286C3D8E00CBC75D /* StatementAttachBridge.cpp */,\n\t\t\t\t75F4DE5428840C4800760DC3 /* StatementBeginBridge.h */,\n\t\t\t\t75F4DE5328840C4800760DC3 /* StatementBeginBridge.cpp */,\n\t\t\t\t75F4DE5E2884149100760DC3 /* StatementCommitBridge.h */,\n\t\t\t\t75F4DE5D2884149100760DC3 /* StatementCommitBridge.cpp */,\n\t\t\t\t03DCB5F1286C480900CBC75D /* StatementCreateIndexBridge.h */,\n\t\t\t\t03DCB5F0286C480900CBC75D /* StatementCreateIndexBridge.cpp */,\n\t\t\t\t757821E0286DF5EB0092F858 /* StatementCreateTableBridge.h */,\n\t\t\t\t757821DF286DF5EB0092F858 /* StatementCreateTableBridge.cpp */,\n\t\t\t\t75EB1A12287F10BF00AA62F7 /* StatementCreateTriggerBridge.h */,\n\t\t\t\t75EB1A11287F10BF00AA62F7 /* StatementCreateTriggerBridge.cpp */,\n\t\t\t\t75EB1A09287F0BDA00AA62F7 /* StatementCreateViewBridge.h */,\n\t\t\t\t75EB1A08287F0BDA00AA62F7 /* StatementCreateViewBridge.cpp */,\n\t\t\t\t75F1A3052871DE9A008503A2 /* StatementCreateVirtualTableBridge.h */,\n\t\t\t\t75F1A3042871DE9A008503A2 /* StatementCreateVirtualTableBridge.cpp */,\n\t\t\t\t75F1A3092871E764008503A2 /* StatementDeleteBridge.h */,\n\t\t\t\t75F1A3082871E764008503A2 /* StatementDeleteBridge.cpp */,\n\t\t\t\t03F5481F287D8467007BCA3E /* StatementDetachBridge.h */,\n\t\t\t\t03F5481E287D8467007BCA3E /* StatementDetachBridge.cpp */,\n\t\t\t\t03F54823287D87F9007BCA3E /* StatementDropIndexBridge.h */,\n\t\t\t\t03F54822287D87F9007BCA3E /* StatementDropIndexBridge.cpp */,\n\t\t\t\t03F54827287D93A7007BCA3E /* StatementDropTableBridge.h */,\n\t\t\t\t03F54826287D93A7007BCA3E /* StatementDropTableBridge.cpp */,\n\t\t\t\t75EB1964287F068200AA62F7 /* StatementDropTriggerBridge.h */,\n\t\t\t\t75EB1963287F068200AA62F7 /* StatementDropTriggerBridge.cpp */,\n\t\t\t\t75EB196D287F093B00AA62F7 /* StatementDropViewBridge.h */,\n\t\t\t\t75EB196C287F093B00AA62F7 /* StatementDropViewBridge.cpp */,\n\t\t\t\t75F4DE322883E43C00760DC3 /* StatementExplainBridge.h */,\n\t\t\t\t75F4DE312883E43C00760DC3 /* StatementExplainBridge.cpp */,\n\t\t\t\t03EE3DA9288165A700C8F0B3 /* StatementInsertBridge.h */,\n\t\t\t\t03EE3DA8288165A700C8F0B3 /* StatementInsertBridge.cpp */,\n\t\t\t\t75F4DE362883E88100760DC3 /* StatementPragmaBridge.h */,\n\t\t\t\t75F4DE352883E88100760DC3 /* StatementPragmaBridge.cpp */,\n\t\t\t\t75F4DE3E2883F0A800760DC3 /* StatementReindexBridge.h */,\n\t\t\t\t75F4DE3D2883F0A800760DC3 /* StatementReindexBridge.cpp */,\n\t\t\t\t75F4DE422883FD6A00760DC3 /* StatementReleaseBridge.h */,\n\t\t\t\t75F4DE412883FD6A00760DC3 /* StatementReleaseBridge.cpp */,\n\t\t\t\t75F4DE462884032600760DC3 /* StatementRollbackBridge.h */,\n\t\t\t\t75F4DE452884032600760DC3 /* StatementRollbackBridge.cpp */,\n\t\t\t\t75F4DE4A288405DD00760DC3 /* StatementSavepointBridge.h */,\n\t\t\t\t75F4DE49288405DD00760DC3 /* StatementSavepointBridge.cpp */,\n\t\t\t\t03E822872844B8CD0072CA57 /* StatementSelectBridge.h */,\n\t\t\t\t03E822862844B8CD0072CA57 /* StatementSelectBridge.cpp */,\n\t\t\t\t03EE3DAD28816DA800C8F0B3 /* StatementUpdateBridge.h */,\n\t\t\t\t03EE3DAC28816DA800C8F0B3 /* StatementUpdateBridge.cpp */,\n\t\t\t\t75F4DE50288407F800760DC3 /* StatementVacuumBridge.h */,\n\t\t\t\t75F4DE4F288407F800760DC3 /* StatementVacuumBridge.cpp */,\n\t\t\t);\n\t\t\tpath = statement;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t032E112128C850E800BCACE0 /* index_object */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t032E112328C8511E00BCACE0 /* CPPIndexObject.hpp */,\n\t\t\t\t032E112228C8511E00BCACE0 /* CPPIndexObject.cpp */,\n\t\t\t);\n\t\t\tpath = index_object;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t032E112528C86E8300BCACE0 /* rebind */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t032E112728C8724A00BCACE0 /* CPPOldRemapObject.hpp */,\n\t\t\t\t032E112628C8724A00BCACE0 /* CPPOldRemapObject.cpp */,\n\t\t\t\t032E112A28C874F500BCACE0 /* CPPNewRemapObject.hpp */,\n\t\t\t\t032E112928C874F500BCACE0 /* CPPNewRemapObject.cpp */,\n\t\t\t\t032E112D28C8768C00BCACE0 /* CPPNewlyCreatedTableIndexObject.hpp */,\n\t\t\t\t032E112C28C8768C00BCACE0 /* CPPNewlyCreatedTableIndexObject.cpp */,\n\t\t\t\t032E113028C8782600BCACE0 /* CPPDropIndexObject.hpp */,\n\t\t\t\t032E112F28C8782600BCACE0 /* CPPDropIndexObject.cpp */,\n\t\t\t);\n\t\t\tpath = rebind;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t03331004281681200094CFCF /* tests */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t0333103B281681A80094CFCF /* common */,\n\t\t\t\t0333100F281681200094CFCF /* crud */,\n\t\t\t);\n\t\t\tpath = tests;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t0333100F281681200094CFCF /* crud */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t0338E0D52819226C0094923A /* AdvanceCRUDTests.swift */,\n\t\t\t\t0338E0D42819226C0094923A /* DeleteInterfaceTests.swift */,\n\t\t\t\t0338E0D22819226C0094923A /* InsertInterfaceTests.swift */,\n\t\t\t\t0338E0CA2819226B0094923A /* InsertTests.swift */,\n\t\t\t\t0338E0CD2819226B0094923A /* MultiSelectTests.swift */,\n\t\t\t\t0338E0CE2819226B0094923A /* RowSelectTests.swift */,\n\t\t\t\t0338E0C92819226A0094923A /* SelectInterfaceTests.swift */,\n\t\t\t\t0338E0CC2819226B0094923A /* UpdateInterfaceTests.swift */,\n\t\t\t\t0338E0D02819226B0094923A /* UpdateTests.swift */,\n\t\t\t\t0333101A281681200094CFCF /* CRUDObject.swift */,\n\t\t\t\t0333101B281681200094CFCF /* CRUDTestCase.swift */,\n\t\t\t\t75067CC2293F8300005DA25B /* DatabaseTestCase.swift */,\n\t\t\t\t03331021281681200094CFCF /* SelectTests.swift */,\n\t\t\t\t0338E0C7281920AB0094923A /* DeleteTests.swift */,\n\t\t\t\t75067CC0293F82B4005DA25B /* AutoAddColumnTests.swift */,\n\t\t\t\t03331043281683450094CFCF /* CRUDObject.h */,\n\t\t\t\t033310452816836C0094CFCF /* CRUDObject.mm */,\n\t\t\t\t75067CBF293F819B005DA25B /* AutoAddColumnObject.h */,\n\t\t\t\t75067CBD293F8192005DA25B /* AutoAddColumnObject.mm */,\n\t\t\t);\n\t\t\tpath = crud;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t0333103B281681A80094CFCF /* common */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t033310ED2816A2700094CFCF /* SwiftBridgeObjcTest-Bridging-Header.h */,\n\t\t\t\t0333103C281681A80094CFCF /* Assert.swift */,\n\t\t\t\t0333103D281681A80094CFCF /* BaseTestCase.swift */,\n\t\t\t\t0333103E281681A80094CFCF /* Convenience.swift */,\n\t\t\t);\n\t\t\tpath = common;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t036E506728113C87007365CD /* objcbridge */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t7500829229223463009C0F38 /* WCTBridgeMacro.h */,\n\t\t\t\t75CE3EFD2812D95100E132F6 /* WCTAPIBridge.h */,\n\t\t\t\t75CE3EFF2812E1A400E132F6 /* WCTAPIBridge.mm */,\n\t\t\t);\n\t\t\tpath = objcbridge;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t037330BE289A901E0030C113 /* core */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t03E3180C28A21AF800540CB1 /* CppInterface.h */,\n\t\t\t\t7596162228BFB05100AE86BA /* CPPDeclaration.h */,\n\t\t\t\t037330C0289A909A0030C113 /* Database.hpp */,\n\t\t\t\t037330BF289A909A0030C113 /* Database.cpp */,\n\t\t\t\t753636DB28BBC3820025C2C4 /* Table.hpp */,\n\t\t\t\t753636DA28BBC3820025C2C4 /* Table.cpp */,\n\t\t\t\t0373310F289A94F10030C113 /* Handle.hpp */,\n\t\t\t\t0373310E289A94F00030C113 /* Handle.cpp */,\n\t\t\t\t0373310B289A94E00030C113 /* PreparedStatement.hpp */,\n\t\t\t\t0373310A289A94E00030C113 /* PreparedStatement.cpp */,\n\t\t\t);\n\t\t\tpath = core;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t037C3C0E2897EBE400328EC8 /* cpp */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t03E5CB0028A3513C005353D9 /* WCDBCpp.h */,\n\t\t\t\t03E5CB9728A38CA6005353D9 /* tests */,\n\t\t\t\t037330BE289A901E0030C113 /* core */,\n\t\t\t\t03AFD32E28B87F4500EF5E56 /* orm */,\n\t\t\t\t7521D38F28BD1133009C33D0 /* chaincall */,\n\t\t\t\t03D3A2A428A605110064D4D4 /* operation */,\n\t\t\t\t0D5363E7290A64320026A4DC /* builtin */,\n\t\t\t);\n\t\t\tpath = cpp;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t039760A927F5BB630071FA8F /* cppbridge */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t039760AA27F5C0DD0071FA8F /* DatabaseBridge.h */,\n\t\t\t\t039760AC27F5C1CA0071FA8F /* DatabaseBridge.cpp */,\n\t\t\t\t0393BEE327F715180058B295 /* HandleBridge.h */,\n\t\t\t\t0393BEE527F7152F0058B295 /* HandleBridge.cpp */,\n\t\t\t\t756A773727F9EDCA00105B7C /* HandleStatementBridge.h */,\n\t\t\t\t756A773C27F9EDDE00105B7C /* HandleStatementBridge.cpp */,\n\t\t\t\t756A773F27FAC17F00105B7C /* CoreBridge.h */,\n\t\t\t\t756A774227FAC1D900105B7C /* CoreBridge.cpp */,\n\t\t\t\t750DC06A2913DE7300F19044 /* FTSBridge.h */,\n\t\t\t\t750DC0692913DE7300F19044 /* FTSBridge.cpp */,\n\t\t\t\t752CF3F7293A490F009ED8FB /* BindingBridge.h */,\n\t\t\t\t752CF3F6293A490F009ED8FB /* BindingBridge.cpp */,\n\t\t\t);\n\t\t\tpath = cppbridge;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t03A57EC6284080FC00D2A4C3 /* identifier */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t03A57F1E2840BEFF00D2A4C3 /* BindParameterTests.swift */,\n\t\t\t\t75A46C0A2843709500B58207 /* ColumnConstraintTests.swift */,\n\t\t\t\t03E1673A27F434E800D2C926 /* ColumnTests.swift */,\n\t\t\t\t03E1672F27F434E800D2C926 /* ColumnDefTests.swift */,\n\t\t\t\t03E1674627F434E800D2C926 /* ColumnTypeTests.swift */,\n\t\t\t\t03E8228D2844C0E70072CA57 /* CommonTableExpressionTests.swift */,\n\t\t\t\t03E1673D27F434E800D2C926 /* ExpressionTests.swift */,\n\t\t\t\t03E1673727F434E800D2C926 /* ForeignKeyTests.swift */,\n\t\t\t\t75195E802852454700EC8C1F /* FrameSpecTests.swift */,\n\t\t\t\t03E1674227F434E800D2C926 /* IndexedColumnTests.swift */,\n\t\t\t\t03E1673F27F434E800D2C926 /* JoinTests.swift */,\n\t\t\t\t03E1673027F434E800D2C926 /* LiteralValueTests.swift */,\n\t\t\t\t03E1673527F434E800D2C926 /* OrderingTermTests.swift */,\n\t\t\t\t75AF6AE32854F2FC00A7C43D /* QualifiedTableTests.swift */,\n\t\t\t\t752594922851FCEF0068A602 /* RaiseFunctionTests.swift */,\n\t\t\t\t03E1674527F434E800D2C926 /* ResultColumnTests.swift */,\n\t\t\t\t03A57F15284089B800D2A4C3 /* SchemaTests.swift */,\n\t\t\t\t03E1672D27F434E800D2C926 /* TableConstraintTests.swift */,\n\t\t\t\t03E1673327F434E800D2C926 /* TableOrSubqueryTests.swift */,\n\t\t\t\t75AF6AF52855D21000A7C43D /* UpsertTests.swift */,\n\t\t\t\t03BFC5382852E9CB00673AE4 /* WindowDefTests.swift */,\n\t\t\t);\n\t\t\tpath = identifier;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t03A57EC72840812200D2A4C3 /* statement */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t03E1672E27F434E800D2C926 /* StatementAlterTableTests.swift */,\n\t\t\t\t03DCB5EA286C35A600CBC75D /* StatementAnalyzeTests.swift */,\n\t\t\t\t03E1673127F434E800D2C926 /* StatementAttachTests.swift */,\n\t\t\t\t75F4DE592884132F00760DC3 /* StatementBeginTests.swift */,\n\t\t\t\t75F4DE632884164E00760DC3 /* StatementCommitTests.swift */,\n\t\t\t\t03E1673C27F434E800D2C926 /* StatementCreateIndexTests.swift */,\n\t\t\t\t03E1672527F434E800D2C926 /* StatementCreateTableTests.swift */,\n\t\t\t\t03EE3DA628810C2000C8F0B3 /* StatementCreateTriggerTests.swift */,\n\t\t\t\t75EB1A0E287F0E3700AA62F7 /* StatementCreateViewTests.swift */,\n\t\t\t\t03E1672727F434E800D2C926 /* StatementCreateVirtualTableTests.swift */,\n\t\t\t\t03E1672927F434E800D2C926 /* StatementDeleteTests.swift */,\n\t\t\t\t03E1672427F434E800D2C926 /* StatementDetachTests.swift */,\n\t\t\t\t03E1672C27F434E800D2C926 /* StatementDropIndexTests.swift */,\n\t\t\t\t03E1674027F434E800D2C926 /* StatementDropTableTests.swift */,\n\t\t\t\t75EB1969287F086D00AA62F7 /* StatementDropTriggerTests.swift */,\n\t\t\t\t75EB1A05287F0AF700AA62F7 /* StatementDropViewTests.swift */,\n\t\t\t\t03E1672A27F434E800D2C926 /* StatementExplainTests.swift */,\n\t\t\t\t03E1674327F434E800D2C926 /* StatementInsertTests.swift */,\n\t\t\t\t03E1673627F434E800D2C926 /* StatementPragmaTests.swift */,\n\t\t\t\t03E1673427F434E800D2C926 /* StatementReindexTests.swift */,\n\t\t\t\t03E1673B27F434E800D2C926 /* StatementReleaseTests.swift */,\n\t\t\t\t03E1673927F434E800D2C926 /* StatementRollbackTests.swift */,\n\t\t\t\t03E1672B27F434E800D2C926 /* StatementSavepointTests.swift */,\n\t\t\t\t03E1672627F434E800D2C926 /* StatementSelectTests.swift */,\n\t\t\t\t03E1672827F434E800D2C926 /* StatementUpdateTests.swift */,\n\t\t\t\t03E1674127F434E800D2C926 /* StatementVacuumTests.swift */,\n\t\t\t);\n\t\t\tpath = statement;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t03AFD32E28B87F4500EF5E56 /* orm */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t03AFD34828B8B88300EF5E56 /* CPPORM.h */,\n\t\t\t\t75F32F0628B9CC2300A72697 /* binding */,\n\t\t\t\t75F32F0728B9CCD200A72697 /* macro */,\n\t\t\t\t75F32F1128BA02AF00A72697 /* fts */,\n\t\t\t);\n\t\t\tpath = orm;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t03D3A2A428A605110064D4D4 /* operation */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t03321E8628A503F3000AFD6D /* StatementOperation.hpp */,\n\t\t\t\t03321E8528A503F3000AFD6D /* StatementOperation.cpp */,\n\t\t\t\t03321E8C28A514F5000AFD6D /* HandleOperation.hpp */,\n\t\t\t\t03321E8B28A514F5000AFD6D /* HandleOperation.cpp */,\n\t\t\t\t03D077F528C1F951009A3B18 /* HandleORMOperation.hpp */,\n\t\t\t\t03D077F828C1FB48009A3B18 /* HandleORMOperation.cpp */,\n\t\t\t\t03D077ED28C1F072009A3B18 /* TableOperation.hpp */,\n\t\t\t\t03D077EC28C1F072009A3B18 /* TableOperation.cpp */,\n\t\t\t\t03D077F228C1F611009A3B18 /* TableORMOperation.hpp */,\n\t\t\t\t75D99B7F28CA441E00BEC8B5 /* BaseOperation.hpp */,\n\t\t\t\t75D99B8228CA46A400BEC8B5 /* BaseOperation.cpp */,\n\t\t\t);\n\t\t\tpath = operation;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t03E1620527F1AA1B00D2C926 /* common */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t2349F6A71EA0D6680021EFA7 /* utility */,\n\t\t\t\t2349F6151EA0D6680021EFA7 /* core */,\n\t\t\t\t2349F5D61EA0D6680021EFA7 /* winq */,\n\t\t\t\t23775B3420AD666900E21AB0 /* repair */,\n\t\t\t\t23775B2E20AD666900E21AB0 /* base */,\n\t\t\t\t0DE08A1A29CBE79C009A7CA3 /* platform */,\n\t\t\t);\n\t\t\tpath = common;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t03E1658E27F42D6500D2C926 /* winq */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t75A46C0828432A5D00B58207 /* SyntaxConst.swift */,\n\t\t\t\t03E165AA27F42D6500D2C926 /* Value.swift */,\n\t\t\t\t03261363283F6CFB00836E0F /* Identifier.swift */,\n\t\t\t\t03E165B727F42D6500D2C926 /* Statement.swift */,\n\t\t\t\t03E165A127F42D6500D2C926 /* Convertible.swift */,\n\t\t\t\t03261361283F6CC600836E0F /* identifier */,\n\t\t\t\t03261362283F6CD300836E0F /* statement */,\n\t\t\t);\n\t\t\tpath = winq;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t03E165BC27F42D6500D2C926 /* builtin */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t03E165BE27F42D6500D2C926 /* CodableType.swift */,\n\t\t\t\t03E165BF27F42D6500D2C926 /* Master.swift */,\n\t\t\t);\n\t\t\tpath = builtin;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t03E165C027F42D6500D2C926 /* core */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t75CD026728CF18FD0071B6C3 /* chaincall */,\n\t\t\t\t03E165C127F42D6500D2C926 /* interface */,\n\t\t\t\t03E165CE27F42D6500D2C926 /* codable */,\n\t\t\t\t03E165D527F42D6500D2C926 /* binding */,\n\t\t\t\t03E165DF27F42D6500D2C926 /* base */,\n\t\t\t);\n\t\t\tpath = core;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t03E165C127F42D6500D2C926 /* interface */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t75CD026028CECD610071B6C3 /* StatementInterface.swift */,\n\t\t\t\t7521DDF129209F45009642EF /* StatementInterface+WCTTableCoding.swift */,\n\t\t\t\t75CD026828CF8DC00071B6C3 /* InsertInterface.swift */,\n\t\t\t\t7521DDF52920A12E009642EF /* InsertInterface+WCTTableCoding.swift */,\n\t\t\t\t75CD026A28CF8EF90071B6C3 /* UpdateInterface.swift */,\n\t\t\t\t7521DDF92920A680009642EF /* UpdateInterface+WCTTableCoding.swift */,\n\t\t\t\t75CD026C28CF8F360071B6C3 /* DeleteInterface.swift */,\n\t\t\t\t75CD026E28CF8F5F0071B6C3 /* SelectInterface.swift */,\n\t\t\t\t7525C1522920AB1900FD34C7 /* SelectInterface+WCTTableCoding.swift */,\n\t\t\t\t75CD027028CF900C0071B6C3 /* TableInterface.swift */,\n\t\t\t\t7525C1552920ACD700FD34C7 /* TableInterface+WCTTableCoding.swift */,\n\t\t\t\t03E165C827F42D6500D2C926 /* TableCRUDInterface.swift */,\n\t\t\t\t7525C15B2920D22300FD34C7 /* TableCRUDInterface+WCTTableCoding.swift */,\n\t\t\t\t75C17A9228D0D3DD009C342E /* TransactionInterface.swift */,\n\t\t\t\t0DF1089529C05559004ED764 /* StatementSelectInterface.swift */,\n\t\t\t);\n\t\t\tpath = interface;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t03E165CE27F42D6500D2C926 /* codable */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t03E165CF27F42D6500D2C926 /* ColumnCodable.swift */,\n\t\t\t\t03E165D027F42D6500D2C926 /* ColumnTypeDecoder.swift */,\n\t\t\t\t03E165D127F42D6500D2C926 /* TableCodable.swift */,\n\t\t\t\t03E165D227F42D6500D2C926 /* CodingTableKey.swift */,\n\t\t\t\t03E165D327F42D6500D2C926 /* TableEncoder.swift */,\n\t\t\t\t03E165D427F42D6500D2C926 /* TableDecoder.swift */,\n\t\t\t);\n\t\t\tpath = codable;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t03E165D527F42D6500D2C926 /* binding */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t03E165D727F42D6500D2C926 /* Property.swift */,\n\t\t\t\t03E165D827F42D6500D2C926 /* Redirectable.swift */,\n\t\t\t\t03E165DC27F42D6500D2C926 /* TableBinding.swift */,\n\t\t\t\t75C44095291CE1FB00D74EB7 /* TableConfiguration.swift */,\n\t\t\t\t75C44093291CE12300D74EB7 /* ColumnConstraintConfig.swift */,\n\t\t\t\t75C44097291CE24900D74EB7 /* IndexConfig.swift */,\n\t\t\t\t75C44099291CE7E200D74EB7 /* MultiPrimaryConfig.swift */,\n\t\t\t\t75C4409B291D0B4F00D74EB7 /* MultiUniqueConfig.swift */,\n\t\t\t\t75C4409D291D0C9C00D74EB7 /* CheckExpressionConfig.swift */,\n\t\t\t\t75C4409F291D108D00D74EB7 /* ForeignKeyConfig.swift */,\n\t\t\t\t75C440A1291D116C00D74EB7 /* VirtualTableConfig.swift */,\n\t\t\t);\n\t\t\tpath = binding;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t03E165DF27F42D6500D2C926 /* base */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t03E165E127F42D6500D2C926 /* BaseType.swift */,\n\t\t\t\t03E165BB27F42D6500D2C926 /* Handle.swift */,\n\t\t\t\t7521DDE729209C90009642EF /* Handle+WCTTableCoding.swift */,\n\t\t\t\t03E165A427F42D6500D2C926 /* PreparedStatement.swift */,\n\t\t\t\t7521DDF32920A0E3009642EF /* HandleStatement+WCTTableCoding.swift */,\n\t\t\t\t03E165C727F42D6500D2C926 /* Table.swift */,\n\t\t\t\t7525C1582920AD7900FD34C7 /* Table+WCTTableCoding.swift */,\n\t\t\t\t03E165E327F42D6500D2C926 /* Database.swift */,\n\t\t\t\t7521DDF72920A623009642EF /* Database+WCTTableCoding.swift */,\n\t\t\t);\n\t\t\tpath = base;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t03E165E727F42D6500D2C926 /* util */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t03E165E827F42D6500D2C926 /* Recyclable.swift */,\n\t\t\t\t03E165EA27F42D6500D2C926 /* WCDBError.swift */,\n\t\t\t\t03E165EE27F42D6500D2C926 /* Lock.swift */,\n\t\t\t\t03E165F627F42D6500D2C926 /* Optional.swift */,\n\t\t\t\t03E165F727F42D6500D2C926 /* Convenience.swift */,\n\t\t\t);\n\t\t\tpath = util;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t03E1670827F434E800D2C926 /* tests */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t03E1671F27F434E800D2C926 /* other */,\n\t\t\t\t03E1674727F434E800D2C926 /* crud */,\n\t\t\t\t03E1675B27F434E800D2C926 /* orm */,\n\t\t\t\t03E1672327F434E800D2C926 /* winq */,\n\t\t\t\t03E1670927F434E800D2C926 /* benchmark */,\n\t\t\t\t03E1676027F434E800D2C926 /* common */,\n\t\t\t);\n\t\t\tpath = tests;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t03E1670927F434E800D2C926 /* benchmark */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t03E1670A27F434E800D2C926 /* other */,\n\t\t\t\t03E1670D27F434E800D2C926 /* cipher */,\n\t\t\t\t03E1671027F434E800D2C926 /* baseline */,\n\t\t\t\t03E1671427F434E800D2C926 /* supporting */,\n\t\t\t\t03E1671927F434E800D2C926 /* multithread */,\n\t\t\t);\n\t\t\tpath = benchmark;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t03E1670A27F434E800D2C926 /* other */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t03E1670B27F434E800D2C926 /* InitializationBenchmark.swift */,\n\t\t\t\t03E1670C27F434E800D2C926 /* SyncWriteBenchmark.swift */,\n\t\t\t);\n\t\t\tpath = other;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t03E1670D27F434E800D2C926 /* cipher */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t03E1670E27F434E800D2C926 /* CipherWriteBenchmark.swift */,\n\t\t\t\t03E1670F27F434E800D2C926 /* CipherReadBenchmark.swift */,\n\t\t\t);\n\t\t\tpath = cipher;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t03E1671027F434E800D2C926 /* baseline */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t03E1671127F434E800D2C926 /* BaselineWriteBenchmark.swift */,\n\t\t\t\t03E1671227F434E800D2C926 /* BaselineBatchWriteBenchmark.swift */,\n\t\t\t\t03E1671327F434E800D2C926 /* BaselineReadBenchmark.swift */,\n\t\t\t);\n\t\t\tpath = baseline;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t03E1671427F434E800D2C926 /* supporting */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t03E1671527F434E800D2C926 /* BaseBenchmark.swift */,\n\t\t\t\t03E1671627F434E800D2C926 /* BenchmarkObject.swift */,\n\t\t\t\t03E1671727F434E800D2C926 /* Config.swift */,\n\t\t\t);\n\t\t\tpath = supporting;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t03E1671927F434E800D2C926 /* multithread */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t03E1671A27F434E800D2C926 /* BaseMultithreadBenchmark.swift */,\n\t\t\t\t03E1671B27F434E800D2C926 /* MultithreadReadWriteBenchmark.swift */,\n\t\t\t\t03E1671C27F434E800D2C926 /* MultithreadReadReadBenchmark.swift */,\n\t\t\t\t03E1671D27F434E800D2C926 /* MultithreadWriteWriteBenchmark.swift */,\n\t\t\t);\n\t\t\tpath = multithread;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t03E1671F27F434E800D2C926 /* other */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t03E1672027F434E800D2C926 /* TracerTests.swift */,\n\t\t\t\t03E1672127F434E800D2C926 /* RepairTests.swift */,\n\t\t\t\t03E1672227F434E800D2C926 /* FileTests.swift */,\n\t\t\t\t75E76ADF29176FA600073CCA /* TokenizerTests.swift */,\n\t\t\t\t75C075352A8922CA00B4A0D4 /* HandleTest.swift */,\n\t\t\t);\n\t\t\tpath = other;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t03E1672327F434E800D2C926 /* winq */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t03A57EC6284080FC00D2A4C3 /* identifier */,\n\t\t\t\t03A57EC72840812200D2A4C3 /* statement */,\n\t\t\t);\n\t\t\tpath = winq;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t03E1674727F434E800D2C926 /* crud */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t03E1674827F434E800D2C926 /* AdvanceCRUDTests.swift */,\n\t\t\t\t03E1674927F434E800D2C926 /* TableTests.swift */,\n\t\t\t\t03E1674A27F434E800D2C926 /* InsertTests.swift */,\n\t\t\t\t03E1674B27F434E800D2C926 /* AdvanceTests.swift */,\n\t\t\t\t03E1674C27F434E800D2C926 /* MultithreadTests.swift */,\n\t\t\t\t03E1674D27F434E800D2C926 /* RowSelectTests.swift */,\n\t\t\t\t03E1674E27F434E800D2C926 /* DatabaseTests.swift */,\n\t\t\t\t03E1674F27F434E800D2C926 /* InsertInterfaceTests.swift */,\n\t\t\t\t03E1675027F434E800D2C926 /* UpdateInterfaceTests.swift */,\n\t\t\t\t03E1675127F434E800D2C926 /* TypedTests.swift */,\n\t\t\t\t03E1675327F434E800D2C926 /* CRUDTestCase.swift */,\n\t\t\t\t03E1675427F434E800D2C926 /* MultiSelectTests.swift */,\n\t\t\t\t03E1675527F434E800D2C926 /* SelectInterfaceTests.swift */,\n\t\t\t\t03E1675627F434E800D2C926 /* DeleteTests.swift */,\n\t\t\t\t03E1675727F434E800D2C926 /* DeleteInterfaceTests.swift */,\n\t\t\t\t03E1675827F434E800D2C926 /* UpdateTests.swift */,\n\t\t\t\t03E1675A27F434E800D2C926 /* SelectTests.swift */,\n\t\t\t);\n\t\t\tpath = crud;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t03E1675B27F434E800D2C926 /* orm */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t75CFB5DB293F30A200F97FA5 /* AutoAddColumnTests.swift */,\n\t\t\t\t03E1675C27F434E800D2C926 /* TableConstraintBindingTests.swift */,\n\t\t\t\t03E1675D27F434E800D2C926 /* VirtualTableBindingTests.swift */,\n\t\t\t\t03E1675E27F434E800D2C926 /* ColumnConstraintBindingTests.swift */,\n\t\t\t\t03E1675F27F434E800D2C926 /* IndexBindingTests.swift */,\n\t\t\t\t7543EDE2293B49CB00336DA9 /* ORMTestCase.swift */,\n\t\t\t);\n\t\t\tpath = orm;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t03E1676027F434E800D2C926 /* common */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t03E1671827F434E800D2C926 /* RandomData.swift */,\n\t\t\t\t03E1676127F434E800D2C926 /* Assert.swift */,\n\t\t\t\t03E1676227F434E800D2C926 /* BaseTestCase.swift */,\n\t\t\t\t03E1676327F434E800D2C926 /* Convenience.swift */,\n\t\t\t\t03E1675227F434E800D2C926 /* TestObject.swift */,\n\t\t\t\t7534735F2935C1E400911FCA /* DatabaseTestCase.swift */,\n\t\t\t\t0D71F9332A8B377100F7B4F6 /* Random.swift */,\n\t\t\t);\n\t\t\tpath = common;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t03E167B427F43CD900D2C926 /* bridge */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t0D8BC3072B99B3BF00DE9AE5 /* WCDBBridging.h */,\n\t\t\t\t03E167B527F4446700D2C926 /* base */,\n\t\t\t\t039760A927F5BB630071FA8F /* cppbridge */,\n\t\t\t\t036E506728113C87007365CD /* objcbridge */,\n\t\t\t\t032612BA283F24A000836E0F /* winqbridge */,\n\t\t\t\t03331004281681200094CFCF /* tests */,\n\t\t\t);\n\t\t\tpath = bridge;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t03E167B527F4446700D2C926 /* base */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t03E167B727F46C7100D2C926 /* ObjectBridge.h */,\n\t\t\t\t03E167B927F46E2E00D2C926 /* ObjectBridge.hpp */,\n\t\t\t\t0397605727F54FA10071FA8F /* ObjectBridge.cpp */,\n\t\t\t\t0393BEDB27F6ED860058B295 /* ErrorBridge.h */,\n\t\t\t\t0393BEDF27F6EDAC0058B295 /* ErrorBridge.cpp */,\n\t\t\t\t75E0A5D52A7FE2A200D4FE9A /* ContainerBridge.h */,\n\t\t\t\t75E0A5D42A7FE2A200D4FE9A /* ContainerBridge.cpp */,\n\t\t\t);\n\t\t\tpath = base;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t03E5CB9728A38CA6005353D9 /* tests */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t03E5CC6528A3B02B005353D9 /* interface */,\n\t\t\t\t03239D6028C60E8400C8D691 /* orm */,\n\t\t\t\t752C7E3E28C8E8D700C9FFA6 /* operation */,\n\t\t\t\t75CD724C290D231D008583A3 /* fts */,\n\t\t\t\t03E5CB9828A38CBA005353D9 /* common */,\n\t\t\t);\n\t\t\tpath = tests;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t03E5CB9828A38CBA005353D9 /* common */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t03E5CC6828A3B09E005353D9 /* CPPTestCase.h */,\n\t\t\t\t03E5CC5028A38DEB005353D9 /* CPPBaseTestCase.h */,\n\t\t\t\t03E5CC4E28A38DDB005353D9 /* CPPBaseTestCase.mm */,\n\t\t\t\t03E5CC5C28A3A16F005353D9 /* CPPDatabaseTestCase.h */,\n\t\t\t\t03E5CC5E28A3A185005353D9 /* CPPDatabaseTestCase.mm */,\n\t\t\t\t75D4834328A79CCE004FDD3C /* CPPTestCaseAssertion.h */,\n\t\t\t\t75D4834628A7A83C004FDD3C /* CPPTableTestCase.h */,\n\t\t\t\t75D4834428A7A827004FDD3C /* CPPTableTestCase.mm */,\n\t\t\t\t75D4834728A7C422004FDD3C /* Random+CPPTestObject.h */,\n\t\t\t\t75D4834828A7C42F004FDD3C /* Random+CPPTestObject.mm */,\n\t\t\t\t753C084E28A8D5EB0042C427 /* CPPCRUDTestCase.h */,\n\t\t\t\t753C084F28A8D5F70042C427 /* CPPCRUDTestCase.mm */,\n\t\t\t\t03239D1828C5EE1A00C8D691 /* CPPORMTestUtil.h */,\n\t\t\t\t032E121428C8A3B700BCACE0 /* CPPTestCaseObject.h */,\n\t\t\t\t032E121328C8A3B700BCACE0 /* CPPTestCaseObject.cpp */,\n\t\t\t);\n\t\t\tpath = common;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t03E5CC6528A3B02B005353D9 /* interface */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t03E5CC6628A3B083005353D9 /* CPPFileTests.mm */,\n\t\t\t\t03E5CC6A28A3B6A4005353D9 /* CPPConfigTests.mm */,\n\t\t\t\t75D4834128A79AD3004FDD3C /* CPPTraceTest.mm */,\n\t\t\t\t753C084928A8B0110042C427 /* CPPDatabaseTest.mm */,\n\t\t\t\t75C075332A8921C600B4A0D4 /* CPPHandleTest.mm */,\n\t\t\t\t0DE2D9A22AEB934E005420D3 /* CPPTableTest.mm */,\n\t\t\t);\n\t\t\tpath = interface;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t0D19BA1C2B0747E80028F92B /* integrity */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t0D19BA1E2B07481B0028F92B /* IntegerityHandleOperator.hpp */,\n\t\t\t\t0D19BA1D2B07481B0028F92B /* IntegerityHandleOperator.cpp */,\n\t\t\t);\n\t\t\tpath = integrity;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t0D47A9742A6E27CF008E9E2C /* compatible */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t7522B5262A6D6F6700B465D6 /* MigratingCRUDTests.mm */,\n\t\t\t\t0D0CD79E2A6FA1A900F89C6B /* CipherMigrationTests.mm */,\n\t\t\t\t0D0CD7A02A6FBE0C00F89C6B /* MigrateTests.mm */,\n\t\t\t);\n\t\t\tpath = compatible;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t0D5363E7290A64320026A4DC /* builtin */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t0D4FE5EE29482F4D0061C3CA /* Builtin.h */,\n\t\t\t\t0D5363E9290A65390026A4DC /* Master.hpp */,\n\t\t\t\t0D5363E8290A65390026A4DC /* Master.cpp */,\n\t\t\t\t0D5363EF290A75F20026A4DC /* Sequence.hpp */,\n\t\t\t\t0D5363EE290A75F20026A4DC /* Sequence.cpp */,\n\t\t\t);\n\t\t\tpath = builtin;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t0D8BC30A2B99C52500DE9AE5 /* bridge */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t036E50B628115AB8007365CD /* WCTBridgeProperty.h */,\n\t\t\t\t036E50BA28115BA0007365CD /* WCTBridgeProperty+CPP.h */,\n\t\t\t\t036E50B828115B1D007365CD /* WCTBridgeProperty.mm */,\n\t\t\t);\n\t\t\tpath = bridge;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t0DB806A22B972E1A00D5E86D /* bridge */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t039760A727F563F00071FA8F /* ObjectBridge.swift */,\n\t\t\t\t03C2EAEC27F8382200B41169 /* ErrorBridge.swift */,\n\t\t\t\t75E76AD329161EE400073CCA /* FTSBridge.swift */,\n\t\t\t\t036E50C028116D7A007365CD /* WCTBridgeProperty.swift */,\n\t\t\t);\n\t\t\tpath = bridge;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t0DE08A1A29CBE79C009A7CA3 /* platform */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t0DE08A1B29CBE79C009A7CA3 /* CrossPlatform.h */,\n\t\t\t\t0DE08A1C29CBE79C009A7CA3 /* WCTFileManager.cpp */,\n\t\t\t\t0DE08A1D29CBE79C009A7CA3 /* CrossPlatform.c */,\n\t\t\t\t0DE08A1E29CBE79C009A7CA3 /* WCTOperationQueue.cpp */,\n\t\t\t\t0D3FFA452A2F2911002DF7CD /* SysTypes.h */,\n\t\t\t);\n\t\t\tpath = platform;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t0DE68B342AB45ADB008BD74C /* model */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t0DE68B392AB45F5F008BD74C /* NormalRepairTestObject.h */,\n\t\t\t\t0DE68B3A2AB45F6C008BD74C /* NormalRepairTestObject.mm */,\n\t\t\t\t0DE68B3C2AB461A0008BD74C /* AutoIncrementRepairTestObject.h */,\n\t\t\t\t0DE68B3D2AB461AA008BD74C /* AutoIncrementRepairTestObject.mm */,\n\t\t\t\t0DE68B3F2AB466E5008BD74C /* WithoutRowidRepairTestObject.h */,\n\t\t\t\t0DE68B402AB466F1008BD74C /* WithoutRowidRepairTestObject.mm */,\n\t\t\t);\n\t\t\tpath = model;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t2321243920172865008146EF /* Products */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t23F5BE0620887FD4000CCD37 /* sqlcipher.framework */,\n\t\t\t);\n\t\t\tname = Products;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t232147001F6AAE6500BF7AF2 /* fts */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t2327414E1F6FBD50004E96F7 /* WCTDatabase+FTS.h */,\n\t\t\t\t2327414F1F6FBD50004E96F7 /* WCTDatabase+FTS.mm */,\n\t\t\t);\n\t\t\tpath = fts;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t233B097A21BE50C0005AD534 /* assemble */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t0D19BA092B0702250028F92B /* AssembleHandleOperator.cpp */,\n\t\t\t\t0D19BA0A2B0702250028F92B /* AssembleHandleOperator.hpp */,\n\t\t\t);\n\t\t\tpath = assemble;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t2349F5D51EA0D6680021EFA7 /* objc */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t2349F6BA1EA0D6680021EFA7 /* WCDBObjc.h */,\n\t\t\t\t23D4DA442085A3D300AE6D90 /* Interface.h */,\n\t\t\t\t234F0376227A9EFA00DD65A2 /* tests */,\n\t\t\t\t2370B0E321914EC200D3227C /* builtin */,\n\t\t\t\t757457022402D571005E3682 /* statement */,\n\t\t\t\t758E7EC02B1B400F00319991 /* compression */,\n\t\t\t\t236BACDF21BF9F5900C8B4D9 /* migration */,\n\t\t\t\t234DBCFE2064DE04000E31E8 /* transaction */,\n\t\t\t\t234DBCEB2064DD0B000E31E8 /* handle */,\n\t\t\t\t232147001F6AAE6500BF7AF2 /* fts */,\n\t\t\t\t2386B3BD1ED442D9000B72F6 /* monitor */,\n\t\t\t\t2349F63B1EA0D6680021EFA7 /* chaincall */,\n\t\t\t\t2349F6561EA0D6680021EFA7 /* convenient */,\n\t\t\t\t2349F65B1EA0D6680021EFA7 /* core */,\n\t\t\t\t2349F6681EA0D6680021EFA7 /* database */,\n\t\t\t\t2349F6791EA0D6680021EFA7 /* orm */,\n\t\t\t\t2349F6991EA0D6680021EFA7 /* table */,\n\t\t\t\t0D8BC30A2B99C52500DE9AE5 /* bridge */,\n\t\t\t);\n\t\t\tpath = objc;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t2349F5D61EA0D6680021EFA7 /* winq */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t23EEDBEB217DFADC006E9E73 /* WINQ.h */,\n\t\t\t\t23EEDBA9217DFADC006E9E73 /* SQL.hpp */,\n\t\t\t\t23EEDBA8217DFADC006E9E73 /* SQL.cpp */,\n\t\t\t\t23EEDBB8217DFADC006E9E73 /* Statement.hpp */,\n\t\t\t\t3962FFC723051429008934D4 /* Statement.cpp */,\n\t\t\t\t23EEDB67217DFADC006E9E73 /* extension */,\n\t\t\t\t23EEDB79217DFADC006E9E73 /* identifier */,\n\t\t\t\t23EEDBB6217DFADC006E9E73 /* statement */,\n\t\t\t\t23EEDBEC217DFADC006E9E73 /* syntax */,\n\t\t\t);\n\t\t\tpath = winq;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t2349F6151EA0D6680021EFA7 /* core */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t759362D72B36D667000AF163 /* vacuum */,\n\t\t\t\t754212092B124CFF00A2FF4D /* compression */,\n\t\t\t\t754211D92B11FCDE00A2FF4D /* function */,\n\t\t\t\t0D19BA1C2B0747E80028F92B /* integrity */,\n\t\t\t\t75F3140F2AAC07C9007FFDFB /* cipher */,\n\t\t\t\t235FBE92229145FC005C7723 /* sqlite */,\n\t\t\t\t233B097A21BE50C0005AD534 /* assemble */,\n\t\t\t\t23A09D632146204300F62EE8 /* migration */,\n\t\t\t\t23B4DCDE2112B03200954D71 /* operate */,\n\t\t\t\t23E163CA20FDDD6900C3F910 /* fts */,\n\t\t\t\t23F70F9D20A055A400CCE3CD /* config */,\n\t\t\t\t2349F61B1EA0D6680021EFA7 /* InnerDatabase.cpp */,\n\t\t\t\t2349F61C1EA0D6680021EFA7 /* InnerDatabase.hpp */,\n\t\t\t\t75CB08CA2A88B9A300429364 /* HandleCounter.hpp */,\n\t\t\t\t75CB08C92A88B9A300429364 /* HandleCounter.cpp */,\n\t\t\t\t2349F6221EA0D6680021EFA7 /* HandlePool.cpp */,\n\t\t\t\t2349F6231EA0D6680021EFA7 /* HandlePool.hpp */,\n\t\t\t\t23D96B902050DED700DB5E93 /* DatabasePool.cpp */,\n\t\t\t\t23D96B912050DED700DB5E93 /* DatabasePool.hpp */,\n\t\t\t\t2349F6241EA0D6680021EFA7 /* RecyclableHandle.cpp */,\n\t\t\t\t2349F6251EA0D6680021EFA7 /* RecyclableHandle.hpp */,\n\t\t\t\t39B524DC2304F9A2001DF52D /* InnerHandle.cpp */,\n\t\t\t\t39B524DB2304F9A1001DF52D /* InnerHandle.hpp */,\n\t\t\t\t23B4DC7C2111B39100954D71 /* Tag.cpp */,\n\t\t\t\t23B4DC7D2111B39200954D71 /* Tag.hpp */,\n\t\t\t\t234591F5204432E400DC7D34 /* CommonCore.hpp */,\n\t\t\t\t23B4DCBB2112A9C800954D71 /* CommonCore.cpp */,\n\t\t\t\t237C900621D45E6700EE6E44 /* CoreConst.h */,\n\t\t\t\t75E0A5BF2A7F4EEE00D4FE9A /* CoreConst.cpp */,\n\t\t\t\t391F7C83225DE8FD0095E82D /* CommonCore.h */,\n\t\t\t);\n\t\t\tpath = core;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t2349F63B1EA0D6680021EFA7 /* chaincall */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t2349F6431EA0D6680021EFA7 /* WCTInsert.h */,\n\t\t\t\t2349F6441EA0D6680021EFA7 /* WCTInsert.mm */,\n\t\t\t\t2349F6401EA0D6680021EFA7 /* WCTDelete.h */,\n\t\t\t\t2349F6411EA0D6680021EFA7 /* WCTDelete.mm */,\n\t\t\t\t2349F6541EA0D6680021EFA7 /* WCTUpdate.h */,\n\t\t\t\t2349F6551EA0D6680021EFA7 /* WCTUpdate.mm */,\n\t\t\t\t2349F64E1EA0D6680021EFA7 /* WCTSelectable+Private.h */,\n\t\t\t\t2349F64F1EA0D6680021EFA7 /* WCTSelectable.h */,\n\t\t\t\t2349F6501EA0D6680021EFA7 /* WCTSelectable.mm */,\n\t\t\t\t2349F64C1EA0D6680021EFA7 /* WCTSelect.h */,\n\t\t\t\t2349F64D1EA0D6680021EFA7 /* WCTSelect.mm */,\n\t\t\t\t2349F6471EA0D6680021EFA7 /* WCTMultiSelect.h */,\n\t\t\t\t2349F6481EA0D6680021EFA7 /* WCTMultiSelect.mm */,\n\t\t\t\t233A05892062698E00F1A212 /* WCTHandle+ChainCall.h */,\n\t\t\t\t233A058A2062698E00F1A212 /* WCTHandle+ChainCall.mm */,\n\t\t\t\t2349F6511EA0D6680021EFA7 /* WCTTable+ChainCall.h */,\n\t\t\t\t2349F6521EA0D6680021EFA7 /* WCTTable+ChainCall.mm */,\n\t\t\t\t23F340DC204D3482007DB8AB /* WCTDatabase+ChainCall.h */,\n\t\t\t\t23F340DD204D3482007DB8AB /* WCTDatabase+ChainCall.mm */,\n\t\t\t\t234DBD0B2064E045000E31E8 /* WCTChainCall.h */,\n\t\t\t\t23776CA3218C41DD00E985DC /* WCTChainCall.mm */,\n\t\t\t\t23776CA5218C41E600E985DC /* WCTChainCall+Private.h */,\n\t\t\t\t2372E05721A2633800051D9A /* WCTTryDisposeGuard.mm */,\n\t\t\t\t2372E05821A2633800051D9A /* WCTTryDisposeGuard.h */,\n\t\t\t);\n\t\t\tpath = chaincall;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t2349F6561EA0D6680021EFA7 /* convenient */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t2349F6571EA0D6680021EFA7 /* WCTDatabase+Convenient.h */,\n\t\t\t\t2349F6581EA0D6680021EFA7 /* WCTDatabase+Convenient.mm */,\n\t\t\t\t2349F6591EA0D6680021EFA7 /* WCTTable+Convenient.h */,\n\t\t\t\t2349F65A1EA0D6680021EFA7 /* WCTTable+Convenient.mm */,\n\t\t\t\t23A3CFB3205FB1A800692F94 /* WCTHandle+Convenient.h */,\n\t\t\t\t23A3CFB4205FB1A800692F94 /* WCTHandle+Convenient.mm */,\n\t\t\t\t23FEC461206B3032001E7A3B /* WCTConvenient.h */,\n\t\t\t);\n\t\t\tpath = convenient;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t2349F65B1EA0D6680021EFA7 /* core */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t234EF46C2015CFDE00B81929 /* WCTConvertible.h */,\n\t\t\t\t234EF46D2015CFDE00B81929 /* WCTConvertible.mm */,\n\t\t\t\t23BBE2A5204955CD00C4CBB6 /* WCTCommon.h */,\n\t\t\t\t23DF0A0D219028E900F0B2B6 /* WCTDeclaration.h */,\n\t\t\t\t2316D93521058B5500707AFC /* WCTFileManager.mm */,\n\t\t\t\t232C6F00229C0A280046742F /* WCTOperationQueue.mm */,\n\t\t\t\t23577F771F74F4E800D31C05 /* WCTFTSTokenizerUtil.h */,\n\t\t\t\t23577F781F74F4E800D31C05 /* WCTFTSTokenizerUtil.mm */,\n\t\t\t\t2370B1302191533C00D3227C /* WCTOptional.h */,\n\t\t\t\t3995150622C2095B008394CC /* WCTOptional.mm */,\n\t\t\t\t23F70F79209FF0EC00CCE3CD /* WCTValue.h */,\n\t\t\t\t23F70F7A209FF0EC00CCE3CD /* WCTValue.mm */,\n\t\t\t\t23176A9921BA7D460051ACF9 /* WCTDatabase+Version.h */,\n\t\t\t\t23176A9A21BA7D460051ACF9 /* WCTDatabase+Version.mm */,\n\t\t\t\t39579856227FBC8A0069F985 /* WCTDatabase+Test.h */,\n\t\t\t\t39579857227FBC8A0069F985 /* WCTDatabase+Test.mm */,\n\t\t\t\t39A3341722B0DD9F008EA5D5 /* WCTFoundation.h */,\n\t\t\t\t39A3341822B0DD9F008EA5D5 /* WCTFoundation.mm */,\n\t\t\t\t3969018A233B1B2F006EEFD4 /* WCTTag.h */,\n\t\t\t);\n\t\t\tpath = core;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t2349F6681EA0D6680021EFA7 /* database */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t23DF0A082190275B00F0B2B6 /* WCTDatabase.h */,\n\t\t\t\t23DF0A072190275B00F0B2B6 /* WCTDatabase.mm */,\n\t\t\t\t23DF0A092190275B00F0B2B6 /* WCTDatabase+Private.h */,\n\t\t\t\t2349F66B1EA0D6680021EFA7 /* WCTDatabase+File.h */,\n\t\t\t\t2349F66C1EA0D6680021EFA7 /* WCTDatabase+File.mm */,\n\t\t\t\t2308F8A720E37FB0001CD9C3 /* WCTDatabase+Repair.h */,\n\t\t\t\t2349F66F1EA0D6680021EFA7 /* WCTDatabase+Repair.mm */,\n\t\t\t\t23BBE2AB2049565600C4CBB6 /* WCTDatabase+Config.h */,\n\t\t\t\t23BBE2AC2049565600C4CBB6 /* WCTDatabase+Config.mm */,\n\t\t\t\t23BBE2AF2049576D00C4CBB6 /* WCTDatabase+Memory.h */,\n\t\t\t\t23BBE2B02049576D00C4CBB6 /* WCTDatabase+Memory.mm */,\n\t\t\t);\n\t\t\tpath = database;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t2349F6791EA0D6680021EFA7 /* orm */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t2349F67A1EA0D6680021EFA7 /* accessor */,\n\t\t\t\t2349F6831EA0D6680021EFA7 /* binding */,\n\t\t\t\t2349F68C1EA0D6680021EFA7 /* coding */,\n\t\t\t\t2349F6921EA0D6680021EFA7 /* macro */,\n\t\t\t\t2349F6981EA0D6680021EFA7 /* WCTORM.h */,\n\t\t\t);\n\t\t\tpath = orm;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t2349F67A1EA0D6680021EFA7 /* accessor */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t2349F67B1EA0D6680021EFA7 /* WCTBaseAccessor.h */,\n\t\t\t\t3962FFC9230514CD008934D4 /* WCTBaseAccessor.mm */,\n\t\t\t\t2349F67C1EA0D6680021EFA7 /* WCTCppAccessor.h */,\n\t\t\t\t2349F67D1EA0D6680021EFA7 /* WCTObjCAccessor.h */,\n\t\t\t\t237908F621928C9F0098797F /* WCTObjCAccessor.mm */,\n\t\t\t\t2349F67E1EA0D6680021EFA7 /* WCTRuntimeBaseAccessor.h */,\n\t\t\t\t2349F67F1EA0D6680021EFA7 /* WCTRuntimeBaseAccessor.mm */,\n\t\t\t\t2349F6801EA0D6680021EFA7 /* WCTRuntimeCppAccessor.h */,\n\t\t\t\t2349F6811EA0D6680021EFA7 /* WCTRuntimeObjCAccessor.h */,\n\t\t\t\t2349F6821EA0D6680021EFA7 /* WCTRuntimeObjCAccessor.mm */,\n\t\t\t);\n\t\t\tpath = accessor;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t2349F6831EA0D6680021EFA7 /* binding */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t2349F6841EA0D6680021EFA7 /* WCTBinding.h */,\n\t\t\t\t2349F6851EA0D6680021EFA7 /* WCTBinding.mm */,\n\t\t\t\t2349F6861EA0D6680021EFA7 /* WCTColumnBinding.h */,\n\t\t\t\t2349F6871EA0D6680021EFA7 /* WCTColumnBinding.mm */,\n\t\t\t);\n\t\t\tpath = binding;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t2349F68C1EA0D6680021EFA7 /* coding */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t2349F68D1EA0D6680021EFA7 /* WCTTableCoding.h */,\n\t\t\t\t3932B9FC25232D9F0094F3F8 /* WCTColumnCoding.h */,\n\t\t\t\t2349F6901EA0D6680021EFA7 /* WCTProperty.h */,\n\t\t\t\t2349F6911EA0D6680021EFA7 /* WCTProperty.mm */,\n\t\t\t\t2396EB0B21801BD60079066C /* WCTResultColumn.h */,\n\t\t\t\t2396EB0C21801BD60079066C /* WCTResultColumn.mm */,\n\t\t\t);\n\t\t\tpath = coding;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t2349F6921EA0D6680021EFA7 /* macro */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t2349F6931EA0D6680021EFA7 /* WCTMacro.h */,\n\t\t\t\t2349F6941EA0D6680021EFA7 /* WCTPropertyMacro.h */,\n\t\t\t\t2349F6961EA0D6680021EFA7 /* WCTIndexMacro.h */,\n\t\t\t\t2349F6951EA0D6680021EFA7 /* WCTTableConstraintMacro.h */,\n\t\t\t\t23790A7D219315D50098797F /* WCTColumnConstraintMacro.h */,\n\t\t\t\t23790A7E219315DE0098797F /* WCTVirtualTableMacro.h */,\n\t\t\t\t23B101E82090667B005D9DD3 /* WCTMacroUtility.h */,\n\t\t\t);\n\t\t\tpath = macro;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t2349F6991EA0D6680021EFA7 /* table */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t23F340D8204D32C2007DB8AB /* WCTTable.h */,\n\t\t\t\t23F340D9204D32C2007DB8AB /* WCTTable.mm */,\n\t\t\t\t2349F69E1EA0D6680021EFA7 /* WCTTable+Private.h */,\n\t\t\t\t3969018E233B20BC006EEFD4 /* WCTTableProtocol.h */,\n\t\t\t\t39690192233B2235006EEFD4 /* WCTTable+Table.h */,\n\t\t\t\t39690193233B2235006EEFD4 /* WCTTable+Table.mm */,\n\t\t\t\t2349F69A1EA0D6680021EFA7 /* WCTDatabase+Table.h */,\n\t\t\t\t2349F69B1EA0D6680021EFA7 /* WCTDatabase+Table.mm */,\n\t\t\t\t23EABBE4206D08EC00241F3B /* WCTHandle+Table.h */,\n\t\t\t\t23EABBE5206D08EC00241F3B /* WCTHandle+Table.mm */,\n\t\t\t);\n\t\t\tpath = table;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t2349F6A71EA0D6680021EFA7 /* utility */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t23B4DCDF2112B03C00954D71 /* AsyncQueue.cpp */,\n\t\t\t\t23B4DCE02112B03C00954D71 /* AsyncQueue.hpp */,\n\t\t\t\t23176A8B21B912B10051ACF9 /* WCDBVersion.h */,\n\t\t\t\t23EEDD5E217DFB16006E9E73 /* Enum.hpp */,\n\t\t\t\t23EEDD5F217DFB17006E9E73 /* Shadow.hpp */,\n\t\t\t\t239776D0202AF2E2000A681C /* Macro.h */,\n\t\t\t\t239776CE202AF2E2000A681C /* TimedQueue.hpp */,\n\t\t\t\t237A65F220F731DF008B4771 /* UniqueList.hpp */,\n\t\t\t\t39411A3E22437E7B00A388F5 /* CaseInsensitiveList.hpp */,\n\t\t\t\t231C35EA21DE090500B5D3D2 /* Exiting.hpp */,\n\t\t\t\t231C35EC21DE09E400B5D3D2 /* Exiting.cpp */,\n\t\t\t);\n\t\t\tpath = utility;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t234DBCEB2064DD0B000E31E8 /* handle */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t234DBCEC2064DD0B000E31E8 /* WCTDatabase+Handle.h */,\n\t\t\t\t234DBCED2064DD0B000E31E8 /* WCTDatabase+Handle.mm */,\n\t\t\t\t234DBCF02064DD0B000E31E8 /* WCTHandle+Private.h */,\n\t\t\t\t234DBCF12064DD0B000E31E8 /* WCTHandle.h */,\n\t\t\t\t234DBCF22064DD0B000E31E8 /* WCTHandle.mm */,\n\t\t\t\t0D8084202A861E8500C81BBF /* WCTCancellationSignal.h */,\n\t\t\t\t0D8084262A861FDB00C81BBF /* WCTCancellationSignal+Private.h */,\n\t\t\t\t0D8084232A861E9500C81BBF /* WCTCancellationSignal.mm */,\n\t\t\t);\n\t\t\tpath = handle;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t234DBCFE2064DE04000E31E8 /* transaction */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t234DBCFF2064DE04000E31E8 /* WCTDatabase+Transaction.h */,\n\t\t\t\t234DBD012064DE04000E31E8 /* WCTHandle+Transaction.h */,\n\t\t\t\t234DBD002064DE04000E31E8 /* WCTDatabase+Transaction.mm */,\n\t\t\t\t234DBD022064DE04000E31E8 /* WCTHandle+Transaction.mm */,\n\t\t\t\t234DBD072064DE23000E31E8 /* WCTTransaction.h */,\n\t\t\t);\n\t\t\tpath = transaction;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t234F0376227A9EFA00DD65A2 /* tests */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t234F0377227A9EFA00DD65A2 /* benchmark */,\n\t\t\t\t234F0383227A9EFA00DD65A2 /* monitor */,\n\t\t\t\t234F0386227A9EFA00DD65A2 /* host */,\n\t\t\t\t234F038A227A9EFA00DD65A2 /* config */,\n\t\t\t\t234F038C227A9EFA00DD65A2 /* basic */,\n\t\t\t\t234F0392227A9EFA00DD65A2 /* winq */,\n\t\t\t\t234F03D7227A9EFA00DD65A2 /* advance */,\n\t\t\t\t234F03F8227A9EFA00DD65A2 /* fts */,\n\t\t\t\t234F03FD227A9EFA00DD65A2 /* common */,\n\t\t\t\t234F0431227A9EFA00DD65A2 /* orm */,\n\t\t\t\t234F0473227A9EFA00DD65A2 /* convenient */,\n\t\t\t\t234F0478227A9EFA00DD65A2 /* thread */,\n\t\t\t\t234F049D227A9EFA00DD65A2 /* repair */,\n\t\t\t\t758E7F2D2B1C82AA00319991 /* compression */,\n\t\t\t\t7522B4BD2A6D2E3800B465D6 /* migration */,\n\t\t\t);\n\t\t\tpath = tests;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t234F0377227A9EFA00DD65A2 /* benchmark */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t234F057B227AA4CB00DD65A2 /* ObjectsBasedBenchmark.h */,\n\t\t\t\t234F057F227AA4CC00DD65A2 /* ObjectsBasedBenchmark.mm */,\n\t\t\t\t234F057A227AA4CB00DD65A2 /* BaselineBenchmark.mm */,\n\t\t\t\t234F0580227AA4CC00DD65A2 /* CipherBenchmark.mm */,\n\t\t\t\t39327ABF22CF265600AABD4B /* RetrieveBenchmark.mm */,\n\t\t\t\t39327AAA22CEFD0F00AABD4B /* TableBenchmark.mm */,\n\t\t\t\t39327BAF22CF2C5400AABD4B /* MigrationBenchmark.h */,\n\t\t\t\t39327BB022CF2C5400AABD4B /* MigrationBenchmark.mm */,\n\t\t\t\t39327BB122CF2C5400AABD4B /* TableMigrationBenchmark.mm */,\n\t\t\t\t39327BB222CF2C5400AABD4B /* DatabaseMigrationBenchmark.mm */,\n\t\t\t\t758DC8032B255EF900E71D9B /* CompressionBenchmark.h */,\n\t\t\t\t758DC8012B255EBF00E71D9B /* CompressionBenchmark.mm */,\n\t\t\t\t758DC8042B25671E00E71D9B /* NormalCompressionBenchmark.mm */,\n\t\t\t\t758DC8062B25678800E71D9B /* DictCompressionBenchmark.mm */,\n\t\t\t\t759362CB2B368D87000AF163 /* VacuumBenchmark.mm */,\n\t\t\t);\n\t\t\tpath = benchmark;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t234F0383227A9EFA00DD65A2 /* monitor */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t234F058C227AA4D700DD65A2 /* TraceTests.mm */,\n\t\t\t\t234F058B227AA4D700DD65A2 /* VersionTests.mm */,\n\t\t\t);\n\t\t\tpath = monitor;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t234F0386227A9EFA00DD65A2 /* host */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t234F0753227AB18B00DD65A2 /* host.xcconfig */,\n\t\t\t\t234F0388227A9EFA00DD65A2 /* main.m */,\n\t\t\t\t234F0389227A9EFA00DD65A2 /* Info.plist */,\n\t\t\t);\n\t\t\tpath = host;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t234F038A227A9EFA00DD65A2 /* config */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t234F038B227A9EFA00DD65A2 /* ConfigTests.mm */,\n\t\t\t\t234F058F227AA4E100DD65A2 /* DatabaseTests.mm */,\n\t\t\t);\n\t\t\tpath = config;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t234F038C227A9EFA00DD65A2 /* basic */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t234F0591227AA4E200DD65A2 /* FileTests.mm */,\n\t\t\t\t234F0590227AA4E100DD65A2 /* ObservationTests.mm */,\n\t\t\t\t234F0593227AA4E200DD65A2 /* TableTests.mm */,\n\t\t\t);\n\t\t\tpath = basic;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t234F0392227A9EFA00DD65A2 /* winq */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t234F05C8227AA4F300DD65A2 /* AggregateFunctionTests.mm */,\n\t\t\t\t234F05A7227AA4EE00DD65A2 /* BindParameterTests.mm */,\n\t\t\t\t234F059E227AA4ED00DD65A2 /* ColumnConstraintTests.mm */,\n\t\t\t\t234F05C3227AA4F200DD65A2 /* ColumnDefTests.mm */,\n\t\t\t\t234F05BB227AA4F100DD65A2 /* ColumnOperableTests.mm */,\n\t\t\t\t234F05D2227AA4F400DD65A2 /* ColumnTests.mm */,\n\t\t\t\t234F05B4227AA4F000DD65A2 /* ColumnTypeTests.mm */,\n\t\t\t\t234F05CE227AA4F400DD65A2 /* CommonTableExpressionTests.mm */,\n\t\t\t\t234F05A8227AA4EE00DD65A2 /* ConflictTests.mm */,\n\t\t\t\t234F05A3227AA4EE00DD65A2 /* CoreFunctionTests.mm */,\n\t\t\t\t234F05B1227AA4F000DD65A2 /* ExpressionOperableTests.mm */,\n\t\t\t\t234F05AF227AA4EF00DD65A2 /* ExpressionTests.mm */,\n\t\t\t\t234F05BF227AA4F200DD65A2 /* FilterTests.mm */,\n\t\t\t\t234F05B9227AA4F100DD65A2 /* ForeignKeyTests.mm */,\n\t\t\t\t234F059A227AA4ED00DD65A2 /* FrameSpecTests.mm */,\n\t\t\t\t234F059B227AA4ED00DD65A2 /* FTSFunctionTests.mm */,\n\t\t\t\t234F05B0227AA4EF00DD65A2 /* IndexedColumnTests.mm */,\n\t\t\t\t234F05AB227AA4EF00DD65A2 /* JoinConstraintTests.mm */,\n\t\t\t\t234F05D4227AA4F500DD65A2 /* JoinTests.mm */,\n\t\t\t\t234F05CB227AA4F300DD65A2 /* LiteralValueTests.mm */,\n\t\t\t\t234F05A6227AA4EE00DD65A2 /* OrderingTermTests.mm */,\n\t\t\t\t234F05D6227AA4F500DD65A2 /* OrderTests.mm */,\n\t\t\t\t234F05DC227AA4F600DD65A2 /* PragmaTests.mm */,\n\t\t\t\t234F05D7227AA4F500DD65A2 /* QualifiedTableTests.mm */,\n\t\t\t\t234F05B8227AA4F100DD65A2 /* RaiseFunctionTests.mm */,\n\t\t\t\t234F05D9227AA4F600DD65A2 /* ResultColumnTests.mm */,\n\t\t\t\t03D3A2A628A65D2F0064D4D4 /* ValueTests.mm */,\n\t\t\t\t234F05BD227AA4F100DD65A2 /* SchemaTests.mm */,\n\t\t\t\t234F0599227AA4EC00DD65A2 /* StatementAlterTableTests.mm */,\n\t\t\t\t234F05B6227AA4F000DD65A2 /* StatementAnalyzeTests.mm */,\n\t\t\t\t234F05C5227AA4F300DD65A2 /* StatementAttachTests.mm */,\n\t\t\t\t234F05BC227AA4F100DD65A2 /* StatementBeginTests.mm */,\n\t\t\t\t234F05C9227AA4F300DD65A2 /* StatementCommitTests.mm */,\n\t\t\t\t234F05C6227AA4F300DD65A2 /* StatementCreateIndexTests.mm */,\n\t\t\t\t234F05B3227AA4F000DD65A2 /* StatementCreateTableTests.mm */,\n\t\t\t\t234F05B2227AA4F000DD65A2 /* StatementCreateTriggerTests.mm */,\n\t\t\t\t234F05CC227AA4F400DD65A2 /* StatementCreateViewTests.mm */,\n\t\t\t\t234F05AD227AA4EF00DD65A2 /* StatementCreateVirtualTableTests.mm */,\n\t\t\t\t234F05A1227AA4ED00DD65A2 /* StatementDeleteTests.mm */,\n\t\t\t\t234F05B5227AA4F000DD65A2 /* StatementDetachTests.mm */,\n\t\t\t\t234F05C4227AA4F200DD65A2 /* StatementDropIndexTests.mm */,\n\t\t\t\t234F05CF227AA4F400DD65A2 /* StatementDropTableTests.mm */,\n\t\t\t\t234F05DA227AA4F600DD65A2 /* StatementDropTriggerTests.mm */,\n\t\t\t\t234F05C1227AA4F200DD65A2 /* StatementDropViewTests.mm */,\n\t\t\t\t3960D8A123192A9D00EF05D1 /* StatementExplainTests.mm */,\n\t\t\t\t234F05D5227AA4F500DD65A2 /* StatementInsertTests.mm */,\n\t\t\t\t234F059D227AA4ED00DD65A2 /* StatementPragmaTests.mm */,\n\t\t\t\t234F05BE227AA4F200DD65A2 /* StatementReindexTests.mm */,\n\t\t\t\t234F05A4227AA4EE00DD65A2 /* StatementReleaseTests.mm */,\n\t\t\t\t234F05D8227AA4F500DD65A2 /* StatementRollbackTests.mm */,\n\t\t\t\t234F05AA227AA4EF00DD65A2 /* StatementSavepointTests.mm */,\n\t\t\t\t234F05C0227AA4F200DD65A2 /* StatementSelectTests.mm */,\n\t\t\t\t234F059C227AA4ED00DD65A2 /* StatementTests.mm */,\n\t\t\t\t234F05C7227AA4F300DD65A2 /* StatementUpdateTests.mm */,\n\t\t\t\t234F05B7227AA4F100DD65A2 /* StatementVacuumTests.mm */,\n\t\t\t\t234F05C2227AA4F200DD65A2 /* StoppableIterationTests.mm */,\n\t\t\t\t234F05CD227AA4F400DD65A2 /* SyntaxListTests.mm */,\n\t\t\t\t234F05DB227AA4F600DD65A2 /* TableConstraintTests.mm */,\n\t\t\t\t234F05AC227AA4EF00DD65A2 /* TableOrSubqueryTests.mm */,\n\t\t\t\t234F05A5227AA4EE00DD65A2 /* UpsertTests.mm */,\n\t\t\t\t234F05D0227AA4F400DD65A2 /* WCTPropertyTests.mm */,\n\t\t\t\t234F05A9227AA4EF00DD65A2 /* WCTResultColumnTests.mm */,\n\t\t\t\t234F05CA227AA4F300DD65A2 /* WindowDefTests.mm */,\n\t\t\t\t234F05BA227AA4F100DD65A2 /* WINQAssertion.h */,\n\t\t\t\t234F05AE227AA4EF00DD65A2 /* WINQAssertion.mm */,\n\t\t\t);\n\t\t\tpath = winq;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t234F03D7227A9EFA00DD65A2 /* advance */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t234F03D8227A9EFA00DD65A2 /* handle */,\n\t\t\t\t234F03DA227A9EFA00DD65A2 /* column_coding */,\n\t\t\t\t234F03F5227A9EFA00DD65A2 /* chaincall */,\n\t\t\t);\n\t\t\tpath = advance;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t234F03D8227A9EFA00DD65A2 /* handle */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t234F03D9227A9EFA00DD65A2 /* HandleTests.mm */,\n\t\t\t);\n\t\t\tpath = handle;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t234F03DA227A9EFA00DD65A2 /* column_coding */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t234F0622227AA50400DD65A2 /* ColumnCodingObject.h */,\n\t\t\t\t234F0625227AA50500DD65A2 /* ColumnCodingObject.mm */,\n\t\t\t\t234F0627227AA50500DD65A2 /* ColumnCodingObject+WCTTableCoding.h */,\n\t\t\t\t234F062E227AA50600DD65A2 /* ColumnCodingTests.mm */,\n\t\t\t\t234F0634227AA50700DD65A2 /* DataCodingObject.h */,\n\t\t\t\t234F0632227AA50700DD65A2 /* DataCodingObject.m */,\n\t\t\t\t234F0628227AA50500DD65A2 /* DataCodingObject+WCTColumnCoding.h */,\n\t\t\t\t234F0638227AA50800DD65A2 /* DataCodingObject+WCTColumnCoding.mm */,\n\t\t\t\t234F062F227AA50600DD65A2 /* DoubleCodingObject.h */,\n\t\t\t\t234F0631227AA50700DD65A2 /* DoubleCodingObject.m */,\n\t\t\t\t234F0629227AA50500DD65A2 /* DoubleCodingObject+WCTColumnCoding.h */,\n\t\t\t\t234F0630227AA50600DD65A2 /* DoubleCodingObject+WCTColumnCoding.mm */,\n\t\t\t\t234F062D227AA50600DD65A2 /* IntegerCodingObject.h */,\n\t\t\t\t234F0621227AA50400DD65A2 /* IntegerCodingObject.m */,\n\t\t\t\t234F0637227AA50700DD65A2 /* IntegerCodingObject+WCTColumnCoding.h */,\n\t\t\t\t234F0623227AA50500DD65A2 /* IntegerCodingObject+WCTColumnCoding.mm */,\n\t\t\t\t234F062A227AA50500DD65A2 /* Random+ColumnCodingObject.h */,\n\t\t\t\t234F0639227AA50800DD65A2 /* Random+ColumnCodingObject.mm */,\n\t\t\t\t234F0635227AA50700DD65A2 /* StringCodingObject.h */,\n\t\t\t\t234F062C227AA50600DD65A2 /* StringCodingObject.m */,\n\t\t\t\t234F062B227AA50600DD65A2 /* StringCodingObject+WCTColumnCoding.h */,\n\t\t\t\t234F0626227AA50500DD65A2 /* StringCodingObject+WCTColumnCoding.mm */,\n\t\t\t);\n\t\t\tpath = column_coding;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t234F03F5227A9EFA00DD65A2 /* chaincall */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t234F03F7227A9EFA00DD65A2 /* ChainCallTests.mm */,\n\t\t\t\t234F03F6227A9EFA00DD65A2 /* MultiSelectTests.mm */,\n\t\t\t);\n\t\t\tpath = chaincall;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t234F03F8227A9EFA00DD65A2 /* fts */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t234F0647227AA51400DD65A2 /* FTS3Object.h */,\n\t\t\t\t234F064A227AA51500DD65A2 /* FTS3Object.mm */,\n\t\t\t\t234F0648227AA51500DD65A2 /* FTS3Object+WCTTableCoding.h */,\n\t\t\t\t234F0649227AA51500DD65A2 /* FTS3Tests.mm */,\n\t\t\t\t0D0D56BF254ABE9B000F16A6 /* FTS5Object.h */,\n\t\t\t\t0D0D56C0254ABEAA000F16A6 /* FTS5Object.mm */,\n\t\t\t\t0D0D56C9254AC0F0000F16A6 /* FTS5Test.mm */,\n\t\t\t);\n\t\t\tpath = fts;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t234F03FD227A9EFA00DD65A2 /* common */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t39327ADF22CF271D00AABD4B /* TestCase.h */,\n\t\t\t\t39327AE022CF271E00AABD4B /* TableTestCase.h */,\n\t\t\t\t39327AE522CF271E00AABD4B /* TableTestCase.mm */,\n\t\t\t\t39327AD622CF271D00AABD4B /* BaseTestCase.h */,\n\t\t\t\t39327AE222CF271E00AABD4B /* BaseTestCase.mm */,\n\t\t\t\t39327AE122CF271E00AABD4B /* CRUDTestCase.h */,\n\t\t\t\t39327AE422CF271E00AABD4B /* CRUDTestCase.mm */,\n\t\t\t\t39327AD722CF271D00AABD4B /* DatabaseTestCase.h */,\n\t\t\t\t39327AE322CF271E00AABD4B /* DatabaseTestCase.mm */,\n\t\t\t\t39327AED22CF271E00AABD4B /* Benchmark.h */,\n\t\t\t\t39327AD522CF271D00AABD4B /* Benchmark.mm */,\n\t\t\t\t0DDF542C2B32D3FF00DB3D65 /* RobustyTestCase.h */,\n\t\t\t\t0DDF542A2B32D3EC00DB3D65 /* RobustyTestCase.mm */,\n\t\t\t\t39327AEE22CF271F00AABD4B /* factory */,\n\t\t\t\t39327AD822CF271D00AABD4B /* object */,\n\t\t\t\t39327AE622CF271E00AABD4B /* random */,\n\t\t\t\t39327AC422CF271D00AABD4B /* utility */,\n\t\t\t);\n\t\t\tpath = common;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t234F0431227A9EFA00DD65A2 /* orm */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t234F0445227A9EFA00DD65A2 /* ORMTests.mm */,\n\t\t\t\t234F0432227A9EFA00DD65A2 /* addtional */,\n\t\t\t\t234F0436227A9EFA00DD65A2 /* virtual_table */,\n\t\t\t\t234F043D227A9EFA00DD65A2 /* table_constraint */,\n\t\t\t\t234F0441227A9EFA00DD65A2 /* property */,\n\t\t\t\t234F0446227A9EFA00DD65A2 /* column_constraint */,\n\t\t\t\t234F0462227A9EFA00DD65A2 /* index */,\n\t\t\t\t234F0466227A9EFA00DD65A2 /* rebind */,\n\t\t\t);\n\t\t\tpath = orm;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t234F0432227A9EFA00DD65A2 /* addtional */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t234F06A5227AA55400DD65A2 /* AdditionalORMObject.h */,\n\t\t\t\t234F06A4227AA55400DD65A2 /* AdditionalORMObject.mm */,\n\t\t\t\t234F06A3227AA55400DD65A2 /* AdditionalORMObject+WCTTableCoding.h */,\n\t\t\t);\n\t\t\tpath = addtional;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t234F0436227A9EFA00DD65A2 /* virtual_table */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t234F06AC227AA56300DD65A2 /* VirtualTableFTS4Object.h */,\n\t\t\t\t234F06AB227AA56300DD65A2 /* VirtualTableFTS4Object.mm */,\n\t\t\t\t234F06A8227AA56300DD65A2 /* VirtualTableFTS4Object+WCTTableCoding.h */,\n\t\t\t\t234F06A7227AA56200DD65A2 /* VirtualTableFTS5Object.h */,\n\t\t\t\t234F06A9227AA56300DD65A2 /* VirtualTableFTS5Object.mm */,\n\t\t\t\t234F06AA227AA56300DD65A2 /* VirtualTableFTS5Object+WCTTableCoding.h */,\n\t\t\t);\n\t\t\tpath = virtual_table;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t234F043D227A9EFA00DD65A2 /* table_constraint */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t234F06B1227AA56B00DD65A2 /* TableConstraintObject.h */,\n\t\t\t\t234F06B0227AA56B00DD65A2 /* TableConstraintObject.mm */,\n\t\t\t\t234F06AF227AA56B00DD65A2 /* TableConstraintObject+WCTTableCoding.h */,\n\t\t\t);\n\t\t\tpath = table_constraint;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t234F0441227A9EFA00DD65A2 /* property */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t234F06B4227AA57100DD65A2 /* PropertyObject.h */,\n\t\t\t\t234F06B5227AA57100DD65A2 /* PropertyObject.mm */,\n\t\t\t\t234F06B3227AA57100DD65A2 /* PropertyObject+WCTTableCoding.h */,\n\t\t\t\t7511EA4E293CDAE700FB033B /* NewPropertyObject.h */,\n\t\t\t\t7511EA4F293CDAFB00FB033B /* NewPropertyObject.mm */,\n\t\t\t);\n\t\t\tpath = property;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t234F0446227A9EFA00DD65A2 /* column_constraint */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t234F06D0227AA57D00DD65A2 /* ColumnConstraintAutoIncrement.h */,\n\t\t\t\t234F06B8227AA57A00DD65A2 /* ColumnConstraintAutoIncrement.mm */,\n\t\t\t\t234F06C3227AA57B00DD65A2 /* ColumnConstraintAutoIncrement+WCTTableCoding.h */,\n\t\t\t\t234F06C0227AA57B00DD65A2 /* ColumnConstraintAutoIncrementAsc.h */,\n\t\t\t\t234F06BE227AA57B00DD65A2 /* ColumnConstraintAutoIncrementAsc.mm */,\n\t\t\t\t234F06B9227AA57A00DD65A2 /* ColumnConstraintAutoIncrementAsc+WCTTableCoding.h */,\n\t\t\t\t234F06C1227AA57B00DD65A2 /* ColumnConstraintCheck.h */,\n\t\t\t\t234F06BF227AA57B00DD65A2 /* ColumnConstraintCheck.mm */,\n\t\t\t\t234F06CF227AA57D00DD65A2 /* ColumnConstraintCheck+WCTTableCoding.h */,\n\t\t\t\t234F06D1227AA57D00DD65A2 /* ColumnConstraintDefault.h */,\n\t\t\t\t234F06CA227AA57C00DD65A2 /* ColumnConstraintDefault.mm */,\n\t\t\t\t234F06B7227AA57A00DD65A2 /* ColumnConstraintDefault+WCTTableCoding.h */,\n\t\t\t\t234F06C9227AA57C00DD65A2 /* ColumnConstraintNotNull.h */,\n\t\t\t\t234F06BA227AA57A00DD65A2 /* ColumnConstraintNotNull.mm */,\n\t\t\t\t234F06C7227AA57C00DD65A2 /* ColumnConstraintNotNull+WCTTableCoding.h */,\n\t\t\t\t234F06CC227AA57D00DD65A2 /* ColumnConstraintPrimary.h */,\n\t\t\t\t234F06C6227AA57C00DD65A2 /* ColumnConstraintPrimary.mm */,\n\t\t\t\t234F06C4227AA57B00DD65A2 /* ColumnConstraintPrimary+WCTTableCoding.h */,\n\t\t\t\t234F06C8227AA57C00DD65A2 /* ColumnConstraintPrimaryAsc.h */,\n\t\t\t\t234F06BD227AA57B00DD65A2 /* ColumnConstraintPrimaryAsc.mm */,\n\t\t\t\t234F06BC227AA57A00DD65A2 /* ColumnConstraintPrimaryAsc+WCTTableCoding.h */,\n\t\t\t\t234F06C2227AA57B00DD65A2 /* ColumnConstraintPrimaryDesc.h */,\n\t\t\t\t234F06C5227AA57B00DD65A2 /* ColumnConstraintPrimaryDesc.mm */,\n\t\t\t\t234F06CB227AA57C00DD65A2 /* ColumnConstraintPrimaryDesc+WCTTableCoding.h */,\n\t\t\t\t234F06BB227AA57A00DD65A2 /* ColumnConstraintUnique.h */,\n\t\t\t\t234F06CD227AA57D00DD65A2 /* ColumnConstraintUnique.mm */,\n\t\t\t\t234F06CE227AA57D00DD65A2 /* ColumnConstraintUnique+WCTTableCoding.h */,\n\t\t\t\t0D81CDA82A569CB40051FF8E /* ColumnConstraintEnablePrimaryAutoIncrement.h */,\n\t\t\t\t0D81CDA92A569CE40051FF8E /* ColumnConstraintEnablePrimaryAutoIncrement.mm */,\n\t\t\t\t0D81CDAA2A569CFC0051FF8E /* ColumnConstraintEnablePrimaryAutoIncrement+WCTTableCoding.h */,\n\t\t\t);\n\t\t\tpath = column_constraint;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t234F0462227A9EFA00DD65A2 /* index */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t234F06DB227AA58400DD65A2 /* IndexObject.h */,\n\t\t\t\t234F06DC227AA58400DD65A2 /* IndexObject.mm */,\n\t\t\t\t234F06DD227AA58400DD65A2 /* IndexObject+WCTTableCoding.h */,\n\t\t\t);\n\t\t\tpath = index;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t234F0466227A9EFA00DD65A2 /* rebind */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t234F06E2227AA58C00DD65A2 /* DropIndexObject.h */,\n\t\t\t\t234F06E6227AA58D00DD65A2 /* DropIndexObject.mm */,\n\t\t\t\t234F06E3227AA58D00DD65A2 /* DropIndexObject+WCTTableCoding.h */,\n\t\t\t\t234F06E8227AA58D00DD65A2 /* NewlyCreatedTableIndexObject.h */,\n\t\t\t\t234F06E9227AA58D00DD65A2 /* NewlyCreatedTableIndexObject.mm */,\n\t\t\t\t234F06E7227AA58D00DD65A2 /* NewlyCreatedTableIndexObject+WCTTableCoding.h */,\n\t\t\t\t234F06E1227AA58C00DD65A2 /* NewRemapObject.h */,\n\t\t\t\t234F06EA227AA58D00DD65A2 /* NewRemapObject.mm */,\n\t\t\t\t234F06E5227AA58D00DD65A2 /* NewRemapObject+WCTTableCoding.h */,\n\t\t\t\t234F06E4227AA58D00DD65A2 /* OldRemapObject.h */,\n\t\t\t\t234F06DF227AA58C00DD65A2 /* OldRemapObject.mm */,\n\t\t\t\t234F06E0227AA58C00DD65A2 /* OldRemapObject+WCTTableCoding.h */,\n\t\t\t);\n\t\t\tpath = rebind;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t234F0473227A9EFA00DD65A2 /* convenient */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t234F06EF227AA59500DD65A2 /* ConvenientDeleteTests.mm */,\n\t\t\t\t234F06F2227AA59600DD65A2 /* ConvenientInsertTests.mm */,\n\t\t\t\t234F06F1227AA59600DD65A2 /* ConvenientSelectTests.mm */,\n\t\t\t\t234F06F0227AA59500DD65A2 /* ConvenientUpdateTests.mm */,\n\t\t\t);\n\t\t\tpath = convenient;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t234F0478227A9EFA00DD65A2 /* thread */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t234F06F7227AA59D00DD65A2 /* ThreadTests.mm */,\n\t\t\t\t234F06F8227AA59D00DD65A2 /* TransactionTests.mm */,\n\t\t\t);\n\t\t\tpath = thread;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t234F049D227A9EFA00DD65A2 /* repair */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t75D2A9BB2AB497D70024B8B2 /* common */,\n\t\t\t\t0DE68B342AB45ADB008BD74C /* model */,\n\t\t\t\t234F072F227AA5C600DD65A2 /* BackupTests.mm */,\n\t\t\t\t234F0730227AA5C700DD65A2 /* DepositTests.mm */,\n\t\t\t\t234F0732227AA5C700DD65A2 /* RetrieveRobustyTests.mm */,\n\t\t\t\t234F0734227AA5C700DD65A2 /* RetrieveTests.mm */,\n\t\t\t\t75E29CAE2B2F2F20003340FF /* VacuumTests.mm */,\n\t\t\t\t0DDF54282B32D18900DB3D65 /* VacuumRobustyTests.mm */,\n\t\t\t);\n\t\t\tpath = repair;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t234F074E227AAE7100DD65A2 /* swift */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t0DB806A22B972E1A00D5E86D /* bridge */,\n\t\t\t\t03E1670827F434E800D2C926 /* tests */,\n\t\t\t\t03E1658E27F42D6500D2C926 /* winq */,\n\t\t\t\t03E165BC27F42D6500D2C926 /* builtin */,\n\t\t\t\t03E165C027F42D6500D2C926 /* core */,\n\t\t\t\t03E165E727F42D6500D2C926 /* util */,\n\t\t\t);\n\t\t\tpath = swift;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t235FBE92229145FC005C7723 /* sqlite */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t2360A5F420D78F1B00E4A311 /* HandleNotification.cpp */,\n\t\t\t\t2360A5F520D78F1B00E4A311 /* HandleNotification.hpp */,\n\t\t\t\t2360A5F320D78F1B00E4A311 /* HandleRelated.cpp */,\n\t\t\t\t2360A5F620D78F1B00E4A311 /* HandleRelated.hpp */,\n\t\t\t\t2370980820590CA700E768B4 /* HandleStatement.cpp */,\n\t\t\t\t2370980920590CA700E768B4 /* HandleStatement.hpp */,\n\t\t\t\t2347378D21CBB3A800AD5E41 /* AbstractHandle.cpp */,\n\t\t\t\t2347378E21CBB3A800AD5E41 /* AbstractHandle.hpp */,\n\t\t\t\t237B47AE21FEEA200059227A /* ColumnMeta.cpp */,\n\t\t\t\t237B47AF21FEEA200059227A /* ColumnMeta.hpp */,\n\t\t\t\t235FBE9322914E0D005C7723 /* Global.cpp */,\n\t\t\t\t235FBE9422914E0D005C7723 /* Global.hpp */,\n\t\t\t\t75ADC5622A8D1C2D00D0AC47 /* TableAttribute.cpp */,\n\t\t\t\t75ADC5632A8D1C2D00D0AC47 /* TableAttribute.hpp */,\n\t\t\t\t0DE84C7C2B03886800522A4E /* DecorativeHandleStatement.hpp */,\n\t\t\t\t0DE84C7B2B03886800522A4E /* DecorativeHandleStatement.cpp */,\n\t\t\t\t0D32815D2B04A8E60027B973 /* DecorativeHandle.cpp */,\n\t\t\t\t0D32815E2B04A8E60027B973 /* DecorativeHandle.hpp */,\n\t\t\t\t754359442B066DBD00CDF232 /* HandleOperator.cpp */,\n\t\t\t\t754359452B066DBD00CDF232 /* HandleOperator.hpp */,\n\t\t\t);\n\t\t\tpath = sqlite;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t236BACDF21BF9F5900C8B4D9 /* migration */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t236BACE021BF9F6400C8B4D9 /* WCTDatabase+Migration.h */,\n\t\t\t\t236BACE121BF9F6400C8B4D9 /* WCTDatabase+Migration.mm */,\n\t\t\t\t236BACE421BF9FC900C8B4D9 /* WCTMigrationInfo.h */,\n\t\t\t\t2395582421C143BB000C85E1 /* WCTMigrationInfo+Private.h */,\n\t\t\t\t236BACE521BF9FC900C8B4D9 /* WCTMigrationInfo.mm */,\n\t\t\t);\n\t\t\tpath = migration;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t2370B0E321914EC200D3227C /* builtin */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t2370B11521914ED500D3227C /* NSData+WCTColumnCoding.h */,\n\t\t\t\t2370B11321914ED500D3227C /* NSData+WCTColumnCoding.mm */,\n\t\t\t\t2370B10F21914ED400D3227C /* NSDate+WCTColumnCoding.h */,\n\t\t\t\t2370B10821914ED400D3227C /* NSDate+WCTColumnCoding.mm */,\n\t\t\t\t2370B11821914ED500D3227C /* NSNull+WCTColumnCoding.h */,\n\t\t\t\t2370B11721914ED500D3227C /* NSNull+WCTColumnCoding.mm */,\n\t\t\t\t2370B11221914ED400D3227C /* NSNumber+WCTColumnCoding.h */,\n\t\t\t\t2370B10C21914ED400D3227C /* NSNumber+WCTColumnCoding.mm */,\n\t\t\t\t2370B10D21914ED400D3227C /* NSObject+WCTColumnCoding.h */,\n\t\t\t\t2370B10E21914ED400D3227C /* NSObject+WCTColumnCoding.mm */,\n\t\t\t\t2370B10B21914ED400D3227C /* NSString+WCTColumnCoding.h */,\n\t\t\t\t2370B11921914ED500D3227C /* NSString+WCTColumnCoding.mm */,\n\t\t\t\t2370B11021914ED400D3227C /* WCTMaster.h */,\n\t\t\t\t2370B11421914ED500D3227C /* WCTMaster.mm */,\n\t\t\t\t2370B11121914ED400D3227C /* WCTMaster+WCTTableCoding.h */,\n\t\t\t\t233A25D2219933D800054EC4 /* WCTBuiltin.h */,\n\t\t\t\t75D566FA2951B7DE00098DD9 /* WCTSequence.h */,\n\t\t\t\t75D566FD2951B7EA00098DD9 /* WCTSequence.mm */,\n\t\t\t\t75D567002951B80B00098DD9 /* WCTSequence+WCTTableCoding.h */,\n\t\t\t);\n\t\t\tpath = builtin;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t23775B2E20AD666900E21AB0 /* base */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t23A6D4BD20BFD7F9004F2DAA /* Progress.cpp */,\n\t\t\t\t23A6D4BE20BFD7F9004F2DAA /* Progress.hpp */,\n\t\t\t\t23F0FEB3215F5E9A008399FB /* Lock.cpp */,\n\t\t\t\t23F0FEB1215F5E9A008399FB /* Lock.hpp */,\n\t\t\t\t390E1C5A2296414C00C24598 /* Thread.cpp */,\n\t\t\t\t390E1C5B2296414C00C24598 /* Thread.hpp */,\n\t\t\t\t23F0FEB2215F5E9A008399FB /* ThreadLocal.hpp */,\n\t\t\t\t2316D92D21057CA700707AFC /* Recyclable.hpp */,\n\t\t\t\t236996B121D5C4FF00E72E81 /* Recyclable.cpp */,\n\t\t\t\t23E7EB1B2123D58D0056B5D8 /* HighWater.cpp */,\n\t\t\t\t23E7EB1C2123D58D0056B5D8 /* HighWater.hpp */,\n\t\t\t\t2308F84B20E32A51001CD9C3 /* FileHandle.cpp */,\n\t\t\t\t2308F84C20E32A51001CD9C3 /* FileHandle.hpp */,\n\t\t\t\t2308F84D20E32A51001CD9C3 /* Serialization.cpp */,\n\t\t\t\t2308F84E20E32A51001CD9C3 /* Serialization.hpp */,\n\t\t\t\t23567D4620CA7DBC005F1C35 /* ErrorProne.cpp */,\n\t\t\t\t23567D4520CA7DBC005F1C35 /* ErrorProne.hpp */,\n\t\t\t\t23567D7220CA91FF005F1C35 /* SharedThreadedErrorProne.cpp */,\n\t\t\t\t23567D7420CA91FF005F1C35 /* SharedThreadedErrorProne.hpp */,\n\t\t\t\t235EE9C422B6321A008F6658 /* StringView.cpp */,\n\t\t\t\t235EE9C322B63219008F6658 /* StringView.hpp */,\n\t\t\t\t75C6E412299E80D3002579A5 /* WCDBOptional.hpp */,\n\t\t\t\t75C6E41629A0C2F0002579A5 /* WCDBOptional.cpp */,\n\t\t\t\t23B35C7520BFE39500425033 /* Path.cpp */,\n\t\t\t\t23B35C7420BFE39400425033 /* Path.hpp */,\n\t\t\t\t23F1698920B6638F009B5C47 /* ThreadedErrors.cpp */,\n\t\t\t\t23F1698720B6638F009B5C47 /* ThreadedErrors.hpp */,\n\t\t\t\t23B9E67420AE733A00CF1683 /* FileManager.cpp */,\n\t\t\t\t23B9E67320AE733A00CF1683 /* FileManager.hpp */,\n\t\t\t\t23775B2F20AD666900E21AB0 /* Assertion.hpp */,\n\t\t\t\t23775B3020AD666900E21AB0 /* WCDBError.cpp */,\n\t\t\t\t23775B3120AD666900E21AB0 /* WCDBError.hpp */,\n\t\t\t\t23775B3220AD666900E21AB0 /* Notifier.cpp */,\n\t\t\t\t23775B3320AD666900E21AB0 /* Notifier.hpp */,\n\t\t\t\t2316D92E21057CA700707AFC /* MappedData.cpp */,\n\t\t\t\t2316D92B21057CA600707AFC /* MappedData.hpp */,\n\t\t\t\t23775BCB20AD72BC00E21AB0 /* Data.cpp */,\n\t\t\t\t23775BCC20AD72BC00E21AB0 /* Data.hpp */,\n\t\t\t\t2375945F210081AA00DBB721 /* UnsafeData.cpp */,\n\t\t\t\t23759460210081AA00DBB721 /* UnsafeData.hpp */,\n\t\t\t\t23567D7920CA93C5005F1C35 /* Time.cpp */,\n\t\t\t\t23567D7A20CA93C5005F1C35 /* Time.hpp */,\n\t\t\t\t2316D9482105D21500707AFC /* LRUCache.hpp */,\n\t\t\t\t2314AE6F21070A1700244D39 /* Range.cpp */,\n\t\t\t\t2314AE7021070A1700244D39 /* Range.hpp */,\n\t\t\t\t23AB898D215BA6DB00554DF1 /* SQLite.h */,\n\t\t\t\t237A8D5721ED88DF003AF5BB /* SQLiteDeclaration.h */,\n\t\t\t\t233A8530215E7CFE00BB8D4F /* Console.cpp */,\n\t\t\t\t233A8531215E7CFE00BB8D4F /* Console.hpp */,\n\t\t\t\t0DC98FD128E46049007F3796 /* DBOperationNotifier.hpp */,\n\t\t\t\t0DC98FD028E46049007F3796 /* DBOperationNotifier.cpp */,\n\t\t\t\t03AFD33928B8A6BD00EF5E56 /* MemberPointer.hpp */,\n\t\t\t\t0DE84ACD2B03295400522A4E /* FunctionContainer.hpp */,\n\t\t\t\t0D3281672B04AC7A0027B973 /* FunctionContainer.cpp */,\n\t\t\t\t7533CB632B051C4F00C8B47D /* ClassDecorator.hpp */,\n\t\t\t);\n\t\t\tpath = base;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t23775B3420AD666900E21AB0 /* repair */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t23B9E66920AE6EE400CF1683 /* RepairKit.h */,\n\t\t\t\t23D0C34820C149D80001BFAE /* factory */,\n\t\t\t\t23D0C30B20C125420001BFAE /* sqlite */,\n\t\t\t\t23775B3520AD666900E21AB0 /* crawl */,\n\t\t\t\t23775B3D20AD666900E21AB0 /* mechanic */,\n\t\t\t\t23775B4420AD666900E21AB0 /* parse */,\n\t\t\t\t23775B4D20AD666900E21AB0 /* basic */,\n\t\t\t\t23775B5B20AD666900E21AB0 /* utility */,\n\t\t\t);\n\t\t\tpath = repair;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t23775B3520AD666900E21AB0 /* crawl */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t23775B3620AD666900E21AB0 /* FullCrawler.cpp */,\n\t\t\t\t23775B3720AD666900E21AB0 /* FullCrawler.hpp */,\n\t\t\t\t23D07CE220BE87360043F4D4 /* MasterCrawler.cpp */,\n\t\t\t\t23D07CE320BE87360043F4D4 /* MasterCrawler.hpp */,\n\t\t\t\t23D07CE820BE873E0043F4D4 /* SequenceCrawler.cpp */,\n\t\t\t\t23D07CE920BE873E0043F4D4 /* SequenceCrawler.hpp */,\n\t\t\t);\n\t\t\tpath = crawl;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t23775B3D20AD666900E21AB0 /* mechanic */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t7543594E2B0671DE00CDF232 /* BackupHandleOperator.cpp */,\n\t\t\t\t7543594F2B0671DE00CDF232 /* BackupHandleOperator.hpp */,\n\t\t\t\t23775B3E20AD666900E21AB0 /* Backup.cpp */,\n\t\t\t\t23775B3F20AD666900E21AB0 /* Backup.hpp */,\n\t\t\t\t23775B4020AD666900E21AB0 /* Material.cpp */,\n\t\t\t\t23775B4120AD666900E21AB0 /* Material.hpp */,\n\t\t\t\t23775B4220AD666900E21AB0 /* Mechanic.cpp */,\n\t\t\t\t23775B4320AD666900E21AB0 /* Mechanic.hpp */,\n\t\t\t\t75EF24FE2AA33FEB0009C99F /* IncrementalMaterial.cpp */,\n\t\t\t\t75EF24FF2AA33FEB0009C99F /* IncrementalMaterial.hpp */,\n\t\t\t);\n\t\t\tpath = mechanic;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t23775B4420AD666900E21AB0 /* parse */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t23775B4520AD666900E21AB0 /* Cell.cpp */,\n\t\t\t\t23775B4620AD666900E21AB0 /* Cell.hpp */,\n\t\t\t\t23775B4720AD666900E21AB0 /* Page.cpp */,\n\t\t\t\t23775B4820AD666900E21AB0 /* Page.hpp */,\n\t\t\t\t23775B4920AD666900E21AB0 /* Pager.cpp */,\n\t\t\t\t23775B4A20AD666900E21AB0 /* Pager.hpp */,\n\t\t\t\t23567D5720CA823C005F1C35 /* PagerRelated.cpp */,\n\t\t\t\t23567D5820CA823C005F1C35 /* PagerRelated.hpp */,\n\t\t\t\t23EB91DC20CA1EBE00ECF668 /* Wal.cpp */,\n\t\t\t\t23EB91DD20CA1EBE00ECF668 /* Wal.hpp */,\n\t\t\t\t23408F0D211897AA0071E5A7 /* Shm.cpp */,\n\t\t\t\t23408F0E211897AA0071E5A7 /* Shm.hpp */,\n\t\t\t\t23593B7B20D3ADF80058B416 /* WalRelated.cpp */,\n\t\t\t\t23593B7C20D3ADF80058B416 /* WalRelated.hpp */,\n\t\t\t\t23567CF820CA3889005F1C35 /* Frame.cpp */,\n\t\t\t\t23567CF920CA3889005F1C35 /* Frame.hpp */,\n\t\t\t\t23AF4E1C20CD04E20050033C /* Initializeable.cpp */,\n\t\t\t\t23AF4E1D20CD04E20050033C /* Initializeable.hpp */,\n\t\t\t\t2316D9412105D19500707AFC /* PageBasedFileHandle.cpp */,\n\t\t\t\t2316D9422105D19500707AFC /* PageBasedFileHandle.hpp */,\n\t\t\t);\n\t\t\tpath = parse;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t23775B4D20AD666900E21AB0 /* basic */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t75EF25082AA42DD90009C99F /* EncryptedSerialization.cpp */,\n\t\t\t\t75EF25092AA42DD90009C99F /* EncryptedSerialization.hpp */,\n\t\t\t\t39C70CC52313E20E002D773C /* Assemble.cpp */,\n\t\t\t\t39C70CC62313E20F002D773C /* Assemble.hpp */,\n\t\t\t\t23775B5020AD666900E21AB0 /* Crawlable.cpp */,\n\t\t\t\t23775B5120AD666900E21AB0 /* Crawlable.hpp */,\n\t\t\t\t23AD52F020DBAC4C00664B62 /* UpgradeableErrorProne.cpp */,\n\t\t\t\t23AD52F120DBAC4C00664B62 /* UpgradeableErrorProne.hpp */,\n\t\t\t\t23EE0EB020B838E100C95998 /* Repairman.cpp */,\n\t\t\t\t23EE0EB120B838E100C95998 /* Repairman.hpp */,\n\t\t\t\t2376CB1920DA5D3B00A68DB5 /* Scoreable.cpp */,\n\t\t\t\t2376CB1A20DA5D3B00A68DB5 /* Scoreable.hpp */,\n\t\t\t\t23AD52D420DB4A3C00664B62 /* MasterItem.cpp */,\n\t\t\t\t23AD52D520DB4A3C00664B62 /* MasterItem.hpp */,\n\t\t\t\t23AD52DB20DB56D200664B62 /* SequenceItem.cpp */,\n\t\t\t\t23AD52DC20DB56D200664B62 /* SequenceItem.hpp */,\n\t\t\t\t75A60AAD29345A38009C1B3C /* Cipher.cpp */,\n\t\t\t\t75A60AAE29345A38009C1B3C /* Cipher.hpp */,\n\t\t\t\t759362CD2B36D450000AF163 /* Vacuum.cpp */,\n\t\t\t\t759362CE2B36D450000AF163 /* Vacuum.hpp */,\n\t\t\t);\n\t\t\tpath = basic;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t23775B5B20AD666900E21AB0 /* utility */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t23AD52E420DB852B00664B62 /* Fraction.cpp */,\n\t\t\t\t23AD52E520DB852B00664B62 /* Fraction.hpp */,\n\t\t\t);\n\t\t\tpath = utility;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t2386B3BD1ED442D9000B72F6 /* monitor */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t23906AB7215E500100C2B717 /* WCTDatabase+Monitor.h */,\n\t\t\t\t23906AB8215E500100C2B717 /* WCTDatabase+Monitor.mm */,\n\t\t\t\t2386B3C21ED442FE000B72F6 /* WCTError.h */,\n\t\t\t\t2386B3C31ED442FE000B72F6 /* WCTError.mm */,\n\t\t\t\t2386B3C41ED442FE000B72F6 /* WCTError+Private.h */,\n\t\t\t\t0D4F0F942AC5728A0067027E /* WCTPerformanceInfo.h */,\n\t\t\t\t0D4F0F9A2AC576560067027E /* WCTPerformanceInfo+Private.h */,\n\t\t\t\t0D4F0F972AC572B20067027E /* WCTPerformanceInfo.mm */,\n\t\t\t);\n\t\t\tpath = monitor;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t23A09D632146204300F62EE8 /* migration */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t23A64D07214A458A00ED28BB /* MigrationInfo.cpp */,\n\t\t\t\t23A64D08214A458A00ED28BB /* MigrationInfo.hpp */,\n\t\t\t\t23A64D0D214A4A7000ED28BB /* Migration.cpp */,\n\t\t\t\t23A64D0E214A4A7000ED28BB /* Migration.hpp */,\n\t\t\t\t23301BF32298FE9A00A8AB5A /* AutoMigrateConfig.cpp */,\n\t\t\t\t23301BF42298FE9A00A8AB5A /* AutoMigrateConfig.hpp */,\n\t\t\t\t7533CB4D2B050FA300C8B47D /* MigratingHandleDecorator.cpp */,\n\t\t\t\t7533CB4E2B050FA300C8B47D /* MigratingHandleDecorator.hpp */,\n\t\t\t\t7533CB572B050FB200C8B47D /* MigratingStatementDecorator.cpp */,\n\t\t\t\t7533CB582B050FB200C8B47D /* MigratingStatementDecorator.hpp */,\n\t\t\t\t0DD8D1152B074C47002C97D3 /* MigrateHandleOperator.cpp */,\n\t\t\t\t0DD8D1162B074C47002C97D3 /* MigrateHandleOperator.hpp */,\n\t\t\t);\n\t\t\tpath = migration;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t23B4DCDE2112B03200954D71 /* operate */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t3934DAE9229B6659008A6AEC /* OperationQueue.cpp */,\n\t\t\t\t3934DAEA229B6659008A6AEC /* OperationQueue.hpp */,\n\t\t\t\t75294DAE29C75058005E7FC0 /* OperationQueueForMemory.hpp */,\n\t\t\t\t75294DAD29C75058005E7FC0 /* OperationQueueForMemory.cpp */,\n\t\t\t);\n\t\t\tpath = operate;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t23B5F75A1E1111C100E58396 = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t75EABA082ADA4F2600AAD3C9 /* zstd.xcodeproj */,\n\t\t\t\t23A747BE20039675003CECFA /* sqlcipher.preprocessed.xcodeproj */,\n\t\t\t\t0DAE11D328DC6CC6003FB63A /* WCDB.h */,\n\t\t\t\t03E1620527F1AA1B00D2C926 /* common */,\n\t\t\t\t037C3C0E2897EBE400328EC8 /* cpp */,\n\t\t\t\t2349F5D51EA0D6680021EFA7 /* objc */,\n\t\t\t\t234F074E227AAE7100DD65A2 /* swift */,\n\t\t\t\t03E167B427F43CD900D2C926 /* bridge */,\n\t\t\t\t23F0FDEE215F266C008399FB /* support */,\n\t\t\t\t23B5F93E1E111CB100E58396 /* Frameworks */,\n\t\t\t\t23B5F7641E1111C100E58396 /* Products */,\n\t\t\t);\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t23B5F7641E1111C100E58396 /* Products */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t239326611E836D7300D677CC /* WCDB.framework */,\n\t\t\t\t239E8A702160A5B100BCB308 /* Host.app */,\n\t\t\t\t234F035C227A9CFE00DD65A2 /* ObjcTests.xctest */,\n\t\t\t\t234F8AD4227B0B5400791E45 /* SwiftTests.xctest */,\n\t\t\t\t0333100228167ECC0094CFCF /* SwiftBridgeObjcTest.xctest */,\n\t\t\t\t03BF4B1F2888F87C00A30500 /* BenchmarkTest.xctest */,\n\t\t\t\t037C3C0C2897E33600328EC8 /* WCDBCpp.framework */,\n\t\t\t\t03E5CC4928A38CCA005353D9 /* CppTests.xctest */,\n\t\t\t\t7521DA47291E9ABB009642EF /* WCDBObjc.framework */,\n\t\t\t\t7521DDDD291EA349009642EF /* WCDBSwift.framework */,\n\t\t\t);\n\t\t\tname = Products;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t23B5F93E1E111CB100E58396 /* Frameworks */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t7587F21B2EC2DF3300CC5224 /* UIKit.framework */,\n\t\t\t\t2387D8A621DF0B190028ADB9 /* XCTest.framework */,\n\t\t\t\t239E8A922160A81600BCB308 /* Foundation.framework */,\n\t\t\t\t23F0FD7C215F1C92008399FB /* Security.framework */,\n\t\t\t\t23C43BCC2087435800AB186D /* libz.tbd */,\n\t\t\t);\n\t\t\tname = Frameworks;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t23D0C30B20C125420001BFAE /* sqlite */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t23D0C30C20C125420001BFAE /* SQLiteAssembler.cpp */,\n\t\t\t\t23D0C30D20C125420001BFAE /* SQLiteAssembler.hpp */,\n\t\t\t\t23C7558F20DCF90F00031A93 /* SQLiteLocker.cpp */,\n\t\t\t\t23C7559020DCF90F00031A93 /* SQLiteLocker.hpp */,\n\t\t\t\t23C7559820DD17B100031A93 /* SQLiteBase.cpp */,\n\t\t\t\t23C7559920DD17B100031A93 /* SQLiteBase.hpp */,\n\t\t\t);\n\t\t\tpath = sqlite;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t23D0C34820C149D80001BFAE /* factory */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t23D0C34920C149D80001BFAE /* Factory.cpp */,\n\t\t\t\t23D0C34A20C149D80001BFAE /* Factory.hpp */,\n\t\t\t\t23D0C36120C14ACC0001BFAE /* FactoryRelated.cpp */,\n\t\t\t\t23D0C36220C14ACC0001BFAE /* FactoryRelated.hpp */,\n\t\t\t\t23D0C34B20C149D80001BFAE /* FactoryDepositor.cpp */,\n\t\t\t\t23D0C34C20C149D80001BFAE /* FactoryDepositor.hpp */,\n\t\t\t\t23D0C34F20C149D80001BFAE /* FactoryRetriever.cpp */,\n\t\t\t\t23D0C35020C149D80001BFAE /* FactoryRetriever.hpp */,\n\t\t\t\t23D0C38B20C17CAE0001BFAE /* FactoryBackup.cpp */,\n\t\t\t\t23D0C38C20C17CAE0001BFAE /* FactoryBackup.hpp */,\n\t\t\t\t23DD76BB20CF78C800E9B451 /* FactoryRenewer.cpp */,\n\t\t\t\t23DD76BC20CF78C800E9B451 /* FactoryRenewer.hpp */,\n\t\t\t\t756F7F622B2CA4B5002AEA0A /* FactoryVacuum.cpp */,\n\t\t\t\t756F7F632B2CA4B5002AEA0A /* FactoryVacuum.hpp */,\n\t\t\t);\n\t\t\tpath = factory;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t23E163CA20FDDD6900C3F910 /* fts */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t75B6988A290AD114006E1F8F /* tokenizer */,\n\t\t\t\t75B69889290AD0A9006E1F8F /* auxfunction */,\n\t\t\t\t0D3AE53725416D99007B9D0E /* AutoMergeFTSIndexConfig.hpp */,\n\t\t\t\t0D3AE53F25416DB4007B9D0E /* AutoMergeFTSIndexConfig.cpp */,\n\t\t\t\t0D249BC02542B8E900B43BD9 /* MergeFTSIndexLogic.hpp */,\n\t\t\t\t0D249BC82542B90600B43BD9 /* MergeFTSIndexLogic.cpp */,\n\t\t\t\t03EA88CD27D5F05D0075C7BD /* FTSError.hpp */,\n\t\t\t\t03EA88CF27D5F0840075C7BD /* FTSError.cpp */,\n\t\t\t\t754014C2290BEDA600EA8D33 /* FTSConst.h */,\n\t\t\t);\n\t\t\tpath = fts;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t23EEDB67217DFADC006E9E73 /* extension */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t23EEDB68217DFADC006E9E73 /* AggregateFunction.cpp */,\n\t\t\t\t23EEDB69217DFADC006E9E73 /* AggregateFunction.hpp */,\n\t\t\t\t23EEDB6A217DFADC006E9E73 /* ColumnType.cpp */,\n\t\t\t\t23EEDB6B217DFADC006E9E73 /* ColumnType.hpp */,\n\t\t\t\t23EEDB6C217DFADC006E9E73 /* Convertible.hpp */,\n\t\t\t\t23EEDB6D217DFADC006E9E73 /* ConvertibleImplementation.cpp */,\n\t\t\t\t23EEDB6E217DFADC006E9E73 /* ConvertibleImplementation.hpp */,\n\t\t\t\t23EEDB6F217DFADC006E9E73 /* CoreFunction.cpp */,\n\t\t\t\t23EEDB70217DFADC006E9E73 /* CoreFunction.hpp */,\n\t\t\t\t23EEDB71217DFADC006E9E73 /* ExpressionOperable.cpp */,\n\t\t\t\t23EEDB72217DFADC006E9E73 /* ExpressionOperable.hpp */,\n\t\t\t\t23EEDB73217DFADC006E9E73 /* FTSFunction.cpp */,\n\t\t\t\t23EEDB74217DFADC006E9E73 /* FTSFunction.hpp */,\n\t\t\t\t23EEDB75217DFADC006E9E73 /* SyntaxForwardDeclaration.h */,\n\t\t\t\t23EEDB76217DFADC006E9E73 /* SyntaxList.hpp */,\n\t\t\t\t03E5CC6D28A3BDF3005353D9 /* Value.hpp */,\n\t\t\t\t03E5CC6C28A3BDF3005353D9 /* Value.cpp */,\n\t\t\t\t03A15DF828AA636A0031A50A /* ValueArray.hpp */,\n\t\t\t\t7537E5D028B939240077D92B /* BaseBinding.hpp */,\n\t\t\t\t7537E5CF28B939240077D92B /* BaseBinding.cpp */,\n\t\t\t);\n\t\t\tpath = extension;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t23EEDB79217DFADC006E9E73 /* identifier */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t23EEDB7A217DFADC006E9E73 /* BindParameter.cpp */,\n\t\t\t\t23EEDB7B217DFADC006E9E73 /* BindParameter.hpp */,\n\t\t\t\t23EEDB7C217DFADC006E9E73 /* Column.cpp */,\n\t\t\t\t23EEDB7D217DFADC006E9E73 /* Column.hpp */,\n\t\t\t\t23EEDB7E217DFADC006E9E73 /* ColumnConstraint.cpp */,\n\t\t\t\t23EEDB7F217DFADC006E9E73 /* ColumnConstraint.hpp */,\n\t\t\t\t23EEDB80217DFADC006E9E73 /* ColumnDef.cpp */,\n\t\t\t\t23EEDB81217DFADC006E9E73 /* ColumnDef.hpp */,\n\t\t\t\t23EEDB82217DFADC006E9E73 /* CommonTableExpression.cpp */,\n\t\t\t\t23EEDB83217DFADC006E9E73 /* CommonTableExpression.hpp */,\n\t\t\t\t23EEDB86217DFADC006E9E73 /* Expression.cpp */,\n\t\t\t\t23EEDB87217DFADC006E9E73 /* Expression.hpp */,\n\t\t\t\t23EEDB88217DFADC006E9E73 /* Filter.cpp */,\n\t\t\t\t23EEDB89217DFADC006E9E73 /* Filter.hpp */,\n\t\t\t\t23EEDB8A217DFADC006E9E73 /* ForeignKey.cpp */,\n\t\t\t\t23EEDB8B217DFADC006E9E73 /* ForeignKey.hpp */,\n\t\t\t\t23EEDB8C217DFADC006E9E73 /* FrameSpec.cpp */,\n\t\t\t\t23EEDB8D217DFADC006E9E73 /* FrameSpec.hpp */,\n\t\t\t\t23EEDB90217DFADC006E9E73 /* IndexedColumn.cpp */,\n\t\t\t\t23EEDB91217DFADC006E9E73 /* IndexedColumn.hpp */,\n\t\t\t\t23EEDB92217DFADC006E9E73 /* Join.cpp */,\n\t\t\t\t23EEDB93217DFADC006E9E73 /* Join.hpp */,\n\t\t\t\t23EEDB94217DFADC006E9E73 /* JoinConstraint.cpp */,\n\t\t\t\t23EEDB95217DFADC006E9E73 /* JoinConstraint.hpp */,\n\t\t\t\t23EEDB96217DFADC006E9E73 /* LiteralValue.cpp */,\n\t\t\t\t23EEDB97217DFADC006E9E73 /* LiteralValue.hpp */,\n\t\t\t\t23EEDB9A217DFADC006E9E73 /* OrderingTerm.cpp */,\n\t\t\t\t23EEDB9B217DFADC006E9E73 /* OrderingTerm.hpp */,\n\t\t\t\t23EEDB9C217DFADC006E9E73 /* Pragma.cpp */,\n\t\t\t\t23EEDB9D217DFADC006E9E73 /* Pragma.hpp */,\n\t\t\t\t23EEDB9E217DFADC006E9E73 /* QualifiedTable.cpp */,\n\t\t\t\t23EEDB9F217DFADC006E9E73 /* QualifiedTable.hpp */,\n\t\t\t\t23EEDBA0217DFADC006E9E73 /* RaiseFunction.cpp */,\n\t\t\t\t23EEDBA1217DFADC006E9E73 /* RaiseFunction.hpp */,\n\t\t\t\t23EEDBA4217DFADC006E9E73 /* ResultColumn.cpp */,\n\t\t\t\t23EEDBA5217DFADC006E9E73 /* ResultColumn.hpp */,\n\t\t\t\t23EEDBA6217DFADC006E9E73 /* Schema.cpp */,\n\t\t\t\t23EEDBA7217DFADC006E9E73 /* Schema.hpp */,\n\t\t\t\t23EEDBAA217DFADC006E9E73 /* TableConstraint.cpp */,\n\t\t\t\t23EEDBAB217DFADC006E9E73 /* TableConstraint.hpp */,\n\t\t\t\t23EEDBAC217DFADC006E9E73 /* TableOrSubquery.cpp */,\n\t\t\t\t23EEDBAD217DFADC006E9E73 /* TableOrSubquery.hpp */,\n\t\t\t\t23EEDBAE217DFADC006E9E73 /* Upsert.cpp */,\n\t\t\t\t23EEDBAF217DFADC006E9E73 /* Upsert.hpp */,\n\t\t\t\t23EEDBB0217DFADC006E9E73 /* WindowDef.cpp */,\n\t\t\t\t23EEDBB1217DFADC006E9E73 /* WindowDef.hpp */,\n\t\t\t);\n\t\t\tpath = identifier;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t23EEDBB6217DFADC006E9E73 /* statement */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t23EEDBB9217DFADC006E9E73 /* StatementAlterTable.cpp */,\n\t\t\t\t23EEDBBA217DFADC006E9E73 /* StatementAlterTable.hpp */,\n\t\t\t\t23EEDBBB217DFADC006E9E73 /* StatementAnalyze.cpp */,\n\t\t\t\t23EEDBBC217DFADC006E9E73 /* StatementAnalyze.hpp */,\n\t\t\t\t23EEDBBD217DFADC006E9E73 /* StatementAttach.cpp */,\n\t\t\t\t23EEDBBE217DFADC006E9E73 /* StatementAttach.hpp */,\n\t\t\t\t23EEDBBF217DFADC006E9E73 /* StatementBegin.cpp */,\n\t\t\t\t23EEDBC0217DFADC006E9E73 /* StatementBegin.hpp */,\n\t\t\t\t23EEDBC1217DFADC006E9E73 /* StatementCommit.cpp */,\n\t\t\t\t23EEDBC2217DFADC006E9E73 /* StatementCommit.hpp */,\n\t\t\t\t23EEDBC3217DFADC006E9E73 /* StatementCreateIndex.cpp */,\n\t\t\t\t23EEDBC4217DFADC006E9E73 /* StatementCreateIndex.hpp */,\n\t\t\t\t23EEDBC5217DFADC006E9E73 /* StatementCreateTable.cpp */,\n\t\t\t\t23EEDBC6217DFADC006E9E73 /* StatementCreateTable.hpp */,\n\t\t\t\t23EEDBC7217DFADC006E9E73 /* StatementCreateTrigger.cpp */,\n\t\t\t\t23EEDBC8217DFADC006E9E73 /* StatementCreateTrigger.hpp */,\n\t\t\t\t23EEDBC9217DFADC006E9E73 /* StatementCreateView.cpp */,\n\t\t\t\t23EEDBCA217DFADC006E9E73 /* StatementCreateView.hpp */,\n\t\t\t\t23EEDBCB217DFADC006E9E73 /* StatementCreateVirtualTable.cpp */,\n\t\t\t\t23EEDBCC217DFADC006E9E73 /* StatementCreateVirtualTable.hpp */,\n\t\t\t\t23EEDBCD217DFADC006E9E73 /* StatementDelete.cpp */,\n\t\t\t\t23EEDBCE217DFADC006E9E73 /* StatementDelete.hpp */,\n\t\t\t\t23EEDBCF217DFADC006E9E73 /* StatementDetach.cpp */,\n\t\t\t\t23EEDBD0217DFADC006E9E73 /* StatementDetach.hpp */,\n\t\t\t\t23EEDBD1217DFADC006E9E73 /* StatementDropIndex.cpp */,\n\t\t\t\t23EEDBD2217DFADC006E9E73 /* StatementDropIndex.hpp */,\n\t\t\t\t23EEDBD3217DFADC006E9E73 /* StatementDropTable.cpp */,\n\t\t\t\t23EEDBD4217DFADC006E9E73 /* StatementDropTable.hpp */,\n\t\t\t\t23EEDBD5217DFADC006E9E73 /* StatementDropTrigger.cpp */,\n\t\t\t\t23EEDBD6217DFADC006E9E73 /* StatementDropTrigger.hpp */,\n\t\t\t\t23EEDBD7217DFADC006E9E73 /* StatementDropView.cpp */,\n\t\t\t\t23EEDBD8217DFADC006E9E73 /* StatementDropView.hpp */,\n\t\t\t\t3960D89D2319288C00EF05D1 /* StatementExplain.cpp */,\n\t\t\t\t3960D89E2319288C00EF05D1 /* StatementExplain.hpp */,\n\t\t\t\t23EEDBD9217DFADC006E9E73 /* StatementInsert.cpp */,\n\t\t\t\t23EEDBDA217DFADC006E9E73 /* StatementInsert.hpp */,\n\t\t\t\t23EEDBDB217DFADC006E9E73 /* StatementPragma.cpp */,\n\t\t\t\t23EEDBDC217DFADC006E9E73 /* StatementPragma.hpp */,\n\t\t\t\t23EEDBDD217DFADC006E9E73 /* StatementReindex.cpp */,\n\t\t\t\t23EEDBDE217DFADC006E9E73 /* StatementReindex.hpp */,\n\t\t\t\t23EEDBDF217DFADC006E9E73 /* StatementRelease.cpp */,\n\t\t\t\t23EEDBE0217DFADC006E9E73 /* StatementRelease.hpp */,\n\t\t\t\t23EEDBE1217DFADC006E9E73 /* StatementRollback.cpp */,\n\t\t\t\t23EEDBE2217DFADC006E9E73 /* StatementRollback.hpp */,\n\t\t\t\t23EEDBE3217DFADC006E9E73 /* StatementSavepoint.cpp */,\n\t\t\t\t23EEDBE4217DFADC006E9E73 /* StatementSavepoint.hpp */,\n\t\t\t\t23EEDBE5217DFADC006E9E73 /* StatementSelect.cpp */,\n\t\t\t\t23EEDBE6217DFADC006E9E73 /* StatementSelect.hpp */,\n\t\t\t\t23EEDBE7217DFADC006E9E73 /* StatementUpdate.cpp */,\n\t\t\t\t23EEDBE8217DFADC006E9E73 /* StatementUpdate.hpp */,\n\t\t\t\t23EEDBE9217DFADC006E9E73 /* StatementVacuum.cpp */,\n\t\t\t\t23EEDBEA217DFADC006E9E73 /* StatementVacuum.hpp */,\n\t\t\t);\n\t\t\tpath = statement;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t23EEDBEC217DFADC006E9E73 /* syntax */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t23545B962224E8270091C981 /* SyntaxAssertion.hpp */,\n\t\t\t\t23EEDC65217DFADC006E9E73 /* Syntax.h */,\n\t\t\t\t23545B9C2224E9C80091C981 /* SyntaxEnum.hpp */,\n\t\t\t\t23EEDBED217DFADC006E9E73 /* const */,\n\t\t\t\t23EEDBF3217DFADC006E9E73 /* identifier */,\n\t\t\t\t23EEDC30217DFADC006E9E73 /* stmt */,\n\t\t\t);\n\t\t\tpath = syntax;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t23EEDBED217DFADC006E9E73 /* const */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t238C177C21CA2190003B6D26 /* SyntaxCommonConst.hpp */,\n\t\t\t\t23545BA12224EAA40091C981 /* SyntaxCommonConst.cpp */,\n\t\t\t);\n\t\t\tpath = const;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t23EEDBF3217DFADC006E9E73 /* identifier */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t23EEDBF4217DFADC006E9E73 /* SyntaxBindParameter.cpp */,\n\t\t\t\t23EEDBF5217DFADC006E9E73 /* SyntaxBindParameter.hpp */,\n\t\t\t\t23EEDBF6217DFADC006E9E73 /* SyntaxColumn.cpp */,\n\t\t\t\t23EEDBF7217DFADC006E9E73 /* SyntaxColumn.hpp */,\n\t\t\t\t23EEDBF8217DFADC006E9E73 /* SyntaxColumnConstraint.cpp */,\n\t\t\t\t23EEDBF9217DFADC006E9E73 /* SyntaxColumnConstraint.hpp */,\n\t\t\t\t23EEDBFA217DFADC006E9E73 /* SyntaxColumnDef.cpp */,\n\t\t\t\t23EEDBFB217DFADC006E9E73 /* SyntaxColumnDef.hpp */,\n\t\t\t\t23EEDBFC217DFADC006E9E73 /* SyntaxCommonTableExpression.cpp */,\n\t\t\t\t23EEDBFD217DFADC006E9E73 /* SyntaxCommonTableExpression.hpp */,\n\t\t\t\t23EEDC00217DFADC006E9E73 /* SyntaxExpression.cpp */,\n\t\t\t\t23EEDC01217DFADC006E9E73 /* SyntaxExpression.hpp */,\n\t\t\t\t23EEDC02217DFADC006E9E73 /* SyntaxFilter.cpp */,\n\t\t\t\t23EEDC03217DFADC006E9E73 /* SyntaxFilter.hpp */,\n\t\t\t\t23EEDC04217DFADC006E9E73 /* SyntaxForeignKeyClause.cpp */,\n\t\t\t\t23EEDC05217DFADC006E9E73 /* SyntaxForeignKeyClause.hpp */,\n\t\t\t\t23EEDC06217DFADC006E9E73 /* SyntaxFrameSpec.cpp */,\n\t\t\t\t23EEDC07217DFADC006E9E73 /* SyntaxFrameSpec.hpp */,\n\t\t\t\t23EEDC0A217DFADC006E9E73 /* SyntaxIdentifier.cpp */,\n\t\t\t\t23EEDC0B217DFADC006E9E73 /* SyntaxIdentifier.hpp */,\n\t\t\t\t23EEDC0C217DFADC006E9E73 /* SyntaxIndexedColumn.cpp */,\n\t\t\t\t23EEDC0D217DFADC006E9E73 /* SyntaxIndexedColumn.hpp */,\n\t\t\t\t23EEDC0E217DFADC006E9E73 /* SyntaxJoinClause.cpp */,\n\t\t\t\t23EEDC0F217DFADC006E9E73 /* SyntaxJoinClause.hpp */,\n\t\t\t\t23EEDC10217DFADC006E9E73 /* SyntaxJoinConstraint.cpp */,\n\t\t\t\t23EEDC11217DFADC006E9E73 /* SyntaxJoinConstraint.hpp */,\n\t\t\t\t23EEDC12217DFADC006E9E73 /* SyntaxLiteralValue.cpp */,\n\t\t\t\t23EEDC13217DFADC006E9E73 /* SyntaxLiteralValue.hpp */,\n\t\t\t\t23EEDC16217DFADC006E9E73 /* SyntaxOrderingTerm.cpp */,\n\t\t\t\t23EEDC17217DFADC006E9E73 /* SyntaxOrderingTerm.hpp */,\n\t\t\t\t23EEDC18217DFADC006E9E73 /* SyntaxPragma.cpp */,\n\t\t\t\t23EEDC19217DFADC006E9E73 /* SyntaxPragma.hpp */,\n\t\t\t\t23EEDC1A217DFADC006E9E73 /* SyntaxQualifiedTableName.cpp */,\n\t\t\t\t23EEDC1B217DFADC006E9E73 /* SyntaxQualifiedTableName.hpp */,\n\t\t\t\t23EEDC1C217DFADC006E9E73 /* SyntaxRaiseFunction.cpp */,\n\t\t\t\t23EEDC1D217DFADC006E9E73 /* SyntaxRaiseFunction.hpp */,\n\t\t\t\t23EEDC20217DFADC006E9E73 /* SyntaxResultColumn.cpp */,\n\t\t\t\t23EEDC21217DFADC006E9E73 /* SyntaxResultColumn.hpp */,\n\t\t\t\t23EEDC22217DFADC006E9E73 /* SyntaxSchema.cpp */,\n\t\t\t\t23EEDC23217DFADC006E9E73 /* SyntaxSchema.hpp */,\n\t\t\t\t23EEDC24217DFADC006E9E73 /* SyntaxSelectCore.cpp */,\n\t\t\t\t23EEDC25217DFADC006E9E73 /* SyntaxSelectCore.hpp */,\n\t\t\t\t23EEDC26217DFADC006E9E73 /* SyntaxTableConstraint.cpp */,\n\t\t\t\t23EEDC27217DFADC006E9E73 /* SyntaxTableConstraint.hpp */,\n\t\t\t\t23EEDC28217DFADC006E9E73 /* SyntaxTableOrSubquery.cpp */,\n\t\t\t\t23EEDC29217DFADC006E9E73 /* SyntaxTableOrSubquery.hpp */,\n\t\t\t\t23EEDC2A217DFADC006E9E73 /* SyntaxUpsertClause.cpp */,\n\t\t\t\t23EEDC2B217DFADC006E9E73 /* SyntaxUpsertClause.hpp */,\n\t\t\t\t23EEDC2C217DFADC006E9E73 /* SyntaxWindowDef.cpp */,\n\t\t\t\t23EEDC2D217DFADC006E9E73 /* SyntaxWindowDef.hpp */,\n\t\t\t);\n\t\t\tpath = identifier;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t23EEDC30217DFADC006E9E73 /* stmt */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t23EEDC31217DFADC006E9E73 /* SyntaxAlterTableSTMT.cpp */,\n\t\t\t\t23EEDC32217DFADC006E9E73 /* SyntaxAlterTableSTMT.hpp */,\n\t\t\t\t23EEDC33217DFADC006E9E73 /* SyntaxAnalyzeSTMT.cpp */,\n\t\t\t\t23EEDC34217DFADC006E9E73 /* SyntaxAnalyzeSTMT.hpp */,\n\t\t\t\t23EEDC35217DFADC006E9E73 /* SyntaxAttachSTMT.cpp */,\n\t\t\t\t23EEDC36217DFADC006E9E73 /* SyntaxAttachSTMT.hpp */,\n\t\t\t\t23EEDC37217DFADC006E9E73 /* SyntaxBeginSTMT.cpp */,\n\t\t\t\t23EEDC38217DFADC006E9E73 /* SyntaxBeginSTMT.hpp */,\n\t\t\t\t23EEDC39217DFADC006E9E73 /* SyntaxCommitSTMT.cpp */,\n\t\t\t\t23EEDC3A217DFADC006E9E73 /* SyntaxCommitSTMT.hpp */,\n\t\t\t\t23EEDC3B217DFADC006E9E73 /* SyntaxCreateIndexSTMT.cpp */,\n\t\t\t\t23EEDC3C217DFADC006E9E73 /* SyntaxCreateIndexSTMT.hpp */,\n\t\t\t\t23EEDC3D217DFADC006E9E73 /* SyntaxCreateTableSTMT.cpp */,\n\t\t\t\t23EEDC3E217DFADC006E9E73 /* SyntaxCreateTableSTMT.hpp */,\n\t\t\t\t23EEDC3F217DFADC006E9E73 /* SyntaxCreateTriggerSTMT.cpp */,\n\t\t\t\t23EEDC40217DFADC006E9E73 /* SyntaxCreateTriggerSTMT.hpp */,\n\t\t\t\t23EEDC41217DFADC006E9E73 /* SyntaxCreateViewSTMT.cpp */,\n\t\t\t\t23EEDC42217DFADC006E9E73 /* SyntaxCreateViewSTMT.hpp */,\n\t\t\t\t23EEDC43217DFADC006E9E73 /* SyntaxCreateVirtualTableSTMT.cpp */,\n\t\t\t\t23EEDC44217DFADC006E9E73 /* SyntaxCreateVirtualTableSTMT.hpp */,\n\t\t\t\t23EEDC45217DFADC006E9E73 /* SyntaxDeleteSTMT.cpp */,\n\t\t\t\t23EEDC46217DFADC006E9E73 /* SyntaxDeleteSTMT.hpp */,\n\t\t\t\t23EEDC47217DFADC006E9E73 /* SyntaxDetachSTMT.cpp */,\n\t\t\t\t23EEDC48217DFADC006E9E73 /* SyntaxDetachSTMT.hpp */,\n\t\t\t\t23EEDC49217DFADC006E9E73 /* SyntaxDropIndexSTMT.cpp */,\n\t\t\t\t23EEDC4A217DFADC006E9E73 /* SyntaxDropIndexSTMT.hpp */,\n\t\t\t\t23EEDC4B217DFADC006E9E73 /* SyntaxDropTableSTMT.cpp */,\n\t\t\t\t23EEDC4C217DFADC006E9E73 /* SyntaxDropTableSTMT.hpp */,\n\t\t\t\t23EEDC4D217DFADC006E9E73 /* SyntaxDropTriggerSTMT.cpp */,\n\t\t\t\t23EEDC4E217DFADC006E9E73 /* SyntaxDropTriggerSTMT.hpp */,\n\t\t\t\t23EEDC4F217DFADC006E9E73 /* SyntaxDropViewSTMT.cpp */,\n\t\t\t\t23EEDC50217DFADC006E9E73 /* SyntaxDropViewSTMT.hpp */,\n\t\t\t\t3960D8992319258B00EF05D1 /* SyntaxExplainSTMT.cpp */,\n\t\t\t\t3960D89A2319258B00EF05D1 /* SyntaxExplainSTMT.hpp */,\n\t\t\t\t23EEDC51217DFADC006E9E73 /* SyntaxInsertSTMT.cpp */,\n\t\t\t\t23EEDC52217DFADC006E9E73 /* SyntaxInsertSTMT.hpp */,\n\t\t\t\t23EEDC53217DFADC006E9E73 /* SyntaxPragmaSTMT.cpp */,\n\t\t\t\t23EEDC54217DFADC006E9E73 /* SyntaxPragmaSTMT.hpp */,\n\t\t\t\t23EEDC55217DFADC006E9E73 /* SyntaxReindexSTMT.cpp */,\n\t\t\t\t23EEDC56217DFADC006E9E73 /* SyntaxReindexSTMT.hpp */,\n\t\t\t\t23EEDC57217DFADC006E9E73 /* SyntaxReleaseSTMT.cpp */,\n\t\t\t\t23EEDC58217DFADC006E9E73 /* SyntaxReleaseSTMT.hpp */,\n\t\t\t\t23EEDC59217DFADC006E9E73 /* SyntaxRollbackSTMT.cpp */,\n\t\t\t\t23EEDC5A217DFADC006E9E73 /* SyntaxRollbackSTMT.hpp */,\n\t\t\t\t23EEDC5B217DFADC006E9E73 /* SyntaxSavepointSTMT.cpp */,\n\t\t\t\t23EEDC5C217DFADC006E9E73 /* SyntaxSavepointSTMT.hpp */,\n\t\t\t\t23EEDC5D217DFADC006E9E73 /* SyntaxSelectSTMT.cpp */,\n\t\t\t\t23EEDC5E217DFADC006E9E73 /* SyntaxSelectSTMT.hpp */,\n\t\t\t\t23EEDC5F217DFADC006E9E73 /* SyntaxUpdateSTMT.cpp */,\n\t\t\t\t23EEDC60217DFADC006E9E73 /* SyntaxUpdateSTMT.hpp */,\n\t\t\t\t23EEDC61217DFADC006E9E73 /* SyntaxVacuumSTMT.cpp */,\n\t\t\t\t23EEDC62217DFADC006E9E73 /* SyntaxVacuumSTMT.hpp */,\n\t\t\t);\n\t\t\tpath = stmt;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t23F0FDEE215F266C008399FB /* support */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t234F036D227A9E3D00DD65A2 /* Base.xcconfig */,\n\t\t\t\t234F036A227A9E3C00DD65A2 /* Debug.xcconfig */,\n\t\t\t\t234F036C227A9E3D00DD65A2 /* Release.xcconfig */,\n\t\t\t\t234F042F227A9EFA00DD65A2 /* Tests.xcconfig */,\n\t\t\t\t234F0369227A9E3C00DD65A2 /* Info.plist */,\n\t\t\t\t234F0370227A9E3D00DD65A2 /* WCDBWithoutCompression.xcconfig */,\n\t\t\t\t0DACF8B22B2ADC7700CB0710 /* WCDB.xcconfig */,\n\t\t\t\t3C9A56E02EB44B9D00DA1C6E /* WCDBSwift.xcconfig */,\n\t\t\t\t234F036E227A9E3D00DD65A2 /* WCDB.modulemap */,\n\t\t\t\t7521DA49291E9D9E009642EF /* WCDBCpp.modulemap */,\n\t\t\t\t7521DA4A291E9D9E009642EF /* WCDBObjc.modulemap */,\n\t\t\t\t7521D6B6291E6DFC009642EF /* WCDBSwift.modulemap */,\n\t\t\t);\n\t\t\tpath = support;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t23F70F9D20A055A400CCE3CD /* config */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t23F70FC320A0618100CCE3CD /* Configs.hpp */,\n\t\t\t\t3962FFCE23051F71008934D4 /* Configs.cpp */,\n\t\t\t\t23F70F9F20A055B400CCE3CD /* Config.hpp */,\n\t\t\t\t2327BC21220944D80078A85B /* Config.cpp */,\n\t\t\t\t23F70FA420A055BD00CCE3CD /* BasicConfig.cpp */,\n\t\t\t\t23F70FA520A055BD00CCE3CD /* BasicConfig.hpp */,\n\t\t\t\t23F70FAA20A055C300CCE3CD /* CipherConfig.cpp */,\n\t\t\t\t23F70FAB20A055C300CCE3CD /* CipherConfig.hpp */,\n\t\t\t\t2360A60120D78F2B00E4A311 /* PerformanceTraceConfig.cpp */,\n\t\t\t\t2360A60220D78F2B00E4A311 /* PerformanceTraceConfig.hpp */,\n\t\t\t\t2360A5FF20D78F2B00E4A311 /* SQLTraceConfig.cpp */,\n\t\t\t\t2360A60020D78F2B00E4A311 /* SQLTraceConfig.hpp */,\n\t\t\t\t23F70FB620A055CF00CCE3CD /* AutoCheckpointConfig.cpp */,\n\t\t\t\t3934DB25229B951C008A6AEC /* AutoCheckpointConfig.hpp */,\n\t\t\t\t23F70FD420A07CEC00CCE3CD /* CustomConfig.cpp */,\n\t\t\t\t23F70FD520A07CEC00CCE3CD /* CustomConfig.hpp */,\n\t\t\t\t237A8D5D21EDBB2E003AF5BB /* BusyRetryConfig.cpp */,\n\t\t\t\t237A8D5E21EDBB2E003AF5BB /* BusyRetryConfig.hpp */,\n\t\t\t\t23301BFA229A851800A8AB5A /* AutoBackupConfig.cpp */,\n\t\t\t\t23301BF9229A851800A8AB5A /* AutoBackupConfig.hpp */,\n\t\t\t\t0DCD2AC12C6E210700C247EC /* AutoVacuumConfig.cpp */,\n\t\t\t\t0DCD2AC22C6E210700C247EC /* AutoVacuumConfig.hpp */,\n\t\t\t);\n\t\t\tpath = config;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t39327AC422CF271D00AABD4B /* utility */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t39327B5722CF275100AABD4B /* Dispatch.h */,\n\t\t\t\t39327B4F22CF275000AABD4B /* Dispatch.mm */,\n\t\t\t\t39327B5122CF275100AABD4B /* Signpost.h */,\n\t\t\t\t39327B4E22CF275000AABD4B /* Signpost.mm */,\n\t\t\t\t39327B5022CF275100AABD4B /* TestCaseAssertion.h */,\n\t\t\t\t39327B5822CF275100AABD4B /* TestCaseCounter.h */,\n\t\t\t\t39327B5322CF275100AABD4B /* TestCaseCounter.mm */,\n\t\t\t\t39327B5622CF275100AABD4B /* TestCaseLog.h */,\n\t\t\t\t39327B5422CF275100AABD4B /* TestCaseLog.mm */,\n\t\t\t\t39327B4C22CF275000AABD4B /* TestCaseMacro.h */,\n\t\t\t\t39327B5922CF275200AABD4B /* TestCaseResult.h */,\n\t\t\t\t39327B5222CF275100AABD4B /* TestCaseResult.mm */,\n\t\t\t\t39327B4D22CF275000AABD4B /* NSObject+TestCase.h */,\n\t\t\t\t39327B4B22CF275000AABD4B /* NSObject+TestCase.mm */,\n\t\t\t\t39327B5A22CF275200AABD4B /* WCTDatabase+TestCase.h */,\n\t\t\t\t39327B5522CF275100AABD4B /* WCTDatabase+TestCase.mm */,\n\t\t\t);\n\t\t\tpath = utility;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t39327AD822CF271D00AABD4B /* object */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t39327B8B22CF275F00AABD4B /* AllTypesObject.h */,\n\t\t\t\t39327B8D22CF275F00AABD4B /* AllTypesObject.mm */,\n\t\t\t\t39327B8A22CF275F00AABD4B /* AllTypesObject+WCTTableCoding.h */,\n\t\t\t\t39327B8E22CF276000AABD4B /* TestCaseObject.h */,\n\t\t\t\t39327B8922CF275F00AABD4B /* TestCaseObject.mm */,\n\t\t\t\t39327B8C22CF275F00AABD4B /* TestCaseObject+WCTTableCoding.h */,\n\t\t\t);\n\t\t\tpath = object;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t39327AE622CF271E00AABD4B /* random */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t39327B7B22CF275800AABD4B /* Random.h */,\n\t\t\t\t39327B7A22CF275800AABD4B /* Random.mm */,\n\t\t\t\t39327B7C22CF275800AABD4B /* Random+TestCaseObject.h */,\n\t\t\t\t39327B7722CF275800AABD4B /* Random+TestCaseObject.mm */,\n\t\t\t\t39327B7822CF275800AABD4B /* Random+WCDB.h */,\n\t\t\t\t39327B7922CF275800AABD4B /* Random+WCDB.mm */,\n\t\t\t);\n\t\t\tpath = random;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t39327AEE22CF271F00AABD4B /* factory */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t39327B9822CF276600AABD4B /* PrototypeFactory.h */,\n\t\t\t\t39327B9922CF276600AABD4B /* PrototypeFactory.mm */,\n\t\t\t\t39327B9A22CF276600AABD4B /* ObjectsBasedFactory.h */,\n\t\t\t\t39327B9722CF276600AABD4B /* ObjectsBasedFactory.mm */,\n\t\t\t\t39327B9C22CF276600AABD4B /* SizeBasedFactory.h */,\n\t\t\t\t39327B9B22CF276600AABD4B /* SizeBasedFactory.mm */,\n\t\t\t\t39327B9D22CF276600AABD4B /* TablesBasedFactory.h */,\n\t\t\t\t39327B9E22CF276600AABD4B /* TablesBasedFactory.mm */,\n\t\t\t);\n\t\t\tpath = factory;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t751CA66F28C648F300874A7A /* field */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t751CA67228C6491A00874A7A /* CPPFieldObject.h */,\n\t\t\t\t7511EA52293CF7CA00FB033B /* CPPNewFieldObject.h */,\n\t\t\t);\n\t\t\tpath = field;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t751CA67428C64B3600874A7A /* alltypes */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t751CA67628C64B7B00874A7A /* CPPAllTypesObject.h */,\n\t\t\t\t751CA67528C64B7B00874A7A /* CPPAllTypesObject.mm */,\n\t\t\t\t0D435A622AF1093B00FABDAF /* CPPSharedPtrAllTypesObject.h */,\n\t\t\t\t0D435A602AF1092100FABDAF /* CPPSharedPtrAllTypesObject.mm */,\n\t\t\t\t0D36C0F92AF1E3A1000BC0DD /* CPPSTDOptionalAllTypesObject.h */,\n\t\t\t\t0D36C0FA2AF1E3B1000BC0DD /* CPPSTDOptionalAllTypesObject.mm */,\n\t\t\t\t0D36C0FF2AF1F482000BC0DD /* CPPWCDBOptionalAllTypesObject.h */,\n\t\t\t\t0D36C1002AF1F492000BC0DD /* CPPWCDBOptionalAllTypesObject.mm */,\n\t\t\t);\n\t\t\tpath = alltypes;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t7521D38F28BD1133009C33D0 /* chaincall */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t7521D39128BD1187009C33D0 /* ChainCall.hpp */,\n\t\t\t\t7521D39028BD1187009C33D0 /* ChainCall.cpp */,\n\t\t\t\t75FFD32D28BE5BB70051DB07 /* Insert.hpp */,\n\t\t\t\t03F428E828BF686F005CE249 /* Update.hpp */,\n\t\t\t\t039D724928BF773D00990803 /* Delete.hpp */,\n\t\t\t\t03D077FB28C20FEE009A3B18 /* Delete.cpp */,\n\t\t\t\t039D724D28BF795700990803 /* Select.hpp */,\n\t\t\t\t75E50A2C2907921600B73E62 /* MultiSelect.hpp */,\n\t\t\t\t75E50A2B2907921600B73E62 /* MultiSelect.cpp */,\n\t\t\t\t75E50A0A29067BC800B73E62 /* MultiObject.hpp */,\n\t\t\t\t75E50A0929067BC800B73E62 /* MultiObject.cpp */,\n\t\t\t);\n\t\t\tpath = chaincall;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t7522B4BD2A6D2E3800B465D6 /* migration */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t7522B51B2A6D3B6F00B465D6 /* model */,\n\t\t\t\t7522B4C02A6D2EAF00B465D6 /* common */,\n\t\t\t\t0D47A9742A6E27CF008E9E2C /* compatible */,\n\t\t\t);\n\t\t\tpath = migration;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t7522B4C02A6D2EAF00B465D6 /* common */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t7522B4BE2A6D2EA900B465D6 /* MigrationTestObject.h */,\n\t\t\t\t7522B5282A6D76DB00B465D6 /* MigrationTestSourceObject.h */,\n\t\t\t\t0D47A9752A6E332B008E9E2C /* MigrationTestObjectBase.h */,\n\t\t\t\t0D47A9762A6E333D008E9E2C /* MigrationTestObjectBase.mm */,\n\t\t\t\t7522B51F2A6D591A00B465D6 /* MigrationTestCase.h */,\n\t\t\t\t7522B5202A6D592800B465D6 /* MigrationTestCase.mm */,\n\t\t\t\t7522B5222A6D5DCA00B465D6 /* Random+MigrationTestObject.h */,\n\t\t\t\t7522B5232A6D5DD600B465D6 /* Random+MigrationTestObject.mm */,\n\t\t\t);\n\t\t\tpath = common;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t7522B51B2A6D3B6F00B465D6 /* model */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t7522B52B2A6D78BA00B465D6 /* AutoIncrementMigrationObject.h */,\n\t\t\t\t7522B5302A6D78BB00B465D6 /* AutoIncrementMigrationObject.mm */,\n\t\t\t\t7522B52E2A6D78BA00B465D6 /* IntegerPrimaryKeyMigrationObject.h */,\n\t\t\t\t7522B52D2A6D78BA00B465D6 /* IntegerPrimaryKeyMigrationObject.mm */,\n\t\t\t\t7522B52C2A6D78BA00B465D6 /* NormalMigrationObject.h */,\n\t\t\t\t7522B52F2A6D78BB00B465D6 /* NormalMigrationObject.mm */,\n\t\t\t\t7522B4C12A6D30B000B465D6 /* NormalMigrationSourceObject.h */,\n\t\t\t\t7522B5162A6D38D800B465D6 /* NormalMigrationSourceObject.mm */,\n\t\t\t\t7522B5182A6D3B2A00B465D6 /* IntegerPrimaryKeyMigrationSourceObject.h */,\n\t\t\t\t7522B5192A6D3B3300B465D6 /* IntegerPrimaryKeyMigrationSourceObject.mm */,\n\t\t\t\t7522B51C2A6D3C6C00B465D6 /* AutoIncrementMigrationSourceObject.h */,\n\t\t\t\t7522B51D2A6D3C8600B465D6 /* AutoIncrementMigrationSourceObject.mm */,\n\t\t\t);\n\t\t\tpath = model;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t752C7E3E28C8E8D700C9FFA6 /* operation */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t753C084C28A8D4560042C427 /* StatementOperationTests.mm */,\n\t\t\t\t758D9D0028BA6AF8001B3D2D /* HandleOperationTests.mm */,\n\t\t\t\t752C7E3C28C8E16800C9FFA6 /* ORMDeleteTests.mm */,\n\t\t\t\t752C7E3F28C8E94200C9FFA6 /* ORMInsertTests.mm */,\n\t\t\t\t03B4DB1528C98E5E00F64141 /* ORMSelectTests.mm */,\n\t\t\t\t0344BA8028C9DC7D000BC154 /* ORMUpdateTests.mm */,\n\t\t\t\t75E50AC12908EC7100B73E62 /* ORMMultiSelectTests.mm */,\n\t\t\t\t0344BACA28CA0589000BC154 /* ChainCallTests.mm */,\n\t\t\t);\n\t\t\tpath = operation;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t754211D92B11FCDE00A2FF4D /* function */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t754211F22B12352A00A2FF4D /* scalar */,\n\t\t\t\t754211E92B12331900A2FF4D /* FunctionModules.hpp */,\n\t\t\t);\n\t\t\tpath = function;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t754211F22B12352A00A2FF4D /* scalar */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t754211DA2B11FE9200A2FF4D /* ScalarFunctionModule.cpp */,\n\t\t\t\t754211DB2B11FE9200A2FF4D /* ScalarFunctionModule.hpp */,\n\t\t\t\t754211F32B12359400A2FF4D /* ScalarFunctionConfig.cpp */,\n\t\t\t\t754211F42B12359400A2FF4D /* ScalarFunctionConfig.hpp */,\n\t\t\t\t754211FE2B123E3200A2FF4D /* ScalarFunctionTemplate.hpp */,\n\t\t\t);\n\t\t\tpath = scalar;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t754212092B124CFF00A2FF4D /* compression */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t7542120A2B124CFF00A2FF4D /* CompressionCenter.cpp */,\n\t\t\t\t7542120E2B124CFF00A2FF4D /* CompressionCenter.hpp */,\n\t\t\t\t7542120B2B124CFF00A2FF4D /* ZSTDDict.cpp */,\n\t\t\t\t7542120F2B124CFF00A2FF4D /* ZSTDDict.hpp */,\n\t\t\t\t7525176A2B12FDC700485175 /* ZSTDContext.cpp */,\n\t\t\t\t7525176B2B12FDC700485175 /* ZSTDContext.hpp */,\n\t\t\t\t7542120C2B124CFF00A2FF4D /* CompressionInfo.cpp */,\n\t\t\t\t754212102B124CFF00A2FF4D /* CompressionInfo.hpp */,\n\t\t\t\t7542120D2B124CFF00A2FF4D /* Compression.cpp */,\n\t\t\t\t754212112B124CFF00A2FF4D /* Compression.hpp */,\n\t\t\t\t752517592B12D43700485175 /* DecompressFunction.cpp */,\n\t\t\t\t7525175A2B12D43700485175 /* DecompressFunction.hpp */,\n\t\t\t\t752517652B12F13C00485175 /* CompressionConst.hpp */,\n\t\t\t\t752517742B132DAB00485175 /* CompressionConst.cpp */,\n\t\t\t\t7525177F2B1338AF00485175 /* CompressionRecord.cpp */,\n\t\t\t\t752517802B1338AF00485175 /* CompressionRecord.hpp */,\n\t\t\t\t7525178B2B133DB700485175 /* CompressHandleOperator.cpp */,\n\t\t\t\t7525178C2B133DB700485175 /* CompressHandleOperator.hpp */,\n\t\t\t\t0D5403012B160693007DF415 /* CompressingStatementDecorator.cpp */,\n\t\t\t\t0D5403022B160693007DF415 /* CompressingStatementDecorator.hpp */,\n\t\t\t\t0D54030B2B1606BC007DF415 /* CompressingHandleDecorator.cpp */,\n\t\t\t\t0D54030C2B1606BC007DF415 /* CompressingHandleDecorator.hpp */,\n\t\t\t\t758E7EB62B1B24AD00319991 /* AutoCompressConfig.cpp */,\n\t\t\t\t758E7EB72B1B24AD00319991 /* AutoCompressConfig.hpp */,\n\t\t\t);\n\t\t\tpath = compression;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t757457022402D571005E3682 /* statement */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t757457032402D614005E3682 /* WCTPreparedStatement.h */,\n\t\t\t\t755391D52403B3DB00036918 /* WCTPreparedStatement.mm */,\n\t\t\t\t755391E02403CB9700036918 /* WCTPreparedStatement+Private.h */,\n\t\t\t);\n\t\t\tpath = statement;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t75882C7E28C7C2F500F95947 /* column_constraint */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t75882C7C28C7C2EF00F95947 /* CPPColumnConstraintPrimary.hpp */,\n\t\t\t\t75882C7B28C7C2EF00F95947 /* CPPColumnConstraintPrimary.cpp */,\n\t\t\t\t75882C8028C7C3E600F95947 /* CPPColumnConstraintPrimaryAsc.hpp */,\n\t\t\t\t75882C7F28C7C3E600F95947 /* CPPColumnConstraintPrimaryAsc.cpp */,\n\t\t\t\t75882C8328C7C4A300F95947 /* CPPColumnConstraintPrimaryDesc.hpp */,\n\t\t\t\t75882C8228C7C4A300F95947 /* CPPColumnConstraintPrimaryDesc.cpp */,\n\t\t\t\t75882C8628C7C55200F95947 /* CPPColumnConstraintAutoIncrement.hpp */,\n\t\t\t\t75882C8528C7C55200F95947 /* CPPColumnConstraintAutoIncrement.cpp */,\n\t\t\t\t75882C8928C7C60C00F95947 /* CPPColumnConstraintAutoIncrementAsc.hpp */,\n\t\t\t\t75882C8828C7C60C00F95947 /* CPPColumnConstraintAutoIncrementAsc.cpp */,\n\t\t\t\t75882C8C28C7C6CF00F95947 /* CPPColumnConstraintUnique.hpp */,\n\t\t\t\t75882C8B28C7C6CF00F95947 /* CPPColumnConstraintUnique.cpp */,\n\t\t\t\t75882C8F28C7C78200F95947 /* CPPColumnConstraintDefault.hpp */,\n\t\t\t\t75882C8E28C7C78200F95947 /* CPPColumnConstraintDefault.cpp */,\n\t\t\t\t0D81CDAC2A56DA070051FF8E /* CPPColumnConstraintEnablePrimaryAutoIncrement.cpp */,\n\t\t\t\t0D81CDAD2A56DA070051FF8E /* CPPColumnConstraintEnablePrimaryAutoIncrement.hpp */,\n\t\t\t);\n\t\t\tpath = column_constraint;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t758E7EC02B1B400F00319991 /* compression */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t758E7EC62B1B41C500319991 /* WCTCompressionInfo.h */,\n\t\t\t\t758E7EC92B1B423200319991 /* WCTCompressionInfo+Private.h */,\n\t\t\t\t758E7EC12B1B41AA00319991 /* WCTCompressionInfo.mm */,\n\t\t\t\t758E7ECC2B1B49E300319991 /* WCTDatabase+Compression.h */,\n\t\t\t\t758E7ECF2B1B49EF00319991 /* WCTDatabase+Compression.mm */,\n\t\t\t);\n\t\t\tpath = compression;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t758E7F2D2B1C82AA00319991 /* compression */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t758E7F2E2B1C82BC00319991 /* common */,\n\t\t\t\t758E7F3C2B1C998300319991 /* compatible */,\n\t\t\t);\n\t\t\tpath = compression;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t758E7F2E2B1C82BC00319991 /* common */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t758E7F322B1C830A00319991 /* CompressionTestObject.h */,\n\t\t\t\t758E7F2F2B1C82EC00319991 /* CompressionTestObject.mm */,\n\t\t\t\t758E7F372B1C85A900319991 /* Random+CompressionTestObject.h */,\n\t\t\t\t758E7F382B1C864700319991 /* Random+CompressionTestObject.mm */,\n\t\t\t\t758E7F3F2B1C99D200319991 /* CompressionTestCase.h */,\n\t\t\t\t758E7F3D2B1C99C700319991 /* CompressionTestCase.mm */,\n\t\t\t);\n\t\t\tpath = common;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t758E7F3C2B1C998300319991 /* compatible */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t751FE4E62B1E10F200BFC7AD /* CompressingCRUDTest.mm */,\n\t\t\t\t0D2789D82B21995800F60E2D /* CompressionTests.mm */,\n\t\t\t\t0DAD8FF62B303D2A00372DBF /* CompressRobustyTests.mm */,\n\t\t\t);\n\t\t\tpath = compatible;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t759362D72B36D667000AF163 /* vacuum */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t759362D82B36D756000AF163 /* VacuumHandleOperator.cpp */,\n\t\t\t\t759362D92B36D756000AF163 /* VacuumHandleOperator.hpp */,\n\t\t\t);\n\t\t\tpath = vacuum;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t75B69889290AD0A9006E1F8F /* auxfunction */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t7543DD82271C2F3B00B533B4 /* FTS5AuxiliaryFunctionTemplate.hpp */,\n\t\t\t\t7543DD85271C2FD000B533B4 /* AuxiliaryFunctionModule.hpp */,\n\t\t\t\t7543DD84271C2FD000B533B4 /* AuxiliaryFunctionModule.cpp */,\n\t\t\t\t7543DD8D271C360E00B533B4 /* AuxiliaryFunctionConfig.hpp */,\n\t\t\t\t7543DD8C271C360E00B533B4 /* AuxiliaryFunctionConfig.cpp */,\n\t\t\t\t7543DD91271C601F00B533B4 /* SubstringMatchInfo.hpp */,\n\t\t\t\t7543DD90271C601F00B533B4 /* SubstringMatchInfo.cpp */,\n\t\t\t);\n\t\t\tpath = auxfunction;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t75B6988A290AD114006E1F8F /* tokenizer */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t234F0337227A950900DD65A2 /* SQLiteFTS3Tokenizer.h */,\n\t\t\t\t2304B42722156CD700901953 /* TokenizerModule.hpp */,\n\t\t\t\t2304B42622156CD700901953 /* TokenizerModule.cpp */,\n\t\t\t\t23E163D120FDDD8500C3F910 /* PorterStemming.c */,\n\t\t\t\t23B4DCD92112AC5600954D71 /* TokenizerModuleTemplate.hpp */,\n\t\t\t\t2304B42D22156E1500901953 /* TokenizerModules.hpp */,\n\t\t\t\t2304B42C22156E1500901953 /* TokenizerModules.cpp */,\n\t\t\t\t23F70FBD20A055D400CCE3CD /* TokenizerConfig.hpp */,\n\t\t\t\t23F70FBC20A055D400CCE3CD /* TokenizerConfig.cpp */,\n\t\t\t\t75B698D4290AD4C0006E1F8F /* BaseTokenizerUtil.hpp */,\n\t\t\t\t75B698D3290AD4C0006E1F8F /* BaseTokenizerUtil.cpp */,\n\t\t\t\t03450DB72738C8F800C4DC1B /* PinyinTokenizer.hpp */,\n\t\t\t\t03450DB62738C8F800C4DC1B /* PinyinTokenizer.cpp */,\n\t\t\t\t03450DB32738BBF000C4DC1B /* OneOrBinaryTokenizer.hpp */,\n\t\t\t\t03450DB22738BBF000C4DC1B /* OneOrBinaryTokenizer.cpp */,\n\t\t\t);\n\t\t\tpath = tokenizer;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t75CD026728CF18FD0071B6C3 /* chaincall */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t03E165C227F42D6500D2C926 /* Declare.swift */,\n\t\t\t\t03E165C627F42D6500D2C926 /* ChainCall.swift */,\n\t\t\t\t7521DDE429209B8D009642EF /* ChainCall+WCTTableCoding.swift */,\n\t\t\t\t03E165CD27F42D6500D2C926 /* Insert.swift */,\n\t\t\t\t7521DDEA29209D04009642EF /* Insert+WCTTableCoding.swift */,\n\t\t\t\t03E165C527F42D6500D2C926 /* Delete.swift */,\n\t\t\t\t03E165C427F42D6500D2C926 /* Update.swift */,\n\t\t\t\t7521DDED29209DCE009642EF /* Update+WCTTableCoding.swift */,\n\t\t\t\t03E165CB27F42D6500D2C926 /* Selectable.swift */,\n\t\t\t\t03E165C927F42D6500D2C926 /* Select.swift */,\n\t\t\t\t7521DDEF29209E4E009642EF /* Select+WCTTableCoding.swift */,\n\t\t\t\t03E165CC27F42D6500D2C926 /* MultiSelect.swift */,\n\t\t\t\t03E165C327F42D6500D2C926 /* RowSelect.swift */,\n\t\t\t\t0DAD93C029FA2A1200E5788C /* TableChainCall.swift */,\n\t\t\t\t0DAD93C329FA2C4800E5788C /* TableChainCall+WCTTableCoding.swift */,\n\t\t\t);\n\t\t\tpath = chaincall;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t75CD724C290D231D008583A3 /* fts */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t75CD724E290D2449008583A3 /* CPPFTS3Object.h */,\n\t\t\t\t75CD724D290D2449008583A3 /* CPPFTS3Object.mm */,\n\t\t\t\t7547A3CE290D2B2600AFA132 /* CPPFTS3Tests.mm */,\n\t\t\t\t75535244290E621B008376AB /* CPPFTS5Object.h */,\n\t\t\t\t75535242290E620F008376AB /* CPPFTS5Object.mm */,\n\t\t\t\t75535245290E63E5008376AB /* CPPFTS5Tests.mm */,\n\t\t\t);\n\t\t\tpath = fts;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t75D2A9BB2AB497D70024B8B2 /* common */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t0DE68B372AB45C36008BD74C /* RepairTestObjectBase.h */,\n\t\t\t\t0DE68B352AB45C27008BD74C /* RepairTestObjectBase.mm */,\n\t\t\t\t0DE68B382AB45EE8008BD74C /* RepairTestObject.h */,\n\t\t\t\t75D2A9BD2AB49B390024B8B2 /* Random+RepairTestObject.h */,\n\t\t\t\t75D2A9BC2AB49B2D0024B8B2 /* Random+RepairTestObject.mm */,\n\t\t\t\t234F0733227AA5C700DD65A2 /* BackupTestCase.h */,\n\t\t\t\t234F0731227AA5C700DD65A2 /* BackupTestCase.mm */,\n\t\t\t);\n\t\t\tpath = common;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t75DF22922AEE83D8006A3311 /* inherit */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t75DF22942AEE8409006A3311 /* CPPInheritObject.hpp */,\n\t\t\t\t75DF22932AEE8409006A3311 /* CPPInheritObject.cpp */,\n\t\t\t);\n\t\t\tpath = inherit;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t75E76AE12917ADF400073CCA /* virtual_table */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t75E76AE32917AE2A00073CCA /* CPPVirtualTableFTS4Object.hpp */,\n\t\t\t\t75E76AE22917AE2A00073CCA /* CPPVirtualTableFTS4Object.cpp */,\n\t\t\t\t75E76AE62917B07E00073CCA /* CPPVirtualTableFTS5Object.hpp */,\n\t\t\t\t75E76AE52917B07E00073CCA /* CPPVirtualTableFTS5Object.cpp */,\n\t\t\t);\n\t\t\tpath = virtual_table;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t75EABA092ADA4F2600AAD3C9 /* Products */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t75EABA0D2ADA4F2600AAD3C9 /* zstd.framework */,\n\t\t\t);\n\t\t\tname = Products;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t75F3140F2AAC07C9007FFDFB /* cipher */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t75F3140C2AAC067B007FFDFB /* CipherHandle.hpp */,\n\t\t\t\t75F3140B2AAC067B007FFDFB /* CipherHandle.cpp */,\n\t\t\t);\n\t\t\tpath = cipher;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t75F32F0628B9CC2300A72697 /* binding */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t03AFD33128B883E700EF5E56 /* Accessor.hpp */,\n\t\t\t\t7537E58428B91F510077D92B /* Accessor.cpp */,\n\t\t\t\t032E113328C88B8000BCACE0 /* RunTimeAccessor.hpp */,\n\t\t\t\t75DF22992AEFF995006A3311 /* SharedPtrAccessor.hpp */,\n\t\t\t\t0D36C0F62AF1E00C000BC0DD /* STDOptionalAccessor.hpp */,\n\t\t\t\t0D36C0FC2AF1F0B6000BC0DD /* WCDBOptionalAccessor.hpp */,\n\t\t\t\t03AFD34128B8B21B00EF5E56 /* Field.hpp */,\n\t\t\t\t03AFD34E28B8C4EB00EF5E56 /* Field.cpp */,\n\t\t\t\t75F32F2728BA31CD00A72697 /* ResultField.hpp */,\n\t\t\t\t75F32F2628BA31CD00A72697 /* ResultField.cpp */,\n\t\t\t\t03AFD34528B8B57600EF5E56 /* Binding.hpp */,\n\t\t\t\t03AFD34B28B8BB7600EF5E56 /* Binding.cpp */,\n\t\t\t);\n\t\t\tpath = binding;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t75F32F0728B9CCD200A72697 /* macro */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t75F32F0828B9CE8E00A72697 /* CPPORMMacro.h */,\n\t\t\t\t75F32F1528BA066400A72697 /* CPPBindingMacro.h */,\n\t\t\t\t75F32F1228BA039D00A72697 /* CPPFieldMacro.h */,\n\t\t\t\t75F32F1828BA083E00A72697 /* CPPIndexMacro.h */,\n\t\t\t\t758D9D0228BA7265001B3D2D /* CPPTableConstraintMacro.h */,\n\t\t\t\t758D9D0528BA7F06001B3D2D /* CPPColumnConstraintMacro.h */,\n\t\t\t\t758D9D0828BA819A001B3D2D /* CPPVirtualTableMacro.h */,\n\t\t\t);\n\t\t\tpath = macro;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t75F32F1128BA02AF00A72697 /* fts */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t75F32F0C28B9F90900A72697 /* FTSTokenizerUtil.hpp */,\n\t\t\t\t75F32F0B28B9F90900A72697 /* FTSTokenizerUtil.cpp */,\n\t\t\t);\n\t\t\tpath = fts;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n/* End PBXGroup section */\n\n/* Begin PBXHeadersBuildPhase section */\n\t\t037C3A852897E33600328EC8 /* Headers */ = {\n\t\t\tisa = PBXHeadersBuildPhase;\n\t\t\tbuildActionMask = 2147483647;\n\t\t\tfiles = (\n\t\t\t\t037C3A862897E33600328EC8 /* AsyncQueue.hpp in Headers */,\n\t\t\t\t75D99B8028CA441E00BEC8B5 /* BaseOperation.hpp in Headers */,\n\t\t\t\t7537E5D328B939240077D92B /* BaseBinding.hpp in Headers */,\n\t\t\t\t037C3A872897E33600328EC8 /* AutoBackupConfig.hpp in Headers */,\n\t\t\t\t0D19BA252B07481B0028F92B /* IntegerityHandleOperator.hpp in Headers */,\n\t\t\t\t037C3A882897E33600328EC8 /* WINQ.h in Headers */,\n\t\t\t\t7521DDDF291EA729009642EF /* StatementOperation.hpp in Headers */,\n\t\t\t\t758E7EBE2B1B24AD00319991 /* AutoCompressConfig.hpp in Headers */,\n\t\t\t\t037C3A8A2897E33600328EC8 /* UnsafeData.hpp in Headers */,\n\t\t\t\t037C3A8C2897E33600328EC8 /* CommonCore.hpp in Headers */,\n\t\t\t\t037C3A8F2897E33600328EC8 /* Pragma.hpp in Headers */,\n\t\t\t\t037C3A902897E33600328EC8 /* SequenceItem.hpp in Headers */,\n\t\t\t\t037C3A912897E33600328EC8 /* MappedData.hpp in Headers */,\n\t\t\t\t037C3A922897E33600328EC8 /* SyntaxCommitSTMT.hpp in Headers */,\n\t\t\t\t037C3A932897E33600328EC8 /* Syntax.h in Headers */,\n\t\t\t\t037C3A942897E33600328EC8 /* SyntaxAttachSTMT.hpp in Headers */,\n\t\t\t\t037C3A952897E33600328EC8 /* CommonTableExpression.hpp in Headers */,\n\t\t\t\t037C3A982897E33600328EC8 /* Console.hpp in Headers */,\n\t\t\t\t037C3A9C2897E33600328EC8 /* CommonCore.h in Headers */,\n\t\t\t\t037C3A9D2897E33600328EC8 /* HandleNotification.hpp in Headers */,\n\t\t\t\t037C3A9E2897E33600328EC8 /* SyntaxCreateTableSTMT.hpp in Headers */,\n\t\t\t\t0D5363EC290A65390026A4DC /* Master.hpp in Headers */,\n\t\t\t\t037C3A9F2897E33600328EC8 /* SyntaxDropTriggerSTMT.hpp in Headers */,\n\t\t\t\t037C3AA02897E33600328EC8 /* TokenizerModuleTemplate.hpp in Headers */,\n\t\t\t\t037C3AA12897E33600328EC8 /* Convertible.hpp in Headers */,\n\t\t\t\t037C3AA22897E33600328EC8 /* Initializeable.hpp in Headers */,\n\t\t\t\t037C3AA52897E33600328EC8 /* Recyclable.hpp in Headers */,\n\t\t\t\t7529C77A2ABC4D9900518293 /* CipherHandle.hpp in Headers */,\n\t\t\t\t037C3AA62897E33600328EC8 /* CoreConst.h in Headers */,\n\t\t\t\t037C3AA72897E33600328EC8 /* Cell.hpp in Headers */,\n\t\t\t\t0DD8D11D2B074C47002C97D3 /* MigrateHandleOperator.hpp in Headers */,\n\t\t\t\t037C3AA92897E33600328EC8 /* BasicConfig.hpp in Headers */,\n\t\t\t\t037C3AAA2897E33600328EC8 /* StatementDropIndex.hpp in Headers */,\n\t\t\t\t037C3AAB2897E33600328EC8 /* Pager.hpp in Headers */,\n\t\t\t\t037C3AAC2897E33600328EC8 /* SyntaxCreateIndexSTMT.hpp in Headers */,\n\t\t\t\t0D36C0FE2AF1F0B6000BC0DD /* WCDBOptionalAccessor.hpp in Headers */,\n\t\t\t\t037C3AAF2897E33600328EC8 /* Crawlable.hpp in Headers */,\n\t\t\t\t037C3AB02897E33600328EC8 /* LiteralValue.hpp in Headers */,\n\t\t\t\t037C3AB12897E33600328EC8 /* CustomConfig.hpp in Headers */,\n\t\t\t\t037C3AB22897E33600328EC8 /* StatementCreateTable.hpp in Headers */,\n\t\t\t\t754212302B124CFF00A2FF4D /* Compression.hpp in Headers */,\n\t\t\t\t037C3AB32897E33600328EC8 /* ForeignKey.hpp in Headers */,\n\t\t\t\t037C3AB62897E33600328EC8 /* WCDBVersion.h in Headers */,\n\t\t\t\t037C3AB82897E33600328EC8 /* StatementDropTrigger.hpp in Headers */,\n\t\t\t\t037C3AB92897E33600328EC8 /* FTSFunction.hpp in Headers */,\n\t\t\t\t037C3ABF2897E33600328EC8 /* WalRelated.hpp in Headers */,\n\t\t\t\t0D19BA112B0702250028F92B /* AssembleHandleOperator.hpp in Headers */,\n\t\t\t\t037C3AC02897E33600328EC8 /* FactoryRelated.hpp in Headers */,\n\t\t\t\t037C3AC12897E33600328EC8 /* SyntaxSelectSTMT.hpp in Headers */,\n\t\t\t\t037C3AC32897E33600328EC8 /* PerformanceTraceConfig.hpp in Headers */,\n\t\t\t\t032E113528C88C3C00BCACE0 /* RunTimeAccessor.hpp in Headers */,\n\t\t\t\t037C3AC42897E33600328EC8 /* ColumnMeta.hpp in Headers */,\n\t\t\t\t037C3AC62897E33600328EC8 /* Macro.h in Headers */,\n\t\t\t\t75ADC56A2A8D1C2D00D0AC47 /* TableAttribute.hpp in Headers */,\n\t\t\t\t037C3AC72897E33600328EC8 /* BusyRetryConfig.hpp in Headers */,\n\t\t\t\t037C3AC82897E33600328EC8 /* Progress.hpp in Headers */,\n\t\t\t\t037C3AC92897E33600328EC8 /* SyntaxForeignKeyClause.hpp in Headers */,\n\t\t\t\t752517722B12FDC700485175 /* ZSTDContext.hpp in Headers */,\n\t\t\t\t754359562B0671DE00CDF232 /* BackupHandleOperator.hpp in Headers */,\n\t\t\t\t037C3ACA2897E33600328EC8 /* SyntaxAssertion.hpp in Headers */,\n\t\t\t\t037C3ACB2897E33600328EC8 /* SyntaxSelectCore.hpp in Headers */,\n\t\t\t\t037C3ACC2897E33600328EC8 /* SyntaxTableConstraint.hpp in Headers */,\n\t\t\t\t754212242B124CFF00A2FF4D /* CompressionCenter.hpp in Headers */,\n\t\t\t\t037C3ACD2897E33600328EC8 /* ThreadedErrors.hpp in Headers */,\n\t\t\t\t037C3ACE2897E33600328EC8 /* TableConstraint.hpp in Headers */,\n\t\t\t\t037C3ACF2897E33600328EC8 /* AuxiliaryFunctionConfig.hpp in Headers */,\n\t\t\t\t037C3AD12897E33600328EC8 /* SQL.hpp in Headers */,\n\t\t\t\t758D9D0328BA7265001B3D2D /* CPPTableConstraintMacro.h in Headers */,\n\t\t\t\t037C3AD32897E33600328EC8 /* SequenceCrawler.hpp in Headers */,\n\t\t\t\t037C3AD42897E33600328EC8 /* PageBasedFileHandle.hpp in Headers */,\n\t\t\t\t037C3AD52897E33600328EC8 /* SQLTraceConfig.hpp in Headers */,\n\t\t\t\t037C3AD62897E33600328EC8 /* Data.hpp in Headers */,\n\t\t\t\t037C3AD82897E33600328EC8 /* Assertion.hpp in Headers */,\n\t\t\t\t037C3ADB2897E33600328EC8 /* Filter.hpp in Headers */,\n\t\t\t\t037C3ADC2897E33600328EC8 /* SyntaxDropViewSTMT.hpp in Headers */,\n\t\t\t\t037C3ADD2897E33600328EC8 /* Scoreable.hpp in Headers */,\n\t\t\t\t037C3ADE2897E33600328EC8 /* CaseInsensitiveList.hpp in Headers */,\n\t\t\t\t037C3ADF2897E33600328EC8 /* SyntaxForwardDeclaration.h in Headers */,\n\t\t\t\t754211FB2B12359400A2FF4D /* ScalarFunctionConfig.hpp in Headers */,\n\t\t\t\t037C3AE22897E33600328EC8 /* MigrationInfo.hpp in Headers */,\n\t\t\t\t03AFD34228B8B21B00EF5E56 /* Field.hpp in Headers */,\n\t\t\t\t037C3AE32897E33600328EC8 /* StatementCreateIndex.hpp in Headers */,\n\t\t\t\t037C3AE72897E33600328EC8 /* StringView.hpp in Headers */,\n\t\t\t\t037C3AE82897E33600328EC8 /* RepairKit.h in Headers */,\n\t\t\t\t0DCD2AC92C6E210700C247EC /* AutoVacuumConfig.hpp in Headers */,\n\t\t\t\t0D3281652B04A8E60027B973 /* DecorativeHandle.hpp in Headers */,\n\t\t\t\t03E5CC7028A3BDF3005353D9 /* Value.hpp in Headers */,\n\t\t\t\t037C3AEA2897E33600328EC8 /* OrderingTerm.hpp in Headers */,\n\t\t\t\t037C3AEB2897E33600328EC8 /* SyntaxUpsertClause.hpp in Headers */,\n\t\t\t\t037C3AEC2897E33600328EC8 /* Shm.hpp in Headers */,\n\t\t\t\t0D5363F2290A75F20026A4DC /* Sequence.hpp in Headers */,\n\t\t\t\t75A60AB529345A38009C1B3C /* Cipher.hpp in Headers */,\n\t\t\t\t037C3AED2897E33600328EC8 /* StatementDetach.hpp in Headers */,\n\t\t\t\t03E5CB0128A3513C005353D9 /* WCDBCpp.h in Headers */,\n\t\t\t\t037C3AEE2897E33600328EC8 /* SubstringMatchInfo.hpp in Headers */,\n\t\t\t\t75F32F2A28BA31CD00A72697 /* ResultField.hpp in Headers */,\n\t\t\t\t037C3AF12897E33600328EC8 /* SyntaxBeginSTMT.hpp in Headers */,\n\t\t\t\t75EF25102AA42DD90009C99F /* EncryptedSerialization.hpp in Headers */,\n\t\t\t\t037C3AF32897E33600328EC8 /* SyntaxUpdateSTMT.hpp in Headers */,\n\t\t\t\t037C3AF42897E33600328EC8 /* ResultColumn.hpp in Headers */,\n\t\t\t\t037C3AF52897E33600328EC8 /* StatementCreateTrigger.hpp in Headers */,\n\t\t\t\t037C3AF62897E33600328EC8 /* Repairman.hpp in Headers */,\n\t\t\t\t037C3AF72897E33600328EC8 /* ExpressionOperable.hpp in Headers */,\n\t\t\t\t037C3AF82897E33600328EC8 /* HandleRelated.hpp in Headers */,\n\t\t\t\t037C3AF92897E33600328EC8 /* SyntaxOrderingTerm.hpp in Headers */,\n\t\t\t\t037C3AFD2897E33600328EC8 /* SyntaxAlterTableSTMT.hpp in Headers */,\n\t\t\t\t037C3AFF2897E33600328EC8 /* IndexedColumn.hpp in Headers */,\n\t\t\t\t037C3B012897E33600328EC8 /* TokenizerModule.hpp in Headers */,\n\t\t\t\t037C3B022897E33600328EC8 /* AbstractHandle.hpp in Headers */,\n\t\t\t\t037C3B032897E33600328EC8 /* Factory.hpp in Headers */,\n\t\t\t\t037C3B052897E33600328EC8 /* SyntaxFrameSpec.hpp in Headers */,\n\t\t\t\t037C3B072897E33600328EC8 /* Path.hpp in Headers */,\n\t\t\t\t037C3B092897E33600328EC8 /* Migration.hpp in Headers */,\n\t\t\t\t037C3B0A2897E33600328EC8 /* SyntaxRaiseFunction.hpp in Headers */,\n\t\t\t\t037C3B0B2897E33600328EC8 /* StatementSelect.hpp in Headers */,\n\t\t\t\t037C3B0D2897E33600328EC8 /* SyntaxDropTableSTMT.hpp in Headers */,\n\t\t\t\t037C3B0F2897E33600328EC8 /* SyntaxExplainSTMT.hpp in Headers */,\n\t\t\t\t037C3B102897E33600328EC8 /* StatementDropView.hpp in Headers */,\n\t\t\t\t037C3B112897E33600328EC8 /* StatementExplain.hpp in Headers */,\n\t\t\t\t037C3B132897E33600328EC8 /* Backup.hpp in Headers */,\n\t\t\t\t037C3B142897E33600328EC8 /* MasterItem.hpp in Headers */,\n\t\t\t\t75F32F0F28B9F90900A72697 /* FTSTokenizerUtil.hpp in Headers */,\n\t\t\t\t037C3B152897E33600328EC8 /* BindParameter.hpp in Headers */,\n\t\t\t\t037C3B162897E33600328EC8 /* Join.hpp in Headers */,\n\t\t\t\t037C3B172897E33600328EC8 /* HighWater.hpp in Headers */,\n\t\t\t\t037C3B182897E33600328EC8 /* SyntaxIdentifier.hpp in Headers */,\n\t\t\t\t037C3B192897E33600328EC8 /* Fraction.hpp in Headers */,\n\t\t\t\t037C3B1A2897E33600328EC8 /* StatementDropTable.hpp in Headers */,\n\t\t\t\t037C3B1B2897E33600328EC8 /* SyntaxExpression.hpp in Headers */,\n\t\t\t\t037C3B1C2897E33600328EC8 /* MasterCrawler.hpp in Headers */,\n\t\t\t\t752517682B12F13C00485175 /* CompressionConst.hpp in Headers */,\n\t\t\t\t0373310D289A94E00030C113 /* PreparedStatement.hpp in Headers */,\n\t\t\t\t037C3B1F2897E33600328EC8 /* TokenizerModules.hpp in Headers */,\n\t\t\t\t037C3B212897E33600328EC8 /* QualifiedTable.hpp in Headers */,\n\t\t\t\t03F428EB28BF686F005CE249 /* Update.hpp in Headers */,\n\t\t\t\t037C3B222897E33600328EC8 /* AutoMergeFTSIndexConfig.hpp in Headers */,\n\t\t\t\t037C3B232897E33600328EC8 /* Exiting.hpp in Headers */,\n\t\t\t\t037C3B242897E33600328EC8 /* Config.hpp in Headers */,\n\t\t\t\t039D724A28BF773D00990803 /* Delete.hpp in Headers */,\n\t\t\t\t037C3B282897E33600328EC8 /* Page.hpp in Headers */,\n\t\t\t\t037C3B2A2897E33600328EC8 /* SyntaxFilter.hpp in Headers */,\n\t\t\t\t0D3FFA482A2F2911002DF7CD /* SysTypes.h in Headers */,\n\t\t\t\t7533CB6A2B051C4F00C8B47D /* ClassDecorator.hpp in Headers */,\n\t\t\t\t759362D52B36D450000AF163 /* Vacuum.hpp in Headers */,\n\t\t\t\t037C3B2B2897E33600328EC8 /* StatementRollback.hpp in Headers */,\n\t\t\t\t037C3B2D2897E33600328EC8 /* StatementAlterTable.hpp in Headers */,\n\t\t\t\t037C3B2E2897E33600328EC8 /* StatementPragma.hpp in Headers */,\n\t\t\t\t75FFD33028BE5BB70051DB07 /* Insert.hpp in Headers */,\n\t\t\t\t037C3B2F2897E33600328EC8 /* RecyclableHandle.hpp in Headers */,\n\t\t\t\t037C3B302897E33600328EC8 /* SyntaxSchema.hpp in Headers */,\n\t\t\t\t03A15DF928AA636A0031A50A /* ValueArray.hpp in Headers */,\n\t\t\t\t0DE08A2029CBE79C009A7CA3 /* CrossPlatform.h in Headers */,\n\t\t\t\t037C3B322897E33600328EC8 /* SyntaxLiteralValue.hpp in Headers */,\n\t\t\t\t037C3B332897E33600328EC8 /* StatementReindex.hpp in Headers */,\n\t\t\t\t037C3B342897E33600328EC8 /* SyntaxList.hpp in Headers */,\n\t\t\t\t037C3B372897E33600328EC8 /* ColumnConstraint.hpp in Headers */,\n\t\t\t\t754212052B123E3200A2FF4D /* ScalarFunctionTemplate.hpp in Headers */,\n\t\t\t\t75F32F1328BA039D00A72697 /* CPPFieldMacro.h in Headers */,\n\t\t\t\t753636DE28BBC3820025C2C4 /* Table.hpp in Headers */,\n\t\t\t\t037C3B392897E33600328EC8 /* SQLiteDeclaration.h in Headers */,\n\t\t\t\t03D077F028C1F072009A3B18 /* TableOperation.hpp in Headers */,\n\t\t\t\t037C3B3A2897E33600328EC8 /* SyntaxEnum.hpp in Headers */,\n\t\t\t\t037C3B3D2897E33600328EC8 /* StatementCreateView.hpp in Headers */,\n\t\t\t\t037C3B3E2897E33600328EC8 /* SyntaxCreateVirtualTableSTMT.hpp in Headers */,\n\t\t\t\t037C3B3F2897E33600328EC8 /* Shadow.hpp in Headers */,\n\t\t\t\t75F32F0928B9CE8E00A72697 /* CPPORMMacro.h in Headers */,\n\t\t\t\t037C3B422897E33600328EC8 /* JoinConstraint.hpp in Headers */,\n\t\t\t\t037C3B442897E33600328EC8 /* SyntaxReleaseSTMT.hpp in Headers */,\n\t\t\t\t037C3B452897E33600328EC8 /* Serialization.hpp in Headers */,\n\t\t\t\t037C3B482897E33600328EC8 /* SyntaxColumn.hpp in Headers */,\n\t\t\t\t037C3B492897E33600328EC8 /* InnerDatabase.hpp in Headers */,\n\t\t\t\t037C3B4C2897E33600328EC8 /* MergeFTSIndexLogic.hpp in Headers */,\n\t\t\t\t037C3B4D2897E33600328EC8 /* SyntaxAnalyzeSTMT.hpp in Headers */,\n\t\t\t\t037C3B4E2897E33600328EC8 /* SyntaxColumnConstraint.hpp in Headers */,\n\t\t\t\t037C3B552897E33600328EC8 /* SyntaxReindexSTMT.hpp in Headers */,\n\t\t\t\t037C3B562897E33600328EC8 /* SyntaxCommonTableExpression.hpp in Headers */,\n\t\t\t\t037330C2289A909A0030C113 /* Database.hpp in Headers */,\n\t\t\t\t037C3B572897E33600328EC8 /* UpgradeableErrorProne.hpp in Headers */,\n\t\t\t\t037C3B5B2897E33600328EC8 /* PagerRelated.hpp in Headers */,\n\t\t\t\t037C3B5D2897E33600328EC8 /* Tag.hpp in Headers */,\n\t\t\t\t7521D39428BD1187009C33D0 /* ChainCall.hpp in Headers */,\n\t\t\t\t037C3B5E2897E33600328EC8 /* SQLite.h in Headers */,\n\t\t\t\t037C3B5F2897E33600328EC8 /* SyntaxPragma.hpp in Headers */,\n\t\t\t\t0DC98FD428E46049007F3796 /* DBOperationNotifier.hpp in Headers */,\n\t\t\t\t037C3B642897E33600328EC8 /* StatementCreateVirtualTable.hpp in Headers */,\n\t\t\t\t037C3B652897E33600328EC8 /* SQLiteFTS3Tokenizer.h in Headers */,\n\t\t\t\t037C3B672897E33600328EC8 /* HandlePool.hpp in Headers */,\n\t\t\t\t037C3B682897E33600328EC8 /* StatementInsert.hpp in Headers */,\n\t\t\t\t037C3B6A2897E33600328EC8 /* FactoryDepositor.hpp in Headers */,\n\t\t\t\t7533CB552B050FA300C8B47D /* MigratingHandleDecorator.hpp in Headers */,\n\t\t\t\t037C3B6C2897E33600328EC8 /* FrameSpec.hpp in Headers */,\n\t\t\t\t037C3B6D2897E33600328EC8 /* TokenizerConfig.hpp in Headers */,\n\t\t\t\t037C3B6E2897E33600328EC8 /* SyntaxCreateViewSTMT.hpp in Headers */,\n\t\t\t\t756F7F6A2B2CA4B5002AEA0A /* FactoryVacuum.hpp in Headers */,\n\t\t\t\t037C3B712897E33600328EC8 /* Enum.hpp in Headers */,\n\t\t\t\t037C3B732897E33600328EC8 /* SyntaxDetachSTMT.hpp in Headers */,\n\t\t\t\t037C3B742897E33600328EC8 /* ColumnType.hpp in Headers */,\n\t\t\t\t037C3B792897E33600328EC8 /* SyntaxDeleteSTMT.hpp in Headers */,\n\t\t\t\t037C3B7C2897E33600328EC8 /* StatementSavepoint.hpp in Headers */,\n\t\t\t\t7533CB5F2B050FB200C8B47D /* MigratingStatementDecorator.hpp in Headers */,\n\t\t\t\t752517932B133DB700485175 /* CompressHandleOperator.hpp in Headers */,\n\t\t\t\t037C3B7E2897E33600328EC8 /* FullCrawler.hpp in Headers */,\n\t\t\t\t75CB08D12A88B9A300429364 /* HandleCounter.hpp in Headers */,\n\t\t\t\t037C3B802897E33600328EC8 /* SQLiteAssembler.hpp in Headers */,\n\t\t\t\t03D077F328C1F611009A3B18 /* TableORMOperation.hpp in Headers */,\n\t\t\t\t037C3B842897E33600328EC8 /* StatementAttach.hpp in Headers */,\n\t\t\t\t037C3B852897E33600328EC8 /* ColumnDef.hpp in Headers */,\n\t\t\t\t037C3B892897E33600328EC8 /* Wal.hpp in Headers */,\n\t\t\t\t037C3B8A2897E33600328EC8 /* SyntaxSavepointSTMT.hpp in Headers */,\n\t\t\t\t037C3B8B2897E33600328EC8 /* AutoMigrateConfig.hpp in Headers */,\n\t\t\t\t037C3B8C2897E33600328EC8 /* UniqueList.hpp in Headers */,\n\t\t\t\t037C3B8D2897E33600328EC8 /* HandleStatement.hpp in Headers */,\n\t\t\t\t037C3B8E2897E33600328EC8 /* FTS5AuxiliaryFunctionTemplate.hpp in Headers */,\n\t\t\t\t037C3B912897E33600328EC8 /* SQLiteLocker.hpp in Headers */,\n\t\t\t\t037C3B942897E33600328EC8 /* ConvertibleImplementation.hpp in Headers */,\n\t\t\t\t037C3B952897E33600328EC8 /* RaiseFunction.hpp in Headers */,\n\t\t\t\t754014C3290BEDA600EA8D33 /* FTSConst.h in Headers */,\n\t\t\t\t75E50A0D29067BC800B73E62 /* MultiObject.hpp in Headers */,\n\t\t\t\t037C3B962897E33600328EC8 /* InnerHandle.hpp in Headers */,\n\t\t\t\t037C3B982897E33600328EC8 /* Global.hpp in Headers */,\n\t\t\t\t037C3B992897E33600328EC8 /* StatementBegin.hpp in Headers */,\n\t\t\t\t037C3B9A2897E33600328EC8 /* SyntaxQualifiedTableName.hpp in Headers */,\n\t\t\t\t037C3B9C2897E33600328EC8 /* SyntaxJoinClause.hpp in Headers */,\n\t\t\t\t75E50A2F2907921600B73E62 /* MultiSelect.hpp in Headers */,\n\t\t\t\t037C3B9F2897E33600328EC8 /* CoreFunction.hpp in Headers */,\n\t\t\t\t037C3BA32897E33600328EC8 /* Frame.hpp in Headers */,\n\t\t\t\t75B698D7290AD4C0006E1F8F /* BaseTokenizerUtil.hpp in Headers */,\n\t\t\t\t037C3BA72897E33600328EC8 /* Thread.hpp in Headers */,\n\t\t\t\t037C3BA92897E33600328EC8 /* FileHandle.hpp in Headers */,\n\t\t\t\t037C3BAA2897E33600328EC8 /* StatementDelete.hpp in Headers */,\n\t\t\t\t037C3BAC2897E33600328EC8 /* OperationQueue.hpp in Headers */,\n\t\t\t\t037C3BAE2897E33600328EC8 /* WindowDef.hpp in Headers */,\n\t\t\t\tDDADC4742949F7C20057AEDB /* Builtin.h in Headers */,\n\t\t\t\t0D5403092B160693007DF415 /* CompressingStatementDecorator.hpp in Headers */,\n\t\t\t\t754211E22B11FE9200A2FF4D /* ScalarFunctionModule.hpp in Headers */,\n\t\t\t\t037C3BB32897E33600328EC8 /* SyntaxTableOrSubquery.hpp in Headers */,\n\t\t\t\t037C3BB42897E33600328EC8 /* StatementRelease.hpp in Headers */,\n\t\t\t\t75DF229B2AEFF995006A3311 /* SharedPtrAccessor.hpp in Headers */,\n\t\t\t\t037C3BB62897E33600328EC8 /* Notifier.hpp in Headers */,\n\t\t\t\t037C3BB72897E33600328EC8 /* SyntaxCreateTriggerSTMT.hpp in Headers */,\n\t\t\t\t037C3BB82897E33600328EC8 /* SyntaxIndexedColumn.hpp in Headers */,\n\t\t\t\t037C3BB92897E33600328EC8 /* SyntaxCommonConst.hpp in Headers */,\n\t\t\t\t037C3BBA2897E33600328EC8 /* StatementUpdate.hpp in Headers */,\n\t\t\t\t037C3BBB2897E33600328EC8 /* SQLiteBase.hpp in Headers */,\n\t\t\t\t037C3BBC2897E33600328EC8 /* Expression.hpp in Headers */,\n\t\t\t\t03E3180D28A21AF800540CB1 /* CppInterface.h in Headers */,\n\t\t\t\t037C3BBF2897E33600328EC8 /* SyntaxPragmaSTMT.hpp in Headers */,\n\t\t\t\t039D724E28BF795700990803 /* Select.hpp in Headers */,\n\t\t\t\t037C3BC02897E33600328EC8 /* Upsert.hpp in Headers */,\n\t\t\t\t755B5A6929154361006955AF /* OneOrBinaryTokenizer.hpp in Headers */,\n\t\t\t\t0D36C0F82AF1E00C000BC0DD /* STDOptionalAccessor.hpp in Headers */,\n\t\t\t\t037C3BC22897E33600328EC8 /* AuxiliaryFunctionModule.hpp in Headers */,\n\t\t\t\t037C3BC42897E33600328EC8 /* Configs.hpp in Headers */,\n\t\t\t\t754211F02B12331900A2FF4D /* FunctionModules.hpp in Headers */,\n\t\t\t\t037C3BC82897E33600328EC8 /* SharedThreadedErrorProne.hpp in Headers */,\n\t\t\t\t037C3BC92897E33600328EC8 /* Range.hpp in Headers */,\n\t\t\t\t037C3BCA2897E33600328EC8 /* SyntaxResultColumn.hpp in Headers */,\n\t\t\t\t03AFD34928B8B88300EF5E56 /* CPPORM.h in Headers */,\n\t\t\t\t037C3BCB2897E33600328EC8 /* FTSError.hpp in Headers */,\n\t\t\t\t037C3BCC2897E33600328EC8 /* Mechanic.hpp in Headers */,\n\t\t\t\t037C3BCF2897E33600328EC8 /* SyntaxJoinConstraint.hpp in Headers */,\n\t\t\t\t037C3BD02897E33600328EC8 /* ErrorProne.hpp in Headers */,\n\t\t\t\t754212282B124CFF00A2FF4D /* ZSTDDict.hpp in Headers */,\n\t\t\t\t037C3BD52897E33600328EC8 /* StatementCommit.hpp in Headers */,\n\t\t\t\t75C6E415299E80D3002579A5 /* WCDBOptional.hpp in Headers */,\n\t\t\t\t75EF25062AA33FEB0009C99F /* IncrementalMaterial.hpp in Headers */,\n\t\t\t\t758D9D0628BA7F06001B3D2D /* CPPColumnConstraintMacro.h in Headers */,\n\t\t\t\t03AFD34628B8B57600EF5E56 /* Binding.hpp in Headers */,\n\t\t\t\t037C3BD62897E33600328EC8 /* SyntaxColumnDef.hpp in Headers */,\n\t\t\t\t037C3BD72897E33600328EC8 /* LRUCache.hpp in Headers */,\n\t\t\t\t037C3BD92897E33600328EC8 /* StatementVacuum.hpp in Headers */,\n\t\t\t\t037C3BDA2897E33600328EC8 /* Column.hpp in Headers */,\n\t\t\t\t75F32F1628BA066400A72697 /* CPPBindingMacro.h in Headers */,\n\t\t\t\t037C3BDC2897E33600328EC8 /* TimedQueue.hpp in Headers */,\n\t\t\t\t759362E02B36D756000AF163 /* VacuumHandleOperator.hpp in Headers */,\n\t\t\t\t037C3BDD2897E33600328EC8 /* Time.hpp in Headers */,\n\t\t\t\t037C3BDE2897E33600328EC8 /* FileManager.hpp in Headers */,\n\t\t\t\t758D9D0928BA819A001B3D2D /* CPPVirtualTableMacro.h in Headers */,\n\t\t\t\t037C3BE12897E33600328EC8 /* WCDBError.hpp in Headers */,\n\t\t\t\t037C3BE32897E33600328EC8 /* DatabasePool.hpp in Headers */,\n\t\t\t\t037C3BE42897E33600328EC8 /* SyntaxWindowDef.hpp in Headers */,\n\t\t\t\t037C3BE62897E33600328EC8 /* TableOrSubquery.hpp in Headers */,\n\t\t\t\t03321E8F28A514F5000AFD6D /* HandleOperation.hpp in Headers */,\n\t\t\t\t037C3BE82897E33600328EC8 /* Statement.hpp in Headers */,\n\t\t\t\t7543594C2B066DBD00CDF232 /* HandleOperator.hpp in Headers */,\n\t\t\t\t037C3BE92897E33600328EC8 /* ThreadLocal.hpp in Headers */,\n\t\t\t\t03AFD33A28B8A6BD00EF5E56 /* MemberPointer.hpp in Headers */,\n\t\t\t\t037C3BEA2897E33600328EC8 /* Schema.hpp in Headers */,\n\t\t\t\t037C3BED2897E33600328EC8 /* SyntaxDropIndexSTMT.hpp in Headers */,\n\t\t\t\t75F32F1928BA083E00A72697 /* CPPIndexMacro.h in Headers */,\n\t\t\t\t0DE84AD42B03295400522A4E /* FunctionContainer.hpp in Headers */,\n\t\t\t\t037C3BEE2897E33600328EC8 /* Assemble.hpp in Headers */,\n\t\t\t\t037C3BF02897E33600328EC8 /* SyntaxBindParameter.hpp in Headers */,\n\t\t\t\t752517872B1338AF00485175 /* CompressionRecord.hpp in Headers */,\n\t\t\t\t037C3BF12897E33600328EC8 /* Lock.hpp in Headers */,\n\t\t\t\t037C3BF22897E33600328EC8 /* FactoryRetriever.hpp in Headers */,\n\t\t\t\t037C3BF52897E33600328EC8 /* AutoCheckpointConfig.hpp in Headers */,\n\t\t\t\t75294DB529C75058005E7FC0 /* OperationQueueForMemory.hpp in Headers */,\n\t\t\t\t7596162328BFB05100AE86BA /* CPPDeclaration.h in Headers */,\n\t\t\t\t037C3BF92897E33600328EC8 /* SyntaxVacuumSTMT.hpp in Headers */,\n\t\t\t\t037C3BFA2897E33600328EC8 /* Material.hpp in Headers */,\n\t\t\t\t752517612B12D43700485175 /* DecompressFunction.hpp in Headers */,\n\t\t\t\t037C3BFB2897E33600328EC8 /* SyntaxInsertSTMT.hpp in Headers */,\n\t\t\t\t037C3BFC2897E33600328EC8 /* AggregateFunction.hpp in Headers */,\n\t\t\t\t03D077F628C1F951009A3B18 /* HandleORMOperation.hpp in Headers */,\n\t\t\t\t037C3BFF2897E33600328EC8 /* FactoryRenewer.hpp in Headers */,\n\t\t\t\t0D5403132B1606BC007DF415 /* CompressingHandleDecorator.hpp in Headers */,\n\t\t\t\t03AFD33428B883E700EF5E56 /* Accessor.hpp in Headers */,\n\t\t\t\t037C3C002897E33600328EC8 /* StatementAnalyze.hpp in Headers */,\n\t\t\t\t0DE84C832B03886800522A4E /* DecorativeHandleStatement.hpp in Headers */,\n\t\t\t\t037C3C022897E33600328EC8 /* FactoryBackup.hpp in Headers */,\n\t\t\t\t03733111289A94F10030C113 /* Handle.hpp in Headers */,\n\t\t\t\t037C3C042897E33600328EC8 /* CipherConfig.hpp in Headers */,\n\t\t\t\t7542122C2B124CFF00A2FF4D /* CompressionInfo.hpp in Headers */,\n\t\t\t\t037C3C052897E33600328EC8 /* SyntaxRollbackSTMT.hpp in Headers */,\n\t\t\t);\n\t\t\trunOnlyForDeploymentPostprocessing = 0;\n\t\t};\n\t\t2393265E1E836D7300D677CC /* Headers */ = {\n\t\t\tisa = PBXHeadersBuildPhase;\n\t\t\tbuildActionMask = 2147483647;\n\t\t\tfiles = (\n\t\t\t\t23B4DCE32112B03C00954D71 /* AsyncQueue.hpp in Headers */,\n\t\t\t\t23301BFB229A851800A8AB5A /* AutoBackupConfig.hpp in Headers */,\n\t\t\t\t23EEDCE7217DFADC006E9E73 /* WINQ.h in Headers */,\n\t\t\t\t23759463210081AA00DBB721 /* UnsafeData.hpp in Headers */,\n\t\t\t\t03E3180F28A21B0000540CB1 /* Handle.hpp in Headers */,\n\t\t\t\t23DF0A0E219029DB00F0B2B6 /* WCTDeclaration.h in Headers */,\n\t\t\t\t234591F6204433E200DC7D34 /* CommonCore.hpp in Headers */,\n\t\t\t\t758E7EBC2B1B24AD00319991 /* AutoCompressConfig.hpp in Headers */,\n\t\t\t\t03D077F728C1F951009A3B18 /* HandleORMOperation.hpp in Headers */,\n\t\t\t\t754211E02B11FE9200A2FF4D /* ScalarFunctionModule.hpp in Headers */,\n\t\t\t\t233A058B2062698E00F1A212 /* WCTHandle+ChainCall.h in Headers */,\n\t\t\t\t75F32F0A28B9CE8E00A72697 /* CPPORMMacro.h in Headers */,\n\t\t\t\t23EEDC9A217DFADC006E9E73 /* Pragma.hpp in Headers */,\n\t\t\t\t23AD52DF20DB56D200664B62 /* SequenceItem.hpp in Headers */,\n\t\t\t\t2316D92F21057CA700707AFC /* MappedData.hpp in Headers */,\n\t\t\t\t23EEDD32217DFADC006E9E73 /* SyntaxCommitSTMT.hpp in Headers */,\n\t\t\t\t03AFD34728B8B57600EF5E56 /* Binding.hpp in Headers */,\n\t\t\t\t7533CB682B051C4F00C8B47D /* ClassDecorator.hpp in Headers */,\n\t\t\t\t7533CB532B050FA300C8B47D /* MigratingHandleDecorator.hpp in Headers */,\n\t\t\t\t23EEDD5D217DFADC006E9E73 /* Syntax.h in Headers */,\n\t\t\t\t23EEDD2E217DFADC006E9E73 /* SyntaxAttachSTMT.hpp in Headers */,\n\t\t\t\t23EEDC80217DFADC006E9E73 /* CommonTableExpression.hpp in Headers */,\n\t\t\t\t03A15DFA28AA636A0031A50A /* ValueArray.hpp in Headers */,\n\t\t\t\t39690194233B2235006EEFD4 /* WCTTable+Table.h in Headers */,\n\t\t\t\t233A8534215E7CFE00BB8D4F /* Console.hpp in Headers */,\n\t\t\t\t2370B11F21914ED500D3227C /* NSObject+WCTColumnCoding.h in Headers */,\n\t\t\t\t39579858227FBC8A0069F985 /* WCTDatabase+Test.h in Headers */,\n\t\t\t\t391F7C84225DE8FD0095E82D /* CommonCore.h in Headers */,\n\t\t\t\t2360A5FB20D78F1B00E4A311 /* HandleNotification.hpp in Headers */,\n\t\t\t\t23EEDD36217DFADC006E9E73 /* SyntaxCreateTableSTMT.hpp in Headers */,\n\t\t\t\t23EEDD46217DFADC006E9E73 /* SyntaxDropTriggerSTMT.hpp in Headers */,\n\t\t\t\t23B4DCDC2112AC5600954D71 /* TokenizerModuleTemplate.hpp in Headers */,\n\t\t\t\t7542122A2B124CFF00A2FF4D /* CompressionInfo.hpp in Headers */,\n\t\t\t\t23EEDC6A217DFADC006E9E73 /* Convertible.hpp in Headers */,\n\t\t\t\t23AF4E2020CD04E20050033C /* Initializeable.hpp in Headers */,\n\t\t\t\t75A46C112843B73C00B58207 /* WinqBridge.hpp in Headers */,\n\t\t\t\t2316D93121057CA700707AFC /* Recyclable.hpp in Headers */,\n\t\t\t\t237C900721D45E6700EE6E44 /* CoreConst.h in Headers */,\n\t\t\t\t23775B8420AD666900E21AB0 /* Cell.hpp in Headers */,\n\t\t\t\t758E7ECD2B1B49E300319991 /* WCTDatabase+Compression.h in Headers */,\n\t\t\t\t23F70FA820A055BE00CCE3CD /* BasicConfig.hpp in Headers */,\n\t\t\t\t23EEDCCE217DFADC006E9E73 /* StatementDropIndex.hpp in Headers */,\n\t\t\t\t23775B8C20AD666900E21AB0 /* Pager.hpp in Headers */,\n\t\t\t\t23EEDD34217DFADC006E9E73 /* SyntaxCreateIndexSTMT.hpp in Headers */,\n\t\t\t\t23B101E92090667E005D9DD3 /* WCTMacroUtility.h in Headers */,\n\t\t\t\t23775B9820AD666900E21AB0 /* Crawlable.hpp in Headers */,\n\t\t\t\t23EEDC94217DFADC006E9E73 /* LiteralValue.hpp in Headers */,\n\t\t\t\t0D5363ED290A65390026A4DC /* Master.hpp in Headers */,\n\t\t\t\t23F70FD820A07CEC00CCE3CD /* CustomConfig.hpp in Headers */,\n\t\t\t\t23EEDCC2217DFADC006E9E73 /* StatementCreateTable.hpp in Headers */,\n\t\t\t\t23EEDC88217DFADC006E9E73 /* ForeignKey.hpp in Headers */,\n\t\t\t\t2372E05A21A2633800051D9A /* WCTTryDisposeGuard.h in Headers */,\n\t\t\t\t23176A8C21B912B10051ACF9 /* WCDBVersion.h in Headers */,\n\t\t\t\t03AFD34328B8B21B00EF5E56 /* Field.hpp in Headers */,\n\t\t\t\t23A3CFB5205FB1A800692F94 /* WCTHandle+Convenient.h in Headers */,\n\t\t\t\t75A60AB329345A38009C1B3C /* Cipher.hpp in Headers */,\n\t\t\t\t23EEDCD2217DFADC006E9E73 /* StatementDropTrigger.hpp in Headers */,\n\t\t\t\t75D99B8128CA441E00BEC8B5 /* BaseOperation.hpp in Headers */,\n\t\t\t\t23EEDC72217DFADC006E9E73 /* FTSFunction.hpp in Headers */,\n\t\t\t\t234DBD092064DE23000E31E8 /* WCTTransaction.h in Headers */,\n\t\t\t\t23593B7F20D3ADF80058B416 /* WalRelated.hpp in Headers */,\n\t\t\t\t23D0C36520C14ACC0001BFAE /* FactoryRelated.hpp in Headers */,\n\t\t\t\t23EEDD56217DFADC006E9E73 /* SyntaxSelectSTMT.hpp in Headers */,\n\t\t\t\t755391E12403CB9E00036918 /* WCTPreparedStatement+Private.h in Headers */,\n\t\t\t\t75F3140E2AAC067B007FFDFB /* CipherHandle.hpp in Headers */,\n\t\t\t\t2360A60920D78F2C00E4A311 /* PerformanceTraceConfig.hpp in Headers */,\n\t\t\t\t75294DB329C75058005E7FC0 /* OperationQueueForMemory.hpp in Headers */,\n\t\t\t\t237B47B121FEEA200059227A /* ColumnMeta.hpp in Headers */,\n\t\t\t\t23EABBE6206D08EC00241F3B /* WCTHandle+Table.h in Headers */,\n\t\t\t\t752CF3FA293A490F009ED8FB /* BindingBridge.h in Headers */,\n\t\t\t\t239776FE202AF2E3000A681C /* Macro.h in Headers */,\n\t\t\t\t03E3181028A21B0500540CB1 /* PreparedStatement.hpp in Headers */,\n\t\t\t\t237A8D6021EDBB2E003AF5BB /* BusyRetryConfig.hpp in Headers */,\n\t\t\t\t23A6D4C120BFD7F9004F2DAA /* Progress.hpp in Headers */,\n\t\t\t\t23EEDCFE217DFADC006E9E73 /* SyntaxForeignKeyClause.hpp in Headers */,\n\t\t\t\t23545B992224E8270091C981 /* SyntaxAssertion.hpp in Headers */,\n\t\t\t\t7533CB5D2B050FB200C8B47D /* MigratingStatementDecorator.hpp in Headers */,\n\t\t\t\t75DF229A2AEFF995006A3311 /* SharedPtrAccessor.hpp in Headers */,\n\t\t\t\t75E50A0E29067BC800B73E62 /* MultiObject.hpp in Headers */,\n\t\t\t\t752517912B133DB700485175 /* CompressHandleOperator.hpp in Headers */,\n\t\t\t\t23EEDD1E217DFADC006E9E73 /* SyntaxSelectCore.hpp in Headers */,\n\t\t\t\t23EEDD20217DFADC006E9E73 /* SyntaxTableConstraint.hpp in Headers */,\n\t\t\t\t752517852B1338AF00485175 /* CompressionRecord.hpp in Headers */,\n\t\t\t\t23F1698A20B6638F009B5C47 /* ThreadedErrors.hpp in Headers */,\n\t\t\t\t0D5403072B160693007DF415 /* CompressingStatementDecorator.hpp in Headers */,\n\t\t\t\t759362DE2B36D756000AF163 /* VacuumHandleOperator.hpp in Headers */,\n\t\t\t\t23EEDCA8217DFADC006E9E73 /* TableConstraint.hpp in Headers */,\n\t\t\t\t7543DD8F271C360E00B533B4 /* AuxiliaryFunctionConfig.hpp in Headers */,\n\t\t\t\t23EEDCA6217DFADC006E9E73 /* SQL.hpp in Headers */,\n\t\t\t\t23D07CEC20BE873E0043F4D4 /* SequenceCrawler.hpp in Headers */,\n\t\t\t\t2316D9452105D19500707AFC /* PageBasedFileHandle.hpp in Headers */,\n\t\t\t\t2360A60520D78F2C00E4A311 /* SQLTraceConfig.hpp in Headers */,\n\t\t\t\t23775BCF20AD72BC00E21AB0 /* Data.hpp in Headers */,\n\t\t\t\t23DF0A0B2190275B00F0B2B6 /* WCTDatabase.h in Headers */,\n\t\t\t\t23775B6020AD666900E21AB0 /* Assertion.hpp in Headers */,\n\t\t\t\t23906AB9215E500100C2B717 /* WCTDatabase+Monitor.h in Headers */,\n\t\t\t\t7543594A2B066DBD00CDF232 /* HandleOperator.hpp in Headers */,\n\t\t\t\t23EEDC86217DFADC006E9E73 /* Filter.hpp in Headers */,\n\t\t\t\t23EEDD48217DFADC006E9E73 /* SyntaxDropViewSTMT.hpp in Headers */,\n\t\t\t\t0DD8D11B2B074C47002C97D3 /* MigrateHandleOperator.hpp in Headers */,\n\t\t\t\t2376CB1D20DA5D3B00A68DB5 /* Scoreable.hpp in Headers */,\n\t\t\t\t39411A4122437E7B00A388F5 /* CaseInsensitiveList.hpp in Headers */,\n\t\t\t\t03AFD33B28B8A6BD00EF5E56 /* MemberPointer.hpp in Headers */,\n\t\t\t\t23EEDC73217DFADC006E9E73 /* SyntaxForwardDeclaration.h in Headers */,\n\t\t\t\t23BBE2AD2049565600C4CBB6 /* WCTDatabase+Config.h in Headers */,\n\t\t\t\t2308F8A820E37FB1001CD9C3 /* WCTDatabase+Repair.h in Headers */,\n\t\t\t\t23A64D0B214A458A00ED28BB /* MigrationInfo.hpp in Headers */,\n\t\t\t\t032E113628C88C3D00BCACE0 /* RunTimeAccessor.hpp in Headers */,\n\t\t\t\t23EEDCC0217DFADC006E9E73 /* StatementCreateIndex.hpp in Headers */,\n\t\t\t\t236BACE621BF9FC900C8B4D9 /* WCTMigrationInfo.h in Headers */,\n\t\t\t\t03D077F428C1F611009A3B18 /* TableORMOperation.hpp in Headers */,\n\t\t\t\t23D4DA452085A40A00AE6D90 /* Interface.h in Headers */,\n\t\t\t\t758E7ECA2B1B423200319991 /* WCTCompressionInfo+Private.h in Headers */,\n\t\t\t\t235EE9C522B6321A008F6658 /* StringView.hpp in Headers */,\n\t\t\t\t23B9E66B20AE6EEA00CF1683 /* RepairKit.h in Headers */,\n\t\t\t\t23F340DA204D32C3007DB8AB /* WCTTable.h in Headers */,\n\t\t\t\t23EEDC98217DFADC006E9E73 /* OrderingTerm.hpp in Headers */,\n\t\t\t\t0D4FE5EF29482F4D0061C3CA /* Builtin.h in Headers */,\n\t\t\t\t23EEDD24217DFADC006E9E73 /* SyntaxUpsertClause.hpp in Headers */,\n\t\t\t\t23408F11211897AA0071E5A7 /* Shm.hpp in Headers */,\n\t\t\t\t23EEDCCC217DFADC006E9E73 /* StatementDetach.hpp in Headers */,\n\t\t\t\t7596162428BFB05100AE86BA /* CPPDeclaration.h in Headers */,\n\t\t\t\t754359542B0671DE00CDF232 /* BackupHandleOperator.hpp in Headers */,\n\t\t\t\t0DE84AD22B03295400522A4E /* FunctionContainer.hpp in Headers */,\n\t\t\t\t7543DD93271C601F00B533B4 /* SubstringMatchInfo.hpp in Headers */,\n\t\t\t\t23EEDD30217DFADC006E9E73 /* SyntaxBeginSTMT.hpp in Headers */,\n\t\t\t\t0D5403112B1606BC007DF415 /* CompressingHandleDecorator.hpp in Headers */,\n\t\t\t\t23EEDD58217DFADC006E9E73 /* SyntaxUpdateSTMT.hpp in Headers */,\n\t\t\t\t23EEDCA2217DFADC006E9E73 /* ResultColumn.hpp in Headers */,\n\t\t\t\t23EEDCC4217DFADC006E9E73 /* StatementCreateTrigger.hpp in Headers */,\n\t\t\t\t23EE0EB420B838E100C95998 /* Repairman.hpp in Headers */,\n\t\t\t\t23EEDC70217DFADC006E9E73 /* ExpressionOperable.hpp in Headers */,\n\t\t\t\t2360A5FD20D78F1B00E4A311 /* HandleRelated.hpp in Headers */,\n\t\t\t\t23EEDD10217DFADC006E9E73 /* SyntaxOrderingTerm.hpp in Headers */,\n\t\t\t\t039D724F28BF795700990803 /* Select.hpp in Headers */,\n\t\t\t\t23F70F7B209FF0EC00CCE3CD /* WCTValue.h in Headers */,\n\t\t\t\t23DF0A0C2190275B00F0B2B6 /* WCTDatabase+Private.h in Headers */,\n\t\t\t\t758D9D0A28BA819A001B3D2D /* CPPVirtualTableMacro.h in Headers */,\n\t\t\t\t234DBCF82064DD0C000E31E8 /* WCTHandle.h in Headers */,\n\t\t\t\t23EEDD2A217DFADC006E9E73 /* SyntaxAlterTableSTMT.hpp in Headers */,\n\t\t\t\t03450DBA2738DDE800C4DC1B /* OneOrBinaryTokenizer.hpp in Headers */,\n\t\t\t\t23EEDC8E217DFADC006E9E73 /* IndexedColumn.hpp in Headers */,\n\t\t\t\t03321E8A28A503F3000AFD6D /* StatementOperation.hpp in Headers */,\n\t\t\t\t23176A9B21BA7D460051ACF9 /* WCTDatabase+Version.h in Headers */,\n\t\t\t\t2304B42A22156CD700901953 /* TokenizerModule.hpp in Headers */,\n\t\t\t\t2347379021CBB3A800AD5E41 /* AbstractHandle.hpp in Headers */,\n\t\t\t\t23D0C35320C149D80001BFAE /* Factory.hpp in Headers */,\n\t\t\t\t23FEC463206B3032001E7A3B /* WCTConvenient.h in Headers */,\n\t\t\t\t23EEDD00217DFADC006E9E73 /* SyntaxFrameSpec.hpp in Headers */,\n\t\t\t\t75DF22962AEE8409006A3311 /* CPPInheritObject.hpp in Headers */,\n\t\t\t\t23B35C7620BFE39500425033 /* Path.hpp in Headers */,\n\t\t\t\t23A64D11214A4A7000ED28BB /* Migration.hpp in Headers */,\n\t\t\t\t75F32F1A28BA083E00A72697 /* CPPIndexMacro.h in Headers */,\n\t\t\t\t0DCD2AC72C6E210700C247EC /* AutoVacuumConfig.hpp in Headers */,\n\t\t\t\t23EEDD16217DFADC006E9E73 /* SyntaxRaiseFunction.hpp in Headers */,\n\t\t\t\t23EEDCE2217DFADC006E9E73 /* StatementSelect.hpp in Headers */,\n\t\t\t\t23EEDD44217DFADC006E9E73 /* SyntaxDropTableSTMT.hpp in Headers */,\n\t\t\t\t23F340DE204D3482007DB8AB /* WCTDatabase+ChainCall.h in Headers */,\n\t\t\t\t3960D89C2319258B00EF05D1 /* SyntaxExplainSTMT.hpp in Headers */,\n\t\t\t\t23EEDCD4217DFADC006E9E73 /* StatementDropView.hpp in Headers */,\n\t\t\t\t3960D8A02319288C00EF05D1 /* StatementExplain.hpp in Headers */,\n\t\t\t\t0D4F0F952AC5728A0067027E /* WCTPerformanceInfo.h in Headers */,\n\t\t\t\t23775B7820AD666900E21AB0 /* Backup.hpp in Headers */,\n\t\t\t\t23AD52D820DB4A3C00664B62 /* MasterItem.hpp in Headers */,\n\t\t\t\t03E3181128A21B0A00540CB1 /* Database.hpp in Headers */,\n\t\t\t\t23EEDC78217DFADC006E9E73 /* BindParameter.hpp in Headers */,\n\t\t\t\t23EEDC90217DFADC006E9E73 /* Join.hpp in Headers */,\n\t\t\t\t23E7EB1F2123D58D0056B5D8 /* HighWater.hpp in Headers */,\n\t\t\t\t756F7F682B2CA4B5002AEA0A /* FactoryVacuum.hpp in Headers */,\n\t\t\t\t23EEDD04217DFADC006E9E73 /* SyntaxIdentifier.hpp in Headers */,\n\t\t\t\t23AD52E820DB852B00664B62 /* Fraction.hpp in Headers */,\n\t\t\t\t23EEDCD0217DFADC006E9E73 /* StatementDropTable.hpp in Headers */,\n\t\t\t\t23EEDCFA217DFADC006E9E73 /* SyntaxExpression.hpp in Headers */,\n\t\t\t\t23D07CE620BE87360043F4D4 /* MasterCrawler.hpp in Headers */,\n\t\t\t\t23790A7F219315E50098797F /* WCTColumnConstraintMacro.h in Headers */,\n\t\t\t\t2304B43022156E1500901953 /* TokenizerModules.hpp in Headers */,\n\t\t\t\t23EEDC9C217DFADC006E9E73 /* QualifiedTable.hpp in Headers */,\n\t\t\t\t0D3AE53825416D99007B9D0E /* AutoMergeFTSIndexConfig.hpp in Headers */,\n\t\t\t\t231C35EF21DE09EC00B5D3D2 /* Exiting.hpp in Headers */,\n\t\t\t\t23F70FA220A055B400CCE3CD /* Config.hpp in Headers */,\n\t\t\t\t234DBCF32064DD0C000E31E8 /* WCTDatabase+Handle.h in Headers */,\n\t\t\t\t2349F76A1EA0D6680021EFA7 /* WCTMacro.h in Headers */,\n\t\t\t\t23775B8820AD666900E21AB0 /* Page.hpp in Headers */,\n\t\t\t\t23EEDCFC217DFADC006E9E73 /* SyntaxFilter.hpp in Headers */,\n\t\t\t\t23EEDCDE217DFADC006E9E73 /* StatementRollback.hpp in Headers */,\n\t\t\t\t23EEDCB6217DFADC006E9E73 /* StatementAlterTable.hpp in Headers */,\n\t\t\t\t23EEDCD8217DFADC006E9E73 /* StatementPragma.hpp in Headers */,\n\t\t\t\t2349F7081EA0D6680021EFA7 /* RecyclableHandle.hpp in Headers */,\n\t\t\t\t23EEDD1C217DFADC006E9E73 /* SyntaxSchema.hpp in Headers */,\n\t\t\t\t75F32F2B28BA31CD00A72697 /* ResultField.hpp in Headers */,\n\t\t\t\t2349F7311EA0D6680021EFA7 /* WCTTable+ChainCall.h in Headers */,\n\t\t\t\t23EEDD0C217DFADC006E9E73 /* SyntaxLiteralValue.hpp in Headers */,\n\t\t\t\t0D5363F3290A75F20026A4DC /* Sequence.hpp in Headers */,\n\t\t\t\t23EEDCDA217DFADC006E9E73 /* StatementReindex.hpp in Headers */,\n\t\t\t\t23EEDC74217DFADC006E9E73 /* SyntaxList.hpp in Headers */,\n\t\t\t\t754211EE2B12331900A2FF4D /* FunctionModules.hpp in Headers */,\n\t\t\t\t75ADC5682A8D1C2D00D0AC47 /* TableAttribute.hpp in Headers */,\n\t\t\t\t2349F76C1EA0D6680021EFA7 /* WCTTableConstraintMacro.h in Headers */,\n\t\t\t\t23EEDC7C217DFADC006E9E73 /* ColumnConstraint.hpp in Headers */,\n\t\t\t\t237A8D5821ED88DF003AF5BB /* SQLiteDeclaration.h in Headers */,\n\t\t\t\t23545B9F2224E9C80091C981 /* SyntaxEnum.hpp in Headers */,\n\t\t\t\t0DC98FD528E46049007F3796 /* DBOperationNotifier.hpp in Headers */,\n\t\t\t\t23EEDCC6217DFADC006E9E73 /* StatementCreateView.hpp in Headers */,\n\t\t\t\t23EEDD3C217DFADC006E9E73 /* SyntaxCreateVirtualTableSTMT.hpp in Headers */,\n\t\t\t\t23EEDD61217DFB17006E9E73 /* Shadow.hpp in Headers */,\n\t\t\t\t75E0A5D82A7FE2A200D4FE9A /* ContainerBridge.h in Headers */,\n\t\t\t\t2349F7651EA0D6680021EFA7 /* WCTTableCoding.h in Headers */,\n\t\t\t\t03AFD33528B883E700EF5E56 /* Accessor.hpp in Headers */,\n\t\t\t\t0DE84C812B03886800522A4E /* DecorativeHandleStatement.hpp in Headers */,\n\t\t\t\t2349F7231EA0D6680021EFA7 /* WCTInsert.h in Headers */,\n\t\t\t\t23EEDC92217DFADC006E9E73 /* JoinConstraint.hpp in Headers */,\n\t\t\t\t23EEDD50217DFADC006E9E73 /* SyntaxReleaseSTMT.hpp in Headers */,\n\t\t\t\t2308F85520E32A51001CD9C3 /* Serialization.hpp in Headers */,\n\t\t\t\t2349F76D1EA0D6680021EFA7 /* WCTIndexMacro.h in Headers */,\n\t\t\t\t39A3341922B0DD9F008EA5D5 /* WCTFoundation.h in Headers */,\n\t\t\t\t0D19BA232B07481B0028F92B /* IntegerityHandleOperator.hpp in Headers */,\n\t\t\t\t23EEDCF0217DFADC006E9E73 /* SyntaxColumn.hpp in Headers */,\n\t\t\t\t2349F6FF1EA0D6680021EFA7 /* InnerDatabase.hpp in Headers */,\n\t\t\t\t75D567012951B90E00098DD9 /* WCTSequence+WCTTableCoding.h in Headers */,\n\t\t\t\t0D8BC3082B99B3C000DE9AE5 /* WCDBBridging.h in Headers */,\n\t\t\t\t3969018C233B1B2F006EEFD4 /* WCTTag.h in Headers */,\n\t\t\t\t039D724B28BF773D00990803 /* Delete.hpp in Headers */,\n\t\t\t\t0D249BC12542B8E900B43BD9 /* MergeFTSIndexLogic.hpp in Headers */,\n\t\t\t\t23EEDD2C217DFADC006E9E73 /* SyntaxAnalyzeSTMT.hpp in Headers */,\n\t\t\t\t23EEDCF2217DFADC006E9E73 /* SyntaxColumnConstraint.hpp in Headers */,\n\t\t\t\t7521D39528BD1187009C33D0 /* ChainCall.hpp in Headers */,\n\t\t\t\t7500829329223463009C0F38 /* WCTBridgeMacro.h in Headers */,\n\t\t\t\t23790A80219315E50098797F /* WCTVirtualTableMacro.h in Headers */,\n\t\t\t\t2386B3C71ED442FE000B72F6 /* WCTError+Private.h in Headers */,\n\t\t\t\t23EEDD4E217DFADC006E9E73 /* SyntaxReindexSTMT.hpp in Headers */,\n\t\t\t\t23EEDCF6217DFADC006E9E73 /* SyntaxCommonTableExpression.hpp in Headers */,\n\t\t\t\t23AD52F420DBAC4C00664B62 /* UpgradeableErrorProne.hpp in Headers */,\n\t\t\t\t2349F7201EA0D6680021EFA7 /* WCTDelete.h in Headers */,\n\t\t\t\t23567D5B20CA823C005F1C35 /* PagerRelated.hpp in Headers */,\n\t\t\t\t2349F75F1EA0D6680021EFA7 /* WCTColumnBinding.h in Headers */,\n\t\t\t\t03F428EC28BF686F005CE249 /* Update.hpp in Headers */,\n\t\t\t\t23B4DC802111B39200954D71 /* Tag.hpp in Headers */,\n\t\t\t\t23AB898E215BA81300554DF1 /* SQLite.h in Headers */,\n\t\t\t\t0D3281632B04A8E60027B973 /* DecorativeHandle.hpp in Headers */,\n\t\t\t\t23EEDD12217DFADC006E9E73 /* SyntaxPragma.hpp in Headers */,\n\t\t\t\t2349F75D1EA0D6680021EFA7 /* WCTBinding.h in Headers */,\n\t\t\t\t236BACE221BF9F6400C8B4D9 /* WCTDatabase+Migration.h in Headers */,\n\t\t\t\t2349F7361EA0D6680021EFA7 /* WCTDatabase+Convenient.h in Headers */,\n\t\t\t\t0DAE11D528DC6D85003FB63A /* WCDBCpp.h in Headers */,\n\t\t\t\t2349F72C1EA0D6680021EFA7 /* WCTSelect.h in Headers */,\n\t\t\t\t23EEDCC8217DFADC006E9E73 /* StatementCreateVirtualTable.hpp in Headers */,\n\t\t\t\t234F0338227A950900DD65A2 /* SQLiteFTS3Tokenizer.h in Headers */,\n\t\t\t\t2349F7341EA0D6680021EFA7 /* WCTUpdate.h in Headers */,\n\t\t\t\t2349F7061EA0D6680021EFA7 /* HandlePool.hpp in Headers */,\n\t\t\t\t23EEDCD6217DFADC006E9E73 /* StatementInsert.hpp in Headers */,\n\t\t\t\t23D0C35720C149D80001BFAE /* FactoryDepositor.hpp in Headers */,\n\t\t\t\t03E3180E28A21AF800540CB1 /* CppInterface.h in Headers */,\n\t\t\t\t23EEDC8A217DFADC006E9E73 /* FrameSpec.hpp in Headers */,\n\t\t\t\t23F70FC020A055D400CCE3CD /* TokenizerConfig.hpp in Headers */,\n\t\t\t\t23EEDD3A217DFADC006E9E73 /* SyntaxCreateViewSTMT.hpp in Headers */,\n\t\t\t\t2370B12421914ED500D3227C /* NSNumber+WCTColumnCoding.h in Headers */,\n\t\t\t\t753636DF28BBC3820025C2C4 /* Table.hpp in Headers */,\n\t\t\t\t2349F78E1EA0D6680021EFA7 /* WCDBObjc.h in Headers */,\n\t\t\t\t23EEDD60217DFB17006E9E73 /* Enum.hpp in Headers */,\n\t\t\t\t0D36C0F72AF1E00C000BC0DD /* STDOptionalAccessor.hpp in Headers */,\n\t\t\t\t23EEDD40217DFADC006E9E73 /* SyntaxDetachSTMT.hpp in Headers */,\n\t\t\t\t23EEDC69217DFADC006E9E73 /* ColumnType.hpp in Headers */,\n\t\t\t\t2370B1322191533C00D3227C /* WCTOptional.h in Headers */,\n\t\t\t\t2349F7271EA0D6680021EFA7 /* WCTMultiSelect.h in Headers */,\n\t\t\t\t23EEDD3E217DFADC006E9E73 /* SyntaxDeleteSTMT.hpp in Headers */,\n\t\t\t\t2395582621C143BB000C85E1 /* WCTMigrationInfo+Private.h in Headers */,\n\t\t\t\t75E50A302907921600B73E62 /* MultiSelect.hpp in Headers */,\n\t\t\t\t23EEDCE0217DFADC006E9E73 /* StatementSavepoint.hpp in Headers */,\n\t\t\t\t75F32F1028B9F90900A72697 /* FTSTokenizerUtil.hpp in Headers */,\n\t\t\t\t75F32F1728BA066400A72697 /* CPPBindingMacro.h in Headers */,\n\t\t\t\t23775B6C20AD666900E21AB0 /* FullCrawler.hpp in Headers */,\n\t\t\t\t754212032B123E3200A2FF4D /* ScalarFunctionTemplate.hpp in Headers */,\n\t\t\t\t2349F7701EA0D6680021EFA7 /* WCTDatabase+Table.h in Headers */,\n\t\t\t\t23D0C31020C125420001BFAE /* SQLiteAssembler.hpp in Headers */,\n\t\t\t\t2349F72F1EA0D6680021EFA7 /* WCTSelectable.h in Headers */,\n\t\t\t\t2349F75B1EA0D6680021EFA7 /* WCTRuntimeObjCAccessor.h in Headers */,\n\t\t\t\t03450DB92738C8F800C4DC1B /* PinyinTokenizer.hpp in Headers */,\n\t\t\t\t23EEDCBA217DFADC006E9E73 /* StatementAttach.hpp in Headers */,\n\t\t\t\t754212262B124CFF00A2FF4D /* ZSTDDict.hpp in Headers */,\n\t\t\t\t23EEDC7E217DFADC006E9E73 /* ColumnDef.hpp in Headers */,\n\t\t\t\t2349F75A1EA0D6680021EFA7 /* WCTRuntimeCppAccessor.h in Headers */,\n\t\t\t\t39690190233B20BC006EEFD4 /* WCTTableProtocol.h in Headers */,\n\t\t\t\t23EB91E020CA1EBE00ECF668 /* Wal.hpp in Headers */,\n\t\t\t\t23EEDD54217DFADC006E9E73 /* SyntaxSavepointSTMT.hpp in Headers */,\n\t\t\t\t23301BF72298FE9A00A8AB5A /* AutoMigrateConfig.hpp in Headers */,\n\t\t\t\t758D9D0428BA7265001B3D2D /* CPPTableConstraintMacro.h in Headers */,\n\t\t\t\t237A65F520F731DF008B4771 /* UniqueList.hpp in Headers */,\n\t\t\t\t2370980B20590CA700E768B4 /* HandleStatement.hpp in Headers */,\n\t\t\t\t7543DD83271C2F3B00B533B4 /* FTS5AuxiliaryFunctionTemplate.hpp in Headers */,\n\t\t\t\t75EF25042AA33FEB0009C99F /* IncrementalMaterial.hpp in Headers */,\n\t\t\t\t23BBE2A8204955CE00C4CBB6 /* WCTCommon.h in Headers */,\n\t\t\t\t23C7559320DCF90F00031A93 /* SQLiteLocker.hpp in Headers */,\n\t\t\t\t2370B12721914ED500D3227C /* NSData+WCTColumnCoding.h in Headers */,\n\t\t\t\t2349F7381EA0D6680021EFA7 /* WCTTable+Convenient.h in Headers */,\n\t\t\t\t23EEDC6C217DFADC006E9E73 /* ConvertibleImplementation.hpp in Headers */,\n\t\t\t\t03E5CC7128A3BDF3005353D9 /* Value.hpp in Headers */,\n\t\t\t\t23EEDC9E217DFADC006E9E73 /* RaiseFunction.hpp in Headers */,\n\t\t\t\t39B524DD2304F9A2001DF52D /* InnerHandle.hpp in Headers */,\n\t\t\t\t23577F791F74F4E800D31C05 /* WCTFTSTokenizerUtil.h in Headers */,\n\t\t\t\t235FBE9722914E0D005C7723 /* Global.hpp in Headers */,\n\t\t\t\t23EEDCBC217DFADC006E9E73 /* StatementBegin.hpp in Headers */,\n\t\t\t\t23EEDD14217DFADC006E9E73 /* SyntaxQualifiedTableName.hpp in Headers */,\n\t\t\t\t2349F7551EA0D6680021EFA7 /* WCTBaseAccessor.h in Headers */,\n\t\t\t\t23EEDD08217DFADC006E9E73 /* SyntaxJoinClause.hpp in Headers */,\n\t\t\t\t03E167B827F46C7100D2C926 /* ObjectBridge.h in Headers */,\n\t\t\t\t75EB1A14287F10BF00AA62F7 /* StatementCreateTriggerBridge.h in Headers */,\n\t\t\t\t75AF6AF22855C8BF00A7C43D /* UpsertBridge.h in Headers */,\n\t\t\t\t752594E6285226C00068A602 /* FrameSpecBridge.h in Headers */,\n\t\t\t\t75AF6AFB2856303700A7C43D /* PragmaBridge.h in Headers */,\n\t\t\t\t75CE3EFE2812D95100E132F6 /* WCTAPIBridge.h in Headers */,\n\t\t\t\t754212222B124CFF00A2FF4D /* CompressionCenter.hpp in Headers */,\n\t\t\t\t03EE3DAB288165A700C8F0B3 /* StatementInsertBridge.h in Headers */,\n\t\t\t\t75AF6ADC2854C5ED00A7C43D /* JoinBridge.h in Headers */,\n\t\t\t\t759362D32B36D450000AF163 /* Vacuum.hpp in Headers */,\n\t\t\t\t03E822922844E1AB0072CA57 /* RaiseFunctionBridge.h in Headers */,\n\t\t\t\t757821E2286DF5EB0092F858 /* StatementCreateTableBridge.h in Headers */,\n\t\t\t\t75F4DE482884032600760DC3 /* StatementRollbackBridge.h in Headers */,\n\t\t\t\t03BFC5D82853538400673AE4 /* IndexedColumnBridge.h in Headers */,\n\t\t\t\t756A774027FAC18000105B7C /* CoreBridge.h in Headers */,\n\t\t\t\t03DCB5EF286C3D8E00CBC75D /* StatementAttachBridge.h in Headers */,\n\t\t\t\t75AF6AD828544C8800A7C43D /* TableOrSubqueryBridge.h in Headers */,\n\t\t\t\t75F4DE602884149100760DC3 /* StatementCommitBridge.h in Headers */,\n\t\t\t\t75AF6AE02854EF6D00A7C43D /* QualifiedTableBridge.h in Headers */,\n\t\t\t\t756A773827F9EDCA00105B7C /* HandleStatementBridge.h in Headers */,\n\t\t\t\t036E50B728115AB8007365CD /* WCTBridgeProperty.h in Headers */,\n\t\t\t\t75AF6AEE28559F4800A7C43D /* TableConstraintBridge.h in Headers */,\n\t\t\t\t75F4DE382883E88100760DC3 /* StatementPragmaBridge.h in Headers */,\n\t\t\t\t03F54821287D8467007BCA3E /* StatementDetachBridge.h in Headers */,\n\t\t\t\t75F4DE5628840C4800760DC3 /* StatementBeginBridge.h in Headers */,\n\t\t\t\t75F1A3072871DE9A008503A2 /* StatementCreateVirtualTableBridge.h in Headers */,\n\t\t\t\t03DCB5F3286C480900CBC75D /* StatementCreateIndexBridge.h in Headers */,\n\t\t\t\t03F54825287D87F9007BCA3E /* StatementDropIndexBridge.h in Headers */,\n\t\t\t\t75F4DE52288407F800760DC3 /* StatementVacuumBridge.h in Headers */,\n\t\t\t\t036E50BB28115BA0007365CD /* WCTBridgeProperty+CPP.h in Headers */,\n\t\t\t\t0326130F283F573C00836E0F /* WinqBridge.h in Headers */,\n\t\t\t\t75EB196F287F093B00AA62F7 /* StatementDropViewBridge.h in Headers */,\n\t\t\t\t03E822892844B8CD0072CA57 /* StatementSelectBridge.h in Headers */,\n\t\t\t\t03A57F1D2840B5DC00D2A4C3 /* BindParameterBridge.h in Headers */,\n\t\t\t\t75EB1966287F068200AA62F7 /* StatementDropTriggerBridge.h in Headers */,\n\t\t\t\t0393BEDC27F6ED860058B295 /* ErrorBridge.h in Headers */,\n\t\t\t\t03E8228128447B940072CA57 /* ColumnDefBridge.h in Headers */,\n\t\t\t\t75F4DE442883FD6A00760DC3 /* StatementReleaseBridge.h in Headers */,\n\t\t\t\t75EB1A0B287F0BDA00AA62F7 /* StatementCreateViewBridge.h in Headers */,\n\t\t\t\t032613B7283F8D7E00836E0F /* ColumnBridge.h in Headers */,\n\t\t\t\t75A46C0E2843B3BC00B58207 /* OrderingTermBridge.h in Headers */,\n\t\t\t\t03B6A33D2869C51B00D83EC4 /* StatementAlterTableBridge.h in Headers */,\n\t\t\t\t0393BEE427F715180058B295 /* HandleBridge.h in Headers */,\n\t\t\t\t75204AEC283FD7410002E40C /* SchemaBridge.h in Headers */,\n\t\t\t\t752517702B12FDC700485175 /* ZSTDContext.hpp in Headers */,\n\t\t\t\t0D36C0FD2AF1F0B6000BC0DD /* WCDBOptionalAccessor.hpp in Headers */,\n\t\t\t\t75C1034328450D840006BBCB /* WindowDefBridge.h in Headers */,\n\t\t\t\t0D19BA0F2B0702250028F92B /* AssembleHandleOperator.hpp in Headers */,\n\t\t\t\t750DC06E2913DE7300F19044 /* FTSBridge.h in Headers */,\n\t\t\t\t032613BB283F8E4900836E0F /* ExpressionBridge.h in Headers */,\n\t\t\t\t75F4DE342883E43C00760DC3 /* StatementExplainBridge.h in Headers */,\n\t\t\t\t752517662B12F13C00485175 /* CompressionConst.hpp in Headers */,\n\t\t\t\t75A46C01284310CE00B58207 /* ColumnConstraintBridge.h in Headers */,\n\t\t\t\t039760AB27F5C0DD0071FA8F /* DatabaseBridge.h in Headers */,\n\t\t\t\t03F54829287D93A7007BCA3E /* StatementDropTableBridge.h in Headers */,\n\t\t\t\t039BD4372846113D00C58BE2 /* ExpressionOperatableBridge.h in Headers */,\n\t\t\t\t75F4DE402883F0A800760DC3 /* StatementReindexBridge.h in Headers */,\n\t\t\t\t75F4DE4C288405DD00760DC3 /* StatementSavepointBridge.h in Headers */,\n\t\t\t\t758E7EC72B1B41C500319991 /* WCTCompressionInfo.h in Headers */,\n\t\t\t\t03E822852844B8760072CA57 /* CommonTableExpressionBridge.h in Headers */,\n\t\t\t\t03DCB5E7286C2E5300CBC75D /* StatementAnalyzeBridge.h in Headers */,\n\t\t\t\t75A46C0528431D6300B58207 /* ForeignKeyBridge.h in Headers */,\n\t\t\t\t75AF6AEA285594A100A7C43D /* ResultColumnBridge.h in Headers */,\n\t\t\t\t0326130E283F56BD00836E0F /* LiteralValueBridge.h in Headers */,\n\t\t\t\t75F1A30B2871E764008503A2 /* StatementDeleteBridge.h in Headers */,\n\t\t\t\t03EE3DAF28816DA800C8F0B3 /* StatementUpdateBridge.h in Headers */,\n\t\t\t\t2370B11D21914ED500D3227C /* NSString+WCTColumnCoding.h in Headers */,\n\t\t\t\t2349F7571EA0D6680021EFA7 /* WCTObjCAccessor.h in Headers */,\n\t\t\t\t23EEDC6E217DFADC006E9E73 /* CoreFunction.hpp in Headers */,\n\t\t\t\t23567CFC20CA3889005F1C35 /* Frame.hpp in Headers */,\n\t\t\t\t754014C4290BEDA600EA8D33 /* FTSConst.h in Headers */,\n\t\t\t\t23776CA7218C41E600E985DC /* WCTChainCall+Private.h in Headers */,\n\t\t\t\t758D9D0728BA7F06001B3D2D /* CPPColumnConstraintMacro.h in Headers */,\n\t\t\t\t2349F7681EA0D6680021EFA7 /* WCTProperty.h in Headers */,\n\t\t\t\t390E1C5E2296414C00C24598 /* Thread.hpp in Headers */,\n\t\t\t\t2349F7561EA0D6680021EFA7 /* WCTCppAccessor.h in Headers */,\n\t\t\t\t7537E5D428B939240077D92B /* BaseBinding.hpp in Headers */,\n\t\t\t\t2308F85120E32A51001CD9C3 /* FileHandle.hpp in Headers */,\n\t\t\t\t75EF250E2AA42DD90009C99F /* EncryptedSerialization.hpp in Headers */,\n\t\t\t\t03AFD34A28B8B88300EF5E56 /* CPPORM.h in Headers */,\n\t\t\t\t23EEDCCA217DFADC006E9E73 /* StatementDelete.hpp in Headers */,\n\t\t\t\t03D077F128C1F072009A3B18 /* TableOperation.hpp in Headers */,\n\t\t\t\t3934DAED229B6659008A6AEC /* OperationQueue.hpp in Headers */,\n\t\t\t\t23EEDCAE217DFADC006E9E73 /* WindowDef.hpp in Headers */,\n\t\t\t\t232741501F6FBD50004E96F7 /* WCTDatabase+FTS.h in Headers */,\n\t\t\t\t03E167BA27F46E2E00D2C926 /* ObjectBridge.hpp in Headers */,\n\t\t\t\t2349F76B1EA0D6680021EFA7 /* WCTPropertyMacro.h in Headers */,\n\t\t\t\t23EEDD22217DFADC006E9E73 /* SyntaxTableOrSubquery.hpp in Headers */,\n\t\t\t\t23EEDCDC217DFADC006E9E73 /* StatementRelease.hpp in Headers */,\n\t\t\t\t2349F76F1EA0D6680021EFA7 /* WCTORM.h in Headers */,\n\t\t\t\t23775B6820AD666900E21AB0 /* Notifier.hpp in Headers */,\n\t\t\t\t23EEDD38217DFADC006E9E73 /* SyntaxCreateTriggerSTMT.hpp in Headers */,\n\t\t\t\t23EEDD06217DFADC006E9E73 /* SyntaxIndexedColumn.hpp in Headers */,\n\t\t\t\t238C177E21CA2190003B6D26 /* SyntaxCommonConst.hpp in Headers */,\n\t\t\t\t23EEDCE4217DFADC006E9E73 /* StatementUpdate.hpp in Headers */,\n\t\t\t\t23C7559C20DD17B100031A93 /* SQLiteBase.hpp in Headers */,\n\t\t\t\t23EEDC84217DFADC006E9E73 /* Expression.hpp in Headers */,\n\t\t\t\t2349F7481EA0D6680021EFA7 /* WCTDatabase+File.h in Headers */,\n\t\t\t\t23EEDD4C217DFADC006E9E73 /* SyntaxPragmaSTMT.hpp in Headers */,\n\t\t\t\t23EEDCAC217DFADC006E9E73 /* Upsert.hpp in Headers */,\n\t\t\t\t7542122E2B124CFF00A2FF4D /* Compression.hpp in Headers */,\n\t\t\t\t7543DD87271C2FD000B533B4 /* AuxiliaryFunctionModule.hpp in Headers */,\n\t\t\t\t234DBD0D2064E045000E31E8 /* WCTChainCall.h in Headers */,\n\t\t\t\t75B698D8290AD4C0006E1F8F /* BaseTokenizerUtil.hpp in Headers */,\n\t\t\t\t23F70FC620A0618100CCE3CD /* Configs.hpp in Headers */,\n\t\t\t\t233A25D3219933DB00054EC4 /* WCTBuiltin.h in Headers */,\n\t\t\t\t23BBE2B12049576D00C4CBB6 /* WCTDatabase+Memory.h in Headers */,\n\t\t\t\t23567D7720CA9200005F1C35 /* SharedThreadedErrorProne.hpp in Headers */,\n\t\t\t\t2314AE7321070A1700244D39 /* Range.hpp in Headers */,\n\t\t\t\t23EEDD1A217DFADC006E9E73 /* SyntaxResultColumn.hpp in Headers */,\n\t\t\t\t03EA88CE27D5F05D0075C7BD /* FTSError.hpp in Headers */,\n\t\t\t\t23775B8020AD666900E21AB0 /* Mechanic.hpp in Headers */,\n\t\t\t\t2370B12321914ED500D3227C /* WCTMaster+WCTTableCoding.h in Headers */,\n\t\t\t\t03321E9028A514F5000AFD6D /* HandleOperation.hpp in Headers */,\n\t\t\t\t757457042402D614005E3682 /* WCTPreparedStatement.h in Headers */,\n\t\t\t\t75F32F1428BA039D00A72697 /* CPPFieldMacro.h in Headers */,\n\t\t\t\t23EEDD0A217DFADC006E9E73 /* SyntaxJoinConstraint.hpp in Headers */,\n\t\t\t\t23567D4720CA7DBC005F1C35 /* ErrorProne.hpp in Headers */,\n\t\t\t\t2349F7581EA0D6680021EFA7 /* WCTRuntimeBaseAccessor.h in Headers */,\n\t\t\t\t23EEDCBE217DFADC006E9E73 /* StatementCommit.hpp in Headers */,\n\t\t\t\t23EEDCF4217DFADC006E9E73 /* SyntaxColumnDef.hpp in Headers */,\n\t\t\t\t2316D94B2105D21500707AFC /* LRUCache.hpp in Headers */,\n\t\t\t\t75CB08CF2A88B9A300429364 /* HandleCounter.hpp in Headers */,\n\t\t\t\t234DBCF72064DD0C000E31E8 /* WCTHandle+Private.h in Headers */,\n\t\t\t\t0D8084212A861E8500C81BBF /* WCTCancellationSignal.h in Headers */,\n\t\t\t\t23EEDCE6217DFADC006E9E73 /* StatementVacuum.hpp in Headers */,\n\t\t\t\t754211F92B12359400A2FF4D /* ScalarFunctionConfig.hpp in Headers */,\n\t\t\t\t23EEDC7A217DFADC006E9E73 /* Column.hpp in Headers */,\n\t\t\t\t2370B12A21914ED500D3227C /* NSNull+WCTColumnCoding.h in Headers */,\n\t\t\t\t239776FA202AF2E3000A681C /* TimedQueue.hpp in Headers */,\n\t\t\t\t75FFD33128BE5BB70051DB07 /* Insert.hpp in Headers */,\n\t\t\t\t23567D7D20CA93C5005F1C35 /* Time.hpp in Headers */,\n\t\t\t\t23B9E67520AE733B00CF1683 /* FileManager.hpp in Headers */,\n\t\t\t\t234EF46E2015CFDE00B81929 /* WCTConvertible.h in Headers */,\n\t\t\t\t2349F7741EA0D6680021EFA7 /* WCTTable+Private.h in Headers */,\n\t\t\t\t23775B6420AD666900E21AB0 /* WCDBError.hpp in Headers */,\n\t\t\t\t23D96B932050DED700DB5E93 /* DatabasePool.hpp in Headers */,\n\t\t\t\t23EEDD26217DFADC006E9E73 /* SyntaxWindowDef.hpp in Headers */,\n\t\t\t\t2370B12221914ED500D3227C /* WCTMaster.h in Headers */,\n\t\t\t\t75C6E413299E80D3002579A5 /* WCDBOptional.hpp in Headers */,\n\t\t\t\t23EEDCAA217DFADC006E9E73 /* TableOrSubquery.hpp in Headers */,\n\t\t\t\t2370B12121914ED500D3227C /* NSDate+WCTColumnCoding.h in Headers */,\n\t\t\t\t23EEDCB4217DFADC006E9E73 /* Statement.hpp in Headers */,\n\t\t\t\t23F0FEB6215F5E9A008399FB /* ThreadLocal.hpp in Headers */,\n\t\t\t\t23EEDCA4217DFADC006E9E73 /* Schema.hpp in Headers */,\n\t\t\t\t23EEDD42217DFADC006E9E73 /* SyntaxDropIndexSTMT.hpp in Headers */,\n\t\t\t\t39C70CC82313E20F002D773C /* Assemble.hpp in Headers */,\n\t\t\t\t234DBD032064DE04000E31E8 /* WCTDatabase+Transaction.h in Headers */,\n\t\t\t\t23EEDCEE217DFADC006E9E73 /* SyntaxBindParameter.hpp in Headers */,\n\t\t\t\t23F0FEB5215F5E9A008399FB /* Lock.hpp in Headers */,\n\t\t\t\t23D0C35F20C149D80001BFAE /* FactoryRetriever.hpp in Headers */,\n\t\t\t\t2396EB0D21801BD60079066C /* WCTResultColumn.h in Headers */,\n\t\t\t\t234DBD052064DE04000E31E8 /* WCTHandle+Transaction.h in Headers */,\n\t\t\t\t3934DB26229B951C008A6AEC /* AutoCheckpointConfig.hpp in Headers */,\n\t\t\t\t3932B9FD25232E490094F3F8 /* WCTColumnCoding.h in Headers */,\n\t\t\t\t23EEDD5A217DFADC006E9E73 /* SyntaxVacuumSTMT.hpp in Headers */,\n\t\t\t\t0D3FFA462A2F2911002DF7CD /* SysTypes.h in Headers */,\n\t\t\t\t23775B7C20AD666900E21AB0 /* Material.hpp in Headers */,\n\t\t\t\t23EEDD4A217DFADC006E9E73 /* SyntaxInsertSTMT.hpp in Headers */,\n\t\t\t\t23EEDC67217DFADC006E9E73 /* AggregateFunction.hpp in Headers */,\n\t\t\t\t7525175F2B12D43700485175 /* DecompressFunction.hpp in Headers */,\n\t\t\t\t2386B3C51ED442FE000B72F6 /* WCTError.h in Headers */,\n\t\t\t\t2349F72E1EA0D6680021EFA7 /* WCTSelectable+Private.h in Headers */,\n\t\t\t\t75D566FB2951B7DE00098DD9 /* WCTSequence.h in Headers */,\n\t\t\t\t23DD76BF20CF78C800E9B451 /* FactoryRenewer.hpp in Headers */,\n\t\t\t\t23EEDCB8217DFADC006E9E73 /* StatementAnalyze.hpp in Headers */,\n\t\t\t\t23D0C38F20C17CAE0001BFAE /* FactoryBackup.hpp in Headers */,\n\t\t\t\t23F70FAE20A055C300CCE3CD /* CipherConfig.hpp in Headers */,\n\t\t\t\t23EEDD52217DFADC006E9E73 /* SyntaxRollbackSTMT.hpp in Headers */,\n\t\t\t\t0DAE11D428DC6CC6003FB63A /* WCDB.h in Headers */,\n\t\t\t);\n\t\t\trunOnlyForDeploymentPostprocessing = 0;\n\t\t};\n\t\t7521D892291E9ABB009642EF /* Headers */ = {\n\t\t\tisa = PBXHeadersBuildPhase;\n\t\t\tbuildActionMask = 2147483647;\n\t\t\tfiles = (\n\t\t\t\t7521D893291E9ABB009642EF /* AsyncQueue.hpp in Headers */,\n\t\t\t\t7521D894291E9ABB009642EF /* AutoBackupConfig.hpp in Headers */,\n\t\t\t\t752517922B133DB700485175 /* CompressHandleOperator.hpp in Headers */,\n\t\t\t\t7521D895291E9ABB009642EF /* WINQ.h in Headers */,\n\t\t\t\t7521D896291E9ABB009642EF /* UnsafeData.hpp in Headers */,\n\t\t\t\t7521D898291E9ABB009642EF /* WCTDeclaration.h in Headers */,\n\t\t\t\t7521D899291E9ABB009642EF /* CommonCore.hpp in Headers */,\n\t\t\t\t7521D89C291E9ABB009642EF /* WCTHandle+ChainCall.h in Headers */,\n\t\t\t\t7521D89E291E9ABB009642EF /* Pragma.hpp in Headers */,\n\t\t\t\t7521D89F291E9ABB009642EF /* SequenceItem.hpp in Headers */,\n\t\t\t\t7521D8A0291E9ABB009642EF /* MappedData.hpp in Headers */,\n\t\t\t\t7521D8A1291E9ABB009642EF /* SyntaxCommitSTMT.hpp in Headers */,\n\t\t\t\t7521D8A3291E9ABB009642EF /* Syntax.h in Headers */,\n\t\t\t\t7521D8A4291E9ABB009642EF /* SyntaxAttachSTMT.hpp in Headers */,\n\t\t\t\t7521D8A5291E9ABB009642EF /* CommonTableExpression.hpp in Headers */,\n\t\t\t\t7521D8A6291E9ABB009642EF /* ValueArray.hpp in Headers */,\n\t\t\t\t7521D8A7291E9ABB009642EF /* WCTTable+Table.h in Headers */,\n\t\t\t\t7521D8A8291E9ABB009642EF /* Console.hpp in Headers */,\n\t\t\t\t7521D8A9291E9ABB009642EF /* NSObject+WCTColumnCoding.h in Headers */,\n\t\t\t\t7521D8AA291E9ABB009642EF /* WCTDatabase+Test.h in Headers */,\n\t\t\t\t7521D8AB291E9ABB009642EF /* CommonCore.h in Headers */,\n\t\t\t\t7521D8AC291E9ABB009642EF /* HandleNotification.hpp in Headers */,\n\t\t\t\t7521D8AD291E9ABB009642EF /* SyntaxCreateTableSTMT.hpp in Headers */,\n\t\t\t\t7521D8AE291E9ABB009642EF /* SyntaxDropTriggerSTMT.hpp in Headers */,\n\t\t\t\t7521D8AF291E9ABB009642EF /* TokenizerModuleTemplate.hpp in Headers */,\n\t\t\t\t7521D8B0291E9ABB009642EF /* Convertible.hpp in Headers */,\n\t\t\t\t7521D8B1291E9ABB009642EF /* Initializeable.hpp in Headers */,\n\t\t\t\t7521D8B3291E9ABB009642EF /* Recyclable.hpp in Headers */,\n\t\t\t\t7521D8B4291E9ABB009642EF /* CoreConst.h in Headers */,\n\t\t\t\t7521D8B5291E9ABB009642EF /* Cell.hpp in Headers */,\n\t\t\t\t0D3345A52BB40C7F004C84C5 /* WCTBridgeProperty.h in Headers */,\n\t\t\t\t7521D8B7291E9ABB009642EF /* BasicConfig.hpp in Headers */,\n\t\t\t\t7521D8B8291E9ABB009642EF /* StatementDropIndex.hpp in Headers */,\n\t\t\t\t7521D8B9291E9ABB009642EF /* Pager.hpp in Headers */,\n\t\t\t\t75A60AB429345A38009C1B3C /* Cipher.hpp in Headers */,\n\t\t\t\t7521D8BA291E9ABB009642EF /* SyntaxCreateIndexSTMT.hpp in Headers */,\n\t\t\t\t7521D8BB291E9ABB009642EF /* WCTMacroUtility.h in Headers */,\n\t\t\t\t7521D8BC291E9ABB009642EF /* Crawlable.hpp in Headers */,\n\t\t\t\t7521D8BD291E9ABB009642EF /* LiteralValue.hpp in Headers */,\n\t\t\t\t7521D8BF291E9ABB009642EF /* CustomConfig.hpp in Headers */,\n\t\t\t\t7521D8C0291E9ABB009642EF /* StatementCreateTable.hpp in Headers */,\n\t\t\t\t754212042B123E3200A2FF4D /* ScalarFunctionTemplate.hpp in Headers */,\n\t\t\t\t7521D8C1291E9ABB009642EF /* ForeignKey.hpp in Headers */,\n\t\t\t\t7521D8C2291E9ABB009642EF /* WCTTryDisposeGuard.h in Headers */,\n\t\t\t\t0D3345912BB3FE2B004C84C5 /* WCTBridgeProperty+CPP.h in Headers */,\n\t\t\t\t7521D8C3291E9ABB009642EF /* WCDBVersion.h in Headers */,\n\t\t\t\t756F7F692B2CA4B5002AEA0A /* FactoryVacuum.hpp in Headers */,\n\t\t\t\t7521D8C5291E9ABB009642EF /* WCTHandle+Convenient.h in Headers */,\n\t\t\t\t758E7ECB2B1B423200319991 /* WCTCompressionInfo+Private.h in Headers */,\n\t\t\t\t7521D8C6291E9ABB009642EF /* StatementDropTrigger.hpp in Headers */,\n\t\t\t\t7521D8C8291E9ABB009642EF /* FTSFunction.hpp in Headers */,\n\t\t\t\t7521D8C9291E9ABB009642EF /* WCTTransaction.h in Headers */,\n\t\t\t\t7521D8CA291E9ABB009642EF /* WalRelated.hpp in Headers */,\n\t\t\t\t7521D8CB291E9ABB009642EF /* FactoryRelated.hpp in Headers */,\n\t\t\t\t7521D8CC291E9ABB009642EF /* SyntaxSelectSTMT.hpp in Headers */,\n\t\t\t\t7521D8CD291E9ABB009642EF /* WCTPreparedStatement+Private.h in Headers */,\n\t\t\t\t0D19BA242B07481B0028F92B /* IntegerityHandleOperator.hpp in Headers */,\n\t\t\t\t75D566FC2951B7DE00098DD9 /* WCTSequence.h in Headers */,\n\t\t\t\t7521D8CE291E9ABB009642EF /* PerformanceTraceConfig.hpp in Headers */,\n\t\t\t\t7543594B2B066DBD00CDF232 /* HandleOperator.hpp in Headers */,\n\t\t\t\t7521D8CF291E9ABB009642EF /* ColumnMeta.hpp in Headers */,\n\t\t\t\t7521D8D0291E9ABB009642EF /* WCTHandle+Table.h in Headers */,\n\t\t\t\t7521D8D1291E9ABB009642EF /* Macro.h in Headers */,\n\t\t\t\t7521D8D3291E9ABB009642EF /* BusyRetryConfig.hpp in Headers */,\n\t\t\t\t7521D8D4291E9ABB009642EF /* Progress.hpp in Headers */,\n\t\t\t\t7521D8D5291E9ABB009642EF /* SyntaxForeignKeyClause.hpp in Headers */,\n\t\t\t\t7521D8D6291E9ABB009642EF /* SyntaxAssertion.hpp in Headers */,\n\t\t\t\t754212272B124CFF00A2FF4D /* ZSTDDict.hpp in Headers */,\n\t\t\t\t7521D8D8291E9ABB009642EF /* SyntaxSelectCore.hpp in Headers */,\n\t\t\t\t7521D8D9291E9ABB009642EF /* SyntaxTableConstraint.hpp in Headers */,\n\t\t\t\t7521D8DA291E9ABB009642EF /* ThreadedErrors.hpp in Headers */,\n\t\t\t\t7521D8DB291E9ABB009642EF /* TableConstraint.hpp in Headers */,\n\t\t\t\t7521D8DC291E9ABB009642EF /* AuxiliaryFunctionConfig.hpp in Headers */,\n\t\t\t\t7521D8DD291E9ABB009642EF /* SQL.hpp in Headers */,\n\t\t\t\t7521D8DF291E9ABB009642EF /* SequenceCrawler.hpp in Headers */,\n\t\t\t\t7521D8E0291E9ABB009642EF /* PageBasedFileHandle.hpp in Headers */,\n\t\t\t\t7521D8E1291E9ABB009642EF /* SQLTraceConfig.hpp in Headers */,\n\t\t\t\t7521D8E2291E9ABB009642EF /* Data.hpp in Headers */,\n\t\t\t\t7521D8E3291E9ABB009642EF /* WCTDatabase.h in Headers */,\n\t\t\t\t754211EF2B12331900A2FF4D /* FunctionModules.hpp in Headers */,\n\t\t\t\t7521D8E4291E9ABB009642EF /* Assertion.hpp in Headers */,\n\t\t\t\t7521D8E5291E9ABB009642EF /* WCTDatabase+Monitor.h in Headers */,\n\t\t\t\t7521D8E6291E9ABB009642EF /* Filter.hpp in Headers */,\n\t\t\t\t7521D8E7291E9ABB009642EF /* SyntaxDropViewSTMT.hpp in Headers */,\n\t\t\t\t7521D8E8291E9ABB009642EF /* Scoreable.hpp in Headers */,\n\t\t\t\t7521D8E9291E9ABB009642EF /* CaseInsensitiveList.hpp in Headers */,\n\t\t\t\t7521D8EB291E9ABB009642EF /* SyntaxForwardDeclaration.h in Headers */,\n\t\t\t\t754359552B0671DE00CDF232 /* BackupHandleOperator.hpp in Headers */,\n\t\t\t\t7521D8EC291E9ABB009642EF /* WCTDatabase+Config.h in Headers */,\n\t\t\t\t0D8084222A861E8500C81BBF /* WCTCancellationSignal.h in Headers */,\n\t\t\t\t7521D8ED291E9ABB009642EF /* WCTDatabase+Repair.h in Headers */,\n\t\t\t\t7521D8EE291E9ABB009642EF /* MigrationInfo.hpp in Headers */,\n\t\t\t\t7521D8F0291E9ABB009642EF /* StatementCreateIndex.hpp in Headers */,\n\t\t\t\t7521D8F1291E9ABB009642EF /* WCTMigrationInfo.h in Headers */,\n\t\t\t\t7521D8F3291E9ABB009642EF /* Interface.h in Headers */,\n\t\t\t\t7521D8F4291E9ABB009642EF /* StringView.hpp in Headers */,\n\t\t\t\t7521D8F5291E9ABB009642EF /* RepairKit.h in Headers */,\n\t\t\t\t7521D8F6291E9ABB009642EF /* WCTTable.h in Headers */,\n\t\t\t\t754211FA2B12359400A2FF4D /* ScalarFunctionConfig.hpp in Headers */,\n\t\t\t\t7521D8F7291E9ABB009642EF /* OrderingTerm.hpp in Headers */,\n\t\t\t\t7521D8F8291E9ABB009642EF /* SyntaxUpsertClause.hpp in Headers */,\n\t\t\t\t7521D8F9291E9ABB009642EF /* Shm.hpp in Headers */,\n\t\t\t\t752517602B12D43700485175 /* DecompressFunction.hpp in Headers */,\n\t\t\t\t7521D8FA291E9ABB009642EF /* StatementDetach.hpp in Headers */,\n\t\t\t\t754211E12B11FE9200A2FF4D /* ScalarFunctionModule.hpp in Headers */,\n\t\t\t\t7521D8FC291E9ABB009642EF /* SubstringMatchInfo.hpp in Headers */,\n\t\t\t\t7521D8FD291E9ABB009642EF /* SyntaxBeginSTMT.hpp in Headers */,\n\t\t\t\t7521D8FE291E9ABB009642EF /* SyntaxUpdateSTMT.hpp in Headers */,\n\t\t\t\t75EF25052AA33FEB0009C99F /* IncrementalMaterial.hpp in Headers */,\n\t\t\t\t7521D8FF291E9ABB009642EF /* ResultColumn.hpp in Headers */,\n\t\t\t\t7521D900291E9ABB009642EF /* StatementCreateTrigger.hpp in Headers */,\n\t\t\t\t7521D901291E9ABB009642EF /* Repairman.hpp in Headers */,\n\t\t\t\t7521D902291E9ABB009642EF /* ExpressionOperable.hpp in Headers */,\n\t\t\t\t7521D903291E9ABB009642EF /* HandleRelated.hpp in Headers */,\n\t\t\t\t7521D904291E9ABB009642EF /* SyntaxOrderingTerm.hpp in Headers */,\n\t\t\t\t7521D906291E9ABB009642EF /* WCTValue.h in Headers */,\n\t\t\t\t7533CB5E2B050FB200C8B47D /* MigratingStatementDecorator.hpp in Headers */,\n\t\t\t\t7521D907291E9ABB009642EF /* WCTDatabase+Private.h in Headers */,\n\t\t\t\t7521D909291E9ABB009642EF /* WCTHandle.h in Headers */,\n\t\t\t\t7521D90A291E9ABB009642EF /* SyntaxAlterTableSTMT.hpp in Headers */,\n\t\t\t\t7521D90B291E9ABB009642EF /* OneOrBinaryTokenizer.hpp in Headers */,\n\t\t\t\t7521D90C291E9ABB009642EF /* IndexedColumn.hpp in Headers */,\n\t\t\t\t758E7EC82B1B41C500319991 /* WCTCompressionInfo.h in Headers */,\n\t\t\t\t7521D90E291E9ABB009642EF /* WCTDatabase+Version.h in Headers */,\n\t\t\t\t7521D90F291E9ABB009642EF /* TokenizerModule.hpp in Headers */,\n\t\t\t\t7521D910291E9ABB009642EF /* AbstractHandle.hpp in Headers */,\n\t\t\t\t7521D911291E9ABB009642EF /* Factory.hpp in Headers */,\n\t\t\t\t759362DF2B36D756000AF163 /* VacuumHandleOperator.hpp in Headers */,\n\t\t\t\t7521D912291E9ABB009642EF /* WCTConvenient.h in Headers */,\n\t\t\t\t7521D913291E9ABB009642EF /* SyntaxFrameSpec.hpp in Headers */,\n\t\t\t\t7521D914291E9ABB009642EF /* Path.hpp in Headers */,\n\t\t\t\t7521D915291E9ABB009642EF /* Migration.hpp in Headers */,\n\t\t\t\t7521D917291E9ABB009642EF /* SyntaxRaiseFunction.hpp in Headers */,\n\t\t\t\t7521D918291E9ABB009642EF /* StatementSelect.hpp in Headers */,\n\t\t\t\t7521D919291E9ABB009642EF /* SyntaxDropTableSTMT.hpp in Headers */,\n\t\t\t\t7521D91A291E9ABB009642EF /* WCTDatabase+ChainCall.h in Headers */,\n\t\t\t\t7521D91B291E9ABB009642EF /* SyntaxExplainSTMT.hpp in Headers */,\n\t\t\t\t7521D91C291E9ABB009642EF /* StatementDropView.hpp in Headers */,\n\t\t\t\t7521D91D291E9ABB009642EF /* StatementExplain.hpp in Headers */,\n\t\t\t\t7521D91E291E9ABB009642EF /* Backup.hpp in Headers */,\n\t\t\t\t7521D91F291E9ABB009642EF /* MasterItem.hpp in Headers */,\n\t\t\t\t7521D921291E9ABB009642EF /* BindParameter.hpp in Headers */,\n\t\t\t\t7521D922291E9ABB009642EF /* Join.hpp in Headers */,\n\t\t\t\t7521D923291E9ABB009642EF /* HighWater.hpp in Headers */,\n\t\t\t\t7521D924291E9ABB009642EF /* SyntaxIdentifier.hpp in Headers */,\n\t\t\t\t7521D925291E9ABB009642EF /* Fraction.hpp in Headers */,\n\t\t\t\t754212232B124CFF00A2FF4D /* CompressionCenter.hpp in Headers */,\n\t\t\t\t7521D926291E9ABB009642EF /* StatementDropTable.hpp in Headers */,\n\t\t\t\t7521D927291E9ABB009642EF /* SyntaxExpression.hpp in Headers */,\n\t\t\t\t7521D928291E9ABB009642EF /* MasterCrawler.hpp in Headers */,\n\t\t\t\t7521D929291E9ABB009642EF /* WCTColumnConstraintMacro.h in Headers */,\n\t\t\t\t7521D92A291E9ABB009642EF /* TokenizerModules.hpp in Headers */,\n\t\t\t\t7521D92B291E9ABB009642EF /* QualifiedTable.hpp in Headers */,\n\t\t\t\t7521D92C291E9ABB009642EF /* AutoMergeFTSIndexConfig.hpp in Headers */,\n\t\t\t\t7521D92D291E9ABB009642EF /* Exiting.hpp in Headers */,\n\t\t\t\t7521D92E291E9ABB009642EF /* Config.hpp in Headers */,\n\t\t\t\t7521D92F291E9ABB009642EF /* WCTDatabase+Handle.h in Headers */,\n\t\t\t\t7521D930291E9ABB009642EF /* WCTMacro.h in Headers */,\n\t\t\t\t7521D931291E9ABB009642EF /* Page.hpp in Headers */,\n\t\t\t\t7521D932291E9ABB009642EF /* SyntaxFilter.hpp in Headers */,\n\t\t\t\t758E7EBD2B1B24AD00319991 /* AutoCompressConfig.hpp in Headers */,\n\t\t\t\t7521D933291E9ABB009642EF /* StatementRollback.hpp in Headers */,\n\t\t\t\t7521D934291E9ABB009642EF /* StatementAlterTable.hpp in Headers */,\n\t\t\t\t7521D935291E9ABB009642EF /* StatementPragma.hpp in Headers */,\n\t\t\t\t7521D936291E9ABB009642EF /* RecyclableHandle.hpp in Headers */,\n\t\t\t\t7521D937291E9ABB009642EF /* SyntaxSchema.hpp in Headers */,\n\t\t\t\t7521D939291E9ABB009642EF /* WCTTable+ChainCall.h in Headers */,\n\t\t\t\t7521D93A291E9ABB009642EF /* SyntaxLiteralValue.hpp in Headers */,\n\t\t\t\t7521D93C291E9ABB009642EF /* StatementReindex.hpp in Headers */,\n\t\t\t\t7521D93D291E9ABB009642EF /* SyntaxList.hpp in Headers */,\n\t\t\t\t752517862B1338AF00485175 /* CompressionRecord.hpp in Headers */,\n\t\t\t\t7521D93E291E9ABB009642EF /* WCTTableConstraintMacro.h in Headers */,\n\t\t\t\t7533CB542B050FA300C8B47D /* MigratingHandleDecorator.hpp in Headers */,\n\t\t\t\t7521D940291E9ABB009642EF /* ColumnConstraint.hpp in Headers */,\n\t\t\t\t7521D941291E9ABB009642EF /* SQLiteDeclaration.h in Headers */,\n\t\t\t\t7521D942291E9ABB009642EF /* SyntaxEnum.hpp in Headers */,\n\t\t\t\t7521D943291E9ABB009642EF /* DBOperationNotifier.hpp in Headers */,\n\t\t\t\t0DE84C822B03886800522A4E /* DecorativeHandleStatement.hpp in Headers */,\n\t\t\t\t7521D944291E9ABB009642EF /* StatementCreateView.hpp in Headers */,\n\t\t\t\t7521D945291E9ABB009642EF /* SyntaxCreateVirtualTableSTMT.hpp in Headers */,\n\t\t\t\t7521D946291E9ABB009642EF /* Shadow.hpp in Headers */,\n\t\t\t\t7521D947291E9ABB009642EF /* WCTTableCoding.h in Headers */,\n\t\t\t\t7521D949291E9ABB009642EF /* WCTInsert.h in Headers */,\n\t\t\t\t7521D94A291E9ABB009642EF /* JoinConstraint.hpp in Headers */,\n\t\t\t\t7521D94B291E9ABB009642EF /* SyntaxReleaseSTMT.hpp in Headers */,\n\t\t\t\t7521D94C291E9ABB009642EF /* Serialization.hpp in Headers */,\n\t\t\t\t7521D94D291E9ABB009642EF /* WCTIndexMacro.h in Headers */,\n\t\t\t\t7521D94E291E9ABB009642EF /* WCTFoundation.h in Headers */,\n\t\t\t\t7521D94F291E9ABB009642EF /* SyntaxColumn.hpp in Headers */,\n\t\t\t\t7521D950291E9ABB009642EF /* InnerDatabase.hpp in Headers */,\n\t\t\t\t759362D42B36D450000AF163 /* Vacuum.hpp in Headers */,\n\t\t\t\t7521D951291E9ABB009642EF /* WCTTag.h in Headers */,\n\t\t\t\t7521D953291E9ABB009642EF /* MergeFTSIndexLogic.hpp in Headers */,\n\t\t\t\t7521D954291E9ABB009642EF /* SyntaxAnalyzeSTMT.hpp in Headers */,\n\t\t\t\t7521D955291E9ABB009642EF /* SyntaxColumnConstraint.hpp in Headers */,\n\t\t\t\t7521D958291E9ABB009642EF /* WCTVirtualTableMacro.h in Headers */,\n\t\t\t\t7521D959291E9ABB009642EF /* WCTError+Private.h in Headers */,\n\t\t\t\t7521D95A291E9ABB009642EF /* SyntaxReindexSTMT.hpp in Headers */,\n\t\t\t\t7521D95B291E9ABB009642EF /* SyntaxCommonTableExpression.hpp in Headers */,\n\t\t\t\t7521D95C291E9ABB009642EF /* UpgradeableErrorProne.hpp in Headers */,\n\t\t\t\t7521D95D291E9ABB009642EF /* WCTDelete.h in Headers */,\n\t\t\t\t7542122F2B124CFF00A2FF4D /* Compression.hpp in Headers */,\n\t\t\t\t75D567022951B90F00098DD9 /* WCTSequence+WCTTableCoding.h in Headers */,\n\t\t\t\t7521D95E291E9ABB009642EF /* PagerRelated.hpp in Headers */,\n\t\t\t\t7521D95F291E9ABB009642EF /* WCTColumnBinding.h in Headers */,\n\t\t\t\t0D3FFA472A2F2911002DF7CD /* SysTypes.h in Headers */,\n\t\t\t\t7521D961291E9ABB009642EF /* Tag.hpp in Headers */,\n\t\t\t\t7521D962291E9ABB009642EF /* SQLite.h in Headers */,\n\t\t\t\t752517712B12FDC700485175 /* ZSTDContext.hpp in Headers */,\n\t\t\t\t7521D963291E9ABB009642EF /* SyntaxPragma.hpp in Headers */,\n\t\t\t\t7521D964291E9ABB009642EF /* WCTBinding.h in Headers */,\n\t\t\t\t0D4F0F962AC5728A0067027E /* WCTPerformanceInfo.h in Headers */,\n\t\t\t\t7521D965291E9ABB009642EF /* WCTDatabase+Migration.h in Headers */,\n\t\t\t\t7521D966291E9ABB009642EF /* WCTDatabase+Convenient.h in Headers */,\n\t\t\t\t7521D968291E9ABB009642EF /* WCTSelect.h in Headers */,\n\t\t\t\t75294DB429C75058005E7FC0 /* OperationQueueForMemory.hpp in Headers */,\n\t\t\t\t7521D969291E9ABB009642EF /* StatementCreateVirtualTable.hpp in Headers */,\n\t\t\t\t7521D96A291E9ABB009642EF /* SQLiteFTS3Tokenizer.h in Headers */,\n\t\t\t\t7521D96B291E9ABB009642EF /* WCTUpdate.h in Headers */,\n\t\t\t\t7521D96C291E9ABB009642EF /* HandlePool.hpp in Headers */,\n\t\t\t\t7521D96D291E9ABB009642EF /* StatementInsert.hpp in Headers */,\n\t\t\t\t7521D96E291E9ABB009642EF /* FactoryDepositor.hpp in Headers */,\n\t\t\t\t7521D970291E9ABB009642EF /* FrameSpec.hpp in Headers */,\n\t\t\t\t7521D971291E9ABB009642EF /* TokenizerConfig.hpp in Headers */,\n\t\t\t\t7521D972291E9ABB009642EF /* SyntaxCreateViewSTMT.hpp in Headers */,\n\t\t\t\t7521D973291E9ABB009642EF /* NSNumber+WCTColumnCoding.h in Headers */,\n\t\t\t\t7521D975291E9ABB009642EF /* WCDBObjc.h in Headers */,\n\t\t\t\t7521D976291E9ABB009642EF /* Enum.hpp in Headers */,\n\t\t\t\t7521D977291E9ABB009642EF /* SyntaxDetachSTMT.hpp in Headers */,\n\t\t\t\t7521D978291E9ABB009642EF /* ColumnType.hpp in Headers */,\n\t\t\t\t7521D979291E9ABB009642EF /* WCTOptional.h in Headers */,\n\t\t\t\t7521D97A291E9ABB009642EF /* WCTMultiSelect.h in Headers */,\n\t\t\t\t7521D97B291E9ABB009642EF /* SyntaxDeleteSTMT.hpp in Headers */,\n\t\t\t\t7521D97C291E9ABB009642EF /* WCTMigrationInfo+Private.h in Headers */,\n\t\t\t\t7521D97E291E9ABB009642EF /* StatementSavepoint.hpp in Headers */,\n\t\t\t\t0DE84AD32B03295400522A4E /* FunctionContainer.hpp in Headers */,\n\t\t\t\t0D3281642B04A8E60027B973 /* DecorativeHandle.hpp in Headers */,\n\t\t\t\t7521D982291E9ABB009642EF /* FullCrawler.hpp in Headers */,\n\t\t\t\t7521D983291E9ABB009642EF /* WCTDatabase+Table.h in Headers */,\n\t\t\t\t7521D984291E9ABB009642EF /* SQLiteAssembler.hpp in Headers */,\n\t\t\t\t7521D985291E9ABB009642EF /* WCTSelectable.h in Headers */,\n\t\t\t\t7521D986291E9ABB009642EF /* WCTRuntimeObjCAccessor.h in Headers */,\n\t\t\t\t7521D987291E9ABB009642EF /* PinyinTokenizer.hpp in Headers */,\n\t\t\t\t7521D988291E9ABB009642EF /* StatementAttach.hpp in Headers */,\n\t\t\t\t75ADC5692A8D1C2D00D0AC47 /* TableAttribute.hpp in Headers */,\n\t\t\t\t7521D989291E9ABB009642EF /* ColumnDef.hpp in Headers */,\n\t\t\t\t7521D98A291E9ABB009642EF /* WCTRuntimeCppAccessor.h in Headers */,\n\t\t\t\t7521D98B291E9ABB009642EF /* WCTTableProtocol.h in Headers */,\n\t\t\t\t7521D98C291E9ABB009642EF /* Wal.hpp in Headers */,\n\t\t\t\t7521D98D291E9ABB009642EF /* SyntaxSavepointSTMT.hpp in Headers */,\n\t\t\t\t7521D98E291E9ABB009642EF /* AutoMigrateConfig.hpp in Headers */,\n\t\t\t\t7521D990291E9ABB009642EF /* UniqueList.hpp in Headers */,\n\t\t\t\t7542122B2B124CFF00A2FF4D /* CompressionInfo.hpp in Headers */,\n\t\t\t\t7521D991291E9ABB009642EF /* HandleStatement.hpp in Headers */,\n\t\t\t\t7521D992291E9ABB009642EF /* FTS5AuxiliaryFunctionTemplate.hpp in Headers */,\n\t\t\t\t7521D993291E9ABB009642EF /* WCTCommon.h in Headers */,\n\t\t\t\t7521D994291E9ABB009642EF /* SQLiteLocker.hpp in Headers */,\n\t\t\t\t7521D995291E9ABB009642EF /* NSData+WCTColumnCoding.h in Headers */,\n\t\t\t\t7521D996291E9ABB009642EF /* WCTTable+Convenient.h in Headers */,\n\t\t\t\t7521D997291E9ABB009642EF /* ConvertibleImplementation.hpp in Headers */,\n\t\t\t\t7521D998291E9ABB009642EF /* Value.hpp in Headers */,\n\t\t\t\t7521D999291E9ABB009642EF /* RaiseFunction.hpp in Headers */,\n\t\t\t\t7521D99A291E9ABB009642EF /* InnerHandle.hpp in Headers */,\n\t\t\t\t7521D99B291E9ABB009642EF /* WCTFTSTokenizerUtil.h in Headers */,\n\t\t\t\t7521D99C291E9ABB009642EF /* Global.hpp in Headers */,\n\t\t\t\t7521D99D291E9ABB009642EF /* StatementBegin.hpp in Headers */,\n\t\t\t\t7521D99E291E9ABB009642EF /* SyntaxQualifiedTableName.hpp in Headers */,\n\t\t\t\t7521D99F291E9ABB009642EF /* WCTBaseAccessor.h in Headers */,\n\t\t\t\t7521D9A0291E9ABB009642EF /* SyntaxJoinClause.hpp in Headers */,\n\t\t\t\t7521D9DE291E9ABB009642EF /* NSString+WCTColumnCoding.h in Headers */,\n\t\t\t\t7521D9DF291E9ABB009642EF /* WCTObjCAccessor.h in Headers */,\n\t\t\t\t7521D9E0291E9ABB009642EF /* CoreFunction.hpp in Headers */,\n\t\t\t\t7521D9E1291E9ABB009642EF /* Frame.hpp in Headers */,\n\t\t\t\t0D5403082B160693007DF415 /* CompressingStatementDecorator.hpp in Headers */,\n\t\t\t\t7521D9E2291E9ABB009642EF /* FTSConst.h in Headers */,\n\t\t\t\t7521D9E3291E9ABB009642EF /* WCTChainCall+Private.h in Headers */,\n\t\t\t\t7521D9E6291E9ABB009642EF /* WCTProperty.h in Headers */,\n\t\t\t\t7521D9E7291E9ABB009642EF /* Thread.hpp in Headers */,\n\t\t\t\t7521D9E8291E9ABB009642EF /* WCTCppAccessor.h in Headers */,\n\t\t\t\t7521D9E9291E9ABB009642EF /* BaseBinding.hpp in Headers */,\n\t\t\t\t7521D9EA291E9ABB009642EF /* FileHandle.hpp in Headers */,\n\t\t\t\t7521D9EC291E9ABB009642EF /* StatementDelete.hpp in Headers */,\n\t\t\t\t7521D9EF291E9ABB009642EF /* OperationQueue.hpp in Headers */,\n\t\t\t\t7521D9F0291E9ABB009642EF /* WindowDef.hpp in Headers */,\n\t\t\t\t7521D9F1291E9ABB009642EF /* WCTDatabase+FTS.h in Headers */,\n\t\t\t\t7521D9F3291E9ABB009642EF /* WCTPropertyMacro.h in Headers */,\n\t\t\t\t7521D9F4291E9ABB009642EF /* SyntaxTableOrSubquery.hpp in Headers */,\n\t\t\t\t7521D9F5291E9ABB009642EF /* StatementRelease.hpp in Headers */,\n\t\t\t\t758E7ECE2B1B49E300319991 /* WCTDatabase+Compression.h in Headers */,\n\t\t\t\t7521D9F6291E9ABB009642EF /* WCTORM.h in Headers */,\n\t\t\t\t7521D9F7291E9ABB009642EF /* Notifier.hpp in Headers */,\n\t\t\t\t752517672B12F13C00485175 /* CompressionConst.hpp in Headers */,\n\t\t\t\t7521D9F8291E9ABB009642EF /* SyntaxCreateTriggerSTMT.hpp in Headers */,\n\t\t\t\t7521D9FA291E9ABB009642EF /* SyntaxIndexedColumn.hpp in Headers */,\n\t\t\t\t7521D9FB291E9ABB009642EF /* SyntaxCommonConst.hpp in Headers */,\n\t\t\t\t7521D9FC291E9ABB009642EF /* StatementUpdate.hpp in Headers */,\n\t\t\t\t7521D9FD291E9ABB009642EF /* SQLiteBase.hpp in Headers */,\n\t\t\t\t7521D9FE291E9ABB009642EF /* Expression.hpp in Headers */,\n\t\t\t\t7521D9FF291E9ABB009642EF /* WCTDatabase+File.h in Headers */,\n\t\t\t\t7521DA00291E9ABB009642EF /* SyntaxPragmaSTMT.hpp in Headers */,\n\t\t\t\t7521DA01291E9ABB009642EF /* Upsert.hpp in Headers */,\n\t\t\t\t7521DA02291E9ABB009642EF /* AuxiliaryFunctionModule.hpp in Headers */,\n\t\t\t\t7521DA03291E9ABB009642EF /* WCTChainCall.h in Headers */,\n\t\t\t\t7521DA04291E9ABB009642EF /* BaseTokenizerUtil.hpp in Headers */,\n\t\t\t\t7521DA05291E9ABB009642EF /* Configs.hpp in Headers */,\n\t\t\t\t7521DA06291E9ABB009642EF /* WCTBuiltin.h in Headers */,\n\t\t\t\t7521DA07291E9ABB009642EF /* WCTDatabase+Memory.h in Headers */,\n\t\t\t\t7521DA08291E9ABB009642EF /* SharedThreadedErrorProne.hpp in Headers */,\n\t\t\t\t7521DA09291E9ABB009642EF /* Range.hpp in Headers */,\n\t\t\t\t7521DA0A291E9ABB009642EF /* SyntaxResultColumn.hpp in Headers */,\n\t\t\t\t7521DA0B291E9ABB009642EF /* FTSError.hpp in Headers */,\n\t\t\t\t7533CB692B051C4F00C8B47D /* ClassDecorator.hpp in Headers */,\n\t\t\t\t7521DA0C291E9ABB009642EF /* Mechanic.hpp in Headers */,\n\t\t\t\t7521DA0D291E9ABB009642EF /* WCTMaster+WCTTableCoding.h in Headers */,\n\t\t\t\t7533CB612B0516A600C8B47D /* MemberPointer.hpp in Headers */,\n\t\t\t\t7521DA0F291E9ABB009642EF /* WCTPreparedStatement.h in Headers */,\n\t\t\t\t7521DA11291E9ABB009642EF /* SyntaxJoinConstraint.hpp in Headers */,\n\t\t\t\t7521DA12291E9ABB009642EF /* ErrorProne.hpp in Headers */,\n\t\t\t\t7521DA13291E9ABB009642EF /* WCTRuntimeBaseAccessor.h in Headers */,\n\t\t\t\t7521DA14291E9ABB009642EF /* StatementCommit.hpp in Headers */,\n\t\t\t\t7521DA15291E9ABB009642EF /* SyntaxColumnDef.hpp in Headers */,\n\t\t\t\t7521DA16291E9ABB009642EF /* LRUCache.hpp in Headers */,\n\t\t\t\t7521DA17291E9ABB009642EF /* WCTHandle+Private.h in Headers */,\n\t\t\t\t0D19BA102B0702250028F92B /* AssembleHandleOperator.hpp in Headers */,\n\t\t\t\t7521DA18291E9ABB009642EF /* StatementVacuum.hpp in Headers */,\n\t\t\t\t7521DA19291E9ABB009642EF /* Column.hpp in Headers */,\n\t\t\t\t7521DA1A291E9ABB009642EF /* NSNull+WCTColumnCoding.h in Headers */,\n\t\t\t\t7521DA1B291E9ABB009642EF /* TimedQueue.hpp in Headers */,\n\t\t\t\t7521DA1D291E9ABB009642EF /* Time.hpp in Headers */,\n\t\t\t\t7521DA1E291E9ABB009642EF /* FileManager.hpp in Headers */,\n\t\t\t\t7521DA1F291E9ABB009642EF /* WCTConvertible.h in Headers */,\n\t\t\t\t7521DA20291E9ABB009642EF /* WCTTable+Private.h in Headers */,\n\t\t\t\t7521DA21291E9ABB009642EF /* WCDBError.hpp in Headers */,\n\t\t\t\t7521DA22291E9ABB009642EF /* DatabasePool.hpp in Headers */,\n\t\t\t\t7521DA23291E9ABB009642EF /* SyntaxWindowDef.hpp in Headers */,\n\t\t\t\t7521DA24291E9ABB009642EF /* WCTMaster.h in Headers */,\n\t\t\t\t75CB08D02A88B9A300429364 /* HandleCounter.hpp in Headers */,\n\t\t\t\t7521DA25291E9ABB009642EF /* TableOrSubquery.hpp in Headers */,\n\t\t\t\t7521DA26291E9ABB009642EF /* NSDate+WCTColumnCoding.h in Headers */,\n\t\t\t\t7521DA27291E9ABB009642EF /* Statement.hpp in Headers */,\n\t\t\t\t7521DA28291E9ABB009642EF /* ThreadLocal.hpp in Headers */,\n\t\t\t\t7521DA29291E9ABB009642EF /* Schema.hpp in Headers */,\n\t\t\t\t7521DA2A291E9ABB009642EF /* SyntaxDropIndexSTMT.hpp in Headers */,\n\t\t\t\t0D5403122B1606BC007DF415 /* CompressingHandleDecorator.hpp in Headers */,\n\t\t\t\t7521DA2B291E9ABB009642EF /* Assemble.hpp in Headers */,\n\t\t\t\t7521DA2C291E9ABB009642EF /* WCTDatabase+Transaction.h in Headers */,\n\t\t\t\t7521DA2E291E9ABB009642EF /* SyntaxBindParameter.hpp in Headers */,\n\t\t\t\t0DCD2AC82C6E210700C247EC /* AutoVacuumConfig.hpp in Headers */,\n\t\t\t\t75EF250F2AA42DD90009C99F /* EncryptedSerialization.hpp in Headers */,\n\t\t\t\t7521DA2F291E9ABB009642EF /* Lock.hpp in Headers */,\n\t\t\t\t7521DA30291E9ABB009642EF /* FactoryRetriever.hpp in Headers */,\n\t\t\t\t7521DA31291E9ABB009642EF /* WCTResultColumn.h in Headers */,\n\t\t\t\t7521DA32291E9ABB009642EF /* WCTHandle+Transaction.h in Headers */,\n\t\t\t\t7521DA33291E9ABB009642EF /* AutoCheckpointConfig.hpp in Headers */,\n\t\t\t\t7521DA34291E9ABB009642EF /* WCTColumnCoding.h in Headers */,\n\t\t\t\t7521DA35291E9ABB009642EF /* SyntaxVacuumSTMT.hpp in Headers */,\n\t\t\t\t7521DA36291E9ABB009642EF /* Material.hpp in Headers */,\n\t\t\t\t7521DA37291E9ABB009642EF /* SyntaxInsertSTMT.hpp in Headers */,\n\t\t\t\t75C6E414299E80D3002579A5 /* WCDBOptional.hpp in Headers */,\n\t\t\t\t7521DA38291E9ABB009642EF /* AggregateFunction.hpp in Headers */,\n\t\t\t\t7521DA39291E9ABB009642EF /* WCTError.h in Headers */,\n\t\t\t\t7521DA3A291E9ABB009642EF /* WCTSelectable+Private.h in Headers */,\n\t\t\t\t7521DA3B291E9ABB009642EF /* FactoryRenewer.hpp in Headers */,\n\t\t\t\t7521DA3C291E9ABB009642EF /* StatementAnalyze.hpp in Headers */,\n\t\t\t\t7521DA3D291E9ABB009642EF /* FactoryBackup.hpp in Headers */,\n\t\t\t\t7521DA3E291E9ABB009642EF /* CipherConfig.hpp in Headers */,\n\t\t\t\t0DD8D11C2B074C47002C97D3 /* MigrateHandleOperator.hpp in Headers */,\n\t\t\t\t7521DA3F291E9ABB009642EF /* SyntaxRollbackSTMT.hpp in Headers */,\n\t\t\t\t7529C7792ABC4D9900518293 /* CipherHandle.hpp in Headers */,\n\t\t\t);\n\t\t\trunOnlyForDeploymentPostprocessing = 0;\n\t\t};\n\t\t7521DC28291EA349009642EF /* Headers */ = {\n\t\t\tisa = PBXHeadersBuildPhase;\n\t\t\tbuildActionMask = 2147483647;\n\t\t\tfiles = (\n\t\t\t\t759362D62B36D450000AF163 /* Vacuum.hpp in Headers */,\n\t\t\t\t7521DC29291EA349009642EF /* AsyncQueue.hpp in Headers */,\n\t\t\t\t752517882B1338AF00485175 /* CompressionRecord.hpp in Headers */,\n\t\t\t\t7533CB602B050FB200C8B47D /* MigratingStatementDecorator.hpp in Headers */,\n\t\t\t\t7521DC2A291EA349009642EF /* AutoBackupConfig.hpp in Headers */,\n\t\t\t\t7521DC2B291EA349009642EF /* WINQ.h in Headers */,\n\t\t\t\t7521DC2C291EA349009642EF /* UnsafeData.hpp in Headers */,\n\t\t\t\t7521DC2F291EA349009642EF /* CommonCore.hpp in Headers */,\n\t\t\t\t7521DC34291EA349009642EF /* Pragma.hpp in Headers */,\n\t\t\t\t7521DC35291EA349009642EF /* SequenceItem.hpp in Headers */,\n\t\t\t\t75CB08D22A88B9A300429364 /* HandleCounter.hpp in Headers */,\n\t\t\t\t7521DC36291EA349009642EF /* MappedData.hpp in Headers */,\n\t\t\t\t7521DC37291EA349009642EF /* SyntaxCommitSTMT.hpp in Headers */,\n\t\t\t\t7521DC39291EA349009642EF /* Syntax.h in Headers */,\n\t\t\t\t7521DC3A291EA349009642EF /* SyntaxAttachSTMT.hpp in Headers */,\n\t\t\t\t0DE84AD52B03295400522A4E /* FunctionContainer.hpp in Headers */,\n\t\t\t\t7521DC3B291EA349009642EF /* CommonTableExpression.hpp in Headers */,\n\t\t\t\t7521DC3C291EA349009642EF /* ValueArray.hpp in Headers */,\n\t\t\t\t7521DC3E291EA349009642EF /* Console.hpp in Headers */,\n\t\t\t\t7521DC41291EA349009642EF /* CommonCore.h in Headers */,\n\t\t\t\t7521DC42291EA349009642EF /* HandleNotification.hpp in Headers */,\n\t\t\t\t7521DC43291EA349009642EF /* SyntaxCreateTableSTMT.hpp in Headers */,\n\t\t\t\t7521DC44291EA349009642EF /* SyntaxDropTriggerSTMT.hpp in Headers */,\n\t\t\t\t0D3FFA492A2F2911002DF7CD /* SysTypes.h in Headers */,\n\t\t\t\t7521DC45291EA349009642EF /* TokenizerModuleTemplate.hpp in Headers */,\n\t\t\t\t7521DC46291EA349009642EF /* Convertible.hpp in Headers */,\n\t\t\t\t7521DC47291EA349009642EF /* Initializeable.hpp in Headers */,\n\t\t\t\t7521DC48291EA349009642EF /* WinqBridge.hpp in Headers */,\n\t\t\t\t754212062B123E3200A2FF4D /* ScalarFunctionTemplate.hpp in Headers */,\n\t\t\t\t7521DC49291EA349009642EF /* Recyclable.hpp in Headers */,\n\t\t\t\t75C6E41B29A124B4002579A5 /* WCDBOptional.hpp in Headers */,\n\t\t\t\t756F7F6B2B2CA4B5002AEA0A /* FactoryVacuum.hpp in Headers */,\n\t\t\t\t7521DC4A291EA349009642EF /* CoreConst.h in Headers */,\n\t\t\t\t7521DC4B291EA349009642EF /* Cell.hpp in Headers */,\n\t\t\t\t7521DC4D291EA349009642EF /* BasicConfig.hpp in Headers */,\n\t\t\t\t750080F42920F4E9009C0F38 /* WCTFoundation.h in Headers */,\n\t\t\t\t7521DC4E291EA349009642EF /* StatementDropIndex.hpp in Headers */,\n\t\t\t\t7521DC4F291EA349009642EF /* Pager.hpp in Headers */,\n\t\t\t\t7521DC50291EA349009642EF /* SyntaxCreateIndexSTMT.hpp in Headers */,\n\t\t\t\t7521DC52291EA349009642EF /* Crawlable.hpp in Headers */,\n\t\t\t\t7521DC53291EA349009642EF /* LiteralValue.hpp in Headers */,\n\t\t\t\t754212252B124CFF00A2FF4D /* CompressionCenter.hpp in Headers */,\n\t\t\t\t7521DC55291EA349009642EF /* CustomConfig.hpp in Headers */,\n\t\t\t\t7521DC56291EA349009642EF /* StatementCreateTable.hpp in Headers */,\n\t\t\t\t7521DC57291EA349009642EF /* ForeignKey.hpp in Headers */,\n\t\t\t\t7521DC59291EA349009642EF /* WCDBVersion.h in Headers */,\n\t\t\t\t7521DC5C291EA349009642EF /* StatementDropTrigger.hpp in Headers */,\n\t\t\t\t7521DC5E291EA349009642EF /* FTSFunction.hpp in Headers */,\n\t\t\t\t7521DC60291EA349009642EF /* WalRelated.hpp in Headers */,\n\t\t\t\t7521DC61291EA349009642EF /* FactoryRelated.hpp in Headers */,\n\t\t\t\t0D3281662B04A8E60027B973 /* DecorativeHandle.hpp in Headers */,\n\t\t\t\t7521DC62291EA349009642EF /* SyntaxSelectSTMT.hpp in Headers */,\n\t\t\t\t7521DC64291EA349009642EF /* PerformanceTraceConfig.hpp in Headers */,\n\t\t\t\t7521DC65291EA349009642EF /* ColumnMeta.hpp in Headers */,\n\t\t\t\t7521DC67291EA349009642EF /* Macro.h in Headers */,\n\t\t\t\t7521DC69291EA349009642EF /* BusyRetryConfig.hpp in Headers */,\n\t\t\t\t7521DC6A291EA349009642EF /* Progress.hpp in Headers */,\n\t\t\t\t7521DC6B291EA349009642EF /* SyntaxForeignKeyClause.hpp in Headers */,\n\t\t\t\t7521DC6C291EA349009642EF /* SyntaxAssertion.hpp in Headers */,\n\t\t\t\t75294DB629C75058005E7FC0 /* OperationQueueForMemory.hpp in Headers */,\n\t\t\t\t7521DC6E291EA349009642EF /* SyntaxSelectCore.hpp in Headers */,\n\t\t\t\t7521DC6F291EA349009642EF /* SyntaxTableConstraint.hpp in Headers */,\n\t\t\t\t7521DC70291EA349009642EF /* ThreadedErrors.hpp in Headers */,\n\t\t\t\t7521DC71291EA349009642EF /* TableConstraint.hpp in Headers */,\n\t\t\t\t7521DC72291EA349009642EF /* AuxiliaryFunctionConfig.hpp in Headers */,\n\t\t\t\t7521DC73291EA349009642EF /* SQL.hpp in Headers */,\n\t\t\t\t7521DC75291EA349009642EF /* SequenceCrawler.hpp in Headers */,\n\t\t\t\t7521DC76291EA349009642EF /* PageBasedFileHandle.hpp in Headers */,\n\t\t\t\t7521DC77291EA349009642EF /* SQLTraceConfig.hpp in Headers */,\n\t\t\t\t752517942B133DB700485175 /* CompressHandleOperator.hpp in Headers */,\n\t\t\t\t7521DC78291EA349009642EF /* Data.hpp in Headers */,\n\t\t\t\t7533CB6B2B051C4F00C8B47D /* ClassDecorator.hpp in Headers */,\n\t\t\t\t7521DC7A291EA349009642EF /* Assertion.hpp in Headers */,\n\t\t\t\t7521DC7C291EA349009642EF /* Filter.hpp in Headers */,\n\t\t\t\t7521DC7D291EA349009642EF /* SyntaxDropViewSTMT.hpp in Headers */,\n\t\t\t\t7521DC7E291EA349009642EF /* Scoreable.hpp in Headers */,\n\t\t\t\t7521DC7F291EA349009642EF /* CaseInsensitiveList.hpp in Headers */,\n\t\t\t\t7521DC81291EA349009642EF /* SyntaxForwardDeclaration.h in Headers */,\n\t\t\t\t0D8BC3092B99B3C000DE9AE5 /* WCDBBridging.h in Headers */,\n\t\t\t\t7521DC84291EA349009642EF /* MigrationInfo.hpp in Headers */,\n\t\t\t\t7521DC86291EA349009642EF /* StatementCreateIndex.hpp in Headers */,\n\t\t\t\t7521DC8A291EA349009642EF /* StringView.hpp in Headers */,\n\t\t\t\t7521DC8B291EA349009642EF /* RepairKit.h in Headers */,\n\t\t\t\t7521DC8D291EA349009642EF /* OrderingTerm.hpp in Headers */,\n\t\t\t\t7521DC8E291EA349009642EF /* SyntaxUpsertClause.hpp in Headers */,\n\t\t\t\t7521DC8F291EA349009642EF /* Shm.hpp in Headers */,\n\t\t\t\t758E7EBF2B1B24AD00319991 /* AutoCompressConfig.hpp in Headers */,\n\t\t\t\t754211FC2B12359400A2FF4D /* ScalarFunctionConfig.hpp in Headers */,\n\t\t\t\t7521DC90291EA349009642EF /* StatementDetach.hpp in Headers */,\n\t\t\t\t7521DC92291EA349009642EF /* SubstringMatchInfo.hpp in Headers */,\n\t\t\t\t7521DC93291EA349009642EF /* SyntaxBeginSTMT.hpp in Headers */,\n\t\t\t\t7521DC94291EA349009642EF /* SyntaxUpdateSTMT.hpp in Headers */,\n\t\t\t\t7521DC95291EA349009642EF /* ResultColumn.hpp in Headers */,\n\t\t\t\t7521DC96291EA349009642EF /* StatementCreateTrigger.hpp in Headers */,\n\t\t\t\t7521DC97291EA349009642EF /* Repairman.hpp in Headers */,\n\t\t\t\t7521DC98291EA349009642EF /* ExpressionOperable.hpp in Headers */,\n\t\t\t\t7521DC99291EA349009642EF /* HandleRelated.hpp in Headers */,\n\t\t\t\t7521DC9A291EA349009642EF /* SyntaxOrderingTerm.hpp in Headers */,\n\t\t\t\t7521DCA0291EA349009642EF /* SyntaxAlterTableSTMT.hpp in Headers */,\n\t\t\t\t7521DCA1291EA349009642EF /* OneOrBinaryTokenizer.hpp in Headers */,\n\t\t\t\t7521DCA2291EA349009642EF /* IndexedColumn.hpp in Headers */,\n\t\t\t\t7521DCA5291EA349009642EF /* TokenizerModule.hpp in Headers */,\n\t\t\t\t7521DCA6291EA349009642EF /* AbstractHandle.hpp in Headers */,\n\t\t\t\t7521DCA7291EA349009642EF /* Factory.hpp in Headers */,\n\t\t\t\t7521DCA9291EA349009642EF /* SyntaxFrameSpec.hpp in Headers */,\n\t\t\t\t7521DCAA291EA349009642EF /* Path.hpp in Headers */,\n\t\t\t\t7521DCAB291EA349009642EF /* Migration.hpp in Headers */,\n\t\t\t\t7521DCAD291EA349009642EF /* SyntaxRaiseFunction.hpp in Headers */,\n\t\t\t\t7521DCAE291EA349009642EF /* StatementSelect.hpp in Headers */,\n\t\t\t\t7521DCAF291EA349009642EF /* SyntaxDropTableSTMT.hpp in Headers */,\n\t\t\t\t7521DCB1291EA349009642EF /* SyntaxExplainSTMT.hpp in Headers */,\n\t\t\t\t7521DCB2291EA349009642EF /* StatementDropView.hpp in Headers */,\n\t\t\t\t7521DCB3291EA349009642EF /* StatementExplain.hpp in Headers */,\n\t\t\t\t7521DCB4291EA349009642EF /* Backup.hpp in Headers */,\n\t\t\t\t75E0A5D92A7FE2A200D4FE9A /* ContainerBridge.h in Headers */,\n\t\t\t\t7521DCB5291EA349009642EF /* MasterItem.hpp in Headers */,\n\t\t\t\t7521DCB7291EA349009642EF /* BindParameter.hpp in Headers */,\n\t\t\t\t7521DCB8291EA349009642EF /* Join.hpp in Headers */,\n\t\t\t\t7521DCB9291EA349009642EF /* HighWater.hpp in Headers */,\n\t\t\t\t7521DCBA291EA349009642EF /* SyntaxIdentifier.hpp in Headers */,\n\t\t\t\t7521DCBB291EA349009642EF /* Fraction.hpp in Headers */,\n\t\t\t\t7521DCBC291EA349009642EF /* StatementDropTable.hpp in Headers */,\n\t\t\t\t7521DCBD291EA349009642EF /* SyntaxExpression.hpp in Headers */,\n\t\t\t\t7521DCBE291EA349009642EF /* MasterCrawler.hpp in Headers */,\n\t\t\t\t7521DCC0291EA349009642EF /* TokenizerModules.hpp in Headers */,\n\t\t\t\t7521DCC1291EA349009642EF /* QualifiedTable.hpp in Headers */,\n\t\t\t\t7521DCC2291EA349009642EF /* AutoMergeFTSIndexConfig.hpp in Headers */,\n\t\t\t\t7521DCC3291EA349009642EF /* Exiting.hpp in Headers */,\n\t\t\t\t7521DCC4291EA349009642EF /* Config.hpp in Headers */,\n\t\t\t\t7521DCC7291EA349009642EF /* Page.hpp in Headers */,\n\t\t\t\t7521DCC8291EA349009642EF /* SyntaxFilter.hpp in Headers */,\n\t\t\t\t7521DCC9291EA349009642EF /* StatementRollback.hpp in Headers */,\n\t\t\t\t7521DCCA291EA349009642EF /* StatementAlterTable.hpp in Headers */,\n\t\t\t\t7521DCCB291EA349009642EF /* StatementPragma.hpp in Headers */,\n\t\t\t\t7521DCCC291EA349009642EF /* RecyclableHandle.hpp in Headers */,\n\t\t\t\t7521DCCD291EA349009642EF /* SyntaxSchema.hpp in Headers */,\n\t\t\t\t7521DCD0291EA349009642EF /* SyntaxLiteralValue.hpp in Headers */,\n\t\t\t\t7521DCD2291EA349009642EF /* StatementReindex.hpp in Headers */,\n\t\t\t\t7521DCD3291EA349009642EF /* SyntaxList.hpp in Headers */,\n\t\t\t\t7521DCD6291EA349009642EF /* ColumnConstraint.hpp in Headers */,\n\t\t\t\t7521DCD7291EA349009642EF /* SQLiteDeclaration.h in Headers */,\n\t\t\t\t7521DCD8291EA349009642EF /* SyntaxEnum.hpp in Headers */,\n\t\t\t\t7521DCD9291EA349009642EF /* DBOperationNotifier.hpp in Headers */,\n\t\t\t\t7521DCDA291EA349009642EF /* StatementCreateView.hpp in Headers */,\n\t\t\t\t759362E12B36D756000AF163 /* VacuumHandleOperator.hpp in Headers */,\n\t\t\t\t7521DCDB291EA349009642EF /* SyntaxCreateVirtualTableSTMT.hpp in Headers */,\n\t\t\t\t7521DCDC291EA349009642EF /* Shadow.hpp in Headers */,\n\t\t\t\t7521DCE0291EA349009642EF /* JoinConstraint.hpp in Headers */,\n\t\t\t\t754211F12B12331900A2FF4D /* FunctionModules.hpp in Headers */,\n\t\t\t\t7521DCE1291EA349009642EF /* SyntaxReleaseSTMT.hpp in Headers */,\n\t\t\t\t7521DCE2291EA349009642EF /* Serialization.hpp in Headers */,\n\t\t\t\t75ADC56B2A8D1C2D00D0AC47 /* TableAttribute.hpp in Headers */,\n\t\t\t\t7521DCE5291EA349009642EF /* SyntaxColumn.hpp in Headers */,\n\t\t\t\t7521DCE6291EA349009642EF /* InnerDatabase.hpp in Headers */,\n\t\t\t\t7521DCE9291EA349009642EF /* MergeFTSIndexLogic.hpp in Headers */,\n\t\t\t\t7521DCEA291EA349009642EF /* SyntaxAnalyzeSTMT.hpp in Headers */,\n\t\t\t\t7521DCEB291EA349009642EF /* SyntaxColumnConstraint.hpp in Headers */,\n\t\t\t\t7521DCF0291EA349009642EF /* SyntaxReindexSTMT.hpp in Headers */,\n\t\t\t\t7521DCF1291EA349009642EF /* SyntaxCommonTableExpression.hpp in Headers */,\n\t\t\t\t75EF25112AA42DD90009C99F /* EncryptedSerialization.hpp in Headers */,\n\t\t\t\t7521DCF2291EA349009642EF /* UpgradeableErrorProne.hpp in Headers */,\n\t\t\t\t7521DCF4291EA349009642EF /* PagerRelated.hpp in Headers */,\n\t\t\t\t7521DCF7291EA349009642EF /* Tag.hpp in Headers */,\n\t\t\t\t7521DCF8291EA349009642EF /* SQLite.h in Headers */,\n\t\t\t\t7521DCF9291EA349009642EF /* SyntaxPragma.hpp in Headers */,\n\t\t\t\t7521DCFF291EA349009642EF /* StatementCreateVirtualTable.hpp in Headers */,\n\t\t\t\t7521DD00291EA349009642EF /* SQLiteFTS3Tokenizer.h in Headers */,\n\t\t\t\t7521DD02291EA349009642EF /* HandlePool.hpp in Headers */,\n\t\t\t\t7521DD03291EA349009642EF /* StatementInsert.hpp in Headers */,\n\t\t\t\t7521DD04291EA349009642EF /* FactoryDepositor.hpp in Headers */,\n\t\t\t\t7521DD06291EA349009642EF /* FrameSpec.hpp in Headers */,\n\t\t\t\t7521DD07291EA349009642EF /* TokenizerConfig.hpp in Headers */,\n\t\t\t\t7521DD08291EA349009642EF /* SyntaxCreateViewSTMT.hpp in Headers */,\n\t\t\t\t0D54030A2B160693007DF415 /* CompressingStatementDecorator.hpp in Headers */,\n\t\t\t\t7521DD0C291EA349009642EF /* Enum.hpp in Headers */,\n\t\t\t\t754212312B124CFF00A2FF4D /* Compression.hpp in Headers */,\n\t\t\t\t7521DD0D291EA349009642EF /* SyntaxDetachSTMT.hpp in Headers */,\n\t\t\t\t7521DD0E291EA349009642EF /* ColumnType.hpp in Headers */,\n\t\t\t\t7521DD11291EA349009642EF /* SyntaxDeleteSTMT.hpp in Headers */,\n\t\t\t\t7521DD14291EA349009642EF /* StatementSavepoint.hpp in Headers */,\n\t\t\t\t7521DD18291EA349009642EF /* FullCrawler.hpp in Headers */,\n\t\t\t\t7521DD1A291EA349009642EF /* SQLiteAssembler.hpp in Headers */,\n\t\t\t\t7521DD1D291EA349009642EF /* PinyinTokenizer.hpp in Headers */,\n\t\t\t\t7521DD1E291EA349009642EF /* StatementAttach.hpp in Headers */,\n\t\t\t\t7521DD1F291EA349009642EF /* ColumnDef.hpp in Headers */,\n\t\t\t\t7521DD22291EA349009642EF /* Wal.hpp in Headers */,\n\t\t\t\t0D5403142B1606BC007DF415 /* CompressingHandleDecorator.hpp in Headers */,\n\t\t\t\t7521DD23291EA349009642EF /* SyntaxSavepointSTMT.hpp in Headers */,\n\t\t\t\t7521DD24291EA349009642EF /* AutoMigrateConfig.hpp in Headers */,\n\t\t\t\t0DE84C842B03886800522A4E /* DecorativeHandleStatement.hpp in Headers */,\n\t\t\t\t7521DD26291EA349009642EF /* UniqueList.hpp in Headers */,\n\t\t\t\t7521DD27291EA349009642EF /* HandleStatement.hpp in Headers */,\n\t\t\t\t75A60AB629345A38009C1B3C /* Cipher.hpp in Headers */,\n\t\t\t\t7521DD28291EA349009642EF /* FTS5AuxiliaryFunctionTemplate.hpp in Headers */,\n\t\t\t\t7521DD2A291EA349009642EF /* SQLiteLocker.hpp in Headers */,\n\t\t\t\t7521DD2D291EA349009642EF /* ConvertibleImplementation.hpp in Headers */,\n\t\t\t\t7521DD2E291EA349009642EF /* Value.hpp in Headers */,\n\t\t\t\t7521DD2F291EA349009642EF /* RaiseFunction.hpp in Headers */,\n\t\t\t\t7521DD30291EA349009642EF /* InnerHandle.hpp in Headers */,\n\t\t\t\t7521DD32291EA349009642EF /* Global.hpp in Headers */,\n\t\t\t\t754359572B0671DE00CDF232 /* BackupHandleOperator.hpp in Headers */,\n\t\t\t\t7521DD33291EA349009642EF /* StatementBegin.hpp in Headers */,\n\t\t\t\t7521DD34291EA349009642EF /* SyntaxQualifiedTableName.hpp in Headers */,\n\t\t\t\t7521DD36291EA349009642EF /* SyntaxJoinClause.hpp in Headers */,\n\t\t\t\t7521DD37291EA349009642EF /* ObjectBridge.h in Headers */,\n\t\t\t\t7521DD38291EA349009642EF /* StatementCreateTriggerBridge.h in Headers */,\n\t\t\t\t7521DD39291EA349009642EF /* UpsertBridge.h in Headers */,\n\t\t\t\t7521DD3B291EA349009642EF /* FrameSpecBridge.h in Headers */,\n\t\t\t\t7521DD3C291EA349009642EF /* PragmaBridge.h in Headers */,\n\t\t\t\t7521DD3E291EA349009642EF /* StatementInsertBridge.h in Headers */,\n\t\t\t\t7521DD3F291EA349009642EF /* JoinBridge.h in Headers */,\n\t\t\t\t7521DD40291EA349009642EF /* RaiseFunctionBridge.h in Headers */,\n\t\t\t\t7521DD41291EA349009642EF /* StatementCreateTableBridge.h in Headers */,\n\t\t\t\t7521DD42291EA349009642EF /* StatementRollbackBridge.h in Headers */,\n\t\t\t\t7521DD43291EA349009642EF /* IndexedColumnBridge.h in Headers */,\n\t\t\t\t7521DD44291EA349009642EF /* CoreBridge.h in Headers */,\n\t\t\t\t7521DD45291EA349009642EF /* StatementAttachBridge.h in Headers */,\n\t\t\t\t7521DD46291EA349009642EF /* TableOrSubqueryBridge.h in Headers */,\n\t\t\t\t7521DD47291EA349009642EF /* StatementCommitBridge.h in Headers */,\n\t\t\t\t7521DD48291EA349009642EF /* QualifiedTableBridge.h in Headers */,\n\t\t\t\t7521DD49291EA349009642EF /* HandleStatementBridge.h in Headers */,\n\t\t\t\t7543594D2B066DBD00CDF232 /* HandleOperator.hpp in Headers */,\n\t\t\t\t75EF25072AA33FEB0009C99F /* IncrementalMaterial.hpp in Headers */,\n\t\t\t\t7521DD4B291EA349009642EF /* TableConstraintBridge.h in Headers */,\n\t\t\t\t7521DD4C291EA349009642EF /* StatementPragmaBridge.h in Headers */,\n\t\t\t\t7521DD4D291EA349009642EF /* StatementDetachBridge.h in Headers */,\n\t\t\t\t7521DD4E291EA349009642EF /* StatementBeginBridge.h in Headers */,\n\t\t\t\t7521DD4F291EA349009642EF /* StatementCreateVirtualTableBridge.h in Headers */,\n\t\t\t\t7542122D2B124CFF00A2FF4D /* CompressionInfo.hpp in Headers */,\n\t\t\t\t7521DD50291EA349009642EF /* StatementCreateIndexBridge.h in Headers */,\n\t\t\t\t7521DD51291EA349009642EF /* StatementDropIndexBridge.h in Headers */,\n\t\t\t\t7521DD52291EA349009642EF /* StatementVacuumBridge.h in Headers */,\n\t\t\t\t7521DD54291EA349009642EF /* WinqBridge.h in Headers */,\n\t\t\t\t754211E32B11FE9200A2FF4D /* ScalarFunctionModule.hpp in Headers */,\n\t\t\t\t0D19BA122B0702250028F92B /* AssembleHandleOperator.hpp in Headers */,\n\t\t\t\t7521DD55291EA349009642EF /* StatementDropViewBridge.h in Headers */,\n\t\t\t\t7521DD56291EA349009642EF /* StatementSelectBridge.h in Headers */,\n\t\t\t\t7529C77B2ABC4D9A00518293 /* CipherHandle.hpp in Headers */,\n\t\t\t\t7521DD57291EA349009642EF /* BindParameterBridge.h in Headers */,\n\t\t\t\t7521DD58291EA349009642EF /* StatementDropTriggerBridge.h in Headers */,\n\t\t\t\t7521DD59291EA349009642EF /* ErrorBridge.h in Headers */,\n\t\t\t\t7521DD5A291EA349009642EF /* ColumnDefBridge.h in Headers */,\n\t\t\t\t0D19BA262B07481B0028F92B /* IntegerityHandleOperator.hpp in Headers */,\n\t\t\t\t7521DD5B291EA349009642EF /* StatementReleaseBridge.h in Headers */,\n\t\t\t\t7521DD5D291EA349009642EF /* StatementCreateViewBridge.h in Headers */,\n\t\t\t\t7521DD5E291EA349009642EF /* ColumnBridge.h in Headers */,\n\t\t\t\t7521DD5F291EA349009642EF /* OrderingTermBridge.h in Headers */,\n\t\t\t\t7521DD60291EA349009642EF /* StatementAlterTableBridge.h in Headers */,\n\t\t\t\t7521DD61291EA349009642EF /* HandleBridge.h in Headers */,\n\t\t\t\t7521DD62291EA349009642EF /* SchemaBridge.h in Headers */,\n\t\t\t\t7521DD63291EA349009642EF /* WindowDefBridge.h in Headers */,\n\t\t\t\t7521DD64291EA349009642EF /* FTSBridge.h in Headers */,\n\t\t\t\t7521DD65291EA349009642EF /* ExpressionBridge.h in Headers */,\n\t\t\t\t7521DD66291EA349009642EF /* StatementExplainBridge.h in Headers */,\n\t\t\t\t7521DD67291EA349009642EF /* ColumnConstraintBridge.h in Headers */,\n\t\t\t\t7521DD68291EA349009642EF /* DatabaseBridge.h in Headers */,\n\t\t\t\t7521DD69291EA349009642EF /* StatementDropTableBridge.h in Headers */,\n\t\t\t\t7521DD6A291EA349009642EF /* ExpressionOperatableBridge.h in Headers */,\n\t\t\t\t7521DD6B291EA349009642EF /* StatementReindexBridge.h in Headers */,\n\t\t\t\t7521DD6C291EA349009642EF /* StatementSavepointBridge.h in Headers */,\n\t\t\t\t7521DD6D291EA349009642EF /* CommonTableExpressionBridge.h in Headers */,\n\t\t\t\t7521DD6E291EA349009642EF /* StatementAnalyzeBridge.h in Headers */,\n\t\t\t\t7521DD6F291EA349009642EF /* ForeignKeyBridge.h in Headers */,\n\t\t\t\t7521DD70291EA349009642EF /* ResultColumnBridge.h in Headers */,\n\t\t\t\t7521DD71291EA349009642EF /* LiteralValueBridge.h in Headers */,\n\t\t\t\t7521DD72291EA349009642EF /* StatementDeleteBridge.h in Headers */,\n\t\t\t\t7521DD73291EA349009642EF /* StatementUpdateBridge.h in Headers */,\n\t\t\t\t7521DD76291EA349009642EF /* CoreFunction.hpp in Headers */,\n\t\t\t\t7521DD77291EA349009642EF /* Frame.hpp in Headers */,\n\t\t\t\t7521DD78291EA349009642EF /* FTSConst.h in Headers */,\n\t\t\t\t7533CB562B050FA300C8B47D /* MigratingHandleDecorator.hpp in Headers */,\n\t\t\t\t7521DD7D291EA349009642EF /* Thread.hpp in Headers */,\n\t\t\t\t7521DD7F291EA349009642EF /* BaseBinding.hpp in Headers */,\n\t\t\t\t7521DD80291EA349009642EF /* FileHandle.hpp in Headers */,\n\t\t\t\t7521DD82291EA349009642EF /* StatementDelete.hpp in Headers */,\n\t\t\t\t7521DD85291EA349009642EF /* OperationQueue.hpp in Headers */,\n\t\t\t\t7521DD86291EA349009642EF /* WindowDef.hpp in Headers */,\n\t\t\t\t7521DD88291EA349009642EF /* ObjectBridge.hpp in Headers */,\n\t\t\t\t7521DD8A291EA349009642EF /* SyntaxTableOrSubquery.hpp in Headers */,\n\t\t\t\t7521DD8B291EA349009642EF /* StatementRelease.hpp in Headers */,\n\t\t\t\t0DD8D11E2B074C47002C97D3 /* MigrateHandleOperator.hpp in Headers */,\n\t\t\t\t752517692B12F13C00485175 /* CompressionConst.hpp in Headers */,\n\t\t\t\t7521DD8D291EA349009642EF /* Notifier.hpp in Headers */,\n\t\t\t\t7521DD8E291EA349009642EF /* SyntaxCreateTriggerSTMT.hpp in Headers */,\n\t\t\t\t754212292B124CFF00A2FF4D /* ZSTDDict.hpp in Headers */,\n\t\t\t\t7521DD90291EA349009642EF /* SyntaxIndexedColumn.hpp in Headers */,\n\t\t\t\t7521DD91291EA349009642EF /* SyntaxCommonConst.hpp in Headers */,\n\t\t\t\t7521DD92291EA349009642EF /* StatementUpdate.hpp in Headers */,\n\t\t\t\t752517622B12D43700485175 /* DecompressFunction.hpp in Headers */,\n\t\t\t\t7521DD93291EA349009642EF /* SQLiteBase.hpp in Headers */,\n\t\t\t\t7521DD94291EA349009642EF /* Expression.hpp in Headers */,\n\t\t\t\t0DCD2ACA2C6E210700C247EC /* AutoVacuumConfig.hpp in Headers */,\n\t\t\t\t7521DD96291EA349009642EF /* SyntaxPragmaSTMT.hpp in Headers */,\n\t\t\t\t7521DD97291EA349009642EF /* Upsert.hpp in Headers */,\n\t\t\t\t7521DD98291EA349009642EF /* AuxiliaryFunctionModule.hpp in Headers */,\n\t\t\t\t7521DD9A291EA349009642EF /* BaseTokenizerUtil.hpp in Headers */,\n\t\t\t\t7521DD9B291EA349009642EF /* Configs.hpp in Headers */,\n\t\t\t\t7521DD9E291EA349009642EF /* SharedThreadedErrorProne.hpp in Headers */,\n\t\t\t\t7521DD9F291EA349009642EF /* Range.hpp in Headers */,\n\t\t\t\t7521DDA0291EA349009642EF /* SyntaxResultColumn.hpp in Headers */,\n\t\t\t\t7521DDA1291EA349009642EF /* FTSError.hpp in Headers */,\n\t\t\t\t7521DDA2291EA349009642EF /* Mechanic.hpp in Headers */,\n\t\t\t\t7521DDA7291EA349009642EF /* SyntaxJoinConstraint.hpp in Headers */,\n\t\t\t\t7521DDA8291EA349009642EF /* ErrorProne.hpp in Headers */,\n\t\t\t\t7521DDAA291EA349009642EF /* StatementCommit.hpp in Headers */,\n\t\t\t\t7521DDAB291EA349009642EF /* SyntaxColumnDef.hpp in Headers */,\n\t\t\t\t7521DDAC291EA349009642EF /* LRUCache.hpp in Headers */,\n\t\t\t\t7521DDAE291EA349009642EF /* StatementVacuum.hpp in Headers */,\n\t\t\t\t7521DDAF291EA349009642EF /* Column.hpp in Headers */,\n\t\t\t\t7521DDB1291EA349009642EF /* TimedQueue.hpp in Headers */,\n\t\t\t\t7521DDB3291EA349009642EF /* Time.hpp in Headers */,\n\t\t\t\t7521DDB4291EA349009642EF /* FileManager.hpp in Headers */,\n\t\t\t\t7521DDB7291EA349009642EF /* WCDBError.hpp in Headers */,\n\t\t\t\t7521DDB8291EA349009642EF /* DatabasePool.hpp in Headers */,\n\t\t\t\t7521DDB9291EA349009642EF /* SyntaxWindowDef.hpp in Headers */,\n\t\t\t\t752CF3FB293A490F009ED8FB /* BindingBridge.h in Headers */,\n\t\t\t\t7521DDBB291EA349009642EF /* TableOrSubquery.hpp in Headers */,\n\t\t\t\t7521DDBD291EA349009642EF /* Statement.hpp in Headers */,\n\t\t\t\t7521DDBE291EA349009642EF /* ThreadLocal.hpp in Headers */,\n\t\t\t\t7521DDBF291EA349009642EF /* Schema.hpp in Headers */,\n\t\t\t\t7521DDC0291EA349009642EF /* SyntaxDropIndexSTMT.hpp in Headers */,\n\t\t\t\t7521DDC1291EA349009642EF /* Assemble.hpp in Headers */,\n\t\t\t\t7521DDC4291EA349009642EF /* SyntaxBindParameter.hpp in Headers */,\n\t\t\t\t7521DDC5291EA349009642EF /* Lock.hpp in Headers */,\n\t\t\t\t7521DDC6291EA349009642EF /* FactoryRetriever.hpp in Headers */,\n\t\t\t\t7521DDC9291EA349009642EF /* AutoCheckpointConfig.hpp in Headers */,\n\t\t\t\t7521DDCB291EA349009642EF /* SyntaxVacuumSTMT.hpp in Headers */,\n\t\t\t\t7521DDCC291EA349009642EF /* Material.hpp in Headers */,\n\t\t\t\t7521DDCD291EA349009642EF /* SyntaxInsertSTMT.hpp in Headers */,\n\t\t\t\t7521DDCE291EA349009642EF /* AggregateFunction.hpp in Headers */,\n\t\t\t\t7521DDE229208EB6009642EF /* WCTAPIBridge.h in Headers */,\n\t\t\t\t7521DDD1291EA349009642EF /* FactoryRenewer.hpp in Headers */,\n\t\t\t\t7521DDD2291EA349009642EF /* StatementAnalyze.hpp in Headers */,\n\t\t\t\t7521DDD3291EA349009642EF /* FactoryBackup.hpp in Headers */,\n\t\t\t\t7521DDD4291EA349009642EF /* CipherConfig.hpp in Headers */,\n\t\t\t\t7521DDD5291EA349009642EF /* SyntaxRollbackSTMT.hpp in Headers */,\n\t\t\t\t752517732B12FDC700485175 /* ZSTDContext.hpp in Headers */,\n\t\t\t);\n\t\t\trunOnlyForDeploymentPostprocessing = 0;\n\t\t};\n/* End PBXHeadersBuildPhase section */\n\n/* Begin PBXNativeTarget section */\n\t\t03330FA828167ECC0094CFCF /* SwiftBridgeObjcTest */ = {\n\t\t\tisa = PBXNativeTarget;\n\t\t\tbuildConfigurationList = 03330FFF28167ECC0094CFCF /* Build configuration list for PBXNativeTarget \"SwiftBridgeObjcTest\" */;\n\t\t\tbuildPhases = (\n\t\t\t\t03330FAD28167ECC0094CFCF /* Sources */,\n\t\t\t\t03330FFC28167ECC0094CFCF /* Frameworks */,\n\t\t\t\t03330FFE28167ECC0094CFCF /* Resources */,\n\t\t\t\t0D22E7AF2B298E9B00AA44D2 /* Embed Frameworks */,\n\t\t\t);\n\t\t\tbuildRules = (\n\t\t\t);\n\t\t\tdependencies = (\n\t\t\t\t0338E0BD2818F6D40094923A /* PBXTargetDependency */,\n\t\t\t\t03330FAB28167ECC0094CFCF /* PBXTargetDependency */,\n\t\t\t);\n\t\t\tname = SwiftBridgeObjcTest;\n\t\t\tproductName = TestsSwift;\n\t\t\tproductReference = 0333100228167ECC0094CFCF /* SwiftBridgeObjcTest.xctest */;\n\t\t\tproductType = \"com.apple.product-type.bundle.unit-test\";\n\t\t};\n\t\t037C38D02897E33600328EC8 /* WCDBCpp */ = {\n\t\t\tisa = PBXNativeTarget;\n\t\t\tbuildConfigurationList = 037C3C092897E33600328EC8 /* Build configuration list for PBXNativeTarget \"WCDBCpp\" */;\n\t\t\tbuildPhases = (\n\t\t\t\t037C38D32897E33600328EC8 /* Sources */,\n\t\t\t\t037C3A802897E33600328EC8 /* Frameworks */,\n\t\t\t\t037C3A852897E33600328EC8 /* Headers */,\n\t\t\t\t037C3C072897E33600328EC8 /* Resources */,\n\t\t\t\t037C3C082897E33600328EC8 /* Install Code Snippets and File Templates */,\n\t\t\t);\n\t\t\tbuildRules = (\n\t\t\t);\n\t\t\tdependencies = (\n\t\t\t\t0DACF7532B29ABE600CB0710 /* PBXTargetDependency */,\n\t\t\t\t037C38D12897E33600328EC8 /* PBXTargetDependency */,\n\t\t\t);\n\t\t\tname = WCDBCpp;\n\t\t\tproductName = \"WCDB framework\";\n\t\t\tproductReference = 037C3C0C2897E33600328EC8 /* WCDBCpp.framework */;\n\t\t\tproductType = \"com.apple.product-type.framework\";\n\t\t};\n\t\t03BF4AB72888F87C00A30500 /* BenchmarkTest */ = {\n\t\t\tisa = PBXNativeTarget;\n\t\t\tbuildConfigurationList = 03BF4B1C2888F87C00A30500 /* Build configuration list for PBXNativeTarget \"BenchmarkTest\" */;\n\t\t\tbuildPhases = (\n\t\t\t\t03BF4ABC2888F87C00A30500 /* Sources */,\n\t\t\t\t03BF4B192888F87C00A30500 /* Frameworks */,\n\t\t\t\t03BF4B1B2888F87C00A30500 /* Resources */,\n\t\t\t\t0D22E7B82B298EB200AA44D2 /* Embed Frameworks */,\n\t\t\t);\n\t\t\tbuildRules = (\n\t\t\t);\n\t\t\tdependencies = (\n\t\t\t\t03BF4AB82888F87C00A30500 /* PBXTargetDependency */,\n\t\t\t\t03BF4ABA2888F87C00A30500 /* PBXTargetDependency */,\n\t\t\t);\n\t\t\tname = BenchmarkTest;\n\t\t\tproductName = TestsSwift;\n\t\t\tproductReference = 03BF4B1F2888F87C00A30500 /* BenchmarkTest.xctest */;\n\t\t\tproductType = \"com.apple.product-type.bundle.unit-test\";\n\t\t};\n\t\t03E5CB9928A38CCA005353D9 /* CppTests */ = {\n\t\t\tisa = PBXNativeTarget;\n\t\t\tbuildConfigurationList = 03E5CC4628A38CCA005353D9 /* Build configuration list for PBXNativeTarget \"CppTests\" */;\n\t\t\tbuildPhases = (\n\t\t\t\t03E5CB9E28A38CCA005353D9 /* Sources */,\n\t\t\t\t03E5CC4328A38CCA005353D9 /* Frameworks */,\n\t\t\t\t03E5CC4528A38CCA005353D9 /* Resources */,\n\t\t\t\t0D22E7B22B298EA400AA44D2 /* Embed Frameworks */,\n\t\t\t);\n\t\t\tbuildRules = (\n\t\t\t);\n\t\t\tdependencies = (\n\t\t\t\t750080EE2920EDBA009C0F38 /* PBXTargetDependency */,\n\t\t\t\t03E5CB9A28A38CCA005353D9 /* PBXTargetDependency */,\n\t\t\t);\n\t\t\tname = CppTests;\n\t\t\tproductName = TestCase;\n\t\t\tproductReference = 03E5CC4928A38CCA005353D9 /* CppTests.xctest */;\n\t\t\tproductType = \"com.apple.product-type.bundle.unit-test\";\n\t\t};\n\t\t234F035B227A9CFE00DD65A2 /* ObjcTests */ = {\n\t\t\tisa = PBXNativeTarget;\n\t\t\tbuildConfigurationList = 234F0364227A9CFE00DD65A2 /* Build configuration list for PBXNativeTarget \"ObjcTests\" */;\n\t\t\tbuildPhases = (\n\t\t\t\t234F0358227A9CFE00DD65A2 /* Sources */,\n\t\t\t\t234F0359227A9CFE00DD65A2 /* Frameworks */,\n\t\t\t\t234F035A227A9CFE00DD65A2 /* Resources */,\n\t\t\t);\n\t\t\tbuildRules = (\n\t\t\t);\n\t\t\tdependencies = (\n\t\t\t\t750080EB2920ED98009C0F38 /* PBXTargetDependency */,\n\t\t\t\t03D3A2AE28A6697F0064D4D4 /* PBXTargetDependency */,\n\t\t\t);\n\t\t\tname = ObjcTests;\n\t\t\tproductName = TestCase;\n\t\t\tproductReference = 234F035C227A9CFE00DD65A2 /* ObjcTests.xctest */;\n\t\t\tproductType = \"com.apple.product-type.bundle.unit-test\";\n\t\t};\n\t\t234F8AD3227B0B5400791E45 /* SwiftTests */ = {\n\t\t\tisa = PBXNativeTarget;\n\t\t\tbuildConfigurationList = 234F8ADC227B0B5400791E45 /* Build configuration list for PBXNativeTarget \"SwiftTests\" */;\n\t\t\tbuildPhases = (\n\t\t\t\t234F8AD0227B0B5400791E45 /* Sources */,\n\t\t\t\t234F8AD1227B0B5400791E45 /* Frameworks */,\n\t\t\t\t234F8AD2227B0B5400791E45 /* Resources */,\n\t\t\t\t0D22E7B52B298EAC00AA44D2 /* Embed Frameworks */,\n\t\t\t);\n\t\t\tbuildRules = (\n\t\t\t);\n\t\t\tdependencies = (\n\t\t\t\t7546D45529D02BAE001B5611 /* PBXTargetDependency */,\n\t\t\t\t7575F7AF280679C7006259E2 /* PBXTargetDependency */,\n\t\t\t);\n\t\t\tname = SwiftTests;\n\t\t\tproductName = TestsSwift;\n\t\t\tproductReference = 234F8AD4227B0B5400791E45 /* SwiftTests.xctest */;\n\t\t\tproductType = \"com.apple.product-type.bundle.unit-test\";\n\t\t};\n\t\t239326601E836D7300D677CC /* WCDB */ = {\n\t\t\tisa = PBXNativeTarget;\n\t\t\tbuildConfigurationList = 239326661E836D7300D677CC /* Build configuration list for PBXNativeTarget \"WCDB\" */;\n\t\t\tbuildPhases = (\n\t\t\t\t2393265C1E836D7300D677CC /* Sources */,\n\t\t\t\t2393265D1E836D7300D677CC /* Frameworks */,\n\t\t\t\t2393265E1E836D7300D677CC /* Headers */,\n\t\t\t\t2393265F1E836D7300D677CC /* Resources */,\n\t\t\t\t23467D0B2230ED8F00A77DF1 /* Install Code Snippets and File Templates */,\n\t\t\t);\n\t\t\tbuildRules = (\n\t\t\t);\n\t\t\tdependencies = (\n\t\t\t\t0DACF74F2B29ABD400CB0710 /* PBXTargetDependency */,\n\t\t\t\t23F5BE0E20887FFF000CCD37 /* PBXTargetDependency */,\n\t\t\t);\n\t\t\tname = WCDB;\n\t\t\tproductName = \"WCDB framework\";\n\t\t\tproductReference = 239326611E836D7300D677CC /* WCDB.framework */;\n\t\t\tproductType = \"com.apple.product-type.framework\";\n\t\t};\n\t\t239E8A6F2160A5B100BCB308 /* Host */ = {\n\t\t\tisa = PBXNativeTarget;\n\t\t\tbuildConfigurationList = 239E8A862160A5B200BCB308 /* Build configuration list for PBXNativeTarget \"Host\" */;\n\t\t\tbuildPhases = (\n\t\t\t\t239E8A6C2160A5B100BCB308 /* Sources */,\n\t\t\t\t239E8A6D2160A5B100BCB308 /* Frameworks */,\n\t\t\t\t239E8A6E2160A5B100BCB308 /* Resources */,\n\t\t\t\t0D28FD302DB09E6300D85025 /* CopyFiles */,\n\t\t\t);\n\t\t\tbuildRules = (\n\t\t\t);\n\t\t\tdependencies = (\n\t\t\t);\n\t\t\tname = Host;\n\t\t\tproductName = Host;\n\t\t\tproductReference = 239E8A702160A5B100BCB308 /* Host.app */;\n\t\t\tproductType = \"com.apple.product-type.application\";\n\t\t};\n\t\t7521D6BE291E9ABB009642EF /* WCDBObjc */ = {\n\t\t\tisa = PBXNativeTarget;\n\t\t\tbuildConfigurationList = 7521DA44291E9ABB009642EF /* Build configuration list for PBXNativeTarget \"WCDBObjc\" */;\n\t\t\tbuildPhases = (\n\t\t\t\t7521D6C1291E9ABB009642EF /* Sources */,\n\t\t\t\t7521D88D291E9ABB009642EF /* Frameworks */,\n\t\t\t\t7521D892291E9ABB009642EF /* Headers */,\n\t\t\t\t7521DA42291E9ABB009642EF /* Resources */,\n\t\t\t\t7521DA43291E9ABB009642EF /* Install Code Snippets and File Templates */,\n\t\t\t);\n\t\t\tbuildRules = (\n\t\t\t);\n\t\t\tdependencies = (\n\t\t\t\t0DACF7512B29ABDB00CB0710 /* PBXTargetDependency */,\n\t\t\t\t7521D6BF291E9ABB009642EF /* PBXTargetDependency */,\n\t\t\t);\n\t\t\tname = WCDBObjc;\n\t\t\tproductName = \"WCDB framework\";\n\t\t\tproductReference = 7521DA47291E9ABB009642EF /* WCDBObjc.framework */;\n\t\t\tproductType = \"com.apple.product-type.framework\";\n\t\t};\n\t\t7521DA54291EA349009642EF /* WCDBSwift */ = {\n\t\t\tisa = PBXNativeTarget;\n\t\t\tbuildConfigurationList = 7521DDDA291EA349009642EF /* Build configuration list for PBXNativeTarget \"WCDBSwift\" */;\n\t\t\tbuildPhases = (\n\t\t\t\t7521DA57291EA349009642EF /* Sources */,\n\t\t\t\t7521DC23291EA349009642EF /* Frameworks */,\n\t\t\t\t7521DC28291EA349009642EF /* Headers */,\n\t\t\t\t7521DDD8291EA349009642EF /* Resources */,\n\t\t\t\t7521DDD9291EA349009642EF /* Install Code Snippets and File Templates */,\n\t\t\t);\n\t\t\tbuildRules = (\n\t\t\t);\n\t\t\tdependencies = (\n\t\t\t\t0DACF7552B29ABEC00CB0710 /* PBXTargetDependency */,\n\t\t\t\t7521DA55291EA349009642EF /* PBXTargetDependency */,\n\t\t\t);\n\t\t\tname = WCDBSwift;\n\t\t\tproductName = \"WCDB framework\";\n\t\t\tproductReference = 7521DDDD291EA349009642EF /* WCDBSwift.framework */;\n\t\t\tproductType = \"com.apple.product-type.framework\";\n\t\t};\n/* End PBXNativeTarget section */\n\n/* Begin PBXProject section */\n\t\t23B5F75B1E1111C100E58396 /* Project object */ = {\n\t\t\tisa = PBXProject;\n\t\t\tattributes = {\n\t\t\t\tLastSwiftUpdateCheck = 1020;\n\t\t\t\tLastUpgradeCheck = 1100;\n\t\t\t\tORGANIZATIONNAME = sanhuazhang;\n\t\t\t\tTargetAttributes = {\n\t\t\t\t\t03330FA828167ECC0094CFCF = {\n\t\t\t\t\t\tLastSwiftMigration = 1320;\n\t\t\t\t\t};\n\t\t\t\t\t037C38D02897E33600328EC8 = {\n\t\t\t\t\t\tProvisioningStyle = Manual;\n\t\t\t\t\t};\n\t\t\t\t\t03E5CB9928A38CCA005353D9 = {\n\t\t\t\t\t\tLastSwiftMigration = 1410;\n\t\t\t\t\t};\n\t\t\t\t\t234F035B227A9CFE00DD65A2 = {\n\t\t\t\t\t\tCreatedOnToolsVersion = 10.2.1;\n\t\t\t\t\t};\n\t\t\t\t\t234F8AD3227B0B5400791E45 = {\n\t\t\t\t\t\tCreatedOnToolsVersion = 10.2.1;\n\t\t\t\t\t\tLastSwiftMigration = 1020;\n\t\t\t\t\t};\n\t\t\t\t\t239326601E836D7300D677CC = {\n\t\t\t\t\t\tCreatedOnToolsVersion = 8.2;\n\t\t\t\t\t\tProvisioningStyle = Manual;\n\t\t\t\t\t};\n\t\t\t\t\t239E8A6F2160A5B100BCB308 = {\n\t\t\t\t\t\tCreatedOnToolsVersion = 10.0;\n\t\t\t\t\t\tProvisioningStyle = Automatic;\n\t\t\t\t\t};\n\t\t\t\t};\n\t\t\t};\n\t\t\tbuildConfigurationList = 23B5F75E1E1111C100E58396 /* Build configuration list for PBXProject \"WCDB\" */;\n\t\t\tcompatibilityVersion = \"Xcode 3.2\";\n\t\t\tdevelopmentRegion = en;\n\t\t\thasScannedForEncodings = 0;\n\t\t\tknownRegions = (\n\t\t\t\ten,\n\t\t\t\tBase,\n\t\t\t);\n\t\t\tmainGroup = 23B5F75A1E1111C100E58396;\n\t\t\tproductRefGroup = 23B5F7641E1111C100E58396 /* Products */;\n\t\t\tprojectDirPath = \"\";\n\t\t\tprojectReferences = (\n\t\t\t\t{\n\t\t\t\t\tProductGroup = 2321243920172865008146EF /* Products */;\n\t\t\t\t\tProjectRef = 23A747BE20039675003CECFA /* sqlcipher.preprocessed.xcodeproj */;\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tProductGroup = 75EABA092ADA4F2600AAD3C9 /* Products */;\n\t\t\t\t\tProjectRef = 75EABA082ADA4F2600AAD3C9 /* zstd.xcodeproj */;\n\t\t\t\t},\n\t\t\t);\n\t\t\tprojectRoot = \"\";\n\t\t\ttargets = (\n\t\t\t\t239326601E836D7300D677CC /* WCDB */,\n\t\t\t\t03330FA828167ECC0094CFCF /* SwiftBridgeObjcTest */,\n\t\t\t\t7521D6BE291E9ABB009642EF /* WCDBObjc */,\n\t\t\t\t234F035B227A9CFE00DD65A2 /* ObjcTests */,\n\t\t\t\t037C38D02897E33600328EC8 /* WCDBCpp */,\n\t\t\t\t03E5CB9928A38CCA005353D9 /* CppTests */,\n\t\t\t\t7521DA54291EA349009642EF /* WCDBSwift */,\n\t\t\t\t234F8AD3227B0B5400791E45 /* SwiftTests */,\n\t\t\t\t03BF4AB72888F87C00A30500 /* BenchmarkTest */,\n\t\t\t\t239E8A6F2160A5B100BCB308 /* Host */,\n\t\t\t);\n\t\t};\n/* End PBXProject section */\n\n/* Begin PBXReferenceProxy section */\n\t\t23F5BE0620887FD4000CCD37 /* sqlcipher.framework */ = {\n\t\t\tisa = PBXReferenceProxy;\n\t\t\tfileType = wrapper.framework;\n\t\t\tpath = sqlcipher.framework;\n\t\t\tremoteRef = 23F5BE0520887FD4000CCD37 /* PBXContainerItemProxy */;\n\t\t\tsourceTree = BUILT_PRODUCTS_DIR;\n\t\t};\n\t\t75EABA0D2ADA4F2600AAD3C9 /* zstd.framework */ = {\n\t\t\tisa = PBXReferenceProxy;\n\t\t\tfileType = wrapper.framework;\n\t\t\tpath = zstd.framework;\n\t\t\tremoteRef = 75EABA0C2ADA4F2600AAD3C9 /* PBXContainerItemProxy */;\n\t\t\tsourceTree = BUILT_PRODUCTS_DIR;\n\t\t};\n/* End PBXReferenceProxy section */\n\n/* Begin PBXResourcesBuildPhase section */\n\t\t03330FFE28167ECC0094CFCF /* Resources */ = {\n\t\t\tisa = PBXResourcesBuildPhase;\n\t\t\tbuildActionMask = 2147483647;\n\t\t\tfiles = (\n\t\t\t);\n\t\t\trunOnlyForDeploymentPostprocessing = 0;\n\t\t};\n\t\t037C3C072897E33600328EC8 /* Resources */ = {\n\t\t\tisa = PBXResourcesBuildPhase;\n\t\t\tbuildActionMask = 2147483647;\n\t\t\tfiles = (\n\t\t\t);\n\t\t\trunOnlyForDeploymentPostprocessing = 0;\n\t\t};\n\t\t03BF4B1B2888F87C00A30500 /* Resources */ = {\n\t\t\tisa = PBXResourcesBuildPhase;\n\t\t\tbuildActionMask = 2147483647;\n\t\t\tfiles = (\n\t\t\t);\n\t\t\trunOnlyForDeploymentPostprocessing = 0;\n\t\t};\n\t\t03E5CC4528A38CCA005353D9 /* Resources */ = {\n\t\t\tisa = PBXResourcesBuildPhase;\n\t\t\tbuildActionMask = 2147483647;\n\t\t\tfiles = (\n\t\t\t);\n\t\t\trunOnlyForDeploymentPostprocessing = 0;\n\t\t};\n\t\t234F035A227A9CFE00DD65A2 /* Resources */ = {\n\t\t\tisa = PBXResourcesBuildPhase;\n\t\t\tbuildActionMask = 2147483647;\n\t\t\tfiles = (\n\t\t\t);\n\t\t\trunOnlyForDeploymentPostprocessing = 0;\n\t\t};\n\t\t234F8AD2227B0B5400791E45 /* Resources */ = {\n\t\t\tisa = PBXResourcesBuildPhase;\n\t\t\tbuildActionMask = 2147483647;\n\t\t\tfiles = (\n\t\t\t);\n\t\t\trunOnlyForDeploymentPostprocessing = 0;\n\t\t};\n\t\t2393265F1E836D7300D677CC /* Resources */ = {\n\t\t\tisa = PBXResourcesBuildPhase;\n\t\t\tbuildActionMask = 2147483647;\n\t\t\tfiles = (\n\t\t\t);\n\t\t\trunOnlyForDeploymentPostprocessing = 0;\n\t\t};\n\t\t239E8A6E2160A5B100BCB308 /* Resources */ = {\n\t\t\tisa = PBXResourcesBuildPhase;\n\t\t\tbuildActionMask = 2147483647;\n\t\t\tfiles = (\n\t\t\t);\n\t\t\trunOnlyForDeploymentPostprocessing = 0;\n\t\t};\n\t\t7521DA42291E9ABB009642EF /* Resources */ = {\n\t\t\tisa = PBXResourcesBuildPhase;\n\t\t\tbuildActionMask = 2147483647;\n\t\t\tfiles = (\n\t\t\t);\n\t\t\trunOnlyForDeploymentPostprocessing = 0;\n\t\t};\n\t\t7521DDD8291EA349009642EF /* Resources */ = {\n\t\t\tisa = PBXResourcesBuildPhase;\n\t\t\tbuildActionMask = 2147483647;\n\t\t\tfiles = (\n\t\t\t);\n\t\t\trunOnlyForDeploymentPostprocessing = 0;\n\t\t};\n/* End PBXResourcesBuildPhase section */\n\n/* Begin PBXShellScriptBuildPhase section */\n\t\t037C3C082897E33600328EC8 /* Install Code Snippets and File Templates */ = {\n\t\t\tisa = PBXShellScriptBuildPhase;\n\t\t\tbuildActionMask = 2147483647;\n\t\t\tfiles = (\n\t\t\t);\n\t\t\tinputFileListPaths = (\n\t\t\t);\n\t\t\tinputPaths = (\n\t\t\t);\n\t\t\tname = \"Install Code Snippets and File Templates\";\n\t\t\toutputFileListPaths = (\n\t\t\t);\n\t\t\toutputPaths = (\n\t\t\t);\n\t\t\trunOnlyForDeploymentPostprocessing = 0;\n\t\t\tshellPath = /bin/sh;\n\t\t\tshellScript = \"if [ \\\"$ACTION\\\" = \\\"build\\\" ]; then \\n    (cd ${SRCROOT}/../tools/templates && sh install.sh) || true\\nfi\\n\";\n\t\t};\n\t\t23467D0B2230ED8F00A77DF1 /* Install Code Snippets and File Templates */ = {\n\t\t\tisa = PBXShellScriptBuildPhase;\n\t\t\tbuildActionMask = 2147483647;\n\t\t\tfiles = (\n\t\t\t);\n\t\t\tinputFileListPaths = (\n\t\t\t);\n\t\t\tinputPaths = (\n\t\t\t);\n\t\t\tname = \"Install Code Snippets and File Templates\";\n\t\t\toutputFileListPaths = (\n\t\t\t);\n\t\t\toutputPaths = (\n\t\t\t);\n\t\t\trunOnlyForDeploymentPostprocessing = 0;\n\t\t\tshellPath = /bin/sh;\n\t\t\tshellScript = \"if [ \\\"$ACTION\\\" = \\\"build\\\" ]; then \\n    (cd ${SRCROOT}/../tools/templates && sh install.sh) || true\\nfi\\n\";\n\t\t};\n\t\t7521DA43291E9ABB009642EF /* Install Code Snippets and File Templates */ = {\n\t\t\tisa = PBXShellScriptBuildPhase;\n\t\t\tbuildActionMask = 2147483647;\n\t\t\tfiles = (\n\t\t\t);\n\t\t\tinputFileListPaths = (\n\t\t\t);\n\t\t\tinputPaths = (\n\t\t\t);\n\t\t\tname = \"Install Code Snippets and File Templates\";\n\t\t\toutputFileListPaths = (\n\t\t\t);\n\t\t\toutputPaths = (\n\t\t\t);\n\t\t\trunOnlyForDeploymentPostprocessing = 0;\n\t\t\tshellPath = /bin/sh;\n\t\t\tshellScript = \"if [ \\\"$ACTION\\\" = \\\"build\\\" ]; then \\n    (cd ${SRCROOT}/../tools/templates && sh install.sh) || true\\nfi\\n\";\n\t\t};\n\t\t7521DDD9291EA349009642EF /* Install Code Snippets and File Templates */ = {\n\t\t\tisa = PBXShellScriptBuildPhase;\n\t\t\tbuildActionMask = 2147483647;\n\t\t\tfiles = (\n\t\t\t);\n\t\t\tinputFileListPaths = (\n\t\t\t);\n\t\t\tinputPaths = (\n\t\t\t);\n\t\t\tname = \"Install Code Snippets and File Templates\";\n\t\t\toutputFileListPaths = (\n\t\t\t);\n\t\t\toutputPaths = (\n\t\t\t);\n\t\t\trunOnlyForDeploymentPostprocessing = 0;\n\t\t\tshellPath = /bin/sh;\n\t\t\tshellScript = \"if [ \\\"$ACTION\\\" = \\\"build\\\" ]; then \\n    (cd ${SRCROOT}/../tools/templates && sh install.sh) || true\\nfi\\n\";\n\t\t};\n/* End PBXShellScriptBuildPhase section */\n\n/* Begin PBXSourcesBuildPhase section */\n\t\t03330FAD28167ECC0094CFCF /* Sources */ = {\n\t\t\tisa = PBXSourcesBuildPhase;\n\t\t\tbuildActionMask = 2147483647;\n\t\t\tfiles = (\n\t\t\t\t03331034281681200094CFCF /* CRUDTestCase.swift in Sources */,\n\t\t\t\t0338E0D62819226C0094923A /* SelectInterfaceTests.swift in Sources */,\n\t\t\t\t0338E0C8281920AB0094923A /* DeleteTests.swift in Sources */,\n\t\t\t\t0338E0DB2819226C0094923A /* RowSelectTests.swift in Sources */,\n\t\t\t\t0338E0E22819226C0094923A /* AdvanceCRUDTests.swift in Sources */,\n\t\t\t\t75067CC3293F8300005DA25B /* DatabaseTestCase.swift in Sources */,\n\t\t\t\t75067CC1293F82B4005DA25B /* AutoAddColumnTests.swift in Sources */,\n\t\t\t\t033310EE2816A2F20094CFCF /* CRUDObject.swift in Sources */,\n\t\t\t\t0338E0DA2819226C0094923A /* MultiSelectTests.swift in Sources */,\n\t\t\t\t0338E0D92819226C0094923A /* UpdateInterfaceTests.swift in Sources */,\n\t\t\t\t03331040281681A80094CFCF /* BaseTestCase.swift in Sources */,\n\t\t\t\t0338E0DF2819226C0094923A /* InsertInterfaceTests.swift in Sources */,\n\t\t\t\t0381A67B2817A36300E64463 /* SelectTests.swift in Sources */,\n\t\t\t\t033310462816836C0094CFCF /* CRUDObject.mm in Sources */,\n\t\t\t\t03331041281681A80094CFCF /* Convenience.swift in Sources */,\n\t\t\t\t0338E0E12819226C0094923A /* DeleteInterfaceTests.swift in Sources */,\n\t\t\t\t0338E0D72819226C0094923A /* InsertTests.swift in Sources */,\n\t\t\t\t75067CC4293F8576005DA25B /* AutoAddColumnObject.mm in Sources */,\n\t\t\t\t0338E0DD2819226C0094923A /* UpdateTests.swift in Sources */,\n\t\t\t\t0333103F281681A80094CFCF /* Assert.swift in Sources */,\n\t\t\t);\n\t\t\trunOnlyForDeploymentPostprocessing = 0;\n\t\t};\n\t\t037C38D32897E33600328EC8 /* Sources */ = {\n\t\t\tisa = PBXSourcesBuildPhase;\n\t\t\tbuildActionMask = 2147483647;\n\t\t\tfiles = (\n\t\t\t\t037C38D42897E33600328EC8 /* SQL.cpp in Sources */,\n\t\t\t\t037C38D52897E33600328EC8 /* HighWater.cpp in Sources */,\n\t\t\t\t759362D12B36D450000AF163 /* Vacuum.cpp in Sources */,\n\t\t\t\t037C38D62897E33600328EC8 /* ConvertibleImplementation.cpp in Sources */,\n\t\t\t\t037C38D72897E33600328EC8 /* Scoreable.cpp in Sources */,\n\t\t\t\t037C38D82897E33600328EC8 /* StatementCreateView.cpp in Sources */,\n\t\t\t\t037C38D92897E33600328EC8 /* MappedData.cpp in Sources */,\n\t\t\t\t037C38DA2897E33600328EC8 /* Backup.cpp in Sources */,\n\t\t\t\t037C38E02897E33600328EC8 /* SQLTraceConfig.cpp in Sources */,\n\t\t\t\t037C38E12897E33600328EC8 /* SyntaxPragma.cpp in Sources */,\n\t\t\t\t037C38E32897E33600328EC8 /* Factory.cpp in Sources */,\n\t\t\t\t037C38E62897E33600328EC8 /* Statement.cpp in Sources */,\n\t\t\t\t7533CB512B050FA300C8B47D /* MigratingHandleDecorator.cpp in Sources */,\n\t\t\t\t037C38E72897E33600328EC8 /* FactoryBackup.cpp in Sources */,\n\t\t\t\t7547A3CD290D28A200AFA132 /* OneOrBinaryTokenizer.cpp in Sources */,\n\t\t\t\t037C38E92897E33600328EC8 /* CustomConfig.cpp in Sources */,\n\t\t\t\t037C38EA2897E33600328EC8 /* StatementDropView.cpp in Sources */,\n\t\t\t\t037C38EB2897E33600328EC8 /* Config.cpp in Sources */,\n\t\t\t\t7537E5D128B939240077D92B /* BaseBinding.cpp in Sources */,\n\t\t\t\t037C38EE2897E33600328EC8 /* Tag.cpp in Sources */,\n\t\t\t\t037C38EF2897E33600328EC8 /* SyntaxSavepointSTMT.cpp in Sources */,\n\t\t\t\t037C38F02897E33600328EC8 /* SyntaxDeleteSTMT.cpp in Sources */,\n\t\t\t\t037C38F12897E33600328EC8 /* SyntaxCommitSTMT.cpp in Sources */,\n\t\t\t\t037C38F42897E33600328EC8 /* Notifier.cpp in Sources */,\n\t\t\t\t0DE08A2429CBE79C009A7CA3 /* CrossPlatform.c in Sources */,\n\t\t\t\t037C38F62897E33600328EC8 /* SyntaxDropViewSTMT.cpp in Sources */,\n\t\t\t\t7529C7712ABC4D6A00518293 /* CipherHandle.cpp in Sources */,\n\t\t\t\t037C38F92897E33600328EC8 /* OrderingTerm.cpp in Sources */,\n\t\t\t\t037C38FB2897E33600328EC8 /* ColumnType.cpp in Sources */,\n\t\t\t\t03D077EE28C1F072009A3B18 /* TableOperation.cpp in Sources */,\n\t\t\t\t037C38FD2897E33600328EC8 /* StatementAttach.cpp in Sources */,\n\t\t\t\t037330C1289A909A0030C113 /* Database.cpp in Sources */,\n\t\t\t\t037C38FE2897E33600328EC8 /* Fraction.cpp in Sources */,\n\t\t\t\t037C39002897E33600328EC8 /* SyntaxTableConstraint.cpp in Sources */,\n\t\t\t\t037C39012897E33600328EC8 /* SequenceCrawler.cpp in Sources */,\n\t\t\t\t037C39062897E33600328EC8 /* StatementDropTrigger.cpp in Sources */,\n\t\t\t\t037C39072897E33600328EC8 /* ExpressionOperable.cpp in Sources */,\n\t\t\t\t037C39092897E33600328EC8 /* SQLiteLocker.cpp in Sources */,\n\t\t\t\t037C390D2897E33600328EC8 /* StatementUpdate.cpp in Sources */,\n\t\t\t\t037C390E2897E33600328EC8 /* SyntaxResultColumn.cpp in Sources */,\n\t\t\t\t759362DC2B36D756000AF163 /* VacuumHandleOperator.cpp in Sources */,\n\t\t\t\t037C390F2897E33600328EC8 /* Initializeable.cpp in Sources */,\n\t\t\t\t037C39102897E33600328EC8 /* PageBasedFileHandle.cpp in Sources */,\n\t\t\t\t75E50A2D2907921600B73E62 /* MultiSelect.cpp in Sources */,\n\t\t\t\t037C39122897E33600328EC8 /* Progress.cpp in Sources */,\n\t\t\t\t0D5363F0290A75F20026A4DC /* Sequence.cpp in Sources */,\n\t\t\t\t75EF25022AA33FEB0009C99F /* IncrementalMaterial.cpp in Sources */,\n\t\t\t\t037C39132897E33600328EC8 /* Mechanic.cpp in Sources */,\n\t\t\t\t037C39172897E33600328EC8 /* SyntaxUpdateSTMT.cpp in Sources */,\n\t\t\t\t037C391B2897E33600328EC8 /* StatementCreateIndex.cpp in Sources */,\n\t\t\t\t037C391D2897E33600328EC8 /* StatementDetach.cpp in Sources */,\n\t\t\t\t03AFD34F28B8C4EB00EF5E56 /* Field.cpp in Sources */,\n\t\t\t\t037C391F2897E33600328EC8 /* StatementAnalyze.cpp in Sources */,\n\t\t\t\t037C39212897E33600328EC8 /* FTSFunction.cpp in Sources */,\n\t\t\t\t0DE08A2629CBE79C009A7CA3 /* WCTOperationQueue.cpp in Sources */,\n\t\t\t\t037C39222897E33600328EC8 /* RecyclableHandle.cpp in Sources */,\n\t\t\t\t7521D39228BD1187009C33D0 /* ChainCall.cpp in Sources */,\n\t\t\t\t037C39262897E33600328EC8 /* ResultColumn.cpp in Sources */,\n\t\t\t\t037C39282897E33600328EC8 /* FullCrawler.cpp in Sources */,\n\t\t\t\t037C39292897E33600328EC8 /* SyntaxVacuumSTMT.cpp in Sources */,\n\t\t\t\t75401478290BE51400EA8D33 /* PinyinTokenizer.cpp in Sources */,\n\t\t\t\t75ADC5662A8D1C2D00D0AC47 /* TableAttribute.cpp in Sources */,\n\t\t\t\t037C392C2897E33600328EC8 /* StatementCreateTable.cpp in Sources */,\n\t\t\t\t037C392D2897E33600328EC8 /* HandleNotification.cpp in Sources */,\n\t\t\t\t037C392E2897E33600328EC8 /* SequenceItem.cpp in Sources */,\n\t\t\t\t037C392F2897E33600328EC8 /* AuxiliaryFunctionModule.cpp in Sources */,\n\t\t\t\t7525178F2B133DB700485175 /* CompressHandleOperator.cpp in Sources */,\n\t\t\t\t03E5CC6E28A3BDF3005353D9 /* Value.cpp in Sources */,\n\t\t\t\t0D5403052B160693007DF415 /* CompressingStatementDecorator.cpp in Sources */,\n\t\t\t\t037C39322897E33600328EC8 /* StatementAlterTable.cpp in Sources */,\n\t\t\t\t0D3281612B04A8E60027B973 /* DecorativeHandle.cpp in Sources */,\n\t\t\t\t037C39332897E33600328EC8 /* CipherConfig.cpp in Sources */,\n\t\t\t\t0D19BA0D2B0702250028F92B /* AssembleHandleOperator.cpp in Sources */,\n\t\t\t\t037C39342897E33600328EC8 /* FactoryRelated.cpp in Sources */,\n\t\t\t\t037C39352897E33600328EC8 /* Global.cpp in Sources */,\n\t\t\t\t037C39392897E33600328EC8 /* SyntaxDropTriggerSTMT.cpp in Sources */,\n\t\t\t\t037C393B2897E33600328EC8 /* AsyncQueue.cpp in Sources */,\n\t\t\t\t03321E8D28A514F5000AFD6D /* HandleOperation.cpp in Sources */,\n\t\t\t\t037C393C2897E33600328EC8 /* SyntaxUpsertClause.cpp in Sources */,\n\t\t\t\t037C393F2897E33600328EC8 /* Expression.cpp in Sources */,\n\t\t\t\t037C39402897E33600328EC8 /* SyntaxPragmaSTMT.cpp in Sources */,\n\t\t\t\t037C394E2897E33600328EC8 /* JoinConstraint.cpp in Sources */,\n\t\t\t\t037C39522897E33600328EC8 /* AutoMigrateConfig.cpp in Sources */,\n\t\t\t\t037C39532897E33600328EC8 /* TableOrSubquery.cpp in Sources */,\n\t\t\t\t037C39552897E33600328EC8 /* WalRelated.cpp in Sources */,\n\t\t\t\t037C39562897E33600328EC8 /* SyntaxBeginSTMT.cpp in Sources */,\n\t\t\t\t037C39572897E33600328EC8 /* SyntaxCommonTableExpression.cpp in Sources */,\n\t\t\t\t037C39592897E33600328EC8 /* StatementDropTable.cpp in Sources */,\n\t\t\t\t037C395C2897E33600328EC8 /* SyntaxExpression.cpp in Sources */,\n\t\t\t\t75CB08CD2A88B9A300429364 /* HandleCounter.cpp in Sources */,\n\t\t\t\t037C395D2897E33600328EC8 /* StatementCreateVirtualTable.cpp in Sources */,\n\t\t\t\t037C395E2897E33600328EC8 /* SyntaxCommonConst.cpp in Sources */,\n\t\t\t\t037C395F2897E33600328EC8 /* StatementSavepoint.cpp in Sources */,\n\t\t\t\t75F32F0D28B9F90900A72697 /* FTSTokenizerUtil.cpp in Sources */,\n\t\t\t\t037C39602897E33600328EC8 /* Recyclable.cpp in Sources */,\n\t\t\t\t037C39612897E33600328EC8 /* Data.cpp in Sources */,\n\t\t\t\t037C39622897E33600328EC8 /* SyntaxForeignKeyClause.cpp in Sources */,\n\t\t\t\t754212202B124CFF00A2FF4D /* Compression.cpp in Sources */,\n\t\t\t\t037C39632897E33600328EC8 /* IndexedColumn.cpp in Sources */,\n\t\t\t\t037C39642897E33600328EC8 /* RaiseFunction.cpp in Sources */,\n\t\t\t\t037C39662897E33600328EC8 /* ColumnConstraint.cpp in Sources */,\n\t\t\t\t037C39692897E33600328EC8 /* Range.cpp in Sources */,\n\t\t\t\t037C396B2897E33600328EC8 /* ThreadedErrors.cpp in Sources */,\n\t\t\t\t037C39712897E33600328EC8 /* StatementCreateTrigger.cpp in Sources */,\n\t\t\t\t037C39722897E33600328EC8 /* DatabasePool.cpp in Sources */,\n\t\t\t\t037C39752897E33600328EC8 /* TokenizerModules.cpp in Sources */,\n\t\t\t\t037C39782897E33600328EC8 /* FactoryDepositor.cpp in Sources */,\n\t\t\t\t037C397D2897E33600328EC8 /* TokenizerConfig.cpp in Sources */,\n\t\t\t\t037C397E2897E33600328EC8 /* FactoryRetriever.cpp in Sources */,\n\t\t\t\t7542121C2B124CFF00A2FF4D /* CompressionInfo.cpp in Sources */,\n\t\t\t\t037C39812897E33600328EC8 /* StatementRollback.cpp in Sources */,\n\t\t\t\t037C39822897E33600328EC8 /* Exiting.cpp in Sources */,\n\t\t\t\t752517832B1338AF00485175 /* CompressionRecord.cpp in Sources */,\n\t\t\t\t0D32816A2B04AC7A0027B973 /* FunctionContainer.cpp in Sources */,\n\t\t\t\t037C39852897E33600328EC8 /* Migration.cpp in Sources */,\n\t\t\t\t037C39862897E33600328EC8 /* Configs.cpp in Sources */,\n\t\t\t\t037C39872897E33600328EC8 /* SyntaxCreateTriggerSTMT.cpp in Sources */,\n\t\t\t\t037C398A2897E33600328EC8 /* Column.cpp in Sources */,\n\t\t\t\t754359482B066DBD00CDF232 /* HandleOperator.cpp in Sources */,\n\t\t\t\t0D54030F2B1606BC007DF415 /* CompressingHandleDecorator.cpp in Sources */,\n\t\t\t\t758E7EBA2B1B24AD00319991 /* AutoCompressConfig.cpp in Sources */,\n\t\t\t\t0D19BA212B07481B0028F92B /* IntegerityHandleOperator.cpp in Sources */,\n\t\t\t\t037C398E2897E33600328EC8 /* StatementSelect.cpp in Sources */,\n\t\t\t\t037C39952897E33600328EC8 /* SyntaxReindexSTMT.cpp in Sources */,\n\t\t\t\t037C39982897E33600328EC8 /* SyntaxCreateViewSTMT.cpp in Sources */,\n\t\t\t\t037C39992897E33600328EC8 /* BindParameter.cpp in Sources */,\n\t\t\t\t756F7F662B2CA4B5002AEA0A /* FactoryVacuum.cpp in Sources */,\n\t\t\t\t037C399A2897E33600328EC8 /* AutoBackupConfig.cpp in Sources */,\n\t\t\t\t75E50A0B29067BC800B73E62 /* MultiObject.cpp in Sources */,\n\t\t\t\t0DC98FD228E46049007F3796 /* DBOperationNotifier.cpp in Sources */,\n\t\t\t\t037C399D2897E33600328EC8 /* SyntaxRaiseFunction.cpp in Sources */,\n\t\t\t\t0DE84C7F2B03886800522A4E /* DecorativeHandleStatement.cpp in Sources */,\n\t\t\t\t037C399E2897E33600328EC8 /* FrameSpec.cpp in Sources */,\n\t\t\t\t03AFD34C28B8BB7600EF5E56 /* Binding.cpp in Sources */,\n\t\t\t\t037C39A12897E33600328EC8 /* HandlePool.cpp in Sources */,\n\t\t\t\t754211DE2B11FE9200A2FF4D /* ScalarFunctionModule.cpp in Sources */,\n\t\t\t\t037C39A32897E33600328EC8 /* SyntaxWindowDef.cpp in Sources */,\n\t\t\t\t037C39A72897E33600328EC8 /* PagerRelated.cpp in Sources */,\n\t\t\t\t037C39AB2897E33600328EC8 /* SyntaxColumnDef.cpp in Sources */,\n\t\t\t\t75C6E41929A0C2F0002579A5 /* WCDBOptional.cpp in Sources */,\n\t\t\t\t037C39AD2897E33600328EC8 /* WindowDef.cpp in Sources */,\n\t\t\t\t0DD8D1192B074C47002C97D3 /* MigrateHandleOperator.cpp in Sources */,\n\t\t\t\t037C39AE2897E33600328EC8 /* FileManager.cpp in Sources */,\n\t\t\t\t037C39AF2897E33600328EC8 /* SyntaxColumn.cpp in Sources */,\n\t\t\t\t75EF250C2AA42DD90009C99F /* EncryptedSerialization.cpp in Sources */,\n\t\t\t\t75E0A5C22A7F4EEE00D4FE9A /* CoreConst.cpp in Sources */,\n\t\t\t\t037C39B02897E33600328EC8 /* SyntaxFilter.cpp in Sources */,\n\t\t\t\t037C39B12897E33600328EC8 /* StatementDelete.cpp in Sources */,\n\t\t\t\t037C39B32897E33600328EC8 /* ErrorProne.cpp in Sources */,\n\t\t\t\t037C39B52897E33600328EC8 /* SyntaxInsertSTMT.cpp in Sources */,\n\t\t\t\t75D99B8328CA46A400BEC8B5 /* BaseOperation.cpp in Sources */,\n\t\t\t\t037C39B82897E33600328EC8 /* Shm.cpp in Sources */,\n\t\t\t\t0DCD2AC52C6E210700C247EC /* AutoVacuumConfig.cpp in Sources */,\n\t\t\t\t037C39B92897E33600328EC8 /* InnerDatabase.cpp in Sources */,\n\t\t\t\t037C39BA2897E33600328EC8 /* Pragma.cpp in Sources */,\n\t\t\t\t037C39BB2897E33600328EC8 /* UpgradeableErrorProne.cpp in Sources */,\n\t\t\t\t037C39C02897E33600328EC8 /* SharedThreadedErrorProne.cpp in Sources */,\n\t\t\t\t037C39C12897E33600328EC8 /* LiteralValue.cpp in Sources */,\n\t\t\t\t037C39C52897E33600328EC8 /* SyntaxCreateIndexSTMT.cpp in Sources */,\n\t\t\t\t037C39CC2897E33600328EC8 /* SyntaxAlterTableSTMT.cpp in Sources */,\n\t\t\t\t037C39CD2897E33600328EC8 /* SyntaxCreateVirtualTableSTMT.cpp in Sources */,\n\t\t\t\t037C39CE2897E33600328EC8 /* SyntaxAttachSTMT.cpp in Sources */,\n\t\t\t\t037C39D02897E33600328EC8 /* SyntaxJoinClause.cpp in Sources */,\n\t\t\t\t037C39D32897E33600328EC8 /* SyntaxDropTableSTMT.cpp in Sources */,\n\t\t\t\t037C39D52897E33600328EC8 /* SyntaxExplainSTMT.cpp in Sources */,\n\t\t\t\t037C39D82897E33600328EC8 /* SyntaxLiteralValue.cpp in Sources */,\n\t\t\t\t037C39DA2897E33600328EC8 /* StringView.cpp in Sources */,\n\t\t\t\t037C39DD2897E33600328EC8 /* SyntaxRollbackSTMT.cpp in Sources */,\n\t\t\t\t037C39DE2897E33600328EC8 /* HandleStatement.cpp in Sources */,\n\t\t\t\t7525176E2B12FDC700485175 /* ZSTDContext.cpp in Sources */,\n\t\t\t\t0373310C289A94E00030C113 /* PreparedStatement.cpp in Sources */,\n\t\t\t\t037C39E02897E33600328EC8 /* CoreFunction.cpp in Sources */,\n\t\t\t\t037C39E52897E33600328EC8 /* FactoryRenewer.cpp in Sources */,\n\t\t\t\t037C39E62897E33600328EC8 /* TokenizerModule.cpp in Sources */,\n\t\t\t\t037C39E72897E33600328EC8 /* SyntaxFrameSpec.cpp in Sources */,\n\t\t\t\t037C39E92897E33600328EC8 /* SyntaxTableOrSubquery.cpp in Sources */,\n\t\t\t\t037C39EC2897E33600328EC8 /* Time.cpp in Sources */,\n\t\t\t\t037C39F02897E33600328EC8 /* StatementVacuum.cpp in Sources */,\n\t\t\t\t037C39F12897E33600328EC8 /* AbstractHandle.cpp in Sources */,\n\t\t\t\t037C39F52897E33600328EC8 /* StatementExplain.cpp in Sources */,\n\t\t\t\t037C39F62897E33600328EC8 /* CommonCore.cpp in Sources */,\n\t\t\t\t037C39F72897E33600328EC8 /* SyntaxIndexedColumn.cpp in Sources */,\n\t\t\t\t037C39F92897E33600328EC8 /* Pager.cpp in Sources */,\n\t\t\t\t037C39FF2897E33600328EC8 /* Console.cpp in Sources */,\n\t\t\t\t754211F72B12359400A2FF4D /* ScalarFunctionConfig.cpp in Sources */,\n\t\t\t\t037C3A012897E33600328EC8 /* Upsert.cpp in Sources */,\n\t\t\t\t037C3A022897E33600328EC8 /* MasterItem.cpp in Sources */,\n\t\t\t\t037C3A032897E33600328EC8 /* StatementDropIndex.cpp in Sources */,\n\t\t\t\t037C3A042897E33600328EC8 /* WCDBError.cpp in Sources */,\n\t\t\t\t037C3A052897E33600328EC8 /* StatementInsert.cpp in Sources */,\n\t\t\t\t037C3A062897E33600328EC8 /* SubstringMatchInfo.cpp in Sources */,\n\t\t\t\t037C3A092897E33600328EC8 /* Assemble.cpp in Sources */,\n\t\t\t\t7533CB5B2B050FB200C8B47D /* MigratingStatementDecorator.cpp in Sources */,\n\t\t\t\t037C3A0A2897E33600328EC8 /* Cell.cpp in Sources */,\n\t\t\t\t037C3A0C2897E33600328EC8 /* AuxiliaryFunctionConfig.cpp in Sources */,\n\t\t\t\t037C3A112897E33600328EC8 /* Frame.cpp in Sources */,\n\t\t\t\t75B698D5290AD4C0006E1F8F /* BaseTokenizerUtil.cpp in Sources */,\n\t\t\t\t037C3A132897E33600328EC8 /* Path.cpp in Sources */,\n\t\t\t\t75294DB129C75058005E7FC0 /* OperationQueueForMemory.cpp in Sources */,\n\t\t\t\t037C3A142897E33600328EC8 /* CommonTableExpression.cpp in Sources */,\n\t\t\t\t037C3A162897E33600328EC8 /* PerformanceTraceConfig.cpp in Sources */,\n\t\t\t\t0D5363EA290A65390026A4DC /* Master.cpp in Sources */,\n\t\t\t\t037C3A172897E33600328EC8 /* StatementCommit.cpp in Sources */,\n\t\t\t\t037C3A1A2897E33600328EC8 /* AutoCheckpointConfig.cpp in Sources */,\n\t\t\t\t037C3A1D2897E33600328EC8 /* Filter.cpp in Sources */,\n\t\t\t\t037C3A1E2897E33600328EC8 /* Thread.cpp in Sources */,\n\t\t\t\t037C3A1F2897E33600328EC8 /* OperationQueue.cpp in Sources */,\n\t\t\t\t037C3A202897E33600328EC8 /* AutoMergeFTSIndexConfig.cpp in Sources */,\n\t\t\t\t037C3A222897E33600328EC8 /* QualifiedTable.cpp in Sources */,\n\t\t\t\t037C3A242897E33600328EC8 /* BasicConfig.cpp in Sources */,\n\t\t\t\t037C3A252897E33600328EC8 /* StatementPragma.cpp in Sources */,\n\t\t\t\t037C3A262897E33600328EC8 /* MergeFTSIndexLogic.cpp in Sources */,\n\t\t\t\t037C3A272897E33600328EC8 /* SyntaxAnalyzeSTMT.cpp in Sources */,\n\t\t\t\t752517772B132DAB00485175 /* CompressionConst.cpp in Sources */,\n\t\t\t\t037C3A292897E33600328EC8 /* SyntaxQualifiedTableName.cpp in Sources */,\n\t\t\t\t037C3A2A2897E33600328EC8 /* SyntaxSchema.cpp in Sources */,\n\t\t\t\t75A60AB129345A38009C1B3C /* Cipher.cpp in Sources */,\n\t\t\t\t037C3A302897E33600328EC8 /* ColumnMeta.cpp in Sources */,\n\t\t\t\t037C3A312897E33600328EC8 /* UnsafeData.cpp in Sources */,\n\t\t\t\t037C3A322897E33600328EC8 /* ColumnDef.cpp in Sources */,\n\t\t\t\t03733110289A94F10030C113 /* Handle.cpp in Sources */,\n\t\t\t\t037C3A342897E33600328EC8 /* TableConstraint.cpp in Sources */,\n\t\t\t\t037C3A352897E33600328EC8 /* SyntaxColumnConstraint.cpp in Sources */,\n\t\t\t\t753636DC28BBC3820025C2C4 /* Table.cpp in Sources */,\n\t\t\t\t037C3A362897E33600328EC8 /* Repairman.cpp in Sources */,\n\t\t\t\t037C3A372897E33600328EC8 /* StatementBegin.cpp in Sources */,\n\t\t\t\t037C3A392897E33600328EC8 /* MigrationInfo.cpp in Sources */,\n\t\t\t\t037C3A3A2897E33600328EC8 /* Material.cpp in Sources */,\n\t\t\t\t754212142B124CFF00A2FF4D /* CompressionCenter.cpp in Sources */,\n\t\t\t\t037C3A3B2897E33600328EC8 /* ForeignKey.cpp in Sources */,\n\t\t\t\t0DE08A2B29CBEB4E009A7CA3 /* WCTFileManager.cpp in Sources */,\n\t\t\t\t037C3A3D2897E33600328EC8 /* Crawlable.cpp in Sources */,\n\t\t\t\t037C3A402897E33600328EC8 /* AggregateFunction.cpp in Sources */,\n\t\t\t\t037C3A412897E33600328EC8 /* SQLiteBase.cpp in Sources */,\n\t\t\t\t037C3A422897E33600328EC8 /* Join.cpp in Sources */,\n\t\t\t\t037C3A432897E33600328EC8 /* SyntaxCreateTableSTMT.cpp in Sources */,\n\t\t\t\t037C3A452897E33600328EC8 /* FTSError.cpp in Sources */,\n\t\t\t\t037C3A462897E33600328EC8 /* SyntaxDropIndexSTMT.cpp in Sources */,\n\t\t\t\t037C3A482897E33600328EC8 /* HandleRelated.cpp in Sources */,\n\t\t\t\t754359522B0671DE00CDF232 /* BackupHandleOperator.cpp in Sources */,\n\t\t\t\t037C3A492897E33600328EC8 /* SyntaxIdentifier.cpp in Sources */,\n\t\t\t\t037C3A4A2897E33600328EC8 /* SyntaxBindParameter.cpp in Sources */,\n\t\t\t\t03321E8728A503F3000AFD6D /* StatementOperation.cpp in Sources */,\n\t\t\t\t75F32F2828BA31CD00A72697 /* ResultField.cpp in Sources */,\n\t\t\t\t037C3A4B2897E33600328EC8 /* SyntaxDetachSTMT.cpp in Sources */,\n\t\t\t\t03D077FC28C20FEE009A3B18 /* Delete.cpp in Sources */,\n\t\t\t\t037C3A4C2897E33600328EC8 /* Page.cpp in Sources */,\n\t\t\t\t037C3A502897E33600328EC8 /* SyntaxOrderingTerm.cpp in Sources */,\n\t\t\t\t037C3A522897E33600328EC8 /* Serialization.cpp in Sources */,\n\t\t\t\t037C3A562897E33600328EC8 /* PorterStemming.c in Sources */,\n\t\t\t\t037C3A592897E33600328EC8 /* SQLiteAssembler.cpp in Sources */,\n\t\t\t\t037C3A5C2897E33600328EC8 /* FileHandle.cpp in Sources */,\n\t\t\t\t037C3A612897E33600328EC8 /* SyntaxJoinConstraint.cpp in Sources */,\n\t\t\t\t037C3A632897E33600328EC8 /* SyntaxReleaseSTMT.cpp in Sources */,\n\t\t\t\t037C3A662897E33600328EC8 /* Schema.cpp in Sources */,\n\t\t\t\t03D077F928C1FB48009A3B18 /* HandleORMOperation.cpp in Sources */,\n\t\t\t\t037C3A672897E33600328EC8 /* MasterCrawler.cpp in Sources */,\n\t\t\t\t037C3A682897E33600328EC8 /* StatementReindex.cpp in Sources */,\n\t\t\t\t7537E58528B91F510077D92B /* Accessor.cpp in Sources */,\n\t\t\t\t037C3A6C2897E33600328EC8 /* Wal.cpp in Sources */,\n\t\t\t\t037C3A722897E33600328EC8 /* BusyRetryConfig.cpp in Sources */,\n\t\t\t\t037C3A742897E33600328EC8 /* SyntaxSelectSTMT.cpp in Sources */,\n\t\t\t\t037C3A752897E33600328EC8 /* InnerHandle.cpp in Sources */,\n\t\t\t\t037C3A772897E33600328EC8 /* Lock.cpp in Sources */,\n\t\t\t\t754212182B124CFF00A2FF4D /* ZSTDDict.cpp in Sources */,\n\t\t\t\t037C3A7A2897E33600328EC8 /* SyntaxSelectCore.cpp in Sources */,\n\t\t\t\t7525175D2B12D43700485175 /* DecompressFunction.cpp in Sources */,\n\t\t\t\t037C3A7D2897E33600328EC8 /* StatementRelease.cpp in Sources */,\n\t\t\t);\n\t\t\trunOnlyForDeploymentPostprocessing = 0;\n\t\t};\n\t\t03BF4ABC2888F87C00A30500 /* Sources */ = {\n\t\t\tisa = PBXSourcesBuildPhase;\n\t\t\tbuildActionMask = 2147483647;\n\t\t\tfiles = (\n\t\t\t\t03BF4B362888F98300A30500 /* BaselineBenchmark.mm in Sources */,\n\t\t\t\t03BF4B352888F97F00A30500 /* ObjectsBasedBenchmark.mm in Sources */,\n\t\t\t\t03BF4B472888FA6700A30500 /* AllTypesObject.mm in Sources */,\n\t\t\t\t03BF4B422888FA4500A30500 /* TableTestCase.mm in Sources */,\n\t\t\t\t03BF4B232888F8F800A30500 /* SyncWriteBenchmark.swift in Sources */,\n\t\t\t\t03BF4B442888FA5E00A30500 /* ObjectsBasedFactory.mm in Sources */,\n\t\t\t\t03BF4B482888FA6B00A30500 /* TestCaseObject.mm in Sources */,\n\t\t\t\t03BF4B262888F90400A30500 /* BaselineWriteBenchmark.swift in Sources */,\n\t\t\t\t758DC8022B255EBF00E71D9B /* CompressionBenchmark.mm in Sources */,\n\t\t\t\t03BF4B372888F98600A30500 /* CipherBenchmark.mm in Sources */,\n\t\t\t\t03BF4B2D2888F91B00A30500 /* BaseMultithreadBenchmark.swift in Sources */,\n\t\t\t\t03BF4B4B2888FA7500A30500 /* Random+WCDB.mm in Sources */,\n\t\t\t\t03BF4B412888FA4300A30500 /* BaseTestCase.mm in Sources */,\n\t\t\t\t03BF4B342888F95C00A30500 /* TestObject.swift in Sources */,\n\t\t\t\t03BF4B432888FA5C00A30500 /* PrototypeFactory.mm in Sources */,\n\t\t\t\t03BF4B2A2888F91100A30500 /* BenchmarkObject.swift in Sources */,\n\t\t\t\t03BF4B402888FA4000A30500 /* CRUDTestCase.mm in Sources */,\n\t\t\t\t03BF4B242888F8FC00A30500 /* CipherWriteBenchmark.swift in Sources */,\n\t\t\t\t03BF4B2F2888F92200A30500 /* MultithreadReadReadBenchmark.swift in Sources */,\n\t\t\t\t03BF4B4F2888FA8100A30500 /* TestCaseCounter.mm in Sources */,\n\t\t\t\t03BF4B2C2888F91800A30500 /* RandomData.swift in Sources */,\n\t\t\t\t03BF4B4D2888FA7C00A30500 /* NSObject+TestCase.mm in Sources */,\n\t\t\t\t03BF4B3D2888FA3000A30500 /* Benchmark.mm in Sources */,\n\t\t\t\t0D71F9352A8B377100F7B4F6 /* Random.swift in Sources */,\n\t\t\t\t759362CC2B368D87000AF163 /* VacuumBenchmark.mm in Sources */,\n\t\t\t\t03BF4B332888F95800A30500 /* Convenience.swift in Sources */,\n\t\t\t\t03BF4B522888FA8900A30500 /* WCTDatabase+TestCase.mm in Sources */,\n\t\t\t\t03BF4B3A2888F99200A30500 /* MigrationBenchmark.mm in Sources */,\n\t\t\t\t03BF4B252888F90000A30500 /* CipherReadBenchmark.swift in Sources */,\n\t\t\t\t03BF4B292888F90E00A30500 /* BaseBenchmark.swift in Sources */,\n\t\t\t\t03BF4B4A2888FA7300A30500 /* Random+TestCaseObject.mm in Sources */,\n\t\t\t\t03BF4B532888FAA600A30500 /* DatabaseTestCase.mm in Sources */,\n\t\t\t\t03BF4B322888F95600A30500 /* BaseTestCase.swift in Sources */,\n\t\t\t\t753473612935C1E400911FCA /* DatabaseTestCase.swift in Sources */,\n\t\t\t\t03BF4B4E2888FA7F00A30500 /* Signpost.mm in Sources */,\n\t\t\t\t03BF4B462888FA6400A30500 /* TablesBasedFactory.mm in Sources */,\n\t\t\t\t03BF4B312888F95300A30500 /* Assert.swift in Sources */,\n\t\t\t\t03BF4B3B2888F99500A30500 /* TableMigrationBenchmark.mm in Sources */,\n\t\t\t\t03BF4B512888FA8600A30500 /* TestCaseResult.mm in Sources */,\n\t\t\t\t758DC8072B25678800E71D9B /* DictCompressionBenchmark.mm in Sources */,\n\t\t\t\t03BF4B282888F90A00A30500 /* BaselineReadBenchmark.swift in Sources */,\n\t\t\t\t03BF4B2E2888F91F00A30500 /* MultithreadReadWriteBenchmark.swift in Sources */,\n\t\t\t\t03BF4B3C2888F99800A30500 /* DatabaseMigrationBenchmark.mm in Sources */,\n\t\t\t\t758DC8052B25671E00E71D9B /* NormalCompressionBenchmark.mm in Sources */,\n\t\t\t\t03BF4B452888FA6100A30500 /* SizeBasedFactory.mm in Sources */,\n\t\t\t\t03BF4B502888FA8300A30500 /* TestCaseLog.mm in Sources */,\n\t\t\t\t03BF4B4C2888FA7A00A30500 /* Dispatch.mm in Sources */,\n\t\t\t\t03BF4B2B2888F91400A30500 /* Config.swift in Sources */,\n\t\t\t\t03BF4B302888F92500A30500 /* MultithreadWriteWriteBenchmark.swift in Sources */,\n\t\t\t\t03BF4B392888F98D00A30500 /* TableBenchmark.mm in Sources */,\n\t\t\t\t03BF4B492888FA7000A30500 /* Random.mm in Sources */,\n\t\t\t\t03BF4B382888F98900A30500 /* RetrieveBenchmark.mm in Sources */,\n\t\t\t\t03BF4B222888F8EC00A30500 /* InitializationBenchmark.swift in Sources */,\n\t\t\t\t03BF4B272888F90700A30500 /* BaselineBatchWriteBenchmark.swift in Sources */,\n\t\t\t);\n\t\t\trunOnlyForDeploymentPostprocessing = 0;\n\t\t};\n\t\t03E5CB9E28A38CCA005353D9 /* Sources */ = {\n\t\t\tisa = PBXSourcesBuildPhase;\n\t\t\tbuildActionMask = 2147483647;\n\t\t\tfiles = (\n\t\t\t\t032E121528C8A3B700BCACE0 /* CPPTestCaseObject.cpp in Sources */,\n\t\t\t\t752C7E3D28C8E16800C9FFA6 /* ORMDeleteTests.mm in Sources */,\n\t\t\t\t03239D6428C60F5C00C8D691 /* CPPTableConstraintObject.cpp in Sources */,\n\t\t\t\t03E5CC5328A38F0F005353D9 /* TestCaseCounter.mm in Sources */,\n\t\t\t\t03E5CC6728A3B083005353D9 /* CPPFileTests.mm in Sources */,\n\t\t\t\t03E5CC5628A38F0F005353D9 /* TestCaseLog.mm in Sources */,\n\t\t\t\t751CA67728C64B7B00874A7A /* CPPAllTypesObject.mm in Sources */,\n\t\t\t\t75535246290E63E5008376AB /* CPPFTS5Tests.mm in Sources */,\n\t\t\t\t0DE2D9A32AEB934E005420D3 /* CPPTableTest.mm in Sources */,\n\t\t\t\t75882C8728C7C55200F95947 /* CPPColumnConstraintAutoIncrement.cpp in Sources */,\n\t\t\t\t0D36C1012AF1F492000BC0DD /* CPPWCDBOptionalAllTypesObject.mm in Sources */,\n\t\t\t\t75D4834928A7C42F004FDD3C /* Random+CPPTestObject.mm in Sources */,\n\t\t\t\t032E112E28C8768C00BCACE0 /* CPPNewlyCreatedTableIndexObject.cpp in Sources */,\n\t\t\t\t753C084A28A8B0110042C427 /* CPPDatabaseTest.mm in Sources */,\n\t\t\t\t03E5CC6B28A3B6A4005353D9 /* CPPConfigTests.mm in Sources */,\n\t\t\t\t75882C8D28C7C6CF00F95947 /* CPPColumnConstraintUnique.cpp in Sources */,\n\t\t\t\t75882C8428C7C4A300F95947 /* CPPColumnConstraintPrimaryDesc.cpp in Sources */,\n\t\t\t\t752C7E4028C8E94200C9FFA6 /* ORMInsertTests.mm in Sources */,\n\t\t\t\t75D4834228A79AD3004FDD3C /* CPPTraceTest.mm in Sources */,\n\t\t\t\t756E89032AF13FDB00A54DB2 /* CPPSharedPtrAllTypesObject.mm in Sources */,\n\t\t\t\t0D81CDAE2A56DA070051FF8E /* CPPColumnConstraintEnablePrimaryAutoIncrement.cpp in Sources */,\n\t\t\t\t75CD724F290D2449008583A3 /* CPPFTS3Object.mm in Sources */,\n\t\t\t\t032E112428C8511E00BCACE0 /* CPPIndexObject.cpp in Sources */,\n\t\t\t\t758D9D0128BA6AF8001B3D2D /* HandleOperationTests.mm in Sources */,\n\t\t\t\t753C084D28A8D4560042C427 /* StatementOperationTests.mm in Sources */,\n\t\t\t\t75DF22972AEE8483006A3311 /* CPPInheritObject.cpp in Sources */,\n\t\t\t\t03E5CC5728A38F0F005353D9 /* TestCaseResult.mm in Sources */,\n\t\t\t\t0344BA8128C9DC7D000BC154 /* ORMUpdateTests.mm in Sources */,\n\t\t\t\t0D36C0FB2AF1E3B1000BC0DD /* CPPSTDOptionalAllTypesObject.mm in Sources */,\n\t\t\t\t03E5CC5928A38FFF005353D9 /* CPPBaseTestCase.mm in Sources */,\n\t\t\t\t03E5CC6028A3A189005353D9 /* CPPDatabaseTestCase.mm in Sources */,\n\t\t\t\t032E112B28C874F500BCACE0 /* CPPNewRemapObject.cpp in Sources */,\n\t\t\t\t03239D6628C6153F00C8D691 /* CPPORMTests.mm in Sources */,\n\t\t\t\t03B4DB1628C98E5E00F64141 /* ORMSelectTests.mm in Sources */,\n\t\t\t\t032E112828C8724A00BCACE0 /* CPPOldRemapObject.cpp in Sources */,\n\t\t\t\t03E5CC5228A38F0F005353D9 /* Signpost.mm in Sources */,\n\t\t\t\t75882C8A28C7C60C00F95947 /* CPPColumnConstraintAutoIncrementAsc.cpp in Sources */,\n\t\t\t\t75535243290E620F008376AB /* CPPFTS5Object.mm in Sources */,\n\t\t\t\t75E76AE42917AE2A00073CCA /* CPPVirtualTableFTS4Object.cpp in Sources */,\n\t\t\t\t75882C7D28C7C2EF00F95947 /* CPPColumnConstraintPrimary.cpp in Sources */,\n\t\t\t\t03E5CC6928A3B603005353D9 /* NSObject+TestCase.mm in Sources */,\n\t\t\t\t75D4834528A7A827004FDD3C /* CPPTableTestCase.mm in Sources */,\n\t\t\t\t75882C9028C7C78200F95947 /* CPPColumnConstraintDefault.cpp in Sources */,\n\t\t\t\t03E5CC6428A3A2B4005353D9 /* Random+WCDB.mm in Sources */,\n\t\t\t\t032E113128C8782600BCACE0 /* CPPDropIndexObject.cpp in Sources */,\n\t\t\t\t75E76AE72917B07E00073CCA /* CPPVirtualTableFTS5Object.cpp in Sources */,\n\t\t\t\t03E5CC5428A38F0F005353D9 /* Random.mm in Sources */,\n\t\t\t\t75C075342A8921C600B4A0D4 /* CPPHandleTest.mm in Sources */,\n\t\t\t\t75882C8128C7C3E600F95947 /* CPPColumnConstraintPrimaryAsc.cpp in Sources */,\n\t\t\t\t7547A3CF290D2B2600AFA132 /* CPPFTS3Tests.mm in Sources */,\n\t\t\t\t0344BACB28CA0589000BC154 /* ChainCallTests.mm in Sources */,\n\t\t\t\t75E50AC22908EC7100B73E62 /* ORMMultiSelectTests.mm in Sources */,\n\t\t\t\t03E5CC5528A38F0F005353D9 /* Dispatch.mm in Sources */,\n\t\t\t\t753C085028A8D5F70042C427 /* CPPCRUDTestCase.mm in Sources */,\n\t\t\t);\n\t\t\trunOnlyForDeploymentPostprocessing = 0;\n\t\t};\n\t\t234F0358227A9CFE00DD65A2 /* Sources */ = {\n\t\t\tisa = PBXSourcesBuildPhase;\n\t\t\tbuildActionMask = 2147483647;\n\t\t\tfiles = (\n\t\t\t\t0D47A9772A6E333D008E9E2C /* MigrationTestObjectBase.mm in Sources */,\n\t\t\t\t234F06D3227AA57D00DD65A2 /* ColumnConstraintNotNull.mm in Sources */,\n\t\t\t\t234F05F6227AA4F600DD65A2 /* StatementCreateTriggerTests.mm in Sources */,\n\t\t\t\t234F060C227AA4F600DD65A2 /* StatementCommitTests.mm in Sources */,\n\t\t\t\t0D2789D92B21995800F60E2D /* CompressionTests.mm in Sources */,\n\t\t\t\t234F0615227AA4F600DD65A2 /* ColumnTests.mm in Sources */,\n\t\t\t\t234F0610227AA4F600DD65A2 /* SyntaxListTests.mm in Sources */,\n\t\t\t\t234F04B1227A9EFA00DD65A2 /* ConfigTests.mm in Sources */,\n\t\t\t\t234F06F9227AA59E00DD65A2 /* ThreadTests.mm in Sources */,\n\t\t\t\t234F0737227AA5C700DD65A2 /* BackupTestCase.mm in Sources */,\n\t\t\t\t39327B6322CF275200AABD4B /* Dispatch.mm in Sources */,\n\t\t\t\t234F0527227A9EFA00DD65A2 /* ORMTests.mm in Sources */,\n\t\t\t\t751FE4E72B1E10F200BFC7AD /* CompressingCRUDTest.mm in Sources */,\n\t\t\t\t7522B5322A6D78BB00B465D6 /* NormalMigrationObject.mm in Sources */,\n\t\t\t\t234F05FB227AA4F600DD65A2 /* StatementVacuumTests.mm in Sources */,\n\t\t\t\t234F05E7227AA4F600DD65A2 /* CoreFunctionTests.mm in Sources */,\n\t\t\t\t234F0604227AA4F600DD65A2 /* StatementDropViewTests.mm in Sources */,\n\t\t\t\t234F0609227AA4F600DD65A2 /* StatementCreateIndexTests.mm in Sources */,\n\t\t\t\t234F0608227AA4F600DD65A2 /* StatementAttachTests.mm in Sources */,\n\t\t\t\t0D0CD7A12A6FBE0C00F89C6B /* MigrateTests.mm in Sources */,\n\t\t\t\t0DE68B362AB45C27008BD74C /* RepairTestObjectBase.mm in Sources */,\n\t\t\t\t234F063D227AA50800DD65A2 /* ColumnCodingObject.mm in Sources */,\n\t\t\t\t234F06A6227AA55400DD65A2 /* AdditionalORMObject.mm in Sources */,\n\t\t\t\t234F05F3227AA4F600DD65A2 /* ExpressionTests.mm in Sources */,\n\t\t\t\t234F04FA227A9EFA00DD65A2 /* HandleTests.mm in Sources */,\n\t\t\t\t234F06FA227AA59E00DD65A2 /* TransactionTests.mm in Sources */,\n\t\t\t\t0D0D56C1254ABEAA000F16A6 /* FTS5Object.mm in Sources */,\n\t\t\t\t0D0CD79F2A6FA1A900F89C6B /* CipherMigrationTests.mm in Sources */,\n\t\t\t\t234F063E227AA50800DD65A2 /* StringCodingObject+WCTColumnCoding.mm in Sources */,\n\t\t\t\t234F05DE227AA4F600DD65A2 /* FrameSpecTests.mm in Sources */,\n\t\t\t\t234F0603227AA4F600DD65A2 /* StatementSelectTests.mm in Sources */,\n\t\t\t\t7522B5242A6D5DD600B465D6 /* Random+MigrationTestObject.mm in Sources */,\n\t\t\t\t0D81CDAB2A569FAB0051FF8E /* ColumnConstraintEnablePrimaryAutoIncrement.mm in Sources */,\n\t\t\t\t234F06D2227AA57D00DD65A2 /* ColumnConstraintAutoIncrement.mm in Sources */,\n\t\t\t\t234F0641227AA50800DD65A2 /* DoubleCodingObject+WCTColumnCoding.mm in Sources */,\n\t\t\t\t234F06D9227AA57D00DD65A2 /* ColumnConstraintDefault.mm in Sources */,\n\t\t\t\t234F05F5227AA4F600DD65A2 /* ExpressionOperableTests.mm in Sources */,\n\t\t\t\t234F058D227AA4D700DD65A2 /* VersionTests.mm in Sources */,\n\t\t\t\t234F0601227AA4F600DD65A2 /* StatementReindexTests.mm in Sources */,\n\t\t\t\t7511EA50293CDAFB00FB033B /* NewPropertyObject.mm in Sources */,\n\t\t\t\t234F05FF227AA4F600DD65A2 /* StatementBeginTests.mm in Sources */,\n\t\t\t\t234F05EC227AA4F600DD65A2 /* ConflictTests.mm in Sources */,\n\t\t\t\t234F05FC227AA4F600DD65A2 /* RaiseFunctionTests.mm in Sources */,\n\t\t\t\t234F05ED227AA4F600DD65A2 /* WCTResultColumnTests.mm in Sources */,\n\t\t\t\t0DE68B3B2AB45F6C008BD74C /* NormalRepairTestObject.mm in Sources */,\n\t\t\t\t39327B9F22CF276600AABD4B /* ObjectsBasedFactory.mm in Sources */,\n\t\t\t\t234F05EF227AA4F600DD65A2 /* JoinConstraintTests.mm in Sources */,\n\t\t\t\t75E29CAF2B2F2F20003340FF /* VacuumTests.mm in Sources */,\n\t\t\t\t234F0607227AA4F600DD65A2 /* StatementDropIndexTests.mm in Sources */,\n\t\t\t\t234F06B6227AA57100DD65A2 /* PropertyObject.mm in Sources */,\n\t\t\t\t234F05F9227AA4F600DD65A2 /* StatementDetachTests.mm in Sources */,\n\t\t\t\t234F06D6227AA57D00DD65A2 /* ColumnConstraintCheck.mm in Sources */,\n\t\t\t\t234F05EB227AA4F600DD65A2 /* BindParameterTests.mm in Sources */,\n\t\t\t\t234F05DF227AA4F600DD65A2 /* FTSFunctionTests.mm in Sources */,\n\t\t\t\t39327BA322CF276600AABD4B /* PrototypeFactory.mm in Sources */,\n\t\t\t\t234F06DA227AA57D00DD65A2 /* ColumnConstraintUnique.mm in Sources */,\n\t\t\t\t39327B5F22CF275200AABD4B /* Signpost.mm in Sources */,\n\t\t\t\t3960D8A223192A9D00EF05D1 /* StatementExplainTests.mm in Sources */,\n\t\t\t\t39327B7322CF275200AABD4B /* WCTDatabase+TestCase.mm in Sources */,\n\t\t\t\t7522B51A2A6D3B3300B465D6 /* IntegerPrimaryKeyMigrationSourceObject.mm in Sources */,\n\t\t\t\t234F05F0227AA4F600DD65A2 /* TableOrSubqueryTests.mm in Sources */,\n\t\t\t\t234F06D7227AA57D00DD65A2 /* ColumnConstraintPrimaryDesc.mm in Sources */,\n\t\t\t\t234F06EC227AA58E00DD65A2 /* DropIndexObject.mm in Sources */,\n\t\t\t\t39327B5B22CF275200AABD4B /* NSObject+TestCase.mm in Sources */,\n\t\t\t\t39327B2722CF271F00AABD4B /* CRUDTestCase.mm in Sources */,\n\t\t\t\t234F05FA227AA4F600DD65A2 /* StatementAnalyzeTests.mm in Sources */,\n\t\t\t\t234F0735227AA5C700DD65A2 /* BackupTests.mm in Sources */,\n\t\t\t\t0DDF54292B32D18900DB3D65 /* VacuumRobustyTests.mm in Sources */,\n\t\t\t\t234F064B227AA51500DD65A2 /* FTS3Tests.mm in Sources */,\n\t\t\t\t234F05E9227AA4F600DD65A2 /* UpsertTests.mm in Sources */,\n\t\t\t\t03BF4B3F2888FA3C00A30500 /* Benchmark.mm in Sources */,\n\t\t\t\t234F06DE227AA58400DD65A2 /* IndexObject.mm in Sources */,\n\t\t\t\t234F05F8227AA4F600DD65A2 /* ColumnTypeTests.mm in Sources */,\n\t\t\t\t234F06F3227AA59600DD65A2 /* ConvenientDeleteTests.mm in Sources */,\n\t\t\t\t234F0646227AA50800DD65A2 /* Random+ColumnCodingObject.mm in Sources */,\n\t\t\t\t234F0595227AA4E200DD65A2 /* ObservationTests.mm in Sources */,\n\t\t\t\t7522B51E2A6D3C8600B465D6 /* AutoIncrementMigrationSourceObject.mm in Sources */,\n\t\t\t\t234F063F227AA50800DD65A2 /* StringCodingObject.m in Sources */,\n\t\t\t\t39327B8522CF275900AABD4B /* Random.mm in Sources */,\n\t\t\t\t39327BAB22CF276600AABD4B /* TablesBasedFactory.mm in Sources */,\n\t\t\t\t0DE68B412AB466F1008BD74C /* WithoutRowidRepairTestObject.mm in Sources */,\n\t\t\t\t234F05E0227AA4F600DD65A2 /* StatementTests.mm in Sources */,\n\t\t\t\t234F06EB227AA58E00DD65A2 /* OldRemapObject.mm in Sources */,\n\t\t\t\t234F0602227AA4F600DD65A2 /* FilterTests.mm in Sources */,\n\t\t\t\t234F061E227AA4F600DD65A2 /* TableConstraintTests.mm in Sources */,\n\t\t\t\t234F06D8227AA57D00DD65A2 /* ColumnConstraintPrimary.mm in Sources */,\n\t\t\t\t39327B6F22CF275200AABD4B /* TestCaseLog.mm in Sources */,\n\t\t\t\t234F061C227AA4F600DD65A2 /* ResultColumnTests.mm in Sources */,\n\t\t\t\t234F06AE227AA56300DD65A2 /* VirtualTableFTS4Object.mm in Sources */,\n\t\t\t\t39327B1F22CF271F00AABD4B /* BaseTestCase.mm in Sources */,\n\t\t\t\t03BF4B3E2888FA3800A30500 /* DatabaseTestCase.mm in Sources */,\n\t\t\t\t758E7F312B1C82F400319991 /* CompressionTestObject.mm in Sources */,\n\t\t\t\t234F0611227AA4F600DD65A2 /* CommonTableExpressionTests.mm in Sources */,\n\t\t\t\t234F0600227AA4F600DD65A2 /* SchemaTests.mm in Sources */,\n\t\t\t\t234F061B227AA4F600DD65A2 /* StatementRollbackTests.mm in Sources */,\n\t\t\t\t39327BA722CF276600AABD4B /* SizeBasedFactory.mm in Sources */,\n\t\t\t\t234F0642227AA50800DD65A2 /* DoubleCodingObject.m in Sources */,\n\t\t\t\t7522B5172A6D38D800B465D6 /* NormalMigrationSourceObject.mm in Sources */,\n\t\t\t\t234F05F4227AA4F600DD65A2 /* IndexedColumnTests.mm in Sources */,\n\t\t\t\t234F06AD227AA56300DD65A2 /* VirtualTableFTS5Object.mm in Sources */,\n\t\t\t\t234F058E227AA4D700DD65A2 /* TraceTests.mm in Sources */,\n\t\t\t\t234F05E5227AA4F600DD65A2 /* StatementDeleteTests.mm in Sources */,\n\t\t\t\t234F064C227AA51500DD65A2 /* FTS3Object.mm in Sources */,\n\t\t\t\t234F063B227AA50800DD65A2 /* IntegerCodingObject.m in Sources */,\n\t\t\t\t234F0598227AA4E200DD65A2 /* TableTests.mm in Sources */,\n\t\t\t\t234F0606227AA4F600DD65A2 /* ColumnDefTests.mm in Sources */,\n\t\t\t\t234F060A227AA4F600DD65A2 /* StatementUpdateTests.mm in Sources */,\n\t\t\t\t234F06F6227AA59600DD65A2 /* ConvenientInsertTests.mm in Sources */,\n\t\t\t\t234F05EE227AA4F600DD65A2 /* StatementSavepointTests.mm in Sources */,\n\t\t\t\t234F06B2227AA56B00DD65A2 /* TableConstraintObject.mm in Sources */,\n\t\t\t\t234F0509227A9EFA00DD65A2 /* ChainCallTests.mm in Sources */,\n\t\t\t\t234F0643227AA50800DD65A2 /* DataCodingObject.m in Sources */,\n\t\t\t\t234F05FE227AA4F600DD65A2 /* ColumnOperableTests.mm in Sources */,\n\t\t\t\t7522B5212A6D592800B465D6 /* MigrationTestCase.mm in Sources */,\n\t\t\t\t0DDF542B2B32D3EC00DB3D65 /* RobustyTestCase.mm in Sources */,\n\t\t\t\t234F0594227AA4E200DD65A2 /* DatabaseTests.mm in Sources */,\n\t\t\t\t7522B5332A6D78BB00B465D6 /* AutoIncrementMigrationObject.mm in Sources */,\n\t\t\t\t234F0619227AA4F600DD65A2 /* OrderTests.mm in Sources */,\n\t\t\t\t234F05F2227AA4F600DD65A2 /* WINQAssertion.mm in Sources */,\n\t\t\t\t39327B9322CF276000AABD4B /* AllTypesObject.mm in Sources */,\n\t\t\t\t234F05DD227AA4F600DD65A2 /* StatementAlterTableTests.mm in Sources */,\n\t\t\t\t234F0739227AA5C700DD65A2 /* RetrieveTests.mm in Sources */,\n\t\t\t\t234F061D227AA4F600DD65A2 /* StatementDropTriggerTests.mm in Sources */,\n\t\t\t\t234F060F227AA4F600DD65A2 /* StatementCreateViewTests.mm in Sources */,\n\t\t\t\t234F0613227AA4F600DD65A2 /* WCTPropertyTests.mm in Sources */,\n\t\t\t\t234F06F5227AA59600DD65A2 /* ConvenientSelectTests.mm in Sources */,\n\t\t\t\t758E7F392B1C864700319991 /* Random+CompressionTestObject.mm in Sources */,\n\t\t\t\t234F061F227AA4F600DD65A2 /* PragmaTests.mm in Sources */,\n\t\t\t\t234F06D5227AA57D00DD65A2 /* ColumnConstraintAutoIncrementAsc.mm in Sources */,\n\t\t\t\t234F0738227AA5C700DD65A2 /* RetrieveRobustyTests.mm in Sources */,\n\t\t\t\t7522B5312A6D78BB00B465D6 /* IntegerPrimaryKeyMigrationObject.mm in Sources */,\n\t\t\t\t234F063C227AA50800DD65A2 /* IntegerCodingObject+WCTColumnCoding.mm in Sources */,\n\t\t\t\t234F060D227AA4F600DD65A2 /* WindowDefTests.mm in Sources */,\n\t\t\t\t234F0645227AA50800DD65A2 /* DataCodingObject+WCTColumnCoding.mm in Sources */,\n\t\t\t\t7522B5272A6D6F6700B465D6 /* MigratingCRUDTests.mm in Sources */,\n\t\t\t\t03D3A2A728A65D2F0064D4D4 /* ValueTests.mm in Sources */,\n\t\t\t\t234F05E1227AA4F600DD65A2 /* StatementPragmaTests.mm in Sources */,\n\t\t\t\t234F05E2227AA4F600DD65A2 /* ColumnConstraintTests.mm in Sources */,\n\t\t\t\t234F0596227AA4E200DD65A2 /* FileTests.mm in Sources */,\n\t\t\t\t234F0605227AA4F600DD65A2 /* StoppableIterationTests.mm in Sources */,\n\t\t\t\t234F060B227AA4F600DD65A2 /* AggregateFunctionTests.mm in Sources */,\n\t\t\t\t234F0508227A9EFA00DD65A2 /* MultiSelectTests.mm in Sources */,\n\t\t\t\t234F06F4227AA59600DD65A2 /* ConvenientUpdateTests.mm in Sources */,\n\t\t\t\t39327B7D22CF275900AABD4B /* Random+TestCaseObject.mm in Sources */,\n\t\t\t\t234F0612227AA4F600DD65A2 /* StatementDropTableTests.mm in Sources */,\n\t\t\t\t234F061A227AA4F600DD65A2 /* QualifiedTableTests.mm in Sources */,\n\t\t\t\t234F05F1227AA4F600DD65A2 /* StatementCreateVirtualTableTests.mm in Sources */,\n\t\t\t\t7522B4BF2A6D2EA900B465D6 /* MigrationTestObject.h in Sources */,\n\t\t\t\t39327B2B22CF271F00AABD4B /* TableTestCase.mm in Sources */,\n\t\t\t\t234F05EA227AA4F600DD65A2 /* OrderingTermTests.mm in Sources */,\n\t\t\t\t39327B8F22CF276000AABD4B /* TestCaseObject.mm in Sources */,\n\t\t\t\t0DE68B3E2AB461AA008BD74C /* AutoIncrementRepairTestObject.mm in Sources */,\n\t\t\t\t234F05E8227AA4F600DD65A2 /* StatementReleaseTests.mm in Sources */,\n\t\t\t\t39327B8122CF275900AABD4B /* Random+WCDB.mm in Sources */,\n\t\t\t\t0DAD8FF72B303D2A00372DBF /* CompressRobustyTests.mm in Sources */,\n\t\t\t\t39327B6B22CF275200AABD4B /* TestCaseCounter.mm in Sources */,\n\t\t\t\t758E7F3E2B1C99C700319991 /* CompressionTestCase.mm in Sources */,\n\t\t\t\t234F0640227AA50800DD65A2 /* ColumnCodingTests.mm in Sources */,\n\t\t\t\t234F06EE227AA58E00DD65A2 /* NewRemapObject.mm in Sources */,\n\t\t\t\t75D2A9BE2AB49C890024B8B2 /* Random+RepairTestObject.mm in Sources */,\n\t\t\t\t234F0617227AA4F600DD65A2 /* JoinTests.mm in Sources */,\n\t\t\t\t234F0618227AA4F600DD65A2 /* StatementInsertTests.mm in Sources */,\n\t\t\t\t234F0736227AA5C700DD65A2 /* DepositTests.mm in Sources */,\n\t\t\t\t234F060E227AA4F600DD65A2 /* LiteralValueTests.mm in Sources */,\n\t\t\t\t234F05F7227AA4F600DD65A2 /* StatementCreateTableTests.mm in Sources */,\n\t\t\t\t39327B6722CF275200AABD4B /* TestCaseResult.mm in Sources */,\n\t\t\t\t234F06D4227AA57D00DD65A2 /* ColumnConstraintPrimaryAsc.mm in Sources */,\n\t\t\t\t234F06ED227AA58E00DD65A2 /* NewlyCreatedTableIndexObject.mm in Sources */,\n\t\t\t\t0D0D56CA254AC0F0000F16A6 /* FTS5Test.mm in Sources */,\n\t\t\t\t234F05FD227AA4F600DD65A2 /* ForeignKeyTests.mm in Sources */,\n\t\t\t);\n\t\t\trunOnlyForDeploymentPostprocessing = 0;\n\t\t};\n\t\t234F8AD0227B0B5400791E45 /* Sources */ = {\n\t\t\tisa = PBXSourcesBuildPhase;\n\t\t\tbuildActionMask = 2147483647;\n\t\t\tfiles = (\n\t\t\t\t03E1677327F434E900D2C926 /* TracerTests.swift in Sources */,\n\t\t\t\t03E1677927F434E900D2C926 /* StatementCreateVirtualTableTests.swift in Sources */,\n\t\t\t\t03E8228E2844C0E70072CA57 /* CommonTableExpressionTests.swift in Sources */,\n\t\t\t\t75F4DE642884164E00760DC3 /* StatementCommitTests.swift in Sources */,\n\t\t\t\t03E167A627F434E900D2C926 /* SelectInterfaceTests.swift in Sources */,\n\t\t\t\t75A46C0B2843709500B58207 /* ColumnConstraintTests.swift in Sources */,\n\t\t\t\t03E1678027F434E900D2C926 /* StatementAlterTableTests.swift in Sources */,\n\t\t\t\t75EB196B287F08A300AA62F7 /* StatementDropTriggerTests.swift in Sources */,\n\t\t\t\t0D71F9362A8B659400F7B4F6 /* RandomData.swift in Sources */,\n\t\t\t\t03E1679527F434E900D2C926 /* StatementInsertTests.swift in Sources */,\n\t\t\t\t03E167AC27F434E900D2C926 /* TableConstraintBindingTests.swift in Sources */,\n\t\t\t\t03BFC5392852E9CB00673AE4 /* WindowDefTests.swift in Sources */,\n\t\t\t\t75AF6AE52854F32200A7C43D /* QualifiedTableTests.swift in Sources */,\n\t\t\t\t03E167A727F434E900D2C926 /* DeleteTests.swift in Sources */,\n\t\t\t\t75C075372A89234300B4A0D4 /* HandleTest.swift in Sources */,\n\t\t\t\t03E1677D27F434E900D2C926 /* StatementSavepointTests.swift in Sources */,\n\t\t\t\t03E167AE27F434E900D2C926 /* ColumnConstraintBindingTests.swift in Sources */,\n\t\t\t\t03E1679827F434E900D2C926 /* ColumnTypeTests.swift in Sources */,\n\t\t\t\t753473602935C1E400911FCA /* DatabaseTestCase.swift in Sources */,\n\t\t\t\t03E167A027F434E900D2C926 /* InsertInterfaceTests.swift in Sources */,\n\t\t\t\t03E1679C27F434E900D2C926 /* AdvanceTests.swift in Sources */,\n\t\t\t\t03E167B227F434E900D2C926 /* Convenience.swift in Sources */,\n\t\t\t\t03E167A527F434E900D2C926 /* MultiSelectTests.swift in Sources */,\n\t\t\t\t03E1678B27F434E900D2C926 /* StatementRollbackTests.swift in Sources */,\n\t\t\t\t03E1677627F434E900D2C926 /* StatementDetachTests.swift in Sources */,\n\t\t\t\t03E1679E27F434E900D2C926 /* RowSelectTests.swift in Sources */,\n\t\t\t\t03EE3DA728810C2000C8F0B3 /* StatementCreateTriggerTests.swift in Sources */,\n\t\t\t\t03E1677B27F434E900D2C926 /* StatementDeleteTests.swift in Sources */,\n\t\t\t\t75F4DE5A2884132F00760DC3 /* StatementBeginTests.swift in Sources */,\n\t\t\t\t03E1677C27F434E900D2C926 /* StatementExplainTests.swift in Sources */,\n\t\t\t\t03E1679427F434E900D2C926 /* IndexedColumnTests.swift in Sources */,\n\t\t\t\t03E1678927F434E900D2C926 /* ForeignKeyTests.swift in Sources */,\n\t\t\t\t03E1679927F434E900D2C926 /* AdvanceCRUDTests.swift in Sources */,\n\t\t\t\t03A57F16284089B800D2A4C3 /* SchemaTests.swift in Sources */,\n\t\t\t\t03E1678527F434E900D2C926 /* TableOrSubqueryTests.swift in Sources */,\n\t\t\t\t03E167A227F434E900D2C926 /* TypedTests.swift in Sources */,\n\t\t\t\t03E167AD27F434E900D2C926 /* VirtualTableBindingTests.swift in Sources */,\n\t\t\t\t75EB1A10287F0EB900AA62F7 /* StatementCreateViewTests.swift in Sources */,\n\t\t\t\t03E1677A27F434E900D2C926 /* StatementUpdateTests.swift in Sources */,\n\t\t\t\t03E167AF27F434E900D2C926 /* IndexBindingTests.swift in Sources */,\n\t\t\t\t03E167B027F434E900D2C926 /* Assert.swift in Sources */,\n\t\t\t\t75EB1A07287F0AFA00AA62F7 /* StatementDropViewTests.swift in Sources */,\n\t\t\t\t03E1679A27F434E900D2C926 /* TableTests.swift in Sources */,\n\t\t\t\t03E167A827F434E900D2C926 /* DeleteInterfaceTests.swift in Sources */,\n\t\t\t\t75CFB5DC293F30A200F97FA5 /* AutoAddColumnTests.swift in Sources */,\n\t\t\t\t03E1678627F434E900D2C926 /* StatementReindexTests.swift in Sources */,\n\t\t\t\t03E1677527F434E900D2C926 /* FileTests.swift in Sources */,\n\t\t\t\t03E1679B27F434E900D2C926 /* InsertTests.swift in Sources */,\n\t\t\t\t03E167A127F434E900D2C926 /* UpdateInterfaceTests.swift in Sources */,\n\t\t\t\t752594932851FCEF0068A602 /* RaiseFunctionTests.swift in Sources */,\n\t\t\t\t03E1678327F434E900D2C926 /* StatementAttachTests.swift in Sources */,\n\t\t\t\t03E1679227F434E900D2C926 /* StatementDropTableTests.swift in Sources */,\n\t\t\t\t03E1679727F434E900D2C926 /* ResultColumnTests.swift in Sources */,\n\t\t\t\t03E167A927F434E900D2C926 /* UpdateTests.swift in Sources */,\n\t\t\t\t03E1677E27F434E900D2C926 /* StatementDropIndexTests.swift in Sources */,\n\t\t\t\t03E1678D27F434E900D2C926 /* StatementReleaseTests.swift in Sources */,\n\t\t\t\t03E1679D27F434E900D2C926 /* MultithreadTests.swift in Sources */,\n\t\t\t\t03E1679327F434E900D2C926 /* StatementVacuumTests.swift in Sources */,\n\t\t\t\t03E1679F27F434E900D2C926 /* DatabaseTests.swift in Sources */,\n\t\t\t\t03E1677427F434E900D2C926 /* RepairTests.swift in Sources */,\n\t\t\t\t03E1677727F434E900D2C926 /* StatementCreateTableTests.swift in Sources */,\n\t\t\t\t03E167A327F434E900D2C926 /* TestObject.swift in Sources */,\n\t\t\t\t03E1678C27F434E900D2C926 /* ColumnTests.swift in Sources */,\n\t\t\t\t75AF6AF62855D21000A7C43D /* UpsertTests.swift in Sources */,\n\t\t\t\t0D71F9342A8B377100F7B4F6 /* Random.swift in Sources */,\n\t\t\t\t03E1677827F434E900D2C926 /* StatementSelectTests.swift in Sources */,\n\t\t\t\t03DCB5EB286C35A600CBC75D /* StatementAnalyzeTests.swift in Sources */,\n\t\t\t\t75195E812852454700EC8C1F /* FrameSpecTests.swift in Sources */,\n\t\t\t\t03A57F1F2840BEFF00D2A4C3 /* BindParameterTests.swift in Sources */,\n\t\t\t\t03E1677F27F434E900D2C926 /* TableConstraintTests.swift in Sources */,\n\t\t\t\t03E1678E27F434E900D2C926 /* StatementCreateIndexTests.swift in Sources */,\n\t\t\t\t03E1678227F434E900D2C926 /* LiteralValueTests.swift in Sources */,\n\t\t\t\t7543EDE3293B49CB00336DA9 /* ORMTestCase.swift in Sources */,\n\t\t\t\t75E76AE029176FA600073CCA /* TokenizerTests.swift in Sources */,\n\t\t\t\t03E167AB27F434E900D2C926 /* SelectTests.swift in Sources */,\n\t\t\t\t03E1678827F434E900D2C926 /* StatementPragmaTests.swift in Sources */,\n\t\t\t\t03E1679127F434E900D2C926 /* JoinTests.swift in Sources */,\n\t\t\t\t03E167A427F434E900D2C926 /* CRUDTestCase.swift in Sources */,\n\t\t\t\t03E1678F27F434E900D2C926 /* ExpressionTests.swift in Sources */,\n\t\t\t\t03E1678727F434E900D2C926 /* OrderingTermTests.swift in Sources */,\n\t\t\t\t03E167B127F434E900D2C926 /* BaseTestCase.swift in Sources */,\n\t\t\t\t03E1678127F434E900D2C926 /* ColumnDefTests.swift in Sources */,\n\t\t\t);\n\t\t\trunOnlyForDeploymentPostprocessing = 0;\n\t\t};\n\t\t2393265C1E836D7300D677CC /* Sources */ = {\n\t\t\tisa = PBXSourcesBuildPhase;\n\t\t\tbuildActionMask = 2147483647;\n\t\t\tfiles = (\n\t\t\t\t23EEDCA5217DFADC006E9E73 /* SQL.cpp in Sources */,\n\t\t\t\t23E7EB1D2123D58D0056B5D8 /* HighWater.cpp in Sources */,\n\t\t\t\t23EEDC6B217DFADC006E9E73 /* ConvertibleImplementation.cpp in Sources */,\n\t\t\t\t2376CB1B20DA5D3B00A68DB5 /* Scoreable.cpp in Sources */,\n\t\t\t\t75E0A5C02A7F4EEE00D4FE9A /* CoreConst.cpp in Sources */,\n\t\t\t\t23EEDCC5217DFADC006E9E73 /* StatementCreateView.cpp in Sources */,\n\t\t\t\t2316D93321057CA700707AFC /* MappedData.cpp in Sources */,\n\t\t\t\t23775B7620AD666900E21AB0 /* Backup.cpp in Sources */,\n\t\t\t\t03E1660227F42D6500D2C926 /* Operable.swift in Sources */,\n\t\t\t\t75EF25002AA33FEB0009C99F /* IncrementalMaterial.cpp in Sources */,\n\t\t\t\t03E1662827F42D6500D2C926 /* Master.swift in Sources */,\n\t\t\t\t03450E032738ED0200C4DC1B /* PinyinTokenizer.cpp in Sources */,\n\t\t\t\t03E1661227F42D6500D2C926 /* TableOrSubquery.swift in Sources */,\n\t\t\t\t75A46C072843273A00B58207 /* ColumnConstraint.swift in Sources */,\n\t\t\t\t2360A60320D78F2C00E4A311 /* SQLTraceConfig.cpp in Sources */,\n\t\t\t\t0D5363F1290A75F20026A4DC /* Sequence.cpp in Sources */,\n\t\t\t\t23EEDD11217DFADC006E9E73 /* SyntaxPragma.cpp in Sources */,\n\t\t\t\t03E165FF27F42D6500D2C926 /* ResultColumn.swift in Sources */,\n\t\t\t\t23D0C35120C149D80001BFAE /* Factory.cpp in Sources */,\n\t\t\t\t234DBD042064DE04000E31E8 /* WCTDatabase+Transaction.mm in Sources */,\n\t\t\t\t2396EB0E21801BD60079066C /* WCTResultColumn.mm in Sources */,\n\t\t\t\t75A60AAF29345A38009C1B3C /* Cipher.cpp in Sources */,\n\t\t\t\t3962FFC82305142A008934D4 /* Statement.cpp in Sources */,\n\t\t\t\t23D0C38D20C17CAE0001BFAE /* FactoryBackup.cpp in Sources */,\n\t\t\t\t75F3140D2AAC067B007FFDFB /* CipherHandle.cpp in Sources */,\n\t\t\t\t752594E5285226C00068A602 /* FrameSpecBridge.cpp in Sources */,\n\t\t\t\t23F70FD620A07CEC00CCE3CD /* CustomConfig.cpp in Sources */,\n\t\t\t\t23EEDCD3217DFADC006E9E73 /* StatementDropView.cpp in Sources */,\n\t\t\t\t2327BC22220944D80078A85B /* Config.cpp in Sources */,\n\t\t\t\t23DF0A0A2190275B00F0B2B6 /* WCTDatabase.mm in Sources */,\n\t\t\t\t232C6F03229C0A280046742F /* WCTOperationQueue.mm in Sources */,\n\t\t\t\t7521DDF42920A0E3009642EF /* HandleStatement+WCTTableCoding.swift in Sources */,\n\t\t\t\t23B4DC7E2111B39200954D71 /* Tag.cpp in Sources */,\n\t\t\t\t23EEDD53217DFADC006E9E73 /* SyntaxSavepointSTMT.cpp in Sources */,\n\t\t\t\t23EEDD3D217DFADC006E9E73 /* SyntaxDeleteSTMT.cpp in Sources */,\n\t\t\t\t23EEDD31217DFADC006E9E73 /* SyntaxCommitSTMT.cpp in Sources */,\n\t\t\t\t75CD026B28CF8EF90071B6C3 /* UpdateInterface.swift in Sources */,\n\t\t\t\t75EB1A0A287F0BDA00AA62F7 /* StatementCreateViewBridge.cpp in Sources */,\n\t\t\t\t03E1663727F42D6600D2C926 /* TableCodable.swift in Sources */,\n\t\t\t\t23775B6620AD666900E21AB0 /* Notifier.cpp in Sources */,\n\t\t\t\t75D566FE2951B7EA00098DD9 /* WCTSequence.mm in Sources */,\n\t\t\t\t03E165FD27F42D6500D2C926 /* StatementInsert.swift in Sources */,\n\t\t\t\t23EEDD47217DFADC006E9E73 /* SyntaxDropViewSTMT.cpp in Sources */,\n\t\t\t\t03E1662427F42D6500D2C926 /* StatementPragma.swift in Sources */,\n\t\t\t\t03E1661427F42D6500D2C926 /* Value.swift in Sources */,\n\t\t\t\t23EEDC97217DFADC006E9E73 /* OrderingTerm.cpp in Sources */,\n\t\t\t\t759362DA2B36D756000AF163 /* VacuumHandleOperator.cpp in Sources */,\n\t\t\t\t03E1661A27F42D6500D2C926 /* StatementRollback.swift in Sources */,\n\t\t\t\t23EEDC68217DFADC006E9E73 /* ColumnType.cpp in Sources */,\n\t\t\t\t2372E05921A2633800051D9A /* WCTTryDisposeGuard.mm in Sources */,\n\t\t\t\t23EEDCB9217DFADC006E9E73 /* StatementAttach.cpp in Sources */,\n\t\t\t\t23AD52E620DB852B00664B62 /* Fraction.cpp in Sources */,\n\t\t\t\t03E8228028447B940072CA57 /* ColumnDefBridge.cpp in Sources */,\n\t\t\t\t23EEDD1F217DFADC006E9E73 /* SyntaxTableConstraint.cpp in Sources */,\n\t\t\t\t23D07CEA20BE873E0043F4D4 /* SequenceCrawler.cpp in Sources */,\n\t\t\t\t75C440A2291D116C00D74EB7 /* VirtualTableConfig.swift in Sources */,\n\t\t\t\t75F4DE432883FD6A00760DC3 /* StatementReleaseBridge.cpp in Sources */,\n\t\t\t\t75EB1971287F0A2600AA62F7 /* StatementDropView.swift in Sources */,\n\t\t\t\t03E1663A27F42D6600D2C926 /* TableDecoder.swift in Sources */,\n\t\t\t\t03E1663927F42D6600D2C926 /* TableEncoder.swift in Sources */,\n\t\t\t\t23EEDCD1217DFADC006E9E73 /* StatementDropTrigger.cpp in Sources */,\n\t\t\t\t23EEDC6F217DFADC006E9E73 /* ExpressionOperable.cpp in Sources */,\n\t\t\t\t03E165FE27F42D6500D2C926 /* StatementDetach.swift in Sources */,\n\t\t\t\t23C7559120DCF90F00031A93 /* SQLiteLocker.cpp in Sources */,\n\t\t\t\t03E1660E27F42D6500D2C926 /* PreparedStatement.swift in Sources */,\n\t\t\t\t75ADC5642A8D1C2D00D0AC47 /* TableAttribute.cpp in Sources */,\n\t\t\t\t2370B11E21914ED500D3227C /* NSNumber+WCTColumnCoding.mm in Sources */,\n\t\t\t\t03E1661027F42D6500D2C926 /* Column.swift in Sources */,\n\t\t\t\t23EEDCE3217DFADC006E9E73 /* StatementUpdate.cpp in Sources */,\n\t\t\t\t23EEDD19217DFADC006E9E73 /* SyntaxResultColumn.cpp in Sources */,\n\t\t\t\t23AF4E1E20CD04E20050033C /* Initializeable.cpp in Sources */,\n\t\t\t\t2316D9432105D19500707AFC /* PageBasedFileHandle.cpp in Sources */,\n\t\t\t\t03E1660827F42D6500D2C926 /* OrderingTerm.swift in Sources */,\n\t\t\t\t7542121A2B124CFF00A2FF4D /* CompressionInfo.cpp in Sources */,\n\t\t\t\t23A6D4BF20BFD7F9004F2DAA /* Progress.cpp in Sources */,\n\t\t\t\t23775B7E20AD666900E21AB0 /* Mechanic.cpp in Sources */,\n\t\t\t\t7521DDEB29209D04009642EF /* Insert+WCTTableCoding.swift in Sources */,\n\t\t\t\t2349F7711EA0D6680021EFA7 /* WCTDatabase+Table.mm in Sources */,\n\t\t\t\t036E50B928115B1D007365CD /* WCTBridgeProperty.mm in Sources */,\n\t\t\t\t23EEDD57217DFADC006E9E73 /* SyntaxUpdateSTMT.cpp in Sources */,\n\t\t\t\t75F4DE3F2883F0A800760DC3 /* StatementReindexBridge.cpp in Sources */,\n\t\t\t\t03E1663227F42D6600D2C926 /* Selectable.swift in Sources */,\n\t\t\t\t2370B11A21914ED500D3227C /* NSDate+WCTColumnCoding.mm in Sources */,\n\t\t\t\t23EEDCBF217DFADC006E9E73 /* StatementCreateIndex.cpp in Sources */,\n\t\t\t\t23F340DB204D32C3007DB8AB /* WCTTable.mm in Sources */,\n\t\t\t\t23EEDCCB217DFADC006E9E73 /* StatementDetach.cpp in Sources */,\n\t\t\t\t75A46C00284310CE00B58207 /* ColumnConstraintBridge.cpp in Sources */,\n\t\t\t\t23EEDCB7217DFADC006E9E73 /* StatementAnalyze.cpp in Sources */,\n\t\t\t\t75C44098291CE24900D74EB7 /* IndexConfig.swift in Sources */,\n\t\t\t\t036E50C128116D7A007365CD /* WCTBridgeProperty.swift in Sources */,\n\t\t\t\t23EEDC71217DFADC006E9E73 /* FTSFunction.cpp in Sources */,\n\t\t\t\t2349F7071EA0D6680021EFA7 /* RecyclableHandle.cpp in Sources */,\n\t\t\t\t03C2EAED27F8382200B41169 /* ErrorBridge.swift in Sources */,\n\t\t\t\t03E165FC27F42D6500D2C926 /* StatementExplain.swift in Sources */,\n\t\t\t\t23EEDCA1217DFADC006E9E73 /* ResultColumn.cpp in Sources */,\n\t\t\t\t75EF250A2AA42DD90009C99F /* EncryptedSerialization.cpp in Sources */,\n\t\t\t\t75F4DE472884032600760DC3 /* StatementRollbackBridge.cpp in Sources */,\n\t\t\t\t23775B6A20AD666900E21AB0 /* FullCrawler.cpp in Sources */,\n\t\t\t\t23EEDD59217DFADC006E9E73 /* SyntaxVacuumSTMT.cpp in Sources */,\n\t\t\t\t75E0A5D62A7FE2A200D4FE9A /* ContainerBridge.cpp in Sources */,\n\t\t\t\t03E1660727F42D6500D2C926 /* ForeignKey.swift in Sources */,\n\t\t\t\t03E1662F27F42D6600D2C926 /* TableCRUDInterface.swift in Sources */,\n\t\t\t\t23EEDCC1217DFADC006E9E73 /* StatementCreateTable.cpp in Sources */,\n\t\t\t\t2360A5F920D78F1B00E4A311 /* HandleNotification.cpp in Sources */,\n\t\t\t\t23AD52DD20DB56D200664B62 /* SequenceItem.cpp in Sources */,\n\t\t\t\t7525C1562920ACD700FD34C7 /* TableInterface+WCTTableCoding.swift in Sources */,\n\t\t\t\t7543DD86271C2FD000B533B4 /* AuxiliaryFunctionModule.cpp in Sources */,\n\t\t\t\t75D99B8428CA46A400BEC8B5 /* BaseOperation.cpp in Sources */,\n\t\t\t\t234EF46F2015CFDE00B81929 /* WCTConvertible.mm in Sources */,\n\t\t\t\t03E1660D27F42D6500D2C926 /* StatementDropTable.swift in Sources */,\n\t\t\t\t23EEDCB5217DFADC006E9E73 /* StatementAlterTable.cpp in Sources */,\n\t\t\t\t23F70FAC20A055C300CCE3CD /* CipherConfig.cpp in Sources */,\n\t\t\t\t23D0C36320C14ACC0001BFAE /* FactoryRelated.cpp in Sources */,\n\t\t\t\t75C440A0291D108D00D74EB7 /* ForeignKeyConfig.swift in Sources */,\n\t\t\t\t235FBE9522914E0D005C7723 /* Global.cpp in Sources */,\n\t\t\t\t233A058C2062698E00F1A212 /* WCTHandle+ChainCall.mm in Sources */,\n\t\t\t\t750DC06C2913DE7300F19044 /* FTSBridge.cpp in Sources */,\n\t\t\t\t75C4409C291D0B4F00D74EB7 /* MultiUniqueConfig.swift in Sources */,\n\t\t\t\t75AF6AE9285594A100A7C43D /* ResultColumnBridge.cpp in Sources */,\n\t\t\t\t03EE3A51287FCECF00C8F0B3 /* StatementCreateTrigger.swift in Sources */,\n\t\t\t\t23EEDD45217DFADC006E9E73 /* SyntaxDropTriggerSTMT.cpp in Sources */,\n\t\t\t\t7525C1532920AB1900FD34C7 /* SelectInterface+WCTTableCoding.swift in Sources */,\n\t\t\t\t75AF6AF12855C8BF00A7C43D /* UpsertBridge.cpp in Sources */,\n\t\t\t\t23B4DCE12112B03C00954D71 /* AsyncQueue.cpp in Sources */,\n\t\t\t\t754211DC2B11FE9200A2FF4D /* ScalarFunctionModule.cpp in Sources */,\n\t\t\t\t23EEDD23217DFADC006E9E73 /* SyntaxUpsertClause.cpp in Sources */,\n\t\t\t\t39690195233B2235006EEFD4 /* WCTTable+Table.mm in Sources */,\n\t\t\t\t75A46C0F2843B3BC00B58207 /* OrderingTermBridge.cpp in Sources */,\n\t\t\t\t7525178D2B133DB700485175 /* CompressHandleOperator.cpp in Sources */,\n\t\t\t\t23EEDC83217DFADC006E9E73 /* Expression.cpp in Sources */,\n\t\t\t\t03D3A2A828A65F3E0064D4D4 /* Lock.swift in Sources */,\n\t\t\t\t23EEDD4B217DFADC006E9E73 /* SyntaxPragmaSTMT.cpp in Sources */,\n\t\t\t\t03E1663827F42D6600D2C926 /* CodingTableKey.swift in Sources */,\n\t\t\t\t39A3341B22B0DD9F008EA5D5 /* WCTFoundation.mm in Sources */,\n\t\t\t\t75CE3F002812E1A400E132F6 /* WCTAPIBridge.mm in Sources */,\n\t\t\t\t03261311283F5E0300836E0F /* WinqBridge.cpp in Sources */,\n\t\t\t\t0393BEE127F6EDAC0058B295 /* ErrorBridge.cpp in Sources */,\n\t\t\t\t03261364283F6CFB00836E0F /* Identifier.swift in Sources */,\n\t\t\t\t75C6E41729A0C2F0002579A5 /* WCDBOptional.cpp in Sources */,\n\t\t\t\t75C10345284530BF0006BBCB /* RaiseFunction.swift in Sources */,\n\t\t\t\t03DCB5E6286C2E5300CBC75D /* StatementAnalyzeBridge.cpp in Sources */,\n\t\t\t\t3995150722C2095B008394CC /* WCTOptional.mm in Sources */,\n\t\t\t\t03E1663627F42D6600D2C926 /* ColumnTypeDecoder.swift in Sources */,\n\t\t\t\t03E1663D27F42D6600D2C926 /* Redirectable.swift in Sources */,\n\t\t\t\t75F4DE332883E43C00760DC3 /* StatementExplainBridge.cpp in Sources */,\n\t\t\t\t23EEDC91217DFADC006E9E73 /* JoinConstraint.cpp in Sources */,\n\t\t\t\t75EB1965287F068200AA62F7 /* StatementDropTriggerBridge.cpp in Sources */,\n\t\t\t\t2349F75C1EA0D6680021EFA7 /* WCTRuntimeObjCAccessor.mm in Sources */,\n\t\t\t\t03DCB5F2286C480900CBC75D /* StatementCreateIndexBridge.cpp in Sources */,\n\t\t\t\t23301BF52298FE9A00A8AB5A /* AutoMigrateConfig.cpp in Sources */,\n\t\t\t\t23EEDCA9217DFADC006E9E73 /* TableOrSubquery.cpp in Sources */,\n\t\t\t\t23593B7D20D3ADF80058B416 /* WalRelated.cpp in Sources */,\n\t\t\t\t23EEDD2F217DFADC006E9E73 /* SyntaxBeginSTMT.cpp in Sources */,\n\t\t\t\t23EEDCF5217DFADC006E9E73 /* SyntaxCommonTableExpression.cpp in Sources */,\n\t\t\t\t03E1660627F42D6500D2C926 /* StatementCreateVirtualTable.swift in Sources */,\n\t\t\t\t23EEDCCF217DFADC006E9E73 /* StatementDropTable.cpp in Sources */,\n\t\t\t\t03E1663427F42D6600D2C926 /* Insert.swift in Sources */,\n\t\t\t\t23EEDCF9217DFADC006E9E73 /* SyntaxExpression.cpp in Sources */,\n\t\t\t\t23EEDCC7217DFADC006E9E73 /* StatementCreateVirtualTable.cpp in Sources */,\n\t\t\t\t23545BA22224EAA40091C981 /* SyntaxCommonConst.cpp in Sources */,\n\t\t\t\t23EEDCDF217DFADC006E9E73 /* StatementSavepoint.cpp in Sources */,\n\t\t\t\t236996B221D5C4FF00E72E81 /* Recyclable.cpp in Sources */,\n\t\t\t\t23775BCD20AD72BC00E21AB0 /* Data.cpp in Sources */,\n\t\t\t\t75C17A9328D0D3DD009C342E /* TransactionInterface.swift in Sources */,\n\t\t\t\t23EEDCFD217DFADC006E9E73 /* SyntaxForeignKeyClause.cpp in Sources */,\n\t\t\t\t23EEDC8D217DFADC006E9E73 /* IndexedColumn.cpp in Sources */,\n\t\t\t\t0D4F0F982AC572B20067027E /* WCTPerformanceInfo.mm in Sources */,\n\t\t\t\t75B698D6290AD4C0006E1F8F /* BaseTokenizerUtil.cpp in Sources */,\n\t\t\t\t23EEDC9D217DFADC006E9E73 /* RaiseFunction.cpp in Sources */,\n\t\t\t\t75AF6AD728544C8800A7C43D /* TableOrSubqueryBridge.cpp in Sources */,\n\t\t\t\t03D077FA28C1FB48009A3B18 /* HandleORMOperation.cpp in Sources */,\n\t\t\t\t23EEDC7B217DFADC006E9E73 /* ColumnConstraint.cpp in Sources */,\n\t\t\t\t2349F7591EA0D6680021EFA7 /* WCTRuntimeBaseAccessor.mm in Sources */,\n\t\t\t\t03AFD34D28B8BB7600EF5E56 /* Binding.cpp in Sources */,\n\t\t\t\t7525C1592920AD7900FD34C7 /* Table+WCTTableCoding.swift in Sources */,\n\t\t\t\t03E1662E27F42D6600D2C926 /* Table.swift in Sources */,\n\t\t\t\t2314AE7121070A1700244D39 /* Range.cpp in Sources */,\n\t\t\t\t234DBCF92064DD0C000E31E8 /* WCTHandle.mm in Sources */,\n\t\t\t\t23F1698C20B6638F009B5C47 /* ThreadedErrors.cpp in Sources */,\n\t\t\t\t03B6A33C2869C51B00D83EC4 /* StatementAlterTableBridge.cpp in Sources */,\n\t\t\t\t75AF6AED28559F4800A7C43D /* TableConstraintBridge.cpp in Sources */,\n\t\t\t\t75EB196E287F093B00AA62F7 /* StatementDropViewBridge.cpp in Sources */,\n\t\t\t\t75F4DE622884161200760DC3 /* StatementCommit.swift in Sources */,\n\t\t\t\t237908F721928C9F0098797F /* WCTObjCAccessor.mm in Sources */,\n\t\t\t\t23EEDCC3217DFADC006E9E73 /* StatementCreateTrigger.cpp in Sources */,\n\t\t\t\t23D96B922050DED700DB5E93 /* DatabasePool.cpp in Sources */,\n\t\t\t\t03BFC5D72853538400673AE4 /* IndexedColumnBridge.cpp in Sources */,\n\t\t\t\t236BACE721BF9FC900C8B4D9 /* WCTMigrationInfo.mm in Sources */,\n\t\t\t\t2304B42E22156E1500901953 /* TokenizerModules.cpp in Sources */,\n\t\t\t\t0DD8D1172B074C47002C97D3 /* MigrateHandleOperator.cpp in Sources */,\n\t\t\t\t03E1663327F42D6600D2C926 /* MultiSelect.swift in Sources */,\n\t\t\t\t03E1661127F42D6500D2C926 /* StatementUpdate.swift in Sources */,\n\t\t\t\t754212162B124CFF00A2FF4D /* ZSTDDict.cpp in Sources */,\n\t\t\t\t23D0C35520C149D80001BFAE /* FactoryDepositor.cpp in Sources */,\n\t\t\t\t03E1662B27F42D6600D2C926 /* Update.swift in Sources */,\n\t\t\t\t23A3CFB6205FB1A800692F94 /* WCTHandle+Convenient.mm in Sources */,\n\t\t\t\t75CD026F28CF8F5F0071B6C3 /* SelectInterface.swift in Sources */,\n\t\t\t\t75EB1968287F078E00AA62F7 /* StatementDropTrigger.swift in Sources */,\n\t\t\t\t7533CB4F2B050FA300C8B47D /* MigratingHandleDecorator.cpp in Sources */,\n\t\t\t\t75A46C0928432A5D00B58207 /* SyntaxConst.swift in Sources */,\n\t\t\t\t23F70FBE20A055D400CCE3CD /* TokenizerConfig.cpp in Sources */,\n\t\t\t\t23D0C35D20C149D80001BFAE /* FactoryRetriever.cpp in Sources */,\n\t\t\t\t755391D62403B3DB00036918 /* WCTPreparedStatement.mm in Sources */,\n\t\t\t\t0DF1089629C05559004ED764 /* StatementSelectInterface.swift in Sources */,\n\t\t\t\t03DCB5EE286C3D8E00CBC75D /* StatementAttachBridge.cpp in Sources */,\n\t\t\t\t23EEDCDD217DFADC006E9E73 /* StatementRollback.cpp in Sources */,\n\t\t\t\t0D19BA1F2B07481B0028F92B /* IntegerityHandleOperator.cpp in Sources */,\n\t\t\t\t7521DDF82920A623009642EF /* Database+WCTTableCoding.swift in Sources */,\n\t\t\t\t231C35EE21DE09E800B5D3D2 /* Exiting.cpp in Sources */,\n\t\t\t\t03A57F1C2840B5DC00D2A4C3 /* BindParameterBridge.cpp in Sources */,\n\t\t\t\t2370B12921914ED500D3227C /* NSNull+WCTColumnCoding.mm in Sources */,\n\t\t\t\t23A64D0F214A4A7000ED28BB /* Migration.cpp in Sources */,\n\t\t\t\t754359502B0671DE00CDF232 /* BackupHandleOperator.cpp in Sources */,\n\t\t\t\t3962FFCF23051F71008934D4 /* Configs.cpp in Sources */,\n\t\t\t\t75E50A0C29067BC800B73E62 /* MultiObject.cpp in Sources */,\n\t\t\t\t23EEDD37217DFADC006E9E73 /* SyntaxCreateTriggerSTMT.cpp in Sources */,\n\t\t\t\t03E1661F27F42D6500D2C926 /* StatementReindex.swift in Sources */,\n\t\t\t\t23EEDC79217DFADC006E9E73 /* Column.cpp in Sources */,\n\t\t\t\t75F4DE372883E88100760DC3 /* StatementPragmaBridge.cpp in Sources */,\n\t\t\t\t3957985A227FBC8A0069F985 /* WCTDatabase+Test.mm in Sources */,\n\t\t\t\t0393BEE627F7152F0058B295 /* HandleBridge.cpp in Sources */,\n\t\t\t\t23EEDCE1217DFADC006E9E73 /* StatementSelect.cpp in Sources */,\n\t\t\t\t03E1662027F42D6500D2C926 /* StatementCreateIndex.swift in Sources */,\n\t\t\t\t7525C15C2920D22300FD34C7 /* TableCRUDInterface+WCTTableCoding.swift in Sources */,\n\t\t\t\t03E1661527F42D6500D2C926 /* StatementCreateTable.swift in Sources */,\n\t\t\t\t03450E012738ECB800C4DC1B /* OneOrBinaryTokenizer.cpp in Sources */,\n\t\t\t\t03E1660127F42D6500D2C926 /* Pragma.swift in Sources */,\n\t\t\t\t75AF6AE22854F19800A7C43D /* QualifiedTable.swift in Sources */,\n\t\t\t\t2370B12621914ED500D3227C /* WCTMaster.mm in Sources */,\n\t\t\t\t23EEDD4D217DFADC006E9E73 /* SyntaxReindexSTMT.cpp in Sources */,\n\t\t\t\t03F54820287D8467007BCA3E /* StatementDetachBridge.cpp in Sources */,\n\t\t\t\t032613B6283F8D7E00836E0F /* ColumnBridge.cpp in Sources */,\n\t\t\t\t23EEDD39217DFADC006E9E73 /* SyntaxCreateViewSTMT.cpp in Sources */,\n\t\t\t\t23EEDC77217DFADC006E9E73 /* BindParameter.cpp in Sources */,\n\t\t\t\t23301BFD229A851800A8AB5A /* AutoBackupConfig.cpp in Sources */,\n\t\t\t\t75CD027128CF900C0071B6C3 /* TableInterface.swift in Sources */,\n\t\t\t\t23BBE2B22049576D00C4CBB6 /* WCTDatabase+Memory.mm in Sources */,\n\t\t\t\t03E1662D27F42D6600D2C926 /* ChainCall.swift in Sources */,\n\t\t\t\t23EEDD15217DFADC006E9E73 /* SyntaxRaiseFunction.cpp in Sources */,\n\t\t\t\t23EEDC89217DFADC006E9E73 /* FrameSpec.cpp in Sources */,\n\t\t\t\t752594E828522A4A0068A602 /* FrameSpec.swift in Sources */,\n\t\t\t\t03E1664A27F42D6600D2C926 /* Recyclable.swift in Sources */,\n\t\t\t\t2349F7051EA0D6680021EFA7 /* HandlePool.cpp in Sources */,\n\t\t\t\t23EEDD25217DFADC006E9E73 /* SyntaxWindowDef.cpp in Sources */,\n\t\t\t\t23F70F7D209FF0EC00CCE3CD /* WCTValue.mm in Sources */,\n\t\t\t\t2349F7491EA0D6680021EFA7 /* WCTDatabase+File.mm in Sources */,\n\t\t\t\t7521D39328BD1187009C33D0 /* ChainCall.cpp in Sources */,\n\t\t\t\t23906ABB215E500100C2B717 /* WCTDatabase+Monitor.mm in Sources */,\n\t\t\t\t23567D5920CA823C005F1C35 /* PagerRelated.cpp in Sources */,\n\t\t\t\t03E1662127F42D6500D2C926 /* Statement.swift in Sources */,\n\t\t\t\t03D077EF28C1F072009A3B18 /* TableOperation.cpp in Sources */,\n\t\t\t\t756F7F642B2CA4B5002AEA0A /* FactoryVacuum.cpp in Sources */,\n\t\t\t\t039BD3982845CB7C00C58BE2 /* WindowDef.swift in Sources */,\n\t\t\t\t032613BA283F8E4900836E0F /* ExpressionBridge.cpp in Sources */,\n\t\t\t\t23EEDCF3217DFADC006E9E73 /* SyntaxColumnDef.cpp in Sources */,\n\t\t\t\t75AF6AF42855CCDD00A7C43D /* Upsert.swift in Sources */,\n\t\t\t\t23EEDCAD217DFADC006E9E73 /* WindowDef.cpp in Sources */,\n\t\t\t\t23B9E67720AE733B00CF1683 /* FileManager.cpp in Sources */,\n\t\t\t\t23EEDCEF217DFADC006E9E73 /* SyntaxColumn.cpp in Sources */,\n\t\t\t\t23EEDCFB217DFADC006E9E73 /* SyntaxFilter.cpp in Sources */,\n\t\t\t\t23EEDCC9217DFADC006E9E73 /* StatementDelete.cpp in Sources */,\n\t\t\t\t23567D4920CA7DBC005F1C35 /* ErrorProne.cpp in Sources */,\n\t\t\t\t2349F7281EA0D6680021EFA7 /* WCTMultiSelect.mm in Sources */,\n\t\t\t\t23EEDD49217DFADC006E9E73 /* SyntaxInsertSTMT.cpp in Sources */,\n\t\t\t\t03321E8E28A514F5000AFD6D /* HandleOperation.cpp in Sources */,\n\t\t\t\t75AF6ADB2854C5ED00A7C43D /* JoinBridge.cpp in Sources */,\n\t\t\t\t23408F0F211897AA0071E5A7 /* Shm.cpp in Sources */,\n\t\t\t\t2349F6FE1EA0D6680021EFA7 /* InnerDatabase.cpp in Sources */,\n\t\t\t\t23EEDC99217DFADC006E9E73 /* Pragma.cpp in Sources */,\n\t\t\t\t7525176C2B12FDC700485175 /* ZSTDContext.cpp in Sources */,\n\t\t\t\t23AD52F220DBAC4C00664B62 /* UpgradeableErrorProne.cpp in Sources */,\n\t\t\t\t03E1661927F42D6500D2C926 /* StatementAlterTable.swift in Sources */,\n\t\t\t\t23176A9C21BA7D460051ACF9 /* WCTDatabase+Version.mm in Sources */,\n\t\t\t\t039BD4362846113D00C58BE2 /* ExpressionOperatableBridge.cpp in Sources */,\n\t\t\t\t23567D7520CA9200005F1C35 /* SharedThreadedErrorProne.cpp in Sources */,\n\t\t\t\t23EEDC93217DFADC006E9E73 /* LiteralValue.cpp in Sources */,\n\t\t\t\t03E1662927F42D6600D2C926 /* Declare.swift in Sources */,\n\t\t\t\t0D5403032B160693007DF415 /* CompressingStatementDecorator.cpp in Sources */,\n\t\t\t\t75C4409E291D0C9C00D74EB7 /* CheckExpressionConfig.swift in Sources */,\n\t\t\t\t75F4DE51288407F800760DC3 /* StatementVacuumBridge.cpp in Sources */,\n\t\t\t\t03E1663027F42D6600D2C926 /* Select.swift in Sources */,\n\t\t\t\t23EEDD33217DFADC006E9E73 /* SyntaxCreateIndexSTMT.cpp in Sources */,\n\t\t\t\t756A773D27F9EDDE00105B7C /* HandleStatementBridge.cpp in Sources */,\n\t\t\t\t03E822842844B8760072CA57 /* CommonTableExpressionBridge.cpp in Sources */,\n\t\t\t\t752517812B1338AF00485175 /* CompressionRecord.cpp in Sources */,\n\t\t\t\t75CD026928CF8DC00071B6C3 /* InsertInterface.swift in Sources */,\n\t\t\t\t2349F7241EA0D6680021EFA7 /* WCTInsert.mm in Sources */,\n\t\t\t\t2349F7601EA0D6680021EFA7 /* WCTColumnBinding.mm in Sources */,\n\t\t\t\t2349F72D1EA0D6680021EFA7 /* WCTSelect.mm in Sources */,\n\t\t\t\t75F4DE5F2884149100760DC3 /* StatementCommitBridge.cpp in Sources */,\n\t\t\t\t7542121E2B124CFF00A2FF4D /* Compression.cpp in Sources */,\n\t\t\t\t75C44094291CE12300D74EB7 /* ColumnConstraintConfig.swift in Sources */,\n\t\t\t\t23EEDD29217DFADC006E9E73 /* SyntaxAlterTableSTMT.cpp in Sources */,\n\t\t\t\t23EEDD3B217DFADC006E9E73 /* SyntaxCreateVirtualTableSTMT.cpp in Sources */,\n\t\t\t\t23EEDD2D217DFADC006E9E73 /* SyntaxAttachSTMT.cpp in Sources */,\n\t\t\t\t23EEDD07217DFADC006E9E73 /* SyntaxJoinClause.cpp in Sources */,\n\t\t\t\t232741521F6FBD50004E96F7 /* WCTDatabase+FTS.mm in Sources */,\n\t\t\t\t23EEDD43217DFADC006E9E73 /* SyntaxDropTableSTMT.cpp in Sources */,\n\t\t\t\t753636DD28BBC3820025C2C4 /* Table.cpp in Sources */,\n\t\t\t\t7521DDEE29209DCE009642EF /* Update+WCTTableCoding.swift in Sources */,\n\t\t\t\t03E1660327F42D6500D2C926 /* StatementSelect.swift in Sources */,\n\t\t\t\t3960D89B2319258B00EF05D1 /* SyntaxExplainSTMT.cpp in Sources */,\n\t\t\t\t0D32815F2B04A8E60027B973 /* DecorativeHandle.cpp in Sources */,\n\t\t\t\t0D19BA0B2B0702250028F92B /* AssembleHandleOperator.cpp in Sources */,\n\t\t\t\t03D3A2A928A6643E0064D4D4 /* PreparedStatement.cpp in Sources */,\n\t\t\t\t03E1661C27F42D6500D2C926 /* StatementVacuum.swift in Sources */,\n\t\t\t\t03E3181228A23CBC00540CB1 /* Handle.cpp in Sources */,\n\t\t\t\t0DCD2AC32C6E210700C247EC /* AutoVacuumConfig.cpp in Sources */,\n\t\t\t\t754211F52B12359400A2FF4D /* ScalarFunctionConfig.cpp in Sources */,\n\t\t\t\t2370B12521914ED500D3227C /* NSData+WCTColumnCoding.mm in Sources */,\n\t\t\t\t23EEDD0B217DFADC006E9E73 /* SyntaxLiteralValue.cpp in Sources */,\n\t\t\t\t03EE3DAE28816DA800C8F0B3 /* StatementUpdateBridge.cpp in Sources */,\n\t\t\t\t0DAD93C429FA2C4800E5788C /* TableChainCall+WCTTableCoding.swift in Sources */,\n\t\t\t\t235EE9C722B6321A008F6658 /* StringView.cpp in Sources */,\n\t\t\t\t03E1661327F42D6500D2C926 /* LiteralValue.swift in Sources */,\n\t\t\t\t03F54824287D87F9007BCA3E /* StatementDropIndexBridge.cpp in Sources */,\n\t\t\t\t23EEDD51217DFADC006E9E73 /* SyntaxRollbackSTMT.cpp in Sources */,\n\t\t\t\t2370980A20590CA700E768B4 /* HandleStatement.cpp in Sources */,\n\t\t\t\t75F32F0E28B9F90900A72697 /* FTSTokenizerUtil.cpp in Sources */,\n\t\t\t\t0326130D283F56BD00836E0F /* LiteralValueBridge.cpp in Sources */,\n\t\t\t\t23EEDC6D217DFADC006E9E73 /* CoreFunction.cpp in Sources */,\n\t\t\t\t2349F75E1EA0D6680021EFA7 /* WCTBinding.mm in Sources */,\n\t\t\t\t2349F7371EA0D6680021EFA7 /* WCTDatabase+Convenient.mm in Sources */,\n\t\t\t\t75EB1A13287F10BF00AA62F7 /* StatementCreateTriggerBridge.cpp in Sources */,\n\t\t\t\t757821E1286DF5EB0092F858 /* StatementCreateTableBridge.cpp in Sources */,\n\t\t\t\t23DD76BD20CF78C800E9B451 /* FactoryRenewer.cpp in Sources */,\n\t\t\t\t2304B42822156CD700901953 /* TokenizerModule.cpp in Sources */,\n\t\t\t\t758E7ED02B1B49EF00319991 /* WCTDatabase+Compression.mm in Sources */,\n\t\t\t\t23EEDCFF217DFADC006E9E73 /* SyntaxFrameSpec.cpp in Sources */,\n\t\t\t\t234DBCF42064DD0C000E31E8 /* WCTDatabase+Handle.mm in Sources */,\n\t\t\t\t23EEDD21217DFADC006E9E73 /* SyntaxTableOrSubquery.cpp in Sources */,\n\t\t\t\t03E1661827F42D6500D2C926 /* StatementAttach.swift in Sources */,\n\t\t\t\t03E165FB27F42D6500D2C926 /* Expression.swift in Sources */,\n\t\t\t\t23567D7B20CA93C5005F1C35 /* Time.cpp in Sources */,\n\t\t\t\t2349F7391EA0D6680021EFA7 /* WCTTable+Convenient.mm in Sources */,\n\t\t\t\t234DBD062064DE04000E31E8 /* WCTHandle+Transaction.mm in Sources */,\n\t\t\t\t23EEDCE5217DFADC006E9E73 /* StatementVacuum.cpp in Sources */,\n\t\t\t\t2347378F21CBB3A800AD5E41 /* AbstractHandle.cpp in Sources */,\n\t\t\t\t23776CA4218C41DD00E985DC /* WCTChainCall.mm in Sources */,\n\t\t\t\t23EABBE7206D08EC00241F3B /* WCTHandle+Table.mm in Sources */,\n\t\t\t\t7521DDE529209B8D009642EF /* ChainCall+WCTTableCoding.swift in Sources */,\n\t\t\t\t2349F7351EA0D6680021EFA7 /* WCTUpdate.mm in Sources */,\n\t\t\t\t3960D89F2319288C00EF05D1 /* StatementExplain.cpp in Sources */,\n\t\t\t\t23B4DCBD2112A9C800954D71 /* CommonCore.cpp in Sources */,\n\t\t\t\t7525175B2B12D43700485175 /* DecompressFunction.cpp in Sources */,\n\t\t\t\t23EEDD05217DFADC006E9E73 /* SyntaxIndexedColumn.cpp in Sources */,\n\t\t\t\t03E1660A27F42D6500D2C926 /* TableConstraint.swift in Sources */,\n\t\t\t\t23775B8A20AD666900E21AB0 /* Pager.cpp in Sources */,\n\t\t\t\t75CD026128CECD610071B6C3 /* StatementInterface.swift in Sources */,\n\t\t\t\t03DCB5E9286C345C00CBC75D /* StatementAnalyze.swift in Sources */,\n\t\t\t\t75F4DE58288411DB00760DC3 /* StatementBegin.swift in Sources */,\n\t\t\t\t75F4DE4B288405DD00760DC3 /* StatementSavepointBridge.cpp in Sources */,\n\t\t\t\t03E1662527F42D6500D2C926 /* Handle.swift in Sources */,\n\t\t\t\t233A8532215E7CFE00BB8D4F /* Console.cpp in Sources */,\n\t\t\t\t0DE84C7D2B03886800522A4E /* DecorativeHandleStatement.cpp in Sources */,\n\t\t\t\t75CB08CB2A88B9A300429364 /* HandleCounter.cpp in Sources */,\n\t\t\t\t03E1660C27F42D6500D2C926 /* IndexedColumn.swift in Sources */,\n\t\t\t\t23EEDCAB217DFADC006E9E73 /* Upsert.cpp in Sources */,\n\t\t\t\t23AD52D620DB4A3C00664B62 /* MasterItem.cpp in Sources */,\n\t\t\t\t23EEDCCD217DFADC006E9E73 /* StatementDropIndex.cpp in Sources */,\n\t\t\t\t23775B6220AD666900E21AB0 /* WCDBError.cpp in Sources */,\n\t\t\t\t23EEDCD5217DFADC006E9E73 /* StatementInsert.cpp in Sources */,\n\t\t\t\t7543DD92271C601F00B533B4 /* SubstringMatchInfo.cpp in Sources */,\n\t\t\t\t03E8228C2844BEFF0072CA57 /* CommonTableExpression.swift in Sources */,\n\t\t\t\t75F1A3062871DE9A008503A2 /* StatementCreateVirtualTableBridge.cpp in Sources */,\n\t\t\t\t39C70CC72313E20F002D773C /* Assemble.cpp in Sources */,\n\t\t\t\t23775B8220AD666900E21AB0 /* Cell.cpp in Sources */,\n\t\t\t\t03E822912844E1AB0072CA57 /* RaiseFunctionBridge.cpp in Sources */,\n\t\t\t\t75294DAF29C75058005E7FC0 /* OperationQueueForMemory.cpp in Sources */,\n\t\t\t\t7543DD8E271C360E00B533B4 /* AuxiliaryFunctionConfig.cpp in Sources */,\n\t\t\t\t03E1665827F42D6600D2C926 /* Optional.swift in Sources */,\n\t\t\t\t236BACE321BF9F6400C8B4D9 /* WCTDatabase+Migration.mm in Sources */,\n\t\t\t\t03E1662A27F42D6600D2C926 /* RowSelect.swift in Sources */,\n\t\t\t\t23567CFA20CA3889005F1C35 /* Frame.cpp in Sources */,\n\t\t\t\t039760A827F563F00071FA8F /* ObjectBridge.swift in Sources */,\n\t\t\t\t23B35C7820BFE39500425033 /* Path.cpp in Sources */,\n\t\t\t\t23EEDC7F217DFADC006E9E73 /* CommonTableExpression.cpp in Sources */,\n\t\t\t\t752517752B132DAB00485175 /* CompressionConst.cpp in Sources */,\n\t\t\t\t0DAD93C129FA2A1200E5788C /* TableChainCall.swift in Sources */,\n\t\t\t\t75204AEB283FD7410002E40C /* SchemaBridge.cpp in Sources */,\n\t\t\t\t2360A60720D78F2C00E4A311 /* PerformanceTraceConfig.cpp in Sources */,\n\t\t\t\t23EEDCBD217DFADC006E9E73 /* StatementCommit.cpp in Sources */,\n\t\t\t\t2349F7301EA0D6680021EFA7 /* WCTSelectable.mm in Sources */,\n\t\t\t\t23F70FB820A055CF00CCE3CD /* AutoCheckpointConfig.cpp in Sources */,\n\t\t\t\t03E1661E27F42D6500D2C926 /* ColumnDef.swift in Sources */,\n\t\t\t\t754212122B124CFF00A2FF4D /* CompressionCenter.cpp in Sources */,\n\t\t\t\t0397605827F54FA10071FA8F /* ObjectBridge.cpp in Sources */,\n\t\t\t\t23EEDC85217DFADC006E9E73 /* Filter.cpp in Sources */,\n\t\t\t\t390E1C5C2296414C00C24598 /* Thread.cpp in Sources */,\n\t\t\t\t3934DAEB229B6659008A6AEC /* OperationQueue.cpp in Sources */,\n\t\t\t\t0D3AE54025416DB4007B9D0E /* AutoMergeFTSIndexConfig.cpp in Sources */,\n\t\t\t\t75A46C0428431D6300B58207 /* ForeignKeyBridge.cpp in Sources */,\n\t\t\t\t23EEDC9B217DFADC006E9E73 /* QualifiedTable.cpp in Sources */,\n\t\t\t\t75AF6ADF2854EF6D00A7C43D /* QualifiedTableBridge.cpp in Sources */,\n\t\t\t\t23F70FA620A055BE00CCE3CD /* BasicConfig.cpp in Sources */,\n\t\t\t\t23EEDCD7217DFADC006E9E73 /* StatementPragma.cpp in Sources */,\n\t\t\t\t0D249BC92542B90600B43BD9 /* MergeFTSIndexLogic.cpp in Sources */,\n\t\t\t\t23EEDD2B217DFADC006E9E73 /* SyntaxAnalyzeSTMT.cpp in Sources */,\n\t\t\t\t03E822882844B8CD0072CA57 /* StatementSelectBridge.cpp in Sources */,\n\t\t\t\t23EEDD13217DFADC006E9E73 /* SyntaxQualifiedTableName.cpp in Sources */,\n\t\t\t\t7521DDF229209F45009642EF /* StatementInterface+WCTTableCoding.swift in Sources */,\n\t\t\t\t754359462B066DBD00CDF232 /* HandleOperator.cpp in Sources */,\n\t\t\t\t23EEDD1B217DFADC006E9E73 /* SyntaxSchema.cpp in Sources */,\n\t\t\t\t2349F7691EA0D6680021EFA7 /* WCTProperty.mm in Sources */,\n\t\t\t\t03E1664627F42D6600D2C926 /* Database.swift in Sources */,\n\t\t\t\t75C44096291CE1FB00D74EB7 /* TableConfiguration.swift in Sources */,\n\t\t\t\t03E1660B27F42D6500D2C926 /* Convertible.swift in Sources */,\n\t\t\t\t03AFD35028B8C4EB00EF5E56 /* Field.cpp in Sources */,\n\t\t\t\t2386B3C61ED442FE000B72F6 /* WCTError.mm in Sources */,\n\t\t\t\t75204AE8283FD6DC0002E40C /* Schema.swift in Sources */,\n\t\t\t\t237B47B021FEEA200059227A /* ColumnMeta.cpp in Sources */,\n\t\t\t\t23759461210081AA00DBB721 /* UnsafeData.cpp in Sources */,\n\t\t\t\t23EEDC7D217DFADC006E9E73 /* ColumnDef.cpp in Sources */,\n\t\t\t\t759362CF2B36D450000AF163 /* Vacuum.cpp in Sources */,\n\t\t\t\t2370B12B21914ED500D3227C /* NSString+WCTColumnCoding.mm in Sources */,\n\t\t\t\t23EEDCA7217DFADC006E9E73 /* TableConstraint.cpp in Sources */,\n\t\t\t\t23EEDCF1217DFADC006E9E73 /* SyntaxColumnConstraint.cpp in Sources */,\n\t\t\t\t23EE0EB220B838E100C95998 /* Repairman.cpp in Sources */,\n\t\t\t\t23EEDCBB217DFADC006E9E73 /* StatementBegin.cpp in Sources */,\n\t\t\t\t2316D93721058B5500707AFC /* WCTFileManager.mm in Sources */,\n\t\t\t\t23A64D09214A458A00ED28BB /* MigrationInfo.cpp in Sources */,\n\t\t\t\t0D54030D2B1606BC007DF415 /* CompressingHandleDecorator.cpp in Sources */,\n\t\t\t\t0D3281682B04AC7A0027B973 /* FunctionContainer.cpp in Sources */,\n\t\t\t\t23775B7A20AD666900E21AB0 /* Material.cpp in Sources */,\n\t\t\t\t23EEDC87217DFADC006E9E73 /* ForeignKey.cpp in Sources */,\n\t\t\t\t23775B9620AD666900E21AB0 /* Crawlable.cpp in Sources */,\n\t\t\t\t23EEDC66217DFADC006E9E73 /* AggregateFunction.cpp in Sources */,\n\t\t\t\t75C4409A291CE7E200D74EB7 /* MultiPrimaryConfig.swift in Sources */,\n\t\t\t\t23C7559A20DD17B100031A93 /* SQLiteBase.cpp in Sources */,\n\t\t\t\t23EEDC8F217DFADC006E9E73 /* Join.cpp in Sources */,\n\t\t\t\t23EEDD35217DFADC006E9E73 /* SyntaxCreateTableSTMT.cpp in Sources */,\n\t\t\t\t75EB1A0D287F0DE200AA62F7 /* StatementCreateView.swift in Sources */,\n\t\t\t\t7537E58628B91F510077D92B /* Accessor.cpp in Sources */,\n\t\t\t\t03EA88D027D5F0840075C7BD /* FTSError.cpp in Sources */,\n\t\t\t\t23EEDD41217DFADC006E9E73 /* SyntaxDropIndexSTMT.cpp in Sources */,\n\t\t\t\t03E1662C27F42D6600D2C926 /* Delete.swift in Sources */,\n\t\t\t\t2360A5F720D78F1B00E4A311 /* HandleRelated.cpp in Sources */,\n\t\t\t\t23EEDD03217DFADC006E9E73 /* SyntaxIdentifier.cpp in Sources */,\n\t\t\t\t23EEDCED217DFADC006E9E73 /* SyntaxBindParameter.cpp in Sources */,\n\t\t\t\t23EEDD3F217DFADC006E9E73 /* SyntaxDetachSTMT.cpp in Sources */,\n\t\t\t\t23775B8620AD666900E21AB0 /* Page.cpp in Sources */,\n\t\t\t\t03E1664C27F42D6600D2C926 /* WCDBError.swift in Sources */,\n\t\t\t\t03E1661D27F42D6500D2C926 /* StatementRelease.swift in Sources */,\n\t\t\t\t23EEDD0F217DFADC006E9E73 /* SyntaxOrderingTerm.cpp in Sources */,\n\t\t\t\t03E1660027F42D6500D2C926 /* StatementDropIndex.swift in Sources */,\n\t\t\t\t2308F85320E32A51001CD9C3 /* Serialization.cpp in Sources */,\n\t\t\t\t03321E8828A503F3000AFD6D /* StatementOperation.cpp in Sources */,\n\t\t\t\t03E1665927F42D6600D2C926 /* Convenience.swift in Sources */,\n\t\t\t\t75F1A30A2871E764008503A2 /* StatementDeleteBridge.cpp in Sources */,\n\t\t\t\t0DC98FD328E46049007F3796 /* DBOperationNotifier.cpp in Sources */,\n\t\t\t\t23E163D320FDDD8500C3F910 /* PorterStemming.c in Sources */,\n\t\t\t\t03E1661727F42D6500D2C926 /* StatementDelete.swift in Sources */,\n\t\t\t\t03EE3DAA288165A700C8F0B3 /* StatementInsertBridge.cpp in Sources */,\n\t\t\t\t23D0C30E20C125420001BFAE /* SQLiteAssembler.cpp in Sources */,\n\t\t\t\t75CD026D28CF8F360071B6C3 /* DeleteInterface.swift in Sources */,\n\t\t\t\t75F4DE5528840C4800760DC3 /* StatementBeginBridge.cpp in Sources */,\n\t\t\t\t03A57F192840B5A700D2A4C3 /* BindParameter.swift in Sources */,\n\t\t\t\t75E76AD429161EE400073CCA /* FTSBridge.swift in Sources */,\n\t\t\t\t758E7EB82B1B24AD00319991 /* AutoCompressConfig.cpp in Sources */,\n\t\t\t\t2308F84F20E32A51001CD9C3 /* FileHandle.cpp in Sources */,\n\t\t\t\t03E1661627F42D6500D2C926 /* Join.swift in Sources */,\n\t\t\t\t75AF6AFA2856303700A7C43D /* PragmaBridge.cpp in Sources */,\n\t\t\t\t75C1034228450D840006BBCB /* WindowDefBridge.cpp in Sources */,\n\t\t\t\t03E1663527F42D6600D2C926 /* ColumnCodable.swift in Sources */,\n\t\t\t\t23EEDD09217DFADC006E9E73 /* SyntaxJoinConstraint.cpp in Sources */,\n\t\t\t\t23BBE2AE2049565600C4CBB6 /* WCTDatabase+Config.mm in Sources */,\n\t\t\t\t7521DDF62920A12E009642EF /* InsertInterface+WCTTableCoding.swift in Sources */,\n\t\t\t\t23EEDD4F217DFADC006E9E73 /* SyntaxReleaseSTMT.cpp in Sources */,\n\t\t\t\t2349F74C1EA0D6680021EFA7 /* WCTDatabase+Repair.mm in Sources */,\n\t\t\t\t7521DDFA2920A680009642EF /* UpdateInterface+WCTTableCoding.swift in Sources */,\n\t\t\t\t756A774327FAC1D900105B7C /* CoreBridge.cpp in Sources */,\n\t\t\t\t23EEDCA3217DFADC006E9E73 /* Schema.cpp in Sources */,\n\t\t\t\t23D07CE420BE87360043F4D4 /* MasterCrawler.cpp in Sources */,\n\t\t\t\t23EEDCD9217DFADC006E9E73 /* StatementReindex.cpp in Sources */,\n\t\t\t\t2370B12021914ED500D3227C /* NSObject+WCTColumnCoding.mm in Sources */,\n\t\t\t\t2349F7321EA0D6680021EFA7 /* WCTTable+ChainCall.mm in Sources */,\n\t\t\t\t752CF3F8293A490F009ED8FB /* BindingBridge.cpp in Sources */,\n\t\t\t\t23EB91DE20CA1EBE00ECF668 /* Wal.cpp in Sources */,\n\t\t\t\t23577F7A1F74F4E800D31C05 /* WCTFTSTokenizerUtil.mm in Sources */,\n\t\t\t\t03E1664127F42D6600D2C926 /* TableBinding.swift in Sources */,\n\t\t\t\t03E1662727F42D6500D2C926 /* CodableType.swift in Sources */,\n\t\t\t\t2349F7211EA0D6680021EFA7 /* WCTDelete.mm in Sources */,\n\t\t\t\t237A8D5F21EDBB2E003AF5BB /* BusyRetryConfig.cpp in Sources */,\n\t\t\t\t7533CB592B050FB200C8B47D /* MigratingStatementDecorator.cpp in Sources */,\n\t\t\t\t03E1663C27F42D6600D2C926 /* Property.swift in Sources */,\n\t\t\t\t03E5CC5A28A39B19005353D9 /* Database.cpp in Sources */,\n\t\t\t\t23EEDD55217DFADC006E9E73 /* SyntaxSelectSTMT.cpp in Sources */,\n\t\t\t\t758E7EC22B1B41AA00319991 /* WCTCompressionInfo.mm in Sources */,\n\t\t\t\t39B524DE2304F9A2001DF52D /* InnerHandle.cpp in Sources */,\n\t\t\t\t03D077FD28C20FEE009A3B18 /* Delete.cpp in Sources */,\n\t\t\t\t75E50A2E2907921600B73E62 /* MultiSelect.cpp in Sources */,\n\t\t\t\t23F340DF204D3482007DB8AB /* WCTDatabase+ChainCall.mm in Sources */,\n\t\t\t\t23F0FEB7215F5E9A008399FB /* Lock.cpp in Sources */,\n\t\t\t\t039760AE27F5C1CA0071FA8F /* DatabaseBridge.cpp in Sources */,\n\t\t\t\t3962FFCB230514CD008934D4 /* WCTBaseAccessor.mm in Sources */,\n\t\t\t\t0D8084242A861E9500C81BBF /* WCTCancellationSignal.mm in Sources */,\n\t\t\t\t75F32F2928BA31CD00A72697 /* ResultField.cpp in Sources */,\n\t\t\t\t7537E5D228B939240077D92B /* BaseBinding.cpp in Sources */,\n\t\t\t\t7521DDE829209C90009642EF /* Handle+WCTTableCoding.swift in Sources */,\n\t\t\t\t23EEDD1D217DFADC006E9E73 /* SyntaxSelectCore.cpp in Sources */,\n\t\t\t\t03E1664427F42D6600D2C926 /* BaseType.swift in Sources */,\n\t\t\t\t03E1660F27F42D6500D2C926 /* StatementSavepoint.swift in Sources */,\n\t\t\t\t7521DDF029209E4E009642EF /* Select+WCTTableCoding.swift in Sources */,\n\t\t\t\t03E5CC6F28A3BDF3005353D9 /* Value.cpp in Sources */,\n\t\t\t\t23EEDCDB217DFADC006E9E73 /* StatementRelease.cpp in Sources */,\n\t\t\t\t0D5363EB290A65390026A4DC /* Master.cpp in Sources */,\n\t\t\t\t03F54828287D93A7007BCA3E /* StatementDropTableBridge.cpp in Sources */,\n\t\t\t);\n\t\t\trunOnlyForDeploymentPostprocessing = 0;\n\t\t};\n\t\t239E8A6C2160A5B100BCB308 /* Sources */ = {\n\t\t\tisa = PBXSourcesBuildPhase;\n\t\t\tbuildActionMask = 2147483647;\n\t\t\tfiles = (\n\t\t\t\t234F0558227A9F0900DD65A2 /* main.m in Sources */,\n\t\t\t);\n\t\t\trunOnlyForDeploymentPostprocessing = 0;\n\t\t};\n\t\t7521D6C1291E9ABB009642EF /* Sources */ = {\n\t\t\tisa = PBXSourcesBuildPhase;\n\t\t\tbuildActionMask = 2147483647;\n\t\t\tfiles = (\n\t\t\t\t7521D6C2291E9ABB009642EF /* SQL.cpp in Sources */,\n\t\t\t\t0D3281602B04A8E60027B973 /* DecorativeHandle.cpp in Sources */,\n\t\t\t\t7521D6C3291E9ABB009642EF /* HighWater.cpp in Sources */,\n\t\t\t\t7521D6C4291E9ABB009642EF /* ConvertibleImplementation.cpp in Sources */,\n\t\t\t\t7521D6C5291E9ABB009642EF /* Scoreable.cpp in Sources */,\n\t\t\t\t7521D6C6291E9ABB009642EF /* StatementCreateView.cpp in Sources */,\n\t\t\t\t7521D6C7291E9ABB009642EF /* MappedData.cpp in Sources */,\n\t\t\t\t7521D6C8291E9ABB009642EF /* Backup.cpp in Sources */,\n\t\t\t\t7521D6CB291E9ABB009642EF /* PinyinTokenizer.cpp in Sources */,\n\t\t\t\t7521D6CE291E9ABB009642EF /* SQLTraceConfig.cpp in Sources */,\n\t\t\t\t7521D6D0291E9ABB009642EF /* SyntaxPragma.cpp in Sources */,\n\t\t\t\t7521D6D2291E9ABB009642EF /* Factory.cpp in Sources */,\n\t\t\t\t7521D6D3291E9ABB009642EF /* WCTDatabase+Transaction.mm in Sources */,\n\t\t\t\t7521D6D4291E9ABB009642EF /* WCTResultColumn.mm in Sources */,\n\t\t\t\t7521D6D5291E9ABB009642EF /* Statement.cpp in Sources */,\n\t\t\t\t7521D6D6291E9ABB009642EF /* FactoryBackup.cpp in Sources */,\n\t\t\t\t7521D6D8291E9ABB009642EF /* CustomConfig.cpp in Sources */,\n\t\t\t\t7521D6D9291E9ABB009642EF /* StatementDropView.cpp in Sources */,\n\t\t\t\t7521D6DA291E9ABB009642EF /* Config.cpp in Sources */,\n\t\t\t\t0DD8D1182B074C47002C97D3 /* MigrateHandleOperator.cpp in Sources */,\n\t\t\t\t7521D6DB291E9ABB009642EF /* WCTDatabase.mm in Sources */,\n\t\t\t\t7521D6DC291E9ABB009642EF /* WCTOperationQueue.mm in Sources */,\n\t\t\t\t7521D6DD291E9ABB009642EF /* Tag.cpp in Sources */,\n\t\t\t\t7521D6DE291E9ABB009642EF /* SyntaxSavepointSTMT.cpp in Sources */,\n\t\t\t\t75ADC5652A8D1C2D00D0AC47 /* TableAttribute.cpp in Sources */,\n\t\t\t\t7521D6DF291E9ABB009642EF /* SyntaxDeleteSTMT.cpp in Sources */,\n\t\t\t\t7521D6E0291E9ABB009642EF /* SyntaxCommitSTMT.cpp in Sources */,\n\t\t\t\t7521D6E4291E9ABB009642EF /* Notifier.cpp in Sources */,\n\t\t\t\t7521D6E6291E9ABB009642EF /* SyntaxDropViewSTMT.cpp in Sources */,\n\t\t\t\t7521D6E9291E9ABB009642EF /* OrderingTerm.cpp in Sources */,\n\t\t\t\t7521D6EB291E9ABB009642EF /* ColumnType.cpp in Sources */,\n\t\t\t\t7521D6EC291E9ABB009642EF /* WCTTryDisposeGuard.mm in Sources */,\n\t\t\t\t7521D6ED291E9ABB009642EF /* StatementAttach.cpp in Sources */,\n\t\t\t\t7521D6EE291E9ABB009642EF /* Fraction.cpp in Sources */,\n\t\t\t\t7521D6F0291E9ABB009642EF /* SyntaxTableConstraint.cpp in Sources */,\n\t\t\t\t7521D6F1291E9ABB009642EF /* SequenceCrawler.cpp in Sources */,\n\t\t\t\t7521D6F7291E9ABB009642EF /* StatementDropTrigger.cpp in Sources */,\n\t\t\t\t7521D6F8291E9ABB009642EF /* ExpressionOperable.cpp in Sources */,\n\t\t\t\t7521D6FA291E9ABB009642EF /* SQLiteLocker.cpp in Sources */,\n\t\t\t\t7521D6FC291E9ABB009642EF /* NSNumber+WCTColumnCoding.mm in Sources */,\n\t\t\t\t7521D6FE291E9ABB009642EF /* StatementUpdate.cpp in Sources */,\n\t\t\t\t7521D6FF291E9ABB009642EF /* SyntaxResultColumn.cpp in Sources */,\n\t\t\t\t7521D700291E9ABB009642EF /* Initializeable.cpp in Sources */,\n\t\t\t\t7521D701291E9ABB009642EF /* PageBasedFileHandle.cpp in Sources */,\n\t\t\t\t7521D703291E9ABB009642EF /* Progress.cpp in Sources */,\n\t\t\t\t7521D704291E9ABB009642EF /* Mechanic.cpp in Sources */,\n\t\t\t\t0D4F0F992AC572B20067027E /* WCTPerformanceInfo.mm in Sources */,\n\t\t\t\t7533CB5A2B050FB200C8B47D /* MigratingStatementDecorator.cpp in Sources */,\n\t\t\t\t7521D705291E9ABB009642EF /* WCTDatabase+Table.mm in Sources */,\n\t\t\t\t7521D707291E9ABB009642EF /* SyntaxUpdateSTMT.cpp in Sources */,\n\t\t\t\t7521D70A291E9ABB009642EF /* NSDate+WCTColumnCoding.mm in Sources */,\n\t\t\t\t7521D70B291E9ABB009642EF /* StatementCreateIndex.cpp in Sources */,\n\t\t\t\t7521D70C291E9ABB009642EF /* WCTTable.mm in Sources */,\n\t\t\t\t7521D70D291E9ABB009642EF /* StatementDetach.cpp in Sources */,\n\t\t\t\t7521D70F291E9ABB009642EF /* StatementAnalyze.cpp in Sources */,\n\t\t\t\t75294DB029C75058005E7FC0 /* OperationQueueForMemory.cpp in Sources */,\n\t\t\t\t7521D712291E9ABB009642EF /* FTSFunction.cpp in Sources */,\n\t\t\t\t7521D713291E9ABB009642EF /* RecyclableHandle.cpp in Sources */,\n\t\t\t\t7521D717291E9ABB009642EF /* ResultColumn.cpp in Sources */,\n\t\t\t\t7521D719291E9ABB009642EF /* FullCrawler.cpp in Sources */,\n\t\t\t\t7521D71A291E9ABB009642EF /* SyntaxVacuumSTMT.cpp in Sources */,\n\t\t\t\t7521D71D291E9ABB009642EF /* StatementCreateTable.cpp in Sources */,\n\t\t\t\t7521D71E291E9ABB009642EF /* HandleNotification.cpp in Sources */,\n\t\t\t\t7521D71F291E9ABB009642EF /* SequenceItem.cpp in Sources */,\n\t\t\t\t7521D720291E9ABB009642EF /* AuxiliaryFunctionModule.cpp in Sources */,\n\t\t\t\t7521D722291E9ABB009642EF /* WCTConvertible.mm in Sources */,\n\t\t\t\t7521D724291E9ABB009642EF /* StatementAlterTable.cpp in Sources */,\n\t\t\t\t7521D725291E9ABB009642EF /* CipherConfig.cpp in Sources */,\n\t\t\t\t7521D726291E9ABB009642EF /* FactoryRelated.cpp in Sources */,\n\t\t\t\t7521D728291E9ABB009642EF /* Global.cpp in Sources */,\n\t\t\t\t7521D729291E9ABB009642EF /* WCTHandle+ChainCall.mm in Sources */,\n\t\t\t\t7521D72E291E9ABB009642EF /* SyntaxDropTriggerSTMT.cpp in Sources */,\n\t\t\t\t7521D730291E9ABB009642EF /* AsyncQueue.cpp in Sources */,\n\t\t\t\t7521D731291E9ABB009642EF /* SyntaxUpsertClause.cpp in Sources */,\n\t\t\t\t7521D732291E9ABB009642EF /* WCTTable+Table.mm in Sources */,\n\t\t\t\t752517822B1338AF00485175 /* CompressionRecord.cpp in Sources */,\n\t\t\t\t7521D734291E9ABB009642EF /* Expression.cpp in Sources */,\n\t\t\t\t7521D736291E9ABB009642EF /* SyntaxPragmaSTMT.cpp in Sources */,\n\t\t\t\t7521D738291E9ABB009642EF /* WCTFoundation.mm in Sources */,\n\t\t\t\t7521D73F291E9ABB009642EF /* WCTOptional.mm in Sources */,\n\t\t\t\t7521D743291E9ABB009642EF /* JoinConstraint.cpp in Sources */,\n\t\t\t\t7521D745291E9ABB009642EF /* WCTRuntimeObjCAccessor.mm in Sources */,\n\t\t\t\t75EF25012AA33FEB0009C99F /* IncrementalMaterial.cpp in Sources */,\n\t\t\t\t7521D747291E9ABB009642EF /* AutoMigrateConfig.cpp in Sources */,\n\t\t\t\t7521D748291E9ABB009642EF /* TableOrSubquery.cpp in Sources */,\n\t\t\t\t7521D74A291E9ABB009642EF /* WalRelated.cpp in Sources */,\n\t\t\t\t7521D74B291E9ABB009642EF /* SyntaxBeginSTMT.cpp in Sources */,\n\t\t\t\t7521D74C291E9ABB009642EF /* SyntaxCommonTableExpression.cpp in Sources */,\n\t\t\t\t759362D02B36D450000AF163 /* Vacuum.cpp in Sources */,\n\t\t\t\t7542121F2B124CFF00A2FF4D /* Compression.cpp in Sources */,\n\t\t\t\t7521D74E291E9ABB009642EF /* StatementDropTable.cpp in Sources */,\n\t\t\t\t7521D751291E9ABB009642EF /* SyntaxExpression.cpp in Sources */,\n\t\t\t\t7521D752291E9ABB009642EF /* StatementCreateVirtualTable.cpp in Sources */,\n\t\t\t\t7521D753291E9ABB009642EF /* SyntaxCommonConst.cpp in Sources */,\n\t\t\t\t7521D754291E9ABB009642EF /* StatementSavepoint.cpp in Sources */,\n\t\t\t\t7521D755291E9ABB009642EF /* Recyclable.cpp in Sources */,\n\t\t\t\t7521D756291E9ABB009642EF /* Data.cpp in Sources */,\n\t\t\t\t7521D758291E9ABB009642EF /* SyntaxForeignKeyClause.cpp in Sources */,\n\t\t\t\t7521D759291E9ABB009642EF /* IndexedColumn.cpp in Sources */,\n\t\t\t\t7521D75A291E9ABB009642EF /* BaseTokenizerUtil.cpp in Sources */,\n\t\t\t\t7521D75B291E9ABB009642EF /* RaiseFunction.cpp in Sources */,\n\t\t\t\t759362DB2B36D756000AF163 /* VacuumHandleOperator.cpp in Sources */,\n\t\t\t\t7521D75E291E9ABB009642EF /* ColumnConstraint.cpp in Sources */,\n\t\t\t\t7521D75F291E9ABB009642EF /* WCTRuntimeBaseAccessor.mm in Sources */,\n\t\t\t\t0D54030E2B1606BC007DF415 /* CompressingHandleDecorator.cpp in Sources */,\n\t\t\t\t7521D762291E9ABB009642EF /* Range.cpp in Sources */,\n\t\t\t\t7521D763291E9ABB009642EF /* WCTHandle.mm in Sources */,\n\t\t\t\t7521D764291E9ABB009642EF /* ThreadedErrors.cpp in Sources */,\n\t\t\t\t0DCD2AC42C6E210700C247EC /* AutoVacuumConfig.cpp in Sources */,\n\t\t\t\t7521D769291E9ABB009642EF /* WCTObjCAccessor.mm in Sources */,\n\t\t\t\t7529C7702ABC4D6600518293 /* CipherHandle.cpp in Sources */,\n\t\t\t\t7521D76A291E9ABB009642EF /* StatementCreateTrigger.cpp in Sources */,\n\t\t\t\t7521D76B291E9ABB009642EF /* DatabasePool.cpp in Sources */,\n\t\t\t\t7521D76D291E9ABB009642EF /* WCTMigrationInfo.mm in Sources */,\n\t\t\t\t754212132B124CFF00A2FF4D /* CompressionCenter.cpp in Sources */,\n\t\t\t\t754211F62B12359400A2FF4D /* ScalarFunctionConfig.cpp in Sources */,\n\t\t\t\t7525175C2B12D43700485175 /* DecompressFunction.cpp in Sources */,\n\t\t\t\t7521D76E291E9ABB009642EF /* TokenizerModules.cpp in Sources */,\n\t\t\t\t758E7ED12B1B49EF00319991 /* WCTDatabase+Compression.mm in Sources */,\n\t\t\t\t7521D771291E9ABB009642EF /* FactoryDepositor.cpp in Sources */,\n\t\t\t\t7521D773291E9ABB009642EF /* WCTHandle+Convenient.mm in Sources */,\n\t\t\t\t7521D777291E9ABB009642EF /* TokenizerConfig.cpp in Sources */,\n\t\t\t\t7521D778291E9ABB009642EF /* FactoryRetriever.cpp in Sources */,\n\t\t\t\t7521D779291E9ABB009642EF /* WCTPreparedStatement.mm in Sources */,\n\t\t\t\t7521D77B291E9ABB009642EF /* StatementRollback.cpp in Sources */,\n\t\t\t\t751BFFCD2B9A31BD00B63FD3 /* WCTBridgeProperty.mm in Sources */,\n\t\t\t\t0DE84C7E2B03886800522A4E /* DecorativeHandleStatement.cpp in Sources */,\n\t\t\t\t7521D77C291E9ABB009642EF /* Exiting.cpp in Sources */,\n\t\t\t\t7521D77E291E9ABB009642EF /* NSNull+WCTColumnCoding.mm in Sources */,\n\t\t\t\t7521D77F291E9ABB009642EF /* Migration.cpp in Sources */,\n\t\t\t\t7521D780291E9ABB009642EF /* Configs.cpp in Sources */,\n\t\t\t\t7521D782291E9ABB009642EF /* SyntaxCreateTriggerSTMT.cpp in Sources */,\n\t\t\t\t7521D784291E9ABB009642EF /* Column.cpp in Sources */,\n\t\t\t\t7521D786291E9ABB009642EF /* WCTDatabase+Test.mm in Sources */,\n\t\t\t\t7521D788291E9ABB009642EF /* StatementSelect.cpp in Sources */,\n\t\t\t\t7521D78B291E9ABB009642EF /* OneOrBinaryTokenizer.cpp in Sources */,\n\t\t\t\t7521D78E291E9ABB009642EF /* WCTMaster.mm in Sources */,\n\t\t\t\t7521D78F291E9ABB009642EF /* SyntaxReindexSTMT.cpp in Sources */,\n\t\t\t\t7521D793291E9ABB009642EF /* SyntaxCreateViewSTMT.cpp in Sources */,\n\t\t\t\t754359472B066DBD00CDF232 /* HandleOperator.cpp in Sources */,\n\t\t\t\t7521D794291E9ABB009642EF /* BindParameter.cpp in Sources */,\n\t\t\t\t75C6E41829A0C2F0002579A5 /* WCDBOptional.cpp in Sources */,\n\t\t\t\t7521D795291E9ABB009642EF /* AutoBackupConfig.cpp in Sources */,\n\t\t\t\t7521D797291E9ABB009642EF /* WCTDatabase+Memory.mm in Sources */,\n\t\t\t\t7525176D2B12FDC700485175 /* ZSTDContext.cpp in Sources */,\n\t\t\t\t7521D799291E9ABB009642EF /* SyntaxRaiseFunction.cpp in Sources */,\n\t\t\t\t7521D79A291E9ABB009642EF /* FrameSpec.cpp in Sources */,\n\t\t\t\t7521D79D291E9ABB009642EF /* HandlePool.cpp in Sources */,\n\t\t\t\t7521D79F291E9ABB009642EF /* SyntaxWindowDef.cpp in Sources */,\n\t\t\t\t7521D7A0291E9ABB009642EF /* WCTValue.mm in Sources */,\n\t\t\t\t7521D7A1291E9ABB009642EF /* WCTDatabase+File.mm in Sources */,\n\t\t\t\t7521D7A3291E9ABB009642EF /* WCTDatabase+Monitor.mm in Sources */,\n\t\t\t\t7521D7A4291E9ABB009642EF /* PagerRelated.cpp in Sources */,\n\t\t\t\t7521D7A9291E9ABB009642EF /* SyntaxColumnDef.cpp in Sources */,\n\t\t\t\t7521D7AB291E9ABB009642EF /* WindowDef.cpp in Sources */,\n\t\t\t\t7521D7AC291E9ABB009642EF /* FileManager.cpp in Sources */,\n\t\t\t\t7521D7AD291E9ABB009642EF /* SyntaxColumn.cpp in Sources */,\n\t\t\t\t7521D7AE291E9ABB009642EF /* SyntaxFilter.cpp in Sources */,\n\t\t\t\t7542121B2B124CFF00A2FF4D /* CompressionInfo.cpp in Sources */,\n\t\t\t\t7521D7AF291E9ABB009642EF /* StatementDelete.cpp in Sources */,\n\t\t\t\t7521D7B0291E9ABB009642EF /* ErrorProne.cpp in Sources */,\n\t\t\t\t75D566FF2951B7EA00098DD9 /* WCTSequence.mm in Sources */,\n\t\t\t\t0D19BA0C2B0702250028F92B /* AssembleHandleOperator.cpp in Sources */,\n\t\t\t\t7521D7B1291E9ABB009642EF /* WCTMultiSelect.mm in Sources */,\n\t\t\t\t7521D7B2291E9ABB009642EF /* SyntaxInsertSTMT.cpp in Sources */,\n\t\t\t\t7521D7B5291E9ABB009642EF /* Shm.cpp in Sources */,\n\t\t\t\t7521D7B6291E9ABB009642EF /* InnerDatabase.cpp in Sources */,\n\t\t\t\t7521D7B7291E9ABB009642EF /* Pragma.cpp in Sources */,\n\t\t\t\t754211DD2B11FE9200A2FF4D /* ScalarFunctionModule.cpp in Sources */,\n\t\t\t\t7521D7B8291E9ABB009642EF /* UpgradeableErrorProne.cpp in Sources */,\n\t\t\t\t7521D7BA291E9ABB009642EF /* WCTDatabase+Version.mm in Sources */,\n\t\t\t\t7521D7BD291E9ABB009642EF /* SharedThreadedErrorProne.cpp in Sources */,\n\t\t\t\t7521D7BE291E9ABB009642EF /* LiteralValue.cpp in Sources */,\n\t\t\t\t7521D7C3291E9ABB009642EF /* SyntaxCreateIndexSTMT.cpp in Sources */,\n\t\t\t\t75E0A5C12A7F4EEE00D4FE9A /* CoreConst.cpp in Sources */,\n\t\t\t\t7521D7C7291E9ABB009642EF /* WCTInsert.mm in Sources */,\n\t\t\t\t7521D7C8291E9ABB009642EF /* WCTColumnBinding.mm in Sources */,\n\t\t\t\t7521D7C9291E9ABB009642EF /* WCTSelect.mm in Sources */,\n\t\t\t\t7521D7CC291E9ABB009642EF /* SyntaxAlterTableSTMT.cpp in Sources */,\n\t\t\t\t7521D7CD291E9ABB009642EF /* SyntaxCreateVirtualTableSTMT.cpp in Sources */,\n\t\t\t\t0D5403042B160693007DF415 /* CompressingStatementDecorator.cpp in Sources */,\n\t\t\t\t7521D7CE291E9ABB009642EF /* SyntaxAttachSTMT.cpp in Sources */,\n\t\t\t\t7521D7D0291E9ABB009642EF /* SyntaxJoinClause.cpp in Sources */,\n\t\t\t\t7521D7D1291E9ABB009642EF /* WCTDatabase+FTS.mm in Sources */,\n\t\t\t\t7521D7D2291E9ABB009642EF /* SyntaxDropTableSTMT.cpp in Sources */,\n\t\t\t\t7521D7D5291E9ABB009642EF /* SyntaxExplainSTMT.cpp in Sources */,\n\t\t\t\t0D19BA202B07481B0028F92B /* IntegerityHandleOperator.cpp in Sources */,\n\t\t\t\t754359512B0671DE00CDF232 /* BackupHandleOperator.cpp in Sources */,\n\t\t\t\t7521D7D9291E9ABB009642EF /* NSData+WCTColumnCoding.mm in Sources */,\n\t\t\t\t7521D7DA291E9ABB009642EF /* SyntaxLiteralValue.cpp in Sources */,\n\t\t\t\t7525178E2B133DB700485175 /* CompressHandleOperator.cpp in Sources */,\n\t\t\t\t7521D7DC291E9ABB009642EF /* StringView.cpp in Sources */,\n\t\t\t\t7521D7DF291E9ABB009642EF /* SyntaxRollbackSTMT.cpp in Sources */,\n\t\t\t\t7521D7E0291E9ABB009642EF /* HandleStatement.cpp in Sources */,\n\t\t\t\t7521D7E3291E9ABB009642EF /* CoreFunction.cpp in Sources */,\n\t\t\t\t7521D7E4291E9ABB009642EF /* WCTBinding.mm in Sources */,\n\t\t\t\t7521D7E5291E9ABB009642EF /* WCTDatabase+Convenient.mm in Sources */,\n\t\t\t\t7521D7E8291E9ABB009642EF /* FactoryRenewer.cpp in Sources */,\n\t\t\t\t75CB08CC2A88B9A300429364 /* HandleCounter.cpp in Sources */,\n\t\t\t\t7521D7E9291E9ABB009642EF /* TokenizerModule.cpp in Sources */,\n\t\t\t\t7521D7EA291E9ABB009642EF /* SyntaxFrameSpec.cpp in Sources */,\n\t\t\t\t7521D7EB291E9ABB009642EF /* WCTDatabase+Handle.mm in Sources */,\n\t\t\t\t7521D7EC291E9ABB009642EF /* SyntaxTableOrSubquery.cpp in Sources */,\n\t\t\t\t7521D7F0291E9ABB009642EF /* Time.cpp in Sources */,\n\t\t\t\t7521D7F1291E9ABB009642EF /* WCTTable+Convenient.mm in Sources */,\n\t\t\t\t7521D7F3291E9ABB009642EF /* WCTHandle+Transaction.mm in Sources */,\n\t\t\t\t7521D7F4291E9ABB009642EF /* StatementVacuum.cpp in Sources */,\n\t\t\t\t7521D7F5291E9ABB009642EF /* AbstractHandle.cpp in Sources */,\n\t\t\t\t7521D7F6291E9ABB009642EF /* WCTChainCall.mm in Sources */,\n\t\t\t\t7521D7F7291E9ABB009642EF /* WCTHandle+Table.mm in Sources */,\n\t\t\t\t75EF250B2AA42DD90009C99F /* EncryptedSerialization.cpp in Sources */,\n\t\t\t\t7521D7F8291E9ABB009642EF /* WCTUpdate.mm in Sources */,\n\t\t\t\t754212172B124CFF00A2FF4D /* ZSTDDict.cpp in Sources */,\n\t\t\t\t7521D7F9291E9ABB009642EF /* StatementExplain.cpp in Sources */,\n\t\t\t\t7521D7FA291E9ABB009642EF /* CommonCore.cpp in Sources */,\n\t\t\t\t7521D7FB291E9ABB009642EF /* SyntaxIndexedColumn.cpp in Sources */,\n\t\t\t\t7521D7FD291E9ABB009642EF /* Pager.cpp in Sources */,\n\t\t\t\t7521D803291E9ABB009642EF /* Console.cpp in Sources */,\n\t\t\t\t7521D805291E9ABB009642EF /* Upsert.cpp in Sources */,\n\t\t\t\t7521D806291E9ABB009642EF /* MasterItem.cpp in Sources */,\n\t\t\t\t7521D807291E9ABB009642EF /* StatementDropIndex.cpp in Sources */,\n\t\t\t\t7521D808291E9ABB009642EF /* WCDBError.cpp in Sources */,\n\t\t\t\t7521D809291E9ABB009642EF /* StatementInsert.cpp in Sources */,\n\t\t\t\t7521D80A291E9ABB009642EF /* SubstringMatchInfo.cpp in Sources */,\n\t\t\t\t7521D80D291E9ABB009642EF /* Assemble.cpp in Sources */,\n\t\t\t\t7521D80E291E9ABB009642EF /* Cell.cpp in Sources */,\n\t\t\t\t7521D810291E9ABB009642EF /* AuxiliaryFunctionConfig.cpp in Sources */,\n\t\t\t\t7521D812291E9ABB009642EF /* WCTDatabase+Migration.mm in Sources */,\n\t\t\t\t7521D814291E9ABB009642EF /* Frame.cpp in Sources */,\n\t\t\t\t7521D816291E9ABB009642EF /* Path.cpp in Sources */,\n\t\t\t\t7521D817291E9ABB009642EF /* CommonTableExpression.cpp in Sources */,\n\t\t\t\t7521D819291E9ABB009642EF /* PerformanceTraceConfig.cpp in Sources */,\n\t\t\t\t7521D81A291E9ABB009642EF /* StatementCommit.cpp in Sources */,\n\t\t\t\t7521D81B291E9ABB009642EF /* WCTSelectable.mm in Sources */,\n\t\t\t\t7521D81D291E9ABB009642EF /* AutoCheckpointConfig.cpp in Sources */,\n\t\t\t\t75A60AB029345A38009C1B3C /* Cipher.cpp in Sources */,\n\t\t\t\t7521D820291E9ABB009642EF /* Filter.cpp in Sources */,\n\t\t\t\t7533CB502B050FA300C8B47D /* MigratingHandleDecorator.cpp in Sources */,\n\t\t\t\t7521D821291E9ABB009642EF /* Thread.cpp in Sources */,\n\t\t\t\t7521D822291E9ABB009642EF /* OperationQueue.cpp in Sources */,\n\t\t\t\t7521D823291E9ABB009642EF /* AutoMergeFTSIndexConfig.cpp in Sources */,\n\t\t\t\t7521D825291E9ABB009642EF /* QualifiedTable.cpp in Sources */,\n\t\t\t\t7521D827291E9ABB009642EF /* BasicConfig.cpp in Sources */,\n\t\t\t\t7521D828291E9ABB009642EF /* StatementPragma.cpp in Sources */,\n\t\t\t\t7521D829291E9ABB009642EF /* MergeFTSIndexLogic.cpp in Sources */,\n\t\t\t\t7521D82A291E9ABB009642EF /* SyntaxAnalyzeSTMT.cpp in Sources */,\n\t\t\t\t7521D82C291E9ABB009642EF /* SyntaxQualifiedTableName.cpp in Sources */,\n\t\t\t\t7521D82D291E9ABB009642EF /* SyntaxSchema.cpp in Sources */,\n\t\t\t\t0D0247702B99B04500AD84E9 /* WCTCancellationSignal.mm in Sources */,\n\t\t\t\t7521D82E291E9ABB009642EF /* WCTProperty.mm in Sources */,\n\t\t\t\t752517762B132DAB00485175 /* CompressionConst.cpp in Sources */,\n\t\t\t\t7521D833291E9ABB009642EF /* WCTError.mm in Sources */,\n\t\t\t\t7521D835291E9ABB009642EF /* ColumnMeta.cpp in Sources */,\n\t\t\t\t7521D836291E9ABB009642EF /* UnsafeData.cpp in Sources */,\n\t\t\t\t7521D837291E9ABB009642EF /* ColumnDef.cpp in Sources */,\n\t\t\t\t7521D838291E9ABB009642EF /* NSString+WCTColumnCoding.mm in Sources */,\n\t\t\t\t7521D839291E9ABB009642EF /* TableConstraint.cpp in Sources */,\n\t\t\t\t7521D83A291E9ABB009642EF /* SyntaxColumnConstraint.cpp in Sources */,\n\t\t\t\t7521D83B291E9ABB009642EF /* Repairman.cpp in Sources */,\n\t\t\t\t7521D83C291E9ABB009642EF /* StatementBegin.cpp in Sources */,\n\t\t\t\t7521D83D291E9ABB009642EF /* WCTFileManager.mm in Sources */,\n\t\t\t\t7521D83E291E9ABB009642EF /* MigrationInfo.cpp in Sources */,\n\t\t\t\t7521D83F291E9ABB009642EF /* Material.cpp in Sources */,\n\t\t\t\t758E7EC32B1B41AA00319991 /* WCTCompressionInfo.mm in Sources */,\n\t\t\t\t7521D840291E9ABB009642EF /* ForeignKey.cpp in Sources */,\n\t\t\t\t7521D841291E9ABB009642EF /* Crawlable.cpp in Sources */,\n\t\t\t\t7521D843291E9ABB009642EF /* AggregateFunction.cpp in Sources */,\n\t\t\t\t7521D845291E9ABB009642EF /* SQLiteBase.cpp in Sources */,\n\t\t\t\t756F7F652B2CA4B5002AEA0A /* FactoryVacuum.cpp in Sources */,\n\t\t\t\t7521D846291E9ABB009642EF /* Join.cpp in Sources */,\n\t\t\t\t7521D847291E9ABB009642EF /* SyntaxCreateTableSTMT.cpp in Sources */,\n\t\t\t\t7521D84A291E9ABB009642EF /* FTSError.cpp in Sources */,\n\t\t\t\t0D3281692B04AC7A0027B973 /* FunctionContainer.cpp in Sources */,\n\t\t\t\t7521D84B291E9ABB009642EF /* SyntaxDropIndexSTMT.cpp in Sources */,\n\t\t\t\t7521D84D291E9ABB009642EF /* HandleRelated.cpp in Sources */,\n\t\t\t\t7521D84E291E9ABB009642EF /* SyntaxIdentifier.cpp in Sources */,\n\t\t\t\t7521D84F291E9ABB009642EF /* SyntaxBindParameter.cpp in Sources */,\n\t\t\t\t7521D850291E9ABB009642EF /* SyntaxDetachSTMT.cpp in Sources */,\n\t\t\t\t7521D851291E9ABB009642EF /* Page.cpp in Sources */,\n\t\t\t\t7521D854291E9ABB009642EF /* SyntaxOrderingTerm.cpp in Sources */,\n\t\t\t\t7521D856291E9ABB009642EF /* Serialization.cpp in Sources */,\n\t\t\t\t7521D85A291E9ABB009642EF /* DBOperationNotifier.cpp in Sources */,\n\t\t\t\t7521D85B291E9ABB009642EF /* PorterStemming.c in Sources */,\n\t\t\t\t7521D85E291E9ABB009642EF /* SQLiteAssembler.cpp in Sources */,\n\t\t\t\t7521D863291E9ABB009642EF /* FileHandle.cpp in Sources */,\n\t\t\t\t7521D868291E9ABB009642EF /* SyntaxJoinConstraint.cpp in Sources */,\n\t\t\t\t758E7EB92B1B24AD00319991 /* AutoCompressConfig.cpp in Sources */,\n\t\t\t\t7521D869291E9ABB009642EF /* WCTDatabase+Config.mm in Sources */,\n\t\t\t\t7521D86A291E9ABB009642EF /* SyntaxReleaseSTMT.cpp in Sources */,\n\t\t\t\t7521D86B291E9ABB009642EF /* WCTDatabase+Repair.mm in Sources */,\n\t\t\t\t7521D86D291E9ABB009642EF /* Schema.cpp in Sources */,\n\t\t\t\t7521D86E291E9ABB009642EF /* MasterCrawler.cpp in Sources */,\n\t\t\t\t7521D86F291E9ABB009642EF /* StatementReindex.cpp in Sources */,\n\t\t\t\t7521D870291E9ABB009642EF /* NSObject+WCTColumnCoding.mm in Sources */,\n\t\t\t\t7521D871291E9ABB009642EF /* WCTTable+ChainCall.mm in Sources */,\n\t\t\t\t7521D872291E9ABB009642EF /* Wal.cpp in Sources */,\n\t\t\t\t7521D873291E9ABB009642EF /* WCTFTSTokenizerUtil.mm in Sources */,\n\t\t\t\t7521D877291E9ABB009642EF /* WCTDelete.mm in Sources */,\n\t\t\t\t7521D878291E9ABB009642EF /* BusyRetryConfig.cpp in Sources */,\n\t\t\t\t7521D87B291E9ABB009642EF /* SyntaxSelectSTMT.cpp in Sources */,\n\t\t\t\t7521D87C291E9ABB009642EF /* InnerHandle.cpp in Sources */,\n\t\t\t\t7521D87F291E9ABB009642EF /* WCTDatabase+ChainCall.mm in Sources */,\n\t\t\t\t7521D880291E9ABB009642EF /* Lock.cpp in Sources */,\n\t\t\t\t7521D882291E9ABB009642EF /* WCTBaseAccessor.mm in Sources */,\n\t\t\t\t7521D884291E9ABB009642EF /* BaseBinding.cpp in Sources */,\n\t\t\t\t7521D885291E9ABB009642EF /* SyntaxSelectCore.cpp in Sources */,\n\t\t\t\t7521D888291E9ABB009642EF /* Value.cpp in Sources */,\n\t\t\t\t7521D889291E9ABB009642EF /* StatementRelease.cpp in Sources */,\n\t\t\t);\n\t\t\trunOnlyForDeploymentPostprocessing = 0;\n\t\t};\n\t\t7521DA57291EA349009642EF /* Sources */ = {\n\t\t\tisa = PBXSourcesBuildPhase;\n\t\t\tbuildActionMask = 2147483647;\n\t\t\tfiles = (\n\t\t\t\t7521DA58291EA349009642EF /* SQL.cpp in Sources */,\n\t\t\t\t7521DA59291EA349009642EF /* HighWater.cpp in Sources */,\n\t\t\t\t7521DA5A291EA349009642EF /* ConvertibleImplementation.cpp in Sources */,\n\t\t\t\t7521DA5B291EA349009642EF /* Scoreable.cpp in Sources */,\n\t\t\t\t7521DA5C291EA349009642EF /* StatementCreateView.cpp in Sources */,\n\t\t\t\t7521DA5D291EA349009642EF /* MappedData.cpp in Sources */,\n\t\t\t\t752517782B132DAB00485175 /* CompressionConst.cpp in Sources */,\n\t\t\t\t7521DA5E291EA349009642EF /* Backup.cpp in Sources */,\n\t\t\t\t7521DA5F291EA349009642EF /* Operable.swift in Sources */,\n\t\t\t\t7521DA60291EA349009642EF /* Master.swift in Sources */,\n\t\t\t\t7521DA61291EA349009642EF /* PinyinTokenizer.cpp in Sources */,\n\t\t\t\t7521DA62291EA349009642EF /* TableOrSubquery.swift in Sources */,\n\t\t\t\t7521DA63291EA349009642EF /* ColumnConstraint.swift in Sources */,\n\t\t\t\t7521DA64291EA349009642EF /* SQLTraceConfig.cpp in Sources */,\n\t\t\t\t7521DA66291EA349009642EF /* SyntaxPragma.cpp in Sources */,\n\t\t\t\t7521DA67291EA349009642EF /* ResultColumn.swift in Sources */,\n\t\t\t\t754359492B066DBD00CDF232 /* HandleOperator.cpp in Sources */,\n\t\t\t\t0D3281622B04A8E60027B973 /* DecorativeHandle.cpp in Sources */,\n\t\t\t\t7521DA68291EA349009642EF /* Factory.cpp in Sources */,\n\t\t\t\t7521DA6B291EA349009642EF /* Statement.cpp in Sources */,\n\t\t\t\t7521DA6C291EA349009642EF /* FactoryBackup.cpp in Sources */,\n\t\t\t\t7521DA6D291EA349009642EF /* FrameSpecBridge.cpp in Sources */,\n\t\t\t\t7521DA6E291EA349009642EF /* CustomConfig.cpp in Sources */,\n\t\t\t\t7521DA6F291EA349009642EF /* StatementDropView.cpp in Sources */,\n\t\t\t\t7521DA70291EA349009642EF /* Config.cpp in Sources */,\n\t\t\t\t7521DA73291EA349009642EF /* Tag.cpp in Sources */,\n\t\t\t\t7521DA74291EA349009642EF /* SyntaxSavepointSTMT.cpp in Sources */,\n\t\t\t\t7521DA75291EA349009642EF /* SyntaxDeleteSTMT.cpp in Sources */,\n\t\t\t\t7521DA76291EA349009642EF /* SyntaxCommitSTMT.cpp in Sources */,\n\t\t\t\t7521DA77291EA349009642EF /* UpdateInterface.swift in Sources */,\n\t\t\t\t7521DA78291EA349009642EF /* StatementCreateViewBridge.cpp in Sources */,\n\t\t\t\t7521DA79291EA349009642EF /* TableCodable.swift in Sources */,\n\t\t\t\t7521DA7A291EA349009642EF /* Notifier.cpp in Sources */,\n\t\t\t\t7521DA7B291EA349009642EF /* StatementInsert.swift in Sources */,\n\t\t\t\t7521DA7C291EA349009642EF /* SyntaxDropViewSTMT.cpp in Sources */,\n\t\t\t\t7521DA7D291EA349009642EF /* StatementPragma.swift in Sources */,\n\t\t\t\t7521DA7E291EA349009642EF /* Value.swift in Sources */,\n\t\t\t\t7521DA7F291EA349009642EF /* OrderingTerm.cpp in Sources */,\n\t\t\t\t7521DA80291EA349009642EF /* StatementRollback.swift in Sources */,\n\t\t\t\t7521DA81291EA349009642EF /* ColumnType.cpp in Sources */,\n\t\t\t\t759362D22B36D450000AF163 /* Vacuum.cpp in Sources */,\n\t\t\t\t7521DA83291EA349009642EF /* StatementAttach.cpp in Sources */,\n\t\t\t\t750080D92920DCFF009C0F38 /* WCTFileManager.mm in Sources */,\n\t\t\t\t7521DA84291EA349009642EF /* Fraction.cpp in Sources */,\n\t\t\t\t7521DA85291EA349009642EF /* ColumnDefBridge.cpp in Sources */,\n\t\t\t\t7521DA86291EA349009642EF /* SyntaxTableConstraint.cpp in Sources */,\n\t\t\t\t7521DA87291EA349009642EF /* SequenceCrawler.cpp in Sources */,\n\t\t\t\t7521DA88291EA349009642EF /* VirtualTableConfig.swift in Sources */,\n\t\t\t\t7521DA89291EA349009642EF /* StatementReleaseBridge.cpp in Sources */,\n\t\t\t\t7521DA8A291EA349009642EF /* StatementDropView.swift in Sources */,\n\t\t\t\t7521DA8B291EA349009642EF /* TableDecoder.swift in Sources */,\n\t\t\t\t0D19BA222B07481B0028F92B /* IntegerityHandleOperator.cpp in Sources */,\n\t\t\t\t7521DA8C291EA349009642EF /* TableEncoder.swift in Sources */,\n\t\t\t\t7521DA8D291EA349009642EF /* StatementDropTrigger.cpp in Sources */,\n\t\t\t\t7521DA8E291EA349009642EF /* ExpressionOperable.cpp in Sources */,\n\t\t\t\t7521DA8F291EA349009642EF /* StatementDetach.swift in Sources */,\n\t\t\t\t7521DA90291EA349009642EF /* SQLiteLocker.cpp in Sources */,\n\t\t\t\t7521DA91291EA349009642EF /* PreparedStatement.swift in Sources */,\n\t\t\t\t7521DA93291EA349009642EF /* Column.swift in Sources */,\n\t\t\t\t7521DA94291EA349009642EF /* StatementUpdate.cpp in Sources */,\n\t\t\t\t7521DA95291EA349009642EF /* SyntaxResultColumn.cpp in Sources */,\n\t\t\t\t7521DA96291EA349009642EF /* Initializeable.cpp in Sources */,\n\t\t\t\t752517842B1338AF00485175 /* CompressionRecord.cpp in Sources */,\n\t\t\t\t7521DA97291EA349009642EF /* PageBasedFileHandle.cpp in Sources */,\n\t\t\t\t754211DF2B11FE9200A2FF4D /* ScalarFunctionModule.cpp in Sources */,\n\t\t\t\t75CB08CE2A88B9A300429364 /* HandleCounter.cpp in Sources */,\n\t\t\t\t7521DA98291EA349009642EF /* OrderingTerm.swift in Sources */,\n\t\t\t\t7521DA99291EA349009642EF /* Progress.cpp in Sources */,\n\t\t\t\t7521DA9A291EA349009642EF /* Mechanic.cpp in Sources */,\n\t\t\t\t75294DB229C75058005E7FC0 /* OperationQueueForMemory.cpp in Sources */,\n\t\t\t\t7521DA9D291EA349009642EF /* SyntaxUpdateSTMT.cpp in Sources */,\n\t\t\t\t7521DA9E291EA349009642EF /* StatementReindexBridge.cpp in Sources */,\n\t\t\t\t7521DA9F291EA349009642EF /* Selectable.swift in Sources */,\n\t\t\t\t7521DAA1291EA349009642EF /* StatementCreateIndex.cpp in Sources */,\n\t\t\t\t7521DAA3291EA349009642EF /* StatementDetach.cpp in Sources */,\n\t\t\t\t7521DAA4291EA349009642EF /* ColumnConstraintBridge.cpp in Sources */,\n\t\t\t\t7521DAA5291EA349009642EF /* StatementAnalyze.cpp in Sources */,\n\t\t\t\t7521DAA6291EA349009642EF /* IndexConfig.swift in Sources */,\n\t\t\t\t7521DAA8291EA349009642EF /* FTSFunction.cpp in Sources */,\n\t\t\t\t7521DAA9291EA349009642EF /* RecyclableHandle.cpp in Sources */,\n\t\t\t\t7521DAAA291EA349009642EF /* ErrorBridge.swift in Sources */,\n\t\t\t\t7521DAAC291EA349009642EF /* StatementExplain.swift in Sources */,\n\t\t\t\t7521DAAD291EA349009642EF /* ResultColumn.cpp in Sources */,\n\t\t\t\t7521DAAE291EA349009642EF /* StatementRollbackBridge.cpp in Sources */,\n\t\t\t\t7521DAAF291EA349009642EF /* FullCrawler.cpp in Sources */,\n\t\t\t\t7521DAB0291EA349009642EF /* SyntaxVacuumSTMT.cpp in Sources */,\n\t\t\t\t0D32816B2B04AC7A0027B973 /* FunctionContainer.cpp in Sources */,\n\t\t\t\t7521DAB1291EA349009642EF /* ForeignKey.swift in Sources */,\n\t\t\t\t7521DAB2291EA349009642EF /* TableCRUDInterface.swift in Sources */,\n\t\t\t\t7521DAB3291EA349009642EF /* StatementCreateTable.cpp in Sources */,\n\t\t\t\t7521DAB4291EA349009642EF /* HandleNotification.cpp in Sources */,\n\t\t\t\t7521DAB5291EA349009642EF /* SequenceItem.cpp in Sources */,\n\t\t\t\t7521DAB6291EA349009642EF /* AuxiliaryFunctionModule.cpp in Sources */,\n\t\t\t\t7521DAB9291EA349009642EF /* StatementDropTable.swift in Sources */,\n\t\t\t\t7521DABA291EA349009642EF /* StatementAlterTable.cpp in Sources */,\n\t\t\t\t7521DABB291EA349009642EF /* CipherConfig.cpp in Sources */,\n\t\t\t\t7521DABC291EA349009642EF /* FactoryRelated.cpp in Sources */,\n\t\t\t\t7521DABD291EA349009642EF /* ForeignKeyConfig.swift in Sources */,\n\t\t\t\t7521DABE291EA349009642EF /* Global.cpp in Sources */,\n\t\t\t\t7521DAC0291EA349009642EF /* FTSBridge.cpp in Sources */,\n\t\t\t\t7521DAC1291EA349009642EF /* MultiUniqueConfig.swift in Sources */,\n\t\t\t\t7521DAC2291EA349009642EF /* ResultColumnBridge.cpp in Sources */,\n\t\t\t\t7521DAC3291EA349009642EF /* StatementCreateTrigger.swift in Sources */,\n\t\t\t\t7521DAC4291EA349009642EF /* SyntaxDropTriggerSTMT.cpp in Sources */,\n\t\t\t\t7521DAC5291EA349009642EF /* UpsertBridge.cpp in Sources */,\n\t\t\t\t7521DAC6291EA349009642EF /* AsyncQueue.cpp in Sources */,\n\t\t\t\t7521DAC7291EA349009642EF /* SyntaxUpsertClause.cpp in Sources */,\n\t\t\t\t7521DAC9291EA349009642EF /* OrderingTermBridge.cpp in Sources */,\n\t\t\t\t7521DACA291EA349009642EF /* Expression.cpp in Sources */,\n\t\t\t\t7521DACB291EA349009642EF /* Lock.swift in Sources */,\n\t\t\t\t7521DACC291EA349009642EF /* SyntaxPragmaSTMT.cpp in Sources */,\n\t\t\t\t7521DACD291EA349009642EF /* CodingTableKey.swift in Sources */,\n\t\t\t\t0D5403062B160693007DF415 /* CompressingStatementDecorator.cpp in Sources */,\n\t\t\t\t7521DAD0291EA349009642EF /* WinqBridge.cpp in Sources */,\n\t\t\t\t7521DAD1291EA349009642EF /* ErrorBridge.cpp in Sources */,\n\t\t\t\t750080E22920E4A1009C0F38 /* WCTFTSTokenizerUtil.mm in Sources */,\n\t\t\t\t7521DAD2291EA349009642EF /* Identifier.swift in Sources */,\n\t\t\t\t7521DAD3291EA349009642EF /* RaiseFunction.swift in Sources */,\n\t\t\t\t7542121D2B124CFF00A2FF4D /* CompressionInfo.cpp in Sources */,\n\t\t\t\t7521DAD4291EA349009642EF /* StatementAnalyzeBridge.cpp in Sources */,\n\t\t\t\t7521DAD6291EA349009642EF /* ColumnTypeDecoder.swift in Sources */,\n\t\t\t\t7521DAD7291EA349009642EF /* Redirectable.swift in Sources */,\n\t\t\t\t752CF3F9293A490F009ED8FB /* BindingBridge.cpp in Sources */,\n\t\t\t\t7521DAD8291EA349009642EF /* StatementExplainBridge.cpp in Sources */,\n\t\t\t\t7521DAD9291EA349009642EF /* JoinConstraint.cpp in Sources */,\n\t\t\t\t7521DADA291EA349009642EF /* StatementDropTriggerBridge.cpp in Sources */,\n\t\t\t\t7521DADC291EA349009642EF /* StatementCreateIndexBridge.cpp in Sources */,\n\t\t\t\t750080DA2920DD1B009C0F38 /* WCTOperationQueue.mm in Sources */,\n\t\t\t\t7521DADD291EA349009642EF /* AutoMigrateConfig.cpp in Sources */,\n\t\t\t\t752517902B133DB700485175 /* CompressHandleOperator.cpp in Sources */,\n\t\t\t\t7521DADE291EA349009642EF /* TableOrSubquery.cpp in Sources */,\n\t\t\t\t7521DAE0291EA349009642EF /* WalRelated.cpp in Sources */,\n\t\t\t\t7521DAE1291EA349009642EF /* SyntaxBeginSTMT.cpp in Sources */,\n\t\t\t\t7521DAE2291EA349009642EF /* SyntaxCommonTableExpression.cpp in Sources */,\n\t\t\t\t7521DAE3291EA349009642EF /* StatementCreateVirtualTable.swift in Sources */,\n\t\t\t\t7521DAE4291EA349009642EF /* StatementDropTable.cpp in Sources */,\n\t\t\t\t75ADC5672A8D1C2D00D0AC47 /* TableAttribute.cpp in Sources */,\n\t\t\t\t7521DAE5291EA349009642EF /* Insert.swift in Sources */,\n\t\t\t\t7521DAE7291EA349009642EF /* SyntaxExpression.cpp in Sources */,\n\t\t\t\t7521DAE8291EA349009642EF /* StatementCreateVirtualTable.cpp in Sources */,\n\t\t\t\t7521DAE9291EA349009642EF /* SyntaxCommonConst.cpp in Sources */,\n\t\t\t\t7521DAEA291EA349009642EF /* StatementSavepoint.cpp in Sources */,\n\t\t\t\t7521DAEB291EA349009642EF /* Recyclable.cpp in Sources */,\n\t\t\t\t7521DAEC291EA349009642EF /* Data.cpp in Sources */,\n\t\t\t\t7521DAED291EA349009642EF /* TransactionInterface.swift in Sources */,\n\t\t\t\t7521DAEE291EA349009642EF /* SyntaxForeignKeyClause.cpp in Sources */,\n\t\t\t\t7521DAEF291EA349009642EF /* IndexedColumn.cpp in Sources */,\n\t\t\t\t7521DAF0291EA349009642EF /* BaseTokenizerUtil.cpp in Sources */,\n\t\t\t\t7521DAF1291EA349009642EF /* RaiseFunction.cpp in Sources */,\n\t\t\t\t7521DAF2291EA349009642EF /* TableOrSubqueryBridge.cpp in Sources */,\n\t\t\t\t0DE84C802B03886800522A4E /* DecorativeHandleStatement.cpp in Sources */,\n\t\t\t\t7521DAF4291EA349009642EF /* ColumnConstraint.cpp in Sources */,\n\t\t\t\t7521DAF7291EA349009642EF /* Table.swift in Sources */,\n\t\t\t\t7521DAF8291EA349009642EF /* Range.cpp in Sources */,\n\t\t\t\t7521DAFA291EA349009642EF /* ThreadedErrors.cpp in Sources */,\n\t\t\t\t7521DAFB291EA349009642EF /* StatementAlterTableBridge.cpp in Sources */,\n\t\t\t\t7521DAFC291EA349009642EF /* TableConstraintBridge.cpp in Sources */,\n\t\t\t\t7521DAFD291EA349009642EF /* StatementDropViewBridge.cpp in Sources */,\n\t\t\t\t7521DAFE291EA349009642EF /* StatementCommit.swift in Sources */,\n\t\t\t\t7521DB00291EA349009642EF /* StatementCreateTrigger.cpp in Sources */,\n\t\t\t\t7521DB01291EA349009642EF /* DatabasePool.cpp in Sources */,\n\t\t\t\t7521DB02291EA349009642EF /* IndexedColumnBridge.cpp in Sources */,\n\t\t\t\t75E0A5D72A7FE2A200D4FE9A /* ContainerBridge.cpp in Sources */,\n\t\t\t\t7521DB04291EA349009642EF /* TokenizerModules.cpp in Sources */,\n\t\t\t\t7521DB05291EA349009642EF /* MultiSelect.swift in Sources */,\n\t\t\t\t7521DB06291EA349009642EF /* StatementUpdate.swift in Sources */,\n\t\t\t\t7521DB07291EA349009642EF /* FactoryDepositor.cpp in Sources */,\n\t\t\t\t7521DB08291EA349009642EF /* Update.swift in Sources */,\n\t\t\t\t7521DB0A291EA349009642EF /* SelectInterface.swift in Sources */,\n\t\t\t\t7521DB0B291EA349009642EF /* StatementDropTrigger.swift in Sources */,\n\t\t\t\t7521DB0C291EA349009642EF /* SyntaxConst.swift in Sources */,\n\t\t\t\t0DCD2AC62C6E210700C247EC /* AutoVacuumConfig.cpp in Sources */,\n\t\t\t\t7521DB0D291EA349009642EF /* TokenizerConfig.cpp in Sources */,\n\t\t\t\t7521DB0E291EA349009642EF /* FactoryRetriever.cpp in Sources */,\n\t\t\t\t7521DB10291EA349009642EF /* StatementAttachBridge.cpp in Sources */,\n\t\t\t\t7521DB11291EA349009642EF /* StatementRollback.cpp in Sources */,\n\t\t\t\t7521DB12291EA349009642EF /* Exiting.cpp in Sources */,\n\t\t\t\t7521DB13291EA349009642EF /* BindParameterBridge.cpp in Sources */,\n\t\t\t\t7521DB15291EA349009642EF /* Migration.cpp in Sources */,\n\t\t\t\t7521DB16291EA349009642EF /* Configs.cpp in Sources */,\n\t\t\t\t7521DB18291EA349009642EF /* SyntaxCreateTriggerSTMT.cpp in Sources */,\n\t\t\t\t7521DB19291EA349009642EF /* StatementReindex.swift in Sources */,\n\t\t\t\t7521DB1A291EA349009642EF /* Column.cpp in Sources */,\n\t\t\t\t7521DB1B291EA349009642EF /* StatementPragmaBridge.cpp in Sources */,\n\t\t\t\t7521DB1D291EA349009642EF /* HandleBridge.cpp in Sources */,\n\t\t\t\t7521DB1E291EA349009642EF /* StatementSelect.cpp in Sources */,\n\t\t\t\t7521DB1F291EA349009642EF /* StatementCreateIndex.swift in Sources */,\n\t\t\t\t7521DB20291EA349009642EF /* StatementCreateTable.swift in Sources */,\n\t\t\t\t7521DB21291EA349009642EF /* OneOrBinaryTokenizer.cpp in Sources */,\n\t\t\t\t7521DB22291EA349009642EF /* Pragma.swift in Sources */,\n\t\t\t\t754212212B124CFF00A2FF4D /* Compression.cpp in Sources */,\n\t\t\t\t0D19BA0E2B0702250028F92B /* AssembleHandleOperator.cpp in Sources */,\n\t\t\t\t7521DB23291EA349009642EF /* QualifiedTable.swift in Sources */,\n\t\t\t\t7521DB25291EA349009642EF /* SyntaxReindexSTMT.cpp in Sources */,\n\t\t\t\t0D5403102B1606BC007DF415 /* CompressingHandleDecorator.cpp in Sources */,\n\t\t\t\t0DD8D11A2B074C47002C97D3 /* MigrateHandleOperator.cpp in Sources */,\n\t\t\t\t7521DB26291EA349009642EF /* StatementDetachBridge.cpp in Sources */,\n\t\t\t\t7521DB28291EA349009642EF /* ColumnBridge.cpp in Sources */,\n\t\t\t\t7521DB29291EA349009642EF /* SyntaxCreateViewSTMT.cpp in Sources */,\n\t\t\t\t7521DB2A291EA349009642EF /* BindParameter.cpp in Sources */,\n\t\t\t\t7521DB2B291EA349009642EF /* AutoBackupConfig.cpp in Sources */,\n\t\t\t\t7521DB2C291EA349009642EF /* TableInterface.swift in Sources */,\n\t\t\t\t7521DB2E291EA349009642EF /* ChainCall.swift in Sources */,\n\t\t\t\t7521DB2F291EA349009642EF /* SyntaxRaiseFunction.cpp in Sources */,\n\t\t\t\t7521DB30291EA349009642EF /* FrameSpec.cpp in Sources */,\n\t\t\t\t7521DB31291EA349009642EF /* FrameSpec.swift in Sources */,\n\t\t\t\t7533CB5C2B050FB200C8B47D /* MigratingStatementDecorator.cpp in Sources */,\n\t\t\t\t750080F32920F3D5009C0F38 /* WCTFoundation.mm in Sources */,\n\t\t\t\t7521DB32291EA349009642EF /* Recyclable.swift in Sources */,\n\t\t\t\t7521DB33291EA349009642EF /* HandlePool.cpp in Sources */,\n\t\t\t\t7521DB35291EA349009642EF /* SyntaxWindowDef.cpp in Sources */,\n\t\t\t\t7521DB3A291EA349009642EF /* PagerRelated.cpp in Sources */,\n\t\t\t\t7521DB3B291EA349009642EF /* Statement.swift in Sources */,\n\t\t\t\t7521DB3D291EA349009642EF /* WindowDef.swift in Sources */,\n\t\t\t\t754211F82B12359400A2FF4D /* ScalarFunctionConfig.cpp in Sources */,\n\t\t\t\t7521DB3E291EA349009642EF /* ExpressionBridge.cpp in Sources */,\n\t\t\t\t7521DB3F291EA349009642EF /* SyntaxColumnDef.cpp in Sources */,\n\t\t\t\t7521DB40291EA349009642EF /* Upsert.swift in Sources */,\n\t\t\t\t7521DB41291EA349009642EF /* WindowDef.cpp in Sources */,\n\t\t\t\t7521DB42291EA349009642EF /* FileManager.cpp in Sources */,\n\t\t\t\t7521DB43291EA349009642EF /* SyntaxColumn.cpp in Sources */,\n\t\t\t\t7521DB44291EA349009642EF /* SyntaxFilter.cpp in Sources */,\n\t\t\t\t7521DB45291EA349009642EF /* StatementDelete.cpp in Sources */,\n\t\t\t\t7521DB46291EA349009642EF /* ErrorProne.cpp in Sources */,\n\t\t\t\t7521DB48291EA349009642EF /* SyntaxInsertSTMT.cpp in Sources */,\n\t\t\t\t7521DB4A291EA349009642EF /* JoinBridge.cpp in Sources */,\n\t\t\t\t7521DB4B291EA349009642EF /* Shm.cpp in Sources */,\n\t\t\t\t756F7F672B2CA4B5002AEA0A /* FactoryVacuum.cpp in Sources */,\n\t\t\t\t7525175E2B12D43700485175 /* DecompressFunction.cpp in Sources */,\n\t\t\t\t7521DB4C291EA349009642EF /* InnerDatabase.cpp in Sources */,\n\t\t\t\t7521DB4D291EA349009642EF /* Pragma.cpp in Sources */,\n\t\t\t\t7521DB4E291EA349009642EF /* UpgradeableErrorProne.cpp in Sources */,\n\t\t\t\t7521DB4F291EA349009642EF /* StatementAlterTable.swift in Sources */,\n\t\t\t\t7521DB51291EA349009642EF /* ExpressionOperatableBridge.cpp in Sources */,\n\t\t\t\t7521DB53291EA349009642EF /* SharedThreadedErrorProne.cpp in Sources */,\n\t\t\t\t7521DB54291EA349009642EF /* LiteralValue.cpp in Sources */,\n\t\t\t\t7521DB55291EA349009642EF /* Declare.swift in Sources */,\n\t\t\t\t7521DB56291EA349009642EF /* CheckExpressionConfig.swift in Sources */,\n\t\t\t\t7500828C29222A93009C0F38 /* WCTAPIBridge.mm in Sources */,\n\t\t\t\t7521DB57291EA349009642EF /* StatementVacuumBridge.cpp in Sources */,\n\t\t\t\t7521DB58291EA349009642EF /* Select.swift in Sources */,\n\t\t\t\t754359532B0671DE00CDF232 /* BackupHandleOperator.cpp in Sources */,\n\t\t\t\t7521DB59291EA349009642EF /* SyntaxCreateIndexSTMT.cpp in Sources */,\n\t\t\t\t75EF250D2AA42DD90009C99F /* EncryptedSerialization.cpp in Sources */,\n\t\t\t\t7521DB5A291EA349009642EF /* HandleStatementBridge.cpp in Sources */,\n\t\t\t\t7521DB5B291EA349009642EF /* CommonTableExpressionBridge.cpp in Sources */,\n\t\t\t\t7521DB5C291EA349009642EF /* InsertInterface.swift in Sources */,\n\t\t\t\t7521DB60291EA349009642EF /* StatementCommitBridge.cpp in Sources */,\n\t\t\t\t7521DB61291EA349009642EF /* ColumnConstraintConfig.swift in Sources */,\n\t\t\t\t7521DB62291EA349009642EF /* SyntaxAlterTableSTMT.cpp in Sources */,\n\t\t\t\t7521DB63291EA349009642EF /* SyntaxCreateVirtualTableSTMT.cpp in Sources */,\n\t\t\t\t7521DB64291EA349009642EF /* SyntaxAttachSTMT.cpp in Sources */,\n\t\t\t\t7521DB66291EA349009642EF /* SyntaxJoinClause.cpp in Sources */,\n\t\t\t\t7521DB68291EA349009642EF /* SyntaxDropTableSTMT.cpp in Sources */,\n\t\t\t\t7521DB6A291EA349009642EF /* StatementSelect.swift in Sources */,\n\t\t\t\t7521DB6B291EA349009642EF /* SyntaxExplainSTMT.cpp in Sources */,\n\t\t\t\t7521DB6D291EA349009642EF /* StatementVacuum.swift in Sources */,\n\t\t\t\t7521DB70291EA349009642EF /* SyntaxLiteralValue.cpp in Sources */,\n\t\t\t\t7529C7722ABC4D6D00518293 /* CipherHandle.cpp in Sources */,\n\t\t\t\t7521DB71291EA349009642EF /* StatementUpdateBridge.cpp in Sources */,\n\t\t\t\t7521DB72291EA349009642EF /* StringView.cpp in Sources */,\n\t\t\t\t7521DB73291EA349009642EF /* LiteralValue.swift in Sources */,\n\t\t\t\t7521DB74291EA349009642EF /* StatementDropIndexBridge.cpp in Sources */,\n\t\t\t\t7521DB75291EA349009642EF /* SyntaxRollbackSTMT.cpp in Sources */,\n\t\t\t\t7521DB76291EA349009642EF /* HandleStatement.cpp in Sources */,\n\t\t\t\t7521DB78291EA349009642EF /* LiteralValueBridge.cpp in Sources */,\n\t\t\t\t7521DB79291EA349009642EF /* CoreFunction.cpp in Sources */,\n\t\t\t\t7521DB7C291EA349009642EF /* StatementCreateTriggerBridge.cpp in Sources */,\n\t\t\t\t7521DB7D291EA349009642EF /* StatementCreateTableBridge.cpp in Sources */,\n\t\t\t\t754212192B124CFF00A2FF4D /* ZSTDDict.cpp in Sources */,\n\t\t\t\t7521DB7E291EA349009642EF /* FactoryRenewer.cpp in Sources */,\n\t\t\t\t7521DB7F291EA349009642EF /* TokenizerModule.cpp in Sources */,\n\t\t\t\t7521DB80291EA349009642EF /* SyntaxFrameSpec.cpp in Sources */,\n\t\t\t\t7521DB82291EA349009642EF /* SyntaxTableOrSubquery.cpp in Sources */,\n\t\t\t\t7525176F2B12FDC700485175 /* ZSTDContext.cpp in Sources */,\n\t\t\t\t7521DB84291EA349009642EF /* StatementAttach.swift in Sources */,\n\t\t\t\t7521DB85291EA349009642EF /* Expression.swift in Sources */,\n\t\t\t\t7521DB86291EA349009642EF /* Time.cpp in Sources */,\n\t\t\t\t7521DB8A291EA349009642EF /* StatementVacuum.cpp in Sources */,\n\t\t\t\t7521DB8B291EA349009642EF /* AbstractHandle.cpp in Sources */,\n\t\t\t\t7521DB8F291EA349009642EF /* StatementExplain.cpp in Sources */,\n\t\t\t\t7521DB90291EA349009642EF /* CommonCore.cpp in Sources */,\n\t\t\t\t7521DB91291EA349009642EF /* SyntaxIndexedColumn.cpp in Sources */,\n\t\t\t\t75A60AB229345A38009C1B3C /* Cipher.cpp in Sources */,\n\t\t\t\t0DAD93C229FA2A1200E5788C /* TableChainCall.swift in Sources */,\n\t\t\t\t7521DB92291EA349009642EF /* TableConstraint.swift in Sources */,\n\t\t\t\t7521DB93291EA349009642EF /* Pager.cpp in Sources */,\n\t\t\t\t7521DB94291EA349009642EF /* StatementInterface.swift in Sources */,\n\t\t\t\t7521DB95291EA349009642EF /* StatementAnalyze.swift in Sources */,\n\t\t\t\t7521DB96291EA349009642EF /* StatementBegin.swift in Sources */,\n\t\t\t\t0DB806A32B972E2F00D5E86D /* WCTBridgeProperty.swift in Sources */,\n\t\t\t\t7521DB97291EA349009642EF /* StatementSavepointBridge.cpp in Sources */,\n\t\t\t\t7521DB98291EA349009642EF /* Handle.swift in Sources */,\n\t\t\t\t7521DB99291EA349009642EF /* Console.cpp in Sources */,\n\t\t\t\t7521DB9A291EA349009642EF /* IndexedColumn.swift in Sources */,\n\t\t\t\t754212152B124CFF00A2FF4D /* CompressionCenter.cpp in Sources */,\n\t\t\t\t7521DB9B291EA349009642EF /* Upsert.cpp in Sources */,\n\t\t\t\t7521DB9C291EA349009642EF /* MasterItem.cpp in Sources */,\n\t\t\t\t7521DB9D291EA349009642EF /* StatementDropIndex.cpp in Sources */,\n\t\t\t\t7521DB9E291EA349009642EF /* WCDBError.cpp in Sources */,\n\t\t\t\t7521DB9F291EA349009642EF /* StatementInsert.cpp in Sources */,\n\t\t\t\t7521DBA0291EA349009642EF /* SubstringMatchInfo.cpp in Sources */,\n\t\t\t\t7521DBA1291EA349009642EF /* CommonTableExpression.swift in Sources */,\n\t\t\t\t7521DBA2291EA349009642EF /* StatementCreateVirtualTableBridge.cpp in Sources */,\n\t\t\t\t7521DBA3291EA349009642EF /* Assemble.cpp in Sources */,\n\t\t\t\t7521DBA4291EA349009642EF /* Cell.cpp in Sources */,\n\t\t\t\t7521DBA5291EA349009642EF /* RaiseFunctionBridge.cpp in Sources */,\n\t\t\t\t7521DBA6291EA349009642EF /* AuxiliaryFunctionConfig.cpp in Sources */,\n\t\t\t\t75E0A5C32A7F4EEE00D4FE9A /* CoreConst.cpp in Sources */,\n\t\t\t\t7521DBA7291EA349009642EF /* Optional.swift in Sources */,\n\t\t\t\t7521DBA9291EA349009642EF /* RowSelect.swift in Sources */,\n\t\t\t\t758E7EBB2B1B24AD00319991 /* AutoCompressConfig.cpp in Sources */,\n\t\t\t\t7521DBAA291EA349009642EF /* Frame.cpp in Sources */,\n\t\t\t\t7521DBAB291EA349009642EF /* ObjectBridge.swift in Sources */,\n\t\t\t\t7521DBAC291EA349009642EF /* Path.cpp in Sources */,\n\t\t\t\t7521DBAD291EA349009642EF /* CommonTableExpression.cpp in Sources */,\n\t\t\t\t7521DBAE291EA349009642EF /* SchemaBridge.cpp in Sources */,\n\t\t\t\t7521DBAF291EA349009642EF /* PerformanceTraceConfig.cpp in Sources */,\n\t\t\t\t7521DBB0291EA349009642EF /* StatementCommit.cpp in Sources */,\n\t\t\t\t7521DBB3291EA349009642EF /* AutoCheckpointConfig.cpp in Sources */,\n\t\t\t\t7521DBB4291EA349009642EF /* ColumnDef.swift in Sources */,\n\t\t\t\t7521DBB5291EA349009642EF /* ObjectBridge.cpp in Sources */,\n\t\t\t\t7521DBB6291EA349009642EF /* Filter.cpp in Sources */,\n\t\t\t\t7521DBB7291EA349009642EF /* Thread.cpp in Sources */,\n\t\t\t\t7521DBB8291EA349009642EF /* OperationQueue.cpp in Sources */,\n\t\t\t\t7521DBB9291EA349009642EF /* AutoMergeFTSIndexConfig.cpp in Sources */,\n\t\t\t\t7521DBBA291EA349009642EF /* ForeignKeyBridge.cpp in Sources */,\n\t\t\t\t7521DBBB291EA349009642EF /* QualifiedTable.cpp in Sources */,\n\t\t\t\t7521DBBC291EA349009642EF /* QualifiedTableBridge.cpp in Sources */,\n\t\t\t\t7521DBBD291EA349009642EF /* BasicConfig.cpp in Sources */,\n\t\t\t\t7521DBBE291EA349009642EF /* StatementPragma.cpp in Sources */,\n\t\t\t\t7521DBBF291EA349009642EF /* MergeFTSIndexLogic.cpp in Sources */,\n\t\t\t\t7521DBC0291EA349009642EF /* SyntaxAnalyzeSTMT.cpp in Sources */,\n\t\t\t\t7521DBC1291EA349009642EF /* StatementSelectBridge.cpp in Sources */,\n\t\t\t\t7521DBC2291EA349009642EF /* SyntaxQualifiedTableName.cpp in Sources */,\n\t\t\t\t7521DBC3291EA349009642EF /* SyntaxSchema.cpp in Sources */,\n\t\t\t\t7521DBC5291EA349009642EF /* Database.swift in Sources */,\n\t\t\t\t7521DBC6291EA349009642EF /* TableConfiguration.swift in Sources */,\n\t\t\t\t7521DBC7291EA349009642EF /* Convertible.swift in Sources */,\n\t\t\t\t7521DBCA291EA349009642EF /* Schema.swift in Sources */,\n\t\t\t\t7521DBCB291EA349009642EF /* ColumnMeta.cpp in Sources */,\n\t\t\t\t7521DBCC291EA349009642EF /* UnsafeData.cpp in Sources */,\n\t\t\t\t7521DBCD291EA349009642EF /* ColumnDef.cpp in Sources */,\n\t\t\t\t7521DBCF291EA349009642EF /* TableConstraint.cpp in Sources */,\n\t\t\t\t7521DBD0291EA349009642EF /* SyntaxColumnConstraint.cpp in Sources */,\n\t\t\t\t7521DBD1291EA349009642EF /* Repairman.cpp in Sources */,\n\t\t\t\t7521DBD2291EA349009642EF /* StatementBegin.cpp in Sources */,\n\t\t\t\t7521DBD4291EA349009642EF /* MigrationInfo.cpp in Sources */,\n\t\t\t\t7521DBD5291EA349009642EF /* Material.cpp in Sources */,\n\t\t\t\t7521DBD6291EA349009642EF /* ForeignKey.cpp in Sources */,\n\t\t\t\t7521DBD7291EA349009642EF /* Crawlable.cpp in Sources */,\n\t\t\t\t7521DBD9291EA349009642EF /* AggregateFunction.cpp in Sources */,\n\t\t\t\t7521DBDA291EA349009642EF /* MultiPrimaryConfig.swift in Sources */,\n\t\t\t\t7521DBDB291EA349009642EF /* SQLiteBase.cpp in Sources */,\n\t\t\t\t759362DD2B36D756000AF163 /* VacuumHandleOperator.cpp in Sources */,\n\t\t\t\t7521DBDC291EA349009642EF /* Join.cpp in Sources */,\n\t\t\t\t75EF25032AA33FEB0009C99F /* IncrementalMaterial.cpp in Sources */,\n\t\t\t\t7521DBDD291EA349009642EF /* SyntaxCreateTableSTMT.cpp in Sources */,\n\t\t\t\t7521DBDE291EA349009642EF /* StatementCreateView.swift in Sources */,\n\t\t\t\t7521DBE0291EA349009642EF /* FTSError.cpp in Sources */,\n\t\t\t\t7521DBE1291EA349009642EF /* SyntaxDropIndexSTMT.cpp in Sources */,\n\t\t\t\t7521DBE2291EA349009642EF /* Delete.swift in Sources */,\n\t\t\t\t7521DBE3291EA349009642EF /* HandleRelated.cpp in Sources */,\n\t\t\t\t7521DBE4291EA349009642EF /* SyntaxIdentifier.cpp in Sources */,\n\t\t\t\t7521DBE5291EA349009642EF /* SyntaxBindParameter.cpp in Sources */,\n\t\t\t\t7521DBE6291EA349009642EF /* SyntaxDetachSTMT.cpp in Sources */,\n\t\t\t\t7521DBE7291EA349009642EF /* Page.cpp in Sources */,\n\t\t\t\t7521DBE8291EA349009642EF /* WCDBError.swift in Sources */,\n\t\t\t\t7521DBE9291EA349009642EF /* StatementRelease.swift in Sources */,\n\t\t\t\t7521DBEA291EA349009642EF /* SyntaxOrderingTerm.cpp in Sources */,\n\t\t\t\t7521DBEB291EA349009642EF /* StatementDropIndex.swift in Sources */,\n\t\t\t\t7521DBEC291EA349009642EF /* Serialization.cpp in Sources */,\n\t\t\t\t7521DBEE291EA349009642EF /* Convenience.swift in Sources */,\n\t\t\t\t7521DBEF291EA349009642EF /* StatementDeleteBridge.cpp in Sources */,\n\t\t\t\t7521DBF0291EA349009642EF /* DBOperationNotifier.cpp in Sources */,\n\t\t\t\t7521DBF1291EA349009642EF /* PorterStemming.c in Sources */,\n\t\t\t\t7521DBF2291EA349009642EF /* StatementDelete.swift in Sources */,\n\t\t\t\t7521DBF3291EA349009642EF /* StatementInsertBridge.cpp in Sources */,\n\t\t\t\t7521DBF4291EA349009642EF /* SQLiteAssembler.cpp in Sources */,\n\t\t\t\t7521DBF5291EA349009642EF /* DeleteInterface.swift in Sources */,\n\t\t\t\t7521DBF6291EA349009642EF /* StatementBeginBridge.cpp in Sources */,\n\t\t\t\t7521DBF7291EA349009642EF /* BindParameter.swift in Sources */,\n\t\t\t\t7521DBF8291EA349009642EF /* FTSBridge.swift in Sources */,\n\t\t\t\t7521DBF9291EA349009642EF /* FileHandle.cpp in Sources */,\n\t\t\t\t7521DBFA291EA349009642EF /* Join.swift in Sources */,\n\t\t\t\t7521DBFB291EA349009642EF /* PragmaBridge.cpp in Sources */,\n\t\t\t\t7521DBFC291EA349009642EF /* WindowDefBridge.cpp in Sources */,\n\t\t\t\t7521DBFD291EA349009642EF /* ColumnCodable.swift in Sources */,\n\t\t\t\t7521DBFE291EA349009642EF /* SyntaxJoinConstraint.cpp in Sources */,\n\t\t\t\t7521DC00291EA349009642EF /* SyntaxReleaseSTMT.cpp in Sources */,\n\t\t\t\t7521DC02291EA349009642EF /* CoreBridge.cpp in Sources */,\n\t\t\t\t7521DC03291EA349009642EF /* Schema.cpp in Sources */,\n\t\t\t\t7533CB522B050FA300C8B47D /* MigratingHandleDecorator.cpp in Sources */,\n\t\t\t\t7521DC04291EA349009642EF /* MasterCrawler.cpp in Sources */,\n\t\t\t\t7521DC05291EA349009642EF /* StatementReindex.cpp in Sources */,\n\t\t\t\t75C6E41A29A0C2F0002579A5 /* WCDBOptional.cpp in Sources */,\n\t\t\t\t7521DC08291EA349009642EF /* Wal.cpp in Sources */,\n\t\t\t\t7521DC0A291EA349009642EF /* TableBinding.swift in Sources */,\n\t\t\t\t7521DC0B291EA349009642EF /* CodableType.swift in Sources */,\n\t\t\t\t0DF1089729C05559004ED764 /* StatementSelectInterface.swift in Sources */,\n\t\t\t\t7521DC0E291EA349009642EF /* BusyRetryConfig.cpp in Sources */,\n\t\t\t\t7521DC0F291EA349009642EF /* Property.swift in Sources */,\n\t\t\t\t7521DC11291EA349009642EF /* SyntaxSelectSTMT.cpp in Sources */,\n\t\t\t\t7521DC12291EA349009642EF /* InnerHandle.cpp in Sources */,\n\t\t\t\t7521DC16291EA349009642EF /* Lock.cpp in Sources */,\n\t\t\t\t7521DC17291EA349009642EF /* DatabaseBridge.cpp in Sources */,\n\t\t\t\t7521DC1A291EA349009642EF /* BaseBinding.cpp in Sources */,\n\t\t\t\t7521DC1B291EA349009642EF /* SyntaxSelectCore.cpp in Sources */,\n\t\t\t\t7521DC1C291EA349009642EF /* BaseType.swift in Sources */,\n\t\t\t\t7521DC1D291EA349009642EF /* StatementSavepoint.swift in Sources */,\n\t\t\t\t7521DC1E291EA349009642EF /* Value.cpp in Sources */,\n\t\t\t\t7521DC1F291EA349009642EF /* StatementRelease.cpp in Sources */,\n\t\t\t\t7521DC22291EA349009642EF /* StatementDropTableBridge.cpp in Sources */,\n\t\t\t);\n\t\t\trunOnlyForDeploymentPostprocessing = 0;\n\t\t};\n/* End PBXSourcesBuildPhase section */\n\n/* Begin PBXTargetDependency section */\n\t\t03330FAB28167ECC0094CFCF /* PBXTargetDependency */ = {\n\t\t\tisa = PBXTargetDependency;\n\t\t\ttarget = 239326601E836D7300D677CC /* WCDB */;\n\t\t\ttargetProxy = 03330FAC28167ECC0094CFCF /* PBXContainerItemProxy */;\n\t\t};\n\t\t0338E0BD2818F6D40094923A /* PBXTargetDependency */ = {\n\t\t\tisa = PBXTargetDependency;\n\t\t\ttarget = 239E8A6F2160A5B100BCB308 /* Host */;\n\t\t\ttargetProxy = 0338E0BC2818F6D40094923A /* PBXContainerItemProxy */;\n\t\t};\n\t\t037C38D12897E33600328EC8 /* PBXTargetDependency */ = {\n\t\t\tisa = PBXTargetDependency;\n\t\t\tname = \"sqlcipher static\";\n\t\t\ttargetProxy = 037C38D22897E33600328EC8 /* PBXContainerItemProxy */;\n\t\t};\n\t\t03BF4AB82888F87C00A30500 /* PBXTargetDependency */ = {\n\t\t\tisa = PBXTargetDependency;\n\t\t\ttarget = 239E8A6F2160A5B100BCB308 /* Host */;\n\t\t\ttargetProxy = 03BF4AB92888F87C00A30500 /* PBXContainerItemProxy */;\n\t\t};\n\t\t03BF4ABA2888F87C00A30500 /* PBXTargetDependency */ = {\n\t\t\tisa = PBXTargetDependency;\n\t\t\ttarget = 239326601E836D7300D677CC /* WCDB */;\n\t\t\ttargetProxy = 03BF4ABB2888F87C00A30500 /* PBXContainerItemProxy */;\n\t\t};\n\t\t03D3A2AE28A6697F0064D4D4 /* PBXTargetDependency */ = {\n\t\t\tisa = PBXTargetDependency;\n\t\t\ttarget = 239E8A6F2160A5B100BCB308 /* Host */;\n\t\t\ttargetProxy = 03D3A2AD28A6697F0064D4D4 /* PBXContainerItemProxy */;\n\t\t};\n\t\t03E5CB9A28A38CCA005353D9 /* PBXTargetDependency */ = {\n\t\t\tisa = PBXTargetDependency;\n\t\t\ttarget = 239E8A6F2160A5B100BCB308 /* Host */;\n\t\t\ttargetProxy = 03E5CB9B28A38CCA005353D9 /* PBXContainerItemProxy */;\n\t\t};\n\t\t0DACF74F2B29ABD400CB0710 /* PBXTargetDependency */ = {\n\t\t\tisa = PBXTargetDependency;\n\t\t\tname = zstd;\n\t\t\ttargetProxy = 0DACF74E2B29ABD400CB0710 /* PBXContainerItemProxy */;\n\t\t};\n\t\t0DACF7512B29ABDB00CB0710 /* PBXTargetDependency */ = {\n\t\t\tisa = PBXTargetDependency;\n\t\t\tname = zstd;\n\t\t\ttargetProxy = 0DACF7502B29ABDB00CB0710 /* PBXContainerItemProxy */;\n\t\t};\n\t\t0DACF7532B29ABE600CB0710 /* PBXTargetDependency */ = {\n\t\t\tisa = PBXTargetDependency;\n\t\t\tname = zstd;\n\t\t\ttargetProxy = 0DACF7522B29ABE600CB0710 /* PBXContainerItemProxy */;\n\t\t};\n\t\t0DACF7552B29ABEC00CB0710 /* PBXTargetDependency */ = {\n\t\t\tisa = PBXTargetDependency;\n\t\t\tname = zstd;\n\t\t\ttargetProxy = 0DACF7542B29ABEC00CB0710 /* PBXContainerItemProxy */;\n\t\t};\n\t\t23F5BE0E20887FFF000CCD37 /* PBXTargetDependency */ = {\n\t\t\tisa = PBXTargetDependency;\n\t\t\tname = \"sqlcipher static\";\n\t\t\ttargetProxy = 23F5BE0D20887FFF000CCD37 /* PBXContainerItemProxy */;\n\t\t};\n\t\t750080EB2920ED98009C0F38 /* PBXTargetDependency */ = {\n\t\t\tisa = PBXTargetDependency;\n\t\t\ttarget = 239326601E836D7300D677CC /* WCDB */;\n\t\t\ttargetProxy = 750080EA2920ED98009C0F38 /* PBXContainerItemProxy */;\n\t\t};\n\t\t750080EE2920EDBA009C0F38 /* PBXTargetDependency */ = {\n\t\t\tisa = PBXTargetDependency;\n\t\t\ttarget = 239326601E836D7300D677CC /* WCDB */;\n\t\t\ttargetProxy = 750080ED2920EDBA009C0F38 /* PBXContainerItemProxy */;\n\t\t};\n\t\t7521D6BF291E9ABB009642EF /* PBXTargetDependency */ = {\n\t\t\tisa = PBXTargetDependency;\n\t\t\tname = \"sqlcipher static\";\n\t\t\ttargetProxy = 7521D6C0291E9ABB009642EF /* PBXContainerItemProxy */;\n\t\t};\n\t\t7521DA55291EA349009642EF /* PBXTargetDependency */ = {\n\t\t\tisa = PBXTargetDependency;\n\t\t\tname = \"sqlcipher static\";\n\t\t\ttargetProxy = 7521DA56291EA349009642EF /* PBXContainerItemProxy */;\n\t\t};\n\t\t7546D45529D02BAE001B5611 /* PBXTargetDependency */ = {\n\t\t\tisa = PBXTargetDependency;\n\t\t\ttarget = 239326601E836D7300D677CC /* WCDB */;\n\t\t\ttargetProxy = 7546D45429D02BAE001B5611 /* PBXContainerItemProxy */;\n\t\t};\n\t\t7575F7AF280679C7006259E2 /* PBXTargetDependency */ = {\n\t\t\tisa = PBXTargetDependency;\n\t\t\ttarget = 239E8A6F2160A5B100BCB308 /* Host */;\n\t\t\ttargetProxy = 7575F7AE280679C7006259E2 /* PBXContainerItemProxy */;\n\t\t};\n/* End PBXTargetDependency section */\n\n/* Begin XCBuildConfiguration section */\n\t\t0333100028167ECC0094CFCF /* Debug */ = {\n\t\t\tisa = XCBuildConfiguration;\n\t\t\tbaseConfigurationReference = 234F042F227A9EFA00DD65A2 /* Tests.xcconfig */;\n\t\t\tbuildSettings = {\n\t\t\t\tSWIFT_OBJC_BRIDGING_HEADER = \"bridge/tests/common/SwiftBridgeObjcTest-Bridging-Header.h\";\n\t\t\t};\n\t\t\tname = Debug;\n\t\t};\n\t\t0333100128167ECC0094CFCF /* Release */ = {\n\t\t\tisa = XCBuildConfiguration;\n\t\t\tbaseConfigurationReference = 234F042F227A9EFA00DD65A2 /* Tests.xcconfig */;\n\t\t\tbuildSettings = {\n\t\t\t\tSWIFT_OBJC_BRIDGING_HEADER = \"bridge/tests/common/SwiftBridgeObjcTest-Bridging-Header.h\";\n\t\t\t};\n\t\t\tname = Release;\n\t\t};\n\t\t037C3C0A2897E33600328EC8 /* Debug */ = {\n\t\t\tisa = XCBuildConfiguration;\n\t\t\tbaseConfigurationReference = 0DACF8B22B2ADC7700CB0710 /* WCDB.xcconfig */;\n\t\t\tbuildSettings = {\n\t\t\t\tFRAMEWORK_SEARCH_PATHS = (\n\t\t\t\t\t\"$(inherited)\",\n\t\t\t\t\t\"$(SDKROOT)/System/iOSSupport/System/Library/Frameworks\",\n\t\t\t\t);\n\t\t\t\tSUPPORTED_PLATFORMS = \"appletvos appletvsimulator iphoneos iphonesimulator macosx watchos watchsimulator\";\n\t\t\t\tSUPPORTS_MACCATALYST = YES;\n\t\t\t\tTARGETED_DEVICE_FAMILY = \"1,2,3,4\";\n\t\t\t};\n\t\t\tname = Debug;\n\t\t};\n\t\t037C3C0B2897E33600328EC8 /* Release */ = {\n\t\t\tisa = XCBuildConfiguration;\n\t\t\tbaseConfigurationReference = 0DACF8B22B2ADC7700CB0710 /* WCDB.xcconfig */;\n\t\t\tbuildSettings = {\n\t\t\t\tFRAMEWORK_SEARCH_PATHS = (\n\t\t\t\t\t\"$(inherited)\",\n\t\t\t\t\t\"$(SDKROOT)/System/iOSSupport/System/Library/Frameworks\",\n\t\t\t\t);\n\t\t\t\tSUPPORTED_PLATFORMS = \"appletvos appletvsimulator iphoneos iphonesimulator macosx watchos watchsimulator\";\n\t\t\t\tSUPPORTS_MACCATALYST = YES;\n\t\t\t\tTARGETED_DEVICE_FAMILY = \"1,2,3,4\";\n\t\t\t};\n\t\t\tname = Release;\n\t\t};\n\t\t03BF4B1D2888F87C00A30500 /* Debug */ = {\n\t\t\tisa = XCBuildConfiguration;\n\t\t\tbaseConfigurationReference = 234F042F227A9EFA00DD65A2 /* Tests.xcconfig */;\n\t\t\tbuildSettings = {\n\t\t\t};\n\t\t\tname = Debug;\n\t\t};\n\t\t03BF4B1E2888F87C00A30500 /* Release */ = {\n\t\t\tisa = XCBuildConfiguration;\n\t\t\tbaseConfigurationReference = 234F042F227A9EFA00DD65A2 /* Tests.xcconfig */;\n\t\t\tbuildSettings = {\n\t\t\t};\n\t\t\tname = Release;\n\t\t};\n\t\t03E5CC4728A38CCA005353D9 /* Debug */ = {\n\t\t\tisa = XCBuildConfiguration;\n\t\t\tbaseConfigurationReference = 234F042F227A9EFA00DD65A2 /* Tests.xcconfig */;\n\t\t\tbuildSettings = {\n\t\t\t\tCLANG_CXX_LANGUAGE_STANDARD = \"c++17\";\n\t\t\t\tCLANG_ENABLE_MODULES = YES;\n\t\t\t\tLD_RUNPATH_SEARCH_PATHS = (\n\t\t\t\t\t\"$(inherited)\",\n\t\t\t\t\t\"@executable_path/Frameworks\",\n\t\t\t\t\t\"@loader_path/Frameworks\",\n\t\t\t\t);\n\t\t\t\tSWIFT_OPTIMIZATION_LEVEL = \"-Onone\";\n\t\t\t\tSWIFT_VERSION = 5.0;\n\t\t\t};\n\t\t\tname = Debug;\n\t\t};\n\t\t03E5CC4828A38CCA005353D9 /* Release */ = {\n\t\t\tisa = XCBuildConfiguration;\n\t\t\tbaseConfigurationReference = 234F042F227A9EFA00DD65A2 /* Tests.xcconfig */;\n\t\t\tbuildSettings = {\n\t\t\t\tCLANG_CXX_LANGUAGE_STANDARD = \"c++17\";\n\t\t\t\tCLANG_ENABLE_MODULES = YES;\n\t\t\t\tLD_RUNPATH_SEARCH_PATHS = (\n\t\t\t\t\t\"$(inherited)\",\n\t\t\t\t\t\"@executable_path/Frameworks\",\n\t\t\t\t\t\"@loader_path/Frameworks\",\n\t\t\t\t);\n\t\t\t\tSWIFT_VERSION = 5.0;\n\t\t\t};\n\t\t\tname = Release;\n\t\t};\n\t\t234F0365227A9CFE00DD65A2 /* Debug */ = {\n\t\t\tisa = XCBuildConfiguration;\n\t\t\tbaseConfigurationReference = 234F042F227A9EFA00DD65A2 /* Tests.xcconfig */;\n\t\t\tbuildSettings = {\n\t\t\t};\n\t\t\tname = Debug;\n\t\t};\n\t\t234F0366227A9CFE00DD65A2 /* Release */ = {\n\t\t\tisa = XCBuildConfiguration;\n\t\t\tbaseConfigurationReference = 234F042F227A9EFA00DD65A2 /* Tests.xcconfig */;\n\t\t\tbuildSettings = {\n\t\t\t};\n\t\t\tname = Release;\n\t\t};\n\t\t234F8ADD227B0B5400791E45 /* Debug */ = {\n\t\t\tisa = XCBuildConfiguration;\n\t\t\tbaseConfigurationReference = 234F042F227A9EFA00DD65A2 /* Tests.xcconfig */;\n\t\t\tbuildSettings = {\n\t\t\t\tSWIFT_ACTIVE_COMPILATION_CONDITIONS = WCDB_QUICK_TESTS;\n\t\t\t};\n\t\t\tname = Debug;\n\t\t};\n\t\t234F8ADE227B0B5400791E45 /* Release */ = {\n\t\t\tisa = XCBuildConfiguration;\n\t\t\tbaseConfigurationReference = 234F042F227A9EFA00DD65A2 /* Tests.xcconfig */;\n\t\t\tbuildSettings = {\n\t\t\t};\n\t\t\tname = Release;\n\t\t};\n\t\t239326671E836D7300D677CC /* Debug */ = {\n\t\t\tisa = XCBuildConfiguration;\n\t\t\tbaseConfigurationReference = 0DACF8B22B2ADC7700CB0710 /* WCDB.xcconfig */;\n\t\t\tbuildSettings = {\n\t\t\t\tFRAMEWORK_SEARCH_PATHS = (\n\t\t\t\t\t\"$(inherited)\",\n\t\t\t\t\t\"$(SDKROOT)/System/iOSSupport/System/Library/Frameworks\",\n\t\t\t\t);\n\t\t\t\tGCC_PREPROCESSOR_DEFINITIONS = (\n\t\t\t\t\t\"$(inherited)\",\n\t\t\t\t\t\"$(WCDB_VERSION_DEFINITIONS)\",\n\t\t\t\t\t\"$(SQLITE_PREPROCESSOR_DEFINITIONS)\",\n\t\t\t\t\t\"ZLIB_CONST=1\",\n\t\t\t\t\t\"SQLITE_WCDB=1\",\n\t\t\t\t\t\"WCDB_SWIFT_BRIDGE_OBJC=1\",\n\t\t\t\t\t\"WCDB_TESTS=1\",\n\t\t\t\t);\n\t\t\t\tMODULEMAP_FILE = \"$(SRCROOT)/support/WCDB.modulemap\";\n\t\t\t\tSUPPORTED_PLATFORMS = \"appletvos appletvsimulator iphoneos iphonesimulator maccatalyst macosx watchos watchsimulator\";\n\t\t\t\tSUPPORTS_MACCATALYST = YES;\n\t\t\t\tSWIFT_ACTIVE_COMPILATION_CONDITIONS = \"WCDB_SWIFT_BRIDGE_OBJC WCDB_QUICK_TESTS\";\n\t\t\t\tTARGETED_DEVICE_FAMILY = \"1,2,3,4\";\n\t\t\t};\n\t\t\tname = Debug;\n\t\t};\n\t\t239326681E836D7300D677CC /* Release */ = {\n\t\t\tisa = XCBuildConfiguration;\n\t\t\tbaseConfigurationReference = 0DACF8B22B2ADC7700CB0710 /* WCDB.xcconfig */;\n\t\t\tbuildSettings = {\n\t\t\t\tFRAMEWORK_SEARCH_PATHS = (\n\t\t\t\t\t\"$(inherited)\",\n\t\t\t\t\t\"$(SDKROOT)/System/iOSSupport/System/Library/Frameworks\",\n\t\t\t\t);\n\t\t\t\tGCC_PREPROCESSOR_DEFINITIONS = (\n\t\t\t\t\t\"$(inherited)\",\n\t\t\t\t\t\"$(WCDB_VERSION_DEFINITIONS)\",\n\t\t\t\t\t\"$(SQLITE_PREPROCESSOR_DEFINITIONS)\",\n\t\t\t\t\t\"ZLIB_CONST=1\",\n\t\t\t\t\t\"SQLITE_WCDB=1\",\n\t\t\t\t\t\"WCDB_SWIFT_BRIDGE_OBJC=1\",\n\t\t\t\t);\n\t\t\t\tMODULEMAP_FILE = \"$(SRCROOT)/support/WCDB.modulemap\";\n\t\t\t\tSUPPORTED_PLATFORMS = \"appletvos appletvsimulator iphoneos iphonesimulator maccatalyst macosx watchos watchsimulator\";\n\t\t\t\tSUPPORTS_MACCATALYST = YES;\n\t\t\t\tSWIFT_ACTIVE_COMPILATION_CONDITIONS = WCDB_SWIFT_BRIDGE_OBJC;\n\t\t\t\tTARGETED_DEVICE_FAMILY = \"1,2,3,4\";\n\t\t\t};\n\t\t\tname = Release;\n\t\t};\n\t\t239E8A832160A5B200BCB308 /* Debug */ = {\n\t\t\tisa = XCBuildConfiguration;\n\t\t\tbaseConfigurationReference = 234F0753227AB18B00DD65A2 /* host.xcconfig */;\n\t\t\tbuildSettings = {\n\t\t\t\tCODE_SIGN_IDENTITY = \"-\";\n\t\t\t\tCODE_SIGN_STYLE = Automatic;\n\t\t\t\tDEVELOPMENT_TEAM = \"\";\n\t\t\t\tPRODUCT_BUNDLE_IDENTIFIER = com.Tencent.WCDB.Host;\n\t\t\t\tPROVISIONING_PROFILE_SPECIFIER = \"\";\n\t\t\t};\n\t\t\tname = Debug;\n\t\t};\n\t\t239E8A842160A5B200BCB308 /* Release */ = {\n\t\t\tisa = XCBuildConfiguration;\n\t\t\tbaseConfigurationReference = 234F0753227AB18B00DD65A2 /* host.xcconfig */;\n\t\t\tbuildSettings = {\n\t\t\t\tCODE_SIGN_IDENTITY = \"-\";\n\t\t\t\tCODE_SIGN_STYLE = Automatic;\n\t\t\t\tDEVELOPMENT_TEAM = \"\";\n\t\t\t\tPRODUCT_BUNDLE_IDENTIFIER = com.Tencent.WCDB.Host;\n\t\t\t\tPROVISIONING_PROFILE_SPECIFIER = \"\";\n\t\t\t};\n\t\t\tname = Release;\n\t\t};\n\t\t23B5F7681E1111C100E58396 /* Debug */ = {\n\t\t\tisa = XCBuildConfiguration;\n\t\t\tbaseConfigurationReference = 234F036A227A9E3C00DD65A2 /* Debug.xcconfig */;\n\t\t\tbuildSettings = {\n\t\t\t\tARCHS = (\n\t\t\t\t\t\"$(ARCHS_STANDARD)\",\n\t\t\t\t\tarm64e,\n\t\t\t\t);\n\t\t\t\tBUILD_LIBRARY_FOR_DISTRIBUTION = NO;\n\t\t\t\tDEAD_CODE_STRIPPING = YES;\n\t\t\t\tGCC_SYMBOLS_PRIVATE_EXTERN = YES;\n\t\t\t\tSWIFT_ENFORCE_EXCLUSIVE_ACCESS = \"debug-only\";\n\t\t\t};\n\t\t\tname = Debug;\n\t\t};\n\t\t23B5F7691E1111C100E58396 /* Release */ = {\n\t\t\tisa = XCBuildConfiguration;\n\t\t\tbaseConfigurationReference = 234F036C227A9E3D00DD65A2 /* Release.xcconfig */;\n\t\t\tbuildSettings = {\n\t\t\t\tARCHS = (\n\t\t\t\t\t\"$(ARCHS_STANDARD)\",\n\t\t\t\t\tarm64e,\n\t\t\t\t);\n\t\t\t\tBUILD_LIBRARY_FOR_DISTRIBUTION = YES;\n\t\t\t\tDEAD_CODE_STRIPPING = YES;\n\t\t\t\tGCC_SYMBOLS_PRIVATE_EXTERN = YES;\n\t\t\t\tSWIFT_ENFORCE_EXCLUSIVE_ACCESS = \"debug-only\";\n\t\t\t};\n\t\t\tname = Release;\n\t\t};\n\t\t7521DA45291E9ABB009642EF /* Debug */ = {\n\t\t\tisa = XCBuildConfiguration;\n\t\t\tbaseConfigurationReference = 0DACF8B22B2ADC7700CB0710 /* WCDB.xcconfig */;\n\t\t\tbuildSettings = {\n\t\t\t\tFRAMEWORK_SEARCH_PATHS = (\n\t\t\t\t\t\"$(inherited)\",\n\t\t\t\t\t\"$(SDKROOT)/System/iOSSupport/System/Library/Frameworks\",\n\t\t\t\t);\n\t\t\t\tMODULEMAP_FILE = \"$(SRCROOT)/support/WCDBObjc.modulemap\";\n\t\t\t\tSUPPORTED_PLATFORMS = \"appletvos appletvsimulator iphoneos iphonesimulator macosx watchos watchsimulator\";\n\t\t\t\tSUPPORTS_MACCATALYST = YES;\n\t\t\t\tTARGETED_DEVICE_FAMILY = \"1,2,3,4\";\n\t\t\t};\n\t\t\tname = Debug;\n\t\t};\n\t\t7521DA46291E9ABB009642EF /* Release */ = {\n\t\t\tisa = XCBuildConfiguration;\n\t\t\tbaseConfigurationReference = 0DACF8B22B2ADC7700CB0710 /* WCDB.xcconfig */;\n\t\t\tbuildSettings = {\n\t\t\t\tFRAMEWORK_SEARCH_PATHS = (\n\t\t\t\t\t\"$(inherited)\",\n\t\t\t\t\t\"$(SDKROOT)/System/iOSSupport/System/Library/Frameworks\",\n\t\t\t\t);\n\t\t\t\tMODULEMAP_FILE = \"$(SRCROOT)/support/WCDBObjc.modulemap\";\n\t\t\t\tSUPPORTED_PLATFORMS = \"appletvos appletvsimulator iphoneos iphonesimulator macosx watchos watchsimulator\";\n\t\t\t\tSUPPORTS_MACCATALYST = YES;\n\t\t\t\tTARGETED_DEVICE_FAMILY = \"1,2,3,4\";\n\t\t\t};\n\t\t\tname = Release;\n\t\t};\n\t\t7521DDDB291EA349009642EF /* Debug */ = {\n\t\t\tisa = XCBuildConfiguration;\n\t\t\tbaseConfigurationReference = 3C9A56E02EB44B9D00DA1C6E /* WCDBSwift.xcconfig */;\n\t\t\tbuildSettings = {\n\t\t\t\tFRAMEWORK_SEARCH_PATHS = (\n\t\t\t\t\t\"$(inherited)\",\n\t\t\t\t\t\"$(SDKROOT)/System/iOSSupport/System/Library/Frameworks\",\n\t\t\t\t);\n\t\t\t\tMODULEMAP_FILE = \"$(SRCROOT)/support/WCDBSwift.modulemap\";\n\t\t\t\tSUPPORTED_PLATFORMS = \"appletvos appletvsimulator iphoneos iphonesimulator macosx watchos watchsimulator\";\n\t\t\t\tSUPPORTS_MACCATALYST = YES;\n\t\t\t\tSWIFT_ENABLE_EXPLICIT_MODULES = YES;\n\t\t\t\tTARGETED_DEVICE_FAMILY = \"1,2,3,4\";\n\t\t\t};\n\t\t\tname = Debug;\n\t\t};\n\t\t7521DDDC291EA349009642EF /* Release */ = {\n\t\t\tisa = XCBuildConfiguration;\n\t\t\tbaseConfigurationReference = 3C9A56E02EB44B9D00DA1C6E /* WCDBSwift.xcconfig */;\n\t\t\tbuildSettings = {\n\t\t\t\tFRAMEWORK_SEARCH_PATHS = (\n\t\t\t\t\t\"$(inherited)\",\n\t\t\t\t\t\"$(SDKROOT)/System/iOSSupport/System/Library/Frameworks\",\n\t\t\t\t);\n\t\t\t\tMODULEMAP_FILE = \"$(SRCROOT)/support/WCDBSwift.modulemap\";\n\t\t\t\tSUPPORTED_PLATFORMS = \"appletvos appletvsimulator iphoneos iphonesimulator macosx watchos watchsimulator\";\n\t\t\t\tSUPPORTS_MACCATALYST = YES;\n\t\t\t\tSWIFT_ENABLE_EXPLICIT_MODULES = YES;\n\t\t\t\tTARGETED_DEVICE_FAMILY = \"1,2,3,4\";\n\t\t\t};\n\t\t\tname = Release;\n\t\t};\n/* End XCBuildConfiguration section */\n\n/* Begin XCConfigurationList section */\n\t\t03330FFF28167ECC0094CFCF /* Build configuration list for PBXNativeTarget \"SwiftBridgeObjcTest\" */ = {\n\t\t\tisa = XCConfigurationList;\n\t\t\tbuildConfigurations = (\n\t\t\t\t0333100028167ECC0094CFCF /* Debug */,\n\t\t\t\t0333100128167ECC0094CFCF /* Release */,\n\t\t\t);\n\t\t\tdefaultConfigurationIsVisible = 0;\n\t\t\tdefaultConfigurationName = Release;\n\t\t};\n\t\t037C3C092897E33600328EC8 /* Build configuration list for PBXNativeTarget \"WCDBCpp\" */ = {\n\t\t\tisa = XCConfigurationList;\n\t\t\tbuildConfigurations = (\n\t\t\t\t037C3C0A2897E33600328EC8 /* Debug */,\n\t\t\t\t037C3C0B2897E33600328EC8 /* Release */,\n\t\t\t);\n\t\t\tdefaultConfigurationIsVisible = 0;\n\t\t\tdefaultConfigurationName = Release;\n\t\t};\n\t\t03BF4B1C2888F87C00A30500 /* Build configuration list for PBXNativeTarget \"BenchmarkTest\" */ = {\n\t\t\tisa = XCConfigurationList;\n\t\t\tbuildConfigurations = (\n\t\t\t\t03BF4B1D2888F87C00A30500 /* Debug */,\n\t\t\t\t03BF4B1E2888F87C00A30500 /* Release */,\n\t\t\t);\n\t\t\tdefaultConfigurationIsVisible = 0;\n\t\t\tdefaultConfigurationName = Release;\n\t\t};\n\t\t03E5CC4628A38CCA005353D9 /* Build configuration list for PBXNativeTarget \"CppTests\" */ = {\n\t\t\tisa = XCConfigurationList;\n\t\t\tbuildConfigurations = (\n\t\t\t\t03E5CC4728A38CCA005353D9 /* Debug */,\n\t\t\t\t03E5CC4828A38CCA005353D9 /* Release */,\n\t\t\t);\n\t\t\tdefaultConfigurationIsVisible = 0;\n\t\t\tdefaultConfigurationName = Release;\n\t\t};\n\t\t234F0364227A9CFE00DD65A2 /* Build configuration list for PBXNativeTarget \"ObjcTests\" */ = {\n\t\t\tisa = XCConfigurationList;\n\t\t\tbuildConfigurations = (\n\t\t\t\t234F0365227A9CFE00DD65A2 /* Debug */,\n\t\t\t\t234F0366227A9CFE00DD65A2 /* Release */,\n\t\t\t);\n\t\t\tdefaultConfigurationIsVisible = 0;\n\t\t\tdefaultConfigurationName = Release;\n\t\t};\n\t\t234F8ADC227B0B5400791E45 /* Build configuration list for PBXNativeTarget \"SwiftTests\" */ = {\n\t\t\tisa = XCConfigurationList;\n\t\t\tbuildConfigurations = (\n\t\t\t\t234F8ADD227B0B5400791E45 /* Debug */,\n\t\t\t\t234F8ADE227B0B5400791E45 /* Release */,\n\t\t\t);\n\t\t\tdefaultConfigurationIsVisible = 0;\n\t\t\tdefaultConfigurationName = Release;\n\t\t};\n\t\t239326661E836D7300D677CC /* Build configuration list for PBXNativeTarget \"WCDB\" */ = {\n\t\t\tisa = XCConfigurationList;\n\t\t\tbuildConfigurations = (\n\t\t\t\t239326671E836D7300D677CC /* Debug */,\n\t\t\t\t239326681E836D7300D677CC /* Release */,\n\t\t\t);\n\t\t\tdefaultConfigurationIsVisible = 0;\n\t\t\tdefaultConfigurationName = Release;\n\t\t};\n\t\t239E8A862160A5B200BCB308 /* Build configuration list for PBXNativeTarget \"Host\" */ = {\n\t\t\tisa = XCConfigurationList;\n\t\t\tbuildConfigurations = (\n\t\t\t\t239E8A832160A5B200BCB308 /* Debug */,\n\t\t\t\t239E8A842160A5B200BCB308 /* Release */,\n\t\t\t);\n\t\t\tdefaultConfigurationIsVisible = 0;\n\t\t\tdefaultConfigurationName = Release;\n\t\t};\n\t\t23B5F75E1E1111C100E58396 /* Build configuration list for PBXProject \"WCDB\" */ = {\n\t\t\tisa = XCConfigurationList;\n\t\t\tbuildConfigurations = (\n\t\t\t\t23B5F7681E1111C100E58396 /* Debug */,\n\t\t\t\t23B5F7691E1111C100E58396 /* Release */,\n\t\t\t);\n\t\t\tdefaultConfigurationIsVisible = 0;\n\t\t\tdefaultConfigurationName = Release;\n\t\t};\n\t\t7521DA44291E9ABB009642EF /* Build configuration list for PBXNativeTarget \"WCDBObjc\" */ = {\n\t\t\tisa = XCConfigurationList;\n\t\t\tbuildConfigurations = (\n\t\t\t\t7521DA45291E9ABB009642EF /* Debug */,\n\t\t\t\t7521DA46291E9ABB009642EF /* Release */,\n\t\t\t);\n\t\t\tdefaultConfigurationIsVisible = 0;\n\t\t\tdefaultConfigurationName = Release;\n\t\t};\n\t\t7521DDDA291EA349009642EF /* Build configuration list for PBXNativeTarget \"WCDBSwift\" */ = {\n\t\t\tisa = XCConfigurationList;\n\t\t\tbuildConfigurations = (\n\t\t\t\t7521DDDB291EA349009642EF /* Debug */,\n\t\t\t\t7521DDDC291EA349009642EF /* Release */,\n\t\t\t);\n\t\t\tdefaultConfigurationIsVisible = 0;\n\t\t\tdefaultConfigurationName = Release;\n\t\t};\n/* End XCConfigurationList section */\n\t};\n\trootObject = 23B5F75B1E1111C100E58396 /* Project object */;\n}\n"
  },
  {
    "path": "src/WCDB.xcodeproj/xcshareddata/IDETemplateMacros.plist",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">\n<plist version=\"1.0\">\n<dict>\n\t<key>FILEHEADER</key>\n\t<string>\n// Created by ___FULLUSERNAME___ on ___DATE___.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the &quot;License&quot;); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an &quot;AS IS&quot; BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */</string>\n</dict>\n</plist>\n"
  },
  {
    "path": "src/WCDB.xcodeproj/xcshareddata/xcbaselines/23FC43C521B6631200FA1A0F.xcbaseline/977CB5EE-2755-4C27-9E15-11B0C28E0E28.plist",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">\n<plist version=\"1.0\">\n<dict>\n\t<key>classNames</key>\n\t<dict>\n\t\t<key>RepairBenchmark</key>\n\t\t<dict>\n\t\t\t<key>test_backup</key>\n\t\t\t<dict>\n\t\t\t\t<key>com.apple.XCTPerformanceMetric_WallClockTime</key>\n\t\t\t\t<dict>\n\t\t\t\t\t<key>baselineAverage</key>\n\t\t\t\t\t<real>0.0846</real>\n\t\t\t\t\t<key>baselineIntegrationDisplayName</key>\n\t\t\t\t\t<string>Dec 13, 2018 at 10:02:29</string>\n\t\t\t\t</dict>\n\t\t\t</dict>\n\t\t</dict>\n\t</dict>\n</dict>\n</plist>\n"
  },
  {
    "path": "src/WCDB.xcodeproj/xcshareddata/xcbaselines/23FC43C521B6631200FA1A0F.xcbaseline/C3BF6D2F-DC2A-49AB-B150-DE139BD363B3.plist",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">\n<plist version=\"1.0\">\n<dict>\n\t<key>classNames</key>\n\t<dict>\n\t\t<key>BaselineBenchmark</key>\n\t\t<dict>\n\t\t\t<key>test_batch_write</key>\n\t\t\t<dict>\n\t\t\t\t<key>com.apple.XCTPerformanceMetric_WallClockTime</key>\n\t\t\t\t<dict>\n\t\t\t\t\t<key>baselineAverage</key>\n\t\t\t\t\t<real>1.21</real>\n\t\t\t\t\t<key>baselineIntegrationDisplayName</key>\n\t\t\t\t\t<string>Jan 18, 2019 at 14:47:39</string>\n\t\t\t\t</dict>\n\t\t\t</dict>\n\t\t\t<key>test_create_index</key>\n\t\t\t<dict>\n\t\t\t\t<key>com.apple.XCTPerformanceMetric_WallClockTime</key>\n\t\t\t\t<dict>\n\t\t\t\t\t<key>baselineAverage</key>\n\t\t\t\t\t<real>0.985</real>\n\t\t\t\t\t<key>baselineIntegrationDisplayName</key>\n\t\t\t\t\t<string>Jan 18, 2019 at 14:47:44</string>\n\t\t\t\t</dict>\n\t\t\t</dict>\n\t\t\t<key>test_read</key>\n\t\t\t<dict>\n\t\t\t\t<key>com.apple.XCTPerformanceMetric_WallClockTime</key>\n\t\t\t\t<dict>\n\t\t\t\t\t<key>baselineAverage</key>\n\t\t\t\t\t<real>1.06</real>\n\t\t\t\t\t<key>baselineIntegrationDisplayName</key>\n\t\t\t\t\t<string>Jan 18, 2019 at 14:47:51</string>\n\t\t\t\t</dict>\n\t\t\t</dict>\n\t\t\t<key>test_write</key>\n\t\t\t<dict>\n\t\t\t\t<key>com.apple.XCTPerformanceMetric_WallClockTime</key>\n\t\t\t\t<dict>\n\t\t\t\t\t<key>baselineAverage</key>\n\t\t\t\t\t<real>0.562</real>\n\t\t\t\t\t<key>baselineIntegrationDisplayName</key>\n\t\t\t\t\t<string>Jan 18, 2019 at 14:47:55</string>\n\t\t\t\t</dict>\n\t\t\t</dict>\n\t\t</dict>\n\t\t<key>CipherBenchmark</key>\n\t\t<dict>\n\t\t\t<key>test_batch_write</key>\n\t\t\t<dict>\n\t\t\t\t<key>com.apple.XCTPerformanceMetric_WallClockTime</key>\n\t\t\t\t<dict>\n\t\t\t\t\t<key>baselineAverage</key>\n\t\t\t\t\t<real>1.79</real>\n\t\t\t\t\t<key>baselineIntegrationDisplayName</key>\n\t\t\t\t\t<string>Jan 18, 2019 at 15:41:03</string>\n\t\t\t\t</dict>\n\t\t\t</dict>\n\t\t\t<key>test_create_index</key>\n\t\t\t<dict>\n\t\t\t\t<key>com.apple.XCTPerformanceMetric_WallClockTime</key>\n\t\t\t\t<dict>\n\t\t\t\t\t<key>baselineAverage</key>\n\t\t\t\t\t<real>1.38</real>\n\t\t\t\t\t<key>baselineIntegrationDisplayName</key>\n\t\t\t\t\t<string>Jan 18, 2019 at 15:41:06</string>\n\t\t\t\t</dict>\n\t\t\t</dict>\n\t\t\t<key>test_read</key>\n\t\t\t<dict>\n\t\t\t\t<key>com.apple.XCTPerformanceMetric_WallClockTime</key>\n\t\t\t\t<dict>\n\t\t\t\t\t<key>baselineAverage</key>\n\t\t\t\t\t<real>1.46</real>\n\t\t\t\t\t<key>baselineIntegrationDisplayName</key>\n\t\t\t\t\t<string>Jan 18, 2019 at 15:41:09</string>\n\t\t\t\t</dict>\n\t\t\t</dict>\n\t\t\t<key>test_write</key>\n\t\t\t<dict>\n\t\t\t\t<key>com.apple.XCTPerformanceMetric_WallClockTime</key>\n\t\t\t\t<dict>\n\t\t\t\t\t<key>baselineAverage</key>\n\t\t\t\t\t<real>0.77</real>\n\t\t\t\t\t<key>baselineIntegrationDisplayName</key>\n\t\t\t\t\t<string>Jan 18, 2019 at 15:41:12</string>\n\t\t\t\t</dict>\n\t\t\t</dict>\n\t\t</dict>\n\t\t<key>DatabaseMigrationBenchmark</key>\n\t\t<dict>\n\t\t\t<key>test_migrate</key>\n\t\t\t<dict>\n\t\t\t\t<key>com.apple.XCTPerformanceMetric_WallClockTime</key>\n\t\t\t\t<dict>\n\t\t\t\t\t<key>baselineAverage</key>\n\t\t\t\t\t<real>6.43</real>\n\t\t\t\t\t<key>baselineIntegrationDisplayName</key>\n\t\t\t\t\t<string>Jan 29, 2019 at 15:45:45</string>\n\t\t\t\t</dict>\n\t\t\t</dict>\n\t\t</dict>\n\t\t<key>InitializationBenchmark</key>\n\t\t<dict>\n\t\t\t<key>test_exists</key>\n\t\t\t<dict>\n\t\t\t\t<key>com.apple.XCTPerformanceMetric_WallClockTime</key>\n\t\t\t\t<dict>\n\t\t\t\t\t<key>baselineAverage</key>\n\t\t\t\t\t<real>0.176</real>\n\t\t\t\t\t<key>baselineIntegrationDisplayName</key>\n\t\t\t\t\t<string>Jan 31, 2019 at 09:41:13</string>\n\t\t\t\t</dict>\n\t\t\t</dict>\n\t\t\t<key>test_initialization</key>\n\t\t\t<dict>\n\t\t\t\t<key>com.apple.XCTPerformanceMetric_WallClockTime</key>\n\t\t\t\t<dict>\n\t\t\t\t\t<key>baselineAverage</key>\n\t\t\t\t\t<real>1.98</real>\n\t\t\t\t\t<key>baselineIntegrationDisplayName</key>\n\t\t\t\t\t<string>Jan 18, 2019 at 16:12:51</string>\n\t\t\t\t</dict>\n\t\t\t</dict>\n\t\t</dict>\n\t\t<key>RepairBenchmark</key>\n\t\t<dict>\n\t\t\t<key>test_backup</key>\n\t\t\t<dict>\n\t\t\t\t<key>com.apple.XCTPerformanceMetric_WallClockTime</key>\n\t\t\t\t<dict>\n\t\t\t\t\t<key>baselineAverage</key>\n\t\t\t\t\t<real>0.656</real>\n\t\t\t\t\t<key>baselineIntegrationDisplayName</key>\n\t\t\t\t\t<string>Jan 18, 2019 at 14:45:25</string>\n\t\t\t\t</dict>\n\t\t\t</dict>\n\t\t\t<key>test_repair</key>\n\t\t\t<dict>\n\t\t\t\t<key>com.apple.XCTPerformanceMetric_WallClockTime</key>\n\t\t\t\t<dict>\n\t\t\t\t\t<key>baselineAverage</key>\n\t\t\t\t\t<real>3.49</real>\n\t\t\t\t\t<key>baselineIntegrationDisplayName</key>\n\t\t\t\t\t<string>Jan 18, 2019 at 14:45:29</string>\n\t\t\t\t</dict>\n\t\t\t</dict>\n\t\t\t<key>test_repair_without_backup</key>\n\t\t\t<dict>\n\t\t\t\t<key>com.apple.XCTPerformanceMetric_WallClockTime</key>\n\t\t\t\t<dict>\n\t\t\t\t\t<key>baselineAverage</key>\n\t\t\t\t\t<real>3.01</real>\n\t\t\t\t\t<key>baselineIntegrationDisplayName</key>\n\t\t\t\t\t<string>Jan 18, 2019 at 14:45:33</string>\n\t\t\t\t</dict>\n\t\t\t</dict>\n\t\t</dict>\n\t\t<key>TableMigrationBenchmark</key>\n\t\t<dict>\n\t\t\t<key>test_migrate</key>\n\t\t\t<dict>\n\t\t\t\t<key>com.apple.XCTPerformanceMetric_WallClockTime</key>\n\t\t\t\t<dict>\n\t\t\t\t\t<key>baselineAverage</key>\n\t\t\t\t\t<real>5.7</real>\n\t\t\t\t\t<key>baselineIntegrationDisplayName</key>\n\t\t\t\t\t<string>Jan 29, 2019 at 15:45:29</string>\n\t\t\t\t</dict>\n\t\t\t</dict>\n\t\t</dict>\n\t</dict>\n</dict>\n</plist>\n"
  },
  {
    "path": "src/WCDB.xcodeproj/xcshareddata/xcbaselines/23FC43C521B6631200FA1A0F.xcbaseline/F4C9EB05-986B-414D-A7A7-E320B90A0C7D.plist",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">\n<plist version=\"1.0\">\n<dict>\n\t<key>classNames</key>\n\t<dict>\n\t\t<key>BaselineBenchmark</key>\n\t\t<dict>\n\t\t\t<key>test_batch_write</key>\n\t\t\t<dict>\n\t\t\t\t<key>com.apple.XCTPerformanceMetric_WallClockTime</key>\n\t\t\t\t<dict>\n\t\t\t\t\t<key>baselineAverage</key>\n\t\t\t\t\t<real>0.88557</real>\n\t\t\t\t\t<key>baselineIntegrationDisplayName</key>\n\t\t\t\t\t<string>Mar 27, 2019 at 11:21:56 AM</string>\n\t\t\t\t</dict>\n\t\t\t</dict>\n\t\t\t<key>test_create_index</key>\n\t\t\t<dict>\n\t\t\t\t<key>com.apple.XCTPerformanceMetric_WallClockTime</key>\n\t\t\t\t<dict>\n\t\t\t\t\t<key>baselineAverage</key>\n\t\t\t\t\t<real>0.62401</real>\n\t\t\t\t\t<key>baselineIntegrationDisplayName</key>\n\t\t\t\t\t<string>Mar 27, 2019 at 11:21:56 AM</string>\n\t\t\t\t</dict>\n\t\t\t</dict>\n\t\t\t<key>test_read</key>\n\t\t\t<dict>\n\t\t\t\t<key>com.apple.XCTPerformanceMetric_WallClockTime</key>\n\t\t\t\t<dict>\n\t\t\t\t\t<key>baselineAverage</key>\n\t\t\t\t\t<real>0.79519</real>\n\t\t\t\t\t<key>baselineIntegrationDisplayName</key>\n\t\t\t\t\t<string>Mar 27, 2019 at 11:21:56 AM</string>\n\t\t\t\t</dict>\n\t\t\t</dict>\n\t\t\t<key>test_write</key>\n\t\t\t<dict>\n\t\t\t\t<key>com.apple.XCTPerformanceMetric_WallClockTime</key>\n\t\t\t\t<dict>\n\t\t\t\t\t<key>baselineAverage</key>\n\t\t\t\t\t<real>0.3795</real>\n\t\t\t\t\t<key>baselineIntegrationDisplayName</key>\n\t\t\t\t\t<string>Mar 27, 2019 at 11:21:56 AM</string>\n\t\t\t\t</dict>\n\t\t\t</dict>\n\t\t</dict>\n\t\t<key>CipherBenchmark</key>\n\t\t<dict>\n\t\t\t<key>test_batch_write</key>\n\t\t\t<dict>\n\t\t\t\t<key>com.apple.XCTPerformanceMetric_WallClockTime</key>\n\t\t\t\t<dict>\n\t\t\t\t\t<key>baselineAverage</key>\n\t\t\t\t\t<real>1.3455</real>\n\t\t\t\t\t<key>baselineIntegrationDisplayName</key>\n\t\t\t\t\t<string>Mar 27, 2019 at 11:21:56 AM</string>\n\t\t\t\t</dict>\n\t\t\t</dict>\n\t\t\t<key>test_create_index</key>\n\t\t\t<dict>\n\t\t\t\t<key>com.apple.XCTPerformanceMetric_WallClockTime</key>\n\t\t\t\t<dict>\n\t\t\t\t\t<key>baselineAverage</key>\n\t\t\t\t\t<real>0.94787</real>\n\t\t\t\t\t<key>baselineIntegrationDisplayName</key>\n\t\t\t\t\t<string>Mar 27, 2019 at 11:21:56 AM</string>\n\t\t\t\t</dict>\n\t\t\t</dict>\n\t\t\t<key>test_read</key>\n\t\t\t<dict>\n\t\t\t\t<key>com.apple.XCTPerformanceMetric_WallClockTime</key>\n\t\t\t\t<dict>\n\t\t\t\t\t<key>baselineAverage</key>\n\t\t\t\t\t<real>1.0573</real>\n\t\t\t\t\t<key>baselineIntegrationDisplayName</key>\n\t\t\t\t\t<string>Mar 27, 2019 at 11:21:56 AM</string>\n\t\t\t\t</dict>\n\t\t\t</dict>\n\t\t\t<key>test_write</key>\n\t\t\t<dict>\n\t\t\t\t<key>com.apple.XCTPerformanceMetric_WallClockTime</key>\n\t\t\t\t<dict>\n\t\t\t\t\t<key>baselineAverage</key>\n\t\t\t\t\t<real>0.58609</real>\n\t\t\t\t\t<key>baselineIntegrationDisplayName</key>\n\t\t\t\t\t<string>Mar 27, 2019 at 11:21:56 AM</string>\n\t\t\t\t</dict>\n\t\t\t</dict>\n\t\t</dict>\n\t\t<key>DatabaseMigrationBenchmark</key>\n\t\t<dict>\n\t\t\t<key>test_batch_write</key>\n\t\t\t<dict>\n\t\t\t\t<key>com.apple.XCTPerformanceMetric_WallClockTime</key>\n\t\t\t\t<dict>\n\t\t\t\t\t<key>baselineAverage</key>\n\t\t\t\t\t<real>7.9021</real>\n\t\t\t\t\t<key>baselineIntegrationDisplayName</key>\n\t\t\t\t\t<string>Mar 27, 2019 at 11:21:56 AM</string>\n\t\t\t\t</dict>\n\t\t\t</dict>\n\t\t\t<key>test_migrate</key>\n\t\t\t<dict>\n\t\t\t\t<key>com.apple.XCTPerformanceMetric_WallClockTime</key>\n\t\t\t\t<dict>\n\t\t\t\t\t<key>baselineAverage</key>\n\t\t\t\t\t<real>4.3242</real>\n\t\t\t\t\t<key>baselineIntegrationDisplayName</key>\n\t\t\t\t\t<string>Mar 27, 2019 at 11:21:56 AM</string>\n\t\t\t\t</dict>\n\t\t\t</dict>\n\t\t\t<key>test_read</key>\n\t\t\t<dict>\n\t\t\t\t<key>com.apple.XCTPerformanceMetric_WallClockTime</key>\n\t\t\t\t<dict>\n\t\t\t\t\t<key>baselineAverage</key>\n\t\t\t\t\t<real>0.94377</real>\n\t\t\t\t\t<key>baselineIntegrationDisplayName</key>\n\t\t\t\t\t<string>Mar 27, 2019 at 11:21:56 AM</string>\n\t\t\t\t</dict>\n\t\t\t</dict>\n\t\t\t<key>test_write</key>\n\t\t\t<dict>\n\t\t\t\t<key>com.apple.XCTPerformanceMetric_WallClockTime</key>\n\t\t\t\t<dict>\n\t\t\t\t\t<key>baselineAverage</key>\n\t\t\t\t\t<real>0.95744</real>\n\t\t\t\t\t<key>baselineIntegrationDisplayName</key>\n\t\t\t\t\t<string>Mar 27, 2019 at 11:21:56 AM</string>\n\t\t\t\t</dict>\n\t\t\t</dict>\n\t\t</dict>\n\t\t<key>InitializationBenchmark</key>\n\t\t<dict>\n\t\t\t<key>test_exists</key>\n\t\t\t<dict>\n\t\t\t\t<key>com.apple.XCTPerformanceMetric_WallClockTime</key>\n\t\t\t\t<dict>\n\t\t\t\t\t<key>baselineAverage</key>\n\t\t\t\t\t<real>0.12595</real>\n\t\t\t\t\t<key>baselineIntegrationDisplayName</key>\n\t\t\t\t\t<string>Mar 27, 2019 at 11:21:56 AM</string>\n\t\t\t\t</dict>\n\t\t\t</dict>\n\t\t\t<key>test_initialization</key>\n\t\t\t<dict>\n\t\t\t\t<key>com.apple.XCTPerformanceMetric_WallClockTime</key>\n\t\t\t\t<dict>\n\t\t\t\t\t<key>baselineAverage</key>\n\t\t\t\t\t<real>1.8123</real>\n\t\t\t\t\t<key>baselineIntegrationDisplayName</key>\n\t\t\t\t\t<string>Mar 27, 2019 at 11:21:56 AM</string>\n\t\t\t\t</dict>\n\t\t\t</dict>\n\t\t</dict>\n\t\t<key>RetrieveBenchmark</key>\n\t\t<dict>\n\t\t\t<key>test_backup</key>\n\t\t\t<dict>\n\t\t\t\t<key>com.apple.XCTPerformanceMetric_WallClockTime</key>\n\t\t\t\t<dict>\n\t\t\t\t\t<key>baselineAverage</key>\n\t\t\t\t\t<real>0.41051</real>\n\t\t\t\t\t<key>baselineIntegrationDisplayName</key>\n\t\t\t\t\t<string>Mar 27, 2019 at 11:21:56 AM</string>\n\t\t\t\t</dict>\n\t\t\t</dict>\n\t\t\t<key>test_retrieve</key>\n\t\t\t<dict>\n\t\t\t\t<key>com.apple.XCTPerformanceMetric_WallClockTime</key>\n\t\t\t\t<dict>\n\t\t\t\t\t<key>baselineAverage</key>\n\t\t\t\t\t<real>8.4732</real>\n\t\t\t\t\t<key>baselineIntegrationDisplayName</key>\n\t\t\t\t\t<string>Mar 27, 2019 at 11:21:56 AM</string>\n\t\t\t\t</dict>\n\t\t\t</dict>\n\t\t\t<key>test_retrieve_without_backup</key>\n\t\t\t<dict>\n\t\t\t\t<key>com.apple.XCTPerformanceMetric_WallClockTime</key>\n\t\t\t\t<dict>\n\t\t\t\t\t<key>baselineAverage</key>\n\t\t\t\t\t<real>7.8254</real>\n\t\t\t\t\t<key>baselineIntegrationDisplayName</key>\n\t\t\t\t\t<string>Mar 27, 2019 at 11:21:56 AM</string>\n\t\t\t\t</dict>\n\t\t\t</dict>\n\t\t</dict>\n\t\t<key>TableBenchmark</key>\n\t\t<dict>\n\t\t\t<key>test_insert_into_multiple_tables_within_one_transaction</key>\n\t\t\t<dict>\n\t\t\t\t<key>com.apple.XCTPerformanceMetric_WallClockTime</key>\n\t\t\t\t<dict>\n\t\t\t\t\t<key>baselineAverage</key>\n\t\t\t\t\t<real>0.866</real>\n\t\t\t\t\t<key>baselineIntegrationDisplayName</key>\n\t\t\t\t\t<string>Mar 27, 2019 at 4:43:13 PM</string>\n\t\t\t\t</dict>\n\t\t\t</dict>\n\t\t\t<key>test_insert_into_multiple_tables_within_seperated_transaction</key>\n\t\t\t<dict>\n\t\t\t\t<key>com.apple.XCTPerformanceMetric_WallClockTime</key>\n\t\t\t\t<dict>\n\t\t\t\t\t<key>baselineAverage</key>\n\t\t\t\t\t<real>0.82</real>\n\t\t\t\t\t<key>baselineIntegrationDisplayName</key>\n\t\t\t\t\t<string>Mar 27, 2019 at 4:43:10 PM</string>\n\t\t\t\t</dict>\n\t\t\t</dict>\n\t\t</dict>\n\t\t<key>TableMigrationBenchmark</key>\n\t\t<dict>\n\t\t\t<key>test_batch_write</key>\n\t\t\t<dict>\n\t\t\t\t<key>com.apple.XCTPerformanceMetric_WallClockTime</key>\n\t\t\t\t<dict>\n\t\t\t\t\t<key>baselineAverage</key>\n\t\t\t\t\t<real>7.822</real>\n\t\t\t\t\t<key>baselineIntegrationDisplayName</key>\n\t\t\t\t\t<string>Mar 27, 2019 at 11:21:56 AM</string>\n\t\t\t\t</dict>\n\t\t\t</dict>\n\t\t\t<key>test_migrate</key>\n\t\t\t<dict>\n\t\t\t\t<key>com.apple.XCTPerformanceMetric_WallClockTime</key>\n\t\t\t\t<dict>\n\t\t\t\t\t<key>baselineAverage</key>\n\t\t\t\t\t<real>3.901</real>\n\t\t\t\t\t<key>baselineIntegrationDisplayName</key>\n\t\t\t\t\t<string>Mar 27, 2019 at 11:21:56 AM</string>\n\t\t\t\t</dict>\n\t\t\t</dict>\n\t\t\t<key>test_read</key>\n\t\t\t<dict>\n\t\t\t\t<key>com.apple.XCTPerformanceMetric_WallClockTime</key>\n\t\t\t\t<dict>\n\t\t\t\t\t<key>baselineAverage</key>\n\t\t\t\t\t<real>0.91252</real>\n\t\t\t\t\t<key>baselineIntegrationDisplayName</key>\n\t\t\t\t\t<string>Mar 27, 2019 at 11:21:56 AM</string>\n\t\t\t\t</dict>\n\t\t\t</dict>\n\t\t\t<key>test_write</key>\n\t\t\t<dict>\n\t\t\t\t<key>com.apple.XCTPerformanceMetric_WallClockTime</key>\n\t\t\t\t<dict>\n\t\t\t\t\t<key>baselineAverage</key>\n\t\t\t\t\t<real>0.88807</real>\n\t\t\t\t\t<key>baselineIntegrationDisplayName</key>\n\t\t\t\t\t<string>Mar 27, 2019 at 11:21:56 AM</string>\n\t\t\t\t</dict>\n\t\t\t</dict>\n\t\t</dict>\n\t</dict>\n</dict>\n</plist>\n"
  },
  {
    "path": "src/WCDB.xcodeproj/xcshareddata/xcbaselines/23FC43C521B6631200FA1A0F.xcbaseline/Info.plist",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">\n<plist version=\"1.0\">\n<dict>\n\t<key>runDestinationsByUUID</key>\n\t<dict>\n\t\t<key>977CB5EE-2755-4C27-9E15-11B0C28E0E28</key>\n\t\t<dict>\n\t\t\t<key>targetArchitecture</key>\n\t\t\t<string>arm64</string>\n\t\t\t<key>targetDevice</key>\n\t\t\t<dict>\n\t\t\t\t<key>modelCode</key>\n\t\t\t\t<string>iPhone8,1</string>\n\t\t\t\t<key>platformIdentifier</key>\n\t\t\t\t<string>com.apple.platform.iphoneos</string>\n\t\t\t</dict>\n\t\t</dict>\n\t\t<key>C3BF6D2F-DC2A-49AB-B150-DE139BD363B3</key>\n\t\t<dict>\n\t\t\t<key>localComputer</key>\n\t\t\t<dict>\n\t\t\t\t<key>busSpeedInMHz</key>\n\t\t\t\t<integer>100</integer>\n\t\t\t\t<key>cpuCount</key>\n\t\t\t\t<integer>1</integer>\n\t\t\t\t<key>cpuKind</key>\n\t\t\t\t<string>Intel Core i7</string>\n\t\t\t\t<key>cpuSpeedInMHz</key>\n\t\t\t\t<integer>3500</integer>\n\t\t\t\t<key>logicalCPUCoresPerPackage</key>\n\t\t\t\t<integer>8</integer>\n\t\t\t\t<key>modelCode</key>\n\t\t\t\t<string>iMac14,2</string>\n\t\t\t\t<key>physicalCPUCoresPerPackage</key>\n\t\t\t\t<integer>4</integer>\n\t\t\t\t<key>platformIdentifier</key>\n\t\t\t\t<string>com.apple.platform.macosx</string>\n\t\t\t</dict>\n\t\t\t<key>targetArchitecture</key>\n\t\t\t<string>x86_64</string>\n\t\t</dict>\n\t\t<key>F4C9EB05-986B-414D-A7A7-E320B90A0C7D</key>\n\t\t<dict>\n\t\t\t<key>localComputer</key>\n\t\t\t<dict>\n\t\t\t\t<key>busSpeedInMHz</key>\n\t\t\t\t<integer>100</integer>\n\t\t\t\t<key>cpuCount</key>\n\t\t\t\t<integer>1</integer>\n\t\t\t\t<key>cpuKind</key>\n\t\t\t\t<string>Intel Core i7</string>\n\t\t\t\t<key>cpuSpeedInMHz</key>\n\t\t\t\t<integer>4200</integer>\n\t\t\t\t<key>logicalCPUCoresPerPackage</key>\n\t\t\t\t<integer>8</integer>\n\t\t\t\t<key>modelCode</key>\n\t\t\t\t<string>iMac18,3</string>\n\t\t\t\t<key>physicalCPUCoresPerPackage</key>\n\t\t\t\t<integer>4</integer>\n\t\t\t\t<key>platformIdentifier</key>\n\t\t\t\t<string>com.apple.platform.macosx</string>\n\t\t\t</dict>\n\t\t\t<key>targetArchitecture</key>\n\t\t\t<string>x86_64</string>\n\t\t</dict>\n\t</dict>\n</dict>\n</plist>\n"
  },
  {
    "path": "src/WCDB.xcodeproj/xcshareddata/xcschemes/BenchmarkTest.xcscheme",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<Scheme\n   LastUpgradeVersion = \"1320\"\n   version = \"1.3\">\n   <BuildAction\n      parallelizeBuildables = \"YES\"\n      buildImplicitDependencies = \"YES\">\n   </BuildAction>\n   <TestAction\n      buildConfiguration = \"Debug\"\n      selectedDebuggerIdentifier = \"Xcode.DebuggerFoundation.Debugger.LLDB\"\n      selectedLauncherIdentifier = \"Xcode.DebuggerFoundation.Launcher.LLDB\"\n      shouldUseLaunchSchemeArgsEnv = \"YES\">\n      <Testables>\n         <TestableReference\n            skipped = \"NO\">\n            <BuildableReference\n               BuildableIdentifier = \"primary\"\n               BlueprintIdentifier = \"03BF4AB72888F87C00A30500\"\n               BuildableName = \"BenchmarkTest.xctest\"\n               BlueprintName = \"BenchmarkTest\"\n               ReferencedContainer = \"container:WCDB.xcodeproj\">\n            </BuildableReference>\n         </TestableReference>\n      </Testables>\n   </TestAction>\n   <LaunchAction\n      buildConfiguration = \"Debug\"\n      selectedDebuggerIdentifier = \"Xcode.DebuggerFoundation.Debugger.LLDB\"\n      selectedLauncherIdentifier = \"Xcode.DebuggerFoundation.Launcher.LLDB\"\n      launchStyle = \"0\"\n      useCustomWorkingDirectory = \"NO\"\n      ignoresPersistentStateOnLaunch = \"NO\"\n      debugDocumentVersioning = \"YES\"\n      debugServiceExtension = \"internal\"\n      allowLocationSimulation = \"YES\">\n   </LaunchAction>\n   <ProfileAction\n      buildConfiguration = \"Release\"\n      shouldUseLaunchSchemeArgsEnv = \"YES\"\n      savedToolIdentifier = \"\"\n      useCustomWorkingDirectory = \"NO\"\n      debugDocumentVersioning = \"YES\">\n   </ProfileAction>\n   <AnalyzeAction\n      buildConfiguration = \"Debug\">\n   </AnalyzeAction>\n   <ArchiveAction\n      buildConfiguration = \"Release\"\n      revealArchiveInOrganizer = \"YES\">\n   </ArchiveAction>\n</Scheme>\n"
  },
  {
    "path": "src/WCDB.xcodeproj/xcshareddata/xcschemes/CppTests.xcscheme",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<Scheme\n   LastUpgradeVersion = \"1320\"\n   version = \"1.3\">\n   <BuildAction\n      parallelizeBuildables = \"YES\"\n      buildImplicitDependencies = \"YES\">\n   </BuildAction>\n   <TestAction\n      buildConfiguration = \"Debug\"\n      selectedDebuggerIdentifier = \"Xcode.DebuggerFoundation.Debugger.LLDB\"\n      selectedLauncherIdentifier = \"Xcode.DebuggerFoundation.Launcher.LLDB\"\n      shouldUseLaunchSchemeArgsEnv = \"YES\">\n      <Testables>\n         <TestableReference\n            skipped = \"NO\">\n            <BuildableReference\n               BuildableIdentifier = \"primary\"\n               BlueprintIdentifier = \"03E5CB9928A38CCA005353D9\"\n               BuildableName = \"CppTests.xctest\"\n               BlueprintName = \"CppTests\"\n               ReferencedContainer = \"container:WCDB.xcodeproj\">\n            </BuildableReference>\n         </TestableReference>\n      </Testables>\n   </TestAction>\n   <LaunchAction\n      buildConfiguration = \"Debug\"\n      selectedDebuggerIdentifier = \"Xcode.DebuggerFoundation.Debugger.LLDB\"\n      selectedLauncherIdentifier = \"Xcode.DebuggerFoundation.Launcher.LLDB\"\n      launchStyle = \"0\"\n      useCustomWorkingDirectory = \"NO\"\n      ignoresPersistentStateOnLaunch = \"NO\"\n      debugDocumentVersioning = \"YES\"\n      debugServiceExtension = \"internal\"\n      allowLocationSimulation = \"YES\">\n   </LaunchAction>\n   <ProfileAction\n      buildConfiguration = \"Release\"\n      shouldUseLaunchSchemeArgsEnv = \"YES\"\n      savedToolIdentifier = \"\"\n      useCustomWorkingDirectory = \"NO\"\n      debugDocumentVersioning = \"YES\">\n   </ProfileAction>\n   <AnalyzeAction\n      buildConfiguration = \"Debug\">\n   </AnalyzeAction>\n   <ArchiveAction\n      buildConfiguration = \"Release\"\n      revealArchiveInOrganizer = \"YES\">\n   </ArchiveAction>\n</Scheme>\n"
  },
  {
    "path": "src/WCDB.xcodeproj/xcshareddata/xcschemes/Host.xcscheme",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<Scheme\n   LastUpgradeVersion = \"1320\"\n   version = \"1.3\">\n   <BuildAction\n      parallelizeBuildables = \"YES\"\n      buildImplicitDependencies = \"YES\">\n      <BuildActionEntries>\n         <BuildActionEntry\n            buildForTesting = \"YES\"\n            buildForRunning = \"YES\"\n            buildForProfiling = \"YES\"\n            buildForArchiving = \"YES\"\n            buildForAnalyzing = \"YES\">\n            <BuildableReference\n               BuildableIdentifier = \"primary\"\n               BlueprintIdentifier = \"239E8A6F2160A5B100BCB308\"\n               BuildableName = \"Host.app\"\n               BlueprintName = \"Host\"\n               ReferencedContainer = \"container:WCDB.xcodeproj\">\n            </BuildableReference>\n         </BuildActionEntry>\n      </BuildActionEntries>\n   </BuildAction>\n   <TestAction\n      buildConfiguration = \"Debug\"\n      selectedDebuggerIdentifier = \"Xcode.DebuggerFoundation.Debugger.LLDB\"\n      selectedLauncherIdentifier = \"Xcode.DebuggerFoundation.Launcher.LLDB\"\n      shouldUseLaunchSchemeArgsEnv = \"YES\">\n      <Testables>\n      </Testables>\n   </TestAction>\n   <LaunchAction\n      buildConfiguration = \"Debug\"\n      selectedDebuggerIdentifier = \"Xcode.DebuggerFoundation.Debugger.LLDB\"\n      selectedLauncherIdentifier = \"Xcode.DebuggerFoundation.Launcher.LLDB\"\n      launchStyle = \"0\"\n      useCustomWorkingDirectory = \"NO\"\n      ignoresPersistentStateOnLaunch = \"NO\"\n      debugDocumentVersioning = \"YES\"\n      debugServiceExtension = \"internal\"\n      allowLocationSimulation = \"YES\">\n      <BuildableProductRunnable\n         runnableDebuggingMode = \"0\">\n         <BuildableReference\n            BuildableIdentifier = \"primary\"\n            BlueprintIdentifier = \"239E8A6F2160A5B100BCB308\"\n            BuildableName = \"Host.app\"\n            BlueprintName = \"Host\"\n            ReferencedContainer = \"container:WCDB.xcodeproj\">\n         </BuildableReference>\n      </BuildableProductRunnable>\n   </LaunchAction>\n   <ProfileAction\n      buildConfiguration = \"Release\"\n      shouldUseLaunchSchemeArgsEnv = \"YES\"\n      savedToolIdentifier = \"\"\n      useCustomWorkingDirectory = \"NO\"\n      debugDocumentVersioning = \"YES\">\n      <BuildableProductRunnable\n         runnableDebuggingMode = \"0\">\n         <BuildableReference\n            BuildableIdentifier = \"primary\"\n            BlueprintIdentifier = \"239E8A6F2160A5B100BCB308\"\n            BuildableName = \"Host.app\"\n            BlueprintName = \"Host\"\n            ReferencedContainer = \"container:WCDB.xcodeproj\">\n         </BuildableReference>\n      </BuildableProductRunnable>\n   </ProfileAction>\n   <AnalyzeAction\n      buildConfiguration = \"Debug\">\n   </AnalyzeAction>\n   <ArchiveAction\n      buildConfiguration = \"Release\"\n      revealArchiveInOrganizer = \"YES\">\n   </ArchiveAction>\n</Scheme>\n"
  },
  {
    "path": "src/WCDB.xcodeproj/xcshareddata/xcschemes/ObjcTests.xcscheme",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<Scheme\n   LastUpgradeVersion = \"1200\"\n   version = \"1.3\">\n   <BuildAction\n      parallelizeBuildables = \"YES\"\n      buildImplicitDependencies = \"YES\">\n   </BuildAction>\n   <TestAction\n      buildConfiguration = \"Debug\"\n      selectedDebuggerIdentifier = \"Xcode.DebuggerFoundation.Debugger.LLDB\"\n      selectedLauncherIdentifier = \"Xcode.DebuggerFoundation.Launcher.LLDB\"\n      shouldUseLaunchSchemeArgsEnv = \"YES\">\n      <Testables>\n         <TestableReference\n            skipped = \"NO\">\n            <BuildableReference\n               BuildableIdentifier = \"primary\"\n               BlueprintIdentifier = \"234F035B227A9CFE00DD65A2\"\n               BuildableName = \"ObjcTests.xctest\"\n               BlueprintName = \"ObjcTests\"\n               ReferencedContainer = \"container:WCDB.xcodeproj\">\n            </BuildableReference>\n         </TestableReference>\n      </Testables>\n   </TestAction>\n   <LaunchAction\n      buildConfiguration = \"Debug\"\n      selectedDebuggerIdentifier = \"Xcode.DebuggerFoundation.Debugger.LLDB\"\n      selectedLauncherIdentifier = \"Xcode.DebuggerFoundation.Launcher.LLDB\"\n      launchStyle = \"0\"\n      useCustomWorkingDirectory = \"NO\"\n      ignoresPersistentStateOnLaunch = \"NO\"\n      debugDocumentVersioning = \"YES\"\n      debugServiceExtension = \"internal\"\n      allowLocationSimulation = \"YES\">\n   </LaunchAction>\n   <ProfileAction\n      buildConfiguration = \"Release\"\n      shouldUseLaunchSchemeArgsEnv = \"YES\"\n      savedToolIdentifier = \"\"\n      useCustomWorkingDirectory = \"NO\"\n      debugDocumentVersioning = \"YES\">\n   </ProfileAction>\n   <AnalyzeAction\n      buildConfiguration = \"Debug\">\n   </AnalyzeAction>\n   <ArchiveAction\n      buildConfiguration = \"Release\"\n      revealArchiveInOrganizer = \"YES\">\n   </ArchiveAction>\n</Scheme>\n"
  },
  {
    "path": "src/WCDB.xcodeproj/xcshareddata/xcschemes/SwiftBridgeObjcTest.xcscheme",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<Scheme\n   LastUpgradeVersion = \"1320\"\n   version = \"1.3\">\n   <BuildAction\n      parallelizeBuildables = \"YES\"\n      buildImplicitDependencies = \"YES\">\n   </BuildAction>\n   <TestAction\n      buildConfiguration = \"Debug\"\n      selectedDebuggerIdentifier = \"Xcode.DebuggerFoundation.Debugger.LLDB\"\n      selectedLauncherIdentifier = \"Xcode.DebuggerFoundation.Launcher.LLDB\"\n      shouldUseLaunchSchemeArgsEnv = \"YES\">\n      <Testables>\n         <TestableReference\n            skipped = \"NO\">\n            <BuildableReference\n               BuildableIdentifier = \"primary\"\n               BlueprintIdentifier = \"03330FA828167ECC0094CFCF\"\n               BuildableName = \"SwiftBridgeObjcTest.xctest\"\n               BlueprintName = \"SwiftBridgeObjcTest\"\n               ReferencedContainer = \"container:WCDB.xcodeproj\">\n            </BuildableReference>\n         </TestableReference>\n      </Testables>\n   </TestAction>\n   <LaunchAction\n      buildConfiguration = \"Debug\"\n      selectedDebuggerIdentifier = \"Xcode.DebuggerFoundation.Debugger.LLDB\"\n      selectedLauncherIdentifier = \"Xcode.DebuggerFoundation.Launcher.LLDB\"\n      launchStyle = \"0\"\n      useCustomWorkingDirectory = \"NO\"\n      ignoresPersistentStateOnLaunch = \"NO\"\n      debugDocumentVersioning = \"YES\"\n      debugServiceExtension = \"internal\"\n      allowLocationSimulation = \"YES\">\n   </LaunchAction>\n   <ProfileAction\n      buildConfiguration = \"Release\"\n      shouldUseLaunchSchemeArgsEnv = \"YES\"\n      savedToolIdentifier = \"\"\n      useCustomWorkingDirectory = \"NO\"\n      debugDocumentVersioning = \"YES\">\n   </ProfileAction>\n   <AnalyzeAction\n      buildConfiguration = \"Debug\">\n   </AnalyzeAction>\n   <ArchiveAction\n      buildConfiguration = \"Release\"\n      revealArchiveInOrganizer = \"YES\">\n   </ArchiveAction>\n</Scheme>\n"
  },
  {
    "path": "src/WCDB.xcodeproj/xcshareddata/xcschemes/SwiftTests.xcscheme",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<Scheme\n   LastUpgradeVersion = \"1320\"\n   version = \"1.3\">\n   <BuildAction\n      parallelizeBuildables = \"YES\"\n      buildImplicitDependencies = \"YES\">\n   </BuildAction>\n   <TestAction\n      buildConfiguration = \"Debug\"\n      selectedDebuggerIdentifier = \"Xcode.DebuggerFoundation.Debugger.LLDB\"\n      selectedLauncherIdentifier = \"Xcode.DebuggerFoundation.Launcher.LLDB\"\n      shouldUseLaunchSchemeArgsEnv = \"YES\">\n      <Testables>\n         <TestableReference\n            skipped = \"NO\">\n            <BuildableReference\n               BuildableIdentifier = \"primary\"\n               BlueprintIdentifier = \"234F8AD3227B0B5400791E45\"\n               BuildableName = \"SwiftTests.xctest\"\n               BlueprintName = \"SwiftTests\"\n               ReferencedContainer = \"container:WCDB.xcodeproj\">\n            </BuildableReference>\n         </TestableReference>\n      </Testables>\n   </TestAction>\n   <LaunchAction\n      buildConfiguration = \"Debug\"\n      selectedDebuggerIdentifier = \"Xcode.DebuggerFoundation.Debugger.LLDB\"\n      selectedLauncherIdentifier = \"Xcode.DebuggerFoundation.Launcher.LLDB\"\n      launchStyle = \"0\"\n      useCustomWorkingDirectory = \"NO\"\n      ignoresPersistentStateOnLaunch = \"NO\"\n      debugDocumentVersioning = \"YES\"\n      debugServiceExtension = \"internal\"\n      allowLocationSimulation = \"YES\">\n   </LaunchAction>\n   <ProfileAction\n      buildConfiguration = \"Release\"\n      shouldUseLaunchSchemeArgsEnv = \"YES\"\n      savedToolIdentifier = \"\"\n      useCustomWorkingDirectory = \"NO\"\n      debugDocumentVersioning = \"YES\">\n   </ProfileAction>\n   <AnalyzeAction\n      buildConfiguration = \"Debug\">\n   </AnalyzeAction>\n   <ArchiveAction\n      buildConfiguration = \"Release\"\n      revealArchiveInOrganizer = \"YES\">\n   </ArchiveAction>\n</Scheme>\n"
  },
  {
    "path": "src/WCDB.xcodeproj/xcshareddata/xcschemes/WCDB.xcscheme",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<Scheme\n   LastUpgradeVersion = \"1100\"\n   version = \"1.3\">\n   <BuildAction\n      parallelizeBuildables = \"YES\"\n      buildImplicitDependencies = \"YES\">\n      <BuildActionEntries>\n         <BuildActionEntry\n            buildForTesting = \"YES\"\n            buildForRunning = \"YES\"\n            buildForProfiling = \"YES\"\n            buildForArchiving = \"YES\"\n            buildForAnalyzing = \"YES\">\n            <BuildableReference\n               BuildableIdentifier = \"primary\"\n               BlueprintIdentifier = \"239326601E836D7300D677CC\"\n               BuildableName = \"WCDB.framework\"\n               BlueprintName = \"WCDB\"\n               ReferencedContainer = \"container:WCDB.xcodeproj\">\n            </BuildableReference>\n         </BuildActionEntry>\n         <BuildActionEntry\n            buildForTesting = \"YES\"\n            buildForRunning = \"NO\"\n            buildForProfiling = \"NO\"\n            buildForArchiving = \"NO\"\n            buildForAnalyzing = \"NO\">\n            <BuildableReference\n               BuildableIdentifier = \"primary\"\n               BlueprintIdentifier = \"234F8AD3227B0B5400791E45\"\n               BuildableName = \"SwiftTests.xctest\"\n               BlueprintName = \"SwiftTests\"\n               ReferencedContainer = \"container:WCDB.xcodeproj\">\n            </BuildableReference>\n         </BuildActionEntry>\n         <BuildActionEntry\n            buildForTesting = \"YES\"\n            buildForRunning = \"NO\"\n            buildForProfiling = \"NO\"\n            buildForArchiving = \"NO\"\n            buildForAnalyzing = \"NO\">\n            <BuildableReference\n               BuildableIdentifier = \"primary\"\n               BlueprintIdentifier = \"03330FA828167ECC0094CFCF\"\n               BuildableName = \"SwiftBridgeObjcTest.xctest\"\n               BlueprintName = \"SwiftBridgeObjcTest\"\n               ReferencedContainer = \"container:WCDB.xcodeproj\">\n            </BuildableReference>\n         </BuildActionEntry>\n      </BuildActionEntries>\n   </BuildAction>\n   <TestAction\n      buildConfiguration = \"Debug\"\n      selectedDebuggerIdentifier = \"Xcode.DebuggerFoundation.Debugger.LLDB\"\n      selectedLauncherIdentifier = \"Xcode.DebuggerFoundation.Launcher.LLDB\"\n      shouldUseLaunchSchemeArgsEnv = \"YES\"\n      enableASanStackUseAfterReturn = \"YES\"\n      disableMainThreadChecker = \"YES\"\n      onlyGenerateCoverageForSpecifiedTargets = \"YES\">\n      <MacroExpansion>\n         <BuildableReference\n            BuildableIdentifier = \"primary\"\n            BlueprintIdentifier = \"239326601E836D7300D677CC\"\n            BuildableName = \"WCDB.framework\"\n            BlueprintName = \"WCDB\"\n            ReferencedContainer = \"container:WCDB.xcodeproj\">\n         </BuildableReference>\n      </MacroExpansion>\n      <CodeCoverageTargets>\n         <BuildableReference\n            BuildableIdentifier = \"primary\"\n            BlueprintIdentifier = \"239326601E836D7300D677CC\"\n            BuildableName = \"WCDB.framework\"\n            BlueprintName = \"WCDB\"\n            ReferencedContainer = \"container:WCDB.xcodeproj\">\n         </BuildableReference>\n      </CodeCoverageTargets>\n      <Testables>\n         <TestableReference\n            skipped = \"NO\"\n            parallelizable = \"YES\"\n            testExecutionOrdering = \"random\">\n            <BuildableReference\n               BuildableIdentifier = \"primary\"\n               BlueprintIdentifier = \"234F035B227A9CFE00DD65A2\"\n               BuildableName = \"ObjcTests.xctest\"\n               BlueprintName = \"ObjcTests\"\n               ReferencedContainer = \"container:WCDB.xcodeproj\">\n            </BuildableReference>\n         </TestableReference>\n         <TestableReference\n            skipped = \"NO\">\n            <BuildableReference\n               BuildableIdentifier = \"primary\"\n               BlueprintIdentifier = \"234F8AD3227B0B5400791E45\"\n               BuildableName = \"SwiftTests.xctest\"\n               BlueprintName = \"SwiftTests\"\n               ReferencedContainer = \"container:WCDB.xcodeproj\">\n            </BuildableReference>\n         </TestableReference>\n         <TestableReference\n            skipped = \"NO\">\n            <BuildableReference\n               BuildableIdentifier = \"primary\"\n               BlueprintIdentifier = \"03330FA828167ECC0094CFCF\"\n               BuildableName = \"SwiftBridgeObjcTest.xctest\"\n               BlueprintName = \"SwiftBridgeObjcTest\"\n               ReferencedContainer = \"container:WCDB.xcodeproj\">\n            </BuildableReference>\n         </TestableReference>\n         <TestableReference\n            skipped = \"NO\">\n            <BuildableReference\n               BuildableIdentifier = \"primary\"\n               BlueprintIdentifier = \"03E5CB9928A38CCA005353D9\"\n               BuildableName = \"CppTests.xctest\"\n               BlueprintName = \"CppTests\"\n               ReferencedContainer = \"container:WCDB.xcodeproj\">\n            </BuildableReference>\n         </TestableReference>\n      </Testables>\n   </TestAction>\n   <LaunchAction\n      buildConfiguration = \"Debug\"\n      selectedDebuggerIdentifier = \"Xcode.DebuggerFoundation.Debugger.LLDB\"\n      selectedLauncherIdentifier = \"Xcode.DebuggerFoundation.Launcher.LLDB\"\n      disableMainThreadChecker = \"YES\"\n      launchStyle = \"0\"\n      useCustomWorkingDirectory = \"NO\"\n      ignoresPersistentStateOnLaunch = \"NO\"\n      debugDocumentVersioning = \"YES\"\n      debugServiceExtension = \"internal\"\n      allowLocationSimulation = \"YES\">\n      <MacroExpansion>\n         <BuildableReference\n            BuildableIdentifier = \"primary\"\n            BlueprintIdentifier = \"239326601E836D7300D677CC\"\n            BuildableName = \"WCDB.framework\"\n            BlueprintName = \"WCDB\"\n            ReferencedContainer = \"container:WCDB.xcodeproj\">\n         </BuildableReference>\n      </MacroExpansion>\n   </LaunchAction>\n   <ProfileAction\n      buildConfiguration = \"Release\"\n      shouldUseLaunchSchemeArgsEnv = \"YES\"\n      savedToolIdentifier = \"\"\n      useCustomWorkingDirectory = \"NO\"\n      debugDocumentVersioning = \"YES\">\n      <MacroExpansion>\n         <BuildableReference\n            BuildableIdentifier = \"primary\"\n            BlueprintIdentifier = \"239326601E836D7300D677CC\"\n            BuildableName = \"WCDB.framework\"\n            BlueprintName = \"WCDB\"\n            ReferencedContainer = \"container:WCDB.xcodeproj\">\n         </BuildableReference>\n      </MacroExpansion>\n   </ProfileAction>\n   <AnalyzeAction\n      buildConfiguration = \"Debug\">\n   </AnalyzeAction>\n   <ArchiveAction\n      buildConfiguration = \"Release\"\n      revealArchiveInOrganizer = \"YES\">\n   </ArchiveAction>\n</Scheme>\n"
  },
  {
    "path": "src/WCDB.xcodeproj/xcshareddata/xcschemes/WCDBCpp.xcscheme",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<Scheme\n   LastUpgradeVersion = \"1320\"\n   version = \"1.3\">\n   <BuildAction\n      parallelizeBuildables = \"YES\"\n      buildImplicitDependencies = \"YES\">\n      <BuildActionEntries>\n         <BuildActionEntry\n            buildForTesting = \"YES\"\n            buildForRunning = \"YES\"\n            buildForProfiling = \"YES\"\n            buildForArchiving = \"YES\"\n            buildForAnalyzing = \"YES\">\n            <BuildableReference\n               BuildableIdentifier = \"primary\"\n               BlueprintIdentifier = \"037C38D02897E33600328EC8\"\n               BuildableName = \"WCDBCpp.framework\"\n               BlueprintName = \"WCDBCpp\"\n               ReferencedContainer = \"container:WCDB.xcodeproj\">\n            </BuildableReference>\n         </BuildActionEntry>\n      </BuildActionEntries>\n   </BuildAction>\n   <TestAction\n      buildConfiguration = \"Debug\"\n      selectedDebuggerIdentifier = \"Xcode.DebuggerFoundation.Debugger.LLDB\"\n      selectedLauncherIdentifier = \"Xcode.DebuggerFoundation.Launcher.LLDB\"\n      shouldUseLaunchSchemeArgsEnv = \"YES\">\n      <Testables>\n      </Testables>\n   </TestAction>\n   <LaunchAction\n      buildConfiguration = \"Release\"\n      selectedDebuggerIdentifier = \"Xcode.DebuggerFoundation.Debugger.LLDB\"\n      selectedLauncherIdentifier = \"Xcode.DebuggerFoundation.Launcher.LLDB\"\n      launchStyle = \"0\"\n      useCustomWorkingDirectory = \"NO\"\n      ignoresPersistentStateOnLaunch = \"NO\"\n      debugDocumentVersioning = \"YES\"\n      debugServiceExtension = \"internal\"\n      allowLocationSimulation = \"YES\">\n   </LaunchAction>\n   <ProfileAction\n      buildConfiguration = \"Release\"\n      shouldUseLaunchSchemeArgsEnv = \"YES\"\n      savedToolIdentifier = \"\"\n      useCustomWorkingDirectory = \"NO\"\n      debugDocumentVersioning = \"YES\">\n      <MacroExpansion>\n         <BuildableReference\n            BuildableIdentifier = \"primary\"\n            BlueprintIdentifier = \"037C38D02897E33600328EC8\"\n            BuildableName = \"WCDBCpp.framework\"\n            BlueprintName = \"WCDBCpp\"\n            ReferencedContainer = \"container:WCDB.xcodeproj\">\n         </BuildableReference>\n      </MacroExpansion>\n   </ProfileAction>\n   <AnalyzeAction\n      buildConfiguration = \"Debug\">\n   </AnalyzeAction>\n   <ArchiveAction\n      buildConfiguration = \"Release\"\n      revealArchiveInOrganizer = \"YES\">\n   </ArchiveAction>\n</Scheme>\n"
  },
  {
    "path": "src/WCDB.xcodeproj/xcshareddata/xcschemes/WCDBObjc.xcscheme",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<Scheme\n   LastUpgradeVersion = \"1410\"\n   version = \"1.3\">\n   <BuildAction\n      parallelizeBuildables = \"YES\"\n      buildImplicitDependencies = \"YES\">\n      <BuildActionEntries>\n         <BuildActionEntry\n            buildForTesting = \"YES\"\n            buildForRunning = \"YES\"\n            buildForProfiling = \"YES\"\n            buildForArchiving = \"YES\"\n            buildForAnalyzing = \"YES\">\n            <BuildableReference\n               BuildableIdentifier = \"primary\"\n               BlueprintIdentifier = \"7521D6BE291E9ABB009642EF\"\n               BuildableName = \"WCDBObjc.framework\"\n               BlueprintName = \"WCDBObjc\"\n               ReferencedContainer = \"container:WCDB.xcodeproj\">\n            </BuildableReference>\n         </BuildActionEntry>\n      </BuildActionEntries>\n   </BuildAction>\n   <TestAction\n      buildConfiguration = \"Debug\"\n      selectedDebuggerIdentifier = \"Xcode.DebuggerFoundation.Debugger.LLDB\"\n      selectedLauncherIdentifier = \"Xcode.DebuggerFoundation.Launcher.LLDB\"\n      shouldUseLaunchSchemeArgsEnv = \"YES\">\n      <Testables>\n      </Testables>\n   </TestAction>\n   <LaunchAction\n      buildConfiguration = \"Debug\"\n      selectedDebuggerIdentifier = \"Xcode.DebuggerFoundation.Debugger.LLDB\"\n      selectedLauncherIdentifier = \"Xcode.DebuggerFoundation.Launcher.LLDB\"\n      launchStyle = \"0\"\n      useCustomWorkingDirectory = \"NO\"\n      ignoresPersistentStateOnLaunch = \"NO\"\n      debugDocumentVersioning = \"YES\"\n      debugServiceExtension = \"internal\"\n      allowLocationSimulation = \"YES\">\n   </LaunchAction>\n   <ProfileAction\n      buildConfiguration = \"Release\"\n      shouldUseLaunchSchemeArgsEnv = \"YES\"\n      savedToolIdentifier = \"\"\n      useCustomWorkingDirectory = \"NO\"\n      debugDocumentVersioning = \"YES\">\n      <MacroExpansion>\n         <BuildableReference\n            BuildableIdentifier = \"primary\"\n            BlueprintIdentifier = \"7521D6BE291E9ABB009642EF\"\n            BuildableName = \"WCDBObjc.framework\"\n            BlueprintName = \"WCDBObjc\"\n            ReferencedContainer = \"container:WCDB.xcodeproj\">\n         </BuildableReference>\n      </MacroExpansion>\n   </ProfileAction>\n   <AnalyzeAction\n      buildConfiguration = \"Debug\">\n   </AnalyzeAction>\n   <ArchiveAction\n      buildConfiguration = \"Release\"\n      revealArchiveInOrganizer = \"YES\">\n   </ArchiveAction>\n</Scheme>\n"
  },
  {
    "path": "src/WCDB.xcodeproj/xcshareddata/xcschemes/WCDBSwift.xcscheme",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<Scheme\n   LastUpgradeVersion = \"1410\"\n   version = \"1.3\">\n   <BuildAction\n      parallelizeBuildables = \"YES\"\n      buildImplicitDependencies = \"YES\">\n      <BuildActionEntries>\n         <BuildActionEntry\n            buildForTesting = \"YES\"\n            buildForRunning = \"YES\"\n            buildForProfiling = \"YES\"\n            buildForArchiving = \"YES\"\n            buildForAnalyzing = \"YES\">\n            <BuildableReference\n               BuildableIdentifier = \"primary\"\n               BlueprintIdentifier = \"7521DA54291EA349009642EF\"\n               BuildableName = \"WCDBSwift.framework\"\n               BlueprintName = \"WCDBSwift\"\n               ReferencedContainer = \"container:WCDB.xcodeproj\">\n            </BuildableReference>\n         </BuildActionEntry>\n      </BuildActionEntries>\n   </BuildAction>\n   <TestAction\n      buildConfiguration = \"Debug\"\n      selectedDebuggerIdentifier = \"Xcode.DebuggerFoundation.Debugger.LLDB\"\n      selectedLauncherIdentifier = \"Xcode.DebuggerFoundation.Launcher.LLDB\"\n      shouldUseLaunchSchemeArgsEnv = \"YES\">\n      <Testables>\n      </Testables>\n   </TestAction>\n   <LaunchAction\n      buildConfiguration = \"Debug\"\n      selectedDebuggerIdentifier = \"Xcode.DebuggerFoundation.Debugger.LLDB\"\n      selectedLauncherIdentifier = \"Xcode.DebuggerFoundation.Launcher.LLDB\"\n      launchStyle = \"0\"\n      useCustomWorkingDirectory = \"NO\"\n      ignoresPersistentStateOnLaunch = \"NO\"\n      debugDocumentVersioning = \"YES\"\n      debugServiceExtension = \"internal\"\n      allowLocationSimulation = \"YES\">\n   </LaunchAction>\n   <ProfileAction\n      buildConfiguration = \"Release\"\n      shouldUseLaunchSchemeArgsEnv = \"YES\"\n      savedToolIdentifier = \"\"\n      useCustomWorkingDirectory = \"NO\"\n      debugDocumentVersioning = \"YES\">\n      <MacroExpansion>\n         <BuildableReference\n            BuildableIdentifier = \"primary\"\n            BlueprintIdentifier = \"7521DA54291EA349009642EF\"\n            BuildableName = \"WCDBSwift.framework\"\n            BlueprintName = \"WCDBSwift\"\n            ReferencedContainer = \"container:WCDB.xcodeproj\">\n         </BuildableReference>\n      </MacroExpansion>\n   </ProfileAction>\n   <AnalyzeAction\n      buildConfiguration = \"Debug\">\n   </AnalyzeAction>\n   <ArchiveAction\n      buildConfiguration = \"Release\"\n      revealArchiveInOrganizer = \"YES\">\n   </ArchiveAction>\n</Scheme>\n"
  },
  {
    "path": "src/bridge/WCDBBridging.h",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"ObjectBridge.h\"\n\n#include \"BindingBridge.h\"\n#include \"ContainerBridge.h\"\n#include \"CoreBridge.h\"\n#include \"DatabaseBridge.h\"\n#include \"ErrorBridge.h\"\n#include \"FTSBridge.h\"\n#include \"HandleBridge.h\"\n#include \"HandleStatementBridge.h\"\n\n#include \"BindParameterBridge.h\"\n#include \"ColumnBridge.h\"\n#include \"ColumnConstraintBridge.h\"\n#include \"ColumnDefBridge.h\"\n#include \"CommonTableExpressionBridge.h\"\n#include \"ExpressionBridge.h\"\n#include \"ExpressionOperatableBridge.h\"\n#include \"ForeignKeyBridge.h\"\n#include \"FrameSpecBridge.h\"\n#include \"IndexedColumnBridge.h\"\n#include \"JoinBridge.h\"\n#include \"LiteralValueBridge.h\"\n#include \"OrderingTermBridge.h\"\n#include \"PragmaBridge.h\"\n#include \"QualifiedTableBridge.h\"\n#include \"RaiseFunctionBridge.h\"\n#include \"ResultColumnBridge.h\"\n#include \"SchemaBridge.h\"\n#include \"TableConstraintBridge.h\"\n#include \"TableOrSubqueryBridge.h\"\n#include \"UpsertBridge.h\"\n#include \"WindowDefBridge.h\"\n#include \"WinqBridge.h\"\n\n#include \"StatementAlterTableBridge.h\"\n#include \"StatementAnalyzeBridge.h\"\n#include \"StatementAttachBridge.h\"\n#include \"StatementBeginBridge.h\"\n#include \"StatementCommitBridge.h\"\n#include \"StatementCreateIndexBridge.h\"\n#include \"StatementCreateTableBridge.h\"\n#include \"StatementCreateTriggerBridge.h\"\n#include \"StatementCreateViewBridge.h\"\n#include \"StatementCreateVirtualTableBridge.h\"\n#include \"StatementDeleteBridge.h\"\n#include \"StatementDetachBridge.h\"\n#include \"StatementDropIndexBridge.h\"\n#include \"StatementDropTableBridge.h\"\n#include \"StatementDropTriggerBridge.h\"\n#include \"StatementDropViewBridge.h\"\n#include \"StatementExplainBridge.h\"\n#include \"StatementInsertBridge.h\"\n#include \"StatementPragmaBridge.h\"\n#include \"StatementReindexBridge.h\"\n#include \"StatementReleaseBridge.h\"\n#include \"StatementRollbackBridge.h\"\n#include \"StatementSavepointBridge.h\"\n#include \"StatementSelectBridge.h\"\n#include \"StatementUpdateBridge.h\"\n#include \"StatementVacuumBridge.h\"\n\n#include \"WCTAPIBridge.h\"\n"
  },
  {
    "path": "src/bridge/base/ContainerBridge.cpp",
    "content": "//\n// Created by 陈秋文 on 2023/8/6.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"ContainerBridge.h\"\n#include \"StringView.hpp\"\n#include \"Value.hpp\"\n\nCPPCommonValue WCDBCreateCommonValue(const WCDB::Value& value)\n{\n    CPPCommonValue commonValue;\n    switch (value.getType()) {\n    case WCDB::Value::Type::Integer: {\n        commonValue.type = WCDBBridgedType_Int;\n        commonValue.intValue = value.intValue();\n    } break;\n    case WCDB::Value::Type::Float: {\n        commonValue.type = WCDBBridgedType_Double;\n        commonValue.doubleValue = value.floatValue();\n    } break;\n    case WCDB::Value::Type::Text: {\n        commonValue.type = WCDBBridgedType_String;\n        commonValue.intValue = reinterpret_cast<long long>(value.textValue().data());\n    } break;\n    default:\n        commonValue.type = WCDBBridgedType_Invalid;\n        break;\n    }\n    return commonValue;\n}\n\nvoid WCDBEnumerateStringViewMap(const void* _Nonnull map,\n                                void* _Nonnull context,\n                                StringViewMapEnumerator _Nonnull enumerator)\n{\n    const WCDB::StringViewMap<WCDB::Value>* cppMap\n    = static_cast<const WCDB::StringViewMap<WCDB::Value>*>(map);\n    for (auto iter = cppMap->begin(); iter != cppMap->end(); iter++) {\n        enumerator(context, iter->first.data(), WCDBCreateCommonValue(iter->second));\n    }\n}\n"
  },
  {
    "path": "src/bridge/base/ContainerBridge.h",
    "content": "//\n// Created by 陈秋文 on 2023/8/6.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"ObjectBridge.h\"\n\nWCDB_EXTERN_C_BEGIN\n\ntypedef void (*StringViewMapEnumerator)(void* _Nonnull context,\n                                        const char* _Nonnull key,\n                                        CPPCommonValue value);\nvoid WCDBEnumerateStringViewMap(const void* _Nonnull map,\n                                void* _Nonnull context,\n                                StringViewMapEnumerator _Nonnull enumerator);\n\nWCDB_EXTERN_C_END\n"
  },
  {
    "path": "src/bridge/base/ErrorBridge.cpp",
    "content": "//\n// Created by qiuwenchen on 2022/4/1.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"ErrorBridge.h\"\n#include \"Assertion.hpp\"\n#include \"CoreConst.h\"\n#include \"ErrorProne.hpp\"\n#include \"Notifier.hpp\"\n#include \"ObjectBridge.hpp\"\n\nlong WCDBErrorGetCode(CPPError error)\n{\n    WCDBGetObjectOrReturnValue(error, WCDB::Error, cppError, INT_MAX);\n    return WCDB::Error::c2rc(cppError->code());\n}\n\nlong WCDBErrorGetLevel(CPPError error)\n{\n    WCDBGetObjectOrReturnValue(error, WCDB::Error, cppError, (int) WCDB::Error::Level::Error);\n    return (int) cppError->level;\n}\n\nconst char* WCDBErrorGetMsg(CPPError obj)\n{\n    WCDBGetObjectOrReturnValue(obj, WCDB::Error, cppError, \"invalid error obj\");\n    if (cppError->getMessage().length() == 0) {\n        return cppError->getMessage().data();\n    }\n    WCTAssert(cppError->getMessage().length() > 0 && cppError->getMessage().data() != nullptr);\n    if (cppError->getMessage().length() == 0 || cppError->getMessage().data() == nullptr) {\n        return \"no error msg\";\n    }\n    return cppError->getMessage().data();\n}\n\nvoid WCDBErrorEnumerateAllInfo(CPPError error, void* _Nonnull context, StringViewMapEnumerator callback)\n{\n    WCDBGetObjectOrReturn(error, WCDB::Error, cppError);\n    WCDBEnumerateStringViewMap(&cppError->infos, context, callback);\n}\n\nvoid WCDBErrorReport(WCDBErrorLevel level, long code, const char* content, const char* _Nullable path, long tag)\n{\n    WCDB::Error::Level cppLevel;\n    switch (level) {\n    case WCDBErrorLevel_Ignore:\n        cppLevel = WCDB::Error::Level::Ignore;\n        break;\n    case WCDBErrorLevel_Debug:\n        cppLevel = WCDB::Error::Level::Debug;\n        break;\n    case WCDBErrorLevel_Notice:\n        cppLevel = WCDB::Error::Level::Notice;\n        break;\n    case WCDBErrorLevel_Warning:\n        cppLevel = WCDB::Error::Level::Warning;\n        break;\n    case WCDBErrorLevel_Error:\n        cppLevel = WCDB::Error::Level::Error;\n        break;\n    case WCDBErrorLevel_Fatal:\n        cppLevel = WCDB::Error::Level::Fatal;\n        break;\n    }\n    WCDB::Error error(WCDB::Error::rc2c((int) code), cppLevel, content);\n    error.infos.insert_or_assign(WCDB::ErrorStringKeySource, WCDB::ErrorSourceSwift);\n    if (path != nullptr) {\n        error.infos.insert_or_assign(WCDB::ErrorStringKeyPath, path);\n    }\n    if (tag != 0) {\n        error.infos.insert_or_assign(WCDB::ErrorIntKeyTag, tag);\n    }\n    WCDB::Notifier::shared().notify(error);\n}\n"
  },
  {
    "path": "src/bridge/base/ErrorBridge.h",
    "content": "//\n// Created by qiuwenchen on 2022/4/1.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"ContainerBridge.h\"\n#include \"ObjectBridge.h\"\n\nWCDB_EXTERN_C_BEGIN\n\nWCDBDefineCPPBridgedType(CPPError)\n\nenum WCDBErrorLevel {\n    WCDBErrorLevel_Ignore = 1,\n    WCDBErrorLevel_Debug,\n    WCDBErrorLevel_Notice,\n    WCDBErrorLevel_Warning,\n    WCDBErrorLevel_Error,\n    WCDBErrorLevel_Fatal,\n};\n\nlong WCDBErrorGetLevel(CPPError obj);\nlong WCDBErrorGetCode(CPPError obj);\nconst char* _Nonnull WCDBErrorGetMsg(CPPError obj);\n\nvoid WCDBErrorEnumerateAllInfo(CPPError error,\n                               void* _Nonnull context,\n                               StringViewMapEnumerator _Nonnull callback);\n\nvoid WCDBErrorReport(enum WCDBErrorLevel level,\n                     long code,\n                     const char* _Nullable content,\n                     const char* _Nullable path,\n                     long tag);\n\nWCDB_EXTERN_C_END\n"
  },
  {
    "path": "src/bridge/base/ObjectBridge.cpp",
    "content": "//\n// Created by qiuwenchen on 2022/3/31.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"ObjectBridge.hpp\"\n#include \"Assertion.hpp\"\n\nWCDBReleaseSwiftObject g_releaseSwiftObject = nullptr;\n\nvoid WCDBSetReleaseSwiftObjectFunction(WCDBReleaseSwiftObject _Nonnull func)\n{\n    g_releaseSwiftObject = func;\n}\n\nWCDBReleaseSwiftObject _Nonnull WCDBGetReleaseSwiftObjectFunction()\n{\n    return g_releaseSwiftObject;\n}\n\nvoid WCDBReleaseCPPObject(CPPObject* _Nonnull obj)\n{\n    if (obj == nullptr) {\n        return;\n    }\n    if (obj->deleter != nullptr) {\n        obj->deleter(obj->realValue);\n    }\n    free(obj);\n}\n\n#ifdef __ANDROID__\n\nchar* _Nullable* _Nullable WCDBPreAllocStringMemorySlot(int count)\n{\n    return WCDB::StringView::preAllocStringMemorySlot(count);\n}\n\nvoid WCDBAllocStringMemory(char* _Nullable* _Nullable slot, int size)\n{\n    WCDB::StringView::allocStringMemory(slot, size);\n}\n\nvoid WCDBClearAllocatedMemory(int count)\n{\n    WCDB::StringView::clearAllocatedMemory(count);\n}\n\nvoid WCDBClearAllPreAllocatedMemory()\n{\n    WCDB::StringView::clearAllPreAllocatedMemory();\n}\n\n#endif\n\nnamespace WCDB {\n\nCPPObject* _Nullable ObjectBridge::createUnmanagedCPPObject(void* _Nullable obj)\n{\n    if (obj == nullptr) {\n        return nullptr;\n    }\n    CPPObject* cppObj = (CPPObject*) malloc(sizeof(CPPObject));\n    cppObj->realValue = obj;\n    cppObj->isRecyclableObj = false;\n    cppObj->deleter = nullptr;\n    return cppObj;\n}\n\nvoid* _Nullable ObjectBridge::extractOriginalCPPObject(const CPPObject* _Nonnull obj)\n{\n    if (obj == nullptr) {\n        return nullptr;\n    }\n    WCTAssert(obj->realValue != nullptr);\n    void* typedObj = nullptr;\n    if (!obj->isRecyclableObj) {\n        typedObj = (void*) obj->realValue;\n    } else {\n        WCDB::Recyclable<void*>* recyclableObj = (WCDB::Recyclable<void*>*) obj->realValue;\n        typedObj = recyclableObj->get();\n    }\n    return typedObj;\n}\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/bridge/base/ObjectBridge.h",
    "content": "//\n// Created by qiuwenchen on 2022/3/30.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include <stdbool.h>\n\n#ifndef WCDB_EXTERN\n#if defined(__cplusplus)\n#define WCDB_EXTERN extern \"C\"\n#define WCDB_EXTERN_C_BEGIN extern \"C\" {\n#define WCDB_EXTERN_C_END }\n#else\n#define WCDB_EXTERN extern\n#define WCDB_EXTERN_C_BEGIN\n#define WCDB_EXTERN_C_END\n#endif\n#endif\n\nWCDB_EXTERN_C_BEGIN\n\ntypedef void SwiftObject;\ntypedef void (*WCDBReleaseSwiftObject)(SwiftObject* _Nonnull obj);\nvoid WCDBSetReleaseSwiftObjectFunction(WCDBReleaseSwiftObject _Nonnull func);\n\nWCDBReleaseSwiftObject _Nonnull WCDBGetReleaseSwiftObjectFunction();\n\ntypedef struct CPPObject {\n    void* _Nonnull realValue;\n    void (*_Nullable deleter)(void* _Nonnull);\n    bool isRecyclableObj;\n} CPPObject;\nvoid WCDBReleaseCPPObject(CPPObject* _Nonnull obj);\n\ntypedef void (*WCDBContextDestructor)(void* _Nonnull context);\n\n#define WCDBDefineSwiftObjectBridgedType(typename)                             \\\n    typedef struct typename                                                    \\\n    {                                                                          \\\n        WCDB::Recyclable<SwiftObject*> innerValue;                             \\\n    }                                                                          \\\n    typename;\n\n#define WCDBDefineCPPBridgedType(typename)                                     \\\n    typedef struct typename                                                    \\\n    {                                                                          \\\n        CPPObject* _Nullable innerValue;                                       \\\n    }                                                                          \\\n    typename;\n\n#define WCDBDefineOptionalBridgedType(bridgedTypeName, originalTypeName)       \\\n    typedef struct bridgedTypeName {                                           \\\n        bool hasValue;                                                         \\\n        originalTypeName value;                                                \\\n    } bridgedTypeName;\n\nWCDBDefineOptionalBridgedType(OptionalBool, bool)\nWCDBDefineOptionalBridgedType(OptionalUInt64, unsigned long long)\n\nenum WCDBBridgedType {\n    WCDBBridgedType_Invalid = 0,\n    WCDBBridgedType_Null,\n    WCDBBridgedType_Bool,\n    WCDBBridgedType_Int,\n    WCDBBridgedType_UInt,\n    WCDBBridgedType_Double,\n    WCDBBridgedType_String,\n\n    WCDBBridgedType_Column,\n    WCDBBridgedType_Schema,\n    WCDBBridgedType_ColumnDef,\n    WCDBBridgedType_ColumnConstraint,\n    WCDBBridgedType_Expression,\n    WCDBBridgedType_LiteralValue,\n    WCDBBridgedType_ForeignKeyClause,\n    WCDBBridgedType_BindParameter,\n    WCDBBridgedType_RaiseFunction,\n    WCDBBridgedType_WindowDef,\n    WCDBBridgedType_Filter,\n    WCDBBridgedType_IndexedColumn,\n    WCDBBridgedType_TableConstraint,\n    WCDBBridgedType_CommonTableExpression,\n    WCDBBridgedType_QualifiedTableName,\n    WCDBBridgedType_OrderingTerm,\n    WCDBBridgedType_UpsertClause,\n    WCDBBridgedType_Pragma,\n    WCDBBridgedType_JoinClause,\n    WCDBBridgedType_TableOrSubquery,\n    WCDBBridgedType_JoinConstraint,\n    WCDBBridgedType_SelectCore,\n    WCDBBridgedType_ResultColumn,\n    WCDBBridgedType_FrameSpec,\n\n    WCDBBridgedType_AlterTableSTMT,\n    WCDBBridgedType_AnalyzeSTMT,\n    WCDBBridgedType_AttachSTMT,\n    WCDBBridgedType_BeginSTMT,\n    WCDBBridgedType_CommitSTMT,\n    WCDBBridgedType_RollbackSTMT,\n    WCDBBridgedType_SavepointSTMT,\n    WCDBBridgedType_ReleaseSTMT,\n    WCDBBridgedType_CreateIndexSTMT,\n    WCDBBridgedType_CreateTableSTMT,\n    WCDBBridgedType_CreateTriggerSTMT,\n    WCDBBridgedType_SelectSTMT,\n    WCDBBridgedType_InsertSTMT,\n    WCDBBridgedType_DeleteSTMT,\n    WCDBBridgedType_UpdateSTMT,\n    WCDBBridgedType_CreateViewSTMT,\n    WCDBBridgedType_CreateVirtualTableSTMT,\n    WCDBBridgedType_DetachSTMT,\n    WCDBBridgedType_DropIndexSTMT,\n    WCDBBridgedType_DropTableSTMT,\n    WCDBBridgedType_DropTriggerSTMT,\n    WCDBBridgedType_DropViewSTMT,\n    WCDBBridgedType_PragmaSTMT,\n    WCDBBridgedType_ReindexSTMT,\n    WCDBBridgedType_VacuumSTMT,\n    WCDBBridgedType_ExplainSTMT,\n};\n\ntypedef struct CPPData {\n    unsigned char* _Nullable buffer;\n    unsigned long long size;\n} CPPData;\n\ntypedef struct CPPCommonValue {\n    enum WCDBBridgedType type;\n    union {\n        long long intValue;\n        double doubleValue;\n    };\n} CPPCommonValue;\n\ntypedef struct CPPCommonArray {\n    enum WCDBBridgedType type;\n    int length;\n    const void* _Nonnull* _Nullable buffer;\n} CPPCommonArray;\n\ntypedef struct CPPMultiTypeArray {\n    int totalLength;\n    const enum WCDBBridgedType* _Nullable types;\n    const long long* _Nullable intValues;\n    const double* _Nullable doubleValues;\n    const char* _Nonnull* _Nullable stringValues;\n} CPPMultiTypeArray;\n\n#ifdef __ANDROID__\n\nchar* _Nullable* _Nullable WCDBPreAllocStringMemorySlot(int count);\nvoid WCDBAllocStringMemory(char* _Nullable* _Nullable slot, int size);\nvoid WCDBClearAllocatedMemory(int count);\nvoid WCDBClearAllPreAllocatedMemory();\n\n#endif\n\nWCDB_EXTERN_C_END\n"
  },
  {
    "path": "src/bridge/base/ObjectBridge.hpp",
    "content": "//\n// Created by qiuwenchen on 2022/3/30.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"ObjectBridge.h\"\n#include \"Recyclable.hpp\"\n#include <assert.h>\n#include <stdlib.h>\n\n#define __WCDBGetObjectOrReturn(rawObj, objType, typedObjName, action)              \\\n    objType* typedObjName                                                           \\\n    = (objType*) WCDB::ObjectBridge::extractOriginalCPPObject((rawObj).innerValue); \\\n    if (typedObjName == nullptr) {                                                  \\\n        action;                                                                     \\\n    }\n\n#define WCDBGetObjectOrReturn(rawObj, objType, typedObjName)                   \\\n    __WCDBGetObjectOrReturn(rawObj, objType, typedObjName, return)\n\n#define WCDBGetObjectOrReturnValue(rawObj, objType, typedObjName, value)       \\\n    __WCDBGetObjectOrReturn(rawObj, objType, typedObjName, return value)\n\n#define WCDBCreateCPPBridgedObjectByCopy(objType, originObj)                   \\\n    WCDB::ObjectBridge::createCPPBridgedObject<objType>(                       \\\n    WCDB::ObjectBridge::copyCPPObject(originObj))\n\n#define WCDBCreateRecylableCPPObject(objType, originObj)                       \\\n    WCDB::ObjectBridge::createCPPBridgedObject<objType>(                       \\\n    WCDB::ObjectBridge::copyCPPObject(originObj, true))\n\n#define WCDBCreateCPPBridgedObject(objType, cppObjType)                        \\\n    WCDB::ObjectBridge::createCPPBridgedObject<objType>(                       \\\n    WCDB::ObjectBridge::createCPPObject<cppObjType>())\n\n#define WCDBCreateCPPBridgedObjectWithParameters(objType, cppObjType, ...)     \\\n    WCDB::ObjectBridge::createCPPBridgedObject<objType>(                       \\\n    WCDB::ObjectBridge::createCPPObject<cppObjType>(__VA_ARGS__))\n\n#define WCDBCreateUnmanagedCPPObject(objType, originObj)                       \\\n    WCDB::ObjectBridge::createCPPBridgedObject<objType>(                       \\\n    WCDB::ObjectBridge::createUnmanagedCPPObject((void*) originObj))\n\n#define WCDBGetSwiftObject(typedObj) typedObj.innerValue.get()\n\n#define WCDBGetBridgedData(type, data)                                         \\\n    (*((type*) WCDB::ObjectBridge::extractOriginalCPPObject((CPPObject*) data.intValue)))\n\n#define WCDBGetCommonArrayLiteralValue(type, array, i) ((type*) array.buffer)[i]\n\n#define WCDBGetCommonArrayObject(type, array, i)                               \\\n    (*((type*) WCDB::ObjectBridge::extractOriginalCPPObject(                   \\\n    (CPPObject*) ((long long*) array.buffer)[i])))\n\n#define WCDBGetMultiTypeArrayObject(type, array, i)                            \\\n    (*((type*) WCDB::ObjectBridge::extractOriginalCPPObject(                   \\\n    (CPPObject*) (array.intValues[i]))))\n\nnamespace WCDB {\n\ntypedef Recyclable<void*> RecyclableContext;\n\nclass ObjectBridge {\npublic:\n    static CPPObject* _Nullable createUnmanagedCPPObject(void* _Nullable obj);\n\n    template<typename T>\n    static CPPObject* _Nonnull copyCPPObject(T&& obj, bool isRecyclable = false)\n    {\n        static_assert(!std::is_same<T, CPPObject>::value, \"\");\n        static_assert(std::is_copy_constructible<T>::value, \"\");\n        static_assert(sizeof(CPPObject) <= 32, \"\");\n        CPPObject* cppObj\n        = (CPPObject*) malloc(32 + sizeof(std::remove_reference_t<T>));\n        cppObj->realValue = (void*) ((unsigned long long) cppObj + 32);\n        // Creating an object at an address that is not 16-byte aligned may crash on x86 systems.\n        new (cppObj->realValue) std::remove_reference_t<T>(std::forward<T>(obj));\n        cppObj->isRecyclableObj = isRecyclable;\n        cppObj->deleter = releaseCPPObject<std::remove_reference_t<T>>;\n        return cppObj;\n    }\n\n    template<typename T, typename... Args>\n    static CPPObject* _Nonnull createCPPObject(const Args&... args)\n    {\n        static_assert(!std::is_same<T, CPPObject>::value, \"\");\n        static_assert(sizeof(CPPObject) <= 32, \"\");\n        CPPObject* cppObj = (CPPObject*) malloc(32 + sizeof(T));\n        cppObj->realValue = (void*) ((unsigned long long) cppObj + 32);\n        // Creating an object at an address that is not 16-byte aligned may crash on x86 systems.\n        new (cppObj->realValue) T(args...);\n        cppObj->isRecyclableObj = false;\n        cppObj->deleter = releaseCPPObject<T>;\n        return cppObj;\n    }\n\n    template<typename T>\n    static T createCPPBridgedObject(CPPObject* _Nonnull obj)\n    {\n        static_assert(offsetof(T, innerValue) == 0, \"\");\n        static_assert(sizeof(T) == sizeof(CPPObject*), \"\");\n\n        T bridgeObj;\n        bridgeObj.innerValue = obj;\n        return bridgeObj;\n    }\n\n    template<typename T>\n    static void releaseCPPObject(void* _Nonnull obj)\n    {\n        T* typedObj = (T*) obj;\n        if (typedObj != nullptr) {\n            typedObj->~T();\n        }\n    }\n\n    static void* _Nullable extractOriginalCPPObject(const CPPObject* _Nonnull obj);\n};\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/bridge/cppbridge/BindingBridge.cpp",
    "content": "//\n// Created by qiuwenchen on 2022/12/2.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"BindingBridge.h\"\n#include \"Assertion.hpp\"\n#include \"BaseBinding.hpp\"\n#include \"ObjectBridge.hpp\"\n\nnamespace WCDB {\n\nclass BridgedBinding final : public BaseBinding {\npublic:\n    BridgedBinding() = default;\n    ~BridgedBinding() override final = default;\n    void addTableConstraint(const WCDB::TableConstraint& tableConstraint)\n    {\n        static int i = 0;\n        i++;\n        m_constraints.emplace(StringView::formatted(\"%d\", i), tableConstraint);\n    }\n    void addColumnDef(const ColumnDef& columnDef)\n    {\n        m_columnDefs.emplace_back(\n        std::make_pair(columnDef.syntax().column.value().name, columnDef));\n    }\n};\n\n}; // namespace WCDB\n\nCPPBinding WCDBBindingCreate()\n{\n    return WCDBCreateCPPBridgedObject(CPPBinding, WCDB::BridgedBinding);\n}\n\nvoid WCDBBindingAddColumnDef(CPPBinding binding, CPPColumnDef columnDef)\n{\n    WCDBGetObjectOrReturn(binding, WCDB::BridgedBinding, cppBinding);\n    WCDBGetObjectOrReturn(columnDef, WCDB::ColumnDef, cppColumnDef);\n    cppBinding->addColumnDef(*cppColumnDef);\n}\n\nvoid WCDBBindingEnableAutoIncrementForExistingTable(CPPBinding binding)\n{\n    WCDBGetObjectOrReturn(binding, WCDB::BridgedBinding, cppBinding);\n    cppBinding->enableAutoIncrementForExistingTable();\n}\n\nvoid WCDBBindingAddColumnConstraint(CPPBinding binding,\n                                    const char* _Nullable columnName,\n                                    CPPColumnConstraint constraint)\n{\n    WCDBGetObjectOrReturn(binding, WCDB::BridgedBinding, cppBinding);\n    WCDBGetObjectOrReturn(constraint, WCDB::ColumnConstraint, cppConstraint);\n    WCDB::ColumnDef* columnDef = cppBinding->getColumnDef(columnName);\n    WCTRemedialAssert(columnDef != nullptr, \"columndef not found\", return;);\n    columnDef->constraint(*cppConstraint);\n}\n\nvoid WCDBBindingAddIndex(CPPBinding binding,\n                         const char* _Nullable indexSuffix,\n                         bool isFullName,\n                         CPPStatementCreateIndex createIndex)\n{\n    WCDBGetObjectOrReturn(binding, WCDB::BridgedBinding, cppBinding);\n    WCDBGetObjectOrReturn(createIndex, WCDB::StatementCreateIndex, cppCreateIndex);\n    WCDB::BaseBinding::Index& index = cppBinding->getOrCreateIndex(indexSuffix, isFullName);\n    index.action = WCDB::BaseBinding::Index::Action::Create;\n    index.statement = *cppCreateIndex;\n}\n\nvoid WCDBBindingAddTableConstraint(CPPBinding binding, CPPTableConstraint tableConstraint)\n{\n    WCDBGetObjectOrReturn(binding, WCDB::BridgedBinding, cppBinding);\n    WCDBGetObjectOrReturn(tableConstraint, WCDB::TableConstraint, cppTableConstraint);\n    cppBinding->addTableConstraint(*cppTableConstraint);\n}\n\nvoid WCDBBindingConfigVirtualModule(CPPBinding binding, const char* _Nullable moduleName)\n{\n    WCDBGetObjectOrReturn(binding, WCDB::BridgedBinding, cppBinding);\n    cppBinding->statementVirtualTable.usingModule(moduleName);\n}\nvoid WCDBBindingConfigVirtualModuleArgument(CPPBinding binding, const char* _Nullable argument)\n{\n    WCDBGetObjectOrReturn(binding, WCDB::BridgedBinding, cppBinding);\n    cppBinding->statementVirtualTable.argument(argument);\n}\n\nbool WCDBBindingIsPrimaryKey(CPPBinding binding, const char* _Nullable columnName)\n{\n    WCDBGetObjectOrReturnValue(binding, WCDB::BridgedBinding, cppBinding, false);\n    WCDB::ColumnDef* columnDef = cppBinding->getColumnDef(columnName);\n    if (!columnDef) {\n        return false;\n    }\n    return columnDef->syntax().isAutoIncrement();\n}\n\nbool WCDBBindingCreateTable(CPPBinding binding, const char* _Nullable tableName, CPPHandle handle)\n{\n    WCDBGetObjectOrReturnValue(binding, WCDB::BridgedBinding, cppBinding, false);\n    WCDBGetObjectOrReturnValue(handle, WCDB::InnerHandle, cppHandle, false);\n    return cppBinding->createTable(tableName, cppHandle);\n}\n\nbool WCDBBindingCreateVirtualTable(CPPBinding binding, const char* _Nullable tableName, CPPHandle handle)\n{\n    WCDBGetObjectOrReturnValue(binding, WCDB::BridgedBinding, cppBinding, false);\n    WCDBGetObjectOrReturnValue(handle, WCDB::InnerHandle, cppHandle, false);\n    return cppBinding->createVirtualTable(tableName, cppHandle);\n}\n\nvoid WCDBBindingConfigWithoutRowId(CPPBinding binding)\n{\n    WCDBGetObjectOrReturn(binding, WCDB::BridgedBinding, cppBinding);\n    cppBinding->statementTable.withoutRowID();\n}\n\nconst void* _Nullable WCDBBindingGetBaseBinding(CPPBinding binding)\n{\n    WCDBGetObjectOrReturnValue(binding, WCDB::BridgedBinding, cppBinding, nullptr);\n    WCTAssert(dynamic_cast<const WCDB::BaseBinding*>(cppBinding) != nullptr);\n    return static_cast<const WCDB::BaseBinding*>(cppBinding);\n}\n"
  },
  {
    "path": "src/bridge/cppbridge/BindingBridge.h",
    "content": "//\n// Created by qiuwenchen on 2022/12/2.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"HandleBridge.h\"\n#include \"ObjectBridge.h\"\n#include \"WinqBridge.h\"\n\nWCDB_EXTERN_C_BEGIN\n\nWCDBDefineCPPBridgedType(CPPBinding)\n\nCPPBinding WCDBBindingCreate();\nvoid WCDBBindingAddColumnDef(CPPBinding binding, CPPColumnDef columnDef);\nvoid WCDBBindingEnableAutoIncrementForExistingTable(CPPBinding binding);\nvoid WCDBBindingAddColumnConstraint(CPPBinding binding,\n                                    const char* _Nullable columnName,\n                                    CPPColumnConstraint constraint);\nvoid WCDBBindingAddIndex(CPPBinding binding,\n                         const char* _Nullable indexNameOrSuffix,\n                         bool isFullName,\n                         CPPStatementCreateIndex createIndex);\nvoid WCDBBindingAddTableConstraint(CPPBinding binding, CPPTableConstraint tableConstraint);\nvoid WCDBBindingConfigVirtualModule(CPPBinding binding, const char* _Nullable moduleName);\nvoid WCDBBindingConfigVirtualModuleArgument(CPPBinding binding, const char* _Nullable argument);\nbool WCDBBindingIsPrimaryKey(CPPBinding binding, const char* _Nullable columnName);\n\nbool WCDBBindingCreateTable(CPPBinding binding, const char* _Nullable tableName, CPPHandle handle);\nbool WCDBBindingCreateVirtualTable(CPPBinding binding,\n                                   const char* _Nullable tableName,\n                                   CPPHandle handle);\n\nvoid WCDBBindingConfigWithoutRowId(CPPBinding binding);\n\nconst void* _Nullable WCDBBindingGetBaseBinding(CPPBinding binding);\n\nWCDB_EXTERN_C_END\n"
  },
  {
    "path": "src/bridge/cppbridge/CoreBridge.cpp",
    "content": "//\n// Created by qiuwenchen on 2022/4/4.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"CoreBridge.h\"\n#include \"CommonCore.hpp\"\n#include \"ObjectBridge.hpp\"\n#include \"Path.hpp\"\n#include \"ThreadedErrors.hpp\"\n\nCPPDatabase WCDBCoreCreateDatabase(const char* _Nullable path, bool readOnly, bool inMemory)\n{\n    WCDB::RecyclableDatabase database;\n    if (!inMemory) {\n        database\n        = WCDB::CommonCore::shared().getOrCreateDatabase(WCDB::Path::normalize(path));\n        if (readOnly) {\n            database->setReadOnly();\n        }\n    } else {\n        database\n        = WCDB::RecyclableDatabase(new WCDB::InnerDatabase(\":memory:\"),\n                                   [](WCDB::InnerDatabase* db) { delete db; });\n        database->setInMemory();\n    }\n    return WCDBCreateRecylableCPPObject(CPPDatabase, database);\n}\n\nvoid WCDBCoreSetDefaultCipherConfig(int version)\n{\n    WCDB::CommonCore::shared().setDefaultCipherConfiguration(version);\n}\n\nvoid WCDBCorePurgeAllDatabase(void)\n{\n    WCDB::CommonCore::shared().purgeDatabasePool();\n}\n\nbool WCDBCoreSetDefaultTemporaryDirectory(const char* _Nullable dir)\n{\n    return WCDB::CommonCore::shared().setDefaultTemporaryDirectory(dir);\n}\n\nvoid WCDBCoreSetAutoCheckpointEnable(CPPDatabase database, bool enable)\n{\n    WCDBGetObjectOrReturn(database, WCDB::InnerDatabase, cppDatabase);\n    WCDB::CommonCore::shared().enableAutoCheckpoint(cppDatabase, enable);\n}\n\nvoid WCDBCoreSetAutoCheckpointMinFrames(int frames)\n{\n    WCDB::CommonCore::shared().setCheckPointMinFrames(frames);\n}\n\nvoid WCDBCoreReleaseSQLiteMemory(int bytes)\n{\n    WCDB::CommonCore::shared().releaseSQLiteMemory(bytes);\n}\n\nvoid WCDBCoreSetSoftHeapLimit(long long limit)\n{\n    WCDB::CommonCore::shared().setSoftHeapLimit(limit);\n}\n\nCPPError WCDBCoreGetThreadedError()\n{\n    const WCDB::Error& error = WCDB::ThreadedErrors::shared().getThreadedError();\n    return WCDBCreateUnmanagedCPPObject(CPPError, &error);\n}\n\nvoid WCDBCoreGlobalTraceBusy(WCDBBusyTracer _Nullable tracer,\n                             double timeOut,\n                             void* _Nullable context,\n                             WCDBContextDestructor _Nullable destructor)\n{\n    WCDB::CommonCore::BusyMonitor callback = nullptr;\n    if (tracer != nullptr) {\n        WCDB::RecyclableContext recyclableContent(context, destructor);\n        callback = [tracer, recyclableContent](const WCDB::Tag& tag,\n                                               const WCDB::UnsafeStringView& path,\n                                               uint64_t tid,\n                                               const WCDB::UnsafeStringView& sql) {\n            tracer(recyclableContent.get(), tag, path.data(), tid, sql.data());\n        };\n    }\n    WCDB::CommonCore::shared().setBusyMonitor(callback, timeOut);\n}\n"
  },
  {
    "path": "src/bridge/cppbridge/CoreBridge.h",
    "content": "//\n// Created by qiuwenchen on 2022/4/4.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n#include \"DatabaseBridge.h\"\n#include \"ObjectBridge.h\"\n\nWCDB_EXTERN_C_BEGIN\n\nCPPDatabase\nWCDBCoreCreateDatabase(const char* _Nullable path, bool readonly, bool inMemory);\nvoid WCDBCoreSetDefaultCipherConfig(int version);\nvoid WCDBCorePurgeAllDatabase(void);\nbool WCDBCoreSetDefaultTemporaryDirectory(const char* _Nullable dir);\nvoid WCDBCoreSetAutoCheckpointEnable(CPPDatabase database, bool enable);\nvoid WCDBCoreSetAutoCheckpointMinFrames(int frames);\nvoid WCDBCoreReleaseSQLiteMemory(int bytes);\nvoid WCDBCoreSetSoftHeapLimit(long long limit);\nCPPError WCDBCoreGetThreadedError();\n\ntypedef void (*WCDBBusyTracer)(void* _Nullable context,\n                               long tag,\n                               const char* _Nonnull path,\n                               unsigned long long tid,\n                               const char* _Nonnull sql);\nvoid WCDBCoreGlobalTraceBusy(WCDBBusyTracer _Nullable tracer,\n                             double timeOut,\n                             void* _Nullable context,\n                             WCDBContextDestructor _Nullable destructor);\n\nWCDB_EXTERN_C_END\n"
  },
  {
    "path": "src/bridge/cppbridge/DatabaseBridge.cpp",
    "content": "//\n// Created by qiuwenchen on 2022/3/31.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"DatabaseBridge.h\"\n#include \"CipherConfig.hpp\"\n#include \"CommonCore.hpp\"\n#include \"CompressionCenter.hpp\"\n#include \"CompressionConst.hpp\"\n#include \"CustomConfig.hpp\"\n#include \"DBOperationNotifier.hpp\"\n#include \"InnerDatabase.hpp\"\n#include \"ObjectBridge.hpp\"\n\nCPPError WCDBDatabaseGetError(CPPDatabase database)\n{\n    WCDBGetObjectOrReturnValue(database, WCDB::InnerDatabase, cppDatabase, CPPError());\n    const WCDB::Error& error = cppDatabase->getThreadedError();\n    return WCDBCreateUnmanagedCPPObject(CPPError, &error);\n}\n\nlong WCDBDatabaseGetTag(CPPDatabase database)\n{\n    WCDBGetObjectOrReturnValue(database, WCDB::InnerDatabase, cppDatabase, 0);\n    return cppDatabase->getTag();\n}\n\nvoid WCDBDatabaseSetTag(CPPDatabase database, long tag)\n{\n    WCDBGetObjectOrReturn(database, WCDB::InnerDatabase, cppDatabase);\n    cppDatabase->setTag(tag);\n}\n\nconst char* WCDBDatabaseGetPath(CPPDatabase database)\n{\n    WCDBGetObjectOrReturnValue(database, WCDB::InnerDatabase, cppDatabase, nullptr);\n    return cppDatabase->getPath().data();\n}\n\nvoid WCDBDatabaseGetPaths(CPPDatabase database,\n                          void* _Nullable context,\n                          WCDBStringEnumerater _Nonnull enumerator)\n{\n    WCDBGetObjectOrReturn(database, WCDB::InnerDatabase, cppDatabase);\n    std::list<WCDB::StringView> paths = cppDatabase->getPaths();\n    for (const auto& path : paths) {\n        enumerator(context, path.data());\n    }\n}\n\nCPPHandle WCDBDatabaseGetHandle(CPPDatabase database, bool writeHint)\n{\n    WCDBGetObjectOrReturnValue(database, WCDB::InnerDatabase, cppDatabase, CPPHandle());\n    WCDB::RecyclableHandle cppHandle = cppDatabase->getHandle(writeHint);\n    if (cppHandle == nullptr) {\n        CPPHandle invalidHandle;\n        invalidHandle.innerValue = NULL;\n        return invalidHandle;\n    }\n    return WCDBCreateRecylableCPPObject(CPPHandle, cppHandle);\n}\n\nbool WCDBDatabaseCanOpen(CPPDatabase database)\n{\n    WCDBGetObjectOrReturnValue(database, WCDB::InnerDatabase, cppDatabase, false);\n    return cppDatabase->canOpen();\n}\n\nbool WCDBDatabaseIsOpened(CPPDatabase database)\n{\n    WCDBGetObjectOrReturnValue(database, WCDB::InnerDatabase, cppDatabase, false);\n    return cppDatabase->isOpened();\n}\n\nbool WCDBDatabaseIsBlockaded(CPPDatabase database)\n{\n    WCDBGetObjectOrReturnValue(database, WCDB::InnerDatabase, cppDatabase, false);\n    return cppDatabase->isBlockaded();\n}\n\nvoid WCDBDatabaseClose(CPPDatabase database, void* context, WCDBDatabaseCloseCallback callback)\n{\n    WCDBGetObjectOrReturn(database, WCDB::InnerDatabase, cppDatabase);\n    cppDatabase->close([callback, context]() {\n        if (callback != nullptr) {\n            callback(context);\n        }\n    });\n}\n\nvoid WCDBDatabaseBlockade(CPPDatabase database)\n{\n    WCDBGetObjectOrReturn(database, WCDB::InnerDatabase, cppDatabase);\n    cppDatabase->blockade();\n}\n\nvoid WCDBDatabaseUnblockade(CPPDatabase database)\n{\n    WCDBGetObjectOrReturn(database, WCDB::InnerDatabase, cppDatabase);\n    cppDatabase->unblockade();\n}\n\nvoid WCDBDatabasePurge(CPPDatabase database)\n{\n    WCDBGetObjectOrReturn(database, WCDB::InnerDatabase, cppDatabase);\n    cppDatabase->purge();\n}\n\nvoid WCDBDatabaseConfigCipher(CPPDatabase database,\n                              const unsigned char* cipherKey,\n                              int keyLength,\n                              int pageSize,\n                              int cipherVersion)\n{\n    WCDBGetObjectOrReturn(database, WCDB::InnerDatabase, cppDatabase);\n    if (cipherKey) {\n        cppDatabase->setConfig(\n        WCDB::CipherConfigName,\n        std::static_pointer_cast<WCDB::Config>(std::make_shared<WCDB::CipherConfig>(\n        WCDB::UnsafeData::immutable(cipherKey, (size_t) keyLength), pageSize, cipherVersion)),\n        WCDB::Configs::Priority::Highest);\n    } else {\n        cppDatabase->removeConfig(WCDB::CipherConfigName);\n    }\n}\n\nvoid WCDBDatabaseConfig(CPPDatabase database,\n                        const char* _Nullable name,\n                        WCDBConfigCallback _Nonnull invocation,\n                        void* _Nonnull invocationContext,\n                        WCDBConfigCallback _Nullable unInvocation,\n                        void* _Nullable unInvocationContext,\n                        int priority,\n                        WCDBContextDestructor _Nonnull destructor)\n{\n    WCDBGetObjectOrReturn(database, WCDB::InnerDatabase, cppDatabase);\n    if (invocation == NULL) {\n        cppDatabase->removeConfig(name);\n        return;\n    }\n    WCDB::RecyclableContext recyclableInvocationContext(invocationContext, destructor);\n\n    WCDB::CustomConfig::Invocation cppInvocation\n    = [invocation, recyclableInvocationContext](WCDB::InnerHandle* handle) -> bool {\n        return invocation(recyclableInvocationContext.get(),\n                          WCDBCreateUnmanagedCPPObject(CPPHandle, handle));\n    };\n\n    WCDB::CustomConfig::Invocation cppUninvocation = nullptr;\n    if (unInvocation != nullptr) {\n        assert(unInvocationContext != nullptr);\n        WCDB::RecyclableContext recyclableUnInvocationContext(unInvocationContext, destructor);\n        cppUninvocation\n        = [unInvocation, recyclableUnInvocationContext](WCDB::InnerHandle* handle) -> bool {\n            return unInvocation(recyclableUnInvocationContext.get(),\n                                WCDBCreateUnmanagedCPPObject(CPPHandle, handle));\n        };\n    }\n    cppDatabase->setConfig(\n    WCDB::UnsafeStringView(name),\n    std::static_pointer_cast<WCDB::Config>(\n    std::make_shared<WCDB::CustomConfig>(cppInvocation, cppUninvocation)),\n    priority);\n}\n\nvoid WCDBDatabaseEnableLiteMode(CPPDatabase database, bool enable)\n{\n    WCDBGetObjectOrReturn(database, WCDB::InnerDatabase, cppDatabase);\n    cppDatabase->setLiteModeEnable(enable);\n}\n\nstatic_assert(sizeof(CPPPerformanceInfo) == sizeof(WCDB::InnerHandle::PerformanceInfo), \"\");\nstatic_assert(offsetof(CPPPerformanceInfo, tablePageReadCount)\n              == offsetof(WCDB::InnerHandle::PerformanceInfo, tablePageReadCount),\n              \"\");\nstatic_assert(offsetof(CPPPerformanceInfo, tablePageWriteCount)\n              == offsetof(WCDB::InnerHandle::PerformanceInfo, tablePageWriteCount),\n              \"\");\nstatic_assert(offsetof(CPPPerformanceInfo, indexPageReadCount)\n              == offsetof(WCDB::InnerHandle::PerformanceInfo, indexPageReadCount),\n              \"\");\nstatic_assert(offsetof(CPPPerformanceInfo, indexPageWriteCount)\n              == offsetof(WCDB::InnerHandle::PerformanceInfo, indexPageWriteCount),\n              \"\");\nstatic_assert(offsetof(CPPPerformanceInfo, overflowPageReadCount)\n              == offsetof(WCDB::InnerHandle::PerformanceInfo, overflowPageReadCount),\n              \"\");\nstatic_assert(offsetof(CPPPerformanceInfo, overflowPageWriteCount)\n              == offsetof(WCDB::InnerHandle::PerformanceInfo, overflowPageWriteCount),\n              \"\");\nstatic_assert(offsetof(CPPPerformanceInfo, costInNanoseconds)\n              == offsetof(WCDB::InnerHandle::PerformanceInfo, costInNanoseconds),\n              \"\");\n\nvoid WCDBDatabaseGlobalTracePerformance(WCDBPerformanceTracer _Nullable tracer,\n                                        void* _Nullable context,\n                                        WCDBContextDestructor _Nullable destructor)\n{\n    WCDB::InnerHandle::PerformanceNotification callback = nullptr;\n    if (tracer != nullptr) {\n        WCDB::RecyclableContext recyclableContext(context, destructor);\n        callback\n        = [recyclableContext, tracer](const WCDB::Tag& tag,\n                                      const WCDB::UnsafeStringView& path,\n                                      const void* handle,\n                                      const WCDB::UnsafeStringView& sql,\n                                      const WCDB::InnerHandle::PerformanceInfo& info) {\n              tracer(recyclableContext.get(),\n                     tag,\n                     path.data(),\n                     (unsigned long long) handle,\n                     sql.data(),\n                     (const CPPPerformanceInfo*) &info);\n          };\n    }\n    WCDB::CommonCore::shared().setNotificationWhenPerformanceGlobalTraced(callback);\n}\n\nvoid WCDBDatabaseTracePerformance(CPPDatabase database,\n                                  WCDBPerformanceTracer _Nullable tracer,\n                                  void* _Nullable context,\n                                  WCDBContextDestructor _Nullable destructor)\n{\n    WCDBGetObjectOrReturn(database, WCDB::InnerDatabase, cppDatabase);\n    if (tracer != nullptr) {\n        WCDB::RecyclableContext recyclableContext(context, destructor);\n        WCDB::InnerHandle::PerformanceNotification callback\n        = [recyclableContext, tracer](const WCDB::Tag& tag,\n                                      const WCDB::UnsafeStringView& path,\n                                      const void* handle,\n                                      const WCDB::UnsafeStringView& sql,\n                                      const WCDB::InnerHandle::PerformanceInfo& info) {\n              tracer(recyclableContext.get(),\n                     tag,\n                     path.data(),\n                     (unsigned long long) handle,\n                     sql.data(),\n                     (const CPPPerformanceInfo*) &info);\n          };\n        cppDatabase->setConfig(WCDB::PerformanceTraceConfigName,\n                               std::static_pointer_cast<WCDB::Config>(\n                               std::make_shared<WCDB::PerformanceTraceConfig>(callback)),\n                               WCDB::Configs::Priority::Highest);\n    } else {\n        cppDatabase->removeConfig(WCDB::PerformanceTraceConfigName);\n    }\n}\n\nvoid WCDBDatabaseGlobalTraceSQL(WCDBSQLTracer _Nullable tracer,\n                                void* _Nullable context,\n                                WCDBContextDestructor _Nullable destructor)\n{\n    WCDB::InnerHandle::SQLNotification callback = nullptr;\n    if (tracer != nullptr) {\n        WCDB::RecyclableContext recyclableContext(context, destructor);\n        callback = [recyclableContext, tracer](const WCDB::Tag& tag,\n                                               const WCDB::UnsafeStringView& path,\n                                               const void* handle,\n                                               const WCDB::UnsafeStringView& sql,\n                                               const WCDB::UnsafeStringView& info) {\n            tracer(recyclableContext.get(),\n                   tag,\n                   path.data(),\n                   (uint64_t) handle,\n                   sql.data(),\n                   info.data());\n        };\n    }\n    WCDB::CommonCore::shared().setNotificationForSQLGLobalTraced(callback);\n}\n\nvoid WCDBDatabaseTraceSQL(CPPDatabase database,\n                          WCDBSQLTracer _Nullable tracer,\n                          void* _Nullable context,\n                          WCDBContextDestructor _Nullable destructor)\n{\n    WCDBGetObjectOrReturn(database, WCDB::InnerDatabase, cppDatabase);\n    if (tracer != nullptr) {\n        WCDB::RecyclableContext recyclableContext(context, destructor);\n        WCDB::InnerHandle::SQLNotification callback\n        = [recyclableContext, tracer](const WCDB::Tag& tag,\n                                      const WCDB::UnsafeStringView& path,\n                                      const void* handle,\n                                      const WCDB::UnsafeStringView& sql,\n                                      const WCDB::UnsafeStringView& info) {\n              tracer(recyclableContext.get(),\n                     tag,\n                     path.data(),\n                     (uint64_t) handle,\n                     sql.data(),\n                     info.data());\n          };\n        cppDatabase->setConfig(WCDB::SQLTraceConfigName,\n                               std::static_pointer_cast<WCDB::Config>(\n                               std::make_shared<WCDB::SQLTraceConfig>(callback)),\n                               WCDB::Configs::Priority::Highest);\n    } else {\n        cppDatabase->removeConfig(WCDB::SQLTraceConfigName);\n    }\n}\n\nvoid WCDBDatabaseSetFullSQLTraceEnable(CPPDatabase database, bool enable)\n{\n    WCDBGetObjectOrReturn(database, WCDB::InnerDatabase, cppDatabase);\n    cppDatabase->setFullSQLTraceEnable(enable);\n}\n\nvoid WCDBDatabaseGlobalTraceError(WCDBErrorTracer _Nullable tracer,\n                                  void* _Nullable context,\n                                  WCDBContextDestructor _Nullable destructor)\n{\n    if (tracer != nullptr) {\n        WCDB::RecyclableContext recyclableContext(context, destructor);\n        WCDB::CommonCore::shared().setNotificationWhenErrorTraced(\n        [recyclableContext, tracer](const WCDB::Error& error) {\n            tracer(recyclableContext.get(), WCDBCreateUnmanagedCPPObject(CPPError, &error));\n        });\n    } else {\n        WCDB::CommonCore::shared().setNotificationWhenErrorTraced(nullptr);\n    }\n}\n\nvoid WCDBDatabaseTraceError(CPPDatabase database,\n                            WCDBErrorTracer _Nullable tracer,\n                            void* _Nullable context,\n                            WCDBContextDestructor _Nullable destructor)\n{\n    const char* path = WCDBDatabaseGetPath(database);\n    if (tracer != nullptr) {\n        WCDB::RecyclableContext recyclableContext(context, destructor);\n        WCDB::CommonCore::shared().setNotificationWhenErrorTraced(\n        path, [recyclableContext, tracer](const WCDB::Error& error) {\n            tracer(recyclableContext.get(), WCDBCreateUnmanagedCPPObject(CPPError, &error));\n        });\n    } else {\n        WCDB::CommonCore::shared().setNotificationWhenErrorTraced(path, nullptr);\n    }\n}\n\n#ifndef __ANDROID__\nconst char* _Nonnull WCDBDatabaseOperationTracerInfoKeyHandleCount()\n{\n    return WCDB::MonitorInfoKeyHandleCount.data();\n}\n\nconst char* _Nonnull WCDBDatabaseOperationTracerInfoKeyHandleOpenTime()\n{\n    return WCDB::MonitorInfoKeyHandleOpenTime.data();\n}\n\nconst char* _Nonnull WCDBDatabaseOperationTracerInfoKeyHandleOpenCPUTime()\n{\n    return WCDB::MonitorInfoKeyHandleOpenCPUTime.data();\n}\n\nconst char* _Nonnull WCDBDatabaseOperationTracerInfoKeySchemaUsage()\n{\n    return WCDB::MonitorInfoKeySchemaUsage.data();\n}\n\nconst char* _Nonnull WCDBDatabaseOperationTracerInfoKeyTableCount()\n{\n    return WCDB::MonitorInfoKeyTableCount.data();\n}\n\nconst char* _Nonnull WCDBDatabaseOperationTracerInfoKeyIndexCount()\n{\n    return WCDB::MonitorInfoKeyIndexCount.data();\n}\n\nconst char* _Nonnull WCDBDatabaseOperationTracerInfoKeyTriggerCount()\n{\n    return WCDB::MonitorInfoKeyTriggerCount.data();\n}\n#endif\n\nvoid WCDBDatabaseGlobalTraceOperation(WCDBOperationTracer _Nullable tracer,\n                                      void* _Nullable context,\n                                      WCDBContextDestructor _Nullable destructor)\n{\n    if (tracer != nullptr) {\n        WCDB::RecyclableContext recyclableContext(context, destructor);\n        WCDB::DBOperationNotifier::shared().setNotification(\n        [=](WCDB::InnerDatabase* database,\n            WCDB::DBOperationNotifier::Operation operation,\n            const WCDB::StringViewMap<WCDB::Value>& info) {\n            CPPDatabase cppDatabase = WCDBCreateUnmanagedCPPObject(CPPDatabase, database);\n            tracer(recyclableContext.get(), cppDatabase, operation, &info);\n        });\n    } else {\n        WCDB::DBOperationNotifier::shared().setNotification(nullptr);\n    }\n}\n\nbool WCDBDatabaseRemoveFile(CPPDatabase database)\n{\n    WCDBGetObjectOrReturnValue(database, WCDB::InnerDatabase, cppDatabase, false);\n    return cppDatabase->removeFiles();\n}\n\nbool WCDBDatabaseMoveFile(CPPDatabase database, const char* _Nonnull destination)\n{\n    WCDBGetObjectOrReturnValue(database, WCDB::InnerDatabase, cppDatabase, false);\n    return cppDatabase->moveFiles(WCDB::UnsafeStringView(destination));\n}\n\nOptionalUInt64 WCDBDatabaseGetFileSize(CPPDatabase database)\n{\n    OptionalUInt64 ret = { false, 0 };\n    WCDBGetObjectOrReturnValue(database, WCDB::InnerDatabase, cppDatabase, ret);\n    auto size = cppDatabase->getFilesSize();\n    if (size.succeed()) {\n        ret.hasValue = true;\n        ret.value = size.value();\n    }\n    return ret;\n}\n\nvoid WCDBDatabaseSetNotificationWhenCorrupted(CPPDatabase database,\n                                              WCDBCorruptioNotification _Nullable notification,\n                                              void* _Nullable context,\n                                              WCDBContextDestructor _Nullable destructor)\n{\n    WCDBGetObjectOrReturn(database, WCDB::InnerDatabase, cppDatabase);\n    WCDB::CommonCore::CorruptedNotification cppNotification = nullptr;\n    if (notification != nullptr) {\n        WCDB::RecyclableContext recyclableContext(context, destructor);\n        cppNotification = [notification, recyclableContext](WCDB::InnerDatabase* cppDatabase) {\n            notification(recyclableContext.get(),\n                         WCDBCreateUnmanagedCPPObject(CPPDatabase, cppDatabase));\n        };\n    }\n    WCDB::CommonCore::shared().setNotificationWhenDatabaseCorrupted(\n    cppDatabase->getPath(), cppNotification);\n}\n\nbool WCDBDatabaseCheckIfCorrupted(CPPDatabase database)\n{\n    WCDBGetObjectOrReturnValue(database, WCDB::InnerDatabase, cppDatabase, false);\n    cppDatabase->checkIntegrity(false);\n    return WCDBDatabaseCheckIsAlreadyCorrupted(database);\n}\n\nbool WCDBDatabaseCheckIsAlreadyCorrupted(CPPDatabase database)\n{\n    WCDBGetObjectOrReturnValue(database, WCDB::InnerDatabase, cppDatabase, false);\n    return WCDB::CommonCore::shared().isFileObservedCorrupted(cppDatabase->getPath());\n}\n\nvoid WCDBDatabaseEnableAutoBackup(CPPDatabase database, bool enable)\n{\n    WCDBGetObjectOrReturn(database, WCDB::InnerDatabase, cppDatabase);\n    WCDB::CommonCore::shared().enableAutoBackup(cppDatabase, enable);\n}\n\nbool WCDBDatabaseBackup(CPPDatabase database)\n{\n    WCDBGetObjectOrReturnValue(database, WCDB::InnerDatabase, cppDatabase, false);\n    return cppDatabase->backup(false);\n}\n\nvoid WCDBDatabaseFilterBackup(CPPDatabase database,\n                              WCDBBackupFilter _Nullable filter,\n                              void* _Nullable context,\n                              WCDBContextDestructor _Nullable destructor)\n{\n    WCDBGetObjectOrReturn(database, WCDB::InnerDatabase, cppDatabase);\n    WCDB::InnerDatabase::BackupFilter cppFilter = nullptr;\n    if (filter != nullptr) {\n        WCDB::RecyclableContext recyclableContext(context, destructor);\n        cppFilter\n        = [filter, recyclableContext](const WCDB::UnsafeStringView& tableName) -> bool {\n            return filter(recyclableContext.get(), tableName.data());\n        };\n    }\n    cppDatabase->filterBackup(cppFilter);\n}\n\nbool WCDBDatabaseDeposit(CPPDatabase database)\n{\n    WCDBGetObjectOrReturnValue(database, WCDB::InnerDatabase, cppDatabase, false);\n    return cppDatabase->deposit();\n}\n\nbool WCDBDatabaseRemoveDepositedFiles(CPPDatabase database)\n{\n    WCDBGetObjectOrReturnValue(database, WCDB::InnerDatabase, cppDatabase, false);\n    return cppDatabase->removeDeposited();\n}\n\nbool WCDBDatabaseContainDepositedFiles(CPPDatabase database)\n{\n    WCDBGetObjectOrReturnValue(database, WCDB::InnerDatabase, cppDatabase, false);\n    return cppDatabase->containsDeposited();\n}\n\ndouble WCDBDatabaseRetrieve(CPPDatabase database,\n                            WCDBProgressUpdate _Nullable monitor,\n                            void* _Nullable context,\n                            WCDBContextDestructor _Nullable destructor)\n{\n    WCDBGetObjectOrReturnValue(database, WCDB::InnerDatabase, cppDatabase, false);\n    WCDB::InnerDatabase::ProgressCallback callback = nullptr;\n    if (monitor != nullptr) {\n        WCDB::RecyclableContext recyclableContext(context, destructor);\n        callback = [monitor, recyclableContext](double percentage, double increment) {\n            monitor(recyclableContext.get(), percentage, increment);\n            return true;\n        };\n    }\n    return cppDatabase->retrieve(callback);\n}\n\nbool WCDBDatabaseVacuum(CPPDatabase database,\n                        WCDBProgressUpdate _Nullable monitor,\n                        void* _Nullable context,\n                        WCDBContextDestructor _Nullable destructor)\n{\n    WCDBGetObjectOrReturnValue(database, WCDB::InnerDatabase, cppDatabase, false);\n    WCDB::InnerDatabase::ProgressCallback callback = nullptr;\n    if (monitor != nullptr) {\n        WCDB::RecyclableContext recyclableContext(context, destructor);\n        callback = [monitor, recyclableContext](double percentage, double increment) {\n            monitor(recyclableContext.get(), percentage, increment);\n            return true;\n        };\n    }\n    return cppDatabase->vacuum(callback);\n}\n\nvoid WCDBDatabaseEnableAutoVacuum(CPPDatabase database, bool incremental)\n{\n    WCDBGetObjectOrReturn(database, WCDB::InnerDatabase, cppDatabase);\n    cppDatabase->enableAutoVacuum(incremental);\n}\n\nbool WCDBDatabaseIncrementalVacuum(CPPDatabase database, int pages)\n{\n    WCDBGetObjectOrReturnValue(database, WCDB::InnerDatabase, cppDatabase, false);\n    return cppDatabase->incrementalVacuum(pages);\n}\n\nbool WCDBDatabasePassiveCheckpoint(CPPDatabase database)\n{\n    WCDBGetObjectOrReturnValue(database, WCDB::InnerDatabase, cppDatabase, false);\n    return cppDatabase->checkpoint(false, WCDB::InnerDatabase::CheckPointMode::Passive);\n}\n\nbool WCDBDatabaseTruncateCheckpoint(CPPDatabase database)\n{\n    WCDBGetObjectOrReturnValue(database, WCDB::InnerDatabase, cppDatabase, false);\n    return cppDatabase->checkpoint(false, WCDB::InnerDatabase::CheckPointMode::Truncate);\n}\n\nvoid WCDBMigrationInfoSetterImp(WCDB::MigrationUserInfo* info,\n                                const char* sourceTable,\n                                CPPExpression expression)\n{\n    info->setSource(sourceTable);\n    WCDBGetObjectOrReturn(expression, WCDB::Expression, cppExpression);\n    info->setFilter(*cppExpression);\n}\n\nvoid WCDBDatabaseAddMigration(CPPDatabase database,\n                              const char* _Nullable sourcePath,\n                              const unsigned char* _Nullable sourceCipher,\n                              int cipherLength,\n                              WCDBMigrationFilter _Nullable filter,\n                              void* _Nullable context,\n                              WCDBContextDestructor _Nullable destructor)\n{\n    WCDBGetObjectOrReturn(database, WCDB::InnerDatabase, cppDatabase);\n    WCDB::InnerDatabase::MigrationTableFilter cppFilter = nullptr;\n    if (filter != nullptr) {\n        WCDB::RecyclableContext recyclableContext(context, destructor);\n        cppFilter = [recyclableContext, filter](WCDB::MigrationUserInfo& info) {\n            filter(recyclableContext.get(),\n                   info.getTable().data(),\n                   &info,\n                   (WCDBMigrationInfoSetter) WCDBMigrationInfoSetterImp);\n        };\n    }\n    cppDatabase->addMigration(\n    sourcePath, WCDB::UnsafeData::immutable(sourceCipher, (size_t) cipherLength), cppFilter);\n}\n\nbool WCDBDatabaseStepMigration(CPPDatabase database)\n{\n    WCDBGetObjectOrReturnValue(database, WCDB::InnerDatabase, cppDatabase, false);\n    return (cppDatabase->stepMigration(false)).succeed();\n}\n\nvoid WCDBDatabaseEnableAutoMigration(CPPDatabase database, bool flag)\n{\n    WCDBGetObjectOrReturn(database, WCDB::InnerDatabase, cppDatabase);\n    WCDB::CommonCore::shared().enableAutoMigrate(cppDatabase, flag);\n}\n\nvoid WCDBDatabaseSetNotificationWhenMigrated(CPPDatabase database,\n                                             WCDBMigrationNotification _Nullable notification,\n                                             void* _Nullable context,\n                                             WCDBContextDestructor _Nullable destructor)\n{\n    WCDBGetObjectOrReturn(database, WCDB::InnerDatabase, cppDatabase);\n    WCDB::InnerDatabase::MigratedCallback callback = nullptr;\n    if (notification != nullptr) {\n        WCDB::RecyclableContext recyclableContext(context, destructor);\n        callback = [notification, recyclableContext](\n                   WCDB::InnerDatabase* cppDatabase, const WCDB::MigrationBaseInfo* baseInfo) {\n            CPPDatabase database = WCDBCreateUnmanagedCPPObject(CPPDatabase, cppDatabase);\n            if (baseInfo != nullptr) {\n                notification(recyclableContext.get(),\n                             database,\n                             baseInfo->getTable().data(),\n                             baseInfo->getSourceTable().data());\n            } else {\n                notification(recyclableContext.get(), database, nullptr, nullptr);\n            }\n        };\n    }\n    cppDatabase->setNotificationWhenMigrated(callback);\n}\n\nbool WCDBDatabaseIsMigrated(CPPDatabase database)\n{\n    WCDBGetObjectOrReturnValue(database, WCDB::InnerDatabase, cppDatabase, false);\n    return cppDatabase->isMigrated();\n}\n\nCPPData WCDBDatabaseTrainDict(unsigned char dictId,\n                              WCDBDataEnumerator _Nonnull dataEnumerator,\n                              void* _Nonnull enumerateContext)\n{\n    auto dict = WCDB::CompressionCenter::shared().trainDict(\n    dictId, [&]() -> WCDB::Optional<WCDB::UnsafeData> {\n        CPPData data = dataEnumerator(enumerateContext);\n        if (data.buffer != nullptr) {\n            return WCDB::UnsafeData((unsigned char*) data.buffer, data.size);\n        } else {\n            return WCDB::NullOpt;\n        }\n    });\n    if (dict.hasValue()) {\n        size_t size = dict.value().size();\n        unsigned char* buffer = (unsigned char*) malloc(size);\n        if (buffer != nullptr) {\n            memcpy(buffer, dict.value().buffer(), size);\n            return { buffer, size };\n        }\n    }\n    return { nullptr, 0 };\n}\n\nbool WCDBDatabaseRegisterDict(const unsigned char* _Nullable dict, long dictSize, unsigned char dictId)\n{\n    return WCDB::CompressionCenter::shared().registerDict(\n    dictId, WCDB::UnsafeData((unsigned char*) dict, dictSize));\n}\n\nvoid WCDBDatabaseSetZSTDNormalCompress(void* _Nonnull context, CPPColumn column)\n{\n    WCDBGetObjectOrReturn(column, WCDB::Column, cppColumn);\n    WCDB::CompressionColumnInfo columnInfo(*cppColumn, WCDB::CompressionType::Normal);\n    WCDB::CompressionTableUserInfo* userInfo = (WCDB::CompressionTableUserInfo*) context;\n    userInfo->addCompressingColumn(columnInfo);\n}\n\nvoid WCDBDatabaseSetZSTDDictCompress(void* _Nonnull context, CPPColumn column, unsigned char dictid)\n{\n    WCDBGetObjectOrReturn(column, WCDB::Column, cppColumn);\n    WCDB::CompressionColumnInfo columnInfo(*cppColumn, WCDB::CompressionType::Dict);\n    columnInfo.setCommonDict(dictid);\n    WCDB::CompressionTableUserInfo* userInfo = (WCDB::CompressionTableUserInfo*) context;\n    userInfo->addCompressingColumn(columnInfo);\n}\n\nvoid WCDBDatabaseSetZSTDMultiDictCompress(void* _Nonnull context,\n                                          CPPColumn column,\n                                          CPPColumn matchColumn,\n                                          const long long* _Nullable values,\n                                          const unsigned char* _Nullable dictIds,\n                                          int dictCount)\n{\n    WCDBGetObjectOrReturn(column, WCDB::Column, cppColumn);\n    WCDBGetObjectOrReturn(matchColumn, WCDB::Column, cppMatchColumn);\n    WCDB::CompressionColumnInfo columnInfo(*cppColumn, *cppMatchColumn);\n    for (int i = 0; i < dictCount; i++) {\n        if (values[i] == INT64_MAX) {\n            columnInfo.setCommonDict(dictIds[i]);\n        } else {\n            columnInfo.addMatchDict(values[i], dictIds[i]);\n        }\n    }\n    WCDB::CompressionTableUserInfo* userInfo = (WCDB::CompressionTableUserInfo*) context;\n    userInfo->addCompressingColumn(columnInfo);\n}\n\nvoid WCDBDatabaseEnableReplaceCompresssion(void* _Nonnull context)\n{\n    WCDB::CompressionTableUserInfo* userInfo = (WCDB::CompressionTableUserInfo*) context;\n    userInfo->enableReplaceCompresssion();\n}\n\nvoid WCDBDatabaseSetCompression(CPPDatabase database,\n                                WCDBCompressionFilter _Nullable filter,\n                                void* _Nullable context,\n                                WCDBContextDestructor _Nullable destructor)\n{\n    WCDBGetObjectOrReturn(database, WCDB::InnerDatabase, cppDatabase);\n    WCDB::InnerDatabase::CompressionTableFilter cppFilter = nullptr;\n    if (filter != nullptr) {\n        WCDB::RecyclableContext recyclableContext(context, destructor);\n        cppFilter = [recyclableContext, filter](WCDB::CompressionTableUserInfo& userInfo) {\n            filter(recyclableContext.get(), userInfo.getTable().data(), &userInfo);\n        };\n        WCDB::StringView configName\n        = WCDB::StringView::formatted(\"%s%s\",\n                                      WCDB::ScalarFunctionConfigPrefix.data(),\n                                      WCDB::DecompressFunctionName.data());\n        cppDatabase->setConfig(\n        configName,\n        WCDB::CommonCore::shared().scalarFunctionConfig(WCDB::DecompressFunctionName),\n        WCDB::Configs::Priority::Higher);\n    }\n    cppDatabase->addCompression(cppFilter);\n}\n\nvoid WCDBDatabaseDisableCompressNewData(CPPDatabase database, bool disable)\n{\n    WCDBGetObjectOrReturn(database, WCDB::InnerDatabase, cppDatabase);\n    cppDatabase->setCanCompressNewData(!disable);\n}\n\nbool WCDBDatabaseStepCompression(CPPDatabase database)\n{\n    WCDBGetObjectOrReturnValue(database, WCDB::InnerDatabase, cppDatabase, false);\n    return cppDatabase->stepCompression(false).succeed();\n}\n\nvoid WCDBDatabaseEnableAutoCompression(CPPDatabase database, bool enable)\n{\n    WCDBGetObjectOrReturn(database, WCDB::InnerDatabase, cppDatabase);\n    WCDB::CommonCore::shared().enableAutoCompress(cppDatabase, enable);\n}\n\nbool WCDBDatabaseIsCompressed(CPPDatabase database)\n{\n    WCDBGetObjectOrReturnValue(database, WCDB::InnerDatabase, cppDatabase, false);\n    return cppDatabase->isCompressed();\n}\n\nvoid WCDBDatabaseSetNotificationWhenCompressed(CPPDatabase database,\n                                               WCDBCompressdNotification _Nullable notification,\n                                               void* _Nullable context,\n                                               WCDBContextDestructor _Nullable destructor)\n{\n    WCDBGetObjectOrReturn(database, WCDB::InnerDatabase, cppDatabase);\n    WCDB::InnerDatabase::CompressedCallback callback = nullptr;\n    if (notification != nullptr) {\n        WCDB::RecyclableContext recyclableContext(context, destructor);\n        callback = [notification, recyclableContext](\n                   WCDB::InnerDatabase* cppDatabase,\n                   const WCDB::CompressionTableBaseInfo* info) {\n            CPPDatabase database = WCDBCreateUnmanagedCPPObject(CPPDatabase, cppDatabase);\n            if (info != nullptr) {\n                notification(recyclableContext.get(), database, info->getTable().data());\n            } else {\n                notification(recyclableContext.get(), database, nullptr);\n            }\n        };\n    }\n    cppDatabase->setNotificationWhenCompressed(callback);\n}\n\nbool WCDBDatabaseRollbackCompression(CPPDatabase database,\n                                     WCDBProgressUpdate _Nullable monitor,\n                                     void* _Nullable context,\n                                     WCDBContextDestructor _Nullable destructor)\n{\n    WCDBGetObjectOrReturnValue(database, WCDB::InnerDatabase, cppDatabase, false);\n    WCDB::InnerDatabase::ProgressCallback callback = nullptr;\n    if (monitor != nullptr) {\n        WCDB::RecyclableContext recyclableContext(context, destructor);\n        callback = [monitor, recyclableContext](double percentage, double increment) {\n            monitor(recyclableContext.get(), percentage, increment);\n            return true;\n        };\n    }\n    return cppDatabase->rollbackCompression(callback);\n}\n\nshort WCDBDatabaseGetAliveHandleCount(CPPDatabase database)\n{\n    WCDBGetObjectOrReturnValue(database, WCDB::InnerDatabase, cppDatabase, 0);\n    return (short) cppDatabase->numberOfAliveHandles();\n}\n"
  },
  {
    "path": "src/bridge/cppbridge/DatabaseBridge.h",
    "content": "//\n// Created by qiuwenchen on 2022/3/31.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n#include \"ErrorBridge.h\"\n#include \"HandleBridge.h\"\n#include \"ObjectBridge.h\"\n\nWCDB_EXTERN_C_BEGIN\n\nWCDBDefineCPPBridgedType(CPPDatabase)\n\nCPPError WCDBDatabaseGetError(CPPDatabase database);\nlong WCDBDatabaseGetTag(const CPPDatabase database);\nvoid WCDBDatabaseSetTag(CPPDatabase database, long tag);\nconst char* _Nullable WCDBDatabaseGetPath(CPPDatabase database);\n\ntypedef void (*WCDBStringEnumerater)(void* _Nullable context, const char* _Nonnull string);\nvoid WCDBDatabaseGetPaths(CPPDatabase database,\n                          void* _Nullable context,\n                          WCDBStringEnumerater _Nonnull enumerater);\n\nCPPHandle WCDBDatabaseGetHandle(CPPDatabase database, bool writeHint);\n\nbool WCDBDatabaseCanOpen(CPPDatabase database);\nbool WCDBDatabaseIsOpened(CPPDatabase database);\nbool WCDBDatabaseIsBlockaded(CPPDatabase database);\ntypedef void (*WCDBDatabaseCloseCallback)(void* _Nonnull context);\nvoid WCDBDatabaseClose(CPPDatabase database,\n                       void* _Nullable context,\n                       WCDBDatabaseCloseCallback _Nullable callback);\nvoid WCDBDatabaseBlockade(CPPDatabase database);\nvoid WCDBDatabaseUnblockade(CPPDatabase database);\nvoid WCDBDatabasePurge(CPPDatabase database);\n\nvoid WCDBDatabaseConfigCipher(CPPDatabase database,\n                              const unsigned char* _Nullable cipherKey,\n                              int keyLength,\n                              int pageSize,\n                              int cipherVersion);\n\ntypedef bool (*WCDBConfigCallback)(void* _Nonnull context, CPPHandle handle);\nvoid WCDBDatabaseConfig(CPPDatabase database,\n                        const char* _Nullable name,\n                        WCDBConfigCallback _Nonnull invocation,\n                        void* _Nonnull invocationContext,\n                        WCDBConfigCallback _Nullable unInvocation,\n                        void* _Nullable unInvocationContext,\n                        int priority,\n                        WCDBContextDestructor _Nonnull destructor);\n\nvoid WCDBDatabaseEnableLiteMode(CPPDatabase database, bool enable);\n\ntypedef struct CPPPerformanceInfo {\n    int tablePageReadCount;\n    int tablePageWriteCount;\n    int indexPageReadCount;\n    int indexPageWriteCount;\n    int overflowPageReadCount;\n    int overflowPageWriteCount;\n    long long costInNanoseconds;\n} CPPPerformanceInfo;\ntypedef void (*WCDBPerformanceTracer)(void* _Nullable context,\n                                      long tag,\n                                      const char* _Nonnull path,\n                                      unsigned long long handleId,\n                                      const char* _Nonnull sql,\n                                      const CPPPerformanceInfo* _Nonnull info);\n\nvoid WCDBDatabaseGlobalTracePerformance(WCDBPerformanceTracer _Nullable tracer,\n                                        void* _Nullable context,\n                                        WCDBContextDestructor _Nullable destructor);\nvoid WCDBDatabaseTracePerformance(CPPDatabase database,\n                                  WCDBPerformanceTracer _Nullable tracer,\n                                  void* _Nullable context,\n                                  WCDBContextDestructor _Nullable destructor);\n\ntypedef void (*WCDBSQLTracer)(void* _Nullable context,\n                              long tag,\n                              const char* _Nonnull path,\n                              unsigned long long handleId,\n                              const char* _Nonnull sql,\n                              const char* _Nonnull info);\nvoid WCDBDatabaseGlobalTraceSQL(WCDBSQLTracer _Nullable tracer,\n                                void* _Nullable context,\n                                WCDBContextDestructor _Nullable destructor);\nvoid WCDBDatabaseTraceSQL(CPPDatabase database,\n                          WCDBSQLTracer _Nullable tracer,\n                          void* _Nullable context,\n                          WCDBContextDestructor _Nullable destructor);\n\nvoid WCDBDatabaseSetFullSQLTraceEnable(CPPDatabase database, bool enable);\n\ntypedef void (*WCDBErrorTracer)(void* _Nullable context, CPPError error);\nvoid WCDBDatabaseGlobalTraceError(WCDBErrorTracer _Nullable tracer,\n                                  void* _Nullable context,\n                                  WCDBContextDestructor _Nullable destructor);\nvoid WCDBDatabaseTraceError(CPPDatabase database,\n                            WCDBErrorTracer _Nullable tracer,\n                            void* _Nullable context,\n                            WCDBContextDestructor _Nullable destructor);\n\n#ifndef __ANDROID__\nconst char* _Nonnull WCDBDatabaseOperationTracerInfoKeyHandleCount();\nconst char* _Nonnull WCDBDatabaseOperationTracerInfoKeyHandleOpenTime();\nconst char* _Nonnull WCDBDatabaseOperationTracerInfoKeyHandleOpenCPUTime();\nconst char* _Nonnull WCDBDatabaseOperationTracerInfoKeySchemaUsage();\nconst char* _Nonnull WCDBDatabaseOperationTracerInfoKeyTableCount();\nconst char* _Nonnull WCDBDatabaseOperationTracerInfoKeyIndexCount();\nconst char* _Nonnull WCDBDatabaseOperationTracerInfoKeyTriggerCount();\n#endif\n\ntypedef void (*WCDBOperationTracer)(void* _Nullable context,\n                                    CPPDatabase database,\n                                    long operation,\n                                    const void* _Nonnull info);\nvoid WCDBDatabaseGlobalTraceOperation(WCDBOperationTracer _Nullable tracer,\n                                      void* _Nullable context,\n                                      WCDBContextDestructor _Nullable destructor);\n\nbool WCDBDatabaseRemoveFile(CPPDatabase database);\nbool WCDBDatabaseMoveFile(CPPDatabase database, const char* _Nonnull destination);\n\nOptionalUInt64 WCDBDatabaseGetFileSize(CPPDatabase database);\n\ntypedef void (*WCDBCorruptioNotification)(void* _Nullable context, CPPDatabase database);\nvoid WCDBDatabaseSetNotificationWhenCorrupted(CPPDatabase database,\n                                              WCDBCorruptioNotification _Nullable notification,\n                                              void* _Nullable context,\n                                              WCDBContextDestructor _Nullable destructor);\n\nbool WCDBDatabaseCheckIfCorrupted(CPPDatabase database);\nbool WCDBDatabaseCheckIsAlreadyCorrupted(CPPDatabase database);\nvoid WCDBDatabaseEnableAutoBackup(CPPDatabase database, bool enable);\nbool WCDBDatabaseBackup(CPPDatabase database);\n\ntypedef bool (*WCDBBackupFilter)(void* _Nullable context, const char* _Nonnull tableName);\nvoid WCDBDatabaseFilterBackup(CPPDatabase database,\n                              WCDBBackupFilter _Nullable filter,\n                              void* _Nullable context,\n                              WCDBContextDestructor _Nullable destructor);\n\nbool WCDBDatabaseDeposit(CPPDatabase database);\nbool WCDBDatabaseRemoveDepositedFiles(CPPDatabase database);\nbool WCDBDatabaseContainDepositedFiles(CPPDatabase database);\n\ntypedef bool (*WCDBProgressUpdate)(void* _Nullable context, double percentage, double increment);\ndouble WCDBDatabaseRetrieve(CPPDatabase database,\n                            WCDBProgressUpdate _Nullable monitor,\n                            void* _Nullable context,\n                            WCDBContextDestructor _Nullable destructor);\n\nbool WCDBDatabaseVacuum(CPPDatabase database,\n                        WCDBProgressUpdate _Nullable monitor,\n                        void* _Nullable context,\n                        WCDBContextDestructor _Nullable destructor);\nvoid WCDBDatabaseEnableAutoVacuum(CPPDatabase database, bool incremental);\nbool WCDBDatabaseIncrementalVacuum(CPPDatabase database, int pages);\n\nbool WCDBDatabasePassiveCheckpoint(CPPDatabase database);\nbool WCDBDatabaseTruncateCheckpoint(CPPDatabase database);\n\ntypedef void (*WCDBMigrationInfoSetter)(void* _Nonnull context,\n                                        const char* _Nullable sourceTable,\n                                        CPPExpression filterCondition);\ntypedef void (*WCDBMigrationFilter)(void* _Nullable context,\n                                    const char* _Nonnull table,\n                                    void* _Nonnull info,\n                                    WCDBMigrationInfoSetter _Nonnull setter);\nvoid WCDBDatabaseAddMigration(CPPDatabase database,\n                              const char* _Nullable sourcePath,\n                              const unsigned char* _Nullable sourceCipher,\n                              int cipherLength,\n                              WCDBMigrationFilter _Nullable filter,\n                              void* _Nullable context,\n                              WCDBContextDestructor _Nullable destructor);\n\nbool WCDBDatabaseStepMigration(CPPDatabase database);\nvoid WCDBDatabaseEnableAutoMigration(CPPDatabase database, bool flag);\ntypedef void (*WCDBMigrationNotification)(void* _Nullable context,\n                                          CPPDatabase database,\n                                          const char* _Nullable table,\n                                          const char* _Nullable sourceTable);\nvoid WCDBDatabaseSetNotificationWhenMigrated(CPPDatabase database,\n                                             WCDBMigrationNotification _Nullable notification,\n                                             void* _Nullable context,\n\n                                             WCDBContextDestructor _Nullable destructor);\nbool WCDBDatabaseIsMigrated(CPPDatabase database);\n\ntypedef CPPData (*WCDBDataEnumerator)(void* _Nonnull context);\nCPPData WCDBDatabaseTrainDict(unsigned char dictId,\n                              WCDBDataEnumerator _Nonnull dataEnumerator,\n                              void* _Nonnull enumerateContext);\n\nbool WCDBDatabaseRegisterDict(const unsigned char* _Nullable dict, long dictSize, unsigned char dictId);\n\nvoid WCDBDatabaseSetZSTDNormalCompress(void* _Nonnull context, CPPColumn column);\nvoid WCDBDatabaseSetZSTDDictCompress(void* _Nonnull context, CPPColumn column, unsigned char dictid);\nvoid WCDBDatabaseSetZSTDMultiDictCompress(void* _Nonnull context,\n                                          CPPColumn column,\n                                          CPPColumn matchColumn,\n                                          const long long* _Nullable values,\n                                          const unsigned char* _Nullable dictIds,\n                                          int dictCount);\nvoid WCDBDatabaseEnableReplaceCompresssion(void* _Nonnull context);\ntypedef void (*WCDBCompressionFilter)(void* _Nonnull context,\n                                      const char* _Nonnull table,\n                                      void* _Nonnull info);\nvoid WCDBDatabaseSetCompression(CPPDatabase database,\n                                WCDBCompressionFilter _Nullable filter,\n                                void* _Nullable context,\n                                WCDBContextDestructor _Nullable destructor);\nvoid WCDBDatabaseDisableCompressNewData(CPPDatabase database, bool disable);\nbool WCDBDatabaseStepCompression(CPPDatabase database);\nvoid WCDBDatabaseEnableAutoCompression(CPPDatabase database, bool enable);\nbool WCDBDatabaseIsCompressed(CPPDatabase database);\ntypedef void (*WCDBCompressdNotification)(void* _Nonnull context,\n                                          CPPDatabase,\n                                          const char* _Nullable table);\nvoid WCDBDatabaseSetNotificationWhenCompressed(CPPDatabase database,\n                                               WCDBCompressdNotification _Nullable notification,\n                                               void* _Nullable context,\n                                               WCDBContextDestructor _Nullable destructor);\nbool WCDBDatabaseRollbackCompression(CPPDatabase database,\n                                     WCDBProgressUpdate _Nullable monitor,\n                                     void* _Nullable context,\n                                     WCDBContextDestructor _Nullable destructor);\n\nshort WCDBDatabaseGetAliveHandleCount(CPPDatabase database);\n\nWCDB_EXTERN_C_END\n"
  },
  {
    "path": "src/bridge/cppbridge/FTSBridge.cpp",
    "content": "//\n// Created by qiuwenchen on 2022/11/3.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"FTSBridge.h\"\n#include \"Assertion.hpp\"\n#include \"CommonCore.hpp\"\n#include \"CustomConfig.hpp\"\n#include \"FTSConst.h\"\n#include \"InnerDatabase.hpp\"\n#include \"ObjectBridge.hpp\"\n#include \"SQLite.h\"\n#include \"TokenizerModule.hpp\"\n\nWCDBSwiftTokenizerCreate g_swiftTokenizerCreate = nullptr;\nvoid WCDBSwiftSetTokenizerCreateFunction(_Nonnull WCDBSwiftTokenizerCreate func)\n{\n    g_swiftTokenizerCreate = func;\n}\n\nWCDBSwiftTokenizerLoadInput g_swiftTokenizerLoadInput = nullptr;\nvoid WCDBSwiftSetTokenizerLoadInputFunction(_Nonnull WCDBSwiftTokenizerLoadInput func)\n{\n    g_swiftTokenizerLoadInput = func;\n}\n\nWCDBSwiftTokenizerNextToken g_swiftTokenizerNextToken = nullptr;\nvoid WCDBSwiftSetTokenizerNextTokenFunction(_Nonnull WCDBSwiftTokenizerNextToken func)\n{\n    g_swiftTokenizerNextToken = func;\n}\n\nnamespace WCDB {\nclass AbstractSwiftTokenizer : public AbstractFTSTokenizer {\npublic:\n    AbstractSwiftTokenizer(const char* const* azArg, int nArg, void* pCtx)\n    : AbstractFTSTokenizer(azArg, nArg, pCtx), m_swiftTokenizer(nullptr)\n    {\n        WCTAssert(g_swiftTokenizerCreate != nullptr);\n        WCTAssert(g_swiftTokenizerLoadInput != nullptr);\n        WCTAssert(g_swiftTokenizerNextToken != nullptr);\n    }\n\n    ~AbstractSwiftTokenizer()\n    {\n        if (m_swiftTokenizer != nullptr) {\n            WCDBGetReleaseSwiftObjectFunction()(m_swiftTokenizer);\n        }\n    }\n\n    void loadInput(const char* pText, int nText, int flags) override final\n    {\n        if (m_swiftTokenizer) {\n            g_swiftTokenizerLoadInput(m_swiftTokenizer, pText, nText, flags);\n        }\n    }\n\n    int nextToken(const char** ppToken, int* nToken, int* iStart, int* iEnd, int* tflags, int* iPosition) override final\n    {\n        if (!m_swiftTokenizer) {\n            return SQLITE_NOMEM;\n        }\n        return g_swiftTokenizerNextToken(\n        m_swiftTokenizer, ppToken, nToken, iStart, iEnd, tflags, iPosition);\n    }\n\nprotected:\n    SwiftObject* m_swiftTokenizer;\n};\n\ntemplate<uint8_t typeId>\nclass SwiftTokenizer : public AbstractSwiftTokenizer {\n    static_assert(typeId < WCDBMaxSwiftTokenizerTypeId, \"\");\n\npublic:\n    SwiftTokenizer(const char* const* azArg, int nArg, void* pCtx)\n    : AbstractSwiftTokenizer(azArg, nArg, pCtx)\n    {\n        m_swiftTokenizer = (SwiftObject*) g_swiftTokenizerCreate(typeId, nArg, azArg);\n    }\n};\n} // namespace WCDB\n\nconst int WCDBMaxSwiftTokenizerTypeId = 5;\n\nconst int WCDBTokenizerErrorCodeOK = SQLITE_OK;\nconst int WCDBTokenizerErrorCodeDone = SQLITE_DONE;\nconst int WCDBTokenizerErrorCodeNoMemory = SQLITE_NOMEM;\n\nvoid WCDBCoreRegisterFTSTokenizer(const char* _Nullable name, int typeId, enum WCDBFTSVersion version)\n{\n    WCTAssert(version > 2 && version < 6);\n    WCTAssert(name != nullptr);\n    switch (typeId) {\n    case 0: {\n        if (version == WCDBFTSVersion5) {\n            WCDB::CommonCore::shared().registerTokenizer(\n            name, WCDB::FTS5TokenizerModuleTemplate<WCDB::SwiftTokenizer<0>>::specializeWithContext(nullptr));\n        } else {\n            WCDB::CommonCore::shared().registerTokenizer(\n            name, WCDB::FTS3TokenizerModuleTemplate<WCDB::SwiftTokenizer<0>>::specialize());\n        }\n    } break;\n    case 1: {\n        if (version == WCDBFTSVersion5) {\n            WCDB::CommonCore::shared().registerTokenizer(\n            name, WCDB::FTS5TokenizerModuleTemplate<WCDB::SwiftTokenizer<1>>::specializeWithContext(nullptr));\n        } else {\n            WCDB::CommonCore::shared().registerTokenizer(\n            name, WCDB::FTS3TokenizerModuleTemplate<WCDB::SwiftTokenizer<1>>::specialize());\n        }\n    } break;\n    case 2: {\n        if (version == WCDBFTSVersion5) {\n            WCDB::CommonCore::shared().registerTokenizer(\n            name, WCDB::FTS5TokenizerModuleTemplate<WCDB::SwiftTokenizer<2>>::specializeWithContext(nullptr));\n        } else {\n            WCDB::CommonCore::shared().registerTokenizer(\n            name, WCDB::FTS3TokenizerModuleTemplate<WCDB::SwiftTokenizer<2>>::specialize());\n        }\n    } break;\n    case 3: {\n        if (version == WCDBFTSVersion5) {\n            WCDB::CommonCore::shared().registerTokenizer(\n            name, WCDB::FTS5TokenizerModuleTemplate<WCDB::SwiftTokenizer<3>>::specializeWithContext(nullptr));\n        } else {\n            WCDB::CommonCore::shared().registerTokenizer(\n            name, WCDB::FTS3TokenizerModuleTemplate<WCDB::SwiftTokenizer<3>>::specialize());\n        }\n    } break;\n    case 4: {\n        if (version == WCDBFTSVersion5) {\n            WCDB::CommonCore::shared().registerTokenizer(\n            name, WCDB::FTS5TokenizerModuleTemplate<WCDB::SwiftTokenizer<4>>::specializeWithContext(nullptr));\n        } else {\n            WCDB::CommonCore::shared().registerTokenizer(\n            name, WCDB::FTS3TokenizerModuleTemplate<WCDB::SwiftTokenizer<4>>::specialize());\n        }\n    } break;\n    default:\n        WCTAssert(false);\n        break;\n    }\n}\n\nvoid WCDBDatabaseEnableAutoMergeFTS5Index(CPPDatabase database, bool enable)\n{\n    WCDBGetObjectOrReturn(database, WCDB::InnerDatabase, cppDatabase);\n    WCDB::CommonCore::shared().enableAutoMergeFTSIndex(cppDatabase, enable);\n}\n\nconst char* WCDBTokenizerSimpleName()\n{\n    return WCDB::BuiltinTokenizer::Simple;\n}\n\nconst char* WCDBTokenizerPorterName()\n{\n    return WCDB::BuiltinTokenizer::Porter;\n}\n\nconst char* WCDBTokenizerICUName()\n{\n    return WCDB::BuiltinTokenizer::ICU;\n}\n\nconst char* WCDBTokenizerUnicode61Name()\n{\n    return WCDB::BuiltinTokenizer::Unicode61;\n}\n\nconst char* WCDBTokenizerOneOrBinaryName()\n{\n    return WCDB::BuiltinTokenizer::OneOrBinary;\n}\n\nconst char* WCDBTokenizerLegacyOneOrBinaryName()\n{\n    return WCDB::BuiltinTokenizer::LegacyOneOrBinary;\n}\n\nconst char* WCDBTokenizerVerbatimName()\n{\n    return WCDB::BuiltinTokenizer::Verbatim;\n}\n\nconst char* WCDBTokenizerPinyinName()\n{\n    return WCDB::BuiltinTokenizer::Pinyin;\n}\n\nconst char* WCDBTokenizerParameterNeedSymbolName()\n{\n    return WCDB::BuiltinTokenizer::Parameter::NeedSymbol;\n}\n\nconst char* WCDBTokenizerParameterSimplifyChineseName()\n{\n    return WCDB::BuiltinTokenizer::Parameter::SimplifyChinese;\n}\n\nconst char* WCDBTokenizerParameterSkipStemmingName()\n{\n    return WCDB::BuiltinTokenizer::Parameter::SkipStemming;\n}\n\nvoid WCDBDatabaseAddTokenizer(CPPDatabase database, const char* _Nullable tokenizer)\n{\n    if (tokenizer == nullptr) {\n        return;\n    }\n    WCDBGetObjectOrReturn(database, WCDB::InnerDatabase, cppDatabase);\n    WCDB::StringView configName = WCDB::StringView::formatted(\n    \"%s%s\", WCDB::TokenizeConfigPrefix.data(), tokenizer);\n    cppDatabase->setConfig(configName,\n                           WCDB::CommonCore::shared().tokenizerConfig(tokenizer),\n                           WCDB::Configs::Priority::Higher);\n}\n\nconst char* _Nonnull WCDBAuxiliaryFunctionSubstringMatchInfoName()\n{\n    return WCDB::BuiltinAuxiliaryFunction::SubstringMatchInfo;\n}\n\nvoid WCDBDatabaseAddAuxiliaryFunction(CPPDatabase database, const char* _Nullable auxFunction)\n{\n    if (auxFunction == nullptr) {\n        return;\n    }\n    WCDBGetObjectOrReturn(database, WCDB::InnerDatabase, cppDatabase);\n    WCDB::StringView configName = WCDB::StringView::formatted(\n    \"%s%s\", WCDB::AuxiliaryFunctionConfigPrefix.data(), auxFunction);\n    cppDatabase->setConfig(configName,\n                           WCDB::CommonCore::shared().auxiliaryFunctionConfig(auxFunction),\n                           WCDB::Configs::Priority::Higher);\n}\n"
  },
  {
    "path": "src/bridge/cppbridge/FTSBridge.h",
    "content": "//\n// Created by qiuwenchen on 2022/11/3.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n#include \"DatabaseBridge.h\"\n\nWCDB_EXTERN_C_BEGIN\n\ntypedef SwiftObject* _Nullable (*WCDBSwiftTokenizerCreate)(\nint typeId, int argc, const char* _Nonnull const* _Nullable argv);\nvoid WCDBSwiftSetTokenizerCreateFunction(_Nonnull WCDBSwiftTokenizerCreate func);\n\ntypedef void (*WCDBSwiftTokenizerLoadInput)(SwiftObject* _Nonnull obj,\n                                            const char* _Nullable input,\n                                            int length,\n                                            int flags);\nvoid WCDBSwiftSetTokenizerLoadInputFunction(_Nonnull WCDBSwiftTokenizerLoadInput func);\n\ntypedef int (*WCDBSwiftTokenizerNextToken)(SwiftObject* _Nonnull obj,\n                                           const char* _Nullable* _Nonnull ppToken,\n                                           int* _Nonnull nToken,\n                                           int* _Nonnull iStart,\n                                           int* _Nonnull iEnd,\n                                           int* _Nullable tflags,\n                                           int* _Nullable iPosition);\nvoid WCDBSwiftSetTokenizerNextTokenFunction(_Nonnull WCDBSwiftTokenizerNextToken func);\n\nextern const int WCDBTokenizerErrorCodeOK;\nextern const int WCDBTokenizerErrorCodeDone;\nextern const int WCDBTokenizerErrorCodeNoMemory;\n\nextern const int WCDBMaxSwiftTokenizerTypeId;\n\nenum WCDBFTSVersion {\n    WCDBFTSVersion3 = 3,\n    WCDBFTSVersion4 = 4,\n    WCDBFTSVersion5 = 5,\n};\n\nvoid WCDBCoreRegisterFTSTokenizer(const char* _Nullable name, int typeId, enum WCDBFTSVersion ftsVersion);\n\nvoid WCDBDatabaseEnableAutoMergeFTS5Index(CPPDatabase database, bool enable);\n\nconst char* _Nonnull WCDBTokenizerSimpleName();\nconst char* _Nonnull WCDBTokenizerPorterName();\nconst char* _Nonnull WCDBTokenizerICUName();\nconst char* _Nonnull WCDBTokenizerUnicode61Name();\nconst char* _Nonnull WCDBTokenizerOneOrBinaryName();\nconst char* _Nonnull WCDBTokenizerLegacyOneOrBinaryName();\nconst char* _Nonnull WCDBTokenizerVerbatimName();\nconst char* _Nonnull WCDBTokenizerPinyinName();\nconst char* _Nonnull WCDBTokenizerParameterNeedSymbolName();\nconst char* _Nonnull WCDBTokenizerParameterSimplifyChineseName();\nconst char* _Nonnull WCDBTokenizerParameterSkipStemmingName();\nvoid WCDBDatabaseAddTokenizer(CPPDatabase database, const char* _Nullable tokenizer);\n\nconst char* _Nonnull WCDBAuxiliaryFunctionSubstringMatchInfoName();\n\nvoid WCDBDatabaseAddAuxiliaryFunction(CPPDatabase database, const char* _Nullable auxFunction);\n\nWCDB_EXTERN_C_END\n"
  },
  {
    "path": "src/bridge/cppbridge/HandleBridge.cpp",
    "content": "//\n// Created by qiuwenchen on 2022/4/1.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"HandleBridge.h\"\n#include \"InnerHandle.hpp\"\n#include \"ObjectBridge.hpp\"\n#include \"RecyclableHandle.hpp\"\n\nCPPError WCDBHandleGetError(CPPHandle handle)\n{\n    WCDBGetObjectOrReturnValue(handle, WCDB::InnerHandle, cppHandle, CPPError());\n    const WCDB::Error& error = cppHandle->getError();\n    return WCDBCreateUnmanagedCPPObject(CPPError, &error);\n}\n\nbool WCDBHandleCheckValid(CPPHandle handle)\n{\n    WCDBGetObjectOrReturnValue(handle, WCDB::InnerHandle, cppHandle, false);\n    WCDB_UNUSED(cppHandle);\n    return true;\n}\n\nWCDB::HandleStatement* WCDB::GetMainHandleStatement(WCDB::InnerHandle* handle)\n{\n    return static_cast<WCDB::HandleStatement*>(handle->m_mainStatement);\n}\n\nCPPHandleStatement WCDBHandleGetMainStatement(CPPHandle handle)\n{\n    WCDBGetObjectOrReturnValue(handle, WCDB::InnerHandle, cppHandle, CPPHandleStatement());\n    WCDB::HandleStatement* stmt = WCDB::GetMainHandleStatement(cppHandle);\n    return WCDBCreateUnmanagedCPPObject(CPPHandleStatement, stmt);\n}\n\nCPPHandleStatement\nWCDBHandleGetOrCreatePreparedStatement(CPPHandle handle, CPPObject* statement)\n{\n    WCDBGetObjectOrReturnValue(handle, WCDB::InnerHandle, cppHandle, CPPHandleStatement());\n    WCDB::Statement* cppStatement\n    = (WCDB::Statement*) WCDB::ObjectBridge::extractOriginalCPPObject(statement);\n    WCDB::HandleStatement* stmt = cppHandle->getOrCreatePreparedStatement(*cppStatement);\n    return WCDBCreateUnmanagedCPPObject(CPPHandleStatement, stmt);\n}\n\nCPPHandleStatement\nWCDBHandleGetOrCreatePreparedSQL(CPPHandle handle, const char* _Nonnull sql)\n{\n    WCDBGetObjectOrReturnValue(handle, WCDB::InnerHandle, cppHandle, CPPHandleStatement());\n    WCDB::HandleStatement* stmt\n    = cppHandle->getOrCreatePreparedStatement(WCDB::UnsafeStringView(sql));\n    return WCDBCreateUnmanagedCPPObject(CPPHandleStatement, stmt);\n}\n\nCPPHandleStatement\nWCDBHandlePrepareNewStatement(CPPHandle handle, CPPObject* statement)\n{\n    WCDBGetObjectOrReturnValue(handle, WCDB::InnerHandle, cppHandle, CPPHandleStatement());\n    WCDB::Statement* cppStatement\n    = (WCDB::Statement*) WCDB::ObjectBridge::extractOriginalCPPObject(statement);\n    WCDB::HandleStatement* stmt = cppHandle->prepareNewStatement(*cppStatement);\n    return WCDBCreateUnmanagedCPPObject(CPPHandleStatement, stmt);\n}\n\nCPPHandleStatement\nWCDBHandlePrepareNewStatementSQL(CPPHandle handle, const char* _Nonnull sql)\n{\n    WCDBGetObjectOrReturnValue(handle, WCDB::InnerHandle, cppHandle, CPPHandleStatement());\n    WCDB::HandleStatement* stmt\n    = cppHandle->prepareNewStatement(WCDB::UnsafeStringView(sql));\n    return WCDBCreateUnmanagedCPPObject(CPPHandleStatement, stmt);\n}\n\nvoid WCDBHandleFinalizeAndReturnPreparedStatement(CPPHandle handle, CPPHandleStatement stmt)\n{\n    WCDBGetObjectOrReturn(handle, WCDB::InnerHandle, cppHandle);\n    WCDBGetObjectOrReturn(stmt, WCDB::HandleStatement, cppStmt);\n    cppHandle->finalizeAndReturnPreparedStatement(cppStmt);\n}\n\nvoid WCDBHandleFinalizeStatements(CPPHandle handle)\n{\n    WCDBGetObjectOrReturn(handle, WCDB::InnerHandle, cppHandle);\n    cppHandle->finalizeStatements();\n}\n\nbool WCDBHandleExecute(CPPHandle handle, CPPObject* statement)\n{\n    WCDBGetObjectOrReturnValue(handle, WCDB::InnerHandle, cppHandle, false);\n    WCDB::Statement* cppStatement\n    = (WCDB::Statement*) WCDB::ObjectBridge::extractOriginalCPPObject(statement);\n    return cppHandle->execute(*cppStatement);\n}\n\nbool WCDBHandleExecuteSQL(CPPHandle handle, const char* _Nonnull sql)\n{\n    WCDBGetObjectOrReturnValue(handle, WCDB::InnerHandle, cppHandle, false);\n    return cppHandle->execute(WCDB::UnsafeStringView(sql));\n}\n\nOptionalBool WCDBHandleExistTable(CPPHandle handle, const char* _Nonnull tableName)\n{\n    OptionalBool ret = { false, false };\n    WCDBGetObjectOrReturnValue(handle, WCDB::InnerHandle, cppHandle, ret);\n    auto exist = cppHandle->tableExists(WCDB::UnsafeStringView(tableName));\n    if (exist.succeed()) {\n        ret.hasValue = exist.succeed();\n        ret.value = exist.value();\n    }\n    return ret;\n}\n\nint WCDBHandleGetChange(CPPHandle handle)\n{\n    WCDBGetObjectOrReturnValue(handle, WCDB::InnerHandle, cppHandle, 0);\n    return cppHandle->getChanges();\n}\n\nint WCDBHandleGetTotalChange(CPPHandle handle)\n{\n    WCDBGetObjectOrReturnValue(handle, WCDB::InnerHandle, cppHandle, 0);\n    return cppHandle->getTotalChange();\n}\n\nsigned long long WCDBHandleGetLastInsertedRowID(CPPHandle handle)\n{\n    WCDBGetObjectOrReturnValue(handle, WCDB::InnerHandle, cppHandle, 0);\n    return cppHandle->getLastInsertedRowID();\n}\n\nbool WCDBHandleIsReadOnly(CPPHandle handle)\n{\n    WCDBGetObjectOrReturnValue(handle, WCDB::InnerHandle, cppHandle, true);\n    return cppHandle->isReadonly();\n}\n\nbool WCDBHandleIsInTransaction(CPPHandle handle)\n{\n    WCDBGetObjectOrReturnValue(handle, WCDB::InnerHandle, cppHandle, false);\n    return cppHandle->isInTransaction();\n}\n\nbool WCDBHandleBeginTransaction(CPPHandle handle)\n{\n    WCDBGetObjectOrReturnValue(handle, WCDB::InnerHandle, cppHandle, false);\n    return cppHandle->beginTransaction();\n}\n\nbool WCDBHandleCommitTransaction(CPPHandle handle)\n{\n    WCDBGetObjectOrReturnValue(handle, WCDB::InnerHandle, cppHandle, false);\n    return cppHandle->commitOrRollbackTransaction();\n}\n\nvoid WCDBHandleRollbackTransaction(CPPHandle handle)\n{\n    WCDBGetObjectOrReturn(handle, WCDB::InnerHandle, cppHandle);\n    cppHandle->rollbackTransaction();\n}\n\nbool WCDBHandleRunTransaction(CPPHandle handle, void* _Nonnull context, TransactionCallback _Nonnull transaction)\n{\n    WCDBGetObjectOrReturnValue(handle, WCDB::InnerHandle, cppHandle, false);\n    return cppHandle->runTransaction([transaction, context](WCDB::InnerHandle* innerHandle) {\n        CPPHandle bridgeHandle = WCDBCreateUnmanagedCPPObject(CPPHandle, innerHandle);\n        return transaction(context, bridgeHandle);\n    });\n}\n\nbool WCDBHandleRunPausableTransaction(CPPHandle handle,\n                                      void* _Nonnull context,\n                                      PausableTransaction _Nonnull pausableTransaction)\n{\n    WCDBGetObjectOrReturnValue(handle, WCDB::InnerHandle, cppHandle, false);\n    return cppHandle->runPausableTransactionWithOneLoop(\n    [pausableTransaction, context](WCDB::InnerHandle* innerHandle, bool& stop, bool isNewTransaction) {\n        CPPHandle bridgeHandle = WCDBCreateUnmanagedCPPObject(CPPHandle, innerHandle);\n        return pausableTransaction(context, bridgeHandle, &stop, isNewTransaction);\n    });\n}\n\nCPPCancellationSignal WCDBCancellationSignalCreate()\n{\n    return WCDBCreateCPPBridgedObjectWithParameters(\n    CPPCancellationSignal, WCDB::InnerHandle::CancellationSignal, new bool(false));\n}\n\nvoid WCDBCancellationSignalCancel(CPPCancellationSignal signal)\n{\n    WCDBGetObjectOrReturn(signal, WCDB::InnerHandle::CancellationSignal, cppSignal);\n    **cppSignal = true;\n}\n\nvoid WCDBHandleAttachCancellationSignal(CPPHandle handle, CPPCancellationSignal signal)\n{\n    WCDBGetObjectOrReturn(handle, WCDB::InnerHandle, cppHandle);\n    WCDBGetObjectOrReturn(signal, WCDB::InnerHandle::CancellationSignal, cppSignal);\n    cppHandle->attachCancellationSignal(*cppSignal);\n}\n\nvoid WCDBHandleDettachCancellationSignal(CPPHandle handle)\n{\n    WCDBGetObjectOrReturn(handle, WCDB::InnerHandle, cppHandle);\n    cppHandle->detachCancellationSignal();\n}\n"
  },
  {
    "path": "src/bridge/cppbridge/HandleBridge.h",
    "content": "//\n// Created by qiuwenchen on 2022/4/1.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n#include \"ObjectBridge.h\"\n\n#include \"ErrorBridge.h\"\n#include \"HandleStatementBridge.h\"\n#include \"WinqBridge.h\"\n\nWCDB_EXTERN_C_BEGIN\n\nWCDBDefineCPPBridgedType(CPPHandle) WCDBDefineCPPBridgedType(CPPCancellationSignal)\n\nCPPError WCDBHandleGetError(CPPHandle handle);\nbool WCDBHandleCheckValid(CPPHandle handle);\n\nCPPHandleStatement WCDBHandleGetMainStatement(CPPHandle handle);\nCPPHandleStatement\nWCDBHandleGetOrCreatePreparedStatement(CPPHandle handle, CPPObject* _Nonnull statement);\nCPPHandleStatement\nWCDBHandleGetOrCreatePreparedSQL(CPPHandle handle, const char* _Nonnull sql);\nCPPHandleStatement\nWCDBHandlePrepareNewStatement(CPPHandle handle, CPPObject* _Nonnull statement);\nCPPHandleStatement\nWCDBHandlePrepareNewStatementSQL(CPPHandle handle, const char* _Nonnull sql);\nvoid WCDBHandleFinalizeAndReturnPreparedStatement(CPPHandle handle, CPPHandleStatement stmt);\nvoid WCDBHandleFinalizeStatements(CPPHandle handle);\nbool WCDBHandleExecute(CPPHandle handle, CPPObject* _Nonnull statement);\nbool WCDBHandleExecuteSQL(CPPHandle handle, const char* _Nonnull sql);\nOptionalBool WCDBHandleExistTable(CPPHandle handle, const char* _Nonnull tableName);\nint WCDBHandleGetChange(CPPHandle handle);\nint WCDBHandleGetTotalChange(CPPHandle handle);\nsigned long long WCDBHandleGetLastInsertedRowID(CPPHandle handle);\n\nbool WCDBHandleIsInTransaction(CPPHandle handle);\nbool WCDBHandleBeginTransaction(CPPHandle handle);\nbool WCDBHandleCommitTransaction(CPPHandle handle);\nvoid WCDBHandleRollbackTransaction(CPPHandle handle);\n\ntypedef bool (*TransactionCallback)(void* _Nonnull context, CPPHandle handle);\nbool WCDBHandleRunTransaction(CPPHandle handle,\n                              void* _Nonnull context,\n                              TransactionCallback _Nonnull transaction);\ntypedef bool (*PausableTransaction)(void* _Nonnull context, CPPHandle, bool* _Nonnull, bool);\nbool WCDBHandleRunPausableTransaction(CPPHandle handle,\n                                      void* _Nonnull context,\n                                      PausableTransaction _Nonnull pausableTransaction);\n\nCPPCancellationSignal WCDBCancellationSignalCreate();\nvoid WCDBCancellationSignalCancel(CPPCancellationSignal signal);\n\nvoid WCDBHandleAttachCancellationSignal(CPPHandle handle, CPPCancellationSignal signal);\nvoid WCDBHandleDettachCancellationSignal(CPPHandle handle);\n\nWCDB_EXTERN_C_END\n"
  },
  {
    "path": "src/bridge/cppbridge/HandleStatementBridge.cpp",
    "content": "//\n// Created by qiuwenchen on 2022/4/3.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"HandleStatementBridge.h\"\n#include \"AbstractHandle.hpp\"\n#include \"HandleStatement.hpp\"\n#include \"ObjectBridge.hpp\"\n#include \"UnsafeData.hpp\"\n\nCPPError WCDBHandleStatementGetError(CPPHandleStatement handleStatement)\n{\n    WCDBGetObjectOrReturnValue(\n    handleStatement, WCDB::HandleStatement, cppHandleStatement, CPPError());\n    WCDB::AbstractHandle* cppHandle = cppHandleStatement->getHandle();\n    if (!cppHandle) {\n        return CPPError();\n    }\n    const WCDB::Error& error = cppHandle->getError();\n    return WCDBCreateUnmanagedCPPObject(CPPError, &error);\n}\n\nbool WCDBHandleStatementPrepare(CPPHandleStatement handleStatement, CPPObject* statement)\n{\n    WCDBGetObjectOrReturnValue(\n    handleStatement, WCDB::HandleStatement, cppHandleStatement, false);\n    WCDB::Statement* cppStatement\n    = (WCDB::Statement*) WCDB::ObjectBridge::extractOriginalCPPObject(statement);\n    return cppHandleStatement->prepare(*cppStatement);\n}\n\nbool WCDBHandleStatementPrepareSQL(CPPHandleStatement handleStatement, const char* _Nonnull sql)\n{\n    WCDBGetObjectOrReturnValue(\n    handleStatement, WCDB::HandleStatement, cppHandleStatement, false);\n    return cppHandleStatement->prepareSQL(WCDB::UnsafeStringView(sql));\n}\n\nbool WCDBHandleStatementCheckPrepared(CPPHandleStatement handleStatement)\n{\n    WCDBGetObjectOrReturnValue(\n    handleStatement, WCDB::HandleStatement, cppHandleStatement, false);\n    return cppHandleStatement->isPrepared();\n}\n\nbool WCDBHandleStatementStep(CPPHandleStatement handleStatement)\n{\n    WCDBGetObjectOrReturnValue(\n    handleStatement, WCDB::HandleStatement, cppHandleStatement, false);\n    return cppHandleStatement->step();\n}\n\nvoid WCDBHandleStatementReset(CPPHandleStatement handleStatement)\n{\n    WCDBGetObjectOrReturn(handleStatement, WCDB::HandleStatement, cppHandleStatement);\n    cppHandleStatement->reset();\n}\n\nvoid WCDBHandleStatementClearBindings(CPPHandleStatement handleStatement)\n{\n    WCDBGetObjectOrReturn(handleStatement, WCDB::HandleStatement, cppHandleStatement);\n    cppHandleStatement->clearBindings();\n}\n\nvoid WCDBHandleStatementFinalize(CPPHandleStatement handleStatement)\n{\n    WCDBGetObjectOrReturn(handleStatement, WCDB::HandleStatement, cppHandleStatement);\n    cppHandleStatement->finalize();\n}\n\nbool WCDBHandleStatementIsDone(CPPHandleStatement handleStatement)\n{\n    WCDBGetObjectOrReturnValue(\n    handleStatement, WCDB::HandleStatement, cppHandleStatement, true);\n    return cppHandleStatement->done();\n}\n\nvoid WCDBHandleStatementBindInteger(CPPHandleStatement handleStatement,\n                                    int index,\n                                    signed long long intValue)\n{\n    WCDBGetObjectOrReturn(handleStatement, WCDB::HandleStatement, cppHandleStatement);\n    cppHandleStatement->bindInteger(intValue, index);\n}\n\nvoid WCDBHandleStatementBindDouble(CPPHandleStatement handleStatement, int index, double doubleValue)\n{\n    WCDBGetObjectOrReturn(handleStatement, WCDB::HandleStatement, cppHandleStatement);\n    cppHandleStatement->bindDouble(doubleValue, index);\n}\n\nvoid WCDBHandleStatementBindText(CPPHandleStatement handleStatement, int index, const char* _Nonnull text)\n{\n    WCDBGetObjectOrReturn(handleStatement, WCDB::HandleStatement, cppHandleStatement);\n    cppHandleStatement->bindText(WCDB::UnsafeStringView(text), index);\n}\n\nvoid WCDBHandleStatementBindText16(CPPHandleStatement handleStatement,\n                                   int index,\n                                   const short* _Nullable text,\n                                   int textLength)\n{\n    WCDBGetObjectOrReturn(handleStatement, WCDB::HandleStatement, cppHandleStatement);\n    cppHandleStatement->bindText16((const char16_t*) text, textLength, index);\n}\n\nvoid WCDBHandleStatementBindBlob(CPPHandleStatement handleStatement,\n                                 int index,\n                                 const unsigned char* _Nonnull buffer,\n                                 unsigned long long buffLength)\n{\n    WCDBGetObjectOrReturn(handleStatement, WCDB::HandleStatement, cppHandleStatement);\n    cppHandleStatement->bindBLOB(\n    WCDB::UnsafeData::immutable(buffer, (size_t) buffLength), index);\n}\n\nvoid WCDBHandleStatementBindNull(CPPHandleStatement handleStatement, int index)\n{\n    WCDBGetObjectOrReturn(handleStatement, WCDB::HandleStatement, cppHandleStatement);\n    cppHandleStatement->bindNull(index);\n}\n\nint WCDBHandleStatementBindParameterIndex(CPPHandleStatement handleStatement,\n                                          const char* parameterName)\n{\n    WCDBGetObjectOrReturnValue(\n    handleStatement, WCDB::HandleStatement, cppHandleStatement, 0);\n    return cppHandleStatement->bindParameterIndex(parameterName);\n}\n\nWCDBColumnValueType\nWCDBHandleStatementGetColumnType(CPPHandleStatement handleStatement, int index)\n{\n    WCDBGetObjectOrReturnValue(\n    handleStatement, WCDB::HandleStatement, cppHandleStatement, WCDBColumnValueTypeNull);\n    switch (cppHandleStatement->getType(index)) {\n    case WCDB::Syntax::ColumnType::Integer:\n        return WCDBColumnValueTypeInterger;\n    case WCDB::Syntax::ColumnType::Float:\n        return WCDBColumnValueTypeFloat;\n    case WCDB::Syntax::ColumnType::BLOB:\n        return WCDBColumnValueTypeBLOB;\n    case WCDB::Syntax::ColumnType::Text:\n        return WCDBColumnValueTypeString;\n    case WCDB::Syntax::ColumnType::Null:\n        return WCDBColumnValueTypeNull;\n    }\n}\n\nsigned long long WCDBHandleStatementGetInteger(CPPHandleStatement handleStatement, int index)\n{\n    WCDBGetObjectOrReturnValue(\n    handleStatement, WCDB::HandleStatement, cppHandleStatement, 0);\n    return cppHandleStatement->getInteger(index);\n}\n\ndouble WCDBHandleStatementGetDouble(CPPHandleStatement handleStatement, int index)\n{\n    WCDBGetObjectOrReturnValue(\n    handleStatement, WCDB::HandleStatement, cppHandleStatement, 0);\n    return cppHandleStatement->getDouble(index);\n}\n\nconst char* _Nullable WCDBHandleStatementGetText(CPPHandleStatement handleStatement, int index)\n{\n    WCDBGetObjectOrReturnValue(\n    handleStatement, WCDB::HandleStatement, cppHandleStatement, nullptr);\n    return cppHandleStatement->getText(index).data();\n}\n\nconst short* _Nullable WCDBHandleStatementGetText16(CPPHandleStatement handleStatement, int index)\n{\n    WCDBGetObjectOrReturnValue(\n    handleStatement, WCDB::HandleStatement, cppHandleStatement, nullptr);\n    return (const short*) cppHandleStatement->getText16(index);\n}\n\nint WCDBHandleStatementGetText16Length(CPPHandleStatement handleStatement, int index)\n{\n    WCDBGetObjectOrReturnValue(\n    handleStatement, WCDB::HandleStatement, cppHandleStatement, 0);\n    return (int) cppHandleStatement->getText16Length(index);\n}\n\nconst unsigned char*\nWCDBHandleStatementGetBlob(CPPHandleStatement handleStatement, int index)\n{\n    WCDBGetObjectOrReturnValue(\n    handleStatement, WCDB::HandleStatement, cppHandleStatement, nullptr);\n    return cppHandleStatement->getBLOB(index).buffer();\n}\n\nsigned long long\nWCDBHandleStatementGetColumnSize(CPPHandleStatement handleStatement, int index)\n{\n    WCDBGetObjectOrReturnValue(\n    handleStatement, WCDB::HandleStatement, cppHandleStatement, 0);\n    return cppHandleStatement->getColumnSize(index);\n}\n\nint WCDBHandleStatementGetColumnCount(CPPHandleStatement handleStatement)\n{\n    WCDBGetObjectOrReturnValue(\n    handleStatement, WCDB::HandleStatement, cppHandleStatement, 0);\n    return cppHandleStatement->getNumberOfColumns();\n}\n\nconst char* _Nullable WCDBHandleStatementGetColumnName(CPPHandleStatement handleStatement, int index)\n{\n    WCDBGetObjectOrReturnValue(\n    handleStatement, WCDB::HandleStatement, cppHandleStatement, nullptr);\n    return cppHandleStatement->getColumnName(index).data();\n}\n\nconst char* _Nullable WCDBHandleStatementGetOriginalColumnName(CPPHandleStatement handleStatement,\n                                                               int index)\n{\n    WCDBGetObjectOrReturnValue(\n    handleStatement, WCDB::HandleStatement, cppHandleStatement, nullptr);\n    return cppHandleStatement->getOriginColumnName(index).data();\n}\n\nconst char* _Nullable WCDBHandleStatementGetColumnTableName(CPPHandleStatement handleStatement,\n                                                            int index)\n{\n    WCDBGetObjectOrReturnValue(\n    handleStatement, WCDB::HandleStatement, cppHandleStatement, nullptr);\n    return cppHandleStatement->getColumnTableName(index).data();\n}\n\nbool WCDBHandleStatementIsReadOnly(CPPHandleStatement handleStatement)\n{\n    WCDBGetObjectOrReturnValue(\n    handleStatement, WCDB::HandleStatement, cppHandleStatement, false);\n    return cppHandleStatement->isReadOnly();\n}\n"
  },
  {
    "path": "src/bridge/cppbridge/HandleStatementBridge.h",
    "content": "//\n// Created by qiuwenchen on 2022/4/3.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n#include \"ErrorBridge.h\"\n#include \"ObjectBridge.h\"\n#include \"WinqBridge.h\"\n\nWCDB_EXTERN_C_BEGIN\n\nWCDBDefineCPPBridgedType(CPPHandleStatement)\n\nenum WCDBColumnValueType {\n    WCDBColumnValueTypeInterger = 1,\n    WCDBColumnValueTypeFloat,\n    WCDBColumnValueTypeString,\n    WCDBColumnValueTypeBLOB,\n    WCDBColumnValueTypeNull,\n};\n\nCPPError WCDBHandleStatementGetError(CPPHandleStatement handleStatement);\n\nbool WCDBHandleStatementPrepare(CPPHandleStatement handleStatement,\n                                CPPObject* _Nonnull statement);\nbool WCDBHandleStatementPrepareSQL(CPPHandleStatement handleStatement,\n                                   const char* _Nonnull sql);\nbool WCDBHandleStatementCheckPrepared(CPPHandleStatement handleStatement);\nbool WCDBHandleStatementStep(CPPHandleStatement handleStatement);\nvoid WCDBHandleStatementReset(CPPHandleStatement handleStatement);\nvoid WCDBHandleStatementClearBindings(CPPHandleStatement handleStatement);\nvoid WCDBHandleStatementFinalize(CPPHandleStatement handleStatement);\nbool WCDBHandleStatementIsDone(CPPHandleStatement handleStatement);\n\nvoid WCDBHandleStatementBindInteger(CPPHandleStatement handleStatement,\n                                    int index,\n                                    signed long long intValue);\nvoid WCDBHandleStatementBindDouble(CPPHandleStatement handleStatement, int index, double doubleValue);\nvoid WCDBHandleStatementBindText(CPPHandleStatement handleStatement,\n                                 int index,\n                                 const char* _Nonnull text);\nvoid WCDBHandleStatementBindText16(CPPHandleStatement handleStatement,\n                                   int index,\n                                   const short* _Nullable text,\n                                   int textLength);\nvoid WCDBHandleStatementBindBlob(CPPHandleStatement handleStatement,\n                                 int index,\n                                 const unsigned char* _Nonnull buffer,\n                                 unsigned long long buffLength);\nvoid WCDBHandleStatementBindNull(CPPHandleStatement handleStatement, int index);\n\nint WCDBHandleStatementBindParameterIndex(CPPHandleStatement handleStatement,\n                                          const char* _Nullable parameterName);\n\nenum WCDBColumnValueType\nWCDBHandleStatementGetColumnType(CPPHandleStatement handleStatement, int index);\nsigned long long\nWCDBHandleStatementGetInteger(CPPHandleStatement handleStatement, int index);\ndouble WCDBHandleStatementGetDouble(CPPHandleStatement handleStatement, int index);\nconst char* _Nullable WCDBHandleStatementGetText(CPPHandleStatement handleStatement, int index);\nconst short* _Nullable WCDBHandleStatementGetText16(CPPHandleStatement handleStatement,\n                                                    int index);\nint WCDBHandleStatementGetText16Length(CPPHandleStatement handleStatement, int index);\nconst unsigned char* _Nullable WCDBHandleStatementGetBlob(CPPHandleStatement handleStatement,\n                                                          int index);\nsigned long long\nWCDBHandleStatementGetColumnSize(CPPHandleStatement handleStatement, int index);\n\nint WCDBHandleStatementGetColumnCount(CPPHandleStatement handleStatement);\nconst char* _Nullable WCDBHandleStatementGetColumnName(CPPHandleStatement handleStatement,\n                                                       int index);\nconst char* _Nullable WCDBHandleStatementGetOriginalColumnName(CPPHandleStatement handleStatement,\n                                                               int index);\nconst char* _Nullable WCDBHandleStatementGetColumnTableName(CPPHandleStatement handleStatement,\n                                                            int index);\n\nbool WCDBHandleStatementIsReadOnly(CPPHandleStatement handleStatement);\n\nWCDB_EXTERN_C_END\n"
  },
  {
    "path": "src/bridge/module.modulemap",
    "content": "module WCDB_Private {\n    requires objc\n    umbrella header \"WCDBBridging.h\"\n    export *\n}\n"
  },
  {
    "path": "src/bridge/objcbridge/WCTAPIBridge.h",
    "content": "//\n// Created by qiuwenchen on 2022/4/22.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"HandleBridge.h\"\n#import <Foundation/Foundation.h>\n\nNS_ASSUME_NONNULL_BEGIN\n\n@protocol WCTTableCoding;\ntypedef NSObject<WCTTableCoding> WCTObject;\ntypedef NSDictionary<NSString * /*table name */, WCTObject *> WCTMultiObject;\n@class WCTBridgeProperty;\ntypedef NSArray<WCTBridgeProperty *> WCTBridgeProperties;\n\n@interface WCTAPIBridge : NSObject\n\n#ifdef WCDB_SWIFT_BRIDGE_OBJC\n+ (BOOL)createTable:(NSString *)name\n          withClass:(Class<WCTTableCoding>)tableClass\n         withHandle:(CPPHandle)handle;\n\n+ (BOOL)createVirtualTable:(NSString *)name\n                 withClass:(Class<WCTTableCoding>)tableClass\n                withHandle:(CPPHandle)handle;\n\n+ (BOOL)insertObjects:(NSArray<WCTObject *> *)objects\n            intoTable:(NSString *)name\n       withProperties:(WCTBridgeProperties *_Nullable)properties\n            orReplace:(BOOL)replace\n             orIgnore:(BOOL)ignore\n           withHandle:(CPPHandle)handle;\n\n+ (void)bindProperties:(WCTBridgeProperties *)properties\n              ofObject:(WCTObject *)object\n   withHandleStatement:(CPPHandleStatement)handleStatement;\n\n+ (void)bindProperty:(WCTBridgeProperty *)property\n            ofObject:(WCTObject *)object\n             toIndex:(int)index\n withHandleStatement:(CPPHandleStatement)handleStatement;\n\n+ (nullable WCTObject *)extractObjectOnResultColumns:(WCTBridgeProperties *)properties\n                                 fromHandleStatement:(CPPHandleStatement)handleStatement;\n\n+ (nullable WCTMultiObject *)extractMultiObjectOnResultColumns:(WCTBridgeProperties *)properties\n                                           fromHandleStatement:(CPPHandleStatement)handleStatement;\n#endif\n\n+ (void)configDefaultSymbolDetectorAndUnicodeNormalizer;\n\n+ (void)configPinyinDict:(NSDictionary<NSString *, NSArray<NSString *> *> *)pinyinDict;\n\n+ (void)configTraditionalChineseDict:(NSDictionary<NSString *, NSString *> *)traditionalChineseDict;\n\n@end\n\nNS_ASSUME_NONNULL_END\n"
  },
  {
    "path": "src/bridge/objcbridge/WCTAPIBridge.mm",
    "content": "//\n// Created by qiuwenchen on 2022/4/22.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"WCTAPIBridge.h\"\n#import \"HandleStatement.hpp\"\n#import \"ObjectBridge.hpp\"\n#import \"WCTFTSTokenizerUtil.h\"\n#import <Foundation/Foundation.h>\n#ifdef WCDB_SWIFT_BRIDGE_OBJC\n#import \"WCTBridgeProperty+CPP.h\"\n#import \"WCTDeclaration.h\"\n#import \"WCTHandle+ChainCall.h\"\n#import \"WCTHandle+Private.h\"\n#import \"WCTHandle+Table.h\"\n#import \"WCTInsert.h\"\n#import \"WCTPreparedStatement+Private.h\"\n#import \"WCTResultColumn.h\"\n#import \"WCTTableCoding.h\"\n#endif\n\n@implementation WCTAPIBridge\n\n#ifdef WCDB_SWIFT_BRIDGE_OBJC\n\n+ (BOOL)createTable:(NSString*)name\n          withClass:(Class)tableClass\n         withHandle:(CPPHandle)handle\n{\n    WCDBGetObjectOrReturnValue(handle, WCDB::InnerHandle, cppHandle, NO);\n    WCTHandle* wctHandle = [[WCTHandle alloc] initWithUnsafeHandle:cppHandle];\n    return [wctHandle createTable:name withClass:tableClass];\n}\n\n+ (BOOL)createVirtualTable:(NSString*)name\n                 withClass:(Class)tableClass\n                withHandle:(CPPHandle)handle\n{\n    WCDBGetObjectOrReturnValue(handle, WCDB::InnerHandle, cppHandle, NO);\n    WCTHandle* wctHandle = [[WCTHandle alloc] initWithUnsafeHandle:cppHandle];\n    return [wctHandle createVirtualTable:name withClass:tableClass];\n}\n\n+ (BOOL)insertObjects:(NSArray<WCTObject*>*)objects\n            intoTable:(NSString*)name\n       withProperties:(WCTBridgeProperties*)properties\n            orReplace:(BOOL)replace\n             orIgnore:(BOOL)ignore\n           withHandle:(CPPHandle)handle\n{\n    if (objects.count == 0) {\n        return YES;\n    }\n    WCDBGetObjectOrReturnValue(handle, WCDB::InnerHandle, cppHandle, NO);\n    WCTHandle* wctHandle = [[WCTHandle alloc] initWithUnsafeHandle:cppHandle];\n    WCTProperties wctProperties;\n    if (properties.count > 0) {\n        for (WCTBridgeProperty* property in properties) {\n            wctProperties.push_back(property.wctProperty);\n        }\n    } else {\n        wctProperties = [objects.firstObject.class allProperties];\n    }\n    WCTInsert* insert = [wctHandle prepareInsert];\n    [[[insert values:objects] intoTable:name] onProperties:wctProperties];\n    if (replace) {\n        [insert orReplace];\n    } else if (ignore) {\n        [insert orIgnore];\n    }\n    return [insert execute];\n}\n\n+ (void)bindProperties:(WCTBridgeProperties*)properties\n              ofObject:(WCTObject*)object\n   withHandleStatement:(CPPHandleStatement)handleStatement\n{\n    WCDBGetObjectOrReturn(handleStatement, WCDB::HandleStatement, cppHandleStatement);\n    WCTPreparedStatement* wctHandleStatement = [[WCTPreparedStatement alloc] initWithHandleStatement:cppHandleStatement];\n    WCTProperties wctProperties;\n    for (WCTBridgeProperty* bridgeProperty in properties) {\n        wctProperties.push_back(bridgeProperty.wctProperty);\n    }\n    [wctHandleStatement bindProperties:wctProperties ofObject:object];\n}\n\n+ (void)bindProperty:(WCTBridgeProperty*)property\n            ofObject:(WCTObject*)object\n             toIndex:(int)index\n withHandleStatement:(CPPHandleStatement)handleStatement\n{\n    WCDBGetObjectOrReturn(handleStatement, WCDB::HandleStatement, cppHandleStatement);\n    WCTPreparedStatement* wctHandleStatement = [[WCTPreparedStatement alloc] initWithHandleStatement:cppHandleStatement];\n    [wctHandleStatement bindProperty:property.wctProperty ofObject:object toIndex:index];\n}\n\n+ (WCTObject*)extractObjectOnResultColumns:(WCTBridgeProperties*)properties\n                       fromHandleStatement:(CPPHandleStatement)handleStatement\n{\n    WCDBGetObjectOrReturnValue(handleStatement, WCDB::HandleStatement, cppHandleStatement, nil);\n    WCTPreparedStatement* wctHandleStatement = [[WCTPreparedStatement alloc] initWithHandleStatement:cppHandleStatement];\n    WCTResultColumns resultColumns;\n    for (WCTBridgeProperty* bridgeProperty in properties) {\n        resultColumns.emplace_back(bridgeProperty.wctProperty);\n    }\n    return [wctHandleStatement extractObjectOnResultColumns:resultColumns];\n}\n\n+ (WCTMultiObject*)extractMultiObjectOnResultColumns:(WCTBridgeProperties*)properties\n                                 fromHandleStatement:(CPPHandleStatement)handleStatement\n{\n    WCDBGetObjectOrReturnValue(handleStatement, WCDB::HandleStatement, cppHandleStatement, nil);\n    WCTPreparedStatement* wctHandleStatement = [[WCTPreparedStatement alloc] initWithHandleStatement:cppHandleStatement];\n    WCTResultColumns resultColumns;\n    for (WCTBridgeProperty* bridgeProperty in properties) {\n        resultColumns.emplace_back(bridgeProperty.wctProperty);\n    }\n    return [wctHandleStatement extractMultiObjectOnResultColumns:resultColumns];\n}\n\n#endif\n\n+ (void)configDefaultSymbolDetectorAndUnicodeNormalizer\n{\n    WCTFTSTokenizerUtil::configDefaultSymbolDetectorAndUnicodeNormalizer();\n}\n\n+ (void)configPinyinDict:(NSDictionary<NSString*, NSArray<NSString*>*>*)pinyinDict\n{\n    WCTFTSTokenizerUtil::configPinyinDict(pinyinDict);\n}\n\n+ (void)configTraditionalChineseDict:(NSDictionary<NSString*, NSString*>*)traditionalChineseDict\n{\n    WCTFTSTokenizerUtil::configTraditionalChineseDict(traditionalChineseDict);\n}\n\n@end\n"
  },
  {
    "path": "src/bridge/objcbridge/WCTBridgeMacro.h",
    "content": "//\n// Created by qiuwenchen on 2022/11/14.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#define WCDB_SWIFT 1\n"
  },
  {
    "path": "src/bridge/tests/common/Assert.swift",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport XCTest\nimport WCDB\n\nfunc XCTAssertEqual(_ expression1: @autoclosure () -> String,\n                    _ expression2: @autoclosure () -> String,\n                    file: StaticString = #file,\n                    line: UInt = #line) {\n    let description1 = expression1()\n    let description2 = expression2()\n    XCTAssertEqual(description1, description2, {\n        return \"different from \\\"\\(description1.commonPrefix(with: description2))\\\"\"\n    }(), file: file, line: line)\n}\n\nfunc WINQAssertEqual<DescribableObject1, DescribableObject2>(\n    _ expression1: @autoclosure () -> DescribableObject1,\n    _ expression2: @autoclosure () -> DescribableObject2,\n    file: StaticString = #file,\n    line: UInt = #line)\n    where DescribableObject1: CustomStringConvertible, DescribableObject2: CustomStringConvertible {\n    XCTAssertEqual(expression1().description, expression2().description, file: file, line: line)\n}\n\nfunc WINQExpressionAssertEqual(\n    _ expression: @autoclosure () -> WCDB.Expression,\n    _ description: @autoclosure () -> String,\n    file: StaticString = #file,\n    line: UInt = #line) {\n    XCTAssertEqual(expression().description, description(), file: file, line: line)\n}\n\nfunc WCDBAssertNoThrowReturned<T>(_ expression: @autoclosure () throws -> T,\n                                  file: StaticString = #file,\n                                  line: UInt = #line,\n                                  whenFailed failedValue: @autoclosure () -> T) -> T {\n    do {\n        return try expression()\n    } catch let error as WCDB.WCDBError {\n        XCTFail(error.description)\n    } catch {\n        XCTFail(error.localizedDescription)\n    }\n    return failedValue()\n}\n\nfunc WCDBAssertNoThrowReturned<T>(_ expression: @autoclosure () throws -> T,\n                                  file: StaticString = #file,\n                                  line: UInt = #line) -> T? {\n    do {\n        return try expression()\n    } catch let error as WCDB.WCDBError {\n        XCTFail(error.description)\n    } catch {\n        XCTFail(error.localizedDescription)\n    }\n    return nil\n}\n\nfunc WCDBAssertNoThrowReturned<T: OptionalRepresentable>(\n    _ expression: @autoclosure () throws -> T,\n    file: StaticString = #file,\n    line: UInt = #line) -> T {\n    return WCDBAssertNoThrowReturned(try expression(), file: file, line: line, whenFailed: T.`nil`)\n}\n\nprotocol ArrayRepresentable {\n    associatedtype ElementType\n    init()\n}\n\nextension Array: ArrayRepresentable {\n    typealias ElementType = Element\n}\n\nfunc WCDBAssertNoThrowReturned<T: ArrayRepresentable>(\n    _ expression: @autoclosure () throws -> T,\n    file: StaticString = #file,\n    line: UInt = #line) -> T {\n    return WCDBAssertNoThrowReturned(try expression(), file: file, line: line, whenFailed: T())\n}\n"
  },
  {
    "path": "src/bridge/tests/common/BaseTestCase.swift",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport XCTest\nimport WCDB\n\nclass BaseTestCase: XCTestCase, Named {\n    static let baseDirectory: URL = {\n        var url = URL(fileURLWithPath: NSTemporaryDirectory())\n        url.appendPathComponent(String(describing: BaseTestCase.self))\n        return url\n    }()\n\n    lazy var recommendedDirectory: URL = {\n        var url = BaseTestCase.baseDirectory\n        url.appendPathComponent(self.className)\n        return url\n    }()\n\n    lazy var recommendedPath: URL = {\n        var url = recommendedDirectory\n        url.appendPathComponent(String(UInt(bitPattern: self.name.hash)))\n        return url\n    }()\n\n    lazy var recommendTag: Tag = recommendedPath.hashValue\n\n    let fileManager = FileManager.default\n\n    override func setUp() {\n        super.setUp()\n        self.continueAfterFailure = false\n\n        if fileManager.fileExists(atPath: recommendedDirectory.path) {\n            XCTAssertNoThrow(try fileManager.removeItem(at: recommendedDirectory))\n        }\n        XCTAssertNoThrow(try fileManager.createDirectory(at: recommendedDirectory,\n                                                         withIntermediateDirectories: true,\n                                                         attributes: nil))\n    }\n}\n"
  },
  {
    "path": "src/bridge/tests/common/Convenience.swift",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport Foundation\n\nprotocol Named {\n    static var name: String {get}\n    var className: String {get}\n}\n\nextension Named {\n    static var name: String {\n        return String(describing: Self.self)\n    }\n    var className: String {\n        return Self.name\n    }\n}\n\nextension URL {\n    func urlByAppendingPathComponent(_ pathComponent: String) -> URL {\n        var url = self\n        url.appendPathComponent(pathComponent)\n        return url\n    }\n}\n"
  },
  {
    "path": "src/bridge/tests/common/SwiftBridgeObjcTest-Bridging-Header.h",
    "content": "//\n//  Use this file to import your target's public headers that you would like to expose to Swift.\n//\n\n#import \"AutoAddColumnObject.h\"\n#import \"CRUDObject.h\"\n"
  },
  {
    "path": "src/bridge/tests/crud/AdvanceCRUDTests.swift",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport XCTest\nimport WCDB\n\nclass AdvanceCRUDTests: CRUDTestCase {\n\n    func testSubthreadCheckpoint() {\n        // Give\n        let fileManager = self.fileManager\n        let walFile = database.path+\"-wal\"\n        let object = CRUDObject()\n        object.variable2 = \"testSubthreadCheckpoint\"\n        object.isAutoIncrement = true\n        // When\n        for _ in 0..<1000 {\n            XCTAssertNoThrow(try database.insert(object, intoTable: CRUDObject.name))\n        }\n        var expectedSize: Int64!\n        do {\n            let walSize = WCDBAssertNoThrowReturned(try fileManager.attributesOfItem(atPath: walFile)[.size])\n            XCTAssertNotNil(walSize)\n            let typedWalSize = walSize! as? Int64\n            XCTAssertNotNil(typedWalSize)\n            XCTAssertGreaterThan(typedWalSize!, 0)\n            expectedSize = typedWalSize!\n        }\n        sleep(5)\n        // Then\n        do {\n            let walSize = WCDBAssertNoThrowReturned(try fileManager.attributesOfItem(atPath: walFile)[.size])\n            XCTAssertNotNil(walSize)\n            let typedWalSize = walSize! as? Int64\n            XCTAssertNotNil(typedWalSize)\n            XCTAssertEqual(typedWalSize!, expectedSize)\n        }\n    }\n\n    struct EncodableColumn: ColumnEncodable {\n        static var columnType: ColumnType {\n            return .integer64\n        }\n\n        func archivedValue() -> Value {\n            return Value(Int64(variable1))\n        }\n\n        var variable1: Int = 0\n    }\n\n    struct DecodableColumn: ColumnDecodable {\n        static var columnType: ColumnType {\n            return .integer64\n        }\n\n        init?(with value: Value) {\n            variable1 = Int(truncatingIfNeeded: value.int64Value)\n        }\n\n        init() {}\n\n        var variable1: Int = 0\n    }\n\n    final class EncodableObject: TableEncodable {\n        var variable1: EncodableColumn = EncodableColumn()\n        enum CodingKeys: String, CodingTableKey {\n            typealias Root = EncodableObject\n            case variable1\n            nonisolated(unsafe) static let objectRelationalMapping = TableBinding(CodingKeys.self)\n        }\n    }\n\n    final class DecodableObject: TableDecodable {\n        var variable1: DecodableColumn = DecodableColumn()\n\n        enum CodingKeys: String, CodingTableKey {\n            typealias Root = DecodableObject\n            case variable1\n            nonisolated(unsafe) static let objectRelationalMapping = TableBinding(CodingKeys.self)\n        }\n    }\n\n    func testPartialCodable() {\n        let tableName = \"testPartialCodable\"\n        XCTAssertNoThrow(try database.create(table: tableName,\n                                             of: DecodableObject.self))\n\n        let object = EncodableObject()\n        XCTAssertNoThrow(try database.insert(object,\n                                             intoTable: tableName))\n\n        let decodableObject: DecodableObject? = WCDBAssertNoThrowReturned(\n            try database.getObject(fromTable: tableName)\n        )\n        XCTAssertNotNil(decodableObject)\n        XCTAssertEqual(decodableObject!.variable1.variable1, object.variable1.variable1)\n    }\n}\n"
  },
  {
    "path": "src/bridge/tests/crud/AutoAddColumnObject.h",
    "content": "//\n// Created by qiuwenchen on 2022/12/6.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import <Foundation/Foundation.h>\n#if TEST_WCDB_OBJC\n#import <WCDBOBjc/WCTMacro.h>\n#elif TEST_WCDB_CPP\n#import <WCDBCpp/WCTMacro.h>\n#else\n#import <WCDB/WCTMacro.h>\n#endif\n#if TEST_WCDB_OBJC\n#import <WCDBOBjc/WCTTableCoding.h>\n#elif TEST_WCDB_CPP\n#import <WCDBCpp/WCTTableCoding.h>\n#else\n#import <WCDB/WCTTableCoding.h>\n#endif\n\n@interface AutoAddColumnObject : NSObject <WCTTableCoding>\n\n@property (nonatomic, assign) int primaryValue;\n@property (nonatomic, assign) int uniqueValue;\n@property (nonatomic, assign) int insertValue;\n@property (nonatomic, assign) int updateValue;\n@property (nonatomic, assign) int selectValue;\n@property (nonatomic, assign) int multiSelectValue;\n@property (nonatomic, assign) int deleteValue;\n@property (nonatomic, assign) int indexValue;\n\nWCDB_PROPERTY(primaryValue)\nWCDB_PROPERTY(uniqueValue)\nWCDB_PROPERTY(insertValue)\nWCDB_PROPERTY(updateValue)\nWCDB_PROPERTY(selectValue)\nWCDB_PROPERTY(multiSelectValue)\nWCDB_PROPERTY(deleteValue)\n\n@end\n"
  },
  {
    "path": "src/bridge/tests/crud/AutoAddColumnObject.mm",
    "content": "//\n// Created by qiuwenchen on 2022/12/6.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"AutoAddColumnObject.h\"\n#import <Foundation/Foundation.h>\n#if TEST_WCDB_OBJC\n#import <WCDBOBjc/WCDB.h>\n#elif TEST_WCDB_CPP\n#import <WCDBCpp/WCDB.h>\n#else\n#import <WCDB/WCDB.h>\n#endif\n\n@implementation AutoAddColumnObject\n\nWCDB_IMPLEMENTATION(AutoAddColumnObject)\nWCDB_SYNTHESIZE(primaryValue)\nWCDB_SYNTHESIZE(uniqueValue)\nWCDB_SYNTHESIZE(insertValue)\nWCDB_SYNTHESIZE(updateValue)\nWCDB_SYNTHESIZE(selectValue)\nWCDB_SYNTHESIZE(multiSelectValue)\nWCDB_SYNTHESIZE(deleteValue)\n\nWCDB_PRIMARY(primaryValue)\nWCDB_UNIQUE(uniqueValue)\n\n@end\n"
  },
  {
    "path": "src/bridge/tests/crud/AutoAddColumnTests.swift",
    "content": "//\n// Created by qiuwenchen on 2022/12/6.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport XCTest\nimport WCDB\n\nclass AutoAddColumnTests: DatabaseTestCase {\n\n    func testAutoAddColumn() {\n        let fakeTable = \"fakeTable\"\n        let tableName = \"AutoAddColumnObject\"\n        let fakeSchema = \"notExistSchema\"\n        XCTAssertNoThrow(try self.database.create(table: fakeTable, of: AutoAddColumnObject.self))\n\n        doTestAutoAdd(column: AutoAddColumnObject.insertValue(), is: true) {\n            try self.database.insert(AutoAddColumnObject(), intoTable: tableName)\n        }\n\n        doTestAutoAdd(column: AutoAddColumnObject.updateValue(), is: true) {\n            try self.database.update(table: tableName, on: AutoAddColumnObject.updateValue(), with: 1)\n        }\n\n        doTestAutoAdd(column: AutoAddColumnObject.deleteValue(), is: true) {\n            try self.database.delete(fromTable: tableName, where: AutoAddColumnObject.deleteValue() == 1)\n        }\n\n        doTestAutoAdd(column: AutoAddColumnObject.deleteValue(), is: true) {\n            try self.database.delete(fromTable: tableName, where: AutoAddColumnObject.deleteValue().in(table: tableName) == 1)\n        }\n\n        doTestAutoAdd(column: AutoAddColumnObject.deleteValue(), is: false) {\n            try self.database.delete(fromTable: tableName, where: AutoAddColumnObject.deleteValue().in(table: fakeTable) == 1)\n        }\n\n        doTestAutoAdd(column: AutoAddColumnObject.deleteValue(), is: false) {\n            try self.database.delete(fromTable: tableName, where: AutoAddColumnObject.deleteValue().in(table: tableName).of(schema: fakeSchema) == 1)\n        }\n\n        doTestAutoAdd(column: AutoAddColumnObject.selectValue(), is: true) {\n            _ = try self.database.getColumn(on: AutoAddColumnObject.selectValue(), fromTable: tableName)\n        }\n\n        doTestAutoAdd(column: AutoAddColumnObject.selectValue(), is: true) {\n            _ = try self.database.getColumn(on: AutoAddColumnObject.insertValue(), fromTable: tableName, where: AutoAddColumnObject.selectValue() == 1)\n        }\n\n        doTestAutoAdd(column: AutoAddColumnObject.selectValue(), is: true) {\n            _ = try self.database.getColumn(on: AutoAddColumnObject.insertValue(), fromTable: tableName, orderBy: [AutoAddColumnObject.selectValue().asOrder()])\n        }\n\n        doTestAutoAdd(column: AutoAddColumnObject.selectValue(), is: true) {\n            _ = try self.database.getColumn(on: AutoAddColumnObject.insertValue(), fromTable: tableName, orderBy: [AutoAddColumnObject.selectValue().in(table: tableName).asOrder()])\n        }\n\n        doTestAutoAdd(column: AutoAddColumnObject.selectValue(), is: false) {\n            _ = try self.database.getColumn(on: AutoAddColumnObject.insertValue(), fromTable: tableName, orderBy: [AutoAddColumnObject.selectValue().in(table: fakeTable).asOrder()])\n        }\n\n        doTestAutoAdd(column: AutoAddColumnObject.selectValue(), is: false) {\n            _ = try self.database.getColumn(on: AutoAddColumnObject.insertValue(), fromTable: tableName, orderBy: [AutoAddColumnObject.selectValue().in(table: tableName).of(schema: fakeSchema).asOrder()])\n        }\n\n        doTestAutoAdd(column: AutoAddColumnObject.multiSelectValue(), is: true) {\n            let multiSelect = try self.database.prepareMultiSelect(on: AutoAddColumnObject.multiSelectValue().in(table: tableName), AutoAddColumnObject.multiSelectValue().in(table: fakeTable), fromTables: [fakeTable, tableName])\n            _ = try multiSelect.allMultiObjects()\n        }\n\n        doTestAutoAdd(column: AutoAddColumnObject.primaryValue(), is: false) {\n            _ = try self.database.getColumn(on: AutoAddColumnObject.primaryValue(), fromTable: tableName)\n        }\n\n        doTestAutoAdd(column: AutoAddColumnObject.uniqueValue(), is: false) {\n            _ = try self.database.getColumn(on: AutoAddColumnObject.uniqueValue(), fromTable: tableName)\n        }\n    }\n\n    func doTestAutoAdd(column codingKey: PropertyConvertible, is succeed: Bool, by execute: () throws -> Void) {\n        let tableName = \"AutoAddColumnObject\"\n        let propertyName = codingKey.asProperty().name\n        let createTable = StatementCreateTable().create(table: tableName)\n        let properties = AutoAddColumnObject.allProperties().filter { element in\n            element.propertyName != propertyName\n        }\n        let columnDefs = properties.map {\n            ColumnDef(with: $0, and: .integer64)\n        }\n        createTable.with(columns: columnDefs)\n        XCTAssertNoThrow(try self.database.exec(createTable))\n        var autoAdded = false\n        self.database.traceError { error in\n            guard error.message == \"Auto add column\" else {\n                return\n            }\n            autoAdded = true\n            XCTAssertEqual(error.extInfos[\"Table\"]?.stringValue, tableName)\n            XCTAssertEqual(error.extInfos[\"Column\"]?.stringValue, propertyName)\n        }\n        if succeed {\n            XCTAssertNoThrow(try execute())\n            XCTAssertEqual(autoAdded, true)\n        } else {\n            XCTAssertThrowsError(try execute())\n            XCTAssertEqual(autoAdded, false)\n        }\n        XCTAssertNoThrow(try self.database.drop(table: tableName))\n        self.database.traceError(nil)\n    }\n}\n"
  },
  {
    "path": "src/bridge/tests/crud/CRUDObject.h",
    "content": "//\n// Created by qiuwenchen on 2022/4/25.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import <Foundation/Foundation.h>\n#if TEST_WCDB_OBJC\n#import <WCDBOBjc/WCTMacro.h>\n#elif TEST_WCDB_CPP\n#import <WCDBCpp/WCTMacro.h>\n#else\n#import <WCDB/WCTMacro.h>\n#endif\n#if TEST_WCDB_OBJC\n#import <WCDBOBjc/WCTTableCoding.h>\n#elif TEST_WCDB_CPP\n#import <WCDBCpp/WCTTableCoding.h>\n#else\n#import <WCDB/WCTTableCoding.h>\n#endif\n\n@interface CRUDObject : NSObject <WCTTableCoding>\n\n@property (nonatomic, assign) long variable1;\n@property (nonatomic, strong) NSString* variable2;\n\nWCDB_PROPERTY(variable1)\nWCDB_PROPERTY(variable2)\n\n@end\n"
  },
  {
    "path": "src/bridge/tests/crud/CRUDObject.mm",
    "content": "//\n// Created by qiuwenchen on 2022/4/25.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"CRUDObject.h\"\n#if TEST_WCDB_OBJC\n#import <WCDBOBjc/WCDB.h>\n#elif TEST_WCDB_CPP\n#import <WCDBCpp/WCDB.h>\n#else\n#import <WCDB/WCDB.h>\n#endif\n\n@implementation CRUDObject\n- (BOOL)isEqual:(CRUDObject *)object\n{\n    return _variable1 == object.variable1 && ((_variable2 == nil && object.variable2 == nil) || [_variable2 isEqualToString:object.variable2]);\n}\n\n@synthesize lastInsertedRowID;\n\nWCDB_IMPLEMENTATION(CRUDObject)\nWCDB_SYNTHESIZE(variable1)\nWCDB_SYNTHESIZE(variable2)\n\nWCDB_PRIMARY_ASC_AUTO_INCREMENT(variable1)\n\n@end\n"
  },
  {
    "path": "src/bridge/tests/crud/CRUDObject.swift",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport Foundation\nimport WCDB\n\nextension CRUDObject: Named, Comparable {\n    static func == (lhs: CRUDObject, rhs: CRUDObject) -> Bool {\n        return lhs.variable1 == rhs.variable1 && lhs.variable2 == rhs.variable2\n    }\n    public static func < (lhs: CRUDObject, rhs: CRUDObject) -> Bool {\n        if lhs.variable1 == rhs.variable1 {\n            if let lhsv2 = lhs.variable2, let rhsv2 = rhs.variable2 {\n                return lhsv2 < rhsv2\n            }\n            return lhs.variable2 == nil\n        }\n        return lhs.variable1 < rhs.variable1\n    }\n    public static func nameForMultiSelect() -> String {\n        return \"MultiSelect_\\(name)\"\n    }\n}\n"
  },
  {
    "path": "src/bridge/tests/crud/CRUDTestCase.swift",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport XCTest\nimport WCDB\n\nclass CRUDTestCase: DatabaseTestCase {\n    let preInsertedObjects: [CRUDObject] = {\n        let object1 = CRUDObject()\n        object1.variable1 = 1\n        object1.variable2 = \"object1\"\n        let object2 = CRUDObject()\n        object2.variable1 = 2\n        object2.variable2 = \"object2\"\n        return [object1, object2]\n    }()\n\n    lazy var table: Table<CRUDObject> = {\n        database.getTable(named: CRUDObject.name)\n    }()\n\n    override func setUp() {\n        super.setUp()\n        XCTAssertNoThrow(try database.create(table: CRUDObject.name, of: CRUDObject.self))\n\n        XCTAssertNoThrow(try database.insert(preInsertedObjects, intoTable: CRUDObject.name))\n    }\n}\n"
  },
  {
    "path": "src/bridge/tests/crud/DatabaseTestCase.swift",
    "content": "//\n// Created by qiuwenchen on 2022/12/6.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport Foundation\nimport WCDB\n\nclass DatabaseTestCase: BaseTestCase {\n    var database: Database!\n    override func setUp() {\n        super.setUp()\n        database = Database(at: self.recommendedPath)\n        database.tag = recommendTag\n        Database.globalTraceError { error in\n            assert(error.level != .Fatal)\n            print(\"Time: \\(Date()),\\(error)\")\n        }\n    }\n\n    override func tearDown() {\n        Database.globalTraceError(nil)\n    }\n}\n"
  },
  {
    "path": "src/bridge/tests/crud/DeleteInterfaceTests.swift",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport XCTest\nimport WCDB\n\nclass DeleteInterfaceTests: CRUDTestCase {\n\n    func testDelete() {\n        // When\n        XCTAssertNoThrow(try database.delete(fromTable: CRUDObject.name))\n        // Then\n        let results: [CRUDObject] = WCDBAssertNoThrowReturned(try database.getObjects(fromTable: CRUDObject.name))\n        XCTAssertEqual(results.count, 0)\n    }\n\n    func testConditionalDelete() {\n        // When\n        XCTAssertNoThrow(try database.delete(fromTable: CRUDObject.name, where: CRUDObject.variable1() == 2))\n        // Then\n        let results: [CRUDObject] = WCDBAssertNoThrowReturned(try database.getObjects(fromTable: CRUDObject.name))\n        XCTAssertEqual(results.count, 1)\n        XCTAssertEqual(results[0], preInsertedObjects[0])\n    }\n\n    func testOrderedDelete() {\n        // Give\n        let order = [CRUDObject.variable1().order(.descending)]\n        // When\n        XCTAssertNoThrow(try database.delete(fromTable: CRUDObject.name, orderBy: order, limit: 1))\n        // Then\n        let results: [CRUDObject] = WCDBAssertNoThrowReturned(\n            try database.getObjects(fromTable: CRUDObject.name, orderBy: order)\n        )\n        XCTAssertEqual(results.count, 1)\n        XCTAssertEqual(results[0], preInsertedObjects[0])\n    }\n\n    func testLimitedDelete() {\n        // When\n        XCTAssertNoThrow(try database.delete(fromTable: CRUDObject.name, limit: 1))\n        // Then\n        let results: [CRUDObject] = WCDBAssertNoThrowReturned(try database.getObjects(fromTable: CRUDObject.name))\n        XCTAssertEqual(results.count, 1)\n        XCTAssertEqual(results[0], preInsertedObjects[1])\n    }\n\n    func testOffsetDelete() {\n        // When\n        XCTAssertNoThrow(try database.delete(fromTable: CRUDObject.name, limit: 1, offset: 1))\n        // Then\n        let results: [CRUDObject] = WCDBAssertNoThrowReturned(try database.getObjects(fromTable: CRUDObject.name))\n        XCTAssertEqual(results.count, 1)\n        XCTAssertEqual(results[0], preInsertedObjects[0])\n    }\n\n    func testTableDelete() {\n        // When\n        XCTAssertNoThrow(try table.delete())\n        // Then\n        let results: [CRUDObject] = WCDBAssertNoThrowReturned(try database.getObjects(fromTable: CRUDObject.name))\n        XCTAssertEqual(results.count, 0)\n    }\n\n    func testTableConditionalDelete() {\n        // When\n        XCTAssertNoThrow(try table.delete(where: CRUDObject.variable1() == 2))\n        // Then\n        let results: [CRUDObject] = WCDBAssertNoThrowReturned(try database.getObjects(fromTable: CRUDObject.name))\n        XCTAssertEqual(results.count, 1)\n        XCTAssertEqual(results[0], preInsertedObjects[0])\n    }\n\n    func testTableOrderedDelete() {\n        // Give\n        let order = [CRUDObject.variable1().order(.descending)]\n        // When\n        XCTAssertNoThrow(try table.delete(orderBy: order, limit: 1))\n        // Then\n        let results: [CRUDObject] = WCDBAssertNoThrowReturned(\n            try database.getObjects(fromTable: CRUDObject.name, orderBy: order)\n        )\n        XCTAssertEqual(results.count, 1)\n        XCTAssertEqual(results[0], preInsertedObjects[0])\n    }\n\n    func testTableLimitedDelete() {\n        // When\n        XCTAssertNoThrow(try table.delete(limit: 1))\n        // Then\n        let results: [CRUDObject] = WCDBAssertNoThrowReturned(try database.getObjects(fromTable: CRUDObject.name))\n        XCTAssertEqual(results.count, 1)\n        XCTAssertEqual(results[0], preInsertedObjects[1])\n    }\n\n    func testTableOffsetDelete() {\n        // When\n        XCTAssertNoThrow(try table.delete(limit: 1, offset: 1))\n        // Then\n        let results: [CRUDObject] = WCDBAssertNoThrowReturned(try database.getObjects(fromTable: CRUDObject.name))\n        XCTAssertEqual(results.count, 1)\n        XCTAssertEqual(results[0], preInsertedObjects[0])\n    }\n\n}\n"
  },
  {
    "path": "src/bridge/tests/crud/DeleteTests.swift",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport XCTest\nimport WCDB\n\nclass DeleteTests: CRUDTestCase {\n\n    var delete: Delete!\n\n    override func setUp() {\n        super.setUp()\n        delete = WCDBAssertNoThrowReturned(try database.prepareDelete(fromTable: CRUDObject.name))\n    }\n\n    func testDelete() {\n        // When\n        XCTAssertNoThrow(try delete.execute())\n        // Then\n        let results: [CRUDObject] = WCDBAssertNoThrowReturned(try database.getObjects(fromTable: CRUDObject.name))\n        XCTAssertEqual(results.count, 0)\n    }\n\n    func testTableDelete() {\n        // Give\n        let optionalDelete = WCDBAssertNoThrowReturned(\n            try table.prepareDelete()\n        )\n        XCTAssertNotNil(optionalDelete)\n        delete = optionalDelete!\n        // When\n        XCTAssertNoThrow(try delete.execute())\n        // Then\n        let results: [CRUDObject] = WCDBAssertNoThrowReturned(try table.getObjects())\n        XCTAssertEqual(results.count, 0)\n    }\n\n    func testConditionalDelete() {\n        // When\n        XCTAssertNoThrow(try delete.where(CRUDObject.variable1() == 2).execute())\n        // Then\n        let results: [CRUDObject] = WCDBAssertNoThrowReturned(try database.getObjects(fromTable: CRUDObject.name))\n        XCTAssertEqual(results.count, 1)\n        XCTAssertEqual(results[0], preInsertedObjects[0])\n    }\n\n    func testOrderedDelete() {\n        // Give\n        let order = CRUDObject.variable1().order(.descending)\n        // When\n        XCTAssertNoThrow(try delete.order(by: order).limit(1).execute())\n        // Then\n        let results: [CRUDObject] = WCDBAssertNoThrowReturned(try database.getObjects(fromTable: CRUDObject.name))\n        XCTAssertEqual(results.count, 1)\n        XCTAssertEqual(results[0], preInsertedObjects[0])\n    }\n\n    func testLimitedDelete() {\n        // When\n        XCTAssertNoThrow(try delete.limit(1).execute())\n        // Then\n        let results: [CRUDObject] = WCDBAssertNoThrowReturned(try database.getObjects(fromTable: CRUDObject.name))\n        XCTAssertEqual(results.count, 1)\n        XCTAssertEqual(results[0], preInsertedObjects[1])\n    }\n\n    func testOffsetDelete() {\n        // When\n        XCTAssertNoThrow(try delete.limit(1, offset: 1).execute())\n        // Then\n        let results: [CRUDObject] = WCDBAssertNoThrowReturned(try database.getObjects(fromTable: CRUDObject.name))\n        XCTAssertEqual(results.count, 1)\n        XCTAssertEqual(results[0], preInsertedObjects[0])\n    }\n\n    func testLimitedFromToDelete() {\n        // When\n        XCTAssertNoThrow(try delete.limit(from: 1, to: 2).execute())\n        // Then\n        let results: [CRUDObject] = WCDBAssertNoThrowReturned(try database.getObjects(fromTable: CRUDObject.name))\n        XCTAssertEqual(results.count, 1)\n        XCTAssertEqual(results[0], preInsertedObjects[0])\n    }\n\n    func testDeleteChanges() {\n        // When\n        XCTAssertNoThrow(try delete.execute())\n        // Then\n        XCTAssertEqual(delete.changes, preInsertedObjects.count)\n    }\n}\n"
  },
  {
    "path": "src/bridge/tests/crud/InsertInterfaceTests.swift",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport XCTest\nimport WCDB\n\nclass InsertInterfaceTests: CRUDTestCase {\n\n    func testInsert() {\n        // Give\n        let object = CRUDObject()\n        object.variable1 = preInsertedObjects.count + 1\n        object.variable2 = self.name\n        // When\n        XCTAssertNoThrow(try database.insert(object, intoTable: CRUDObject.name))\n        // Then\n        let condition = CRUDObject.variable1() == object.variable1\n        let result: CRUDObject? = WCDBAssertNoThrowReturned(\n            try database.getObject(fromTable: CRUDObject.name, where: condition)\n        )\n        XCTAssertNotNil(result)\n        XCTAssertEqual(result!, object)\n    }\n\n    func testAutoIncrementInsert() {\n        // Give\n        let object = CRUDObject()\n        let expectedRowID = preInsertedObjects.count + 1\n        object.isAutoIncrement = true\n        object.variable2 = self.name\n        // When\n        XCTAssertNoThrow(try database.insert(object, intoTable: CRUDObject.name))\n        // Then\n        XCTAssertEqual(object.lastInsertedRowID, Int64(expectedRowID))\n        let condition = CRUDObject.variable1() == expectedRowID\n        let result: CRUDObject? = WCDBAssertNoThrowReturned(\n            try database.getObject(fromTable: CRUDObject.name, where: condition)\n        )\n        XCTAssertNotNil(result)\n        XCTAssertEqual(result!.variable1, expectedRowID)\n        XCTAssertEqual(result!.variable2, object.variable2)\n    }\n\n    func testInsertOrReplace() {\n        // Give\n        let object = CRUDObject()\n        let expectedReplacedRowID = 1\n        object.variable1 = expectedReplacedRowID\n        object.variable2 = self.name\n        // When\n        XCTAssertNoThrow(try database.insertOrReplace(object, intoTable: CRUDObject.name))\n        // Then\n        let condition = CRUDObject.variable1() == expectedReplacedRowID\n        let result: CRUDObject? = WCDBAssertNoThrowReturned(\n            try database.getObject(fromTable: CRUDObject.name, where: condition)\n        )\n        XCTAssertNotNil(result)\n        XCTAssertEqual(result!.variable2, self.name)\n    }\n\n    func testInsertOrIgnore() {\n        // Give\n        let object = CRUDObject()\n        let expectedReplacedRowID = 1\n        object.variable1 = expectedReplacedRowID\n        object.variable2 = self.name\n        // When\n        XCTAssertNoThrow(try database.insertOrIgnore(object, intoTable: CRUDObject.name))\n        // Then\n        let condition = CRUDObject.variable1() == expectedReplacedRowID\n        let result: CRUDObject? = WCDBAssertNoThrowReturned(\n            try database.getObject(fromTable: CRUDObject.name, where: condition)\n        )\n        XCTAssertNotNil(result)\n        XCTAssertNotEqual(result!.variable2, self.name)\n    }\n\n    func testPartialInsert() {\n        // Give\n        let object = CRUDObject()\n        object.variable1 = preInsertedObjects.count + 1\n        object.variable2 = self.name\n        // When\n        XCTAssertNoThrow(try database.insert(object,\n                                             on: [CRUDObject.variable1()],\n                                             intoTable: CRUDObject.name))\n        // Then\n        let result: CRUDObject? = WCDBAssertNoThrowReturned(\n            try database.getObject(fromTable: CRUDObject.name,\n                                   where: CRUDObject.variable1() == object.variable1)\n        )\n        XCTAssertNotNil(result)\n        XCTAssertNil(result!.variable2)\n    }\n\n    func testTableInsert() {\n        // Give\n        let object = CRUDObject()\n        object.variable1 = preInsertedObjects.count + 1\n        object.variable2 = self.name\n        let table = database.getTable(named: CRUDObject.name, of: CRUDObject.self)\n        // When\n        XCTAssertNoThrow(try table.insert(object))\n        // Then\n        let result = WCDBAssertNoThrowReturned(\n            try table.getObject(where: CRUDObject.variable1() == object.variable1)\n        )\n        XCTAssertNotNil(result)\n        XCTAssertEqual(result!, object)\n    }\n\n    func testTableInsertOrReplace() {\n        // Give\n        let object = CRUDObject()\n        let expectedReplacedRowID = 1\n        object.variable1 = expectedReplacedRowID\n        object.variable2 = self.name\n        let table = database.getTable(named: CRUDObject.name, of: CRUDObject.self)\n        // When\n        XCTAssertNoThrow(try table.insertOrReplace(object))\n        // Then\n        let condition = CRUDObject.variable1() == expectedReplacedRowID\n        let result: CRUDObject? = WCDBAssertNoThrowReturned(\n            try table.getObject(where: condition)\n        )\n        XCTAssertNotNil(result)\n        XCTAssertEqual(result!.variable2, self.name)\n    }\n\n    func testTableInsertOrIgnore() {\n        // Give\n        let object = CRUDObject()\n        let expectedReplacedRowID = 1\n        object.variable1 = expectedReplacedRowID\n        object.variable2 = self.name\n        let table = database.getTable(named: CRUDObject.name, of: CRUDObject.self)\n        // When\n        XCTAssertNoThrow(try table.insertOrIgnore(object))\n        // Then\n        let condition = CRUDObject.variable1() == expectedReplacedRowID\n        let result: CRUDObject? = WCDBAssertNoThrowReturned(\n            try table.getObject(where: condition)\n        )\n        XCTAssertNotNil(result)\n        XCTAssertNotEqual(result!.variable2, self.name)\n    }\n\n}\n"
  },
  {
    "path": "src/bridge/tests/crud/InsertTests.swift",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport XCTest\nimport WCDB\n\nclass InsertTests: CRUDTestCase {\n\n    var insert: Insert!\n\n    override func setUp() {\n        super.setUp()\n\n        let optionalInsert = WCDBAssertNoThrowReturned(\n            try database.prepareInsert(of: CRUDObject.self, intoTable: CRUDObject.name)\n        )\n        XCTAssertNotNil(optionalInsert)\n        insert = optionalInsert!\n    }\n\n    func testInsert() {\n        // Give\n        let object = CRUDObject()\n        object.variable1 = preInsertedObjects.count + 1\n        object.variable2 = self.name\n        // When\n        XCTAssertNoThrow(try insert.execute(with: object))\n        // Then\n        let condition = CRUDObject.variable1() == object.variable1\n        let result: CRUDObject? = WCDBAssertNoThrowReturned(\n            try database.getObject(fromTable: CRUDObject.name, where: condition)\n        )\n        XCTAssertNotNil(result)\n        XCTAssertEqual(result!, object)\n    }\n\n    func testTableInsert() {\n        // Give\n        let optionalTableInsert = WCDBAssertNoThrowReturned(\n            try table.prepareInsert(of: CRUDObject.self)\n        )\n        XCTAssertNotNil(optionalTableInsert)\n        insert = optionalTableInsert!\n        let object = CRUDObject()\n        object.variable1 = preInsertedObjects.count + 1\n        object.variable2 = self.name\n        // When\n        XCTAssertNoThrow(try insert.execute(with: object))\n        // Then\n        let condition = CRUDObject.variable1() == object.variable1\n        let result: CRUDObject? = WCDBAssertNoThrowReturned(\n            try table.getObject(where: condition)\n        )\n        XCTAssertNotNil(result)\n        XCTAssertEqual(result!, object)\n    }\n\n    func testAutoIncrementInsert() {\n        // Give\n        let object = CRUDObject()\n        let expectedRowID = preInsertedObjects.count + 1\n        object.isAutoIncrement = true\n        object.variable2 = self.name\n        // When\n        XCTAssertNoThrow(try insert.execute(with: object))\n        // Then\n        let condition = CRUDObject.variable1() == expectedRowID\n        XCTAssertEqual(object.lastInsertedRowID, Int64(expectedRowID))\n        let result: CRUDObject? = WCDBAssertNoThrowReturned(\n            try database.getObject(fromTable: CRUDObject.name, where: condition)\n        )\n        XCTAssertNotNil(result)\n        XCTAssertEqual(result!.variable1, expectedRowID)\n        XCTAssertEqual(result!.variable2, object.variable2)\n    }\n\n    func testInsertOrReplace() {\n        // Give\n        let object = CRUDObject()\n        let expectedReplacedRowID = 1\n        object.variable1 = expectedReplacedRowID\n        object.variable2 = self.name\n        let optionalInsert = WCDBAssertNoThrowReturned(\n            try database.prepareInsertOrReplace(of: CRUDObject.self, intoTable: CRUDObject.name)\n        )\n        XCTAssertNotNil(optionalInsert)\n        insert = optionalInsert!\n        // When\n        XCTAssertNoThrow(try insert.execute(with: object))\n        // Then\n        let condition = CRUDObject.variable1() == expectedReplacedRowID\n        let result: CRUDObject? = WCDBAssertNoThrowReturned(\n            try database.getObject(fromTable: CRUDObject.name, where: condition)\n        )\n        XCTAssertNotNil(result)\n        XCTAssertEqual(result!.variable2, self.name)\n    }\n\n    func testTableInsertOrReplace() {\n        // Give\n        let object = CRUDObject()\n        let expectedReplacedRowID = 1\n        object.variable1 = expectedReplacedRowID\n        object.variable2 = self.name\n        let optionalInsert = WCDBAssertNoThrowReturned(\n            try table.prepareInsertOrReplace(of: CRUDObject.self)\n        )\n        XCTAssertNotNil(optionalInsert)\n        insert = optionalInsert!\n        // When\n        XCTAssertNoThrow(try insert.execute(with: object))\n        // Then\n        let condition = CRUDObject.variable1() == expectedReplacedRowID\n        let result: CRUDObject? = WCDBAssertNoThrowReturned(\n            try table.getObject(where: condition)\n        )\n        XCTAssertNotNil(result)\n        XCTAssertEqual(result!.variable2, self.name)\n    }\n\n    func testInsertOrIgnore() {\n        // Give\n        let object = CRUDObject()\n        let expectedReplacedRowID = 1\n        object.variable1 = expectedReplacedRowID\n        object.variable2 = self.name\n        let optionalInsert = WCDBAssertNoThrowReturned(\n            try database.prepareInsertOrIgnore(of: CRUDObject.self, intoTable: CRUDObject.name)\n        )\n        XCTAssertNotNil(optionalInsert)\n        insert = optionalInsert!\n        // When\n        XCTAssertNoThrow(try insert.execute(with: object))\n        // Then\n        let condition = CRUDObject.variable1() == expectedReplacedRowID\n        let result: CRUDObject? = WCDBAssertNoThrowReturned(\n            try database.getObject(fromTable: CRUDObject.name, where: condition)\n        )\n        XCTAssertNotNil(result)\n        XCTAssertNotEqual(result!.variable2, self.name)\n    }\n\n    func testTableInsertOrIgnore() {\n        // Give\n        let object = CRUDObject()\n        let expectedReplacedRowID = 1\n        object.variable1 = expectedReplacedRowID\n        object.variable2 = self.name\n        let optionalInsert = WCDBAssertNoThrowReturned(\n            try table.prepareInsertOrIgnore(of: CRUDObject.self)\n        )\n        XCTAssertNotNil(optionalInsert)\n        insert = optionalInsert!\n        // When\n        XCTAssertNoThrow(try insert.execute(with: object))\n        // Then\n        let condition = CRUDObject.variable1() == expectedReplacedRowID\n        let result: CRUDObject? = WCDBAssertNoThrowReturned(\n            try table.getObject(where: condition)\n        )\n        XCTAssertNotNil(result)\n        XCTAssertNotEqual(result!.variable2, self.name)\n    }\n\n    func testPartialInsert() {\n        // Give\n        let object = CRUDObject()\n        object.variable1 = preInsertedObjects.count + 1\n        object.variable2 = self.name\n        let optionalInsert = WCDBAssertNoThrowReturned(\n            try database.prepareInsert(on: CRUDObject.variable1(), intoTable: CRUDObject.name)\n        )\n        XCTAssertNotNil(optionalInsert)\n        let insert = optionalInsert!\n        // When\n        XCTAssertNoThrow(try insert.execute(with: object))\n        // Then\n        let condition = CRUDObject.variable1() == object.variable1\n        let result: CRUDObject? = WCDBAssertNoThrowReturned(\n            try database.getObject(fromTable: CRUDObject.name, where: condition)\n        )\n        XCTAssertNotNil(result)\n        XCTAssertNil(result!.variable2)\n    }\n\n    func testTablePartialInsert() {\n        // Give\n        let object = CRUDObject()\n        object.variable1 = preInsertedObjects.count + 1\n        object.variable2 = self.name\n        let optionalInsert = WCDBAssertNoThrowReturned(\n            try table.prepareInsert(on: CRUDObject.variable1())\n        )\n        XCTAssertNotNil(optionalInsert)\n        let insert = optionalInsert!\n        // When\n        XCTAssertNoThrow(try insert.execute(with: object))\n        // Then\n        let condition = CRUDObject.variable1() == object.variable1\n        let result: CRUDObject? = WCDBAssertNoThrowReturned(\n            try table.getObject(where: condition)\n        )\n        XCTAssertNotNil(result)\n        XCTAssertNil(result!.variable2)\n    }\n\n    func testPartialInsertOrReplace() {\n        // Give\n        let object = CRUDObject()\n        let expectedReplacedRowID = 1\n        object.variable1 = expectedReplacedRowID\n        object.variable2 = self.name\n        let optionalInsert = WCDBAssertNoThrowReturned(\n            try database.prepareInsertOrReplace(on:\n                CRUDObject.variable1(),\n                CRUDObject.variable2(),\n                                                intoTable: CRUDObject.name)\n        )\n        XCTAssertNotNil(optionalInsert)\n        insert = optionalInsert!\n        // When\n        XCTAssertNoThrow(try insert.execute(with: object))\n        // Then\n        let condition = CRUDObject.variable1() == expectedReplacedRowID\n        let result: CRUDObject? = WCDBAssertNoThrowReturned(\n            try database.getObject(fromTable: CRUDObject.name, where: condition)\n        )\n        XCTAssertNotNil(result)\n        XCTAssertEqual(result!.variable2, self.name)\n    }\n\n    func testTablePartialInsertOrReplace() {\n        // Give\n        let object = CRUDObject()\n        let expectedReplacedRowID = 1\n        object.variable1 = expectedReplacedRowID\n        object.variable2 = self.name\n        let optionalInsert = WCDBAssertNoThrowReturned(\n            try table.prepareInsertOrReplace(on:\n                CRUDObject.variable1(),\n                CRUDObject.variable2())\n        )\n        XCTAssertNotNil(optionalInsert)\n        insert = optionalInsert!\n        // When\n        XCTAssertNoThrow(try insert.execute(with: object))\n        // Then\n        let condition = CRUDObject.variable1() == expectedReplacedRowID\n        let result: CRUDObject? = WCDBAssertNoThrowReturned(\n            try table.getObject(where: condition)\n        )\n        XCTAssertNotNil(result)\n        XCTAssertEqual(result!.variable2, self.name)\n    }\n\n    func testInsertEmpty() {\n        XCTAssertNoThrow(try insert.execute(with: [CRUDObject]()))\n    }\n\n    func testInsertFailed() {\n        XCTAssertNoThrow(try database.prepareInsert(of: CRUDObject.self, intoTable: \"\"))\n    }\n\n}\n"
  },
  {
    "path": "src/bridge/tests/crud/MultiSelectTests.swift",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport XCTest\nimport WCDB\n\nextension Dictionary where Key==String, Value: CRUDObject {\n    static func == (lhs: [Key: Value], rhs: [Key: Value]) -> Bool {\n        guard lhs.count == rhs.count else {\n            return false\n        }\n        for (key, value) in lhs {\n            guard rhs[key] == value else {\n                return false\n            }\n        }\n        return true\n    }\n\n    static func < (lhs: [Key: Value], rhs: [Key: Value]) -> Bool {\n        guard lhs.count == rhs.count else {\n            return lhs.count < rhs.count\n        }\n        for i in 0..<lhs.count {\n            let lhsWrap = lhs[lhs.index(lhs.startIndex, offsetBy: i)]\n            let rhsWrap = rhs[rhs.index(rhs.startIndex, offsetBy: i)]\n            guard lhsWrap.key == rhsWrap.key else {\n                return lhsWrap.key < rhsWrap.key\n            }\n            guard lhsWrap.value == rhsWrap.value else {\n                return lhsWrap.value < rhsWrap.value\n            }\n        }\n        return false\n    }\n}\n\nextension Array where Element==[String: CRUDObject] {\n    static func == (lhs: [Element], rhs: [Element]) -> Bool {\n        guard lhs.count == rhs.count else {\n            return false\n        }\n        for i in 0..<lhs.count {\n            guard lhs[i] == rhs[i] else {\n                return false\n            }\n        }\n        return true\n    }\n\n    func sorted() -> [Element] {\n        return self.sorted { (lhs, rhs) -> Bool in\n            return lhs < rhs\n        }\n    }\n}\n\nclass MultiSelectTests: CRUDTestCase {\n\n    var preInsertedCRUDObjects: [CRUDObject] = {\n        let object1 = CRUDObject()\n        object1.variable1 = 1\n        object1.variable2 = \"multiObject1\"\n        let object2 = CRUDObject()\n        object2.variable1 = 2\n        object2.variable2 = \"multiObject2\"\n        return [object1, object2]\n    }()\n\n    lazy var preInsertedMultiObjects: [[String: CRUDObject]] = [\n        [\n            CRUDObject.name: preInsertedObjects[0],\n            CRUDObject.nameForMultiSelect(): preInsertedCRUDObjects[0]\n        ],\n        [\n            CRUDObject.name: preInsertedObjects[1],\n            CRUDObject.nameForMultiSelect(): preInsertedCRUDObjects[1]\n        ]\n    ]\n\n    var multiSelect: MultiSelect!\n\n    override func setUp() {\n        super.setUp()\n\n        XCTAssertNoThrow(try database.create(table: CRUDObject.nameForMultiSelect(), of: CRUDObject.self))\n        XCTAssertNoThrow(try database.insert(preInsertedCRUDObjects, intoTable: CRUDObject.nameForMultiSelect()))\n\n        let tables = [CRUDObject.name, CRUDObject.nameForMultiSelect()]\n        let property1 = CRUDObject.variable1().in(table: CRUDObject.name)\n        let property2 = CRUDObject.variable1().in(table: CRUDObject.nameForMultiSelect())\n        multiSelect = WCDBAssertNoThrowReturned(\n            try database.prepareMultiSelect(on: CRUDObject.variable1().in(table: CRUDObject.name),\n                                            CRUDObject.variable2().in(table: CRUDObject.name),\n                                            CRUDObject.variable1().in(table: CRUDObject.nameForMultiSelect()),\n                                            CRUDObject.variable2().in(table: CRUDObject.nameForMultiSelect()),\n                                            fromTables: tables).where(property1 == property2)\n        )!\n    }\n\n    func testSelect() {\n        // When\n        let results = WCDBAssertNoThrowReturned(\n            try multiSelect.allMultiObjects(),\n            whenFailed: [[String: TableDecodableBase]]()\n        )\n        let baseResults = results as? [[String: CRUDObject]]\n        // Then\n        XCTAssertNotNil(baseResults)\n        XCTAssertTrue(baseResults! == preInsertedMultiObjects)\n    }\n\n    func testOrderedSelect() {\n        // When\n        let order = CRUDObject.variable1().in(table: CRUDObject.name).order(.descending)\n        let results = WCDBAssertNoThrowReturned(\n            try multiSelect.order(by: order).allMultiObjects(),\n            whenFailed: [[String: TableDecodableBase]]())\n        let baseResults = results as? [[String: CRUDObject]]\n        // Then\n        XCTAssertNotNil(baseResults)\n        XCTAssertTrue(baseResults! == preInsertedMultiObjects.reversed())\n    }\n\n    func testLimitedSelect() {\n        // When\n        let results = WCDBAssertNoThrowReturned(\n            try multiSelect.limit(1).allMultiObjects(),\n            whenFailed: [[String: TableDecodableBase]]()\n        )\n        let baseResults = results as? [[String: CRUDObject]]\n        // Then\n        XCTAssertNotNil(baseResults)\n        XCTAssertEqual(baseResults!.count, 1)\n        XCTAssertTrue(baseResults![0] == preInsertedMultiObjects[0])\n    }\n\n    func testOffsetSelect() {\n        // When\n        let results = WCDBAssertNoThrowReturned(\n            try multiSelect.limit(1, offset: 1).allMultiObjects(),\n            whenFailed: [[String: TableDecodableBase]]()\n        )\n        let baseResults = results as? [[String: CRUDObject]]\n        // Then\n        XCTAssertNotNil(baseResults)\n        XCTAssertEqual(baseResults!.count, 1)\n        XCTAssertTrue(baseResults![0] == preInsertedMultiObjects[1])\n    }\n\n    func testSelectIteration() {\n        // When\n        var results: [[String: CRUDObject]] = []\n        while let result = WCDBAssertNoThrowReturned(try multiSelect.nextMultiObject()) {\n            let crudObject = result as? [String: CRUDObject]\n            XCTAssertNotNil(crudObject)\n            results.append(crudObject!)\n        }\n        // Then\n        XCTAssertTrue(results == preInsertedMultiObjects)\n    }\n}\n"
  },
  {
    "path": "src/bridge/tests/crud/RowSelectTests.swift",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport XCTest\nimport WCDB\n\nclass RowSelectTests: CRUDTestCase {\n\n    var rowSelect: RowSelect!\n\n    override func setUp() {\n        super.setUp()\n\n        let optionalRowSelect = WCDBAssertNoThrowReturned(\n            try database.prepareRowSelect(fromTable: CRUDObject.name)\n        )\n        XCTAssertNotNil(optionalRowSelect)\n        rowSelect = optionalRowSelect!\n    }\n\n    func testRowSelect() {\n        // When\n        let results: MultiRowsValue = WCDBAssertNoThrowReturned(try rowSelect.allRows())\n        // Then\n        XCTAssertEqual(results.count, preInsertedObjects.count)\n        XCTAssertEqual(Int(results[row: 0, column: 0].int64Value), preInsertedObjects[0].variable1)\n        XCTAssertEqual(results[row: 0, column: 1].stringValue, preInsertedObjects[0].variable2)\n        XCTAssertEqual(Int(results[row: 1, column: 0].int64Value), preInsertedObjects[1].variable1)\n        XCTAssertEqual(results[row: 1, column: 1].stringValue, preInsertedObjects[1].variable2)\n    }\n\n    func testTableRowSelect() {\n        let optionalRowSelect = WCDBAssertNoThrowReturned(\n            try table.prepareRowSelect()\n        )\n        XCTAssertNotNil(optionalRowSelect)\n        rowSelect = optionalRowSelect!\n        // When\n        let results: MultiRowsValue = WCDBAssertNoThrowReturned(try rowSelect.allRows())\n        // Then\n        XCTAssertEqual(results.count, preInsertedObjects.count)\n        XCTAssertEqual(Int(results[row: 0, column: 0].int64Value), preInsertedObjects[0].variable1)\n        XCTAssertEqual(results[row: 0, column: 1].stringValue, preInsertedObjects[0].variable2)\n        XCTAssertEqual(Int(results[row: 1, column: 0].int64Value), preInsertedObjects[1].variable1)\n        XCTAssertEqual(results[row: 1, column: 1].stringValue, preInsertedObjects[1].variable2)\n    }\n\n    func testConditionalRowSelect() {\n        // When\n        let results: MultiRowsValue = WCDBAssertNoThrowReturned(\n            try rowSelect.where(CRUDObject.variable1() == 1).allRows()\n        )\n        // Then\n        XCTAssertEqual(results.count, 1)\n        XCTAssertEqual(Int(results[row: 0, column: 0].int64Value), preInsertedObjects[0].variable1)\n        XCTAssertEqual(results[row: 0, column: 1].stringValue, preInsertedObjects[0].variable2)\n    }\n\n    func testOrderedRowSelect() {\n        // Give\n        let order = CRUDObject.variable1().order(.descending)\n        // When\n        let results: MultiRowsValue = WCDBAssertNoThrowReturned(try rowSelect.order(by: order).allRows())\n        // Then\n        XCTAssertEqual(results.count, preInsertedObjects.count)\n        XCTAssertEqual(Int(results[row: 0, column: 0].int64Value), preInsertedObjects[1].variable1)\n        XCTAssertEqual(results[row: 0, column: 1].stringValue, preInsertedObjects[1].variable2)\n        XCTAssertEqual(Int(results[row: 1, column: 0].int64Value), preInsertedObjects[0].variable1)\n        XCTAssertEqual(results[row: 1, column: 1].stringValue, preInsertedObjects[0].variable2)\n    }\n\n    func testLimitedRowSelect() {\n        // When\n        let results: MultiRowsValue = WCDBAssertNoThrowReturned(try rowSelect.limit(1).allRows())\n        // Then\n        XCTAssertEqual(results.count, 1)\n        XCTAssertEqual(Int(results[row: 0, column: 0].int64Value), preInsertedObjects[0].variable1)\n        XCTAssertEqual(results[row: 0, column: 1].stringValue, preInsertedObjects[0].variable2)\n    }\n\n    func testOffsetRowSelect() {\n        // When\n        let results: MultiRowsValue = WCDBAssertNoThrowReturned(try rowSelect.limit(1, offset: 1).allRows())\n        // Then\n        XCTAssertEqual(results.count, 1)\n        XCTAssertEqual(Int(results[row: 0, column: 0].int64Value), preInsertedObjects[1].variable1)\n        XCTAssertEqual(results[row: 0, column: 1].stringValue, preInsertedObjects[1].variable2)\n    }\n\n    func testGroupByRowSelect() {\n        // Give\n        let preInsertedObjects: [CRUDObject] = {\n            let object1 = CRUDObject()\n            object1.variable1 = 3\n            object1.variable2 = \"object1\"\n            let object2 = CRUDObject()\n            object2.variable1 = 4\n            object2.variable2 = \"object2\"\n            return [object1, object2]\n        }()\n        XCTAssertNoThrow(try database.insert(preInsertedObjects, intoTable: CRUDObject.name))\n\n        let optionalRowSelect = WCDBAssertNoThrowReturned(\n            try database.prepareRowSelect(on: Column.all().count(),\n                                          fromTable: CRUDObject.name)\n        )\n        XCTAssertNotNil(optionalRowSelect)\n        rowSelect = optionalRowSelect!\n        rowSelect.group(by: CRUDObject.variable2()).having(CRUDObject.variable1() > 0)\n        // When\n        let results: OneColumnValue = WCDBAssertNoThrowReturned(try rowSelect.allValues())\n        // Then\n        XCTAssertEqual(results.count, 2)\n        XCTAssertEqual(results[0].int32Value, 2)\n        XCTAssertEqual(results[1].int32Value, 2)\n    }\n\n    func testTableGroupByRowSelect() {\n        // Give\n        var optionalRowSelect = WCDBAssertNoThrowReturned(\n            try table.prepareRowSelect()\n        )\n        XCTAssertNotNil(optionalRowSelect)\n        rowSelect = optionalRowSelect!\n        let preInsertedObjects: [CRUDObject] = {\n            let object1 = CRUDObject()\n            object1.variable1 = 3\n            object1.variable2 = \"object1\"\n            let object2 = CRUDObject()\n            object2.variable1 = 4\n            object2.variable2 = \"object2\"\n            return [object1, object2]\n        }()\n        XCTAssertNoThrow(try table.insert(preInsertedObjects))\n\n        optionalRowSelect = WCDBAssertNoThrowReturned(\n            try table.prepareRowSelect(on: Column.all().count())\n        )\n        XCTAssertNotNil(optionalRowSelect)\n        rowSelect = optionalRowSelect!\n        rowSelect.group(by: CRUDObject.variable2()).having(CRUDObject.variable1() > 0)\n        // When\n        let results: OneColumnValue = WCDBAssertNoThrowReturned(try rowSelect.allValues())\n        // Then\n        XCTAssertEqual(results.count, 2)\n        XCTAssertEqual(results[0].int32Value, 2)\n        XCTAssertEqual(results[1].int32Value, 2)\n    }\n\n    func testPartialRowSelect() {\n        // Give\n        let optionalRowSelect = WCDBAssertNoThrowReturned(\n            try database.prepareRowSelect(on: CRUDObject.variable2(), fromTable: CRUDObject.name)\n        )\n        XCTAssertNotNil(optionalRowSelect)\n        rowSelect = optionalRowSelect!\n        // When\n        let results: MultiRowsValue = WCDBAssertNoThrowReturned(try rowSelect.allRows())\n        // Then\n        XCTAssertEqual(results.count, preInsertedObjects.count)\n        XCTAssertEqual(results[row: 0, column: 0].stringValue, preInsertedObjects[0].variable2)\n        XCTAssertEqual(results[row: 1, column: 0].stringValue, preInsertedObjects[1].variable2)\n    }\n\n    func testTablePartialRowSelect() {\n        // Give\n        let optionalRowSelect = WCDBAssertNoThrowReturned(\n            try table.prepareRowSelect(on: CRUDObject.variable2())\n        )\n        XCTAssertNotNil(optionalRowSelect)\n        rowSelect = optionalRowSelect!\n        // When\n        let results: MultiRowsValue = WCDBAssertNoThrowReturned(try rowSelect.allRows())\n        // Then\n        XCTAssertEqual(results.count, preInsertedObjects.count)\n        XCTAssertEqual(results[row: 0, column: 0].stringValue, preInsertedObjects[0].variable2)\n        XCTAssertEqual(results[row: 1, column: 0].stringValue, preInsertedObjects[1].variable2)\n    }\n\n    func testRowSelectIteration() {\n        // When\n        var results: MultiRowsValue = []\n        while let result = WCDBAssertNoThrowReturned(try rowSelect.nextRow()) {\n            results.append(result)\n        }\n        // Then\n        XCTAssertEqual(results.count, preInsertedObjects.count)\n        XCTAssertEqual(Int(results[row: 0, column: 0].int64Value), preInsertedObjects[0].variable1)\n        XCTAssertEqual(results[row: 0, column: 1].stringValue, preInsertedObjects[0].variable2)\n        XCTAssertEqual(Int(results[row: 1, column: 0].int64Value), preInsertedObjects[1].variable1)\n        XCTAssertEqual(results[row: 1, column: 1].stringValue, preInsertedObjects[1].variable2)\n    }\n\n    func testRowSelectValue() {\n        // When\n        let results: OneColumnValue = WCDBAssertNoThrowReturned(try rowSelect.allValues())\n        // Then\n        XCTAssertEqual(results.count, preInsertedObjects.count)\n        XCTAssertEqual(Int(results[0].int64Value), preInsertedObjects[0].variable1)\n        XCTAssertEqual(Int(results[1].int64Value), preInsertedObjects[1].variable1)\n    }\n\n    func testRowSelectValueIteraion() {\n        // When\n        var results: OneColumnValue = []\n        while let result = WCDBAssertNoThrowReturned(try rowSelect.nextValue()) {\n            results.append(result)\n        }\n        // Then\n        XCTAssertEqual(results.count, preInsertedObjects.count)\n        XCTAssertEqual(Int(results[0].int64Value), preInsertedObjects[0].variable1)\n        XCTAssertEqual(Int(results[1].int64Value), preInsertedObjects[1].variable1)\n    }\n\n    func testRowSelectMultiTables() {\n        // Give\n        let table = CRUDObject.name\n        let table2 = \"\\(CRUDObject.name)_2\"\n        XCTAssertNoThrow(try database.create(table: table2, of: CRUDObject.self))\n\n        let object1 = CRUDObject()\n        object1.variable1 = 1\n        object1.variable2 = \"object3\"\n        XCTAssertNoThrow(try database.insert(object1, intoTable: table2))\n\n        let column1Table1 = CRUDObject.variable1().in(table: table)\n        let column1Table2 = CRUDObject.variable1().in(table: table2)\n        let column2Table1 = CRUDObject.variable2().in(table: table)\n        let column2Table2 = CRUDObject.variable2().in(table: table2)\n        // When\n        let optionalRowSelect = WCDBAssertNoThrowReturned(\n            try database.prepareRowSelect(on: column2Table1, column2Table2,\n                                          fromTables: [table, table2])\n                .where(column1Table1 == column1Table2)\n        )\n        XCTAssertNotNil(optionalRowSelect)\n        let rowSelect = optionalRowSelect!\n        let rows = WCDBAssertNoThrowReturned(try rowSelect.allRows())\n        // Then\n        XCTAssertEqual(rows.count, 1)\n        XCTAssertEqual(rows[row: 0, column: 0].stringValue, \"object1\")\n        XCTAssertEqual(rows[row: 0, column: 1].stringValue, \"object3\")\n    }\n\n    func testRowSelectAllMultiTables() {\n        // Give\n        let table = CRUDObject.name\n        let table2 = \"\\(CRUDObject.name)_2\"\n        XCTAssertNoThrow(try database.create(table: table2, of: CRUDObject.self))\n\n        let object1 = CRUDObject()\n        object1.variable1 = 1\n        object1.variable2 = \"object3\"\n        XCTAssertNoThrow(try database.insert(object1, intoTable: table2))\n\n        let column1Table1 = CRUDObject.variable1().in(table: table)\n        let column1Table2 = CRUDObject.variable1().in(table: table2)\n        // When\n        let optionalRowSelect = WCDBAssertNoThrowReturned(\n            try database.prepareRowSelect(fromTables: [table, table2])\n                .where(column1Table1 == column1Table2)\n        )\n        XCTAssertNotNil(optionalRowSelect)\n        let rowSelect = optionalRowSelect!\n        let rows = WCDBAssertNoThrowReturned(try rowSelect.allRows())\n        // Then\n        XCTAssertEqual(rows.count, 1)\n        XCTAssertEqual(Int(rows[row: 0, column: 0].int32Value), 1)\n        XCTAssertEqual(rows[row: 0, column: 1].stringValue, \"object1\")\n        XCTAssertEqual(Int(rows[row: 0, column: 2].int32Value), 1)\n        XCTAssertEqual(rows[row: 0, column: 3].stringValue, \"object3\")\n    }\n\n    func testRowSelectFailed() {\n        XCTAssertNoThrow(try database.prepareRowSelect(fromTables: []))\n    }\n\n    func testRowSelectType() {\n        // Give\n        let optionalRowSelect = WCDBAssertNoThrowReturned(\n            try database.prepareRowSelect(on: 1, 2.0, \"3\", fromTable: CRUDObject.name)\n        )\n        XCTAssertNotNil(optionalRowSelect)\n        rowSelect = optionalRowSelect!\n\n        // When\n        let results: OneRowValue? = WCDBAssertNoThrowReturned(try rowSelect.nextRow())\n        XCTAssertNotNil(results)\n        XCTAssertEqual(results!.count, 3)\n        // Then\n        XCTAssertEqual(results![0].int32Value, 1)\n        XCTAssertEqual(results![1].doubleValue, 2.0)\n        XCTAssertEqual(results![2].stringValue, \"3\")\n    }\n\n    func testTableRowSelectType() {\n        // Give\n        let optionalRowSelect = WCDBAssertNoThrowReturned(\n            try table.prepareRowSelect(on: 1, 2.0, \"3\")\n        )\n        XCTAssertNotNil(optionalRowSelect)\n        rowSelect = optionalRowSelect!\n\n        // When\n        let results: OneRowValue? = WCDBAssertNoThrowReturned(try rowSelect.nextRow())\n        XCTAssertNotNil(results)\n        XCTAssertEqual(results!.count, 3)\n        // Then\n        XCTAssertEqual(results![0].int32Value, 1)\n        XCTAssertEqual(results![1].doubleValue, 2.0)\n        XCTAssertEqual(results![2].stringValue, \"3\")\n    }\n}\n"
  },
  {
    "path": "src/bridge/tests/crud/SelectInterfaceTests.swift",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport XCTest\nimport WCDB\n\nclass SelectInterfaceTests: CRUDTestCase {\n\n    func testSelect() {\n        let results: [CRUDObject] = WCDBAssertNoThrowReturned(\n            try database.getObjects(fromTable: CRUDObject.name),\n            whenFailed: [CRUDObject]()\n        )\n        XCTAssertEqual(results.sorted(), preInsertedObjects.sorted())\n    }\n\n    func testConditionalSelect() {\n        let results: [CRUDObject] = WCDBAssertNoThrowReturned(\n            try database.getObjects(fromTable: CRUDObject.name, where: CRUDObject.variable1() == 2),\n            whenFailed: [CRUDObject]()\n        )\n        XCTAssertEqual(results.count, 1)\n        XCTAssertEqual(results[0].variable2, \"object2\")\n    }\n\n    func testOrderedSelect() {\n        let order = [CRUDObject.variable2().order(.descending)]\n        let results: [CRUDObject] = WCDBAssertNoThrowReturned(\n            try database.getObjects(fromTable: CRUDObject.name, orderBy: order),\n            whenFailed: [CRUDObject]()\n        )\n        XCTAssertEqual(results, preInsertedObjects.reversed())\n    }\n\n    func testLimitedSelect() {\n        let results: [CRUDObject] = WCDBAssertNoThrowReturned(\n            try database.getObjects(fromTable: CRUDObject.name, limit: 1),\n            whenFailed: [CRUDObject]()\n        )\n        XCTAssertEqual(results.count, 1)\n        XCTAssertEqual(results[0], preInsertedObjects[0])\n    }\n\n    func testOffsetSelect() {\n        let results: [CRUDObject] = WCDBAssertNoThrowReturned(\n            try database.getObjects(fromTable: CRUDObject.name, limit: 1, offset: 1),\n            whenFailed: [CRUDObject]()\n        )\n        XCTAssertEqual(results.count, 1)\n        XCTAssertEqual(results[0], preInsertedObjects[1])\n    }\n\n    func testPartialSelect() {\n        let results: [CRUDObject] = WCDBAssertNoThrowReturned(\n            try database.getObjects(on: CRUDObject.variable2(), fromTable: CRUDObject.name),\n            whenFailed: [CRUDObject]()\n        )\n        XCTAssertEqual(results.map({ (object) in\n            XCTAssertTrue(object.variable1 == 0)\n            XCTAssertNotNil(object.variable2)\n            return object.variable2!\n        }), preInsertedObjects.map { $0.variable2! })\n    }\n\n    func testTableSelect() {\n        // When\n        let results: [CRUDObject] = WCDBAssertNoThrowReturned(\n            try table.getObjects(), whenFailed: [CRUDObject]()\n        )\n        // Then\n        XCTAssertEqual(results.sorted(), preInsertedObjects.sorted())\n    }\n\n    func testRowSelect() {\n        // When\n        let results: MultiRowsValue = WCDBAssertNoThrowReturned(\n            try database.getRows(fromTable: CRUDObject.name)\n        )\n        // Then\n        XCTAssertEqual(results.count, preInsertedObjects.count)\n        XCTAssertEqual(Int(results[row: 0, column: 0].int64Value), preInsertedObjects[0].variable1)\n        XCTAssertEqual(results[row: 0, column: 1].stringValue, preInsertedObjects[0].variable2)\n        XCTAssertEqual(Int(results[row: 1, column: 0].int64Value), preInsertedObjects[1].variable1)\n        XCTAssertEqual(results[row: 1, column: 1].stringValue, preInsertedObjects[1].variable2)\n    }\n\n    func testConditionalRowSelect() {\n        // When\n        let results: MultiRowsValue = WCDBAssertNoThrowReturned(\n            try database.getRows(fromTable: CRUDObject.name, where: CRUDObject.variable1() == 1)\n        )\n        // Then\n        XCTAssertEqual(results.count, 1)\n        XCTAssertEqual(Int(results[row: 0, column: 0].int64Value), preInsertedObjects[0].variable1)\n        XCTAssertEqual(results[row: 0, column: 1].stringValue, preInsertedObjects[0].variable2)\n    }\n\n    func testOrderedRowSelect() {\n        // Give\n        let order = [CRUDObject.variable1().order(.descending)]\n        // When\n        let results: MultiRowsValue = WCDBAssertNoThrowReturned(\n            try database.getRows(fromTable: CRUDObject.name, orderBy: order)\n        )\n        // Then\n        XCTAssertEqual(results.count, preInsertedObjects.count)\n        XCTAssertEqual(Int(results[row: 0, column: 0].int64Value), preInsertedObjects[1].variable1)\n        XCTAssertEqual(results[row: 0, column: 1].stringValue, preInsertedObjects[1].variable2)\n        XCTAssertEqual(Int(results[row: 1, column: 0].int64Value), preInsertedObjects[0].variable1)\n        XCTAssertEqual(results[row: 1, column: 1].stringValue, preInsertedObjects[0].variable2)\n    }\n\n    func testLimitedRowSelect() {\n        // When\n        let results: MultiRowsValue = WCDBAssertNoThrowReturned(\n            try database.getRows(fromTable: CRUDObject.name, limit: 1)\n        )\n        // Then\n        XCTAssertEqual(results.count, 1)\n        XCTAssertEqual(Int(results[row: 0, column: 0].int64Value), preInsertedObjects[0].variable1)\n        XCTAssertEqual(results[row: 0, column: 1].stringValue, preInsertedObjects[0].variable2)\n    }\n\n    func testOffsetRowSelect() {\n        // When\n        let results: MultiRowsValue = WCDBAssertNoThrowReturned(\n            try database.getRows(fromTable: CRUDObject.name, limit: 1, offset: 1)\n        )\n        // Then\n        XCTAssertEqual(results.count, 1)\n        let row = results[row: 0]\n        XCTAssertEqual(Int(row[0].int64Value), preInsertedObjects[1].variable1)\n        XCTAssertEqual(row[1].stringValue, preInsertedObjects[1].variable2)\n    }\n\n    func testPartialRowSelect() {\n        // When\n        let results: MultiRowsValue = WCDBAssertNoThrowReturned(\n            try database.getRows(on: CRUDObject.variable2(), fromTable: CRUDObject.name)\n        )\n        // Then\n        XCTAssertEqual(results.count, preInsertedObjects.count)\n        XCTAssertEqual(results[row: 0, column: 0].stringValue, preInsertedObjects[0].variable2)\n        XCTAssertEqual(results[row: 1, column: 0].stringValue, preInsertedObjects[1].variable2)\n    }\n\n    func testRowSelectOne() {\n        // When\n        let results: OneRowValue = WCDBAssertNoThrowReturned(\n            try database.getRow(fromTable: CRUDObject.name)\n        )\n        // Then\n        XCTAssertEqual(results.count, 2)\n        XCTAssertEqual(Int(results[0].int64Value), preInsertedObjects[0].variable1)\n        XCTAssertEqual(results[1].stringValue, preInsertedObjects[0].variable2)\n    }\n\n    func testRowSelectColumn() {\n        // When\n        let results: OneColumnValue = WCDBAssertNoThrowReturned(\n            try database.getColumn(on: CRUDObject.variable1(), fromTable: CRUDObject.name)\n        )\n        // Then\n        XCTAssertEqual(Int(results[0].int64Value), preInsertedObjects[0].variable1)\n        XCTAssertEqual(Int(results[1].int64Value), preInsertedObjects[1].variable1)\n    }\n\n    func testConditionalRowSelectColumn() {\n        // When\n        let results: OneColumnValue = WCDBAssertNoThrowReturned(\n            try database.getColumn(on: CRUDObject.variable1(),\n                                   fromTable: CRUDObject.name,\n                                   where: CRUDObject.variable1() == 1)\n        )\n        // Then\n        XCTAssertEqual(results.count, 1)\n        XCTAssertEqual(Int(results[0].int64Value), preInsertedObjects[0].variable1)\n    }\n\n    func testOrderedRowSelectColumn() {\n        // Give\n        let order = [CRUDObject.variable1().order(.descending)]\n        // When\n        let results: OneColumnValue = WCDBAssertNoThrowReturned(\n            try database.getColumn(on: CRUDObject.variable1(), fromTable: CRUDObject.name, orderBy: order)\n        )\n        // Then\n        XCTAssertEqual(results.count, preInsertedObjects.count)\n        XCTAssertEqual(Int(results[0].int64Value), preInsertedObjects[1].variable1)\n        XCTAssertEqual(Int(results[1].int64Value), preInsertedObjects[0].variable1)\n    }\n\n    func testLimitedRowSelectColumn() {\n        // When\n        let results: OneColumnValue = WCDBAssertNoThrowReturned(\n            try database.getColumn(on: CRUDObject.variable1(), fromTable: CRUDObject.name, limit: 1)\n        )\n        // Then\n        XCTAssertEqual(results.count, 1)\n        XCTAssertEqual(Int(results[0].int64Value), preInsertedObjects[0].variable1)\n    }\n\n    func testOffsetRowSelectColumn() {\n        // When\n        let results: OneColumnValue = WCDBAssertNoThrowReturned(\n            try database.getColumn(on: CRUDObject.variable1(), fromTable: CRUDObject.name, limit: 1, offset: 1)\n        )\n        // Then\n        XCTAssertEqual(results.count, 1)\n        XCTAssertEqual(Int(results[0].int64Value), preInsertedObjects[1].variable1)\n    }\n\n    func testRowSelectDistinctColumn() {\n        // Give\n        let object1 = CRUDObject()\n        object1.variable1 = 3\n        object1.variable2 = \"object1\"\n        XCTAssertNoThrow(try database.insert(object1, intoTable: CRUDObject.name))\n        // When\n        let results: OneColumnValue = WCDBAssertNoThrowReturned(\n            try database.getDistinctColumn(on: CRUDObject.variable2(), fromTable: CRUDObject.name)\n        )\n        // Then\n        XCTAssertEqual(results[0].stringValue, preInsertedObjects[0].variable2)\n        XCTAssertEqual(results[1].stringValue, preInsertedObjects[1].variable2)\n    }\n\n    func testConditionalRowSelectDistinctColumn() {\n        // Give\n        let object1 = CRUDObject()\n        object1.variable1 = 3\n        object1.variable2 = \"object1\"\n        XCTAssertNoThrow(try database.insert(object1, intoTable: CRUDObject.name))\n        // When\n        let results: OneColumnValue = WCDBAssertNoThrowReturned(\n            try database.getDistinctColumn(on: CRUDObject.variable2(),\n                                           fromTable: CRUDObject.name,\n                                           where: CRUDObject.variable1() == 1)\n        )\n        // Then\n        XCTAssertEqual(results.count, 1)\n        XCTAssertEqual(results[0].stringValue, preInsertedObjects[0].variable2)\n    }\n\n    func testOrderedRowSelectDistinctColumn() {\n        // Give\n        let object1 = CRUDObject()\n        object1.variable1 = 3\n        object1.variable2 = \"object1\"\n        XCTAssertNoThrow(try database.insert(object1, intoTable: CRUDObject.name))\n        // Give\n        let order = [CRUDObject.variable2().order(.descending)]\n        // When\n        let results: OneColumnValue = WCDBAssertNoThrowReturned(\n            try database.getDistinctColumn(on: CRUDObject.variable2(),\n                                           fromTable: CRUDObject.name,\n                                           orderBy: order)\n        )\n        // Then\n        XCTAssertEqual(results.count, preInsertedObjects.count)\n        XCTAssertEqual(results[0].stringValue, preInsertedObjects[1].variable2)\n        XCTAssertEqual(results[1].stringValue, preInsertedObjects[0].variable2)\n    }\n\n    func testLimitedRowSelectDistinctColumn() {\n        // Give\n        let object1 = CRUDObject()\n        object1.variable1 = 3\n        object1.variable2 = \"object1\"\n        XCTAssertNoThrow(try database.insert(object1, intoTable: CRUDObject.name))\n        // When\n        let results: OneColumnValue = WCDBAssertNoThrowReturned(\n            try database.getDistinctColumn(on: CRUDObject.variable2(), fromTable: CRUDObject.name, limit: 1)\n        )\n        // Then\n        XCTAssertEqual(results.count, 1)\n        XCTAssertEqual(results[0].stringValue, preInsertedObjects[0].variable2)\n    }\n\n    func testOffsetRowSelectDistinctColumn() {\n        // Give\n        let object1 = CRUDObject()\n        object1.variable1 = 3\n        object1.variable2 = \"object1\"\n        XCTAssertNoThrow(try database.insert(object1, intoTable: CRUDObject.name))\n        // When\n        let results: OneColumnValue = WCDBAssertNoThrowReturned(\n            try database.getDistinctColumn(on: CRUDObject.variable2(),\n                                           fromTable: CRUDObject.name,\n                                           limit: 1,\n                                           offset: 1)\n        )\n        // Then\n        XCTAssertEqual(results.count, 1)\n        XCTAssertEqual(results[0].stringValue, preInsertedObjects[1].variable2)\n    }\n\n    func testRowSelectValue() {\n        // When\n        let result: Value? = WCDBAssertNoThrowReturned(\n            try database.getValue(on: CRUDObject.variable2(), fromTable: CRUDObject.name)\n        )\n        // Then\n        XCTAssertNotNil(result)\n        XCTAssertEqual(result!.stringValue, preInsertedObjects[0].variable2)\n    }\n\n    func testSelectOne() {\n        let result: CRUDObject? = WCDBAssertNoThrowReturned(\n            try database.getObject(fromTable: CRUDObject.name)\n        )\n        XCTAssertNotNil(result)\n        XCTAssertEqual(result!, preInsertedObjects[0])\n    }\n\n    func testTableRowSelect() {\n        // When\n        let results: MultiRowsValue = WCDBAssertNoThrowReturned(try table.getRows())\n        // Then\n        XCTAssertEqual(results.count, preInsertedObjects.count)\n        XCTAssertEqual(Int(results[row: 0, column: 0].int64Value), preInsertedObjects[0].variable1)\n        XCTAssertEqual(results[row: 0, column: 1].stringValue, preInsertedObjects[0].variable2)\n        XCTAssertEqual(Int(results[row: 1, column: 0].int64Value), preInsertedObjects[1].variable1)\n        XCTAssertEqual(results[row: 1, column: 1].stringValue, preInsertedObjects[1].variable2)\n    }\n\n    func testTableRowSelectOne() {\n        // When\n        let results: OneRowValue = WCDBAssertNoThrowReturned(\n            try table.getRow()\n        )\n        // Then\n        XCTAssertEqual(results.count, 2)\n        XCTAssertEqual(Int(results[0].int64Value), preInsertedObjects[0].variable1)\n        XCTAssertEqual(results[1].stringValue, preInsertedObjects[0].variable2)\n    }\n\n    func testTableRowSelectColumn() {\n        // When\n        let results: OneColumnValue = WCDBAssertNoThrowReturned(\n            try table.getColumn(on: CRUDObject.variable1())\n        )\n        // Then\n        XCTAssertEqual(Int(results[0].int64Value), preInsertedObjects[0].variable1)\n        XCTAssertEqual(Int(results[1].int64Value), preInsertedObjects[1].variable1)\n    }\n\n    func testTableConditionalRowSelectColumn() {\n        // When\n        let results: OneColumnValue = WCDBAssertNoThrowReturned(\n            try table.getColumn(on: CRUDObject.variable1(), where: CRUDObject.variable1() == 1)\n        )\n        // Then\n        XCTAssertEqual(results.count, 1)\n        XCTAssertEqual(Int(results[0].int64Value), preInsertedObjects[0].variable1)\n    }\n\n    func testTableOrderedRowSelectColumn() {\n        // Give\n        let order = [CRUDObject.variable1().order(.descending)]\n        // When\n        let results: OneColumnValue = WCDBAssertNoThrowReturned(\n            try table.getColumn(on: CRUDObject.variable1(), orderBy: order)\n        )\n        // Then\n        XCTAssertEqual(results.count, preInsertedObjects.count)\n        XCTAssertEqual(Int(results[0].int64Value), preInsertedObjects[1].variable1)\n        XCTAssertEqual(Int(results[1].int64Value), preInsertedObjects[0].variable1)\n    }\n\n    func testTableLimitedRowSelectColumn() {\n        // When\n        let results: OneColumnValue = WCDBAssertNoThrowReturned(\n            try table.getColumn(on: CRUDObject.variable1(), limit: 1)\n        )\n        // Then\n        XCTAssertEqual(results.count, 1)\n        XCTAssertEqual(Int(results[0].int64Value), preInsertedObjects[0].variable1)\n    }\n\n    func testTableOffsetRowSelectColumn() {\n        // When\n        let results: OneColumnValue = WCDBAssertNoThrowReturned(\n            try table.getColumn(on: CRUDObject.variable1(), limit: 1, offset: 1)\n        )\n        // Then\n        XCTAssertEqual(results.count, 1)\n        XCTAssertEqual(Int(results[0].int64Value), preInsertedObjects[1].variable1)\n    }\n\n    func testTableRowSelectDistinctColumn() {\n        let object1 = CRUDObject()\n        object1.variable1 = 3\n        object1.variable2 = \"object1\"\n        XCTAssertNoThrow(try database.insert(object1, intoTable: CRUDObject.name))\n        // When\n        let results: OneColumnValue = WCDBAssertNoThrowReturned(\n            try table.getDistinctColumn(on: CRUDObject.variable2())\n        )\n        // Then\n        XCTAssertEqual(results[0].stringValue, preInsertedObjects[0].variable2)\n        XCTAssertEqual(results[1].stringValue, preInsertedObjects[1].variable2)\n    }\n\n    func testTableConditionalRowSelectDistinctColumn() {\n        let object1 = CRUDObject()\n        object1.variable1 = 3\n        object1.variable2 = \"object1\"\n        XCTAssertNoThrow(try database.insert(object1, intoTable: CRUDObject.name))\n        // When\n        let results: OneColumnValue = WCDBAssertNoThrowReturned(\n            try table.getDistinctColumn(on: CRUDObject.variable2(),\n                                         where: CRUDObject.variable1() == 1)\n        )\n        // Then\n        XCTAssertEqual(results.count, 1)\n        XCTAssertEqual(results[0].stringValue, preInsertedObjects[0].variable2)\n    }\n\n    func testTableOrderedRowSelectDistinctColumn() {\n        let object1 = CRUDObject()\n        object1.variable1 = 3\n        object1.variable2 = \"object1\"\n        XCTAssertNoThrow(try database.insert(object1, intoTable: CRUDObject.name))\n        // Give\n        let order = [CRUDObject.variable2().order(.descending)]\n        // When\n        let results: OneColumnValue = WCDBAssertNoThrowReturned(\n            try table.getDistinctColumn(on: CRUDObject.variable2(), orderBy: order)\n        )\n        // Then\n        XCTAssertEqual(results.count, preInsertedObjects.count)\n        XCTAssertEqual(results[0].stringValue, preInsertedObjects[1].variable2)\n        XCTAssertEqual(results[1].stringValue, preInsertedObjects[0].variable2)\n    }\n\n    func testTableLimitedRowSelectDistinctColumn() {\n        let object1 = CRUDObject()\n        object1.variable1 = 3\n        object1.variable2 = \"object1\"\n        XCTAssertNoThrow(try database.insert(object1, intoTable: CRUDObject.name))\n        // When\n        let results: OneColumnValue = WCDBAssertNoThrowReturned(\n            try table.getDistinctColumn(on: CRUDObject.variable2(), limit: 1)\n        )\n        // Then\n        XCTAssertEqual(results.count, 1)\n        XCTAssertEqual(results[0].stringValue, preInsertedObjects[0].variable2)\n    }\n\n    func testTableOffsetRowSelectDistinctColumn() {\n        let object1 = CRUDObject()\n        object1.variable1 = 3\n        object1.variable2 = \"object1\"\n        XCTAssertNoThrow(try database.insert(object1, intoTable: CRUDObject.name))\n        // When\n        let results: OneColumnValue = WCDBAssertNoThrowReturned(\n            try table.getDistinctColumn(on: CRUDObject.variable2(), limit: 1, offset: 1)\n        )\n        // Then\n        XCTAssertEqual(results.count, 1)\n        XCTAssertEqual(results[0].stringValue, preInsertedObjects[1].variable2)\n    }\n\n    func testTableRowSelectValue() {\n        // When\n        let result: Value? = WCDBAssertNoThrowReturned(\n            try table.getValue(on: CRUDObject.variable2())\n        )\n        // Then\n        XCTAssertNotNil(result)\n        XCTAssertEqual(result!.stringValue, preInsertedObjects[0].variable2)\n    }\n\n    func testTableSelectOne() {\n        // When\n        let result: CRUDObject? = WCDBAssertNoThrowReturned(\n            try table.getObject()\n        )\n        // Then\n        XCTAssertNotNil(result)\n        XCTAssertEqual(result!, preInsertedObjects[0])\n    }\n\n    func testSelectEmpty() {\n        let tableName = CRUDObject.name\n        // Give\n        XCTAssertNoThrow(try database.delete(fromTable: tableName))\n        // Then\n        do {\n            let row = try database.getRow(on: Column.all(), fromTable: tableName)\n            XCTAssertEqual(row.count, 0)\n\n            let distinctValue = try database.getDistinctValue(on: Column.all(), fromTable: tableName)\n            XCTAssertEqual(distinctValue.type, .null)\n\n            let value = try database.getValue(on: Column.all(), fromTable: tableName)\n            XCTAssertEqual(value.type, .null)\n        } catch let error {\n            XCTFail(error.localizedDescription)\n        }\n    }\n\n    func testTableSelectEmpty() {\n        // Give\n        XCTAssertNoThrow(try database.delete(fromTable: CRUDObject.name))\n        // Then\n        do {\n            let row = try table.getRow(on: Column.all())\n            XCTAssertEqual(row.count, 0)\n\n            let distinctValue = try table.getDistinctValue(on: Column.all())\n            XCTAssertEqual(distinctValue.type, .null)\n\n            let value = try table.getValue(on: Column.all())\n            XCTAssertEqual(value.type, .null)\n        } catch let error {\n            XCTFail(error.localizedDescription)\n        }\n    }\n}\n"
  },
  {
    "path": "src/bridge/tests/crud/SelectTests.swift",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport XCTest\nimport WCDB\n\nclass SelectTests: CRUDTestCase {\n\n    var select: Select!\n\n    override func setUp() {\n        super.setUp()\n\n        select = WCDBAssertNoThrowReturned(try database.prepareSelect(of: CRUDObject.self, fromTable: CRUDObject.name))!\n    }\n\n    func testSelect() {\n        let results: [CRUDObject] = WCDBAssertNoThrowReturned(try select.allObjects(), whenFailed: [CRUDObject]())\n        XCTAssertEqual(results.sorted(), preInsertedObjects.sorted())\n    }\n\n    func testTableSelect() {\n        select = WCDBAssertNoThrowReturned(try table.prepareSelect(of: CRUDObject.self))\n        let results: [CRUDObject] = WCDBAssertNoThrowReturned(try select.allObjects(), whenFailed: [CRUDObject]())\n        XCTAssertEqual(results.sorted(), preInsertedObjects.sorted())\n    }\n\n    func testConditionalSelect() {\n        let results: [CRUDObject] = WCDBAssertNoThrowReturned(\n            try select.where(CRUDObject.variable1() == 2).allObjects(),\n            whenFailed: [CRUDObject]()\n        )\n        XCTAssertEqual(results.count, 1)\n        XCTAssertEqual(results[0].variable2, \"object2\")\n    }\n\n    func testOrderedSelect() {\n        let order = CRUDObject.variable2().order(.descending)\n        let results: [CRUDObject] = WCDBAssertNoThrowReturned(\n            try select.order(by: order).allObjects(),\n            whenFailed: [CRUDObject]()\n        )\n        XCTAssertEqual(results, preInsertedObjects.reversed())\n    }\n\n    func testLimitedSelect() {\n        let results: [CRUDObject] = WCDBAssertNoThrowReturned(\n            try select.limit(1).allObjects(),\n            whenFailed: [CRUDObject]()\n        )\n        XCTAssertEqual(results.count, 1)\n        XCTAssertEqual(results[0], preInsertedObjects[0])\n    }\n\n    func testOffsetSelect() {\n        let results: [CRUDObject] = WCDBAssertNoThrowReturned(\n            try select.limit(from: 1, to: 1).allObjects(),\n            whenFailed: [CRUDObject]()\n        )\n        XCTAssertEqual(results.count, 1)\n        XCTAssertEqual(results[0], preInsertedObjects[1])\n    }\n\n    func testPartialSelect() {\n        let select = WCDBAssertNoThrowReturned(try database.prepareSelect(on: CRUDObject.variable2().asProperty(), fromTable: CRUDObject.name))!\n        let results: [CRUDObject] = WCDBAssertNoThrowReturned(\n            try select.allObjects(),\n            whenFailed: [CRUDObject]()\n        )\n        XCTAssertEqual(results.map({ (object) -> String in\n            XCTAssertTrue(object.variable1 == 0)\n            XCTAssertNotNil(object.variable2)\n            return object.variable2!\n        }), preInsertedObjects.map({\n            XCTAssertNotNil($0.variable2)\n            return $0.variable2!\n        }))\n    }\n\n    func testTablePartialSelect() {\n        let select = WCDBAssertNoThrowReturned(try table.prepareSelect(on: CRUDObject.variable2().asProperty()))!\n        let results: [CRUDObject] = WCDBAssertNoThrowReturned(\n            try select.allObjects(),\n            whenFailed: [CRUDObject]()\n        )\n        XCTAssertEqual(results.map({ (object) -> String in\n            XCTAssertTrue(object.variable1 == 0)\n            XCTAssertNotNil(object.variable2)\n            return object.variable2!\n        }), preInsertedObjects.map({\n            XCTAssertNotNil($0.variable2)\n            return $0.variable2!\n        }))\n    }\n\n    func testSelectIteration() {\n        var results: [CRUDObject] = []\n        while let result: CRUDObject = WCDBAssertNoThrowReturned(try select.nextObject()) {\n            results.append(result)\n        }\n        XCTAssertEqual(results.sorted(), preInsertedObjects.sorted())\n    }\n\n    func testUnspecificSelect() {\n        let results = WCDBAssertNoThrowReturned(try select.allObjects(), whenFailed: [Any]())\n        let objects = results as? [CRUDObject]\n        XCTAssertNotNil(objects)\n        XCTAssertEqual(objects!.sorted(), preInsertedObjects.sorted())\n    }\n\n    func testUnspecificSelectIteration() {\n        var results: [CRUDObject] = []\n        while let result = WCDBAssertNoThrowReturned(try select.nextObject()) {\n            let crudObject = result as? CRUDObject\n            XCTAssertNotNil(crudObject)\n            results.append(crudObject!)\n        }\n        XCTAssertEqual(results.sorted(), preInsertedObjects.sorted())\n    }\n\n    final class WrongObject: TableCodable {\n        var variable1: Int? = 0\n        var variable2: String? = \"\"\n        enum CodingKeys: String, CodingTableKey {\n            typealias Root = WrongObject\n            case variable1\n            case variable2\n            nonisolated(unsafe) static let objectRelationalMapping = TableBinding(CodingKeys.self)\n        }\n    }\n\n    func testSelectFailed() {\n        select = WCDBAssertNoThrowReturned(try database.prepareSelect(of: CRUDObject.self, fromTable: \"nonexistentTable\"))!\n        XCTAssertThrowsError(try select.nextObject())\n    }\n}\n"
  },
  {
    "path": "src/bridge/tests/crud/UpdateInterfaceTests.swift",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport XCTest\nimport WCDB\n\nclass UpdateInterfaceTests: CRUDTestCase {\n\n    func testUpdate() {\n        // Give\n        let object = CRUDObject()\n        object.variable2 = self.name\n        // When\n        XCTAssertNoThrow(try database.update(table: CRUDObject.name, on: CRUDObject.variable2(), with: object))\n        // Then\n        let results: [CRUDObject] = WCDBAssertNoThrowReturned(\n            try database.getObjects(fromTable: CRUDObject.name),\n            whenFailed: [CRUDObject]()\n        )\n        XCTAssertEqual(Array(repeating: self.name, count: preInsertedObjects.count), results.map({\n            XCTAssertNotNil($0.variable2)\n            return $0.variable2!\n        }))\n    }\n\n    func testConditionalUpdate() {\n        // Give\n        let object = CRUDObject()\n        object.variable2 = self.name\n        // When\n        XCTAssertNoThrow(try database.update(table: CRUDObject.name,\n                                             on: CRUDObject.variable2(),\n                                             with: object,\n                                             where: CRUDObject.variable1() == 1))\n        // Then\n        let result: CRUDObject? = WCDBAssertNoThrowReturned(\n            try database.getObject(fromTable: CRUDObject.name, where: CRUDObject.variable1() == 1)\n        )\n        XCTAssertNotNil(result)\n        XCTAssertEqual(self.name, result!.variable2)\n    }\n\n    func testOrderedUpdate() {\n        // Give\n        let object = CRUDObject()\n        object.variable2 = self.name\n        let order = [CRUDObject.variable1().order(.descending)]\n        // When\n        XCTAssertNoThrow(try database.update(table: CRUDObject.name,\n                                             on: CRUDObject.variable2(),\n                                             with: object,\n                                             orderBy: order,\n                                             limit: 1))\n        // Then\n        let result: CRUDObject? = WCDBAssertNoThrowReturned(\n            try database.getObject(fromTable: CRUDObject.name, where: CRUDObject.variable1() == 2)\n        )\n        XCTAssertNotNil(result)\n        XCTAssertEqual(self.name, result!.variable2)\n    }\n\n    func testLimitedUpdate() {\n        // Give\n        let object = CRUDObject()\n        object.variable2 = self.name\n        // When\n        XCTAssertNoThrow(try database.update(table: CRUDObject.name,\n                                             on: CRUDObject.variable2(),\n                                             with: object,\n                                             limit: 1))\n        // Then\n        let results: [CRUDObject] = WCDBAssertNoThrowReturned(try database.getObjects(fromTable: CRUDObject.name))\n        XCTAssertEqual(results[0].variable2, self.name)\n        XCTAssertEqual(results[1], preInsertedObjects[1])\n    }\n\n    func testOffsetUpdate() {\n        // Give\n        let object = CRUDObject()\n        object.variable2 = self.name\n        // When\n        XCTAssertNoThrow(try database.update(table: CRUDObject.name,\n                                             on: CRUDObject.variable2(),\n                                             with: object,\n                                             limit: 1,\n                                             offset: 1))\n        // Then\n        let results: [CRUDObject] = WCDBAssertNoThrowReturned(try database.getObjects(fromTable: CRUDObject.name))\n        XCTAssertEqual(results[0], preInsertedObjects[0])\n        XCTAssertEqual(results[1].variable2, self.name)\n    }\n\n    func testUpdateWithRow() {\n        // Give\n        let object = CRUDObject()\n        object.variable2 = self.name\n        // When\n        XCTAssertNoThrow(\n            try database.update(table: CRUDObject.name, on: CRUDObject.variable2(), with: [self.name])\n        )\n        // Then\n        let results: [CRUDObject] = WCDBAssertNoThrowReturned(\n            try database.getObjects(fromTable: CRUDObject.name),\n            whenFailed: [CRUDObject]()\n        )\n        XCTAssertEqual(Array(repeating: self.name, count: preInsertedObjects.count), results.map({\n            XCTAssertNotNil($0.variable2)\n            return $0.variable2!\n        }))\n    }\n\n    func testConditionalUpdateWithRow() {\n        // Give\n        let object = CRUDObject()\n        object.variable2 = self.name\n        // When\n        XCTAssertNoThrow(try database.update(table: CRUDObject.name,\n                                             on: CRUDObject.variable2(),\n                                             with: [self.name],\n                                             where: CRUDObject.variable1() == 1))\n        // Then\n        let result: CRUDObject? = WCDBAssertNoThrowReturned(\n            try database.getObject(fromTable: CRUDObject.name, where: CRUDObject.variable1() == 1)\n        )\n        XCTAssertNotNil(result)\n        XCTAssertEqual(self.name, result!.variable2)\n    }\n\n    func testOrderedUpdateWithRow() {\n        // Give\n        let object = CRUDObject()\n        object.variable2 = self.name\n        let order = [CRUDObject.variable1().order(.descending)]\n        // When\n        XCTAssertNoThrow(try database.update(table: CRUDObject.name,\n                                             on: CRUDObject.variable2(),\n                                             with: [self.name],\n                                             orderBy: order,\n                                             limit: 1))\n        // Then\n        let result: CRUDObject? = WCDBAssertNoThrowReturned(\n            try database.getObject(fromTable: CRUDObject.name, where: CRUDObject.variable1() == 2)\n        )\n        XCTAssertNotNil(result)\n        XCTAssertEqual(self.name, result!.variable2)\n    }\n\n    func testLimitedUpdateWithRow() {\n        // Give\n        let object = CRUDObject()\n        object.variable2 = self.name\n        // When\n        XCTAssertNoThrow(try database.update(table: CRUDObject.name,\n                                             on: CRUDObject.variable2(),\n                                             with: [self.name],\n                                             limit: 1))\n        // Then\n        let results: [CRUDObject] = WCDBAssertNoThrowReturned(try database.getObjects(fromTable: CRUDObject.name))\n        XCTAssertEqual(results[0].variable2, self.name)\n        XCTAssertEqual(results[1], preInsertedObjects[1])\n    }\n\n    func testOffsetUpdateWithRow() {\n        // Give\n        let object = CRUDObject()\n        object.variable2 = self.name\n        // When\n        XCTAssertNoThrow(try database.update(table: CRUDObject.name,\n                                             on: CRUDObject.variable2(),\n                                             with: [self.name],\n                                             limit: 1,\n                                             offset: 1))\n        // Then\n        let results: [CRUDObject] = WCDBAssertNoThrowReturned(try database.getObjects(fromTable: CRUDObject.name))\n        XCTAssertEqual(results[0], preInsertedObjects[0])\n        XCTAssertEqual(results[1].variable2, self.name)\n    }\n\n    func testTableUpdate() {\n        // Give\n        let object = CRUDObject()\n        object.variable2 = self.name\n        // When\n        XCTAssertNoThrow(try table.update(on: CRUDObject.variable2(), with: object))\n        // Then\n        let results: [CRUDObject] = WCDBAssertNoThrowReturned(try table.getObjects())\n        XCTAssertEqual(results.map({\n            XCTAssertNotNil($0.variable2)\n            return $0.variable2!\n        }), Array(repeating: self.name, count: preInsertedObjects.count))\n    }\n\n    func testTableConditionalUpdate() {\n        // Give\n        let object = CRUDObject()\n        object.variable2 = self.name\n        // When\n        XCTAssertNoThrow(try table.update(on: CRUDObject.variable2(),\n                                             with: object,\n                                             where: CRUDObject.variable1() == 1))\n        // Then\n        let result: CRUDObject? = WCDBAssertNoThrowReturned(\n            try database.getObject(fromTable: CRUDObject.name, where: CRUDObject.variable1() == 1)\n        )\n        XCTAssertNotNil(result)\n        XCTAssertEqual(self.name, result!.variable2)\n    }\n\n    func testTableOrderedUpdate() {\n        // Give\n        let object = CRUDObject()\n        object.variable2 = self.name\n        let order = [CRUDObject.variable1().order(.descending)]\n        // When\n        XCTAssertNoThrow(try table.update(on: CRUDObject.variable2(),\n                                             with: object,\n                                             orderBy: order,\n                                             limit: 1))\n        // Then\n        let result: CRUDObject? = WCDBAssertNoThrowReturned(\n            try database.getObject(fromTable: CRUDObject.name, where: CRUDObject.variable1() == 2)\n        )\n        XCTAssertNotNil(result)\n        XCTAssertEqual(self.name, result!.variable2)\n    }\n\n    func testTableLimitedUpdate() {\n        // Give\n        let object = CRUDObject()\n        object.variable2 = self.name\n        // When\n        XCTAssertNoThrow(try table.update(on: CRUDObject.variable2(),\n                                             with: object,\n                                             limit: 1))\n        // Then\n        let results: [CRUDObject] = WCDBAssertNoThrowReturned(try database.getObjects(fromTable: CRUDObject.name))\n        XCTAssertEqual(results[0].variable2, self.name)\n        XCTAssertEqual(results[1], preInsertedObjects[1])\n    }\n\n    func testTableOffsetUpdate() {\n        // Give\n        let object = CRUDObject()\n        object.variable2 = self.name\n        // When\n        XCTAssertNoThrow(try table.update(on: CRUDObject.variable2(),\n                                             with: object,\n                                             limit: 1,\n                                             offset: 1))\n        // Then\n        let results: [CRUDObject] = WCDBAssertNoThrowReturned(try database.getObjects(fromTable: CRUDObject.name))\n        XCTAssertEqual(results[0], preInsertedObjects[0])\n        XCTAssertEqual(results[1].variable2, self.name)\n    }\n\n    func testTableUpdateWithRow() {\n        // Give\n        let object = CRUDObject()\n        object.variable2 = self.name\n        // When\n        XCTAssertNoThrow(\n            try table.update(on: CRUDObject.variable2(), with: [self.name])\n        )\n        // Then\n        let results: [CRUDObject] = WCDBAssertNoThrowReturned(\n            try database.getObjects(fromTable: CRUDObject.name),\n            whenFailed: [CRUDObject]()\n        )\n        XCTAssertEqual(Array(repeating: self.name, count: preInsertedObjects.count), results.map({\n            XCTAssertNotNil($0.variable2)\n            return $0.variable2!\n        }))\n    }\n\n    func testTableConditionalUpdateWithRow() {\n        // Give\n        let object = CRUDObject()\n        object.variable2 = self.name\n        // When\n        XCTAssertNoThrow(try table.update(on: CRUDObject.variable2(),\n                                             with: [self.name],\n                                             where: CRUDObject.variable1() == 1))\n        // Then\n        let result: CRUDObject? = WCDBAssertNoThrowReturned(\n            try database.getObject(fromTable: CRUDObject.name, where: CRUDObject.variable1() == 1)\n        )\n        XCTAssertNotNil(result)\n        XCTAssertEqual(self.name, result!.variable2)\n    }\n\n    func testTableOrderedUpdateWithRow() {\n        // Give\n        let object = CRUDObject()\n        object.variable2 = self.name\n        let order = [CRUDObject.variable1().order(.descending)]\n        // When\n        XCTAssertNoThrow(try table.update(on: CRUDObject.variable2(),\n                                             with: [self.name],\n                                             orderBy: order,\n                                             limit: 1))\n        // Then\n        let result: CRUDObject? = WCDBAssertNoThrowReturned(\n            try database.getObject(fromTable: CRUDObject.name, where: CRUDObject.variable1() == 2)\n        )\n        XCTAssertNotNil(result)\n        XCTAssertEqual(self.name, result!.variable2)\n    }\n\n    func testTableLimitedUpdateWithRow() {\n        // Give\n        let object = CRUDObject()\n        object.variable2 = self.name\n        // When\n        XCTAssertNoThrow(try table.update(on: CRUDObject.variable2(),\n                                             with: [self.name],\n                                             limit: 1))\n        // Then\n        let results: [CRUDObject] = WCDBAssertNoThrowReturned(try database.getObjects(fromTable: CRUDObject.name))\n        XCTAssertEqual(results[0].variable2, self.name)\n        XCTAssertEqual(results[1], preInsertedObjects[1])\n    }\n\n    func testTableOffsetUpdateWithRow() {\n        // Give\n        let object = CRUDObject()\n        object.variable2 = self.name\n        // When\n        XCTAssertNoThrow(try table.update(on: CRUDObject.variable2(),\n                                             with: [self.name],\n                                             limit: 1,\n                                             offset: 1))\n        // Then\n        let results: [CRUDObject] = WCDBAssertNoThrowReturned(try database.getObjects(fromTable: CRUDObject.name))\n        XCTAssertEqual(results[0], preInsertedObjects[0])\n        XCTAssertEqual(results[1].variable2, self.name)\n    }\n\n}\n"
  },
  {
    "path": "src/bridge/tests/crud/UpdateTests.swift",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport XCTest\nimport WCDB\n\nclass UpdateTests: CRUDTestCase {\n\n    var update: Update!\n\n    override func setUp() {\n        super.setUp()\n\n        let optionalUpdate = WCDBAssertNoThrowReturned(\n            try database.prepareUpdate(table: CRUDObject.name, on: CRUDObject.variable2())\n        )\n        XCTAssertNotNil(optionalUpdate)\n        update = optionalUpdate!\n    }\n\n    func testUpdate() {\n        // Give\n        let object = CRUDObject()\n        object.variable2 = self.name\n        // When\n        XCTAssertNoThrow(try update.execute(with: object))\n        // Then\n        let results: [CRUDObject] = WCDBAssertNoThrowReturned(\n            try database.getObjects(fromTable: CRUDObject.name),\n            whenFailed: [CRUDObject]()\n        )\n        XCTAssertEqual(Array(repeating: self.name, count: preInsertedObjects.count), results.map({\n            XCTAssertNotNil($0.variable2)\n            return $0.variable2!\n        }))\n    }\n\n    func testTableUpdate() {\n        // Give\n        let optionalUpdate = WCDBAssertNoThrowReturned(\n            try table.prepareUpdate(on: CRUDObject.variable2())\n        )\n        XCTAssertNotNil(optionalUpdate)\n        update = optionalUpdate!\n        let object = CRUDObject()\n        object.variable2 = self.name\n        // When\n        XCTAssertNoThrow(try update.execute(with: object))\n        // Then\n        let results: [CRUDObject] = WCDBAssertNoThrowReturned(\n            try database.getObjects(fromTable: CRUDObject.name),\n            whenFailed: [CRUDObject]()\n        )\n        XCTAssertEqual(Array(repeating: self.name, count: preInsertedObjects.count), results.map({\n            XCTAssertNotNil($0.variable2)\n            return $0.variable2!\n        }))\n    }\n\n    func testConditionalUpdate() {\n        // Give\n        let object = CRUDObject()\n        object.variable2 = self.name\n        // When\n        XCTAssertNoThrow(try update.where(CRUDObject.variable1() == 1).execute(with: object))\n        // Then\n        let result: CRUDObject? = WCDBAssertNoThrowReturned(\n            try database.getObject(fromTable: CRUDObject.name, where: CRUDObject.variable1() == 1)\n        )\n        XCTAssertNotNil(result)\n        XCTAssertEqual(self.name, result!.variable2)\n    }\n\n    func testOrderedUpdate() {\n        // Give\n        let object = CRUDObject()\n        object.variable2 = self.name\n        let order = CRUDObject.variable1().order(.descending)\n        // When\n        XCTAssertNoThrow(try update.order(by: order).limit(1).execute(with: object))\n        // Then\n        let result: CRUDObject? = WCDBAssertNoThrowReturned(\n            try database.getObject(fromTable: CRUDObject.name, where: CRUDObject.variable1() == 2)\n        )\n        XCTAssertNotNil(result)\n        XCTAssertEqual(self.name, result!.variable2)\n    }\n\n    func testLimitedUpdate() {\n        // Give\n        let object = CRUDObject()\n        object.variable2 = self.name\n        // When\n        XCTAssertNoThrow(try update.limit(1).execute(with: object))\n        // Then\n        let results: [CRUDObject] = WCDBAssertNoThrowReturned(\n            try database.getObjects(fromTable: CRUDObject.name)\n        )\n        XCTAssertEqual(results[0].variable2, self.name)\n        XCTAssertEqual(results[1], preInsertedObjects[1])\n    }\n\n    func testOffsetUpdate() {\n        // Give\n        let object = CRUDObject()\n        object.variable2 = self.name\n        // When\n        XCTAssertNoThrow(try update.limit(1, offset: 1).execute(with: object))\n        // Then\n        let results: [CRUDObject] = WCDBAssertNoThrowReturned(try database.getObjects(fromTable: CRUDObject.name))\n        XCTAssertEqual(results[0], preInsertedObjects[0])\n        XCTAssertEqual(results[1].variable2, self.name)\n    }\n\n    func testLimitFromToUpdate() {\n        // Give\n        let object = CRUDObject()\n        object.variable2 = self.name\n        // When\n        XCTAssertNoThrow(try update.limit(from: 1, to: 2).execute(with: object))\n        // Then\n        let results: [CRUDObject] = WCDBAssertNoThrowReturned(try database.getObjects(fromTable: CRUDObject.name))\n        XCTAssertEqual(results[0], preInsertedObjects[0])\n        XCTAssertEqual(results[1].variable2, self.name)\n    }\n\n    func testUpdateChanges() {\n        // Give\n        let object = CRUDObject()\n        object.variable2 = self.name\n        // When\n        XCTAssertNoThrow(try update.execute(with: object))\n        // Then\n        XCTAssertEqual(update.changes, preInsertedObjects.count)\n    }\n}\n"
  },
  {
    "path": "src/bridge/winqbridge/WinqBridge.cpp",
    "content": "//\n// Created by qiuwenchen on 2022/5/26.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"WinqBridge.hpp\"\n#include \"Column.hpp\"\n#include \"Expression.hpp\"\n#include \"LiteralValue.hpp\"\n#include \"Recyclable.hpp\"\n#include \"SQL.hpp\"\n#include \"Schema.hpp\"\n#include \"Statement.hpp\"\n#include \"TableOrSubquery.hpp\"\n\nconst char* _Nonnull WCDBWinqGetDescription(CPPObject* statement)\n{\n    WCDB::SQL* innerValue = (WCDB::SQL*) statement->realValue;\n    return innerValue->getDescription().data();\n}\n\nbool WCDBStatementNeedToWrite(CPPObject* _Nonnull statement)\n{\n    WCDB::Statement* innerValue = (WCDB::Statement*) statement->realValue;\n    return innerValue->isWriteStatement();\n}\n\nnamespace WCDB {\n\nOrder WinqBridge::changeOrder(enum WCDBSyntaxOrder order)\n{\n    switch (order) {\n    case WCDBSyntaxOrder_Asc:\n        return Order::ASC;\n    case WCDBSyntaxOrder_Desc:\n        return Order::DESC;\n    }\n}\n\nConflict WinqBridge::changeConflict(enum WCDBSyntaxConflictAction action)\n{\n    switch (action) {\n    case WCDBSyntaxConflictAction_Fail:\n        return Conflict::Fail;\n    case WCDBSyntaxConflictAction_Abort:\n        return Conflict::Abort;\n    case WCDBSyntaxConflictAction_Ignore:\n        return Conflict::Ignore;\n    case WCDBSyntaxConflictAction_Replace:\n        return Conflict::Replace;\n    case WCDBSyntaxConflictAction_Rollback:\n        return Conflict::Rollback;\n    }\n}\n\nSyntax::ConflictAction WinqBridge::changeConflictAction(enum WCDBSyntaxConflictAction action)\n{\n    switch (action) {\n    case WCDBSyntaxConflictAction_Fail:\n        return Syntax::ConflictAction::Fail;\n    case WCDBSyntaxConflictAction_Abort:\n        return Syntax::ConflictAction::Abort;\n    case WCDBSyntaxConflictAction_Ignore:\n        return Syntax::ConflictAction::Ignore;\n    case WCDBSyntaxConflictAction_Replace:\n        return Syntax::ConflictAction::Replace;\n    case WCDBSyntaxConflictAction_Rollback:\n        return Syntax::ConflictAction::Rollback;\n    }\n}\n\nSyntax::CompoundOperator\nWinqBridge::changeCompoundOperator(enum WCDBSyntaxCompoundOperator compound)\n{\n    switch (compound) {\n    case WCDBSyntaxCompoundOperator_Union:\n        return Syntax::CompoundOperator::Union;\n    case WCDBSyntaxCompoundOperator_Except:\n        return Syntax::CompoundOperator::Except;\n    case WCDBSyntaxCompoundOperator_Intersect:\n        return Syntax::CompoundOperator::Intersect;\n    case WCDBSyntaxCompoundOperator_UnionAll:\n        return Syntax::CompoundOperator::UnionAll;\n    }\n}\n\nSyntax::JoinOperator WinqBridge::changeJoinOperator(enum WCDBSyntaxJoinOperator join)\n{\n    switch (join) {\n    case WCDBSyntaxJoinOperator_Join:\n        return Syntax::JoinOperator::Join;\n    case WCDBSyntaxJoinOperator_With:\n        return Syntax::JoinOperator::With;\n    case WCDBSyntaxJoinOperator_LeftJoin:\n        return Syntax::JoinOperator::LeftJoin;\n    case WCDBSyntaxJoinOperator_LeftOuterJoin:\n        return Syntax::JoinOperator::LeftOuterJoin;\n    case WCDBSyntaxJoinOperator_CrossJoin:\n        return Syntax::JoinOperator::CrossJoin;\n    case WCDBSyntaxJoinOperator_InnerJoin:\n        return Syntax::JoinOperator::InnerJoin;\n    case WCDBSyntaxJoinOperator_NaturalJoin:\n        return Syntax::JoinOperator::NaturalJoin;\n    case WCDBSyntaxJoinOperator_NaturalLeftJoin:\n        return Syntax::JoinOperator::NaturalLeftJoin;\n    case WCDBSyntaxJoinOperator_NaturalLeftOuterJoin:\n        return Syntax::JoinOperator::NaturalLeftOuterJoin;\n    case WCDBSyntaxJoinOperator_NaturalInnerJoin:\n        return Syntax::JoinOperator::NaturalInnerJoin;\n    case WCDBSyntaxJoinOperator_NaturalCrossJoin:\n        return Syntax::JoinOperator::NaturalCrossJoin;\n    }\n}\n\nSyntax::LimitParameterType\nWinqBridge::changeLimitParameterType(enum WCDBSyntaxLimitParameterType type)\n{\n    switch (type) {\n    case WCDBSyntaxLimitParameterType_End:\n        return Syntax::LimitParameterType::End;\n    case WCDBSyntaxLimitParameterType_NotSet:\n        return Syntax::LimitParameterType::NotSet;\n    case WCDBSyntaxLimitParameterType_Offset:\n        return Syntax::LimitParameterType::Offset;\n    }\n}\n\nMatchType WinqBridge::changeMatchType(enum WCDBSyntaxMatchType type)\n{\n    switch (type) {\n    case WCDBSyntaxMatchType_Full:\n        return MatchType::Full;\n    case WCDBSyntaxMatchType_Simple:\n        return MatchType::Simple;\n    case WCDBSyntaxMatchType_Partial:\n        return MatchType::Partial;\n    }\n}\n\nColumnType WinqBridge::changeColumnType(enum WCDBSyntaxColumnType type)\n{\n    switch (type) {\n    case WCDBSyntaxColumnType_Null:\n        return ColumnType::Null;\n    case WCDBSyntaxColumnType_Integer:\n        return ColumnType::Integer;\n    case WCDBSyntaxColumnType_Float:\n        return ColumnType::Float;\n    case WCDBSyntaxColumnType_Text:\n        return ColumnType::Text;\n    case WCDBSyntaxColumnType_BLOB:\n        return ColumnType::BLOB;\n    }\n}\n\nSchema WinqBridge::createSchema(CPPCommonValue schema)\n{\n    switch (schema.type) {\n    case WCDBBridgedType_String:\n        return Schema((const char*) schema.intValue);\n    case WCDBBridgedType_Schema:\n        return WCDBGetBridgedData(WCDB::Schema, schema);\n    default:\n        assert(schema.type == WCDBBridgedType_Null);\n        return Schema();\n    }\n}\n\nLiteralValue WinqBridge::createLiteralValue(CPPCommonValue data)\n{\n    switch (data.type) {\n    case WCDBBridgedType_Null:\n        return LiteralValue(nullptr);\n    case WCDBBridgedType_Bool:\n        return LiteralValue((bool) data.intValue);\n    case WCDBBridgedType_Int:\n        return LiteralValue((int64_t) data.intValue);\n    case WCDBBridgedType_UInt:\n        return LiteralValue((uint64_t) data.intValue);\n    case WCDBBridgedType_Double:\n        return LiteralValue(data.doubleValue);\n    case WCDBBridgedType_String:\n        return LiteralValue(StringView((const char*) data.intValue));\n    default:\n        assert(0);\n    }\n    return LiteralValue(nullptr);\n}\n\nExpression WinqBridge::createExpression(CPPCommonValue exp)\n{\n    switch (exp.type) {\n    case WCDBBridgedType_Null:\n        return LiteralValue(nullptr);\n    case WCDBBridgedType_Bool:\n        return LiteralValue((bool) exp.intValue);\n    case WCDBBridgedType_Int:\n        return LiteralValue((int64_t) exp.intValue);\n    case WCDBBridgedType_UInt:\n        return LiteralValue((uint64_t) exp.intValue);\n    case WCDBBridgedType_Double:\n        return LiteralValue(exp.doubleValue);\n    case WCDBBridgedType_String:\n        return LiteralValue(StringView((const char*) exp.intValue));\n    case WCDBBridgedType_Column:\n        return WCDBGetBridgedData(WCDB::Column, exp);\n    case WCDBBridgedType_BindParameter:\n        return WCDBGetBridgedData(WCDB::BindParameter, exp);\n    case WCDBBridgedType_LiteralValue:\n        return WCDBGetBridgedData(WCDB::LiteralValue, exp);\n    case WCDBBridgedType_RaiseFunction:\n        return WCDBGetBridgedData(WCDB::RaiseFunction, exp);\n    case WCDBBridgedType_Expression:\n        return WCDBGetBridgedData(WCDB::Expression, exp);\n        break;\n    default:\n        assert(0);\n        break;\n    }\n    return Expression();\n}\n\nTableOrSubquery WinqBridge::createTableOrSubquery(CPPCommonValue tableOrSubquery)\n{\n    switch (tableOrSubquery.type) {\n    case WCDBBridgedType_String:\n        return StringView((const char*) tableOrSubquery.intValue);\n    case WCDBBridgedType_TableOrSubquery:\n        return WCDBGetBridgedData(TableOrSubquery, tableOrSubquery);\n    case WCDBBridgedType_SelectSTMT:\n        return WCDBGetBridgedData(StatementSelect, tableOrSubquery);\n    case WCDBBridgedType_JoinClause:\n        return WCDBGetBridgedData(Join, tableOrSubquery);\n    default:\n        break;\n    }\n    assert(tableOrSubquery.type == WCDBBridgedType_Null);\n    return TableOrSubquery();\n}\n\nColumn WinqBridge::createColumn(CPPCommonValue column)\n{\n    switch (column.type) {\n    case WCDBBridgedType_String:\n        return StringView((const char*) column.intValue);\n    case WCDBBridgedType_Column:\n        return WCDBGetBridgedData(WCDB::Column, column);\n    default:\n        assert(column.type == WCDBBridgedType_Null);\n        return Column();\n    }\n}\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/bridge/winqbridge/WinqBridge.h",
    "content": "//\n// Created by qiuwenchen on 2022/5/26.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n#pragma once\n\n#include \"ObjectBridge.h\"\n\nWCDB_EXTERN_C_BEGIN\n\nconst char* _Nonnull WCDBWinqGetDescription(CPPObject* _Nonnull statement);\n\nenum WCDBSyntaxOrder {\n    WCDBSyntaxOrder_Asc = 1,\n    WCDBSyntaxOrder_Desc,\n};\n\nenum WCDBSyntaxConflictAction {\n    WCDBSyntaxConflictAction_Replace = 1,\n    WCDBSyntaxConflictAction_Rollback,\n    WCDBSyntaxConflictAction_Abort,\n    WCDBSyntaxConflictAction_Fail,\n    WCDBSyntaxConflictAction_Ignore,\n};\n\nenum WCDBSyntaxCompoundOperator {\n    WCDBSyntaxCompoundOperator_Union = 1,\n    WCDBSyntaxCompoundOperator_UnionAll,\n    WCDBSyntaxCompoundOperator_Intersect,\n    WCDBSyntaxCompoundOperator_Except,\n};\n\nenum WCDBSyntaxJoinOperator {\n    WCDBSyntaxJoinOperator_With = 1,\n    WCDBSyntaxJoinOperator_Join,\n    WCDBSyntaxJoinOperator_LeftOuterJoin,\n    WCDBSyntaxJoinOperator_LeftJoin,\n    WCDBSyntaxJoinOperator_InnerJoin,\n    WCDBSyntaxJoinOperator_CrossJoin,\n    WCDBSyntaxJoinOperator_NaturalJoin,\n    WCDBSyntaxJoinOperator_NaturalLeftOuterJoin,\n    WCDBSyntaxJoinOperator_NaturalLeftJoin,\n    WCDBSyntaxJoinOperator_NaturalInnerJoin,\n    WCDBSyntaxJoinOperator_NaturalCrossJoin,\n};\n\nenum WCDBSyntaxLimitParameterType {\n    WCDBSyntaxLimitParameterType_NotSet = 0,\n    WCDBSyntaxLimitParameterType_Offset,\n    WCDBSyntaxLimitParameterType_End,\n};\n\nenum WCDBSyntaxMatchType {\n    WCDBSyntaxMatchType_Simple = 1,\n    WCDBSyntaxMatchType_Full,\n    WCDBSyntaxMatchType_Partial,\n};\n\nenum WCDBSyntaxColumnType {\n    WCDBSyntaxColumnType_Null = 0,\n    WCDBSyntaxColumnType_Integer,\n    WCDBSyntaxColumnType_Float,\n    WCDBSyntaxColumnType_Text,\n    WCDBSyntaxColumnType_BLOB,\n};\n\nenum WCDBSyntaxTransactionType {\n    WCDBSyntaxTransactionType_Deferred = 0,\n    WCDBSyntaxTransactionType_Immediate,\n    WCDBSyntaxTransactionType_Exclusive,\n};\n\nbool WCDBStatementNeedToWrite(CPPObject* _Nonnull statement);\n\nWCDBDefineCPPBridgedType(CPPBindParameter);\nWCDBDefineCPPBridgedType(CPPColumn);\nWCDBDefineCPPBridgedType(CPPColumnConstraint);\nWCDBDefineCPPBridgedType(CPPColumnDef);\nWCDBDefineCPPBridgedType(CPPCommonTableExpression);\nWCDBDefineCPPBridgedType(CPPExpression);\nWCDBDefineCPPBridgedType(CPPFilter);\nWCDBDefineCPPBridgedType(CPPForeignKey);\nWCDBDefineCPPBridgedType(CPPFrameSpec);\nWCDBDefineCPPBridgedType(CPPIndexedColumn);\nWCDBDefineCPPBridgedType(CPPJoin);\nWCDBDefineCPPBridgedType(CPPLiteralValue);\nWCDBDefineCPPBridgedType(CPPOrderingTerm);\nWCDBDefineCPPBridgedType(CPPPragma);\nWCDBDefineCPPBridgedType(CPPQualifiedTable);\nWCDBDefineCPPBridgedType(CPPRaiseFunction);\nWCDBDefineCPPBridgedType(CPPResultColumn);\nWCDBDefineCPPBridgedType(CPPSchema);\nWCDBDefineCPPBridgedType(CPPTableConstraint);\nWCDBDefineCPPBridgedType(CPPTableOrSubquery);\nWCDBDefineCPPBridgedType(CPPUpsert);\nWCDBDefineCPPBridgedType(CPPWindowDef);\n\nWCDBDefineCPPBridgedType(CPPStatementAlterTable);\nWCDBDefineCPPBridgedType(CPPStatementAnalyze);\nWCDBDefineCPPBridgedType(CPPStatementAttach);\nWCDBDefineCPPBridgedType(CPPStatementBegin);\nWCDBDefineCPPBridgedType(CPPStatementCommit);\nWCDBDefineCPPBridgedType(CPPStatementCreateIndex);\nWCDBDefineCPPBridgedType(CPPStatementCreateTable);\nWCDBDefineCPPBridgedType(CPPStatementCreateTrigger);\nWCDBDefineCPPBridgedType(CPPStatementCreateView);\nWCDBDefineCPPBridgedType(CPPStatementCreateVirtualTable);\nWCDBDefineCPPBridgedType(CPPStatementDelete);\nWCDBDefineCPPBridgedType(CPPStatementDetach);\nWCDBDefineCPPBridgedType(CPPStatementDropIndex);\nWCDBDefineCPPBridgedType(CPPStatementDropTable);\nWCDBDefineCPPBridgedType(CPPStatementDropTrigger);\nWCDBDefineCPPBridgedType(CPPStatementDropView);\nWCDBDefineCPPBridgedType(CPPStatementExplain);\nWCDBDefineCPPBridgedType(CPPStatementInsert);\nWCDBDefineCPPBridgedType(CPPStatementPragma);\nWCDBDefineCPPBridgedType(CPPStatementReIndex);\nWCDBDefineCPPBridgedType(CPPStatementRelease);\nWCDBDefineCPPBridgedType(CPPStatementRollback);\nWCDBDefineCPPBridgedType(CPPStatementSavepoint);\nWCDBDefineCPPBridgedType(CPPStatementSelect);\nWCDBDefineCPPBridgedType(CPPStatementUpdate);\nWCDBDefineCPPBridgedType(CPPStatementVacuum);\n\nWCDB_EXTERN_C_END\n"
  },
  {
    "path": "src/bridge/winqbridge/WinqBridge.hpp",
    "content": "//\n// Created by qiuwenchen on 2022/5/29.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"ObjectBridge.hpp\"\n#include \"SyntaxForwardDeclaration.h\"\n#include \"SyntaxList.hpp\"\n#include \"WinqBridge.h\"\n\n#define WCDBGetCPPSyntaxList(CPPObjType, cppList, rawList, rawCount)           \\\n    WCDB::SyntaxList<CPPObjType> cppList                                       \\\n    = WCDB::WinqBridge::createSyntaxList<CPPObjType>(rawList, rawCount);\n\n#define WCDBGetCPPSyntaxListOrReturn(CPPObjType, cppList, rawList, rawCount)   \\\n    WCDBGetCPPSyntaxList(CPPObjType, cppList, rawList, rawCount);              \\\n    if (cppList.size() <= 0) {                                                 \\\n        return;                                                                \\\n    }\n\n#define WCDBCreateSchemaFromCommonValue(data)                                  \\\n    WCDB::WinqBridge::createSchema(data)\n#define WCDBCreateLiteralValueFromCommonValue(data)                            \\\n    WCDB::WinqBridge::createLiteralValue(data)\n#define WCDBCreateExpressionFromCommonValue(data)                              \\\n    WCDB::WinqBridge::createExpression(data)\n#define WCDBCreateTableOrSubqueryFromCommonValue(data)                         \\\n    WCDB::WinqBridge::createTableOrSubquery(data)\n#define WCDBCreateColumnFromCommonValue(data)                                  \\\n    WCDB::WinqBridge::createColumn(data)\n\nnamespace WCDB {\n\nclass WinqBridge {\npublic:\n    static Order changeOrder(enum WCDBSyntaxOrder order);\n    static Conflict changeConflict(enum WCDBSyntaxConflictAction action);\n    static Syntax::ConflictAction\n    changeConflictAction(enum WCDBSyntaxConflictAction action);\n    static Syntax::CompoundOperator\n    changeCompoundOperator(enum WCDBSyntaxCompoundOperator compound);\n    static Syntax::JoinOperator changeJoinOperator(enum WCDBSyntaxJoinOperator join);\n    static Syntax::LimitParameterType\n    changeLimitParameterType(enum WCDBSyntaxLimitParameterType type);\n    static MatchType changeMatchType(enum WCDBSyntaxMatchType type);\n    static ColumnType changeColumnType(enum WCDBSyntaxColumnType type);\n\n    template<typename T, typename U>\n    static SyntaxList<T> createSyntaxList(const U* itemArr, int itemCount)\n    {\n        SyntaxList<T> result;\n        if (itemArr == nullptr || itemCount <= 0) {\n            return result;\n        }\n        for (int i = 0; i < itemCount; i++) {\n            const U& item = itemArr[i];\n            T* typedObjName\n            = (T*) WCDB::ObjectBridge::extractOriginalCPPObject(item.innerValue);\n            if (typedObjName == nullptr) {\n                continue;\n            }\n            result.push_back(*typedObjName);\n        }\n        return result;\n    }\n\n    static Schema createSchema(CPPCommonValue schema);\n    static LiteralValue createLiteralValue(CPPCommonValue data);\n    static Expression createExpression(CPPCommonValue exp);\n    static TableOrSubquery createTableOrSubquery(CPPCommonValue tableOrSubquery);\n    static Column createColumn(CPPCommonValue column);\n};\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/bridge/winqbridge/identifier/BindParameterBridge.cpp",
    "content": "//\n// Created by qiuwenchen on 2022/5/27.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"BindParameterBridge.h\"\n#include \"BindParameter.hpp\"\n#include \"ObjectBridge.hpp\"\n\nCPPBindParameter WCDBBindparameterCreateQuestionSignType(int num)\n{\n    return WCDBCreateCPPBridgedObjectWithParameters(\n    CPPBindParameter, WCDB::BindParameter, num);\n}\n\nCPPBindParameter WCDBBindparameterCreateAtSignType(const char* _Nullable name)\n{\n    return WCDBCreateCPPBridgedObjectByCopy(CPPBindParameter,\n                                            WCDB::BindParameter::at(name));\n}\n\nCPPBindParameter WCDBBindparameterCreateColonSignType(const char* _Nullable name)\n{\n    return WCDBCreateCPPBridgedObjectByCopy(CPPBindParameter,\n                                            WCDB::BindParameter::colon(name));\n}\n\nCPPBindParameter WCDBBindparameterCreateDollarSignType(const char* _Nullable name)\n{\n    return WCDBCreateCPPBridgedObjectByCopy(CPPBindParameter,\n                                            WCDB::BindParameter::dollar(name));\n}\n"
  },
  {
    "path": "src/bridge/winqbridge/identifier/BindParameterBridge.h",
    "content": "//\n// Created by qiuwenchen on 2022/5/27.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"WinqBridge.h\"\n\nWCDB_EXTERN_C_BEGIN\n\nCPPBindParameter WCDBBindparameterCreateQuestionSignType(int num);\nCPPBindParameter WCDBBindparameterCreateAtSignType(const char* _Nullable name);\nCPPBindParameter WCDBBindparameterCreateColonSignType(const char* _Nullable name);\nCPPBindParameter WCDBBindparameterCreateDollarSignType(const char* _Nullable name);\n\nWCDB_EXTERN_C_END\n"
  },
  {
    "path": "src/bridge/winqbridge/identifier/ColumnBridge.cpp",
    "content": "//\n// Created by qiuwenchen on 2022/5/26.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"ColumnBridge.h\"\n#include \"Column.hpp\"\n#include \"Expression.hpp\"\n#include \"ObjectBridge.hpp\"\n#include \"ResultColumn.hpp\"\n#include \"Schema.hpp\"\n#include \"WinqBridge.hpp\"\n\nCPPColumn WCDBColumnCreateAll()\n{\n    return WCDBCreateCPPBridgedObjectByCopy(CPPColumn, WCDB::Column::all());\n}\n\nCPPColumn WCDBColumnCreateRowId()\n{\n    return WCDBCreateCPPBridgedObjectByCopy(CPPColumn, WCDB::Column::rowid());\n}\n\nCPPColumn WCDBColumnCreateWithName(const char* _Nullable name, const void* _Nullable binding)\n{\n    return WCDBCreateCPPBridgedObjectWithParameters(\n    CPPColumn, WCDB::Column, name, static_cast<const WCDB::BaseBinding*>(binding));\n}\n\nCPPColumn WCDBColumnCopy(CPPColumn column)\n{\n    WCDBGetObjectOrReturnValue(column, WCDB::Column, cppColumn, CPPColumn());\n    return WCDBCreateCPPBridgedObjectByCopy(CPPColumn, *cppColumn);\n}\n\nCPPColumn WCDBColumnCreateWithName2(const char* _Nullable name, const void* _Nullable binding)\n{\n    if (binding == nullptr) {\n        return WCDBCreateCPPBridgedObjectWithParameters(\n        CPPColumn, WCDB::Column, name, static_cast<const WCDB::BaseBinding*>(binding));\n    } else {\n        return WCDBCreateCPPBridgedObjectWithParameters(\n        CPPColumn,\n        WCDB::Column,\n        WCDB::StringView::createConstant(name),\n        static_cast<const WCDB::BaseBinding*>(binding));\n    }\n}\n\nvoid WCDBColumnInTable(CPPColumn column, const char* _Nullable table)\n{\n    WCDBGetObjectOrReturn(column, WCDB::Column, cppColumn);\n    cppColumn->table(table);\n}\n\nvoid WCDBColumnOfSchema(CPPColumn column, CPPSchema schema)\n{\n    WCDBGetObjectOrReturn(column, WCDB::Column, cppColumn);\n    WCDBGetObjectOrReturn(schema, WCDB::Schema, cppSchema);\n    cppColumn->schema(*cppSchema);\n}\n\nvoid WCDBColumnOfSchema2(CPPColumn column, CPPCommonValue schema)\n{\n    WCDBGetObjectOrReturn(column, WCDB::Column, cppColumn);\n    cppColumn->schema(WCDBCreateSchemaFromCommonValue(schema));\n}\n\nCPPResultColumn WCDBColumnConfigAlias(CPPColumn column, const char* _Nullable alias)\n{\n    WCDBGetObjectOrReturnValue(column, WCDB::Column, cppColumn, CPPResultColumn());\n    return WCDBCreateCPPBridgedObjectByCopy(\n    CPPResultColumn, cppColumn->as(WCDB::UnsafeStringView(alias)));\n}\n\nCPPExpression WCDBColumnAsExpressionOperand(CPPColumn column)\n{\n    WCDBGetObjectOrReturnValue(column, WCDB::Column, cppColumn, CPPExpression());\n    return WCDBCreateCPPBridgedObjectWithParameters(\n    CPPExpression, WCDB::Expression, *cppColumn);\n}\n"
  },
  {
    "path": "src/bridge/winqbridge/identifier/ColumnBridge.h",
    "content": "//\n// Created by qiuwenchen on 2022/5/26.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"WinqBridge.h\"\n\nWCDB_EXTERN_C_BEGIN\n\nCPPColumn WCDBColumnCreateAll();\nCPPColumn WCDBColumnCreateRowId();\nCPPColumn WCDBColumnCreateWithName(const char* _Nullable name, const void* _Nullable binding);\nCPPColumn WCDBColumnCreateWithName2(const char* _Nullable name, const void* _Nullable binding);\nCPPColumn WCDBColumnCopy(CPPColumn column);\nvoid WCDBColumnInTable(CPPColumn column, const char* _Nullable table);\nvoid WCDBColumnOfSchema(CPPColumn column, CPPSchema schema);\nvoid WCDBColumnOfSchema2(CPPColumn column, CPPCommonValue schema);\nCPPResultColumn WCDBColumnConfigAlias(CPPColumn column, const char* _Nullable alias);\nCPPExpression WCDBColumnAsExpressionOperand(CPPColumn column);\n\nWCDB_EXTERN_C_END\n"
  },
  {
    "path": "src/bridge/winqbridge/identifier/ColumnConstraintBridge.cpp",
    "content": "//\n// Created by qiuwenchen on 2022/5/29.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"ColumnConstraintBridge.h\"\n#include \"Column.hpp\"\n#include \"ColumnConstraint.hpp\"\n#include \"Expression.hpp\"\n#include \"ExpressionBridge.h\"\n#include \"ForeignKey.hpp\"\n#include \"LiteralValue.hpp\"\n#include \"ObjectBridge.hpp\"\n#include \"RaiseFunction.hpp\"\n#include \"StatementSelect.hpp\"\n#include \"WinqBridge.hpp\"\n\nCPPColumnConstraint WCDBColumnConstraintCreate(const char* _Nullable name)\n{\n    return WCDBCreateCPPBridgedObjectWithParameters(\n    CPPColumnConstraint, WCDB::ColumnConstraint, name);\n}\n\nvoid WCDBColumnConstraintConfigPrimaryKey(CPPColumnConstraint constraint)\n{\n    WCDBGetObjectOrReturn(constraint, WCDB::ColumnConstraint, cppColumnConstraint);\n    cppColumnConstraint->primaryKey();\n}\n\nvoid WCDBColumnConstraintConfigOrder(CPPColumnConstraint constraint, WCDBSyntaxOrder order)\n{\n    WCDBGetObjectOrReturn(constraint, WCDB::ColumnConstraint, cppColumnConstraint);\n    switch (order) {\n    case WCDBSyntaxOrder_Asc:\n        cppColumnConstraint->order(WCDB::Order::ASC);\n        break;\n    case WCDBSyntaxOrder_Desc:\n        cppColumnConstraint->order(WCDB::Order::DESC);\n        break;\n    default:\n        break;\n    }\n}\n\nvoid WCDBColumnConstraintConfigCoflictAction(CPPColumnConstraint constraint,\n                                             WCDBSyntaxConflictAction conflictAction)\n{\n    WCDBGetObjectOrReturn(constraint, WCDB::ColumnConstraint, cppColumnConstraint);\n    cppColumnConstraint->conflict(WCDB::WinqBridge::changeConflict(conflictAction));\n}\n\nvoid WCDBColumnConstraintConfigAutoIncrement(CPPColumnConstraint constraint)\n{\n    WCDBGetObjectOrReturn(constraint, WCDB::ColumnConstraint, cppColumnConstraint);\n    cppColumnConstraint->autoIncrement();\n}\n\nvoid WCDBColumnConstraintConfigNotNull(CPPColumnConstraint constraint)\n{\n    WCDBGetObjectOrReturn(constraint, WCDB::ColumnConstraint, cppColumnConstraint);\n    cppColumnConstraint->notNull();\n}\nvoid WCDBColumnConstraintConfigUnique(CPPColumnConstraint constraint)\n{\n    WCDBGetObjectOrReturn(constraint, WCDB::ColumnConstraint, cppColumnConstraint);\n    cppColumnConstraint->unique();\n}\nvoid WCDBColumnConstraintConfigCheck(CPPColumnConstraint constraint, CPPExpression expression)\n{\n    WCDBGetObjectOrReturn(constraint, WCDB::ColumnConstraint, cppColumnConstraint);\n    WCDBGetObjectOrReturn(expression, WCDB::Expression, cppExpression);\n    cppColumnConstraint->check(*cppExpression);\n}\n\nvoid WCDBColumnConstraintConfigDefaultValue(CPPColumnConstraint constraint, CPPExpression expression)\n{\n    WCDBGetObjectOrReturn(constraint, WCDB::ColumnConstraint, cppColumnConstraint);\n    WCDBGetObjectOrReturn(expression, WCDB::Expression, cppExpression);\n    cppColumnConstraint->default_(*cppExpression);\n}\n\nvoid WCDBColumnConstraintConfigDefaultValue2(CPPColumnConstraint constraint, CPPCommonValue expression)\n{\n    WCDBGetObjectOrReturn(constraint, WCDB::ColumnConstraint, cppColumnConstraint);\n    cppColumnConstraint->default_(WCDBCreateExpressionFromCommonValue(expression));\n}\n\nvoid WCDBColumnConstraintConfigCollation(CPPColumnConstraint constraint, const char* collation)\n{\n    WCDBGetObjectOrReturn(constraint, WCDB::ColumnConstraint, cppColumnConstraint);\n    cppColumnConstraint->collate(collation);\n}\n\nvoid WCDBColumnConstraintConfigForeignKey(CPPColumnConstraint constraint, CPPForeignKey foreignKey)\n{\n    WCDBGetObjectOrReturn(constraint, WCDB::ColumnConstraint, cppColumnConstraint);\n    WCDBGetObjectOrReturn(foreignKey, WCDB::ForeignKey, cppObj);\n    cppColumnConstraint->foreignKey(*cppObj);\n}\n\nvoid WCDBColumnConstraintConfigUnIndexed(CPPColumnConstraint constraint)\n{\n    WCDBGetObjectOrReturn(constraint, WCDB::ColumnConstraint, cppConstraint);\n    cppConstraint->unIndexed();\n}\n"
  },
  {
    "path": "src/bridge/winqbridge/identifier/ColumnConstraintBridge.h",
    "content": "//\n// Created by qiuwenchen on 2022/5/29.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"WinqBridge.h\"\n\nWCDB_EXTERN_C_BEGIN\n\nCPPColumnConstraint WCDBColumnConstraintCreate(const char* _Nullable name);\nvoid WCDBColumnConstraintConfigPrimaryKey(CPPColumnConstraint constraint);\nvoid WCDBColumnConstraintConfigOrder(CPPColumnConstraint constraint,\n                                     enum WCDBSyntaxOrder order);\nvoid WCDBColumnConstraintConfigCoflictAction(CPPColumnConstraint constraint,\n                                             enum WCDBSyntaxConflictAction conflictAction);\nvoid WCDBColumnConstraintConfigAutoIncrement(CPPColumnConstraint constraint);\nvoid WCDBColumnConstraintConfigNotNull(CPPColumnConstraint constraint);\nvoid WCDBColumnConstraintConfigUnique(CPPColumnConstraint constraint);\nvoid WCDBColumnConstraintConfigCheck(CPPColumnConstraint constraint, CPPExpression expression);\nvoid WCDBColumnConstraintConfigDefaultValue(CPPColumnConstraint constraint,\n                                            CPPExpression expression);\nvoid WCDBColumnConstraintConfigDefaultValue2(CPPColumnConstraint constraint,\n                                             CPPCommonValue expression);\nvoid WCDBColumnConstraintConfigCollation(CPPColumnConstraint constraint,\n                                         const char* _Nullable collation);\nvoid WCDBColumnConstraintConfigForeignKey(CPPColumnConstraint constraint,\n                                          CPPForeignKey foreignKey);\nvoid WCDBColumnConstraintConfigUnIndexed(CPPColumnConstraint constraint);\n\nWCDB_EXTERN_C_END\n"
  },
  {
    "path": "src/bridge/winqbridge/identifier/ColumnDefBridge.cpp",
    "content": "//\n// Created by qiuwenchen on 2022/5/30.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"ColumnDefBridge.h\"\n#include \"ColumnConstraint.hpp\"\n#include \"ColumnDef.hpp\"\n#include \"ObjectBridge.hpp\"\n#include \"WinqBridge.hpp\"\n\nCPPColumnDef WCDBColumnDefCreateWithoutType2(CPPCommonValue column)\n{\n    return WCDBCreateCPPBridgedObjectWithParameters(\n    CPPColumnDef, WCDB::ColumnDef, WCDBCreateColumnFromCommonValue(column));\n}\n\nCPPColumnDef WCDBColumnDefCreateWithType2(CPPCommonValue column, enum WCDBSyntaxColumnType type)\n{\n    return WCDBCreateCPPBridgedObjectWithParameters(\n    CPPColumnDef,\n    WCDB::ColumnDef,\n    WCDBCreateColumnFromCommonValue(column),\n    WCDB::WinqBridge::changeColumnType(type));\n}\n\nCPPColumnDef WCDBColumnDefCreateWithoutType(CPPColumn column)\n{\n    WCDBGetObjectOrReturnValue(column, WCDB::Column, cppColumn, CPPColumnDef());\n    return WCDBCreateCPPBridgedObjectWithParameters(CPPColumnDef, WCDB::ColumnDef, *cppColumn);\n}\n\nCPPColumnDef WCDBColumnDefCreateWithType(CPPColumn column, enum WCDBSyntaxColumnType type)\n{\n    WCDBGetObjectOrReturnValue(column, WCDB::Column, cppColumn, CPPColumnDef());\n    return WCDBCreateCPPBridgedObjectWithParameters(\n    CPPColumnDef, WCDB::ColumnDef, *cppColumn, WCDB::WinqBridge::changeColumnType(type));\n}\n\nvoid WCDBColumnDefConfigConstraint(CPPColumnDef columnDef, CPPColumnConstraint constraint)\n{\n    WCDBGetObjectOrReturn(columnDef, WCDB::ColumnDef, cppColumnDef);\n    WCDBGetObjectOrReturn(constraint, WCDB::ColumnConstraint, cppColumnConstraint);\n    cppColumnDef->constraint(*cppColumnConstraint);\n}\n"
  },
  {
    "path": "src/bridge/winqbridge/identifier/ColumnDefBridge.h",
    "content": "//\n// Created by qiuwenchen on 2022/5/30.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"WinqBridge.h\"\n\nWCDB_EXTERN_C_BEGIN\n\nCPPColumnDef WCDBColumnDefCreateWithoutType2(CPPCommonValue commonValue);\nCPPColumnDef\nWCDBColumnDefCreateWithType2(CPPCommonValue column, enum WCDBSyntaxColumnType type);\n\nCPPColumnDef WCDBColumnDefCreateWithoutType(CPPColumn column);\nCPPColumnDef WCDBColumnDefCreateWithType(CPPColumn column, enum WCDBSyntaxColumnType type);\nvoid WCDBColumnDefConfigConstraint(CPPColumnDef columnDef, CPPColumnConstraint constraint);\n\nWCDB_EXTERN_C_END\n"
  },
  {
    "path": "src/bridge/winqbridge/identifier/CommonTableExpressionBridge.cpp",
    "content": "//\n// Created by qiuwenchen on 2022/5/30.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"CommonTableExpressionBridge.h\"\n#include \"CommonTableExpression.hpp\"\n#include \"ObjectBridge.hpp\"\n#include \"StatementSelect.hpp\"\n#include \"WinqBridge.hpp\"\n\nCPPCommonTableExpression WCDBCommonTableExpressionCreate(const char* _Nullable tableName)\n{\n    return WCDBCreateCPPBridgedObjectByCopy(\n    CPPCommonTableExpression, WCDB::CommonTableExpression(tableName));\n}\n\nvoid WCDBCommonTableExpressionAddColumn(CPPCommonTableExpression expression, CPPColumn column)\n{\n    WCDBGetObjectOrReturn(expression, WCDB::CommonTableExpression, cppCTE);\n    WCDBGetObjectOrReturn(column, WCDB::Column, cppColumn);\n    cppCTE->column(*cppColumn);\n}\n\nvoid WCDBCommonTableExpressionAsSelection(CPPCommonTableExpression expression,\n                                          CPPStatementSelect select)\n{\n    WCDBGetObjectOrReturn(expression, WCDB::CommonTableExpression, cppCTE);\n    WCDBGetObjectOrReturn(select, WCDB::StatementSelect, cppSelect);\n    cppCTE->as(*cppSelect);\n}\n"
  },
  {
    "path": "src/bridge/winqbridge/identifier/CommonTableExpressionBridge.h",
    "content": "//\n// Created by qiuwenchen on 2022/5/30.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"WinqBridge.h\"\n\nWCDB_EXTERN_C_BEGIN\n\nCPPCommonTableExpression WCDBCommonTableExpressionCreate(const char* _Nullable tableName);\nvoid WCDBCommonTableExpressionAddColumn(CPPCommonTableExpression expression, CPPColumn column);\nvoid WCDBCommonTableExpressionAsSelection(CPPCommonTableExpression expression,\n                                          CPPStatementSelect select);\n\nWCDB_EXTERN_C_END\n"
  },
  {
    "path": "src/bridge/winqbridge/identifier/ExpressionBridge.cpp",
    "content": "//\n// Created by qiuwenchen on 2022/5/26.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"ExpressionBridge.h\"\n#include \"BindParameter.hpp\"\n#include \"Column.hpp\"\n#include \"Expression.hpp\"\n#include \"Filter.hpp\"\n#include \"LiteralValue.hpp\"\n#include \"ObjectBridge.hpp\"\n#include \"RaiseFunction.hpp\"\n#include \"ResultColumn.hpp\"\n#include \"Schema.hpp\"\n#include \"StatementSelect.hpp\"\n#include \"SyntaxForwardDeclaration.h\"\n#include \"WindowDef.hpp\"\n#include \"WinqBridge.hpp\"\n\nCPPExpression WCDBExpressionCreateWithBool(bool value)\n{\n    return WCDBCreateCPPBridgedObjectWithParameters(\n    CPPExpression, WCDB::Expression, WCDB::LiteralValue(value));\n}\n\nCPPExpression WCDBExpressionCreateWithLong(long long value)\n{\n    return WCDBCreateCPPBridgedObjectWithParameters(\n    CPPExpression, WCDB::Expression, WCDB::LiteralValue((int64_t) value));\n}\n\nCPPExpression WCDBExpressionCreateWithDouble(double value)\n{\n    return WCDBCreateCPPBridgedObjectWithParameters(\n    CPPExpression, WCDB::Expression, WCDB::LiteralValue(value));\n}\n\nCPPExpression WCDBExpressionCreateWithString(const char* _Nullable value)\n{\n    return WCDBCreateCPPBridgedObjectWithParameters(\n    CPPExpression, WCDB::Expression, WCDB::LiteralValue(value));\n}\n\nCPPExpression WCDBExpressionCreateWithLiteralValue(CPPLiteralValue value)\n{\n    WCDBGetObjectOrReturnValue(value, WCDB::LiteralValue, cppValue, CPPExpression());\n    return WCDBCreateCPPBridgedObjectWithParameters(\n    CPPExpression, WCDB::Expression, *cppValue);\n}\n\nCPPExpression WCDBExpressionCreateWithBindParameter(CPPBindParameter value)\n{\n    WCDBGetObjectOrReturnValue(value, WCDB::BindParameter, cppValue, CPPExpression());\n    return WCDBCreateCPPBridgedObjectWithParameters(\n    CPPExpression, WCDB::Expression, *cppValue);\n}\n\nCPPExpression WCDBExpressionCreateWithColumn(CPPColumn column)\n{\n    WCDBGetObjectOrReturnValue(column, WCDB::Column, cppColumn, CPPExpression());\n    return WCDBCreateCPPBridgedObjectWithParameters(\n    CPPExpression, WCDB::Expression, *cppColumn);\n}\n\nCPPExpression WCDBExpressionCreateWithSelection(CPPStatementSelect select)\n{\n    WCDBGetObjectOrReturnValue(select, WCDB::StatementSelect, cppSelect, CPPExpression());\n    return WCDBCreateCPPBridgedObjectWithParameters(\n    CPPExpression, WCDB::Expression, *cppSelect);\n}\n\nCPPExpression WCDBExpressionCreateWithRaiseFunction(CPPRaiseFunction function)\n{\n    WCDBGetObjectOrReturnValue(function, WCDB::RaiseFunction, cppFunction, CPPExpression());\n    return WCDBCreateCPPBridgedObjectWithParameters(\n    CPPExpression, WCDB::Expression, *cppFunction);\n}\n\nCPPExpression WCDBExpressionCreateWithFunction(const char* _Nullable funcName)\n{\n    return WCDBCreateCPPBridgedObjectByCopy(\n    CPPExpression, WCDB::Expression::function(funcName));\n}\n\nCPPExpression WCDBExpressionCreate(CPPCommonValue value)\n{\n    switch (value.type) {\n    case WCDBBridgedType_Null:\n        return WCDBCreateCPPBridgedObjectWithParameters(\n        CPPExpression, WCDB::Expression, WCDB::LiteralValue(nullptr));\n    case WCDBBridgedType_Bool:\n        return WCDBCreateCPPBridgedObjectWithParameters(\n        CPPExpression, WCDB::Expression, WCDB::LiteralValue((bool) value.intValue));\n    case WCDBBridgedType_Int:\n        return WCDBCreateCPPBridgedObjectWithParameters(\n        CPPExpression, WCDB::Expression, WCDB::LiteralValue((int64_t) value.intValue));\n    case WCDBBridgedType_UInt:\n        return WCDBCreateCPPBridgedObjectWithParameters(\n        CPPExpression, WCDB::Expression, WCDB::LiteralValue((uint64_t) value.intValue));\n    case WCDBBridgedType_Double:\n        return WCDBCreateCPPBridgedObjectWithParameters(\n        CPPExpression, WCDB::Expression, WCDB::LiteralValue(value.doubleValue));\n    case WCDBBridgedType_String:\n        return WCDBCreateCPPBridgedObjectWithParameters(\n        CPPExpression, WCDB::Expression, WCDB::LiteralValue((const char*) value.intValue));\n    case WCDBBridgedType_Column:\n        return WCDBCreateCPPBridgedObjectWithParameters(\n        CPPExpression, WCDB::Expression, WCDBGetBridgedData(WCDB::Column, value));\n    case WCDBBridgedType_LiteralValue:\n        return WCDBCreateCPPBridgedObjectWithParameters(\n        CPPExpression, WCDB::Expression, WCDBGetBridgedData(WCDB::LiteralValue, value));\n    case WCDBBridgedType_BindParameter:\n        return WCDBCreateCPPBridgedObjectWithParameters(\n        CPPExpression, WCDB::Expression, WCDBGetBridgedData(WCDB::BindParameter, value));\n    case WCDBBridgedType_SelectSTMT:\n        return WCDBCreateCPPBridgedObjectWithParameters(\n        CPPExpression, WCDB::Expression, WCDBGetBridgedData(WCDB::StatementSelect, value));\n    case WCDBBridgedType_RaiseFunction:\n        return WCDBCreateCPPBridgedObjectWithParameters(\n        CPPExpression, WCDB::Expression, WCDBGetBridgedData(WCDB::RaiseFunction, value));\n    default:\n        assert(0);\n        break;\n    }\n    return CPPExpression();\n}\n\nCPPExpression WCDBExpressionCreateWithExistStatement(CPPStatementSelect select)\n{\n    WCDBGetObjectOrReturnValue(select, WCDB::StatementSelect, cppSelect, CPPExpression());\n    return WCDBCreateCPPBridgedObjectByCopy(\n    CPPExpression, WCDB::Expression::exists(*cppSelect));\n}\n\nCPPExpression WCDBExpressionCreateWithNotExistStatement(CPPStatementSelect select)\n{\n    WCDBGetObjectOrReturnValue(select, WCDB::StatementSelect, cppSelect, CPPExpression());\n    return WCDBCreateCPPBridgedObjectByCopy(\n    CPPExpression, WCDB::Expression::notExists(*cppSelect));\n}\n\nvoid WCDBExpressionSetWithSchema(CPPExpression expression, CPPSchema schema)\n{\n    WCDBGetObjectOrReturn(expression, WCDB::Expression, cppExpression);\n    WCDBGetObjectOrReturn(schema, WCDB::Schema, cppSchema);\n    cppExpression->schema(*cppSchema);\n}\n\nvoid WCDBExpressionSetWithSchema2(CPPExpression expression, CPPCommonValue schema)\n{\n    WCDBGetObjectOrReturn(expression, WCDB::Expression, cppExpression);\n    cppExpression->schema(WCDBCreateSchemaFromCommonValue(schema));\n}\n\nvoid WCDBExpressionSetArgument(CPPExpression expression, CPPCommonValue argument)\n{\n    WCDBGetObjectOrReturn(expression, WCDB::Expression, cppExpression);\n    cppExpression->argument(WCDBCreateExpressionFromCommonValue(argument));\n}\n\nvoid WCDBExpressionSetArguments(CPPExpression expression, const CPPExpression* arguments, int num)\n{\n    WCDBGetObjectOrReturn(expression, WCDB::Expression, cppExpression);\n    WCDBGetCPPSyntaxListOrReturn(WCDB::Expression, cppArgs, arguments, num);\n    cppExpression->arguments(cppArgs);\n}\n\nvoid WCDBExpressionInvoke(CPPExpression expression)\n{\n    WCDBGetObjectOrReturn(expression, WCDB::Expression, cppExpression);\n    cppExpression->invoke();\n}\n\nvoid WCDBExpressionInvokeAll(CPPExpression expression)\n{\n    WCDBGetObjectOrReturn(expression, WCDB::Expression, cppExpression);\n    cppExpression->invokeAll();\n}\n\nvoid WCDBExpressionDistinct(CPPExpression expression)\n{\n    WCDBGetObjectOrReturn(expression, WCDB::Expression, cppExpression);\n    cppExpression->distinct();\n}\n\nCPPExpression WCDBExpressionCast(CPPExpression expression)\n{\n    WCDBGetObjectOrReturnValue(expression, WCDB::Expression, cppExpression, CPPExpression());\n    return WCDBCreateCPPBridgedObjectByCopy(\n    CPPExpression, WCDB::Expression::cast(*cppExpression));\n}\n\nCPPExpression WCDBExpressionCast2(CPPCommonValue expression)\n{\n    if (expression.type == WCDBBridgedType_String) {\n        return WCDBCreateCPPBridgedObjectByCopy(\n        CPPExpression,\n        WCDB::Expression::cast(\n        WCDB::Column(WCDB::StringView((const char*) expression.intValue))));\n    } else {\n        return WCDBCreateCPPBridgedObjectByCopy(\n        CPPExpression,\n        WCDB::Expression::cast(WCDBCreateExpressionFromCommonValue(expression)));\n    }\n}\n\nvoid WCDBExpressionAs(CPPExpression expression, enum WCDBSyntaxColumnType type)\n{\n    WCDBGetObjectOrReturn(expression, WCDB::Expression, cppExpression);\n    cppExpression->as(WCDB::WinqBridge::changeColumnType(type));\n}\n\nCPPResultColumn\nWCDBExpressionConfigAlias(CPPExpression expression, const char* _Nullable alias)\n{\n    WCDBGetObjectOrReturnValue(\n    expression, WCDB::Expression, cppExpression, CPPResultColumn());\n    return WCDBCreateCPPBridgedObjectByCopy(\n    CPPResultColumn, cppExpression->as(WCDB::UnsafeStringView(alias)));\n}\n\nCPPExpression WCDBExpressionCaseWithExp(CPPExpression expression)\n{\n    WCDBGetObjectOrReturnValue(expression, WCDB::Expression, cppExpression, CPPExpression());\n    return WCDBCreateCPPBridgedObjectByCopy(\n    CPPExpression, WCDB::Expression::case_(*cppExpression));\n}\n\nCPPExpression WCDBExpressionCaseWithExp2(CPPCommonValue expression)\n{\n    if (expression.type == WCDBBridgedType_String) {\n        return WCDBCreateCPPBridgedObjectByCopy(\n        CPPExpression,\n        WCDB::Expression::case_(\n        WCDB::Column(WCDB::StringView((const char*) expression.intValue))));\n    } else {\n        return WCDBCreateCPPBridgedObjectByCopy(\n        CPPExpression,\n        WCDB::Expression::case_(WCDBCreateExpressionFromCommonValue(expression)));\n    }\n}\n\nCPPExpression WCDBExpressionCase()\n{\n    return WCDBCreateCPPBridgedObjectByCopy(CPPExpression, WCDB::Expression::case_());\n}\n\nvoid WCDBExpressionSetWithWhenExp(CPPExpression expression, CPPExpression when)\n{\n    WCDBGetObjectOrReturn(expression, WCDB::Expression, cppExpression);\n    WCDBGetObjectOrReturn(when, WCDB::Expression, cppWhen);\n    cppExpression->when(*cppWhen);\n}\n\nvoid WCDBExpressionSetWithWhenExp2(CPPExpression expression, CPPCommonValue when)\n{\n    WCDBGetObjectOrReturn(expression, WCDB::Expression, cppExpression);\n    cppExpression->when(WCDBCreateExpressionFromCommonValue(when));\n}\n\nvoid WCDBExpressionSetWithThenExp(CPPExpression expression, CPPExpression then)\n{\n    WCDBGetObjectOrReturn(expression, WCDB::Expression, cppExpression);\n    WCDBGetObjectOrReturn(then, WCDB::Expression, cppThen);\n    cppExpression->then(*cppThen);\n}\n\nvoid WCDBExpressionSetWithThenExp2(CPPExpression expression, CPPCommonValue then)\n{\n    WCDBGetObjectOrReturn(expression, WCDB::Expression, cppExpression);\n    cppExpression->then(WCDBCreateExpressionFromCommonValue(then));\n}\n\nvoid WCDBExpressionSetWithElseExp(CPPExpression expression, CPPExpression else_)\n{\n    WCDBGetObjectOrReturn(expression, WCDB::Expression, cppExpression);\n    WCDBGetObjectOrReturn(else_, WCDB::Expression, cppElse);\n    cppExpression->else_(*cppElse);\n}\n\nvoid WCDBExpressionSetWithElseExp2(CPPExpression expression, CPPCommonValue else_)\n{\n    WCDBGetObjectOrReturn(expression, WCDB::Expression, cppExpression);\n    cppExpression->else_(WCDBCreateExpressionFromCommonValue(else_));\n}\n\nvoid WCDBExpressionEscapeWith(CPPExpression expression, CPPExpression operand)\n{\n    WCDBGetObjectOrReturn(expression, WCDB::Expression, cppExpression);\n    WCDBGetObjectOrReturn(operand, WCDB::Expression, cppOperand);\n    cppExpression->escape(*cppOperand);\n}\n\nvoid WCDBExpressionEscapeWith2(CPPExpression expression, const char* operand)\n{\n    WCDBGetObjectOrReturn(expression, WCDB::Expression, cppExpression);\n    cppExpression->escape(WCDB::LiteralValue(WCDB::UnsafeStringView(operand)));\n}\n\nCPPExpression WCDBExpressionCreateWithWindowFunction(const char* _Nullable funcName)\n{\n    return WCDBCreateCPPBridgedObjectByCopy(\n    CPPExpression, WCDB::Expression::windowFunction(funcName));\n}\n\nvoid WCDBExpressionFilter(CPPExpression expression, CPPExpression condition)\n{\n    WCDBGetObjectOrReturn(expression, WCDB::Expression, cppExpression);\n    WCDBGetObjectOrReturn(condition, WCDB::Expression, cppCondition);\n    cppExpression->filter(*cppCondition);\n}\n\nvoid WCDBExpressionOverWindowDef(CPPExpression expression, CPPWindowDef def)\n{\n    WCDBGetObjectOrReturn(expression, WCDB::Expression, cppExpression);\n    WCDBGetObjectOrReturn(def, WCDB::WindowDef, cppDef);\n    cppExpression->over(*cppDef);\n}\nvoid WCDBExpressionOverWindow(CPPExpression expression, const char* _Nullable window)\n{\n    WCDBGetObjectOrReturn(expression, WCDB::Expression, cppExpression);\n    cppExpression->over(window);\n}\n"
  },
  {
    "path": "src/bridge/winqbridge/identifier/ExpressionBridge.h",
    "content": "//\n// Created by qiuwenchen on 2022/5/26.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"WinqBridge.h\"\n\nWCDB_EXTERN_C_BEGIN\n\nCPPExpression WCDBExpressionCreateWithBool(bool value);\nCPPExpression WCDBExpressionCreateWithLong(long long value);\nCPPExpression WCDBExpressionCreateWithDouble(double value);\nCPPExpression WCDBExpressionCreateWithString(const char* _Nullable value);\nCPPExpression WCDBExpressionCreateWithLiteralValue(CPPLiteralValue value);\nCPPExpression WCDBExpressionCreateWithBindParameter(CPPBindParameter value);\nCPPExpression WCDBExpressionCreateWithColumn(CPPColumn column);\nCPPExpression WCDBExpressionCreateWithSelection(CPPStatementSelect select);\nCPPExpression WCDBExpressionCreateWithRaiseFunction(CPPRaiseFunction function);\nCPPExpression WCDBExpressionCreateWithFunction(const char* _Nullable funcName);\nCPPExpression WCDBExpressionCreateWithExistStatement(CPPStatementSelect select);\nCPPExpression WCDBExpressionCreateWithNotExistStatement(CPPStatementSelect select);\n\nCPPExpression WCDBExpressionCreate(CPPCommonValue value);\n\nvoid WCDBExpressionSetWithSchema(CPPExpression expression, CPPSchema schema);\nvoid WCDBExpressionSetWithSchema2(CPPExpression expression, CPPCommonValue schema);\nvoid WCDBExpressionSetArgument(CPPExpression expression, CPPCommonValue argument);\nvoid WCDBExpressionSetArguments(CPPExpression expression,\n                                const CPPExpression* _Nullable arguments,\n                                int num);\nvoid WCDBExpressionInvoke(CPPExpression expression);\nvoid WCDBExpressionInvokeAll(CPPExpression expression);\n\nvoid WCDBExpressionDistinct(CPPExpression expression);\n\nCPPExpression WCDBExpressionCast(CPPExpression expression);\nCPPExpression WCDBExpressionCast2(CPPCommonValue expression);\nvoid WCDBExpressionAs(CPPExpression expression, enum WCDBSyntaxColumnType type);\n\nCPPResultColumn\nWCDBExpressionConfigAlias(CPPExpression expression, const char* _Nullable alias);\n\nCPPExpression WCDBExpressionCaseWithExp(CPPExpression expression);\nCPPExpression WCDBExpressionCaseWithExp2(CPPCommonValue expression);\nCPPExpression WCDBExpressionCase(void);\n\nvoid WCDBExpressionSetWithWhenExp(CPPExpression expression, CPPExpression when);\nvoid WCDBExpressionSetWithWhenExp2(CPPExpression expression, CPPCommonValue when);\nvoid WCDBExpressionSetWithThenExp(CPPExpression expression, CPPExpression then);\nvoid WCDBExpressionSetWithThenExp2(CPPExpression expression, CPPCommonValue then);\nvoid WCDBExpressionSetWithElseExp(CPPExpression expression, CPPExpression else_);\nvoid WCDBExpressionSetWithElseExp2(CPPExpression expression, CPPCommonValue else_);\n\nvoid WCDBExpressionEscapeWith(CPPExpression expression, CPPExpression operand);\nvoid WCDBExpressionEscapeWith2(CPPExpression expression, const char* _Nullable operand);\n\nCPPExpression WCDBExpressionCreateWithWindowFunction(const char* _Nullable funcName);\nvoid WCDBExpressionFilter(CPPExpression expression, CPPExpression condition);\nvoid WCDBExpressionOverWindowDef(CPPExpression expression, CPPWindowDef def);\nvoid WCDBExpressionOverWindow(CPPExpression expression, const char* _Nullable window);\n\nWCDB_EXTERN_C_END\n"
  },
  {
    "path": "src/bridge/winqbridge/identifier/ExpressionOperatableBridge.cpp",
    "content": "//\n// Created by qiuwenchen on 2022/5/31.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"ExpressionOperatableBridge.h\"\n#include \"Assertion.hpp\"\n#include \"BindParameter.hpp\"\n#include \"Column.hpp\"\n#include \"Expression.hpp\"\n#include \"LiteralValue.hpp\"\n#include \"ObjectBridge.hpp\"\n#include \"StatementSelect.hpp\"\n#include \"WinqBridge.hpp\"\n\n#define WCDBExpressionPushOperand(operand)                                     \\\n    newExpression->syntax().expressions.push_back(                             \\\n    WCDB::WinqBridge::createExpression(operand));\n\nCPPExpression WCDBExpressionUnaryOperate(CPPExpression expression,\n                                         enum WCDBExpressionUnaryOperateType operatorType)\n{\n    WCDBGetObjectOrReturnValue(expression, WCDB::Expression, cppExpression, CPPExpression());\n    WCDB::Expression::SyntaxType::UnaryOperator cppOperatorType;\n    switch (operatorType) {\n    case WCDBExpressionUnaryOperateType_Not:\n        cppOperatorType = WCDB::Expression::SyntaxType::UnaryOperator::Not;\n        break;\n    case WCDBExpressionUnaryOperateType_Negative:\n        cppOperatorType = WCDB::Expression::SyntaxType::UnaryOperator::Negative;\n        break;\n    case WCDBExpressionUnaryOperateType_Positive:\n        cppOperatorType = WCDB::Expression::SyntaxType::UnaryOperator::Positive;\n        break;\n    case WCDBExpressionUnaryOperateType_Tilde:\n        cppOperatorType = WCDB::Expression::SyntaxType::UnaryOperator::Tilde;\n        break;\n    default:\n        WCTAssert(false);\n    }\n\n    CPPExpression ret = WCDBCreateCPPBridgedObject(CPPExpression, WCDB::Expression);\n    WCDBGetObjectOrReturnValue(ret, WCDB::Expression, newExpression, CPPExpression());\n\n    newExpression->syntax().switcher = WCDB::Expression::SyntaxType::Switch::UnaryOperation;\n    newExpression->syntax().unaryOperator = cppOperatorType;\n    newExpression->syntax().expressions.push_back(*cppExpression);\n    return ret;\n}\n\nCPPExpression WCDBExpressionNullOperate(CPPExpression expression, bool isNot)\n{\n    WCDBGetObjectOrReturnValue(expression, WCDB::Expression, cppExpression, CPPExpression());\n\n    CPPExpression ret = WCDBCreateCPPBridgedObject(CPPExpression, WCDB::Expression);\n    WCDBGetObjectOrReturnValue(ret, WCDB::Expression, newExpression, CPPExpression())\n\n    newExpression->syntax()\n    .switcher\n    = WCDB::Expression::SyntaxType::Switch::UnaryOperation;\n    newExpression->syntax().unaryOperator\n    = WCDB::Expression::SyntaxType::UnaryOperator::Null;\n    newExpression->syntax().expressions.push_back(*cppExpression);\n    newExpression->syntax().isNot = isNot;\n    return ret;\n}\n\nCPPExpression WCDBExpressionNullOperate2(CPPCommonValue expression, bool isNot)\n{\n    CPPExpression ret = WCDBCreateCPPBridgedObject(CPPExpression, WCDB::Expression);\n    WCDBGetObjectOrReturnValue(ret, WCDB::Expression, newExpression, CPPExpression())\n\n    newExpression->syntax()\n    .switcher\n    = WCDB::Expression::SyntaxType::Switch::UnaryOperation;\n    newExpression->syntax().unaryOperator\n    = WCDB::Expression::SyntaxType::UnaryOperator::Null;\n    newExpression->syntax().isNot = isNot;\n    WCDBExpressionPushOperand(expression);\n    return ret;\n}\n\nWCDB::Expression::SyntaxType::BinaryOperator\nWCDBCastOperatorType(enum WCDBExpressionBinaryOperatorType operatorType)\n{\n    WCDB::Expression::SyntaxType::BinaryOperator cppOperatorType;\n    switch (operatorType) {\n    case WCDBExpressionBinaryOperatorType_Concatenate:\n        cppOperatorType = WCDB::Expression::SyntaxType::BinaryOperator::Concatenate;\n        break;\n    case WCDBExpressionBinaryOperatorType_Multiply:\n        cppOperatorType = WCDB::Expression::SyntaxType::BinaryOperator::Multiply;\n        break;\n    case WCDBExpressionBinaryOperatorType_Divide:\n        cppOperatorType = WCDB::Expression::SyntaxType::BinaryOperator::Divide;\n        break;\n    case WCDBExpressionBinaryOperatorType_Modulo:\n        cppOperatorType = WCDB::Expression::SyntaxType::BinaryOperator::Modulo;\n        break;\n    case WCDBExpressionBinaryOperatorType_Plus:\n        cppOperatorType = WCDB::Expression::SyntaxType::BinaryOperator::Plus;\n        break;\n    case WCDBExpressionBinaryOperatorType_Minus:\n        cppOperatorType = WCDB::Expression::SyntaxType::BinaryOperator::Minus;\n        break;\n    case WCDBExpressionBinaryOperatorType_LeftShift:\n        cppOperatorType = WCDB::Expression::SyntaxType::BinaryOperator::LeftShift;\n        break;\n    case WCDBExpressionBinaryOperatorType_RightShift:\n        cppOperatorType = WCDB::Expression::SyntaxType::BinaryOperator::RightShift;\n        break;\n    case WCDBExpressionBinaryOperatorType_BitwiseAnd:\n        cppOperatorType = WCDB::Expression::SyntaxType::BinaryOperator::BitwiseAnd;\n        break;\n    case WCDBExpressionBinaryOperatorType_BitwiseOr:\n        cppOperatorType = WCDB::Expression::SyntaxType::BinaryOperator::BitwiseOr;\n        break;\n    case WCDBExpressionBinaryOperatorType_Less:\n        cppOperatorType = WCDB::Expression::SyntaxType::BinaryOperator::Less;\n        break;\n    case WCDBExpressionBinaryOperatorType_LessOrEqual:\n        cppOperatorType = WCDB::Expression::SyntaxType::BinaryOperator::LessOrEqual;\n        break;\n    case WCDBExpressionBinaryOperatorType_Greater:\n        cppOperatorType = WCDB::Expression::SyntaxType::BinaryOperator::Greater;\n        break;\n    case WCDBExpressionBinaryOperatorType_GreaterOrEqual:\n        cppOperatorType = WCDB::Expression::SyntaxType::BinaryOperator::GreaterOrEqual;\n        break;\n    case WCDBExpressionBinaryOperatorType_Equal:\n        cppOperatorType = WCDB::Expression::SyntaxType::BinaryOperator::Equal;\n        break;\n    case WCDBExpressionBinaryOperatorType_NotEqual:\n        cppOperatorType = WCDB::Expression::SyntaxType::BinaryOperator::NotEqual;\n        break;\n    case WCDBExpressionBinaryOperatorType_Is:\n        cppOperatorType = WCDB::Expression::SyntaxType::BinaryOperator::Is;\n        break;\n    case WCDBExpressionBinaryOperatorType_And:\n        cppOperatorType = WCDB::Expression::SyntaxType::BinaryOperator::And;\n        break;\n    case WCDBExpressionBinaryOperatorType_Or:\n        cppOperatorType = WCDB::Expression::SyntaxType::BinaryOperator::Or;\n        break;\n    case WCDBExpressionBinaryOperatorType_Like:\n        cppOperatorType = WCDB::Expression::SyntaxType::BinaryOperator::Like;\n        break;\n    case WCDBExpressionBinaryOperatorType_GLOB:\n        cppOperatorType = WCDB::Expression::SyntaxType::BinaryOperator::GLOB;\n        break;\n    case WCDBExpressionBinaryOperatorType_RegExp:\n        cppOperatorType = WCDB::Expression::SyntaxType::BinaryOperator::RegExp;\n        break;\n    case WCDBExpressionBinaryOperatorType_Match:\n        cppOperatorType = WCDB::Expression::SyntaxType::BinaryOperator::Match;\n        break;\n    }\n    return cppOperatorType;\n}\n\nCPPExpression WCDBExpressionBinaryOperate(CPPExpression left,\n                                          CPPExpression right,\n                                          enum WCDBExpressionBinaryOperatorType operatorType,\n                                          bool isNot)\n{\n    WCDBGetObjectOrReturnValue(left, WCDB::Expression, cppLeft, CPPExpression());\n    WCDBGetObjectOrReturnValue(right, WCDB::Expression, cppRight, CPPExpression());\n\n    CPPExpression ret = WCDBCreateCPPBridgedObject(CPPExpression, WCDB::Expression);\n    WCDBGetObjectOrReturnValue(ret, WCDB::Expression, newExpression, CPPExpression())\n\n    newExpression->syntax()\n    .switcher\n    = WCDB::Expression::SyntaxType::Switch::BinaryOperation;\n    newExpression->syntax().binaryOperator = WCDBCastOperatorType(operatorType);\n    newExpression->syntax().expressions.push_back(*cppLeft);\n    newExpression->syntax().expressions.push_back(*cppRight);\n    newExpression->syntax().isNot = isNot;\n    return ret;\n}\n\nCPPExpression WCDBExpressionBinaryOperate2(CPPCommonValue left,\n                                           CPPCommonValue right,\n                                           enum WCDBExpressionBinaryOperatorType operatorType,\n                                           bool isNot)\n{\n    CPPExpression ret = WCDBCreateCPPBridgedObject(CPPExpression, WCDB::Expression);\n    WCDBGetObjectOrReturnValue(ret, WCDB::Expression, newExpression, CPPExpression())\n\n    newExpression->syntax()\n    .switcher\n    = WCDB::Expression::SyntaxType::Switch::BinaryOperation;\n    newExpression->syntax().binaryOperator = WCDBCastOperatorType(operatorType);\n    newExpression->syntax().isNot = isNot;\n    WCDBExpressionPushOperand(left);\n    WCDBExpressionPushOperand(right);\n    return ret;\n}\n\nCPPExpression\nWCDBExpressionBetweenOperate(CPPExpression operand, CPPExpression left, CPPExpression right, bool isNot)\n{\n    WCDBGetObjectOrReturnValue(operand, WCDB::Expression, cppOperand, CPPExpression());\n    WCDBGetObjectOrReturnValue(left, WCDB::Expression, cppLeft, CPPExpression());\n    WCDBGetObjectOrReturnValue(right, WCDB::Expression, cppRight, CPPExpression());\n\n    CPPExpression ret = WCDBCreateCPPBridgedObject(CPPExpression, WCDB::Expression);\n    WCDBGetObjectOrReturnValue(ret, WCDB::Expression, newExpression, CPPExpression())\n\n    newExpression->syntax()\n    .switcher\n    = WCDB::Expression::SyntaxType::Switch::Between;\n    auto& expressions = newExpression->syntax().expressions;\n    expressions.push_back(*cppOperand);\n    expressions.push_back(*cppLeft);\n    expressions.push_back(*cppRight);\n    newExpression->syntax().isNot = isNot;\n\n    return ret;\n}\n\nCPPExpression WCDBExpressionBetweenOperate2(CPPCommonValue operand,\n                                            CPPCommonValue left,\n                                            CPPCommonValue right,\n                                            bool isNot)\n{\n    CPPExpression ret = WCDBCreateCPPBridgedObject(CPPExpression, WCDB::Expression);\n    WCDBGetObjectOrReturnValue(ret, WCDB::Expression, newExpression, CPPExpression())\n    newExpression->syntax()\n    .switcher\n    = WCDB::Expression::SyntaxType::Switch::Between;\n    newExpression->syntax().isNot = isNot;\n    WCDBExpressionPushOperand(operand);\n    WCDBExpressionPushOperand(left);\n    WCDBExpressionPushOperand(right);\n    return ret;\n}\n\nCPPExpression\nWCDBExpressionInTableOperate(CPPExpression operand, const char* _Nullable table, bool isNot)\n{\n    WCDBGetObjectOrReturnValue(operand, WCDB::Expression, cppOperand, CPPExpression());\n\n    CPPExpression ret = WCDBCreateCPPBridgedObject(CPPExpression, WCDB::Expression);\n    WCDBGetObjectOrReturnValue(ret, WCDB::Expression, newExpression, CPPExpression())\n\n    newExpression->syntax()\n    .switcher\n    = WCDB::Expression::SyntaxType::Switch::In;\n    newExpression->syntax().expressions.push_back(*cppOperand);\n    newExpression->syntax().inSwitcher = WCDB::Expression::SyntaxType::SwitchIn::Table;\n    newExpression->syntax().table() = table;\n    newExpression->syntax().isNot = isNot;\n    return ret;\n}\n\nCPPExpression\nWCDBExpressionInTableOperate2(CPPCommonValue operand, const char* _Nullable table, bool isNot)\n{\n    CPPExpression ret = WCDBCreateCPPBridgedObject(CPPExpression, WCDB::Expression);\n    WCDBGetObjectOrReturnValue(ret, WCDB::Expression, newExpression, CPPExpression())\n\n    newExpression->syntax()\n    .switcher\n    = WCDB::Expression::SyntaxType::Switch::In;\n    newExpression->syntax().inSwitcher = WCDB::Expression::SyntaxType::SwitchIn::Table;\n    newExpression->syntax().table() = table;\n    newExpression->syntax().isNot = isNot;\n    WCDBExpressionPushOperand(operand);\n    return ret;\n}\n\nCPPExpression\nWCDBExpressionInSelectionOperate(CPPExpression operand, CPPStatementSelect select, bool isNot)\n{\n    WCDBGetObjectOrReturnValue(operand, WCDB::Expression, cppOperand, CPPExpression());\n    WCDBGetObjectOrReturnValue(select, WCDB::StatementSelect, cppSelect, CPPExpression());\n\n    CPPExpression ret = WCDBCreateCPPBridgedObject(CPPExpression, WCDB::Expression);\n    WCDBGetObjectOrReturnValue(ret, WCDB::Expression, newExpression, CPPExpression())\n\n    newExpression->syntax()\n    .switcher\n    = WCDB::Expression::SyntaxType::Switch::In;\n    newExpression->syntax().expressions.push_back(*cppOperand);\n    newExpression->syntax().inSwitcher = WCDB::Expression::SyntaxType::SwitchIn::Select;\n    newExpression->syntax().select() = *cppSelect;\n    newExpression->syntax().isNot = isNot;\n    return ret;\n}\n\nCPPExpression\nWCDBExpressionInSelectionOperate2(CPPCommonValue operand, CPPStatementSelect select, bool isNot)\n{\n    WCDBGetObjectOrReturnValue(select, WCDB::StatementSelect, cppSelect, CPPExpression());\n    CPPExpression ret = WCDBCreateCPPBridgedObject(CPPExpression, WCDB::Expression);\n    WCDBGetObjectOrReturnValue(ret, WCDB::Expression, newExpression, CPPExpression())\n\n    newExpression->syntax()\n    .switcher\n    = WCDB::Expression::SyntaxType::Switch::In;\n    newExpression->syntax().inSwitcher = WCDB::Expression::SyntaxType::SwitchIn::Select;\n    newExpression->syntax().select() = *cppSelect;\n    newExpression->syntax().isNot = isNot;\n    WCDBExpressionPushOperand(operand);\n    return ret;\n}\n\nCPPExpression\nWCDBExpressionInOperate(CPPCommonValue operand, CPPCommonArray valueArray, bool isNot)\n{\n    CPPExpression ret = WCDBCreateCPPBridgedObject(CPPExpression, WCDB::Expression);\n    WCDBGetObjectOrReturnValue(ret, WCDB::Expression, newExpression, CPPExpression())\n\n    newExpression->syntax()\n    .switcher\n    = WCDB::Expression::SyntaxType::Switch::In;\n    newExpression->syntax().isNot = isNot;\n    newExpression->syntax().inSwitcher = WCDB::Expression::SyntaxType::SwitchIn::Expressions;\n    WCDBExpressionPushOperand(operand);\n    for (int i = 0; i < valueArray.length; i++) {\n        switch (valueArray.type) {\n        case WCDBBridgedType_Int:\n            newExpression->syntax().expressions.push_back(WCDB::Expression(\n            WCDB::LiteralValue(WCDBGetCommonArrayLiteralValue(int64_t, valueArray, i))));\n            break;\n        case WCDBBridgedType_UInt:\n            newExpression->syntax().expressions.push_back(WCDB::Expression(WCDB::LiteralValue(\n            WCDBGetCommonArrayLiteralValue(uint64_t, valueArray, i))));\n            break;\n        case WCDBBridgedType_Double:\n            newExpression->syntax().expressions.push_back(WCDB::Expression(\n            WCDB::LiteralValue(WCDBGetCommonArrayLiteralValue(double, valueArray, i))));\n            break;\n        case WCDBBridgedType_String:\n            newExpression->syntax().expressions.push_back(\n            WCDB::Expression(WCDB::LiteralValue(WCDB::StringView(\n            WCDBGetCommonArrayLiteralValue(const char*, valueArray, i)))));\n            break;\n        case WCDBBridgedType_Column:\n            newExpression->syntax().expressions.push_back(\n            WCDB::Expression(WCDBGetCommonArrayObject(WCDB::Column, valueArray, i)));\n            break;\n        case WCDBBridgedType_LiteralValue:\n            newExpression->syntax().expressions.push_back(WCDB::Expression(\n            WCDBGetCommonArrayObject(WCDB::LiteralValue, valueArray, i)));\n            break;\n        case WCDBBridgedType_BindParameter:\n            newExpression->syntax().expressions.push_back(WCDB::Expression(\n            WCDBGetCommonArrayObject(WCDB::BindParameter, valueArray, i)));\n            break;\n        case WCDBBridgedType_Expression:\n            newExpression->syntax().expressions.push_back(WCDB::Expression(\n            WCDBGetCommonArrayObject(WCDB::Expression, valueArray, i)));\n            break;\n        default:\n            assert(valueArray.type == WCDBBridgedType_Null);\n            break;\n        }\n    }\n    return ret;\n}\n\nCPPExpression WCDBExpressionInExpressionOperate(CPPExpression operand,\n                                                const CPPExpression* _Nullable expressions,\n                                                int num,\n                                                bool isNot)\n{\n    WCDBGetObjectOrReturnValue(operand, WCDB::Expression, cppOperand, CPPExpression());\n\n    CPPExpression ret = WCDBCreateCPPBridgedObject(CPPExpression, WCDB::Expression);\n    WCDBGetObjectOrReturnValue(ret, WCDB::Expression, newExpression, CPPExpression())\n\n    newExpression->syntax()\n    .switcher\n    = WCDB::Expression::SyntaxType::Switch::In;\n    newExpression->syntax().expressions.push_back(*cppOperand);\n    newExpression->syntax().inSwitcher = WCDB::Expression::SyntaxType::SwitchIn::Expressions;\n    newExpression->syntax().isNot = isNot;\n    WCDBGetCPPSyntaxList(WCDB::Expression, cppExpressions, expressions, num);\n    newExpression->syntax().expressions.splice(\n    newExpression->syntax().expressions.end(), cppExpressions);\n    return ret;\n}\n\nCPPExpression\nWCDBExpressionInFunctionOperate(CPPExpression operand, const char* _Nullable func, bool isNot)\n{\n    WCDBGetObjectOrReturnValue(operand, WCDB::Expression, cppOperand, CPPExpression());\n\n    CPPExpression ret = WCDBCreateCPPBridgedObject(CPPExpression, WCDB::Expression);\n    WCDBGetObjectOrReturnValue(ret, WCDB::Expression, newExpression, CPPExpression())\n\n    newExpression->syntax()\n    .switcher\n    = WCDB::Expression::SyntaxType::Switch::In;\n    newExpression->syntax().inSwitcher = WCDB::Expression::SyntaxType::SwitchIn::Function;\n    newExpression->syntax().expressions.push_back(*cppOperand);\n    newExpression->syntax().function() = func;\n    newExpression->syntax().isNot = isNot;\n    return ret;\n}\n\nCPPExpression\nWCDBExpressionInFunctionOperate2(CPPCommonValue operand, const char* _Nullable func, bool isNot)\n{\n    CPPExpression ret = WCDBCreateCPPBridgedObject(CPPExpression, WCDB::Expression);\n    WCDBGetObjectOrReturnValue(ret, WCDB::Expression, newExpression, CPPExpression())\n\n    newExpression->syntax()\n    .switcher\n    = WCDB::Expression::SyntaxType::Switch::In;\n    newExpression->syntax().inSwitcher = WCDB::Expression::SyntaxType::SwitchIn::Function;\n    newExpression->syntax().function() = func;\n    newExpression->syntax().isNot = isNot;\n    WCDBExpressionPushOperand(operand);\n    return ret;\n}\n\nCPPExpression WCDBExpressionCollateOperate(CPPExpression operand, const char* _Nullable collation)\n{\n    WCDBGetObjectOrReturnValue(operand, WCDB::Expression, cppOperand, CPPExpression());\n\n    CPPExpression ret = WCDBCreateCPPBridgedObject(CPPExpression, WCDB::Expression);\n    WCDBGetObjectOrReturnValue(ret, WCDB::Expression, newExpression, CPPExpression())\n\n    newExpression->syntax()\n    .switcher\n    = WCDB::Expression::SyntaxType::Switch::Collate;\n    newExpression->syntax().expressions.push_back(*cppOperand);\n    newExpression->syntax().collation() = collation;\n    return ret;\n}\n\nCPPExpression\nWCDBExpressionCollateOperate2(CPPCommonValue operand, const char* _Nullable collation)\n{\n    CPPExpression ret = WCDBCreateCPPBridgedObject(CPPExpression, WCDB::Expression);\n    WCDBGetObjectOrReturnValue(ret, WCDB::Expression, newExpression, CPPExpression())\n\n    newExpression->syntax()\n    .switcher\n    = WCDB::Expression::SyntaxType::Switch::Collate;\n    newExpression->syntax().collation() = collation;\n    WCDBExpressionPushOperand(operand);\n    return ret;\n}\n"
  },
  {
    "path": "src/bridge/winqbridge/identifier/ExpressionOperatableBridge.h",
    "content": "//\n// Created by qiuwenchen on 2022/5/31.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"ExpressionBridge.h\"\n\nWCDB_EXTERN_C_BEGIN\n\nenum WCDBExpressionUnaryOperateType {\n    WCDBExpressionUnaryOperateType_Negative = 1,\n    WCDBExpressionUnaryOperateType_Positive,\n    WCDBExpressionUnaryOperateType_Tilde,\n    WCDBExpressionUnaryOperateType_Not,\n};\nCPPExpression WCDBExpressionUnaryOperate(CPPExpression expression,\n                                         enum WCDBExpressionUnaryOperateType operatorType);\nCPPExpression WCDBExpressionNullOperate(CPPExpression expression, bool isNot);\n\nCPPExpression WCDBExpressionNullOperate2(CPPCommonValue expression, bool isNot);\n\nenum WCDBExpressionBinaryOperatorType {\n    WCDBExpressionBinaryOperatorType_Concatenate = 1,\n    WCDBExpressionBinaryOperatorType_Multiply,\n    WCDBExpressionBinaryOperatorType_Divide,\n    WCDBExpressionBinaryOperatorType_Modulo,\n    WCDBExpressionBinaryOperatorType_Plus,\n    WCDBExpressionBinaryOperatorType_Minus,\n    WCDBExpressionBinaryOperatorType_LeftShift,\n    WCDBExpressionBinaryOperatorType_RightShift,\n    WCDBExpressionBinaryOperatorType_BitwiseAnd,\n    WCDBExpressionBinaryOperatorType_BitwiseOr,\n    WCDBExpressionBinaryOperatorType_Less,\n    WCDBExpressionBinaryOperatorType_LessOrEqual,\n    WCDBExpressionBinaryOperatorType_Greater,\n    WCDBExpressionBinaryOperatorType_GreaterOrEqual,\n    WCDBExpressionBinaryOperatorType_Equal,\n    WCDBExpressionBinaryOperatorType_NotEqual,\n    WCDBExpressionBinaryOperatorType_Is,\n    WCDBExpressionBinaryOperatorType_And,\n    WCDBExpressionBinaryOperatorType_Or,\n    WCDBExpressionBinaryOperatorType_Like,\n    WCDBExpressionBinaryOperatorType_GLOB,\n    WCDBExpressionBinaryOperatorType_RegExp,\n    WCDBExpressionBinaryOperatorType_Match,\n};\nCPPExpression WCDBExpressionBinaryOperate(CPPExpression left,\n                                          CPPExpression right,\n                                          enum WCDBExpressionBinaryOperatorType operatorType,\n                                          bool isNot);\n\nCPPExpression WCDBExpressionBinaryOperate2(CPPCommonValue left,\n                                           CPPCommonValue right,\n                                           enum WCDBExpressionBinaryOperatorType operatorType,\n                                           bool isNot);\n\nCPPExpression WCDBExpressionBetweenOperate(CPPExpression operand,\n                                           CPPExpression left,\n                                           CPPExpression right,\n                                           bool isNot);\n\nCPPExpression WCDBExpressionBetweenOperate2(CPPCommonValue operand,\n                                            CPPCommonValue left,\n                                            CPPCommonValue right,\n                                            bool isNot);\n\nCPPExpression\nWCDBExpressionInOperate(CPPCommonValue operand, CPPCommonArray valueArray, bool isNot);\n\nCPPExpression\nWCDBExpressionInTableOperate(CPPExpression operand, const char* _Nullable table, bool isNot);\nCPPExpression\nWCDBExpressionInTableOperate2(CPPCommonValue operand, const char* _Nullable table, bool isNot);\n\nCPPExpression\nWCDBExpressionInSelectionOperate(CPPExpression operand, CPPStatementSelect select, bool isNot);\n\nCPPExpression WCDBExpressionInSelectionOperate2(CPPCommonValue operand,\n                                                CPPStatementSelect select,\n                                                bool isNot);\n\nCPPExpression WCDBExpressionInExpressionOperate(CPPExpression operand,\n                                                const CPPExpression* _Nullable expressions,\n                                                int num,\n                                                bool isNot);\n\nCPPExpression\nWCDBExpressionInFunctionOperate(CPPExpression operand, const char* _Nullable func, bool isNot);\n\nCPPExpression WCDBExpressionInFunctionOperate2(CPPCommonValue operand,\n                                               const char* _Nullable func,\n                                               bool isNot);\n\nCPPExpression\nWCDBExpressionCollateOperate(CPPExpression operand, const char* _Nullable collation);\n\nCPPExpression\nWCDBExpressionCollateOperate2(CPPCommonValue operand, const char* _Nullable collation);\n\nWCDB_EXTERN_C_END\n"
  },
  {
    "path": "src/bridge/winqbridge/identifier/ForeignKeyBridge.cpp",
    "content": "//\n// Created by qiuwenchen on 2022/5/29.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"ForeignKeyBridge.h\"\n#include \"Column.hpp\"\n#include \"ForeignKey.hpp\"\n#include \"ObjectBridge.hpp\"\n#include \"WinqBridge.hpp\"\n\nCPPForeignKey WCDBForeignKeyCreate()\n{\n    return WCDBCreateCPPBridgedObject(CPPForeignKey, WCDB::ForeignKey);\n}\nvoid WCDBForeignKeyConfigReferencesTable(CPPForeignKey foreignKey, const char* _Nullable table)\n{\n    WCDBGetObjectOrReturn(foreignKey, WCDB::ForeignKey, cppObj);\n    cppObj->references(table);\n}\n\nvoid WCDBForeignKeyAddColumn(CPPForeignKey foreignKey, CPPColumn column)\n{\n    WCDBGetObjectOrReturn(foreignKey, WCDB::ForeignKey, cppObj);\n    WCDBGetObjectOrReturn(column, WCDB::Column, cppColumn);\n    cppObj->column(*cppColumn);\n}\n\nvoid WCDBForeignKeyAddColumn2(CPPForeignKey foreignKey, CPPCommonArray columns)\n{\n    WCDBGetObjectOrReturn(foreignKey, WCDB::ForeignKey, cppObj);\n    for (int i = 0; i < columns.length; i++) {\n        switch (columns.type) {\n        case WCDBBridgedType_String:\n            cppObj->column(WCDB::StringView(\n            WCDBGetCommonArrayLiteralValue(const char*, columns, i)));\n            break;\n        case WCDBBridgedType_Column:\n            cppObj->column(WCDBGetCommonArrayObject(WCDB::Column, columns, i));\n            break;\n        default:\n            assert(0);\n            break;\n        }\n    }\n}\n\nvoid WCDBForeignKeyConfigOnDeleteSetNull(CPPForeignKey foreignKey)\n{\n    WCDBGetObjectOrReturn(foreignKey, WCDB::ForeignKey, cppObj);\n    cppObj->onDeleteSetNull();\n}\n\nvoid WCDBForeignKeyConfigOnDeleteSetDefault(CPPForeignKey foreignKey)\n{\n    WCDBGetObjectOrReturn(foreignKey, WCDB::ForeignKey, cppObj);\n    cppObj->onDeleteSetDefault();\n}\nvoid WCDBForeignKeyConfigOnDeleteCascade(CPPForeignKey foreignKey)\n{\n    WCDBGetObjectOrReturn(foreignKey, WCDB::ForeignKey, cppObj);\n    cppObj->onDeleteCascade();\n}\n\nvoid WCDBForeignKeyConfigOnDeleteRestrict(CPPForeignKey foreignKey)\n{\n    WCDBGetObjectOrReturn(foreignKey, WCDB::ForeignKey, cppObj);\n    cppObj->onDeleteRestrict();\n}\n\nvoid WCDBForeignKeyConfigOnDeleteNoAction(CPPForeignKey foreignKey)\n{\n    WCDBGetObjectOrReturn(foreignKey, WCDB::ForeignKey, cppObj);\n    cppObj->onDeleteNoAction();\n}\n\nvoid WCDBForeignKeyConfigOnUpdateSetNull(CPPForeignKey foreignKey)\n{\n    WCDBGetObjectOrReturn(foreignKey, WCDB::ForeignKey, cppObj);\n    cppObj->onUpdateSetNull();\n}\n\nvoid WCDBForeignKeyConfigOnUpdateSetDefault(CPPForeignKey foreignKey)\n{\n    WCDBGetObjectOrReturn(foreignKey, WCDB::ForeignKey, cppObj);\n    cppObj->onUpdateSetDefault();\n}\n\nvoid WCDBForeignKeyConfigOnUpdateCascade(CPPForeignKey foreignKey)\n{\n    WCDBGetObjectOrReturn(foreignKey, WCDB::ForeignKey, cppObj);\n    cppObj->onUpdateCascade();\n}\n\nvoid WCDBForeignKeyConfigOnUpdateRestrict(CPPForeignKey foreignKey)\n{\n    WCDBGetObjectOrReturn(foreignKey, WCDB::ForeignKey, cppObj);\n    cppObj->onUpdateRestrict();\n}\n\nvoid WCDBForeignKeyConfigOnUpdateNoAction(CPPForeignKey foreignKey)\n{\n    WCDBGetObjectOrReturn(foreignKey, WCDB::ForeignKey, cppObj);\n    cppObj->onUpdateNoAction();\n}\n\nvoid WCDBForeignKeyConfigMatch(CPPForeignKey foreignKey, WCDBSyntaxMatchType match)\n{\n    WCDBGetObjectOrReturn(foreignKey, WCDB::ForeignKey, cppObj);\n    cppObj->match(WCDB::WinqBridge::changeMatchType(match));\n}\n\nvoid WCDBForeignKeyConfigDeferrable(CPPForeignKey foreignKey)\n{\n    WCDBGetObjectOrReturn(foreignKey, WCDB::ForeignKey, cppObj);\n    cppObj->deferrable();\n}\n\nvoid WCDBForeignKeyConfigDeferrableInitiallyDeferred(CPPForeignKey foreignKey)\n{\n    WCDBGetObjectOrReturn(foreignKey, WCDB::ForeignKey, cppObj);\n    cppObj->deferrableInitiallyDeferred();\n}\n\nvoid WCDBForeignKeyConfigDeferrableInitiallyImmediate(CPPForeignKey foreignKey)\n{\n    WCDBGetObjectOrReturn(foreignKey, WCDB::ForeignKey, cppObj);\n    cppObj->deferrableInitiallyImmediate();\n}\n\nvoid WCDBForeignKeyConfigNotDeferrable(CPPForeignKey foreignKey)\n{\n    WCDBGetObjectOrReturn(foreignKey, WCDB::ForeignKey, cppObj);\n    cppObj->notDeferrable();\n}\n\nvoid WCDBForeignKeyConfigNotDeferrableInitiallyDeferred(CPPForeignKey foreignKey)\n{\n    WCDBGetObjectOrReturn(foreignKey, WCDB::ForeignKey, cppObj);\n    cppObj->notDeferrableInitiallyDeferred();\n}\n\nvoid WCDBForeignKeyConfigNotDeferrableInitiallyImmediate(CPPForeignKey foreignKey)\n{\n    WCDBGetObjectOrReturn(foreignKey, WCDB::ForeignKey, cppObj);\n    cppObj->notDeferrableInitiallyImmediate();\n}\n"
  },
  {
    "path": "src/bridge/winqbridge/identifier/ForeignKeyBridge.h",
    "content": "//\n// Created by qiuwenchen on 2022/5/29.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"WinqBridge.h\"\n\nWCDB_EXTERN_C_BEGIN\n\nCPPForeignKey WCDBForeignKeyCreate(void);\nvoid WCDBForeignKeyConfigReferencesTable(CPPForeignKey foreignKey, const char* _Nullable table);\nvoid WCDBForeignKeyAddColumn(CPPForeignKey foreignKey, CPPColumn column);\nvoid WCDBForeignKeyAddColumn2(CPPForeignKey foreignKey, CPPCommonArray columns);\n\nvoid WCDBForeignKeyConfigOnDeleteSetNull(CPPForeignKey foreignKey);\nvoid WCDBForeignKeyConfigOnDeleteSetDefault(CPPForeignKey foreignKey);\nvoid WCDBForeignKeyConfigOnDeleteCascade(CPPForeignKey foreignKey);\nvoid WCDBForeignKeyConfigOnDeleteRestrict(CPPForeignKey foreignKey);\nvoid WCDBForeignKeyConfigOnDeleteNoAction(CPPForeignKey foreignKey);\n\nvoid WCDBForeignKeyConfigOnUpdateSetNull(CPPForeignKey foreignKey);\nvoid WCDBForeignKeyConfigOnUpdateSetDefault(CPPForeignKey foreignKey);\nvoid WCDBForeignKeyConfigOnUpdateCascade(CPPForeignKey foreignKey);\nvoid WCDBForeignKeyConfigOnUpdateRestrict(CPPForeignKey foreignKey);\nvoid WCDBForeignKeyConfigOnUpdateNoAction(CPPForeignKey foreignKey);\n\nvoid WCDBForeignKeyConfigMatch(CPPForeignKey foreignKey, enum WCDBSyntaxMatchType match);\n\nvoid WCDBForeignKeyConfigDeferrable(CPPForeignKey foreignKey);\nvoid WCDBForeignKeyConfigDeferrableInitiallyDeferred(CPPForeignKey foreignKey);\nvoid WCDBForeignKeyConfigDeferrableInitiallyImmediate(CPPForeignKey foreignKey);\nvoid WCDBForeignKeyConfigNotDeferrable(CPPForeignKey foreignKey);\nvoid WCDBForeignKeyConfigNotDeferrableInitiallyDeferred(CPPForeignKey foreignKey);\nvoid WCDBForeignKeyConfigNotDeferrableInitiallyImmediate(CPPForeignKey foreignKey);\n\nWCDB_EXTERN_C_END\n"
  },
  {
    "path": "src/bridge/winqbridge/identifier/FrameSpecBridge.cpp",
    "content": "//\n// Created by qiuwenchen on 2022/6/9.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"FrameSpecBridge.h\"\n#include \"Expression.hpp\"\n#include \"FrameSpec.hpp\"\n#include \"ObjectBridge.hpp\"\n#include \"WinqBridge.hpp\"\n\nCPPFrameSpec WCDBFrameSpecCreate()\n{\n    return WCDBCreateCPPBridgedObject(CPPFrameSpec, WCDB::FrameSpec);\n}\nvoid WCDBFrameSpecConfigRange(CPPFrameSpec frameSpec)\n{\n    WCDBGetObjectOrReturn(frameSpec, WCDB::FrameSpec, cppFrameSpec);\n    cppFrameSpec->range();\n}\n\nvoid WCDBFrameSpecConfigRows(CPPFrameSpec frameSpec)\n{\n    WCDBGetObjectOrReturn(frameSpec, WCDB::FrameSpec, cppFrameSpec);\n    cppFrameSpec->rows();\n}\n\nvoid WCDBFrameSpecConfigUnboundedPreceding(CPPFrameSpec frameSpec)\n{\n    WCDBGetObjectOrReturn(frameSpec, WCDB::FrameSpec, cppFrameSpec);\n    cppFrameSpec->unboundedPreceding();\n}\n\nvoid WCDBFrameSpecConfigPreceding(CPPFrameSpec frameSpec, CPPExpression expression)\n{\n    WCDBGetObjectOrReturn(frameSpec, WCDB::FrameSpec, cppFrameSpec);\n    WCDBGetObjectOrReturn(expression, WCDB::Expression, cppExpression);\n    cppFrameSpec->preceding(*cppExpression);\n}\n\nvoid WCDBFrameSpecConfigPreceding2(CPPFrameSpec frameSpec, CPPCommonValue expression)\n{\n    WCDBGetObjectOrReturn(frameSpec, WCDB::FrameSpec, cppFrameSpec);\n    cppFrameSpec->preceding(WCDBCreateExpressionFromCommonValue(expression));\n}\n\nvoid WCDBFrameSpecConfigCurrentRow(CPPFrameSpec frameSpec)\n{\n    WCDBGetObjectOrReturn(frameSpec, WCDB::FrameSpec, cppFrameSpec);\n    cppFrameSpec->currentRow();\n}\n\nvoid WCDBFrameSpecConfigBetweenUnboundedPreceding(CPPFrameSpec frameSpec)\n{\n    WCDBGetObjectOrReturn(frameSpec, WCDB::FrameSpec, cppFrameSpec);\n    cppFrameSpec->betweenUnboundedPreceding();\n}\n\nvoid WCDBFrameSpecConfigBetweenPreceding(CPPFrameSpec frameSpec, CPPExpression expression)\n{\n    WCDBGetObjectOrReturn(frameSpec, WCDB::FrameSpec, cppFrameSpec);\n    WCDBGetObjectOrReturn(expression, WCDB::Expression, cppExpression);\n    cppFrameSpec->betweenPreceding(*cppExpression);\n}\n\nvoid WCDBFrameSpecConfigBetweenPreceding2(CPPFrameSpec frameSpec, CPPCommonValue expression)\n{\n    WCDBGetObjectOrReturn(frameSpec, WCDB::FrameSpec, cppFrameSpec);\n    cppFrameSpec->betweenPreceding(WCDBCreateExpressionFromCommonValue(expression));\n}\n\nvoid WCDBFrameSpecConfigBetweenCurrentRow(CPPFrameSpec frameSpec)\n{\n    WCDBGetObjectOrReturn(frameSpec, WCDB::FrameSpec, cppFrameSpec);\n    cppFrameSpec->betweenCurrentRow();\n}\n\nvoid WCDBFrameSpecConfigBetweenFollowing(CPPFrameSpec frameSpec, CPPExpression expression)\n{\n    WCDBGetObjectOrReturn(frameSpec, WCDB::FrameSpec, cppFrameSpec);\n    WCDBGetObjectOrReturn(expression, WCDB::Expression, cppExpression);\n    cppFrameSpec->betweenFollowing(*cppExpression);\n}\n\nvoid WCDBFrameSpecConfigBetweenFollowing2(CPPFrameSpec frameSpec, CPPCommonValue expression)\n{\n    WCDBGetObjectOrReturn(frameSpec, WCDB::FrameSpec, cppFrameSpec);\n    cppFrameSpec->betweenFollowing(WCDBCreateExpressionFromCommonValue(expression));\n}\n\nvoid WCDBFrameSpecConfigAndPreceding(CPPFrameSpec frameSpec, CPPExpression expression)\n{\n    WCDBGetObjectOrReturn(frameSpec, WCDB::FrameSpec, cppFrameSpec);\n    WCDBGetObjectOrReturn(expression, WCDB::Expression, cppExpression);\n    cppFrameSpec->andPreceding(*cppExpression);\n}\n\nvoid WCDBFrameSpecConfigAndPreceding2(CPPFrameSpec frameSpec, CPPCommonValue expression)\n{\n    WCDBGetObjectOrReturn(frameSpec, WCDB::FrameSpec, cppFrameSpec);\n    cppFrameSpec->andPreceding(WCDBCreateExpressionFromCommonValue(expression));\n}\n\nvoid WCDBFrameSpecConfigAndCurrentRow(CPPFrameSpec frameSpec)\n{\n    WCDBGetObjectOrReturn(frameSpec, WCDB::FrameSpec, cppFrameSpec);\n    cppFrameSpec->andCurrentRow();\n}\n\nvoid WCDBFrameSpecConfigAndFollowing(CPPFrameSpec frameSpec, CPPExpression expression)\n{\n    WCDBGetObjectOrReturn(frameSpec, WCDB::FrameSpec, cppFrameSpec);\n    WCDBGetObjectOrReturn(expression, WCDB::Expression, cppExpression);\n    cppFrameSpec->andFollowing(*cppExpression);\n}\n\nvoid WCDBFrameSpecConfigAndFollowing2(CPPFrameSpec frameSpec, CPPCommonValue expression)\n{\n    WCDBGetObjectOrReturn(frameSpec, WCDB::FrameSpec, cppFrameSpec);\n    cppFrameSpec->andFollowing(WCDBCreateExpressionFromCommonValue(expression));\n}\n\nvoid WCDBFrameSpecConfigAndUnboundedFollowing(CPPFrameSpec frameSpec)\n{\n    WCDBGetObjectOrReturn(frameSpec, WCDB::FrameSpec, cppFrameSpec);\n    cppFrameSpec->andUnboundedFollowing();\n}\n"
  },
  {
    "path": "src/bridge/winqbridge/identifier/FrameSpecBridge.h",
    "content": "//\n// Created by qiuwenchen on 2022/6/9.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"WinqBridge.h\"\n\nWCDB_EXTERN_C_BEGIN\n\nCPPFrameSpec WCDBFrameSpecCreate(void);\nvoid WCDBFrameSpecConfigRange(CPPFrameSpec frameSpec);\nvoid WCDBFrameSpecConfigRows(CPPFrameSpec frameSpec);\nvoid WCDBFrameSpecConfigUnboundedPreceding(CPPFrameSpec frameSpec);\nvoid WCDBFrameSpecConfigPreceding(CPPFrameSpec frameSpec, CPPExpression expression);\nvoid WCDBFrameSpecConfigPreceding2(CPPFrameSpec frameSpec, CPPCommonValue expression);\nvoid WCDBFrameSpecConfigCurrentRow(CPPFrameSpec frameSpec);\nvoid WCDBFrameSpecConfigBetweenUnboundedPreceding(CPPFrameSpec frameSpec);\nvoid WCDBFrameSpecConfigBetweenPreceding(CPPFrameSpec frameSpec, CPPExpression expression);\nvoid WCDBFrameSpecConfigBetweenPreceding2(CPPFrameSpec frameSpec, CPPCommonValue expression);\nvoid WCDBFrameSpecConfigBetweenCurrentRow(CPPFrameSpec frameSpec);\nvoid WCDBFrameSpecConfigBetweenFollowing(CPPFrameSpec frameSpec, CPPExpression expression);\nvoid WCDBFrameSpecConfigBetweenFollowing2(CPPFrameSpec frameSpec, CPPCommonValue expression);\nvoid WCDBFrameSpecConfigAndPreceding(CPPFrameSpec frameSpec, CPPExpression expression);\nvoid WCDBFrameSpecConfigAndPreceding2(CPPFrameSpec frameSpec, CPPCommonValue expression);\nvoid WCDBFrameSpecConfigAndCurrentRow(CPPFrameSpec frameSpec);\nvoid WCDBFrameSpecConfigAndFollowing(CPPFrameSpec frameSpec, CPPExpression expression);\nvoid WCDBFrameSpecConfigAndFollowing2(CPPFrameSpec frameSpec, CPPCommonValue expression);\nvoid WCDBFrameSpecConfigAndUnboundedFollowing(CPPFrameSpec frameSpec);\n\nWCDB_EXTERN_C_END\n"
  },
  {
    "path": "src/bridge/winqbridge/identifier/IndexedColumnBridge.cpp",
    "content": "//\n// Created by qiuwenchen on 2022/6/10.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"IndexedColumnBridge.h\"\n#include \"Column.hpp\"\n#include \"Expression.hpp\"\n#include \"IndexedColumn.hpp\"\n#include \"ObjectBridge.hpp\"\n#include \"WinqBridge.hpp\"\n\nCPPIndexedColumn WCDBIndexedColumnCreate(CPPCommonValue value)\n{\n    if (value.type == WCDBBridgedType_Column) {\n        return WCDBCreateCPPBridgedObjectWithParameters(\n        CPPIndexedColumn, WCDB::IndexedColumn, WCDBGetBridgedData(WCDB::Column, value));\n    } else if (value.type == WCDBBridgedType_IndexedColumn) {\n        return WCDBCreateCPPBridgedObjectByCopy(\n        CPPIndexedColumn, WCDBGetBridgedData(WCDB::IndexedColumn, value));\n    } else if (value.type == WCDBBridgedType_String) {\n        return WCDBCreateCPPBridgedObjectWithParameters(\n        CPPIndexedColumn, WCDB::IndexedColumn, WCDB::Column((const char*) value.intValue));\n    } else {\n        return WCDBCreateCPPBridgedObjectWithParameters(\n        CPPIndexedColumn, WCDB::IndexedColumn, WCDBCreateExpressionFromCommonValue(value));\n    }\n}\n\nCPPIndexedColumn WCDBIndexedColumnCreateWithColumn(CPPColumn column)\n{\n    WCDBGetObjectOrReturnValue(column, WCDB::Column, cppColumn, CPPIndexedColumn());\n    return WCDBCreateCPPBridgedObjectWithParameters(\n    CPPIndexedColumn, WCDB::IndexedColumn, *cppColumn);\n}\n\nCPPIndexedColumn WCDBIndexedColumnCreateWithExpression(CPPExpression expression)\n{\n    WCDBGetObjectOrReturnValue(\n    expression, WCDB::Expression, cppExpression, CPPIndexedColumn());\n    return WCDBCreateCPPBridgedObjectWithParameters(\n    CPPIndexedColumn, WCDB::IndexedColumn, *cppExpression);\n}\n\nvoid WCDBIndexedColumnConfigCollation(CPPIndexedColumn indexedColumn, const char* _Nullable collation)\n{\n    WCDBGetObjectOrReturn(indexedColumn, WCDB::IndexedColumn, cppIndexedColumn);\n    cppIndexedColumn->collate(collation);\n}\n\nvoid WCDBIndexedColumnConfigOrder(CPPIndexedColumn indexedColumn, enum WCDBSyntaxOrder order)\n{\n    WCDBGetObjectOrReturn(indexedColumn, WCDB::IndexedColumn, cppIndexedColumn);\n    cppIndexedColumn->order(WCDB::WinqBridge::changeOrder(order));\n}\n"
  },
  {
    "path": "src/bridge/winqbridge/identifier/IndexedColumnBridge.h",
    "content": "//\n// Created by qiuwenchen on 2022/6/10.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"WinqBridge.h\"\n\nWCDB_EXTERN_C_BEGIN\n\nCPPIndexedColumn WCDBIndexedColumnCreate(CPPCommonValue value);\nCPPIndexedColumn WCDBIndexedColumnCreateWithColumn(CPPColumn column);\nCPPIndexedColumn WCDBIndexedColumnCreateWithExpression(CPPExpression expression);\nvoid WCDBIndexedColumnConfigCollation(CPPIndexedColumn indexedColumn,\n                                      const char* _Nullable collation);\nvoid WCDBIndexedColumnConfigOrder(CPPIndexedColumn indexedColumn, enum WCDBSyntaxOrder order);\n\nWCDB_EXTERN_C_END\n"
  },
  {
    "path": "src/bridge/winqbridge/identifier/JoinBridge.cpp",
    "content": "//\n// Created by qiuwenchen on 2022/6/11.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"JoinBridge.h\"\n#include \"Column.hpp\"\n#include \"Expression.hpp\"\n#include \"Join.hpp\"\n#include \"ObjectBridge.hpp\"\n#include \"TableOrSubquery.hpp\"\n#include \"WinqBridge.hpp\"\n\nCPPJoin WCDBJoinCreateWithTableOrSubquery(CPPTableOrSubquery query)\n{\n    WCDBGetObjectOrReturnValue(query, WCDB::TableOrSubquery, cppQuery, CPPJoin());\n    CPPJoin ret = WCDBCreateCPPBridgedObject(CPPJoin, WCDB::Join);\n    WCDBGetObjectOrReturnValue(ret, WCDB::Join, join, CPPJoin());\n    join->table(*cppQuery);\n    return ret;\n}\n\nCPPJoin WCDBJoinCreateWithTableOrSubquery2(CPPCommonValue query)\n{\n    CPPJoin ret = WCDBCreateCPPBridgedObject(CPPJoin, WCDB::Join);\n    WCDBGetObjectOrReturnValue(ret, WCDB::Join, join, CPPJoin());\n    join->table(WCDBCreateTableOrSubqueryFromCommonValue(query));\n    return ret;\n}\n\nvoid WCDBJoinWith(CPPJoin join, CPPTableOrSubquery query)\n{\n    WCDBGetObjectOrReturn(join, WCDB::Join, cppJoin);\n    WCDBGetObjectOrReturn(query, WCDB::TableOrSubquery, cppQuery);\n    cppJoin->with(*cppQuery);\n}\n\nvoid WCDBJoinWith2(CPPJoin join, CPPCommonValue query)\n{\n    WCDBGetObjectOrReturn(join, WCDB::Join, cppJoin);\n    cppJoin->with(WCDBCreateTableOrSubqueryFromCommonValue(query));\n}\n\nvoid WCDBJoinWithJoin(CPPJoin join, CPPTableOrSubquery query)\n{\n    WCDBGetObjectOrReturn(join, WCDB::Join, cppJoin);\n    WCDBGetObjectOrReturn(query, WCDB::TableOrSubquery, cppQuery);\n    cppJoin->join(*cppQuery);\n}\n\nvoid WCDBJoinWithJoin2(CPPJoin join, CPPCommonValue query)\n{\n    WCDBGetObjectOrReturn(join, WCDB::Join, cppJoin);\n    cppJoin->join(WCDBCreateTableOrSubqueryFromCommonValue(query));\n}\n\nvoid WCDBJoinWithLeftOuterJoin(CPPJoin join, CPPTableOrSubquery query)\n{\n    WCDBGetObjectOrReturn(join, WCDB::Join, cppJoin);\n    WCDBGetObjectOrReturn(query, WCDB::TableOrSubquery, cppQuery);\n    cppJoin->leftOuterJoin(*cppQuery);\n}\n\nvoid WCDBJoinWithLeftOuterJoin2(CPPJoin join, CPPCommonValue query)\n{\n    WCDBGetObjectOrReturn(join, WCDB::Join, cppJoin);\n    cppJoin->leftOuterJoin(WCDBCreateTableOrSubqueryFromCommonValue(query));\n}\n\nvoid WCDBJoinWithLeftJoin(CPPJoin join, CPPTableOrSubquery query)\n{\n    WCDBGetObjectOrReturn(join, WCDB::Join, cppJoin);\n    WCDBGetObjectOrReturn(query, WCDB::TableOrSubquery, cppQuery);\n    cppJoin->leftJoin(*cppQuery);\n}\n\nvoid WCDBJoinWithLeftJoin2(CPPJoin join, CPPCommonValue query)\n{\n    WCDBGetObjectOrReturn(join, WCDB::Join, cppJoin);\n    cppJoin->leftJoin(WCDBCreateTableOrSubqueryFromCommonValue(query));\n}\n\nvoid WCDBJoinWithInnerJoin(CPPJoin join, CPPTableOrSubquery query)\n{\n    WCDBGetObjectOrReturn(join, WCDB::Join, cppJoin);\n    WCDBGetObjectOrReturn(query, WCDB::TableOrSubquery, cppQuery);\n    cppJoin->innerJoin(*cppQuery);\n}\n\nvoid WCDBJoinWithInnerJoin2(CPPJoin join, CPPCommonValue query)\n{\n    WCDBGetObjectOrReturn(join, WCDB::Join, cppJoin);\n    cppJoin->innerJoin(WCDBCreateTableOrSubqueryFromCommonValue(query));\n}\n\nvoid WCDBJoinWithCrossJoin(CPPJoin join, CPPTableOrSubquery query)\n{\n    WCDBGetObjectOrReturn(join, WCDB::Join, cppJoin);\n    WCDBGetObjectOrReturn(query, WCDB::TableOrSubquery, cppQuery);\n    cppJoin->crossJoin(*cppQuery);\n}\n\nvoid WCDBJoinWithCrossJoin2(CPPJoin join, CPPCommonValue query)\n{\n    WCDBGetObjectOrReturn(join, WCDB::Join, cppJoin);\n    cppJoin->crossJoin(WCDBCreateTableOrSubqueryFromCommonValue(query));\n}\n\nvoid WCDBJoinWithNaturalJoin(CPPJoin join, CPPTableOrSubquery query)\n{\n    WCDBGetObjectOrReturn(join, WCDB::Join, cppJoin);\n    WCDBGetObjectOrReturn(query, WCDB::TableOrSubquery, cppQuery);\n    cppJoin->naturalJoin(*cppQuery);\n}\n\nvoid WCDBJoinWithNaturalJoin2(CPPJoin join, CPPCommonValue query)\n{\n    WCDBGetObjectOrReturn(join, WCDB::Join, cppJoin);\n    cppJoin->naturalJoin(WCDBCreateTableOrSubqueryFromCommonValue(query));\n}\n\nvoid WCDBJoinWithNaturalLeftOuterJoin(CPPJoin join, CPPTableOrSubquery query)\n{\n    WCDBGetObjectOrReturn(join, WCDB::Join, cppJoin);\n    WCDBGetObjectOrReturn(query, WCDB::TableOrSubquery, cppQuery);\n    cppJoin->naturalLeftOuterJoin(*cppQuery);\n}\n\nvoid WCDBJoinWithNaturalLeftOuterJoin2(CPPJoin join, CPPCommonValue query)\n{\n    WCDBGetObjectOrReturn(join, WCDB::Join, cppJoin);\n    cppJoin->naturalLeftOuterJoin(WCDBCreateTableOrSubqueryFromCommonValue(query));\n}\n\nvoid WCDBJoinWithNaturalLeftJoin(CPPJoin join, CPPTableOrSubquery query)\n{\n    WCDBGetObjectOrReturn(join, WCDB::Join, cppJoin);\n    WCDBGetObjectOrReturn(query, WCDB::TableOrSubquery, cppQuery);\n    cppJoin->naturalLeftJoin(*cppQuery);\n}\n\nvoid WCDBJoinWithNaturalLeftJoin2(CPPJoin join, CPPCommonValue query)\n{\n    WCDBGetObjectOrReturn(join, WCDB::Join, cppJoin);\n    cppJoin->naturalLeftJoin(WCDBCreateTableOrSubqueryFromCommonValue(query));\n}\n\nvoid WCDBJoinWithNaturalInnerJoin(CPPJoin join, CPPTableOrSubquery query)\n{\n    WCDBGetObjectOrReturn(join, WCDB::Join, cppJoin);\n    WCDBGetObjectOrReturn(query, WCDB::TableOrSubquery, cppQuery);\n    cppJoin->naturalInnerJoin(*cppQuery);\n}\n\nvoid WCDBJoinWithNaturalInnerJoin2(CPPJoin join, CPPCommonValue query)\n{\n    WCDBGetObjectOrReturn(join, WCDB::Join, cppJoin);\n    cppJoin->naturalInnerJoin(WCDBCreateTableOrSubqueryFromCommonValue(query));\n}\n\nvoid WCDBJoinWithNaturalCrossJoin(CPPJoin join, CPPTableOrSubquery query)\n{\n    WCDBGetObjectOrReturn(join, WCDB::Join, cppJoin);\n    WCDBGetObjectOrReturn(query, WCDB::TableOrSubquery, cppQuery);\n    cppJoin->naturalCrossJoin(*cppQuery);\n}\n\nvoid WCDBJoinWithNaturalCrossJoin2(CPPJoin join, CPPCommonValue query)\n{\n    WCDBGetObjectOrReturn(join, WCDB::Join, cppJoin);\n    cppJoin->naturalCrossJoin(WCDBCreateTableOrSubqueryFromCommonValue(query));\n}\n\nvoid WCDBJoinConfigOn(CPPJoin join, CPPExpression expression)\n{\n    WCDBGetObjectOrReturn(join, WCDB::Join, cppJoin);\n    WCDBGetObjectOrReturn(expression, WCDB::Expression, cppExpression);\n    cppJoin->on(*cppExpression);\n}\n\nvoid WCDBJoinConfigUsingColumn(CPPJoin join, const CPPColumn* columns, int columnNum)\n{\n    WCDBGetObjectOrReturn(join, WCDB::Join, cppJoin);\n    WCDBGetCPPSyntaxListOrReturn(WCDB::Column, cppColumns, columns, columnNum);\n    cppJoin->usingColumns(cppColumns);\n}\n\nvoid WCDBJoinConfigUsingColumn2(CPPJoin join, CPPCommonArray columns)\n{\n    WCDBGetObjectOrReturn(join, WCDB::Join, cppJoin);\n    WCDB::Columns cppColumns;\n    for (int i = 0; i < columns.length; i++) {\n        switch (columns.type) {\n        case WCDBBridgedType_String:\n            cppColumns.emplace_back(WCDB::UnsafeStringView(\n            WCDBGetCommonArrayLiteralValue(const char*, columns, i)));\n            break;\n        case WCDBBridgedType_Column:\n            cppColumns.push_back(WCDBGetCommonArrayObject(WCDB::Column, columns, i));\n            break;\n        default:\n            assert(0);\n            break;\n        }\n    }\n    cppJoin->usingColumns(cppColumns);\n}\n"
  },
  {
    "path": "src/bridge/winqbridge/identifier/JoinBridge.h",
    "content": "//\n// Created by qiuwenchen on 2022/6/11.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"WinqBridge.h\"\n\nWCDB_EXTERN_C_BEGIN\n\nCPPJoin WCDBJoinCreateWithTableOrSubquery(CPPTableOrSubquery query);\nCPPJoin WCDBJoinCreateWithTableOrSubquery2(CPPCommonValue query);\nvoid WCDBJoinWith(CPPJoin join, CPPTableOrSubquery query);\nvoid WCDBJoinWith2(CPPJoin join, CPPCommonValue query);\nvoid WCDBJoinWithJoin(CPPJoin join, CPPTableOrSubquery query);\nvoid WCDBJoinWithJoin2(CPPJoin join, CPPCommonValue query);\nvoid WCDBJoinWithLeftOuterJoin(CPPJoin join, CPPTableOrSubquery query);\nvoid WCDBJoinWithLeftOuterJoin2(CPPJoin join, CPPCommonValue query);\nvoid WCDBJoinWithLeftJoin(CPPJoin join, CPPTableOrSubquery query);\nvoid WCDBJoinWithLeftJoin2(CPPJoin join, CPPCommonValue query);\nvoid WCDBJoinWithInnerJoin(CPPJoin join, CPPTableOrSubquery query);\nvoid WCDBJoinWithInnerJoin2(CPPJoin join, CPPCommonValue query);\nvoid WCDBJoinWithCrossJoin(CPPJoin join, CPPTableOrSubquery query);\nvoid WCDBJoinWithCrossJoin2(CPPJoin join, CPPCommonValue query);\nvoid WCDBJoinWithNaturalJoin(CPPJoin join, CPPTableOrSubquery query);\nvoid WCDBJoinWithNaturalJoin2(CPPJoin join, CPPCommonValue query);\nvoid WCDBJoinWithNaturalLeftOuterJoin(CPPJoin join, CPPTableOrSubquery query);\nvoid WCDBJoinWithNaturalLeftOuterJoin2(CPPJoin join, CPPCommonValue query);\nvoid WCDBJoinWithNaturalLeftJoin(CPPJoin join, CPPTableOrSubquery query);\nvoid WCDBJoinWithNaturalLeftJoin2(CPPJoin join, CPPCommonValue query);\nvoid WCDBJoinWithNaturalInnerJoin(CPPJoin join, CPPTableOrSubquery query);\nvoid WCDBJoinWithNaturalInnerJoin2(CPPJoin join, CPPCommonValue query);\nvoid WCDBJoinWithNaturalCrossJoin(CPPJoin join, CPPTableOrSubquery query);\nvoid WCDBJoinWithNaturalCrossJoin2(CPPJoin join, CPPCommonValue query);\nvoid WCDBJoinConfigOn(CPPJoin join, CPPExpression expression);\nvoid WCDBJoinConfigUsingColumn(CPPJoin join, const CPPColumn* columns, int columnNum);\nvoid WCDBJoinConfigUsingColumn2(CPPJoin join, CPPCommonArray columns);\n\nWCDB_EXTERN_C_END\n"
  },
  {
    "path": "src/bridge/winqbridge/identifier/LiteralValueBridge.cpp",
    "content": "//\n// Created by qiuwenchen on 2022/5/26.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"LiteralValueBridge.h\"\n#include \"LiteralValue.hpp\"\n#include \"ObjectBridge.hpp\"\n#include <cstdint>\n\nCPPLiteralValue WCDBLiteralValueCreate(CPPCommonValue value)\n{\n    switch (value.type) {\n    case WCDBBridgedType_Null:\n        return WCDBCreateCPPBridgedObjectWithParameters(\n        CPPLiteralValue, WCDB::LiteralValue, nullptr);\n    case WCDBBridgedType_Bool:\n        return WCDBCreateCPPBridgedObjectWithParameters(\n        CPPLiteralValue, WCDB::LiteralValue, (bool) value.intValue);\n    case WCDBBridgedType_Int:\n        return WCDBCreateCPPBridgedObjectWithParameters(\n        CPPLiteralValue, WCDB::LiteralValue, (int64_t) value.intValue);\n    case WCDBBridgedType_UInt:\n        return WCDBCreateCPPBridgedObjectWithParameters(\n        CPPLiteralValue, WCDB::LiteralValue, (uint64_t) value.intValue);\n    case WCDBBridgedType_Double:\n        return WCDBCreateCPPBridgedObjectWithParameters(\n        CPPLiteralValue, WCDB::LiteralValue, value.doubleValue);\n    case WCDBBridgedType_String:\n        return WCDBCreateCPPBridgedObjectWithParameters(\n        CPPLiteralValue,\n        WCDB::LiteralValue,\n        WCDB::StringView((const char*) value.intValue));\n    default:\n        assert(0);\n    }\n    return WCDBCreateCPPBridgedObjectWithParameters(\n    CPPLiteralValue, WCDB::LiteralValue, nullptr);\n}\n\nCPPLiteralValue WCDBLiteralValueCreateWithInt64(long long value)\n{\n    return WCDBCreateCPPBridgedObjectWithParameters(\n    CPPLiteralValue, WCDB::LiteralValue, (int64_t) value);\n}\n\nCPPLiteralValue WCDBLiteralValueCreateWithUInt64(unsigned long long value)\n{\n    return WCDBCreateCPPBridgedObjectWithParameters(\n    CPPLiteralValue, WCDB::LiteralValue, (uint64_t) value);\n}\n\nCPPLiteralValue WCDBLiteralValueCreateWithDouble(double value)\n{\n    return WCDBCreateCPPBridgedObjectWithParameters(\n    CPPLiteralValue, WCDB::LiteralValue, value);\n}\n\nCPPLiteralValue WCDBLiteralValueCreateWithNull()\n{\n    return WCDBCreateCPPBridgedObjectWithParameters(\n    CPPLiteralValue, WCDB::LiteralValue, nullptr);\n}\n\nCPPLiteralValue WCDBLiteralValueCreateWithBool(bool value)\n{\n    return WCDBCreateCPPBridgedObjectWithParameters(\n    CPPLiteralValue, WCDB::LiteralValue, value);\n}\n\nCPPLiteralValue WCDBLiteralValueCreateWithString(const char* _Nullable value)\n{\n    return WCDBCreateCPPBridgedObjectWithParameters(\n    CPPLiteralValue, WCDB::LiteralValue, WCDB::StringView(value));\n}\n\nCPPLiteralValue WCDBLiteralValueCreateWithCurrentTime()\n{\n    return WCDBCreateCPPBridgedObjectByCopy(CPPLiteralValue,\n                                            WCDB::LiteralValue::currentTime());\n}\n\nCPPLiteralValue WCDBLiteralValueCreateWithCurrentDate()\n{\n    return WCDBCreateCPPBridgedObjectByCopy(CPPLiteralValue,\n                                            WCDB::LiteralValue::currentDate());\n}\n\nCPPLiteralValue WCDBLiteralValueCreateWithCurrentTimestamp()\n{\n    return WCDBCreateCPPBridgedObjectByCopy(\n    CPPLiteralValue, WCDB::LiteralValue::currentTimestamp());\n}\n"
  },
  {
    "path": "src/bridge/winqbridge/identifier/LiteralValueBridge.h",
    "content": "//\n// Created by qiuwenchen on 2022/5/26.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n#pragma once\n\n#include \"WinqBridge.h\"\n\nWCDB_EXTERN_C_BEGIN\n\nCPPLiteralValue WCDBLiteralValueCreate(CPPCommonValue value);\n\nCPPLiteralValue WCDBLiteralValueCreateWithInt64(long long value);\nCPPLiteralValue WCDBLiteralValueCreateWithUInt64(unsigned long long value);\nCPPLiteralValue WCDBLiteralValueCreateWithDouble(double value);\nCPPLiteralValue WCDBLiteralValueCreateWithNull(void);\nCPPLiteralValue WCDBLiteralValueCreateWithBool(bool value);\nCPPLiteralValue WCDBLiteralValueCreateWithString(const char* _Nullable value);\nCPPLiteralValue WCDBLiteralValueCreateWithCurrentTime(void);\nCPPLiteralValue WCDBLiteralValueCreateWithCurrentDate(void);\nCPPLiteralValue WCDBLiteralValueCreateWithCurrentTimestamp(void);\n\nWCDB_EXTERN_C_END\n"
  },
  {
    "path": "src/bridge/winqbridge/identifier/OrderingTermBridge.cpp",
    "content": "//\n// Created by qiuwenchen on 2022/5/29.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"OrderingTermBridge.h\"\n#include \"Expression.hpp\"\n#include \"ObjectBridge.hpp\"\n#include \"OrderingTerm.hpp\"\n#include \"WinqBridge.hpp\"\n\nCPPOrderingTerm WCDBOrderingTermCreate(CPPExpression expression)\n{\n    WCDBGetObjectOrReturnValue(\n    expression, WCDB::Expression, cppExpression, CPPOrderingTerm());\n    return WCDBCreateCPPBridgedObjectWithParameters(\n    CPPOrderingTerm, WCDB::OrderingTerm, *cppExpression);\n}\n\nCPPOrderingTerm WCDBOrderingTermCreate2(CPPCommonValue expression)\n{\n    return WCDBCreateCPPBridgedObjectWithParameters(\n    CPPOrderingTerm, WCDB::OrderingTerm, WCDBCreateExpressionFromCommonValue(expression));\n}\n\nvoid WCDBOrderingTermConfigCollation(CPPOrderingTerm orderingTerm, const char* _Nullable collation)\n{\n    WCDBGetObjectOrReturn(orderingTerm, WCDB::OrderingTerm, cppOrderingTerm);\n    cppOrderingTerm->collate(collation);\n}\nvoid WCDBOrderingTermConfigOrder(CPPOrderingTerm orderingTerm, enum WCDBSyntaxOrder order)\n{\n    WCDBGetObjectOrReturn(orderingTerm, WCDB::OrderingTerm, cppOrderingTerm);\n    cppOrderingTerm->order(WCDB::WinqBridge::changeOrder(order));\n}\n"
  },
  {
    "path": "src/bridge/winqbridge/identifier/OrderingTermBridge.h",
    "content": "//\n// Created by qiuwenchen on 2022/5/29.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"WinqBridge.h\"\n\nWCDB_EXTERN_C_BEGIN\n\nCPPOrderingTerm WCDBOrderingTermCreate(CPPExpression expression);\nCPPOrderingTerm WCDBOrderingTermCreate2(CPPCommonValue expression);\nvoid WCDBOrderingTermConfigCollation(CPPOrderingTerm orderingTerm,\n                                     const char* _Nullable collation);\nvoid WCDBOrderingTermConfigOrder(CPPOrderingTerm orderingTerm, enum WCDBSyntaxOrder order);\n\nWCDB_EXTERN_C_END\n"
  },
  {
    "path": "src/bridge/winqbridge/identifier/PragmaBridge.cpp",
    "content": "//\n// Created by qiuwenchen on 2022/6/12.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"PragmaBridge.h\"\n#include \"ObjectBridge.hpp\"\n#include \"Pragma.hpp\"\n\nCPPPragma WCDBPragmaCreateWithName(const char* _Nullable name)\n{\n    return WCDBCreateCPPBridgedObjectWithParameters(CPPPragma, WCDB::Pragma, name);\n}\n"
  },
  {
    "path": "src/bridge/winqbridge/identifier/PragmaBridge.h",
    "content": "//\n// Created by qiuwenchen on 2022/6/12.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"WinqBridge.h\"\n\nWCDB_EXTERN_C_BEGIN\n\nCPPPragma WCDBPragmaCreateWithName(const char* _Nullable name);\n\nWCDB_EXTERN_C_END\n"
  },
  {
    "path": "src/bridge/winqbridge/identifier/QualifiedTableBridge.cpp",
    "content": "//\n// Created by qiuwenchen on 2022/6/11.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"QualifiedTableBridge.h\"\n#include \"ObjectBridge.hpp\"\n#include \"QualifiedTable.hpp\"\n#include \"Schema.hpp\"\n#include \"WinqBridge.hpp\"\n\nCPPQualifiedTable WCDBQualifiedTableCreateWithTable(const char* _Nullable name)\n{\n    return WCDBCreateCPPBridgedObjectWithParameters(\n    CPPQualifiedTable, WCDB::QualifiedTable, name);\n}\n\nvoid WCDBQualifiedTableConfigSchema2(CPPQualifiedTable table, CPPCommonValue schema)\n{\n    WCDBGetObjectOrReturn(table, WCDB::QualifiedTable, cppTable);\n    cppTable->schema(WCDBCreateSchemaFromCommonValue(schema));\n}\n\nvoid WCDBQualifiedTableConfigSchema(CPPQualifiedTable table, CPPSchema schema)\n{\n    WCDBGetObjectOrReturn(table, WCDB::QualifiedTable, cppTable);\n    WCDBGetObjectOrReturn(schema, WCDB::Schema, cppSchema);\n    cppTable->schema(*cppSchema);\n}\n\nvoid WCDBQualifiedTableConfigAliasName(CPPQualifiedTable table, const char* _Nullable alias)\n{\n    WCDBGetObjectOrReturn(table, WCDB::QualifiedTable, cppTable);\n    cppTable->as(alias);\n}\n\nvoid WCDBQualifiedTableConfigIndexName(CPPQualifiedTable table, const char* _Nullable indexName)\n{\n    WCDBGetObjectOrReturn(table, WCDB::QualifiedTable, cppTable);\n    cppTable->indexed(indexName);\n}\n\nvoid WCDBQualifiedTableConfigNoIndexed(CPPQualifiedTable table)\n{\n    WCDBGetObjectOrReturn(table, WCDB::QualifiedTable, cppTable);\n    cppTable->notIndexed();\n}\n"
  },
  {
    "path": "src/bridge/winqbridge/identifier/QualifiedTableBridge.h",
    "content": "//\n// Created by qiuwenchen on 2022/6/11.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"WinqBridge.h\"\n\nWCDB_EXTERN_C_BEGIN\n\nCPPQualifiedTable WCDBQualifiedTableCreateWithTable(const char* _Nullable name);\nvoid WCDBQualifiedTableConfigSchema2(CPPQualifiedTable table, CPPCommonValue schema);\nvoid WCDBQualifiedTableConfigSchema(CPPQualifiedTable table, CPPSchema schema);\nvoid WCDBQualifiedTableConfigAliasName(CPPQualifiedTable table, const char* _Nullable alias);\nvoid WCDBQualifiedTableConfigIndexName(CPPQualifiedTable table, const char* _Nullable indexName);\nvoid WCDBQualifiedTableConfigNoIndexed(CPPQualifiedTable table);\n\nWCDB_EXTERN_C_END\n"
  },
  {
    "path": "src/bridge/winqbridge/identifier/RaiseFunctionBridge.cpp",
    "content": "//\n// Created by qiuwenchen on 2022/5/30.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"RaiseFunctionBridge.h\"\n#include \"ObjectBridge.hpp\"\n#include \"RaiseFunction.hpp\"\n\nCPPRaiseFunction WCDBRaiseFunctionCreate()\n{\n    return WCDBCreateCPPBridgedObject(CPPRaiseFunction, WCDB::RaiseFunction);\n}\nvoid WCDBRaiseFunctionSetAction(CPPRaiseFunction function,\n                                enum WCDBSyntaxRaiseAction action,\n                                const char* _Nullable errMsg)\n{\n    WCDBGetObjectOrReturn(function, WCDB::RaiseFunction, cppFunction);\n    cppFunction->syntax().errorMessage = errMsg;\n    switch (action) {\n    case WCDBSyntaxRaiseAction_Ignore:\n        cppFunction->syntax().switcher = WCDB::Syntax::RaiseFunction::Switch::Ignore;\n        break;\n    case WCDBSyntaxRaiseAction_Rollback:\n        cppFunction->syntax().switcher = WCDB::Syntax::RaiseFunction::Switch::Rollback;\n        break;\n    case WCDBSyntaxRaiseAction_Abort:\n        cppFunction->syntax().switcher = WCDB::Syntax::RaiseFunction::Switch::Abort;\n        break;\n    case WCDBSyntaxRaiseAction_Fail:\n        cppFunction->syntax().switcher = WCDB::Syntax::RaiseFunction::Switch::Fail;\n        break;\n    }\n}\n"
  },
  {
    "path": "src/bridge/winqbridge/identifier/RaiseFunctionBridge.h",
    "content": "//\n// Created by qiuwenchen on 2022/5/30.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n#include \"WinqBridge.h\"\n\nenum WCDBSyntaxRaiseAction {\n    WCDBSyntaxRaiseAction_Ignore = 0,\n    WCDBSyntaxRaiseAction_Rollback,\n    WCDBSyntaxRaiseAction_Abort,\n    WCDBSyntaxRaiseAction_Fail,\n};\n\nWCDB_EXTERN_C_BEGIN\n\nCPPRaiseFunction WCDBRaiseFunctionCreate(void);\nvoid WCDBRaiseFunctionSetAction(CPPRaiseFunction function,\n                                enum WCDBSyntaxRaiseAction action,\n                                const char* _Nullable errMsg);\n\nWCDB_EXTERN_C_END\n"
  },
  {
    "path": "src/bridge/winqbridge/identifier/ResultColumnBridge.cpp",
    "content": "//\n// Created by qiuwenchen on 2022/6/12.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"ResultColumnBridge.h\"\n#include \"Column.hpp\"\n#include \"Expression.hpp\"\n#include \"ObjectBridge.hpp\"\n#include \"ResultColumn.hpp\"\n#include \"WinqBridge.hpp\"\n\nCPPResultColumn WCDBResultColumnCreate(CPPCommonValue expression)\n{\n    if (expression.type == WCDBBridgedType_String) {\n        return WCDBCreateCPPBridgedObjectWithParameters(\n        CPPResultColumn,\n        WCDB::ResultColumn,\n        WCDB::Column((const char*) expression.intValue));\n    } else if (expression.type == WCDBBridgedType_ResultColumn) {\n        return WCDBCreateCPPBridgedObjectByCopy(\n        CPPResultColumn, WCDBGetBridgedData(WCDB::ResultColumn, expression));\n    } else {\n        return WCDBCreateCPPBridgedObjectWithParameters(\n        CPPResultColumn, WCDB::ResultColumn, WCDBCreateExpressionFromCommonValue(expression));\n    }\n}\n\nCPPResultColumn WCDBResultColumnCreateWithExpression(CPPExpression expression)\n{\n    WCDBGetObjectOrReturnValue(\n    expression, WCDB::Expression, cppExpression, CPPResultColumn());\n    return WCDBCreateCPPBridgedObjectWithParameters(\n    CPPResultColumn, WCDB::ResultColumn, *cppExpression);\n}\n\nvoid WCDBResultColumnConfigAlias(CPPResultColumn column, const char* _Nullable alias)\n{\n    WCDBGetObjectOrReturn(column, WCDB::ResultColumn, cppColumn);\n    cppColumn->as(alias);\n}\n"
  },
  {
    "path": "src/bridge/winqbridge/identifier/ResultColumnBridge.h",
    "content": "//\n// Created by qiuwenchen on 2022/6/12.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"WinqBridge.h\"\n\nWCDB_EXTERN_C_BEGIN\n\nCPPResultColumn WCDBResultColumnCreate(CPPCommonValue expression);\nCPPResultColumn WCDBResultColumnCreateWithExpression(CPPExpression expression);\nvoid WCDBResultColumnConfigAlias(CPPResultColumn column, const char* _Nullable alias);\n\nWCDB_EXTERN_C_END\n"
  },
  {
    "path": "src/bridge/winqbridge/identifier/SchemaBridge.cpp",
    "content": "//\n// Created by qiuwenchen on 2022/5/26.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"SchemaBridge.h\"\n#include \"ObjectBridge.hpp\"\n#include \"Schema.hpp\"\n\nCPPSchema WCDBSchemaCreateWithName(const char* _Nullable name)\n{\n    return WCDBCreateCPPBridgedObjectWithParameters(CPPSchema, WCDB::Schema, name);\n}\n\nCPPSchema WCDBSchemaMain()\n{\n    return WCDBCreateCPPBridgedObjectByCopy(CPPSchema, WCDB::Schema::main());\n}\n\nCPPSchema WCDBSchemaTemp()\n{\n    return WCDBCreateCPPBridgedObjectByCopy(CPPSchema, WCDB::Schema::temp());\n}\n"
  },
  {
    "path": "src/bridge/winqbridge/identifier/SchemaBridge.h",
    "content": "//\n// Created by qiuwenchen on 2022/5/26.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"WinqBridge.h\"\n\nWCDB_EXTERN_C_BEGIN\n\nCPPSchema WCDBSchemaCreateWithName(const char* _Nullable name);\nCPPSchema WCDBSchemaMain(void);\nCPPSchema WCDBSchemaTemp(void);\n\nWCDB_EXTERN_C_END\n"
  },
  {
    "path": "src/bridge/winqbridge/identifier/TableConstraintBridge.cpp",
    "content": "//\n// Created by qiuwenchen on 2022/6/12.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"TableConstraintBridge.h\"\n#include \"Column.hpp\"\n#include \"Expression.hpp\"\n#include \"ForeignKey.hpp\"\n#include \"IndexedColumn.hpp\"\n#include \"ObjectBridge.hpp\"\n#include \"TableConstraint.hpp\"\n#include \"WinqBridge.hpp\"\n\nCPPTableConstraint WCDBTableConstraintCreate(const char* _Nullable name)\n{\n    return WCDBCreateCPPBridgedObjectWithParameters(\n    CPPTableConstraint, WCDB::TableConstraint, name);\n}\n\nvoid WCDBTableConstraintConfigPrimaryKey(CPPTableConstraint constraint)\n{\n    WCDBGetObjectOrReturn(constraint, WCDB::TableConstraint, cppConstraint);\n    cppConstraint->primaryKey();\n}\n\nvoid WCDBTableConstraintConfigUnique(CPPTableConstraint constraint)\n{\n    WCDBGetObjectOrReturn(constraint, WCDB::TableConstraint, cppConstraint);\n    cppConstraint->unique();\n}\n\nvoid WCDBTableConstraintConfigIndexedColumn(CPPTableConstraint constraint,\n                                            const CPPIndexedColumn* _Nullable columns,\n                                            int colNum)\n{\n    WCDBGetObjectOrReturn(constraint, WCDB::TableConstraint, cppConstraint);\n    WCDBGetCPPSyntaxListOrReturn(WCDB::IndexedColumn, cppColumns, columns, colNum);\n    cppConstraint->syntax().indexedColumns = cppColumns;\n}\n\nvoid WCDBTableConstraintConfigIndexedColumn2(CPPTableConstraint constraint, CPPCommonArray columns)\n{\n    WCDBGetObjectOrReturn(constraint, WCDB::TableConstraint, cppTableConstraint);\n    WCDB::IndexedColumns indexedColumns;\n    for (int i = 0; i < columns.length; i++) {\n        switch (columns.type) {\n        case WCDBBridgedType_String:\n            indexedColumns.emplace_back(WCDB::UnsafeStringView(\n            WCDBGetCommonArrayLiteralValue(const char*, columns, i)));\n            break;\n        case WCDBBridgedType_Column:\n            indexedColumns.emplace_back(WCDBGetCommonArrayObject(WCDB::Column, columns, i));\n            break;\n        case WCDBBridgedType_Expression:\n            indexedColumns.emplace_back(\n            WCDBGetCommonArrayObject(WCDB::Expression, columns, i));\n            break;\n        case WCDBBridgedType_IndexedColumn:\n            indexedColumns.push_back(\n            WCDBGetCommonArrayObject(WCDB::IndexedColumn, columns, i));\n            break;\n        default:\n            assert(0);\n            break;\n        }\n    }\n    cppTableConstraint->syntax().indexedColumns = indexedColumns;\n}\n\nvoid WCDBTableConstraintConfigConfliction(CPPTableConstraint constraint,\n                                          enum WCDBSyntaxConflictAction conflict)\n{\n    WCDBGetObjectOrReturn(constraint, WCDB::TableConstraint, cppConstraint);\n    cppConstraint->conflict(WCDB::WinqBridge::changeConflict(conflict));\n}\n\nvoid WCDBTableConstraintConfigCheckCondition(CPPTableConstraint constraint, CPPExpression expression)\n{\n    WCDBGetObjectOrReturn(constraint, WCDB::TableConstraint, cppConstraint);\n    WCDBGetObjectOrReturn(expression, WCDB::Expression, cppExpression);\n    cppConstraint->check(*cppExpression);\n}\n\nvoid WCDBTableConstraintConfigForeignKey(CPPTableConstraint constraint,\n                                         const CPPColumn* _Nullable columns,\n                                         int colNum,\n                                         CPPForeignKey foreignKey)\n{\n    WCDBGetObjectOrReturn(constraint, WCDB::TableConstraint, cppConstraint);\n    WCDBGetObjectOrReturn(foreignKey, WCDB::ForeignKey, cppForeignKey);\n    WCDBGetCPPSyntaxListOrReturn(WCDB::Column, cppColumns, columns, colNum);\n    cppConstraint->foreignKey(cppColumns, *cppForeignKey);\n}\n\nvoid WCDBTableConstraintConfigForeignKey2(CPPTableConstraint constraint,\n                                          CPPCommonArray columns,\n                                          CPPForeignKey foreignKey)\n{\n    WCDBGetObjectOrReturn(constraint, WCDB::TableConstraint, cppConstraint);\n    WCDBGetObjectOrReturn(foreignKey, WCDB::ForeignKey, cppForeignKey);\n    WCDB::Columns cppColumns;\n    for (int i = 0; i < columns.length; i++) {\n        switch (columns.type) {\n        case WCDBBridgedType_String:\n            cppColumns.emplace_back(WCDBGetCommonArrayLiteralValue(const char*, columns, i));\n            break;\n        case WCDBBridgedType_Column:\n            cppColumns.push_back(WCDBGetCommonArrayObject(WCDB::Column, columns, i));\n            break;\n        default:\n            assert(0);\n            break;\n        }\n    }\n    cppConstraint->foreignKey(cppColumns, *cppForeignKey);\n}\n"
  },
  {
    "path": "src/bridge/winqbridge/identifier/TableConstraintBridge.h",
    "content": "//\n// Created by qiuwenchen on 2022/6/12.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"WinqBridge.h\"\n\nWCDB_EXTERN_C_BEGIN\n\nCPPTableConstraint WCDBTableConstraintCreate(const char* _Nullable name);\nvoid WCDBTableConstraintConfigPrimaryKey(CPPTableConstraint constraint);\nvoid WCDBTableConstraintConfigUnique(CPPTableConstraint constraint);\nvoid WCDBTableConstraintConfigIndexedColumn(CPPTableConstraint constraint,\n                                            const CPPIndexedColumn* _Nullable columns,\n                                            int colNum);\nvoid WCDBTableConstraintConfigIndexedColumn2(CPPTableConstraint constraint,\n                                             CPPCommonArray columns);\nvoid WCDBTableConstraintConfigConfliction(CPPTableConstraint constraint,\n                                          enum WCDBSyntaxConflictAction conflict);\nvoid WCDBTableConstraintConfigCheckCondition(CPPTableConstraint constraint,\n                                             CPPExpression expression);\nvoid WCDBTableConstraintConfigForeignKey(CPPTableConstraint constraint,\n                                         const CPPColumn* _Nullable columns,\n                                         int colNum,\n                                         CPPForeignKey foreignKey);\n\nvoid WCDBTableConstraintConfigForeignKey2(CPPTableConstraint constraint,\n                                          CPPCommonArray columns,\n                                          CPPForeignKey foreignKey);\n\nWCDB_EXTERN_C_END\n"
  },
  {
    "path": "src/bridge/winqbridge/identifier/TableOrSubqueryBridge.cpp",
    "content": "//\n// Created by qiuwenchen on 2022/6/11.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"TableOrSubqueryBridge.h\"\n#include \"Expression.hpp\"\n#include \"Join.hpp\"\n#include \"ObjectBridge.hpp\"\n#include \"Schema.hpp\"\n#include \"StatementSelect.hpp\"\n#include \"TableOrSubquery.hpp\"\n#include \"WinqBridge.hpp\"\n\nCPPTableOrSubquery WCDBTableOrSubqueryCreate(CPPCommonValue value)\n{\n    if (value.type == WCDBBridgedType_String) {\n        return WCDBCreateCPPBridgedObjectWithParameters(\n        CPPTableOrSubquery,\n        WCDB::TableOrSubquery,\n        WCDB::UnsafeStringView((const char*) value.intValue));\n    } else if (value.type == WCDBBridgedType_TableOrSubquery) {\n        return WCDBCreateCPPBridgedObjectByCopy(\n        CPPTableOrSubquery, WCDBGetBridgedData(WCDB::TableOrSubquery, value));\n    } else if (value.type == WCDBBridgedType_SelectSTMT) {\n        return WCDBCreateCPPBridgedObjectWithParameters(\n        CPPTableOrSubquery,\n        WCDB::TableOrSubquery,\n        WCDBGetBridgedData(WCDB::StatementSelect, value));\n    } else if (value.type == WCDBBridgedType_JoinClause) {\n        return WCDBCreateCPPBridgedObjectWithParameters(\n        CPPTableOrSubquery, WCDB::TableOrSubquery, WCDBGetBridgedData(WCDB::Join, value));\n    } else {\n        assert(value.type == WCDBBridgedType_Null);\n    }\n    return CPPTableOrSubquery();\n}\n\nCPPTableOrSubquery WCDBTableOrSubqueryCreateWithTable(const char* _Nullable tableName)\n{\n    return WCDBCreateCPPBridgedObjectWithParameters(\n    CPPTableOrSubquery, WCDB::TableOrSubquery, WCDB::UnsafeStringView(tableName));\n}\n\nCPPTableOrSubquery WCDBTableOrSubqueryCreateWithFunction(const char* _Nullable functionName)\n{\n    return WCDBCreateCPPBridgedObjectByCopy(\n    CPPTableOrSubquery, WCDB::TableOrSubquery::function(functionName));\n}\n\nCPPTableOrSubquery WCDBTableOrSubqueryCreateWithJoin(CPPJoin join)\n{\n    WCDBGetObjectOrReturnValue(join, WCDB::Join, cppJoin, CPPTableOrSubquery());\n    return WCDBCreateCPPBridgedObjectWithParameters(\n    CPPTableOrSubquery, WCDB::TableOrSubquery, *cppJoin);\n}\n\nCPPTableOrSubquery WCDBTableOrSubqueryCreateWithSelection(CPPStatementSelect select)\n{\n    WCDBGetObjectOrReturnValue(\n    select, WCDB::StatementSelect, cppSelect, CPPTableOrSubquery());\n    return WCDBCreateCPPBridgedObjectWithParameters(\n    CPPTableOrSubquery, WCDB::TableOrSubquery, *cppSelect);\n}\n\nCPPTableOrSubquery\nWCDBTableOrSubqueryCreateWithTableOrSubqueries(const CPPTableOrSubquery* queries, int queryNum)\n{\n    WCDBGetCPPSyntaxList(WCDB::TableOrSubquery, cppQueries, queries, queryNum);\n    return WCDBCreateCPPBridgedObjectWithParameters(\n    CPPTableOrSubquery, WCDB::TableOrSubquery, cppQueries);\n}\n\nCPPTableOrSubquery\nWCDBTableOrSubqueryCreateWithTableOrSubqueries2(CPPCommonArray tableOrSubqueries)\n{\n    WCDB::TablesOrSubqueries cppTableOrSubqueries;\n    for (int i = 0; i < tableOrSubqueries.length; i++) {\n        switch (tableOrSubqueries.type) {\n        case WCDBBridgedType_String:\n            cppTableOrSubqueries.emplace_back(WCDB::UnsafeStringView(\n            WCDBGetCommonArrayLiteralValue(const char*, tableOrSubqueries, i)));\n            break;\n        case WCDBBridgedType_SelectSTMT:\n            cppTableOrSubqueries.emplace_back(WCDBGetCommonArrayObject(\n            WCDB::StatementSelect, tableOrSubqueries, i));\n            break;\n        case WCDBBridgedType_JoinClause:\n            cppTableOrSubqueries.emplace_back(\n            WCDBGetCommonArrayObject(WCDB::Join, tableOrSubqueries, i));\n            break;\n        default:\n            assert(0);\n            break;\n        }\n    }\n    return WCDBCreateCPPBridgedObjectWithParameters(\n    CPPTableOrSubquery, WCDB::TableOrSubquery, cppTableOrSubqueries);\n}\n\nvoid WCDBTableOrSubqueryConfigSchema2(CPPTableOrSubquery tableOrSubquery, CPPCommonValue schema)\n{\n    WCDBGetObjectOrReturn(tableOrSubquery, WCDB::TableOrSubquery, cppTableOrSubquery);\n    cppTableOrSubquery->schema(WCDBCreateSchemaFromCommonValue(schema));\n}\n\nvoid WCDBTableOrSubqueryConfigSchema(CPPTableOrSubquery tableOrSubquery, CPPSchema schema)\n{\n    WCDBGetObjectOrReturn(tableOrSubquery, WCDB::TableOrSubquery, cppTableOrSubquery);\n    WCDBGetObjectOrReturn(schema, WCDB::Schema, cppSchema);\n    cppTableOrSubquery->schema(*cppSchema);\n}\n\nvoid WCDBTableOrSubqueryConfigAs(CPPTableOrSubquery tableOrSubquery, const char* _Nullable aliasName)\n{\n    WCDBGetObjectOrReturn(tableOrSubquery, WCDB::TableOrSubquery, cppTableOrSubquery);\n    cppTableOrSubquery->as(aliasName);\n}\n\nvoid WCDBTableOrSubqueryConfigNotIndexed(CPPTableOrSubquery tableOrSubquery)\n{\n    WCDBGetObjectOrReturn(tableOrSubquery, WCDB::TableOrSubquery, cppTableOrSubquery);\n    cppTableOrSubquery->notIndexed();\n}\n\nvoid WCDBTableOrSubqueryConfigIndexName(CPPTableOrSubquery tableOrSubquery,\n                                        const char* _Nullable indexName)\n{\n    WCDBGetObjectOrReturn(tableOrSubquery, WCDB::TableOrSubquery, cppTableOrSubquery);\n    cppTableOrSubquery->indexed(indexName);\n}\n\nvoid WCDBTableOrSubqueryConfigArguments(CPPTableOrSubquery tableOrSubquery,\n                                        const CPPExpression* args,\n                                        int argNum)\n{\n    WCDBGetObjectOrReturn(tableOrSubquery, WCDB::TableOrSubquery, cppTableOrSubquery);\n    WCDBGetCPPSyntaxListOrReturn(WCDB::Expression, cppArgs, args, argNum);\n    cppTableOrSubquery->arguments(cppArgs);\n}\n\nvoid WCDBTableOrSubqueryConfigArgument(CPPTableOrSubquery tableOrSubquery, CPPCommonValue expression)\n{\n    WCDBGetObjectOrReturn(tableOrSubquery, WCDB::TableOrSubquery, cppTableOrSubquery);\n    cppTableOrSubquery->argument(WCDBCreateExpressionFromCommonValue(expression));\n}\n"
  },
  {
    "path": "src/bridge/winqbridge/identifier/TableOrSubqueryBridge.h",
    "content": "//\n// Created by qiuwenchen on 2022/6/11.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"WinqBridge.h\"\n\nWCDB_EXTERN_C_BEGIN\n\nCPPTableOrSubquery WCDBTableOrSubqueryCreate(CPPCommonValue value);\n\nCPPTableOrSubquery WCDBTableOrSubqueryCreateWithTable(const char* _Nullable tableName);\nCPPTableOrSubquery WCDBTableOrSubqueryCreateWithFunction(const char* _Nullable functionName);\nCPPTableOrSubquery WCDBTableOrSubqueryCreateWithJoin(CPPJoin join);\nCPPTableOrSubquery WCDBTableOrSubqueryCreateWithSelection(CPPStatementSelect select);\nCPPTableOrSubquery\nWCDBTableOrSubqueryCreateWithTableOrSubqueries(const CPPTableOrSubquery* _Nullable queries,\n                                               int queryNum);\n\nCPPTableOrSubquery\nWCDBTableOrSubqueryCreateWithTableOrSubqueries2(CPPCommonArray tableOrSubqueries);\n\nvoid WCDBTableOrSubqueryConfigSchema2(CPPTableOrSubquery tableOrSubquery, CPPCommonValue schema);\n\nvoid WCDBTableOrSubqueryConfigSchema(CPPTableOrSubquery tableOrSubquery, CPPSchema schema);\nvoid WCDBTableOrSubqueryConfigAs(CPPTableOrSubquery tableOrSubquery,\n                                 const char* _Nullable aliasName);\nvoid WCDBTableOrSubqueryConfigNotIndexed(CPPTableOrSubquery tableOrSubquery);\nvoid WCDBTableOrSubqueryConfigIndexName(CPPTableOrSubquery tableOrSubquery,\n                                        const char* _Nullable indexName);\nvoid WCDBTableOrSubqueryConfigArguments(CPPTableOrSubquery tableOrSubquery,\n                                        const CPPExpression* _Nullable args,\n                                        int argNum);\n\nvoid WCDBTableOrSubqueryConfigArgument(CPPTableOrSubquery tableOrSubquery,\n                                       CPPCommonValue expression);\n\nWCDB_EXTERN_C_END\n"
  },
  {
    "path": "src/bridge/winqbridge/identifier/UpsertBridge.cpp",
    "content": "//\n// Created by qiuwenchen on 2022/6/12.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"UpsertBridge.h\"\n#include \"Column.hpp\"\n#include \"Expression.hpp\"\n#include \"IndexedColumn.hpp\"\n#include \"ObjectBridge.hpp\"\n#include \"Upsert.hpp\"\n#include \"WinqBridge.hpp\"\n\nCPPUpsert WCDBUpsertCreate()\n{\n    return WCDBCreateCPPBridgedObject(CPPUpsert, WCDB::Upsert);\n}\n\nvoid WCDBUpsertConfigIndexdColumn(CPPUpsert upsert,\n                                  const CPPIndexedColumn* _Nullable columns,\n                                  int colnum)\n{\n    WCDBGetObjectOrReturn(upsert, WCDB::Upsert, cppUpsert);\n    WCDBGetCPPSyntaxListOrReturn(WCDB::IndexedColumn, cppColumns, columns, colnum);\n    cppUpsert->syntax().indexedColumns = cppColumns;\n}\n\nvoid WCDBUpsertConfigIndexdColumn2(CPPUpsert upsert, CPPCommonArray columns)\n{\n    WCDBGetObjectOrReturn(upsert, WCDB::Upsert, cppUpsert);\n    WCDB::IndexedColumns indexedColumns;\n    for (int i = 0; i < columns.length; i++) {\n        switch (columns.type) {\n        case WCDBBridgedType_String:\n            indexedColumns.emplace_back(\n            WCDB::Column(WCDBGetCommonArrayLiteralValue(const char*, columns, i)));\n            break;\n        case WCDBBridgedType_Column:\n            indexedColumns.emplace_back(WCDBGetCommonArrayObject(WCDB::Column, columns, i));\n            break;\n        case WCDBBridgedType_Expression:\n            indexedColumns.emplace_back(\n            WCDBGetCommonArrayObject(WCDB::Expression, columns, i));\n            break;\n        case WCDBBridgedType_IndexedColumn:\n            indexedColumns.push_back(\n            WCDBGetCommonArrayObject(WCDB::IndexedColumn, columns, i));\n            break;\n        default:\n            assert(0);\n            break;\n        }\n    }\n    cppUpsert->syntax().indexedColumns = indexedColumns;\n}\n\nvoid WCDBUpsertConfigWhere(CPPUpsert upsert, CPPExpression expression)\n{\n    WCDBGetObjectOrReturn(upsert, WCDB::Upsert, cppUpsert);\n    WCDBGetObjectOrReturn(expression, WCDB::Expression, cppExpression);\n    cppUpsert->where(*cppExpression);\n}\n\nvoid WCDBUpsertConfigDoNothing(CPPUpsert upsert)\n{\n    WCDBGetObjectOrReturn(upsert, WCDB::Upsert, cppUpsert);\n    cppUpsert->doNothing();\n}\n\nvoid WCDBUpsertConfigDoUpdate(CPPUpsert upsert)\n{\n    WCDBGetObjectOrReturn(upsert, WCDB::Upsert, cppUpsert);\n    cppUpsert->doUpdate();\n}\n\nvoid WCDBUpsertConfigSetColumns(CPPUpsert upsert, const CPPColumn* _Nullable columns, int colNum)\n{\n    WCDBGetObjectOrReturn(upsert, WCDB::Upsert, cppUpsert);\n    WCDBGetCPPSyntaxListOrReturn(WCDB::Column, cppColumns, columns, colNum);\n    cppUpsert->set(cppColumns);\n}\n\nvoid WCDBUpsertConfigSetColumns2(CPPUpsert upsert, CPPCommonArray columns)\n{\n    WCDBGetObjectOrReturn(upsert, WCDB::Upsert, cppUpsert);\n    WCDB::Columns cppColumns;\n    for (int i = 0; i < columns.length; i++) {\n        switch (columns.type) {\n        case WCDBBridgedType_String:\n            cppColumns.emplace_back(\n            WCDB::Column(WCDBGetCommonArrayLiteralValue(const char*, columns, i)));\n            break;\n        case WCDBBridgedType_Column:\n            cppColumns.emplace_back(WCDBGetCommonArrayObject(WCDB::Column, columns, i));\n            break;\n        default:\n            assert(0);\n            break;\n        }\n    }\n    cppUpsert->set(cppColumns);\n}\n\nvoid WCDBUpsertConfigToValue(CPPUpsert upsert, CPPExpression expression)\n{\n    WCDBGetObjectOrReturn(upsert, WCDB::Upsert, cppUpsert);\n    WCDBGetObjectOrReturn(expression, WCDB::Expression, cppExpression);\n    cppUpsert->to(*cppExpression);\n}\n\nvoid WCDBUpsertConfigToValue2(CPPUpsert upsert, CPPCommonValue expression)\n{\n    WCDBGetObjectOrReturn(upsert, WCDB::Upsert, cppUpsert);\n    cppUpsert->to(WCDBCreateExpressionFromCommonValue(expression));\n}\n"
  },
  {
    "path": "src/bridge/winqbridge/identifier/UpsertBridge.h",
    "content": "//\n// Created by qiuwenchen on 2022/6/12.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"WinqBridge.h\"\n\nWCDB_EXTERN_C_BEGIN\n\nCPPUpsert WCDBUpsertCreate(void);\nvoid WCDBUpsertConfigIndexdColumn(CPPUpsert upsert,\n                                  const CPPIndexedColumn* _Nullable columns,\n                                  int colnum);\nvoid WCDBUpsertConfigIndexdColumn2(CPPUpsert upsert, CPPCommonArray columns);\nvoid WCDBUpsertConfigWhere(CPPUpsert upsert, CPPExpression expression);\nvoid WCDBUpsertConfigDoNothing(CPPUpsert upsert);\nvoid WCDBUpsertConfigDoUpdate(CPPUpsert upsert);\nvoid WCDBUpsertConfigSetColumns(CPPUpsert upsert, const CPPColumn* _Nullable columns, int colNum);\nvoid WCDBUpsertConfigSetColumns2(CPPUpsert upsert, CPPCommonArray columns);\nvoid WCDBUpsertConfigToValue(CPPUpsert upsert, CPPExpression expression);\nvoid WCDBUpsertConfigToValue2(CPPUpsert upsert, CPPCommonValue expression);\n\nWCDB_EXTERN_C_END\n"
  },
  {
    "path": "src/bridge/winqbridge/identifier/WindowDefBridge.cpp",
    "content": "//\n// Created by qiuwenchen on 2022/5/30.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"WindowDefBridge.h\"\n#include \"Column.hpp\"\n#include \"Expression.hpp\"\n#include \"LiteralValue.hpp\"\n#include \"ObjectBridge.hpp\"\n#include \"OrderingTerm.hpp\"\n#include \"WindowDef.hpp\"\n#include \"WinqBridge.hpp\"\n\nCPPWindowDef WCDBWindowDefCreate(void)\n{\n    return WCDBCreateCPPBridgedObject(CPPWindowDef, WCDB::WindowDef);\n}\n\nvoid WCDBWindowDefConfigPartition(CPPWindowDef def, const CPPExpression* partitions, int partitionNum)\n{\n    WCDBGetObjectOrReturn(def, WCDB::WindowDef, cppDef);\n    WCDBGetCPPSyntaxListOrReturn(WCDB::Expression, cppPartitions, partitions, partitionNum);\n    cppDef->partition(cppPartitions);\n}\n\nvoid WCDBWindowDefConfigPartition2(CPPWindowDef def, CPPMultiTypeArray partitions)\n{\n    WCDBGetObjectOrReturn(def, WCDB::WindowDef, cppDef);\n    WCDB::Expressions cppPartitions;\n    int intIndex = 0;\n    int stringIndex = 0;\n    for (int i = 0; i < partitions.totalLength; i++) {\n        switch (partitions.types[i]) {\n        case WCDBBridgedType_String: {\n            cppPartitions.emplace_back(WCDB::Column(\n            WCDB::UnsafeStringView(partitions.stringValues[stringIndex])));\n            stringIndex++;\n        } break;\n        case WCDBBridgedType_Column: {\n            cppPartitions.emplace_back(\n            WCDBGetMultiTypeArrayObject(WCDB::Column, partitions, intIndex));\n            intIndex++;\n        } break;\n        case WCDBBridgedType_LiteralValue: {\n            cppPartitions.emplace_back(\n            WCDBGetMultiTypeArrayObject(WCDB::LiteralValue, partitions, i));\n            intIndex++;\n        } break;\n        case WCDBBridgedType_Expression: {\n            cppPartitions.emplace_back(\n            WCDBGetMultiTypeArrayObject(WCDB::Expression, partitions, i));\n            intIndex++;\n        } break;\n        default:\n            assert(partitions.types[i] == WCDBBridgedType_Invalid);\n            break;\n        }\n    }\n    cppDef->partition(cppPartitions);\n}\n\nvoid WCDBWindowDefConfigOrder(CPPWindowDef def,\n                              const CPPOrderingTerm* _Nullable orderingTerms,\n                              int orderingTermNum)\n{\n    WCDBGetObjectOrReturn(def, WCDB::WindowDef, cppDef);\n    WCDBGetCPPSyntaxListOrReturn(WCDB::OrderingTerm, cppTerms, orderingTerms, orderingTermNum);\n    cppDef->order(cppTerms);\n}\n\nvoid WCDBWindowDefConfigFrameSpec(CPPWindowDef def, CPPFrameSpec frameSpec)\n{\n    WCDBGetObjectOrReturn(def, WCDB::WindowDef, cppDef);\n    WCDBGetObjectOrReturn(frameSpec, WCDB::FrameSpec, cppFrameSpec);\n    cppDef->framespec(*cppFrameSpec);\n}\n"
  },
  {
    "path": "src/bridge/winqbridge/identifier/WindowDefBridge.h",
    "content": "//\n// Created by qiuwenchen on 2022/5/30.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"WinqBridge.h\"\n\nWCDB_EXTERN_C_BEGIN\n\nCPPWindowDef WCDBWindowDefCreate(void);\nvoid WCDBWindowDefConfigPartition(CPPWindowDef def,\n                                  const CPPExpression* _Nullable partitions,\n                                  int partitionNum);\nvoid WCDBWindowDefConfigPartition2(CPPWindowDef def, CPPMultiTypeArray partitions);\nvoid WCDBWindowDefConfigOrder(CPPWindowDef def,\n                              const CPPOrderingTerm* _Nullable orderingTerms,\n                              int orderingTermNum);\nvoid WCDBWindowDefConfigFrameSpec(CPPWindowDef def, CPPFrameSpec frameSpec);\n\nWCDB_EXTERN_C_END\n"
  },
  {
    "path": "src/bridge/winqbridge/statement/StatementAlterTableBridge.cpp",
    "content": "//\n// Created by qiuwenchen on 2022/6/27.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"StatementAlterTableBridge.h\"\n#include \"Column.hpp\"\n#include \"ColumnDef.hpp\"\n#include \"ObjectBridge.hpp\"\n#include \"Schema.hpp\"\n#include \"StatementAlterTable.hpp\"\n#include \"WinqBridge.hpp\"\n\nCPPStatementAlterTable WCDBStatementAlterTableCreate()\n{\n    return WCDBCreateCPPBridgedObject(CPPStatementAlterTable, WCDB::StatementAlterTable);\n}\n\nvoid WCDBStatementAlterTableConfigTable(CPPStatementAlterTable alterTable,\n                                        const char* _Nullable name)\n{\n    WCDBGetObjectOrReturn(alterTable, WCDB::StatementAlterTable, cppAlterTable);\n    cppAlterTable->alterTable(name);\n}\n\nvoid WCDBStatementAlterTableConfigSchema(CPPStatementAlterTable alterTable, CPPSchema schema)\n{\n    WCDBGetObjectOrReturn(alterTable, WCDB::StatementAlterTable, cppAlterTable);\n    WCDBGetObjectOrReturn(schema, WCDB::Schema, cppSchema);\n    cppAlterTable->schema(*cppSchema);\n}\n\nvoid WCDBStatementAlterTableConfigSchema2(CPPStatementAlterTable alterTable, CPPCommonValue schema)\n{\n    WCDBGetObjectOrReturn(alterTable, WCDB::StatementAlterTable, cppAlterTable);\n    cppAlterTable->schema(WCDBCreateSchemaFromCommonValue(schema));\n}\n\nvoid WCDBStatementAlterTableConfigRenameToTable(CPPStatementAlterTable alterTable,\n                                                const char* _Nullable name)\n{\n    WCDBGetObjectOrReturn(alterTable, WCDB::StatementAlterTable, cppAlterTable);\n    cppAlterTable->renameToTable(name);\n}\n\nvoid WCDBStatementAlterTableConfigRenameColumn(CPPStatementAlterTable alterTable, CPPColumn column)\n{\n    WCDBGetObjectOrReturn(alterTable, WCDB::StatementAlterTable, cppAlterTable);\n    WCDBGetObjectOrReturn(column, WCDB::Column, cppColumn);\n    cppAlterTable->renameColumn(*cppColumn);\n}\n\nvoid WCDBStatementAlterTableConfigRenameColumn2(CPPStatementAlterTable alterTable,\n                                                CPPCommonValue column)\n{\n    WCDBGetObjectOrReturn(alterTable, WCDB::StatementAlterTable, cppAlterTable);\n    cppAlterTable->renameColumn(WCDBCreateColumnFromCommonValue(column));\n}\n\nvoid WCDBStatementAlterTableConfigRenameToColumn(CPPStatementAlterTable alterTable, CPPColumn column)\n{\n    WCDBGetObjectOrReturn(alterTable, WCDB::StatementAlterTable, cppAlterTable);\n    WCDBGetObjectOrReturn(column, WCDB::Column, cppColumn);\n    cppAlterTable->toColumn(*cppColumn);\n}\n\nvoid WCDBStatementAlterTableConfigRenameToColumn2(CPPStatementAlterTable alterTable,\n                                                  CPPCommonValue column)\n{\n    WCDBGetObjectOrReturn(alterTable, WCDB::StatementAlterTable, cppAlterTable);\n    cppAlterTable->toColumn(WCDBCreateColumnFromCommonValue(column));\n}\n\nvoid WCDBStatementAlterTableConfigAddColumn(CPPStatementAlterTable alterTable, CPPColumnDef columndef)\n{\n    WCDBGetObjectOrReturn(alterTable, WCDB::StatementAlterTable, cppAlterTable);\n    WCDBGetObjectOrReturn(columndef, WCDB::ColumnDef, cppColumnDef);\n    cppAlterTable->addColumn(*cppColumnDef);\n}\n"
  },
  {
    "path": "src/bridge/winqbridge/statement/StatementAlterTableBridge.h",
    "content": "//\n// Created by qiuwenchen on 2022/6/27.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"WinqBridge.h\"\n\nWCDB_EXTERN_C_BEGIN\n\nCPPStatementAlterTable WCDBStatementAlterTableCreate();\nvoid WCDBStatementAlterTableConfigTable(CPPStatementAlterTable alterTable,\n                                        const char* _Nullable name);\nvoid WCDBStatementAlterTableConfigSchema(CPPStatementAlterTable alterTable, CPPSchema schema);\nvoid WCDBStatementAlterTableConfigSchema2(CPPStatementAlterTable alterTable,\n                                          CPPCommonValue schema);\nvoid WCDBStatementAlterTableConfigRenameToTable(CPPStatementAlterTable alterTable,\n                                                const char* _Nullable name);\nvoid WCDBStatementAlterTableConfigRenameColumn(CPPStatementAlterTable alterTable,\n                                               CPPColumn column);\nvoid WCDBStatementAlterTableConfigRenameColumn2(CPPStatementAlterTable alterTable,\n                                                CPPCommonValue column);\nvoid WCDBStatementAlterTableConfigRenameToColumn(CPPStatementAlterTable alterTable,\n                                                 CPPColumn column);\nvoid WCDBStatementAlterTableConfigRenameToColumn2(CPPStatementAlterTable alterTable,\n                                                  CPPCommonValue column);\nvoid WCDBStatementAlterTableConfigAddColumn(CPPStatementAlterTable alterTable,\n                                            CPPColumnDef columndef);\n\nWCDB_EXTERN_C_END\n"
  },
  {
    "path": "src/bridge/winqbridge/statement/StatementAnalyzeBridge.cpp",
    "content": "//\n// Created by qiuwenchen on 2022/6/29.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"StatementAnalyzeBridge.h\"\n#include \"ObjectBridge.hpp\"\n#include \"Schema.hpp\"\n#include \"StatementAnalyze.hpp\"\n#include \"WinqBridge.hpp\"\n\nCPPStatementAnalyze WCDBStatementAnalyzeCreate(void)\n{\n    return WCDBCreateCPPBridgedObject(CPPStatementAnalyze, WCDB::StatementAnalyze);\n}\n\nvoid WCDBStatementAnalyzeToAnalyze(CPPStatementAnalyze analyze)\n{\n    WCDBGetObjectOrReturn(analyze, WCDB::StatementAnalyze, cppAnalyze);\n    cppAnalyze->analyze();\n}\n\nvoid WCDBStatementAnalyzeConfigSchema(CPPStatementAnalyze analyze, CPPSchema schema)\n{\n    WCDBGetObjectOrReturn(analyze, WCDB::StatementAnalyze, cppAnalyze);\n    WCDBGetObjectOrReturn(schema, WCDB::Schema, cppSchema);\n    cppAnalyze->schema(*cppSchema);\n}\n\nvoid WCDBStatementAnalyzeConfigSchema2(CPPStatementAnalyze analyze, CPPCommonValue schema)\n{\n    WCDBGetObjectOrReturn(analyze, WCDB::StatementAnalyze, cppAnalyze);\n    cppAnalyze->schema(WCDBCreateSchemaFromCommonValue(schema));\n}\n\nvoid WCDBStatementAnalyzeConfigTable(CPPStatementAnalyze analyze, const char* _Nullable table)\n{\n    WCDBGetObjectOrReturn(analyze, WCDB::StatementAnalyze, cppAnalyze);\n    cppAnalyze->table(table);\n}\n\nvoid WCDBStatementAnalyzeConfigIndex(CPPStatementAnalyze analyze, const char* _Nullable index)\n{\n    WCDBGetObjectOrReturn(analyze, WCDB::StatementAnalyze, cppAnalyze);\n    cppAnalyze->index(index);\n}\n"
  },
  {
    "path": "src/bridge/winqbridge/statement/StatementAnalyzeBridge.h",
    "content": "//\n// Created by qiuwenchen on 2022/6/29.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"WinqBridge.h\"\n\nWCDB_EXTERN_C_BEGIN\n\nCPPStatementAnalyze WCDBStatementAnalyzeCreate(void);\nvoid WCDBStatementAnalyzeToAnalyze(CPPStatementAnalyze analyze);\nvoid WCDBStatementAnalyzeConfigSchema(CPPStatementAnalyze analyze, CPPSchema schema);\nvoid WCDBStatementAnalyzeConfigSchema2(CPPStatementAnalyze analyze, CPPCommonValue schema);\nvoid WCDBStatementAnalyzeConfigTable(CPPStatementAnalyze analyze, const char* _Nullable table);\nvoid WCDBStatementAnalyzeConfigIndex(CPPStatementAnalyze analyze, const char* _Nullable index);\n\nWCDB_EXTERN_C_END\n"
  },
  {
    "path": "src/bridge/winqbridge/statement/StatementAttachBridge.cpp",
    "content": "//\n// Created by qiuwenchen on 2022/6/29.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"StatementAttachBridge.h\"\n#include \"Expression.hpp\"\n#include \"ObjectBridge.hpp\"\n#include \"Schema.hpp\"\n#include \"StatementAttach.hpp\"\n#include \"WinqBridge.hpp\"\n\nCPPStatementAttach WCDBStatementAttachCreate()\n{\n    return WCDBCreateCPPBridgedObject(CPPStatementAttach, WCDB::StatementAttach);\n}\n\nvoid WCDBStatementAttachConfigPath(CPPStatementAttach attach, CPPExpression path)\n{\n    WCDBGetObjectOrReturn(attach, WCDB::StatementAttach, cppAttach);\n    WCDBGetObjectOrReturn(path, WCDB::Expression, cppPath);\n    cppAttach->attach(*cppPath);\n}\n\nvoid WCDBStatementAttachConfigPath2(CPPStatementAttach attach, CPPCommonValue path)\n{\n    WCDBGetObjectOrReturn(attach, WCDB::StatementAttach, cppAttach);\n    cppAttach->attach(WCDBCreateExpressionFromCommonValue(path));\n}\n\nvoid WCDBStatementAttachConfigSchema(CPPStatementAttach attach, CPPSchema schema)\n{\n    WCDBGetObjectOrReturn(attach, WCDB::StatementAttach, cppAttach);\n    WCDBGetObjectOrReturn(schema, WCDB::Schema, cppSchema);\n    cppAttach->as(*cppSchema);\n}\n\nvoid WCDBStatementAttachConfigSchema2(CPPStatementAttach attach, CPPCommonValue schema)\n{\n    WCDBGetObjectOrReturn(attach, WCDB::StatementAttach, cppAttach);\n    cppAttach->as(WCDBCreateSchemaFromCommonValue(schema));\n}\n\nvoid WCDBStatementAttachConfigKey(CPPStatementAttach attach, CPPExpression key)\n{\n    WCDBGetObjectOrReturn(attach, WCDB::StatementAttach, cppAttach);\n    WCDBGetObjectOrReturn(key, WCDB::Expression, cppKey);\n    cppAttach->key(*cppKey);\n}\n\nvoid WCDBStatementAttachConfigKey2(CPPStatementAttach attach, CPPCommonValue key)\n{\n    WCDBGetObjectOrReturn(attach, WCDB::StatementAttach, cppAttach);\n    cppAttach->key(WCDBCreateExpressionFromCommonValue(key));\n}\n"
  },
  {
    "path": "src/bridge/winqbridge/statement/StatementAttachBridge.h",
    "content": "//\n// Created by qiuwenchen on 2022/6/29.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"WinqBridge.h\"\n\nWCDB_EXTERN_C_BEGIN\n\nCPPStatementAttach WCDBStatementAttachCreate();\nvoid WCDBStatementAttachConfigPath(CPPStatementAttach attach, CPPExpression path);\nvoid WCDBStatementAttachConfigPath2(CPPStatementAttach attach, CPPCommonValue path);\nvoid WCDBStatementAttachConfigSchema(CPPStatementAttach attach, CPPSchema schema);\nvoid WCDBStatementAttachConfigSchema2(CPPStatementAttach attach, CPPCommonValue schema);\nvoid WCDBStatementAttachConfigKey(CPPStatementAttach attach, CPPExpression key);\nvoid WCDBStatementAttachConfigKey2(CPPStatementAttach attach, CPPCommonValue key);\n\nWCDB_EXTERN_C_END\n"
  },
  {
    "path": "src/bridge/winqbridge/statement/StatementBeginBridge.cpp",
    "content": "//\n// Created by qiuwenchen on 2022/7/17.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"StatementBeginBridge.h\"\n#include \"StatementBegin.hpp\"\n#include \"WinqBridge.hpp\"\n\nCPPStatementBegin WCDBStatementBeginCreate()\n{\n    CPPStatementBegin begin\n    = WCDBCreateCPPBridgedObject(CPPStatementBegin, WCDB::StatementBegin);\n    WCDBStatementBeginConfigType(begin, WCDBSyntaxTransactionType_Deferred);\n    return begin;\n}\n\nvoid WCDBStatementBeginConfigType(CPPStatementBegin begin, enum WCDBSyntaxTransactionType type)\n{\n    WCDBGetObjectOrReturn(begin, WCDB::StatementBegin, cppBegin);\n    switch (type) {\n    case WCDBSyntaxTransactionType_Deferred:\n        cppBegin->beginDeferred();\n        break;\n    case WCDBSyntaxTransactionType_Immediate:\n        cppBegin->beginImmediate();\n        break;\n    case WCDBSyntaxTransactionType_Exclusive:\n        cppBegin->beginExclusive();\n        break;\n    }\n}\n"
  },
  {
    "path": "src/bridge/winqbridge/statement/StatementBeginBridge.h",
    "content": "//\n// Created by qiuwenchen on 2022/7/17.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"WinqBridge.h\"\n\nWCDB_EXTERN_C_BEGIN\n\nCPPStatementBegin WCDBStatementBeginCreate();\nvoid WCDBStatementBeginConfigType(CPPStatementBegin begin, enum WCDBSyntaxTransactionType type);\n\nWCDB_EXTERN_C_END\n"
  },
  {
    "path": "src/bridge/winqbridge/statement/StatementCommitBridge.cpp",
    "content": "//\n// Created by qiuwenchen on 2022/7/17.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"StatementCommitBridge.h\"\n#include \"StatementCommit.hpp\"\n#include \"WinqBridge.hpp\"\n\nCPPStatementCommit WCDBStatementCommitCreate()\n{\n    CPPStatementCommit commit\n    = WCDBCreateCPPBridgedObject(CPPStatementCommit, WCDB::StatementCommit);\n    WCDBGetObjectOrReturnValue(\n    commit, WCDB::StatementCommit, cppCommit, CPPStatementCommit());\n    cppCommit->commit();\n    return commit;\n}\n"
  },
  {
    "path": "src/bridge/winqbridge/statement/StatementCommitBridge.h",
    "content": "//\n// Created by qiuwenchen on 2022/7/17.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"WinqBridge.h\"\n\nWCDB_EXTERN_C_BEGIN\n\nCPPStatementCommit WCDBStatementCommitCreate();\n\nWCDB_EXTERN_C_END\n"
  },
  {
    "path": "src/bridge/winqbridge/statement/StatementCreateIndexBridge.cpp",
    "content": "//\n// Created by qiuwenchen on 2022/6/29.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"StatementCreateIndexBridge.h\"\n#include \"Column.hpp\"\n#include \"Expression.hpp\"\n#include \"IndexedColumn.hpp\"\n#include \"Schema.hpp\"\n#include \"StatementCreateIndex.hpp\"\n#include \"WinqBridge.hpp\"\n\nCPPStatementCreateIndex WCDBStatementCreateIndexCreate()\n{\n    return WCDBCreateCPPBridgedObject(CPPStatementCreateIndex, WCDB::StatementCreateIndex);\n}\n\nvoid WCDBStatementCreateIndexConfigIndexName(CPPStatementCreateIndex createIndex,\n                                             const char* _Nullable name)\n{\n    WCDBGetObjectOrReturn(createIndex, WCDB::StatementCreateIndex, cppCreateIndex);\n    cppCreateIndex->createIndex(name);\n}\n\nvoid WCDBStatementCreateIndexConfigSchema(CPPStatementCreateIndex createIndex, CPPSchema schema)\n{\n    WCDBGetObjectOrReturn(createIndex, WCDB::StatementCreateIndex, cppCreateIndex);\n    WCDBGetObjectOrReturn(schema, WCDB::Schema, cppSchema);\n    cppCreateIndex->schema(*cppSchema);\n}\n\nvoid WCDBStatementCreateIndexConfigSchema2(CPPStatementCreateIndex createIndex,\n                                           CPPCommonValue schema)\n{\n    WCDBGetObjectOrReturn(createIndex, WCDB::StatementCreateIndex, cppCreateIndex);\n    cppCreateIndex->schema(WCDBCreateSchemaFromCommonValue(schema));\n}\n\nvoid WCDBStatementCreateIndexConfigUniqe(CPPStatementCreateIndex createIndex)\n{\n    WCDBGetObjectOrReturn(createIndex, WCDB::StatementCreateIndex, cppCreateIndex);\n    cppCreateIndex->unique();\n}\n\nvoid WCDBStatementCreateIndexConfigIfNotExist(CPPStatementCreateIndex createIndex)\n{\n    WCDBGetObjectOrReturn(createIndex, WCDB::StatementCreateIndex, cppCreateIndex);\n    cppCreateIndex->ifNotExists();\n}\n\nvoid WCDBStatementCreateIndexConfigTable(CPPStatementCreateIndex createIndex,\n                                         const char* _Nullable name)\n{\n    WCDBGetObjectOrReturn(createIndex, WCDB::StatementCreateIndex, cppCreateIndex);\n    cppCreateIndex->table(name);\n}\n\nvoid WCDBStatementCreateIndexConfigIndexColumns(CPPStatementCreateIndex createIndex,\n                                                const CPPIndexedColumn* _Nullable columns,\n                                                int columnNum)\n{\n    WCDBGetObjectOrReturn(createIndex, WCDB::StatementCreateIndex, cppCreateIndex);\n    WCDBGetCPPSyntaxListOrReturn(WCDB::IndexedColumn, cppColumns, columns, columnNum);\n    cppCreateIndex->syntax().indexedColumns = cppColumns;\n}\n\nvoid WCDBStatementCreateIndexConfigIndexColumns2(CPPStatementCreateIndex createIndex,\n                                                 CPPCommonArray columns)\n{\n    WCDBGetObjectOrReturn(createIndex, WCDB::StatementCreateIndex, cppCreateIndex);\n    WCDB::IndexedColumns indexedColumns;\n    for (int i = 0; i < columns.length; i++) {\n        switch (columns.type) {\n        case WCDBBridgedType_String:\n            indexedColumns.emplace_back(\n            WCDB::Column(WCDBGetCommonArrayLiteralValue(const char*, columns, i)));\n            break;\n        case WCDBBridgedType_Column:\n            indexedColumns.emplace_back(WCDBGetCommonArrayObject(WCDB::Column, columns, i));\n            break;\n        case WCDBBridgedType_Expression:\n            indexedColumns.emplace_back(\n            WCDBGetCommonArrayObject(WCDB::Expression, columns, i));\n            break;\n        case WCDBBridgedType_IndexedColumn:\n            indexedColumns.push_back(\n            WCDBGetCommonArrayObject(WCDB::IndexedColumn, columns, i));\n            break;\n        default:\n            assert(0);\n            break;\n        }\n    }\n    cppCreateIndex->syntax().indexedColumns = indexedColumns;\n}\n\nvoid WCDBStatementCreateIndexConfigWhere(CPPStatementCreateIndex createIndex, CPPExpression condition)\n{\n    WCDBGetObjectOrReturn(createIndex, WCDB::StatementCreateIndex, cppCreateIndex);\n    WCDBGetObjectOrReturn(condition, WCDB::Expression, cppCondition);\n    cppCreateIndex->where(*cppCondition);\n}\n"
  },
  {
    "path": "src/bridge/winqbridge/statement/StatementCreateIndexBridge.h",
    "content": "//\n// Created by qiuwenchen on 2022/6/29.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"WinqBridge.h\"\n\nWCDB_EXTERN_C_BEGIN\n\nCPPStatementCreateIndex WCDBStatementCreateIndexCreate(void);\nvoid WCDBStatementCreateIndexConfigIndexName(CPPStatementCreateIndex createIndex,\n                                             const char* _Nullable name);\nvoid WCDBStatementCreateIndexConfigSchema(CPPStatementCreateIndex createIndex, CPPSchema schema);\nvoid WCDBStatementCreateIndexConfigSchema2(CPPStatementCreateIndex createIndex,\n                                           CPPCommonValue schema);\nvoid WCDBStatementCreateIndexConfigUniqe(CPPStatementCreateIndex createIndex);\nvoid WCDBStatementCreateIndexConfigIfNotExist(CPPStatementCreateIndex createIndex);\nvoid WCDBStatementCreateIndexConfigTable(CPPStatementCreateIndex createIndex,\n                                         const char* _Nullable name);\nvoid WCDBStatementCreateIndexConfigIndexColumns(CPPStatementCreateIndex createIndex,\n                                                const CPPIndexedColumn* _Nullable columns,\n                                                int columnNum);\nvoid WCDBStatementCreateIndexConfigIndexColumns2(CPPStatementCreateIndex createIndex,\n                                                 CPPCommonArray columns);\nvoid WCDBStatementCreateIndexConfigWhere(CPPStatementCreateIndex createIndex,\n                                         CPPExpression condition);\n\nWCDB_EXTERN_C_END\n"
  },
  {
    "path": "src/bridge/winqbridge/statement/StatementCreateTableBridge.cpp",
    "content": "//\n// Created by qiuwenchen on 2022/6/30.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"StatementCreateTableBridge.h\"\n#include \"ColumnDef.hpp\"\n#include \"Schema.hpp\"\n#include \"StatementCreateTable.hpp\"\n#include \"StatementSelect.hpp\"\n#include \"TableConstraint.hpp\"\n#include \"WinqBridge.hpp\"\n\nCPPStatementCreateTable WCDBStatementCreateTableCreate(void)\n{\n    return WCDBCreateCPPBridgedObject(CPPStatementCreateTable, WCDB::StatementCreateTable);\n}\n\nvoid WCDBStatementCreateTableConfigTable(CPPStatementCreateTable createTable,\n                                         const char* _Nullable name)\n{\n    WCDBGetObjectOrReturn(createTable, WCDB::StatementCreateTable, cppCreateTable);\n    cppCreateTable->createTable(name);\n}\n\nvoid WCDBStatementCreateTableConfigSchema(CPPStatementCreateTable createTable, CPPSchema schema)\n{\n    WCDBGetObjectOrReturn(createTable, WCDB::StatementCreateTable, cppCreateTable);\n    WCDBGetObjectOrReturn(schema, WCDB::Schema, cppSchema);\n    cppCreateTable->schema(*cppSchema);\n}\n\nvoid WCDBStatementCreateTableConfigSchema2(CPPStatementCreateTable createTable,\n                                           CPPCommonValue schema)\n{\n    WCDBGetObjectOrReturn(createTable, WCDB::StatementCreateTable, cppCreateTable);\n    cppCreateTable->schema(WCDBCreateSchemaFromCommonValue(schema));\n}\n\nvoid WCDBStatementCreateTableConfigTemp(CPPStatementCreateTable createTable)\n{\n    WCDBGetObjectOrReturn(createTable, WCDB::StatementCreateTable, cppCreateTable);\n    cppCreateTable->temp();\n}\n\nvoid WCDBStatementCreateTableConfigIfNotExist(CPPStatementCreateTable createTable)\n{\n    WCDBGetObjectOrReturn(createTable, WCDB::StatementCreateTable, cppCreateTable);\n    cppCreateTable->ifNotExists();\n}\n\nvoid WCDBStatementCreateTableConfigAs(CPPStatementCreateTable createTable, CPPStatementSelect select)\n{\n    WCDBGetObjectOrReturn(createTable, WCDB::StatementCreateTable, cppCreateTable);\n    WCDBGetObjectOrReturn(select, WCDB::StatementSelect, cppSelect);\n    cppCreateTable->as(*cppSelect);\n}\n\nvoid WCDBStatementCreateTableConfigColumns(CPPStatementCreateTable createTable,\n                                           const CPPColumnDef* _Nullable columns,\n                                           int columnNum)\n{\n    WCDBGetObjectOrReturn(createTable, WCDB::StatementCreateTable, cppCreateTable);\n    WCDBGetCPPSyntaxListOrReturn(WCDB::ColumnDef, cppColumns, columns, columnNum);\n    cppCreateTable->syntax().switcher\n    = WCDB::StatementCreateTable::SyntaxType::Switch::ColumnDefs;\n    cppCreateTable->syntax().columnDefs = cppColumns;\n}\n\nvoid WCDBStatementCreateTableConfigColumn(CPPStatementCreateTable createTable, CPPColumnDef column)\n{\n    WCDBGetObjectOrReturn(createTable, WCDB::StatementCreateTable, cppCreateTable);\n    WCDBGetObjectOrReturn(column, WCDB::ColumnDef, cppColumn);\n    cppCreateTable->define(*cppColumn);\n}\n\nvoid WCDBStatementCreateTableConfigTableConstraints(CPPStatementCreateTable createTable,\n                                                    const CPPTableConstraint* _Nullable constraints,\n                                                    int constraintNum)\n{\n    WCDBGetObjectOrReturn(createTable, WCDB::StatementCreateTable, cppCreateTable);\n    WCDBGetCPPSyntaxListOrReturn(\n    WCDB::TableConstraint, cppConstraints, constraints, constraintNum);\n    cppCreateTable->syntax().tableConstraints = cppConstraints;\n}\n\nvoid WCDBStatementCreateTableConfigWithoutRowId(CPPStatementCreateTable createTable)\n{\n    WCDBGetObjectOrReturn(createTable, WCDB::StatementCreateTable, cppCreateTable);\n    cppCreateTable->withoutRowID();\n}\n"
  },
  {
    "path": "src/bridge/winqbridge/statement/StatementCreateTableBridge.h",
    "content": "//\n// Created by qiuwenchen on 2022/6/30.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"WinqBridge.h\"\n\nWCDB_EXTERN_C_BEGIN\n\nCPPStatementCreateTable WCDBStatementCreateTableCreate(void);\nvoid WCDBStatementCreateTableConfigTable(CPPStatementCreateTable createTable,\n                                         const char* _Nullable name);\nvoid WCDBStatementCreateTableConfigSchema2(CPPStatementCreateTable createTable,\n                                           CPPCommonValue schema);\nvoid WCDBStatementCreateTableConfigSchema(CPPStatementCreateTable createTable, CPPSchema schema);\nvoid WCDBStatementCreateTableConfigTemp(CPPStatementCreateTable createTable);\nvoid WCDBStatementCreateTableConfigIfNotExist(CPPStatementCreateTable createTable);\nvoid WCDBStatementCreateTableConfigAs(CPPStatementCreateTable createTable,\n                                      CPPStatementSelect select);\nvoid WCDBStatementCreateTableConfigColumns(CPPStatementCreateTable createTable,\n                                           const CPPColumnDef* _Nullable columns,\n                                           int columnNum);\nvoid WCDBStatementCreateTableConfigColumn(CPPStatementCreateTable createTable,\n                                          CPPColumnDef column);\nvoid WCDBStatementCreateTableConfigTableConstraints(CPPStatementCreateTable createTable,\n                                                    const CPPTableConstraint* _Nullable constraints,\n                                                    int constraintNum);\nvoid WCDBStatementCreateTableConfigWithoutRowId(CPPStatementCreateTable createTable);\n\nWCDB_EXTERN_C_END\n"
  },
  {
    "path": "src/bridge/winqbridge/statement/StatementCreateTriggerBridge.cpp",
    "content": "//\n// Created by qiuwenchen on 2022/7/13.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"StatementCreateTriggerBridge.h\"\n#include \"Column.hpp\"\n#include \"Schema.hpp\"\n#include \"StatementCreateTrigger.hpp\"\n#include \"StatementDelete.hpp\"\n#include \"StatementInsert.hpp\"\n#include \"StatementSelect.hpp\"\n#include \"StatementUpdate.hpp\"\n#include \"WinqBridge.hpp\"\n\nCPPStatementCreateTrigger WCDBStatementCreateTriggerCreate(void)\n{\n    return WCDBCreateCPPBridgedObject(CPPStatementCreateTrigger, WCDB::StatementCreateTrigger);\n}\n\nvoid WCDBStatementCreateTriggerConfigTrigger(CPPStatementCreateTrigger createTrigger,\n                                             const char* _Nullable name)\n{\n    WCDBGetObjectOrReturn(createTrigger, WCDB::StatementCreateTrigger, cppCreateTrigger);\n    cppCreateTrigger->createTrigger(name);\n}\n\nvoid WCDBStatementCreateTriggerConfigSchema(CPPStatementCreateTrigger createTrigger,\n                                            CPPSchema schema)\n{\n    WCDBGetObjectOrReturn(createTrigger, WCDB::StatementCreateTrigger, cppCreateTrigger);\n    WCDBGetObjectOrReturn(schema, WCDB::Schema, cppSchema);\n    cppCreateTrigger->schema(*cppSchema);\n}\n\nvoid WCDBStatementCreateTriggerConfigSchema2(CPPStatementCreateTrigger createTrigger,\n                                             CPPCommonValue schema)\n{\n    WCDBGetObjectOrReturn(createTrigger, WCDB::StatementCreateTrigger, cppCreateTrigger);\n    cppCreateTrigger->schema(WCDBCreateSchemaFromCommonValue(schema));\n}\n\nvoid WCDBStatementCreateTriggerConfigTemp(CPPStatementCreateTrigger createTrigger)\n{\n    WCDBGetObjectOrReturn(createTrigger, WCDB::StatementCreateTrigger, cppCreateTrigger);\n    cppCreateTrigger->temp();\n}\n\nvoid WCDBStatementCreateTriggerConfigIfNotExist(CPPStatementCreateTrigger createTrigger)\n{\n    WCDBGetObjectOrReturn(createTrigger, WCDB::StatementCreateTrigger, cppCreateTrigger);\n    cppCreateTrigger->ifNotExists();\n}\n\nvoid WCDBStatementCreateTriggerConfigBefore(CPPStatementCreateTrigger createTrigger)\n{\n    WCDBGetObjectOrReturn(createTrigger, WCDB::StatementCreateTrigger, cppCreateTrigger);\n    cppCreateTrigger->before();\n}\n\nvoid WCDBStatementCreateTriggerConfigAfter(CPPStatementCreateTrigger createTrigger)\n{\n    WCDBGetObjectOrReturn(createTrigger, WCDB::StatementCreateTrigger, cppCreateTrigger);\n    cppCreateTrigger->after();\n}\nvoid WCDBStatementCreateTriggerConfigInsteadOf(CPPStatementCreateTrigger createTrigger)\n{\n    WCDBGetObjectOrReturn(createTrigger, WCDB::StatementCreateTrigger, cppCreateTrigger);\n    cppCreateTrigger->insteadOf();\n}\n\nvoid WCDBStatementCreateTriggerConfigDelete(CPPStatementCreateTrigger createTrigger)\n{\n    WCDBGetObjectOrReturn(createTrigger, WCDB::StatementCreateTrigger, cppCreateTrigger);\n    cppCreateTrigger->delete_();\n}\n\nvoid WCDBStatementCreateTriggerConfigInsert(CPPStatementCreateTrigger createTrigger)\n{\n    WCDBGetObjectOrReturn(createTrigger, WCDB::StatementCreateTrigger, cppCreateTrigger);\n    cppCreateTrigger->insert();\n}\n\nvoid WCDBStatementCreateTriggerConfigUpdate(CPPStatementCreateTrigger createTrigger)\n{\n    WCDBGetObjectOrReturn(createTrigger, WCDB::StatementCreateTrigger, cppCreateTrigger);\n    cppCreateTrigger->update();\n}\n\nvoid WCDBStatementCreateTriggerConfigColumns(CPPStatementCreateTrigger createTrigger,\n                                             const CPPColumn* _Nullable columns,\n                                             int colNum)\n{\n    WCDBGetObjectOrReturn(createTrigger, WCDB::StatementCreateTrigger, cppCreateTrigger);\n    WCDBGetCPPSyntaxListOrReturn(WCDB::Column, cppColumns, columns, colNum);\n    cppCreateTrigger->syntax().columns = cppColumns;\n}\n\nvoid WCDBStatementCreateTriggerConfigColumns2(CPPStatementCreateTrigger createTrigger,\n                                              CPPCommonArray columns)\n{\n    WCDBGetObjectOrReturn(createTrigger, WCDB::StatementCreateTrigger, cppCreateTrigger);\n    WCDB::Columns cppColumns;\n    for (int i = 0; i < columns.length; i++) {\n        switch (columns.type) {\n        case WCDBBridgedType_String:\n            cppColumns.emplace_back(WCDB::UnsafeStringView(\n            WCDBGetCommonArrayLiteralValue(const char*, columns, i)));\n            break;\n        case WCDBBridgedType_Column:\n            cppColumns.push_back(WCDBGetCommonArrayObject(WCDB::Column, columns, i));\n            break;\n        default:\n            assert(0);\n            break;\n        }\n    }\n    cppCreateTrigger->syntax().columns = cppColumns;\n}\n\nvoid WCDBStatementCreateTriggerConfigTable(CPPStatementCreateTrigger createTrigger,\n                                           const char* _Nullable name)\n{\n    WCDBGetObjectOrReturn(createTrigger, WCDB::StatementCreateTrigger, cppCreateTrigger);\n    cppCreateTrigger->on(name);\n}\n\nvoid WCDBStatementCreateTriggerConfigForEachRow(CPPStatementCreateTrigger createTrigger)\n{\n    WCDBGetObjectOrReturn(createTrigger, WCDB::StatementCreateTrigger, cppCreateTrigger);\n    cppCreateTrigger->forEachRow();\n}\n\nvoid WCDBStatementCreateTriggerConfigWhen(CPPStatementCreateTrigger createTrigger,\n                                          CPPExpression expression)\n{\n    WCDBGetObjectOrReturn(createTrigger, WCDB::StatementCreateTrigger, cppCreateTrigger);\n    WCDBGetObjectOrReturn(expression, WCDB::Expression, cppExpression);\n    cppCreateTrigger->when(*cppExpression);\n}\n\nvoid WCDBStatementCreateTriggerExecuteInsert(CPPStatementCreateTrigger createTrigger,\n                                             CPPStatementInsert insert)\n{\n    WCDBGetObjectOrReturn(createTrigger, WCDB::StatementCreateTrigger, cppCreateTrigger);\n    WCDBGetObjectOrReturn(insert, WCDB::StatementInsert, cppInsert);\n    cppCreateTrigger->execute(*cppInsert);\n}\n\nvoid WCDBStatementCreateTriggerExecuteUpdate(CPPStatementCreateTrigger createTrigger,\n                                             CPPStatementUpdate update)\n{\n    WCDBGetObjectOrReturn(createTrigger, WCDB::StatementCreateTrigger, cppCreateTrigger);\n    WCDBGetObjectOrReturn(update, WCDB::StatementUpdate, cppUpdate);\n    cppCreateTrigger->execute(*cppUpdate);\n}\n\nvoid WCDBStatementCreateTriggerExecuteDelete(CPPStatementCreateTrigger createTrigger,\n                                             CPPStatementDelete delete_)\n{\n    WCDBGetObjectOrReturn(createTrigger, WCDB::StatementCreateTrigger, cppCreateTrigger);\n    WCDBGetObjectOrReturn(delete_, WCDB::StatementDelete, cppDelete);\n    cppCreateTrigger->execute(*cppDelete);\n}\n\nvoid WCDBStatementCreateTriggerExecuteSelect(CPPStatementCreateTrigger createTrigger,\n                                             CPPStatementSelect select)\n{\n    WCDBGetObjectOrReturn(createTrigger, WCDB::StatementCreateTrigger, cppCreateTrigger);\n    WCDBGetObjectOrReturn(select, WCDB::StatementSelect, cppSelect);\n    cppCreateTrigger->execute(*cppSelect);\n}\n"
  },
  {
    "path": "src/bridge/winqbridge/statement/StatementCreateTriggerBridge.h",
    "content": "//\n// Created by qiuwenchen on 2022/7/13.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"WinqBridge.h\"\n\nWCDB_EXTERN_C_BEGIN\n\nCPPStatementCreateTrigger WCDBStatementCreateTriggerCreate(void);\nvoid WCDBStatementCreateTriggerConfigTrigger(CPPStatementCreateTrigger createTrigger,\n                                             const char* _Nullable name);\nvoid WCDBStatementCreateTriggerConfigSchema(CPPStatementCreateTrigger createTrigger,\n                                            CPPSchema schema);\nvoid WCDBStatementCreateTriggerConfigSchema2(CPPStatementCreateTrigger createTrigger,\n                                             CPPCommonValue schema);\nvoid WCDBStatementCreateTriggerConfigTemp(CPPStatementCreateTrigger createTrigger);\nvoid WCDBStatementCreateTriggerConfigIfNotExist(CPPStatementCreateTrigger createTrigger);\n\nvoid WCDBStatementCreateTriggerConfigBefore(CPPStatementCreateTrigger createTrigger);\nvoid WCDBStatementCreateTriggerConfigAfter(CPPStatementCreateTrigger createTrigger);\nvoid WCDBStatementCreateTriggerConfigInsteadOf(CPPStatementCreateTrigger createTrigger);\n\nvoid WCDBStatementCreateTriggerConfigDelete(CPPStatementCreateTrigger createTrigger);\nvoid WCDBStatementCreateTriggerConfigInsert(CPPStatementCreateTrigger createTrigger);\nvoid WCDBStatementCreateTriggerConfigUpdate(CPPStatementCreateTrigger createTrigger);\n\nvoid WCDBStatementCreateTriggerConfigColumns(CPPStatementCreateTrigger createTrigger,\n                                             const CPPColumn* _Nullable columns,\n                                             int colNum);\nvoid WCDBStatementCreateTriggerConfigColumns2(CPPStatementCreateTrigger createTrigger,\n                                              CPPCommonArray columns);\nvoid WCDBStatementCreateTriggerConfigTable(CPPStatementCreateTrigger createTrigger,\n                                           const char* _Nullable name);\nvoid WCDBStatementCreateTriggerConfigForEachRow(CPPStatementCreateTrigger createTrigger);\nvoid WCDBStatementCreateTriggerConfigWhen(CPPStatementCreateTrigger createTrigger,\n                                          CPPExpression expression);\n\nvoid WCDBStatementCreateTriggerExecuteInsert(CPPStatementCreateTrigger createTrigger,\n                                             CPPStatementInsert insert);\nvoid WCDBStatementCreateTriggerExecuteUpdate(CPPStatementCreateTrigger createTrigger,\n                                             CPPStatementUpdate update);\nvoid WCDBStatementCreateTriggerExecuteDelete(CPPStatementCreateTrigger createTrigger,\n                                             CPPStatementDelete delete_);\nvoid WCDBStatementCreateTriggerExecuteSelect(CPPStatementCreateTrigger createTrigger,\n                                             CPPStatementSelect select);\n\nWCDB_EXTERN_C_END\n"
  },
  {
    "path": "src/bridge/winqbridge/statement/StatementCreateViewBridge.cpp",
    "content": "//\n// Created by qiuwenchen on 2022/7/13.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"StatementCreateViewBridge.h\"\n#include \"Column.hpp\"\n#include \"Schema.hpp\"\n#include \"StatementCreateView.hpp\"\n#include \"StatementSelect.hpp\"\n#include \"WinqBridge.hpp\"\n\nCPPStatementCreateView WCDBStatementCreateViewCreate(void)\n{\n    return WCDBCreateCPPBridgedObject(CPPStatementCreateView, WCDB::StatementCreateView);\n}\n\nvoid WCDBStatementCreateViewConfigView(CPPStatementCreateView createView,\n                                       const char* _Nullable name)\n{\n    WCDBGetObjectOrReturn(createView, WCDB::StatementCreateView, cppCreateView);\n    cppCreateView->createView(name);\n}\n\nvoid WCDBStatementCreateViewConfigSchema(CPPStatementCreateView createView, CPPSchema schema)\n{\n    WCDBGetObjectOrReturn(createView, WCDB::StatementCreateView, cppCreateView);\n    WCDBGetObjectOrReturn(schema, WCDB::Schema, cppSchema);\n    cppCreateView->schema(*cppSchema);\n}\n\nvoid WCDBStatementCreateViewConfigSchema2(CPPStatementCreateView createView, CPPCommonValue schema)\n{\n    WCDBGetObjectOrReturn(createView, WCDB::StatementCreateView, cppCreateView);\n    cppCreateView->schema(WCDBCreateSchemaFromCommonValue(schema));\n}\n\nvoid WCDBStatementCreateViewConfigTemp(CPPStatementCreateView createView)\n{\n    WCDBGetObjectOrReturn(createView, WCDB::StatementCreateView, cppCreateView);\n    cppCreateView->temp();\n}\n\nvoid WCDBStatementCreateViewConfigIfNotExist(CPPStatementCreateView createView)\n{\n    WCDBGetObjectOrReturn(createView, WCDB::StatementCreateView, cppCreateView);\n    cppCreateView->ifNotExists();\n}\n\nvoid WCDBStatementCreateViewConfigAs(CPPStatementCreateView createView, CPPStatementSelect select)\n{\n    WCDBGetObjectOrReturn(createView, WCDB::StatementCreateView, cppCreateView);\n    WCDBGetObjectOrReturn(select, WCDB::StatementSelect, cppSelect);\n    cppCreateView->as(*cppSelect);\n}\n\nvoid WCDBStatementCreateViewConfigColumns(CPPStatementCreateView createView,\n                                          const CPPColumn* _Nullable columns,\n                                          int columnNum)\n{\n    WCDBGetObjectOrReturn(createView, WCDB::StatementCreateView, cppCreateView);\n    WCDBGetCPPSyntaxListOrReturn(WCDB::Column, cppColumns, columns, columnNum);\n    cppCreateView->syntax().columns = cppColumns;\n}\n\nvoid WCDBStatementCreateViewConfigColumns2(CPPStatementCreateView createView, CPPCommonArray columns)\n{\n    WCDBGetObjectOrReturn(createView, WCDB::StatementCreateView, cppCreateView);\n    WCDB::Columns cppColumns;\n    for (int i = 0; i < columns.length; i++) {\n        switch (columns.type) {\n        case WCDBBridgedType_String:\n            cppColumns.emplace_back(WCDB::UnsafeStringView(\n            WCDBGetCommonArrayLiteralValue(const char*, columns, i)));\n            break;\n        case WCDBBridgedType_Column:\n            cppColumns.push_back(WCDBGetCommonArrayObject(WCDB::Column, columns, i));\n            break;\n        default:\n            assert(0);\n            break;\n        }\n    }\n    cppCreateView->syntax().columns = cppColumns;\n}\n"
  },
  {
    "path": "src/bridge/winqbridge/statement/StatementCreateViewBridge.h",
    "content": "//\n// Created by qiuwenchen on 2022/7/13.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"WinqBridge.h\"\n\nWCDB_EXTERN_C_BEGIN\n\nCPPStatementCreateView WCDBStatementCreateViewCreate(void);\nvoid WCDBStatementCreateViewConfigView(CPPStatementCreateView createView,\n                                       const char* _Nullable name);\nvoid WCDBStatementCreateViewConfigSchema(CPPStatementCreateView createView, CPPSchema schema);\nvoid WCDBStatementCreateViewConfigSchema2(CPPStatementCreateView createView,\n                                          CPPCommonValue schema);\nvoid WCDBStatementCreateViewConfigTemp(CPPStatementCreateView createView);\nvoid WCDBStatementCreateViewConfigIfNotExist(CPPStatementCreateView createView);\nvoid WCDBStatementCreateViewConfigAs(CPPStatementCreateView createView,\n                                     CPPStatementSelect select);\nvoid WCDBStatementCreateViewConfigColumns(CPPStatementCreateView createView,\n                                          const CPPColumn* _Nullable columns,\n                                          int columnNum);\nvoid WCDBStatementCreateViewConfigColumns2(CPPStatementCreateView createView,\n                                           CPPCommonArray columns);\n\nWCDB_EXTERN_C_END\n"
  },
  {
    "path": "src/bridge/winqbridge/statement/StatementCreateVirtualTableBridge.cpp",
    "content": "//\n// Created by qiuwenchen on 2022/7/3.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"StatementCreateVirtualTableBridge.h\"\n#include \"Schema.hpp\"\n#include \"StatementCreateVirtualTable.hpp\"\n#include \"WinqBridge.hpp\"\n\nCPPStatementCreateVirtualTable WCDBStatementCreateVirtualTableCreate(void)\n{\n    return WCDBCreateCPPBridgedObject(CPPStatementCreateVirtualTable,\n                                      WCDB::StatementCreateVirtualTable);\n}\n\nvoid WCDBStatementCreateVirtualTableConfigTable(CPPStatementCreateVirtualTable createTable,\n                                                const char* _Nullable name)\n{\n    WCDBGetObjectOrReturn(createTable, WCDB::StatementCreateVirtualTable, cppCreateTable);\n    cppCreateTable->createVirtualTable(name);\n}\n\nvoid WCDBStatementCreateVirtualTableConfigSchema(CPPStatementCreateVirtualTable createTable,\n                                                 CPPSchema schema)\n{\n    WCDBGetObjectOrReturn(createTable, WCDB::StatementCreateVirtualTable, cppCreateTable);\n    WCDBGetObjectOrReturn(schema, WCDB::Schema, cppSchema);\n    cppCreateTable->schema(*cppSchema);\n}\n\nvoid WCDBStatementCreateVirtualTableConfigSchema2(CPPStatementCreateVirtualTable createTable,\n                                                  CPPCommonValue schema)\n{\n    WCDBGetObjectOrReturn(createTable, WCDB::StatementCreateVirtualTable, cppCreateTable);\n    cppCreateTable->schema(WCDBCreateSchemaFromCommonValue(schema));\n}\n\nvoid WCDBStatementCreateVirtualTableConfigIfNotExist(CPPStatementCreateVirtualTable createTable)\n{\n    WCDBGetObjectOrReturn(createTable, WCDB::StatementCreateVirtualTable, cppCreateTable);\n    cppCreateTable->ifNotExists();\n}\n\nvoid WCDBStatementCreateVirtualTableConfigModule(CPPStatementCreateVirtualTable createTable,\n                                                 const char* _Nullable module)\n{\n    WCDBGetObjectOrReturn(createTable, WCDB::StatementCreateVirtualTable, cppCreateTable);\n    cppCreateTable->usingModule(module);\n}\n\nvoid WCDBStatementCreateVirtualTableConfigArguments(CPPStatementCreateVirtualTable createTable,\n                                                    const char* const _Nullable* _Nullable arguments,\n                                                    int argNum)\n{\n    WCDBGetObjectOrReturn(createTable, WCDB::StatementCreateVirtualTable, cppCreateTable);\n    if (argNum == 0 || arguments == nullptr) {\n        return;\n    }\n    for (int i = 0; i < argNum; i++) {\n        const char* argument = arguments[i];\n        cppCreateTable->argument(argument);\n    }\n}\n"
  },
  {
    "path": "src/bridge/winqbridge/statement/StatementCreateVirtualTableBridge.h",
    "content": "//\n// Created by qiuwenchen on 2022/7/3.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"WinqBridge.h\"\n\nWCDB_EXTERN_C_BEGIN\n\nCPPStatementCreateVirtualTable WCDBStatementCreateVirtualTableCreate(void);\nvoid WCDBStatementCreateVirtualTableConfigTable(CPPStatementCreateVirtualTable createTable,\n                                                const char* _Nullable name);\nvoid WCDBStatementCreateVirtualTableConfigSchema(CPPStatementCreateVirtualTable createTable,\n                                                 CPPSchema schema);\nvoid WCDBStatementCreateVirtualTableConfigSchema2(CPPStatementCreateVirtualTable createTable,\n                                                  CPPCommonValue schema);\nvoid WCDBStatementCreateVirtualTableConfigIfNotExist(CPPStatementCreateVirtualTable createTable);\nvoid WCDBStatementCreateVirtualTableConfigModule(CPPStatementCreateVirtualTable createTable,\n                                                 const char* _Nullable module);\nvoid WCDBStatementCreateVirtualTableConfigArguments(CPPStatementCreateVirtualTable createTable,\n                                                    const char* const _Nullable* _Nullable arguments,\n                                                    int argNum);\n\nWCDB_EXTERN_C_END\n"
  },
  {
    "path": "src/bridge/winqbridge/statement/StatementDeleteBridge.cpp",
    "content": "//\n// Created by qiuwenchen on 2022/7/3.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"StatementDeleteBridge.h\"\n#include \"CommonTableExpression.hpp\"\n#include \"Expression.hpp\"\n#include \"OrderingTerm.hpp\"\n#include \"QualifiedTable.hpp\"\n#include \"StatementDelete.hpp\"\n#include \"WinqBridge.hpp\"\n\nCPPStatementDelete WCDBStatementDeleteCreate(void)\n{\n    return WCDBCreateCPPBridgedObject(CPPStatementDelete, WCDB::StatementDelete);\n}\n\nvoid WCDBStatementDeleteConfigWith(CPPStatementDelete deleteStatement,\n                                   const CPPCommonTableExpression* _Nullable expressions,\n                                   int expNum)\n{\n    WCDBGetObjectOrReturn(deleteStatement, WCDB::StatementDelete, cppDelete);\n    WCDBGetCPPSyntaxListOrReturn(\n    WCDB::CommonTableExpression, cppExpressions, expressions, expNum);\n    cppDelete->with(cppExpressions);\n}\n\nvoid WCDBStatementDeleteConfigRecursive(CPPStatementDelete deleteStatement)\n{\n    WCDBGetObjectOrReturn(deleteStatement, WCDB::StatementDelete, cppDelete);\n    cppDelete->recursive();\n}\n\nvoid WCDBStatementDeleteConfigDeleteFrom(CPPStatementDelete deleteStatement, CPPQualifiedTable table)\n{\n    WCDBGetObjectOrReturn(deleteStatement, WCDB::StatementDelete, cppDelete);\n    WCDBGetObjectOrReturn(table, WCDB::QualifiedTable, cppTable);\n    cppDelete->deleteFrom(*cppTable);\n}\n\nvoid WCDBStatementDeleteConfigDeleteFrom2(CPPStatementDelete deleteStatement, CPPCommonValue table)\n{\n    WCDBGetObjectOrReturn(deleteStatement, WCDB::StatementDelete, cppDelete);\n    if (table.type == WCDBBridgedType_String) {\n        cppDelete->deleteFrom(WCDB::UnsafeStringView((const char*) table.intValue));\n    } else if (table.type == WCDBBridgedType_QualifiedTableName) {\n        cppDelete->deleteFrom(WCDBGetBridgedData(WCDB::QualifiedTable, table));\n    } else {\n        assert(table.type == WCDBBridgedType_Null);\n    }\n}\n\nvoid WCDBStatementDeleteConfigWhere(CPPStatementDelete deleteStatement, CPPExpression expression)\n{\n    WCDBGetObjectOrReturn(deleteStatement, WCDB::StatementDelete, cppDelete);\n    WCDBGetObjectOrReturn(expression, WCDB::Expression, cppExpression);\n    cppDelete->where(*cppExpression);\n}\n\nvoid WCDBStatementDeleteConfigOrder(CPPStatementDelete deleteStatement,\n                                    const CPPOrderingTerm* _Nullable orders,\n                                    int orderNum)\n{\n    WCDBGetObjectOrReturn(deleteStatement, WCDB::StatementDelete, cppDelete);\n    WCDBGetCPPSyntaxListOrReturn(WCDB::OrderingTerm, cppOrders, orders, orderNum);\n    cppDelete->orders(cppOrders);\n}\n\nvoid WCDBStatementDeleteConfigLimitRange(CPPStatementDelete deleteStatement,\n                                         CPPExpression from,\n                                         CPPExpression to)\n{\n    WCDBGetObjectOrReturn(deleteStatement, WCDB::StatementDelete, cppDelete);\n    WCDBGetObjectOrReturn(from, WCDB::Expression, cppFrom);\n    WCDBGetObjectOrReturn(to, WCDB::Expression, cppTo);\n    cppDelete->limit(*cppFrom, *cppTo);\n}\n\nvoid WCDBStatementDeleteConfigLimitCount(CPPStatementDelete deleteStatement, CPPExpression limit)\n{\n    WCDBGetObjectOrReturn(deleteStatement, WCDB::StatementDelete, cppDelete);\n    WCDBGetObjectOrReturn(limit, WCDB::Expression, cppLimit);\n    cppDelete->limit(*cppLimit);\n}\n\nvoid WCDBStatementDeleteConfigOffset(CPPStatementDelete deleteStatement, CPPExpression offset)\n{\n    WCDBGetObjectOrReturn(deleteStatement, WCDB::StatementDelete, cppDelete);\n    WCDBGetObjectOrReturn(offset, WCDB::Expression, cppOffset);\n    cppDelete->offset(*cppOffset);\n}\n\nvoid WCDBStatementDeleteConfigLimitRange2(CPPStatementDelete deleteStatement,\n                                          CPPCommonValue from,\n                                          CPPCommonValue to)\n{\n    WCDBGetObjectOrReturn(deleteStatement, WCDB::StatementDelete, cppDelete);\n    cppDelete->limit(WCDBCreateExpressionFromCommonValue(from),\n                     WCDBCreateExpressionFromCommonValue(to));\n}\n\nvoid WCDBStatementDeleteConfigLimitCount2(CPPStatementDelete deleteStatement, CPPCommonValue limit)\n{\n    WCDBGetObjectOrReturn(deleteStatement, WCDB::StatementDelete, cppDelete);\n    cppDelete->limit(WCDBCreateExpressionFromCommonValue(limit));\n}\n\nvoid WCDBStatementDeleteConfigOffset2(CPPStatementDelete deleteStatement, CPPCommonValue offset)\n{\n    WCDBGetObjectOrReturn(deleteStatement, WCDB::StatementDelete, cppDelete);\n    cppDelete->offset(WCDBCreateExpressionFromCommonValue(offset));\n}\n"
  },
  {
    "path": "src/bridge/winqbridge/statement/StatementDeleteBridge.h",
    "content": "//\n// Created by qiuwenchen on 2022/7/3.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"WinqBridge.h\"\n\nWCDB_EXTERN_C_BEGIN\n\nCPPStatementDelete WCDBStatementDeleteCreate(void);\nvoid WCDBStatementDeleteConfigWith(CPPStatementDelete deleteStatement,\n                                   const CPPCommonTableExpression* _Nullable expressions,\n                                   int expNum);\nvoid WCDBStatementDeleteConfigRecursive(CPPStatementDelete deleteStatement);\nvoid WCDBStatementDeleteConfigDeleteFrom(CPPStatementDelete deleteStatement,\n                                         CPPQualifiedTable table);\n\nvoid WCDBStatementDeleteConfigDeleteFrom2(CPPStatementDelete deleteStatement,\n                                          CPPCommonValue table);\n\nvoid WCDBStatementDeleteConfigWhere(CPPStatementDelete deleteStatement, CPPExpression expression);\nvoid WCDBStatementDeleteConfigOrder(CPPStatementDelete deleteStatement,\n                                    const CPPOrderingTerm* _Nullable orders,\n                                    int orderNum);\nvoid WCDBStatementDeleteConfigLimitRange(CPPStatementDelete deleteStatement,\n                                         CPPExpression from,\n                                         CPPExpression to);\nvoid WCDBStatementDeleteConfigLimitCount(CPPStatementDelete deleteStatement,\n                                         CPPExpression limit);\nvoid WCDBStatementDeleteConfigOffset(CPPStatementDelete deleteStatement, CPPExpression offset);\n\nvoid WCDBStatementDeleteConfigLimitRange2(CPPStatementDelete deleteStatement,\n                                          CPPCommonValue from,\n                                          CPPCommonValue to);\nvoid WCDBStatementDeleteConfigLimitCount2(CPPStatementDelete deleteStatement,\n                                          CPPCommonValue limit);\nvoid WCDBStatementDeleteConfigOffset2(CPPStatementDelete deleteStatement, CPPCommonValue offset);\n\nWCDB_EXTERN_C_END\n"
  },
  {
    "path": "src/bridge/winqbridge/statement/StatementDetachBridge.cpp",
    "content": "//\n// Created by qiuwenchen on 2022/7/12.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"StatementDetachBridge.h\"\n#include \"Schema.hpp\"\n#include \"StatementDetach.hpp\"\n#include \"WinqBridge.hpp\"\n\nCPPStatementDetach WCDBStatementDetachCreate(void)\n{\n    return WCDBCreateCPPBridgedObject(CPPStatementDetach, WCDB::StatementDetach);\n}\n\nvoid WCDBStatementDetachConfigSchema(CPPStatementDetach detachStatement, CPPSchema schema)\n{\n    WCDBGetObjectOrReturn(detachStatement, WCDB::StatementDetach, cppDetachStatement);\n    WCDBGetObjectOrReturn(schema, WCDB::Schema, cppSchema);\n    cppDetachStatement->detach(*cppSchema);\n}\n\nvoid WCDBStatementDetachConfigSchema2(CPPStatementDetach detachStatement, CPPCommonValue schema)\n{\n    WCDBGetObjectOrReturn(detachStatement, WCDB::StatementDetach, cppDetachStatement);\n    cppDetachStatement->detach(WCDBCreateSchemaFromCommonValue(schema));\n}\n"
  },
  {
    "path": "src/bridge/winqbridge/statement/StatementDetachBridge.h",
    "content": "//\n// Created by qiuwenchen on 2022/7/12.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"WinqBridge.h\"\n\nWCDB_EXTERN_C_BEGIN\n\nCPPStatementDetach WCDBStatementDetachCreate(void);\nvoid WCDBStatementDetachConfigSchema(CPPStatementDetach detachStatement, CPPSchema schema);\nvoid WCDBStatementDetachConfigSchema2(CPPStatementDetach detachStatement, CPPCommonValue schema);\n\nWCDB_EXTERN_C_END\n"
  },
  {
    "path": "src/bridge/winqbridge/statement/StatementDropIndexBridge.cpp",
    "content": "//\n// Created by qiuwenchen on 2022/7/12.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"StatementDropIndexBridge.h\"\n#include \"Schema.hpp\"\n#include \"StatementDropIndex.hpp\"\n#include \"WinqBridge.hpp\"\n\nCPPStatementDropIndex WCDBStatementDropIndexCreate(void)\n{\n    return WCDBCreateCPPBridgedObject(CPPStatementDropIndex, WCDB::StatementDropIndex);\n}\n\nvoid WCDBStatementDropIndexConfigSchema(CPPStatementDropIndex dropIndexStatement, CPPSchema schema)\n{\n    WCDBGetObjectOrReturn(dropIndexStatement, WCDB::StatementDropIndex, cppDropIndexStatement);\n    WCDBGetObjectOrReturn(schema, WCDB::Schema, cppSchema);\n    cppDropIndexStatement->schema(*cppSchema);\n}\n\nvoid WCDBStatementDropIndexConfigSchema2(CPPStatementDropIndex dropIndexStatement,\n                                         CPPCommonValue schema)\n{\n    WCDBGetObjectOrReturn(dropIndexStatement, WCDB::StatementDropIndex, cppDropIndexStatement);\n    cppDropIndexStatement->schema(WCDBCreateSchemaFromCommonValue(schema));\n}\n\nvoid WCDBStatementDropIndexConfigIndex(CPPStatementDropIndex dropIndexStatement,\n                                       const char* _Nullable name)\n{\n    WCDBGetObjectOrReturn(dropIndexStatement, WCDB::StatementDropIndex, cppDropIndexStatement);\n    cppDropIndexStatement->dropIndex(name);\n}\n\nvoid WCDBStatementDropIndexConfigIfExists(CPPStatementDropIndex dropIndexStatement)\n{\n    WCDBGetObjectOrReturn(dropIndexStatement, WCDB::StatementDropIndex, cppDropIndexStatement);\n    cppDropIndexStatement->ifExists();\n}\n"
  },
  {
    "path": "src/bridge/winqbridge/statement/StatementDropIndexBridge.h",
    "content": "//\n// Created by qiuwenchen on 2022/7/12.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"WinqBridge.h\"\n\nWCDB_EXTERN_C_BEGIN\n\nCPPStatementDropIndex WCDBStatementDropIndexCreate(void);\nvoid WCDBStatementDropIndexConfigSchema(CPPStatementDropIndex dropIndexStatement,\n                                        CPPSchema schema);\nvoid WCDBStatementDropIndexConfigSchema2(CPPStatementDropIndex dropIndexStatement,\n                                         CPPCommonValue schema);\nvoid WCDBStatementDropIndexConfigIndex(CPPStatementDropIndex dropIndexStatement,\n                                       const char* _Nullable name);\nvoid WCDBStatementDropIndexConfigIfExists(CPPStatementDropIndex dropIndexStatement);\n\nWCDB_EXTERN_C_END\n"
  },
  {
    "path": "src/bridge/winqbridge/statement/StatementDropTableBridge.cpp",
    "content": "//\n// Created by qiuwenchen on 2022/7/12.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"StatementDropTableBridge.h\"\n#include \"Schema.hpp\"\n#include \"StatementDropTable.hpp\"\n#include \"WinqBridge.hpp\"\n\nCPPStatementDropTable WCDBStatementDropTableCreate(void)\n{\n    return WCDBCreateCPPBridgedObject(CPPStatementDropTable, WCDB::StatementDropTable);\n}\n\nvoid WCDBStatementDropTableConfigSchema(CPPStatementDropTable dropTableStatement, CPPSchema schema)\n{\n    WCDBGetObjectOrReturn(dropTableStatement, WCDB::StatementDropTable, cppDropTableStatement);\n    WCDBGetObjectOrReturn(schema, WCDB::Schema, cppSchema);\n    cppDropTableStatement->schema(*cppSchema);\n}\n\nvoid WCDBStatementDropTableConfigSchema2(CPPStatementDropTable dropTableStatement,\n                                         CPPCommonValue schema)\n{\n    WCDBGetObjectOrReturn(dropTableStatement, WCDB::StatementDropTable, cppDropTableStatement);\n    cppDropTableStatement->schema(WCDBCreateSchemaFromCommonValue(schema));\n}\n\nvoid WCDBStatementDropTableConfigTable(CPPStatementDropTable dropTableStatement,\n                                       const char* _Nullable name)\n{\n    WCDBGetObjectOrReturn(dropTableStatement, WCDB::StatementDropTable, cppDropTableStatement);\n    cppDropTableStatement->dropTable(name);\n}\n\nvoid WCDBStatementDropTableConfigIfExists(CPPStatementDropTable dropTableStatement)\n{\n    WCDBGetObjectOrReturn(dropTableStatement, WCDB::StatementDropTable, cppDropTableStatement);\n    cppDropTableStatement->ifExists();\n}\n"
  },
  {
    "path": "src/bridge/winqbridge/statement/StatementDropTableBridge.h",
    "content": "//\n// Created by qiuwenchen on 2022/7/12.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"WinqBridge.h\"\n\nWCDB_EXTERN_C_BEGIN\n\nCPPStatementDropTable WCDBStatementDropTableCreate(void);\nvoid WCDBStatementDropTableConfigSchema(CPPStatementDropTable dropTableStatement,\n                                        CPPSchema schema);\nvoid WCDBStatementDropTableConfigSchema2(CPPStatementDropTable dropTableStatement,\n                                         CPPCommonValue schema);\nvoid WCDBStatementDropTableConfigTable(CPPStatementDropTable dropTableStatement,\n                                       const char* _Nullable name);\nvoid WCDBStatementDropTableConfigIfExists(CPPStatementDropTable dropTableStatement);\n\nWCDB_EXTERN_C_END\n"
  },
  {
    "path": "src/bridge/winqbridge/statement/StatementDropTriggerBridge.cpp",
    "content": "//\n// Created by qiuwenchen on 2022/7/13.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"StatementDropTriggerBridge.h\"\n#include \"Schema.hpp\"\n#include \"StatementDropTrigger.hpp\"\n#include \"WinqBridge.hpp\"\n\nCPPStatementDropTrigger WCDBStatementDropTriggerCreate(void)\n{\n    return WCDBCreateCPPBridgedObject(CPPStatementDropTrigger, WCDB::StatementDropTrigger);\n}\n\nvoid WCDBStatementDropTriggerConfigSchema(CPPStatementDropTrigger dropTriggerStatement,\n                                          CPPSchema schema)\n{\n    WCDBGetObjectOrReturn(\n    dropTriggerStatement, WCDB::StatementDropTrigger, cppDropTriggerStatement);\n    WCDBGetObjectOrReturn(schema, WCDB::Schema, cppSchema);\n    cppDropTriggerStatement->schema(*cppSchema);\n}\n\nvoid WCDBStatementDropTriggerConfigSchema2(CPPStatementDropTrigger dropTriggerStatement,\n                                           CPPCommonValue schema)\n{\n    WCDBGetObjectOrReturn(\n    dropTriggerStatement, WCDB::StatementDropTrigger, cppDropTriggerStatement);\n    cppDropTriggerStatement->schema(WCDBCreateSchemaFromCommonValue(schema));\n}\n\nvoid WCDBStatementDropTriggerConfigTrigger(CPPStatementDropTrigger dropTriggerStatement,\n                                           const char* _Nullable name)\n{\n    WCDBGetObjectOrReturn(\n    dropTriggerStatement, WCDB::StatementDropTrigger, cppDropTriggerStatement);\n    cppDropTriggerStatement->dropTrigger(name);\n}\n\nvoid WCDBStatementDropTriggerConfigIfExists(CPPStatementDropTrigger dropTriggerStatement)\n{\n    WCDBGetObjectOrReturn(\n    dropTriggerStatement, WCDB::StatementDropTrigger, cppDropTriggerStatement);\n    cppDropTriggerStatement->ifExists();\n}\n"
  },
  {
    "path": "src/bridge/winqbridge/statement/StatementDropTriggerBridge.h",
    "content": "//\n// Created by qiuwenchen on 2022/7/13.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"WinqBridge.h\"\n\nWCDB_EXTERN_C_BEGIN\n\nCPPStatementDropTrigger WCDBStatementDropTriggerCreate(void);\nvoid WCDBStatementDropTriggerConfigSchema(CPPStatementDropTrigger dropTriggerStatement,\n                                          CPPSchema schema);\nvoid WCDBStatementDropTriggerConfigSchema2(CPPStatementDropTrigger dropTriggerStatement,\n                                           CPPCommonValue schema);\nvoid WCDBStatementDropTriggerConfigTrigger(CPPStatementDropTrigger dropTriggerStatement,\n                                           const char* _Nullable name);\nvoid WCDBStatementDropTriggerConfigIfExists(CPPStatementDropTrigger dropTriggerStatement);\n\nWCDB_EXTERN_C_END\n"
  },
  {
    "path": "src/bridge/winqbridge/statement/StatementDropViewBridge.cpp",
    "content": "//\n// Created by qiuwenchen on 2022/7/13.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"StatementDropViewBridge.h\"\n#include \"Schema.hpp\"\n#include \"StatementDropView.hpp\"\n#include \"WinqBridge.hpp\"\n\nCPPStatementDropView WCDBStatementDropViewCreate(void)\n{\n    return WCDBCreateCPPBridgedObject(CPPStatementDropView, WCDB::StatementDropView);\n}\n\nvoid WCDBStatementDropViewConfigSchema(CPPStatementDropView dropViewStatement, CPPSchema schema)\n{\n    WCDBGetObjectOrReturn(dropViewStatement, WCDB::StatementDropView, cppDropViewStatement);\n    WCDBGetObjectOrReturn(schema, WCDB::Schema, cppSchema);\n    cppDropViewStatement->schema(*cppSchema);\n}\n\nvoid WCDBStatementDropViewConfigSchema2(CPPStatementDropView dropViewStatement,\n                                        CPPCommonValue schema)\n{\n    WCDBGetObjectOrReturn(dropViewStatement, WCDB::StatementDropView, cppDropViewStatement);\n    cppDropViewStatement->schema(WCDBCreateSchemaFromCommonValue(schema));\n}\n\nvoid WCDBStatementDropViewConfigView(CPPStatementDropView dropViewStatement,\n                                     const char* _Nullable name)\n{\n    WCDBGetObjectOrReturn(dropViewStatement, WCDB::StatementDropView, cppDropViewStatement);\n    cppDropViewStatement->dropView(name);\n}\n\nvoid WCDBStatementDropViewConfigIfExists(CPPStatementDropView dropViewStatement)\n{\n    WCDBGetObjectOrReturn(dropViewStatement, WCDB::StatementDropView, cppDropViewStatement);\n    cppDropViewStatement->ifExists();\n}\n"
  },
  {
    "path": "src/bridge/winqbridge/statement/StatementDropViewBridge.h",
    "content": "//\n// Created by qiuwenchen on 2022/7/13.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"WinqBridge.h\"\n\nWCDB_EXTERN_C_BEGIN\n\nCPPStatementDropView WCDBStatementDropViewCreate(void);\nvoid WCDBStatementDropViewConfigSchema(CPPStatementDropView dropViewStatement, CPPSchema schema);\nvoid WCDBStatementDropViewConfigSchema2(CPPStatementDropView dropViewStatement,\n                                        CPPCommonValue schema);\nvoid WCDBStatementDropViewConfigView(CPPStatementDropView dropViewStatement,\n                                     const char* _Nullable name);\nvoid WCDBStatementDropViewConfigIfExists(CPPStatementDropView dropViewStatement);\n\nWCDB_EXTERN_C_END\n"
  },
  {
    "path": "src/bridge/winqbridge/statement/StatementExplainBridge.cpp",
    "content": "//\n// Created by qiuwenchen on 2022/7/17.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"StatementExplainBridge.h\"\n#include \"Statement.hpp\"\n#include \"StatementExplain.hpp\"\n#include \"WinqBridge.hpp\"\n\nCPPStatementExplain WCDBStatementExplainCreate(void)\n{\n    return WCDBCreateCPPBridgedObject(CPPStatementExplain, WCDB::StatementExplain);\n}\n\nvoid WCDBStatementExplain(CPPStatementExplain explain, CPPObject* statement, bool queryPlan)\n{\n    WCDBGetObjectOrReturn(explain, WCDB::StatementExplain, cppExplain);\n    WCDB::Statement* cppStatement\n    = (WCDB::Statement*) WCDB::ObjectBridge::extractOriginalCPPObject(statement);\n    cppExplain->syntax().queryPlan = queryPlan;\n    cppExplain->syntax().stmt = cppStatement->syntax();\n}\n"
  },
  {
    "path": "src/bridge/winqbridge/statement/StatementExplainBridge.h",
    "content": "//\n// Created by qiuwenchen on 2022/7/17.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"WinqBridge.h\"\n\nWCDB_EXTERN_C_BEGIN\n\nCPPStatementExplain WCDBStatementExplainCreate(void);\nvoid WCDBStatementExplain(CPPStatementExplain explain, CPPObject* statement, bool queryPlan);\n\nWCDB_EXTERN_C_END\n"
  },
  {
    "path": "src/bridge/winqbridge/statement/StatementInsertBridge.cpp",
    "content": "//\n// Created by qiuwenchen on 2022/7/15.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"StatementInsertBridge.h\"\n#include \"BindParameter.hpp\"\n#include \"Column.hpp\"\n#include \"CommonTableExpression.hpp\"\n#include \"Expression.hpp\"\n#include \"LiteralValue.hpp\"\n#include \"Schema.hpp\"\n#include \"StatementInsert.hpp\"\n#include \"StatementSelect.hpp\"\n#include \"Upsert.hpp\"\n#include \"WinqBridge.hpp\"\n\nCPPStatementInsert WCDBStatementInsertCreate(void)\n{\n    return WCDBCreateCPPBridgedObject(CPPStatementInsert, WCDB::StatementInsert);\n}\n\nvoid WCDBStatementInsertConfigWith(CPPStatementInsert insert,\n                                   const CPPCommonTableExpression* _Nullable exps,\n                                   int expNum)\n{\n    WCDBGetObjectOrReturn(insert, WCDB::StatementInsert, cppInsert);\n    WCDBGetCPPSyntaxListOrReturn(WCDB::CommonTableExpression, cppExps, exps, expNum);\n    cppInsert->with(cppExps);\n}\n\nvoid WCDBStatementInsertConfigRecursive(CPPStatementInsert insert)\n{\n    WCDBGetObjectOrReturn(insert, WCDB::StatementInsert, cppInsert);\n    cppInsert->recursive();\n}\n\nvoid WCDBStatementInsertConfigTable(CPPStatementInsert insert, const char* _Nullable name)\n{\n    WCDBGetObjectOrReturn(insert, WCDB::StatementInsert, cppInsert);\n    cppInsert->insertIntoTable(name);\n}\n\nvoid WCDBStatementInsertConfigSchema(CPPStatementInsert insert, CPPSchema schema)\n{\n    WCDBGetObjectOrReturn(insert, WCDB::StatementInsert, cppInsert);\n    WCDBGetObjectOrReturn(schema, WCDB::Schema, cppSchema);\n    cppInsert->schema(*cppSchema);\n}\n\nvoid WCDBStatementInsertConfigSchema2(CPPStatementInsert insert, CPPCommonValue schema)\n{\n    WCDBGetObjectOrReturn(insert, WCDB::StatementInsert, cppInsert);\n    cppInsert->schema(WCDBCreateSchemaFromCommonValue(schema));\n}\n\nvoid WCDBStatementInsertConfigConfiction(CPPStatementInsert insert,\n                                         enum WCDBSyntaxConflictAction action)\n{\n    WCDBGetObjectOrReturn(insert, WCDB::StatementInsert, cppInsert);\n    cppInsert->syntax().conflictAction = WCDB::WinqBridge::changeConflictAction(action);\n}\n\nvoid WCDBStatementInsertConfigAlias(CPPStatementInsert insert, const char* _Nullable name)\n{\n    WCDBGetObjectOrReturn(insert, WCDB::StatementInsert, cppInsert);\n    cppInsert->as(name);\n}\n\nvoid WCDBStatementInsertConfigColumns(CPPStatementInsert insert,\n                                      const CPPColumn* _Nullable columns,\n                                      int colNum)\n{\n    WCDBGetObjectOrReturn(insert, WCDB::StatementInsert, cppInsert);\n    WCDBGetCPPSyntaxListOrReturn(WCDB::Column, cppColumns, columns, colNum);\n    cppInsert->columns(cppColumns);\n}\n\nvoid WCDBStatementInsertConfigColumns2(CPPStatementInsert insert, CPPCommonArray columns)\n{\n    WCDBGetObjectOrReturn(insert, WCDB::StatementInsert, cppInsert);\n    WCDB::Columns cppColumns;\n    for (int i = 0; i < columns.length; i++) {\n        switch (columns.type) {\n        case WCDBBridgedType_String:\n            cppColumns.emplace_back(\n            WCDB::Column(WCDBGetCommonArrayLiteralValue(const char*, columns, i)));\n            break;\n        case WCDBBridgedType_Column:\n            cppColumns.emplace_back(WCDBGetCommonArrayObject(WCDB::Column, columns, i));\n            break;\n        default:\n            assert(0);\n            break;\n        }\n    }\n    cppInsert->columns(cppColumns);\n}\n\nvoid WCDBStatementInsertConfigValuesWithMultiTypeArray(CPPStatementInsert insert,\n                                                       CPPMultiTypeArray values)\n{\n    WCDBGetObjectOrReturn(insert, WCDB::StatementInsert, cppInsert);\n    int intIndex = 0;\n    int doubleIndex = 0;\n    int stringIndex = 0;\n    for (int i = 0; i < values.totalLength; i++) {\n        switch (values.types[i]) {\n        case WCDBBridgedType_Null: {\n            cppInsert->value(WCDB::LiteralValue(nullptr));\n            intIndex++;\n        } break;\n        case WCDBBridgedType_Bool: {\n            cppInsert->value(WCDB::LiteralValue((bool) values.intValues[intIndex]));\n            intIndex++;\n        } break;\n        case WCDBBridgedType_Int: {\n            cppInsert->value(WCDB::LiteralValue((int64_t) values.intValues[intIndex]));\n            intIndex++;\n        } break;\n        case WCDBBridgedType_UInt: {\n            cppInsert->value(WCDB::LiteralValue((uint64_t) values.intValues[intIndex]));\n            intIndex++;\n        } break;\n        case WCDBBridgedType_Double: {\n            cppInsert->value(WCDB::LiteralValue(values.doubleValues[doubleIndex]));\n            doubleIndex++;\n        } break;\n        case WCDBBridgedType_String: {\n            cppInsert->value(WCDB::LiteralValue(\n            WCDB::UnsafeStringView(values.stringValues[stringIndex])));\n            stringIndex++;\n        } break;\n        case WCDBBridgedType_Column: {\n            cppInsert->value(WCDBGetMultiTypeArrayObject(WCDB::Column, values, intIndex));\n            intIndex++;\n        } break;\n        case WCDBBridgedType_LiteralValue: {\n            cppInsert->value(WCDBGetMultiTypeArrayObject(WCDB::LiteralValue, values, intIndex));\n            intIndex++;\n        } break;\n        case WCDBBridgedType_BindParameter: {\n            cppInsert->value(WCDBGetMultiTypeArrayObject(WCDB::BindParameter, values, intIndex));\n            intIndex++;\n        } break;\n        case WCDBBridgedType_Expression: {\n            cppInsert->value(WCDBGetMultiTypeArrayObject(WCDB::Expression, values, intIndex));\n            intIndex++;\n        } break;\n        default:\n            break;\n        }\n    }\n}\n\nvoid WCDBStatementInsertConfigValuesWithBindParameters(CPPStatementInsert insert, int parametersCount)\n{\n    WCDBGetObjectOrReturn(insert, WCDB::StatementInsert, cppInsert);\n    cppInsert->values(WCDB::BindParameter::bindParameters(parametersCount));\n}\n\nvoid WCDBStatementInsertConfigValues(CPPStatementInsert insert,\n                                     const CPPExpression* _Nullable exps,\n                                     int expNum)\n{\n    WCDBGetObjectOrReturn(insert, WCDB::StatementInsert, cppInsert);\n    WCDBGetCPPSyntaxListOrReturn(WCDB::Expression, cppExps, exps, expNum);\n    cppInsert->values(cppExps);\n}\n\nvoid WCDBStatementInsertConfigSelect(CPPStatementInsert insert, CPPStatementSelect select)\n{\n    WCDBGetObjectOrReturn(insert, WCDB::StatementInsert, cppInsert);\n    WCDBGetObjectOrReturn(select, WCDB::StatementSelect, cppSelect)\n    cppInsert->values(*cppSelect);\n}\n\nvoid WCDBStatementInsertConfigDefaultValues(CPPStatementInsert insert)\n{\n    WCDBGetObjectOrReturn(insert, WCDB::StatementInsert, cppInsert);\n    cppInsert->defaultValues();\n}\n\nvoid WCDBStatementInsertConfigUpsert(CPPStatementInsert insert, CPPUpsert upsert)\n{\n    WCDBGetObjectOrReturn(insert, WCDB::StatementInsert, cppInsert);\n    WCDBGetObjectOrReturn(upsert, WCDB::Upsert, cppUpsert);\n    cppInsert->upsert(*cppUpsert);\n}\n"
  },
  {
    "path": "src/bridge/winqbridge/statement/StatementInsertBridge.h",
    "content": "//\n// Created by qiuwenchen on 2022/7/15.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"WinqBridge.h\"\n\nWCDB_EXTERN_C_BEGIN\n\nCPPStatementInsert WCDBStatementInsertCreate(void);\n\nvoid WCDBStatementInsertConfigWith(CPPStatementInsert insert,\n                                   const CPPCommonTableExpression* _Nullable exps,\n                                   int expNum);\nvoid WCDBStatementInsertConfigRecursive(CPPStatementInsert insert);\n\nvoid WCDBStatementInsertConfigTable(CPPStatementInsert insert, const char* _Nullable name);\nvoid WCDBStatementInsertConfigSchema(CPPStatementInsert insert, CPPSchema schema);\nvoid WCDBStatementInsertConfigSchema2(CPPStatementInsert insert, CPPCommonValue schema);\n\nvoid WCDBStatementInsertConfigConfiction(CPPStatementInsert insert,\n                                         enum WCDBSyntaxConflictAction action);\n\nvoid WCDBStatementInsertConfigAlias(CPPStatementInsert insert, const char* _Nullable name);\n\nvoid WCDBStatementInsertConfigColumns(CPPStatementInsert insert,\n                                      const CPPColumn* _Nullable columns,\n                                      int colNum);\nvoid WCDBStatementInsertConfigColumns2(CPPStatementInsert insert, CPPCommonArray columns);\nvoid WCDBStatementInsertConfigValues(CPPStatementInsert insert,\n                                     const CPPExpression* _Nullable exps,\n                                     int expNum);\nvoid WCDBStatementInsertConfigValuesWithMultiTypeArray(CPPStatementInsert insert,\n                                                       CPPMultiTypeArray values);\nvoid WCDBStatementInsertConfigValuesWithBindParameters(CPPStatementInsert insert,\n                                                       int parametersCount);\nvoid WCDBStatementInsertConfigSelect(CPPStatementInsert insert, CPPStatementSelect select);\n\nvoid WCDBStatementInsertConfigDefaultValues(CPPStatementInsert insert);\nvoid WCDBStatementInsertConfigUpsert(CPPStatementInsert insert, CPPUpsert upsert);\n\nWCDB_EXTERN_C_END\n"
  },
  {
    "path": "src/bridge/winqbridge/statement/StatementPragmaBridge.cpp",
    "content": "//\n// Created by qiuwenchen on 2022/7/17.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"StatementPragmaBridge.h\"\n#include \"LiteralValue.hpp\"\n#include \"Pragma.hpp\"\n#include \"Schema.hpp\"\n#include \"StatementPragma.hpp\"\n#include \"WinqBridge.hpp\"\n\nCPPStatementPragma WCDBStatementPragmaCreate(void)\n{\n    return WCDBCreateCPPBridgedObject(CPPStatementPragma, WCDB::StatementPragma);\n}\n\nvoid WCDBStatementPragmaConfigPragma(CPPStatementPragma statment, CPPPragma pragma)\n{\n    WCDBGetObjectOrReturn(statment, WCDB::StatementPragma, cppStatement);\n    WCDBGetObjectOrReturn(pragma, WCDB::Pragma, cppPragma);\n    cppStatement->pragma(*cppPragma);\n}\n\nvoid WCDBStatementPragmaConfigSchema(CPPStatementPragma statment, CPPSchema schema)\n{\n    WCDBGetObjectOrReturn(statment, WCDB::StatementPragma, cppStatement);\n    WCDBGetObjectOrReturn(schema, WCDB::Schema, cppSchema);\n    cppStatement->schema(*cppSchema);\n}\n\nvoid WCDBStatementPragmaConfigSchema2(CPPStatementPragma statment, CPPCommonValue schema)\n{\n    WCDBGetObjectOrReturn(statment, WCDB::StatementPragma, cppStatement);\n    cppStatement->schema(WCDBCreateSchemaFromCommonValue(schema));\n}\n\nvoid WCDBStatementPragmaConfigToValue(CPPStatementPragma statment, CPPLiteralValue value)\n{\n    WCDBGetObjectOrReturn(statment, WCDB::StatementPragma, cppStatement);\n    WCDBGetObjectOrReturn(value, WCDB::LiteralValue, cppValue);\n    cppStatement->to(*cppValue);\n}\n\nvoid WCDBStatementPragmaConfigWithValue(CPPStatementPragma statment, CPPLiteralValue value)\n{\n    WCDBGetObjectOrReturn(statment, WCDB::StatementPragma, cppStatement);\n    WCDBGetObjectOrReturn(value, WCDB::LiteralValue, cppValue);\n    cppStatement->with(*cppValue);\n}\n\nvoid WCDBStatementPragmaConfigToValue2(CPPStatementPragma statment, CPPCommonValue value)\n{\n    WCDBGetObjectOrReturn(statment, WCDB::StatementPragma, cppStatement);\n    cppStatement->to(WCDBCreateLiteralValueFromCommonValue(value));\n}\n\nvoid WCDBStatementPragmaConfigWithValue2(CPPStatementPragma statment, CPPCommonValue value)\n{\n    WCDBGetObjectOrReturn(statment, WCDB::StatementPragma, cppStatement);\n    cppStatement->with(WCDBCreateLiteralValueFromCommonValue(value));\n}\n"
  },
  {
    "path": "src/bridge/winqbridge/statement/StatementPragmaBridge.h",
    "content": "//\n// Created by qiuwenchen on 2022/7/17.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"WinqBridge.h\"\n\nWCDB_EXTERN_C_BEGIN\n\nCPPStatementPragma WCDBStatementPragmaCreate(void);\nvoid WCDBStatementPragmaConfigPragma(CPPStatementPragma statment, CPPPragma pragma);\nvoid WCDBStatementPragmaConfigSchema(CPPStatementPragma statment, CPPSchema schema);\nvoid WCDBStatementPragmaConfigSchema2(CPPStatementPragma statment, CPPCommonValue schema);\nvoid WCDBStatementPragmaConfigToValue(CPPStatementPragma statment, CPPLiteralValue value);\nvoid WCDBStatementPragmaConfigWithValue(CPPStatementPragma statment, CPPLiteralValue value);\n\nvoid WCDBStatementPragmaConfigToValue2(CPPStatementPragma statment, CPPCommonValue value);\nvoid WCDBStatementPragmaConfigWithValue2(CPPStatementPragma statment, CPPCommonValue value);\n\nWCDB_EXTERN_C_END\n"
  },
  {
    "path": "src/bridge/winqbridge/statement/StatementReindexBridge.cpp",
    "content": "//\n// Created by qiuwenchen on 2022/7/17.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"StatementReindexBridge.h\"\n#include \"Schema.hpp\"\n#include \"StatementReindex.hpp\"\n#include \"WinqBridge.hpp\"\n\nCPPStatementReIndex WCDBStatementReIndexCreate(void)\n{\n    return WCDBCreateCPPBridgedObject(CPPStatementReIndex, WCDB::StatementReindex);\n}\n\nvoid WCDBStatementReIndexConfigCollation(CPPStatementReIndex statment,\n                                         const char* _Nullable collation)\n{\n    WCDBGetObjectOrReturn(statment, WCDB::StatementReindex, cppStatement);\n    cppStatement->collation(collation);\n}\n\nvoid WCDBStatementReIndexConfigTable(CPPStatementReIndex statment, const char* _Nullable name)\n{\n    WCDBGetObjectOrReturn(statment, WCDB::StatementReindex, cppStatement);\n    cppStatement->table(name);\n}\n\nvoid WCDBStatementReIndexConfigIndex(CPPStatementReIndex statment, const char* _Nullable name)\n{\n    WCDBGetObjectOrReturn(statment, WCDB::StatementReindex, cppStatement);\n    cppStatement->index(name);\n}\n\nvoid WCDBStatementReIndexConfigSchema(CPPStatementReIndex statment, CPPSchema schema)\n{\n    WCDBGetObjectOrReturn(statment, WCDB::StatementReindex, cppStatement);\n    WCDBGetObjectOrReturn(schema, WCDB::Schema, cppSchema);\n    cppStatement->schema(*cppSchema);\n}\n\nvoid WCDBStatementReIndexConfigSchema2(CPPStatementReIndex statment, CPPCommonValue schema)\n{\n    WCDBGetObjectOrReturn(statment, WCDB::StatementReindex, cppStatement);\n    cppStatement->schema(WCDBCreateSchemaFromCommonValue(schema));\n}\n"
  },
  {
    "path": "src/bridge/winqbridge/statement/StatementReindexBridge.h",
    "content": "//\n// Created by qiuwenchen on 2022/7/17.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"WinqBridge.h\"\n\nWCDB_EXTERN_C_BEGIN\n\nCPPStatementReIndex WCDBStatementReIndexCreate(void);\nvoid WCDBStatementReIndexConfigCollation(CPPStatementReIndex statment,\n                                         const char* _Nullable collation);\nvoid WCDBStatementReIndexConfigTable(CPPStatementReIndex statment, const char* _Nullable name);\nvoid WCDBStatementReIndexConfigIndex(CPPStatementReIndex statment, const char* _Nullable name);\nvoid WCDBStatementReIndexConfigSchema(CPPStatementReIndex statment, CPPSchema schema);\nvoid WCDBStatementReIndexConfigSchema2(CPPStatementReIndex statment, CPPCommonValue schema);\n\nWCDB_EXTERN_C_END\n"
  },
  {
    "path": "src/bridge/winqbridge/statement/StatementReleaseBridge.cpp",
    "content": "//\n// Created by qiuwenchen on 2022/7/17.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"StatementReleaseBridge.h\"\n#include \"StatementRelease.hpp\"\n#include \"WinqBridge.hpp\"\n\nCPPStatementRelease WCDBStatementReleaseCreate(void)\n{\n    return WCDBCreateCPPBridgedObject(CPPStatementRelease, WCDB::StatementRelease);\n}\n\nvoid WCDBStatementReleaseConfigSavepoint(CPPStatementRelease release, const char* _Nullable savepoint)\n{\n    WCDBGetObjectOrReturn(release, WCDB::StatementRelease, cppRelease);\n    cppRelease->release(savepoint);\n}\n"
  },
  {
    "path": "src/bridge/winqbridge/statement/StatementReleaseBridge.h",
    "content": "//\n// Created by qiuwenchen on 2022/7/17.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"WinqBridge.h\"\n\nWCDB_EXTERN_C_BEGIN\n\nCPPStatementRelease WCDBStatementReleaseCreate(void);\nvoid WCDBStatementReleaseConfigSavepoint(CPPStatementRelease release,\n                                         const char* _Nullable savepoint);\n\nWCDB_EXTERN_C_END\n"
  },
  {
    "path": "src/bridge/winqbridge/statement/StatementRollbackBridge.cpp",
    "content": "//\n// Created by qiuwenchen on 2022/7/17.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"StatementRollbackBridge.h\"\n#include \"StatementRollback.hpp\"\n#include \"WinqBridge.hpp\"\n\nCPPStatementRollback WCDBStatementRollbackCreate(void)\n{\n    CPPStatementRollback rollback\n    = WCDBCreateCPPBridgedObject(CPPStatementRollback, WCDB::StatementRollback);\n    WCDBStatementRollbackConfigSavepoint(rollback, nullptr);\n    return rollback;\n}\n\nvoid WCDBStatementRollbackConfigSavepoint(CPPStatementRollback rollback,\n                                          const char* _Nullable savepoint)\n{\n    WCDBGetObjectOrReturn(rollback, WCDB::StatementRollback, cppRollback);\n    if (savepoint != nullptr) {\n        cppRollback->rollbackToSavepoint(savepoint);\n    } else {\n        cppRollback->rollback();\n    }\n}\n"
  },
  {
    "path": "src/bridge/winqbridge/statement/StatementRollbackBridge.h",
    "content": "//\n// Created by qiuwenchen on 2022/7/17.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"WinqBridge.h\"\n\nWCDB_EXTERN_C_BEGIN\n\nCPPStatementRollback WCDBStatementRollbackCreate(void);\nvoid WCDBStatementRollbackConfigSavepoint(CPPStatementRollback rollback,\n                                          const char* _Nullable savepoint);\n\nWCDB_EXTERN_C_END\n"
  },
  {
    "path": "src/bridge/winqbridge/statement/StatementSavepointBridge.cpp",
    "content": "//\n// Created by qiuwenchen on 2022/7/17.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"StatementSavepointBridge.h\"\n#include \"StatementSavepoint.hpp\"\n#include \"WinqBridge.hpp\"\n\nCPPStatementSavepoint WCDBStatementSavepointCreate(void)\n{\n    return WCDBCreateCPPBridgedObject(CPPStatementSavepoint, WCDB::StatementSavepoint);\n}\n\nvoid WCDBStatementSavepointConfigName(CPPStatementSavepoint savepoint, const char* _Nullable name)\n{\n    WCDBGetObjectOrReturn(savepoint, WCDB::StatementSavepoint, cppSavepoint);\n    cppSavepoint->savepoint(name);\n}\n"
  },
  {
    "path": "src/bridge/winqbridge/statement/StatementSavepointBridge.h",
    "content": "//\n// Created by qiuwenchen on 2022/7/17.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"WinqBridge.h\"\n\nWCDB_EXTERN_C_BEGIN\n\nCPPStatementSavepoint WCDBStatementSavepointCreate(void);\nvoid WCDBStatementSavepointConfigName(CPPStatementSavepoint savepoint,\n                                      const char* _Nullable name);\n\nWCDB_EXTERN_C_END\n"
  },
  {
    "path": "src/bridge/winqbridge/statement/StatementSelectBridge.cpp",
    "content": "//\n// Created by qiuwenchen on 2022/5/30.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"StatementSelectBridge.h\"\n#include \"Column.hpp\"\n#include \"CommonTableExpression.hpp\"\n#include \"Expression.hpp\"\n#include \"Join.hpp\"\n#include \"LiteralValue.hpp\"\n#include \"OrderingTerm.hpp\"\n#include \"ResultColumn.hpp\"\n#include \"StatementSelect.hpp\"\n#include \"TableOrSubquery.hpp\"\n#include \"WindowDef.hpp\"\n#include \"WinqBridge.hpp\"\n\nCPPStatementSelect WCDBStatementSelectCreate()\n{\n    return WCDBCreateCPPBridgedObject(CPPStatementSelect, WCDB::StatementSelect);\n}\n\nvoid WCDBStatementSelectConfigWith(CPPStatementSelect select,\n                                   const CPPCommonTableExpression* exps,\n                                   int expNum)\n{\n    WCDBGetObjectOrReturn(select, WCDB::StatementSelect, cppSelect);\n    WCDBGetCPPSyntaxListOrReturn(WCDB::CommonTableExpression, cppExps, exps, expNum);\n    cppSelect->with(cppExps);\n}\n\nvoid WCDBStatementSelectConfigRecursive(CPPStatementSelect select)\n{\n    WCDBGetObjectOrReturn(select, WCDB::StatementSelect, cppSelect);\n    cppSelect->recursive();\n}\n\nvoid WCDBStatementSelectConfigResultColumns(CPPStatementSelect select,\n                                            const CPPResultColumn* columns,\n                                            int columnNum)\n{\n    WCDBGetObjectOrReturn(select, WCDB::StatementSelect, cppSelect);\n    WCDBGetCPPSyntaxListOrReturn(WCDB::ResultColumn, cppColumns, columns, columnNum);\n    cppSelect->select(cppColumns);\n}\n\nvoid WCDBStatementSelectConfigResultColumns2(CPPStatementSelect select, CPPMultiTypeArray resultColumns)\n{\n    WCDBGetObjectOrReturn(select, WCDB::StatementSelect, cppSelect);\n    WCDB::ResultColumns cppResultColumns;\n    int intIndex = 0;\n    int doubleIndex = 0;\n    int stringIndex = 0;\n    for (int i = 0; i < resultColumns.totalLength; i++) {\n        switch (resultColumns.types[i]) {\n        case WCDBBridgedType_Null: {\n            cppResultColumns.emplace_back(WCDB::LiteralValue(nullptr));\n            intIndex++;\n        } break;\n        case WCDBBridgedType_Bool: {\n            cppResultColumns.emplace_back(\n            WCDB::LiteralValue((bool) resultColumns.intValues[intIndex]));\n            intIndex++;\n        } break;\n        case WCDBBridgedType_Int: {\n            cppResultColumns.emplace_back(\n            WCDB::LiteralValue((int64_t) resultColumns.intValues[intIndex]));\n            intIndex++;\n        } break;\n        case WCDBBridgedType_UInt: {\n            cppResultColumns.emplace_back(\n            WCDB::LiteralValue((uint64_t) resultColumns.intValues[intIndex]));\n            intIndex++;\n        } break;\n        case WCDBBridgedType_Double: {\n            cppResultColumns.emplace_back(\n            WCDB::LiteralValue(resultColumns.doubleValues[doubleIndex]));\n            doubleIndex++;\n        } break;\n        case WCDBBridgedType_String: {\n            cppResultColumns.emplace_back(WCDB::Column(\n            WCDB::UnsafeStringView(resultColumns.stringValues[stringIndex])));\n            stringIndex++;\n        } break;\n        case WCDBBridgedType_Column: {\n            cppResultColumns.emplace_back(\n            WCDBGetMultiTypeArrayObject(WCDB::Column, resultColumns, intIndex));\n            intIndex++;\n        } break;\n        case WCDBBridgedType_LiteralValue: {\n            cppResultColumns.emplace_back(WCDBGetMultiTypeArrayObject(\n            WCDB::LiteralValue, resultColumns, intIndex));\n            intIndex++;\n        } break;\n        case WCDBBridgedType_Expression: {\n            cppResultColumns.emplace_back(WCDBGetMultiTypeArrayObject(\n            WCDB::Expression, resultColumns, intIndex));\n            intIndex++;\n        } break;\n        case WCDBBridgedType_RaiseFunction: {\n            cppResultColumns.emplace_back(WCDBGetMultiTypeArrayObject(\n            WCDB::RaiseFunction, resultColumns, intIndex));\n            intIndex++;\n        } break;\n        case WCDBBridgedType_ResultColumn: {\n            cppResultColumns.push_back(WCDBGetMultiTypeArrayObject(\n            WCDB::ResultColumn, resultColumns, intIndex));\n            intIndex++;\n        } break;\n        default:\n            assert(0);\n            break;\n        }\n    }\n    cppSelect->select(cppResultColumns);\n}\n\nvoid WCDBStatementSelectConfigDistinct(CPPStatementSelect select)\n{\n    WCDBGetObjectOrReturn(select, WCDB::StatementSelect, cppSelect);\n    cppSelect->distinct();\n}\n\nvoid WCDBStatementSelectConfigFromTableOrSubqueries(CPPStatementSelect select,\n                                                    const CPPTableOrSubquery* _Nullable tableOrSubqueries,\n                                                    int queryNum)\n{\n    WCDBGetObjectOrReturn(select, WCDB::StatementSelect, cppSelect);\n    WCDBGetCPPSyntaxListOrReturn(\n    WCDB::TableOrSubquery, cppQueries, tableOrSubqueries, queryNum);\n    cppSelect->from(cppQueries);\n}\n\nvoid WCDBStatementSelectConfigFromTableOrSubqueries2(CPPStatementSelect select,\n                                                     CPPMultiTypeArray tableOrSubqueries)\n{\n    WCDBGetObjectOrReturn(select, WCDB::StatementSelect, cppSelect);\n    WCDB::TablesOrSubqueries cppTableOrSubqueries;\n    int intIndex = 0;\n    int stringIndex = 0;\n    for (int i = 0; i < tableOrSubqueries.totalLength; i++) {\n        switch (tableOrSubqueries.types[i]) {\n        case WCDBBridgedType_String: {\n            cppTableOrSubqueries.emplace_back(\n            WCDB::UnsafeStringView(tableOrSubqueries.stringValues[stringIndex]));\n            stringIndex++;\n        } break;\n        case WCDBBridgedType_TableOrSubquery: {\n            cppTableOrSubqueries.push_back(WCDBGetMultiTypeArrayObject(\n            WCDB::TableOrSubquery, tableOrSubqueries, intIndex));\n            intIndex++;\n        } break;\n        case WCDBBridgedType_SelectSTMT: {\n            cppTableOrSubqueries.emplace_back(WCDBGetMultiTypeArrayObject(\n            WCDB::StatementSelect, tableOrSubqueries, intIndex));\n            intIndex++;\n        } break;\n        case WCDBBridgedType_JoinClause: {\n            cppTableOrSubqueries.emplace_back(WCDBGetMultiTypeArrayObject(\n            WCDB::Join, tableOrSubqueries, intIndex));\n            intIndex++;\n        } break;\n        default:\n            assert(tableOrSubqueries.types[i] == WCDBBridgedType_Invalid);\n            break;\n        }\n    }\n    cppSelect->from(cppTableOrSubqueries);\n}\n\nvoid WCDBStatementSelectConfigWhere(CPPStatementSelect select, CPPExpression condition)\n{\n    WCDBGetObjectOrReturn(select, WCDB::StatementSelect, cppSelect);\n    WCDBGetObjectOrReturn(condition, WCDB::Expression, cppCondition);\n    cppSelect->where(*cppCondition);\n}\n\nvoid WCDBStatementSelectConfigGroups(CPPStatementSelect select, const CPPExpression* exps, int expNum)\n{\n    WCDBGetObjectOrReturn(select, WCDB::StatementSelect, cppSelect);\n    WCDBGetCPPSyntaxListOrReturn(WCDB::Expression, cppExps, exps, expNum);\n    cppSelect->groups(cppExps);\n}\n\nvoid WCDBStatementSelectConfigGroups2(CPPStatementSelect select, CPPMultiTypeArray groups)\n{\n    WCDBGetObjectOrReturn(select, WCDB::StatementSelect, cppSelect);\n    WCDB::Expressions cppExps;\n    int intIndex = 0;\n    int stringIndex = 0;\n    for (int i = 0; i < groups.totalLength; i++) {\n        switch (groups.types[i]) {\n        case WCDBBridgedType_String: {\n            cppExps.emplace_back(WCDB::Column(groups.stringValues[stringIndex]));\n            stringIndex++;\n        } break;\n        case WCDBBridgedType_Column: {\n            cppExps.emplace_back(WCDBGetMultiTypeArrayObject(WCDB::Column, groups, intIndex));\n            intIndex++;\n        } break;\n        case WCDBBridgedType_Expression: {\n            cppExps.push_back(WCDBGetMultiTypeArrayObject(WCDB::Expression, groups, intIndex));\n            intIndex++;\n        } break;\n        default:\n            assert(groups.types[i] == WCDBBridgedType_Invalid);\n            break;\n        }\n    }\n    cppSelect->groups(cppExps);\n}\n\nvoid WCDBStatementSelectConfigHaving(CPPStatementSelect select, CPPExpression expression)\n{\n    WCDBGetObjectOrReturn(select, WCDB::StatementSelect, cppSelect);\n    WCDBGetObjectOrReturn(expression, WCDB::Expression, cppExpression);\n    cppSelect->having(*cppExpression);\n}\n\nvoid WCDBStatementSelectConfigWindow(CPPStatementSelect select, const char* windowName)\n{\n    WCDBGetObjectOrReturn(select, WCDB::StatementSelect, cppSelect);\n    cppSelect->window(windowName);\n}\n\nvoid WCDBStatementSelectConfigAs(CPPStatementSelect select, CPPWindowDef windowDef)\n{\n    WCDBGetObjectOrReturn(select, WCDB::StatementSelect, cppSelect);\n    WCDBGetObjectOrReturn(windowDef, WCDB::WindowDef, cppWindowDef);\n    cppSelect->as(*cppWindowDef);\n}\n\nvoid WCDBStatementSelectConfigValues(CPPStatementSelect select, const CPPExpression* exps, int expNum)\n{\n    WCDBGetObjectOrReturn(select, WCDB::StatementSelect, cppSelect);\n    WCDBGetCPPSyntaxListOrReturn(WCDB::Expression, cppExps, exps, expNum);\n    cppSelect->values(cppExps);\n}\n\nvoid WCDBStatementSelectConfigUnion(CPPStatementSelect select)\n{\n    WCDBGetObjectOrReturn(select, WCDB::StatementSelect, cppSelect);\n    cppSelect->union_();\n}\n\nvoid WCDBStatementSelectConfigUnionAll(CPPStatementSelect select)\n{\n    WCDBGetObjectOrReturn(select, WCDB::StatementSelect, cppSelect);\n    cppSelect->unionAll();\n}\n\nvoid WCDBStatementSelectConfigIntersect(CPPStatementSelect select)\n{\n    WCDBGetObjectOrReturn(select, WCDB::StatementSelect, cppSelect);\n    cppSelect->intersect();\n}\n\nvoid WCDBStatementSelectConfigExcept(CPPStatementSelect select)\n{\n    WCDBGetObjectOrReturn(select, WCDB::StatementSelect, cppSelect);\n    cppSelect->except();\n}\n\nvoid WCDBStatementSelectConfigOrders(CPPStatementSelect select,\n                                     const CPPOrderingTerm* orders,\n                                     int orderNum)\n{\n    WCDBGetObjectOrReturn(select, WCDB::StatementSelect, cppSelect);\n    WCDBGetCPPSyntaxListOrReturn(WCDB::OrderingTerm, cppOrders, orders, orderNum);\n    cppSelect->orders(cppOrders);\n}\n\nvoid WCDBStatementSelectConfigLimitRange(CPPStatementSelect select, CPPExpression from, CPPExpression to)\n{\n    WCDBGetObjectOrReturn(select, WCDB::StatementSelect, cppSelect);\n    WCDBGetObjectOrReturn(from, WCDB::Expression, cppFrom);\n    WCDBGetObjectOrReturn(to, WCDB::Expression, cppTo);\n    cppSelect->limit(*cppFrom, *cppTo);\n}\n\nvoid WCDBStatementSelectConfigLimitCount(CPPStatementSelect select, CPPExpression limit)\n{\n    WCDBGetObjectOrReturn(select, WCDB::StatementSelect, cppSelect);\n    WCDBGetObjectOrReturn(limit, WCDB::Expression, cppLimit);\n    cppSelect->limit(*cppLimit);\n}\n\nvoid WCDBStatementSelectConfigLimitOffset(CPPStatementSelect select, CPPExpression offset)\n{\n    WCDBGetObjectOrReturn(select, WCDB::StatementSelect, cppSelect);\n    WCDBGetObjectOrReturn(offset, WCDB::Expression, cppOffset);\n    cppSelect->offset(*cppOffset);\n}\n\nvoid WCDBStatementSelectConfigLimitRange2(CPPStatementSelect select,\n                                          CPPCommonValue from,\n                                          CPPCommonValue to)\n{\n    WCDBGetObjectOrReturn(select, WCDB::StatementSelect, cppSelect);\n    cppSelect->limit(WCDBCreateExpressionFromCommonValue(from),\n                     WCDBCreateExpressionFromCommonValue(to));\n}\n\nvoid WCDBStatementSelectConfigLimitCount2(CPPStatementSelect select, CPPCommonValue limit)\n{\n    WCDBGetObjectOrReturn(select, WCDB::StatementSelect, cppSelect);\n    cppSelect->limit(WCDBCreateExpressionFromCommonValue(limit));\n}\n\nvoid WCDBStatementSelectConfigOffset2(CPPStatementSelect select, CPPCommonValue offset)\n{\n    WCDBGetObjectOrReturn(select, WCDB::StatementSelect, cppSelect);\n    cppSelect->offset(WCDBCreateExpressionFromCommonValue(offset));\n}\n"
  },
  {
    "path": "src/bridge/winqbridge/statement/StatementSelectBridge.h",
    "content": "//\n// Created by qiuwenchen on 2022/5/30.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"WinqBridge.h\"\n\nWCDB_EXTERN_C_BEGIN\n\nCPPStatementSelect WCDBStatementSelectCreate(void);\nvoid WCDBStatementSelectConfigWith(CPPStatementSelect select,\n                                   const CPPCommonTableExpression* _Nullable exps,\n                                   int expNum);\nvoid WCDBStatementSelectConfigRecursive(CPPStatementSelect select);\nvoid WCDBStatementSelectConfigResultColumns(CPPStatementSelect select,\n                                            const CPPResultColumn* _Nullable resultColumn,\n                                            int columnNum);\nvoid WCDBStatementSelectConfigResultColumns2(CPPStatementSelect select,\n                                             CPPMultiTypeArray resultColumns);\nvoid WCDBStatementSelectConfigDistinct(CPPStatementSelect select);\nvoid WCDBStatementSelectConfigFromTableOrSubqueries(CPPStatementSelect select,\n                                                    const CPPTableOrSubquery* _Nullable tableOrSubqueries,\n                                                    int queryNum);\nvoid WCDBStatementSelectConfigFromTableOrSubqueries2(CPPStatementSelect select,\n                                                     CPPMultiTypeArray tableOrSubqueries);\nvoid WCDBStatementSelectConfigWhere(CPPStatementSelect select, CPPExpression condition);\nvoid WCDBStatementSelectConfigGroups(CPPStatementSelect select,\n                                     const CPPExpression* _Nullable exps,\n                                     int expNum);\nvoid WCDBStatementSelectConfigGroups2(CPPStatementSelect select, CPPMultiTypeArray groups);\nvoid WCDBStatementSelectConfigHaving(CPPStatementSelect select, CPPExpression expression);\nvoid WCDBStatementSelectConfigWindow(CPPStatementSelect select, const char* _Nullable windowName);\nvoid WCDBStatementSelectConfigAs(CPPStatementSelect select, CPPWindowDef windowDef);\nvoid WCDBStatementSelectConfigValues(CPPStatementSelect select,\n                                     const CPPExpression* _Nullable exps,\n                                     int expNum);\nvoid WCDBStatementSelectConfigUnion(CPPStatementSelect select);\nvoid WCDBStatementSelectConfigUnionAll(CPPStatementSelect select);\nvoid WCDBStatementSelectConfigIntersect(CPPStatementSelect select);\nvoid WCDBStatementSelectConfigExcept(CPPStatementSelect select);\nvoid WCDBStatementSelectConfigOrders(CPPStatementSelect select,\n                                     const CPPOrderingTerm* _Nullable orders,\n                                     int orderNum);\nvoid WCDBStatementSelectConfigLimitRange(CPPStatementSelect select,\n                                         CPPExpression from,\n                                         CPPExpression to);\nvoid WCDBStatementSelectConfigLimitCount(CPPStatementSelect select, CPPExpression limit);\nvoid WCDBStatementSelectConfigLimitOffset(CPPStatementSelect select, CPPExpression offset);\n\nvoid WCDBStatementSelectConfigLimitRange2(CPPStatementSelect select,\n                                          CPPCommonValue from,\n                                          CPPCommonValue to);\nvoid WCDBStatementSelectConfigLimitCount2(CPPStatementSelect select, CPPCommonValue limit);\nvoid WCDBStatementSelectConfigOffset2(CPPStatementSelect select, CPPCommonValue offset);\n\nWCDB_EXTERN_C_END\n"
  },
  {
    "path": "src/bridge/winqbridge/statement/StatementUpdateBridge.cpp",
    "content": "//\n// Created by qiuwenchen on 2022/7/15.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"StatementUpdateBridge.h\"\n#include \"BindParameter.hpp\"\n#include \"Column.hpp\"\n#include \"CommonTableExpression.hpp\"\n#include \"Expression.hpp\"\n#include \"LiteralValue.hpp\"\n#include \"OrderingTerm.hpp\"\n#include \"QualifiedTable.hpp\"\n#include \"StatementUpdate.hpp\"\n#include \"WinqBridge.hpp\"\n\nCPPStatementUpdate WCDBStatementUpdateCreate(void)\n{\n    return WCDBCreateCPPBridgedObject(CPPStatementUpdate, WCDB::StatementUpdate);\n}\n\nvoid WCDBStatementUpdateConfigWith(CPPStatementUpdate update,\n                                   const CPPCommonTableExpression* _Nullable exps,\n                                   int expNum)\n{\n    WCDBGetObjectOrReturn(update, WCDB::StatementUpdate, cppUpdate);\n    WCDBGetCPPSyntaxListOrReturn(WCDB::CommonTableExpression, cppExps, exps, expNum);\n    cppUpdate->with(cppExps);\n}\n\nvoid WCDBStatementUpdateConfigRecursive(CPPStatementUpdate update)\n{\n    WCDBGetObjectOrReturn(update, WCDB::StatementUpdate, cppUpdate);\n    cppUpdate->recursive();\n}\n\nvoid WCDBStatementUpdateConfigTable(CPPStatementUpdate update, CPPQualifiedTable table)\n{\n    WCDBGetObjectOrReturn(update, WCDB::StatementUpdate, cppUpdate);\n    WCDBGetObjectOrReturn(table, WCDB::QualifiedTable, cppTable);\n    cppUpdate->update(*cppTable);\n}\n\nvoid WCDBStatementUpdateConfigTable2(CPPStatementUpdate update, CPPCommonValue table)\n{\n    WCDBGetObjectOrReturn(update, WCDB::StatementUpdate, cppUpdate);\n    if (table.type == WCDBBridgedType_String) {\n        cppUpdate->update(WCDB::UnsafeStringView((const char*) table.intValue));\n    } else if (table.type == WCDBBridgedType_QualifiedTableName) {\n        cppUpdate->update(WCDBGetBridgedData(WCDB::QualifiedTable, table));\n    }\n}\n\nvoid WCDBStatementUpdateConfigConfiction(CPPStatementUpdate update,\n                                         enum WCDBSyntaxConflictAction action)\n{\n    WCDBGetObjectOrReturn(update, WCDB::StatementUpdate, cppUpdate);\n    cppUpdate->syntax().conflictAction = WCDB::WinqBridge::changeConflictAction(action);\n}\n\nvoid WCDBStatementUpdateConfigColumns(CPPStatementUpdate update,\n                                      const CPPColumn* _Nullable columns,\n                                      int colNum)\n{\n    WCDBGetObjectOrReturn(update, WCDB::StatementUpdate, cppUpdate);\n    WCDBGetCPPSyntaxListOrReturn(WCDB::Column, cppColumns, columns, colNum);\n    cppUpdate->set(cppColumns);\n}\n\nvoid WCDBStatementUpdateConfigColumns2(CPPStatementUpdate update, CPPCommonArray columns)\n{\n    WCDBGetObjectOrReturn(update, WCDB::StatementUpdate, cppUpdate);\n    WCDB::Columns cppColumns;\n    if (columns.type == WCDBBridgedType_String) {\n        for (int i = 0; i < columns.length; i++) {\n            cppColumns.emplace_back(WCDBGetCommonArrayLiteralValue(const char*, columns, i));\n        }\n    } else if (columns.type == WCDBBridgedType_Column) {\n        for (int i = 0; i < columns.length; i++) {\n            cppColumns.push_back(WCDBGetCommonArrayObject(WCDB::Column, columns, i));\n        }\n    } else {\n        assert(0);\n    }\n    cppUpdate->set(cppColumns);\n}\n\nvoid WCDBStatementUpdateConfigValue(CPPStatementUpdate update, CPPExpression expression)\n{\n    WCDBGetObjectOrReturn(update, WCDB::StatementUpdate, cppUpdate);\n    WCDBGetObjectOrReturn(expression, WCDB::Expression, cppExpression);\n    cppUpdate->to(*cppExpression);\n}\n\nvoid WCDBStatementUpdateConfigValue2(CPPStatementUpdate update, CPPCommonValue expression)\n{\n    WCDBGetObjectOrReturn(update, WCDB::StatementUpdate, cppUpdate);\n    cppUpdate->to(WCDBCreateExpressionFromCommonValue(expression));\n}\n\nvoid WCDBStatementUpdateConfigColumnsToValues(CPPStatementUpdate update,\n                                              CPPCommonArray columns,\n                                              CPPMultiTypeArray values)\n{\n    WCDBGetObjectOrReturn(update, WCDB::StatementUpdate, cppUpdate);\n    int totalLength\n    = columns.length > values.totalLength ? values.totalLength : columns.length;\n    int intIndex = 0;\n    int doubleIndex = 0;\n    int stringIndex = 0;\n    for (int i = 0; i < totalLength; i++) {\n        if (columns.type == WCDBBridgedType_String) {\n            cppUpdate->set(\n            WCDB::Column(WCDBGetCommonArrayLiteralValue(const char*, columns, i)));\n        } else if (columns.type == WCDBBridgedType_Column) {\n            cppUpdate->set(WCDBGetCommonArrayObject(WCDB::Column, columns, i));\n        } else {\n            assert(0);\n        }\n        switch (values.types[i]) {\n        case WCDBBridgedType_Null: {\n            cppUpdate->to(WCDB::LiteralValue(nullptr));\n            intIndex++;\n        } break;\n        case WCDBBridgedType_Bool: {\n            cppUpdate->to(WCDB::LiteralValue((bool) values.intValues[intIndex]));\n            intIndex++;\n        } break;\n        case WCDBBridgedType_Int: {\n            cppUpdate->to(WCDB::LiteralValue((int64_t) values.intValues[intIndex]));\n            intIndex++;\n        } break;\n        case WCDBBridgedType_UInt: {\n            cppUpdate->to(WCDB::LiteralValue((uint64_t) values.intValues[intIndex]));\n            intIndex++;\n        } break;\n        case WCDBBridgedType_Double: {\n            cppUpdate->to(WCDB::LiteralValue(values.doubleValues[doubleIndex]));\n            doubleIndex++;\n        } break;\n        case WCDBBridgedType_String: {\n            cppUpdate->to(WCDB::LiteralValue(\n            WCDB::UnsafeStringView(values.stringValues[stringIndex])));\n            stringIndex++;\n        } break;\n        case WCDBBridgedType_Column: {\n            cppUpdate->to(WCDBGetMultiTypeArrayObject(WCDB::Column, values, intIndex));\n            intIndex++;\n        } break;\n        case WCDBBridgedType_LiteralValue: {\n            cppUpdate->to(WCDBGetMultiTypeArrayObject(WCDB::LiteralValue, values, intIndex));\n            intIndex++;\n        } break;\n        case WCDBBridgedType_BindParameter: {\n            cppUpdate->to(WCDBGetMultiTypeArrayObject(WCDB::BindParameter, values, intIndex));\n            intIndex++;\n        } break;\n        case WCDBBridgedType_Expression: {\n            cppUpdate->to(WCDBGetMultiTypeArrayObject(WCDB::Expression, values, intIndex));\n            intIndex++;\n        } break;\n        default:\n            break;\n        }\n    }\n}\n\nvoid WCDBStatementUpdateConfigColumnsToBindParameters(CPPStatementUpdate update,\n                                                      CPPCommonArray columns)\n{\n    WCDBGetObjectOrReturn(update, WCDB::StatementUpdate, cppUpdate);\n    if (columns.type == WCDBBridgedType_String) {\n        for (int i = 0; i < columns.length; i++) {\n            cppUpdate->set(WCDBGetCommonArrayLiteralValue(const char*, columns, i));\n            cppUpdate->to(WCDB::BindParameter(i + 1));\n        }\n    } else if (columns.type == WCDBBridgedType_Column) {\n        for (int i = 0; i < columns.length; i++) {\n            cppUpdate->set(WCDBGetCommonArrayObject(WCDB::Column, columns, i));\n            cppUpdate->to(WCDB::BindParameter(i + 1));\n        }\n    } else {\n        assert(0);\n    }\n}\n\nvoid WCDBStatementUpdateConfigCondition(CPPStatementUpdate update, CPPExpression expression)\n{\n    WCDBGetObjectOrReturn(update, WCDB::StatementUpdate, cppUpdate);\n    WCDBGetObjectOrReturn(expression, WCDB::Expression, cppExpression);\n    cppUpdate->where(*cppExpression);\n}\n\nvoid WCDBStatementUpdateConfigOrders(CPPStatementUpdate update,\n                                     const CPPOrderingTerm* orders,\n                                     int orderNum)\n{\n    WCDBGetObjectOrReturn(update, WCDB::StatementUpdate, cppUpdate);\n    WCDBGetCPPSyntaxListOrReturn(WCDB::OrderingTerm, cppOrders, orders, orderNum);\n    cppUpdate->orders(cppOrders);\n}\n\nvoid WCDBStatementUpdateConfigLimitRange(CPPStatementUpdate update, CPPExpression from, CPPExpression to)\n{\n    WCDBGetObjectOrReturn(update, WCDB::StatementUpdate, cppUpdate);\n    WCDBGetObjectOrReturn(from, WCDB::Expression, cppFrom);\n    WCDBGetObjectOrReturn(to, WCDB::Expression, cppTo);\n    cppUpdate->limit(*cppFrom, *cppTo);\n}\n\nvoid WCDBStatementUpdateConfigLimitCount(CPPStatementUpdate update, CPPExpression limit)\n{\n    WCDBGetObjectOrReturn(update, WCDB::StatementUpdate, cppUpdate);\n    WCDBGetObjectOrReturn(limit, WCDB::Expression, cppLimit);\n    cppUpdate->limit(*cppLimit);\n}\n\nvoid WCDBStatementUpdateConfigLimitOffset(CPPStatementUpdate update, CPPExpression offset)\n{\n    WCDBGetObjectOrReturn(update, WCDB::StatementUpdate, cppUpdate);\n    WCDBGetObjectOrReturn(offset, WCDB::Expression, cppOffset);\n    cppUpdate->offset(*cppOffset);\n}\n\nvoid WCDBStatementUpdateConfigLimitRange2(CPPStatementUpdate update,\n                                          CPPCommonValue from,\n                                          CPPCommonValue to)\n{\n    WCDBGetObjectOrReturn(update, WCDB::StatementUpdate, cppSelect);\n    cppSelect->limit(WCDBCreateExpressionFromCommonValue(from),\n                     WCDBCreateExpressionFromCommonValue(to));\n}\n\nvoid WCDBStatementUpdateConfigLimitCount2(CPPStatementUpdate update, CPPCommonValue limit)\n{\n    WCDBGetObjectOrReturn(update, WCDB::StatementUpdate, cppSelect);\n    cppSelect->limit(WCDBCreateExpressionFromCommonValue(limit));\n}\n\nvoid WCDBStatementUpdateConfigOffset2(CPPStatementUpdate update, CPPCommonValue offset)\n{\n    WCDBGetObjectOrReturn(update, WCDB::StatementUpdate, cppSelect);\n    cppSelect->offset(WCDBCreateExpressionFromCommonValue(offset));\n}\n"
  },
  {
    "path": "src/bridge/winqbridge/statement/StatementUpdateBridge.h",
    "content": "//\n// Created by qiuwenchen on 2022/7/15.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"WinqBridge.h\"\n\nWCDB_EXTERN_C_BEGIN\n\nCPPStatementUpdate WCDBStatementUpdateCreate(void);\n\nvoid WCDBStatementUpdateConfigWith(CPPStatementUpdate update,\n                                   const CPPCommonTableExpression* _Nullable exps,\n                                   int expNum);\nvoid WCDBStatementUpdateConfigRecursive(CPPStatementUpdate update);\n\nvoid WCDBStatementUpdateConfigTable(CPPStatementUpdate update, CPPQualifiedTable table);\nvoid WCDBStatementUpdateConfigTable2(CPPStatementUpdate update, CPPCommonValue table);\n\nvoid WCDBStatementUpdateConfigConfiction(CPPStatementUpdate update,\n                                         enum WCDBSyntaxConflictAction action);\n\nvoid WCDBStatementUpdateConfigColumns(CPPStatementUpdate update,\n                                      const CPPColumn* _Nullable columns,\n                                      int colNum);\nvoid WCDBStatementUpdateConfigColumns2(CPPStatementUpdate update, CPPCommonArray columns);\nvoid WCDBStatementUpdateConfigValue(CPPStatementUpdate update, CPPExpression expression);\nvoid WCDBStatementUpdateConfigValue2(CPPStatementUpdate update, CPPCommonValue expression);\nvoid WCDBStatementUpdateConfigColumnsToValues(CPPStatementUpdate update,\n                                              CPPCommonArray columns,\n                                              CPPMultiTypeArray values);\nvoid WCDBStatementUpdateConfigColumnsToBindParameters(CPPStatementUpdate update,\n                                                      CPPCommonArray columns);\nvoid WCDBStatementUpdateConfigCondition(CPPStatementUpdate update, CPPExpression expression);\n\nvoid WCDBStatementUpdateConfigOrders(CPPStatementUpdate update,\n                                     const CPPOrderingTerm* _Nullable orders,\n                                     int orderNum);\nvoid WCDBStatementUpdateConfigLimitRange(CPPStatementUpdate update,\n                                         CPPExpression from,\n                                         CPPExpression to);\nvoid WCDBStatementUpdateConfigLimitCount(CPPStatementUpdate update, CPPExpression limit);\nvoid WCDBStatementUpdateConfigLimitOffset(CPPStatementUpdate update, CPPExpression offset);\n\nvoid WCDBStatementUpdateConfigLimitRange2(CPPStatementUpdate update,\n                                          CPPCommonValue from,\n                                          CPPCommonValue to);\nvoid WCDBStatementUpdateConfigLimitCount2(CPPStatementUpdate update, CPPCommonValue limit);\nvoid WCDBStatementUpdateConfigOffset2(CPPStatementUpdate update, CPPCommonValue offset);\n\nWCDB_EXTERN_C_END\n"
  },
  {
    "path": "src/bridge/winqbridge/statement/StatementVacuumBridge.cpp",
    "content": "//\n// Created by qiuwenchen on 2022/7/17.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"StatementVacuumBridge.h\"\n#include \"Schema.hpp\"\n#include \"StatementVacuum.hpp\"\n#include \"WinqBridge.hpp\"\n\nCPPStatementVacuum WCDBStatementVacuumCreate(void)\n{\n    return WCDBCreateCPPBridgedObject(CPPStatementVacuum, WCDB::StatementVacuum);\n}\n\nvoid WCDBStatementVacuumConfigAll(CPPStatementVacuum vacuum)\n{\n    WCDBGetObjectOrReturn(vacuum, WCDB::StatementVacuum, cppVacuum);\n    cppVacuum->vacuum();\n}\n\nvoid WCDBStatementVacuumConfigSchema(CPPStatementVacuum vacuum, CPPSchema schema)\n{\n    WCDBGetObjectOrReturn(vacuum, WCDB::StatementVacuum, cppVacuum);\n    WCDBGetObjectOrReturn(schema, WCDB::Schema, cppSchema);\n    cppVacuum->vacuum(*cppSchema);\n}\n\nvoid WCDBStatementVacuumConfigSchema2(CPPStatementVacuum vacuum, CPPCommonValue schema)\n{\n    WCDBGetObjectOrReturn(vacuum, WCDB::StatementVacuum, cppVacuum);\n    cppVacuum->vacuum(WCDBCreateSchemaFromCommonValue(schema));\n}\n"
  },
  {
    "path": "src/bridge/winqbridge/statement/StatementVacuumBridge.h",
    "content": "//\n// Created by qiuwenchen on 2022/7/17.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"WinqBridge.h\"\n\nWCDB_EXTERN_C_BEGIN\n\nCPPStatementVacuum WCDBStatementVacuumCreate(void);\nvoid WCDBStatementVacuumConfigAll(CPPStatementVacuum vacuum);\nvoid WCDBStatementVacuumConfigSchema(CPPStatementVacuum vacuum, CPPSchema schema);\nvoid WCDBStatementVacuumConfigSchema2(CPPStatementVacuum vacuum, CPPCommonValue schema);\n\nWCDB_EXTERN_C_END\n"
  },
  {
    "path": "src/common/base/Assertion.hpp",
    "content": "//\n// Created by sanhuazhang on 2018/05/19\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"Console.hpp\"\n\n// Assert is for WCDB debugging only, which will be removed when released. It ensures that the correctness of WCDB's code.\n// Remedial assertion is used to ensure that the app does not crash due to incorrect usage by developers.\n\n#if WCDB_DEBUG\n\n#define __WCTAssert(cond, message, action)                                      \\\n    if (!(cond)) {                                                              \\\n        WCDB::Console::fatal(message, __FILE__, __LINE__, __PRETTY_FUNCTION__); \\\n        action                                                                  \\\n    }\n\n#define WCTAssert(cond)                                                        \\\n    __WCTAssert(                                                               \\\n    cond, \"If you think it's a bug caused by WCDB, please report to us.\", abort();)\n\n#else // WCDB_DEBUG\n\n#define __WCTAssert(cond, message, action)                                     \\\n    if (!(cond)) {                                                             \\\n        WCDB::Console::fatal(message);                                         \\\n        action                                                                 \\\n    }\n\n#define WCTAssert(cond)\n\n#endif // WCDB_DEBUG\n\n#define WCTRemedialAssert(cond, message, remedial)                             \\\n    __WCTAssert(cond, message, remedial)\n"
  },
  {
    "path": "src/common/base/ClassDecorator.hpp",
    "content": "//\n// Created by 陈秋文 on 2023/11/15.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"FunctionContainer.hpp\"\n#include \"StringView.hpp\"\n#include <list>\n#include <memory>\n\n#define WCDBRegisterDecorativeFunction(baseClass, func)                        \\\n    auto lambda_##func = [this](auto&&... args) -> decltype(auto) {            \\\n        return this->baseClass::func(decltype(args)(args)...);                 \\\n    };                                                                         \\\n    registerFunction<getMemberType<decltype(&baseClass::func)>::type>(         \\\n    SlotType::func, lambda_##func);\n\n#define WCDBCallDecoratedFunction(type, func, ...)                             \\\n    getFunction(SlotType::func, &type::func)(__VA_ARGS__)\n\n#define WCDBCallDecorativeFunction(baseClass, func, ...)                       \\\n    (!m_hasDecorators ? baseClass::func(__VA_ARGS__) :                         \\\n                        getFunction(SlotType::func, &baseClass::func)(__VA_ARGS__))\n\n#define WCDBAssertFunctionTypeConsistent(classA, classB, memberFunction)         \\\n    static_assert(                                                               \\\n    std::is_same<getMemberType<decltype(&classA::memberFunction)>::type,         \\\n                 getMemberType<decltype(&classB::memberFunction)>::type>::value, \\\n    \"Function types must be consistent.\");\n\n#define WCDBSwizzleDecorativeFunction(object, curClass, func)                               \\\n    registerFunction(SlotType::func, object->getFunction(SlotType::func, &curClass::func)); \\\n    auto lambda_##func = [this](auto&&... args) -> decltype(auto) {                         \\\n        return this->curClass::func(decltype(args)(args)...);                               \\\n    };                                                                                      \\\n    object->registerFunction<getMemberType<decltype(&curClass::func)>::type>(               \\\n    SlotType::func, lambda_##func);\n\nnamespace WCDB {\n\ntemplate<typename Type, unsigned char Count>\nclass DecorativeClass;\n\ntemplate<typename Type, unsigned char Count>\nclass ClassDecorator : public FunctionContainer<Type> {\npublic:\n    ClassDecorator() { FunctionContainerBase::initFunctionSlot(Count); }\n\n    typedef DecorativeClass<Type, Count> Decorative;\n    virtual void decorate(Decorative* decorativeClass)\n    {\n        m_decoratedObj = decorativeClass;\n    }\n\nprotected:\n    DecorativeClass<Type, Count>* m_decoratedObj = nullptr;\n};\n\ntemplate<typename Type, unsigned char Count>\nclass DecorativeClass : public FunctionContainer<Type> {\npublic:\n    typedef ClassDecorator<Type, Count> Decorator;\n\n    virtual void initDecorativeFunctions() = 0;\n\n    template<typename SpecifiedDecorator, typename... Args>\n    void tryAddDecorator(const UnsafeStringView& name, Args&... args)\n    {\n        static_assert(std::is_base_of<Decorator, SpecifiedDecorator>::value, \"\");\n        if (containDecorator(name)) {\n            return;\n        }\n        std::shared_ptr<Decorator> decorator\n        = std::make_shared<SpecifiedDecorator>(args...);\n        addDecorator(name, decorator);\n    }\n\n    template<typename SpecifiedDecorator, typename... Args>\n    void tryAddDecorator(const UnsafeStringView& name, const Args&... args)\n    {\n        static_assert(std::is_base_of<Decorator, SpecifiedDecorator>::value, \"\");\n        if (containDecorator(name)) {\n            return;\n        }\n        std::shared_ptr<Decorator> decorator\n        = std::make_shared<SpecifiedDecorator>(args...);\n        addDecorator(name, decorator);\n    }\n\n    virtual void onDecorationChange() {}\n\n    bool containDecorator(const UnsafeStringView& name)\n    {\n        return m_decorators.find(name) != m_decorators.end();\n    }\n\n    template<typename SpecifiedDecorator>\n    SpecifiedDecorator* getDecorator(const UnsafeStringView& name)\n    {\n        static_assert(std::is_base_of<Decorator, SpecifiedDecorator>::value, \"\");\n        auto iter = m_decorators.find(name);\n        if (iter == m_decorators.end()) {\n            return nullptr;\n        }\n        WCTAssert(dynamic_cast<SpecifiedDecorator*>(iter->second.get()) != nullptr);\n        return static_cast<SpecifiedDecorator*>(iter->second.get());\n    }\n\n    void clearDecorators()\n    {\n        m_hasDecorators = false;\n        FunctionContainerBase::clearFunctionSlot();\n        m_decorators.clear();\n        onDecorationChange();\n    }\n\nprotected:\n    bool m_hasDecorators = false;\n\nprivate:\n    void addDecorator(const UnsafeStringView& name, std::shared_ptr<Decorator> decorator)\n    {\n        WCTAssert(!containDecorator(name));\n        if (!m_hasDecorators) {\n            FunctionContainerBase::initFunctionSlot(Count);\n            initDecorativeFunctions();\n        }\n        m_hasDecorators = true;\n        m_decorators.emplace(name, decorator);\n        decorator->decorate(this);\n        onDecorationChange();\n    }\n    StringViewMap<std::shared_ptr<Decorator>> m_decorators;\n};\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/common/base/Console.cpp",
    "content": "//\n// Created by sanhuazhang on 2018/09/28\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"Console.hpp\"\n#include \"CoreConst.h\"\n#include \"Notifier.hpp\"\n#include \"WCDBError.hpp\"\n#include \"WCDBVersion.h\"\n\n#if !defined(__OHOS__) && !defined(__ANDROID__) && !defined(_WIN32)\n#include <execinfo.h>\n#endif\n\n#include <stdlib.h>\n\nnamespace WCDB {\n\n#if WCDB_DEBUG\n\nvoid Console::fatal(const UnsafeStringView& message, const char* file, int line, const char* function)\n{\n    Error error(Error::Code::Misuse, Error::Level::Fatal, message);\n    error.infos.insert_or_assign(ErrorStringKeySource, ErrorSourceAssertion);\n    error.infos.insert_or_assign(\"File\", file);\n    error.infos.insert_or_assign(\"Line\", line);\n    error.infos.insert_or_assign(\"Func\", function);\n    error.infos.insert_or_assign(\"Version\", WCDB_VERSION_STRING);\n    error.infos.insert_or_assign(\"Build\", WCDB_BUILD_STRING);\n    auto callstacks = Console::callstacks();\n    if (callstacks.succeed()) {\n        error.infos.insert_or_assign(\"Callstacks\", callstacks.value());\n    }\n    Notifier::shared().notify(error);\n}\n\n#else // WCDB_DEBUG\n\nvoid Console::fatal(const UnsafeStringView& message)\n{\n    Error error(Error::Code::Misuse, Error::Level::Fatal, message);\n    error.infos.insert_or_assign(ErrorStringKeySource, ErrorSourceAssertion);\n    error.infos.insert_or_assign(\"Version\", WCDB_VERSION_STRING);\n    error.infos.insert_or_assign(\"Build\", WCDB_BUILD_STRING);\n    auto callstacks = Console::callstacks();\n    if (callstacks.succeed()) {\n        error.infos.insert_or_assign(\"Callstacks\", callstacks.value());\n    }\n    Notifier::shared().notify(error);\n}\n\n#endif // WCDB_DEBUG\n\nOptional<StringView> Console::callstacks()\n{\n#if !defined(__OHOS__) && !defined(__ANDROID__) && !defined(_WIN32)\n    constexpr const int size = 100;\n    void* buffer[size];\n    int depth = backtrace(buffer, size);\n    char** symbols = backtrace_symbols(buffer, depth);\n    if (symbols == nullptr) {\n        return NullOpt;\n    }\n\n    std::ostringstream stream;\n    std::string string;\n    for (int i = 0; i < depth; ++i) {\n        if (i != 0) {\n            stream << std::endl;\n        }\n        stream << symbols[i];\n    }\n    free(symbols);\n    return StringView(stream.str());\n#else\n    return NullOpt;\n#endif\n}\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/base/Console.hpp",
    "content": "//\n// Created by sanhuazhang on 2018/09/28\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"Macro.h\"\n#include \"StringView.hpp\"\n#include \"WCDBOptional.hpp\"\n\nnamespace WCDB {\n\nclass Error;\n\nclass Console final {\npublic:\n    Console() = delete;\n    Console(const Console&) = delete;\n    Console& operator=(const Console&) = delete;\n\n#if WCDB_DEBUG\n    static void\n    fatal(const UnsafeStringView& message, const char* file, int line, const char* function);\n#else  // WCDB_DEBUG\n    static void fatal(const UnsafeStringView& message);\n#endif // WCDB_DEBUG\n\nprivate:\n    static Optional<StringView> callstacks();\n};\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/base/DBOperationNotifier.cpp",
    "content": "//\n// Created by qiuwenchen on 2022/9/28.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"DBOperationNotifier.hpp\"\n#include \"Assertion.hpp\"\n#include \"InnerDatabase.hpp\"\n\nnamespace WCDB {\n\nDBOperationNotifier::DBOperationNotifier() = default;\n\nDBOperationNotifier &DBOperationNotifier::shared()\n{\n    static DBOperationNotifier *s_notifier = new DBOperationNotifier;\n    return *s_notifier;\n}\n\nvoid DBOperationNotifier::setNotification(const Callback &callback)\n{\n    LockGuard lockGuard(m_lock);\n    if (callback != nullptr) {\n        WCTAssert(m_notification == nullptr);\n    }\n    m_notification = callback;\n}\n\nvoid DBOperationNotifier::notifyOperation(InnerDatabase *database,\n                                          Operation operation,\n                                          StringViewMap<Value> &info) const\n{\n    SharedLockGuard lockGuard(m_lock);\n    if (m_notification) {\n        m_notification(database, operation, info);\n    }\n}\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/base/DBOperationNotifier.hpp",
    "content": "//\n// Created by qiuwenchen on 2022/9/28.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"Lock.hpp\"\n#include \"Value.hpp\"\n\nnamespace WCDB {\n\nclass InnerDatabase;\n\nclass DBOperationNotifier final {\npublic:\n    static DBOperationNotifier &shared();\n\n    enum Operation : int {\n        Create = 0,\n        SetTag = 1,\n        OpenHandle = 2,\n    };\n\n    void notifyOperation(InnerDatabase *database,\n                         Operation operation,\n                         StringViewMap<Value> &info) const;\n\n    typedef std::function<void(InnerDatabase *database, Operation operation, StringViewMap<Value> &info)> Callback;\n\n    void setNotification(const Callback &callback);\n\nprotected:\n    DBOperationNotifier();\n    DBOperationNotifier(const DBOperationNotifier &) = delete;\n    DBOperationNotifier &operator=(const DBOperationNotifier &) = delete;\n\n    mutable SharedLock m_lock;\n    Callback m_notification;\n};\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/common/base/Data.cpp",
    "content": "//\n// Created by sanhuazhang on 2018/05/19\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"Data.hpp\"\n#include \"Assertion.hpp\"\n#include \"HighWater.hpp\"\n#include \"Notifier.hpp\"\n#include <cstring>\n#include <zlib.h>\n\nnamespace WCDB {\n\n#pragma mark - Initialize\nData::Data() : UnsafeData()\n{\n}\n\nData::Data(size_t size) : UnsafeData()\n{\n    reset(size);\n}\n\nData::Data(const unsigned char* buffer, size_t size) : UnsafeData()\n{\n    reset(buffer, size, nullptr);\n}\n\nData::Data(const unsigned char* buffer, size_t size, SharedHighWater highWater)\n{\n    reset(buffer, size, highWater);\n}\n\nData::Data(const UnsafeData& unsafeData) : UnsafeData(unsafeData)\n{\n    if (!unsafeData.hasSharedBuffer()) {\n        reset(unsafeData);\n    }\n}\n\nData::Data(UnsafeData&& unsafeData) : UnsafeData(std::move(unsafeData))\n{\n    if (!hasSharedBuffer()) {\n        reset(m_buffer, m_size, nullptr);\n    }\n}\n\nData::~Data() = default;\n\nData& Data::operator=(const UnsafeData& unsafeData)\n{\n    if (unsafeData.hasSharedBuffer()) {\n        UnsafeData::operator=(unsafeData);\n    } else {\n        reset(unsafeData);\n    }\n    return *this;\n}\n\nData& Data::operator=(UnsafeData&& unsafeData)\n{\n    if (unsafeData.hasSharedBuffer()) {\n        UnsafeData::operator=(std::move(unsafeData));\n    } else {\n        reset(unsafeData);\n    }\n    return *this;\n}\n\noffset_t Data::getCurrentOffset() const\n{\n    WCTAssert(m_sharedBuffer != nullptr);\n    return m_buffer - m_sharedBuffer.get().buffer;\n}\n\nsize_t Data::getSharedSize() const\n{\n    WCTAssert(m_sharedBuffer != nullptr);\n    return m_sharedBuffer.get().size;\n}\n\nData::Data(unsigned char* buffer, size_t size, const SharedBuffer& sharedBuffer)\n: UnsafeData(buffer, size, sharedBuffer)\n{\n}\n\n#pragma mark - Reset\nbool Data::resize(size_t size)\n{\n    if (m_sharedBuffer != nullptr && getCurrentOffset() + size <= getSharedSize()) {\n        m_size = size;\n    } else {\n        SharedBuffer oldSharedBuffer = m_sharedBuffer;\n        unsigned char* oldBuffer = m_buffer;\n        size_t oldSize = m_size;\n        if (!reset(size)) {\n            return false;\n        }\n        if (oldBuffer && oldSize > 0) {\n            memcpy(m_buffer, oldBuffer, oldSize);\n        }\n    }\n    return true;\n}\n\nbool Data::reset(const unsigned char* buffer, size_t size, SharedHighWater highWater)\n{\n    if (size == 0) {\n        m_sharedBuffer = nullptr;\n        return true;\n    }\n    unsigned char* newBuffer = (unsigned char*) malloc(size * sizeof(unsigned char));\n    if (newBuffer == nullptr) {\n        setThreadedError(Error(Error::Code::NoMemory, Error::Level::Error));\n        return false;\n    }\n    if (highWater != nullptr) {\n        highWater->increase(size);\n    }\n    if (buffer != nullptr) {\n        memcpy(newBuffer, buffer, size);\n    }\n    m_sharedBuffer = makeSharedBuffer(newBuffer, size, [highWater](SharedData& data) {\n        Data::dealloc(data);\n        if (highWater != nullptr) {\n            highWater->decrease(data.size);\n        }\n    });\n    m_size = size;\n    m_buffer = m_sharedBuffer.get().buffer;\n    return true;\n}\n\nbool Data::reset(size_t size)\n{\n    return reset(nullptr, size, nullptr);\n}\n\nbool Data::reset(const UnsafeData& unsafeData)\n{\n    return reset(unsafeData.buffer(), unsafeData.size(), nullptr);\n}\n\nvoid Data::dealloc(SharedData& data)\n{\n    free(data.buffer);\n}\n\n#pragma mark - Subdata\nData Data::subdata(size_t size) const\n{\n    return subdata(0, size);\n}\n\nData Data::subdata(offset_t offset, size_t size) const\n{\n    if (size == 0) {\n        return null();\n    }\n    WCTRemedialAssert(size > 0 && getCurrentOffset() + offset + size <= getSharedSize(),\n                      \"Memory cross-border.\",\n                      return null(););\n    return Data(m_buffer + offset, size, m_sharedBuffer);\n}\n\nconst Data& Data::null()\n{\n    static const Data* s_null = new Data;\n    return *s_null;\n}\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/common/base/Data.hpp",
    "content": "//\n// Created by sanhuazhang on 2018/05/19\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"UnsafeData.hpp\"\n#include <memory>\n\nnamespace WCDB {\n\nclass ShareableHighWater;\ntypedef std::shared_ptr<ShareableHighWater> SharedHighWater;\n\nclass WCDB_API Data final : public UnsafeData {\n#pragma mark - Initialize\npublic:\n    Data();\n    Data(const UnsafeData& data);\n    Data(UnsafeData&& data);\n    Data(size_t size);\n    Data(const unsigned char* buffer, size_t size);\n    Data(const unsigned char* buffer, size_t size, SharedHighWater highWater);\n\n    ~Data() override;\n\n    Data& operator=(const UnsafeData& other);\n    Data& operator=(UnsafeData&& other);\n\nprotected:\n    using SharedData = UnsafeData::SharedData;\n    using SharedBuffer = UnsafeData::SharedBuffer;\n    Data(unsigned char* buffer, size_t size, const SharedBuffer& sharedBuffer);\n    offset_t getCurrentOffset() const;\n    size_t getSharedSize() const;\n\n#pragma mark - Reset\npublic:\n    bool resize(size_t size);\n\n    bool reset(const unsigned char* buffer, size_t size, SharedHighWater highWater);\n    bool reset(size_t size);\n    bool reset(const UnsafeData& unsafeData);\n\nprotected:\n    static void dealloc(SharedData& data);\n\n#pragma mark - Subdata\npublic:\n    Data subdata(size_t size) const;\n    Data subdata(offset_t offset, size_t size) const;\n\n#pragma mark - Empty\npublic:\n    static const Data& null();\n\n#pragma mark - Opaque\nprotected:\n    using UnsafeData::immutable;\n};\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/common/base/ErrorProne.cpp",
    "content": "//\n// Created by sanhuazhang on 2018/06/08\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"ErrorProne.hpp\"\n\nnamespace WCDB {\n\n#pragma mark - ErrorProne\nErrorProne::~ErrorProne() = default;\n\nconst Error &ErrorProne::getError() const\n{\n    return m_error;\n}\n\nvoid ErrorProne::assignWithSharedThreadedError()\n{\n    setError(std::move(ThreadedErrors::shared().moveThreadedError()));\n}\n\nvoid ErrorProne::setError(const Error &error)\n{\n    m_error = error;\n}\n\nvoid ErrorProne::setError(Error &&error)\n{\n    m_error = std::move(error);\n}\n\n#pragma mark - ThreadedErrorProne\nThreadedErrorProne::~ThreadedErrorProne() = default;\n\nvoid ThreadedErrorProne::setThreadedError(const Error &error)\n{\n    m_threadedError.setThreadedError(error);\n}\n\nvoid ThreadedErrorProne::setThreadedError(Error &&error)\n{\n    m_threadedError.setThreadedError(std::move(error));\n}\n\nconst Error &ThreadedErrorProne::getThreadedError()\n{\n    return m_threadedError.getThreadedError();\n}\n\nvoid ThreadedErrorProne::assignWithSharedThreadedError()\n{\n    setThreadedError(std::move(ThreadedErrors::shared().moveThreadedError()));\n}\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/common/base/ErrorProne.hpp",
    "content": "//\n// Created by sanhuazhang on 2018/06/08\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"ThreadedErrors.hpp\"\n#include \"WCDBError.hpp\"\n\nnamespace WCDB {\n\nclass ErrorProne {\npublic:\n    virtual ~ErrorProne() = 0;\n    const Error &getError() const;\n\nprotected:\n    void assignWithSharedThreadedError();\n    void setError(const Error &error);\n    void setError(Error &&error);\n\n    Error m_error;\n};\n\nclass ThreadedErrorProne {\npublic:\n    virtual ~ThreadedErrorProne() = 0;\n    const Error &getThreadedError();\n    void setThreadedError(const Error &error);\n\nprotected:\n    void setThreadedError(Error &&error);\n    void assignWithSharedThreadedError();\n\nprivate:\n    ThreadedErrors m_threadedError;\n};\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/common/base/FileHandle.cpp",
    "content": "//\n// Created by sanhuazhang on 2018/06/27\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"FileHandle.hpp\"\n#include \"Assertion.hpp\"\n#include \"CoreConst.h\"\n#include \"FileManager.hpp\"\n#include \"Notifier.hpp\"\n#include <errno.h>\n#include <fcntl.h>\n#ifndef _WIN32\n#include <sys/mman.h>\n#else\n#define NOMINMAX\n#include <windows.h>\n#include <cstdlib>\n#include <ctime>\n#endif\n\n#ifndef O_BINARY\n#define O_BINARY 0\n#endif\n\nnamespace WCDB {\n\n#pragma mark - Initialize\nFileHandle::FileHandle(const UnsafeStringView &path)\n: path(path)\n, m_fd(-1)\n#ifdef _WIN32\n, m_mapHandle(INVALID_HANDLE_VALUE)\n#endif\n, m_mode(Mode::None)\n, m_errorIgnorable(false)\n, m_fileSize(-1)\n{\n}\n\nFileHandle::FileHandle(FileHandle &&other)\n: path(std::move(other.path))\n, m_fd(other.m_fd)\n#ifdef _WIN32\n, m_mapHandle(other.m_mapHandle)\n#endif\n, m_mode(other.m_mode)\n, m_errorIgnorable(false)\n, m_fileSize(other.m_fileSize)\n{\n    other.m_fd = -1;\n    other.m_mode = Mode::None;\n}\n\nFileHandle::~FileHandle()\n{\n    WCTAssert(!isOpened() || m_mode != Mode::OverWrite);\n    close();\n}\n\nFileHandle &FileHandle::operator=(FileHandle &&other)\n{\n    WCTAssert(path == other.path);\n    m_fd = other.m_fd;\n    other.m_fd = -1;\n    other.m_mode = Mode::None;\n    return *this;\n}\n\n#pragma mark - Basic\nbool FileHandle::open(Mode mode)\n{\n    WCTAssert(!isOpened());\n    switch (mode) {\n    case Mode::OverWrite: {\n        m_fd = wcdb_open(\n        GetPathString(path), O_BINARY | O_CREAT | O_WRONLY | O_TRUNC, FileFullAccess);\n        break;\n    }\n    default:\n        WCTAssert(mode == Mode::ReadOnly);\n        m_fd = wcdb_open(GetPathString(path), O_RDONLY | O_BINARY);\n        break;\n    }\n    if (m_fd == -1) {\n        setThreadedError();\n        return false;\n    }\n    m_mode = mode;\n    return true;\n}\n\nbool FileHandle::isOpened() const\n{\n    return m_fd != -1;\n}\n\nvoid FileHandle::close()\n{\n#ifdef _WIN32\n    if (m_mapHandle != INVALID_HANDLE_VALUE) {\n        bool ret = CloseHandle(m_mapHandle);\n        WCTAssert(ret);\n        WCDB_UNUSED(ret);\n        m_mapHandle = INVALID_HANDLE_VALUE;\n    }\n#endif\n    if (m_fd != -1) {\n        int ret = ::close(m_fd);\n        WCTAssert(ret == 0);\n        WCDB_UNUSED(ret);\n        m_fd = -1;\n    }\n}\n\nssize_t FileHandle::size()\n{\n    if (m_mode == Mode::ReadOnly && m_fileSize >= 0) {\n        return m_fileSize;\n    }\n    auto fileSize = FileManager::getFileSize(path);\n    if (fileSize.succeed()) {\n        m_fileSize = fileSize.value();\n    }\n    return m_fileSize;\n}\n\nData FileHandle::read(size_t size)\n{\n    if (size == 0) {\n        return Data::null();\n    }\n    WCTAssert(isOpened());\n    Data data(size);\n    if (data.empty()) {\n        return Data::null();\n    }\n    offset_t offset = (offset_t) wcdb_lseek(m_fd, 0, SEEK_SET);\n    if (offset != 0) {\n        setThreadedError();\n        return Data::null();\n    }\n    ssize_t got;\n    size_t prior = 0;\n    size_t readSize = size;\n    unsigned char *buffer = data.buffer();\n    do {\n        got = ::read(m_fd, buffer, readSize);\n        if (got == readSize) {\n            break;\n        }\n#ifndef _WIN32\n        if (got <= 0) {\n            auto err = errno;\n            if (err == EDEVERR || err == EILSEQ || err == EINVAL) {\n                setThreadedError(\"This file may be permanently damaged\");\n                prior = 0;\n                break;\n            }\n        }\n#endif\n        if (got < 0) {\n            if (errno == EINTR) {\n                got = 1;\n                continue;\n            }\n            prior = 0;\n            setThreadedError();\n            break;\n        } else if (got > 0) {\n            readSize -= got;\n            prior += got;\n            buffer = got + buffer;\n        }\n    } while (got > 0);\n    if (got + prior == size) {\n        return data;\n    }\n    Error error;\n    error.level = m_errorIgnorable ? Error::Level::Warning : Error::Level::Error;\n    error.setSystemCode(EIO, Error::Code::IOError, \"Short read.\");\n    error.infos.insert_or_assign(ErrorStringKeyAssociatePath, path);\n    Notifier::shared().notify(error);\n    SharedThreadedErrorProne::setThreadedError(std::move(error));\n    return data.subdata(got + prior);\n}\n\nbool FileHandle::write(const UnsafeData &unsafeData)\n{\n    WCTAssert(isOpened());\n    ssize_t wrote;\n    ssize_t prior = 0;\n    size_t size = unsafeData.size();\n    const unsigned char *buffer = unsafeData.buffer();\n    offset_t offset = (offset_t) wcdb_lseek(m_fd, 0, SEEK_SET);\n    if (offset != 0) {\n        setThreadedError();\n        return false;\n    }\n    do {\n        wrote = ::write(m_fd, buffer, size);\n        if (wrote == size) {\n            break;\n        }\n        if (wrote < 0) {\n            if (errno == EINTR) {\n                wrote = 1;\n                continue;\n            }\n            setThreadedError();\n            break;\n        } else if (wrote > 0) {\n            size -= wrote;\n            prior += wrote;\n            buffer = wrote + buffer;\n        }\n    } while (wrote > 0);\n    if (wrote + prior == unsafeData.size()) {\n        m_fileSize = unsafeData.size();\n        return true;\n    }\n    m_fileSize = -1;\n    Error error;\n    error.level = m_errorIgnorable ? Error::Level::Warning : Error::Level::Error;\n    error.setSystemCode(EIO, Error::Code::IOError, \"Short write.\");\n    error.infos.insert_or_assign(ErrorStringKeyAssociatePath, path);\n    Notifier::shared().notify(error);\n    SharedThreadedErrorProne::setThreadedError(std::move(error));\n    return false;\n}\n\n#ifdef _WIN32\nvoid FileHandle::mapExceptHandler(void **mapped, size_t absoluteOffset)\n{\n    __try {\n        volatile unsigned char testByte\n        = *reinterpret_cast<unsigned char *>(static_cast<char *>(*mapped) + absoluteOffset);\n        WCDB_UNUSED(testByte);\n    } __except (EXCEPTION_EXECUTE_HANDLER) {\n        UnmapViewOfFile(*mapped);\n        *mapped = NULL;\n    }\n}\n#endif\n\n#pragma mark - Memory map\nMappedData FileHandle::map(offset_t offset, size_t length, SharedHighWater highWater)\n{\n    WCTRemedialAssert(m_mode == Mode::ReadOnly,\n                      \"Map is only supported in Readonly mode.\",\n                      return MappedData::null(););\n    WCTAssert(length > 0);\n    size_t fileSize = size();\n    size_t pageSize = memoryPageSize();\n    offset_t offsetAlignment = offset % pageSize;\n    offset_t roundedOffset = offset - offsetAlignment;\n    WCTAssert(roundedOffset < fileSize);\n\n    size_t roundedSize = length + offsetAlignment;\n    size_t sizeAlignment = roundedSize % pageSize;\n    if (sizeAlignment != 0) {\n        roundedSize += pageSize - sizeAlignment;\n    }\n    if (roundedSize + roundedOffset > fileSize) {\n        roundedSize = fileSize - roundedOffset;\n    }\n\n#ifndef _WIN32\n\n    // Avoid to mmap permanently corrupted files\n    if (offset == 0) {\n        auto testData = read(4);\n        if (testData.size() <= 0) {\n            return MappedData::null();\n        }\n    }\n\n    void *mapped = mmap(\n    nullptr, roundedSize, PROT_READ, MAP_SHARED | MAP_NOEXTEND | MAP_NORESERVE, m_fd, roundedOffset);\n    if (mapped == MAP_FAILED) {\n        Error error;\n        error.level = m_errorIgnorable ? Error::Level::Warning : Error::Level::Error;\n        error.setSystemCode(errno, Error::Code::IOError);\n        error.infos.insert_or_assign(ErrorStringKeyAssociatePath, path);\n        error.infos.insert_or_assign(\"MmapSize\", roundedSize);\n        Notifier::shared().notify(error);\n        SharedThreadedErrorProne::setThreadedError(std::move(error));\n        return MappedData::null();\n    }\n    return MappedData(reinterpret_cast<unsigned char *>(mapped), roundedSize, highWater)\n    .subdata(offsetAlignment, std::min(length, roundedSize));\n#else\n    if (m_mapHandle == INVALID_HANDLE_VALUE) {\n        HANDLE handle = (HANDLE) _get_osfhandle(m_fd);\n        if (handle == INVALID_HANDLE_VALUE) {\n            Error error;\n            error.level = m_errorIgnorable ? Error::Level::Warning : Error::Level::Error;\n            error.setSystemCode(errno, Error::Code::IOError);\n            error.infos.insert_or_assign(ErrorStringKeyAssociatePath, path);\n            error.infos.insert_or_assign(\"MmapSize\", roundedSize);\n            Notifier::shared().notify(error);\n            SharedThreadedErrorProne::setThreadedError(std::move(error));\n            return MappedData::null();\n        }\n        m_mapHandle = CreateFileMappingA(handle, NULL, PAGE_READONLY, 0, 0, NULL);\n        if (m_mapHandle == INVALID_HANDLE_VALUE) {\n            Error error;\n            error.level = m_errorIgnorable ? Error::Level::Warning : Error::Level::Error;\n            error.setWinSystemCode(GetLastError(), Error::Code::IOError);\n            error.infos.insert_or_assign(ErrorStringKeyAssociatePath, path);\n            error.infos.insert_or_assign(\"MmapSize\", roundedSize);\n            Notifier::shared().notify(error);\n            SharedThreadedErrorProne::setThreadedError(std::move(error));\n            return MappedData::null();\n        }\n    }\n    WCTAssert(m_mapHandle != INVALID_HANDLE_VALUE);\n    uint32_t offsetLow = roundedOffset & 0xffffffff;\n    uint32_t offsetHigh = roundedOffset >> 32;\n    void *mapped\n    = MapViewOfFile(m_mapHandle, FILE_MAP_READ, offsetHigh, offsetLow, roundedSize);\n    if (mapped == NULL) {\n        Error error;\n        error.level = m_errorIgnorable ? Error::Level::Warning : Error::Level::Error;\n        error.setWinSystemCode(GetLastError(), Error::Code::IOError);\n        error.infos.insert_or_assign(ErrorStringKeyAssociatePath, path);\n        error.infos.insert_or_assign(\"MmapSize\", roundedSize);\n        Notifier::shared().notify(error);\n        SharedThreadedErrorProne::setThreadedError(std::move(error));\n        return MappedData::null();\n    }\n    \n    size_t numPages = (roundedSize + pageSize - 1) / pageSize;\n    for (size_t pageIndex = 0; pageIndex < numPages; ++pageIndex) {\n        size_t pageStart = pageIndex * pageSize;\n        size_t pageSizeActual = std::min(pageSize, roundedSize - pageStart);\n        if (pageSizeActual > 0) {\n            size_t randomOffsetInPage = rand() % pageSizeActual;\n            size_t absoluteOffset = pageStart + randomOffsetInPage;\n            \n            mapExceptHandler(&mapped, absoluteOffset);\n            if (mapped == NULL) {\n                Error error;\n                error.level = m_errorIgnorable ? Error::Level::Warning :\n                                                  Error::Level::Error;\n                error.infos.insert_or_assign(ErrorStringKeyAssociatePath, path);\n                error.infos.insert_or_assign(\"MmapSize\", roundedSize);\n                error.infos.insert_or_assign(\n                \"Error\", \"Memory access violation during mapping test\");\n                Notifier::shared().notify(error);\n                SharedThreadedErrorProne::setThreadedError(std::move(error));\n                return MappedData::null();\n            }\n        }\n    }\n    \n    return MappedData(reinterpret_cast<unsigned char *>(mapped), roundedSize, highWater)\n    .subdata(offsetAlignment, std::min(length, roundedSize));\n#endif\n}\n\nUnsafeData FileHandle::mapOrReadAllData()\n{\n    do {\n        ssize_t fileSize = size();\n        if (fileSize < 0) {\n            break;\n        }\n        FileManager::setFileProtectionCompleteUntilFirstUserAuthenticationIfNeeded(path);\n        markErrorAsIgnorable(true);\n        UnsafeData data = map(0, fileSize);\n        markErrorAsIgnorable(false);\n        if (data.size() == fileSize) {\n            return data;\n        }\n        data = read(fileSize);\n        if (data.size() == fileSize) {\n            return data;\n        }\n    } while (false);\n    return UnsafeData::null();\n}\n\nconst size_t &FileHandle::memoryPageSize()\n{\n#ifndef _WIN32\n    static size_t s_memoryPageSize = getpagesize();\n#else\n    static size_t s_memoryPageSize = 0;\n    if (s_memoryPageSize == 0) {\n        SYSTEM_INFO system_info;\n        GetSystemInfo(&system_info);\n        s_memoryPageSize = system_info.dwAllocationGranularity;\n    }\n#endif\n    return s_memoryPageSize;\n}\n\n#pragma mark - Error\nvoid FileHandle::markErrorAsIgnorable(bool flag)\n{\n    m_errorIgnorable = flag;\n}\n\nvoid FileHandle::setThreadedError(const UnsafeStringView &message)\n{\n    Error error;\n    error.level = m_errorIgnorable ? Error::Level::Warning : Error::Level::Error;\n    error.setSystemCode(errno, Error::Code::IOError, message);\n    error.infos.insert_or_assign(ErrorStringKeyAssociatePath, path);\n    Notifier::shared().notify(error);\n    SharedThreadedErrorProne::setThreadedError(std::move(error));\n}\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/common/base/FileHandle.hpp",
    "content": "//\n// Created by sanhuazhang on 2018/06/27\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"CrossPlatform.h\"\n#include \"Data.hpp\"\n#include \"MappedData.hpp\"\n#include \"SharedThreadedErrorProne.hpp\"\n#include \"StringView.hpp\"\n#include <stdio.h>\n\nnamespace WCDB {\n\nclass FileHandle : public SharedThreadedErrorProne {\n#pragma mark - Initialize\npublic:\n    FileHandle(const UnsafeStringView &path);\n    FileHandle(FileHandle &&);\n    virtual ~FileHandle() override;\n    FileHandle &operator=(FileHandle &&);\n    FileHandle() = delete;\n    FileHandle(const FileHandle &) = delete;\n    FileHandle &operator=(const FileHandle &) = delete;\n\n    const StringView path;\n\nprotected:\n    int m_fd;\n#ifdef _WIN32\n    void mapExceptHandler(void **mapped, size_t absoluteOffset);\n    void *m_mapHandle;\n#endif\n\n#pragma mark - Basic\npublic:\n    enum Mode {\n        None = 0,\n        OverWrite = 1,\n        ReadOnly = 2,\n    };\n    bool open(Mode mode);\n    bool isOpened() const;\n    void close();\n    ssize_t size();\n    Data read(size_t size);\n    bool write(const UnsafeData &unsafeData);\n\nprotected:\n    int m_mode;\n    bool m_errorIgnorable;\n    ssize_t m_fileSize;\n\n#pragma mark - Memory map\npublic:\n    MappedData map(offset_t offset, size_t size, SharedHighWater highWater = nullptr);\n    UnsafeData mapOrReadAllData();\n\nprotected:\n    static const size_t &memoryPageSize();\n\n#pragma mark - Error\npublic:\n    void markErrorAsIgnorable(bool flag = true);\n\nprotected:\n    //    void markAsMisuse(const char *message);\n    void setThreadedError(const UnsafeStringView &message = \"\");\n};\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/common/base/FileManager.cpp",
    "content": "//\n// Created by sanhuazhang on 2018/05/19\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"FileManager.hpp\"\n#include \"Assertion.hpp\"\n#include \"CoreConst.h\"\n#include \"Notifier.hpp\"\n#include \"Path.hpp\"\n#include \"StringView.hpp\"\n#include \"UnsafeData.hpp\"\n#include <cstring>\n#include <errno.h>\n#include <fcntl.h>\n#include <sys/stat.h>\n#ifndef _WIN32\n#include <dirent.h>\n#else\n#include <direct.h>\n#include <windows.h>\n#endif\n#include \"CrossPlatform.h\"\n\n#ifndef O_BINARY\n#define O_BINARY 0\n#endif\n\nnamespace WCDB {\n\n#pragma mark - Basic\nOptional<std::pair<bool, bool>> FileManager::itemExists(const UnsafeStringView &path)\n{\n    StatType s;\n    if (StatFunc(GetPathString(path), &s) == 0) {\n        if ((s.st_mode & S_IFMT) == S_IFDIR) {\n            return std::make_pair(true, true);\n        } else {\n            return std::make_pair(true, false);\n        }\n    } else if (errno == ENOENT) {\n        return std::make_pair(false, false);\n    }\n    setThreadedError(path);\n    return NullOpt;\n}\n\nOptional<size_t> FileManager::getFileSize(const UnsafeStringView &file)\n{\n    StatType temp;\n    if (StatFunc(GetPathString(file), &temp) == 0) {\n        return (size_t) temp.st_size;\n    } else if (errno == ENOENT) {\n        return 0;\n    }\n    setThreadedError(file);\n    return NullOpt;\n}\n\nOptional<size_t> FileManager::getDirectorySize(const UnsafeStringView &directory)\n{\n    Optional<size_t> totalSize = 0;\n    if (!enumerateDirectory(\n        directory, [&totalSize](const UnsafeStringView &dir, const UnsafeStringView &subpath, bool isDirectory) {\n            StringView path = Path::addComponent(dir, subpath);\n            auto size = isDirectory ? getDirectorySize(path) : getFileSize(path);\n            if (!size.succeed()) {\n                totalSize = NullOpt;\n                return false;\n            }\n            totalSize.value() += size.value();\n            return true;\n        })) {\n        totalSize = NullOpt;\n    };\n    return totalSize;\n}\n\nbool FileManager::enumerateDirectory(\nconst UnsafeStringView &directory,\nconst std::function<bool(const UnsafeStringView &, const UnsafeStringView &, bool)> &enumeration)\n{\n#ifndef _WIN32\n    DIR *dir = opendir(GetPathString(directory));\n    if (dir == NULL) {\n        if (errno == ENOENT) {\n            return true;\n        }\n        setThreadedError(directory);\n        return false;\n    }\n\n    struct dirent *entry;\n    while ((entry = readdir(dir)) != NULL) {\n        if (strcmp(entry->d_name, \".\") != 0 && strcmp(entry->d_name, \"..\") != 0) {\n            if (!enumeration(directory, entry->d_name, entry->d_type == DT_DIR)) {\n                break;\n            }\n        }\n    }\n    closedir(dir);\n#else\n    StringView searchDir = Path::addComponent(directory, \"*.*\");\n    uint32_t status = 0;\n    WIN32_FIND_DATAW findFileData;\n    HANDLE findHandle = FindFirstFileW(GetPathString(searchDir), &findFileData);\n    if (findHandle == INVALID_HANDLE_VALUE) {\n        if (GetLastError() == ERROR_PATH_NOT_FOUND) {\n            return true;\n        }\n        setThreadedWinError(directory);\n        return false;\n    }\n    bool isBreak = false;\n    do {\n        StringView subFileName = StringView::createFromWString(findFileData.cFileName);\n        if (strcmp(subFileName.data(), \".\") != 0 && strcmp(subFileName.data(), \"..\") != 0) {\n            if (!enumeration(directory,\n                             subFileName,\n                             (findFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0)) {\n                isBreak = true;\n                break;\n            }\n        }\n    } while (FindNextFileW(findHandle, &findFileData) != 0);\n    if (!isBreak && GetLastError() != ERROR_NO_MORE_FILES) {\n        setThreadedWinError(directory);\n        bool ret = FindClose(findHandle);\n        WCTAssert(ret);\n        return false;\n    }\n    bool ret = FindClose(findHandle);\n    WCTAssert(ret);\n#endif\n\n    return true;\n}\n#if !defined(__OHOS__) && !defined(__ANDROID__)\nbool FileManager::createFileHardLink(const UnsafeStringView &from, const UnsafeStringView &to)\n{\n#ifndef _WIN32\n    if (link(GetPathString(from), GetPathString(to)) == 0) {\n        return true;\n    }\n    setThreadedError(to);\n    return false;\n#else\n    if (CreateHardLinkW(GetPathString(to), GetPathString(from), NULL)) {\n        return true;\n    }\n    if (CopyFileW(GetPathString(from), GetPathString(to), TRUE)) {\n        return true;\n    }\n    setThreadedWinError(to);\n    return false;\n#endif\n}\n\nbool FileManager::removeFileHardLink(const UnsafeStringView &path)\n{\n    if (wcdb_unlink(GetPathString(path)) == 0 || errno == ENOENT) {\n        return true;\n    }\n    setThreadedError(path);\n    return false;\n}\n#endif\n\nbool FileManager::removeFile(const UnsafeStringView &file)\n{\n    if (wcdb_remove(GetPathString(file)) == 0 || errno == ENOENT) {\n        return true;\n    }\n    setThreadedError(file);\n    return false;\n}\n\nbool FileManager::removeDirectory(const UnsafeStringView &directory)\n{\n#ifndef _WIN32\n    DIR *dir = opendir(GetPathString(directory));\n    if (dir == NULL) {\n        if (errno == ENOENT) {\n            return true;\n        }\n        setThreadedError(directory);\n        return false;\n    }\n\n    StringView path;\n    struct dirent *entry;\n    bool result;\n    while ((entry = readdir(dir)) != NULL) {\n        if (strcmp(entry->d_name, \".\") && strcmp(entry->d_name, \"..\")) {\n            path = Path::addComponent(directory, entry->d_name);\n            if (entry->d_type == DT_DIR) {\n                result = removeDirectory(path);\n            } else {\n                result = removeFile(path);\n            }\n            if (!result) {\n                setThreadedError(path);\n                return false;\n            }\n        }\n    }\n    closedir(dir);\n\n    if (wcdb_remove(GetPathString(directory)) != 0) {\n        setThreadedError(directory);\n        return false;\n    }\n    return true;\n#else\n    StringView searchDir = Path::addComponent(directory, \"*.*\");\n    uint32_t status = 0;\n    WIN32_FIND_DATAW findFileData;\n    HANDLE findHandle = FindFirstFileW(GetPathString(searchDir), &findFileData);\n    if (findHandle == INVALID_HANDLE_VALUE) {\n        if (GetLastError() == ERROR_PATH_NOT_FOUND) {\n            return true;\n        }\n        setThreadedWinError(directory);\n        return false;\n    }\n    bool result;\n    do {\n        StringView subFileName = StringView::createFromWString(findFileData.cFileName);\n        if (strcmp(subFileName.data(), \".\") != 0 && strcmp(subFileName.data(), \"..\") != 0) {\n            StringView currentPath = Path::addComponent(directory, subFileName);\n            if ((findFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0) {\n                result = removeDirectory(currentPath);\n            } else {\n                result = removeFile(currentPath);\n            }\n            if (!result) {\n                setThreadedWinError(directory);\n                bool ret = FindClose(findHandle);\n                WCTAssert(ret);\n                return false;\n            }\n        }\n    } while (FindNextFileW(findHandle, &findFileData) != 0);\n    if (GetLastError() != ERROR_NO_MORE_FILES) {\n        setThreadedWinError(directory);\n        bool ret = FindClose(findHandle);\n        WCTAssert(ret);\n        return false;\n    }\n    bool ret = FindClose(findHandle);\n    WCTAssert(ret);\n    if (!RemoveDirectoryW(GetPathString(directory))) {\n        setThreadedWinError(directory);\n        return false;\n    }\n    return true;\n#endif\n}\n\nbool FileManager::createDirectory(const UnsafeStringView &path)\n{\n    if (wcdb_mkdir(GetPathString(path), DirFullAccess) == 0) {\n        return true;\n    }\n    if (errno == EEXIST) {\n        return true;\n    }\n    setThreadedError(path);\n    return false;\n}\n\nOptional<Time> FileManager::getFileModifiedTime(const UnsafeStringView &path)\n{\n    StatType result;\n    if (StatFunc(GetPathString(path), &result) == 0) {\n        return Time(result.st_mtimespec);\n    }\n    setThreadedError(path);\n    return NullOpt;\n}\n\nOptional<uint32_t> FileManager::getFileIdentifier(const UnsafeStringView &path)\n{\n#ifndef _WIN32\n    StatType result;\n    if (StatFunc(GetPathString(path), &result) == 0) {\n        constexpr int size = sizeof(result.st_dev) + sizeof(result.st_ino);\n        unsigned char buffer[size];\n        memcpy(buffer, &result.st_dev, sizeof(result.st_dev));\n        memcpy(buffer + sizeof(result.st_dev), &result.st_ino, sizeof(result.st_ino));\n        return UnsafeData(buffer, size).hash();\n    }\n    return NullOpt;\n#else\n    HANDLE hFile = CreateFileW(GetPathString(path),\n                               GENERIC_READ,\n                               FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,\n                               NULL,\n                               OPEN_EXISTING,\n                               FILE_ATTRIBUTE_NORMAL,\n                               NULL);\n    if (hFile == INVALID_HANDLE_VALUE) {\n        setThreadedWinError(path);\n        return NullOpt;\n    }\n    BY_HANDLE_FILE_INFORMATION fileInfo;\n    if (GetFileInformationByHandle(hFile, &fileInfo)) {\n        CloseHandle(hFile);\n\n        constexpr size_t size = sizeof(fileInfo.nFileIndexHigh)\n                                + sizeof(fileInfo.nFileIndexLow)\n                                + sizeof(fileInfo.dwVolumeSerialNumber);\n        unsigned char buffer[size];\n        memcpy(buffer, &fileInfo.nFileIndexHigh, sizeof(fileInfo.nFileIndexHigh));\n        memcpy(buffer + sizeof(fileInfo.nFileIndexHigh),\n               &fileInfo.nFileIndexLow,\n               sizeof(fileInfo.nFileIndexLow));\n        memcpy(buffer + sizeof(fileInfo.nFileIndexHigh) + sizeof(fileInfo.nFileIndexLow),\n               &fileInfo.dwVolumeSerialNumber,\n               sizeof(fileInfo.dwVolumeSerialNumber));\n        return UnsafeData(buffer, size).hash();\n    }\n\n    setThreadedWinError(path);\n    CloseHandle(hFile);\n    return NullOpt;\n#endif\n}\n\nbool FileManager::createFile(const UnsafeStringView &path)\n{\n    int fd = wcdb_open(GetPathString(path), O_CREAT | O_RDWR | O_BINARY, FileFullAccess);\n    if (fd != -1) {\n        close(fd);\n        return true;\n    }\n    setThreadedError(path);\n    return false;\n}\n\n#pragma mark - Combination\nOptional<size_t> FileManager::getItemSize(const UnsafeStringView &path)\n{\n    StatType temp;\n    if (StatFunc(GetPathString(path), &temp) == 0) {\n        if ((temp.st_mode & S_IFMT) == S_IFDIR) {\n            return getDirectorySize(path);\n        }\n        return getFileSize(path);\n    } else if (errno == ENOENT) {\n        return 0;\n    }\n    setThreadedError(path);\n    return NullOpt;\n}\n\nOptional<bool> FileManager::fileExists(const UnsafeStringView &file)\n{\n    auto result = itemExists(file);\n    if (result.succeed()) {\n        bool exists, isDirectory;\n        std::tie(exists, isDirectory) = result.value();\n        return exists && !isDirectory;\n    }\n    return NullOpt;\n}\n\nOptional<bool> FileManager::fileExistsAndNotEmpty(const UnsafeStringView &file)\n{\n    StatType s;\n    if (StatFunc(GetPathString(file), &s) == 0) {\n        if ((s.st_mode & S_IFMT) == S_IFDIR) {\n            return false;\n        } else {\n            return s.st_size > 0;\n        }\n    } else if (errno == ENOENT) {\n        return false;\n    }\n    setThreadedError(file);\n    return NullOpt;\n}\n\nOptional<bool> FileManager::directoryExists(const UnsafeStringView &directory)\n{\n    auto result = itemExists(directory);\n    if (result.succeed()) {\n        bool exists, isDirectory;\n        std::tie(exists, isDirectory) = result.value();\n        return exists && isDirectory;\n    }\n    return NullOpt;\n}\n\nOptional<size_t> FileManager::getItemsSize(const std::list<StringView> &paths)\n{\n    size_t size = 0;\n    Optional<size_t> temp;\n    for (const auto &path : paths) {\n        temp = getItemSize(path);\n        if (!temp.succeed()) {\n            return NullOpt;\n        }\n        size += temp.value();\n    }\n    return size;\n}\n\nbool FileManager::removeItem(const UnsafeStringView &path)\n{\n    StatType temp;\n    if (StatFunc(GetPathString(path), &temp) == 0) {\n        if ((temp.st_mode & S_IFMT) == S_IFDIR) {\n            return removeDirectory(path);\n        }\n        return removeFile(path);\n    } else if (errno == ENOENT) {\n        return true;\n    }\n    setThreadedError(path);\n    return false;\n}\n\nbool FileManager::removeItems(const std::list<StringView> &items)\n{\n    for (const auto &item : items) {\n        if (!removeItem(item)) {\n            return false;\n        }\n    }\n    return true;\n}\n\nbool FileManager::moveItems(const std::list<StringView> &paths, const UnsafeStringView &directory)\n{\n    if (!createDirectoryWithIntermediateDirectories(directory)) {\n        return false;\n    }\n    std::list<std::pair<StringView, StringView>> pairedPaths;\n    for (const auto &path : paths) {\n        const StringView fileName = Path::getFileName(path);\n        StringView newPath = Path::addComponent(directory, fileName);\n        pairedPaths.push_back({ path, newPath });\n    }\n    return moveItems(pairedPaths);\n}\n\nbool FileManager::moveItems(const std::list<std::pair<StringView, StringView>> &pairedPaths)\n{\n    bool result = true;\n    std::list<StringView> recovers;\n    for (const auto &pairedPath : pairedPaths) {\n        auto optionalExists = itemExists(pairedPath.first);\n        if (!optionalExists.succeed()) {\n            break;\n        }\n        bool exists, isDirectory;\n        std::tie(exists, isDirectory) = optionalExists.value();\n        if (exists) {\n            const StringView &newPath = pairedPath.second;\n            if (!removeItem(newPath)) {\n                result = false;\n                break;\n            }\n            if (isDirectory) {\n#if defined(__ANDROID__) || defined(__OHOS__)\n                if (::rename(pairedPath.first.data(), newPath.data()) != 0) {\n#else\n                if (!createDirectoryHardLink(pairedPath.first, newPath)) {\n#endif\n                    result = false;\n                    break;\n                }\n            } else {\n#if defined(__ANDROID__) || defined(__OHOS__)\n                if (::rename(pairedPath.first.data(), newPath.data()) != 0) {\n#else\n                if (!createFileHardLink(pairedPath.first, newPath)) {\n#endif\n                    result = false;\n                    break;\n                }\n            }\n            recovers.push_back(newPath);\n        }\n    }\n    if (result) {\n        for (const auto &pairedPath : pairedPaths) {\n            if (!removeItem(pairedPath.first)) {\n                return false;\n            }\n        }\n    } else {\n        for (const auto &recover : recovers) {\n            removeItem(recover.data());\n        }\n    }\n    return result;\n}\n\nbool FileManager::createDirectoryWithIntermediateDirectories(const UnsafeStringView &directory)\n{\n    if (directory.length() == 0) {\n        Error error(Error::Code::IOError, Error::Level::Error, \"Empty directory\");\n        Notifier::shared().notify(error);\n        SharedThreadedErrorProne::setThreadedError(std::move(error));\n        return false;\n    }\n    auto exists = directoryExists(directory);\n    if (!exists.succeed()) {\n        return false;\n    }\n    if (!exists.value()) {\n        return createDirectoryWithIntermediateDirectories(Path::getDirectory(directory))\n               && createDirectory(directory);\n    }\n    return true;\n}\n\nbool FileManager::setFileProtectionCompleteUntilFirstUserAuthenticationIfNeeded(const UnsafeStringView &path)\n{\n    if (!path.empty()) {\n        auto optionalFileProtection = getFileProtection(path);\n        if (!optionalFileProtection.succeed()) {\n            return false;\n        }\n        FileProtection fileProtection = optionalFileProtection.value();\n        if (fileProtection != FileProtection::None\n            && fileProtection != FileProtection::CompleteUntilFirstUserAuthentication) {\n            return setFileProtection(path, FileProtection::CompleteUntilFirstUserAuthentication);\n        }\n    }\n    return true;\n}\n\n#if !defined(__OHOS__) && !defined(__ANDROID__)\nbool FileManager::createDirectoryHardLink(const UnsafeStringView &from,\n                                          const UnsafeStringView &to)\n{\n    if (!createDirectory(to)) {\n        return false;\n    }\n    bool succeed = true;\n    if (enumerateDirectory(from,\n                           [&succeed, &to](const UnsafeStringView &directory,\n                                           const UnsafeStringView &subpath,\n                                           bool isDirectory) -> bool {\n                               StringView oldPath = Path::addComponent(directory, subpath);\n                               StringView newPath = Path::addComponent(to, subpath);\n                               if (isDirectory) {\n                                   succeed = createDirectoryHardLink(oldPath, newPath);\n                               } else {\n                                   succeed = createFileHardLink(oldPath, newPath);\n                               }\n                               return succeed;\n                           })\n        && succeed) {\n        return true;\n    }\n    removeItem(to);\n    return false;\n}\n#endif\n\n#pragma mark - Error\nvoid FileManager::setThreadedError(const UnsafeStringView &path)\n{\n    Error error;\n    error.level = Error::Level::Error;\n    error.setSystemCode(errno, Error::Code::IOError);\n    error.infos.insert_or_assign(ErrorStringKeyAssociatePath, path);\n    Notifier::shared().notify(error);\n    SharedThreadedErrorProne::setThreadedError(std::move(error));\n}\n\nvoid FileManager::setThreadedError(Error::Code codeIfUnresolved)\n{\n    Error error;\n    error.level = Error::Level::Error;\n    error.setSystemCode(errno, codeIfUnresolved);\n    Notifier::shared().notify(error);\n    SharedThreadedErrorProne::setThreadedError(std::move(error));\n}\n\n#ifdef _WIN32\nvoid FileManager::setThreadedWinError(const UnsafeStringView &path)\n{\n    Error error;\n    error.level = Error::Level::Error;\n    error.setWinSystemCode(GetLastError(), Error::Code::IOError);\n    error.infos.insert_or_assign(ErrorStringKeyAssociatePath, path);\n    Notifier::shared().notify(error);\n    SharedThreadedErrorProne::setThreadedError(std::move(error));\n}\n\nvoid FileManager::setThreadedWinError(Error::Code codeIfUnresolved)\n{\n    Error error;\n    error.level = Error::Level::Error;\n    error.setWinSystemCode(GetLastError(), codeIfUnresolved);\n    Notifier::shared().notify(error);\n    SharedThreadedErrorProne::setThreadedError(std::move(error));\n}\n#endif\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/common/base/FileManager.hpp",
    "content": "//\n// Created by sanhuazhang on 2018/05/19\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"SharedThreadedErrorProne.hpp\"\n#include \"StringView.hpp\"\n#include \"Time.hpp\"\n#include \"WCDBError.hpp\"\n#include \"WCDBOptional.hpp\"\n#include <functional>\n#include <list>\n\nnamespace WCDB {\n\nenum class FileProtection {\n    None = 0,\n    Complete,\n    CompleteUnlessOpen,\n    CompleteUntilFirstUserAuthentication,\n};\n\nclass FileManager final : public SharedThreadedErrorProne {\npublic:\n    FileManager() = delete;\n    FileManager(const FileManager &) = delete;\n    FileManager &operator=(const FileManager &) = delete;\n\n#pragma mark - Basic\npublic:\n    // exists, directory?\n    static Optional<std::pair<bool, bool>> itemExists(const UnsafeStringView &path);\n    static Optional<size_t> getDirectorySize(const UnsafeStringView &directory);\n    static Optional<size_t> getFileSize(const UnsafeStringView &file);\n#if !defined(__OHOS__) && !defined(__ANDROID__)\n    static bool\n    createFileHardLink(const UnsafeStringView &from, const UnsafeStringView &to);\n    static bool removeFileHardLink(const UnsafeStringView &path);\n#endif\n    static bool createDirectory(const UnsafeStringView &path);\n    static Optional<Time> getFileModifiedTime(const UnsafeStringView &path);\n    static Optional<uint32_t> getFileIdentifier(const UnsafeStringView &path);\n    static bool createFile(const UnsafeStringView &path);\n\n    static bool enumerateDirectory(\n    const UnsafeStringView &directory,\n    const std::function<bool /* stop */ (const UnsafeStringView &directory, const UnsafeStringView &subpath, bool isDirectory)>\n    &enumeration);\n\n    static bool setFileProtection(const UnsafeStringView &path, FileProtection fileProtection);\n    static StringView getTemporaryDirectory();\n    static Optional<FileProtection> getFileProtection(const UnsafeStringView &path);\n\nprotected:\n    static bool removeFile(const UnsafeStringView &file);\n    static bool removeDirectory(const UnsafeStringView &directory);\n\n#pragma mark - Combination\npublic:\n    static Optional<bool> fileExists(const UnsafeStringView &file);\n    static Optional<bool> fileExistsAndNotEmpty(const UnsafeStringView &file);\n    static Optional<bool> directoryExists(const UnsafeStringView &directory);\n    static Optional<size_t> getItemSize(const UnsafeStringView &path);\n    static Optional<size_t> getItemsSize(const std::list<StringView> &paths);\n    static bool removeItem(const UnsafeStringView &path);\n    static bool removeItems(const std::list<StringView> &paths);\n    static bool\n    moveItems(const std::list<StringView> &paths, const UnsafeStringView &directory);\n    static bool moveItems(const std::list<std::pair<StringView, StringView>> &pairedPaths);\n    static bool\n    createDirectoryWithIntermediateDirectories(const UnsafeStringView &directory);\n    static bool\n    setFileProtectionCompleteUntilFirstUserAuthenticationIfNeeded(const UnsafeStringView &path);\n#if !defined(__OHOS__) && !defined(__ANDROID__)\n    static bool\n    createDirectoryHardLink(const UnsafeStringView &from, const UnsafeStringView &to);\n#endif\n\n#pragma mark - Error\nprotected:\n    static void setThreadedError(const UnsafeStringView &path);\n    static void setThreadedError(Error::Code codeIfUnresolved);\n#ifdef _WIN32\n    static void setThreadedWinError(const UnsafeStringView &path);\n    static void setThreadedWinError(Error::Code codeIfUnresolved);\n#endif\n};\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/common/base/FunctionContainer.cpp",
    "content": "//\n// Created by qiuwenchen on 2023/11/15.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"FunctionContainer.hpp\"\n#include <stdlib.h>\n\nnamespace WCDB {\n\nFunctionContainerBase::FunctionContainerBase()\n: m_functionSlots(nullptr), m_funcDeconstructors(nullptr)\n{\n}\n\nFunctionContainerBase::FunctionContainerBase(FunctionContainerBase&& other)\n: m_functionSlots(other.m_functionSlots), m_funcDeconstructors(other.m_funcDeconstructors)\n{\n    other.m_functionSlots = nullptr;\n    other.m_funcDeconstructors = nullptr;\n}\n\nFunctionContainerBase& FunctionContainerBase::operator=(FunctionContainerBase&& other)\n{\n    clearFunctionSlot();\n    m_functionSlots = other.m_functionSlots;\n    m_funcDeconstructors = other.m_funcDeconstructors;\n    other.m_functionSlots = nullptr;\n    other.m_funcDeconstructors = nullptr;\n    return *this;\n}\n\nFunctionContainerBase::~FunctionContainerBase()\n{\n    clearFunctionSlot();\n}\n\nvoid FunctionContainerBase::initFunctionSlot(size_t slotCount)\n{\n    WCTAssert(m_functionSlots == nullptr);\n    m_functionSlots = (Slot*) calloc(slotCount, sizeof(Slot) + sizeof(Destructor*));\n    m_funcDeconstructors = (Destructor*) (m_functionSlots + slotCount);\n}\n\nsize_t FunctionContainerBase::getSlotCount() const\n{\n    return ((int64_t) m_funcDeconstructors - (int64_t) m_functionSlots) / sizeof(Slot);\n}\n\nvoid FunctionContainerBase::clearFunctionSlot()\n{\n    if (m_functionSlots == nullptr) {\n        return;\n    }\n    for (int i = 0; i < getSlotCount(); i++) {\n        if (m_funcDeconstructors[i] == nullptr) {\n            continue;\n        }\n        m_funcDeconstructors[i](m_functionSlots + i);\n    }\n    free(m_functionSlots);\n    m_functionSlots = nullptr;\n}\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/base/FunctionContainer.hpp",
    "content": "//\n// Created by qiuwenchen on 2023/11/14.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"Assertion.hpp\"\n#include \"Macro.h\"\n#include \"MemberPointer.hpp\"\n#include <functional>\n#include <string>\n\nnamespace WCDB {\n\nclass FunctionContainerBase {\npublic:\n    typedef std::function<void()> Slot;\n    typedef void (*Destructor)(Slot*);\n\n    FunctionContainerBase();\n    FunctionContainerBase(FunctionContainerBase&& other);\n    FunctionContainerBase& operator=(FunctionContainerBase&&);\n    FunctionContainerBase(const FunctionContainerBase& other) = delete;\n    FunctionContainerBase& operator=(const FunctionContainerBase&) = delete;\n    virtual ~FunctionContainerBase();\n\nprotected:\n    template<typename FuncType>\n    static void functionDestructor(Slot* func)\n    {\n        std::function<FuncType>* typedFunc = (std::function<FuncType>*) func;\n        typedef std::function<FuncType> STDFunctionType;\n        typedFunc->~STDFunctionType();\n    }\n\n    void initFunctionSlot(size_t slotCount);\n    size_t getSlotCount() const;\n    void clearFunctionSlot();\n\n    Slot* m_functionSlots;\n    Destructor* m_funcDeconstructors;\n};\n\ntemplate<typename Type>\nclass FunctionContainer : public FunctionContainerBase {\npublic:\n    typedef Type SlotType;\n\n    template<typename FuncType>\n    void registerFunction(SlotType slot, const std::function<FuncType>& func)\n    {\n        static_assert(sizeof(std::function<FuncType>) == sizeof(Slot),\n                      \"Unsupported function type!\");\n        int slotNum = (int) slot;\n        if (m_funcDeconstructors[slotNum] != nullptr) {\n            m_funcDeconstructors[slotNum](m_functionSlots + slotNum);\n        }\n        new ((void*) (m_functionSlots + slotNum)) std::function<FuncType>(func);\n        m_funcDeconstructors[slotNum] = functionDestructor<FuncType>;\n    }\n\n    template<typename FuncType, typename ObjectType>\n    const std::function<FuncType>& getFunction(SlotType slot, FuncType ObjectType::*)\n    {\n        static_assert(std::is_member_function_pointer<FuncType ObjectType::*>::value,\n                      \"It must be a member function!\");\n        WCTAssert((size_t) slot < getSlotCount()\n                  && m_funcDeconstructors[(int) slot] != nullptr);\n        return *(std::function<FuncType>*) (m_functionSlots + (int) slot);\n    }\n};\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/base/HighWater.cpp",
    "content": "//\n// Created by sanhuazhang on 2018/08/15\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"HighWater.hpp\"\n\nnamespace WCDB {\n\nAbstractHighWater::AbstractHighWater(ssize_t init)\n: m_current(init), m_highWater(init)\n{\n}\n\nAbstractHighWater::~AbstractHighWater() = default;\n\nvoid AbstractHighWater::increase(size_t size)\n{\n    m_current += size;\n    if (m_current > m_highWater) {\n        m_highWater = m_current;\n    }\n}\n\nvoid AbstractHighWater::decrease(size_t size)\n{\n    m_current -= size;\n}\n\nssize_t AbstractHighWater::getCurrent() const\n{\n    return m_current;\n}\n\nssize_t AbstractHighWater::getHighWater() const\n{\n    return m_highWater;\n}\n\nShareableHighWater::~ShareableHighWater() = default;\n\nvoid ShareableHighWater::increase(size_t size)\n{\n    std::lock_guard<std::mutex> lockGuard(m_lock);\n    AbstractHighWater::increase(size);\n}\n\nvoid ShareableHighWater::decrease(size_t size)\n{\n    std::lock_guard<std::mutex> lockGuard(m_lock);\n    AbstractHighWater::decrease(size);\n}\n\nssize_t ShareableHighWater::getCurrent() const\n{\n    std::lock_guard<std::mutex> lockGuard(m_lock);\n    return AbstractHighWater::getCurrent();\n}\n\nssize_t ShareableHighWater::getHighWater() const\n{\n    std::lock_guard<std::mutex> lockGuard(m_lock);\n    return AbstractHighWater::getHighWater();\n}\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/base/HighWater.hpp",
    "content": "//\n// Created by sanhuazhang on 2018/08/15\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"CrossPlatform.h\"\n#include \"Lock.hpp\"\n\nnamespace WCDB {\n\nclass AbstractHighWater {\npublic:\n    AbstractHighWater(ssize_t init = 0);\n    virtual ~AbstractHighWater() = 0;\n\n    virtual void increase(size_t size);\n    virtual void decrease(size_t size);\n    virtual ssize_t getCurrent() const;\n    virtual ssize_t getHighWater() const;\n\nprotected:\n    ssize_t m_current;\n    ssize_t m_highWater;\n};\n\nclass HighWater final : public AbstractHighWater {\npublic:\n    using AbstractHighWater::AbstractHighWater;\n    ~HighWater() override;\n};\n\nclass ShareableHighWater final : public AbstractHighWater {\npublic:\n    using AbstractHighWater::AbstractHighWater;\n    ~ShareableHighWater() override;\n\n    void increase(size_t size) override final;\n    void decrease(size_t size) override final;\n    ssize_t getCurrent() const override final;\n    ssize_t getHighWater() const override final;\n\nprotected:\n    mutable std::mutex m_lock;\n};\n\ntypedef std::shared_ptr<ShareableHighWater> SharedHighWater;\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/base/LRUCache.hpp",
    "content": "//\n// Created by sanhuazhang on 2018/07/23\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"Assertion.hpp\"\n#include <list>\n#include <unordered_map>\n\nnamespace WCDB {\n\ntemplate<typename Key, typename Value>\nclass LRUCache {\nprotected:\n    using KeyValue = typename std::pair<Key, Value>;\n    using List = std::list<KeyValue>;\n    using KeyValueIterator = typename List::iterator;\n    using Map = std::map<Key, KeyValueIterator>;\n    using MapIterator = typename Map::iterator;\n\npublic:\n    LRUCache() = default;\n    virtual ~LRUCache() = default;\n\n    void put(const Key& key, const Value& value)\n    {\n        auto it = m_map.find(key);\n        m_list.push_front(KeyValue(key, value));\n        if (it != m_map.end()) {\n            m_list.erase(it->second);\n            m_map.erase(it);\n        }\n        m_map[key] = m_list.begin();\n        if (shouldPurge()) {\n            purge();\n        }\n    }\n\n    void purge(size_t count = 1)\n    {\n        for (size_t i = 0; i < count && !m_list.empty(); ++i) {\n            auto last = m_list.end();\n            --last;\n            willPurge(last->first, last->second);\n            m_map.erase(last->first);\n            m_list.pop_back();\n        }\n    }\n\n    const Value& get(const Key& key)\n    {\n        auto it = m_map.find(key);\n        WCTAssert(exists(key));\n        retain(it);\n        return it->second->second;\n    }\n\n    bool exists(const Key& key) const { return m_map.find(key) != m_map.end(); }\n\n    size_t size() const { return m_map.size(); }\n\n    bool empty() const { return m_map.empty(); }\n\nprotected:\n    void retain(const MapIterator& it)\n    {\n        m_list.splice(m_list.begin(), m_list, it->second);\n    }\n\n    virtual bool shouldPurge() const = 0;\n    virtual void willPurge(const Key& key, const Value& value)\n    {\n        WCDB_UNUSED(key);\n        WCDB_UNUSED(value);\n    }\n\n    List m_list;\n    Map m_map;\n};\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/base/Lock.cpp",
    "content": "//\n// Created by sanhuazhang on 2018/09/29\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"Lock.hpp\"\n#include \"Assertion.hpp\"\n#include \"CrossPlatform.h\"\n#include <condition_variable>\n\nnamespace WCDB {\n\n#pragma mark - Conditional\nbool Conditional::wait_for(std::unique_lock<std::mutex> &lockGuard, double seconds)\n{\n    WCTAssert(lockGuard.owns_lock());\n    bool timeout = false;\n    if (seconds > 0) {\n        timeout = std::condition_variable::wait_for(\n                  lockGuard, std::chrono::nanoseconds((long long) (seconds * 1E9)))\n                  == std::cv_status::timeout;\n    }\n    return !timeout;\n}\n\n#ifdef __APPLE__\nvoid Conditional::notify(const Thread &thread)\n{\n    pthread_cond_signal_thread_np(native_handle(), thread.m_pthreadId);\n}\n#endif\n\n#pragma mark - Shared Lock\nSharedLock::SharedLock()\n: m_readers(0), m_writers(0), m_pendingReaders(0), m_threadedReaders(0)\n{\n}\n\nSharedLock::~SharedLock()\n{\n    WCTRemedialAssert(m_writers == 0 && m_pendingWriters.size() == 0, \"Unpaired lock\", ;);\n    WCTRemedialAssert(m_readers == 0 && m_pendingReaders == 0, \"Unpaired shared lock\", ;);\n}\n\nvoid SharedLock::lockShared()\n{\n    std::unique_lock<std::mutex> lockGuard(m_lock);\n    if (m_writers > 0 ?\n        !m_locking.isCurrentThread() :\n        (m_pendingWriters.size() > 0 && m_threadedReaders.getOrCreate() == 0)) {\n        // If it is locked but not current thread, it should wait for the write lock.\n        // If it is not locked but there is someone pending to lock and current thread is not already shared locked, it should wait for the pending lock to avoid the pending lock starve.\n        ++m_pendingReaders;\n        do {\n            m_conditionalReaders.wait(lockGuard);\n        } while (m_writers > 0 || m_pendingWriters.size() > 0);\n        --m_pendingReaders;\n    }\n    // it's already locked by current thread\n    // or it's already shared locked by current thread\n    // or it's not locked\n    WCTAssert(m_locking.isCurrentThread() || m_threadedReaders.getOrCreate() > 0\n              || m_writers == 0);\n    ++m_readers;\n    ++m_threadedReaders.getOrCreate();\n}\n\nvoid SharedLock::unlockShared()\n{\n    int &threadedReader = m_threadedReaders.getOrCreate();\n    WCTRemedialAssert(threadedReader > 0, \"Unpaired unlock shared.\", return;);\n    WCTAssert(threadedReader > 0);\n\n    std::unique_lock<std::mutex> lockGuard(m_lock);\n    WCTAssert(m_readers > 0);\n    --threadedReader;\n    --m_readers;\n    if (m_readers == 0) {\n        WCTAssert(m_threadedReaders.getOrCreate() == 0);\n        if (m_writers == 0 && m_pendingWriters.size() > 0) {\n#ifdef __APPLE__\n            m_conditionalWriters.notify(m_pendingWriters.front());\n#else\n            m_conditionalWriters.notify_all();\n#endif\n        }\n    }\n}\n\nvoid SharedLock::lock()\n{\n    WCTRemedialAssert(\n    m_threadedReaders.getOrCreate() == 0, \"Upgrade lock is not supported.\", return;);\n\n    Thread current = Thread::current();\n    std::unique_lock<std::mutex> lockGuard(m_lock);\n    if (!m_locking.equal(current)) {\n        m_pendingWriters.push_back(current);\n        while (m_readers > 0 || m_writers > 0 || !m_pendingWriters.front().equal(current)) {\n            m_conditionalWriters.wait(lockGuard);\n        }\n        WCTAssert(m_pendingWriters.front().isCurrentThread());\n        m_pendingWriters.pop_front();\n    }\n    // it's already locked by current thread\n    // or it's not locked and it's not shared locked\n    WCTAssert(m_locking.isCurrentThread() || (m_writers == 0 && m_readers == 0));\n    ++m_writers;\n    m_locking = Thread::current();\n}\n\nbool SharedLock::isLocked()\n{\n    return m_writers > 0;\n}\n\nvoid SharedLock::unlock()\n{\n    WCTRemedialAssert(\n    m_threadedReaders.getOrCreate() == 0, \"Downgrade lock is not supported.\", return;);\n\n    std::unique_lock<std::mutex> lockGuard(m_lock);\n    WCTRemedialAssert(m_locking.isCurrentThread(), \"Unpaired unlock.\", return;);\n    WCTAssert(m_readers == 0);\n    WCTAssert(m_writers > 0);\n    if (--m_writers == 0) {\n        m_locking = nullptr;\n        // write lock first\n        if (m_pendingWriters.size() > 0) {\n#ifdef __APPLE__\n            m_conditionalWriters.notify(m_pendingWriters.front());\n#else\n            m_conditionalWriters.notify_all();\n#endif\n        } else if (m_pendingReaders > 0) {\n            m_conditionalReaders.notify_all();\n        }\n    }\n}\n\nSharedLock::Level SharedLock::level() const\n{\n    std::unique_lock<std::mutex> lockGuard(m_lock);\n    if (m_locking.isCurrentThread()) {\n        return Level::Write;\n    } else if ((m_threadedReaders.getOrCreate()) > 0) {\n        return Level::Read;\n    }\n    return Level::None;\n}\n\nbool SharedLock::readSafety() const\n{\n    return level() >= SharedLock::Level::Read;\n}\n\nbool SharedLock::writeSafety() const\n{\n    return level() >= SharedLock::Level::Write;\n}\n\n#pragma mark - Lock Guard\nLockGuard::LockGuard(const std::nullptr_t &) : m_lock(nullptr)\n{\n}\n\nLockGuard::LockGuard(SharedLock &lock) : m_lock(&lock)\n{\n    m_lock->lock();\n}\n\nLockGuard::LockGuard(LockGuard &&movable) : m_lock(movable.m_lock)\n{\n    movable.m_lock = nullptr;\n}\n\nLockGuard::~LockGuard()\n{\n    if (m_lock != nullptr) {\n        m_lock->unlock();\n    }\n}\n\nbool LockGuard::valid() const\n{\n    return m_lock != nullptr;\n}\n\n#pragma mark - Shared Lock Guard\nSharedLockGuard::SharedLockGuard(SharedLockGuard &&movable)\n: m_lock(movable.m_lock)\n{\n    movable.m_lock = nullptr;\n}\n\nSharedLockGuard::SharedLockGuard(const std::nullptr_t &) : m_lock(nullptr)\n{\n}\n\nSharedLockGuard::SharedLockGuard(SharedLock &lock) : m_lock(&lock)\n{\n    m_lock->lockShared();\n}\n\nbool SharedLockGuard::valid() const\n{\n    return m_lock != nullptr;\n}\n\nSharedLockGuard::~SharedLockGuard()\n{\n    if (m_lock != nullptr) {\n        m_lock->unlockShared();\n    }\n}\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/common/base/Lock.hpp",
    "content": "//\n// Created by sanhuazhang on 2018/09/29\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"Thread.hpp\"\n#include \"ThreadLocal.hpp\"\n#include <atomic>\n#include <condition_variable>\n#include <functional>\n#include <mutex>\n#include <list>\n\nnamespace WCDB {\n\n#pragma mark - Conditional\nclass Conditional final : public std::condition_variable {\npublic:\n    // false for timeout\n    bool wait_for(std::unique_lock<std::mutex> &lockGuard, double seconds);\n#ifdef __APPLE__\n    void notify(const Thread &thread);\n#endif\n};\n\n#pragma mark - Shared Lock\n// TODO:\n// std::shared_timed_mutex is supported since iOS 10 and macOS 10.12.\n// std::shared_mutex is supported in a more recent version.\nclass SharedLock final {\npublic:\n    typedef std::function<void(void)> PendingCallback;\n    SharedLock();\n    ~SharedLock();\n\n    void lock();\n    bool isLocked();\n    void unlock();\n\n    void lockShared();\n    void unlockShared();\n\n    enum Level {\n        None = 0,\n        Read = 1,\n        Write = 2,\n    };\n    Level level() const;\n    bool readSafety() const;\n    bool writeSafety() const;\n\nprotected:\n    mutable std::mutex m_lock;\n    Conditional m_conditionalReaders;\n    Conditional m_conditionalWriters;\n    int m_readers;\n    int m_writers;\n    int m_pendingReaders;\n    std::list<Thread> m_pendingWriters;\n    Thread m_locking;\n    // mutable since it can be only modified threaded\n    mutable ThreadLocal<int> m_threadedReaders;\n};\n\n#pragma mark - Lock Guard\nclass LockGuard final {\npublic:\n    LockGuard(SharedLock &lock);\n    LockGuard(LockGuard &&movable);\n    LockGuard(const std::nullptr_t &);\n    ~LockGuard();\n\n    LockGuard() = delete;\n    LockGuard(const LockGuard &) = delete;\n    LockGuard &operator=(const LockGuard &) = delete;\n\n    bool valid() const;\n\nprotected:\n    SharedLock *m_lock;\n};\n\n#pragma mark - Shared Lock Guard\nclass SharedLockGuard final {\npublic:\n    SharedLockGuard(SharedLock &lock);\n    SharedLockGuard(SharedLockGuard &&movable);\n    SharedLockGuard(const std::nullptr_t &);\n    ~SharedLockGuard();\n\n    SharedLockGuard() = delete;\n    SharedLockGuard(const SharedLockGuard &) = delete;\n    SharedLockGuard &operator=(const SharedLockGuard &) = delete;\n\n    bool valid() const;\n\nprotected:\n    SharedLock *m_lock;\n};\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/common/base/MappedData.cpp",
    "content": "//\n// Created by sanhuazhang on 2018/07/23\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"MappedData.hpp\"\n#include \"Notifier.hpp\"\n#ifndef _WIN32\n#include <sys/mman.h>\n#else\n#include <windows.h>\n#endif\n\nnamespace WCDB {\n\nMappedData::MappedData() : UnsafeData()\n{\n}\n\nMappedData::MappedData(unsigned char* mapped, size_t size)\n: UnsafeData(mapped, size, SharedBuffer(makeSharedBuffer(mapped, size, MappedData::unmapData)))\n{\n}\n\nMappedData::MappedData(unsigned char* mapped, size_t size, SharedHighWater highWater)\n: UnsafeData(mapped, size)\n{\n    m_sharedBuffer = makeSharedBuffer(mapped, size, [highWater](SharedData& data) {\n        unmapData(data);\n        if (highWater != nullptr) {\n            highWater->decrease(data.size);\n        }\n    });\n    if (highWater != nullptr) {\n        highWater->increase(size);\n    }\n}\n\nMappedData::~MappedData() = default;\n\nvoid MappedData::unmapData(SharedData& data)\n{\n#ifndef _WIN32\n    if (munmap(data.buffer, data.size) != 0) {\n        Error error;\n        error.level = Error::Level::Warning;\n        error.setSystemCode(errno, Error::Code::IOError);\n        error.infos.insert_or_assign(\"MunmapSize\", data.size);\n        Notifier::shared().notify(error);\n        SharedThreadedErrorProne::setThreadedError(std::move(error));\n    }\n#else\n    if (!UnmapViewOfFile(data.buffer)) {\n        Error error;\n        error.level = Error::Level::Warning;\n        error.setWinSystemCode(GetLastError(), Error::Code::IOError);\n        error.infos.insert_or_assign(\"MunmapSize\", data.size);\n        Notifier::shared().notify(error);\n        SharedThreadedErrorProne::setThreadedError(std::move(error));\n    }\n#endif\n}\n\nMappedData::MappedData(const MappedData& other) : UnsafeData(other)\n{\n}\n\nMappedData::MappedData(MappedData&& other) : UnsafeData(std::move(other))\n{\n}\n\nMappedData::MappedData(const UnsafeData& data) : UnsafeData(data)\n{\n}\n\nMappedData& MappedData::operator=(const MappedData& other)\n{\n    UnsafeData::operator=(other);\n    return *this;\n}\n\nMappedData& MappedData::operator=(MappedData&& other)\n{\n    UnsafeData::operator=(std::move(other));\n    return *this;\n}\n\nMappedData MappedData::subdata(size_t size) const\n{\n    return MappedData(UnsafeData::subdata(size));\n}\n\nMappedData MappedData::subdata(offset_t offset, size_t size) const\n{\n    return MappedData(UnsafeData::subdata(offset, size));\n}\n\nconst MappedData& MappedData::null()\n{\n    static const MappedData* s_null = new MappedData;\n    return *s_null;\n}\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/base/MappedData.hpp",
    "content": "//\n// Created by sanhuazhang on 2018/07/23\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"HighWater.hpp\"\n#include \"Recyclable.hpp\"\n#include \"SharedThreadedErrorProne.hpp\"\n#include \"UnsafeData.hpp\"\n\nnamespace WCDB {\n\nclass MappedData final : public UnsafeData {\npublic:\n    MappedData();\n    MappedData(unsigned char* mapped, size_t size);\n    MappedData(unsigned char* mapped, size_t size, SharedHighWater highWater);\n    MappedData(const MappedData& other);\n    MappedData(MappedData&& other);\n    MappedData& operator=(const MappedData& other);\n    MappedData& operator=(MappedData&& other);\n    ~MappedData() override;\n\n    MappedData subdata(size_t size) const;\n    MappedData subdata(offset_t offset, size_t size) const;\n\n    static const MappedData& null();\n\nprotected:\n    MappedData(const UnsafeData& data);\n    using SharedData = UnsafeData::SharedData;\n    using SharedBuffer = UnsafeData::SharedBuffer;\n    static void unmapData(SharedData& data);\n};\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/base/MemberPointer.hpp",
    "content": "//\n// Created by qiuwenchen on 2022/8/26.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n#include <type_traits>\n\nnamespace WCDB {\n\ntemplate<class T, typename Enable = void>\nstruct IsFieldMemberPointer : std::false_type {};\n\ntemplate<class T>\nstruct IsFieldMemberPointer<T, typename std::enable_if<std::is_member_pointer<T>::value && !std::is_member_function_pointer<T>::value>::type>\n: std::true_type {};\n\ntemplate<typename T, typename O>\nvoid* castMemberPointer(T O::* memberPointer)\n{\n    union {\n        T O::* memberp;\n        void* voidp;\n    };\n    voidp = nullptr;\n    memberp = memberPointer;\n    return voidp;\n}\n\ntemplate<typename P>\nstruct getMemberType;\n\ntemplate<typename O, typename T>\nstruct getMemberType<T O::*> {\n    typedef T type;\n};\n\ntemplate<typename P>\nstruct getClassType;\n\ntemplate<typename O, typename T>\nstruct getClassType<T O::*> {\n    typedef O type;\n    typedef O* pointerType;\n};\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/common/base/Notifier.cpp",
    "content": "//\n// Created by sanhuazhang on 2018/06/07\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"Notifier.hpp\"\n#include \"Assertion.hpp\"\n\nnamespace WCDB {\n\nNotifier &Notifier::shared()\n{\n    static Notifier *s_notifier = new Notifier;\n    return *s_notifier;\n}\n\nNotifier::Notifier() = default;\n\nvoid Notifier::setNotification(int order, const UnsafeStringView &key, const Callback &callback)\n{\n    WCTAssert(callback != nullptr);\n    LockGuard lockGuard(m_lock);\n    WCTAssert(m_notifications.find(StringView(key)) == m_notifications.end());\n    m_notifications.insert(StringView(key), callback, order);\n}\n\nvoid Notifier::unsetNotification(const UnsafeStringView &key)\n{\n    LockGuard lockGuard(m_lock);\n    m_notifications.erase(StringView(key));\n}\n\nvoid Notifier::setNotificationForPreprocessing(const UnsafeStringView &key,\n                                               const PreprocessCallback &callback)\n{\n    LockGuard lockGuard(m_lock);\n    if (callback != nullptr) {\n        m_preprocessNotifications[key] = callback;\n    } else {\n        m_preprocessNotifications.erase(key);\n    }\n}\n\nvoid Notifier::notify(Error &error) const\n{\n    SharedLockGuard lockGuard(m_lock);\n    for (const auto &element : m_preprocessNotifications) {\n        element.second(error);\n    }\n    for (const auto &element : m_notifications) {\n        element.value()(error);\n    }\n}\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/common/base/Notifier.hpp",
    "content": "//\n// Created by sanhuazhang on 2018/06/07\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"Lock.hpp\"\n#include \"UniqueList.hpp\"\n#include \"WCDBError.hpp\"\n\nnamespace WCDB {\n\nclass Notifier final {\npublic:\n    static Notifier &shared();\n\n    void notify(Error &error) const;\n\n    typedef std::function<void(const Error &)> Callback;\n    void setNotification(int order, const UnsafeStringView &key, const Callback &callback);\n    void unsetNotification(const UnsafeStringView &key);\n\n    typedef std::function<void(Error &error)> PreprocessCallback;\n    void setNotificationForPreprocessing(const UnsafeStringView &key,\n                                         const PreprocessCallback &callback);\n\nprotected:\n    Notifier();\n    Notifier(const Notifier &) = delete;\n    Notifier &operator=(const Notifier &) = delete;\n\n    mutable SharedLock m_lock;\n\n    UniqueList<StringView, Callback> m_notifications;\n    StringViewMap<PreprocessCallback> m_preprocessNotifications;\n};\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/common/base/Path.cpp",
    "content": "//\n// Created by sanhuazhang on 2018/05/31\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"Path.hpp\"\n#include \"Assertion.hpp\"\n#include \"CommonCore.hpp\"\n#include \"CrossPlatform.h\"\n#include \"FileManager.hpp\"\n\n#include <errno.h>\n#include <stdlib.h>\n#ifndef _WIN32\n#include <unistd.h>\n#else\n#include <conio.h>\n#include <direct.h>\n#endif\n\nnamespace WCDB {\n\nnamespace Path {\n\nStringView addExtention(const UnsafeStringView &base, const UnsafeStringView &extention)\n{\n    std::ostringstream stream;\n    stream << base << extention;\n    return StringView(stream.str());\n}\n\nconst char kPathSeparator =\n#if defined _WIN32\n'\\\\';\n#else\n'/';\n#endif\n\nStringView addComponent(const UnsafeStringView &base, const UnsafeStringView &component)\n{\n    std::ostringstream stream;\n    stream << base;\n    if (base.empty() || base[base.length() - 1] != kPathSeparator) {\n        stream << kPathSeparator;\n    }\n    stream << component;\n    return StringView(stream.str());\n}\n\nStringView getFileName(const UnsafeStringView &base)\n{\n    const char *str = base.data();\n    WCTAssert(str != nullptr || base.length() == 0);\n    for (int i = (int) base.length() - 1; i >= 0; i--) {\n        if (str[i] == kPathSeparator) {\n            return StringView(str + i + 1, base.length() - i - 1);\n        }\n    }\n    return StringView(base);\n}\n\nStringView getDirectory(const UnsafeStringView &path)\n{\n    const char *str = path.data();\n    WCTAssert(str != nullptr);\n    bool foundName = false;\n    for (int i = (int) path.length() - 1; i >= 0; i--) {\n        if (str[i] != kPathSeparator) {\n            // Deal with the case /A/B//\n            foundName = true;\n        } else if (foundName) {\n            return StringView(str, i + 1);\n        }\n    }\n    return StringView();\n}\n\nUnsafeStringView normalize(const UnsafeStringView &path)\n{\n    if (path.equal(\":memory:\")) {\n        return path;\n    }\n    StringView normalized;\n#ifndef _WIN32\n    const char *resolvePath = realpath(path.data(), nullptr);\n    if (resolvePath == nullptr && errno == ENOENT) {\n        CommonCore::shared().setThreadedErrorPath(path);\n        if (FileManager::createDirectoryWithIntermediateDirectories(getDirectory(path))\n            && FileManager::createFile(path)) {\n            resolvePath = realpath(path.data(), nullptr);\n            if (resolvePath == NULL) {\n                Error error;\n                error.level = Error::Level::Warning;\n                error.setSystemCode(errno, Error::Code::IOError);\n                error.infos.insert_or_assign(ErrorStringKeyPath, path);\n                Notifier::shared().notify(error);\n            }\n            FileManager::removeItem(path);\n        }\n        CommonCore::shared().setThreadedErrorPath(nullptr);\n    }\n    if (resolvePath != nullptr) {\n        UnsafeStringView newPath = UnsafeStringView(resolvePath);\n#ifdef __APPLE__\n        /*\n         /var is the symlink to /private/var.\n         In most cases, realpath will return the path with the /var prefix,\n         while in a small number of cases it will return the path with the /private/var prefix.\n         In order to avoid the inconsistency of the path of the same file, remove the /private prefix of path here\n         */\n        if (newPath.hasPrefix(\"/private\")) {\n            newPath = UnsafeStringView(resolvePath + 8);\n        }\n#endif\n        normalized = newPath;\n        free((void *) resolvePath);\n    }\n#else\n    wchar_t resolvePath[_MAX_PATH];\n    if (::_wfullpath(resolvePath, GetPathString(path), _MAX_PATH) != NULL) {\n        normalized = StringView::createFromWString(resolvePath);\n    }\n#endif\n    if (normalized.length() > 0) {\n        return normalized;\n    } else {\n        return path;\n    }\n}\n\n} //namespace Path\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/common/base/Path.hpp",
    "content": "//\n// Created by sanhuazhang on 2018/05/31\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"StringView.hpp\"\n\n// TODO std::filesystem is available since C++17 + Clang with Xcode 11.\n\nnamespace WCDB {\n\nnamespace Path {\n\nStringView addExtention(const UnsafeStringView &base, const UnsafeStringView &extention);\nStringView addComponent(const UnsafeStringView &base, const UnsafeStringView &component);\nStringView getFileName(const UnsafeStringView &base);\nStringView getDirectory(const UnsafeStringView &base);\n\nUnsafeStringView normalize(const UnsafeStringView &path);\n\n} //namespace Path\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/common/base/Progress.cpp",
    "content": "//\n// Created by sanhuazhang on 2018/09/26\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"Progress.hpp\"\n#include \"Assertion.hpp\"\n#include <algorithm>\n\nnamespace WCDB {\n\nProgress::Progress() : m_progress(0), m_onProgressUpdated(nullptr)\n{\n}\n\nProgress::~Progress() = default;\n\nvoid Progress::clearProgress()\n{\n    m_progress = 0;\n}\n\nbool Progress::increaseProgress(double increment)\n{\n    return updateProgress(m_progress + increment);\n}\n\nbool Progress::updateProgress(double progress, bool force)\n{\n    if (!force) {\n        progress = std::min(progress, 0.999);\n    }\n    double increment = progress - m_progress;\n    WCTAssert(increment >= 0);\n    if (increment > 0.001) {\n        m_progress = progress;\n        if (m_onProgressUpdated != nullptr) {\n            return m_onProgressUpdated(m_progress, increment);\n        }\n    }\n    return true;\n}\n\nbool Progress::finishProgress()\n{\n    return updateProgress(1, true);\n}\n\nvoid Progress::setProgressCallback(const ProgressUpdateCallback &onProgressUpdated)\n{\n    m_onProgressUpdated = onProgressUpdated;\n}\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/common/base/Progress.hpp",
    "content": "//\n// Created by sanhuazhang on 2018/09/26\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include <functional>\n\nnamespace WCDB {\n\nclass Progress {\npublic:\n    Progress();\n    virtual ~Progress() = 0;\n\n    typedef std::function<bool(double progress, double increment)> ProgressUpdateCallback;\n    void setProgressCallback(const ProgressUpdateCallback &onProgressUpdated);\n\nprotected:\n    void clearProgress();\n    bool increaseProgress(double increment);\n    bool updateProgress(double progress, bool force = false);\n    bool finishProgress();\n\nprivate:\n    double m_progress;\n    ProgressUpdateCallback m_onProgressUpdated;\n};\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/common/base/Range.cpp",
    "content": "//\n// Created by sanhuazhang on 2018/07/25\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"Range.hpp\"\n#include \"Assertion.hpp\"\n#include <algorithm>\n\nnamespace WCDB {\n\nconst Range& Range::notFound()\n{\n    static const Range* s_notFound = new Range(0, -1);\n    return *s_notFound;\n}\n\nRange::Range() : location(0), length(0)\n{\n}\n\nRange::Range(Location location_, Length length_)\n: location(location_), length(length_)\n{\n}\n\nvoid Range::expandToEdge(Location edge)\n{\n    WCTRemedialAssert(\n    edge >= location, \"Edge should be greater than length.\", edge = location;);\n    length = Length(edge - location);\n}\n\nvoid Range::shiftToLocation(Location location_)\n{\n    location = location_;\n}\n\nvoid Range::shiftToEdge(Location edge)\n{\n    location = edge - length;\n}\n\nRange::Location Range::edge() const\n{\n    return location + length;\n}\n\nbool Range::contains(Location location_) const\n{\n    return location_ >= location && location_ < location + length;\n}\n\nbool Range::contains(const Range& other) const\n{\n    return other.location >= location && other.edge() <= edge();\n}\n\nbool Range::operator<(const Range& other) const\n{\n    return location < other.location;\n}\n\nbool Range::operator==(const Range& other) const\n{\n    return location == other.location && length == other.length;\n}\n\nbool Range::operator!=(const Range& other) const\n{\n    return !operator==(other);\n}\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/base/Range.hpp",
    "content": "//\n// Created by sanhuazhang on 2018/07/25\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"CrossPlatform.h\"\n#include \"SysTypes.h\"\n\nnamespace WCDB {\n\nclass Range final {\npublic:\n    using Location = offset_t;\n    using Length = size_t;\n\n    static const Range& notFound();\n\n    Range();\n    Range(Location location, Length length);\n\n    Location location;\n    Length length;\n\n    void expandToEdge(Location edge);\n    void shiftToLocation(Location location);\n    void shiftToEdge(Location edge);\n    Location edge() const;\n\n    bool contains(Location location_) const;\n    bool contains(const Range& other) const;\n\n    bool operator<(const Range& other) const;\n    bool operator==(const Range& other) const;\n    bool operator!=(const Range& other) const;\n};\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/base/Recyclable.cpp",
    "content": "//\n// Created by sanhuazhang on 2018/12/28\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"Recyclable.hpp\"\n#include \"Assertion.hpp\"\n#include <atomic>\n\nnamespace WCDB {\n\nReferenced::Referenced() : m_reference(new std::atomic<int>(0))\n{\n}\n\nReferenced::Referenced(const std::nullptr_t&) : m_reference(nullptr)\n{\n}\n\nReferenced::~Referenced() = default;\n\nvoid Referenced::reset(const Referenced& other)\n{\n    other.retain();\n    release();\n    m_reference = other.m_reference;\n}\n\nvoid Referenced::reset(const std::nullptr_t&)\n{\n    release();\n    m_reference = nullptr;\n}\n\nvoid Referenced::retain() const\n{\n    if (m_reference != nullptr) {\n        ++(*m_reference);\n    }\n}\n\nvoid Referenced::release()\n{\n    if (m_reference != nullptr) {\n        WCTAssert((*m_reference) > 0);\n        if (--(*m_reference) == 0) {\n            onUnreferenced();\n        }\n    }\n}\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/base/Recyclable.hpp",
    "content": "//\n// Created by sanhuazhang on 2018/07/23\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"Macro.h\"\n#include <atomic>\n#include <functional>\n#include <memory>\n\nnamespace WCDB {\n\nclass WCDB_API Referenced {\npublic:\n    Referenced();\n    Referenced(const std::nullptr_t &);\n    virtual ~Referenced() = 0;\n\nprotected:\n    void reset(const Referenced &other);\n    void reset(const std::nullptr_t &);\n\n    void retain() const;\n    void release();\n    virtual void onUnreferenced() = 0;\n\nprivate:\n    mutable std::shared_ptr<std::atomic<int>> m_reference;\n};\n\ntemplate<typename T>\nclass Recyclable : public Referenced {\npublic:\n    typedef std::function<void(T &)> OnRecycled;\n\n    Recyclable() : Referenced(nullptr), m_value(nullptr), m_onRecycled(nullptr)\n    {\n    }\n\n    Recyclable(const std::nullptr_t &) : Recyclable() {}\n\n    Recyclable(const T &value, const Recyclable::OnRecycled &onRecycled)\n    : Referenced(), m_value(value), m_onRecycled(onRecycled)\n    {\n        retain();\n    }\n\n    Recyclable(const Recyclable &other)\n    : Referenced(other), m_value(other.m_value), m_onRecycled(other.m_onRecycled)\n    {\n        retain();\n    }\n\n    Recyclable(Recyclable &&other)\n    : Referenced(other), m_value(std::move(other.m_value)), m_onRecycled(other.m_onRecycled)\n    {\n        retain();\n        other = nullptr;\n    }\n\n    Recyclable &operator=(const Recyclable &other)\n    {\n        reset(other);\n        m_value = other.m_value;\n        m_onRecycled = other.m_onRecycled;\n        return *this;\n    }\n\n    Recyclable &operator=(Recyclable &&other)\n    {\n        reset(other);\n        m_value = std::move(other.m_value);\n        m_onRecycled = other.m_onRecycled;\n        other = nullptr;\n        return *this;\n    }\n\n    Recyclable &operator=(const std::nullptr_t &)\n    {\n        reset(nullptr);\n        m_value = nullptr;\n        m_onRecycled = nullptr;\n        return *this;\n    }\n\n    bool operator==(const Recyclable &other) const\n    {\n        return m_value == other.m_value;\n    }\n\n    bool operator==(const std::nullptr_t &) const { return m_value == nullptr; }\n    bool operator!=(const std::nullptr_t &) const { return m_value != nullptr; }\n\n    ~Recyclable() override { release(); }\n\n    constexpr const T &operator->() const { return m_value; }\n    constexpr T &operator->() { return m_value; }\n    T &get() { return m_value; }\n    const T &get() const { return m_value; }\n\nprotected:\n    void onUnreferenced() override final\n    {\n        if (m_onRecycled != nullptr) {\n            m_onRecycled(m_value);\n            m_onRecycled = nullptr;\n        }\n    }\n\n    T m_value;\n    Recyclable::OnRecycled m_onRecycled;\n};\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/common/base/SQLite.h",
    "content": "//\n// Created by sanhuazhang on 2018/09/26\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#if SQLITE_WCDB\n#include <sqlcipher/sqlite3.h>\n#include <sqlcipher/sqlite3_wcdb.h>\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\nextern char *sqlite3_temp_directory;\n\nint sqlcipher_set_default_hmac_algorithm(int algorithm);\nint sqlcipher_set_default_kdf_algorithm(int algorithm);\nvoid sqlcipher_set_default_kdf_iter(int iter);\nvoid sqlcipher_set_default_use_hmac(int use);\n\n#ifdef __cplusplus\n}\n#endif\n\n#else\n#include <sqlite3.h>\n#endif\n"
  },
  {
    "path": "src/common/base/SQLiteDeclaration.h",
    "content": "//\n// Created by sanhuazhang on 2019/01/15\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\nextern \"C\" {\ntypedef struct sqlite3 sqlite3;\ntypedef struct sqlite3_stmt sqlite3_stmt;\ntypedef struct sqlite3_tokenizer_module sqlite3_tokenizer_module;\n}\n"
  },
  {
    "path": "src/common/base/Serialization.cpp",
    "content": "//\n// Created by sanhuazhang on 2018/06/27\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"Serialization.hpp\"\n#include \"Assertion.hpp\"\n#include \"FileHandle.hpp\"\n#include \"FileManager.hpp\"\n#include \"StringView.hpp\"\n#include <cstring>\n\nnamespace WCDB {\n\n#pragma mark - SerializeIteration\nSerializeIteration::SerializeIteration() : m_cursor(0)\n{\n}\n\nSerializeIteration::~SerializeIteration() = default;\n\nvoid SerializeIteration::seek(offset_t position)\n{\n    if (position < 0) {\n        m_cursor = std::max((offset_t) 0, (offset_t) capacity() + position + 1);\n    } else {\n        m_cursor = std::min((offset_t) capacity(), position);\n    }\n}\n\nvoid SerializeIteration::advance(offset_t offset)\n{\n    seek(m_cursor + offset);\n}\n\nbool SerializeIteration::isEnough(size_t size) const\n{\n    return size <= capacity();\n}\n\nbool SerializeIteration::canAdvance(size_t size) const\n{\n    return m_cursor + size <= capacity();\n}\n\nbool SerializeIteration::ended() const\n{\n    return m_cursor == (offset_t) capacity();\n}\n\nconst unsigned char *SerializeIteration::pointee() const\n{\n    return data().buffer() + m_cursor;\n}\n\nconst unsigned char *SerializeIteration::base() const\n{\n    return data().buffer();\n}\n\nsize_t SerializeIteration::capacity() const\n{\n    return data().size();\n}\n\n#pragma mark - Serialization\nSerialization::~Serialization() = default;\n\nbool Serialization::resize(size_t size)\n{\n    if (size < m_data.size()) {\n        return true;\n    }\n    return m_data.resize(std::max((size_t) size, m_data.size() * 2));\n}\n\nbool Serialization::expand(size_t expand)\n{\n    return resize((size_t) m_cursor + expand);\n}\n\nconst UnsafeData &Serialization::data() const\n{\n    return m_data;\n}\n\nunsigned char *Serialization::pointee()\n{\n    return m_data.buffer() + m_cursor;\n}\n\nunsigned char *Serialization::base()\n{\n    return m_data.buffer();\n}\n\n#pragma mark - Put\nbool Serialization::putSizedString(const UnsafeStringView &string)\n{\n    offset_t cursor = m_cursor;\n    bool succeed = false;\n    do {\n        size_t size = string.size();\n        size_t lengthOfSize = putVarint(size);\n        if (lengthOfSize == 0) {\n            break;\n        }\n        if (!expand(size)) {\n            break;\n        }\n        memcpy(pointee(), string.data(), size);\n        succeed = true;\n        advance(size);\n    } while (false);\n    if (!succeed) {\n        seek(cursor);\n    }\n    return true;\n}\n\nbool Serialization::putSizedData(const UnsafeData &data)\n{\n    offset_t cursor = m_cursor;\n    bool succeed = false;\n    do {\n        size_t size = data.size();\n        size_t lengthOfSize = putVarint(size);\n        if (lengthOfSize == 0) {\n            break;\n        }\n        if (!expand(size)) {\n            break;\n        }\n        memcpy(pointee(), data.buffer(), size);\n        succeed = true;\n        advance(size);\n    } while (false);\n    if (!succeed) {\n        seek(cursor);\n    }\n    return true;\n}\n\nbool Serialization::put4BytesUInt(uint32_t value)\n{\n    if (!expand(sizeof(uint32_t))) {\n        return false;\n    }\n    unsigned char *p = pointee();\n    p[0] = (uint8_t) (value >> 24);\n    p[1] = (uint8_t) (value >> 16);\n    p[2] = (uint8_t) (value >> 8);\n    p[3] = (uint8_t) value;\n    advance(sizeof(uint32_t));\n    return true;\n}\n\nbool Serialization::put8BytesUInt(uint64_t value)\n{\n    offset_t cursor = m_cursor;\n    if (!put4BytesUInt((uint32_t) (value >> 32)) || !put4BytesUInt((uint32_t) value)) {\n        seek(cursor);\n        return false;\n    }\n    return true;\n}\n\nbool Serialization::putString(const UnsafeStringView &string)\n{\n    if (!expand(string.size() + 1)) {\n        return false;\n    }\n    unsigned char *p = pointee();\n    memcpy(p, string.data(), string.size() + 1);\n    return true;\n}\n\nsize_t Serialization::putVarint(uint64_t value)\n{\n    if (!expand(9)) {\n        return 0;\n    }\n    unsigned char *p = pointee();\n    int length = 0;\n    if (value <= 0x7f) {\n        p[0] = value & 0x7f;\n        length = 1;\n    } else if (value <= 0x3fff) {\n        p[0] = ((value >> 7) & 0x7f) | 0x80;\n        p[1] = value & 0x7f;\n        length = 2;\n    } else {\n        int i, j, n;\n        uint8_t buf[10];\n        if (value & (((uint64_t) 0xff000000) << 32)) {\n            p[8] = (uint8_t) value;\n            value >>= 8;\n            for (i = 7; i >= 0; i--) {\n                p[i] = (uint8_t) ((value & 0x7f) | 0x80);\n                value >>= 7;\n            }\n            length = 9;\n        } else {\n            n = 0;\n            do {\n                buf[n++] = (uint8_t) ((value & 0x7f) | 0x80);\n                value >>= 7;\n            } while (value != 0);\n            buf[0] &= 0x7f;\n            WCTAssert(n <= 9);\n            for (i = 0, j = n - 1; j >= 0; j--, i++) {\n                p[i] = buf[j];\n            }\n            length = n;\n        }\n    }\n    advance(length);\n    return length;\n}\n\nData Serialization::finalize()\n{\n    return m_data.subdata((size_t) m_cursor);\n}\n\n#pragma mark - Deserialization\nDeserialization::Deserialization() = default;\nDeserialization::~Deserialization() = default;\n\nDeserialization::Deserialization(const UnsafeData &data)\n: m_data(data), m_dataVersion(0)\n{\n    static_assert(slot_2_0 == ((0x7f << 14) | (0x7f)), \"\");\n    static_assert(slot_4_2_0 == ((0xfU << 28) | (0x7f << 14) | (0x7f)), \"\");\n}\n\nconst UnsafeData &Deserialization::data() const\n{\n    return m_data;\n}\n\nuint32_t Deserialization::version() const\n{\n    return m_dataVersion;\n}\n\nvoid Deserialization::setDataVersion(uint32_t version)\n{\n    m_dataVersion = version;\n}\n\nvoid Deserialization::reset(const UnsafeData &data)\n{\n    m_data = data;\n    m_cursor = 0;\n}\n\n#pragma mark - Advance\nstd::pair<size_t, StringView> Deserialization::advanceSizedString()\n{\n    auto pair = getSizedString(m_cursor);\n    if (pair.first > 0) {\n        advance(pair.first);\n    }\n    return pair;\n}\n\nstd::pair<size_t, const UnsafeData> Deserialization::advanceSizedData()\n{\n    auto pair = getSizedData(m_cursor);\n    if (pair.first > 0) {\n        advance(pair.first);\n    }\n    return pair;\n}\n\nstd::pair<size_t, uint64_t> Deserialization::advanceVarint()\n{\n    auto result = getVarint(m_cursor);\n    if (result.first > 0) {\n        advance(result.first);\n    }\n    return result;\n}\n\nint64_t Deserialization::advance8BytesInt()\n{\n    int64_t value = get8BytesInt(m_cursor);\n    advance(8);\n    return value;\n}\n\nint64_t Deserialization::advance6BytesInt()\n{\n    int64_t value = get6BytesInt(m_cursor);\n    advance(6);\n    return value;\n}\n\nint32_t Deserialization::advance4BytesInt()\n{\n    int32_t value = get4BytesInt(m_cursor);\n    advance(4);\n    return value;\n}\n\nint32_t Deserialization::advance3BytesInt()\n{\n    int32_t value = get3BytesInt(m_cursor);\n    advance(3);\n    return value;\n}\n\nint32_t Deserialization::advance2BytesInt()\n{\n    int32_t value = get2BytesInt(m_cursor);\n    advance(2);\n    return value;\n}\n\nint32_t Deserialization::advance1ByteInt()\n{\n    int32_t value = get1ByteInt(m_cursor);\n    advance(1);\n    return value;\n}\n\ndouble Deserialization::advance8BytesDouble()\n{\n    double value = get8BytesDouble(m_cursor);\n    advance(8);\n    return value;\n}\n\nuint32_t Deserialization::advance4BytesUInt()\n{\n    uint32_t value = get4BytesUInt(m_cursor);\n    advance(4);\n    return value;\n}\n\nstd::pair<size_t, StringView> Deserialization::getSizedString(offset_t offset) const\n{\n    size_t lengthOfSize;\n    uint64_t size;\n    std::tie(lengthOfSize, size) = getVarint(offset);\n    if (lengthOfSize == 0 || !isEnough((size_t) offset + lengthOfSize + (size_t) size)) {\n        return { 0, StringView() };\n    }\n    return { lengthOfSize + size, getString((size_t) offset + lengthOfSize, (size_t) size) };\n}\n\nstd::pair<size_t, const UnsafeData> Deserialization::getSizedData(offset_t offset) const\n{\n    size_t lengthOfSize;\n    uint64_t size;\n    std::tie(lengthOfSize, size) = getVarint(offset);\n    if (lengthOfSize == 0 || !isEnough((size_t) offset + lengthOfSize + (size_t) size)) {\n        return { 0, Data::null() };\n    }\n    return { lengthOfSize + size, getData((size_t) offset + lengthOfSize, (size_t) size) };\n}\n\nstd::pair<size_t, uint64_t> Deserialization::getVarint(offset_t offset) const\n{\n    if (!isEnough((size_t) offset + 1)) {\n        return { 0, 0 };\n    }\n    const unsigned char *p = base() + offset;\n\n    uint32_t a = *p;\n    /* a: p0 (unmasked) */\n    if (!(a & 0x80)) {\n        return { 1, a };\n    }\n\n    if (!isEnough((size_t) offset + 2)) {\n        return { 0, 0 };\n    }\n    ++p;\n\n    uint32_t b = *p;\n    /* b: p1 (unmasked) */\n    if (!(b & 0x80)) {\n        a &= 0x7f;\n        a = a << 7;\n        a |= b;\n        return { 2, a };\n    }\n\n    /* Verify that constants are precomputed correctly */\n\n    if (!isEnough((size_t) offset + 3)) {\n        return { 0, 0 };\n    }\n    ++p;\n    a = a << 14;\n    a |= *p;\n    /* a: p0<<14 | p2 (unmasked) */\n    if (!(a & 0x80)) {\n        a &= slot_2_0;\n        b &= 0x7f;\n        b = b << 7;\n        a |= b;\n        return { 3, a };\n    }\n\n    /* CSE1 from below */\n\n    a &= slot_2_0;\n    if (!isEnough((size_t) offset + 4)) {\n        return { 0, 0 };\n    }\n    ++p;\n    b = b << 14;\n    b |= *p;\n    /* b: p1<<14 | p3 (unmasked) */\n    if (!(b & 0x80)) {\n        b &= slot_2_0;\n        /* moved CSE1 up */\n        /* a &= (0x7f<<14)|(0x7f); */\n        a = a << 7;\n        a |= b;\n        return { 4, a };\n    }\n\n    /* a: p0<<14 | p2 (masked) */\n    /* b: p1<<14 | p3 (unmasked) */\n    /* 1:save off p0<<21 | p1<<14 | p2<<7 | p3 (masked) */\n    /* moved CSE1 up */\n    /* a &= (0x7f<<14)|(0x7f); */\n    b &= slot_2_0;\n    uint64_t s = a;\n    /* s: p0<<14 | p2 (masked) */\n\n    if (!isEnough((size_t) offset + 5)) {\n        return { 0, 0 };\n    }\n    ++p;\n    a = a << 14;\n    a |= *p;\n    /* a: p0<<28 | p2<<14 | p4 (unmasked) */\n    if (!(a & 0x80)) {\n        /* we can skip these cause they were (effectively) done above\n             ** while calculating s */\n        /* a &= (0x7f<<28)|(0x7f<<14)|(0x7f); */\n        /* b &= (0x7f<<14)|(0x7f); */\n        b = b << 7;\n        a |= b;\n        s = s >> 18;\n        return { 5, ((uint64_t) s) << 32 | a };\n    }\n\n    /* 2:save off p0<<21 | p1<<14 | p2<<7 | p3 (masked) */\n    s = s << 7;\n    s |= b;\n    /* s: p0<<21 | p1<<14 | p2<<7 | p3 (masked) */\n\n    if (!isEnough((size_t) offset + 6)) {\n        return { 0, 0 };\n    }\n    ++p;\n    b = b << 14;\n    b |= *p;\n    /* b: p1<<28 | p3<<14 | p5 (unmasked) */\n    if (!(b & 0x80)) {\n        /* we can skip this cause it was (effectively) done above in calc'ing s */\n        /* b &= (0x7f<<28)|(0x7f<<14)|(0x7f); */\n        a &= slot_2_0;\n        a = a << 7;\n        a |= b;\n        s = s >> 18;\n        return { 6, ((uint64_t) s) << 32 | a };\n    }\n\n    if (!isEnough((size_t) offset + 7)) {\n        return { 0, 0 };\n    }\n    ++p;\n    a = a << 14;\n    a |= *p;\n    /* a: p2<<28 | p4<<14 | p6 (unmasked) */\n    if (!(a & 0x80)) {\n        a &= slot_4_2_0;\n        b &= slot_2_0;\n        b = b << 7;\n        a |= b;\n        s = s >> 11;\n        return { 7, ((uint64_t) s) << 32 | a };\n    }\n\n    /* CSE2 from below */\n    a &= slot_2_0;\n    if (!isEnough((size_t) offset + 8)) {\n        return { 0, 0 };\n    }\n    ++p;\n    b = b << 14;\n    b |= *p;\n    /* b: p3<<28 | p5<<14 | p7 (unmasked) */\n    if (!(b & 0x80)) {\n        b &= slot_4_2_0;\n        /* moved CSE2 up */\n        /* a &= (0x7f<<14)|(0x7f); */\n        a = a << 7;\n        a |= b;\n        s = s >> 4;\n        return { 8, ((uint64_t) s) << 32 | a };\n    }\n\n    if (!isEnough((size_t) offset + 9)) {\n        return { 0, 0 };\n    }\n    ++p;\n    a = a << 15;\n    a |= *p;\n    /* a: p4<<29 | p6<<15 | p8 (unmasked) */\n\n    /* moved CSE2 up */\n    /* a &= (0x7f<<29)|(0x7f<<15)|(0xff); */\n    b &= slot_2_0;\n    b = b << 8;\n    a |= b;\n\n    s = s << 4;\n    b = p[-4];\n    b &= 0x7f;\n    b = b >> 3;\n    s |= b;\n\n    return { 9, ((uint64_t) s) << 32 | a };\n}\n\nStringView Deserialization::getString(offset_t offset, size_t size) const\n{\n    if (size == 0) {\n        return StringView();\n    }\n    WCTAssert(isEnough((size_t) offset + size));\n    return StringView(reinterpret_cast<const char *>(base() + offset), size);\n}\n\nconst UnsafeData Deserialization::getData(offset_t offset, size_t size) const\n{\n    WCTAssert(isEnough((size_t) offset + size));\n    return UnsafeData::immutable(base() + offset, size);\n}\n\nint64_t Deserialization::get8BytesInt(offset_t offset) const\n{\n    WCTAssert(isEnough((size_t) offset + 8));\n    uint64_t x = get4BytesUInt(offset);\n    uint32_t y = get4BytesUInt(offset + 4);\n    x = (x << 32) + y;\n    return *(int64_t *) &x;\n}\n\nint64_t Deserialization::get6BytesInt(offset_t offset) const\n{\n    WCTAssert(isEnough((size_t) offset + 6));\n    return get4BytesUInt(offset + 2) + (((int64_t) 1) << 32) * get2BytesInt(offset);\n}\n\nint32_t Deserialization::get4BytesInt(offset_t offset) const\n{\n    WCTAssert(isEnough((size_t) offset + 4));\n    const unsigned char *p = base() + offset;\n    return (16777216 * (int8_t) (p[0]) | (p[1] << 16) | (p[2] << 8) | p[3]);\n}\n\nint32_t Deserialization::get3BytesInt(offset_t offset) const\n{\n    WCTAssert(isEnough((size_t) offset + 3));\n    const unsigned char *p = base() + offset;\n    return (65536 * (int8_t) (p[0]) | (p[1] << 8) | p[2]);\n}\n\nint32_t Deserialization::get2BytesInt(offset_t offset) const\n{\n    WCTAssert(isEnough((size_t) offset + 2));\n    const unsigned char *p = base() + offset;\n    return (256 * (int8_t) (p[0]) | p[1]);\n}\n\nint32_t Deserialization::get1ByteInt(offset_t offset) const\n{\n    WCTAssert(isEnough((size_t) offset + 1));\n    return (int8_t) (base() + offset)[0];\n}\n\ndouble Deserialization::get8BytesDouble(offset_t offset) const\n{\n    WCTAssert(isEnough((size_t) offset + 8));\n    uint64_t x = get4BytesUInt(offset);\n    uint32_t y = get4BytesUInt(offset + 4);\n    x = (x << 32) + y;\n    double d;\n    memcpy(&d, &x, sizeof(double));\n    return d;\n}\n\nuint32_t Deserialization::get4BytesUInt(offset_t offset) const\n{\n    WCTAssert(isEnough((size_t) offset + 4));\n    const unsigned char *p = base() + offset;\n    return (((uint32_t) p[0] << 24) | (p[1] << 16) | (p[2] << 8) | p[3]);\n}\n\n#pragma mark - Serializable\nSerializable::~Serializable() = default;\n\nData Serializable::serialize() const\n{\n    Serialization serialization;\n    if (serialize(serialization)) {\n        return serialization.finalize();\n    }\n    return Data::null();\n}\n\nbool Serializable::serialize(const UnsafeStringView &path) const\n{\n    Data data = serialize();\n    if (data.empty()) {\n        return false;\n    }\n    FileHandle fileHandle(path);\n    if (!fileHandle.open(FileHandle::Mode::OverWrite)) {\n        return false;\n    }\n    bool succeed = fileHandle.write(data);\n    fileHandle.close();\n    FileManager::setFileProtectionCompleteUntilFirstUserAuthenticationIfNeeded(path);\n    return succeed;\n}\n\n#pragma mark - Deserializable\nDeserializable::~Deserializable() = default;\n\nbool Deserializable::deserialize(const Data &data)\n{\n    Deserialization deserialization(data);\n    return deserialize(deserialization);\n}\n\nbool Deserializable::deserialize(const UnsafeStringView &path)\n{\n    FileHandle fileHandle(path);\n    if (!fileHandle.open(FileHandle::Mode::ReadOnly)) {\n        return false;\n    }\n    Data data = fileHandle.mapOrReadAllData();\n    if (data.empty() || !deserialize(data)) {\n        return false;\n    }\n    return true;\n}\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/common/base/Serialization.hpp",
    "content": "//\n// Created by sanhuazhang on 2018/06/27\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"Data.hpp\"\n#include \"StringView.hpp\"\n\nnamespace WCDB {\n\nclass SerializeIteration {\n#pragma mark - SerializeIteration\npublic:\n    SerializeIteration();\n    virtual ~SerializeIteration() = 0;\n\n    void seek(offset_t position);\n    void advance(offset_t offset);\n    bool canAdvance(size_t size) const;\n    bool isEnough(size_t size) const;\n    bool ended() const;\n\nprotected:\n    virtual const UnsafeData &data() const = 0;\n    const unsigned char *pointee() const;\n    const unsigned char *base() const;\n    size_t capacity() const;\n\n    offset_t m_cursor;\n};\n\nclass Serialization final : public SerializeIteration {\n#pragma mark - Serialization\npublic:\n    ~Serialization() override;\n\n    Data finalize();\n    bool resize(size_t size);\n    bool expand(size_t expand);\n\nprotected:\n    unsigned char *pointee();\n    unsigned char *base();\n    const UnsafeData &data() const override final;\n    Data m_data;\n\n#pragma mark - Put\npublic:\n    bool putSizedString(const UnsafeStringView &string);\n    bool putSizedData(const UnsafeData &data);\n    bool put4BytesUInt(uint32_t value);\n    bool put8BytesUInt(uint64_t value);\n    bool putString(const UnsafeStringView &string);\n    size_t putVarint(uint64_t value);\n};\n\nclass Deserialization final : public SerializeIteration {\n#pragma mark - Deserialization\npublic:\n    Deserialization();\n    Deserialization(const UnsafeData &data);\n    ~Deserialization() override;\n\n    void reset(const UnsafeData &data);\n\n    const UnsafeData &data() const override final;\n    uint32_t version() const;\n    void setDataVersion(uint32_t version);\n\nprotected:\n    UnsafeData m_data;\n    uint32_t m_dataVersion;\n\n    static constexpr const uint32_t slot_2_0 = 0x001fc07f;\n    static constexpr const uint32_t slot_4_2_0 = 0xf01fc07f;\n\n#pragma mark - Advance\npublic:\n    //return 0 size to indicate failure\n    std::pair<size_t, StringView> advanceSizedString();\n    std::pair<size_t, const UnsafeData> advanceSizedData();\n    std::pair<size_t, uint64_t> advanceVarint();\n\n    // For the following types with specified size, `canAdvance` should be called first.\n    int64_t advance8BytesInt();\n    int64_t advance6BytesInt();\n    int32_t advance4BytesInt();\n    int32_t advance3BytesInt();\n    int32_t advance2BytesInt();\n    int32_t advance1ByteInt();\n    double advance8BytesDouble();\n    uint32_t advance4BytesUInt();\n\n#pragma mark - Get\npublic:\n    //return 0 size to indicate failure\n    std::pair<size_t, StringView> getSizedString(offset_t offset) const;\n    std::pair<size_t, const UnsafeData> getSizedData(offset_t offset) const;\n    std::pair<size_t, uint64_t> getVarint(offset_t offset) const;\n\n    // For the following types with specified size, `isEnough` should be called first.\n    StringView getString(offset_t offset, size_t size) const;\n    const UnsafeData getData(offset_t offset, size_t size) const;\n    int64_t get8BytesInt(offset_t offset) const;\n    int64_t get6BytesInt(offset_t offset) const;\n    int32_t get4BytesInt(offset_t offset) const;\n    int32_t get3BytesInt(offset_t offset) const;\n    int32_t get2BytesInt(offset_t offset) const;\n    int32_t get1ByteInt(offset_t offset) const;\n    double get8BytesDouble(offset_t offset) const;\n    uint32_t get4BytesUInt(offset_t offset) const;\n};\n\n#pragma mark - Serializable\nclass Serializable : protected SharedThreadedErrorProne {\npublic:\n    virtual ~Serializable() override = 0;\n    Data serialize() const;\n    bool serialize(const UnsafeStringView &path) const;\n    virtual bool serialize(Serialization &serialization) const = 0;\n};\n\n#pragma mark - Deserializable\nclass Deserializable : protected SharedThreadedErrorProne {\npublic:\n    virtual ~Deserializable() override = 0;\n    bool deserialize(const Data &data);\n    bool deserialize(const UnsafeStringView &path);\n    virtual bool deserialize(Deserialization &deserialization) = 0;\n};\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/common/base/SharedThreadedErrorProne.cpp",
    "content": "//\n// Created by sanhuazhang on 2018/06/08\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"SharedThreadedErrorProne.hpp\"\n#include \"ThreadedErrors.hpp\"\n\nnamespace WCDB {\n\nSharedThreadedErrorProne::~SharedThreadedErrorProne() = default;\n\nvoid SharedThreadedErrorProne::setThreadedError(const Error &error)\n{\n    ThreadedErrors::shared().setThreadedError(error);\n}\n\nvoid SharedThreadedErrorProne::setThreadedError(Error &&error)\n{\n    ThreadedErrors::shared().setThreadedError(std::move(error));\n}\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/common/base/SharedThreadedErrorProne.hpp",
    "content": "//\n// Created by sanhuazhang on 2018/06/08\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"Macro.h\"\n\nnamespace WCDB {\n\nclass Error;\n\nclass WCDB_API SharedThreadedErrorProne {\npublic:\n    virtual ~SharedThreadedErrorProne() = 0;\n\nprotected:\n    static void setThreadedError(const Error &error);\n    static void setThreadedError(Error &&error);\n};\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/common/base/StringView.cpp",
    "content": "//\n// Created by sanhuazhang on 2019/06/16\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"StringView.hpp\"\n#include \"Assertion.hpp\"\n#include \"CrossPlatform.h\"\n#include \"Macro.h\"\n#include \"UnsafeData.hpp\"\n#ifdef _WIN32\n#define NOMINMAX\n#include <windows.h>\n#endif\n#include <algorithm>\n#include <cstring>\n#include <iomanip>\n#include <numeric>\n#include <zlib.h>\n\nnamespace WCDB {\n\nconstexpr int kReferenceSize = sizeof(std::atomic<int>) / sizeof(char);\n\n#pragma mark - UnsafeStringView - Constructor\nUnsafeStringView::UnsafeStringView()\n: m_data(\"\"), m_length(0), m_referenceCount(nullptr)\n{\n}\n\nUnsafeStringView::UnsafeStringView(const char* string)\n: m_data(string != nullptr ? string : \"\")\n, m_length(string != nullptr ? (int) strlen(string) : 0)\n, m_referenceCount(nullptr)\n{\n#ifdef __ANDROID__\n    if (tryRetrievePreAllocatedMemory(string)) {\n        m_referenceCount = (std::atomic<int>*) (string - kReferenceSize);\n        new (m_referenceCount) std::atomic<int>(1);\n    }\n#endif\n}\n\nUnsafeStringView::UnsafeStringView(const char* string, size_t length)\n: m_data(string != nullptr ? string : \"\"), m_length(length), m_referenceCount(nullptr)\n{\n}\n\nUnsafeStringView::UnsafeStringView(const UnsafeStringView& other)\n: m_data(other.m_data), m_length(other.m_length), m_referenceCount(other.m_referenceCount)\n{\n    if ((uint64_t) m_referenceCount > ConstanceReference) {\n        (*m_referenceCount)++;\n    }\n}\n\nUnsafeStringView::UnsafeStringView(UnsafeStringView&& other)\n: m_data(other.m_data), m_length(other.m_length), m_referenceCount(other.m_referenceCount)\n{\n    other.m_referenceCount = nullptr;\n    other.m_data = \"\";\n    other.m_length = 0;\n}\n\nUnsafeStringView::~UnsafeStringView()\n{\n    tryClearSpace();\n};\n\nUnsafeStringView& UnsafeStringView::operator=(const UnsafeStringView& other)\n{\n    tryClearSpace();\n    m_data = other.m_data;\n    m_length = other.m_length;\n    m_referenceCount = other.m_referenceCount;\n    if (((uint64_t) m_referenceCount > ConstanceReference)) {\n        (*m_referenceCount)++;\n    }\n    return *this;\n}\n\nUnsafeStringView& UnsafeStringView::operator=(UnsafeStringView&& other)\n{\n    tryClearSpace();\n    m_data = other.m_data;\n    m_length = other.m_length;\n    m_referenceCount = other.m_referenceCount;\n    other.m_referenceCount = nullptr;\n    other.m_data = \"\";\n    other.m_length = 0;\n    return *this;\n}\n\nbool UnsafeStringView::operator==(const UnsafeStringView& other) const\n{\n    return compare(other) == 0;\n}\n\nbool UnsafeStringView::operator!=(const UnsafeStringView& other) const\n{\n    return compare(other) != 0;\n}\n\nbool UnsafeStringView::operator<(const UnsafeStringView& other) const\n{\n    return compare(other) < 0;\n}\n\nbool UnsafeStringView::operator>(const UnsafeStringView& other) const\n{\n    return compare(other) > 0;\n}\n\nconst char& UnsafeStringView::operator[](offset_t off) const\n{\n    return m_data[off];\n}\n\nUnsafeStringView::operator std::string() const\n{\n    if (m_length > 0) {\n        return std::string(m_data, m_length);\n    }\n    return std::string();\n}\n\nconst char* UnsafeStringView::data() const\n{\n    return m_data;\n}\n\nsize_t UnsafeStringView::length() const\n{\n    return m_length;\n}\n\nsize_t UnsafeStringView::size() const\n{\n    return m_length;\n}\n\nbool UnsafeStringView::empty() const\n{\n    return m_length == 0;\n}\n\nconst char& UnsafeStringView::at(offset_t off) const\n{\n    return m_data[off];\n}\n\nUnsafeStringView UnsafeStringView::subStr(offset_t off, size_t length) const\n{\n    WCTRemedialAssert(off + length <= m_length, \"invalid parameter\", UnsafeStringView(););\n    if (length == 0) {\n        length = m_length - off;\n    }\n    UnsafeStringView ret(m_data + off, length);\n    ret.m_referenceCount = m_referenceCount;\n    if (((uint64_t) m_referenceCount > ConstanceReference)) {\n        (*m_referenceCount)++;\n    }\n    return ret;\n}\n\n#pragma mark - UTF16\n\n#ifdef _WIN32\nstd::wstring UnsafeStringView::getWString() const\n{\n    std::wstring wstring;\n    int wlen = MultiByteToWideChar(CP_UTF8, 0, m_data, m_length, NULL, 0);\n    if (wlen > 0) {\n        wstring.resize(static_cast<size_t>(wlen));\n        MultiByteToWideChar(CP_UTF8, 0, m_data, m_length, &wstring[0], wlen);\n    }\n    return wstring;\n}\n#endif\n\n#define READ_UTF16LE(zIn, TERM, c)                                                      \\\n    {                                                                                   \\\n        c = (*zIn++);                                                                   \\\n        c += ((*zIn++) << 8);                                                           \\\n        if (c >= 0xD800 && c < 0xE000 && TERM) {                                        \\\n            int c2 = (*zIn++);                                                          \\\n            c2 += ((*zIn++) << 8);                                                      \\\n            c = (c2 & 0x03FF) + ((c & 0x003F) << 10) + (((c & 0x03C0) + 0x0040) << 10); \\\n        }                                                                               \\\n    }\n\n#define READ_UTF16BE(zIn, TERM, c)                                                      \\\n    {                                                                                   \\\n        c = ((*zIn++) << 8);                                                            \\\n        c += (*zIn++);                                                                  \\\n        if (c >= 0xD800 && c < 0xE000 && TERM) {                                        \\\n            int c2 = ((*zIn++) << 8);                                                   \\\n            c2 += (*zIn++);                                                             \\\n            c = (c2 & 0x03FF) + ((c & 0x003F) << 10) + (((c & 0x03C0) + 0x0040) << 10); \\\n        }                                                                               \\\n    }\n\n#define u8 unsigned char\n\n#define WRITE_UTF8(zOut, c)                                                    \\\n    {                                                                          \\\n        if (c < 0x00080) {                                                     \\\n            *zOut++ = (u8) (c & 0xFF);                                         \\\n        } else if (c < 0x00800) {                                              \\\n            *zOut++ = 0xC0 + (u8) ((c >> 6) & 0x1F);                           \\\n            *zOut++ = 0x80 + (u8) (c & 0x3F);                                  \\\n        } else if (c < 0x10000) {                                              \\\n            *zOut++ = 0xE0 + (u8) ((c >> 12) & 0x0F);                          \\\n            *zOut++ = 0x80 + (u8) ((c >> 6) & 0x3F);                           \\\n            *zOut++ = 0x80 + (u8) (c & 0x3F);                                  \\\n        } else {                                                               \\\n            *zOut++ = 0xF0 + (u8) ((c >> 18) & 0x07);                          \\\n            *zOut++ = 0x80 + (u8) ((c >> 12) & 0x3F);                          \\\n            *zOut++ = 0x80 + (u8) ((c >> 6) & 0x3F);                           \\\n            *zOut++ = 0x80 + (u8) (c & 0x3F);                                  \\\n        }                                                                      \\\n    }\n\nUnsafeStringView\nUnsafeStringView::createFromUTF16(const char16_t* utf16Str, size_t length, char* buffer)\n{\n    return UnsafeStringView(buffer, changeToUTF8(utf16Str, length, buffer));\n}\n\nsize_t UnsafeStringView::changeToUTF8(const char16_t* utf16Str, size_t length, char* buffer)\n{\n    if (length == 0) {\n        return length;\n    }\n    const char* in = (const char*) utf16Str;\n    const char* end = (const char*) (utf16Str + length);\n    char* out = buffer;\n    unsigned int c;\n    static bool s_isBigEndian = []() -> bool {\n        short int n = 0x1;\n        char* p = (char*) &n;\n        return p[0] != 1;\n    }();\n    while (in < end) {\n        if (s_isBigEndian) {\n            READ_UTF16BE(in, in < end, c)\n            WRITE_UTF8(out, c);\n        } else {\n            READ_UTF16LE(in, in < end, c)\n            WRITE_UTF8(out, c);\n        }\n    }\n    *out = 0;\n    return out - buffer;\n}\n\n#pragma mark - UnsafeStringView - Comparison\nint UnsafeStringView::caseInsensitiveCompare(const UnsafeStringView& other) const\n{\n    if (m_data == other.m_data && m_length == other.m_length) {\n        return 0;\n    }\n    int ret = strncasecmp(m_data, other.m_data, std::min(m_length, other.m_length));\n    if (ret != 0) {\n        return ret;\n    }\n    if (m_length > other.m_length) {\n        return 1;\n    } else if (m_length < other.m_length) {\n        return -1;\n    } else {\n        return 0;\n    }\n}\n\nbool UnsafeStringView::caseInsensitiveEqual(const UnsafeStringView& other) const\n{\n    if (length() != other.length()) {\n        return false;\n    }\n    return strncasecmp(data(), other.data(), m_length) == 0;\n}\n\n#pragma mark - UnsafeStringView - Operations\nuint32_t UnsafeStringView::hash() const\n{\n    return (uint32_t) crc32(0, (const unsigned char*) data(), (uint32_t) m_length);\n}\n\nbool UnsafeStringView::hasPrefix(const UnsafeStringView& target) const\n{\n    bool has = false;\n    if (length() >= target.length()) {\n        has = strncmp(data(), target.data(), target.m_length) == 0;\n    }\n    return has;\n}\n\nbool UnsafeStringView::hasSuffix(const UnsafeStringView& target) const\n{\n    bool has = false;\n    if (m_length >= target.m_length) {\n        has = strncmp(data() + m_length - target.m_length, target.data(), target.m_length) == 0;\n    }\n    return has;\n}\n\nbool UnsafeStringView::contain(const UnsafeStringView& target) const\n{\n    if (target.m_length > m_length || target.m_length == 0) {\n        return false;\n    }\n    return strstr(m_data, target.m_data) != nullptr;\n}\n\nbool UnsafeStringView::equal(const UnsafeStringView& other) const\n{\n    return compare(other) == 0;\n}\n\nint UnsafeStringView::compare(const UnsafeStringView& other) const\n{\n    if (m_data == other.m_data && m_length == other.m_length) {\n        return 0;\n    }\n    int ret = strncmp(m_data, other.m_data, std::min(m_length, other.m_length));\n    if (ret != 0) {\n        return ret;\n    }\n    if (m_length > other.m_length) {\n        return 1;\n    } else if (m_length < other.m_length) {\n        return -1;\n    } else {\n        return 0;\n    }\n}\n\nsize_t UnsafeStringView::find(const UnsafeStringView& other, off_t off) const\n{\n    if (off + other.m_length > m_length || other.m_length == 0 || off < 0) {\n        return npos;\n    }\n    const char* ret = strstr(m_data + off, other.m_data);\n    if (ret == nullptr) {\n        return npos;\n    }\n    size_t pos = ret - m_data;\n    if (pos >= m_length) {\n        return npos;\n    }\n    return pos;\n}\n\n#pragma mark - UnsafeStringView - Memory Management\nvoid UnsafeStringView::clear()\n{\n    ensureNewSpace(0);\n    m_data = \"\";\n}\n\nvoid UnsafeStringView::ensureNewSpace(size_t newSize)\n{\n    if ((uint64_t) m_referenceCount <= ConstanceReference) {\n        if (newSize > 0) {\n            createNewSpace(newSize);\n        } else {\n            m_referenceCount = nullptr;\n        }\n    } else {\n        int count = --(*m_referenceCount);\n        if (newSize > m_length || newSize == 0) {\n            if (count == 0) {\n                clearSpace();\n            }\n            if (newSize > 0) {\n                createNewSpace(newSize);\n            } else {\n                m_referenceCount = nullptr;\n            }\n        } else {\n            if (count > 0) {\n                createNewSpace(newSize);\n            } else {\n                *m_referenceCount = 1;\n            }\n        }\n    }\n    m_length = newSize;\n}\n\nvoid UnsafeStringView::createNewSpace(size_t newSize)\n{\n    m_referenceCount = (std::atomic<int>*) malloc(kReferenceSize + newSize + 1);\n    if (m_referenceCount != nullptr) {\n        new (m_referenceCount) std::atomic<int>(1);\n    }\n}\n\nvoid UnsafeStringView::tryClearSpace()\n{\n    if ((uint64_t) m_referenceCount <= ConstanceReference) {\n        return;\n    }\n    if (--(*m_referenceCount) == 0) {\n        clearSpace();\n    }\n}\n\nvoid UnsafeStringView::clearSpace()\n{\n    m_referenceCount->~atomic<int>();\n    free(m_referenceCount);\n    m_referenceCount = nullptr;\n    m_data = \"\";\n    m_length = 0;\n}\n\n#ifdef __ANDROID__\n\n#pragma mark - UnsafeStringView - PreAllocMemory\n\nthread_local UnsafeStringView::PreAllocatedMemory UnsafeStringView::g_preAllocatedMemory\n= { nullptr, 0, 0 };\n\nchar** UnsafeStringView::preAllocStringMemorySlot(int count)\n{\n    if (count == 0) {\n        return nullptr;\n    }\n    if (g_preAllocatedMemory.totalCount - g_preAllocatedMemory.usedCount < count) {\n        int neededCount = g_preAllocatedMemory.usedCount + count;\n        int newCount = 1;\n        while (newCount < neededCount) {\n            newCount = newCount << 1;\n        }\n        char** newMemory\n        = (char**) realloc(g_preAllocatedMemory.memory, newCount * sizeof(char*));\n        if (newMemory == nullptr) {\n            return nullptr;\n        }\n        memset(newMemory + g_preAllocatedMemory.totalCount,\n               0,\n               sizeof(char*) * (newCount - g_preAllocatedMemory.totalCount));\n        g_preAllocatedMemory.memory = newMemory;\n        g_preAllocatedMemory.totalCount = newCount;\n    }\n    char** ret = g_preAllocatedMemory.memory + g_preAllocatedMemory.usedCount;\n    g_preAllocatedMemory.usedCount += count;\n    return ret;\n}\n\nvoid UnsafeStringView::allocStringMemory(char** slot, int size)\n{\n    if (slot == nullptr) {\n        return;\n    }\n    char* buffer = (char*) malloc((size + 1 + kReferenceSize) * sizeof(char));\n    if (buffer == nullptr) {\n        return;\n    }\n    *slot = buffer + kReferenceSize;\n    *(*slot + size) = '\\0';\n}\n\nvoid UnsafeStringView::clearAllocatedMemory(int count)\n{\n    char** memory = g_preAllocatedMemory.memory;\n    for (int i = g_preAllocatedMemory.usedCount - count;\n         i < g_preAllocatedMemory.usedCount;\n         i++) {\n        if (memory[i] == nullptr) {\n            continue;\n        }\n        free(memory[i] - kReferenceSize);\n        memory[i] = nullptr;\n    }\n    g_preAllocatedMemory.usedCount -= count;\n}\n\nvoid UnsafeStringView::clearAllPreAllocatedMemory()\n{\n    WCTAssert(g_preAllocatedMemory.usedCount == 0);\n    clearAllocatedMemory(g_preAllocatedMemory.usedCount);\n}\n\nbool UnsafeStringView::tryRetrievePreAllocatedMemory(const char* string)\n{\n    if (string == nullptr) {\n        return false;\n    }\n    for (int i = 0; i < g_preAllocatedMemory.usedCount; i++) {\n        if (g_preAllocatedMemory.memory[i] != string) {\n            continue;\n        }\n        g_preAllocatedMemory.memory[i] = nullptr;\n        if (g_preAllocatedMemory.usedCount == i + 1) {\n            int j = i - 1;\n            for (; j >= 0 && g_preAllocatedMemory.memory[j] == nullptr; j--);\n            g_preAllocatedMemory.usedCount = j + 1;\n        }\n        WCTAssert(g_preAllocatedMemory.usedCount >= 0);\n        return true;\n    }\n    return false;\n}\n\n#endif\n\n#pragma mark - StringView - Constructor\nStringView::StringView() = default;\n\nvoid StringView::assignString(const char* content, size_t length)\n{\n    if (length == 0 && content != nullptr) {\n        length = strlen(content);\n    }\n    ensureNewSpace(length);\n    if (content == nullptr || length == 0 || m_referenceCount == nullptr) {\n        m_data = \"\";\n        return;\n    }\n    char* data = (char*) (m_referenceCount + 1);\n    memcpy(data, (void*) content, length);\n    data[length] = '\\0';\n    m_data = data;\n}\n\n#pragma mark - UTF16\nStringView StringView::createFromUTF16(const char16_t* utf16Str, size_t length)\n{\n    StringView ret;\n    if (length == 0 || utf16Str == nullptr) {\n        return ret;\n    }\n    ret.ensureNewSpace(4 * length + 1);\n    ret.m_data = (char*) (ret.m_referenceCount + 1);\n    ret.m_length = changeToUTF8(utf16Str, length, const_cast<char*>(ret.m_data));\n    return ret;\n}\n\nStringView::StringView(const char* string) : UnsafeStringView()\n{\n#ifdef __ANDROID__\n    if (tryRetrievePreAllocatedMemory(string)) {\n        m_referenceCount = (std::atomic<int>*) (string - kReferenceSize);\n        new (m_referenceCount) std::atomic<int>(1);\n        m_data = string;\n        m_length = strlen(string);\n        return;\n    }\n#endif\n    assignString(string, 0);\n}\n\nStringView::StringView(const char* string, size_t length) : UnsafeStringView()\n{\n    assignString(string, length);\n}\n\nStringView::StringView(std::string&& string) : UnsafeStringView()\n{\n    assignString(string.data(), string.length());\n}\n\nStringView::StringView(const UnsafeStringView& other)\n: UnsafeStringView(other.m_referenceCount != nullptr ? other : UnsafeStringView())\n{\n    if (m_referenceCount == nullptr) {\n        assignString(other.m_data, other.m_length);\n    }\n}\n\nStringView::StringView(UnsafeStringView&& other)\n: UnsafeStringView(other.m_referenceCount != nullptr ? std::move(other) : UnsafeStringView())\n{\n    if (m_referenceCount == nullptr) {\n        assignString(other.m_data, other.m_length);\n    }\n}\n\nStringView& StringView::operator=(const UnsafeStringView& other)\n{\n    if (other.m_referenceCount != nullptr) {\n        UnsafeStringView::operator=(other);\n    } else {\n        assignString(other.m_data, other.m_length);\n    }\n    return *this;\n}\n\nStringView& StringView::operator=(UnsafeStringView&& other)\n{\n    if (other.m_referenceCount != nullptr) {\n        UnsafeStringView::operator=(std::move(other));\n    } else {\n        assignString(other.m_data, other.m_length);\n    }\n    return *this;\n}\n\n#pragma mark - StringView - Utility\nStringView StringView::formatted(const char* format, ...)\n{\n    size_t size = strlen(format) * 2 + 50;\n    std::string result;\n    va_list ap;\n    do {\n        result.resize(size);\n        va_start(ap, format);\n        int n = vsnprintf((char*) result.data(), size, format, ap);\n        va_end(ap);\n        if (n > -1 && n < (int) size) {\n            result.resize(n);\n            return StringView(std::move(result));\n        }\n        if (n > -1) {\n            size = n + 1;\n        } else {\n            size *= 2;\n        }\n    } while (true);\n    return StringView(std::move(result));\n}\n\nStringView StringView::hexString(const UnsafeData& data)\n{\n    std::ostringstream ss;\n    ss << std::hex << std::setfill('0');\n    for (int i = 0; i < data.size(); i++) {\n        int c = data.buffer()[i];\n        ss << std::setw(2) << c;\n    }\n    return StringView(ss.str());\n}\n\nStringView StringView::makeConstant(const char* string)\n{\n    StringView ret;\n    if (string != nullptr) {\n        ret.m_data = string;\n        ret.m_length = strlen(string);\n        ret.m_referenceCount = (std::atomic<int>*) ConstanceReference;\n    }\n    return ret;\n}\n\nStringView StringView::createConstant(const char* string, size_t length)\n{\n    StringView ret;\n    if (string != nullptr) {\n        if (length == 0) {\n            length = strlen(string);\n        }\n#ifdef __ANDROID__\n        if (tryRetrievePreAllocatedMemory(string)) {\n            ret.m_data = string;\n            ret.m_length = length;\n            ret.m_referenceCount = (std::atomic<int>*) ConstanceReference;\n            return ret;\n        }\n#endif\n        char* data = (char*) malloc((length + 1) * sizeof(char));\n        if (data != nullptr) {\n            memcpy((void*) data, (void*) string, length);\n            data[length] = '\\0';\n        } else {\n            length = 0;\n        }\n        ret.m_data = data;\n        ret.m_length = length;\n        ret.m_referenceCount = (std::atomic<int>*) ConstanceReference;\n    }\n    return ret;\n}\n#ifdef _WIN32\nStringView StringView::createFromWString(const wchar_t* string, size_t length)\n{\n    if (!string || (length == 0 && string[0] == L'\\0')) {\n        return StringView();\n    }\n\n    int srcLen = (length > 0) ? length : -1;\n    int utf8Size = WideCharToMultiByte(CP_UTF8, 0, string, srcLen, nullptr, 0, nullptr, nullptr);\n    if (utf8Size <= 0) {\n        return StringView();\n    }\n\n    std::string utf8Str(utf8Size, 0);\n    WideCharToMultiByte(CP_UTF8, 0, string, srcLen, &utf8Str[0], utf8Size, nullptr, nullptr);\n\n    if (srcLen == -1) {\n        utf8Str.resize(utf8Size - 1);\n    }\n    return utf8Str;\n}\n#endif\n\nbool StringViewComparator::operator()(const StringView& lhs, const StringView& rhs) const\n{\n    return lhs.compare(rhs) < 0;\n}\n\nbool StringViewComparator::operator()(const StringView& lhs, const UnsafeStringView& rhs) const\n{\n    return lhs.compare(rhs) < 0;\n}\n\nbool StringViewComparator::operator()(const UnsafeStringView& lhs, const StringView& rhs) const\n{\n    return lhs.compare(rhs) < 0;\n}\n\nvoid StringViewSet::erase(const UnsafeStringView& value)\n{\n    auto iter = this->find(value);\n    if (iter != this->end()) {\n        this->Super::erase(iter);\n    }\n}\n\n} // namespace WCDB\n\nstd::ostream& operator<<(std::ostream& stream, const WCDB::UnsafeStringView& string)\n{\n    stream.write(string.data(), string.length());\n    return stream;\n}\n"
  },
  {
    "path": "src/common/base/StringView.hpp",
    "content": "//\n// Created by sanhuazhang on 2019/06/16\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"Macro.h\"\n#include \"SysTypes.h\"\n#include <atomic>\n#include <limits>\n#include <map>\n#include <memory>\n#include <set>\n#include <sstream>\n#include <string>\n\nnamespace WCDB {\n\nclass UnsafeData;\ntemplate<typename T, typename Enable = void>\nstruct ColumnIsTextType;\n\nclass WCDB_API UnsafeStringView {\n#pragma mark - UnsafeStringView - Constructor\npublic:\n    UnsafeStringView();\n    UnsafeStringView(const char* string);\n    UnsafeStringView(const char* string, size_t length);\n\n    UnsafeStringView(const UnsafeStringView& other);\n    UnsafeStringView(UnsafeStringView&& other);\n\n    UnsafeStringView& operator=(const UnsafeStringView& other);\n    UnsafeStringView& operator=(UnsafeStringView&& other);\n    bool operator==(const UnsafeStringView& other) const;\n    bool operator!=(const UnsafeStringView& other) const;\n    bool operator<(const UnsafeStringView& other) const;\n    bool operator>(const UnsafeStringView& other) const;\n    const char& operator[](offset_t off) const;\n    operator std::string() const;\n\n    ~UnsafeStringView();\n\n    const char* data() const;\n    size_t length() const;\n    size_t size() const;\n    bool empty() const;\n    const char& at(offset_t off) const;\n    UnsafeStringView subStr(offset_t off, size_t length = 0) const;\n\nprivate:\n    friend class StringView;\n    static constexpr int ConstanceReference = 1;\n    const char* m_data = \"\";\n    size_t m_length = 0;\n    std::atomic<int>* m_referenceCount = nullptr;\n\n#pragma mark - UTF16\npublic:\n#ifdef _WIN32\n    std::wstring getWString() const;\n#endif\n    static UnsafeStringView\n    createFromUTF16(const char16_t* utf16Str, size_t length, char* buffer);\n\nprotected:\n    static size_t changeToUTF8(const char16_t* utf16Str, size_t length, char* buffer);\n\n#pragma mark - UnsafeStringView - Comparison\npublic:\n    int caseInsensitiveCompare(const UnsafeStringView& other) const;\n    bool caseInsensitiveEqual(const UnsafeStringView& other) const;\n\n    bool hasPrefix(const UnsafeStringView& target) const;\n    bool hasSuffix(const UnsafeStringView& target) const;\n    bool contain(const UnsafeStringView& target) const;\n    int compare(const UnsafeStringView& other) const;\n    bool equal(const UnsafeStringView& other) const;\n\n    static constexpr size_t npos = std::numeric_limits<size_t>::max();\n    size_t find(const UnsafeStringView& other, off_t off = 0) const;\n\n#pragma mark - UnsafeStringView - Operations\npublic:\n    uint32_t hash() const;\n\n#pragma mark - UnsafeStringView - Memory Management\npublic:\n    void clear();\n\nprotected:\n    void ensureNewSpace(size_t newSize);\n    void createNewSpace(size_t newSize);\n    void tryClearSpace();\n    void clearSpace();\n\nprivate:\n#pragma mark - UnsafeStringView - Convertible\npublic:\n    template<typename T, typename Enable = void>\n    struct Convertible : public std::false_type {\n    public:\n        static UnsafeStringView asUnsafeStringView(const T&);\n    };\n\n    template<typename T>\n    struct Convertible<T, typename std::enable_if<ColumnIsTextType<T>::value>::type>\n    : public std::true_type {\n    public:\n        static UnsafeStringView asUnsafeStringView(const T& t)\n        {\n            return ColumnIsTextType<T>::asUnderlyingType(t);\n        }\n    };\n\n    template<typename T>\n    struct Convertible<T, std::enable_if_t<std::is_function<T>::value>>\n    : public std::false_type {};\n\n    template<typename T, typename Enable = typename std::enable_if<Convertible<T>::value>::type>\n    UnsafeStringView(const T& t)\n    {\n        *this = Convertible<T>::asUnsafeStringView(t);\n    }\n\n#ifdef __ANDROID__\n\n#pragma mark - UnsafeStringView - PreAllocMemory\npublic:\n    static char** preAllocStringMemorySlot(int count);\n    static void allocStringMemory(char** slot, int size);\n    static void clearAllocatedMemory(int count);\n    static void clearAllPreAllocatedMemory();\n\nprotected:\n    static bool tryRetrievePreAllocatedMemory(const char* string);\n\nprivate:\n    typedef struct PreAllocatedMemory {\n        char** memory;\n        int totalCount;\n        int usedCount;\n    } PreAllocatedMemory;\n    thread_local static PreAllocatedMemory g_preAllocatedMemory;\n\n#endif\n};\n\nclass WCDB_API StringView final : public UnsafeStringView {\n#pragma mark - StringView - Constructor\npublic:\n    explicit StringView();\n    explicit StringView(const char* string);\n    explicit StringView(const char* string, size_t length);\n    explicit StringView(const UnsafeStringView& other);\n    StringView(UnsafeStringView&& other);\n    StringView(std::string&& string);\n\n    StringView& operator=(const UnsafeStringView& other);\n    StringView& operator=(UnsafeStringView&& other);\n\n#pragma mark - StringView - Utility\n    static StringView formatted(const char* format, ...);\n    static StringView hexString(const UnsafeData& data);\n    static StringView makeConstant(const char* string);\n    static StringView createConstant(const char* string, size_t length = 0);\n#ifdef _WIN32\n    static StringView createFromWString(const wchar_t* string, size_t length = 0);\n#endif\n\nprotected:\n    void assignString(const char* content, size_t length);\n\n#pragma mark - UTF16\npublic:\n    static StringView createFromUTF16(const char16_t* utf16Str, size_t length);\n};\n\nstruct WCDB_API StringViewComparator {\n    using is_transparent = std::true_type;\n\n    bool operator()(const StringView& lhs, const StringView& rhs) const;\n\n    bool operator()(const StringView& lhs, const UnsafeStringView& rhs) const;\n    bool operator()(const UnsafeStringView& lhs, const StringView& rhs) const;\n};\n\ntemplate<typename T>\nclass StringViewMap final : public std::map<StringView, T, StringViewComparator> {\nprivate:\n    using Super = std::map<StringView, T, StringViewComparator>;\n\npublic:\n    using std::map<StringView, T, StringViewComparator>::map;\n\n    using Super::erase;\n    void erase(const UnsafeStringView& key)\n    {\n        auto iter = this->find(key);\n        if (iter != this->end()) {\n            this->Super::erase(iter);\n        }\n    }\n\n    using Super::at;\n    T& at(const UnsafeStringView& key) { return this->find(key)->second; }\n    const T& at(const UnsafeStringView& key) const\n    {\n        return this->find(key)->second;\n    }\n\n    void insert_or_assign(const UnsafeStringView& key, const T& value)\n    {\n        StringView stringKey = StringView(key);\n        auto find = Super::find(stringKey);\n        if (find != Super::end()) {\n            find->second = value;\n        } else {\n            Super::insert(std::make_pair(stringKey, value));\n        }\n    }\n    void insert_or_assign(const UnsafeStringView& key, T&& value)\n    {\n        StringView stringKey = StringView(key);\n        auto find = Super::find(stringKey);\n        if (find != Super::end()) {\n            find->second = std::move(value);\n        } else {\n            Super::insert(std::make_pair(stringKey, std::move(value)));\n        }\n    }\n\n    using Super::emplace;\n    auto emplace(const UnsafeStringView& key, const T& value)\n    {\n        return this->Super::emplace(std::make_pair(StringView(key), value));\n    }\n\n    auto emplace(const UnsafeStringView& key, T&& value)\n    {\n        return this->Super::emplace(std::make_pair(StringView(key), std::forward<T>(value)));\n    }\n\n    using Super::operator[];\n    T& operator[](const UnsafeStringView& key)\n    {\n        auto iter = this->find(key);\n        if (iter != this->end()) {\n            return iter->second;\n        }\n        return Super::operator[](StringView(key));\n    }\n};\n\nclass WCDB_API StringViewSet final : public std::set<StringView, StringViewComparator> {\nprivate:\n    using Super = std::set<StringView, StringViewComparator>;\n\npublic:\n    using Super::set;\n\n    using Super::erase;\n    void erase(const UnsafeStringView& value);\n};\n\n} // namespace WCDB\n\nWCDB_API std::ostream&\noperator<<(std::ostream& stream, const WCDB::UnsafeStringView& string);\n"
  },
  {
    "path": "src/common/base/Thread.cpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/23\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"Thread.hpp\"\n#include \"Assertion.hpp\"\n#include \"CrossPlatform.h\"\n#include \"Notifier.hpp\"\n#include \"WCDBError.hpp\"\n#include <cstring>\n#if _WIN32\n#define NOMINMAX\n#include <windows.h>\n#else\n#include <unistd.h>\n#ifdef __linux__\n#include <sys/syscall.h>\n#endif\n#endif\n\nnamespace WCDB {\n\n#pragma mark - Initialize\nThread::Thread(std::thread::id threadId\n#if defined(__APPLE__)\n               ,\n               pthread_t pthreadId\n#endif\n               )\n: m_id(threadId)\n#if defined(__APPLE__)\n, m_pthreadId(pthreadId)\n#endif\n{\n}\n\nThread& Thread::operator=(const std::nullptr_t&)\n{\n    m_id = std::thread::id();\n#if defined(__APPLE__)\n    m_pthreadId = nullptr;\n#endif\n    return *this;\n}\n\nThread::Thread()\n: m_id()\n#if defined(__APPLE__)\n, m_pthreadId(nullptr)\n#endif\n{\n}\n\nThread::~Thread() = default;\n\n#pragma mark - Which\nThread Thread::current()\n{\n#if defined(__APPLE__)\n    return Thread(std::this_thread::get_id(), pthread_self());\n#else\n    return Thread(std::this_thread::get_id());\n#endif\n}\n\nbool Thread::isMain()\n{\n#ifndef _WIN32\n    return pthread_main_np() != 0;\n#else\n    return std::this_thread::get_id() == m_uiThreadId;\n#endif\n}\n\nbool Thread::isCurrentThread() const\n{\n    return m_id == std::this_thread::get_id();\n}\n\nbool Thread::equal(const Thread& other) const\n{\n    return m_id == other.m_id;\n}\n\nbool Thread::operator==(const Thread& other) const\n{\n    return equal(other);\n}\n\nstd::thread::id Thread::m_uiThreadId;\n\nvoid Thread::setUIThreadId(std::thread::id threadId)\n{\n    m_uiThreadId = threadId;\n}\n\nuint64_t Thread::getCurrentThreadId()\n{\n#ifdef __APPLE__\n    uint64_t tid = 0;\n    pthread_threadid_np(nullptr, &tid);\n    return tid;\n#elif _WIN32\n    return (uint64_t) GetCurrentThreadId();\n#elif __linux__\n    return (uint64_t) syscall(SYS_gettid);\n#else\n    return (uint64_t) ::gettid();\n#endif\n}\n\n#pragma mark - Name\nconstexpr int Thread::maxLengthOfAllowedThreadName()\n{\n    return 256;\n}\n\nvoid Thread::setName(const UnsafeStringView& name)\n{\n#ifndef _WIN32\n    WCTAssert(name.length() <= 16) // Thread name is limited to 16 bytes in linus;\n    char buffer[maxLengthOfAllowedThreadName()];\n    memset(buffer, 0, maxLengthOfAllowedThreadName());\n    memcpy(buffer, name.data(), name.length());\n    int ret = pthread_setname_np(buffer);\n    if (ret != 0) {\n        Error error;\n        error.level = Error::Level::Warning;\n        error.setSystemCode(ret, Error::Code::Error);\n        error.infos.insert_or_assign(\"Operation\", \"setThreadName\");\n        Notifier::shared().notify(error);\n        SharedThreadedErrorProne::setThreadedError(std::move(error));\n    }\n#else\n    // See also: http://msdn.microsoft.com/en-us/library/xcb2z8hs.aspx\n    WCTAssert(name.length() <= 16) // Thread name is limited to 16 bytes\n    char buffer[maxLengthOfAllowedThreadName()];\n    memset(buffer, 0, maxLengthOfAllowedThreadName());\n    memcpy(buffer, name.data(), name.length());\n    const DWORD MS_VC_EXCEPTION = 0x406D1388;\n\n#pragma pack(push, 8)\n    typedef struct tagTHREADNAME_INFO {\n        DWORD dwType;     // Must be 0x1000.\n        LPCSTR szName;    // Pointer to name (in user addr space).\n        DWORD dwThreadID; // Thread ID (-1=caller thread).\n        DWORD dwFlags;    // Reserved for future use, must be zero.\n    } THREADNAME_INFO;\n#pragma pack(pop)\n\n    THREADNAME_INFO info;\n    info.dwType = 0x1000;\n    info.szName = buffer;\n    info.dwThreadID = GetCurrentThreadId();\n    info.dwFlags = 0;\n\n#pragma warning(push)\n#pragma warning(disable : 6320 6322)\n    __try {\n        RaiseException(\n        MS_VC_EXCEPTION, 0, sizeof(info) / sizeof(ULONG_PTR), (ULONG_PTR*) &info);\n    } __except (EXCEPTION_CONTINUE_EXECUTION) {\n    }\n#pragma warning(pop)\n#endif\n}\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/base/Thread.hpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/23\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"CrossPlatform.h\"\n#include \"Macro.h\"\n#include \"SharedThreadedErrorProne.hpp\"\n#include \"StringView.hpp\"\n#include <cstddef>\n#include <thread>\n\nnamespace WCDB {\n\nclass Thread final : public SharedThreadedErrorProne {\n#pragma mark - Initialize\npublic:\n    Thread();\n    ~Thread() override;\n    Thread& operator=(const std::nullptr_t&);\n\nprivate:\n    Thread(std::thread::id id\n#if defined(__APPLE__)\n           ,\n           pthread_t pthreadId\n#endif\n    );\n    friend class Conditional;\n    std::thread::id m_id;\n#if defined(__APPLE__)\n    pthread_t m_pthreadId;\n#endif\n    static std::thread::id m_uiThreadId;\n\n#pragma mark - Which\npublic:\n    static Thread current();\n    static bool isMain();\n    static void setUIThreadId(std::thread::id threadId);\n    static uint64_t getCurrentThreadId();\n    bool isCurrentThread() const;\n\n    bool equal(const Thread& other) const;\n    bool operator==(const Thread& other) const;\n\nprivate:\n#pragma mark - Name\npublic:\n    static void setName(const UnsafeStringView& name);\n\nprivate:\n    static constexpr int maxLengthOfAllowedThreadName();\n};\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/base/ThreadLocal.hpp",
    "content": "//\n// Created by sanhuazhang on 2018/09/29\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include <atomic>\n#include <map>\n#include <memory>\n\nnamespace WCDB {\n\ntemplate<typename T>\nclass UntypedThreadLocal {\nprotected:\n    typedef unsigned int Identifier;\n\n    struct ThreadedStorage {\n        std::map<Identifier, T>* ptr;\n        ThreadedStorage() : ptr(new std::map<Identifier, T>()) {}\n        ~ThreadedStorage()\n        {\n            delete ptr;\n            ptr = nullptr;\n        }\n    };\n\n    static Identifier nextIdentifier()\n    {\n        static std::atomic<Identifier>* s_identifier = new std::atomic<Identifier>(0);\n        return ++(*s_identifier);\n    }\n    static std::map<Identifier, T>& threadedStorage()\n    {\n        thread_local ThreadedStorage s_storage;\n        if (s_storage.ptr == nullptr) {\n            s_storage.ptr = new std::map<Identifier, T>();\n        }\n        return *s_storage.ptr;\n    }\n};\n\ntemplate<typename T>\nclass ThreadLocal : public UntypedThreadLocal<T> {\npublic:\n    using UntypedThreadLocal<T>::nextIdentifier;\n    using UntypedThreadLocal<T>::threadedStorage;\n    using Identifier = typename UntypedThreadLocal<T>::Identifier;\n    ThreadLocal(const typename std::enable_if<std::is_default_constructible<T>::value>::type* = nullptr)\n    : m_identifier(nextIdentifier()), m_default()\n    {\n    }\n\n    ThreadLocal(const T& defaultValue)\n    : m_identifier(nextIdentifier()), m_default(defaultValue)\n    {\n    }\n\n    ThreadLocal(T&& defaultValue)\n    : m_identifier(nextIdentifier()), m_default(std::move(defaultValue))\n    {\n    }\n\n    T& getOrCreate()\n    {\n        auto& storage = threadedStorage();\n        auto iter = storage.find(m_identifier);\n        if (iter == storage.end()) {\n            iter = storage.emplace(m_identifier, m_default).first;\n        }\n        return *(&iter->second);\n    }\n\nprivate:\n    const Identifier m_identifier;\n    const T m_default;\n};\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/common/base/ThreadedErrors.cpp",
    "content": "//\n// Created by sanhuazhang on 2018/05/24\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"ThreadedErrors.hpp\"\n#include \"CoreConst.h\"\n#include \"Macro.h\"\n\nnamespace WCDB {\n\nThreadedErrors &ThreadedErrors::shared()\n{\n    static ThreadedErrors *s_threadedErrors = new ThreadedErrors;\n    return *s_threadedErrors;\n}\n\nconst Error &ThreadedErrors::getThreadedError()\n{\n    return m_errors.getOrCreate();\n}\n\nError &&ThreadedErrors::moveThreadedError()\n{\n    return std::move(m_errors.getOrCreate());\n}\n\nvoid ThreadedErrors::setThreadedError(const Error &error)\n{\n    m_errors.getOrCreate() = error;\n}\n\nvoid ThreadedErrors::setThreadedError(Error &&error)\n{\n    m_errors.getOrCreate() = std::move(error);\n}\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/common/base/ThreadedErrors.hpp",
    "content": "//\n// Created by sanhuazhang on 2018/05/24\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"ThreadLocal.hpp\"\n#include \"WCDBError.hpp\"\n\nnamespace WCDB {\n\nclass ThreadedErrors final {\npublic:\n    static ThreadedErrors &shared();\n    const Error &getThreadedError();\n    Error &&moveThreadedError();\n\n    void setThreadedError(const Error &error);\n    void setThreadedError(Error &&error);\n\nprivate:\n    ThreadLocal<Error> m_errors;\n};\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/common/base/Time.cpp",
    "content": "//\n// Created by sanhuazhang on 2018/06/08\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"Time.hpp\"\n#include \"Notifier.hpp\"\n#include \"StringView.hpp\"\n#include \"ThreadedErrors.hpp\"\n#include <iomanip>\n#include <sstream>\n\n#ifdef __APPLE__\n#include <mach/mach_init.h>\n#include <mach/thread_act.h>\n#include <mach/thread_info.h>\n#elif _WIN32\n#define NOMINMAX\n#include <windows.h>\n#else\n#include <pthread.h>\n#include <time.h>\n#endif\n\nnamespace WCDB {\n\nTime::Time() = default;\n\nTime::Time(const Super &super) : Super(super)\n{\n}\n\nTime::Time(Super &&super) : Super(std::move(super))\n{\n}\n\nTime::Time(const struct timespec &ts)\n: Super(std::chrono::system_clock::time_point{\n  std::chrono::duration_cast<std::chrono::system_clock::duration>(\n  std::chrono::seconds{ ts.tv_sec } + std::chrono::nanoseconds{ ts.tv_nsec }) })\n{\n}\n\nTime::Time(const uint64_t &second)\n: Super(std::chrono::system_clock::time_point{\n  std::chrono::duration_cast<std::chrono::system_clock::duration>(std::chrono::seconds{ second }) })\n{\n}\n\nTime::~Time() = default;\n\nTime Time::now()\n{\n    return std::chrono::system_clock::now();\n}\n\nuint64_t Time::currentThreadCPUTimeInMicroseconds()\n{\n#ifdef __APPLE__\n    thread_basic_info_data_t basic_info;\n    mach_msg_type_number_t count = THREAD_BASIC_INFO_COUNT;\n    kern_return_t result = thread_info(\n    mach_thread_self(), THREAD_BASIC_INFO, (thread_info_t) &basic_info, &count);\n    if (result != KERN_SUCCESS) {\n        return 0;\n    }\n    return basic_info.user_time.seconds * 1000000 + basic_info.user_time.microseconds\n           + basic_info.system_time.seconds * 1000000 + basic_info.system_time.microseconds;\n#elif _WIN32\n    HANDLE currentThread = GetCurrentThread();\n    FILETIME creationTime, exitTime, kernelTime, userTime;\n    if (GetThreadTimes(currentThread, &creationTime, &exitTime, &kernelTime, &userTime)) {\n        uint64_t ret = ((uint64_t) kernelTime.dwHighDateTime << 32) + kernelTime.dwLowDateTime;\n        ret += ((uint64_t) userTime.dwHighDateTime << 32) + userTime.dwLowDateTime;\n        ret /= 10;\n        return ret;\n    }\n    return 0;\n#else\n    clockid_t cid;\n    struct timespec ts;\n    if (pthread_getcpuclockid(pthread_self(), &cid) == 0 && clock_gettime(cid, &ts) == 0) {\n        return ts.tv_sec * 1000000 + ts.tv_nsec / 1000;\n    }\n    return 0;\n#endif\n}\n\nstd::time_t Time::seconds() const\n{\n    return (std::time_t) std::chrono::duration_cast<std::chrono::seconds>(time_since_epoch())\n    .count();\n}\n\nstd::time_t Time::nanoseconds() const\n{\n    return (std::time_t) std::chrono::duration_cast<std::chrono::nanoseconds>(time_since_epoch())\n    .count();\n}\n\nbool Time::empty() const\n{\n    return time_since_epoch().count() == 0;\n}\n\nOptional<StringView> Time::stringify() const\n{\n    std::time_t nanoseconds\n    = (std::time_t) std::chrono::duration_cast<std::chrono::nanoseconds>(time_since_epoch())\n      .count();\n    std::time_t secondsPart = nanoseconds / (int) 1E9;\n    struct tm tm;\n    int err = 0;\n#ifndef _WIN32\n    if (localtime_r(&secondsPart, &tm) == nullptr) {\n        err = errno;\n#else\n    err = localtime_s(&tm, &secondsPart);\n    if (err) {\n#endif\n        Error error;\n        error.level = Error::Level::Error;\n        error.setSystemCode(err, Error::Code::Error);\n        Notifier::shared().notify(error);\n        setThreadedError(std::move(error));\n        return NullOpt;\n    }\n    std::time_t nanosecondsPart = nanoseconds % (int) 1E9;\n    std::ostringstream stream;\n    stream << std::put_time(&tm, \"%Y-%m-%d_%H-%M-%S\") << \".\" << nanosecondsPart;\n    return StringView(stream.str());\n}\n\nSteadyClock::SteadyClock() = default;\n\nSteadyClock::SteadyClock(const Super &super) : Super(super)\n{\n}\n\nSteadyClock::SteadyClock(Super &&super) : Super(std::move(super))\n{\n}\n\nSteadyClock SteadyClock::now()\n{\n    return std::chrono::steady_clock::now();\n}\n\ndouble SteadyClock::timeIntervalSinceSteadyClock(const SteadyClock &other) const\n{\n    return std::chrono::duration_cast<std::chrono::nanoseconds>(*this - other).count() / 1E9;\n}\n\ndouble SteadyClock::timeIntervalSinceNow() const\n{\n    return timeIntervalSinceSteadyClock(SteadyClock::now());\n}\n\ndouble SteadyClock::timeIntervalSinceSteadyClockToNow(const SteadyClock &other)\n{\n    return SteadyClock::now().timeIntervalSinceSteadyClock(other);\n}\n\nSteadyClock SteadyClock::steadyClockByAddingTimeInterval(double seconds) const\n{\n    return SteadyClock(*this + std::chrono::nanoseconds((long long) (seconds * 1E9)));\n}\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/common/base/Time.hpp",
    "content": "//\n// Created by sanhuazhang on 2018/06/08\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"SharedThreadedErrorProne.hpp\"\n#include \"StringView.hpp\"\n#include \"WCDBOptional.hpp\"\n#include <chrono>\n#include <ctime>\n\nnamespace WCDB {\n\nclass Time final : public std::chrono::system_clock::time_point, public SharedThreadedErrorProne {\npublic:\n    using Super = std::chrono::system_clock::time_point;\n    Time();\n    Time(const Super &super);\n    Time(Super &&super);\n    Time(const struct timespec &ts);\n    Time(const uint64_t &second);\n    ~Time() override;\n\n    static Time now();\n    static uint64_t currentThreadCPUTimeInMicroseconds();\n\n    std::time_t seconds() const;\n    std::time_t nanoseconds() const;\n    bool empty() const;\n    Optional<StringView> stringify() const;\n};\n\nclass SteadyClock final : public std::chrono::steady_clock::time_point {\npublic:\n    using Super = std::chrono::steady_clock::time_point;\n    SteadyClock();\n    SteadyClock(const Super &super);\n    SteadyClock(Super &&super);\n\n    template<typename T, typename U>\n    SteadyClock(const std::chrono::duration<T, U> &duration)\n    : Super(std::chrono::duration_cast<std::chrono::steady_clock::duration>(duration))\n    {\n    }\n\n    SteadyClock steadyClockByAddingTimeInterval(double seconds) const;\n\n    double timeIntervalSinceSteadyClock(const SteadyClock &other) const;\n\n    double timeIntervalSinceNow() const;\n\n    static double timeIntervalSinceSteadyClockToNow(const SteadyClock &other);\n\n    static SteadyClock now();\n};\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/common/base/UnsafeData.cpp",
    "content": "//\n// Created by sanhuazhang on 2018/07/19\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"UnsafeData.hpp\"\n#include \"Assertion.hpp\"\n#include <string.h>\n#include <zlib.h>\n\nnamespace WCDB {\n\n#pragma mark - Initialize\nUnsafeData::UnsafeData() : m_buffer(nullptr), m_size(0), m_sharedBuffer(nullptr)\n{\n}\n\nUnsafeData::UnsafeData(unsigned char *buffer, size_t size)\n: m_buffer(buffer), m_size(size), m_sharedBuffer(nullptr)\n{\n}\n\nUnsafeData::UnsafeData(const UnsafeData &other)\n: m_buffer(other.m_buffer), m_size(other.m_size), m_sharedBuffer(other.m_sharedBuffer)\n{\n}\n\nUnsafeData::UnsafeData(UnsafeData &&other)\n: m_buffer(other.m_buffer)\n, m_size(other.m_size)\n, m_sharedBuffer(std::move(other.m_sharedBuffer))\n{\n    other.m_buffer = nullptr;\n    other.m_size = 0;\n}\n\nUnsafeData::~UnsafeData() = default;\n\nUnsafeData &UnsafeData::operator=(const UnsafeData &other)\n{\n    m_buffer = other.m_buffer;\n    m_size = other.m_size;\n    m_sharedBuffer = other.m_sharedBuffer;\n    return *this;\n}\n\nUnsafeData &UnsafeData::operator=(UnsafeData &&other)\n{\n    m_buffer = other.m_buffer;\n    m_size = other.m_size;\n    m_sharedBuffer = std::move(other.m_sharedBuffer);\n    other.m_buffer = nullptr;\n    other.m_size = 0;\n    return *this;\n}\n\nbool UnsafeData::operator==(const UnsafeData &other) const\n{\n    if (m_size != other.size()) {\n        return false;\n    }\n    if (m_size > 0 && memcmp(m_buffer, other.m_buffer, m_size) != 0) {\n        return false;\n    }\n    return true;\n}\n\nbool UnsafeData::operator!=(const UnsafeData &other) const\n{\n    return !operator==(other);\n}\n\nUnsafeData::UnsafeData(unsigned char *buffer, size_t size, const SharedBuffer &sharedBuffer)\n: m_buffer(buffer), m_size(size), m_sharedBuffer(sharedBuffer)\n{\n}\n\nUnsafeData::SharedBuffer\nUnsafeData::makeSharedBuffer(unsigned char *buffer, size_t size, SharedBuffer::OnRecycled onRecycle)\n{\n    return SharedBuffer(SharedData(buffer, size), onRecycle);\n}\n\nconst UnsafeData UnsafeData::immutable(const unsigned char *buffer, size_t size)\n{\n    return UnsafeData((unsigned char *) buffer, size);\n}\n\n#pragma mark - Subdata\nUnsafeData UnsafeData::subdata(size_t size) const\n{\n    WCTRemedialAssert(size <= m_size, \"Memory cross-border\", return UnsafeData(););\n    return subdata(0, size);\n}\n\nUnsafeData UnsafeData::subdata(offset_t offset, size_t size) const\n{\n    if (size == 0) {\n        return null();\n    }\n    WCTRemedialAssert(\n    offset + size <= m_size, \"Memory cross-border\", return UnsafeData(););\n    return UnsafeData(m_buffer + offset, size, m_sharedBuffer);\n}\n\n#pragma mark - Empty\nconst UnsafeData &UnsafeData::null()\n{\n    static const UnsafeData *s_null = new UnsafeData;\n    return *s_null;\n}\n\nbool UnsafeData::empty() const\n{\n    return m_size == 0;\n}\n\nunsigned char *UnsafeData::emptyBuffer()\n{\n    static unsigned char s_empty = '\\0';\n    return &s_empty;\n}\n\n#pragma mark - Basic\nsize_t UnsafeData::size() const\n{\n    return m_size;\n}\n\nuint32_t UnsafeData::hash() const\n{\n    // crc32 is pretty fast and have more collisions. BUT it's enough for checking whether corrupted.\n    return (uint32_t) crc32(0, buffer(), (uint32_t) size());\n}\n\nconst unsigned char *UnsafeData::buffer() const\n{\n    return m_buffer ? m_buffer : emptyBuffer();\n}\n\nunsigned char *UnsafeData::buffer()\n{\n    return m_buffer ? m_buffer : emptyBuffer();\n}\n\nbool UnsafeData::hasSharedBuffer() const\n{\n    return m_sharedBuffer != nullptr;\n}\n\nUnsafeData::SharedData::SharedData(unsigned char *buffer, size_t size)\n: buffer(buffer), size(size)\n{\n}\n\nUnsafeData::SharedData::SharedData(std::nullptr_t) : buffer(nullptr), size(0)\n{\n}\n\nbool UnsafeData::SharedData::operator==(const std::nullptr_t &) const\n{\n    return buffer == nullptr;\n}\n\nbool UnsafeData::SharedData::operator!=(const std::nullptr_t &) const\n{\n    return buffer != nullptr;\n}\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/base/UnsafeData.hpp",
    "content": "//\n// Created by sanhuazhang on 2018/07/19\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"Recyclable.hpp\"\n#include \"SharedThreadedErrorProne.hpp\"\n#include \"SysTypes.h\"\n#include <memory>\n#include <stdio.h>\n#include <stdlib.h>\n#include <type_traits>\n#include <vector>\n\nnamespace WCDB {\n\ntemplate<typename T, typename Enable = void>\nstruct ColumnIsBLOBType;\n\nclass WCDB_API UnsafeData : protected SharedThreadedErrorProne {\n#pragma mark - Initialize\npublic:\n    template<typename T, typename Enable = void>\n    struct Convertible : public std::false_type {\n    public:\n        static UnsafeData asUnsafeData(const T &);\n    };\n\n    template<typename T>\n    struct Convertible<T, typename std::enable_if<ColumnIsBLOBType<T>::value>::type>\n    : public std::true_type {\n    public:\n        static UnsafeData asUnsafeData(const T &t)\n        {\n            return ColumnIsBLOBType<T>::asUnderlyingType(t);\n        }\n    };\n\n    template<typename T, typename Enable = typename std::enable_if<Convertible<T>::value>::type>\n    UnsafeData(const T &t)\n    {\n        *this = Convertible<T>::asUnsafeData(t);\n    }\n\n    UnsafeData();\n    UnsafeData(UnsafeData &&other);\n    UnsafeData(const UnsafeData &other);\n    virtual ~UnsafeData();\n\n    UnsafeData &operator=(const UnsafeData &other);\n    UnsafeData &operator=(UnsafeData &&other);\n    bool operator==(const UnsafeData &other) const;\n    bool operator!=(const UnsafeData &other) const;\n\n    UnsafeData(unsigned char *buffer, size_t size);\n\n    static const UnsafeData immutable(const unsigned char *buffer, size_t size);\n\nprotected:\n    unsigned char *m_buffer;\n    size_t m_size;\n\n#pragma mark - SharedBuffer\nprotected:\n    struct SharedData {\n        SharedData(unsigned char *buffer, size_t size);\n        SharedData(std::nullptr_t p);\n        bool operator==(const std::nullptr_t &) const;\n        bool operator!=(const std::nullptr_t &) const;\n        unsigned char *buffer;\n        size_t size;\n    };\n    typedef Recyclable<SharedData> SharedBuffer;\n    static SharedBuffer\n    makeSharedBuffer(unsigned char *buffer, size_t size, SharedBuffer::OnRecycled onRecycle);\n\n    UnsafeData(unsigned char *buffer, size_t size, const SharedBuffer &sharedBuffer);\n    SharedBuffer m_sharedBuffer;\n\n#pragma mark - Subdata\npublic:\n    UnsafeData subdata(size_t size) const;\n    UnsafeData subdata(offset_t offset, size_t size) const;\n\n#pragma mark - Empty\npublic:\n    static const UnsafeData &null();\n    bool empty() const;\n\nprivate:\n    static unsigned char *emptyBuffer();\n\n#pragma mark - Basic\npublic:\n    size_t size() const;\n    uint32_t hash() const;\n\n    //Nota that buffer will never be null.\n    const unsigned char *buffer() const;\n    unsigned char *buffer();\n\n    bool hasSharedBuffer() const;\n};\n\n}; // namespace WCDB\n"
  },
  {
    "path": "src/common/base/WCDBError.cpp",
    "content": "//\n// Created by sanhuazhang on 2018/05/19\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"WCDBError.hpp\"\n#include \"Assertion.hpp\"\n#include \"CoreConst.h\"\n#include \"CrossPlatform.h\"\n#include \"SQLite.h\"\n#include \"StringView.hpp\"\n#include <cstring>\n#include <sstream>\n#include <system_error>\n#ifdef _WIN32\n#include <windows.h>\n#endif\n\nnamespace WCDB {\n\n// Code\nstatic_assert((int) Error::Code::OK == SQLITE_OK, \"\");\nstatic_assert((int) Error::Code::Error == SQLITE_ERROR, \"\");\nstatic_assert((int) Error::Code::Internal == SQLITE_INTERNAL, \"\");\nstatic_assert((int) Error::Code::Permission == SQLITE_PERM, \"\");\nstatic_assert((int) Error::Code::Abort == SQLITE_ABORT, \"\");\nstatic_assert((int) Error::Code::Busy == SQLITE_BUSY, \"\");\nstatic_assert((int) Error::Code::Locked == SQLITE_LOCKED, \"\");\nstatic_assert((int) Error::Code::NoMemory == SQLITE_NOMEM, \"\");\nstatic_assert((int) Error::Code::Readonly == SQLITE_READONLY, \"\");\nstatic_assert((int) Error::Code::Interrupt == SQLITE_INTERRUPT, \"\");\nstatic_assert((int) Error::Code::IOError == SQLITE_IOERR, \"\");\nstatic_assert((int) Error::Code::Corrupt == SQLITE_CORRUPT, \"\");\nstatic_assert((int) Error::Code::NotFound == SQLITE_NOTFOUND, \"\");\nstatic_assert((int) Error::Code::Full == SQLITE_FULL, \"\");\nstatic_assert((int) Error::Code::CantOpen == SQLITE_CANTOPEN, \"\");\nstatic_assert((int) Error::Code::Protocol == SQLITE_PROTOCOL, \"\");\nstatic_assert((int) Error::Code::Empty == SQLITE_EMPTY, \"\");\nstatic_assert((int) Error::Code::Schema == SQLITE_SCHEMA, \"\");\nstatic_assert((int) Error::Code::Exceed == SQLITE_TOOBIG, \"\");\nstatic_assert((int) Error::Code::Constraint == SQLITE_CONSTRAINT, \"\");\nstatic_assert((int) Error::Code::Mismatch == SQLITE_MISMATCH, \"\");\nstatic_assert((int) Error::Code::Misuse == SQLITE_MISUSE, \"\");\nstatic_assert((int) Error::Code::NoLargeFileSupport == SQLITE_NOLFS, \"\");\nstatic_assert((int) Error::Code::Authorization == SQLITE_AUTH, \"\");\nstatic_assert((int) Error::Code::Format == SQLITE_FORMAT, \"\");\nstatic_assert((int) Error::Code::Range == SQLITE_RANGE, \"\");\nstatic_assert((int) Error::Code::NotADatabase == SQLITE_NOTADB, \"\");\nstatic_assert((int) Error::Code::Notice == SQLITE_NOTICE, \"\");\nstatic_assert((int) Error::Code::Warning == SQLITE_WARNING, \"\");\nstatic_assert((int) Error::Code::Row == SQLITE_ROW, \"\");\nstatic_assert((int) Error::Code::Done == SQLITE_DONE, \"\");\n\n// ExtCode\nstatic_assert((int) Error::ExtCode::ErrorMissingCollseq == SQLITE_ERROR_MISSING_COLLSEQ, \"\");\nstatic_assert((int) Error::ExtCode::ErrorRetry == SQLITE_ERROR_RETRY, \"\");\nstatic_assert((int) Error::ExtCode::ErrorSnapshot == SQLITE_ERROR_SNAPSHOT, \"\");\nstatic_assert((int) Error::ExtCode::IOErrorRead == SQLITE_IOERR_READ, \"\");\nstatic_assert((int) Error::ExtCode::IOErrorShortRead == SQLITE_IOERR_SHORT_READ, \"\");\nstatic_assert((int) Error::ExtCode::IOErrorWrite == SQLITE_IOERR_WRITE, \"\");\nstatic_assert((int) Error::ExtCode::IOErrorFsync == SQLITE_IOERR_FSYNC, \"\");\nstatic_assert((int) Error::ExtCode::IOErrorDirFsync == SQLITE_IOERR_DIR_FSYNC, \"\");\nstatic_assert((int) Error::ExtCode::IOErrorTruncate == SQLITE_IOERR_TRUNCATE, \"\");\nstatic_assert((int) Error::ExtCode::IOErrorFstat == SQLITE_IOERR_FSTAT, \"\");\nstatic_assert((int) Error::ExtCode::IOErrorUnlock == SQLITE_IOERR_UNLOCK, \"\");\nstatic_assert((int) Error::ExtCode::IOErrorRdlock == SQLITE_IOERR_RDLOCK, \"\");\nstatic_assert((int) Error::ExtCode::IOErrorDelete == SQLITE_IOERR_DELETE, \"\");\nstatic_assert((int) Error::ExtCode::IOErrorBlocked == SQLITE_IOERR_BLOCKED, \"\");\nstatic_assert((int) Error::ExtCode::IOErrorNoMemory == SQLITE_IOERR_NOMEM, \"\");\nstatic_assert((int) Error::ExtCode::IOErrorAccess == SQLITE_IOERR_ACCESS, \"\");\nstatic_assert((int) Error::ExtCode::IOErrorCheckReservedLock == SQLITE_IOERR_CHECKRESERVEDLOCK,\n              \"\");\nstatic_assert((int) Error::ExtCode::IOErrorLock == SQLITE_IOERR_LOCK, \"\");\nstatic_assert((int) Error::ExtCode::IOErrorClose == SQLITE_IOERR_CLOSE, \"\");\nstatic_assert((int) Error::ExtCode::IOErrorDirClose == SQLITE_IOERR_DIR_CLOSE, \"\");\nstatic_assert((int) Error::ExtCode::IOErrorShmOpen == SQLITE_IOERR_SHMOPEN, \"\");\nstatic_assert((int) Error::ExtCode::IOErrorShmSize == SQLITE_IOERR_SHMSIZE, \"\");\nstatic_assert((int) Error::ExtCode::IOErrorShmLock == SQLITE_IOERR_SHMLOCK, \"\");\nstatic_assert((int) Error::ExtCode::IOErrorShmMap == SQLITE_IOERR_SHMMAP, \"\");\nstatic_assert((int) Error::ExtCode::IOErrorSeek == SQLITE_IOERR_SEEK, \"\");\nstatic_assert((int) Error::ExtCode::IOErrorDeleteNoEntry == SQLITE_IOERR_DELETE_NOENT, \"\");\nstatic_assert((int) Error::ExtCode::IOErrorMmap == SQLITE_IOERR_MMAP, \"\");\nstatic_assert((int) Error::ExtCode::IOErrorGetTempPath == SQLITE_IOERR_GETTEMPPATH, \"\");\nstatic_assert((int) Error::ExtCode::IOErrorConvPath == SQLITE_IOERR_CONVPATH, \"\");\nstatic_assert((int) Error::ExtCode::IOErrorVnode == SQLITE_IOERR_VNODE, \"\");\nstatic_assert((int) Error::ExtCode::IOErrorAuthorization == SQLITE_IOERR_AUTH, \"\");\nstatic_assert((int) Error::ExtCode::IOErrorBeginAtomic == SQLITE_IOERR_BEGIN_ATOMIC, \"\");\nstatic_assert((int) Error::ExtCode::IOErrorCommitAtomic == SQLITE_IOERR_COMMIT_ATOMIC, \"\");\nstatic_assert((int) Error::ExtCode::IOErrorRollbackAtomic == SQLITE_IOERR_ROLLBACK_ATOMIC, \"\");\nstatic_assert((int) Error::ExtCode::LockedSharedCache == SQLITE_LOCKED_SHAREDCACHE, \"\");\nstatic_assert((int) Error::ExtCode::LockedVirtualTable == SQLITE_LOCKED_VTAB, \"\");\nstatic_assert((int) Error::ExtCode::BusyRecovery == SQLITE_BUSY_RECOVERY, \"\");\nstatic_assert((int) Error::ExtCode::BusySnapshot == SQLITE_BUSY_SNAPSHOT, \"\");\nstatic_assert((int) Error::ExtCode::CantOpenNoTempDir == SQLITE_CANTOPEN_NOTEMPDIR, \"\");\nstatic_assert((int) Error::ExtCode::CantOpenIsDir == SQLITE_CANTOPEN_ISDIR, \"\");\nstatic_assert((int) Error::ExtCode::CantOpenFullPath == SQLITE_CANTOPEN_FULLPATH, \"\");\nstatic_assert((int) Error::ExtCode::CantOpenConvPath == SQLITE_CANTOPEN_CONVPATH, \"\");\nstatic_assert((int) Error::ExtCode::CantOpenDirtyWal == SQLITE_CANTOPEN_DIRTYWAL, \"\");\nstatic_assert((int) Error::ExtCode::CorruptVirtualTable == SQLITE_CORRUPT_VTAB, \"\");\nstatic_assert((int) Error::ExtCode::CorruptSequence == SQLITE_CORRUPT_SEQUENCE, \"\");\nstatic_assert((int) Error::ExtCode::ReadonlyRecovery == SQLITE_READONLY_RECOVERY, \"\");\nstatic_assert((int) Error::ExtCode::ReadonlyCantLock == SQLITE_READONLY_CANTLOCK, \"\");\nstatic_assert((int) Error::ExtCode::ReadonlyRollback == SQLITE_READONLY_ROLLBACK, \"\");\nstatic_assert((int) Error::ExtCode::ReadonlyDatabaseMoved == SQLITE_READONLY_DBMOVED, \"\");\nstatic_assert((int) Error::ExtCode::ReadonlyCantInit == SQLITE_READONLY_CANTINIT, \"\");\nstatic_assert((int) Error::ExtCode::ReadonlyDirectory == SQLITE_READONLY_DIRECTORY, \"\");\nstatic_assert((int) Error::ExtCode::AbortRollback == SQLITE_ABORT_ROLLBACK, \"\");\nstatic_assert((int) Error::ExtCode::ConstraintCheck == SQLITE_CONSTRAINT_CHECK, \"\");\nstatic_assert((int) Error::ExtCode::ConstraintCommitHook == SQLITE_CONSTRAINT_COMMITHOOK, \"\");\nstatic_assert((int) Error::ExtCode::ConstraintForeignKey == SQLITE_CONSTRAINT_FOREIGNKEY, \"\");\nstatic_assert((int) Error::ExtCode::ConstraintFunction == SQLITE_CONSTRAINT_FUNCTION, \"\");\nstatic_assert((int) Error::ExtCode::ConstraintNotNull == SQLITE_CONSTRAINT_NOTNULL, \"\");\nstatic_assert((int) Error::ExtCode::ConstraintPrimaryKey == SQLITE_CONSTRAINT_PRIMARYKEY, \"\");\nstatic_assert((int) Error::ExtCode::ConstraintTrigger == SQLITE_CONSTRAINT_TRIGGER, \"\");\nstatic_assert((int) Error::ExtCode::ConstraintUnique == SQLITE_CONSTRAINT_UNIQUE, \"\");\nstatic_assert((int) Error::ExtCode::ConstraintVirtualTable == SQLITE_CONSTRAINT_VTAB, \"\");\nstatic_assert((int) Error::ExtCode::ConstraintRowID == SQLITE_CONSTRAINT_ROWID, \"\");\nstatic_assert((int) Error::ExtCode::NoticeRecoverWal == SQLITE_NOTICE_RECOVER_WAL, \"\");\nstatic_assert((int) Error::ExtCode::NoticeRecoverRollback == SQLITE_NOTICE_RECOVER_ROLLBACK, \"\");\nstatic_assert((int) Error::ExtCode::WarningAutoIndex == SQLITE_WARNING_AUTOINDEX, \"\");\nstatic_assert((int) Error::ExtCode::AuthorizationUser == SQLITE_AUTH_USER, \"\");\nstatic_assert((int) Error::ExtCode::OKLoadPermanently == SQLITE_OK_LOAD_PERMANENTLY, \"\");\n\n#pragma mark - Initialize\nError::Error() : level(Level::Ignore), m_code(Code::OK)\n{\n}\n\nError::Error(Code code, Level level_, const UnsafeStringView& message)\n: level(level_)\n{\n    setCode(code, message);\n}\n\nError::Error(Error&& other)\n: level(other.level)\n, m_code(other.m_code)\n, m_message(std::move(other.m_message))\n, infos(std::move(other.infos))\n{\n    other.level = Level::Ignore;\n    other.m_code = Code::OK;\n    other.m_message.clear();\n}\n\nError::Error(const Error& other)\n: level(other.level)\n, m_code(other.m_code)\n, m_message(std::move(other.m_message))\n, infos(std::move(other.infos))\n{\n}\n\nError& Error::operator=(Error&& other)\n{\n    level = other.level;\n    m_code = other.m_code;\n    m_message = std::move(other.m_message);\n    infos = std::move(other.infos);\n    other.level = Level::Ignore;\n    other.m_code = Code::OK;\n    other.m_message.clear();\n    return *this;\n}\n\nError& Error::operator=(const Error& other)\n{\n    level = other.level;\n    m_code = other.m_code;\n    m_message = std::move(other.m_message);\n    infos = std::move(other.infos);\n    return *this;\n}\n\n#pragma mark - Level\nbool Error::isIgnorable() const\n{\n    return level == Level::Ignore;\n}\n\n#pragma mark - Code\nbool Error::isError(int rc)\n{\n    return rc != SQLITE_OK && rc != SQLITE_ROW && rc != SQLITE_DONE;\n}\n\nError::Code Error::rc2c(int rc)\n{\n    return (Error::Code) (rc & 0xff);\n}\n\nint Error::c2rc(Error::Code code)\n{\n    return (int) code;\n}\n\nvoid Error::setCode(Code code, const UnsafeStringView& message)\n{\n    m_code = code;\n    if (message.empty()) {\n        m_message = UnsafeStringView(codeName(code));\n    } else {\n        m_message = message;\n    }\n}\n\nvoid Error::setSystemCode(int systemCode, Code codeIfUnresolved, const UnsafeStringView& message)\n{\n    Code code;\n    switch (systemCode) {\n    case EIO:\n        code = Code::IOError;\n        break;\n    case ENOMEM:\n        code = Code::NoMemory;\n        break;\n    case EACCES:\n        code = Code::Permission;\n        break;\n    case EBUSY:\n        code = Code::Busy;\n        break;\n    case ENOSPC:\n        code = Code::Full;\n        break;\n    case EAUTH:\n        code = Code::Authorization;\n        break;\n    case ENOENT:\n        code = Code::NotFound;\n        break;\n    default:\n        code = codeIfUnresolved;\n        break;\n    }\n#ifdef _WIN32\n    setCode(code, message.empty() ? StringView::createFromWString(_wcserror(systemCode)) : message);\n#else\n    setCode(code, message.empty() ? strerror(systemCode) : message);\n#endif\n    infos.insert_or_assign(ErrorStringKeySource, ErrorSourceSystem);\n    infos.insert_or_assign(ErrorIntKeyExtCode, systemCode);\n}\n\n#ifdef _WIN32\nvoid Error::setWinSystemCode(int systemCode, Code code, const UnsafeStringView& message)\n{\n    if (!message.empty()) {\n        setCode(code, message);\n    } else if (systemCode != 0) {\n        LPWSTR buffer = nullptr;\n        DWORD size = FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,\n                                    nullptr,\n                                    systemCode,\n                                    MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),\n                                    reinterpret_cast<LPWSTR>(&buffer),\n                                    0,\n                                    nullptr);\n        if (size == 0) {\n            setCode(code, \"FormatMessageW failed\");\n        } else {\n            setCode(code, StringView::createFromWString(buffer, size));\n            LocalFree(buffer);\n        }\n    }\n    infos.insert_or_assign(ErrorStringKeySource, ErrorSourceSystem);\n    infos.insert_or_assign(ErrorIntKeyExtCode, systemCode);\n}\n#endif\n\nvoid Error::setSQLiteCode(int rc, const UnsafeStringView& message)\n{\n    Code code = rc2c(rc);\n    setCode(code, message.empty() ? sqlite3_errstr(rc) : message);\n    if (c2rc(code) == rc) {\n        infos.erase(ErrorIntKeyExtCode);\n    } else {\n        infos.insert_or_assign(ErrorIntKeyExtCode, rc);\n    }\n    infos.insert_or_assign(ErrorStringKeySource, ErrorSourceSQLite);\n    if (code == Code::CantOpen || code == Code::IOError) {\n#ifndef _WIN32\n        infos.insert_or_assign(\"SystemErrno\", errno);\n        infos.insert_or_assign(\"SystemErrMsg\", strerror(errno));\n#else\n        int err = GetLastError();\n        infos.insert_or_assign(\"SystemErrno\", err);\n        LPWSTR buffer = nullptr;\n        DWORD size = FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,\n                                    nullptr,\n                                    err,\n                                    MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),\n                                    reinterpret_cast<LPWSTR>(&buffer),\n                                    0,\n                                    nullptr);\n        if (size == 0) {\n            infos.insert_or_assign(\"SystemErrMsg\", \"FormatMessageW failed\");\n        } else {\n            infos.insert_or_assign(\"SystemErrMsg\", StringView::createFromWString(buffer, size));\n            LocalFree(buffer);\n        }\n#endif\n    }\n}\n\nError::Code Error::code() const\n{\n    return m_code;\n}\n\nbool Error::isOK() const\n{\n    return m_code == Code::OK;\n}\n\nbool Error::isCorruption() const\n{\n    return m_code == Error::Code::Corrupt || m_code == Error::Code::NotADatabase\n           || (m_code == Error::Code::Error && m_message.contain(Syntax::malformedSchemaMsg));\n}\n\n#pragma mark - ExtCode\nError::ExtCode Error::rc2ec(int rc)\n{\n    return (Error::ExtCode) rc;\n}\n\nconst StringView& Error::getMessage() const\n{\n    return m_message;\n}\n\n#pragma mark - Common Info\nUnsafeStringView Error::getPath() const\n{\n    auto iter = infos.find(ErrorStringKeyPath);\n    if (iter != infos.end()) {\n        return iter->second.textValue();\n    }\n    return UnsafeStringView();\n}\n\nUnsafeStringView Error::getAssociatePath() const\n{\n    auto iter = infos.find(ErrorStringKeyAssociatePath);\n    if (iter != infos.end()) {\n        return iter->second.textValue();\n    }\n    return UnsafeStringView();\n}\n\nUnsafeStringView Error::getSQL() const\n{\n    auto iter = infos.find(ErrorStringKeySQL);\n    if (iter != infos.end()) {\n        return iter->second.textValue();\n    }\n    return UnsafeStringView();\n}\n\nTag Error::getTag() const\n{\n    auto iter = infos.find(ErrorIntKeyTag);\n    if (iter != infos.end()) {\n        return iter->second.intValue();\n    }\n    return Tag::invalid();\n}\n\nError::ExtCode Error::getExtCode() const\n{\n    auto iter = infos.find(ErrorIntKeyExtCode);\n    if (iter != infos.end()) {\n        return rc2ec((int) iter->second.intValue());\n    }\n    return rc2ec(0);\n}\n\n#pragma mark - Description\nStringView Error::getDescription() const\n{\n    WCTAssert(isError((int) code()));\n    //    WCTAssert(!m_message.empty());\n    std::ostringstream stream;\n    stream << \"[\" << levelName(level) << \": \" << (int) code() << \", \" << m_message << \"]\";\n\n    for (const auto& info : infos) {\n        stream << \", \" << info.first;\n        switch (info.second.getType()) {\n        case Value::Type::Text:\n            stream << \":\" << info.second.textValue();\n            break;\n        case Value::Type::Integer:\n            stream << \":\" << info.second.intValue();\n            break;\n        case Value::Type::Float:\n            stream << \":\" << info.second.floatValue();\n            break;\n        default:\n            break;\n        }\n    }\n    return StringView(stream.str());\n}\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/common/base/WCDBError.hpp",
    "content": "//\n// Created by sanhuazhang on 2018/05/19\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"StringView.hpp\"\n#include \"Tag.hpp\"\n#include \"Value.hpp\"\n#include <map>\n\nnamespace WCDB {\n\nclass WCDB_API Error final {\n#pragma mark - Initialize\npublic:\n    enum class Level;\n    enum class Code;\n    Error();\n    Error(Code code, Level level, const UnsafeStringView &message = UnsafeStringView());\n    Error(Error &&other);\n    Error(const Error &other);\n\n    Error &operator=(Error &&other);\n    Error &operator=(const Error &other);\n\n    //    void clear();\n\n#pragma mark - Level\npublic:\n    enum class Level : int {\n        Ignore = 1,\n        Debug = 2,\n        Notice = 3,\n        Warning = 4,\n        Error = 5, // Only for the errors that will cause api to return false.\n        Fatal = 6, // Application should abort.\n    };\n    Level level;\n    static constexpr const char *levelName(const Level &level)\n    {\n        switch (level) {\n        case Level::Ignore:\n            return \"IGNORE\";\n        case Level::Debug:\n            return \"DEBUG\";\n        case Level::Notice:\n            return \"NOTICE\";\n        case Level::Warning:\n            return \"WARNING\";\n        case Level::Error:\n            return \"ERROR\";\n        case Level::Fatal:\n            return \"FATAL\";\n        }\n    }\n    bool isIgnorable() const;\n\n#pragma mark - Code\npublic:\n    enum class Code : int {\n        OK = 0,\n        Error = 1,\n        Internal = 2,\n        Permission = 3,\n        Abort = 4,\n        Busy = 5,\n        Locked = 6,\n        NoMemory = 7,\n        Readonly = 8,\n        Interrupt = 9,\n        IOError = 10,\n        Corrupt = 11,\n        NotFound = 12,\n        Full = 13,\n        CantOpen = 14,\n        Protocol = 15,\n        Empty = 16,\n        Schema = 17,\n        Exceed = 18,\n        Constraint = 19,\n        Mismatch = 20,\n        Misuse = 21,\n        NoLargeFileSupport = 22,\n        Authorization = 23,\n        Format = 24,\n        Range = 25,\n        NotADatabase = 26,\n        Notice = 27,\n        Warning = 28,\n        Row = 100,\n        Done = 101,\n        ZstdError = 1000,\n    };\n    static Error::Code rc2c(int rc);\n    static int c2rc(Error::Code code);\n    static bool isError(int rc);\n    static constexpr const char *codeName(const Code &code)\n    {\n        switch (code) {\n        case Code::OK:\n            return \"OK\";\n        case Code::Error:\n            return \"Error\";\n        case Code::Internal:\n            return \"Internal\";\n        case Code::Permission:\n            return \"Permission\";\n        case Code::Abort:\n            return \"Abort\";\n        case Code::Busy:\n            return \"Busy\";\n        case Code::Locked:\n            return \"Locked\";\n        case Code::NoMemory:\n            return \"NoMemory\";\n        case Code::Readonly:\n            return \"Readonly\";\n        case Code::Interrupt:\n            return \"Interrupt\";\n        case Code::IOError:\n            return \"IOError\";\n        case Code::Corrupt:\n            return \"Corrupt\";\n        case Code::NotFound:\n            return \"NotFound\";\n        case Code::Full:\n            return \"Full\";\n        case Code::CantOpen:\n            return \"CantOpen\";\n        case Code::Protocol:\n            return \"Protocol\";\n        case Code::Empty:\n            return \"Empty\";\n        case Code::Schema:\n            return \"Schema\";\n        case Code::Exceed:\n            return \"Exceed\";\n        case Code::Constraint:\n            return \"Constraint\";\n        case Code::Mismatch:\n            return \"Mismatch\";\n        case Code::Misuse:\n            return \"Misuse\";\n        case Code::NoLargeFileSupport:\n            return \"NoLargeFileSupport\";\n        case Code::Authorization:\n            return \"Authorization\";\n        case Code::Format:\n            return \"Format\";\n        case Code::Range:\n            return \"Range\";\n        case Code::NotADatabase:\n            return \"NotADatabase\";\n        case Code::Notice:\n            return \"Notice\";\n        case Code::Warning:\n            return \"Warning\";\n        case Code::Row:\n            return \"Row\";\n        case Code::Done:\n            return \"Done\";\n        case Code::ZstdError:\n            return \"ZstdError\";\n        }\n    }\n\n    Code code() const;\n    bool isOK() const;\n    bool isCorruption() const;\n\n    void setSystemCode(int systemCode,\n                       Code codeIfUnresolved,\n                       const UnsafeStringView &message = UnsafeStringView());\n#ifdef _WIN32\n    void setWinSystemCode(int systemCode,\n                          Code code,\n                          const UnsafeStringView &message = UnsafeStringView());\n#endif\n    void setSQLiteCode(int code, const UnsafeStringView &message = UnsafeStringView());\n    void setCode(Code code, const UnsafeStringView &message = UnsafeStringView());\n\nprotected:\n    Code m_code;\n\n#pragma mark - ExtCode\npublic:\n    enum class ExtCode : int {\n        ErrorMissingCollseq = ((int) Code::Error | (1 << 8)),\n        ErrorRetry = ((int) Code::Error | (2 << 8)),\n        ErrorSnapshot = ((int) Code::Error | (3 << 8)),\n        IOErrorRead = ((int) Code::IOError | (1 << 8)),\n        IOErrorShortRead = ((int) Code::IOError | (2 << 8)),\n        IOErrorWrite = ((int) Code::IOError | (3 << 8)),\n        IOErrorFsync = ((int) Code::IOError | (4 << 8)),\n        IOErrorDirFsync = ((int) Code::IOError | (5 << 8)),\n        IOErrorTruncate = ((int) Code::IOError | (6 << 8)),\n        IOErrorFstat = ((int) Code::IOError | (7 << 8)),\n        IOErrorUnlock = ((int) Code::IOError | (8 << 8)),\n        IOErrorRdlock = ((int) Code::IOError | (9 << 8)),\n        IOErrorDelete = ((int) Code::IOError | (10 << 8)),\n        IOErrorBlocked = ((int) Code::IOError | (11 << 8)),\n        IOErrorNoMemory = ((int) Code::IOError | (12 << 8)),\n        IOErrorAccess = ((int) Code::IOError | (13 << 8)),\n        IOErrorCheckReservedLock = ((int) Code::IOError | (14 << 8)),\n        IOErrorLock = ((int) Code::IOError | (15 << 8)),\n        IOErrorClose = ((int) Code::IOError | (16 << 8)),\n        IOErrorDirClose = ((int) Code::IOError | (17 << 8)),\n        IOErrorShmOpen = ((int) Code::IOError | (18 << 8)),\n        IOErrorShmSize = ((int) Code::IOError | (19 << 8)),\n        IOErrorShmLock = ((int) Code::IOError | (20 << 8)),\n        IOErrorShmMap = ((int) Code::IOError | (21 << 8)),\n        IOErrorSeek = ((int) Code::IOError | (22 << 8)),\n        IOErrorDeleteNoEntry = ((int) Code::IOError | (23 << 8)),\n        IOErrorMmap = ((int) Code::IOError | (24 << 8)),\n        IOErrorGetTempPath = ((int) Code::IOError | (25 << 8)),\n        IOErrorConvPath = ((int) Code::IOError | (26 << 8)),\n        IOErrorVnode = ((int) Code::IOError | (27 << 8)),\n        IOErrorAuthorization = ((int) Code::IOError | (28 << 8)),\n        IOErrorBeginAtomic = ((int) Code::IOError | (29 << 8)),\n        IOErrorCommitAtomic = ((int) Code::IOError | (30 << 8)),\n        IOErrorRollbackAtomic = ((int) Code::IOError | (31 << 8)),\n        LockedSharedCache = ((int) Code::Locked | (1 << 8)),\n        LockedVirtualTable = ((int) Code::Locked | (2 << 8)),\n        BusyRecovery = ((int) Code::Busy | (1 << 8)),\n        BusySnapshot = ((int) Code::Busy | (2 << 8)),\n        CantOpenNoTempDir = ((int) Code::CantOpen | (1 << 8)),\n        CantOpenIsDir = ((int) Code::CantOpen | (2 << 8)),\n        CantOpenFullPath = ((int) Code::CantOpen | (3 << 8)),\n        CantOpenConvPath = ((int) Code::CantOpen | (4 << 8)),\n        CantOpenDirtyWal = ((int) Code::CantOpen | (5 << 8)),\n        CorruptVirtualTable = ((int) Code::Corrupt | (1 << 8)),\n        CorruptSequence = ((int) Code::Corrupt | (2 << 8)),\n        ReadonlyRecovery = ((int) Code::Readonly | (1 << 8)),\n        ReadonlyCantLock = ((int) Code::Readonly | (2 << 8)),\n        ReadonlyRollback = ((int) Code::Readonly | (3 << 8)),\n        ReadonlyDatabaseMoved = ((int) Code::Readonly | (4 << 8)),\n        ReadonlyCantInit = ((int) Code::Readonly | (5 << 8)),\n        ReadonlyDirectory = ((int) Code::Readonly | (6 << 8)),\n        AbortRollback = ((int) Code::Abort | (2 << 8)),\n        ConstraintCheck = ((int) Code::Constraint | (1 << 8)),\n        ConstraintCommitHook = ((int) Code::Constraint | (2 << 8)),\n        ConstraintForeignKey = ((int) Code::Constraint | (3 << 8)),\n        ConstraintFunction = ((int) Code::Constraint | (4 << 8)),\n        ConstraintNotNull = ((int) Code::Constraint | (5 << 8)),\n        ConstraintPrimaryKey = ((int) Code::Constraint | (6 << 8)),\n        ConstraintTrigger = ((int) Code::Constraint | (7 << 8)),\n        ConstraintUnique = ((int) Code::Constraint | (8 << 8)),\n        ConstraintVirtualTable = ((int) Code::Constraint | (9 << 8)),\n        ConstraintRowID = ((int) Code::Constraint | (10 << 8)),\n        NoticeRecoverWal = ((int) Code::Notice | (1 << 8)),\n        NoticeRecoverRollback = ((int) Code::Notice | (2 << 8)),\n        WarningAutoIndex = ((int) Code::Warning | (1 << 8)),\n        AuthorizationUser = ((int) Code::Authorization | (1 << 8)),\n        OKLoadPermanently = ((int) Code::OK | (1 << 8)),\n    };\n\n    static ExtCode rc2ec(int rc);\n\n#pragma mark - Message\npublic:\n    const StringView &getMessage() const;\n\nprotected:\n    StringView m_message;\n\n#pragma mark - Info\npublic:\n    StringViewMap<Value> infos;\n\n#pragma mark - Common Info\npublic:\n    UnsafeStringView getPath() const;\n    UnsafeStringView getAssociatePath() const;\n    UnsafeStringView getSQL() const;\n    Tag getTag() const;\n    ExtCode getExtCode() const;\n\n#pragma mark - Descritpion\npublic:\n    StringView getDescription() const;\n};\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/common/base/WCDBOptional.cpp",
    "content": "//\n// Created by qiuwenchen on 2023/2/18.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"WCDBOptional.hpp\"\n\nnamespace WCDB {\n\n_OptionalValueFlag::_OptionalValueFlag() : m_hasValue(false)\n{\n}\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/base/WCDBOptional.hpp",
    "content": "//\n// Created by qiuwenchen on 2023/2/16.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"Macro.h\"\n#include <memory>\n#include <type_traits>\n\nnamespace WCDB {\n\nstruct NullOpt_T {\n    struct SecretTag {\n        explicit SecretTag() = default;\n    };\n    constexpr explicit NullOpt_T(SecretTag, SecretTag) noexcept {}\n};\n\nconstexpr NullOpt_T NullOpt{ NullOpt_T::SecretTag{}, NullOpt_T::SecretTag{} };\n\nclass WCDB_API _OptionalValueFlag {\n    template<typename U>\n    friend class Optional;\n\npublic:\n    _OptionalValueFlag();\n\nprotected:\n    mutable bool m_hasValue;\n};\n\ntemplate<class T, bool = std::is_trivially_destructible<T>::value>\nclass _OptionalValueDestruct : public _OptionalValueFlag {};\n\ntemplate<class T>\nclass _OptionalValueDestruct<T, false> : public _OptionalValueFlag {\n    template<typename U>\n    friend class _OptionalValueStorage;\n    template<typename U>\n    friend class Optional;\n\nprotected:\n    union {\n        char m_nullState;\n        T m_value;\n    };\n\n    void reset()\n    {\n        if (m_hasValue) {\n            m_value.~T();\n        }\n        m_nullState = 0;\n        m_hasValue = false;\n    }\n\npublic:\n    ~_OptionalValueDestruct()\n    {\n        if (m_hasValue) {\n            m_value.~T();\n        }\n    }\n\n    _OptionalValueDestruct() : _OptionalValueFlag(), m_nullState(0) {}\n};\n\ntemplate<class T>\nclass _OptionalValueDestruct<T, true> : public _OptionalValueFlag {\n    template<typename U>\n    friend class _OptionalValueStorage;\n    template<typename U>\n    friend class Optional;\n\nprotected:\n    union {\n        mutable char m_nullState;\n        mutable T m_value;\n    };\n\n    void reset()\n    {\n        m_nullState = 0;\n        m_hasValue = false;\n    }\n\npublic:\n    _OptionalValueDestruct() : _OptionalValueFlag(), m_nullState(0) {}\n};\n\ntemplate<class T>\nclass _OptionalValueStorage : public _OptionalValueDestruct<T> {\npublic:\n    constexpr inline bool hasValue() const { return this->m_hasValue; };\n\n    constexpr inline T& value() & { return this->m_value; }\n\n    constexpr inline const T& value() const& { return this->m_value; }\n\n    constexpr inline T&& value() && { return std::move(this->m_value); }\n\n    constexpr inline const T&& value() const&&\n    {\n        return std::move(this->m_value);\n    }\n\n    template<class U>\n    constexpr T valueOr(U&& v) const&\n    {\n        static_assert(std::is_copy_constructible<T>::value,\n                      \"Optional<T>::valueOr: T must be copy constructible\");\n        static_assert(std::is_convertible<U, T>::value,\n                      \"Optional<T>::valueOr: U must be convertible to T\");\n        return this->hasValue() ? this->value() : static_cast<T>(std::forward<U>(v));\n    }\n\n    template<class U>\n    constexpr T valueOr(U&& v) &&\n    {\n        static_assert(std::is_move_constructible<T>::value,\n                      \"Optional<T>::valueOr: T must be copy constructible\");\n        static_assert(std::is_convertible<U, T>::value,\n                      \"Optional<T>::valueOr: U must be convertible to T\");\n        return this->hasValue() ? std::move(this->value()) :\n                                  static_cast<T>(std::forward<U>(v));\n    }\n\n    constexpr T valueOrDefault() const&\n    {\n        static_assert(std::is_copy_constructible<T>::value,\n                      \"Optional<T>::valueOrDefault: T must be copy constructible\");\n        static_assert(std::is_default_constructible<T>::value,\n                      \"Optional<T>::valueOrDefault: T must be have default constructor\");\n        return this->hasValue() ? this->value() : T();\n    }\n\n    constexpr T valueOrDefault() &&\n    {\n        static_assert(std::is_move_constructible<T>::value,\n                      \"Optional<T>::valueOrDefault: T must be copy constructible\");\n        static_assert(std::is_default_constructible<T>::value,\n                      \"Optional<T>::valueOrDefault: T must be have default constructor\");\n        return this->hasValue() ? std::move(this->value()) : T();\n    }\n\nprotected:\n    template<class That>\n    void construct(That&& value)\n    {\n        new ((void*) std::addressof(this->m_value)) T(std::forward<That>(value));\n        this->m_hasValue = true;\n    }\n\n    template<class That>\n    void constructFrom(That&& opt)\n    {\n        if (opt.hasValue()) {\n            construct(std::forward<That>(opt).value());\n        }\n    }\n\n    template<class That>\n    void assignFrom(That&& opt)\n    {\n        if (this->m_hasValue == opt.hasValue()) {\n            if (this->m_hasValue) {\n                this->m_value = std::forward<That>(opt).value();\n            }\n        } else {\n            if (this->m_hasValue) {\n                this->reset();\n            } else {\n                construct(std::forward<That>(opt).value());\n            }\n        }\n    }\n};\n\ntemplate<class T, bool = std::is_trivially_copy_constructible<T>::value>\nclass _OptionalCopyBase : public _OptionalValueStorage<T> {\npublic:\n    using _OptionalValueStorage<T>::_OptionalValueStorage;\n};\n\ntemplate<class T>\nclass _OptionalCopyBase<T, false> : public _OptionalValueStorage<T> {\npublic:\n    using _OptionalValueStorage<T>::_OptionalValueStorage;\n\n    _OptionalCopyBase() = default;\n\n    _OptionalCopyBase(const _OptionalCopyBase& opt)\n    {\n        this->constructFrom(opt);\n    }\n\n    _OptionalCopyBase(_OptionalCopyBase&&) = default;\n    _OptionalCopyBase& operator=(const _OptionalCopyBase&) = default;\n    _OptionalCopyBase& operator=(_OptionalCopyBase&&) = default;\n};\n\ntemplate<class T, bool = std::is_trivially_move_constructible<T>::value>\nclass _OptionalMoveBase : public _OptionalCopyBase<T> {\npublic:\n    using _OptionalCopyBase<T>::_OptionalCopyBase;\n};\n\ntemplate<class T>\nclass _OptionalMoveBase<T, false> : public _OptionalCopyBase<T> {\npublic:\n    using _OptionalCopyBase<T>::_OptionalCopyBase;\n    _OptionalMoveBase() = default;\n    _OptionalMoveBase(const _OptionalMoveBase&) = default;\n\n    _OptionalMoveBase(_OptionalMoveBase&& opt)\n    {\n        this->constructFrom(std::move(opt));\n    }\n\n    _OptionalMoveBase& operator=(const _OptionalMoveBase&) = default;\n    _OptionalMoveBase& operator=(_OptionalMoveBase&&) = default;\n};\n\ntemplate<class T,\n         bool = std::is_trivially_destructible<T>::value && std::is_trivially_copy_constructible<T>::value\n                && std::is_trivially_copy_assignable<T>::value>\nclass _OptionalCopyAssignBase : public _OptionalMoveBase<T> {\npublic:\n    using _OptionalMoveBase<T>::_OptionalMoveBase;\n};\n\ntemplate<class T>\nclass _OptionalCopyAssignBase<T, false> : public _OptionalMoveBase<T> {\npublic:\n    using _OptionalMoveBase<T>::_OptionalMoveBase;\n    _OptionalCopyAssignBase() = default;\n    _OptionalCopyAssignBase(const _OptionalCopyAssignBase&) = default;\n    _OptionalCopyAssignBase(_OptionalCopyAssignBase&&) = default;\n\n    _OptionalCopyAssignBase& operator=(const _OptionalCopyAssignBase& opt)\n    {\n        this->assignFrom(opt);\n        return *this;\n    }\n\n    _OptionalCopyAssignBase& operator=(_OptionalCopyAssignBase&&) = default;\n};\n\ntemplate<class T,\n         bool = std::is_trivially_destructible<T>::value && std::is_trivially_move_constructible<T>::value\n                && std::is_trivially_move_assignable<T>::value>\nclass _OptionalMoveAssignBase : public _OptionalCopyAssignBase<T> {\npublic:\n    using _OptionalCopyAssignBase<T>::_OptionalCopyAssignBase;\n};\n\ntemplate<class T>\nclass _OptionalMoveAssignBase<T, false> : public _OptionalCopyAssignBase<T> {\npublic:\n    using _OptionalCopyAssignBase<T>::_OptionalCopyAssignBase;\n\n    _OptionalMoveAssignBase() = default;\n    _OptionalMoveAssignBase(const _OptionalMoveAssignBase& __opt) = default;\n    _OptionalMoveAssignBase(_OptionalMoveAssignBase&&) = default;\n    _OptionalMoveAssignBase& operator=(const _OptionalMoveAssignBase&) = default;\n\n    _OptionalMoveAssignBase& operator=(_OptionalMoveAssignBase&& opt)\n    {\n        this->assignFrom(std::move(opt));\n        return *this;\n    }\n};\n\ntemplate<typename T>\nclass Optional : public _OptionalMoveAssignBase<T> {\n    static_assert(std::is_object<T>::value,\n                  \"instantiation of optional with a non-object type is undefined behavior\");\n\npublic:\n    typedef T ValueType;\n#pragma mark - Interface\n\n    inline bool succeed() const { return this->m_hasValue; }\n    inline bool failed() const { return !this->m_hasValue; };\n\n    constexpr inline T* operator->() { return &this->m_value; }\n\n    constexpr inline const T* operator->() const { return &this->m_value; }\n\n    T& getOrCreate()\n    {\n        if (!this->m_hasValue) {\n            new ((void*) std::addressof(this->m_value)) T();\n            this->m_hasValue = true;\n        }\n        return this->m_value;\n    }\n\n    const T& getOrCreate() const\n    {\n        if (!this->m_hasValue) {\n            new ((void*) std::addressof(this->m_value)) T();\n            this->m_hasValue = true;\n        }\n        return this->m_value;\n    }\n\n#pragma mark - Constructor\n\n    Optional() : _OptionalMoveAssignBase<T>() {}\n\n    Optional(const NullOpt_T&) : _OptionalMoveAssignBase<T>() {}\n\n    template<typename U, typename Enable = void>\n    struct Constructable : public std::false_type {};\n\n    template<typename U>\n    struct Constructable<U, typename std::enable_if<!std::is_base_of<Optional, U>::value && std::is_constructible<T, U>::value>::type>\n    : public std::true_type {};\n\n    template<typename U, typename Enable = typename std::enable_if<Constructable<U>::value && std::is_copy_constructible<U>::value>::type>\n    Optional(const Optional<U>& opt)\n    {\n        this->constructFrom(opt);\n    }\n\n    template<typename U, typename Enable = typename std::enable_if<Constructable<U>::value && std::is_move_constructible<U>::value>::type>\n    Optional(Optional<U>&& opt)\n    {\n        this->constructFrom(std::move(opt));\n    }\n\n    template<typename U, typename Enable = typename std::enable_if<Constructable<U>::value && std::is_copy_constructible<U>::value>::type>\n    Optional(const U& value)\n    {\n        this->construct(value);\n    }\n\n    template<typename U, typename Enable = typename std::enable_if<Constructable<U>::value && std::is_move_constructible<U>::value>::type>\n    Optional(U&& value)\n    {\n        this->construct(std::forward<U>(value));\n    }\n\n#pragma mark - Assignment\n\n    Optional<T>& operator=(const NullOpt_T&)\n    {\n        this->reset();\n        return *this;\n    }\n\n    template<typename U, typename Enable = typename std::enable_if<Constructable<U>::value && std::is_copy_assignable<U>::value>::type>\n    Optional<T>& operator=(const Optional<U>& other)\n    {\n        this->assignFrom(other);\n        return *this;\n    }\n\n    template<typename U, typename Enable = typename std::enable_if<Constructable<U>::value && std::is_move_assignable<U>::value>::type>\n    Optional<T>& operator=(Optional<U>&& other)\n    {\n        this->assignFrom(std::move(other));\n        return *this;\n    }\n\n    template<typename U, typename Enable = typename std::enable_if<Constructable<U>::value>::type>\n    Optional<T>& operator=(U&& value)\n    {\n        if (this->m_hasValue) {\n            this->m_value = std::forward<U>(value);\n        } else {\n            this->construct(std::forward<U>(value));\n        }\n        return *this;\n    }\n\n    bool operator==(const NullOpt_T&) const { return !this->m_hasValue; }\n\n    bool operator!=(const NullOpt_T&) const { return this->m_hasValue; }\n\n    template<typename U, typename Enable = typename std::enable_if<Constructable<U>::value>::type>\n    bool operator==(const Optional<U>& other) const\n    {\n        if (this->m_hasValue != other.m_hasValue) {\n            return false;\n        } else if (!this->m_hasValue) {\n            return true;\n        }\n        return this->m_value == other.m_value;\n    }\n\n    template<typename U, typename Enable = typename std::enable_if<Constructable<U>::value>::type>\n    bool operator!=(const Optional<U>& other) const\n    {\n        if (this->m_hasValue != other.m_hasValue) {\n            return true;\n        } else if (this->m_hasValue) {\n            return false;\n        }\n        return this->m_value != other.m_value;\n    }\n\n    inline constexpr const ValueType& operator*() const& noexcept\n    {\n        return this->m_value;\n    }\n\n    inline constexpr ValueType& operator*() & noexcept { return this->m_value; }\n\n    inline constexpr ValueType&& operator*() && noexcept\n    {\n        return std::move(this->m_value);\n    }\n\n    inline constexpr const ValueType&& operator*() const&& noexcept\n    {\n        return std::move(this->m_value);\n    }\n};\n\ntemplate<class T>\nstruct IsWCDBOptional : std::false_type {};\n\ntemplate<class T>\nstruct IsWCDBOptional<Optional<T>> : std::true_type {};\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/core/CommonCore.cpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"CommonCore.h\"\n#include \"AutoMigrateConfig.hpp\"\n#include \"BusyRetryConfig.hpp\"\n#include \"CompressionConst.hpp\"\n#include \"DecompressFunction.hpp\"\n#include \"FTS5AuxiliaryFunctionTemplate.hpp\"\n#include \"FTSConst.h\"\n#include \"FileManager.hpp\"\n#include \"Global.hpp\"\n#include \"Notifier.hpp\"\n#include \"OneOrBinaryTokenizer.hpp\"\n#include \"PinyinTokenizer.hpp\"\n#include \"SQLite.h\"\n#include \"ScalarFunctionTemplate.hpp\"\n#include \"StringView.hpp\"\n#include \"SubstringMatchInfo.hpp\"\n\n#ifdef __ANDROID__\n#include \"MMICUTokenizer.hpp\"\n#endif\n\nnamespace WCDB {\n\n#pragma mark - Core\nCommonCore& CommonCore::shared()\n{\n    static CommonCore* s_core = new CommonCore;\n    return *s_core;\n}\n\nCommonCore::CommonCore()\n// Database\n: m_databasePool(this)\n, m_scalarFunctionModules(std::make_shared<ScalarFunctionModules>())\n, m_tokenizerModules(std::make_shared<TokenizerModules>())\n, m_auxiliaryFunctionModules(std::make_shared<AuxiliaryFunctionModules>())\n, m_operationQueue(std::make_shared<OperationQueue>(OperationQueueName, this))\n// Checkpoint\n, m_autoCheckpointConfig(std::make_shared<AutoCheckpointConfig>(m_operationQueue))\n// Backup\n, m_autoBackupConfig(std::make_shared<AutoBackupConfig>(m_operationQueue))\n// Migration\n, m_autoMigrateConfig(std::make_shared<AutoMigrateConfig>(m_operationQueue))\n// Compression\n, m_autoCompressConfig(std::make_shared<AutoCompressConfig>(m_operationQueue))\n// Trace\n, m_globalSQLTraceConfig(std::make_shared<ShareableSQLTraceConfig>())\n, m_globalPerformanceTraceConfig(std::make_shared<ShareablePerformanceTraceConfig>())\n// Busy Retry\n, m_globalBusyRetryConfig(std::make_shared<BusyRetryConfig>())\n, m_enableBusyTrace(false)\n//Merge\n, m_AutoMergeFTSConfig(std::make_shared<AutoMergeFTSIndexConfig>(m_operationQueue))\n// Config\n, m_configs({\n  { StringView(GlobalSQLTraceConfigName), m_globalSQLTraceConfig, Configs::Priority::Highest },\n  { StringView(GlobalPerformanceTraceConfigName), m_globalPerformanceTraceConfig, Configs::Priority::Highest },\n  { StringView(BusyRetryConfigName), m_globalBusyRetryConfig, Configs::Priority::Highest },\n  { StringView(BasicConfigName), std::make_shared<BasicConfig>(), Configs::Priority::Higher },\n  })\n{\n    Global::initialize();\n\n    Global::shared().setNotificationForLog(\n    NotifierLoggerName,\n    std::bind(&CommonCore::globalLog, this, std::placeholders::_1, std::placeholders::_2));\n\n    Notifier::shared().setNotificationForPreprocessing(\n    NotifierPreprocessorName,\n    std::bind(&CommonCore::preprocessError, this, std::placeholders::_1));\n\n    m_operationQueue->run();\n\n    //config FTS\n    registerTokenizer(BuiltinTokenizer::OneOrBinary,\n                      FTS3TokenizerModuleTemplate<OneOrBinaryTokenizer>::specialize());\n    registerTokenizer(BuiltinTokenizer::LegacyOneOrBinary,\n                      FTS3TokenizerModuleTemplate<OneOrBinaryTokenizer>::specialize());\n    registerTokenizer(\n    BuiltinTokenizer::Verbatim,\n    FTS5TokenizerModuleTemplate<OneOrBinaryTokenizer>::specializeWithContext(nullptr));\n    registerTokenizer(\n    BuiltinTokenizer::Pinyin,\n    FTS5TokenizerModuleTemplate<PinyinTokenizer>::specializeWithContext(nullptr));\n\n#ifdef __ANDROID__\n    registerTokenizer(BuiltinTokenizer::MMICU,\n                      FTS3TokenizerModuleTemplate<MMICUTokenizer>::specialize());\n#endif\n\n    registerAuxiliaryFunction(\n    BuiltinAuxiliaryFunction::SubstringMatchInfo,\n    FTS5AuxiliaryFunctionTemplate<SubstringMatchInfo>::specializeWithContext(nullptr));\n    registerScalarFunction(DecompressFunctionName,\n                           ScalarFunctionTemplate<DecompressFunction>::specialize(2));\n}\n\nCommonCore::~CommonCore()\n{\n    Global::shared().setNotificationForLog(NotifierLoggerName, nullptr);\n    Notifier::shared().setNotificationForPreprocessing(NotifierPreprocessorName, nullptr);\n}\n\n#pragma mark - Database\nRecyclableDatabase CommonCore::getOrCreateDatabase(const UnsafeStringView& path)\n{\n    return m_databasePool.getOrCreate(path);\n}\n\nvoid CommonCore::purgeDatabasePool()\n{\n    m_databasePool.purge();\n}\n\nvoid CommonCore::releaseSQLiteMemory(int bytes)\n{\n    sqlite3_release_memory(bytes);\n}\n\nvoid CommonCore::setSoftHeapLimit(int64_t limit)\n{\n    sqlite3_soft_heap_limit64(limit);\n}\n\nvoid CommonCore::stopQueue()\n{\n    m_operationQueue->stop();\n}\n\nvoid CommonCore::databaseDidCreate(InnerDatabase* database)\n{\n    WCTAssert(database != nullptr);\n\n    database->setConfigs(m_configs);\n\n    enableAutoCheckpoint(database, true);\n}\n\n#pragma mark - Error\n\nvoid CommonCore::setThreadedErrorPath(const UnsafeStringView& path)\n{\n    m_errorPath.getOrCreate() = path;\n}\n\nvoid CommonCore::setThreadedErrorIgnorable(bool ignorable)\n{\n    m_errorIgnorable.getOrCreate() = ignorable;\n}\n\nvoid CommonCore::preprocessError(Error& error)\n{\n    auto& infos = error.infos;\n\n    const StringView& path = error.getPath();\n    const StringView& associatePath = error.getAssociatePath();\n    const StringView& threadedPath = m_errorPath.getOrCreate();\n\n    if (path.empty()) {\n        if (!threadedPath.empty()) {\n            error.infos.insert_or_assign(ErrorStringKeyPath, threadedPath);\n        } else if (!associatePath.empty()) {\n            error.infos.insert_or_assign(ErrorStringKeyPath, associatePath);\n            error.infos.erase(ErrorStringKeyAssociatePath);\n        }\n    }\n    if (error.getPath().equal(associatePath)) {\n        error.infos.erase(ErrorStringKeyAssociatePath);\n    }\n\n    if (error.level == Error::Level::Error && m_errorIgnorable.getOrCreate()) {\n        error.level = Error::Level::Warning;\n    }\n\n    auto iter = infos.find(UnsafeStringView(ErrorStringKeyPath));\n    if (iter != infos.end() && iter->second.getType() == Value::Type::Text) {\n        auto tag = m_databasePool.getTag(iter->second.textValue());\n        if (tag.isValid()) {\n            error.infos.insert_or_assign(ErrorIntKeyTag, (long) tag);\n        }\n    }\n}\n\n#pragma mark - ScalarFunction\nvoid CommonCore::registerScalarFunction(const UnsafeStringView& name,\n                                        const ScalarFunctionModule& module)\n{\n    m_scalarFunctionModules->add(name, module);\n}\n\nbool CommonCore::scalarFunctionExists(const UnsafeStringView& name) const\n{\n    return m_scalarFunctionModules->get(name) != nullptr;\n}\n\nstd::shared_ptr<Config>\nCommonCore::scalarFunctionConfig(const UnsafeStringView& scalarFunctionName)\n{\n    return std::make_shared<ScalarFunctionConfig>(scalarFunctionName, m_scalarFunctionModules);\n}\n\n#pragma mark - Tokenizer\nvoid CommonCore::registerTokenizer(const UnsafeStringView& name, const TokenizerModule& module)\n{\n    m_tokenizerModules->add(name, module);\n}\n\nbool CommonCore::tokenizerExists(const UnsafeStringView& name) const\n{\n    return m_tokenizerModules->get(name) != nullptr;\n}\n\nstd::shared_ptr<Config> CommonCore::tokenizerConfig(const UnsafeStringView& tokenizeName)\n{\n    return std::make_shared<TokenizerConfig>(tokenizeName, m_tokenizerModules);\n}\n\n#pragma mark - AuxiliaryFunction\nvoid CommonCore::registerAuxiliaryFunction(const UnsafeStringView& name,\n                                           const FTS5AuxiliaryFunctionModule& module)\n{\n    m_auxiliaryFunctionModules->add(name, module);\n}\n\nbool CommonCore::auxiliaryFunctionExists(const UnsafeStringView& name) const\n{\n    return m_auxiliaryFunctionModules->get(name) != nullptr;\n}\n\nstd::shared_ptr<Config>\nCommonCore::auxiliaryFunctionConfig(const UnsafeStringView& auxiliaryFunctionName)\n{\n    return std::make_shared<AuxiliaryFunctionConfig>(\n    auxiliaryFunctionName, m_auxiliaryFunctionModules);\n}\n\n#pragma mark - Operation\nOptional<bool> CommonCore::migrationShouldBeOperated(const UnsafeStringView& path)\n{\n    RecyclableDatabase database = m_databasePool.getOrCreate(path);\n    Optional<bool> done = false; // mark as no error if database is not referenced.\n    if (database != nullptr) {\n        done = database->stepMigration(true);\n    }\n    return done;\n}\n\nOptional<bool> CommonCore::compressionShouldBeOperated(const UnsafeStringView& path)\n{\n    RecyclableDatabase database = m_databasePool.getOrCreate(path);\n    Optional<bool> done = false; // mark as no error if database is not referenced.\n    if (database != nullptr) {\n        done = database->stepCompression(true);\n    }\n    return done;\n}\n\nvoid CommonCore::backupShouldBeOperated(const UnsafeStringView& path)\n{\n    RecyclableDatabase database = m_databasePool.getOrCreate(path);\n    if (database != nullptr) {\n        database->backup(true);\n    }\n}\n\nvoid CommonCore::checkpointShouldBeOperated(const UnsafeStringView& path)\n{\n    RecyclableDatabase database = m_databasePool.getOrCreate(path);\n    if (database != nullptr) {\n        database->checkpoint(true);\n    }\n}\n\nvoid CommonCore::integrityShouldBeChecked(const UnsafeStringView& path)\n{\n    RecyclableDatabase database = m_databasePool.getOrCreate(path);\n    if (database != nullptr) {\n        database->checkIntegrity(true);\n\n        StringViewSet sourcePaths = database->getPathsOfSourceDatabases();\n        for (const UnsafeStringView& sourcePath : sourcePaths) {\n            RecyclableDatabase sourceDatabase = m_databasePool.getOrCreate(sourcePath);\n            if (sourceDatabase != nullptr) {\n                sourceDatabase->checkIntegrity(true);\n            }\n        }\n    }\n}\n\nvoid CommonCore::purgeShouldBeOperated()\n{\n    purgeDatabasePool();\n}\n\nvoid CommonCore::stopAllDatabaseEvent(const UnsafeStringView& path)\n{\n    m_operationQueue->stopAllDatabaseEvent(path);\n}\n\nbool CommonCore::isFileObservedCorrupted(const UnsafeStringView& path)\n{\n    return m_operationQueue->isFileObservedCorrupted(path);\n}\n\nvoid CommonCore::setNotificationWhenDatabaseCorrupted(const UnsafeStringView& path,\n                                                      const CorruptedNotification& notification)\n{\n    OperationQueue::CorruptionNotification underlyingNotification = nullptr;\n    if (notification != nullptr) {\n        underlyingNotification\n        = [this, notification](const UnsafeStringView& path, uint32_t corruptedIdentifier) {\n              RecyclableDatabase database = m_databasePool.getOrCreate(path);\n              if (database == nullptr) {\n                  return;\n              }\n              database->blockade();\n              do {\n                  auto exists = FileManager::fileExists(path);\n                  if (!exists.succeed()) {\n                      // I/O error\n                      break;\n                  }\n                  if (!exists.value()) {\n                      // it's already not existing\n                      break;\n                  }\n                  auto identifier = FileManager::getFileIdentifier(path);\n                  if (!identifier.succeed()) {\n                      // I/O error\n                      break;\n                  }\n                  if (identifier.value() != corruptedIdentifier) {\n                      // file is changed.\n                      break;\n                  }\n                  notification(database.get());\n              } while (false);\n              database->unblockade();\n          };\n    }\n    m_operationQueue->setNotificationWhenCorrupted(path, underlyingNotification);\n}\n\n#pragma mark - Checkpoint\nvoid CommonCore::enableAutoCheckpoint(InnerDatabase* database, bool enable)\n{\n    if (enable) {\n        if (!database->liteModeEnable()) {\n            database->setConfig(\n            AutoCheckpointConfigName, m_autoCheckpointConfig, Configs::Priority::Highest);\n            m_operationQueue->registerAsRequiredCheckpoint(database->getPath());\n        }\n    } else {\n        database->removeConfig(AutoCheckpointConfigName);\n        m_operationQueue->registerAsNoCheckpointRequired(database->getPath());\n    }\n}\n\nvoid CommonCore::setCheckPointMinFrames(int frames)\n{\n    AutoCheckpointConfig* checkpointConfig\n    = dynamic_cast<AutoCheckpointConfig*>(m_autoCheckpointConfig.get());\n    WCTAssert(checkpointConfig != nullptr);\n    if (checkpointConfig != nullptr) {\n        checkpointConfig->setMinFrames(frames);\n    }\n}\n\n#pragma mark - Backup\nvoid CommonCore::enableAutoBackup(InnerDatabase* database, bool enable)\n{\n    WCTAssert(database != nullptr);\n    if (enable) {\n        database->setConfig(\n        AutoBackupConfigName, m_autoBackupConfig, WCDB::Configs::Priority::Highest);\n        m_operationQueue->registerAsRequiredBackup(database->getPath());\n        database->markNeedLoadIncremetalMaterial();\n    } else {\n        database->removeConfig(AutoBackupConfigName);\n        m_operationQueue->registerAsNoBackupRequired(database->getPath());\n    }\n}\n\nvoid CommonCore::tryRegisterIncrementalMaterial(const UnsafeStringView& path,\n                                                SharedIncrementalMaterial material)\n{\n    if (!m_operationQueue->isAutoBackup(path)) {\n        return;\n    }\n    WCTAssert(dynamic_cast<AutoBackupConfig*>(m_autoBackupConfig.get()) != nullptr);\n    AutoBackupConfig* backupConfig\n    = static_cast<AutoBackupConfig*>(m_autoBackupConfig.get());\n    if (backupConfig != nullptr) {\n        backupConfig->tryRegisterIncrementalMaterial(path, material);\n    }\n}\n\nSharedIncrementalMaterial\nCommonCore::tryGetIncrementalMaterial(const UnsafeStringView& path)\n{\n    WCTAssert(dynamic_cast<AutoBackupConfig*>(m_autoBackupConfig.get()) != nullptr);\n    AutoBackupConfig* backupConfig\n    = static_cast<AutoBackupConfig*>(m_autoBackupConfig.get());\n    if (backupConfig != nullptr) {\n        return backupConfig->tryGetIncrementalMaterial(path);\n    }\n    return nullptr;\n}\n\n#pragma mark - Migration\nvoid CommonCore::enableAutoMigrate(InnerDatabase* database, bool enable)\n{\n    WCTAssert(database != nullptr);\n    if (enable) {\n        database->setConfig(\n        AutoMigrateConfigName, m_autoMigrateConfig, WCDB::Configs::Priority::Highest);\n        m_operationQueue->registerAsRequiredMigration(database->getPath());\n        m_operationQueue->asyncMigrate(database->getPath());\n    } else {\n        database->removeConfig(AutoMigrateConfigName);\n        m_operationQueue->registerAsNoMigrationRequired(database->getPath());\n    }\n}\n\n#pragma mark - Compression\nvoid CommonCore::enableAutoCompress(InnerDatabase* database, bool enable)\n{\n    WCTAssert(database != nullptr);\n    if (enable) {\n        database->setConfig(\n        AutoCompressConfigName, m_autoCompressConfig, WCDB::Configs::Priority::Highest);\n        m_operationQueue->registerAsRequiredCompression(database->getPath());\n        m_operationQueue->asyncCompress(database->getPath());\n    } else {\n        database->removeConfig(AutoCompressConfigName);\n        m_operationQueue->registerAsNoCompressionRequired(database->getPath());\n    }\n}\n\n#pragma mark - Merge FTS Index\nvoid CommonCore::enableAutoMergeFTSIndex(InnerDatabase* database, bool enable)\n{\n    WCTAssert(database != nullptr);\n    if (enable) {\n        database->setConfig(AutoMergeFTSIndexConfigName,\n                            m_AutoMergeFTSConfig,\n                            WCDB::Configs::Priority::Highest);\n        m_operationQueue->registerAsRequiredMergeFTSIndex(database->getPath());\n        m_operationQueue->asyncMergeFTSIndex(database->getPath(), nullptr, nullptr);\n    } else {\n        database->removeConfig(AutoMergeFTSIndexConfigName);\n        m_operationQueue->registerAsNoMergeFTSIndexRequired(database->getPath());\n    }\n}\n\nOptional<bool> CommonCore::mergeFTSIndexShouldBeOperated(const UnsafeStringView& path,\n                                                         TableArray newTables,\n                                                         TableArray modifiedTables)\n{\n    RecyclableDatabase database = m_databasePool.getOrCreate(path);\n    Optional<bool> done = false; // mark as no error if database is not referenced.\n    if (database != nullptr) {\n        done = database->mergeFTSIndex(newTables, modifiedTables);\n    }\n    return done;\n}\n\n#pragma mark - Trace\nvoid CommonCore::globalLog(int rc, const char* message)\n{\n    Error::Code code = Error::rc2c(rc);\n    if (code == Error::Code::Warning || code == Error::Code::Corrupt) {\n        Error error;\n        error.setSQLiteCode(rc, message);\n        error.level = Error::Level::Warning;\n        Notifier::shared().notify(error);\n    }\n}\n\nvoid CommonCore::setNotificationForSQLGLobalTraced(const ShareableSQLTraceConfig::Notification& notification)\n{\n    static_cast<ShareableSQLTraceConfig*>(m_globalSQLTraceConfig.get())->setNotification(notification);\n}\n\nvoid CommonCore::setNotificationWhenPerformanceGlobalTraced(\nconst ShareablePerformanceTraceConfig::Notification& notification)\n{\n    static_cast<ShareablePerformanceTraceConfig*>(m_globalPerformanceTraceConfig.get())\n    ->setNotification(notification);\n}\n\nvoid CommonCore::setNotificationWhenErrorTraced(const Notifier::Callback& notification)\n{\n    if (notification != nullptr) {\n        Notifier::shared().setNotification(\n        std::numeric_limits<int>::min(), WCDB::NotifierLoggerName, notification);\n    } else {\n        Notifier::shared().unsetNotification(WCDB::NotifierLoggerName);\n    }\n}\n\nvoid CommonCore::setNotificationWhenErrorTraced(const UnsafeStringView& path,\n                                                const Notifier::Callback& notification)\n{\n    StringView notifierKey\n    = StringView::formatted(\"%s_%s\", NotifierLoggerName.data(), path.data());\n    if (notification != nullptr) {\n        StringView catchedPath = StringView(path);\n        Notifier::Callback realNotification = [=](const Error& error) {\n            if (error.getPath().length() == 0 || error.getPath().compare(catchedPath) == 0) {\n                notification(error);\n            }\n        };\n        Notifier::shared().setNotification(\n        std::numeric_limits<int>::min() + 1, notifierKey, realNotification);\n    } else {\n        Notifier::shared().unsetNotification(notifierKey);\n    }\n}\n\nvoid CommonCore::setBusyMonitor(BusyMonitor monitor, double timeOut)\n{\n    if (monitor != nullptr && timeOut > 0) {\n        m_enableBusyTrace = true;\n        static_cast<BusyRetryConfig*>(m_globalBusyRetryConfig.get())\n        ->setBusyMonitor(\n        [=](const UnsafeStringView& path, uint64_t tid) {\n            if (m_errorIgnorable.getOrCreate()) {\n                return;\n            }\n            auto database = getOrCreateDatabase(path);\n            StringView sql = database->getRunningSQLInThread(tid);\n            monitor(database->getTag(), path, tid, sql);\n        },\n        timeOut);\n    } else {\n        m_enableBusyTrace = false;\n        static_cast<BusyRetryConfig*>(m_globalBusyRetryConfig.get())->setBusyMonitor(nullptr, 0);\n    }\n}\n\nbool CommonCore::isBusyTraceEnable() const\n{\n    return m_enableBusyTrace;\n}\n\n#pragma mark - Integrity\n\nvoid CommonCore::skipIntegrityCheck(const UnsafeStringView& path)\n{\n    m_operationQueue->skipIntegrityCheck(path);\n}\n\n#pragma mark - Config\nvoid CommonCore::setABTestConfig(const UnsafeStringView& configName,\n                                 const UnsafeStringView& configValue)\n{\n    LockGuard memoryGuard(m_memory);\n    m_abtestConfig[configName] = configValue;\n}\n\nvoid CommonCore::removeABTestConfig(const UnsafeStringView& configName)\n{\n    LockGuard memoryGuard(m_memory);\n    m_abtestConfig.erase(configName);\n}\n\nOptional<UnsafeStringView> CommonCore::getABTestConfig(const UnsafeStringView& configName)\n{\n    SharedLockGuard memoryGuard(m_memory);\n    if (m_abtestConfig.find(configName) != m_abtestConfig.end()) {\n        return m_abtestConfig[configName];\n    }\n    return NullOpt;\n}\n\nvoid CommonCore::setDefaultCipherConfiguration(int version)\n{\n    switch (version) {\n    case 1:\n        sqlcipher_set_default_hmac_algorithm(0);\n        sqlcipher_set_default_kdf_algorithm(0);\n        sqlcipher_set_default_kdf_iter(4000);\n        sqlcipher_set_default_use_hmac(0);\n        break;\n\n    case 2:\n        sqlcipher_set_default_hmac_algorithm(0);\n        sqlcipher_set_default_kdf_algorithm(0);\n        sqlcipher_set_default_kdf_iter(4000);\n        sqlcipher_set_default_use_hmac(1);\n        break;\n\n    case 3:\n        sqlcipher_set_default_hmac_algorithm(0);\n        sqlcipher_set_default_kdf_algorithm(0);\n        sqlcipher_set_default_kdf_iter(64000);\n        sqlcipher_set_default_use_hmac(1);\n        break;\n\n    default:\n        sqlcipher_set_default_hmac_algorithm(2);\n        sqlcipher_set_default_kdf_algorithm(2);\n        sqlcipher_set_default_kdf_iter(256000);\n        sqlcipher_set_default_use_hmac(1);\n        break;\n    }\n}\n\nbool CommonCore::setDefaultTemporaryDirectory(const UnsafeStringView& dir)\n{\n    if (dir.length() > 0) {\n        if (!FileManager::createDirectoryWithIntermediateDirectories(dir)) {\n            return false;\n        }\n    }\n    sqlite3_temp_directory = (char*) StringView::createConstant(dir.data()).data();\n    return true;\n}\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/core/CommonCore.h",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"CommonCore.hpp\"\n#include \"CoreConst.h\"\n\n#include \"AsyncQueue.hpp\"\n#include \"OperationQueue.hpp\"\n\n#include \"AuxiliaryFunctionConfig.hpp\"\n#include \"BasicConfig.hpp\"\n#include \"CipherConfig.hpp\"\n#include \"Config.hpp\"\n#include \"Configs.hpp\"\n#include \"CustomConfig.hpp\"\n#include \"PerformanceTraceConfig.hpp\"\n#include \"SQLTraceConfig.hpp\"\n#include \"TokenizerConfig.hpp\"\n\n#include \"DatabasePool.hpp\"\n#include \"InnerDatabase.hpp\"\n#include \"RecyclableHandle.hpp\"\n\n#include \"TokenizerModule.hpp\"\n#include \"TokenizerModules.hpp\"\n\n#include \"AuxiliaryFunctionModule.hpp\"\n\n#include \"CompressionInfo.hpp\"\n#include \"MigrationInfo.hpp\"\n"
  },
  {
    "path": "src/common/core/CommonCore.hpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"OperationQueue.hpp\"\n\n#include \"Config.hpp\"\n#include \"Configs.hpp\"\n#include \"PerformanceTraceConfig.hpp\"\n#include \"SQLTraceConfig.hpp\"\n\n#include \"DatabasePool.hpp\"\n\n#include \"AuxiliaryFunctionConfig.hpp\"\n#include \"ScalarFunctionConfig.hpp\"\n#include \"TokenizerModules.hpp\"\n\n#include \"Notifier.hpp\"\n\nnamespace WCDB {\n\n// The order of member variables here is important.\nclass CommonCore final : public DatabasePoolEvent, public OperationEvent {\n#pragma mark - Core\npublic:\n    static CommonCore& shared();\n    ~CommonCore() override;\n\nprotected:\n    CommonCore();\n    CommonCore(const CommonCore&) = delete;\n    CommonCore& operator=(const CommonCore&) = delete;\n\n#pragma mark - Database\npublic:\n    RecyclableDatabase getOrCreateDatabase(const UnsafeStringView& path);\n\n    void purgeDatabasePool();\n    void releaseSQLiteMemory(int bytes);\n    void setSoftHeapLimit(int64_t limit);\n\n    void stopQueue();\n\nprotected:\n    void databaseDidCreate(InnerDatabase* database) override final;\n    DatabasePool m_databasePool;\n\n#pragma mark - Error\npublic:\n    void setThreadedErrorPath(const UnsafeStringView& path);\n    void setThreadedErrorIgnorable(bool ignorable);\n\nprotected:\n    void preprocessError(Error& error);\n    ThreadLocal<bool> m_errorIgnorable;\n    ThreadLocal<StringView> m_errorPath;\n\n#pragma mark - ScalarFunction\npublic:\n    void registerScalarFunction(const UnsafeStringView& name,\n                                const ScalarFunctionModule& module);\n    std::shared_ptr<Config> scalarFunctionConfig(const UnsafeStringView& ScalarFunctionName);\n    bool scalarFunctionExists(const UnsafeStringView& name) const;\n\nprotected:\n    std::shared_ptr<ScalarFunctionModules> m_scalarFunctionModules;\n\n#pragma mark - Tokenizer\npublic:\n    void registerTokenizer(const UnsafeStringView& name, const TokenizerModule& module);\n    std::shared_ptr<Config> tokenizerConfig(const UnsafeStringView& tokenizeName);\n    bool tokenizerExists(const UnsafeStringView& name) const;\n\nprotected:\n    std::shared_ptr<TokenizerModules> m_tokenizerModules;\n\n#pragma mark - AuxiliaryFunction\npublic:\n    void registerAuxiliaryFunction(const UnsafeStringView& name,\n                                   const FTS5AuxiliaryFunctionModule& module);\n    std::shared_ptr<Config>\n    auxiliaryFunctionConfig(const UnsafeStringView& auxiliaryFunctionName);\n    bool auxiliaryFunctionExists(const UnsafeStringView& name) const;\n\nprotected:\n    std::shared_ptr<AuxiliaryFunctionModules> m_auxiliaryFunctionModules;\n\n#pragma mark - Operation\npublic:\n    void stopAllDatabaseEvent(const UnsafeStringView& path);\n    typedef std::function<void(InnerDatabase*)> CorruptedNotification;\n    bool isFileObservedCorrupted(const UnsafeStringView& path);\n    void setNotificationWhenDatabaseCorrupted(const UnsafeStringView& path,\n                                              const CorruptedNotification& notification);\n\nprotected:\n    Optional<bool> migrationShouldBeOperated(const UnsafeStringView& path) override final;\n    Optional<bool> compressionShouldBeOperated(const UnsafeStringView& path) override final;\n    void backupShouldBeOperated(const UnsafeStringView& path) override final;\n    void checkpointShouldBeOperated(const UnsafeStringView& path) override final;\n    void integrityShouldBeChecked(const UnsafeStringView& path) override final;\n    void purgeShouldBeOperated() override final;\n\n    std::shared_ptr<OperationQueue> m_operationQueue;\n\n#pragma mark - Checkpoint\npublic:\n    void enableAutoCheckpoint(InnerDatabase* database, bool enable);\n    void setCheckPointMinFrames(int frames);\n\nprivate:\n    std::shared_ptr<Config> m_autoCheckpointConfig;\n\n#pragma mark - Backup\npublic:\n    void enableAutoBackup(InnerDatabase* database, bool enable);\n\n    void tryRegisterIncrementalMaterial(const UnsafeStringView& path,\n                                        SharedIncrementalMaterial material);\n    SharedIncrementalMaterial tryGetIncrementalMaterial(const UnsafeStringView& path);\n\nprotected:\n    std::shared_ptr<Config> m_autoBackupConfig;\n\n#pragma mark - Migration\npublic:\n    void enableAutoMigrate(InnerDatabase* database, bool enable);\n\nprotected:\n    std::shared_ptr<Config> m_autoMigrateConfig;\n\n#pragma mark - Compression\npublic:\n    void enableAutoCompress(InnerDatabase* database, bool enable);\n\nprotected:\n    std::shared_ptr<Config> m_autoCompressConfig;\n\n#pragma mark - Trace\npublic:\n    void setNotificationForSQLGLobalTraced(const ShareableSQLTraceConfig::Notification& notification);\n    void setNotificationWhenPerformanceGlobalTraced(\n    const ShareablePerformanceTraceConfig::Notification& notification);\n    void setNotificationWhenErrorTraced(const Notifier::Callback& notification);\n    void setNotificationWhenErrorTraced(const UnsafeStringView& path,\n                                        const Notifier::Callback& notification);\n\nprotected:\n    std::shared_ptr<Config> m_globalSQLTraceConfig;\n    std::shared_ptr<Config> m_globalPerformanceTraceConfig;\n\n    void globalLog(int rc, const char* message);\n\n    static void breakpoint() WCDB_USED WCDB_NO_INLINE;\n    static void print(const UnsafeStringView& message);\n\n#pragma mark - Busy Retry\npublic:\n    typedef std::function<void(const Tag&, const UnsafeStringView&, uint64_t, const UnsafeStringView)> BusyMonitor;\n    void setBusyMonitor(BusyMonitor monitor, double timeOut);\n    bool isBusyTraceEnable() const;\n\nprotected:\n    std::shared_ptr<Config> m_globalBusyRetryConfig;\n    bool m_enableBusyTrace;\n\n#pragma mark - Merge FTS Index\npublic:\n    using TableArray = OperationQueue::TableArray;\n    void enableAutoMergeFTSIndex(InnerDatabase* database, bool enable);\n    Optional<bool> mergeFTSIndexShouldBeOperated(const UnsafeStringView& path,\n                                                 TableArray newTables,\n                                                 TableArray modifiedTables) override final;\n\nprotected:\n    std::shared_ptr<Config> m_AutoMergeFTSConfig;\n\n#pragma mark - Integrity\npublic:\n    void skipIntegrityCheck(const UnsafeStringView& path);\n\n#pragma mark - Config\npublic:\n    void setABTestConfig(const UnsafeStringView& configName,\n                         const UnsafeStringView& configValue);\n    void removeABTestConfig(const UnsafeStringView& configName);\n    Optional<UnsafeStringView> getABTestConfig(const UnsafeStringView& configName);\n\n    void setDefaultCipherConfiguration(int version);\n    bool setDefaultTemporaryDirectory(const UnsafeStringView& dir);\n\nprotected:\n    Configs m_configs;\n    mutable SharedLock m_memory;\n    StringViewMap<StringView> m_abtestConfig;\n};\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/core/CoreConst.cpp",
    "content": "//\n// Created by qiuwenchen on 2023/8/6.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"CoreConst.h\"\n\nnamespace WCDB {\n\nWCDBLiteralStringImplement(OperationQueueName);\n\nWCDBLiteralStringImplement(AutoCheckpointConfigName);\n\nWCDBLiteralStringImplement(AutoBackupConfigName);\n\nWCDBLiteralStringImplement(AutoMigrateConfigName);\n\nWCDBLiteralStringImplement(AutoCompressConfigName);\n\nWCDBLiteralStringImplement(AutoMergeFTSIndexConfigName);\n\nWCDBLiteralStringImplement(AutoMergeFTSIndexQueueName);\n\nWCDBLiteralStringImplement(BasicConfigName);\n\nWCDBLiteralStringImplement(BusyRetryConfigName);\n\nWCDBLiteralStringImplement(CipherConfigName);\n\nWCDBLiteralStringImplement(GlobalSQLTraceConfigName);\n\nWCDBLiteralStringImplement(GlobalPerformanceTraceConfigName);\n\nWCDBLiteralStringImplement(PerformanceTraceConfigName);\n\nWCDBLiteralStringImplement(SQLTraceConfigName);\n\nWCDBLiteralStringImplement(TokenizeConfigPrefix);\n\nWCDBLiteralStringImplement(AuxiliaryFunctionConfigPrefix);\n\nWCDBLiteralStringImplement(ScalarFunctionConfigPrefix);\n\nWCDBLiteralStringImplement(AutoVacuumConfigName);\n\nWCDBLiteralStringImplement(NotifierPreprocessorName);\n\nWCDBLiteralStringImplement(NotifierLoggerName);\n\nWCDBLiteralStringImplement(ErrorStringKeyType);\nWCDBLiteralStringImplement(ErrorStringKeySource);\nWCDBLiteralStringImplement(ErrorStringKeyPath);\nWCDBLiteralStringImplement(ErrorStringKeyAssociatePath);\nWCDBLiteralStringImplement(ErrorStringKeySQL);\nWCDBLiteralStringImplement(ErrorIntKeyTag);\nWCDBLiteralStringImplement(ErrorIntKeyExtCode);\n\nWCDBLiteralStringImplement(ErrorSourceSQLite);\nWCDBLiteralStringImplement(ErrorSourceRepair);\nWCDBLiteralStringImplement(ErrorSourceSystem);\nWCDBLiteralStringImplement(ErrorSourceAssertion);\nWCDBLiteralStringImplement(ErrorSourceNative);\nWCDBLiteralStringImplement(ErrorSourceSwift);\nWCDBLiteralStringImplement(ErrorSourceZstd);\n\nWCDBLiteralStringImplement(ErrorTypeMigrate);\nWCDBLiteralStringImplement(ErrorTypeCompress);\nWCDBLiteralStringImplement(ErrorTypeCheckpoint);\nWCDBLiteralStringImplement(ErrorTypeIntegrity);\nWCDBLiteralStringImplement(ErrorTypeBackup);\nWCDBLiteralStringImplement(ErrorTypeMergeIndex);\n\nWCDBLiteralStringImplement(MonitorInfoKeyHandleCount);\nWCDBLiteralStringImplement(MonitorInfoKeyHandleOpenTime);\nWCDBLiteralStringImplement(MonitorInfoKeyHandleOpenCPUTime);\nWCDBLiteralStringImplement(MonitorInfoKeySchemaUsage);\nWCDBLiteralStringImplement(MonitorInfoKeyTableCount);\nWCDBLiteralStringImplement(MonitorInfoKeyIndexCount);\nWCDBLiteralStringImplement(MonitorInfoKeyTriggerCount);\n\nWCDBLiteralStringImplement(DecoratorAllType);\nWCDBLiteralStringImplement(DecoratorMigratingHandleStatement);\nWCDBLiteralStringImplement(DecoratorMigratingHandle);\nWCDBLiteralStringImplement(DecoratorCompressingHandleStatement);\nWCDBLiteralStringImplement(DecoratorCompressingHandle);\n\nWCDBLiteralStringImplement(OperatorMigrate);\nWCDBLiteralStringImplement(OperatorCompress);\nWCDBLiteralStringImplement(OperatorBackup);\nWCDBLiteralStringImplement(OperatorCheckIntegrity);\n\n}; // namespace WCDB\n"
  },
  {
    "path": "src/common/core/CoreConst.h",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"Macro.h\"\n#include \"StringView.hpp\"\n\nnamespace WCDB {\n\n#pragma mark - Async Queue\nstatic constexpr const double AsyncQueueTimeOutForExiting = 10.0;\n\n#pragma mark - Operation Queue\nWCDBLiteralStringDefine(OperationQueueName, \"WCDB.Operation\");\nstatic constexpr double OperationQueueTimeIntervalForRetringAfterFailure = 5.0;\n#pragma mark - Operation Queue - Migration\nstatic constexpr const double OperationQueueTimeIntervalForMigration = 2.0;\nstatic constexpr const int OperationQueueTolerableFailuresForMigration = 5;\n#pragma mark - Operation Queue - Compression\nstatic constexpr const double OperationQueueTimeIntervalForCompression = 0.2;\nstatic constexpr const int OperationQueueTolerableFailuresForCompression = 5;\n#pragma mark - Operation Queue - Purge\nstatic constexpr const double OperationQueueTimeIntervalForPurgingAgain = 30.0;\nstatic constexpr const double OperationQueueRateForTooManyFileDescriptors = 0.7;\n#pragma mark - Operation Queue - Checkpoint\nstatic constexpr const double OperationQueueTimeIntervalForCheckpoint = 10.0;\n#pragma mark - Operation Queue - Backup\n#ifndef WCDB_QUICK_TESTS\nstatic double OperationQueueTimeIntervalForBackup = 600.0;\n#else\nstatic double OperationQueueTimeIntervalForBackup = 10.0;\n#endif\n#pragma mark - Operation Queue - Merge FTS Index\nstatic constexpr const double OperationQueueTimeIntervalForMergeFTSIndex\n= 1.871; //Use prime numbers to reduce the probability of collision with external logic\n\n#pragma mark - Config - Auto Checkpoint\nWCDBLiteralStringDefine(AutoCheckpointConfigName, \"com.Tencent.WCDB.Config.AutoCheckpoint\");\n#pragma mark - Config - Auto Backup\nWCDBLiteralStringDefine(AutoBackupConfigName, \"com.Tencent.WCDB.Config.AutoBackup\");\n#pragma mark - Config - Auto Migrate\nWCDBLiteralStringDefine(AutoMigrateConfigName, \"com.Tencent.WCDB.Config.AutoMigrate\");\n#pragma mark - Config - Auto Compress\nWCDBLiteralStringDefine(AutoCompressConfigName, \"com.Tencent.WCDB.Config.AutoCompress\");\n#pragma mark - Config - Auto Merge\nWCDBLiteralStringDefine(AutoMergeFTSIndexConfigName, \"com.Tencent.WCDB.Config.AutoMergeFTSIndex\");\nWCDBLiteralStringDefine(AutoMergeFTSIndexQueueName, \"WCDB.MergeIndex\");\nstatic constexpr const int AutoMergeFTS5IndexMinSegmentCount = 4;\nstatic constexpr const double AutoMergeFTSIndexMaxExpectingDuration = 0.02;\nstatic constexpr const double AutoMergeFTSIndexMaxInitializeDuration = 0.005;\n#pragma mark - Config - Basic\nWCDBLiteralStringDefine(BasicConfigName, \"com.Tencent.WCDB.Config.Basic\");\nstatic constexpr const int BasicConfigBusyRetryMaxAllowedNumberOfTimes = 3;\n#pragma mark - Config - Busy Retry\nWCDBLiteralStringDefine(BusyRetryConfigName, \"com.Tencent.WCDB.Config.BusyRetry\");\nstatic constexpr const double BusyRetryTimeOut = 10.0;\n#pragma mark - Config - Cipher\nWCDBLiteralStringDefine(CipherConfigName, \"com.Tencent.WCDB.Config.Cipher\");\n#pragma mark - Config - Global SQL Trace\nWCDBLiteralStringDefine(GlobalSQLTraceConfigName, \"com.Tencent.WCDB.Config.GlobalSQLTrace\");\n#pragma mark - Config - Global Performance Trace\nWCDBLiteralStringDefine(GlobalPerformanceTraceConfigName,\n                        \"com.Tencent.WCDB.Config.GlobalPerformanceTrace\");\n#pragma mark - Config - Performance Trace\nWCDBLiteralStringDefine(PerformanceTraceConfigName, \"com.Tencent.WCDB.Config.PerformanceTrace\");\n#pragma mark - Config - SQL Trace\nWCDBLiteralStringDefine(SQLTraceConfigName, \"com.Tencent.WCDB.Config.SQLTrace\");\n#pragma mark - Config - Tokenize\nWCDBLiteralStringDefine(TokenizeConfigPrefix, \"com.Tencent.WCDB.Config.Tokenize.\");\n#pragma mark - Config - ScalarFunction\nWCDBLiteralStringDefine(ScalarFunctionConfigPrefix, \"com.Tencent.WCDB.Config.ScalarFunction.\");\n#pragma mark - Config - AuxiliaryFunction\nWCDBLiteralStringDefine(AuxiliaryFunctionConfigPrefix,\n                        \"com.Tencent.WCDB.Config.AuxiliaryFunction.\");\n#pragma mark - Config - AutoVaccum\nWCDBLiteralStringDefine(AutoVacuumConfigName, \"com.Tencent.WCDB.Config.AutoVaccum\");\n\n#pragma mark - Notifier\nWCDBLiteralStringDefine(NotifierPreprocessorName, \"com.Tencent.WCDB.Notifier.PreprocessTag\");\nWCDBLiteralStringDefine(NotifierLoggerName, \"com.Tencent.WCDB.Notifier.Log\");\n\n#pragma mark - Handle Pool\nstatic constexpr const int HandlePoolMaxAllowedNumberOfHandles = 32;\nstatic constexpr const int HandlePoolMaxAllowedNumberOfWriters = 4;\n\nenum HandleSlot : unsigned char {\n    HandleSlotNormal = 0,\n    HandleSlotAutoTask,\n    HandleSlotAssemble,\n    HandleSlotVacuum,\n    HandleSlotCipher,\n    HandleSlotCount,\n};\n\nenum HandleCategory : unsigned char {\n    HandleCategoryNormal = 0,\n    HandleCategoryMigrate,\n    HandleCategoryCompress,\n    HandleCategoryBackup,\n    HandleCategoryCipher,\n    HandleCategoryCheckpoint,\n    HandleCategoryIntegrity,\n    HandleCategoryMergeIndex,\n    HandleCategoryVacuum,\n    HandleCategoryCount,\n};\n\nenum class HandleType : unsigned int {\n    Normal = (HandleCategoryNormal << 8) | HandleSlotNormal,\n    Migrate = (HandleCategoryMigrate << 8) | HandleSlotAutoTask,\n    Compress = (HandleCategoryCompress << 8) | HandleSlotAutoTask,\n    BackupCipher = (HandleCategoryCipher << 8) | HandleSlotCipher,\n    Backup = (HandleCategoryBackup << 8) | HandleSlotAutoTask,\n    Checkpoint = (HandleCategoryCheckpoint << 8) | HandleSlotAutoTask,\n    IntegrityCheck = (HandleCategoryIntegrity << 8) | HandleSlotAutoTask,\n    Assemble = (HandleCategoryNormal << 8) | HandleSlotAssemble,\n    AssembleCipher = (HandleCategoryCipher << 8) | HandleSlotCipher,\n    AssembleBackup = (HandleCategoryBackup << 8) | HandleSlotAssemble,\n    Vacuum = (HandleCategoryVacuum << 8) | HandleSlotVacuum,\n    AutoVacuum = (HandleCategoryVacuum << 8) | HandleSlotAutoTask,\n    MergeIndex = (HandleCategoryMergeIndex << 8) | HandleSlotAutoTask,\n};\nstatic constexpr HandleSlot slotOfHandleType(HandleType type)\n{\n    return HandleSlot(((unsigned int) type) & 0xff);\n}\nstatic constexpr HandleCategory categoryOfHandleType(HandleType type)\n{\n    return HandleCategory(((unsigned int) type >> 8) & 0xff);\n}\nstatic constexpr bool handleShouldWaitWhenFull(HandleType type)\n{\n    return type == HandleType::Normal;\n}\n\n#pragma mark - Backup\nstatic constexpr const int BackupMaxIncrementalTimes = 1000;\nstatic constexpr const int BackupMaxIncrementalPageCount = 1000;\nstatic constexpr const int BackupMaxAllowIncrementalPageCount = 1000000;\n\n#pragma mark - Migrate\nstatic constexpr const int MigrationBatchCount = 100;\n\n#pragma mark - Compression\nstatic constexpr const int CompressionBatchCount = 10;\nstatic constexpr const int CompressionUpdateRecordBatchCount = 1000;\n\n#pragma mark - Vacuum\nstatic constexpr const int VacuumBatchCount = 1000;\n\nWCDBLiteralStringDefine(ErrorStringKeyType, \"Type\");\nWCDBLiteralStringDefine(ErrorStringKeySource, \"Source\")\n\n#define WCDB_ERROR_STRING_KEY_PATH \"Path\"\nWCDBLiteralStringDefine(ErrorStringKeyPath, WCDB_ERROR_STRING_KEY_PATH);\n\n#define WCDB_ERROR_STRING_KEY_ASSOCIATE_PATH \"AssociatePath\"\nWCDBLiteralStringDefine(ErrorStringKeyAssociatePath, WCDB_ERROR_STRING_KEY_ASSOCIATE_PATH);\n\n#define WCDB_ERROR_STRING_KEY_SQL \"SQL\"\nWCDBLiteralStringDefine(ErrorStringKeySQL, WCDB_ERROR_STRING_KEY_SQL);\n\n#define WCDB_ERROR_INT_KEY_TAG \"Tag\"\nWCDBLiteralStringDefine(ErrorIntKeyTag, WCDB_ERROR_INT_KEY_TAG);\n\n#define WCDB_ERROR_INT_KEY_EXTCODE \"ExtCode\"\nWCDBLiteralStringDefine(ErrorIntKeyExtCode, WCDB_ERROR_INT_KEY_EXTCODE);\n\n#pragma mark - Error - Source\nWCDBLiteralStringDefine(ErrorSourceSQLite, \"SQLite\");\nWCDBLiteralStringDefine(ErrorSourceRepair, \"Repair\");\nWCDBLiteralStringDefine(ErrorSourceSystem, \"System\");\nWCDBLiteralStringDefine(ErrorSourceAssertion, \"Assertion\");\nWCDBLiteralStringDefine(ErrorSourceNative, \"Native\");\nWCDBLiteralStringDefine(ErrorSourceSwift, \"Swift\");\nWCDBLiteralStringDefine(ErrorSourceZstd, \"Zstd\");\n\n#pragma mark - Error - Type\nWCDBLiteralStringDefine(ErrorTypeMigrate, \"Migrate\");\nWCDBLiteralStringDefine(ErrorTypeCompress, \"Compress\");\nWCDBLiteralStringDefine(ErrorTypeCheckpoint, \"Checkpoint\");\nWCDBLiteralStringDefine(ErrorTypeIntegrity, \"Integrity\");\nWCDBLiteralStringDefine(ErrorTypeBackup, \"Backup\")\nWCDBLiteralStringDefine(ErrorTypeMergeIndex, \"MergeIndex\")\n\n#pragma mark - Moniter\nWCDBLiteralStringDefine(MonitorInfoKeyHandleCount, \"HandleCount\");\nWCDBLiteralStringDefine(MonitorInfoKeyHandleOpenTime, \"OpenTime\");\nWCDBLiteralStringDefine(MonitorInfoKeyHandleOpenCPUTime, \"OpenCPUTime\");\nWCDBLiteralStringDefine(MonitorInfoKeySchemaUsage, \"SchemaUsage\");\nWCDBLiteralStringDefine(MonitorInfoKeyTableCount, \"TableCount\");\nWCDBLiteralStringDefine(MonitorInfoKeyIndexCount, \"IndexCount\");\nWCDBLiteralStringDefine(MonitorInfoKeyTriggerCount, \"TriggerCount\");\n\n#pragma mark - Decorator\nWCDBLiteralStringDefine(DecoratorAllType, \"AllType\");\nWCDBLiteralStringDefine(DecoratorMigratingHandleStatement, \"MigratingHandleStatement\");\nWCDBLiteralStringDefine(DecoratorMigratingHandle, \"MigratingHandle\");\nWCDBLiteralStringDefine(DecoratorCompressingHandleStatement, \"CompressingHandleStatement\");\nWCDBLiteralStringDefine(DecoratorCompressingHandle, \"CompressingHandle\");\n\n#pragma mark - HandleOperator\nWCDBLiteralStringDefine(OperatorMigrate, \"Migrate\");\nWCDBLiteralStringDefine(OperatorCompress, \"Compress\");\nWCDBLiteralStringDefine(OperatorBackup, \"Backup\");\nWCDBLiteralStringDefine(OperatorCheckIntegrity, \"CheckIntegrity\");\n\n#pragma mark - Tag\nstatic constexpr const int TagInvalidValue = 0;\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/core/DatabasePool.cpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"DatabasePool.hpp\"\n#include \"Assertion.hpp\"\n\nnamespace WCDB {\n\nDatabasePoolEvent::~DatabasePoolEvent() = default;\n\n#pragma mark - DatabasePool\nDatabasePool::DatabasePool(DatabasePoolEvent *event) : m_event(event)\n{\n    WCTAssert(m_event != nullptr);\n}\n\nRecyclableDatabase DatabasePool::getOrCreate(const UnsafeStringView &path)\n{\n    {\n        SharedLockGuard lockGuard(m_lock);\n        auto iter = m_databases.find(path);\n        if (iter != m_databases.end()) {\n            return get(iter);\n        }\n    }\n    LockGuard lockGuard(m_lock);\n    auto iter = m_databases.find(path);\n    if (iter != m_databases.end()) {\n        return get(iter);\n    }\n    ReferencedDatabase referencedDatabase(std::make_shared<InnerDatabase>(path));\n    auto result = m_databases.emplace(path, std::move(referencedDatabase));\n    WCTAssert(result.second);\n    m_event->databaseDidCreate(result.first->second.database.get());\n    return get(result.first);\n}\n\nTag DatabasePool::getTag(const UnsafeStringView &path)\n{\n    SharedLockGuard lockGuard(m_lock);\n    auto iter = m_databases.find(path);\n    if (iter != m_databases.end()) {\n        return iter->second.database->getTag();\n    } else {\n        return Tag::invalid();\n    }\n}\n\nDatabasePool::ReferencedDatabase::ReferencedDatabase(std::shared_ptr<InnerDatabase> &&database_)\n: database(std::move(database_)), reference(0)\n{\n}\n\nDatabasePool::ReferencedDatabase::ReferencedDatabase(ReferencedDatabase &&other)\n: database(std::move(other.database)), reference(other.reference.load())\n{\n    other.reference = 0;\n}\n\nRecyclableDatabase\nDatabasePool::get(const StringViewMap<ReferencedDatabase>::iterator &iter)\n{\n    WCTAssert(m_lock.readSafety());\n    WCTAssert(iter != m_databases.end());\n    ++iter->second.reference;\n    return RecyclableDatabase(\n    iter->second.database.get(),\n    std::bind(&DatabasePool::flowBack, this, std::placeholders::_1));\n}\n\nvoid DatabasePool::flowBack(InnerDatabase *database)\n{\n    // shared lock is enough.\n    SharedLockGuard lockGuard(m_lock);\n    const auto &iter = m_databases.find(database->getPath());\n    WCTAssert(iter != m_databases.end());\n    WCTAssert(iter->second.database.get() == database);\n    if (--iter->second.reference == 0) {\n        // A created database will never be erased. Instead, it will be empty so that the memory used will be very low.\n        iter->second.database->close(nullptr);\n    }\n}\n\nvoid DatabasePool::purge()\n{\n    SharedLockGuard lockGuard(m_lock);\n    for (const auto &iter : m_databases) {\n        if (!iter.second.database->isBlockaded()) {\n            iter.second.database->purge();\n        }\n    }\n}\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/common/core/DatabasePool.hpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"InnerDatabase.hpp\"\n#include \"Lock.hpp\"\n#include \"Path.hpp\"\n#include \"Tag.hpp\"\n\nnamespace WCDB {\n\ntypedef Recyclable<InnerDatabase*> RecyclableDatabase;\n\nclass DatabasePoolEvent {\npublic:\n    virtual ~DatabasePoolEvent() = 0;\n\nprotected:\n    virtual void databaseDidCreate(InnerDatabase* database) = 0;\n    friend class DatabasePool;\n};\n\nclass DatabasePool final {\n#pragma mark - DatabasePool\npublic:\n    DatabasePool(DatabasePoolEvent* event);\n\n    RecyclableDatabase getOrCreate(const UnsafeStringView& path);\n    Tag getTag(const UnsafeStringView& path);\n\n    void purge();\n\nprotected:\n    struct ReferencedDatabase {\n        ReferencedDatabase(std::shared_ptr<InnerDatabase>&& database);\n        ReferencedDatabase(ReferencedDatabase&& other);\n        std::shared_ptr<InnerDatabase> database;\n        std::atomic<int> reference;\n    };\n    typedef struct ReferencedDatabase ReferencedDatabase;\n\n    RecyclableDatabase get(const StringViewMap<ReferencedDatabase>::iterator& iter);\n    void flowBack(InnerDatabase* database);\n\n    StringViewMap<ReferencedDatabase> m_databases; //path->{database, reference}\n    SharedLock m_lock;\n\n    DatabasePoolEvent* m_event;\n};\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/common/core/HandleCounter.cpp",
    "content": "//\n// Created by 陈秋文 on 2023/8/13.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"HandleCounter.hpp\"\n#include \"Assertion.hpp\"\n#include <condition_variable>\n\nnamespace WCDB {\n\nHandleCounter::HandleCounter() : m_writerCount(0), m_totalCount(0)\n{\n}\n\nHandleCounter::~HandleCounter() = default;\n\nbool HandleCounter::tryIncreaseHandleCount(HandleType type, bool writeHint)\n{\n    std::unique_lock<std::mutex> lockGuard(m_lock);\n    while (m_totalCount >= HandlePoolMaxAllowedNumberOfHandles\n           || (writeHint && m_writerCount >= HandlePoolMaxAllowedNumberOfWriters)) {\n        while (m_totalCount >= HandlePoolMaxAllowedNumberOfHandles) {\n            if (!handleShouldWaitWhenFull(type)) {\n                return false;\n            }\n            m_pendingNormals.push_back(Thread::current());\n            m_conditionalNormals.wait(lockGuard);\n            m_pendingNormals.pop_front();\n        }\n        while (writeHint && m_writerCount >= HandlePoolMaxAllowedNumberOfWriters) {\n            if (!handleShouldWaitWhenFull(type)) {\n                return false;\n            }\n            m_pendingWriters.push_back(Thread::current());\n            m_conditionalWriters.wait(lockGuard);\n            m_pendingWriters.pop_front();\n        }\n    }\n    if (writeHint) {\n        m_writerCount++;\n    }\n    m_totalCount++;\n    return true;\n}\n\nvoid HandleCounter::decreaseHandleCount(bool writeHint)\n{\n    bool hasNotified = false;\n    std::unique_lock<std::mutex> lockGuard(m_lock);\n    if (writeHint) {\n        m_writerCount--;\n        WCTAssert(m_writerCount >= 0);\n        if (m_pendingWriters.size() > 0) {\n#ifdef __APPLE__\n            m_conditionalWriters.notify(m_pendingWriters.front());\n#else\n            m_conditionalWriters.notify_all();\n#endif\n            hasNotified = true;\n        }\n    }\n    m_totalCount--;\n    WCTAssert(m_totalCount >= 0);\n    if (!hasNotified && m_pendingNormals.size() > 0) {\n#ifdef __APPLE__\n        m_conditionalNormals.notify(m_pendingNormals.front());\n#else\n        m_conditionalNormals.notify_all();\n#endif\n    }\n}\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/core/HandleCounter.hpp",
    "content": "//\n// Created by 陈秋文 on 2023/8/13.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"CoreConst.h\"\n#include \"Lock.hpp\"\n#include \"Thread.hpp\"\n\nnamespace WCDB {\n\n/*\n * When obtaining a database handle, you can indicate whether\n * this handle will be used to write new data to the database.\n *\n * The handle counter is used to limit the number of handles in two ways:\n * 1. Only 4 handles can exist for writing at the same time.\n *    Because it is difficult to accurately distinguish whether the handle is used for writing,\n *    and there is still a little time between getting the handle and writing data,\n *    let the four handles fully compete.\n * 2. Only up to 32 handles can exist at the same time.\n *    Too many handles not only take up memory, but generally imply inappropriate usage.\n *\n * When the number limit is exceeded, the handle counter will let the thread\n * that acquires the handle wait in place until other handles are recycled.\n */\n\nclass HandleCounter {\npublic:\n    HandleCounter();\n    ~HandleCounter();\n    HandleCounter(const HandleCounter &) = delete;\n    HandleCounter &operator=(const HandleCounter &) = delete;\n\n    bool tryIncreaseHandleCount(HandleType type, bool writeHint);\n    void decreaseHandleCount(bool writeHint);\n\nprivate:\n    mutable std::mutex m_lock;\n    Conditional m_conditionalNormals;\n    Conditional m_conditionalWriters;\n    std::list<Thread> m_pendingNormals;\n    std::list<Thread> m_pendingWriters;\n    int m_writerCount = 0;\n    int m_totalCount = 0;\n};\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/core/HandlePool.cpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"HandlePool.hpp\"\n#include \"Assertion.hpp\"\n#include \"CoreConst.h\"\n#include \"FileManager.hpp\"\n#include \"InnerHandle.hpp\"\n#include \"Notifier.hpp\"\n#include \"Path.hpp\"\n#include \"Serialization.hpp\"\n#include <algorithm>\n#include <map>\n\nnamespace WCDB {\n\n#pragma mark - Initialize\nHandlePool::HandlePool(const UnsafeStringView &thePath) : path(thePath)\n{\n}\n\nHandlePool::~HandlePool()\n{\n    //wait until all handles back.\n    drain(nullptr);\n}\n\n#pragma mark - Concurrency\nbool HandlePool::isNumberOfHandlesAllowed() const\n{\n    WCTAssert(m_concurrency.readSafety());\n    WCTAssert(m_memory.readSafety());\n    return numberOfAliveHandles() <= HandlePoolMaxAllowedNumberOfHandles;\n}\n\nvoid HandlePool::blockade()\n{\n    m_concurrency.lock();\n}\n\nvoid HandlePool::unblockade()\n{\n    WCTRemedialAssert(m_concurrency.writeSafety(),\n                      \"Unblockade should not be called without blockaded.\",\n                      return;);\n    m_concurrency.unlock();\n}\n\nbool HandlePool::isBlockaded() const\n{\n    return m_concurrency.isLocked();\n}\n\nvoid HandlePool::didDrain()\n{\n}\n\nvoid HandlePool::drain(const HandlePool::DrainedCallback &onDrained)\n{\n    WCTRemedialAssert(m_concurrency.level() != SharedLock::Level::Read,\n                      \"There are some threaded handles not invalidated.\",\n                      return;);\n    LockGuard concurrencyGuard(m_concurrency);\n    LockGuard memoryGuard(m_memory);\n    clearAllHandles();\n    didDrain();\n    if (onDrained != nullptr) {\n        onDrained();\n        // double-clear since there might be some operations inside the drained block.\n        clearAllHandles();\n        didDrain();\n    }\n}\n\nvoid HandlePool::clearAllHandles()\n{\n    WCTAssert(m_concurrency.writeSafety());\n    WCTAssert(m_memory.writeSafety());\n    for (unsigned int i = 0; i < HandleSlotCount; ++i) {\n        m_frees[i].clear();\n        auto &handles = m_handles[i];\n        for (const auto &handle : handles) {\n            handle->close();\n        }\n        handles.clear();\n    }\n}\n\n#pragma mark - Handle\nvoid HandlePool::purge()\n{\n    SharedLockGuard concurrencyGuard(m_concurrency);\n    LockGuard memoryGuard(m_memory);\n    for (unsigned int i = 0; i < HandleSlotCount; ++i) {\n        auto &handles = m_handles[i];\n        auto &frees = m_frees[i];\n        for (const auto &handle : frees) {\n            handle->close();\n            handles.erase(handle);\n        }\n        frees.clear();\n    }\n}\n\nsize_t HandlePool::numberOfAliveHandles() const\n{\n    size_t count = 0;\n    {\n        SharedLockGuard concurrencyGuard(m_concurrency);\n        SharedLockGuard memoryGuard(m_memory);\n        for (const auto &handles : m_handles) {\n            count += handles.size();\n        }\n    }\n    return count;\n}\n\nbool HandlePool::isAliving() const\n{\n    bool aliving = false;\n    {\n        SharedLockGuard concurrencyGuard(m_concurrency);\n        SharedLockGuard memoryGuard(m_memory);\n        for (const auto &handles : m_handles) {\n            if (handles.size() > 0) {\n                aliving = true;\n                break;\n            }\n        }\n    }\n    return aliving;\n}\n\nconst std::set<std::shared_ptr<InnerHandle>> &HandlePool::getHandlesOfSlot(HandleSlot slot)\n{\n    WCTAssert(m_concurrency.readSafety());\n    WCTAssert(m_memory.readSafety());\n    WCTAssert(slot < HandleSlotCount);\n    return m_handles[slot];\n}\n\nsize_t HandlePool::numberOfAliveHandlesInSlot(HandleSlot slot) const\n{\n    SharedLockGuard concurrencyGuard(m_concurrency);\n    SharedLockGuard memoryGuard(m_memory);\n    return m_handles[slot].size();\n}\n\nRecyclableHandle HandlePool::flowOut(HandleType type, bool writeHint, bool threaded)\n{\n    HandleSlot slot = slotOfHandleType(type);\n    WCTAssert(slot < HandleSlotCount);\n    HandleCategory category = categoryOfHandleType(type);\n    WCTAssert(category < HandleCategoryCount);\n\n    ReferencedHandle &referencedHandle = m_threadedHandles.getOrCreate().at(category);\n    {\n        // threaded handles is thread safe.\n        if (referencedHandle.handle != nullptr) {\n            WCTAssert(m_concurrency.readSafety());\n            WCTAssert(referencedHandle.reference > 0 || referencedHandle.handle->isInTransaction());\n            WCTAssert(referencedHandle.handle->isUsingInThread(Thread::getCurrentThreadId()));\n            ++referencedHandle.reference;\n            return RecyclableHandle(\n            referencedHandle.handle,\n            std::bind(&HandlePool::flowBack, this, type, std::placeholders::_1));\n        } else if (threaded) {\n            return nullptr;\n        }\n    }\n\n    if (!m_counter.tryIncreaseHandleCount(type, writeHint)) {\n        Error error(Error::Code::Exceed,\n                    Error::Level::Error,\n                    \"The operating count of database exceeds the maximum allowed.\");\n        error.infos.insert_or_assign(\"MaxAllowed\", HandlePoolMaxAllowedNumberOfHandles);\n        error.infos.insert_or_assign(ErrorStringKeyPath, path);\n        Notifier::shared().notify(error);\n        setThreadedError(std::move(error));\n        return nullptr;\n    }\n\n    SharedLockGuard concurrencyGuard(m_concurrency);\n    std::shared_ptr<InnerHandle> handle;\n    {\n        LockGuard memoryGuard(m_memory);\n        auto &freeSlot = m_frees[slot];\n        if (!freeSlot.empty()) {\n            handle = freeSlot.back();\n            WCTAssert(handle != nullptr);\n            freeSlot.pop_back();\n        }\n    }\n\n    if (handle == nullptr) {\n        handle = generateSlotedHandle(type);\n        if (handle == nullptr) {\n            m_counter.decreaseHandleCount(writeHint);\n            return nullptr;\n        }\n\n        LockGuard memoryGuard(m_memory);\n        WCTAssert(m_handles[slot].find(handle) == m_handles[slot].end());\n        m_handles[slot].emplace(handle);\n\n        // Clean free handles of the other slots.\n        if (!isNumberOfHandlesAllowed()) {\n            purge();\n            WCTAssert(isNumberOfHandlesAllowed());\n        }\n    } else {\n        if (!willReuseSlotedHandle(type, handle.get())) {\n            handle->close();\n            {\n                LockGuard memoryGuard(m_memory);\n                // remove if the exists handle fails in handles\n                m_handles[slot].erase(handle);\n            }\n            m_counter.decreaseHandleCount(writeHint);\n            return nullptr;\n        }\n    }\n\n    WCTAssert(handle != nullptr);\n    handle->setWriteHint(writeHint);\n    handle->setActiveThreadId(Thread::getCurrentThreadId());\n\n    m_concurrency.lockShared();\n    WCTAssert(referencedHandle.handle == nullptr && referencedHandle.reference == 0);\n    referencedHandle.handle = handle;\n    referencedHandle.reference = 1;\n    return RecyclableHandle(\n    handle, std::bind(&HandlePool::flowBack, this, type, std::placeholders::_1));\n}\n\nvoid HandlePool::flowBack(HandleType type, const std::shared_ptr<InnerHandle> &handle)\n{\n    WCTAssert(handle != nullptr);\n    WCTAssert(m_concurrency.readSafety());\n\n    HandleSlot slot = slotOfHandleType(type);\n    WCTAssert(slot < HandleSlotCount);\n    HandleCategory category = categoryOfHandleType(type);\n    WCTAssert(category < HandleCategoryCount);\n\n    ReferencedHandle &referencedHandle = m_threadedHandles.getOrCreate().at(category);\n    WCTAssert(referencedHandle.handle == handle);\n    WCTAssert(referencedHandle.reference > 0);\n    if (--referencedHandle.reference == 0) {\n        if(handle->isOpened() && handle->isInTransaction()){\n            return;\n        }\n        referencedHandle.handle = nullptr;\n        bool writeHint = handle->getWriteHint();\n        WCTRemedialAssert(\n        !handle->isPrepared(), \"Statement is not finalized.\", handle->finalize(););\n        handle->detachCancellationSignal();\n        handle->finalizeStatements();\n        {\n            LockGuard memoryGuard(m_memory);\n            m_frees[slot].push_back(handle);\n            handle->setWriteHint(false);\n            handle->setActiveThreadId(0);\n        }\n        m_concurrency.unlockShared();\n        m_counter.decreaseHandleCount(writeHint);\n    }\n}\n\nHandlePool::ReferencedHandle::ReferencedHandle() : handle(nullptr), reference(0)\n{\n}\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/common/core/HandlePool.hpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"CoreConst.h\"\n#include \"ErrorProne.hpp\"\n#include \"HandleCounter.hpp\"\n#include \"Lock.hpp\"\n#include \"RecyclableHandle.hpp\"\n#include \"ThreadedErrors.hpp\"\n#include <array>\n#include <list>\n\nnamespace WCDB {\n\n/*\n * There are two kind of locks in the pool.\n * 1. Memory lock is to protect the memory order of the variable inside the pool.\n * 2. Concurrency lock is to blockade all other operations while closing.\n * Corcurrency is always locked before Memory.\n *\n * When you are writing and reading any variables, you should lock or shared lock memory.\n * When you are operating m_handles, you should lock or shared lock concurrency in addition.\n */\n\nclass HandlePool : public ThreadedErrorProne {\n#pragma mark - Initialize\npublic:\n    HandlePool() = delete;\n    HandlePool(const HandlePool &) = delete;\n    HandlePool &operator=(const HandlePool &) = delete;\n\n    HandlePool(const UnsafeStringView &path);\n    const StringView path;\n\n    virtual ~HandlePool() override;\n\n#pragma mark - Concurrency\npublic:\n    void blockade();\n    bool isBlockaded() const;\n    void unblockade();\n\n    typedef std::function<void(void)> DrainedCallback;\n    void drain(const HandlePool::DrainedCallback &onDrained);\n\nprotected:\n    virtual void didDrain();\n    mutable SharedLock m_concurrency;\n\nprivate:\n    bool isNumberOfHandlesAllowed() const;\n    void clearAllHandles();\n\n#pragma mark - Handle\npublic:\n    typedef unsigned int Slot;\n    RecyclableHandle flowOut(HandleType type, bool writeHint = false, bool threaded = false);\n    void purge();\n    size_t numberOfAliveHandles() const;\n    size_t numberOfAliveHandlesInSlot(HandleSlot slot) const;\n    bool isAliving() const;\n\nprotected:\n    virtual std::shared_ptr<InnerHandle> generateSlotedHandle(HandleType type) = 0;\n    virtual bool willReuseSlotedHandle(HandleType type, InnerHandle *handle) = 0;\n    const std::set<std::shared_ptr<InnerHandle>> &getHandlesOfSlot(HandleSlot slot);\n\n    mutable SharedLock m_memory;\n\n    std::array<std::set<std::shared_ptr<InnerHandle>>, HandleSlotCount> m_handles;\n\nprivate:\n    void flowBack(HandleType type, const std::shared_ptr<InnerHandle> &handle);\n    std::array<std::list<std::shared_ptr<InnerHandle>>, HandleSlotCount> m_frees;\n    HandleCounter m_counter;\n\n#pragma mark - Threaded\nprivate:\n    struct ReferencedHandle {\n        ReferencedHandle();\n\n        std::shared_ptr<InnerHandle> handle;\n        int reference;\n    };\n    typedef struct ReferencedHandle ReferencedHandle;\n\n    ThreadLocal<std::array<ReferencedHandle, HandleCategoryCount>> m_threadedHandles;\n};\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/common/core/InnerDatabase.cpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"InnerDatabase.hpp\"\n#include \"Assertion.hpp\"\n#include \"FileManager.hpp\"\n#include \"Notifier.hpp\"\n#include \"Path.hpp\"\n#include \"RepairKit.h\"\n#include \"StringView.hpp\"\n#include \"WCDBError.hpp\"\n\n#include \"AssembleHandleOperator.hpp\"\n#include \"BackupHandleOperator.hpp\"\n#include \"CompressHandleOperator.hpp\"\n#include \"IntegerityHandleOperator.hpp\"\n#include \"MigrateHandleOperator.hpp\"\n#include \"VacuumHandleOperator.hpp\"\n\n#include \"CompressingHandleDecorator.hpp\"\n#include \"MigratingHandleDecorator.hpp\"\n\n#include \"AutoVacuumConfig.hpp\"\n#include \"BasicConfig.hpp\"\n#include \"BusyRetryConfig.hpp\"\n#include \"CipherHandle.hpp\"\n#include \"CommonCore.hpp\"\n#include \"DBOperationNotifier.hpp\"\n#include \"DecorativeHandle.hpp\"\n#include \"SQLite.h\"\n\n#include <ctime>\n\nnamespace WCDB {\n\n#pragma mark - Initializer\nInnerDatabase::InnerDatabase(const UnsafeStringView &path)\n: HandlePool(path)\n, m_initialized(false)\n, m_closing(0)\n, m_tag(Tag::invalid())\n, m_isReadOnly(false)\n, m_fullSQLTrace(false)\n, m_liteModeEnable(false)\n, m_factory(path)\n, m_needLoadIncremetalMaterial(false)\n, m_migration(this)\n, m_migratedCallback(nullptr)\n, m_compression(this)\n, m_compressedCallback(nullptr)\n, m_isInMemory(false)\n, m_sharedInMemoryHandle(nullptr)\n, m_mergeLogic(this)\n{\n    StringViewMap<Value> info;\n    DBOperationNotifier::shared().notifyOperation(\n    this, DBOperationNotifier::Operation::Create, info);\n}\n\nInnerDatabase::~InnerDatabase() = default;\n\n#pragma mark - Basic\nvoid InnerDatabase::setTag(const Tag &tag)\n{\n    LockGuard memoryGuard(m_memory);\n    m_tag = tag;\n    StringViewMap<Value> info;\n    DBOperationNotifier::shared().notifyOperation(\n    this, DBOperationNotifier::Operation::SetTag, info);\n}\n\nTag InnerDatabase::getTag() const\n{\n    SharedLockGuard memoryGuard(m_memory);\n    return m_tag;\n}\n\nbool InnerDatabase::canOpen()\n{\n    CommonCore::shared().skipIntegrityCheck(getPath());\n    auto handle = getHandle();\n    CommonCore::shared().skipIntegrityCheck(nullptr);\n    return handle != nullptr;\n}\n\nvoid InnerDatabase::didDrain()\n{\n    WCTAssert(m_concurrency.writeSafety());\n    WCTAssert(m_memory.writeSafety());\n    WCTAssert(!isOpened());\n    m_initialized = false;\n}\n\nbool InnerDatabase::checkShouldInterruptWhenClosing(const UnsafeStringView &sourceType)\n{\n    if (m_closing != 0) {\n        Error error(Error::Code::Interrupt, Error::Level::Ignore, \"Interrupt due to it's closing.\");\n        error.infos.insert_or_assign(ErrorStringKeyPath, path);\n        error.infos.insert_or_assign(ErrorStringKeyType, sourceType);\n        Notifier::shared().notify(error);\n        setThreadedError(std::move(error));\n        return true;\n    }\n    return false;\n}\n\nvoid InnerDatabase::close(const ClosedCallback &onClosed)\n{\n    if (m_isInMemory) {\n        if (m_sharedInMemoryHandle != nullptr) {\n            m_sharedInMemoryHandle->close();\n        }\n        m_sharedInMemoryHandle = nullptr;\n        if (onClosed != nullptr) {\n            onClosed();\n            didDrain();\n        }\n        return;\n    }\n    ++m_closing;\n    {\n        SharedLockGuard concurrencyGuard(m_concurrency);\n        SharedLockGuard memoryGuard(m_memory);\n        // suspend auto checkpoint/backup/integrity check/migrate/compress/merge fts5 index\n        for (auto &handle : getHandlesOfSlot(HandleSlot::HandleSlotAutoTask)) {\n            handle->suspend(true);\n        }\n    }\n    CommonCore::shared().stopAllDatabaseEvent(getPath());\n    drain(onClosed);\n    --m_closing;\n}\n\nvoid InnerDatabase::setReadOnly()\n{\n    close([this] {\n        m_isReadOnly = true;\n        CommonCore::shared().enableAutoCheckpoint(this, false);\n    });\n}\n\nbool InnerDatabase::isOpened() const\n{\n    return isAliving();\n}\n\nInnerDatabase::InitializedGuard InnerDatabase::initialize()\n{\n    do {\n        {\n            SharedLockGuard concurrencyGuard(m_concurrency);\n            SharedLockGuard memoryGuard(m_memory);\n            if (m_initialized) {\n                return concurrencyGuard;\n            }\n        }\n\n        // Blocked initialization\n        LockGuard concurrencyGuard(m_concurrency);\n        LockGuard memoryGuard(m_memory);\n        if (m_initialized) {\n            // retry\n            continue;\n        }\n        if (m_isInMemory) {\n            m_initialized = true;\n            continue;\n        }\n        CommonCore::shared().setThreadedErrorPath(path);\n        if (!FileManager::createDirectoryWithIntermediateDirectories(Path::getDirectory(path))) {\n            assignWithSharedThreadedError();\n            break;\n        }\n        // vacuum\n        {\n            Repair::FactoryVacuum vacuumer = m_factory.vacuumer();\n            if (!vacuumer.work()) {\n                setThreadedError(vacuumer.getError());\n                break;\n            }\n        }\n        // retrieveRenewed\n        {\n            Repair::FactoryRenewer renewer = m_factory.renewer();\n            if (!renewer.work()) {\n                setThreadedError(renewer.getError());\n                break;\n            }\n        }\n        auto exists = FileManager::fileExists(path);\n        if (!exists.succeed()) {\n            assignWithSharedThreadedError();\n            break;\n        }\n        // create file to make file identifier stable\n        if (!exists.value() && !FileManager::createFile(path)) {\n            assignWithSharedThreadedError();\n            break;\n        }\n        CommonCore::shared().setThreadedErrorPath(nullptr);\n        m_initialized = true;\n    } while (true);\n    return nullptr;\n}\n\n#pragma mark - Config\nvoid InnerDatabase::setConfigs(const Configs &configs)\n{\n    LockGuard memoryGuard(m_memory);\n    m_configs = configs;\n}\n\nvoid InnerDatabase::setConfig(const UnsafeStringView &name,\n                              const std::shared_ptr<Config> &config,\n                              int priority)\n{\n    LockGuard memoryGuard(m_memory);\n    m_configs.insert(StringView(name), config, priority);\n}\n\nvoid InnerDatabase::removeConfig(const UnsafeStringView &name)\n{\n    LockGuard memoryGuard(m_memory);\n    m_configs.erase(StringView(name));\n}\n\nvoid InnerDatabase::setFullSQLTraceEnable(bool enable)\n{\n    m_fullSQLTrace = enable;\n}\n\nvoid InnerDatabase::setLiteModeEnable(bool enable)\n{\n    if (m_liteModeEnable != enable) {\n        close([&] {\n            m_liteModeEnable = enable;\n            CommonCore::shared().enableAutoCheckpoint(this, !m_liteModeEnable);\n        });\n    }\n}\n\nbool InnerDatabase::liteModeEnable()\n{\n    return m_liteModeEnable;\n}\n\n#pragma mark - Handle\nRecyclableHandle InnerDatabase::getHandle(bool writeHint, bool threaded)\n{\n    HandleType type = HandleType::Normal;\n    if (m_isInMemory) {\n        InitializedGuard initializedGuard = initialize();\n        if (m_sharedInMemoryHandle == nullptr) {\n            m_sharedInMemoryHandle = generateSlotedHandle(type);\n        }\n        return RecyclableHandle(m_sharedInMemoryHandle, nullptr);\n    }\n    InitializedGuard initializedGuard = initialize();\n    if (!initializedGuard.valid()) {\n        return nullptr;\n    }\n    auto handle = flowOut(type, writeHint, threaded);\n    return handle;\n}\n\nbool InnerDatabase::execute(const Statement &statement)\n{\n    RecyclableHandle handle = getHandle(statement.isWriteStatement());\n    if (handle != nullptr) {\n        if (handle->execute(statement)) {\n            return true;\n        }\n        setThreadedError(handle->getError());\n    }\n    return false;\n}\n\nbool InnerDatabase::execute(const UnsafeStringView &sql)\n{\n    RecyclableHandle handle = getHandle();\n    if (handle != nullptr) {\n        if (handle->execute(sql)) {\n            return true;\n        }\n        setThreadedError(handle->getError());\n    }\n    return false;\n}\n\nOptional<bool> InnerDatabase::tableExists(const UnsafeStringView &table)\n{\n    Optional<bool> exists;\n    RecyclableHandle handle = getHandle();\n    if (handle != nullptr) {\n        exists = handle->tableExists(table);\n        if (!exists.succeed()) {\n            setThreadedError(handle->getError());\n        }\n    }\n    return exists;\n}\n\nStringView InnerDatabase::getRunningSQLInThread(uint64_t tid) const\n{\n    SharedLockGuard concurrencyGuard(m_concurrency);\n    SharedLockGuard memoryGuard(m_memory);\n    for (const auto &handles : m_handles) {\n        for (const auto &handle : handles) {\n            if (handle->isUsingInThread(tid)) {\n                StringView sql = handle->getCurrentSQL();\n                if (!sql.empty()) {\n                    return sql;\n                }\n            }\n        }\n    }\n    return StringView();\n}\n\nstd::shared_ptr<InnerHandle> InnerDatabase::generateSlotedHandle(HandleType type)\n{\n    WCTAssert(m_concurrency.readSafety());\n    HandleSlot slot = slotOfHandleType(type);\n    std::shared_ptr<InnerHandle> handle;\n    switch (slot) {\n    case HandleSlotNormal:\n    case HandleSlotAutoTask:\n        handle = std::make_shared<DecorativeHandle>();\n        break;\n    case HandleSlotCipher:\n        handle = std::make_shared<CipherHandle>();\n        break;\n    default:\n        WCTAssert(slot == HandleSlotAssemble || slot == HandleSlotVacuum);\n        handle = std::make_shared<ConfiguredHandle>();\n        break;\n    }\n\n    if (handle == nullptr) {\n        setThreadedError(Error(Error::Code::NoMemory, Error::Level::Error));\n        return nullptr;\n    }\n\n    handle->setThreadedErrorProne(this);\n\n    if (!setupHandle(type, handle.get())) {\n        return nullptr;\n    }\n    return handle;\n}\n\nbool InnerDatabase::willReuseSlotedHandle(HandleType type, InnerHandle *handle)\n{\n    return setupHandle(type, handle);\n}\n\nbool InnerDatabase::setupHandle(HandleType type, InnerHandle *handle)\n{\n    WCTAssert(handle != nullptr);\n    if (m_isReadOnly) {\n        handle->setReadOnly();\n    }\n    handle->setTag(getTag());\n    handle->setType(type);\n    handle->setLiteModeEnable(m_liteModeEnable);\n    handle->setFullSQLTraceEnable(m_fullSQLTrace);\n    handle->setBusyTraceEnable(CommonCore::shared().isBusyTraceEnable());\n    HandleSlot slot = slotOfHandleType(type);\n    handle->enableWriteMainDB(m_liteModeEnable || slot == HandleSlotAutoTask\n                              || slot == HandleSlotAssemble || slot == HandleSlotVacuum);\n    handle->markAsCanBeSuspended(false);\n    handle->markErrorAsUnignorable(99); //Clear all ignorable code\n\n    // Decoration\n    if (slot == HandleSlotNormal || slot == HandleSlotAutoTask) {\n        bool hasDecorator = false;\n        WCTAssert(dynamic_cast<DecorativeHandle *>(handle) != nullptr);\n        DecorativeHandle *decorativeHandle = static_cast<DecorativeHandle *>(handle);\n        // CompressingHandleDecorator must be added before MigratingHandleDecorator.\n        if (m_compression.shouldCompress()) {\n            hasDecorator = true;\n            decorativeHandle->tryAddDecorator<CompressingHandleDecorator>(\n            DecoratorCompressingHandle, m_compression);\n        }\n        if (type == HandleType::Normal && m_migration.shouldMigrate()) {\n            hasDecorator = true;\n            decorativeHandle->tryAddDecorator<MigratingHandleDecorator>(\n            DecoratorMigratingHandle, m_migration);\n        }\n        if (!hasDecorator) {\n            decorativeHandle->clearDecorators();\n        }\n    }\n\n    Configs configs;\n    {\n        SharedLockGuard memoryGuard(m_memory);\n        configs = m_configs;\n    }\n    bool succeed = handle->reconfigure(configs);\n    if (!succeed) {\n        setThreadedError(handle->getError());\n        return false;\n    }\n\n    if (slot != HandleSlotAssemble && slot != HandleSlotVacuum && slot != HandleSlotCipher) {\n        handle->setPath(path);\n        bool hasOpened = handle->isOpened();\n        Time start = Time::now();\n        uint64_t cpuStart = Time::currentThreadCPUTimeInMicroseconds();\n        if (!handle->open()) {\n            setThreadedError(handle->getError());\n            return false;\n        }\n        if (!hasOpened && slot == HandleSlotNormal) {\n            std::time_t openTime\n            = (Time::now().nanoseconds() - start.nanoseconds()) / 1000;\n            uint64_t openCPUTime = Time::currentThreadCPUTimeInMicroseconds() - cpuStart;\n            int memoryUsed, tableCount, indexCount, triggerCount;\n            if (handle->getSchemaInfo(memoryUsed, tableCount, indexCount, triggerCount)) {\n                StringViewMap<Value> info;\n                info.insert_or_assign(MonitorInfoKeyHandleOpenTime, openTime);\n                info.insert_or_assign(MonitorInfoKeyHandleOpenCPUTime, openCPUTime);\n                info.insert_or_assign(MonitorInfoKeySchemaUsage, memoryUsed);\n                info.insert_or_assign(MonitorInfoKeyTableCount, tableCount);\n                info.insert_or_assign(MonitorInfoKeyIndexCount, indexCount);\n                info.insert_or_assign(MonitorInfoKeyTriggerCount, triggerCount);\n                info.insert_or_assign(MonitorInfoKeyHandleCount,\n                                      numberOfAliveHandlesInSlot(slot) + 1);\n                DBOperationNotifier::shared().notifyOperation(\n                this, DBOperationNotifier::Operation::OpenHandle, info);\n            }\n        }\n    } else if (slot == HandleSlotCipher) {\n        WCTAssert(dynamic_cast<CipherHandle *>(handle) != nullptr);\n        CipherHandle *cipherHandle = static_cast<CipherHandle *>(handle);\n        if (!cipherHandle->openCipherInMemory()) {\n            setThreadedError(cipherHandle->getCipherError());\n            return false;\n        }\n        auto salt = cipherHandle->tryGetSaltFromDatabase(getPath());\n        if (salt.failed()) {\n            assignWithSharedThreadedError();\n            return false;\n        } else if (salt.value().length() > 0) {\n            cipherHandle->setCipherSalt(salt.value());\n        }\n    }\n\n    return true;\n}\n\n#pragma mark - Transaction\nbool InnerDatabase::isInTransaction()\n{\n    auto threadedHandle = getHandle(false, true);\n    if(threadedHandle.get() == nullptr || !threadedHandle->isInTransaction()) {\n        return false;\n    }\n    return true;\n}\n\nbool InnerDatabase::beginTransaction()\n{\n    RecyclableHandle handle = getHandle(true);\n    if (handle == nullptr) {\n        return false;\n    }\n    if (handle->beginTransaction()) {\n        return true;\n    }\n    setThreadedError(handle->getError());\n    return false;\n}\n\nbool InnerDatabase::commitOrRollbackTransaction()\n{\n    RecyclableHandle handle = getHandle();\n    WCTRemedialAssert(handle != nullptr,\n                      \"Commit or rollback transaction should not be called without begin.\",\n                      return false;);\n    if (handle->commitOrRollbackTransaction()) {\n        return true;\n    }\n    setThreadedError(handle->getError());\n    return false;\n}\n\nvoid InnerDatabase::rollbackTransaction()\n{\n    RecyclableHandle handle = getHandle();\n    WCTRemedialAssert(handle != nullptr,\n                      \"Rollback transaction should not be called without begin.\",\n                      return;);\n    handle->rollbackTransaction();\n}\n\nbool InnerDatabase::runTransaction(const TransactionCallback &transaction)\n{\n    RecyclableHandle handle = getHandle(true);\n    if (handle == nullptr) return false;\n    if (!handle->runTransaction(transaction)) {\n        setThreadedError(handle->getError());\n        return false;\n    }\n    return true;\n}\n\nbool InnerDatabase::runPausableTransactionWithOneLoop(const TransactionCallbackForOneLoop &transaction)\n{\n    // get threaded handle\n    RecyclableHandle handle = getHandle(true);\n    if (handle == nullptr) return false;\n    if (!handle->runPausableTransactionWithOneLoop(transaction)) {\n        setThreadedError(handle->getError());\n        return false;\n    }\n    return true;\n}\n\n#pragma mark - File\nbool InnerDatabase::removeFiles()\n{\n    if (m_isInMemory) {\n        return false;\n    }\n    bool result = false;\n    close([&result, this]() {\n        std::list<StringView> paths = getPaths();\n        paths.reverse(); // reverse to remove the non-critical paths first avoiding app stopped between the removing\n        result = FileManager::removeItems(paths);\n        if (!result) {\n            assignWithSharedThreadedError();\n        }\n        m_migration.purge();\n        m_compression.purge();\n    });\n    return result;\n}\n\nOptional<size_t> InnerDatabase::getFilesSize()\n{\n    if (m_isInMemory) {\n        return 0;\n    }\n    auto size = FileManager::getItemsSize(getPaths());\n    if (!size.succeed()) {\n        assignWithSharedThreadedError();\n    }\n    return size;\n}\n\nbool InnerDatabase::moveFiles(const UnsafeStringView &directory)\n{\n    if (m_isInMemory) {\n        return false;\n    }\n    bool result = false;\n    close([&result, &directory, this]() {\n        std::list<StringView> paths = getPaths();\n        paths.reverse();\n        result = FileManager::moveItems(paths, directory);\n        if (!result) {\n            assignWithSharedThreadedError();\n        }\n    });\n    return result;\n}\n\nconst StringView &InnerDatabase::getPath() const\n{\n    return path;\n}\n\nstd::list<StringView> InnerDatabase::getPaths() const\n{\n    if (m_isInMemory) {\n        return { path };\n    }\n    return pathsOfDatabase(path);\n}\n\nstd::list<StringView> InnerDatabase::pathsOfDatabase(const UnsafeStringView &database)\n{\n    return {\n        StringView(database),\n        InnerHandle::walPathOfDatabase(database),\n        Repair::Factory::incrementalMaterialPathForDatabase(database),\n        Repair::Factory::firstMaterialPathForDatabase(database),\n        Repair::Factory::lastMaterialPathForDatabase(database),\n        Repair::Factory::factoryPathForDatabase(database),\n        InnerHandle::journalPathOfDatabase(database),\n        InnerHandle::shmPathOfDatabase(database),\n    };\n}\n\nvoid InnerDatabase::setInMemory()\n{\n    WCTAssert(!m_initialized);\n    m_isInMemory = true;\n}\n\n#pragma mark - Repair\n\nvoid InnerDatabase::markNeedLoadIncremetalMaterial()\n{\n    m_needLoadIncremetalMaterial = true;\n}\n\nvoid InnerDatabase::tryLoadIncremetalMaterial()\n{\n    if (!m_needLoadIncremetalMaterial) {\n        return;\n    }\n\n    const StringView &databasePath = getPath();\n    StringView materialPath\n    = Repair::Factory::incrementalMaterialPathForDatabase(databasePath);\n    auto exist = FileManager::fileExists(materialPath);\n    if (!exist.hasValue()) {\n        return;\n    }\n    if (!exist.value()) {\n        m_needLoadIncremetalMaterial = false;\n        return;\n    }\n    SharedIncrementalMaterial material = std::make_shared<Repair::IncrementalMaterial>();\n    RecyclableHandle handle = flowOut(HandleType::BackupCipher);\n    if (handle == nullptr) {\n        return;\n    }\n    WCTAssert(dynamic_cast<CipherHandle *>(handle.get()) != nullptr);\n    CipherHandle *cipherHandle = static_cast<CipherHandle *>(handle.get());\n    bool useMaterial = false;\n    if (cipherHandle->isCipherDB()) {\n        material->setCipherDelegate(cipherHandle);\n        useMaterial = material->decryptedDeserialize(materialPath, false);\n        material->setCipherDelegate(nullptr);\n    } else {\n        useMaterial = material->deserialize(materialPath);\n    }\n    if (useMaterial) {\n        if (material->pages.size() < BackupMaxAllowIncrementalPageCount) {\n            CommonCore::shared().tryRegisterIncrementalMaterial(getPath(), material);\n        } else {\n            FileManager::removeItem(materialPath);\n            Error error(Error::Code::Error, Error::Level::Warning, \"Remove large incremental material\");\n            error.infos.insert_or_assign(ErrorStringKeySource, ErrorSourceRepair);\n            error.infos.insert_or_assign(ErrorStringKeyPath, databasePath);\n            error.infos.insert_or_assign(\"PageCount\", material->pages.size());\n            Notifier::shared().notify(error);\n        }\n    } else {\n        FileManager::removeItem(materialPath);\n        Error error(Error::Code::Error, Error::Level::Warning, \"Remove unresolved incremental material\");\n        error.infos.insert_or_assign(ErrorStringKeySource, ErrorSourceRepair);\n        error.infos.insert_or_assign(ErrorStringKeyPath, databasePath);\n        Notifier::shared().notify(error);\n    }\n    m_needLoadIncremetalMaterial = false;\n}\n\nvoid InnerDatabase::filterBackup(const BackupFilter &tableShouldBeBackedup)\n{\n    LockGuard memoryGuard(m_memory);\n    m_factory.filter(tableShouldBeBackedup);\n}\n\nbool InnerDatabase::backup(bool interruptible)\n{\n    if (m_isInMemory) {\n        return false;\n    }\n    InitializedGuard initializedGuard = initialize();\n    if (!initializedGuard.valid()) {\n        return false; // mark as succeed if it's not an auto initialize action.\n    }\n\n    WCTRemedialAssert(\n    !isInTransaction(), \"Backup can't be run in transaction.\", return false;);\n\n    WCTRemedialAssert(!m_liteModeEnable, \"Backup can't run in lite mode.\", return false;);\n\n    RecyclableHandle backupHandle = flowOut(HandleType::Backup);\n    if (backupHandle == nullptr) {\n        return false;\n    }\n\n    RecyclableHandle backupCipherHandle = flowOut(HandleType::BackupCipher);\n    if (backupCipherHandle == nullptr) {\n        return false;\n    }\n    WCTAssert(backupHandle.get() != backupCipherHandle.get());\n\n    if (interruptible) {\n        backupHandle->markAsCanBeSuspended(true);\n        if (checkShouldInterruptWhenClosing(ErrorTypeBackup)) {\n            return false;\n        }\n    }\n\n    CommonCore::shared().setThreadedErrorPath(path);\n\n    Repair::FactoryBackup backup = m_factory.backup();\n    Repair::BackupHandleOperator &backupOperator\n    = backupHandle.getDecorative()->getOrCreateOperator<Repair::BackupHandleOperator>(OperatorBackup);\n    backup.setBackupSharedDelegate(&backupOperator);\n    backup.setBackupExclusiveDelegate(&backupOperator);\n    WCTAssert(dynamic_cast<CipherHandle *>(backupCipherHandle.get()) != nullptr);\n    backup.setCipherDelegate(static_cast<CipherHandle *>(backupCipherHandle.get()));\n\n    bool succeed = backup.work(getPath(), interruptible);\n    if (!succeed) {\n        if (backup.getError().level == Error::Level::Ignore) {\n            succeed = true;\n        } else {\n            setThreadedError(backup.getError());\n        }\n    }\n    CommonCore::shared().setThreadedErrorPath(\"\");\n    return succeed;\n}\n\nbool InnerDatabase::deposit()\n{\n    if (m_isInMemory) {\n        return false;\n    }\n    bool result = false;\n    close([&result, this]() {\n        InitializedGuard initializedGuard = initialize();\n        if (!initializedGuard.valid()) {\n            return;\n        }\n\n        RecyclableHandle backupHandle = flowOut(HandleType::AssembleBackup);\n        if (backupHandle == nullptr) {\n            return;\n        }\n        RecyclableHandle assemblerHandle = flowOut(HandleType::Assemble);\n        if (assemblerHandle == nullptr) {\n            return;\n        }\n        RecyclableHandle cipherHandle = flowOut(HandleType::AssembleCipher);\n        if (cipherHandle == nullptr) {\n            return;\n        }\n        WCTAssert(backupHandle.get() != assemblerHandle.get());\n        WCTAssert(backupHandle.get() != cipherHandle.get());\n        WCTAssert(assemblerHandle.get() != cipherHandle.get());\n\n        WCTAssert(!backupHandle->isOpened());\n        WCTAssert(!assemblerHandle->isOpened());\n\n        CommonCore::shared().setThreadedErrorPath(path);\n\n        Repair::FactoryRenewer renewer = m_factory.renewer();\n        Repair::BackupHandleOperator backupOperator(backupHandle.get());\n        renewer.setBackupSharedDelegate(&backupOperator);\n        renewer.setBackupExclusiveDelegate(&backupOperator);\n        AssembleHandleOperator assembleOperator(assemblerHandle.get());\n        renewer.setAssembleDelegate(&assembleOperator);\n        WCTAssert(dynamic_cast<CipherHandle *>(cipherHandle.get()) != nullptr);\n        renewer.setCipherDelegate(static_cast<CipherHandle *>(cipherHandle.get()));\n        // Prepare a new database from material at renew directory and wait for moving\n        if (!renewer.prepare()) {\n            setThreadedError(renewer.getError());\n            CommonCore::shared().setThreadedErrorPath(\"\");\n            return;\n        }\n        Repair::FactoryDepositor depositor = m_factory.depositor();\n        if (!depositor.work()) {\n            setThreadedError(depositor.getError());\n            return;\n        }\n        // If app stop here, it results that the old database is moved to deposited directory and the renewed one is not moved to the origin directory.\n        // At next time this database launchs, the retrieveRenewed method will do the remaining work. So data will never lost.\n        if (!renewer.work()) {\n            setThreadedError(renewer.getError());\n            CommonCore::shared().setThreadedErrorPath(\"\");\n        } else {\n            result = true;\n        }\n        cipherHandle->close();\n    });\n    CommonCore::shared().setThreadedErrorPath(\"\");\n    return result;\n}\n\nbool InnerDatabase::containsDeposited() const\n{\n    SharedLockGuard concurrencyGuard(m_concurrency);\n    return m_factory.containsDeposited();\n}\n\nbool InnerDatabase::removeDeposited()\n{\n    bool result = false;\n    close([&result, this]() {\n        result = m_factory.removeDeposited();\n        if (!result) {\n            assignWithSharedThreadedError();\n        }\n    });\n    return result;\n}\n\ndouble InnerDatabase::retrieve(const ProgressCallback &onProgressUpdated)\n{\n    if (m_isInMemory) {\n        return 0;\n    }\n    double result = -1;\n    close([&result, &onProgressUpdated, this]() {\n        InitializedGuard initializedGuard = initialize();\n        if (!initializedGuard.valid()) {\n            return;\n        }\n\n        RecyclableHandle backupHandle = flowOut(HandleType::AssembleBackup);\n        if (backupHandle == nullptr) {\n            return;\n        }\n        RecyclableHandle assemblerHandle = flowOut(HandleType::Assemble);\n        if (assemblerHandle == nullptr) {\n            return;\n        }\n        assemblerHandle->markAsCanBeSuspended(true);\n        RecyclableHandle cipherHandle = flowOut(HandleType::AssembleCipher);\n        if (cipherHandle == nullptr) {\n            return;\n        }\n        WCTAssert(backupHandle.get() != assemblerHandle.get());\n        WCTAssert(backupHandle.get() != cipherHandle.get());\n        WCTAssert(assemblerHandle.get() != cipherHandle.get());\n\n        WCTAssert(!backupHandle->isOpened());\n        WCTAssert(!assemblerHandle->isOpened());\n\n        CommonCore::shared().setThreadedErrorPath(path);\n\n        Repair::FactoryRetriever retriever = m_factory.retriever();\n        Repair::BackupHandleOperator backupOperator(backupHandle.get());\n        retriever.setBackupSharedDelegate(&backupOperator);\n        retriever.setBackupExclusiveDelegate(&backupOperator);\n        AssembleHandleOperator assembleOperator(assemblerHandle.get());\n        retriever.setAssembleDelegate(&assembleOperator);\n        WCTAssert(dynamic_cast<CipherHandle *>(cipherHandle.get()) != nullptr);\n        retriever.setCipherDelegate(static_cast<CipherHandle *>(cipherHandle.get()));\n        retriever.setProgressCallback(onProgressUpdated);\n        if (retriever.work()) {\n            result = retriever.getScore().value();\n        }\n        setThreadedError(retriever.getError()); // retriever may have non-critical error even if it succeeds.\n        CommonCore::shared().setThreadedErrorPath(\"\");\n        cipherHandle->close();\n    });\n    return result;\n}\n\nbool InnerDatabase::removeMaterials()\n{\n    bool result = false;\n    close([&result, this]() {\n        result = FileManager::removeItems(\n        { Repair::Factory::incrementalMaterialPathForDatabase(path),\n          Repair::Factory::firstMaterialPathForDatabase(path),\n          Repair::Factory::lastMaterialPathForDatabase(path) });\n        if (!result) {\n            assignWithSharedThreadedError();\n        }\n    });\n    return result;\n}\n\nvoid InnerDatabase::checkIntegrity(bool interruptible)\n{\n    InitializedGuard initializedGuard = initialize();\n    if (!initializedGuard.valid()) {\n        return; // mark as succeed if it's not an auto initialize action.\n    }\n    RecyclableHandle handle = flowOut(HandleType::IntegrityCheck);\n    if (handle != nullptr) {\n        IntegerityHandleOperator &integerityOperator\n        = handle.getDecorative()->getOrCreateOperator<IntegerityHandleOperator>(OperatorCheckIntegrity);\n        if (interruptible) {\n            if (checkShouldInterruptWhenClosing(ErrorTypeIntegrity)) {\n                return;\n            }\n            handle->markAsCanBeSuspended(true);\n        }\n        integerityOperator.checkIntegrity();\n    }\n}\n\n#pragma mark - Vacuum\n\nbool InnerDatabase::vacuum(const ProgressCallback &onProgressUpdated)\n{\n    if (m_isInMemory) {\n        return true;\n    }\n    bool result = false;\n    close([&result, &onProgressUpdated, this]() {\n        InitializedGuard initializedGuard = initialize();\n        if (!initializedGuard.valid()) {\n            return;\n        }\n\n        RecyclableHandle vacuumHandle = flowOut(HandleType::Vacuum);\n        if (vacuumHandle == nullptr) {\n            return;\n        }\n\n        CommonCore::shared().setThreadedErrorPath(path);\n\n        Repair::FactoryVacuum vacuummer = m_factory.vacuumer();\n        VacuumHandleOperator vacuumOperator(vacuumHandle.get());\n        vacuummer.setVacuumDelegate(&vacuumOperator);\n        vacuummer.setProgressCallback(onProgressUpdated);\n\n        if (!vacuummer.prepare()) {\n            setThreadedError(vacuummer.getError());\n            CommonCore::shared().setThreadedErrorPath(\"\");\n            return;\n        }\n\n        if (!vacuummer.work()) {\n            setThreadedError(vacuummer.getError());\n            CommonCore::shared().setThreadedErrorPath(\"\");\n            return;\n        }\n        CommonCore::shared().setThreadedErrorPath(\"\");\n        result = true;\n    });\n    return result;\n}\n\nvoid InnerDatabase::enableAutoVacuum(bool incremental)\n{\n    setConfig(AutoVacuumConfigName,\n              std::static_pointer_cast<WCDB::Config>(\n              std::make_shared<WCDB::AutoVacuumConfig>(incremental)),\n              Configs::Priority::Highest);\n}\n\nbool InnerDatabase::incrementalVacuum(int pages)\n{\n    InitializedGuard initializedGuard = initialize();\n    if (!initializedGuard.valid()) {\n        return false; // mark as succeed if it's not an auto initialize action.\n    }\n    RecyclableHandle handle = flowOut(HandleType::AutoVacuum);\n    if (!handle->prepare(StatementPragma().pragma(Pragma::incrementalVacuum()).with(pages))) {\n        return false;\n    }\n    bool succeed = false;\n    do {\n        succeed = handle->step();\n    } while (succeed && !handle->done());\n    handle->finalize();\n    return succeed;\n}\n\n#pragma mark - Migration\nOptional<bool> InnerDatabase::stepMigration(bool interruptible)\n{\n    InitializedGuard initializedGuard = initialize();\n    if (!initializedGuard.valid()) {\n        return NullOpt;\n    }\n    WCTRemedialAssert(\n    !isInTransaction(), \"Migrating can't be run in transaction.\", return NullOpt;);\n    WCTRemedialAssert(\n    m_migration.shouldMigrate(), \"It's not configured for migration.\", return NullOpt;);\n    Optional<bool> done;\n    RecyclableHandle handle = flowOut(HandleType::Migrate);\n    if (handle != nullptr) {\n        MigrateHandleOperator &migrateOperator\n        = handle.getDecorative()->getOrCreateOperator<MigrateHandleOperator>(OperatorMigrate);\n        if (interruptible) {\n            if (checkShouldInterruptWhenClosing(ErrorTypeMigrate)) {\n                return false;\n            }\n            handle->markAsCanBeSuspended(true);\n        }\n        handle->markErrorAsIgnorable(Error::Code::Busy);\n\n        done = m_migration.step(migrateOperator);\n        if (!done.succeed() && handle->getError().isIgnorable()) {\n            done = false;\n        }\n    }\n    return done;\n}\n\nvoid InnerDatabase::didMigrate(const MigrationBaseInfo *info)\n{\n    MigratedCallback callback = nullptr;\n    {\n        SharedLockGuard lockGuard(m_memory);\n        callback = m_migratedCallback;\n    }\n    if (callback != nullptr) {\n        callback(this, info);\n    }\n}\n\nvoid InnerDatabase::setNotificationWhenMigrated(const MigratedCallback &callback)\n{\n    LockGuard lockGuard(m_memory);\n    m_migratedCallback = callback;\n}\n\nvoid InnerDatabase::addMigration(const UnsafeStringView &sourcePath,\n                                 const UnsafeData &sourceCipher,\n                                 const MigrationTableFilter &filter)\n{\n    StringView sourceDatabase = Path::normalize(sourcePath);\n    if (sourceDatabase.compare(getPath()) != 0) {\n        close([=]() {\n            m_migration.addMigration(sourceDatabase, sourceCipher, filter);\n        });\n    } else {\n        close([=]() {\n            m_migration.addMigration(UnsafeStringView(), sourceCipher, filter);\n        });\n    }\n}\n\nbool InnerDatabase::isMigrated() const\n{\n    return m_migration.isMigrated();\n}\n\nStringViewSet InnerDatabase::getPathsOfSourceDatabases() const\n{\n    return m_migration.getPathsOfSourceDatabases();\n}\n\n#pragma mark - Compression\nOptional<bool> InnerDatabase::stepCompression(bool interruptible)\n{\n    InitializedGuard initializedGuard = initialize();\n    if (!initializedGuard.valid()) {\n        return NullOpt;\n    }\n    WCTRemedialAssert(\n    !isInTransaction(), \"Compressing can't be run in transaction.\", return NullOpt;);\n    WCTRemedialAssert(m_compression.shouldCompress(),\n                      \"It's not configured for compression.\",\n                      return NullOpt;);\n    Optional<bool> done;\n    RecyclableHandle handle = flowOut(HandleType::Compress);\n    if (handle != nullptr) {\n        CompressHandleOperator &compressOperator\n        = handle.getDecorative()->getOrCreateOperator<CompressHandleOperator>(OperatorCompress);\n        if (interruptible) {\n            if (checkShouldInterruptWhenClosing(ErrorTypeCompress)) {\n                return false;\n            }\n            handle->markAsCanBeSuspended(true);\n        }\n        handle->markErrorAsIgnorable(Error::Code::Busy);\n\n        done = m_compression.step(compressOperator);\n        if (!done.succeed() && handle->getError().isIgnorable()) {\n            done = false;\n        }\n    }\n    return done;\n}\n\nvoid InnerDatabase::didCompress(const CompressionTableBaseInfo *info)\n{\n    CompressedCallback callback = nullptr;\n    {\n        SharedLockGuard lockGuard(m_memory);\n        callback = m_compressedCallback;\n    }\n    if (callback != nullptr) {\n        callback(this, info);\n    }\n}\n\nvoid InnerDatabase::setNotificationWhenCompressed(const CompressedCallback &callback)\n{\n    LockGuard lockGuard(m_memory);\n    m_compressedCallback = callback;\n}\n\nvoid InnerDatabase::addCompression(const CompressionTableFilter &filter)\n{\n    close([=]() { m_compression.setTableFilter(filter); });\n}\n\nvoid InnerDatabase::setCanCompressNewData(bool canCompress)\n{\n    m_compression.setCanCompressNewData(canCompress);\n}\n\nbool InnerDatabase::isCompressed() const\n{\n    return m_compression.isCompressed();\n}\n\nbool InnerDatabase::rollbackCompression(const ProgressCallback &callback)\n{\n    WCTRemedialAssert(\n    !isInTransaction(), \"Can't revert compression in transaction.\", return false;);\n\n    bool ret = false;\n    close([&]() {\n        InitializedGuard initializedGuard = initialize();\n        if (!initializedGuard.valid()) {\n            return; // mark as succeed if it's not an auto initialize action.\n        }\n\n        m_compression.setProgressCallback(callback);\n\n        RecyclableHandle handle = flowOut(HandleType::Compress);\n        if (handle != nullptr) {\n            CompressHandleOperator &compressOperator\n            = handle.getDecorative()->getOrCreateOperator<CompressHandleOperator>(OperatorCompress);\n\n            ret = m_compression.rollbackCompression(compressOperator);\n            if (ret) {\n                CommonCore::shared().enableAutoCompress(this, false);\n            }\n        }\n    });\n    return ret;\n}\n\n#pragma mark - Checkpoint\nbool InnerDatabase::checkpoint(bool interruptible, CheckPointMode mode)\n{\n    InitializedGuard initializedGuard = initialize();\n    if (!initializedGuard.valid()) {\n        return false; // mark as succeed if it's not an auto initialize action.\n    }\n    bool succeed = false;\n    RecyclableHandle handle = flowOut(HandleType::Checkpoint);\n    if (handle != nullptr) {\n        if (interruptible) {\n            if (checkShouldInterruptWhenClosing(ErrorTypeCheckpoint)) {\n                return false;\n            }\n            handle->markAsCanBeSuspended(true);\n        }\n        tryLoadIncremetalMaterial();\n        handle->markErrorAsIgnorable(Error::Code::Busy);\n        succeed = handle->checkpoint(mode);\n        if (!succeed && handle->getError().isIgnorable()) {\n            succeed = true;\n        }\n    }\n    return succeed;\n}\n\n#pragma mark - AutoMergeFTSIndex\n\nOptional<bool> InnerDatabase::mergeFTSIndex(TableArray newTables, TableArray modifiedTables)\n{\n    InitializedGuard initializedGuard = initialize();\n    if (!initializedGuard.valid()) {\n        return false; // mark as succeed if it's not an auto initialize action.\n    }\n    if (checkShouldInterruptWhenClosing(ErrorTypeMergeIndex)) {\n        return false;\n    }\n    return m_mergeLogic.triggerMerge(newTables, modifiedTables);\n}\n\nvoid InnerDatabase::proccessMerge()\n{\n    InitializedGuard initializedGuard = initialize();\n    if (!initializedGuard.valid()) {\n        return; // mark as succeed if it's not an auto initialize action.\n    }\n    if (checkShouldInterruptWhenClosing(ErrorTypeMergeIndex)) {\n        return;\n    }\n    return m_mergeLogic.proccessMerge();\n}\n\nRecyclableHandle InnerDatabase::getMergeIndexHandle()\n{\n    return flowOut(HandleType::MergeIndex);\n}\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/common/core/InnerDatabase.hpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"Compression.hpp\"\n#include \"Configs.hpp\"\n#include \"Factory.hpp\"\n#include \"HandlePool.hpp\"\n#include \"MergeFTSIndexLogic.hpp\"\n#include \"Migration.hpp\"\n#include \"Tag.hpp\"\n#include \"ThreadLocal.hpp\"\n#include \"WINQ.h\"\n\nnamespace WCDB {\n\nclass BaseOperation;\n\n// TODO: readonly manually - by removing basic config and adding query_only config?\n// TODO: support authorize\nclass InnerDatabase final : private HandlePool,\n                            public MigrationEvent,\n                            public CompressionEvent,\n                            public MergeFTSIndexHandleProvider {\n    friend BaseOperation;\n#pragma mark - Initializer\npublic:\n    InnerDatabase(const UnsafeStringView &path);\n    InnerDatabase() = delete;\n    InnerDatabase(const InnerDatabase &) = delete;\n    InnerDatabase &operator=(const InnerDatabase &) = delete;\n    ~InnerDatabase() override;\n\nprotected:\n    // All public interfaces that are related with concurrency should make sure the initialization.\n    typedef SharedLockGuard InitializedGuard;\n    InitializedGuard initialize();\n    bool m_initialized;\n    std::atomic<int> m_closing;\n\n#pragma mark - Basic\npublic:\n    void setTag(const Tag &tag);\n    Tag getTag() const;\n\n    bool canOpen();\n    bool isOpened() const;\n    using HandlePool::blockade;\n    using ClosedCallback = HandlePool::DrainedCallback;\n    void close(const ClosedCallback &onClosed);\n    using HandlePool::unblockade;\n    using HandlePool::isBlockaded;\n    using HandlePool::numberOfAliveHandles;\n    void setReadOnly();\n\nprotected:\n    Tag m_tag;\n    bool m_isReadOnly = false;\n\n    void didDrain() override final;\n    bool checkShouldInterruptWhenClosing(const UnsafeStringView &sourceType);\n\n#pragma mark - Handle\npublic:\n    RecyclableHandle getHandle(bool writeHint = false, bool threaded = false);\n    bool execute(const Statement &statement);\n    bool execute(const UnsafeStringView &sql);\n    Optional<bool> tableExists(const UnsafeStringView &table);\n    StringView getRunningSQLInThread(uint64_t tid) const;\n\nprotected:\n    std::shared_ptr<InnerHandle> generateSlotedHandle(HandleType type) override final;\n    bool willReuseSlotedHandle(HandleType type, InnerHandle *handle) override final;\n\nprivate:\n    bool setupHandle(HandleType type, InnerHandle *handle);\n\n#pragma mark - Config\npublic:\n    void setConfigs(const Configs &configs);\n    void setConfig(const UnsafeStringView &name,\n                   const std::shared_ptr<Config> &config,\n                   int priority = Configs::Priority::Default);\n    void removeConfig(const UnsafeStringView &name);\n    void setFullSQLTraceEnable(bool enable);\n    void setLiteModeEnable(bool enable);\n    bool liteModeEnable();\n\nprivate:\n    Configs m_configs;\n    bool m_fullSQLTrace = false;\n    bool m_liteModeEnable = false;\n\n#pragma mark - Transaction\npublic:\n    using TransactionCallback = InnerHandle::TransactionCallback;\n    using TransactionCallbackForOneLoop = InnerHandle::TransactionCallbackForOneLoop;\n\n    bool isInTransaction();\n\n    bool beginTransaction();\n    bool commitOrRollbackTransaction();\n    void rollbackTransaction();\n    bool runTransaction(const TransactionCallback &transaction);\n    bool runPausableTransactionWithOneLoop(const TransactionCallbackForOneLoop &transaction);\n\n#pragma mark - File\npublic:\n    const StringView &getPath() const override;\n    std::list<StringView> getPaths() const;\n    static std::list<StringView> pathsOfDatabase(const UnsafeStringView &database);\n\n    bool moveFiles(const UnsafeStringView &directory);\n    bool removeFiles();\n    Optional<size_t> getFilesSize();\n\n#pragma mark - Repair\npublic:\n    void markNeedLoadIncremetalMaterial();\n    void tryLoadIncremetalMaterial();\n    typedef Repair::Factory::Filter BackupFilter;\n    void filterBackup(const BackupFilter &tableShouldBeBackedup);\n    bool backup(bool interruptible);\n    bool removeMaterials();\n\n    bool deposit();\n    bool removeDeposited();\n    bool containsDeposited() const;\n\n    typedef Progress::ProgressUpdateCallback ProgressCallback;\n    double retrieve(const ProgressCallback &onProgressUpdated);\n\n    void checkIntegrity(bool interruptible);\n\nprivate:\n    Repair::Factory m_factory;\n    bool m_needLoadIncremetalMaterial;\n\n#pragma mark - Vacuum\npublic:\n    bool vacuum(const ProgressCallback &onProgressUpdated);\n    void enableAutoVacuum(bool incremental);\n    bool incrementalVacuum(int pages);\n\n#pragma mark - Migration\npublic:\n    typedef Migration::TableFilter MigrationTableFilter;\n    void addMigration(const UnsafeStringView &sourcePath,\n                      const UnsafeData &sourceCipher,\n                      const MigrationTableFilter &filter);\n\n    typedef std::function<void(InnerDatabase *, const MigrationBaseInfo *)> MigratedCallback;\n    void setNotificationWhenMigrated(const MigratedCallback &callback);\n\n    Optional<bool> stepMigration(bool interruptible);\n\n    bool isMigrated() const;\n\n    StringViewSet getPathsOfSourceDatabases() const;\n\nprotected:\n    void didMigrate(const MigrationBaseInfo *info) override final;\n    Migration m_migration; // thread-safe\n    MigratedCallback m_migratedCallback;\n\n#pragma mark - Compression\npublic:\n    typedef Compression::TableFilter CompressionTableFilter;\n    void addCompression(const CompressionTableFilter &filter);\n\n    void setCanCompressNewData(bool canCompress);\n\n    typedef std::function<void(InnerDatabase *, const CompressionTableBaseInfo *)> CompressedCallback;\n    void setNotificationWhenCompressed(const CompressedCallback &callback);\n\n    Optional<bool> stepCompression(bool interruptible);\n\n    bool isCompressed() const;\n\n    bool rollbackCompression(const ProgressCallback &callback);\n\nprotected:\n    void didCompress(const CompressionTableBaseInfo *info) override final;\n    Compression m_compression; // thread-safe\n    CompressedCallback m_compressedCallback;\n\n#pragma mark - Checkpoint\npublic:\n    using CheckPointMode = AbstractHandle::CheckpointMode;\n    bool checkpoint(bool interruptible = true, CheckPointMode mode = CheckPointMode::Passive);\n\n#pragma mark - Memory\npublic:\n    using HandlePool::purge;\n    void setInMemory();\n\nprivate:\n    bool m_isInMemory;\n    std::shared_ptr<InnerHandle> m_sharedInMemoryHandle;\n\n#pragma mark - Error\npublic:\n    using HandlePool::getThreadedError;\n\n#pragma mark - Merge FTS Index\npublic:\n    using TableArray = std::shared_ptr<std::vector<StringView>>;\n    Optional<bool> mergeFTSIndex(TableArray newTables, TableArray modifiedTables);\n    void proccessMerge();\n    RecyclableHandle getMergeIndexHandle() override final;\n\nprivate:\n    MergeFTSIndexLogic m_mergeLogic;\n};\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/common/core/InnerHandle.cpp",
    "content": "//\n// Created by sanhuazhang on 2019/08/15\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"InnerHandle.hpp\"\n#include \"Assertion.hpp\"\n#include \"BusyRetryConfig.hpp\"\n#include \"CipherConfig.hpp\"\n#include \"CoreConst.h\"\n\nnamespace WCDB {\n\nInnerHandle::InnerHandle()\n: m_type(HandleType::Normal)\n, m_writeHint(false)\n, m_mainStatement(nullptr)\n{\n    m_mainStatement = getStatement();\n}\n\nInnerHandle::~InnerHandle()\n{\n    returnStatement(m_mainStatement);\n}\n\nvoid InnerHandle::setType(HandleType type)\n{\n    switch (type) {\n    case HandleType::Migrate:\n        m_error.infos.insert_or_assign(ErrorStringKeyType, ErrorTypeMigrate);\n        break;\n    case HandleType::Compress:\n        m_error.infos.insert_or_assign(ErrorStringKeyType, ErrorTypeCompress);\n        break;\n    case HandleType::Backup:\n    case HandleType::BackupCipher:\n        m_error.infos.insert_or_assign(ErrorStringKeyType, ErrorTypeBackup);\n        break;\n    case HandleType::Checkpoint:\n        m_error.infos.insert_or_assign(ErrorStringKeyType, ErrorTypeCheckpoint);\n        break;\n    case HandleType::IntegrityCheck:\n        m_error.infos.insert_or_assign(ErrorStringKeyType, ErrorTypeIntegrity);\n        break;\n    case HandleType::MergeIndex:\n        m_error.infos.insert_or_assign(ErrorStringKeyType, ErrorTypeMergeIndex);\n        break;\n    default:\n        m_error.infos.erase(ErrorStringKeyType);\n        break;\n    }\n    m_type = type;\n}\n\nHandleType InnerHandle::getType() const\n{\n    return m_type;\n}\n\nbool InnerHandle::getWriteHint()\n{\n    return m_writeHint;\n}\n\nvoid InnerHandle::setWriteHint(bool hint)\n{\n    m_writeHint = hint;\n}\n\n#pragma mark - Config\nbool InnerHandle::open()\n{\n    bool succeed = false;\n    if (AbstractHandle::open()) {\n        if (configure()) {\n            succeed = true;\n        } else {\n            close();\n        }\n    }\n    return succeed;\n}\n\nvoid InnerHandle::close()\n{\n    if (isOpened()) {\n        while (!m_invokeds.empty()) {\n            const auto last = m_invokeds.back();\n            last.value()->uninvoke(this); // ignore errors\n            m_invokeds.pop_back();\n        }\n    }\n    AbstractHandle::close();\n}\n\nbool InnerHandle::reconfigure(const Configs &newConfigs)\n{\n    if (newConfigs != m_pendings) {\n        m_pendings = newConfigs;\n        if (isOpened()) {\n            return configure();\n        }\n    }\n    return true;\n}\n\nbool InnerHandle::configure()\n{\n    if (m_pendings != m_invokeds) {\n        while (!m_invokeds.empty()) {\n            auto last = m_invokeds.back();\n            if (!last.value()->uninvoke(this)) {\n                return false;\n            }\n            m_invokeds.pop_back();\n        }\n        WCTAssert(m_invokeds.empty());\n        std::shared_ptr<Config> cipherConfig = nullptr;\n        for (const auto &element : m_pendings) {\n            if (!element.value()->invoke(this)) {\n                if (element.key().caseInsensitiveEqual(BasicConfigName)\n                    && !canWriteMainDB()) {\n                    //Setting the WAL journal mode requires writing the main DB.\n                    enableWriteMainDB(true);\n                    close();\n                    bool success = open();\n                    enableWriteMainDB(false);\n                    return success;\n                }\n                return false;\n            }\n            m_invokeds.insert(element.key(), element.value(), element.order());\n            if (element.key().compare(CipherConfigName) == 0) {\n                cipherConfig = element.value();\n            }\n        }\n        m_pendings = m_invokeds;\n        if (cipherConfig != nullptr) {\n            WCTAssert(dynamic_cast<CipherConfig *>(cipherConfig.get()) != nullptr);\n            CipherConfig *convertedConfig\n            = static_cast<CipherConfig *>(cipherConfig.get());\n            if (convertedConfig != nullptr) {\n                convertedConfig->trySaveRawKey(this);\n            }\n        }\n    }\n    return true;\n}\n\n#pragma mark - Statement\nbool InnerHandle::execute(const Statement &statement)\n{\n    bool succeed = false;\n    if (prepare(statement)) {\n        succeed = step();\n        finalize();\n    }\n    return succeed;\n}\n\nbool InnerHandle::execute(const UnsafeStringView &sql)\n{\n    bool succeed = false;\n    if (prepare(sql)) {\n        succeed = step();\n        finalize();\n    }\n    return succeed;\n}\n\nbool InnerHandle::prepare(const Statement &statement)\n{\n    return m_mainStatement->prepare(statement);\n}\n\nbool InnerHandle::prepare(const UnsafeStringView &sql)\n{\n    return m_mainStatement->prepareSQL(sql);\n}\n\nbool InnerHandle::isPrepared()\n{\n    return m_mainStatement->isPrepared();\n}\n\nvoid InnerHandle::reset()\n{\n    m_mainStatement->reset();\n}\n\nvoid InnerHandle::clearBindings()\n{\n    m_mainStatement->clearBindings();\n}\n\nbool InnerHandle::done()\n{\n    return m_mainStatement->done();\n}\n\nbool InnerHandle::step()\n{\n    return m_mainStatement->step();\n}\n\nint InnerHandle::getNumberOfColumns()\n{\n    return m_mainStatement->getNumberOfColumns();\n}\n\nconst UnsafeStringView InnerHandle::getOriginColumnName(int index)\n{\n    return m_mainStatement->getOriginColumnName(index);\n}\n\nconst UnsafeStringView InnerHandle::getColumnName(int index)\n{\n    return m_mainStatement->getColumnName(index);\n}\n\nconst UnsafeStringView InnerHandle::getColumnTableName(int index)\n{\n    return m_mainStatement->getColumnTableName(index);\n}\n\nColumnType InnerHandle::getColumnType(int index)\n{\n    return m_mainStatement->getType(index);\n}\n\nvoid InnerHandle::bindInteger(const Integer &value, int index)\n{\n    m_mainStatement->bindInteger(value, index);\n}\n\nvoid InnerHandle::bindDouble(const Float &value, int index)\n{\n    m_mainStatement->bindDouble(value, index);\n}\n\nvoid InnerHandle::bindText(const Text &value, int index)\n{\n    m_mainStatement->bindText(value, index);\n}\n\nvoid InnerHandle::bindBLOB(const BLOB &value, int index)\n{\n    m_mainStatement->bindBLOB(value, index);\n}\n\nvoid InnerHandle::bindNull(int index)\n{\n    m_mainStatement->bindNull(index);\n}\n\nvoid InnerHandle::bindPointer(void *ptr, int index, const Text &type, void (*destructor)(void *))\n{\n    m_mainStatement->bindPointer(ptr, index, type, destructor);\n}\n\nvoid InnerHandle::bindValue(const Value &value, int index)\n{\n    m_mainStatement->bindValue(value, index);\n}\n\nvoid InnerHandle::bindRow(const OneRowValue &row)\n{\n    m_mainStatement->bindRow(row);\n}\n\nint InnerHandle::bindParameterIndex(const Text &parameterName)\n{\n    return m_mainStatement->bindParameterIndex(parameterName);\n}\n\nInnerHandle::Integer InnerHandle::getInteger(int index)\n{\n    return m_mainStatement->getInteger(index);\n}\n\nInnerHandle::Float InnerHandle::getDouble(int index)\n{\n    return m_mainStatement->getDouble(index);\n}\n\nInnerHandle::Text InnerHandle::getText(int index)\n{\n    return m_mainStatement->getText(index);\n}\n\nInnerHandle::BLOB InnerHandle::getBLOB(int index)\n{\n    return m_mainStatement->getBLOB(index);\n}\n\nValue InnerHandle::getValue(int index)\n{\n    return m_mainStatement->getValue(index);\n}\n\nOptionalOneColumn InnerHandle::getOneColumn(int index)\n{\n    return m_mainStatement->getOneColumn(index);\n}\n\nOneRowValue InnerHandle::getOneRow()\n{\n    return m_mainStatement->getOneRow();\n}\n\nOptionalMultiRows InnerHandle::getAllRows()\n{\n    return m_mainStatement->getAllRows();\n}\n\nvoid InnerHandle::finalize()\n{\n    m_mainStatement->finalize();\n}\n\nbool InnerHandle::isStatementReadonly()\n{\n    return m_mainStatement->isReadOnly();\n}\n\n#pragma mark - Transaction\nbool InnerHandle::checkMainThreadBusyRetry()\n{\n    const auto &element = m_pendings.find(StringView(BusyRetryConfigName));\n    if (element == m_pendings.end()) {\n        return false;\n    }\n    std::shared_ptr<BusyRetryConfig> config\n    = std::dynamic_pointer_cast<BusyRetryConfig>(element->value());\n    if (config == nullptr) {\n        return false;\n    }\n    return config->checkMainThreadBusyRetry(getPath());\n}\n\nbool InnerHandle::checkHasBusyRetry()\n{\n    const auto &element = m_pendings.find(StringView(BusyRetryConfigName));\n    if (element == m_pendings.end()) {\n        return false;\n    }\n    std::shared_ptr<BusyRetryConfig> config\n    = std::dynamic_pointer_cast<BusyRetryConfig>(element->value());\n    if (config == nullptr) {\n        return false;\n    }\n    return config->checkHasBusyRetry(getPath());\n}\n\nbool InnerHandle::runTransactionIfNotInTransaction(const TransactionCallback &transaction)\n{\n    if (isInTransaction()) {\n        return transaction(this);\n    } else {\n        return runTransaction(transaction);\n    }\n}\n\nbool InnerHandle::runTransaction(const TransactionCallback &transaction)\n{\n    if (beginTransaction()) {\n        if (transaction(this)) {\n            return commitOrRollbackTransaction();\n        } else {\n            rollbackTransaction();\n        }\n    }\n    return false;\n}\n\nbool InnerHandle::runPausableTransactionWithOneLoop(const TransactionCallbackForOneLoop &transaction)\n{\n    bool stop = false;\n    bool needBegin = true;\n    bool isNewTransaction;\n    do {\n        isNewTransaction = needBegin;\n        if (needBegin && !beginTransaction()) {\n            return false;\n        }\n        needBegin = false;\n        if (!transaction(this, stop, isNewTransaction)) {\n            rollbackTransaction();\n            return false;\n        }\n        if (checkMainThreadBusyRetry() || stop) {\n            if (!commitOrRollbackTransaction()) {\n                return false;\n            }\n            if (!stop) {\n                needBegin = true;\n                std::this_thread::sleep_for(std::chrono::microseconds(100));\n            }\n        }\n    } while (!stop);\n    return true;\n}\n\nConfiguredHandle::~ConfiguredHandle() = default;\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/common/core/InnerHandle.hpp",
    "content": "//\n// Created by sanhuazhang on 2019/08/15\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"AbstractHandle.hpp\"\n#include \"Configs.hpp\"\n#include \"CoreConst.h\"\n\nnamespace WCDB {\n\nclass Handle;\nclass HandleDecorator;\n\nHandleStatement *GetMainHandleStatement(InnerHandle *handle);\n\nclass InnerHandle : public AbstractHandle {\n    friend Handle;\n    friend HandleStatement *GetMainHandleStatement(InnerHandle *handle);\n    friend HandleDecorator;\n#pragma mark - Initialize\npublic:\n    InnerHandle();\n    virtual ~InnerHandle() override = 0;\n\n    void setType(HandleType type);\n    HandleType getType() const;\n    bool getWriteHint();\n    void setWriteHint(bool hint);\n\nprivate:\n    HandleType m_type;\n    bool m_writeHint;\n\n#pragma mark - Config\npublic:\n    bool open() override final;\n    void close() override final;\n    bool reconfigure(const Configs &newConfigs);\n\nprotected:\n    bool configure();\n\nprivate:\n    Configs m_invokeds;\n    Configs m_pendings;\n\n#pragma mark - Statement\npublic:\n    virtual bool execute(const Statement &statement);\n    bool execute(const UnsafeStringView &sql);\n\n    bool prepare(const Statement &statement);\n    bool prepare(const UnsafeStringView &sql);\n    bool isPrepared();\n    virtual void finalize();\n\n    bool step();\n    bool done();\n    void reset();\n    void clearBindings();\n\n    using Integer = HandleStatement::Integer;\n    using Text = HandleStatement::Text;\n    using Float = HandleStatement::Float;\n    using BLOB = HandleStatement::BLOB;\n\n    void bindInteger(const Integer &value, int index = 1);\n    void bindDouble(const Float &value, int index = 1);\n    void bindText(const Text &value, int index = 1);\n    void bindBLOB(const BLOB &value, int index = 1);\n    void bindNull(int index);\n    void bindPointer(void *ptr, int index, const Text &type, void (*destructor)(void *));\n    virtual int bindParameterIndex(const Text &parameterName);\n\n    void bindValue(const Value &value, int index = 1);\n    void bindRow(const OneRowValue &row);\n\n    Integer getInteger(int index = 0);\n    Float getDouble(int index = 0);\n    Text getText(int index = 0);\n    BLOB getBLOB(int index = 0);\n\n    Value getValue(int index = 0);\n    OptionalOneColumn getOneColumn(int index = 0);\n    OneRowValue getOneRow();\n    OptionalMultiRows getAllRows();\n\n    const UnsafeStringView getOriginColumnName(int index);\n    const UnsafeStringView getColumnName(int index);\n    const UnsafeStringView getColumnTableName(int index);\n\n    ColumnType getColumnType(int index);\n    bool isStatementReadonly();\n    int getNumberOfColumns();\n\nprotected:\n    DecorativeHandleStatement *m_mainStatement;\n\n#pragma mark - Transaction\npublic:\n    typedef std::function<bool(InnerHandle *)> TransactionCallback;\n    typedef std::function<bool(InnerHandle *, bool &, bool)> TransactionCallbackForOneLoop;\n\n    bool checkMainThreadBusyRetry();\n    bool checkHasBusyRetry();\n    bool runTransaction(const TransactionCallback &transaction);\n    bool runTransactionIfNotInTransaction(const TransactionCallback &transaction);\n    bool runPausableTransactionWithOneLoop(const TransactionCallbackForOneLoop &transaction);\n};\n\nclass ConfiguredHandle final : public InnerHandle {\npublic:\n    ~ConfiguredHandle() override;\n};\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/common/core/RecyclableHandle.cpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"RecyclableHandle.hpp\"\n#include \"Assertion.hpp\"\n#include \"DecorativeHandle.hpp\"\n\nnamespace WCDB {\n\nRecyclableHandle::RecyclableHandle() : Super(), m_handle(nullptr)\n{\n}\n\nRecyclableHandle::RecyclableHandle(const std::nullptr_t &)\n: Super(nullptr), m_handle(nullptr)\n{\n}\n\nRecyclableHandle::RecyclableHandle(const std::shared_ptr<InnerHandle> &value,\n                                   const Super::OnRecycled &onRecycled)\n: Super(value, onRecycled), m_handle(value.get())\n{\n}\n\nRecyclableHandle::~RecyclableHandle() = default;\n\nRecyclableHandle &RecyclableHandle::operator=(const std::nullptr_t &)\n{\n    Super::operator=(nullptr);\n    m_handle = nullptr;\n    return *this;\n}\n\nInnerHandle *RecyclableHandle::operator->() const\n{\n    return m_handle;\n}\n\nRecyclableHandle &RecyclableHandle::operator=(const RecyclableHandle &other)\n{\n    Super::operator=(other);\n    m_handle = other.m_handle;\n    return *this;\n}\n\nInnerHandle *RecyclableHandle::get() const\n{\n    return m_handle;\n}\n\nDecorativeHandle *RecyclableHandle::getDecorative() const\n{\n    WCTAssert(dynamic_cast<DecorativeHandle *>(m_handle) != nullptr);\n    return static_cast<DecorativeHandle *>(m_handle);\n}\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/common/core/RecyclableHandle.hpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"Recyclable.hpp\"\n\nnamespace WCDB {\n\nclass InnerHandle;\nclass DecorativeHandle;\n\nclass WCDB_API RecyclableHandle final : public Recyclable<std::shared_ptr<InnerHandle>> {\npublic:\n    using Super = Recyclable<std::shared_ptr<InnerHandle>>;\n\n    RecyclableHandle();\n    RecyclableHandle(const std::nullptr_t &);\n    RecyclableHandle(const std::shared_ptr<InnerHandle> &value,\n                     const Super::OnRecycled &onRecycled);\n    ~RecyclableHandle() override;\n\n    RecyclableHandle &operator=(const std::nullptr_t &);\n    RecyclableHandle &operator=(const RecyclableHandle &other);\n\n    InnerHandle *operator->() const;\n    InnerHandle *get() const;\n    DecorativeHandle *getDecorative() const;\n\nprotected:\n    InnerHandle *m_handle;\n};\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/common/core/Tag.cpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"Tag.hpp\"\n#include \"Assertion.hpp\"\n#include \"CoreConst.h\"\n\nnamespace WCDB {\n\nconst Tag& Tag::invalid()\n{\n    static const Tag* s_invalid = new Tag(nullptr);\n    return *s_invalid;\n}\n\nTag::Tag(long tag) : m_value(tag)\n{\n    WCTRemedialAssert(m_value != TagInvalidValue, \"Tag can't be 0.\", return;);\n}\n\nTag::Tag(const std::nullptr_t&) : m_value(TagInvalidValue)\n{\n}\n\nbool Tag::operator==(const Tag& other) const\n{\n    return m_value == other.m_value;\n}\n\nbool Tag::operator!=(const Tag& other) const\n{\n    return m_value != other.m_value;\n}\n\nTag::operator long() const\n{\n    return value();\n}\n\nlong Tag::value() const\n{\n    return m_value;\n}\n\nbool Tag::isValid() const\n{\n    return m_value != TagInvalidValue;\n}\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/core/Tag.hpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"Macro.h\"\n#include <cstdint>\n#include <type_traits>\n\nnamespace WCDB {\n\nclass WCDB_API Tag final {\npublic:\n    static const Tag& invalid();\n\n    Tag(long tag);\n\n    bool operator==(const Tag& other) const;\n    bool operator!=(const Tag& other) const;\n    operator long() const;\n    long value() const;\n\n    bool isValid() const;\n\nprivate:\n    Tag(const std::nullptr_t&);\n    long m_value;\n};\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/core/assemble/AssembleHandleOperator.cpp",
    "content": "//\n// Created by qiuwenchen on 2023/11/17.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"AssembleHandleOperator.hpp\"\n\nnamespace WCDB {\n\nAssembleHandleOperator::AssembleHandleOperator(InnerHandle *handle)\n: HandleOperator(handle)\n, Repair::AssembleDelegate()\n, m_statementForDisableJounral(StatementPragma().pragma(Pragma::journalMode()).to(\"OFF\"))\n, m_statementForEnableMMap(StatementPragma().pragma(Pragma::mmapSize()).to(2147418112))\n, m_integerPrimary(-1)\n, m_withoutRowid(false)\n, m_cellStatement(handle->getStatement(DecoratorAllType))\n, m_statementForUpdateSequence(StatementUpdate()\n                               .update(\"sqlite_sequence\")\n                               .set(Column(\"seq\"))\n                               .to(BindParameter(1))\n                               .where(Column(\"name\") == BindParameter(2)))\n, m_statementForInsertSequence(StatementInsert()\n                               .insertIntoTable(\"sqlite_sequence\")\n                               .columns({ Column(\"name\"), Column(\"seq\") })\n                               .values(BindParameter::bindParameters(2)))\n{\n}\n\nAssembleHandleOperator::~AssembleHandleOperator()\n{\n    getHandle()->returnStatement(m_cellStatement);\n}\n\n#pragma mark - Assemble\nvoid AssembleHandleOperator::setAssemblePath(const UnsafeStringView &path)\n{\n    getHandle()->setPath(path);\n}\n\nconst StringView &AssembleHandleOperator::getAssemblePath() const\n{\n    return getHandle()->getPath();\n}\n\nconst Error &AssembleHandleOperator::getAssembleError() const\n{\n    return getHandle()->getError();\n}\n\nvoid AssembleHandleOperator::suspendAssemble()\n{\n    return getHandle()->suspend(true);\n}\n\nvoid AssembleHandleOperator::finishAssemble()\n{\n    getHandle()->close();\n}\n\nbool AssembleHandleOperator::markAsAssembling()\n{\n    InnerHandle *handle = getHandle();\n    bool succeed = handle->open();\n    if (succeed) {\n        if (!handle->execute(m_statementForDisableJounral)\n            || !handle->execute(m_statementForEnableMMap) || !markSequenceAsAssembling()) {\n            handle->close();\n            succeed = false;\n        }\n    }\n    return succeed;\n}\n\nbool AssembleHandleOperator::markAsAssembled()\n{\n    m_table.clear();\n    m_cellStatement->finalize();\n    InnerHandle *handle = getHandle();\n    bool succeed = markSequenceAsAssembled();\n    if (handle->isInTransaction()) {\n        succeed = handle->commitOrRollbackTransaction() && succeed;\n    }\n    // TODO: check integrity after assembled?\n    handle->close();\n    return succeed;\n}\n\nbool AssembleHandleOperator::markAsMilestone()\n{\n    InnerHandle *handle = getHandle();\n    if (handle->isInTransaction()) {\n        if (!handle->commitOrRollbackTransaction()) {\n            return false;\n        }\n    }\n    return handle->beginTransaction();\n}\n\nbool AssembleHandleOperator::assembleSQL(const UnsafeStringView &sql)\n{\n    InnerHandle *handle = getHandle();\n    bool succeed = false;\n    handle->markErrorAsIgnorable(Error::Code::Error);\n    succeed = handle->executeSQL(sql);\n    if (!succeed && handle->getError().code() == Error::Code::Error) {\n        succeed = true;\n    }\n    handle->markErrorAsUnignorable();\n    return succeed;\n}\n\n#pragma mark - Assemble - Table\nbool AssembleHandleOperator::assembleTable(const UnsafeStringView &tableName,\n                                           const UnsafeStringView &sql)\n{\n    m_cellStatement->finalize();\n    m_table.clear();\n    InnerHandle *handle = getHandle();\n    bool succeed = false;\n    handle->markErrorAsIgnorable(Error::Code::Error);\n    succeed = handle->executeSQL(sql);\n    if (!succeed && handle->getError().code() == Error::Code::Error) {\n        succeed = true;\n    }\n    handle->markErrorAsUnignorable();\n    if (succeed) {\n        m_table = tableName;\n        auto attribute = handle->getTableAttribute(Schema::main(), tableName);\n        if (attribute.hasValue()) {\n            m_withoutRowid = attribute->withoutRowid;\n        }\n    }\n    return succeed;\n}\n\nbool AssembleHandleOperator::isAssemblingTableWithoutRowid() const\n{\n    return m_withoutRowid;\n}\n\nbool AssembleHandleOperator::assembleCell(const Repair::Cell &cell)\n{\n    WCTAssert(!m_table.empty());\n    if (!lazyPrepareCell()) {\n        return false;\n    }\n    WCTAssert(m_cellStatement->isPrepared());\n    m_cellStatement->reset();\n    if (!m_withoutRowid) {\n        m_cellStatement->bindInteger(cell.getRowID(), 1);\n    }\n    for (int i = 0; i < cell.getCount(); ++i) {\n        int bindIndex = m_withoutRowid ? i + 1 : i + 2;\n        switch (cell.getValueType(i)) {\n        case Repair::Cell::Integer:\n            m_cellStatement->bindInteger(cell.integerValue(i), bindIndex);\n            break;\n        case Repair::Cell::Text: {\n            m_cellStatement->bindText(cell.textValue(i), bindIndex);\n            break;\n        }\n        case Repair::Cell::BLOB: {\n            m_cellStatement->bindBLOB(cell.blobValue(i), bindIndex);\n            break;\n        }\n        case Repair::Cell::Real:\n            m_cellStatement->bindDouble(cell.doubleValue(i), bindIndex);\n            break;\n        case Repair::Cell::Null:\n            if (i == m_integerPrimary) {\n                m_cellStatement->bindInteger(cell.getRowID(), bindIndex);\n            } else {\n                m_cellStatement->bindNull(bindIndex);\n            }\n            break;\n        }\n    }\n    bool succeed = m_cellStatement->step();\n    return succeed;\n}\n\nvoid AssembleHandleOperator::markDuplicatedAsReplaceable(bool replaceable)\n{\n    if (isDuplicatedReplaceable() != replaceable && m_cellStatement->isPrepared()) {\n        m_cellStatement->finalize();\n    }\n    AssembleDelegate::markDuplicatedAsReplaceable(replaceable);\n}\n\nbool AssembleHandleOperator::lazyPrepareCell()\n{\n    if (m_cellStatement->isPrepared()) {\n        return true;\n    }\n\n    auto optionalMetas = getHandle()->getTableMeta(Schema(), m_table);\n    if (!optionalMetas.succeed()) {\n        return false;\n    }\n    auto &metas = optionalMetas.value();\n    m_integerPrimary = ColumnMeta::getIndexOfIntegerPrimary(metas);\n\n    Columns columns = {};\n    if (!m_withoutRowid) {\n        columns.push_back(Column::rowid());\n    }\n    for (const auto &meta : metas) {\n        columns.push_back(Column(meta.name));\n    }\n    StatementInsert statement\n    = StatementInsert().insertIntoTable(StringView::formatted(\"'%s'\", m_table.data()));\n    if (isDuplicatedReplaceable()) {\n        statement.orReplace();\n    } else if (isDuplicatedIgnorable()) {\n        statement.orIgnore();\n    }\n    statement.columns(columns).values(BindParameter::bindParameters(columns.size()));\n\n    return m_cellStatement->prepare(statement);\n}\n\n#pragma mark - Assemble - Sequence\nbool AssembleHandleOperator::assembleSequence(const UnsafeStringView &tableName, int64_t sequence)\n{\n    if (sequence == 0) {\n        return true;\n    }\n    bool succeed = false;\n    auto worked = updateSequence(tableName, sequence);\n    if (worked.succeed()) {\n        if (worked.value()) {\n            succeed = true;\n        } else {\n            succeed = insertSequence(tableName, sequence);\n        }\n    }\n    return succeed;\n}\n\nOptional<bool>\nAssembleHandleOperator::updateSequence(const UnsafeStringView &tableName, int64_t sequence)\n{\n    Optional<bool> worked;\n    InnerHandle *handle = getHandle();\n    if (handle->prepare(m_statementForUpdateSequence)) {\n        handle->bindInteger(sequence, 1);\n        handle->bindText(tableName, 2);\n        if (handle->step()) {\n            worked = handle->getChanges() > 0;\n        }\n        handle->finalize();\n    }\n    return worked;\n}\n\nbool AssembleHandleOperator::insertSequence(const UnsafeStringView &tableName, int64_t sequence)\n{\n    InnerHandle *handle = getHandle();\n    bool succeed = false;\n    if (handle->prepare(m_statementForInsertSequence)) {\n        handle->bindText(tableName, 1);\n        handle->bindInteger(sequence, 2);\n        succeed = handle->step();\n        handle->finalize();\n    }\n    return succeed;\n}\n\nbool AssembleHandleOperator::markSequenceAsAssembling()\n{\n    return getHandle()->executeStatement(\n    StatementCreateTable()\n    .createTable(s_dummySequence)\n    .ifNotExists()\n    .define(ColumnDef(Column(\"i\"), ColumnType::Integer)\n            .constraint(ColumnConstraint().primaryKey().autoIncrement())));\n}\n\nbool AssembleHandleOperator::markSequenceAsAssembled()\n{\n    return getHandle()->executeStatement(\n    StatementDropTable().dropTable(s_dummySequence).ifExists());\n}\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/core/assemble/AssembleHandleOperator.hpp",
    "content": "//\n// Created by qiuwenchen on 2023/11/17.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"Assemble.hpp\"\n#include \"HandleOperator.hpp\"\n#include \"RepairKit.h\"\n\nnamespace WCDB {\n\nclass AssembleHandleOperator : public HandleOperator, public Repair::AssembleDelegate {\npublic:\n    AssembleHandleOperator(InnerHandle *handle);\n    ~AssembleHandleOperator() override;\n\n#pragma mark - Assemble\npublic:\n    void setAssemblePath(const UnsafeStringView &path) override final;\n    const StringView &getAssemblePath() const override final;\n    const Error &getAssembleError() const override final;\n\n    void suspendAssemble() override final;\n    void finishAssemble() override final;\n\n    bool markAsAssembling() override final;\n    bool markAsAssembled() override final;\n\n    bool markAsMilestone() override final;\n\n    bool assembleSQL(const UnsafeStringView &sql) override final;\n\nprotected:\n    StatementPragma m_statementForDisableJounral;\n    StatementPragma m_statementForEnableMMap;\n\n#pragma mark - Assemble - Table\npublic:\n    bool assembleTable(const UnsafeStringView &tableName,\n                       const UnsafeStringView &sql) override final;\n    bool isAssemblingTableWithoutRowid() const override final;\n    bool assembleCell(const Repair::Cell &cell) override final;\n    void markDuplicatedAsReplaceable(bool replaceable) override final;\n\nprotected:\n    bool lazyPrepareCell();\n    int64_t m_integerPrimary;\n    StringView m_table;\n    bool m_withoutRowid;\n    HandleStatement *m_cellStatement;\n\n#pragma mark - Assemble - Sequence\npublic:\n    bool assembleSequence(const UnsafeStringView &tableName, int64_t sequence) override final;\n\nprotected:\n    Optional<bool> updateSequence(const UnsafeStringView &tableName, int64_t sequence);\n    bool insertSequence(const UnsafeStringView &tableName, int64_t sequence);\n    static constexpr const char *s_dummySequence = \"wcdb_dummy_sqlite_sequence\";\n    bool markSequenceAsAssembling();\n    bool markSequenceAsAssembled();\n\n    StatementUpdate m_statementForUpdateSequence;\n    StatementInsert m_statementForInsertSequence;\n};\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/common/core/cipher/CipherHandle.cpp",
    "content": "//\n// Created by 陈秋文 on 2023/9/9.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"CipherHandle.hpp\"\n#include \"Assertion.hpp\"\n#include \"FileManager.hpp\"\n#include \"SQLite.h\"\n#include <string.h>\n\nnamespace WCDB {\n\n#pragma mark - Cipher\n\nCipherHandle::CipherHandle() : InnerHandle(), m_isInitializing(false)\n{\n}\n\nCipherHandle::~CipherHandle() = default;\n\nconst Error &CipherHandle::getCipherError() const\n{\n    return InnerHandle::getError();\n}\n\nbool CipherHandle::execute(const Statement &statement)\n{\n    //Filter out encryption-irrelevant statements during the initialization phase\n    if (m_isInitializing && !statement.getDescription().hasPrefix(\"PRAGMA cipher_\")\n        && !statement.getDescription().hasPrefix(\"PRAGMA kdf_iter\")) {\n        return true;\n    } else {\n        return InnerHandle::execute(statement);\n    }\n}\n\nbool CipherHandle::setCipherKey(const UnsafeData &data)\n{\n    if (m_isInitializing && data.size() == 99) {\n        UnsafeStringView cipher\n        = UnsafeStringView((const char *) data.buffer(), data.size());\n        if (cipher.hasPrefix(\"x'\") && cipher.hasSuffix(\"'\")) {\n            // In this case, the cipher is made up of a 64-bit raw key and a 32-bit salt,\n            // and we need to remove the salt part.\n            // Please see: https://www.zetetic.net/sqlcipher/sqlcipher-api/#key\n            void *buffer = malloc(67 * sizeof(unsigned char));\n            if (buffer == nullptr) {\n                notifyError(Error::Code::NoMemory, \"\", \"Malloc memory for cipher fail\");\n                return false;\n            }\n            memcpy(buffer, data.buffer(), 66 * sizeof(unsigned char));\n            ((char *) buffer)[66] = '\\'';\n            bool ret\n            = InnerHandle::setCipherKey(UnsafeData((unsigned char *) buffer, 67));\n            free(buffer);\n            return ret;\n        }\n    }\n    return InnerHandle::setCipherKey(data);\n}\n\nOptional<StringView> CipherHandle::tryGetSaltFromDatabase(const UnsafeStringView &path)\n{\n    Optional<StringView> result;\n    auto size = FileManager::getFileSize(path);\n    if (size.failed()) {\n        return result;\n    }\n    int saltLength = 16;\n    if (size.value() < saltLength) {\n        return StringView();\n    }\n    FileHandle handle(path);\n    if (!handle.open(FileHandle::Mode::ReadOnly)) {\n        return result;\n    }\n    Data saltData = handle.read(saltLength);\n    if (saltData.size() != saltLength) {\n        return result;\n    }\n    if (strncmp(\"SQLite format 3\\000\", (const char *) saltData.buffer(), saltLength) == 0) {\n        return StringView();\n    }\n    return StringView::hexString(saltData);\n}\n\nbool CipherHandle::openCipherInMemory()\n{\n    InnerHandle::setPath(\":memory:\");\n    m_isInitializing = true;\n    bool ret = InnerHandle::open();\n    m_isInitializing = false;\n    return ret;\n}\n\nvoid CipherHandle::closeCipher()\n{\n    InnerHandle::close();\n}\n\nbool CipherHandle::isCipherDB()\n{\n    WCTAssert(isOpened());\n    return InnerHandle::hasCipher();\n}\n\nvoid *CipherHandle::getCipherContext()\n{\n    WCTAssert(isOpened());\n    return AbstractHandle::getCipherContext();\n}\n\nsize_t CipherHandle::getCipherPageSize()\n{\n    WCTAssert(isOpened());\n    return AbstractHandle::getCipherPageSize();\n}\n\nStringView CipherHandle::getCipherSalt()\n{\n    WCTAssert(isOpened());\n    return AbstractHandle::getCipherSalt();\n}\n\nbool CipherHandle::setCipherSalt(const UnsafeStringView &salt)\n{\n    WCTAssert(isOpened());\n    return AbstractHandle::setCipherSalt(salt);\n}\n\nbool CipherHandle::switchCipherSalt(const UnsafeStringView &salt)\n{\n    closeCipher();\n    if (!openCipherInMemory()) {\n        return false;\n    }\n    return AbstractHandle::setCipherSalt(salt);\n}\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/core/cipher/CipherHandle.hpp",
    "content": "//\n// Created by 陈秋文 on 2023/9/9.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"Backup.hpp\"\n#include \"InnerHandle.hpp\"\n\nnamespace WCDB {\n\nclass CipherHandle final : public InnerHandle, public Repair::CipherDelegate {\npublic:\n    CipherHandle();\n    ~CipherHandle() override;\n\n    bool execute(const Statement &statement) override final;\n    bool setCipherKey(const UnsafeData &data) override final;\n    Optional<StringView> tryGetSaltFromDatabase(const UnsafeStringView &path) override final;\n\n#pragma mark - Cipher\npublic:\n    const Error &getCipherError() const override final;\n    bool openCipherInMemory() override final;\n    void closeCipher() override final;\n    bool isCipherDB() override final;\n\n    void *getCipherContext() override final;\n    size_t getCipherPageSize() override final;\n    StringView getCipherSalt() override final;\n    bool setCipherSalt(const UnsafeStringView &salt) override final;\n    bool switchCipherSalt(const UnsafeStringView &salt) override final;\n    bool m_isInitializing;\n};\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/core/compression/AutoCompressConfig.cpp",
    "content": "//\n// Created by qiuwenchen on 2023/12/2.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"AutoCompressConfig.hpp\"\n#include \"Assertion.hpp\"\n#include \"InnerHandle.hpp\"\n\nnamespace WCDB {\n\nAutoCompressOperator::~AutoCompressOperator() = default;\n\nAutoCompressConfig::AutoCompressConfig(const std::shared_ptr<AutoCompressOperator>& operator_)\n: Config(), m_operator(operator_)\n{\n    WCTAssert(m_operator != nullptr);\n}\n\nAutoCompressConfig::~AutoCompressConfig() = default;\n\nbool AutoCompressConfig::invoke(InnerHandle* handle)\n{\n    const UnsafeStringView& path = handle->getPath();\n    if (++getOrCreateRegister(path) == 1) {\n        m_operator->asyncCompress(path);\n    }\n    return true;\n}\n\nbool AutoCompressConfig::uninvoke(InnerHandle* handle)\n{\n    const UnsafeStringView& path = handle->getPath();\n    if (--getOrCreateRegister(path) == 0) {\n        m_operator->stopCompress(path);\n    }\n    return true;\n}\n\nstd::atomic<int>& AutoCompressConfig::getOrCreateRegister(const UnsafeStringView& path)\n{\n    {\n        SharedLockGuard lockGuard(m_lock);\n        auto iter = m_registers.find(path);\n        if (iter != m_registers.end()) {\n            WCTAssert(iter->second.load() >= 0);\n            return iter->second;\n        }\n    }\n    {\n        LockGuard lockGuard(m_lock);\n        auto iter = m_registers.find(path);\n        if (iter == m_registers.end()) {\n            m_registers[path] = 0;\n            iter = m_registers.find(path);\n        }\n        WCTAssert(iter->second.load() >= 0);\n        return iter->second;\n    }\n}\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/core/compression/AutoCompressConfig.hpp",
    "content": "//\n// Created by qiuwenchen on 2023/12/2.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"Config.hpp\"\n#include \"Lock.hpp\"\n#include \"StringView.hpp\"\n#include <map>\n#include <memory>\n\nnamespace WCDB {\n\nclass AutoCompressOperator {\npublic:\n    virtual ~AutoCompressOperator() = 0;\n    virtual void asyncCompress(const UnsafeStringView &path) = 0;\n    virtual void stopCompress(const UnsafeStringView &path) = 0;\n};\n\nclass AutoCompressConfig final : public Config {\npublic:\n    AutoCompressConfig(const std::shared_ptr<AutoCompressOperator> &operator_);\n    ~AutoCompressConfig() override;\n\n    bool invoke(InnerHandle *handle) override final;\n    bool uninvoke(InnerHandle *handle) override final;\n\nprotected:\n    std::shared_ptr<AutoCompressOperator> m_operator;\n\n    std::atomic<int> &getOrCreateRegister(const UnsafeStringView &path);\n\nprivate:\n    SharedLock m_lock;\n    StringViewMap<std::atomic<int>> m_registers;\n};\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/common/core/compression/CompressHandleOperator.cpp",
    "content": "//\n// Created by qiuwenchen on 2023/11/26.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"CompressHandleOperator.hpp\"\n#include \"Assertion.hpp\"\n#include \"CompressionCenter.hpp\"\n#include \"CompressionConst.hpp\"\n#include \"CompressionRecord.hpp\"\n#include \"CoreConst.h\"\n#include \"Notifier.hpp\"\n#include \"Time.hpp\"\n#include <stdlib.h>\n#include <string.h>\n\nnamespace WCDB {\n\nCompressHandleOperator::CompressHandleOperator(InnerHandle* handle)\n: HandleOperator(handle)\n, m_compressedCount(0)\n, m_compressingTableInfo(nullptr)\n, m_insertParameterCount(0)\n, m_selectRowidStatement(handle->getStatement(DecoratorAllType))\n, m_selectRowStatement(handle->getStatement(DecoratorAllType))\n, m_deleteRowStatement(handle->getStatement(DecoratorAllType))\n, m_insertNewRowStatement(handle->getStatement(DecoratorAllType))\n, m_updateRecordStatement(handle->getStatement(DecoratorAllType))\n{\n}\n\nCompressHandleOperator::~CompressHandleOperator()\n{\n    finalizeCompressionStatements();\n    m_updateRecordStatement->finalize();\n    InnerHandle* handle = getHandle();\n    WCTAssert(handle != nullptr);\n    handle->returnStatement(m_selectRowidStatement);\n    handle->returnStatement(m_selectRowStatement);\n    handle->returnStatement(m_deleteRowStatement);\n    handle->returnStatement(m_insertNewRowStatement);\n    handle->returnStatement(m_updateRecordStatement);\n}\n\n#pragma mark - Stepper\nOptional<StringViewSet> CompressHandleOperator::getAllTables()\n{\n    Column name(\"name\");\n    Column type(\"type\");\n    StringView sqlitePattern\n    = StringView::formatted(\"%s%%\", Syntax::builtinTablePrefix.data());\n    StringView wcdbPattern\n    = StringView::formatted(\"%s%%\", Syntax::builtinWCDBTablePrefix.data());\n    return getHandle()->getValues(\n    StatementSelect()\n    .select(name)\n    .from(TableOrSubquery::master())\n    .where(type == \"table\" && name.notLike(sqlitePattern) && name.notLike(wcdbPattern)),\n    0);\n}\n\nbool CompressHandleOperator::filterComplessingTables(std::set<const CompressionTableInfo*>& allTableInfos)\n{\n    InnerHandle* handle = getHandle();\n    WCTAssert(handle != nullptr);\n    StatementSelect select\n    = StatementSelect().select(Column::all()).from(CompressionRecord::tableName);\n    if (!handle->prepare(select)) {\n        return false;\n    }\n    auto allRecords = handle->getAllRows();\n    handle->finalize();\n    if (allRecords.failed()) {\n        return false;\n    }\n    if (allRecords.value().size() == 0) {\n        return true;\n    }\n    if (allRecords.value().front().size() != 3) {\n        StringView msg = StringView::formatted(\n        \"Invalid compression record size: %llu\", allRecords.value().size());\n        handle->notifyError(Error::Code::Error, nullptr, msg);\n        return false;\n    }\n    StringViewMap<std::pair<StringView, int64_t>> allRecordsMap;\n    for (auto& row : allRecords.value()) {\n        allRecordsMap.emplace(row[0].textValue(),\n                              { row[1].textValue(), row[2].intValue() });\n    }\n    for (auto iter = allTableInfos.begin(); iter != allTableInfos.end();) {\n        auto recordIter = allRecordsMap.find((*iter)->getTable());\n        if (recordIter == allRecordsMap.end()) {\n            iter++;\n            continue;\n        }\n        const StringView& compression = recordIter->second.first;\n        if (!(*iter)->shouldReplaceCompression()) {\n            auto compressedColumns = parseColumns(compression);\n            bool columnMatched = true;\n            for (const auto& compressingColumn : (*iter)->getColumnInfos()) {\n                const StringView& columnName = compressingColumn.getColumn();\n                if (compressedColumns.find(columnName) == compressedColumns.end()) {\n                    columnMatched = false;\n                    break;\n                }\n            }\n            if (!columnMatched) {\n                iter++;\n                continue;\n            }\n        } else {\n            StringView curCompression = (*iter)->getCompressionDescription();\n            if (!curCompression.equal(compression)) {\n                iter++;\n                continue;\n            }\n        }\n        if (recordIter->second.second <= 0) {\n            (*iter)->setMinCompressedRowid(0);\n            iter = allTableInfos.erase(iter);\n        } else {\n            (*iter)->setMinCompressedRowid(recordIter->second.second);\n            iter++;\n        }\n    }\n    return true;\n}\n\nstd::set<StringView> CompressHandleOperator::parseColumns(const StringView& compressRecord)\n{\n    std::set<StringView> columnNames;\n    size_t start = 0;\n    size_t end = compressRecord.find(\",\");\n\n    while (end != UnsafeStringView::npos) {\n        UnsafeStringView subInput = compressRecord.subStr(start, end - start);\n        size_t colonPos = subInput.find(\":\");\n        if (colonPos != UnsafeStringView::npos) {\n            columnNames.insert(subInput.subStr(0, colonPos - 1));\n        } else {\n            columnNames.insert(StringView(subInput));\n        }\n\n        start = end + 1;\n        end = compressRecord.find(\",\", start);\n    }\n\n    UnsafeStringView subInput = compressRecord.subStr(start);\n    size_t colonPos = subInput.find(\":\");\n    if (colonPos != UnsafeStringView::npos) {\n        columnNames.insert(subInput.subStr(0, colonPos - 1));\n    } else {\n        columnNames.insert(StringView(subInput));\n    }\n\n    return columnNames;\n}\n\nOptional<bool> CompressHandleOperator::compressRows(const CompressionTableInfo* info)\n{\n    WCTAssert(info != nullptr);\n    int64_t start = Time::currentThreadCPUTimeInMicroseconds();\n    if (m_compressingTableInfo != info) {\n        finalizeCompressionStatements();\n        m_compressedCount = 0;\n        m_compressingTableInfo = info;\n    }\n    if (!prepareCompressionStatements()) {\n        return NullOpt;\n    }\n    m_selectRowidStatement->bindInteger(m_compressingTableInfo->getMinCompressedRowid());\n    auto rowids = m_selectRowidStatement->getOneColumn();\n    if (rowids.failed()) {\n        m_selectRowidStatement->reset();\n        return NullOpt;\n    }\n    auto compressed = doCompressRows(rowids.value());\n    if (compressed.failed()) {\n        return NullOpt;\n    }\n    if (!compressed.value()) {\n        return false;\n    }\n\n    bool compressionFinish = false;\n    if (rowids.value().size() < CompressionBatchCount) {\n        m_compressingTableInfo->setMinCompressedRowid(0);\n        compressionFinish = true;\n    } else {\n        m_compressingTableInfo->setMinCompressedRowid(rowids.value().back());\n    }\n    m_compressedCount += rowids.value().size();\n    if (m_compressedCount >= CompressionUpdateRecordBatchCount || compressionFinish) {\n        updateCompressionRecord();\n    }\n\n    m_performance.compressTime += Time::currentThreadCPUTimeInMicroseconds() - start;\n    if (m_performance.compressedCount + m_performance.uncompressedCount > CompressionUpdateRecordBatchCount\n        || (compressionFinish\n            && m_performance.compressedCount + m_performance.uncompressedCount > 0)) {\n        reportPerformance(info->getTable());\n    }\n\n    return compressionFinish;\n}\n\nOptional<bool> CompressHandleOperator::doCompressRows(const OneColumnValue& rowids)\n{\n    bool interrupted = false;\n    bool ret = getHandle()->runTransaction([&](InnerHandle* handle) {\n        MultiRowsValue rows;\n        for (const auto& rowid : rowids) {\n            m_selectRowStatement->reset();\n            m_selectRowStatement->bindInteger(rowid);\n            if (!m_selectRowStatement->step()) {\n                return false;\n            }\n            if (m_selectRowStatement->done()) {\n                continue;\n            }\n            auto row = m_selectRowStatement->getOneRow();\n\n            if (!compressRow(row)) {\n                return false;\n            }\n\n            rows.push_back(std::move(row));\n\n            m_deleteRowStatement->reset();\n            m_deleteRowStatement->bindInteger(rowid);\n            if (!m_deleteRowStatement->step()) {\n                return false;\n            }\n            if (handle->checkHasBusyRetry()) {\n                interrupted = true;\n                handle->notifyError(Error::Code::Notice, \"\", \"Interrupt compression due to busy\");\n                return false;\n            }\n        }\n        for (const auto& row : rows) {\n            if (handle->checkHasBusyRetry()) {\n                interrupted = true;\n                handle->notifyError(Error::Code::Notice, \"\", \"Interrupt compression due to busy\");\n                return false;\n            }\n            if (!m_insertNewRowStatement->isPrepared() || row.size() != m_insertParameterCount) {\n                m_insertNewRowStatement->finalize();\n                m_insertParameterCount = row.size();\n                if (!m_insertNewRowStatement->prepare(m_compressingTableInfo->getInsertNewRowStatement(\n                    m_insertParameterCount))) {\n                    return false;\n                }\n            }\n            m_insertNewRowStatement->reset();\n            m_insertNewRowStatement->bindRow(row);\n            if (!m_insertNewRowStatement->step()) {\n                return false;\n            }\n        }\n        return true;\n    });\n    resetCompressionStatements();\n    if (!ret && !interrupted) {\n        return NullOpt;\n    }\n    return !interrupted;\n}\n\nbool CompressHandleOperator::compressRow(OneRowValue& row)\n{\n    for (const auto& column : m_compressingTableInfo->getColumnInfos()) {\n        if (column.getColumnIndex() >= row.size()) {\n            getHandle()->notifyError(\n            Error::Code::Error,\n            nullptr,\n            StringView::formatted(\"Compressing column %s with index index %u out of range\",\n                                  column.getColumn().data(),\n                                  column.getColumnIndex()));\n            return false;\n        }\n        Value& value = row[column.getColumnIndex()];\n        ColumnType valueType = value.getType();\n\n        if (column.getTypeColumnIndex() >= row.size()) {\n            getHandle()->notifyError(\n            Error::Code::Error,\n            nullptr,\n            StringView::formatted(\"Compressing type column %s with index index %u out of range\",\n                                  column.getTypeColumn().data(),\n                                  column.getTypeColumnIndex()));\n            return false;\n        }\n\n        Value& compressedType = row[column.getTypeColumnIndex()];\n        if (valueType < ColumnType::Text) {\n            compressedType = CompressedType::None;\n            continue;\n        }\n        UnsafeData data;\n        if (valueType == ColumnType::Text) {\n            const StringView& text = value.textValue();\n            data = UnsafeData((unsigned char*) text.data(), text.length());\n        } else {\n            data = value.blobValue();\n        }\n        CompressedType originCompressionType\n        = WCDBGetCompressedType(compressedType.intValue());\n        if (originCompressionType != CompressedType::None) {\n            if (!m_compressingTableInfo->shouldReplaceCompression()) {\n                continue;\n            }\n            auto decompressed = CompressionCenter::shared().decompressContent(\n            data, originCompressionType == CompressedType::ZSTDDict, getHandle());\n            if (!decompressed.hasValue()) {\n                return false;\n            }\n            valueType = WCDBGetOriginType(compressedType.intValue());\n            if (valueType == ColumnType::Text) {\n                value = StringView((const char*) decompressed.value().buffer(),\n                                   decompressed.value().size());\n                const StringView& text = value.textValue();\n                data = UnsafeData((unsigned char*) text.data(), text.length());\n            } else {\n                value = decompressed.value();\n                data = value.blobValue();\n            }\n        }\n\n        CompressedType toCompressedType = CompressedType::ZSTDDict;\n        Optional<UnsafeData> compressedValue;\n\n        switch (column.getCompressionType()) {\n        case CompressionType::Normal: {\n            toCompressedType = CompressedType::ZSTDNormal;\n            compressedValue\n            = CompressionCenter::shared().compressContent(data, 0, getHandle());\n        } break;\n        case CompressionType::Dict: {\n            compressedValue = CompressionCenter::shared().compressContent(\n            data, column.getDictId(), getHandle());\n        } break;\n        case CompressionType::VariousDict: {\n            if (column.getMatchColumnIndex() >= row.size()) {\n                getHandle()->notifyError(\n                Error::Code::Error,\n                nullptr,\n                StringView::formatted(\"Compressing match column %s with index index %u out of range\",\n                                      column.getMatchColumn().data(),\n                                      column.getMatchColumnIndex()));\n                return false;\n            }\n            Value& matchValue = row[column.getMatchColumnIndex()];\n            compressedValue = CompressionCenter::shared().compressContent(\n            data, column.getMatchDictId(matchValue), getHandle());\n        } break;\n        }\n\n        if (compressedValue.failed()) {\n            return false;\n        }\n        WCTAssert(compressedValue.value().size() <= data.size());\n\n        m_performance.totalSize += data.size();\n        if (compressedValue.value().size() < data.size()) {\n            value = compressedValue.value();\n            if (!CompressionCenter::shared().testContentCanBeDecompressed(\n                value.blobValue(), toCompressedType == CompressedType::ZSTDDict, getHandle())) {\n                return false;\n            }\n            compressedType = WCDBMergeCompressionType(toCompressedType, valueType);\n\n            m_performance.compressedCount++;\n            m_performance.compressedSize += compressedValue.value().size();\n            m_performance.originalSize += data.size();\n        } else {\n            m_performance.uncompressedCount++;\n            compressedType = WCDBMergeCompressionType(CompressedType::None, valueType);\n        }\n    }\n    return true;\n}\n\nbool CompressHandleOperator::prepareCompressionStatements()\n{\n    if (!m_selectRowidStatement->isPrepared()\n        && !m_selectRowidStatement->prepare(\n        m_compressingTableInfo->getSelectNeedCompressRowIdStatement())) {\n        return false;\n    }\n    if (!m_selectRowStatement->isPrepared()\n        && !m_selectRowStatement->prepare(m_compressingTableInfo->getSelectRowStatement())) {\n        return false;\n    }\n    if (!m_deleteRowStatement->isPrepared()\n        && !m_deleteRowStatement->prepare(m_compressingTableInfo->getDelectRowStatement())) {\n        return false;\n    }\n    return true;\n}\n\nvoid CompressHandleOperator::resetCompressionStatements()\n{\n    if (m_selectRowidStatement->isPrepared()) {\n        m_selectRowidStatement->reset();\n    }\n    if (m_selectRowStatement->isPrepared()) {\n        m_selectRowStatement->reset();\n    }\n    if (m_deleteRowStatement->isPrepared()) {\n        m_deleteRowStatement->reset();\n    }\n    if (m_insertNewRowStatement->isPrepared()) {\n        m_insertNewRowStatement->reset();\n    }\n}\n\nvoid CompressHandleOperator::finalizeCompressionStatements()\n{\n    m_insertParameterCount = 0;\n    m_selectRowidStatement->finalize();\n    m_selectRowStatement->finalize();\n    m_deleteRowStatement->finalize();\n    m_insertNewRowStatement->finalize();\n}\n\nbool CompressHandleOperator::updateCompressionRecord()\n{\n    if (!m_updateRecordStatement->isPrepared()\n        && !m_updateRecordStatement->prepare(CompressionRecord::getInsertValueStatement())) {\n        return false;\n    }\n\n    m_updateRecordStatement->bindText(m_compressingTableInfo->getTable(), 1);\n    m_updateRecordStatement->bindText(\n    m_compressingTableInfo->getCompressionDescription(), 2);\n    m_updateRecordStatement->bindInteger(\n    m_compressingTableInfo->getMinCompressedRowid(), 3);\n    bool ret = m_updateRecordStatement->step();\n    m_updateRecordStatement->reset();\n    return ret;\n}\n\nvoid CompressHandleOperator::reportPerformance(const UnsafeStringView& table)\n{\n    Error error(Error::Code::Notice, Error::Level::Notice, \"Compression performance\");\n    error.infos.insert_or_assign(ErrorStringKeyPath, getHandle()->getPath());\n    error.infos.insert_or_assign(ErrorIntKeyTag, (long) getHandle()->getTag());\n    error.infos.insert_or_assign(\"CompressTime\", m_performance.compressTime);\n    error.infos.insert_or_assign(\"CompressedCount\", m_performance.compressedCount);\n    error.infos.insert_or_assign(\"UncompressedCount\", m_performance.uncompressedCount);\n    error.infos.insert_or_assign(\"OriginalSize\", m_performance.originalSize);\n    error.infos.insert_or_assign(\"CompressedSize\", m_performance.compressedSize);\n    error.infos.insert_or_assign(\"TotalSize\", m_performance.totalSize);\n    error.infos.insert_or_assign(\"Table\", table);\n\n    Notifier::shared().notify(error);\n\n    m_performance = CompressionPerformance();\n}\n\nInnerHandle* CompressHandleOperator::getCurrentHandle() const\n{\n    return getHandle();\n}\n\nbool CompressHandleOperator::rollbackCompression(const CompressionTableInfo* info)\n{\n    clearProgress();\n    auto compressedColumns = getCompressedColumns(info);\n    if (compressedColumns.failed()) {\n        return false;\n    }\n    if (compressedColumns.value().size() == 0) {\n        finishProgress();\n        return true;\n    }\n\n    int64_t maxRowId = 0;\n    int64_t curMaxRowid = std::numeric_limits<int64_t>::max();\n    bool succeed = true;\n    while (curMaxRowid > 0) {\n        auto nextMaxRowid = batchRollbackCompression(\n        info, compressedColumns.value(), maxRowId, curMaxRowid);\n        succeed = nextMaxRowid.succeed() && getHandle()->checkpoint();\n        if (!succeed) {\n            return false;\n        }\n        curMaxRowid = nextMaxRowid.value();\n    }\n    if (succeed) {\n        succeed\n        = execute(CompressionRecord::getDeleteRecordStatement(info->getTable()));\n        succeed = succeed && getHandle()->checkpoint();\n    }\n    if (succeed) {\n        finishProgress();\n    }\n    return succeed;\n}\n\nOptional<int64_t> CompressHandleOperator::batchRollbackCompression(\nconst CompressionTableInfo* info,\nconst std::list<const CompressionColumnInfo*>& compressedColumns,\nint64_t& maxRowId,\nint64_t curRowId)\n{\n    bool ret = getHandle()->runTransaction([&](InnerHandle*) {\n        HandleStatement* selectRowid = getHandle()->getStatement(DecoratorAllType);\n        HandleStatement* selectCompressedColumn\n        = getHandle()->getStatement(DecoratorAllType);\n        HandleStatement* updateCompressedColumn\n        = getHandle()->getStatement(DecoratorAllType);\n\n        bool succeed\n        = selectRowid->prepare(info->getSelectCompressedRowIdStatement(curRowId));\n        succeed = succeed\n                  && selectCompressedColumn->prepare(\n                  info->getSelectCompressedRowStatement(&compressedColumns));\n        succeed = succeed\n                  && updateCompressedColumn->prepare(\n                  info->getUpdateCompressColumnStatement(&compressedColumns));\n\n        int updatedRowCount = 0;\n        if (succeed) {\n            while ((succeed = selectRowid->step()) && !selectRowid->done()) {\n                curRowId = selectRowid->getInteger();\n                if (maxRowId == 0) {\n                    maxRowId = curRowId;\n                }\n\n                succeed = info->stepSelectAndUpdateCompressedRowStatement(\n                selectCompressedColumn, updateCompressedColumn, curRowId);\n                if (!succeed) {\n                    break;\n                }\n\n                if (maxRowId > 0 && !updateProgress(((double) maxRowId - curRowId) / maxRowId)) {\n                    succeed = false;\n                    break;\n                }\n\n                if (++updatedRowCount > 10 * CompressionBatchCount) {\n                    break;\n                }\n            }\n            if (selectRowid->done()) {\n                curRowId = 0;\n            }\n        }\n\n        selectRowid->finalize();\n        selectCompressedColumn->finalize();\n        updateCompressedColumn->finalize();\n        getHandle()->returnStatement(selectRowid);\n        getHandle()->returnStatement(selectCompressedColumn);\n        getHandle()->returnStatement(updateCompressedColumn);\n        return succeed;\n    });\n    if (ret) {\n        return curRowId;\n    } else {\n        return NullOpt;\n    }\n}\n\nbool CompressHandleOperator::deleteCompressionRecord()\n{\n    return execute(CompressionRecord::getDropTableStatement());\n}\n\nbool CompressHandleOperator::execute(const Statement& statement)\n{\n    HandleStatement* handleStatement = getHandle()->getStatement(DecoratorAllType);\n    bool succeed = handleStatement->prepare(statement) && handleStatement->step();\n    handleStatement->finalize();\n    getHandle()->returnStatement(handleStatement);\n    return succeed;\n}\n\nOptional<std::list<const CompressionColumnInfo*>>\nCompressHandleOperator::getCompressedColumns(const CompressionTableInfo* info)\n{\n    auto optionalMetas = getHandle()->getTableMeta(Schema::main(), info->getTable());\n    if (!optionalMetas.succeed()) {\n        return NullOpt;\n    }\n    auto& metas = optionalMetas.value();\n    std::list<StringView> curColumns;\n    for (const auto& meta : metas) {\n        curColumns.push_back(meta.name);\n    }\n\n    std::list<const CompressionColumnInfo*> compressedColumns;\n    for (auto& compressingColumn : info->getColumnInfos()) {\n        for (const auto& column : curColumns) {\n            if (column.equal(compressingColumn.getTypeColumn())) {\n                compressedColumns.push_back(&compressingColumn);\n            }\n        }\n    }\n    return compressedColumns;\n}\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/common/core/compression/CompressHandleOperator.hpp",
    "content": "//\n// Created by qiuwenchen on 2023/11/26.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"Compression.hpp\"\n#include \"HandleOperator.hpp\"\n#include <array>\n#include <set>\n\nnamespace WCDB {\n\nclass CompressHandleOperator final : public HandleOperator, public Compression::Stepper {\npublic:\n    CompressHandleOperator(InnerHandle* handle);\n    ~CompressHandleOperator() override;\n\n#pragma mark - Stepper\n    Optional<StringViewSet> getAllTables() override final;\n    bool filterComplessingTables(std::set<const CompressionTableInfo*>& allTableInfos) override final;\n    Optional<bool> compressRows(const CompressionTableInfo* info) override final;\n    bool rollbackCompression(const CompressionTableInfo* info) override final;\n    bool deleteCompressionRecord() override final;\n\nprivate:\n    std::set<StringView> parseColumns(const StringView& compressRecord);\n\n    typedef struct CompressionPerformance {\n        int compressedCount = 0;\n        int uncompressedCount = 0;\n        size_t compressedSize = 0;\n        size_t originalSize = 0;\n        int64_t compressTime = 0;\n        size_t totalSize = 0;\n    } CompressionPerformance;\n\n    Optional<bool> doCompressRows(const OneColumnValue& rowids);\n    bool compressRow(OneRowValue& row);\n\n    bool prepareCompressionStatements();\n    void resetCompressionStatements();\n    void finalizeCompressionStatements();\n    bool updateCompressionRecord();\n\n    Optional<int64_t>\n    batchRollbackCompression(const CompressionTableInfo* info,\n                             const std::list<const CompressionColumnInfo*>& compressedColumns,\n                             int64_t& maxRowId,\n                             int64_t curRowId);\n    bool execute(const Statement& statement);\n    Optional<std::list<const CompressionColumnInfo*>>\n    getCompressedColumns(const CompressionTableInfo* info);\n\n    int m_compressedCount;\n    const CompressionTableInfo* m_compressingTableInfo;\n    size_t m_insertParameterCount;\n    HandleStatement* m_selectRowidStatement;\n    HandleStatement* m_selectRowStatement;\n    HandleStatement* m_deleteRowStatement;\n    HandleStatement* m_insertNewRowStatement;\n    HandleStatement* m_updateRecordStatement;\n\n    CompressionPerformance m_performance;\n    void reportPerformance(const UnsafeStringView& table);\n\n#pragma mark - Info Initializer\nprotected:\n    InnerHandle* getCurrentHandle() const override final;\n};\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/common/core/compression/CompressingHandleDecorator.cpp",
    "content": "//\n// Created by qiuwenchen on 2023/11/28.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"CompressingHandleDecorator.hpp\"\n#include \"CompressingStatementDecorator.hpp\"\n\nnamespace WCDB {\n\nCompressingHandleDecorator::CompressingHandleDecorator(Compression& compression)\n: HandleDecorator(), Compression::Binder(compression)\n{\n}\n\nCompressingHandleDecorator::~CompressingHandleDecorator() = default;\n\nvoid CompressingHandleDecorator::decorate(Decorative* handle)\n{\n    Super::decorate(handle);\n    WCDBSwizzleDecorativeFunction(handle, CompressingHandleDecorator, getStatement);\n    WCDBSwizzleDecorativeFunction(handle, CompressingHandleDecorator, commitTransaction);\n    WCDBSwizzleDecorativeFunction(handle, CompressingHandleDecorator, rollbackTransaction);\n}\n\nInnerHandle* CompressingHandleDecorator::getCurrentHandle() const\n{\n    return getHandle();\n}\n\nDecorativeHandleStatement*\nCompressingHandleDecorator::getStatement(const UnsafeStringView& skipDecorator)\n{\n    DecorativeHandleStatement* statement = Super::getStatement(skipDecorator);\n    if (!statement->containDecorator(DecoratorCompressingHandleStatement)\n        && !skipDecorator.equal(DecoratorCompressingHandleStatement)\n        && !skipDecorator.equal(DecoratorAllType)) {\n        statement->tryAddDecorator<CompressingStatementDecorator>(\n        DecoratorCompressingHandleStatement, this);\n    }\n    return statement;\n}\n\nbool CompressingHandleDecorator::commitTransaction()\n{\n    bool ret = Super::commitTransaction();\n    if (ret && !getHandle()->isInTransaction()) {\n        notifyTransactionCommitted(true);\n    }\n    return ret;\n}\n\nvoid CompressingHandleDecorator::rollbackTransaction()\n{\n    Super::rollbackTransaction();\n    notifyTransactionCommitted(false);\n}\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/core/compression/CompressingHandleDecorator.hpp",
    "content": "//\n// Created by qiuwenchen on 2023/11/28.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"Compression.hpp\"\n#include \"DecorativeHandle.hpp\"\n\nnamespace WCDB {\n\nclass CompressingHandleDecorator : public HandleDecorator, public Compression::Binder {\nprivate:\n    using Super = HandleDecorator;\n#pragma mark - Initialize\npublic:\n    CompressingHandleDecorator(Compression &compression);\n    ~CompressingHandleDecorator() override;\n\n    void decorate(Decorative *handle) override final;\n\n#pragma mark - InfoInitializer\n    InnerHandle *getCurrentHandle() const override final;\n    bool commitTransaction() override final;\n    void rollbackTransaction() override final;\n\n#pragma mark - Statement\npublic:\n    DecorativeHandleStatement *\n    getStatement(const UnsafeStringView &skipDecorator) override final;\n};\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/core/compression/CompressingStatementDecorator.cpp",
    "content": "//\n// Created by qiuwenchen on 2023/11/28.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"CompressingStatementDecorator.hpp\"\n#include \"Assertion.hpp\"\n#include \"CommonCore.hpp\"\n#include \"CompressionCenter.hpp\"\n#include \"CompressionConst.hpp\"\n#include \"CompressionRecord.hpp\"\n#include \"InnerHandle.hpp\"\n#include \"StringView.hpp\"\n#include \"WINQ.h\"\n#include <algorithm>\n\nnamespace WCDB {\n\n#pragma mark - Basic\nCompressingStatementDecorator::CompressingStatementDecorator(Compression::Binder* binder)\n: HandleStatementDecorator()\n, m_compressionBinder(binder)\n, m_currentStatementType(StatementType::Invalid)\n, m_processing(false)\n, m_compressFail(false)\n, m_compressionTableInfo(nullptr)\n{\n}\n\nCompressingStatementDecorator::CompressingStatementDecorator(CompressingStatementDecorator&& other)\n: Super(std::move(other))\n, m_compressionBinder(other.m_compressionBinder)\n, m_currentStatementType(other.m_currentStatementType)\n, m_processing(other.m_processing)\n, m_additionalStatements(std::move(other.m_additionalStatements))\n{\n    other.m_compressionBinder = nullptr;\n    other.m_processing = false;\n    other.m_currentStatementType = StatementType::Invalid;\n    other.m_additionalStatements.clear();\n}\n\nCompressingStatementDecorator::~CompressingStatementDecorator() = default;\n\nvoid CompressingStatementDecorator::decorate(Decorative* handleStatement)\n{\n    Super::decorate(handleStatement);\n    WCDBSwizzleDecorativeFunction(handleStatement, CompressingStatementDecorator, prepare);\n    WCDBSwizzleDecorativeFunction(handleStatement, CompressingStatementDecorator, finalize);\n    WCDBSwizzleDecorativeFunction(handleStatement, CompressingStatementDecorator, step);\n    WCDBSwizzleDecorativeFunction(handleStatement, CompressingStatementDecorator, reset);\n    WCDBSwizzleDecorativeFunction(handleStatement, CompressingStatementDecorator, clearBindings);\n    WCDBSwizzleDecorativeFunction(handleStatement, CompressingStatementDecorator, bindInteger);\n    WCDBSwizzleDecorativeFunction(handleStatement, CompressingStatementDecorator, bindDouble);\n    WCDBSwizzleDecorativeFunction(handleStatement, CompressingStatementDecorator, bindText);\n    WCDBSwizzleDecorativeFunction(handleStatement, CompressingStatementDecorator, bindText16);\n    WCDBSwizzleDecorativeFunction(handleStatement, CompressingStatementDecorator, bindBLOB);\n    WCDBSwizzleDecorativeFunction(handleStatement, CompressingStatementDecorator, bindNull);\n    WCDBSwizzleDecorativeFunction(handleStatement, CompressingStatementDecorator, bindPointer);\n}\n\n#pragma mark - Override\nbool CompressingStatementDecorator::prepare(const Statement& statement)\n{\n    WCTRemedialAssert(!getHandleStatement()->isPrepared(),\n                      \"Last statement is not finalized.\",\n                      finalize(););\n    WCTAssert(!m_processing);\n    m_processing = true;\n    resetCompressionStatus();\n    bool ret = true;\n    m_currentStatementType = statement.getType();\n    switch (m_currentStatementType) {\n    case StatementType::InsertSTMT:\n        ret = processInsert(static_cast<const StatementInsert&>(statement));\n        break;\n    case StatementType::UpdateSTMT:\n        ret = processUpdate(static_cast<const StatementUpdate&>(statement));\n        break;\n    case StatementType::SelectSTMT:\n        ret = processSelect(static_cast<const StatementSelect&>(statement));\n        break;\n    case StatementType::DeleteSTMT:\n        ret = processDelete(static_cast<const StatementDelete&>(statement));\n        break;\n    case StatementType::CreateTableSTMT:\n        ret = processCreateTable(static_cast<const StatementCreateTable&>(statement));\n        break;\n    case StatementType::CreateViewSTMT:\n        ret = processCreateView(static_cast<const StatementCreateView&>(statement));\n        break;\n    case StatementType::DropTableSTMT:\n        ret = processDropTable(static_cast<const StatementDropTable&>(statement));\n        break;\n    case StatementType::AlterTableSTMT:\n        ret = processAlterTable(static_cast<const StatementAlterTable&>(statement));\n        break;\n    default:\n        ret = Super::prepare(statement);\n        break;\n    }\n    m_processing = false;\n    return ret;\n}\n\nvoid CompressingStatementDecorator::finalize()\n{\n    Super::finalize();\n    for (auto& handleStatement : m_additionalStatements) {\n        handleStatement.finalize();\n    }\n    m_additionalStatements.clear();\n    resetCompressionStatus();\n}\n\nbool CompressingStatementDecorator::step()\n{\n    if (m_compressFail) {\n        return false;\n    }\n    if (m_additionalStatements.size() > 0) {\n        WCTAssert(dynamic_cast<InnerHandle*>(getHandle()) != nullptr);\n        InnerHandle* handle = static_cast<InnerHandle*>(getHandle());\n        return handle->runTransaction([this](InnerHandle*) { return realStep(); });\n    }\n    return realStep();\n}\n\nvoid CompressingStatementDecorator::reset()\n{\n    Super::reset();\n    for (auto& handleStatement : m_additionalStatements) {\n        handleStatement.reset();\n    }\n    m_compressFail = false;\n}\n\nvoid CompressingStatementDecorator::clearBindings()\n{\n    Super::clearBindings();\n    for (auto& handleStatement : m_additionalStatements) {\n        handleStatement.clearBindings();\n    }\n    m_compressFail = false;\n}\n\nvoid CompressingStatementDecorator::bindInteger(const Integer& value, int index)\n{\n    if (getHandleStatement()->getBindParameterCount() >= index) {\n        Super::bindInteger(value, index);\n    }\n    BindInfo* info = m_bindInfoMap[index];\n    if (info != nullptr) {\n        WCTAssert(index != info->typeBindIndex);\n        if (index == info->matchColumnBindIndex) {\n            if (!info->bindedValue.isNull()) {\n                bindValueInInfo(info, value);\n            } else {\n                info->bindedValue = value;\n            }\n        } else {\n            Super::bindInteger((Integer) CompressedType::None, info->typeBindIndex);\n        }\n    } else if (m_currentStatementType == StatementType::UpdateSTMT\n               && !m_additionalStatements.empty()\n               && m_additionalStatements.front().getBindParameterCount() >= index) {\n        m_additionalStatements.front().bindInteger(value, index);\n    }\n}\n\nvoid CompressingStatementDecorator::bindDouble(const Float& value, int index)\n{\n    if (getHandleStatement()->getBindParameterCount() >= index) {\n        Super::bindDouble(value, index);\n    }\n    BindInfo* info = m_bindInfoMap[index];\n    if (info != nullptr) {\n        if (index == info->matchColumnBindIndex) {\n            getHandle()->notifyError(\n            Error::Code::Misuse,\n            \"\",\n            StringView::formatted(\"Bind float to compression match column: %s\",\n                                  info->columnInfo->getMatchColumn().data()));\n            m_compressFail = true;\n            return;\n        }\n        WCTAssert(index != info->typeBindIndex);\n        Super::bindInteger((Integer) CompressedType::None, info->typeBindIndex);\n    } else if (m_currentStatementType == StatementType::UpdateSTMT\n               && !m_additionalStatements.empty()\n               && m_additionalStatements.front().getBindParameterCount() >= index) {\n        m_additionalStatements.front().bindDouble(value, index);\n    }\n}\n\nvoid CompressingStatementDecorator::bindText(const Text& value, int index)\n{\n    BindInfo* info = m_bindInfoMap[index];\n    if (info != nullptr) {\n        WCTAssert(index == info->columnBindIndex);\n        if (index == info->matchColumnBindIndex) {\n            getHandle()->notifyError(\n            Error::Code::Misuse,\n            \"\",\n            StringView::formatted(\"Bind text to compression match column: %s\",\n                                  info->columnInfo->getMatchColumn().data()));\n            m_compressFail = true;\n            return;\n        }\n        UnsafeData data((unsigned char*) value.data(), value.size());\n        if (info->matchColumnBindIndex > 0) {\n            if (!info->bindedValue.isNull()) {\n                Optional<UnsafeData> compressedValue;\n                if (m_compressionBinder->canCompressNewData()) {\n                    compressedValue = CompressionCenter::shared().compressContent(\n                    data,\n                    info->columnInfo->getMatchDictId(info->bindedValue.intValue()),\n                    static_cast<InnerHandle*>(getHandle()));\n                } else {\n                    compressedValue = data;\n                }\n                if (compressedValue.failed()) {\n                    m_compressFail = true;\n                    return;\n                }\n                if (compressedValue.value().size() < value.size()) {\n                    Super::bindBLOB(compressedValue.value(), info->columnBindIndex);\n                    Super::bindInteger(WCDBMergeCompressionType(\n                                       CompressedType::ZSTDDict, ColumnType::Text),\n                                       info->typeBindIndex);\n                } else {\n                    Super::bindText(value, index);\n                    if (m_compressionBinder->canCompressNewData()) {\n                        Super::bindInteger(WCDBMergeCompressionType(\n                                           CompressedType::None, ColumnType::Text),\n                                           info->typeBindIndex);\n                    } else {\n                        Super::bindNull(info->typeBindIndex);\n                    }\n                }\n            } else {\n                info->bindedValue = value;\n            }\n        } else {\n            bool usingDict\n            = info->columnInfo->getCompressionType() == CompressionType::Dict;\n            Optional<UnsafeData> compressedValue;\n            if (m_compressionBinder->canCompressNewData()) {\n                compressedValue = CompressionCenter::shared().compressContent(\n                data,\n                usingDict ? info->columnInfo->getDictId() : 0,\n                static_cast<InnerHandle*>(getHandle()));\n            } else {\n                compressedValue = data;\n            }\n            if (compressedValue.failed()) {\n                m_compressFail = true;\n                return;\n            }\n            if (compressedValue.value().size() < value.size()) {\n                Super::bindBLOB(compressedValue.value(), info->columnBindIndex);\n                Super::bindInteger(\n                WCDBMergeCompressionType(usingDict ? CompressedType::ZSTDDict :\n                                                     CompressedType::ZSTDNormal,\n                                         ColumnType::Text),\n                info->typeBindIndex);\n            } else {\n                Super::bindText(value, index);\n                if (m_compressionBinder->canCompressNewData()) {\n                    Super::bindInteger(\n                    WCDBMergeCompressionType(CompressedType::None, ColumnType::Text),\n                    info->typeBindIndex);\n                } else {\n                    Super::bindNull(info->typeBindIndex);\n                }\n            }\n        }\n    } else {\n        if (getHandleStatement()->getBindParameterCount() >= index) {\n            Super::bindText(value, index);\n        }\n        if (m_currentStatementType == StatementType::UpdateSTMT\n            && !m_additionalStatements.empty()\n            && m_additionalStatements.front().getBindParameterCount() >= index) {\n            m_additionalStatements.front().bindText(value, index);\n        }\n    }\n}\n\nvoid CompressingStatementDecorator::bindText16(const char16_t* value, size_t valueLength, int index)\n{\n    BindInfo* info = m_bindInfoMap[index];\n    if (info == nullptr) {\n        if (getHandleStatement()->getBindParameterCount() >= index) {\n            Super::bindText16(value, valueLength, index);\n        }\n        if (m_currentStatementType == StatementType::UpdateSTMT\n            && !m_additionalStatements.empty()\n            && m_additionalStatements.front().getBindParameterCount() >= index) {\n            m_additionalStatements.front().bindText16(value, valueLength, index);\n        }\n    } else {\n        bindText(StringView::createFromUTF16(value, valueLength), index);\n    }\n}\n\nvoid CompressingStatementDecorator::bindBLOB(const BLOB& value, int index)\n{\n    BindInfo* info = m_bindInfoMap[index];\n    if (m_bindInfoMap[index] != nullptr) {\n        WCTAssert(index == info->columnBindIndex);\n        if (index == info->matchColumnBindIndex) {\n            getHandle()->notifyError(\n            Error::Code::Misuse,\n            \"\",\n            StringView::formatted(\"Bind blob to compression match column: %s\",\n                                  info->columnInfo->getMatchColumn().data()));\n            m_compressFail = true;\n            return;\n        }\n        if (info->matchColumnBindIndex > 0) {\n            if (!info->bindedValue.isNull()) {\n                Optional<UnsafeData> compressedValue;\n                if (m_compressionBinder->canCompressNewData()) {\n                    compressedValue = CompressionCenter::shared().compressContent(\n                    value,\n                    info->columnInfo->getMatchDictId(info->bindedValue.intValue()),\n                    static_cast<InnerHandle*>(getHandle()));\n                } else {\n                    compressedValue = value;\n                }\n                if (compressedValue.failed()) {\n                    m_compressFail = true;\n                    return;\n                }\n                if (compressedValue.value().size() < value.size()) {\n                    Super::bindBLOB(compressedValue.value(), info->columnBindIndex);\n                    Super::bindInteger(WCDBMergeCompressionType(\n                                       CompressedType::ZSTDDict, ColumnType::BLOB),\n                                       info->typeBindIndex);\n                } else {\n                    Super::bindBLOB(value, index);\n                    if (m_compressionBinder->canCompressNewData()) {\n                        Super::bindInteger(WCDBMergeCompressionType(\n                                           CompressedType::None, ColumnType::BLOB),\n                                           info->typeBindIndex);\n                    } else {\n                        Super::bindNull(info->typeBindIndex);\n                    }\n                }\n            } else {\n                info->bindedValue = value;\n            }\n        } else {\n            bool usingDict\n            = info->columnInfo->getCompressionType() == CompressionType::Dict;\n            Optional<UnsafeData> compressedValue;\n            if (m_compressionBinder->canCompressNewData()) {\n                compressedValue = CompressionCenter::shared().compressContent(\n                value,\n                usingDict ? info->columnInfo->getDictId() : 0,\n                static_cast<InnerHandle*>(getHandle()));\n            } else {\n                compressedValue = value;\n            }\n            if (compressedValue.failed()) {\n                m_compressFail = true;\n                return;\n            }\n            if (compressedValue.value().size() < value.size()) {\n                Super::bindBLOB(compressedValue.value(), info->columnBindIndex);\n                Super::bindInteger(\n                WCDBMergeCompressionType(usingDict ? CompressedType::ZSTDDict :\n                                                     CompressedType::ZSTDNormal,\n                                         ColumnType::BLOB),\n                info->typeBindIndex);\n            } else {\n                Super::bindBLOB(value, index);\n                if (m_compressionBinder->canCompressNewData()) {\n                    Super::bindInteger(\n                    WCDBMergeCompressionType(CompressedType::None, ColumnType::BLOB),\n                    info->typeBindIndex);\n                } else {\n                    Super::bindNull(info->typeBindIndex);\n                }\n            }\n        }\n    } else {\n        if (getHandleStatement()->getBindParameterCount() >= index) {\n            Super::bindBLOB(value, index);\n        }\n        if (m_currentStatementType == StatementType::UpdateSTMT\n            && !m_additionalStatements.empty()\n            && m_additionalStatements.front().getBindParameterCount() >= index) {\n            m_additionalStatements.front().bindBLOB(value, index);\n        }\n    }\n}\n\nvoid CompressingStatementDecorator::bindNull(int index)\n{\n    if (getHandleStatement()->getBindParameterCount() >= index) {\n        Super::bindNull(index);\n    }\n    BindInfo* info = m_bindInfoMap[index];\n    if (info != nullptr) {\n        WCTAssert(index == info->columnBindIndex);\n        if (index == info->matchColumnBindIndex) {\n            getHandle()->notifyError(\n            Error::Code::Misuse,\n            \"\",\n            StringView::formatted(\"Bind null to compression match column: %s\",\n                                  info->columnInfo->getMatchColumn().data()));\n            m_compressFail = true;\n            return;\n        }\n        Super::bindInteger((Integer) CompressedType::None, info->typeBindIndex);\n    } else if (m_currentStatementType == StatementType::UpdateSTMT\n               && !m_additionalStatements.empty()\n               && m_additionalStatements.front().getBindParameterCount() >= index) {\n        m_additionalStatements.front().bindNull();\n    }\n}\n\nvoid CompressingStatementDecorator::bindPointer(void* ptr,\n                                                int index,\n                                                const Text& type,\n                                                void (*destructor)(void*))\n{\n    if (getHandleStatement()->getBindParameterCount() >= index) {\n        Super::bindPointer(ptr, index, type, destructor);\n    }\n    WCTAssert(m_bindInfoMap[index] == nullptr);\n    if (m_currentStatementType == StatementType::UpdateSTMT\n        && !m_additionalStatements.empty()\n        && m_additionalStatements.front().getBindParameterCount() >= index) {\n        m_additionalStatements.front().bindPointer(ptr, index, type, destructor);\n    }\n}\n\n#pragma mark - Process Statement\nbool CompressingStatementDecorator::processInsert(const StatementInsert& insert)\n{\n    const Syntax::InsertSTMT& insertSTMT = insert.syntax();\n    if (insertSTMT.switcher == Syntax::InsertSTMT::Switch::Default) {\n        return Super::prepare(insert);\n    }\n\n    // Get compression info\n    if (!initCompressionTableInfo(insertSTMT.schema, insertSTMT.table)) {\n        return false;\n    }\n\n    // Find compressing column\n    if (m_compressionTableInfo != nullptr) {\n        WCTRemedialAssert(!insertSTMT.isMultiWrite(),\n                          \"Insert statement that contains multiple values is not supported while using compression feature.\",\n                          return false;);\n        for (const auto& compressingColumn : m_compressionTableInfo->getColumnInfos()) {\n            m_bindInfoList.emplace_back();\n            m_bindInfoList.back().columnInfo = &compressingColumn;\n        }\n        int index = 0;\n        for (const auto& column : insertSTMT.columns) {\n            for (auto& bindInfo : m_bindInfoList) {\n                if (bindInfo.columnInfo->getColumn().equal(column.name)) {\n                    bindInfo.columnParaIndex = { index, 0 };\n                } else if (bindInfo.columnInfo->getMatchColumn().equal(column.name)) {\n                    bindInfo.matchColumnParaIndex = { index, 0 };\n                }\n                WCTAssert(!bindInfo.columnInfo->getTypeColumn().equal(column.name));\n            }\n            index++;\n        }\n        for (auto iter = m_bindInfoList.begin(); iter != m_bindInfoList.end();) {\n            if (iter->columnParaIndex.first == -1) {\n                iter = m_bindInfoList.erase(iter);\n            } else {\n                iter++;\n            }\n        }\n    }\n\n    bool needCompress\n    = m_bindInfoList.size() > 0\n      || (m_compressionTableInfo != nullptr && insertSTMT.columns.size() == 0);\n\n    // Skip simple case\n    if (!needCompress && insertSTMT.switcher == Syntax::InsertSTMT::Switch::Values\n        && !insertSTMT.upsertClause.hasValue()\n        && insertSTMT.commonTableExpressions.empty()) {\n        return Super::prepare(insert);\n    }\n\n    StatementInsert newInsert = insert;\n    int maxBindIndex = 0;\n    if (!adaptCompressingColumn(newInsert, &maxBindIndex, m_compressionTableInfo)) {\n        return false;\n    }\n\n    // Check whether data can be compressed directly in the current statement\n    bool directCompress = true;\n    Syntax::InsertSTMT& newInsertSTMT = newInsert.syntax();\n    if (newInsertSTMT.switcher == Syntax::InsertSTMT::Switch::Select\n        || newInsertSTMT.upsertClause.hasValue() || newInsertSTMT.columns.size() == 0\n        || newInsertSTMT.expressionsValues.size() == 0) {\n        directCompress = false;\n    } else {\n        WCTAssert(newInsertSTMT.switcher == Syntax::InsertSTMT::Switch::Values);\n        directCompress\n        = checkBindParametersExist(newInsertSTMT.expressionsValues.front());\n    }\n\n    // Add compression related columns/statements\n    if (directCompress) {\n        for (auto& bindInfo : m_bindInfoList) {\n            m_bindInfoMap.emplace(bindInfo.columnBindIndex, &bindInfo);\n            if (bindInfo.matchColumnBindIndex > 0) {\n                WCTAssert(m_bindInfoMap.find(bindInfo.matchColumnBindIndex)\n                          == m_bindInfoMap.end());\n                m_bindInfoMap.emplace(bindInfo.matchColumnBindIndex, &bindInfo);\n            }\n            // INSERT INTO compressingTable(...columnA,..., columnB, ..., WCDB_CT_columnA, WCDB_CT_columnB, ...) VALUES(...)\n            newInsertSTMT.columns.push_back(Column(bindInfo.columnInfo->getTypeColumn()));\n            newInsertSTMT.expressionsValues.front().push_back(\n            Expression(BindParameter(++maxBindIndex)));\n            bindInfo.typeBindIndex = maxBindIndex;\n            WCTAssert(m_bindInfoMap.find(maxBindIndex) == m_bindInfoMap.end());\n            m_bindInfoMap.emplace(maxBindIndex, &bindInfo);\n        }\n        if (!Super::prepare(newInsert)) {\n            return false;\n        }\n    } else {\n        if (needCompress && newInsertSTMT.upsertClause.hasValue()) {\n            const Syntax::UpsertClause& upsert = insertSTMT.upsertClause.value();\n            Syntax::UpsertClause& newUpsert = newInsertSTMT.upsertClause.value();\n            // Set null to compressed type\n            for (const auto& columns : upsert.columnsList) {\n                for (const auto& column : columns) {\n                    for (const auto& columnInfo : m_compressionTableInfo->getColumnInfos()) {\n                        if (column.name.equal(columnInfo.getColumn())) {\n                            newUpsert.columnsList.push_back(\n                            { Column(columnInfo.getTypeColumn()) });\n                            newUpsert.expressions.push_back(Expression(nullptr));\n                            break;\n                        }\n                    }\n                }\n            }\n        }\n        if (!Super::prepare(newInsert)) {\n            return false;\n        }\n        if (needCompress) {\n            HandleStatement& selectUncompressRow = addNewHandleStatement();\n            if (!selectUncompressRow.prepare(\n                m_compressionTableInfo->getSelectUncompressRowStatement())) {\n                return false;\n            }\n            HandleStatement& updateUncompressRow = addNewHandleStatement();\n            if (!updateUncompressRow.prepare(\n                m_compressionTableInfo->getUpdateCompressColumnStatement())) {\n                return false;\n            }\n        }\n    }\n    return true;\n}\n\nbool CompressingStatementDecorator::processUpdate(const StatementUpdate& update)\n{\n    const Syntax::UpdateSTMT& updateSTMT = update.syntax();\n\n    // Get compression info\n    if (!initCompressionTableInfo(updateSTMT.table.schema, updateSTMT.table.table)) {\n        return false;\n    }\n\n    // Find compressing column\n    if (m_compressionTableInfo != nullptr) {\n        for (const auto& compressingColumn : m_compressionTableInfo->getColumnInfos()) {\n            m_bindInfoList.emplace_back();\n            m_bindInfoList.back().columnInfo = &compressingColumn;\n        }\n        int i = 0;\n        for (const auto& columns : updateSTMT.columnsList) {\n            int j = 0;\n            for (const auto& column : columns) {\n                for (auto& bindInfo : m_bindInfoList) {\n                    if (bindInfo.columnInfo->getColumn().equal(column.name)) {\n                        bindInfo.columnParaIndex = { i, j };\n                    } else if (bindInfo.columnInfo->getMatchColumn().equal(\n                               column.name)) {\n                        bindInfo.matchColumnParaIndex = { i, j };\n                    }\n                    WCTAssert(!bindInfo.columnInfo->getTypeColumn().equal(column.name));\n                }\n                j++;\n            }\n            i++;\n        }\n        for (auto iter = m_bindInfoList.begin(); iter != m_bindInfoList.end();) {\n            if (iter->columnParaIndex.first == -1) {\n                iter = m_bindInfoList.erase(iter);\n            } else {\n                m_compressingUpdateColumns.push_back(iter->columnInfo);\n                iter++;\n            }\n        }\n    }\n\n    StatementUpdate newUpdate = update;\n    int maxBindIndex = 0;\n    if (!adaptCompressingColumn(newUpdate, &maxBindIndex, m_compressionTableInfo)) {\n        return false;\n    }\n\n    // Check whether data can be compressed directly in the current statement\n    Syntax::UpdateSTMT& newUpdateSTMT = newUpdate.syntax();\n    bool directCompress = checkBindParametersExist(newUpdateSTMT.expressions);\n\n    // Add compression related columns/statements\n    if (directCompress) {\n        for (auto& bindInfo : m_bindInfoList) {\n            m_bindInfoMap.emplace(bindInfo.columnBindIndex, &bindInfo);\n            if (bindInfo.matchColumnBindIndex > 0) {\n                WCTAssert(m_bindInfoMap.find(bindInfo.matchColumnBindIndex)\n                          == m_bindInfoMap.end());\n                m_bindInfoMap.emplace(bindInfo.matchColumnBindIndex, &bindInfo);\n            }\n            newUpdateSTMT.columnsList.push_back(\n            { Column(bindInfo.columnInfo->getTypeColumn()) });\n            newUpdateSTMT.expressions.push_back(Expression(BindParameter(++maxBindIndex)));\n            bindInfo.typeBindIndex = maxBindIndex;\n            WCTAssert(m_bindInfoMap.find(maxBindIndex) == m_bindInfoMap.end());\n            m_bindInfoMap.emplace(maxBindIndex, &bindInfo);\n        }\n        if (!Super::prepare(newUpdate)) {\n            return false;\n        }\n    } else {\n        if (m_bindInfoList.empty()) {\n            if (!Super::prepare(newUpdate)) {\n                return false;\n            }\n        } else {\n            // SELECT rowid[, dictMatchTypeColumn] FROM compressingTable WHERE ... ORDER BY ... LIMIT ... OFFSET ...\n            StatementSelect selectRowid\n            = StatementSelect().select(Column::rowid()).from(newUpdateSTMT.table.table);\n            selectRowid.syntax().select.getOrCreate().condition = newUpdateSTMT.condition;\n\n            selectRowid.syntax().orderingTerms = newUpdateSTMT.orderingTerms;\n            newUpdateSTMT.orderingTerms.clear();\n\n            selectRowid.syntax().limitParameterType = newUpdateSTMT.limitParameterType;\n            newUpdateSTMT.limitParameterType = Syntax::LimitParameterType::NotSet;\n            selectRowid.syntax().limit = newUpdateSTMT.limit;\n            newUpdateSTMT.limit = NullOpt;\n            selectRowid.syntax().limitParameter = newUpdateSTMT.limitParameter;\n            newUpdateSTMT.limitParameter = NullOpt;\n\n            bool selectMatchType = true;\n            for (auto& bindInfo : m_bindInfoList) {\n                if (bindInfo.columnBindIndex == 0) {\n                    selectMatchType = false;\n                    break;\n                }\n                if (bindInfo.columnInfo->getCompressionType() != CompressionType::VariousDict) {\n                    continue;\n                }\n                if (bindInfo.matchColumnParaIndex.first >= 0) {\n                    selectMatchType = false;\n                    break;\n                }\n            }\n\n            if (selectMatchType) {\n                for (auto& bindInfo : m_bindInfoList) {\n                    m_bindInfoMap.emplace(bindInfo.columnBindIndex, &bindInfo);\n                    if (bindInfo.matchColumnBindIndex > 0) {\n                        WCTAssert(m_bindInfoMap.find(bindInfo.matchColumnBindIndex)\n                                  == m_bindInfoMap.end());\n                        m_bindInfoMap.emplace(bindInfo.matchColumnBindIndex, &bindInfo);\n                    } else if (bindInfo.columnInfo->getCompressionType()\n                               == CompressionType::VariousDict) {\n                        selectRowid.syntax().select.getOrCreate().resultColumns.push_back(\n                        ResultColumn(Column(bindInfo.columnInfo->getMatchColumn())));\n                        bindInfo.matchColumnBindIndex = SelectedMatchValueBindIndex;\n                        m_bindInfoMap.emplace(bindInfo.matchColumnBindIndex, &bindInfo);\n                    }\n                    newUpdateSTMT.columnsList.push_back(\n                    { Column(bindInfo.columnInfo->getTypeColumn()) });\n                    newUpdateSTMT.expressions.push_back(\n                    Expression(BindParameter(++maxBindIndex)));\n                    bindInfo.typeBindIndex = maxBindIndex;\n                    WCTAssert(m_bindInfoMap.find(maxBindIndex) == m_bindInfoMap.end());\n                    m_bindInfoMap.emplace(maxBindIndex, &bindInfo);\n                }\n            } else {\n                // Set null to compressed type\n                for (auto& bindInfo : m_bindInfoList) {\n                    newUpdateSTMT.columnsList.push_back(\n                    { Column(bindInfo.columnInfo->getTypeColumn()) });\n                    newUpdateSTMT.expressions.push_back(Expression(nullptr));\n                }\n            }\n\n            //Rowid must be binded to the largest index\n            newUpdate.where(Column::rowid() == BindParameter(++maxBindIndex));\n\n            HandleStatement& selectRowidSTMT = addNewHandleStatement();\n            if (!selectRowidSTMT.prepare(selectRowid)) {\n                return false;\n            }\n\n            if (!Super::prepare(newUpdate)) {\n                return false;\n            }\n\n            if (!selectMatchType) {\n                HandleStatement& selectUncompressRow = addNewHandleStatement();\n                if (!selectUncompressRow.prepare(m_compressionTableInfo->getSelectUncompressRowStatement(\n                    &m_compressingUpdateColumns))) {\n                    return false;\n                }\n\n                HandleStatement& updateUncompressRow = addNewHandleStatement();\n                if (!updateUncompressRow.prepare(m_compressionTableInfo->getUpdateCompressColumnStatement(\n                    &m_compressingUpdateColumns))) {\n                    return false;\n                }\n            }\n        }\n    }\n    return true;\n}\n\nbool CompressingStatementDecorator::checkBindParametersExist(std::list<Syntax::Expression>& exps)\n{\n    bool ret = true;\n    for (auto& bindInfo : m_bindInfoList) {\n        //Check column value\n        auto bindIndex = getBindParameter(exps, bindInfo.columnParaIndex);\n        if (bindIndex.failed()) {\n            ret = false;\n            continue;\n        }\n        bindInfo.columnBindIndex = bindIndex.value();\n        // Check match column value\n        if (bindInfo.matchColumnParaIndex.first < 0) {\n            if (bindInfo.columnInfo->getCompressionType() == CompressionType::VariousDict) {\n                ret = false;\n            }\n            continue;\n        }\n        bindIndex = getBindParameter(exps, bindInfo.matchColumnParaIndex);\n        if (bindIndex.failed()) {\n            ret = false;\n            continue;\n        }\n        bindInfo.matchColumnBindIndex = bindIndex.value();\n    }\n    return ret;\n}\n\nOptional<int>\nCompressingStatementDecorator::getBindParameter(std::list<Syntax::Expression>& exps,\n                                                std::pair<int, int>& index)\n{\n    if (exps.size() <= index.first) {\n        return NullOpt;\n    }\n    auto iter = exps.begin();\n    std::advance(iter, index.first);\n    if (index.second > 0) {\n        if (iter->switcher != Syntax::Expression::Switch::Expressions\n            || iter->expressions.size() <= index.second) {\n            return NullOpt;\n        }\n        iter = iter->expressions.begin();\n        std::advance(iter, index.second);\n    }\n    if (iter->switcher != Syntax::Expression::Switch::BindParameter\n        || iter->bindParameter().switcher != Syntax::BindParameter::Switch::QuestionSign) {\n        return NullOpt;\n    } else {\n        return iter->bindParameter().n;\n    }\n}\n\nHandleStatement& CompressingStatementDecorator::addNewHandleStatement()\n{\n    m_additionalStatements.emplace_back(getHandle());\n    m_additionalStatements.back().enableAutoAddColumn();\n    return m_additionalStatements.back();\n}\n\nbool CompressingStatementDecorator::processSelect(const StatementSelect& select)\n{\n    StatementSelect newSelect = select;\n    if (!adaptCompressingColumn(newSelect)) {\n        return false;\n    }\n    return Super::prepare(newSelect);\n}\n\nbool CompressingStatementDecorator::processDelete(const StatementDelete& delete_)\n{\n    const Syntax::DeleteSTMT& deleteSTMT = delete_.syntax();\n\n    // Get compression info\n    if (!initCompressionTableInfo(deleteSTMT.table.schema, deleteSTMT.table.table)) {\n        return false;\n    }\n    StatementDelete newDelete = delete_;\n    if (!adaptCompressingColumn(newDelete, nullptr, m_compressionTableInfo)) {\n        return false;\n    }\n    return Super::prepare(newDelete);\n}\n\nbool CompressingStatementDecorator::processCreateTable(const StatementCreateTable& createTable)\n{\n    if (!createTable.syntax().schema.isMain()) {\n        return Super::prepare(createTable);\n    }\n    auto compressingColumns = m_compressionBinder->tryGetCompressingColumnsForNewTable(\n    createTable.syntax().table);\n    if (compressingColumns.failed()) {\n        return false;\n    }\n    if (compressingColumns.value().size() == 0) {\n        return Super::prepare(createTable);\n    }\n    StatementCreateTable newStatement = createTable;\n    for (auto columnInfo : compressingColumns.value()) {\n        newStatement.define(ColumnDef(columnInfo.getTypeColumn(), ColumnType::Integer)\n                            .constraint(ColumnConstraint().default_(nullptr)));\n    }\n    return Super::prepare(newStatement);\n}\n\nbool CompressingStatementDecorator::processCreateView(const StatementCreateView& createView)\n{\n    StatementCreateView newStatement = createView;\n    if (!adaptCompressingColumn(newStatement)) {\n        return false;\n    }\n    return Super::prepare(newStatement);\n}\n\nbool CompressingStatementDecorator::processDropTable(const StatementDropTable& dropTable)\n{\n    if (!Super::prepare(dropTable)) {\n        return false;\n    }\n    if (!dropTable.syntax().schema.isMain()) {\n        return true;\n    }\n    HandleStatement& newStatement = addNewHandleStatement();\n    if (!newStatement.prepare(\n        CompressionRecord::getDeleteRecordStatement(dropTable.syntax().table))) {\n        if (getHandle()->getError().code() == Error::Code::Error\n            && getHandle()->getError().getMessage().hasPrefix(\"no such table:\")) {\n            m_additionalStatements.pop_back();\n        } else {\n            return false;\n        }\n    }\n    return true;\n}\n\nbool CompressingStatementDecorator::processAlterTable(const StatementAlterTable& alterTable)\n{\n    if (alterTable.syntax().switcher == Syntax::AlterTableSTMT::Switch::AddColumn) {\n        return Super::prepare(alterTable);\n    }\n    // Get compression info\n    if (!initCompressionTableInfo(alterTable.syntax().schema,\n                                  alterTable.syntax().table)) {\n        return false;\n    }\n\n    if (m_compressionTableInfo == nullptr) {\n        return Super::prepare(alterTable);\n    }\n    if (alterTable.syntax().switcher == Syntax::AlterTableSTMT::Switch::RenameColumn) {\n        getHandle()->notifyError(\n        Error::Code::Misuse,\n        alterTable.getDescription(),\n        \"Modifying the column name of a compressing table is not supported.\");\n        return false;\n    }\n\n    WCTAssert(alterTable.syntax().switcher == Syntax::AlterTableSTMT::Switch::RenameTable);\n\n    if (!Super::prepare(alterTable)) {\n        return false;\n    }\n\n    HandleStatement& newStatement = addNewHandleStatement();\n    auto updateRecord = CompressionRecord::getUpdateRecordStatement(\n    alterTable.syntax().table, alterTable.syntax().newTable);\n    if (!newStatement.prepare(updateRecord)) {\n        if (getHandle()->getError().getMessage().hasPrefix(\"no such table:\")) {\n            m_additionalStatements.clear();\n            return true;\n        }\n        return false;\n    }\n    return true;\n}\n\nbool CompressingStatementDecorator::initCompressionTableInfo(const Syntax::Schema& schema,\n                                                             const UnsafeStringView& table)\n{\n    if (schema.isMain()) {\n        auto optionalTableInfo = m_compressionBinder->tryGetCompressionInfo(table);\n        if (optionalTableInfo.failed()) {\n            return false;\n        }\n        m_compressionTableInfo = optionalTableInfo.value();\n    }\n    return true;\n}\n\n/*\n Adapt compresssing columns in expression to decompress function.\n Eg:\n    SELECT compresssingColumnA From compressingTable\n will be changed to\n    SELECT wcdb_decompress(compresssingColumnA, WCDB_CT_compresssingColumnA) From compressingTable\n */\nbool CompressingStatementDecorator::adaptCompressingColumn(Statement& statement,\n                                                           int* maxBindIndex,\n                                                           const CompressionTableInfo* curInfo)\n{\n    std::list<TableInfos> tableInfoStack;\n    if (curInfo != nullptr) {\n        tableInfoStack.emplace_back();\n        tableInfoStack.back().insert_or_assign(curInfo->getTable(), curInfo);\n    }\n    bool succeed = true;\n    std::unordered_map<Syntax::Expression*, const CompressionColumnInfo*> compressingColumns;\n    statement.iterate([&](Syntax::Identifier& identifier, bool isBegin, bool& stop) {\n        if (identifier.getType() == StatementType::SelectSTMT) {\n            if (!isBegin) {\n                tableInfoStack.pop_back();\n                return;\n            }\n            tableInfoStack.emplace_back();\n            TableInfos& tableInfos = tableInfoStack.back();\n            Syntax::SelectSTMT& selectSTMT = (Syntax::SelectSTMT&) identifier;\n            if (selectSTMT.select.hasValue()\n                && selectSTMT.select.value().switcher != Syntax::SelectCore::Switch::Values\n                && !parseTable(selectSTMT.select.value().tableOrSubqueries, tableInfos)) {\n                succeed = false;\n                stop = true;\n                return;\n            }\n            for (const auto& selectCore : selectSTMT.cores) {\n                if (selectCore.switcher != Syntax::SelectCore::Switch::Values\n                    && !parseTable(selectCore.tableOrSubqueries, tableInfos)) {\n                    succeed = false;\n                    stop = true;\n                    return;\n                }\n            }\n        } else if (identifier.getType() == StatementType::SelectCore) {\n            if (!isBegin) {\n                tableInfoStack.pop_back();\n                return;\n            }\n            Syntax::SelectCore& syntax = (Syntax::SelectCore&) identifier;\n            tableInfoStack.emplace_back();\n            if (syntax.switcher == Syntax::SelectCore::Switch::Values) {\n                return;\n            }\n            TableInfos& tableInfos = tableInfoStack.back();\n            if (!parseTable(syntax.tableOrSubqueries, tableInfos)) {\n                succeed = false;\n                stop = true;\n                return;\n            }\n        } else if (identifier.getType() == StatementType::CommonTableExpression) {\n            if (isBegin) {\n                if (tableInfoStack.size() == 0) {\n                    tableInfoStack.emplace_back();\n                    Syntax::CommonTableExpression& cte\n                    = (Syntax::CommonTableExpression&) identifier;\n                    tableInfoStack.back().insert_or_assign(cte.table, nullptr);\n                }\n                tableInfoStack.emplace_back();\n            } else {\n                tableInfoStack.pop_back();\n            }\n        } else {\n            if (!isBegin && identifier.getType() == Syntax::Identifier::Type::ResultColumn) {\n                Syntax::ResultColumn& resultColumn = (Syntax::ResultColumn&) identifier;\n                auto iter = compressingColumns.find(&resultColumn.expression.value());\n                if (iter != compressingColumns.end()) {\n                    resultColumn.alias = iter->second->getColumn();\n                }\n                return;\n            }\n            if (!isBegin || identifier.getType() != Syntax::Identifier::Type::Expression) {\n                return;\n            }\n            Syntax::Expression& expression = (Syntax::Expression&) identifier;\n            if (expression.switcher == Syntax::Expression::Switch::BindParameter) {\n                if (expression.bindParameter().switcher\n                    != Syntax::BindParameter::Switch::QuestionSign) {\n                    getHandle()->notifyError(\n                    Error::Code::Misuse,\n                    statement.getDescription(),\n                    \"The compressing table only supports numeric type bind parameters.\");\n                    succeed = false;\n                    stop = true;\n                    return;\n                }\n                if (maxBindIndex == nullptr) {\n                    return;\n                }\n                *maxBindIndex = std::max(expression.bindParameter().n, *maxBindIndex);\n            }\n            if (expression.switcher != Syntax::Expression::Switch::Column) {\n                return;\n            }\n            Syntax::Column& column = expression.column();\n            if (!column.schema.isMain()) {\n                return;\n            }\n            if (tableInfoStack.size() == 0) {\n                return;\n            }\n            const CompressionTableInfo* tableInfo = nullptr;\n            if (!column.table.empty()) {\n                auto stackIter = tableInfoStack.end();\n                for (int i = 0; i < tableInfoStack.size(); i++) {\n                    stackIter--;\n                    auto iter = stackIter->find(column.table);\n                    if (iter != stackIter->end()) {\n                        tableInfo = iter->second;\n                        break;\n                    }\n                }\n            } else if (!tableInfoStack.back().empty()) {\n                tableInfo = tableInfoStack.back().begin()->second;\n            }\n            if (tableInfo == nullptr) {\n                return;\n            }\n            for (const auto& compressingColumn : tableInfo->getColumnInfos()) {\n                if (compressingColumn.getColumn().equal(column.name)) {\n                    compressingColumns[&expression] = &compressingColumn;\n                    return;\n                }\n            }\n        }\n    });\n\n    for (auto iter : compressingColumns) {\n        Syntax::Expression& expression = *(iter.first);\n        const CompressionColumnInfo& compressingColumn = *(iter.second);\n        StringView table = expression.column().table;\n        expression = Expression();\n        expression.switcher = Syntax::Expression::Switch::Function;\n        expression.function() = DecompressFunctionName;\n        expression.expressions.push_back(Expression(Column(compressingColumn.getColumn())));\n        expression.expressions.back().column().table = table;\n        expression.expressions.push_back(\n        Expression(Column(compressingColumn.getTypeColumn())));\n        expression.expressions.back().column().table = table;\n        expression.useWildcard = false;\n    }\n\n    return succeed;\n}\n\nbool CompressingStatementDecorator::parseTable(const std::list<Syntax::TableOrSubquery>& tables,\n                                               StringViewMap<const CompressionTableInfo*>& tableInfos)\n{\n    for (const auto& table : tables) {\n        if (table.switcher == Syntax::TableOrSubquery::Switch::Table) {\n            if (!table.schema.isMain()) {\n                return true;\n            }\n            auto tableInfo\n            = m_compressionBinder->tryGetCompressionInfo(table.tableOrFunction);\n            if (!tableInfo.hasValue()) {\n                return false;\n            }\n            tableInfos.insert_or_assign(table.tableOrFunction, tableInfo.value());\n            if (!table.alias.empty()) {\n                tableInfos.insert_or_assign(table.alias, tableInfo.value());\n            }\n            return true;\n        } else if (table.switcher == Syntax::TableOrSubquery::Switch::TableOrSubqueries) {\n            if (!parseTable(table.tableOrSubqueries, tableInfos)) {\n                return false;\n            }\n        } else if (!table.alias.empty()) {\n            tableInfos.insert_or_assign(table.alias, nullptr);\n        }\n    }\n    return true;\n}\n\nvoid CompressingStatementDecorator::resetCompressionStatus()\n{\n    m_compressFail = false;\n    m_compressionTableInfo = nullptr;\n    m_compressingUpdateColumns.clear();\n    m_bindInfoMap.clear();\n    m_bindInfoList.clear();\n}\n\nvoid CompressingStatementDecorator::bindValueInInfo(const BindInfo* info, const Integer& matchValue)\n{\n    UnsafeData data;\n    UnsafeStringView text;\n    ColumnType valueType = info->bindedValue.getType();\n    if (valueType == Value::Type::Text) {\n        text = info->bindedValue.textValue();\n        data = UnsafeData((unsigned char*) text.data(), text.length());\n    } else {\n        data = info->bindedValue.blobValue();\n    }\n    Optional<UnsafeData> compressedValue;\n    if (m_compressionBinder->canCompressNewData()) {\n        compressedValue = CompressionCenter::shared().compressContent(\n        data,\n        info->columnInfo->getMatchDictId(matchValue),\n        static_cast<InnerHandle*>(getHandle()));\n    } else {\n        compressedValue = data;\n    }\n    if (compressedValue.failed()) {\n        m_compressFail = true;\n        return;\n    }\n    if (compressedValue.value().size() < data.size()) {\n        Super::bindBLOB(compressedValue.value(), info->columnBindIndex);\n        Super::bindInteger(WCDBMergeCompressionType(CompressedType::ZSTDDict, valueType),\n                           info->typeBindIndex);\n    } else {\n        if (valueType == Value::Type::Text) {\n            Super::bindText(text, info->columnBindIndex);\n        } else {\n            Super::bindBLOB(data, info->columnBindIndex);\n        }\n        if (m_compressionBinder->canCompressNewData()) {\n            Super::bindInteger(WCDBMergeCompressionType(CompressedType::None, valueType),\n                               info->typeBindIndex);\n        } else {\n            Super::bindNull(info->typeBindIndex);\n        }\n    }\n}\n\n#pragma mark - Step Statement\n\nbool CompressingStatementDecorator::realStep()\n{\n    switch (m_currentStatementType) {\n    case StatementType::InsertSTMT:\n        return stepInsert();\n    case StatementType::UpdateSTMT:\n        return stepUpdate();\n    default: {\n        if (!Super::step()) {\n            return false;\n        }\n        for (auto& handleStatement : m_additionalStatements) {\n            if (!handleStatement.step()) {\n                return false;\n            }\n        }\n        return true;\n    }\n    }\n}\n\nbool CompressingStatementDecorator::stepInsert()\n{\n    if (!Super::step()) {\n        return false;\n    }\n    if (m_additionalStatements.size() == 0) {\n        return true;\n    }\n    AbstractHandle* handle = getHandle();\n    if (handle->getChanges() == 0) {\n        return true;\n    }\n    WCTAssert(m_additionalStatements.size() == 2);\n    auto iter = m_additionalStatements.begin();\n    HandleStatement* select = &(*iter);\n    iter++;\n    HandleStatement* update = &(*iter);\n    return m_compressionTableInfo->stepSelectAndUpdateUncompressRowStatement(\n    select, update, handle->getLastInsertedRowID());\n}\n\nbool CompressingStatementDecorator::stepUpdate()\n{\n    if (m_additionalStatements.empty()) {\n        return Super::step();\n    }\n    WCTAssert(m_compressionTableInfo != nullptr);\n    WCTAssert(m_compressingUpdateColumns.size() > 0);\n    AbstractHandle* handle = getHandle();\n    auto iter = m_additionalStatements.begin();\n    HandleStatement* selectRowid = &(*iter);\n    iter++;\n\n    HandleStatement* selectValue = nullptr;\n    HandleStatement* updateValue = nullptr;\n    bool needSelectValue = m_additionalStatements.size() > 1;\n    if (needSelectValue) {\n        WCTAssert(m_additionalStatements.size() == 3) selectValue = &(*iter);\n        iter++;\n        updateValue = &(*iter);\n    }\n\n    int rowidIndex = getHandleStatement()->getBindParameterCount();\n    if (!selectRowid->step()) {\n        return false;\n    }\n    while (!selectRowid->done()) {\n        int64_t rowid = selectRowid->getInteger();\n        Super::reset();\n        Super::bindInteger(rowid, rowidIndex);\n        if (!needSelectValue) {\n            int index = 0;\n            for (const auto& bindInfo : m_bindInfoList) {\n                if (bindInfo.matchColumnBindIndex != SelectedMatchValueBindIndex) {\n                    continue;\n                }\n                index++;\n                if (bindInfo.bindedValue.isNull()) {\n                    continue;\n                }\n                bindValueInInfo(&bindInfo, selectRowid->getValue(index));\n            }\n        }\n        if (!Super::step()) {\n            return false;\n        }\n        if (needSelectValue && handle->getChanges() > 0\n            && !m_compressionTableInfo->stepSelectAndUpdateUncompressRowStatement(\n            selectValue, updateValue, rowid, &m_compressingUpdateColumns)) {\n            return false;\n        }\n        if (!selectRowid->step()) {\n            return false;\n        }\n    }\n    return true;\n}\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/common/core/compression/CompressingStatementDecorator.hpp",
    "content": "//\n// Created by qiuwenchen on 2023/11/28.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"Compression.hpp\"\n#include \"DecorativeHandleStatement.hpp\"\n#include <limits.h>\n#include <list>\n#include <unordered_map>\n\nnamespace WCDB {\n\nclass CompressingStatementDecorator final : public HandleStatementDecorator {\n#pragma mark - Basic\npublic:\n    CompressingStatementDecorator(Compression::Binder *binder);\n    CompressingStatementDecorator(CompressingStatementDecorator &&other);\n    ~CompressingStatementDecorator() override;\n\n    CompressingStatementDecorator() = delete;\n    CompressingStatementDecorator(const CompressingStatementDecorator &) = delete;\n    CompressingStatementDecorator &operator=(const CompressingStatementDecorator &) = delete;\n\n    void decorate(Decorative *handleStatement) override final;\n\nprotected:\n    using Super = HandleStatementDecorator;\n\nprivate:\n    Compression::Binder *m_compressionBinder;\n\n#pragma mark - Decorated functions\npublic:\n    bool prepare(const Statement &statement) override final;\n    void finalize() override final;\n    bool step() override final;\n    void reset() override final;\n    void clearBindings() override final;\n\n    void bindInteger(const Integer &value, int index) override final;\n    void bindDouble(const Float &value, int index) override final;\n    void bindText(const Text &value, int index) override final;\n    void bindText16(const char16_t *value, size_t valueLength, int index) override final;\n    void bindBLOB(const BLOB &value, int index) override final;\n    void bindNull(int index) override final;\n    void bindPointer(void *ptr, int index, const Text &type, void (*destructor)(void *)) override final;\n\n#pragma mark - Process Statement\nprotected:\n    bool processInsert(const StatementInsert &insert);\n    bool processUpdate(const StatementUpdate &update);\n    bool processSelect(const StatementSelect &select);\n    bool processDelete(const StatementDelete &delete_);\n\n    bool processCreateTable(const StatementCreateTable &createTable);\n    bool processCreateView(const StatementCreateView &createView);\n    bool processDropTable(const StatementDropTable &dropTable);\n    bool processAlterTable(const StatementAlterTable &alterTable);\n\n    bool initCompressionTableInfo(const Syntax::Schema &schema, const UnsafeStringView &table);\n    bool adaptCompressingColumn(Statement &statement,\n                                int *maxBindIndex = nullptr,\n                                const CompressionTableInfo *curInfo = nullptr);\n    typedef StringViewMap<const CompressionTableInfo *> TableInfos;\n    bool parseTable(const std::list<Syntax::TableOrSubquery> &tables, TableInfos &tableInfos);\n    bool checkBindParametersExist(std::list<Syntax::Expression> &exps);\n    Optional<int>\n    getBindParameter(std::list<Syntax::Expression> &exps, std::pair<int, int> &index);\n    HandleStatement &addNewHandleStatement();\n\n    void resetCompressionStatus();\n\n    typedef struct BindInfo {\n        std::pair<int, int> columnParaIndex = { -1, -1 };\n        std::pair<int, int> matchColumnParaIndex = { -1, -1 };\n        int columnBindIndex = 0;\n        int typeBindIndex = 0;\n        int matchColumnBindIndex = 0;\n        Value bindedValue;\n        const CompressionColumnInfo *columnInfo = nullptr;\n    } BindInfo;\n\n    static const int SelectedMatchValueBindIndex = INT_MAX;\n    void bindValueInInfo(const BindInfo *bindInfo, const Integer &matchValue);\n\n    using StatementType = Syntax::Identifier::Type;\n    StatementType m_currentStatementType;\n    bool m_processing;\n    bool m_compressFail;\n    const CompressionTableInfo *m_compressionTableInfo;\n    std::list<const CompressionColumnInfo *> m_compressingUpdateColumns;\n    std::list<BindInfo> m_bindInfoList;\n    std::unordered_map<int, BindInfo *> m_bindInfoMap;\n    std::list<HandleStatement> m_additionalStatements;\n\n#pragma mark - Step Statement\nprotected:\n    bool realStep();\n    bool stepInsert();\n    bool stepUpdate();\n};\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/core/compression/Compression.cpp",
    "content": "//\n// Created by qiuwenchen on 2023/11/21.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"Compression.hpp\"\n#include \"Assertion.hpp\"\n#include \"CompressionConst.hpp\"\n#include \"CompressionRecord.hpp\"\n#include \"InnerHandle.hpp\"\n#include \"Notifier.hpp\"\n#include \"WCDBError.hpp\"\n\nnamespace WCDB {\n\nCompressionEvent::~CompressionEvent() = default;\n\n#pragma mark - Initialize\nCompression::Compression(CompressionEvent* event)\n: m_dataVersion(0)\n, m_hasCreatedRecord(false)\n, m_canCompressNewData(true)\n, m_tableAcquired(false)\n, m_compressed(false)\n, m_event(event)\n{\n}\n\nvoid Compression::setTableFilter(const TableFilter& tableFilter)\n{\n    LockGuard lockGuard(m_lock);\n    m_tableFilter = tableFilter;\n    purge();\n}\n\nbool Compression::shouldCompress() const\n{\n    SharedLockGuard lockGuard(m_lock);\n    return m_tableFilter != nullptr;\n}\n\nvoid Compression::purge()\n{\n    LockGuard lockGuard(m_lock);\n    m_hasCreatedRecord = false;\n    m_tableAcquired = false;\n    m_compressed = false;\n    m_compressings.clear();\n    m_holder.clear();\n    m_hints.clear();\n    m_filted.clear();\n    // Invalidate all thread local data.\n    m_dataVersion++;\n}\n\nvoid Compression::tryResetLocalStatus()\n{\n    if (m_localDataVersion.getOrCreate() == m_dataVersion) {\n        return;\n    }\n    m_localFilted.getOrCreate().clear();\n    m_commitingTables.getOrCreate().clear();\n    m_localDataVersion.getOrCreate() = m_dataVersion;\n}\n\nbool Compression::initInfo(InfoInitializer& initializer, const UnsafeStringView& table)\n{\n    // do not migrate sqlite builtin table\n    if (table.hasPrefix(Syntax::builtinTablePrefix)\n        || table.hasPrefix(Syntax::builtinWCDBTablePrefix)) {\n        markAsNoNeedToCompress(table);\n        return true;\n    }\n    StringView targetTable = StringView(table);\n    bool hasFiltered = false;\n    CompressionTableUserInfo userInfo(targetTable);\n    TableFilter filter;\n    {\n        SharedLockGuard lockGuard(m_lock);\n        filter = m_tableFilter;\n        auto iter = m_hints.find(targetTable);\n        if (iter != m_hints.end()) {\n            hasFiltered = true;\n            userInfo = iter->second;\n        }\n    }\n    if (!hasFiltered) {\n        if (filter != nullptr) {\n            filter(userInfo);\n        }\n        if (!userInfo.shouldCompress()) {\n            markAsNoNeedToCompress(table);\n            return true;\n        }\n    }\n\n    auto tableExist = initializer.tableExist(userInfo.getTable());\n    if (tableExist.failed()) {\n        return false;\n    }\n\n    if (!tryCreateRecordTable(initializer)) {\n        return false;\n    }\n\n    LockGuard lockGuard(m_lock);\n    auto iter = m_filted.find(targetTable);\n    if (iter == m_filted.end()) {\n        m_compressed = false;\n        if (!tableExist.value()) {\n            // it's not created\n            if (!hasFiltered) {\n                m_hints.emplace(\n                std::piecewise_construct,\n                std::forward_as_tuple(targetTable),\n                std::forward_as_tuple(targetTable, userInfo.getColumnInfos()));\n                m_tableAcquired = false;\n            }\n        } else {\n            WCTAssert(userInfo.shouldCompress());\n            m_holder.emplace_back(userInfo);\n            const CompressionTableInfo* hold = &m_holder.back();\n            m_filted.insert_or_assign(targetTable, hold);\n            m_hints.erase(targetTable);\n        }\n    } else {\n        iter->second->setNeedCheckColumns(true);\n    }\n    return true;\n}\n\nvoid Compression::markAsNoNeedToCompress(const UnsafeStringView& table)\n{\n    LockGuard lockGuard(m_lock);\n    if (m_filted.find(table) == m_filted.end()) {\n        m_filted.insert_or_assign(table, nullptr);\n    }\n    m_hints.erase(table);\n}\n\nOptional<std::list<CompressionColumnInfo>>\nCompression::tryGetCompressingColumnsForNewTable(InfoInitializer& initializer,\n                                                 const UnsafeStringView& table)\n{\n    if (!initInfo(initializer, table)) {\n        return NullOpt;\n    }\n    SharedLockGuard lockGuard(m_lock);\n    auto iter = m_hints.find(table);\n    if (iter != m_hints.end()) {\n        return iter->second.getColumnInfos();\n    }\n    return std::list<CompressionColumnInfo>();\n}\n\nvoid Compression::markAsCompressed(const CompressionTableInfo* info)\n{\n    {\n        LockGuard lockGuard(m_lock);\n        WCTAssert(info != nullptr);\n        WCTAssert(m_filted.find(info->getTable()) != m_filted.end());\n        WCTAssert(m_hints.find(info->getTable()) == m_hints.end());\n        WCTAssert(m_compressings.find(info) != m_compressings.end());\n        m_compressings.erase(info);\n    }\n    if (m_event != nullptr) {\n        m_event->didCompress(info);\n    }\n}\n\nOptional<const CompressionTableInfo*> Compression::getInfo(const UnsafeStringView& table)\n{\n    tryResetLocalStatus();\n    auto localFilted = m_localFilted.getOrCreate();\n    auto localIter = localFilted.find(table);\n    if (localIter != localFilted.end()) {\n        return localIter->second;\n    }\n    SharedLockGuard lockGuard(m_lock);\n    auto iter = m_filted.find(table);\n    if (iter != m_filted.end()) {\n        localFilted.insert_or_assign(iter->first, iter->second);\n        return iter->second;\n    }\n    return NullOpt;\n}\n\nOptional<const CompressionTableInfo*>\nCompression::getOrInitInfo(InfoInitializer& initializer, const UnsafeStringView& table)\n{\n    auto info = getInfo(table);\n    if (!info.succeed() && initInfo(initializer, table)) {\n        info = getInfo(table);\n    }\n    if (info.valueOr(nullptr) != nullptr\n        && !checkCompressingColumn(initializer, info.value())) {\n        return NullOpt;\n    }\n    return info;\n}\n\nbool Compression::tryFixCompressingColumn(InfoInitializer& initializer,\n                                          const UnsafeStringView& table)\n{\n    auto info = getInfo(table);\n    if (!info.succeed() || info.value() == nullptr) {\n        return false;\n    }\n    auto compressingInfo = info.value();\n    if (compressingInfo->needCheckColumns()) {\n        return false;\n    }\n    compressingInfo->setNeedCheckColumns(true);\n    return checkCompressingColumn(initializer, compressingInfo);\n}\n\nbool Compression::checkCompressingColumn(InfoInitializer& initializer,\n                                         const CompressionTableInfo* info)\n{\n    if (!info->needCheckColumns()) {\n        return true;\n    }\n    InnerHandle* handle = initializer.getCurrentHandle();\n    auto addColumn = initializer.checkCompressingColumns(*info);\n    if (addColumn.failed()) {\n        return false;\n    }\n    info->setNeedCheckColumns(false);\n    if (addColumn.value() && handle->isInTransaction()) {\n        tryResetLocalStatus();\n        m_commitingTables.getOrCreate().insert(info);\n    }\n    return true;\n}\n\nvoid Compression::notifyTransactionCommitted(bool committed)\n{\n    tryResetLocalStatus();\n    if (!committed) {\n        for (auto tableInfo : m_commitingTables.getOrCreate()) {\n            tableInfo->setNeedCheckColumns(true);\n        }\n        if (m_localHasCreatedRecord.getOrCreate()) {\n            m_hasCreatedRecord = false;\n        }\n    }\n    m_localHasCreatedRecord.getOrCreate() = false;\n    m_commitingTables.getOrCreate().clear();\n}\n\nbool Compression::tryCreateRecordTable(InfoInitializer& initializer)\n{\n    if (m_hasCreatedRecord) {\n        return true;\n    }\n    auto exist = initializer.tableExist(CompressionRecord::tableName);\n    if (exist.failed()) {\n        return false;\n    }\n    if (exist.value()) {\n        m_hasCreatedRecord = true;\n        return true;\n    }\n    InnerHandle* handle = initializer.getCurrentHandle();\n    WCTAssert(handle != nullptr);\n    HandleStatement createTable(handle);\n    if (!createTable.prepare(CompressionRecord::getCreateTableStatement())) {\n        return false;\n    }\n    bool created = createTable.step();\n    createTable.finalize();\n    if (!created) {\n        return false;\n    }\n    m_hasCreatedRecord = true;\n    if (handle->isInTransaction()) {\n        m_localHasCreatedRecord.getOrCreate() = true;\n    }\n    return true;\n}\n\n#pragma mark - InfoInitializer\nCompression::InfoInitializer::~InfoInitializer() = default;\n\nOptional<bool> Compression::InfoInitializer::tableExist(const UnsafeStringView& table)\n{\n    InnerHandle* handle = getCurrentHandle();\n    WCTAssert(handle != nullptr);\n    return handle->tableExists(Schema::main(), table);\n}\n\nOptional<bool>\nCompression::InfoInitializer::checkCompressingColumns(const CompressionTableInfo& info)\n{\n    auto& compressingColumns = info.getColumnInfos();\n    const StringView& tableName = info.getTable();\n    InnerHandle* handle = getCurrentHandle();\n    WCTAssert(handle != nullptr);\n    auto optionalMetas = handle->getTableMeta(Schema::main(), tableName);\n    if (!optionalMetas.succeed()) {\n        return NullOpt;\n    }\n    auto& metas = optionalMetas.value();\n    std::list<StringView> curColumns;\n    for (const auto& meta : metas) {\n        curColumns.push_back(meta.name);\n    }\n    auto tableConfig = handle->getTableAttribute(Schema::main(), tableName);\n    if (!tableConfig.succeed()) {\n        return NullOpt;\n    }\n    if (tableConfig.value().withoutRowid) {\n        StringView msg = StringView::formatted(\n        \"Does not support to compress data in the table without rowid: %s\",\n        tableName.data());\n        handle->notifyError(Error::Code::Misuse, nullptr, msg);\n        return NullOpt;\n    }\n    uint16_t newColumnIndex = (uint16_t) curColumns.size();\n    for (auto& compressingColumn : compressingColumns) {\n        uint16_t columnIndex = 0;\n        bool findTypeColumn = false;\n        for (const auto& column : curColumns) {\n            if (column.equal(compressingColumn.getColumn())) {\n                compressingColumn.setColumnIndex(columnIndex);\n            } else if (column.equal(compressingColumn.getTypeColumn())) {\n                compressingColumn.setTypeColumnIndex(columnIndex);\n                findTypeColumn = true;\n            } else if (column.equal(compressingColumn.getMatchColumn())) {\n                compressingColumn.setMatchColumnIndex(columnIndex);\n            }\n            columnIndex++;\n        }\n        if (!findTypeColumn) {\n            if (!handle->addColumn(\n                Schema::main(),\n                tableName,\n                ColumnDef(compressingColumn.getTypeColumn(), ColumnType::Integer)\n                .constraint(ColumnConstraint().default_(nullptr)))) {\n                return NullOpt;\n            }\n            compressingColumn.setTypeColumnIndex(newColumnIndex);\n            newColumnIndex++;\n        }\n    }\n    if (newColumnIndex != curColumns.size()) {\n        return true;\n    }\n    return false;\n}\n\nCompression::Binder::Binder(Compression& compression)\n: m_compression(compression)\n{\n}\n\nCompression::Binder::~Binder() = default;\n\nOptional<std::list<CompressionColumnInfo>>\nCompression::Binder::tryGetCompressingColumnsForNewTable(const UnsafeStringView& table)\n{\n    return m_compression.tryGetCompressingColumnsForNewTable(*this, table);\n}\n\nvoid Compression::Binder::notifyTransactionCommitted(bool committed)\n{\n    m_compression.notifyTransactionCommitted(committed);\n}\n\nOptional<const CompressionTableInfo*>\nCompression::Binder::tryGetCompressionInfo(const UnsafeStringView& table)\n{\n    return m_compression.getOrInitInfo(*this, table);\n}\n\nbool Compression::Binder::tryFixCompressingColumn(const UnsafeStringView& table)\n{\n    return m_compression.tryFixCompressingColumn(*this, table);\n}\n\nbool Compression::Binder::canCompressNewData() const\n{\n    return m_compression.canCompressNewData();\n}\n\nbool Compression::canCompressNewData() const\n{\n    return m_canCompressNewData;\n}\n\nvoid Compression::setCanCompressNewData(bool canCompress)\n{\n    m_canCompressNewData = canCompress;\n}\n\n#pragma mark - Step\nCompression::Stepper::~Stepper() = default;\n\nOptional<bool> Compression::step(Compression::Stepper& stepper)\n{\n    auto worked = tryCompressRows(stepper);\n    if (!worked.succeed()) {\n        return NullOpt;\n    }\n    if (worked.value()) {\n        return false;\n    }\n    // acquire table is a readonly operation.\n    // retry if and only if it works.\n    worked = tryAcquireTables(stepper);\n    if (!worked.succeed()) {\n        return NullOpt;\n    }\n    if (worked.value()) {\n        return step(stepper);\n    }\n    LockGuard lockGuard(m_lock);\n    WCTAssert(m_tableAcquired);\n    WCTAssert(m_compressings.empty());\n    WCTAssert(m_hints.empty());\n    m_compressed = true;\n    if (m_event != nullptr) {\n        m_event->didCompress(nullptr);\n    }\n    return true;\n}\n\nbool Compression::rollbackCompression(Compression::Stepper& stepper)\n{\n    clearProgress();\n    auto worked = tryAcquireTables(stepper);\n    if (!worked.succeed()) {\n        return false;\n    }\n    std::set<const CompressionTableInfo*> needRevertInfos;\n    {\n        SharedLockGuard lockGuard(m_lock);\n        for (auto iter = m_filted.begin(); iter != m_filted.end(); iter++) {\n            if (iter->second == nullptr) {\n                continue;\n            }\n            needRevertInfos.insert(iter->second);\n        }\n    }\n    if (needRevertInfos.size() == 0) {\n        return stepper.deleteCompressionRecord();\n    }\n\n    double tableWeight = 1.0 / needRevertInfos.size();\n    double currentProgress = 0;\n    stepper.setProgressCallback([&](double progress, double) {\n        return updateProgress(currentProgress + tableWeight * progress);\n    });\n    for (auto& info : needRevertInfos) {\n        bool ret = stepper.rollbackCompression(info);\n        if (!ret) {\n            return false;\n        }\n        currentProgress += tableWeight;\n    }\n    bool ret = stepper.deleteCompressionRecord();\n    if (ret) {\n        finishProgress();\n        purge();\n    }\n    return ret;\n}\n\nOptional<bool> Compression::tryAcquireTables(Compression::Stepper& stepper)\n{\n    {\n        SharedLockGuard lockGuard(m_lock);\n        if (m_tableAcquired) {\n            return false;\n        }\n    }\n    auto optionalTables = stepper.getAllTables();\n    if (!optionalTables.succeed()) {\n        return NullOpt;\n    }\n    StringViewSet& tables = optionalTables.value();\n    {\n        SharedLockGuard lockGuard(m_lock);\n        for (const auto& hint : m_hints) {\n            tables.insert(hint.first);\n        }\n    }\n    for (const auto& table : tables) {\n        WCTAssert(!table.hasPrefix(Syntax::builtinTablePrefix)\n                  && !table.hasPrefix(Syntax::builtinWCDBTablePrefix));\n        if (!initInfo(stepper, table)) {\n            return NullOpt;\n        }\n    }\n    std::set<const CompressionTableInfo*> needCompressInfos;\n    {\n        SharedLockGuard lockGuard(m_lock);\n        for (auto iter = tables.begin(); iter != tables.end();) {\n            auto filtedIter = m_filted.find(*iter);\n            if (filtedIter == m_filted.end() || filtedIter->second == nullptr) {\n                iter = tables.erase(iter);\n            } else {\n                needCompressInfos.insert(filtedIter->second);\n                iter++;\n            }\n        }\n    }\n    if (!tryCreateRecordTable(stepper)) {\n        return NullOpt;\n    }\n    if (!stepper.filterComplessingTables(needCompressInfos)) {\n        return NullOpt;\n    }\n    LockGuard lockGuard(m_lock);\n    m_tableAcquired = true;\n    m_compressings = needCompressInfos;\n    return true;\n}\n\nOptional<bool> Compression::tryCompressRows(Compression::Stepper& stepper)\n{\n    const CompressionTableInfo* info = nullptr;\n    {\n        SharedLockGuard lockGuard(m_lock);\n        if (m_compressings.empty()) {\n            return false;\n        }\n        info = *m_compressings.begin();\n    }\n    WCTAssert(info != nullptr);\n    InnerHandle* handle = stepper.getCurrentHandle();\n    auto exists = handle->tableExists(info->getTable());\n    if (!exists.succeed()) {\n        return NullOpt;\n    }\n    if (!exists.value()) {\n        handle->execute(CompressionRecord::getDeleteRecordStatement(info->getTable()));\n        markAsCompressed(info);\n        return true;\n    }\n    if (!checkCompressingColumn(stepper, info)) {\n        return NullOpt;\n    }\n\n    auto compressed = stepper.compressRows(info);\n    if (compressed.failed()) {\n        return NullOpt;\n    }\n    if (compressed.succeed() && compressed.value()) {\n        markAsCompressed(info);\n    }\n    return true;\n}\n\n#pragma mark - Event\nbool Compression::isCompressed() const\n{\n    SharedLockGuard lockGuard(m_lock);\n    return m_compressed;\n}\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/core/compression/Compression.hpp",
    "content": "//\n// Created by qiuwenchen on 2023/11/21.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"CompressionInfo.hpp\"\n#include \"Lock.hpp\"\n#include \"Progress.hpp\"\n#include \"ThreadLocal.hpp\"\n#include <functional>\n#include <map>\n#include <set>\n\nnamespace WCDB {\n\nclass InnerHandle;\n\nclass CompressionEvent {\npublic:\n    virtual ~CompressionEvent() = 0;\n\nprotected:\n    friend class Compression;\n    // parameter will be nullptr when all tables are compressed.\n    virtual void didCompress(const CompressionTableBaseInfo* info) = 0;\n};\n\nclass Compression final : public Progress {\n#pragma mark - Initialize\npublic:\n    Compression(CompressionEvent* event);\n\n    typedef std::function<void(CompressionTableUserInfo&)> TableFilter;\n    void setTableFilter(const TableFilter& tableFilter);\n    bool shouldCompress() const;\n    void purge();\n\nprivate:\n    TableFilter m_tableFilter;\n\n    volatile int m_dataVersion;\n    ThreadLocal<int> m_localDataVersion;\n    void tryResetLocalStatus();\n\nprotected:\n    class InfoInitializer {\n        friend class Compression;\n\n    public:\n        virtual ~InfoInitializer() = 0;\n\n    protected:\n        virtual InnerHandle* getCurrentHandle() const = 0;\n        Optional<bool> tableExist(const UnsafeStringView& table);\n        Optional<bool> checkCompressingColumns(const CompressionTableInfo& info);\n    };\n\n    bool initInfo(InfoInitializer& initializer, const UnsafeStringView& table);\n    Optional<std::list<CompressionColumnInfo>>\n    tryGetCompressingColumnsForNewTable(InfoInitializer& initializer,\n                                        const UnsafeStringView& table);\n    void markAsNoNeedToCompress(const UnsafeStringView& table);\n    void markAsCompressed(const CompressionTableInfo* info);\n    Optional<const CompressionTableInfo*> getInfo(const UnsafeStringView& table);\n    Optional<const CompressionTableInfo*>\n    getOrInitInfo(InfoInitializer& initializer, const UnsafeStringView& table);\n    bool tryFixCompressingColumn(InfoInitializer& initializer, const UnsafeStringView& table);\n    bool checkCompressingColumn(InfoInitializer& initializer,\n                                const CompressionTableInfo* info);\n    void notifyTransactionCommitted(bool committed);\n    bool tryCreateRecordTable(InfoInitializer& initializer);\n\nprivate:\n    ThreadLocal<StringViewMap<const CompressionTableInfo*>> m_localFilted;\n    ThreadLocal<std::set<const CompressionTableInfo*>> m_commitingTables;\n    std::set<const CompressionTableInfo*> m_compressings;\n    StringViewMap<const CompressionTableInfo*> m_filted;\n    StringViewMap<CompressionTableUserInfo> m_hints;\n    std::list<CompressionTableInfo> m_holder;\n    mutable SharedLock m_lock;\n\n    volatile bool m_hasCreatedRecord;\n    ThreadLocal<bool> m_localHasCreatedRecord;\n\n#pragma mark - Bind\npublic:\n    class Binder : public InfoInitializer {\n        friend class Compression;\n\n    public:\n        Binder(Compression& compression);\n        virtual ~Binder() override = 0;\n\n        Optional<const CompressionTableInfo*>\n        tryGetCompressionInfo(const UnsafeStringView& table);\n        bool tryFixCompressingColumn(const UnsafeStringView& table);\n        Optional<std::list<CompressionColumnInfo>>\n        tryGetCompressingColumnsForNewTable(const UnsafeStringView& table);\n        void notifyTransactionCommitted(bool committed);\n        bool canCompressNewData() const;\n\n    private:\n        Compression& m_compression;\n    };\n\n    bool canCompressNewData() const;\n    void setCanCompressNewData(bool canCompress);\n\nprivate:\n    volatile bool m_canCompressNewData;\n\n#pragma mark - Step\npublic:\n    class Stepper : public InfoInitializer, public Progress {\n        friend class Compression;\n\n    public:\n        virtual ~Stepper() override = 0;\n\n    protected:\n        virtual Optional<StringViewSet> getAllTables() = 0;\n        virtual bool\n        filterComplessingTables(std::set<const CompressionTableInfo*>& allTableInfos)\n        = 0;\n        virtual Optional<bool> compressRows(const CompressionTableInfo* info) = 0;\n\n        typedef std::function<void(double)> ProgressCallback;\n        virtual bool rollbackCompression(const CompressionTableInfo* info) = 0;\n        virtual bool deleteCompressionRecord() = 0;\n    };\n\n    Optional<bool> step(Compression::Stepper& stepper);\n\n    bool rollbackCompression(Compression::Stepper& stepper);\n\nprotected:\n    // worked\n    Optional<bool> tryCompressRows(Compression::Stepper& stepper);\n    Optional<bool> tryAcquireTables(Compression::Stepper& stepper);\n\nprivate:\n    bool m_tableAcquired;\n    bool m_compressed;\n\n#pragma mark - Event\npublic:\n    bool isCompressed() const;\n\nprotected:\n    CompressionEvent* m_event;\n};\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/common/core/compression/CompressionCenter.cpp",
    "content": "//\n// Created by qiuwenchen on 2023/11/21.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"CompressionCenter.hpp\"\n#include \"Assertion.hpp\"\n#include \"InnerHandle.hpp\"\n#include \"Notifier.hpp\"\n#include \"ScalarFunctionModule.hpp\"\n#include \"WCDBError.hpp\"\n#include <string.h>\n#if defined(WCDB_ZSTD) && WCDB_ZSTD\n#define ZDICT_STATIC_LINKING_ONLY 1\n#include <zstd/zdict.h>\n#include <zstd/zstd.h>\n#endif\n\nnamespace WCDB {\n\nCompressionCenter::CompressionCenter()\n{\n    m_dicts = (ZSTDDict**) calloc(MaxDictId, sizeof(ZSTDDict*));\n    WCTAssert(m_dicts != nullptr);\n}\n\nCompressionCenter::~CompressionCenter()\n{\n    free(m_dicts);\n}\n\nCompressionCenter& CompressionCenter::shared()\n{\n    static CompressionCenter* g_dictCenter = new CompressionCenter;\n    return *g_dictCenter;\n}\n\nZSTDDict* CompressionCenter::getDict(DictId id) const\n{\n    if (id >= MaxDictId || id == 0) {\n        return nullptr;\n    }\n    return m_dicts[id];\n}\n\nbool CompressionCenter::registerDict(DictId dictId, const UnsafeData& data)\n{\n    ZSTDDict* dict = new ZSTDDict;\n    if (!dict->loadData(data)) {\n        delete dict;\n        return false;\n    }\n    if (dictId != dict->getDictId()) {\n        Error error(Error::Code::ZstdError, Error::Level::Error, \"DictId mismatch!\");\n        error.infos.insert_or_assign(\"GivenDictId\", dictId);\n        error.infos.insert_or_assign(\"ActualDictId\", dict->getDictId());\n        Notifier::shared().notify(error);\n        SharedThreadedErrorProne::setThreadedError(std::move(error));\n        delete dict;\n        return false;\n    }\n    if (dict->getDictId() >= MaxDictId || dict->getDictId() == 0) {\n        Error error(Error::Code::ZstdError, Error::Level::Error, \"DictId must be an integer between 1 and 999!\");\n        error.infos.insert_or_assign(\"CurrendDictId\", dict->getDictId());\n        Notifier::shared().notify(error);\n        SharedThreadedErrorProne::setThreadedError(std::move(error));\n        delete dict;\n        return false;\n    }\n    if (m_dicts[dict->getDictId()] != nullptr) {\n        Error error(Error::Code::ZstdError, Error::Level::Error, \"Duplicate dictid!\");\n        error.infos.insert_or_assign(\"DictId\", dict->getDictId());\n        Notifier::shared().notify(error);\n        SharedThreadedErrorProne::setThreadedError(std::move(error));\n        delete dict;\n        return false;\n    }\n    m_dicts[dict->getDictId()] = dict;\n    return true;\n}\n\n#if defined(WCDB_ZSTD) && WCDB_ZSTD\n\nOptional<Data> CompressionCenter::trainDict(DictId dictId, TrainDataEnumerator dataEnummerator)\n{\n    if (dictId == 0 || dictId >= MaxDictId) {\n        Error error(Error::Code::ZstdError, Error::Level::Error, \"DictId must be an integer between 1 and 999\");\n        error.infos.insert_or_assign(\"CurrendDictId\", dictId);\n        Notifier::shared().notify(error);\n        SharedThreadedErrorProne::setThreadedError(std::move(error));\n        return NullOpt;\n    }\n    int64_t totalSize = 0;\n    std::vector<size_t> dataSizes;\n\n    size_t dictSize = 100 * 1024;\n    Data dict(dictSize);\n    if (dict.empty()) {\n        return NullOpt;\n    }\n    Data allData(1024 * 1024);\n    if (allData.empty()) {\n        return NullOpt;\n    }\n\n    Optional<UnsafeData> data = dataEnummerator();\n    static const int64_t kMaxTrainDataSize = 4LL * 1024 * 1024 * 1024;\n    while (data.hasValue()) {\n        size_t dataSize = data.value().size();\n        if (dataSize == 0) {\n            continue;\n        }\n        if (totalSize + dataSize > kMaxTrainDataSize) {\n            Error error(Error::Code::ZstdError,\n                        Error::Level::Warning,\n                        \"The size of the training data exceeds the maximum value of 4G\");\n            Notifier::shared().notify(error);\n            SharedThreadedErrorProne::setThreadedError(std::move(error));\n            break;\n        }\n        if (totalSize + dataSize > allData.size()) {\n            size_t newSize = std::max(2 * allData.size(), allData.size() + dataSize);\n            if (!allData.resize(newSize)) {\n                return NullOpt;\n            }\n        }\n\n        memcpy(allData.buffer() + totalSize, data.value().buffer(), dataSize);\n        totalSize += dataSize;\n        dataSizes.push_back(dataSize);\n        data = dataEnummerator();\n    }\n\n    ZDICT_fastCover_params_t params;\n    memset(&params, 0, sizeof(params));\n    params.d = 8;\n    params.steps = 4;\n    params.zParams.dictID = dictId;\n    params.zParams.compressionLevel = ZSTD_CLEVEL_DEFAULT;\n    dictSize = ZDICT_optimizeTrainFromBuffer_fastCover(dict.buffer(),\n                                                       dictSize,\n                                                       allData.buffer(),\n                                                       dataSizes.data(),\n                                                       (unsigned) dataSizes.size(),\n                                                       &params);\n    if (ZSTD_isError(dictSize)) {\n        Error error(Error::Code::ZstdError, Error::Level::Error, \"Train dict failed\");\n        error.infos.insert_or_assign(\"ZSTDErrorCode\", dictSize);\n        error.infos.insert_or_assign(\"ZSTDErrorName\", ZSTD_getErrorName(dictSize));\n        Notifier::shared().notify(error);\n        SharedThreadedErrorProne::setThreadedError(std::move(error));\n        return NullOpt;\n    }\n    return dict;\n}\n\nOptional<UnsafeData>\nCompressionCenter::compressContent(const UnsafeData& data, DictId dictId, InnerHandle* errorReportHandle)\n{\n    if (data.size() == 0) {\n        return data;\n    }\n\n    int64_t boundSize = ZSTD_compressBound(data.size());\n    if (ZSTD_isError(boundSize)) {\n        errorReportHandle->notifyError(\n        Error::Code::ZstdError,\n        nullptr,\n        StringView::formatted(\"Compress bound fail: %s\", ZSTD_getErrorName(boundSize)));\n        return NullOpt;\n    }\n    ZSTDContext& ctx = m_ctxes.getOrCreate();\n    void* buffer = ctx.getOrCreateBuffer(boundSize);\n    if (buffer == nullptr) {\n        errorReportHandle->notifyError(\n        Error::Code::NoMemory, nullptr, \"Compress fail due to no memory\");\n        return NullOpt;\n    }\n    int64_t compressSize = 0;\n    if (dictId > 0) {\n        ZSTDDict* dict = getDict(dictId);\n        if (dict == nullptr) {\n            errorReportHandle->notifyError(\n            Error::Code::ZstdError,\n            nullptr,\n            StringView::formatted(\"Can not find compress dict with id: %d\", dictId));\n            return NullOpt;\n        }\n        if (!dict->tryMemoryVerification()) {\n            errorReportHandle->notifyError(\n            Error::Code::ZstdError,\n            nullptr,\n            StringView::formatted(\"Dict with id %d is corrupted\", dictId));\n            return NullOpt;\n        }\n        compressSize = ZSTD_compress_usingCDict((ZSTD_CCtx*) ctx.getOrCreateCCtx(),\n                                                buffer,\n                                                boundSize,\n                                                data.buffer(),\n                                                data.size(),\n                                                (ZSTD_CDict*) dict->getCDict());\n    } else {\n        compressSize = ZSTD_compress2((ZSTD_CCtx*) ctx.getOrCreateCCtx(),\n                                      buffer,\n                                      boundSize,\n                                      data.buffer(),\n                                      data.size());\n    }\n    if (ZSTD_isError(compressSize)) {\n        errorReportHandle->notifyError(\n        Error::Code::ZstdError,\n        nullptr,\n        StringView::formatted(\"Compress fail: %s\", ZSTD_getErrorName(compressSize)));\n        return NullOpt;\n    }\n    if (compressSize >= data.size()) {\n        return data;\n    }\n    return UnsafeData((unsigned char*) buffer, compressSize);\n}\n\nvoid CompressionCenter::decompressContent(const UnsafeData& data,\n                                          bool usingDict,\n                                          ColumnType originType,\n                                          ScalarFunctionAPI& resultAPI)\n{\n    int64_t frameSize = ZSTD_getFrameContentSize(data.buffer(), data.size());\n    if (ZSTD_isError(frameSize)) {\n        resultAPI.setErrorResult(Error::Code::ZstdError,\n                                 StringView::formatted(\"Get compress content frame size fail: %s\",\n                                                       ZSTD_getErrorName(frameSize)));\n        return;\n    }\n    ZSTDContext& ctx = m_ctxes.getOrCreate();\n    void* buffer = ctx.getOrCreateBuffer(frameSize);\n    if (buffer == nullptr) {\n        resultAPI.setErrorResult(Error::Code::NoMemory, \"Decompress fail due to no memory\");\n        return;\n    }\n    int64_t decompressSize = 0;\n    if (usingDict) {\n        DictId dictId = (DictId) ZSTD_getDictID_fromFrame(data.buffer(), data.size());\n        if (dictId == 0) {\n            resultAPI.setErrorResult(Error::Code::ZstdError, \"Can not decode dictid\");\n            return;\n        }\n        ZSTDDict* dict = getDict(dictId);\n        if (dict == nullptr) {\n            resultAPI.setErrorResult(\n            Error::Code::ZstdError,\n            StringView::formatted(\"Can not find decompress dict with id: %d\", dictId));\n            return;\n        }\n        decompressSize = ZSTD_decompress_usingDDict((ZSTD_DCtx*) ctx.getOrCreateDCtx(),\n                                                    buffer,\n                                                    frameSize,\n                                                    data.buffer(),\n                                                    data.size(),\n                                                    (ZSTD_DDict*) dict->getDDict());\n    } else {\n        decompressSize = ZSTD_decompressDCtx((ZSTD_DCtx*) ctx.getOrCreateDCtx(),\n                                             buffer,\n                                             frameSize,\n                                             data.buffer(),\n                                             data.size());\n    }\n\n    if (ZSTD_isError(decompressSize)) {\n        // The data is corrupted and not recoverable. Just ignore it.\n        Error error(Error::Code::ZstdError,\n                    Error::Level::Error,\n                    StringView::formatted(\"Decompress fail: %s\",\n                                          ZSTD_getErrorName(decompressSize)));\n        Notifier::shared().notify(error);\n        decompressSize = 0;\n    }\n    if (originType == ColumnType::Text) {\n        resultAPI.setTextResult(UnsafeStringView((char*) buffer, decompressSize));\n    } else {\n        resultAPI.setBlobResult(UnsafeData((unsigned char*) buffer, decompressSize));\n    }\n}\n\nOptional<UnsafeData>\nCompressionCenter::decompressContent(const UnsafeData& data, bool usingDict, InnerHandle* handle)\n{\n    int64_t frameSize = ZSTD_getFrameContentSize(data.buffer(), data.size());\n    if (ZSTD_isError(frameSize)) {\n        handle->notifyError(Error::Code::ZstdError,\n                            nullptr,\n                            StringView::formatted(\"Get compress content frame size fail: %s\",\n                                                  ZSTD_getErrorName(frameSize)));\n        return NullOpt;\n    }\n    ZSTDContext& ctx = m_ctxes.getOrCreate();\n    void* buffer = ctx.getOrCreateBuffer(frameSize);\n    if (buffer == nullptr) {\n        handle->notifyError(Error::Code::NoMemory, nullptr, \"Decompress fail due to no memory\");\n        return NullOpt;\n    }\n    int64_t decompressSize = 0;\n    if (usingDict) {\n        DictId dictId = (DictId) ZSTD_getDictID_fromFrame(data.buffer(), data.size());\n        if (dictId == 0) {\n            handle->notifyError(Error::Code::ZstdError, nullptr, \"Can not decode dictid\");\n            return NullOpt;\n        }\n        ZSTDDict* dict = getDict(dictId);\n        if (dict == nullptr) {\n            handle->notifyError(\n            Error::Code::ZstdError,\n            nullptr,\n            StringView::formatted(\"Can not find decompress dict with id: %d\", dictId));\n            return NullOpt;\n        }\n        decompressSize = ZSTD_decompress_usingDDict((ZSTD_DCtx*) ctx.getOrCreateDCtx(),\n                                                    buffer,\n                                                    frameSize,\n                                                    data.buffer(),\n                                                    data.size(),\n                                                    (ZSTD_DDict*) dict->getDDict());\n    } else {\n        decompressSize = ZSTD_decompressDCtx((ZSTD_DCtx*) ctx.getOrCreateDCtx(),\n                                             buffer,\n                                             frameSize,\n                                             data.buffer(),\n                                             data.size());\n    }\n\n    if (ZSTD_isError(decompressSize)) {\n        // The data is corrupted and not recoverable. Just ignore it.\n        Error error(Error::Code::ZstdError,\n                    Error::Level::Error,\n                    StringView::formatted(\"Decompress fail: %s\",\n                                          ZSTD_getErrorName(decompressSize)));\n        Notifier::shared().notify(error);\n        decompressSize = 0;\n    }\n    return UnsafeData((unsigned char*) buffer, decompressSize);\n}\n\nbool CompressionCenter::testContentCanBeDecompressed(const UnsafeData& data,\n                                                     bool usingDict,\n                                                     InnerHandle* errorReportHandle)\n{\n    int64_t frameSize = ZSTD_getFrameContentSize(data.buffer(), data.size());\n    if (ZSTD_isError(frameSize)) {\n        errorReportHandle->notifyError(\n        Error::Code::ZstdError,\n        StringView::formatted(\"Get compress content frame size fail: %s\",\n                              ZSTD_getErrorName(frameSize)));\n        return false;\n    }\n    ZSTDContext& ctx = m_ctxes.getOrCreate();\n    void* buffer = ctx.getOrCreateBuffer(frameSize);\n    if (buffer == nullptr) {\n        errorReportHandle->notifyError(\n        Error::Code::NoMemory, \"\", \"Decompress fail due to no memory\");\n        return false;\n    }\n    int64_t decompressSize = 0;\n    if (usingDict) {\n        DictId dictId = (DictId) ZSTD_getDictID_fromFrame(data.buffer(), data.size());\n        if (dictId == 0) {\n            errorReportHandle->notifyError(Error::Code::ZstdError, \"\", \"Can not decode dictid\");\n            return false;\n        }\n        ZSTDDict* dict = getDict(dictId);\n        if (dict == nullptr) {\n            errorReportHandle->notifyError(\n            Error::Code::ZstdError,\n            \"\",\n            StringView::formatted(\"Can not find decompress dict with id: %d\", dictId));\n            return false;\n        }\n        decompressSize = ZSTD_decompress_usingDDict((ZSTD_DCtx*) ctx.getOrCreateDCtx(),\n                                                    buffer,\n                                                    frameSize,\n                                                    data.buffer(),\n                                                    data.size(),\n                                                    (ZSTD_DDict*) dict->getDDict());\n    } else {\n        decompressSize = ZSTD_decompressDCtx((ZSTD_DCtx*) ctx.getOrCreateDCtx(),\n                                             buffer,\n                                             frameSize,\n                                             data.buffer(),\n                                             data.size());\n    }\n\n    if (ZSTD_isError(decompressSize)) {\n        errorReportHandle->notifyError(\n        Error::Code::ZstdError,\n        \"\",\n        StringView::formatted(\"Decompress fail: %s\", ZSTD_getErrorName(decompressSize)));\n        return false;\n    }\n    return true;\n}\n\n#else\n\nOptional<Data> CompressionCenter::trainDict(DictId, TrainDataEnumerator)\n{\n    Error error(Error::Code::ZstdError, Error::Level::Error, \"You need to build WCDB with WCDB_ZSTD macro\");\n    Notifier::shared().notify(error);\n    SharedThreadedErrorProne::setThreadedError(std::move(error));\n    return NullOpt;\n}\n\nOptional<UnsafeData>\nCompressionCenter::compressContent(const UnsafeData&, DictId, InnerHandle* errorReportHandle)\n{\n    errorReportHandle->notifyError(\n    Error::Code::ZstdError, nullptr, \"You need to build WCDB with WCDB_ZSTD macro\");\n    return NullOpt;\n}\n\nOptional<UnsafeData>\nCompressionCenter::decompressContent(const UnsafeData& data, bool usingDict, InnerHandle* handle)\n{\n    handle->notifyError(\n    Error::Code::ZstdError, nullptr, \"You need to build WCDB with WCDB_ZSTD macro\");\n    return NullOpt;\n}\n\nvoid CompressionCenter::decompressContent(const UnsafeData&, bool, ColumnType, ScalarFunctionAPI& resultAPI)\n{\n    resultAPI.setErrorResult(Error::Code::ZstdError,\n                             \"You need to build WCDB with WCDB_ZSTD macro\");\n}\n\nbool CompressionCenter::testContentCanBeDecompressed(const UnsafeData&, bool, InnerHandle* errorReportHandle)\n{\n    errorReportHandle->notifyError(\n    Error::Code::ZstdError, \"\", \"You need to build WCDB with WCDB_ZSTD macro\");\n    return false;\n}\n\n#endif\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/core/compression/CompressionCenter.hpp",
    "content": "//\n// Created by qiuwenchen on 2023/11/21.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"ColumnType.hpp\"\n#include \"CompressionConst.hpp\"\n#include \"ThreadLocal.hpp\"\n#include \"ZSTDContext.hpp\"\n#include \"ZSTDDict.hpp\"\n#include <memory>\n\nnamespace WCDB {\n\nclass ScalarFunctionAPI;\nclass InnerHandle;\n\nclass CompressionCenter : public SharedThreadedErrorProne {\npublic:\n    CompressionCenter();\n    ~CompressionCenter();\n    CompressionCenter(const CompressionCenter&) = delete;\n    CompressionCenter& operator=(const CompressionCenter&) = delete;\n\n    static CompressionCenter& shared();\n\n    using DictId = ZSTDDict::DictId;\n    static constexpr const DictId MaxDictId = 1000;\n\n    bool registerDict(DictId dictId, const UnsafeData& data);\n    typedef std::function<Optional<UnsafeData>()> TrainDataEnumerator;\n    Optional<Data> trainDict(DictId dictId, TrainDataEnumerator dataEnummerator);\n\n    Optional<UnsafeData>\n    compressContent(const UnsafeData& data, DictId dictId, InnerHandle* errorReportHandle);\n    void decompressContent(const UnsafeData& data,\n                           bool usingDict,\n                           ColumnType originType,\n                           ScalarFunctionAPI& resultAPI);\n    Optional<UnsafeData>\n    decompressContent(const UnsafeData& data, bool usingDict, InnerHandle* handle);\n\n    bool testContentCanBeDecompressed(const UnsafeData& data,\n                                      bool usingDict,\n                                      InnerHandle* errorReportHandle);\n\nprivate:\n    ZSTDDict* getDict(DictId id) const;\n    ZSTDDict** m_dicts;\n    ThreadLocal<ZSTDContext> m_ctxes;\n};\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/core/compression/CompressionConst.cpp",
    "content": "//\n// Created by qiuwenchen on 2023/11/26.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"CompressionConst.hpp\"\n\nnamespace WCDB {\n\nWCDBLiteralStringImplement(DecompressFunctionName);\n\nWCDBLiteralStringImplement(CompressionRecordTable);\nWCDBLiteralStringImplement(CompressionRecordColumn_Table);\nWCDBLiteralStringImplement(CompressionRecordColumn_Columns);\nWCDBLiteralStringImplement(CompressionRecordColumn_Rowid);\n\nWCDBLiteralStringImplement(CompressionColumnTypePrefix);\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/core/compression/CompressionConst.hpp",
    "content": "//\n// Created by 陈秋文 on 2023/11/26.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"Macro.h\"\n#include \"StringView.hpp\"\n\nnamespace WCDB {\n\nenum class CompressedType {\n    None = 0,\n    ZSTDDict,\n    ZSTDNormal,\n};\n\n#define WCDBMergeCompressionType(compressedType, columnType)                   \\\n    ((((int) (compressedType)) << 1) | ((columnType) == WCDB::ColumnType::Text ? 0 : 1))\n#define WCDBGetCompressedType(mergeType)                                       \\\n    ((WCDB::CompressedType) ((mergeType) >> 1))\n#define WCDBGetOriginType(mergeType)                                           \\\n    ((((mergeType) & 0x1) > 0) ? WCDB::ColumnType::BLOB : WCDB::ColumnType::Text)\n\nWCDBLiteralStringDefine(DecompressFunctionName, \"wcdb_decompress\");\n\nWCDBLiteralStringDefine(CompressionRecordTable, \"wcdb_builtin_compression_record\");\nWCDBLiteralStringDefine(CompressionRecordColumn_Table, \"tableName\");\nWCDBLiteralStringDefine(CompressionRecordColumn_Columns, \"columns\");\nWCDBLiteralStringDefine(CompressionRecordColumn_Rowid, \"rowid\");\n\nconst char CompressionRecordColumnSeperater = ' ';\n\nWCDBLiteralStringDefine(CompressionColumnTypePrefix, \"WCDB_CT_\")\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/common/core/compression/CompressionInfo.cpp",
    "content": "//\n// Created by qiuwenchen on 2023/11/21.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"CompressionInfo.hpp\"\n#include \"Assertion.hpp\"\n#include \"CompressionCenter.hpp\"\n#include \"CompressionConst.hpp\"\n#include \"CoreConst.h\"\n#include \"HandleStatement.hpp\"\n#include \"InnerHandle.hpp\"\n#include \"WINQ.h\"\n\nnamespace WCDB {\n\n#pragma mark - CompressionColumnInfo\nCompressionColumnInfo::CompressionColumnInfo(const Column &column, CompressionType type)\n: m_columnIndex(UINT16_MAX)\n, m_typeColumnIndex(UINT16_MAX)\n, m_matchColumnIndex(UINT16_MAX)\n, m_compressionType(type)\n, m_commonDictID(-1)\n{\n    std::ostringstream stringStream;\n    stringStream << CompressionColumnTypePrefix << column.syntax().name;\n    m_typeColumn = StringView(stringStream.str());\n}\n\nCompressionColumnInfo::CompressionColumnInfo(const Column &column, const Column &matchColumn)\n: m_columnIndex(UINT16_MAX)\n, m_typeColumnIndex(UINT16_MAX)\n, m_matchColumn(matchColumn.syntax().name)\n, m_matchColumnIndex(UINT16_MAX)\n, m_compressionType(CompressionType::VariousDict)\n, m_commonDictID(-1)\n{\n    std::ostringstream stringStream;\n    stringStream << CompressionColumnTypePrefix << column.syntax().name;\n    m_typeColumn = StringView(stringStream.str());\n}\n\nCompressionColumnInfo::CompressionColumnInfo(const CompressionColumnInfo &other)\n: m_columnIndex(other.m_columnIndex.load())\n, m_typeColumn(other.m_typeColumn)\n, m_typeColumnIndex(other.m_typeColumnIndex.load())\n, m_matchColumn(other.m_matchColumn)\n, m_matchColumnIndex(other.m_matchColumnIndex.load())\n, m_compressionType(other.m_compressionType)\n, m_commonDictID(other.m_commonDictID)\n, m_matchDicts(other.m_matchDicts)\n{\n}\n\nCompressionColumnInfo::CompressionColumnInfo(CompressionColumnInfo &&other)\n: m_columnIndex(other.m_columnIndex.load())\n, m_typeColumn(std::move(other.m_typeColumn))\n, m_typeColumnIndex(other.m_typeColumnIndex.load())\n, m_matchColumn(std::move(other.m_matchColumn))\n, m_matchColumnIndex(other.m_matchColumnIndex.load())\n, m_compressionType(other.m_compressionType)\n, m_commonDictID(other.m_commonDictID)\n, m_matchDicts(std::move(other.m_matchDicts))\n{\n}\n\nCompressionColumnInfo &CompressionColumnInfo::operator=(const CompressionColumnInfo &other)\n{\n    m_columnIndex = other.m_columnIndex.load();\n    m_typeColumn = other.m_typeColumn;\n    m_typeColumnIndex = other.m_typeColumnIndex.load();\n    m_matchColumn = other.m_matchColumn;\n    m_matchColumnIndex = other.m_matchColumnIndex.load();\n    m_compressionType = other.m_compressionType;\n    m_commonDictID = other.m_commonDictID;\n    m_matchDicts = other.m_matchDicts;\n    return *this;\n}\n\nCompressionColumnInfo &CompressionColumnInfo::operator=(CompressionColumnInfo &&other)\n{\n    m_columnIndex = other.m_columnIndex.load();\n    m_typeColumn = std::move(other.m_typeColumn);\n    m_typeColumnIndex = other.m_typeColumnIndex.load();\n    m_matchColumn = std::move(other.m_matchColumn);\n    m_matchColumnIndex = other.m_matchColumnIndex.load();\n    m_compressionType = other.m_compressionType;\n    m_commonDictID = other.m_commonDictID;\n    m_matchDicts = std::move(other.m_matchDicts);\n    return *this;\n}\n\nStringView CompressionColumnInfo::getColumn() const\n{\n    return m_typeColumn.subStr(CompressionColumnTypePrefix.length());\n}\n\nvoid CompressionColumnInfo::setColumnIndex(uint16_t index) const\n{\n    m_columnIndex = index;\n}\n\nuint16_t CompressionColumnInfo::getColumnIndex() const\n{\n    WCTAssert(m_columnIndex != UINT16_MAX);\n    return m_columnIndex;\n}\n\nconst StringView &CompressionColumnInfo::getTypeColumn() const\n{\n    return m_typeColumn;\n}\n\nvoid CompressionColumnInfo::setTypeColumnIndex(uint16_t index) const\n{\n    m_typeColumnIndex = index;\n}\n\nuint16_t CompressionColumnInfo::getTypeColumnIndex() const\n{\n    WCTAssert(m_typeColumnIndex != UINT16_MAX);\n    return m_typeColumnIndex;\n}\n\nconst StringView &CompressionColumnInfo::getMatchColumn() const\n{\n    return m_matchColumn;\n}\n\nvoid CompressionColumnInfo::setMatchColumnIndex(uint16_t index) const\n{\n    m_matchColumnIndex = index;\n}\n\nuint16_t CompressionColumnInfo::getMatchColumnIndex() const\n{\n    WCTAssert(m_matchColumnIndex != UINT16_MAX);\n    return m_matchColumnIndex;\n}\n\nCompressionType CompressionColumnInfo::getCompressionType() const\n{\n    return m_compressionType;\n}\n\nCompressionColumnInfo::DictId CompressionColumnInfo::getDictId() const\n{\n    WCTAssert(m_compressionType == CompressionType::Dict);\n    return m_commonDictID;\n}\n\nCompressionColumnInfo::DictId\nCompressionColumnInfo::getMatchDictId(const Integer &matchValue) const\n{\n    WCTAssert(m_compressionType == CompressionType::VariousDict);\n    auto iter = m_matchDicts.find(matchValue);\n    if (iter == m_matchDicts.end()) {\n        return m_commonDictID;\n    }\n    return iter->second;\n}\n\nvoid CompressionColumnInfo::setCommonDict(DictId dictId)\n{\n    WCTAssert(m_compressionType != CompressionType::Normal);\n    m_commonDictID = dictId;\n}\n\nvoid CompressionColumnInfo::addMatchDict(const Integer &matchValue, DictId dictId)\n{\n    WCTAssert(m_compressionType == CompressionType::VariousDict);\n    m_matchDicts[matchValue] = dictId;\n}\n\n#pragma mark - CompressionTableBaseInfo\nCompressionTableBaseInfo::CompressionTableBaseInfo(const UnsafeStringView &table)\n: m_table(table), m_replaceCompression(false)\n{\n}\n\nbool CompressionTableBaseInfo::shouldCompress() const\n{\n    return m_compressingColumns.size() > 0;\n}\n\nconst StringView &CompressionTableBaseInfo::getTable() const\n{\n    return m_table;\n}\n\nCompressionTableInfo::ColumnInfoList &CompressionTableBaseInfo::getColumnInfos() const\n{\n    return m_compressingColumns;\n}\n\n#pragma mark - CompressionTableUserInfo\n\nCompressionTableUserInfo::CompressionTableUserInfo(const UnsafeStringView &table)\n: CompressionTableBaseInfo(table)\n{\n}\n\nCompressionTableUserInfo::CompressionTableUserInfo(const UnsafeStringView &table,\n                                                   const std::list<CompressionColumnInfo> &columns)\n: CompressionTableBaseInfo(table)\n{\n    m_compressingColumns = columns;\n}\n\nvoid CompressionTableUserInfo::addCompressingColumn(const CompressionColumnInfo &info)\n{\n    for (auto iter = m_compressingColumns.begin(); iter != m_compressingColumns.end(); iter++) {\n        if (iter->getColumn().equal(info.getColumn())) {\n            m_compressingColumns.erase(iter);\n            break;\n        }\n    }\n    m_compressingColumns.push_back(info);\n}\n\nvoid CompressionTableUserInfo::enableReplaceCompresssion()\n{\n    m_replaceCompression = true;\n}\n\n#pragma mark - CompressionTableInfo\nCompressionTableInfo::CompressionTableInfo(const CompressionTableUserInfo &userInfo)\n: CompressionTableBaseInfo(userInfo)\n, m_minCompressedRowid(INT64_MAX)\n, m_needCheckColumn(true)\n{\n}\n\nvoid CompressionTableInfo::setMinCompressedRowid(int64_t rowid) const\n{\n    m_minCompressedRowid = rowid;\n}\n\nint64_t CompressionTableInfo::getMinCompressedRowid() const\n{\n    return m_minCompressedRowid;\n}\n\nbool CompressionTableInfo::needCheckColumns() const\n{\n    return m_needCheckColumn;\n}\n\nvoid CompressionTableInfo::setNeedCheckColumns(bool needCheck) const\n{\n    m_needCheckColumn = needCheck;\n}\n\nStringView CompressionTableInfo::getCompressionDescription() const\n{\n    StringViewMap<const CompressionColumnInfo *> orderedInfos;\n    for (const auto &info : m_compressingColumns) {\n        orderedInfos[info.getColumn()] = &info;\n    }\n    std::ostringstream stream;\n    bool isFirst = true;\n    for (const auto &iter : orderedInfos) {\n        if (!isFirst) {\n            stream << \",\";\n        } else {\n            isFirst = false;\n        }\n        stream << iter.first;\n        auto &compressionInfo = *iter.second;\n        switch (compressionInfo.getCompressionType()) {\n        case CompressionType::Dict:\n            stream << \":\" << compressionInfo.getDictId();\n            break;\n        case CompressionType::VariousDict: {\n            stream << \":\";\n            std::map<CompressionColumnInfo::Integer, CompressionColumnInfo::DictId> matchDicts;\n            for (const auto &dictIter : compressionInfo.m_matchDicts) {\n                matchDicts[dictIter.first] = dictIter.second;\n            }\n            stream << \"{\";\n            for (const auto &dictIter : matchDicts) {\n                stream << dictIter.first << \":\" << dictIter.second;\n                stream << \";\";\n            }\n            stream << INT64_MAX << \":\" << compressionInfo.m_commonDictID;\n            stream << \"}\";\n        }\n        default:\n            break;\n        }\n    }\n    return stream.str();\n}\n\nbool CompressionTableInfo::shouldReplaceCompression() const\n{\n    return m_replaceCompression;\n}\n\n#pragma mark - Compress Statements\n\nStatementSelect CompressionTableInfo::getSelectNeedCompressRowIdStatement() const\n{\n    Expression condition;\n    if (!m_replaceCompression) {\n        for (auto &column : m_compressingColumns) {\n            if (condition.syntax().isValid()) {\n                condition = condition || Column(column.getTypeColumn()).isNull();\n            } else {\n                condition = Column(column.getTypeColumn()).isNull();\n            }\n        }\n        condition = condition && Column::rowid() < BindParameter();\n    } else {\n        condition = Column::rowid() < BindParameter();\n    }\n    return StatementSelect()\n    .select(Column::rowid())\n    .from(m_table)\n    .where(condition)\n    .order(Column::rowid().asOrder(Order::DESC))\n    .limit(CompressionBatchCount);\n}\n\nStatementSelect CompressionTableInfo::getSelectRowStatement() const\n{\n    return StatementSelect().select(Column::all()).from(m_table).where(Column::rowid() == BindParameter());\n}\n\nStatementDelete CompressionTableInfo::getDelectRowStatement() const\n{\n    return StatementDelete().deleteFrom(m_table).where(Column::rowid() == BindParameter());\n}\n\nStatementInsert CompressionTableInfo::getInsertNewRowStatement(size_t valueCount) const\n{\n    return StatementInsert().insertIntoTable(m_table).values(\n    BindParameter::bindParameters(valueCount));\n}\n\nStatementSelect\nCompressionTableInfo::getSelectUncompressRowStatement(ColumnInfoPtrList *columnList) const\n{\n    ResultColumns resultColumns;\n    ColumnInfoIter columnIter(&m_compressingColumns, columnList);\n    const CompressionColumnInfo *column = nullptr;\n    while ((column = columnIter.nextInfo()) != nullptr) {\n        resultColumns.emplace_back(Column(column->getColumn()));\n        resultColumns.emplace_back(Column(column->getTypeColumn()));\n        if (column->getCompressionType() == CompressionType::VariousDict) {\n            resultColumns.emplace_back(Column(column->getMatchColumn()));\n        }\n    }\n    return StatementSelect().select(resultColumns).from(m_table).where(Column::rowid() == BindParameter());\n}\n\nStatementUpdate\nCompressionTableInfo::getUpdateCompressColumnStatement(ColumnInfoPtrList *columnList) const\n{\n    StatementUpdate update\n    = StatementUpdate().update(m_table).where(Column::rowid() == BindParameter(1));\n    int index = 2;\n    ColumnInfoIter columnIter(&getColumnInfos(), columnList);\n    const CompressionColumnInfo *column = nullptr;\n    while ((column = columnIter.nextInfo()) != nullptr) {\n        update.set(Column(column->getColumn())).to(BindParameter(index++));\n        update.set(Column(column->getTypeColumn())).to(BindParameter(index++));\n    }\n    return update;\n}\n\nbool CompressionTableInfo::stepSelectAndUpdateUncompressRowStatement(\nHandleStatement *select, HandleStatement *update, int64_t rowid, ColumnInfoPtrList *columnList) const\n{\n    select->reset();\n    select->bindInteger(rowid);\n    if (!select->step()) {\n        return false;\n    }\n    if (select->done()) {\n        return true;\n    }\n    update->reset();\n    update->bindInteger(rowid);\n\n    int preOffset = 0;\n    int columnIndex = 0;\n    ColumnInfoIter columnIter(&getColumnInfos(), columnList);\n    const CompressionColumnInfo *column = nullptr;\n    while ((column = columnIter.nextInfo()) != nullptr) {\n        int selectIndex = 2 * columnIndex + preOffset;\n        int updateIndex = 2 * columnIndex + 2;\n        ColumnType valueType = select->getType(selectIndex);\n        bool isUncompressed = select->getType(selectIndex + 1) == ColumnType::Null;\n\n        if (valueType >= ColumnType::Text && isUncompressed) {\n            UnsafeData value = select->getBLOB(selectIndex);\n            Optional<UnsafeData> compressedValue;\n            CompressedType compressedType = CompressedType::ZSTDDict;\n            switch (column->getCompressionType()) {\n            case CompressionType::Normal: {\n                compressedType = CompressedType::ZSTDNormal;\n                compressedValue = CompressionCenter::shared().compressContent(\n                value, 0, static_cast<InnerHandle *>(select->getHandle()));\n            } break;\n            case CompressionType::Dict: {\n                compressedValue = CompressionCenter::shared().compressContent(\n                value, column->getDictId(), static_cast<InnerHandle *>(select->getHandle()));\n            } break;\n            case CompressionType::VariousDict: {\n                int64_t matchValue = select->getInteger(selectIndex + 2);\n                preOffset++;\n                compressedValue = CompressionCenter::shared().compressContent(\n                value,\n                column->getMatchDictId(matchValue),\n                static_cast<InnerHandle *>(select->getHandle()));\n            } break;\n            }\n            if (compressedValue.failed()) {\n                return false;\n            }\n            WCTAssert(compressedValue.value().size() <= value.size());\n\n            if (compressedValue.value().size() < value.size()) {\n                update->bindBLOB(compressedValue.value(), updateIndex);\n                update->bindInteger(\n                WCDBMergeCompressionType(compressedType, valueType), updateIndex + 1);\n            } else {\n                if (valueType == ColumnType::Text) {\n                    update->bindText(select->getText(selectIndex), updateIndex);\n                } else {\n                    update->bindBLOB(value, updateIndex);\n                }\n                update->bindInteger(WCDBMergeCompressionType(CompressedType::None, valueType),\n                                    updateIndex + 1);\n            }\n        } else {\n            switch (valueType) {\n            case ColumnType::Null:\n                update->bindNull(updateIndex);\n                break;\n            case ColumnType::Integer:\n                update->bindInteger(select->getInteger(selectIndex), updateIndex);\n                break;\n            case ColumnType::Float:\n                update->bindDouble(select->getDouble(selectIndex), updateIndex);\n                break;\n            case ColumnType::Text:\n                update->bindText(select->getText(selectIndex), updateIndex);\n                break;\n            case ColumnType::BLOB:\n                update->bindBLOB(select->getBLOB(selectIndex), updateIndex);\n                break;\n            }\n            update->bindInteger(select->getInteger(selectIndex + 1), updateIndex + 1);\n        }\n        columnIndex++;\n    }\n    if (!update->step()) {\n        return false;\n    }\n    return true;\n}\n\nStatementSelect CompressionTableInfo::getSelectCompressedRowIdStatement(int64_t maxRowId) const\n{\n    Expression condition;\n    for (auto &column : m_compressingColumns) {\n        if (condition.syntax().isValid()) {\n            condition = condition || Column(column.getTypeColumn()).notNull();\n        } else {\n            condition = Column(column.getTypeColumn()).notNull();\n        }\n    }\n    return StatementSelect()\n    .select(Column::rowid())\n    .from(m_table)\n    .where(condition && Column::rowid() < maxRowId)\n    .order(Column::rowid().asOrder(Order::DESC));\n}\n\nStatementSelect\nCompressionTableInfo::getSelectCompressedRowStatement(ColumnInfoPtrList *columnList) const\n{\n    ResultColumns resultColumns;\n    ColumnInfoIter columnIter(&m_compressingColumns, columnList);\n    const CompressionColumnInfo *column = nullptr;\n    while ((column = columnIter.nextInfo()) != nullptr) {\n        resultColumns.emplace_back(CoreFunction::decompress(\n        Column(column->getColumn()), Column(column->getTypeColumn())));\n    }\n    return StatementSelect().select(resultColumns).from(m_table).where(Column::rowid() == BindParameter());\n}\n\nbool CompressionTableInfo::stepSelectAndUpdateCompressedRowStatement(\nHandleStatement *select, HandleStatement *update, int64_t rowid, ColumnInfoPtrList *columnList) const\n{\n    select->bindInteger(rowid);\n    if (!select->step()) {\n        return false;\n    }\n    if (select->done()) {\n        return true;\n    }\n    update->bindInteger(rowid);\n\n    int columnIndex = 0;\n    ColumnInfoIter columnIter(&getColumnInfos(), columnList);\n    while (columnIter.nextInfo() != nullptr) {\n        int selectIndex = columnIndex;\n        int updateIndex = 2 * columnIndex + 2;\n        ColumnType valueType = select->getType(selectIndex);\n\n        switch (valueType) {\n        case ColumnType::Null:\n            update->bindNull(updateIndex);\n            break;\n        case ColumnType::Integer:\n            update->bindInteger(select->getInteger(selectIndex), updateIndex);\n            break;\n        case ColumnType::Float:\n            update->bindDouble(select->getDouble(selectIndex), updateIndex);\n            break;\n        case ColumnType::Text:\n            update->bindText(select->getText(selectIndex), updateIndex);\n            break;\n        case ColumnType::BLOB:\n            update->bindBLOB(select->getBLOB(selectIndex), updateIndex);\n            break;\n        }\n        update->bindNull(updateIndex + 1);\n        columnIndex++;\n    }\n    if (!update->step()) {\n        return false;\n    }\n\n    select->reset();\n    update->reset();\n    return true;\n}\n\nCompressionTableInfo::ColumnInfoIter::ColumnInfoIter(const ColumnInfoList *infoList,\n                                                     ColumnInfoPtrList *infoPtrList)\n: m_infoList(infoList), m_infoPtrList(infoPtrList)\n{\n    WCTAssert(infoList != nullptr);\n    if (infoPtrList != nullptr) {\n        m_infoPtrIter = infoPtrList->begin();\n    } else {\n        m_infoIter = infoList->begin();\n    }\n}\n\nconst CompressionColumnInfo *CompressionTableInfo::ColumnInfoIter::nextInfo()\n{\n    const CompressionColumnInfo *info = nullptr;\n    if (m_infoPtrList != nullptr) {\n        if (m_infoPtrIter != m_infoPtrList->end()) {\n            info = *m_infoPtrIter;\n            m_infoPtrIter++;\n        }\n    } else {\n        if (m_infoIter != m_infoList->end()) {\n            info = &(*m_infoIter);\n            m_infoIter++;\n        }\n    }\n    return info;\n}\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/core/compression/CompressionInfo.hpp",
    "content": "//\n// Created by qiuwenchen on 2023/11/21.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"Column.hpp\"\n#include \"ColumnType.hpp\"\n#include \"StringView.hpp\"\n#include \"ZSTDDict.hpp\"\n#include <atomic>\n#include <list>\n#include <memory>\n#include <unordered_map>\n\nnamespace WCDB {\n\nclass HandleStatement;\nclass CompressionTableInfo;\n\nenum class CompressionType : char {\n    Normal,\n    Dict,\n    VariousDict,\n};\n\nclass CompressionColumnInfo {\n    friend CompressionTableInfo;\n\npublic:\n    using DictId = ZSTDDict::DictId;\n    using Integer = ColumnTypeInfo<ColumnType::Integer>::UnderlyingType;\n    CompressionColumnInfo() = delete;\n    CompressionColumnInfo(const Column &column, CompressionType type);\n    CompressionColumnInfo(const Column &column, const Column &matchColumn);\n    CompressionColumnInfo(const CompressionColumnInfo &other);\n    CompressionColumnInfo(CompressionColumnInfo &&other);\n    CompressionColumnInfo &operator=(const CompressionColumnInfo &other);\n    CompressionColumnInfo &operator=(CompressionColumnInfo &&other);\n\n    StringView getColumn() const;\n    void setColumnIndex(uint16_t index) const;\n    uint16_t getColumnIndex() const;\n\n    const StringView &getTypeColumn() const;\n    void setTypeColumnIndex(uint16_t index) const;\n    uint16_t getTypeColumnIndex() const;\n\n    const StringView &getMatchColumn() const;\n    void setMatchColumnIndex(uint16_t index) const;\n    uint16_t getMatchColumnIndex() const;\n\n    CompressionType getCompressionType() const;\n    DictId getDictId() const;\n    DictId getMatchDictId(const Integer &matchValue) const;\n\n    void setCommonDict(DictId dictId);\n    void addMatchDict(const Integer &matchValue, DictId dictId);\n\nprivate:\n    mutable std::atomic_ushort m_columnIndex;\n    StringView m_typeColumn;\n    mutable std::atomic_ushort m_typeColumnIndex;\n    StringView m_matchColumn;\n    mutable std::atomic_ushort m_matchColumnIndex;\n\n    CompressionType m_compressionType;\n    DictId m_commonDictID;\n    std::unordered_map<Integer, DictId> m_matchDicts;\n};\n\nclass CompressionTableBaseInfo {\npublic:\n    CompressionTableBaseInfo(const UnsafeStringView &table);\n    bool shouldCompress() const;\n    const StringView &getTable() const;\n\n    typedef const std::list<CompressionColumnInfo> ColumnInfoList;\n    ColumnInfoList &getColumnInfos() const;\n\nprotected:\n    StringView m_table;\n    std::list<CompressionColumnInfo> m_compressingColumns;\n    bool m_replaceCompression;\n};\n\nclass CompressionTableUserInfo : public CompressionTableBaseInfo {\npublic:\n    CompressionTableUserInfo(const UnsafeStringView &table);\n    CompressionTableUserInfo(const UnsafeStringView &table,\n                             const std::list<CompressionColumnInfo> &columns);\n    void addCompressingColumn(const CompressionColumnInfo &info);\n    void enableReplaceCompresssion();\n};\n\nclass CompressionTableInfo : public CompressionTableBaseInfo {\npublic:\n    CompressionTableInfo() = delete;\n    CompressionTableInfo(const UnsafeStringView &table) = delete;\n    CompressionTableInfo(const CompressionTableUserInfo &userInfo);\n    void addCompressingColumn(const CompressionColumnInfo &info);\n\n    void setMinCompressedRowid(int64_t rowid) const;\n    int64_t getMinCompressedRowid() const;\n\n    bool needCheckColumns() const;\n    void setNeedCheckColumns(bool needCheck) const;\n\n    StringView getCompressionDescription() const;\n    bool shouldReplaceCompression() const;\n\nprivate:\n    mutable int64_t m_minCompressedRowid;\n    mutable bool m_needCheckColumn;\n\n#pragma mark - Compress Statements\npublic:\n    typedef const std::list<const CompressionColumnInfo *> ColumnInfoPtrList;\n    /*\n     SELECT rowid FROM compressingTable\n     WHERE rowid < ?\n     (WCDB_CT_compressingColumnA IS NULL OR WCDB_CT_compressingColumnB IS NULL ...)\n     ORDER BY rowid DESC\n     LIMIT 10\n     */\n    StatementSelect getSelectNeedCompressRowIdStatement() const;\n\n    /*\n     SELECT * FROM compressingTable WHERE rowid = ?\n     */\n    StatementSelect getSelectRowStatement() const;\n\n    /*\n     DELECT FROM compressingTable WHERE rowid = ?\n     */\n    StatementDelete getDelectRowStatement() const;\n\n    /*\n     INSERT INTO compressingTable VALUES(?1, ?2, ...)\n     */\n    StatementInsert getInsertNewRowStatement(size_t valueCount) const;\n\n    /*\n     SELECT compressingColumnA, WCDB_CT_compressingColumnA,\n     compressingColumnB, WCDB_CT_compressingColumnB ...\n     FROM compressingTable\n     WHERE rowid == ?\n     */\n    StatementSelect\n    getSelectUncompressRowStatement(ColumnInfoPtrList *columnList = nullptr) const;\n\n    /*\n     UPDATE compressingTable\n     SET compressingColumnA = ?2, WCDB_CT_compressingColumnA = ?3,\n     compressingColumnB = ?4, WCDB_CT_compressingColumnB = ?5 ...\n     WHERE rowid == ?1\n     */\n    StatementUpdate\n    getUpdateCompressColumnStatement(ColumnInfoPtrList *columnList = nullptr) const;\n\n    bool stepSelectAndUpdateUncompressRowStatement(HandleStatement *select,\n                                                   HandleStatement *update,\n                                                   int64_t rowid,\n                                                   ColumnInfoPtrList *columnList\n                                                   = nullptr) const;\n\n#pragma mark - Revert compression\npublic:\n    /*\n     SELECT rowid FROM compressingTable\n     WHERE rowid < ? AND (WCDB_CT_compressingColumnA NOTNULL OR WCDB_CT_compressingColumnB NOTNULL ...)\n     ORDER BY rowid DESC\n     */\n    StatementSelect getSelectCompressedRowIdStatement(int64_t maxRowId) const;\n\n    /*\n     SELECT wcdb_decompress(compressingColumnA, WCDB_CT_compressingColumnA),\n     wcdb_decompress(compressingColumnB, WCDB_CT_compressingColumnB) ...\n     FROM compressingTable\n     WHERE rowid == ?\n     */\n    StatementSelect\n    getSelectCompressedRowStatement(ColumnInfoPtrList *columnList = nullptr) const;\n\n    bool stepSelectAndUpdateCompressedRowStatement(HandleStatement *select,\n                                                   HandleStatement *update,\n                                                   int64_t rowid,\n                                                   ColumnInfoPtrList *columnList\n                                                   = nullptr) const;\n\nprivate:\n    class ColumnInfoIter {\n    public:\n        ColumnInfoIter(ColumnInfoList *infoList, ColumnInfoPtrList *infoPtrList);\n        const CompressionColumnInfo *nextInfo();\n\n    private:\n        ColumnInfoList *m_infoList;\n        ColumnInfoPtrList *m_infoPtrList;\n        ColumnInfoList::const_iterator m_infoIter;\n        ColumnInfoPtrList::const_iterator m_infoPtrIter;\n    };\n};\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/core/compression/CompressionRecord.cpp",
    "content": "//\n// Created by qiuwenchen on 2023/11/26.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"CompressionRecord.hpp\"\n#include \"CompressionConst.hpp\"\n\nnamespace WCDB {\n\nconst StringView &CompressionRecord::tableName = CompressionRecordTable;\nconst StringView &CompressionRecord::columnTable = CompressionRecordColumn_Table;\nconst StringView &CompressionRecord::columnCompressColumns = CompressionRecordColumn_Columns;\nconst StringView &CompressionRecord::columnRowdid = CompressionRecordColumn_Rowid;\n\nStatementCreateTable CompressionRecord::getCreateTableStatement()\n{\n    StatementCreateTable createTable;\n    createTable.createTable(tableName).ifNotExists();\n    createTable.define(\n    ColumnDef(columnTable, ColumnType::Text).constraint(ColumnConstraint().primaryKey()));\n    createTable.define(ColumnDef(columnCompressColumns, ColumnType::Text)\n                       .constraint(ColumnConstraint().notNull()));\n    createTable.define(ColumnDef(columnRowdid, ColumnType::Integer));\n    createTable.withoutRowID();\n    return createTable;\n}\n\nStatementInsert CompressionRecord::getInsertValueStatement()\n{\n    return StatementInsert()\n    .insertIntoTable(tableName)\n    .orReplace()\n    .columns({ columnTable, columnCompressColumns, columnRowdid })\n    .values(BindParameter::bindParameters(3));\n}\n\nStatementDelete CompressionRecord::getDeleteRecordStatement(const UnsafeStringView &table)\n{\n    return StatementDelete().deleteFrom(tableName).where(Column(columnTable) == table);\n}\n\nStatementUpdate\nCompressionRecord::getUpdateRecordStatement(const UnsafeStringView &oldTable,\n                                            const UnsafeStringView &newTable)\n{\n    return StatementUpdate().update(tableName).set(columnTable).to(newTable).where(Column(columnTable) == oldTable);\n}\n\nStatementDropTable CompressionRecord::getDropTableStatement()\n{\n    return StatementDropTable().dropTable(tableName).ifExists();\n}\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/common/core/compression/CompressionRecord.hpp",
    "content": "//\n// Created by qiuwenchen on 2023/11/26.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"StringView.hpp\"\n#include \"WINQ.h\"\n\nnamespace WCDB {\n\ntypedef struct CompressionRecord {\n    static const StringView& tableName;\n\n    StringView table;\n    static const StringView& columnTable;\n\n    StringView columns;\n    static const StringView& columnCompressColumns;\n\n    int64_t minCompressedRowid;\n    static const StringView& columnRowdid;\n\n    /*\n     CREATE TABLE IF NOT EXIST wcdb_builtin_compression_record\n     (tableName TEXT PRIMARY KEY, columns TEXT NOT NULL, rowid INTEGER)\n     WITHOUT ROWID\n     */\n    static StatementCreateTable getCreateTableStatement();\n\n    /*\n     INSERT OR REPLACE INTO wcdb_builtin_compression_record\n     (tableName, columns rowid)\n     VALUES(?1, ?2, ?3)\n     */\n    static StatementInsert getInsertValueStatement();\n\n    /*\n     DELETE FROM wcdb_builtin_compression_record\n     WHERE tableName == xxx\n     */\n    static StatementDelete getDeleteRecordStatement(const UnsafeStringView& table);\n\n    /*\n     UPDATE wcdb_builtin_compression_record\n     SET tableName = newTable\n     WHERE tableName == oldTable\n     */\n    static StatementUpdate getUpdateRecordStatement(const UnsafeStringView& oldTable,\n                                                    const UnsafeStringView& newTable);\n\n    /*\n     DROP TABLE IF EXIST wcdb_builtin_compression_record\n     */\n    static StatementDropTable getDropTableStatement();\n} CompressionRecord;\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/core/compression/DecompressFunction.cpp",
    "content": "//\n// Created by qiuwenchen on 2023/11/26.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"DecompressFunction.hpp\"\n#include \"Assertion.hpp\"\n#include \"CompressionCenter.hpp\"\n#include \"CompressionConst.hpp\"\n#include \"WCDBError.hpp\"\n\nnamespace WCDB {\n\nDecompressFunction::DecompressFunction(void* userContext, ScalarFunctionAPI& apiObj)\n: AbstractScalarFunctionObject(userContext, apiObj)\n{\n}\n\nDecompressFunction::~DecompressFunction() = default;\n\nvoid DecompressFunction::process(ScalarFunctionAPI& apiObj)\n{\n    WCTAssert(apiObj.getValueCount() == 2);\n    if (apiObj.getValueCount() != 2) {\n        apiObj.setErrorResult(Error::Code::Misuse,\n                              StringView::formatted(\"Invalid parameter count for compress funciton: %d\",\n                                                    apiObj.getValueCount()));\n        return;\n    }\n    ColumnType valueType = apiObj.getValueType(0);\n    int type = (int) apiObj.getIntValue(1);\n    CompressedType compressionType = WCDBGetCompressedType(type);\n    if (compressionType <= CompressedType::None || compressionType > CompressedType::ZSTDNormal\n        || valueType != ColumnType::BLOB) {\n        transferValue(valueType, apiObj);\n        return;\n    }\n    UnsafeData data = apiObj.getBlobValue(0);\n    if (data.size() == 0) {\n        transferValue(valueType, apiObj);\n        return;\n    }\n    CompressionCenter::shared().decompressContent(\n    data, compressionType == CompressedType::ZSTDDict, WCDBGetOriginType(type), apiObj);\n}\n\nvoid DecompressFunction::transferValue(ColumnType type, ScalarFunctionAPI& apiObj)\n{\n    switch (type) {\n    case Syntax::ColumnType::Integer:\n        apiObj.setIntResult(apiObj.getIntValue(0));\n        break;\n    case Syntax::ColumnType::Float:\n        apiObj.setFloatResult(apiObj.getFloatValue(0));\n        break;\n    case Syntax::ColumnType::Text:\n        apiObj.setTextResult(apiObj.getTextValue(0));\n        break;\n    case Syntax::ColumnType::BLOB:\n        apiObj.setBlobResult(apiObj.getBlobValue(0));\n        break;\n    default:\n        apiObj.setNullResult();\n        break;\n    }\n}\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/core/compression/DecompressFunction.hpp",
    "content": "//\n// Created by qiuwenchen on 2023/11/26.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"ColumnType.hpp\"\n#include \"ScalarFunctionModule.hpp\"\n\nnamespace WCDB {\n\nclass DecompressFunction : public AbstractScalarFunctionObject {\npublic:\n    DecompressFunction(void* userContext, ScalarFunctionAPI& apiObj);\n    virtual ~DecompressFunction() override;\n    virtual void process(ScalarFunctionAPI& apiObj) override final;\n\nprivate:\n    void transferValue(ColumnType type, ScalarFunctionAPI& apiObj);\n};\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/core/compression/ZSTDContext.cpp",
    "content": "//\n// Created by 陈秋文 on 2023/11/26.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"ZSTDContext.hpp\"\n#include <memory>\n#include <stdlib.h>\n#if defined(WCDB_ZSTD) && WCDB_ZSTD\n#include <zstd/zstd.h>\n#endif\n\nnamespace WCDB {\n\nZSTDContext::ZSTDContext()\n: m_buffer(nullptr), m_bufferSize(0), m_cctx(nullptr), m_dctx(nullptr)\n{\n}\n\nZSTDContext::~ZSTDContext()\n{\n#if defined(WCDB_ZSTD) && WCDB_ZSTD\n    if (m_cctx != nullptr) {\n        ZSTD_freeCCtx((ZSTD_CCtx*) m_cctx);\n    }\n    if (m_dctx != nullptr) {\n        ZSTD_freeDCtx((ZSTD_DCtx*) m_dctx);\n    }\n#endif\n    if (m_buffer != nullptr) {\n        free(m_buffer);\n    }\n}\n\nZCCtx* ZSTDContext::getOrCreateCCtx()\n{\n    if (m_cctx == nullptr) {\n#if defined(WCDB_ZSTD) && WCDB_ZSTD\n        m_cctx = (ZCCtx*) ZSTD_createCCtx();\n#endif\n    }\n    return m_cctx;\n}\n\nZDCtx* ZSTDContext::getOrCreateDCtx()\n{\n    if (m_dctx == nullptr) {\n#if defined(WCDB_ZSTD) && WCDB_ZSTD\n        m_dctx = (ZDCtx*) ZSTD_createDCtx();\n#endif\n    }\n    return m_dctx;\n}\n\nvoid* ZSTDContext::getOrCreateBuffer(size_t size)\n{\n    if (size < MaxBufferSize && m_bufferSize >= MaxBufferSize) {\n        // Free accidentally large buffer\n        free(m_buffer);\n        m_buffer = nullptr;\n    }\n    if (m_bufferSize > size && m_buffer != nullptr) {\n        return m_buffer;\n    }\n    if (m_buffer != nullptr) {\n        free(m_buffer);\n    }\n    m_buffer = malloc(size);\n    m_bufferSize = size;\n    return m_buffer;\n}\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/common/core/compression/ZSTDContext.hpp",
    "content": "//\n// Created by 陈秋文 on 2023/11/26.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n#include \"SysTypes.h\"\n\nnamespace WCDB {\n\ntypedef struct ZCCtx ZCCtx;\ntypedef struct ZDCtx ZDCtx;\n\nclass ZSTDContext {\npublic:\n    ZSTDContext();\n    ~ZSTDContext();\n    ZCCtx* getOrCreateCCtx();\n    ZDCtx* getOrCreateDCtx();\n    void* getOrCreateBuffer(size_t size);\n\nprivate:\n    static constexpr const size_t MaxBufferSize = 1024 * 1024;\n    void* m_buffer;\n    size_t m_bufferSize;\n    ZCCtx* m_cctx;\n    ZDCtx* m_dctx;\n};\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/common/core/compression/ZSTDDict.cpp",
    "content": "//\n// Created by qiuwenchen on 2023/11/19.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"ZSTDDict.hpp\"\n#include \"Assertion.hpp\"\n#include \"Notifier.hpp\"\n#include \"WCDBError.hpp\"\n#include <stdlib.h>\n#if defined(WCDB_ZSTD) && WCDB_ZSTD\n#define ZSTD_STATIC_LINKING_ONLY\n#include <zstd/zdict.h>\n#include <zstd/zstd.h>\n#endif\n\nnamespace WCDB {\n\nZSTDDict::ZSTDDict()\n: m_dictId(0), m_cDict(nullptr), m_dDict(nullptr), m_dictUseCount(0)\n{\n}\n\nZSTDDict::ZSTDDict(ZSTDDict&& dict)\n: m_dictId(dict.m_dictId)\n, m_cDict(dict.m_cDict)\n, m_dDict(dict.m_dDict)\n, m_memory(std::move(dict.m_memory))\n, m_dictUseCount(dict.m_dictUseCount)\n{\n    dict.m_dictId = 0;\n    dict.m_cDict = nullptr;\n    dict.m_dDict = nullptr;\n    dict.m_memory.clear();\n    dict.m_dictUseCount = 0;\n}\n\nZSTDDict& ZSTDDict::operator=(ZSTDDict&& other)\n{\n    clearDict();\n    m_dictId = other.m_dictId;\n    m_cDict = other.m_cDict;\n    m_dDict = other.m_dDict;\n\n    other.m_dictId = 0;\n    other.m_cDict = nullptr;\n    other.m_dDict = nullptr;\n\n    return *this;\n}\n\nZSTDDict::~ZSTDDict()\n{\n    clearDict();\n}\n\n#if defined(WCDB_ZSTD) && WCDB_ZSTD\n\nvoid ZSTDDict::clearDict()\n{\n    ZSTD_freeCDict((ZSTD_CDict*) m_cDict);\n    ZSTD_freeDDict((ZSTD_DDict*) m_dDict);\n    WCTAssert(m_memory.size() == 0);\n}\n\nbool ZSTDDict::loadData(const UnsafeData& data)\n{\n    WCTAssert(m_dictId == 0 && m_cDict == nullptr && m_dDict == nullptr);\n    if (data.empty()) {\n        Error error(Error::Code::ZstdError, Error::Level::Error, \"Empty dict!\");\n        Notifier::shared().notify(error);\n        SharedThreadedErrorProne::setThreadedError(std::move(error));\n        return false;\n    }\n\n    ZSTD_compressionParameters cparams\n    = ZSTD_getCParams(ZSTD_CLEVEL_DEFAULT, ZSTD_CONTENTSIZE_UNKNOWN, data.size());\n    m_cDict = (ZCDict*) ZSTD_createCDict_advanced(data.buffer(),\n                                                  data.size(),\n                                                  ZSTD_dlm_byCopy,\n                                                  ZSTD_dct_auto,\n                                                  cparams,\n                                                  {\n                                                  dictMemAlloc,\n                                                  dictMemFree,\n                                                  this,\n                                                  });\n    if (m_cDict == nullptr) {\n        Error error(Error::Code::ZstdError, Error::Level::Error, \"Create compress dict failed!\");\n        error.infos.insert_or_assign(\"DictSize\", data.size());\n        Notifier::shared().notify(error);\n        SharedThreadedErrorProne::setThreadedError(std::move(error));\n        return false;\n    }\n    initializeMemoryVerification();\n\n    m_dDict = (ZDDcit*) ZSTD_createDDict(data.buffer(), data.size());\n    if (m_dDict == nullptr) {\n        Error error(Error::Code::ZstdError, Error::Level::Error, \"Create decompress dict failed!\");\n        error.infos.insert_or_assign(\"DictSize\", data.size());\n        Notifier::shared().notify(error);\n        SharedThreadedErrorProne::setThreadedError(std::move(error));\n        return false;\n    }\n    m_dictId = (DictId) ZSTD_getDictID_fromDDict((ZSTD_DDict*) m_dDict);\n    if (m_dictId == 0) {\n        Error error(Error::Code::ZstdError,\n                    Error::Level::Error,\n                    \"The dictionary is not conformant to ZSTD specification\");\n        error.infos.insert_or_assign(\"DictSize\", data.size());\n        Notifier::shared().notify(error);\n        SharedThreadedErrorProne::setThreadedError(std::move(error));\n        return false;\n    }\n    return true;\n}\n\n#else\n\nvoid ZSTDDict::clearDict()\n{\n}\n\nbool ZSTDDict::loadData(const UnsafeData& data)\n{\n    Error error(Error::Code::ZstdError, Error::Level::Error, \"You need to build WCDB with WCDB_ZSTD macro\");\n    error.infos.insert_or_assign(\"DictSize\", data.size());\n    Notifier::shared().notify(error);\n    SharedThreadedErrorProne::setThreadedError(std::move(error));\n    return false;\n}\n\n#endif\n\nZSTDDict::DictId ZSTDDict::getDictId() const\n{\n    return m_dictId;\n}\n\nZCDict* ZSTDDict::getCDict() const\n{\n    return m_cDict;\n}\n\nZDDcit* ZSTDDict::getDDict() const\n{\n    return m_dDict;\n}\n\n#pragma mark - Memory verification\nbool ZSTDDict::tryMemoryVerification() const\n{\n    if (++m_dictUseCount < kDictMaxUseCountBeforeCheck) {\n        return true;\n    }\n    for (const auto& iter : m_memory) {\n        UnsafeData dictMemory((unsigned char*) iter.first, iter.second.first);\n        if (dictMemory.hash() != iter.second.second) {\n            return false;\n        }\n    }\n    m_dictUseCount = 0;\n    return true;\n}\n\nvoid* ZSTDDict::dictMemAlloc(void* opaque, size_t size)\n{\n    ZSTDDict* dict = static_cast<ZSTDDict*>(opaque);\n    WCTAssert(dict != nullptr);\n    WCTAssert(dict->m_cDict == nullptr);\n    void* buffer = malloc(size);\n    if (buffer != nullptr) {\n        dict->m_memory[buffer] = std::make_pair(size, 0);\n    }\n    return buffer;\n}\n\nvoid ZSTDDict::dictMemFree(void* opaque, void* address)\n{\n    ZSTDDict* dict = static_cast<ZSTDDict*>(opaque);\n    WCTAssert(dict != nullptr);\n    WCTAssert(dict->m_cDict != nullptr);\n    WCTAssert(address != nullptr);\n    if (address == nullptr) {\n        return;\n    }\n    dict->m_memory.erase(address);\n    free(address);\n}\n\nvoid ZSTDDict::initializeMemoryVerification()\n{\n    for (auto& iter : m_memory) {\n        UnsafeData dictMemory((unsigned char*) iter.first, iter.second.first);\n        iter.second.second = dictMemory.hash();\n    }\n}\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/common/core/compression/ZSTDDict.hpp",
    "content": "//\n// Created by qiuwenchen on 2023/11/19.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"Data.hpp\"\n#include \"SharedThreadedErrorProne.hpp\"\n#include \"StringView.hpp\"\n#include \"UnsafeData.hpp\"\n#include \"WCDBOptional.hpp\"\n#include <unordered_map>\n\nnamespace WCDB {\n\ntypedef struct ZCDict ZCDict;\ntypedef struct ZDDcit ZDDcit;\n\nclass ZSTDDict : public SharedThreadedErrorProne {\npublic:\n    ZSTDDict();\n    ZSTDDict(ZSTDDict&& dict);\n    ~ZSTDDict();\n\n    ZSTDDict(const ZSTDDict&) = delete;\n    ZSTDDict& operator=(const ZSTDDict&) = delete;\n    ZSTDDict& operator=(ZSTDDict&&);\n\n    bool loadData(const UnsafeData& data);\n\n    typedef uint16_t DictId;\n    DictId getDictId() const;\n    ZCDict* getCDict() const;\n    ZDDcit* getDDict() const;\n\nprivate:\n    void clearDict();\n    DictId m_dictId;\n    ZCDict* m_cDict;\n    ZDDcit* m_dDict;\n\n#pragma mark - Memory verification\npublic:\n    bool tryMemoryVerification() const;\n\nprivate:\n    static void* dictMemAlloc(void* opaque, size_t size);\n    static void dictMemFree(void* opaque, void* address);\n\n    void initializeMemoryVerification();\n\n    std::unordered_map<void*, std::pair<size_t, uint32_t>> m_memory;\n\n    static constexpr int kDictMaxUseCountBeforeCheck = 10;\n    mutable int m_dictUseCount;\n};\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/common/core/config/AutoBackupConfig.cpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/26\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"AutoBackupConfig.hpp\"\n#include \"Assertion.hpp\"\n#include \"CommonCore.hpp\"\n#include \"Factory.hpp\"\n#include \"FileManager.hpp\"\n#include \"InnerHandle.hpp\"\n#include \"Notifier.hpp\"\n#include \"StringView.hpp\"\n\nnamespace WCDB {\n\nAutoBackupOperator::~AutoBackupOperator() = default;\n\nAutoBackupConfig::AutoBackupConfig(const std::shared_ptr<AutoBackupOperator>& operator_)\n: Config(), m_identifier(StringView::formatted(\"Backup-%p\", this)), m_operator(operator_)\n{\n    WCTAssert(m_operator != nullptr);\n}\n\nAutoBackupConfig::~AutoBackupConfig() = default;\n\nbool AutoBackupConfig::invoke(InnerHandle* handle)\n{\n    AbstractHandle::CheckPointNotification notifination\n    = { std::bind(&AutoBackupConfig::onCheckpointBegin,\n                  this,\n                  std::placeholders::_1,\n                  std::placeholders::_2,\n                  std::placeholders::_3,\n                  std::placeholders::_4,\n                  std::placeholders::_5),\n        std::bind(&AutoBackupConfig::onCheckpointPage,\n                  this,\n                  std::placeholders::_1,\n                  std::placeholders::_2,\n                  std::placeholders::_3),\n        std::bind(&AutoBackupConfig::onCheckpointFinish,\n                  this,\n                  std::placeholders::_1,\n                  std::placeholders::_2,\n                  std::placeholders::_3,\n                  std::placeholders::_4,\n                  std::placeholders::_5) };\n    handle->setNotificationWhenCheckpointed(m_identifier, notifination);\n\n    return true;\n}\n\nbool AutoBackupConfig::uninvoke(InnerHandle* handle)\n{\n    handle->setNotificationWhenCheckpointed(m_identifier, NullOpt);\n    return true;\n}\n\nvoid AutoBackupConfig::tryRegisterIncrementalMaterial(const UnsafeStringView& path,\n                                                      SharedIncrementalMaterial material)\n{\n    LockGuard lock(m_lock);\n    m_materials[path] = material;\n}\n\nSharedIncrementalMaterial\nAutoBackupConfig::tryGetIncrementalMaterial(const UnsafeStringView& path)\n{\n    LockGuard lock(m_lock);\n    auto iter = m_materials.find(path);\n    if (iter != m_materials.end()) {\n        return iter->second;\n    }\n    return nullptr;\n}\n\nvoid AutoBackupConfig::onCheckpointBegin(AbstractHandle* handle,\n                                         uint32_t nBackFill,\n                                         uint32_t mxFrame,\n                                         uint32_t salt1,\n                                         uint32_t salt2)\n{\n    WCDB_UNUSED(mxFrame);\n    LockGuard lock(m_lock);\n    auto& path = handle->getPath();\n    auto iter = m_materials.find(path);\n    if (iter == m_materials.end()) {\n        return;\n    }\n    auto& material = iter->second;\n    auto& curSalt = material->info.currentWalSalt;\n    uint32_t& currentNBackFill = material->info.currentNBackFill;\n    bool& lastCheckPointFinish = material->info.lastCheckPointFinish;\n    m_checkpointPages[path] = Pages();\n    if (curSalt.first == salt1 && curSalt.second == salt2 && currentNBackFill == nBackFill) {\n        return;\n    }\n    if (Repair::Wal::isCheckpointIncreasedSalt(curSalt, { salt1, salt2 })\n        && nBackFill == 0 && lastCheckPointFinish) {\n        curSalt.first = salt1;\n        curSalt.second = salt2;\n        currentNBackFill = nBackFill;\n        lastCheckPointFinish = false;\n        return;\n    }\n\n    Error error(Error::Code::Error, Error::Level::Warning, \"Expired incremental Material\");\n    error.infos.insert_or_assign(ErrorStringKeySource, ErrorSourceRepair);\n    error.infos.insert_or_assign(ErrorStringKeyPath, path);\n    error.infos.insert_or_assign(\n    \"currentSalt\", (((uint64_t) curSalt.second) << 32) | curSalt.first);\n    error.infos.insert_or_assign(\"newSalt\", (((uint64_t) salt2) << 32) | salt1);\n    error.infos.insert_or_assign(\"currentNBackFill\", currentNBackFill);\n    error.infos.insert_or_assign(\"newNBackFill\", nBackFill);\n\n    m_materials.erase(path);\n    m_checkpointPages.erase(path);\n    FileManager::removeItem(Repair::Factory::incrementalMaterialPathForDatabase(path));\n\n    std::thread asyncNotify([=]() {\n        Error newError = error;\n        Notifier::shared().notify(newError);\n    });\n    asyncNotify.detach();\n}\n\nvoid AutoBackupConfig::onCheckpointPage(AbstractHandle* handle, uint32_t pageNo, const UnsafeData& data)\n{\n    if (data.size() == 0) {\n        return;\n    }\n    LockGuard lock(m_lock);\n    auto& path = handle->getPath();\n    auto iter = m_checkpointPages.find(path);\n    if (iter == m_checkpointPages.end()) {\n        return;\n    }\n\n    Repair::IncrementalMaterial::Page newPage;\n    newPage.number = pageNo;\n    newPage.type = Repair::Page::convertToPageType(data.buffer()[0]);\n    if (newPage.type == Repair::Page::Type::LeafTable) {\n        newPage.hash = data.hash();\n    } else {\n        newPage.hash = 0;\n    }\n    iter->second[pageNo] = newPage;\n}\n\nvoid AutoBackupConfig::onCheckpointFinish(AbstractHandle* handle,\n                                          uint32_t nBackFill,\n                                          uint32_t mxFrame,\n                                          uint32_t salt1,\n                                          uint32_t salt2)\n{\n    LockGuard lock(m_lock);\n    auto& path = handle->getPath();\n    auto materialIter = m_materials.find(path);\n    if (materialIter == m_materials.end()) {\n        m_operator->asyncBackup(path, false);\n        return;\n    }\n    auto& material = materialIter->second;\n    WCTAssert((material->info.currentWalSalt.first == salt1\n               && material->info.currentWalSalt.second == salt2)\n              || (nBackFill == 0\n                  && Repair::Wal::isCheckpointIncreasedSalt(\n                  material->info.currentWalSalt, { salt1, salt2 })));\n    material->info.currentWalSalt = { salt1, salt2 };\n    material->info.currentNBackFill = nBackFill;\n    material->info.lastCheckPointFinish = nBackFill == mxFrame;\n    auto pagesIter = m_checkpointPages.find(path);\n    WCTAssert(pagesIter != m_checkpointPages.end());\n    if (pagesIter != m_checkpointPages.end()) {\n        for (auto& iter : pagesIter->second) {\n            material->pages[iter.first] = iter.second;\n        }\n        if (pagesIter->second.size() > 0) {\n            m_operator->asyncBackup(path, true);\n        }\n    }\n}\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/common/core/config/AutoBackupConfig.hpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/26\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"Config.hpp\"\n#include \"IncrementalMaterial.hpp\"\n#include \"Lock.hpp\"\n#include \"StringView.hpp\"\n\nnamespace WCDB {\n\nclass AbstractHandle;\n\nclass AutoBackupOperator {\npublic:\n    virtual ~AutoBackupOperator() = 0;\n    virtual void asyncBackup(const UnsafeStringView& path, bool incremental) = 0;\n};\n\nclass AutoBackupConfig final : public Config {\npublic:\n    AutoBackupConfig(const std::shared_ptr<AutoBackupOperator>& operator_);\n    ~AutoBackupConfig() override;\n\n    bool invoke(InnerHandle* handle) override final;\n    bool uninvoke(InnerHandle* handle) override final;\n\n    void tryRegisterIncrementalMaterial(const UnsafeStringView& path,\n                                        SharedIncrementalMaterial material);\n    SharedIncrementalMaterial tryGetIncrementalMaterial(const UnsafeStringView& path);\n\nprivate:\n    void onCheckpointBegin(AbstractHandle* handle,\n                           uint32_t nBackFill,\n                           uint32_t mxFrame,\n                           uint32_t salt1,\n                           uint32_t salt2);\n    void onCheckpointPage(AbstractHandle* handle, uint32_t pageNo, const UnsafeData& data);\n    void onCheckpointFinish(AbstractHandle* handle,\n                            uint32_t nBackFill,\n                            uint32_t mxFrame,\n                            uint32_t salt1,\n                            uint32_t salt2);\n\n    void clearMaterial(const UnsafeStringView& path);\n\n    mutable SharedLock m_lock;\n\n    const StringView m_identifier;\n    std::shared_ptr<AutoBackupOperator> m_operator;\n    StringViewMap<SharedIncrementalMaterial> m_materials;\n    typedef Repair::IncrementalMaterial::Pages Pages;\n    StringViewMap<Pages> m_checkpointPages;\n};\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/common/core/config/AutoCheckpointConfig.cpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/27\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"AutoCheckpointConfig.hpp\"\n#include \"Assertion.hpp\"\n#include \"Global.hpp\"\n#include \"InnerHandle.hpp\"\n#include \"StatementPragma.hpp\"\n#include \"StringView.hpp\"\n#include <regex>\n\nnamespace WCDB {\n\nAutoCheckpointOperator::~AutoCheckpointOperator() = default;\n\nAutoCheckpointConfig::AutoCheckpointConfig(const std::shared_ptr<AutoCheckpointOperator>& operator_)\n: Config()\n, m_identifier(StringView::formatted(\"Checkpoint-%p\", this))\n, m_minFrames(0)\n, m_operator(operator_)\n, m_disableAutoCheckpoint(StatementPragma().pragma(Pragma::walAutocheckpoint()).to(0))\n{\n    WCTAssert(m_operator != nullptr);\n\n    Global::shared().setNotificationForLog(\n    m_identifier,\n    std::bind(&AutoCheckpointConfig::log, this, std::placeholders::_1, std::placeholders::_2));\n}\n\nAutoCheckpointConfig::~AutoCheckpointConfig()\n{\n    Global::shared().setNotificationForLog(m_identifier, nullptr);\n}\n\nbool AutoCheckpointConfig::invoke(InnerHandle* handle)\n{\n    if (SQLITE_DEFAULT_WAL_AUTOCHECKPOINT != 0 && !handle->execute(m_disableAutoCheckpoint)) {\n        return false;\n    }\n    handle->setNotificationWhenCommitted(\n    0,\n    m_identifier,\n    std::bind(&AutoCheckpointConfig::onCommitted, this, std::placeholders::_1, std::placeholders::_2));\n    return true;\n}\n\nbool AutoCheckpointConfig::uninvoke(InnerHandle* handle)\n{\n    handle->unsetNotificationWhenCommitted(m_identifier);\n\n    return true;\n}\n\nvoid AutoCheckpointConfig::setMinFrames(int frame)\n{\n    m_minFrames = frame;\n}\n\nbool AutoCheckpointConfig::onCommitted(const UnsafeStringView& path, int frames)\n{\n    bool needCheckpoint = frames > 0;\n    if (m_minFrames > 0) {\n        int* curFrames = nullptr;\n        {\n            SharedLockGuard guard(m_lock);\n            auto iter = m_frames.find(path);\n            if (iter != m_frames.end()) {\n                curFrames = &(iter->second);\n            }\n        }\n        if (curFrames == nullptr) {\n            LockGuard guard(m_lock);\n            m_frames.insert_or_assign(path, 0);\n            curFrames = &(m_frames.at(path));\n        }\n        if (frames + *curFrames > m_minFrames) {\n            needCheckpoint = true;\n            *curFrames = 0;\n        } else {\n            needCheckpoint = false;\n            *curFrames = *curFrames + frames;\n        }\n    }\n    if (needCheckpoint) {\n        m_operator->asyncCheckpoint(path);\n    }\n    return true;\n}\n\nvoid AutoCheckpointConfig::log(int rc, const char* message)\n{\n    Error::ExtCode extCode = Error::rc2ec(rc);\n    if (extCode != Error::ExtCode::NoticeRecoverWal || message == nullptr) {\n        return;\n    }\n    std::regex pattern(\"recovered (\\\\w+) frames from WAL file (.+)\\\\-wal\");\n    const std::string source = message;\n    std::smatch match;\n    if (std::regex_search(source.begin(), source.end(), match, pattern)) {\n        int frames = atoi(match[1].str().c_str());\n        if (frames > 0) {\n            // hint checkpoint\n            if (frames > 0) {\n                StringView path(match[2].str());\n                m_operator->asyncCheckpoint(path);\n            }\n        }\n    }\n    WCTAssert(match.size() == 3); // assert match and match 3.\n}\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/common/core/config/AutoCheckpointConfig.hpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/27\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"Config.hpp\"\n#include \"Lock.hpp\"\n#include \"Statement.hpp\"\n\nnamespace WCDB {\n\nclass AutoCheckpointOperator {\npublic:\n    virtual ~AutoCheckpointOperator() = 0;\n\n    virtual void asyncCheckpoint(const UnsafeStringView &path) = 0;\n};\n\nclass AutoCheckpointConfig final : public Config {\npublic:\n    AutoCheckpointConfig(const std::shared_ptr<AutoCheckpointOperator> &operator_);\n    ~AutoCheckpointConfig() override;\n\n    bool invoke(InnerHandle *handle) override final;\n    bool uninvoke(InnerHandle *handle) override final;\n    void setMinFrames(int frame);\n\nprotected:\n    const StringView m_identifier;\n    bool onCommitted(const UnsafeStringView &path, int pages);\n    void log(int rc, const char *message);\n\n    int m_minFrames;\n    std::shared_ptr<AutoCheckpointOperator> m_operator;\n    Statement m_disableAutoCheckpoint;\n    StringViewMap<int> m_frames;\n    mutable SharedLock m_lock;\n};\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/common/core/config/AutoVacuumConfig.cpp",
    "content": "//\n// Created by qiuwenchen on 2024/8/15.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"AutoVacuumConfig.hpp\"\n\nnamespace WCDB {\n\nAutoVacuumConfig::AutoVacuumConfig(bool incremental)\n: m_mode(incremental ? 2 : 1)\n, m_getAutoVacuumMode(StatementPragma().pragma(Pragma::autoVacuum()))\n, m_setAutoVacuumMode(StatementPragma().pragma(Pragma::autoVacuum()).to(m_mode))\n{\n}\n\nAutoVacuumConfig::~AutoVacuumConfig() = default;\n\nbool AutoVacuumConfig::invoke(InnerHandle *handle)\n{\n    if (!handle->prepare(m_getAutoVacuumMode)) {\n        return false;\n    }\n    if (!handle->step()) {\n        handle->finalize();\n        return false;\n    }\n    int currentVacuumMode = (int) handle->getInteger();\n    handle->finalize();\n    if (currentVacuumMode == m_mode) {\n        return true;\n    }\n    if (!handle->canWriteMainDB()) {\n        handle->enableWriteMainDB(true);\n        handle->close();\n        if (!handle->open()) {\n            handle->enableWriteMainDB(false);\n            return false;\n        }\n        handle->enableWriteMainDB(false);\n    }\n    return handle->execute(m_setAutoVacuumMode);\n}\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/core/config/AutoVacuumConfig.hpp",
    "content": "//\n// Created by qiuwenchen on 2024/8/15.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"Config.hpp\"\n#include \"InnerHandle.hpp\"\n\nnamespace WCDB {\n\nclass AutoVacuumConfig final : public Config {\npublic:\n    AutoVacuumConfig(bool incremental);\n    ~AutoVacuumConfig() override final;\n\n    bool invoke(InnerHandle* handle) override final;\n\nprivate:\n    int m_mode = 0;\n    const StatementPragma m_getAutoVacuumMode;\n    const StatementPragma m_setAutoVacuumMode;\n};\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/core/config/BasicConfig.cpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"BasicConfig.hpp\"\n#include \"Assertion.hpp\"\n#include \"CommonCore.hpp\"\n#include \"CoreConst.h\"\n#include \"InnerHandle.hpp\"\n#include \"Macro.h\"\n\nnamespace WCDB {\n\nBasicConfig::BasicConfig()\n: Config()\n, m_getJournalMode(StatementPragma().pragma(Pragma::journalMode()))\n, m_setTempStore(StatementPragma().pragma(Pragma::tempStore()).to(1))\n{\n}\n\nBasicConfig::~BasicConfig() = default;\n\nbool BasicConfig::invoke(InnerHandle* handle)\n{\n    static_assert(SQLITE_DEFAULT_SYNCHRONOUS == 1, \"\");\n    static_assert(SQLITE_DEFAULT_WAL_SYNCHRONOUS == 1, \"\");\n    static_assert(SQLITE_DEFAULT_LOCKING_MODE == 0, \"\");\n\n    handle->enableExtendedResultCodes(true);\n    handle->disableCheckpointWhenClosing(true);\n    bool succeed = true;\n    if (!handle->isReadonly()) {\n        handle->setWALFilePersist(true);\n        succeed = lazySetJournalMode(handle);\n#ifndef __ANDROID__\n        succeed = succeed && handle->execute(m_setTempStore);\n#endif\n    }\n    return succeed;\n}\n\n#pragma mark - Journal Mode\nbool BasicConfig::lazySetJournalMode(InnerHandle* handle)\n{\n    bool succeed = false;\n    handle->markErrorAsIgnorable(Error::Code::Busy);\n    int remainingNumberOfBusyRetryTimes = BasicConfigBusyRetryMaxAllowedNumberOfTimes;\n    do {\n        auto journalMode = getJournalMode(handle);\n        if (!journalMode.hasValue()) {\n            continue;\n        }\n        succeed = true;\n        if (!handle->liteModeEnable()) {\n            if (!journalMode.value().caseInsensitiveEqual(\"WAL\")) {\n                if (!handle->canWriteMainDB()) {\n                    succeed = false;\n                    break;\n                } else {\n                    succeed = setJournalMode(handle, \"WAL\");\n                }\n            }\n        } else {\n            if (!journalMode.value().caseInsensitiveEqual(\"OFF\")) {\n                succeed = setJournalMode(handle, \"OFF\");\n            }\n        }\n        // These is no busy handler for this busy event.\n        // So we should retry from outside.\n    } while (--remainingNumberOfBusyRetryTimes > 0 && !succeed\n             && handle->getError().isIgnorable());\n    handle->markErrorAsUnignorable();\n    return succeed;\n}\n\nOptional<StringView> BasicConfig::getJournalMode(InnerHandle* handle)\n{\n    Optional<StringView> ret;\n    if (handle->prepare(m_getJournalMode)) {\n        if (handle->step()) {\n            ret = handle->getText();\n        }\n        handle->finalize();\n    }\n    return ret;\n}\n\nbool BasicConfig::setJournalMode(InnerHandle* handle, const UnsafeStringView& mode)\n{\n    return handle->execute(StatementPragma().pragma(Pragma::journalMode()).to(mode));\n}\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/common/core/config/BasicConfig.hpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"Config.hpp\"\n#include \"WINQ.h\"\n\nnamespace WCDB {\n\nclass BasicConfig final : public Config {\npublic:\n    BasicConfig();\n    ~BasicConfig() override;\n\n    bool invoke(InnerHandle* handle) override final;\n\n#pragma mark - Journal Mode\nprotected:\n    bool lazySetJournalMode(InnerHandle* handle);\n\nprivate:\n    Optional<StringView> getJournalMode(InnerHandle* handle);\n    bool setJournalMode(InnerHandle* handle, const UnsafeStringView& mode);\n\nprivate:\n    const StatementPragma m_getJournalMode;\n\n#pragma mark - Temp Store\nprotected:\n    const StatementPragma m_setTempStore;\n};\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/common/core/config/BusyRetryConfig.cpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"BusyRetryConfig.hpp\"\n#include \"Assertion.hpp\"\n#include \"CoreConst.h\"\n#include \"InnerHandle.hpp\"\n#include \"Time.hpp\"\n\nnamespace WCDB {\n\nBusyRetryConfig::BusyRetryConfig()\n: Config()\n, m_identifier(StringView::formatted(\"Busy-%p\", this))\n, m_busyMonitor(nullptr)\n, m_timeOut(0)\n{\n    Global::shared().setNotificationForLockEvent(\n    m_identifier,\n    std::bind(&BusyRetryConfig::willLock, this, std::placeholders::_1, std::placeholders::_2),\n    std::bind(&BusyRetryConfig::lockDidChange, this, std::placeholders::_1, std::placeholders::_2),\n    std::bind(\n    &BusyRetryConfig::willShmLock, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3),\n    std::bind(&BusyRetryConfig::shmLockDidChange,\n              this,\n              std::placeholders::_1,\n              std::placeholders::_2,\n              std::placeholders::_3,\n              std::placeholders::_4));\n}\n\nBusyRetryConfig::~BusyRetryConfig()\n{\n    Global::shared().setNotificationForLockEvent(\n    m_identifier, nullptr, nullptr, nullptr, nullptr);\n}\n\nbool BusyRetryConfig::invoke(InnerHandle* handle)\n{\n    handle->setNotificationWhenBusy(std::bind(\n    &BusyRetryConfig::onBusy, this, std::placeholders::_1, std::placeholders::_2));\n    return true;\n}\n\nbool BusyRetryConfig::uninvoke(InnerHandle* handle)\n{\n    handle->setNotificationWhenBusy(nullptr);\n    return true;\n}\n\nbool BusyRetryConfig::checkMainThreadBusyRetry(const UnsafeStringView& path)\n{\n    return getOrCreateState(path).checkMainThreadBusyRetry();\n}\n\nbool BusyRetryConfig::checkHasBusyRetry(const UnsafeStringView& path)\n{\n    return getOrCreateState(path).checkHasBusyRetry();\n}\n\nbool BusyRetryConfig::onBusy(const UnsafeStringView& path, int numberOfTimes)\n{\n    WCDB_UNUSED(path);\n    WCDB_UNUSED(numberOfTimes);\n\n    Trying& trying = m_tryings.getOrCreate();\n    WCTAssert(trying.valid());\n    return getOrCreateState(trying.getPath()).wait(trying);\n}\n\n#pragma mark - Busy Moniter\nvoid BusyRetryConfig::setBusyMonitor(const BusyMonitor& monitor, double timeOut)\n{\n    LockGuard lockGuard(m_statesLock);\n    m_busyMonitor = monitor;\n    m_timeOut = timeOut;\n    for (auto& iter : m_states) {\n        iter.second.setBusyMonitor(monitor, timeOut);\n    }\n}\n\n#pragma mark - State\nBusyRetryConfig::Expecting::Expecting() : m_category(Category::None)\n{\n}\n\nbool BusyRetryConfig::Expecting::valid() const\n{\n    return m_category == Category::Pager || m_category == Category::Shm;\n}\n\nvoid BusyRetryConfig::Expecting::expecting(ShmLockType type, int mask)\n{\n    m_category = Category::Shm;\n    m_shmType = type;\n    m_shmMask = mask;\n}\n\nvoid BusyRetryConfig::Expecting::expecting(PagerLockType type)\n{\n    m_category = Category::Pager;\n    WCTAssert(type != PagerLockType::None);\n    m_pagerType = type;\n}\n\nbool BusyRetryConfig::Expecting::satisfied(PagerLockType type) const\n{\n    WCTAssert(valid());\n    bool satisfied = true;\n    if (m_category == Category::Pager) {\n        switch (m_pagerType) {\n        case PagerLockType::Reserved:\n            satisfied = type < PagerLockType::Reserved;\n            break;\n        case PagerLockType::Pending:\n            // fallthrough\n        case PagerLockType::Exclusive:\n            satisfied = type == PagerLockType::None;\n            break;\n        case PagerLockType::Shared:\n            satisfied = type < PagerLockType::Pending;\n            break;\n        default:\n            WCTAssert(false);\n            break;\n        }\n    }\n    return satisfied;\n}\n\nbool BusyRetryConfig::Expecting::satisfied(int sharedMask, int exclusiveMask) const\n{\n    WCTAssert(valid());\n    bool satisified = true;\n    if (m_category == Category::Shm) {\n        switch (m_shmType) {\n        case ShmLockType::Shared:\n            satisified = (m_shmMask & exclusiveMask) == 0;\n            break;\n        default:\n            WCTAssert(m_shmType == ShmLockType::Exclusive);\n            satisified\n            = (m_shmMask & sharedMask) == 0 && (m_shmMask & exclusiveMask) == 0;\n            break;\n        }\n    }\n    return satisified;\n}\n\nBusyRetryConfig::State::ShmMask::ShmMask() : shared(0), exclusive(0)\n{\n}\n\nBusyRetryConfig::State& BusyRetryConfig::getOrCreateState(const UnsafeStringView& path)\n{\n    WCTAssert(!path.empty());\n    StateHolder& stateHoder = m_localState.getOrCreate();\n    if (stateHoder.state != nullptr) {\n        State& localState = *stateHoder.state;\n        if (localState.m_path == path) {\n            return localState;\n        }\n    }\n    {\n        SharedLockGuard lockGuard(m_statesLock);\n        auto iter = m_states.find(path);\n        if (iter != m_states.end()) {\n            stateHoder.state = &iter->second;\n            return *stateHoder.state;\n        }\n    }\n    {\n        LockGuard lockGuard(m_statesLock);\n        State& state = m_states[path];\n        state.m_path = path;\n        stateHoder.state = &state;\n        state.setBusyMonitor(m_busyMonitor, m_timeOut);\n        return state;\n    }\n}\n\nBusyRetryConfig::State::State()\n: m_pagerType(PagerLockType::None)\n, m_pagerChangeTid(0)\n, m_mainThreadBusyTrying(nullptr)\n, m_busyMonitor(nullptr)\n, m_timeOut(0)\n{\n}\n\nvoid BusyRetryConfig::State::updatePagerLock(PagerLockType type)\n{\n    std::lock_guard<std::mutex> lockGuard(m_lock);\n    if (m_pagerType != type) {\n        bool notify = type < m_pagerType;\n        m_pagerType = type;\n        m_localPagerType.getOrCreate() = type;\n        m_pagerChangeTid = Thread::getCurrentThreadId();\n        if (notify) {\n            tryNotify();\n        }\n    }\n}\n\nvoid BusyRetryConfig::State::updateShmLock(void* identifier, int sharedMask, int exclusiveMask)\n{\n    std::lock_guard<std::mutex> lockGuard(m_lock);\n    bool notify = false;\n    if (sharedMask == 0 && exclusiveMask == 0) {\n        m_shmMasks.erase(identifier);\n        notify = true;\n    } else {\n        State::ShmMask& mask = m_shmMasks[identifier];\n        notify = sharedMask < mask.shared || exclusiveMask < mask.exclusive;\n        mask.shared = sharedMask;\n        mask.exclusive = exclusiveMask;\n        mask.tid = Thread::getCurrentThreadId();\n    }\n    if (notify) {\n        tryNotify();\n    }\n}\n\nbool BusyRetryConfig::State::shouldWait(const Expecting& expecting) const\n{\n    bool wait = false;\n    if (!expecting.satisfied(m_pagerType)\n        && m_pagerType != m_localPagerType.getOrCreate()) // Shouldn't wait for the lock obtained by itself\n    {\n        wait = true;\n    } else {\n        for (const auto& iter : m_shmMasks) {\n            if (!expecting.satisfied(iter.second.shared, iter.second.exclusive)) {\n                wait = true;\n                break;\n            }\n        }\n    }\n    return wait;\n}\n\nbool BusyRetryConfig::State::localShouldWait(const Expecting& expecting) const\n{\n    bool wait = false;\n    uint64_t tid = Thread::getCurrentThreadId();\n    if (m_pagerChangeTid == tid && !expecting.satisfied(m_pagerType)) {\n        wait = true;\n    } else {\n        for (const auto& iter : m_shmMasks) {\n            if (iter.second.tid == tid\n                && !expecting.satisfied(iter.second.shared, iter.second.exclusive)) {\n                wait = true;\n                break;\n            }\n        }\n    }\n    return wait;\n}\n\nbool BusyRetryConfig::State::wait(Trying& trying)\n{\n    static_assert(Exclusivity::Must < Exclusivity::NoMatter, \"\");\n\n    double timeOut = m_busyMonitor != nullptr && m_timeOut > 0 ? m_timeOut : BusyRetryTimeOut;\n    int timeOutTimes = 0;\n    std::unique_lock<std::mutex> lockGuard(m_lock);\n    while (shouldWait(trying)) {\n        Thread currentThread = Thread::current();\n        // main thread first\n        Exclusivity exclusivity\n        = Thread::isMain() ? Exclusivity::Must : Exclusivity::NoMatter;\n\n        m_waitings.insert(currentThread, trying, exclusivity);\n\n        if (exclusivity == Exclusivity::Must) {\n            m_mainThreadBusyTrying = &trying;\n        }\n\n        bool notified = m_conditional.wait_for(lockGuard, timeOut);\n\n        if (exclusivity == Exclusivity::Must) {\n            m_mainThreadBusyTrying = nullptr;\n        }\n\n        m_waitings.erase(currentThread);\n\n        if (!notified) {\n            if (m_busyMonitor != nullptr) {\n                if (!trying.satisfied(m_pagerType)) {\n                    WCTAssert(m_pagerChangeTid != 0\n                              && m_pagerChangeTid != Thread::getCurrentThreadId());\n                    m_busyMonitor(m_path, m_pagerChangeTid);\n                    timeOutTimes++;\n                } else {\n                    for (const auto& iter : m_shmMasks) {\n                        if (!trying.satisfied(iter.second.shared, iter.second.exclusive)) {\n                            WCTAssert(iter.second.tid != 0\n                                      && iter.second.tid != Thread::getCurrentThreadId());\n                            m_busyMonitor(m_path, iter.second.tid);\n                            timeOutTimes++;\n                            break;\n                        }\n                    }\n                }\n                if (timeOut * timeOutTimes >= BusyRetryTimeOut) {\n                    break;\n                }\n            } else {\n                // retry anyway if timeout\n                break;\n            }\n        }\n    }\n    // never timeout\n    return true;\n}\n\nbool BusyRetryConfig::State::checkMainThreadBusyRetry()\n{\n    if (m_mainThreadBusyTrying == nullptr) {\n        return false;\n    }\n    std::unique_lock<std::mutex> lockGuard(m_lock);\n    if (m_mainThreadBusyTrying == nullptr) {\n        return false;\n    }\n    return localShouldWait(*m_mainThreadBusyTrying);\n}\n\nbool BusyRetryConfig::State::checkHasBusyRetry()\n{\n    std::unique_lock<std::mutex> lockGuard(m_lock);\n    return m_waitings.size() > 0;\n}\n\nvoid BusyRetryConfig::State::setBusyMonitor(const BusyMonitor& monitor, double timeOut)\n{\n    std::unique_lock<std::mutex> lockGuard(m_lock);\n    m_busyMonitor = monitor;\n    m_timeOut = timeOut;\n}\n\nvoid BusyRetryConfig::State::tryNotify()\n{\n    for (auto iter = m_waitings.begin(); iter != m_waitings.end();) {\n        if (shouldWait(iter->value())) {\n            if (iter->order() == Exclusivity::Must) {\n                // stop so that the main thread can hold the mutex first.\n                return;\n            }\n            ++iter;\n        } else {\n#ifdef __APPLE__\n            m_conditional.notify(iter->key());\n            iter = m_waitings.erase(iter);\n#else\n            m_conditional.notify_all();\n            return;\n#endif\n        }\n    }\n}\n\n#pragma mark - Trying\nvoid BusyRetryConfig::Trying::expecting(const UnsafeStringView& path, ShmLockType type, int mask)\n{\n    WCTAssert(!path.empty());\n    m_path = path;\n    Expecting::expecting(type, mask);\n}\n\nvoid BusyRetryConfig::Trying::expecting(const UnsafeStringView& path, PagerLockType type)\n{\n    WCTAssert(!path.empty());\n    m_path = path;\n    Expecting::expecting(type);\n}\n\nbool BusyRetryConfig::Trying::valid() const\n{\n    return !m_path.empty() && Expecting::valid();\n}\n\nconst StringView& BusyRetryConfig::Trying::getPath() const\n{\n    return m_path;\n}\n\n#pragma mark - Lock Event\nvoid BusyRetryConfig::willLock(const UnsafeStringView& path, PagerLockType type)\n{\n    m_tryings.getOrCreate().expecting(path, type);\n}\n\nvoid BusyRetryConfig::lockDidChange(const UnsafeStringView& path, PagerLockType type)\n{\n    getOrCreateState(path).updatePagerLock(type);\n}\n\nvoid BusyRetryConfig::willShmLock(const UnsafeStringView& path, ShmLockType type, int mask)\n{\n    m_tryings.getOrCreate().expecting(path, type, mask);\n}\n\nvoid BusyRetryConfig::shmLockDidChange(const UnsafeStringView& path,\n                                       void* identifier,\n                                       int sharedMask,\n                                       int exclusiveMask)\n{\n    getOrCreateState(path).updateShmLock(identifier, sharedMask, exclusiveMask);\n}\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/core/config/BusyRetryConfig.hpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"Config.hpp\"\n#include \"Global.hpp\"\n#include \"Lock.hpp\"\n#include \"StringView.hpp\"\n#include \"ThreadLocal.hpp\"\n#include \"UniqueList.hpp\"\n\nnamespace WCDB {\n\nclass BusyRetryConfig final : public Config {\npublic:\n    BusyRetryConfig();\n    ~BusyRetryConfig() override;\n\n    bool invoke(InnerHandle* handle) override final;\n    bool uninvoke(InnerHandle* handle) override final;\n    bool checkMainThreadBusyRetry(const UnsafeStringView& path);\n    bool checkHasBusyRetry(const UnsafeStringView& path);\n\nprotected:\n    bool onBusy(const UnsafeStringView& path, int numberOfTimes);\n\n    const StringView m_identifier;\n\n#pragma mark - Busy Moniter\npublic:\n    typedef std::function<void(const UnsafeStringView& path, uint64_t tid)> BusyMonitor;\n    void setBusyMonitor(const BusyMonitor& monitor, double timeOut);\n\nprivate:\n    BusyMonitor m_busyMonitor;\n    double m_timeOut;\n\n#pragma mark - Lock Event\nprotected:\n    typedef Global::PagerLock PagerLockType;\n    typedef Global::ShmLock ShmLockType;\n    void willLock(const UnsafeStringView& path, PagerLockType type);\n    void lockDidChange(const UnsafeStringView& path, PagerLockType type);\n    void willShmLock(const UnsafeStringView& path, ShmLockType type, int mask);\n    void shmLockDidChange(const UnsafeStringView& path, void* identifier, int sharedMask, int exclusiveMask);\n\n#pragma mark - State\nprotected:\n    class Expecting {\n    public:\n        Expecting();\n\n        bool satisfied(PagerLockType type) const;\n        bool satisfied(int sharedMask, int exclusiveMask) const;\n\n    protected:\n        void expecting(ShmLockType type, int mask);\n        void expecting(PagerLockType type);\n        bool valid() const;\n\n    private:\n        enum class Category {\n            None,\n            Pager,\n            Shm,\n        };\n        Category m_category;\n        ShmLockType m_shmType;\n        int m_shmMask;\n        PagerLockType m_pagerType;\n    };\n\n    class Trying;\n    class State {\n    public:\n        State();\n\n        void updatePagerLock(PagerLockType type);\n        void updateShmLock(void* identifier, int sharedMask, int exclusiveMask);\n\n        bool wait(Trying& trying);\n        StringView m_path;\n        bool checkMainThreadBusyRetry();\n        bool checkHasBusyRetry();\n        void setBusyMonitor(const BusyMonitor& monitor, double timeOut);\n\n    protected:\n        bool shouldWait(const Expecting& expecting) const;\n        bool localShouldWait(const Expecting& expecting) const;\n        PagerLockType m_pagerType;\n        mutable ThreadLocal<PagerLockType> m_localPagerType;\n        uint64_t m_pagerChangeTid;\n        struct ShmMask {\n            ShmMask();\n            int shared;\n            int exclusive;\n            uint64_t tid;\n        };\n        typedef struct ShmMask ShmMask;\n        std::map<void* /* identifier */, ShmMask> m_shmMasks;\n\n        void tryNotify();\n        std::mutex m_lock;\n        Conditional m_conditional;\n\n        enum class Exclusivity {\n            Must = 0,\n            NoMatter = 1,\n        };\n        Trying* m_mainThreadBusyTrying;\n        UniqueList<Thread, Expecting, Exclusivity> m_waitings;\n\n        BusyMonitor m_busyMonitor;\n        double m_timeOut;\n    };\n\n    State& getOrCreateState(const UnsafeStringView& path);\n\nprivate:\n    SharedLock m_statesLock;\n    StringViewMap<State> m_states;\n\n#pragma mark - Trying\nprotected:\n    class Trying : public Expecting {\n    public:\n        using Expecting::Expecting;\n\n        void expecting(const UnsafeStringView& path, ShmLockType type, int mask);\n        void expecting(const UnsafeStringView& path, PagerLockType type);\n\n        const StringView& getPath() const;\n\n        bool valid() const;\n\n    private:\n        StringView m_path;\n    };\n    typedef struct StateHolder {\n        State* state;\n    } StateHolder;\n    ThreadLocal<Trying> m_tryings;\n    ThreadLocal<StateHolder> m_localState;\n};\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/common/core/config/CipherConfig.cpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"CipherConfig.hpp\"\n#include \"Assertion.hpp\"\n#include \"InnerHandle.hpp\"\n\nnamespace WCDB {\n\nCipherConfig::CipherConfig(const UnsafeData& cipher, int pageSize, int cipherVersion)\n: Config(), m_key(cipher), m_pageSize(pageSize), m_cipherVersion(cipherVersion)\n{\n}\n\nCipherConfig::~CipherConfig() = default;\n\nbool CipherConfig::invoke(InnerHandle* handle)\n{\n    bool ret = false;\n    {\n        SharedLockGuard lockGuard(m_lock);\n        if (!m_rawKey.empty()) {\n            ret = handle->setCipherKey(m_rawKey);\n        } else {\n            ret = handle->setCipherKey(m_key);\n        }\n    }\n\n    if (ret && m_cipherVersion != 0) {\n        ret = handle->execute(\n        StatementPragma().pragma(Pragma::cipherCompatibility()).to(m_cipherVersion));\n    }\n    if (ret) {\n        ret = handle->setCipherPageSize(m_pageSize);\n    }\n    return ret;\n}\n\nvoid CipherConfig::trySaveRawKey(InnerHandle* handle)\n{\n    {\n        SharedLockGuard lockGuard(m_lock);\n        if (!m_rawKey.empty()) {\n            return;\n        }\n    }\n    LockGuard lockGuard(m_lock);\n    if (!m_rawKey.empty()) {\n        return;\n    }\n    m_rawKey = handle->getRawCipherKey();\n    if (!m_rawKey.empty()) {\n        m_key = Data();\n    }\n}\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/common/core/config/CipherConfig.hpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"Config.hpp\"\n#include \"Data.hpp\"\n#include \"Lock.hpp\"\n#include \"WINQ.h\"\n\nnamespace WCDB {\n\nclass CipherConfig final : public Config {\npublic:\n    CipherConfig(const UnsafeData &cipher, int pageSize, int cipherVersion);\n    ~CipherConfig() override;\n\n    bool invoke(InnerHandle *handle) override final;\n    void trySaveRawKey(InnerHandle *handle);\n\nprotected:\n    Data m_key;\n    Data m_rawKey;\n    mutable SharedLock m_lock;\n    const int m_pageSize;\n    const int m_cipherVersion = 4;\n};\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/common/core/config/Config.cpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"Config.hpp\"\n#include \"Macro.h\"\n\nnamespace WCDB {\n\nConfig::~Config() = default;\n\nbool Config::uninvoke(InnerHandle *handle)\n{\n    WCDB_UNUSED(handle);\n    return true;\n}\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/core/config/Config.hpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\nnamespace WCDB {\n\nclass InnerHandle;\n\nclass Config {\npublic:\n    virtual ~Config() = 0;\n    virtual bool invoke(InnerHandle *handle) = 0;\n    virtual bool uninvoke(InnerHandle *handle);\n};\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/common/core/config/Configs.cpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"Configs.hpp\"\n\nnamespace WCDB {\n\nConfigs::~Configs() = default;\n\n}\n"
  },
  {
    "path": "src/common/core/config/Configs.hpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"Config.hpp\"\n#include \"StringView.hpp\"\n#include \"UniqueList.hpp\"\n#include <limits>\n\nnamespace WCDB {\n\nclass Configs final : public UniqueList<StringView, std::shared_ptr<Config>> {\npublic:\n    using UniqueList<StringView, std::shared_ptr<Config>>::UniqueList;\n    ~Configs() override;\n\n    enum Priority : int {\n        Highest = std::numeric_limits<int>::min(),\n        Higher = std::numeric_limits<int>::min() + 1,\n        High = -100,\n        Default = 0,\n        Low = 100,\n    };\n};\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/common/core/config/CustomConfig.cpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"CustomConfig.hpp\"\n#include \"Assertion.hpp\"\n\nnamespace WCDB {\n\nCustomConfig::CustomConfig(const Invocation &invocation, const Invocation &uninvocation)\n: Config(), m_invocation(invocation), m_uninvocation(uninvocation)\n{\n}\n\nCustomConfig::~CustomConfig() = default;\n\nbool CustomConfig::invoke(InnerHandle *handle)\n{\n    WCTRemedialAssert(\n    m_invocation != nullptr, \"Invocation should not be null.\", return false;);\n    return m_invocation(handle);\n}\n\nbool CustomConfig::uninvoke(InnerHandle *handle)\n{\n    bool succeed = true;\n    if (m_uninvocation != nullptr) {\n        succeed = m_uninvocation(handle);\n    }\n    return succeed;\n}\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/common/core/config/CustomConfig.hpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"Config.hpp\"\n#include <functional>\n\nnamespace WCDB {\n\nclass CustomConfig final : public Config {\npublic:\n    using Invocation = std::function<bool(InnerHandle *)>;\n\n    CustomConfig(const Invocation &invocation, const Invocation &uninvocation);\n    ~CustomConfig() override;\n\n    bool invoke(InnerHandle *handle) override final;\n    bool uninvoke(InnerHandle *handle) override final;\n\nprotected:\n    const Invocation m_invocation;\n    const Invocation m_uninvocation;\n};\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/common/core/config/PerformanceTraceConfig.cpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"PerformanceTraceConfig.hpp\"\n#include \"Assertion.hpp\"\n#include \"StringView.hpp\"\n\nnamespace WCDB {\n\n#pragma mark - PerformanceTracer\nPerformanceTracer::PerformanceTracer()\n: m_identifier(StringView::formatted(\"PerformanceTrace-%p\", this))\n, m_notification(nullptr)\n{\n}\n\nPerformanceTracer::~PerformanceTracer() = default;\n\nvoid PerformanceTracer::setNotification(const Notification &notification)\n{\n    m_notification = notification;\n}\n\nbool PerformanceTracer::invoke(InnerHandle *handle)\n{\n    handle->setNotificationWhenPerformanceTraced(m_identifier, m_notification);\n    return true;\n}\n\nbool PerformanceTracer::uninvoke(InnerHandle *handle)\n{\n    handle->setNotificationWhenPerformanceTraced(m_identifier, nullptr);\n    return true;\n}\n\n#pragma mark - PerformanceTraceConfig\nPerformanceTraceConfig::PerformanceTraceConfig(const Notification &notification)\n{\n    setNotification(notification);\n}\n\nPerformanceTraceConfig::~PerformanceTraceConfig() = default;\n\nbool PerformanceTraceConfig::invoke(InnerHandle *handle)\n{\n    return PerformanceTracer::invoke(handle);\n}\n\nbool PerformanceTraceConfig::uninvoke(InnerHandle *handle)\n{\n    return PerformanceTracer::uninvoke(handle);\n}\n\n#pragma mark - ShareablePerformanceTraceConfig\nShareablePerformanceTraceConfig::ShareablePerformanceTraceConfig() = default;\n\nShareablePerformanceTraceConfig::~ShareablePerformanceTraceConfig() = default;\n\nvoid ShareablePerformanceTraceConfig::setNotification(const Notification &notification)\n{\n    LockGuard lockGuard(m_lock);\n    WCTAssert(m_notification == nullptr || notification == nullptr);\n    PerformanceTracer::setNotification(notification);\n}\n\nbool ShareablePerformanceTraceConfig::invoke(InnerHandle *handle)\n{\n    SharedLockGuard lockGuard(m_lock);\n    return PerformanceTracer::invoke(handle);\n}\n\nbool ShareablePerformanceTraceConfig::uninvoke(InnerHandle *handle)\n{\n    SharedLockGuard lockGuard(m_lock);\n    return PerformanceTracer::uninvoke(handle);\n}\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/common/core/config/PerformanceTraceConfig.hpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"Config.hpp\"\n#include \"InnerHandle.hpp\"\n#include \"Lock.hpp\"\n\nnamespace WCDB {\n\nclass PerformanceTracer {\npublic:\n    PerformanceTracer();\n    virtual ~PerformanceTracer() = 0;\n\n    using Notification = InnerHandle::PerformanceNotification;\n\nprotected:\n    void setNotification(const Notification &notification);\n    bool invoke(InnerHandle *handle);\n    bool uninvoke(InnerHandle *handle);\n\n    const StringView m_identifier;\n    Notification m_notification;\n};\n\nclass PerformanceTraceConfig final : public Config, public PerformanceTracer {\npublic:\n    PerformanceTraceConfig(const Notification &notification);\n    ~PerformanceTraceConfig() override;\n\n    bool invoke(InnerHandle *handle) override final;\n    bool uninvoke(InnerHandle *handle) override final;\n\nprivate:\n    using PerformanceTracer::setNotification;\n};\n\nclass ShareablePerformanceTraceConfig final : public Config, public PerformanceTracer {\npublic:\n    ShareablePerformanceTraceConfig();\n    ~ShareablePerformanceTraceConfig() override;\n\n    bool invoke(InnerHandle *handle) override final;\n    bool uninvoke(InnerHandle *handle) override final;\n\n    void setNotification(const Notification &notification);\n\nprotected:\n    mutable SharedLock m_lock;\n};\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/common/core/config/SQLTraceConfig.cpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"SQLTraceConfig.hpp\"\n#include \"Assertion.hpp\"\n#include \"StringView.hpp\"\n\nnamespace WCDB {\n\nSQLTracer::SQLTracer()\n: m_identifier(StringView::formatted(\"SQLTrace-%p\", this))\n{\n}\n\nSQLTracer::~SQLTracer() = default;\n\nbool SQLTracer::invoke(InnerHandle *handle)\n{\n    handle->setNotificationWhenSQLTraced(m_identifier, m_notification);\n    return true;\n}\n\nbool SQLTracer::uninvoke(InnerHandle *handle)\n{\n    handle->setNotificationWhenSQLTraced(m_identifier, nullptr);\n    return true;\n}\n\nvoid SQLTracer::setNotification(const Notification &notification)\n{\n    m_notification = notification;\n}\n\nSQLTraceConfig::SQLTraceConfig(const Notification &notification)\n{\n    setNotification(notification);\n}\n\nSQLTraceConfig::~SQLTraceConfig() = default;\n\nbool SQLTraceConfig::invoke(InnerHandle *handle)\n{\n    return SQLTracer::invoke(handle);\n}\n\nbool SQLTraceConfig::uninvoke(InnerHandle *handle)\n{\n    return SQLTracer::uninvoke(handle);\n}\n\nShareableSQLTraceConfig::ShareableSQLTraceConfig() = default;\n\nShareableSQLTraceConfig::~ShareableSQLTraceConfig() = default;\n\nvoid ShareableSQLTraceConfig::setNotification(const Notification &notification)\n{\n    LockGuard lockGuard(m_lock);\n    WCTAssert(m_notification == nullptr || notification == nullptr);\n    SQLTracer::setNotification(notification);\n}\n\nbool ShareableSQLTraceConfig::invoke(InnerHandle *handle)\n{\n    SharedLockGuard lockGuard(m_lock);\n    return SQLTracer::invoke(handle);\n}\n\nbool ShareableSQLTraceConfig::uninvoke(InnerHandle *handle)\n{\n    SharedLockGuard lockGuard(m_lock);\n    return SQLTracer::uninvoke(handle);\n}\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/common/core/config/SQLTraceConfig.hpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"Config.hpp\"\n#include \"InnerHandle.hpp\"\n#include \"Lock.hpp\"\n\nnamespace WCDB {\n\nclass SQLTracer {\npublic:\n    SQLTracer();\n    virtual ~SQLTracer() = 0;\n    using Notification = InnerHandle::SQLNotification;\n\nprotected:\n    bool invoke(InnerHandle *handle);\n    bool uninvoke(InnerHandle *handle);\n    void setNotification(const Notification &notification);\n\n    const StringView m_identifier;\n    Notification m_notification;\n};\n\nclass SQLTraceConfig final : public Config, public SQLTracer {\npublic:\n    SQLTraceConfig(const Notification &notification);\n    ~SQLTraceConfig() override;\n\n    bool invoke(InnerHandle *handle) override final;\n    bool uninvoke(InnerHandle *handle) override final;\n};\n\nclass ShareableSQLTraceConfig final : public Config, public SQLTracer {\npublic:\n    ShareableSQLTraceConfig();\n    ~ShareableSQLTraceConfig() override;\n\n    bool invoke(InnerHandle *handle) override final;\n    bool uninvoke(InnerHandle *handle) override final;\n\n    void setNotification(const Notification &notification);\n\nprotected:\n    mutable SharedLock m_lock;\n};\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/common/core/fts/AutoMergeFTSIndexConfig.cpp",
    "content": "//\n// Created by qiuwenchen(qiuwenchen) on 2020/10/22.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"AutoMergeFTSIndexConfig.hpp\"\n#include \"Assertion.hpp\"\n#include \"InnerHandle.hpp\"\n#include \"StringView.hpp\"\n\nnamespace WCDB {\n\nAutoMergeFTSIndexOperator::~AutoMergeFTSIndexOperator() = default;\n\nAutoMergeFTSIndexConfig::AutoMergeFTSIndexConfig(const std::shared_ptr<AutoMergeFTSIndexOperator> &operator_)\n: Config(), m_identifier(StringView::formatted(\"Merge-%p\", this)), m_operator(operator_)\n{\n    WCTAssert(m_operator != nullptr);\n}\n\nAutoMergeFTSIndexConfig::~AutoMergeFTSIndexConfig() = default;\n\nbool AutoMergeFTSIndexConfig::invoke(InnerHandle *handle)\n{\n    handle->setNotificationWhenTableModified(m_identifier,\n                                             std::bind(&AutoMergeFTSIndexConfig::onTableModified,\n                                                       this,\n                                                       std::placeholders::_1,\n                                                       std::placeholders::_2,\n                                                       std::placeholders::_3));\n    handle->setNotificationWhenCommitted(\n    1,\n    m_identifier,\n    std::bind(&AutoMergeFTSIndexConfig::onCommitted, this, std::placeholders::_1, std::placeholders::_2));\n\n    return true;\n}\n\nbool AutoMergeFTSIndexConfig::uninvoke(InnerHandle *handle)\n{\n    handle->unsetNotificationWhenCommitted(m_identifier);\n    handle->setNotificationWhenTableModified(m_identifier, nullptr);\n\n    return true;\n}\n\nvoid AutoMergeFTSIndexConfig::onTableModified(const UnsafeStringView &path,\n                                              const UnsafeStringView &newTable,\n                                              const UnsafeStringView &modifiedTable)\n{\n    WCTAssert(!path.empty());\n    LockGuard lockGuard(m_lock);\n    if (!newTable.empty()) {\n        m_newTables[path].emplace(StringView(newTable));\n    }\n    if (!modifiedTable.empty()) {\n        m_modifiedTables[path].emplace(StringView(modifiedTable));\n    }\n}\n\nbool AutoMergeFTSIndexConfig::onCommitted(const UnsafeStringView &path, int pages)\n{\n    WCTAssert(!path.empty());\n    LockGuard lockGuard(m_lock);\n    if (pages == 0) {\n        m_newTables.erase(path);\n        m_modifiedTables.erase(path);\n        return true;\n    }\n    auto newTablesIter = m_newTables.find(path);\n    TableArray newTables = nullptr;\n    if (newTablesIter != m_newTables.end()) {\n        newTables = TableArray(new std::vector<StringView>());\n        newTables->assign(newTablesIter->second.begin(), newTablesIter->second.end());\n        m_newTables.erase(path);\n    }\n\n    auto modifiedTablesIter = m_modifiedTables.find(path);\n    TableArray modifiedTables = nullptr;\n    if (modifiedTablesIter != m_modifiedTables.end()) {\n        modifiedTables = TableArray(new std::vector<StringView>());\n        modifiedTables->assign(modifiedTablesIter->second.begin(),\n                               modifiedTablesIter->second.end());\n        m_modifiedTables.erase(path);\n    }\n\n    if (newTables != nullptr || modifiedTables != nullptr) {\n        m_operator->asyncMergeFTSIndex(path, newTables, modifiedTables);\n    }\n    return true;\n}\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/common/core/fts/AutoMergeFTSIndexConfig.hpp",
    "content": "//\n// Created by qiuwenchen(qiuwenchen) on 2020/10/22.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"Config.hpp\"\n#include \"Lock.hpp\"\n\n#include <vector>\n\nnamespace WCDB {\n\nclass AutoMergeFTSIndexOperator {\npublic:\n    using TableArray = std::shared_ptr<std::vector<StringView>>;\n\n    virtual ~AutoMergeFTSIndexOperator() = 0;\n\n    virtual void\n    asyncMergeFTSIndex(const UnsafeStringView& path, TableArray newTables, TableArray modifiedTables)\n    = 0;\n};\n\nclass AutoMergeFTSIndexConfig final : public Config {\npublic:\n    AutoMergeFTSIndexConfig(const std::shared_ptr<AutoMergeFTSIndexOperator>& operator_);\n    ~AutoMergeFTSIndexConfig() override;\n\n    bool invoke(InnerHandle* handle) override final;\n    bool uninvoke(InnerHandle* handle) override final;\n\n    using TableArray = AutoMergeFTSIndexOperator::TableArray;\n\nprotected:\n    const StringView m_identifier;\n\n    void onTableModified(const UnsafeStringView& path,\n                         const UnsafeStringView& newTable,\n                         const UnsafeStringView& modifiedTable);\n    bool onCommitted(const UnsafeStringView& path, int pages);\n\n    std::shared_ptr<AutoMergeFTSIndexOperator> m_operator;\n    StringViewMap<StringViewSet> m_newTables;\n    StringViewMap<StringViewSet> m_modifiedTables;\n    mutable SharedLock m_lock;\n};\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/common/core/fts/FTSConst.h",
    "content": "//\n// Created by qiuwenchen on 2022/10/28.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\nnamespace WCDB {\n\nnamespace Module {\n/**\n The following three are different versions of the sqlite fts module. `Module::FTS5` is recommended. You can use `WCDB_CPP_VIRTUAL_TABLE_MODULE` to config fts module for a cpp ORM class.\n */\nstatic constexpr const char* FTS3 = \"fts3\";\nstatic constexpr const char* FTS4 = \"fts4\";\nstatic constexpr const char* FTS5 = \"fts5\";\n\n}; // namespace Module\n\nnamespace BuiltinTokenizer {\n/**\n The following four are sqlite built-in fts tokenizers. `WCDB::Simple` tokenizer can be used in fts3/4 and the others can be used in fts3/4/5. You can use `WCDB_CPP_VIRTUAL_TABLE_TOKENIZE` to config fts tokenizer for a cpp ORM class.\n */\nstatic constexpr const char* Simple = \"simple\";\nstatic constexpr const char* Porter = \"porter\";\nstatic constexpr const char* ICU = \"icu\";\nstatic constexpr const char* Unicode61 = \"unicode61\";\n\n/**\n The following two are WCDB implemented tokenizers for fts3/4. They are the same tokenizer with different name.\n When tokenizing, symbol characters are ignored by default (Before using this tokenizer, you need to use `static Database::configSymbolDetector()` to configure a symbol detector.). Consecutive English letters will be recognized as an English token, and this token will be stemmed using the porter stemming algorithm. Continuous Arabic numerals will be recognized as a single numeric token. For other Unicode characters, each character will be recognized as one token.\n For example, the sentence \"The phone number of 张三 is 12345\" will be split into these tokens: \"the\", \"phone\", \"number\", \"of\", \"张\", \"三\", \"is\", \"12345\".\n */\nstatic constexpr const char* OneOrBinary = \"wcdb_one_or_binary\";\nstatic constexpr const char* LegacyOneOrBinary\n= \"WCDB\"; // Same as OneOrBinary, just for compatibility with older versions\n\n#ifdef __ANDROID__\nstatic constexpr const char* MMICU = \"mmicu\";\n#endif\n\n/**\n The following two are WCDB implemented tokenizers for fts5.\n `BuiltinTokenizer::Verbatim` has the same tokenize rules as `BuiltinTokenizer::OneOrBinary` or `BuiltinTokenizer::LegacyOneOrBinary`.\n `BuiltinTokenizer::Pinyin` is designed for pinyin search. You can use the simplified or full pinyin of Chinese characters to search for Chinese characters. Before using this tokenizer, you need to use `static Database::configPinyinConverter()` to configure the converter from Chinese characters to their pinyins.\n */\nstatic constexpr const char* Verbatim = \"wcdb_verbatim\";\nstatic constexpr const char* Pinyin = \"wcdb_pinyin\";\n\nnamespace Parameter {\n/**\n The following three are optional parameters for WCDB implemented tokenizers. You can use `WCDB_CPP_VIRTUAL_TABLE_TOKENIZE_WITH_PARAMETERS` to config fts tokenizer with parameters for a cpp ORM class.\n Configuring `BuiltinTokenizer::Parameter::NeedSymbol` allows the tokenizer to recognize each symbol character as a token.\n Configuring `BuiltinTokenizer::Parameter::SimplifyChinese` enables the tokenizer to convert each traditional Chinese character into a simplified Chinese character, so that you can use Simplified Chinese characters to search Traditional Chinese characters. Note that you need to use `static Database::configTraditionalChineseConverter()` to configure the converter from traditional Chinese characters to their simplified Chinese characters before using the tokenizer.\n Configuring `BuiltinTokenizer::Parameter::SkipStemming` will disable the stemming during tokenization.\n */\nstatic constexpr const char* NeedSymbol = \"need_symbol\";\nstatic constexpr const char* SimplifyChinese = \"chinese_traditional_to_simplified\";\nstatic constexpr const char* SkipStemming = \"skip_stemming\";\n\n} //namespace Parameter\n\n} //namespace BuiltinTokenizer\n\nnamespace BuiltinAuxiliaryFunction {\n\n/**\n `BuiltinAuxiliaryFunction::SubstringMatchInfo` is a WCDB implemented auxiliary function for fts5.\n When you need to concat multiple contents together with multi-level separators and save them in a single column of the fts5 table, \n you can use this auxiliary function to improve the accuracy of searching for the contents of this column.\n Suppose you have a friend named 张三, whose address is 广州 and 上海, and phone number is 12345 and 67890. \n You can use semicolon and comma as two-level separators to concat your friend's information into \"张三;广州,上海;12345,67890\" and save it in a column named \"friends\" in an fts5 table.\n Then you can use following code to search your friend:\n \n        fts5Table.selectOneColumn(WCDB::Column(fts5Table.tableName).substringMatchInfo(0, \";,\"), WCDB::Column(\"friends\").match(\"州\"));\n \n The first argument of SubstringMatchInfo is a column named with table name. \n The second argument is the index of the colum you need to search. The index is are numbered starting from 0. \n The third parameter is the separator used when concating the content, which should be arranged according to their level.\n Then you will get this string result \"1,0;广;州;3;\". \n The result is made by concating a variety of information with the separator you passed in.\n The first part of the result \"1,0\" gives the hierarchical position of the matched content within matched column.\n The second part \"广;州\" is the original text of the matching content, you can use it for highlighting.\n The third part \"3\" is the byte offset of the matching content in the original text, you can use it to sort the results.\n \n @warning The search results may contain some empty strings, which are invalid results. \n This kind of results appear when the content of some rows contain the tokens you are searching for,\n but these tokens are located in different parts separated by separators.\n You just need to ignore these results.\n */\nstatic constexpr const char* SubstringMatchInfo = \"substring_match_info\";\n\n} //namespace BuiltinAuxiliaryFunction\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/common/core/fts/FTSError.cpp",
    "content": "//\n// Created by qiuwenchen on 2022/3/7.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"FTSError.hpp\"\n#include \"SQLite.h\"\n\nnamespace WCDB {\nint FTSError::OK()\n{\n    return SQLITE_OK;\n}\n\nint FTSError::Done()\n{\n    return SQLITE_DONE;\n}\n\nint FTSError::NoMem()\n{\n    return SQLITE_NOMEM;\n}\n\nint FTSError::Error()\n{\n    return SQLITE_ERROR;\n}\n\nbool FTSError::isOK(int rc)\n{\n    return rc == SQLITE_OK;\n}\n\nbool FTSError::isDone(int rc)\n{\n    return rc == SQLITE_DONE;\n}\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/core/fts/FTSError.hpp",
    "content": "//\n// Created by qiuwenchen on 2022/3/7.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"Macro.h\"\n\nnamespace WCDB {\n\nclass WCDB_API FTSError {\npublic:\n    static int OK();\n    static int Done();\n    static int NoMem();\n    static int Error();\n    static bool isOK(int rc);\n    static bool isDone(int rc);\n};\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/core/fts/MergeFTSIndexLogic.cpp",
    "content": "//\n// Created by qiuwenchen(qiuwenchen) on 2020/10/23.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"MergeFTSIndexLogic.hpp\"\n#include \"Assertion.hpp\"\n#include \"CommonCore.hpp\"\n#include \"CoreConst.h\"\n#include \"Notifier.hpp\"\n#include \"WCDBError.hpp\"\n#include <cmath>\n\nnamespace WCDB {\n\nMergeFTSIndexHandleProvider::~MergeFTSIndexHandleProvider() = default;\n\nMergeFTSIndexLogic::MergeFTSIndexLogic(MergeFTSIndexHandleProvider *handleProvider)\n: m_handleProvider(handleProvider)\n, m_hasInit(false)\n, m_processing(false)\n, m_errorCount(0)\n, m_getTableStatement(StatementSelect()\n                      .select(Column(\"name\"))\n                      .from(\"sqlite_master\")\n                      .where(Column(\"type\") == \"table\"\n                             && Column(\"sql\").like(\"CREATE VIRTUAL TABLE % USING fts5(%\")))\n{\n}\n\nbool MergeFTSIndexLogic::tryInit(InnerHandle &handle)\n{\n    if (m_hasInit) {\n        return true;\n    }\n    m_mergedTables.clear();\n    m_mergingTables.clear();\n\n    if (!handle.prepare(m_getTableStatement)) {\n        return false;\n    }\n    bool success = false;\n    while ((success = handle.step()) && !handle.done()) {\n        UnsafeStringView table = handle.getText(0);\n        WCTAssert(!table.empty());\n        m_mergingTables.emplace(table);\n    }\n    handle.finalize();\n    if (!success) {\n        return false;\n    }\n    for (const StringView &element : m_mergingTables) {\n        if (!tryConfigUserMerge(handle, element, false)) {\n            return false;\n        }\n    }\n\n    m_hasInit = true;\n    return true;\n}\n\nbool MergeFTSIndexLogic::tryConfigUserMerge(InnerHandle &handle,\n                                            const UnsafeStringView &table,\n                                            bool isNew)\n{\n    bool needConfig = isNew;\n    if (!isNew) {\n        Statement selectConfig = StatementSelect()\n                                 .select(Column(\"v\"))\n                                 .from(StringView().formatted(\"%s_config\", table.data()))\n                                 .where(Column(\"k\") == \"usermerge\");\n        if (!handle.prepare(selectConfig)) {\n            return false;\n        }\n        if (!handle.step()) {\n            handle.finalize();\n            return false;\n        }\n        if (handle.done() || handle.getInteger(0) != 2) {\n            needConfig = true;\n        }\n        handle.finalize();\n    }\n    if (needConfig) {\n        if (!handle.execute(StatementInsert()\n                            .insertIntoTable(table)\n                            .columns({ Column(table), Column(\"rank\") })\n                            .values({ \"usermerge\", 2 }))) {\n            return false;\n        }\n    }\n    return true;\n}\n\nOptional<bool> MergeFTSIndexLogic::triggerMerge(TableArray newTables, TableArray modifiedTables)\n{\n    RecyclableHandle recyclableHandle = m_handleProvider->getMergeIndexHandle();\n    if (recyclableHandle == nullptr) {\n        return false;\n    }\n    WCTRemedialAssert(!recyclableHandle->isInTransaction(),\n                      \"Merge Index can't be run in transaction.\",\n                      return NullOpt;);\n\n    InnerHandle *handle = recyclableHandle.get();\n    handle->markAsCanBeSuspended(true);\n    handle->markErrorAsIgnorable(Error::Code::Busy);\n    handle->setTableMonitorEnable(false);\n\n    Optional<bool> done = triggerMerge(*handle, newTables, modifiedTables);\n    if (!done.succeed() && handle->getError().isIgnorable()) {\n        done = false;\n    }\n    handle->setTableMonitorEnable(true);\n    return done;\n}\n\nOptional<bool>\nMergeFTSIndexLogic::triggerMerge(InnerHandle &handle, TableArray newTables, TableArray modifiedTables)\n{\n    LockGuard lockGuard(m_lock);\n    if (m_errorCount.load() > 5) {\n        return NullOpt;\n    }\n    if (!tryInit(handle)) {\n        increaseErrorCount();\n        return NullOpt;\n    }\n    if (!checkModifiedTables(handle, newTables, modifiedTables)) {\n        increaseErrorCount();\n        return NullOpt;\n    }\n    if (m_mergingTables.size() == 0) {\n        return true;\n    }\n    if (m_processing) {\n        return false;\n    }\n    OperationQueue::shared().async(handle.getPath(), [](const UnsafeStringView &path) {\n        RecyclableDatabase database = CommonCore::shared().getOrCreateDatabase(path);\n        if (database != nullptr) {\n            database->proccessMerge();\n        }\n    });\n    return false;\n}\n\nvoid MergeFTSIndexLogic::proccessMerge()\n{\n    StringView table;\n    {\n        SharedLockGuard lockGuard(m_lock);\n        if (m_errorCount > 5) {\n            return;\n        }\n        if (m_mergingTables.size() == 0) {\n            return;\n        }\n        table = *m_mergingTables.begin();\n    }\n    RecyclableHandle recyclableHandle = m_handleProvider->getMergeIndexHandle();\n    if (recyclableHandle == nullptr) {\n        return;\n    }\n    WCTRemedialAssert(!recyclableHandle->isInTransaction(),\n                      \"Merge Index can't be run in transaction.\",\n                      return;);\n\n    InnerHandle *handle = recyclableHandle.get();\n    handle->markAsCanBeSuspended(true);\n    handle->markErrorAsIgnorable(Error::Code::Busy);\n    handle->setTableMonitorEnable(false);\n\n    while (!table.empty()) {\n        if (!mergeTable(*handle, table)) {\n            if (!handle->getError().isIgnorable()) {\n                increaseErrorCount();\n            }\n            break;\n        }\n        SharedLockGuard lockGuard(m_lock);\n        m_mergingTables.erase(table);\n        m_mergedTables.emplace(table);\n        if (m_mergingTables.size() > 0) {\n            table = *m_mergingTables.begin();\n        } else {\n            break;\n        }\n    }\n    handle->setTableMonitorEnable(true);\n}\n\nbool MergeFTSIndexLogic::mergeTable(InnerHandle &handle, const StringView &table)\n{\n    int preChangeCount;\n    Statement mergeSTM\n    = StatementInsert()\n      .insertIntoTable(table)\n      .columns({ Column(table), Column(\"rank\"), Column().rowid() })\n      .values({ UnsafeStringView(\"merge\"), 256, WCDB::BindParameter(1) });\n    if (!handle.prepare(mergeSTM)) {\n        return false;\n    }\n    void **callbackPointer = new void *[2];\n    callbackPointer[0] = (void *) MergeFTSIndexLogic::userMergeCallback;\n    callbackPointer[1] = &handle;\n    do {\n        preChangeCount = handle.getTotalChange();\n        handle.bindPointer(callbackPointer, 1, \"fts5_user_merge_callback\", nullptr);\n        if (!handle.step()) {\n            handle.finalize();\n            delete[] callbackPointer;\n            return false;\n        } else {\n            handle.reset();\n        }\n        //Use prime numbers to reduce the probability of collision with external logic\n        std::this_thread::sleep_for(std::chrono::microseconds(1229));\n    } while (handle.getTotalChange() - preChangeCount > 1);\n    handle.finalize();\n    delete[] callbackPointer;\n    return true;\n}\n\nvoid MergeFTSIndexLogic::userMergeCallback(InnerHandle *handle,\n                                           int *remainPages,\n                                           int totalPagesWriten,\n                                           int *lastCheckPages)\n{\n    if (totalPagesWriten - *lastCheckPages < 16) {\n        return;\n    }\n    *lastCheckPages = totalPagesWriten;\n    if (!handle->checkHasBusyRetry()) {\n        return;\n    }\n    *remainPages = totalPagesWriten - 1;\n}\n\nbool MergeFTSIndexLogic::checkModifiedTables(InnerHandle &handle,\n                                             TableArray newTables,\n                                             TableArray modifiedTables)\n{\n    if (newTables != nullptr && newTables->size() > 0) {\n        StatementSelect select\n        = StatementSelect()\n          .select(Column().rowid())\n          .from(\"sqlite_master\")\n          .where(Column(\"name\") == BindParameter(1)\n                 && Column(\"sql\").like(\"CREATE VIRTUAL TABLE % USING fts5(%\"));\n\n        if (!handle.prepare(select)) {\n            return false;\n        }\n\n        TableArray fts5Tables(new std::vector<StringView>());\n\n        for (const auto &element : *newTables) {\n            if (m_mergedTables.find(element) != m_mergedTables.end()) {\n                m_mergedTables.erase(element);\n            }\n            handle.bindText(element.data(), 1);\n            if (!handle.step()) {\n                handle.finalize();\n                return false;\n            }\n            if (!handle.done()) {\n                m_mergingTables.emplace(element);\n                fts5Tables->push_back(element);\n            }\n            handle.reset();\n        }\n\n        handle.finalize();\n\n        for (const auto &element : *fts5Tables) {\n            if (!tryConfigUserMerge(handle, element, true)) {\n                return false;\n            }\n        }\n    }\n\n    if (modifiedTables != nullptr && modifiedTables->size() > 0) {\n        for (const auto &element : *modifiedTables) {\n            if (m_mergedTables.find(element) != m_mergedTables.end()) {\n                m_mergedTables.erase(element);\n                m_mergingTables.emplace(element);\n            }\n        }\n    }\n    return true;\n}\n\nvoid MergeFTSIndexLogic::increaseErrorCount()\n{\n    m_errorCount++;\n    if (m_errorCount.load() > 5) {\n        Error error(Error::Code::Notice,\n                    Error::Level::Notice,\n                    \"Auto merge fts index is stopped due to too many errors.\");\n        error.infos.insert_or_assign(ErrorStringKeyPath, m_handleProvider->getPath());\n        error.infos.insert_or_assign(ErrorStringKeyType, ErrorTypeMergeIndex);\n        Notifier::shared().notify(error);\n    }\n}\n\n#pragma mark - OperationQueue\n\nMergeFTSIndexLogic::OperationQueue &MergeFTSIndexLogic::OperationQueue::shared()\n{\n    static OperationQueue *g_operationQueue = nullptr;\n    if (!g_operationQueue) {\n        g_operationQueue = new OperationQueue(AutoMergeFTSIndexQueueName);\n    }\n    return *g_operationQueue;\n}\n\nMergeFTSIndexLogic::OperationQueue::OperationQueue(const UnsafeStringView &name)\n: AsyncQueue(name)\n{\n    run();\n}\n\nvoid MergeFTSIndexLogic::OperationQueue::async(const UnsafeStringView &path,\n                                               const OperationCallBack &callback)\n{\n    m_timedQueue.queue(StringView(path), 0, callback, AsyncMode::ForwardOnly);\n}\n\nvoid MergeFTSIndexLogic::OperationQueue::cancelOperation(const UnsafeStringView &path)\n{\n    m_timedQueue.remove(StringView(path));\n}\n\nvoid MergeFTSIndexLogic::OperationQueue::main()\n{\n    m_timedQueue.loop(std::bind(&MergeFTSIndexLogic::OperationQueue::onTimed,\n                                this,\n                                std::placeholders::_1,\n                                std::placeholders::_2));\n}\n\nvoid MergeFTSIndexLogic::OperationQueue::onTimed(const StringView &path,\n                                                 const OperationCallBack &callback)\n{\n    CommonCore::shared().setThreadedErrorIgnorable(true);\n    callback(path);\n    CommonCore::shared().setThreadedErrorIgnorable(false);\n}\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/core/fts/MergeFTSIndexLogic.hpp",
    "content": "//\n// Created by qiuwenchen(qiuwenchen) on 2020/10/23.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"AsyncQueue.hpp\"\n#include \"InnerHandle.hpp\"\n#include \"Lock.hpp\"\n#include \"RecyclableHandle.hpp\"\n#include \"StringView.hpp\"\n#include \"TimedQueue.hpp\"\n#include <array>\n\nnamespace WCDB {\n\nclass MergeFTSIndexHandleProvider {\npublic:\n    virtual ~MergeFTSIndexHandleProvider() = 0;\n\nprotected:\n    friend class MergeFTSIndexLogic;\n    virtual RecyclableHandle getMergeIndexHandle() = 0;\n    virtual const StringView& getPath() const = 0;\n};\n\nclass MergeFTSIndexLogic {\npublic:\n    MergeFTSIndexLogic() = delete;\n    MergeFTSIndexLogic(MergeFTSIndexHandleProvider* provider);\n    using TableArray = std::shared_ptr<std::vector<StringView>>;\n    Optional<bool> triggerMerge(TableArray newTables, TableArray modifiedTables);\n    void proccessMerge();\n\nprivate:\n    bool tryInit(InnerHandle& handle);\n    Optional<bool>\n    triggerMerge(InnerHandle& handle, TableArray newTables, TableArray modifiedTables);\n    bool tryConfigUserMerge(InnerHandle& handle, const UnsafeStringView& table, bool isNew);\n    bool checkModifiedTables(InnerHandle& handle, TableArray newTables, TableArray modifiedTables);\n    bool mergeTable(InnerHandle& handle, const StringView& table);\n    void increaseErrorCount();\n\n    static void\n    userMergeCallback(InnerHandle* handle, int* remainPages, int totalPagesWriten, int* lastCheckPages);\n\n    MergeFTSIndexHandleProvider* m_handleProvider;\n\n    bool m_hasInit;\n    std::atomic<bool> m_processing;\n    std::atomic<int> m_errorCount;\n\n    SharedLock m_lock;\n\n    Statement m_getTableStatement;\n    StringViewSet m_mergingTables;\n    StringViewSet m_mergedTables;\n\nprivate:\n    class OperationQueue : public AsyncQueue {\n    public:\n        OperationQueue() = delete;\n        OperationQueue(const UnsafeStringView& name);\n        static OperationQueue& shared();\n\n        using OperationCallBack = std::function<void(const UnsafeStringView&)>;\n        void async(const UnsafeStringView& path, const OperationCallBack& callback);\n        void cancelOperation(const UnsafeStringView& path);\n\n    private:\n        using AsyncMode = TimedQueue<StringView, OperationCallBack>::Mode;\n        void main() override final;\n        TimedQueue<StringView, OperationCallBack> m_timedQueue;\n        void onTimed(const StringView& path, const OperationCallBack& callback);\n    };\n};\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/core/fts/auxfunction/AuxiliaryFunctionConfig.cpp",
    "content": "//\n// Created by qiuwenchen on 2021/10/17.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"AuxiliaryFunctionConfig.hpp\"\n#include \"Assertion.hpp\"\n#include \"InnerHandle.hpp\"\n#include \"SQLite.h\"\n\nnamespace WCDB {\n\nAuxiliaryFunctionConfig::AuxiliaryFunctionConfig(const UnsafeStringView& name_,\n                                                 const std::shared_ptr<AuxiliaryFunctionModules>& modules)\n: Config()\n, name(name_)\n, m_modules(modules)\n, m_Statement(StatementSelect().select(\n  Expression::function(\"fts5\").invoke().arguments(BindParameter::bindParameters(1))))\n{\n}\n\nAuxiliaryFunctionConfig::~AuxiliaryFunctionConfig() = default;\n\nbool AuxiliaryFunctionConfig::invoke(InnerHandle* handle)\n{\n    const FTS5AuxiliaryFunctionModule* module = m_modules->get(name);\n    WCTRemedialAssert(module != nullptr, \"Module does not exist.\", return true;);\n    fts5_api* api = nullptr;\n    if (handle->prepare(m_Statement)) {\n        const UnsafeStringView type = \"fts5_api_ptr\";\n        handle->bindPointer((void*) &api, 1, type, nullptr);\n        if (!handle->step() || api == nullptr) {\n            handle->finalize();\n            return false;\n        }\n        handle->finalize();\n    }\n    int rc = api->xCreateFunction(\n    api,\n    name.data(),\n    module->getContext(),\n    (void (*)(const Fts5ExtensionApi*, Fts5Context*, sqlite3_context*, int, sqlite3_value**))\n    module->getFunc(),\n    nullptr);\n    if (rc != SQLITE_OK) {\n        handle->notifyError(rc, \"create fts5 auxiliary function\");\n        return false;\n    }\n    return true;\n}\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/common/core/fts/auxfunction/AuxiliaryFunctionConfig.hpp",
    "content": "//\n// Created by qiuwenchen on 2021/10/17.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"AuxiliaryFunctionModule.hpp\"\n#include \"Config.hpp\"\n#include \"FunctionModules.hpp\"\n#include \"WINQ.h\"\n\nnamespace WCDB {\n\ntypedef FunctionModules<FTS5AuxiliaryFunctionModule> AuxiliaryFunctionModules;\n\nclass AuxiliaryFunctionConfig final : public Config {\npublic:\n    AuxiliaryFunctionConfig(const UnsafeStringView& name,\n                            const std::shared_ptr<AuxiliaryFunctionModules>& modules);\n    ~AuxiliaryFunctionConfig() override;\n\n    StringView name;\n\n    bool invoke(InnerHandle* handle) override final;\n\nprotected:\n    std::shared_ptr<AuxiliaryFunctionModules> m_modules;\n    StatementSelect m_Statement;\n};\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/common/core/fts/auxfunction/AuxiliaryFunctionModule.cpp",
    "content": "//\n// Created by qiuwenchen on 2021/10/17.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"AuxiliaryFunctionModule.hpp\"\n#include \"Assertion.hpp\"\n#include \"SQLite.h\"\n\nnamespace WCDB {\n\nFTS5AuxiliaryFunctionAPI::FTS5AuxiliaryFunctionAPI(const FTS5AuxiliaryFunctionAPIPointer* ptr,\n                                                   FTS5AuxiliaryFunctionContext* functionContext,\n                                                   SQLiteContext* sqliteContext,\n                                                   SQLiteValue** values,\n                                                   int valueNum)\n: ScalarFunctionAPI(sqliteContext, values, valueNum)\n, m_ptr(ptr)\n, m_functionContext(functionContext)\n, m_queryCallback(nullptr)\n{\n}\n\nAbstractFTS5AuxiliaryFunctionObject* FTS5AuxiliaryFunctionAPI::getOrCreateFunctionObject(\nstd::function<AbstractFTS5AuxiliaryFunctionObject*(void*)> createHandler,\nvoid (*freeHandler)(void*))\n{\n    AbstractFTS5AuxiliaryFunctionObject* funcObject\n    = (AbstractFTS5AuxiliaryFunctionObject*) ((Fts5ExtensionApi*) m_ptr)\n      ->xGetAuxdata((Fts5Context*) m_functionContext, false);\n    if (funcObject == nullptr) {\n        WCTAssert(createHandler != nullptr);\n        if (createHandler == nullptr) {\n            return nullptr;\n        }\n        void* userData\n        = ((Fts5ExtensionApi*) m_ptr)->xUserData((Fts5Context*) m_functionContext);\n        funcObject = createHandler(userData);\n        ((Fts5ExtensionApi*) m_ptr)->xSetAuxdata((Fts5Context*) m_functionContext, (void*) funcObject, freeHandler);\n    }\n    return funcObject;\n}\n\nint FTS5AuxiliaryFunctionAPI::getColumnCount()\n{\n    return ((Fts5ExtensionApi*) m_ptr)->xColumnCount((Fts5Context*) m_functionContext);\n}\n\nint FTS5AuxiliaryFunctionAPI::getRowCount(int64_t* rowCount)\n{\n    return ((Fts5ExtensionApi*) m_ptr)->xRowCount((Fts5Context*) m_functionContext, (sqlite3_int64*) rowCount);\n}\n\nint64_t FTS5AuxiliaryFunctionAPI::getRowid()\n{\n    return ((Fts5ExtensionApi*) m_ptr)->xRowid((Fts5Context*) m_functionContext);\n}\n\nint FTS5AuxiliaryFunctionAPI::getColumnSize(int column, int* columnSize)\n{\n    return ((Fts5ExtensionApi*) m_ptr)->xColumnSize((Fts5Context*) m_functionContext, column, columnSize);\n}\n\nint FTS5AuxiliaryFunctionAPI::getColumnTotalSize(int column, int64_t* columnTotalSize)\n{\n    return ((Fts5ExtensionApi*) m_ptr)\n    ->xColumnTotalSize((Fts5Context*) m_functionContext, column, (sqlite3_int64*) columnTotalSize);\n}\n\nint FTS5AuxiliaryFunctionAPI::getPhraseCount()\n{\n    return ((Fts5ExtensionApi*) m_ptr)->xPhraseCount((Fts5Context*) m_functionContext);\n}\n\nint FTS5AuxiliaryFunctionAPI::getPhraseSize(int phraseNum)\n{\n    return ((Fts5ExtensionApi*) m_ptr)->xPhraseSize((Fts5Context*) m_functionContext, phraseNum);\n}\n\nint FTS5AuxiliaryFunctionAPI::instCount(int* count)\n{\n    return ((Fts5ExtensionApi*) m_ptr)->xInstCount((Fts5Context*) m_functionContext, count);\n}\n\nint FTS5AuxiliaryFunctionAPI::inst(int instIndex, int* phraseNum, int* column, int* instOffset)\n{\n    return ((Fts5ExtensionApi*) m_ptr)\n    ->xInst((Fts5Context*) m_functionContext, instIndex, phraseNum, column, instOffset);\n}\n\nint FTS5AuxiliaryFunctionAPI::getTextForThisRow(int column, UnsafeStringView& output)\n{\n    const char* text = nullptr;\n    int textLength = 0;\n    int ret\n    = ((Fts5ExtensionApi*) m_ptr)->xColumnText((Fts5Context*) m_functionContext, column, &text, &textLength);\n    if (FTSError::isOK(ret)) {\n        output = UnsafeStringView(text, textLength);\n    }\n    return ret;\n}\n\nint FTS5AuxiliaryFunctionAPI::tokenize(const UnsafeStringView& text,\n                                       void* context,\n                                       int (*tokenCallback)(void*, int, const char*, int, int, int))\n{\n    return ((Fts5ExtensionApi*) m_ptr)\n    ->xTokenize(\n    (Fts5Context*) m_functionContext, text.data(), (int) text.length(), context, tokenCallback);\n}\n\nint FTS5AuxiliaryFunctionAPI::queryPhrase(int phraseNum,\n                                          void* userData,\n                                          int (*callback)(FTS5AuxiliaryFunctionAPI&, void*))\n{\n    WCTRemedialAssert(\n    callback != nullptr, \"callback should not be null\", return FTSError::Error(););\n    m_queryCallback = [userData, callback](FTS5AuxiliaryFunctionAPI& apiObj) {\n        return callback(apiObj, userData);\n    };\n    int ret = ((Fts5ExtensionApi*) m_ptr)\n              ->xQueryPhrase((Fts5Context*) m_functionContext,\n                             phraseNum,\n                             (void*) this,\n                             (int (*)(const Fts5ExtensionApi*, Fts5Context*, void*)) queryCallBack);\n    m_queryCallback = nullptr;\n    return ret;\n}\n\nint FTS5AuxiliaryFunctionAPI::queryCallBack(const FTS5AuxiliaryFunctionAPIPointer* apiPointer,\n                                            FTS5AuxiliaryFunctionContext* functionContext,\n                                            void* queryContext)\n{\n    FTS5AuxiliaryFunctionAPI* apiObj = (FTS5AuxiliaryFunctionAPI*) queryContext;\n    FTS5AuxiliaryFunctionAPI newAPIObj\n    = FTS5AuxiliaryFunctionAPI(apiPointer, functionContext, nullptr, nullptr, 0);\n    WCTAssert(apiObj->m_queryCallback != nullptr);\n    return apiObj->m_queryCallback(newAPIObj);\n}\n\nAbstractFTS5AuxiliaryFunctionObject::AbstractFTS5AuxiliaryFunctionObject(\nvoid* userContext, FTS5AuxiliaryFunctionAPI& apiObj)\n{\n    WCDB_UNUSED(userContext);\n    WCDB_UNUSED(apiObj);\n}\n\nAbstractFTS5AuxiliaryFunctionObject::~AbstractFTS5AuxiliaryFunctionObject() = default;\n\nFTS5AuxiliaryFunctionModule::FTS5AuxiliaryFunctionModule(const AuxiliaryFunction& func,\n                                                         void* context)\n: m_func(func), m_context(context)\n{\n}\n\nFTS5AuxiliaryFunctionModule::AuxiliaryFunction FTS5AuxiliaryFunctionModule::getFunc() const\n{\n    return m_func;\n}\n\nvoid* FTS5AuxiliaryFunctionModule::getContext() const\n{\n    return m_context;\n}\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/core/fts/auxfunction/AuxiliaryFunctionModule.hpp",
    "content": "//\n// Created by qiuwenchen on 2021/10/17.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"FTSError.hpp\"\n#include \"ScalarFunctionModule.hpp\"\n#include <functional>\n\ntypedef struct FTS5AuxiliaryFunctionAPIPointer FTS5AuxiliaryFunctionAPIPointer;\ntypedef struct FTS5AuxiliaryFunctionContext FTS5AuxiliaryFunctionContext;\n\nnamespace WCDB {\n\nclass AbstractFTS5AuxiliaryFunctionObject;\n\ntemplate<typename AuxiliaryFunctionObject>\nclass FTS5AuxiliaryFunctionTemplate;\n\nclass WCDB_API FTS5AuxiliaryFunctionAPI : public ScalarFunctionAPI {\n    template<typename AuxiliaryFunctionObject>\n    friend class FTS5AuxiliaryFunctionTemplate;\n\npublic:\n    // FTS5 Extension API\n    int getColumnCount();\n    int getRowCount(int64_t* rowCount);\n    int64_t getRowid();\n    int getColumnSize(int column, int* columnSize);\n    int getColumnTotalSize(int column, int64_t* columnTotalSize);\n    int getPhraseCount();\n    int getPhraseSize(int phraseNum);\n    int instCount(int* count);\n    int inst(int instIndex, int* phraseNum, int* column, int* instOffset);\n    int getTextForThisRow(int column, UnsafeStringView& output);\n    int tokenize(const UnsafeStringView& text,\n                 void* context,\n                 int (*tokenCallback)(void*, int, const char*, int, int, int));\n    int queryPhrase(int phraseNum,\n                    void* userData,\n                    int (*callback)(FTS5AuxiliaryFunctionAPI&, void*));\n\nprotected:\n    FTS5AuxiliaryFunctionAPI(const FTS5AuxiliaryFunctionAPIPointer* ptr,\n                             FTS5AuxiliaryFunctionContext* functionContext,\n                             SQLiteContext* sqliteContext,\n                             SQLiteValue** values,\n                             int valueNum);\n\n    AbstractFTS5AuxiliaryFunctionObject*\n    getOrCreateFunctionObject(std::function<AbstractFTS5AuxiliaryFunctionObject*(void*)> createHandler,\n                              void (*freeHandler)(void*));\n\nprivate:\n    static int queryCallBack(const FTS5AuxiliaryFunctionAPIPointer* apiPointer,\n                             FTS5AuxiliaryFunctionContext* functionContext,\n                             void* queryContext);\n\n    const FTS5AuxiliaryFunctionAPIPointer* m_ptr;\n    FTS5AuxiliaryFunctionContext* m_functionContext;\n    std::function<int(FTS5AuxiliaryFunctionAPI&)> m_queryCallback;\n};\n\nclass WCDB_API AbstractFTS5AuxiliaryFunctionObject {\npublic:\n    AbstractFTS5AuxiliaryFunctionObject(void* userContext, FTS5AuxiliaryFunctionAPI& apiObj);\n    virtual ~AbstractFTS5AuxiliaryFunctionObject() = 0;\n    virtual void process(FTS5AuxiliaryFunctionAPI& apiObj) = 0;\n};\n\nclass WCDB_API FTS5AuxiliaryFunctionModule final {\npublic:\n    typedef void (*AuxiliaryFunction)(const FTS5AuxiliaryFunctionAPIPointer* pApi,\n                                      FTS5AuxiliaryFunctionContext* pFts,\n                                      SQLiteContext* pCtx,\n                                      int nVal,\n                                      SQLiteValue** apVal);\n    FTS5AuxiliaryFunctionModule() = delete;\n    FTS5AuxiliaryFunctionModule(const AuxiliaryFunction& func, void* context = nullptr);\n    AuxiliaryFunction getFunc() const;\n    void* getContext() const;\n\nprivate:\n    AuxiliaryFunction m_func;\n    void* m_context;\n};\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/core/fts/auxfunction/FTS5AuxiliaryFunctionTemplate.hpp",
    "content": "//\n// Created by qiuwenchen on 2021/10/17.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"AuxiliaryFunctionModule.hpp\"\n\nnamespace WCDB {\n\ntemplate<typename AuxiliaryFunctionObject>\nclass FTS5AuxiliaryFunctionTemplate {\npublic:\n    static_assert(std::is_base_of<AbstractFTS5AuxiliaryFunctionObject, AuxiliaryFunctionObject>::value,\n                  \"\");\n\n    static FTS5AuxiliaryFunctionModule specializeWithContext(void *userContext)\n    {\n        return FTS5AuxiliaryFunctionModule(run, userContext);\n    }\n\n    static void run(const FTS5AuxiliaryFunctionAPIPointer *pApi,\n                    FTS5AuxiliaryFunctionContext *pFts,\n                    SQLiteContext *pCtx,\n                    int nVal,\n                    SQLiteValue **apVal)\n    {\n        FTS5AuxiliaryFunctionAPI apiObj\n        = FTS5AuxiliaryFunctionAPI(pApi, pFts, pCtx, apVal, nVal);\n        AbstractFTS5AuxiliaryFunctionObject *funcObject = apiObj.getOrCreateFunctionObject(\n        [&apiObj](void *userData) {\n            AbstractFTS5AuxiliaryFunctionObject *funcObject\n            = static_cast<AbstractFTS5AuxiliaryFunctionObject *>(\n            new AuxiliaryFunctionObject(userData, apiObj));\n            return funcObject;\n        },\n        deleteAuxData);\n\n        if (funcObject != nullptr) {\n            funcObject->process(apiObj);\n        }\n    }\n\n    static void deleteAuxData(void *auxObject)\n    {\n        if (auxObject != nullptr) {\n            delete static_cast<AuxiliaryFunctionObject *>(auxObject);\n        }\n    }\n};\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/core/fts/auxfunction/SubstringMatchInfo.cpp",
    "content": "//\n// Created by qiuwenchen on 2021/10/17.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"SubstringMatchInfo.hpp\"\n#include \"Assertion.hpp\"\n#include <cstring>\n\nnamespace WCDB {\n\n#pragma mark - MultiLevelHighlight\n\nSubstringMatchInfo::SubstringMatchInfo(void *userContext, FTS5AuxiliaryFunctionAPI &apiObj)\n: AbstractFTS5AuxiliaryFunctionObject(userContext, apiObj)\n, m_columnNum(0)\n, m_phaseMatchResult(nullptr)\n, m_substringPhaseMatchCount(0)\n, m_currentPhaseMatchCount(0)\n, m_phaseCount(0)\n, m_matchIndex(nullptr)\n, m_tokenPos(0)\n, m_bytePos(0)\n, m_curLevelStartPos(0)\n{\n    WCTAssert(apiObj.getValueCount() == 2);\n    if (apiObj.getValueCount() != 2) {\n        return;\n    }\n    m_columnNum = (int) apiObj.getIntValue(0);\n    m_seperators = apiObj.getTextValue(1);\n    m_matchIndex = new int[m_seperators.length()];\n}\n\nSubstringMatchInfo::~SubstringMatchInfo()\n{\n    if (m_phaseMatchResult != nullptr) {\n        delete[] m_phaseMatchResult;\n    }\n    if (m_matchIndex != nullptr) {\n        delete[] m_matchIndex;\n    }\n}\n\nvoid SubstringMatchInfo::resetStatusFromLevel(int level)\n{\n    memset(m_phaseMatchResult, 0, m_phaseCount * sizeof(bool));\n    m_substringPhaseMatchCount = 0;\n\n    if (level < m_seperators.length()) {\n        memset(&m_matchIndex[level], 0, (m_seperators.length() - level) * sizeof(int));\n    }\n    m_output.clear();\n    m_curLevelStartPos = m_bytePos;\n}\n\nint SubstringMatchInfo::checkSeperator(char sep)\n{\n    for (int i = 0; i < m_seperators.length(); i++) {\n        if (m_seperators.at(i) == sep) {\n            return i;\n        }\n    }\n    return -1;\n}\n\nint SubstringMatchInfo::tokenCallback(\nvoid *pContext, int tflags, const char *pToken, int nToken, int iStartOff, int iEndOff)\n{\n    SubstringMatchInfo *funcObjc = static_cast<SubstringMatchInfo *>(pContext);\n    return funcObjc->internalTokenCallback(tflags, pToken, nToken, iStartOff, iEndOff);\n}\n\nint SubstringMatchInfo::internalTokenCallback(\nint tflags, const char *pToken, int nToken, int iStartOff, int iEndOff)\n{\n    if (tflags != 0) {\n        return FTSError::OK();\n    }\n    WCDB_UNUSED(nToken);\n    int iPos = m_tokenPos;\n    int rc = FTSError::OK();\n    m_tokenPos++;\n\n    int level = checkSeperator(pToken[0]);\n    if (level >= 0) {\n        if (m_substringPhaseMatchCount >= m_currentPhaseMatchCount) {\n            WCTAssert(m_substringPhaseMatchCount == m_currentPhaseMatchCount);\n            m_output.emplace_back(std::make_pair(\n            UnsafeStringView(&m_input[m_bytePos], iStartOff - m_bytePos), -1));\n            m_bytePos = iStartOff;\n            return FTSError::Done();\n        } else {\n            m_matchIndex[level]++;\n            m_bytePos = iEndOff;\n            resetStatusFromLevel(level + 1);\n        }\n    } else if (iPos == m_pIter.m_curPhaseStart) {\n        if (iStartOff > m_bytePos) {\n            m_output.emplace_back(std::make_pair(\n            UnsafeStringView(&m_input[m_bytePos], iStartOff - m_bytePos), -1));\n        }\n        m_bytePos = iStartOff;\n    }\n    if (iPos == m_pIter.m_curPhaseEnd) {\n        m_output.emplace_back(std::make_pair(\n        UnsafeStringView(&m_input[m_bytePos], iEndOff - m_bytePos),\n        m_bytePos - m_curLevelStartPos));\n        m_bytePos = iEndOff;\n        for (int phaseIndex : m_pIter.m_phaseIndexes) {\n            if (!m_phaseMatchResult[phaseIndex]) {\n                m_phaseMatchResult[phaseIndex] = true;\n                m_substringPhaseMatchCount++;\n            }\n        }\n        if (m_pIter.m_iInst < m_pIter.m_nInst\n            && m_substringPhaseMatchCount < m_currentPhaseMatchCount) {\n            rc = m_pIter.next(m_columnNum);\n        } else {\n            rc = FTSError::Done();\n        }\n    }\n    return rc;\n}\n\nvoid SubstringMatchInfo::process(FTS5AuxiliaryFunctionAPI &apiObj)\n{\n    m_input = UnsafeStringView();\n    m_tokenPos = 0;\n    m_bytePos = 0;\n    int rc = FTSError::OK();\n\n    rc = apiObj.getTextForThisRow(m_columnNum, m_input);\n    if (m_input.length() > 0) {\n        m_phaseCount = apiObj.getPhraseCount();\n        if (!m_phaseMatchResult) {\n            m_phaseMatchResult = new bool[m_phaseCount];\n        }\n        m_pIter = PhaseInstIter();\n        rc = m_pIter.init(&apiObj);\n        if (FTSError::isOK(rc)) {\n            m_currentPhaseMatchCount = 0;\n            memset(m_phaseMatchResult, 0, m_phaseCount * sizeof(bool));\n            rc = m_pIter.next(m_columnNum);\n            while (FTSError::isOK(rc)) {\n                for (int phaseIndex : m_pIter.m_phaseIndexes) {\n                    if (!m_phaseMatchResult[phaseIndex]) {\n                        m_phaseMatchResult[phaseIndex] = true;\n                        m_currentPhaseMatchCount++;\n                    }\n                }\n                if (m_pIter.m_iInst >= m_pIter.m_nInst) {\n                    break;\n                }\n                rc = m_pIter.next(m_columnNum);\n            }\n            m_pIter.m_iInst = 0;\n            rc = m_pIter.next(m_columnNum);\n        }\n        resetStatusFromLevel(0);\n        if (FTSError::isOK(rc)) {\n            rc = apiObj.tokenize(m_input, this, tokenCallback);\n        }\n        if (m_bytePos < m_input.length()) {\n            int i = m_bytePos;\n            for (; i < m_input.length(); i++) {\n                int level = checkSeperator(m_input[i]);\n                if (level >= 0) {\n                    m_output.emplace_back(std::make_pair(\n                    UnsafeStringView(&m_input[m_bytePos], i - m_bytePos), -1));\n                    break;\n                }\n            }\n            if (i == m_input.length()) {\n                m_output.emplace_back(std::make_pair(\n                UnsafeStringView(&m_input[m_bytePos], i - m_bytePos), -1));\n            }\n        }\n        if ((FTSError::isOK(rc) || FTSError::isDone(rc))\n            && m_substringPhaseMatchCount >= m_currentPhaseMatchCount) {\n            WCTAssert(m_substringPhaseMatchCount == m_currentPhaseMatchCount);\n            std::ostringstream stream;\n            generateOutput(stream);\n            StringView output = stream.str();\n            apiObj.setTextResult(output);\n        }\n    }\n    if (!FTSError::isOK(rc) && !FTSError::isDone(rc)) {\n        StringView msg = StringView(\"parse match info fail\");\n        apiObj.setErrorResult(rc, msg);\n    }\n}\n\nvoid SubstringMatchInfo::generateOutput(std::ostringstream &stream)\n{\n    for (int i = 0; i < m_seperators.length(); i++) {\n        if (i != 0) {\n            stream << ',';\n        }\n        stream << m_matchIndex[i];\n    }\n    stream << m_seperators[0];\n    for (auto &output : m_output) {\n        if (output.second >= 0) {\n            stream << m_seperators[0];\n            stream << output.first;\n            stream << m_seperators[0];\n            stream << output.second;\n            stream << m_seperators[0];\n        } else {\n            stream << output.first;\n        }\n    }\n}\n\n#pragma mark - PhaseInstIter\n\nSubstringMatchInfo::PhaseInstIter::PhaseInstIter()\n: m_curPhaseStart(-1), m_curPhaseEnd(-1), m_iInst(0), m_nInst(0)\n{\n}\n\nSubstringMatchInfo::PhaseInstIter::~PhaseInstIter() = default;\n\nint SubstringMatchInfo::PhaseInstIter::init(FTS5AuxiliaryFunctionAPI *apiObj)\n{\n    m_apiObj = apiObj;\n    return m_apiObj->instCount(&m_nInst);\n}\n\nint SubstringMatchInfo::PhaseInstIter::next(int iCol)\n{\n    int rc = FTSError::OK();\n    m_curPhaseStart = -1;\n    m_curPhaseEnd = -1;\n    m_phaseIndexes.clear();\n\n    while (FTSError::isOK(rc) && m_iInst < m_nInst) {\n        int ic;\n        int io;\n        int ip;\n        rc = m_apiObj->inst(m_iInst, &ip, &ic, &io);\n        if (FTSError::isOK(rc)) {\n            if (ic == iCol) {\n                int iEnd = io - 1 + m_apiObj->getPhraseSize(ip);\n                if (m_curPhaseEnd < 0) {\n                    m_phaseIndexes.emplace_back(ip);\n                    m_curPhaseStart = io;\n                    m_curPhaseEnd = iEnd;\n                } else if (io <= m_curPhaseEnd) {\n                    m_phaseIndexes.emplace_back(ip);\n                    if (iEnd > m_curPhaseEnd) {\n                        m_curPhaseEnd = iEnd;\n                    }\n                } else {\n                    break;\n                }\n            }\n            m_iInst++;\n        }\n    }\n    return rc;\n}\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/core/fts/auxfunction/SubstringMatchInfo.hpp",
    "content": "//\n// Created by qiuwenchen on 2021/10/17.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"AuxiliaryFunctionModule.hpp\"\n#include <vector>\n\nnamespace WCDB {\n\nclass WCDB_API SubstringMatchInfo : public AbstractFTS5AuxiliaryFunctionObject {\npublic:\n    SubstringMatchInfo(void *userContext, FTS5AuxiliaryFunctionAPI &apiObj);\n    ~SubstringMatchInfo();\n    void process(FTS5AuxiliaryFunctionAPI &apiObj) override final;\n    static int\n    tokenCallback(void *pContext, int tflags, const char *pToken, int nToken, int iStartOff, int iEndOff);\n    int internalTokenCallback(int tflags, const char *pToken, int nToken, int iStartOff, int iEndOff);\n\nprivate:\n    class PhaseInstIter final {\n        friend class SubstringMatchInfo;\n\n    public:\n        PhaseInstIter();\n        ~PhaseInstIter();\n        int init(FTS5AuxiliaryFunctionAPI *apiObj);\n        int next(int iCol);\n\n    private:\n        FTS5AuxiliaryFunctionAPI *m_apiObj;\n        int m_curPhaseStart;\n        int m_curPhaseEnd;\n        int m_iInst;\n        int m_nInst;\n        std::vector<int> m_phaseIndexes;\n    };\n\n    void resetStatusFromLevel(int level);\n    int checkSeperator(char sep);\n    void generateOutput(std::ostringstream &stream);\n\n    UnsafeStringView m_input;\n    int m_columnNum;\n\n    bool *m_phaseMatchResult;\n    int m_substringPhaseMatchCount;\n    int m_currentPhaseMatchCount;\n    int m_phaseCount;\n\n    int *m_matchIndex;\n\n    int m_tokenPos;\n    int m_bytePos;\n    int m_curLevelStartPos;\n\n    StringView m_seperators;\n    std::vector<std::pair<UnsafeStringView, int>> m_output;\n    PhaseInstIter m_pIter;\n};\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/core/fts/tokenizer/AndroidUnicodeDefine.h",
    "content": "// Created by chenqiuwen on 2024/5/19.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"Macro.h\"\n#include <cstdlib>\n#include <cstring>\n\n/**\n * The following definition is copied from the Unicode library in Android system\n */\n\nWCDB_EXTERN_C_BEGIN\n\ntypedef enum UErrorCode {\n    U_ZERO_ERROR = 0, /**< No error, no warning. */\n} UErrorCode;\n\ntypedef int32_t UChar32;\n\ntypedef int8_t UBool;\n\n/**\n * \\def U_CDECL_END\n * This is used to end a declaration of a library private ICU C API\n * @stable ICU 2.4\n */\n\n#ifdef __cplusplus\n#define U_CFUNC extern \"C\"\n#define U_CDECL_BEGIN extern \"C\" {\n#define U_CDECL_END }\n#else\n#define U_CFUNC extern\n#define U_CDECL_BEGIN\n#define U_CDECL_END\n#endif\n\n#ifdef __has_declspec_attribute\n#define UPRV_HAS_DECLSPEC_ATTRIBUTE(x) __has_declspec_attribute(x)\n#else\n#define UPRV_HAS_DECLSPEC_ATTRIBUTE(x) 0\n#endif\n\n#ifdef U_EXPORT\n/* Use the predefined value. */\n#elif defined(U_STATIC_IMPLEMENTATION)\n#define U_EXPORT\n#elif defined(_MSC_VER)                                                        \\\n|| (UPRV_HAS_DECLSPEC_ATTRIBUTE(__dllexport__) && UPRV_HAS_DECLSPEC_ATTRIBUTE(__dllimport__))\n#define U_EXPORT __declspec(dllexport)\n#elif defined(__GNUC__)\n#define U_EXPORT __attribute__((visibility(\"default\")))\n#elif (defined(__SUNPRO_CC) && __SUNPRO_CC >= 0x550)                           \\\n|| (defined(__SUNPRO_C) && __SUNPRO_C >= 0x550)\n#define U_EXPORT __global\n/*#elif defined(__HP_aCC) || defined(__HP_cc)\n#   define U_EXPORT __declspec(dllexport)*/\n#else\n#define U_EXPORT\n#endif\n\n/* U_CALLCONV is related to U_EXPORT2 */\n#ifdef U_EXPORT2\n/* Use the predefined value. */\n#elif defined(_MSC_VER)\n#define U_EXPORT2 __cdecl\n#else\n#define U_EXPORT2\n#endif\n\n/** This is used to declare a function as a public ICU C API @stable ICU 2.0*/\n#define U_CAPI U_CFUNC U_EXPORT\n\n/** This is used to declare a function as a stable public ICU C API*/\n#define U_STABLE U_CAPI\n\n/** The possible types of text boundaries.  @stable ICU 2.0 */\ntypedef enum UBreakIteratorType {\n    /** Character breaks  @stable ICU 2.0 */\n    UBRK_CHARACTER = 0,\n    /** Word breaks @stable ICU 2.0 */\n    UBRK_WORD = 1,\n    /** Line breaks @stable ICU 2.0 */\n    UBRK_LINE = 2,\n    /** Sentence breaks @stable ICU 2.0 */\n    UBRK_SENTENCE = 3,\n\n#ifndef U_HIDE_DEPRECATED_API\n    /**\n     * Title Case breaks\n     * The iterator created using this type locates title boundaries as described for\n     * Unicode 3.2 only. For Unicode 4.0 and above title boundary iteration,\n     * please use Word Boundary iterator.\n     *\n     * @deprecated ICU 2.8 Use the word break iterator for titlecasing for Unicode 4 and later.\n     */\n    UBRK_TITLE = 4,\n#endif /* U_HIDE_DEPRECATED_API */\n    UBRK_COUNT = 5\n} UBreakIteratorType;\n\n/**\n * Set the iterator position to the index of the first character in the text being scanned.\n * This is not always the same as index 0 of the text.\n * @param bi The break iterator to use.\n * @return The character index of the first character in the text being scanned.\n * @see ubrk_last\n * @stable ICU 2.0\n */\nU_STABLE int32_t U_EXPORT2 ubrk_first(UBreakIterator *bi);\n\n#define UBRK_DONE ((int32_t) -1)\n\ntypedef enum UWordBreak {\n    /** Tag value for \"words\" that do not fit into any of other categories.\n     *  Includes spaces and most punctuation. */\n    UBRK_WORD_NONE = 0,\n    /** Upper bound for tags for uncategorized words. */\n    UBRK_WORD_NONE_LIMIT = 100,\n    /** Tag value for words that appear to be numbers, lower limit.    */\n    UBRK_WORD_NUMBER = 100,\n    /** Tag value for words that appear to be numbers, upper limit.    */\n    UBRK_WORD_NUMBER_LIMIT = 200,\n    /** Tag value for words that contain letters, excluding\n     *  hiragana, katakana or ideographic characters, lower limit.    */\n    UBRK_WORD_LETTER = 200,\n    /** Tag value for words containing letters, upper limit  */\n    UBRK_WORD_LETTER_LIMIT = 300,\n    /** Tag value for words containing kana characters, lower limit */\n    UBRK_WORD_KANA = 300,\n    /** Tag value for words containing kana characters, upper limit */\n    UBRK_WORD_KANA_LIMIT = 400,\n    /** Tag value for words containing ideographic characters, lower limit */\n    UBRK_WORD_IDEO = 400,\n    /** Tag value for words containing ideographic characters, upper limit */\n    UBRK_WORD_IDEO_LIMIT = 500\n} UWordBreak;\n\n/**\n * Constants for normalization modes.\n * @stable ICU 2.0\n */\ntypedef enum {\n    /** No decomposition/composition. @stable ICU 2.0 */\n    UNORM_NONE = 1,\n    /** Canonical decomposition. @stable ICU 2.0 */\n    UNORM_NFD = 2,\n    /** Compatibility decomposition. @stable ICU 2.0 */\n    UNORM_NFKD = 3,\n    /** Canonical decomposition followed by canonical composition. @stable ICU 2.0 */\n    UNORM_NFC = 4,\n    /** Default normalization. @stable ICU 2.0 */\n    UNORM_DEFAULT = UNORM_NFC,\n    /** Compatibility decomposition followed by canonical composition. @stable ICU 2.0 */\n    UNORM_NFKC = 5,\n    /** \"Fast C or D\" form. @stable ICU 2.0 */\n    UNORM_FCD = 6,\n\n    /** One more than the highest normalization mode constant. @stable ICU 2.0 */\n    UNORM_MODE_COUNT\n} UNormalizationMode;\n\n/**\n * Option value for case folding: Use default mappings defined in CaseFolding.txt.\n *\n * @stable ICU 2.0\n */\n#define U_FOLD_CASE_DEFAULT 0\n\n/**\n * Is this code unit (byte) a UTF-8 lead byte? (0xC2..0xF4)\n * @param c 8-bit code unit (byte)\n * @return true or false\n * @stable ICU 2.4\n */\n#define U8_IS_LEAD(c) ((uint8_t) ((c) - 0xc2) <= 0x32)\n// 0x32=0xf4-0xc2\n\n/**\n * This value is intended for sentinel values for APIs that\n * (take or) return single code points (UChar32).\n * It is outside of the Unicode code point range 0..0x10ffff.\n *\n * For example, a \"done\" or \"error\" value in a new API\n * could be indicated with U_SENTINEL.\n *\n * ICU APIs designed before ICU 2.4 usually define service-specific \"done\"\n * values, mostly 0xffff.\n * Those may need to be distinguished from\n * actual U+ffff text contents by calling functions like\n * CharacterIterator::hasNext() or UnicodeString::length().\n *\n * @return -1\n * @see UChar32\n * @stable ICU 2.4\n */\n#define U_SENTINEL (-1)\n\n/**\n * Get a code point from a string at a code point boundary offset,\n * and advance the offset to the next code point boundary.\n * (Post-incrementing forward iteration.)\n * \"Safe\" macro, checks for illegal sequences and for string boundaries.\n *\n * The offset may point to the lead byte of a multi-byte sequence,\n * in which case the macro will read the whole sequence.\n * If the offset points to a trail byte or an illegal UTF-8 sequence, then\n * c is set to a negative value.\n *\n * @param s const uint8_t * string\n * @param i string offset, must be i<length\n * @param length string length\n * @param c output UChar32 variable, set to <0 in case of an error\n * @see U8_NEXT_UNSAFE\n * @stable ICU 2.4\n */\n#define U8_NEXT(s, i, length, c)                                                                                 \\\n    {                                                                                                            \\\n        (c) = (uint8_t) (s)[(i)++];                                                                              \\\n        if ((c) >= 0x80) {                                                                                       \\\n            uint8_t __t1, __t2;                                                                                  \\\n            if (/* handle U+1000..U+CFFF inline */                                                               \\\n                (0xe0 < (c) && (c) <= 0xec) && (((i) + 1) < (length))                                            \\\n                && (__t1 = (uint8_t) ((s)[i] - 0x80)) <= 0x3f                                                    \\\n                && (__t2 = (uint8_t) ((s)[(i) + 1] - 0x80)) <= 0x3f) {                                           \\\n                /* no need for (c&0xf) because the upper bits are truncated after <<12 in the cast to (UChar) */ \\\n                (c) = (UChar) (((c) << 12) | (__t1 << 6) | __t2);                                                \\\n                (i) += 2;                                                                                        \\\n            } else if (/* handle U+0080..U+07FF inline */                                                        \\\n                       ((c) < 0xe0 && (c) >= 0xc2) && ((i) < (length))                                           \\\n                       && (__t1 = (uint8_t) ((s)[i] - 0x80)) <= 0x3f) {                                          \\\n                (c) = (UChar) ((((c) & 0x1f) << 6) | __t1);                                                      \\\n                ++(i);                                                                                           \\\n            } else if (U8_IS_LEAD(c)) {                                                                          \\\n                /* function call for \"complicated\" and error cases */                                            \\\n                (c) = utf8_nextCharSafeBody(                                                                     \\\n                (const uint8_t *) s, &(i), (int32_t) (length), c, -1);                                           \\\n            } else {                                                                                             \\\n                (c) = U_SENTINEL;                                                                                \\\n            }                                                                                                    \\\n        }                                                                                                        \\\n    }\n\n/**\n * \\def UPRV_BLOCK_MACRO_BEGIN\n * Defined as the \"do\" keyword by default.\n * @internal\n */\n#ifndef UPRV_BLOCK_MACRO_BEGIN\n#define UPRV_BLOCK_MACRO_BEGIN do\n#endif\n\n/**\n * \\def UPRV_BLOCK_MACRO_END\n * Defined as \"while (false)\" by default.\n * @internal\n */\n#ifndef UPRV_BLOCK_MACRO_END\n#define UPRV_BLOCK_MACRO_END while (false)\n#endif\n\n/**\n * Append a code point to a string, overwriting 1 or 2 code units.\n * The offset points to the current end of the string contents\n * and is advanced (post-increment).\n * \"Safe\" macro, checks for a valid code point.\n * If a surrogate pair is written, checks for sufficient space in the string.\n * If the code point is not valid or a trail surrogate does not fit,\n * then isError is set to true.\n *\n * @param s const UChar * string buffer\n * @param i string offset, must be i<capacity\n * @param capacity size of the string buffer\n * @param c code point to append\n * @param isError output UBool set to true if an error occurs, otherwise not modified\n * @see U16_APPEND_UNSAFE\n * @stable ICU 2.4\n */\n#define U16_APPEND(s, i, capacity, c, isError)                                 \\\n    UPRV_BLOCK_MACRO_BEGIN                                                     \\\n    {                                                                          \\\n        if ((uint32_t) (c) <= 0xffff) {                                        \\\n            (s)[(i)++] = (uint16_t) (c);                                       \\\n        } else if ((uint32_t) (c) <= 0x10ffff && (i) + 1 < (capacity)) {       \\\n            (s)[(i)++] = (uint16_t) (((c) >> 10) + 0xd7c0);                    \\\n            (s)[(i)++] = (uint16_t) (((c) & 0x3ff) | 0xdc00);                  \\\n        } else /* c>0x10ffff or not enough space */ {                          \\\n            (isError) = true;                                                  \\\n        }                                                                      \\\n    }                                                                          \\\n    UPRV_BLOCK_MACRO_END\n\n/**\n * Is this code unit a lead surrogate (U+d800..U+dbff)?\n * @param c 16-bit code unit\n * @return true or false\n * @stable ICU 2.4\n */\n#define U16_IS_LEAD(c) (((c) & 0xfffffc00) == 0xd800)\n\n/**\n * Does the error code indicate success?\n * @stable ICU 2.0\n */\n#define U_SUCCESS(x) ((x) <= U_ZERO_ERROR)\n/**\n * Does the error code indicate a failure?\n * @stable ICU 2.0\n */\n#define U_FAILURE(x) ((x) > U_ZERO_ERROR)\n\nWCDB_EXTERN_C_END\n"
  },
  {
    "path": "src/common/core/fts/tokenizer/AndroidUnicodeFunctions.h",
    "content": "// Created by chenqiuwen on 2024/5/19.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#ifndef ICU_UC_FUNC\n#define ICU_UC_FUNC(ret_type, func_name, arg_list)\n#endif\n\n#ifndef ICU_I18N_FUNC\n#define ICU_I18N_FUNC(ret_type, func_name, arg_list)\n#endif\n\n#ifdef ICU_DEFINE_SYMBOL\n\n/* uchar functions */\n#define u_isspace ICU_DEFINE_SYMBOL(u_isspace)\n\n/* ustring functions */\n#define u_strFoldCase ICU_DEFINE_SYMBOL(u_strFoldCase)\n#define u_strToUTF8 ICU_DEFINE_SYMBOL(u_strToUTF8)\n\n/* utf8 functions */\n#define utf8_nextCharSafeBody ICU_DEFINE_SYMBOL(utf8_nextCharSafeBody)\n\n/* ubrk functions */\n#define ubrk_open ICU_DEFINE_SYMBOL(ubrk_open)\n#define ubrk_close ICU_DEFINE_SYMBOL(ubrk_close)\n#define ubrk_current ICU_DEFINE_SYMBOL(ubrk_current)\n#define ubrk_next ICU_DEFINE_SYMBOL(ubrk_next)\n#define ubrk_first ICU_DEFINE_SYMBOL(ubrk_first)\n#define ubrk_isBoundary ICU_DEFINE_SYMBOL(ubrk_isBoundary)\n#define ubrk_getRuleStatus ICU_DEFINE_SYMBOL(ubrk_getRuleStatus)\n\n/* unorm functions */\n#define unorm_normalize ICU_DEFINE_SYMBOL(unorm_normalize)\n\n#else\n\n/* uchar functions */\nICU_UC_FUNC(UBool, u_isspace, (UChar32 c))\n\n/* ustring functions */\nICU_UC_FUNC(int32_t,\n            u_strFoldCase,\n            (UChar * dest, int32_t destCapacity, const UChar *src, int32_t srcLength, uint32_t options, UErrorCode *pErrorCode))\nICU_UC_FUNC(char *,\n            u_strToUTF8,\n            (char *dest, int32_t destCapacity, int32_t *pDestLength, const UChar *src, int32_t srcLength, UErrorCode *pErrorCode))\n\n/* utf8 functions */\nICU_UC_FUNC(UChar32,\n            utf8_nextCharSafeBody,\n            (const uint8_t *s, int32_t *pi, int32_t length, UChar32 c, UBool strict))\n\n/* ubrk functions */\nICU_UC_FUNC(UBreakIterator *,\n            ubrk_open,\n            (UBreakIteratorType type, const char *locale, const UChar *text, int32_t textLength, UErrorCode *status))\nICU_UC_FUNC(void, ubrk_close, (UBreakIterator * bi))\nICU_UC_FUNC(int32_t, ubrk_current, (const UBreakIterator *bi))\nICU_UC_FUNC(int32_t, ubrk_next, (UBreakIterator * bi))\nICU_UC_FUNC(int32_t, ubrk_first, (UBreakIterator * bi))\nICU_UC_FUNC(UBool, ubrk_isBoundary, (UBreakIterator * bi, int32_t offset))\nICU_UC_FUNC(int32_t, ubrk_getRuleStatus, (UBreakIterator * bi))\n\n/* unorm functions */\nICU_UC_FUNC(int32_t,\n            unorm_normalize,\n            (const UChar *source,\n             int32_t sourceLength,\n             UNormalizationMode mode,\n             int32_t options,\n             UChar *result,\n             int32_t resultLength,\n             UErrorCode *status))\n#endif\n"
  },
  {
    "path": "src/common/core/fts/tokenizer/BaseTokenizerUtil.cpp",
    "content": "//\n// Created by qiuwenchen on 2022/10/27.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"BaseTokenizerUtil.hpp\"\n#include \"Assertion.hpp\"\n#include \"FTSError.hpp\"\n\nnamespace WCDB {\n\n#pragma mark - Token Classify\n\nvoid BaseTokenizerUtil::stepOneUnicode(const UnsafeStringView input,\n                                       UnicodeType& unicodeType,\n                                       int& unicodeLength)\n{\n    if (input.length() == 0) {\n        unicodeType = UnicodeType::None;\n        unicodeLength = 0;\n        return;\n    }\n\n    const unsigned char& first = input.at(0);\n    if (first < 0xC0) {\n        unicodeLength = 1;\n        if (first >= 0x30 && first <= 0x39) {\n            unicodeType = UnicodeType::BasicMultilingualPlaneDigit;\n        } else if ((first >= 0x41 && first <= 0x5a) || (first >= 0x61 && first <= 0x7a)) {\n            unicodeType = UnicodeType::BasicMultilingualPlaneLetter;\n        } else {\n            if (isSymbol(first)) {\n                unicodeType = UnicodeType::BasicMultilingualPlaneSymbol;\n            } else {\n                unicodeType = UnicodeType::BasicMultilingualPlaneOther;\n            }\n        }\n    } else if (first < 0xF0) {\n        UnicodeChar unicode = 0;\n        if (first < 0xE0) {\n            unicodeLength = 2;\n            unicode = first & 0x1F;\n        } else {\n            unicodeLength = 3;\n            unicode = first & 0x0F;\n        }\n        for (int i = 1; i < unicodeLength; ++i) {\n            if (i < input.length()) {\n                WCTAssert(((unicode << 6) >> 6) == unicode);\n                unicode = (UnicodeChar) (((int) unicode << 6) | (input.at(i) & 0x3F));\n            } else {\n                break;\n            }\n        }\n        if (isSymbol(unicode)) {\n            unicodeType = UnicodeType::BasicMultilingualPlaneSymbol;\n        } else {\n            unicodeType = UnicodeType::BasicMultilingualPlaneOther;\n        }\n    } else {\n        unicodeType = UnicodeType::AuxiliaryPlaneOther;\n        if (first < 0xF8) {\n            unicodeLength = 4;\n        } else if (first < 0xFC) {\n            unicodeLength = 5;\n        } else {\n            unicodeLength = 6;\n        }\n    }\n    if (unicodeLength > input.length()) {\n        unicodeType = UnicodeType::None;\n        unicodeLength = (int) input.length();\n    }\n}\n\n#pragma mark - Symbol Detect\n\nbool BaseTokenizerUtil::isSymbol(UnicodeChar theChar)\n{\n    if (getSymbolDetector() == nullptr) {\n        return false;\n    }\n    return getSymbolDetector()(theChar);\n}\n\nvoid BaseTokenizerUtil::configSymbolDetector(SymbolDetector detector)\n{\n    getSymbolDetector() = detector;\n}\n\nBaseTokenizerUtil::SymbolDetector& BaseTokenizerUtil::getSymbolDetector()\n{\n    static SymbolDetector& g_detector = *new SymbolDetector();\n    return g_detector;\n}\n\n#pragma mark - Unicode Normalize\n\nStringView BaseTokenizerUtil::normalizeToken(UnsafeStringView& token)\n{\n    if (getUnicodeNormalizer() == nullptr) {\n        return StringView(token);\n    }\n    return getUnicodeNormalizer()(token);\n}\n\nvoid BaseTokenizerUtil::configUnicodeNormalizer(UnicodeNormalizer normalizer)\n{\n    getUnicodeNormalizer() = normalizer;\n}\n\nBaseTokenizerUtil::UnicodeNormalizer& BaseTokenizerUtil::getUnicodeNormalizer()\n{\n    static UnicodeNormalizer& g_normalizer = *new UnicodeNormalizer();\n    return g_normalizer;\n}\n\n#pragma mark - Pinyin\n\nconst std::vector<StringView>\nBaseTokenizerUtil::getPinYin(const UnsafeStringView& chineseCharacter)\n{\n    WCTAssert(g_pinyinDict != nullptr || getPinyinConverter() != nullptr);\n    if (g_pinyinDict != nullptr) {\n        auto iter = g_pinyinDict->find(chineseCharacter);\n        if (iter != g_pinyinDict->end()) {\n            return iter->second;\n        }\n    } else if (getPinyinConverter() != nullptr) {\n        return getPinyinConverter()(chineseCharacter);\n    }\n    return std::vector<StringView>();\n}\n\nWCDB::StringViewMap<std::vector<WCDB::StringView>>* BaseTokenizerUtil::g_pinyinDict = nullptr;\nvoid BaseTokenizerUtil::configPinyinDict(WCDB::StringViewMap<std::vector<WCDB::StringView>>* dict)\n{\n    if (g_pinyinDict != nullptr) {\n        delete g_pinyinDict;\n        g_pinyinDict = nullptr;\n    }\n    g_pinyinDict = dict;\n}\n\nvoid BaseTokenizerUtil::configPinyinConverter(PinYinConverter converter)\n{\n    if (g_pinyinDict != nullptr) {\n        delete g_pinyinDict;\n        g_pinyinDict = nullptr;\n    }\n    getPinyinConverter() = converter;\n}\n\nBaseTokenizerUtil::PinYinConverter& BaseTokenizerUtil::getPinyinConverter()\n{\n    static PinYinConverter& converter = *new PinYinConverter();\n    return converter;\n}\n\n#pragma mark - Traditional Chinese\n\nconst StringView BaseTokenizerUtil::getSimplifiedChinese(const UnsafeStringView& chineseCharacter)\n{\n    WCTAssert(g_traditionalChineseDict != nullptr\n              || getTraditionalChineseConverter() != nullptr);\n    if (g_traditionalChineseDict != nullptr) {\n        auto iter = g_traditionalChineseDict->find(chineseCharacter);\n        if (iter != g_traditionalChineseDict->end() && iter->second.length() > 0) {\n            return iter->second;\n        }\n    } else if (getTraditionalChineseConverter() != nullptr) {\n        const StringView traditionalChinese\n        = getTraditionalChineseConverter()(chineseCharacter);\n        if (traditionalChinese.length() > 0) {\n            return traditionalChinese;\n        }\n    }\n    return StringView(chineseCharacter);\n}\n\nWCDB::StringViewMap<WCDB::StringView>* BaseTokenizerUtil::g_traditionalChineseDict = nullptr;\nvoid BaseTokenizerUtil::configTraditionalChineseDict(WCDB::StringViewMap<WCDB::StringView>* dict)\n{\n    if (g_traditionalChineseDict != nullptr) {\n        delete g_traditionalChineseDict;\n        g_traditionalChineseDict = nullptr;\n    }\n    g_traditionalChineseDict = dict;\n}\n\nvoid BaseTokenizerUtil::configTraditionalChineseConverter(TraditionalChineseConverter converter)\n{\n    if (g_traditionalChineseDict != nullptr) {\n        delete g_traditionalChineseDict;\n        g_traditionalChineseDict = nullptr;\n    }\n    getTraditionalChineseConverter() = converter;\n}\n\nBaseTokenizerUtil::TraditionalChineseConverter&\nBaseTokenizerUtil::getTraditionalChineseConverter()\n{\n    static TraditionalChineseConverter& converter = *new TraditionalChineseConverter();\n    return converter;\n}\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/common/core/fts/tokenizer/BaseTokenizerUtil.hpp",
    "content": "//\n// Created by qiuwenchen on 2022/10/27.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"StringView.hpp\"\n#include <functional>\n#include <vector>\n\nnamespace WCDB {\n\nclass WCDB_API BaseTokenizerUtil {\npublic:\n    enum class UnicodeType : unsigned int {\n        None = 0,\n        BasicMultilingualPlaneLetter = 0x00000001,\n        BasicMultilingualPlaneDigit = 0x00000002,\n        BasicMultilingualPlaneSymbol = 0x00000003,\n        BasicMultilingualPlaneOther = 0x0000FFFF,\n        AuxiliaryPlaneOther = 0xFFFFFFFF,\n    };\n    static void\n    stepOneUnicode(const UnsafeStringView input, UnicodeType& unicodeType, int& unicodeLength);\n\n    typedef unsigned short UnicodeChar;\n    typedef std::function<bool(UnicodeChar)> SymbolDetector;\n    static void configSymbolDetector(SymbolDetector detector);\n    static bool isSymbol(UnicodeChar theChar);\n\n    typedef std::function<StringView(const UnsafeStringView&)> UnicodeNormalizer;\n    static void configUnicodeNormalizer(UnicodeNormalizer normalizer);\n    static StringView normalizeToken(UnsafeStringView& token);\n\n    static const std::vector<StringView> getPinYin(const UnsafeStringView& chineseCharacter);\n    typedef std::function<std::vector<StringView>(const UnsafeStringView&)> PinYinConverter;\n    static void configPinyinConverter(PinYinConverter converter);\n    static void\n    configPinyinDict(WCDB::StringViewMap<std::vector<WCDB::StringView>>* dict);\n\n    static const StringView getSimplifiedChinese(const UnsafeStringView& chineseCharacter);\n    typedef std::function<const StringView(const UnsafeStringView&)> TraditionalChineseConverter;\n    static void configTraditionalChineseConverter(TraditionalChineseConverter converter);\n    static void configTraditionalChineseDict(WCDB::StringViewMap<WCDB::StringView>* dict);\n\nprivate:\n    static PinYinConverter& getPinyinConverter();\n    static WCDB::StringViewMap<std::vector<WCDB::StringView>>* g_pinyinDict;\n\n    static SymbolDetector& getSymbolDetector();\n    static UnicodeNormalizer& getUnicodeNormalizer();\n    static TraditionalChineseConverter& getTraditionalChineseConverter();\n    static WCDB::StringViewMap<WCDB::StringView>* g_traditionalChineseDict;\n};\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/common/core/fts/tokenizer/MMICUTokenizer.cpp",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#ifdef __ANDROID__\n\n#include \"MMICUTokenizer.hpp\"\n#include \"AndroidUnicodeDefine.h\"\n#include \"SQLite.h\"\n#include <dirent.h>\n#include <dlfcn.h>\n#include <mutex>\n\nWCDB_EXTERN_C_BEGIN\n\ntypedef struct icu_compat_t {\n#define ICU_UC_FUNC(retType, funcName, argList)                                \\\n    retType(U_EXPORT2 *funcName##_) argList;\n#define ICU_I18N_FUNC(retType, funcName, argList)                              \\\n    retType(U_EXPORT2 *funcName##_) argList;\n\n#include \"AndroidUnicodeFunctions.h\"\n\n#undef ICU_UC_FUNC\n#undef ICU_I18N_FUNC\n} ICUInterface;\n\nstatic ICUInterface g_icuInterface = { nullptr };\nstatic void *g_libicuuc_so = nullptr;\nstatic void *g_libicui18n_so = nullptr;\n\n#ifndef ICU_IMPL\n#define ICU_DEFINE_SYMBOL(symbol) (g_icuInterface.symbol##_)\n\n#include \"AndroidUnicodeFunctions.h\"\n\n#undef ICU_UC_FUNC\n#undef ICU_I18N_FUNC\n#endif\n\nWCDB_EXTERN_C_END\n\n#define ROUND4(n) (((n) + 3) & ~3)\n#define MINIMAL_OUT_BUFFER_LENGTH 512\n\nnamespace WCDB {\n\nMMICUTokenizer::MMICUTokenizer(const char *const *azArg, int nArg, void *pCtx)\n: AbstractFTSTokenizer(azArg, nArg, pCtx)\n, m_iter(nullptr)\n, m_originText(nullptr)\n, m_originTextLength(0)\n, m_inBuffer(nullptr)\n, m_inLength(0)\n, m_inOffset(nullptr)\n, m_outBuffer(nullptr)\n, m_outLength(0)\n, m_tokenCount(0)\n, m_ideoStart(0)\n, m_ideoEnd(0)\n, m_ideoState(0)\n{\n    if (nArg > 0) {\n        strncpy(m_locale, azArg[0], 15);\n        m_locale[15] = 0;\n    } else {\n        m_locale[0] = 0;\n    }\n}\n\nMMICUTokenizer::~MMICUTokenizer()\n{\n    clearMemory();\n}\n\nvoid MMICUTokenizer::loadInput(const char *pText, int nText, int flags)\n{\n    if (nText < 0) {\n        nText = (int) strlen(pText);\n    }\n    m_originText = pText;\n    m_originTextLength = nText;\n\n    clearMemory();\n\n    m_tokenCount = 0;\n    m_ideoStart = -1;\n    m_ideoEnd = -1;\n    m_ideoState = -1;\n}\n\nint MMICUTokenizer::nextToken(\nconst char **ppToken, int *nToken, int *iStart, int *iEnd, int *tflags, int *iPosition)\n{\n    if (!loadICUFunctionsFromSystemLibrary()) {\n        return FTSError::Error();\n    }\n    if (m_originTextLength == 0) {\n        return FTSError::Done();\n    }\n    int ret = initBRKIfNeeded();\n    if (!FTSError::isOK(ret)) {\n        return ret;\n    }\n\n    int32_t start, end;\n    int32_t token_type;\n\n    // process pending ideographic token.\n    if (findSplitIDEOToken(&start, &end)) {\n        return outputToken(start, end, ppToken, nToken, iStart, iEnd, iPosition);\n    }\n\n    start = ubrk_current(m_iter);\n\n    // find first non-NONE token.\n    for (;;) {\n        end = ubrk_next(m_iter);\n        if (end == UBRK_DONE) {\n            // sqlite3_mm_clear_error();\n            return FTSError::Done();\n        }\n\n        token_type = ubrk_getRuleStatus(m_iter);\n        if (token_type >= UBRK_WORD_NONE && token_type < UBRK_WORD_NONE_LIMIT) {\n            // look at the first character, if it's a space or ZWSP, ignore this token.\n            // also ignore '*' because sqlite parser uses it as prefix operator.\n            UChar32 c = m_inBuffer[start];\n            if (c == '*' || c == 0x200b || u_isspace(c)) {\n                start = end;\n                continue;\n            }\n        }\n\n        break;\n    }\n\n    // for non-IDEO tokens, just return.\n    if (token_type < UBRK_WORD_IDEO || token_type >= UBRK_WORD_IDEO_LIMIT) {\n        return outputToken(start, end, ppToken, nToken, iStart, iEnd, iPosition);\n    }\n\n    // for IDEO tokens, find all suffix ideo tokens.\n    for (;;) {\n        int32_t e = ubrk_next(m_iter);\n        if (e == UBRK_DONE) break;\n        token_type = ubrk_getRuleStatus(m_iter);\n        if (token_type < UBRK_WORD_IDEO || token_type >= UBRK_WORD_IDEO_LIMIT)\n            break;\n        end = e;\n    }\n\n    ubrk_isBoundary(m_iter, end);\n\n    m_ideoStart = start;\n    m_ideoEnd = end;\n    m_ideoState = 0;\n    if (findSplitIDEOToken(&start, &end)) {\n        return outputToken(start, end, ppToken, nToken, iStart, iEnd, iPosition);\n    }\n    // sqlite3_mm_set_last_error(\"IDEO token found but can't output token.\");\n    return FTSError::Error();\n}\n\nvoid MMICUTokenizer::clearMemory()\n{\n    if (m_inBuffer != nullptr) {\n        sqlite3_free(m_inBuffer);\n        m_inBuffer = nullptr;\n        m_inOffset = nullptr;\n        m_inLength = 0;\n    }\n    if (m_outBuffer != nullptr) {\n        sqlite3_free(m_outBuffer);\n        m_outBuffer = nullptr;\n        m_outLength = 0;\n    }\n\n    if (m_iter) {\n        ubrk_close(m_iter);\n        m_iter = nullptr;\n    }\n}\n\nint MMICUTokenizer::initBRKIfNeeded()\n{\n    if (m_originTextLength == 0 || m_outBuffer != nullptr) {\n        return FTSError::OK();\n    }\n\n    int dst_len = ROUND4(m_originTextLength + 1);\n    m_inBuffer = (UChar *) sqlite3_malloc((int) (dst_len * sizeof(UChar) // m_inBuffer\n                                                 + (dst_len + 1) * sizeof(int))); // m_inOffset\n    if (!m_inBuffer) {\n        return FTSError::NoMem();\n    }\n    m_inOffset = (int *) (m_inBuffer + dst_len);\n\n    UErrorCode status = U_ZERO_ERROR;\n    UChar32 c;\n    int i_input = 0;\n    int i_output = 0;\n    m_inOffset[i_output] = i_input;\n\n    for (;;) {\n        if (i_input >= m_originTextLength) {\n            break;\n        }\n\n        U8_NEXT(m_originText, i_input, m_originTextLength, c);\n        if (!c) {\n            break;\n        }\n        if (c < 0) {\n            c = ' ';\n        }\n        int is_error = 0;\n        U16_APPEND(m_inBuffer, i_output, dst_len, c, is_error);\n        if (is_error) {\n            // sqlite3_mm_set_last_error(\"Writing UTF-16 character failed. Code point: 0x%x\", c);\n            return FTSError::Error();\n        }\n        m_inOffset[i_output] = i_input;\n    }\n\n    m_iter = ubrk_open(UBRK_WORD, m_locale, m_inBuffer, i_output, &status);\n    if (U_FAILURE(status)) {\n        // sqlite3_mm_set_last_error(\"Open UBreakIterator failed. ICU error code: %d\", status);\n        return FTSError::Error();\n    }\n    m_inLength = i_output;\n\n    ubrk_first(m_iter);\n    return FTSError::OK();\n}\n\nbool MMICUTokenizer::findSplitIDEOToken(int32_t *start, int32_t *end)\n{\n    if (m_ideoState < 0) {\n        return false;\n    }\n\n    if (m_ideoStart == m_ideoEnd) {\n        m_ideoState = -1;\n        return false;\n    }\n\n    int32_t s, e;\n    UChar32 c;\n\n    // check UTF-16 surrogates, output 2 UChars if it's a lead surrogates, otherwise 1.\n    s = m_ideoStart;\n    e = s + 1;\n    c = m_inBuffer[s];\n    if (U16_IS_LEAD(c) && m_ideoEnd - s >= 2) {\n        e++;\n    }\n\n    *start = s;\n    *end = e;\n    m_ideoStart = e;\n    return true;\n}\n\nint MMICUTokenizer::outputToken(\nint32_t start, int32_t end, const char **ppToken, int *nToken, int *iStart, int *iEnd, int *iPosition)\n{\n    UChar buf1[256];\n    UChar buf2[256];\n    UErrorCode status = U_ZERO_ERROR;\n    int32_t result;\n    int32_t length;\n\n    length = end - start;\n    if (length > 256) {\n        length = 256;\n    }\n    result = unorm_normalize(\n    m_inBuffer + start, length, UNORM_NFKD, 0, buf1, sizeof(buf1) / sizeof(UChar), &status);\n    // currently, only try fixed length buffer, failed if overflowed.\n    if (U_FAILURE(status) || result > sizeof(buf1) / sizeof(UChar)) {\n        // char *seq = generate_token_printable_code(m_inBuffer + start, length);\n        // sqlite3_mm_set_last_error(\"Normalize token failed. ICU status: %d, input: %s\", status, seq);\n        // free(seq);\n        return FTSError::Error();\n    }\n\n    length = result;\n    result = u_strFoldCase(\n    buf2, sizeof(buf2) / sizeof(UChar), buf1, length, U_FOLD_CASE_DEFAULT, &status);\n    // currently, only try fixed length buffer, failed if overflowed.\n    if (U_FAILURE(status) || result > sizeof(buf2) / sizeof(UChar)) {\n        // char *seq = generate_token_printable_code(buf1, length);\n        // sqlite3_mm_set_last_error(\"FoldCase token failed. ICU status: %d, input: %s\", status, seq);\n        // free(seq);\n        return FTSError::Error();\n    }\n\n    if (m_outBuffer == nullptr) {\n        m_outBuffer = (char *) sqlite3_malloc(MINIMAL_OUT_BUFFER_LENGTH * sizeof(char));\n        if (!m_outBuffer) return FTSError::NoMem();\n        m_outLength = MINIMAL_OUT_BUFFER_LENGTH;\n    }\n\n    length = result;\n    u_strToUTF8(m_outBuffer, m_outLength, &result, buf2, length, &status);\n    if (result > m_outLength) {\n        char *b = (char *) sqlite3_realloc(m_outBuffer, (int) (result * sizeof(char)));\n        if (!b) return FTSError::NoMem();\n\n        m_outBuffer = b;\n        m_outLength = result;\n\n        status = U_ZERO_ERROR;\n        u_strToUTF8(m_outBuffer, m_outLength, &result, buf2, length, &status);\n    }\n    if (U_FAILURE(status) || result > m_outLength) {\n        // char *seq = generate_token_printable_code(buf2, length);\n        // sqlite3_mm_set_last_error(\"Transform token to UTF-8 failed. ICU status: %d, input: %s\", status, seq);\n        // free(seq);\n        return FTSError::Error();\n    }\n\n    *ppToken = m_outBuffer;\n    *nToken = result;\n    *iStart = m_inOffset[start];\n    *iEnd = m_inOffset[end];\n    m_tokenCount++;\n    if (iPosition != nullptr) {\n        *iPosition = m_tokenCount;\n    }\n    return FTSError::OK();\n}\n\n#pragma mark - Load ICU\nbool MMICUTokenizer::loadICUFunctionsFromSystemLibrary()\n{\n    static bool g_icuLoaded = false;\n    static std::once_flag g_flag;\n    std::call_once(g_flag, [&]() {\n        char suffix[16];\n        g_libicuuc_so = dlopen(\"libicuuc.so\", RTLD_LAZY);\n        g_libicui18n_so = dlopen(\"libicui18n.so\", RTLD_LAZY);\n        if (g_libicuuc_so != nullptr && g_libicui18n_so != nullptr\n            && findICUSuffix(g_libicuuc_so, suffix, sizeof(suffix))) {\n            loadFunctions(suffix);\n            g_icuLoaded = true;\n        } else {\n            if (g_libicuuc_so) {\n                dlclose(g_libicuuc_so);\n            }\n            if (g_libicui18n_so) {\n                dlclose(g_libicui18n_so);\n            }\n        }\n    });\n    return g_icuLoaded;\n}\n\nvoid *MMICUTokenizer::loadFunction(void *libHandle, const char *funcName, const char *suffix)\n{\n    char buf[128];\n    size_t len = strlcpy(buf, funcName, sizeof(buf));\n    strlcpy(buf + len, suffix, sizeof(buf) - len);\n\n    return dlsym(libHandle, buf);\n}\n\nvoid MMICUTokenizer::loadFunctions(const char *suffix)\n{\n#undef ICU_DEFINE_SYMBOL\n#define ICU_UC_FUNC(retType, funcName, argList)                                \\\n    (g_icuInterface.funcName##_)                                               \\\n    = (retType(*) argList) loadFunction(g_libicuuc_so, #funcName, suffix);\n#define ICU_I18N_FUNC(retType, funcName, argList)                              \\\n    (g_icuInterface.funcName##_)                                               \\\n    = (retType(*) argList) loadFunction(g_libicui18n_so, #funcName, suffix);\n\n#include \"AndroidUnicodeFunctions.h\"\n\n#undef ICU_UC_FUNC\n#undef ICU_I18N_FUNC\n}\n\nconst char *MMICUTokenizer::findICUSuffix(void *libHandle, char *buf, size_t bufLen)\n{\n    DIR *icuDir = opendir(\"/system/usr/icu\");\n    if (!icuDir) return nullptr;\n\n    struct dirent *dp;\n    while ((dp = readdir(icuDir)) != nullptr) {\n        if (dp->d_type == DT_REG) {\n            // Find /system/usr/icu/icudt??l.dat\n            const char *name = dp->d_name;\n            if (strlen(name) == 12 && !strncmp(\"icudt\", name, 5)\n                && name[5] >= '0' && name[5] <= '9' && name[6] >= '0'\n                && name[6] <= '9' && !strncmp(\"l.dat\", &name[7], 6)) {\n                snprintf(buf, bufLen, \"_%c%c\", name[5], name[6]);\n\n                // Try loading with suffix.\n                if (loadFunction(libHandle, \"u_getVersion\", buf)) {\n                    closedir(icuDir);\n                    return buf;\n                }\n            }\n        }\n    }\n    closedir(icuDir);\n\n    // Failed, try plain names without suffix.\n    if (loadFunction(libHandle, \"u_getVersion\", \"\")) {\n        buf[0] = 0;\n        return buf;\n    }\n\n    return nullptr;\n}\n\n} // namespace WCDB\n\n#endif"
  },
  {
    "path": "src/common/core/fts/tokenizer/MMICUTokenizer.hpp",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"TokenizerModuleTemplate.hpp\"\n\n/**\n * The following definition is copied from the Unicode library in Android system\n */\ntypedef struct UBreakIterator UBreakIterator;\n#if defined(UCHAR_TYPE)\ntypedef UCHAR_TYPE UChar;\n/* Not #elif U_HAVE_CHAR16_T -- because that is type-incompatible with pre-C++11 callers\n    typedef char16_t UChar;  */\n#elif U_SIZEOF_WCHAR_T == 2\ntypedef wchar_t UChar;\n#elif defined(__CHAR16_TYPE__)\ntypedef __CHAR16_TYPE__ UChar;\n#else\ntypedef uint16_t UChar;\n#endif\n\nnamespace WCDB {\n\nclass WCDB_API MMICUTokenizer final : public AbstractFTSTokenizer {\npublic:\n    MMICUTokenizer(const char *const *azArg, int nArg, void *pCtx);\n    ~MMICUTokenizer();\n    void loadInput(const char *pText, int nText, int flags) override;\n    int nextToken(const char **ppToken, int *nToken, int *iStart, int *iEnd, int *tflags, int *iPosition) override;\n\nprivate:\n    void clearMemory();\n    int initBRKIfNeeded();\n    bool findSplitIDEOToken(int32_t *start, int32_t *end);\n    int outputToken(int32_t start,\n                    int32_t end,\n                    const char **ppToken,\n                    int *nToken,\n                    int *iStart,\n                    int *iEnd,\n                    int *iPosition);\n\n    char m_locale[16]{};\n\n    UBreakIterator *m_iter; // UBreakIterator for the text.\n\n    const char *m_originText; // origin input text, in UTF-8.\n    int m_originTextLength;   // length of m_originText\n\n    UChar *m_inBuffer; // whole input text buffer, in UTF-16.\n    int m_inLength;    // input text length.\n\n    int *m_inOffset; // offset of each utf8 token\n\n    char *m_outBuffer; // output token buffer, int UTF-8,\n    int m_outLength;   // output token buffer length.\n\n    int m_tokenCount;\n    int32_t m_ideoStart; // ideographic unary/binary tokenizing cursor.\n    int32_t m_ideoEnd;   // ideographic unary/binary tokenizing end point.\n    int m_ideoState;     // 0 for unary output, -1 for invalid status.\n\n#pragma mark - Load ICU\nprivate:\n    static bool loadICUFunctionsFromSystemLibrary();\n    static void *loadFunction(void *libHandle, const char *funcName, const char *suffix);\n    static void loadFunctions(const char *suffix);\n    static const char *findICUSuffix(void *libHandle, char *buf, size_t bufLen);\n};\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/common/core/fts/tokenizer/OneOrBinaryTokenizer.cpp",
    "content": "//\n// Created by qiuwenchen on 2021/11/8.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"OneOrBinaryTokenizer.hpp\"\n#include \"Assertion.hpp\"\n#include \"FTSConst.h\"\n#include \"FTSError.hpp\"\n#include <algorithm>\n\nextern \"C\" {\nextern int porterStem(char *p, int i, int j);\n}\n\nnamespace WCDB {\n\n#pragma mark - Tokenizer\nOneOrBinaryTokenizer::OneOrBinaryTokenizer(const char *const *azArg, int nArg, void *pCtx)\n: AbstractFTSTokenizer(azArg, nArg, pCtx)\n, m_input(nullptr)\n, m_inputLength(0)\n, m_position(0)\n, m_startOffset(0)\n, m_endOffset(0)\n, m_cursor(0)\n, m_cursorTokenLength(0)\n, m_cursorTokenType(UnicodeType::None)\n, m_preTokenType(UnicodeType::None)\n, m_subTokensCursor(0)\n, m_subTokensDoubleChar(true)\n, m_tokenLength(0)\n, m_needBinary(false)\n, m_needSymbol(false)\n, m_needSimplifiedChinese(false)\n, m_skipStemming(false)\n{\n    for (int i = 0; i < nArg; i++) {\n        if (strcmp(azArg[i], BuiltinTokenizer::Parameter::NeedSymbol) == 0) {\n            m_needSymbol = true;\n        } else if (strcmp(azArg[i], BuiltinTokenizer::Parameter::SimplifyChinese) == 0) {\n            m_needSimplifiedChinese = true;\n        } else if (strcmp(azArg[i], BuiltinTokenizer::Parameter::SkipStemming) == 0) {\n            m_skipStemming = true;\n        }\n    }\n}\n\nOneOrBinaryTokenizer::~OneOrBinaryTokenizer() = default;\n\nvoid OneOrBinaryTokenizer::loadInput(const char *pText, int nText, int flags)\n{\n    WCDB_UNUSED(flags);\n    m_input = pText;\n    m_inputLength = nText;\n    m_position = 0;\n    m_startOffset = 0;\n    m_endOffset = 0;\n    m_cursor = 0;\n    m_cursorTokenLength = 0;\n    m_cursorTokenType = UnicodeType::None;\n    m_preTokenType = UnicodeType::None;\n    m_subTokensLengthArray.clear();\n    m_subTokensCursor = 0;\n    m_subTokensDoubleChar = true;\n    m_token.clear();\n    m_tokenLength = 0;\n}\n\nint OneOrBinaryTokenizer::nextToken(\nconst char **ppToken, int *nToken, int *iStart, int *iEnd, int *tflags, int *iPosition)\n{\n    int ret = stepNextToken();\n    if (!FTSError::isOK(ret)) {\n        return ret;\n    }\n    genToken();\n    if (tflags != nullptr) {\n        *tflags = 0;\n    }\n    *ppToken = m_token.data();\n    *nToken = m_tokenLength;\n    *iStart = m_startOffset;\n    *iEnd = m_endOffset;\n    if (iPosition != nullptr) {\n        *iPosition = m_position;\n    }\n    return FTSError::OK();\n}\n\n//Inspired by zorrozhang\nint OneOrBinaryTokenizer::stepNextToken()\n{\n    if (m_position == 0) {\n        cursorStep();\n    }\n    if (m_subTokensLengthArray.empty()) {\n        if (!m_needSymbol) { //Skip symbol\n            while (m_cursorTokenType == UnicodeType::BasicMultilingualPlaneSymbol) {\n                cursorStep();\n            }\n        }\n        m_preTokenType = m_cursorTokenType;\n        switch (m_preTokenType) {\n        case UnicodeType::BasicMultilingualPlaneLetter:\n        case UnicodeType::BasicMultilingualPlaneDigit:\n            m_startOffset = m_cursor;\n            do {\n                cursorStep();\n            } while (m_cursorTokenType == m_preTokenType);\n            m_endOffset = m_cursor;\n            m_tokenLength = m_endOffset - m_startOffset;\n            break;\n        case UnicodeType::BasicMultilingualPlaneSymbol:\n        case UnicodeType::BasicMultilingualPlaneOther:\n        case UnicodeType::AuxiliaryPlaneOther:\n            m_subTokensCursor = m_cursor;\n            m_subTokensDoubleChar = m_needBinary;\n            do {\n                m_subTokensLengthArray.push_back(m_cursorTokenLength);\n                cursorStep();\n            } while (m_cursorTokenType == m_preTokenType);\n            subTokensStep();\n            break;\n        case UnicodeType::None:\n            return FTSError::Done();\n        }\n    } else {\n        subTokensStep();\n    }\n    return FTSError::OK();\n}\n\nvoid OneOrBinaryTokenizer::cursorStep()\n{\n    if (m_cursor + m_cursorTokenLength < m_inputLength) {\n        m_cursor += m_cursorTokenLength;\n        UnsafeStringView currentInput\n        = UnsafeStringView(m_input + m_cursor, m_inputLength - m_cursor);\n        BaseTokenizerUtil::stepOneUnicode(currentInput, m_cursorTokenType, m_cursorTokenLength);\n        return;\n    }\n    m_cursor = m_inputLength;\n    m_cursorTokenType = UnicodeType::None;\n    m_cursorTokenLength = 0;\n}\n\nvoid OneOrBinaryTokenizer::lemmatization(const char *input, int inputLength)\n{\n    // tolower only. You can implement your own lemmatization.\n    m_token.assign(input, input + inputLength);\n    std::transform(m_token.begin(), m_token.end(), m_token.begin(), ::tolower);\n    if (!m_skipStemming) {\n        m_tokenLength = porterStem(m_token.data(), 0, m_tokenLength - 1) + 1;\n    }\n}\n\nvoid OneOrBinaryTokenizer::subTokensStep()\n{\n    m_startOffset = m_subTokensCursor;\n    m_tokenLength = m_subTokensLengthArray[0];\n    if (m_subTokensDoubleChar) {\n        if (m_subTokensLengthArray.size() > 1) {\n            m_tokenLength += m_subTokensLengthArray[1];\n            if (m_needBinary) {\n                m_subTokensDoubleChar = false;\n            }\n        } else {\n            m_subTokensLengthArray.clear();\n        }\n    } else {\n        m_subTokensCursor += m_subTokensLengthArray[0];\n        m_subTokensLengthArray.erase(m_subTokensLengthArray.begin());\n        if (m_needBinary) {\n            m_subTokensDoubleChar = true;\n        }\n    }\n    m_endOffset = m_startOffset + m_tokenLength;\n}\n\nvoid OneOrBinaryTokenizer::genToken()\n{\n    if (m_preTokenType == UnicodeType::BasicMultilingualPlaneLetter) {\n        lemmatization(m_input + m_startOffset, m_tokenLength);\n    } else if (m_preTokenType != UnicodeType::BasicMultilingualPlaneOther\n               || !m_needSimplifiedChinese) {\n        UnsafeStringView token = UnsafeStringView(m_input + m_startOffset, m_tokenLength);\n        StringView nomalizeToken = BaseTokenizerUtil::normalizeToken(token);\n        m_tokenLength = (int) nomalizeToken.length();\n        m_token.assign(nomalizeToken.data(), nomalizeToken.data() + m_tokenLength);\n    } else if (!m_needBinary || m_subTokensDoubleChar) {\n        UnsafeStringView token = UnsafeStringView(m_input + m_startOffset, m_tokenLength);\n        StringView nomalizeToken = BaseTokenizerUtil::normalizeToken(token);\n        StringView simplifiedToken = BaseTokenizerUtil::getSimplifiedChinese(nomalizeToken);\n        m_tokenLength = (int) simplifiedToken.length();\n        m_token.assign(simplifiedToken.data(), simplifiedToken.data() + m_tokenLength);\n    } else {\n        UnsafeStringView firstChar\n        = UnsafeStringView(m_input + m_startOffset, m_subTokensLengthArray[0]);\n        UnsafeStringView secondChar = UnsafeStringView(\n        m_input + m_startOffset + m_subTokensLengthArray[0], m_subTokensLengthArray[1]);\n        firstChar = BaseTokenizerUtil::getSimplifiedChinese(firstChar);\n        secondChar = BaseTokenizerUtil::getSimplifiedChinese(secondChar);\n        StringView normalizeFirstChar = BaseTokenizerUtil::normalizeToken(firstChar);\n        StringView normalizeSecondChar = BaseTokenizerUtil::normalizeToken(secondChar);\n        m_tokenLength\n        = (int) normalizeFirstChar.length() + (int) normalizeSecondChar.length();\n        m_token.assign(normalizeFirstChar.data(),\n                       normalizeFirstChar.data() + normalizeFirstChar.length());\n        m_token.insert(m_token.end(),\n                       normalizeSecondChar.data(),\n                       normalizeSecondChar.data() + normalizeSecondChar.length());\n    }\n    m_position++;\n}\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/common/core/fts/tokenizer/OneOrBinaryTokenizer.hpp",
    "content": "//\n// Created by qiuwenchen on 2021/11/8.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"BaseTokenizerUtil.hpp\"\n#include \"TokenizerModuleTemplate.hpp\"\n\nnamespace WCDB {\n\nclass WCDB_API OneOrBinaryTokenizer final : public AbstractFTSTokenizer {\npublic:\n    OneOrBinaryTokenizer(const char *const *azArg, int nArg, void *pCtx);\n    ~OneOrBinaryTokenizer();\n    void loadInput(const char *pText, int nText, int flags) override;\n    int nextToken(const char **ppToken, int *nToken, int *iStart, int *iEnd, int *tflags, int *iPosition) override;\n\n    int stepNextToken();\n\nprivate:\n    const char *m_input;\n    int m_inputLength;\n\n    int m_position;\n    int m_startOffset;\n    int m_endOffset;\n\n    int m_cursor;\n    int m_cursorTokenLength;\n\n    using UnicodeType = BaseTokenizerUtil::UnicodeType;\n    UnicodeType m_cursorTokenType;\n    UnicodeType m_preTokenType;\n\n    std::vector<int> m_subTokensLengthArray;\n    int m_subTokensCursor;\n    bool m_subTokensDoubleChar;\n\n    std::vector<char> m_token;\n    int m_tokenLength;\n\n    bool m_needBinary;\n    // Can be configed by tokenizer parameters\n    bool m_needSymbol;\n    bool m_needSimplifiedChinese;\n    bool m_skipStemming;\n\n    void cursorStep();\n    void subTokensStep();\n\n    void lemmatization(const char *input, int inputLength);\n    void genToken();\n};\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/common/core/fts/tokenizer/PinyinTokenizer.cpp",
    "content": "//\n// Created by qwchen on 2021/11/8.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"PinyinTokenizer.hpp\"\n#include \"Assertion.hpp\"\n#include \"FTSConst.h\"\n#include \"FTSError.hpp\"\n#include \"SQLite.h\"\n#include <algorithm>\n\nnamespace WCDB {\n\nPinyinTokenizer::PinyinTokenizer(const char *const *azArg, int nArg, void *pCtx)\n: AbstractFTSTokenizer(azArg, nArg, pCtx)\n, m_input(nullptr)\n, m_inputLength(0)\n, m_flags(0)\n, m_startOffset(0)\n, m_endOffset(0)\n, m_cursor(0)\n, m_cursorTokenLength(0)\n, m_cursorTokenType(UnicodeType::None)\n, m_preTokenType(UnicodeType::None)\n, m_normalTokenLength(0)\n, m_pinyinTokenIndex(0)\n, m_needSymbol(false)\n{\n    for (int i = 0; i < nArg; i++) {\n        if (strcmp(azArg[i], BuiltinTokenizer::Parameter::NeedSymbol) == 0) {\n            m_needSymbol = true;\n        }\n    }\n}\n\nPinyinTokenizer::~PinyinTokenizer() = default;\n\nvoid PinyinTokenizer::loadInput(const char *pText, int nText, int flags)\n{\n    m_input = pText;\n    m_inputLength = nText;\n    m_flags = flags;\n    m_startOffset = 0;\n    m_endOffset = 0;\n    m_cursor = 0;\n    m_cursorTokenLength = 0;\n    m_cursorTokenType = UnicodeType::None;\n    m_preTokenType = UnicodeType::None;\n    m_normalToken.clear();\n    m_normalTokenLength = 0;\n    m_pinyinTokenArr.clear();\n    m_pinyinTokenIndex = 0;\n}\n\nint PinyinTokenizer::nextToken(\nconst char **ppToken, int *nToken, int *iStart, int *iEnd, int *tflags, int *iPosition)\n{\n    WCDB_UNUSED(iPosition);\n    if (m_flags & FTS5_TOKENIZE_QUERY || m_pinyinTokenArr.size() == m_pinyinTokenIndex) {\n        while (true) {\n            int ret = stepNextToken();\n            if (!FTSError::isOK(ret)) {\n                return ret;\n            }\n            if (m_flags & FTS5_TOKENIZE_QUERY) {\n                genNormalToken();\n                break;\n            } else {\n                genPinyinToken();\n                if (m_pinyinTokenArr.size() > 0) {\n                    break;\n                }\n            }\n        }\n    }\n    *tflags = 0;\n    if (m_flags & FTS5_TOKENIZE_QUERY) {\n        *ppToken = m_normalToken.data();\n        *nToken = m_normalTokenLength;\n        *iStart = m_startOffset;\n        *iEnd = m_endOffset;\n        return FTSError::OK();\n    } else {\n        if (m_pinyinTokenIndex > 0) {\n            *tflags = FTS5_TOKEN_COLOCATED;\n        }\n        const StringView &pinyinToken = m_pinyinTokenArr[m_pinyinTokenIndex];\n        *ppToken = pinyinToken.data();\n        *nToken = (int) pinyinToken.length();\n        *iStart = m_startOffset;\n        *iEnd = m_endOffset;\n        m_pinyinTokenIndex++;\n        return FTSError::OK();\n    }\n}\n\nint PinyinTokenizer::stepNextToken()\n{\n    if (m_cursorTokenLength == 0) {\n        cursorStep();\n    }\n\n    UnicodeType searchType = m_flags & FTS5_TOKENIZE_QUERY ?\n                             UnicodeType::BasicMultilingualPlaneLetter :\n                             UnicodeType::BasicMultilingualPlaneOther;\n    while (m_cursorTokenType != searchType && m_cursorTokenType != UnicodeType::None) {\n        if (m_needSymbol && !(m_flags & FTS5_TOKENIZE_QUERY)\n            && m_cursorTokenType == UnicodeType::BasicMultilingualPlaneSymbol) {\n            break;\n        }\n        cursorStep();\n    }\n\n    m_preTokenType = m_cursorTokenType;\n    switch (m_preTokenType) {\n    case UnicodeType::BasicMultilingualPlaneLetter:\n    case UnicodeType::BasicMultilingualPlaneSymbol:\n    case UnicodeType::BasicMultilingualPlaneOther:\n        m_startOffset = m_cursor;\n        if (m_preTokenType == UnicodeType::BasicMultilingualPlaneLetter) {\n            do {\n                cursorStep();\n            } while (m_cursorTokenType == m_preTokenType);\n        } else {\n            cursorStep();\n        }\n        m_endOffset = m_cursor;\n        m_normalTokenLength = m_endOffset - m_startOffset;\n        break;\n    default:\n        return FTSError::Done();\n    }\n    return FTSError::OK();\n}\n\nvoid PinyinTokenizer::cursorStep()\n{\n    if (m_cursor + m_cursorTokenLength < m_inputLength) {\n        m_cursor += m_cursorTokenLength;\n        UnsafeStringView currentInput\n        = UnsafeStringView(m_input + m_cursor, m_inputLength - m_cursor);\n        BaseTokenizerUtil::stepOneUnicode(currentInput, m_cursorTokenType, m_cursorTokenLength);\n        return;\n    }\n    m_cursor = m_inputLength;\n    m_cursorTokenType = UnicodeType::None;\n    m_cursorTokenLength = 0;\n}\n\nvoid PinyinTokenizer::genNormalToken()\n{\n    m_normalToken.assign(m_input + m_startOffset, m_input + m_endOffset);\n    if (m_preTokenType == UnicodeType::BasicMultilingualPlaneLetter) {\n        std::transform(\n        m_normalToken.begin(), m_normalToken.end(), m_normalToken.begin(), ::tolower);\n    }\n}\n\nvoid PinyinTokenizer::genPinyinToken()\n{\n    m_pinyinTokenArr.clear();\n    m_pinyinTokenIndex = 0;\n    StringViewSet pinyinSet;\n    UnsafeStringView token = UnsafeStringView(m_input + m_startOffset, m_normalTokenLength);\n    const std::vector<StringView> pinyinPtr = BaseTokenizerUtil::getPinYin(token);\n    if (pinyinPtr.size() == 0) {\n        if (m_preTokenType == UnicodeType::BasicMultilingualPlaneSymbol\n            && token.length() > 0) {\n            m_pinyinTokenArr.emplace_back(token);\n        }\n        return;\n    }\n    for (const StringView &pinyin : pinyinPtr) {\n        if (pinyin.length() == 0) {\n            continue;\n        }\n        if (pinyinSet.find(pinyin) != pinyinSet.end()) {\n            continue;\n        }\n        //full pinyin\n        m_pinyinTokenArr.emplace_back(pinyin);\n        pinyinSet.emplace(pinyin);\n        if (pinyin.length() <= 1) {\n            continue;\n        }\n        UnsafeStringView shortPinyin = UnsafeStringView(pinyin.data(), 1);\n        if (pinyinSet.find(shortPinyin) != pinyinSet.end()) {\n            continue;\n        }\n        //short pinyin\n        pinyinSet.emplace(shortPinyin);\n        m_pinyinTokenArr.emplace_back(shortPinyin);\n    }\n}\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/common/core/fts/tokenizer/PinyinTokenizer.hpp",
    "content": "//\n// Created by qwchen on 2021/11/8.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"BaseTokenizerUtil.hpp\"\n#include \"TokenizerModuleTemplate.hpp\"\n\nnamespace WCDB {\n\nclass WCDB_API PinyinTokenizer final : public AbstractFTSTokenizer {\npublic:\n    PinyinTokenizer(const char *const *azArg, int nArg, void *pCtx);\n    void loadInput(const char *pText, int nText, int flags) override;\n    int nextToken(const char **ppToken, int *nToken, int *iStart, int *iEnd, int *tflags, int *iPosition) override;\n\n    ~PinyinTokenizer() override;\n    int stepNextToken();\n\nprivate:\n    using UnicodeType = BaseTokenizerUtil::UnicodeType;\n\n    const char *m_input;\n    int m_inputLength;\n    int m_flags;\n\n    int m_startOffset;\n    int m_endOffset;\n\n    int m_cursor;\n    int m_cursorTokenLength;\n\n    UnicodeType m_cursorTokenType;\n    UnicodeType m_preTokenType;\n\n    std::vector<char> m_normalToken;\n    int m_normalTokenLength;\n    std::vector<StringView> m_pinyinTokenArr;\n    int m_pinyinTokenIndex;\n\n    // Can be configed by tokenizer parameters\n    bool m_needSymbol;\n\n    void cursorStep();\n    void subTokensStep();\n\n    void genNormalToken();\n    void genPinyinToken();\n};\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/common/core/fts/tokenizer/PorterStemming.c",
    "content": "\n/* This is the Porter stemming algorithm, coded up in ANSI C by the\n author. It may be be regarded as canonical, in that it follows the\n algorithm presented in\n \n Porter, 1980, An algorithm for suffix stripping, Program, Vol. 14,\n no. 3, pp 130-137,\n \n only differing from it at the points marked --DEPARTURE-- below.\n \n See also http://www.tartarus.org/~martin/PorterStemmer\n \n The algorithm as described in the paper could be exactly replicated\n by adjusting the points of DEPARTURE, but this is barely necessary,\n because (a) the points of DEPARTURE are definitely improvements, and\n (b) no encoding of the Porter stemmer I have seen is anything like\n as exact as this version, even with the points of DEPARTURE!\n \n You can compile it on Unix with 'gcc -O3 -o stem stem.c' after which\n 'stem' takes a list of inputs and sends the stemmed equivalent to\n stdout.\n \n The algorithm as encoded here is particularly fast.\n \n Release 1: was many years ago\n Release 2: 11 Apr 2013\n fixes a bug noted by Matt Patenaude <matt@mattpatenaude.com>,\n \n case 'o': if (ends(\"\\03\" \"ion\") && (b[j] == 's' || b[j] == 't')) break;\n ==>\n case 'o': if (ends(\"\\03\" \"ion\") && j >= k0 && (b[j] == 's' || b[j] == 't')) break;\n \n to avoid accessing b[k0-1] when the word in b is \"ion\".\n Release 3: 25 Mar 2014\n fixes a similar bug noted by Klemens Baum <klemensbaum@gmail.com>,\n that if step1ab leaves a one letter result (ied -> i, aing -> a etc),\n step2 and step4 access the byte before the first letter. So we skip\n steps after step1ab unless k > k0.\n */\n\n#include <stdint.h>\n#include <string.h> /* for memmove */\n\n#define TRUE 1\n#define FALSE 0\n\n/* The main part of the stemming algorithm starts here. b is a buffer\n holding a word to be stemmed. The letters are in b[k0], b[k0+1] ...\n ending at b[k]. In fact k0 = 0 in this demo program. k is readjusted\n downwards as the stemming progresses. Zero termination is not in fact\n used in the algorithm.\n \n Note that only lower case sequences are stemmed. Forcing to lower case\n should be done before stem(...) is called.\n */\n\nstatic char* s_b;          /* buffer for word to be stemmed */\nstatic int s_k, s_k0, s_j; /* j is a general offset into the string */\n\n/* cons(i) is TRUE <=> b[i] is a consonant. */\n\nstatic int cons(int i)\n{\n    switch (s_b[i]) {\n    case 'a':\n    case 'e':\n    case 'i':\n    case 'o':\n    case 'u':\n        return FALSE;\n    case 'y':\n        return (i == s_k0) ? TRUE : !cons(i - 1);\n    default:\n        return TRUE;\n    }\n}\n\n/* m() measures the number of consonant sequences between k0 and j. if c is\n a consonant sequence and v a vowel sequence, and <..> indicates arbitrary\n presence,\n \n <c><v>       gives 0\n <c>vc<v>     gives 1\n <c>vcvc<v>   gives 2\n <c>vcvcvc<v> gives 3\n ....\n */\n\nstatic int m()\n{\n    int n = 0;\n    int i = s_k0;\n    while (TRUE) {\n        if (i > s_j) return n;\n        if (!cons(i)) break;\n        i++;\n    }\n    i++;\n    while (TRUE) {\n        while (TRUE) {\n            if (i > s_j) return n;\n            if (cons(i)) break;\n            i++;\n        }\n        i++;\n        n++;\n        while (TRUE) {\n            if (i > s_j) return n;\n            if (!cons(i)) break;\n            i++;\n        }\n        i++;\n    }\n}\n\n/* vowelinstem() is TRUE <=> k0,...j contains a vowel */\n\nstatic int vowelinstem()\n{\n    int i;\n    for (i = s_k0; i <= s_j; i++)\n        if (!cons(i)) return TRUE;\n    return FALSE;\n}\n\n/* doublec(j) is TRUE <=> j,(j-1) contain a double consonant. */\n\nstatic int doublec(int j)\n{\n    if (j < s_k0 + 1) return FALSE;\n    if (s_b[j] != s_b[j - 1]) return FALSE;\n    return cons(j);\n}\n\n/* cvc(i) is TRUE <=> i-2,i-1,i has the form consonant - vowel - consonant\n and also if the second c is not w,x or y. this is used when trying to\n restore an e at the end of a short word. e.g.\n \n cav(e), lov(e), hop(e), crim(e), but\n snow, box, tray.\n \n */\n\nstatic int cvc(int i)\n{\n    if (i < s_k0 + 2 || !cons(i) || cons(i - 1) || !cons(i - 2)) return FALSE;\n    {\n        int ch = s_b[i];\n        if (ch == 'w' || ch == 'x' || ch == 'y') return FALSE;\n    }\n    return TRUE;\n}\n\n/* ends(s) is TRUE <=> k0,...k ends with the string s. */\n\nstatic int ends(char* s)\n{\n    int length = s[0];\n    if (s[length] != s_b[s_k]) return FALSE; /* tiny speed-up */\n    if (length > s_k - s_k0 + 1) return FALSE;\n    if (memcmp(s_b + s_k - length + 1, s + 1, (size_t) length) != 0)\n        return FALSE;\n    s_j = s_k - length;\n    return TRUE;\n}\n\n/* setto(s) sets (j+1),...k to the characters in the string s, readjusting\n k. */\n\nstatic void setto(char* s)\n{\n    int length = s[0];\n    memmove(s_b + s_j + 1, s + 1, length);\n    s_k = s_j + length;\n}\n\n/* r(s) is used further down. */\n\nstatic void r(char* s)\n{\n    if (m() > 0) setto(s);\n}\n\n/* step1ab() gets rid of plurals and -ed or -ing. e.g.\n \n caresses  ->  caress\n ponies    ->  poni\n ties      ->  ti\n caress    ->  caress\n cats      ->  cat\n \n feed      ->  feed\n agreed    ->  agree\n disabled  ->  disable\n \n matting   ->  mat\n mating    ->  mate\n meeting   ->  meet\n milling   ->  mill\n messing   ->  mess\n \n meetings  ->  meet\n \n */\n\nstatic void step1ab()\n{\n    if (s_b[s_k] == 's') {\n        if (ends(\"\\04\"\n                 \"sses\"))\n            s_k -= 2;\n        else if (ends(\"\\03\"\n                      \"ies\"))\n            setto(\n            \"\\01\"\n            \"i\");\n        else if (s_b[s_k - 1] != 's')\n            s_k--;\n    }\n    if (ends(\"\\03\"\n             \"eed\")) {\n        if (m() > 0) s_k--;\n    } else if ((ends(\"\\02\"\n                     \"ed\")\n                || ends(\"\\03\"\n                        \"ing\"))\n               && vowelinstem()) {\n        s_k = s_j;\n        if (ends(\"\\02\"\n                 \"at\"))\n            setto(\n            \"\\03\"\n            \"ate\");\n        else if (ends(\"\\02\"\n                      \"bl\"))\n            setto(\n            \"\\03\"\n            \"ble\");\n        else if (ends(\"\\02\"\n                      \"iz\"))\n            setto(\n            \"\\03\"\n            \"ize\");\n        else if (doublec(s_k)) {\n            s_k--;\n            {\n                int ch = s_b[s_k];\n                if (ch == 'l' || ch == 's' || ch == 'z') s_k++;\n            }\n        } else if (m() == 1 && cvc(s_k))\n            setto(\n            \"\\01\"\n            \"e\");\n    }\n}\n\n/* step1c() turns terminal y to i when there is another vowel in the stem. */\n\nstatic void step1c()\n{\n    if (ends(\"\\01\"\n             \"y\")\n        && vowelinstem())\n        s_b[s_k] = 'i';\n}\n\n/* step2() maps double suffices to single ones. so -ization ( = -ize plus\n -ation) maps to -ize etc. note that the string before the suffix must give\n m() > 0. */\n\nstatic void step2()\n{\n    switch (s_b[s_k - 1]) {\n    case 'a':\n        if (ends(\"\\07\"\n                 \"ational\")) {\n            r(\n            \"\\03\"\n            \"ate\");\n            break;\n        }\n        if (ends(\"\\06\"\n                 \"tional\")) {\n            r(\n            \"\\04\"\n            \"tion\");\n            break;\n        }\n        break;\n    case 'c':\n        if (ends(\"\\04\"\n                 \"enci\")) {\n            r(\n            \"\\04\"\n            \"ence\");\n            break;\n        }\n        if (ends(\"\\04\"\n                 \"anci\")) {\n            r(\n            \"\\04\"\n            \"ance\");\n            break;\n        }\n        break;\n    case 'e':\n        if (ends(\"\\04\"\n                 \"izer\")) {\n            r(\n            \"\\03\"\n            \"ize\");\n            break;\n        }\n        break;\n    case 'l':\n        if (ends(\"\\03\"\n                 \"bli\")) {\n            r(\n            \"\\03\"\n            \"ble\");\n            break;\n        } /*-DEPARTURE-*/\n\n        /* To match the published algorithm, replace this line with\n             case 'l': if (ends(\"\\04\" \"abli\")) { r(\"\\04\" \"able\"); break; } */\n\n        if (ends(\"\\04\"\n                 \"alli\")) {\n            r(\n            \"\\02\"\n            \"al\");\n            break;\n        }\n        if (ends(\"\\05\"\n                 \"entli\")) {\n            r(\n            \"\\03\"\n            \"ent\");\n            break;\n        }\n        if (ends(\"\\03\"\n                 \"eli\")) {\n            r(\n            \"\\01\"\n            \"e\");\n            break;\n        }\n        if (ends(\"\\05\"\n                 \"ousli\")) {\n            r(\n            \"\\03\"\n            \"ous\");\n            break;\n        }\n        break;\n    case 'o':\n        if (ends(\"\\07\"\n                 \"ization\")) {\n            r(\n            \"\\03\"\n            \"ize\");\n            break;\n        }\n        if (ends(\"\\05\"\n                 \"ation\")) {\n            r(\n            \"\\03\"\n            \"ate\");\n            break;\n        }\n        if (ends(\"\\04\"\n                 \"ator\")) {\n            r(\n            \"\\03\"\n            \"ate\");\n            break;\n        }\n        break;\n    case 's':\n        if (ends(\"\\05\"\n                 \"alism\")) {\n            r(\n            \"\\02\"\n            \"al\");\n            break;\n        }\n        if (ends(\"\\07\"\n                 \"iveness\")) {\n            r(\n            \"\\03\"\n            \"ive\");\n            break;\n        }\n        if (ends(\"\\07\"\n                 \"fulness\")) {\n            r(\n            \"\\03\"\n            \"ful\");\n            break;\n        }\n        if (ends(\"\\07\"\n                 \"ousness\")) {\n            r(\n            \"\\03\"\n            \"ous\");\n            break;\n        }\n        break;\n    case 't':\n        if (ends(\"\\05\"\n                 \"aliti\")) {\n            r(\n            \"\\02\"\n            \"al\");\n            break;\n        }\n        if (ends(\"\\05\"\n                 \"iviti\")) {\n            r(\n            \"\\03\"\n            \"ive\");\n            break;\n        }\n        if (ends(\"\\06\"\n                 \"biliti\")) {\n            r(\n            \"\\03\"\n            \"ble\");\n            break;\n        }\n        break;\n    case 'g':\n        if (ends(\"\\04\"\n                 \"logi\")) {\n            r(\n            \"\\03\"\n            \"log\");\n            break;\n        } /*-DEPARTURE-*/\n\n        /* To match the published algorithm, delete this line */\n    }\n}\n\n/* step3() deals with -ic-, -full, -ness etc. similar strategy to step2. */\n\nstatic void step3()\n{\n    switch (s_b[s_k]) {\n    case 'e':\n        if (ends(\"\\05\"\n                 \"icate\")) {\n            r(\n            \"\\02\"\n            \"ic\");\n            break;\n        }\n        if (ends(\"\\05\"\n                 \"ative\")) {\n            r(\n            \"\\00\"\n            \"\");\n            break;\n        }\n        if (ends(\"\\05\"\n                 \"alize\")) {\n            r(\n            \"\\02\"\n            \"al\");\n            break;\n        }\n        break;\n    case 'i':\n        if (ends(\"\\05\"\n                 \"iciti\")) {\n            r(\n            \"\\02\"\n            \"ic\");\n            break;\n        }\n        break;\n    case 'l':\n        if (ends(\"\\04\"\n                 \"ical\")) {\n            r(\n            \"\\02\"\n            \"ic\");\n            break;\n        }\n        if (ends(\"\\03\"\n                 \"ful\")) {\n            r(\n            \"\\00\"\n            \"\");\n            break;\n        }\n        break;\n    case 's':\n        if (ends(\"\\04\"\n                 \"ness\")) {\n            r(\n            \"\\00\"\n            \"\");\n            break;\n        }\n        break;\n    }\n}\n\n/* step4() takes off -ant, -ence etc., in context <c>vcvc<v>. */\n\nstatic void step4()\n{\n    switch (s_b[s_k - 1]) {\n    case 'a':\n        if (ends(\"\\02\"\n                 \"al\"))\n            break;\n        return;\n    case 'c':\n        if (ends(\"\\04\"\n                 \"ance\"))\n            break;\n        if (ends(\"\\04\"\n                 \"ence\"))\n            break;\n        return;\n    case 'e':\n        if (ends(\"\\02\"\n                 \"er\"))\n            break;\n        return;\n    case 'i':\n        if (ends(\"\\02\"\n                 \"ic\"))\n            break;\n        return;\n    case 'l':\n        if (ends(\"\\04\"\n                 \"able\"))\n            break;\n        if (ends(\"\\04\"\n                 \"ible\"))\n            break;\n        return;\n    case 'n':\n        if (ends(\"\\03\"\n                 \"ant\"))\n            break;\n        if (ends(\"\\05\"\n                 \"ement\"))\n            break;\n        if (ends(\"\\04\"\n                 \"ment\"))\n            break;\n        if (ends(\"\\03\"\n                 \"ent\"))\n            break;\n        return;\n    case 'o':\n        if (ends(\"\\03\"\n                 \"ion\")\n            && s_j >= s_k0 && (s_b[s_j] == 's' || s_b[s_j] == 't'))\n            break;\n        if (ends(\"\\02\"\n                 \"ou\"))\n            break;\n        return;\n        /* takes care of -ous */\n    case 's':\n        if (ends(\"\\03\"\n                 \"ism\"))\n            break;\n        return;\n    case 't':\n        if (ends(\"\\03\"\n                 \"ate\"))\n            break;\n        if (ends(\"\\03\"\n                 \"iti\"))\n            break;\n        return;\n    case 'u':\n        if (ends(\"\\03\"\n                 \"ous\"))\n            break;\n        return;\n    case 'v':\n        if (ends(\"\\03\"\n                 \"ive\"))\n            break;\n        return;\n    case 'z':\n        if (ends(\"\\03\"\n                 \"ize\"))\n            break;\n        return;\n    default:\n        return;\n    }\n    if (m() > 1) s_k = s_j;\n}\n\n/* step5() removes a final -e if m() > 1, and changes -ll to -l if\n m() > 1. */\n\nstatic void step5()\n{\n    s_j = s_k;\n    if (s_b[s_k] == 'e') {\n        int a = m();\n        if (a > 1 || (a == 1 && !cvc(s_k - 1))) s_k--;\n    }\n    if (s_b[s_k] == 'l' && doublec(s_k) && m() > 1) s_k--;\n}\n\n/* In stem(p,i,j), p is a char pointer, and the string to be stemmed is from\n p[i] to p[j] inclusive. Typically i is zero and j is the offset to the last\n character of a string, (p[j+1] == '\\0'). The stemmer adjusts the\n characters p[i] ... p[j] and returns the new end-point of the string, k.\n Stemming never increases word length, so i <= k <= j. To turn the stemmer\n into a module, declare 'stem' as extern, and delete the remainder of this\n file.\n */\n\nint porterStem(char* p, int i, int j)\n{\n    s_b = p;\n    s_k = j;\n    s_k0 = i;                        /* copy the parameters into statics */\n    if (s_k <= s_k0 + 1) return s_k; /*-DEPARTURE-*/\n\n    /* With this line, strings of length 1 or 2 don't go through the\n     stemming process, although no mention is made of this in the\n     published algorithm. Remove the line to match the published\n     algorithm. */\n\n    step1ab();\n    if (s_k > s_k0) {\n        step1c();\n        step2();\n        step3();\n        step4();\n        step5();\n    }\n    return s_k;\n}\n\n/*--------------------stemmer definition ends here------------------------*/\n"
  },
  {
    "path": "src/common/core/fts/tokenizer/SQLiteFTS3Tokenizer.h",
    "content": "//\n// Created by sanhuazhang on 2019/05/19\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n#pragma GCC diagnostic push\n#pragma GCC diagnostic ignored \"-Wquoted-include-in-framework-header\"\n#pragma GCC diagnostic ignored \"-Wmodule-import-in-extern-c\"\n#include <sqlcipher/fts3_tokenizer.h>\n#pragma GCC diagnostic pop\n\n#ifdef __cplusplus\n}\n#endif\n"
  },
  {
    "path": "src/common/core/fts/tokenizer/TokenizerConfig.cpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/28\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"TokenizerConfig.hpp\"\n#include \"Assertion.hpp\"\n#include \"InnerHandle.hpp\"\n#include \"SQLite.h\"\n#include \"TokenizerModules.hpp\"\n#include <cstring>\n\nnamespace WCDB {\n\nTokenizerConfig::TokenizerConfig(const UnsafeStringView& name_,\n                                 const std::shared_ptr<TokenizerModules>& modules)\n: Config()\n, name(name_)\n, m_modules(modules)\n, m_fts3Statement(StatementSelect().select(\n  Expression::function(\"fts3_tokenizer\").invoke().arguments(BindParameter::bindParameters(2))))\n, m_fts5Statement(StatementSelect().select(\n  Expression::function(\"fts5\").invoke().arguments(BindParameter::bindParameters(1))))\n{\n    size_t pos = name.find(\" \");\n    if (pos != UnsafeStringView::npos) {\n        name = StringView(name.data(), pos);\n    }\n}\n\nTokenizerConfig::~TokenizerConfig() = default;\n\nbool TokenizerConfig::invoke(InnerHandle* handle)\n{\n    const TokenizerModule* module = m_modules->get(name);\n    WCTRemedialAssert(module != nullptr, \"Module does not exist.\", return true;);\n    if (module->getFts3Module() != nullptr) {\n        auto exists = handle->ft3TokenizerExists(name);\n        if (!exists.succeed()) {\n            return false;\n        }\n        if (exists.value()) {\n            return true;\n        }\n        bool succeed = false;\n        if (handle->prepare(m_fts3Statement)) {\n            handle->bindText(name, 1);\n            FTS3TokenizerModule* fts3Module = module->getFts3Module().get();\n            UnsafeData address((unsigned char*) &fts3Module, sizeof(unsigned char*));\n            handle->bindBLOB(address, 2);\n            succeed = handle->step();\n            handle->finalize();\n        }\n        return succeed;\n    } else {\n        fts5_api* api = nullptr;\n        if (handle->prepare(m_fts5Statement)) {\n            const UnsafeStringView type = \"fts5_api_ptr\";\n            handle->bindPointer((void*) &api, 1, type, nullptr);\n            if (!handle->step() || api == nullptr) {\n                handle->finalize();\n                return false;\n            }\n            handle->finalize();\n        }\n        void* pCtx = nullptr;\n        fts5_tokenizer* pTokenizer = new fts5_tokenizer();\n        if (api->xFindTokenizer(api, name.data(), &pCtx, pTokenizer) == SQLITE_OK) {\n            delete pTokenizer;\n            return true;\n        }\n        delete pTokenizer;\n        if (api->xCreateTokenizer(api,\n                                  name.data(),\n                                  module->getFts5Module()->getContext(),\n                                  (fts5_tokenizer*) module->getFts5Module().get(),\n                                  nullptr)\n            != SQLITE_OK) {\n            return false;\n        }\n        return true;\n    }\n}\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/common/core/fts/tokenizer/TokenizerConfig.hpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/28\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"Config.hpp\"\n#include \"WINQ.h\"\n\nnamespace WCDB {\n\nclass TokenizerModules;\n\nclass TokenizerConfig final : public Config {\npublic:\n    TokenizerConfig(const UnsafeStringView& name,\n                    const std::shared_ptr<TokenizerModules>& modules);\n    ~TokenizerConfig() override;\n\n    StringView name;\n\n    bool invoke(InnerHandle* handle) override final;\n\nprotected:\n    std::shared_ptr<TokenizerModules> m_modules;\n    StatementSelect m_fts3Statement;\n    StatementSelect m_fts5Statement;\n};\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/common/core/fts/tokenizer/TokenizerModule.cpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/19\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"TokenizerModule.hpp\"\n#include \"Assertion.hpp\"\n#include \"SQLite.h\"\n#include \"SQLiteFTS3Tokenizer.h\"\n#include <cstring>\n#include <memory>\n\nnamespace WCDB {\n\n#ifndef offsetof\n#define offsetof(STRUCTURE, FIELD) ((int) ((char *) &((STRUCTURE *) 0)->FIELD))\n#endif\n\n#pragma mark - AbstractFTS5Tokenizer\nAbstractFTSTokenizer::AbstractFTSTokenizer(const char *const *azArg, int nArg, void *pCtx)\n{\n    WCDB_UNUSED(pCtx);\n    WCDB_UNUSED(azArg);\n    WCDB_UNUSED(nArg);\n}\n\nAbstractFTSTokenizer::~AbstractFTSTokenizer() = default;\n\nstruct FTS3TokenizerWrap {\n    sqlite3_tokenizer base;\n    AbstractFTSTokenizer *tokenizer;\n};\n\nstruct FTS3TokenizeCursorWrap {\n    sqlite3_tokenizer_cursor base;\n    AbstractFTSTokenizer *tokenizer;\n};\n\n#pragma mark - AbstractFTS3TokenizerModuleTemplate\nint AbstractFTS3TokenizerModuleTemplate::newTokenizer(FTS3TokenizerWrap **ppTokenizerWrap,\n                                                      AbstractFTSTokenizer *tokenizer)\n{\n    WCTAssert(ppTokenizerWrap != nullptr);\n    *ppTokenizerWrap = nullptr;\n    if (tokenizer == nullptr) {\n        return FTSError::NoMem();\n    }\n    FTS3TokenizerWrap *tokenizerWrap\n    = (FTS3TokenizerWrap *) sqlite3_malloc(sizeof(FTS3TokenizerWrap));\n    if (tokenizer == nullptr) {\n        return FTSError::NoMem();\n    }\n    memset(tokenizerWrap, 0, sizeof(FTS3TokenizerWrap));\n    tokenizerWrap->tokenizer = tokenizer;\n    *(sqlite3_tokenizer **) ppTokenizerWrap = &tokenizerWrap->base;\n    return FTSError::OK();\n}\n\nAbstractFTSTokenizer *\nAbstractFTS3TokenizerModuleTemplate::getTokenizerFromWrap(FTS3TokenizerWrap *tokenizerWrap)\n{\n    WCTAssert(tokenizerWrap != nullptr);\n    return tokenizerWrap->tokenizer;\n}\n\nvoid AbstractFTS3TokenizerModuleTemplate::deleteTokenizerWrap(FTS3TokenizerWrap *ppTokenizerWrap)\n{\n    if (ppTokenizerWrap != nullptr) {\n        sqlite3_free(ppTokenizerWrap);\n    }\n}\n\nint AbstractFTS3TokenizerModuleTemplate::newCursor(FTS3TokenizeCursorWrap **ppCursor,\n                                                   AbstractFTSTokenizer *tokenizer)\n{\n    WCTAssert(ppCursor != nullptr);\n    *ppCursor = nullptr;\n    if (tokenizer == nullptr) {\n        return FTSError::NoMem();\n    }\n    FTS3TokenizeCursorWrap *cursor\n    = (FTS3TokenizeCursorWrap *) sqlite3_malloc(sizeof(FTS3TokenizeCursorWrap));\n    if (cursor == nullptr) {\n        return FTSError::NoMem();\n    }\n    memset(cursor, 0, sizeof(FTS3TokenizeCursorWrap));\n    cursor->tokenizer = tokenizer;\n    *(sqlite3_tokenizer_cursor **) ppCursor = &cursor->base;\n    return FTSError::OK();\n}\n\nAbstractFTSTokenizer *\nAbstractFTS3TokenizerModuleTemplate::getTokenizerFromCurser(FTS3TokenizeCursorWrap *pCursor)\n{\n    WCTAssert(pCursor != nullptr);\n    return pCursor->tokenizer;\n}\n\nvoid AbstractFTS3TokenizerModuleTemplate::deleteCursor(FTS3TokenizeCursorWrap *pCursor)\n{\n    if (pCursor != nullptr) {\n        sqlite3_free(pCursor);\n    }\n}\n\n#pragma mark - FTS3TokenizerModule\nFTS3TokenizerModule::FTS3TokenizerModule()\n: m_version(0)\n, m_create(nullptr)\n, m_destroy(nullptr)\n, m_open(nullptr)\n, m_close(nullptr)\n, m_next(nullptr)\n, m_languageid(nullptr)\n{\n}\n\nFTS3TokenizerModule::FTS3TokenizerModule(const FTS3TokenizerModule::Create &create,\n                                         const FTS3TokenizerModule::Destroy &destroy,\n                                         const FTS3TokenizerModule::Open &open,\n                                         const FTS3TokenizerModule::Close &close,\n                                         const FTS3TokenizerModule::Next &next)\n: m_version(0)\n, m_create(create)\n, m_destroy(destroy)\n, m_open(open)\n, m_close(close)\n, m_next(next)\n, m_languageid(nullptr)\n{\n    static_assert(sizeof(FTS3TokenizerModule) == sizeof(sqlite3_tokenizer_module), \"\");\n    static_assert(offsetof(FTS3TokenizerModule, m_version)\n                  == offsetof(sqlite3_tokenizer_module, iVersion),\n                  \"\");\n    static_assert(offsetof(FTS3TokenizerModule, m_create)\n                  == offsetof(sqlite3_tokenizer_module, xCreate),\n                  \"\");\n    static_assert(offsetof(FTS3TokenizerModule, m_destroy)\n                  == offsetof(sqlite3_tokenizer_module, xDestroy),\n                  \"\");\n    static_assert(\n    offsetof(FTS3TokenizerModule, m_open) == offsetof(sqlite3_tokenizer_module, xOpen), \"\");\n    static_assert(\n    offsetof(FTS3TokenizerModule, m_close) == offsetof(sqlite3_tokenizer_module, xClose), \"\");\n    static_assert(\n    offsetof(FTS3TokenizerModule, m_next) == offsetof(sqlite3_tokenizer_module, xNext), \"\");\n    static_assert(offsetof(FTS3TokenizerModule, m_languageid)\n                  == offsetof(sqlite3_tokenizer_module, xLanguageid),\n                  \"\");\n}\n\n#pragma mark - FTS5TokenizerModule\nFTS5TokenizerModule::FTS5TokenizerModule()\n: m_create(nullptr), m_destroy(nullptr), m_tokenize(nullptr), m_pCtx(nullptr)\n{\n}\n\nFTS5TokenizerModule::FTS5TokenizerModule(const Create &create,\n                                         const Destroy &destroy,\n                                         const Tokenize &tokenize,\n                                         void *pCtx)\n: m_create(create), m_destroy(destroy), m_tokenize(tokenize), m_pCtx(pCtx)\n{\n    static_assert(\n    sizeof(FTS5TokenizerModule) == sizeof(fts5_tokenizer) + sizeof(m_pCtx), \"\");\n    static_assert(\n    offsetof(FTS5TokenizerModule, m_create) == offsetof(fts5_tokenizer, xCreate), \"\");\n    static_assert(\n    offsetof(FTS5TokenizerModule, m_destroy) == offsetof(fts5_tokenizer, xDelete), \"\");\n    static_assert(\n    offsetof(FTS5TokenizerModule, m_tokenize) == offsetof(fts5_tokenizer, xTokenize), \"\");\n}\n\nvoid *FTS5TokenizerModule::getContext()\n{\n    return m_pCtx;\n}\n\n#pragma mark - TokenizerModule\n\nTokenizerModule::TokenizerModule(std::shared_ptr<FTS3TokenizerModule> fts3Module)\n: m_fts3Module(fts3Module), m_fts5Module(nullptr)\n{\n}\n\nTokenizerModule::TokenizerModule(std::shared_ptr<FTS5TokenizerModule> fts5Module)\n: m_fts3Module(nullptr), m_fts5Module(fts5Module)\n{\n}\n\nstd::shared_ptr<FTS3TokenizerModule> TokenizerModule::getFts3Module() const\n{\n    WCTAssert(m_fts3Module == nullptr || m_fts5Module == nullptr);\n    return m_fts3Module;\n}\n\nstd::shared_ptr<FTS5TokenizerModule> TokenizerModule::getFts5Module() const\n{\n    WCTAssert(m_fts3Module == nullptr || m_fts5Module == nullptr);\n    return m_fts5Module;\n}\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/core/fts/tokenizer/TokenizerModule.hpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/19\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n#include \"FTSError.hpp\"\n#include <memory>\n\nnamespace WCDB {\n\nclass WCDB_API AbstractFTSTokenizer {\npublic:\n    AbstractFTSTokenizer(const char *const *azArg, int nArg, void *pCtx /* pCtx is only used in FTS5 */);\n    virtual ~AbstractFTSTokenizer() = 0;\n    virtual void\n    loadInput(const char *pText, int nText, int flags /* flags is only used in FTS5 */)\n    = 0;\n    virtual int nextToken(const char **ppToken,\n                          int *nToken,\n                          int *iStart,\n                          int *iEnd,\n                          int *tflags,   //tflags is only used in FTS5\n                          int *iPosition //iPosition is only used in FTS3/4\n                          )\n    = 0;\n};\n\ntypedef struct FTS3TokenizerWrap FTS3TokenizerWrap;\ntypedef struct FTS3TokenizeCursorWrap FTS3TokenizeCursorWrap;\n\nclass WCDB_API AbstractFTS3TokenizerModuleTemplate {\npublic:\n    AbstractFTS3TokenizerModuleTemplate() = delete;\n    AbstractFTS3TokenizerModuleTemplate(const AbstractFTS3TokenizerModuleTemplate &) = delete;\n    AbstractFTS3TokenizerModuleTemplate &\n    operator=(const AbstractFTS3TokenizerModuleTemplate &)\n    = delete;\n\nprotected:\n    static int\n    newTokenizer(FTS3TokenizerWrap **ppTokenizerWrap, AbstractFTSTokenizer *tokenizer);\n    static AbstractFTSTokenizer *getTokenizerFromWrap(FTS3TokenizerWrap *tokenizerWrap);\n    static void deleteTokenizerWrap(FTS3TokenizerWrap *ppTokenizer);\n\n    static int newCursor(FTS3TokenizeCursorWrap **ppCursor, AbstractFTSTokenizer *tokenizer);\n    static AbstractFTSTokenizer *getTokenizerFromCurser(FTS3TokenizeCursorWrap *pCursor);\n    static void deleteCursor(FTS3TokenizeCursorWrap *pCursor);\n};\n\nclass WCDB_API FTS3TokenizerModule final {\npublic:\n    typedef int (*Create)(int argc, const char *const *argv, FTS3TokenizerWrap **ppTokenizer);\n    typedef int (*Destroy)(FTS3TokenizerWrap *pTokenizer);\n    typedef int (*Open)(FTS3TokenizerWrap *pTokenizer,\n                        const char *pInput,\n                        int nBytes,\n                        FTS3TokenizeCursorWrap **ppCursor);\n    typedef int (*Close)(FTS3TokenizeCursorWrap *pCursor);\n    typedef int (*Next)(FTS3TokenizeCursorWrap *pCursor,\n                        const char **ppToken,\n                        int *pnBytes,\n                        int *piStartOffset,\n                        int *piEndOffset,\n                        int *piPosition);\n    typedef int (*Languageid)(FTS3TokenizeCursorWrap *pCursor, int iLangid);\n\n    FTS3TokenizerModule();\n    FTS3TokenizerModule(const Create &create,\n                        const Destroy &destroy,\n                        const Open &open,\n                        const Close &close,\n                        const Next &next);\n\n#pragma GCC diagnostic push\n#pragma GCC diagnostic ignored \"-Wunused-private-field\"\nprivate:\n    int m_version;\n    Create m_create;\n    Destroy m_destroy;\n    Open m_open;\n    Close m_close;\n    Next m_next;\n    Languageid m_languageid;\n#pragma GCC diagnostic pop\n};\n\n#pragma mark - fts5\n\nclass WCDB_API AbstractFTS5TokenizerModuleTemplate {\npublic:\n    AbstractFTS5TokenizerModuleTemplate() = delete;\n    AbstractFTS5TokenizerModuleTemplate(const AbstractFTS5TokenizerModuleTemplate &) = delete;\n    AbstractFTS5TokenizerModuleTemplate &\n    operator=(const AbstractFTS5TokenizerModuleTemplate &)\n    = delete;\n};\n\nclass WCDB_API FTS5TokenizerModule final {\npublic:\n    typedef int (*Create)(void *, const char *const *azArg, int nArg, AbstractFTSTokenizer **ppTokenizer);\n    typedef int (*Destroy)(AbstractFTSTokenizer *pTokenizer);\n    typedef int (*TokenCallback)(\n    void *pCtx, int tflags, const char *pToken, int nToken, int iStart, int iEnd);\n    typedef int (*Tokenize)(AbstractFTSTokenizer *pTokenizer,\n                            void *pCtx,\n                            int flags,\n                            const char *pText,\n                            int nText,\n                            TokenCallback callback);\n\n    FTS5TokenizerModule();\n    FTS5TokenizerModule(const Create &create,\n                        const Destroy &destroy,\n                        const Tokenize &tokenize,\n                        void *pCtx);\n    void *getContext();\n\n#pragma GCC diagnostic push\n#pragma GCC diagnostic ignored \"-Wunused-private-field\"\nprivate:\n    Create m_create;\n    Destroy m_destroy;\n    Tokenize m_tokenize;\n    void *m_pCtx;\n#pragma GCC diagnostic pop\n};\n\n#pragma mark - fts module wrapper\n\nclass WCDB_API TokenizerModule {\npublic:\n    TokenizerModule(std::shared_ptr<FTS3TokenizerModule> fts3Module);\n    TokenizerModule(std::shared_ptr<FTS5TokenizerModule> fts3Module);\n    TokenizerModule() = delete;\n    std::shared_ptr<FTS3TokenizerModule> getFts3Module() const;\n    std::shared_ptr<FTS5TokenizerModule> getFts5Module() const;\n\nprivate:\n    std::shared_ptr<FTS3TokenizerModule> m_fts3Module;\n    std::shared_ptr<FTS5TokenizerModule> m_fts5Module;\n};\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/core/fts/tokenizer/TokenizerModuleTemplate.hpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"TokenizerModule.hpp\"\n#include <cstring>\n#include <type_traits>\n\nnamespace WCDB {\n\ntemplate<typename Fts3Tokenizer>\nclass FTS3TokenizerModuleTemplate final : protected AbstractFTS3TokenizerModuleTemplate {\npublic:\n    static_assert(std::is_base_of<AbstractFTSTokenizer, Fts3Tokenizer>::value, \"\");\n\n    static TokenizerModule specialize()\n    {\n        return TokenizerModule(std::make_shared<FTS3TokenizerModule>(\n        create, destroy, open, close, next));\n    }\n\n    static int create(int argc, const char *const *argv, FTS3TokenizerWrap **ppTokenizerWrap)\n    {\n        Fts3Tokenizer *tokenizer = new Fts3Tokenizer(argv, argc, nullptr);\n        int rc = newTokenizer(ppTokenizerWrap, tokenizer);\n        if (!FTSError::isOK(rc)) {\n            if (tokenizer != nullptr) {\n                delete tokenizer;\n            }\n            deleteTokenizerWrap(*ppTokenizerWrap);\n            *ppTokenizerWrap = nullptr;\n        }\n        return rc;\n    }\n\n    static int destroy(FTS3TokenizerWrap *tokenizerWrap)\n    {\n        if (tokenizerWrap != nullptr) {\n            AbstractFTSTokenizer *tokenizer = getTokenizerFromWrap(tokenizerWrap);\n            deleteTokenizer(static_cast<Fts3Tokenizer *>(tokenizer));\n            deleteTokenizerWrap(tokenizerWrap);\n        }\n        return FTSError::OK();\n    }\n\n    static void deleteTokenizer(Fts3Tokenizer *tokenizer)\n    {\n        if (tokenizer != nullptr) {\n            delete tokenizer;\n        }\n    }\n\n    static int open(FTS3TokenizerWrap *tokenizerWrap,\n                    const char *pInput,\n                    int nBytes,\n                    FTS3TokenizeCursorWrap **ppCursor)\n    {\n        AbstractFTSTokenizer *tokenizer = getTokenizerFromWrap(tokenizerWrap);\n        if (pInput == nullptr) {\n            nBytes = 0;\n        } else if (nBytes <= 0) {\n            nBytes = (int) strlen(pInput);\n        }\n        tokenizer->loadInput(pInput, nBytes, 0);\n        int rc = newCursor(ppCursor, tokenizer);\n        if (!FTSError::isOK(rc)) {\n            deleteCursor(*ppCursor);\n            *ppCursor = nullptr;\n        }\n        return rc;\n    }\n\n    static int close(FTS3TokenizeCursorWrap *pCursor)\n    {\n        deleteCursor(pCursor);\n        return FTSError::OK();\n    }\n\n    static int next(FTS3TokenizeCursorWrap *pCursor,\n                    const char **ppToken,\n                    int *pnBytes,\n                    int *piStartOffset,\n                    int *piEndOffset,\n                    int *piPosition)\n    {\n        AbstractFTSTokenizer *tokenizer = getTokenizerFromCurser(pCursor);\n        return tokenizer->nextToken(\n        ppToken, pnBytes, piStartOffset, piEndOffset, nullptr, piPosition);\n    }\n};\n\ntemplate<typename Fts5Tokenizer>\nclass FTS5TokenizerModuleTemplate final : protected AbstractFTS5TokenizerModuleTemplate {\npublic:\n    static_assert(std::is_base_of<AbstractFTSTokenizer, Fts5Tokenizer>::value, \"\");\n\n    static TokenizerModule specializeWithContext(void *pCtx)\n    {\n        return TokenizerModule(\n        std::make_shared<FTS5TokenizerModule>(create, destroy, tokenize, pCtx));\n    }\n\n    static int\n    create(void *pCtx, const char *const *azArg, int nArg, AbstractFTSTokenizer **ppTokenizer)\n    {\n        *ppTokenizer\n        = static_cast<AbstractFTSTokenizer *>(new Fts5Tokenizer(azArg, nArg, pCtx));\n        return FTSError::OK();\n    }\n\n    static int destroy(AbstractFTSTokenizer *pTokenizer)\n    {\n        delete pTokenizer;\n        return FTSError::OK();\n    }\n\n    static int\n    tokenize(AbstractFTSTokenizer *pTokenizer,\n             void *pCtx,\n             int flags,\n             const char *pText,\n             int nText,\n             int (*xToken)(void *pCtx, int tflags, const char *pToken, int nToken, int iStart, int iEnd))\n    {\n        int rc;\n        const char *pToken;\n        int nToken;\n        int iStart;\n        int iEnd;\n        int tflags;\n        if (pText == nullptr) {\n            nText = 0;\n        } else if (nText <= 0) {\n            nText = (int) strlen(pText);\n        }\n        pTokenizer->loadInput(pText, nText, flags);\n        while (FTSError::isOK(rc = pTokenizer->nextToken(\n                              &pToken, &nToken, &iStart, &iEnd, &tflags, nullptr))) {\n            rc = xToken(pCtx, tflags, pToken, nToken, iStart, iEnd);\n            if (!FTSError::isOK(rc)) {\n                break;\n            }\n        }\n        if (FTSError::isDone(rc)) {\n            return FTSError::OK();\n        }\n        return rc;\n    }\n};\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/core/fts/tokenizer/TokenizerModules.cpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"TokenizerModules.hpp\"\n#include \"Assertion.hpp\"\n#include \"SQLiteFTS3Tokenizer.h\"\n#include \"WCDBError.hpp\"\n\nnamespace WCDB {\n\nvoid TokenizerModules::add(const UnsafeStringView& name, const TokenizerModule& module)\n{\n    WCTRemedialAssert(!name.empty(), \"Name of module can't be null.\", return;);\n    LockGuard lockGuard(m_lock);\n    WCTRemedialAssert(\n    m_modules.find(name) == m_modules.end(), \"Module already exists.\", return;);\n    auto iter = m_modules.emplace(name, module).first;\n    WCTAssert(m_pointers.find(name) == m_pointers.end());\n    m_pointers.emplace(name, &iter->second);\n}\n\nconst TokenizerModule* TokenizerModules::get(const UnsafeStringView& name) const\n{\n    SharedLockGuard lockGuard(m_lock);\n    const TokenizerModule* module = nullptr;\n    const auto iter = m_pointers.find(name);\n    if (iter != m_pointers.end()) {\n        module = iter->second;\n    }\n    return module;\n}\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/core/fts/tokenizer/TokenizerModules.hpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"Lock.hpp\"\n#include \"StringView.hpp\"\n#include \"TokenizerModule.hpp\"\n#include \"TokenizerModuleTemplate.hpp\"\n#include \"UnsafeData.hpp\"\n#include <list>\n\nnamespace WCDB {\n\nclass TokenizerModules final {\npublic:\n    void add(const UnsafeStringView& name, const TokenizerModule& module);\n    const TokenizerModule* get(const UnsafeStringView& name) const;\n\nprotected:\n    StringViewMap<const TokenizerModule> m_modules;\n    StringViewMap<const TokenizerModule*> m_pointers;\n    mutable SharedLock m_lock;\n};\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/core/function/FunctionModules.hpp",
    "content": "//\n// Created by 陈秋文 on 2023/11/25.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"Assertion.hpp\"\n#include \"Lock.hpp\"\n#include \"StringView.hpp\"\n#include \"WCDBError.hpp\"\n#include <list>\n\nnamespace WCDB {\n\ntemplate<typename FunctionModule>\nclass FunctionModules final {\npublic:\n    void add(const UnsafeStringView& name, const FunctionModule& module)\n    {\n        WCTRemedialAssert(!name.empty(), \"Name of module can't be null.\", return;);\n        LockGuard lockGuard(m_lock);\n        WCTRemedialAssert(\n        m_modules.find(name) == m_modules.end(), \"Module already exists.\", return;);\n        m_modules.emplace(name, module);\n    }\n\n    const FunctionModule* get(const UnsafeStringView& name) const\n    {\n        SharedLockGuard lockGuard(m_lock);\n        const FunctionModule* module = nullptr;\n        const auto iter = m_modules.find(name);\n        if (iter != m_modules.end()) {\n            module = &(iter->second);\n        }\n        return module;\n    }\n\nprotected:\n    StringViewMap<const FunctionModule> m_modules;\n    mutable SharedLock m_lock;\n};\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/core/function/scalar/ScalarFunctionConfig.cpp",
    "content": "//\n// Created by qiuwenchen on 2023/11/25.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"ScalarFunctionConfig.hpp\"\n#include \"Assertion.hpp\"\n#include \"InnerHandle.hpp\"\n#include \"Notifier.hpp\"\n#include \"SQLite.h\"\n\nnamespace WCDB {\n\nScalarFunctionConfig::ScalarFunctionConfig(const UnsafeStringView& name_,\n                                           const std::shared_ptr<ScalarFunctionModules>& modules)\n: Config(), name(name_), m_modules(modules)\n{\n}\n\nScalarFunctionConfig::~ScalarFunctionConfig() = default;\n\nbool ScalarFunctionConfig::invoke(InnerHandle* handle)\n{\n    const ScalarFunctionModule* module = m_modules->get(name);\n    WCTRemedialAssert(module != nullptr, \"Module does not exist.\", return true;);\n    int rc = sqlite3_create_function(\n    handle->getRawHandle(),\n    name.data(),\n    module->getParameterNum(),\n    module->isDeterminisic() ? SQLITE_DETERMINISTIC | SQLITE_UTF8 : SQLITE_UTF8,\n    module->getUserCtx(),\n    (void (*)(sqlite3_context*, int, sqlite3_value**)) module->getFunc(),\n    nullptr,\n    nullptr);\n    if (rc != SQLITE_OK) {\n        handle->notifyError(rc, \"create scalar function\");\n        return false;\n    }\n    return true;\n}\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/common/core/function/scalar/ScalarFunctionConfig.hpp",
    "content": "//\n// Created by qiuwenchen on 2023/11/25.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"Config.hpp\"\n#include \"FunctionModules.hpp\"\n#include \"ScalarFunctionModule.hpp\"\n#include \"WINQ.h\"\n\nnamespace WCDB {\n\ntypedef FunctionModules<ScalarFunctionModule> ScalarFunctionModules;\n\nclass ScalarFunctionConfig final : public Config {\npublic:\n    ScalarFunctionConfig(const UnsafeStringView& name,\n                         const std::shared_ptr<ScalarFunctionModules>& modules);\n    ~ScalarFunctionConfig() override;\n\n    StringView name;\n\n    bool invoke(InnerHandle* handle) override final;\n\nprotected:\n    std::shared_ptr<ScalarFunctionModules> m_modules;\n};\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/common/core/function/scalar/ScalarFunctionModule.cpp",
    "content": "//\n// Created by 陈秋文 on 2023/11/25.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"ScalarFunctionModule.hpp\"\n#include \"Assertion.hpp\"\n#include \"SQLite.h\"\n\nnamespace WCDB {\n\n// Access value\nScalarFunctionAPI::ScalarFunctionAPI(SQLiteContext *ctx, SQLiteValue **values, int valueNum)\n: m_sqliteContext(ctx), m_values(values), m_valueNum(valueNum)\n{\n}\n\nint ScalarFunctionAPI::getValueCount() const\n{\n    return m_valueNum;\n}\n\nColumnType ScalarFunctionAPI::getValueType(int index) const\n{\n    WCTAssert(index < m_valueNum);\n    if (index < m_valueNum) {\n        int type = sqlite3_value_type((sqlite3_value *) m_values[index]);\n        switch (type) {\n        case SQLITE_INTEGER:\n            return ColumnType::Integer;\n        case SQLITE_FLOAT:\n            return ColumnType::Float;\n        case SQLITE_BLOB:\n            return ColumnType::BLOB;\n        case SQLITE_TEXT:\n            return ColumnType::Text;\n        default:\n            return ColumnType::Null;\n        }\n    } else {\n        return ColumnType::Null;\n    }\n}\n\nint64_t ScalarFunctionAPI::getIntValue(int index) const\n{\n    WCTAssert(index < m_valueNum);\n    if (index < m_valueNum) {\n        return sqlite3_value_int64((sqlite3_value *) m_values[index]);\n    } else {\n        return 0;\n    }\n}\n\ndouble ScalarFunctionAPI::getFloatValue(int index) const\n{\n    WCTAssert(index < m_valueNum);\n    if (index < m_valueNum) {\n        return sqlite3_value_double((sqlite3_value *) m_values[index]);\n    } else {\n        return 0;\n    }\n}\n\nconst UnsafeStringView ScalarFunctionAPI::getTextValue(int index) const\n{\n    WCTAssert(index < m_valueNum);\n    if (index < m_valueNum) {\n        return UnsafeStringView(\n        (const char *) sqlite3_value_text((sqlite3_value *) m_values[index]),\n        sqlite3_value_bytes((sqlite3_value *) m_values[index]));\n    } else {\n        return UnsafeStringView();\n    }\n}\n\nconst UnsafeData ScalarFunctionAPI::getBlobValue(int index) const\n{\n    WCTAssert(index < m_valueNum);\n    if (index < m_valueNum) {\n        return UnsafeData(\n        (unsigned char *) sqlite3_value_blob((sqlite3_value *) m_values[index]),\n        sqlite3_value_bytes((sqlite3_value *) m_values[index]));\n    } else {\n        return UnsafeData();\n    }\n}\n\n// Output result\nvoid ScalarFunctionAPI::setNullResult()\n{\n    if (!m_sqliteContext) {\n        return;\n    }\n    sqlite3_result_null((sqlite3_context *) m_sqliteContext);\n}\n\nvoid ScalarFunctionAPI::setFloatResult(double result)\n{\n    if (!m_sqliteContext) {\n        return;\n    }\n    sqlite3_result_double((sqlite3_context *) m_sqliteContext, result);\n}\n\nvoid ScalarFunctionAPI::setIntResult(int64_t result)\n{\n    if (!m_sqliteContext) {\n        return;\n    }\n    sqlite3_result_int64((sqlite3_context *) m_sqliteContext, result);\n}\n\nvoid ScalarFunctionAPI::setTextResult(const UnsafeStringView &result)\n{\n    if (!m_sqliteContext) {\n        return;\n    }\n    sqlite3_result_text(\n    (sqlite3_context *) m_sqliteContext, result.data(), (int) result.length(), SQLITE_TRANSIENT);\n}\n\nvoid ScalarFunctionAPI::setBlobResult(const UnsafeData &data)\n{\n    if (!m_sqliteContext) {\n        return;\n    }\n    sqlite3_result_blob(\n    (sqlite3_context *) m_sqliteContext, data.buffer(), (int) data.size(), SQLITE_TRANSIENT);\n}\n\nvoid ScalarFunctionAPI::setErrorResult(Error::Code code, const UnsafeStringView &msg)\n{\n    if (!m_sqliteContext) {\n        return;\n    }\n    sqlite3_result_error(\n    (sqlite3_context *) m_sqliteContext, msg.data(), (int) msg.length());\n    sqlite3_result_error_code((sqlite3_context *) m_sqliteContext, (int) code);\n}\n\nvoid ScalarFunctionAPI::setErrorResult(int code, const UnsafeStringView &msg)\n{\n    if (!m_sqliteContext) {\n        return;\n    }\n    sqlite3_result_error(\n    (sqlite3_context *) m_sqliteContext, msg.data(), (int) msg.length());\n    sqlite3_result_error_code((sqlite3_context *) m_sqliteContext, code);\n}\n\nvoid ScalarFunctionAPI::setAuxData(void *data, void (*destroy)(void *), int index)\n{\n    if (!m_sqliteContext) {\n        return;\n    }\n    sqlite3_set_auxdata((sqlite3_context *) m_sqliteContext, index, data, destroy);\n}\n\nvoid *ScalarFunctionAPI::getAuxData(int index)\n{\n    if (!m_sqliteContext) {\n        return nullptr;\n    }\n    return sqlite3_get_auxdata((sqlite3_context *) m_sqliteContext, index);\n}\n\nvoid *ScalarFunctionAPI::getUserData() const\n{\n    if (!m_sqliteContext) {\n        return nullptr;\n    }\n    return sqlite3_user_data((sqlite3_context *) m_sqliteContext);\n}\n\nAbstractScalarFunctionObject::AbstractScalarFunctionObject(void *userContext,\n                                                           ScalarFunctionAPI &apiObj)\n{\n    WCDB_UNUSED(userContext);\n    WCDB_UNUSED(apiObj);\n}\n\nAbstractScalarFunctionObject::~AbstractScalarFunctionObject() = default;\n\nScalarFunctionModule::ScalarFunctionModule(const ScalarFunction &func,\n                                           int parameterNum,\n                                           bool deterministic,\n                                           void *userCtx)\n: m_func(func), m_parameterNum(parameterNum), m_deterministic(deterministic), m_userCtx(userCtx)\n{\n}\n\nScalarFunctionModule::ScalarFunction ScalarFunctionModule::getFunc() const\n{\n    return m_func;\n}\n\nvoid *ScalarFunctionModule::getUserCtx() const\n{\n    return m_userCtx;\n}\n\nint ScalarFunctionModule::getParameterNum() const\n{\n    return m_parameterNum;\n}\n\nbool ScalarFunctionModule::isDeterminisic() const\n{\n    return m_deterministic;\n}\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/core/function/scalar/ScalarFunctionModule.hpp",
    "content": "//\n// Created by 陈秋文 on 2023/11/25.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"ColumnType.hpp\"\n#include \"StringView.hpp\"\n#include \"UnsafeData.hpp\"\n#include \"WCDBError.hpp\"\n\nnamespace WCDB {\n\ntypedef struct SQLiteContext SQLiteContext;\ntypedef struct SQLiteValue SQLiteValue;\n\ntemplate<typename ScalarFunctionObject>\nclass ScalarFunctionTemplate;\n\nclass WCDB_API ScalarFunctionAPI {\n    template<typename ScalarFunctionObject>\n    friend class ScalarFunctionTemplate;\n\npublic:\n    // Access value\n    int getValueCount() const;\n    ColumnType getValueType(int index = 0) const;\n    int64_t getIntValue(int index = 0) const;\n    double getFloatValue(int index = 0) const;\n    const UnsafeStringView getTextValue(int index = 0) const;\n    const UnsafeData getBlobValue(int index = 0) const;\n\n    // Output result\n    void setNullResult();\n    void setIntResult(int64_t result);\n    void setFloatResult(double result);\n    void setTextResult(const UnsafeStringView& result);\n    void setBlobResult(const UnsafeData& result);\n    void setErrorResult(Error::Code code, const UnsafeStringView& msg);\n    void setErrorResult(int code, const UnsafeStringView& msg);\n\n    // Access Auxiliary Data\n    void setAuxData(void* data, void (*destroy)(void*), int index = 0);\n    void* getAuxData(int index = 0);\n\nprotected:\n    ScalarFunctionAPI(SQLiteContext* ctx, SQLiteValue** values, int valueNum);\n\n    void* getUserData() const;\n\nprivate:\n    SQLiteContext* m_sqliteContext;\n    SQLiteValue** m_values;\n    int m_valueNum;\n};\n\nclass WCDB_API AbstractScalarFunctionObject {\npublic:\n    AbstractScalarFunctionObject(void* userContext, ScalarFunctionAPI& apiObj);\n    virtual ~AbstractScalarFunctionObject() = 0;\n    virtual void process(ScalarFunctionAPI& apiObj) = 0;\n};\n\nclass WCDB_API ScalarFunctionModule final {\npublic:\n    typedef void (*ScalarFunction)(SQLiteContext* pCtx, int nVal, SQLiteValue** apVal);\n    ScalarFunctionModule() = delete;\n    ScalarFunctionModule(const ScalarFunction& func, int parameterNum, bool deterministic, void* userCtx);\n    ScalarFunction getFunc() const;\n    int getParameterNum() const;\n    bool isDeterminisic() const;\n    void* getUserCtx() const;\n\nprivate:\n    ScalarFunction m_func;\n    int m_parameterNum;\n    bool m_deterministic;\n    void* m_userCtx;\n};\n\n}; // namespace WCDB\n"
  },
  {
    "path": "src/common/core/function/scalar/ScalarFunctionTemplate.hpp",
    "content": "//\n// Created by 陈秋文 on 2023/11/25.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"ScalarFunctionModule.hpp\"\n\nnamespace WCDB {\n\ntemplate<typename ScalarFunctionObject>\nclass ScalarFunctionTemplate {\npublic:\n    static_assert(std::is_base_of<AbstractScalarFunctionObject, ScalarFunctionObject>::value, \"\");\n\n    static ScalarFunctionModule\n    specialize(int parameterNum, bool deterministic = true, void* userContext = nullptr)\n    {\n        return ScalarFunctionModule(run, parameterNum, deterministic, userContext);\n    }\n\n    static void run(SQLiteContext* pCtx, int nVal, SQLiteValue** apVal)\n    {\n        ScalarFunctionAPI apiObj = ScalarFunctionAPI(pCtx, apVal, nVal);\n        ScalarFunctionObject functionObject(apiObj.getUserData(), apiObj);\n        functionObject.process(apiObj);\n    }\n};\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/core/integrity/IntegerityHandleOperator.cpp",
    "content": "//\n// Created by qiuwenchen on 2023/11/17.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"IntegerityHandleOperator.hpp\"\n#include \"Assertion.hpp\"\n#include \"CoreConst.h\"\n#include \"Notifier.hpp\"\n\nnamespace WCDB {\n\nIntegerityHandleOperator::IntegerityHandleOperator(InnerHandle* handle)\n: HandleOperator(handle)\n, m_statementForIntegrityCheck(\n  StatementPragma().pragma(Pragma::integrityCheck()).schema(Schema::main()).with(1))\n, m_statementForGetFTSTable(\n  StatementSelect()\n  .select(Column(\"name\"))\n  .from(Syntax::masterTable)\n  .where(Column(\"type\") == \"table\" && Column(\"sql\").like(\"CREATE VIRTUAL TABLE % USING fts%\")))\n{\n}\n\nIntegerityHandleOperator::~IntegerityHandleOperator() = default;\n\n#pragma mark - Integrity\nvoid IntegerityHandleOperator::checkIntegrity()\n{\n    InnerHandle* handle = getHandle();\n    auto optionalIntegrityMessages = handle->getValues(m_statementForIntegrityCheck, 0);\n    bool needCheckFTS = true;\n    if (optionalIntegrityMessages.succeed()) {\n        auto& integrityMessages = optionalIntegrityMessages.value();\n        WCTAssert(integrityMessages.size() == 1);\n        if (integrityMessages.size() > 0) {\n            auto integrityMessage = *integrityMessages.begin();\n            if (!integrityMessage.caseInsensitiveEqual(\"ok\")) {\n                Error error(Error::Code::Corrupt, Error::Level::Warning, integrityMessage);\n                error.infos.insert_or_assign(ErrorStringKeyPath, handle->getPath());\n                error.infos.insert_or_assign(ErrorStringKeyType, ErrorTypeIntegrity);\n                Notifier::shared().notify(error);\n                needCheckFTS = false;\n            }\n        }\n    }\n    if (!needCheckFTS) {\n        return;\n    }\n    Optional<StringViewSet> ftsTableSet\n    = handle->getValues(m_statementForGetFTSTable, 0);\n    if (!ftsTableSet.succeed()) {\n        return;\n    }\n    for (const StringView& ftsTable : ftsTableSet.value()) {\n        if (handle->executeStatement(\n            StatementInsert().insertIntoTable(ftsTable).column(Column(ftsTable)).value(\"integrity-check\"))) {\n            continue;\n        }\n        const Error& handleError = handle->getError();\n        if (Error::rc2ec((int) handleError.getExtCode()) == Error::ExtCode::CorruptVirtualTable) {\n            Error error(\n            Error::Code::Corrupt, Error::Level::Warning, handleError.getMessage());\n            error.infos.insert_or_assign(ErrorStringKeyPath, handle->getPath());\n            error.infos.insert_or_assign(ErrorStringKeyType, ErrorTypeIntegrity);\n            Notifier::shared().notify(error);\n            break;\n        }\n    }\n}\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/common/core/integrity/IntegerityHandleOperator.hpp",
    "content": "//\n// Created by qiuwenchen on 2023/11/17.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"HandleOperator.hpp\"\n\nnamespace WCDB {\n\nclass IntegerityHandleOperator : public HandleOperator {\npublic:\n    IntegerityHandleOperator(InnerHandle* handle);\n    ~IntegerityHandleOperator();\n    void checkIntegrity();\n\nprotected:\n    StatementPragma m_statementForIntegrityCheck;\n    StatementSelect m_statementForGetFTSTable;\n};\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/common/core/migration/AutoMigrateConfig.cpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/26\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"AutoMigrateConfig.hpp\"\n#include \"Assertion.hpp\"\n#include \"InnerHandle.hpp\"\n\nnamespace WCDB {\n\nAutoMigrateOperator::~AutoMigrateOperator() = default;\n\nAutoMigrateConfig::AutoMigrateConfig(const std::shared_ptr<AutoMigrateOperator>& operator_)\n: Config(), m_operator(operator_)\n{\n    WCTAssert(m_operator != nullptr);\n}\n\nAutoMigrateConfig::~AutoMigrateConfig() = default;\n\nbool AutoMigrateConfig::invoke(InnerHandle* handle)\n{\n    const UnsafeStringView& path = handle->getPath();\n    if (++getOrCreateRegister(path) == 1) {\n        m_operator->asyncMigrate(path);\n    }\n    return true;\n}\n\nbool AutoMigrateConfig::uninvoke(InnerHandle* handle)\n{\n    const UnsafeStringView& path = handle->getPath();\n    if (--getOrCreateRegister(path) == 0) {\n        m_operator->stopMigrate(path);\n    }\n    return true;\n}\n\nstd::atomic<int>& AutoMigrateConfig::getOrCreateRegister(const UnsafeStringView& path)\n{\n    {\n        SharedLockGuard lockGuard(m_lock);\n        auto iter = m_registers.find(path);\n        if (iter != m_registers.end()) {\n            WCTAssert(iter->second.load() >= 0);\n            return iter->second;\n        }\n    }\n    {\n        LockGuard lockGuard(m_lock);\n        auto iter = m_registers.find(path);\n        if (iter == m_registers.end()) {\n            m_registers[path] = 0;\n            iter = m_registers.find(path);\n        }\n        WCTAssert(iter->second.load() >= 0);\n        return iter->second;\n    }\n}\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/core/migration/AutoMigrateConfig.hpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/26\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"Config.hpp\"\n#include \"Lock.hpp\"\n#include \"StringView.hpp\"\n#include <map>\n#include <memory>\n\nnamespace WCDB {\n\nclass AutoMigrateOperator {\npublic:\n    virtual ~AutoMigrateOperator() = 0;\n    virtual void asyncMigrate(const UnsafeStringView &path) = 0;\n    virtual void stopMigrate(const UnsafeStringView &path) = 0;\n};\n\nclass AutoMigrateConfig final : public Config {\npublic:\n    AutoMigrateConfig(const std::shared_ptr<AutoMigrateOperator> &operator_);\n    ~AutoMigrateConfig() override;\n\n    bool invoke(InnerHandle *handle) override final;\n    bool uninvoke(InnerHandle *handle) override final;\n\nprotected:\n    std::shared_ptr<AutoMigrateOperator> m_operator;\n\n    std::atomic<int> &getOrCreateRegister(const UnsafeStringView &path);\n\nprivate:\n    SharedLock m_lock;\n    StringViewMap<std::atomic<int>> m_registers;\n};\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/common/core/migration/MigrateHandleOperator.cpp",
    "content": "//\n// Created by qiuwenchen on 2023/11/17.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"MigrateHandleOperator.hpp\"\n#include \"Assertion.hpp\"\n#include \"CoreConst.h\"\n#include \"Time.hpp\"\n#include <cmath>\n\nnamespace WCDB {\n\nMigrateHandleOperator::MigrateHandleOperator(InnerHandle* handle)\n: HandleOperator(handle)\n, m_migratingInfo(nullptr)\n, m_migrateStatement(handle->getStatement(DecoratorMigratingHandleStatement))\n, m_removeMigratedStatement(handle->getStatement(DecoratorMigratingHandleStatement))\n{\n}\n\nMigrateHandleOperator::~MigrateHandleOperator()\n{\n    finalizeMigrationStatement();\n    getHandle()->returnStatement(m_migrateStatement);\n    getHandle()->returnStatement(m_removeMigratedStatement);\n}\n\nvoid MigrateHandleOperator::onDecorationChange()\n{\n    finalizeMigrationStatement();\n\n    InnerHandle* handle = getHandle();\n\n    handle->returnStatement(m_migrateStatement);\n    m_migrateStatement = handle->getStatement(DecoratorMigratingHandleStatement);\n\n    handle->returnStatement(m_removeMigratedStatement);\n    m_removeMigratedStatement = handle->getStatement(DecoratorMigratingHandleStatement);\n}\n\nbool MigrateHandleOperator::reAttach(const MigrationBaseInfo* info)\n{\n    WCTAssert(!getHandle()->isInTransaction());\n    WCTAssert(!getHandle()->isPrepared());\n\n    bool succeed = true;\n    if (!m_attached.syntax().isTargetingSameSchema(\n        info->getSchemaForSourceDatabase().syntax())) {\n        succeed = detach() && attach(info);\n    }\n    m_migratingInfo = nullptr;\n    finalizeMigrationStatement();\n    return succeed;\n}\n\nbool MigrateHandleOperator::attach(const MigrationBaseInfo* info)\n{\n    WCTAssert(!getHandle()->isInTransaction());\n    WCTAssert(!getHandle()->isPrepared());\n    WCTAssert(m_attached.syntax().isMain());\n\n    const StatementAttach& attach = info->getStatementForAttachingSchema();\n    const Data& cipher = info->getSourceCipher();\n    HandleStatement handleStatement(getHandle());\n    bool succeed = handleStatement.prepare(attach);\n    if (succeed) {\n        if (!cipher.empty()) {\n            handleStatement.bindBLOB(cipher);\n        }\n        succeed = handleStatement.step();\n        handleStatement.finalize();\n    }\n    if (succeed) {\n        if (info->needRawSourceCipher()) {\n            info->setRawSourceCipher(\n            getHandle()->getRawCipherKey(info->getSchemaForSourceDatabase()));\n        }\n        m_attached = info->getSchemaForSourceDatabase();\n    }\n    return succeed;\n}\n\nbool MigrateHandleOperator::detach()\n{\n    WCTAssert(!getHandle()->isInTransaction());\n    WCTAssert(!getHandle()->isPrepared());\n\n    bool succeed = true;\n    if (!m_attached.syntax().isMain()) {\n        succeed = getHandle()->execute(WCDB::StatementDetach().detach(m_attached));\n        if (succeed) {\n            m_attached = Schema::main();\n        }\n    }\n    return succeed;\n}\n\n#pragma mark - Stepper\nOptional<StringViewSet> MigrateHandleOperator::getAllTables()\n{\n    Column name(\"name\");\n    Column type(\"type\");\n    StringView sqlitePattern\n    = StringView::formatted(\"%s%%\", Syntax::builtinTablePrefix.data());\n    StringView wcdbPattern\n    = StringView::formatted(\"%s%%\", Syntax::builtinWCDBTablePrefix.data());\n    return getHandle()->getValues(\n    StatementSelect()\n    .select(name)\n    .from(TableOrSubquery::master())\n    .where(type == \"table\" && name.notLike(sqlitePattern) && name.notLike(wcdbPattern)),\n    0);\n}\n\nbool MigrateHandleOperator::dropSourceTable(const MigrationInfo* info)\n{\n    WCTAssert(info != nullptr);\n    if (!reAttach(info)) {\n        return false;\n    }\n    m_migratingInfo = info;\n    InnerHandle* handle = getHandle();\n    if (!handle->prepare(m_migratingInfo->getStatementForSelectingAnyRowFromSourceTable())) {\n        return false;\n    }\n    if (!handle->step()) {\n        handle->finalize();\n        return false;\n    }\n    bool hasContent = !handle->done();\n    handle->finalize();\n    if (!hasContent) {\n        return handle->execute(m_migratingInfo->getStatementForDroppingSourceTable());\n    }\n    return true;\n}\n\nOptional<bool> MigrateHandleOperator::migrateRows(const MigrationInfo* info)\n{\n    WCTAssert(info != nullptr);\n    if (m_migratingInfo != info) {\n        if (!reAttach(info)) {\n            return NullOpt;\n        }\n        m_migratingInfo = info;\n    }\n\n    if (!m_migrateStatement->isPrepared()\n        && !m_migrateStatement->prepare(m_migratingInfo->getStatementForMigratingOneRow())) {\n        return NullOpt;\n    }\n\n    if (!m_removeMigratedStatement->isPrepared()\n        && !m_removeMigratedStatement->prepare(\n        m_migratingInfo->getStatementForDeletingMigratedOneRow())) {\n        return NullOpt;\n    }\n\n    Optional<bool> migrated;\n    if (getHandle()->runTransaction([&migrated, this](InnerHandle* handle) -> bool {\n            int migratedCount = 0;\n            do {\n                migrated = migrateRow();\n                migratedCount++;\n                if (handle->checkHasBusyRetry()) {\n                    handle->notifyError(\n                    Error::Code::Notice, \"\", \"Interrupt compression due to busy\");\n                    break;\n                } else if (migratedCount > MigrationBatchCount) {\n                    break;\n                }\n            } while (migrated.succeed() && !migrated.value());\n            return migrated.succeed();\n        })) {\n        WCTAssert(migrated.succeed());\n        return migrated;\n    }\n    return NullOpt;\n}\n\nOptional<bool> MigrateHandleOperator::migrateRow()\n{\n    WCTAssert(m_migrateStatement->isPrepared() && m_removeMigratedStatement->isPrepared());\n    WCTAssert(getHandle()->isInTransaction());\n    Optional<bool> migrated;\n    if (m_migrateStatement->step()) {\n        if (getHandle()->getChanges() != 0) {\n            if (m_removeMigratedStatement->step()) {\n                migrated = false;\n            }\n        } else {\n            migrated = true;\n        }\n    }\n    m_migrateStatement->reset();\n    m_removeMigratedStatement->reset();\n    return migrated;\n}\n\nvoid MigrateHandleOperator::finalizeMigrationStatement()\n{\n    m_migrateStatement->finalize();\n    m_removeMigratedStatement->finalize();\n}\n\n#pragma mark - Info Initializer\nbool MigrateHandleOperator::attachSourceDatabase(const MigrationUserInfo& userInfo)\n{\n    return reAttach(&userInfo);\n}\n\nInnerHandle* MigrateHandleOperator::getCurrentHandle() const\n{\n    return getHandle();\n}\n\nconst StringView& MigrateHandleOperator::getDatabasePath() const\n{\n    return getHandle()->getPath();\n}\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/common/core/migration/MigrateHandleOperator.hpp",
    "content": "//\n// Created by qiuwenchen on 2023/11/17.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"HandleOperator.hpp\"\n#include \"Migration.hpp\"\n#include <array>\n#include <set>\n\nnamespace WCDB {\n\n// Each step of migration should be as small as possible to avoid blocking user operations.\n// However, it's very wasteful for those resources(CPU, IO...) when the step is too small.\n// So stepper will try to migrate one by one until the count of dirty pages(to be written) is changed.\n// In addition, stepper can/will be interrupted when database is not idled.\nclass MigrateHandleOperator final : public HandleOperator, public Migration::Stepper {\npublic:\n    MigrateHandleOperator(InnerHandle* handle);\n    ~MigrateHandleOperator() override;\n\n    void onDecorationChange() override final;\n\n#pragma mark - Schema\nprotected:\n    bool reAttach(const MigrationBaseInfo* info);\n    bool attach(const MigrationBaseInfo* info);\n    bool detach();\n\nprivate:\n    Schema m_attached;\n\n#pragma mark - Stepper\nprotected:\n    Optional<StringViewSet> getAllTables() override final;\n    bool dropSourceTable(const MigrationInfo* info) override final;\n    Optional<bool> migrateRows(const MigrationInfo* info) override final;\n    Optional<bool> migrateRow();\n\n    bool reAttachMigrationInfo(const MigrationInfo* info);\n    void finalizeMigrationStatement();\n\nprivate:\n    const MigrationInfo* m_migratingInfo;\n    HandleStatement* m_migrateStatement;\n    HandleStatement* m_removeMigratedStatement;\n\n#pragma mark - Info Initializer\nprotected:\n    bool attachSourceDatabase(const MigrationUserInfo& userInfo) override final;\n    InnerHandle* getCurrentHandle() const override final;\n    const StringView& getDatabasePath() const override final;\n};\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/core/migration/MigratingHandleDecorator.cpp",
    "content": "//\n// Created by qiuwenchen on 2023/11/15.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"MigratingHandleDecorator.hpp\"\n#include \"CompressionConst.hpp\"\n#include \"MigratingStatementDecorator.hpp\"\n\nnamespace WCDB {\n\n#pragma mark - Basic\n\nMigratingHandleDecorator::MigratingHandleDecorator(Migration& migration)\n: HandleDecorator(), Migration::Binder(migration), m_createdNewViewInTransaction(false)\n{\n}\n\nMigratingHandleDecorator::~MigratingHandleDecorator() = default;\n\nvoid MigratingHandleDecorator::decorate(Decorative* handle)\n{\n    Super::decorate(handle);\n    WCDBSwizzleDecorativeFunction(handle, MigratingHandleDecorator, getColumns);\n    WCDBSwizzleDecorativeFunction(handle, MigratingHandleDecorator, addColumn);\n    WCDBSwizzleDecorativeFunction(handle, MigratingHandleDecorator, commitTransaction);\n    WCDBSwizzleDecorativeFunction(handle, MigratingHandleDecorator, rollbackTransaction);\n    WCDBSwizzleDecorativeFunction(handle, MigratingHandleDecorator, getStatement);\n    WCDBSwizzleDecorativeFunction(handle, MigratingHandleDecorator, finalizeStatements);\n}\n\n#pragma mark - Meta\n\nOptional<const MigrationInfo*>\nMigratingHandleDecorator::getBindingInfo(const UnsafeStringView& table)\n{\n    const MigrationInfo* boundInfo = getBoundInfo(table);\n    if (boundInfo != nullptr) {\n        return boundInfo;\n    }\n    Optional<const MigrationInfo*> result;\n\n    startBinding();\n\n    result = bindTable(table);\n\n    bool needBinding = result.valueOr(nullptr) != nullptr;\n\n    bool success = stopBinding(needBinding);\n    if (needBinding && !success) {\n        return Optional<const MigrationInfo*>();\n    }\n\n    return result;\n}\n\nOptional<StringViewSet>\nMigratingHandleDecorator::getColumns(const Schema& schema, const UnsafeStringView& table)\n{\n    auto ret = Super::getColumns(schema, table);\n    if (!ret.succeed()) {\n        return ret;\n    }\n    if (!schema.syntax().isMain()) {\n        return ret;\n    }\n\n    auto info = getBindingInfo(table);\n    if (!info.succeed()) {\n        return Optional<StringViewSet>();\n    }\n    if (info.value() == nullptr) {\n        return ret;\n    }\n    auto sourceColumns = Super::getColumns(\n    info.value()->getSchemaForSourceDatabase(), info.value()->getSourceTable());\n    if (!sourceColumns.succeed()) {\n        return NullOpt;\n    }\n    auto iterator = ret->begin();\n    while (iterator != ret->end()) {\n        if (sourceColumns->find(*iterator) == sourceColumns->end()) {\n            iterator = ret->erase(iterator);\n        } else {\n            iterator++;\n        }\n    }\n    return ret;\n}\n\nbool MigratingHandleDecorator::addColumn(const Schema& schema,\n                                         const UnsafeStringView& table,\n                                         const ColumnDef& column)\n{\n    if (!Super::addColumn(schema, table, column)) {\n        return false;\n    }\n\n    if (!schema.syntax().isMain()\n        || column.syntax().column.value().name.hasPrefix(CompressionColumnTypePrefix)) {\n        return true;\n    }\n\n    auto info = getBindingInfo(table);\n    if (!info.succeed()) {\n        return false;\n    }\n    if (info.value() == nullptr) {\n        return true;\n    }\n\n    return Super::addColumn(\n    info.value()->getSchemaForSourceDatabase(), info.value()->getSourceTable(), column);\n}\n\nbool MigratingHandleDecorator::rebindUnionView(const UnsafeStringView& table,\n                                               const Columns& columns)\n{\n    auto info = getBindingInfo(table);\n    if (!info.succeed()) {\n        return false;\n    }\n    if (info.value() == nullptr) {\n        return true;\n    }\n\n    return getHandle()->runTransactionIfNotInTransaction([&](InnerHandle* handle) {\n        HandleStatement handleStatement = HandleStatement(handle);\n        bool succeed = handleStatement.prepare(MigrationInfo::getStatementForDroppingUnionedView(\n                       info.value()->getUnionedView()))\n                       && handleStatement.step();\n        handleStatement.finalize();\n        if (!succeed) {\n            return false;\n        }\n        StatementCreateView createView\n        = info.value()->getStatementForCreatingUnionedView(columns);\n        succeed = handleStatement.prepare(createView) && handleStatement.step();\n        handleStatement.finalize();\n        return succeed;\n    });\n}\n\nbool MigratingHandleDecorator::checkSourceTable(const UnsafeStringView& table,\n                                                const UnsafeStringView& sourceTable)\n{\n    auto info = getBindingInfo(table);\n    if (!info.succeed()) {\n        return false;\n    }\n    if (info.value() == nullptr) {\n        return false;\n    }\n    return info.value()->getSourceTable().compare(sourceTable) == 0;\n}\n\nbool MigratingHandleDecorator::attachDatabase(const MigrationBaseInfo* attachInfo)\n{\n    const StatementAttach& attach = attachInfo->getStatementForAttachingSchema();\n    const Data& cipher = attachInfo->getSourceCipher();\n    HandleStatement handleStatement(getHandle());\n    bool succeed = handleStatement.prepare(attach);\n    if (succeed) {\n        if (!cipher.empty()) {\n            handleStatement.bindBLOB(cipher);\n        }\n        succeed = handleStatement.step();\n        handleStatement.finalize();\n    }\n    if (succeed && attachInfo->needRawSourceCipher()) {\n        attachInfo->setRawSourceCipher(\n        getHandle()->getRawCipherKey(attachInfo->getSchemaForSourceDatabase()));\n    }\n    return succeed;\n}\n\n#pragma mark - Info Initializer\nbool MigratingHandleDecorator::attachSourceDatabase(const MigrationUserInfo& userInfo)\n{\n    const Schema& schema = userInfo.getSchemaForSourceDatabase();\n    if (!schema.syntax().isMain()) {\n        auto optionalAttacheds = getHandle()->getValues(\n        MigrationInfo::getStatementForSelectingDatabaseList(), 1);\n        if (!optionalAttacheds.succeed()) {\n            return false;\n        }\n        StringViewSet& attacheds = optionalAttacheds.value();\n        if (attacheds.find(schema.getDescription()) == attacheds.end()) {\n            if (!attachDatabase(&userInfo) || !trySynchronousTransactionAfterAttached()) {\n                return false;\n            }\n        }\n    }\n    return true;\n}\n\nInnerHandle* MigratingHandleDecorator::getCurrentHandle() const\n{\n    return getHandle();\n}\n\nconst StringView& MigratingHandleDecorator::getDatabasePath() const\n{\n    return getHandle()->getPath();\n}\n\n#pragma mark - Binder\nbool MigratingHandleDecorator::rebindViews(const StringViewMap<const MigrationInfo*>& migratings)\n{\n    StringViewMap<const MigrationInfo*> views2MigratingInfos;\n    InnerHandle* handle = getHandle();\n    for (const auto& iter : migratings) {\n        const MigrationInfo* info = iter.second;\n        WCTAssert(info != nullptr);\n        views2MigratingInfos.emplace(info->getUnionedView(), info);\n    }\n\n    // get existing unioned views\n    auto exists = handle->tableExists(Schema::temp(), Syntax::masterTable);\n    if (!exists.succeed()) {\n        return false;\n    }\n    if (exists.value()) {\n        auto existingViews\n        = handle->getValues(MigrationInfo::getStatementForSelectingUnionedView(), 0);\n        if (!existingViews.succeed()) {\n            return false;\n        }\n\n        for (const auto& existingView : existingViews.value()) {\n            WCTAssert(existingView.hasPrefix(MigrationInfo::getUnionedViewPrefix()));\n            auto iter = views2MigratingInfos.find(existingView);\n            if (iter != views2MigratingInfos.end()) {\n                // it is already created\n                views2MigratingInfos.erase(iter);\n            } else {\n                // it is no longer needed\n                if (!handle->executeStatement(\n                    MigrationInfo::getStatementForDroppingUnionedView(existingView))) {\n                    return false;\n                }\n            }\n        }\n    }\n\n    bool hasNewView = false;\n    // create all needed views\n    for (const auto& iter : views2MigratingInfos) {\n        HandleStatement* statement = handle->getStatement(DecoratorMigratingHandleStatement);\n        bool ret = statement->prepare(iter.second->getStatementForCreatingUnionedView());\n        ret = ret && statement->step();\n        statement->finalize();\n        handle->returnStatement(statement);\n        if (!ret) {\n            return false;\n        }\n        hasNewView = true;\n    }\n    if (hasNewView && handle->isInTransaction()) {\n        m_createdNewViewInTransaction = true;\n    }\n    return true;\n}\n\nbool MigratingHandleDecorator::rebindSchemas(const StringViewMap<const MigrationInfo*>& migratings)\n{\n    StringViewMap<const MigrationInfo*> schemas2MigratingInfos;\n    for (const auto& iter : migratings) {\n        const MigrationInfo* info = iter.second;\n        WCTAssert(info != nullptr);\n        if (info->isCrossDatabase()) {\n            schemas2MigratingInfos.emplace(\n            info->getSchemaForSourceDatabase().getDescription(), info);\n        }\n    }\n\n    auto existingSchemas = getHandle()->getValues(\n    MigrationInfo::getStatementForSelectingDatabaseList(), 1);\n    if (!existingSchemas.succeed()) {\n        return false;\n    }\n\n    for (const auto& existingSchema : existingSchemas.value()) {\n        if (existingSchema.hasPrefix(MigrationDatabaseInfo::getSchemaPrefix())) {\n            auto iter = schemas2MigratingInfos.find(existingSchema);\n            if (iter != schemas2MigratingInfos.end()) {\n                // it is already attached\n                schemas2MigratingInfos.erase(iter);\n            } else {\n                if (!getHandle()->isInTransaction()) {\n                    // it is not longer needed\n                    if (!getHandle()->executeStatement(\n                        MigrationInfo::getStatementForDetachingSchema(existingSchema))) {\n                        return false;\n                    }\n                }\n            }\n        }\n    }\n    bool attached = false;\n    // attach all needed schemas\n    for (const auto& iter : schemas2MigratingInfos) {\n        if (!attachDatabase(iter.second)) {\n            return false;\n        }\n        attached = true;\n    }\n    if (attached) {\n        return trySynchronousTransactionAfterAttached();\n    }\n    return true;\n}\n\nbool MigratingHandleDecorator::commitTransaction()\n{\n    bool ret = Super::commitTransaction();\n    if (ret && !getHandle()->isInTransaction()) {\n        m_createdNewViewInTransaction = false;\n        setTableInfoCommitted(true);\n    }\n    return ret;\n}\n\nvoid MigratingHandleDecorator::rollbackTransaction()\n{\n    Super::rollbackTransaction();\n    if (m_createdNewViewInTransaction) {\n        setNeedRebind();\n        m_createdNewViewInTransaction = false;\n        setTableInfoCommitted(false);\n    }\n}\n\nbool MigratingHandleDecorator::bindInfos(const StringViewMap<const MigrationInfo*>& migratings)\n{\n    return rebindViews(migratings) && rebindSchemas(migratings);\n}\n\nbool MigratingHandleDecorator::trySynchronousTransactionAfterAttached()\n{\n    bool succeed = true;\n    if (getHandle()->isInTransaction()) {\n        getHandle()->markErrorAsIgnorable(Error::Code::Error);\n        static const StatementBegin* s_synchronousTransaction\n        = new StatementBegin(StatementBegin().beginImmediate());\n        succeed = getHandle()->executeStatement(*s_synchronousTransaction);\n        WCTAssert(!succeed);\n        if (!succeed && getHandle()->getError().isIgnorable()) {\n            succeed = true;\n        }\n        getHandle()->markErrorAsUnignorable();\n    }\n    return succeed;\n}\n\n#pragma mark - Statement\nDecorativeHandleStatement*\nMigratingHandleDecorator::getStatement(const UnsafeStringView& skipDecorator)\n{\n    DecorativeHandleStatement* statement = Super::getStatement(skipDecorator);\n    if (!statement->containDecorator(DecoratorMigratingHandleStatement)\n        && !skipDecorator.equal(DecoratorMigratingHandleStatement)\n        && !skipDecorator.equal(DecoratorAllType)) {\n        statement->tryAddDecorator<MigratingStatementDecorator>(\n        DecoratorMigratingHandleStatement, this);\n    }\n    return statement;\n}\n\nvoid MigratingHandleDecorator::finalizeStatements()\n{\n    Super::finalizeStatements();\n    stopReferenced();\n}\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/common/core/migration/MigratingHandleDecorator.hpp",
    "content": "//\n// Created by qiuwenchen on 2023/11/15.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"DecorativeHandle.hpp\"\n#include \"Migration.hpp\"\n\nnamespace WCDB {\n\nclass MigrationInfo;\n\nclass MigratingHandleDecorator : public HandleDecorator, public Migration::Binder {\nprivate:\n    using Super = HandleDecorator;\n#pragma mark - Initialize\npublic:\n    MigratingHandleDecorator(Migration &migration);\n    ~MigratingHandleDecorator() override;\n\n    void decorate(Decorative *handle) override final;\n\n#pragma mark - Meta\n    Optional<StringViewSet>\n    getColumns(const Schema &schema, const UnsafeStringView &table) override final;\n    bool addColumn(const Schema &schema,\n                   const UnsafeStringView &table,\n                   const ColumnDef &column) override final;\n    bool rebindUnionView(const UnsafeStringView &table, const Columns &columns);\n    bool checkSourceTable(const UnsafeStringView &table, const UnsafeStringView &sourceTable);\n    bool attachDatabase(const MigrationBaseInfo *attachInfo);\n\n#pragma mark - Binder\nprotected:\n    bool commitTransaction() override final;\n    void rollbackTransaction() override final;\n\n    bool bindInfos(const StringViewMap<const MigrationInfo *> &migratings) override final;\n    Optional<const MigrationInfo *> getBindingInfo(const UnsafeStringView &table);\n\nprivate:\n    bool rebindViews(const StringViewMap<const MigrationInfo *> &migratings);\n    bool rebindSchemas(const StringViewMap<const MigrationInfo *> &migratings);\n\n    bool trySynchronousTransactionAfterAttached();\n\n    bool m_createdNewViewInTransaction;\n\n#pragma mark - Info Initializer\nprotected:\n    bool attachSourceDatabase(const MigrationUserInfo &userInfo) override final;\n    InnerHandle *getCurrentHandle() const override final;\n    const StringView &getDatabasePath() const override final;\n\n#pragma mark - Statement\npublic:\n    DecorativeHandleStatement *\n    getStatement(const UnsafeStringView &skipDecorator) override final;\n    void finalizeStatements() override final;\n};\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/core/migration/MigratingStatementDecorator.cpp",
    "content": "//\n// Created by qiuwenchen on 2023/11/15.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"MigratingStatementDecorator.hpp\"\n#include \"Assertion.hpp\"\n#include \"CommonCore.hpp\"\n#include \"SQLite.h\"\n#include \"StringView.hpp\"\n#include \"WINQ.h\"\n\nnamespace WCDB {\n\n#pragma mark - Basic\nMigratingStatementDecorator::MigratingStatementDecorator(Migration::Binder* binder)\n: HandleStatementDecorator()\n, m_migrationBinder(binder)\n, m_processing(false)\n, m_currentStatementType(StatementType::Invalid)\n, m_migratingInfo(nullptr)\n, m_primaryKeyIndex(0)\n, m_rowidBindIndex(0)\n{\n}\n\nMigratingStatementDecorator::MigratingStatementDecorator(MigratingStatementDecorator&& other)\n: Super(std::move(other))\n, m_migrationBinder(other.m_migrationBinder)\n, m_processing(other.m_processing)\n, m_currentStatementType(other.m_currentStatementType)\n, m_additionalStatements(std::move(other.m_additionalStatements))\n, m_migratingInfo(other.m_migratingInfo)\n, m_assignedPrimaryKey(std::move(other.m_assignedPrimaryKey))\n, m_primaryKeyIndex(other.m_primaryKeyIndex)\n, m_rowidBindIndex(other.m_rowidBindIndex)\n{\n    other.m_migrationBinder = nullptr;\n    other.m_processing = false;\n    other.m_currentStatementType = StatementType::Invalid;\n    other.m_additionalStatements.clear();\n    other.m_migratingInfo = nullptr;\n    other.m_assignedPrimaryKey = NullOpt;\n    other.m_primaryKeyIndex = 0;\n    other.m_rowidBindIndex = 0;\n}\n\nMigratingStatementDecorator::~MigratingStatementDecorator() = default;\n\nvoid MigratingStatementDecorator::decorate(Decorative* handleStatement)\n{\n    Super::decorate(handleStatement);\n    WCDBSwizzleDecorativeFunction(handleStatement, MigratingStatementDecorator, prepare);\n    WCDBSwizzleDecorativeFunction(handleStatement, MigratingStatementDecorator, finalize);\n    WCDBSwizzleDecorativeFunction(handleStatement, MigratingStatementDecorator, step);\n    WCDBSwizzleDecorativeFunction(handleStatement, MigratingStatementDecorator, reset);\n    WCDBSwizzleDecorativeFunction(handleStatement, MigratingStatementDecorator, clearBindings);\n    WCDBSwizzleDecorativeFunction(handleStatement, MigratingStatementDecorator, bindInteger);\n    WCDBSwizzleDecorativeFunction(handleStatement, MigratingStatementDecorator, bindDouble);\n    WCDBSwizzleDecorativeFunction(handleStatement, MigratingStatementDecorator, bindText);\n    WCDBSwizzleDecorativeFunction(handleStatement, MigratingStatementDecorator, bindText16);\n    WCDBSwizzleDecorativeFunction(handleStatement, MigratingStatementDecorator, bindBLOB);\n    WCDBSwizzleDecorativeFunction(handleStatement, MigratingStatementDecorator, bindNull);\n    WCDBSwizzleDecorativeFunction(handleStatement, MigratingStatementDecorator, bindPointer);\n}\n\n#pragma mark - Migration\nOptional<std::list<Statement>>\nMigratingStatementDecorator::process(const Statement& originStatement)\n{\n    m_processing = true;\n    bool succeed = true;\n    std::list<Statement> statements;\n    do {\n        m_migrationBinder->startBinding();\n\n        // It's dangerous to use origin statement after tampering since all the tokens are not fit.\n        Statement falledBackStatement = originStatement;\n        // fallback\n        falledBackStatement.iterate([&succeed, this, &originStatement](\n                                    Syntax::Identifier& identifier, bool isBegin, bool& stop) {\n            if (!isBegin) {\n                return;\n            }\n            switch (identifier.getType()) {\n            case Syntax::Identifier::Type::TableOrSubquery: {\n                // main.table -> temp.unionedView\n                Syntax::TableOrSubquery& syntax = (Syntax::TableOrSubquery&) identifier;\n                if (syntax.switcher == Syntax::TableOrSubquery::Switch::Table) {\n                    succeed = tryFallbackToUnionedView(syntax.schema, syntax.tableOrFunction);\n                }\n            } break;\n            case Syntax::Identifier::Type::QualifiedTableName: {\n                // main.table -> schemaForSourceDatabase.sourceTable\n                Syntax::QualifiedTableName& syntax = (Syntax::QualifiedTableName&) identifier;\n                succeed = tryFallbackToSourceTable(syntax.schema, syntax.table);\n            } break;\n            case Syntax::Identifier::Type::InsertSTMT: {\n                // main.table -> schemaForSourceDatabase.sourceTable\n                Syntax::InsertSTMT& syntax = (Syntax::InsertSTMT&) identifier;\n                succeed = tryFallbackToSourceTable(syntax.schema, syntax.table);\n            } break;\n            case Syntax::Identifier::Type::DropTableSTMT: {\n                // main.table -> schemaForSourceDatabase.sourceTable\n                Syntax::DropTableSTMT& syntax = (Syntax::DropTableSTMT&) identifier;\n                succeed = tryFallbackToSourceTable(syntax.schema, syntax.table);\n            } break;\n            case Syntax::Identifier::Type::AlterTableSTMT: {\n                // main.table -> schemaForSourceDatabase.sourceTable\n                Syntax::AlterTableSTMT& syntax = (Syntax::AlterTableSTMT&) identifier;\n                succeed = tryFallbackToSourceTable(syntax.schema, syntax.table);\n            } break;\n            case Syntax::Identifier::Type::Expression: {\n                // main.table -> temp.unionedView\n                Syntax::Expression& syntax = (Syntax::Expression&) identifier;\n                switch (syntax.switcher) {\n                case Syntax::Expression::Switch::Column:\n                    succeed = tryFallbackToUnionedView(syntax.column().schema,\n                                                       syntax.column().table);\n                    break;\n                case Syntax::Expression::Switch::In:\n                    if (syntax.inSwitcher == Syntax::Expression::SwitchIn::Table) {\n                        succeed\n                        = tryFallbackToUnionedView(syntax.schema(), syntax.table());\n                    }\n                    break;\n                default:\n                    break;\n                }\n            } break;\n            case Syntax::Identifier::Type::CreateTableSTMT: {\n                Syntax::CreateTableSTMT& syntax = (Syntax::CreateTableSTMT&) identifier;\n                if (!m_migrationBinder->hintThatTableWillBeCreated(syntax.table)) {\n                    succeed = false;\n                }\n            } break;\n            case Syntax::Identifier::Type::BindParameter: {\n                Syntax::BindParameter& bindParameter = (Syntax::BindParameter&) identifier;\n                if (bindParameter.switcher != Syntax::BindParameter::Switch::QuestionSign) {\n                    getHandle()->notifyError(\n                    Error::Code::Misuse,\n                    originStatement.getDescription(),\n                    \"Only numeric bind parameters are allowed to used in the migrating database\");\n                    succeed = false;\n                } else if (bindParameter.n <= 0) {\n                    getHandle()->notifyError(\n                    (int) Error::Code::Misuse,\n                    originStatement.getDescription().data(),\n                    \"The indexes of bind parameters must be assigned in the migrating database\");\n                    succeed = false;\n                } else {\n                    m_rowidBindIndex = std::max(m_rowidBindIndex, bindParameter.n);\n                }\n            } break;\n            default:\n                break;\n            }\n            if (!succeed) {\n                stop = true;\n            }\n        });\n        succeed = m_migrationBinder->stopBinding(succeed);\n        if (!succeed) {\n            break;\n        }\n        m_rowidBindIndex++;\n\n        switch (originStatement.getType()) {\n        case Syntax::Identifier::Type::InsertSTMT: {\n            const Syntax::InsertSTMT& migratedInsertSTMT\n            = static_cast<const Syntax::InsertSTMT&>(originStatement.syntax());\n            const Syntax::InsertSTMT& falledBackSTMT\n            = static_cast<const Syntax::InsertSTMT&>(falledBackStatement.syntax());\n            if (migratedInsertSTMT.isTargetingSameTable(falledBackSTMT)) {\n                statements.push_back(falledBackStatement);\n            } else {\n                WCTRemedialAssert(!migratedInsertSTMT.columns.empty(),\n                                  \"Insert statement that does not explicitly indicate columns is not supported while using migration feature.\",\n                                  succeed = false;\n                                  break;);\n                WCTRemedialAssert(!migratedInsertSTMT.isMultiWrite(),\n                                  \"Insert statement that contains multiple values is not supported while using migration feature.\",\n                                  succeed = false;\n                                  break;);\n                clearMigrateStatus();\n                const MigrationInfo* info\n                = m_migrationBinder->getBoundInfo(migratedInsertSTMT.table);\n                WCTAssert(info != nullptr);\n                m_migratingInfo = info;\n                info->generateStatementsForInsertMigrating(\n                falledBackStatement, statements, m_primaryKeyIndex, m_rowidBindIndex, m_assignedPrimaryKey);\n                sqlite3_revertCommitOrder(getHandleStatement()->getRawHandle());\n            }\n        } break;\n        case Syntax::Identifier::Type::UpdateSTMT: {\n            const Syntax::QualifiedTableName& migratedTable\n            = static_cast<const Syntax::UpdateSTMT&>(originStatement.syntax()).table;\n            const Syntax::QualifiedTableName& falledBackTable\n            = static_cast<const Syntax::UpdateSTMT&>(falledBackStatement.syntax())\n              .table;\n            if (migratedTable.isTargetingToSameTable(falledBackTable)) {\n                statements.push_back(falledBackStatement);\n            } else {\n                const UnsafeStringView& migratedTableName = migratedTable.table;\n                const MigrationInfo* info\n                = m_migrationBinder->getBoundInfo(migratedTableName);\n                WCTAssert(info != nullptr);\n                info->generateStatementsForUpdateMigrating(\n                falledBackStatement, statements, m_rowidBindIndex);\n            }\n        } break;\n        case Syntax::Identifier::Type::DeleteSTMT: {\n            const Syntax::QualifiedTableName& migratedTable\n            = static_cast<const Syntax::DeleteSTMT&>(originStatement.syntax()).table;\n            const Syntax::QualifiedTableName& falledBackTable\n            = static_cast<const Syntax::DeleteSTMT&>(falledBackStatement.syntax())\n              .table;\n            if (migratedTable.isTargetingToSameTable(falledBackTable)) {\n                statements.push_back(falledBackStatement);\n            } else {\n                const UnsafeStringView& migratedTableName = migratedTable.table;\n                const MigrationInfo* info\n                = m_migrationBinder->getBoundInfo(migratedTableName);\n                WCTAssert(info != nullptr);\n                info->generateStatementsForDeleteMigrating(\n                falledBackStatement, statements, m_rowidBindIndex);\n            }\n        } break;\n        case Syntax::Identifier::Type::DropTableSTMT: {\n            const Syntax::DropTableSTMT& migratedSTMT\n            = static_cast<const Syntax::DropTableSTMT&>(originStatement.syntax());\n            const Syntax::DropTableSTMT& falledBackSTMT\n            = static_cast<const Syntax::DropTableSTMT&>(falledBackStatement.syntax());\n            statements.push_back(originStatement);\n            if (!migratedSTMT.isTargetingSameTable(falledBackSTMT)) {\n                // Don't drop source table. Instead, delete all contents from source table and wait the stepper do the dropping work.\n                Syntax::DropTableSTMT& stmt\n                = static_cast<Syntax::DropTableSTMT&>(statements.back().syntax());\n                stmt.schema = Schema::main();\n                const MigrationInfo* info\n                = m_migrationBinder->getBoundInfo(migratedSTMT.table);\n                WCTAssert(info != nullptr);\n                statements.push_back(info->getStatementForDeletingFromTable(falledBackStatement));\n            }\n        } break;\n        case Syntax::Identifier::Type::AlterTableSTMT: {\n            statements.push_back(falledBackStatement);\n            const Syntax::AlterTableSTMT& migratedSTMT\n            = static_cast<const Syntax::AlterTableSTMT&>(originStatement.syntax());\n            const Syntax::AlterTableSTMT& falledBackSTMT\n            = static_cast<const Syntax::AlterTableSTMT&>(falledBackStatement.syntax());\n            if (!migratedSTMT.isTargetingSameTable(falledBackSTMT)) {\n                statements.push_back(originStatement);\n                Syntax::AlterTableSTMT& stmt\n                = static_cast<Syntax::AlterTableSTMT&>(statements.back().syntax());\n                stmt.schema = Schema::main();\n            }\n        } break;\n        default:\n            statements.push_back(falledBackStatement);\n            break;\n        }\n    } while (false);\n    m_processing = false;\n    if (succeed) {\n        m_currentStatementType = originStatement.getType();\n        return std::move(statements);\n    } else {\n        return NullOpt;\n    }\n}\n\nbool MigratingStatementDecorator::tryFallbackToUnionedView(Syntax::Schema& schema,\n                                                           StringView& table)\n{\n    if (schema.isMain()) {\n        auto optionalInfo = m_migrationBinder->bindTable(table);\n        if (!optionalInfo.succeed()) {\n            return false;\n        }\n        const MigrationInfo* info = optionalInfo.value();\n        if (info != nullptr) {\n            schema = Schema::temp();\n            table = info->getUnionedView();\n        }\n    }\n    return true;\n}\n\nbool MigratingStatementDecorator::tryFallbackToSourceTable(Syntax::Schema& schema,\n                                                           StringView& table)\n{\n    if (schema.isMain()) {\n        auto optionalInfo = m_migrationBinder->bindTable(table);\n        if (!optionalInfo.succeed()) {\n            return false;\n        }\n        const MigrationInfo* info = optionalInfo.value();\n        if (info != nullptr) {\n            schema = info->getSchemaForSourceDatabase();\n            table = info->getSourceTable();\n        }\n    }\n    return true;\n}\n\n#pragma mark - Override\nbool MigratingStatementDecorator::prepare(const Statement& statement)\n{\n    WCTRemedialAssert(!getHandleStatement()->isPrepared(),\n                      \"Last statement is not finalized.\",\n                      finalize(););\n    WCTAssert(!m_processing);\n    auto optionalStatements = process(statement);\n    if (!optionalStatements.succeed()) {\n        return false;\n    }\n    auto& statements = optionalStatements.value();\n    WCTAssert(!statements.empty());\n    WCTAssert(m_additionalStatements.empty());\n    // The last statement must be targeted at the main scheme\n    if (!Super::prepare(statements.back())) {\n        return false;\n    }\n    statements.pop_back();\n    for (const auto& stmt : statements) {\n        m_additionalStatements.emplace_back(getHandle());\n        m_additionalStatements.back().enableAutoAddColumn();\n        if (!m_additionalStatements.back().prepare(stmt)) {\n            getHandleStatement()->finalize();\n            return false;\n        }\n    }\n    return true;\n}\n\nvoid MigratingStatementDecorator::finalize()\n{\n    Super::finalize();\n    for (auto& handleStatement : m_additionalStatements) {\n        handleStatement.finalize();\n    }\n    m_additionalStatements.clear();\n    m_currentStatementType = StatementType::Invalid;\n    m_rowidBindIndex = 0;\n    clearMigrateStatus();\n}\n\nbool MigratingStatementDecorator::step()\n{\n    if (m_additionalStatements.size() > 0) {\n        WCTAssert(dynamic_cast<InnerHandle*>(getHandle()) != nullptr);\n        InnerHandle* handle = static_cast<InnerHandle*>(getHandle());\n        return handle->runTransaction(\n        [this](InnerHandle*) -> bool { return realStep(); });\n    }\n    return realStep();\n}\n\nbool MigratingStatementDecorator::realStep()\n{\n    if (m_additionalStatements.empty()) {\n        return Super::step();\n    }\n    if (m_currentStatementType == StatementType::InsertSTMT) {\n        return stepInsert();\n    } else if (m_currentStatementType == StatementType::DeleteSTMT\n               || m_currentStatementType == StatementType::UpdateSTMT) {\n        return stepUpdateOrDelete();\n    } else {\n        for (auto& handleStatement : m_additionalStatements) {\n            if (!handleStatement.step()) {\n                return false;\n            }\n        }\n        return Super::step();\n    }\n}\n\nvoid MigratingStatementDecorator::reset()\n{\n    Super::reset();\n    for (auto& handleStatement : m_additionalStatements) {\n        handleStatement.reset();\n    }\n    if (m_primaryKeyIndex > 0) {\n        m_assignedPrimaryKey = NullOpt;\n    }\n}\n\nvoid MigratingStatementDecorator::clearBindings()\n{\n    Super::reset();\n    for (auto& handleStatement : m_additionalStatements) {\n        handleStatement.clearBindings();\n    }\n    if (m_primaryKeyIndex > 0) {\n        m_assignedPrimaryKey = NullOpt;\n    }\n}\n\nvoid MigratingStatementDecorator::bindInteger(const Integer& value, int index)\n{\n    WCTRemedialAssert(index != m_rowidBindIndex, \"Binding index is out of range\", return;);\n    for (auto& handleStatement : m_additionalStatements) {\n        if (handleStatement.getBindParameterCount() >= index) {\n            handleStatement.bindInteger(value, index);\n        }\n    }\n    if (getHandleStatement()->getBindParameterCount() >= index) {\n        Super::bindInteger(value, index);\n    }\n    if (m_currentStatementType == StatementType::InsertSTMT\n        && m_primaryKeyIndex > 0 && index == m_primaryKeyIndex) {\n        m_assignedPrimaryKey = value;\n    }\n}\n\nvoid MigratingStatementDecorator::bindDouble(const Float& value, int index)\n{\n    WCTRemedialAssert(index != m_rowidBindIndex, \"Binding index is out of range\", return;);\n    for (auto& handleStatement : m_additionalStatements) {\n        if (handleStatement.getBindParameterCount() >= index) {\n            handleStatement.bindDouble(value, index);\n        }\n    }\n    if (getHandleStatement()->getBindParameterCount() >= index) {\n        Super::bindDouble(value, index);\n    }\n}\n\nvoid MigratingStatementDecorator::bindText(const Text& value, int index)\n{\n    WCTRemedialAssert(index != m_rowidBindIndex, \"Binding index is out of range\", return;);\n    for (auto& handleStatement : m_additionalStatements) {\n        if (handleStatement.getBindParameterCount() >= index) {\n            handleStatement.bindText(value, index);\n        }\n    }\n    if (getHandleStatement()->getBindParameterCount() >= index) {\n        Super::bindText(value, index);\n    }\n}\n\nvoid MigratingStatementDecorator::bindText16(const char16_t* value, size_t valueLength, int index)\n{\n    WCTRemedialAssert(index != m_rowidBindIndex, \"Binding index is out of range\", return;);\n    for (auto& handleStatement : m_additionalStatements) {\n        if (handleStatement.getBindParameterCount() >= index) {\n            handleStatement.bindText16(value, valueLength, index);\n        }\n    }\n    if (getHandleStatement()->getBindParameterCount() >= index) {\n        Super::bindText16(value, valueLength, index);\n    }\n}\n\nvoid MigratingStatementDecorator::bindBLOB(const BLOB& value, int index)\n{\n    WCTRemedialAssert(index != m_rowidBindIndex, \"Binding index is out of range\", return;);\n    for (auto& handleStatement : m_additionalStatements) {\n        if (handleStatement.getBindParameterCount() >= index) {\n            handleStatement.bindBLOB(value, index);\n        }\n    }\n    if (getHandleStatement()->getBindParameterCount() >= index) {\n        Super::bindBLOB(value, index);\n    }\n}\n\nvoid MigratingStatementDecorator::bindNull(int index)\n{\n    WCTRemedialAssert(index != m_rowidBindIndex, \"Binding index is out of range\", return;);\n    for (auto& handleStatement : m_additionalStatements) {\n        if (handleStatement.getBindParameterCount() >= index) {\n            handleStatement.bindNull(index);\n        }\n    }\n    if (getHandleStatement()->getBindParameterCount() >= index) {\n        Super::bindNull(index);\n    }\n    if (m_currentStatementType == StatementType::InsertSTMT\n        && m_primaryKeyIndex > 0 && index == m_primaryKeyIndex) {\n        m_assignedPrimaryKey = NullOpt;\n    }\n}\n\nvoid MigratingStatementDecorator::bindPointer(void* ptr,\n                                              int index,\n                                              const Text& type,\n                                              void (*destructor)(void*))\n{\n    WCTRemedialAssert(index != m_rowidBindIndex, \"Binding index is out of range\", return;);\n    for (auto& handleStatement : m_additionalStatements) {\n        if (handleStatement.getBindParameterCount() >= index) {\n            handleStatement.bindPointer(ptr, index, type, destructor);\n        }\n    }\n    if (getHandleStatement()->getBindParameterCount() >= index) {\n        Super::bindPointer(ptr, index, type, destructor);\n    }\n}\n\n#pragma mark - Insert\nbool MigratingStatementDecorator::stepInsert()\n{\n    // Insert to source table\n    auto iter = m_additionalStatements.begin();\n    if (!iter->step()) {\n        return false;\n    }\n    // The content inserting to source table is ignored.\n    if (getHandle()->getChanges() == 0) {\n        return true;\n    }\n    iter++;\n    int64_t rowid = getHandle()->getLastInsertedRowID();\n    WCTAssert(m_additionalStatements.size() >= 2);\n\n    // Remove from source table\n    iter->bindInteger(rowid, 1);\n    if (!iter->step()) {\n        return false;\n    }\n    iter++;\n\n    // Insert to target table\n    WCTAssert(m_migratingInfo != nullptr);\n    if (m_migratingInfo->isAutoIncrement()) {\n        return Super::step();\n    }\n\n    int64_t maxId = 1;\n\n    if (!m_migratingInfo->getIntegerPrimaryKey().empty()) {\n        if (m_assignedPrimaryKey.hasValue()) {\n            maxId = m_assignedPrimaryKey.value();\n        } else {\n            WCTAssert(iter != m_additionalStatements.end());\n            if (!iter->step()) {\n                return false;\n            }\n            if (!iter->done()) {\n                maxId = std::max(maxId, iter->getInteger());\n            }\n        }\n    } else {\n        WCTAssert(iter != m_additionalStatements.end());\n        maxId = std::max(maxId, rowid);\n        if (!iter->step()) {\n            return false;\n        }\n        if (!iter->done()) {\n            maxId = std::max(maxId, iter->getInteger());\n        }\n    }\n    Super::bindInteger(maxId, m_rowidBindIndex);\n    if (!Super::step()) {\n        if (getHandle()->getError().code() == Error::Code::Constraint) {\n            Error error = Error(\n            Error::Code::Warning,\n            Error::Level::Warning,\n            StringView::formatted(\"UNIQUE constraint failed with id %d\", maxId));\n            Notifier::shared().notify(error);\n        }\n        return false;\n    }\n    return true;\n}\n\nvoid MigratingStatementDecorator::clearMigrateStatus()\n{\n    m_migratingInfo = nullptr;\n    m_assignedPrimaryKey = NullOpt;\n    m_primaryKeyIndex = 0;\n}\n\n#pragma mark - Update/Delete\nbool MigratingStatementDecorator::stepUpdateOrDelete()\n{\n    WCTAssert(m_additionalStatements.size() == 2);\n    auto iter = m_additionalStatements.begin();\n    HandleStatement& selectStatement = *iter;\n    if (!selectStatement.step()) {\n        return false;\n    }\n    iter++;\n    HandleStatement& sourceStatement = *iter;\n    while (!selectStatement.done()) {\n        int64_t rowid = selectStatement.getInteger();\n        sourceStatement.reset();\n        sourceStatement.bindInteger(rowid, m_rowidBindIndex);\n        if (!sourceStatement.step()) {\n            return false;\n        }\n        Super::reset();\n        Super::bindInteger(rowid, m_rowidBindIndex);\n        if (!Super::step()) {\n            return false;\n        }\n        if (!selectStatement.step()) {\n            return false;\n        }\n    }\n    return true;\n}\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/common/core/migration/MigratingStatementDecorator.hpp",
    "content": "//\n// Created by 陈秋文 on 2023/11/15.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"DecorativeHandleStatement.hpp\"\n#include \"Migration.hpp\"\n#include <list>\n\nnamespace WCDB {\n\nclass MigratingStatementDecorator final : public HandleStatementDecorator {\n#pragma mark - Basic\npublic:\n    MigratingStatementDecorator(Migration::Binder *binder);\n    MigratingStatementDecorator(MigratingStatementDecorator &&other);\n    ~MigratingStatementDecorator() override;\n\n    MigratingStatementDecorator() = delete;\n    MigratingStatementDecorator(const MigratingStatementDecorator &) = delete;\n    MigratingStatementDecorator &operator=(const MigratingStatementDecorator &) = delete;\n\n    void decorate(Decorative *handleStatement) override final;\n\nprotected:\n    using Super = HandleStatementDecorator;\n\nprivate:\n    Migration::Binder *m_migrationBinder;\n\n#pragma mark - Decorated functions\npublic:\n    bool prepare(const Statement &statement) override final;\n    void finalize() override final;\n    bool step() override final;\n    void reset() override final;\n    void clearBindings() override final;\n\n    void bindInteger(const Integer &value, int index) override final;\n    void bindDouble(const Float &value, int index) override final;\n    void bindText(const Text &value, int index) override final;\n    void bindText16(const char16_t *value, size_t valueLength, int index) override final;\n    void bindBLOB(const BLOB &value, int index) override final;\n    void bindNull(int index) override final;\n    void bindPointer(void *ptr, int index, const Text &type, void (*destructor)(void *)) override final;\n\n#pragma mark - Migration\nprotected:\n    bool realStep();\n    Optional<std::list<Statement>> process(const Statement &statement);\n    bool tryFallbackToUnionedView(Syntax::Schema &schema, StringView &table);\n    bool tryFallbackToSourceTable(Syntax::Schema &schema, StringView &table);\n    bool m_processing;\n\n    using StatementType = Syntax::Identifier::Type;\n    StatementType m_currentStatementType;\n    std::list<HandleStatement> m_additionalStatements;\n\n#pragma mark - Insert\nprotected:\n    bool stepInsert();\n    void clearMigrateStatus();\n\nprivate:\n    const MigrationInfo *m_migratingInfo;\n    Optional<int64_t> m_assignedPrimaryKey;\n    int m_primaryKeyIndex;\n    int m_rowidBindIndex;\n\n#pragma mark - Update/Delete\nprotected:\n    bool stepUpdateOrDelete();\n};\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/core/migration/Migration.cpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"Migration.hpp\"\n#include \"Assertion.hpp\"\n#include \"CompressionConst.hpp\"\n#include \"HandleStatement.hpp\"\n#include \"InnerHandle.hpp\"\n#include \"Notifier.hpp\"\n#include \"StringView.hpp\"\n#include \"WCDBError.hpp\"\n\nnamespace WCDB {\n\nMigrationEvent::~MigrationEvent() = default;\n\n#pragma mark - Initialize\nMigration::Migration(MigrationEvent* event)\n: m_tableAcquired(false), m_migrated(true), m_event(event)\n{\n}\n\nvoid Migration::addMigration(const UnsafeStringView& sourcePath,\n                             const UnsafeData& sourceCipher,\n                             const TableFilter& filter)\n{\n    LockGuard lockGuard(m_lock);\n    if (filter != nullptr) {\n        m_migrationInfo.insert_or_assign(\n        sourcePath,\n        std::make_shared<MigrationDatabaseInfo>(sourcePath, sourceCipher, filter));\n    } else {\n        m_migrationInfo.erase(sourcePath);\n    }\n    purge();\n}\n\nvoid Migration::purge()\n{\n    LockGuard lockGuard(m_lock);\n    m_migratings.clear();\n    m_dumpster.clear();\n    m_referenceds.clear();\n    m_holder.clear();\n    m_filted.clear();\n    m_hints.clear();\n    m_tableAcquired = false;\n    m_migrated = false;\n}\n\nbool Migration::shouldMigrate() const\n{\n    SharedLockGuard lockGuard(m_lock);\n    return !m_migrationInfo.empty();\n}\n\nStringViewSet Migration::getPathsOfSourceDatabases() const\n{\n    StringViewSet paths;\n    {\n        SharedLockGuard lockGuard(m_lock);\n        for (const auto& info : m_migrationInfo) {\n            if (info.second->isCrossDatabase()) {\n                paths.emplace(info.second->getSourceDatabase());\n            }\n        }\n    }\n    return paths;\n}\n\nbool Migration::initInfo(InfoInitializer& initializer, const UnsafeStringView& table)\n{\n    // do not migrate sqlite builtin table\n    if (table.hasPrefix(Syntax::builtinTablePrefix)\n        || table.hasPrefix(Syntax::builtinWCDBTablePrefix)) {\n        markAsNoNeedToMigrate(table);\n        return true;\n    }\n\n    StringView targetTable = StringView(table);\n\n    for (auto& info : m_migrationInfo) {\n        MigrationUserInfo userInfo = MigrationUserInfo(*info.second, targetTable);\n        info.second->getFilter()(userInfo);\n        if (!userInfo.shouldMigrate()) {\n            continue;\n        }\n\n        if (!initializer.attachSourceDatabase(userInfo)) {\n            return false;\n        }\n\n        auto exists = initializer.checkSourceTableExistsAndHasRowid(userInfo);\n        if (!exists.succeed()) {\n            return false;\n        }\n        if (!exists.value()) {\n            markAsNoNeedToMigrate(targetTable);\n            return true;\n        }\n\n        bool targetTableExsits = false;\n        bool autoincrement = false;\n        StringViewSet columns;\n        StringView integerPrimaryKey;\n        if (!initializer.getTargetTableInfo(\n            userInfo, targetTableExsits, columns, autoincrement, integerPrimaryKey)) {\n            return false;\n        }\n\n        LockGuard lockGuard(m_lock);\n        if (m_filted.find(targetTable) == m_filted.end()) {\n            m_migrated = false;\n            if (!targetTableExsits || columns.empty()) {\n                // it's not created\n                m_hints.emplace(targetTable);\n                m_tableAcquired = false;\n            } else {\n                m_holder.push_back(MigrationInfo(\n                userInfo, columns, autoincrement, integerPrimaryKey));\n                const MigrationInfo* hold = &m_holder.back();\n                m_migratings.emplace(hold);\n                m_referenceds.emplace(hold, 0);\n                m_filted.insert_or_assign(targetTable, hold);\n                m_hints.erase(targetTable);\n            }\n        }\n        return true;\n    }\n\n    markAsNoNeedToMigrate(targetTable);\n    return true;\n}\n\nvoid Migration::markAsNoNeedToMigrate(const UnsafeStringView& table)\n{\n    LockGuard lockGuard(m_lock);\n    if (m_filted.find(table) == m_filted.end()) {\n        m_filted.insert_or_assign(table, nullptr);\n    }\n    m_hints.erase(table);\n}\n\nbool Migration::hintThatTableWillBeCreated(InfoInitializer& initializer,\n                                           const UnsafeStringView& table)\n{\n    return initInfo(initializer, table);\n}\n\nvoid Migration::markAsUnreferenced(const MigrationInfo* info)\n{\n    LockGuard lockGuard(m_lock);\n    WCTAssert(info != nullptr);\n    WCTAssert(m_filted.find(info->getTable()) != m_filted.end());\n    WCTAssert(m_hints.find(info->getTable()) == m_hints.end());\n    WCTAssert(m_migratings.find(info) == m_migratings.end());\n    WCTAssert(m_referenceds.find(info) != m_referenceds.end());\n    WCTAssert(m_referenceds.find(info)->second == 0);\n    WCTAssert(m_dumpster.find(info) == m_dumpster.end());\n    m_referenceds.erase(info);\n    m_dumpster.emplace(info);\n}\n\nvoid Migration::markAsDropped(const MigrationInfo* info)\n{\n    LockGuard lockGuard(m_lock);\n    WCTAssert(info != nullptr);\n    WCTAssert(m_filted.find(info->getTable()) != m_filted.end());\n    WCTAssert(m_hints.find(info->getTable()) == m_hints.end());\n    WCTAssert(m_migratings.find(info) == m_migratings.end());\n    WCTAssert(m_referenceds.find(info) == m_referenceds.end());\n    WCTAssert(m_dumpster.find(info) != m_dumpster.end());\n    m_dumpster.erase(info);\n}\n\nvoid Migration::markAsMigrated(const MigrationInfo* info)\n{\n    LockGuard lockGuard(m_lock);\n    WCTAssert(info != nullptr);\n    WCTAssert(m_filted.find(info->getTable()) != m_filted.end());\n    WCTAssert(m_hints.find(info->getTable()) == m_hints.end());\n    WCTAssert(m_migratings.find(info) != m_migratings.end());\n    m_migratings.erase(info);\n    auto iter = m_referenceds.find(info);\n    WCTAssert(iter != m_referenceds.end());\n    if (iter->second == 0) {\n        markAsUnreferenced(info);\n    }\n}\n\nvoid Migration::retainInfo(const MigrationInfo* info)\n{\n    WCTAssert(info != nullptr);\n    LockGuard lockGuard(m_lock);\n    WCTAssert(m_filted.find(info->getTable()) != m_filted.end());\n    WCTAssert(m_hints.find(info->getTable()) == m_hints.end());\n    WCTAssert(m_migratings.find(info) != m_migratings.end());\n    WCTAssert(m_dumpster.find(info) == m_dumpster.end());\n    auto iter = m_referenceds.find(info);\n    WCTAssert(iter != m_referenceds.end());\n    ++iter->second;\n}\n\nvoid Migration::releaseInfo(const MigrationInfo* info)\n{\n    WCTAssert(info != nullptr);\n    LockGuard lockGuard(m_lock);\n    WCTAssert(m_filted.find(info->getTable()) != m_filted.end());\n    WCTAssert(m_hints.find(info->getTable()) == m_hints.end());\n    WCTAssert(m_dumpster.find(info) == m_dumpster.end());\n    auto iter = m_referenceds.find(info);\n    WCTAssert(iter != m_referenceds.end());\n    WCTAssert(iter->second > 0);\n    if (--iter->second == 0 && m_migratings.find(info) == m_migratings.end()) {\n        markAsUnreferenced(info);\n    }\n}\n\nOptional<RecyclableMigrationInfo> Migration::getInfo(const UnsafeStringView& table)\n{\n    LockGuard lockGuard(m_lock);\n    auto iter = m_filted.find(table);\n    if (iter != m_filted.end()) {\n        const MigrationInfo* info = iter->second;\n        if (m_migratings.find(info) != m_migratings.end()) {\n            retainInfo(info);\n            return RecyclableMigrationInfo(\n            info, std::bind(&Migration::releaseInfo, this, std::placeholders::_1));\n        }\n        return nullptr;\n    }\n    return NullOpt;\n}\n\n#pragma mark - Update sequence\nbool Migration::tryUpdateSequence(InfoInitializer& initializer, const MigrationInfo& info)\n{\n    if (!info.needUpdateSequance()) {\n        return true;\n    }\n    auto updated = initializer.tryUpdateSequence(info);\n    if (!updated.succeed()) {\n        return false;\n    }\n    info.setNeedUpdateSequence(false);\n    if (updated.value() && initializer.getCurrentHandle()->isInTransaction()) {\n        m_commitingInfos.getOrCreate().insert(&info);\n    }\n    return true;\n}\n\nvoid Migration::setTableInfoCommitted(bool committed)\n{\n    if (!committed) {\n        for (auto info : m_commitingInfos.getOrCreate()) {\n            info->setNeedUpdateSequence(true);\n        }\n    }\n    m_commitingInfos.getOrCreate().clear();\n}\n\n#pragma mark - InfoInitializer\nMigration::InfoInitializer::~InfoInitializer() = default;\n\nOptional<bool>\nMigration::InfoInitializer::checkSourceTableExistsAndHasRowid(const MigrationUserInfo& userInfo)\n{\n    const Schema& schema = userInfo.getSchemaForSourceDatabase();\n    const StringView& tableName = userInfo.getSourceTable();\n    InnerHandle* handle = getCurrentHandle();\n    WCTAssert(handle != nullptr);\n    Optional<bool> optionalExists = handle->tableExists(schema, tableName);\n    if (!optionalExists.hasValue() || !optionalExists.value()) {\n        return optionalExists;\n    }\n    auto tableConfig = handle->getTableAttribute(schema, tableName);\n    if (!tableConfig.succeed()) {\n        return NullOpt;\n    }\n    if (tableConfig.value().withoutRowid) {\n        StringView msg = StringView::formatted(\n        \"Does not support migrating data from the table without rowid: %s\",\n        tableName.data());\n        handle->notifyError(Error::Code::Misuse, nullptr, msg);\n        return NullOpt;\n    }\n    return optionalExists;\n}\n\nbool Migration::InfoInitializer::getTargetTableInfo(const MigrationUserInfo& userInfo,\n                                                    bool& exists,\n                                                    StringViewSet& columns,\n                                                    bool& autoincrement,\n                                                    StringView& integerPrimaryKey)\n{\n    const StringView& tableName = userInfo.getTable();\n    InnerHandle* handle = getCurrentHandle();\n    WCTAssert(handle != nullptr);\n    auto optionalExists = handle->tableExists(Schema::main(), tableName);\n    if (!optionalExists.hasValue()) {\n        return false;\n    }\n    exists = optionalExists.value();\n    if (!exists) {\n        return true;\n    }\n    auto optionalMetas = handle->getTableMeta(Schema::main(), userInfo.getTable());\n    if (!optionalMetas.succeed()) {\n        return false;\n    }\n    auto& metas = optionalMetas.value();\n    for (const auto& meta : metas) {\n        if (meta.name.hasPrefix(CompressionColumnTypePrefix)) {\n            continue;\n        }\n        columns.emplace(meta.name);\n    }\n    auto tableConfig = handle->getTableAttribute(Schema::main(), tableName);\n    if (!tableConfig.succeed()) {\n        return false;\n    }\n    if (tableConfig.value().withoutRowid) {\n        StringView msg = StringView::formatted(\n        \"Does not support migrating data to the table without rowid: %s\",\n        tableName.data());\n        handle->notifyError(Error::Code::Misuse, nullptr, msg);\n        return false;\n    }\n    autoincrement = tableConfig.value().autoincrement;\n    integerPrimaryKey = tableConfig.value().integerPrimaryKey;\n    return true;\n}\n\nOptional<bool> Migration::InfoInitializer::tryUpdateSequence(const MigrationInfo& info)\n{\n    const StringView& targetTable = info.getTable();\n    InnerHandle* handle = getCurrentHandle();\n    Column name(\"name\");\n    auto sequenceTable = TableOrSubquery(Syntax::sequenceTable).schema(Schema::main());\n    auto selectTable\n    = StatementSelect().select(name).from(sequenceTable).where(name == targetTable);\n    auto tableNames = handle->getValues(selectTable, 1);\n    if (!tableNames.hasValue()) {\n        if (handle->getError().getMessage().compare(\"no such table: main.sqlite_sequence\") == 0) {\n            bool ret = handle->execute(\n            StatementPragma().pragma(Pragma::writableSchema()).to(true));\n            StatementCreateTable createSeq\n            = StatementCreateTable().createTable(Syntax::sequenceTable).ifNotExists();\n            createSeq.define(ColumnDef(\"name\"));\n            createSeq.define(ColumnDef(\"seq\"));\n            ret = ret && handle->execute(createSeq);\n            ret = ret\n                  && handle->execute(\n                  StatementPragma().pragma(Pragma::writableSchema()).to(false));\n            if (!ret) {\n                return NullOpt;\n            }\n            tableNames = StringViewSet();\n        } else {\n            return NullOpt;\n        }\n    }\n    if (tableNames.value().size() > 0) {\n        return false;\n    }\n    bool ret = handle->runTransactionIfNotInTransaction([&](InnerHandle* handle) {\n        auto tableNames = handle->getValues(selectTable, 1);\n        if (!tableNames.hasValue()) {\n            return false;\n        }\n        if (tableNames.value().size() > 0) {\n            return true;\n        }\n        const StringView& sourceTable = info.getSourceTable();\n        const Schema& sourceSchema = info.getSchemaForSourceDatabase();\n        auto selectMaxPrimaryKey\n        = StatementSelect()\n          .select(Column(info.getIntegerPrimaryKey()).max())\n          .from(TableOrSubquery(sourceTable).schema(sourceSchema));\n        HandleStatement handleStatement(handle);\n        if (!handleStatement.prepare(selectMaxPrimaryKey)) {\n            return false;\n        }\n        if (!handleStatement.step()) {\n            handleStatement.finalize();\n            return false;\n        }\n        int64_t seq = 0;\n        if (!handleStatement.done()) {\n            seq = handleStatement.getInteger();\n        }\n        handleStatement.finalize();\n        auto insertSeq = StatementInsert()\n                         .insertIntoTable(Syntax::sequenceTable)\n                         .schema(Schema::main())\n                         .values({ targetTable, seq });\n        if (!handleStatement.prepare(insertSeq)) {\n            return false;\n        }\n        bool ret = handleStatement.step();\n        handleStatement.finalize();\n        return ret;\n    });\n    if (!ret) {\n        return NullOpt;\n    }\n    return true;\n}\n\n#pragma mark - Bind\nMigration::Binder::Binder(Migration& migration)\n: m_migration(migration), m_binding(false), m_rebind(false)\n{\n}\n\nMigration::Binder::~Binder() = default;\n\nvoid Migration::Binder::startBinding()\n{\n    WCTAssert(m_binding == false);\n    m_binding = true;\n}\n\nbool Migration::Binder::stopBinding(bool succeed)\n{\n    WCTAssert(m_binding);\n    if (succeed) {\n        m_migration.tryReduceBounds(m_bindings);\n        for (const auto& iter : m_referenceds) {\n            if (iter.second != nullptr) {\n                m_bindings.emplace(iter.first, iter.second.get());\n            }\n        }\n\n        if (m_rebind || m_bounds != m_bindings) {\n            succeed = bindInfos(m_bindings);\n            if (succeed) {\n                m_rebind = false;\n                m_bounds = m_bindings;\n            } else {\n                m_rebind = true;\n            }\n        } else {\n            succeed = true;\n        }\n    }\n    m_binding = false;\n    return succeed;\n}\n\nvoid Migration::Binder::setNeedRebind()\n{\n    m_bounds.clear();\n    m_rebind = true;\n}\n\nvoid Migration::Binder::stopReferenced()\n{\n    m_referenceds.clear();\n}\n\nOptional<const MigrationInfo*> Migration::Binder::bindTable(const UnsafeStringView& table)\n{\n    WCTAssert(m_binding);\n    Optional<const MigrationInfo*> info = (MigrationInfo*) nullptr;\n    if (!table.empty()) {\n        auto optionalReferencedInfo = m_migration.getOrInitInfo(*this, table);\n        if (optionalReferencedInfo.succeed()) {\n            auto& referencedInfo = optionalReferencedInfo.value();\n            m_referenceds.insert_or_assign(table, referencedInfo);\n            info = referencedInfo.get();\n        }\n    }\n    return info;\n}\n\nbool Migration::Binder::hintThatTableWillBeCreated(const UnsafeStringView& table)\n{\n    return m_migration.hintThatTableWillBeCreated(*this, table);\n}\n\nconst MigrationInfo* Migration::Binder::getBoundInfo(const UnsafeStringView& table)\n{\n    WCTAssert(m_binding == false);\n    const MigrationInfo* info = nullptr;\n    auto iter = m_bounds.find(table);\n    if (iter != m_bounds.end()) {\n        info = iter->second;\n    }\n    return info;\n}\n\nvoid Migration::Binder::setTableInfoCommitted(bool committed)\n{\n    m_migration.setTableInfoCommitted(committed);\n}\n\nOptional<RecyclableMigrationInfo>\nMigration::getOrInitInfo(InfoInitializer& initializer, const UnsafeStringView& table)\n{\n    auto info = getInfo(table);\n    if (!info.succeed() && initInfo(initializer, table)) {\n        info = getInfo(table);\n    }\n    if (info.valueOr(nullptr) != nullptr\n        && !tryUpdateSequence(initializer, *(info.value().get()))) {\n        return NullOpt;\n    }\n    return info;\n}\n\nvoid Migration::tryReduceBounds(StringViewMap<const MigrationInfo*>& bounds)\n{\n    bool reduce = false;\n    {\n        SharedLockGuard lockGuard(m_lock);\n        for (const auto& iter : bounds) {\n            if (m_migratings.find(iter.second) == m_migratings.end()) {\n                reduce = true;\n                break;\n            }\n        }\n    }\n    if (reduce) {\n        LockGuard lockGuard(m_lock);\n        for (auto iter = bounds.begin(); iter != bounds.end();) {\n            const MigrationInfo* info = iter->second;\n            if (m_migratings.find(info) == m_migratings.end()) {\n                iter = bounds.erase(iter);\n            } else {\n                ++iter;\n            }\n        }\n    }\n}\n\n#pragma mark - Step\nMigration::Stepper::~Stepper() = default;\n\nOptional<bool> Migration::step(Migration::Stepper& stepper)\n{\n    auto worked = tryDropUnreferencedTable(stepper);\n    if (!worked.succeed()) {\n        return NullOpt;\n    }\n    if (worked.value()) {\n        return false;\n    }\n    worked = tryMigrateRows(stepper);\n    if (!worked.succeed()) {\n        return NullOpt;\n    }\n    if (worked.value()) {\n        return false;\n    }\n    // acquire table is a readonly operation.\n    // retry if and only if it works.\n    worked = tryAcquireTables(stepper);\n    if (!worked.succeed()) {\n        return NullOpt;\n    }\n    if (worked.value()) {\n        return step(stepper);\n    }\n    WCTAssert(worked.succeed());\n    WCTAssert(!worked.value());\n\n    {\n        SharedLockGuard lockGuard(m_lock);\n        WCTAssert(m_tableAcquired);\n        if (!m_dumpster.empty() || !m_migratings.empty() || !m_referenceds.empty()) {\n            // wait until all tables unreferenced\n            return false;\n        }\n    }\n    LockGuard lockGuard(m_lock);\n    WCTAssert(m_tableAcquired);\n    WCTAssert(m_dumpster.empty());\n    WCTAssert(m_migratings.empty());\n    WCTAssert(m_referenceds.empty());\n    WCTAssert(m_hints.empty());\n    m_migrated = true;\n    if (m_event != nullptr) {\n        m_event->didMigrate(nullptr);\n    }\n    return true;\n}\n\nOptional<bool> Migration::tryDropUnreferencedTable(Migration::Stepper& stepper)\n{\n    const MigrationInfo* info = nullptr;\n    {\n        SharedLockGuard lockGuard(m_lock);\n        if (!m_dumpster.empty()) {\n            info = *m_dumpster.begin();\n            WCTAssert(info != nullptr);\n        }\n    }\n    Optional<bool> worked = false;\n    if (info != nullptr) {\n        if (stepper.dropSourceTable(info)) {\n            worked = true;\n            markAsDropped(info);\n\n            // table migrated\n            SharedLockGuard lockGuard(m_lock);\n            WCTAssert(m_migratings.find(info) == m_migratings.end());\n            WCTAssert(m_referenceds.find(info) == m_referenceds.end());\n            WCTAssert(m_dumpster.find(info) == m_dumpster.end());\n            if (m_event != nullptr) {\n                m_event->didMigrate(info);\n            }\n        } else {\n            worked = NullOpt;\n        }\n    }\n    return worked;\n}\n\nOptional<bool> Migration::tryMigrateRows(Migration::Stepper& stepper)\n{\n    const MigrationInfo* info = nullptr;\n    {\n        SharedLockGuard lockGuard(m_lock);\n        if (m_migratings.empty()) {\n            return false;\n        }\n        for (const auto& migrating : m_migratings) {\n            if (migrating->isCrossDatabase()) {\n                // cross database migration first to reduce additional database lock.\n                info = migrating;\n                break;\n            }\n        }\n        if (info == nullptr) {\n            info = *m_migratings.begin();\n        }\n    }\n    WCTAssert(info != nullptr);\n    InnerHandle* handle = stepper.getCurrentHandle();\n    WCTAssert(handle != nullptr);\n    auto exists = handle->tableExists(info->getTable());\n    if (!exists.succeed()) {\n        return NullOpt;\n    }\n\n    if (!exists.value()) {\n        markAsMigrated(info);\n        return true;\n    }\n\n    if (!tryUpdateSequence(stepper, *info)) {\n        return NullOpt;\n    }\n\n    auto migrated = stepper.migrateRows(info);\n    if (migrated.failed()) {\n        return NullOpt;\n    }\n    if (migrated.succeed() && migrated.value()) {\n        markAsMigrated(info);\n    }\n    return true;\n}\n\nOptional<bool> Migration::tryAcquireTables(Migration::Stepper& stepper)\n{\n    {\n        SharedLockGuard lockGuard(m_lock);\n        if (m_tableAcquired) {\n            return false;\n        }\n    }\n    auto optionalTables = stepper.getAllTables();\n    if (!optionalTables.succeed()) {\n        return NullOpt;\n    }\n    StringViewSet& tables = optionalTables.value();\n    tables.insert(m_hints.begin(), m_hints.end());\n    for (const auto& table : tables) {\n        WCTAssert(!table.hasPrefix(Syntax::builtinTablePrefix)\n                  && !table.hasPrefix(Syntax::builtinWCDBTablePrefix));\n        if (!initInfo(stepper, table)) {\n            return NullOpt;\n        }\n    }\n    LockGuard lockGuard(m_lock);\n    m_tableAcquired = true;\n    return true;\n}\n\n#pragma mark - Event\nbool Migration::isMigrated() const\n{\n    SharedLockGuard lockGuard(m_lock);\n    return m_migrated;\n}\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/core/migration/Migration.hpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"Lock.hpp\"\n#include \"MigrationInfo.hpp\"\n#include \"Recyclable.hpp\"\n#include \"ThreadLocal.hpp\"\n#include \"WCDBOptional.hpp\"\n#include <functional>\n#include <map>\n#include <set>\n\nnamespace WCDB {\n\ntypedef Recyclable<const MigrationInfo*> RecyclableMigrationInfo;\nclass InnerHandle;\n\nclass MigrationEvent {\npublic:\n    virtual ~MigrationEvent() = 0;\n\nprotected:\n    friend class Migration;\n    // parameter will be nullptr when all tables migrated.\n    virtual void didMigrate(const MigrationBaseInfo* info) = 0;\n};\n\n// TODO: deny if user visiting source table by using authorize feature.\nclass Migration final {\n#pragma mark - Initialize\npublic:\n    Migration(MigrationEvent* event);\n\n    using TableFilter = MigrationDatabaseInfo::TableFilter;\n    // addMigration should be called at the very beginning.\n    void addMigration(const UnsafeStringView& sourcePath,\n                      const UnsafeData& sourceCipher,\n                      const TableFilter& filter);\n\n    bool shouldMigrate() const;\n\n    void purge();\n\n    StringViewSet getPathsOfSourceDatabases() const;\n\nprotected:\n    class InfoInitializer {\n        friend class Migration;\n\n    public:\n        virtual ~InfoInitializer() = 0;\n\n    protected:\n        virtual bool attachSourceDatabase(const MigrationUserInfo& userInfo) = 0;\n        virtual InnerHandle* getCurrentHandle() const = 0;\n        virtual const StringView& getDatabasePath() const = 0;\n\n        Optional<bool> checkSourceTableExistsAndHasRowid(const MigrationUserInfo& userInfo);\n        bool getTargetTableInfo(const MigrationUserInfo& userInfo,\n                                bool& exists,\n                                StringViewSet& columns,\n                                bool& autoincrement,\n                                StringView& integerPrimaryKey);\n        Optional<bool> tryUpdateSequence(const MigrationInfo& info);\n    };\n\n    bool initInfo(InfoInitializer& initializer, const UnsafeStringView& table);\n    bool hintThatTableWillBeCreated(InfoInitializer& initializer,\n                                    const UnsafeStringView& table);\n    void markAsNoNeedToMigrate(const UnsafeStringView& table);\n\n    void markAsUnreferenced(const MigrationInfo* info);\n    void markAsDropped(const MigrationInfo* info);\n    void markAsMigrated(const MigrationInfo* info);\n    Optional<RecyclableMigrationInfo> getInfo(const UnsafeStringView& table);\n\nprivate:\n    // Those infos needed to be migrate will be held by m_migrating after initialized. (Other infos that already migrated or have no need to migrate will be dropped when initializing.)\n    // And when all the columns inside source table is migrated, the info will not be dropped immedially but removed from m_migratings. The reason is that there might be some handles still holding it. At the same time, the source table will not be dropped too.\n    // Until there is really no one holding them, it will be moved to dumpster and wait to be dropped.\n    // During these routine, info will not be erased from holder to avoid memory issue.\n    //        ┌──────┐                                ┌────────┐\n    // ┌────┐ │Inited│  ┌───────────────────────────┐ │Migrated│ ┌─────────────┐\n    // │Info│─┴──────┴─▶│m_migratings, m_referenceds│─┴────────┴▶│m_referenceds│─▶\n    // └────┘           └───────────────────────────┘            └─────────────┘\n    //    ┌──────────────────┐              ┌───────┐\n    //    │Until Unreferenced│ ┌──────────┐ │Dropped│ ┌───────┐\n    //  ──┴──────────────────┴▶│m_dumpster│─┴───────┴▶│Removed│\n    //                         └──────────┘           └───────┘\n    std::set<const MigrationInfo*> m_migratings;\n    std::set<const MigrationInfo*> m_dumpster;\n\n    std::map<const MigrationInfo*, int> m_referenceds;\n    std::list<MigrationInfo> m_holder;\n    StringViewMap<const MigrationInfo*> m_filted;\n    StringViewSet m_hints;\n\n    void retainInfo(const MigrationInfo* info);\n    void releaseInfo(const MigrationInfo* info);\n\n    mutable SharedLock m_lock;\n\n    StringViewMap<std::shared_ptr<MigrationDatabaseInfo>> m_migrationInfo;\n\n#pragma mark - Update sequence\npublic:\n    bool tryUpdateSequence(InfoInitializer& initializer, const MigrationInfo& info);\n    void setTableInfoCommitted(bool committed);\n\nprotected:\n    ThreadLocal<std::set<const MigrationInfo*>> m_commitingInfos;\n\n#pragma mark - Bind\npublic:\n    class Binder : public InfoInitializer {\n        friend class Migration;\n\n    public:\n        Binder(Migration& migration);\n        virtual ~Binder() override = 0;\n\n        void startBinding();\n        bool stopBinding(bool succeed);\n        void stopReferenced();\n        void setNeedRebind();\n\n        Optional<const MigrationInfo*> bindTable(const UnsafeStringView& table);\n        bool hintThatTableWillBeCreated(const UnsafeStringView& table);\n        const MigrationInfo* getBoundInfo(const UnsafeStringView& table);\n\n        virtual bool bindInfos(const StringViewMap<const MigrationInfo*>& infos) = 0;\n\n        void setTableInfoCommitted(bool committed);\n\n    private:\n        Migration& m_migration;\n        bool m_binding;\n        StringViewMap<RecyclableMigrationInfo> m_referenceds; // all infos need to be bound during this cycle\n        StringViewMap<const MigrationInfo*> m_bindings;\n        StringViewMap<const MigrationInfo*> m_bounds;\n        bool m_rebind;\n    };\n\nprotected:\n    Optional<RecyclableMigrationInfo>\n    getOrInitInfo(InfoInitializer& initializer, const UnsafeStringView& table);\n    void tryReduceBounds(StringViewMap<const MigrationInfo*>& bounds);\n\nprivate:\n#pragma mark - Step\npublic:\n    class Stepper : public InfoInitializer {\n        friend class Migration;\n\n    public:\n        virtual ~Stepper() override = 0;\n\n    protected:\n        virtual Optional<StringViewSet> getAllTables() = 0;\n        virtual bool dropSourceTable(const MigrationInfo* info) = 0;\n        virtual Optional<bool> migrateRows(const MigrationInfo* info) = 0;\n    };\n\n    // done\n    Optional<bool> step(Migration::Stepper& stepper);\n\nprotected:\n    // worked\n    Optional<bool> tryDropUnreferencedTable(Migration::Stepper& stepper);\n    Optional<bool> tryMigrateRows(Migration::Stepper& stepper);\n    Optional<bool> tryAcquireTables(Migration::Stepper& stepper);\n\nprivate:\n    bool m_tableAcquired;\n    bool m_migrated;\n\n#pragma mark - Event\npublic:\n    bool isMigrated() const;\n\nprotected:\n    MigrationEvent* m_event;\n};\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/core/migration/MigrationInfo.cpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"MigrationInfo.hpp\"\n#include \"Assertion.hpp\"\n#include \"StringView.hpp\"\n\nnamespace WCDB {\n\nconst char* MigrationDatabaseInfo::getSchemaPrefix()\n{\n    static const char* s_schemaPrefix = \"wcdb_migration_\";\n    return s_schemaPrefix;\n}\n\n#pragma mark - MigrationDatabaseInfo\nMigrationDatabaseInfo::MigrationDatabaseInfo(const UnsafeStringView& path,\n                                             const UnsafeData& cipher,\n                                             const TableFilter& filter)\n: m_sourcePath(path)\n, m_cipher(cipher)\n, m_filter(filter)\n, m_needRawCipher(!cipher.empty())\n{\n    if (!m_sourcePath.empty()) {\n        std::ostringstream stream;\n        stream << getSchemaPrefix() << m_sourcePath.hash();\n        m_schema = stream.str();\n        m_statementForAttachingSchema = StatementAttach().attach(m_sourcePath).as(m_schema);\n        if (!cipher.empty()) {\n            m_statementForAttachingSchema.key(BindParameter(1));\n        }\n    } else {\n        m_schema = Schema::main();\n    }\n}\n\nbool MigrationDatabaseInfo::isCrossDatabase() const\n{\n    return !m_sourcePath.empty();\n}\n\nconst StringView& MigrationDatabaseInfo::getSourceDatabase() const\n{\n    return m_sourcePath;\n}\n\nData MigrationDatabaseInfo::getCipher() const\n{\n    SharedLockGuard lockGoard(m_lock);\n    return m_cipher;\n}\n\nvoid MigrationDatabaseInfo::setRawCipher(const UnsafeData& rawCipher) const\n{\n    LockGuard lockGuard(m_lock);\n    m_cipher = rawCipher;\n    m_needRawCipher = false;\n}\n\nbool MigrationDatabaseInfo::needRawCipher() const\n{\n    return m_needRawCipher;\n}\n\nconst MigrationDatabaseInfo::TableFilter& MigrationDatabaseInfo::getFilter() const\n{\n    return m_filter;\n}\n\nconst Schema& MigrationDatabaseInfo::getSchemaForSourceDatabase() const\n{\n    return m_schema;\n}\n\nconst StatementAttach& MigrationDatabaseInfo::getStatementForAttachingSchema() const\n{\n    return m_statementForAttachingSchema;\n}\n\n#pragma mark - MigrationBaseInfo\nMigrationBaseInfo::MigrationBaseInfo(MigrationDatabaseInfo& databaseInfo,\n                                     const UnsafeStringView& table)\n: m_databaseInfo(databaseInfo), m_table(table)\n{\n    WCTAssert(!m_table.empty());\n}\n\nMigrationBaseInfo::~MigrationBaseInfo() = default;\n\nconst StringView& MigrationBaseInfo::getTable() const\n{\n    return m_table;\n}\n\nconst StringView& MigrationBaseInfo::getSourceTable() const\n{\n    return m_sourceTable;\n}\n\nconst Expression& MigrationBaseInfo::getFilterCondition() const\n{\n    return m_filterCondition;\n}\n\nconst Schema& MigrationBaseInfo::getSchemaForSourceDatabase() const\n{\n    return m_databaseInfo.getSchemaForSourceDatabase();\n}\n\nconst StatementAttach& MigrationBaseInfo::getStatementForAttachingSchema() const\n{\n    return m_databaseInfo.getStatementForAttachingSchema();\n}\n\nvoid MigrationBaseInfo::setSource(const UnsafeStringView& table)\n{\n    WCTRemedialAssert(!table.empty() && (table != m_table || isCrossDatabase()),\n                      \"Invalid migration source.\",\n                      return;);\n    m_sourceTable = table;\n}\n\nvoid MigrationBaseInfo::setFilter(Expression filterCondition)\n{\n    filterCondition.iterate([this](Syntax::Identifier& identifier, bool isBegin, bool&) {\n        if (!isBegin) {\n            return;\n        }\n        switch (identifier.getType()) {\n        case Syntax::Identifier::Type::TableOrSubquery: {\n            // main.table -> temp.unionedView\n            Syntax::TableOrSubquery& syntax = (Syntax::TableOrSubquery&) identifier;\n            if (syntax.switcher == Syntax::TableOrSubquery::Switch::Table) {\n                tryFallbackToSourceTable(syntax.schema, syntax.tableOrFunction);\n            }\n        } break;\n        case Syntax::Identifier::Type::QualifiedTableName: {\n            // main.table -> schemaForSourceDatabase.sourceTable\n            Syntax::QualifiedTableName& syntax = (Syntax::QualifiedTableName&) identifier;\n            tryFallbackToSourceTable(syntax.schema, syntax.table);\n        } break;\n        case Syntax::Identifier::Type::Expression: {\n            // main.table -> temp.unionedView\n            Syntax::Expression& syntax = (Syntax::Expression&) identifier;\n            switch (syntax.switcher) {\n            case Syntax::Expression::Switch::Column:\n                tryFallbackToSourceTable(syntax.column().schema, syntax.column().table);\n                break;\n            case Syntax::Expression::Switch::In:\n                if (syntax.inSwitcher == Syntax::Expression::SwitchIn::Table) {\n                    tryFallbackToSourceTable(syntax.schema(), syntax.table());\n                }\n                break;\n            default:\n                break;\n            }\n        } break;\n        default:\n            break;\n        }\n    });\n    m_filterCondition = filterCondition;\n}\n\nvoid MigrationBaseInfo::tryFallbackToSourceTable(Syntax::Schema& schema, StringView& table) const\n{\n    if (schema.isMain()) {\n        schema = getSchemaForSourceDatabase();\n        if (table.empty()) {\n            table = m_sourceTable;\n        }\n    }\n}\n\nbool MigrationBaseInfo::shouldMigrate() const\n{\n    return !m_sourceTable.empty();\n}\n\nbool MigrationBaseInfo::isCrossDatabase() const\n{\n    return m_databaseInfo.isCrossDatabase();\n}\n\nconst StringView& MigrationBaseInfo::getSourceDatabase() const\n{\n    return m_databaseInfo.getSourceDatabase();\n}\n\nData MigrationBaseInfo::getSourceCipher() const\n{\n    return m_databaseInfo.getCipher();\n}\n\nvoid MigrationBaseInfo::setRawSourceCipher(const UnsafeData& rawCipher) const\n{\n    return m_databaseInfo.setRawCipher(rawCipher);\n}\n\nbool MigrationBaseInfo::needRawSourceCipher() const\n{\n    return m_databaseInfo.needRawCipher();\n}\n\n#pragma mark - MigrationUserInfo\nMigrationUserInfo::~MigrationUserInfo() = default;\n\n#pragma mark - MigrationInfo\nMigrationInfo::MigrationInfo(const MigrationUserInfo& userInfo,\n                             const StringViewSet& uniqueColumns,\n                             bool autoincrement,\n                             const UnsafeStringView& integerPrimaryKey)\n: MigrationBaseInfo(userInfo)\n, m_autoincrement(autoincrement)\n, m_integerPrimaryKey(integerPrimaryKey)\n, m_needUpdateSequence(autoincrement)\n{\n    WCTAssert(!uniqueColumns.empty());\n\n    Column rowid = Column::rowid();\n    Columns columns;\n    columns.push_back(rowid);\n    columns.insert(columns.end(), uniqueColumns.begin(), uniqueColumns.end());\n\n    ResultColumns resultColumns;\n    resultColumns.insert(resultColumns.begin(), columns.begin(), columns.end());\n\n    const Schema& sourceSchema = m_databaseInfo.getSchemaForSourceDatabase();\n\n    TableOrSubquery sourceTableQuery\n    = TableOrSubquery(getSourceTable()).schema(sourceSchema);\n    QualifiedTable qualifiedSourceTable\n    = QualifiedTable(getSourceTable()).schema(sourceSchema);\n\n    // View\n    {\n        std::ostringstream stream;\n        stream << getUnionedViewPrefix() << getTable();\n        m_unionedView = StringView(stream.str());\n\n        m_statementForCreatingUnionedView = StatementCreateView()\n                                            .createView(m_unionedView)\n                                            .temp()\n                                            .ifNotExists()\n                                            .columns(columns)\n                                            .as(StatementSelect()\n                                                .select(resultColumns)\n                                                .from(TableOrSubquery(getTable()))\n                                                .unionAll()\n                                                .select(resultColumns)\n                                                .from(sourceTableQuery)\n                                                .where(m_filterCondition));\n    }\n\n    // Migrate\n    {\n        OrderingTerm migrateOrder\n        = m_integerPrimaryKey.empty() ?\n          OrderingTerm(rowid).order(Order::DESC) :\n          OrderingTerm(Column(m_integerPrimaryKey)).order(Order::DESC);\n\n        m_statementForMigratingOneRow = StatementInsert()\n                                        .insertIntoTable(getTable())\n                                        .orIgnore()\n                                        .columns(columns)\n                                        .values(StatementSelect()\n                                                .select(resultColumns)\n                                                .from(sourceTableQuery)\n                                                .where(m_filterCondition)\n                                                .order(migrateOrder)\n                                                .limit(1));\n\n        m_statementForDeletingMigratedOneRow = StatementDelete()\n                                               .deleteFrom(qualifiedSourceTable)\n                                               .where(m_filterCondition)\n                                               .orders(migrateOrder)\n                                               .limit(1);\n\n        m_statementForSelectingAnyRowFromSourceTable\n        = StatementSelect().select(Column::all()).from(sourceTableQuery).limit(1);\n    }\n\n    // Compatible\n    {\n        if (m_integerPrimaryKey.empty()) {\n            m_statementForSelectingMaxID\n            = StatementSelect()\n              .select(rowid.max() + 1)\n              .from(TableOrSubquery(m_table).schema(Schema::main()));\n        } else if (!autoincrement) {\n            m_statementForSelectingMaxID\n            = StatementSelect()\n              .select(Column(m_integerPrimaryKey).max() + 1)\n              .from(TableOrSubquery(m_unionedView).schema(Schema::temp()));\n        }\n\n        m_statementForDeletingSpecifiedRow\n        = StatementDelete().deleteFrom(qualifiedSourceTable).where(rowid == BindParameter(1));\n\n        m_statementForDroppingSourceTable\n        = StatementDropTable().dropTable(getSourceTable()).schema(sourceSchema).ifExists();\n    }\n}\n\nMigrationInfo::~MigrationInfo() = default;\n\nbool MigrationInfo::isAutoIncrement() const\n{\n    return m_autoincrement;\n}\n\nconst StringView& MigrationInfo::getIntegerPrimaryKey() const\n{\n    return m_integerPrimaryKey;\n}\n\nbool MigrationInfo::needUpdateSequance() const\n{\n    return m_needUpdateSequence;\n}\n\nvoid MigrationInfo::setNeedUpdateSequence(bool needUpdate) const\n{\n    m_needUpdateSequence = needUpdate;\n}\n\n#pragma mark - Schema\n\nconst StringView& MigrationInfo::getUnionedView() const\n{\n    return m_unionedView;\n}\n\nStatementDetach MigrationInfo::getStatementForDetachingSchema(const Schema& schema)\n{\n    WCTAssert(schema.getDescription().hasPrefix(MigrationDatabaseInfo::getSchemaPrefix()));\n    return StatementDetach().detach(schema);\n}\n\nStatementPragma MigrationInfo::getStatementForSelectingDatabaseList()\n{\n    return StatementPragma().pragma(Pragma::databaseList());\n}\n\n#pragma mark - View\nconst char* MigrationInfo::getUnionedViewPrefix()\n{\n    return \"wcdb_union_\";\n}\n\nconst StatementCreateView& MigrationInfo::getStatementForCreatingUnionedView() const\n{\n    return m_statementForCreatingUnionedView;\n}\n\nStatementCreateView\nMigrationInfo::getStatementForCreatingUnionedView(const Columns& columns) const\n{\n    StatementCreateView createView = getStatementForCreatingUnionedView();\n    Columns newColumns = columns;\n    newColumns.push_back(Column::rowid());\n    createView.columns(newColumns);\n    ResultColumns resultColumns;\n    resultColumns.insert(resultColumns.begin(), newColumns.begin(), newColumns.end());\n    createView.syntax().select.getOrCreate().select.getOrCreate().resultColumns = resultColumns;\n    for (auto& core : createView.syntax().select.getOrCreate().cores) {\n        core.resultColumns = resultColumns;\n    }\n    return createView;\n}\n\nconst StatementDropView\nMigrationInfo::getStatementForDroppingUnionedView(const UnsafeStringView& unionedView)\n{\n    WCTAssert(unionedView.hasPrefix(getUnionedViewPrefix()));\n    return StatementDropView().dropView(unionedView).schema(Schema::temp()).ifExists();\n}\n\nStatementSelect MigrationInfo::getStatementForSelectingUnionedView()\n{\n    Column name(\"name\");\n    Column type(\"type\");\n    StringView pattern = StringView::formatted(\"%s%%\", getUnionedViewPrefix());\n    return StatementSelect()\n    .select(name)\n    .from(TableOrSubquery::master().schema(Schema::temp()))\n    .where(type == \"view\" && name.like(pattern));\n}\n\n#pragma mark - Migrate\nconst StatementInsert& MigrationInfo::getStatementForMigratingOneRow() const\n{\n    return m_statementForMigratingOneRow;\n}\n\nconst StatementDelete& MigrationInfo::getStatementForDeletingMigratedOneRow() const\n{\n    return m_statementForDeletingMigratedOneRow;\n}\n\nvoid MigrationInfo::generateStatementsForInsertMigrating(const Statement& sourceStatement,\n                                                         std::list<Statement>& statements,\n                                                         int& primaryKeyIndex,\n                                                         int rowidBindIndex,\n                                                         Optional<int64_t>& assignedPrimaryKey) const\n{\n    WCTAssert(sourceStatement.syntax().getType() == Syntax::Identifier::Type::InsertSTMT);\n    statements.push_back(sourceStatement);\n    statements.push_back(m_statementForDeletingSpecifiedRow);\n    statements.push_back(sourceStatement);\n\n    auto& insertSyntax = static_cast<Syntax::InsertSTMT&>(statements.back().syntax());\n    insertSyntax.schema = Schema::main();\n    insertSyntax.table = m_table;\n\n    if (m_autoincrement) {\n        return;\n    }\n\n    WCTAssert(!insertSyntax.isMultiWrite());\n    auto& columns = insertSyntax.columns;\n    WCTAssert(!columns.empty());\n    columns.insert(columns.end(), Column(\"rowid\"));\n\n    if (insertSyntax.expressionsValues.empty()) {\n        insertSyntax.expressionsValues.push_back({});\n    }\n    WCTAssert(insertSyntax.expressionsValues.size() == 1);\n    auto& values = *insertSyntax.expressionsValues.begin();\n    Expression rowid = BindParameter(rowidBindIndex);\n    values.insert(values.end(), rowid);\n\n    WCTAssert(columns.size() == values.size());\n\n    if (m_integerPrimaryKey.empty()) {\n        statements.insert(--statements.end(), m_statementForSelectingMaxID);\n        return;\n    }\n\n    int index = -1;\n    int i = 0;\n    for (const auto& iter : columns) {\n        if (iter.name.caseInsensitiveEqual(m_integerPrimaryKey)) {\n            index = i;\n            break;\n        }\n        i++;\n    }\n\n    if (index >= 0) {\n        auto valueIter = values.begin();\n        std::advance(valueIter, index);\n        if (valueIter->switcher == Syntax::Expression::Switch::BindParameter) {\n            primaryKeyIndex = valueIter->bindParameter().n;\n        } else {\n            WCTAssert(valueIter->switcher == Syntax::Expression::Switch::LiteralValue);\n            if (valueIter->literalValue().switcher == Syntax::LiteralValue::Switch::Integer) {\n                assignedPrimaryKey = valueIter->literalValue().integerValue;\n            } else if (valueIter->literalValue().switcher\n                       == Syntax::LiteralValue::Switch::UnsignedInteger) {\n                assignedPrimaryKey = valueIter->literalValue().unsignedIntegerValue;\n            } else {\n                WCTAssert(valueIter->literalValue().switcher\n                          == Syntax::LiteralValue::Switch::Null)\n            }\n        }\n    }\n\n    if (!assignedPrimaryKey.hasValue()) {\n        statements.insert(--statements.end(), m_statementForSelectingMaxID);\n    }\n}\n\nvoid MigrationInfo::generateStatementsForUpdateMigrating(const Statement& sourceStatement,\n                                                         std::list<Statement>& statements,\n                                                         int rowidBindIndex) const\n{\n    WCTAssert(sourceStatement.getType() == Syntax::Identifier::Type::UpdateSTMT);\n    statements.push_back(StatementSelect().from(\n    TableOrSubquery(getUnionedView()).schema(Schema::temp())));\n    StatementSelect& select = static_cast<StatementSelect&>(statements.back());\n    statements.push_back(sourceStatement);\n    StatementUpdate& update = static_cast<StatementUpdate&>(statements.back());\n\n    Syntax::UpdateSTMT& updateSyntax = update.syntax();\n    Syntax::SelectSTMT& selectSyntax = select.syntax();\n    Syntax::SelectCore& coreSyntax = selectSyntax.select.getOrCreate();\n\n    selectSyntax.commonTableExpressions = updateSyntax.commonTableExpressions;\n    updateSyntax.commonTableExpressions.clear();\n\n    coreSyntax.condition = updateSyntax.condition;\n    updateSyntax.condition.getOrCreate().__is_valid = Syntax::Identifier::invalid;\n\n    selectSyntax.orderingTerms = updateSyntax.orderingTerms;\n    updateSyntax.orderingTerms.clear();\n\n    selectSyntax.limit = updateSyntax.limit;\n    selectSyntax.limitParameterType = updateSyntax.limitParameterType;\n    selectSyntax.limitParameter = updateSyntax.limitParameter;\n    updateSyntax.limit.getOrCreate().__is_valid = Syntax::Identifier::invalid;\n\n    if (m_integerPrimaryKey.empty()) {\n        select.select(Column::rowid());\n        update.where(Column::rowid() == BindParameter(rowidBindIndex));\n    } else {\n        select.select(Column(m_integerPrimaryKey));\n        update.where(Column(m_integerPrimaryKey) == BindParameter(rowidBindIndex));\n    }\n\n    statements.push_back(update);\n    StatementUpdate& update2 = static_cast<StatementUpdate&>(statements.back());\n    update2.syntax().table.table = m_table;\n    update2.syntax().table.schema = Schema::main();\n}\n\nvoid MigrationInfo::generateStatementsForDeleteMigrating(const Statement& sourceStatement,\n                                                         std::list<Statement>& statements,\n                                                         int rowidBindIndex) const\n{\n    WCTAssert(sourceStatement.getType() == Syntax::Identifier::Type::DeleteSTMT);\n    statements.push_back(StatementSelect().from(\n    TableOrSubquery(getUnionedView()).schema(Schema::temp())));\n    StatementSelect& select = static_cast<StatementSelect&>(statements.back());\n    statements.push_back(sourceStatement);\n    StatementDelete& delete_ = static_cast<StatementDelete&>(statements.back());\n\n    Syntax::DeleteSTMT& deleteSyntax = delete_.syntax();\n    Syntax::SelectSTMT& selectSyntax = select.syntax();\n    Syntax::SelectCore& coreSyntax = selectSyntax.select.getOrCreate();\n\n    selectSyntax.commonTableExpressions = deleteSyntax.commonTableExpressions;\n    deleteSyntax.commonTableExpressions.clear();\n\n    coreSyntax.condition = deleteSyntax.condition;\n    deleteSyntax.condition.getOrCreate().__is_valid = Syntax::Identifier::invalid;\n\n    selectSyntax.orderingTerms = deleteSyntax.orderingTerms;\n    deleteSyntax.orderingTerms.clear();\n\n    selectSyntax.limit = deleteSyntax.limit;\n    selectSyntax.limitParameterType = deleteSyntax.limitParameterType;\n    selectSyntax.limitParameter = deleteSyntax.limitParameter;\n    deleteSyntax.limit.getOrCreate().__is_valid = Syntax::Identifier::invalid;\n\n    if (m_integerPrimaryKey.empty()) {\n        select.select(Column::rowid());\n        delete_.where(Column::rowid() == BindParameter(rowidBindIndex));\n    } else {\n        select.select(Column(m_integerPrimaryKey));\n        delete_.where(Column(m_integerPrimaryKey) == BindParameter(rowidBindIndex));\n    }\n\n    statements.push_back(delete_);\n    StatementDelete& delete2 = static_cast<StatementDelete&>(statements.back());\n    delete2.syntax().table.table = m_table;\n    delete2.syntax().table.schema = Schema::main();\n}\n\nStatementDelete\nMigrationInfo::getStatementForDeletingFromTable(const Statement& sourceStatement) const\n{\n    WCTAssert(sourceStatement.getType() == Syntax::Identifier::Type::DropTableSTMT);\n\n    const Syntax::DropTableSTMT& dropTableSyntax\n    = ((const StatementDropTable&) sourceStatement).syntax();\n    WCDB::QualifiedTable table(dropTableSyntax.table);\n    table.syntax().schema = dropTableSyntax.schema;\n\n    return StatementDelete().deleteFrom(table).where(m_filterCondition);\n}\n\nconst StatementSelect& MigrationInfo::getStatementForSelectingAnyRowFromSourceTable() const\n{\n    return m_statementForSelectingAnyRowFromSourceTable;\n}\n\nconst StatementDropTable& MigrationInfo::getStatementForDroppingSourceTable() const\n{\n    return m_statementForDroppingSourceTable;\n}\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/core/migration/MigrationInfo.hpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"Lock.hpp\"\n#include \"StringView.hpp\"\n#include \"WINQ.h\"\n#include <set>\n\nnamespace WCDB {\n\nclass MigrationUserInfo;\n\n#pragma mark - MigrationDatabaseInfo\nclass MigrationDatabaseInfo {\npublic:\n    typedef std::function<void(MigrationUserInfo&)> TableFilter;\n\n    MigrationDatabaseInfo(const UnsafeStringView& path,\n                          const UnsafeData& cipher,\n                          const TableFilter& filter);\n\n    bool isCrossDatabase() const;\n\n    static const char* getSchemaPrefix();\n    const StringView& getSourceDatabase() const;\n\n    Data getCipher() const;\n    void setRawCipher(const UnsafeData& rawCipher) const;\n    bool needRawCipher() const;\n\n    const TableFilter& getFilter() const;\n\n    const Schema& getSchemaForSourceDatabase() const;\n    const StatementAttach& getStatementForAttachingSchema() const;\n\nprivate:\n    StringView m_sourcePath;\n    mutable Data m_cipher;\n    TableFilter m_filter;\n\n    mutable bool m_needRawCipher;\n    mutable SharedLock m_lock;\n\n    // wcdb_migration_ + hash(m_sourcePath)\n    Schema m_schema;\n    StatementAttach m_statementForAttachingSchema;\n};\n\n#pragma mark - MigrationBaseInfo\nclass MigrationBaseInfo {\npublic:\n    MigrationBaseInfo();\n    MigrationBaseInfo(MigrationDatabaseInfo& databaseInfo, const UnsafeStringView& table);\n    virtual ~MigrationBaseInfo() = 0;\n\n    const StringView& getTable() const;\n    const StringView& getSourceTable() const;\n    const Expression& getFilterCondition() const;\n\n    bool shouldMigrate() const;\n    bool isCrossDatabase() const;\n    const StringView& getSourceDatabase() const;\n\n    Data getSourceCipher() const;\n    void setRawSourceCipher(const UnsafeData& rawCipher) const;\n    bool needRawSourceCipher() const;\n\n    const Schema& getSchemaForSourceDatabase() const;\n    const StatementAttach& getStatementForAttachingSchema() const;\n\nprotected:\n    void setSource(const UnsafeStringView& table);\n    void setFilter(Expression filterCondition);\n    void tryFallbackToSourceTable(Syntax::Schema& schema, StringView& table) const;\n\n    MigrationDatabaseInfo& m_databaseInfo;\n    StringView m_table;\n    StringView m_sourceTable;\n    Expression m_filterCondition;\n};\n\n#pragma mark - MigrationUserInfo\nclass MigrationUserInfo final : public MigrationBaseInfo {\npublic:\n    using MigrationBaseInfo::MigrationBaseInfo;\n    ~MigrationUserInfo() override;\n\n    using MigrationBaseInfo::setSource;\n    using MigrationBaseInfo::setFilter;\n};\n\n#pragma mark - MigrationInfo\nclass MigrationInfo final : public MigrationBaseInfo {\npublic:\n    MigrationInfo(const MigrationUserInfo& userInfo,\n                  const StringViewSet& columns,\n                  bool autoincrement,\n                  const UnsafeStringView& integerPrimaryKey);\n    ~MigrationInfo() override;\n\n    bool isAutoIncrement() const;\n    const StringView& getIntegerPrimaryKey() const;\n    bool needUpdateSequance() const;\n    void setNeedUpdateSequence(bool needUpdate) const;\n\nprotected:\n    bool m_autoincrement;\n    StringView m_integerPrimaryKey;\n    mutable bool m_needUpdateSequence;\n\n#pragma mark - Schema\npublic:\n    /*\n     DETACH [schemaForSourceDatabase]\n     */\n    static StatementDetach getStatementForDetachingSchema(const Schema& schema);\n\n    /*\n     PRAGMA main.database_list\n     */\n    static StatementPragma getStatementForSelectingDatabaseList();\n\n#pragma mark - View\npublic:\n    // wcdb_union_\n    static const char* getUnionedViewPrefix();\n\n    const StringView& getUnionedView() const;\n\n    /*\n     CREATE TEMP VIEW IF NOT EXISTS [unionedView] AS\n     SELECT rowid, [columns]\n     FROM [schemaForSourceDatabase].[sourceTable]\n     UNION/UNION ALL\n     SELECT rowid, [columns]\n     FROM main.[table]\n     ORDER BY rowid ASC\n     */\n    const StatementCreateView& getStatementForCreatingUnionedView() const;\n    StatementCreateView getStatementForCreatingUnionedView(const Columns& columns) const;\n\n    /*\n     DROP VIEW IF EXISTS temp.[unionedView]\n     */\n    static const StatementDropView\n    getStatementForDroppingUnionedView(const UnsafeStringView& unionedView);\n\n    /*\n     SELECT name\n     FROM temp.sqlite_master\n     WHERE type == \"view\" AND name LIKE \"wcdb_union_%\"\n     */\n    static StatementSelect getStatementForSelectingUnionedView();\n\nprotected:\n    // wcdb_union_ + [table]\n    StringView m_unionedView;\n    StatementCreateView m_statementForCreatingUnionedView;\n\n#pragma mark - Compatible\npublic:\n    /*\n     Firstly,\n     \n     INSERT INTO [schemaForSourceDatabase].[sourceTable]([columns]) VALUES (...)\n     DELETE FROM [schemaForSourceDatabase].[sourceTable] WHERE rowid == ?1\n     \n     And then\n     \n     1. for the tables with autoincrement integer primary key:\n     \n        INSERT INTO main.targetTable([columns]) VALUES (...)\n     \n     2. for the tables with integer primary key:\n     \n        INSERT INTO main.targetTable([columns], rowid) VALUES (..., ?rowidIndex)\n     \n        Note that newRowid is\n        (1) the primmay key assigned from statement\n        (2) or SELECT max(primary key)+1 FROM temp.[unionedView]\n     \n     3. for the tables with normal primary key or no primary key:\n     \n        INSERT INTO main.targetTable([columns], rowid) VALUES (..., ?rowidIndex)\n     \n        Note that newRowid is SELECT max(rowid)+1 FROM temp.[unionedView]\n     */\n    void generateStatementsForInsertMigrating(const Statement& sourceStatement,\n                                              std::list<Statement>& statements,\n                                              int& primaryKeyIndex,\n                                              int rowidBindIndex,\n                                              Optional<int64_t>& assignedPrimaryKey) const;\n\n    /*\n     SELECT [rowid/primary key] FROM temp.[unionedView] WHERE ... ORDER BY ... LIMIT ... OFFSET ...\n     UPDATE [schemaForSourceDatabase].[sourceTable] SET ... TO ... WHERE [rowid/primary key] == ?index\n     UPDATE main.targetTable SET ... TO ... WHERE [rowid/primary key] == ?index\n     \n     For the tables with integer primary key, it uses primary key. For the other tables, it uses rowid.\n     */\n    void generateStatementsForUpdateMigrating(const Statement& sourceStatement,\n                                              std::list<Statement>& statements,\n                                              int rowidBindIndex) const;\n\n    /*\n     SELECT [rowid/primary key] FROM temp.[unionedView] WHERE ... ORDER BY ... LIMIT ... OFFSET ...\n     DELETE FROM [schemaForSourceDatabase].[sourceTable] WHERE [rowid/primary key] == ?index\n     DELETE FROM main.targetTable WHERE [rowid/primary key] == ?index\n     \n     For the tables with integer primary key, it uses primary key. For the other tables, it uses rowid.\n     */\n    void generateStatementsForDeleteMigrating(const Statement& sourceStatement,\n                                              std::list<Statement>& statements,\n                                              int rowidBindIndex) const;\n\n    StatementDelete getStatementForDeletingFromTable(const Statement& sourceStatement) const;\n\nprotected:\n    StatementDelete m_statementForDeletingSpecifiedRow;\n    StatementSelect m_statementForSelectingMaxID;\n\n#pragma mark - Migrate\npublic:\n    /*\n     INSERT [columns]\n     INTO rowid, main.[table]\n     SELECT rowid, [columns]\n     FROM [schemaForSourceDatabase].[sourceTable]\n     ORDER BY [rowid/primary key] DESC\n     LIMIT 1\n     \n     For the tables with integer primary key, it uses primary key. For the other tables, it uses rowid.\n     */\n    const StatementInsert& getStatementForMigratingOneRow() const;\n\n    /*\n     DELETE FROM [schemaForSourceDatabase].[sourceTable]\n     ORDER BY [rowid/primary key] DESC\n     LIMIT 1\n     \n     For the tables with integer primary key, it uses primary key. For the other tables, it uses rowid.\n     */\n    const StatementDelete& getStatementForDeletingMigratedOneRow() const;\n\n    /*\n     SELECT * FROM [schemaForSourceDatabase].[sourceTable] LIMIT 1\n     */\n    const StatementSelect& getStatementForSelectingAnyRowFromSourceTable() const;\n\n    /*\n     DROP TABLE IF EXISTS [schemaForSourceDatabase].[sourceTable]\n     */\n    const StatementDropTable& getStatementForDroppingSourceTable() const;\n\nprotected:\n    StatementInsert m_statementForMigratingOneRow;\n    StatementDelete m_statementForDeletingMigratedOneRow;\n    StatementDropTable m_statementForDroppingSourceTable;\n    StatementSelect m_statementForSelectingAnyRowFromSourceTable;\n};\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/core/operate/OperationQueue.cpp",
    "content": "//\n// Created by sanhuazhang on 2019/06/06\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"OperationQueue.hpp\"\n#include \"Assertion.hpp\"\n#include \"CommonCore.hpp\"\n#include \"CoreConst.h\"\n#include \"CrossPlatform.h\"\n#include \"FileManager.hpp\"\n#include \"Global.hpp\"\n#include \"Notifier.hpp\"\n#include <fcntl.h>\n\nnamespace WCDB {\n\nOperationEvent::~OperationEvent() = default;\n\nOperationQueue::OperationQueue(const UnsafeStringView& name, OperationEvent* event)\n: AsyncQueue(name)\n, m_event(event)\n, m_observerForMemoryWarning(registerNotificationWhenMemoryWarning())\n{\n    Notifier::shared().setNotification(\n    0, name, std::bind(&OperationQueue::handleError, this, std::placeholders::_1));\n#ifndef _WIN32\n    Global::shared().setNotificationWhenFileOpened(\n    name,\n    std::bind(&OperationQueue::observatedThatFileOpened,\n              this,\n              std::placeholders::_1,\n              std::placeholders::_2,\n              std::placeholders::_3,\n              std::placeholders::_4));\n#endif\n}\n\nOperationQueue::~OperationQueue()\n{\n#ifndef _WIN32\n    Global::shared().setNotificationWhenFileOpened(name, nullptr);\n#endif\n    Notifier::shared().unsetNotification(name);\n\n    unregisterNotificationWhenMemoryWarning(m_observerForMemoryWarning);\n}\n\nvoid OperationQueue::stopAllDatabaseEvent(const UnsafeStringView& path)\n{\n    LockGuard lockGuard(m_lock);\n    Operation integerity(Operation::Type::Integrity, path);\n    m_timedQueue.remove(integerity);\n\n    Operation checkpoint(Operation::Type::Checkpoint, path);\n    m_timedQueue.remove(checkpoint);\n\n    Operation backup(Operation::Type::Backup, path);\n    m_timedQueue.remove(backup);\n\n    Operation migrate(Operation::Type::Migrate, path);\n    m_timedQueue.remove(migrate);\n\n    Operation compress(Operation::Type::Compress, path);\n    m_timedQueue.remove(compress);\n\n    Operation mergeIndex(Operation::Type::MergeIndex, path);\n    m_timedQueue.remove(mergeIndex);\n}\n\nvoid OperationQueue::stop()\n{\n    m_timedQueue.stop();\n}\n\nvoid OperationQueue::main()\n{\n    m_timedQueue.loop(std::bind(\n    &OperationQueue::onTimed, this, std::placeholders::_1, std::placeholders::_2));\n}\n\nvoid OperationQueue::handleError(const Error& error)\n{\n    if (error.level < Error::Level::Warning || !error.isCorruption() || isExiting()) {\n        return;\n    }\n\n    const auto& infos = error.infos;\n\n    auto iter = infos.find(UnsafeStringView(ErrorStringKeyPath));\n    if (iter == infos.end() || iter->second.getType() != Value::Type::Text) {\n        // make sure no empty path will be added into queue\n        return;\n    }\n\n    const UnsafeStringView& path = iter->second.textValue();\n    if (path.empty()) {\n        return;\n    }\n\n    if (path.compare(m_skipIntegrityCheckPath.getOrCreate()) == 0) {\n        return;\n    }\n\n    auto optionalIdentifier = FileManager::getFileIdentifier(path);\n    if (!optionalIdentifier.succeed()) {\n        return;\n    }\n    uint32_t identifier = optionalIdentifier.value();\n\n    bool fromIntegrity = false;\n    auto actionIter = infos.find(UnsafeStringView(ErrorStringKeyType));\n    if (actionIter != infos.end() && actionIter->second.textValue() == ErrorTypeIntegrity) {\n        fromIntegrity = true;\n    }\n\n    if (fromIntegrity) {\n        LockGuard lockGuard(m_lock);\n        bool emplaced = m_corrupteds.emplace(identifier).second;\n        if (emplaced\n            && m_corruptionNotifications.find(path) != m_corruptionNotifications.end()) {\n            asyncNotifyCorruption(path, identifier);\n        }\n    } else {\n        // check integrity to\n        // 1. find out the real corrupted database for multi-schemas\n        // 2. avoid wrongly report by backup\n        asyncCheckIntegrity(path, identifier);\n    }\n}\n#ifndef _WIN32\nvoid OperationQueue::observatedThatFileOpened(int fd, const char* path, int flags, int mode)\n{\n    WCDB_UNUSED(mode);\n\n    if (fd != -1) {\n        if ((flags & O_CREAT) != 0) {\n            FileManager::setFileProtectionCompleteUntilFirstUserAuthenticationIfNeeded(path);\n        }\n\n        int possibleNumberOfActiveFileDescriptors = fd + 1;\n        if (possibleNumberOfActiveFileDescriptors\n            > maxAllowedNumberOfFileDescriptors() * OperationQueueRateForTooManyFileDescriptors) {\n            Parameter parameter;\n            parameter.source = Parameter::Source::FileDescriptorsWarning;\n            parameter.numberOfFileDescriptors = possibleNumberOfActiveFileDescriptors;\n            asyncPurge(parameter);\n        }\n    } else if (errno == EMFILE) {\n        Parameter parameter;\n        parameter.source = Parameter::Source::OutOfMaxAllowedFileDescriptors;\n        asyncPurge(parameter);\n    }\n}\n#endif\n\n#pragma mark - Operation\nOperationQueue::Operation::Operation(Type type_) : type(type_)\n{\n}\n\nOperationQueue::Operation::Operation(Type type_, const UnsafeStringView& path_)\n: type(type_), path(path_)\n{\n}\n\nbool OperationQueue::Operation::operator==(const Operation& other) const\n{\n    bool equal = false;\n    if (type == other.type) {\n        if (type == Type::Purge) {\n            equal = true;\n        } else {\n            equal = (path == other.path);\n        }\n    }\n    return equal;\n}\n\nOperationQueue::Parameter::Parameter()\n: source(Source::Other), numberOfFailures(0), identifier(0), numberOfFileDescriptors(0)\n{\n}\n\nvoid OperationQueue::onTimed(const Operation& operation, const Parameter& parameter)\n{\n    executeOperationWithAutoMemoryRelease([&]() {\n        if (operation.type != Operation::Type::NotifyCorruption) {\n            CommonCore::shared().setThreadedErrorIgnorable(true);\n        }\n        switch (operation.type) {\n        case Operation::Type::Migrate:\n            doMigrate(operation.path, parameter.numberOfFailures);\n            break;\n        case Operation::Type::Compress:\n            doCompress(operation.path, parameter.numberOfFailures);\n            break;\n        case Operation::Type::Checkpoint:\n            doCheckpoint(operation.path);\n            break;\n        case Operation::Type::Purge:\n            WCTAssert(operation.path.empty());\n            doPurge(parameter);\n            break;\n        case Operation::Type::Integrity:\n            doCheckIntegrity(operation.path);\n            break;\n        case Operation::Type::NotifyCorruption:\n            doNotifyCorruption(operation.path, parameter.identifier);\n            break;\n        case Operation::Type::MergeIndex:\n            doMergeFTSIndex(operation.path, parameter.newTables, parameter.modifiedTables);\n            break;\n        case Operation::Type::Backup:\n            doBackup(operation.path);\n            break;\n        }\n        if (operation.type != Operation::Type::NotifyCorruption) {\n            CommonCore::shared().setThreadedErrorIgnorable(false);\n        }\n    });\n}\n\nvoid OperationQueue::async(const Operation& operation, double delay, const Parameter& parameter, AsyncMode mode)\n{\n    m_timedQueue.queue(operation, delay, parameter, mode);\n}\n\n#pragma mark - Record\nOperationQueue::Record::Record()\n: registeredForMigration(false)\n, registeredForCompression(false)\n, registeredForBackup(false)\n, registeredForCheckpoint(false)\n{\n}\n\n#pragma mark - Migrate\nvoid OperationQueue::registerAsRequiredMigration(const UnsafeStringView& path)\n{\n    WCTAssert(!path.empty());\n\n    LockGuard lockGuard(m_lock);\n    m_records[path].registeredForMigration = true;\n}\n\nvoid OperationQueue::registerAsNoMigrationRequired(const UnsafeStringView& path)\n{\n    WCTAssert(!path.empty());\n\n    LockGuard lockGuard(m_lock);\n    m_records[path].registeredForMigration = false;\n    Operation operation(Operation::Type::Migrate, path);\n    m_timedQueue.remove(operation);\n}\n\nvoid OperationQueue::asyncMigrate(const UnsafeStringView& path)\n{\n    asyncMigrate(path, OperationQueueTimeIntervalForMigration, 0);\n}\n\nvoid OperationQueue::stopMigrate(const UnsafeStringView& path)\n{\n    LockGuard lockGuard(m_lock);\n    Operation operation(Operation::Type::Migrate, path);\n    m_timedQueue.remove(operation);\n}\n\nvoid OperationQueue::asyncMigrate(const UnsafeStringView& path, double delay, int numberOfFailures)\n{\n    WCTAssert(!path.empty());\n    WCTAssert(numberOfFailures >= 0\n              && numberOfFailures < OperationQueueTolerableFailuresForMigration);\n\n    SharedLockGuard lockGuard(m_lock);\n    if (m_records[path].registeredForMigration) {\n        Operation operation(Operation::Type::Migrate, path);\n        Parameter parameter;\n        parameter.numberOfFailures = numberOfFailures;\n        async(operation, delay, parameter);\n    }\n}\n\nvoid OperationQueue::doMigrate(const UnsafeStringView& path, int numberOfFailures)\n{\n    WCTAssert(!path.empty());\n    WCTAssert(numberOfFailures >= 0\n              && numberOfFailures < OperationQueueTolerableFailuresForMigration);\n\n    auto done = m_event->migrationShouldBeOperated(path);\n    if (done.succeed()) {\n        if (!done.value()) {\n            asyncMigrate(path, OperationQueueTimeIntervalForMigration, numberOfFailures);\n        }\n    } else {\n        if (numberOfFailures + 1 < OperationQueueTolerableFailuresForMigration) {\n            asyncMigrate(\n            path, OperationQueueTimeIntervalForRetringAfterFailure, numberOfFailures + 1);\n        } else {\n            Error error(Error::Code::Notice,\n                        Error::Level::Notice,\n                        \"Auto migration is stopped due to too many errors.\");\n            error.infos.insert_or_assign(ErrorStringKeyPath, path);\n            error.infos.insert_or_assign(ErrorStringKeyType, ErrorTypeMigrate);\n            Notifier::shared().notify(error);\n        }\n    }\n}\n\n#pragma mark - Compress\nvoid OperationQueue::registerAsRequiredCompression(const UnsafeStringView& path)\n{\n    WCTAssert(!path.empty());\n\n    LockGuard lockGuard(m_lock);\n    m_records[path].registeredForCompression = true;\n}\n\nvoid OperationQueue::registerAsNoCompressionRequired(const UnsafeStringView& path)\n{\n    WCTAssert(!path.empty());\n\n    LockGuard lockGuard(m_lock);\n    m_records[path].registeredForCompression = false;\n    Operation operation(Operation::Type::Compress, path);\n    m_timedQueue.remove(operation);\n}\n\nvoid OperationQueue::asyncCompress(const UnsafeStringView& path)\n{\n    asyncCompress(path, OperationQueueTimeIntervalForCompression, 0);\n}\n\nvoid OperationQueue::stopCompress(const UnsafeStringView& path)\n{\n    LockGuard lockGuard(m_lock);\n    Operation operation(Operation::Type::Compress, path);\n    m_timedQueue.remove(operation);\n}\n\nvoid OperationQueue::asyncCompress(const UnsafeStringView& path, double delay, int numberOfFailures)\n{\n    WCTAssert(!path.empty());\n    WCTAssert(numberOfFailures >= 0\n              && numberOfFailures < OperationQueueTolerableFailuresForCompression);\n\n    SharedLockGuard lockGuard(m_lock);\n    if (m_records[path].registeredForCompression) {\n        Operation operation(Operation::Type::Compress, path);\n        Parameter parameter;\n        parameter.numberOfFailures = numberOfFailures;\n        async(operation, delay, parameter);\n    }\n}\n\nvoid OperationQueue::doCompress(const UnsafeStringView& path, int numberOfFailures)\n{\n    WCTAssert(!path.empty());\n    WCTAssert(numberOfFailures >= 0\n              && numberOfFailures < OperationQueueTolerableFailuresForCompression);\n\n    auto done = m_event->compressionShouldBeOperated(path);\n    if (done.succeed()) {\n        if (!done.value()) {\n            asyncCompress(path, OperationQueueTimeIntervalForCompression, numberOfFailures);\n        }\n    } else {\n        if (numberOfFailures + 1 < OperationQueueTolerableFailuresForCompression) {\n            asyncCompress(\n            path, OperationQueueTimeIntervalForRetringAfterFailure, numberOfFailures + 1);\n        } else {\n            Error error(Error::Code::Notice,\n                        Error::Level::Notice,\n                        \"Auto compression is stopped due to too many errors.\");\n            error.infos.insert_or_assign(ErrorStringKeyPath, path);\n            error.infos.insert_or_assign(ErrorStringKeyType, ErrorTypeCompress);\n            Notifier::shared().notify(error);\n        }\n    }\n}\n\n#pragma mark - Merge FTS Index\nvoid OperationQueue::registerAsRequiredMergeFTSIndex(const UnsafeStringView& path)\n{\n    WCTAssert(!path.empty());\n\n    LockGuard lockGuard(m_lock);\n    m_records[path].registeredForMergeFTSIndex = true;\n}\n\nvoid OperationQueue::registerAsNoMergeFTSIndexRequired(const UnsafeStringView& path)\n{\n    WCTAssert(!path.empty());\n\n    LockGuard lockGuard(m_lock);\n    m_records[path].registeredForMergeFTSIndex = false;\n    Operation operation(Operation::Type::MergeIndex, path);\n    m_timedQueue.remove(operation);\n}\n\nvoid OperationQueue::asyncMergeFTSIndex(const UnsafeStringView& path,\n                                        TableArray newTables,\n                                        TableArray modifiedTables)\n{\n    SharedLockGuard lockGuard(m_lock);\n    if (m_records[path].registeredForMergeFTSIndex) {\n        Operation operation(Operation::Type::MergeIndex, path);\n        Parameter parameter;\n        parameter.newTables = newTables;\n        parameter.modifiedTables = modifiedTables;\n        async(operation, OperationQueueTimeIntervalForMergeFTSIndex, parameter);\n    }\n}\n\nvoid OperationQueue::doMergeFTSIndex(const UnsafeStringView& path,\n                                     TableArray newTables,\n                                     TableArray modifiedTables)\n{\n    WCTAssert(!path.empty());\n\n    m_event->mergeFTSIndexShouldBeOperated(path, newTables, modifiedTables);\n}\n\n#pragma mark - Backup\nbool OperationQueue::isAutoBackup(const UnsafeStringView& path)\n{\n    WCTAssert(!path.empty());\n\n    SharedLockGuard lockGuard(m_lock);\n    return m_records[path].registeredForBackup;\n}\n\nvoid OperationQueue::registerAsRequiredBackup(const UnsafeStringView& path)\n{\n    WCTAssert(!path.empty());\n\n    LockGuard lockGuard(m_lock);\n    m_records[path].registeredForBackup = true;\n}\n\nvoid OperationQueue::registerAsNoBackupRequired(const UnsafeStringView& path)\n{\n    WCTAssert(!path.empty());\n\n    LockGuard lockGuard(m_lock);\n    m_records[path].registeredForBackup = false;\n    Operation operation(Operation::Type::Backup, path);\n    m_timedQueue.remove(operation);\n}\n\nvoid OperationQueue::asyncBackup(const UnsafeStringView& path, bool incremental)\n{\n    WCTAssert(!path.empty());\n\n    SharedLockGuard lockGuard(m_lock);\n    auto iter = m_records.find(path);\n    if (iter != m_records.end() && iter->second.registeredForBackup) {\n        asyncBackup(path, incremental ? 0 : OperationQueueTimeIntervalForBackup);\n    }\n}\n\nvoid OperationQueue::asyncBackup(const UnsafeStringView& path, double delay)\n{\n    WCTAssert(!path.empty());\n\n    Operation operation(Operation::Type::Backup, path);\n    Parameter parameter; // no use\n    async(operation, delay, parameter);\n}\n\nvoid OperationQueue::doBackup(const UnsafeStringView& path)\n{\n    WCTAssert(!path.empty());\n\n    m_event->backupShouldBeOperated(path);\n}\n\n#pragma mark - Checkpoint\nvoid OperationQueue::registerAsRequiredCheckpoint(const UnsafeStringView& path)\n{\n    WCTAssert(!path.empty());\n\n    LockGuard lockGuard(m_lock);\n    m_records[path].registeredForCheckpoint = true;\n}\n\nvoid OperationQueue::registerAsNoCheckpointRequired(const UnsafeStringView& path)\n{\n    WCTAssert(!path.empty());\n\n    LockGuard lockGuard(m_lock);\n    m_records[path].registeredForCheckpoint = false;\n\n    Operation operation(Operation::Type::Checkpoint, path);\n    m_timedQueue.remove(operation);\n}\n\nvoid OperationQueue::asyncCheckpoint(const UnsafeStringView& path)\n{\n    WCTAssert(!path.empty());\n\n    SharedLockGuard lockGuard(m_lock);\n    auto iter = m_records.find(path);\n    if (iter != m_records.end() && iter->second.registeredForCheckpoint) {\n        Operation operation(Operation::Type::Checkpoint, path);\n        Parameter parameter;\n        double checkPointInterval = OperationQueueTimeIntervalForCheckpoint;\n        async(operation, checkPointInterval, parameter, AsyncMode::ForwardOnly);\n    }\n}\n\nvoid OperationQueue::doCheckpoint(const UnsafeStringView& path)\n{\n    WCTAssert(!path.empty());\n\n    m_event->checkpointShouldBeOperated(path);\n}\n\n#pragma mark - Purge\n#ifndef _WIN32\nint OperationQueue::maxAllowedNumberOfFileDescriptors()\n{\n    const int s_maxAllowedNumberOfFileDescriptors = std::max(getdtablesize(), 1024);\n    return s_maxAllowedNumberOfFileDescriptors;\n}\n#endif\n\nvoid OperationQueue::asyncPurge(const Parameter& parameter)\n{\n    WCTAssert(parameter.source != Parameter::Source::Other);\n\n    SharedLockGuard lockGuard(m_lock);\n    if (SteadyClock::timeIntervalSinceSteadyClockToNow(m_lastPurge)\n        > OperationQueueTimeIntervalForPurgingAgain) {\n        Operation operation(Operation::Type::Purge);\n        async(operation, 0, parameter);\n    }\n}\n\nvoid OperationQueue::doPurge(const Parameter& parameter)\n{\n    switch (parameter.source) {\n    case Parameter::Source::MemoryWarning: {\n        Error error(Error::Code::Warning, Error::Level::Warning, \"Purge due to memory warning.\");\n        Notifier::shared().notify(error);\n    } break;\n    case Parameter::Source::Other:{\n    } break;\n#ifndef _WIN32\n    case Parameter::Source::FileDescriptorsWarning: {\n        Error error(Error::Code::Warning, Error::Level::Warning, \"Purge due to file descriptors warning.\");\n        error.infos.insert_or_assign(\"MaxAllowedFileDescriptors\",\n                                     maxAllowedNumberOfFileDescriptors());\n        error.infos.insert_or_assign(\"FileDescriptor\", parameter.numberOfFileDescriptors);\n        Notifier::shared().notify(error);\n    } break;\n    default: {\n        WCTAssert(parameter.source == Parameter::Source::OutOfMaxAllowedFileDescriptors);\n        Error error(Error::Code::Warning,\n                    Error::Level::Warning,\n                    \"Purge due to out of max allowed file descriptors.\");\n        error.infos.insert_or_assign(\"MaxAllowedFileDescriptors\",\n                                     maxAllowedNumberOfFileDescriptors());\n        Notifier::shared().notify(error);\n    } break;\n#endif\n    }\n\n    m_event->purgeShouldBeOperated();\n\n    LockGuard lockGuard(m_lock);\n    WCTAssert(SteadyClock::now() > m_lastPurge);\n    m_lastPurge = SteadyClock::now();\n}\n\nvoid OperationQueue::asyncPurgeWhenMemoryWarning()\n{\n    Parameter parameter;\n    parameter.source = Parameter::Source::MemoryWarning;\n    this->asyncPurge(parameter);\n}\n\n#pragma mark - Check Integrity\nvoid OperationQueue::skipIntegrityCheck(const UnsafeStringView& path)\n{\n    m_skipIntegrityCheckPath.getOrCreate() = path;\n}\n\nvoid OperationQueue::asyncCheckIntegrity(const UnsafeStringView& path, uint32_t identifier)\n{\n    WCTAssert(!path.empty());\n    WCTAssert(identifier != 0);\n\n    SharedLockGuard lockGuard(m_lock);\n    if (m_corrupteds.find(identifier) == m_corrupteds.end()) {\n        Operation operation(Operation::Type::Integrity, path);\n        Parameter parameter; // useless\n        async(operation, 0, parameter);\n    }\n}\n\nvoid OperationQueue::doCheckIntegrity(const UnsafeStringView& path)\n{\n    WCTAssert(!path.empty());\n\n    m_event->integrityShouldBeChecked(path);\n}\n\n#pragma mark - Corrupted\nvoid OperationQueue::setNotificationWhenCorrupted(const UnsafeStringView& path,\n                                                  const CorruptionNotification& notification)\n{\n    WCTAssert(!path.empty());\n\n    LockGuard lockGuard(m_lock);\n    if (notification != nullptr) {\n        m_corruptionNotifications[path] = notification;\n    } else {\n        m_corruptionNotifications.erase(path);\n    }\n}\n\nbool OperationQueue::isFileObservedCorrupted(const UnsafeStringView& path) const\n{\n    WCTAssert(!path.empty());\n\n    bool corrupted = false;\n    auto identifier = FileManager::getFileIdentifier(path);\n    if (identifier.succeed()) {\n        SharedLockGuard lockGuard(m_lock);\n        corrupted = m_corrupteds.find(identifier.value()) != m_corrupteds.end();\n    }\n    return corrupted;\n}\n\nvoid OperationQueue::asyncNotifyCorruption(const UnsafeStringView& path, uint32_t identifier)\n{\n    WCTAssert(!path.empty());\n    WCTAssert(identifier != 0);\n\n    Operation operation(Operation::Type::NotifyCorruption, path);\n    Parameter parameter;\n    parameter.identifier = identifier;\n    async(operation, 0, parameter);\n}\n\nvoid OperationQueue::doNotifyCorruption(const UnsafeStringView& path, uint32_t identifier)\n{\n    WCTAssert(!path.empty());\n    WCTAssert(identifier != 0);\n\n    CorruptionNotification notification;\n    {\n        SharedLockGuard lockGuard(m_lock);\n        auto iter = m_corruptionNotifications.find(path);\n        if (iter != m_corruptionNotifications.end()) {\n            WCTAssert(iter->second != nullptr);\n            notification = iter->second;\n        }\n    }\n    notification(path, identifier);\n}\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/core/operate/OperationQueue.hpp",
    "content": "//\n// Created by sanhuazhang on 2019/06/06\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"AsyncQueue.hpp\"\n#include \"Lock.hpp\"\n#include \"StringView.hpp\"\n#include \"Time.hpp\"\n#include \"TimedQueue.hpp\"\n#include <map>\n#include <set>\n\n#include \"AutoBackupConfig.hpp\"\n#include \"AutoCheckpointConfig.hpp\"\n#include \"AutoCompressConfig.hpp\"\n#include \"AutoMergeFTSIndexConfig.hpp\"\n#include \"AutoMigrateConfig.hpp\"\n#include \"OperationQueueForMemory.hpp\"\n#include \"WCDBOptional.hpp\"\n\nnamespace WCDB {\n\nclass OperationEvent {\npublic:\n    virtual ~OperationEvent() = 0;\n\nprotected:\n    virtual Optional<bool> migrationShouldBeOperated(const UnsafeStringView& path) = 0;\n    virtual Optional<bool> compressionShouldBeOperated(const UnsafeStringView& path) = 0;\n    virtual void backupShouldBeOperated(const UnsafeStringView& path) = 0;\n    virtual void checkpointShouldBeOperated(const UnsafeStringView& path) = 0;\n    virtual void integrityShouldBeChecked(const UnsafeStringView& path) = 0;\n    virtual void purgeShouldBeOperated() = 0;\n\n    using TableArray = AutoMergeFTSIndexOperator::TableArray;\n    virtual Optional<bool>\n    mergeFTSIndexShouldBeOperated(const UnsafeStringView& path, TableArray newTables, TableArray modifiedTables)\n    = 0;\n\n    friend class OperationQueue;\n};\n\nclass OperationQueue final : public AsyncQueue,\n                             public OperationQueueForMemory,\n                             public AutoMigrateOperator,\n                             public AutoCompressOperator,\n                             public AutoBackupOperator,\n                             public AutoMergeFTSIndexOperator,\n                             public AutoCheckpointOperator {\npublic:\n    OperationQueue(const UnsafeStringView& name, OperationEvent* event);\n    ~OperationQueue() override;\n\n    void stopAllDatabaseEvent(const UnsafeStringView& path);\n\n    void stop();\n\nprotected:\n    void main() override final;\n    void handleError(const Error& error);\n#ifndef _WIN32\n    void observatedThatFileOpened(int fd, const char* path, int flags, int mode);\n#endif\nprivate:\n    OperationEvent* m_event;\n    mutable SharedLock m_lock;\n\n#pragma mark - Operation\nprotected:\n    struct Operation {\n    public:\n        enum class Type {\n            Integrity,\n            Purge,\n            NotifyCorruption,\n            Checkpoint,\n            Backup,\n            Migrate,\n            Compress,\n            MergeIndex,\n        };\n\n        const Type type;\n        const StringView path;\n\n        Operation(Type type);\n        Operation(Type type, const UnsafeStringView& path);\n\n        bool operator==(const Operation& other) const;\n    };\n    typedef struct Operation Operation;\n\n    struct Parameter {\n        Parameter();\n        enum class Source {\n            Other = -1,\n            MemoryWarning,\n#ifndef _WIN32\n            FileDescriptorsWarning,\n            OutOfMaxAllowedFileDescriptors,\n#endif\n        } source;\n        int numberOfFailures;\n        uint32_t identifier;\n        uint32_t numberOfFileDescriptors;\n        TableArray newTables;\n        TableArray modifiedTables;\n    };\n    typedef struct Parameter Parameter;\n\n    void onTimed(const Operation& operation, const Parameter& parameter);\n\n    typedef TimedQueue<Operation, Parameter>::Mode AsyncMode;\n    void async(const Operation& operation,\n               double delay,\n               const Parameter& parameter,\n               AsyncMode mode = AsyncMode::ForwardOnly);\n    TimedQueue<Operation, Parameter> m_timedQueue;\n\n#pragma mark - Record\nprotected:\n    struct Record {\n        Record();\n        bool registeredForMigration;\n        bool registeredForCompression;\n        bool registeredForBackup;\n        bool registeredForCheckpoint;\n        bool registeredForMergeFTSIndex;\n    };\n    typedef struct Record Record;\n    StringViewMap<Record> m_records;\n\n#pragma mark - Migrate\npublic:\n    void registerAsRequiredMigration(const UnsafeStringView& path);\n    void registerAsNoMigrationRequired(const UnsafeStringView& path);\n    void asyncMigrate(const UnsafeStringView& path) override final;\n    void stopMigrate(const UnsafeStringView& path) override final;\n\nprotected:\n    void asyncMigrate(const UnsafeStringView& path, double delay, int numberOfFailures);\n    void doMigrate(const UnsafeStringView& path, int numberOfFailures);\n\n#pragma mark - Compress\npublic:\n    void registerAsRequiredCompression(const UnsafeStringView& path);\n    void registerAsNoCompressionRequired(const UnsafeStringView& path);\n    void asyncCompress(const UnsafeStringView& path) override final;\n    void stopCompress(const UnsafeStringView& path) override final;\n\nprotected:\n    void asyncCompress(const UnsafeStringView& path, double delay, int numberOfFailures);\n    void doCompress(const UnsafeStringView& path, int numberOfFailures);\n\n#pragma mark - Merge FTS Index\npublic:\n    using TableArray = AutoMergeFTSIndexOperator::TableArray;\n    void registerAsRequiredMergeFTSIndex(const UnsafeStringView& path);\n    void registerAsNoMergeFTSIndexRequired(const UnsafeStringView& path);\n    void asyncMergeFTSIndex(const UnsafeStringView& path,\n                            TableArray newTables,\n                            TableArray modifiedTables) override final;\n\nprotected:\n    void doMergeFTSIndex(const UnsafeStringView& path, TableArray newTables, TableArray modifiedTables);\n\n#pragma mark - Backup\npublic:\n    bool isAutoBackup(const UnsafeStringView& path);\n    void registerAsRequiredBackup(const UnsafeStringView& path);\n    void registerAsNoBackupRequired(const UnsafeStringView& path);\n\n    void asyncBackup(const UnsafeStringView& path, bool incremental) override final;\n\nprotected:\n    void asyncBackup(const UnsafeStringView& path, double delay);\n    void doBackup(const UnsafeStringView& path);\n\n#pragma mark - Checkpoint\npublic:\n    void registerAsRequiredCheckpoint(const UnsafeStringView& path);\n    void registerAsNoCheckpointRequired(const UnsafeStringView& path);\n\n    void asyncCheckpoint(const UnsafeStringView& path) override final;\n\nprotected:\n    void doCheckpoint(const UnsafeStringView& path);\n\n#pragma mark - Purge\nprotected:\n    void asyncPurge(const Parameter& parameter);\n\n    void doPurge(const Parameter& parameter);\n\n    static int maxAllowedNumberOfFileDescriptors();\n\n    void asyncPurgeWhenMemoryWarning() override;\n\n    SteadyClock m_lastPurge;\n    void* m_observerForMemoryWarning;\n\n#pragma mark - Integrity\npublic:\n    void skipIntegrityCheck(const UnsafeStringView& path);\n\nprotected:\n    void asyncCheckIntegrity(const UnsafeStringView& path, uint32_t identifier);\n\n    void doCheckIntegrity(const UnsafeStringView& path);\n\n    // identifier of the corrupted database file -> the times of ignored corruption\n    // it will be kept forever in memory since the identifier will be changed after removed/recovered\n    std::set<uint32_t> m_corrupteds;\n    ThreadLocal<StringView> m_skipIntegrityCheckPath;\n\n#pragma mark - Corrupted\npublic:\n    typedef std::function<void(const UnsafeStringView& path, uint32_t identifier)> CorruptionNotification;\n    void setNotificationWhenCorrupted(const UnsafeStringView& path,\n                                      const CorruptionNotification& notification);\n\n    bool isFileObservedCorrupted(const UnsafeStringView& path) const;\n\nprotected:\n    void asyncNotifyCorruption(const UnsafeStringView& path, uint32_t identifier);\n\n    void doNotifyCorruption(const UnsafeStringView& path, uint32_t identifier);\n\n    StringViewMap<CorruptionNotification> m_corruptionNotifications;\n};\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/core/operate/OperationQueueForMemory.cpp",
    "content": "//\n// Created by qiuwenchen on 2023/3/19.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"OperationQueueForMemory.hpp\"\n\nnamespace WCDB {\nOperationQueueForMemory::~OperationQueueForMemory() = default;\n}\n"
  },
  {
    "path": "src/common/core/operate/OperationQueueForMemory.hpp",
    "content": "//\n// Created by qiuwenchen on 2023/3/19.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include <functional>\n\nnamespace WCDB {\n\nclass OperationQueueForMemory {\npublic:\n    virtual ~OperationQueueForMemory() = 0;\n    void* registerNotificationWhenMemoryWarning();\n    void unregisterNotificationWhenMemoryWarning(void* observer);\n    void executeOperationWithAutoMemoryRelease(std::function<void(void)> operation);\n    virtual void asyncPurgeWhenMemoryWarning() = 0;\n};\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/core/sqlite/AbstractHandle.cpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/19\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"AbstractHandle.hpp\"\n#include \"Assertion.hpp\"\n#include \"CoreConst.h\"\n#include \"Notifier.hpp\"\n#include \"Path.hpp\"\n#include \"SQLite.h\"\n#include \"StringView.hpp\"\n\nnamespace WCDB {\n\n#pragma mark - Initialize\nAbstractHandle::AbstractHandle()\n: m_handle(nullptr)\n, m_customOpenFlag(0)\n, m_tag(Tag::invalid())\n, m_enableLiteMode(false)\n, m_isReadOnly(false)\n, m_transactionLevel(0)\n, m_transactionError(TransactionError::Allowed)\n, m_cacheTransactionError(TransactionError::Allowed)\n, m_notification(this)\n, m_tableMonitorForbidden(false)\n, m_fullSQLTrace(false)\n, m_busyTrace(false)\n, m_tid(0)\n, m_threadErrorProne(nullptr)\n, m_canBeSuspended(false)\n{\n}\n\nAbstractHandle::~AbstractHandle()\n{\n    WCTAssert(m_transactionError == TransactionError::Allowed);\n    close();\n}\n\nsqlite3 *AbstractHandle::getRawHandle()\n{\n    WCTAssert(isOpened());\n    return m_handle;\n}\n\n#pragma mark - Path\nvoid AbstractHandle::setPath(const UnsafeStringView &path)\n{\n    if (m_path != path) {\n        close();\n        m_path = path;\n        m_error.infos.insert_or_assign(ErrorStringKeyPath, m_path);\n    }\n}\n\nvoid AbstractHandle::clearPath()\n{\n    close();\n    m_path.clear();\n}\n\nconst StringView &AbstractHandle::getPath() const\n{\n    return m_path;\n}\n\nStringView AbstractHandle::shmPathOfDatabase(const UnsafeStringView &database)\n{\n    return Path::addExtention(database, \"-shm\");\n}\n\nStringView AbstractHandle::walPathOfDatabase(const UnsafeStringView &database)\n{\n    return Path::addExtention(database, \"-wal\");\n}\n\nStringView AbstractHandle::journalPathOfDatabase(const UnsafeStringView &database)\n{\n    return Path::addExtention(database, \"-journal\");\n}\n\n#pragma mark - Basic\nbool AbstractHandle::open()\n{\n    bool succeed = true;\n    if (!isOpened()) {\n        if (m_isReadOnly) {\n            succeed = APIExit(\n            sqlite3_open_v2(m_path.data(), &m_handle, SQLITE_OPEN_READONLY, 0));\n        } else if (m_customOpenFlag == 0) {\n            succeed = APIExit(sqlite3_open_v2(\n            m_path.data(), &m_handle, SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE | SQLITE_OPEN_MAINDB_READONLY, 0));\n        } else {\n            succeed\n            = APIExit(sqlite3_open_v2(m_path.data(), &m_handle, m_customOpenFlag, 0));\n        }\n        if (!succeed) {\n            m_handle = nullptr;\n        }\n    }\n    return succeed;\n}\n\nbool AbstractHandle::isOpened() const\n{\n    return m_handle != nullptr;\n}\n\nvoid AbstractHandle::close()\n{\n    if (isOpened()) {\n        if (m_cancelSignal != nullptr) {\n            sqlite3_progress_handler(m_handle, 0, nullptr, nullptr);\n        }\n        finalizeStatements();\n        m_transactionLevel = 0;\n        m_notification.purge();\n        APIExit(sqlite3_close_v2(m_handle));\n        m_handle = nullptr;\n    }\n}\n\nvoid AbstractHandle::setTag(Tag tag)\n{\n    m_tag = tag;\n}\n\nTag AbstractHandle::getTag()\n{\n    return m_tag;\n}\n\nbool AbstractHandle::executeSQL(const UnsafeStringView &sql)\n{\n    // use seperated sqlite3_exec to get more information\n    WCTAssert(isOpened());\n    HandleStatement handleStatement(this);\n    bool succeed = handleStatement.prepareSQL(sql);\n    if (succeed) {\n        succeed = handleStatement.step();\n        handleStatement.finalize();\n    }\n    return succeed;\n}\n\nbool AbstractHandle::executeStatement(const Statement &statement)\n{\n    // use seperated sqlite3_exec to get more information\n    WCTAssert(isOpened());\n    HandleStatement handleStatement(this);\n    bool succeed = handleStatement.prepare(statement);\n    if (succeed) {\n        succeed = handleStatement.step();\n        handleStatement.finalize();\n    }\n    return succeed;\n}\n\nlong long AbstractHandle::getLastInsertedRowID()\n{\n    WCTAssert(isOpened());\n    return sqlite3_last_insert_rowid(m_handle);\n}\n\nint AbstractHandle::getTotalChange()\n{\n    WCTAssert(isOpened());\n    return sqlite3_total_changes(m_handle);\n}\n\nvoid AbstractHandle::enableWriteMainDB(bool enable)\n{\n    if (enable) {\n        m_customOpenFlag = SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE;\n    } else {\n        m_customOpenFlag = 0;\n    }\n}\n\nbool AbstractHandle::canWriteMainDB()\n{\n    return m_customOpenFlag & SQLITE_OPEN_READWRITE;\n}\n\nvoid AbstractHandle::setLiteModeEnable(bool enable)\n{\n    m_enableLiteMode = enable;\n}\n\nbool AbstractHandle::liteModeEnable() const\n{\n    return m_enableLiteMode;\n}\n\nint AbstractHandle::getChanges()\n{\n    WCTAssert(isOpened());\n    return sqlite3_changes(m_handle);\n}\n\nbool AbstractHandle::isReadonly()\n{\n    WCTAssert(isOpened());\n    return sqlite3_db_readonly(m_handle, NULL) == 1;\n}\n\nvoid AbstractHandle::setReadOnly()\n{\n    m_isReadOnly = true;\n}\n\nbool AbstractHandle::isInTransaction()\n{\n    WCTAssert(isOpened());\n    return sqlite3_get_autocommit(m_handle) == 0;\n}\n\n#pragma mark - Statement\nDecorativeHandleStatement *AbstractHandle::getStatement(const UnsafeStringView &)\n{\n    m_handleStatements.push_back(DecorativeHandleStatement(this));\n    m_handleStatements.back().enableAutoAddColumn();\n    return &m_handleStatements.back();\n}\n\nvoid AbstractHandle::returnStatement(HandleStatement *handleStatement)\n{\n    if (handleStatement != nullptr) {\n        for (auto iter = m_handleStatements.begin(); iter != m_handleStatements.end(); ++iter) {\n            if (&(*iter) == handleStatement) {\n                m_handleStatements.erase(iter);\n                return;\n            }\n        }\n        WCTAssert(false);\n    }\n}\n\nvoid AbstractHandle::resetAllStatements()\n{\n    for (auto &handleStatement : m_handleStatements) {\n        if (!handleStatement.isPrepared()) continue;\n        handleStatement.reset();\n    }\n}\n\nvoid AbstractHandle::finalizeStatements()\n{\n    for (const auto &iter : m_preparedStatements) {\n        iter.second->finalize();\n        returnStatement(iter.second);\n    }\n    m_preparedStatements.clear();\n    for (auto &handleStatement : m_handleStatements) {\n        handleStatement.finalize();\n    }\n}\n\nHandleStatement *AbstractHandle::getOrCreatePreparedStatement(const Statement &statement)\n{\n    const StringView &sql = statement.getDescription();\n    HandleStatement *preparedStatement = getOrCreateStatement(sql);\n\n    if (preparedStatement == nullptr\n        || (!preparedStatement->isPrepared() && !preparedStatement->prepare(statement))) {\n        return nullptr;\n    }\n    return preparedStatement;\n}\n\nHandleStatement *AbstractHandle::getOrCreatePreparedStatement(const UnsafeStringView &sql)\n{\n    HandleStatement *preparedStatement = getOrCreateStatement(sql);\n\n    if (preparedStatement == nullptr\n        || (!preparedStatement->isPrepared() && !preparedStatement->prepareSQL(sql))) {\n        return nullptr;\n    }\n    return preparedStatement;\n}\n\nHandleStatement *AbstractHandle::prepareNewStatement(const Statement &statement)\n{\n    const StringView &sql = statement.getDescription();\n    if (sql.length() == 0) {\n        m_error.setCode(Error::Code::Error, \"Invalid statement\");\n        m_error.infos.erase(ErrorStringKeySQL);\n        m_error.level = Error::Level::Error;\n        Notifier::shared().notify(m_error);\n        return nullptr;\n    }\n    DecorativeHandleStatement *handleStatement = getStatement();\n    if (handleStatement == nullptr || !handleStatement->prepare(statement)) {\n        if (handleStatement != nullptr) {\n            returnStatement(handleStatement);\n        }\n        return nullptr;\n    }\n    return handleStatement;\n}\n\nHandleStatement *AbstractHandle::prepareNewStatement(const UnsafeStringView &sql)\n{\n    if (sql.length() == 0) {\n        m_error.setCode(Error::Code::Error, \"Invalid statement\");\n        m_error.infos.erase(ErrorStringKeySQL);\n        m_error.level = Error::Level::Error;\n        Notifier::shared().notify(m_error);\n        return nullptr;\n    }\n    DecorativeHandleStatement *handleStatement = getStatement();\n    if (handleStatement == nullptr || !handleStatement->prepareSQL(sql)) {\n        if (handleStatement != nullptr) {\n            returnStatement(handleStatement);\n        }\n        return nullptr;\n    }\n    return handleStatement;\n}\n\nvoid AbstractHandle::finalizeAndReturnPreparedStatement(HandleStatement *handleStatement)\n{\n    if (handleStatement != nullptr) {\n        handleStatement->finalize();\n        returnStatement(handleStatement);\n    }\n}\n\nHandleStatement *AbstractHandle::getOrCreateStatement(const UnsafeStringView &sql)\n{\n    if (sql.length() == 0) {\n        m_error.setCode(Error::Code::Error, \"Invalid statement\");\n        m_error.infos.erase(ErrorStringKeySQL);\n        m_error.level = Error::Level::Error;\n        Notifier::shared().notify(m_error);\n        return nullptr;\n    }\n    auto iter = m_preparedStatements.find(sql);\n    DecorativeHandleStatement *handleStatement;\n    if (iter == m_preparedStatements.end()) {\n        handleStatement = getStatement();\n        m_preparedStatements[sql] = handleStatement;\n    } else {\n        handleStatement = iter->second;\n    }\n    WCTAssert(handleStatement != nullptr);\n    return handleStatement;\n}\n\n#pragma mark - Meta\nOptional<bool> AbstractHandle::ft3TokenizerExists(const UnsafeStringView &tokenizer)\n{\n    markErrorAsIgnorable(Error::Code::Error);\n    bool succeed = executeStatement(StatementSelect().select(\n    Expression::function(\"fts3_tokenizer\").invoke().arguments(tokenizer)));\n    Optional<bool> exists;\n    if (succeed) {\n        exists = true;\n    } else if (m_error.isIgnorable()) {\n        exists = false;\n    }\n    markErrorAsUnignorable();\n    return exists;\n}\n\nOptional<bool> AbstractHandle::tableExists(const UnsafeStringView &table)\n{\n    return tableExists(Schema::main(), table);\n}\n\nOptional<bool>\nAbstractHandle::tableExists(const Schema &schema, const UnsafeStringView &table)\n{\n    StatementSelect statement\n    = StatementSelect().select(1).from(TableOrSubquery(table).schema(schema)).limit(1);\n\n    HandleStatement handleStatement(this);\n    markErrorAsIgnorable(Error::Code::Error);\n    bool succeed = handleStatement.prepare(statement);\n    Optional<bool> exists;\n    if (succeed) {\n        handleStatement.finalize();\n        exists = true;\n    } else if (m_error.isIgnorable()) {\n        exists = false;\n    }\n    markErrorAsUnignorable();\n    return exists;\n}\n\nbool AbstractHandle::addColumn(const Schema &schema,\n                               const UnsafeStringView &table,\n                               const ColumnDef &column)\n{\n    StatementAlterTable statement\n    = StatementAlterTable().alterTable(table).schema(schema).addColumn(column);\n    HandleStatement handleStatement(this);\n    bool hasCacheError = false;\n    if (m_transactionError != TransactionError::Fatal) {\n        hasCacheError = true;\n        cacheCurrentTransactionError();\n    }\n    bool succeed = handleStatement.prepare(statement) && handleStatement.step();\n    if (!succeed && getError().getMessage().hasPrefix(\"duplicate column name: \")) {\n        succeed = true;\n        if (hasCacheError) {\n            resumeCacheTransactionError();\n        }\n    }\n    handleStatement.finalize();\n    return succeed;\n}\n\nOptional<StringViewSet>\nAbstractHandle::getColumns(const Schema &schema, const UnsafeStringView &table)\n{\n    WCDB::StatementPragma statement\n    = StatementPragma().pragma(Pragma::tableInfo()).schema(schema).with(table);\n    return getValues(statement, 1);\n}\n\nOptional<std::vector<ColumnMeta>>\nAbstractHandle::getTableMeta(const Schema &schema, const UnsafeStringView &table)\n{\n    Optional<std::vector<ColumnMeta>> metas;\n    HandleStatement handleStatement(this);\n    if (handleStatement.prepare(\n        StatementPragma().pragma(Pragma::tableInfo()).schema(schema).with(table))) {\n        bool succeed = false;\n        std::vector<ColumnMeta> rows;\n        while ((succeed = handleStatement.step()) && !handleStatement.done()) {\n            rows.push_back(ColumnMeta(handleStatement.getInteger(0), // cid\n                                      handleStatement.getText(1),    // name\n                                      handleStatement.getText(2),    // type\n                                      handleStatement.getInteger(3), // notnull\n                                      handleStatement.getInteger(5)) // pk\n            );\n        }\n        handleStatement.finalize();\n        if (succeed) {\n            metas = rows;\n        }\n    }\n    return metas;\n}\n\nOptional<StringViewSet> AbstractHandle::getValues(const Statement &statement, int index)\n{\n    Optional<StringViewSet> values;\n    HandleStatement handleStatement(this);\n    if (handleStatement.prepare(statement)) {\n        StringViewSet rows;\n        bool succeed = false;\n        while ((succeed = handleStatement.step()) && !handleStatement.done()) {\n            rows.emplace(handleStatement.getText(index));\n        }\n        handleStatement.finalize();\n        if (succeed) {\n            values = std::move(rows);\n        }\n    }\n    return values;\n}\n\nOptional<TableAttribute>\nAbstractHandle::getTableAttribute(const Schema &schema, const UnsafeStringView &tableName)\n{\n    int isAutoincrement = 0;\n    int isWithoutRowid = 0;\n    int isVirtual = 0;\n    const char *integerPrimaryKey = nullptr;\n    bool ret = APIExit(sqlite3_table_config(m_handle,\n                                            schema.syntax().name.data(),\n                                            tableName.data(),\n                                            &isAutoincrement,\n                                            &isWithoutRowid,\n                                            &isVirtual,\n                                            &integerPrimaryKey));\n    if (!ret) {\n        if (integerPrimaryKey != nullptr) {\n            free((void *) integerPrimaryKey);\n        }\n        return NullOpt;\n    }\n    TableAttribute config(\n    isAutoincrement > 0, isWithoutRowid > 0, isVirtual > 0, StringView(integerPrimaryKey));\n    if (integerPrimaryKey != nullptr) {\n        free((void *) integerPrimaryKey);\n    }\n    return config;\n}\n\nbool AbstractHandle::configAutoIncrement(const UnsafeStringView &tableName)\n{\n    return APIExit(sqlite3_table_config_auto_increment(m_handle, tableName.data()));\n}\n\nbool AbstractHandle::getSchemaInfo(int &memoryUsed, int &tableCount, int &indexCount, int &triggerCount)\n{\n    int highWater;\n    return APIExit(sqlite3_db_status(\n           m_handle, SQLITE_DBSTATUS_SCHEMA_USED, &memoryUsed, &highWater, false))\n           && APIExit(sqlite3_schema_info(m_handle, &tableCount, &indexCount, &triggerCount));\n}\n\n#pragma mark - Transaction\nvoid AbstractHandle::markErrorNotAllowedWithinTransaction()\n{\n    if (m_transactionError == TransactionError::Allowed) {\n        m_transactionError = TransactionError::NotAllowed;\n    }\n}\n\nbool AbstractHandle::isErrorAllowedWithinTransaction() const\n{\n    return m_transactionError != TransactionError::NotAllowed;\n}\n\nvoid AbstractHandle::cacheCurrentTransactionError()\n{\n    m_cacheTransactionError = m_transactionError;\n}\n\nvoid AbstractHandle::resumeCacheTransactionError()\n{\n    m_transactionError = m_cacheTransactionError;\n}\n\nStringView AbstractHandle::getSavepointName(int transactionLevel)\n{\n    return StringView::formatted(\"wcdb_lv_%d\", transactionLevel);\n}\n\nbool AbstractHandle::beginTransaction()\n{\n    bool succeed = true;\n    if (isInTransaction()) {\n        if (m_transactionLevel == 0) {\n            m_transactionLevel = 1;\n        }\n    } else {\n        m_transactionLevel = 0;\n    }\n    if (m_transactionLevel > 0) {\n        if (m_transactionError == TransactionError::Allowed) {\n            succeed = executeStatement(\n            StatementSavepoint().savepoint(getSavepointName(m_transactionLevel + 1)));\n        }\n        if (succeed) {\n            ++m_transactionLevel;\n        }\n        return succeed;\n    } else {\n        static const StatementBegin *s_beginImmediate\n        = new StatementBegin(StatementBegin().beginImmediate());\n        succeed = executeStatement(*s_beginImmediate);\n        if (succeed) {\n            m_transactionLevel = 1;\n        }\n        return succeed;\n    }\n}\n\nbool AbstractHandle::commitOrRollbackTransaction()\n{\n    bool succeed = true;\n    if (m_transactionError != TransactionError::Fatal) {\n        succeed = commitTransaction();\n    } else {\n        succeed = false;\n    }\n    if (!succeed) {\n        // If certain kinds of errors occur within a transaction, the transaction may or may not be rolled back automatically: https://sqlite.org/lang_transaction.html\n        rollbackTransaction();\n        succeed = false;\n    }\n    return succeed;\n}\n\nbool AbstractHandle::commitTransaction()\n{\n    bool succeed = true;\n    if (m_transactionLevel > 1) {\n        if (m_transactionError == TransactionError::Allowed && isInTransaction()) {\n            succeed = executeStatement(\n            StatementRelease().release(getSavepointName(m_transactionLevel)));\n        }\n        if (succeed) {\n            --m_transactionLevel;\n        }\n        return succeed;\n    }\n    /*\n    All statements must be reset before commit or rollback,\n    because sqlite will downgrade handle to a read-only transaction state\n    if some statements of this handle are still active.\n    Please see the comment of btreeEndTransaction for more information.\n    */\n    resetAllStatements();\n    // Transaction can be removed automatically in some case. e.g. interrupt step\n    if (isInTransaction()) {\n        static const StatementCommit *s_commit\n        = new StatementCommit(StatementCommit().commit());\n\n        succeed = executeStatement(*s_commit);\n    }\n    if (succeed) {\n        m_transactionLevel = 0;\n        m_transactionError = TransactionError::Allowed;\n    }\n    return succeed;\n}\n\nvoid AbstractHandle::rollbackTransaction()\n{\n    if (m_enableLiteMode) {\n        notifyError(Error::Code::Misuse, \"\", \"Can not execute rollback in a database without rollback journal.\");\n        commitTransaction();\n        return;\n    }\n    /*\n     It is unnecessary to check whether the rollback operation is successful or not.\n     If the rollback fails and the transaction level can not be decreased,\n     db won't be able to exit the transaction under abnormal circumstances.\n     */\n    if (m_transactionLevel > 1) {\n        if (m_transactionError == TransactionError::Allowed && isInTransaction()) {\n            sqlite3_unimpeded(m_handle, true);\n            executeStatement(StatementRollback().rollbackToSavepoint(getSavepointName(m_transactionLevel)));\n            sqlite3_unimpeded(m_handle, false);\n        }\n        --m_transactionLevel;\n        return;\n    }\n    /*\n    All statements must be reset before commit or rollback,\n    because sqlite will downgrade handle to a read-only transaction state\n    if some statements of this handle are still active.\n    Please see the comment of btreeEndTransaction for more information.\n    */\n    resetAllStatements();\n    // Transaction can be removed automatically in some case. e.g. interrupt step\n    if (isInTransaction()) {\n        static const StatementRollback *s_rollback\n        = new StatementRollback(StatementRollback().rollback());\n        sqlite3_unimpeded(m_handle, true);\n        executeStatement(*s_rollback);\n        sqlite3_unimpeded(m_handle, false);\n    }\n    m_transactionLevel = 0;\n    m_transactionError = TransactionError::Allowed;\n}\n\n#pragma mark - Wal\nvoid AbstractHandle::enableExtendedResultCodes(bool enable)\n{\n    WCTAssert(isOpened());\n    APIExit(sqlite3_extended_result_codes(m_handle, (int) enable));\n}\n\nbool AbstractHandle::checkpoint(CheckpointMode mode)\n{\n    static_assert((int) CheckpointMode::Passive == SQLITE_CHECKPOINT_PASSIVE, \"\");\n    static_assert((int) CheckpointMode::Full == SQLITE_CHECKPOINT_FULL, \"\");\n    static_assert((int) CheckpointMode::Restart == SQLITE_CHECKPOINT_RESTART, \"\");\n    static_assert((int) CheckpointMode::Truncate == SQLITE_CHECKPOINT_TRUNCATE, \"\");\n    WCTAssert(isOpened());\n\n    return APIExit(sqlite3_wal_checkpoint_v2(\n    m_handle, Syntax::mainSchema.data(), (int) mode, nullptr, nullptr));\n}\n\nvoid AbstractHandle::disableCheckpointWhenClosing(bool disable)\n{\n    WCTAssert(isOpened());\n    APIExit(sqlite3_db_config(\n    m_handle, SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE, (int) disable, nullptr));\n}\n\nvoid AbstractHandle::setWALFilePersist(int persist)\n{\n    if (m_path.compare(\":memory:\") == 0) {\n        return;\n    }\n    WCTAssert(isOpened());\n    APIExit(sqlite3_file_control(\n    m_handle, Syntax::mainSchema.data(), SQLITE_FCNTL_PERSIST_WAL, &persist));\n}\n\nbool AbstractHandle::setCheckPointLock(bool enable)\n{\n    if (m_path.compare(\":memory:\") == 0) {\n        return true;\n    }\n    WCTAssert(isOpened());\n    return APIExit(sqlite3_lock_checkpoint(m_handle, enable));\n}\n\n#pragma mark - Notification\nvoid AbstractHandle::setNotificationWhenSQLTraced(const UnsafeStringView &name,\n                                                  const SQLNotification &onTraced)\n{\n    WCTAssert(isOpened());\n    m_notification.setNotificationWhenSQLTraced(name, onTraced);\n}\n\nvoid AbstractHandle::setNotificationWhenPerformanceTraced(const UnsafeStringView &name,\n                                                          const PerformanceNotification &onTraced)\n{\n    WCTAssert(isOpened());\n    m_notification.setNotificationWhenPerformanceTraced(name, onTraced);\n}\n\nvoid AbstractHandle::setNotificationWhenCommitted(int order,\n                                                  const UnsafeStringView &name,\n                                                  const CommittedNotification &onCommitted)\n{\n    WCTAssert(isOpened());\n    m_notification.setNotificationWhenCommitted(order, name, onCommitted);\n}\n\nvoid AbstractHandle::unsetNotificationWhenCommitted(const UnsafeStringView &name)\n{\n    WCTAssert(isOpened());\n    m_notification.unsetNotificationWhenCommitted(name);\n}\n\nvoid AbstractHandle::setNotificationWhenCheckpointed(const UnsafeStringView &name,\n                                                     Optional<CheckPointNotification> notification)\n{\n    WCTAssert(isOpened());\n    m_notification.setNotificationWhenCheckpointed(name, notification);\n}\n\nvoid AbstractHandle::setNotificationWhenBusy(const BusyNotification &busyNotification)\n{\n    WCTAssert(isOpened());\n    m_notification.setNotificationWhenBusy(busyNotification);\n}\n\nvoid AbstractHandle::setNotificationWhenTableModified(const UnsafeStringView &name,\n                                                      const TableModifiedNotification &tableModifiedNotification)\n{\n    m_notification.setNotificationWhenTableModified(name, tableModifiedNotification);\n}\n\nvoid AbstractHandle::postTableNotification(const UnsafeStringView &newTable,\n                                           const UnsafeStringView &modifiedTable)\n{\n    m_notification.postTableModifiedNotification(newTable, modifiedTable);\n}\n\nbool AbstractHandle::needMonitorTable()\n{\n    return !m_tableMonitorForbidden && m_notification.needMonitorTable();\n}\n\nvoid AbstractHandle::setTableMonitorEnable(bool enable)\n{\n    m_tableMonitorForbidden = !enable;\n}\n\nvoid AbstractHandle::setFullSQLTraceEnable(bool enable)\n{\n    m_fullSQLTrace = enable;\n    if (isOpened()) {\n        m_notification.setFullSQLTraceEnable(enable);\n    }\n}\n\nbool AbstractHandle::isFullSQLEnable()\n{\n    return m_fullSQLTrace;\n}\n\nvoid AbstractHandle::postSQLNotification(const UnsafeStringView &sql,\n                                         const UnsafeStringView &info)\n{\n    m_notification.postSQLTraceNotification(m_tag, m_path, m_handle, sql, info);\n}\n\nvoid AbstractHandle::setBusyTraceEnable(bool enable)\n{\n    m_busyTrace = enable;\n}\n\nbool AbstractHandle::isBusyTraceEnable() const\n{\n    return m_busyTrace;\n}\n\nvoid AbstractHandle::setCurrentSQL(const UnsafeStringView &sql)\n{\n    if (m_currentSQL.data() == sql.data()) {\n        return;\n    }\n    std::unique_lock<std::mutex> lockGuard(m_lock);\n    m_currentSQL = sql;\n}\n\nvoid AbstractHandle::resetCurrentSQL(const UnsafeStringView &sql)\n{\n    if (m_currentSQL.data() != sql.data()) {\n        return;\n    }\n    std::unique_lock<std::mutex> lockGuard(m_lock);\n    m_currentSQL.clear();\n}\n\nStringView AbstractHandle::getCurrentSQL() const\n{\n    std::unique_lock<std::mutex> lockGuard(m_lock);\n    return m_currentSQL;\n}\n\nvoid AbstractHandle::setActiveThreadId(uint64_t tid)\n{\n    m_tid = tid;\n}\n\nbool AbstractHandle::isUsingInThread(uint64_t tid) const\n{\n    return m_tid == tid;\n}\n\n#pragma mark - Error\nbool AbstractHandle::APIExit(int rc)\n{\n    return APIExit(rc, nullptr);\n}\n\nbool AbstractHandle::APIExit(int rc, const UnsafeStringView &sql)\n{\n    return APIExit(rc, sql.data());\n}\n\nbool AbstractHandle::APIExit(int rc, const char *sql)\n{\n    bool result = true;\n    if (Error::isError(rc)) {\n        notifyError(rc, sql);\n        result = false;\n    }\n    return result;\n}\n\nvoid AbstractHandle::notifyError(Error::Code rc, const UnsafeStringView &sql, const UnsafeStringView &msg)\n{\n    notifyError((int) rc, sql, msg);\n}\n\nvoid AbstractHandle::notifyError(int rc, const UnsafeStringView &sql, const UnsafeStringView &msg)\n{\n    WCTAssert(Error::isError(rc));\n    Error::Code code = Error::rc2c(rc);\n    if (code == Error::Code::ZstdError) {\n        m_error.setCode(code, !msg.empty() ? msg : sqlite3_errmsg(m_handle));\n        m_error.infos.insert_or_assign(ErrorStringKeySource, ErrorSourceZstd);\n    } else if (code != Error::Code::Misuse && sqlite3_errcode(m_handle) == rc\n               && msg.empty()) {\n        m_error.setSQLiteCode(rc, sqlite3_errmsg(m_handle));\n    } else {\n        // extended error code/message will not be set in some case for misuse error\n        m_error.setSQLiteCode(rc, msg);\n    }\n    if (std::find(m_ignorableCodes.begin(), m_ignorableCodes.end(), rc)\n        == m_ignorableCodes.end()) {\n        m_error.level = Error::Level::Error;\n        if (code == Error::Code::Warning) {\n            m_error.level = Error::Level::Warning;\n        } else if (code == Error::Code::Notice) {\n            m_error.level = Error::Level::Notice;\n        } else if (m_transactionError != TransactionError::Allowed) {\n            m_transactionError = TransactionError::Fatal;\n        }\n    } else {\n        m_error.level = Error::Level::Ignore;\n    }\n    if (!sql.empty()) {\n        m_error.infos.insert_or_assign(ErrorStringKeySQL, sql);\n    } else {\n        m_error.infos.erase(ErrorStringKeySQL);\n    }\n    if (m_error.level >= Error::Level::Error && m_threadErrorProne != nullptr) {\n        m_threadErrorProne->setThreadedError(m_error);\n    }\n    Notifier::shared().notify(m_error);\n}\n\nvoid AbstractHandle::markErrorAsIgnorable(Error::Code ignorableCode)\n{\n    m_ignorableCodes.emplace_back((int) ignorableCode);\n}\n\nvoid AbstractHandle::markErrorAsUnignorable(int count)\n{\n    while (!m_ignorableCodes.empty() && count > 0) {\n        m_ignorableCodes.pop_back();\n        --count;\n    }\n}\n\nvoid AbstractHandle::setThreadedErrorProne(ThreadedErrorProne *threadedErrorProne)\n{\n    m_threadErrorProne = threadedErrorProne;\n}\n\n#pragma mark - Suspend\nvoid AbstractHandle::suspend(bool suspend)\n{\n    doSuspend(suspend && m_canBeSuspended);\n}\n\nvoid AbstractHandle::markAsCanBeSuspended(bool canBeSuspended)\n{\n    if (canBeSuspended && !m_canBeSuspended) {\n        markErrorAsIgnorable(Error::Code::Interrupt);\n    }\n    if (!(m_canBeSuspended = canBeSuspended)) {\n        doSuspend(false);\n    }\n}\n\nvoid AbstractHandle::doSuspend(bool suspend)\n{\n    if (isOpened()) {\n        sqlite3_suspend(m_handle, suspend);\n    }\n}\n\nbool AbstractHandle::isSuspended() const\n{\n    return sqlite3_is_suspended(m_handle);\n}\n\n#pragma mark - Cancellation Signal\nvoid AbstractHandle::attachCancellationSignal(CancellationSignal signal)\n{\n    WCTAssert(isOpened());\n    m_cancelSignal = signal;\n    sqlite3_progress_handler(m_handle, 4, AbstractHandle::progressHandlerCallback, this);\n}\n\nvoid AbstractHandle::detachCancellationSignal()\n{\n    if (m_cancelSignal == nullptr) {\n        return;\n    }\n    sqlite3_progress_handler(m_handle, 0, nullptr, nullptr);\n    m_cancelSignal = nullptr;\n}\n\nint AbstractHandle::progressHandlerCallback(void *ctx)\n{\n    AbstractHandle *handle = static_cast<AbstractHandle *>(ctx);\n    WCTAssert(handle->m_cancelSignal != nullptr);\n    return *(handle->m_cancelSignal);\n}\n\n#pragma mark - Cipher\n\nvoid *AbstractHandle::getCipherContext()\n{\n    WCTAssert(isOpened());\n    return sqlite3_getCipherContext(m_handle, Schema::main().getDescription().data());\n}\n\nsize_t AbstractHandle::getCipherPageSize()\n{\n    WCTAssert(isOpened());\n    HandleStatement handleStatement(this);\n    Statement cipherPageSize = StatementPragma().pragma(Pragma::cipherPageSize());\n    size_t size = 0;\n    if (handleStatement.prepare(cipherPageSize) && handleStatement.step()) {\n        size = handleStatement.getInteger();\n    }\n    handleStatement.finalize();\n    return size;\n}\n\nbool AbstractHandle::setCipherKey(const UnsafeData &data)\n{\n    WCTAssert(isOpened());\n    return APIExit(sqlite3_key(m_handle, data.buffer(), (int) data.size()));\n}\n\nData AbstractHandle::getRawCipherKey(const Schema &schema)\n{\n    WCTAssert(isOpened());\n    void *rawCipher = NULL;\n    int rawCipherSize = 0;\n    int index = sqlcipher_find_db_index(m_handle, schema.syntax().name.data());\n    sqlite3CodecGetKey(m_handle, index, &rawCipher, &rawCipherSize);\n\n    if (rawCipher == NULL || rawCipherSize == 0) {\n        return Data();\n    }\n    WCTAssert(rawCipherSize == 99);\n    return Data((unsigned char *) rawCipher, rawCipherSize);\n}\n\nbool AbstractHandle::hasCipher() const\n{\n    WCTAssert(isOpened());\n    void *rawCipher = NULL;\n    int rawCipherSize = 0;\n    int index = sqlcipher_find_db_index(m_handle, \"main\");\n    sqlite3CodecGetKey(m_handle, index, &rawCipher, &rawCipherSize);\n\n    if (rawCipher == NULL || rawCipherSize == 0) {\n        return false;\n    }\n    return true;\n}\n\nbool AbstractHandle::setCipherPageSize(int pageSize)\n{\n    WCTAssert(isOpened());\n    HandleStatement handleStatement(this);\n    Statement cipherPageSize\n    = StatementPragma().pragma(Pragma::cipherPageSize()).to(pageSize);\n    bool succeed = handleStatement.prepare(cipherPageSize) && handleStatement.step();\n    handleStatement.finalize();\n    return succeed;\n}\n\nStringView AbstractHandle::getCipherSalt()\n{\n    WCTAssert(isOpened());\n    HandleStatement handleStatement(this);\n    Statement cipherSalt = StatementPragma().pragma(Pragma::cipherSalt());\n    StringView salt;\n    if (handleStatement.prepare(cipherSalt) && handleStatement.step()\n        && !handleStatement.done()) {\n        salt = handleStatement.getText();\n    }\n    handleStatement.finalize();\n    return salt;\n}\nbool AbstractHandle::setCipherSalt(const UnsafeStringView &salt)\n{\n    WCTAssert(isOpened());\n    HandleStatement handleStatement(this);\n    StatementPragma cipherSalt = StatementPragma().pragma(Pragma::cipherSalt());\n    if (salt.length() == 32 && !salt.hasPrefix(\"x'\")) {\n        cipherSalt.to(StringView::formatted(\"x'%s'\", salt.data()));\n    } else {\n        cipherSalt.to(salt);\n    }\n    bool succeed = handleStatement.prepare(cipherSalt) && handleStatement.step();\n    handleStatement.finalize();\n    return succeed;\n}\n\nvoid AbstractHandle::tryPreloadAllPages()\n{\n    sqlite3_preload_pages_to_cache(m_handle);\n}\n\nvoid AbstractHandle::setFileChunkSize(int size)\n{\n    WCTAssert(isOpened());\n    if (size < SQLITE_DEFAULT_PAGE_SIZE) {\n        return;\n    }\n    size = size / SQLITE_DEFAULT_PAGE_SIZE * SQLITE_DEFAULT_PAGE_SIZE;\n    sqlite3_file_control(\n    m_handle, Syntax::mainSchema.data(), SQLITE_FCNTL_CHUNK_SIZE, &size);\n}\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/common/core/sqlite/AbstractHandle.hpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/19\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"ColumnMeta.hpp\"\n#include \"DecorativeHandleStatement.hpp\"\n#include \"ErrorProne.hpp\"\n#include \"HandleNotification.hpp\"\n#include \"StringView.hpp\"\n#include \"TableAttribute.hpp\"\n#include \"Tag.hpp\"\n#include \"WCDBOptional.hpp\"\n#include \"WINQ.h\"\n#include <set>\n#include <tuple>\n#include <vector>\n\nnamespace WCDB {\n\nclass ScalarFunctionConfig;\n\nclass AbstractHandle : public ErrorProne {\n#pragma mark - Initialize\npublic:\n    AbstractHandle();\n\n    AbstractHandle(const AbstractHandle &) = delete;\n    AbstractHandle &operator=(const AbstractHandle &) = delete;\n    virtual ~AbstractHandle() override = 0;\n\nprivate:\n    friend class ScalarFunctionConfig;\n    friend class HandleRelated;\n    sqlite3 *getRawHandle();\n    sqlite3 *m_handle;\n\n#pragma mark - Path\npublic:\n    void setPath(const UnsafeStringView &path);\n    void clearPath();\n    const StringView &getPath() const;\n\n    static StringView shmPathOfDatabase(const UnsafeStringView &database);\n    static StringView walPathOfDatabase(const UnsafeStringView &database);\n    static StringView journalPathOfDatabase(const UnsafeStringView &database);\n\nprivate:\n    StringView m_path;\n\n#pragma mark - Basic\npublic:\n    virtual bool open();\n    virtual void close();\n    bool isOpened() const;\n\n    void enableWriteMainDB(bool enable);\n    bool canWriteMainDB();\n    void setLiteModeEnable(bool enable);\n    bool liteModeEnable() const;\n\n    long long getLastInsertedRowID();\n    //    const char *getErrorMessage();\n    //    Error::ExtCode getExtendedErrorCode();\n    //    Error::Code getResultCode();\n    int getChanges();\n    int getTotalChange();\n    void setReadOnly();\n    bool isReadonly();\n    bool isInTransaction();\n\n    void setTag(Tag tag);\n    Tag getTag();\n\n    bool executeStatement(const Statement &statement);\n    bool executeSQL(const UnsafeStringView &sql);\n\nprotected:\n    int m_customOpenFlag;\n    Tag m_tag;\n    bool m_enableLiteMode = false;\n    bool m_isReadOnly = false;\n\n#pragma mark - Statement\npublic:\n    virtual DecorativeHandleStatement *\n    getStatement(const UnsafeStringView &skipDecorator = UnsafeStringView());\n    virtual void returnStatement(HandleStatement *handleStatement);\n    virtual void resetAllStatements();\n    virtual void finalizeStatements();\n    HandleStatement *getOrCreatePreparedStatement(const Statement &statement);\n    HandleStatement *getOrCreatePreparedStatement(const UnsafeStringView &sql);\n\n    HandleStatement *prepareNewStatement(const Statement &statement);\n    HandleStatement *prepareNewStatement(const UnsafeStringView &sql);\n    void finalizeAndReturnPreparedStatement(HandleStatement *handleStatement);\n\nprivate:\n    HandleStatement *getOrCreateStatement(const UnsafeStringView &sql);\n    std::list<DecorativeHandleStatement> m_handleStatements;\n    StringViewMap<DecorativeHandleStatement *> m_preparedStatements;\n\n#pragma mark - Meta\npublic:\n    Optional<bool> ft3TokenizerExists(const UnsafeStringView &tokenizer);\n\n    Optional<bool> tableExists(const UnsafeStringView &table);\n    Optional<bool> tableExists(const Schema &schema, const UnsafeStringView &table);\n\n    virtual bool\n    addColumn(const Schema &schema, const UnsafeStringView &table, const ColumnDef &column);\n\n    virtual Optional<StringViewSet>\n    getColumns(const Schema &schema, const UnsafeStringView &table);\n\n    Optional<std::vector<ColumnMeta>>\n    getTableMeta(const Schema &schema, const UnsafeStringView &table);\n    Optional<StringViewSet> getValues(const Statement &statement, int index);\n    Optional<TableAttribute>\n    getTableAttribute(const Schema &schema, const UnsafeStringView &tableName);\n    bool configAutoIncrement(const UnsafeStringView &tableName);\n\n    bool getSchemaInfo(int &memoryUsed, int &tableCount, int &indexCount, int &triggerCount);\n\n#pragma mark - Transaction\npublic:\n    virtual bool beginTransaction();\n    bool commitOrRollbackTransaction();\n    virtual bool commitTransaction();\n    virtual void rollbackTransaction();\n\n    void markErrorNotAllowedWithinTransaction();\n    bool isErrorAllowedWithinTransaction() const;\n    bool checkMainThreadBusyRetry() const;\n\nprotected:\n    void cacheCurrentTransactionError();\n    void resumeCacheTransactionError();\n\nprivate:\n    int m_transactionLevel;\n    enum class TransactionError {\n        Allowed,\n        NotAllowed,\n        Fatal,\n    } m_transactionError;\n    TransactionError m_cacheTransactionError;\n    static StringView getSavepointName(int transactionLevel);\n\n#pragma mark - Wal\npublic:\n    void enableExtendedResultCodes(bool enable);\n\n    enum class CheckpointMode {\n        Passive = 0,\n        Full,\n        Restart,\n        Truncate,\n    };\n    bool checkpoint(CheckpointMode mode = CheckpointMode::Passive);\n    void disableCheckpointWhenClosing(bool disable);\n    void setWALFilePersist(int persist);\n    bool setCheckPointLock(bool enable);\n\n#pragma mark - Notification\npublic:\n    typedef HandleNotification::PerformanceInfo PerformanceInfo;\n    typedef HandleNotification::PerformanceNotification PerformanceNotification;\n    void setNotificationWhenPerformanceTraced(const UnsafeStringView &name,\n                                              const PerformanceNotification &onTraced);\n\n    typedef HandleNotification::SQLNotification SQLNotification;\n    void setNotificationWhenSQLTraced(const UnsafeStringView &name,\n                                      const SQLNotification &onTraced);\n\n    typedef HandleNotification::CommittedNotification CommittedNotification;\n    void setNotificationWhenCommitted(int order,\n                                      const UnsafeStringView &name,\n                                      const CommittedNotification &onCommitted);\n\n    typedef HandleNotification::CheckPointNotification CheckPointNotification;\n    void setNotificationWhenCheckpointed(const UnsafeStringView &name,\n                                         Optional<CheckPointNotification> notification);\n    void unsetNotificationWhenCommitted(const UnsafeStringView &name);\n\n    typedef HandleNotification::BusyNotification BusyNotification;\n    void setNotificationWhenBusy(const BusyNotification &busyNotification);\n\n    typedef HandleNotification::TableModifiedNotification TableModifiedNotification;\n    void setNotificationWhenTableModified(const UnsafeStringView &name,\n                                          const TableModifiedNotification &tableModifiedNotification);\n\n    void postTableNotification(const UnsafeStringView &newTable,\n                               const UnsafeStringView &modifiedTable);\n    bool needMonitorTable();\n    void setTableMonitorEnable(bool enable);\n\n    void setFullSQLTraceEnable(bool enable);\n    bool isFullSQLEnable();\n    void postSQLNotification(const UnsafeStringView &sql, const UnsafeStringView &info);\n\n    void setBusyTraceEnable(bool enable);\n    bool isBusyTraceEnable() const;\n    void setCurrentSQL(const UnsafeStringView &sql);\n    void resetCurrentSQL(const UnsafeStringView &sql);\n    StringView getCurrentSQL() const;\n    void setActiveThreadId(uint64_t tid);\n    bool isUsingInThread(uint64_t tid) const;\n\nprivate:\n    HandleNotification m_notification;\n    bool m_tableMonitorForbidden;\n    bool m_fullSQLTrace;\n    mutable std::mutex m_lock;\n    bool m_busyTrace;\n    StringView m_currentSQL;\n    uint64_t m_tid;\n\n#pragma mark - Error\npublic:\n    void notifyError(Error::Code rc,\n                     const UnsafeStringView &sql,\n                     const UnsafeStringView &msg = UnsafeStringView());\n    void notifyError(int rc,\n                     const UnsafeStringView &sql,\n                     const UnsafeStringView &msg = UnsafeStringView());\n    // call it as push/pop in stack structure.\n    void markErrorAsIgnorable(Error::Code ignorableCode);\n    void markErrorAsUnignorable(int count = 1);\n    void setThreadedErrorProne(ThreadedErrorProne *threadedErrorProne);\n\nprivate:\n    // The level of error will be \"Ignore\" if it's marked as ignorable.\n    // But the return value will be still false.\n    bool APIExit(int rc);\n    bool APIExit(int rc, const UnsafeStringView &sql);\n    bool APIExit(int rc, const char *sql);\n\n    ThreadedErrorProne *m_threadErrorProne;\n    std::vector<int> m_ignorableCodes;\n\n#pragma mark - Suspend\npublic:\n    void suspend(bool suspend);                     // thread-safe\n    void markAsCanBeSuspended(bool canBeSuspended); // thread-safe, default to false\n    bool isSuspended() const;\n\nprotected:\n    virtual void doSuspend(bool suspend);\n\nprivate:\n    std::atomic<bool> m_canBeSuspended;\n\n#pragma mark - Cancellation Signal\npublic:\n    typedef std::shared_ptr<volatile bool> CancellationSignal;\n    void attachCancellationSignal(CancellationSignal signal);\n    void detachCancellationSignal();\n\nprivate:\n    static int progressHandlerCallback(void *ctx);\n    CancellationSignal m_cancelSignal;\n\n#pragma mark - Cipher\npublic:\n    size_t getCipherPageSize();\n    void *getCipherContext();\n    virtual bool setCipherKey(const UnsafeData &data);\n    Data getRawCipherKey(const Schema &schema = Schema::main());\n    bool hasCipher() const;\n    bool setCipherPageSize(int pageSize);\n    StringView getCipherSalt();\n    bool setCipherSalt(const UnsafeStringView &salt);\n\n#pragma mark - Extra\npublic:\n    void tryPreloadAllPages();\n    void setFileChunkSize(int size);\n};\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/common/core/sqlite/ColumnMeta.cpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/19\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"ColumnMeta.hpp\"\n\nnamespace WCDB {\n\nColumnMeta::ColumnMeta(int64_t id_, StringView name_, StringView type_, bool notnull_, int64_t primary_)\n: id(id_), name(name_), type(type_), notnull(notnull_), primary(primary_)\n{\n}\n\nint64_t ColumnMeta::getIndexOfIntegerPrimary(const std::vector<ColumnMeta>& columnMetas)\n{\n    int64_t indexOfIntegerPrimary = -1;\n    size_t size = columnMetas.size();\n    for (size_t i = 0; i < size; ++i) {\n        int64_t pk = columnMetas[i].primary;\n        if (pk > 0) {\n            if (pk > 1) {\n                // multi-primary is existsing\n                return -1;\n            } else if (Syntax::isIntegerColumnType(columnMetas[i].type)) {\n                indexOfIntegerPrimary = (int64_t) i;\n            }\n        }\n    }\n    return indexOfIntegerPrimary;\n}\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/core/sqlite/ColumnMeta.hpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/19\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"StringView.hpp\"\n#include \"WINQ.h\"\n#include <vector>\n\nnamespace WCDB {\n\nclass ColumnMeta {\npublic:\n    ColumnMeta(int64_t id_, StringView name_, StringView type_, bool notnull_, int64_t primary_);\n\n    int64_t id;\n    StringView name;\n    StringView type;\n    bool notnull;\n    int64_t primary;\n\n    static int64_t getIndexOfIntegerPrimary(const std::vector<ColumnMeta>& columnMetas);\n};\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/core/sqlite/DecorativeHandle.cpp",
    "content": "//\n// Created by qiuwenchen on 2023/11/15.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"DecorativeHandle.hpp\"\n\nnamespace WCDB {\n\n#pragma mark - HandleDecorator\nDecorativeHandle *HandleDecorator::getHandle() const\n{\n    return static_cast<DecorativeHandle *>(m_decoratedObj);\n}\n\nOptional<StringViewSet>\nHandleDecorator::getColumns(const Schema &schema, const UnsafeStringView &table)\n{\n    return WCDBCallDecoratedFunction(InnerHandle, getColumns, schema, table);\n}\n\nbool HandleDecorator::addColumn(const Schema &schema,\n                                const UnsafeStringView &table,\n                                const ColumnDef &column)\n{\n    return WCDBCallDecoratedFunction(InnerHandle, addColumn, schema, table, column);\n}\n\nbool HandleDecorator::commitTransaction()\n{\n    return WCDBCallDecoratedFunction(InnerHandle, commitTransaction);\n}\n\nvoid HandleDecorator::rollbackTransaction()\n{\n    WCDBCallDecoratedFunction(InnerHandle, rollbackTransaction);\n}\n\nDecorativeHandleStatement *HandleDecorator::getStatement(const UnsafeStringView &skipDecorator)\n{\n    return WCDBCallDecoratedFunction(InnerHandle, getStatement, skipDecorator);\n}\n\nvoid HandleDecorator::finalizeStatements()\n{\n    WCDBCallDecoratedFunction(InnerHandle, finalizeStatements);\n}\n\n#pragma mark - DecorativeHandle\n\nvoid DecorativeHandle::onDecorationChange()\n{\n    m_mainStatement->finalize();\n    returnStatement(m_mainStatement);\n    m_mainStatement = getStatement();\n    for (auto iter : m_operators) {\n        iter.second->onDecorationChange();\n    }\n}\n\nvoid DecorativeHandle::initDecorativeFunctions()\n{\n    WCDBRegisterDecorativeFunction(InnerHandle, getColumns);\n    WCDBRegisterDecorativeFunction(InnerHandle, addColumn);\n    WCDBRegisterDecorativeFunction(InnerHandle, commitTransaction);\n    WCDBRegisterDecorativeFunction(InnerHandle, rollbackTransaction);\n    WCDBRegisterDecorativeFunction(InnerHandle, getStatement);\n    WCDBRegisterDecorativeFunction(InnerHandle, finalizeStatements);\n}\n\nOptional<StringViewSet>\nDecorativeHandle::getColumns(const Schema &schema, const UnsafeStringView &table)\n{\n    return WCDBCallDecorativeFunction(InnerHandle, getColumns, schema, table);\n}\n\nbool DecorativeHandle::addColumn(const Schema &schema,\n                                 const UnsafeStringView &table,\n                                 const ColumnDef &column)\n{\n    return WCDBCallDecorativeFunction(InnerHandle, addColumn, schema, table, column);\n}\n\nbool DecorativeHandle::commitTransaction()\n{\n    return WCDBCallDecorativeFunction(InnerHandle, commitTransaction);\n}\n\nvoid DecorativeHandle::rollbackTransaction()\n{\n    WCDBCallDecorativeFunction(InnerHandle, rollbackTransaction);\n}\n\nDecorativeHandleStatement *DecorativeHandle::getStatement(const UnsafeStringView &skipDecorator)\n{\n    return WCDBCallDecorativeFunction(InnerHandle, getStatement, skipDecorator);\n}\n\nvoid DecorativeHandle::finalizeStatements()\n{\n    WCDBCallDecorativeFunction(InnerHandle, finalizeStatements);\n}\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/common/core/sqlite/DecorativeHandle.hpp",
    "content": "//\n// Created by qiuwenchen on 2023/11/15.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"ClassDecorator.hpp\"\n#include \"DecorativeHandleStatement.hpp\"\n#include \"HandleOperator.hpp\"\n#include \"InnerHandle.hpp\"\n\nnamespace WCDB {\n\nenum class HandleFuncType : unsigned char {\n    getColumns = 0,\n    addColumn,\n    commitTransaction,\n    rollbackTransaction,\n    getStatement,\n    finalizeStatements,\n    Count,\n};\n\nclass DecorativeHandle;\n\nclass HandleDecorator\n: public ClassDecorator<HandleFuncType, (unsigned char) HandleFuncType::Count> {\npublic:\n    DecorativeHandle *getHandle() const;\n\n    virtual Optional<StringViewSet>\n    getColumns(const Schema &schema, const UnsafeStringView &table);\n    WCDBAssertFunctionTypeConsistent(HandleDecorator, InnerHandle, getColumns);\n\n    virtual bool\n    addColumn(const Schema &schema, const UnsafeStringView &table, const ColumnDef &column);\n    WCDBAssertFunctionTypeConsistent(HandleDecorator, InnerHandle, addColumn);\n\n    virtual bool commitTransaction();\n    WCDBAssertFunctionTypeConsistent(HandleDecorator, InnerHandle, commitTransaction);\n\n    virtual void rollbackTransaction();\n    WCDBAssertFunctionTypeConsistent(HandleDecorator, InnerHandle, rollbackTransaction);\n\n    virtual DecorativeHandleStatement *\n    getStatement(const UnsafeStringView &skipDecorator = UnsafeStringView());\n    WCDBAssertFunctionTypeConsistent(HandleDecorator, InnerHandle, getStatement);\n\n    virtual void finalizeStatements();\n    WCDBAssertFunctionTypeConsistent(HandleDecorator, InnerHandle, finalizeStatements);\n};\n\nclass DecorativeHandle\n: public DecorativeClass<HandleFuncType, (unsigned char) HandleFuncType::Count>,\n  public InnerHandle {\nprivate:\n    using Super = InnerHandle;\n    using SuperDecorativeClass\n    = DecorativeClass<HandleFuncType, (unsigned char) HandleFuncType::Count>;\n\n#pragma mark - Decoration\npublic:\n    void onDecorationChange() override final;\n    void initDecorativeFunctions() override final;\n\n#pragma mark - Operator\npublic:\n    template<typename Operator, typename... Args>\n    Operator &getOrCreateOperator(const UnsafeStringView &name, const Args &...args)\n    {\n        static_assert(std::is_base_of<HandleOperator, Operator>::value, \"\");\n        auto iter = m_operators.find(name);\n        if (iter != m_operators.end()) {\n            return *(static_cast<Operator *>(iter->second.get()));\n        } else {\n            std::shared_ptr<HandleOperator> newOperator\n            = std::make_shared<Operator>(this, args...);\n            m_operators.emplace(name, newOperator);\n            return *(static_cast<Operator *>(newOperator.get()));\n        }\n    }\n\nprivate:\n    StringViewMap<std::shared_ptr<HandleOperator>> m_operators;\n\n#pragma mark - Override\npublic:\n    Optional<StringViewSet>\n    getColumns(const Schema &schema, const UnsafeStringView &table) override final;\n    bool addColumn(const Schema &schema,\n                   const UnsafeStringView &table,\n                   const ColumnDef &column) override final;\n\n    bool commitTransaction() override final;\n    void rollbackTransaction() override final;\n    DecorativeHandleStatement *getStatement(const UnsafeStringView &skipDecorator\n                                            = UnsafeStringView()) override final;\n    void finalizeStatements() override final;\n};\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/core/sqlite/DecorativeHandleStatement.cpp",
    "content": "//\n// Created by qiuwenchen on 2023/11/14.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"DecorativeHandleStatement.hpp\"\n\nnamespace WCDB {\n\n#pragma mark - HandleStatementDecorator\nDecorativeHandleStatement *HandleStatementDecorator::getHandleStatement() const\n{\n    return static_cast<DecorativeHandleStatement *>(m_decoratedObj);\n}\n\nAbstractHandle *HandleStatementDecorator::getHandle() const\n{\n    return getHandleStatement()->getHandle();\n}\n\nbool HandleStatementDecorator::prepare(const Statement &statement)\n{\n    return WCDBCallDecoratedFunction(HandleStatement, prepare, statement);\n}\n\nvoid HandleStatementDecorator::finalize()\n{\n    WCDBCallDecoratedFunction(HandleStatement, finalize);\n}\n\nbool HandleStatementDecorator::step()\n{\n    return WCDBCallDecoratedFunction(HandleStatement, step);\n}\n\nvoid HandleStatementDecorator::reset()\n{\n    WCDBCallDecoratedFunction(HandleStatement, reset);\n}\n\nvoid HandleStatementDecorator::clearBindings()\n{\n    WCDBCallDecoratedFunction(HandleStatement, clearBindings);\n}\n\nvoid HandleStatementDecorator::bindInteger(const Integer &value, int index)\n{\n    WCDBCallDecoratedFunction(HandleStatement, bindInteger, value, index);\n}\n\nvoid HandleStatementDecorator::bindDouble(const Float &value, int index)\n{\n    WCDBCallDecoratedFunction(HandleStatement, bindDouble, value, index);\n}\n\nvoid HandleStatementDecorator::bindText(const Text &value, int index)\n{\n    WCDBCallDecoratedFunction(HandleStatement, bindText, value, index);\n}\n\nvoid HandleStatementDecorator::bindText16(const char16_t *value, size_t valueLength, int index)\n{\n    WCDBCallDecoratedFunction(HandleStatement, bindText16, value, valueLength, index);\n}\n\nvoid HandleStatementDecorator::bindBLOB(const BLOB &value, int index)\n{\n    WCDBCallDecoratedFunction(HandleStatement, bindBLOB, value, index);\n}\n\nvoid HandleStatementDecorator::bindNull(int index)\n{\n    WCDBCallDecoratedFunction(HandleStatement, bindNull, index);\n}\n\nvoid HandleStatementDecorator::bindPointer(void *ptr,\n                                           int index,\n                                           const Text &type,\n                                           void (*destructor)(void *))\n{\n    WCDBCallDecoratedFunction(HandleStatement, bindPointer, ptr, index, type, destructor);\n}\n\n#pragma mark - DecorativeHandleStatement - Basic\nDecorativeHandleStatement::DecorativeHandleStatement(DecorativeHandleStatement &&other)\n: HandleStatement(std::move(other)), SuperDecorativeClass(std::move(other))\n{\n}\n\nDecorativeHandleStatement::DecorativeHandleStatement(AbstractHandle *handle)\n: HandleStatement(handle), SuperDecorativeClass()\n{\n}\n\nDecorativeHandleStatement::~DecorativeHandleStatement() = default;\n\n#pragma mark - Decoration\n\nvoid DecorativeHandleStatement::initDecorativeFunctions()\n{\n    WCDBRegisterDecorativeFunction(HandleStatement, prepare);\n    WCDBRegisterDecorativeFunction(HandleStatement, finalize);\n    WCDBRegisterDecorativeFunction(HandleStatement, step);\n    WCDBRegisterDecorativeFunction(HandleStatement, reset);\n    WCDBRegisterDecorativeFunction(HandleStatement, clearBindings);\n    WCDBRegisterDecorativeFunction(HandleStatement, bindInteger);\n    WCDBRegisterDecorativeFunction(HandleStatement, bindDouble);\n    WCDBRegisterDecorativeFunction(HandleStatement, bindText);\n    WCDBRegisterDecorativeFunction(HandleStatement, bindText16);\n    WCDBRegisterDecorativeFunction(HandleStatement, bindBLOB);\n    WCDBRegisterDecorativeFunction(HandleStatement, bindNull);\n    WCDBRegisterDecorativeFunction(HandleStatement, bindPointer);\n}\n\n#pragma mark - DecorativeHandleStatement - Override\nbool DecorativeHandleStatement::prepare(const Statement &statement)\n{\n    if (!WCDBCallDecorativeFunction(HandleStatement, prepare, statement)) {\n        finalize();\n        return false;\n    }\n    return true;\n}\n\nvoid DecorativeHandleStatement::finalize()\n{\n    WCDBCallDecorativeFunction(HandleStatement, finalize);\n}\n\nbool DecorativeHandleStatement::step()\n{\n    return WCDBCallDecorativeFunction(HandleStatement, step);\n}\n\nvoid DecorativeHandleStatement::reset()\n{\n    WCDBCallDecorativeFunction(HandleStatement, reset);\n}\n\nvoid DecorativeHandleStatement::clearBindings()\n{\n    WCDBCallDecorativeFunction(HandleStatement, clearBindings);\n}\n\nvoid DecorativeHandleStatement::bindInteger(const Integer &value, int index)\n{\n    WCDBCallDecorativeFunction(HandleStatement, bindInteger, value, index);\n}\n\nvoid DecorativeHandleStatement::bindDouble(const Float &value, int index)\n{\n    WCDBCallDecorativeFunction(HandleStatement, bindDouble, value, index);\n}\n\nvoid DecorativeHandleStatement::bindText(const Text &value, int index)\n{\n    WCDBCallDecorativeFunction(HandleStatement, bindText, value, index);\n}\n\nvoid DecorativeHandleStatement::bindText16(const char16_t *value, size_t valueLength, int index)\n{\n    WCDBCallDecorativeFunction(HandleStatement, bindText16, value, valueLength, index);\n}\n\nvoid DecorativeHandleStatement::bindBLOB(const BLOB &value, int index)\n{\n    WCDBCallDecorativeFunction(HandleStatement, bindBLOB, value, index);\n}\n\nvoid DecorativeHandleStatement::bindNull(int index)\n{\n    WCDBCallDecorativeFunction(HandleStatement, bindNull, index);\n}\n\nvoid DecorativeHandleStatement::bindPointer(void *ptr,\n                                            int index,\n                                            const Text &type,\n                                            void (*destructor)(void *))\n{\n    WCDBCallDecorativeFunction(HandleStatement, bindPointer, ptr, index, type, destructor);\n}\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/common/core/sqlite/DecorativeHandleStatement.hpp",
    "content": "//\n// Created by qiuwenchen on 2023/11/14.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"ClassDecorator.hpp\"\n#include \"HandleStatement.hpp\"\n\nnamespace WCDB {\n\nenum class HandleStatementFuncType : unsigned char {\n    prepare = 0,\n    finalize,\n    step,\n    reset,\n    clearBindings,\n    bindInteger,\n    bindDouble,\n    bindText,\n    bindText16,\n    bindBLOB,\n    bindNull,\n    bindPointer,\n    Count,\n};\n\nclass DecorativeHandleStatement;\n\nclass HandleStatementDecorator\n: public ClassDecorator<HandleStatementFuncType, (unsigned char) HandleStatementFuncType::Count> {\npublic:\n    AbstractHandle *getHandle() const;\n    DecorativeHandleStatement *getHandleStatement() const;\n\n    using Integer = HandleStatement::Integer;\n    using Text = HandleStatement::Text;\n    using Float = HandleStatement::Float;\n    using BLOB = HandleStatement::BLOB;\n\n    virtual bool prepare(const Statement &statement);\n    WCDBAssertFunctionTypeConsistent(HandleStatementDecorator, HandleStatement, prepare);\n\n    virtual void finalize();\n    WCDBAssertFunctionTypeConsistent(HandleStatementDecorator, HandleStatement, finalize)\n\n    virtual bool step();\n    WCDBAssertFunctionTypeConsistent(HandleStatementDecorator, HandleStatement, step);\n\n    virtual void reset();\n    WCDBAssertFunctionTypeConsistent(HandleStatementDecorator, HandleStatement, reset);\n\n    virtual void clearBindings();\n    WCDBAssertFunctionTypeConsistent(HandleStatementDecorator, HandleStatement, clearBindings);\n\n    virtual void bindInteger(const Integer &value, int index);\n    WCDBAssertFunctionTypeConsistent(HandleStatementDecorator, HandleStatement, bindInteger);\n\n    virtual void bindDouble(const Float &value, int index);\n    WCDBAssertFunctionTypeConsistent(HandleStatementDecorator, HandleStatement, bindDouble);\n\n    virtual void bindText(const Text &value, int index);\n    WCDBAssertFunctionTypeConsistent(HandleStatementDecorator, HandleStatement, bindText);\n\n    virtual void bindText16(const char16_t *value, size_t valueLength, int index);\n    WCDBAssertFunctionTypeConsistent(HandleStatementDecorator, HandleStatement, bindText16);\n\n    virtual void bindBLOB(const BLOB &value, int index);\n    WCDBAssertFunctionTypeConsistent(HandleStatementDecorator, HandleStatement, bindText16);\n\n    virtual void bindNull(int index);\n    WCDBAssertFunctionTypeConsistent(HandleStatementDecorator, HandleStatement, bindNull);\n\n    virtual void\n    bindPointer(void *ptr, int index, const Text &type, void (*destructor)(void *));\n    WCDBAssertFunctionTypeConsistent(HandleStatementDecorator, HandleStatement, bindPointer);\n};\n\nclass DecorativeHandleStatement final\n: public HandleStatement,\n  public DecorativeClass<HandleStatementFuncType, (unsigned char) HandleStatementFuncType::Count> {\nprivate:\n    using Super = HandleStatement;\n    using SuperDecorativeClass\n    = DecorativeClass<HandleStatementFuncType, (unsigned char) HandleStatementFuncType::Count>;\n\n#pragma mark - Basic\npublic:\n    DecorativeHandleStatement(AbstractHandle *handle);\n    DecorativeHandleStatement() = delete;\n    DecorativeHandleStatement(const DecorativeHandleStatement &) = delete;\n    DecorativeHandleStatement &operator=(const DecorativeHandleStatement &) = delete;\n    DecorativeHandleStatement(DecorativeHandleStatement &&other);\n    ~DecorativeHandleStatement() override;\n\n#pragma mark - Decoration\npublic:\n    void initDecorativeFunctions() override final;\n\n#pragma mark - Override\npublic:\n    bool prepare(const Statement &statement) override final;\n    void finalize() override final;\n    bool step() override final;\n    void reset() override final;\n    void clearBindings() override final;\n\n    void bindInteger(const Integer &value, int index = 1) override final;\n    void bindDouble(const Float &value, int index = 1) override final;\n    void bindText(const Text &value, int index = 1) override final;\n    void bindText16(const char16_t *value, size_t valueLength, int index = 1) override final;\n    void bindBLOB(const BLOB &value, int index = 1) override final;\n    void bindNull(int index) override final;\n    void bindPointer(void *ptr, int index, const Text &type, void (*destructor)(void *)) override final;\n};\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/common/core/sqlite/Global.cpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/19\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"Global.hpp\"\n#include \"Assertion.hpp\"\n#include \"Notifier.hpp\"\n#include \"SQLite.h\"\n#include <fcntl.h>\n\nnamespace WCDB {\n\nstatic_assert((int) Global::PagerLock::None == SQLITE_LOCK_NONE, \"\");\nstatic_assert((int) Global::PagerLock::Shared == SQLITE_LOCK_SHARED, \"\");\nstatic_assert((int) Global::PagerLock::Reserved == SQLITE_LOCK_RESERVED, \"\");\nstatic_assert((int) Global::PagerLock::Pending == SQLITE_LOCK_PENDING, \"\");\nstatic_assert((int) Global::PagerLock::Exclusive == SQLITE_LOCK_EXCLUSIVE, \"\");\n\nstatic_assert((int) Global::ShmLock::Shared == SQLITE_SHM_SHARED, \"\");\nstatic_assert((int) Global::ShmLock::Exclusive == SQLITE_SHM_EXCLUSIVE, \"\");\n\nvoid Global::initialize()\n{\n    Global::shared();\n}\n\nGlobal &Global::shared()\n{\n    static Global *s_global = new Global;\n    return *s_global;\n}\n\nGlobal::Global()\n{\n    {\n        int rc = sqlite3_lock_hook(\n        Global::willLock, Global::lockDidChange, Global::willShmLock, Global::shmLockDidChange, this);\n        WCTAssert(rc == SQLITE_OK);\n        staticAPIExit(rc);\n    }\n\n    {\n        int rc = sqlite3_config(SQLITE_CONFIG_LOG, Global::log, this);\n        WCTAssert(rc == SQLITE_OK);\n        staticAPIExit(rc);\n    }\n\n    {\n#ifndef _WIN32\n        m_open = nullptr;\n        sqlite3_vfs *vfs = sqlite3_vfs_find(nullptr);\n        WCTAssert(vfs != nullptr);\n        int rc = vfs->xSetSystemCall(vfs, \"open\", (sqlite3_syscall_ptr) Global::open);\n        WCTAssert(rc == SQLITE_OK);\n        staticAPIExit(rc);\n#endif\n    }\n}\n\nvoid Global::staticAPIExit(int rc)\n{\n    if (Error::isError(rc)) {\n        Error error;\n        error.level = Error::Level::Fatal;\n        error.setSQLiteCode(rc);\n        Notifier::shared().notify(error);\n    }\n}\n\n#pragma mark - Log\nvoid Global::setNotificationForLog(const UnsafeStringView &name, const LogNotification &notification)\n{\n    LockGuard lockGuard(m_lock);\n    if (notification != nullptr) {\n        m_logNotifications[name] = notification;\n    } else {\n        m_logNotifications.erase(name);\n    }\n}\n\nvoid Global::postLogNotification(int rc, const char *message)\n{\n    SharedLockGuard lockGuard(m_lock);\n    for (const auto &iter : m_logNotifications) {\n        WCTAssert(iter.second != nullptr);\n        iter.second(rc, message);\n    }\n}\n\nvoid Global::log(void *parameter, int rc, const char *message)\n{\n    Global *global = static_cast<Global *>(parameter);\n    global->postLogNotification(rc, message);\n}\n\n#ifndef _WIN32\n#pragma mark - File Opened\nvoid Global::setNotificationWhenFileOpened(const UnsafeStringView &name,\n                                           const FileOpenedNotification &notification)\n{\n    LockGuard lockGuard(m_lock);\n    if (notification != nullptr) {\n        m_fileOpenedNotifications[name] = notification;\n    } else {\n        m_fileOpenedNotifications.erase(name);\n    }\n}\n\nint Global::open(const char *path, int flags, int mode)\n{\n    int fd = 0;\n    POSIXOpen openFunc = Global::shared().m_open;\n    if (openFunc != nullptr) {\n        fd = openFunc(path, flags, mode);\n    } else {\n        fd = ::open(path, flags, mode);\n    }\n    Global::shared().postFileOpenedNotification(fd, path, flags, mode);\n    return fd;\n}\n\nvoid Global::postFileOpenedNotification(int fd, const char *path, int flags, int mode)\n{\n    SharedLockGuard lockGuard(m_lock);\n    for (const auto &iter : m_fileOpenedNotifications) {\n        WCTAssert(iter.second != nullptr);\n        iter.second(fd, path, flags, mode);\n    }\n}\n\nvoid Global::registerPOSIXOpen(POSIXOpen open)\n{\n    m_open = open;\n}\n\nvoid Global::registerPOSIXClose(POSIXClose close)\n{\n    sqlite3_vfs *vfs = sqlite3_vfs_find(nullptr);\n    WCTAssert(vfs != nullptr);\n    int rc = vfs->xSetSystemCall(vfs, \"close\", (sqlite3_syscall_ptr) close);\n    WCTAssert(rc == SQLITE_OK);\n    staticAPIExit(rc);\n}\n\n#endif\n#pragma mark - Lock\nvoid Global::setNotificationForLockEvent(const UnsafeStringView &name,\n                                         const WillLockNotification &willLock,\n                                         const LockDidChangeNotification &lockDidChange,\n                                         const WillShmLockNotification &willShmLock,\n                                         const ShmLockDidChangeNotification &shmLockDidChange)\n{\n    LockGuard lockGuard(m_lock);\n    LockEvent event;\n    event.willLock = willLock;\n    event.lockDidChange = lockDidChange;\n    event.willShmLock = willShmLock;\n    event.shmLockDidChange = shmLockDidChange;\n    m_lockEventNotifications[name] = event;\n}\n\nvoid Global::willLock(void *parameter, const char *path, int type)\n{\n    reinterpret_cast<Global *>(parameter)->postWillLockNotification(path, type);\n}\n\nvoid Global::postWillLockNotification(const char *path_, int type_)\n{\n    UnsafeStringView path = path_;\n    WCTAssert(!path.empty());\n\n    PagerLock type = (PagerLock) type_;\n    WCTAssert(type == PagerLock::Shared || type == PagerLock::Reserved\n              || type == PagerLock::Exclusive);\n\n    SharedLockGuard lockGuard(m_lock);\n    for (const auto &iter : m_lockEventNotifications) {\n        if (iter.second.willLock != nullptr) {\n            iter.second.willLock(path, type);\n        }\n    }\n}\n\nvoid Global::lockDidChange(void *parameter, const char *path, int type)\n{\n    reinterpret_cast<Global *>(parameter)->postLockDidChangeNotification(path, type);\n}\n\nvoid Global::postLockDidChangeNotification(const char *path_, int type_)\n{\n    UnsafeStringView path = path_;\n    WCTAssert(!path.empty());\n\n    PagerLock type = (PagerLock) type_;\n    WCTAssert(type == PagerLock::None || type == PagerLock::Shared || type == PagerLock::Reserved\n              || type == PagerLock::Pending || type == PagerLock::Exclusive);\n\n    SharedLockGuard lockGuard(m_lock);\n    for (const auto &iter : m_lockEventNotifications) {\n        if (iter.second.lockDidChange != nullptr) {\n            iter.second.lockDidChange(path, type);\n        }\n    }\n}\n\nvoid Global::willShmLock(void *parameter, const char *path, int flags, int mask)\n{\n    reinterpret_cast<Global *>(parameter)->postWillShmLockNotification(path, flags, mask);\n}\n\nvoid Global::postWillShmLockNotification(const char *path_, int flags, int mask)\n{\n    UnsafeStringView path = path_;\n    WCTAssert(!path.empty());\n\n    ShmLock type;\n    if ((flags & SQLITE_SHM_SHARED) != 0) {\n        WCTAssert((flags & SQLITE_SHM_EXCLUSIVE) == 0);\n        type = ShmLock::Shared;\n    } else {\n        WCTAssert((flags & SQLITE_SHM_EXCLUSIVE) != 0);\n        type = ShmLock::Exclusive;\n    }\n\n    SharedLockGuard lockGuard(m_lock);\n    for (const auto &iter : m_lockEventNotifications) {\n        if (iter.second.willShmLock != nullptr) {\n            iter.second.willShmLock(path, type, mask);\n        }\n    }\n}\n\nvoid Global::shmLockDidChange(void *parameter, const char *path, void *identifier, int sharedMask, int exclusiveMask)\n{\n    reinterpret_cast<Global *>(parameter)->postShmLockDidChangeNotification(\n    path, identifier, sharedMask, exclusiveMask);\n}\n\nvoid Global::postShmLockDidChangeNotification(const char *path_,\n                                              void *identifier,\n                                              int sharedMask,\n                                              int exclusiveMask)\n{\n    WCTAssert(identifier != nullptr);\n\n    UnsafeStringView path = path_;\n    WCTAssert(!path.empty());\n\n    SharedLockGuard lockGuard(m_lock);\n    for (const auto &iter : m_lockEventNotifications) {\n        if (iter.second.shmLockDidChange != nullptr) {\n            iter.second.shmLockDidChange(path, identifier, sharedMask, exclusiveMask);\n        }\n    }\n}\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/core/sqlite/Global.hpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/19\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"Lock.hpp\"\n#include \"StringView.hpp\"\n#include <map>\n\nnamespace WCDB {\n\nclass Global {\npublic:\n    static void initialize();\n    static Global& shared();\n\nprotected:\n    Global();\n    Global(const Global&) = delete;\n    Global& operator=(const Global&) = delete;\n\n    mutable SharedLock m_lock;\n\nprivate:\n    static void staticAPIExit(int rc);\n\n#pragma mark - Log\npublic:\n    // rc, message\n    typedef std::function<void(int, const char*)> LogNotification;\n    void setNotificationForLog(const UnsafeStringView& name, const LogNotification& notification);\n\nprivate:\n    static void log(void* parameter, int rc, const char* message);\n    void postLogNotification(int rc, const char* message);\n    StringViewMap<LogNotification> m_logNotifications;\n\n#ifndef _WIN32\n#pragma mark - File Opened\npublic:\n    typedef std::function<void(int /* fd */, const char* /* path */, int /* flags */, int /* mode */)> FileOpenedNotification;\n    void setNotificationWhenFileOpened(const UnsafeStringView& name,\n                                       const FileOpenedNotification& notification);\n\n    typedef int (*POSIXOpen)(const char*, int, int);\n    void registerPOSIXOpen(POSIXOpen open);\n\n    typedef int (*POSIXClose)(int);\n    void registerPOSIXClose(POSIXClose close);\n\nprivate:\n    static int open(const char* path, int flags, int mode);\n    void postFileOpenedNotification(int fd, const char* path, int flags, int mode);\n    StringViewMap<FileOpenedNotification> m_fileOpenedNotifications;\n    POSIXOpen m_open;\n#endif\n\n#pragma mark - Lock\npublic:\n    enum class PagerLock {\n        None = 0,\n        Shared = 1,\n        Reserved = 2,\n        Pending = 3,\n        Exclusive = 4,\n    };\n    enum class ShmLock {\n        Shared = 4,\n        Exclusive = 8,\n    };\n    typedef std::function<void(const UnsafeStringView& /* path */, PagerLock)> WillLockNotification;\n    typedef std::function<void(const UnsafeStringView& /* path */, PagerLock)> LockDidChangeNotification;\n    typedef std::function<void(const UnsafeStringView& /* path */, ShmLock, int /* mask */)> WillShmLockNotification;\n    typedef std::function<void(const UnsafeStringView& /* path */, void* /* identifier */, int /* sharedMask */, int /* exclMask */)> ShmLockDidChangeNotification;\n    void setNotificationForLockEvent(const UnsafeStringView& name,\n                                     const WillLockNotification& willLock,\n                                     const LockDidChangeNotification& lockDidChange,\n                                     const WillShmLockNotification& willShmLock,\n                                     const ShmLockDidChangeNotification& shmLockDidChange);\n\nprivate:\n    static void willLock(void* parameter, const char* path, int type);\n    void postWillLockNotification(const char* path, int type);\n\n    static void lockDidChange(void* parameter, const char* path, int type);\n    void postLockDidChangeNotification(const char* path, int type);\n\n    static void willShmLock(void* parameter, const char* path, int flags, int mask);\n    void postWillShmLockNotification(const char* path, int flags, int mask);\n\n    static void\n    shmLockDidChange(void* parameter, const char* path, void* identifier, int sharedMask, int exclusiveMask);\n    void postShmLockDidChangeNotification(const char* path,\n                                          void* identifier,\n                                          int sharedMask,\n                                          int exclusiveMask);\n\n    struct LockEvent {\n        WillLockNotification willLock;\n        LockDidChangeNotification lockDidChange;\n        WillShmLockNotification willShmLock;\n        ShmLockDidChangeNotification shmLockDidChange;\n    };\n    typedef struct LockEvent LockEvent;\n    StringViewMap<LockEvent> m_lockEventNotifications;\n};\n\n}; // namespace WCDB\n"
  },
  {
    "path": "src/common/core/sqlite/HandleNotification.cpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/19\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"HandleNotification.hpp\"\n#include \"AbstractHandle.hpp\"\n#include \"Assertion.hpp\"\n#include \"SQLite.h\"\n#include \"StringView.hpp\"\n\nnamespace WCDB {\n\nHandleNotification::~HandleNotification() = default;\n\nvoid HandleNotification::purge()\n{\n    bool isOpened = getHandle()->isOpened();\n    bool set = areSQLTraceNotificationsSet() || arePerformanceTraceNotificationsSet();\n    m_sqlNotifications.clear();\n    m_performanceNotifications.clear();\n    if (set && isOpened) {\n        setupTraceNotifications();\n    }\n\n    set = isCommittedNotificationSet();\n    m_committedNotifications.clear();\n    if (set && isOpened) {\n        setupCommittedNotification();\n    }\n\n    set = areCheckpointNotificationsSet();\n    m_checkpointedNotifications.clear();\n    if (set && isOpened) {\n        setupCheckpointNotifications();\n    }\n\n    if (isOpened) {\n        setNotificationWhenBusy(nullptr);\n    }\n}\n\n#pragma mark - Trace\nint HandleNotification::traced(unsigned int T, void *C, void *P, void *X)\n{\n    HandleNotification *notification = reinterpret_cast<HandleNotification *>(C);\n    notification->postTraceNotification(T, P, X);\n    return SQLITE_OK;\n}\n\nvoid HandleNotification::postTraceNotification(unsigned int flag, void *P, void *X)\n{\n    sqlite3_stmt *stmt = (sqlite3_stmt *) P;\n    switch (flag) {\n    case SQLITE_TRACE_STMT: {\n        const char *sql = static_cast<const char *>(X);\n        if (sql) {\n            AbstractHandle *handle = getHandle();\n            postSQLTraceNotification(\n            handle->getTag(), handle->getPath(), getHandle(), sql, \"\");\n        }\n    } break;\n    case SQLITE_TRACE_PROFILE: {\n        const char *sql = sqlite3_sql(stmt);\n        PerformanceInfo *info = (PerformanceInfo *) X;\n        AbstractHandle *handle = getHandle();\n        postPerformanceTraceNotification(\n        handle->getTag(), handle->getPath(), getHandle(), sql, *info);\n    } break;\n    default:\n        break;\n    }\n}\n\nvoid HandleNotification::setupTraceNotifications()\n{\n    unsigned flag = 0;\n    if (!m_sqlNotifications.empty() && !m_fullSQLTrace) {\n        flag |= SQLITE_TRACE_STMT;\n    }\n    if (!m_performanceNotifications.empty()) {\n        flag |= SQLITE_TRACE_PROFILE;\n    }\n    if (flag != 0) {\n        APIExit(sqlite3_trace_v2(getRawHandle(), flag, HandleNotification::traced, this));\n    } else {\n        APIExit(sqlite3_trace_v2(getRawHandle(), 0, nullptr, nullptr));\n    }\n}\n\n#pragma mark - SQL\nvoid HandleNotification::setFullSQLTraceEnable(bool enable)\n{\n    bool before = m_fullSQLTrace;\n    m_fullSQLTrace = enable;\n    if (before != enable) {\n        setupTraceNotifications();\n    }\n}\n\nbool HandleNotification::areSQLTraceNotificationsSet() const\n{\n    return !m_sqlNotifications.empty();\n}\n\nvoid HandleNotification::setNotificationWhenSQLTraced(const UnsafeStringView &name,\n                                                      const SQLNotification &onTraced)\n{\n    bool stateBefore = areSQLTraceNotificationsSet();\n    if (onTraced != nullptr) {\n        m_sqlNotifications[name] = onTraced;\n    } else {\n        m_sqlNotifications.erase(name);\n    }\n    bool stateAfter = areSQLTraceNotificationsSet();\n    if (stateBefore != stateAfter) {\n        setupTraceNotifications();\n    }\n}\n\nvoid HandleNotification::postSQLTraceNotification(const Tag &tag,\n                                                  const UnsafeStringView &path,\n                                                  const void *handle,\n                                                  const UnsafeStringView &sql,\n                                                  const UnsafeStringView &info)\n{\n    for (const auto &element : m_sqlNotifications) {\n        element.second(tag, path, handle, sql, info);\n    }\n}\n\n#pragma mark - Performance\n\nbool HandleNotification::arePerformanceTraceNotificationsSet() const\n{\n    return !m_performanceNotifications.empty();\n}\n\nvoid HandleNotification::setNotificationWhenPerformanceTraced(const UnsafeStringView &name,\n                                                              const PerformanceNotification &onTraced)\n{\n    bool stateBefore = arePerformanceTraceNotificationsSet();\n    if (onTraced != nullptr) {\n        m_performanceNotifications[name] = onTraced;\n    } else {\n        m_performanceNotifications.erase(name);\n    }\n    bool stateAfter = arePerformanceTraceNotificationsSet();\n    if (stateAfter != stateBefore) {\n        setupTraceNotifications();\n    }\n}\n\nvoid HandleNotification::postPerformanceTraceNotification(const Tag &tag,\n                                                          const UnsafeStringView &path,\n                                                          const void *handle,\n                                                          const UnsafeStringView &sql,\n                                                          const PerformanceInfo &info)\n{\n    WCTAssert(!m_performanceNotifications.empty());\n    for (const auto &element : m_performanceNotifications) {\n        element.second(tag, path, handle, sql, info);\n    }\n}\n\n#pragma mark - Committed\nint HandleNotification::committed(void *p, sqlite3 *handle, const char *name, int numberOfFrames)\n{\n    WCTAssert(p != nullptr);\n    HandleNotification *notification = reinterpret_cast<HandleNotification *>(p);\n    notification->postCommittedNotification(sqlite3_db_filename(handle, name), numberOfFrames);\n    return SQLITE_OK;\n}\n\nvoid HandleNotification::setNotificationWhenCommitted(int order,\n                                                      const UnsafeStringView &name,\n                                                      const CommittedNotification &onCommitted)\n{\n    WCTAssert(onCommitted);\n    bool stateBefore = isCommittedNotificationSet();\n    m_committedNotifications.insert(StringView(name), onCommitted, order);\n    bool stateAfter = isCommittedNotificationSet();\n    if (stateBefore != stateAfter) {\n        setupCommittedNotification();\n    }\n}\n\nvoid HandleNotification::unsetNotificationWhenCommitted(const UnsafeStringView &name)\n{\n    bool stateBefore = isCommittedNotificationSet();\n    m_committedNotifications.erase(StringView(name));\n    bool stateAfter = isCommittedNotificationSet();\n    if (stateBefore != stateAfter) {\n        setupCommittedNotification();\n    }\n}\n\nvoid HandleNotification::setupCommittedNotification()\n{\n    if (!m_committedNotifications.empty()) {\n        sqlite3_wal_hook(getRawHandle(), HandleNotification::committed, this);\n    } else {\n        sqlite3_wal_hook(getRawHandle(), nullptr, nullptr);\n    }\n}\n\nbool HandleNotification::isCommittedNotificationSet() const\n{\n    return !m_committedNotifications.empty();\n}\n\nvoid HandleNotification::postCommittedNotification(const UnsafeStringView &path, int numberOfFrames)\n{\n    WCTAssert(!m_committedNotifications.empty());\n    for (const auto &element : m_committedNotifications) {\n        if (!element.value()(path, numberOfFrames)) {\n            break;\n        }\n    }\n}\n\n#pragma mark - Checkpoint\n\nbool HandleNotification::areCheckpointNotificationsSet() const\n{\n    return !m_checkpointedNotifications.empty();\n}\n\nvoid HandleNotification::setupCheckpointNotifications()\n{\n    if (!m_checkpointedNotifications.empty()) {\n        sqlite3_wal_checkpoint_handler(getRawHandle(),\n                                       HandleNotification::checkpointBegin,\n                                       HandleNotification::checkpointPage,\n                                       HandleNotification::checkpointFinish,\n                                       this);\n    } else {\n        sqlite3_wal_checkpoint_handler(getRawHandle(), nullptr, nullptr, nullptr, nullptr);\n    }\n}\n\nvoid HandleNotification::setNotificationWhenCheckpointed(const UnsafeStringView &name,\n                                                         Optional<CheckPointNotification> notification)\n{\n    bool stateBefore = areCheckpointNotificationsSet();\n    if (notification.hasValue()) {\n        m_checkpointedNotifications[name] = notification.value();\n    } else {\n        m_checkpointedNotifications.erase(name);\n    }\n    bool stateAfter = areCheckpointNotificationsSet();\n    if (stateBefore != stateAfter) {\n        setupCheckpointNotifications();\n    }\n}\n\nvoid HandleNotification::checkpointBegin(void *ctx, int nBackFill, int mxFrame, int salt1, int salt2)\n{\n    WCTAssert(ctx != nullptr);\n    HandleNotification *notification = reinterpret_cast<HandleNotification *>(ctx);\n    notification->postCheckpointBeginNotification(\n    notification->getHandle(), nBackFill, mxFrame, salt1, salt2);\n}\n\nvoid HandleNotification::postCheckpointBeginNotification(AbstractHandle *handle,\n                                                         uint32_t nBackFill,\n                                                         uint32_t mxFrame,\n                                                         uint32_t salt1,\n                                                         uint32_t salt2)\n{\n    WCTAssert(areCheckpointNotificationsSet());\n    for (const auto &element : m_checkpointedNotifications) {\n        if (element.second.begin == nullptr) {\n            continue;\n        }\n        element.second.begin(handle, nBackFill, mxFrame, salt1, salt2);\n    }\n}\n\nvoid HandleNotification::checkpointPage(void *ctx, int pageNo, void *data, int size)\n{\n    WCTAssert(ctx != nullptr);\n    HandleNotification *notification = reinterpret_cast<HandleNotification *>(ctx);\n    notification->postCheckpointPageNotification(\n    notification->getHandle(), pageNo, UnsafeData((unsigned char *) data, size));\n}\n\nvoid HandleNotification::postCheckpointPageNotification(AbstractHandle *handle,\n                                                        uint32_t pageNo,\n                                                        const UnsafeData &data)\n{\n    WCTAssert(areCheckpointNotificationsSet());\n    for (const auto &element : m_checkpointedNotifications) {\n        if (element.second.page == nullptr) {\n            continue;\n        }\n        element.second.page(handle, pageNo, data);\n    }\n}\n\nvoid HandleNotification::checkpointFinish(void *ctx, int nBackFill, int mxFrame, int salt1, int salt2)\n{\n    WCTAssert(ctx != nullptr);\n    HandleNotification *notification = reinterpret_cast<HandleNotification *>(ctx);\n    notification->postCheckpointFinishNotification(\n    notification->getHandle(), nBackFill, mxFrame, salt1, salt2);\n}\n\nvoid HandleNotification::postCheckpointFinishNotification(AbstractHandle *handle,\n                                                          uint32_t nBackFill,\n                                                          uint32_t mxFrame,\n                                                          uint32_t salt1,\n                                                          uint32_t salt2)\n{\n    WCTAssert(areCheckpointNotificationsSet());\n    for (const auto &element : m_checkpointedNotifications) {\n        if (element.second.finish == nullptr) {\n            continue;\n        }\n        element.second.finish(handle, nBackFill, mxFrame, salt1, salt2);\n    }\n}\n\n#pragma mark - Busy\nint HandleNotification::onBusy(void *p, int numberOfTimes)\n{\n    HandleNotification *notification = reinterpret_cast<HandleNotification *>(p);\n    int rc = SQLITE_OK;\n    if (notification->postBusyNotification(numberOfTimes)) {\n        // return any non-zero value to retry\n        rc = SQLITE_BUSY;\n    }\n    return rc;\n}\n\nvoid HandleNotification::setNotificationWhenBusy(const BusyNotification &busyNotification)\n{\n    m_busyNotification = busyNotification;\n    if (m_busyNotification != nullptr) {\n        APIExit(sqlite3_busy_handler(getRawHandle(), HandleNotification::onBusy, this));\n    } else {\n        APIExit(sqlite3_busy_handler(getRawHandle(), nullptr, nullptr));\n    }\n}\n\nbool HandleNotification::postBusyNotification(int numberOfTimes)\n{\n    WCTAssert(m_busyNotification != nullptr);\n    bool retry = false;\n    if (m_busyNotification != nullptr) {\n        retry = m_busyNotification(getHandle()->getPath(), numberOfTimes);\n    }\n    return retry;\n}\n\n#pragma mark - Table Modification\nvoid HandleNotification::setNotificationWhenTableModified(const UnsafeStringView &name,\n                                                          const TableModifiedNotification &tableModified)\n{\n    if (tableModified != nullptr) {\n        m_tableModifiedNotifications[name] = tableModified;\n    } else {\n        m_tableModifiedNotifications.erase(name);\n    }\n}\n\nvoid HandleNotification::postTableModifiedNotification(const UnsafeStringView &newTable,\n                                                       const UnsafeStringView &modifiedTable)\n{\n    WCTAssert(!m_tableModifiedNotifications.empty());\n    for (const auto &element : m_tableModifiedNotifications) {\n        element.second(getHandle()->getPath(), newTable, modifiedTable);\n    }\n}\n\nbool HandleNotification::needMonitorTable()\n{\n    return !m_tableModifiedNotifications.empty();\n}\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/common/core/sqlite/HandleNotification.hpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/19\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"HandleRelated.hpp\"\n#include \"Lock.hpp\"\n#include \"SQLiteDeclaration.h\"\n#include \"Tag.hpp\"\n#include \"UniqueList.hpp\"\n#include \"WCDBOptional.hpp\"\n#include <functional>\n#include <map>\n\nnamespace WCDB {\n\nclass HandleNotification final : public HandleRelated {\npublic:\n    using HandleRelated::HandleRelated;\n    ~HandleNotification() override;\n\n    void purge();\n\n#pragma mark - Trace\nprivate:\n    void postTraceNotification(unsigned int flag, void *P, void *X);\n    void setupTraceNotifications();\n    static int traced(unsigned int T, void *C, void *P, void *X);\n\n#pragma mark - SQL\npublic:\n    typedef std::function<void(const Tag &tag, const UnsafeStringView &path, const void *handle, const UnsafeStringView &sql, const UnsafeStringView &info)> SQLNotification;\n    void setNotificationWhenSQLTraced(const UnsafeStringView &name,\n                                      const SQLNotification &onTraced);\n\n    void postSQLTraceNotification(const Tag &tag,\n                                  const UnsafeStringView &path,\n                                  const void *handle,\n                                  const UnsafeStringView &sql,\n                                  const UnsafeStringView &info);\n\n    void setFullSQLTraceEnable(bool enable);\n\nprivate:\n    bool areSQLTraceNotificationsSet() const;\n    StringViewMap<SQLNotification> m_sqlNotifications;\n    bool m_fullSQLTrace = false;\n\n#pragma mark - Performance\npublic:\n    typedef struct PerformanceInfo {\n        int tablePageReadCount;\n        int tablePageWriteCount;\n        int indexPageReadCount;\n        int indexPageWriteCount;\n        int overflowPageReadCount;\n        int overflowPageWriteCount;\n        int64_t costInNanoseconds;\n    } PerformanceInfo;\n    typedef std::function<void(const Tag &tag, const UnsafeStringView &path, const void *handle, const UnsafeStringView &sql, PerformanceInfo info)> PerformanceNotification;\n    void setNotificationWhenPerformanceTraced(const UnsafeStringView &name,\n                                              const PerformanceNotification &onTraced);\n\nprivate:\n    bool arePerformanceTraceNotificationsSet() const;\n    void postPerformanceTraceNotification(const Tag &tag,\n                                          const UnsafeStringView &path,\n                                          const void *handle,\n                                          const UnsafeStringView &sql,\n                                          const PerformanceInfo &info);\n    StringViewMap<PerformanceNotification> m_performanceNotifications;\n\n#pragma mark - Committed\npublic:\n    //committed dispatch will abort if any notification return false\n    typedef std::function<bool(const UnsafeStringView &path, int numberOfFrames)> CommittedNotification;\n    void setNotificationWhenCommitted(int order,\n                                      const UnsafeStringView &name,\n                                      const CommittedNotification &onCommitted);\n    void unsetNotificationWhenCommitted(const UnsafeStringView &name);\n\nprivate:\n    static int committed(void *p, sqlite3 *, const char *, int numberOfFrames);\n\n    bool isCommittedNotificationSet() const;\n    void setupCommittedNotification();\n\n    void postCommittedNotification(const UnsafeStringView &path, int numberOfFrames);\n    UniqueList<StringView, CommittedNotification> m_committedNotifications;\n\n#pragma mark - Checkpoint\npublic:\n    typedef std::function<void(AbstractHandle *handle, uint32_t nBackFill, uint32_t mxFrame, uint32_t salt1, uint32_t salt2)> CheckpointBeginNotification;\n    typedef std::function<void(AbstractHandle *handle, uint32_t pageNo, const UnsafeData &data)> CheckpointPageNotification;\n    typedef std::function<void(AbstractHandle *handle, uint32_t nBackFill, uint32_t mxFrame, uint32_t salt1, uint32_t salt2)> CheckpointFinishNotification;\n    typedef struct CheckPointNotification {\n        CheckpointBeginNotification begin;\n        CheckpointPageNotification page;\n        CheckpointFinishNotification finish;\n    } CheckPointNotification;\n    void setNotificationWhenCheckpointed(const UnsafeStringView &name,\n                                         Optional<CheckPointNotification> notification);\n\nprivate:\n    bool areCheckpointNotificationsSet() const;\n    void setupCheckpointNotifications();\n\n    static void\n    checkpointBegin(void *ctx, int nBackFill, int mxFrame, int salt1, int salt2);\n    void postCheckpointBeginNotification(AbstractHandle *handle,\n                                         uint32_t nBackFill,\n                                         uint32_t mxFrame,\n                                         uint32_t salt1,\n                                         uint32_t salt2);\n\n    static void checkpointPage(void *ctx, int pageNo, void *data, int size);\n    void postCheckpointPageNotification(AbstractHandle *handle,\n                                        uint32_t pageNo,\n                                        const UnsafeData &data);\n\n    static void\n    checkpointFinish(void *ctx, int nBackFill, int mxFrame, int salt1, int salt2);\n    void postCheckpointFinishNotification(AbstractHandle *handle,\n                                          uint32_t nBackFill,\n                                          uint32_t mxFrame,\n                                          uint32_t salt1,\n                                          uint32_t salt2);\n\n    StringViewMap<CheckPointNotification> m_checkpointedNotifications;\n\n#pragma mark - Busy\npublic:\n    typedef std::function<bool(const UnsafeStringView &path, int numberOfTimes)> BusyNotification;\n    void setNotificationWhenBusy(const BusyNotification &busyNotification);\n\nprivate:\n    static int onBusy(void *p, int numberOfTimes);\n    bool postBusyNotification(int numberOfTimes);\n    BusyNotification m_busyNotification;\n\n#pragma mark - Table Modification\npublic:\n    typedef std::function<void(const UnsafeStringView &path, const UnsafeStringView &newTable, const UnsafeStringView &modifiedTable)> TableModifiedNotification;\n    void setNotificationWhenTableModified(const UnsafeStringView &name,\n                                          const TableModifiedNotification &tableModified);\n    void postTableModifiedNotification(const UnsafeStringView &newTable,\n                                       const UnsafeStringView &modifiedTable);\n    bool needMonitorTable();\n\nprivate:\n    StringViewMap<TableModifiedNotification> m_tableModifiedNotifications;\n};\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/common/core/sqlite/HandleOperator.cpp",
    "content": "//\n// Created by 陈秋文 on 2023/11/16.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"HandleOperator.hpp\"\n\nnamespace WCDB {\n\nHandleOperator::HandleOperator(InnerHandle *handle) : m_handle(handle)\n{\n}\n\nHandleOperator::HandleOperator(HandleOperator &&other)\n: m_handle(std::move(other.m_handle))\n{\n    other.m_handle = nullptr;\n}\n\nHandleOperator::~HandleOperator() = default;\n\nInnerHandle *HandleOperator::getHandle() const\n{\n    return m_handle;\n}\n\nvoid HandleOperator::onDecorationChange()\n{\n}\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/core/sqlite/HandleOperator.hpp",
    "content": "//\n// Created by 陈秋文 on 2023/11/16.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"InnerHandle.hpp\"\n\nnamespace WCDB {\n\nclass HandleOperator {\npublic:\n    HandleOperator(InnerHandle *handle);\n    HandleOperator(HandleOperator &&other);\n    HandleOperator(const HandleOperator &other) = delete;\n    virtual ~HandleOperator();\n\n    InnerHandle *getHandle() const;\n\n    virtual void onDecorationChange();\n\nprivate:\n    InnerHandle *m_handle;\n};\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/core/sqlite/HandleRelated.cpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/19\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"HandleRelated.hpp\"\n#include \"Assertion.hpp\"\n#include \"InnerHandle.hpp\"\n\nnamespace WCDB {\n\nHandleRelated::HandleRelated(AbstractHandle *handle) : m_handle(handle)\n{\n    WCTAssert(m_handle != nullptr);\n}\n\nHandleRelated::~HandleRelated() = default;\n\nbool HandleRelated::APIExit(int rc)\n{\n    return m_handle->APIExit(rc);\n}\n\nbool HandleRelated::APIExit(int rc, const UnsafeStringView &sql)\n{\n    return m_handle->APIExit(rc, sql);\n}\n\nbool HandleRelated::APIExit(int rc, const char *sql)\n{\n    return m_handle->APIExit(rc, sql);\n}\n\nAbstractHandle *HandleRelated::getHandle() const\n{\n    return m_handle;\n}\n\nsqlite3 *HandleRelated::getRawHandle()\n{\n    return m_handle->getRawHandle();\n}\n\nvoid HandleRelated::cacheCurrentTransactionError()\n{\n    m_handle->cacheCurrentTransactionError();\n}\nvoid HandleRelated::resumeCacheTransactionError()\n{\n    m_handle->resumeCacheTransactionError();\n}\n\nbool HandleRelated::isBusyTraceEnable() const\n{\n    return m_handle->isBusyTraceEnable();\n}\n\nvoid HandleRelated::setCurrentSQL(const UnsafeStringView &sql)\n{\n    m_handle->setCurrentSQL(sql);\n}\n\nvoid HandleRelated::resetCurrentSQL(const UnsafeStringView &sql)\n{\n    m_handle->resetCurrentSQL(sql);\n}\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/common/core/sqlite/HandleRelated.hpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/19\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"SQLiteDeclaration.h\"\n#include \"StringView.hpp\"\n\nnamespace WCDB {\n\nclass AbstractHandle;\n\nclass HandleRelated {\npublic:\n    HandleRelated(AbstractHandle *handle);\n    virtual ~HandleRelated() = 0;\n\n    AbstractHandle *getHandle() const;\n    sqlite3 *getRawHandle();\n\nprotected:\n    bool APIExit(int rc);\n    bool APIExit(int rc, const UnsafeStringView &sql);\n    bool APIExit(int rc, const char *sql);\n    void cacheCurrentTransactionError();\n    void resumeCacheTransactionError();\n    bool isBusyTraceEnable() const;\n    void setCurrentSQL(const UnsafeStringView &sql);\n    void resetCurrentSQL(const UnsafeStringView &sql);\n\nprivate:\n    AbstractHandle *m_handle;\n};\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/common/core/sqlite/HandleStatement.cpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/19\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"HandleStatement.hpp\"\n#include \"AbstractHandle.hpp\"\n#include \"Assertion.hpp\"\n#include \"BaseBinding.hpp\"\n#include \"CommonCore.hpp\"\n#include \"CompressingHandleDecorator.hpp\"\n#include \"CompressionConst.hpp\"\n#include \"DecorativeHandle.hpp\"\n#include \"InnerHandle.hpp\"\n#include \"MigratingHandleDecorator.hpp\"\n#include \"MigrationInfo.hpp\"\n#include \"SQLite.h\"\n#include \"WINQ.h\"\n#include <iomanip>\n#include <string.h>\n\nnamespace WCDB {\n\nHandleStatement::HandleStatement(HandleStatement &&other)\n: HandleRelated(other.getHandle())\n, m_stmt(other.m_stmt)\n, m_done(other.m_done)\n, m_newTable(other.m_newTable)\n, m_modifiedTable(other.m_modifiedTable)\n, m_needAutoAddColumn(other.m_needAutoAddColumn)\n, m_sql(other.m_sql)\n, m_fullTrace(other.m_fullTrace)\n, m_needReport(other.m_needReport)\n, m_stepCount(other.m_stepCount)\n{\n    other.m_done = false;\n    other.m_stmt = nullptr;\n}\n\nHandleStatement::HandleStatement(AbstractHandle *handle)\n: HandleRelated(handle)\n, m_stmt(nullptr)\n, m_done(false)\n, m_needAutoAddColumn(false)\n, m_fullTrace(handle->isFullSQLEnable())\n, m_needReport(false)\n, m_stepCount(0)\n{\n}\n\nHandleStatement::~HandleStatement()\n{\n    finalize();\n}\n\nbool HandleStatement::prepare(const Statement &statement)\n{\n    if (getHandle()->needMonitorTable()) {\n        analysisStatement(statement);\n    }\n\n    const StringView &sql = statement.getDescription();\n    if (m_needAutoAddColumn) {\n        cacheCurrentTransactionError();\n    }\n    if (prepareSQL(sql)) {\n        return true;\n    }\n\n    if (!m_needAutoAddColumn) {\n        return false;\n    }\n\n    auto statementType = statement.getType();\n    if (statementType != Syntax::Identifier::Type::InsertSTMT\n        && statementType != Syntax::Identifier::Type::DeleteSTMT\n        && statementType != Syntax::Identifier::Type::UpdateSTMT\n        && statementType != Syntax::Identifier::Type::SelectSTMT) {\n        return false;\n    }\n\n    const Error &error = getHandle()->getError();\n    if (error.code() != Error::Code::Error || (int) error.getExtCode() != 0) {\n        return false;\n    }\n    const StringView &msg = error.getMessage();\n    if (!msg.hasPrefix(\"no such column: \")\n        && !(statement.getType() == Syntax::Identifier::Type::InsertSTMT\n             && msg.hasPrefix(\"table \") && msg.contain(\" has no column named \"))) {\n        return false;\n    }\n\n    InnerHandle *innerHandle = dynamic_cast<InnerHandle *>(getHandle());\n    if (!innerHandle) {\n        return false;\n    }\n\n    StringView columnName;\n    StringView tableName;\n    StringView schemaName;\n    const BaseBinding *binding = nullptr;\n    if (!tryExtractColumnInfo(statement, msg, columnName, tableName, schemaName, &binding)) {\n        return false;\n    }\n    if (binding != nullptr) {\n        if (!binding->tryRecoverColumn(columnName, tableName, schemaName, sql, innerHandle)) {\n            return false;\n        }\n    } else {\n        WCTAssert(columnName.hasPrefix(CompressionColumnTypePrefix));\n        DecorativeHandle *decorativeHandle\n        = dynamic_cast<DecorativeHandle *>(getHandle());\n        if (decorativeHandle != nullptr\n            && decorativeHandle->containDecorator(DecoratorCompressingHandle)) {\n            CompressingHandleDecorator *compressingDecorator\n            = decorativeHandle->getDecorator<CompressingHandleDecorator>(DecoratorCompressingHandle);\n            if (!compressingDecorator->tryFixCompressingColumn(tableName)) {\n                return false;\n            }\n        }\n    }\n\n    resumeCacheTransactionError();\n    return prepareSQL(sql);\n}\n\nvoid HandleStatement::analysisStatement(const Statement &statement)\n{\n    m_modifiedTable.clear();\n    m_newTable.clear();\n    switch (statement.getType()) {\n    case Syntax::Identifier::Type::InsertSTMT: {\n        const Syntax::InsertSTMT &insertSTMT\n        = static_cast<const Syntax::InsertSTMT &>(statement.syntax());\n        m_modifiedTable = insertSTMT.table;\n    } break;\n    case Syntax::Identifier::Type::UpdateSTMT: {\n        const Syntax::UpdateSTMT &updateSTMT\n        = static_cast<const Syntax::UpdateSTMT &>(statement.syntax());\n        m_modifiedTable = updateSTMT.table.table;\n    } break;\n    case Syntax::Identifier::Type::DeleteSTMT: {\n        const Syntax::DeleteSTMT &deleteSTMT\n        = static_cast<const Syntax::DeleteSTMT &>(statement.syntax());\n        m_modifiedTable = deleteSTMT.table.table;\n    } break;\n    case Syntax::Identifier::Type::AlterTableSTMT: {\n        const Syntax::AlterTableSTMT &alterSTMT\n        = static_cast<const Syntax::AlterTableSTMT &>(statement.syntax());\n        if (alterSTMT.switcher == Syntax::AlterTableSTMT::Switch::RenameTable) {\n            m_modifiedTable = alterSTMT.newTable;\n        }\n    } break;\n    case Syntax::Identifier::Type::CreateTableSTMT: {\n        const Syntax::CreateTableSTMT &createSTMT\n        = static_cast<const Syntax::CreateTableSTMT &>(statement.syntax());\n        m_newTable = createSTMT.table;\n    } break;\n    case Syntax::Identifier::Type::CreateVirtualTableSTMT: {\n        const Syntax::CreateVirtualTableSTMT &createSTMT\n        = static_cast<const Syntax::CreateVirtualTableSTMT &>(statement.syntax());\n        m_newTable = createSTMT.table;\n    } break;\n    default:\n        break;\n    }\n}\n\nbool HandleStatement::tryExtractColumnInfo(const Statement &statement,\n                                           const StringView &msg,\n                                           StringView &columnName,\n                                           StringView &tableName,\n                                           StringView &schemaName,\n                                           const BaseBinding **binding)\n{\n    StringView columnInfo[3];\n    const char *msgStr = msg.data();\n    bool isInsert = false;\n    if (msg.hasPrefix(\"no such column: \")) {\n        int index = 2;\n        size_t preLocation = msg.length();\n        int i = (int) msg.length() - 2;\n        for (; i >= 17; i--) {\n            if (msgStr[i] == ' ') {\n                return false;\n            }\n            if (msgStr[i] == '.') {\n                columnInfo[index] = StringView(msgStr + i + 1, preLocation - i - 1);\n                preLocation = i;\n                index--;\n            }\n            if (index < 0) {\n                return false;\n            }\n        }\n        columnInfo[index] = StringView(msgStr + i, preLocation - i);\n    } else {\n        isInsert = true;\n        offset_t firstLoc = msg.find(\" has no column named \");\n        const UnsafeStringView tablePart(msgStr + 6, firstLoc - 6);\n        offset_t secondLoc = tablePart.find(\".\");\n        if (secondLoc == UnsafeStringView::npos) {\n            columnInfo[1] = tablePart;\n        } else {\n            columnInfo[0] = StringView(tablePart.data(), secondLoc);\n            columnInfo[1] = StringView(tablePart.data() + secondLoc + 1,\n                                       tablePart.length() - secondLoc - 1);\n        }\n        columnInfo[2]\n        = StringView(msg.data() + firstLoc + 21, msg.length() - firstLoc - 21);\n    }\n\n    schemaName = columnInfo[0];\n    tableName = columnInfo[1];\n    columnName = columnInfo[2];\n    if (columnName.length() == 0) {\n        return false;\n    }\n\n    bool tableSpecified = tableName.length() > 0;\n    bool schemaSpecified = schemaName.length() > 0;\n\n    if (schemaSpecified) {\n        if (tableName.hasPrefix(MigrationInfo::getUnionedViewPrefix())\n            && schemaName.compare(Syntax::tempSchema) == 0) {\n            size_t prefixLength = strlen(MigrationInfo::getUnionedViewPrefix());\n            tableName = StringView(tableName.data() + prefixLength,\n                                   tableName.length() - prefixLength);\n            schemaName = \"\";\n            schemaSpecified = false;\n        } else if (schemaName.hasPrefix(MigrationDatabaseInfo::getSchemaPrefix())) {\n            schemaName = \"\";\n            schemaSpecified = false;\n        }\n    }\n\n    WCTAssert(tableSpecified || !schemaSpecified);\n    bool findTable = !tableSpecified;\n    bool isCompressingColumn = columnName.hasPrefix(CompressionColumnTypePrefix);\n    Statement copyStatement = statement;\n    bool invalidStatement = false;\n\n    copyStatement.syntax();\n    copyStatement.iterate([&](Syntax::Identifier &identifier, bool isBegin, bool &stop) {\n        if (!isBegin) {\n            return;\n        }\n        StringView curTableName;\n        Syntax::Schema curSchema;\n        bool needCheckTable = false;\n        switch (identifier.getType()) {\n        case Syntax::Identifier::Type::Column: {\n            Syntax::Column &column = (Syntax::Column &) identifier;\n            if (isCompressingColumn) {\n                return;\n            }\n            if (column.name.compare(columnName) != 0) {\n                return;\n            }\n            if (!isInsert) {\n                if ((tableSpecified && column.table.compare(tableName) != 0)\n                    || (!tableSpecified && column.table.length() > 0)) {\n                    return;\n                }\n                if ((schemaSpecified && column.schema.name.compare(schemaName) != 0)\n                    || (!schemaSpecified && tableSpecified && !column.schema.isMain())) {\n                    return;\n                }\n            }\n            const BaseBinding *newBinding = column.getTableBinding();\n            if (newBinding != nullptr && *binding != nullptr && newBinding != *binding) {\n                invalidStatement = true;\n                stop = true;\n                return;\n            }\n            *binding = newBinding;\n        } break;\n        case Syntax::Identifier::Type::QualifiedTableName: {\n            Syntax::QualifiedTableName &qualifiedTable\n            = (Syntax::QualifiedTableName &) identifier;\n            curTableName = qualifiedTable.table;\n            curSchema = qualifiedTable.schema;\n            needCheckTable = true;\n        } break;\n        case Syntax::Identifier::Type::TableOrSubquery: {\n            Syntax::TableOrSubquery &tableOrSubquery = (Syntax::TableOrSubquery &) identifier;\n            if (tableOrSubquery.switcher == Syntax::TableOrSubquery::Switch::Table) {\n                curTableName = tableOrSubquery.tableOrFunction;\n                curSchema = tableOrSubquery.schema;\n                needCheckTable = true;\n            }\n        } break;\n        case Syntax::Identifier::Type::InsertSTMT: {\n            Syntax::InsertSTMT &insert = (Syntax::InsertSTMT &) identifier;\n            curTableName = insert.table;\n            curSchema = insert.schema;\n            needCheckTable = true;\n        } break;\n        default:\n            break;\n        }\n        if (!needCheckTable) {\n            return;\n        }\n\n        if (curTableName.hasPrefix(MigrationInfo::getUnionedViewPrefix())\n            && curSchema.isTemp()) {\n            size_t prefixLength = strlen(MigrationInfo::getUnionedViewPrefix());\n            curTableName = StringView(curTableName.data() + prefixLength,\n                                      curTableName.length() - prefixLength);\n            curSchema = Schema::main();\n        }\n        if (curSchema.name.hasPrefix(MigrationDatabaseInfo::getSchemaPrefix())) {\n            curSchema = Schema::main();\n        }\n\n        if (!tableSpecified) {\n            if (tableName.length() > 0 && tableName.compare(curTableName) != 0) {\n                DecorativeHandle *decorativeHandle\n                = dynamic_cast<DecorativeHandle *>(getHandle());\n                if (decorativeHandle != nullptr\n                    && decorativeHandle->containDecorator(DecoratorMigratingHandle)) {\n                    MigratingHandleDecorator *migratingDecorator\n                    = decorativeHandle->getDecorator<MigratingHandleDecorator>(DecoratorMigratingHandle);\n                    if (!migratingDecorator->checkSourceTable(tableName, curTableName)\n                        && !migratingDecorator->checkSourceTable(curTableName, tableName)) {\n                        invalidStatement = true;\n                    }\n                } else {\n                    invalidStatement = true;\n                }\n            }\n            if (schemaName.length() > 0 && curSchema.name.compare(schemaName) != 0) {\n                invalidStatement = true;\n            }\n            if (invalidStatement) {\n                stop = true;\n                return;\n            }\n            tableName = curTableName;\n            if (!curSchema.isMain()) {\n                schemaName = curSchema.name;\n            }\n        } else if (!findTable && curTableName.compare(tableName) == 0) {\n            if ((schemaName.length() == 0 && curSchema.isMain())\n                || (schemaName.length() > 0 && curSchema.name.compare(schemaName) == 0)) {\n                findTable = true;\n            }\n        }\n    });\n    return (*binding != nullptr || isCompressingColumn) && findTable && !invalidStatement;\n}\n\nbool HandleStatement::prepareSQL(const UnsafeStringView &sql)\n{\n    WCTRemedialAssert(!isPrepared(), \"Last statement is not finalized.\", finalize(););\n    WCTAssert(sql.length() > 0);\n\n    bool result = APIExit(\n    sqlite3_prepare_v2(getRawHandle(), sql.data(), -1, &m_stmt, nullptr), sql);\n    m_done = false;\n    m_fullTrace = getHandle()->isFullSQLEnable();\n    if (!result) {\n        m_stmt = nullptr;\n    } else {\n        if (m_fullTrace) {\n            clearReport();\n        }\n        if (isBusyTraceEnable()) {\n            m_sql = sql;\n        }\n    }\n    return result;\n}\n\nvoid HandleStatement::reset()\n{\n    WCTAssert(isPrepared());\n    tryReportSQL();\n    APIExit(sqlite3_reset(m_stmt));\n}\n\nvoid HandleStatement::clearBindings()\n{\n    WCTAssert(isPrepared());\n    APIExit(sqlite3_clear_bindings(m_stmt));\n}\n\nbool HandleStatement::done()\n{\n    return m_done;\n}\n\nbool HandleStatement::step()\n{\n    WCTAssert(isPrepared());\n\n    if (isBusyTraceEnable()) {\n        setCurrentSQL(m_sql);\n    }\n\n    int rc = sqlite3_step(m_stmt);\n    m_done = rc == SQLITE_DONE;\n\n    if (m_fullTrace) {\n        m_needReport = true;\n    }\n\n    if (m_done) {\n        if (getHandle()->needMonitorTable()\n            && (!m_newTable.empty() || !m_modifiedTable.empty())) {\n            getHandle()->postTableNotification(m_newTable, m_modifiedTable);\n        }\n        tryReportSQL();\n    } else {\n        m_stepCount++;\n    }\n\n    const char *sql = nullptr;\n    if (isPrepared()) {\n        // There will be privacy issues if use sqlite3_expanded_sql\n        sql = sqlite3_sql(m_stmt);\n    }\n    return APIExit(rc, sql);\n}\n\nvoid HandleStatement::finalize()\n{\n    if (m_stmt != nullptr) {\n        tryReportSQL();\n        // no need to call APIExit since it returns old code only.\n        sqlite3_finalize(m_stmt);\n        m_stmt = nullptr;\n        resetCurrentSQL(m_sql);\n        m_sql.clear();\n    }\n}\n\nint HandleStatement::getNumberOfColumns()\n{\n    WCTAssert(isPrepared());\n    return sqlite3_column_count(m_stmt);\n}\n\nconst UnsafeStringView HandleStatement::getOriginColumnName(int index)\n{\n    WCTAssert(isPrepared());\n    return sqlite3_column_origin_name(m_stmt, index);\n}\n\nconst UnsafeStringView HandleStatement::getColumnName(int index)\n{\n    WCTAssert(isPrepared());\n    return sqlite3_column_name(m_stmt, index);\n}\n\nconst UnsafeStringView HandleStatement::getColumnTableName(int index)\n{\n    WCTAssert(isPrepared());\n    return sqlite3_column_table_name(m_stmt, index);\n}\n\nint HandleStatement::getBindParameterCount()\n{\n    WCTAssert(isPrepared());\n    return sqlite3_bind_parameter_count(m_stmt);\n}\n\nColumnType HandleStatement::getType(int index)\n{\n    WCTAssert(isPrepared());\n    switch (sqlite3_column_type(m_stmt, index)) {\n    case SQLITE_INTEGER:\n        return ColumnType::Integer;\n    case SQLITE_FLOAT:\n        return ColumnType::Float;\n    case SQLITE_BLOB:\n        return ColumnType::BLOB;\n    case SQLITE_TEXT:\n        return ColumnType::Text;\n    default:\n        return ColumnType::Null;\n    }\n}\n\nvoid HandleStatement::bindInteger(const Integer &value, int index)\n{\n    WCTAssert(isPrepared());\n    WCTAssert(!isBusy());\n    bool succeed = APIExit(sqlite3_bind_int64(m_stmt, index, value));\n    if (succeed && m_fullTrace) {\n        m_stream << index << \":\" << value << \";\";\n    }\n    WCTAssert(succeed);\n    WCDB_UNUSED(succeed);\n}\n\nvoid HandleStatement::bindDouble(const Float &value, int index)\n{\n    WCTAssert(isPrepared());\n    WCTAssert(!isBusy());\n    bool succeed = APIExit(sqlite3_bind_double(m_stmt, index, value));\n    if (succeed && m_fullTrace) {\n        m_stream << index << \":\" << value << \";\";\n    }\n    WCTAssert(succeed);\n    WCDB_UNUSED(succeed);\n}\n\nvoid HandleStatement::bindText(const Text &value, int index)\n{\n    WCTAssert(isPrepared());\n    WCTAssert(!isBusy());\n    // use SQLITE_STATIC if auto_commit?\n    bool succeed = APIExit(sqlite3_bind_text(\n    m_stmt, index, value.data(), (int) value.length(), SQLITE_TRANSIENT));\n    if (succeed && m_fullTrace) {\n        m_stream << index << \":\";\n        if (value.length() < 20) {\n            m_stream << value;\n        } else {\n            m_stream << UnsafeStringView(value.data(), 20) << \"...\";\n        }\n        m_stream << \";\";\n    }\n    WCTAssert(succeed);\n    WCDB_UNUSED(succeed);\n}\n\nvoid HandleStatement::bindText16(const char16_t *value, size_t valueLength, int index)\n{\n    WCTAssert(isPrepared());\n    WCTAssert(!isBusy());\n    bool succeed = APIExit(sqlite3_bind_text16(\n    m_stmt, index, value, (int) valueLength * 2, SQLITE_TRANSIENT));\n    if (succeed && m_fullTrace) {\n        m_stream << index << \":\";\n        char buffer[81];\n        m_stream << UnsafeStringView::createFromUTF16(\n        value, valueLength < 20 ? valueLength : 20, buffer);\n        if (valueLength > 20) {\n            m_stream << \"...\";\n        }\n        m_stream << \";\";\n    }\n    WCTAssert(succeed);\n    WCDB_UNUSED(succeed);\n}\n\nvoid HandleStatement::bindBLOB(const BLOB &value, int index)\n{\n    WCTAssert(isPrepared());\n    WCTAssert(!isBusy());\n    // TODO: use SQLITE_STATIC to get better performance?\n    bool succeed = APIExit(sqlite3_bind_blob(\n    m_stmt, index, value.buffer(), (int) value.size(), SQLITE_TRANSIENT));\n    if (succeed && m_fullTrace) {\n        m_stream << index << \":\";\n        auto flags = m_stream.flags();\n        m_stream << std::hex << std::setfill('0');\n        size_t length = value.size() > 10 ? 10 : value.size();\n        for (int i = 0; i < length; i++) {\n            int c = value.buffer()[i];\n            m_stream << std::setw(2) << c;\n        }\n        m_stream.flags(flags);\n        if (value.size() > 10) {\n            m_stream << \"...\";\n        }\n        m_stream << \";\";\n    }\n    WCTAssert(succeed);\n    WCDB_UNUSED(succeed);\n}\n\nvoid HandleStatement::bindNull(int index)\n{\n    WCTAssert(isPrepared());\n    WCTAssert(!isBusy());\n    bool succeed = APIExit(sqlite3_bind_null(m_stmt, index));\n    if (succeed && m_fullTrace) {\n        m_stream << index << \":\"\n                 << \";\";\n    }\n    WCTAssert(succeed);\n    WCDB_UNUSED(succeed);\n}\n\nvoid HandleStatement::bindPointer(void *ptr, int index, const Text &type, void (*destructor)(void *))\n{\n    WCTAssert(isPrepared());\n    WCTAssert(!isBusy());\n    bool succeed\n    = APIExit(sqlite3_bind_pointer(m_stmt, index, ptr, type.data(), destructor));\n    WCTAssert(succeed);\n    WCDB_UNUSED(succeed);\n}\n\nint HandleStatement::bindParameterIndex(const Text &parameterName)\n{\n    WCTAssert(isPrepared());\n    WCTAssert(!isBusy());\n    int index = sqlite3_bind_parameter_index(m_stmt, parameterName.data());\n    return index;\n}\n\nHandleStatement::Integer HandleStatement::getInteger(int index)\n{\n    WCTAssert(isPrepared());\n    WCTAssert(isBusy());\n    return static_cast<Integer>(sqlite3_column_int64(m_stmt, index));\n}\n\nHandleStatement::Float HandleStatement::getDouble(int index)\n{\n    WCTAssert(isPrepared());\n    WCTAssert(isBusy());\n    return static_cast<Float>(sqlite3_column_double(m_stmt, index));\n}\n\nHandleStatement::Text HandleStatement::getText(int index)\n{\n    WCTAssert(isPrepared());\n    WCTAssert(isBusy());\n    return UnsafeStringView(\n    reinterpret_cast<const char *>(sqlite3_column_text(m_stmt, index)),\n    sqlite3_column_bytes(m_stmt, index));\n}\n\nconst char16_t *HandleStatement::getText16(int index)\n{\n    WCTAssert(isPrepared());\n    WCTAssert(isBusy());\n    return reinterpret_cast<const char16_t *>(sqlite3_column_text16(m_stmt, index));\n}\n\nsize_t HandleStatement::getText16Length(int index)\n{\n    WCTAssert(isPrepared());\n    WCTAssert(isBusy());\n    return sqlite3_column_bytes16(m_stmt, index) / 2;\n}\n\nconst HandleStatement::BLOB HandleStatement::getBLOB(int index)\n{\n    WCTAssert(isPrepared());\n    WCTAssert(isBusy());\n    return BLOB::immutable(\n    reinterpret_cast<const unsigned char *>(sqlite3_column_blob(m_stmt, index)),\n    sqlite3_column_bytes(m_stmt, index));\n}\n\nvoid HandleStatement::bindValue(const Value &value, int index)\n{\n    switch (value.getType()) {\n    case ColumnType::Null:\n        return bindNull(index);\n    case ColumnType::Integer:\n        return bindInteger(value, index);\n    case ColumnType::Float:\n        return bindDouble(value, index);\n    case ColumnType::Text:\n        return bindText(value, index);\n    case ColumnType::BLOB:\n        return bindBLOB(value, index);\n    }\n}\n\nvoid HandleStatement::bindRow(const OneRowValue &row)\n{\n    for (int i = 1; i <= row.size(); i++) {\n        bindValue(row[i - 1], i);\n    }\n}\n\nValue HandleStatement::getValue(int index)\n{\n    switch (getType(index)) {\n    case ColumnType::Null:\n        return Value(nullptr);\n    case ColumnType::Integer:\n        return Value(getInteger(index));\n    case ColumnType::Float:\n        return Value(getDouble(index));\n    case ColumnType::Text:\n        return Value(getText(index));\n    case ColumnType::BLOB:\n        return Value(getBLOB(index));\n    }\n}\n\nOptionalOneColumn HandleStatement::getOneColumn(int index)\n{\n    OptionalOneColumn result;\n    bool succeed = false;\n    while ((succeed = step()) && !done()) {\n        if (!result.succeed()) {\n            result = OneColumnValue();\n        }\n        result->push_back(getValue(index));\n    }\n    if (!succeed) {\n        return NullOpt;\n    }\n    return !result.hasValue() ? OneColumnValue() : result;\n}\n\nOneRowValue HandleStatement::getOneRow()\n{\n    OneRowValue result;\n    int count = getNumberOfColumns();\n    for (int i = 0; i < count; i++) {\n        result.push_back(getValue(i));\n    }\n    return result;\n}\n\nOptionalMultiRows HandleStatement::getAllRows()\n{\n    OptionalMultiRows result;\n    bool succeed = false;\n    while ((succeed = step()) && !done()) {\n        if (!result.succeed()) {\n            result = MultiRowsValue();\n        }\n        result->push_back(getOneRow());\n    }\n    if (!succeed) {\n        return NullOpt;\n    }\n    return !result.hasValue() ? MultiRowsValue() : result;\n}\n\nsigned long long HandleStatement::getColumnSize(int index)\n{\n    WCTAssert(isPrepared());\n    WCTAssert(isBusy());\n    return sqlite3_column_bytes(m_stmt, index);\n}\n\nbool HandleStatement::isBusy()\n{\n    WCTAssert(isPrepared());\n    return sqlite3_stmt_busy(m_stmt) != 0;\n}\n\nvoid HandleStatement::enableAutoAddColumn()\n{\n    m_needAutoAddColumn = true;\n}\n\nbool HandleStatement::isReadOnly()\n{\n    WCTAssert(isPrepared());\n    return sqlite3_stmt_readonly(m_stmt) != 0;\n}\n\nbool HandleStatement::isPrepared()\n{\n    return m_stmt != nullptr;\n}\n\n#pragma mark - Full trace sql\nvoid HandleStatement::tryReportSQL()\n{\n    if (!m_fullTrace || !m_needReport || !isPrepared()) {\n        return;\n    }\n    UnsafeStringView sql = sqlite3_sql(m_stmt);\n    if (sql.hasPrefix(\"SELECT\")) {\n        m_stream << \"RowCount:\" << m_stepCount;\n    } else if (sql.hasPrefix(\"INSERT\")) {\n        m_stream << \"LastInsertedId:\" << getHandle()->getLastInsertedRowID();\n    } else if (sql.hasPrefix(\"DELETE\") || sql.hasPrefix(\"UPDATE\")) {\n        m_stream << \"Changes:\" << getHandle()->getChanges();\n    }\n    getHandle()->postSQLNotification(sql, m_stream.str());\n    clearReport();\n}\n\nvoid HandleStatement::clearReport()\n{\n    m_stream.str(\"\");\n    m_stream.clear();\n    m_needReport = false;\n    m_stepCount = 0;\n}\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/common/core/sqlite/HandleStatement.hpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/19\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"ColumnType.hpp\"\n#include \"HandleRelated.hpp\"\n#include \"SQLiteDeclaration.h\"\n#include \"Statement.hpp\"\n#include \"Value.hpp\"\n\nnamespace WCDB {\n\nclass HandleStatementDecorator;\n\nclass HandleStatement : public HandleRelated {\n    friend class AbstractHandle;\n    friend class HandleStatementDecorator;\n\npublic:\n    HandleStatement() = delete;\n    HandleStatement(const HandleStatement &) = delete;\n    HandleStatement &operator=(const HandleStatement &) = delete;\n\n    HandleStatement(HandleStatement &&other);\n    HandleStatement(AbstractHandle *handle);\n\n    void enableTableMonitor();\n\n    virtual ~HandleStatement() override;\n\n    virtual bool prepare(const Statement &statement);\n    bool prepareSQL(const UnsafeStringView &sql);\n    bool isPrepared();\n    virtual void finalize();\n\n    virtual bool step();\n    bool done();\n    virtual void reset();\n    virtual void clearBindings();\n\n    using Integer = ColumnTypeInfo<ColumnType::Integer>::UnderlyingType;\n    using Text = ColumnTypeInfo<ColumnType::Text>::UnderlyingType;\n    using Float = ColumnTypeInfo<ColumnType::Float>::UnderlyingType;\n    using BLOB = ColumnTypeInfo<ColumnType::BLOB>::UnderlyingType;\n\n    virtual void bindInteger(const Integer &value, int index = 1);\n    virtual void bindDouble(const Float &value, int index = 1);\n    virtual void bindText(const Text &value, int index = 1);\n    virtual void bindText16(const char16_t *value, size_t valueLength, int index = 1);\n    virtual void bindBLOB(const BLOB &value, int index = 1);\n    virtual void bindNull(int index = 1);\n    virtual void\n    bindPointer(void *ptr, int index, const Text &type, void (*destructor)(void *));\n    int bindParameterIndex(const Text &parameterName);\n\n    void bindValue(const Value &value, int index = 1);\n    void bindRow(const OneRowValue &row);\n\n    ColumnType getType(int index = 0);\n    signed long long getColumnSize(int index = 0);\n    int getNumberOfColumns();\n\n    Integer getInteger(int index = 0);\n    Float getDouble(int index = 0);\n    Text getText(int index = 0);\n    const char16_t *getText16(int index = 0);\n    size_t getText16Length(int index = 0);\n    const BLOB getBLOB(int index = 0);\n\n    Value getValue(int index = 0);\n    OptionalOneColumn getOneColumn(int index = 0);\n    OneRowValue getOneRow();\n    OptionalMultiRows getAllRows();\n\n    const UnsafeStringView getOriginColumnName(int index);\n    const UnsafeStringView getColumnName(int index);\n    const UnsafeStringView getColumnTableName(int index);\n    int getBindParameterCount();\n\n    bool isReadOnly();\n    void enableAutoAddColumn();\n\nprotected:\n    bool isBusy();\n\nprivate:\n    void analysisStatement(const Statement &statement);\n    bool tryExtractColumnInfo(const Statement &statement,\n                              const StringView &msg,\n                              StringView &columnName,\n                              StringView &tableName,\n                              StringView &schemaName,\n                              const BaseBinding **binding);\n    sqlite3_stmt *m_stmt;\n    bool m_done;\n    StringView m_newTable;\n    StringView m_modifiedTable;\n    bool m_needAutoAddColumn;\n    StringView m_sql;\n\n#pragma mark - Full trace sql\nprivate:\n    void tryReportSQL();\n    void clearReport();\n\n    bool m_fullTrace;\n    bool m_needReport;\n    int m_stepCount;\n    std::ostringstream m_stream;\n};\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/common/core/sqlite/TableAttribute.cpp",
    "content": "//\n// Created by 陈秋文 on 2023/8/16.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"TableAttribute.hpp\"\n\nnamespace WCDB {\n\nTableAttribute::TableAttribute(bool autoincrement, bool withoutRowid, bool isVirtual, StringView integerPrimaryKey)\n: autoincrement(autoincrement)\n, withoutRowid(withoutRowid)\n, isVirtual(isVirtual)\n, integerPrimaryKey(integerPrimaryKey)\n{\n}\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/core/sqlite/TableAttribute.hpp",
    "content": "//\n// Created by 陈秋文 on 2023/8/16.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"StringView.hpp\"\n\nnamespace WCDB {\n\nclass TableAttribute {\npublic:\n    TableAttribute(bool autoincrement, bool withoutRowid, bool isVirtual, StringView integerPrimaryKey);\n\n    bool autoincrement;\n    bool withoutRowid;\n    bool isVirtual;\n    StringView integerPrimaryKey;\n};\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/core/vacuum/VacuumHandleOperator.cpp",
    "content": "//\n// Created by qiuwenchen on 2023/12/23.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"VacuumHandleOperator.hpp\"\n#include \"CoreConst.h\"\n#include \"WINQ.h\"\n\nnamespace WCDB {\n\nconst char *VacuumHandleOperator::kOriginSchema = \"origin\";\n\nVacuumHandleOperator::VacuumHandleOperator(InnerHandle *handle)\n: HandleOperator(handle), Repair::VacuumDelegate(), m_tableWeight(0)\n{\n}\n\nVacuumHandleOperator::~VacuumHandleOperator()\n{\n}\n\n#pragma mark - Vacuum\nbool VacuumHandleOperator::executeVacuum()\n{\n    if (!configDatabase()) {\n        return false;\n    }\n    if (!initTables()) {\n        return false;\n    }\n    InnerHandle *handle = getHandle();\n    WCTAssert(handle->isOpened());\n    auto seqIter = m_tables.find(Syntax::sequenceTable);\n    if (seqIter != m_tables.end() && !copyWithouRowidTable(seqIter->second)) {\n        return false;\n    }\n    bool needCheckShadowTable = false;\n    for (const auto &table : m_tables) {\n        if (table.first.equal(Syntax::sequenceTable)) {\n            continue;\n        }\n        if (needCheckShadowTable) {\n            auto exist = handle->tableExists(table.first);\n            if (exist.failed()) {\n                return false;\n            }\n            if (exist.value()) {\n                continue;\n            }\n            needCheckShadowTable = false;\n        }\n        auto attribute = handle->getTableAttribute(kOriginSchema, table.first);\n        if (attribute.failed()) {\n            return false;\n        }\n        if (attribute.value().withoutRowid) {\n            if (!copyWithouRowidTable(table.second)) {\n                return false;\n            }\n        } else {\n            if (attribute.value().isVirtual) {\n                needCheckShadowTable = true;\n            }\n            if (!copyNormalTable(table.second)) {\n                return false;\n            }\n        }\n    }\n    for (const auto &sql : m_associatedSQLs) {\n        if (!handle->execute(sql)) {\n            return false;\n        }\n    }\n    handle->close();\n    return finishProgress();\n}\n\nconst Error &VacuumHandleOperator::getVacuumError()\n{\n    return getHandle()->getError();\n}\n\nbool VacuumHandleOperator::configDatabase()\n{\n    WCTAssert(!m_vacuumPath.empty());\n    WCTAssert(!m_originalPath.empty());\n    InnerHandle *handle = getHandle();\n    WCTAssert(!handle->isOpened());\n    handle->setPath(m_vacuumPath);\n    if (!handle->open()) {\n        return false;\n    }\n    if (!handle->execute(StatementPragma().pragma(Pragma::journalMode()).to(\"OFF\"))) {\n        return false;\n    }\n    if (!handle->execute(StatementPragma().pragma(Pragma::mmapSize()).to(2147418112))) {\n        return false;\n    }\n    if (!handle->execute(StatementPragma().pragma(Pragma::writableSchema()).to(true))) {\n        return false;\n    }\n    auto attach = StatementAttach().attach(m_originalPath).as(kOriginSchema);\n    if (handle->hasCipher()) {\n        Data cipher = handle->getRawCipherKey();\n        attach.key(UnsafeStringView((const char *) cipher.buffer(), cipher.size()));\n    }\n    if (!handle->execute(attach)) {\n        return false;\n    }\n    return true;\n}\n\nbool VacuumHandleOperator::initTables()\n{\n    InnerHandle *handle = getHandle();\n    WCTAssert(handle->isOpened());\n    if (!handle->prepare(StatementSelect()\n                         .select(Column::all())\n                         .from(TableOrSubquery(Syntax::masterTable).schema(kOriginSchema)))) {\n        return false;\n    }\n    if (!handle->step()) {\n        handle->finalize();\n        return false;\n    }\n    while (!handle->done()) {\n        auto row = handle->getOneRow();\n        WCTAssert(row.size() == 5);\n        const StringView &type = row[0].textValue();\n        if (type.equal(\"table\")) {\n            const StringView &name = row[1].textValue();\n            if (!name.hasPrefix(Syntax::builtinTablePrefix)\n                || name.equal(Syntax::sequenceTable)) {\n                TableInfo info;\n                info.name = name;\n                info.sql = row[4].textValue();\n                WCTAssert(m_tables.find(name) == m_tables.end());\n                m_tables.insert_or_assign(name, info);\n            }\n        } else if (type.equal(\"index\")) {\n            const StringView &name = row[1].textValue();\n            if (!name.hasPrefix(Syntax::builtinTablePrefix)) {\n                const StringView &tblName = row[2].textValue();\n                auto iter = m_tables.find(tblName);\n                WCTAssert(iter != m_tables.end());\n                if (iter != m_tables.end()) {\n                    iter->second.indexSQLs.push_back(row[4].textValue());\n                }\n            }\n        } else {\n            m_associatedSQLs.push_back(row[4].textValue());\n        }\n        if (!handle->step()) {\n            handle->finalize();\n            return false;\n        }\n    }\n    handle->finalize();\n    m_tableWeight = m_tables.size() > 0 ? 1.0 / m_tables.size() : 0;\n    return true;\n}\n\nbool VacuumHandleOperator::createTable(const TableInfo &info)\n{\n    InnerHandle *handle = getHandle();\n    WCTAssert(handle->isOpened());\n    if (!handle->execute(info.sql)) {\n        return false;\n    }\n    for (const auto &index : info.indexSQLs) {\n        if (!handle->execute(index)) {\n            return false;\n        }\n    }\n    return true;\n}\n\nbool VacuumHandleOperator::copyWithouRowidTable(const TableInfo &info)\n{\n    if (!createTable(info)) {\n        return false;\n    }\n    StringView protectedTableName = StringView::formatted(\"'%s'\", info.name.data());\n    StatementInsert insert\n    = StatementInsert()\n      .insertIntoTable(protectedTableName)\n      .values(StatementSelect()\n              .select(Column::all())\n              .from(TableOrSubquery(protectedTableName).schema(kOriginSchema)));\n    if (!getHandle()->execute(insert)) {\n        return false;\n    }\n    return increaseProgress(m_tableWeight);\n}\n\nbool VacuumHandleOperator::copyNormalTable(const TableInfo &info)\n{\n    if (!createTable(info)) {\n        return false;\n    }\n    InnerHandle *handle = getHandle();\n    WCTAssert(handle->isOpened());\n    StringView protectedTableName = StringView::formatted(\"'%s'\", info.name.data());\n    auto selectMaxRowid\n    = StatementSelect()\n      .select(Column::rowid().max())\n      .from(TableOrSubquery(protectedTableName).schema(kOriginSchema));\n    if (!handle->prepare(selectMaxRowid)) {\n        return false;\n    }\n    if (!handle->step()) {\n        handle->finalize();\n        return false;\n    }\n    if (handle->done()) {\n        handle->finalize();\n        return increaseProgress(m_tableWeight);\n    }\n    int64_t maxRowid = handle->getInteger();\n    handle->finalize();\n\n    auto selectMinRowid\n    = StatementSelect()\n      .select(Column::rowid().min())\n      .from(TableOrSubquery(protectedTableName).schema(kOriginSchema));\n    if (!handle->prepare(selectMinRowid)) {\n        return false;\n    }\n    if (!handle->step()) {\n        handle->finalize();\n        return false;\n    }\n    if (handle->done()) {\n        handle->finalize();\n        return increaseProgress(m_tableWeight);\n    }\n    int64_t minRowid = handle->getInteger();\n    handle->finalize();\n\n    auto optionalMetas = handle->getTableMeta(Schema(), info.name);\n    if (!optionalMetas.succeed()) {\n        return false;\n    }\n    auto &metas = optionalMetas.value();\n    Columns columns = { Column::rowid() };\n    for (const auto &meta : metas) {\n        columns.push_back(Column(meta.name));\n    }\n\n    auto insert = StatementInsert()\n                  .insertIntoTable(protectedTableName)\n                  .columns(columns)\n                  .values(StatementSelect()\n                          .select(columns)\n                          .from(TableOrSubquery(protectedTableName).schema(kOriginSchema))\n                          .where(Column::rowid() >= BindParameter())\n                          .order(Column::rowid().asOrder(Order::ASC))\n                          .limit(VacuumBatchCount));\n    if (!handle->prepare(insert)) {\n        return false;\n    }\n    int64_t curMinRowid = minRowid;\n    do {\n        handle->reset();\n        handle->bindInteger(curMinRowid);\n        if (!handle->step()) {\n            handle->finalize();\n            return false;\n        }\n        double incre = (double) (handle->getLastInsertedRowID() - curMinRowid + 1)\n                       / (maxRowid - minRowid + 1) * m_tableWeight;\n        WCTAssert(incre >= 0);\n        if (!increaseProgress(incre)) {\n            handle->finalize();\n            return false;\n        }\n        curMinRowid = handle->getLastInsertedRowID() + 1;\n    } while (handle->getChanges() > 0);\n    handle->finalize();\n    return true;\n}\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/core/vacuum/VacuumHandleOperator.hpp",
    "content": "//\n// Created by qiuwenchen on 2023/12/23.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"HandleOperator.hpp\"\n#include \"MasterItem.hpp\"\n#include \"StatementPragma.hpp\"\n#include \"Vacuum.hpp\"\n#include <vector>\n\nnamespace WCDB {\n\nclass VacuumHandleOperator : public HandleOperator, public Repair::VacuumDelegate {\npublic:\n    VacuumHandleOperator(InnerHandle *handle);\n    ~VacuumHandleOperator() override;\n\n#pragma mark - Vacuum\npublic:\n    bool executeVacuum() override final;\n    const Error &getVacuumError() override final;\n\nprivate:\n    struct TableInfo {\n        StringView name;\n        StringView sql;\n        std::list<StringView> indexSQLs;\n    };\n\n    static const char *kOriginSchema;\n\n    bool configDatabase();\n    bool initTables();\n    bool createTable(const TableInfo &info);\n    bool copyWithouRowidTable(const TableInfo &info);\n    bool copyNormalTable(const TableInfo &info);\n\n    StringViewMap<TableInfo> m_tables;\n    double m_tableWeight;\n    std::list<StringView> m_associatedSQLs; // View, Trigger\n};\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/common/platform/CrossPlatform.c",
    "content": "//\n// Created by qiuwenchen on 2022/9/15.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"CrossPlatform.h\"\n\n#if defined(__linux__) || defined(__ANDROID__)\n#include <errno.h>\n#include <unistd.h>\n\n#if __GLIBC__ == 2 && __GLIBC_MINOR__ < 30\n#include <sys/syscall.h>\n#define gettid() syscall(SYS_gettid)\n#endif\n\nint pthread_main_np()\n{\n    int pid = getpid();\n    int tid = gettid();\n    return pid == tid ? 1 : 0;\n}\n\n#ifdef __ANDROID__\n#include <sys/sysconf.h>\n\nint getdtablesize()\n{\n    return (int) sysconf(_SC_OPEN_MAX);\n}\n#endif /* __ANDROID__ */\n\n#endif /* defined(__linux__) || defined(__ANDROID__) */\n"
  },
  {
    "path": "src/common/platform/CrossPlatform.h",
    "content": "//\n// Created by qiuwenchen on 2022/9/15.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"Macro.h\"\n\n#pragma mark - path\n#ifndef _WIN32\n#define GetPathString(path) path.data()\n#else\n#define GetPathString(path) path.getWString().c_str()\n#endif\n\n#pragma mark - errno\n\n#ifndef EAUTH\n// Magic number, something unique to avoid being matched\n#define EAUTH 1550442950 //0x5c69e1c6\n#endif\n\n#ifndef EDEVERR\n// Magic number, something unique to avoid being matched\n#define EDEVERR 1550442951 //0x5c69e1c7\n#endif\n\n#pragma mark - mman\n\n#if defined(__linux__) || defined(__ANDROID__)\n#ifndef MAP_NOEXTEND\n// Not exists in Linux, set to 0 to avoid making a difference in OR operation\n#define MAP_NOEXTEND 0x0\n#endif /* ndef MAP_NOEXTEND */\n#endif /* defined(__linux__) || defined(__ANDROID__) */\n\n#pragma mark - pthread\n\n#ifndef _WIN32\n#include <pthread.h>\n#endif\n\n#if defined(__linux__) || defined(__ANDROID__)\n\nWCDB_EXTERN_C_BEGIN\nint pthread_main_np();\nWCDB_EXTERN_C_END\n#define pthread_setname_np(CHAR) pthread_setname_np(pthread_self(), CHAR)\n\n#endif /* defined(_linux__) || defined(__ANDROID__) */\n\n#pragma mark - stat\n\n#ifndef _WIN32\n#define StatType struct stat\n#define StatFunc stat\n#else\n#define StatType struct _stat64\n#define StatFunc _wstat64\n#endif\n\n#if defined(__linux__) || defined(__ANDROID__)\n#define st_atimespec st_atim\n#define st_mtimespec st_mtim\n#define st_ctimespec st_ctim\n#elif defined(_WIN32)\n#define st_atimespec st_atime\n#define st_mtimespec st_mtime\n#define st_ctimespec st_ctime\n#endif\n\n#pragma mark - unistd\n\n#ifndef _WIN32\n#include <unistd.h>\n#else\n#include <io.h>\n#endif\n\n#ifndef _WIN32\n#include <unistd.h>\n#else\n#include <io.h>\n#endif\n\n#ifdef __ANDROID__\nWCDB_EXTERN_C_BEGIN\nint getdtablesize();\nWCDB_EXTERN_C_END\n#endif /* __ANDROID__ */\n\n#pragma mark - file api\n\n#ifdef _WIN32\n#define wcdb_open ::_wopen\n#define wcdb_mkdir(path, mask) ::_wmkdir(path)\n#define wcdb_unlink ::_wunlink\n#define wcdb_remove ::_wremove\n#define wcdb_lseek ::_lseeki64\n#define FileFullAccess S_IREAD | S_IWRITE\n#define DirFullAccess 0\n#else\n#define wcdb_open ::open\n#define wcdb_mkdir ::mkdir\n#define wcdb_unlink ::unlink\n#define wcdb_remove ::remove\n#define wcdb_lseek ::lseek\n#define FileFullAccess S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH\n#define DirFullAccess S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH\n#endif //_WIN32\n\n#pragma mark - string\n\n#ifdef _WIN32\n#define strncasecmp _strnicmp\n#endif //_WIN32\n"
  },
  {
    "path": "src/common/platform/SysTypes.h",
    "content": "//\n// Created by qiuwenchen on 2023/6/6.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n#include <sys/types.h>\n#ifdef _WIN32\n#include <BaseTsd.h>\n#endif\n\nnamespace WCDB {\n\n#ifndef _WIN32\n\ntypedef off_t offset_t;\n\n#else\n\ntypedef SSIZE_T ssize_t;\ntypedef SSIZE_T offset_t;\n\n#endif //_WIN32\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/common/platform/WCTFileManager.cpp",
    "content": "//\n// Created by qiuwenchen on 2022/8/1.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"CommonCore.hpp\"\n#include \"FileManager.hpp\"\n#include <stdio.h>\n\nnamespace WCDB {\n\nvoid CommonCore::print(const UnsafeStringView &message)\n{\n    printf(\"%s\", message.data());\n}\n\nStringView FileManager::getTemporaryDirectory()\n{\n    return StringView();\n}\n\nbool FileManager::setFileProtection(const WCDB::UnsafeStringView &path,\n                                    WCDB::FileProtection fileProtection)\n{\n    WCDB_UNUSED(path);\n    WCDB_UNUSED(fileProtection);\n    return true;\n}\n\nOptional<WCDB::FileProtection>\nFileManager::getFileProtection(const WCDB::UnsafeStringView &path)\n{\n    WCDB_UNUSED(path);\n    return WCDB::FileProtection::None;\n}\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/platform/WCTOperationQueue.cpp",
    "content": "//\n// Created by qiuwenchen on 2022/8/1.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"Macro.h\"\n#include \"OperationQueueForMemory.hpp\"\n#include <stdio.h>\n\nnamespace WCDB {\n\nvoid *OperationQueueForMemory::registerNotificationWhenMemoryWarning()\n{\n    return nullptr;\n}\n\nvoid OperationQueueForMemory::unregisterNotificationWhenMemoryWarning(void *observer)\n{\n    WCDB_UNUSED(observer);\n}\n\nvoid OperationQueueForMemory::executeOperationWithAutoMemoryRelease(std::function<void(void)> operation)\n{\n    operation();\n}\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/repair/Info.plist",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">\n<plist version=\"1.0\">\n<dict>\n\t<key>CFBundleDevelopmentRegion</key>\n\t<string>en</string>\n\t<key>CFBundleExecutable</key>\n\t<string>$(EXECUTABLE_NAME)</string>\n\t<key>CFBundleIdentifier</key>\n\t<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>\n\t<key>CFBundleInfoDictionaryVersion</key>\n\t<string>6.0</string>\n\t<key>CFBundleName</key>\n\t<string>$(PRODUCT_NAME)</string>\n\t<key>CFBundlePackageType</key>\n\t<string>FMWK</string>\n\t<key>CFBundleShortVersionString</key>\n\t<string>1.0.0</string>\n\t<key>CFBundleVersion</key>\n\t<string>$(CURRENT_PROJECT_VERSION)</string>\n\t<key>NSHumanReadableCopyright</key>\n\t<string>Copyright © 2017 Tencent. All rights reserved.</string>\n\t<key>NSPrincipalClass</key>\n\t<string></string>\n</dict>\n</plist>\n"
  },
  {
    "path": "src/common/repair/RepairKit.h",
    "content": "//\n// Created by sanhuazhang on 2018/05/19\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"Factory.hpp\"\n#include \"FactoryBackup.hpp\"\n#include \"FactoryDepositor.hpp\"\n#include \"FactoryRenewer.hpp\"\n#include \"FactoryRetriever.hpp\"\n#include \"FactoryVacuum.hpp\"\n\n#include \"Assemble.hpp\"\n#include \"Cell.hpp\"\n\n#if WCDB_USE_BUILTIN_SQLITE_REPAIR\n#include \"SQLiteAssembler.hpp\"\n#include \"SQLiteLocker.hpp\"\n#endif /* WCDB_USE_BUILTIN_SQLITE_REPAIR */\n"
  },
  {
    "path": "src/common/repair/SQLiteRepairKit.modulemap",
    "content": "framework module sqliterk {\n  umbrella header \"SQLiteRepairKit.h\"\n\n  export *\n  module * { export * }\n}\n"
  },
  {
    "path": "src/common/repair/basic/Assemble.cpp",
    "content": "//\n// Created by sanhuazhang on 2019/08/27\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"Assemble.hpp\"\n#include \"Assertion.hpp\"\n#include \"Cell.hpp\"\n\nnamespace WCDB {\n\nnamespace Repair {\n\nAssembleDelegate::AssembleDelegate()\n: m_duplicatedIgnorable(false), m_duplicatedReplaceable(false)\n{\n}\n\nAssembleDelegate::~AssembleDelegate() = default;\n\nvoid AssembleDelegate::markDuplicatedAsIgnorable(bool ignorable)\n{\n    m_duplicatedIgnorable = ignorable;\n}\n\nvoid AssembleDelegate::markDuplicatedAsReplaceable(bool replaceable)\n{\n    m_duplicatedReplaceable = replaceable;\n}\n\nbool AssembleDelegate::isDuplicatedIgnorable() const\n{\n    return m_duplicatedIgnorable;\n}\n\nbool AssembleDelegate::isDuplicatedReplaceable() const\n{\n    return m_duplicatedReplaceable;\n}\n\nAssembleDelegateHolder::AssembleDelegateHolder() : m_assembleDelegate(nullptr)\n{\n}\n\nvoid AssembleDelegateHolder::setAssembleDelegate(AssembleDelegate* delegate)\n{\n    m_assembleDelegate = delegate;\n}\n\nAssembleDelegateHolder::~AssembleDelegateHolder() = default;\n\n} //namespace Repair\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/common/repair/basic/Assemble.hpp",
    "content": "//\n// Created by sanhuazhang on 2019/08/27\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"Cipher.hpp\"\n#include <map>\n\nnamespace WCDB {\n\nclass Error;\n\nnamespace Repair {\n\nclass Cell;\n\nclass AssembleDelegate {\npublic:\n    AssembleDelegate();\n    virtual ~AssembleDelegate() = 0;\n\n    virtual void setAssemblePath(const UnsafeStringView &path) = 0;\n    virtual const StringView &getAssemblePath() const = 0;\n\n    virtual bool markAsAssembling() = 0;\n    virtual bool markAsAssembled() = 0;\n\n    virtual bool markAsMilestone() = 0;\n    virtual bool\n    assembleTable(const UnsafeStringView &tableName, const UnsafeStringView &sql)\n    = 0;\n    virtual bool isAssemblingTableWithoutRowid() const = 0;\n    virtual bool assembleSequence(const UnsafeStringView &tableName, int64_t sequence) = 0;\n    virtual bool assembleCell(const Cell &cell) = 0;\n    void markDuplicatedAsIgnorable(bool ignorable);\n    virtual void markDuplicatedAsReplaceable(bool replaceable);\n\n    virtual bool assembleSQL(const UnsafeStringView &sql) = 0;\n\n    virtual const Error &getAssembleError() const = 0;\n\n    virtual void suspendAssemble() = 0;\n    virtual void finishAssemble() = 0;\n\nprotected:\n    bool isDuplicatedIgnorable() const;\n    bool isDuplicatedReplaceable() const;\n\nprivate:\n    bool m_duplicatedIgnorable;\n    bool m_duplicatedReplaceable;\n};\n\nclass AssembleDelegateHolder {\npublic:\n    AssembleDelegateHolder();\n    virtual ~AssembleDelegateHolder() = 0;\n    void setAssembleDelegate(AssembleDelegate *delegate);\n\nprotected:\n    AssembleDelegate *m_assembleDelegate;\n};\n\n} //namespace Repair\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/common/repair/basic/Cipher.cpp",
    "content": "//\n// Created by qiuwenchen on 2022/11/28.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"Cipher.hpp\"\n\nnamespace WCDB {\n\nnamespace Repair {\n\nCipherDelegate::~CipherDelegate() = default;\n\nCipherDelegateHolder::CipherDelegateHolder() : m_cipherDelegate(nullptr)\n{\n}\n\nCipherDelegateHolder::~CipherDelegateHolder() = default;\n\nvoid CipherDelegateHolder::setCipherDelegate(CipherDelegate *delegate)\n{\n    m_cipherDelegate = delegate;\n}\n\n} //namespace Repair\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/common/repair/basic/Cipher.hpp",
    "content": "//\n// Created by qiuwenchen on 2022/11/28.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"StringView.hpp\"\n#include \"WCDBError.hpp\"\n\nnamespace WCDB {\n\nnamespace Repair {\n\nclass CipherDelegate {\npublic:\n    virtual ~CipherDelegate() = 0;\n    virtual bool isCipherDB() = 0;\n    virtual const Error &getCipherError() const = 0;\n    virtual bool openCipherInMemory() = 0;\n    virtual void closeCipher() = 0;\n    virtual void *getCipherContext() = 0;\n    virtual size_t getCipherPageSize() = 0;\n    virtual Optional<StringView> tryGetSaltFromDatabase(const UnsafeStringView &path) = 0;\n    virtual StringView getCipherSalt() = 0;\n    virtual bool setCipherSalt(const UnsafeStringView &salt) = 0;\n    virtual bool switchCipherSalt(const UnsafeStringView &salt) = 0;\n};\n\nclass CipherDelegateHolder {\npublic:\n    CipherDelegateHolder();\n    virtual ~CipherDelegateHolder() = 0;\n    void setCipherDelegate(CipherDelegate *delegate);\n\nprotected:\n    CipherDelegate *m_cipherDelegate;\n};\n\n} //namespace Repair\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/common/repair/basic/Crawlable.cpp",
    "content": "//\n// Created by sanhuazhang on 2018/09/26\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"Crawlable.hpp\"\n#include \"Assertion.hpp\"\n#include \"Cell.hpp\"\n#include \"Page.hpp\"\n#include \"Pager.hpp\"\n#include \"StringView.hpp\"\n#include \"ThreadedErrors.hpp\"\n\nnamespace WCDB {\n\nnamespace Repair {\n\n#pragma mark - Initialize\nCrawlable::Crawlable()\n: m_associatedPager(nullptr), m_suspend(false), m_isCrawling(false)\n{\n}\n\nCrawlable::~Crawlable() = default;\n\nvoid Crawlable::setAssociatedPager(Pager *pager)\n{\n    m_associatedPager = pager;\n}\n\nvoid Crawlable::suspend()\n{\n    m_suspend = true;\n}\n\n#pragma mark - Error\nconst Error &Crawlable::getCrawlError() const\n{\n    return m_associatedPager->getError();\n}\n\nvoid Crawlable::markAsCorrupted(int page, const UnsafeStringView &message)\n{\n    m_associatedPager->markAsCorrupted(page, message);\n    markAsError();\n}\n\nvoid Crawlable::markAsInterrupted()\n{\n    m_associatedPager->markAsError(Error::Code::Interrupt);\n    markAsError();\n}\n\nvoid Crawlable::markAsError()\n{\n    onCrawlerError();\n}\n\nbool Crawlable::crawl(int rootpageno)\n{\n    WCTAssert(m_associatedPager != nullptr);\n    WCTAssert(!m_isCrawling);\n    m_isCrawling = true;\n    std::set<int> crawledInteriorPages;\n    safeCrawl(rootpageno, crawledInteriorPages, 1);\n    m_isCrawling = false;\n    return m_associatedPager->getError().isOK();\n}\n\nvoid Crawlable::safeCrawl(int rootpageno, std::set<int> &crawledInteriorPages, int height)\n{\n    if (m_suspend || !canCrawlPage(rootpageno)) {\n        return;\n    }\n    Page rootpage(rootpageno, m_associatedPager);\n    if (!rootpage.initialize()) {\n        markAsError();\n        return;\n    }\n    if (height == 1) {\n        m_isCrawlingIndexTable = rootpage.isIndexPage();\n    } else if (m_isCrawlingIndexTable != rootpage.isIndexPage()) {\n        markAsCorrupted(rootpageno, \"Unmatched page type.\");\n        return;\n    }\n    if (!willCrawlPage(rootpage, height)) {\n        return;\n    }\n\n    if (crawledInteriorPages.find(rootpageno) != crawledInteriorPages.end()) {\n        //avoid dead loop\n        markAsCorrupted(rootpageno, \"Page is already crawled.\");\n        return;\n    }\n    crawledInteriorPages.emplace(rootpageno);\n    switch (rootpage.getType()) {\n    case Page::Type::InteriorTable:\n        for (int i = 0; i < rootpage.getNumberOfSubpages(); ++i) {\n            if (m_suspend) {\n                return;\n            }\n            int pageno = rootpage.getSubpageno(i);\n            safeCrawl(pageno, crawledInteriorPages, height + 1);\n        }\n        break;\n    case Page::Type::InteriorIndex:\n        for (int i = 0; i < rootpage.getNumberOfCells(); ++i) {\n            if (m_suspend) {\n                return;\n            }\n            Cell cell = rootpage.getCell(i);\n            if (cell.initialize()) {\n                safeCrawl(cell.getLeftChild(), crawledInteriorPages, height + 1);\n                onCellCrawled(cell);\n            } else {\n                markAsError();\n            }\n        }\n        safeCrawl(rootpage.getRightMostPage(), crawledInteriorPages, height + 1);\n        break;\n    case Page::Type::LeafTable:\n    case Page::Type::LeafIndex:\n        for (int i = 0; i < rootpage.getNumberOfCells(); ++i) {\n            if (m_suspend) {\n                return;\n            }\n            Cell cell = rootpage.getCell(i);\n            if (cell.initialize()) {\n                onCellCrawled(cell);\n            } else {\n                markAsError();\n            }\n        }\n        break;\n    default:\n        markAsCorrupted(\n        rootpageno, StringView::formatted(\"Unexpected page type: %d\", rootpage.getType()));\n        break;\n    }\n}\n\nvoid Crawlable::onCellCrawled(const Cell &cell)\n{\n    WCDB_UNUSED(cell);\n}\n\nbool Crawlable::canCrawlPage(uint32_t pageno)\n{\n    WCDB_UNUSED(pageno);\n    return true;\n}\n\nbool Crawlable::willCrawlPage(const Page &page, int height)\n{\n    WCDB_UNUSED(page);\n    WCDB_UNUSED(height);\n    return true;\n}\n\nvoid Crawlable::onCrawlerError()\n{\n}\n\n} //namespace Repair\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/common/repair/basic/Crawlable.hpp",
    "content": "//\n// Created by sanhuazhang on 2018/09/26\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"Pager.hpp\"\n#include <set>\n\nnamespace WCDB {\n\nnamespace Repair {\n\nclass Cell;\nclass Page;\nclass Pager;\n\nclass Crawlable {\n#pragma mark - Initialize\npublic:\n    Crawlable();\n    virtual ~Crawlable() = 0;\n\n    void setAssociatedPager(Pager *pager);\n\nprivate:\n    Pager *m_associatedPager;\n\n#pragma mark - Suspend\npublic:\n    void suspend(); // thread-safe\n\nprotected:\n    std::atomic<bool> m_suspend;\n\n#pragma mark - Error\npublic:\n    const Error &getCrawlError() const;\n\nprotected:\n    void markAsCorrupted(int page, const UnsafeStringView &message);\n    void markAsInterrupted();\n    void markAsError();\n\n#pragma mark - Crawlable\nprotected:\n    bool crawl(int rootpageno);\n\n    virtual bool canCrawlPage(uint32_t pageno);\n    virtual void onCellCrawled(const Cell &cell);\n    //return false to skip current page\n    virtual bool willCrawlPage(const Page &page, int height);\n    virtual void onCrawlerError();\n\nprivate:\n    void safeCrawl(int rootpageno, std::set<int> &crawledInteriorPages, int height);\n    bool m_isCrawling;\n    bool m_isCrawlingIndexTable;\n};\n\n} //namespace Repair\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/common/repair/basic/EncryptedSerialization.cpp",
    "content": "//\n// Created by 陈秋文 on 2023/9/3.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"EncryptedSerialization.hpp\"\n#include \"Assertion.hpp\"\n#include \"FileHandle.hpp\"\n#include \"FileManager.hpp\"\n#include \"Notifier.hpp\"\n#include \"SQLite.h\"\n#include <string.h>\n\nnamespace WCDB {\n\nnamespace Repair {\n\n#pragma mark - Serializable\nEncryptedSerializable::~EncryptedSerializable() = default;\n\nData EncryptedSerializable::encryptedSerialize() const\n{\n    Data rawData = serialize();\n    if (rawData.empty()) {\n        return false;\n    }\n\n    CipherDelegate *cipherDelegate = getCipherDelegate();\n    WCTAssert(cipherDelegate != nullptr);\n    size_t pageSize = cipherDelegate->getCipherPageSize();\n    if (pageSize == 0) {\n        setThreadedError(std::move(cipherDelegate->getCipherError()));\n        return false;\n    }\n    WCTAssert((pageSize & (pageSize - 1)) == 0);\n\n    StringView salt = cipherDelegate->getCipherSalt();\n    WCTAssert(salt.length() == saltBytes * 2);\n\n    void *pCodec = cipherDelegate->getCipherContext();\n    WCTAssert(pCodec != nullptr);\n\n    int reserveBytes = sqlcipher_codec_ctx_get_reservesize(pCodec);\n    WCTAssert(reserveBytes > 0);\n    size_t usableSize = pageSize - reserveBytes;\n    int pageCount = int((rawData.size() + saltBytes - 1) / usableSize) + 1;\n    size_t totalSize = pageCount * pageSize;\n\n    Data encryptData(totalSize);\n    if (encryptData.size() != totalSize) {\n        return false;\n    }\n\n    memset(encryptData.buffer(), 0, encryptData.size());\n    unsigned char *encryptAddr = encryptData.buffer();\n    unsigned char *dataAddr = rawData.buffer();\n\n    for (int pageNo = 1; pageNo <= pageCount; pageNo++) {\n        if (pageNo == 1) {\n            size_t length = usableSize > rawData.size() + saltBytes ?\n                            rawData.size() :\n                            usableSize - saltBytes;\n            memcpy(encryptAddr + saltBytes, dataAddr, length);\n        } else {\n            size_t length = pageNo * usableSize > rawData.size() + saltBytes ?\n                            rawData.size() + saltBytes - (pageNo - 1) * usableSize :\n                            usableSize;\n            memcpy(encryptAddr, dataAddr, length);\n        }\n\n        unsigned char *pData\n        = (unsigned char *) sqlite3Codec(pCodec, encryptAddr, pageNo, 6);\n        WCTAssert(pData != nullptr);\n        if (*pData == 0 && memcmp(pData, pData + 1, pageSize - 1) == 0) {\n            Error error(Error::Code::Corrupt,\n                        Error::Level::Warning,\n                        StringView::formatted(\n                        \"fail to encrypt data at page %d, total page %d\", pageNo, pageCount));\n            Notifier::shared().notify(error);\n            setThreadedError(std::move(error));\n            return false;\n        }\n        memcpy(encryptAddr, pData, pageSize);\n        encryptAddr += pageSize;\n        if (pageNo == 1) {\n            dataAddr += usableSize - saltBytes;\n        } else {\n            dataAddr += usableSize;\n        }\n    }\n    StringView salt2 = StringView::hexString(encryptData.subdata(saltBytes));\n    WCTAssert(salt2.compare(salt) == 0);\n    return encryptData;\n}\n\nbool EncryptedSerializable::encryptedSerialize(const UnsafeStringView &path) const\n{\n    WCTAssert(path.length() > 0);\n\n    Data encryptData = encryptedSerialize();\n    FileHandle fileHandle(path);\n    if (!fileHandle.open(FileHandle::Mode::OverWrite)) {\n        return false;\n    }\n    bool succeed = fileHandle.write(encryptData);\n    fileHandle.close();\n    FileManager::setFileProtectionCompleteUntilFirstUserAuthenticationIfNeeded(path);\n    return succeed;\n};\n\n#pragma mark - Deserializable\nDecryptedDeserializable::~DecryptedDeserializable() = default;\n\nbool DecryptedDeserializable::decryptedDeserialize(Data &rawData, bool reloadSalt)\n{\n    CipherDelegate *cipherDelegate = getCipherDelegate();\n    WCTAssert(cipherDelegate != nullptr);\n\n    size_t pageSize = cipherDelegate->getCipherPageSize();\n    if (pageSize == 0) {\n        setThreadedError(std::move(cipherDelegate->getCipherError()));\n        return false;\n    }\n    WCTAssert((pageSize & (pageSize - 1)) == 0);\n    if (rawData.size() % pageSize != 0) {\n        decryptFail(\"Data\");\n        return false;\n    }\n\n    if (reloadSalt) {\n        StringView salt = StringView::hexString(rawData.subdata(saltBytes));\n        if (!cipherDelegate->switchCipherSalt(salt)) {\n            setThreadedError(std::move(cipherDelegate->getCipherError()));\n            return false;\n        }\n    }\n\n    void *pCodec = cipherDelegate->getCipherContext();\n    WCTAssert(pCodec != nullptr);\n\n    int reserveBytes = sqlcipher_codec_ctx_get_reservesize(pCodec);\n    WCTAssert(reserveBytes > 0);\n    int pageCount = int(rawData.size() / pageSize);\n    size_t usableSize = pageSize - reserveBytes;\n    size_t totalSize = pageCount * usableSize - saltBytes;\n\n    Data decryptData(totalSize);\n    if (decryptData.size() != totalSize) {\n        return false;\n    }\n\n    unsigned char *rawAdder = rawData.buffer();\n    unsigned char *dataAdder = decryptData.buffer();\n    for (int pageNo = 1; pageNo <= pageCount; pageNo++) {\n        unsigned char *pData\n        = (unsigned char *) sqlite3Codec(pCodec, rawAdder, pageNo, 4);\n        if (pData == nullptr) {\n            decryptFail(StringView::formatted(\"Page %d\", pageNo));\n            return false;\n        }\n        if (pageNo == 1) {\n            memcpy(dataAdder, pData + saltBytes, usableSize - saltBytes);\n            dataAdder += usableSize - saltBytes;\n        } else {\n            memcpy(dataAdder, pData, usableSize);\n            dataAdder += usableSize;\n        }\n        rawAdder += pageSize;\n    }\n    if (!deserialize(decryptData)) {\n        return false;\n    }\n    return true;\n}\n\nbool DecryptedDeserializable::decryptedDeserialize(const UnsafeStringView &path, bool reloadSalt)\n{\n    FileHandle fileHandle(path);\n    if (!fileHandle.open(FileHandle::Mode::ReadOnly)) {\n        return false;\n    }\n\n    Data rawData = fileHandle.mapOrReadAllData();\n    if (rawData.empty()) {\n        return false;\n    }\n    return decryptedDeserialize(rawData, reloadSalt);\n}\n\n} //namespace Repair\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/common/repair/basic/EncryptedSerialization.hpp",
    "content": "//\n// Created by 陈秋文 on 2023/9/3.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"Cipher.hpp\"\n#include \"Serialization.hpp\"\n\nnamespace WCDB {\n\nnamespace Repair {\n\nconstexpr const uint8_t saltBytes = 16;\n\n#pragma mark - Serializable\nclass EncryptedSerializable : public Serializable {\npublic:\n    virtual ~EncryptedSerializable() override = 0;\n    Data encryptedSerialize() const;\n    bool encryptedSerialize(const UnsafeStringView &path) const;\n\nprotected:\n    virtual CipherDelegate *getCipherDelegate() const = 0;\n};\n\n#pragma mark - Deserializable\nclass DecryptedDeserializable : public Deserializable {\npublic:\n    virtual ~DecryptedDeserializable() override = 0;\n    bool decryptedDeserialize(Data &rawData, bool reloadSalt);\n    bool decryptedDeserialize(const UnsafeStringView &path, bool reloadSalt);\n    virtual void decryptFail(const UnsafeStringView &element) const = 0;\n\nprotected:\n    virtual CipherDelegate *getCipherDelegate() const = 0;\n};\n\n} //namespace Repair\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/common/repair/basic/MasterItem.cpp",
    "content": "//\n// Created by sanhuazhang on 2018/09/26\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"MasterItem.hpp\"\n#include \"StringView.hpp\"\n\nnamespace WCDB {\n\nnamespace Repair {\n\nMasterItem::MasterItem() : rootpage(0)\n{\n}\n\nbool MasterItem::isReservedTableName(const UnsafeStringView &tableName)\n{\n    return tableName.hasPrefix(\"sqlite_\");\n}\n\n} //namespace Repair\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/common/repair/basic/MasterItem.hpp",
    "content": "//\n// Created by sanhuazhang on 2018/09/26\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"StringView.hpp\"\n\nnamespace WCDB {\n\nnamespace Repair {\n\nstruct MasterItem {\npublic:\n    MasterItem();\n\n    static bool isReservedTableName(const UnsafeStringView &tableName);\n\n    StringView type;\n    StringView name;\n    StringView tableName;\n    StringView sql;\n    int rootpage;\n};\n\n} //namespace Repair\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/common/repair/basic/Repairman.cpp",
    "content": "//\n// Created by sanhuazhang on 2018/09/26\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"Repairman.hpp\"\n#include \"Assertion.hpp\"\n#include \"Cell.hpp\"\n#include \"CoreConst.h\"\n#include \"FileManager.hpp\"\n#include \"Notifier.hpp\"\n#include \"Page.hpp\"\n#include \"ThreadedErrors.hpp\"\n\nnamespace WCDB {\n\nnamespace Repair {\n\n#pragma mark - Initialize\nRepairman::Repairman(const UnsafeStringView &path)\n: Crawlable(), Progress(), m_pager(path), m_milestone(1000), m_mile(0)\n{\n    setAssociatedPager(&m_pager);\n}\n\nRepairman::~Repairman() = default;\n\nconst StringView &Repairman::getPath() const\n{\n    return m_pager.getPath();\n}\n\nint64_t Repairman::getTotalPageCount() const\n{\n    if (m_pageWeight.value() > 0) {\n        return (int64_t) (1.0 / m_pageWeight.value());\n    }\n    return 0;\n}\n\nint Repairman::getDisposedWalPageCount() const\n{\n    return m_pager.getDisposedWalPages();\n}\n\nbool Repairman::exit()\n{\n    if (!isErrorCritial()) {\n        return finishProgress();\n    }\n    return false;\n}\n\nbool Repairman::exit(bool result)\n{\n    if (result) {\n        return finishProgress();\n    }\n    return result;\n}\n\nOptional<bool> Repairman::isEmptyDatabase()\n{\n    auto fileSize = FileManager::getFileSize(getPath());\n    if (fileSize.succeed()) {\n        if (fileSize.value() == 0) {\n            Error error(Error::Code::Empty, Error::Level::Warning, \"Database is not found or empty.\");\n            error.infos.insert_or_assign(ErrorStringKeySource, ErrorSourceRepair);\n            error.infos.insert_or_assign(ErrorStringKeyAssociatePath, getPath());\n            Notifier::shared().notify(error);\n            return true;\n        } else {\n            return false;\n        }\n    } else {\n        setCriticalErrorWithSharedThreadedError();\n        return NullOpt;\n    }\n}\n\nbool Repairman::markAsAssembling()\n{\n    if (m_assembleDelegate->markAsAssembling()) {\n        return true;\n    }\n    setCriticalError(m_assembleDelegate->getAssembleError());\n    return false;\n}\n\nvoid Repairman::markAsAssembled()\n{\n    markAsMilestone();\n    if (!isErrorCritial() && !m_assembleDelegate->markAsAssembled()) {\n        setCriticalError(m_assembleDelegate->getAssembleError());\n    }\n}\n\nbool Repairman::markAsMilestone()\n{\n    m_mile = 0;\n    if (m_assembleDelegate->markAsMilestone()) {\n        markSegmentedScoreCounted();\n        return true;\n    }\n    markSegmentedScoreDropped();\n    tryUpgrateAssembleError();\n    return false;\n}\n\nbool Repairman::towardMilestone(int mile)\n{\n    m_mile += mile;\n    if (m_mile > m_milestone) {\n        return markAsMilestone();\n    }\n    return true;\n}\n\nbool Repairman::assembleTable(const UnsafeStringView &tableName, const UnsafeStringView &sql)\n{\n    if (m_assembleDelegate->assembleTable(tableName, sql)) {\n        if (markAsMilestone()) {\n            return true;\n        }\n    } else {\n        tryUpgrateAssembleError();\n    }\n    return false;\n}\n\nbool Repairman::assembleCell(const Cell &cell)\n{\n    if (m_assembleDelegate->assembleCell(cell)) {\n        markCellAsCounted(cell);\n        towardMilestone(1);\n        return true;\n    }\n    tryUpgrateAssembleError();\n    return false;\n}\n\nbool Repairman::assembleSequence(const UnsafeStringView &tableName, int64_t sequence)\n{\n    if (m_assembleDelegate->assembleSequence(tableName, sequence)) {\n        towardMilestone(1);\n        return true;\n    }\n    tryUpgrateAssembleError();\n    return false;\n}\n\nvoid Repairman::assembleAssociatedSQLs(const std::list<StringView> &sqls)\n{\n    for (const auto &sql : sqls) {\n        //ignore its errors\n        m_assembleDelegate->assembleSQL(sql);\n    }\n}\n\n#pragma mark - Crawlable\nvoid Repairman::onCrawlerError()\n{\n    tryUpgradeCrawlerError();\n}\n\n#pragma mark - Error\nint Repairman::tryUpgradeCrawlerError()\n{\n    Error error = m_pager.getError();\n    if (error.isCorruption()) {\n        error.level = Error::Level::Notice;\n    }\n    return tryUpgradeError(std::move(error));\n}\n\nint Repairman::tryUpgrateAssembleError()\n{\n    Error error = m_assembleDelegate->getAssembleError();\n    if (error.code() == Error::Code::Constraint && !isErrorCritial()) {\n        error.level = Error::Level::Notice;\n    }\n    return tryUpgradeError(std::move(error));\n}\n\nvoid Repairman::onErrorCritical()\n{\n    suspend();\n}\n\n#pragma mark - Evaluation\nvoid Repairman::markCellAsCounted(const Cell &cell)\n{\n    if (cell.getPage().isIndexPage()) {\n        return;\n    }\n    int numberOfCells = cell.getPage().getNumberOfCells();\n    WCTAssert(numberOfCells != 0);\n    if (numberOfCells > 0) {\n        Fraction cellWeight(1, numberOfCells);\n        increaseScore(m_pageWeight * cellWeight);\n    }\n}\n\nvoid Repairman::markPageAsCounted(const Page &page)\n{\n    if (page.getType() == Page::Type::LeafTable && page.getNumberOfCells() == 0) {\n        increaseScore(m_pageWeight);\n    }\n}\n\nvoid Repairman::setPageWeight(const Fraction &pageWeight)\n{\n    WCTAssert(m_pageWeight.value() == 0);\n    m_pageWeight = pageWeight;\n}\n\nconst Fraction &Repairman::getPageWeight() const\n{\n    return m_pageWeight;\n}\n\n} //namespace Repair\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/common/repair/basic/Repairman.hpp",
    "content": "//\n// Created by sanhuazhang on 2018/09/26\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"Assemble.hpp\"\n#include \"Cipher.hpp\"\n#include \"Crawlable.hpp\"\n#include \"ErrorProne.hpp\"\n#include \"Progress.hpp\"\n#include \"Scoreable.hpp\"\n#include \"UpgradeableErrorProne.hpp\"\n#include \"WCDBOptional.hpp\"\n#include <list>\n\nnamespace WCDB {\n\nnamespace Repair {\n\nclass Repairman : public Crawlable,\n                  public UpgradeableErrorProne,\n                  public Progress,\n                  public SegmentedScoreable,\n                  public CipherDelegateHolder,\n                  public AssembleDelegateHolder {\n#pragma mark - Initialize\npublic:\n    Repairman(const UnsafeStringView &path);\n    virtual ~Repairman() override = 0;\n\n    const StringView &getPath() const;\n    int64_t getTotalPageCount() const;\n    int getDisposedWalPageCount() const;\n\nprotected:\n    Optional<bool> isEmptyDatabase();\n    bool exit();\n    bool exit(bool result);\n\n#pragma mark - Crawlable\nprotected:\n    void onCrawlerError() override final;\n    Pager m_pager;\n\n#pragma mark - Error\nprotected:\n    int tryUpgrateAssembleError();\n    int tryUpgradeCrawlerError();\n\n    virtual void onErrorCritical() override;\n\n#pragma mark - Assemble\nprotected:\n    bool markAsAssembling();\n    void markAsAssembled();\n\n    bool assembleTable(const UnsafeStringView &tableName, const UnsafeStringView &sql);\n    bool assembleCell(const Cell &cell);\n    bool assembleSequence(const UnsafeStringView &tableName, int64_t sequence);\n    void assembleAssociatedSQLs(const std::list<StringView> &sqls);\n\nprotected:\n    bool towardMilestone(int mile);\n\nprivate:\n    bool markAsMilestone();\n    int m_milestone;\n    int m_mile;\n\n#pragma mark - Evaluation\nprotected:\n    void setPageWeight(const Fraction &pageWeight);\n    const Fraction &getPageWeight() const;\n    void markCellAsCounted(const Cell &cell);\n    void markPageAsCounted(const Page &page);\n\nprivate:\n    Fraction m_pageWeight;\n};\n\n} //namespace Repair\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/common/repair/basic/Scoreable.cpp",
    "content": "//\n// Created by sanhuazhang on 2018/09/26\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"Scoreable.hpp\"\n#include \"Assertion.hpp\"\n#include \"Console.hpp\"\n#include <cmath>\n\nnamespace WCDB {\n\nnamespace Repair {\n\nScoreable::~Scoreable() = default;\n\nconst Fraction &Scoreable::getScore() const\n{\n    return m_score;\n}\n\nvoid Scoreable::increaseScore(const Fraction &increment)\n{\n    m_score += increment;\n    WCTAssert(m_score.value() <= 1.0);\n    if (m_score.value() > 1.0) {\n        m_score = 1;\n    }\n}\n\nSegmentedScoreable::~SegmentedScoreable() = default;\n\nconst Fraction &SegmentedScoreable::getScore() const\n{\n    WCTAssert(m_segmentedScore.value() == 0);\n    return Scoreable::getScore();\n}\n\nvoid SegmentedScoreable::markSegmentedScoreCounted()\n{\n    Scoreable::increaseScore(m_segmentedScore);\n    m_segmentedScore = 0;\n}\n\nvoid SegmentedScoreable::markSegmentedScoreDropped()\n{\n    m_segmentedScore = 0;\n}\n\nvoid SegmentedScoreable::increaseScore(const Fraction &increment)\n{\n    m_segmentedScore += increment;\n    WCTAssert((Scoreable::getScore() + m_segmentedScore).value() <= 1.0);\n}\n\n} //namespace Repair\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/common/repair/basic/Scoreable.hpp",
    "content": "//\n// Created by sanhuazhang on 2018/09/26\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"Fraction.hpp\"\n\nnamespace WCDB {\n\nnamespace Repair {\n\nclass Scoreable {\npublic:\n    virtual ~Scoreable() = 0;\n    const Fraction &getScore() const;\n\nprotected:\n    void increaseScore(const Fraction &fraction);\n\nprivate:\n    Fraction m_score;\n};\n\nclass SegmentedScoreable : public Scoreable {\npublic:\n    virtual ~SegmentedScoreable() override = 0;\n    const Fraction &getScore() const;\n\nprotected:\n    void markSegmentedScoreCounted();\n    void markSegmentedScoreDropped();\n    void increaseScore(const Fraction &fraction);\n\nprivate:\n    using Scoreable::increaseScore;\n    using Scoreable::getScore;\n    Fraction m_segmentedScore;\n};\n\n} //namespace Repair\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/common/repair/basic/SequenceItem.cpp",
    "content": "//\n// Created by sanhuazhang on 2018/09/26\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"SequenceItem.hpp\"\n\nnamespace WCDB {\n\nnamespace Repair {\n\nSequenceItem::SequenceItem() : seq(0)\n{\n}\n\n} //namespace Repair\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/common/repair/basic/SequenceItem.hpp",
    "content": "//\n// Created by sanhuazhang on 2018/09/26\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"StringView.hpp\"\n\nnamespace WCDB {\n\nnamespace Repair {\n\nstruct SequenceItem {\n    SequenceItem();\n\n    StringView name;\n    int64_t seq;\n};\n\n} //namespace Repair\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/common/repair/basic/UpgradeableErrorProne.cpp",
    "content": "//\n// Created by sanhuazhang on 2018/09/26\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"UpgradeableErrorProne.hpp\"\n#include \"Assertion.hpp\"\n#include \"ThreadedErrors.hpp\"\n\nnamespace WCDB {\n\nnamespace Repair {\n\nUpgradeableErrorProne::UpgradeableErrorProne() : m_severity(Severity::None)\n{\n}\n\nUpgradeableErrorProne::~UpgradeableErrorProne() = default;\n\nint UpgradeableErrorProne::getErrorSeverity() const\n{\n    return m_severity;\n}\n\nbool UpgradeableErrorProne::isErrorCritial() const\n{\n    return m_severity >= Severity::Critical;\n}\n\nint UpgradeableErrorProne::errorSeverity(const Error &error)\n{\n    if (error.level == Error::Level::Ignore) {\n        if (error.code() != Error::Code::Interrupt) {\n            return -1;\n        }\n    } else if (error.level < Error::Level::Error) {\n        return -1;\n    }\n    switch (error.code()) {\n    case Error::Code::Full:\n        return Severity::Critical + 3;\n    case Error::Code::Corrupt:\n    case Error::Code::NotADatabase:\n        return Severity::Critical + 2;\n    case Error::Code::IOError:\n        return Severity::Critical + 1;\n    case Error::Code::NoMemory:\n    case Error::Code::Interrupt:\n        return Severity::Critical;\n    case Error::Code::OK:\n        return Severity::None;\n    default:\n        return Severity::Normal;\n    }\n}\n\nint UpgradeableErrorProne::tryUpgradeError(const Error &error)\n{\n    int severity = errorSeverity(error);\n    if (severity > m_severity) {\n        ErrorProne::setError(error);\n        setSeverity(severity);\n    }\n    return m_severity;\n}\n\nint UpgradeableErrorProne::tryUpgradeError(Error &&error)\n{\n    int severity = errorSeverity(error);\n    if (severity > m_severity) {\n        ErrorProne::setError(std::move(error));\n        setSeverity(severity);\n    }\n    return m_severity;\n}\n\nint UpgradeableErrorProne::tryUpgradeErrorWithSharedThreadedError()\n{\n    return tryUpgradeError(std::move(ThreadedErrors::shared().moveThreadedError()));\n}\n\nvoid UpgradeableErrorProne::setCriticalError(const Error &error)\n{\n    ErrorProne::setError(error);\n    setSeverity(Severity::MostCritical);\n    onErrorCritical();\n}\n\nvoid UpgradeableErrorProne::setCriticalError(Error &&error)\n{\n    ErrorProne::setError(std::move(error));\n    setSeverity(Severity::MostCritical);\n    onErrorCritical();\n}\n\nvoid UpgradeableErrorProne::setCriticalErrorWithSharedThreadedError()\n{\n    setCriticalError(std::move(ThreadedErrors::shared().moveThreadedError()));\n}\n\nvoid UpgradeableErrorProne::setSeverity(int severity)\n{\n    WCTAssert(severity > m_severity);\n    WCTAssert(m_severity < Severity::Critical);\n    if (severity > m_severity) {\n        m_severity = severity;\n        if (m_severity >= Severity::Critical) {\n            onErrorCritical();\n        }\n    }\n}\n\nvoid UpgradeableErrorProne::onErrorCritical()\n{\n}\n\n} //namespace Repair\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/common/repair/basic/UpgradeableErrorProne.hpp",
    "content": "//\n// Created by sanhuazhang on 2018/09/26\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"ErrorProne.hpp\"\n#include <limits>\n\nnamespace WCDB {\n\nnamespace Repair {\n\nclass UpgradeableErrorProne : private ErrorProne {\npublic:\n    UpgradeableErrorProne();\n    virtual ~UpgradeableErrorProne() override = 0;\n    enum Severity {\n        MostCritical = std::numeric_limits<int>::max(),\n        Critical = 1,\n        Normal = 0,\n        None = std::numeric_limits<int>::min(),\n    };\n\n    using ErrorProne::getError;\n    int getErrorSeverity() const;\n    bool isErrorCritial() const;\n\nprotected:\n    int errorSeverity(const Error &error);\n\n    int tryUpgradeError(const Error &newError);\n    int tryUpgradeError(Error &&newError);\n    int tryUpgradeErrorWithSharedThreadedError();\n\n    void setCriticalError(const Error &error);\n    void setCriticalError(Error &&error);\n    void setCriticalErrorWithSharedThreadedError();\n\n    virtual void onErrorCritical();\n\nprivate:\n    void setSeverity(int severity);\n    int m_severity;\n};\n\n} //namespace Repair\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/common/repair/basic/Vacuum.cpp",
    "content": "//\n// Created by qiuwenchen on 2023/12/23.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"Vacuum.hpp\"\n\nnamespace WCDB {\n\nnamespace Repair {\n\nVacuumDelegate::VacuumDelegate() = default;\n\nVacuumDelegate::~VacuumDelegate() = default;\n\nvoid VacuumDelegate::setOriginalDatabase(const UnsafeStringView &originalPath)\n{\n    m_originalPath = originalPath;\n}\n\nvoid VacuumDelegate::setVacuumDatabase(const UnsafeStringView &vacuumPath)\n{\n    m_vacuumPath = vacuumPath;\n}\n\nVacuumDelegateHolder::VacuumDelegateHolder() : m_vacuumDelegate(nullptr)\n{\n}\n\nvoid VacuumDelegateHolder::setVacuumDelegate(VacuumDelegate *delegate)\n{\n    m_vacuumDelegate = delegate;\n}\n\nVacuumDelegateHolder::~VacuumDelegateHolder() = default;\n\n} //namespace Repair\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/common/repair/basic/Vacuum.hpp",
    "content": "//\n// Created by qiuwenchen on 2023/12/23.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"Progress.hpp\"\n#include \"StringView.hpp\"\n#include \"WCDBError.hpp\"\n\nnamespace WCDB {\n\nnamespace Repair {\n\nclass VacuumDelegate : public Progress {\npublic:\n    VacuumDelegate();\n    virtual ~VacuumDelegate() = 0;\n\n    void setOriginalDatabase(const UnsafeStringView &originalPath);\n    void setVacuumDatabase(const UnsafeStringView &vacuumPath);\n\n    virtual bool executeVacuum() = 0;\n    virtual const Error &getVacuumError() = 0;\n\nprotected:\n    StringView m_originalPath;\n    StringView m_vacuumPath;\n};\n\nclass VacuumDelegateHolder {\npublic:\n    VacuumDelegateHolder();\n    virtual ~VacuumDelegateHolder() = 0;\n    void setVacuumDelegate(VacuumDelegate *delegate);\n\nprotected:\n    VacuumDelegate *m_vacuumDelegate;\n};\n\n} //namespace Repair\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/common/repair/crawl/FullCrawler.cpp",
    "content": "//\n// Created by sanhuazhang on 2018/05/31\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"FullCrawler.hpp\"\n#include \"Assemble.hpp\"\n#include \"Assertion.hpp\"\n#include \"MasterItem.hpp\"\n#include \"Page.hpp\"\n#include \"SequenceCrawler.hpp\"\n#include \"SequenceItem.hpp\"\n#include \"StringView.hpp\"\n#include \"SyntaxCommonConst.hpp\"\n\nnamespace WCDB {\n\nnamespace Repair {\n\n#pragma mark - Initialize\nFullCrawler::FullCrawler(const UnsafeStringView &source)\n: Repairman(source), m_pageCount(0), m_masterCrawler(), m_sequenceCrawler()\n{\n    m_sequenceCrawler.setAssociatedPager(&m_pager);\n    m_masterCrawler.setAssociatedPager(&m_pager);\n}\n\nFullCrawler::~FullCrawler() = default;\n\nvoid FullCrawler::setPageCount(int64_t pageCount)\n{\n    m_pageCount = pageCount;\n}\n\n#pragma mark - Repair\nbool FullCrawler::work()\n{\n    auto isEmpty = isEmptyDatabase();\n    if (isEmpty.succeed()) {\n        if (isEmpty.value()) {\n            return exit(true);\n        }\n    } else {\n        return exit(false);\n    }\n\n    if (m_cipherDelegate->isCipherDB()) {\n        size_t pageSize = m_cipherDelegate->getCipherPageSize();\n        if (pageSize == 0) {\n            setCriticalError(m_cipherDelegate->getCipherError());\n            return exit(false);\n        }\n        void *pCodec = m_cipherDelegate->getCipherContext();\n        if (pCodec == nullptr) {\n            setCriticalError(m_cipherDelegate->getCipherError());\n            return exit(false);\n        }\n        m_pager.setCipherContext(pCodec);\n        m_pager.setPageSize((int) pageSize);\n    }\n\n    if (!m_pager.initialize()) {\n        if (m_pager.getError().isCorruption()) {\n            tryUpgradeCrawlerError();\n            return exit(true);\n        } else {\n            setCriticalError(m_pager.getError());\n            return exit(false);\n        }\n    }\n\n    //calculate score\n    int64_t numbersOfLeafTablePages = 0;\n    if (m_pageCount != 0) {\n        numbersOfLeafTablePages = m_pageCount;\n    } else {\n        for (int i = 1; i <= m_pager.getNumberOfPages(); ++i) {\n            Page page(i, &m_pager);\n            auto type = page.acquireType();\n            // treat as leaf table if unknown\n            if (type.failed() || type.value() == Page::Type::LeafTable) {\n                ++numbersOfLeafTablePages;\n            }\n        }\n    }\n    // If there are only without-rowid tables in the db, numbersOfLeafTablePages will be 0\n    setPageWeight(Fraction(1, numbersOfLeafTablePages == 0 ? 1 : numbersOfLeafTablePages));\n\n    if (markAsAssembling()) {\n        if (!m_masterCrawler.work(this) || isErrorCritial()) {\n            markAsAssembled();\n            return exit();\n        }\n        for (const auto &element : m_associatedSQLs) {\n            assembleAssociatedSQLs(element.second);\n        }\n        markAsAssembled();\n    }\n\n    return exit();\n}\n\n#pragma mark - Crawlable\nvoid FullCrawler::onCellCrawled(const Cell &cell)\n{\n    if (isErrorCritial()) {\n        return;\n    }\n    assembleCell(cell);\n}\n\nbool FullCrawler::willCrawlPage(const Page &page, int)\n{\n    if (isErrorCritial()) {\n        return false;\n    }\n    markPageAsCounted(page);\n    if (page.getType() == Page::Type::LeafTable) {\n        increaseProgress(getPageWeight().value());\n    }\n    m_assembleDelegate->markDuplicatedAsReplaceable(\n    m_pager.containPageInWal(page.number));\n    return true;\n}\n\n#pragma mark - Filter\nvoid FullCrawler::filter(const Filter &tableShouldBeCrawled)\n{\n    m_filter = tableShouldBeCrawled;\n}\n\nbool FullCrawler::filter(const UnsafeStringView &tableName)\n{\n    bool result = true;\n    if (m_filter != nullptr) {\n        result = m_filter(tableName);\n    }\n    return result;\n}\n\n#pragma mark - Error\nvoid FullCrawler::onErrorCritical()\n{\n    m_masterCrawler.suspend();\n    m_sequenceCrawler.suspend();\n    Repairman::onErrorCritical();\n}\n\n#pragma mark - MasterCrawlerDelegate\nvoid FullCrawler::onMasterPageCrawled(const Page &page)\n{\n    if (page.getType() == Page::Type::LeafTable) {\n        increaseProgress(getPageWeight().value());\n    }\n    markPageAsCounted(page);\n}\n\nvoid FullCrawler::onMasterCellCrawled(const Cell &cell, const MasterItem &master)\n{\n    if (isErrorCritial()) {\n        return;\n    }\n    markCellAsCounted(cell);\n    if (master.name == Syntax::sequenceTable) {\n        WCTAssert(master.type.caseInsensitiveEqual(\"table\"));\n        WCTAssert(master.tableName.caseInsensitiveEqual(master.name));\n        m_sequenceCrawler.work(master.rootpage, this);\n    } else if (!filter(master.tableName)\n               || MasterItem::isReservedTableName(master.name)\n               || MasterItem::isReservedTableName(master.tableName)) {\n        //Skip no backup table and sqlite reserved table\n        return;\n    } else {\n        if (master.type.caseInsensitiveEqual(\"table\")) {\n            WCTAssert(master.tableName.caseInsensitiveEqual(master.name));\n            if (assembleTable(master.name, master.sql)) {\n                crawl(master.rootpage);\n            }\n        } else {\n            if (!master.sql.empty()) {\n                m_associatedSQLs[master.tableName].push_back(master.sql);\n            }\n        }\n    }\n}\n\nvoid FullCrawler::onMasterCrawlerError()\n{\n    tryUpgradeCrawlerError();\n}\n\n#pragma mark - SequenceCrawlerDelegate\nvoid FullCrawler::onSequencePageCrawled(const Page &page)\n{\n    if (isErrorCritial()) {\n        return;\n    }\n    if (page.getType() == Page::Type::LeafTable) {\n        increaseProgress(getPageWeight().value());\n    }\n    markPageAsCounted(page);\n}\n\nvoid FullCrawler::onSequenceCellCrawled(const Cell &cell, const SequenceItem &sequence)\n{\n    if (isErrorCritial()) {\n        return;\n    }\n    if (assembleSequence(sequence.name, sequence.seq)) {\n        markCellAsCounted(cell);\n    }\n}\n\nvoid FullCrawler::onSequenceCrawlerError()\n{\n    tryUpgradeCrawlerError();\n}\n\n} //namespace Repair\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/common/repair/crawl/FullCrawler.hpp",
    "content": "//\n// Created by sanhuazhang on 2018/05/31\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"Assemble.hpp\"\n#include \"Backup.hpp\"\n#include \"Crawlable.hpp\"\n#include \"MasterCrawler.hpp\"\n#include \"Repairman.hpp\"\n#include \"SequenceCrawler.hpp\"\n#include <list>\n#include <map>\n\nnamespace WCDB {\n\nnamespace Repair {\n\nclass FullCrawler final : public Repairman, public MasterCrawlerDelegate, public SequenceCrawlerDelegate {\n#pragma mark - Initialize\npublic:\n    FullCrawler(const UnsafeStringView &source);\n    ~FullCrawler() override;\n    void setPageCount(int64_t pageCount);\n\nprivate:\n    int64_t m_pageCount;\n\n#pragma mark - Repair\npublic:\n    bool work();\n\nprotected:\n    StringViewMap<std::list<StringView>> m_associatedSQLs;\n\n#pragma mark - Crawlable\nprotected:\n    void onCellCrawled(const Cell &cell) override final;\n    bool willCrawlPage(const Page &, int) override final;\n\npublic:\n    typedef Backup::Filter Filter;\n    void filter(const Filter &tableShouldBeCrawled);\n\nprotected:\n    bool filter(const UnsafeStringView &tableName);\n    Filter m_filter;\n\n#pragma mark - Error\nprotected:\n    void onErrorCritical() override final;\n\n#pragma mark - MasterCrawlerDelegate\nprotected:\n    void onMasterPageCrawled(const Page &page) override final;\n    void onMasterCellCrawled(const Cell &cell, const MasterItem &master) override final;\n    void onMasterCrawlerError() override final;\n\n    MasterCrawler m_masterCrawler;\n\n#pragma mark - SequenceCrawlerDelegate\nprotected:\n    void onSequencePageCrawled(const Page &page) override final;\n    void onSequenceCellCrawled(const Cell &cell, const SequenceItem &sequence) override final;\n    void onSequenceCrawlerError() override final;\n\n    SequenceCrawler m_sequenceCrawler;\n};\n\n} //namespace Repair\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/common/repair/crawl/MasterCrawler.cpp",
    "content": "//\n// Created by sanhuazhang on 2018/05/31\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"MasterCrawler.hpp\"\n#include \"Assertion.hpp\"\n#include \"Cell.hpp\"\n#include \"MasterItem.hpp\"\n#include \"Page.hpp\"\n#include \"StringView.hpp\"\n\nnamespace WCDB {\n\nnamespace Repair {\n\nMasterCrawlerDelegate::~MasterCrawlerDelegate() = default;\n\nMasterCrawler::MasterCrawler() : Crawlable(), m_delegate(nullptr)\n{\n}\n\nMasterCrawler::~MasterCrawler() = default;\n\nbool MasterCrawler::work(MasterCrawlerDelegate *delegate)\n{\n    WCTAssert(delegate != nullptr);\n    m_delegate = delegate;\n    bool result = crawl(1);\n    m_delegate = nullptr;\n    return result;\n}\n\nvoid MasterCrawler::onCellCrawled(const Cell &cell)\n{\n    MasterItem master;\n    if (cell.getValueType(0) == Cell::Type::Text) {\n        master.type = cell.stringValue(0);\n    }\n    if (cell.getValueType(1) == Cell::Type::Text) {\n        master.name = cell.stringValue(1);\n    }\n    if (cell.getValueType(2) == Cell::Type::Text) {\n        master.tableName = cell.stringValue(2);\n    }\n    if (cell.getValueType(3) == Cell::Type::Integer) {\n        master.rootpage = (int) cell.integerValue(3);\n        if (master.rootpage <= 0) {\n            markAsCorrupted(cell.getPage().number,\n                            StringView::formatted(\"Root page: %d in Master is less than or equal to 0.\",\n                                                  master.rootpage));\n            return;\n        }\n    }\n    if (cell.getValueType(4) == Cell::Type::Text) {\n        master.sql = cell.stringValue(4);\n    }\n    m_delegate->onMasterCellCrawled(cell, master);\n}\n\nbool MasterCrawler::willCrawlPage(const Page &page, int)\n{\n    m_delegate->onMasterPageCrawled(page);\n    return true;\n}\n\nvoid MasterCrawler::onCrawlerError()\n{\n    m_delegate->onMasterCrawlerError();\n}\n\n} //namespace Repair\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/common/repair/crawl/MasterCrawler.hpp",
    "content": "//\n// Created by sanhuazhang on 2018/05/31\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"Crawlable.hpp\"\n\nnamespace WCDB {\n\nnamespace Repair {\n\nstruct MasterItem;\nclass MasterCrawler;\n\nclass MasterCrawlerDelegate {\npublic:\n    virtual ~MasterCrawlerDelegate() = 0;\n\nprotected:\n    friend class MasterCrawler;\n\n    virtual void onMasterPageCrawled(const Page &page) = 0;\n    virtual void onMasterCellCrawled(const Cell &cell, const MasterItem &master) = 0;\n    virtual void onMasterCrawlerError() = 0;\n};\n\nclass MasterCrawler final : public Crawlable {\n#pragma mark - Initialize\npublic:\n    MasterCrawler();\n    ~MasterCrawler() override;\n\n#pragma mark - Master\npublic:\n    bool work(MasterCrawlerDelegate *delegate);\n\nprotected:\n    MasterCrawlerDelegate *m_delegate;\n\n#pragma mark - Crawlable\nprotected:\n    void onCellCrawled(const Cell &cell) override final;\n    bool willCrawlPage(const Page &page, int height) override final;\n    void onCrawlerError() override final;\n};\n\n} //namespace Repair\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/common/repair/crawl/SequenceCrawler.cpp",
    "content": "//\n// Created by sanhuazhang on 2018/05/31\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"SequenceCrawler.hpp\"\n#include \"Assertion.hpp\"\n#include \"Cell.hpp\"\n#include \"Page.hpp\"\n#include \"SequenceItem.hpp\"\n#include \"StringView.hpp\"\n\nnamespace WCDB {\n\nnamespace Repair {\n\nSequenceCrawlerDelegate::~SequenceCrawlerDelegate() = default;\n\n#pragma mark - Initialize\nSequenceCrawler::SequenceCrawler() : Crawlable(), m_delegate(nullptr)\n{\n}\n\nSequenceCrawler::~SequenceCrawler() = default;\n\n#pragma mark - Sequence\nbool SequenceCrawler::work(int rootpage, SequenceCrawlerDelegate *delegate)\n{\n    WCTAssert(delegate != nullptr);\n    m_delegate = delegate;\n    bool result = crawl(rootpage);\n    m_delegate = nullptr;\n    return result;\n}\n\n#pragma mark - Crawlable\nvoid SequenceCrawler::onCellCrawled(const Cell &cell)\n{\n    if (cell.getValueType(0) != Cell::Type::Text) {\n        markAsCorrupted(cell.getPage().number,\n                        StringView::formatted(\"Name with type: %d in Sequence is Text.\",\n                                              cell.getValueType(0)));\n        return;\n    }\n    if (cell.getValueType(1) != Cell::Type::Integer) {\n        markAsCorrupted(cell.getPage().number,\n                        StringView::formatted(\"Seq with type: %d in Sequence is Integer.\",\n                                              cell.getValueType(1)));\n        return;\n    }\n    StringView name = cell.stringValue(0);\n    if (name.empty()) {\n        markAsCorrupted(cell.getPage().number, \"Name in Sequence is empty.\");\n        return;\n    }\n\n    SequenceItem sequence;\n    sequence.name = std::move(name);\n    sequence.seq = cell.integerValue(1);\n    m_delegate->onSequenceCellCrawled(cell, sequence);\n}\n\nvoid SequenceCrawler::onCrawlerError()\n{\n    m_delegate->onSequenceCrawlerError();\n    suspend();\n}\n\nbool SequenceCrawler::willCrawlPage(const Page &page, int height)\n{\n    WCDB_UNUSED(height);\n    m_delegate->onSequencePageCrawled(page);\n    return true;\n}\n\n} //namespace Repair\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/common/repair/crawl/SequenceCrawler.hpp",
    "content": "//\n// Created by sanhuazhang on 2018/05/31\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"Crawlable.hpp\"\n\nnamespace WCDB {\n\nnamespace Repair {\n\nstruct SequenceItem;\nclass SequenceCrawler;\n\nclass SequenceCrawlerDelegate {\npublic:\n    virtual ~SequenceCrawlerDelegate() = 0;\n\nprotected:\n    friend class SequenceCrawler;\n\n    virtual void onSequencePageCrawled(const Page &page) = 0;\n    virtual void onSequenceCellCrawled(const Cell &cell, const SequenceItem &sequence) = 0;\n    virtual void onSequenceCrawlerError() = 0;\n};\n\nclass SequenceCrawler final : public Crawlable {\n#pragma mark - Initialize\npublic:\n    SequenceCrawler();\n    ~SequenceCrawler() override;\n\n#pragma mark - Sequence\npublic:\n    bool work(int rootpage, SequenceCrawlerDelegate *delegate);\n\nprotected:\n    SequenceCrawlerDelegate *m_delegate;\n\n#pragma mark - Crawlable\nprotected:\n    void onCellCrawled(const Cell &cell) override final;\n    void onCrawlerError() override final;\n    bool willCrawlPage(const Page &page, int height) override final;\n};\n\n} //namespace Repair\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/common/repair/factory/Factory.cpp",
    "content": "//\n// Created by sanhuazhang on 2018/05/31\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"Factory.hpp\"\n#include \"Assemble.hpp\"\n#include \"Assertion.hpp\"\n#include \"FileManager.hpp\"\n#include \"Material.hpp\"\n#include \"Path.hpp\"\n#include \"StringView.hpp\"\n#include \"Time.hpp\"\n\nnamespace WCDB {\n\nnamespace Repair {\n\n#pragma mark - Factory\nFactory::Factory(const UnsafeStringView &database_)\n: database(database_), directory(factoryPathForDatabase(database_))\n{\n}\n\nOptional<std::list<StringView>> Factory::getWorkshopDirectories() const\n{\n    Optional<std::list<StringView>> result;\n    std::list<StringView> workshopDirectories;\n    if (FileManager::enumerateDirectory(\n        directory,\n        [&workshopDirectories](\n        const UnsafeStringView &root, const UnsafeStringView &subpath, bool isDirectory) -> bool {\n            if (isDirectory && isWorkshopDirectory(subpath)) {\n                workshopDirectories.push_back(Path::addComponent(root, subpath));\n            }\n            return true;\n        })) {\n        result = std::move(workshopDirectories);\n    }\n    return result;\n}\n\nOptional<StringView> Factory::getUniqueWorkshopDiectory() const\n{\n    StringView path;\n    do {\n        Time time = Time::now();\n        auto fileName = time.stringify();\n        if (!fileName.succeed()) {\n            return NullOpt;\n        }\n        path = Path::addComponent(directory, fileName.value());\n\n        auto exists = FileManager::directoryExists(path);\n        if (!exists.succeed()) {\n            return NullOpt;\n        }\n        if (!exists.value()) {\n            break;\n        }\n    } while (true); //try repeatly\n    return path;\n}\n\nbool Factory::containsDeposited() const\n{\n    bool contains = false;\n    StringView databaseName = getDatabaseName();\n    FileManager::enumerateDirectory(\n    directory,\n    [&contains, &databaseName](\n    const UnsafeStringView &root, const UnsafeStringView &subpath, bool isDirectory) -> bool {\n        if (isDirectory && isWorkshopDirectory(subpath)) {\n            StringView databasePath\n            = Path::addComponent(Path::addComponent(root, subpath), databaseName);\n            auto exist = FileManager::fileExists(databasePath);\n            if (exist.succeed() && exist.value()) {\n                contains = true;\n                return false;\n            }\n        }\n        return true;\n    });\n    return contains;\n}\n\nbool Factory::isWorkshopDirectory(const UnsafeStringView &dir)\n{\n    return dir != restoreDirectoryName && dir != renewDirectoryName && dir != vacuumDirectoryName;\n}\n\n#pragma mark - Factory Related\nvoid Factory::filter(const Filter &tableShouldBeBackedUp)\n{\n    m_filter = tableShouldBeBackedUp;\n}\n\nFactory::Filter Factory::getFilter() const\n{\n    return m_filter;\n}\n\nFactoryDepositor Factory::depositor() const\n{\n    return FactoryDepositor(*this);\n}\n\nFactoryRetriever Factory::retriever() const\n{\n    return FactoryRetriever(*this);\n}\n\nFactoryVacuum Factory::vacuumer() const\n{\n    return FactoryVacuum(*this);\n}\n\nFactoryBackup Factory::backup() const\n{\n    return FactoryBackup(*this);\n}\n\nFactoryRenewer Factory::renewer() const\n{\n    return FactoryRenewer(*this);\n}\n\n#pragma mark - Helper\nbool Factory::removeDeposited() const\n{\n    std::list<StringView> depositedPath;\n    if (!FileManager::enumerateDirectory(\n        directory,\n        [&depositedPath](\n        const UnsafeStringView &root, const UnsafeStringView &subpath, bool isDirectory) -> bool {\n            if (isDirectory && isWorkshopDirectory(subpath)) {\n                depositedPath.push_back(Path::addComponent(root, subpath));\n            }\n            return true;\n        })) {\n        return false;\n    }\n    if (FileManager::removeItems(depositedPath)) {\n        removeDirectoryIfEmpty();\n        return true;\n    }\n    return false;\n}\n\nbool Factory::removeDirectoryIfEmpty() const\n{\n    bool canRemove = true;\n    bool succeed = FileManager::enumerateDirectory(\n    directory,\n    [&canRemove](const UnsafeStringView &root, const UnsafeStringView &subpath, bool isDirectory) -> bool {\n        WCDB_UNUSED(root);\n        if (subpath == restoreDirectoryName || !isDirectory) {\n            return true;\n        }\n        canRemove = false;\n        return false;\n    });\n    if (!succeed) {\n        return false;\n    }\n    if (canRemove) {\n        return FileManager::removeItem(directory);\n    }\n    return true;\n}\n\nStringView Factory::incrementalMaterialPathForDatabase(const UnsafeStringView &database)\n{\n    return Path::addExtention(database, \"-incremental.material\");\n}\n\nStringView Factory::firstMaterialPathForDatabase(const UnsafeStringView &database)\n{\n    return Path::addExtention(database, \"-first.material\");\n}\n\nStringView Factory::lastMaterialPathForDatabase(const UnsafeStringView &database)\n{\n    return Path::addExtention(database, \"-last.material\");\n}\n\nStringView Factory::factoryPathForDatabase(const UnsafeStringView &database)\n{\n    return Path::addExtention(database, \".factory\");\n}\n\nStringView Factory::getRestoreDirectory() const\n{\n    return Path::addComponent(directory, restoreDirectoryName);\n}\n\nStringView Factory::getRenewDirectory() const\n{\n    return Path::addComponent(directory, renewDirectoryName);\n}\n\nStringView Factory::getVacuumDirectory() const\n{\n    return Path::addComponent(directory, vacuumDirectoryName);\n}\n\nStringView Factory::getDatabaseName() const\n{\n    return Path::getFileName(database);\n}\n\nstd::list<StringView> Factory::associatedPathsForDatabase(const UnsafeStringView &database)\n{\n    return {\n        StringView(database),\n        Path::addExtention(database, \"-journal\"),\n        Path::addExtention(database, \"-wal\"),\n        Path::addExtention(database, \"-shm\"),\n        incrementalMaterialPathForDatabase(database),\n        firstMaterialPathForDatabase(database),\n        lastMaterialPathForDatabase(database),\n    };\n}\n\nstd::list<StringView> Factory::databasePathsForDatabase(const UnsafeStringView &database)\n{\n    return {\n        StringView(database),\n        Path::addExtention(database, \"-journal\"),\n        Path::addExtention(database, \"-wal\"),\n        Path::addExtention(database, \"-shm\"),\n    };\n}\n\nOptional<StringView>\nFactory::materialForSerializingForDatabase(const UnsafeStringView &database)\n{\n    //If all materials exist, return the old one.\n    //Otherwise, return the one that does not exist.\n    Time now = Time::now();\n\n    StringView firstMaterialPath = Factory::firstMaterialPathForDatabase(database);\n    auto optionalFirstMaterialModifiedTime\n    = getModifiedTimeOr0IfNotExists(firstMaterialPath);\n    if (!optionalFirstMaterialModifiedTime.succeed()) {\n        return NullOpt;\n    }\n    auto &firstMaterialModifiedTime = optionalFirstMaterialModifiedTime.value();\n    if (firstMaterialModifiedTime.empty()\n        || firstMaterialModifiedTime.seconds() > now.seconds()) {\n        return firstMaterialPath;\n    }\n\n    StringView lastMaterialPath = Factory::lastMaterialPathForDatabase(database);\n    auto optionalLastMaterialModifiedTime = getModifiedTimeOr0IfNotExists(lastMaterialPath);\n    if (!optionalLastMaterialModifiedTime.succeed()) {\n        return NullOpt;\n    }\n    auto &lastMaterialModifiedTime = optionalLastMaterialModifiedTime.value();\n    if (lastMaterialModifiedTime.empty()\n        || lastMaterialModifiedTime.seconds() > now.seconds()) {\n        return lastMaterialPath;\n    }\n\n    return firstMaterialModifiedTime > lastMaterialModifiedTime ? lastMaterialPath : firstMaterialPath;\n}\n\nOptional<StringView> Factory::latestMaterialForDatabase(const UnsafeStringView &database)\n{\n    Time now = Time::now();\n\n    StringView firstMaterialPath = Factory::firstMaterialPathForDatabase(database);\n    auto optionalFirstMaterialModifiedTime\n    = getModifiedTimeOr0IfNotExists(firstMaterialPath);\n    if (!optionalFirstMaterialModifiedTime.succeed()) {\n        return NullOpt;\n    }\n    auto &firstMaterialModifiedTime = optionalFirstMaterialModifiedTime.value();\n    StringView lastMaterialPath = Factory::lastMaterialPathForDatabase(database);\n    auto optionalLastMaterialModifiedTime = getModifiedTimeOr0IfNotExists(lastMaterialPath);\n    if (!optionalLastMaterialModifiedTime.succeed()) {\n        return NullOpt;\n    }\n    auto &lastMaterialModifiedTime = optionalLastMaterialModifiedTime.value();\n    if (lastMaterialModifiedTime.empty() && firstMaterialModifiedTime.empty()) {\n        return \"\";\n    }\n    if (firstMaterialModifiedTime.empty()\n        || firstMaterialModifiedTime.seconds() > now.seconds()) {\n        return lastMaterialPath;\n    }\n    if (lastMaterialModifiedTime.empty()\n        || lastMaterialModifiedTime.seconds() > now.seconds()) {\n        return firstMaterialPath;\n    }\n    return firstMaterialModifiedTime < lastMaterialModifiedTime ? lastMaterialPath : firstMaterialPath;\n}\n\nOptional<std::list<StringView>>\nFactory::materialsForDeserializingForDatabase(const UnsafeStringView &database)\n{\n    //If all materials exist, return the new one.\n    //If all materials do not exist, return empty.\n    //Otherwise, return the existing one.\n    std::list<StringView> materialPaths;\n\n    StringView firstMaterialPath = Factory::firstMaterialPathForDatabase(database);\n    auto optionalFirstMaterialModifiedTime\n    = getModifiedTimeOr0IfNotExists(firstMaterialPath);\n    if (!optionalFirstMaterialModifiedTime.succeed()) {\n        return NullOpt;\n    }\n    Time &firstMaterialModifiedTime = optionalFirstMaterialModifiedTime.value();\n    if (!firstMaterialModifiedTime.empty()) {\n        materialPaths.push_back(firstMaterialPath);\n    }\n\n    StringView lastMaterialPath = Factory::lastMaterialPathForDatabase(database);\n    auto optionalLastMaterialModifiedTime = getModifiedTimeOr0IfNotExists(lastMaterialPath);\n    if (!optionalLastMaterialModifiedTime.succeed()) {\n        return NullOpt;\n    }\n    Time &lastMaterialModifiedTime = optionalLastMaterialModifiedTime.value();\n    if (!lastMaterialModifiedTime.empty()) {\n        materialPaths.push_back(lastMaterialPath);\n    }\n\n    if (firstMaterialModifiedTime < lastMaterialModifiedTime) {\n        materialPaths.reverse();\n    }\n    return materialPaths;\n}\n\nOptional<Time> Factory::getModifiedTimeOr0IfNotExists(const UnsafeStringView &path)\n{\n    Optional<Time> modifiedTime;\n    auto exists = FileManager::fileExistsAndNotEmpty(path);\n    if (exists.succeed()) {\n        if (exists.value()) {\n            modifiedTime = FileManager::getFileModifiedTime(path);\n        } else {\n            modifiedTime = Time();\n        }\n    }\n    return modifiedTime;\n}\n\n} //namespace Repair\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/common/repair/factory/Factory.hpp",
    "content": "//\n// Created by sanhuazhang on 2018/05/31\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"FactoryBackup.hpp\"\n#include \"FactoryDepositor.hpp\"\n#include \"FactoryRenewer.hpp\"\n#include \"FactoryRetriever.hpp\"\n#include \"FactoryVacuum.hpp\"\n#include \"StringView.hpp\"\n#include \"Time.hpp\"\n#include \"WCDBOptional.hpp\"\n#include <future>\n#include <list>\n\nnamespace WCDB {\n\nnamespace Repair {\n\nclass AssembleDelegate;\n\nclass Factory final {\n#pragma mark - Factory\npublic:\n    Factory(const UnsafeStringView &database);\n\n    const StringView database;\n    const StringView directory;\n\n    static constexpr const char *restoreDirectoryName = \"restore\";\n    static constexpr const char *renewDirectoryName = \"renew\";\n    static constexpr const char *vacuumDirectoryName = \"vacuum\";\n    StringView getRestoreDirectory() const;\n    StringView getRenewDirectory() const;\n    StringView getVacuumDirectory() const;\n    StringView getDatabaseName() const;\n    bool removeDirectoryIfEmpty() const;\n    bool removeDeposited() const;\n    Optional<std::list<StringView>> getWorkshopDirectories() const;\n    Optional<StringView> getUniqueWorkshopDiectory() const;\n    bool containsDeposited() const;\n    static bool isWorkshopDirectory(const UnsafeStringView &dir);\n\n#pragma mark - Factory Related\npublic:\n    friend class FactoryRelated;\n    FactoryDepositor depositor() const;\n    FactoryRetriever retriever() const;\n    FactoryVacuum vacuumer() const;\n    FactoryBackup backup() const;\n    FactoryRenewer renewer() const;\n\n    typedef Backup::Filter Filter;\n    void filter(const Filter &tableShouldBeBackedUp);\n    Filter getFilter() const;\n\nprotected:\n    Filter m_filter;\n\n#pragma mark - Helper\npublic:\n    static std::list<StringView>\n    associatedPathsForDatabase(const UnsafeStringView &database);\n    static std::list<StringView> databasePathsForDatabase(const UnsafeStringView &database);\n\n    static StringView incrementalMaterialPathForDatabase(const UnsafeStringView &database);\n    static StringView firstMaterialPathForDatabase(const UnsafeStringView &database);\n    static StringView lastMaterialPathForDatabase(const UnsafeStringView &database);\n    static StringView factoryPathForDatabase(const UnsafeStringView &database);\n\n    static Optional<StringView>\n    materialForSerializingForDatabase(const UnsafeStringView &database);\n    static Optional<StringView> latestMaterialForDatabase(const UnsafeStringView &database);\n    static Optional<std::list<StringView>>\n    materialsForDeserializingForDatabase(const UnsafeStringView &database);\n\nprotected:\n    static Optional<Time> getModifiedTimeOr0IfNotExists(const UnsafeStringView &path);\n};\n\n} //namespace Repair\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/common/repair/factory/FactoryBackup.cpp",
    "content": "//\n// Created by sanhuazhang on 2018/06/05\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"FactoryBackup.hpp\"\n#include \"CommonCore.hpp\"\n#include \"CoreConst.h\"\n#include \"Data.hpp\"\n#include \"Factory.hpp\"\n#include \"FileManager.hpp\"\n#include \"Notifier.hpp\"\n\nnamespace WCDB {\n\nnamespace Repair {\n\nFactoryBackup::~FactoryBackup() = default;\n\nbool FactoryBackup::work(const UnsafeStringView& database, bool interruptible)\n{\n    m_sharedDelegate->setBackupPath(database);\n    m_exclusiveDelegate->setBackupPath(database);\n\n    //acquire checkpoint lock to avoid checkpoint during whole iteration of backup\n    if (!m_sharedDelegate->acquireBackupSharedLock()) {\n        return false;\n    }\n\n    bool succeed = doBackUp(database, interruptible);\n\n    if (!m_sharedDelegate->releaseBackupSharedLock() && succeed) {\n        setError(m_sharedDelegate->getBackupError());\n        return false;\n    }\n\n    return succeed;\n}\n\nbool FactoryBackup::doBackUp(const UnsafeStringView& database, bool interruptible)\n{\n    Optional<size_t> incrementalMaterialSize = 0;\n    SharedIncrementalMaterial incrementalMaterial;\n    incrementalMaterial = CommonCore::shared().tryGetIncrementalMaterial(database);\n    if (interruptible && incrementalMaterial != nullptr) {\n        incrementalMaterialSize = saveIncrementalMaterial(database, incrementalMaterial);\n        if (!incrementalMaterialSize.hasValue()) {\n            return false;\n        }\n        if (Time::now().seconds() - incrementalMaterial->info.lastBackupTime < OperationQueueTimeIntervalForBackup\n            && incrementalMaterial->pages.size() < BackupMaxIncrementalPageCount) {\n            return true;\n        }\n    }\n\n    if (interruptible) {\n        notifiyBackupBegin(database);\n    }\n\n    Backup backup(database);\n    backup.setCipherDelegate(m_cipherDelegate);\n    backup.setBackupSharedDelegate(m_sharedDelegate);\n    backup.setBackupExclusiveDelegate(m_exclusiveDelegate);\n    backup.filter(factory.getFilter());\n    if (!backup.work(incrementalMaterial)) {\n        // Treat database empty error as succeed\n        if (backup.getError().code() == Error::Code::Empty) {\n            notifiyBackupEnd(database, 0, 0, backup.getMaterial(), incrementalMaterial);\n            return true;\n        }\n        setError(backup.getError());\n        return false;\n    }\n\n    const Material& material = backup.getMaterial();\n    auto materialSize = saveMaterial(database, material);\n    if (!materialSize.hasValue()) {\n        return false;\n    }\n\n    SharedIncrementalMaterial newIncrementalMaterial = backup.getIncrementalMaterial();\n    if (!saveIncrementalMaterial(database, newIncrementalMaterial).hasValue()) {\n        return false;\n    }\n    CommonCore::shared().tryRegisterIncrementalMaterial(database, newIncrementalMaterial);\n\n    if (interruptible) {\n        notifiyBackupEnd(\n        database, materialSize.value(), incrementalMaterialSize.value(), material, newIncrementalMaterial);\n    }\n    return true;\n}\n\nOptional<size_t>\nFactoryBackup::saveIncrementalMaterial(const UnsafeStringView& database,\n                                       SharedIncrementalMaterial material)\n{\n    WCTAssert(material != nullptr);\n    if (material == nullptr) {\n        return 0;\n    }\n    StringView materialPath = Repair::Factory::incrementalMaterialPathForDatabase(database);\n    bool succeed = false;\n    if (m_cipherDelegate->isCipherDB()) {\n        material->setCipherDelegate(m_cipherDelegate);\n        StringView salt = m_cipherDelegate->tryGetSaltFromDatabase(database).value();\n        succeed = material->encryptedSerialize(materialPath);\n        material->setCipherDelegate(nullptr);\n    } else {\n        succeed = material->serialize(materialPath);\n    }\n    if (!succeed) {\n        return NullOpt;\n    }\n    return FileManager::getFileSize(materialPath);\n}\n\nOptional<size_t>\nFactoryBackup::saveMaterial(const UnsafeStringView& database, const Material& material)\n{\n    auto materialPath = Factory::materialForSerializingForDatabase(database);\n    if (!materialPath.succeed()) {\n        assignWithSharedThreadedError();\n        return NullOpt;\n    }\n    if (!m_cipherDelegate->isCipherDB()) {\n        if (!material.serialize(materialPath.value())) {\n            assignWithSharedThreadedError();\n            return NullOpt;\n        }\n    } else {\n        if (!material.encryptedSerialize(materialPath.value())) {\n            assignWithSharedThreadedError();\n            return NullOpt;\n        }\n    }\n    return FileManager::getFileSize(materialPath.value());\n}\n\nvoid FactoryBackup::notifiyBackupBegin(const UnsafeStringView& database)\n{\n    Error error(Error::Code::Notice, Error::Level::Notice, \"Backup Begin.\");\n    error.infos.insert_or_assign(ErrorStringKeyPath, database);\n    Notifier::shared().notify(error);\n}\n\nvoid FactoryBackup::notifiyBackupEnd(const UnsafeStringView& database,\n                                     size_t materialSize,\n                                     size_t incrementalMaterialSize,\n                                     const Material& material,\n                                     SharedIncrementalMaterial incrementalMaterial)\n{\n    uint32_t associatedTableCount = 0;\n    uint32_t leafPageCount = 0;\n    for (auto& content : material.contentsMap) {\n        associatedTableCount += content.second->associatedSQLs.size();\n        leafPageCount += content.second->verifiedPagenos.size();\n    }\n    Error error(Error::Code::Notice, Error::Level::Notice, \"Backup End.\");\n    error.infos.insert_or_assign(\"Incremental\",\n                                 incrementalMaterial != nullptr\n                                 && incrementalMaterial->info.incrementalBackupTimes > 0);\n    error.infos.insert_or_assign(\"MaterialSize\", materialSize);\n    error.infos.insert_or_assign(\"LastIncrementalMaterialSize\", incrementalMaterialSize);\n    error.infos.insert_or_assign(\"TableCount\", material.contentsMap.size());\n    error.infos.insert_or_assign(\"AssociatedTableCount\", associatedTableCount);\n    error.infos.insert_or_assign(\"LeafPageCount\", leafPageCount);\n    error.infos.insert_or_assign(ErrorStringKeyPath, database);\n    Notifier::shared().notify(error);\n}\n\n} //namespace Repair\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/common/repair/factory/FactoryBackup.hpp",
    "content": "//\n// Created by sanhuazhang on 2018/06/05\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"Backup.hpp\"\n#include \"FactoryRelated.hpp\"\n#include \"IncrementalMaterial.hpp\"\n\nnamespace WCDB {\n\nnamespace Repair {\n\nclass FactoryBackup final : public FactoryRelated,\n                            public ErrorProne,\n                            public CipherDelegateHolder,\n                            public BackupDelegateHolder {\npublic:\n    using FactoryRelated::FactoryRelated;\n    ~FactoryBackup() override;\n    bool work(const UnsafeStringView& database, bool interruptible = false);\n\nprotected:\n    bool doBackUp(const UnsafeStringView& database, bool interruptible);\n    Optional<size_t> saveIncrementalMaterial(const UnsafeStringView& database,\n                                             SharedIncrementalMaterial material);\n    Optional<size_t>\n    saveMaterial(const UnsafeStringView& database, const Material& material);\n    void notifiyBackupBegin(const UnsafeStringView& database);\n    void notifiyBackupEnd(const UnsafeStringView& database,\n                          size_t materialSize,\n                          size_t incrementalMaterialSize,\n                          const Material& material,\n                          SharedIncrementalMaterial incrementalMaterial);\n};\n\n} //namespace Repair\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/common/repair/factory/FactoryDepositor.cpp",
    "content": "//\n// Created by sanhuazhang on 2018/06/05\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"FactoryDepositor.hpp\"\n#include \"Factory.hpp\"\n#include \"FileManager.hpp\"\n#include \"Path.hpp\"\n\nnamespace WCDB {\n\nnamespace Repair {\n\nFactoryDepositor::~FactoryDepositor() = default;\n\nbool FactoryDepositor::work()\n{\n    auto optionalWorkshopDirectory = factory.getUniqueWorkshopDiectory();\n    if (!optionalWorkshopDirectory.succeed()) {\n        assignWithSharedThreadedError();\n        return false;\n    }\n\n    StringView& workshopDirectory = optionalWorkshopDirectory.value();\n    if (!FileManager::createDirectoryWithIntermediateDirectories(workshopDirectory)\n        || !FileManager::moveItems(\n        Factory::associatedPathsForDatabase(factory.database), workshopDirectory)) {\n        assignWithSharedThreadedError();\n        return false;\n    }\n    return true;\n}\n\n} //namespace Repair\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/common/repair/factory/FactoryDepositor.hpp",
    "content": "//\n// Created by sanhuazhang on 2018/06/05\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"ErrorProne.hpp\"\n#include \"FactoryRelated.hpp\"\n\nnamespace WCDB {\n\nnamespace Repair {\n\nclass FactoryDepositor final : public FactoryRelated, public ErrorProne {\npublic:\n    using FactoryRelated::FactoryRelated;\n    ~FactoryDepositor() override;\n    bool work();\n};\n\n} //namespace Repair\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/common/repair/factory/FactoryRelated.cpp",
    "content": "//\n// Created by sanhuazhang on 2018/06/05\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"FactoryRelated.hpp\"\n#include \"Factory.hpp\"\n\nnamespace WCDB {\n\nnamespace Repair {\n\nFactoryRelated::FactoryRelated(const Factory &factory_) : factory(factory_)\n{\n}\n\nFactoryRelated::~FactoryRelated() = default;\n\n} //namespace Repair\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/common/repair/factory/FactoryRelated.hpp",
    "content": "//\n// Created by sanhuazhang on 2018/06/05\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\nnamespace WCDB {\n\nnamespace Repair {\n\nclass Factory;\n\nclass FactoryRelated {\npublic:\n    FactoryRelated(const Factory &factory);\n    virtual ~FactoryRelated() = 0;\n\nprotected:\n    const Factory &factory;\n};\n\n} //namespace Repair\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/common/repair/factory/FactoryRenewer.cpp",
    "content": "//\n// Created by sanhuazhang on 2018/06/12\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"FactoryRenewer.hpp\"\n#include \"Assertion.hpp\"\n#include \"CoreConst.h\"\n#include \"Factory.hpp\"\n#include \"FactoryBackup.hpp\"\n#include \"FileManager.hpp\"\n#include \"Notifier.hpp\"\n#include \"Path.hpp\"\n\nnamespace WCDB {\n\nnamespace Repair {\n\nFactoryRenewer::FactoryRenewer(const Factory &factory_)\n: FactoryRelated(factory_)\n, directory(factory.getRenewDirectory())\n, database(Path::addComponent(directory, factory.getDatabaseName()))\n{\n}\n\nFactoryRenewer::~FactoryRenewer() = default;\n\nbool FactoryRenewer::work()\n{\n    auto exists = FileManager::fileExists(database);\n    if (!exists.succeed()) {\n        assignWithSharedThreadedError();\n        return false;\n    }\n    if (!exists.value()) {\n        factory.removeDirectoryIfEmpty();\n        return true;\n    }\n\n    exists = FileManager::fileExists(factory.database);\n    if (!exists.succeed()) {\n        assignWithSharedThreadedError();\n        return false;\n    }\n    if (exists.value()) {\n        Error error(Error::Code::Misuse, Error::Level::Warning, \"Database already exists when renewing.\");\n        error.infos.insert_or_assign(ErrorStringKeySource, ErrorSourceRepair);\n        error.infos.insert_or_assign(ErrorStringKeyPath, factory.database);\n        Notifier::shared().notify(error);\n        FileManager::removeItem(directory);\n        factory.removeDirectoryIfEmpty();\n        return true;\n    }\n    if (!FileManager::removeItems(Factory::associatedPathsForDatabase(factory.database))) {\n        assignWithSharedThreadedError();\n        return false;\n    }\n\n    std::list<StringView> toMove = Factory::associatedPathsForDatabase(database);\n    toMove.reverse();\n    if (!FileManager::moveItems(toMove, Path::getDirectory(factory.database))) {\n        assignWithSharedThreadedError();\n        return false;\n    }\n    FileManager::removeItem(directory);\n    factory.removeDirectoryIfEmpty();\n\n    return true;\n}\n\nbool FactoryRenewer::prepare()\n{\n    WCTRemedialAssert(\n    m_assembleDelegate != nullptr, \"Assemble is not available.\", return false;);\n\n    // 1. create temp directory for acquisition\n    StringView tempDirectory = Path::addComponent(directory, \"temp\");\n    StringView tempDatabase\n    = Path::addComponent(tempDirectory, factory.getDatabaseName());\n    m_assembleDelegate->setAssemblePath(tempDatabase);\n\n    if (!FileManager::removeItem(tempDirectory)\n        || !FileManager::createDirectoryWithIntermediateDirectories(tempDirectory)) {\n        assignWithSharedThreadedError();\n        return false;\n    }\n\n    // 2. get deposited directories for acquisition\n    auto optionalWorkshopDirectories = factory.getWorkshopDirectories();\n    if (!optionalWorkshopDirectories.succeed()) {\n        assignWithSharedThreadedError();\n        return false;\n    }\n    std::list<StringView> &workshopDirectories = optionalWorkshopDirectories.value();\n\n    // 3. resolve infos\n    StringViewMap<Info> infos;\n    if (!resolveInfosForDatabase(infos, factory.database)) {\n        return false;\n    }\n    const StringView databaseName = Path::getFileName(factory.database);\n    for (const auto &workshopDirectory : workshopDirectories) {\n        StringView databaseForAcquisition\n        = Path::addComponent(workshopDirectory, databaseName);\n        if (!resolveInfosForDatabase(infos, databaseForAcquisition)) {\n            return false;\n        }\n    }\n\n    // 4. assemble infos\n    if (!m_assembleDelegate->markAsAssembling()) {\n        setError(m_assembleDelegate->getAssembleError());\n        return false;\n    }\n    bool succeed = true;\n    for (const auto &element : infos) {\n        if (!m_assembleDelegate->assembleTable(element.first, element.second.sql)\n            || !m_assembleDelegate->assembleSequence(element.first,\n                                                     element.second.sequence)) {\n            succeed = false;\n            setError(m_assembleDelegate->getAssembleError());\n            break;\n        }\n        for (const auto &iter : element.second.associatedSQLs) {\n            m_assembleDelegate->assembleSQL(iter);\n        }\n    }\n    if (!m_assembleDelegate->markAsAssembled()) {\n        if (!succeed) {\n            setError(m_assembleDelegate->getAssembleError());\n        }\n        return false;\n    }\n\n    m_assembleDelegate->finishAssemble();\n\n    // 5. force backup assembled database if exists\n    auto fileSize = FileManager::getFileSize(tempDatabase);\n    if (!fileSize.succeed()) {\n        assignWithSharedThreadedError();\n        return false;\n    }\n    if (fileSize.value() > 0) {\n        FactoryBackup backup(factory);\n        backup.setBackupExclusiveDelegate(m_exclusiveDelegate);\n        backup.setBackupSharedDelegate(m_sharedDelegate);\n        backup.setCipherDelegate(m_cipherDelegate);\n        if (m_cipherDelegate->isCipherDB()) {\n            auto salt = m_cipherDelegate->tryGetSaltFromDatabase(tempDatabase);\n            if (!salt.succeed()) {\n                assignWithSharedThreadedError();\n                return false;\n            }\n            if (!m_cipherDelegate->switchCipherSalt(salt.value())) {\n                setError(m_cipherDelegate->getCipherError());\n                return false;\n            }\n        }\n        if (!backup.work(tempDatabase)) {\n            setError(backup.getError());\n            return false;\n        }\n    }\n\n    m_exclusiveDelegate->finishBackup();\n    m_sharedDelegate->finishBackup();\n\n    // 6. move the assembled database to renew directory and wait for renew.\n    std::list<StringView> toRemove = Factory::associatedPathsForDatabase(database);\n    toRemove.reverse(); // move from end to start, which can avoid issues that unexpected crash happens before all files moved.\n    if (!FileManager::removeItems(toRemove)) {\n        assignWithSharedThreadedError();\n        return false;\n    }\n    std::list<StringView> toMove = Factory::associatedPathsForDatabase(tempDatabase);\n    toMove.reverse();\n    if (!FileManager::moveItems(toMove, directory)) {\n        assignWithSharedThreadedError();\n        return false;\n    }\n    FileManager::removeItem(tempDirectory);\n    return true;\n}\n\nbool FactoryRenewer::resolveInfosForDatabase(StringViewMap<Info> &infos,\n                                             const UnsafeStringView &databaseForAcquisition)\n{\n    auto optionalMaterialPaths\n    = Factory::materialsForDeserializingForDatabase(databaseForAcquisition);\n    if (!optionalMaterialPaths.succeed()) {\n        assignWithSharedThreadedError();\n        return false;\n    }\n    std::list<StringView> &materialPaths = optionalMaterialPaths.value();\n\n    if (materialPaths.empty()) {\n        Error error(Error::Code::NotFound, Error::Level::Warning, \"Material is not found when renewing.\");\n        error.infos.insert_or_assign(ErrorStringKeySource, ErrorSourceRepair);\n        error.infos.insert_or_assign(ErrorStringKeyAssociatePath, databaseForAcquisition);\n        Notifier::shared().notify(error);\n        return true;\n    }\n    for (const auto &materialPath : materialPaths) {\n        Material material;\n        bool succeed = false;\n        if (!m_cipherDelegate->isCipherDB()) {\n            succeed = material.deserialize(materialPath);\n        } else {\n            material.setCipherDelegate(m_cipherDelegate);\n            succeed = material.decryptedDeserialize(materialPath, true);\n        }\n        if (!succeed) {\n            if (ThreadedErrors::shared().getThreadedError().isCorruption()) {\n                continue;\n            } else {\n                break;\n            }\n        }\n\n        for (auto &element : material.contentsMap) {\n            auto iter = infos.find(element.first);\n            if (iter == infos.end()) {\n                iter = infos.emplace(std::move(element.first), Info()).first;\n                iter->second.sql = std::move(element.second->sql);\n                iter->second.associatedSQLs = std::move(element.second->associatedSQLs);\n            } else {\n                if (iter->second.sql != element.second->sql) {\n                    Error error(Error::Code::Mismatch,\n                                Error::Level::Notice,\n                                \"Different sqls is found in materials.\");\n                    error.infos.insert_or_assign(ErrorStringKeySource, ErrorSourceRepair);\n                    error.infos.insert_or_assign(\"MaterialPaths\", materialPath);\n                    error.infos.insert_or_assign(\"SQL1\", element.second->sql);\n                    error.infos.insert_or_assign(\"SQL2\", iter->second.sql);\n                    Notifier::shared().notify(error);\n                }\n            }\n            if (element.second->sequence > iter->second.sequence) {\n                iter->second.sequence = element.second->sequence;\n            }\n        }\n        return true;\n    }\n    // Regard it as no error\n    Error error(Error::Code::Notice, Error::Level::Notice, \"All materials are corrupted when renewing.\");\n    error.infos.insert_or_assign(ErrorStringKeySource, ErrorSourceRepair);\n    error.infos.insert_or_assign(ErrorStringKeyAssociatePath, databaseForAcquisition);\n    Notifier::shared().notify(error);\n    return true;\n}\n\nFactoryRenewer::Info::Info() : sequence(0)\n{\n}\n\n} //namespace Repair\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/common/repair/factory/FactoryRenewer.hpp",
    "content": "//\n// Created by sanhuazhang on 2018/06/12\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"Assemble.hpp\"\n#include \"Backup.hpp\"\n#include \"ErrorProne.hpp\"\n#include \"FactoryRelated.hpp\"\n\nnamespace WCDB {\n\nnamespace Repair {\n\nclass FactoryRenewer final : public FactoryRelated,\n                             public ErrorProne,\n                             public CipherDelegateHolder,\n                             public AssembleDelegateHolder,\n                             public BackupDelegateHolder {\npublic:\n    FactoryRenewer(const Factory &factory);\n    ~FactoryRenewer() override;\n\n    const StringView directory;\n    const StringView database;\n\n    bool prepare();\n    bool work();\n\nprotected:\n    struct Info {\n        Info();\n        StringView sql;\n        int64_t sequence;\n        std::list<StringView> associatedSQLs;\n    };\n    typedef struct Info Info;\n\n    bool resolveInfosForDatabase(StringViewMap<Info> &infos,\n                                 const UnsafeStringView &databaseForAcquisition);\n\nprivate:\n    bool assembleInfos(const StringViewMap<Info> &infos);\n    bool doAssembleInfos(const StringViewMap<Info> &infos);\n};\n\n} //namespace Repair\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/common/repair/factory/FactoryRetriever.cpp",
    "content": "//\n// Created by sanhuazhang on 2018/06/06\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"FactoryRetriever.hpp\"\n#include \"Assertion.hpp\"\n#include \"CoreConst.h\"\n#include \"Data.hpp\"\n#include \"Factory.hpp\"\n#include \"FactoryBackup.hpp\"\n#include \"FileHandle.hpp\"\n#include \"FileManager.hpp\"\n#include \"FullCrawler.hpp\"\n#include \"Mechanic.hpp\"\n#include \"Notifier.hpp\"\n#include \"Path.hpp\"\n#include \"SQLite.h\"\n#include \"ThreadedErrors.hpp\"\n#include <cstring>\n#include <numeric>\n\nnamespace WCDB {\n\nnamespace Repair {\n\nFactoryRetriever::FactoryRetriever(const Factory &factory_)\n: FactoryRelated(factory_)\n, database(Path::addComponent(factory.getRestoreDirectory(), factory.getDatabaseName()))\n, databaseFileName(factory.getDatabaseName())\n, m_totalSize(0)\n{\n}\n\nFactoryRetriever::~FactoryRetriever() = default;\n\n#pragma mark - Retriever\nbool FactoryRetriever::work()\n{\n    WCTRemedialAssert(\n    m_assembleDelegate != nullptr, \"Assemble is not available.\", return false;);\n    m_assembleDelegate->setAssemblePath(database);\n\n    bool succeed;\n    //1. Remove the old restore db\n    StringView restoreDirectory = factory.getRestoreDirectory();\n    if (!FileManager::removeItem(restoreDirectory)) {\n        setCriticalErrorWithSharedThreadedError();\n        return exit(false);\n    }\n    if (!FileManager::createDirectoryWithIntermediateDirectories(factory.getRestoreDirectory())) {\n        setCriticalErrorWithSharedThreadedError();\n        return exit(false);\n    }\n\n    //1.5 calculate weights to deal with the progress and score\n    auto optionalWorkshopDirectories = factory.getWorkshopDirectories();\n    if (!optionalWorkshopDirectories.succeed()) {\n        setCriticalErrorWithSharedThreadedError();\n        return exit(false);\n    }\n    std::list<StringView> &workshopDirectories = optionalWorkshopDirectories.value();\n\n    if (!calculateSizes(workshopDirectories)) {\n        return exit(false);\n    }\n\n    SteadyClock before = SteadyClock::now();\n    //2. Restore from current db. It must be succeed without even non-critical errors.\n    if (!restore(factory.database) || getErrorSeverity() >= Severity::Normal) {\n        return exit(false);\n    }\n\n    //3. Restore from all depositor db. It should be succeed without critical errors.\n    for (const auto &workshopDirectory : workshopDirectories) {\n        if (!restore(Path::addComponent(workshopDirectory, databaseFileName))) {\n            return exit(false);\n        }\n    }\n\n    reportSummary(SteadyClock::timeIntervalSinceSteadyClockToNow(before));\n\n    // Did not restore anything, return false\n    if (getScore().value() == 0) {\n        return exit(false);\n    }\n\n    //4. Do a backup on restore db.\n    FactoryBackup backup(factory);\n    backup.setBackupExclusiveDelegate(m_exclusiveDelegate);\n    backup.setBackupSharedDelegate(m_sharedDelegate);\n    backup.setCipherDelegate(m_cipherDelegate);\n    if (m_cipherDelegate->isCipherDB()) {\n        auto salt = m_cipherDelegate->tryGetSaltFromDatabase(database);\n        if (!salt.succeed()) {\n            setCriticalErrorWithSharedThreadedError();\n            return false;\n        }\n        if (!m_cipherDelegate->switchCipherSalt(salt.value())) {\n            setCriticalError(m_cipherDelegate->getCipherError());\n            return false;\n        }\n    }\n    if (!backup.work(database)) {\n        setCriticalError(backup.getError());\n        return exit(false);\n    }\n\n    m_exclusiveDelegate->finishBackup();\n    m_sharedDelegate->finishBackup();\n    m_assembleDelegate->finishAssemble();\n\n    //5. Archive current db and use restore db\n    FactoryDepositor depositor(factory);\n    if (!depositor.work()) {\n        setCriticalError(depositor.getError());\n        return exit(false);\n    }\n    StringView baseDirectory = Path::getDirectory(factory.database);\n    succeed = FileManager::moveItems(\n    Factory::associatedPathsForDatabase(database), baseDirectory);\n    if (!succeed) {\n        setCriticalErrorWithSharedThreadedError();\n        return exit(false);\n    }\n\n    //6. Remove all deposited dbs if error is ignorable.\n    if (getErrorSeverity() <= UpgradeableErrorProne::Severity::Normal) {\n        const StringView tempDir = FileManager::getTemporaryDirectory();\n        if (tempDir.length() > 0) {\n            FileManager::moveItems({ factory.directory }, tempDir);\n        } else {\n            FileManager::removeItem(factory.directory);\n        }\n    }\n\n    return exit(true);\n}\n\nbool FactoryRetriever::exit(bool result)\n{\n    factory.removeDirectoryIfEmpty();\n    if (result) {\n        finishProgress();\n    }\n    return result;\n}\n\nbool FactoryRetriever::restore(const UnsafeStringView &databasePath)\n{\n    // material paths is already ordered by modified time\n    auto optionalMaterialPaths = Factory::materialsForDeserializingForDatabase(databasePath);\n    if (!optionalMaterialPaths.succeed()) {\n        setCriticalErrorWithSharedThreadedError();\n        return false;\n    }\n\n    std::list<StringView> &materialPaths = optionalMaterialPaths.value();\n    bool useMaterial = false;\n    Fraction score;\n    if (!materialPaths.empty()) {\n        Material material;\n        Time materialTime;\n        StringView path;\n        for (const auto &materialPath : materialPaths) {\n            if (!m_cipherDelegate->isCipherDB()) {\n                useMaterial = material.deserialize(materialPath);\n            } else {\n                material.setCipherDelegate(m_cipherDelegate);\n                useMaterial = material.decryptedDeserialize(materialPath, true);\n            }\n\n            if (useMaterial) {\n                auto optionalMaterialTime = FileManager::getFileModifiedTime(materialPath);\n                if (!optionalMaterialTime.succeed()) {\n                    setCriticalErrorWithSharedThreadedError();\n                    return false;\n                }\n                materialTime = std::move(optionalMaterialTime.value());\n                break;\n            } else if (!ThreadedErrors::shared().getThreadedError().isCorruption()) {\n                setCriticalErrorWithSharedThreadedError();\n                return false;\n            }\n        }\n        if (useMaterial) {\n            Mechanic mechanic(databasePath);\n            m_assembleDelegate->markDuplicatedAsIgnorable(false);\n            mechanic.setAssembleDelegate(m_assembleDelegate);\n            mechanic.setMaterial(&material);\n            mechanic.setProgressCallback(std::bind(&FactoryRetriever::increaseProgress,\n                                                   this,\n                                                   databasePath,\n                                                   true,\n                                                   std::placeholders::_1,\n                                                   std::placeholders::_2));\n            mechanic.setCipherDelegate(m_cipherDelegate);\n            SteadyClock before = SteadyClock::now();\n            bool result = mechanic.work();\n            if (!result) {\n                setCriticalError(mechanic.getError());\n                return false;\n            } else {\n                tryUpgradeError(mechanic.getError());\n            }\n            score = mechanic.getScore();\n            reportMechanic(mechanic,\n                           databasePath,\n                           SteadyClock::timeIntervalSinceSteadyClockToNow(before),\n                           materialTime);\n        }\n    } else {\n        Error warning(Error::Code::NotFound, Error::Level::Warning, \"Material is not found\");\n        warning.infos.insert_or_assign(ErrorStringKeySource, ErrorSourceRepair);\n        warning.infos.insert_or_assign(ErrorStringKeyAssociatePath, databasePath);\n        Notifier::shared().notify(warning);\n    }\n\n    FullCrawler fullCrawler(databasePath);\n    m_assembleDelegate->markDuplicatedAsIgnorable(useMaterial);\n    fullCrawler.setAssembleDelegate(m_assembleDelegate);\n    fullCrawler.setProgressCallback(std::bind(&FactoryRetriever::increaseProgress,\n                                              this,\n                                              databasePath,\n                                              useMaterial,\n                                              std::placeholders::_1,\n                                              std::placeholders::_2));\n    fullCrawler.filter(factory.getFilter());\n    fullCrawler.setCipherDelegate(m_cipherDelegate);\n    if (!useMaterial) {\n        auto salt = m_cipherDelegate->tryGetSaltFromDatabase(databasePath);\n        if (!salt.succeed()) {\n            setCriticalErrorWithSharedThreadedError();\n            return false;\n        }\n        if (!m_cipherDelegate->switchCipherSalt(salt.value())) {\n            setCriticalError(m_cipherDelegate->getCipherError());\n            return false;\n        }\n    }\n\n    SteadyClock before = SteadyClock::now();\n    if (fullCrawler.work()) {\n        reportFullCrawler(\n        fullCrawler, databasePath, SteadyClock::timeIntervalSinceSteadyClockToNow(before));\n        score = std::max(score, fullCrawler.getScore());\n    } else if (!useMaterial) {\n        setCriticalError(fullCrawler.getError());\n        return false;\n    }\n    tryUpgradeError(fullCrawler.getError());\n\n    increaseScore(databasePath, score);\n    return true;\n}\n\n#pragma mark - Report\nvoid FactoryRetriever::reportMechanic(const Mechanic &mechanic,\n                                      const UnsafeStringView &path,\n                                      double cost,\n                                      const Time &material)\n{\n    Error error(Error::Code::Notice, Error::Level::Notice, \"Mechanic Retrieve Report.\");\n    error.infos.insert_or_assign(ErrorStringKeySource, ErrorSourceRepair);\n    error.infos.insert_or_assign(ErrorStringKeyAssociatePath, path);\n    error.infos.insert_or_assign(\"Score\", mechanic.getScore().value());\n    error.infos.insert_or_assign(\"TotalPageCount\", mechanic.getTotalPageCount());\n    error.infos.insert_or_assign(\"DepositedWalPageCount\",\n                                 mechanic.getDisposedWalPageCount());\n    auto optionalMaterial = material.stringify();\n    if (optionalMaterial.succeed()) {\n        error.infos.insert_or_assign(\"Material\", optionalMaterial.value());\n    }\n    finishReportOfPerformance(error, path, cost);\n    error.infos.insert_or_assign(\n    \"Weight\", StringView::formatted(\"%f%%\", getWeight(path).value() * 100.0f));\n    Notifier::shared().notify(error);\n}\n\nvoid FactoryRetriever::reportFullCrawler(const FullCrawler &fullCrawler,\n                                         const UnsafeStringView &path,\n                                         double cost)\n{\n    Error error(Error::Code::Notice, Error::Level::Notice, \"Crawler Retrieve Report.\");\n    error.infos.insert_or_assign(ErrorStringKeySource, ErrorSourceRepair);\n    error.infos.insert_or_assign(ErrorStringKeyAssociatePath, path);\n    error.infos.insert_or_assign(ErrorStringKeyPath, path);\n    error.infos.insert_or_assign(\"Score\", fullCrawler.getScore().value());\n    error.infos.insert_or_assign(\"TotalPageCount\", fullCrawler.getTotalPageCount());\n    finishReportOfPerformance(error, path, cost);\n    error.infos.insert_or_assign(\n    \"Weight\", StringView::formatted(\"%f%%\", getWeight(path).value() * 100.0f));\n    Notifier::shared().notify(error);\n}\n\nvoid FactoryRetriever::reportSummary(double cost)\n{\n    Error error(Error::Code::Notice, Error::Level::Notice, \"Summary Retrieve Report.\");\n    error.infos.insert_or_assign(ErrorStringKeySource, ErrorSourceRepair);\n    error.infos.insert_or_assign(ErrorStringKeyPath, factory.database);\n    error.infos.insert_or_assign(\"Cost\", StringView::formatted(\"%f sec\", cost));\n    error.infos.insert_or_assign(\"Score\", getScore().value());\n    Notifier::shared().notify(error);\n}\n\nvoid FactoryRetriever::finishReportOfPerformance(Error &error,\n                                                 const UnsafeStringView &databasePath,\n                                                 double cost)\n{\n    WCTAssert(m_sizes.find(databasePath) != m_sizes.end());\n    size_t size = m_sizes[databasePath];\n    double sizeInMB = (double) size / 1024 / 1024;\n    double speed = cost > 0 ? sizeInMB / cost : 0;\n    error.infos.insert_or_assign(\"Cost\", StringView::formatted(\"%f sec\", cost));\n    error.infos.insert_or_assign(\"Size\", StringView::formatted(\"%f MB\", sizeInMB));\n    error.infos.insert_or_assign(\"Speed\", StringView::formatted(\"%f MB/s\", speed));\n}\n\n#pragma mark - Score and Progress\nbool FactoryRetriever::calculateSizes(const std::list<StringView> &workshopDirectories)\n{\n    //Origin database\n    if (!calculateSize(factory.database)) {\n        return false;\n    }\n\n    //Materials\n    for (const auto &workshopDirectory : workshopDirectories) {\n        StringView databasePath = Path::addComponent(workshopDirectory, databaseFileName);\n        if (!calculateSize(databasePath)) {\n            return false;\n        }\n    }\n\n    m_totalSize = std::accumulate(\n    m_sizes.begin(), m_sizes.end(), m_totalSize, FactoryRetriever::iterateSize);\n    return true;\n}\n\nsize_t FactoryRetriever::iterateSize(const size_t previous,\n                                     const std::pair<StringView, size_t> &element)\n{\n    return previous + element.second;\n}\n\nbool FactoryRetriever::calculateSize(const UnsafeStringView &databasePath)\n{\n    auto fileSize\n    = FileManager::getItemsSize(Factory::databasePathsForDatabase(databasePath));\n    if (!fileSize.succeed()) {\n        setCriticalErrorWithSharedThreadedError();\n        return false;\n    }\n    m_sizes[databasePath] = fileSize.value();\n    return true;\n}\n\nFraction FactoryRetriever::getWeight(const UnsafeStringView &databasePath)\n{\n    WCTAssert(m_sizes.find(databasePath) != m_sizes.end());\n    return Fraction(m_sizes[databasePath], m_totalSize > 0 ? m_totalSize : 1);\n}\n\nbool FactoryRetriever::increaseProgress(const UnsafeStringView &databasePath,\n                                        bool useMaterial,\n                                        double progress,\n                                        double increment)\n{\n    WCDB_UNUSED(progress);\n    if (useMaterial) {\n        increment *= 0.5;\n    }\n    if (!Progress::increaseProgress(getWeight(databasePath).value() * increment)) {\n        m_assembleDelegate->suspendAssemble();\n        return false;\n    }\n    return true;\n}\n\nvoid FactoryRetriever::increaseScore(const UnsafeStringView &databasePath,\n                                     const Fraction &increment)\n{\n    Scoreable::increaseScore(getWeight(databasePath) * increment);\n}\n\n} //namespace Repair\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/common/repair/factory/FactoryRetriever.hpp",
    "content": "//\n// Created by sanhuazhang on 2018/06/06\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"Assemble.hpp\"\n#include \"FactoryBackup.hpp\"\n#include \"FactoryRelated.hpp\"\n#include \"Progress.hpp\"\n#include \"Scoreable.hpp\"\n#include \"Time.hpp\"\n#include \"UpgradeableErrorProne.hpp\"\n#include \"WCDBOptional.hpp\"\n\nnamespace WCDB {\n\nnamespace Repair {\n\nclass Mechanic;\nclass FullCrawler;\n\nclass FactoryRetriever final : public FactoryRelated,\n                               public UpgradeableErrorProne,\n                               public Progress,\n                               public Scoreable,\n                               public CipherDelegateHolder,\n                               public AssembleDelegateHolder,\n                               public BackupDelegateHolder {\n#pragma mark - Retriever\npublic:\n    FactoryRetriever(const Factory &factory);\n    ~FactoryRetriever() override;\n\n    const StringView database;\n\npublic:\n    bool work();\n\nprotected:\n    bool exit(bool result);\n\nprotected:\n    bool restore(const UnsafeStringView &database);\n    const StringView databaseFileName;\n\n#pragma mark - Report\nprotected:\n    void reportMechanic(const Mechanic &mechanic,\n                        const UnsafeStringView &path,\n                        double cost,\n                        const Time &material);\n    void reportFullCrawler(const FullCrawler &fullcrawler, const UnsafeStringView &path, double cost);\n    void reportSummary(double cost);\n\n    void finishReportOfPerformance(Error &error, const UnsafeStringView &database, double cost);\n\n#pragma mark - Evaluation and Progress\nprotected:\n    bool calculateSizes(const std::list<StringView> &workshopDirectories);\n    bool calculateSize(const UnsafeStringView &database);\n    bool increaseProgress(const UnsafeStringView &database,\n                          bool useMaterial,\n                          double progress,\n                          double increment);\n    static size_t\n    iterateSize(const size_t previous, const std::pair<StringView, size_t> &element);\n\n    Fraction getWeight(const UnsafeStringView &database);\n\n    StringViewMap<size_t> m_sizes;\n    size_t m_totalSize;\n    void increaseScore(const UnsafeStringView &database, const Fraction &increment);\n};\n\n} //namespace Repair\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/common/repair/factory/FactoryVacuum.cpp",
    "content": "//\n// Created by qiuwenchen on 2023/12/15.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"FactoryVacuum.hpp\"\n#include \"CoreConst.h\"\n#include \"Factory.hpp\"\n#include \"FileManager.hpp\"\n#include \"FullCrawler.hpp\"\n#include \"Notifier.hpp\"\n#include \"Path.hpp\"\n\nnamespace WCDB {\n\nnamespace Repair {\n\nFactoryVacuum::FactoryVacuum(const Factory &factory_)\n: FactoryRelated(factory_)\n, directory(factory.getVacuumDirectory())\n, database(Path::addComponent(directory, factory.getDatabaseName()))\n{\n}\n\nFactoryVacuum::~FactoryVacuum() = default;\n\nbool FactoryVacuum::work()\n{\n    auto exists = FileManager::fileExists(database);\n    if (!exists.succeed()) {\n        assignWithSharedThreadedError();\n        return exit(false);\n    }\n    if (!exists.value()) {\n        return exit(true);\n    }\n\n    exists = FileManager::fileExists(factory.database);\n    if (!exists.succeed()) {\n        assignWithSharedThreadedError();\n        return exit(false);\n    }\n    if (exists.value()) {\n        Error error(Error::Code::Misuse, Error::Level::Warning, \"Database already exists when vacuum.\");\n        error.infos.insert_or_assign(ErrorStringKeySource, ErrorSourceRepair);\n        error.infos.insert_or_assign(ErrorStringKeyPath, factory.database);\n        Notifier::shared().notify(error);\n        return exit(true);\n    }\n\n    if (!FileManager::removeItems(Factory::associatedPathsForDatabase(factory.database))) {\n        assignWithSharedThreadedError();\n        return exit(false);\n    }\n\n    std::list<StringView> toMove = Factory::associatedPathsForDatabase(database);\n    toMove.reverse();\n    if (!FileManager::moveItems(toMove, Path::getDirectory(factory.database))) {\n        assignWithSharedThreadedError();\n        return exit(false);\n    }\n\n    return exit(true);\n}\n\nbool FactoryVacuum::prepare()\n{\n    WCTRemedialAssert(\n    m_vacuumDelegate != nullptr, \"Vacuum delegate is not available.\", return false;);\n\n    // 1. create temp directory for acquisition\n    StringView tempDirectory = Path::addComponent(directory, \"temp\");\n    StringView tempDatabase\n    = Path::addComponent(tempDirectory, factory.getDatabaseName());\n\n    if (!FileManager::removeItem(tempDirectory)\n        || !FileManager::createDirectoryWithIntermediateDirectories(tempDirectory)) {\n        assignWithSharedThreadedError();\n        return exit(false);\n    }\n\n    // 2. Copy all data into temp database\n    m_vacuumDelegate->setVacuumDatabase(tempDatabase);\n    m_vacuumDelegate->setOriginalDatabase(factory.database);\n    m_vacuumDelegate->setProgressCallback(std::bind(\n    &FactoryVacuum::increaseProgress, this, std::placeholders::_1, std::placeholders::_2));\n    ;\n    if (!m_vacuumDelegate->executeVacuum()) {\n        setError(m_vacuumDelegate->getVacuumError());\n        return exit(false);\n    }\n\n    // 3. move the assembled database to vacuum directory.\n    std::list<StringView> toRemove = Factory::associatedPathsForDatabase(database);\n    toRemove.reverse(); // move from end to start, which can avoid issues that unexpected crash happens before all files moved.\n    if (!FileManager::removeItems(toRemove)) {\n        assignWithSharedThreadedError();\n        return exit(false);\n    }\n    std::list<StringView> toMove = Factory::associatedPathsForDatabase(tempDatabase);\n    toMove.reverse();\n    if (!FileManager::moveItems(toMove, directory)) {\n        assignWithSharedThreadedError();\n        return exit(false);\n    }\n    FileManager::removeItem(tempDirectory);\n\n    // 4. remove the original database\n    if (!FileManager::removeItems(Factory::associatedPathsForDatabase(factory.database))) {\n        assignWithSharedThreadedError();\n        return exit(false);\n    }\n\n    return true;\n}\n\nbool FactoryVacuum::increaseProgress(double, double increment)\n{\n    return Progress::increaseProgress(increment);\n}\n\nbool FactoryVacuum::exit(bool result)\n{\n    FileManager::removeItem(directory);\n    factory.removeDirectoryIfEmpty();\n    if (result) {\n        finishProgress();\n    }\n    return result;\n}\n\n} // namespace Repair\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/repair/factory/FactoryVacuum.hpp",
    "content": "//\n// Created by qiuwenchen on 2023/12/15.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"Backup.hpp\"\n#include \"ErrorProne.hpp\"\n#include \"FactoryRelated.hpp\"\n#include \"Vacuum.hpp\"\n\nnamespace WCDB {\n\nnamespace Repair {\n\nclass FactoryVacuum final : public FactoryRelated,\n                            public ErrorProne,\n                            public Progress,\n                            public VacuumDelegateHolder {\npublic:\n    FactoryVacuum(const Factory &factory);\n    ~FactoryVacuum() override;\n\n    const StringView directory;\n    const StringView database;\n\n    bool work();\n    bool prepare();\n\nprotected:\n    bool increaseProgress(double progress, double increment);\n    bool exit(bool result);\n};\n\n} // namespace Repair\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/repair/mechanic/Backup.cpp",
    "content": "//\n// Created by sanhuazhang on 2018/06/05\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"Backup.hpp\"\n#include \"Assertion.hpp\"\n#include \"Cell.hpp\"\n#include \"CoreConst.h\"\n#include \"Factory.hpp\"\n#include \"FileManager.hpp\"\n#include \"MasterItem.hpp\"\n#include \"Notifier.hpp\"\n#include \"Page.hpp\"\n#include \"SequenceItem.hpp\"\n#include \"StringView.hpp\"\n#include \"SyntaxCommonConst.hpp\"\n\nnamespace WCDB {\n\nnamespace Repair {\n\nBackupBaseDelegate::~BackupBaseDelegate() = default;\n\nBackupSharedDelegate::~BackupSharedDelegate() = default;\n\nBackupExclusiveDelegate::BackupExclusiveDelegate() : m_suspend(false)\n{\n}\n\nBackupExclusiveDelegate::~BackupExclusiveDelegate() = default;\n\nBackupDelegateHolder::BackupDelegateHolder() = default;\n\nBackupDelegateHolder::~BackupDelegateHolder() = default;\n\nvoid BackupDelegateHolder::setBackupSharedDelegate(BackupSharedDelegate *delegate)\n{\n    WCTAssert(delegate != nullptr);\n    m_sharedDelegate = delegate;\n}\n\nvoid BackupDelegateHolder::setBackupExclusiveDelegate(BackupExclusiveDelegate *delegate)\n{\n    WCTAssert(delegate != nullptr);\n    m_exclusiveDelegate = delegate;\n}\n\nbool BackupDelegateHolder::isDelegateValid() const\n{\n    return m_sharedDelegate != nullptr && m_exclusiveDelegate != nullptr\n           && (uintptr_t) m_sharedDelegate != (uintptr_t) m_exclusiveDelegate;\n}\n\n#pragma mark - Initialize\nBackup::Backup(const UnsafeStringView &path)\n: Crawlable()\n, m_pager(path)\n, m_incrementalMaterial(nullptr)\n, m_verifyingPagenos(nullptr)\n, m_unchangedLeavesCount(0)\n, m_masterCrawler()\n{\n    setAssociatedPager(&m_pager);\n    m_masterCrawler.setAssociatedPager(&m_pager);\n}\n\nBackup::~Backup() = default;\n\n#pragma mark - Backup\nbool Backup::work(SharedIncrementalMaterial incrementalMaterial)\n{\n    WCTRemedialAssert(isDelegateValid(), \"Read/Write locker is not avaiable.\", return false;);\n\n    auto materialLoad = tryLoadLatestMaterial(incrementalMaterial);\n    if (!materialLoad.hasValue()) {\n        return false;\n    }\n    if (!materialLoad.value()) {\n        if (!fullBackup()) {\n            return false;\n        }\n        if (incrementalMaterial != nullptr) {\n            //Avoid to be changed during the backup\n            m_incrementalMaterial\n            = std::make_shared<IncrementalMaterial>(*incrementalMaterial);\n        }\n    } else {\n        if (incrementalMaterial != nullptr) {\n            //Avoid to be changed during the backup\n            m_incrementalMaterial\n            = std::make_shared<IncrementalMaterial>(*incrementalMaterial);\n        }\n        if (!incrementalBackup()) {\n            return false;\n        }\n    }\n\n    updateMaterial(materialLoad.value());\n\n    return true;\n}\n\nOptional<bool> Backup::tryLoadLatestMaterial(SharedIncrementalMaterial incrementalMaterial)\n{\n    if (incrementalMaterial == nullptr\n        || incrementalMaterial->info.incrementalBackupTimes >= BackupMaxIncrementalTimes) {\n        return false;\n    }\n    auto materialPath = Factory::latestMaterialForDatabase(m_pager.getPath());\n    if (materialPath.failed()) {\n        return NullOpt;\n    }\n    if (materialPath->empty()) {\n        return false;\n    }\n    bool useMaterial = false;\n    if (m_cipherDelegate->isCipherDB()) {\n        m_material.setCipherDelegate(m_cipherDelegate);\n        useMaterial = m_material.decryptedDeserialize(materialPath.value(), false);\n    } else {\n        useMaterial = m_material.deserialize(materialPath.value());\n    }\n    if (!useMaterial) {\n        m_material = Material();\n        return NullOpt;\n    }\n    if (m_material.info.walSalt != incrementalMaterial->info.lastWalSalt\n        || m_material.info.nBackFill != incrementalMaterial->info.lastNBackFill) {\n        Error error(Error::Code::Error, Error::Level::Warning, \"Mismatch incremental Material\");\n        error.infos.insert_or_assign(ErrorStringKeySource, ErrorSourceRepair);\n        error.infos.insert_or_assign(ErrorStringKeyPath, m_pager.getPath());\n        error.infos.insert_or_assign(\"currentSalt\",\n                                     (((uint64_t) m_material.info.walSalt.second) << 32)\n                                     | m_material.info.walSalt.first);\n        error.infos.insert_or_assign(\n        \"newSalt\",\n        (((uint64_t) incrementalMaterial->info.lastWalSalt.second) << 32)\n        | incrementalMaterial->info.lastWalSalt.first);\n        error.infos.insert_or_assign(\"currentNBackFill\", m_material.info.nBackFill);\n        error.infos.insert_or_assign(\"newNBackFill\", incrementalMaterial->info.lastNBackFill);\n        Notifier::shared().notify(error);\n        m_material = Material();\n        return false;\n    }\n    return true;\n}\n\nbool Backup::fullBackup()\n{\n    bool exclusive = false;\n    bool succeed = false;\n    do {\n        //acquire write lock to avoid shm changed during initialize\n        if (!m_exclusiveDelegate->acquireBackupExclusiveLock()) {\n            setError(m_exclusiveDelegate->getBackupError());\n            break;\n        }\n        exclusive = true;\n\n        if (m_cipherDelegate->isCipherDB()) {\n            size_t pageSize = m_cipherDelegate->getCipherPageSize();\n            if (pageSize == 0) {\n                setError(m_cipherDelegate->getCipherError());\n                break;\n            }\n            void *pCodec = m_cipherDelegate->getCipherContext();\n            m_pager.setCipherContext(pCodec);\n            m_pager.setPageSize((int) pageSize);\n        }\n\n        if (!m_pager.initialize()) {\n            setError(m_pager.getError());\n            break;\n        }\n\n        if (!m_exclusiveDelegate->releaseBackupExclusiveLock()) {\n            setError(m_exclusiveDelegate->getBackupError());\n            break;\n        }\n        exclusive = false;\n\n        m_material.setCipherDelegate(m_cipherDelegate);\n        succeed = m_masterCrawler.work(this);\n        if (!succeed) {\n            setError(m_pager.getError());\n        }\n        if (m_material.info.seqTableRootPage == Material::UnknownPageNo) {\n            m_material.info.seqTableRootPage = 0;\n        }\n    } while (false);\n\n    if (exclusive && !m_exclusiveDelegate->releaseBackupExclusiveLock() && succeed) {\n        setError(m_exclusiveDelegate->getBackupError());\n        succeed = false;\n    }\n\n    return succeed;\n}\n\nbool Backup::incrementalBackup()\n{\n    if (m_cipherDelegate->isCipherDB()) {\n        size_t pageSize = m_cipherDelegate->getCipherPageSize();\n        if (pageSize == 0) {\n            setError(m_cipherDelegate->getCipherError());\n            return false;\n        }\n        void *pCodec = m_cipherDelegate->getCipherContext();\n        m_pager.setCipherContext(pCodec);\n        m_pager.setPageSize((int) pageSize);\n    }\n    m_pager.setWalSkipped();\n    if (!m_pager.initialize()) {\n        setError(m_pager.getError());\n        return false;\n    }\n    m_verifyingPagenos = &m_incrementalMaterial->pages;\n    int schemaCookie = m_pager.getSchemaCookie();\n    if (schemaCookie != m_incrementalMaterial->info.lastSchemaCookie\n        || m_material.info.seqTableRootPage == Material::UnknownPageNo) {\n        if (!loadWal()) {\n            setError(m_pager.getError());\n            return false;\n        }\n        if (!m_masterCrawler.work(this)) {\n            setError(m_pager.getError());\n            return false;\n        }\n        if (m_material.info.seqTableRootPage == Material::UnknownPageNo) {\n            m_material.info.seqTableRootPage = 0;\n        }\n        m_pager.disposeWal();\n        for (auto iter = m_material.contentsList.begin();\n             iter != m_material.contentsList.end();) {\n            auto &content = *iter;\n            if (content.checked) {\n                iter++;\n            } else {\n                // Deleted table\n                m_material.contentsMap.erase(content.tableName);\n                iter = m_material.contentsList.erase(iter);\n            }\n        }\n    } else if (m_material.info.seqTableRootPage != 0\n               && m_material.info.seqTableRootPage != Material::UnknownPageNo) {\n        SequenceCrawler crawler;\n        crawler.setAssociatedPager(&m_pager);\n        if (!crawler.work(m_material.info.seqTableRootPage, this)) {\n            setError(m_pager.getError());\n            return false;\n        }\n    }\n\n    if (m_verifyingPagenos->size() == 0) {\n        return true;\n    }\n\n    uint32_t pageCount = m_pager.getNumberOfPages();\n    WCTAssert(pageCount > 0);\n    m_unchangedLeaves.resize(pageCount, false);\n    m_unchangedLeavesCount = 0;\n\n    auto &contentList = m_material.contentsList;\n    for (auto &content : contentList) {\n        auto &pages = content.verifiedPagenos;\n        for (auto page = pages.begin(); page != pages.end();) {\n            if (m_verifyingPagenos->find(page->number) != m_verifyingPagenos->end()) {\n                // Need to be verified\n                page->number = 0;\n            } else if (page->number <= pageCount) {\n                m_unchangedLeaves[page->number - 1] = true;\n                m_unchangedLeavesCount++;\n            }\n            page++;\n        }\n    }\n    for (auto iter = m_verifyingPagenos->begin(); iter != m_verifyingPagenos->end();) {\n        auto &page = iter->second;\n        if (page.type != Page::Type::LeafTable && page.type != Page::Type::InteriorTable) {\n            iter = m_verifyingPagenos->erase(iter);\n        } else {\n            iter++;\n        }\n    }\n    if (m_verifyingPagenos->size() == 0) {\n        return true;\n    }\n    for (auto iter = contentList.begin(); iter != contentList.end();) {\n        WCTAssert(iter->rootPage > 1 && iter->rootPage != Material::UnknownPageNo);\n        if (!crawl(iter->rootPage)) {\n            setError(m_pager.getError());\n            return false;\n        }\n        for (auto pageIter = iter->verifiedPagenos.begin();\n             pageIter != iter->verifiedPagenos.end();\n             pageIter++) {\n            if (pageIter->number > 0 && pageIter->number <= m_unchangedLeaves.size()\n                && m_unchangedLeaves[pageIter->number - 1]) {\n                // Deleted page\n                pageIter->number = 0;\n            }\n        }\n        if (m_verifiedPagenos.size() > 0) {\n            iter->verifiedPagenos.insert(iter->verifiedPagenos.end(),\n                                         m_verifiedPagenos.begin(),\n                                         m_verifiedPagenos.end());\n            m_verifiedPagenos.clear();\n            auto preIter = iter;\n            iter++;\n            contentList.splice(contentList.begin(), contentList, preIter);\n        } else {\n            iter++;\n        }\n        if (m_verifyingPagenos->size() == 0) {\n            return true;\n        }\n    }\n    return true;\n}\n\nbool Backup::loadWal()\n{\n    bool exclusive = false;\n    bool succeed = false;\n    do {\n        //acquire write lock to avoid shm changed during initialize\n        if (!m_exclusiveDelegate->acquireBackupExclusiveLock()) {\n            setError(m_exclusiveDelegate->getBackupError());\n            break;\n        }\n        exclusive = true;\n\n        WCTAssert(m_incrementalMaterial != nullptr);\n        m_pager.setNBackFill(m_incrementalMaterial->info.currentNBackFill);\n        m_pager.setWalSalt(m_incrementalMaterial->info.currentWalSalt);\n        succeed = m_pager.loadWal();\n    } while (false);\n\n    if (exclusive && !m_exclusiveDelegate->releaseBackupExclusiveLock() && succeed) {\n        setError(m_exclusiveDelegate->getBackupError());\n        succeed = false;\n    }\n    return succeed;\n}\n\nconst Material &Backup::getMaterial() const\n{\n    return m_material;\n}\n\nSharedIncrementalMaterial Backup::getIncrementalMaterial()\n{\n    return m_incrementalMaterial;\n}\n\nvoid Backup::updateMaterial(bool isIncremental)\n{\n    auto &info = m_material.info;\n\n    if (m_incrementalMaterial != nullptr) {\n        info.walSalt = m_incrementalMaterial->info.currentWalSalt;\n        info.nBackFill = m_incrementalMaterial->info.currentNBackFill;\n    } else {\n        m_incrementalMaterial = std::make_shared<IncrementalMaterial>();\n        info.walSalt = m_pager.getWalSalt();\n        info.nBackFill = m_pager.getNBackFill();\n        m_incrementalMaterial->info.lastCheckPointFinish\n        = info.nBackFill == m_pager.getMaxFrame();\n    }\n\n    auto &incrementalInfo = m_incrementalMaterial->info;\n\n    m_material.info.pageSize = m_pager.getPageSize();\n    m_material.info.reservedBytes = m_pager.getReservedBytes();\n    incrementalInfo.lastWalSalt = info.walSalt;\n    incrementalInfo.lastNBackFill = info.nBackFill;\n    incrementalInfo.currentWalSalt = info.walSalt;\n    incrementalInfo.currentNBackFill = info.nBackFill;\n    incrementalInfo.lastSchemaCookie = m_pager.getSchemaCookie();\n    incrementalInfo.lastBackupTime = (uint32_t) Time::now().seconds();\n    m_incrementalMaterial->pages.clear();\n    if (!isIncremental) {\n        incrementalInfo.incrementalBackupTimes = 0;\n    } else {\n        incrementalInfo.incrementalBackupTimes++;\n    }\n}\n\nMaterial::Content &Backup::getOrCreateContent(const UnsafeStringView &tableName)\n{\n    auto &contentsMap = m_material.contentsMap;\n    auto iter = contentsMap.find(tableName);\n    if (iter == contentsMap.end()) {\n        m_material.contentsList.emplace_back();\n        m_material.contentsList.back().tableName = tableName;\n        iter = contentsMap.emplace(tableName, &(m_material.contentsList.back())).first;\n    }\n    return (*iter->second);\n}\n\n#pragma mark - Filter\nvoid Backup::filter(const Filter &tableShouldBeBackedUp)\n{\n    m_filter = tableShouldBeBackedUp;\n}\n\nbool Backup::filter(const UnsafeStringView &tableName)\n{\n    bool result = true;\n    if (m_filter != nullptr) {\n        result = m_filter(tableName);\n    }\n    return result;\n}\n\n#pragma mark - Crawlable\nbool Backup::canCrawlPage(uint32_t pageno)\n{\n    if (m_verifyingPagenos != nullptr) {\n        //Incremental backup\n        if (pageno > m_unchangedLeaves.size() || pageno == 0) {\n            markAsCorrupted(\n            pageno,\n            StringView::formatted(\n            \"Page %u exceeds max pageno %u\", pageno, m_unchangedLeaves.size()));\n            return false;\n        }\n        if (m_unchangedLeaves[pageno - 1]) {\n            m_unchangedLeaves[pageno - 1] = false;\n            return false;\n        }\n        auto iter = m_verifyingPagenos->find(pageno);\n        if (iter != m_verifyingPagenos->end()) {\n            bool isLeaf = iter->second.type == Page::Type::LeafTable;\n            if (isLeaf) {\n                m_verifiedPagenos.emplace_back(iter->first, iter->second.hash);\n            }\n            m_verifyingPagenos->erase(iter);\n            return !isLeaf;\n        }\n    }\n    return true;\n}\n\nvoid Backup::onCellCrawled(const Cell &cell)\n{\n    WCDB_UNUSED(cell);\n    WCTAssert(false);\n}\n\nbool Backup::willCrawlPage(const Page &page, int height)\n{\n    if (m_exclusiveDelegate->backupSuspended()) {\n        markAsInterrupted();\n        return false;\n    }\n    WCDB_UNUSED(height);\n    switch (page.getType()) {\n    case Page::Type::InteriorTable:\n        return true;\n    case Page::Type::LeafTable: {\n        WCTAssert(m_unchangedLeavesCount == 0);\n        m_verifiedPagenos.emplace_back(page.number, page.getData().hash());\n        return false;\n    }\n    case Page::Type::InteriorIndex:\n    case Page::Type::LeafIndex:\n        return false;\n    default:\n        markAsCorrupted(\n        page.number, StringView::formatted(\"Unexpected page type: %d\", page.getType()));\n        return false;\n    }\n}\n\nvoid Backup::onCrawlerError()\n{\n    m_masterCrawler.suspend();\n    suspend();\n}\n\n#pragma mark - MasterCrawlerDelegate\nvoid Backup::onMasterPageCrawled(const Page &page)\n{\n    if (m_verifyingPagenos != nullptr) {\n        m_verifyingPagenos->erase(page.number);\n    }\n}\n\nvoid Backup::onMasterCellCrawled(const Cell &cell, const MasterItem &master)\n{\n    WCDB_UNUSED(cell);\n    if (master.name == Syntax::sequenceTable) {\n        m_material.info.seqTableRootPage = master.rootpage;\n        SequenceCrawler crawler;\n        crawler.setAssociatedPager(&m_pager);\n        crawler.work(master.rootpage, this);\n    } else if (filter(master.tableName)\n               && !MasterItem::isReservedTableName(master.tableName)\n               && !MasterItem::isReservedTableName(master.name)) {\n        Material::Content &content = getOrCreateContent(master.tableName);\n        if (master.type.caseInsensitiveEqual(\"table\")\n            && master.name.caseInsensitiveEqual(master.tableName)) {\n            content.sql = master.sql;\n            content.associatedSQLs.clear();\n            content.rootPage = master.rootpage;\n            content.checked = true;\n            if (m_incrementalMaterial != nullptr) {\n                return;\n            }\n            if (!crawl(master.rootpage)) {\n                return;\n            }\n            content.verifiedPagenos = std::move(m_verifiedPagenos);\n        } else {\n            if (!master.sql.empty()) {\n                content.associatedSQLs.push_back(master.sql);\n            }\n        }\n    }\n}\n\nvoid Backup::onMasterCrawlerError()\n{\n    markAsError();\n}\n\n#pragma mark - SequenceCrawlerDelegate\nvoid Backup::onSequencePageCrawled(const Page &page)\n{\n    if (m_verifyingPagenos != nullptr) {\n        m_verifyingPagenos->erase(page.number);\n    }\n}\n\nvoid Backup::onSequenceCellCrawled(const Cell &cell, const SequenceItem &sequence)\n{\n    WCDB_UNUSED(cell);\n    if (sequence.seq == 0) {\n        return;\n    }\n    if (!MasterItem::isReservedTableName(sequence.name) && filter(sequence.name)) {\n        Material::Content &content = getOrCreateContent(sequence.name);\n        //the columns in sqlite_sequence are not unique.\n        content.sequence = std::max(content.sequence, sequence.seq);\n    }\n}\n\nvoid Backup::onSequenceCrawlerError()\n{\n    markAsError();\n}\n\n} //namespace Repair\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/common/repair/mechanic/Backup.hpp",
    "content": "//\n// Created by sanhuazhang on 2018/06/05\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"Cipher.hpp\"\n#include \"IncrementalMaterial.hpp\"\n#include \"MasterCrawler.hpp\"\n#include \"Material.hpp\"\n#include \"SequenceCrawler.hpp\"\n#include <memory>\n#include <vector>\n\nnamespace WCDB {\n\nnamespace Repair {\n\nclass BackupBaseDelegate {\npublic:\n    virtual ~BackupBaseDelegate() = 0;\n    virtual void setBackupPath(const UnsafeStringView &path) = 0;\n    virtual const StringView &getBackupPath() const = 0;\n\n    virtual const Error &getBackupError() const = 0;\n    virtual void finishBackup() = 0;\n};\n\nclass BackupSharedDelegate : public BackupBaseDelegate {\npublic:\n    virtual ~BackupSharedDelegate() = 0;\n\n    virtual bool acquireBackupSharedLock() = 0;\n    virtual bool releaseBackupSharedLock() = 0;\n};\n\nclass BackupExclusiveDelegate : public BackupBaseDelegate {\npublic:\n    BackupExclusiveDelegate();\n    virtual ~BackupExclusiveDelegate() = 0;\n\n    virtual bool acquireBackupExclusiveLock() = 0;\n    virtual bool releaseBackupExclusiveLock() = 0;\n    virtual bool backupSuspended() const = 0;\n\nprivate:\n    std::atomic<bool> m_suspend;\n};\n\nclass BackupDelegateHolder {\npublic:\n    BackupDelegateHolder();\n    virtual ~BackupDelegateHolder() = 0;\n    void setBackupSharedDelegate(BackupSharedDelegate *delegate);\n    void setBackupExclusiveDelegate(BackupExclusiveDelegate *delegate);\n\nprotected:\n    bool isDelegateValid() const;\n    BackupSharedDelegate *m_sharedDelegate;\n    BackupExclusiveDelegate *m_exclusiveDelegate;\n};\n\nclass Backup final : public Crawlable,\n                     public MasterCrawlerDelegate,\n                     public SequenceCrawlerDelegate,\n                     public CipherDelegateHolder,\n                     public BackupDelegateHolder,\n                     public ErrorProne {\n#pragma mark - Initialize\npublic:\n    Backup(const UnsafeStringView &path);\n    ~Backup() override;\n\nprotected:\n    Pager m_pager;\n\n#pragma mark - Backup\npublic:\n    bool work(SharedIncrementalMaterial material);\n\n    const Material &getMaterial() const;\n    SharedIncrementalMaterial getIncrementalMaterial();\n\nprotected:\n    Optional<bool> tryLoadLatestMaterial(SharedIncrementalMaterial incrementalMaterial);\n    bool fullBackup();\n    bool incrementalBackup();\n    bool loadWal();\n    void updateMaterial(bool isIncremental);\n\n    Material m_material;\n    SharedIncrementalMaterial m_incrementalMaterial;\n    Material::Content &getOrCreateContent(const UnsafeStringView &tableName);\n\n    typedef Material::VerifiedPages VerifiedPages;\n    VerifiedPages m_verifiedPagenos;\n\n    typedef IncrementalMaterial::Pages IncrementalPages;\n    IncrementalPages *m_verifyingPagenos;\n    std::vector<bool> m_unchangedLeaves;\n    int m_unchangedLeavesCount;\n\n#pragma mark - Filter\npublic:\n    typedef std::function<bool(const UnsafeStringView &table)> Filter;\n    void filter(const Filter &tableShouldBeBackedUp);\n\nprotected:\n    bool filter(const UnsafeStringView &tableName);\n    Filter m_filter;\n\n#pragma mark - Crawlable\nprotected:\n    bool canCrawlPage(uint32_t pageno) override final;\n    void onCellCrawled(const Cell &cell) override final;\n    bool willCrawlPage(const Page &page, int height) override final;\n    void onCrawlerError() override final;\n\n#pragma mark - MasterCrawlerDelegate\nprotected:\n    void onMasterPageCrawled(const Page &page) override final;\n    void onMasterCellCrawled(const Cell &cell, const MasterItem &master) override final;\n    void onMasterCrawlerError() override final;\n\n    MasterCrawler m_masterCrawler;\n\n#pragma mark - SequenceCrawlerDelegate\nprotected:\n    void onSequencePageCrawled(const Page &page) override final;\n    void onSequenceCellCrawled(const Cell &cell, const SequenceItem &sequence) override final;\n    void onSequenceCrawlerError() override final;\n};\n\n} //namespace Repair\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/common/repair/mechanic/BackupHandleOperator.cpp",
    "content": "//\n// Created by 陈秋文 on 2023/11/16.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"BackupHandleOperator.hpp\"\n\nnamespace WCDB {\n\nnamespace Repair {\n\nBackupHandleOperator::BackupHandleOperator(InnerHandle *handle)\n: HandleOperator(handle)\n{\n}\n\nBackupHandleOperator::~BackupHandleOperator() = default;\n\n#pragma mark - Backup\nvoid BackupHandleOperator::setBackupPath(const UnsafeStringView &path)\n{\n    getHandle()->setPath(path);\n    getHandle()->open();\n}\n\nconst StringView &BackupHandleOperator::getBackupPath() const\n{\n    return getHandle()->getPath();\n}\n\nconst Error &BackupHandleOperator::getBackupError() const\n{\n    return getHandle()->getError();\n}\n\nbool BackupHandleOperator::acquireBackupSharedLock()\n{\n    WCTAssert(getHandle()->isOpened());\n    if (!getHandle()->isOpened()) {\n        getHandle()->notifyError(Error::Code::Warning, \"\", \"Handle is not opened!\");\n        return false;\n    }\n    int maxRryTimes = 5;\n    do {\n        if (getHandle()->setCheckPointLock(true)) {\n            return true;\n        }\n        if (getHandle()->getError().code() != Error::Code::Busy) {\n            return false;\n        }\n        std::this_thread::sleep_for(std::chrono::milliseconds(100));\n        maxRryTimes--;\n    } while (maxRryTimes > 0);\n    return false;\n}\n\nbool BackupHandleOperator::releaseBackupSharedLock()\n{\n    return getHandle()->setCheckPointLock(false);\n}\n\nbool BackupHandleOperator::acquireBackupExclusiveLock()\n{\n    WCTAssert(getHandle()->isOpened());\n    return getHandle()->beginTransaction();\n}\n\nbool BackupHandleOperator::releaseBackupExclusiveLock()\n{\n    getHandle()->rollbackTransaction();\n    return true;\n}\n\nbool BackupHandleOperator::backupSuspended() const\n{\n    return getHandle()->isSuspended();\n}\n\nvoid BackupHandleOperator::finishBackup()\n{\n    getHandle()->close();\n}\n\n} // namespace Repair\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/repair/mechanic/BackupHandleOperator.hpp",
    "content": "//\n// Created by 陈秋文 on 2023/11/16.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"Backup.hpp\"\n#include \"HandleOperator.hpp\"\n\nnamespace WCDB {\n\nnamespace Repair {\n\nclass BackupHandleOperator : public HandleOperator,\n                             public BackupSharedDelegate,\n                             public BackupExclusiveDelegate {\npublic:\n    BackupHandleOperator(InnerHandle *handle);\n    ~BackupHandleOperator() override;\n\n#pragma mark - Backup\npublic:\n    void setBackupPath(const UnsafeStringView &path) override final;\n    const StringView &getBackupPath() const override final;\n    const Error &getBackupError() const override final;\n\n    bool acquireBackupSharedLock() override final;\n    bool releaseBackupSharedLock() override final;\n\n    bool acquireBackupExclusiveLock() override final;\n    bool releaseBackupExclusiveLock() override final;\n    bool backupSuspended() const override final;\n\n    void finishBackup() override final;\n};\n\n} // namespace Repair\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/repair/mechanic/IncrementalMaterial.cpp",
    "content": "//\n// Created by 陈秋文 on 2023/9/2.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"IncrementalMaterial.hpp\"\n#include \"Assertion.hpp\"\n#include \"CoreConst.h\"\n#include \"Data.hpp\"\n#include \"FileHandle.hpp\"\n#include \"FileManager.hpp\"\n#include \"Notifier.hpp\"\n#include \"SQLite.h\"\n#include \"Serialization.hpp\"\n#include \"WCDBError.hpp\"\n#include <cstring>\n\nnamespace WCDB {\n\nnamespace Repair {\n\nIncrementalMaterial::~IncrementalMaterial() = default;\n\n#pragma mark - Serialization\nbool IncrementalMaterial::serialize(Serialization &serialization) const\n{\n    //Header\n    if (!serialization.expand(IncrementalMaterial::headerSize)) {\n        return false;\n    }\n    serialization.put4BytesUInt(magic);\n    serialization.put4BytesUInt(version);\n\n    //Info\n    if (!info.serialize(serialization)) {\n        return false;\n    }\n\n    //Contents\n    Serialization encoder;\n    for (const auto &element : pages) {\n        if (element.second.number == 0) {\n            markAsEmpty(\"Page\");\n            return false;\n        }\n        if (!element.second.serialize(encoder)) {\n            return false;\n        }\n    }\n    return serializeData(serialization, encoder.finalize());\n}\n\nbool IncrementalMaterial::serializeData(Serialization &serialization, const Data &data)\n{\n    uint32_t checksum = data.empty() ? 0 : data.hash();\n    return serialization.put4BytesUInt(checksum) && serialization.putSizedData(data);\n}\n\nvoid IncrementalMaterial::markAsEmpty(const UnsafeStringView &element)\n{\n    Error error(Error::Code::Empty, Error::Level::Error, \"Element of IncrementalMaterial is empty.\");\n    error.infos.insert_or_assign(ErrorStringKeySource, ErrorSourceRepair);\n    error.infos.insert_or_assign(\"Element\", element);\n    Notifier::shared().notify(error);\n    setThreadedError(std::move(error));\n}\n\n#pragma mark - Deserialization\nbool IncrementalMaterial::deserialize(Deserialization &deserialization)\n{\n    //Header\n    if (!deserialization.canAdvance(IncrementalMaterial::headerSize)) {\n        markAsCorrupt(\"Header\");\n        return false;\n    }\n    uint32_t magicValue = deserialization.advance4BytesUInt();\n    uint32_t versionValue = deserialization.advance4BytesUInt();\n    if (magicValue != IncrementalMaterial::magic) {\n        markAsCorrupt(\"Magic\");\n        return false;\n    }\n    if (versionValue != 0x01000000) {\n        markAsCorrupt(\"Version\");\n        return false;\n    }\n    deserialization.setDataVersion(versionValue);\n\n    //Info\n    if (!info.deserialize(deserialization)) {\n        return false;\n    }\n\n    auto decompressed = deserializeData(deserialization);\n    if (!decompressed.succeed()) {\n        return false;\n    }\n\n    Deserialization decoder(decompressed.value());\n    decoder.setDataVersion(deserialization.version());\n    while (!decoder.ended()) {\n        Page page;\n        if (!page.deserialize(decoder)) {\n            return false;\n        }\n        pages[page.number] = std::move(page);\n    }\n    return true;\n}\n\nOptional<Data> IncrementalMaterial::deserializeData(Deserialization &deserialization)\n{\n    if (!deserialization.canAdvance(sizeof(uint32_t))) {\n        markAsCorrupt(\"Checksum\");\n        return NullOpt;\n    }\n    uint32_t checksum = deserialization.advance4BytesUInt();\n    auto intermediate = deserialization.advanceSizedData();\n    if (intermediate.first == 0) {\n        markAsCorrupt(\"Content\");\n        return NullOpt;\n    }\n    Data data;\n    if (!intermediate.second.empty()) {\n        data = intermediate.second;\n        if (checksum != data.hash()) {\n            markAsCorrupt(\"Checksum\");\n            return NullOpt;\n        }\n    } else if (checksum != 0) {\n        markAsCorrupt(\"Checksum\");\n        return NullOpt;\n    }\n    return data;\n}\n\nvoid IncrementalMaterial::decryptFail(const UnsafeStringView &element) const\n{\n    markAsCorrupt(element);\n}\n\nvoid IncrementalMaterial::markAsCorrupt(const UnsafeStringView &element)\n{\n    Error error(Error::Code::Corrupt, Error::Level::Notice, \"IncrementalMaterial is corrupted\");\n    error.infos.insert_or_assign(ErrorStringKeySource, ErrorSourceRepair);\n    error.infos.insert_or_assign(\"Element\", element);\n    Notifier::shared().notify(error);\n    setThreadedError(std::move(error));\n}\n\nCipherDelegate *IncrementalMaterial::getCipherDelegate() const\n{\n    return m_cipherDelegate;\n}\n\n#pragma mark - Info\nIncrementalMaterial::Info::Info()\n: lastWalSalt({ 0, 0 })\n, currentWalSalt({ 0, 0 })\n, currentNBackFill(0)\n, lastSchemaCookie(0)\n, lastCheckPointFinish(false)\n, lastBackupTime(0)\n, incrementalBackupTimes(0)\n{\n    static_assert(saltSize == 16, \"\");\n}\n\nIncrementalMaterial::Info::~Info() = default;\n\n#pragma mark - Serialization\nbool IncrementalMaterial::Info::serialize(Serialization &serialization) const\n{\n    if (!serialization.expand(Info::saltSize)) {\n        return false;\n    }\n    serialization.put4BytesUInt(lastWalSalt.first);\n    serialization.put4BytesUInt(lastWalSalt.second);\n    serialization.put4BytesUInt(currentWalSalt.first);\n    serialization.put4BytesUInt(currentWalSalt.second);\n    serialization.putVarint(lastNBackFill);\n    serialization.putVarint(currentNBackFill);\n    serialization.put4BytesUInt(lastSchemaCookie);\n    serialization.putVarint(lastCheckPointFinish);\n    serialization.put4BytesUInt(lastBackupTime);\n    serialization.putVarint(incrementalBackupTimes);\n    return true;\n}\n\n#pragma mark - Deserialization\nbool IncrementalMaterial::Info::deserialize(Deserialization &deserialization)\n{\n    if (!deserialization.canAdvance(Info::saltSize)) {\n        markAsCorrupt(\"Salt\");\n        return false;\n    }\n    lastWalSalt.first = deserialization.advance4BytesUInt();\n    lastWalSalt.second = deserialization.advance4BytesUInt();\n    currentWalSalt.first = deserialization.advance4BytesUInt();\n    currentWalSalt.second = deserialization.advance4BytesUInt();\n\n    auto varLastNBackfill = deserialization.advanceVarint();\n    if (varLastNBackfill.first == 0) {\n        markAsCorrupt(\"LastNBackfill\");\n        return false;\n    }\n    lastNBackFill = (uint32_t) varLastNBackfill.second;\n\n    auto varCurrentNBackfill = deserialization.advanceVarint();\n    if (varCurrentNBackfill.first == 0) {\n        markAsCorrupt(\"MxFrame\");\n        return false;\n    }\n    currentNBackFill = (uint32_t) varCurrentNBackfill.second;\n\n    if (!deserialization.canAdvance(4)) {\n        markAsCorrupt(\"lastSchemaCookie\");\n    }\n    lastSchemaCookie = deserialization.advance4BytesUInt();\n\n    auto varLastCheckpointFinish = deserialization.advanceVarint();\n    if (varLastCheckpointFinish.first == 0) {\n        markAsCorrupt(\"LastCheckpointFinish\");\n        return false;\n    }\n    lastCheckPointFinish = (bool) varLastCheckpointFinish.second;\n\n    if (!deserialization.canAdvance(4)) {\n        markAsCorrupt(\"LastBackupTime\");\n    }\n    lastBackupTime = deserialization.advance4BytesUInt();\n\n    auto varBackupTimes = deserialization.advanceVarint();\n    if (varBackupTimes.first == 0) {\n        markAsCorrupt(\"BackupTimes\");\n        return false;\n    }\n    incrementalBackupTimes = (int32_t) varBackupTimes.second;\n\n    return true;\n}\n\n#pragma mark - Page\nIncrementalMaterial::Page::Page() : number(0), type(Type::Unknown), hash(0)\n{\n}\n\nIncrementalMaterial::Page::~Page() = default;\n\n#pragma mark - Serialization\nbool IncrementalMaterial::Page::serialize(Serialization &serialization) const\n{\n    if (!serialization.putVarint(number)) {\n        return false;\n    }\n    if (hash != 0) {\n        return serialization.putVarint(2 * type + 1) && serialization.put4BytesUInt(hash);\n    } else {\n        return serialization.putVarint(2 * type);\n    }\n}\n\n#pragma mark - Deserialization\nbool IncrementalMaterial::Page::deserialize(Deserialization &deserialization)\n{\n    auto varPageNo = deserialization.advanceVarint();\n    if (varPageNo.first == 0) {\n        markAsCorrupt(\"PageNo\");\n        return false;\n    }\n    number = (uint32_t) varPageNo.second;\n\n    auto varType = deserialization.advanceVarint();\n    if (varType.first == 0) {\n        markAsCorrupt(\"PageType\");\n        return false;\n    }\n    type = (Type) (varType.second / 2);\n\n    if (varType.second % 2 == 1) {\n        if (!deserialization.canAdvance(4)) {\n            markAsCorrupt(\"PageHash\");\n            return false;\n        }\n        hash = deserialization.advance4BytesInt();\n    }\n    return true;\n}\n\n} // namespace Repair\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/common/repair/mechanic/IncrementalMaterial.hpp",
    "content": "//\n// Created by 陈秋文 on 2023/9/2.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"EncryptedSerialization.hpp\"\n#include \"Page.hpp\"\n#include \"StringView.hpp\"\n#include <stdlib.h>\n#include <unordered_map>\n#include <vector>\n\nnamespace WCDB {\n\nclass Data;\nclass Serialization;\nclass Deserialization;\n\nnamespace Repair {\n\nclass IncrementalMaterial final : public EncryptedSerializable,\n                                  public DecryptedDeserializable,\n                                  public CipherDelegateHolder {\n#pragma mark - Serializable\npublic:\n    bool serialize(Serialization &serialization) const override final;\n    using Serializable::serialize;\n\n    ~IncrementalMaterial() override;\n\nprotected:\n    static bool serializeData(Serialization &serialization, const Data &data);\n    static void markAsEmpty(const UnsafeStringView &element);\n\n#pragma mark - Deserializable\npublic:\n    bool deserialize(Deserialization &deserialization) override final;\n    using Deserializable::deserialize;\n\nprotected:\n    static Optional<Data> deserializeData(Deserialization &deserialization);\n    static void markAsCorrupt(const UnsafeStringView &element);\n    void decryptFail(const UnsafeStringView &element) const override final;\n    CipherDelegate *getCipherDelegate() const override;\n\n#pragma mark - Header\nprotected:\n    static constexpr const uint32_t magic = 0x57434441;\n    static constexpr const uint32_t version = 0x01000000; //1.0.0.0\n    static constexpr const int headerSize = sizeof(magic) + sizeof(version); //magic + version\n\n#pragma mark - Info\n    class Info final : public Serializable, public Deserializable {\n    public:\n        static constexpr const int saltSize = sizeof(uint32_t) * 4;\n        Info();\n        ~Info() override;\n        std::pair<uint32_t, uint32_t> lastWalSalt;\n        std::pair<uint32_t, uint32_t> currentWalSalt;\n        uint32_t lastNBackFill;\n        uint32_t currentNBackFill;\n        uint32_t lastSchemaCookie;\n        bool lastCheckPointFinish;\n        uint32_t lastBackupTime;\n        int32_t incrementalBackupTimes;\n#pragma mark - Serializable\n    public:\n        bool serialize(Serialization &serialization) const override final;\n#pragma mark - Deserializable\n    public:\n        bool deserialize(Deserialization &deserialization) override final;\n    };\n\npublic:\n    Info info;\n\n#pragma mark - Page\npublic:\n    class Page final : public Serializable, public Deserializable {\n    public:\n        Page();\n        ~Page() override;\n\n        typedef Repair::Page::Type Type;\n\n        uint32_t number;\n        Type type;\n        uint32_t hash;\n\n#pragma mark - Serializable\n    public:\n        bool serialize(Serialization &serialization) const override final;\n#pragma mark - Deserializable\n    public:\n        bool deserialize(Deserialization &deserialization) override final;\n    };\n\n    typedef std::unordered_map<uint32_t, Page> Pages;\n\n    Pages pages;\n};\n\n} //namespace Repair\n\ntypedef std::shared_ptr<Repair::IncrementalMaterial> SharedIncrementalMaterial;\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/common/repair/mechanic/Material.cpp",
    "content": "//\n// Created by sanhuazhang on 2018/05/25\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"Material.hpp\"\n#include \"Assertion.hpp\"\n#include \"CoreConst.h\"\n#include \"Data.hpp\"\n#include \"FileHandle.hpp\"\n#include \"FileManager.hpp\"\n#include \"Notifier.hpp\"\n#include \"SQLite.h\"\n#include \"Serialization.hpp\"\n#include \"WCDBError.hpp\"\n#include <cstring>\n\nnamespace WCDB {\n\nnamespace Repair {\n\nMaterial::~Material() = default;\n\n#pragma mark - Serialization\nbool Material::serialize(Serialization &serialization) const\n{\n    //Header\n    if (!serialization.expand(Material::headerSize)) {\n        return false;\n    }\n    serialization.put4BytesUInt(magic);\n    serialization.put4BytesUInt(version);\n\n    //Info\n    if (!info.serialize(serialization)) {\n        return false;\n    }\n\n    //Contents\n    Serialization encoder;\n    for (const auto &element : contentsList) {\n        if (element.tableName.empty()) {\n            markAsEmpty(\"TableName\");\n            return false;\n        }\n        if (element.sql.length() == 0) {\n            markAsEmpty(\"SQL\");\n            return false;\n        }\n        if (!element.serialize(encoder)) {\n            return false;\n        }\n    }\n    return serializeData(serialization, encoder.finalize());\n}\n\nbool Material::serializeData(Serialization &serialization, const Data &data)\n{\n    uint32_t checksum = data.empty() ? 0 : data.hash();\n    return serialization.put4BytesUInt(checksum) && serialization.putSizedData(data);\n}\n\nvoid Material::markAsEmpty(const UnsafeStringView &element)\n{\n    Error error(Error::Code::Empty, Error::Level::Error, \"Element of material is empty.\");\n    error.infos.insert_or_assign(ErrorStringKeySource, ErrorSourceRepair);\n    error.infos.insert_or_assign(\"Element\", element);\n    Notifier::shared().notify(error);\n    setThreadedError(std::move(error));\n}\n\n#pragma mark - Deserialization\nbool Material::deserialize(Deserialization &deserialization)\n{\n    //Header\n    if (!deserialization.canAdvance(Material::headerSize)) {\n        markAsCorrupt(\"Header\");\n        return false;\n    }\n    uint32_t magicValue = deserialization.advance4BytesUInt();\n    uint32_t versionValue = deserialization.advance4BytesUInt();\n    if (magicValue != Material::magic) {\n        markAsCorrupt(\"Magic\");\n        return false;\n    }\n    if (versionValue != 0x01000000 && versionValue != version) {\n        markAsCorrupt(\"Version\");\n        return false;\n    }\n    deserialization.setDataVersion(versionValue);\n\n    //Info\n    if (!info.deserialize(deserialization)) {\n        return false;\n    }\n\n    auto decompressed = deserializeData(deserialization);\n    if (!decompressed.succeed()) {\n        return false;\n    }\n\n    Deserialization decoder(decompressed.value());\n    decoder.setDataVersion(deserialization.version());\n    while (!decoder.ended()) {\n        contentsList.emplace_back();\n        Content &content = contentsList.back();\n        if (!content.deserialize(decoder)) {\n            return false;\n        }\n        StringView tableName = content.tableName;\n        contentsMap[tableName] = &content;\n    }\n    return true;\n}\n\nOptional<Data> Material::deserializeData(Deserialization &deserialization)\n{\n    if (!deserialization.canAdvance(sizeof(uint32_t))) {\n        markAsCorrupt(\"Checksum\");\n        return NullOpt;\n    }\n    uint32_t checksum = deserialization.advance4BytesUInt();\n    auto intermediate = deserialization.advanceSizedData();\n    if (intermediate.first == 0) {\n        markAsCorrupt(\"Content\");\n        return NullOpt;\n    }\n    Data data;\n    if (!intermediate.second.empty()) {\n        data = intermediate.second;\n        if (checksum != data.hash()) {\n            markAsCorrupt(\"Checksum\");\n            return NullOpt;\n        }\n    } else if (checksum != 0) {\n        markAsCorrupt(\"Checksum\");\n        return NullOpt;\n    }\n    return data;\n}\n\nvoid Material::decryptFail(const UnsafeStringView &element) const\n{\n    markAsCorrupt(element);\n}\n\nvoid Material::markAsCorrupt(const UnsafeStringView &element)\n{\n    Error error(Error::Code::Corrupt, Error::Level::Notice, \"Material is corrupted\");\n    error.infos.insert_or_assign(ErrorStringKeySource, ErrorSourceRepair);\n    error.infos.insert_or_assign(\"Element\", element);\n    Notifier::shared().notify(error);\n    setThreadedError(std::move(error));\n}\n\nCipherDelegate *Material::getCipherDelegate() const\n{\n    return m_cipherDelegate;\n}\n\n#pragma mark - Info\nMaterial::Info::Info()\n: pageSize(0), reservedBytes(0), walSalt({ 0, 0 }), nBackFill(0), seqTableRootPage(UnknownPageNo)\n{\n    static_assert(size == 24, \"\");\n}\n\nMaterial::Info::~Info() = default;\n\n#pragma mark - Serialization\nbool Material::Info::serialize(Serialization &serialization) const\n{\n    if (!serialization.expand(Info::size)) {\n        return false;\n    }\n    serialization.put4BytesUInt(pageSize);\n    serialization.put4BytesUInt(reservedBytes);\n    serialization.put4BytesUInt(walSalt.first);\n    serialization.put4BytesUInt(walSalt.second);\n    serialization.put4BytesUInt(nBackFill);\n    serialization.put4BytesUInt(seqTableRootPage);\n    return true;\n}\n\n#pragma mark - Deserialization\nbool Material::Info::deserialize(Deserialization &deserialization)\n{\n    if (!deserialization.canAdvance(Info::size - sizeof(uint32_t))) {\n        markAsCorrupt(\"Info\");\n        return false;\n    }\n    pageSize = deserialization.advance4BytesUInt();\n    reservedBytes = deserialization.advance4BytesUInt();\n    walSalt.first = deserialization.advance4BytesUInt();\n    walSalt.second = deserialization.advance4BytesUInt();\n    nBackFill = deserialization.advance4BytesUInt();\n    if (deserialization.version() >= 0x01000001) {\n        if (!deserialization.canAdvance(sizeof(uint32_t))) {\n            markAsCorrupt(\"SeqTableRootPage\");\n            return false;\n        }\n        seqTableRootPage = deserialization.advance4BytesUInt();\n        WCTAssert(seqTableRootPage != UnknownPageNo);\n    }\n    return true;\n}\n\n#pragma mark - Content\nMaterial::Page::Page(uint32_t n, uint32_t h) : number(n), hash(h) {};\n\nMaterial::Page::~Page() = default;\n\nMaterial::Content::Content()\n: rootPage(UnknownPageNo), sequence(0), checked(false)\n{\n}\n\nMaterial::Content::~Content() = default;\n\n#pragma mark - Serialization\nbool Material::Content::serialize(Serialization &serialization) const\n{\n    if (!serialization.putSizedString(tableName) || !serialization.putVarint(rootPage)\n        || !serialization.putVarint(sequence) || !serialization.putSizedString(sql)) {\n        return false;\n    }\n\n    if (!serialization.putVarint(associatedSQLs.size())) {\n        return false;\n    }\n    for (const auto &associatedSQL : associatedSQLs) {\n        if (!serialization.putSizedString(associatedSQL)) {\n            return false;\n        }\n    }\n    VerifiedPages *pages = const_cast<VerifiedPages *>(&verifiedPagenos);\n    std::sort(pages->begin(), pages->end(), [](const Page &a, const Page &b) {\n        return a.number < b.number;\n    });\n    uint32_t prePageNo = 0;\n    for (int i = 0; i < verifiedPagenos.size(); i++) {\n        const auto &page = verifiedPagenos[i];\n        if (page.number == 0) {\n            WCTAssert(prePageNo == 0);\n            // Deleted pages\n            continue;\n        }\n        if (prePageNo == 0) {\n            if (!serialization.putVarint(verifiedPagenos.size() - i)) {\n                return false;\n            }\n            if (!serialization.putVarint(page.number)) {\n                return false;\n            }\n        } else {\n            WCTAssert(page.number > prePageNo);\n            if (!serialization.putVarint(page.number - prePageNo)) {\n                return false;\n            }\n        }\n        prePageNo = page.number;\n        if (!serialization.put4BytesUInt(page.hash)) {\n            return false;\n        }\n    }\n\n    // No leaf page\n    if (prePageNo == 0 && !serialization.putVarint(0)) {\n        return false;\n    }\n\n    return true;\n}\n\n#pragma mark - Deserialization\nbool Material::Content::deserialize(Deserialization &deserialization)\n{\n    size_t lengthOfSizedString;\n    StringView table;\n    std::tie(lengthOfSizedString, table) = deserialization.advanceSizedString();\n    if (lengthOfSizedString == 0 || table.empty()) {\n        markAsCorrupt(\"TableName\");\n        return false;\n    }\n    tableName = table;\n\n    if (deserialization.version() >= 0x01000001) {\n        size_t lengthOfPageNo;\n        uint64_t pageNo;\n        std::tie(lengthOfPageNo, pageNo) = deserialization.advanceVarint();\n        if (lengthOfPageNo == 0) {\n            markAsCorrupt(\"rootPage\");\n            return false;\n        }\n        rootPage = (uint32_t) pageNo;\n        WCTAssert(rootPage != UnknownPageNo);\n    }\n\n    size_t lengthOfVarint;\n    uint64_t varint;\n    std::tie(lengthOfVarint, varint) = deserialization.advanceVarint();\n    if (lengthOfVarint == 0) {\n        markAsCorrupt(\"Sequence\");\n        return false;\n    }\n    sequence = (int64_t) varint;\n\n    std::tie(lengthOfSizedString, sql) = deserialization.advanceSizedString();\n    if (lengthOfSizedString == 0 || sql.empty()) {\n        markAsCorrupt(\"SQL\");\n        return false;\n    }\n\n    std::tie(lengthOfVarint, varint) = deserialization.advanceVarint();\n    if (lengthOfVarint == 0) {\n        markAsCorrupt(\"SQLs\");\n        return false;\n    }\n    int numberOfAssociatedSQLs = (int) varint;\n    associatedSQLs.clear();\n    StringView buffer;\n    for (int i = 0; i < numberOfAssociatedSQLs; ++i) {\n        std::tie(lengthOfSizedString, buffer) = deserialization.advanceSizedString();\n        if (lengthOfSizedString == 0 || buffer.empty()) {\n            markAsCorrupt(\"SQLs\");\n            return false;\n        }\n        associatedSQLs.push_back(std::move(buffer));\n    }\n\n    std::tie(lengthOfVarint, varint) = deserialization.advanceVarint();\n    if (lengthOfVarint == 0) {\n        markAsCorrupt(\"NumberOfPages\");\n        return false;\n    }\n    int numberOfPages = (int) varint;\n    uint64_t prePageNo = 0;\n    verifiedPagenos.reserve(numberOfPages);\n    for (int i = 0; i < numberOfPages; ++i) {\n        std::tie(lengthOfVarint, varint) = deserialization.advanceVarint();\n        if (lengthOfVarint == 0) {\n            markAsCorrupt(\"Pageno\");\n            return false;\n        }\n        if (!deserialization.canAdvance(4)) {\n            markAsCorrupt(\"PageChecksum\");\n            return false;\n        }\n        uint32_t checksum = deserialization.advance4BytesUInt();\n        if (deserialization.version() >= 0x01000001) {\n            verifiedPagenos.emplace_back((uint32_t) (varint + prePageNo), checksum);\n            prePageNo += varint;\n        } else {\n            verifiedPagenos.emplace_back((uint32_t) varint, checksum);\n        }\n    }\n    return true;\n}\n\n} // namespace Repair\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/common/repair/mechanic/Material.hpp",
    "content": "//\n// Created by sanhuazhang on 2018/05/25\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"EncryptedSerialization.hpp\"\n#include \"StringView.hpp\"\n#include \"WCDBOptional.hpp\"\n#include <list>\n#include <map>\n#include <stdlib.h>\n#include <vector>\n\nnamespace WCDB {\n\nclass Data;\nclass Serialization;\nclass Deserialization;\n\nnamespace Repair {\n\nclass Material final : public EncryptedSerializable,\n                       public DecryptedDeserializable,\n                       public CipherDelegateHolder {\n#pragma mark - Serializable\npublic:\n    bool serialize(Serialization &serialization) const override final;\n    using Serializable::serialize;\n\n    ~Material() override;\n\nprotected:\n    static bool serializeData(Serialization &serialization, const Data &data);\n    static void markAsEmpty(const UnsafeStringView &element);\n\n#pragma mark - Deserializable\npublic:\n    bool deserialize(Deserialization &deserialization) override final;\n    using Deserializable::deserialize;\n\nprotected:\n    static Optional<Data> deserializeData(Deserialization &deserialization);\n    static void markAsCorrupt(const UnsafeStringView &element);\n    void decryptFail(const UnsafeStringView &element) const override final;\n    CipherDelegate *getCipherDelegate() const override;\n\n#pragma mark - Header\nprotected:\n    static constexpr const uint32_t magic = 0x57434442;\n    static constexpr const uint32_t version = 0x01000001; //1.0.0.1\n    static constexpr const uint8_t saltBytes = 16;\n    static constexpr const int headerSize = sizeof(magic) + sizeof(version); //magic + version\n\n#pragma mark - Info\npublic:\n    static constexpr const uint32_t UnknownPageNo = UINT32_MAX;\n\n    class Info final : public Serializable, public Deserializable {\n    public:\n        static constexpr const int size = sizeof(uint32_t) * 6;\n        Info();\n        ~Info() override;\n\n        uint32_t pageSize;\n        uint32_t reservedBytes;\n        std::pair<uint32_t, uint32_t> walSalt;\n        uint32_t nBackFill;\n        uint32_t seqTableRootPage;\n#pragma mark - Serializable\n    public:\n        bool serialize(Serialization &serialization) const override final;\n#pragma mark - Deserializable\n    public:\n        bool deserialize(Deserialization &deserialization) override final;\n    };\n\n    Info info;\n\n#pragma mark - Content\npublic:\n    typedef struct Page {\n    public:\n        uint32_t number;\n        uint32_t hash;\n        Page(uint32_t number, uint32_t hash);\n        ~Page();\n    } Page;\n    typedef std::vector<Page> VerifiedPages;\n    class Content final : public Serializable, public Deserializable {\n    public:\n        Content();\n        ~Content() override;\n\n        StringView tableName;\n        StringView sql;\n        std::list<StringView> associatedSQLs;\n        uint32_t rootPage;\n        int64_t sequence;\n        VerifiedPages verifiedPagenos;\n        bool checked; //It will not be saved to file\n#pragma mark - Serializable\n    public:\n        bool serialize(Serialization &serialization) const override final;\n#pragma mark - Deserializable\n    public:\n        bool deserialize(Deserialization &deserialization) override final;\n    };\n\n    std::list<Content> contentsList;\n    StringViewMap<Content *> contentsMap;\n};\n\n} //namespace Repair\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/common/repair/mechanic/Mechanic.cpp",
    "content": "//\n// Created by sanhuazhang on 2018/05/19\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"Mechanic.hpp\"\n#include \"Assertion.hpp\"\n#include \"CoreConst.h\"\n#include \"Notifier.hpp\"\n#include \"Page.hpp\"\n#include \"StringView.hpp\"\n\nnamespace WCDB {\n\nnamespace Repair {\n\n#pragma mark - Initialize\nMechanic::Mechanic(const UnsafeStringView &path)\n: Repairman(path), m_checksum(0), m_withoutRowId(false)\n{\n}\n\nMechanic::~Mechanic() = default;\n\n#pragma mark - Material\nvoid Mechanic::setMaterial(const Material *material)\n{\n    m_material = material;\n}\n\n#pragma mark - Mechanic\nbool Mechanic::work()\n{\n    WCTAssert(m_material != nullptr);\n\n    auto isEmpty = isEmptyDatabase();\n    if (isEmpty.succeed()) {\n        if (isEmpty.value()) {\n            return exit(true);\n        }\n    } else {\n        return exit(false);\n    }\n\n    m_pager.setWalImportance(false);\n    m_pager.setNBackFill(m_material->info.nBackFill);\n    m_pager.setWalSalt(m_material->info.walSalt);\n    m_pager.setPageSize(m_material->info.pageSize);\n    m_pager.setReservedBytes(m_material->info.reservedBytes);\n\n    WCTAssert(m_cipherDelegate != nullptr);\n    if (m_cipherDelegate->isCipherDB()) {\n        m_pager.setCipherContext(m_cipherDelegate->getCipherContext());\n    }\n\n    if (!m_pager.initialize()) {\n        //Actually, the initialization of pager always succeed if material is not corrupted.\n        if (m_pager.getError().isCorruption()) {\n            tryUpgradeCrawlerError();\n            return exit(true);\n        } else {\n            setCriticalError(m_pager.getError());\n            return exit(false);\n        }\n    }\n\n    m_pager.disposeWal();\n\n    int numberOfPages = 0;\n    for (const auto &element : m_material->contentsMap) {\n        numberOfPages += element.second->verifiedPagenos.size();\n    }\n    // If there are only without-rowid tables in the db, numberOfPages will be 0\n    setPageWeight(Fraction(\n    1, (numberOfPages == 0 ? 1 : numberOfPages) + m_pager.getDisposedWalPages()));\n\n    if (markAsAssembling()) {\n        for (const auto &contentElement : m_material->contentsMap) {\n            if (isErrorCritial()) {\n                break;\n            }\n            if (!assembleTable(contentElement.first, contentElement.second->sql)\n                || !assembleSequence(contentElement.first,\n                                     contentElement.second->sequence)) {\n                continue;\n            }\n\n            if (!m_assembleDelegate->isAssemblingTableWithoutRowid()) {\n                m_withoutRowId = false;\n                for (const auto &verifiedPagenosElement : contentElement.second->verifiedPagenos) {\n                    m_checksum = verifiedPagenosElement.hash;\n                    if (!crawl(verifiedPagenosElement.number)) {\n                        tryUpgradeCrawlerError();\n                        if (isErrorCritial()) {\n                            break;\n                        }\n                    }\n                }\n            } else if (contentElement.second->rootPage > 1) {\n                m_withoutRowId = true;\n                if (!crawl(contentElement.second->rootPage)) {\n                    tryUpgradeCrawlerError();\n                }\n            }\n            assembleAssociatedSQLs(contentElement.second->associatedSQLs);\n        }\n        markAsAssembled();\n    }\n    if (numberOfPages == 0 && !isErrorCritial() && getScore().value() == 0) {\n        increaseScore(1);\n        markSegmentedScoreCounted();\n    }\n    return exit();\n}\n\n#pragma mark - Crawlable\nvoid Mechanic::onCellCrawled(const Cell &cell)\n{\n    if (isErrorCritial()) {\n        return;\n    }\n    assembleCell(cell);\n}\n\nbool Mechanic::willCrawlPage(const Page &page, int)\n{\n    if (page.getType() == Page::Type::LeafTable) {\n        increaseProgress(getPageWeight().value());\n    }\n    if (isErrorCritial()) {\n        return false;\n    }\n    if (page.getType() == Page::Type::LeafTable && !m_withoutRowId) {\n        if (page.getData().hash() != m_checksum) {\n            markAsCorrupted(page.number,\n                            StringView::formatted(\n                            \"Mismatched hash: %u for %u.\", page.getData().hash(), m_checksum));\n            return false;\n        }\n        markPageAsCounted(page);\n    } else if (page.isIndexPage() && m_withoutRowId) {\n        markPageAsCounted(page);\n    } else {\n        markAsCorrupted(page.number,\n                        StringView::formatted(\n                        \"Unexpected page type: %d.\", page.getType(), page.getType()));\n        return false;\n    }\n    return true;\n}\n\n} //namespace Repair\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/common/repair/mechanic/Mechanic.hpp",
    "content": "//\n// Created by sanhuazhang on 2018/05/19\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"Assemble.hpp\"\n#include \"Crawlable.hpp\"\n#include \"Material.hpp\"\n#include \"Repairman.hpp\"\n\nnamespace WCDB {\n\nnamespace Repair {\n\nclass Material;\n\nclass Mechanic final : public Repairman {\n#pragma mark - Initialize\npublic:\n    Mechanic(const UnsafeStringView &path);\n    ~Mechanic() override;\n\n#pragma mark - Mechanic\npublic:\n    bool work();\n\n#pragma mark - Material\npublic:\n    void setMaterial(const Material *material);\n\nprotected:\n    const Material *m_material;\n    uint32_t m_checksum;\n    bool m_withoutRowId;\n\n#pragma mark - Crawlable\nprotected:\n    void onCellCrawled(const Cell &cell) override final;\n    bool willCrawlPage(const Page &page, int) override final;\n};\n\n} //namespace Repair\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/common/repair/parse/Cell.cpp",
    "content": "//\n// Created by sanhuazhang on 2018/05/19\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"Cell.hpp\"\n#include \"Assertion.hpp\"\n#include \"Page.hpp\"\n#include \"Pager.hpp\"\n#include \"Serialization.hpp\"\n#include \"StringView.hpp\"\n#include <cstring>\n#include <set>\n\nnamespace WCDB {\n\nnamespace Repair {\n\nCell::Cell(int pointer, Page *page, Pager *pager)\n: PagerRelated(pager), m_page(page), m_leftChild(0), m_rowid(0), m_pointer(pointer)\n{\n    WCTAssert(m_page != nullptr);\n}\n\nCell::~Cell() = default;\n\nconst Page &Cell::getPage() const\n{\n    return *m_page;\n}\n\nint Cell::getLengthOfSerialType(int serialType)\n{\n    WCTAssert(isSerialTypeSanity(serialType));\n    static int s_lengthsOfSerialType[10] = {\n        0, //Null\n        1, //8-bit integer\n        2, //16-bit integer\n        3, //24-bit integer\n        4, //32-bit integer\n        6, //48-bit integer\n        8, //64-bit integer\n        8, //IEEE 754-2008 64-bit floating point number\n        0, //0\n        0, //1\n    };\n    if (serialType <= 10) {\n        return s_lengthsOfSerialType[serialType];\n    }\n    return (serialType - 12 - serialType % 2) / 2;\n}\n\nint Cell::isSerialTypeSanity(int serialType)\n{\n    return serialType >= 0 && serialType != 10 && serialType != 11;\n}\n\nuint32_t Cell::getLeftChild() const\n{\n    WCTAssert(isInitialized());\n    WCTAssert(m_page->isInteriorPage());\n    return m_leftChild;\n}\n\nint64_t Cell::getRowID() const\n{\n    WCTAssert(isInitialized());\n    WCTAssert(m_page->isTablePage());\n    return m_rowid;\n}\n\nint Cell::getCount() const\n{\n    WCTAssert(isInitialized());\n    WCTAssert(m_page->getType() != Page::Type::InteriorTable);\n    return (int) m_columns.size();\n}\n\nCell::Type Cell::getValueType(int index) const\n{\n    WCTAssert(isInitialized());\n    WCTAssert(index < m_columns.size());\n    WCTAssert(m_page->getType() != Page::Type::InteriorTable);\n    int serialType = m_columns[index].first;\n    if (serialType == 0) {\n        return Type::Null;\n    } else if (serialType == 7) {\n        //IEEE 754-2008 64-bit floating point number\n        return Type::Real;\n    } else if (serialType <= 10) {\n        // 1. 8-bit integer\n        // 2. 16-bit integer\n        // 3. 24-bit integer\n        // 4. 32-bit integer\n        // 5. 48-bit integer\n        // 6. 64-bit integer\n        // 8. false\n        // 9. true\n        return Type::Integer;\n    } else {\n        return serialType % 2 ? Type::Text : Type::BLOB;\n    }\n}\n\nint64_t Cell::integerValue(int index) const\n{\n    WCTAssert(isInitialized());\n    WCTAssert(m_page->getType() != Page::Type::InteriorTable);\n    WCTAssert(index < m_columns.size());\n    WCTAssert(getValueType(index) == Type::Integer);\n    const auto &cell = m_columns[index];\n    int serialType = cell.first;\n    int64_t value = 0;\n    if (serialType == 8) {\n        return false;\n    } else if (serialType == 9) {\n        return true;\n    } else {\n        int length = getLengthOfSerialType(serialType);\n        WCTAssert(m_deserialization.isEnough(cell.second + length));\n        switch (length) {\n        case 1:\n            value = m_deserialization.get1ByteInt(cell.second);\n            break;\n        case 2:\n            value = m_deserialization.get2BytesInt(cell.second);\n            break;\n        case 3:\n            value = m_deserialization.get3BytesInt(cell.second);\n            break;\n        case 4:\n            value = m_deserialization.get4BytesInt(cell.second);\n            break;\n        case 6:\n            value = m_deserialization.get6BytesInt(cell.second);\n            break;\n        case 8:\n            value = m_deserialization.get8BytesInt(cell.second);\n            break;\n        default:\n            WCTAssert(false);\n            break;\n        }\n    }\n    return value;\n}\n\ndouble Cell::doubleValue(int index) const\n{\n    WCTAssert(isInitialized());\n    WCTAssert(m_page->getType() != Page::Type::InteriorTable);\n    WCTAssert(index < m_columns.size());\n    WCTAssert(getValueType(index) == Type::Real);\n    const auto &cell = m_columns[index];\n    WCTAssert(m_deserialization.isEnough(cell.second + 8));\n    return m_deserialization.get8BytesDouble(cell.second);\n}\n\nUnsafeStringView Cell::textValue(int index) const\n{\n    WCTAssert(isInitialized());\n    WCTAssert(m_page->getType() != Page::Type::InteriorTable);\n    WCTAssert(index < m_columns.size());\n    WCTAssert(getValueType(index) == Type::Text);\n    const auto &cell = m_columns[index];\n    return UnsafeStringView(\n    reinterpret_cast<const char *>(m_payload.buffer() + cell.second),\n    getLengthOfSerialType(cell.first));\n}\n\nStringView Cell::stringValue(int index) const\n{\n    WCTAssert(isInitialized());\n    WCTAssert(m_page->getType() != Page::Type::InteriorTable);\n    WCTAssert(index < m_columns.size());\n    WCTAssert(getValueType(index) == Type::Text);\n    const auto &cell = m_columns[index];\n    int length = getLengthOfSerialType(cell.first);\n    WCTAssert(m_deserialization.isEnough(cell.second + length));\n    return m_deserialization.getString(cell.second, length);\n}\n\nconst UnsafeData Cell::blobValue(int index) const\n{\n    WCTAssert(isInitialized());\n    WCTAssert(m_page->getType() != Page::Type::InteriorTable);\n    WCTAssert(index < m_columns.size());\n    WCTAssert(getValueType(index) == Type::BLOB);\n    const auto &cell = m_columns[index];\n    int size = getLengthOfSerialType(cell.first);\n    WCTAssert(m_deserialization.isEnough(cell.second + size));\n    return m_deserialization.getData(cell.second, size);\n}\n\n#pragma mark - Initializeable\nbool Cell::doInitialize()\n{\n    WCTAssert(m_page->getType() != Page::Type::InteriorTable);\n    Deserialization deserialization(m_page->getData());\n    int offsetOfPayload = m_pointer;\n    deserialization.seek(m_pointer);\n\n    //parse leftChild\n    if (!m_page->isLeafPage()) {\n        if (!deserialization.canAdvance(4)) {\n            markPagerAsCorrupted(m_page->number, \"Unable to deserialize left child.\");\n            return false;\n        }\n        m_leftChild = deserialization.advance4BytesInt();\n        offsetOfPayload += 4;\n    }\n\n    //parse payload size\n    int payloadSize = 0;\n    if (m_page->getType() != Page::Type::InteriorTable) {\n        int lengthOfPayloadSize;\n        std::tie(lengthOfPayloadSize, payloadSize) = deserialization.advanceVarint();\n        if (lengthOfPayloadSize == 0) {\n            markPagerAsCorrupted(m_page->number, \"Unable to deserialize PayloadSize.\");\n            return false;\n        }\n        offsetOfPayload += lengthOfPayloadSize;\n    }\n    //parse rowid\n    if (m_page->isTablePage()) {\n        int lengthOfRowid;\n        std::tie(lengthOfRowid, m_rowid) = deserialization.advanceVarint();\n        if (lengthOfRowid == 0) {\n            markPagerAsCorrupted(m_page->number, \"Unable to deserialize Rowid.\");\n            return false;\n        }\n        offsetOfPayload += lengthOfRowid;\n    }\n    if (m_page->getType() == Page::Type::InteriorTable) {\n        return true;\n    }\n    //parse local\n    int localPayloadSize = 0;\n    if (payloadSize < m_page->getMaxLocal()) {\n        localPayloadSize = payloadSize;\n    } else {\n        int k = m_page->getMinLocal()\n                + (payloadSize - m_page->getMinLocal()) % (m_pager->getUsableSize() - 4);\n        if (k <= m_page->getMaxLocal()) {\n            localPayloadSize = k;\n        } else {\n            localPayloadSize = m_page->getMinLocal();\n        }\n    }\n    if (!deserialization.canAdvance(localPayloadSize)) {\n        markPagerAsCorrupted(m_page->number, \"Unable to deserialize LocalPayloadSize.\");\n        return false;\n    }\n    //parse payload\n    if (localPayloadSize < payloadSize) {\n        //append overflow pages\n        deserialization.seek(offsetOfPayload + localPayloadSize);\n        if (!deserialization.canAdvance(4)) {\n            markPagerAsCorrupted(m_page->number, \"Unable to deserialize OverflowPageno.\");\n            return false;\n        }\n        int overflowPageno = deserialization.advance4BytesInt();\n        m_overflowedPayloadHolder = Data(payloadSize);\n        if (m_overflowedPayloadHolder.empty()) {\n            assignWithSharedThreadedError();\n            return false;\n        }\n        //fill payload with local data\n        memcpy(m_overflowedPayloadHolder.buffer(),\n               m_page->getData().buffer() + offsetOfPayload,\n               localPayloadSize);\n\n        int cursorOfPayload = localPayloadSize;\n        std::set<int> overflowPagenos;\n        while (overflowPageno > 0 && cursorOfPayload < payloadSize) {\n            if (overflowPagenos.find(overflowPageno) != overflowPagenos.end()) {\n                m_pager->markAsCorrupted(\n                m_page->number,\n                StringView::formatted(\"Overflow page: %d is redundant.\", overflowPageno));\n                return false;\n            }\n            if (overflowPageno > m_pager->getNumberOfPages()) {\n                m_pager->markAsCorrupted(\n                m_page->number,\n                StringView::formatted(\"Overflow page number: %d exceeds the page count: %d.\",\n                                      overflowPageno,\n                                      m_pager->getNumberOfPages()));\n                return false;\n            }\n            overflowPagenos.emplace(overflowPageno);\n            //fill payload with overflow data\n            UnsafeData overflow = m_pager->acquirePageData(overflowPageno);\n            if (overflow.empty()) {\n                return false;\n            }\n            int overflowSize\n            = std::min(payloadSize - cursorOfPayload, m_pager->getUsableSize() - 4);\n            WCTAssert(cursorOfPayload + overflowSize\n                      <= m_overflowedPayloadHolder.size());\n            memcpy(m_overflowedPayloadHolder.buffer() + cursorOfPayload,\n                   overflow.buffer() + 4,\n                   overflowSize);\n            cursorOfPayload += overflowSize;\n            //next overflow page\n            Deserialization overflowDeserialization(overflow);\n            WCTAssert(overflowDeserialization.canAdvance(4));\n            overflowPageno = overflowDeserialization.advance4BytesInt();\n        }\n        if (overflowPageno != 0 || cursorOfPayload != payloadSize) {\n            markPagerAsCorrupted(m_page->number, \"Unexpected termination of OverflowPage.\");\n            return false;\n        }\n        m_payload = m_overflowedPayloadHolder;\n    } else {\n        //non-overflow\n        m_nonOverflowedPayloadHolder\n        = m_page->getData().subdata(offsetOfPayload, localPayloadSize);\n        m_payload = m_nonOverflowedPayloadHolder;\n    }\n    m_deserialization.reset(m_payload);\n    //parse value offsets\n    int lengthOfOffsetOfValues, offsetOfValues;\n    std::tie(lengthOfOffsetOfValues, offsetOfValues) = m_deserialization.advanceVarint();\n    if (lengthOfOffsetOfValues == 0) {\n        markPagerAsCorrupted(m_page->number, \"Unable to deserialize CellValueOffset.\");\n        return false;\n    }\n\n    int cursorOfSerialTypes = lengthOfOffsetOfValues;\n    int cursorOfValues = offsetOfValues;\n    const int endOfValues = payloadSize;\n    const int endOfSerialTypes = offsetOfValues;\n\n    while (cursorOfSerialTypes < endOfSerialTypes) {\n        int lengthOfSerialType, serialType;\n        m_deserialization.seek(cursorOfSerialTypes);\n        std::tie(lengthOfSerialType, serialType) = m_deserialization.advanceVarint();\n        if (lengthOfSerialType == 0) {\n            markPagerAsCorrupted(m_page->number, \"Unable to deserialize SerialType.\");\n            return false;\n        }\n        if (!isSerialTypeSanity(serialType)) {\n            markPagerAsCorrupted(\n            m_page->number, StringView::formatted(\"Serial type: %d is illegal.\", serialType));\n            return false;\n        }\n        cursorOfSerialTypes += lengthOfSerialType;\n        m_columns.push_back({ serialType, cursorOfValues });\n        cursorOfValues += getLengthOfSerialType(serialType);\n        if (cursorOfValues > endOfValues) {\n            markPagerAsCorrupted(m_page->number, \"Unexpected termination of Payload.\");\n            return false;\n        }\n    }\n    if (cursorOfSerialTypes != endOfSerialTypes || cursorOfValues != endOfValues) {\n        markPagerAsCorrupted(m_page->number, \"Unexpected termination of Payload.\");\n        return false;\n    }\n    return true;\n}\n\n} //namespace Repair\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/common/repair/parse/Cell.hpp",
    "content": "//\n// Created by sanhuazhang on 2018/05/19\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"Initializeable.hpp\"\n#include \"MappedData.hpp\"\n#include \"PagerRelated.hpp\"\n#include \"Serialization.hpp\"\n\nnamespace WCDB {\n\nnamespace Repair {\n\nclass Page;\n\nclass Cell final : public PagerRelated, public Initializeable {\npublic:\n    Cell(int pointer, Page *page, Pager *pager);\n    ~Cell() override;\n\n    const Page &getPage() const;\n\n    enum Type {\n        Null = 0,\n        Integer = 1,\n        Real = 2,\n        Text = 3,\n        BLOB = 4,\n    };\n    uint32_t getLeftChild() const;\n    int64_t getRowID() const;\n    Type getValueType(int index) const;\n    int getCount() const;\n\n    int64_t integerValue(int index) const;\n    double doubleValue(int index) const;\n    UnsafeStringView textValue(int index) const;\n    StringView stringValue(int index) const;\n    const UnsafeData blobValue(int index) const;\n\nprotected:\n    static int getLengthOfSerialType(int serialType);\n    static int isSerialTypeSanity(int serialType);\n\n    Page *m_page;\n\n    uint32_t m_leftChild;\n    int64_t m_rowid;\n    int m_pointer;\n\n    Deserialization m_deserialization;\n    Data m_overflowedPayloadHolder;\n    Data m_nonOverflowedPayloadHolder;\n    Data m_payload;\n    //serial type -> offset of value\n    std::vector<std::pair<int, int>> m_columns;\n\n#pragma mark - Initializeable\nprotected:\n    bool doInitialize() override final;\n};\n\n} //namespace Repair\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/common/repair/parse/Frame.cpp",
    "content": "//\n// Created by sanhuazhang on 2018/06/08\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"Frame.hpp\"\n#include \"Assertion.hpp\"\n#include \"Serialization.hpp\"\n#include \"StringView.hpp\"\n#include \"Wal.hpp\"\n\nnamespace WCDB {\n\nnamespace Repair {\n\nFrame::Frame(int frameno_, Wal *wal) : WalRelated(wal), frameno(frameno_)\n{\n    WCTAssert(m_wal != nullptr);\n}\n\nFrame::~Frame() = default;\n\nint Frame::getPageNumber() const\n{\n    WCTAssert(isInitialized());\n    return m_pageno;\n}\n\nconst std::pair<uint32_t, uint32_t> &Frame::getChecksum() const\n{\n    WCTAssert(isInitialized());\n    return m_checksum;\n}\n\nOptional<Page::Type> Frame::getPageType() const\n{\n    WCTAssert(isInitialized());\n    MappedData pageData = m_data.subdata(headerSize, m_wal->getPageSize());\n    Page page = Page(getPageNumber(), m_pager, pageData);\n    return page.acquireType();\n}\n\nuint32_t Frame::getTruncate() const\n{\n    WCTAssert(isInitialized());\n    return m_truncate;\n}\n\nstd::pair<uint32_t, uint32_t>\nFrame::calculateChecksum(const std::pair<uint32_t, uint32_t> &source) const\n{\n    WCTAssert(isInitialized());\n    std::pair<uint32_t, uint32_t> checksum = source;\n    checksum = WalRelated::calculateChecksum(m_data.subdata(0, 8), checksum);\n    checksum = WalRelated::calculateChecksum(\n    m_data.subdata(headerSize, m_wal->getPageSize()), checksum);\n    return checksum;\n}\n\n#pragma mark - Initializeable\nbool Frame::doInitialize()\n{\n    if (m_data.empty()) {\n        m_data = m_wal->acquireFrameData(frameno);\n        if (m_data.empty()) {\n            return false;\n        }\n    }\n    Deserialization deserialization(m_data);\n\n    WCTAssert(deserialization.canAdvance(4));\n    m_pageno = (int) deserialization.advance4BytesUInt();\n\n    WCTAssert(deserialization.canAdvance(4));\n    m_truncate = deserialization.advance4BytesUInt();\n\n    std::pair<uint32_t, uint32_t> salt;\n    WCTAssert(deserialization.canAdvance(4));\n    salt.first = deserialization.advance4BytesUInt();\n    WCTAssert(deserialization.canAdvance(4));\n    salt.second = deserialization.advance4BytesUInt();\n    if (salt != m_wal->getSalt()) {\n        markWalAsCorrupted(frameno,\n                           StringView::formatted(\"Mismatched frame salt: %u, %u to %u, %u.\",\n                                                 salt.first,\n                                                 salt.second,\n                                                 m_wal->getSalt().first,\n                                                 m_wal->getSalt().second));\n        return false;\n    }\n\n    m_checksum.first = deserialization.advance4BytesUInt();\n    m_checksum.second = deserialization.advance4BytesUInt();\n    return true;\n}\n\n} //namespace Repair\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/common/repair/parse/Frame.hpp",
    "content": "//\n// Created by sanhuazhang on 2018/06/08\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"Initializeable.hpp\"\n#include \"Page.hpp\"\n#include \"WCDBOptional.hpp\"\n#include \"WalRelated.hpp\"\n#include <utility>\n\nnamespace WCDB {\n\nnamespace Repair {\n\nclass Wal;\n\nclass Frame final : public WalRelated, public Initializeable {\npublic:\n    Frame(int frameno, Wal *wal);\n    ~Frame() override;\n\n    static constexpr const int headerSize = 24;\n    const int frameno;\n\n    int getPageNumber() const;\n    Optional<Page::Type> getPageType() const;\n    const std::pair<uint32_t, uint32_t> &getChecksum() const;\n    std::pair<uint32_t, uint32_t>\n    calculateChecksum(const std::pair<uint32_t, uint32_t> &checksum) const;\n    uint32_t getTruncate() const;\n\nprotected:\n    std::pair<uint32_t, uint32_t> m_checksum;\n    int m_pageno;\n    uint32_t m_truncate;\n    MappedData m_data;\n\n#pragma mark - Initializeable\nprotected:\n    bool doInitialize() override final;\n};\n\n} //namespace Repair\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/common/repair/parse/Initializeable.cpp",
    "content": "//\n// Created by sanhuazhang on 2018/06/10\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"Initializeable.hpp\"\n\nnamespace WCDB {\n\nnamespace Repair {\n\nInitializeable::Initializeable() : m_state(State::None)\n{\n}\n\nInitializeable::~Initializeable() = default;\n\nbool Initializeable::isInitialized() const\n{\n    return m_state == State::Initialized;\n}\n\nbool Initializeable::isInitializing() const\n{\n    return m_state == State::Initializing;\n}\n\nbool Initializeable::isInitializeFalied() const\n{\n    return m_state == State::Failed;\n}\n\nbool Initializeable::initialize()\n{\n    if (m_state == State::None) {\n        m_state = State::Initializing;\n        m_state = doInitialize() ? State::Initialized : State::Failed;\n    }\n    return m_state == State::Initialized;\n}\n\n} //namespace Repair\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/common/repair/parse/Initializeable.hpp",
    "content": "//\n// Created by sanhuazhang on 2018/06/10\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\nnamespace WCDB {\n\nnamespace Repair {\n\nclass Initializeable {\npublic:\n    Initializeable();\n    virtual ~Initializeable() = 0;\n    bool initialize();\n    bool isInitialized() const;\n    bool isInitializing() const;\n    bool isInitializeFalied() const;\n\nprotected:\n    virtual bool doInitialize() = 0;\n\nprivate:\n    enum State {\n        Failed = -1,\n        None = 0,\n        Initializing = 1,\n        Initialized = 2,\n    };\n    State m_state;\n};\n\n} //namespace Repair\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/common/repair/parse/Page.cpp",
    "content": "//\n// Created by sanhuazhang on 2018/05/19\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"Page.hpp\"\n#include \"Assertion.hpp\"\n#include \"Cell.hpp\"\n#include \"Pager.hpp\"\n#include \"Serialization.hpp\"\n#include \"StringView.hpp\"\n\nnamespace WCDB {\n\nnamespace Repair {\n\n#pragma mark - Initialize\nPage::Page(int number_, Pager *pager)\n: PagerRelated(pager), number(number_), m_type(Type::UnSet)\n{\n}\n\nPage::Page(int number_, Pager *pager, const UnsafeData &data)\n: PagerRelated(pager), number(number_), m_type(Type::UnSet), m_deserialization(data), m_data(data)\n{\n}\n\nPage::~Page() = default;\n\nOptional<Page::Type> Page::acquireType()\n{\n    int type = 0;\n    if (m_deserialization.data().empty()) {\n        UnsafeData data = m_pager->acquirePageData(number, getOffsetOfHeader(), 1);\n        if (data.empty()) {\n            return NullOpt;\n        }\n        Deserialization deserialization(data);\n        WCTAssert(deserialization.canAdvance(1));\n        type = deserialization.advance1ByteInt();\n    } else {\n        WCTAssert(m_deserialization.isEnough(1));\n        m_deserialization.seek(getOffsetOfHeader());\n        type = m_deserialization.get1ByteInt(0);\n    }\n    return convertToPageType(type);\n}\n\nconst Data &Page::getData() const\n{\n    WCTAssert(isInitialized());\n    return m_data;\n}\n\nPage::Type Page::getType() const\n{\n    WCTAssert(isInitialized());\n    return m_type;\n}\n\nbool Page::isInteriorPage() const\n{\n    WCTAssert(m_type != Type::UnSet);\n    return m_type == Type::InteriorTable || m_type == Type::InteriorIndex;\n}\n\nbool Page::isLeafPage() const\n{\n    WCTAssert(m_type != Type::UnSet);\n    return m_type == Type::LeafTable || m_type == Type::LeafIndex;\n}\n\nbool Page::isTablePage() const\n{\n    WCTAssert(m_type != Type::UnSet);\n    return m_type == Type::InteriorTable || m_type == Type::LeafTable;\n}\n\nbool Page::isIndexPage() const\n{\n    WCTAssert(m_type != Type::UnSet);\n    return m_type == Type::InteriorIndex || m_type == Type::LeafIndex;\n}\n\nPage::Type Page::convertToPageType(int type)\n{\n    switch (type) {\n    case (int) Type::InteriorIndex:\n    case (int) Type::InteriorTable:\n    case (int) Type::LeafIndex:\n    case (int) Type::LeafTable:\n        return (Type) type;\n    default:\n        return Type::Unknown;\n    }\n}\n\n#pragma mark - Interior Table\nint Page::getSubpageno(int index) const\n{\n    WCTAssert(isInitialized());\n    WCTAssert(index < getNumberOfSubpages());\n    WCTAssert(isInteriorPage());\n    return m_subpagenos[index];\n}\n\nint Page::getNumberOfSubpages() const\n{\n    WCTAssert(isInitialized());\n    WCTAssert(isInteriorPage());\n    return (int) m_subpagenos.size();\n}\n\nint Page::getRightMostPage() const\n{\n    WCTAssert(isInitialized());\n    WCTAssert(isInteriorPage());\n    return m_subpagenos.back();\n}\n\n#pragma mark - Leaf Table\nCell Page::getCell(int index)\n{\n    WCTAssert(isInitialized());\n    WCTAssert(index < getNumberOfCells());\n    WCTAssert(m_type != Type::InteriorTable);\n    return Cell(m_cellPointers[index], this, m_pager);\n}\n\nint Page::getNumberOfCells() const\n{\n    WCTAssert(isInitialized());\n    WCTAssert(m_type != Type::InteriorTable);\n    return (int) m_cellPointers.size();\n}\n\nint Page::getMaxLocal() const\n{\n    WCTAssert(m_type != Type::InteriorTable);\n    if (m_type == Type::LeafTable) {\n        return m_pager->getUsableSize() - 35;\n    } else {\n        return (m_pager->getUsableSize() - 12) * 64 / 255 - 23;\n    }\n}\n\nint Page::getMinLocal() const\n{\n    WCTAssert(m_type != Type::InteriorTable);\n    return (m_pager->getUsableSize() - 12) * 32 / 255 - 23;\n}\n\n#pragma mark - Common\nint Page::getOffsetOfCellPointer() const\n{\n    WCTAssert(m_type != Type::Unknown);\n    return isInteriorPage() ? 12 : 8;\n}\n\nbool Page::hasRightMostPageNo() const\n{\n    WCTAssert(m_type != Type::Unknown);\n    return isInteriorPage();\n}\n\nint Page::getOffsetOfHeader() const\n{\n    return number == 1 ? 100 : 0;\n}\n\n#pragma mark - Initializeable\nbool Page::doInitialize()\n{\n    if (m_data.empty()) {\n        m_data = m_pager->acquirePageData(number);\n        if (m_data.empty()) {\n            return false;\n        }\n        m_deserialization.reset(m_data);\n    }\n    m_deserialization.seek(getOffsetOfHeader());\n    WCTAssert(m_deserialization.canAdvance(1));\n    int type = m_deserialization.advance1ByteInt();\n    m_type = convertToPageType(type);\n    if (m_type == Type::Unknown) {\n        return true;\n    }\n    WCTAssert(m_deserialization.canAdvance(4));\n    m_deserialization.advance(2);\n    int numberOfCells = m_deserialization.advance2BytesInt();\n    if (numberOfCells < 0) {\n        markPagerAsCorrupted(\n        number, StringView::formatted(\"Unexpected CellCount: %d.\", numberOfCells));\n        return false;\n    }\n    m_cellPointers.reserve(numberOfCells);\n    for (int i = 0; i < numberOfCells; ++i) {\n        int offset = getOffsetOfHeader() + getOffsetOfCellPointer() + i * 2;\n        if (!m_deserialization.isEnough(offset + 2)) {\n            markPagerAsCorrupted(number, \"Unable to deserialize CellPointer.\");\n            return false;\n        }\n        int cellPointer = m_deserialization.get2BytesInt(offset);\n        m_cellPointers.push_back(cellPointer);\n    }\n    if (m_type == Type::InteriorTable || m_type == Type::InteriorIndex) {\n        int numberOfSubpage = (int) m_cellPointers.size() + hasRightMostPageNo();\n        m_subpagenos.reserve(numberOfSubpage);\n        for (int i = 0; i < numberOfSubpage; ++i) {\n            int offset = i < m_cellPointers.size() || !hasRightMostPageNo() ?\n                         m_cellPointers[i] :\n                         8 + getOffsetOfHeader();\n            if (!m_deserialization.isEnough(offset + 4)) {\n                markPagerAsCorrupted(number, \"Unable to deserialize Subpageno.\");\n                return false;\n            }\n            int pageno = m_deserialization.get4BytesInt(offset);\n            if (pageno > m_pager->getNumberOfPages()) {\n                markPagerAsCorrupted(\n                number,\n                StringView::formatted(\"Page number: %d exceeds the page count: %d.\",\n                                      pageno,\n                                      m_pager->getNumberOfPages()));\n                return false;\n            }\n            if (pageno <= 0) {\n                markPagerAsCorrupted(\n                number, StringView::formatted(\"Pageno: %d is less than or equal to 0.\", pageno));\n                return false;\n            }\n            m_subpagenos.push_back(pageno);\n        }\n    }\n    return true;\n}\n\n} //namespace Repair\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/common/repair/parse/Page.hpp",
    "content": "//\n// Created by sanhuazhang on 2018/05/19\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"Initializeable.hpp\"\n#include \"MappedData.hpp\"\n#include \"PagerRelated.hpp\"\n#include \"Serialization.hpp\"\n#include \"WCDBOptional.hpp\"\n\nnamespace WCDB {\n\nnamespace Repair {\n\nclass Cell;\n\nclass Page final : public PagerRelated, public Initializeable {\n#pragma mark - Initialize\npublic:\n    Page(int number, Pager *pager);\n    Page(int number, Pager *pager, const UnsafeData &data);\n    ~Page() override;\n\n    const int number;\n\n    enum Type : char {\n        Unknown = 0,\n        InteriorIndex = 2,\n        InteriorTable = 5,\n        LeafIndex = 10,\n        LeafTable = 13,\n        UnSet = INT8_MAX,\n    };\n\n    static Type convertToPageType(int type);\n    Optional<Type> acquireType();\n    Type getType() const;\n    bool isInteriorPage() const;\n    bool isLeafPage() const;\n    bool isTablePage() const;\n    bool isIndexPage() const;\n\n    const Data &getData() const;\n\nprotected:\n    Type m_type;\n    Deserialization m_deserialization;\n    Data m_data;\n\n#pragma mark - Interior Table\npublic:\n    int getSubpageno(int index) const;\n    int getNumberOfSubpages() const;\n    int getRightMostPage() const;\n\nprotected:\n    std::vector<int> m_subpagenos;\n\n#pragma mark - Leaf Table\npublic:\n    Cell getCell(int index);\n    int getNumberOfCells() const;\n    int getMaxLocal() const;\n    int getMinLocal() const;\n\n#pragma mark - Common\nprotected:\n    int getOffsetOfHeader() const;\n    int getOffsetOfCellPointer() const;\n    bool hasRightMostPageNo() const;\n\n    std::vector<int> m_cellPointers;\n#pragma mark - Initializeable\nprotected:\n    bool doInitialize() override final;\n};\n\n} //namespace Repair\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/common/repair/parse/PageBasedFileHandle.cpp",
    "content": "//\n// Created by sanhuazhang on 2018/07/23\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"PageBasedFileHandle.hpp\"\n#include \"Assertion.hpp\"\n#include \"CoreConst.h\"\n#include \"Notifier.hpp\"\n#include \"WCDBError.hpp\"\n\nnamespace WCDB {\n\n#pragma mark - PageBasedFileHandle\nPageBasedFileHandle::PageBasedFileHandle(const UnsafeStringView& path)\n: FileHandle(path), m_pageSize(0), m_cache(maxAllowedCacheMemory), m_cachePageSize(0)\n{\n    static_assert(maxAllowedCacheMemory % cacheMemoryPerRange == 0, \"\");\n    static_assert((maxAllowedCacheMemory & maxAllowedCacheMemory - 1) == 0, \"\");\n    static_assert((cacheMemoryPerRange & cacheMemoryPerRange - 1) == 0, \"\");\n}\n\nPageBasedFileHandle::~PageBasedFileHandle() = default;\n\nRange PageBasedFileHandle::restrictedRange(Range::Location base,\n                                           Range::Length maxLength,\n                                           const Range& restrictor)\n{\n    Range result;\n    result.length = std::min(maxLength, restrictor.length);\n    result.location = base - Range::Location(result.length / 2);\n    if (result.location < restrictor.location) {\n        result.shiftToLocation(restrictor.location);\n    } else if (result.edge() > restrictor.edge()) {\n        result.shiftToEdge(restrictor.edge());\n    }\n    return result;\n}\n\nMappedData PageBasedFileHandle::mapPage(int pageno,\n                                        offset_t offsetWithinPage,\n                                        size_t sizeWithinPage,\n                                        SharedHighWater highWater)\n{\n    WCTAssert(m_cachePageSize > 0);\n    WCTAssert(pageno > 0);\n    WCTAssert(offsetWithinPage < m_pageSize);\n    WCTAssert(sizeWithinPage <= m_pageSize && sizeWithinPage > 0);\n    WCTAssert(m_cachePageSize >= m_pageSize);\n\n    offset_t offset = (pageno - 1) * m_pageSize + offsetWithinPage;\n    offset_t cachePageno = offset / m_cachePageSize;\n\n    // assert same cache page\n    WCTAssert(cachePageno == (offset + sizeWithinPage - 1) / m_cachePageSize);\n\n    Range gap;\n    const MappedData* cachedData;\n    std::tie(gap, cachedData) = m_cache.find(cachePageno);\n    if (cachedData != nullptr) {\n        WCTAssert(gap.contains(cachePageno));\n        offset_t offsetWithinCache = offset - gap.location * m_cachePageSize;\n        WCTAssert(offsetWithinCache < gap.length * m_cachePageSize);\n        return cachedData->subdata(offsetWithinCache, sizeWithinPage);\n    }\n\n    Range::Length maxLength = cachePagePerRange();\n    do {\n        Range range = restrictedRange(cachePageno, maxLength, gap);\n\n        WCTAssert(gap.contains(range));\n        WCTAssert(range.contains(cachePageno));\n\n        bool cuttable = range.length > 1;\n        bool purgeable = !m_cache.empty();\n        bool ignorable = cuttable || purgeable;\n\n        markErrorAsIgnorable(ignorable);\n        MappedData mappedData\n        = map(range.location * m_cachePageSize, range.length * m_cachePageSize, highWater);\n        markErrorAsIgnorable(false);\n\n        if (!mappedData.empty()) {\n            m_cache.insert(range, mappedData);\n            offset_t offsetWithinCache = offset - range.location * m_cachePageSize;\n            WCTAssert(offsetWithinCache < range.length * m_cachePageSize);\n            return mappedData.subdata(offsetWithinCache, sizeWithinPage);\n        } else if (cuttable) {\n            maxLength = (range.length + 1) / 2;\n            WCTAssert(maxLength >= 1);\n        } else if (purgeable) {\n            m_cache.purge();\n            std::tie(gap, cachedData) = m_cache.find(cachePageno);\n            maxLength = cachePagePerRange();\n            WCTAssert(cachedData == nullptr);\n        } else {\n            break;\n        }\n    } while (true);\n    return MappedData::null();\n}\n\n#pragma mark - PageSize\nMappedData PageBasedFileHandle::mapPage(int pageno, SharedHighWater highWater)\n{\n    WCTAssert(pageno > 0);\n    return mapPage(pageno, 0, m_pageSize, highWater);\n}\n\nsize_t PageBasedFileHandle::cachePagePerRange() const\n{\n    WCTAssert(m_cachePageSize != 0);\n    return cacheMemoryPerRange / m_cachePageSize;\n}\n\nvoid PageBasedFileHandle::setPageSize(size_t pageSize)\n{\n    WCTAssert(m_cachePageSize == 0);\n    m_pageSize = pageSize;\n    m_cachePageSize = pageSize;\n    size_t alignment = m_cachePageSize % memoryPageSize();\n    if (alignment > 0) {\n        m_cachePageSize = m_cachePageSize - alignment + memoryPageSize();\n    }\n    WCTAssert(m_cachePageSize > 0 && m_cachePageSize % memoryPageSize() == 0);\n    m_cachePageSize = std::max(memoryPageSize(), m_cachePageSize);\n    WCTAssert(m_cachePageSize > 0 && cacheMemoryPerRange % m_cachePageSize == 0);\n\n    size_t fileSize = FileHandle::size();\n    Range::Length restrictCachePageno\n    = fileSize / m_cachePageSize + (fileSize % m_cachePageSize > 0);\n    m_cache.setRange(Range(0, restrictCachePageno));\n}\n\n#pragma mark - Cache\nvoid PageBasedFileHandle::purgeAll()\n{\n    m_cache.purge(m_cache.size());\n}\n\nbool PageBasedFileHandle::purgeOne()\n{\n    if (m_cache.empty()) {\n        return false;\n    }\n    m_cache.purge();\n    return true;\n}\n\nPageBasedFileHandle::Cache::Cache(size_t maxAllowedMemory)\n: LRUCache<WCDB::Range, WCDB::MappedData>()\n, m_range(Range::notFound())\n, m_maxAllowedMemory(maxAllowedMemory)\n, m_currentUsedMemery(0)\n{\n}\n\nPageBasedFileHandle::Cache::~Cache() = default;\n\nvoid PageBasedFileHandle::Cache::setRange(const WCDB::Range& range)\n{\n    WCTAssert(range != Range::notFound());\n    m_range = range;\n}\n\nstd::pair<Range, const MappedData*> PageBasedFileHandle::Cache::find(Location location)\n{\n    WCTAssert(m_range != Range::notFound());\n    WCTAssert(m_range.contains(location));\n\n    Range range;\n    const MappedData* data = nullptr;\n\n    // assume: a < b < c < d < e < f < g\n    // { [b, c), [e, f) }\n    // findIterator(a) = [b, c), find(a) = [min, b)\n    // findIterator(b) = [b, c), find(b) = [b, c)\n    // findIterator(c) = [e, f), find(c) = [c, e)\n    // findIterator(d) = [e, f), find(d) = [c, e)\n    // findIterator(e) = [e, f), find(e) = [e, f)\n    // findIterator(f) = end(), find(f) = [f, max)\n    // findIterator(g) = end(), find(g) = [f, max)\n    auto match = findIterator(location);\n    if (match != m_map.end()) {\n        if (match->first.contains(location)) {\n            retain(match);\n            range = match->first;\n            data = &(match->second->second);\n        } else {\n            if (match != m_map.begin()) {\n                auto previous = match;\n                --previous;\n                range.location = previous->first.edge();\n            } else {\n                range.location = m_range.location;\n            }\n            range.expandToEdge(match->first.location);\n        }\n    } else {\n        if (!m_map.empty()) {\n            auto last = m_map.end();\n            --last;\n            range.location = last->first.edge();\n        } else {\n            range.location = m_range.location;\n        }\n        range.expandToEdge(m_range.edge());\n    }\n    return std::make_pair(range, data);\n}\n\nvoid PageBasedFileHandle::Cache::insert(const Range& range, const MappedData& data)\n{\n    WCTAssert(range.length > 0);\n    WCTAssert(m_range.contains(range));\n    WCTAssert(find(range.location).second == nullptr);\n    WCTAssert(find(range.edge() - 1).second == nullptr);\n    m_currentUsedMemery += data.size();\n    put(range, data);\n}\n\nbool PageBasedFileHandle::Cache::shouldPurge() const\n{\n    return m_currentUsedMemery > m_maxAllowedMemory;\n}\n\nvoid PageBasedFileHandle::Cache::willPurge(const Range& range, const MappedData& data)\n{\n    WCDB_UNUSED(range);\n    m_currentUsedMemery -= data.size();\n}\n\nPageBasedFileHandle::Cache::MapIterator\nPageBasedFileHandle::Cache::findIterator(Location location)\n{\n    return std::find_if(m_map.begin(), m_map.end(), [&location](const auto& iter) -> bool {\n        const Range& range = iter.first;\n        return location < range.edge();\n    });\n}\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/repair/parse/PageBasedFileHandle.hpp",
    "content": "//\n// Created by sanhuazhang on 2018/07/23\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"FileHandle.hpp\"\n#include \"LRUCache.hpp\"\n#include \"MappedData.hpp\"\n#include \"Range.hpp\"\n\nnamespace WCDB {\n\nclass PageBasedFileHandle final : public FileHandle {\n#pragma mark - PageBasedFileHandle\npublic:\n    PageBasedFileHandle(const UnsafeStringView& path);\n    ~PageBasedFileHandle() override;\n\n    MappedData\n    mapPage(int pageno, offset_t offset, size_t size, SharedHighWater highWater = nullptr);\n    MappedData mapPage(int pageno, SharedHighWater highWater = nullptr);\n\nprotected:\n    static Range\n    restrictedRange(Range::Location base, Range::Length maxLength, const Range& restrictor);\n\n#pragma mark - PageSize\npublic:\n    void setPageSize(size_t pageSize);\n    size_t cachePagePerRange() const;\n\nprotected:\n    size_t m_pageSize;\n\n#pragma mark - Cache\npublic:\n    void purgeAll();\n    bool purgeOne();\n\nprotected:\n    static constexpr const size_t cacheMemoryPerRange = 1 * 1024 * 1024;\n    static constexpr const size_t maxAllowedCacheMemory = 16 * 1024 * 1024;\n\n    class Cache final : protected LRUCache<Range, MappedData> {\n    public:\n        Cache(size_t maxAllowedMemory);\n        ~Cache() override;\n\n        using Super = LRUCache<Range, MappedData>;\n        using Location = Range::Location;\n        using Length = Range::Length;\n        using Super::purge;\n        using Super::size;\n        using Super::empty;\n\n        void setRange(const Range& range);\n        std::pair<Range, const MappedData*> find(Location location);\n        void insert(const Range& range, const MappedData& data);\n\n    protected:\n        MapIterator findIterator(Location location);\n        Range m_range;\n\n        bool shouldPurge() const override final;\n        void willPurge(const Range& range, const MappedData& data) override final;\n        size_t m_maxAllowedMemory;\n        size_t m_currentUsedMemery;\n    };\n\n    Cache m_cache;\n    size_t m_cachePageSize;\n};\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/repair/parse/Pager.cpp",
    "content": "//\n// Created by sanhuazhang on 2018/05/19\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"Pager.hpp\"\n#include \"Assertion.hpp\"\n#include \"CoreConst.h\"\n#include \"FileManager.hpp\"\n#include \"Notifier.hpp\"\n#include \"SQLite.h\"\n#include \"Serialization.hpp\"\n#include \"StringView.hpp\"\n#include \"ThreadedErrors.hpp\"\n#include <cstring>\n\nnamespace WCDB {\n\nnamespace Repair {\n\n#pragma mark - Initialize\nPager::Pager(const UnsafeStringView& path)\n: m_fileHandle(path)\n, m_pCodec(nullptr)\n, m_pageSize(-1)\n, m_reservedBytes(-1)\n, m_numberOfPages(0)\n, m_fileSize(0)\n, m_schemaCookie(-1)\n, m_wal(this)\n, m_walImportance(true)\n, m_skipWal(false)\n, m_cache(maxAllowedCacheMemory)\n, m_highWater(std::make_shared<ShareableHighWater>())\n{\n}\n\nPager::~Pager() = default;\n\nvoid Pager::setPageSize(int pageSize)\n{\n    WCTAssert(!isInitialized());\n    m_pageSize = pageSize;\n}\n\nvoid Pager::setReservedBytes(int reservedBytes)\n{\n    WCTAssert(!isInitialized());\n    m_reservedBytes = reservedBytes;\n}\n\nvoid Pager::setCipherContext(void* ctx)\n{\n    WCTAssert(ctx != nullptr);\n    m_pCodec = ctx;\n}\n\nconst StringView& Pager::getPath() const\n{\n    return m_fileHandle.path;\n}\n\n#pragma mark - Page\nint Pager::getNumberOfPages() const\n{\n    WCTAssert(isInitialized());\n    return std::max(m_wal.getMaxPageno(), m_numberOfPages);\n}\n\nint Pager::getUsableSize() const\n{\n    WCTAssert(isInitialized() || isInitializing());\n    return m_pageSize - m_reservedBytes;\n}\n\nint Pager::getPageSize() const\n{\n    WCTAssert(isInitialized() || isInitializing());\n    return m_pageSize;\n}\n\nint Pager::getReservedBytes() const\n{\n    WCTAssert(isInitialized());\n    return m_reservedBytes;\n}\n\nint Pager::getSchemaCookie() const\n{\n    WCTAssert(isInitialized());\n    return m_schemaCookie;\n}\n\nUnsafeData Pager::acquirePageData(int number)\n{\n    return acquirePageData(number, 0, m_pageSize);\n}\n\nUnsafeData Pager::acquirePageData(int number, offset_t offset, size_t size)\n{\n    WCTAssert(isInitialized());\n    WCTAssert(number > 0);\n    WCTAssert(offset + size <= m_pageSize);\n    if (m_cache.exists(number)) {\n        return m_cache.get(number).subdata(offset, size);\n    }\n    UnsafeData data;\n    if (m_wal.containsPage(number)) {\n        data = m_wal.acquirePageData(number, m_highWater);\n    } else {\n        if (number > m_numberOfPages) {\n            markAsCorrupted(\n            number,\n            StringView::formatted(\n            \"Acquired page number: %d exceeds the page count: %d.\", number, m_numberOfPages));\n            return MappedData::null();\n        }\n        data = m_fileHandle.mapPage(number, m_highWater);\n    }\n    if (data.size() != m_pageSize) {\n        if (data.size() > 0) {\n            //short read\n            markAsCorrupted(number,\n                            StringView::formatted(\"Acquired page data with size: %d is less than the expected size: %d.\",\n                                                  data.size(),\n                                                  size));\n        } else {\n            assignWithSharedThreadedError();\n        }\n        return MappedData::null();\n    }\n    if (m_pCodec) {\n        void* decodedBuffer = sqlite3Codec(m_pCodec, data.buffer(), number, 4);\n        if (decodedBuffer == nullptr) {\n            markAsCorrupted(number, \"Decode page data fail!\");\n            return MappedData::null();\n        }\n        data = Data(reinterpret_cast<unsigned char*>(decodedBuffer), m_pageSize, m_highWater);\n    }\n    m_cache.insert(number, data);\n    tryPurgeCache();\n    return data.subdata(offset, size);\n}\n\nUnsafeData Pager::acquireHeader()\n{\n    WCTAssert(m_fileHandle.isOpened());\n    WCTAssert(m_pCodec == nullptr || m_pageSize > 0);\n    UnsafeData data;\n    if (m_pCodec == nullptr) {\n        data = m_fileHandle.map(0, 100);\n        if (data.size() != 100) {\n            assignWithSharedThreadedError();\n        }\n    } else {\n        data = m_fileHandle.map(0, m_pageSize);\n        if (data.size() == m_pageSize) {\n            void* decodedBuffer = sqlite3Codec(m_pCodec, data.buffer(), 1, 4);\n            if (decodedBuffer == nullptr) {\n                markAsCorrupted(1, \"Decode page data fail!\");\n                return MappedData::null();\n            }\n            data\n            = Data(reinterpret_cast<unsigned char*>(decodedBuffer), m_pageSize).subdata(0, 100);\n        } else {\n            assignWithSharedThreadedError();\n        }\n    }\n    if (data.size() != 100) {\n        return MappedData::null();\n    }\n    return data;\n}\n\n#pragma mark - Wal\nvoid Pager::setWalImportance(bool flag)\n{\n    m_walImportance = flag;\n    m_wal.setShmLegality(flag);\n}\n\nint Pager::getNBackFill() const\n{\n    return m_wal.getNBackFill();\n}\n\nvoid Pager::setNBackFill(int nbackfill)\n{\n    m_wal.setNBackFill(nbackfill);\n}\n\nconst Pager::Salt& Pager::getWalSalt() const\n{\n    return m_wal.getSalt();\n}\n\nvoid Pager::setWalSalt(const Salt& salt)\n{\n    return m_wal.setSalt(salt);\n}\n\nint Pager::getMaxFrame() const\n{\n    return m_wal.getMaxFrame();\n}\n\nint Pager::getDisposedWalPages() const\n{\n    return m_wal.getDisposedPages();\n}\n\nvoid Pager::disposeWal()\n{\n    m_wal.dispose();\n}\n\nvoid Pager::setWalSkipped()\n{\n    m_skipWal = true;\n}\n\nbool Pager::loadWal()\n{\n    return m_wal.initialize();\n}\n\nint Pager::getNumberOfWalFrames() const\n{\n    return m_wal.getNumberOfFrames();\n}\n\nbool Pager::containPageInWal(uint32_t pageno)\n{\n    return m_wal.containsPage(pageno);\n}\n\n#pragma mark - Error\nvoid Pager::markAsCorrupted(int page, const UnsafeStringView& message)\n{\n    Error error(Error::Code::Corrupt, Error::Level::Notice, message);\n    error.infos.insert_or_assign(ErrorStringKeySource, ErrorSourceRepair);\n    error.infos.insert_or_assign(ErrorStringKeyAssociatePath, getPath());\n    error.infos.insert_or_assign(\"Page\", page);\n    Notifier::shared().notify(error);\n    setError(std::move(error));\n}\n\nvoid Pager::markAsError(Error::Code code)\n{\n    Error error(code, Error::Level::Notice);\n    error.infos.insert_or_assign(ErrorStringKeySource, ErrorSourceRepair);\n    error.infos.insert_or_assign(ErrorStringKeyAssociatePath, getPath());\n    Notifier::shared().notify(error);\n    setError(std::move(error));\n}\n\n#pragma mark - Initializeable\nbool Pager::doInitialize()\n{\n    auto fileSize = FileManager::getFileSize(getPath());\n    if (!fileSize.succeed()) {\n        assignWithSharedThreadedError();\n        return false;\n    }\n    m_fileSize = fileSize.value();\n    if (m_fileSize == 0) {\n        markAsError(Error::Code::Empty);\n        return false;\n    }\n\n    if (!m_fileHandle.open(FileHandle::Mode::ReadOnly)) {\n        assignWithSharedThreadedError();\n        return false;\n    }\n    FileManager::setFileProtectionCompleteUntilFirstUserAuthenticationIfNeeded(getPath());\n    if (m_pageSize == -1 || m_reservedBytes == -1) {\n        UnsafeData data = acquireHeader();\n        if (data.empty()) {\n            return false;\n        }\n        if (memcmp(data.buffer(), \"SQLite format 3\\000\", 16) != 0) {\n            markAsError(Error::Code::NotADatabase);\n            return false;\n        }\n        Deserialization deserialization(data);\n        //parse page size\n        if (m_pageSize == -1) {\n            deserialization.seek(16);\n            WCTAssert(deserialization.canAdvance(2));\n            m_pageSize = deserialization.advance2BytesInt();\n        }\n        //parse reserved bytes\n        if (m_reservedBytes == -1) {\n            deserialization.seek(20);\n            WCTAssert(deserialization.canAdvance(1));\n            m_reservedBytes = deserialization.advance1ByteInt();\n        }\n        //parse schema cookie\n        if (m_schemaCookie == -1) {\n            deserialization.seek(40);\n            WCTAssert(deserialization.canAdvance(4));\n            m_schemaCookie = deserialization.advance4BytesInt();\n        }\n    }\n    if (((m_pageSize - 1) & m_pageSize) != 0 || m_pageSize < 512 || m_pageSize > 65536) {\n        markAsCorrupted(\n        1, StringView::formatted(\"Page size: %d is not aligned or not too small.\", m_pageSize));\n        return false;\n    }\n    if (m_reservedBytes < 0 || m_reservedBytes > 255) {\n        markAsCorrupted(\n        1, StringView::formatted(\"Reversed bytes: %d is illegal.\", m_reservedBytes));\n        return false;\n    }\n\n    m_fileHandle.setPageSize(m_pageSize);\n\n    m_numberOfPages = (int) ((m_fileSize + m_pageSize - 1) / m_pageSize);\n\n    if (m_skipWal) {\n        return true;\n    }\n\n    if (m_wal.initialize()) {\n        return true;\n    }\n    if (m_walImportance || !m_error.isCorruption()) {\n        return false;\n    }\n    disposeWal();\n    return true;\n}\n\nvoid Pager::tryPurgeCache()\n{\n    ssize_t allowedSize = maxAllowedCacheMemory * 2;\n    if (m_pCodec) {\n        allowedSize *= 2;\n    }\n    if (m_highWater->getCurrent() <= allowedSize) {\n        return;\n    }\n    if (m_pCodec != nullptr) {\n        m_fileHandle.purgeAll();\n        while (!m_cache.empty() && m_highWater->getCurrent() > allowedSize) {\n            m_cache.purge();\n        }\n    } else {\n        m_cache.purge(m_cache.size());\n        while (m_highWater->getCurrent() > allowedSize && m_fileHandle.purgeOne());\n    }\n}\n\nPager::Cache::Cache(size_t maxAllowedMemory)\n: LRUCache<uint32_t, UnsafeData>()\n, m_maxAllowedMemory(maxAllowedMemory)\n, m_currentUsedMemery(0)\n{\n}\n\nPager::Cache::~Cache() = default;\n\nvoid Pager::Cache::insert(uint32_t pageNum, const UnsafeData& data)\n{\n    WCTAssert(!exists(pageNum));\n    m_currentUsedMemery += data.size();\n    put(pageNum, data);\n}\n\nbool Pager::Cache::shouldPurge() const\n{\n    return m_currentUsedMemery > m_maxAllowedMemory;\n}\n\nvoid Pager::Cache::willPurge(const uint32_t& pageNum, const UnsafeData& data)\n{\n    WCDB_UNUSED(pageNum);\n    m_currentUsedMemery -= data.size();\n}\n\n} //namespace Repair\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/common/repair/parse/Pager.hpp",
    "content": "//\n// Created by sanhuazhang on 2018/05/19\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"ErrorProne.hpp\"\n#include \"HighWater.hpp\"\n#include \"Initializeable.hpp\"\n#include \"PageBasedFileHandle.hpp\"\n#include \"WCDBError.hpp\"\n#include \"Wal.hpp\"\n\nnamespace WCDB {\n\nclass Data;\n\nnamespace Repair {\n\nclass Pager final : public ErrorProne, public Initializeable {\n#pragma mark - Initialize\npublic:\n    Pager(const UnsafeStringView& path);\n    ~Pager() override;\n\n    void setPageSize(int pageSize);\n    void setReservedBytes(int reservedBytes);\n    void setCipherContext(void* ctx);\n\n    const StringView& getPath() const;\n\nprotected:\n    PageBasedFileHandle m_fileHandle;\n    void* m_pCodec;\n    friend class PagerRelated;\n\n#pragma mark - Page\npublic:\n    int getNumberOfPages() const;\n    UnsafeData acquirePageData(int number);\n    UnsafeData acquirePageData(int number, offset_t offset, size_t size);\n\n    int getUsableSize() const;\n    int getPageSize() const;\n    int getReservedBytes() const;\n    int getSchemaCookie() const;\n\nprotected:\n    UnsafeData acquireHeader();\n    int m_pageSize;\n    int m_reservedBytes;\n    int m_numberOfPages;\n    size_t m_fileSize;\n    int m_schemaCookie;\n\n#pragma mark - Wal\npublic:\n    void setWalImportance(bool flag);\n    int getNumberOfWalFrames() const;\n\n    void setNBackFill(int nbackfill);\n    int getNBackFill() const;\n\n    typedef Wal::Salt Salt;\n    const Salt& getWalSalt() const;\n    void setWalSalt(const Salt& salt);\n\n    int getMaxFrame() const;\n    int getDisposedWalPages() const;\n    void disposeWal();\n\n    void setWalSkipped();\n    bool loadWal();\n    bool containPageInWal(uint32_t pageno);\n\nprotected:\n    Wal m_wal;\n    bool m_walImportance;\n    bool m_skipWal;\n\n#pragma mark - Error\npublic:\n    void markAsCorrupted(int page, const UnsafeStringView& message);\n\n    void markAsError(Error::Code code);\n\n#pragma mark - Initializeable\nprotected:\n    bool doInitialize() override final;\n\n#pragma mark - Cache\nprotected:\n    static constexpr const size_t maxAllowedCacheMemory = 16 * 1024 * 1024;\n    class Cache final : public LRUCache<uint32_t, UnsafeData> {\n    public:\n        Cache(size_t maxAllowedMemory);\n        ~Cache() override;\n\n        void insert(uint32_t pageNum, const UnsafeData& data);\n\n    protected:\n        bool shouldPurge() const override final;\n        void willPurge(const uint32_t& pageNum, const UnsafeData& data) override final;\n        size_t m_maxAllowedMemory;\n        size_t m_currentUsedMemery;\n    };\n    void tryPurgeCache();\n    Cache m_cache;\n    SharedHighWater m_highWater;\n};\n\n} //namespace Repair\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/common/repair/parse/PagerRelated.cpp",
    "content": "//\n// Created by sanhuazhang on 2018/06/08\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"PagerRelated.hpp\"\n#include \"Assertion.hpp\"\n#include \"Pager.hpp\"\n\nnamespace WCDB {\n\nnamespace Repair {\n\nPagerRelated::~PagerRelated() = default;\n\nPagerRelated::PagerRelated(Pager *pager) : m_pager(pager)\n{\n    WCTAssert(m_pager != nullptr);\n}\n\nPagerRelated::PagerRelated(const PagerRelated &other) : m_pager(other.m_pager)\n{\n}\n\nPagerRelated::PagerRelated(PagerRelated &&other) : m_pager(other.m_pager)\n{\n}\n\nPagerRelated &PagerRelated::operator=(PagerRelated &&other)\n{\n    m_pager = other.m_pager;\n    return *this;\n}\n\nconst StringView &PagerRelated::getPagerPath() const\n{\n    return m_pager->getPath();\n}\n\nvoid PagerRelated::setError(Error &&error)\n{\n    m_pager->setError(std::move(error));\n}\n\nvoid PagerRelated::assignWithSharedThreadedError()\n{\n    m_pager->assignWithSharedThreadedError();\n}\n\nvoid PagerRelated::markPagerAsCorrupted(int page, const UnsafeStringView &message)\n{\n    m_pager->markAsCorrupted(page, message);\n}\n\n} //namespace Repair\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/common/repair/parse/PagerRelated.hpp",
    "content": "//\n// Created by sanhuazhang on 2018/06/08\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"WCDBError.hpp\"\n\nnamespace WCDB {\n\nnamespace Repair {\n\nclass Pager;\n\nclass PagerRelated {\npublic:\n    PagerRelated(Pager *pager);\n    PagerRelated(const PagerRelated &);\n    PagerRelated(PagerRelated &&);\n    virtual ~PagerRelated() = 0;\n    PagerRelated &operator=(PagerRelated &&);\n\n    const StringView &getPagerPath() const;\n\nprotected:\n    void markPagerAsCorrupted(int page, const UnsafeStringView &message);\n    void setError(Error &&error);\n    void assignWithSharedThreadedError();\n\n    Pager *m_pager;\n};\n\n} //namespace Repair\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/common/repair/parse/Shm.cpp",
    "content": "//\n// Created by sanhuazhang on 2018/08/06\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"Shm.hpp\"\n#include \"Assertion.hpp\"\n#include \"CoreConst.h\"\n#include \"FileManager.hpp\"\n#include \"Notifier.hpp\"\n#include \"Path.hpp\"\n#include \"Serialization.hpp\"\n#include \"StringView.hpp\"\n#include \"Wal.hpp\"\n#include <cstring>\n\nnamespace WCDB {\n\nnamespace Repair {\n\nShm::Shm(Wal *wal)\n: WalRelated(wal), m_fileHandle(Path::addExtention(getPagerPath(), \"-shm\"))\n{\n    static_assert(sizeof(Header) == 48, \"\");\n    static_assert(sizeof(CheckpointInfo) == 40, \"\");\n    memset(&m_checkpointInfo, 0, sizeof(m_checkpointInfo));\n}\n\nShm::~Shm() = default;\n\nconst StringView &Shm::getPath() const\n{\n    return m_fileHandle.path;\n}\n\nuint32_t Shm::getMaxFrame() const\n{\n    WCTAssert(isInitialized());\n    return m_header.maxFrame;\n}\n\nuint32_t Shm::getBackfill() const\n{\n    WCTAssert(isInitialized());\n    return m_checkpointInfo.backfill;\n}\n\nShm::Salt Shm::getSalt() const\n{\n    Salt salt;\n    const unsigned char *p = (const unsigned char *) &(m_header.___salt[0]);\n    salt.first = (((uint32_t) p[0] << 24) | (p[1] << 16) | (p[2] << 8) | p[3]);\n    p = (const unsigned char *) &(m_header.___salt[1]);\n    salt.second = (((uint32_t) p[0] << 24) | (p[1] << 16) | (p[2] << 8) | p[3]);\n    return salt;\n}\n\nvoid Shm::markAsCorrupted(const UnsafeStringView &message)\n{\n    Error error(Error::Code::Corrupt, Error::Level::Notice, message);\n    error.infos.insert_or_assign(ErrorStringKeySource, ErrorSourceRepair);\n    error.infos.insert_or_assign(ErrorStringKeyAssociatePath, getPagerPath());\n    Notifier::shared().notify(error);\n    setError(std::move(error));\n}\n\nbool Shm::doInitialize()\n{\n    WCTAssert(m_wal->isInitialized() || m_wal->isInitializing());\n\n    auto optionalFileSize = FileManager::getFileSize(getPath());\n    if (!optionalFileSize.succeed()) {\n        assignWithSharedThreadedError();\n        return false;\n    }\n    size_t fileSize = optionalFileSize.value();\n    if (fileSize == 0) {\n        return true;\n    }\n\n    if (!m_fileHandle.open(FileHandle::Mode::ReadOnly)) {\n        assignWithSharedThreadedError();\n        return false;\n    }\n    FileManager::setFileProtectionCompleteUntilFirstUserAuthenticationIfNeeded(getPath());\n\n    if (fileSize < sizeof(Header)) {\n        markAsCorrupted(StringView::formatted(\n        \"File size: %lu is not enough for header.\", fileSize));\n        return false;\n    }\n\n    constexpr const int size = sizeof(Header) * 2 + sizeof(CheckpointInfo);\n    MappedData data = m_fileHandle.map(0, size);\n    if (data.size() != size) {\n        if (data.size() > 0) {\n            markAsCorrupted(StringView::formatted(\"Acquired shm data with size: %d is less than the expected size: %d.\",\n                                                  data.size(),\n                                                  size));\n        } else {\n            assignWithSharedThreadedError();\n        }\n        return false;\n    }\n\n    memcpy(&m_header, data.buffer(), sizeof(Header));\n    if (m_header.version != 3007000) {\n        markAsCorrupted(\n        StringView::formatted(\"Shm version: %u is illegal.\", m_header.version));\n        return false;\n    }\n    memcpy(&m_checkpointInfo, data.buffer() + sizeof(Header) * 2, sizeof(CheckpointInfo));\n    return true;\n}\n\nShm::Header::Header()\n: version(3007000), maxFrame(std::numeric_limits<decltype(maxFrame)>::max())\n{\n}\n\n} // namespace Repair\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/repair/parse/Shm.hpp",
    "content": "//\n// Created by sanhuazhang on 2018/08/06\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"FileHandle.hpp\"\n#include \"Initializeable.hpp\"\n#include \"WalRelated.hpp\"\n\nnamespace WCDB {\n\nnamespace Repair {\n\nclass Shm final : public WalRelated, public Initializeable {\npublic:\n    Shm(Wal *wal);\n    ~Shm() override;\n\n    const StringView &getPath() const;\n\nprotected:\n    bool doInitialize() override final;\n    void markAsCorrupted(const UnsafeStringView &message);\n    FileHandle m_fileHandle;\n\npublic:\n    uint32_t getMaxFrame() const;\n    uint32_t getBackfill() const;\n    typedef std::pair<uint32_t, uint32_t> Salt;\n    Salt getSalt() const;\n\nprotected:\n    struct Header {\n        Header();\n        uint32_t version;\n        uint32_t ___unused;\n        uint32_t ___change;\n        uint8_t ___isInit;\n        uint8_t ___bigEndChecksum;\n        uint16_t ___pageSize;\n        uint32_t maxFrame;\n        uint32_t ___page;\n        uint32_t ___frameChecksum[2];\n        uint32_t ___salt[2];\n        uint32_t ___checksum[2];\n    };\n    typedef struct Header Header;\n\n    struct CheckpointInfo {\n        uint32_t backfill;\n        uint32_t ___readMark[5];\n        uint8_t ___lock[8];\n        uint32_t ___backfillAttempted;\n        uint32_t ___unused;\n    };\n    typedef struct CheckpointInfo CheckpointInfo;\n\n    Header m_header;\n    CheckpointInfo m_checkpointInfo;\n};\n\n} // namespace Repair\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/repair/parse/Wal.cpp",
    "content": "//\n// Created by sanhuazhang on 2018/06/08\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"Wal.hpp\"\n#include \"Assertion.hpp\"\n#include \"CoreConst.h\"\n#include \"FileManager.hpp\"\n#include \"Frame.hpp\"\n#include \"Notifier.hpp\"\n#include \"Pager.hpp\"\n#include \"Path.hpp\"\n#include \"SQLite.h\"\n#include \"Serialization.hpp\"\n#include \"StringView.hpp\"\n\nnamespace WCDB {\n\nnamespace Repair {\n\n#pragma mark - Initialize\nWal::Wal(Pager *pager)\n: PagerRelated(pager)\n, m_fileHandle(Path::addExtention(m_pager->getPath(), \"-wal\"))\n, m_fileSize(0)\n, m_truncate(std::numeric_limits<uint32_t>::max())\n, m_maxFrame(0)\n, m_isNativeChecksum(false)\n, m_salt({ 0, 0 })\n, m_shmLegality(true)\n, m_shm(this)\n{\n}\n\nWal::~Wal() = default;\n\nconst StringView &Wal::getPath() const\n{\n    return m_fileHandle.path;\n}\n\nMappedData Wal::acquireData(offset_t offset, size_t size, SharedHighWater highWater)\n{\n    WCTAssert(m_fileHandle.isOpened());\n    MappedData data = m_fileHandle.map(offset, size, highWater);\n    if (data.size() != size) {\n        if (data.size() > 0) {\n            markAsCorrupted((int) ((offset - headerSize) / getFrameSize() + 1),\n                            StringView::formatted(\"Acquired wal data with size: %d is less than the expected size: %d.\",\n                                                  data.size(),\n                                                  size));\n        } else {\n            assignWithSharedThreadedError();\n        }\n        return MappedData::null();\n    }\n    return data;\n}\n\n#pragma mark - Page\nbool Wal::containsPage(int pageno) const\n{\n    return m_pages2Frames.find(pageno) != m_pages2Frames.end();\n}\n\nMappedData Wal::acquirePageData(int pageno, SharedHighWater highWater)\n{\n    return acquirePageData(pageno, 0, getPageSize(), highWater);\n}\n\nMappedData Wal::acquirePageData(int pageno, offset_t offset, size_t size, SharedHighWater highWater)\n{\n    WCTAssert(isInitialized());\n    WCTAssert(containsPage(pageno));\n    WCTAssert(offset + size <= getPageSize());\n    return acquireData(headerSize + getFrameSize() * (m_pages2Frames[pageno] - 1)\n                       + Frame::headerSize + offset,\n                       size,\n                       highWater);\n}\n\nint Wal::getMaxPageno() const\n{\n    if (m_pages2Frames.empty()) {\n        return 0;\n    }\n    return m_pages2Frames.rbegin()->first;\n}\n\n#pragma mark - Wal\nbool Wal::isCheckpointIncreasedSalt(const Salt &before, const Salt &after)\n{\n    return before.first + 1 == after.first && before.second != after.second;\n}\n\nvoid Wal::setShmLegality(bool flag)\n{\n    WCTAssert(!isInitialized());\n    m_shmLegality = flag;\n}\n\nMappedData Wal::acquireFrameData(int frameno)\n{\n    WCTAssert(isInitializing());\n    return acquireData(headerSize + getFrameSize() * (frameno - 1), getFrameSize());\n}\n\nint Wal::getNBackFill() const\n{\n    WCTAssert(isInitialized());\n    return m_shm.getBackfill();\n}\n\nvoid Wal::setNBackFill(int nbackfill)\n{\n    WCTAssert(!isInitialized());\n    m_nbackfill = nbackfill;\n}\n\nint Wal::getMaxFrame() const\n{\n    return m_maxFrame;\n}\n\nint Wal::getNumberOfFrames() const\n{\n    return (int) m_pages2Frames.size();\n}\n\nint Wal::getPageSize() const\n{\n    return m_pager->getPageSize();\n}\n\nint Wal::getFrameSize() const\n{\n    return Frame::headerSize + getPageSize();\n}\n\nconst std::pair<uint32_t, uint32_t> &Wal::getSalt() const\n{\n    return m_salt;\n}\n\nvoid Wal::setSalt(const std::pair<uint32_t, uint32_t> &salt)\n{\n    WCTAssert(!isInitialized());\n    m_salt = salt;\n}\n\nbool Wal::isBigEndian()\n{\n    static bool s_isBigEndian = []() -> bool {\n        short int n = 0x1;\n        char *p = (char *) &n;\n        return p[0] != 1;\n    }();\n    return s_isBigEndian;\n}\n\nstd::pair<uint32_t, uint32_t>\nWal::calculateChecksum(const MappedData &data, const std::pair<uint32_t, uint32_t> &checksum) const\n{\n    WCTAssert(data.size() >= 8);\n    WCTAssert((data.size() & 0x00000007) == 0);\n\n    const uint32_t *iter = reinterpret_cast<const uint32_t *>(data.buffer());\n    const uint32_t *end\n    = reinterpret_cast<const uint32_t *>(data.buffer() + data.size());\n\n    std::pair<uint32_t, uint32_t> result = checksum;\n\n    if (m_isNativeChecksum) {\n        do {\n            result.first += *iter++ + result.second;\n            result.second += *iter++ + result.first;\n        } while (iter < end);\n    } else {\n        do {\n#define BYTESWAP32(x)                                                          \\\n    ((((x) & 0x000000FF) << 24) + (((x) & 0x0000FF00) << 8)                    \\\n     + (((x) & 0x00FF0000) >> 8) + (((x) & 0xFF000000) >> 24))\n            result.first += BYTESWAP32(iter[0]) + result.second;\n            result.second += BYTESWAP32(iter[1]) + result.first;\n            iter += 2;\n        } while (iter < end);\n    }\n\n    return result;\n}\n\nbool Wal::doInitialize()\n{\n    WCTAssert(m_pager->isInitialized() || m_pager->isInitializing());\n\n    int maxWalFrame = std::numeric_limits<int>::max();\n    if (m_shmLegality) {\n        if (!m_shm.initialize()) {\n            return false;\n        }\n        WCTAssert(m_nbackfill == 0 || (m_salt == Salt{ 0, 0 })\n                  || (m_nbackfill == m_shm.getBackfill() && m_salt == m_shm.getSalt())\n                  || (m_shm.getBackfill() == 0\n                      && isCheckpointIncreasedSalt(m_salt, m_shm.getSalt())));\n        m_nbackfill = m_shm.getBackfill();\n        m_salt = m_shm.getSalt();\n        maxWalFrame = m_shm.getMaxFrame();\n    }\n\n    auto fileSize = FileManager::getFileSize(getPath());\n    if (!fileSize.succeed()) {\n        assignWithSharedThreadedError();\n        return false;\n    }\n    m_fileSize = fileSize.value();\n    if (m_fileSize == 0) {\n        return true;\n    }\n\n    if (!m_fileHandle.open(FileHandle::Mode::ReadOnly)) {\n        assignWithSharedThreadedError();\n        return false;\n    }\n    FileManager::setFileProtectionCompleteUntilFirstUserAuthenticationIfNeeded(getPath());\n\n    MappedData data = acquireData(0, headerSize);\n    if (data.empty()) {\n        return false;\n    }\n    Deserialization deserialization(data);\n    uint32_t magic = deserialization.advance4BytesUInt();\n    if ((magic & 0xFFFFFFFE) != 0x377F0682) {\n        // ignore wal\n        markAsCorrupted(0, StringView::formatted(\"Incorrect wal magic: 0x%x.\", magic));\n        return false;\n    }\n    m_isNativeChecksum = (magic & 0x00000001) == isBigEndian();\n    deserialization.seek(16);\n    std::pair<uint32_t, uint32_t> salt = { 0, 0 };\n    WCTAssert(deserialization.canAdvance(4));\n    salt.first = deserialization.advance4BytesUInt();\n    WCTAssert(deserialization.canAdvance(4));\n    salt.second = deserialization.advance4BytesUInt();\n\n    if (m_salt != Salt{ 0, 0 } && m_salt != salt\n        && !(isCheckpointIncreasedSalt(m_salt, salt) && m_nbackfill > 0)) {\n        m_nbackfill = 0;\n        maxWalFrame = std::numeric_limits<int>::max();\n    }\n    m_salt = salt;\n\n    const int numberOfFramesInFile = ((int) m_fileSize - headerSize) / getFrameSize();\n    maxWalFrame = std::min(numberOfFramesInFile, maxWalFrame);\n\n    if (m_nbackfill >= maxWalFrame) {\n        // dispose all wal frames since they are already checkpointed.\n        return true;\n    }\n\n    std::pair<uint32_t, uint32_t> checksum = { 0, 0 };\n    checksum = calculateChecksum(data.subdata(headerSize - 2 * sizeof(uint32_t)), checksum);\n\n    std::pair<uint32_t, uint32_t> deserializedChecksum;\n    WCTAssert(deserialization.canAdvance(4));\n    deserializedChecksum.first = deserialization.advance4BytesUInt();\n    WCTAssert(deserialization.canAdvance(4));\n    deserializedChecksum.second = deserialization.advance4BytesUInt();\n\n    if (checksum != deserializedChecksum) {\n        markAsCorrupted(0,\n                        StringView::formatted(\"Mismatched wal checksum: %u, %u to %u, %u.\",\n                                              checksum.first,\n                                              checksum.second,\n                                              deserializedChecksum.first,\n                                              deserializedChecksum.second));\n        return false;\n    }\n\n    if (m_nbackfill > 0) {\n        Frame frame(m_nbackfill, this);\n        if (!frame.initialize()) {\n            dispose();\n            return false;\n        }\n        checksum = frame.getChecksum();\n    }\n\n    std::map<int, int> committedRecords;\n    for (int frameno = m_nbackfill + 1; frameno <= maxWalFrame; ++frameno) {\n        Frame frame(frameno, this);\n        if (!frame.initialize()) {\n            dispose();\n            return false;\n        }\n        checksum = frame.calculateChecksum(checksum);\n        if (checksum != frame.getChecksum()) {\n            if (m_shmLegality) {\n                //If the frame checksum is mismatched and shm is legal, it mean to be corrupted.\n                markAsCorrupted(frameno,\n                                StringView::formatted(\"Mismatched frame checksum: %u, %u to %u, %u.\",\n                                                      frame.getChecksum().first,\n                                                      frame.getChecksum().second,\n                                                      checksum.first,\n                                                      checksum.second));\n                return false;\n            } else {\n                //If the frame checksum is mismatched and shm is not legal, it mean to be disposed.\n                break;\n            }\n        }\n        checksum = frame.getChecksum();\n        committedRecords[frame.getPageNumber()] = frameno;\n        if (frame.getTruncate() != 0) {\n            m_truncate = frame.getTruncate();\n            m_maxFrame = frameno;\n            for (const auto &element : committedRecords) {\n                m_pages2Frames[element.first] = element.second;\n            }\n            committedRecords.clear();\n        }\n    }\n    if (!committedRecords.empty()) {\n        for (const auto &iter : committedRecords) {\n            m_disposedPages.emplace(iter.first);\n        }\n    }\n    // all those frames that are uncommitted or exceeds the max allowed count will be disposed.\n    return true;\n}\n\n#pragma mark - Error\nvoid Wal::markAsCorrupted(int frame, const UnsafeStringView &message)\n{\n    Error error(Error::Code::Corrupt, Error::Level::Notice, message);\n    error.infos.insert_or_assign(ErrorStringKeySource, ErrorSourceRepair);\n    error.infos.insert_or_assign(ErrorStringKeyAssociatePath, getPagerPath());\n    error.infos.insert_or_assign(\"Frame\", frame);\n    Notifier::shared().notify(error);\n    setError(std::move(error));\n}\n\n#pragma mark - Dispose\nint Wal::getDisposedPages() const\n{\n    return (int) m_disposedPages.size();\n}\n\nvoid Wal::dispose()\n{\n    for (const auto &element : m_pages2Frames) {\n        m_disposedPages.emplace(element.first);\n    }\n    m_pages2Frames.clear();\n    m_truncate = std::numeric_limits<uint32_t>::max();\n    m_fileSize = 0;\n    m_maxFrame = 0;\n    m_salt = { 0, 0 };\n}\n\n} //namespace Repair\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/common/repair/parse/Wal.hpp",
    "content": "//\n// Created by sanhuazhang on 2018/06/08\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"FileHandle.hpp\"\n#include \"Initializeable.hpp\"\n#include \"PagerRelated.hpp\"\n#include \"Shm.hpp\"\n#include <map>\n#include <set>\n\nnamespace WCDB {\n\nnamespace Repair {\n\nclass Wal final : public PagerRelated, public Initializeable {\n#pragma mark - Initialize\npublic:\n    Wal(Pager *pager);\n    ~Wal() override;\n\n    const StringView &getPath() const;\n    static constexpr const int headerSize = 32;\n\nprotected:\n    FileHandle m_fileHandle;\n    friend class WalRelated;\n    MappedData\n    acquireData(offset_t offset, size_t size, SharedHighWater highWater = nullptr);\n\n#pragma mark - Page\npublic:\n    bool containsPage(int pageno) const;\n    MappedData acquirePageData(int pageno, SharedHighWater highWater = nullptr);\n    MappedData\n    acquirePageData(int pageno, offset_t offset, size_t size, SharedHighWater highWater = nullptr);\n    int getMaxPageno() const;\n\nprotected:\n    // pageno -> frameno\n    std::map<int, int> m_pages2Frames;\n\n#pragma mark - Wal\npublic:\n    typedef Shm::Salt Salt;\n    static bool isCheckpointIncreasedSalt(const Salt &before, const Salt &after);\n\n    void setShmLegality(bool flag);\n    int getNBackFill() const;\n    void setNBackFill(int nbackfill);\n    int getNumberOfFrames() const;\n    const Salt &getSalt() const;\n    void setSalt(const Salt &salt);\n    int getMaxFrame() const;\n    int getPageSize() const;\n\nprotected:\n    std::pair<uint32_t, uint32_t>\n    calculateChecksum(const MappedData &data,\n                      const std::pair<uint32_t, uint32_t> &checksum) const;\n\n    size_t m_fileSize;\n    uint32_t m_truncate;\n    int m_nbackfill;\n    int m_maxFrame;\n    bool m_isNativeChecksum;\n    Salt m_salt;\n    bool m_shmLegality;\n    Shm m_shm;\n\n#pragma mark - Frame\npublic:\n    int getFrameSize() const;\n    MappedData acquireFrameData(int frameno);\n\n#pragma mark - Initializeable\nprotected:\n    bool doInitialize() override final;\n    static bool isBigEndian();\n\n#pragma mark - Error\nprotected:\n    void markAsCorrupted(int frame, const UnsafeStringView &message);\n    //    void markAsError(Error::Code code);\n\n#pragma mark - Dispose\npublic:\n    int getDisposedPages() const;\n    void dispose();\n\nprotected:\n    std::set<int> m_disposedPages;\n};\n\n} //namespace Repair\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/common/repair/parse/WalRelated.cpp",
    "content": "//\n// Created by sanhuazhang on 2018/06/15\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"WalRelated.hpp\"\n#include \"Assertion.hpp\"\n#include \"Pager.hpp\"\n\nnamespace WCDB {\n\nnamespace Repair {\n\nWalRelated::~WalRelated() = default;\n\nWalRelated::WalRelated(Wal *wal) : m_wal(wal), m_pager(m_wal->m_pager)\n{\n    WCTAssert(m_wal != nullptr);\n}\n\nWalRelated::WalRelated(WalRelated &&other) : m_wal(other.m_wal)\n{\n}\n\nWalRelated &WalRelated::operator=(WalRelated &&other)\n{\n    m_wal = other.m_wal;\n    return *this;\n}\n\nconst StringView &WalRelated::getWalPath() const\n{\n    return m_wal->getPath();\n}\n\nconst StringView &WalRelated::getPagerPath() const\n{\n    return m_pager->getPath();\n}\n\nvoid WalRelated::setError(Error &&error)\n{\n    m_wal->setError(std::move(error));\n}\n\nvoid WalRelated::assignWithSharedThreadedError()\n{\n    m_wal->assignWithSharedThreadedError();\n}\n\nvoid WalRelated::markWalAsCorrupted(int frame, const UnsafeStringView &message)\n{\n    m_wal->markAsCorrupted(frame, message);\n}\n\nstd::pair<uint32_t, uint32_t>\nWalRelated::calculateChecksum(const MappedData &data,\n                              const std::pair<uint32_t, uint32_t> &checksum) const\n{\n    return m_wal->calculateChecksum(data, checksum);\n}\n\n} //namespace Repair\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/common/repair/parse/WalRelated.hpp",
    "content": "//\n// Created by sanhuazhang on 2018/06/15\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"MappedData.hpp\"\n#include \"WCDBError.hpp\"\n\nnamespace WCDB {\n\nnamespace Repair {\n\nclass Wal;\nclass Pager;\n\nclass WalRelated {\npublic:\n    WalRelated(Wal *wal);\n    WalRelated(WalRelated &&);\n    virtual ~WalRelated() = 0;\n    WalRelated &operator=(WalRelated &&);\n\n    const StringView &getWalPath() const;\n    const StringView &getPagerPath() const;\n\nprotected:\n    void markWalAsCorrupted(int frame, const UnsafeStringView &message);\n    void setError(Error &&error);\n    void assignWithSharedThreadedError();\n    std::pair<uint32_t, uint32_t>\n    calculateChecksum(const MappedData &data,\n                      const std::pair<uint32_t, uint32_t> &checksum) const;\n\n    Wal *m_wal;\n    Pager *m_pager;\n};\n\n} //namespace Repair\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/common/repair/sqlite/SQLiteAssembler.cpp",
    "content": "//\n// Created by sanhuazhang on 2018/05/19\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#if WCDB_USE_BUILTIN_SQLITE_REPAIR\n\n#include \"SQLiteAssembler.hpp\"\n#include \"Assertion.hpp\"\n#include \"Cell.hpp\"\n#include \"SQLite.h\"\n#include \"StringView.hpp\"\n#include <sstream>\n\nnamespace WCDB {\n\nnamespace Repair {\n\n#pragma mark - Initialize\nSQLiteAssembler::SQLiteAssembler() : m_cellSTMT(nullptr), m_primary(-1)\n{\n}\n\nSQLiteAssembler::~SQLiteAssembler() = default;\n\n#pragma mark - Assemble\nvoid SQLiteAssembler::setPath(const UnsafeStringView &path)\n{\n    SQLiteBase::setPath(path);\n}\n\nconst StringView &SQLiteAssembler::getPath() const\n{\n    return SQLiteBase::getPath();\n}\n\nbool SQLiteAssembler::markAsAssembling()\n{\n    if (!open()) {\n        return false;\n    }\n    if (!markSequenceAsAssembling()) {\n        close();\n        return false;\n    }\n    return true;\n}\n\nbool SQLiteAssembler::markAsAssembled()\n{\n    m_table.clear();\n    finalize(&m_cellSTMT);\n    bool result = markSequenceAsAssembled();\n    result = lazyCommitOrRollbackTransaction() && result;\n    close();\n    return result;\n}\n\nbool SQLiteAssembler::markAsMilestone()\n{\n    return lazyCommitOrRollbackTransaction() && lazyBeginTransactionImmediate();\n}\n\nbool SQLiteAssembler::assembleTable(const UnsafeStringView &tableName,\n                                    const UnsafeStringView &sql)\n{\n    finalize(&m_cellSTMT);\n    m_table.clear();\n    markErrorAsIgnorable(SQLITE_ERROR);\n    bool succeed = execute(sql.c_str());\n    markErrorAsUnignorable();\n    if (succeed) {\n        m_table = tableName;\n        return true;\n    }\n    return false;\n}\n\nbool SQLiteAssembler::assembleCell(const Cell &cell)\n{\n    if (!lazyPrepareCell()) {\n        return false;\n    }\n    sqlite3_bind_int64((sqlite3_stmt *) m_cellSTMT, 1, cell.getRowID());\n    for (int i = 0; i < cell.getCount(); ++i) {\n        int bindIndex = i + 2;\n        switch (cell.getValueType(i)) {\n        case Cell::Integer:\n            sqlite3_bind_int64(\n            (sqlite3_stmt *) m_cellSTMT, bindIndex, cell.integerValue(i));\n            break;\n        case Cell::Text: {\n            sqlite3_bind_text(\n            (sqlite3_stmt *) m_cellSTMT, bindIndex, cell.textValue(i).cstring(), -1, SQLITE_TRANSIENT);\n            break;\n        }\n        case Cell::BLOB: {\n            const UnsafeData data = cell.blobValue(i);\n            sqlite3_bind_blob(\n            (sqlite3_stmt *) m_cellSTMT, bindIndex, data.buffer(), (int) data.size(), SQLITE_TRANSIENT);\n            break;\n        }\n        case Cell::Real:\n            sqlite3_bind_double(\n            (sqlite3_stmt *) m_cellSTMT, bindIndex, cell.doubleValue(i));\n            break;\n        case Cell::Null:\n            if (i == m_primary) {\n                sqlite3_bind_int64((sqlite3_stmt *) m_cellSTMT, bindIndex, cell.getRowID());\n            } else {\n                sqlite3_bind_null((sqlite3_stmt *) m_cellSTMT, bindIndex);\n            }\n            break;\n        }\n    }\n    bool result = step(m_cellSTMT);\n    sqlite3_reset((sqlite3_stmt *) m_cellSTMT);\n    return result;\n}\n\nbool SQLiteAssembler::assembleSQL(const UnsafeStringView &sql)\n{\n    markErrorAsIgnorable(SQLITE_ERROR);\n    bool succeed = execute(sql.c_str());\n    markErrorAsUnignorable();\n    return succeed;\n}\n\nconst Error &SQLiteAssembler::getError() const\n{\n    return ErrorProne::getError();\n}\n\n#pragma mark - Cell\nbool SQLiteAssembler::lazyPrepareCell()\n{\n    WCTAssert(!m_table.empty());\n    if (m_cellSTMT == nullptr) {\n        bool succeed;\n        StringView sql;\n        std::tie(succeed, sql) = getAssembleSQL(m_table);\n        if (!succeed) {\n            return false;\n        }\n        m_cellSTMT = prepare(sql.c_str());\n    }\n    return m_cellSTMT != nullptr;\n}\n\nOptional<StringView> SQLiteAssembler::getAssembleSQL(const UnsafeStringView &tableName)\n{\n    bool succeed;\n    std::list<StringView> columnNames;\n    std::tie(succeed, columnNames) = getColumnNames(tableName);\n    if (!succeed) {\n        return { false, StringView() };\n    }\n\n    std::ostringstream firstHalfStream;\n    std::ostringstream lastHalfStream;\n    if (isDuplicatedIgnorable()) {\n        firstHalfStream << \"INSERT OR IGNORE INTO \";\n    } else {\n        firstHalfStream << \"INSERT INTO \";\n    }\n    firstHalfStream << tableName << \"(rowid\";\n    lastHalfStream << \") VALUES(?\";\n    for (const auto &columnName : columnNames) {\n        firstHalfStream << \", \" << columnName;\n        lastHalfStream << \", ?\";\n    }\n    lastHalfStream << \")\";\n\n    return { true, firstHalfStream.str() + lastHalfStream.str() };\n}\n\nOptional<std::list<StringView>>\nSQLiteAssembler::getColumnNames(const UnsafeStringView &tableName)\n{\n    std::ostringstream stream;\n    stream << \"PRAGMA table_info(\" << tableName << \")\";\n    void *stmt = prepare(stream.str().c_str());\n    if (stmt == nullptr) {\n        return { false, {} };\n    }\n    bool done;\n    std::list<StringView> columns;\n    int primary = -1;\n    int maxpk = 0;\n    while (step(stmt, done) && !done) {\n        const char *column\n        = reinterpret_cast<const char *>(sqlite3_column_text((sqlite3_stmt *) stmt, 1));\n        columns.push_back(column ? column : StringView());\n\n        //check if and only if single column is primary key\n        int pk = sqlite3_column_int((sqlite3_stmt *) stmt, 5);\n        maxpk = std::max(pk, maxpk);\n        if (pk == 1) {\n            primary = (int) columns.size() - 1;\n        }\n    }\n    finalize(&stmt);\n    if (done) {\n        m_primary = maxpk == 1 ? primary : -1;\n        return { true, columns };\n    }\n    return { false, {} };\n}\n\n#pragma mark - Sequence\nbool SQLiteAssembler::markSequenceAsAssembling()\n{\n    return execute(\n    \"CREATE TABLE IF NOT EXISTS wcdb_dummy_sqlite_sequence(i INTEGER \"\n    \"PRIMARY KEY AUTOINCREMENT)\");\n}\n\nbool SQLiteAssembler::markSequenceAsAssembled()\n{\n    return execute(\"DROP TABLE IF EXISTS wcdb_dummy_sqlite_sequence\");\n}\n\nOptional<bool>\nSQLiteAssembler::updateSequence(const UnsafeStringView &tableName, int64_t sequence)\n{\n    void *stmt = prepare(\"UPDATE sqlite_sequence SET seq = ?1 WHERE name = ?2\");\n    sqlite3_bind_int64((sqlite3_stmt *) stmt, 1, sequence);\n    sqlite3_bind_text((sqlite3_stmt *) stmt, 2, tableName.c_str(), -1, SQLITE_TRANSIENT);\n    bool result = step(stmt);\n    finalize(&stmt);\n    if (!result) {\n        return { false, false };\n    }\n    int changes = sqlite3_changes((sqlite3 *) m_handle);\n    WCTAssert(changes <= 1);\n    return { true, changes > 0 };\n}\n\nbool SQLiteAssembler::insertSequence(const UnsafeStringView &tableName, int64_t sequence)\n{\n    void *stmt = prepare(\"INSERT INTO sqlite_sequence(name, seq) VALUES(?1, ?2)\");\n    sqlite3_bind_text((sqlite3_stmt *) stmt, 1, tableName.c_str(), -1, SQLITE_TRANSIENT);\n    sqlite3_bind_int64((sqlite3_stmt *) stmt, 2, sequence);\n    bool result = step(stmt);\n    finalize(&stmt);\n    return result;\n}\n\nbool SQLiteAssembler::assembleSequence(const UnsafeStringView &tableName, int64_t sequence)\n{\n    if (sequence <= 0) {\n        return true;\n    }\n    bool succeed, updated;\n    std::tie(succeed, updated) = updateSequence(tableName, sequence);\n    if (!succeed) {\n        return false;\n    }\n    if (updated) {\n        return true;\n    }\n    return insertSequence(tableName, sequence);\n}\n\n#pragma mark - SQLite Base\nbool SQLiteAssembler::open()\n{\n    if (!SQLiteBase::open()) {\n        return false;\n    }\n    if (!execute(\"PRAGMA journal_mode=OFF\") || !execute(\"PRAGMA mmap_size=2147418112\")) {\n        close();\n        return false;\n    }\n    return true;\n}\n\nvoid SQLiteAssembler::close()\n{\n    WCTAssert(m_cellSTMT == nullptr);\n    SQLiteBase::close();\n}\n\n} //namespace Repair\n\n} //namespace WCDB\n\n#endif /* WCDB_USE_BUILTIN_SQLITE_REPAIR */\n"
  },
  {
    "path": "src/common/repair/sqlite/SQLiteAssembler.hpp",
    "content": "//\n// Created by sanhuazhang on 2018/05/19\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#if WCDB_USE_BUILTIN_SQLITE_REPAIR\n\n#include \"Assembler.hpp\"\n#include \"SQLiteBase.hpp\"\n#include \"WCDBOptional.hpp\"\n#include <list>\n\nnamespace WCDB {\n\nnamespace Repair {\n\nclass SQLiteAssembler final : public Assembler, public SQLiteBase {\n#pragma mark - Initialize\npublic:\n    SQLiteAssembler();\n    ~SQLiteAssembler() override;\n\n#pragma mark - Assembler\npublic:\n    void setPath(const UnsafeStringView &path) override final;\n    const StringView &getPath() const override final;\n\n    bool markAsAssembling() override final;\n    bool markAsAssembled() override final;\n\n    bool markAsMilestone() override final;\n\n    bool assembleTable(const UnsafeStringView &tableName,\n                       const UnsafeStringView &sql) override final;\n    bool assembleCell(const Cell &cell) override final;\n    bool assembleSQL(const UnsafeStringView &sql) override final;\n\n    const Error &getError() const override final;\n\n#pragma mark - Cell\nprotected:\n    bool lazyPrepareCell();\n    Optional<StringView> getAssembleSQL(const UnsafeStringView &tableName);\n    Optional<std::list<StringView>> getColumnNames(const UnsafeStringView &tableName);\n\n    StringView m_table;\n    int m_primary;\n    void *m_cellSTMT;\n\n#pragma mark - Sequence\nprotected:\n    bool markSequenceAsAssembling();\n    bool assembleSequence(const UnsafeStringView &tableName, int64_t sequence) override final;\n    bool markSequenceAsAssembled();\n\n    Optional<bool> updateSequence(const UnsafeStringView &tableName, int64_t sequence);\n    bool insertSequence(const UnsafeStringView &tableName, int64_t sequence);\n\n#pragma mark - SQLite Base\nprotected:\n    bool open();\n    void close();\n};\n\n} //namespace Repair\n\n} //namespace WCDB\n\n#endif /* WCDB_USE_BUILTIN_SQLITE_REPAIR */\n"
  },
  {
    "path": "src/common/repair/sqlite/SQLiteBase.cpp",
    "content": "//\n// Created by sanhuazhang on 2018/06/22\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#if WCDB_USE_BUILTIN_SQLITE_REPAIR\n\n#include \"SQLiteBase.hpp\"\n#include \"Assertion.hpp\"\n#include \"Notifier.hpp\"\n#include \"SQLite.h\"\n#include \"StringView.hpp\"\n#include <sstream>\n\nnamespace WCDB {\n\nnamespace Repair {\n\nSQLiteBase::SQLiteBase() : m_handle(nullptr), m_codeToBeIgnored(SQLITE_OK)\n{\n}\n\nvoid SQLiteBase::setPath(const UnsafeStringView &path)\n{\n    m_path = path;\n}\n\nconst StringView &SQLiteBase::getPath() const\n{\n    return m_path;\n}\n\n#pragma mark - Transaction\nbool SQLiteBase::lazyBeginTransaction()\n{\n    if (isInTransaction()) {\n        return true;\n    }\n    return execute(\"BEGIN\");\n}\n\nbool SQLiteBase::lazyBeginTransactionImmediate()\n{\n    if (isInTransaction()) {\n        return true;\n    }\n    return execute(\"BEGIN IMMEDIATE\");\n}\n\nbool SQLiteBase::lazyCommitOrRollbackTransaction(bool commit)\n{\n    if (isInTransaction()) {\n        if (!commit || !execute(\"COMMIT\")) {\n            markErrorAsIgnorable(-1);\n            execute(\"ROLLBACK\"); //ignore all errors\n            markErrorAsUnignorable();\n            return false;\n        }\n    }\n    return true;\n}\n\nbool SQLiteBase::isInTransaction()\n{\n    return sqlite3_get_autocommit((sqlite3 *) m_handle) == 0;\n}\n\n#pragma mark - Error\nvoid SQLiteBase::markErrorAsIgnorable(int codeToBeIgnored)\n{\n    m_codeToBeIgnored = codeToBeIgnored;\n}\n\nvoid SQLiteBase::markErrorAsUnignorable()\n{\n    m_codeToBeIgnored = SQLITE_OK;\n}\n\nbool SQLiteBase::error(int rc, const char *sql)\n{\n    bool result;\n    Error error;\n    if (m_codeToBeIgnored >= 0 && rc != m_codeToBeIgnored) {\n        error.level = Error::Level::Error;\n        result = false;\n    } else {\n        error.level = Error::Level::Notice;\n        result = true;\n    }\n    error.setSQLiteCode(rc, sqlite3_extended_errcode((sqlite3 *) m_handle));\n    const char *message = sqlite3_errmsg((sqlite3 *) m_handle);\n    if (message != nullptr) {\n        error.message = message;\n    }\n    if (sql != nullptr) {\n        error.infos.insert_or_assign(ErrorStringKeySQL, sql);\n    }\n    error.infos.insert_or_assign(ErrorStringKeyPath, m_path);\n    Notifier::shared().notify(error);\n    ErrorProne::setError(std::move(error));\n    return result;\n}\n\n#pragma mark - SQLite Handle\nbool SQLiteBase::open()\n{\n    WCTAssert(!m_path.empty());\n    if (m_handle == nullptr) {\n        int rc = sqlite3_open(m_path.c_str(), (sqlite3 **) &m_handle);\n        if (rc != SQLITE_OK) {\n            return error(rc);\n        }\n    }\n    return true;\n}\n\nbool SQLiteBase::isOpened() const\n{\n    return m_handle != nullptr;\n}\n\nvoid SQLiteBase::close()\n{\n    if (m_handle != nullptr) {\n        sqlite3_close_v2((sqlite3 *) m_handle);\n        m_handle = nullptr;\n    }\n}\n\nbool SQLiteBase::execute(const char *sql)\n{\n    WCTAssert(isOpened());\n    WCTAssert(sql != nullptr);\n    int rc = sqlite3_exec((sqlite3 *) m_handle, sql, nullptr, nullptr, nullptr);\n    if (rc != SQLITE_OK) {\n        return error(rc, sql);\n    }\n    return true;\n}\n\n#pragma mark - SQLite STMT\nvoid *SQLiteBase::prepare(const char *sql)\n{\n    WCTAssert(isOpened());\n    WCTAssert(sql != nullptr);\n    sqlite3_stmt *stmt;\n    int rc = sqlite3_prepare_v2((sqlite3 *) m_handle, sql, -1, &stmt, nullptr);\n    if (rc == SQLITE_OK) {\n        return stmt;\n    }\n    error(rc, sql);\n    return nullptr;\n}\n\nbool SQLiteBase::step(void *stmt)\n{\n    bool unused;\n    return step(stmt, unused);\n}\n\nbool SQLiteBase::step(void *stmt, bool &done)\n{\n    WCTAssert(isOpened());\n    WCTAssert(stmt != nullptr);\n    int rc = sqlite3_step((sqlite3_stmt *) stmt);\n    done = rc == SQLITE_DONE;\n    if (rc == SQLITE_OK || rc == SQLITE_DONE || rc == SQLITE_ROW) {\n        return true;\n    };\n    const char *sql = sqlite3_sql((sqlite3_stmt *) stmt);\n    return error(rc, sql ? sql : nullptr);\n}\n\nvoid SQLiteBase::finalize(void **stmt)\n{\n    if (*stmt != nullptr) {\n        sqlite3_finalize((sqlite3_stmt *) *stmt);\n        *stmt = nullptr;\n    }\n}\n\n} //namespace Repair\n\n} //namespace WCDB\n\n#endif /* WCDB_USE_BUILTIN_SQLITE_REPAIR */\n"
  },
  {
    "path": "src/common/repair/sqlite/SQLiteBase.hpp",
    "content": "//\n// Created by sanhuazhang on 2018/06/22\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#if WCDB_USE_BUILTIN_SQLITE_REPAIR\n\n#include \"ErrorProne.hpp\"\n#include \"StringView.hpp\"\n\n// repair/sqlite are optional. Ones can implement their own tools.\n\nnamespace WCDB {\n\nnamespace Repair {\n\nclass SQLiteBase : public ErrorProne {\npublic:\n    SQLiteBase();\n    virtual ~SQLiteBase() override = 0;\n\n    void setPath(const UnsafeStringView &path);\n    const StringView &getPath() const;\n\nprotected:\n    StringView m_path;\n\n#pragma mark - Error\nprotected:\n    bool error(int rc, const char *sql = nullptr);\n\n    // if code >= 0, then the level of error with the specified code will be marked as ignored\n    // if code < 0, then the level of all errors will be marked as ignored\n    void markErrorAsIgnorable(int codeToBeIgnored);\n    void markErrorAsUnignorable();\n\nprivate:\n    int m_codeToBeIgnored;\n\n#pragma mark - SQLite Handle\nprotected:\n    bool open();\n    bool isOpened() const;\n    void close();\n\n    bool execute(const char *sql);\n\n    void *m_handle;\n\n#pragma mark - SQLite STMT\nprotected:\n    void *prepare(const char *sql);\n    bool step(void *stmt);\n    bool step(void *stmt, bool &done);\n\n    void finalize(void **stmt);\n\n#pragma mark - Transaction\nprotected:\n    bool lazyBeginTransaction();\n    bool lazyBeginTransactionImmediate();\n    bool lazyCommitOrRollbackTransaction(bool commit = true);\n    bool isInTransaction();\n};\n\n} //namespace Repair\n\n} //namespace WCDB\n\n#endif /* WCDB_USE_BUILTIN_SQLITE_REPAIR */\n"
  },
  {
    "path": "src/common/repair/sqlite/SQLiteLocker.cpp",
    "content": "//\n// Created by sanhuazhang on 2018/06/22\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#if WCDB_USE_BUILTIN_SQLITE_REPAIR\n\n#include \"SQLiteLocker.hpp\"\n#include \"Assertion.hpp\"\n#include \"SQLite.h\"\n\nnamespace WCDB {\n\nnamespace Repair {\n\n#pragma mark - SQLiteReadLocker\nSQLiteReadLocker::~SQLiteReadLocker() = default;\n\nconst Error &SQLiteReadLocker::getError() const\n{\n    return ErrorProne::getError();\n}\n\nvoid SQLiteReadLocker::setPath(const UnsafeStringView &path)\n{\n    WCTAssert(m_path.empty());\n    SQLiteBase::setPath(path);\n}\n\nconst StringView &SQLiteReadLocker::getPath() const\n{\n    return SQLiteBase::getPath();\n}\n\nbool SQLiteReadLocker::acquireLock()\n{\n    if (!open()) {\n        return false;\n    }\n    if (!lazyBeginTransaction()) {\n        return false;\n    }\n    //execute read sql to acquire read lock\n    return execute(\"SELECT 1 FROM sqlite_master LIMIT 0\");\n}\n\nbool SQLiteReadLocker::releaseLock()\n{\n    lazyCommitOrRollbackTransaction(false);\n    close();\n    return true;\n}\n\n#pragma mark - SQLiteWriteLocker\nSQLiteWriteLocker::~SQLiteWriteLocker() = default;\n\nconst Error &SQLiteWriteLocker::getError() const\n{\n    return ErrorProne::getError();\n}\n\nvoid SQLiteWriteLocker::setPath(const UnsafeStringView &path)\n{\n    WCTAssert(m_path.empty());\n    SQLiteBase::setPath(path);\n}\n\nconst StringView &SQLiteWriteLocker::getPath() const\n{\n    return SQLiteBase::getPath();\n}\n\nbool SQLiteWriteLocker::acquireLock()\n{\n    if (!open()) {\n        return false;\n    }\n    return lazyBeginTransactionImmediate();\n}\n\nbool SQLiteWriteLocker::releaseLock()\n{\n    lazyCommitOrRollbackTransaction(false);\n    close();\n    return true;\n}\n\n} //namespace Repair\n\n} //namespace WCDB\n\n#endif /* WCDB_USE_BUILTIN_SQLITE_REPAIR */\n"
  },
  {
    "path": "src/common/repair/sqlite/SQLiteLocker.hpp",
    "content": "//\n// Created by sanhuazhang on 2018/06/22\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#if WCDB_USE_BUILTIN_SQLITE_REPAIR\n\n#include \"SQLiteBase.hpp\"\n\nnamespace WCDB {\n\nnamespace Repair {\n\nclass SQLiteReadLocker final : public ReadLocker, public SQLiteBase {\npublic:\n    ~SQLiteReadLocker() override;\n\n    void setPath(const UnsafeStringView &path) override final;\n    const StringView &getPath() const override final;\n\n    bool acquireLock() override final;\n    bool releaseLock() override final;\n    const Error &getError() const override final;\n};\n\nclass SQLiteWriteLocker final : public WriteLocker, public SQLiteBase {\npublic:\n    ~SQLiteWriteLocker() override;\n    void setPath(const UnsafeStringView &path) override final;\n    const StringView &getPath() const override final;\n\n    bool acquireLock() override final;\n    bool releaseLock() override final;\n    const Error &getError() const override final;\n};\n\n} //namespace Repair\n\n} //namespace WCDB\n\n#endif /* WCDB_USE_BUILTIN_SQLITE_REPAIR */\n"
  },
  {
    "path": "src/common/repair/utility/Fraction.cpp",
    "content": "//\n// Created by sanhuazhang on 2018/06/21\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"Fraction.hpp\"\n#include \"Assertion.hpp\"\n\nnamespace WCDB {\n\nnamespace Repair {\n\nFraction::Fraction() : m_numerator(0), m_denominator(1)\n{\n}\n\nFraction::Fraction(int64_t value) : m_numerator(value), m_denominator(1)\n{\n}\n\nFraction::Fraction(int64_t numerator, int64_t denominator)\n: m_numerator(numerator), m_denominator(denominator)\n{\n    WCTRemedialAssert(denominator != 0, \"Denominator can't be 0.\", m_numerator = 0;\n                      m_denominator = 1;);\n}\n\nint64_t Fraction::euclidean(int64_t a, int64_t b) const\n{\n    while (b != 0) {\n        std::tie(a, b) = std::make_pair(b, a % b);\n    }\n    if (a == 0) {\n        a = 1;\n    }\n    return a;\n}\n\nvoid Fraction::reduce()\n{\n    int64_t gcd = euclidean(m_numerator, m_denominator);\n    if (gcd > 1) {\n        m_numerator /= gcd;\n        m_denominator /= gcd;\n    }\n}\n\nint64_t Fraction::limitNumber(int64_t a, int64_t b) const\n{\n    int64_t limit = 1;\n    a = std::abs(a);\n    b = std::abs(b);\n    int64_t max_b = std::numeric_limits<int64_t>::max() / a;\n    if (max_b < b) {\n        limit = b / max_b + (b % max_b > 0 ? 1 : 0);\n    }\n    return limit;\n}\n\nFraction Fraction::operator+(const Fraction &operand) const\n{\n    int64_t numerator, denominator;\n    if (m_denominator == operand.m_denominator) {\n        numerator = m_numerator + operand.m_numerator;\n        denominator = m_denominator;\n    } else {\n        int64_t gcd = euclidean(m_denominator, operand.m_denominator);\n\n        denominator = m_denominator / gcd;\n        int64_t limit = limitNumber(denominator, operand.m_denominator);\n        gcd *= limit;\n        denominator /= limit;\n\n        numerator = (operand.m_denominator / gcd * m_numerator)\n                    + (m_denominator / gcd * operand.m_numerator);\n        denominator = denominator * operand.m_denominator;\n    }\n    Fraction result(numerator, denominator);\n    result.reduce();\n    return result;\n}\n\nFraction Fraction::operator*(const Fraction &operand) const\n{\n    int64_t gcd1 = euclidean(m_numerator, operand.m_denominator);\n    int64_t gcd2 = euclidean(operand.m_numerator, m_denominator);\n\n    int64_t denominator1 = m_denominator / gcd2;\n    int64_t denominator2 = operand.m_denominator / gcd1;\n    int64_t limit = limitNumber(denominator1, denominator2);\n    gcd2 *= limit;\n    denominator1 /= limit;\n\n    Fraction result(m_numerator / gcd1 * (operand.m_numerator / gcd2),\n                    denominator1 * denominator2);\n    return result;\n}\n\nFraction &Fraction::operator+=(const Fraction &operand)\n{\n    if (m_denominator == operand.m_denominator) {\n        m_numerator += operand.m_numerator;\n    } else {\n        int64_t gcd = euclidean(m_denominator, operand.m_denominator);\n\n        int64_t denominator = operand.m_denominator / gcd;\n        int64_t limit = limitNumber(m_denominator, denominator);\n        gcd *= limit;\n        denominator /= limit;\n\n        m_numerator = (operand.m_denominator / gcd * m_numerator)\n                      + (m_denominator / gcd * operand.m_numerator);\n        m_denominator *= denominator;\n    }\n    reduce();\n    return *this;\n}\n\nFraction Fraction::operator/(const Fraction &operand) const\n{\n    int64_t gcd1 = euclidean(m_numerator, operand.m_numerator);\n    int64_t gcd2 = euclidean(m_denominator, operand.m_denominator);\n    Fraction result(m_numerator / gcd1 * (operand.m_denominator / gcd2),\n                    m_denominator / gcd2 * (operand.m_numerator / gcd1));\n    return result;\n}\n\nbool Fraction::operator<(const Fraction &operand) const\n{\n    int64_t gcd1 = euclidean(m_numerator, operand.m_numerator);\n    int64_t gcd2 = euclidean(m_denominator, operand.m_denominator);\n    return (m_numerator / gcd1 * (operand.m_denominator / gcd2))\n           < (m_denominator / gcd2 * (operand.m_numerator / gcd1));\n}\n\ndouble Fraction::value() const\n{\n    return (double) m_numerator / m_denominator;\n}\n\nint64_t Fraction::numberator() const\n{\n    return m_numerator;\n}\n\nint64_t Fraction::denominator() const\n{\n    return m_denominator;\n}\n\n} //namespace Repair\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/common/repair/utility/Fraction.hpp",
    "content": "//\n// Created by sanhuazhang on 2018/06/21\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include <cstdint>\n\nnamespace WCDB {\n\nnamespace Repair {\n\nclass Fraction final {\npublic:\n    Fraction();\n    Fraction(int64_t numerator, int64_t denominator);\n    Fraction(int64_t value);\n\n    Fraction operator+(const Fraction &operand) const;\n    Fraction operator*(const Fraction &operand) const;\n    Fraction operator/(const Fraction &operand) const;\n    Fraction &operator+=(const Fraction &fraction);\n\n    bool operator<(const Fraction &operand) const;\n\n    double value() const;\n\n    int64_t numberator() const;\n    int64_t denominator() const;\n\nprotected:\n    void reduce();\n    int64_t euclidean(int64_t a, int64_t b) const;\n    int64_t limitNumber(int64_t a, int64_t b) const;\n\nprivate:\n    int64_t m_numerator;\n    int64_t m_denominator;\n};\n\n} //namespace Repair\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/common/utility/AsyncQueue.cpp",
    "content": "//\n// Created by sanhuazhang on 2019/06/06\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"AsyncQueue.hpp\"\n#include \"Assertion.hpp\"\n#include \"CoreConst.h\"\n#include \"Exiting.hpp\"\n#include \"Notifier.hpp\"\n#include \"StringView.hpp\"\n#include \"WCDBError.hpp\"\n#include <atomic>\n#include <thread>\n\nnamespace WCDB {\n\nAsyncQueue::AsyncQueue(const UnsafeStringView& name_) : name(name_)\n{\n}\n\nAsyncQueue::~AsyncQueue()\n{\n    if (m_running.valid()\n        && m_running.wait_for(\n           std::chrono::nanoseconds((long long) (AsyncQueueTimeOutForExiting * 1E9)))\n           == std::future_status::timeout) {\n        Error error(Error::Code::Warning, Error::Level::Warning, \"Queue does not exit on time.\");\n        error.infos.insert_or_assign(\"Timeout\", AsyncQueueTimeOutForExiting);\n        error.infos.insert_or_assign(\"Name\", name);\n        Notifier::shared().notify(error);\n    }\n}\n\nvoid AsyncQueue::run()\n{\n    m_running = std::async(std::launch::async, &AsyncQueue::load, this);\n}\n\nvoid AsyncQueue::load()\n{\n    Thread::setName(name);\n    main();\n}\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/utility/AsyncQueue.hpp",
    "content": "//\n// Created by sanhuazhang on 2019/06/06\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"Lock.hpp\"\n#include \"StringView.hpp\"\n#include <future>\n\nnamespace WCDB {\n\nclass AsyncQueue {\npublic:\n    AsyncQueue(const UnsafeStringView &name);\n    virtual ~AsyncQueue() = 0;\n\n    AsyncQueue() = delete;\n    AsyncQueue(const AsyncQueue &) = delete;\n    AsyncQueue &operator=(const AsyncQueue &) = delete;\n\n    void run();\n\n    const StringView name;\n\nprotected:\n    virtual void main() = 0;\n\nprivate:\n    void load();\n    std::future<void> m_running;\n};\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/utility/CaseInsensitiveList.hpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"StringView.hpp\"\n#include <algorithm>\n#include <functional>\n#include <list>\n\nnamespace WCDB {\n\ntemplate<typename T>\nclass CaseInsensitiveList : public std::list<std::pair<StringView, T>> {\npublic:\n    auto caseInsensitiveFind(const UnsafeStringView& key)\n    {\n        return std::find_if(\n        this->begin(),\n        this->end(),\n        std::bind(&CaseInsensitiveList::caseInsensitiveEqual, key, std::placeholders::_1));\n    }\n\n    auto caseInsensitiveFind(const UnsafeStringView& key) const\n    {\n        return std::find_if(\n        this->begin(),\n        this->end(),\n        std::bind(&CaseInsensitiveList::caseInsensitiveEqual, key, std::placeholders::_1));\n    }\n\n    void alphabeticallyCaseInsensitiveSort()\n    {\n        this->sort(caseInsensitiveLess);\n    }\n\nprotected:\n    static bool caseInsensitiveEqual(const UnsafeStringView& key,\n                                     const std::pair<StringView, T>& element)\n    {\n        return key.caseInsensitiveEqual(element.first);\n    }\n\n    static bool caseInsensitiveLess(const std::pair<StringView, T>& left,\n                                    const std::pair<StringView, T>& right)\n    {\n        return left.first.caseInsensitiveCompare(right.first) < 0;\n    }\n};\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/utility/Enum.hpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include <sstream>\n#include <type_traits>\n\nnamespace WCDB {\n\nclass Enum final {\npublic:\n    template<typename T, typename Enable = typename std::enable_if<std::is_enum<T>::value>::type>\n    static constexpr const char* description(const T& t);\n};\n\n} // namespace WCDB\n\ntemplate<typename T, typename Enable = typename std::enable_if<std::is_enum<T>::value>::type>\nstd::ostream& operator<<(std::ostream& stream, const T& value)\n{\n    stream << WCDB::Enum::description(value);\n    return stream;\n}\n"
  },
  {
    "path": "src/common/utility/Exiting.cpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"Exiting.hpp\"\n#include \"CommonCore.hpp\"\n#include \"Macro.h\"\n#include <atomic>\n#include <stdlib.h>\n#ifdef _WIN32\n#include <windows.h>\n// VersionHelpers.h must be included after windows.h.\n#include <VersionHelpers.h>\n#endif\n\nnamespace WCDB {\n\nstatic void exiting();\n\nstatic std::atomic<bool>& exitingValue()\n{\n    static std::atomic<bool>* s_exitingValue = new std::atomic<bool>(false);\n    WCDB_ONCE(atexit(exiting));\n    return *s_exitingValue;\n}\n\nstatic void exiting()\n{\n    exitingValue().store(true);\n\n#ifdef _WIN32\n    /*\n     On Windows 7, the thread where the OperationQueue is located may have been released.\n     So it can't receive notifications from the condition variable.\n     */\n    if (IsWindows7OrGreater() && !IsWindows8OrGreater()) {\n        return;\n    }\n#endif\n\n    // The queue needs to be terminated to exit the program normally in Windows.\n    CommonCore::shared().stopQueue();\n}\n\nbool isExiting()\n{\n    return exitingValue().load();\n}\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/utility/Exiting.hpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\nnamespace WCDB {\n\nbool isExiting();\n\n}\n"
  },
  {
    "path": "src/common/utility/Macro.h",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#ifndef _WIN32\n#define WCDB_API __attribute__((visibility(\"default\")))\n#else\n#if defined(WCDB_DLL)\n#if defined(WCDB_BUILD_DLL)\n#define WCDB_API __declspec(dllexport)\n#else\n#define WCDB_API __declspec(dllimport)\n#endif //WCDB_BUILD_DLL\n#else\n#define WCDB_API\n#endif //WCDB_DLL\n#endif //_WIN32\n\n#define WCDB_BOOL_1 1\n#define WCDB_BOOL_0 0\n#define WCDB_BOOL_true 1\n#define WCDB_BOOL_false 0\n#define WCDB_BOOL_TRUE 1\n#define WCDB_BOOL_FALSE 0\n#define WCDB_BOOL_YES 1\n#define WCDB_BOOL_NO 0\n#define WCDB_BOOL___objc_yes 1\n#define WCDB_BOOL___objc_no 0\n#define WCDB_BOOL(var) _WCDB_BOOL(var)\n#define _WCDB_BOOL(var) WCDB_BOOL_##var\n\n#define WCDB_IF_ELSE_0(t, f) f\n#define WCDB_IF_ELSE_1(t, f) t\n#define __WCDB_IF_ELSE(bit, t, f) WCDB_IF_ELSE_##bit(t, f)\n#define _WCDB_IF_ELSE(bit, t, f) __WCDB_IF_ELSE(bit, t, f)\n#define WCDB_IF_ELSE(cond, t, f) _WCDB_IF_ELSE(WCDB_BOOL(cond), t, f)\n\n#define WCDB_IF_0(t)\n#define WCDB_IF_1(t) t\n#define __WCDB_IF(bit, t) WCDB_IF_##bit(t)\n#define _WCDB_IF(bit, t) __WCDB_IF(bit, t)\n#define WCDB_IF(cond, t) _WCDB_IF(WCDB_BOOL(cond), t)\n\n#define WCDB_IF_NOT_0(f) f\n#define WCDB_IF_NOT_1(f)\n#define __WCDB_IF_NOT(bit, f) WCDB_IF_NOT_##bit(f)\n#define _WCDB_IF_NOT(bit, f) __WCDB_IF_NOT(bit, f)\n#define WCDB_IF_NOT(cond, f) _WCDB_IF_NOT(WCDB_BOOL(cond), f)\n\n#define _WCDB_STRINGIFY(str) #str\n#define WCDB_STRINGIFY(str) _WCDB_STRINGIFY(str)\n\n#define _WCDB_CONCAT(a, b) a##b\n#define WCDB_CONCAT(a, b) _WCDB_CONCAT(a, b)\n\n#define WCDB_UNIQUE_ID __COUNTER__\n#define WCDB_ONCE(task)                                                        \\\n    static auto WCDB_CONCAT(__once_, WCDB_UNIQUE_ID) WCDB_USED = task;\n\n#define WCDB_STATIC_ASSERT_EXISTS(type_or_expression)                          \\\n    static_assert(sizeof(type_or_expression) > 0,                              \\\n                  WCDB_STRINGIFY(type_or_expression) \"does not exist.\")\n\n#define WCDB_NO_ESCAPE __attribute__((noescape))\n#define WCDB_ESCAPE\n\n#if !defined(_WIN32)\n#define WCDB_NO_INLINE __attribute__((noinline))\n#else\n#define WCDB_NO_INLINE\n#endif\n\n#if !defined(_WIN32)\n#define WCDB_USED __attribute__((__used__))\n#else\n#define WCDB_USED\n#endif\n\n#ifndef WCDB_EXTERN\n#if defined(__cplusplus)\n#define WCDB_EXTERN extern \"C\" WCDB_API\n#define WCDB_EXTERN_C_BEGIN extern \"C\" {\n#define WCDB_EXTERN_C_END }\n#else\n#define WCDB_EXTERN extern WCDB_API\n#define WCDB_EXTERN_C_BEGIN\n#define WCDB_EXTERN_C_END\n#endif\n#endif\n\n#define WCDB_FIRST_ARG(N, ...) N\n#define WCDB_NON_FIRST_ARGS(N, ...) __VA_ARGS__\n\n#if !defined(_WIN32)\n#define WCDB_UNUSED(variable) _Pragma(WCDB_STRINGIFY(unused(variable)))\n#else\n#define WCDB_UNUSED(variable) (void) (variable)\n#endif\n\n#ifdef __clang__\n#define WCDB_NO_DESTROY [[clang::no_destroy]]\n#define WCDB_STATIC_VARIABLE WCDB_NO_DESTROY static\n#else\n#define WCDB_NO_DESTROY\n#define WCDB_STATIC_VARIABLE\n#endif\n\n#define WCDBLiteralStringDefine(name, value)                                   \\\n    static constexpr const char* k_##name = value;                             \\\n    WCDB_EXTERN const StringView name;\n\n#define WCDBLiteralStringImplement(name)                                       \\\n    WCDB_NO_DESTROY const StringView name = StringView::makeConstant(k_##name)\n"
  },
  {
    "path": "src/common/utility/Shadow.hpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include <memory>\n\nnamespace WCDB {\n\ntemplate<typename T>\nclass Cloneable {\npublic:\n    virtual ~Cloneable() = default;\n    virtual std::shared_ptr<T> clone() const = 0;\n};\n\ntemplate<typename T>\nclass Shadow final {\n    //    static_assert(std::is_base_of<Cloneable<T>, T>::value, \"\");\n#pragma mark - NULL\npublic:\n    Shadow() : m_payload(nullptr), m_isPrivate(true) {}\n\n    Shadow(const std::nullptr_t&) : m_payload(nullptr), m_isPrivate(true) {}\n\n    Shadow& operator=(const std::nullptr_t&)\n    {\n        m_payload = nullptr;\n        m_isPrivate = true;\n        return *this;\n    }\n\n    bool operator==(std::nullptr_t) const { return m_payload == nullptr; }\n    bool operator!=(std::nullptr_t) const { return m_payload != nullptr; }\n\n#pragma mark - Value\npublic:\n    Shadow(const T& value) : m_payload(value.clone()), m_isPrivate(true) {}\n\n    Shadow(std::shared_ptr<T>&& value)\n    : m_payload(std::move(value)), m_isPrivate(true)\n    {\n        m_isPrivate = true;\n    }\n\n    Shadow& operator=(const T& value)\n    {\n        auto newPayload = value.clone();\n        m_payload = std::shared_ptr<T>(newPayload, static_cast<T*>(newPayload.get()));\n        m_isPrivate = true;\n        return *this;\n    }\n\n    const T* get() const { return m_payload.get(); }\n\n    T* get()\n    {\n        if (!m_isPrivate) {\n            if (m_payload.use_count() > 1) {\n                auto newPayload = m_payload->clone();\n                m_payload\n                = std::shared_ptr<T>(newPayload, static_cast<T*>(newPayload.get()));\n                m_isPrivate = true;\n            } else {\n                m_isPrivate = false;\n            }\n        }\n        return m_payload.get();\n    }\n\n#pragma mark - Shadow\npublic:\n    Shadow(const Shadow<T>& other)\n    : m_payload(other.m_payload), m_isPrivate(other.m_payload != nullptr ? false : true)\n    {\n        if (other.m_payload != nullptr) {\n            other.m_isPrivate = false;\n        }\n    }\n\n    Shadow(Shadow<T>&& other)\n    : m_payload(std::move(other.m_payload)), m_isPrivate(other.m_isPrivate)\n    {\n    }\n\n    Shadow& operator=(const Shadow<T>& other)\n    {\n        m_payload = other.m_payload;\n        m_isPrivate = m_payload == nullptr;\n        other.m_isPrivate = m_isPrivate;\n        return *this;\n    }\n\n    Shadow& operator=(Shadow<T>&& other)\n    {\n        m_payload = std::move(other.m_payload);\n        m_isPrivate = other.m_isPrivate;\n        return *this;\n    }\n\nprivate:\n    std::shared_ptr<T> m_payload;\n    mutable bool m_isPrivate;\n};\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/utility/TimedQueue.hpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"Assertion.hpp\"\n#include \"Exiting.hpp\"\n#include \"Time.hpp\"\n#include \"UniqueList.hpp\"\n#include <condition_variable>\n#include <list>\n#include <stdio.h>\n\nnamespace WCDB {\n\ntemplate<typename Key, typename Info>\nclass TimedQueue final {\nprivate:\n    typedef UniqueList<Key, Info, SteadyClock> List;\n    List m_list;\n    Conditional m_conditional;\n    std::mutex m_lock;\n    bool m_stop;\n    std::atomic<bool> m_running;\n\npublic:\n    TimedQueue() : m_stop(false), m_running(false) {}\n    ~TimedQueue()\n    {\n        stop();\n        waitUntilDone();\n    }\n\n    // return true to erase the element\n    typedef std::function<void(const Key &, const Info &)> ExpiredCallback;\n\n    enum class Mode {\n        ForwardOnly,\n        ReQueue,\n    };\n\n    void queue(const Key &key, double delay, const Info &info, Mode mode = Mode::ForwardOnly)\n    {\n        if (isExiting()) {\n            stop();\n            return;\n        }\n        bool notify = false;\n        {\n            SteadyClock expired\n            = SteadyClock::now().steadyClockByAddingTimeInterval(delay);\n\n            std::lock_guard<std::mutex> lockGuard(m_lock);\n            if (m_stop) {\n                return;\n            }\n\n            auto iter = m_list.find(key);\n            if (mode == Mode::ForwardOnly && iter != m_list.end() && iter->order() < expired) {\n                iter->value() = info;\n            } else {\n                m_list.insert(key, info, expired);\n                notify = m_list.front().key() == key;\n            }\n        }\n        if (notify) {\n            m_conditional.notify_one();\n        }\n    }\n\n    void remove(const Key &key)\n    {\n        {\n            std::lock_guard<std::mutex> lockGuard(m_lock);\n            if (m_stop) {\n                return;\n            }\n            m_list.erase(key);\n        }\n        if (isExiting()) {\n            stop();\n            return;\n        }\n    }\n\n    void stop()\n    {\n        {\n            std::lock_guard<std::mutex> lockGuard(m_lock);\n            m_list.clear();\n            m_stop = true;\n        }\n        m_conditional.notify_one();\n    }\n\n    void waitUntilDone() { while (m_running.load()); }\n\n    void loop(const ExpiredCallback &onElementExpired)\n    {\n        m_running.store(true);\n        while (!isExiting()) {\n            std::list<std::pair<Key, Info>> expireds;\n            {\n                std::unique_lock<std::mutex> lockGuard(m_lock);\n                if (m_stop) {\n                    break;\n                }\n                auto shortest = m_list.begin();\n                if (shortest == m_list.end()) {\n                    if (!isExiting()) {\n                        m_conditional.wait(lockGuard);\n                    }\n                    continue;\n                }\n                double timeInterval = shortest->order().timeIntervalSinceNow();\n                if (timeInterval > 0) {\n                    if (!isExiting()) {\n                        m_conditional.wait_for(lockGuard, timeInterval);\n                    }\n                    continue;\n                }\n                expireds.push_back(std::make_pair(shortest->key(), shortest->value()));\n                m_list.erase(shortest);\n            }\n            if (!isExiting()) {\n                WCTAssert(expireds.size() == 1);\n                onElementExpired(expireds.begin()->first, expireds.begin()->second);\n            }\n        }\n        m_running.store(false);\n    }\n};\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/common/utility/UniqueList.hpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/30\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n/*\n * Unique list is a data structure that\n * 1. constrained by unique key.\n * 2. sorted by ascending order.\n *\n * The performance is not good while\n * 1. Both insert/find/erase are O(N)\n * 2. Initialization is O(N^2)\n *\n * It's designed for tiny dataset less than 20 in usual thus... well.\n */\n\n#include <algorithm>\n#include <functional>\n#include <list>\n\nnamespace WCDB {\n\ntemplate<typename Key, typename Value, typename Order>\nclass UniqueListElement {\nprivate:\n    typedef UniqueListElement<Key, Value, Order> SelfType;\n\npublic:\n    UniqueListElement(const Key& key, const Value& value, const Order& order)\n    : m_key(key), m_value(value), m_order(order)\n    {\n    }\n\n    const Key& key() const { return m_key; }\n\n    Value& value() { return m_value; }\n\n    const Value& value() const { return m_value; }\n\n    const Order& order() const { return m_order; }\n\n    bool operator==(const SelfType& other) const\n    {\n        return m_order == other.m_order && m_key == other.m_key\n               && m_value == other.m_value;\n    }\n\nprivate:\n    Key m_key;\n    Value m_value;\n    Order m_order;\n};\n\n// Small order first\ntemplate<typename Key, typename Value, typename Order = int>\nclass UniqueList : private std::list<UniqueListElement<Key, Value, Order>> {\n#pragma mark - Declaration\nprivate:\n    typedef UniqueListElement<Key, Value, Order> Element;\n    typedef UniqueList<Key, Value, Order> SelfType;\n    typedef std::list<Element> SuperType;\n    typedef typename SuperType::iterator Iterator;\n\n#pragma mark - Initializer\npublic:\n    UniqueList() = default;\n\n    UniqueList(const std::initializer_list<Element>& elements)\n    {\n        for (const auto& element : elements) {\n            insert(element.key(), element.value(), element.order());\n        }\n    }\n\n    UniqueList(const SelfType& elements)\n    {\n        for (const auto& element : elements) {\n            insert(element.key(), element.value(), element.order());\n        }\n    }\n\n    virtual ~UniqueList() = default;\n\n#pragma mark - Element Access\npublic:\n    using SuperType::back;\n    using SuperType::front;\n\n#pragma mark - Iterator\npublic:\n    Iterator find(const Key& key)\n    {\n        return std::find_if(\n        this->begin(),\n        this->end(),\n        std::bind(&UniqueList<Key, Value, Order>::findKey, key, std::placeholders::_1));\n    }\n\n    using SuperType::begin;\n    using SuperType::end;\n    using SuperType::cbegin;\n    using SuperType::cend;\n    using SuperType::rbegin;\n    using SuperType::rend;\n    using SuperType::crbegin;\n    using SuperType::crend;\n\nprivate:\n    static bool findKey(const Key& key, const Element& element)\n    {\n        return element.key() == key;\n    }\n\n#pragma mark - Capacity\npublic:\n    using SuperType::empty;\n    using SuperType::size;\n    using SuperType::max_size;\n\n#pragma mark - Modifiers\npublic:\n    void insert(const Key& key, const Value& value, const Order& order)\n    {\n        bool inserted = false;\n        bool erased = false;\n        for (auto iter = this->begin(); iter != this->end() && (!inserted || !erased);) {\n            if (!erased && iter->key() == key) {\n                iter = this->SuperType::erase(iter);\n                erased = true;\n            } else {\n                if (!inserted && order < iter->order()) {\n                    iter = this->SuperType::insert(iter, Element(key, value, order));\n                    inserted = true;\n                }\n                ++iter;\n            }\n        }\n        if (!inserted) {\n            this->push_back(Element(key, value, order));\n        }\n    }\n\n    Iterator erase(const Key& key)\n    {\n        auto iter = find(key);\n        if (iter != this->end()) {\n            iter = this->SuperType::erase(iter);\n        }\n        return iter;\n    }\n\n    using SuperType::clear;\n    using SuperType::erase;\n    using SuperType::pop_back;\n    using SuperType::pop_front;\n\n#pragma mark - Comparator\npublic:\n    bool operator==(const SelfType& other) const\n    {\n        return std::equal(begin(), end(), other.begin(), other.end());\n    }\n\n    bool operator!=(const SelfType& other) const\n    {\n        return !std::equal(begin(), end(), other.begin(), other.end());\n    }\n};\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/utility/WCDBVersion.h",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#define WCDB_IDENTIFIER \"8e3f0e2f9c9b06619b166bf3e2897b46\"\n\n#ifdef WCDB_VERSION\n#define WCDB_VERSION_STRING WCDB_STRINGIFY(WCDB_VERSION)\n#else\n#define WCDB_VERSION_STRING \"Custom build\"\n#endif\n\n#ifdef WCDB_BUILD\n#define WCDB_BUILD_STRING WCDB_STRINGIFY(WCDB_BUILD)\n#else\n#define WCDB_BUILD_STRING \"Custom Build\"\n#endif\n\n#define WCDB_SOURCE_ID                                                         \\\n    WCDB_IDENTIFIER \", \" WCDB_VERSION_STRING \".\" WCDB_BUILD_STRING\n"
  },
  {
    "path": "src/common/winq/SQL.cpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"SQL.hpp\"\n#include \"Assertion.hpp\"\n#include <atomic>\n\nnamespace WCDB {\n\nSQL::SQL() = default;\n\nSQL::SQL(const SQL& other)\n: m_syntaxPtr(other.m_syntaxPtr)\n, m_description(other.m_hasDescription ? std::atomic_load(&other.m_description) : nullptr)\n, m_hasDescription(other.m_hasDescription)\n{\n}\n\nSQL::SQL(SQL&& other)\n: m_syntaxPtr(other.m_syntaxPtr)\n, m_description(other.m_hasDescription ? std::atomic_load(&other.m_description) : nullptr)\n, m_hasDescription(other.m_hasDescription)\n{\n    if (other.m_hasDescription) {\n        std::atomic_store(&other.m_description, std::shared_ptr<StringView>(nullptr));\n        other.m_hasDescription = false;\n    }\n}\n\nSQL::~SQL() = default;\n\nSQL& SQL::operator=(const SQL& other)\n{\n    if (other.m_hasDescription) {\n        m_description = std::atomic_load(&other.m_description);\n    } else {\n        m_description = nullptr;\n    }\n    m_hasDescription = other.m_hasDescription;\n    return *this;\n}\n\nSQL& SQL::operator=(SQL&& other)\n{\n    if (other.m_hasDescription) {\n        m_description = std::atomic_load(&other.m_description);\n    } else {\n        m_description = nullptr;\n    }\n    m_hasDescription = other.m_hasDescription;\n    if (other.m_hasDescription) {\n        std::atomic_store(&other.m_description, std::shared_ptr<StringView>(nullptr));\n        other.m_hasDescription = false;\n    }\n    return *this;\n}\n\nSQL::Type SQL::getType() const\n{\n    return syntax().getType();\n}\n\nvoid SQL::iterate(const ConstIterator& iterator) const\n{\n    return syntax().iterate(iterator);\n}\n\nvoid SQL::iterate(const Iterator& iterator)\n{\n    if (m_hasDescription) {\n        std::atomic_store(&m_description, std::shared_ptr<StringView>(nullptr));\n        m_hasDescription = false;\n    }\n    return syntax().iterate(iterator);\n}\n\nStringView SQL::getDescription() const\n{\n    // class SQL is not designed for thread-safe.\n    // But here, the cache of `m_description` may be accessed/modified in different threads.\n    // So we must make this const function thread-safe.\n    std::shared_ptr<StringView> description = std::atomic_load(&m_description);\n    while (description == nullptr) {\n        if (syntax().isValid()) {\n            std::atomic_store(\n            &m_description, std::make_shared<StringView>(syntax().getDescription()));\n            description = std::atomic_load(&m_description);\n            m_hasDescription = true;\n        } else {\n            return StringView();\n        }\n    }\n    return *description.get();\n}\n\nSyntax::Identifier& SQL::syntax()\n{\n    // Note that `syntax()` is not designed for thread-safe.\n    if (m_hasDescription) {\n        std::atomic_store(&m_description, std::shared_ptr<StringView>(nullptr));\n        m_hasDescription = false;\n    }\n    return *m_syntaxPtr;\n}\n\nconst Syntax::Identifier& SQL::syntax() const\n{\n    return *m_syntaxPtr;\n}\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/SQL.hpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"ColumnType.hpp\"\n#include \"Convertible.hpp\"\n#include \"StringView.hpp\"\n#include \"Syntax.h\"\n#include \"SyntaxForwardDeclaration.h\"\n#include \"SyntaxList.hpp\"\n#include <memory>\n\nnamespace WCDB {\n\nclass WCDB_API SQL {\npublic:\n    SQL();\n    virtual ~SQL();\n\n    typedef Syntax::Identifier::Type Type;\n    virtual Type getType() const;\n\n    typedef Syntax::Identifier::Iterator Iterator;\n    void iterate(const Iterator& iterator);\n    typedef Syntax::Identifier::ConstIterator ConstIterator;\n    void iterate(const ConstIterator& iterator) const;\n\n    StringView getDescription() const;\n\n    virtual Syntax::Identifier& syntax();\n    virtual const Syntax::Identifier& syntax() const;\n\nprotected:\n    SQL(const SQL& sql);\n    SQL(SQL&& sql);\n    SQL& operator=(const SQL& other);\n    SQL& operator=(SQL&& other);\n\n    mutable Syntax::Identifier* m_syntaxPtr = nullptr;\n    mutable std::shared_ptr<StringView> m_description;\n    mutable bool m_hasDescription = false;\n};\n\ntemplate<typename __SyntaxType, typename __SQLType>\nclass SpecifiedSyntax : public __SQLType {\n    static_assert(sizeof(__SyntaxType) < 1000,\n                  \"Syntax is too large to be allocated on the stack.\");\n\npublic:\n    using SyntaxType = __SyntaxType;\n    static constexpr const SQL::Type type = SyntaxType::type;\n\nprivate:\n    using SQLType = __SQLType;\n    using Self = SpecifiedSyntax<SyntaxType, SQLType>;\n    using Super = SQLType;\n    static_assert(std::is_base_of<Syntax::Identifier, SyntaxType>::value, \"\");\n    static_assert(std::is_base_of<SQL, SQLType>::value, \"\");\n    __SyntaxType m_syntax;\n\npublic:\n    SpecifiedSyntax() : Super(), m_syntax() { this->m_syntaxPtr = &m_syntax; }\n\n    explicit SpecifiedSyntax(const Self& other)\n    : Super(other), m_syntax(other.m_syntax)\n    {\n        this->m_syntaxPtr = &m_syntax;\n    }\n\n    explicit SpecifiedSyntax(const SyntaxType& syntax)\n    : Super(), m_syntax(syntax)\n    {\n        this->m_syntaxPtr = &m_syntax;\n    }\n\n    SpecifiedSyntax(SyntaxType&& syntax) : Super(), m_syntax(std::move(syntax))\n    {\n        this->m_syntaxPtr = &m_syntax;\n    }\n\n    SpecifiedSyntax(Self&& other)\n    : Super(std::move(other)), m_syntax(std::move(other.m_syntax))\n    {\n        this->m_syntaxPtr = &m_syntax;\n    }\n\n    ~SpecifiedSyntax() override = default;\n\n    Self& operator=(const Self& other)\n    {\n        Super::operator=(other);\n        m_syntax = other.m_syntax;\n        this->m_syntaxPtr = &m_syntax;\n        return *this;\n    }\n\n    Self& operator=(Self&& other)\n    {\n        Super::operator=(std::move(other));\n        m_syntax = std::move(other.m_syntax);\n        this->m_syntaxPtr = &m_syntax;\n        return *this;\n    }\n\n    SyntaxType& syntax() override\n    {\n        return static_cast<SyntaxType&>(Super::syntax());\n    }\n\n    const SyntaxType& syntax() const override\n    {\n        return static_cast<const SyntaxType&>(Super::syntax());\n    }\n\n    // Convert SQL to Syntax implicitly\n    operator const SyntaxType&() const\n    {\n        return static_cast<const SyntaxType&>(Super::syntax());\n    }\n};\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/Statement.cpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"Statement.hpp\"\n\nnamespace WCDB {\n\nStatement::~Statement() = default;\n\nStatement::Statement(const Statement& sql) : SQL(sql), m_syntax(sql.m_syntax)\n{\n}\n\nStatement::Statement(Statement&& sql)\n: SQL(std::move(sql)), m_syntax(std::move(sql.m_syntax))\n{\n}\n\nStatement::Statement(const Shadow<Syntax::Identifier>& syntax)\n: SQL(), m_syntax(syntax)\n{\n}\n\nStatement::Statement(Shadow<Syntax::Identifier>&& syntax)\n: SQL(), m_syntax(std::move(syntax))\n{\n}\n\nStatement::Statement(std::shared_ptr<Syntax::Identifier>&& underlying)\n: SQL(), m_syntax(std::move(underlying))\n{\n}\n\nStatement& Statement::operator=(const Statement& other)\n{\n    m_syntax = other.m_syntax;\n    SQL::operator=(other);\n    return *this;\n}\n\nStatement& Statement::operator=(Statement&& other)\n{\n    m_syntax = std::move(other.m_syntax);\n    SQL::operator=(std::move(other));\n    return *this;\n}\n\nSyntax::Identifier& Statement::syntax()\n{\n    m_syntaxPtr = m_syntax.get();\n    return SQL::syntax();\n}\n\nconst Syntax::Identifier& Statement::syntax() const\n{\n    m_syntaxPtr = const_cast<Syntax::Identifier*>(m_syntax.get());\n    return SQL::syntax();\n}\n\nbool Statement::isWriteStatement() const\n{\n    Syntax::Identifier::Type type = syntax().getType();\n    switch (type) {\n    case Syntax::Identifier::Type::AlterTableSTMT:\n    case Syntax::Identifier::Type::CreateIndexSTMT:\n    case Syntax::Identifier::Type::CreateTableSTMT:\n    case Syntax::Identifier::Type::CreateTriggerSTMT:\n    case Syntax::Identifier::Type::InsertSTMT:\n    case Syntax::Identifier::Type::DeleteSTMT:\n    case Syntax::Identifier::Type::UpdateSTMT:\n    case Syntax::Identifier::Type::CreateViewSTMT:\n    case Syntax::Identifier::Type::CreateVirtualTableSTMT:\n    case Syntax::Identifier::Type::DropIndexSTMT:\n    case Syntax::Identifier::Type::DropTableSTMT:\n    case Syntax::Identifier::Type::DropViewSTMT:\n    case Syntax::Identifier::Type::ReindexSTMT:\n    case Syntax::Identifier::Type::VacuumSTMT:\n        return true;\n    default:\n        return false;\n    }\n    return true;\n}\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/common/winq/Statement.hpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"SQL.hpp\"\n\nnamespace WCDB {\n\nclass WCDB_API Statement : public SQL {\npublic:\n    virtual ~Statement() override;\n    Statement(const Shadow<Syntax::Identifier>& syntax);\n    Statement(Shadow<Syntax::Identifier>&& syntax);\n    Statement(std::shared_ptr<Syntax::Identifier>&& underlying);\n\n    virtual Syntax::Identifier& syntax() override;\n    virtual const Syntax::Identifier& syntax() const override;\n\n    Statement(const Statement& sql);\n    Statement(Statement&& sql);\n    Statement& operator=(const Statement& other);\n    Statement& operator=(Statement&& other);\n    bool isWriteStatement() const;\n\nprivate:\n    Shadow<Syntax::Identifier> m_syntax;\n};\n\ntemplate<typename __SyntaxType>\nclass SpecifiedSyntax<__SyntaxType, Statement> : public Statement {\npublic:\n    using SyntaxType = __SyntaxType;\n    static constexpr const SQL::Type type = SyntaxType::type;\n\nprivate:\n    using Self = SpecifiedSyntax<SyntaxType, Statement>;\n    using Super = Statement;\n    static_assert(std::is_base_of<Syntax::Identifier, SyntaxType>::value, \"\");\n    static_assert(std::is_base_of<SQL, Statement>::value, \"\");\n\npublic:\n    SpecifiedSyntax() : Super(std::make_shared<SyntaxType>()) {}\n\n    explicit SpecifiedSyntax(const Self& other) : Super(other) {}\n\n    explicit SpecifiedSyntax(const SyntaxType& syntax) : Super(syntax) {}\n\n    SpecifiedSyntax(SyntaxType&& syntax) : Super(std::move(syntax)) {}\n\n    SpecifiedSyntax(Self&& other) : Super(std::move(other)) {}\n\n    ~SpecifiedSyntax() override = default;\n\n    Self& operator=(const Self& other)\n    {\n        Super::operator=(other);\n        return *this;\n    }\n\n    Self& operator=(Self&& other)\n    {\n        Super::operator=(std::move(other));\n        return *this;\n    }\n\n    SyntaxType& syntax() override\n    {\n        return static_cast<SyntaxType&>(Super::syntax());\n    }\n\n    const SyntaxType& syntax() const override\n    {\n        return static_cast<const SyntaxType&>(Super::syntax());\n    }\n\n    // Convert SQL to Syntax implicitly\n    operator const SyntaxType&() const\n    {\n        return static_cast<const SyntaxType&>(Super::syntax());\n    }\n};\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/WINQ.h",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n// See also: https://sqlite.org/syntaxdiagrams.html\n\n#include \"SQL.hpp\"\n\n#include \"AggregateFunction.hpp\"\n#include \"ColumnType.hpp\"\n#include \"Convertible.hpp\"\n#include \"CoreFunction.hpp\"\n#include \"ExpressionOperable.hpp\"\n#include \"FTSFunction.hpp\"\n\n#include \"BindParameter.hpp\"\n#include \"Column.hpp\"\n#include \"ColumnConstraint.hpp\"\n#include \"ColumnDef.hpp\"\n#include \"CommonTableExpression.hpp\"\n#include \"Expression.hpp\"\n#include \"Filter.hpp\"\n#include \"ForeignKey.hpp\"\n#include \"FrameSpec.hpp\"\n#include \"IndexedColumn.hpp\"\n#include \"Join.hpp\"\n#include \"JoinConstraint.hpp\"\n#include \"LiteralValue.hpp\"\n#include \"OrderingTerm.hpp\"\n#include \"Pragma.hpp\"\n#include \"QualifiedTable.hpp\"\n#include \"RaiseFunction.hpp\"\n#include \"ResultColumn.hpp\"\n#include \"Schema.hpp\"\n#include \"TableConstraint.hpp\"\n#include \"TableOrSubquery.hpp\"\n#include \"Upsert.hpp\"\n#include \"WindowDef.hpp\"\n\n#include \"Statement.hpp\"\n#include \"StatementAlterTable.hpp\"\n#include \"StatementAnalyze.hpp\"\n#include \"StatementAttach.hpp\"\n#include \"StatementBegin.hpp\"\n#include \"StatementCommit.hpp\"\n#include \"StatementCreateIndex.hpp\"\n#include \"StatementCreateTable.hpp\"\n#include \"StatementCreateTrigger.hpp\"\n#include \"StatementCreateView.hpp\"\n#include \"StatementCreateVirtualTable.hpp\"\n#include \"StatementDelete.hpp\"\n#include \"StatementDetach.hpp\"\n#include \"StatementDropIndex.hpp\"\n#include \"StatementDropTable.hpp\"\n#include \"StatementDropTrigger.hpp\"\n#include \"StatementDropView.hpp\"\n#include \"StatementInsert.hpp\"\n#include \"StatementPragma.hpp\"\n#include \"StatementReindex.hpp\"\n#include \"StatementRelease.hpp\"\n#include \"StatementRollback.hpp\"\n#include \"StatementSavepoint.hpp\"\n#include \"StatementSelect.hpp\"\n#include \"StatementUpdate.hpp\"\n#include \"StatementVacuum.hpp\"\n\n#include \"StatementExplain.hpp\"\n\n#include \"ConvertibleImplementation.hpp\"\n"
  },
  {
    "path": "src/common/winq/extension/AggregateFunction.cpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"WINQ.h\"\n\nnamespace WCDB {\n\nExpression AggregateFunction::avg(const Expression& expression)\n{\n    static const char* funcName = \"avg\";\n    return Expression::function(StringView::makeConstant(funcName)).invoke().arguments(expression);\n}\n\nExpression AggregateFunction::count(const Expression& expression)\n{\n    static const char* funcName = \"count\";\n    return Expression::function(StringView::makeConstant(funcName)).invoke().arguments(expression);\n}\n\nExpression AggregateFunction::groupConcat(const Expression& expression)\n{\n    static const char* funcName = \"group_concat\";\n    return Expression::function(StringView::makeConstant(funcName)).invoke().arguments(expression);\n}\n\nExpression\nAggregateFunction::groupConcat(const Expression& expression, const Expression& seperator)\n{\n    static const char* funcName = \"group_concat\";\n    return Expression::function(StringView::makeConstant(funcName)).invoke().arguments({ expression, seperator });\n}\n\nExpression AggregateFunction::max(const Expression& expression)\n{\n    static const char* funcName = \"max\";\n    return Expression::function(StringView::makeConstant(funcName)).invoke().arguments(expression);\n}\n\nExpression AggregateFunction::min(const Expression& expression)\n{\n    static const char* funcName = \"min\";\n    return Expression::function(StringView::makeConstant(funcName)).invoke().arguments(expression);\n}\n\nExpression AggregateFunction::sum(const Expression& expression)\n{\n    static const char* funcName = \"sum\";\n    return Expression::function(StringView::makeConstant(funcName)).invoke().arguments(expression);\n}\n\nExpression AggregateFunction::total(const Expression& expression)\n{\n    static const char* funcName = \"total\";\n    return Expression::function(StringView::makeConstant(funcName)).invoke().arguments(expression);\n}\n\nAggregateFunctionOperable::~AggregateFunctionOperable() = default;\n\nExpression AggregateFunctionOperable::avg() const\n{\n    return AggregateFunction::avg(asExpressionOperand());\n}\n\nExpression AggregateFunctionOperable::count() const\n{\n    return AggregateFunction::count(asExpressionOperand());\n}\n\nExpression AggregateFunctionOperable::groupConcat() const\n{\n    return AggregateFunction::groupConcat(asExpressionOperand());\n}\n\nExpression AggregateFunctionOperable::groupConcat(const Expression& seperator) const\n{\n    return AggregateFunction::groupConcat(asExpressionOperand(), seperator);\n}\n\nExpression AggregateFunctionOperable::max() const\n{\n    return AggregateFunction::max(asExpressionOperand());\n}\n\nExpression AggregateFunctionOperable::min() const\n{\n    return AggregateFunction::min(asExpressionOperand());\n}\n\nExpression AggregateFunctionOperable::sum() const\n{\n    return AggregateFunction::sum(asExpressionOperand());\n}\n\nExpression AggregateFunctionOperable::total() const\n{\n    return AggregateFunction::total(asExpressionOperand());\n}\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/extension/AggregateFunction.hpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"ExpressionOperable.hpp\"\n#include \"SQL.hpp\"\n\nnamespace WCDB {\n\nclass WCDB_API AggregateFunction final {\npublic:\n    AggregateFunction() = delete;\n    AggregateFunction(const AggregateFunction&) = delete;\n    AggregateFunction& operator=(const AggregateFunction&) = delete;\n\n    static Expression avg(const Expression& expression);\n    static Expression count(const Expression& expression);\n    static Expression groupConcat(const Expression& expression);\n    static Expression\n    groupConcat(const Expression& expression, const Expression& seperator);\n    static Expression max(const Expression& expression);\n    static Expression min(const Expression& expression);\n    static Expression sum(const Expression& expression);\n    static Expression total(const Expression& expression);\n};\n\nclass WCDB_API AggregateFunctionOperable : virtual public ExpressionOperable {\npublic:\n    virtual ~AggregateFunctionOperable() override = 0;\n    Expression avg() const;\n    Expression count() const;\n    Expression groupConcat() const;\n    Expression groupConcat(const Expression& seperator) const;\n    Expression max() const;\n    Expression min() const;\n    Expression sum() const;\n    Expression total() const;\n};\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/extension/BaseBinding.cpp",
    "content": "//\n// Created by qiuwenchen on 2022/8/27.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"BaseBinding.hpp\"\n#include \"Assertion.hpp\"\n#include \"CompressionConst.hpp\"\n#include \"DecorativeHandle.hpp\"\n#include \"InnerHandle.hpp\"\n#include \"MigratingHandleDecorator.hpp\"\n#include \"Notifier.hpp\"\n#include \"WCDBError.hpp\"\n#include <algorithm>\n#include <string>\n\nnamespace WCDB {\n\nBaseBinding::BaseBinding() = default;\n\nBaseBinding::~BaseBinding() = default;\n\n#pragma mark - Column Def\nconst CaseInsensitiveList<ColumnDef> &BaseBinding::getColumnDefs() const\n{\n    return m_columnDefs;\n}\n\nColumnDef *BaseBinding::getColumnDef(const UnsafeStringView &columnName)\n{\n    ColumnDef *columnDef = nullptr;\n    auto iter = m_columnDefs.caseInsensitiveFind(columnName);\n    if (iter != m_columnDefs.end()) {\n        columnDef = &iter->second;\n    }\n    return columnDef;\n}\n\nconst ColumnDef *BaseBinding::getColumnDef(const UnsafeStringView &columnName) const\n{\n    const ColumnDef *columnDef = nullptr;\n    auto iter = m_columnDefs.caseInsensitiveFind(columnName);\n    if (iter != m_columnDefs.end()) {\n        columnDef = &iter->second;\n    }\n    return columnDef;\n}\n\nvoid BaseBinding::enableAutoIncrementForExistingTable()\n{\n    m_enableAutoIncrementForExistingTable = true;\n}\n\nbool BaseBinding::configAutoincrementIfNeed(const UnsafeStringView &tableName,\n                                            InnerHandle *handle) const\n{\n    auto tableConfig = handle->getTableAttribute(Schema::main(), tableName);\n    if (!tableConfig.succeed()) {\n        return false;\n    }\n    if (tableConfig.value().autoincrement) {\n        return true;\n    }\n    if (tableConfig.value().withoutRowid) {\n        Error error(Error::Code::Error,\n                    Error::Level::Error,\n                    \"Without rowid table can not be configed as autoincrement\");\n        error.infos.insert_or_assign(\"Table\", tableName);\n        error.infos.insert_or_assign(ErrorStringKeyPath, handle->getPath());\n        Notifier::shared().notify(error);\n        return false;\n    }\n    const StringView &integerPrimaryKey = tableConfig.value().integerPrimaryKey;\n    if (integerPrimaryKey.length() == 0) {\n        Error error(Error::Code::Error, Error::Level::Error, \"No integer primary key found\");\n        error.infos.insert_or_assign(\"Table\", tableName);\n        error.infos.insert_or_assign(ErrorStringKeyPath, handle->getPath());\n        Notifier::shared().notify(error);\n        return false;\n    }\n    WCTAssert(m_columnDefs.caseInsensitiveFind(integerPrimaryKey)\n              != m_columnDefs.end());\n\n    bool ret\n    = handle->execute(StatementPragma().pragma(Pragma::writableSchema()).to(true));\n\n    ret = ret && updateMasterTable(tableName, handle);\n\n    ret = ret && updateSequeceTable(tableName, integerPrimaryKey, handle);\n\n    ret = ret && handle->configAutoIncrement(tableName);\n\n    handle->execute(StatementPragma().pragma(Pragma::writableSchema()).to(false));\n\n    return ret;\n}\n\nbool BaseBinding::updateMasterTable(const UnsafeStringView &tableName, InnerHandle *handle) const\n{\n    StatementSelect select\n    = StatementSelect()\n      .select(Column(\"sql\"))\n      .from(Syntax::masterTable)\n      .where(Column(\"name\") == tableName && Column(\"type\") == \"table\");\n    auto sqls = handle->getValues(select, 0);\n    if (sqls.failed()) {\n        return false;\n    }\n    if (sqls.value().size() != 1) {\n        Error error(Error::Code::Error, Error::Level::Error, \"Can not read sql\");\n        error.infos.insert_or_assign(\"Table\", tableName);\n        error.infos.insert_or_assign(ErrorStringKeyPath, handle->getPath());\n        Notifier::shared().notify(error);\n        return false;\n    }\n\n    std::string sql = *sqls.value().begin();\n    std::transform(sql.begin(), sql.end(), sql.begin(), ::toupper);\n\n    size_t startPos = sql.find(\" PRIMARY \");\n    if (startPos == std::string::npos) {\n        reportSqlParseFail(*sqls.value().begin(), tableName, handle);\n        return false;\n    }\n\n    size_t endPos = sql.find(\",\", startPos);\n    if (endPos == std::string::npos) {\n        endPos = sql.find(\")\", startPos);\n    }\n    if (endPos == std::string::npos) {\n        reportSqlParseFail(*sqls.value().begin(), tableName, handle);\n        return false;\n    }\n\n    endPos = std::min(endPos, sql.find(\"NOT\", startPos));\n    endPos = std::min(endPos, sql.find(\"UNIQUE\", startPos));\n    endPos = std::min(endPos, sql.find(\"CHECK\", startPos));\n    endPos = std::min(endPos, sql.find(\"DEFAULT\", startPos));\n    endPos = std::min(endPos, sql.find(\"COLLATE\", startPos));\n    endPos = std::min(endPos, sql.find(\"GENERATED\", startPos));\n    endPos = std::min(endPos, sql.find(\"AS\", startPos));\n\n    std::string originSql = *sqls.value().begin();\n    originSql.insert(endPos, \" AUTOINCREMENT \");\n\n    ConfiguredHandle memoryHandle;\n    memoryHandle.setPath(\":memory:\");\n    if (!memoryHandle.open()) {\n        return false;\n    }\n    if (!memoryHandle.prepare(originSql)) {\n        reportSqlParseFail(*sqls.value().begin(), tableName, handle);\n        return false;\n    }\n    memoryHandle.finalize();\n    memoryHandle.close();\n\n    StatementUpdate update\n    = StatementUpdate()\n      .update(Syntax::masterTable)\n      .set(Column(\"sql\"))\n      .to(originSql)\n      .where(Column(\"name\") == tableName && Column(\"type\") == \"table\");\n\n    return handle->execute(update);\n}\n\nvoid BaseBinding::reportSqlParseFail(const UnsafeStringView &sql,\n                                     const UnsafeStringView &tableName,\n                                     InnerHandle *handle) const\n{\n    Error error(Error::Code::Error, Error::Level::Error, \"Can not parse create table sql\");\n    error.infos.insert_or_assign(\"Table\", tableName);\n    error.infos.insert_or_assign(ErrorStringKeyPath, handle->getPath());\n    error.infos.insert_or_assign(ErrorStringKeySQL, sql);\n    Notifier::shared().notify(error);\n}\n\nbool BaseBinding::updateSequeceTable(const UnsafeStringView &tableName,\n                                     const UnsafeStringView &integerPrimaryKey,\n                                     InnerHandle *handle) const\n{\n    StatementCreateTable createSeq\n    = StatementCreateTable().createTable(Syntax::sequenceTable).ifNotExists();\n    createSeq.define(ColumnDef(\"name\"));\n    createSeq.define(ColumnDef(\"seq\"));\n    if (!handle->execute(createSeq)) {\n        return false;\n    }\n    if (!handle->prepare(\n        StatementSelect().select(Column(integerPrimaryKey).max()).from(tableName))) {\n        return false;\n    }\n    if (!handle->step()) {\n        handle->finalize();\n        return false;\n    }\n    int64_t maxRowid = 0;\n    bool hasContent = false;\n    if (!handle->done()) {\n        maxRowid = handle->getInteger();\n        hasContent = true;\n    }\n    handle->finalize();\n    if (hasContent) {\n        StatementInsert insert = StatementInsert().insertIntoTable(Syntax::sequenceTable);\n        insert.column(\"name\").column(\"seq\");\n        insert.value(tableName).value(std::max(maxRowid, (int64_t) 0));\n        return handle->execute(insert);\n    }\n    return true;\n}\n\n#pragma mark - Table\nbool BaseBinding::createTable(const UnsafeStringView &tableName, InnerHandle *handle) const\n{\n    WCTAssert(handle != nullptr);\n    handle->markErrorNotAllowedWithinTransaction();\n    return handle->runTransactionIfNotInTransaction([&](InnerHandle *handle) {\n        auto exists = handle->tableExists(tableName);\n        if (!exists.succeed()) {\n            return false;\n        }\n        if (exists.value()) {\n            auto optionalColumnNames = handle->getColumns(Schema::main(), tableName);\n            if (!optionalColumnNames.succeed()) {\n                return false;\n            }\n            StringViewSet &columnNames = optionalColumnNames.value();\n            //Check whether the column names exists\n            const auto &columnDefs = getColumnDefs();\n            for (const auto &columnDef : columnDefs) {\n                const StringView &columnName = columnDef.first;\n                auto iter = columnNames.find(columnName);\n                if (iter == columnNames.end() && columnName.hasPrefix(\"'\") && columnName.hasSuffix(\"'\")) {\n                    iter = columnNames.find(columnName.subStr(1, columnName.length() - 2));\n                }\n                if (iter == columnNames.end()) {\n                    //Add new column\n                    if (!handle->addColumn(Schema::main(), tableName, columnDef.second)) {\n                        return false;\n                    }\n                } else {\n                    columnNames.erase(iter);\n                }\n            }\n            for (const auto &columnName : columnNames) {\n                if (columnName.hasPrefix(CompressionColumnTypePrefix)) {\n                    continue;\n                }\n                Error error(Error::Code::Mismatch, Error::Level::Notice, \"Skip column\");\n                error.infos.insert_or_assign(\"Table\", StringView(tableName));\n                error.infos.insert_or_assign(\"Column\", StringView(columnName));\n                error.infos.insert_or_assign(ErrorStringKeyPath, handle->getPath());\n                Notifier::shared().notify(error);\n            }\n            if (m_enableAutoIncrementForExistingTable\n                && !configAutoincrementIfNeed(tableName, handle)) {\n                return false;\n            }\n        } else {\n            if (!handle->execute(generateCreateTableStatement(tableName))) {\n                return false;\n            }\n        }\n        std::list<StatementCreateIndex> createIndexStatements;\n        std::list<StatementDropIndex> dropIndexStatements;\n        std::tie(createIndexStatements, dropIndexStatements)\n        = generateIndexStatements(tableName, !exists.value());\n        for (const StatementCreateIndex &statement : createIndexStatements) {\n            if (!handle->execute(statement)) {\n                return false;\n            }\n        }\n        for (const StatementDropIndex &statement : dropIndexStatements) {\n            if (!handle->execute(statement)) {\n                return false;\n            }\n        }\n        return true;\n    });\n}\n\nbool BaseBinding::createVirtualTable(const UnsafeStringView &tableName, InnerHandle *handle) const\n{\n    WCTAssert(handle != nullptr);\n    return handle->execute(generateCreateVirtualTableStatement(tableName));\n}\n\nStatementCreateTable\nBaseBinding::generateCreateTableStatement(const UnsafeStringView &tableName) const\n{\n    StatementCreateTable statement = statementTable;\n    statement.createTable(tableName).ifNotExists();\n    for (const auto &iter : m_columnDefs) {\n        statement.define(iter.second);\n    }\n    for (const auto &constraint : m_constraints) {\n        statement.constraint(constraint.second);\n    }\n    return statement;\n}\n\nStatementCreateVirtualTable\nBaseBinding::generateCreateVirtualTableStatement(const UnsafeStringView &tableName) const\n{\n    StatementCreateVirtualTable statement = statementVirtualTable;\n    statement.createVirtualTable(tableName).ifNotExists();\n    std::list<StringView> &arguments = statement.syntax().arguments;\n    bool isFTS5 = statement.syntax().module.caseInsensitiveEqual(\"fts5\");\n    for (const auto &iter : m_columnDefs) {\n        if (isFTS5) {\n            bool added = false;\n            for (auto &constrain : iter.second.syntax().constraints) {\n                if (constrain.switcher == WCDB::Syntax::ColumnConstraint::Switch::UnIndexed) {\n                    arguments.push_back(StringView().formatted(\n                    \"%s %s\",\n                    iter.second.syntax().column.getOrCreate().getDescription().data(),\n                    constrain.getDescription().data()));\n                    added = true;\n                    break;\n                }\n            }\n            // FTS5 does not need type\n            if (!added) {\n                arguments.push_back(iter.second.syntax().column.getOrCreate().getDescription());\n            }\n        } else {\n            arguments.push_back(iter.second.getDescription());\n        }\n    }\n    return statement;\n}\n\nbool BaseBinding::tryRecoverColumn(const UnsafeStringView &columnName,\n                                   const UnsafeStringView &tableName,\n                                   const UnsafeStringView &schemaName,\n                                   const UnsafeStringView &sql,\n                                   InnerHandle *handle) const\n{\n    if (m_columnDefs.caseInsensitiveFind(columnName) == m_columnDefs.end()) {\n        return false;\n    }\n    auto exist = handle->tableExists(schemaName, tableName);\n    if (exist.failed() || !exist.value()) {\n        return false;\n    }\n    auto optionalColumnNames = handle->getColumns(schemaName, tableName);\n    if (!optionalColumnNames.succeed()) {\n        return false;\n    }\n    StringViewSet &columnNames = optionalColumnNames.value();\n\n    const auto &columnDefs = getColumnDefs();\n    int matchCount = 0;\n    for (const auto &columnDef : columnDefs) {\n        const StringView &name = columnDef.first;\n        if (columnNames.find(name) != columnNames.end()) {\n            matchCount++;\n        } else if (name.hasPrefix(\"'\") &&\n                   name.hasSuffix(\"'\") &&\n                   columnNames.find(name.subStr(1, name.length() - 2)) != columnNames.end()) {\n            matchCount++;\n        }\n    }\n    if (matchCount != columnDefs.size() - 1 && matchCount < (columnDefs.size() + 1) / 2) {\n        return false;\n    }\n\n    for (const auto &columnDef : columnDefs) {\n        const StringView &name = columnDef.first;\n        if (columnNames.find(name) != columnNames.end()) {\n            continue;\n        } else if (name.hasPrefix(\"'\") &&\n                   name.hasSuffix(\"'\") &&\n                   columnNames.find(name.subStr(1, name.length() - 2)) != columnNames.end()) {\n            continue;\n        }\n        if (columnDef.second.syntax().isPrimaryKey()\n            || columnDef.second.syntax().isUnique()) {\n            continue;\n        }\n        //Add new column\n        if (handle->addColumn(schemaName, tableName, columnDef.second)) {\n            Error error(Error::Code::Warning, Error::Level::Warning, \"Auto add column\");\n            error.infos.insert_or_assign(\n            \"Column\", columnDef.second.syntax().column.getOrCreate().name);\n            error.infos.insert_or_assign(\"Table\", tableName);\n            if (schemaName.length() > 0) {\n                error.infos.insert_or_assign(\"Schema\", schemaName);\n            }\n            error.infos.insert_or_assign(ErrorStringKeySQL, sql);\n            error.infos.insert_or_assign(ErrorStringKeyPath, handle->getPath());\n            Notifier::shared().notify(error);\n        } else {\n            return false;\n        }\n    }\n    DecorativeHandle *decorativeHandle = dynamic_cast<DecorativeHandle *>(handle);\n    if (decorativeHandle != nullptr\n        && decorativeHandle->containDecorator(DecoratorMigratingHandle)) {\n        MigratingHandleDecorator *decorator\n        = decorativeHandle->getDecorator<MigratingHandleDecorator>(DecoratorMigratingHandle);\n        Columns columns;\n        for (const auto &columnDef : columnDefs) {\n            columns.push_back(columnDef.second.syntax().column.getOrCreate().name);\n        }\n        return decorator->rebindUnionView(tableName, columns);\n    }\n    return true;\n}\n\n#pragma mark - Table Constraint\nTableConstraint &BaseBinding::getOrCreateTableConstraint(const UnsafeStringView &name)\n{\n    auto iter = m_constraints.find(name);\n    if (iter == m_constraints.end()) {\n        iter = m_constraints.emplace(name, TableConstraint(name)).first;\n    }\n    return iter->second;\n}\n\n#pragma mark - Index\n\nBaseBinding::Index::Index(const UnsafeStringView &suffix_, bool isFullName)\n: nameOrSuffix(suffix_), isFullName(isFullName), action(Action::Create)\n{\n}\n\nStringView BaseBinding::Index::getIndexName(const UnsafeStringView &tableName)\n{\n    if (!isFullName) {\n        StringView closingQuotation;\n        if (tableName.length() > 2) {\n            if (tableName.hasPrefix(\"'\") && tableName.hasSuffix(\"'\")) {\n                closingQuotation = \"'\";\n            } else if (tableName.hasPrefix(\"\\\"\") && tableName.hasSuffix(\"\\\"\")) {\n                closingQuotation = \"\\\"\";\n            } else if (tableName.hasPrefix(\"[\") && tableName.hasSuffix(\"]\")) {\n                closingQuotation = \"]\";\n            } else if (tableName.hasPrefix(\"`\") && tableName.hasSuffix(\"`\")) {\n                closingQuotation = \"`\";\n            }\n        }\n        std::ostringstream stream;\n        if (closingQuotation.length() == 0) {\n            stream << tableName << nameOrSuffix;\n        } else {\n            stream << UnsafeStringView(tableName.data(), tableName.length() - 1);\n            stream << nameOrSuffix;\n            stream << closingQuotation;\n        }\n        return stream.str();\n    } else {\n        return nameOrSuffix;\n    }\n}\n\nBaseBinding::Index &\nBaseBinding::getOrCreateIndex(const UnsafeStringView &nameOrSuffix, bool isFullName)\n{\n    auto iter = m_indexes.find(nameOrSuffix);\n    if (iter == m_indexes.end()) {\n        iter = m_indexes.emplace(nameOrSuffix, Index(nameOrSuffix, isFullName)).first;\n    }\n    WCTAssert(iter->first == iter->second.nameOrSuffix);\n    return iter->second;\n}\n\nstd::pair<std::list<StatementCreateIndex>, std::list<StatementDropIndex>>\nBaseBinding::generateIndexStatements(const UnsafeStringView &tableName, bool isTableNewlyCreated) const\n{\n    std::pair<std::list<StatementCreateIndex>, std::list<StatementDropIndex>> pairs;\n    for (const auto &iter : m_indexes) {\n        WCTAssert(iter.first == iter.second.nameOrSuffix);\n        Index index = iter.second;\n        switch (index.action) {\n        case Index::Action::CreateForNewlyCreatedTableOnly:\n            if (!isTableNewlyCreated) {\n                break;\n            }\n            // fallthrough\n        case Index::Action::Create: {\n            StatementCreateIndex statement = index.statement;\n            statement.createIndex(index.getIndexName(tableName)).ifNotExists().table(tableName);\n            pairs.first.push_back(statement);\n        } break;\n        default:\n            WCTAssert(index.action == Index::Action::Drop);\n            StatementDropIndex statement\n            = StatementDropIndex().dropIndex(index.getIndexName(tableName)).ifExists();\n            pairs.second.push_back(statement);\n            break;\n        }\n    }\n    return pairs;\n}\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/common/winq/extension/BaseBinding.hpp",
    "content": "//\n// Created by qiuwenchen on 2022/8/27.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"CaseInsensitiveList.hpp\"\n#include \"WINQ.h\"\n\nnamespace WCDB {\n\nclass InnerHandle;\n\nclass WCDB_API BaseBinding {\npublic:\n    BaseBinding();\n    virtual ~BaseBinding() = 0;\n#pragma mark - Column Def\npublic:\n    const CaseInsensitiveList<ColumnDef> &getColumnDefs() const;\n    ColumnDef *getColumnDef(const UnsafeStringView &columnName);\n    const ColumnDef *getColumnDef(const UnsafeStringView &columnName) const;\n    void enableAutoIncrementForExistingTable();\n\nprotected:\n    CaseInsensitiveList<ColumnDef> m_columnDefs;\n    bool m_enableAutoIncrementForExistingTable = false;\n\nprivate:\n    bool configAutoincrementIfNeed(const UnsafeStringView &tableName, InnerHandle *handle) const;\n    bool updateMasterTable(const UnsafeStringView &tableName, InnerHandle *handle) const;\n    bool updateSequeceTable(const UnsafeStringView &tableName,\n                            const UnsafeStringView &integerPrimaryKey,\n                            InnerHandle *handle) const;\n    void reportSqlParseFail(const UnsafeStringView &sql,\n                            const UnsafeStringView &tableName,\n                            InnerHandle *handle) const;\n\n#pragma mark - Table\npublic:\n    bool createTable(const UnsafeStringView &tableName, InnerHandle *handle) const;\n    bool createVirtualTable(const UnsafeStringView &tableName, InnerHandle *handle) const;\n\n    StatementCreateTable\n    generateCreateTableStatement(const UnsafeStringView &tableName) const;\n\n    StatementCreateVirtualTable\n    generateCreateVirtualTableStatement(const UnsafeStringView &tableName) const;\n\n    StatementCreateTable statementTable;\n    StatementCreateVirtualTable statementVirtualTable;\n\n    bool tryRecoverColumn(const UnsafeStringView &columnName,\n                          const UnsafeStringView &tableName,\n                          const UnsafeStringView &schemaName,\n                          const UnsafeStringView &sql,\n                          InnerHandle *handle) const;\n\n#pragma mark - Table Constraint\npublic:\n    TableConstraint &getOrCreateTableConstraint(const UnsafeStringView &name);\n\nprotected:\n    /* constraint name */\n    StringViewMap<TableConstraint> m_constraints;\n\n#pragma mark - Index\npublic:\n    struct Index {\n        Index(const UnsafeStringView &nameOrSuffix, bool isFullName = false);\n        const StringView nameOrSuffix;\n        bool isFullName;\n        enum class Action {\n            Create,\n            CreateForNewlyCreatedTableOnly, // create if and only if the table is newly created by createTable:withClass:\n            Drop,\n        } action;\n        StatementCreateIndex statement;\n        StringView getIndexName(const UnsafeStringView &tableName);\n    };\n    typedef struct Index Index;\n    Index &getOrCreateIndex(const UnsafeStringView &nameOrSuffix, bool isFullName = false);\n\n    std::pair<std::list<StatementCreateIndex>, std::list<StatementDropIndex>>\n    generateIndexStatements(const UnsafeStringView &tableName, bool isTableNewlyCreated) const;\n\nprotected:\n    /* index suffix */\n    StringViewMap<Index> m_indexes;\n};\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/extension/ColumnType.cpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"ColumnType.hpp\"\n#include <cstring>\n\nnamespace WCDB {\n\n#pragma mark - Builtin Type\n//Text\nColumnTypeInfo<ColumnType::Text>::UnderlyingType\nColumnIsTextType<const char *>::asUnderlyingType(const char *text)\n{\n    return UnsafeStringView(text);\n}\n\nvoid ColumnIsTextType<const char *>::setToUnderlyingType(\nconst char *&target, const ColumnTypeInfo<ColumnType::Text>::UnderlyingType &t)\n{\n    int64_t length = t.length() + 1;\n    char *text = new char[length];\n    memcpy(text, t.data(), length * sizeof(char));\n    target = text;\n};\n\nColumnTypeInfo<ColumnType::Text>::UnderlyingType\nColumnIsTextType<char *>::asUnderlyingType(const char *text)\n{\n    return UnsafeStringView(text);\n}\n\nvoid ColumnIsTextType<char *>::setToUnderlyingType(\nchar *&target, const ColumnTypeInfo<ColumnType::Text>::UnderlyingType &t)\n{\n    int64_t length = t.length() + 1;\n    char *text = new char[length];\n    memcpy(text, t.data(), length * sizeof(char));\n    target = text;\n};\n\nColumnTypeInfo<ColumnType::Text>::UnderlyingType\nColumnIsTextType<std::string>::asUnderlyingType(const std::string &text)\n{\n    return UnsafeStringView(text.c_str(), text.length());\n}\n\nvoid ColumnIsTextType<std::string>::setToUnderlyingType(\nstd::string &target, const ColumnTypeInfo<ColumnType::Text>::UnderlyingType &t)\n{\n    target = t;\n}\n\nColumnTypeInfo<ColumnType::Text>::UnderlyingType\nColumnIsTextType<UnsafeStringView>::asUnderlyingType(const UnsafeStringView &text)\n{\n    return text;\n}\n\nvoid ColumnIsTextType<UnsafeStringView>::setToUnderlyingType(\nUnsafeStringView &target, const ColumnTypeInfo<ColumnType::Text>::UnderlyingType &t)\n{\n    target = StringView(t);\n}\n\nColumnTypeInfo<ColumnType::Text>::UnderlyingType\nColumnIsTextType<StringView>::asUnderlyingType(const UnsafeStringView &text)\n{\n    return text;\n}\n\nvoid ColumnIsTextType<StringView>::setToUnderlyingType(\nStringView &target, const ColumnTypeInfo<ColumnType::Text>::UnderlyingType &t)\n{\n    target = t;\n}\n\n//BLOB\nColumnTypeInfo<ColumnType::BLOB>::UnderlyingType\nColumnIsBLOBType<std::vector<unsigned char>>::asUnderlyingType(const std::vector<unsigned char> &blob)\n{\n    return UnsafeData::immutable(blob.data(), blob.size());\n}\n\nvoid ColumnIsBLOBType<std::vector<unsigned char>>::setToUnderlyingType(\nstd::vector<unsigned char> &target, const ColumnTypeInfo<ColumnType::BLOB>::UnderlyingType &t)\n{\n    target.resize(t.size());\n    memcpy(target.data(), t.buffer(), t.size());\n}\n\nColumnTypeInfo<ColumnType::BLOB>::UnderlyingType\nColumnIsBLOBType<UnsafeData>::asUnderlyingType(const UnsafeData &blob)\n{\n    return blob;\n}\n\nvoid ColumnIsBLOBType<UnsafeData>::setToUnderlyingType(\nUnsafeData &target, const ColumnTypeInfo<ColumnType::BLOB>::UnderlyingType &t)\n{\n    target = Data(t);\n}\n\nColumnTypeInfo<ColumnType::BLOB>::UnderlyingType\nColumnIsBLOBType<Data>::asUnderlyingType(const UnsafeData &blob)\n{\n    return blob;\n}\n\nvoid ColumnIsBLOBType<Data>::setToUnderlyingType(\nData &target, const ColumnTypeInfo<ColumnType::BLOB>::UnderlyingType &t)\n{\n    target = t;\n}\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/common/winq/extension/ColumnType.hpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"Data.hpp\"\n#include \"StringView.hpp\"\n#include \"Syntax.h\"\n#include \"SyntaxForwardDeclaration.h\"\n#include <cstdint>\n#include <type_traits>\n#include <vector>\n\nnamespace WCDB {\n\ntypedef Syntax::ColumnType ColumnType;\n\n#pragma mark - Column Type Info\n//Null\ntemplate<ColumnType T = ColumnType::Null>\nstruct ColumnTypeInfo {\n    static constexpr const bool isNull = true;\n    static constexpr const bool isFloat = false;\n    static constexpr const bool isInteger = false;\n    static constexpr const bool isText = false;\n    static constexpr const bool isBLOB = false;\n    static constexpr const bool isBaseType = false;\n    using UnderlyingType = std::nullptr_t;\n    static constexpr const ColumnType type = ColumnType::Null;\n};\n//Float\ntemplate<>\nstruct ColumnTypeInfo<ColumnType::Float> {\n    static constexpr const bool isNull = false;\n    static constexpr const bool isFloat = true;\n    static constexpr const bool isInteger = false;\n    static constexpr const bool isText = false;\n    static constexpr const bool isBLOB = false;\n    static constexpr const bool isBaseType = true;\n    using UnderlyingType = double;\n    static constexpr const ColumnType type = ColumnType::Float;\n};\n//Integer\ntemplate<>\nstruct ColumnTypeInfo<ColumnType::Integer> {\n    static constexpr const bool isNull = false;\n    static constexpr const bool isFloat = false;\n    static constexpr const bool isInteger = true;\n    static constexpr const bool isText = false;\n    static constexpr const bool isBLOB = false;\n    static constexpr const bool isBaseType = true;\n    using UnderlyingType = int64_t;\n    static constexpr const ColumnType type = ColumnType::Integer;\n};\n//Text\ntemplate<>\nstruct ColumnTypeInfo<ColumnType::Text> {\n    static constexpr const bool isNull = false;\n    static constexpr const bool isFloat = false;\n    static constexpr const bool isInteger64 = false;\n    static constexpr const bool isText = true;\n    static constexpr const bool isBLOB = false;\n    static constexpr const bool isBaseType = true;\n    using UnderlyingType = UnsafeStringView;\n    static constexpr const ColumnType type = ColumnType::Text;\n};\n//BLOB\ntemplate<>\nstruct ColumnTypeInfo<ColumnType::BLOB> {\n    static constexpr const bool isNull = false;\n    static constexpr const bool isFloat = false;\n    static constexpr const bool isInteger = false;\n    static constexpr const bool isText = false;\n    static constexpr const bool isBLOB = true;\n    static constexpr const bool isBaseType = false;\n    using UnderlyingType = UnsafeData;\n    static constexpr const ColumnType type = ColumnType::BLOB;\n};\n\n#pragma mark - ColumnIsType\n//Float\ntemplate<typename T, typename Enable = void>\nstruct ColumnIsFloatType : public std::false_type {\npublic:\n    static ColumnTypeInfo<ColumnType::Float>::UnderlyingType asUnderlyingType(const T &);\n};\n//Integer\ntemplate<typename T, typename Enable = void>\nstruct ColumnIsIntegerType : public std::false_type {\npublic:\n    static ColumnTypeInfo<ColumnType::Integer>::UnderlyingType\n    asUnderlyingType(const T &);\n};\n//Text\ntemplate<typename T, typename Enable>\nstruct ColumnIsTextType : public std::false_type {\npublic:\n    static ColumnTypeInfo<ColumnType::Text>::UnderlyingType asUnderlyingType(const T &);\n};\n//BLOB\ntemplate<typename T, typename Enable>\nstruct ColumnIsBLOBType : public std::false_type {\npublic:\n    static ColumnTypeInfo<ColumnType::BLOB>::UnderlyingType asUnderlyingType(const T &);\n};\n\n#pragma mark - ColumnInfo\ntemplate<typename T, typename Enable = void>\nstruct ColumnInfo {};\n//Float\ntemplate<typename T>\nstruct ColumnInfo<T, typename std::enable_if<ColumnIsFloatType<T>::value>::type>\n: public ColumnTypeInfo<ColumnType::Float> {};\n//Integer\ntemplate<typename T>\nstruct ColumnInfo<T, typename std::enable_if<ColumnIsIntegerType<T>::value>::type>\n: public ColumnTypeInfo<ColumnType::Integer> {};\n//Text\ntemplate<typename T>\nstruct ColumnInfo<T, typename std::enable_if<ColumnIsTextType<T>::value>::type>\n: public ColumnTypeInfo<ColumnType::Text> {};\n//BLOB\ntemplate<typename T>\nstruct ColumnInfo<T, typename std::enable_if<ColumnIsBLOBType<T>::value>::type>\n: public ColumnTypeInfo<ColumnType::BLOB> {};\n\n#pragma mark - Builtin Type\n//Float\ntemplate<typename T>\nstruct ColumnIsFloatType<T, typename std::enable_if<std::is_floating_point<T>::value>::type>\n: public std::true_type {\npublic:\n    static ColumnTypeInfo<ColumnType::Float>::UnderlyingType asUnderlyingType(const T &t)\n    {\n        return (ColumnTypeInfo<ColumnType::Float>::UnderlyingType) t;\n    }\n};\n\n//Integer\ntemplate<typename T>\nstruct ColumnIsIntegerType<T, typename std::enable_if<(std::is_integral<T>::value || std::is_enum<T>::value)>::type>\n: public std::true_type {\npublic:\n    static ColumnTypeInfo<ColumnType::Integer>::UnderlyingType\n    asUnderlyingType(const T &t)\n    {\n        return (ColumnTypeInfo<ColumnType::Integer>::UnderlyingType) t;\n    }\n};\n\n//Text\ntemplate<>\nstruct WCDB_API ColumnIsTextType<const char *> : public std::true_type {\npublic:\n    static ColumnTypeInfo<ColumnType::Text>::UnderlyingType\n    asUnderlyingType(const char *text);\n    static void\n    setToUnderlyingType(const char *&target,\n                        const ColumnTypeInfo<ColumnType::Text>::UnderlyingType &t);\n};\n\ntemplate<>\nstruct WCDB_API ColumnIsTextType<char *> : public std::true_type {\npublic:\n    static ColumnTypeInfo<ColumnType::Text>::UnderlyingType\n    asUnderlyingType(const char *text);\n    static void\n    setToUnderlyingType(char *&target,\n                        const ColumnTypeInfo<ColumnType::Text>::UnderlyingType &t);\n};\n\ntemplate<int size>\nstruct ColumnIsTextType<const char[size]> : public std::true_type {\npublic:\n    using ValueType = char[size];\n    static ColumnTypeInfo<ColumnType::Text>::UnderlyingType\n    asUnderlyingType(const ValueType &text)\n    {\n        return text;\n    }\n    static void setToUnderlyingType(const ValueType &,\n                                    const ColumnTypeInfo<ColumnType::Text>::UnderlyingType &)\n    {\n    }\n};\n\ntemplate<int size>\nstruct ColumnIsTextType<char[size]> : public std::true_type {\npublic:\n    using ValueType = char[size];\n    static ColumnTypeInfo<ColumnType::Text>::UnderlyingType\n    asUnderlyingType(const ValueType &text)\n    {\n        return text;\n    }\n    static void\n    setToUnderlyingType(ValueType &target,\n                        const ColumnTypeInfo<ColumnType::Text>::UnderlyingType &t)\n    {\n        memcpy(target, t.data(), std::min(t.size(), (size_t) size));\n        if (t.size() < size) {\n            target[t.size()] = '\\0';\n        }\n    }\n};\n\ntemplate<>\nstruct WCDB_API ColumnIsTextType<std::string> : public std::true_type {\npublic:\n    static ColumnTypeInfo<ColumnType::Text>::UnderlyingType\n    asUnderlyingType(const std::string &text);\n    static void\n    setToUnderlyingType(std::string &target,\n                        const ColumnTypeInfo<ColumnType::Text>::UnderlyingType &t);\n};\n\ntemplate<>\nstruct WCDB_API ColumnIsTextType<UnsafeStringView> : public std::true_type {\npublic:\n    static ColumnTypeInfo<ColumnType::Text>::UnderlyingType\n    asUnderlyingType(const UnsafeStringView &text);\n    static void\n    setToUnderlyingType(UnsafeStringView &target,\n                        const ColumnTypeInfo<ColumnType::Text>::UnderlyingType &t);\n};\n\ntemplate<>\nstruct WCDB_API ColumnIsTextType<StringView> : public std::true_type {\npublic:\n    static ColumnTypeInfo<ColumnType::Text>::UnderlyingType\n    asUnderlyingType(const UnsafeStringView &text);\n    static void\n    setToUnderlyingType(StringView &target,\n                        const ColumnTypeInfo<ColumnType::Text>::UnderlyingType &t);\n};\n\ntemplate<typename T>\nstruct ColumnIsTextType<T, std::enable_if_t<std::is_function<T>::value>>\n: public std::false_type {};\n\n//BLOB\ntemplate<>\nstruct WCDB_API ColumnIsBLOBType<std::vector<unsigned char>> : public std::true_type {\npublic:\n    static ColumnTypeInfo<ColumnType::BLOB>::UnderlyingType\n    asUnderlyingType(const std::vector<unsigned char> &blob);\n    static void\n    setToUnderlyingType(std::vector<unsigned char> &target,\n                        const ColumnTypeInfo<ColumnType::BLOB>::UnderlyingType &t);\n};\n\ntemplate<>\nstruct WCDB_API ColumnIsBLOBType<UnsafeData> : public std::true_type {\npublic:\n    static ColumnTypeInfo<ColumnType::BLOB>::UnderlyingType\n    asUnderlyingType(const UnsafeData &blob);\n    static void\n    setToUnderlyingType(UnsafeData &target,\n                        const ColumnTypeInfo<ColumnType::BLOB>::UnderlyingType &t);\n};\n\ntemplate<>\nstruct WCDB_API ColumnIsBLOBType<Data> : public std::true_type {\npublic:\n    static ColumnTypeInfo<ColumnType::BLOB>::UnderlyingType\n    asUnderlyingType(const UnsafeData &blob);\n    static void\n    setToUnderlyingType(Data &target,\n                        const ColumnTypeInfo<ColumnType::BLOB>::UnderlyingType &t);\n};\n\ntemplate<int size>\nstruct ColumnIsBLOBType<const unsigned char[size]> : public std::true_type {\npublic:\n    using ValueType = unsigned char[size];\n    static ColumnTypeInfo<ColumnType::BLOB>::UnderlyingType\n    asUnderlyingType(const ValueType &data)\n    {\n        return UnsafeData(data, size);\n    }\n\n    static void setToUnderlyingType(const ValueType &,\n                                    const ColumnTypeInfo<ColumnType::BLOB>::UnderlyingType &)\n    {\n    }\n};\n\ntemplate<int size>\nstruct ColumnIsBLOBType<unsigned char[size]> : public std::true_type {\npublic:\n    using ValueType = unsigned char[size];\n    static ColumnTypeInfo<ColumnType::BLOB>::UnderlyingType\n    asUnderlyingType(const ValueType &data)\n    {\n        return UnsafeData((unsigned char *) data, size);\n    }\n    static void\n    setToUnderlyingType(ValueType &target,\n                        const ColumnTypeInfo<ColumnType::BLOB>::UnderlyingType &t)\n    {\n        memcpy(target, t.buffer(), std::min(t.size(), (size_t) size));\n        if (size > t.size()) {\n            memset(target + t.size(), 0, size - t.size());\n        }\n    }\n};\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/common/winq/extension/Convertible.hpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"ColumnType.hpp\"\n#include \"SyntaxForwardDeclaration.h\"\n\nnamespace WCDB {\n\ntemplate<typename T, typename Enable = void>\nclass LiteralValueConvertible final : public std::false_type {\npublic:\n    static LiteralValue asLiteralValue(const T &);\n};\n\ntemplate<typename T, typename Enable = void>\nclass ExpressionConvertible final : public std::false_type {\npublic:\n    static Expression asExpression(const T &);\n};\n\ntemplate<typename T, typename Enable = void>\nclass IndexedColumnConvertible final : public std::false_type {\npublic:\n    static IndexedColumn asIndexedColumn(const T &);\n};\n\ntemplate<typename T, typename Enable = void>\nclass ColumnConvertible final : public std::false_type {\npublic:\n    static Column asColumn(const T &);\n};\n\ntemplate<typename T, typename Enable = void>\nclass ResultColumnConvertible final : public std::false_type {\npublic:\n    static ResultColumn asResultColumn(const T &);\n};\n\ntemplate<typename T, typename Enable = void>\nclass QualifiedTableConvertible final : public std::false_type {\npublic:\n    static QualifiedTable asQualifiedTable(const T &);\n};\n\ntemplate<typename T, typename Enable = void>\nclass OrderingTermConvertible final : public std::false_type {\npublic:\n    static OrderingTerm asOrderingTerm(const T &);\n};\n\ntemplate<typename T, typename Enable = void>\nclass TableOrSubqueryConvertible final : public std::false_type {\npublic:\n    static TableOrSubquery asTableOrSubquery(const T &);\n};\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/extension/ConvertibleImplementation.cpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"WINQ.h\"\n\nnamespace WCDB {\n\nLiteralValue LiteralValueConvertible<bool>::asLiteralValue(const bool &t)\n{\n    return t;\n}\n\nLiteralValue LiteralValueConvertible<Value>::asLiteralValue(const Value &value)\n{\n    switch (value.getType()) {\n    case Value::Type::Null:\n        return nullptr;\n    case Value::Type::Integer:\n        return value.intValue();\n    case Value::Type::Float:\n        return value.floatValue();\n    default:\n        return value.textValue();\n    }\n}\n\nExpression ExpressionConvertible<Column>::asExpression(const Column &column)\n{\n    return column;\n}\n\nExpression ExpressionConvertible<BindParameter>::asExpression(const BindParameter &bindParameter)\n{\n    return bindParameter;\n}\n\nExpression ExpressionConvertible<LiteralValue>::asExpression(const LiteralValue &literalValue)\n{\n    return literalValue;\n}\n\nExpression ExpressionConvertible<Value>::asExpression(const Value &value)\n{\n    return LiteralValue(value);\n}\n\nExpression ExpressionConvertible<RaiseFunction>::asExpression(const RaiseFunction &raiseFunction)\n{\n    return raiseFunction;\n}\n\nExpression ExpressionConvertible<StatementSelect>::asExpression(const StatementSelect &statementSelect)\n{\n    return statementSelect;\n}\n\nIndexedColumn IndexedColumnConvertible<Column>::asIndexedColumn(const Column &column)\n{\n    return column;\n}\n\nIndexedColumn\nIndexedColumnConvertible<Expression>::asIndexedColumn(const Expression &expression)\n{\n    return expression;\n}\n\nResultColumn ResultColumnConvertible<Expression>::asResultColumn(const Expression &expression)\n{\n    return expression;\n}\n\nOrderingTerm OrderingTermConvertible<Expression>::asOrderingTerm(const Expression &expression)\n{\n    return expression;\n}\n\nTableOrSubquery TableOrSubqueryConvertible<Join>::asTableOrSubquery(const Join &join)\n{\n    return join;\n}\n\nTableOrSubquery\nTableOrSubqueryConvertible<StatementSelect>::asTableOrSubquery(const StatementSelect &statementSelect)\n{\n    return statementSelect;\n}\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/extension/ConvertibleImplementation.hpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"Convertible.hpp\"\n#include \"Value.hpp\"\n\nnamespace WCDB {\n\ntemplate<>\nclass WCDB_API LiteralValueConvertible<bool> final : public std::true_type {\npublic:\n    static LiteralValue asLiteralValue(const bool& t);\n};\n\ntemplate<>\nclass LiteralValueConvertible<std::nullptr_t> final : public std::true_type {\npublic:\n    static LiteralValue asLiteralValue(const std::nullptr_t& t)\n    {\n        WCDB_UNUSED(t);\n        return nullptr;\n    }\n};\n\ntemplate<typename T>\nclass LiteralValueConvertible<T, typename std::enable_if<ColumnIsFloatType<T>::value>::type> final\n: public std::true_type {\npublic:\n    static LiteralValue asLiteralValue(const T& t)\n    {\n        return ColumnIsFloatType<T>::asUnderlyingType(t);\n    }\n};\n\ntemplate<class T, bool = std::is_enum<T>::value>\nstruct SafeUnderlyingType : std::underlying_type<T> {};\ntemplate<class T>\nstruct SafeUnderlyingType<T, false> {};\n\ntemplate<typename T, typename Enable = void>\nstruct Is64BitUnsignedInteger : public std::false_type {};\ntemplate<typename T>\nstruct Is64BitUnsignedInteger<T, typename std::enable_if<std::is_integral<T>::value && (sizeof(T) > 4) && std::is_unsigned<T>::value>::type>\n: public std::true_type {};\n\ntemplate<typename T, typename Enable = void>\nstruct Is64BitUnsignedEnum : public std::false_type {};\ntemplate<typename T>\nstruct Is64BitUnsignedEnum<T, typename std::enable_if<std::is_enum<T>::value && (sizeof(T) > 4) && std::is_unsigned<typename SafeUnderlyingType<T>::type>::value>::type>\n: public std::true_type {};\n\ntemplate<typename T>\nclass LiteralValueConvertible<\nT, // 32-bit-integer/enum or 64-bit-signed-integer/enum\ntypename std::enable_if<(std::is_integral<T>::value || std::is_enum<T>::value)\n                        && !Is64BitUnsignedInteger<T>::value && !Is64BitUnsignedEnum<T>::value>::type>\nfinal : public std::true_type {\npublic:\n    static LiteralValue asLiteralValue(const T& t) { return (int64_t) t; }\n};\n\ntemplate<typename T>\nclass LiteralValueConvertible<T, // 64-bit-unsigned-integer\n                              typename std::enable_if<Is64BitUnsignedInteger<T>::value || Is64BitUnsignedEnum<T>::value>::type>\nfinal : public std::true_type {\npublic:\n    static LiteralValue asLiteralValue(const T& t) { return (uint64_t) t; }\n};\n\ntemplate<typename T>\nclass LiteralValueConvertible<T, typename std::enable_if<ColumnIsTextType<T>::value>::type> final\n: public std::true_type {\npublic:\n    static LiteralValue asLiteralValue(const T& t)\n    {\n        return ColumnIsTextType<T>::asUnderlyingType(t);\n    }\n};\n\ntemplate<>\nclass WCDB_API LiteralValueConvertible<Value> final : public std::true_type {\npublic:\n    static LiteralValue asLiteralValue(const Value& value);\n};\n\ntemplate<typename T>\nclass ExpressionConvertible<T, typename std::enable_if<LiteralValueConvertible<T>::value>::type> final\n: public std::true_type {\npublic:\n    static Expression asExpression(const T& t)\n    {\n        return LiteralValueConvertible<T>::asLiteralValue(t);\n    }\n};\n\ntemplate<>\nclass WCDB_API ExpressionConvertible<Column> final : public std::true_type {\npublic:\n    static Expression asExpression(const Column& column);\n};\n\ntemplate<>\nclass WCDB_API ExpressionConvertible<BindParameter> final : public std::true_type {\npublic:\n    static Expression asExpression(const BindParameter& bindParameter);\n};\n\ntemplate<>\nclass WCDB_API ExpressionConvertible<LiteralValue> final : public std::true_type {\npublic:\n    static Expression asExpression(const LiteralValue& literalValue);\n};\n\ntemplate<>\nclass WCDB_API ExpressionConvertible<Value> final : public std::true_type {\npublic:\n    static Expression asExpression(const Value& value);\n};\n\ntemplate<>\nclass WCDB_API ExpressionConvertible<RaiseFunction> final : public std::true_type {\npublic:\n    static Expression asExpression(const RaiseFunction& raiseFunction);\n};\n\ntemplate<>\nclass WCDB_API ExpressionConvertible<StatementSelect> final : public std::true_type {\npublic:\n    static Expression asExpression(const StatementSelect& statementSelect);\n};\n\ntemplate<typename T>\nclass IndexedColumnConvertible<T, typename std::enable_if<ExpressionConvertible<T>::value>::type> final\n: public std::true_type {\npublic:\n    static IndexedColumn asIndexedColumn(const T& t)\n    {\n        return ExpressionConvertible<T>::asExpression(t);\n    }\n};\n\ntemplate<>\nclass WCDB_API IndexedColumnConvertible<Column> final : public std::true_type {\npublic:\n    static IndexedColumn asIndexedColumn(const Column& column);\n};\n\ntemplate<>\nclass WCDB_API IndexedColumnConvertible<Expression> final : public std::true_type {\npublic:\n    static IndexedColumn asIndexedColumn(const Expression& expression);\n};\n\ntemplate<typename T>\nclass ResultColumnConvertible<T, typename std::enable_if<ExpressionConvertible<T>::value>::type> final\n: public std::true_type {\npublic:\n    static ResultColumn asResultColumn(const T& t)\n    {\n        return ExpressionConvertible<T>::asExpression(t);\n    }\n};\n\ntemplate<typename T>\nclass ColumnConvertible<T, typename std::enable_if<ColumnIsTextType<T>::value>::type> final\n: public std::true_type {\npublic:\n    static Column asColumn(const T& t)\n    {\n        return ColumnIsTextType<T>::asUnderlyingType(t);\n    }\n};\n\ntemplate<>\nclass WCDB_API ResultColumnConvertible<Expression> final : public std::true_type {\npublic:\n    static ResultColumn asResultColumn(const Expression& expression);\n};\n\ntemplate<typename T>\nclass QualifiedTableConvertible<T, typename std::enable_if<ColumnIsTextType<T>::value>::type> final\n: public std::true_type {\npublic:\n    static QualifiedTable asQualifiedTable(const T& t)\n    {\n        return ColumnIsTextType<T>::asUnderlyingType(t);\n    }\n};\n\ntemplate<typename T>\nclass OrderingTermConvertible<T, typename std::enable_if<ExpressionConvertible<T>::value>::type> final\n: public std::true_type {\npublic:\n    static OrderingTerm asOrderingTerm(const T& t)\n    {\n        return ExpressionConvertible<T>::asExpression(t);\n    }\n};\n\ntemplate<>\nclass WCDB_API OrderingTermConvertible<Expression> final : public std::true_type {\npublic:\n    static OrderingTerm asOrderingTerm(const Expression& expression);\n};\n\ntemplate<typename T>\nclass TableOrSubqueryConvertible<T, typename std::enable_if<ColumnIsTextType<T>::value>::type> final\n: public std::true_type {\npublic:\n    static TableOrSubquery asTableOrSubquery(const T& t)\n    {\n        return ColumnIsTextType<T>::asUnderlyingType(t);\n    }\n};\n\ntemplate<>\nclass WCDB_API TableOrSubqueryConvertible<Join> final : public std::true_type {\npublic:\n    static TableOrSubquery asTableOrSubquery(const Join& join);\n};\n\ntemplate<>\nclass WCDB_API TableOrSubqueryConvertible<StatementSelect> final : public std::true_type {\npublic:\n    static TableOrSubquery asTableOrSubquery(const StatementSelect& select);\n};\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/extension/CoreFunction.cpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"CompressionConst.hpp\"\n#include \"WINQ.h\"\n\nnamespace WCDB {\n\nExpression CoreFunction::abs(const Expression& expression)\n{\n    static const char* funcName = \"abs\";\n    return Expression::function(StringView::makeConstant(funcName)).invoke().arguments(expression);\n}\n\nExpression CoreFunction::changes()\n{\n    static const char* funcName = \"changes\";\n    return Expression::function(StringView::makeConstant(funcName)).invoke();\n}\n\nExpression CoreFunction::char_(const Expressions& expressions)\n{\n    static const char* funcName = \"char\";\n    return Expression::function(StringView::makeConstant(funcName)).invoke().arguments(expressions);\n}\n\nExpression CoreFunction::coalesce(const Expressions& expressions)\n{\n    static const char* funcName = \"coalesce\";\n    return Expression::function(StringView::makeConstant(funcName)).invoke().arguments(expressions);\n}\n\nExpression CoreFunction::glob(const Expression& pattern, const Expression& string)\n{\n    static const char* funcName = \"glob\";\n    return Expression::function(StringView::makeConstant(funcName)).invoke().arguments({ pattern, string });\n}\n\nExpression CoreFunction::hex(const Expression& expression)\n{\n    static const char* funcName = \"hex\";\n    return Expression::function(StringView::makeConstant(funcName)).invoke().arguments(expression);\n}\n\nExpression CoreFunction::ifNull(const Expression& expression1, const Expression& expression2)\n{\n    static const char* funcName = \"ifnull\";\n    return Expression::function(StringView::makeConstant(funcName)).invoke().arguments({ expression1, expression2 });\n}\n\nExpression CoreFunction::instr(const Expression& string, const Expression& occurrence)\n{\n    static const char* funcName = \"instr\";\n    return Expression::function(StringView::makeConstant(funcName)).invoke().arguments({ string, occurrence });\n}\n\nExpression CoreFunction::lastInsertRowID()\n{\n    static const char* funcName = \"last_insert_rowid\";\n    return Expression::function(StringView::makeConstant(funcName)).invoke();\n}\n\nExpression CoreFunction::length(const Expression& expression)\n{\n    static const char* funcName = \"length\";\n    return Expression::function(StringView::makeConstant(funcName)).invoke().arguments(expression);\n}\n\nExpression CoreFunction::like(const Expression& origin, const Expression& pattern)\n{\n    static const char* funcName = \"like\";\n    return Expression::function(StringView::makeConstant(funcName)).invoke().arguments({ origin, pattern });\n}\n\nExpression\nCoreFunction::like(const Expression& origin, const Expression& pattern, const Expression& escape)\n{\n    static const char* funcName = \"like\";\n    return Expression::function(StringView::makeConstant(funcName)).invoke().arguments({ origin, pattern, escape });\n}\n\nExpression CoreFunction::likelihood(const Expression& unchanged, const Expression& floating)\n{\n    static const char* funcName = \"likelihood\";\n    return Expression::function(StringView::makeConstant(funcName)).invoke().arguments({ unchanged, floating });\n}\n\nExpression CoreFunction::likely(const Expression& unchanged)\n{\n    static const char* funcName = \"likely\";\n    return Expression::function(StringView::makeConstant(funcName)).invoke().arguments(unchanged);\n}\n\nExpression CoreFunction::lower(const Expression& expression)\n{\n    static const char* funcName = \"lower\";\n    return Expression::function(StringView::makeConstant(funcName)).invoke().arguments(expression);\n}\n\nExpression CoreFunction::ltrim(const Expression& expression)\n{\n    static const char* funcName = \"ltrim\";\n    return Expression::function(StringView::makeConstant(funcName)).invoke().arguments(expression);\n}\n\nExpression CoreFunction::ltrim(const Expression& expression, const Expression& removing)\n{\n    static const char* funcName = \"ltrim\";\n    return Expression::function(StringView::makeConstant(funcName)).invoke().arguments({ expression, removing });\n}\n\nExpression CoreFunction::max(const Expressions& expressions)\n{\n    static const char* funcName = \"max\";\n    return Expression::function(StringView::makeConstant(funcName)).invoke().arguments(expressions);\n}\n\nExpression CoreFunction::min(const Expressions& expressions)\n{\n    static const char* funcName = \"min\";\n    return Expression::function(StringView::makeConstant(funcName)).invoke().arguments(expressions);\n}\n\nExpression CoreFunction::nullIf(const Expression& expression1, const Expression& expression2)\n{\n    static const char* funcName = \"nullif\";\n    return Expression::function(StringView::makeConstant(funcName)).invoke().arguments({ expression1, expression2 });\n}\n\nExpression CoreFunction::printf(const Expressions& expressions)\n{\n    static const char* funcName = \"printf\";\n    return Expression::function(StringView::makeConstant(funcName)).invoke().arguments(expressions);\n}\n\nExpression CoreFunction::quote(const Expression& expression)\n{\n    static const char* funcName = \"quote\";\n    return Expression::function(StringView::makeConstant(funcName)).invoke().arguments(expression);\n}\n\nExpression CoreFunction::random()\n{\n    static const char* funcName = \"random\";\n    return Expression::function(StringView::makeConstant(funcName)).invoke();\n}\n\nExpression CoreFunction::randomBLOB(const Expression& n)\n{\n    static const char* funcName = \"randomblob\";\n    return Expression::function(StringView::makeConstant(funcName)).invoke().arguments(n);\n}\n\nExpression CoreFunction::replace(const Expression& origin,\n                                 const Expression& target,\n                                 const Expression& replacement)\n{\n    static const char* funcName = \"replace\";\n    return Expression::function(StringView::makeConstant(funcName))\n    .invoke()\n    .arguments({ origin, target, replacement });\n}\n\nExpression CoreFunction::round(const Expression& expression)\n{\n    static const char* funcName = \"round\";\n    return Expression::function(StringView::makeConstant(funcName)).invoke().arguments(expression);\n}\n\nExpression CoreFunction::round(const Expression& expression, const Expression& digits)\n{\n    static const char* funcName = \"round\";\n    return Expression::function(StringView::makeConstant(funcName)).invoke().arguments({ expression, digits });\n}\n\nExpression CoreFunction::rtrim(const Expression& expression)\n{\n    static const char* funcName = \"rtrim\";\n    return Expression::function(StringView::makeConstant(funcName)).invoke().arguments(expression);\n}\n\nExpression CoreFunction::rtrim(const Expression& expression, const Expression& removing)\n{\n    static const char* funcName = \"rtrim\";\n    return Expression::function(StringView::makeConstant(funcName)).invoke().arguments({ expression, removing });\n}\n\nExpression CoreFunction::soundex(const Expression& expression)\n{\n    static const char* funcName = \"soundex\";\n    return Expression::function(StringView::makeConstant(funcName)).invoke().arguments(expression);\n}\n\nExpression CoreFunction::sqliteCompileOptionGet(const Expression& n)\n{\n    static const char* funcName = \"sqlite_compileoption_get\";\n    return Expression::function(StringView::makeConstant(funcName)).invoke().arguments(n);\n}\n\nExpression CoreFunction::sqliteCompileOptionUsed(const Expression& name)\n{\n    static const char* funcName = \"sqlite_compileoption_used\";\n    return Expression::function(StringView::makeConstant(funcName)).invoke().arguments(name);\n}\n\nExpression CoreFunction::sqliteOffset(const Expression& expression)\n{\n    static const char* funcName = \"sqlite_offset\";\n    return Expression::function(StringView::makeConstant(funcName)).invoke().arguments(expression);\n}\n\nExpression CoreFunction::sqliteSourceID()\n{\n    static const char* funcName = \"sqlite_source_id\";\n    return Expression::function(StringView::makeConstant(funcName)).invoke();\n}\n\nExpression CoreFunction::sqliteVersion()\n{\n    static const char* funcName = \"sqlite_version\";\n    return Expression::function(StringView::makeConstant(funcName)).invoke();\n}\n\nExpression CoreFunction::substr(const Expression& origin, const Expression& offset)\n{\n    static const char* funcName = \"substr\";\n    return Expression::function(StringView::makeConstant(funcName)).invoke().arguments({ origin, offset });\n}\n\nExpression\nCoreFunction::substr(const Expression& origin, const Expression& offset, const Expression& length)\n{\n    static const char* funcName = \"substr\";\n    return Expression::function(StringView::makeConstant(funcName)).invoke().arguments({ origin, offset, length });\n}\n\nExpression CoreFunction::totalChanges()\n{\n    static const char* funcName = \"total_changes\";\n    return Expression::function(StringView::makeConstant(funcName)).invoke();\n}\n\nExpression CoreFunction::trim(const Expression& expression)\n{\n    static const char* funcName = \"trim\";\n    return Expression::function(StringView::makeConstant(funcName)).invoke().arguments(expression);\n}\n\nExpression CoreFunction::trim(const Expression& expression, const Expression& removing)\n{\n    static const char* funcName = \"trim\";\n    return Expression::function(StringView::makeConstant(funcName)).invoke().arguments({ expression, removing });\n}\n\nExpression CoreFunction::typeof_(const Expression& expression)\n{\n    static const char* funcName = \"typeof\";\n    return Expression::function(StringView::makeConstant(funcName)).invoke().arguments(expression);\n}\n\nExpression CoreFunction::unicode(const Expression& expression)\n{\n    static const char* funcName = \"unicode\";\n    return Expression::function(StringView::makeConstant(funcName)).invoke().arguments(expression);\n}\n\nExpression CoreFunction::unlikely(const Expression& expression)\n{\n    static const char* funcName = \"unlikely\";\n    return Expression::function(StringView::makeConstant(funcName)).invoke().arguments(expression);\n}\n\nExpression CoreFunction::upper(const Expression& expression)\n{\n    static const char* funcName = \"upper\";\n    return Expression::function(StringView::makeConstant(funcName)).invoke().arguments(expression);\n}\n\nExpression CoreFunction::zeroBLOB(const Expression& expression)\n{\n    static const char* funcName = \"zeroblob\";\n    return Expression::function(StringView::makeConstant(funcName)).invoke().arguments(expression);\n}\n\nExpression CoreFunction::decompress(const Expression& value, const Expression& compressionType)\n{\n    return Expression::function(DecompressFunctionName).invoke().arguments({ value, compressionType });\n}\n\nCoreFunctionOperable::~CoreFunctionOperable() = default;\n\nExpression CoreFunctionOperable::abs() const\n{\n    return CoreFunction::abs(asExpressionOperand());\n}\n\nExpression CoreFunctionOperable::hex() const\n{\n    return CoreFunction::hex(asExpressionOperand());\n}\n\nExpression CoreFunctionOperable::length() const\n{\n    return CoreFunction::length(asExpressionOperand());\n}\n\nExpression CoreFunctionOperable::lower() const\n{\n    return CoreFunction::lower(asExpressionOperand());\n}\n\nExpression CoreFunctionOperable::ltrim() const\n{\n    return CoreFunction::ltrim(asExpressionOperand());\n}\n\nExpression CoreFunctionOperable::ltrim(const Expression& removing) const\n{\n    return CoreFunction::ltrim(asExpressionOperand(), removing);\n}\n\nExpression CoreFunctionOperable::replace(const Expression& pattern,\n                                         const Expression& replacement) const\n{\n    return CoreFunction::replace(asExpressionOperand(), pattern, replacement);\n}\n\nExpression CoreFunctionOperable::round() const\n{\n    return CoreFunction::round(asExpressionOperand());\n}\n\nExpression CoreFunctionOperable::round(const Expression& digits) const\n{\n    return CoreFunction::round(asExpressionOperand(), digits);\n}\n\nExpression CoreFunctionOperable::rtrim() const\n{\n    return CoreFunction::rtrim(asExpressionOperand());\n}\n\nExpression CoreFunctionOperable::rtrim(const Expression& removing) const\n{\n    return CoreFunction::rtrim(asExpressionOperand(), removing);\n}\n\nExpression CoreFunctionOperable::substr(const Expression& offset) const\n{\n    return CoreFunction::substr(asExpressionOperand(), offset);\n}\n\nExpression\nCoreFunctionOperable::substr(const Expression& offset, const Expression& length) const\n{\n    return CoreFunction::substr(asExpressionOperand(), offset, length);\n}\n\nExpression CoreFunctionOperable::trim() const\n{\n    return CoreFunction::trim(asExpressionOperand());\n}\n\nExpression CoreFunctionOperable::trim(const Expression& removing) const\n{\n    return CoreFunction::trim(asExpressionOperand(), removing);\n}\n\nExpression CoreFunctionOperable::typeof_() const\n{\n    return CoreFunction::typeof_(asExpressionOperand());\n}\n\nExpression CoreFunctionOperable::upper() const\n{\n    return CoreFunction::upper(asExpressionOperand());\n}\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/extension/CoreFunction.hpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"ExpressionOperable.hpp\"\n#include \"SQL.hpp\"\n\nnamespace WCDB {\n\nclass CompressionTableInfo;\n\nclass WCDB_API CoreFunction final {\n    friend CompressionTableInfo;\n\npublic:\n    CoreFunction() = delete;\n    CoreFunction(const CoreFunction&) = delete;\n    CoreFunction& operator=(const CoreFunction&) = delete;\n\n    static Expression abs(const Expression& expression);\n    static Expression changes();\n    static Expression char_(const Expressions& expressions);\n    static Expression coalesce(const Expressions& expressions);\n    static Expression glob(const Expression& pattern, const Expression& string);\n    static Expression hex(const Expression& expression);\n    static Expression ifNull(const Expression& expression1, const Expression& expression2);\n    static Expression instr(const Expression& string, const Expression& occurrence);\n    static Expression lastInsertRowID();\n    static Expression length(const Expression& expression);\n    static Expression like(const Expression& origin, const Expression& pattern);\n    static Expression\n    like(const Expression& origin, const Expression& pattern, const Expression& escape);\n    static Expression likelihood(const Expression& unchanged, const Expression& floating);\n    static Expression likely(const Expression& unchanged);\n    static Expression lower(const Expression& expression);\n    static Expression ltrim(const Expression& expression);\n    static Expression ltrim(const Expression& expression, const Expression& removing);\n    static Expression max(const Expressions& expressions);\n    static Expression min(const Expressions& expressions);\n    static Expression nullIf(const Expression& expression1, const Expression& expression2);\n    static Expression printf(const Expressions& expressions);\n    static Expression quote(const Expression& expression);\n    static Expression random();\n    static Expression randomBLOB(const Expression& n);\n    static Expression\n    replace(const Expression& origin, const Expression& target, const Expression& replacement);\n    static Expression round(const Expression& expression);\n    static Expression round(const Expression& expression, const Expression& digits);\n    static Expression rtrim(const Expression& expression);\n    static Expression rtrim(const Expression& expression, const Expression& removing);\n    static Expression soundex(const Expression& expression);\n    static Expression sqliteCompileOptionGet(const Expression& n);\n    static Expression sqliteCompileOptionUsed(const Expression& name);\n    static Expression sqliteOffset(const Expression& expression);\n    static Expression sqliteSourceID();\n    static Expression sqliteVersion();\n    static Expression substr(const Expression& origin, const Expression& offset);\n    static Expression\n    substr(const Expression& origin, const Expression& offset, const Expression& length);\n    static Expression totalChanges();\n    static Expression trim(const Expression& expression);\n    static Expression trim(const Expression& expression, const Expression& removing);\n    static Expression typeof_(const Expression& expression);\n    static Expression unicode(const Expression& expression);\n    static Expression unlikely(const Expression& expression);\n    static Expression upper(const Expression& expression);\n    static Expression zeroBLOB(const Expression& expression);\n\nprotected:\n    static Expression decompress(const Expression& value, const Expression& compressionType);\n};\n\nclass WCDB_API CoreFunctionOperable : virtual public ExpressionOperable {\npublic:\n    virtual ~CoreFunctionOperable() override = 0;\n    Expression abs() const;\n    Expression hex() const;\n    Expression length() const;\n    Expression lower() const;\n    Expression ltrim() const;\n    Expression ltrim(const Expression& removing) const;\n    Expression replace(const Expression& pattern, const Expression& replacement) const;\n    Expression round() const;\n    Expression round(const Expression& digits) const;\n    Expression rtrim() const;\n    Expression rtrim(const Expression& removing) const;\n    Expression substr(const Expression& offset) const;\n    Expression substr(const Expression& offset, const Expression& length) const;\n    Expression trim() const;\n    Expression trim(const Expression& removing) const;\n    Expression typeof_() const;\n    Expression upper() const;\n};\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/extension/ExpressionOperable.cpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"WINQ.h\"\n\nnamespace WCDB {\n\nExpressionOperable::~ExpressionOperable() = default;\n\n#pragma mark - Unary\nExpressionUnaryOperable::~ExpressionUnaryOperable() = default;\n\nExpression ExpressionUnaryOperable::operator!() const\n{\n    return unaryOperate(Expression::SyntaxType::UnaryOperator::Not);\n}\n\nExpression ExpressionUnaryOperable::operator~() const\n{\n    return unaryOperate(Expression::SyntaxType::UnaryOperator::Tilde);\n}\n\nExpression ExpressionUnaryOperable::isNull() const\n{\n    Expression expression = unaryOperate(Expression::SyntaxType::UnaryOperator::Null);\n    expression.syntax().isNot = false;\n    return expression;\n}\n\nExpression ExpressionUnaryOperable::notNull() const\n{\n    Expression expression = unaryOperate(Expression::SyntaxType::UnaryOperator::Null);\n    expression.syntax().isNot = true;\n    return expression;\n}\n\nExpression\nExpressionUnaryOperable::unaryOperate(const Syntax::Expression::UnaryOperator &op) const\n{\n    Expression expression;\n    expression.syntax().switcher = Expression::SyntaxType::Switch::UnaryOperation;\n    expression.syntax().unaryOperator = op;\n    expression.syntax().expressions.push_back(asExpressionOperand());\n    return expression;\n}\n\n#pragma mark - Binary\nExpressionBinaryOperable::~ExpressionBinaryOperable() = default;\n\nExpression ExpressionBinaryOperable::concat(const Expression &operand) const\n{\n    return binaryOperate(operand, Expression::SyntaxType::BinaryOperator::Concatenate);\n}\n\nExpression ExpressionBinaryOperable::operator*(const Expression &operand) const\n{\n    return binaryOperate(operand, Expression::SyntaxType::BinaryOperator::Multiply);\n}\n\nExpression ExpressionBinaryOperable::operator/(const Expression &operand) const\n{\n    return binaryOperate(operand, Expression::SyntaxType::BinaryOperator::Divide);\n}\n\nExpression ExpressionBinaryOperable::operator%(const Expression &operand) const\n{\n    return binaryOperate(operand, Expression::SyntaxType::BinaryOperator::Modulo);\n}\n\nExpression ExpressionBinaryOperable::operator+(const Expression &operand) const\n{\n    return binaryOperate(operand, Expression::SyntaxType::BinaryOperator::Plus);\n}\n\nExpression ExpressionBinaryOperable::operator-(const Expression &operand) const\n{\n    return binaryOperate(operand, Expression::SyntaxType::BinaryOperator::Minus);\n}\n\nExpression ExpressionBinaryOperable::operator<<(const Expression &operand) const\n{\n    return binaryOperate(operand, Expression::SyntaxType::BinaryOperator::LeftShift);\n}\n\nExpression ExpressionBinaryOperable::operator>>(const Expression &operand) const\n{\n    return binaryOperate(operand, Expression::SyntaxType::BinaryOperator::RightShift);\n}\n\nExpression ExpressionBinaryOperable::operator&(const Expression &operand) const\n{\n    return binaryOperate(operand, Expression::SyntaxType::BinaryOperator::BitwiseAnd);\n}\n\nExpression ExpressionBinaryOperable::operator|(const Expression &operand) const\n{\n    return binaryOperate(operand, Expression::SyntaxType::BinaryOperator::BitwiseOr);\n}\n\nExpression ExpressionBinaryOperable::operator<(const Expression &operand) const\n{\n    return binaryOperate(operand, Expression::SyntaxType::BinaryOperator::Less);\n}\n\nExpression ExpressionBinaryOperable::operator<=(const Expression &operand) const\n{\n    return binaryOperate(operand, Expression::SyntaxType::BinaryOperator::LessOrEqual);\n}\n\nExpression ExpressionBinaryOperable::operator>(const Expression &operand) const\n{\n    return binaryOperate(operand, Expression::SyntaxType::BinaryOperator::Greater);\n}\n\nExpression ExpressionBinaryOperable::operator>=(const Expression &operand) const\n{\n    return binaryOperate(operand, Expression::SyntaxType::BinaryOperator::GreaterOrEqual);\n}\n\nExpression ExpressionBinaryOperable::operator==(const Expression &operand) const\n{\n    if (operand.syntax().switcher == Syntax::Expression::Switch::LiteralValue\n        && operand.syntax().literalValue().switcher == Syntax::LiteralValue::Switch::Null) {\n        return asExpressionOperand().isNull();\n    }\n    return binaryOperate(operand, Expression::SyntaxType::BinaryOperator::Equal);\n}\n\nExpression ExpressionBinaryOperable::operator!=(const Expression &operand) const\n{\n    if (operand.syntax().switcher == Syntax::Expression::Switch::LiteralValue\n        && operand.syntax().literalValue().switcher == Syntax::LiteralValue::Switch::Null) {\n        return asExpressionOperand().notNull();\n    }\n    return binaryOperate(operand, Expression::SyntaxType::BinaryOperator::NotEqual);\n}\n\nExpression ExpressionBinaryOperable::is(const Expression &operand) const\n{\n    Expression expression\n    = binaryOperate(operand, Expression::SyntaxType::BinaryOperator::Is);\n    expression.syntax().isNot = false;\n    return expression;\n}\n\nExpression ExpressionBinaryOperable::isNot(const Expression &operand) const\n{\n    Expression expression\n    = binaryOperate(operand, Expression::SyntaxType::BinaryOperator::Is);\n    expression.syntax().isNot = true;\n    return expression;\n}\n\nExpression ExpressionBinaryOperable::operator&&(const Expression &operand) const\n{\n    return binaryOperate(operand, Expression::SyntaxType::BinaryOperator::And);\n}\n\nExpression ExpressionBinaryOperable::operator||(const Expression &operand) const\n{\n    return binaryOperate(operand, Expression::SyntaxType::BinaryOperator::Or);\n}\n\nExpression ExpressionBinaryOperable::like(const Expression &operand) const\n{\n    Expression expression\n    = binaryOperate(operand, Expression::SyntaxType::BinaryOperator::Like);\n    expression.syntax().isNot = false;\n    return expression;\n}\n\nExpression ExpressionBinaryOperable::glob(const Expression &operand) const\n{\n    Expression expression\n    = binaryOperate(operand, Expression::SyntaxType::BinaryOperator::GLOB);\n    expression.syntax().isNot = false;\n    return expression;\n}\n\nExpression ExpressionBinaryOperable::regexp(const Expression &operand) const\n{\n    Expression expression\n    = binaryOperate(operand, Expression::SyntaxType::BinaryOperator::RegExp);\n    expression.syntax().isNot = false;\n    return expression;\n}\n\nExpression ExpressionBinaryOperable::match(const Expression &operand) const\n{\n    Expression expression\n    = binaryOperate(operand, Expression::SyntaxType::BinaryOperator::Match);\n    expression.syntax().isNot = false;\n    return expression;\n}\n\nExpression ExpressionBinaryOperable::notLike(const Expression &operand) const\n{\n    Expression expression\n    = binaryOperate(operand, Expression::SyntaxType::BinaryOperator::Like);\n    expression.syntax().isNot = true;\n    return expression;\n}\n\nExpression ExpressionBinaryOperable::notGlob(const Expression &operand) const\n{\n    Expression expression\n    = binaryOperate(operand, Expression::SyntaxType::BinaryOperator::GLOB);\n    expression.syntax().isNot = true;\n    return expression;\n}\n\nExpression ExpressionBinaryOperable::notRegexp(const Expression &operand) const\n{\n    Expression expression\n    = binaryOperate(operand, Expression::SyntaxType::BinaryOperator::RegExp);\n    expression.syntax().isNot = true;\n    return expression;\n}\n\nExpression ExpressionBinaryOperable::notMatch(const Expression &operand) const\n{\n    Expression expression\n    = binaryOperate(operand, Expression::SyntaxType::BinaryOperator::Match);\n    expression.syntax().isNot = true;\n    return expression;\n}\n\nExpression\nExpressionBinaryOperable::binaryOperate(const Expression &operand,\n                                        const Syntax::Expression::BinaryOperator &op) const\n{\n    Expression expression;\n    expression.syntax().switcher = Expression::SyntaxType::Switch::BinaryOperation;\n    expression.syntax().binaryOperator = op;\n    expression.syntax().expressions.push_back(asExpressionOperand());\n    expression.syntax().expressions.push_back(operand);\n    return expression;\n}\n\n#pragma mark - Between\nExpressionBetweenOperable::~ExpressionBetweenOperable() = default;\n\nExpression\nExpressionBetweenOperable::between(const Expression &left, const Expression &right) const\n{\n    Expression expression = betweenOperate(left, right);\n    expression.syntax().isNot = false;\n    return expression;\n}\n\nExpression ExpressionBetweenOperable::notBetween(const Expression &left,\n                                                 const Expression &right) const\n{\n    Expression expression = betweenOperate(left, right);\n    expression.syntax().isNot = true;\n    return expression;\n}\n\nExpression ExpressionBetweenOperable::betweenOperate(const Expression &left,\n                                                     const Expression &right) const\n{\n    Expression expression;\n    expression.syntax().switcher = Expression::SyntaxType::Switch::Between;\n    auto &expressionList = expression.syntax().expressions;\n    expressionList.push_back(asExpressionOperand());\n    expressionList.push_back(left);\n    expressionList.push_back(right);\n    return expression;\n}\n\n#pragma mark - In\nExpressionInOperable::~ExpressionInOperable() = default;\n\nExpression ExpressionInOperable::in() const\n{\n    Expression expression;\n    expression.syntax().switcher = Expression::SyntaxType::Switch::In;\n    expression.syntax().isNot = false;\n    expression.syntax().expressions.push_back(asExpressionOperand());\n    expression.syntax().inSwitcher = Expression::SyntaxType::SwitchIn::Empty;\n    return expression;\n}\n\nExpression ExpressionInOperable::notIn() const\n{\n    Expression expression = in();\n    expression.syntax().isNot = true;\n    return expression;\n}\n\nExpression ExpressionInOperable::inTable(const UnsafeStringView &table) const\n{\n    Expression expression;\n    expression.syntax().switcher = Expression::SyntaxType::Switch::In;\n    expression.syntax().isNot = false;\n    expression.syntax().expressions.push_back(asExpressionOperand());\n    expression.syntax().inSwitcher = Expression::SyntaxType::SwitchIn::Table;\n    expression.syntax().table() = table;\n    return expression;\n}\n\nExpression ExpressionInOperable::notInTable(const UnsafeStringView &table) const\n{\n    Expression expression = inTable(table);\n    expression.syntax().isNot = true;\n    return expression;\n}\n\nExpression ExpressionInOperable::in(const StatementSelect &select) const\n{\n    Expression expression;\n    expression.syntax().switcher = Expression::SyntaxType::Switch::In;\n    expression.syntax().isNot = false;\n    expression.syntax().expressions.push_back(asExpressionOperand());\n    expression.syntax().inSwitcher = Expression::SyntaxType::SwitchIn::Select;\n    expression.syntax().select() = select;\n    return expression;\n}\n\nExpression ExpressionInOperable::notIn(const StatementSelect &select) const\n{\n    Expression expression = in(select);\n    expression.syntax().isNot = true;\n    return expression;\n}\n\nExpression ExpressionInOperable::in(const Expressions &expressions) const\n{\n    Expression expression;\n    expression.syntax().switcher = Expression::SyntaxType::Switch::In;\n    expression.syntax().isNot = false;\n    auto &expressionList = expression.syntax().expressions;\n    expressionList.push_back(asExpressionOperand());\n    expression.syntax().inSwitcher = Expression::SyntaxType::SwitchIn::Expressions;\n    expressionList.insert(expressionList.end(), expressions.begin(), expressions.end());\n    return expression;\n}\n\nExpression ExpressionInOperable::notIn(const Expressions &expressions) const\n{\n    Expression expression = in(expressions);\n    expression.syntax().isNot = true;\n    return expression;\n}\n\nExpression ExpressionInOperable::inFunction(const UnsafeStringView &tableFunction) const\n{\n    Expression expression;\n    expression.syntax().switcher = Expression::SyntaxType::Switch::In;\n    expression.syntax().inSwitcher = Expression::SyntaxType::SwitchIn::Function;\n    expression.syntax().isNot = false;\n    expression.syntax().expressions.push_back(asExpressionOperand());\n    expression.syntax().function() = tableFunction;\n    return expression;\n}\n\nExpression ExpressionInOperable::notInFunction(const UnsafeStringView &tableFunction) const\n{\n    Expression expression = inFunction(tableFunction);\n    expression.syntax().isNot = true;\n    return expression;\n}\n\n#pragma mark - Collate\nExpressionCollateOperable::~ExpressionCollateOperable() = default;\n\nExpression ExpressionCollateOperable::collate(const UnsafeStringView &collation) const\n{\n    Expression expression;\n    expression.syntax().switcher = Expression::SyntaxType::Switch::Collate;\n    expression.syntax().expressions.push_back(asExpressionOperand());\n    expression.syntax().collation() = collation;\n    return expression;\n}\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/extension/ExpressionOperable.hpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"SQL.hpp\"\n\nnamespace WCDB {\n\nclass WCDB_API ExpressionOperable {\npublic:\n    virtual ~ExpressionOperable() = 0;\n\nprotected:\n    virtual Expression asExpressionOperand() const = 0;\n};\n\nclass WCDB_API ExpressionUnaryOperable : virtual public ExpressionOperable {\npublic:\n    virtual ~ExpressionUnaryOperable() override = 0;\n    Expression operator!() const;\n    Expression operator~() const;\n    Expression isNull() const;\n    Expression notNull() const;\n\nprivate:\n    Expression unaryOperate(const Syntax::Expression::UnaryOperator &op) const;\n};\n\nclass WCDB_API ExpressionBinaryOperable : virtual public ExpressionOperable {\npublic:\n    virtual ~ExpressionBinaryOperable() override = 0;\n\n    Expression concat(const Expression &operand) const;\n    Expression operator*(const Expression &operand) const;\n    Expression operator/(const Expression &operand) const;\n    Expression operator%(const Expression &operand) const;\n    Expression operator+(const Expression &operand) const;\n    Expression operator-(const Expression &operand) const;\n    Expression operator<<(const Expression &operand) const;\n    Expression operator>>(const Expression &operand) const;\n    Expression operator&(const Expression &operand) const;\n    Expression operator|(const Expression &operand) const;\n    Expression operator<(const Expression &operand) const;\n    Expression operator<=(const Expression &operand) const;\n    Expression operator>(const Expression &operand) const;\n    Expression operator>=(const Expression &operand) const;\n    Expression operator==(const Expression &operand) const;\n    Expression operator!=(const Expression &operand) const;\n    Expression is(const Expression &operand) const;\n    Expression isNot(const Expression &operand) const;\n    Expression operator&&(const Expression &operand) const;\n    Expression operator||(const Expression &operand) const;\n\n    Expression like(const Expression &operand) const;\n    Expression glob(const Expression &operand) const;\n    Expression regexp(const Expression &operand) const;\n    Expression match(const Expression &operand) const;\n    Expression notLike(const Expression &operand) const;\n    Expression notGlob(const Expression &operand) const;\n    Expression notRegexp(const Expression &operand) const;\n    Expression notMatch(const Expression &operand) const;\n\nprivate:\n    Expression binaryOperate(const Expression &operand,\n                             const Syntax::Expression::BinaryOperator &op) const;\n};\n\nclass WCDB_API ExpressionBetweenOperable : virtual public ExpressionOperable {\npublic:\n    virtual ~ExpressionBetweenOperable() override = 0;\n    Expression between(const Expression &left, const Expression &right) const;\n    Expression notBetween(const Expression &left, const Expression &right) const;\n\nprivate:\n    Expression betweenOperate(const Expression &left, const Expression &right) const;\n};\n\nclass WCDB_API ExpressionInOperable : virtual public ExpressionOperable {\npublic:\n    virtual ~ExpressionInOperable() override = 0;\n\n    Expression in() const;\n    Expression notIn() const;\n    Expression inTable(const UnsafeStringView &table) const;\n    Expression notInTable(const UnsafeStringView &table) const;\n    Expression in(const StatementSelect &select) const;\n    Expression notIn(const StatementSelect &select) const;\n    // in(arguments) usually accept multiple arguments, so the seperated method is not provided.\n    Expression in(const Expressions &expressions) const;\n    Expression notIn(const Expressions &expressions) const;\n    Expression inFunction(const UnsafeStringView &tableFunction) const;\n    Expression notInFunction(const UnsafeStringView &tableFunction) const;\n};\n\nclass WCDB_API ExpressionCollateOperable : virtual public ExpressionOperable {\npublic:\n    virtual ~ExpressionCollateOperable() override = 0;\n    Expression collate(const UnsafeStringView &collation) const;\n};\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/extension/FTSFunction.cpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"FTSConst.h\"\n#include \"WINQ.h\"\n\nnamespace WCDB {\n\nExpression FTSFunction::offsets(const Expression &expression)\n{\n    static const char *funcName = \"offsets\";\n    return Expression::function(StringView::makeConstant(funcName)).invoke().arguments(expression);\n}\n\nExpression FTSFunction::fts3Snippet(const Expression &expression,\n                                    const UnsafeStringView &startMatchText,\n                                    const UnsafeStringView &endMatchText,\n                                    const UnsafeStringView &ellipses,\n                                    int columnNumber,\n                                    int approximateNumberOfTokens)\n{\n    static const char *funcName = \"snippet\";\n    return Expression::function(StringView::makeConstant(funcName))\n    .invoke()\n    .arguments({ expression, startMatchText, endMatchText, ellipses, columnNumber, approximateNumberOfTokens });\n}\n\nExpression FTSFunction::matchinfo(const Expression &expression)\n{\n    static const char *funcName = \"matchinfo\";\n    return Expression::function(StringView::makeConstant(funcName)).invoke().arguments(expression);\n}\n\nExpression FTSFunction::bm25(const Expression &expression)\n{\n    static const char *funcName = \"bm25\";\n    return Expression::function(StringView::makeConstant(funcName)).invoke().arguments(expression);\n}\n\nExpression FTSFunction::highlight(const Expression &expression,\n                                  int columnNumber,\n                                  const UnsafeStringView &startMatchText,\n                                  const UnsafeStringView &endMatchText)\n{\n    static const char *funcName = \"highlight\";\n    return Expression::function(StringView::makeConstant(funcName))\n    .invoke()\n    .arguments({ expression, columnNumber, startMatchText, endMatchText });\n}\n\nExpression FTSFunction::fts5Snippet(const Expression &expression,\n                                    int columnNumber,\n                                    const UnsafeStringView &startMatchText,\n                                    const UnsafeStringView &endMatchText,\n                                    const UnsafeStringView &ellipses,\n                                    int approximateNumberOfTokens)\n{\n    static const char *funcName = \"snippet\";\n    return Expression::function(StringView::makeConstant(funcName))\n    .invoke()\n    .arguments({ expression, columnNumber, startMatchText, endMatchText, ellipses, approximateNumberOfTokens });\n}\n\nExpression FTSFunction::substringMatchInfo(const Expression &expression,\n                                           int columnNumber,\n                                           const UnsafeStringView &separators)\n{\n    return Expression::function(StringView::makeConstant(BuiltinAuxiliaryFunction::SubstringMatchInfo))\n    .invoke()\n    .arguments({ expression, columnNumber, separators });\n}\n\nFTSFunctionOperable::~FTSFunctionOperable() = default;\n\nExpression FTSFunctionOperable::offsets() const\n{\n    return FTSFunction::offsets(asExpressionOperand());\n}\n\nExpression FTSFunctionOperable::fts3Snippet(const UnsafeStringView &startMatchText,\n                                            const UnsafeStringView &endMatchText,\n                                            const UnsafeStringView &ellipses,\n                                            int columnNumber,\n                                            int approximateNumberOfTokens) const\n{\n    return FTSFunction::fts3Snippet(\n    asExpressionOperand(), startMatchText, endMatchText, ellipses, columnNumber, approximateNumberOfTokens);\n}\n\nExpression FTSFunctionOperable::matchinfo() const\n{\n    return FTSFunction::matchinfo(asExpressionOperand());\n}\n\nExpression FTSFunctionOperable::bm25() const\n{\n    return FTSFunction::bm25(asExpressionOperand());\n}\n\nExpression FTSFunctionOperable::highlight(int columnNumber,\n                                          const UnsafeStringView &startMatchText,\n                                          const UnsafeStringView &endMatchText) const\n{\n    return FTSFunction::highlight(\n    asExpressionOperand(), columnNumber, startMatchText, endMatchText);\n}\n\nExpression FTSFunctionOperable::fts5Snippet(int columnNumber,\n                                            const UnsafeStringView &startMatchText,\n                                            const UnsafeStringView &endMatchText,\n                                            const UnsafeStringView &ellipses,\n                                            int approximateNumberOfTokens) const\n{\n    return FTSFunction::fts5Snippet(\n    asExpressionOperand(), columnNumber, startMatchText, endMatchText, ellipses, approximateNumberOfTokens);\n}\n\nExpression FTSFunctionOperable::substringMatchInfo(int columnNumber,\n                                                   const UnsafeStringView &separators) const\n{\n    return FTSFunction::substringMatchInfo(asExpressionOperand(), columnNumber, separators);\n}\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/extension/FTSFunction.hpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"ExpressionOperable.hpp\"\n#include \"SQL.hpp\"\n\nnamespace WCDB {\n\nclass WCDB_API FTSFunction final {\npublic:\n    FTSFunction() = delete;\n    FTSFunction(const FTSFunction &) = delete;\n    FTSFunction &operator=(const FTSFunction &) = delete;\n\n    // For FTS3/4\n    static Expression offsets(const Expression &expression);\n    static Expression fts3Snippet(const Expression &expression,\n                                  const UnsafeStringView &startMatchText = \"<b>\",\n                                  const UnsafeStringView &endMatchText = \"</b>\",\n                                  const UnsafeStringView &ellipses = \"<b>...</b>\",\n                                  int columnNumber = -1,\n                                  int approximateNumberOfTokens = -15);\n    static Expression matchinfo(const Expression &expression);\n\n    // For FTS5\n    static Expression bm25(const Expression &expression);\n    static Expression highlight(const Expression &expression,\n                                int columnNumber = 0,\n                                const UnsafeStringView &startMatchText = \"<b>\",\n                                const UnsafeStringView &endMatchText = \"</b>\");\n    static Expression fts5Snippet(const Expression &expression,\n                                  int columnNumber = 0,\n                                  const UnsafeStringView &startMatchText = \"<b>\",\n                                  const UnsafeStringView &endMatchText = \"</b>\",\n                                  const UnsafeStringView &ellipses = \"<b>...</b>\",\n                                  int approximateNumberOfTokens = 64);\n    static Expression substringMatchInfo(const Expression &expression,\n                                         int columnNumber,\n                                         const UnsafeStringView &separators);\n};\n\nclass WCDB_API FTSFunctionOperable : virtual public ExpressionOperable {\npublic:\n    virtual ~FTSFunctionOperable() override = 0;\n\n    // For FTS3/4\n    Expression offsets() const;\n    Expression fts3Snippet(const UnsafeStringView &startMatchText = \"<b>\",\n                           const UnsafeStringView &endMatchText = \"</b>\",\n                           const UnsafeStringView &ellipses = \"<b>...</b>\",\n                           int columnNumber = -1,\n                           int approximateNumberOfTokens = -15) const;\n    Expression matchinfo() const;\n\n    // For FTS5\n    Expression bm25() const;\n    Expression highlight(int columnNumber = 0,\n                         const UnsafeStringView &startMatchText = \"<b>\",\n                         const UnsafeStringView &endMatchText = \"</b>\") const;\n    Expression fts5Snippet(int columnNumber = 0,\n                           const UnsafeStringView &startMatchText = \"<b>\",\n                           const UnsafeStringView &endMatchText = \"</b>\",\n                           const UnsafeStringView &ellipses = \"<b>...</b>\",\n                           int approximateNumberOfTokens = 64) const;\n    Expression substringMatchInfo(int columnNumber, const UnsafeStringView &separators) const;\n};\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/extension/SyntaxForwardDeclaration.h",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"Syntax.h\"\n\nnamespace WCDB {\n\ntypedef Syntax::ColumnType ColumnType;\ntypedef Syntax::Order Order;\ntypedef Syntax::Conflict Conflict;\ntypedef Syntax::MatchType MatchType;\n\nclass Schema;\nclass Column;\nclass BindParameter;\nclass ColumnDef;\nclass Expression;\nclass IndexedColumn;\nclass ColumnConstraint;\nclass TableConstraint;\nclass ForeignKey;\nclass CommonTableExpression;\nclass Expression;\nclass ModuleArgument;\nclass RaiseFunction;\nclass LiteralValue;\nclass Upsert;\nclass Pragma;\nclass Join;\nclass TableOrSubquery;\nclass ResultColumn;\nclass JoinConstraint;\nclass OrderingTerm;\nclass QualifiedTable;\nclass WindowDef;\nclass FrameSpec;\nclass Filter;\n\nclass Statement;\nclass StatementAlterTable;\nclass StatementAttach;\nclass StatementAnalyze;\nclass StatementBegin;\nclass StatementCommit;\nclass StatementRollback;\nclass StatementSavepoint;\nclass StatementRelease;\nclass StatementCreateIndex;\nclass StatementCreateTable;\nclass StatementCreateTrigger;\nclass StatementCreateView;\nclass StatementCreateVirtualTable;\nclass StatementDelete;\nclass StatementDetach;\nclass StatementDropIndex;\nclass StatementDropTable;\nclass StatementDropTrigger;\nclass StatementDropView;\nclass StatementInsert;\nclass StatementSelect;\nclass StatementUpdate;\n\ntemplate<typename T>\nclass SyntaxList;\n\ntypedef SyntaxList<IndexedColumn> IndexedColumns;\ntypedef SyntaxList<Expression> Expressions;\ntypedef SyntaxList<Column> Columns;\ntypedef SyntaxList<ColumnConstraint> ColumnConstraints;\ntypedef SyntaxList<TableOrSubquery> TablesOrSubqueries;\ntypedef SyntaxList<OrderingTerm> OrderingTerms;\ntypedef SyntaxList<TableConstraint> TableConstraints;\ntypedef SyntaxList<ModuleArgument> ModuleArguments;\ntypedef SyntaxList<CommonTableExpression> CommonTableExpressions;\ntypedef SyntaxList<ResultColumn> ResultColumns;\ntypedef SyntaxList<ColumnDef> ColumnDefs;\ntypedef SyntaxList<BindParameter> BindParameters;\ntypedef SyntaxList<LiteralValue> LiteralValues;\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/extension/SyntaxList.hpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"ValueArray.hpp\"\n#include <cassert>\n#include <list>\n#include <type_traits>\n\nnamespace WCDB {\n\nclass SQL;\n\n// list is better than vector here by avoiding memory reallocation\n// we can add random accessibility for this list since the total size is small, usually less than 10\n// all other method is same as std::list, see also: http://www.cplusplus.com/reference/list/list/\ntemplate<typename T>\nclass _SyntaxList : public std::list<T> {\n    static_assert(std::is_base_of<SQL, T>::value, \"\");\n\nprotected:\n    using Super = std::list<T>;\n\npublic:\n    using std::list<T>::list;\n    typedef T SQLType;\n    typedef typename T::SyntaxType SyntaxType;\n\n    _SyntaxList() {}\n\n    _SyntaxList(const T& t) { this->push_back(t); }\n\n    template<typename V, typename Enable = void>\n    struct Convertible : public std::false_type {\n    public:\n        static _SyntaxList<T> asSyntaxList(const V&);\n    };\n\n#if defined(__linux__)\n    template<typename U, typename Enable = void>\n    _SyntaxList(const U& u)\n    {\n        this->emplace_back(u);\n    }\n#else\n    template<typename U>\n    struct Convertible<U, typename std::enable_if<!std::is_base_of<_SyntaxList, U>::value && std::is_constructible<T, U>::value>::type>\n    : public std::true_type {\n    public:\n        static _SyntaxList<T> asSyntaxList(const U& u)\n        {\n            _SyntaxList<T> t;\n            t.emplace_back(u);\n            return t;\n        }\n    };\n\n    template<typename V, typename Enable = typename std::enable_if<Convertible<V>::value>::type>\n    _SyntaxList(const V& v)\n    {\n        *this = Convertible<V>::asSyntaxList(v);\n    }\n#endif\n\n    template<typename U, typename Enable = typename std::enable_if<std::is_constructible<T, U>::value>::type>\n    _SyntaxList(const SyntaxList<U>& others)\n    {\n        for (const auto& other : others) {\n            this->emplace_back(other);\n        }\n    }\n\n    template<typename U, typename Enable = typename std::enable_if<std::is_constructible<T, U>::value>::type>\n    _SyntaxList(const std::initializer_list<U>& others)\n    {\n        for (const auto& other : others) {\n            this->emplace_back(other);\n        }\n    }\n\n    template<typename U, typename Enable = typename std::enable_if<std::is_constructible<T, U>::value>::type>\n    _SyntaxList(const std::vector<U>& others)\n    {\n        for (const auto& other : others) {\n            this->emplace_back(other);\n        }\n    }\n\n    template<typename U, typename Enable = typename std::enable_if<std::is_constructible<T, U>::value>::type>\n    _SyntaxList(const ValueArray<U>& others)\n    {\n        for (const auto& other : others) {\n            this->emplace_back(other);\n        }\n    }\n\n    template<typename U, typename Enable = typename std::enable_if<std::is_constructible<T, U>::value>::type>\n    _SyntaxList(const std::list<U>& others)\n    {\n        for (const auto& other : others) {\n            this->emplace_back(other);\n        }\n    }\n\n    virtual ~_SyntaxList() = default;\n\n    operator std::list<SyntaxType>() const\n    {\n        std::list<SyntaxType> list;\n        for (const auto& sql : *this) {\n            list.push_back(sql.syntax());\n        }\n        return list;\n    }\n\n    const T& operator[](size_t index) const\n    {\n        assert(index < this->size());\n        auto iter = this->begin();\n        while (index != 0) {\n            ++iter;\n            --index;\n        }\n        return *iter;\n    }\n\n    T& operator[](size_t index)\n    {\n        assert(index < this->size());\n        auto iter = this->begin();\n        while (index != 0) {\n            ++iter;\n            --index;\n        }\n        return *iter;\n    }\n\n    StringView getDescription() const\n    {\n        std::ostringstream stream;\n        bool comma = false;\n        for (const auto& sql : *this) {\n            if (comma) {\n                stream << \", \";\n            } else {\n                comma = true;\n            }\n            stream << sql.getDescription();\n        }\n        return StringView(stream.str());\n    }\n};\n\ntemplate<typename T>\nclass SyntaxList final : public _SyntaxList<T> {\npublic:\n    using _SyntaxList<T>::_SyntaxList;\n    ~SyntaxList() override final = default;\n};\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/extension/Value.cpp",
    "content": "//\n// Created by qiuwenchen on 2022/8/10.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"Value.hpp\"\n#include <cstring>\n#include <math.h>\n\nnamespace WCDB {\n\nValue::Value() : m_type(Type::Null)\n{\n    m_intValue = 0;\n}\n\nValue::Value(const Value &other)\n{\n    m_type = other.m_type;\n    copyValue(other);\n}\n\nValue::Value(Value &&other)\n{\n    m_type = other.m_type;\n    moveValue(other);\n}\n\nValue::~Value()\n{\n    clearValue();\n}\n\nValue &Value::operator=(const Value &other)\n{\n    clearValue();\n    m_type = other.m_type;\n    copyValue(other);\n    return *this;\n}\n\nValue &Value::operator=(Value &&other)\n{\n    clearValue();\n    m_type = other.m_type;\n    moveValue(other);\n    return *this;\n}\n\nbool Value::operator==(const Value &other) const\n{\n    if (m_type != other.m_type) {\n        return false;\n    }\n    switch (m_type) {\n    case Type::Null:\n        return true;\n    case Type::Integer:\n        return m_intValue == other.m_intValue;\n    case Type::Float:\n        return m_floatValue == other.m_floatValue;\n    case Type::Text:\n        return (m_textValue).compare(other.m_textValue) == 0;\n    case Type::BLOB: {\n        if (m_blobValue.size() != other.m_blobValue.size()) {\n            return false;\n        }\n        return memcmp(\n               m_blobValue.buffer(), other.m_blobValue.buffer(), m_blobValue.size())\n               == 0;\n    }\n    }\n}\n\nbool Value::operator!=(const Value &other) const\n{\n    return !(operator==(other));\n}\n\nValue::operator bool() const\n{\n    return boolValue();\n}\n\nValue::operator StringView() const\n{\n    return textValue();\n}\n\nValue::operator std::string() const\n{\n    StringView text = textValue();\n    return std::string(text.data(), text.size());\n}\n\nValue::operator Data() const\n{\n    return blobValue();\n}\n\nvoid Value::clearValue()\n{\n    switch (m_type) {\n    case Type::Integer: {\n        m_intValue = 0;\n    } break;\n    case Type::Float: {\n        m_floatValue = 0;\n    } break;\n    case Type::Text: {\n        m_textValue.~StringView();\n    } break;\n    case Type::BLOB: {\n        m_blobValue.~Data();\n    } break;\n    case Type::Null: {\n        return;\n    }\n    }\n}\n\nvoid Value::copyValue(const Value &other)\n{\n    switch (other.m_type) {\n    case Type::Integer: {\n        m_intValue = other.m_intValue;\n    } break;\n    case Type::Float: {\n        m_floatValue = other.m_floatValue;\n    } break;\n    case Type::Text: {\n        new ((void *) std::addressof(m_textValue)) StringView(other.m_textValue);\n    } break;\n    case Type::BLOB: {\n        new ((void *) std::addressof(m_blobValue)) Data(other.m_blobValue);\n    } break;\n    case Type::Null: {\n        return;\n    }\n    }\n}\n\nvoid Value::moveValue(Value &other)\n{\n    switch (other.m_type) {\n    case Type::Integer: {\n        m_intValue = other.m_intValue;\n    } break;\n    case Type::Float: {\n        m_floatValue = other.m_floatValue;\n    } break;\n    case Type::Text: {\n        new ((void *) std::addressof(m_textValue))\n        StringView(std::move(other.m_textValue));\n    } break;\n    case Type::BLOB: {\n        new ((void *) std::addressof(m_blobValue)) Data(std::move(other.m_blobValue));\n    } break;\n    case Type::Null: {\n        return;\n    }\n    }\n}\n\nValue::Type Value::getType() const\n{\n    return m_type;\n}\n\nbool Value::boolValue() const\n{\n    return intValue() > 0;\n}\n\nint64_t Value::intValue() const\n{\n    switch (m_type) {\n    case Type::Integer:\n        return m_intValue;\n    case Type::Float:\n        return (int64_t) m_floatValue;\n    case Type::Text: {\n        if (m_textValue.size() > 0) {\n            return atoll(m_textValue.data());\n        } else {\n            return 0;\n        }\n    }\n    case Type::BLOB: {\n        if (m_blobValue.size() > 0) {\n            return atoll((const char *) m_blobValue.buffer());\n        } else {\n            return 0;\n        }\n    }\n    case Type::Null: {\n        return 0;\n    }\n    }\n}\ndouble Value::floatValue() const\n{\n    switch (m_type) {\n    case Type::Integer:\n        return m_intValue;\n    case Type::Float:\n        return m_floatValue;\n    case Type::Text: {\n        if (m_textValue.size() > 0) {\n            double num = atof(m_textValue.data());\n            if (isnan(num) || isinf(num)) return 0;\n            return num;\n        } else {\n            return 0;\n        }\n    }\n    case Type::BLOB: {\n        if (m_blobValue.size() > 0) {\n            double num = atof((const char *) m_blobValue.buffer());\n            if (isnan(num) || isinf(num)) return 0;\n            return num;\n        } else {\n            return 0;\n        }\n    }\n    case Type::Null: {\n        return 0;\n    }\n    }\n}\n\nStringView Value::textValue() const\n{\n    switch (m_type) {\n    case Type::Integer:\n        return StringView::formatted(\"%lld\", m_intValue);\n    case Type::Float:\n        return StringView::formatted(\"%f\", m_floatValue);\n    case Type::Text: {\n        return m_textValue;\n    }\n    case Type::BLOB: {\n        return StringView((const char *) m_blobValue.buffer(), m_blobValue.size());\n    }\n    case Type::Null: {\n        return StringView();\n    }\n    }\n}\n\nData Value::blobValue() const\n{\n    switch (m_type) {\n    case Type::Integer: {\n        StringView string = StringView::formatted(\"%lld\", m_intValue);\n        return Data((const unsigned char *) string.data(), string.length());\n    }\n    case Type::Float: {\n        StringView string = StringView::formatted(\"%f\", m_floatValue);\n        return Data((const unsigned char *) string.data(), string.length());\n    }\n    case Type::Text: {\n        return Data((const unsigned char *) m_textValue.data(), m_textValue.length());\n    }\n    case Type::BLOB: {\n        return m_blobValue;\n    }\n    case Type::Null: {\n        return Data();\n    }\n    }\n}\n\nbool Value::isNull() const\n{\n    return m_type == Type::Null;\n}\n\nbool Value::isEmpty() const\n{\n    switch (m_type) {\n    case Type::Integer:\n        return m_intValue == 0;\n    case Type::Float:\n        return m_floatValue == 0;\n    case Type::Text:\n        return m_textValue.length() == 0;\n    case Type::BLOB:\n        return m_blobValue.size() == 0;\n    case Type::Null:\n        return true;\n    }\n}\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/extension/Value.hpp",
    "content": "//\n// Created by qiuwenchen on 2022/8/10.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n#include \"ColumnType.hpp\"\n#include \"ValueArray.hpp\"\n#include \"WCDBOptional.hpp\"\n#if defined(__cplusplus) && __cplusplus > 201402L\n#include <optional>\n#endif\n\nnamespace WCDB {\n\ntemplate<class T>\nstruct IsSTDSharedPtr : std::false_type {};\n\ntemplate<class T>\nstruct IsSTDSharedPtr<std::shared_ptr<T>> : std::true_type {};\n\n#if defined(__cplusplus) && __cplusplus > 201402L\ntemplate<class T>\nstruct IsSTDOptional : std::false_type {};\n\ntemplate<class T>\nstruct IsSTDOptional<std::optional<T>> : std::true_type {};\n#endif\n\nclass WCDB_API Value {\npublic:\n#pragma mark - Base Type\n    template<class T, std::enable_if_t<ColumnIsIntegerType<T>::value, int> = 0>\n    Value(const T& value) : m_type(Type::Integer)\n    {\n        m_intValue = ColumnIsIntegerType<T>::asUnderlyingType(value);\n    }\n\n    template<class T, std::enable_if_t<ColumnIsFloatType<T>::value, int> = 0>\n    Value(const T& value) : m_type(Type::Float)\n    {\n        m_floatValue = ColumnIsFloatType<T>::asUnderlyingType(value);\n    }\n\n    template<class T, std::enable_if_t<ColumnIsTextType<T>::value, int> = 0>\n    Value(const T& value) : m_type(Type::Text)\n    {\n        new ((void*) std::addressof(m_textValue))\n        StringView(ColumnIsTextType<T>::asUnderlyingType(value));\n    }\n\n    template<class T, std::enable_if_t<ColumnIsBLOBType<T>::value, int> = 0>\n    Value(const T& value) : m_type(Type::BLOB)\n    {\n        new ((void*) std::addressof(m_blobValue))\n        Data(ColumnIsBLOBType<T>::asUnderlyingType(value));\n    }\n\n    Value(const std::nullptr_t& value) : m_type(Type::Null)\n    {\n        WCDB_UNUSED(value);\n        m_intValue = 0;\n    }\n\n#pragma mark - Shared Pointer\n    template<class T, std::enable_if_t<IsSTDSharedPtr<T>::value && ColumnIsIntegerType<typename T::element_type>::value, int> = 0>\n    Value(const T& value) : m_type(Type::Integer)\n    {\n        if (value != nullptr) {\n            m_intValue\n            = ColumnIsIntegerType<typename T::element_type>::asUnderlyingType(*value);\n        } else {\n            m_type = Type::Null;\n            m_intValue = 0;\n        }\n    }\n\n    template<class T, std::enable_if_t<IsSTDSharedPtr<T>::value && ColumnIsFloatType<typename T::element_type>::value, int> = 0>\n    Value(const T& value) : m_type(Type::Float)\n    {\n        if (value != nullptr) {\n            m_floatValue\n            = ColumnIsFloatType<typename T::element_type>::asUnderlyingType(*value);\n        } else {\n            m_type = Type::Null;\n            m_intValue = 0;\n        }\n    }\n\n    template<class T, std::enable_if_t<IsSTDSharedPtr<T>::value && ColumnIsTextType<typename T::element_type>::value, int> = 0>\n    Value(const T& value) : m_type(Type::Text)\n    {\n        if (value != nullptr) {\n            new ((void*) std::addressof(m_textValue)) StringView(\n            ColumnIsTextType<typename T::element_type>::asUnderlyingType(*value));\n        } else {\n            m_type = Type::Null;\n            m_intValue = 0;\n        }\n    }\n\n    template<class T, std::enable_if_t<IsSTDSharedPtr<T>::value && ColumnIsBLOBType<typename T::element_type>::value, int> = 0>\n    Value(const T& value) : m_type(Type::BLOB)\n    {\n        if (value != nullptr) {\n            new ((void*) std::addressof(m_blobValue))\n            Data(ColumnIsBLOBType<typename T::element_type>::asUnderlyingType(*value));\n        } else {\n            m_type = Type::Null;\n            m_intValue = 0;\n        }\n    }\n\n#pragma mark - STD Optional\n#if defined(__cplusplus) && __cplusplus > 201402L\n    template<class T, std::enable_if_t<IsSTDOptional<T>::value && ColumnIsIntegerType<typename T::value_type>::value, int> = 0>\n    Value(const T& value) : m_type(Type::Integer)\n    {\n        if (value.has_value()) {\n            m_intValue = ColumnIsIntegerType<typename T::value_type>::asUnderlyingType(\n            value.value());\n        } else {\n            m_type = Type::Null;\n            m_intValue = 0;\n        }\n    }\n\n    template<class T, std::enable_if_t<IsSTDOptional<T>::value && ColumnIsFloatType<typename T::value_type>::value, int> = 0>\n    Value(const T& value) : m_type(Type::Float)\n    {\n        if (value.has_value()) {\n            m_floatValue\n            = ColumnIsFloatType<typename T::value_type>::asUnderlyingType(value.value());\n        } else {\n            m_type = Type::Null;\n            m_intValue = 0;\n        }\n    }\n\n    template<class T, std::enable_if_t<IsSTDOptional<T>::value && ColumnIsTextType<typename T::value_type>::value, int> = 0>\n    Value(const T& value) : m_type(Type::Text)\n    {\n        if (value.has_value()) {\n            new ((void*) std::addressof(m_textValue)) StringView(\n            ColumnIsTextType<typename T::value_type>::asUnderlyingType(value.value()));\n        } else {\n            m_type = Type::Null;\n            m_intValue = 0;\n        }\n    }\n\n    template<class T, std::enable_if_t<IsSTDOptional<T>::value && ColumnIsBLOBType<typename T::value_type>::value, int> = 0>\n    Value(const T& value) : m_type(Type::BLOB)\n    {\n        if (value.has_value()) {\n            new ((void*) std::addressof(m_blobValue)) Data(\n            ColumnIsBLOBType<typename T::value_type>::asUnderlyingType(value.value()));\n        } else {\n            m_type = Type::Null;\n            m_intValue = 0;\n        }\n    }\n#endif\n\n#pragma mark - WCDB Optional\n    template<class T, std::enable_if_t<IsWCDBOptional<T>::value && ColumnIsIntegerType<typename T::ValueType>::value, int> = 0>\n    Value(const T& value) : m_type(Type::Integer)\n    {\n        if (value.hasValue()) {\n            m_intValue\n            = ColumnIsIntegerType<typename T::ValueType>::asUnderlyingType(value.value());\n        } else {\n            m_type = Type::Null;\n            m_intValue = 0;\n        }\n    }\n\n    template<class T, std::enable_if_t<IsWCDBOptional<T>::value && ColumnIsFloatType<typename T::ValueType>::value, int> = 0>\n    Value(const T& value) : m_type(Type::Float)\n    {\n        if (value.hasValue()) {\n            m_floatValue\n            = ColumnIsFloatType<typename T::ValueType>::asUnderlyingType(value.value());\n        } else {\n            m_type = Type::Null;\n            m_intValue = 0;\n        }\n    }\n\n    template<class T, std::enable_if_t<IsWCDBOptional<T>::value && ColumnIsTextType<typename T::ValueType>::value, int> = 0>\n    Value(const T& value) : m_type(Type::Text)\n    {\n        if (value.hasValue()) {\n            new ((void*) std::addressof(m_textValue)) StringView(\n            ColumnIsTextType<typename T::ValueType>::asUnderlyingType(value.value()));\n        } else {\n            m_type = Type::Null;\n            m_intValue = 0;\n        }\n    }\n\n    template<class T, std::enable_if_t<IsWCDBOptional<T>::value && ColumnIsBLOBType<typename T::ValueType>::value, int> = 0>\n    Value(const T& value) : m_type(Type::BLOB)\n    {\n        if (value.hasValue()) {\n            new ((void*) std::addressof(m_blobValue))\n            Data(ColumnIsBLOBType<typename T::ValueType>::asUnderlyingType(value.value()));\n        } else {\n            m_type = Type::Null;\n            m_intValue = 0;\n        }\n    }\n\n#pragma mark - Basic\n    Value();\n    Value(const Value& other);\n    Value(Value&& other);\n    ~Value();\n\n    Value& operator=(const Value& other);\n    Value& operator=(Value&& other);\n\n    bool operator==(const Value& other) const;\n    template<class T, std::enable_if_t<std::is_constructible<Value, T>::value, int> = 0>\n    bool operator==(const T& other) const\n    {\n        return operator==(Value(other));\n    }\n\n    bool operator!=(const Value& other) const;\n    template<class T, std::enable_if_t<std::is_constructible<Value, T>::value, int> = 0>\n    bool operator!=(const T& other) const\n    {\n        return operator!=(Value(other));\n    }\n\n    template<class T, std::enable_if_t<ColumnIsIntegerType<T>::value, int> = 0>\n    operator T() const\n    {\n        return (T) intValue();\n    }\n    template<class T, std::enable_if_t<ColumnIsFloatType<T>::value, int> = 0>\n    operator T() const\n    {\n        return (T) floatValue();\n    }\n    operator bool() const;\n    operator StringView() const;\n    operator std::string() const;\n    operator Data() const;\n\n    using Type = ColumnType;\n    Type getType() const;\n\n    bool boolValue() const;\n    int64_t intValue() const;\n    double floatValue() const;\n    StringView textValue() const;\n    Data blobValue() const;\n    bool isNull() const;\n    bool isEmpty() const;\n\nprivate:\n    Type m_type;\n    union {\n        int64_t m_intValue;\n        double m_floatValue;\n        StringView m_textValue;\n        Data m_blobValue;\n    };\n\n    void clearValue();\n    void copyValue(const Value& other);\n    void moveValue(Value& other);\n};\n\ntypedef ValueArray<Value> OneRowValue;\ntypedef ValueArray<Value> OneColumnValue;\ntypedef ValueArray<ValueArray<Value>> MultiRowsValue;\n\ntemplate<typename ValueType>\nusing OptionalValueArray = Optional<ValueArray<ValueType>>;\n\ntypedef Optional<Value> OptionalValue;\ntypedef OptionalValueArray<Value> OptionalOneRow;\ntypedef OptionalValueArray<Value> OptionalOneColumn;\ntypedef OptionalValueArray<ValueArray<Value>> OptionalMultiRows;\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/extension/ValueArray.hpp",
    "content": "//\n// Created by qiuwenchen on 2022/8/15.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include <list>\n#include <type_traits>\n#include <vector>\n\nnamespace WCDB {\n\ntemplate<typename T>\nclass ValueArray : public std::vector<T> {\npublic:\n    using std::vector<T>::vector;\n    ValueArray() = default;\n    ValueArray(const T& value) { this->push_back(value); }\n\n    template<typename U, typename Enable = typename std::enable_if<std::is_constructible<T, U>::value>::type>\n    ValueArray(const U& u)\n    {\n        this->emplace_back(u);\n    }\n\n    template<typename U, typename Enable = typename std::enable_if<std::is_constructible<T, U>::value>::type>\n    ValueArray(const std::list<U>& others)\n    {\n        this->reserve(others.size());\n        for (const auto& other : others) {\n            this->emplace_back(other);\n        }\n    }\n\n    template<typename U, typename Enable = typename std::enable_if<std::is_constructible<T, U>::value>::type>\n    ValueArray(const std::initializer_list<U>& others)\n    {\n        this->reserve(others.size());\n        for (const auto& other : others) {\n            this->emplace_back(other);\n        }\n    }\n\n    template<typename U, typename Enable = typename std::enable_if<std::is_constructible<T, U>::value>::type>\n    ValueArray(const std::vector<U>& others)\n    {\n        this->reserve(others.size());\n        for (const auto& other : others) {\n            this->emplace_back(other);\n        }\n    }\n};\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/identifier/BindParameter.cpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"WINQ.h\"\n\nnamespace WCDB {\n\nBindParameter::BindParameter()\n{\n    syntax().switcher = SyntaxType::Switch::QuestionSign;\n}\n\nBindParameter::BindParameter(int n)\n{\n    syntax().switcher = SyntaxType::Switch::QuestionSign;\n    syntax().n = n;\n}\n\nBindParameter::BindParameter(const UnsafeStringView& name)\n{\n    syntax().switcher = SyntaxType::Switch::ColonSign;\n    syntax().name = name;\n}\n\nBindParameter::~BindParameter() = default;\n\nBindParameters BindParameter::bindParameters(size_t count)\n{\n    BindParameters result;\n    for (size_t i = 1; i <= count; ++i) {\n        result.push_back(BindParameter((int) i));\n    }\n    return result;\n}\n\nBindParameter BindParameter::at(const UnsafeStringView& name)\n{\n    return bindParameter(name, SyntaxType::Switch::AtSign);\n}\n\nBindParameter BindParameter::colon(const UnsafeStringView& name)\n{\n    return bindParameter(name, SyntaxType::Switch::ColonSign);\n}\n\nBindParameter BindParameter::dollar(const UnsafeStringView& name)\n{\n    return bindParameter(name, SyntaxType::Switch::DollarSign);\n}\n\nBindParameter BindParameter::bindParameter(const UnsafeStringView& name,\n                                           const SyntaxType::Switch& switcher)\n{\n    BindParameter bindParameter;\n    bindParameter.syntax().switcher = switcher;\n    bindParameter.syntax().name = name;\n    return bindParameter;\n}\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/identifier/BindParameter.hpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"SQL.hpp\"\n\nnamespace WCDB {\n\nclass WCDB_API BindParameter final : public SpecifiedSyntax<Syntax::BindParameter, SQL> {\npublic:\n    using SpecifiedSyntax<Syntax::BindParameter, SQL>::SpecifiedSyntax;\n    BindParameter();\n    BindParameter(int n);\n    explicit BindParameter(const UnsafeStringView& name);\n    ~BindParameter() override;\n\n    static BindParameters bindParameters(size_t count);\n\n    static BindParameter at(const UnsafeStringView& name);\n    static BindParameter colon(const UnsafeStringView& name);\n    static BindParameter dollar(const UnsafeStringView& name);\n\nprivate:\n    static BindParameter\n    bindParameter(const UnsafeStringView& name, const SyntaxType::Switch& switcher);\n};\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/identifier/Column.cpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"WINQ.h\"\n\nnamespace WCDB {\n\nColumn::Column() = default;\n\nColumn::Column(const UnsafeStringView& name)\n{\n    syntax().wildcard = false;\n    syntax().name = name;\n}\n\nColumn::Column(const UnsafeStringView& name, const BaseBinding* binding)\n{\n    syntax().wildcard = false;\n    syntax().name = name;\n    syntax().tableBinding = binding;\n}\n\nColumn& Column::schema(const Schema& schema)\n{\n    syntax().schema = schema;\n    return *this;\n}\n\nColumn& Column::table(const UnsafeStringView& table)\n{\n    syntax().table = table;\n    return *this;\n}\n\nColumn::~Column() = default;\n\nColumn Column::rowid()\n{\n    return Column(\"rowid\");\n}\n\nResultColumn Column::as(const UnsafeStringView& alias)\n{\n    return ResultColumn(*this).as(alias);\n}\n\nIndexedColumn Column::asIndex() const\n{\n    return IndexedColumn(*this);\n}\n\nIndexedColumn Column::asIndex(const Order& order) const\n{\n    return IndexedColumn(*this).order(order);\n}\n\nIndexedColumn Column::asAscIndex() const\n{\n    return IndexedColumn(*this).order(WCDB::Order::ASC);\n}\n\nIndexedColumn Column::asDescIndex() const\n{\n    return IndexedColumn(*this).order(WCDB::Order::DESC);\n}\n\nOrderingTerm Column::asOrder() const\n{\n    return OrderingTerm(*this);\n}\n\nOrderingTerm Column::asOrder(const Order& order) const\n{\n    return OrderingTerm(*this).order(order);\n}\n\nOrderingTerm Column::asAscOrder() const\n{\n    return OrderingTerm(*this).order(WCDB::Order::ASC);\n}\n\nOrderingTerm Column::asDescOrder() const\n{\n    return OrderingTerm(*this).order(WCDB::Order::DESC);\n}\n\nColumn Column::all()\n{\n    Column result = Column();\n    result.syntax().wildcard = true;\n    return result;\n}\n\nExpression Column::asExpressionOperand() const\n{\n    return Expression(*this);\n}\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/identifier/Column.hpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"AggregateFunction.hpp\"\n#include \"CoreFunction.hpp\"\n#include \"FTSFunction.hpp\"\n#include \"OrderingTerm.hpp\"\n#include \"SQL.hpp\"\n\nnamespace WCDB {\n\nclass WCDB_API Column : public SpecifiedSyntax<Syntax::Column, SQL>,\n                        public ExpressionUnaryOperable,\n                        public ExpressionBinaryOperable,\n                        public ExpressionInOperable,\n                        public ExpressionBetweenOperable,\n                        public ExpressionCollateOperable,\n                        public CoreFunctionOperable,\n                        public AggregateFunctionOperable,\n                        public FTSFunctionOperable {\npublic:\n    template<typename T, typename Enable = typename std::enable_if<ColumnConvertible<T>::value>::type>\n    Column(const T& t)\n    {\n        *this = ColumnConvertible<T>::asColumn(t);\n    }\n    Column();\n    Column(const UnsafeStringView& name);\n    Column(const UnsafeStringView& name, const BaseBinding* binding);\n    virtual ~Column() override;\n\n    Column& table(const UnsafeStringView& table);\n    Column& schema(const Schema& schema);\n\n    ResultColumn as(const UnsafeStringView& alias);\n\n    IndexedColumn asIndex() const;\n    IndexedColumn asIndex(const Order& order) const;\n    IndexedColumn asAscIndex() const;\n    IndexedColumn asDescIndex() const;\n\n    OrderingTerm asOrder() const;\n    OrderingTerm asOrder(const Order& order) const;\n    OrderingTerm asAscOrder() const;\n    OrderingTerm asDescOrder() const;\n\n    static Column rowid();\n    static Column all();\n\nprotected:\n    Expression asExpressionOperand() const override final;\n};\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/identifier/ColumnConstraint.cpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"WINQ.h\"\n\nnamespace WCDB {\n\nColumnConstraint::ColumnConstraint() = default;\n\nColumnConstraint::ColumnConstraint(const UnsafeStringView& name)\n{\n    syntax().name = name;\n}\n\nColumnConstraint::~ColumnConstraint() = default;\n\nColumnConstraint& ColumnConstraint::primaryKey()\n{\n    syntax().switcher = SyntaxType::Switch::PrimaryKey;\n    return *this;\n}\n\nColumnConstraint& ColumnConstraint::order(const Order& order)\n{\n    syntax().order = order;\n    return *this;\n}\n\nColumnConstraint& ColumnConstraint::conflict(const Conflict& conflict)\n{\n    syntax().conflict = conflict;\n    return *this;\n}\n\nColumnConstraint& ColumnConstraint::autoIncrement()\n{\n    syntax().autoIncrement = true;\n    return *this;\n}\n\nColumnConstraint& ColumnConstraint::notNull()\n{\n    syntax().switcher = SyntaxType::Switch::NotNull;\n    return *this;\n}\n\nColumnConstraint& ColumnConstraint::unique()\n{\n    syntax().switcher = SyntaxType::Switch::Unique;\n    return *this;\n}\n\nColumnConstraint& ColumnConstraint::check(const Expression& expression)\n{\n    syntax().switcher = SyntaxType::Switch::Check;\n    syntax().expression = expression;\n    return *this;\n}\n\nColumnConstraint& ColumnConstraint::default_(const Expression& defaultValue)\n{\n    syntax().switcher = SyntaxType::Switch::Default;\n    syntax().expression = defaultValue;\n    return *this;\n}\n\nColumnConstraint& ColumnConstraint::collate(const UnsafeStringView& collation)\n{\n    syntax().switcher = SyntaxType::Switch::Collate;\n    syntax().collation = collation;\n    return *this;\n}\n\nColumnConstraint& ColumnConstraint::foreignKey(const ForeignKey& foreignKey)\n{\n    syntax().switcher = SyntaxType::Switch::ForeignKey;\n    syntax().foreignKeyClause = foreignKey;\n    return *this;\n}\n\nColumnConstraint& ColumnConstraint::unIndexed()\n{\n    syntax().switcher = SyntaxType::Switch::UnIndexed;\n    return *this;\n}\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/identifier/ColumnConstraint.hpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"SQL.hpp\"\n\nnamespace WCDB {\n\nclass WCDB_API ColumnConstraint final\n: public SpecifiedSyntax<Syntax::ColumnConstraint, SQL> {\npublic:\n    ColumnConstraint();\n    explicit ColumnConstraint(const UnsafeStringView& name);\n    ~ColumnConstraint() override;\n\n    ColumnConstraint& primaryKey();\n    ColumnConstraint& order(const Order& order);\n    ColumnConstraint& conflict(const Conflict& conflict);\n    ColumnConstraint& autoIncrement();\n\n    ColumnConstraint& notNull();\n    ColumnConstraint& unique();\n\n    ColumnConstraint& check(const Expression& expression);\n\n    ColumnConstraint& default_(const Expression& defaultValue);\n\n    ColumnConstraint& collate(const UnsafeStringView& collation);\n    ColumnConstraint& foreignKey(const ForeignKey& foreignKey);\n    ColumnConstraint& unIndexed();\n};\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/identifier/ColumnDef.cpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"WINQ.h\"\n\nnamespace WCDB {\n\nColumnDef::ColumnDef() = default;\n\nColumnDef::ColumnDef(const Column& column)\n{\n    syntax().column = column;\n}\n\nColumnDef::ColumnDef(const Column& column, const ColumnType& type)\n{\n    syntax().column = column;\n    syntax().columnType = type;\n}\n\nColumnDef::~ColumnDef() = default;\n\nColumnDef& ColumnDef::constraint(const ColumnConstraint& constraint)\n{\n    syntax().constraints.push_back(constraint);\n    return *this;\n}\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/identifier/ColumnDef.hpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"Column.hpp\"\n#include \"SQL.hpp\"\n\nnamespace WCDB {\n\nclass WCDB_API ColumnDef final : public SpecifiedSyntax<Syntax::ColumnDef, SQL> {\npublic:\n    using SpecifiedSyntax<Syntax::ColumnDef, SQL>::SpecifiedSyntax;\n\n    template<typename T, typename Enable = typename std::enable_if<ColumnConvertible<T>::value>::type>\n    ColumnDef(const T& t) : ColumnDef(ColumnConvertible<T>::asColumn(t))\n    {\n    }\n\n    template<typename T, typename Enable = typename std::enable_if<ColumnConvertible<T>::value>::type>\n    ColumnDef(const T& t, const ColumnType& type)\n    : ColumnDef(ColumnConvertible<T>::asColumn(t), type)\n    {\n    }\n\n    ColumnDef();\n    ColumnDef(const Column& column);\n    ColumnDef(const Column& column, const ColumnType& type);\n    ~ColumnDef() override;\n\n    ColumnDef& constraint(const ColumnConstraint& constraint);\n};\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/identifier/CommonTableExpression.cpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"WINQ.h\"\n\nnamespace WCDB {\n\nCommonTableExpression::CommonTableExpression() = default;\n\nCommonTableExpression::CommonTableExpression(const UnsafeStringView& table)\n{\n    syntax().table = table;\n}\n\nCommonTableExpression::~CommonTableExpression() = default;\n\nCommonTableExpression& CommonTableExpression::column(const Column& column)\n{\n    syntax().columns.push_back(column);\n    return *this;\n}\n\nCommonTableExpression& CommonTableExpression::as(const StatementSelect& select)\n{\n    syntax().select = select;\n    return *this;\n}\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/identifier/CommonTableExpression.hpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"SQL.hpp\"\n\nnamespace WCDB {\n\nclass WCDB_API CommonTableExpression final\n: public SpecifiedSyntax<Syntax::CommonTableExpression, SQL> {\npublic:\n    using SpecifiedSyntax<Syntax::CommonTableExpression, SQL>::SpecifiedSyntax;\n    explicit CommonTableExpression(const UnsafeStringView& table);\n    ~CommonTableExpression() override;\n    CommonTableExpression();\n    CommonTableExpression& column(const Column& column);\n    CommonTableExpression& as(const StatementSelect& select);\n};\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/identifier/Expression.cpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"WINQ.h\"\n\nnamespace WCDB {\n\nExpression::Expression() = default;\n\nExpression::~Expression() = default;\n\nExpression::Expression(const LiteralValue& literalValue)\n{\n    syntax().switcher = SyntaxType::Switch::LiteralValue;\n    syntax().literalValue() = literalValue;\n}\n\nExpression::Expression(const BindParameter& bindParameter)\n{\n    syntax().switcher = SyntaxType::Switch::BindParameter;\n    syntax().bindParameter() = bindParameter;\n}\n\nExpression::Expression(const Column& column)\n{\n    syntax().switcher = SyntaxType::Switch::Column;\n    syntax().column() = column;\n}\n\nExpression::Expression(const StatementSelect& select)\n{\n    syntax().switcher = SyntaxType::Switch::Select;\n    syntax().select() = select;\n}\n\nExpression& Expression::schema(const Schema& schema)\n{\n    syntax().schema() = schema;\n    return *this;\n}\n\nExpression::Expression(const Expressions& expressions)\n{\n    syntax().switcher = SyntaxType::Switch::Expressions;\n    syntax().expressions = expressions;\n}\n\nExpression::Expression(const RaiseFunction& raiseFunction)\n{\n    syntax().switcher = SyntaxType::Switch::RaiseFunction;\n    syntax().raiseFunction() = raiseFunction;\n}\n\nExpression Expression::function(const UnsafeStringView& function)\n{\n    Expression expression;\n    expression.syntax().switcher = SyntaxType::Switch::Function;\n    expression.syntax().function() = function;\n    expression.syntax().useWildcard = false;\n    return expression;\n}\n\nExpression& Expression::invoke()\n{\n    syntax().useWildcard = false;\n    return *this;\n}\n\nExpression& Expression::argument(const Expression& parameter)\n{\n    syntax().expressions.push_back(parameter);\n    syntax().useWildcard = false;\n    return *this;\n}\n\nExpression& Expression::arguments(const Expressions& parameters)\n{\n    syntax().expressions.insert(\n    syntax().expressions.end(), parameters.begin(), parameters.end());\n    syntax().useWildcard = false;\n    return *this;\n}\n\nExpression& Expression::invokeAll()\n{\n    syntax().useWildcard = true;\n    return *this;\n}\n\nExpression& Expression::distinct()\n{\n    syntax().distinct = true;\n    return *this;\n}\n\nExpression Expression::cast(const Expression& expression)\n{\n    Expression result;\n    result.syntax().switcher = SyntaxType::Switch::Cast;\n    result.syntax().expressions.push_back(expression);\n    return result;\n}\n\nExpression& Expression::as(const ColumnType& columnType)\n{\n    syntax().castType = columnType;\n    return *this;\n}\n\nResultColumn Expression::as(const UnsafeStringView& alias)\n{\n    return ResultColumn(*this).as(alias);\n}\n\nOrderingTerm Expression::asAscOrder() const\n{\n    return OrderingTerm(*this).order(WCDB::Order::ASC);\n}\n\nOrderingTerm Expression::asDescOrder() const\n{\n    return OrderingTerm(*this).order(WCDB::Order::DESC);\n}\n\nExpression Expression::exists(const StatementSelect& select)\n{\n    Expression expression;\n    expression.syntax().switcher = SyntaxType::Switch::Exists;\n    expression.syntax().isNot = false;\n    expression.syntax().select() = select;\n    return expression;\n}\n\nExpression Expression::notExists(const StatementSelect& select)\n{\n    Expression expression;\n    expression.syntax().switcher = SyntaxType::Switch::Exists;\n    expression.syntax().isNot = true;\n    expression.syntax().select() = select;\n    return expression;\n}\n\nExpression Expression::case_(const Expression& expression)\n{\n    Expression result;\n    result.syntax().switcher = SyntaxType::Switch::Case;\n    result.syntax().hasCase = true;\n    result.syntax().expressions.push_back(expression);\n    return result;\n}\n\nExpression Expression::case_()\n{\n    Expression result;\n    result.syntax().hasCase = false;\n    result.syntax().switcher = SyntaxType::Switch::Case;\n    return result;\n}\n\nExpression& Expression::when(const Expression& expression)\n{\n    syntax().expressions.push_back(expression);\n    return *this;\n}\n\nExpression& Expression::then(const Expression& expression)\n{\n    syntax().expressions.push_back(expression);\n    return *this;\n}\n\nExpression& Expression::else_(const Expression& expression)\n{\n    syntax().hasElse = true;\n    syntax().expressions.push_back(expression);\n    return *this;\n}\n\nExpression& Expression::escape(const Expression& operand)\n{\n    syntax().escape = true;\n    syntax().expressions.push_back(operand);\n    return *this;\n}\n\nExpression Expression::windowFunction(const UnsafeStringView& function)\n{\n    Expression expression;\n    expression.syntax().switcher = SyntaxType::Switch::Window;\n    expression.syntax().function() = function;\n    return expression;\n}\n\nExpression& Expression::filter(const Expression& condition)\n{\n    syntax().filter() = Filter().where(condition);\n    return *this;\n}\n\nExpression& Expression::over(const WindowDef& windowDef)\n{\n    syntax().windowDef() = windowDef;\n    return *this;\n}\n\nExpression& Expression::over(const UnsafeStringView& window)\n{\n    syntax().windowName() = window;\n    return *this;\n}\n\nExpression Expression::asExpressionOperand() const\n{\n    return *this;\n}\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/identifier/Expression.hpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"AggregateFunction.hpp\"\n#include \"CoreFunction.hpp\"\n#include \"FTSFunction.hpp\"\n#include \"SQL.hpp\"\n\nnamespace WCDB {\n\nclass WCDB_API Expression final : public SpecifiedSyntax<Syntax::Expression, SQL>,\n                                  public ExpressionUnaryOperable,\n                                  public ExpressionBinaryOperable,\n                                  public ExpressionInOperable,\n                                  public ExpressionBetweenOperable,\n                                  public ExpressionCollateOperable,\n                                  public CoreFunctionOperable,\n                                  public AggregateFunctionOperable,\n                                  public FTSFunctionOperable {\npublic:\n    using SpecifiedSyntax<Syntax::Expression, SQL>::SpecifiedSyntax;\n    ~Expression() override;\n\n    template<typename T, typename Enable = typename std::enable_if<ExpressionConvertible<T>::value>::type>\n    Expression(const T& t)\n    {\n        *this = ExpressionConvertible<T>::asExpression(t);\n    }\n\n    Expression();\n    Expression(const LiteralValue& literalValue);\n    Expression(const BindParameter& bindParameter);\n    Expression(const Column& column);\n    Expression(const StatementSelect& select);\n\n    explicit Expression(const Expressions& expressions);\n    Expression(const RaiseFunction& raiseFunction);\n\n    static Expression function(const UnsafeStringView& function);\n    Expression& schema(const Schema& schema);\n    Expression& invoke();\n    Expression& argument(const Expression& parameter);\n    Expression& arguments(const Expressions& parameters);\n    Expression& invokeAll();\n\n    Expression& distinct();\n\n    static Expression cast(const Expression& expression);\n    Expression& as(const ColumnType& columnType);\n\n    ResultColumn as(const UnsafeStringView& alias);\n\n    OrderingTerm asAscOrder() const;\n    OrderingTerm asDescOrder() const;\n\n    static Expression exists(const StatementSelect& select);\n    static Expression notExists(const StatementSelect& select);\n\n    static Expression case_(const Expression& expression);\n    static Expression case_();\n    Expression& when(const Expression& expression);\n    Expression& then(const Expression& expression);\n    Expression& else_(const Expression& expression);\n\n    Expression& escape(const Expression& operand);\n\n    static Expression windowFunction(const UnsafeStringView& function);\n    Expression& filter(const Expression& condition);\n    Expression& over(const WindowDef& windowDef);\n    Expression& over(const UnsafeStringView& window);\n\nprotected:\n    Expression asExpressionOperand() const override final;\n};\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/identifier/Filter.cpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"WINQ.h\"\n\nnamespace WCDB {\n\nFilter::Filter() = default;\n\nFilter::~Filter() = default;\n\nFilter& Filter::where(const Expression& expression)\n{\n    syntax().expression = expression;\n    return *this;\n}\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/identifier/Filter.hpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"SQL.hpp\"\n\nnamespace WCDB {\n\nclass WCDB_API Filter final : public SpecifiedSyntax<Syntax::Filter, SQL> {\npublic:\n    using SpecifiedSyntax<Syntax::Filter, SQL>::SpecifiedSyntax;\n    ~Filter() override;\n    Filter();\n    Filter& where(const Expression& expression);\n};\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/identifier/ForeignKey.cpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"WINQ.h\"\n\nnamespace WCDB {\n\nForeignKey::ForeignKey() = default;\n\nForeignKey::~ForeignKey() = default;\n\nForeignKey& ForeignKey::references(const UnsafeStringView& table)\n{\n    syntax().foreignTable = table;\n    return *this;\n}\n\nForeignKey& ForeignKey::column(const Column& column)\n{\n    syntax().columns.push_back(column);\n    return *this;\n}\n\nForeignKey& ForeignKey::onDeleteSetNull()\n{\n    syntax().switchers.push_back(SyntaxType::Switch::OnDeleteSetNull);\n    return *this;\n}\n\nForeignKey& ForeignKey::onDeleteSetDefault()\n{\n    syntax().switchers.push_back(SyntaxType::Switch::OnDeleteSetDefault);\n    return *this;\n}\n\nForeignKey& ForeignKey::onDeleteCascade()\n{\n    syntax().switchers.push_back(SyntaxType::Switch::OnDeleteCascade);\n    return *this;\n}\n\nForeignKey& ForeignKey::onDeleteRestrict()\n{\n    syntax().switchers.push_back(SyntaxType::Switch::OnDeleteRestrict);\n    return *this;\n}\n\nForeignKey& ForeignKey::onDeleteNoAction()\n{\n    syntax().switchers.push_back(SyntaxType::Switch::OnDeleteNoAction);\n    return *this;\n}\n\nForeignKey& ForeignKey::onUpdateSetNull()\n{\n    syntax().switchers.push_back(SyntaxType::Switch::OnUpdateSetNull);\n    return *this;\n}\n\nForeignKey& ForeignKey::onUpdateSetDefault()\n{\n    syntax().switchers.push_back(SyntaxType::Switch::OnUpdateSetDefault);\n    return *this;\n}\n\nForeignKey& ForeignKey::onUpdateCascade()\n{\n    syntax().switchers.push_back(SyntaxType::Switch::OnUpdateCascade);\n    return *this;\n}\n\nForeignKey& ForeignKey::onUpdateRestrict()\n{\n    syntax().switchers.push_back(SyntaxType::Switch::OnUpdateRestrict);\n    return *this;\n}\n\nForeignKey& ForeignKey::onUpdateNoAction()\n{\n    syntax().switchers.push_back(SyntaxType::Switch::OnUpdateNoAction);\n    return *this;\n}\n\nForeignKey& ForeignKey::match(const MatchType& type)\n{\n    syntax().matchType = type;\n    return *this;\n}\n\nForeignKey& ForeignKey::deferrable()\n{\n    syntax().deferrable = SyntaxType::Deferrable::Deferrable;\n    return *this;\n}\n\nForeignKey& ForeignKey::deferrableInitiallyDeferred()\n{\n    syntax().deferrable = SyntaxType::Deferrable::DeferrableInitiallyDeferred;\n    return *this;\n}\n\nForeignKey& ForeignKey::deferrableInitiallyImmediate()\n{\n    syntax().deferrable = SyntaxType::Deferrable::DeferrableInitiallyImmediate;\n    return *this;\n}\n\nForeignKey& ForeignKey::notDeferrable()\n{\n    syntax().deferrable = SyntaxType::Deferrable::NotDeferrable;\n    return *this;\n}\n\nForeignKey& ForeignKey::notDeferrableInitiallyDeferred()\n{\n    syntax().deferrable = SyntaxType::Deferrable::NotDeferrableInitiallyDeferred;\n    return *this;\n}\n\nForeignKey& ForeignKey::notDeferrableInitiallyImmediate()\n{\n    syntax().deferrable = SyntaxType::Deferrable::NotDeferrableInitiallyImmediate;\n    return *this;\n}\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/identifier/ForeignKey.hpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"SQL.hpp\"\n\nnamespace WCDB {\n\nclass WCDB_API ForeignKey final : public SpecifiedSyntax<Syntax::ForeignKeyClause, SQL> {\npublic:\n    ForeignKey();\n    ~ForeignKey() override;\n\n    ForeignKey& references(const UnsafeStringView& table);\n    ForeignKey& column(const Column& column);\n\n    ForeignKey& onDeleteSetNull();\n    ForeignKey& onDeleteSetDefault();\n    ForeignKey& onDeleteCascade();\n    ForeignKey& onDeleteRestrict();\n    ForeignKey& onDeleteNoAction();\n\n    ForeignKey& onUpdateSetNull();\n    ForeignKey& onUpdateSetDefault();\n    ForeignKey& onUpdateCascade();\n    ForeignKey& onUpdateRestrict();\n    ForeignKey& onUpdateNoAction();\n\n    ForeignKey& match(const MatchType& match);\n\n    ForeignKey& deferrable();\n    ForeignKey& deferrableInitiallyDeferred();\n    ForeignKey& deferrableInitiallyImmediate();\n    ForeignKey& notDeferrable();\n    ForeignKey& notDeferrableInitiallyDeferred();\n    ForeignKey& notDeferrableInitiallyImmediate();\n};\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/identifier/FrameSpec.cpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"WINQ.h\"\n\nnamespace WCDB {\n\nFrameSpec::FrameSpec() = default;\n\nFrameSpec::~FrameSpec() = default;\n\nFrameSpec& FrameSpec::range()\n{\n    syntax().switcher = SyntaxType::Switch::Range;\n    return *this;\n}\n\nFrameSpec& FrameSpec::rows()\n{\n    syntax().switcher = SyntaxType::Switch::Rows;\n    return *this;\n}\n\nFrameSpec& FrameSpec::unboundedPreceding()\n{\n    syntax().between = false;\n    syntax().firstEvent = SyntaxType::FirstEvent::UnboundedPreceding;\n    return *this;\n}\n\nFrameSpec& FrameSpec::preceding(const Expression& expression)\n{\n    syntax().between = false;\n    syntax().firstEvent = SyntaxType::FirstEvent::Preceding;\n    syntax().expression1 = expression;\n    return *this;\n}\n\nFrameSpec& FrameSpec::currentRow()\n{\n    syntax().between = false;\n    syntax().firstEvent = SyntaxType::FirstEvent::CurrentRow;\n    return *this;\n}\n\nFrameSpec& FrameSpec::betweenUnboundedPreceding()\n{\n    syntax().between = true;\n    syntax().firstEvent = SyntaxType::FirstEvent::UnboundedPreceding;\n    return *this;\n}\n\nFrameSpec& FrameSpec::betweenPreceding(const Expression& expression)\n{\n    syntax().between = true;\n    syntax().firstEvent = SyntaxType::FirstEvent::Preceding;\n    syntax().expression1 = expression;\n    return *this;\n}\n\nFrameSpec& FrameSpec::betweenCurrentRow()\n{\n    syntax().between = true;\n    syntax().firstEvent = SyntaxType::FirstEvent::CurrentRow;\n    return *this;\n}\n\nFrameSpec& FrameSpec::betweenFollowing(const Expression& expression)\n{\n    syntax().between = true;\n    syntax().firstEvent = SyntaxType::FirstEvent::Following;\n    syntax().expression1 = expression;\n    return *this;\n}\n\nFrameSpec& FrameSpec::andPreceding(const Expression& expression)\n{\n    syntax().between = true;\n    syntax().secondEvent = SyntaxType::SecondEvent::Preceding;\n    syntax().expression2 = expression;\n    return *this;\n}\n\nFrameSpec& FrameSpec::andCurrentRow()\n{\n    syntax().between = true;\n    syntax().secondEvent = SyntaxType::SecondEvent::CurrentRow;\n    return *this;\n}\n\nFrameSpec& FrameSpec::andFollowing(const Expression& expression)\n{\n    syntax().between = true;\n    syntax().secondEvent = SyntaxType::SecondEvent::Following;\n    syntax().expression2 = expression;\n    return *this;\n}\n\nFrameSpec& FrameSpec::andUnboundedFollowing()\n{\n    syntax().between = true;\n    syntax().secondEvent = SyntaxType::SecondEvent::UnboundedFollowing;\n    return *this;\n}\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/identifier/FrameSpec.hpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"SQL.hpp\"\n\nnamespace WCDB {\n\nclass WCDB_API FrameSpec final : public SpecifiedSyntax<Syntax::FrameSpec, SQL> {\npublic:\n    FrameSpec();\n    ~FrameSpec() override;\n\n    FrameSpec& range();\n    FrameSpec& rows();\n\n    FrameSpec& unboundedPreceding();\n    FrameSpec& preceding(const Expression& expression);\n    FrameSpec& currentRow();\n\n    FrameSpec& betweenUnboundedPreceding();\n    FrameSpec& betweenPreceding(const Expression& expression);\n    FrameSpec& betweenCurrentRow();\n    FrameSpec& betweenFollowing(const Expression& expression);\n\n    FrameSpec& andPreceding(const Expression& expression);\n    FrameSpec& andCurrentRow();\n    FrameSpec& andFollowing(const Expression& expression);\n    FrameSpec& andUnboundedFollowing();\n};\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/identifier/IndexedColumn.cpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"WINQ.h\"\n\nnamespace WCDB {\n\nIndexedColumn::IndexedColumn() = default;\n\nIndexedColumn::IndexedColumn(const Column& column)\n{\n    syntax().switcher = SyntaxType::Switch::Column;\n    syntax().column = column;\n}\n\nIndexedColumn::IndexedColumn(const Expression& expression)\n{\n    syntax().switcher = SyntaxType::Switch::Expression;\n    syntax().expression = expression;\n}\n\nIndexedColumn::~IndexedColumn() = default;\n\nIndexedColumn& IndexedColumn::collate(const UnsafeStringView& collation)\n{\n    syntax().collation = collation;\n    return *this;\n}\n\nIndexedColumn& IndexedColumn::order(const Order& order)\n{\n    syntax().order = order;\n    return *this;\n}\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/identifier/IndexedColumn.hpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"SQL.hpp\"\n\nnamespace WCDB {\n\nclass WCDB_API IndexedColumn final : public SpecifiedSyntax<Syntax::IndexedColumn, SQL> {\npublic:\n    using SpecifiedSyntax<Syntax::IndexedColumn, SQL>::SpecifiedSyntax;\n    IndexedColumn();\n    ~IndexedColumn() override;\n\n    template<typename T, typename Enable = typename std::enable_if<IndexedColumnConvertible<T>::value>::type>\n    IndexedColumn(const T& t)\n    {\n        *this = IndexedColumnConvertible<T>::asIndexedColumn(t);\n    }\n\n    IndexedColumn(const Column& column);\n    IndexedColumn(const Expression& expression);\n\n    IndexedColumn& collate(const UnsafeStringView& collation);\n    IndexedColumn& order(const Order& order);\n};\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/identifier/Join.cpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"WINQ.h\"\n\nnamespace WCDB {\n\nJoin::Join() = default;\n\nJoin::~Join() = default;\n\nJoin& Join::table(const TableOrSubquery& tableOrSubquery)\n{\n    syntax().tableOrSubqueries.push_back(tableOrSubquery);\n    return *this;\n}\n\nJoin& Join::with(const TableOrSubquery& tableOrSubquery)\n{\n    join(Syntax::JoinOperator::With, tableOrSubquery);\n    return *this;\n}\n\nJoin& Join::join(const TableOrSubquery& tableOrSubquery)\n{\n    join(Syntax::JoinOperator::Join, tableOrSubquery);\n    return *this;\n}\n\nJoin& Join::leftOuterJoin(const TableOrSubquery& tableOrSubquery)\n{\n    join(Syntax::JoinOperator::LeftOuterJoin, tableOrSubquery);\n    return *this;\n}\n\nJoin& Join::leftJoin(const TableOrSubquery& tableOrSubquery)\n{\n    join(Syntax::JoinOperator::LeftJoin, tableOrSubquery);\n    return *this;\n}\n\nJoin& Join::innerJoin(const TableOrSubquery& tableOrSubquery)\n{\n    join(Syntax::JoinOperator::InnerJoin, tableOrSubquery);\n    return *this;\n}\n\nJoin& Join::crossJoin(const TableOrSubquery& tableOrSubquery)\n{\n    join(Syntax::JoinOperator::CrossJoin, tableOrSubquery);\n    return *this;\n}\n\nJoin& Join::naturalJoin(const TableOrSubquery& tableOrSubquery)\n{\n    join(Syntax::JoinOperator::NaturalJoin, tableOrSubquery);\n    return *this;\n}\n\nJoin& Join::naturalLeftOuterJoin(const TableOrSubquery& tableOrSubquery)\n{\n    join(Syntax::JoinOperator::NaturalLeftOuterJoin, tableOrSubquery);\n    return *this;\n}\n\nJoin& Join::naturalLeftJoin(const TableOrSubquery& tableOrSubquery)\n{\n    join(Syntax::JoinOperator::NaturalLeftJoin, tableOrSubquery);\n    return *this;\n}\n\nJoin& Join::naturalInnerJoin(const TableOrSubquery& tableOrSubquery)\n{\n    join(Syntax::JoinOperator::NaturalInnerJoin, tableOrSubquery);\n    return *this;\n}\n\nJoin& Join::naturalCrossJoin(const TableOrSubquery& tableOrSubquery)\n{\n    join(Syntax::JoinOperator::NaturalCrossJoin, tableOrSubquery);\n    return *this;\n}\n\nJoin& Join::on(const Expression& expression)\n{\n    return constraint(JoinConstraint().on(expression));\n}\n\nJoin& Join::usingColumn(const Column& column)\n{\n    return constraint(JoinConstraint().column(column));\n}\n\nJoin& Join::usingColumns(const Columns& columns)\n{\n    return constraint(JoinConstraint().columns(columns));\n}\n\nJoin& Join::constraint(const JoinConstraint& constraint)\n{\n    syntax().joinConstraints.back() = constraint;\n    return *this;\n}\n\nJoin& Join::join(const Syntax::JoinOperator& joinOperator, const TableOrSubquery& tableOrSubquery)\n{\n    syntax().joinOperators.push_back(joinOperator);\n    syntax().tableOrSubqueries.push_back(tableOrSubquery);\n    syntax().joinConstraints.push_back(nullptr);\n    return *this;\n}\n\nTableOrSubquery Join::as(const UnsafeStringView& alias)\n{\n    return TableOrSubquery(*this).as(alias);\n}\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/identifier/Join.hpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"SQL.hpp\"\n\nnamespace WCDB {\n\nclass TableOrSubquery;\n\nclass WCDB_API Join final : public SpecifiedSyntax<Syntax::JoinClause, SQL> {\npublic:\n    using SpecifiedSyntax<Syntax::JoinClause, SQL>::SpecifiedSyntax;\n    Join();\n    ~Join() override;\n\n    Join& table(const TableOrSubquery& tableOrSubquery);\n\n    Join& with(const TableOrSubquery& tableOrSubquery);\n    Join& join(const TableOrSubquery& tableOrSubquery);\n    Join& leftOuterJoin(const TableOrSubquery& tableOrSubquery);\n    Join& leftJoin(const TableOrSubquery& tableOrSubquery);\n    Join& innerJoin(const TableOrSubquery& tableOrSubquery);\n    Join& crossJoin(const TableOrSubquery& tableOrSubquery);\n    Join& naturalJoin(const TableOrSubquery& tableOrSubquery);\n    Join& naturalLeftOuterJoin(const TableOrSubquery& tableOrSubquery);\n    Join& naturalLeftJoin(const TableOrSubquery& tableOrSubquery);\n    Join& naturalInnerJoin(const TableOrSubquery& tableOrSubquery);\n    Join& naturalCrossJoin(const TableOrSubquery& tableOrSubquery);\n\n    Join& on(const Expression& expression);\n    Join& usingColumn(const Column& column);\n    Join& usingColumns(const Columns& columns);\n\n    TableOrSubquery as(const UnsafeStringView& alias);\n\nprivate:\n    Join& constraint(const JoinConstraint& constraint);\n    Join& join(const Syntax::JoinOperator& joinOperator, const TableOrSubquery& tableOrSubquery);\n};\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/identifier/JoinConstraint.cpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"WINQ.h\"\n\nnamespace WCDB {\n\nJoinConstraint::JoinConstraint() = default;\n\nJoinConstraint::~JoinConstraint() = default;\n\nJoinConstraint& JoinConstraint::on(const Expression& expression)\n{\n    syntax().expression = expression;\n    return *this;\n}\n\nJoinConstraint& JoinConstraint::using_()\n{\n    return *this;\n}\n\nJoinConstraint& JoinConstraint::column(const Column& column)\n{\n    syntax().columns.push_back(column);\n    return *this;\n}\n\nJoinConstraint& JoinConstraint::columns(const Columns& columns)\n{\n    syntax().columns = columns;\n    return *this;\n}\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/identifier/JoinConstraint.hpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"SQL.hpp\"\n\nnamespace WCDB {\n\nclass WCDB_API JoinConstraint final : public SpecifiedSyntax<Syntax::JoinConstraint, SQL> {\npublic:\n    JoinConstraint();\n    ~JoinConstraint() override;\n\n    JoinConstraint& on(const Expression& expression);\n    JoinConstraint& using_();\n    JoinConstraint& column(const Column& column);\n    JoinConstraint& columns(const Columns& columns);\n};\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/identifier/LiteralValue.cpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"WINQ.h\"\n\nnamespace WCDB {\n\nLiteralValue::LiteralValue() = default;\n\nLiteralValue::~LiteralValue() = default;\n\nLiteralValue::LiteralValue(int64_t value)\n{\n    syntax().switcher = SyntaxType::Switch::Integer;\n    syntax().integerValue = value;\n}\n\nLiteralValue::LiteralValue(uint64_t value)\n{\n    syntax().switcher = SyntaxType::Switch::UnsignedInteger;\n    syntax().unsignedIntegerValue = value;\n}\n\nLiteralValue::LiteralValue(bool value)\n{\n    syntax().switcher = SyntaxType::Switch::Bool;\n    syntax().boolValue = value;\n}\n\nLiteralValue::LiteralValue(double value)\n{\n    syntax().switcher = SyntaxType::Switch::Float;\n    syntax().floatValue = value;\n}\n\nLiteralValue::LiteralValue(std::nullptr_t)\n{\n    syntax().switcher = SyntaxType::Switch::Null;\n}\n\nLiteralValue::LiteralValue(const UnsafeStringView& value)\n{\n    syntax().switcher = SyntaxType::Switch::StringView;\n    syntax().stringValue = value;\n}\n\nLiteralValue LiteralValue::currentTime()\n{\n    LiteralValue value;\n    value.syntax().switcher = SyntaxType::Switch::CurrentTime;\n    return value;\n}\n\nLiteralValue LiteralValue::currentDate()\n{\n    LiteralValue value;\n    value.syntax().switcher = SyntaxType::Switch::CurrentDate;\n    return value;\n}\n\nLiteralValue LiteralValue::currentTimestamp()\n{\n    LiteralValue value;\n    value.syntax().switcher = SyntaxType::Switch::CurrentTimestamp;\n    return value;\n}\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/identifier/LiteralValue.hpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"SQL.hpp\"\n\nnamespace WCDB {\n\n// BLOB is not supported since it may cause string truncation. Ones should use BindParameter instead.\nclass WCDB_API LiteralValue final : public SpecifiedSyntax<Syntax::LiteralValue, SQL> {\npublic:\n    using SpecifiedSyntax<Syntax::LiteralValue, SQL>::SpecifiedSyntax;\n    LiteralValue();\n    ~LiteralValue() override;\n\n    LiteralValue(int64_t value);\n    LiteralValue(uint64_t value);\n    LiteralValue(double value);\n    LiteralValue(std::nullptr_t);\n    LiteralValue(bool value);\n    LiteralValue(const UnsafeStringView& value);\n\n    template<typename T, typename Enable = typename std::enable_if<LiteralValueConvertible<T>::value>::type>\n    LiteralValue(const T& t)\n    {\n        *this = LiteralValueConvertible<T>::asLiteralValue(t);\n    }\n\n    static LiteralValue currentTime();\n    static LiteralValue currentDate();\n    static LiteralValue currentTimestamp();\n};\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/identifier/OrderingTerm.cpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"WINQ.h\"\n\nnamespace WCDB {\n\nOrderingTerm::OrderingTerm() = default;\n\nOrderingTerm::~OrderingTerm() = default;\n\nOrderingTerm::OrderingTerm(const Expression& expression)\n{\n    syntax().expression = expression;\n}\n\nOrderingTerm& OrderingTerm::collate(const UnsafeStringView& collation)\n{\n    syntax().collation = collation;\n    return *this;\n}\n\nOrderingTerm& OrderingTerm::order(const Order& order)\n{\n    syntax().order = order;\n    return *this;\n}\n\nconst OrderingTerm& OrderingTerm::ascendingRowid()\n{\n    static const OrderingTerm* s_ascendingRowid\n    = new OrderingTerm(OrderingTerm(Column::rowid()).order(WCDB::Order::ASC));\n    return *s_ascendingRowid;\n}\n\nconst OrderingTerm& OrderingTerm::descendingRowid()\n{\n    static const OrderingTerm* s_descendingRowid\n    = new OrderingTerm(OrderingTerm(Column::rowid()).order(WCDB::Order::DESC));\n    return *s_descendingRowid;\n}\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/identifier/OrderingTerm.hpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"SQL.hpp\"\n\nnamespace WCDB {\n\nclass WCDB_API OrderingTerm final : public SpecifiedSyntax<Syntax::OrderingTerm, SQL> {\npublic:\n    using SpecifiedSyntax<Syntax::OrderingTerm, SQL>::SpecifiedSyntax;\n    OrderingTerm();\n    ~OrderingTerm() override;\n\n    template<typename T, typename Enable = typename std::enable_if<OrderingTermConvertible<T>::value>::type>\n    OrderingTerm(const T& t)\n    {\n        *this = OrderingTermConvertible<T>::asOrderingTerm(t);\n    }\n\n    OrderingTerm(const Expression& expression);\n    OrderingTerm& collate(const UnsafeStringView& collation);\n    OrderingTerm& order(const Order& order);\n\n    static const OrderingTerm& ascendingRowid();\n    static const OrderingTerm& descendingRowid();\n};\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/identifier/Pragma.cpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\";\n    return Pragma(StringView::makeConstant(string)); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"WINQ.h\"\n\nnamespace WCDB {\n\nPragma::Pragma() = default;\n\nPragma::~Pragma() = default;\n\nPragma::Pragma(const UnsafeStringView& name)\n{\n    syntax().name = name;\n}\n\nPragma Pragma::applicationId()\n{\n    static const char* string = \"application_id\";\n    return Pragma(StringView::makeConstant(string));\n}\n\nPragma Pragma::autoVacuum()\n{\n    static const char* string = \"auto_vacuum\";\n    return Pragma(StringView::makeConstant(string));\n}\n\nPragma Pragma::automaticIndex()\n{\n    static const char* string = \"automatic_index\";\n    return Pragma(StringView::makeConstant(string));\n}\n\nPragma Pragma::busyTimeout()\n{\n    static const char* string = \"busy_timeout\";\n    return Pragma(StringView::makeConstant(string));\n}\n\nPragma Pragma::cacheSize()\n{\n    static const char* string = \"cache_size\";\n    return Pragma(StringView::makeConstant(string));\n}\n\nPragma Pragma::cacheSpill()\n{\n    static const char* string = \"cache_spill\";\n    return Pragma(StringView::makeConstant(string));\n}\n\nPragma Pragma::caseSensitiveLike()\n{\n    static const char* string = \"case_sensitive_like\";\n    return Pragma(StringView::makeConstant(string));\n}\n\nPragma Pragma::cellSizeCheck()\n{\n    static const char* string = \"cell_size_check\";\n    return Pragma(StringView::makeConstant(string));\n}\n\nPragma Pragma::checkpointFullfsync()\n{\n    static const char* string = \"checkpoint_fullfsync\";\n    return Pragma(StringView::makeConstant(string));\n}\n\nPragma Pragma::cipher()\n{\n    static const char* string = \"cipher\";\n    return Pragma(StringView::makeConstant(string));\n}\n\nPragma Pragma::cipherAddRandom()\n{\n    static const char* string = \"cipher_add_random\";\n    return Pragma(StringView::makeConstant(string));\n}\n\nPragma Pragma::cipherCompatibility()\n{\n    static const char* string = \"cipher_compatibility\";\n    return Pragma(StringView::makeConstant(string));\n}\n\nPragma Pragma::cipherDefaultKdfIter()\n{\n    static const char* string = \"cipher_default_kdf_iter\";\n    return Pragma(StringView::makeConstant(string));\n}\n\nPragma Pragma::cipherDefaultPageSize()\n{\n    static const char* string = \"cipher_default_page_size\";\n    return Pragma(StringView::makeConstant(string));\n}\n\nPragma Pragma::cipherHmacAlgorithm()\n{\n    static const char* string = \"cipher_hmac_algorithm\";\n    return Pragma(StringView::makeConstant(string));\n}\n\nPragma Pragma::cipherKdfAlgorithm()\n{\n    static const char* string = \"cipher_kdf_algorithm\";\n    return Pragma(StringView::makeConstant(string));\n}\n\nPragma Pragma::cipherPlainTextHeaderSize()\n{\n    static const char* string = \"cipher_plaintext_header_size\";\n    return Pragma(StringView::makeConstant(string));\n}\n\nPragma Pragma::cipherDefaultUseHmac()\n{\n    static const char* string = \"cipher_default_use_hmac\";\n    return Pragma(StringView::makeConstant(string));\n}\n\nPragma Pragma::cipherMigrate()\n{\n    static const char* string = \"cipher_migrate\";\n    return Pragma(StringView::makeConstant(string));\n}\n\nPragma Pragma::cipherProfile()\n{\n    static const char* string = \"cipher_profile\";\n    return Pragma(StringView::makeConstant(string));\n}\n\nPragma Pragma::cipherProvider()\n{\n    static const char* string = \"cipher_provider\";\n    return Pragma(StringView::makeConstant(string));\n}\n\nPragma Pragma::cipherProviderVersion()\n{\n    static const char* string = \"cipher_provider_version\";\n    return Pragma(StringView::makeConstant(string));\n}\n\nPragma Pragma::cipherSalt()\n{\n    static const char* string = \"cipher_salt\";\n    return Pragma(StringView::makeConstant(string));\n}\n\nPragma Pragma::cipherUseHmac()\n{\n    static const char* string = \"cipher_use_hmac\";\n    return Pragma(StringView::makeConstant(string));\n}\n\nPragma Pragma::cipherVersion()\n{\n    static const char* string = \"cipher_version\";\n    return Pragma(StringView::makeConstant(string));\n}\n\nPragma Pragma::cipherPageSize()\n{\n    static const char* string = \"cipher_page_size\";\n    return Pragma(StringView::makeConstant(string));\n}\n\nPragma Pragma::collationList()\n{\n    static const char* string = \"collation_list\";\n    return Pragma(StringView::makeConstant(string));\n}\n\nPragma Pragma::dataVersion()\n{\n    static const char* string = \"data_version\";\n    return Pragma(StringView::makeConstant(string));\n}\n\nPragma Pragma::databaseList()\n{\n    static const char* string = \"database_list\";\n    return Pragma(StringView::makeConstant(string));\n}\n\nPragma Pragma::deferForeignKeys()\n{\n    static const char* string = \"defer_foreign_keys\";\n    return Pragma(StringView::makeConstant(string));\n}\n\nPragma Pragma::encoding()\n{\n    static const char* string = \"encoding\";\n    return Pragma(StringView::makeConstant(string));\n}\n\nPragma Pragma::foreignKeyCheck()\n{\n    static const char* string = \"foreign_key_check\";\n    return Pragma(StringView::makeConstant(string));\n}\n\nPragma Pragma::foreignKeyList()\n{\n    static const char* string = \"foreign_key_list\";\n    return Pragma(StringView::makeConstant(string));\n}\n\nPragma Pragma::foreignKeys()\n{\n    static const char* string = \"foreign_keys\";\n    return Pragma(StringView::makeConstant(string));\n}\n\nPragma Pragma::freelistCount()\n{\n    static const char* string = \"freelist_count\";\n    return Pragma(StringView::makeConstant(string));\n}\n\nPragma Pragma::fullfsync()\n{\n    static const char* string = \"fullfsync\";\n    return Pragma(StringView::makeConstant(string));\n}\n\nPragma Pragma::functionList()\n{\n    static const char* string = \"function_list\";\n    return Pragma(StringView::makeConstant(string));\n}\n\nPragma Pragma::ignoreCheckConstraints()\n{\n    static const char* string = \"ignore_check_constraints\";\n    return Pragma(StringView::makeConstant(string));\n}\n\nPragma Pragma::incrementalVacuum()\n{\n    static const char* string = \"incremental_vacuum\";\n    return Pragma(StringView::makeConstant(string));\n}\n\nPragma Pragma::indexInfo()\n{\n    static const char* string = \"index_info\";\n    return Pragma(StringView::makeConstant(string));\n}\n\nPragma Pragma::indexList()\n{\n    static const char* string = \"index_list\";\n    return Pragma(StringView::makeConstant(string));\n}\n\nPragma Pragma::indexXinfo()\n{\n    static const char* string = \"index_xinfo\";\n    return Pragma(StringView::makeConstant(string));\n}\n\nPragma Pragma::integrityCheck()\n{\n    static const char* string = \"integrity_check\";\n    return Pragma(StringView::makeConstant(string));\n}\n\nPragma Pragma::journalMode()\n{\n    static const char* string = \"journal_mode\";\n    return Pragma(StringView::makeConstant(string));\n}\n\nPragma Pragma::journalSizeLimit()\n{\n    static const char* string = \"journal_size_limit\";\n    return Pragma(StringView::makeConstant(string));\n}\n\nPragma Pragma::key()\n{\n    static const char* string = \"key\";\n    return Pragma(StringView::makeConstant(string));\n}\n\nPragma Pragma::kdfIter()\n{\n    static const char* string = \"kdf_iter\";\n    return Pragma(StringView::makeConstant(string));\n}\n\nPragma Pragma::legacyFileFormat()\n{\n    static const char* string = \"legacy_file_format\";\n    return Pragma(StringView::makeConstant(string));\n}\n\nPragma Pragma::lockingMode()\n{\n    static const char* string = \"locking_mode\";\n    return Pragma(StringView::makeConstant(string));\n}\n\nPragma Pragma::maxPageCount()\n{\n    static const char* string = \"max_page_count\";\n    return Pragma(StringView::makeConstant(string));\n}\n\nPragma Pragma::mmapSize()\n{\n    static const char* string = \"mmap_size\";\n    return Pragma(StringView::makeConstant(string));\n}\n\nPragma Pragma::moduleList()\n{\n    static const char* string = \"module_list\";\n    return Pragma(StringView::makeConstant(string));\n}\n\nPragma Pragma::optimize()\n{\n    static const char* string = \"optimize\";\n    return Pragma(StringView::makeConstant(string));\n}\n\nPragma Pragma::pageCount()\n{\n    static const char* string = \"page_count\";\n    return Pragma(StringView::makeConstant(string));\n}\n\nPragma Pragma::pageSize()\n{\n    static const char* string = \"page_size\";\n    return Pragma(StringView::makeConstant(string));\n}\n\nPragma Pragma::parserTrace()\n{\n    static const char* string = \"parser_trace\";\n    return Pragma(StringView::makeConstant(string));\n}\n\nPragma Pragma::pragmaList()\n{\n    static const char* string = \"pragma_list\";\n    return Pragma(StringView::makeConstant(string));\n}\n\nPragma Pragma::queryOnly()\n{\n    static const char* string = \"query_only\";\n    return Pragma(StringView::makeConstant(string));\n}\n\nPragma Pragma::quickCheck()\n{\n    static const char* string = \"quick_check\";\n    return Pragma(StringView::makeConstant(string));\n}\n\nPragma Pragma::readUncommitted()\n{\n    static const char* string = \"read_uncommitted\";\n    return Pragma(StringView::makeConstant(string));\n}\n\nPragma Pragma::recursiveTriggers()\n{\n    static const char* string = \"recursive_triggers\";\n    return Pragma(StringView::makeConstant(string));\n}\n\nPragma Pragma::rekey()\n{\n    static const char* string = \"rekey\";\n    return Pragma(StringView::makeConstant(string));\n}\n\nPragma Pragma::reverseUnorderedSelects()\n{\n    static const char* string = \"reverse_unordered_selects\";\n    return Pragma(StringView::makeConstant(string));\n}\n\nPragma Pragma::schemaVersion()\n{\n    static const char* string = \"schema_version\";\n    return Pragma(StringView::makeConstant(string));\n}\n\nPragma Pragma::secureDelete()\n{\n    static const char* string = \"secure_delete\";\n    return Pragma(StringView::makeConstant(string));\n}\n\nPragma Pragma::shrinkMemory()\n{\n    static const char* string = \"shrink_memory\";\n    return Pragma(StringView::makeConstant(string));\n}\n\nPragma Pragma::softHeapLimit()\n{\n    static const char* string = \"soft_heap_limit\";\n    return Pragma(StringView::makeConstant(string));\n}\n\nPragma Pragma::stats()\n{\n    static const char* string = \"stats\";\n    return Pragma(StringView::makeConstant(string));\n}\n\nPragma Pragma::synchronous()\n{\n    static const char* string = \"synchronous\";\n    return Pragma(StringView::makeConstant(string));\n}\n\nPragma Pragma::tableInfo()\n{\n    static const char* string = \"table_info\";\n    return Pragma(StringView::makeConstant(string));\n}\n\nPragma Pragma::tempStore()\n{\n    static const char* string = \"temp_store\";\n    return Pragma(StringView::makeConstant(string));\n}\n\nPragma Pragma::threads()\n{\n    static const char* string = \"threads\";\n    return Pragma(StringView::makeConstant(string));\n}\n\nPragma Pragma::userVersion()\n{\n    static const char* string = \"user_version\";\n    return Pragma(StringView::makeConstant(string));\n}\n\nPragma Pragma::vdbeAddoptrace()\n{\n    static const char* string = \"vdbe_addoptrace\";\n    return Pragma(StringView::makeConstant(string));\n}\n\nPragma Pragma::vdbeDebug()\n{\n    static const char* string = \"vdbe_debug\";\n    return Pragma(StringView::makeConstant(string));\n}\n\nPragma Pragma::vdbeListing()\n{\n    static const char* string = \"vdbe_listing\";\n    return Pragma(StringView::makeConstant(string));\n}\n\nPragma Pragma::vdbeTrace()\n{\n    static const char* string = \"vdbe_trace\";\n    return Pragma(StringView::makeConstant(string));\n}\n\nPragma Pragma::walAutocheckpoint()\n{\n    static const char* string = \"wal_autocheckpoint\";\n    return Pragma(StringView::makeConstant(string));\n}\n\nPragma Pragma::walCheckpoint()\n{\n    static const char* string = \"wal_checkpoint\";\n    return Pragma(StringView::makeConstant(string));\n}\n\nPragma Pragma::writableSchema()\n{\n    static const char* string = \"writable_schema\";\n    return Pragma(StringView::makeConstant(string));\n}\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/identifier/Pragma.hpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"SQL.hpp\"\n\nnamespace WCDB {\n\nclass WCDB_API Pragma final : public SpecifiedSyntax<Syntax::Pragma, SQL> {\n#pragma mark - Initializer\npublic:\n    using SpecifiedSyntax<Syntax::Pragma, SQL>::SpecifiedSyntax;\n    Pragma();\n    ~Pragma() override;\n\n    template<typename T, typename Enable = typename std::enable_if<ColumnIsTextType<T>::value>::type>\n    Pragma(const T& t) : Pragma(ColumnIsTextType<T>::asUnderlyingType(t))\n    {\n    }\n\n    Pragma(const UnsafeStringView& name);\n\n#pragma mark - SQLite\npublic:\n    static Pragma applicationId();\n    static Pragma autoVacuum();\n    static Pragma automaticIndex();\n    static Pragma busyTimeout();\n    static Pragma cacheSize();\n    static Pragma cacheSpill();\n    static Pragma caseSensitiveLike();\n    static Pragma cellSizeCheck();\n    static Pragma checkpointFullfsync();\n    static Pragma collationList();\n    static Pragma dataVersion();\n    static Pragma databaseList();\n    static Pragma deferForeignKeys();\n    static Pragma encoding();\n    static Pragma foreignKeyCheck();\n    static Pragma foreignKeyList();\n    static Pragma foreignKeys();\n    static Pragma freelistCount();\n    static Pragma fullfsync();\n    static Pragma functionList();\n    static Pragma ignoreCheckConstraints();\n    static Pragma incrementalVacuum();\n    static Pragma indexInfo();\n    static Pragma indexList();\n    static Pragma indexXinfo();\n    static Pragma integrityCheck();\n    static Pragma journalMode();\n    static Pragma journalSizeLimit();\n    static Pragma legacyFileFormat();\n    static Pragma lockingMode();\n    static Pragma maxPageCount();\n    static Pragma mmapSize();\n    static Pragma moduleList();\n    static Pragma optimize();\n    static Pragma pageCount();\n    static Pragma pageSize();\n    static Pragma parserTrace();\n    static Pragma pragmaList();\n    static Pragma queryOnly();\n    static Pragma quickCheck();\n    static Pragma readUncommitted();\n    static Pragma recursiveTriggers();\n    static Pragma reverseUnorderedSelects();\n    static Pragma schemaVersion();\n    static Pragma secureDelete();\n    static Pragma shrinkMemory();\n    static Pragma softHeapLimit();\n    static Pragma stats();\n    static Pragma synchronous();\n    static Pragma tableInfo();\n    static Pragma tempStore();\n    static Pragma threads();\n    static Pragma userVersion();\n    static Pragma vdbeAddoptrace();\n    static Pragma vdbeDebug();\n    static Pragma vdbeListing();\n    static Pragma vdbeTrace();\n    static Pragma walAutocheckpoint();\n    static Pragma walCheckpoint();\n    static Pragma writableSchema();\n\n#pragma mark - SQLCipher\npublic:\n    static Pragma cipher();\n    static Pragma cipherAddRandom();\n    static Pragma cipherCompatibility();\n    static Pragma cipherDefaultKdfIter();\n    static Pragma cipherDefaultPageSize();\n    static Pragma cipherHmacAlgorithm();\n    static Pragma cipherKdfAlgorithm();\n    static Pragma cipherPageSize();\n    static Pragma cipherPlainTextHeaderSize();\n    static Pragma cipherDefaultUseHmac();\n    static Pragma cipherMigrate();\n    static Pragma cipherProfile();\n    static Pragma cipherProvider();\n    static Pragma cipherProviderVersion();\n    static Pragma cipherSalt();\n    static Pragma cipherUseHmac();\n    static Pragma cipherVersion();\n    static Pragma key();\n    static Pragma kdfIter();\n    static Pragma rekey();\n};\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/identifier/QualifiedTable.cpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"WINQ.h\"\n\nnamespace WCDB {\n\nQualifiedTable::QualifiedTable() = default;\n\nQualifiedTable::~QualifiedTable() = default;\n\nQualifiedTable::QualifiedTable(const UnsafeStringView& table)\n{\n    syntax().table = table;\n}\n\nQualifiedTable& QualifiedTable::schema(const Schema& schema)\n{\n    syntax().schema = schema;\n    return *this;\n}\n\nQualifiedTable& QualifiedTable::as(const UnsafeStringView& alias)\n{\n    syntax().alias = alias;\n    return *this;\n}\n\nQualifiedTable& QualifiedTable::indexed(const UnsafeStringView& index)\n{\n    syntax().switcher = SyntaxType::Switch::Indexed;\n    syntax().index = index;\n    return *this;\n}\n\nQualifiedTable& QualifiedTable::notIndexed()\n{\n    syntax().switcher = SyntaxType::Switch::NotIndexed;\n    return *this;\n}\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/identifier/QualifiedTable.hpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"SQL.hpp\"\n\nnamespace WCDB {\n\nclass WCDB_API QualifiedTable final\n: public SpecifiedSyntax<Syntax::QualifiedTableName, SQL> {\npublic:\n    using SpecifiedSyntax<Syntax::QualifiedTableName, SQL>::SpecifiedSyntax;\n    QualifiedTable();\n    ~QualifiedTable() override;\n\n    template<typename T, typename Enable = typename std::enable_if<QualifiedTableConvertible<T>::value>::type>\n    QualifiedTable(const T& t)\n    {\n        *this = QualifiedTableConvertible<T>::asQualifiedTable(t);\n    }\n\n    QualifiedTable(const UnsafeStringView& table);\n\n    QualifiedTable& schema(const Schema& schema);\n    QualifiedTable& as(const UnsafeStringView& alias);\n\n    QualifiedTable& indexed(const UnsafeStringView& index);\n    QualifiedTable& notIndexed();\n};\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/identifier/RaiseFunction.cpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"WINQ.h\"\n\nnamespace WCDB {\n\nRaiseFunction::RaiseFunction() = default;\n\nRaiseFunction::~RaiseFunction() = default;\n\nRaiseFunction& RaiseFunction::ignore()\n{\n    syntax().switcher = SyntaxType::Switch::Ignore;\n    return *this;\n}\n\nRaiseFunction& RaiseFunction::rollback(const UnsafeStringView& errorMessage)\n{\n    syntax().switcher = SyntaxType::Switch::Rollback;\n    syntax().errorMessage = errorMessage;\n    return *this;\n}\n\nRaiseFunction& RaiseFunction::abort(const UnsafeStringView& errorMessage)\n{\n    syntax().switcher = SyntaxType::Switch::Abort;\n    syntax().errorMessage = errorMessage;\n    return *this;\n}\n\nRaiseFunction& RaiseFunction::fail(const UnsafeStringView& errorMessage)\n{\n    syntax().switcher = SyntaxType::Switch::Fail;\n    syntax().errorMessage = errorMessage;\n    return *this;\n}\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/identifier/RaiseFunction.hpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"SQL.hpp\"\n\nnamespace WCDB {\n\nclass WCDB_API RaiseFunction final : public SpecifiedSyntax<Syntax::RaiseFunction, SQL> {\npublic:\n    RaiseFunction();\n    ~RaiseFunction() override;\n    RaiseFunction& ignore();\n    RaiseFunction& rollback(const UnsafeStringView& errorMessage);\n    RaiseFunction& abort(const UnsafeStringView& errorMessage);\n    RaiseFunction& fail(const UnsafeStringView& errorMessage);\n};\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/identifier/ResultColumn.cpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"Assertion.hpp\"\n#include \"WINQ.h\"\n\nnamespace WCDB {\n\nResultColumn::ResultColumn() = default;\n\nResultColumn::~ResultColumn() = default;\n\nResultColumn::ResultColumn(const Expression& expression)\n{\n    syntax().expression = expression;\n}\n\nResultColumn& ResultColumn::as(const UnsafeStringView& alias)\n{\n    syntax().alias = alias;\n    return *this;\n}\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/identifier/ResultColumn.hpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"SQL.hpp\"\n\nnamespace WCDB {\n\nclass WCDB_API ResultColumn : public SpecifiedSyntax<Syntax::ResultColumn, SQL> {\npublic:\n    using SpecifiedSyntax<Syntax::ResultColumn, SQL>::SpecifiedSyntax;\n    ResultColumn();\n    virtual ~ResultColumn() override;\n\n    template<typename T, typename Enable = typename std::enable_if<ResultColumnConvertible<T>::value>::type>\n    ResultColumn(const T& t)\n    {\n        *this = ResultColumnConvertible<T>::asResultColumn(t);\n    }\n\n    ResultColumn(const Expression& expression);\n    ResultColumn& as(const UnsafeStringView& alias);\n};\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/identifier/Schema.cpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"WINQ.h\"\n\nnamespace WCDB {\n\nSchema::Schema() = default;\n\nSchema::~Schema() = default;\n\nSchema::Schema(const UnsafeStringView& name)\n{\n    syntax().name = name;\n}\n\nSchema Schema::main()\n{\n    return Schema(Syntax::mainSchema);\n}\n\nSchema Schema::temp()\n{\n    return Schema(Syntax::tempSchema);\n}\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/identifier/Schema.hpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"Convertible.hpp\"\n#include \"SQL.hpp\"\n\nnamespace WCDB {\n\nclass WCDB_API Schema final : public SpecifiedSyntax<Syntax::Schema, SQL> {\npublic:\n    Schema();\n    ~Schema() override;\n\n    template<typename T, typename Enable = typename std::enable_if<ColumnIsTextType<T>::value>::type>\n    Schema(const T& t) : Schema(ColumnIsTextType<T>::asUnderlyingType(t))\n    {\n    }\n\n    Schema(const UnsafeStringView& name);\n\n    static Schema main();\n    static Schema temp();\n};\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/identifier/TableConstraint.cpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"WINQ.h\"\n\nnamespace WCDB {\n\nTableConstraint::TableConstraint() = default;\n\nTableConstraint::~TableConstraint() = default;\n\nTableConstraint::TableConstraint(const UnsafeStringView& name)\n{\n    syntax().name = name;\n}\n\nTableConstraint& TableConstraint::primaryKey()\n{\n    syntax().switcher = SyntaxType::Switch::PrimaryKey;\n    return *this;\n}\n\nTableConstraint& TableConstraint::unique()\n{\n    syntax().switcher = SyntaxType::Switch::Unique;\n    return *this;\n}\n\nTableConstraint& TableConstraint::indexed(const IndexedColumn& indexedColumn)\n{\n    syntax().indexedColumns.push_back(indexedColumn);\n    return *this;\n}\n\nTableConstraint& TableConstraint::conflict(const Conflict& conflict)\n{\n    syntax().conflict = conflict;\n    return *this;\n}\n\nTableConstraint& TableConstraint::check(const Expression& condition)\n{\n    syntax().switcher = SyntaxType::Switch::Check;\n    syntax().expression = condition;\n    return *this;\n}\n\nTableConstraint&\nTableConstraint::foreignKey(const Columns& columns, const ForeignKey& foreignKey)\n{\n    syntax().switcher = SyntaxType::Switch::ForeignKey;\n    syntax().columns = columns;\n    syntax().foreignKeyClause = foreignKey;\n    return *this;\n}\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/identifier/TableConstraint.hpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"SQL.hpp\"\n\nnamespace WCDB {\n\nclass WCDB_API TableConstraint final\n: public SpecifiedSyntax<Syntax::TableConstraint, SQL> {\npublic:\n    TableConstraint();\n    explicit TableConstraint(const UnsafeStringView& name);\n    ~TableConstraint() override;\n\n    TableConstraint& primaryKey();\n    TableConstraint& unique();\n    TableConstraint& indexed(const IndexedColumn& indexedColumn);\n\n    TableConstraint& conflict(const Conflict& conflict);\n\n    TableConstraint& check(const Expression& condition);\n\n    TableConstraint& foreignKey(const Columns& columns, const ForeignKey& foreignKey);\n};\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/identifier/TableOrSubquery.cpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"WINQ.h\"\n\nnamespace WCDB {\n\nTableOrSubquery::TableOrSubquery() = default;\n\nTableOrSubquery::TableOrSubquery(const UnsafeStringView& table)\n{\n    syntax().switcher = SyntaxType::Switch::Table;\n    syntax().tableOrFunction = table;\n}\n\nTableOrSubquery::~TableOrSubquery() = default;\n\nTableOrSubquery& TableOrSubquery::schema(const Schema& schema)\n{\n    syntax().schema = schema;\n    return *this;\n}\n\nTableOrSubquery& TableOrSubquery::as(const UnsafeStringView& alias)\n{\n    syntax().alias = alias;\n    return *this;\n}\n\nTableOrSubquery& TableOrSubquery::notIndexed()\n{\n    syntax().indexType = SyntaxType::IndexType::NotIndexed;\n    return *this;\n}\n\nTableOrSubquery& TableOrSubquery::indexed(const UnsafeStringView& index)\n{\n    syntax().indexType = SyntaxType::IndexType::Indexed;\n    syntax().index = index;\n    return *this;\n}\n\nTableOrSubquery TableOrSubquery::function(const UnsafeStringView& function)\n{\n    TableOrSubquery tableOrSubquery;\n    tableOrSubquery.syntax().switcher = SyntaxType::Switch::Function;\n    tableOrSubquery.syntax().tableOrFunction = function;\n    return tableOrSubquery;\n}\n\nTableOrSubquery& TableOrSubquery::invoke()\n{\n    return *this;\n}\n\nTableOrSubquery& TableOrSubquery::argument(const Expression& expression)\n{\n    syntax().expressions.push_back(expression);\n    return *this;\n}\n\nTableOrSubquery& TableOrSubquery::arguments(const Expressions& expressions)\n{\n    syntax().expressions = expressions;\n    return *this;\n}\n\nTableOrSubquery::TableOrSubquery(const TablesOrSubqueries& tableOrSubqueries)\n{\n    syntax().switcher = SyntaxType::Switch::TableOrSubqueries;\n    syntax().tableOrSubqueries = tableOrSubqueries;\n}\n\nTableOrSubquery::TableOrSubquery(const Join& join)\n{\n    syntax().switcher = SyntaxType::Switch::JoinClause;\n    syntax().joinClause = join;\n}\n\nTableOrSubquery::TableOrSubquery(const StatementSelect& select)\n{\n    syntax().switcher = SyntaxType::Switch::Select;\n    syntax().select = select;\n}\n\nTableOrSubquery TableOrSubquery::master()\n{\n    return WCDB::Syntax::masterTable;\n}\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/identifier/TableOrSubquery.hpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"SQL.hpp\"\n\nnamespace WCDB {\n\nclass WCDB_API TableOrSubquery final\n: public SpecifiedSyntax<Syntax::TableOrSubquery, SQL> {\npublic:\n    using SpecifiedSyntax<Syntax::TableOrSubquery, SQL>::SpecifiedSyntax;\n    TableOrSubquery();\n    ~TableOrSubquery() override;\n\n    template<typename T, typename Enable = typename std::enable_if<TableOrSubqueryConvertible<T>::value>::type>\n    TableOrSubquery(const T& t)\n    {\n        *this = TableOrSubqueryConvertible<T>::asTableOrSubquery(t);\n    }\n\n    TableOrSubquery(const UnsafeStringView& table);\n    TableOrSubquery& schema(const Schema& schema);\n\n    TableOrSubquery& as(const UnsafeStringView& alias);\n\n    TableOrSubquery& notIndexed();\n    TableOrSubquery& indexed(const UnsafeStringView& index);\n\n    static TableOrSubquery function(const UnsafeStringView& function);\n    TableOrSubquery& invoke();\n    TableOrSubquery& argument(const Expression& expression);\n    TableOrSubquery& arguments(const Expressions& expressions);\n\n    explicit TableOrSubquery(const TablesOrSubqueries& tableOrSubqueries);\n    TableOrSubquery(const Join& join);\n\n    TableOrSubquery(const StatementSelect& select);\n\n    static TableOrSubquery master();\n};\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/identifier/Upsert.cpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"WINQ.h\"\n\nnamespace WCDB {\n\nUpsert::Upsert() = default;\n\nUpsert::~Upsert() = default;\n\nUpsert& Upsert::onConflict()\n{\n    return *this;\n}\n\nUpsert& Upsert::indexed(const IndexedColumn& indexedColumn)\n{\n    syntax().indexedColumns.push_back(indexedColumn);\n    return *this;\n}\n\nUpsert& Upsert::where(const Expression& condition)\n{\n    if (syntax().columnsList.empty()) {\n        syntax().condition = condition;\n    } else {\n        syntax().updateCondition = condition;\n    }\n    return *this;\n}\n\nUpsert& Upsert::doNothing()\n{\n    syntax().switcher = Syntax::UpsertClause::Switch::Nothing;\n    syntax().columnsList.clear();\n    syntax().expressions.clear();\n    return *this;\n}\n\nUpsert& Upsert::doUpdate()\n{\n    syntax().switcher = Syntax::UpsertClause::Switch::Update;\n    syntax().columnsList.clear();\n    syntax().expressions.clear();\n    return *this;\n}\n\nUpsert& Upsert::set(const Columns& columns)\n{\n    syntax().columnsList.push_back(columns);\n    return *this;\n}\n\nUpsert& Upsert::to(const Expression& value)\n{\n    syntax().expressions.push_back(value);\n    return *this;\n}\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/identifier/Upsert.hpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"SQL.hpp\"\n\nnamespace WCDB {\n\nclass WCDB_API Upsert final : public SpecifiedSyntax<Syntax::UpsertClause, SQL> {\npublic:\n    Upsert();\n    ~Upsert() override;\n\n    Upsert& onConflict();\n    Upsert& indexed(const IndexedColumn& indexedColumn);\n    Upsert& where(const Expression& condition);\n    Upsert& doNothing();\n    Upsert& doUpdate();\n    Upsert& set(const Columns& columns);\n    Upsert& to(const Expression& value);\n};\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/identifier/WindowDef.cpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"WINQ.h\"\n\nnamespace WCDB {\n\nWindowDef::WindowDef() = default;\n\nWindowDef::~WindowDef() = default;\n\nWindowDef& WindowDef::partition(const Expressions& expressions)\n{\n    syntax().expressions = expressions;\n    return *this;\n}\n\nWindowDef& WindowDef::order(const OrderingTerms& orders)\n{\n    syntax().orderingTerms = orders;\n    return *this;\n}\n\nWindowDef& WindowDef::framespec(const FrameSpec& framespec)\n{\n    syntax().frameSpec = framespec;\n    return *this;\n}\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/identifier/WindowDef.hpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"SQL.hpp\"\n\nnamespace WCDB {\n\nclass WCDB_API WindowDef final : public SpecifiedSyntax<Syntax::WindowDef, SQL> {\npublic:\n    WindowDef();\n    ~WindowDef() override;\n\n    WindowDef& partition(const Expressions& expressions);\n    WindowDef& order(const OrderingTerms& orders);\n    WindowDef& framespec(const FrameSpec& framespec);\n};\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/statement/StatementAlterTable.cpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"WINQ.h\"\n\nnamespace WCDB {\n\nStatementAlterTable::StatementAlterTable() = default;\n\nStatementAlterTable::~StatementAlterTable() = default;\n\nStatementAlterTable& StatementAlterTable::alterTable(const UnsafeStringView& table)\n{\n    syntax().table = table;\n    return *this;\n}\n\nStatementAlterTable& StatementAlterTable::schema(const Schema& schema)\n{\n    syntax().schema = schema;\n    return *this;\n}\n\nStatementAlterTable& StatementAlterTable::renameToTable(const UnsafeStringView& newTable)\n{\n    syntax().switcher = Syntax::AlterTableSTMT::Switch::RenameTable;\n    syntax().newTable = newTable;\n    return *this;\n}\n\nStatementAlterTable& StatementAlterTable::renameColumn(const Column& oldColumn)\n{\n    syntax().switcher = Syntax::AlterTableSTMT::Switch::RenameColumn;\n    syntax().column = oldColumn;\n    return *this;\n}\n\nStatementAlterTable& StatementAlterTable::toColumn(const Column& newColumn)\n{\n    syntax().newColumn = newColumn;\n    return *this;\n}\n\nStatementAlterTable& StatementAlterTable::addColumn(const ColumnDef& columnDef)\n{\n    syntax().switcher = Syntax::AlterTableSTMT::Switch::AddColumn;\n    syntax().columnDef = columnDef;\n    return *this;\n}\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/statement/StatementAlterTable.hpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"Statement.hpp\"\n\nnamespace WCDB {\n\nclass WCDB_API StatementAlterTable final\n: public SpecifiedSyntax<Syntax::AlterTableSTMT, Statement> {\npublic:\n    using SpecifiedSyntax<Syntax::AlterTableSTMT, Statement>::SpecifiedSyntax;\n    StatementAlterTable();\n    ~StatementAlterTable() override;\n\n    StatementAlterTable& alterTable(const UnsafeStringView& table);\n    StatementAlterTable& schema(const Schema& schema);\n\n    StatementAlterTable& renameToTable(const UnsafeStringView& newTable);\n    StatementAlterTable& renameColumn(const Column& oldColumn);\n    StatementAlterTable& toColumn(const Column& newColumn);\n    StatementAlterTable& addColumn(const ColumnDef& columnDef);\n};\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/statement/StatementAnalyze.cpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"WINQ.h\"\n\nnamespace WCDB {\n\nStatementAnalyze::StatementAnalyze() = default;\n\nStatementAnalyze::~StatementAnalyze() = default;\n\nStatementAnalyze& StatementAnalyze::analyze()\n{\n    syntax().switcher = Syntax::AnalyzeSTMT::Switch::All;\n    return *this;\n}\n\nStatementAnalyze& StatementAnalyze::schema(const Schema& schema)\n{\n    syntax().switcher = Syntax::AnalyzeSTMT::Switch::SchemaOrTableOrIndex;\n    syntax().schema = schema;\n    return *this;\n}\n\nStatementAnalyze& StatementAnalyze::table(const UnsafeStringView& table)\n{\n    syntax().switcher = Syntax::AnalyzeSTMT::Switch::SchemaOrTableOrIndex;\n    syntax().tableOrIndex = table;\n    return *this;\n}\n\nStatementAnalyze& StatementAnalyze::index(const UnsafeStringView& index)\n{\n    syntax().switcher = Syntax::AnalyzeSTMT::Switch::SchemaOrTableOrIndex;\n    syntax().tableOrIndex = index;\n    return *this;\n}\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/statement/StatementAnalyze.hpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"Statement.hpp\"\n\nnamespace WCDB {\n\nclass WCDB_API StatementAnalyze final\n: public SpecifiedSyntax<Syntax::AnalyzeSTMT, Statement> {\npublic:\n    StatementAnalyze();\n    using SpecifiedSyntax<Syntax::AnalyzeSTMT, Statement>::SpecifiedSyntax;\n    ~StatementAnalyze() override;\n\n    StatementAnalyze& analyze();\n    StatementAnalyze& schema(const Schema& schema);\n    StatementAnalyze& table(const UnsafeStringView& table);\n    StatementAnalyze& index(const UnsafeStringView& index);\n};\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/statement/StatementAttach.cpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"WINQ.h\"\n\nnamespace WCDB {\n\nStatementAttach::StatementAttach() = default;\n\nStatementAttach::~StatementAttach() = default;\n\nStatementAttach& StatementAttach::attach(const Expression& expression)\n{\n    syntax().expression = expression;\n    return *this;\n}\n\nStatementAttach& StatementAttach::as(const Schema& schema)\n{\n    syntax().schema = schema;\n    return *this;\n}\n\nStatementAttach& StatementAttach::key(const Expression& key)\n{\n    syntax().key = key;\n    return *this;\n}\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/statement/StatementAttach.hpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"Statement.hpp\"\n\nnamespace WCDB {\n\nclass WCDB_API StatementAttach final : public SpecifiedSyntax<Syntax::AttachSTMT, Statement> {\npublic:\n    using SpecifiedSyntax<Syntax::AttachSTMT, Statement>::SpecifiedSyntax;\n    StatementAttach();\n    ~StatementAttach() override;\n\n    StatementAttach& attach(const Expression& expression);\n    StatementAttach& as(const Schema& schema);\n    StatementAttach& key(const Expression& key);\n};\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/statement/StatementBegin.cpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"WINQ.h\"\n\nnamespace WCDB {\n\nStatementBegin::StatementBegin() = default;\n\nStatementBegin::~StatementBegin() = default;\n\nStatementBegin& StatementBegin::beginDeferred()\n{\n    syntax().switcher = Syntax::BeginSTMT::Switch::Deferred;\n    return *this;\n}\n\nStatementBegin& StatementBegin::beginImmediate()\n{\n    syntax().switcher = Syntax::BeginSTMT::Switch::Immediate;\n    return *this;\n}\n\nStatementBegin& StatementBegin::beginExclusive()\n{\n    syntax().switcher = Syntax::BeginSTMT::Switch::Exclusive;\n    return *this;\n}\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/statement/StatementBegin.hpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"Statement.hpp\"\n\nnamespace WCDB {\n\nclass WCDB_API StatementBegin final : public SpecifiedSyntax<Syntax::BeginSTMT, Statement> {\npublic:\n    using SpecifiedSyntax<Syntax::BeginSTMT, Statement>::SpecifiedSyntax;\n    StatementBegin();\n    ~StatementBegin() override;\n\n    StatementBegin& beginDeferred();\n    StatementBegin& beginImmediate();\n    StatementBegin& beginExclusive();\n};\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/statement/StatementCommit.cpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"WINQ.h\"\n\nnamespace WCDB {\n\nStatementCommit::StatementCommit() = default;\n\nStatementCommit::~StatementCommit() = default;\n\nStatementCommit& StatementCommit::commit()\n{\n    syntax().inited = true;\n    return *this;\n}\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/statement/StatementCommit.hpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"Statement.hpp\"\n\nnamespace WCDB {\n\nclass WCDB_API StatementCommit final : public SpecifiedSyntax<Syntax::CommitSTMT, Statement> {\npublic:\n    using SpecifiedSyntax<Syntax::CommitSTMT, Statement>::SpecifiedSyntax;\n    StatementCommit();\n    ~StatementCommit() override;\n\n    StatementCommit& commit();\n};\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/statement/StatementCreateIndex.cpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"WINQ.h\"\n\nnamespace WCDB {\n\nStatementCreateIndex::StatementCreateIndex() = default;\n\nStatementCreateIndex::~StatementCreateIndex() = default;\n\nStatementCreateIndex& StatementCreateIndex::createIndex(const UnsafeStringView& index)\n{\n    syntax().index = index;\n    return *this;\n}\n\nStatementCreateIndex& StatementCreateIndex::schema(const Schema& schema)\n{\n    syntax().schema = schema;\n    return *this;\n}\n\nStatementCreateIndex& StatementCreateIndex::unique()\n{\n    syntax().unique = true;\n    return *this;\n}\n\nStatementCreateIndex& StatementCreateIndex::ifNotExists()\n{\n    syntax().ifNotExists = true;\n    return *this;\n}\n\nStatementCreateIndex& StatementCreateIndex::table(const UnsafeStringView& table)\n{\n    syntax().table = table;\n    return *this;\n}\n\nStatementCreateIndex& StatementCreateIndex::indexed(const IndexedColumn& indexedColumn)\n{\n    syntax().indexedColumns.push_back(indexedColumn);\n    return *this;\n}\n\nStatementCreateIndex& StatementCreateIndex::where(const Expression& condition)\n{\n    syntax().condition = condition;\n    return *this;\n}\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/statement/StatementCreateIndex.hpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"Statement.hpp\"\n\nnamespace WCDB {\n\nclass WCDB_API StatementCreateIndex final\n: public SpecifiedSyntax<Syntax::CreateIndexSTMT, Statement> {\npublic:\n    using SpecifiedSyntax<Syntax::CreateIndexSTMT, Statement>::SpecifiedSyntax;\n    StatementCreateIndex();\n    ~StatementCreateIndex() override;\n\n    StatementCreateIndex& createIndex(const UnsafeStringView& index);\n    StatementCreateIndex& schema(const Schema& schema);\n    StatementCreateIndex& unique();\n    StatementCreateIndex& ifNotExists();\n    StatementCreateIndex& table(const UnsafeStringView& table);\n\n    StatementCreateIndex& indexed(const IndexedColumn& indexedColumn);\n    StatementCreateIndex& where(const Expression& condition);\n};\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/statement/StatementCreateTable.cpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"WINQ.h\"\n\nnamespace WCDB {\n\nStatementCreateTable::StatementCreateTable() = default;\n\nStatementCreateTable::~StatementCreateTable() = default;\n\nStatementCreateTable& StatementCreateTable::createTable(const UnsafeStringView& table)\n{\n    syntax().table = table;\n    return *this;\n}\n\nStatementCreateTable& StatementCreateTable::schema(const Schema& schema)\n{\n    syntax().schema = schema;\n    return *this;\n}\n\nStatementCreateTable& StatementCreateTable::temp()\n{\n    syntax().temp = true;\n    return *this;\n}\n\nStatementCreateTable& StatementCreateTable::ifNotExists()\n{\n    syntax().ifNotExists = true;\n    return *this;\n}\n\nStatementCreateTable& StatementCreateTable::as(const StatementSelect& select)\n{\n    syntax().switcher = SyntaxType::Switch::Select;\n    syntax().select = select;\n    return *this;\n}\n\nStatementCreateTable& StatementCreateTable::define(const ColumnDef& columnDef)\n{\n    syntax().switcher = SyntaxType::Switch::ColumnDefs;\n    syntax().columnDefs.push_back(columnDef);\n    return *this;\n}\n\nStatementCreateTable& StatementCreateTable::constraint(const TableConstraint& constraint)\n{\n    syntax().tableConstraints.push_back(constraint);\n    return *this;\n}\n\nStatementCreateTable& StatementCreateTable::withoutRowID()\n{\n    syntax().withoutRowid = true;\n    return *this;\n}\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/statement/StatementCreateTable.hpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"Statement.hpp\"\n\nnamespace WCDB {\n\nclass WCDB_API StatementCreateTable final\n: public SpecifiedSyntax<Syntax::CreateTableSTMT, Statement> {\npublic:\n    using SpecifiedSyntax<Syntax::CreateTableSTMT, Statement>::SpecifiedSyntax;\n    StatementCreateTable();\n    ~StatementCreateTable() override;\n\n    StatementCreateTable& createTable(const UnsafeStringView& table);\n    StatementCreateTable& schema(const Schema& schema);\n    StatementCreateTable& temp();\n\n    StatementCreateTable& ifNotExists();\n\n    StatementCreateTable& as(const StatementSelect& select);\n\n    StatementCreateTable& define(const ColumnDef& columnDef);\n    StatementCreateTable& constraint(const TableConstraint& constraint);\n    StatementCreateTable& withoutRowID();\n};\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/statement/StatementCreateTrigger.cpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"WINQ.h\"\n\nnamespace WCDB {\n\nStatementCreateTrigger::StatementCreateTrigger() = default;\n\nStatementCreateTrigger::~StatementCreateTrigger() = default;\n\nStatementCreateTrigger& StatementCreateTrigger::createTrigger(const UnsafeStringView& trigger)\n{\n    syntax().trigger = trigger;\n    return *this;\n}\n\nStatementCreateTrigger& StatementCreateTrigger::schema(const Schema& schema)\n{\n    syntax().schema = schema;\n    return *this;\n}\n\nStatementCreateTrigger& StatementCreateTrigger::temp()\n{\n    syntax().temp = true;\n    return *this;\n}\n\nStatementCreateTrigger& StatementCreateTrigger::ifNotExists()\n{\n    syntax().ifNotExists = true;\n    return *this;\n}\n\nStatementCreateTrigger& StatementCreateTrigger::before()\n{\n    syntax().specifiedTiming = true;\n    syntax().timing = SyntaxType::Timing::Before;\n    return *this;\n}\n\nStatementCreateTrigger& StatementCreateTrigger::after()\n{\n    syntax().specifiedTiming = true;\n    syntax().timing = SyntaxType::Timing::After;\n    return *this;\n}\n\nStatementCreateTrigger& StatementCreateTrigger::insteadOf()\n{\n    syntax().specifiedTiming = true;\n    syntax().timing = SyntaxType::Timing::InsteadOf;\n    return *this;\n}\n\nStatementCreateTrigger& StatementCreateTrigger::delete_()\n{\n    syntax().event = SyntaxType::Event::Delete;\n    return *this;\n}\n\nStatementCreateTrigger& StatementCreateTrigger::insert()\n{\n    syntax().event = SyntaxType::Event::Insert;\n    return *this;\n}\n\nStatementCreateTrigger& StatementCreateTrigger::update()\n{\n    syntax().event = SyntaxType::Event::Update;\n    return *this;\n}\n\nStatementCreateTrigger& StatementCreateTrigger::column(const Column& column)\n{\n    syntax().columns.push_back(column);\n    return *this;\n}\n\nStatementCreateTrigger& StatementCreateTrigger::on(const UnsafeStringView& table)\n{\n    syntax().table = table;\n    return *this;\n}\n\nStatementCreateTrigger& StatementCreateTrigger::forEachRow()\n{\n    syntax().forEachFow = true;\n    return *this;\n}\n\nStatementCreateTrigger& StatementCreateTrigger::when(const Expression& condition)\n{\n    syntax().condition = condition;\n    return *this;\n}\n\nStatementCreateTrigger& StatementCreateTrigger::execute(const StatementInsert& statement)\n{\n    syntax().stmts.push_back(SyntaxType::STMT::Insert);\n    syntax().inserts.push_back(statement);\n    return *this;\n}\n\nStatementCreateTrigger& StatementCreateTrigger::execute(const StatementUpdate& statement)\n{\n    syntax().stmts.push_back(SyntaxType::STMT::Update);\n    syntax().updates.push_back(statement);\n    return *this;\n}\n\nStatementCreateTrigger& StatementCreateTrigger::execute(const StatementDelete& statement)\n{\n    syntax().stmts.push_back(SyntaxType::STMT::Delete);\n    syntax().deletes.push_back(statement);\n    return *this;\n}\n\nStatementCreateTrigger& StatementCreateTrigger::execute(const StatementSelect& statement)\n{\n    syntax().stmts.push_back(SyntaxType::STMT::Select);\n    syntax().selects.push_back(statement);\n    return *this;\n}\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/statement/StatementCreateTrigger.hpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"Statement.hpp\"\n\nnamespace WCDB {\n\nclass WCDB_API StatementCreateTrigger final\n: public SpecifiedSyntax<Syntax::CreateTriggerSTMT, Statement> {\npublic:\n    using SpecifiedSyntax<Syntax::CreateTriggerSTMT, Statement>::SpecifiedSyntax;\n    StatementCreateTrigger();\n    ~StatementCreateTrigger() override;\n\n    StatementCreateTrigger& createTrigger(const UnsafeStringView& trigger);\n    StatementCreateTrigger& schema(const Schema& schema);\n    StatementCreateTrigger& temp();\n    StatementCreateTrigger& ifNotExists();\n\n    StatementCreateTrigger& before();\n    StatementCreateTrigger& after();\n    StatementCreateTrigger& insteadOf();\n\n    StatementCreateTrigger& delete_();\n    StatementCreateTrigger& insert();\n    StatementCreateTrigger& update();\n    StatementCreateTrigger& column(const Column& column);\n\n    StatementCreateTrigger& on(const UnsafeStringView& table);\n\n    StatementCreateTrigger& forEachRow();\n\n    StatementCreateTrigger& when(const Expression& condition);\n\n    StatementCreateTrigger& execute(const StatementInsert& statement);\n    StatementCreateTrigger& execute(const StatementUpdate& statement);\n    StatementCreateTrigger& execute(const StatementDelete& statement);\n    StatementCreateTrigger& execute(const StatementSelect& statement);\n};\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/statement/StatementCreateView.cpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"WINQ.h\"\n\nnamespace WCDB {\n\nStatementCreateView::StatementCreateView() = default;\n\nStatementCreateView::~StatementCreateView() = default;\n\nStatementCreateView& StatementCreateView::createView(const UnsafeStringView& view)\n{\n    syntax().view = view;\n    return *this;\n}\n\nStatementCreateView& StatementCreateView::schema(const Schema& schema)\n{\n    syntax().schema = schema;\n    return *this;\n}\n\nStatementCreateView& StatementCreateView::temp()\n{\n    syntax().temp = true;\n    return *this;\n}\n\nStatementCreateView& StatementCreateView::ifNotExists()\n{\n    syntax().ifNotExists = true;\n    return *this;\n}\n\nStatementCreateView& StatementCreateView::columns(const Columns& columns)\n{\n    syntax().columns = columns;\n    return *this;\n}\n\nStatementCreateView& StatementCreateView::as(const StatementSelect& select)\n{\n    syntax().select = select;\n    return *this;\n}\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/statement/StatementCreateView.hpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"Statement.hpp\"\n\nnamespace WCDB {\n\nclass WCDB_API StatementCreateView final\n: public SpecifiedSyntax<Syntax::CreateViewSTMT, Statement> {\npublic:\n    using SpecifiedSyntax<Syntax::CreateViewSTMT, Statement>::SpecifiedSyntax;\n    StatementCreateView();\n    ~StatementCreateView() override;\n\n    StatementCreateView& createView(const UnsafeStringView& view);\n    StatementCreateView& schema(const Schema& schema);\n    StatementCreateView& temp();\n\n    StatementCreateView& ifNotExists();\n\n    StatementCreateView& columns(const Columns& columns);\n\n    StatementCreateView& as(const StatementSelect& select);\n};\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/statement/StatementCreateVirtualTable.cpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"WINQ.h\"\n\nnamespace WCDB {\n\nStatementCreateVirtualTable::StatementCreateVirtualTable() = default;\n\nStatementCreateVirtualTable::~StatementCreateVirtualTable() = default;\n\nStatementCreateVirtualTable&\nStatementCreateVirtualTable::createVirtualTable(const UnsafeStringView& table)\n{\n    syntax().table = table;\n    return *this;\n}\n\nStatementCreateVirtualTable& StatementCreateVirtualTable::schema(const Schema& schema)\n{\n    syntax().schema = schema;\n    return *this;\n}\n\nStatementCreateVirtualTable& StatementCreateVirtualTable::ifNotExists()\n{\n    syntax().ifNotExists = true;\n    return *this;\n}\n\nStatementCreateVirtualTable&\nStatementCreateVirtualTable::usingModule(const UnsafeStringView& module)\n{\n    syntax().module = module;\n    return *this;\n}\n\nStatementCreateVirtualTable&\nStatementCreateVirtualTable::argument(const UnsafeStringView& argument)\n{\n    syntax().arguments.push_back(StringView(argument));\n    return *this;\n}\n\nStatementCreateVirtualTable& StatementCreateVirtualTable::argument(const SQL& argument)\n{\n    syntax().arguments.push_back(argument.getDescription());\n    return *this;\n}\n\nStringView StatementCreateVirtualTable::externalContent(const UnsafeStringView& tableName)\n{\n    return StringView::formatted(\"content='%s'\", tableName.data());\n}\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/statement/StatementCreateVirtualTable.hpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"Statement.hpp\"\n\nnamespace WCDB {\n\nclass WCDB_API StatementCreateVirtualTable\n: public SpecifiedSyntax<Syntax::CreateVirtualTableSTMT, Statement> {\npublic:\n    using SpecifiedSyntax<Syntax::CreateVirtualTableSTMT, Statement>::SpecifiedSyntax;\n    StatementCreateVirtualTable();\n    ~StatementCreateVirtualTable() override;\n\n    StatementCreateVirtualTable& createVirtualTable(const UnsafeStringView& table);\n    StatementCreateVirtualTable& schema(const Schema& schema);\n\n    StatementCreateVirtualTable& ifNotExists();\n\n    StatementCreateVirtualTable& usingModule(const UnsafeStringView& module);\n\n    StatementCreateVirtualTable& argument(const UnsafeStringView& argument);\n    StatementCreateVirtualTable& argument(const SQL& argument);\n    static StringView externalContent(const UnsafeStringView& tableName);\n};\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/statement/StatementDelete.cpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"WINQ.h\"\n\nnamespace WCDB {\n\nStatementDelete::StatementDelete() = default;\n\nStatementDelete::~StatementDelete() = default;\n\nStatementDelete& StatementDelete::with(const CommonTableExpressions& commonTableExpressions)\n{\n    syntax().commonTableExpressions = commonTableExpressions;\n    return *this;\n}\n\nStatementDelete& StatementDelete::recursive()\n{\n    syntax().recursive = true;\n    return *this;\n}\n\nStatementDelete& StatementDelete::deleteFrom(const QualifiedTable& table)\n{\n    syntax().table = table;\n    return *this;\n}\n\nStatementDelete& StatementDelete::where(const Expression& condition)\n{\n    syntax().condition = condition;\n    return *this;\n}\n\nStatementDelete& StatementDelete::orders(const OrderingTerms& orderingTerms)\n{\n    syntax().orderingTerms = orderingTerms;\n    return *this;\n}\n\nStatementDelete& StatementDelete::limit(const Expression& from, const Expression& to)\n{\n    syntax().limitParameterType = Syntax::LimitParameterType::End;\n    syntax().limit = from;\n    syntax().limitParameter = to;\n    return *this;\n}\n\nStatementDelete& StatementDelete::limit(const Expression& limit)\n{\n    syntax().limitParameterType = Syntax::LimitParameterType::NotSet;\n    syntax().limit = limit;\n    return *this;\n}\n\nStatementDelete& StatementDelete::offset(const Expression& offset)\n{\n    syntax().limitParameterType = Syntax::LimitParameterType::Offset;\n    syntax().limitParameter = offset;\n    return *this;\n}\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/statement/StatementDelete.hpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"Statement.hpp\"\n\nnamespace WCDB {\n\nclass WCDB_API StatementDelete final : public SpecifiedSyntax<Syntax::DeleteSTMT, Statement> {\npublic:\n    using SpecifiedSyntax<Syntax::DeleteSTMT, Statement>::SpecifiedSyntax;\n    StatementDelete();\n    ~StatementDelete() override;\n\n    StatementDelete& with(const CommonTableExpressions& commonTableExpressions);\n    StatementDelete& recursive();\n\n    StatementDelete& deleteFrom(const QualifiedTable& table);\n    StatementDelete& where(const Expression& condition);\n    StatementDelete& orders(const OrderingTerms& orderingTerms);\n\n    StatementDelete& limit(const Expression& from, const Expression& to);\n\n    StatementDelete& limit(const Expression& limit);\n    StatementDelete& offset(const Expression& offset);\n};\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/statement/StatementDetach.cpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"WINQ.h\"\n\nnamespace WCDB {\n\nStatementDetach::StatementDetach() = default;\n\nStatementDetach::~StatementDetach() = default;\n\nStatementDetach& StatementDetach::detach(const Schema& schema)\n{\n    syntax().schema = schema;\n    return *this;\n}\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/statement/StatementDetach.hpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"Statement.hpp\"\n\nnamespace WCDB {\n\nclass WCDB_API StatementDetach final : public SpecifiedSyntax<Syntax::DetachSTMT, Statement> {\npublic:\n    using SpecifiedSyntax<Syntax::DetachSTMT, Statement>::SpecifiedSyntax;\n    StatementDetach();\n    ~StatementDetach() override;\n\n    StatementDetach& detach(const Schema& schema);\n};\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/statement/StatementDropIndex.cpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"WINQ.h\"\n\nnamespace WCDB {\n\nStatementDropIndex::StatementDropIndex() = default;\n\nStatementDropIndex::~StatementDropIndex() = default;\n\nStatementDropIndex& StatementDropIndex::dropIndex(const UnsafeStringView& index)\n{\n    syntax().index = index;\n    return *this;\n}\n\nStatementDropIndex& StatementDropIndex::schema(const Schema& schema)\n{\n    syntax().schema = schema;\n    return *this;\n}\n\nStatementDropIndex& StatementDropIndex::ifExists()\n{\n    syntax().ifExists = true;\n    return *this;\n}\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/statement/StatementDropIndex.hpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"Statement.hpp\"\n\nnamespace WCDB {\n\nclass WCDB_API StatementDropIndex final\n: public SpecifiedSyntax<Syntax::DropIndexSTMT, Statement> {\npublic:\n    using SpecifiedSyntax<Syntax::DropIndexSTMT, Statement>::SpecifiedSyntax;\n    StatementDropIndex();\n    ~StatementDropIndex() override;\n\n    StatementDropIndex& dropIndex(const UnsafeStringView& index);\n    StatementDropIndex& schema(const Schema& schema);\n    StatementDropIndex& ifExists();\n};\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/statement/StatementDropTable.cpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"WINQ.h\"\n\nnamespace WCDB {\n\nStatementDropTable::StatementDropTable() = default;\n\nStatementDropTable::~StatementDropTable() = default;\n\nStatementDropTable& StatementDropTable::dropTable(const UnsafeStringView& table)\n{\n    syntax().table = table;\n    return *this;\n}\n\nStatementDropTable& StatementDropTable::schema(const Schema& schema)\n{\n    syntax().schema = schema;\n    return *this;\n}\n\nStatementDropTable& StatementDropTable::ifExists()\n{\n    syntax().ifExists = true;\n    return *this;\n}\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/statement/StatementDropTable.hpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"Statement.hpp\"\n\nnamespace WCDB {\n\nclass WCDB_API StatementDropTable final\n: public SpecifiedSyntax<Syntax::DropTableSTMT, Statement> {\npublic:\n    using SpecifiedSyntax<Syntax::DropTableSTMT, Statement>::SpecifiedSyntax;\n    StatementDropTable();\n    ~StatementDropTable() override;\n\n    StatementDropTable& dropTable(const UnsafeStringView& table);\n    StatementDropTable& schema(const Schema& schema);\n    StatementDropTable& ifExists();\n};\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/statement/StatementDropTrigger.cpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"WINQ.h\"\n\nnamespace WCDB {\n\nStatementDropTrigger::StatementDropTrigger() = default;\n\nStatementDropTrigger::~StatementDropTrigger() = default;\n\nStatementDropTrigger& StatementDropTrigger::dropTrigger(const UnsafeStringView& trigger)\n{\n    syntax().trigger = trigger;\n    return *this;\n}\n\nStatementDropTrigger& StatementDropTrigger::schema(const Schema& schema)\n{\n    syntax().schema = schema;\n    return *this;\n}\n\nStatementDropTrigger& StatementDropTrigger::ifExists()\n{\n    syntax().ifExists = true;\n    return *this;\n}\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/statement/StatementDropTrigger.hpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"Statement.hpp\"\n\nnamespace WCDB {\n\nclass WCDB_API StatementDropTrigger final\n: public SpecifiedSyntax<Syntax::DropTriggerSTMT, Statement> {\npublic:\n    using SpecifiedSyntax<Syntax::DropTriggerSTMT, Statement>::SpecifiedSyntax;\n    StatementDropTrigger();\n    ~StatementDropTrigger() override;\n\n    StatementDropTrigger& dropTrigger(const UnsafeStringView& trigger);\n    StatementDropTrigger& schema(const Schema& schema);\n    StatementDropTrigger& ifExists();\n};\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/statement/StatementDropView.cpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"WINQ.h\"\n\nnamespace WCDB {\n\nStatementDropView::StatementDropView() = default;\n\nStatementDropView::~StatementDropView() = default;\n\nStatementDropView& StatementDropView::dropView(const UnsafeStringView& view)\n{\n    syntax().view = view;\n    return *this;\n}\n\nStatementDropView& StatementDropView::schema(const Schema& schema)\n{\n    syntax().schema = schema;\n    return *this;\n}\n\nStatementDropView& StatementDropView::ifExists()\n{\n    syntax().ifExists = true;\n    return *this;\n}\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/statement/StatementDropView.hpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"Statement.hpp\"\n\nnamespace WCDB {\n\nclass WCDB_API StatementDropView final\n: public SpecifiedSyntax<Syntax::DropViewSTMT, Statement> {\npublic:\n    using SpecifiedSyntax<Syntax::DropViewSTMT, Statement>::SpecifiedSyntax;\n    StatementDropView();\n    ~StatementDropView() override;\n\n    StatementDropView& dropView(const UnsafeStringView& view);\n    StatementDropView& schema(const Schema& schema);\n    StatementDropView& ifExists();\n};\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/statement/StatementExplain.cpp",
    "content": "//\n// Created by sanhuazhang on 2019/08/30\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"WINQ.h\"\n\nnamespace WCDB {\n\nStatementExplain::StatementExplain() = default;\n\nStatementExplain::~StatementExplain() = default;\n\nStatementExplain& StatementExplain::explain(const Statement& statement)\n{\n    explain(statement, false);\n    return *this;\n}\n\nStatementExplain& StatementExplain::explainQueryPlan(const Statement& statement)\n{\n    explain(statement, true);\n    return *this;\n}\n\nvoid StatementExplain::explain(const Statement& statement, bool queryPlan)\n{\n    syntax().queryPlan = queryPlan;\n    syntax().stmt = statement.syntax();\n}\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/statement/StatementExplain.hpp",
    "content": "//\n// Created by sanhuazhang on 2019/08/30\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"Statement.hpp\"\n\nnamespace WCDB {\n\nclass WCDB_API StatementExplain final\n: public SpecifiedSyntax<Syntax::ExplainSTMT, Statement> {\npublic:\n    using SpecifiedSyntax<Syntax::ExplainSTMT, Statement>::SpecifiedSyntax;\n    StatementExplain();\n    ~StatementExplain() override;\n\n    StatementExplain& explain(const Statement& statement);\n    StatementExplain& explainQueryPlan(const Statement& statement);\n\nprivate:\n    void explain(const Statement& statement, bool queryPlan);\n};\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/statement/StatementInsert.cpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"WINQ.h\"\n\nnamespace WCDB {\n\nStatementInsert::StatementInsert() = default;\n\nStatementInsert::~StatementInsert() = default;\n\nStatementInsert& StatementInsert::with(const CommonTableExpressions& commonTableExpressions)\n{\n    syntax().commonTableExpressions = commonTableExpressions;\n    return *this;\n}\n\nStatementInsert& StatementInsert::recursive()\n{\n    syntax().recursive = true;\n    return *this;\n}\n\nStatementInsert& StatementInsert::insertIntoTable(const UnsafeStringView& table)\n{\n    syntax().table = table;\n    return *this;\n}\n\nStatementInsert& StatementInsert::schema(const Schema& schema)\n{\n    syntax().schema = schema;\n    return *this;\n}\n\nStatementInsert& StatementInsert::orReplace()\n{\n    syntax().conflictAction = Syntax::ConflictAction::Replace;\n    return *this;\n}\n\nStatementInsert& StatementInsert::orRollback()\n{\n    syntax().conflictAction = Syntax::ConflictAction::Rollback;\n    return *this;\n}\n\nStatementInsert& StatementInsert::orAbort()\n{\n    syntax().conflictAction = Syntax::ConflictAction::Abort;\n    return *this;\n}\n\nStatementInsert& StatementInsert::orFail()\n{\n    syntax().conflictAction = Syntax::ConflictAction::Fail;\n    return *this;\n}\n\nStatementInsert& StatementInsert::orIgnore()\n{\n    syntax().conflictAction = Syntax::ConflictAction::Ignore;\n    return *this;\n}\n\nStatementInsert& StatementInsert::as(const UnsafeStringView& alias)\n{\n    syntax().alias = alias;\n    return *this;\n}\n\nStatementInsert& StatementInsert::column(const Column& column)\n{\n    syntax().columns.push_back(column);\n    return *this;\n}\n\nStatementInsert& StatementInsert::columns(const Columns& columns)\n{\n    syntax().columns = columns;\n    return *this;\n}\n\nStatementInsert& StatementInsert::value(const Expression& expression)\n{\n    syntax().switcher = SyntaxType::Switch::Values;\n    if (syntax().expressionsValues.empty()) {\n        syntax().expressionsValues.push_back({});\n    }\n    syntax().expressionsValues.begin()->push_back(expression);\n    return *this;\n}\n\nStatementInsert& StatementInsert::values(const Expressions& expressions)\n{\n    syntax().switcher = SyntaxType::Switch::Values;\n    syntax().expressionsValues.push_back(expressions);\n    return *this;\n}\n\nStatementInsert& StatementInsert::values(const StatementSelect& select)\n{\n    syntax().switcher = SyntaxType::Switch::Select;\n    syntax().select = select;\n    return *this;\n}\n\nStatementInsert& StatementInsert::defaultValues()\n{\n    syntax().switcher = SyntaxType::Switch::Default;\n    return *this;\n}\n\nStatementInsert& StatementInsert::upsert(const Upsert& upsert)\n{\n    syntax().upsertClause = upsert;\n    return *this;\n}\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/statement/StatementInsert.hpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"Statement.hpp\"\n\nnamespace WCDB {\n\nclass WCDB_API StatementInsert final : public SpecifiedSyntax<Syntax::InsertSTMT, Statement> {\npublic:\n    using SpecifiedSyntax<Syntax::InsertSTMT, Statement>::SpecifiedSyntax;\n    StatementInsert();\n    ~StatementInsert() override;\n\n    StatementInsert& with(const CommonTableExpressions& commonTableExpressions);\n    StatementInsert& recursive();\n\n    StatementInsert& insertIntoTable(const UnsafeStringView& table);\n    StatementInsert& schema(const Schema& schema);\n\n    StatementInsert& orReplace();\n    StatementInsert& orRollback();\n    StatementInsert& orAbort();\n    StatementInsert& orFail();\n    StatementInsert& orIgnore();\n\n    StatementInsert& as(const UnsafeStringView& alias);\n\n    StatementInsert& column(const Column& column);\n    StatementInsert& columns(const Columns& columns);\n\n    StatementInsert& value(const Expression& expression);\n    StatementInsert& values(const Expressions& expressions);\n    StatementInsert& values(const StatementSelect& select);\n    StatementInsert& defaultValues();\n\n    StatementInsert& upsert(const Upsert& upsert);\n};\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/statement/StatementPragma.cpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"WINQ.h\"\n\nnamespace WCDB {\n\nStatementPragma::StatementPragma() = default;\n\nStatementPragma::~StatementPragma() = default;\n\nStatementPragma& StatementPragma::pragma(const Pragma& pragma)\n{\n    syntax().pragma = pragma;\n    syntax().switcher = SyntaxType::Switch::NotSet;\n    return *this;\n}\n\nStatementPragma& StatementPragma::schema(const Schema& schema)\n{\n    syntax().schema = schema;\n    return *this;\n}\n\nStatementPragma& StatementPragma::to(const LiteralValue& value)\n{\n    syntax().switcher = SyntaxType::Switch::To;\n    syntax().value = value;\n    return *this;\n}\n\nStatementPragma& StatementPragma::with(const LiteralValue& value)\n{\n    syntax().switcher = SyntaxType::Switch::With;\n    const StringView& stringValue = value.syntax().stringValue;\n    if (stringValue.length() > 2) {\n        if ((stringValue.hasPrefix(\"'\") && stringValue.hasSuffix(\"'\"))\n            || (stringValue.hasPrefix(\"[\") && stringValue.hasSuffix(\"]\"))\n            || (stringValue.hasPrefix(\"`\") && stringValue.hasSuffix(\"`\"))) {\n            const UnsafeStringView unQuateValue\n            = UnsafeStringView(stringValue.data() + 1, stringValue.length() - 2);\n            syntax().value = LiteralValue(unQuateValue);\n            return *this;\n        }\n    }\n    syntax().value = value;\n    return *this;\n}\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/statement/StatementPragma.hpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"Statement.hpp\"\n\nnamespace WCDB {\n\nclass WCDB_API StatementPragma final : public SpecifiedSyntax<Syntax::PragmaSTMT, Statement> {\npublic:\n    using SpecifiedSyntax<Syntax::PragmaSTMT, Statement>::SpecifiedSyntax;\n    StatementPragma();\n    ~StatementPragma() override;\n\n    StatementPragma& pragma(const Pragma& pragma);\n    StatementPragma& schema(const Schema& Schema);\n    StatementPragma& to(const LiteralValue& value);\n    StatementPragma& with(const LiteralValue& value);\n};\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/statement/StatementReindex.cpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"WINQ.h\"\n\nnamespace WCDB {\n\nStatementReindex::StatementReindex() = default;\n\nStatementReindex::~StatementReindex() = default;\n\nStatementReindex& StatementReindex::reindex()\n{\n    syntax().switcher = SyntaxType::Switch::NotSet;\n    return *this;\n}\n\nStatementReindex& StatementReindex::collation(const UnsafeStringView& collation)\n{\n    syntax().switcher = SyntaxType::Switch::Collation;\n    syntax().collationOrTableOrIndex = collation;\n    return *this;\n}\n\nStatementReindex& StatementReindex::table(const UnsafeStringView& table)\n{\n    syntax().switcher = SyntaxType::Switch::TableOrIndex;\n    syntax().collationOrTableOrIndex = table;\n    return *this;\n}\n\nStatementReindex& StatementReindex::schema(const Schema& schema)\n{\n    syntax().schema = schema;\n    return *this;\n}\n\nStatementReindex& StatementReindex::index(const UnsafeStringView& index)\n{\n    syntax().switcher = SyntaxType::Switch::TableOrIndex;\n    syntax().collationOrTableOrIndex = index;\n    return *this;\n}\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/statement/StatementReindex.hpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"Statement.hpp\"\n\nnamespace WCDB {\n\nclass WCDB_API StatementReindex final\n: public SpecifiedSyntax<Syntax::ReindexSTMT, Statement> {\npublic:\n    using SpecifiedSyntax<Syntax::ReindexSTMT, Statement>::SpecifiedSyntax;\n    StatementReindex();\n    ~StatementReindex() override;\n\n    StatementReindex& reindex();\n    StatementReindex& collation(const UnsafeStringView& collation);\n    StatementReindex& table(const UnsafeStringView& table);\n    StatementReindex& index(const UnsafeStringView& index);\n    StatementReindex& schema(const Schema& schema);\n};\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/statement/StatementRelease.cpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"WINQ.h\"\n\nnamespace WCDB {\n\nStatementRelease::StatementRelease() = default;\n\nStatementRelease::~StatementRelease() = default;\n\nStatementRelease& StatementRelease::release(const UnsafeStringView& savepoint)\n{\n    syntax().savepoint = savepoint;\n    return *this;\n}\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/statement/StatementRelease.hpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"Statement.hpp\"\n\nnamespace WCDB {\n\nclass WCDB_API StatementRelease final\n: public SpecifiedSyntax<Syntax::ReleaseSTMT, Statement> {\npublic:\n    using SpecifiedSyntax<Syntax::ReleaseSTMT, Statement>::SpecifiedSyntax;\n    StatementRelease();\n    ~StatementRelease() override;\n\n    StatementRelease& release(const UnsafeStringView& savepoint);\n};\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/statement/StatementRollback.cpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"WINQ.h\"\n\nnamespace WCDB {\n\nStatementRollback::StatementRollback() = default;\n\nStatementRollback::~StatementRollback() = default;\n\nStatementRollback& StatementRollback::rollback()\n{\n    syntax().switcher = Syntax::RollbackSTMT::Switch::Transaction;\n    syntax().savepoint.clear();\n    return *this;\n}\n\nStatementRollback& StatementRollback::rollbackToSavepoint(const UnsafeStringView& savepoint)\n{\n    syntax().switcher = Syntax::RollbackSTMT::Switch::Savepoint;\n    syntax().savepoint = savepoint;\n    return *this;\n}\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/statement/StatementRollback.hpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"Statement.hpp\"\n\nnamespace WCDB {\n\nclass WCDB_API StatementRollback final\n: public SpecifiedSyntax<Syntax::RollbackSTMT, Statement> {\npublic:\n    using SpecifiedSyntax<Syntax::RollbackSTMT, Statement>::SpecifiedSyntax;\n    StatementRollback();\n    ~StatementRollback() override;\n\n    StatementRollback& rollback();\n    StatementRollback& rollbackToSavepoint(const UnsafeStringView& savepoint);\n};\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/statement/StatementSavepoint.cpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"WINQ.h\"\n\nnamespace WCDB {\n\nStatementSavepoint::StatementSavepoint() = default;\n\nStatementSavepoint::~StatementSavepoint() = default;\n\nStatementSavepoint& StatementSavepoint::savepoint(const UnsafeStringView& savepoint)\n{\n    syntax().savepoint = savepoint;\n    return *this;\n}\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/statement/StatementSavepoint.hpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"Statement.hpp\"\n\nnamespace WCDB {\n\nclass WCDB_API StatementSavepoint final\n: public SpecifiedSyntax<Syntax::SavepointSTMT, Statement> {\npublic:\n    using SpecifiedSyntax<Syntax::SavepointSTMT, Statement>::SpecifiedSyntax;\n    StatementSavepoint();\n    ~StatementSavepoint() override;\n\n    StatementSavepoint& savepoint(const UnsafeStringView& savepoint);\n};\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/statement/StatementSelect.cpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"WINQ.h\"\n\nnamespace WCDB {\n\nStatementSelect::StatementSelect() = default;\n\nStatementSelect::~StatementSelect() = default;\n\nStatementSelect& StatementSelect::with(const CommonTableExpressions& commonTableExpressions)\n{\n    syntax().commonTableExpressions = commonTableExpressions;\n    return *this;\n}\n\nStatementSelect& StatementSelect::recursive()\n{\n    syntax().recursive = true;\n    return *this;\n}\n\nStatementSelect& StatementSelect::select(const ResultColumns& resultColumns)\n{\n    Syntax::SelectCore& core = currentCore();\n    core.switcher = Syntax::SelectCore::Switch::Select;\n    core.resultColumns = resultColumns;\n    return *this;\n}\n\nStatementSelect& StatementSelect::distinct()\n{\n    currentCore().distinct = true;\n    return *this;\n}\n\nStatementSelect& StatementSelect::from(const TablesOrSubqueries& tablesOrSubqueries)\n{\n    Syntax::SelectCore& core = currentCore();\n    core.tableOrSubqueries = tablesOrSubqueries;\n    return *this;\n}\n\nStatementSelect& StatementSelect::from(const Join& join)\n{\n    Syntax::SelectCore& core = currentCore();\n    core.tableOrSubqueries.clear();\n    core.joinClause = join;\n    return *this;\n}\n\nStatementSelect& StatementSelect::where(const Expression& condition)\n{\n    Syntax::SelectCore& core = currentCore();\n    core.condition = condition;\n    return *this;\n}\n\nStatementSelect& StatementSelect::groups(const Expressions& groups)\n{\n    currentCore().groups = groups;\n    return *this;\n}\n\nStatementSelect& StatementSelect::group(const Expression& group)\n{\n    currentCore().groups.push_back(group);\n    return *this;\n}\n\nStatementSelect& StatementSelect::having(const Expression& having)\n{\n    Syntax::SelectCore& core = currentCore();\n    core.having = having;\n    return *this;\n}\n\nStatementSelect& StatementSelect::window(const UnsafeStringView& window)\n{\n    currentCore().windows.push_back(StringView(window));\n    return *this;\n}\n\nStatementSelect& StatementSelect::as(const WindowDef& windowDef)\n{\n    currentCore().windowDefs.push_back(windowDef);\n    return *this;\n}\n\nTableOrSubquery StatementSelect::as(const UnsafeStringView& alias)\n{\n    return TableOrSubquery(*this).as(alias);\n}\n\nStatementSelect& StatementSelect::value(const Expression& expression)\n{\n    Syntax::SelectCore& core = currentCore();\n    core.switcher = Syntax::SelectCore::Switch::Values;\n    if (core.valuesList.empty()) {\n        core.valuesList.push_back({});\n    }\n    core.valuesList.begin()->push_back(expression);\n    return *this;\n}\n\nStatementSelect& StatementSelect::values(const Expressions& expressions)\n{\n    Syntax::SelectCore& core = currentCore();\n    core.switcher = Syntax::SelectCore::Switch::Values;\n    core.valuesList.push_back(expressions);\n    return *this;\n}\n\nStatementSelect& StatementSelect::union_()\n{\n    syntax().compoundOperators.push_back(Syntax::CompoundOperator::Union);\n    syntax().cores.push_back({});\n    return *this;\n}\n\nStatementSelect& StatementSelect::unionAll()\n{\n    syntax().compoundOperators.push_back(Syntax::CompoundOperator::UnionAll);\n    syntax().cores.push_back({});\n    return *this;\n}\n\nStatementSelect& StatementSelect::intersect()\n{\n    syntax().compoundOperators.push_back(Syntax::CompoundOperator::Intersect);\n    syntax().cores.push_back({});\n    return *this;\n}\n\nStatementSelect& StatementSelect::except()\n{\n    syntax().compoundOperators.push_back(Syntax::CompoundOperator::Except);\n    syntax().cores.push_back({});\n    return *this;\n}\n\nStatementSelect& StatementSelect::order(const OrderingTerm& order)\n{\n    syntax().orderingTerms.push_back(order);\n    return *this;\n}\n\nStatementSelect& StatementSelect::orders(const OrderingTerms& orders)\n{\n    syntax().orderingTerms = orders;\n    return *this;\n}\n\nStatementSelect& StatementSelect::limit(const Expression& from, const Expression& to)\n{\n    syntax().limitParameterType = Syntax::LimitParameterType::End;\n    syntax().limit = from;\n    syntax().limitParameter = to;\n    return *this;\n}\n\nStatementSelect& StatementSelect::limit(const Expression& limit)\n{\n    syntax().limitParameterType = Syntax::LimitParameterType::NotSet;\n    syntax().limit = limit;\n    return *this;\n}\n\nStatementSelect& StatementSelect::offset(const Expression& offset)\n{\n    syntax().limitParameterType = Syntax::LimitParameterType::Offset;\n    syntax().limitParameter = offset;\n    return *this;\n}\n\nSyntax::SelectCore& StatementSelect::currentCore()\n{\n    if (syntax().cores.empty()) {\n        return syntax().select.getOrCreate();\n    } else {\n        return syntax().cores.back();\n    }\n}\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/statement/StatementSelect.hpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"Statement.hpp\"\n\nnamespace WCDB {\n\nclass TableOrSubquery;\n\nclass WCDB_API StatementSelect final : public SpecifiedSyntax<Syntax::SelectSTMT, Statement> {\npublic:\n    using SpecifiedSyntax<Syntax::SelectSTMT, Statement>::SpecifiedSyntax;\n    StatementSelect();\n    ~StatementSelect() override;\n\n    StatementSelect& with(const CommonTableExpressions& commonTableExpressions);\n    StatementSelect& recursive();\n\n    StatementSelect& select(const ResultColumns& resultColumns);\n    StatementSelect& distinct();\n    StatementSelect& from(const TablesOrSubqueries& tablesOrSubqueries);\n    StatementSelect& from(const Join& join);\n\n    StatementSelect& where(const Expression& condition);\n    StatementSelect& group(const Expression& group);\n    StatementSelect& groups(const Expressions& groups);\n    StatementSelect& having(const Expression& having);\n\n    StatementSelect& window(const UnsafeStringView& window);\n    StatementSelect& as(const WindowDef& windowDef);\n\n    TableOrSubquery as(const UnsafeStringView& alias);\n\n    StatementSelect& value(const Expression& expression);\n    StatementSelect& values(const Expressions& expressions);\n\n    StatementSelect& union_();\n    StatementSelect& unionAll();\n    StatementSelect& intersect();\n    StatementSelect& except();\n\n    StatementSelect& order(const OrderingTerm& order);\n    StatementSelect& orders(const OrderingTerms& orders);\n\n    StatementSelect& limit(const Expression& from, const Expression& to);\n\n    StatementSelect& limit(const Expression& limit);\n    StatementSelect& offset(const Expression& offset);\n\nprivate:\n    Syntax::SelectCore& currentCore();\n};\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/statement/StatementUpdate.cpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"WINQ.h\"\n\nnamespace WCDB {\n\nStatementUpdate::StatementUpdate() = default;\n\nStatementUpdate::~StatementUpdate() = default;\n\nStatementUpdate& StatementUpdate::with(const CommonTableExpressions& commonTableExpressions)\n{\n    syntax().commonTableExpressions = commonTableExpressions;\n    return *this;\n}\n\nStatementUpdate& StatementUpdate::recursive()\n{\n    syntax().recursive = true;\n    return *this;\n}\n\nStatementUpdate& StatementUpdate::update(const QualifiedTable& table)\n{\n    syntax().table = table;\n    return *this;\n}\n\nStatementUpdate& StatementUpdate::orRollback()\n{\n    syntax().conflictAction = Syntax::ConflictAction::Rollback;\n    return *this;\n}\n\nStatementUpdate& StatementUpdate::orAbort()\n{\n    syntax().conflictAction = Syntax::ConflictAction::Abort;\n    return *this;\n}\n\nStatementUpdate& StatementUpdate::orReplace()\n{\n    syntax().conflictAction = Syntax::ConflictAction::Replace;\n    return *this;\n}\n\nStatementUpdate& StatementUpdate::orFail()\n{\n    syntax().conflictAction = Syntax::ConflictAction::Fail;\n    return *this;\n}\n\nStatementUpdate& StatementUpdate::orIgnore()\n{\n    syntax().conflictAction = Syntax::ConflictAction::Ignore;\n    return *this;\n}\n\nStatementUpdate& StatementUpdate::set(const Columns& columns)\n{\n    syntax().columnsList.push_back(columns);\n    return *this;\n}\n\nStatementUpdate& StatementUpdate::to(const Expression& value)\n{\n    syntax().expressions.push_back(value);\n    return *this;\n}\n\nStatementUpdate& StatementUpdate::where(const Expression& condition)\n{\n    syntax().condition = condition;\n    return *this;\n}\n\nStatementUpdate& StatementUpdate::order(const OrderingTerm& order)\n{\n    syntax().orderingTerms.push_back(order);\n    return *this;\n}\n\nStatementUpdate& StatementUpdate::orders(const OrderingTerms& orders)\n{\n    syntax().orderingTerms = orders;\n    return *this;\n}\n\nStatementUpdate& StatementUpdate::limit(const Expression& from, const Expression& to)\n{\n    syntax().limitParameterType = Syntax::LimitParameterType::End;\n    syntax().limit = from;\n    syntax().limitParameter = to;\n    return *this;\n}\n\nStatementUpdate& StatementUpdate::limit(const Expression& limit)\n{\n    syntax().limitParameterType = Syntax::LimitParameterType::NotSet;\n    syntax().limit = limit;\n    return *this;\n}\n\nStatementUpdate& StatementUpdate::offset(const Expression& offset)\n{\n    syntax().limitParameterType = Syntax::LimitParameterType::Offset;\n    syntax().limitParameter = offset;\n    return *this;\n}\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/statement/StatementUpdate.hpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"Statement.hpp\"\n\nnamespace WCDB {\n\nclass WCDB_API StatementUpdate final : public SpecifiedSyntax<Syntax::UpdateSTMT, Statement> {\npublic:\n    using SpecifiedSyntax<Syntax::UpdateSTMT, Statement>::SpecifiedSyntax;\n    StatementUpdate();\n    ~StatementUpdate() override;\n\n    StatementUpdate& with(const CommonTableExpressions& commonTableExpressions);\n    StatementUpdate& recursive();\n\n    StatementUpdate& update(const QualifiedTable& table);\n    StatementUpdate& orRollback();\n    StatementUpdate& orAbort();\n    StatementUpdate& orReplace();\n    StatementUpdate& orFail();\n    StatementUpdate& orIgnore();\n\n    StatementUpdate& set(const Columns& columns);\n    StatementUpdate& to(const Expression& value);\n\n    StatementUpdate& where(const Expression& condition);\n\n    StatementUpdate& order(const OrderingTerm& order);\n    StatementUpdate& orders(const OrderingTerms& orders);\n\n    StatementUpdate& limit(const Expression& from, const Expression& to);\n\n    StatementUpdate& limit(const Expression& limit);\n    StatementUpdate& offset(const Expression& offset);\n};\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/statement/StatementVacuum.cpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"WINQ.h\"\n\nnamespace WCDB {\n\nStatementVacuum::StatementVacuum() = default;\n\nStatementVacuum::~StatementVacuum() = default;\n\nStatementVacuum& StatementVacuum::vacuum()\n{\n    syntax().switcher = Syntax::VacuumSTMT::Switch::All;\n    return *this;\n}\n\nStatementVacuum& StatementVacuum::vacuum(const Schema& schema)\n{\n    syntax().switcher = Syntax::VacuumSTMT::Switch::Schema;\n    syntax().schema = schema;\n    return *this;\n}\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/statement/StatementVacuum.hpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"Statement.hpp\"\n\nnamespace WCDB {\n\nclass WCDB_API StatementVacuum final : public SpecifiedSyntax<Syntax::VacuumSTMT, Statement> {\npublic:\n    using SpecifiedSyntax<Syntax::VacuumSTMT, Statement>::SpecifiedSyntax;\n    StatementVacuum();\n    ~StatementVacuum() override;\n\n    StatementVacuum& vacuum();\n    StatementVacuum& vacuum(const Schema& schema);\n};\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/syntax/Syntax.h",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n// See also: https://sqlite.org/syntaxdiagrams.html\n\n// TODO: use double-quotes for all identifiers to accept SQLite keyword. https://sqlite.org/c3ref/keyword_check.html\n\n#include \"SyntaxCommonConst.hpp\"\n\n#include \"SyntaxColumn.hpp\"\n#include \"SyntaxColumnConstraint.hpp\"\n#include \"SyntaxColumnDef.hpp\"\n#include \"SyntaxCommonTableExpression.hpp\"\n#include \"SyntaxExpression.hpp\"\n#include \"SyntaxFilter.hpp\"\n#include \"SyntaxForeignKeyClause.hpp\"\n#include \"SyntaxFrameSpec.hpp\"\n#include \"SyntaxIdentifier.hpp\"\n#include \"SyntaxIndexedColumn.hpp\"\n#include \"SyntaxJoinClause.hpp\"\n#include \"SyntaxJoinConstraint.hpp\"\n#include \"SyntaxLiteralValue.hpp\"\n#include \"SyntaxOrderingTerm.hpp\"\n#include \"SyntaxPragma.hpp\"\n#include \"SyntaxQualifiedTableName.hpp\"\n#include \"SyntaxResultColumn.hpp\"\n#include \"SyntaxSchema.hpp\"\n#include \"SyntaxSelectCore.hpp\"\n#include \"SyntaxSelectSTMT.hpp\"\n#include \"SyntaxTableConstraint.hpp\"\n#include \"SyntaxTableOrSubquery.hpp\"\n#include \"SyntaxUpsertClause.hpp\"\n\n#include \"SyntaxAlterTableSTMT.hpp\"\n#include \"SyntaxAnalyzeSTMT.hpp\"\n#include \"SyntaxAttachSTMT.hpp\"\n#include \"SyntaxBeginSTMT.hpp\"\n#include \"SyntaxCommitSTMT.hpp\"\n#include \"SyntaxCreateIndexSTMT.hpp\"\n#include \"SyntaxCreateTableSTMT.hpp\"\n#include \"SyntaxCreateTriggerSTMT.hpp\"\n#include \"SyntaxCreateViewSTMT.hpp\"\n#include \"SyntaxCreateVirtualTableSTMT.hpp\"\n#include \"SyntaxDeleteSTMT.hpp\"\n#include \"SyntaxDetachSTMT.hpp\"\n#include \"SyntaxDropIndexSTMT.hpp\"\n#include \"SyntaxDropTableSTMT.hpp\"\n#include \"SyntaxDropTriggerSTMT.hpp\"\n#include \"SyntaxDropViewSTMT.hpp\"\n#include \"SyntaxInsertSTMT.hpp\"\n#include \"SyntaxPragmaSTMT.hpp\"\n#include \"SyntaxReindexSTMT.hpp\"\n#include \"SyntaxReleaseSTMT.hpp\"\n#include \"SyntaxRollbackSTMT.hpp\"\n#include \"SyntaxSavepointSTMT.hpp\"\n#include \"SyntaxUpdateSTMT.hpp\"\n#include \"SyntaxVacuumSTMT.hpp\"\n\n#include \"SyntaxExplainSTMT.hpp\"\n"
  },
  {
    "path": "src/common/winq/syntax/SyntaxAssertion.hpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"Assertion.hpp\"\n\n#define WCTSyntaxRemedialAssert(cond)                                          \\\n    WCTRemedialAssert(cond, \"Invalid syntax detected.\", return false;)\n\n#define WCTIterateRemedialAssert(cond)                                         \\\n    WCTRemedialAssert(cond, \"Invalid types detected.\", return;)\n"
  },
  {
    "path": "src/common/winq/syntax/SyntaxEnum.hpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"Enum.hpp\"\n#include \"SyntaxCommonConst.hpp\"\n\nnamespace WCDB {\n\ntemplate<>\nconstexpr const char* Enum::description(const Syntax::ColumnType& columnType)\n{\n    switch (columnType) {\n    case Syntax::ColumnType::Null:\n        return \"NULL\";\n    case Syntax::ColumnType::Integer:\n        return \"INTEGER\";\n    case Syntax::ColumnType::Float:\n        return \"REAL\";\n    case Syntax::ColumnType::Text:\n        return \"TEXT\";\n    case Syntax::ColumnType::BLOB:\n        return \"BLOB\";\n    }\n}\n\ntemplate<>\nconstexpr const char* Enum::description(const Syntax::CompoundOperator& compoundOperator)\n{\n    switch (compoundOperator) {\n    case Syntax::CompoundOperator::Union:\n        return \"UNION\";\n    case Syntax::CompoundOperator::UnionAll:\n        return \"UNION ALL\";\n    case Syntax::CompoundOperator::Intersect:\n        return \"INTERSECT\";\n    case Syntax::CompoundOperator::Except:\n        return \"EXCEPT\";\n    }\n}\n\ntemplate<>\nconstexpr const char* Enum::description(const Syntax::Conflict& conflict)\n{\n    switch (conflict) {\n    case Syntax::Conflict::Rollback:\n        return \"ON CONFLICT ROLLBACK\";\n    case Syntax::Conflict::Abort:\n        return \"ON CONFLICT ABORT\";\n    case Syntax::Conflict::Fail:\n        return \"ON CONFLICT FAIL\";\n    case Syntax::Conflict::Ignore:\n        return \"ON CONFLICT IGNORE\";\n    case Syntax::Conflict::Replace:\n        return \"ON CONFLICT REPLACE\";\n    }\n}\n\ntemplate<>\nconstexpr const char* Enum::description(const Syntax::JoinOperator& joinOperator)\n{\n    switch (joinOperator) {\n    case Syntax::JoinOperator::With:\n        return \",\";\n    case Syntax::JoinOperator::Join:\n        return \"JOIN\";\n    case Syntax::JoinOperator::LeftOuterJoin:\n        return \"LEFT OUTER JOIN\";\n    case Syntax::JoinOperator::LeftJoin:\n        return \"LEFT JOIN\";\n    case Syntax::JoinOperator::InnerJoin:\n        return \"INNER JOIN\";\n    case Syntax::JoinOperator::CrossJoin:\n        return \"CROSS JOIN\";\n    case Syntax::JoinOperator::NaturalJoin:\n        return \"NATURAL JOIN\";\n    case Syntax::JoinOperator::NaturalLeftOuterJoin:\n        return \"NATURAL LEFT OUTER JOIN\";\n    case Syntax::JoinOperator::NaturalLeftJoin:\n        return \"NATURAL LEFT JOIN\";\n    case Syntax::JoinOperator::NaturalInnerJoin:\n        return \"NATURAL INNER JOIN\";\n    case Syntax::JoinOperator::NaturalCrossJoin:\n        return \"NATURAL CROSS JOIN\";\n    }\n}\n\ntemplate<>\nconstexpr const char* Enum::description(const Syntax::Order& order)\n{\n    switch (order) {\n    case Syntax::Order::ASC:\n        return \"ASC\";\n    case Syntax::Order::DESC:\n        return \"DESC\";\n    }\n}\n\ntemplate<>\nconstexpr const char* Enum::description(const Syntax::ConflictAction& action)\n{\n    switch (action) {\n    case Syntax::ConflictAction::Replace:\n        return \"OR REPLACE\";\n    case Syntax::ConflictAction::Rollback:\n        return \"OR ROLLBACK\";\n    case Syntax::ConflictAction::Abort:\n        return \"OR ABORT\";\n    case Syntax::ConflictAction::Fail:\n        return \"OR FAIL\";\n    case Syntax::ConflictAction::Ignore:\n        return \"OR IGNORE\";\n    }\n}\n\ntemplate<>\nconstexpr const char* Enum::description(const Syntax::MatchType& match)\n{\n    switch (match) {\n    case Syntax::MatchType::Simple:\n        return \"SIMPLE\";\n    case Syntax::MatchType::Full:\n        return \"FULL\";\n    case Syntax::MatchType::Partial:\n        return \"PARTIAL\";\n    }\n}\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/syntax/const/SyntaxCommonConst.cpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"SyntaxCommonConst.hpp\"\n#include \"StringView.hpp\"\n\nnamespace WCDB {\n\nnamespace Syntax {\n\nbool isIntegerColumnType(const UnsafeStringView& type)\n{\n    return type.caseInsensitiveEqual(\"INTEGER\") || type.caseInsensitiveEqual(\"INT\")\n           || type.caseInsensitiveEqual(\"TINYINT\") || type.caseInsensitiveEqual(\"SMALLINT\")\n           || type.caseInsensitiveEqual(\"MEDIUMINT\") || type.caseInsensitiveEqual(\"BIGINT\")\n           || type.caseInsensitiveEqual(\"UNSIGNED BIG INT\")\n           || type.caseInsensitiveEqual(\"INT2\") || type.caseInsensitiveEqual(\"INT8\");\n}\n\nWCDBLiteralStringImplement(masterTable);\nWCDBLiteralStringImplement(sequenceTable);\nWCDBLiteralStringImplement(mainSchema);\nWCDBLiteralStringImplement(tempSchema);\nWCDBLiteralStringImplement(builtinTablePrefix);\nWCDBLiteralStringImplement(builtinWCDBTablePrefix);\nWCDBLiteralStringImplement(malformedSchemaMsg);\n\n} // namespace Syntax\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/syntax/const/SyntaxCommonConst.hpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"Macro.h\"\n\nnamespace WCDB {\n\nclass UnsafeStringView;\nclass StringView;\n\nnamespace Syntax {\n\nenum class ColumnType : signed char {\n    Null = 0,\n    Integer,\n    Float,\n    Text,\n    BLOB,\n};\n\nbool isIntegerColumnType(const UnsafeStringView& type);\n\nenum class CompoundOperator : signed char {\n    Union = 1,\n    UnionAll,\n    Intersect,\n    Except,\n};\n\nenum class Conflict : signed char {\n    Rollback = 1,\n    Abort,\n    Fail,\n    Ignore,\n    Replace,\n};\n\nenum class JoinOperator : signed char {\n    With = 1,\n    Join,\n    LeftOuterJoin,\n    LeftJoin,\n    InnerJoin,\n    CrossJoin,\n    NaturalJoin,\n    NaturalLeftOuterJoin,\n    NaturalLeftJoin,\n    NaturalInnerJoin,\n    NaturalCrossJoin,\n};\n\nenum class Order : signed char {\n    ASC = 0,\n    DESC,\n};\n\nenum class LimitParameterType : signed char {\n    NotSet = 0,\n    Offset,\n    End,\n};\n\nenum class ConflictAction : signed char {\n    Replace = 1,\n    Rollback,\n    Abort,\n    Fail,\n    Ignore,\n};\n\nenum class MatchType : signed char {\n    Simple = 1,\n    Full,\n    Partial,\n};\n\nWCDBLiteralStringDefine(masterTable, \"sqlite_master\");\nWCDBLiteralStringDefine(sequenceTable, \"sqlite_sequence\");\nWCDBLiteralStringDefine(mainSchema, \"main\");\nWCDBLiteralStringDefine(tempSchema, \"temp\");\nWCDBLiteralStringDefine(builtinTablePrefix, \"sqlite_\");\nWCDBLiteralStringDefine(builtinWCDBTablePrefix, \"wcdb_builtin_\");\nWCDBLiteralStringDefine(malformedSchemaMsg, \"malformed database schema\");\n\n} // namespace Syntax\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/syntax/identifier/SyntaxBindParameter.cpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"Syntax.h\"\n#include \"SyntaxAssertion.hpp\"\n#include \"SyntaxEnum.hpp\"\n\nnamespace WCDB {\n\ntemplate<>\nconstexpr const char* Enum::description(const Syntax::BindParameter::Switch& switcher)\n{\n    switch (switcher) {\n    case Syntax::BindParameter::Switch::QuestionSign:\n        return \"?\";\n    case Syntax::BindParameter::Switch::ColonSign:\n        return \":\";\n    case Syntax::BindParameter::Switch::DollarSign:\n        return \"$\";\n    case Syntax::BindParameter::Switch::AtSign:\n        return \"@\";\n    }\n}\n\nnamespace Syntax {\n\nBindParameter::~BindParameter() = default;\n\n#pragma mark - Identifier\nIdentifier::Type BindParameter::getType() const\n{\n    return type;\n}\n\nbool BindParameter::describle(std::ostream& stream) const\n{\n    stream << switcher;\n    switch (switcher) {\n    case Switch::QuestionSign:\n        if (n > 0) {\n            stream << n;\n        }\n        break;\n    case Switch::ColonSign:\n    case Switch::AtSign:\n    case Switch::DollarSign:\n        stream << name;\n        break;\n    }\n    return true;\n}\n\n} // namespace Syntax\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/syntax/identifier/SyntaxBindParameter.hpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"SyntaxIdentifier.hpp\"\n\nnamespace WCDB {\n\nnamespace Syntax {\n\nclass WCDB_API BindParameter final : public Identifier {\n#pragma mark - Lang\npublic:\n    ~BindParameter() override;\n\n    WCDB_SYNTAX_MAIN_UNION_ENUM(QuestionSign, ColonSign, DollarSign, AtSign, );\n    int n;\n    StringView name;\n\n#pragma mark - Identifier\npublic:\n    static constexpr const Type type = Type::BindParameter;\n    Type getType() const override final;\n    bool describle(std::ostream& stream) const override final;\n};\n\n} // namespace Syntax\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/syntax/identifier/SyntaxColumn.cpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"Syntax.h\"\n#include \"SyntaxAssertion.hpp\"\n\nnamespace WCDB {\n\nnamespace Syntax {\n\nColumn::~Column() = default;\n\nbool Column::isValid() const\n{\n    return wildcard || !name.empty();\n}\n\n#pragma mark - Identifier\nIdentifier::Type Column::getType() const\n{\n    return type;\n}\n\nconst BaseBinding* Column::getTableBinding() const\n{\n    if (tableBinding != nullptr) {\n        return tableBinding;\n    } else if (tableBindingRetrive != nullptr) {\n        return tableBindingRetrive();\n    }\n    return nullptr;\n}\n\nbool Column::describle(std::ostream& stream) const\n{\n    if (!table.empty()) {\n        if (!schema.empty()) {\n            stream << schema << \".\";\n        }\n        stream << table << \".\";\n    }\n    if (wildcard) {\n        stream << \"*\";\n    } else {\n        stream << name;\n    }\n    return true;\n}\n\nvoid Column::iterate(const Iterator& iterator, bool& stop)\n{\n    Identifier::iterate(iterator, true, stop);\n    if (!table.empty()) {\n        recursiveIterate(schema, iterator, stop);\n    }\n    Identifier::iterate(iterator, false, stop);\n}\n\n} // namespace Syntax\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/syntax/identifier/SyntaxColumn.hpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"SyntaxIdentifier.hpp\"\n#include \"SyntaxSchema.hpp\"\n\nnamespace WCDB {\n\nclass BaseBinding;\nclass Column;\n\nnamespace Syntax {\n\nclass WCDB_API Column final : public Identifier {\n    friend WCDB::Column;\n#pragma mark - Syntax\npublic:\n    ~Column() override;\n\n    Schema schema;\n    StringView table;\n    bool wildcard = false;\n    StringView name;\n\n    bool isValid() const override final;\n\n#pragma mark - TableBinding\npublic:\n    typedef std::function<const BaseBinding*()> TableBindingRetirve;\n    TableBindingRetirve tableBindingRetrive = nullptr;\n    const BaseBinding* tableBinding = nullptr;\n    const BaseBinding* getTableBinding() const;\n\n#pragma mark - Identifier\npublic:\n    static constexpr const Type type = Type::Column;\n    Type getType() const override final;\n    bool describle(std::ostream& stream) const override final;\n    void iterate(const Iterator& iterator, bool& stop) override final;\n};\n\n} // namespace Syntax\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/syntax/identifier/SyntaxColumnConstraint.cpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"Syntax.h\"\n#include \"SyntaxAssertion.hpp\"\n#include \"SyntaxEnum.hpp\"\n\nnamespace WCDB {\n\nnamespace Syntax {\n\nColumnConstraint::~ColumnConstraint() = default;\n\n#pragma mark - Identifier\nIdentifier::Type ColumnConstraint::getType() const\n{\n    return type;\n}\n\nbool ColumnConstraint::describle(std::ostream& stream) const\n{\n    if (!name.empty()) {\n        stream << \"CONSTRAINT \" << name << space;\n    }\n    switch (switcher) {\n    case Switch::PrimaryKey:\n        stream << \"PRIMARY KEY\";\n        if (orderValid()) {\n            stream << space << order;\n        }\n        if (conflictValid()) {\n            stream << space << conflict;\n        }\n        if (autoIncrement) {\n            stream << \" AUTOINCREMENT\";\n        }\n        break;\n    case Switch::NotNull:\n        stream << \"NOT NULL\";\n        if (conflictValid()) {\n            stream << space << conflict;\n        }\n        break;\n    case Switch::Unique:\n        stream << \"UNIQUE\";\n        if (conflictValid()) {\n            stream << space << conflict;\n        }\n        break;\n    case Switch::Check:\n        stream << \"CHECK(\" << expression.getOrCreate() << \")\";\n        break;\n    case Switch::Default:\n        stream << \"DEFAULT \" << expression.getOrCreate();\n        break;\n    case Switch::Collate:\n        stream << \"COLLATE \" << collation;\n        break;\n    case Switch::ForeignKey:\n        stream << foreignKeyClause.getOrCreate();\n        break;\n    case Switch::UnIndexed:\n        stream << \"UNINDEXED\";\n        break;\n    }\n    return true;\n}\n\nvoid ColumnConstraint::iterate(const Iterator& iterator, bool& stop)\n{\n    Identifier::iterate(iterator, true, stop);\n    switch (switcher) {\n    case Switch::PrimaryKey:\n    case Switch::NotNull:\n    case Switch::Unique:\n    case Switch::Collate:\n    case Switch::UnIndexed:\n        break;\n    case Switch::Check:\n        recursiveIterate(expression.getOrCreate(), iterator, stop);\n        break;\n    case Switch::Default:\n        recursiveIterate(expression.getOrCreate(), iterator, stop);\n        break;\n    case Switch::ForeignKey:\n        recursiveIterate(foreignKeyClause.getOrCreate(), iterator, stop);\n        break;\n    }\n    Identifier::iterate(iterator, false, stop);\n}\n\n#pragma mark - Utility\nbool ColumnConstraint::isAutoIncrement() const\n{\n    return switcher == Switch::PrimaryKey && autoIncrement;\n}\n\nbool ColumnConstraint::isPrimaryKey() const\n{\n    return switcher == Switch::PrimaryKey;\n}\n\nbool ColumnConstraint::isUnique() const\n{\n    return switcher == Switch::Unique;\n}\n\n} // namespace Syntax\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/syntax/identifier/SyntaxColumnConstraint.hpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"SyntaxExpression.hpp\"\n#include \"SyntaxForeignKeyClause.hpp\"\n#include \"SyntaxIdentifier.hpp\"\n#include \"SyntaxLiteralValue.hpp\"\n\nnamespace WCDB {\n\nnamespace Syntax {\n\nclass WCDB_API ColumnConstraint final : public Identifier {\n#pragma mark - Lang\npublic:\n    ~ColumnConstraint() override;\n\n    StringView name;\n    WCDB_SYNTAX_MAIN_UNION_ENUM(PrimaryKey, NotNull, Unique, Check, Default, Collate, ForeignKey, UnIndexed, );\n\n    WCDB_SYNTAX_ENUM_UNION(Order, order);\n    WCDB_SYNTAX_ENUM_UNION(Conflict, conflict);\n\n    StringView collation;\n    bool autoIncrement = false;\n    Optional<Expression> expression;\n    Optional<ForeignKeyClause> foreignKeyClause;\n\n#pragma mark - Identifier\npublic:\n    static constexpr const Type type = Type::ColumnConstraint;\n    Type getType() const override final;\n    bool describle(std::ostream& stream) const override final;\n    void iterate(const Iterator& iterator, bool& stop) override final;\n\n#pragma mark - Utility\npublic:\n    bool isAutoIncrement() const;\n    bool isPrimaryKey() const;\n    bool isUnique() const;\n};\n\n} // namespace Syntax\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/syntax/identifier/SyntaxColumnDef.cpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"Syntax.h\"\n#include \"SyntaxAssertion.hpp\"\n#include \"SyntaxEnum.hpp\"\n\nnamespace WCDB {\n\nnamespace Syntax {\n\nColumnDef::~ColumnDef() = default;\n\nbool ColumnDef::isValid() const\n{\n    return WCDB_SYNTAX_CHECK_OPTIONAL_VALID(column);\n}\n\n#pragma mark - Identifier\nIdentifier::Type ColumnDef::getType() const\n{\n    return type;\n}\n\nbool ColumnDef::describle(std::ostream& stream) const\n{\n    stream << column.getOrCreate();\n    if (columnTypeValid()) {\n        stream << space << columnType;\n    };\n    for (const auto& constraint : constraints) {\n        stream << space << constraint;\n    }\n    return true;\n}\n\nvoid ColumnDef::iterate(const Iterator& iterator, bool& stop)\n{\n    Identifier::iterate(iterator, true, stop);\n    recursiveIterate(column.getOrCreate(), iterator, stop);\n    listIterate(constraints, iterator, stop);\n    Identifier::iterate(iterator, false, stop);\n}\n\n#pragma mark - Utility\nbool ColumnDef::isAutoIncrement() const\n{\n    bool isAutoIncrement = false;\n    for (const auto& constraint : constraints) {\n        if (constraint.isAutoIncrement()) {\n            isAutoIncrement = true;\n            break;\n        }\n    }\n    return isAutoIncrement;\n}\n\nbool ColumnDef::isPrimaryKey() const\n{\n    bool isPrimary = false;\n    for (const auto& constraint : constraints) {\n        if (constraint.isPrimaryKey()) {\n            isPrimary = true;\n            break;\n        }\n    }\n    return isPrimary;\n}\n\nbool ColumnDef::isUnique() const\n{\n    bool isUnique = false;\n    for (const auto& constraint : constraints) {\n        if (constraint.isUnique()) {\n            isUnique = true;\n            break;\n        }\n    }\n    return isUnique;\n}\n\n} // namespace Syntax\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/syntax/identifier/SyntaxColumnDef.hpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"SyntaxColumnConstraint.hpp\"\n#include \"SyntaxIdentifier.hpp\"\n\nnamespace WCDB {\n\nnamespace Syntax {\n\nclass WCDB_API ColumnDef final : public Identifier {\n#pragma mark - Syntax\npublic:\n    ~ColumnDef() override;\n\n    Optional<Column> column;\n    WCDB_SYNTAX_ENUM_UNION(ColumnType, columnType);\n    std::list<ColumnConstraint> constraints;\n\n    bool isValid() const override final;\n\n#pragma mark - Identifier\npublic:\n    static constexpr const Type type = Type::ColumnDef;\n    Type getType() const override final;\n    bool describle(std::ostream& stream) const override final;\n    void iterate(const Iterator& iterator, bool& stop) override final;\n\n#pragma mark - Utility\npublic:\n    bool isAutoIncrement() const;\n    bool isPrimaryKey() const;\n    bool isUnique() const;\n};\n\n} // namespace Syntax\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/syntax/identifier/SyntaxCommonTableExpression.cpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"Syntax.h\"\n#include \"SyntaxAssertion.hpp\"\n\nnamespace WCDB {\n\nnamespace Syntax {\n\nCommonTableExpression::~CommonTableExpression() = default;\n\nbool CommonTableExpression::isValid() const\n{\n    return !table.empty();\n}\n\n#pragma mark - Identifier\nIdentifier::Type CommonTableExpression::getType() const\n{\n    return type;\n}\n\nbool CommonTableExpression::describle(std::ostream& stream) const\n{\n    stream << table;\n    if (!columns.empty()) {\n        stream << \"(\" << columns << \")\";\n    }\n    if (select != nullptr) {\n        stream << \" AS(\" << *select.get() << \")\";\n    }\n    return true;\n}\n\nvoid CommonTableExpression::iterate(const Iterator& iterator, bool& stop)\n{\n    Identifier::iterate(iterator, true, stop);\n    listIterate(columns, iterator, stop);\n    if (select != nullptr) {\n        recursiveIterate(*select.get(), iterator, stop);\n    }\n    Identifier::iterate(iterator, false, stop);\n}\n\n} // namespace Syntax\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/syntax/identifier/SyntaxCommonTableExpression.hpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"SyntaxIdentifier.hpp\"\n\nnamespace WCDB {\n\nnamespace Syntax {\n\nclass WCDB_API CommonTableExpression final : public Identifier {\n#pragma mark - Lang\npublic:\n    ~CommonTableExpression() override;\n\n    StringView table;\n    std::list<Column> columns;\n    Shadow<SelectSTMT> select;\n\n    bool isValid() const override final;\n\n#pragma mark - Identifier\npublic:\n    static constexpr const Type type = Type::CommonTableExpression;\n    Type getType() const override final;\n    bool describle(std::ostream& stream) const override final;\n    void iterate(const Iterator& iterator, bool& stop) override final;\n};\n\n} // namespace Syntax\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/syntax/identifier/SyntaxExpression.cpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"Syntax.h\"\n#include \"SyntaxAssertion.hpp\"\n#include \"SyntaxEnum.hpp\"\n\nnamespace WCDB {\n\ntemplate<>\nconstexpr const char*\nEnum::description(const Syntax::Expression::UnaryOperator& unaryOperator)\n{\n    switch (unaryOperator) {\n    case Syntax::Expression::UnaryOperator::Negative:\n        return \"-\";\n    case Syntax::Expression::UnaryOperator::Positive:\n        return \"+\";\n    case Syntax::Expression::UnaryOperator::Tilde:\n        return \"~\";\n    case Syntax::Expression::UnaryOperator::Not:\n        return \"NOT\";\n    case Syntax::Expression::UnaryOperator::Null:\n        return \"NULL\";\n    }\n}\n\ntemplate<>\nconstexpr const char*\nEnum::description(const Syntax::Expression::BinaryOperator& binaryOperator)\n{\n    switch (binaryOperator) {\n    case Syntax::Expression::BinaryOperator::Concatenate:\n        return \"||\";\n    case Syntax::Expression::BinaryOperator::Multiply:\n        return \"*\";\n    case Syntax::Expression::BinaryOperator::Divide:\n        return \"/\";\n    case Syntax::Expression::BinaryOperator::Modulo:\n        return \"%\";\n    case Syntax::Expression::BinaryOperator::Plus:\n        return \"+\";\n    case Syntax::Expression::BinaryOperator::Minus:\n        return \"-\";\n    case Syntax::Expression::BinaryOperator::LeftShift:\n        return \"<<\";\n    case Syntax::Expression::BinaryOperator::RightShift:\n        return \">>\";\n    case Syntax::Expression::BinaryOperator::BitwiseAnd:\n        return \"&\";\n    case Syntax::Expression::BinaryOperator::BitwiseOr:\n        return \"|\";\n    case Syntax::Expression::BinaryOperator::Less:\n        return \"<\";\n    case Syntax::Expression::BinaryOperator::LessOrEqual:\n        return \"<=\";\n    case Syntax::Expression::BinaryOperator::Greater:\n        return \">\";\n    case Syntax::Expression::BinaryOperator::GreaterOrEqual:\n        return \">=\";\n    case Syntax::Expression::BinaryOperator::Equal:\n        return \"==\";\n    case Syntax::Expression::BinaryOperator::NotEqual:\n        return \"!=\";\n    case Syntax::Expression::BinaryOperator::Is:\n        return \"IS\";\n    case Syntax::Expression::BinaryOperator::And:\n        return \"AND\";\n    case Syntax::Expression::BinaryOperator::Or:\n        return \"OR\";\n    case Syntax::Expression::BinaryOperator::Like:\n        return \"LIKE\";\n    case Syntax::Expression::BinaryOperator::GLOB:\n        return \"GLOB\";\n    case Syntax::Expression::BinaryOperator::RegExp:\n        return \"REGEXP\";\n    case Syntax::Expression::BinaryOperator::Match:\n        return \"MATCH\";\n    }\n}\n\nnamespace Syntax {\n\n#pragma mark - ExpressionMember\nvoid ExpressionUnionMember::firstMemberReset() const\n{\n    if (m_firstMember == Member::Invalid) {\n        return;\n    }\n    switch (m_firstMember) {\n    case Member::literalValue:\n        m_literalValue.~LiteralValue();\n        break;\n    case Member::bindParameter:\n        m_bindParameter.~BindParameter();\n        break;\n    case Member::column:\n        m_column.~Column();\n        break;\n    case Member::raiseFunction:\n        m_raiseFunction.~RaiseFunction();\n        break;\n    case Member::windowDef:\n        m_windowDef.~WindowDef();\n        break;\n    case Member::windowName:\n        m_windowName.~StringView();\n        break;\n    default:\n        break;\n    }\n    m_firstMember = Member::Invalid;\n}\n\nvoid ExpressionUnionMember::secondMemberReset() const\n{\n    if (m_secondMember == Member::Invalid) {\n        return;\n    }\n    switch (m_secondMember) {\n    case Member::select:\n        m_select.~Shadow<SelectSTMT>();\n        break;\n    case Member::collation:\n        m_collation.~StringView();\n        break;\n    case Member::schema:\n        m_schema.~Schema();\n        break;\n    case Member::filter:\n        m_filter.~Filter();\n        break;\n    default:\n        break;\n    }\n    m_secondMember = Member::Invalid;\n}\n\nvoid ExpressionUnionMember::thirdMemberReset() const\n{\n    if (m_thirdMember == Member::Invalid) {\n        return;\n    }\n    switch (m_thirdMember) {\n    case Member::table:\n        m_table.~StringView();\n        break;\n    case Member::function:\n        m_function.~StringView();\n    default:\n        break;\n    }\n    m_thirdMember = Member::Invalid;\n}\n\ntemplate<typename T>\nvoid ExpressionUnionMember::assignFromOther(T&& other)\n{\n    if (other.m_firstMember != Member::Invalid) {\n        switch (other.m_firstMember) {\n        case Member::literalValue:\n            new ((void*) std::addressof(m_literalValue))\n            LiteralValue(std::forward<T>(other).m_literalValue);\n            break;\n        case Member::bindParameter:\n            new ((void*) std::addressof(m_bindParameter))\n            BindParameter(std::forward<T>(other).m_bindParameter);\n            break;\n        case Member::column:\n            new ((void*) std::addressof(m_column)) Column(std::forward<T>(other).m_column);\n            break;\n        case Member::raiseFunction:\n            new ((void*) std::addressof(m_raiseFunction))\n            RaiseFunction(std::forward<T>(other).m_raiseFunction);\n            break;\n        case Member::windowDef:\n            new ((void*) std::addressof(m_windowDef))\n            WindowDef(std::forward<T>(other).m_windowDef);\n            break;\n        case Member::windowName:\n            new ((void*) std::addressof(m_windowName))\n            StringView(std::forward<T>(other).m_windowName);\n            break;\n        default:\n            break;\n        }\n        m_firstMember = other.m_firstMember;\n    }\n    if (other.m_secondMember != Member::Invalid) {\n        switch (other.m_secondMember) {\n        case Member::select:\n            new ((void*) std::addressof(m_select))\n            Shadow<SelectSTMT>(std::forward<T>(other).m_select);\n            break;\n        case Member::collation:\n            new ((void*) std::addressof(m_collation))\n            StringView(std::forward<T>(other).m_collation);\n            break;\n        case Member::schema:\n            new ((void*) std::addressof(m_schema)) Schema(std::forward<T>(other).m_schema);\n            break;\n        case Member::filter:\n            new ((void*) std::addressof(m_filter)) Filter(std::forward<T>(other).m_filter);\n            break;\n        default:\n            break;\n        }\n        m_secondMember = other.m_secondMember;\n    }\n    if (other.m_thirdMember != Member::Invalid) {\n        switch (other.m_thirdMember) {\n        case Member::table:\n            new ((void*) std::addressof(m_table))\n            StringView(std::forward<T>(other).m_table);\n            break;\n        case Member::function:\n            new ((void*) std::addressof(m_function))\n            StringView(std::forward<T>(other).m_function);\n            break;\n        default:\n            break;\n        }\n        m_thirdMember = other.m_thirdMember;\n    }\n}\n\nExpressionUnionMember::ExpressionUnionMember()\n: m_firstMember(Member::Invalid)\n, m_secondMember(Member::Invalid)\n, m_thirdMember(Member::Invalid)\n{\n}\n\nExpressionUnionMember::~ExpressionUnionMember()\n{\n    firstMemberReset();\n    secondMemberReset();\n    thirdMemberReset();\n};\n\nExpressionUnionMember::ExpressionUnionMember(const ExpressionUnionMember& other)\n{\n    assignFromOther(other);\n}\n\nExpressionUnionMember::ExpressionUnionMember(ExpressionUnionMember&& other)\n{\n    assignFromOther(std::move(other));\n}\n\nExpressionUnionMember& ExpressionUnionMember::operator=(const ExpressionUnionMember& other)\n{\n    firstMemberReset();\n    secondMemberReset();\n    thirdMemberReset();\n    assignFromOther(other);\n    return *this;\n}\n\nExpressionUnionMember& ExpressionUnionMember::operator=(ExpressionUnionMember&& other)\n{\n    firstMemberReset();\n    secondMemberReset();\n    thirdMemberReset();\n    assignFromOther(std::move(other));\n    return *this;\n}\n\nWCDB_SYNTAX_UNION_MEMBER_IMPLEMENT(ExpressionUnionMember, firstMember, LiteralValue, literalValue)\nWCDB_SYNTAX_UNION_MEMBER_IMPLEMENT(ExpressionUnionMember, firstMember, BindParameter, bindParameter)\nWCDB_SYNTAX_UNION_MEMBER_IMPLEMENT(ExpressionUnionMember, firstMember, Column, column)\nWCDB_SYNTAX_UNION_MEMBER_IMPLEMENT(ExpressionUnionMember, firstMember, RaiseFunction, raiseFunction)\nWCDB_SYNTAX_UNION_MEMBER_IMPLEMENT(ExpressionUnionMember, firstMember, WindowDef, windowDef)\nWCDB_SYNTAX_UNION_MEMBER_IMPLEMENT(ExpressionUnionMember, firstMember, StringView, windowName)\nWCDB_SYNTAX_UNION_MEMBER_IMPLEMENT(ExpressionUnionMember, secondMember, Shadow<SelectSTMT>, select)\nWCDB_SYNTAX_UNION_MEMBER_IMPLEMENT(ExpressionUnionMember, secondMember, StringView, collation)\nWCDB_SYNTAX_UNION_MEMBER_IMPLEMENT(ExpressionUnionMember, secondMember, Schema, schema)\nWCDB_SYNTAX_UNION_MEMBER_IMPLEMENT(ExpressionUnionMember, secondMember, Filter, filter)\nWCDB_SYNTAX_UNION_MEMBER_IMPLEMENT(ExpressionUnionMember, thirdMember, StringView, table)\nWCDB_SYNTAX_UNION_MEMBER_IMPLEMENT(ExpressionUnionMember, thirdMember, StringView, function)\n\n#pragma mark - Identifier\nExpression::~Expression() = default;\n\nIdentifier::Type Expression::getType() const\n{\n    return type;\n}\n\nstatic void streamAutoParenthesesExpression(std::ostream& stream, const Expression& expression)\n{\n    bool parentheses;\n    switch (expression.switcher) {\n    case Expression::Switch::LiteralValue:\n    case Expression::Switch::BindParameter:\n    case Expression::Switch::Column:\n    case Expression::Switch::Function:\n    case Expression::Switch::Cast:\n    case Expression::Switch::In:\n    case Expression::Switch::Exists:\n    case Expression::Switch::Case:\n    case Expression::Switch::RaiseFunction:\n    case Expression::Switch::Window:\n    case Expression::Switch::Expressions:\n    case Expression::Switch::Select:\n        parentheses = false;\n        break;\n    case Expression::Switch::UnaryOperation:\n    case Expression::Switch::BinaryOperation:\n    case Expression::Switch::Collate:\n    case Expression::Switch::Between:\n        parentheses = true;\n        break;\n    }\n    if (parentheses) {\n        stream << \"(\";\n    }\n    stream << expression;\n    if (parentheses) {\n        stream << \")\";\n    }\n}\n\nbool Expression::describle(std::ostream& stream) const\n{\n    switch (switcher) {\n    case Switch::LiteralValue:\n        stream << literalValue();\n        break;\n    case Switch::BindParameter:\n        stream << bindParameter();\n        break;\n    case Switch::Column:\n        stream << column();\n        break;\n    case Switch::UnaryOperation: {\n        WCTSyntaxRemedialAssert(expressions.size() == 1);\n        switch (unaryOperator) {\n        case UnaryOperator::Null:\n            streamAutoParenthesesExpression(stream, *expressions.begin());\n            stream << space;\n            if (isNot) {\n                stream << \"NOT\";\n            } else {\n                stream << \"IS\";\n            }\n            stream << unaryOperator;\n            break;\n        case UnaryOperator::Not:\n            stream << unaryOperator << space;\n            streamAutoParenthesesExpression(stream, *expressions.begin());\n            break;\n        case UnaryOperator::Positive:\n        case UnaryOperator::Negative:\n        case UnaryOperator::Tilde:\n            stream << unaryOperator;\n            streamAutoParenthesesExpression(stream, *expressions.begin());\n            break;\n        }\n        break;\n    }\n    case Switch::BinaryOperation: {\n        switch (binaryOperator) {\n        case Syntax::Expression::BinaryOperator::Concatenate:\n        case Syntax::Expression::BinaryOperator::Multiply:\n        case Syntax::Expression::BinaryOperator::Divide:\n        case Syntax::Expression::BinaryOperator::Modulo:\n        case Syntax::Expression::BinaryOperator::Plus:\n        case Syntax::Expression::BinaryOperator::Minus:\n        case Syntax::Expression::BinaryOperator::LeftShift:\n        case Syntax::Expression::BinaryOperator::RightShift:\n        case Syntax::Expression::BinaryOperator::BitwiseAnd:\n        case Syntax::Expression::BinaryOperator::BitwiseOr:\n        case Syntax::Expression::BinaryOperator::Less:\n        case Syntax::Expression::BinaryOperator::LessOrEqual:\n        case Syntax::Expression::BinaryOperator::Greater:\n        case Syntax::Expression::BinaryOperator::GreaterOrEqual:\n        case Syntax::Expression::BinaryOperator::Equal:\n        case Syntax::Expression::BinaryOperator::NotEqual:\n        case Syntax::Expression::BinaryOperator::And:\n        case Syntax::Expression::BinaryOperator::Or:\n            WCTSyntaxRemedialAssert(expressions.size() == 2);\n            streamAutoParenthesesExpression(stream, *expressions.begin());\n            stream << space << binaryOperator << space;\n            streamAutoParenthesesExpression(stream, *(++expressions.begin()));\n            break;\n        case Syntax::Expression::BinaryOperator::Is:\n            WCTSyntaxRemedialAssert(expressions.size() == 2);\n            // Extra parentheses to ensure the correctness of operator precedence\n            streamAutoParenthesesExpression(stream, *expressions.begin());\n            stream << space << binaryOperator;\n            if (isNot) {\n                stream << \" NOT\";\n            }\n            stream << space;\n            streamAutoParenthesesExpression(stream, *(++expressions.begin()));\n            break;\n        case Syntax::Expression::BinaryOperator::Like:\n        case Syntax::Expression::BinaryOperator::GLOB:\n        case Syntax::Expression::BinaryOperator::RegExp:\n        case Syntax::Expression::BinaryOperator::Match: {\n            WCTSyntaxRemedialAssert(expressions.size() == 2 + escape);\n            auto iter = expressions.begin();\n            streamAutoParenthesesExpression(stream, *iter);\n            if (isNot) {\n                stream << \" NOT\";\n            }\n            stream << space << binaryOperator << space;\n            streamAutoParenthesesExpression(stream, *(++iter));\n            if (escape) {\n                stream << \" ESCAPE \";\n                streamAutoParenthesesExpression(stream, *(++iter));\n            }\n            break;\n        }\n        }\n    } break;\n    case Switch::Function:\n        stream << function() << \"(\";\n        if (!expressions.empty()) {\n            if (distinct) {\n                stream << \"DISTINCT \";\n            }\n            stream << expressions;\n        } else if (useWildcard) {\n            stream << \"*\";\n        }\n        stream << \")\";\n        break;\n    case Switch::Expressions:\n        stream << \"(\" << expressions << \")\";\n        break;\n    case Switch::Cast:\n        WCTSyntaxRemedialAssert(expressions.size() == 1);\n        stream << \"CAST(\" << *expressions.begin() << \" AS \" << castType << \")\";\n        break;\n    case Switch::Collate:\n        WCTSyntaxRemedialAssert(expressions.size() == 1);\n        stream << *expressions.begin() << \" COLLATE \" << collation();\n        break;\n    case Switch::Between: {\n        WCTSyntaxRemedialAssert(expressions.size() == 3);\n        auto iter = expressions.begin();\n        streamAutoParenthesesExpression(stream, *iter);\n        if (isNot) {\n            stream << \" NOT\";\n        }\n        stream << \" BETWEEN \";\n        streamAutoParenthesesExpression(stream, *++iter);\n        stream << \" AND \";\n        streamAutoParenthesesExpression(stream, *++iter);\n        break;\n    }\n    case Switch::In: {\n        WCTSyntaxRemedialAssert(expressions.size() >= 1);\n        auto iter = expressions.begin();\n        stream << *iter;\n        if (isNot) {\n            stream << \" NOT\";\n        }\n        stream << \" IN\";\n        switch (inSwitcher) {\n        case SwitchIn::Empty:\n            stream << \"()\";\n            break;\n        case SwitchIn::Select:\n            WCTSyntaxRemedialAssert(select() != nullptr);\n            stream << \"(\" << *select().get() << \")\";\n            break;\n        case SwitchIn::Expressions: {\n            stream << \"(\";\n            bool comma = false;\n            while (++iter != expressions.end()) {\n                if (comma) {\n                    stream << \", \";\n                } else {\n                    comma = true;\n                }\n                stream << *iter;\n            }\n            stream << \")\";\n            break;\n        }\n        case SwitchIn::Table:\n            stream << space;\n            if (!schema().empty()) {\n                stream << schema() << \".\";\n            }\n            stream << table();\n            break;\n        case SwitchIn::Function: {\n            stream << space;\n            if (!schema().empty()) {\n                stream << schema() << \".\";\n            }\n            stream << function() << \"(\";\n            bool comma = false;\n            while (++iter != expressions.end()) {\n                if (comma) {\n                    stream << \", \";\n                } else {\n                    comma = true;\n                }\n                stream << *iter;\n            }\n            stream << \")\";\n            break;\n        }\n        }\n        break;\n    }\n    case Switch::Exists:\n        WCTSyntaxRemedialAssert(select() != nullptr);\n        if (isNot) {\n            stream << \"NOT \";\n        }\n        stream << \"EXISTS(\" << *select().get() << \")\";\n        break;\n    case Switch::Select:\n        WCTSyntaxRemedialAssert(select() != nullptr);\n        stream << \"(\" << *select().get() << \")\";\n        break;\n    case Switch::Case: {\n        WCTSyntaxRemedialAssert(expressions.size() >= hasCase + 2 + hasElse);\n        WCTSyntaxRemedialAssert((expressions.size() - hasCase - hasElse) % 2 == 0);\n        auto iter = expressions.begin();\n        stream << \"CASE \";\n        if (hasCase) {\n            stream << *iter << space;\n            ++iter;\n        }\n        do {\n            stream << \"WHEN \" << *iter;\n            ++iter;\n            stream << \" THEN \" << *iter << space;\n            ++iter;\n        } while (std::distance(iter, expressions.end()) > hasElse);\n        if (hasElse) {\n            stream << \"ELSE \" << *iter << space;\n        }\n        stream << \"END\";\n        break;\n    }\n    case Switch::RaiseFunction:\n        stream << raiseFunction();\n        break;\n    case Switch::Window:\n        stream << function() << \"(\";\n        if (!expressions.empty()) {\n            stream << expressions;\n        } else if (useWildcard) {\n            stream << \"*\";\n        }\n        stream << \")\";\n        if (filter().isValid()) {\n            stream << space << filter();\n        }\n        if (m_firstMember == Member::windowDef && windowDef().isValid()) {\n            stream << \" OVER\";\n            stream << windowDef();\n        } else if (m_firstMember == Member::windowName && !windowName().empty()) {\n            stream << \" OVER\";\n            stream << space << windowName();\n        }\n        break;\n    }\n    return true;\n}\n\nvoid Expression::iterate(const Iterator& iterator, bool& stop)\n{\n    Identifier::iterate(iterator, true, stop);\n    switch (switcher) {\n    // one expression\n    case Switch::UnaryOperation:\n    case Switch::Collate:\n        WCTIterateRemedialAssert(expressions.size() == 1);\n        expressions.begin()->iterate(iterator, stop);\n        break;\n\n    // two expressions\n    case Switch::BinaryOperation:\n        switch (binaryOperator) {\n        case Syntax::Expression::BinaryOperator::Concatenate:\n        case Syntax::Expression::BinaryOperator::Multiply:\n        case Syntax::Expression::BinaryOperator::Divide:\n        case Syntax::Expression::BinaryOperator::Modulo:\n        case Syntax::Expression::BinaryOperator::Plus:\n        case Syntax::Expression::BinaryOperator::Minus:\n        case Syntax::Expression::BinaryOperator::LeftShift:\n        case Syntax::Expression::BinaryOperator::RightShift:\n        case Syntax::Expression::BinaryOperator::BitwiseAnd:\n        case Syntax::Expression::BinaryOperator::BitwiseOr:\n        case Syntax::Expression::BinaryOperator::Less:\n        case Syntax::Expression::BinaryOperator::LessOrEqual:\n        case Syntax::Expression::BinaryOperator::Greater:\n        case Syntax::Expression::BinaryOperator::GreaterOrEqual:\n        case Syntax::Expression::BinaryOperator::Equal:\n        case Syntax::Expression::BinaryOperator::NotEqual:\n        case Syntax::Expression::BinaryOperator::Is:\n        case Syntax::Expression::BinaryOperator::And:\n        case Syntax::Expression::BinaryOperator::Or:\n            WCTIterateRemedialAssert(expressions.size() == 2);\n            listIterate(expressions, iterator, stop);\n            break;\n        case Syntax::Expression::BinaryOperator::Like:\n        case Syntax::Expression::BinaryOperator::GLOB:\n        case Syntax::Expression::BinaryOperator::RegExp:\n        case Syntax::Expression::BinaryOperator::Match: {\n            WCTIterateRemedialAssert(expressions.size() == 2 + escape);\n            listIterate(expressions, iterator, stop);\n            break;\n        }\n        }\n        break;\n    // three expressions\n    case Switch::Between: {\n        WCTIterateRemedialAssert(expressions.size() == 3);\n        listIterate(expressions, iterator, stop);\n        break;\n    }\n    // expression list\n    case Switch::Function:\n    case Switch::Expressions:\n    case Switch::Cast:\n    case Switch::Case:\n        listIterate(expressions, iterator, stop);\n        break;\n    // others\n    case Switch::LiteralValue:\n        recursiveIterate(literalValue(), iterator, stop);\n        break;\n    case Switch::BindParameter:\n        recursiveIterate(bindParameter(), iterator, stop);\n        break;\n    case Switch::Column:\n        recursiveIterate(column(), iterator, stop);\n        break;\n    case Switch::In: {\n        WCTIterateRemedialAssert(expressions.size() >= 1);\n        auto iter = expressions.begin();\n        iter->iterate(iterator, stop);\n        switch (inSwitcher) {\n        case SwitchIn::Empty:\n            break;\n        case SwitchIn::Select:\n            WCTIterateRemedialAssert(select() != nullptr);\n            select().get()->iterate(iterator, stop);\n            break;\n        case SwitchIn::Expressions: {\n            while (++iter != expressions.end()) {\n                iter->iterate(iterator, stop);\n            }\n            break;\n        }\n        case SwitchIn::Table:\n            recursiveIterate(schema(), iterator, stop);\n            break;\n        case SwitchIn::Function: {\n            recursiveIterate(schema(), iterator, stop);\n            while (++iter != expressions.end()) {\n                iter->iterate(iterator, stop);\n            }\n            break;\n        }\n        }\n        break;\n    }\n    case Switch::Exists:\n        WCTIterateRemedialAssert(select() != nullptr);\n        select().get()->iterate(iterator, stop);\n        break;\n    case Switch::Select:\n        WCTIterateRemedialAssert(select() != nullptr);\n        select().get()->iterate(iterator, stop);\n        break;\n    case Switch::RaiseFunction:\n        recursiveIterate(raiseFunction(), iterator, stop);\n        break;\n    case Switch::Window:\n        listIterate(expressions, iterator, stop);\n        if (filter().isValid()) {\n            recursiveIterate(filter(), iterator, stop);\n        }\n        if (m_firstMember == Member::windowDef) {\n            recursiveIterate(windowDef(), iterator, stop);\n        }\n        break;\n    }\n    Identifier::iterate(iterator, false, stop);\n}\n\n} // namespace Syntax\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/syntax/identifier/SyntaxExpression.hpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"SyntaxBindParameter.hpp\"\n#include \"SyntaxFilter.hpp\"\n#include \"SyntaxIdentifier.hpp\"\n#include \"SyntaxLiteralValue.hpp\"\n#include \"SyntaxRaiseFunction.hpp\"\n#include \"SyntaxSchema.hpp\"\n#include \"SyntaxWindowDef.hpp\"\n\nnamespace WCDB {\n\nnamespace Syntax {\n\nclass SelectSTMT;\n\nclass WCDB_API ExpressionUnionMember {\npublic:\n    ExpressionUnionMember();\n    ~ExpressionUnionMember();\n    ExpressionUnionMember(const ExpressionUnionMember& other);\n    ExpressionUnionMember(ExpressionUnionMember&& other);\n    ExpressionUnionMember& operator=(const ExpressionUnionMember& other);\n    ExpressionUnionMember& operator=(ExpressionUnionMember&& other);\n\n    LiteralValue& literalValue();\n    BindParameter& bindParameter();\n    Column& column();\n    Shadow<SelectSTMT>& select();\n    StringView& table();\n    RaiseFunction& raiseFunction();\n    WindowDef& windowDef();\n    StringView& collation();\n    Schema& schema();\n    Filter& filter();\n    StringView& windowName();\n    StringView& function();\n\n    const LiteralValue& literalValue() const;\n    const BindParameter& bindParameter() const;\n    const Column& column() const;\n    const Shadow<SelectSTMT>& select() const;\n    const StringView& table() const;\n    const RaiseFunction& raiseFunction() const;\n    const WindowDef& windowDef() const;\n    const StringView& collation() const;\n    const Schema& schema() const;\n    const Filter& filter() const;\n    const StringView& windowName() const;\n    const StringView& function() const;\n\nprotected:\n    enum class Member : signed char {\n        Invalid = 0,\n        literalValue,\n        bindParameter,\n        column,\n        raiseFunction,\n        windowDef,\n        windowName,\n        select,\n        collation,\n        schema,\n        filter,\n        table,\n        function,\n    };\n\n    mutable Member m_firstMember = Member::Invalid;\n    mutable Member m_secondMember = Member::Invalid;\n    mutable Member m_thirdMember = Member::Invalid;\n\n    union {\n        mutable LiteralValue m_literalValue;\n        mutable BindParameter m_bindParameter;\n        mutable Column m_column;\n        mutable RaiseFunction m_raiseFunction;\n        mutable WindowDef m_windowDef;\n        mutable StringView m_windowName;\n    };\n    void firstMemberReset() const;\n\n    union {\n        mutable Shadow<SelectSTMT> m_select;\n        mutable StringView m_collation;\n        mutable Schema m_schema;\n        mutable Filter m_filter;\n    };\n    void secondMemberReset() const;\n\n    union {\n        mutable StringView m_table;\n        mutable StringView m_function;\n    };\n    void thirdMemberReset() const;\n\n    template<typename T>\n    void assignFromOther(T&& member);\n};\n\nclass WCDB_API Expression final : public Identifier, public ExpressionUnionMember {\npublic:\n    ~Expression() override;\n\n    std::list<Expression> expressions;\n\n    WCDB_SYNTAX_MAIN_UNION_ENUM(LiteralValue,\n                                BindParameter,\n                                Column,\n                                UnaryOperation,\n                                BinaryOperation,\n                                Function,\n                                Expressions,\n                                Cast,\n                                Collate,\n                                Between,\n                                In,\n                                Exists,\n                                Case,\n                                RaiseFunction,\n                                Window,\n                                Select, );\n\n    enum class UnaryOperator : signed char {\n        Negative = 1,\n        Positive,\n        Tilde,\n        Not,\n        Null,\n    } unaryOperator;\n\n    enum class BinaryOperator : signed char {\n        Concatenate = 1,\n        Multiply,\n        Divide,\n        Modulo,\n        Plus,\n        Minus,\n        LeftShift,\n        RightShift,\n        BitwiseAnd,\n        BitwiseOr,\n        Less,\n        LessOrEqual,\n        Greater,\n        GreaterOrEqual,\n        Equal,\n        NotEqual,\n        Is,\n        And,\n        Or,\n        Like,\n        GLOB,\n        RegExp,\n        Match,\n    } binaryOperator;\n\n    bool distinct = false;\n    bool useWildcard = false;\n\n    ColumnType castType;\n\n    bool isNot = false;\n    bool escape = false;\n\n    bool hasCase = false;\n    bool hasElse = false;\n\n    enum class SwitchIn : signed char {\n        Empty = 1,\n        Select,\n        Expressions,\n        Table,\n        Function,\n    } inSwitcher;\n\n#pragma mark - Identifier\npublic:\n    static constexpr const Type type = Type::Expression;\n    Type getType() const override final;\n    bool describle(std::ostream& stream) const override final;\n    void iterate(const Iterator& iterator, bool& stop) override final;\n};\n\nstatic_assert(sizeof(Expression) < 500, \"Expression is too large.\");\n\n} // namespace Syntax\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/syntax/identifier/SyntaxFilter.cpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"Syntax.h\"\n#include \"SyntaxAssertion.hpp\"\n\nnamespace WCDB {\n\nnamespace Syntax {\n\nFilter::~Filter() = default;\n\nbool Filter::isValid() const\n{\n    return expression != nullptr;\n}\n\n#pragma mark - Identifier\nIdentifier::Type Filter::getType() const\n{\n    return type;\n}\n\nbool Filter::describle(std::ostream& stream) const\n{\n    stream << \"FILTER(WHERE \" << *expression.get() << \")\";\n    return true;\n}\n\nvoid Filter::iterate(const Iterator& iterator, bool& stop)\n{\n    Identifier::iterate(iterator, true, stop);\n    expression.get()->iterate(iterator, stop);\n    Identifier::iterate(iterator, false, stop);\n}\n\n} // namespace Syntax\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/syntax/identifier/SyntaxFilter.hpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"SyntaxIdentifier.hpp\"\n\nnamespace WCDB {\n\nnamespace Syntax {\n\nclass Expression;\n\nclass WCDB_API Filter final : public Identifier {\n#pragma mark - Lang\npublic:\n    ~Filter() override;\n\n    Shadow<Expression> expression;\n    bool isValid() const override final;\n\n#pragma mark - Identifier\npublic:\n    static constexpr const Type type = Type::Filter;\n    Type getType() const override final;\n    bool describle(std::ostream& stream) const override final;\n    void iterate(const Iterator& iterator, bool& stop) override final;\n};\n\n} // namespace Syntax\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/syntax/identifier/SyntaxForeignKeyClause.cpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"Syntax.h\"\n#include \"SyntaxAssertion.hpp\"\n#include \"SyntaxEnum.hpp\"\n\nnamespace WCDB {\n\ntemplate<>\nconstexpr const char* Enum::description(const Syntax::ForeignKeyClause::Switch& switcher)\n{\n    switch (switcher) {\n    case Syntax::ForeignKeyClause::Switch::OnDeleteSetNull:\n        return \"ON DELETE SET NULL\";\n    case Syntax::ForeignKeyClause::Switch::OnDeleteSetDefault:\n        return \"ON DELETE SET DEFAULT\";\n    case Syntax::ForeignKeyClause::Switch::OnDeleteCascade:\n        return \"ON DELETE CASCADE\";\n    case Syntax::ForeignKeyClause::Switch::OnDeleteRestrict:\n        return \"ON DELETE RESTRICT\";\n    case Syntax::ForeignKeyClause::Switch::OnDeleteNoAction:\n        return \"ON DELETE NO ACTION\";\n    case Syntax::ForeignKeyClause::Switch::OnUpdateSetNull:\n        return \"ON UPDATE SET NULL\";\n    case Syntax::ForeignKeyClause::Switch::OnUpdateSetDefault:\n        return \"ON UPDATE SET DEFAULT\";\n    case Syntax::ForeignKeyClause::Switch::OnUpdateCascade:\n        return \"ON UPDATE CASCADE\";\n    case Syntax::ForeignKeyClause::Switch::OnUpdateRestrict:\n        return \"ON UPDATE RESTRICT\";\n    case Syntax::ForeignKeyClause::Switch::OnUpdateNoAction:\n        return \"ON UPDATE NO ACTION\";\n    }\n}\n\ntemplate<>\nconstexpr const char*\nEnum::description(const Syntax::ForeignKeyClause::Deferrable& deferrable)\n{\n    switch (deferrable) {\n    case Syntax::ForeignKeyClause::Deferrable::DeferrableInitiallyDeferred:\n        return \"DEFERRABLE INITIALLY DEFERRED\";\n    case Syntax::ForeignKeyClause::Deferrable::DeferrableInitiallyImmediate:\n        return \"DEFERRABLE INITIALLY IMMEDIATE\";\n    case Syntax::ForeignKeyClause::Deferrable::Deferrable:\n        return \"DEFERRABLE\";\n    case Syntax::ForeignKeyClause::Deferrable::NotDeferrableInitiallyDeferred:\n        return \"NOT DEFERRABLE INITIALLY DEFERRED\";\n    case Syntax::ForeignKeyClause::Deferrable::NotDeferrableInitiallyImmediate:\n        return \"NOT DEFERRABLE INITIALLY IMMEDIATE\";\n    case Syntax::ForeignKeyClause::Deferrable::NotDeferrable:\n        return \"NOT DEFERRABLE\";\n    }\n}\n\nnamespace Syntax {\n\nForeignKeyClause::~ForeignKeyClause() = default;\n\nbool ForeignKeyClause::isValid() const\n{\n    return !foreignTable.empty();\n}\n\n#pragma mark - Identifier\nIdentifier::Type ForeignKeyClause::getType() const\n{\n    return type;\n}\n\nbool ForeignKeyClause::describle(std::ostream& stream) const\n{\n    stream << \"REFERENCES \" << foreignTable;\n    if (!columns.empty()) {\n        stream << \"(\" << columns << \")\";\n    }\n    for (const auto& switcher : switchers) {\n        stream << space << switcher;\n    }\n    if (matchTypeValid()) {\n        stream << space << \"MATCH\" << space << matchType;\n    }\n    if (deferrableValid()) {\n        stream << space << deferrable;\n    }\n    return true;\n}\n\nvoid ForeignKeyClause::iterate(const Iterator& iterator, bool& stop)\n{\n    Identifier::iterate(iterator, true, stop);\n    listIterate(columns, iterator, stop);\n    Identifier::iterate(iterator, false, stop);\n}\n\n} // namespace Syntax\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/syntax/identifier/SyntaxForeignKeyClause.hpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"SyntaxIdentifier.hpp\"\n\nnamespace WCDB {\n\nnamespace Syntax {\n\nclass WCDB_API ForeignKeyClause final : public Identifier {\n#pragma mark - Lang\npublic:\n    ~ForeignKeyClause() override;\n\n    StringView foreignTable;\n    std::list<Column> columns;\n    enum class Switch : signed char {\n        OnDeleteSetNull = 1,\n        OnDeleteSetDefault,\n        OnDeleteCascade,\n        OnDeleteRestrict,\n        OnDeleteNoAction,\n        OnUpdateSetNull,\n        OnUpdateSetDefault,\n        OnUpdateCascade,\n        OnUpdateRestrict,\n        OnUpdateNoAction,\n    };\n    std::list<Switch> switchers;\n    WCDB_SYNTAX_ENUM_UNION(MatchType, matchType);\n\n    WCDB_SYNTAX_UNION_ENUM(Deferrable,\n                           deferrable,\n                           DeferrableInitiallyDeferred,\n                           DeferrableInitiallyImmediate,\n                           Deferrable,\n                           NotDeferrableInitiallyDeferred,\n                           NotDeferrableInitiallyImmediate,\n                           NotDeferrable, );\n\n    bool isValid() const override final;\n\n#pragma mark - Identifier\npublic:\n    static constexpr const Type type = Type::ForeignKeyClause;\n    Type getType() const override final;\n    bool describle(std::ostream& stream) const override final;\n    void iterate(const Iterator& iterator, bool& stop) override final;\n};\n\n} // namespace Syntax\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/syntax/identifier/SyntaxFrameSpec.cpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"Syntax.h\"\n#include \"SyntaxAssertion.hpp\"\n#include \"SyntaxEnum.hpp\"\n\nnamespace WCDB {\n\ntemplate<>\nconstexpr const char* Enum::description(const Syntax::FrameSpec::Switch& switcher)\n{\n    switch (switcher) {\n    case Syntax::FrameSpec::Switch::Range:\n        return \"RANGE\";\n    case Syntax::FrameSpec::Switch::Rows:\n        return \"ROWS\";\n    }\n}\n\ntemplate<>\nconstexpr const char* Enum::description(const Syntax::FrameSpec::FirstEvent& firstEvent)\n{\n    switch (firstEvent) {\n    case Syntax::FrameSpec::FirstEvent::UnboundedPreceding:\n        return \"UNBOUNDED PRECEDING\";\n    case Syntax::FrameSpec::FirstEvent::Preceding:\n        return \"PRECEDING\";\n    case Syntax::FrameSpec::FirstEvent::CurrentRow:\n        return \"CURRENT ROW\";\n    case Syntax::FrameSpec::FirstEvent::Following:\n        return \"FOLLOWING\";\n    }\n}\n\ntemplate<>\nconstexpr const char* Enum::description(const Syntax::FrameSpec::SecondEvent& secondEvent)\n{\n    switch (secondEvent) {\n    case Syntax::FrameSpec::SecondEvent::UnboundedFollowing:\n        return \"UNBOUNDED FOLLOWING\";\n    case Syntax::FrameSpec::SecondEvent::Preceding:\n        return \"PRECEDING\";\n    case Syntax::FrameSpec::SecondEvent::CurrentRow:\n        return \"CURRENT ROW\";\n    case Syntax::FrameSpec::SecondEvent::Following:\n        return \"FOLLOWING\";\n    }\n}\n\nnamespace Syntax {\n\nFrameSpec::~FrameSpec() = default;\n\n#pragma mark - Identifier\nIdentifier::Type FrameSpec::getType() const\n{\n    return type;\n}\n\nbool FrameSpec::describle(std::ostream& stream) const\n{\n    stream << switcher << space;\n    if (between) {\n        stream << \"BETWEEN \";\n    }\n    switch (firstEvent) {\n    case FirstEvent::Preceding:\n    case FirstEvent::Following:\n        stream << *expression1.get() << space;\n        // fallthrough\n    case FirstEvent::UnboundedPreceding:\n    case FirstEvent::CurrentRow:\n        stream << firstEvent;\n        break;\n    }\n    if (between) {\n        stream << \" AND \";\n        switch (secondEvent) {\n        case SecondEvent::Preceding:\n        case SecondEvent::Following:\n            stream << *expression2.get() << space;\n            // fallthrough\n        case SecondEvent::UnboundedFollowing:\n        case SecondEvent::CurrentRow:\n            stream << secondEvent;\n            break;\n        }\n    }\n    return true;\n}\n\nvoid FrameSpec::iterate(const Iterator& iterator, bool& stop)\n{\n    Identifier::iterate(iterator, true, stop);\n    switch (firstEvent) {\n    case FirstEvent::Preceding:\n    case FirstEvent::Following:\n        expression1.get()->iterate(iterator, stop);\n        // fallthrough\n    case FirstEvent::UnboundedPreceding:\n    case FirstEvent::CurrentRow:\n        break;\n    }\n    if (between) {\n        switch (secondEvent) {\n        case SecondEvent::Preceding:\n        case SecondEvent::Following:\n            expression2.get()->iterate(iterator, stop);\n            // fallthrough\n        case SecondEvent::UnboundedFollowing:\n        case SecondEvent::CurrentRow:\n            break;\n        }\n    }\n    Identifier::iterate(iterator, false, stop);\n}\n\n} // namespace Syntax\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/syntax/identifier/SyntaxFrameSpec.hpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"SyntaxIdentifier.hpp\"\n#include <ostream>\n\nnamespace WCDB {\n\nnamespace Syntax {\n\nclass Expression;\n\nclass WCDB_API FrameSpec final : public Identifier {\n#pragma mark - Lang\npublic:\n    ~FrameSpec() override;\n\n    WCDB_SYNTAX_MAIN_UNION_ENUM(Range, Rows, );\n\n    enum class Event : signed char {\n        Single = 1,\n        Between,\n    } event;\n    enum class FirstEvent : signed char {\n        UnboundedPreceding = 1,\n        Preceding,\n        Following,\n        CurrentRow,\n    } firstEvent;\n    enum class SecondEvent : signed char {\n        UnboundedFollowing = 1,\n        Preceding,\n        Following,\n        CurrentRow,\n    } secondEvent;\n    bool between = false;\n    Shadow<Expression> expression1;\n    Shadow<Expression> expression2;\n\n#pragma mark - Identifier\npublic:\n    static constexpr const Type type = Type::FrameSpec;\n    Type getType() const override final;\n    bool describle(std::ostream& stream) const override final;\n    void iterate(const Iterator& iterator, bool& stop) override final;\n};\n\n} // namespace Syntax\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/syntax/identifier/SyntaxIdentifier.cpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"Syntax.h\"\n#include \"SyntaxAssertion.hpp\"\n\nnamespace WCDB {\n\nnamespace Syntax {\n\nIdentifier::~Identifier() = default;\n\nStringView Identifier::getDescription() const\n{\n    if (isValid()) {\n        std::ostringstream stream;\n        if (describle(stream)) {\n            return stream.str();\n        }\n        WCTAssert(false);\n    }\n    return StringView();\n}\n\nvoid Identifier::iterate(const Iterator &iterator)\n{\n    if (isValid()) {\n        bool stop = false;\n        iterate(iterator, stop);\n    }\n}\n\nvoid Identifier::iterate(const ConstIterator &iterator) const\n{\n    if (isValid()) {\n        bool stop = false;\n        const Iterator iter = static_cast<Iterator>(iterator);\n        Identifier *identifier = const_cast<Identifier *>(this);\n        identifier->iterate(iter, stop);\n    }\n}\n\nvoid Identifier::recursiveIterate(Identifier &identifier, const Iterator &iterator, bool &stop)\n{\n    if (stop) {\n        return;\n    }\n    identifier.iterate(iterator, stop);\n}\n\nvoid Identifier::iterate(const Iterator &iterator, bool isBegin, bool &stop)\n{\n    if (!stop && isValid()) {\n        iterator(*this, isBegin, stop);\n    }\n}\n\nvoid Identifier::iterate(const Iterator &iterator, bool &stop)\n{\n    if (!stop && isValid()) {\n        iterator(*this, true, stop);\n        iterator(*this, false, stop);\n    }\n}\n\nstd::shared_ptr<Identifier> Identifier::clone() const\n{\n    switch (getType()) {\n    case Type::Column:\n        return std::make_shared<Column>(*static_cast<const Column *>(this));\n    case Type::Schema:\n        return std::make_shared<Schema>(*static_cast<const Schema *>(this));\n    case Type::ColumnDef:\n        return std::make_shared<ColumnDef>(*static_cast<const ColumnDef *>(this));\n    case Type::ColumnConstraint:\n        return std::make_shared<ColumnConstraint>(\n        *static_cast<const ColumnConstraint *>(this));\n    case Type::Expression:\n        return std::make_shared<Expression>(*static_cast<const Expression *>(this));\n    case Type::LiteralValue:\n        return std::make_shared<LiteralValue>(*static_cast<const LiteralValue *>(this));\n    case Type::ForeignKeyClause:\n        return std::make_shared<ForeignKeyClause>(\n        *static_cast<const ForeignKeyClause *>(this));\n    case Type::BindParameter:\n        return std::make_shared<BindParameter>(*static_cast<const BindParameter *>(this));\n    case Type::RaiseFunction:\n        return std::make_shared<RaiseFunction>(*static_cast<const RaiseFunction *>(this));\n    case Type::WindowDef:\n        return std::make_shared<WindowDef>(*static_cast<const WindowDef *>(this));\n    case Type::Filter:\n        return std::make_shared<Filter>(*static_cast<const Filter *>(this));\n    case Type::IndexedColumn:\n        return std::make_shared<IndexedColumn>(*static_cast<const IndexedColumn *>(this));\n    case Type::TableConstraint:\n        return std::make_shared<TableConstraint>(*static_cast<const TableConstraint *>(this));\n    case Type::CommonTableExpression:\n        return std::make_shared<CommonTableExpression>(\n        *static_cast<const CommonTableExpression *>(this));\n    case Type::QualifiedTableName:\n        return std::make_shared<QualifiedTableName>(\n        *static_cast<const QualifiedTableName *>(this));\n    case Type::OrderingTerm:\n        return std::make_shared<OrderingTerm>(*static_cast<const OrderingTerm *>(this));\n    case Type::UpsertClause:\n        return std::make_shared<UpsertClause>(*static_cast<const UpsertClause *>(this));\n    case Type::Pragma:\n        return std::make_shared<Pragma>(*static_cast<const Pragma *>(this));\n    case Type::JoinClause:\n        return std::make_shared<JoinClause>(*static_cast<const JoinClause *>(this));\n    case Type::TableOrSubquery:\n        return std::make_shared<TableOrSubquery>(*static_cast<const TableOrSubquery *>(this));\n    case Type::JoinConstraint:\n        return std::make_shared<JoinConstraint>(*static_cast<const JoinConstraint *>(this));\n        //    case Type::SelectCore:\n        //        return std::make_shared<SelectCore>(*static_cast<const SelectCore *>(this));\n    case Type::ResultColumn:\n        return std::make_shared<ResultColumn>(*static_cast<const ResultColumn *>(this));\n    case Type::FrameSpec:\n        return std::make_shared<FrameSpec>(*static_cast<const FrameSpec *>(this));\n    case Type::AlterTableSTMT:\n        return std::make_shared<AlterTableSTMT>(*static_cast<const AlterTableSTMT *>(this));\n    case Type::AnalyzeSTMT:\n        return std::make_shared<AnalyzeSTMT>(*static_cast<const AnalyzeSTMT *>(this));\n    case Type::AttachSTMT:\n        return std::make_shared<AttachSTMT>(*static_cast<const AttachSTMT *>(this));\n    case Type::BeginSTMT:\n        return std::make_shared<BeginSTMT>(*static_cast<const BeginSTMT *>(this));\n    case Type::CommitSTMT:\n        return std::make_shared<CommitSTMT>(*static_cast<const CommitSTMT *>(this));\n    case Type::RollbackSTMT:\n        return std::make_shared<RollbackSTMT>(*static_cast<const RollbackSTMT *>(this));\n    case Type::SavepointSTMT:\n        return std::make_shared<SavepointSTMT>(*static_cast<const SavepointSTMT *>(this));\n    case Type::ReleaseSTMT:\n        return std::make_shared<ReleaseSTMT>(*static_cast<const ReleaseSTMT *>(this));\n    case Type::CreateIndexSTMT:\n        return std::make_shared<CreateIndexSTMT>(*static_cast<const CreateIndexSTMT *>(this));\n    case Type::CreateTableSTMT:\n        return std::make_shared<CreateTableSTMT>(*static_cast<const CreateTableSTMT *>(this));\n    case Type::CreateTriggerSTMT:\n        return std::make_shared<CreateTriggerSTMT>(\n        *static_cast<const CreateTriggerSTMT *>(this));\n    case Type::SelectSTMT:\n        return std::make_shared<SelectSTMT>(*static_cast<const SelectSTMT *>(this));\n    case Type::InsertSTMT:\n        return std::make_shared<InsertSTMT>(*static_cast<const InsertSTMT *>(this));\n    case Type::DeleteSTMT:\n        return std::make_shared<DeleteSTMT>(*static_cast<const DeleteSTMT *>(this));\n    case Type::UpdateSTMT:\n        return std::make_shared<UpdateSTMT>(*static_cast<const UpdateSTMT *>(this));\n    case Type::CreateViewSTMT:\n        return std::make_shared<CreateViewSTMT>(*static_cast<const CreateViewSTMT *>(this));\n    case Type::CreateVirtualTableSTMT:\n        return std::make_shared<CreateVirtualTableSTMT>(\n        *static_cast<const CreateVirtualTableSTMT *>(this));\n    case Type::DetachSTMT:\n        return std::make_shared<DetachSTMT>(*static_cast<const DetachSTMT *>(this));\n    case Type::DropIndexSTMT:\n        return std::make_shared<DropIndexSTMT>(*static_cast<const DropIndexSTMT *>(this));\n    case Type::DropTableSTMT:\n        return std::make_shared<DropTableSTMT>(*static_cast<const DropTableSTMT *>(this));\n    case Type::DropTriggerSTMT:\n        return std::make_shared<DropTriggerSTMT>(*static_cast<const DropTriggerSTMT *>(this));\n    case Type::DropViewSTMT:\n        return std::make_shared<DropViewSTMT>(*static_cast<const DropViewSTMT *>(this));\n    case Type::PragmaSTMT:\n        return std::make_shared<PragmaSTMT>(*static_cast<const PragmaSTMT *>(this));\n    case Type::ReindexSTMT:\n        return std::make_shared<ReindexSTMT>(*static_cast<const ReindexSTMT *>(this));\n    case Type::VacuumSTMT:\n        return std::make_shared<VacuumSTMT>(*static_cast<const VacuumSTMT *>(this));\n    case Type::ExplainSTMT:\n        return std::make_shared<ExplainSTMT>(*static_cast<const ExplainSTMT *>(this));\n    default:\n        WCTAssert(false);\n        return nullptr;\n    }\n}\n\n} // namespace Syntax\n\n} // namespace WCDB\n\nstd::ostream &operator<<(std::ostream &stream, const WCDB::Syntax::Identifier &identifier)\n{\n    identifier.describle(stream);\n    return stream;\n}\n"
  },
  {
    "path": "src/common/winq/syntax/identifier/SyntaxIdentifier.hpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"Macro.h\"\n#include \"Shadow.hpp\"\n#include \"StringView.hpp\"\n#include \"SyntaxCommonConst.hpp\"\n#include \"WCDBOptional.hpp\"\n#include <functional>\n#include <list>\n#include <sstream>\n\nnamespace WCDB {\n\nnamespace Syntax {\n\nclass WCDB_API Identifier : public Cloneable<Identifier> {\npublic:\n    virtual ~Identifier() override = 0;\n\n    enum class Type : signed char {\n        Invalid = 0,\n        Column,\n        Schema,\n        ColumnDef,\n        ColumnConstraint,\n        Expression,\n        LiteralValue,\n        ForeignKeyClause,\n        BindParameter,\n        RaiseFunction,\n        WindowDef,\n        Filter,\n        IndexedColumn,\n        TableConstraint,\n        CommonTableExpression,\n        QualifiedTableName,\n        OrderingTerm,\n        UpsertClause,\n        Pragma,\n        JoinClause,\n        TableOrSubquery,\n        JoinConstraint,\n        SelectCore,\n        ResultColumn,\n        FrameSpec,\n\n        AlterTableSTMT,\n        AnalyzeSTMT,\n        AttachSTMT,\n        BeginSTMT,\n        CommitSTMT,\n        RollbackSTMT,\n        SavepointSTMT,\n        ReleaseSTMT,\n        CreateIndexSTMT,\n        CreateTableSTMT,\n        CreateTriggerSTMT,\n        SelectSTMT,\n        InsertSTMT,\n        DeleteSTMT,\n        UpdateSTMT,\n        CreateViewSTMT,\n        CreateVirtualTableSTMT,\n        DetachSTMT,\n        DropIndexSTMT,\n        DropTableSTMT,\n        DropTriggerSTMT,\n        DropViewSTMT,\n        PragmaSTMT,\n        ReindexSTMT,\n        VacuumSTMT,\n        ExplainSTMT,\n    };\n    virtual Type getType() const = 0;\n\n    StringView getDescription() const;\n\n    std::shared_ptr<Identifier> clone() const override final;\n\n    typedef signed char Valid;\n    static constexpr const Valid invalid = -1;\n\n    virtual bool isValid() const = 0;\n\n    virtual bool describle(std::ostream& stream) const = 0;\n\n#pragma mark - Iterable\npublic:\n    typedef std::function<void(Identifier&, bool isBegin, bool& stop)> Iterator;\n    typedef std::function<void(const Identifier&, bool isBegin, bool& stop)> ConstIterator;\n\n    void iterate(const Iterator& iterator);\n    void iterate(const ConstIterator& iterator) const;\n    virtual void iterate(const Iterator& iterator, bool& stop);\n\nprotected:\n    void iterate(const Iterator& iterator, bool isBegin, bool& stop);\n    static void\n    recursiveIterate(Identifier& identifier, const Iterator& iterator, bool& stop);\n\n    template<typename T, typename Enable = typename std::enable_if<std::is_base_of<Identifier, T>::value>>\n    static void\n    listIterate(std::list<T>& identifiers, const Iterator& iterator, bool& stop)\n    {\n        if (!stop) {\n            for (auto& identifier : identifiers) {\n                recursiveIterate(identifier, iterator, stop);\n            }\n        }\n    }\n    static constexpr const char* space = \" \";\n};\n\n} // namespace Syntax\n\n} // namespace WCDB\n\nstd::ostream& operator<<(std::ostream& stream, const WCDB::Syntax::Identifier& identifiers);\n\ntemplate<typename T, typename Enable = typename std::enable_if<std::is_base_of<WCDB::Syntax::Identifier, T>::value>::type>\nstd::ostream& operator<<(std::ostream& stream, const std::list<T>& identifiers)\n{\n    bool comma = false;\n    for (const auto& identifier : identifiers) {\n        if (comma) {\n            stream << \", \";\n        } else {\n            comma = true;\n        }\n        stream << identifier;\n    }\n    return stream;\n}\n\n// The value of Type should always be positive.\n#define __WCDB_SYNTAX_UNION_ENUM(Type, nameOfType, nameOfValid)                \\\n    static_assert(sizeof(Type) == sizeof(Valid), \"\");                          \\\n    union {                                                                    \\\n        Type nameOfType;                                                       \\\n        Valid nameOfValid = Identifier::invalid;                               \\\n    };\n\n#define WCDB_SYNTAX_ENUM_UNION(Type, nameOfType)                               \\\n    __WCDB_SYNTAX_UNION_ENUM(Type, nameOfType, __##nameOfType##Valid);         \\\n    bool nameOfType##Valid() const                                             \\\n    {                                                                          \\\n        return __##nameOfType##Valid >= 0;                                     \\\n    }\n\n#define WCDB_SYNTAX_UNION_ENUM(Type, nameOfType, First, ...)                   \\\n    enum class Type : signed char { First = 1, __VA_ARGS__ };                  \\\n    __WCDB_SYNTAX_UNION_ENUM(Type, nameOfType, __##nameOfType##Valid);         \\\n    bool nameOfType##Valid() const                                             \\\n    {                                                                          \\\n        return __##nameOfType##Valid >= 0;                                     \\\n    }\n\n#define WCDB_SYNTAX_MAIN_UNION_ENUM(First, ...)                                \\\n    enum class Switch : signed char { First = 1, __VA_ARGS__ };                \\\n    __WCDB_SYNTAX_UNION_ENUM(Switch, switcher, __is_valid);                    \\\n    bool isValid() const override final                                        \\\n    {                                                                          \\\n        return __is_valid >= 0;                                                \\\n    }\n\n#define WCDB_SYNTAX_UNION_MEMBER_IMPLEMENT(NameSpace, MemberTag, Type, name)   \\\n    Type& NameSpace::name()                                                    \\\n    {                                                                          \\\n        if (m_##MemberTag != Member::name) {                                   \\\n            MemberTag##Reset();                                                \\\n        }                                                                      \\\n        if (m_##MemberTag == Member::Invalid) {                                \\\n            new ((void*) std::addressof(m_##name)) Type();                     \\\n            m_##MemberTag = Member::name;                                      \\\n        }                                                                      \\\n        return m_##name;                                                       \\\n    }                                                                          \\\n    const Type& NameSpace::name() const                                        \\\n    {                                                                          \\\n        if (m_##MemberTag != Member::name) {                                   \\\n            MemberTag##Reset();                                                \\\n        }                                                                      \\\n        if (m_##MemberTag == Member::Invalid) {                                \\\n            new ((void*) std::addressof(m_##name)) Type();                     \\\n            m_##MemberTag = Member::name;                                      \\\n        }                                                                      \\\n        return m_##name;                                                       \\\n    }\n\n#define WCDB_SYNTAX_CHECK_OPTIONAL_VALID(value)                                \\\n    (value.hasValue() && value->isValid())\n"
  },
  {
    "path": "src/common/winq/syntax/identifier/SyntaxIndexedColumn.cpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"Syntax.h\"\n#include \"SyntaxAssertion.hpp\"\n#include \"SyntaxEnum.hpp\"\n\nnamespace WCDB {\n\nnamespace Syntax {\n\nIndexedColumn::~IndexedColumn() = default;\n\n#pragma mark - Identifier\nIdentifier::Type IndexedColumn::getType() const\n{\n    return type;\n}\n\nbool IndexedColumn::describle(std::ostream& stream) const\n{\n    switch (switcher) {\n    case Switch::Column:\n        stream << column.getOrCreate();\n        break;\n    case Switch::Expression:\n        stream << expression.getOrCreate();\n        break;\n    }\n    if (collation.length() > 0) {\n        stream << \" COLLATE \" << collation;\n    }\n    if (orderValid()) {\n        stream << space << order;\n    }\n    return true;\n}\n\nvoid IndexedColumn::iterate(const Iterator& iterator, bool& stop)\n{\n    Identifier::iterate(iterator, true, stop);\n    switch (switcher) {\n    case Switch::Column:\n        recursiveIterate(column.getOrCreate(), iterator, stop);\n        break;\n    case Switch::Expression:\n        recursiveIterate(expression.getOrCreate(), iterator, stop);\n    }\n    Identifier::iterate(iterator, false, stop);\n}\n\n} // namespace Syntax\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/syntax/identifier/SyntaxIndexedColumn.hpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"SyntaxColumn.hpp\"\n#include \"SyntaxExpression.hpp\"\n#include \"SyntaxIdentifier.hpp\"\n\nnamespace WCDB {\n\nnamespace Syntax {\n\nclass WCDB_API IndexedColumn final : public Identifier {\n#pragma mark - Lang\npublic:\n    ~IndexedColumn() override;\n\n    WCDB_SYNTAX_MAIN_UNION_ENUM(Column, Expression);\n\n    Optional<Column> column;\n    Optional<Expression> expression;\n    StringView collation;\n\n    WCDB_SYNTAX_ENUM_UNION(Order, order);\n\n#pragma mark - Identifier\npublic:\n    static constexpr const Type type = Type::IndexedColumn;\n    Type getType() const override final;\n    bool describle(std::ostream& stream) const override final;\n    void iterate(const Iterator& iterator, bool& stop) override final;\n};\n\n} // namespace Syntax\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/syntax/identifier/SyntaxJoinClause.cpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"Syntax.h\"\n#include \"SyntaxAssertion.hpp\"\n#include \"SyntaxEnum.hpp\"\n\nnamespace WCDB {\n\nnamespace Syntax {\n\nJoinClause::~JoinClause() = default;\n\nbool JoinClause::isValid() const\n{\n    return !tableOrSubqueries.empty();\n}\n\n#pragma mark - Identifier\nIdentifier::Type JoinClause::getType() const\n{\n    return type;\n}\n\nbool JoinClause::describle(std::ostream& stream) const\n{\n    auto tableOrSubquery = tableOrSubqueries.begin();\n    stream << *tableOrSubquery;\n    if (++tableOrSubquery != tableOrSubqueries.end()) {\n        auto joinOperator = joinOperators.begin();\n        auto joinConstraint = joinConstraints.begin();\n        WCTSyntaxRemedialAssert(std::distance(tableOrSubquery, tableOrSubqueries.end())\n                                == std::distance(joinOperator, joinOperators.end()));\n        while (joinOperator != joinOperators.end()\n               && tableOrSubquery != tableOrSubqueries.end()\n               && joinConstraint != joinConstraints.end()) {\n            if (*joinOperator != JoinOperator::With) {\n                stream << space;\n            }\n            stream << *joinOperator << space << *tableOrSubquery;\n            if (joinConstraint->get() != nullptr) {\n                stream << space << *joinConstraint->get();\n            }\n            ++joinOperator;\n            ++tableOrSubquery;\n            ++joinConstraint;\n        }\n    }\n    return true;\n}\n\nvoid JoinClause::iterate(const Iterator& iterator, bool& stop)\n{\n    Identifier::iterate(iterator, true, stop);\n    auto tableOrSubquery = tableOrSubqueries.begin();\n    tableOrSubquery->iterate(iterator, stop);\n    if (++tableOrSubquery != tableOrSubqueries.end()) {\n        auto joinOperator = joinOperators.begin();\n        auto joinConstraint = joinConstraints.begin();\n        WCTIterateRemedialAssert(\n        std::distance(tableOrSubquery, tableOrSubqueries.end())\n        == std::distance(joinOperator, joinOperators.end()));\n        while (joinOperator != joinOperators.end()\n               && tableOrSubquery != tableOrSubqueries.end()\n               && joinConstraint != joinConstraints.end()) {\n            tableOrSubquery->iterate(iterator, stop);\n            if (joinConstraint->get() != nullptr) {\n                joinConstraint->get()->iterate(iterator, stop);\n            }\n            ++joinOperator;\n            ++tableOrSubquery;\n            ++joinConstraint;\n        }\n    }\n    Identifier::iterate(iterator, false, stop);\n}\n\n} // namespace Syntax\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/syntax/identifier/SyntaxJoinClause.hpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"SyntaxIdentifier.hpp\"\n\nnamespace WCDB {\n\nnamespace Syntax {\n\nclass TableOrSubquery;\nclass JoinConstraint;\n\nclass WCDB_API JoinClause final : public Identifier {\n#pragma mark - Lang\npublic:\n    ~JoinClause() override;\n\n    std::list<JoinOperator> joinOperators;\n    std::list<TableOrSubquery> tableOrSubqueries;\n    std::list<Shadow<JoinConstraint>> joinConstraints; // nullable\n\n    bool isValid() const override final;\n\n#pragma mark - Identifier\npublic:\n    static constexpr const Type type = Type::JoinClause;\n    Type getType() const override final;\n    bool describle(std::ostream& stream) const override final;\n    void iterate(const Iterator& iterator, bool& stop) override final;\n};\n\n} // namespace Syntax\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/syntax/identifier/SyntaxJoinConstraint.cpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"Syntax.h\"\n#include \"SyntaxAssertion.hpp\"\n\nnamespace WCDB {\n\nnamespace Syntax {\n\nJoinConstraint::~JoinConstraint() = default;\n\nbool JoinConstraint::isValid() const\n{\n    return !columns.empty() || (expression.hasValue() && expression->isValid());\n}\n\n#pragma mark - Identifier\nIdentifier::Type JoinConstraint::getType() const\n{\n    return type;\n}\n\nbool JoinConstraint::describle(std::ostream& stream) const\n{\n    if (!columns.empty()) {\n        stream << \"USING(\" << columns << \")\";\n    } else {\n        stream << \"ON \" << expression.getOrCreate();\n    }\n    return true;\n}\n\nvoid JoinConstraint::iterate(const Iterator& iterator, bool& stop)\n{\n    Identifier::iterate(iterator, true, stop);\n    if (!columns.empty()) {\n        listIterate(columns, iterator, stop);\n    } else {\n        recursiveIterate(expression.getOrCreate(), iterator, stop);\n    }\n    Identifier::iterate(iterator, false, stop);\n}\n\n} // namespace Syntax\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/syntax/identifier/SyntaxJoinConstraint.hpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"SyntaxIdentifier.hpp\"\n\nnamespace WCDB {\n\nnamespace Syntax {\n\nclass WCDB_API JoinConstraint final : public Identifier {\n#pragma mark - Lang\npublic:\n    ~JoinConstraint() override;\n\n    Optional<Expression> expression;\n    std::list<Column> columns;\n    bool isValid() const override final;\n\n#pragma mark - Identifier\npublic:\n    static constexpr const Type type = Type::JoinConstraint;\n    Type getType() const override final;\n    bool describle(std::ostream& stream) const override final;\n    void iterate(const Iterator& iterator, bool& stop) override final;\n};\n\n} // namespace Syntax\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/syntax/identifier/SyntaxLiteralValue.cpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"Syntax.h\"\n#include \"SyntaxAssertion.hpp\"\n#include <limits>\n\nnamespace WCDB {\n\nnamespace Syntax {\n\nLiteralValue::~LiteralValue() = default;\n\n#pragma mark - Identifier\nIdentifier::Type LiteralValue::getType() const\n{\n    return type;\n}\n\nbool LiteralValue::describle(std::ostream& stream) const\n{\n    switch (switcher) {\n    case Switch::StringView: {\n        stream << \"'\";\n        for (int i = 0; i < stringValue.length(); i++) {\n            const auto character = stringValue.at(i);\n            if (character != '\\'') {\n                stream << character;\n            } else {\n                stream << \"''\";\n            }\n        }\n        stream << \"'\";\n    } break;\n    case Switch::Null:\n        stream << \"NULL\";\n        break;\n    case Switch::Float:\n        stream.precision(std::numeric_limits<double>::max_digits10);\n        stream << floatValue;\n        break;\n    case Switch::Integer:\n        stream << integerValue;\n        break;\n    case Switch::UnsignedInteger:\n        stream << unsignedIntegerValue;\n        break;\n    case Switch::Bool:\n        stream << (boolValue ? \"TRUE\" : \"FALSE\");\n        break;\n    case Switch::CurrentTime:\n        stream << \"CURRENT_TIME\";\n        break;\n    case Switch::CurrentDate:\n        stream << \"CURRENT_DATE\";\n        break;\n    case Switch::CurrentTimestamp:\n        stream << \"CURRENT_TIMESTAMP\";\n        break;\n    }\n    return true;\n}\n\n} // namespace Syntax\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/syntax/identifier/SyntaxLiteralValue.hpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"SyntaxIdentifier.hpp\"\n\nnamespace WCDB {\n\nnamespace Syntax {\n\n// BLOB is not supported since it may cause string truncation. Ones should use BindParameter instead.\nclass WCDB_API LiteralValue final : public Identifier {\n#pragma mark - Lang\npublic:\n    ~LiteralValue() override;\n\n    WCDB_SYNTAX_MAIN_UNION_ENUM(\n    StringView, Null, Float, Integer, UnsignedInteger, Bool, CurrentTime, CurrentDate, CurrentTimestamp);\n\n    StringView stringValue;\n    union {\n        double floatValue;\n        int64_t integerValue;\n        uint64_t unsignedIntegerValue;\n        bool boolValue;\n    };\n\n#pragma mark - Identifier\npublic:\n    static constexpr const Type type = Type::LiteralValue;\n    Type getType() const override final;\n    bool describle(std::ostream& stream) const override final;\n};\n\n} // namespace Syntax\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/syntax/identifier/SyntaxOrderingTerm.cpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"Syntax.h\"\n#include \"SyntaxAssertion.hpp\"\n#include \"SyntaxEnum.hpp\"\n\nnamespace WCDB {\n\nnamespace Syntax {\n\nOrderingTerm::~OrderingTerm() = default;\n\nbool OrderingTerm::isValid() const\n{\n    return WCDB_SYNTAX_CHECK_OPTIONAL_VALID(expression);\n}\n\n#pragma mark - Identifier\nIdentifier::Type OrderingTerm::getType() const\n{\n    return type;\n}\n\nbool OrderingTerm::describle(std::ostream& stream) const\n{\n    stream << expression.getOrCreate();\n    if (collation.length() > 0) {\n        stream << \" COLLATE \" << collation;\n    }\n    if (orderValid()) {\n        stream << space << order;\n    }\n    return true;\n}\n\nvoid OrderingTerm::iterate(const Iterator& iterator, bool& stop)\n{\n    Identifier::iterate(iterator, true, stop);\n    recursiveIterate(expression.getOrCreate(), iterator, stop);\n    Identifier::iterate(iterator, false, stop);\n}\n\n} // namespace Syntax\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/syntax/identifier/SyntaxOrderingTerm.hpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"SyntaxIdentifier.hpp\"\n\nnamespace WCDB {\n\nnamespace Syntax {\n\nclass WCDB_API OrderingTerm final : public Identifier {\n#pragma mark - Lang\npublic:\n    ~OrderingTerm() override;\n\n    Optional<Expression> expression;\n    StringView collation;\n    WCDB_SYNTAX_ENUM_UNION(Order, order);\n\n    bool isValid() const override final;\n\n#pragma mark - Identifier\npublic:\n    static constexpr const Type type = Type::OrderingTerm;\n    Type getType() const override final;\n    bool describle(std::ostream& stream) const override final;\n    void iterate(const Iterator& iterator, bool& stop) override final;\n};\n\n} // namespace Syntax\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/syntax/identifier/SyntaxPragma.cpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"Syntax.h\"\n#include \"SyntaxAssertion.hpp\"\n\nnamespace WCDB {\n\nnamespace Syntax {\n\nPragma::~Pragma() = default;\n\nbool Pragma::isValid() const\n{\n    return !name.empty();\n}\n\n#pragma mark - Identifier\nIdentifier::Type Pragma::getType() const\n{\n    return type;\n}\n\nbool Pragma::describle(std::ostream& stream) const\n{\n    stream << name;\n    return true;\n}\n\n} // namespace Syntax\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/syntax/identifier/SyntaxPragma.hpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"SyntaxIdentifier.hpp\"\n\nnamespace WCDB {\n\nnamespace Syntax {\n\nclass WCDB_API Pragma final : public Identifier {\n#pragma mark - Lang\npublic:\n    ~Pragma() override;\n\n    StringView name;\n\n    bool isValid() const override final;\n\n#pragma mark - Identifier\npublic:\n    static constexpr const Type type = Type::Pragma;\n    Type getType() const override final;\n    bool describle(std::ostream& stream) const override final;\n};\n\n} // namespace Syntax\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/syntax/identifier/SyntaxQualifiedTableName.cpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"Syntax.h\"\n#include \"SyntaxAssertion.hpp\"\n\nnamespace WCDB {\n\nnamespace Syntax {\n\nQualifiedTableName::~QualifiedTableName() = default;\n\nbool QualifiedTableName::isValid() const\n{\n    return !table.empty();\n}\n\n#pragma mark - Identifier\nIdentifier::Type QualifiedTableName::getType() const\n{\n    return type;\n}\n\nbool QualifiedTableName::describle(std::ostream& stream) const\n{\n    return describle(stream, false);\n}\n\nbool QualifiedTableName::describle(std::ostream& stream, bool skipSchema) const\n{\n    if (!skipSchema && !schema.empty()) {\n        stream << schema << \".\";\n    }\n    stream << table;\n    if (!alias.empty()) {\n        stream << \" AS \" << alias;\n    }\n    switch (switcher) {\n    case Switch::NotSet:\n        break;\n    case Switch::Indexed:\n        stream << \" INDEXED BY \" << index;\n        break;\n    case Switch::NotIndexed:\n        stream << \" NOT INDEXED\";\n        break;\n    }\n    return true;\n}\n\nvoid QualifiedTableName::iterate(const Iterator& iterator, bool& stop)\n{\n    Identifier::iterate(iterator, true, stop);\n    recursiveIterate(schema, iterator, stop);\n    Identifier::iterate(iterator, false, stop);\n}\n\n#pragma mark - Utility\nbool QualifiedTableName::isTargetingToSameTable(const QualifiedTableName& other) const\n{\n    return table == other.table && schema.isTargetingSameSchema(other.schema);\n}\n\n} // namespace Syntax\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/syntax/identifier/SyntaxQualifiedTableName.hpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"SyntaxIdentifier.hpp\"\n\nnamespace WCDB {\n\nnamespace Syntax {\n\nclass WCDB_API QualifiedTableName final : public Identifier {\n#pragma mark - Lang\npublic:\n    ~QualifiedTableName() override;\n\n    Schema schema;\n    StringView table;\n    StringView alias;\n    enum class Switch : signed char {\n        NotSet = 0,\n        Indexed,\n        NotIndexed,\n    } switcher\n    = Switch::NotSet;\n    StringView index;\n\n    bool isValid() const override final;\n\n#pragma mark - Identifier\npublic:\n    static constexpr const Type type = Type::QualifiedTableName;\n    Type getType() const override final;\n    bool describle(std::ostream& stream) const override final;\n    bool describle(std::ostream& stream, bool skipSchema) const;\n    void iterate(const Iterator& iterator, bool& stop) override final;\n\n#pragma mark - Utility\npublic:\n    bool isTargetingToSameTable(const QualifiedTableName& other) const;\n};\n\n} // namespace Syntax\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/syntax/identifier/SyntaxRaiseFunction.cpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"Syntax.h\"\n#include \"SyntaxAssertion.hpp\"\n#include \"SyntaxEnum.hpp\"\n\nnamespace WCDB {\n\ntemplate<>\nconstexpr const char* Enum::description(const Syntax::RaiseFunction::Switch& switcher)\n{\n    switch (switcher) {\n    case Syntax::RaiseFunction::Switch::Ignore:\n        return \"IGNORE\";\n    case Syntax::RaiseFunction::Switch::Rollback:\n        return \"ROLLBACK\";\n    case Syntax::RaiseFunction::Switch::Abort:\n        return \"ABORT\";\n    case Syntax::RaiseFunction::Switch::Fail:\n        return \"FAIL\";\n    }\n}\n\nnamespace Syntax {\n\nRaiseFunction::~RaiseFunction() = default;\n\n#pragma mark - Identifier\nIdentifier::Type RaiseFunction::getType() const\n{\n    return type;\n}\n\nbool RaiseFunction::describle(std::ostream& stream) const\n{\n    stream << \"RAISE(\" << switcher;\n    switch (switcher) {\n    case Switch::Ignore:\n        break;\n    case Switch::Abort:\n    case Switch::Rollback:\n    case Switch::Fail:\n        stream << \", \" << errorMessage;\n        break;\n    }\n    stream << \")\";\n    return true;\n}\n\n} // namespace Syntax\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/syntax/identifier/SyntaxRaiseFunction.hpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"SyntaxIdentifier.hpp\"\n\nnamespace WCDB {\n\nnamespace Syntax {\n\nclass WCDB_API RaiseFunction final : public Identifier {\n#pragma mark - Lang\npublic:\n    ~RaiseFunction() override;\n\n    WCDB_SYNTAX_MAIN_UNION_ENUM(Ignore, Rollback, Abort, Fail, );\n    StringView errorMessage;\n\n#pragma mark - Identifier\npublic:\n    static constexpr const Type type = Type::RaiseFunction;\n    Type getType() const override final;\n    bool describle(std::ostream& stream) const override final;\n};\n\n} // namespace Syntax\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/syntax/identifier/SyntaxResultColumn.cpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"Syntax.h\"\n#include \"SyntaxAssertion.hpp\"\n\nnamespace WCDB {\n\nnamespace Syntax {\n\nResultColumn::~ResultColumn() = default;\n\nbool ResultColumn::isValid() const\n{\n    return WCDB_SYNTAX_CHECK_OPTIONAL_VALID(expression);\n}\n\n#pragma mark - Identifier\nIdentifier::Type ResultColumn::getType() const\n{\n    return type;\n}\n\nbool ResultColumn::describle(std::ostream& stream) const\n{\n    stream << expression.getOrCreate();\n    if (!alias.empty()) {\n        stream << \" AS \" << alias;\n    }\n    return true;\n}\n\nvoid ResultColumn::iterate(const Iterator& iterator, bool& stop)\n{\n    Identifier::iterate(iterator, true, stop);\n    recursiveIterate(expression.getOrCreate(), iterator, stop);\n    Identifier::iterate(iterator, false, stop);\n}\n\n} // namespace Syntax\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/syntax/identifier/SyntaxResultColumn.hpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"SyntaxIdentifier.hpp\"\n\nnamespace WCDB {\n\nnamespace Syntax {\n\nclass WCDB_API ResultColumn final : public Identifier {\n#pragma mark - Lang\npublic:\n    ~ResultColumn() override;\n\n    Optional<Expression> expression;\n    StringView alias;\n\n    bool isValid() const override final;\n\n#pragma mark - Identifier\npublic:\n    static constexpr const Type type = Type::ResultColumn;\n    Type getType() const override final;\n    bool describle(std::ostream& stream) const override final;\n    void iterate(const Iterator& iterator, bool& stop) override final;\n};\n\n} // namespace Syntax\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/syntax/identifier/SyntaxSchema.cpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"Syntax.h\"\n#include \"SyntaxAssertion.hpp\"\n\nnamespace WCDB {\n\nnamespace Syntax {\n\nbool Schema::isValid() const\n{\n    return !name.empty();\n}\n\nSchema::Schema() : name()\n{\n}\n\nSchema::~Schema() = default;\n\n#pragma mark - Identifier\nIdentifier::Type Schema::getType() const\n{\n    return type;\n}\n\nbool Schema::describle(std::ostream& stream) const\n{\n    stream << name;\n    return true;\n}\n\nbool Schema::isMain() const\n{\n    return name.empty() || name == mainSchema;\n}\n\nbool Schema::isTemp() const\n{\n    return name == tempSchema;\n}\n\nbool Schema::empty() const\n{\n    return name.empty();\n}\n\nbool Schema::isTargetingSameSchema(const Schema& other) const\n{\n    return (isMain() && other.isMain()) || (getDescription() == other.getDescription());\n}\n\n} // namespace Syntax\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/syntax/identifier/SyntaxSchema.hpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"SyntaxIdentifier.hpp\"\n\nnamespace WCDB {\n\nnamespace Syntax {\n\nclass WCDB_API Schema final : public Identifier {\n#pragma mark - Syntax\npublic:\n    Schema();\n    ~Schema() override;\n\n    StringView name;\n\n    bool isValid() const override final;\n\n#pragma mark - Identifier\npublic:\n    static constexpr const Type type = Type::Schema;\n    Type getType() const override final;\n    bool describle(std::ostream& stream) const override final;\n\n#pragma mark - Utility\npublic:\n    bool empty() const;\n    bool isMain() const;\n    bool isTemp() const;\n    bool isTargetingSameSchema(const Schema& other) const;\n};\n\n} // namespace Syntax\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/syntax/identifier/SyntaxSelectCore.cpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"Syntax.h\"\n#include \"SyntaxAssertion.hpp\"\n\nnamespace WCDB {\n\nnamespace Syntax {\n\nSelectCore::~SelectCore() = default;\n\n#pragma mark - Identifier\nIdentifier::Type SelectCore::getType() const\n{\n    return type;\n}\n\nbool SelectCore::describle(std::ostream& stream) const\n{\n    switch (switcher) {\n    case Switch::Select:\n        stream << \"SELECT \";\n        if (distinct) {\n            stream << \"DISTINCT \";\n        }\n        stream << resultColumns;\n        if (!tableOrSubqueries.empty() || WCDB_SYNTAX_CHECK_OPTIONAL_VALID(joinClause)) {\n            stream << \" FROM \";\n            if (!tableOrSubqueries.empty()) {\n                stream << tableOrSubqueries;\n            } else {\n                stream << joinClause.value();\n            }\n        }\n        if (WCDB_SYNTAX_CHECK_OPTIONAL_VALID(condition)) {\n            stream << \" WHERE \" << condition.value();\n        }\n        if (!groups.empty()) {\n            stream << \" GROUP BY \" << groups;\n            if (WCDB_SYNTAX_CHECK_OPTIONAL_VALID(having)) {\n                stream << \" HAVING \" << having.value();\n            }\n        }\n        if (!windows.empty()) {\n            WCTSyntaxRemedialAssert(windows.size() == windowDefs.size());\n            stream << \" WINDOW \";\n            auto window = windows.begin();\n            auto windowDef = windowDefs.begin();\n            bool comma = false;\n            while (window != windows.end() && windowDef != windowDefs.end()) {\n                if (comma) {\n                    stream << \", \";\n                } else {\n                    comma = true;\n                }\n                stream << *window << \" AS \" << *windowDef;\n                ++window;\n                ++windowDef;\n            }\n        }\n        break;\n    case Switch::Values:\n        stream << \"VALUES\";\n        bool comma = false;\n        for (const auto& values : valuesList) {\n            if (comma) {\n                stream << \", \";\n            } else {\n                comma = true;\n            }\n            stream << \"(\" << values << \")\";\n        }\n        break;\n    }\n    return true;\n}\n\nvoid SelectCore::iterate(const Iterator& iterator, bool& stop)\n{\n    Identifier::iterate(iterator, true, stop);\n    switch (switcher) {\n    case Switch::Select:\n        listIterate(resultColumns, iterator, stop);\n        if (!tableOrSubqueries.empty()) {\n            listIterate(tableOrSubqueries, iterator, stop);\n        } else if (WCDB_SYNTAX_CHECK_OPTIONAL_VALID(joinClause)) {\n            recursiveIterate(joinClause.value(), iterator, stop);\n        }\n        if (WCDB_SYNTAX_CHECK_OPTIONAL_VALID(condition)) {\n            recursiveIterate(condition.value(), iterator, stop);\n        }\n        if (!groups.empty()) {\n            listIterate(groups, iterator, stop);\n            if (WCDB_SYNTAX_CHECK_OPTIONAL_VALID(having)) {\n                recursiveIterate(having.value(), iterator, stop);\n            }\n        }\n        if (!windows.empty()) {\n            WCTIterateRemedialAssert(windows.size() == windowDefs.size());\n            listIterate(windowDefs, iterator, stop);\n        }\n        break;\n    case Switch::Values:\n        for (auto& values : valuesList) {\n            listIterate(values, iterator, stop);\n        }\n        break;\n    }\n    Identifier::iterate(iterator, false, stop);\n}\n\n} // namespace Syntax\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/syntax/identifier/SyntaxSelectCore.hpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"SyntaxIdentifier.hpp\"\n#include \"SyntaxJoinClause.hpp\"\n\nnamespace WCDB {\n\nnamespace Syntax {\n\nclass ResultColumn;\nclass TableOrSubquery;\n\nclass WCDB_API SelectCore final : public Identifier {\n#pragma mark - Lang\npublic:\n    ~SelectCore() override;\n\n    WCDB_SYNTAX_MAIN_UNION_ENUM(Select, Values, );\n    bool distinct = false;\n    std::list<ResultColumn> resultColumns;\n    std::list<TableOrSubquery> tableOrSubqueries;\n    Optional<JoinClause> joinClause;\n    Optional<Expression> condition;\n    std::list<Expression> groups;\n    Optional<Expression> having;\n    std::list<StringView> windows;\n    std::list<WindowDef> windowDefs;\n\n    std::list<std::list<Expression>> valuesList;\n\n#pragma mark - Identifier\npublic:\n    static constexpr const Type type = Type::SelectCore;\n    Type getType() const override final;\n    bool describle(std::ostream& stream) const override final;\n    void iterate(const Iterator& iterator, bool& stop) override final;\n};\n\n} // namespace Syntax\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/syntax/identifier/SyntaxTableConstraint.cpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"Syntax.h\"\n#include \"SyntaxAssertion.hpp\"\n#include \"SyntaxEnum.hpp\"\n\nnamespace WCDB {\n\nnamespace Syntax {\n\nTableConstraint::~TableConstraint() = default;\n\n#pragma mark - Identifier\nIdentifier::Type TableConstraint::getType() const\n{\n    return type;\n}\n\nbool TableConstraint::describle(std::ostream& stream) const\n{\n    if (!name.empty()) {\n        stream << \"CONSTRAINT \" << name << space;\n    }\n    switch (switcher) {\n    case Switch::PrimaryKey:\n        stream << \"PRIMARY KEY(\" << indexedColumns << \")\";\n        if (conflictValid()) {\n            stream << space << conflict;\n        }\n        break;\n    case Switch::Unique:\n        stream << \"UNIQUE(\" << indexedColumns << \")\";\n        if (conflictValid()) {\n            stream << space << conflict;\n        }\n        break;\n    case Switch::Check:\n        stream << \"CHECK(\" << expression.getOrCreate() << \")\";\n        break;\n    case Switch::ForeignKey:\n        stream << \"FOREIGN KEY(\" << columns << \") \" << foreignKeyClause.getOrCreate();\n        break;\n    }\n    return true;\n}\n\nvoid TableConstraint::iterate(const Iterator& iterator, bool& stop)\n{\n    Identifier::iterate(iterator, true, stop);\n    switch (switcher) {\n    case Switch::PrimaryKey:\n    case Switch::Unique:\n        listIterate(indexedColumns, iterator, stop);\n        break;\n    case Switch::Check:\n        recursiveIterate(expression.getOrCreate(), iterator, stop);\n        break;\n    case Switch::ForeignKey:\n        listIterate(columns, iterator, stop);\n        recursiveIterate(foreignKeyClause.getOrCreate(), iterator, stop);\n        break;\n    }\n    Identifier::iterate(iterator, false, stop);\n}\n\n} // namespace Syntax\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/syntax/identifier/SyntaxTableConstraint.hpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"SyntaxColumn.hpp\"\n#include \"SyntaxExpression.hpp\"\n#include \"SyntaxForeignKeyClause.hpp\"\n#include \"SyntaxIdentifier.hpp\"\n#include \"SyntaxIndexedColumn.hpp\"\n\nnamespace WCDB {\n\nnamespace Syntax {\n\nclass WCDB_API TableConstraint final : public Identifier {\n#pragma mark - Lang\npublic:\n    ~TableConstraint() override;\n\n    StringView name;\n    WCDB_SYNTAX_MAIN_UNION_ENUM(PrimaryKey, Unique, Check, ForeignKey, );\n\n    std::list<IndexedColumn> indexedColumns;\n    WCDB_SYNTAX_ENUM_UNION(Conflict, conflict);\n\n    Optional<Expression> expression;\n\n    std::list<Column> columns;\n    Optional<ForeignKeyClause> foreignKeyClause;\n\n#pragma mark - Identifier\npublic:\n    static constexpr const Type type = Type::TableConstraint;\n    Type getType() const override final;\n    bool describle(std::ostream& stream) const override final;\n    void iterate(const Iterator& iterator, bool& stop) override final;\n};\n\n} // namespace Syntax\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/syntax/identifier/SyntaxTableOrSubquery.cpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"Syntax.h\"\n#include \"SyntaxAssertion.hpp\"\n\nnamespace WCDB {\n\nnamespace Syntax {\n\nTableOrSubquery::~TableOrSubquery() = default;\n\n#pragma mark - Identifier\nIdentifier::Type TableOrSubquery::getType() const\n{\n    return type;\n}\n\nbool TableOrSubquery::describle(std::ostream& stream) const\n{\n    switch (switcher) {\n    case Switch::Table:\n        if (!schema.empty()) {\n            stream << schema << \".\";\n        }\n        stream << tableOrFunction;\n        if (!alias.empty()) {\n            stream << \" AS \" << alias;\n        }\n        switch (indexType) {\n        case IndexType::NotSet:\n            break;\n        case IndexType::Indexed:\n            stream << \" INDEXED BY \" << index;\n            break;\n        case IndexType::NotIndexed:\n            stream << \" NOT INDEXED\";\n            break;\n        }\n        break;\n    case Switch::Function:\n        if (!schema.empty()) {\n            stream << schema << \".\";\n        }\n        stream << tableOrFunction << \"(\" << expressions << \")\";\n        if (!alias.empty()) {\n            stream << \" AS \" << alias;\n        }\n        break;\n    case Switch::TableOrSubqueries:\n        stream << \"(\" << tableOrSubqueries << \")\";\n        break;\n    case Switch::JoinClause:\n        stream << \"(\" << *joinClause.get() << \")\";\n        break;\n    case Switch::Select:\n        stream << \"(\" << *select.get() << \")\";\n        if (!alias.empty()) {\n            stream << \" AS \" << alias;\n        }\n        break;\n    }\n    return true;\n}\n\nvoid TableOrSubquery::iterate(const Iterator& iterator, bool& stop)\n{\n    Identifier::iterate(iterator, true, stop);\n    switch (switcher) {\n    case Switch::Table:\n        recursiveIterate(schema, iterator, stop);\n        break;\n    case Switch::Function:\n        recursiveIterate(schema, iterator, stop);\n        listIterate(expressions, iterator, stop);\n        break;\n    case Switch::TableOrSubqueries:\n        listIterate(tableOrSubqueries, iterator, stop);\n        break;\n    case Switch::JoinClause:\n        recursiveIterate(*joinClause.get(), iterator, stop);\n        break;\n    case Switch::Select:\n        recursiveIterate(*select.get(), iterator, stop);\n        break;\n    }\n    Identifier::iterate(iterator, false, stop);\n}\n\n} // namespace Syntax\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/syntax/identifier/SyntaxTableOrSubquery.hpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"SyntaxIdentifier.hpp\"\n#include \"SyntaxJoinClause.hpp\"\n#include \"SyntaxSelectSTMT.hpp\"\n\nnamespace WCDB {\n\nnamespace Syntax {\n\nclass WCDB_API TableOrSubquery final : public Identifier {\n#pragma mark - Lang\npublic:\n    ~TableOrSubquery() override;\n\n    WCDB_SYNTAX_MAIN_UNION_ENUM(Table, Function, TableOrSubqueries, JoinClause, Select, );\n\n    Schema schema;\n    StringView tableOrFunction;\n    StringView alias;\n    enum class IndexType : signed char {\n        NotSet = 0,\n        Indexed,\n        NotIndexed,\n    } indexType\n    = IndexType::NotSet;\n    StringView index;\n    std::list<Expression> expressions;\n    std::list<TableOrSubquery> tableOrSubqueries;\n    Shadow<JoinClause> joinClause;\n    Shadow<SelectSTMT> select;\n\n#pragma mark - Identifier\npublic:\n    static constexpr const Type type = Type::TableOrSubquery;\n    Type getType() const override final;\n    bool describle(std::ostream& stream) const override final;\n    void iterate(const Iterator& iterator, bool& stop) override final;\n};\n\n} // namespace Syntax\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/syntax/identifier/SyntaxUpsertClause.cpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"Syntax.h\"\n#include \"SyntaxAssertion.hpp\"\n\nnamespace WCDB {\n\nnamespace Syntax {\n\nUpsertClause::~UpsertClause() = default;\n\n#pragma mark - Identifier\nIdentifier::Type UpsertClause::getType() const\n{\n    return type;\n}\n\nbool UpsertClause::describle(std::ostream& stream) const\n{\n    stream << \"ON CONFLICT\";\n    if (!indexedColumns.empty()) {\n        stream << \"(\" << indexedColumns << \")\";\n        if (condition != nullptr && condition.get()->isValid()) {\n            stream << \" WHERE \" << *condition.get();\n        }\n    }\n    stream << \" DO \";\n    switch (switcher) {\n    case Switch::Nothing:\n        stream << \"NOTHING\";\n        break;\n    case Switch::Update: {\n        WCTSyntaxRemedialAssert(columnsList.size() == expressions.size());\n        stream << \"UPDATE SET \";\n        auto columns = columnsList.begin();\n        auto expression = expressions.begin();\n        bool comma = false;\n        while (columns != columnsList.end() && expression != expressions.end()) {\n            if (comma) {\n                stream << \", \";\n            } else {\n                comma = true;\n            }\n            if (columns->size() > 1) {\n                stream << \"(\" << *columns << \")\";\n            } else {\n                stream << *columns;\n            }\n            stream << \" = \" << *expression;\n            ++columns;\n            ++expression;\n        }\n        if (updateCondition != nullptr && updateCondition.get()->isValid()) {\n            stream << \" WHERE \" << *updateCondition.get();\n        }\n    } break;\n    }\n    return true;\n}\n\nvoid UpsertClause::iterate(const Iterator& iterator, bool& stop)\n{\n    Identifier::iterate(iterator, true, stop);\n    if (!indexedColumns.empty()) {\n        listIterate(indexedColumns, iterator, stop);\n        if (condition != nullptr && condition.get()->isValid()) {\n            recursiveIterate(*condition.get(), iterator, stop);\n        }\n    }\n    if (!columnsList.empty()) {\n        WCTIterateRemedialAssert(columnsList.size() == expressions.size());\n        auto columns = columnsList.begin();\n        auto expression = expressions.begin();\n        while (columns != columnsList.end() && expression != expressions.end()) {\n            listIterate(*columns, iterator, stop);\n            expression->iterate(iterator, stop);\n            ++columns;\n            ++expression;\n        }\n        if (updateCondition != nullptr && updateCondition.get()->isValid()) {\n            recursiveIterate(*updateCondition.get(), iterator, stop);\n        }\n    }\n    Identifier::iterate(iterator, false, stop);\n}\n\n} // namespace Syntax\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/syntax/identifier/SyntaxUpsertClause.hpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"SyntaxIdentifier.hpp\"\n\nnamespace WCDB {\n\nnamespace Syntax {\n\nclass WCDB_API UpsertClause final : public Identifier {\n#pragma mark - Lang\npublic:\n    ~UpsertClause() override;\n\n    std::list<IndexedColumn> indexedColumns;\n    Shadow<Expression> condition;\n    WCDB_SYNTAX_MAIN_UNION_ENUM(Nothing, Update);\n    std::list<std::list<Column>> columnsList;\n    std::list<Expression> expressions;\n    Shadow<Expression> updateCondition;\n\n#pragma mark - Identifier\npublic:\n    static constexpr const Type type = Type::UpsertClause;\n    Type getType() const override final;\n    bool describle(std::ostream& stream) const override final;\n    void iterate(const Iterator& iterator, bool& stop) override final;\n};\n\n} // namespace Syntax\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/syntax/identifier/SyntaxWindowDef.cpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"Syntax.h\"\n#include \"SyntaxAssertion.hpp\"\n\nnamespace WCDB {\n\nnamespace Syntax {\n\nWindowDef::~WindowDef() = default;\n\nbool WindowDef::isValid() const\n{\n    return !expressions.empty() || !orderingTerms.empty()\n           || WCDB_SYNTAX_CHECK_OPTIONAL_VALID(frameSpec);\n}\n\n#pragma mark - Identifier\nIdentifier::Type WindowDef::getType() const\n{\n    return type;\n}\n\nbool WindowDef::describle(std::ostream& stream) const\n{\n    stream << \"(\";\n    bool extraSpace = false;\n    if (!expressions.empty()) {\n        extraSpace = true;\n        stream << \"PARTITION BY \" << expressions;\n    }\n    if (!orderingTerms.empty()) {\n        if (extraSpace) {\n            stream << space;\n        }\n        stream << \"ORDER BY \" << orderingTerms;\n    }\n    if (WCDB_SYNTAX_CHECK_OPTIONAL_VALID(frameSpec)) {\n        if (extraSpace) {\n            stream << space;\n        }\n        stream << frameSpec.value();\n    }\n    stream << \")\";\n    return true;\n}\n\nvoid WindowDef::iterate(const Iterator& iterator, bool& stop)\n{\n    Identifier::iterate(iterator, true, stop);\n    listIterate(expressions, iterator, stop);\n    listIterate(orderingTerms, iterator, stop);\n    if (WCDB_SYNTAX_CHECK_OPTIONAL_VALID(frameSpec)) {\n        recursiveIterate(frameSpec.value(), iterator, stop);\n    }\n    Identifier::iterate(iterator, false, stop);\n}\n\n} // namespace Syntax\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/syntax/identifier/SyntaxWindowDef.hpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"SyntaxFrameSpec.hpp\"\n#include \"SyntaxIdentifier.hpp\"\n\nnamespace WCDB {\n\nnamespace Syntax {\n\nclass Expression;\nclass OrderingTerm;\n\nclass WCDB_API WindowDef final : public Identifier {\n#pragma mark - Lang\npublic:\n    ~WindowDef() override;\n\n    std::list<Expression> expressions;\n    std::list<OrderingTerm> orderingTerms;\n    Optional<FrameSpec> frameSpec;\n\n    bool isValid() const override final;\n\n#pragma mark - Identifier\npublic:\n    static constexpr const Type type = Type::WindowDef;\n    Type getType() const override final;\n    bool describle(std::ostream& stream) const override final;\n    void iterate(const Iterator& iterator, bool& stop) override final;\n};\n\n} // namespace Syntax\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/syntax/stmt/SyntaxAlterTableSTMT.cpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"Syntax.h\"\n#include \"SyntaxAssertion.hpp\"\n\nnamespace WCDB {\n\nnamespace Syntax {\n\nAlterTableSTMT::~AlterTableSTMT() = default;\n\n#pragma mark - Identifier\nIdentifier::Type AlterTableSTMT::getType() const\n{\n    return type;\n}\n\nbool AlterTableSTMT::describle(std::ostream& stream) const\n{\n    stream << \"ALTER TABLE \";\n    if (!schema.empty()) {\n        stream << schema << \".\";\n    }\n    stream << table;\n    switch (switcher) {\n    case Switch::RenameTable:\n        stream << \" RENAME TO \" << newTable;\n        break;\n    case Switch::AddColumn:\n        stream << \" ADD COLUMN \" << columnDef;\n        break;\n    case Switch::RenameColumn:\n        stream << \" RENAME COLUMN \" << column << \" TO \" << newColumn;\n        break;\n    }\n    return true;\n}\n\nvoid AlterTableSTMT::iterate(const Iterator& iterator, bool& stop)\n{\n    Identifier::iterate(iterator, true, stop);\n    recursiveIterate(schema, iterator, stop);\n    switch (switcher) {\n    case Switch::RenameTable:\n        break;\n    case Switch::AddColumn:\n        recursiveIterate(columnDef, iterator, stop);\n        break;\n    case Switch::RenameColumn:\n        recursiveIterate(column, iterator, stop);\n        recursiveIterate(newColumn, iterator, stop);\n        break;\n    }\n    Identifier::iterate(iterator, false, stop);\n}\n\nbool AlterTableSTMT::isTargetingSameTable(const AlterTableSTMT& other) const\n{\n    return table == other.table && schema.isTargetingSameSchema(other.schema);\n}\n\n} // namespace Syntax\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/syntax/stmt/SyntaxAlterTableSTMT.hpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"SyntaxIdentifier.hpp\"\n\nnamespace WCDB {\n\nnamespace Syntax {\n\nclass WCDB_API AlterTableSTMT final : public Identifier {\n#pragma mark - Syntax\npublic:\n    ~AlterTableSTMT() override;\n\n    Schema schema;\n    StringView table;\n\n    WCDB_SYNTAX_MAIN_UNION_ENUM(RenameTable, RenameColumn, AddColumn, );\n    StringView newTable;\n    Column column;\n    Column newColumn;\n    ColumnDef columnDef;\n\n#pragma mark - Identifier\npublic:\n    static constexpr const Type type = Type::AlterTableSTMT;\n    Type getType() const override final;\n    bool describle(std::ostream& stream) const override final;\n    void iterate(const Iterator& iterator, bool& stop) override final;\n#pragma mark - Utility\npublic:\n    bool isTargetingSameTable(const AlterTableSTMT& other) const;\n};\n\n} // namespace Syntax\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/syntax/stmt/SyntaxAnalyzeSTMT.cpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"Syntax.h\"\n#include \"SyntaxAssertion.hpp\"\n\nnamespace WCDB {\n\nnamespace Syntax {\n\nAnalyzeSTMT::~AnalyzeSTMT() = default;\n\n#pragma mark - Identifier\nIdentifier::Type AnalyzeSTMT::getType() const\n{\n    return type;\n}\n\nbool AnalyzeSTMT::describle(std::ostream& stream) const\n{\n    stream << \"ANALYZE\";\n    switch (switcher) {\n    case Switch::SchemaOrTableOrIndex:\n        stream << space << schema;\n        if (!tableOrIndex.empty()) {\n            if (schema.isValid()) {\n                stream << \".\";\n            }\n            stream << tableOrIndex;\n        }\n        break;\n    default:\n        WCTAssert(switcher == Switch::All);\n        break;\n    }\n    return true;\n}\n\nvoid AnalyzeSTMT::iterate(const Iterator& iterator, bool& stop)\n{\n    Identifier::iterate(iterator, true, stop);\n    switch (switcher) {\n    case Switch::SchemaOrTableOrIndex:\n        recursiveIterate(schema, iterator, stop);\n        break;\n    default:\n        WCTAssert(switcher == Switch::All);\n        break;\n    }\n    Identifier::iterate(iterator, false, stop);\n}\n\n} // namespace Syntax\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/syntax/stmt/SyntaxAnalyzeSTMT.hpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"SyntaxIdentifier.hpp\"\n#include \"SyntaxSchema.hpp\"\n\nnamespace WCDB {\n\nnamespace Syntax {\n\nclass WCDB_API AnalyzeSTMT final : public Identifier {\n#pragma mark - Lang\npublic:\n    ~AnalyzeSTMT() override;\n\n    WCDB_SYNTAX_MAIN_UNION_ENUM(All, SchemaOrTableOrIndex);\n    Schema schema;\n    StringView tableOrIndex;\n\n#pragma mark - Identifier\npublic:\n    static constexpr const Type type = Type::AnalyzeSTMT;\n    Type getType() const override final;\n    bool describle(std::ostream& stream) const override final;\n    void iterate(const Iterator& iterator, bool& stop) override final;\n};\n\n} // namespace Syntax\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/syntax/stmt/SyntaxAttachSTMT.cpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"Syntax.h\"\n#include \"SyntaxAssertion.hpp\"\n\nnamespace WCDB {\n\nnamespace Syntax {\n\nAttachSTMT::~AttachSTMT() = default;\n\nbool AttachSTMT::isValid() const\n{\n    return expression.isValid();\n}\n\n#pragma mark - Identifier\nIdentifier::Type AttachSTMT::getType() const\n{\n    return type;\n}\n\nbool AttachSTMT::describle(std::ostream& stream) const\n{\n    stream << \"ATTACH \" << expression << \" AS \" << schema;\n    if (key.isValid()) {\n        stream << \" KEY \" << key;\n    }\n    return true;\n}\n\nvoid AttachSTMT::iterate(const Iterator& iterator, bool& stop)\n{\n    Identifier::iterate(iterator, true, stop);\n    recursiveIterate(expression, iterator, stop);\n    recursiveIterate(schema, iterator, stop);\n    recursiveIterate(key, iterator, stop);\n    Identifier::iterate(iterator, false, stop);\n}\n\n} // namespace Syntax\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/syntax/stmt/SyntaxAttachSTMT.hpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"SyntaxExpression.hpp\"\n#include \"SyntaxIdentifier.hpp\"\n#include \"SyntaxSchema.hpp\"\n\nnamespace WCDB {\n\nnamespace Syntax {\n\nclass WCDB_API AttachSTMT final : public Identifier {\n#pragma mark - Lang\npublic:\n    ~AttachSTMT() override;\n\n    Expression expression;\n    Schema schema;\n    Expression key;\n\n    bool isValid() const override final;\n\n#pragma mark - Identifier\npublic:\n    static constexpr const Type type = Type::AttachSTMT;\n    Type getType() const override final;\n    bool describle(std::ostream& stream) const override final;\n    void iterate(const Iterator& iterator, bool& stop) override final;\n};\n\n} // namespace Syntax\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/syntax/stmt/SyntaxBeginSTMT.cpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"Syntax.h\"\n#include \"SyntaxAssertion.hpp\"\n#include \"SyntaxEnum.hpp\"\n\nnamespace WCDB {\n\ntemplate<>\nconstexpr const char* Enum::description(const Syntax::BeginSTMT::Switch& switcher)\n{\n    switch (switcher) {\n    case Syntax::BeginSTMT::Switch::Deferred:\n        return \"DEFERRED\";\n    case Syntax::BeginSTMT::Switch::Immediate:\n        return \"IMMEDIATE\";\n    case Syntax::BeginSTMT::Switch::Exclusive:\n        return \"EXCLUSIVE\";\n    }\n}\n\nnamespace Syntax {\n\nBeginSTMT::~BeginSTMT() = default;\n\n#pragma mark - Identifier\nIdentifier::Type BeginSTMT::getType() const\n{\n    return type;\n}\n\nbool BeginSTMT::describle(std::ostream& stream) const\n{\n    stream << \"BEGIN \" << switcher;\n    return true;\n}\n\n} // namespace Syntax\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/syntax/stmt/SyntaxBeginSTMT.hpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"SyntaxIdentifier.hpp\"\n\nnamespace WCDB {\n\nnamespace Syntax {\n\nclass WCDB_API BeginSTMT final : public Identifier {\n#pragma mark - Lang\npublic:\n    ~BeginSTMT() override;\n\n    WCDB_SYNTAX_MAIN_UNION_ENUM(Deferred, Immediate, Exclusive, );\n\n#pragma mark - Identifier\npublic:\n    static constexpr const Type type = Type::BeginSTMT;\n    Type getType() const override final;\n    bool describle(std::ostream& stream) const override final;\n};\n\n} // namespace Syntax\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/syntax/stmt/SyntaxCommitSTMT.cpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"Syntax.h\"\n#include \"SyntaxAssertion.hpp\"\n\nnamespace WCDB {\n\nnamespace Syntax {\n\nCommitSTMT::~CommitSTMT() = default;\n\nbool CommitSTMT::isValid() const\n{\n    return inited;\n}\n\n#pragma mark - Identifier\nIdentifier::Type CommitSTMT::getType() const\n{\n    return type;\n}\n\nbool CommitSTMT::describle(std::ostream& stream) const\n{\n    stream << \"COMMIT\";\n    return true;\n}\n\n} // namespace Syntax\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/syntax/stmt/SyntaxCommitSTMT.hpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"SyntaxIdentifier.hpp\"\n\nnamespace WCDB {\n\nnamespace Syntax {\n\nclass WCDB_API CommitSTMT final : public Identifier {\n#pragma mark - Lang\npublic:\n    ~CommitSTMT() override;\n\n    bool inited = false;\n    bool isValid() const override final;\n\n#pragma mark - Identifier\npublic:\n    static constexpr const Type type = Type::CommitSTMT;\n    Type getType() const override final;\n    bool describle(std::ostream& stream) const override final;\n};\n\n} // namespace Syntax\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/syntax/stmt/SyntaxCreateIndexSTMT.cpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"Syntax.h\"\n#include \"SyntaxAssertion.hpp\"\n\nnamespace WCDB {\n\nnamespace Syntax {\n\nCreateIndexSTMT::~CreateIndexSTMT() = default;\n\nbool CreateIndexSTMT::isValid() const\n{\n    return !index.empty();\n}\n\n#pragma mark - Identifier\nIdentifier::Type CreateIndexSTMT::getType() const\n{\n    return type;\n}\n\nbool CreateIndexSTMT::describle(std::ostream& stream) const\n{\n    stream << \"CREATE \";\n    if (unique) {\n        stream << \"UNIQUE \";\n    }\n    stream << \"INDEX \";\n    if (ifNotExists) {\n        stream << \"IF NOT EXISTS \";\n    }\n    if (!schema.empty()) {\n        stream << schema << \".\";\n    }\n    stream << index << \" ON \" << table << \"(\" << indexedColumns << \")\";\n    if (WCDB_SYNTAX_CHECK_OPTIONAL_VALID(condition)) {\n        stream << \" WHERE \" << condition.value();\n    }\n    return true;\n}\n\nvoid CreateIndexSTMT::iterate(const Iterator& iterator, bool& stop)\n{\n    Identifier::iterate(iterator, true, stop);\n    recursiveIterate(schema, iterator, stop);\n    listIterate(indexedColumns, iterator, stop);\n    if (WCDB_SYNTAX_CHECK_OPTIONAL_VALID(condition)) {\n        recursiveIterate(condition.value(), iterator, stop);\n    }\n    Identifier::iterate(iterator, false, stop);\n}\n\n} // namespace Syntax\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/syntax/stmt/SyntaxCreateIndexSTMT.hpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"SyntaxIdentifier.hpp\"\n#include \"SyntaxSchema.hpp\"\n\nnamespace WCDB {\n\nnamespace Syntax {\n\nclass WCDB_API CreateIndexSTMT final : public Identifier {\n#pragma mark - Lang\npublic:\n    ~CreateIndexSTMT() override;\n\n    bool unique = false;\n    bool ifNotExists = false;\n    Schema schema;\n    StringView index;\n    StringView table;\n    std::list<IndexedColumn> indexedColumns;\n    Optional<Expression> condition;\n\n    bool isValid() const override final;\n\n#pragma mark - Identifier\npublic:\n    static constexpr const Type type = Type::CreateIndexSTMT;\n    Type getType() const override final;\n    bool describle(std::ostream& stream) const override final;\n    void iterate(const Iterator& iterator, bool& stop) override final;\n};\n\n} // namespace Syntax\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/syntax/stmt/SyntaxCreateTableSTMT.cpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"Syntax.h\"\n#include \"SyntaxAssertion.hpp\"\n\nnamespace WCDB {\n\nnamespace Syntax {\n\nCreateTableSTMT::~CreateTableSTMT() = default;\n\n#pragma mark - Identifier\nIdentifier::Type CreateTableSTMT::getType() const\n{\n    return type;\n}\n\nbool CreateTableSTMT::describle(std::ostream& stream) const\n{\n    stream << \"CREATE \";\n    if (temp) {\n        stream << \"TEMP \";\n    }\n    stream << \"TABLE \";\n    if (ifNotExists) {\n        stream << \"IF NOT EXISTS \";\n    }\n    if (!temp && !schema.empty()) {\n        stream << schema << \".\";\n    }\n    stream << table;\n    switch (switcher) {\n    case Switch::ColumnDefs:\n        stream << \"(\" << columnDefs;\n        if (!tableConstraints.empty()) {\n            stream << \", \" << tableConstraints;\n        }\n        stream << \")\";\n        if (withoutRowid) {\n            stream << \" WITHOUT ROWID\";\n        }\n        break;\n    case Switch::Select:\n        stream << \" AS \" << select.getOrCreate();\n        break;\n    }\n    return true;\n}\n\nvoid CreateTableSTMT::iterate(const Iterator& iterator, bool& stop)\n{\n    Identifier::iterate(iterator, true, stop);\n    recursiveIterate(schema, iterator, stop);\n    switch (switcher) {\n    case Switch::ColumnDefs:\n        listIterate(columnDefs, iterator, stop);\n        listIterate(tableConstraints, iterator, stop);\n        break;\n    case Switch::Select:\n        recursiveIterate(select.getOrCreate(), iterator, stop);\n        break;\n    }\n    Identifier::iterate(iterator, false, stop);\n}\n\n} // namespace Syntax\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/syntax/stmt/SyntaxCreateTableSTMT.hpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"SyntaxColumnDef.hpp\"\n#include \"SyntaxIdentifier.hpp\"\n#include \"SyntaxSchema.hpp\"\n#include \"SyntaxSelectSTMT.hpp\"\n#include \"SyntaxTableConstraint.hpp\"\n\nnamespace WCDB {\n\nnamespace Syntax {\n\nclass WCDB_API CreateTableSTMT final : public Identifier {\n#pragma mark - Lang\npublic:\n    ~CreateTableSTMT() override;\n\n    bool temp = false;\n    bool ifNotExists = false;\n    Schema schema;\n    StringView table;\n    WCDB_SYNTAX_MAIN_UNION_ENUM(ColumnDefs, Select, );\n    std::list<ColumnDef> columnDefs;\n    std::list<TableConstraint> tableConstraints;\n    bool withoutRowid = false;\n\n    Optional<SelectSTMT> select;\n\n#pragma mark - Identifier\npublic:\n    static constexpr const Type type = Type::CreateTableSTMT;\n    Type getType() const override final;\n    bool describle(std::ostream& stream) const override final;\n    void iterate(const Iterator& iterator, bool& stop) override final;\n};\n\n} // namespace Syntax\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/syntax/stmt/SyntaxCreateTriggerSTMT.cpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"Syntax.h\"\n#include \"SyntaxAssertion.hpp\"\n#include \"SyntaxEnum.hpp\"\n\nnamespace WCDB {\n\ntemplate<>\nconstexpr const char* Enum::description(const Syntax::CreateTriggerSTMT::Timing& timing)\n{\n    switch (timing) {\n    case Syntax::CreateTriggerSTMT::Timing::Before:\n        return \"BEFORE\";\n    case Syntax::CreateTriggerSTMT::Timing::After:\n        return \"AFTER\";\n    case Syntax::CreateTriggerSTMT::Timing::InsteadOf:\n        return \"INSTEAD OF\";\n    }\n}\n\ntemplate<>\nconstexpr const char* Enum::description(const Syntax::CreateTriggerSTMT::Event& event)\n{\n    switch (event) {\n    case Syntax::CreateTriggerSTMT::Event::Delete:\n        return \"DELETE\";\n    case Syntax::CreateTriggerSTMT::Event::Insert:\n        return \"INSERT\";\n    case Syntax::CreateTriggerSTMT::Event::Update:\n        return \"UPDATE\";\n    }\n}\n\nnamespace Syntax {\n\nCreateTriggerSTMT::~CreateTriggerSTMT() = default;\n\nbool CreateTriggerSTMT::isValid() const\n{\n    return !trigger.empty();\n}\n\n#pragma mark - Identifier\nIdentifier::Type CreateTriggerSTMT::getType() const\n{\n    return type;\n}\n\nbool CreateTriggerSTMT::describle(std::ostream& stream) const\n{\n    stream << \"CREATE \";\n    if (temp) {\n        stream << \"TEMP \";\n    }\n    stream << \"TRIGGER \";\n    if (ifNotExists) {\n        stream << \"IF NOT EXISTS \";\n    }\n    if (!temp && !schema.empty()) {\n        stream << schema << \".\";\n    }\n    stream << trigger << space;\n    if (specifiedTiming) {\n        stream << timing << space;\n    }\n    stream << event << space;\n    if (event == Event::Update && !columns.empty()) {\n        stream << \"OF \" << columns << space;\n    }\n    stream << \"ON \" << table << space;\n    if (forEachFow) {\n        stream << \"FOR EACH ROW \";\n    }\n    if (WCDB_SYNTAX_CHECK_OPTIONAL_VALID(condition)) {\n        stream << \"WHEN \" << condition.value() << space;\n    }\n    stream << \"BEGIN \";\n    auto insert = inserts.begin();\n    auto delete_ = deletes.begin();\n    auto update = updates.begin();\n    auto select = selects.begin();\n    for (const auto& stmt : stmts) {\n        switch (stmt) {\n        case STMT::Insert:\n            WCTSyntaxRemedialAssert(insert != inserts.end());\n            if (!insert->describle(stream, true)) {\n                return false;\n            }\n            ++insert;\n            break;\n        case STMT::Update:\n            WCTSyntaxRemedialAssert(update != updates.end());\n            if (!update->describle(stream, true)) {\n                return false;\n            }\n            ++update;\n            break;\n        case STMT::Delete:\n            WCTSyntaxRemedialAssert(delete_ != deletes.end());\n            if (!delete_->describle(stream, true)) {\n                return false;\n            }\n            ++delete_;\n            break;\n        case STMT::Select:\n            WCTSyntaxRemedialAssert(select != selects.end());\n            stream << *select;\n            ++select;\n            break;\n        }\n        stream << \"; \";\n    }\n    stream << \"END\";\n    return true;\n}\n\nvoid CreateTriggerSTMT::iterate(const Iterator& iterator, bool& stop)\n{\n    Identifier::iterate(iterator, true, stop);\n    recursiveIterate(schema, iterator, stop);\n    if (event == Event::Update) {\n        listIterate(columns, iterator, stop);\n    }\n    if (WCDB_SYNTAX_CHECK_OPTIONAL_VALID(condition)) {\n        recursiveIterate(condition.value(), iterator, stop);\n    }\n    auto insert = inserts.begin();\n    auto delete_ = deletes.begin();\n    auto update = updates.begin();\n    auto select = selects.begin();\n    for (const auto& stmt : stmts) {\n        switch (stmt) {\n        case STMT::Insert:\n            WCTIterateRemedialAssert(insert != inserts.end());\n            insert->iterate(iterator, stop);\n            ++insert;\n            break;\n        case STMT::Update:\n            WCTIterateRemedialAssert(update != updates.end());\n            update->iterate(iterator, stop);\n            ++update;\n            break;\n        case STMT::Delete:\n            WCTIterateRemedialAssert(delete_ != deletes.end());\n            delete_->iterate(iterator, stop);\n            ++delete_;\n            break;\n        case STMT::Select:\n            WCTIterateRemedialAssert(select != selects.end());\n            select->iterate(iterator, stop);\n            ++select;\n            break;\n        }\n    }\n    Identifier::iterate(iterator, false, stop);\n}\n\n} // namespace Syntax\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/syntax/stmt/SyntaxCreateTriggerSTMT.hpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"SyntaxIdentifier.hpp\"\n\nnamespace WCDB {\n\nnamespace Syntax {\n\nclass InsertSTMT;\nclass DeleteSTMT;\nclass UpdateSTMT;\nclass SelectSTMT;\n\nclass WCDB_API CreateTriggerSTMT final : public Identifier {\n#pragma mark - Lang\npublic:\n    ~CreateTriggerSTMT() override;\n\n    bool temp = false;\n    bool ifNotExists = false;\n    Schema schema;\n    StringView trigger;\n    enum class Timing : signed char {\n        Before = 1,\n        After,\n        InsteadOf,\n    } timing;\n    bool specifiedTiming = false;\n    enum class Event : signed char {\n        Delete = 1,\n        Insert,\n        Update,\n    } event;\n    std::list<Column> columns;\n    StringView table;\n    bool forEachFow = false;\n    Optional<Expression> condition;\n\n    enum class STMT : signed char {\n        Insert = 1,\n        Update,\n        Delete,\n        Select,\n    };\n    std::list<STMT> stmts;\n    std::list<InsertSTMT> inserts;\n    std::list<SelectSTMT> selects;\n    std::list<UpdateSTMT> updates;\n    std::list<DeleteSTMT> deletes;\n\n    bool isValid() const override final;\n\n#pragma mark - Identifier\npublic:\n    static constexpr const Type type = Type::CreateTriggerSTMT;\n    Type getType() const override final;\n    bool describle(std::ostream& stream) const override final;\n    void iterate(const Iterator& iterator, bool& stop) override final;\n};\n\n} // namespace Syntax\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/syntax/stmt/SyntaxCreateViewSTMT.cpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"Syntax.h\"\n#include \"SyntaxAssertion.hpp\"\n\nnamespace WCDB {\n\nnamespace Syntax {\n\nCreateViewSTMT::~CreateViewSTMT() = default;\n\nbool CreateViewSTMT::isValid() const\n{\n    return !view.empty();\n}\n\n#pragma mark - Identifier\nIdentifier::Type CreateViewSTMT::getType() const\n{\n    return type;\n}\n\nbool CreateViewSTMT::describle(std::ostream& stream) const\n{\n    stream << \"CREATE \";\n    if (temp) {\n        stream << \"TEMP \";\n    }\n    stream << \"VIEW \";\n    if (ifNotExists) {\n        stream << \"IF NOT EXISTS \";\n    }\n    if (!temp && !schema.empty()) {\n        stream << schema << \".\";\n    }\n    stream << view;\n    if (!columns.empty()) {\n        stream << \"(\" << columns << \")\";\n    }\n    stream << \" AS \" << select.getOrCreate();\n    return true;\n}\n\nvoid CreateViewSTMT::iterate(const Iterator& iterator, bool& stop)\n{\n    Identifier::iterate(iterator, true, stop);\n    recursiveIterate(schema, iterator, stop);\n    listIterate(columns, iterator, stop);\n    recursiveIterate(select.getOrCreate(), iterator, stop);\n    Identifier::iterate(iterator, false, stop);\n}\n\n} // namespace Syntax\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/syntax/stmt/SyntaxCreateViewSTMT.hpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"SyntaxIdentifier.hpp\"\n\nnamespace WCDB {\n\nnamespace Syntax {\n\nclass WCDB_API CreateViewSTMT final : public Identifier {\n#pragma mark - Lang\npublic:\n    ~CreateViewSTMT() override;\n\n    bool temp = false;\n    bool ifNotExists = false;\n    Schema schema;\n    StringView view;\n    std::list<Column> columns;\n    Optional<SelectSTMT> select;\n\n    bool isValid() const override final;\n\n#pragma mark - Identifier\npublic:\n    static constexpr const Type type = Type::CreateViewSTMT;\n    Type getType() const override final;\n    bool describle(std::ostream& stream) const override final;\n    void iterate(const Iterator& iterator, bool& stop) override final;\n};\n\n} // namespace Syntax\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/syntax/stmt/SyntaxCreateVirtualTableSTMT.cpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"FTSConst.h\"\n#include \"Syntax.h\"\n#include \"SyntaxAssertion.hpp\"\n\nnamespace WCDB {\n\nnamespace Syntax {\n\nCreateVirtualTableSTMT::~CreateVirtualTableSTMT() = default;\n\nbool CreateVirtualTableSTMT::isValid() const\n{\n    return !table.empty();\n}\n\n#pragma mark - Identifier\nIdentifier::Type CreateVirtualTableSTMT::getType() const\n{\n    return type;\n}\n\nbool CreateVirtualTableSTMT::describle(std::ostream& stream) const\n{\n    stream << \"CREATE VIRTUAL TABLE \";\n    if (ifNotExists) {\n        stream << \"IF NOT EXISTS \";\n    }\n    if (!schema.empty()) {\n        stream << schema << \".\";\n    }\n    stream << table << \" USING \" << module;\n    bool isFTS5 = module.caseInsensitiveEqual(Module::FTS5);\n    StringView tokenizerPrefix = tokenizerPreFix();\n    if (!arguments.empty()) {\n        stream << \"(\";\n        bool comma = false;\n        std::list<StringView> notIndexedColumn;\n        for (const auto& argument : arguments) {\n            if (comma) {\n                stream << \", \";\n            } else {\n                comma = true;\n            }\n            offset_t loc = UnsafeStringView::npos;\n            if (isFTS5 && (loc = argument.find(tokenizerPrefix)) == 0) {\n                stream << tokenizerPrefix << \"'\";\n                stream << UnsafeStringView(argument.data() + 11, argument.length() - 11);\n                stream << \"'\";\n            } else if (!isFTS5 && (loc = argument.find(\"UNINDEXED\")) != UnsafeStringView::npos) {\n                std::string columnDef = std::string(argument.data()).erase(loc - 1, 10);\n                offset_t spaceLoc = argument.find(\" \");\n                notIndexedColumn.push_back(std::string(argument.data(), spaceLoc));\n                stream << columnDef;\n            } else {\n                stream << argument;\n            }\n        }\n        if (!notIndexedColumn.empty()) {\n            for (const auto& column : notIndexedColumn) {\n                stream << \", notindexed=\";\n                stream << column;\n            }\n        }\n        stream << \")\";\n    }\n    return true;\n}\n\nvoid CreateVirtualTableSTMT::iterate(const Iterator& iterator, bool& stop)\n{\n    Identifier::iterate(iterator, true, stop);\n    recursiveIterate(schema, iterator, stop);\n    Identifier::iterate(iterator, false, stop);\n}\n\nStringView CreateVirtualTableSTMT::tokenizerPreFix()\n{\n    return StringView(\"tokenize = \");\n}\n\n} // namespace Syntax\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/syntax/stmt/SyntaxCreateVirtualTableSTMT.hpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"SyntaxIdentifier.hpp\"\n\nnamespace WCDB {\n\nnamespace Syntax {\n\nclass WCDB_API CreateVirtualTableSTMT final : public Identifier {\n#pragma mark - Lang\npublic:\n    ~CreateVirtualTableSTMT() override;\n\n    bool ifNotExists = false;\n    Schema schema;\n    StringView table;\n    StringView module;\n    std::list<StringView> arguments;\n\n    bool isValid() const override final;\n\n#pragma mark - Identifier\npublic:\n    static constexpr const Type type = Type::CreateVirtualTableSTMT;\n    Type getType() const override final;\n    bool describle(std::ostream& stream) const override final;\n    void iterate(const Iterator& iterator, bool& stop) override final;\n    static StringView tokenizerPreFix();\n};\n\n} // namespace Syntax\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/syntax/stmt/SyntaxDeleteSTMT.cpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"Syntax.h\"\n#include \"SyntaxAssertion.hpp\"\n\nnamespace WCDB {\n\nnamespace Syntax {\n\nDeleteSTMT::~DeleteSTMT() = default;\n\nbool DeleteSTMT::isValid() const\n{\n    return table.isValid();\n}\n\n#pragma mark - Identifier\nIdentifier::Type DeleteSTMT::getType() const\n{\n    return type;\n}\n\nbool DeleteSTMT::describle(std::ostream& stream) const\n{\n    return describle(stream, false);\n}\n\nbool DeleteSTMT::describle(std::ostream& stream, bool skipSchema) const\n{\n    if (!commonTableExpressions.empty()) {\n        stream << \"WITH \";\n        if (recursive) {\n            stream << \"RECURSIVE \";\n        }\n        stream << commonTableExpressions << space;\n    }\n    stream << \"DELETE FROM \";\n    if (!table.describle(stream, skipSchema)) {\n        return false;\n    }\n    if (WCDB_SYNTAX_CHECK_OPTIONAL_VALID(condition)) {\n        stream << \" WHERE \" << condition.value();\n    }\n    if (!orderingTerms.empty()) {\n        stream << \" ORDER BY \" << orderingTerms;\n    }\n    if (WCDB_SYNTAX_CHECK_OPTIONAL_VALID(limit)) {\n        stream << \" LIMIT \" << limit.value();\n        switch (limitParameterType) {\n        case LimitParameterType::NotSet:\n            break;\n        case LimitParameterType::Offset:\n            stream << \" OFFSET \" << limitParameter.getOrCreate();\n            break;\n        case LimitParameterType::End:\n            stream << \", \" << limitParameter.getOrCreate();\n            break;\n        }\n    }\n    return true;\n}\n\nvoid DeleteSTMT::iterate(const Iterator& iterator, bool& stop)\n{\n    Identifier::iterate(iterator, true, stop);\n    listIterate(commonTableExpressions, iterator, stop);\n    recursiveIterate(table, iterator, stop);\n    if (WCDB_SYNTAX_CHECK_OPTIONAL_VALID(condition)) {\n        recursiveIterate(condition.getOrCreate(), iterator, stop);\n    }\n    listIterate(orderingTerms, iterator, stop);\n    if (WCDB_SYNTAX_CHECK_OPTIONAL_VALID(limit)) {\n        recursiveIterate(limit.getOrCreate(), iterator, stop);\n        switch (limitParameterType) {\n        case LimitParameterType::NotSet:\n            break;\n        case LimitParameterType::Offset:\n        case LimitParameterType::End:\n            recursiveIterate(limitParameter.getOrCreate(), iterator, stop);\n            break;\n        }\n    }\n    Identifier::iterate(iterator, false, stop);\n}\n\n} // namespace Syntax\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/syntax/stmt/SyntaxDeleteSTMT.hpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"SyntaxIdentifier.hpp\"\n\nnamespace WCDB {\n\nnamespace Syntax {\n\nclass WCDB_API DeleteSTMT final : public Identifier {\n#pragma mark - Lang\npublic:\n    ~DeleteSTMT() override;\n\n    bool recursive = false;\n    std::list<CommonTableExpression> commonTableExpressions;\n    QualifiedTableName table;\n    Optional<Expression> condition;\n    std::list<OrderingTerm> orderingTerms;\n    Optional<Expression> limit;\n    LimitParameterType limitParameterType = LimitParameterType::NotSet;\n    Optional<Expression> limitParameter;\n\n    bool isValid() const override final;\n\n#pragma mark - Identifier\npublic:\n    static constexpr const Type type = Type::DeleteSTMT;\n    Type getType() const override final;\n    bool describle(std::ostream& stream) const override final;\n    bool describle(std::ostream& stream, bool skipSchema) const;\n    void iterate(const Iterator& iterator, bool& stop) override final;\n};\n\n} // namespace Syntax\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/syntax/stmt/SyntaxDetachSTMT.cpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"Syntax.h\"\n#include \"SyntaxAssertion.hpp\"\n\nnamespace WCDB {\n\nnamespace Syntax {\n\nDetachSTMT::~DetachSTMT() = default;\n\nbool DetachSTMT::isValid() const\n{\n    return schema.isValid() && !schema.isMain();\n}\n\n#pragma mark - Identifier\nIdentifier::Type DetachSTMT::getType() const\n{\n    return type;\n}\n\nbool DetachSTMT::describle(std::ostream& stream) const\n{\n    stream << \"DETACH \" << schema;\n    return true;\n}\n\nvoid DetachSTMT::iterate(const Iterator& iterator, bool& stop)\n{\n    Identifier::iterate(iterator, true, stop);\n    recursiveIterate(schema, iterator, stop);\n    Identifier::iterate(iterator, false, stop);\n}\n\n} // namespace Syntax\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/syntax/stmt/SyntaxDetachSTMT.hpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"SyntaxIdentifier.hpp\"\n\nnamespace WCDB {\n\nnamespace Syntax {\n\nclass WCDB_API DetachSTMT final : public Identifier {\n#pragma mark - Lang\npublic:\n    ~DetachSTMT() override;\n\n    Schema schema;\n\n    bool isValid() const override final;\n\n#pragma mark - Identifier\npublic:\n    static constexpr const Type type = Type::DetachSTMT;\n    Type getType() const override final;\n    bool describle(std::ostream& stream) const override final;\n    void iterate(const Iterator& iterator, bool& stop) override final;\n};\n\n} // namespace Syntax\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/syntax/stmt/SyntaxDropIndexSTMT.cpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"Syntax.h\"\n#include \"SyntaxAssertion.hpp\"\n\nnamespace WCDB {\n\nnamespace Syntax {\n\nDropIndexSTMT::~DropIndexSTMT() = default;\n\nbool DropIndexSTMT::isValid() const\n{\n    return !index.empty();\n}\n\n#pragma mark - Identifier\nIdentifier::Type DropIndexSTMT::getType() const\n{\n    return type;\n}\n\nbool DropIndexSTMT::describle(std::ostream& stream) const\n{\n    stream << \"DROP INDEX \";\n    if (ifExists) {\n        stream << \"IF EXISTS \";\n    }\n    if (!schema.empty()) {\n        stream << schema << \".\";\n    }\n    stream << index;\n    return true;\n}\n\nvoid DropIndexSTMT::iterate(const Iterator& iterator, bool& stop)\n{\n    Identifier::iterate(iterator, true, stop);\n    recursiveIterate(schema, iterator, stop);\n    Identifier::iterate(iterator, false, stop);\n}\n\n} // namespace Syntax\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/syntax/stmt/SyntaxDropIndexSTMT.hpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"SyntaxIdentifier.hpp\"\n\nnamespace WCDB {\n\nnamespace Syntax {\n\nclass WCDB_API DropIndexSTMT final : public Identifier {\n#pragma mark - Lang\npublic:\n    ~DropIndexSTMT() override;\n\n    bool ifExists = false;\n    Schema schema;\n    StringView index;\n\n    bool isValid() const override final;\n\n#pragma mark - Identifier\npublic:\n    static constexpr const Type type = Type::DropIndexSTMT;\n    Type getType() const override final;\n    bool describle(std::ostream& stream) const override final;\n    void iterate(const Iterator& iterator, bool& stop) override final;\n};\n\n} // namespace Syntax\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/syntax/stmt/SyntaxDropTableSTMT.cpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"Syntax.h\"\n#include \"SyntaxAssertion.hpp\"\n\nnamespace WCDB {\n\nnamespace Syntax {\n\nDropTableSTMT::~DropTableSTMT() = default;\n\nbool DropTableSTMT::isValid() const\n{\n    return !table.empty();\n}\n\n#pragma mark - Identifier\nIdentifier::Type DropTableSTMT::getType() const\n{\n    return type;\n}\n\nbool DropTableSTMT::describle(std::ostream& stream) const\n{\n    stream << \"DROP TABLE \";\n    if (ifExists) {\n        stream << \"IF EXISTS \";\n    }\n    if (!schema.empty()) {\n        stream << schema << \".\";\n    }\n    stream << table;\n    return true;\n}\n\nvoid DropTableSTMT::iterate(const Iterator& iterator, bool& stop)\n{\n    Identifier::iterate(iterator, true, stop);\n    recursiveIterate(schema, iterator, stop);\n    Identifier::iterate(iterator, false, stop);\n}\n\n#pragma mark - Utility\nbool DropTableSTMT::isTargetingSameTable(const DropTableSTMT& other) const\n{\n    return table == other.table && schema.isTargetingSameSchema(other.schema);\n}\n\n} // namespace Syntax\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/syntax/stmt/SyntaxDropTableSTMT.hpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"SyntaxIdentifier.hpp\"\n\nnamespace WCDB {\n\nnamespace Syntax {\n\nclass WCDB_API DropTableSTMT final : public Identifier {\n#pragma mark - Lang\npublic:\n    ~DropTableSTMT() override;\n\n    bool ifExists = false;\n    Schema schema;\n    StringView table;\n\n    bool isValid() const override final;\n\n#pragma mark - Identifier\npublic:\n    static constexpr const Type type = Type::DropTableSTMT;\n    Type getType() const override final;\n    bool describle(std::ostream& stream) const override final;\n    void iterate(const Iterator& iterator, bool& stop) override final;\n\n#pragma mark - Utility\npublic:\n    bool isTargetingSameTable(const DropTableSTMT& other) const;\n};\n\n} // namespace Syntax\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/syntax/stmt/SyntaxDropTriggerSTMT.cpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"Syntax.h\"\n#include \"SyntaxAssertion.hpp\"\n\nnamespace WCDB {\n\nnamespace Syntax {\n\nDropTriggerSTMT::~DropTriggerSTMT() = default;\n\nbool DropTriggerSTMT::isValid() const\n{\n    return !trigger.empty();\n}\n\n#pragma mark - Identifier\nIdentifier::Type DropTriggerSTMT::getType() const\n{\n    return type;\n}\n\nbool DropTriggerSTMT::describle(std::ostream& stream) const\n{\n    stream << \"DROP TRIGGER \";\n    if (ifExists) {\n        stream << \"IF EXISTS \";\n    }\n    if (!schema.empty()) {\n        stream << schema << \".\";\n    }\n    stream << trigger;\n    return true;\n}\n\nvoid DropTriggerSTMT::iterate(const Iterator& iterator, bool& stop)\n{\n    Identifier::iterate(iterator, true, stop);\n    recursiveIterate(schema, iterator, stop);\n    Identifier::iterate(iterator, false, stop);\n}\n\n} // namespace Syntax\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/syntax/stmt/SyntaxDropTriggerSTMT.hpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"SyntaxIdentifier.hpp\"\n\nnamespace WCDB {\n\nnamespace Syntax {\n\nclass WCDB_API DropTriggerSTMT final : public Identifier {\n#pragma mark - Lang\npublic:\n    ~DropTriggerSTMT() override;\n\n    bool ifExists = false;\n    Schema schema;\n    StringView trigger;\n\n    bool isValid() const override final;\n\n#pragma mark - Identifier\npublic:\n    static constexpr const Type type = Type::DropTriggerSTMT;\n    Type getType() const override final;\n    bool describle(std::ostream& stream) const override final;\n    void iterate(const Iterator& iterator, bool& stop) override final;\n};\n\n} // namespace Syntax\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/syntax/stmt/SyntaxDropViewSTMT.cpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"Syntax.h\"\n#include \"SyntaxAssertion.hpp\"\n\nnamespace WCDB {\n\nnamespace Syntax {\n\nDropViewSTMT::~DropViewSTMT() = default;\n\nbool DropViewSTMT::isValid() const\n{\n    return !view.empty();\n}\n\n#pragma mark - Identifier\nIdentifier::Type DropViewSTMT::getType() const\n{\n    return type;\n}\n\nbool DropViewSTMT::describle(std::ostream& stream) const\n{\n    stream << \"DROP VIEW \";\n    if (ifExists) {\n        stream << \"IF EXISTS \";\n    }\n    if (!schema.empty()) {\n        stream << schema << \".\";\n    }\n    stream << view;\n    return true;\n}\n\nvoid DropViewSTMT::iterate(const Iterator& iterator, bool& stop)\n{\n    Identifier::iterate(iterator, true, stop);\n    recursiveIterate(schema, iterator, stop);\n    Identifier::iterate(iterator, false, stop);\n}\n\n} // namespace Syntax\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/syntax/stmt/SyntaxDropViewSTMT.hpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"SyntaxIdentifier.hpp\"\n\nnamespace WCDB {\n\nnamespace Syntax {\n\nclass WCDB_API DropViewSTMT final : public Identifier {\n#pragma mark - Lang\npublic:\n    ~DropViewSTMT() override;\n\n    bool ifExists = false;\n    Schema schema;\n    StringView view;\n\n    bool isValid() const override final;\n\n#pragma mark - Identifier\npublic:\n    static constexpr const Type type = Type::DropViewSTMT;\n    Type getType() const override final;\n    bool describle(std::ostream& stream) const override final;\n    void iterate(const Iterator& iterator, bool& stop) override final;\n};\n\n} // namespace Syntax\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/syntax/stmt/SyntaxExplainSTMT.cpp",
    "content": "//\n// Created by sanhuazhang on 2019/08/30\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"Syntax.h\"\n#include \"SyntaxAssertion.hpp\"\n\nnamespace WCDB {\n\nnamespace Syntax {\n\nExplainSTMT::~ExplainSTMT() = default;\n\nbool ExplainSTMT::isValid() const\n{\n    return stmt != nullptr;\n}\n\n#pragma mark - Identifier\nIdentifier::Type ExplainSTMT::getType() const\n{\n    return type;\n}\n\nbool ExplainSTMT::describle(std::ostream& stream) const\n{\n    stream << \"EXPLAIN \";\n    if (queryPlan) {\n        stream << \"QUERY PLAN \";\n    }\n    stream << *stmt.get();\n    return true;\n}\n\nvoid ExplainSTMT::iterate(const Iterator& iterator, bool& stop)\n{\n    Identifier::iterate(iterator, true, stop);\n    recursiveIterate(*stmt.get(), iterator, stop);\n    Identifier::iterate(iterator, false, stop);\n}\n\n} // namespace Syntax\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/syntax/stmt/SyntaxExplainSTMT.hpp",
    "content": "//\n// Created by sanhuazhang on 2019/08/30\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"SyntaxIdentifier.hpp\"\n\nnamespace WCDB {\n\nnamespace Syntax {\n\nclass WCDB_API ExplainSTMT final : public Identifier {\n#pragma mark - Lang\npublic:\n    ~ExplainSTMT() override;\n\n    bool queryPlan = false;\n    Shadow<Identifier> stmt;\n\n    bool isValid() const override final;\n\n#pragma mark - Identifier\npublic:\n    static constexpr const Type type = Type::ExplainSTMT;\n    Type getType() const override final;\n    bool describle(std::ostream& stream) const override final;\n    void iterate(const Iterator& iterator, bool& stop) override final;\n};\n\n} // namespace Syntax\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/syntax/stmt/SyntaxInsertSTMT.cpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"Syntax.h\"\n#include \"SyntaxAssertion.hpp\"\n#include \"SyntaxEnum.hpp\"\n\nnamespace WCDB {\n\nnamespace Syntax {\n\nInsertSTMT::~InsertSTMT() = default;\n\n#pragma mark - Identifier\nIdentifier::Type InsertSTMT::getType() const\n{\n    return type;\n}\n\nbool InsertSTMT::describle(std::ostream& stream, bool skipSchema) const\n{\n    if (!commonTableExpressions.empty()) {\n        stream << \"WITH \";\n        if (recursive) {\n            stream << \"RECURSIVE \";\n        }\n        stream << commonTableExpressions << space;\n    }\n    stream << \"INSERT \";\n    if (conflictActionValid()) {\n        stream << conflictAction << space;\n    }\n    stream << \"INTO \";\n    if (!skipSchema && !schema.empty()) {\n        stream << schema << \".\";\n    }\n    stream << table;\n    if (!alias.empty()) {\n        stream << \" AS \" << alias;\n    }\n    if (!columns.empty()) {\n        stream << \"(\" << columns << \")\";\n    }\n    stream << space;\n    switch (switcher) {\n    case Switch::Values: {\n        stream << \"VALUES\";\n        bool comma = false;\n        for (const auto& expressionsValue : expressionsValues) {\n            if (comma) {\n                stream << \", \";\n            } else {\n                comma = true;\n            }\n            stream << \"(\" << expressionsValue << \")\";\n        }\n        break;\n    }\n    case Switch::Select:\n        stream << select.getOrCreate();\n        break;\n    case Switch::Default:\n        stream << \"DEFAULT VALUES\";\n        break;\n    }\n    if (WCDB_SYNTAX_CHECK_OPTIONAL_VALID(upsertClause)) {\n        stream << space << upsertClause.value();\n    }\n    return true;\n}\n\nbool InsertSTMT::describle(std::ostream& stream) const\n{\n    return describle(stream, false);\n}\n\nvoid InsertSTMT::iterate(const Iterator& iterator, bool& stop)\n{\n    Identifier::iterate(iterator, true, stop);\n    listIterate(commonTableExpressions, iterator, stop);\n    recursiveIterate(schema, iterator, stop);\n    listIterate(columns, iterator, stop);\n    switch (switcher) {\n    case Switch::Values: {\n        for (auto& expressionsValue : expressionsValues) {\n            listIterate(expressionsValue, iterator, stop);\n        }\n        break;\n    }\n    case Switch::Select:\n        recursiveIterate(select.getOrCreate(), iterator, stop);\n        break;\n    case Switch::Default:\n        break;\n    }\n    if (WCDB_SYNTAX_CHECK_OPTIONAL_VALID(upsertClause)) {\n        recursiveIterate(upsertClause.value(), iterator, stop);\n    }\n    Identifier::iterate(iterator, false, stop);\n}\n\n#pragma mark - Utility\nbool InsertSTMT::isMultiWrite() const\n{\n    if (switcher == Switch::Values && expressionsValues.size() > 1) {\n        return true;\n    }\n    if (switcher == Switch::Select) {\n        if (!select.hasValue()) {\n            return true;\n        }\n        auto& selectValue = select.value();\n        if (!selectValue.limit.hasValue()\n            || selectValue.limitParameterType == LimitParameterType::End\n            || selectValue.limit.value().switcher != Expression::Switch::LiteralValue) {\n            return true;\n        }\n        auto& literalValue = selectValue.limit.value().literalValue();\n        if (!literalValue.isValid() || literalValue.switcher != LiteralValue::Switch::Integer) {\n            return true;\n        }\n        return literalValue.integerValue != 1;\n    }\n    return false;\n}\n\nbool InsertSTMT::isTargetingSameTable(const InsertSTMT& other) const\n{\n    return table == other.table && schema.isTargetingSameSchema(other.schema);\n}\n\n} // namespace Syntax\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/syntax/stmt/SyntaxInsertSTMT.hpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"SyntaxIdentifier.hpp\"\n\nnamespace WCDB {\n\nnamespace Syntax {\n\nclass WCDB_API InsertSTMT final : public Identifier {\n#pragma mark - Lang\npublic:\n    ~InsertSTMT() override;\n\n    bool recursive = false;\n    std::list<CommonTableExpression> commonTableExpressions;\n\n    WCDB_SYNTAX_ENUM_UNION(ConflictAction, conflictAction);\n    Schema schema;\n    StringView table;\n    StringView alias;\n    std::list<Column> columns;\n\n    WCDB_SYNTAX_MAIN_UNION_ENUM(Values, Select, Default);\n    std::list<std::list<Expression>> expressionsValues;\n    Optional<SelectSTMT> select;\n\n    Optional<UpsertClause> upsertClause;\n\n#pragma mark - Identifier\npublic:\n    static constexpr const Type type = Type::InsertSTMT;\n    Type getType() const override final;\n    bool describle(std::ostream& stream) const override final;\n    bool describle(std::ostream& stream, bool skipSchema) const;\n    void iterate(const Iterator& iterator, bool& stop) override final;\n\n#pragma mark - Utility\npublic:\n    bool isMultiWrite() const;\n    bool isTargetingSameTable(const InsertSTMT& other) const;\n};\n\n} // namespace Syntax\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/syntax/stmt/SyntaxPragmaSTMT.cpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"Syntax.h\"\n#include \"SyntaxAssertion.hpp\"\n\nnamespace WCDB {\n\nnamespace Syntax {\n\nPragmaSTMT::~PragmaSTMT() = default;\n\nbool PragmaSTMT::isValid() const\n{\n    return pragma.isValid();\n}\n\n#pragma mark - Identifier\nIdentifier::Type PragmaSTMT::getType() const\n{\n    return type;\n}\n\nbool PragmaSTMT::describle(std::ostream& stream) const\n{\n    stream << \"PRAGMA \";\n    if (!schema.empty()) {\n        stream << schema << \".\";\n    }\n    stream << pragma;\n    switch (switcher) {\n    case Switch::NotSet:\n        break;\n    case Switch::To:\n        stream << \" = \" << value;\n        break;\n    case Switch::With:\n        stream << \"(\" << value << \")\";\n        break;\n    }\n    return true;\n}\n\nvoid PragmaSTMT::iterate(const Iterator& iterator, bool& stop)\n{\n    Identifier::iterate(iterator, true, stop);\n    recursiveIterate(schema, iterator, stop);\n    recursiveIterate(pragma, iterator, stop);\n    switch (switcher) {\n    case Switch::NotSet:\n        break;\n    case Switch::To:\n    case Switch::With:\n        recursiveIterate(value, iterator, stop);\n        break;\n    }\n    Identifier::iterate(iterator, false, stop);\n}\n\n} // namespace Syntax\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/syntax/stmt/SyntaxPragmaSTMT.hpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"SyntaxIdentifier.hpp\"\n\nnamespace WCDB {\n\nnamespace Syntax {\n\nclass WCDB_API PragmaSTMT final : public Identifier {\n#pragma mark - Lang\npublic:\n    ~PragmaSTMT() override;\n\n    Schema schema;\n    Pragma pragma;\n    enum class Switch : signed char {\n        NotSet = 0,\n        To,\n        With,\n    } switcher\n    = Switch::NotSet;\n    LiteralValue value;\n\n    bool isValid() const override final;\n\n#pragma mark - Identifier\npublic:\n    static constexpr const Type type = Type::PragmaSTMT;\n    Type getType() const override final;\n    bool describle(std::ostream& stream) const override final;\n    void iterate(const Iterator& iterator, bool& stop) override final;\n};\n\n} // namespace Syntax\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/syntax/stmt/SyntaxReindexSTMT.cpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"Syntax.h\"\n#include \"SyntaxAssertion.hpp\"\n\nnamespace WCDB {\n\nnamespace Syntax {\n\nReindexSTMT::~ReindexSTMT() = default;\n\n#pragma mark - Identifier\nIdentifier::Type ReindexSTMT::getType() const\n{\n    return type;\n}\n\nbool ReindexSTMT::describle(std::ostream& stream) const\n{\n    stream << \"REINDEX\";\n    switch (switcher) {\n    case Switch::NotSet:\n        break;\n    case Switch::Collation:\n        stream << space << collationOrTableOrIndex;\n        break;\n    case Switch::TableOrIndex:\n        stream << space;\n        if (!schema.empty()) {\n            stream << schema << \".\";\n        }\n        stream << collationOrTableOrIndex;\n        break;\n    }\n    return true;\n}\n\nvoid ReindexSTMT::iterate(const Iterator& iterator, bool& stop)\n{\n    Identifier::iterate(iterator, true, stop);\n    switch (switcher) {\n    case Switch::NotSet:\n    case Switch::Collation:\n        break;\n    case Switch::TableOrIndex:\n        recursiveIterate(schema, iterator, stop);\n        break;\n    }\n    Identifier::iterate(iterator, false, stop);\n}\n\n} // namespace Syntax\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/syntax/stmt/SyntaxReindexSTMT.hpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"SyntaxIdentifier.hpp\"\n\nnamespace WCDB {\n\nnamespace Syntax {\n\nclass WCDB_API ReindexSTMT final : public Identifier {\n#pragma mark - Lang\npublic:\n    ~ReindexSTMT() override;\n\n    WCDB_SYNTAX_MAIN_UNION_ENUM(NotSet, Collation, TableOrIndex, );\n    StringView collationOrTableOrIndex;\n    Schema schema;\n\n#pragma mark - Identifier\npublic:\n    static constexpr const Type type = Type::ReindexSTMT;\n    Type getType() const override final;\n    bool describle(std::ostream& stream) const override final;\n    void iterate(const Iterator& iterator, bool& stop) override final;\n};\n\n} // namespace Syntax\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/syntax/stmt/SyntaxReleaseSTMT.cpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"Syntax.h\"\n#include \"SyntaxAssertion.hpp\"\n\nnamespace WCDB {\n\nnamespace Syntax {\n\nReleaseSTMT::~ReleaseSTMT() = default;\n\nbool ReleaseSTMT::isValid() const\n{\n    return !savepoint.empty();\n}\n\n#pragma mark - Identifier\nIdentifier::Type ReleaseSTMT::getType() const\n{\n    return type;\n}\n\nbool ReleaseSTMT::describle(std::ostream& stream) const\n{\n    stream << \"RELEASE \" << savepoint;\n    return true;\n}\n\n} // namespace Syntax\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/syntax/stmt/SyntaxReleaseSTMT.hpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"SyntaxIdentifier.hpp\"\n\nnamespace WCDB {\n\nnamespace Syntax {\n\nclass WCDB_API ReleaseSTMT final : public Identifier {\n#pragma mark - Lang\npublic:\n    ~ReleaseSTMT() override;\n\n    StringView savepoint;\n\n    bool isValid() const override final;\n\n#pragma mark - Identifier\npublic:\n    static constexpr const Type type = Type::ReleaseSTMT;\n    Type getType() const override final;\n    bool describle(std::ostream& stream) const override final;\n};\n\n} // namespace Syntax\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/syntax/stmt/SyntaxRollbackSTMT.cpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"Syntax.h\"\n#include \"SyntaxAssertion.hpp\"\n\nnamespace WCDB {\n\nnamespace Syntax {\n\nRollbackSTMT::~RollbackSTMT() = default;\n\n#pragma mark - Identifier\nIdentifier::Type RollbackSTMT::getType() const\n{\n    return type;\n}\n\nbool RollbackSTMT::describle(std::ostream& stream) const\n{\n    stream << \"ROLLBACK\";\n    switch (switcher) {\n    case Switch::Transaction:\n        break;\n    case Switch::Savepoint:\n        stream << \" TO \" << savepoint;\n        break;\n    }\n    return true;\n}\n\n} // namespace Syntax\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/syntax/stmt/SyntaxRollbackSTMT.hpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"SyntaxIdentifier.hpp\"\n\nnamespace WCDB {\n\nnamespace Syntax {\n\nclass WCDB_API RollbackSTMT final : public Identifier {\n#pragma mark - Lang\npublic:\n    ~RollbackSTMT() override;\n\n    WCDB_SYNTAX_MAIN_UNION_ENUM(Transaction, Savepoint);\n    StringView savepoint;\n\n#pragma mark - Identifier\npublic:\n    static constexpr const Type type = Type::RollbackSTMT;\n    Type getType() const override final;\n    bool describle(std::ostream& stream) const override final;\n};\n\n} // namespace Syntax\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/syntax/stmt/SyntaxSavepointSTMT.cpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"Syntax.h\"\n#include \"SyntaxAssertion.hpp\"\n\nnamespace WCDB {\n\nnamespace Syntax {\n\nSavepointSTMT::~SavepointSTMT() = default;\n\nbool SavepointSTMT::isValid() const\n{\n    return !savepoint.empty();\n}\n\n#pragma mark - Identifier\nIdentifier::Type SavepointSTMT::getType() const\n{\n    return type;\n}\n\nbool SavepointSTMT::describle(std::ostream& stream) const\n{\n    stream << \"SAVEPOINT \" << savepoint;\n    return true;\n}\n\n} // namespace Syntax\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/syntax/stmt/SyntaxSavepointSTMT.hpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"SyntaxIdentifier.hpp\"\n\nnamespace WCDB {\n\nnamespace Syntax {\n\nclass WCDB_API SavepointSTMT final : public Identifier {\n#pragma mark - Lang\npublic:\n    ~SavepointSTMT() override;\n\n    StringView savepoint;\n\n    bool isValid() const override final;\n\n#pragma mark - Identifier\npublic:\n    static constexpr const Type type = Type::SavepointSTMT;\n    Type getType() const override final;\n    bool describle(std::ostream& stream) const override final;\n};\n\n} // namespace Syntax\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/syntax/stmt/SyntaxSelectSTMT.cpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"Syntax.h\"\n#include \"SyntaxAssertion.hpp\"\n#include \"SyntaxEnum.hpp\"\n\nnamespace WCDB {\n\nnamespace Syntax {\n\nSelectSTMT::~SelectSTMT() = default;\n\nbool SelectSTMT::isValid() const\n{\n    return WCDB_SYNTAX_CHECK_OPTIONAL_VALID(select);\n}\n\n#pragma mark - Identifier\nIdentifier::Type SelectSTMT::getType() const\n{\n    return type;\n}\n\nbool SelectSTMT::describle(std::ostream& stream) const\n{\n    if (!commonTableExpressions.empty()) {\n        stream << \"WITH \";\n        if (recursive) {\n            stream << \"RECURSIVE \";\n        }\n        stream << commonTableExpressions << space;\n    }\n    stream << select.getOrCreate();\n    if (!cores.empty()) {\n        WCTSyntaxRemedialAssert(cores.size() == compoundOperators.size());\n        auto core = cores.begin();\n        auto compoundOperator = compoundOperators.begin();\n        while (core != cores.end() && compoundOperator != compoundOperators.end()) {\n            stream << space << *compoundOperator << space << *core;\n            ++compoundOperator;\n            ++core;\n        }\n    }\n    if (!orderingTerms.empty()) {\n        stream << \" ORDER BY \" << orderingTerms;\n    }\n    if (WCDB_SYNTAX_CHECK_OPTIONAL_VALID(limit)) {\n        stream << \" LIMIT \" << limit.value();\n        switch (limitParameterType) {\n        case LimitParameterType::NotSet:\n            break;\n        case LimitParameterType::Offset:\n            stream << \" OFFSET \" << limitParameter.getOrCreate();\n            break;\n        case LimitParameterType::End:\n            stream << \", \" << limitParameter.getOrCreate();\n            break;\n        }\n    }\n    return true;\n}\n\nvoid SelectSTMT::iterate(const Iterator& iterator, bool& stop)\n{\n    Identifier::iterate(iterator, true, stop);\n    listIterate(commonTableExpressions, iterator, stop);\n    recursiveIterate(select.getOrCreate(), iterator, stop);\n    listIterate(cores, iterator, stop);\n    listIterate(orderingTerms, iterator, stop);\n    if (WCDB_SYNTAX_CHECK_OPTIONAL_VALID(limit)) {\n        recursiveIterate(limit.value(), iterator, stop);\n        switch (limitParameterType) {\n        case LimitParameterType::NotSet:\n            break;\n        case LimitParameterType::Offset:\n        case LimitParameterType::End:\n            recursiveIterate(limitParameter.getOrCreate(), iterator, stop);\n            break;\n        }\n    }\n    Identifier::iterate(iterator, false, stop);\n}\n\n} // namespace Syntax\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/syntax/stmt/SyntaxSelectSTMT.hpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"SyntaxExpression.hpp\"\n#include \"SyntaxIdentifier.hpp\"\n#include \"SyntaxSelectCore.hpp\"\n\nnamespace WCDB {\n\nnamespace Syntax {\n\nclass CommonTableExpression;\nclass OrderingTerm;\n\nclass WCDB_API SelectSTMT final : public Identifier {\n#pragma mark - Lang\npublic:\n    ~SelectSTMT() override;\n\n    bool recursive = false;\n    std::list<CommonTableExpression> commonTableExpressions;\n\n    Optional<SelectCore> select;\n    std::list<SelectCore> cores;\n    std::list<CompoundOperator> compoundOperators;\n\n    std::list<OrderingTerm> orderingTerms;\n    Optional<Expression> limit;\n    LimitParameterType limitParameterType = LimitParameterType::NotSet;\n    Optional<Expression> limitParameter;\n\n    bool isValid() const override final;\n\n#pragma mark - Identifier\npublic:\n    static constexpr const Type type = Type::SelectSTMT;\n    Type getType() const override final;\n    bool describle(std::ostream& stream) const override final;\n    void iterate(const Iterator& iterator, bool& stop) override final;\n};\n\n} // namespace Syntax\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/syntax/stmt/SyntaxUpdateSTMT.cpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"Syntax.h\"\n#include \"SyntaxAssertion.hpp\"\n#include \"SyntaxEnum.hpp\"\n\nnamespace WCDB {\n\nnamespace Syntax {\n\nUpdateSTMT::~UpdateSTMT() = default;\n\nbool UpdateSTMT::isValid() const\n{\n    return table.isValid();\n}\n\n#pragma mark - Identifier\nIdentifier::Type UpdateSTMT::getType() const\n{\n    return type;\n}\n\nbool UpdateSTMT::describle(std::ostream& stream, bool skipSchema) const\n{\n    if (!commonTableExpressions.empty()) {\n        stream << \"WITH \";\n        if (recursive) {\n            stream << \"RECURSIVE \";\n        }\n        stream << commonTableExpressions << space;\n    }\n    stream << \"UPDATE \";\n    if (conflictActionValid()) {\n        stream << conflictAction << space;\n    }\n    if (!table.describle(stream, skipSchema)) {\n        return false;\n    }\n    stream << \" SET \";\n    if (!columnsList.empty()) {\n        WCTSyntaxRemedialAssert(columnsList.size() == expressions.size());\n        auto columns = columnsList.begin();\n        auto expression = expressions.begin();\n        bool comma = false;\n        while (columns != columnsList.end() && expression != expressions.end()) {\n            if (comma) {\n                stream << \", \";\n            } else {\n                comma = true;\n            }\n            if (columns->size() > 1) {\n                stream << \"(\" << *columns << \")\";\n            } else {\n                stream << *columns;\n            }\n            stream << \" = \" << *expression;\n            ++columns;\n            ++expression;\n        }\n        if (WCDB_SYNTAX_CHECK_OPTIONAL_VALID(condition)) {\n            stream << \" WHERE \" << condition.value();\n        }\n        if (!orderingTerms.empty()) {\n            stream << \" ORDER BY \" << orderingTerms;\n        }\n        if (WCDB_SYNTAX_CHECK_OPTIONAL_VALID(limit)) {\n            stream << \" LIMIT \" << limit.value();\n            switch (limitParameterType) {\n            case LimitParameterType::NotSet:\n                break;\n            case LimitParameterType::Offset:\n                stream << \" OFFSET \" << limitParameter.getOrCreate();\n                break;\n            case LimitParameterType::End:\n                stream << \", \" << limitParameter.getOrCreate();\n                break;\n            }\n        }\n    }\n    return true;\n}\n\nbool UpdateSTMT::describle(std::ostream& stream) const\n{\n    return describle(stream, false);\n}\n\nvoid UpdateSTMT::iterate(const Iterator& iterator, bool& stop)\n{\n    Identifier::iterate(iterator, true, stop);\n    listIterate(commonTableExpressions, iterator, stop);\n    recursiveIterate(table, iterator, stop);\n    if (!columnsList.empty()) {\n        WCTIterateRemedialAssert(columnsList.size() == expressions.size());\n        auto columns = columnsList.begin();\n        auto expression = expressions.begin();\n        while (columns != columnsList.end() && expression != expressions.end()) {\n            listIterate(*columns, iterator, stop);\n            expression->iterate(iterator, stop);\n            ++columns;\n            ++expression;\n        }\n        if (WCDB_SYNTAX_CHECK_OPTIONAL_VALID(condition)) {\n            recursiveIterate(condition.value(), iterator, stop);\n        }\n        if (!orderingTerms.empty()) {\n            listIterate(orderingTerms, iterator, stop);\n        }\n        if (WCDB_SYNTAX_CHECK_OPTIONAL_VALID(limit)) {\n            recursiveIterate(limit.value(), iterator, stop);\n            switch (limitParameterType) {\n            case LimitParameterType::NotSet:\n                break;\n            case LimitParameterType::Offset:\n            case LimitParameterType::End:\n                recursiveIterate(limitParameter.getOrCreate(), iterator, stop);\n                break;\n            }\n        }\n    }\n    Identifier::iterate(iterator, false, stop);\n}\n\n} // namespace Syntax\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/syntax/stmt/SyntaxUpdateSTMT.hpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"SyntaxIdentifier.hpp\"\n\nnamespace WCDB {\n\nnamespace Syntax {\n\nclass WCDB_API UpdateSTMT final : public Identifier {\n#pragma mark - Lang\npublic:\n    ~UpdateSTMT() override;\n\n    bool recursive = false;\n    std::list<CommonTableExpression> commonTableExpressions;\n\n    WCDB_SYNTAX_ENUM_UNION(ConflictAction, conflictAction);\n    QualifiedTableName table;\n    std::list<std::list<Column>> columnsList;\n    std::list<Expression> expressions;\n    Optional<Expression> condition;\n    std::list<OrderingTerm> orderingTerms;\n    Optional<Expression> limit;\n    LimitParameterType limitParameterType = LimitParameterType::NotSet;\n    Optional<Expression> limitParameter;\n\n    bool isValid() const override final;\n\n#pragma mark - Identifier\npublic:\n    static constexpr const Type type = Type::UpdateSTMT;\n    Type getType() const override final;\n    bool describle(std::ostream& stream) const override final;\n    bool describle(std::ostream& stream, bool skipSchema) const;\n    void iterate(const Iterator& iterator, bool& stop) override final;\n};\n\n} // namespace Syntax\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/syntax/stmt/SyntaxVacuumSTMT.cpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"Syntax.h\"\n#include \"SyntaxAssertion.hpp\"\n\nnamespace WCDB {\n\nnamespace Syntax {\n\nVacuumSTMT::~VacuumSTMT() = default;\n\n#pragma mark - Identifier\nIdentifier::Type VacuumSTMT::getType() const\n{\n    return type;\n}\n\nbool VacuumSTMT::describle(std::ostream& stream) const\n{\n    stream << \"VACUUM\";\n    switch (switcher) {\n    case Switch::All:\n        break;\n    case Switch::Schema:\n        stream << space << schema;\n        break;\n    }\n    return true;\n}\n\nvoid VacuumSTMT::iterate(const Iterator& iterator, bool& stop)\n{\n    Identifier::iterate(iterator, true, stop);\n    switch (switcher) {\n    case Switch::All:\n        break;\n    case Switch::Schema:\n        recursiveIterate(schema, iterator, stop);\n        break;\n    }\n    Identifier::iterate(iterator, false, stop);\n}\n\n} // namespace Syntax\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/common/winq/syntax/stmt/SyntaxVacuumSTMT.hpp",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"SyntaxIdentifier.hpp\"\n\nnamespace WCDB {\n\nnamespace Syntax {\n\nclass WCDB_API VacuumSTMT final : public Identifier {\n#pragma mark - Lang\npublic:\n    ~VacuumSTMT() override;\n\n    WCDB_SYNTAX_MAIN_UNION_ENUM(All, Schema);\n    Schema schema;\n\n#pragma mark - Identifier\npublic:\n    static constexpr const Type type = Type::VacuumSTMT;\n    Type getType() const override final;\n    bool describle(std::ostream& stream) const override final;\n    void iterate(const Iterator& iterator, bool& stop) override final;\n};\n\n} // namespace Syntax\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/cpp/Operation/BaseOperation.cpp",
    "content": "//\n// Created by qiuwenchen on 2022/9/8.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"BaseOperation.hpp\"\n#include \"InnerDatabase.hpp\"\n#include \"InnerHandle.hpp\"\n\nnamespace WCDB {\n\nBaseOperation::~BaseOperation() = default;\n\nvoid BaseOperation::assignErrorToDatabase(const Error& error)\n{\n    auto database = getDatabaseHolder();\n    if (database != nullptr) {\n        database->setThreadedError(error);\n    }\n}\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/cpp/Operation/BaseOperation.hpp",
    "content": "//\n// Created by qiuwenchen on 2022/9/8.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n#include \"CPPDeclaration.h\"\n#include \"RecyclableHandle.hpp\"\n\nnamespace WCDB {\n\nclass WCDB_API BaseOperation {\nprotected:\n    virtual ~BaseOperation() = 0;\n    virtual RecyclableHandle getHandleHolder(bool writeHint) = 0;\n    virtual Recyclable<InnerDatabase *> getDatabaseHolder() = 0;\n    void assignErrorToDatabase(const Error &error);\n\n    template<class StatementType>\n    void configStatement(StatementType &statement,\n                         const Expression &where,\n                         const OrderingTerms &orders,\n                         const Expression &limit,\n                         const Expression &offset)\n    {\n        if (where.syntax().isValid()) {\n            statement.where(where);\n        }\n        if (orders.size() > 0) {\n            statement.orders(orders);\n        }\n        if (limit.syntax().isValid()) {\n            statement.limit(limit);\n        }\n        if (offset.syntax().isValid()) {\n            statement.offset(offset);\n        }\n    }\n};\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/cpp/Operation/HandleORMOperation.cpp",
    "content": "//\n// Created by qiuwenchen on 2022/9/2.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"HandleORMOperation.hpp\"\n#include \"Delete.hpp\"\n#include \"Handle.hpp\"\n#include \"MultiSelect.hpp\"\n\nnamespace WCDB {\n\nHandleORMOperation::~HandleORMOperation() = default;\n\nDelete HandleORMOperation::prepareDelete()\n{\n    return Delete(getDatabaseHolder());\n}\n\nbool HandleORMOperation::deleteObjects(const UnsafeStringView &table,\n                                       const Expression &where,\n                                       const OrderingTerms &orders,\n                                       const Expression &limit,\n                                       const Expression &offset)\n{\n    auto delete_ = prepareDelete().fromTable(table);\n    configStatement(delete_, where, orders, limit, offset);\n    return delete_.execute();\n}\n\nMultiSelect HandleORMOperation::prepareMultiSelect()\n{\n    return MultiSelect(getDatabaseHolder());\n}\n\nOptionalMultiObject\nHandleORMOperation::getFirstMultiObject(const ValueArray<StringView> tables,\n                                        const ResultFields &resultFields,\n                                        const Expression &where,\n                                        const OrderingTerms &orders,\n                                        const Expression &limit,\n                                        const Expression &offset)\n{\n    auto select = prepareMultiSelect();\n    select.onResultFields(resultFields).fromTables(tables);\n    configStatement(select, where, orders, limit, offset);\n    return select.firstMultiObject();\n}\n\nOptionalMultiObjectArray\nHandleORMOperation::getAllMultiObjects(const ValueArray<StringView> tables,\n                                       const ResultFields &resultFields,\n                                       const Expression &where,\n                                       const OrderingTerms &orders,\n                                       const Expression &limit,\n                                       const Expression &offset)\n{\n    auto select = prepareMultiSelect();\n    select.onResultFields(resultFields).fromTables(tables);\n    configStatement(select, where, orders, limit, offset);\n    return select.allMultiObjects();\n}\n\nbool HandleORMOperation::createTable(const UnsafeStringView &tableName, const Binding &binding)\n{\n    auto handle = getHandleHolder(true);\n    if (handle == nullptr) {\n        return false;\n    }\n    return binding.createTable(tableName, handle.get());\n}\n\nbool HandleORMOperation::createVirtualTable(const UnsafeStringView &tableName,\n                                            const Binding &binding)\n{\n    auto handle = getHandleHolder(true);\n    if (handle == nullptr) {\n        return false;\n    }\n    return binding.createVirtualTable(tableName, handle.get());\n}\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/cpp/Operation/HandleORMOperation.hpp",
    "content": "//\n// Created by qiuwenchen on 2022/9/2.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n#include \"CPPORM.h\"\n#include \"HandleOperation.hpp\"\n#include \"MultiObject.hpp\"\n#include \"WCDBError.hpp\"\n\nnamespace WCDB {\n\nclass WCDB_API HandleORMOperation : public HandleOperation {\npublic:\n#pragma mark - Table\n    /**\n     @brief Get a wrapper from an existing table.\n     @param tableName The name of the table.\n     @return WCDB::Table.\n     */\n    template<class ObjectType>\n    Table<ObjectType> getTable(const UnsafeStringView &tableName)\n    {\n        assertCondition(tableName.length() > 0);\n        return Table<ObjectType>(getDatabaseHolder(), tableName);\n    }\n\n    /**\n     @brief Create virtual table from ORM if not exists.\n     @see   http://www.sqlite.org/vtab.html\n     @param tableName The name of the virtual table to be created.\n     @return True if no error occurs.\n     */\n    template<class ObjectType>\n    bool createVirtualTable(const UnsafeStringView &tableName)\n    {\n        WCDB_CPP_ORM_STATIC_ASSERT_FOR_OBJECT_TYPE\n        assertCondition(tableName.length() > 0);\n        const WCDB::Binding &binding = ObjectType::getObjectRelationBinding();\n        return createVirtualTable(tableName, binding);\n    }\n\n    /**\n     @brief Create table and indexes from ORM if not exists.\n     @note  It will run embedded transaction, and add newly defined columns automatically.\n            The embedded transaction means that it will run a transaction if it's not in other transaction, otherwise it will be executed within the existing transaction.\n     @param tableName This would be the name of the table and the prefix of the index names.\n     @return True if no error occurs.\n     */\n    template<class ObjectType>\n    bool createTable(const UnsafeStringView &tableName)\n    {\n        WCDB_CPP_ORM_STATIC_ASSERT_FOR_OBJECT_TYPE\n        assertCondition(tableName.length() > 0);\n        const Binding &binding = ObjectType::getObjectRelationBinding();\n        return createTable(tableName, binding);\n    }\n\n#pragma mark - ChainCall\n    /**\n     @brief Generate a `WCDB::Insert` to do an insertion or replacement.\n     */\n    template<class ObjectType>\n    Insert<ObjectType> prepareInsert()\n    {\n        return Insert<ObjectType>(getDatabaseHolder());\n    }\n\n    /**\n     @brief Generate a `WCDB::Delete` to do a deletion.\n     */\n    Delete prepareDelete();\n\n    /**\n     @brief Generate a `WCDB::Update` to do an update.\n     */\n    template<class ObjectType>\n    Update<ObjectType> prepareUpdate()\n    {\n        return Update<ObjectType>(getDatabaseHolder());\n    }\n\n    /**\n     @brief Generate a `WCDB::Select` to do an object selection.\n     */\n    template<class ObjectType>\n    Select<ObjectType> prepareSelect()\n    {\n        return Select<ObjectType>(getDatabaseHolder());\n    }\n\n    /**\n     @brief Generate a `WCDB::MultiSelect` to do a cross table selection.\n     */\n    MultiSelect prepareMultiSelect();\n\n#pragma mark - Insert\n    /**\n     @brief Execute inserting with one object on specific(or all) fields.\n     @return True if no error occurs.\n     */\n    template<class ObjectType>\n    bool insertObject(const ObjectType &obj,\n                      const UnsafeStringView &table,\n                      const Fields &fields = Fields())\n    {\n        auto insert = prepareInsert<ObjectType>().intoTable(table).value(obj);\n        if (fields.size() > 0) {\n            insert.onFields(fields);\n        }\n        return insert.execute();\n    }\n\n    /**\n     @brief Execute inserting with multi objects on specific(or all) fields.\n     @note  It will run embedded transaction while objs.size>1. The embedded transaction means that it will run a transaction if it's not in other transaction, otherwise it will be executed within the existing transaction.\n     @return True if no error occurs.\n     */\n    template<class ObjectType>\n    bool insertObjects(const ValueArray<ObjectType> &objs,\n                       const UnsafeStringView &table,\n                       const Fields &fields = Fields())\n    {\n        if (objs.size() == 0) {\n            return true;\n        }\n        auto insert = prepareInsert<ObjectType>().intoTable(table).values(objs);\n        if (fields.size() > 0) {\n            insert.onFields(fields);\n        }\n        return insert.execute();\n    }\n\n    /**\n     @brief Execute inserting with multi objects on specific(or all) fields.\n     @note  It will run embedded transaction while objs.size>1. The embedded transaction means that it will run a transaction if it's not in other transaction, otherwise it will be executed within the existing transaction.\n     @return True if no error occurs.\n     */\n    template<class ObjectType>\n    bool insertObjects(const ValueArray<ObjectType *> &objs,\n                       const UnsafeStringView &table,\n                       const Fields &fields = Fields())\n    {\n        if (objs.size() == 0) {\n            return true;\n        }\n        auto insert = prepareInsert<ObjectType>().intoTable(table).values(objs);\n        if (fields.size() > 0) {\n            insert.onFields(fields);\n        }\n        return insert.execute();\n    }\n\n    /**\n     @brief Execute inserting with multi objects on specific(or all) fields.\n     @note  It will run embedded transaction while objs.size>1. The embedded transaction means that it will run a transaction if it's not in other transaction, otherwise it will be executed within the existing transaction.\n     @return True if no error occurs.\n     */\n    template<class ObjectType>\n    bool insertObjects(const ValueArray<std::shared_ptr<ObjectType>> &objs,\n                       const UnsafeStringView &table,\n                       const Fields &fields = Fields())\n    {\n        if (objs.size() == 0) {\n            return true;\n        }\n        auto insert = prepareInsert<ObjectType>().intoTable(table).values(objs);\n        if (fields.size() > 0) {\n            insert.onFields(fields);\n        }\n        return insert.execute();\n    }\n\n    /**\n     @brief Execute inserting with one object on specific(or all) fields.\n     It will replace the original row while they have same primary key or row id.\n     @return True if no error occurs.\n     */\n    template<class ObjectType>\n    bool insertOrReplaceObject(const ObjectType &obj,\n                               const UnsafeStringView &table,\n                               const Fields &fields = Fields())\n    {\n        auto insert = prepareInsert<ObjectType>().orReplace().intoTable(table).value(obj);\n        if (fields.size() > 0) {\n            insert.onFields(fields);\n        }\n        return insert.execute();\n    }\n\n    /**\n     @brief Execute inserting with multi objects on specific(or all) fields.\n     It will replace the original row while they have same primary key or row id.\n     @note  It will run embedded transaction while objs.size>1. The embedded transaction means that it will run a transaction if it's not in other transaction, otherwise it will be executed within the existing transaction.\n     @return True if no error occurs.\n     */\n    template<class ObjectType>\n    bool insertOrReplaceObjects(const ValueArray<ObjectType> &objs,\n                                const UnsafeStringView &table,\n                                const Fields &fields = Fields())\n    {\n        if (objs.size() == 0) {\n            return true;\n        }\n        auto insert\n        = prepareInsert<ObjectType>().orReplace().intoTable(table).values(objs);\n        if (fields.size() > 0) {\n            insert.onFields(fields);\n        }\n        return insert.execute();\n    }\n\n    /**\n     @brief Execute inserting with multi objects on specific(or all) fields.\n     It will replace the original row while they have same primary key or row id.\n     @note  It will run embedded transaction while objs.size>1. The embedded transaction means that it will run a transaction if it's not in other transaction, otherwise it will be executed within the existing transaction.\n     @return True if no error occurs.\n     */\n    template<class ObjectType>\n    bool insertOrReplaceObjects(const ValueArray<ObjectType *> &objs,\n                                const UnsafeStringView &table,\n                                const Fields &fields = Fields())\n    {\n        if (objs.size() == 0) {\n            return true;\n        }\n        auto insert\n        = prepareInsert<ObjectType>().orReplace().intoTable(table).values(objs);\n        if (fields.size() > 0) {\n            insert.onFields(fields);\n        }\n        return insert.execute();\n    }\n\n    /**\n     @brief Execute inserting with multi objects on specific(or all) fields.\n     It will replace the original row while they have same primary key or row id.\n     @note  It will run embedded transaction while objs.size>1. The embedded transaction means that it will run a transaction if it's not in other transaction, otherwise it will be executed within the existing transaction.\n     @return True if no error occurs.\n     */\n    template<class ObjectType>\n    bool insertOrReplaceObjects(const ValueArray<std::shared_ptr<ObjectType>> &objs,\n                                const UnsafeStringView &table,\n                                const Fields &fields = Fields())\n    {\n        if (objs.size() == 0) {\n            return true;\n        }\n        auto insert\n        = prepareInsert<ObjectType>().orReplace().intoTable(table).values(objs);\n        if (fields.size() > 0) {\n            insert.onFields(fields);\n        }\n        return insert.execute();\n    }\n\n    /**\n     @brief Execute inserting with multi objects on specific(or all) fields.\n     It will ignore the object while there already exists the same primary key or row id in current table.\n     @return True if no error occurs.\n     */\n    template<class ObjectType>\n    bool insertOrIgnoreObject(const ObjectType &obj,\n                              const UnsafeStringView &table,\n                              const Fields &fields = Fields())\n    {\n        auto insert = prepareInsert<ObjectType>().orIgnore().intoTable(table).value(obj);\n        if (fields.size() > 0) {\n            insert.onFields(fields);\n        }\n        return insert.execute();\n    }\n\n    /**\n     @brief Execute inserting with multi objects on specific(or all) fields.\n     It will ignore the object while there already exists the same primary key or row id in current table.\n     @note  It will run embedded transaction while objs.size>1. The embedded transaction means that it will run a transaction if it's not in other transaction, otherwise it will be executed within the existing transaction.\n     @return True if no error occurs.\n     */\n    template<class ObjectType>\n    bool insertOrIgnoreObjects(const ValueArray<ObjectType> &objs,\n                               const UnsafeStringView &table,\n                               const Fields &fields = Fields())\n    {\n        if (objs.size() == 0) {\n            return true;\n        }\n        auto insert\n        = prepareInsert<ObjectType>().orIgnore().intoTable(table).values(objs);\n        if (fields.size() > 0) {\n            insert.onFields(fields);\n        }\n        return insert.execute();\n    }\n\n    /**\n     @brief Execute inserting with multi objects on specific(or all) fields.\n     It will ignore the object while there already exists the same primary key or row id in current table.\n     @note  It will run embedded transaction while objs.size>1. The embedded transaction means that it will run a transaction if it's not in other transaction, otherwise it will be executed within the existing transaction.\n     @return True if no error occurs.\n     */\n    template<class ObjectType>\n    bool insertOrIgnoreObjects(const ValueArray<ObjectType *> &objs,\n                               const UnsafeStringView &table,\n                               const Fields &fields = Fields())\n    {\n        if (objs.size() == 0) {\n            return true;\n        }\n        auto insert\n        = prepareInsert<ObjectType>().orIgnore().intoTable(table).values(objs);\n        if (fields.size() > 0) {\n            insert.onFields(fields);\n        }\n        return insert.execute();\n    }\n\n    /**\n     @brief Execute inserting with multi objects on specific(or all) fields.\n     It will ignore the object while there already exists the same primary key or row id in current table.\n     @note  It will run embedded transaction while objs.size>1. The embedded transaction means that it will run a transaction if it's not in other transaction, otherwise it will be executed within the existing transaction.\n     @return True if no error occurs.\n     */\n    template<class ObjectType>\n    bool insertOrIgnoreObjects(const ValueArray<std::shared_ptr<ObjectType>> &objs,\n                               const UnsafeStringView &table,\n                               const Fields &fields = Fields())\n    {\n        if (objs.size() == 0) {\n            return true;\n        }\n        auto insert\n        = prepareInsert<ObjectType>().orIgnore().intoTable(table).values(objs);\n        if (fields.size() > 0) {\n            insert.onFields(fields);\n        }\n        return insert.execute();\n    }\n\n#pragma mark - Delete\n    /**\n     @brief Execute deleting.\n     @return True if no error occurs.\n     */\n    bool deleteObjects(const UnsafeStringView &table,\n                       const Expression &where = Expression(),\n                       const OrderingTerms &orders = OrderingTerms(),\n                       const Expression &limit = Expression(),\n                       const Expression &offset = Expression());\n\n#pragma mark - Update\n    /**\n     @brief Execute updating with object on specific(or all) fields.\n     @return True if no error occurs.\n     */\n    template<class ObjectType>\n    bool updateObject(const ObjectType &obj,\n                      const Fields &fields,\n                      const UnsafeStringView &table,\n                      const Expression &where = Expression(),\n                      const OrderingTerms &orders = OrderingTerms(),\n                      const Expression &limit = Expression(),\n                      const Expression &offset = Expression())\n    {\n        auto update\n        = prepareUpdate<ObjectType>().table(table).set(fields).toObject(&obj);\n        configStatement(update, where, orders, limit, offset);\n        return update.execute();\n    }\n\n#pragma mark - Select\n    /**\n     @brief Get an object by specific selecting.\n     */\n    template<class ObjectType>\n    Optional<ObjectType> getFirstObject(const UnsafeStringView &table,\n                                        const Expression &where = Expression(),\n                                        const OrderingTerms &orders = OrderingTerms(),\n                                        const Expression &offset = Expression())\n    {\n        auto select = prepareSelect<ObjectType>().fromTable(table);\n        configStatement(select, where, orders, Expression(1), offset);\n        return select.firstObject();\n    }\n\n    /**\n     @brief Get an object on specific fields by specific selecting.\n     */\n    template<class ObjectType>\n    Optional<ObjectType>\n    getFirstObjectWithFields(const UnsafeStringView &table,\n                             const ResultFields &resultFields,\n                             const Expression &where = Expression(),\n                             const OrderingTerms &orders = OrderingTerms(),\n                             const Expression &offset = Expression())\n    {\n        auto select\n        = prepareSelect<ObjectType>().fromTable(table).onResultFields(resultFields);\n        configStatement(select, where, orders, Expression(1), offset);\n        return select.firstObject();\n    }\n\n    /**\n     @brief Get objects by specific selecting.\n     */\n    template<class ObjectType>\n    OptionalValueArray<ObjectType>\n    getAllObjects(const UnsafeStringView &table,\n                  const Expression &where = Expression(),\n                  const OrderingTerms &orders = OrderingTerms(),\n                  const Expression &limit = Expression(),\n                  const Expression &offset = Expression())\n    {\n        auto select = prepareSelect<ObjectType>().fromTable(table);\n        configStatement(select, where, orders, limit, offset);\n        return select.allObjects();\n    }\n\n    /**\n     @brief Get objects on specific fields by specific selecting.\n     */\n    template<class ObjectType>\n    OptionalValueArray<ObjectType>\n    getAllObjectsWithFields(const UnsafeStringView &table,\n                            const ResultFields &resultFields,\n                            const Expression &where = Expression(),\n                            const OrderingTerms &orders = OrderingTerms(),\n                            const Expression &limit = Expression(),\n                            const Expression &offset = Expression())\n    {\n        auto select\n        = prepareSelect<ObjectType>().fromTable(table).onResultFields(resultFields);\n        configStatement(select, where, orders, limit, offset);\n        return select.allObjects();\n    }\n\n    /**\n     @brief Get first row of objects by specific multi-selecting.\n     */\n    OptionalMultiObject\n    getFirstMultiObject(const ValueArray<StringView> tables,\n                        const ResultFields &resultFields,\n                        const Expression &where = Expression(),\n                        const OrderingTerms &orders = OrderingTerms(),\n                        const Expression &limit = Expression(),\n                        const Expression &offset = Expression());\n\n    /**\n     @brief Get objects by specific multi-selecting.\n     */\n    OptionalMultiObjectArray\n    getAllMultiObjects(const ValueArray<StringView> tables,\n                       const ResultFields &resultFields,\n                       const Expression &where = Expression(),\n                       const OrderingTerms &orders = OrderingTerms(),\n                       const Expression &limit = Expression(),\n                       const Expression &offset = Expression());\n\nprotected:\n    bool createTable(const UnsafeStringView &tableName, const Binding &binding);\n    bool createVirtualTable(const UnsafeStringView &tableName, const Binding &binding);\n    virtual ~HandleORMOperation() override = 0;\n};\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/cpp/Operation/HandleOperation.cpp",
    "content": "//\n// Created by qiuwenchen on 2022/8/11.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"HandleOperation.hpp\"\n#include \"Assertion.hpp\"\n#include \"CoreConst.h\"\n#include \"Handle.hpp\"\n#include \"InnerHandle.hpp\"\n#include \"Notifier.hpp\"\n\n#define GetHandleOrReturnValue(writeHint, value)                               \\\n    RecyclableHandle handle = getHandleHolder(writeHint);                      \\\n    if (handle == nullptr) {                                                   \\\n        return value;                                                          \\\n    }\n\nnamespace WCDB {\n\nHandleOperation::~HandleOperation() = default;\n\nbool HandleOperation::insertRows(const MultiRowsValue &rows,\n                                 const Columns &columns,\n                                 const UnsafeStringView &table)\n{\n    auto insertAction = [&](Handle &handle) {\n        StatementInsert insert\n        = StatementInsert().insertIntoTable(table).columns(columns).values(\n        BindParameter::bindParameters(columns.size()));\n        if (!handle.prepare(insert)) {\n            assignErrorToDatabase(handle.getError());\n            return false;\n        }\n        for (const OneRowValue &row : rows) {\n            WCTRemedialAssert(columns.size() == row.size(),\n                              \"Number of values is not equal to number of columns\",\n                              handle.finalize();\n                              return false;) handle.reset();\n            handle.bindRow(row);\n            if (!handle.step()) {\n                handle.finalize();\n                assignErrorToDatabase(handle.getError());\n                return false;\n            }\n        }\n        handle.finalize();\n        return true;\n    };\n    if (rows.size() == 0) {\n        return true;\n    } else if (rows.size() == 1) {\n        GetHandleOrReturnValue(true, false);\n        Handle newHandle = Handle(handle);\n        return insertAction(newHandle);\n    } else {\n        return lazyRunTransaction(insertAction);\n    }\n}\n\nbool HandleOperation::insertOrReplaceRows(const MultiRowsValue &rows,\n                                          const Columns &columns,\n                                          const UnsafeStringView &table)\n{\n    auto insertAction = [&](Handle &handle) {\n        StatementInsert insert\n        = StatementInsert().insertIntoTable(table).orReplace().columns(columns).values(\n        BindParameter::bindParameters(columns.size()));\n        if (!handle.prepare(insert)) {\n            assignErrorToDatabase(handle.getError());\n            return false;\n        }\n        for (const OneRowValue &row : rows) {\n            WCTRemedialAssert(columns.size() == row.size(),\n                              \"Number of values is not equal to number of columns\",\n                              handle.finalize();\n                              return false;) handle.reset();\n            handle.bindRow(row);\n            if (!handle.step()) {\n                handle.finalize();\n                assignErrorToDatabase(handle.getError());\n                return false;\n            }\n        }\n        handle.finalize();\n        return true;\n    };\n    if (rows.size() == 0) {\n        return true;\n    } else if (rows.size() == 1) {\n        GetHandleOrReturnValue(true, false);\n        Handle newHandle = Handle(handle);\n        return insertAction(newHandle);\n    } else {\n        return lazyRunTransaction(insertAction);\n    }\n}\n\nbool HandleOperation::insertOrIgnoreRows(const MultiRowsValue &rows,\n                                         const Columns &columns,\n                                         const UnsafeStringView &table)\n{\n    auto insertAction = [&](Handle &handle) {\n        StatementInsert insert\n        = StatementInsert().insertIntoTable(table).orIgnore().columns(columns).values(\n        BindParameter::bindParameters(columns.size()));\n        if (!handle.prepare(insert)) {\n            assignErrorToDatabase(handle.getError());\n            return false;\n        }\n        for (const OneRowValue &row : rows) {\n            WCTRemedialAssert(columns.size() == row.size(),\n                              \"Number of values is not equal to number of columns\",\n                              handle.finalize();\n                              return false;) handle.reset();\n            handle.bindRow(row);\n            if (!handle.step()) {\n                handle.finalize();\n                assignErrorToDatabase(handle.getError());\n                return false;\n            }\n        }\n        handle.finalize();\n        return true;\n    };\n    if (rows.size() == 0) {\n        return true;\n    } else if (rows.size() == 1) {\n        GetHandleOrReturnValue(true, false);\n        Handle newHandle = Handle(handle);\n        return insertAction(newHandle);\n    } else {\n        return lazyRunTransaction(insertAction);\n    }\n}\n\nbool HandleOperation::updateRow(const OneRowValue &row,\n                                const Columns &columns,\n                                const UnsafeStringView &table,\n                                const Expression &where,\n                                const OrderingTerms &orders,\n                                const Expression &limit,\n                                const Expression &offset)\n{\n    WCTRemedialAssert(columns.size() > 0, \"Number of columns can not be zero\", return false;)\n    WCTRemedialAssert(columns.size() == row.size(),\n                      \"Number of values in this row is not equal to number of columns\",\n                      return false;) StatementUpdate update\n    = StatementUpdate().update(table);\n    for (int i = 0; i < columns.size(); i++) {\n        update.set(columns[i]).to(WCDB::BindParameter(i + 1));\n    }\n    configStatement(update, where, orders, limit, offset);\n    GetHandleOrReturnValue(true, false);\n    bool succeed = false;\n    if ((succeed = handle->prepare(update))) {\n        handle->bindRow(row);\n        succeed = handle->step();\n        handle->finalize();\n    }\n    if (!succeed) {\n        assignErrorToDatabase(handle->getError());\n    }\n    return succeed;\n}\n\nbool HandleOperation::deleteValues(const UnsafeStringView &table,\n                                   const Expression &where,\n                                   const OrderingTerms &orders,\n                                   const Expression &limit,\n                                   const Expression &offset)\n{\n    StatementDelete delete_ = StatementDelete().deleteFrom(table);\n    configStatement(delete_, where, orders, limit, offset);\n    return execute(delete_);\n}\n\nOptionalValue HandleOperation::selectValue(const ResultColumn &column,\n                                           const UnsafeStringView &table,\n                                           const Expression &where,\n                                           const OrderingTerms &orders,\n                                           const Expression &offset)\n{\n    auto select = StatementSelect().select(column).from(table);\n    configStatement(select, where, orders, Expression(1), offset);\n    return getValueFromStatement(select);\n}\n\nOptionalOneColumn HandleOperation::selectOneColumn(const ResultColumn &column,\n                                                   const UnsafeStringView &table,\n                                                   const Expression &where,\n                                                   const OrderingTerms &orders,\n                                                   const Expression &limit,\n                                                   const Expression &offset)\n{\n    auto select = StatementSelect().select(column).from(table);\n    configStatement(select, where, orders, limit, offset);\n    return getOneColumnFromStatement(select);\n}\n\nOptionalOneRow HandleOperation::selectOneRow(const ResultColumns &columns,\n                                             const UnsafeStringView &table,\n                                             const Expression &where,\n                                             const OrderingTerms &orders,\n                                             const Expression &offset)\n{\n    auto select = StatementSelect().select(columns).from(table);\n    configStatement(select, where, orders, Expression(1), offset);\n    return getOneRowFromStatement(select);\n}\n\nOptionalMultiRows HandleOperation::selectAllRow(const ResultColumns &columns,\n                                                const UnsafeStringView &table,\n                                                const Expression &where,\n                                                const OrderingTerms &orders,\n                                                const Expression &limit,\n                                                const Expression &offset)\n{\n    auto select = StatementSelect().select(columns).from(table);\n    configStatement(select, where, orders, limit, offset);\n    return getAllRowsFromStatement(select);\n}\n\nOptionalValue HandleOperation::getValueFromStatement(const Statement &statement, int index)\n{\n    OptionalValue result;\n    GetHandleOrReturnValue(false, result);\n    if (!handle->prepare(statement)) {\n        assignErrorToDatabase(handle->getError());\n        return result;\n    }\n    bool succeed = false;\n    if ((succeed = handle->step()) && !handle->done()) {\n        result = handle->getValue(index);\n    }\n    handle->finalize();\n    if (!succeed) {\n        assignErrorToDatabase(handle->getError());\n    }\n    return result;\n}\n\nOptionalOneColumn\nHandleOperation::getOneColumnFromStatement(const Statement &statement, int index)\n{\n    OptionalOneColumn result;\n    GetHandleOrReturnValue(false, result);\n    if (!handle->prepare(statement)) {\n        assignErrorToDatabase(handle->getError());\n        return result;\n    }\n    result = handle->getOneColumn(index);\n    handle->finalize();\n    if (!result.succeed()) {\n        assignErrorToDatabase(handle->getError());\n    }\n    return result;\n}\n\nOptionalOneRow HandleOperation::getOneRowFromStatement(const Statement &statement)\n{\n    OptionalOneRow result;\n    GetHandleOrReturnValue(false, result);\n    if (!handle->prepare(statement)) {\n        assignErrorToDatabase(handle->getError());\n        return result;\n    }\n    bool succeed = false;\n    if ((succeed = handle->step()) && !handle->done()) {\n        result = handle->getOneRow();\n    }\n    handle->finalize();\n    if (!succeed) {\n        assignErrorToDatabase(handle->getError());\n    }\n    return result;\n}\n\nOptionalMultiRows HandleOperation::getAllRowsFromStatement(const Statement &statement)\n{\n    OptionalMultiRows result;\n    GetHandleOrReturnValue(false, result);\n    if (!handle->prepare(statement)) {\n        assignErrorToDatabase(handle->getError());\n        return result;\n    }\n    result = handle->getAllRows();\n    handle->finalize();\n    if (!result.succeed()) {\n        assignErrorToDatabase(handle->getError());\n    }\n    return result;\n}\n\nbool HandleOperation::execute(const Statement &statement)\n{\n    GetHandleOrReturnValue(statement.isWriteStatement(), false);\n    bool succeed = handle->execute(statement);\n    if (!succeed) {\n        assignErrorToDatabase(handle->getError());\n    }\n    return succeed;\n}\n\nbool HandleOperation::runTransaction(TransactionCallback inTransaction)\n{\n    GetHandleOrReturnValue(true, false);\n    bool succeed = handle->runTransaction([inTransaction, this](InnerHandle *innerHandle) {\n        Handle handle = Handle(getDatabaseHolder(), innerHandle);\n        return inTransaction(handle);\n    });\n    if (!succeed) {\n        assignErrorToDatabase(handle->getError());\n    }\n    return succeed;\n}\n\nbool HandleOperation::lazyRunTransaction(TransactionCallback inTransaction)\n{\n    GetHandleOrReturnValue(true, false);\n    if (handle->isInTransaction()) {\n        Handle newHandle = Handle(getDatabaseHolder(), handle.get());\n        return inTransaction(newHandle);\n    } else {\n        handle->markErrorNotAllowedWithinTransaction();\n        return runTransaction(inTransaction);\n    }\n}\n\nbool HandleOperation::runPausableTransactionWithOneLoop(TransactionCallbackForOneLoop inTransaction)\n{\n    Handle newHandle = Handle(getDatabaseHolder());\n    auto handleHolder = newHandle.getHandleHolder(true);\n    if (handleHolder == nullptr) {\n        return false;\n    }\n    bool succeed = handleHolder->runPausableTransactionWithOneLoop(\n    [&](InnerHandle *, bool &stop, bool isNewTransaction) {\n        return inTransaction(newHandle, stop, isNewTransaction);\n    });\n    if (!succeed) {\n        assignErrorToDatabase(newHandle.getError());\n    }\n    return succeed;\n}\n\nOptional<bool> HandleOperation::tableExists(const UnsafeStringView &tableName)\n{\n    Optional<bool> result;\n    GetHandleOrReturnValue(false, result);\n    result = handle->tableExists(tableName);\n    if (!result.succeed()) {\n        assignErrorToDatabase(handle->getError());\n    }\n    return result;\n}\n\nbool HandleOperation::dropTable(const UnsafeStringView &tableName)\n{\n    return execute(StatementDropTable().dropTable(tableName).ifExists());\n}\n\nbool HandleOperation::dropIndex(const UnsafeStringView &indexName)\n{\n    return execute(StatementDropIndex().dropIndex(indexName).ifExists());\n}\n\nvoid HandleOperation::notifyError(Error &error)\n{\n    auto handleHolder = getHandleHolder(false);\n    if (handleHolder != nullptr) {\n        error.infos.insert_or_assign(ErrorStringKeyPath, handleHolder->getPath());\n    }\n    Notifier::shared().notify(error);\n}\n\nvoid HandleOperation::assertCondition(bool condition)\n{\n    WCTAssert(condition);\n}\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/cpp/Operation/HandleOperation.hpp",
    "content": "//\n// Created by qiuwenchen on 2022/8/11.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"BaseOperation.hpp\"\n#include \"Value.hpp\"\n\nnamespace WCDB {\n\nclass WCDB_API HandleOperation : public BaseOperation {\n#pragma mark - Insert\npublic:\n    /**\n     @brief Execute inserting with multi rows of values. \n     @note  It will run embedded transaction while rows.size>1. The embedded transaction means that it will run a transaction if it's not in other transaction, otherwise it will be executed within the existing transaction.\n     @return True if no error occurs.\n     */\n    bool insertRows(const MultiRowsValue &rows, const Columns &columns, const UnsafeStringView &table);\n\n    /**\n     @brief Execute inserting with multi rows of values.\n     It will replace the original row while they have same primary key or row id.\n     @note  It will run embedded transaction while rows.size>1. The embedded transaction means that it will run a transaction if it's not in other transaction, otherwise it will be executed within the existing transaction.\n     @return True if no error occurs.\n     */\n    bool insertOrReplaceRows(const MultiRowsValue &rows,\n                             const Columns &columns,\n                             const UnsafeStringView &table);\n\n    /**\n     @brief Execute inserting with multi rows of values.\n     It will ignore the row while there already exists the same primary key or row id in current table.\n     @note  It will run embedded transaction while rows.size>1. The embedded transaction means that it will run a transaction if it's not in other transaction, otherwise it will be executed within the existing transaction.\n     @return True if no error occurs.\n     */\n    bool insertOrIgnoreRows(const MultiRowsValue &rows,\n                            const Columns &columns,\n                            const UnsafeStringView &table);\n\n#pragma mark - Update\npublic:\n    /**\n     @brief Execute updating with one row of values.\n     @return True if no error occurs.\n     */\n    bool updateRow(const OneRowValue &row,\n                   const Columns &columns,\n                   const UnsafeStringView &table,\n                   const Expression &where = Expression(),\n                   const OrderingTerms &orders = OrderingTerms(),\n                   const Expression &limit = Expression(),\n                   const Expression &offset = Expression());\n\n#pragma mark - delete\npublic:\n    /**\n     @brief Execute deleting.\n     @return True if no error occurs.\n     */\n    bool deleteValues(const UnsafeStringView &table,\n                      const Expression &where = Expression(),\n                      const OrderingTerms &orders = OrderingTerms(),\n                      const Expression &limit = Expression(),\n                      const Expression &offset = Expression());\n\n#pragma mark - Select\npublic:\n    /**\n     @brief Get one value by specific selecting.\n     */\n    OptionalValue selectValue(const ResultColumn &column,\n                              const UnsafeStringView &table,\n                              const Expression &where = Expression(),\n                              const OrderingTerms &orders = OrderingTerms(),\n                              const Expression &offset = Expression());\n\n    /**\n     @brief Get one column of values by specific selecting.\n     */\n    OptionalOneColumn selectOneColumn(const ResultColumn &column,\n                                      const UnsafeStringView &table,\n                                      const Expression &where = Expression(),\n                                      const OrderingTerms &orders = OrderingTerms(),\n                                      const Expression &limit = Expression(),\n                                      const Expression &offset = Expression());\n\n    /**\n     @brief Get one row of values by specific selecting.\n     */\n    OptionalOneRow selectOneRow(const ResultColumns &columns,\n                                const UnsafeStringView &table,\n                                const Expression &where = Expression(),\n                                const OrderingTerms &orders = OrderingTerms(),\n                                const Expression &offset = Expression());\n\n    /**\n     @brief Get all row of values by specific selecting.\n     */\n    OptionalMultiRows selectAllRow(const ResultColumns &columns,\n                                   const UnsafeStringView &table,\n                                   const Expression &where = Expression(),\n                                   const OrderingTerms &orders = OrderingTerms(),\n                                   const Expression &limit = Expression(),\n                                   const Expression &offset = Expression());\n\n#pragma mark - Statement\npublic:\n    /**\n     @brief Get one value from specific statement.\n     @param statement The statement to execute.\n     @param index The index of result column, starting from 0.\n     @return A value.\n     */\n    OptionalValue getValueFromStatement(const Statement &statement, int index = 0);\n\n    /**\n     @brief Get one column of value from specific statement.\n     @param statement The statement to execute.\n     @param index The index of result column, starting from 0.\n     @return A value array.\n     */\n    OptionalOneRow getOneColumnFromStatement(const Statement &statement, int index = 0);\n\n    /**\n     @brief Get one row of value from specific statement.\n     @param statement The statement to execute.\n     @return A value array.\n     */\n    OptionalOneRow getOneRowFromStatement(const Statement &statement);\n\n    /**\n     @brief Get all rows of value from specific statement.\n     @param statement The statement to execute.\n     @return Two-dimensional array of values.\n     */\n    OptionalMultiRows getAllRowsFromStatement(const Statement &statement);\n\n    /**\n     @brief Execute a statement directly.\n     @warning You should firstly use `-[WCTHandle finalizeStatement]` to finalize the previous statement prepared by `-[WCTHandle prepare:]`.\n     @return YES if no error occurs.\n     */\n    bool execute(const Statement &statement);\n\n#pragma mark - Transaction\npublic:\n    /**\n     Triggered when a new transaction is begun successfully.\n     */\n    typedef std::function<bool(Handle &)> TransactionCallback;\n\n    bool runTransaction(TransactionCallback inTransaction);\n\n    /**\n     Triggered when a new transaction is begun successfully or the main thread isn't suspended due to the current transaction.\n     */\n    typedef std::function<bool(Handle &, bool &, bool)> TransactionCallbackForOneLoop;\n\n    /**\n     @brief Run a pausable transaction in block.\n     Firstly, WCDB will begin a transaction and call the block. After the block is finished, WCDB will check whether the main thread is suspended due to the current transaction. If not, it will call the block again; if it is, it will temporarily commit the current transaction. Once database operations in main thread are finished, WCDB will rebegin a new transaction in the current thread and call the block. This process will be repeated until the second parameter of the block is specified as YES, or some error occurs during the transaction.\n     You can use pausable transaction to do some long term database operations, such as data cleaning or data migration, and avoid to block the main thread.\n     \n         database.runPausableTransactionWithOneLoop([&](Handle& handle, bool &stop, bool isNewTransaction) {\n             if(isNewTransaction) {\n                 // Do some initialization for new transaction.\n             }\n             \n             // Perform a small amount of data processing.\n             \n             if( Error occurs ) {\n                 return false;\n             }\n             if( All database operations are finished ) {\n                 stop = true;\n             }\n             return true;\n         });\n     \n     @param inTransaction Operation inside transaction for one loop.\n     @see   `TransactionCallbackForOneLoop`\n     @return True only if all transactions are committed.\n     */\n    bool runPausableTransactionWithOneLoop(TransactionCallbackForOneLoop inTransaction);\n\nprotected:\n    bool lazyRunTransaction(TransactionCallback inTransaction);\n\n#pragma mark - Table\npublic:\n    /**\n     @brief Check the existence of the table.\n     @param tableName The name of the table to be checked.\n     @return result.\n     */\n    Optional<bool> tableExists(const UnsafeStringView &tableName);\n\n    /**\n     @brief Drop table if exists.\n     @param tableName The name of the table to be dropped.\n     @return True only if no error occurs.\n     */\n    bool dropTable(const UnsafeStringView &tableName);\n\n    /**\n     @brief Drop index if not exists.\n     @param indexName The name of the index to be dropped.\n     @return True only if no error occurs.\n     */\n    bool dropIndex(const UnsafeStringView &indexName);\n\nprotected:\n    void notifyError(Error &error);\n    void assertCondition(bool condition);\n    virtual ~HandleOperation() override = 0;\n};\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/cpp/Operation/StatementOperation.cpp",
    "content": "//\n// Created by qiuwenchen on 2022/8/11.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"StatementOperation.hpp\"\n#include \"HandleStatement.hpp\"\n#include \"MultiObject.hpp\"\n\n#define GetHandleStatementOrReturn                                             \\\n    auto handleStatement = getInnerHandleStatement();                          \\\n    if (handleStatement == nullptr) {                                          \\\n        return;                                                                \\\n    }\n\n#define GetHandleStatementOrReturnValue(value)                                 \\\n    auto handleStatement = getInnerHandleStatement();                          \\\n    if (handleStatement == nullptr) {                                          \\\n        return value;                                                          \\\n    }\n\nnamespace WCDB {\n\nStatementOperation::~StatementOperation() = default;\n\nbool StatementOperation::prepare(const Statement &statement)\n{\n    GetHandleStatementOrReturnValue(false);\n    return handleStatement->prepare(statement);\n}\n\nbool StatementOperation::isPrepared()\n{\n    GetHandleStatementOrReturnValue(false);\n    return handleStatement->isPrepared();\n}\n\nvoid StatementOperation::finalize()\n{\n    GetHandleStatementOrReturn;\n    handleStatement->finalize();\n}\n\nbool StatementOperation::step()\n{\n    GetHandleStatementOrReturnValue(false);\n    return handleStatement->step();\n}\n\nbool StatementOperation::done()\n{\n    GetHandleStatementOrReturnValue(true);\n    return handleStatement->done();\n}\n\nvoid StatementOperation::reset()\n{\n    GetHandleStatementOrReturn;\n    handleStatement->reset();\n}\n\nvoid StatementOperation::clearBindings()\n{\n    GetHandleStatementOrReturn;\n    handleStatement->clearBindings();\n}\n\nbool StatementOperation::isReadOnly()\n{\n    GetHandleStatementOrReturnValue(false);\n    return handleStatement->isReadOnly();\n}\n\nvoid StatementOperation::bindInteger(const Integer &value, int index)\n{\n    GetHandleStatementOrReturn;\n    handleStatement->bindInteger(value, index);\n}\n\nvoid StatementOperation::bindDouble(const Float &value, int index)\n{\n    GetHandleStatementOrReturn;\n    handleStatement->bindDouble(value, index);\n}\n\nvoid StatementOperation::bindText(const Text &value, int index)\n{\n    GetHandleStatementOrReturn;\n    handleStatement->bindText(value, index);\n}\n\nvoid StatementOperation::bindBLOB(const BLOB &value, int index)\n{\n    GetHandleStatementOrReturn;\n    handleStatement->bindBLOB(value, index);\n}\n\nvoid StatementOperation::bindNull(int index)\n{\n    GetHandleStatementOrReturn;\n    handleStatement->bindNull(index);\n}\n\nvoid StatementOperation::bindValue(const Value &value, int index)\n{\n    GetHandleStatementOrReturn;\n    handleStatement->bindValue(value, index);\n}\n\nvoid StatementOperation::bindRow(const OneRowValue &row)\n{\n    GetHandleStatementOrReturn;\n    handleStatement->bindRow(row);\n}\n\nint StatementOperation::bindParameterIndex(const Text &parameterName)\n{\n    GetHandleStatementOrReturnValue(0);\n    return handleStatement->bindParameterIndex(parameterName);\n}\n\nColumnType StatementOperation::getType(int index)\n{\n    GetHandleStatementOrReturnValue(ColumnType::Null);\n    return handleStatement->getType(index);\n}\n\nint StatementOperation::getNumberOfColumns()\n{\n    GetHandleStatementOrReturnValue(0);\n    return handleStatement->getNumberOfColumns();\n}\n\nStatementOperation::Integer StatementOperation::getInteger(int index)\n{\n    GetHandleStatementOrReturnValue(0);\n    return handleStatement->getInteger(index);\n}\n\nStatementOperation::Float StatementOperation::getDouble(int index)\n{\n    GetHandleStatementOrReturnValue(0);\n    return handleStatement->getDouble(index);\n}\n\nStatementOperation::Text StatementOperation::getText(int index)\n{\n    GetHandleStatementOrReturnValue(StatementOperation::Text());\n    return handleStatement->getText(index);\n}\n\nconst StatementOperation::BLOB StatementOperation::getBLOB(int index)\n{\n    GetHandleStatementOrReturnValue(StatementOperation::BLOB());\n    return handleStatement->getBLOB(index);\n}\n\nValue StatementOperation::getValue(int index)\n{\n    GetHandleStatementOrReturnValue(0);\n    return handleStatement->getValue(index);\n}\n\nOptionalOneColumn StatementOperation::getOneColumn(int index)\n{\n    GetHandleStatementOrReturnValue(OptionalOneColumn());\n    return handleStatement->getOneColumn(index);\n}\n\nOneRowValue StatementOperation::getOneRow()\n{\n    GetHandleStatementOrReturnValue(OneRowValue());\n    return handleStatement->getOneRow();\n}\n\nOptionalMultiRows StatementOperation::getAllRows()\n{\n    GetHandleStatementOrReturnValue(OptionalMultiRows());\n    return handleStatement->getAllRows();\n}\n\nMultiObject StatementOperation::extractOneMultiObject(const ResultFields &resultFields)\n{\n    MultiObject result;\n    GetHandleStatementOrReturnValue(result);\n    int index = 0;\n    for (const ResultField &field : resultFields) {\n        const UnsafeStringView table = getColumnTableName(index);\n        result.addField(table, field, getValue(index));\n        ++index;\n    }\n    return result;\n}\n\nOptionalMultiObjectArray\nStatementOperation::extractAllMultiObjects(const ResultFields &resultFields)\n{\n    OptionalMultiObjectArray result;\n    bool succeed = false;\n    while ((succeed = step()) && !done()) {\n        if (!result.succeed()) {\n            result = ValueArray<MultiObject>();\n        }\n        result->push_back(extractOneMultiObject(resultFields));\n    }\n    return succeed && !result.hasValue() ? ValueArray<MultiObject>() : result;\n}\n\nconst UnsafeStringView StatementOperation::getOriginColumnName(int index)\n{\n    GetHandleStatementOrReturnValue(UnsafeStringView());\n    return handleStatement->getOriginColumnName(index);\n}\n\nconst UnsafeStringView StatementOperation::getColumnName(int index)\n{\n    GetHandleStatementOrReturnValue(UnsafeStringView());\n    return handleStatement->getColumnName(index);\n}\n\nconst UnsafeStringView StatementOperation::getColumnTableName(int index)\n{\n    GetHandleStatementOrReturnValue(UnsafeStringView());\n    return handleStatement->getColumnTableName(index);\n}\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/cpp/Operation/StatementOperation.hpp",
    "content": "//\n// Created by qiuwenchen on 2022/8/11.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n#include \"CPPDeclaration.h\"\n#include \"MultiObject.hpp\"\n#include \"Statement.hpp\"\n#include \"Value.hpp\"\n\nnamespace WCDB {\n\nclass WCDB_API StatementOperation {\npublic:\n#pragma mark - Basic\n    /**\n     @brief Use `sqlite3_prepare` internally to prepare a new statement.\n     @warning You should firstly use `StatementOperation::finalize()` to finalize the previous statement prepared by `StatementOperation::prepare()`. If you need to prepare multiple statements at the same time, `Handle::getOrCreatePreparedStatement()` is recommended.\n     @see   `Handle::getOrCreatePreparedStatement()`\n     @return True if no error occurs.\n     */\n    bool prepare(const Statement& statement);\n\n    /**\n     @brief Check if there is a statement previously prepared by `StatementOperation::prepare()`.\n     @return True if there is a prepared statement.\n     */\n    bool isPrepared();\n\n    /**\n     @brief Finalize the statement previously prepared by `StatementOperation::prepare()`.\n     @warning You should finalize the previously prepared statement before use a new statement.\n     */\n    void finalize();\n\n    /**\n     It is a wrapper for `sqlite3_step`.\n     @warning Not Thread-safe.\n     @return True if no error occurs.\n     */\n    bool step();\n\n    /**\n     @brief Check if you can continue stepping.\n     @return True if you can continue stepping.\n     */\n    bool done();\n\n    /**\n     @brief The wrapper of `sqlite3_reset`.\n     */\n    void reset();\n\n    /**\n     @brief The wrapper of `sqlite3_clear_bindings`.\n     */\n    void clearBindings();\n\n    /**\n     @brief The wrapper of `sqlite3_stmt_readonly`.\n     */\n    bool isReadOnly();\n\n#pragma mark - Bind Value\n    using Integer = ColumnTypeInfo<ColumnType::Integer>::UnderlyingType;\n    using Text = ColumnTypeInfo<ColumnType::Text>::UnderlyingType;\n    using Float = ColumnTypeInfo<ColumnType::Float>::UnderlyingType;\n    using BLOB = ColumnTypeInfo<ColumnType::BLOB>::UnderlyingType;\n\n    /**\n     @brief The wrapper of `sqlite3_bind_int64`.\n     */\n    void bindInteger(const Integer& value, int index = 1);\n\n    /**\n     @brief The wrapper of `sqlite3_bind_double`.\n     */\n    void bindDouble(const Float& value, int index = 1);\n\n    /**\n     @brief The wrapper of `sqlite3_bind_text`.\n     */\n    void bindText(const Text& value, int index = 1);\n\n    /**\n     @brief The wrapper of `sqlite3_bind_blob`.\n     */\n    void bindBLOB(const BLOB& value, int index = 1);\n\n    /**\n     @brief The wrapper of `sqlite3_bind_null`.\n     */\n    void bindNull(int index = 1);\n\n    /**\n     @brief The wrapper of `sqlite3_bind_parameter_index`.\n     */\n    int bindParameterIndex(const Text& parameterName);\n\n    /**\n     @brief The wrapper of `sqlite3_bind_*`.\n     It will call the appropriate routine according to the column type returned by `Value::getType()`.\n     @param value A value wrapping the type.\n     @see   `WCDB::Value`\n     */\n    void bindValue(const Value& value, int index = 1);\n\n    /**\n     @brief The wrapper of `sqlite3_bind_*` for binding an array of value.\n     It will call the appropriate routine according to the column type returned by `Value::getType()`.\n     @param row An array of value.\n     @see   `WCDB::Value`\n     */\n    void bindRow(const OneRowValue& row);\n\n    /**\n     @brief The wrapper of `sqlite3_bind_*` for binding property of object to index.\n     It will call the appropriate routine according to the data type of property.\n     */\n    template<class ObjectType>\n    void bindObject(const ObjectType& obj, const Field& field, int index = 1)\n    {\n        WCDB_CPP_ORM_STATIC_ASSERT_FOR_OBJECT_TYPE\n        const BaseAccessor* accessor = field.getAccessor();\n        switch (accessor->getColumnType()) {\n        case ColumnType::Integer: {\n            auto intAccessor\n            = static_cast<const Accessor<ObjectType, ColumnType::Integer>*>(accessor);\n            if (!intAccessor->isNull(obj)) {\n                bindInteger(intAccessor->getValue(obj), index);\n            } else {\n                bindNull(index);\n            }\n        } break;\n        case ColumnType::Float: {\n            auto floatAccessor\n            = static_cast<const Accessor<ObjectType, ColumnType::Float>*>(accessor);\n            if (!floatAccessor->isNull(obj)) {\n                bindDouble(floatAccessor->getValue(obj), index);\n            } else {\n                bindNull(index);\n            }\n        } break;\n        case ColumnType::Text: {\n            auto textAccessor\n            = static_cast<const Accessor<ObjectType, ColumnType::Text>*>(accessor);\n            if (!textAccessor->isNull(obj)) {\n                bindText(textAccessor->getValue(obj), index);\n            } else {\n                bindNull(index);\n            }\n        } break;\n        case ColumnType::BLOB: {\n            auto blobAccessor\n            = static_cast<const Accessor<ObjectType, ColumnType::BLOB>*>(accessor);\n            if (!blobAccessor->isNull(obj)) {\n                bindBLOB(blobAccessor->getValue(obj), index);\n            } else {\n                bindNull(index);\n            }\n        } break;\n        default:\n            assert(0);\n            break;\n        }\n    }\n\n    /**\n     @brief The wrapper of `sqlite3_bind_*` for binding the specified properties of object.\n     It will call the appropriate routine according to the data type of properties.\n     */\n    template<class ObjectType>\n    void bindObject(const ObjectType& obj, const Fields& fields)\n    {\n        int index = 1;\n        for (const Field& field : fields) {\n            bindObject(obj, field, index);\n            index++;\n        }\n    }\n\n#pragma mark - Extract Column meta\n    /**\n     @brief The wrapper of `sqlite3_column_type`.\n     */\n    ColumnType getType(int index = 0);\n\n    /**\n     @brief The wrapper of `sqlite3_column_count`.\n     */\n    int getNumberOfColumns();\n\n    /**\n     @brief The wrapper of `sqlite3_column_origin_name`.\n     */\n    const UnsafeStringView getOriginColumnName(int index);\n\n    /**\n     @brief The wrapper of `sqlite3_column_name`.\n     */\n    const UnsafeStringView getColumnName(int index);\n\n    /**\n     @brief The wrapper of `sqlite3_column_table_name`.\n     */\n    const UnsafeStringView getColumnTableName(int index);\n\n#pragma mark - Extract Row data\n    /**\n     @brief The wrapper of `sqlite3_column_int64`.\n     */\n    Integer getInteger(int index = 0);\n\n    /**\n     @brief The wrapper of `sqlite3_column_double`.\n     */\n    Float getDouble(int index = 0);\n\n    /**\n     @brief The wrapper of `sqlite3_column_text`.\n     */\n    Text getText(int index = 0);\n\n    /**\n     @brief The wrapper of `sqlite3_column_blob`.\n     */\n    const BLOB getBLOB(int index = 0);\n\n    /**\n     @brief The wrapper of `sqlite3_column_*`.\n     */\n    Value getValue(int index = 0);\n\n    /**\n     @brief Extract all values of current row.\n     @return An array of value.\n     */\n    OneRowValue getOneRow();\n\n    /**\n     @brief Extract the values of the current row and assign them into the fields specified by resultFields of a new object.\n     @return An object.\n     */\n    template<class ObjectType>\n    ObjectType extractOneObject(const ResultFields& resultFields)\n    {\n        WCDB_CPP_ORM_STATIC_ASSERT_FOR_OBJECT_TYPE\n        ObjectType obj;\n        int index = 0;\n        for (const ResultField& field : resultFields) {\n            const BaseAccessor* accessor = field.getAccessor();\n            bool notNull = getType(index) != ColumnType::Null;\n            switch (accessor->getColumnType()) {\n            case ColumnType::Integer: {\n                auto intAccessor\n                = static_cast<const Accessor<ObjectType, ColumnType::Integer>*>(accessor);\n                if (notNull) {\n                    intAccessor->setValue(obj, getInteger(index));\n                } else {\n                    intAccessor->setNull(obj);\n                }\n            } break;\n            case ColumnType::Float: {\n                auto floatAccessor\n                = static_cast<const Accessor<ObjectType, ColumnType::Float>*>(accessor);\n                if (notNull) {\n                    floatAccessor->setValue(obj, getDouble(index));\n                } else {\n                    floatAccessor->setNull(obj);\n                }\n            } break;\n            case ColumnType::Text: {\n                auto textAccessor\n                = static_cast<const Accessor<ObjectType, ColumnType::Text>*>(accessor);\n                if (notNull) {\n                    textAccessor->setValue(obj, getText(index));\n                } else {\n                    textAccessor->setNull(obj);\n                }\n            } break;\n            case ColumnType::BLOB: {\n                auto blobAccessor\n                = static_cast<const Accessor<ObjectType, ColumnType::BLOB>*>(accessor);\n                if (notNull) {\n                    blobAccessor->setValue(obj, getBLOB(index));\n                } else {\n                    blobAccessor->setNull(obj);\n                }\n            } break;\n            default:\n                assert(0);\n                break;\n            }\n            index++;\n        }\n        return obj;\n    }\n\n    /**\n     @brief Extract the results of a multi-table query in the current row.\n     @return A `WCDB::MultiObject` containing the result of multi-table.\n     @see   `WCDB::MultiObject`\n     */\n    MultiObject extractOneMultiObject(const ResultFields& resultFields);\n\n#pragma mark - Step And Extract All Data\n    /**\n     @brief Extract all the values of the column of index in the result.\n     @return An array of Value.\n     */\n    OptionalOneColumn getOneColumn(int index = 0);\n\n    /**\n     @brief Extract all the values in the result.\n     @return A two-dimensional array.\n     */\n    OptionalMultiRows getAllRows();\n\n    /**\n     @brief Extract the values of all rows in the result and assign them into the fields specified by resultFields of new objects.\n     @return An array of objects.\n     */\n    template<class ObjectType>\n    OptionalValueArray<ObjectType> extractAllObjects(const ResultFields& resultFields)\n    {\n        OptionalValueArray<ObjectType> result;\n        bool succeed = step();\n        while (succeed && !done()) {\n            if (!result.succeed()) {\n                result = ValueArray<ObjectType>();\n            }\n            result->push_back(extractOneObject<ObjectType>(resultFields));\n            succeed = step();\n        }\n        if (!succeed) {\n            return NullOpt;\n        }\n        return !result.hasValue() ? ValueArray<ObjectType>() : result;\n    }\n\n    /**\n     @brief Extract the results of a multi-table query.\n     @return An array of `WCDB::MultiObject`.\n     */\n    OptionalMultiObjectArray extractAllMultiObjects(const ResultFields& resultFields);\n\nprotected:\n    virtual ~StatementOperation() = 0;\n    virtual HandleStatement* getInnerHandleStatement() = 0;\n};\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/cpp/Operation/TableORMOperation.hpp",
    "content": "//\n// Created by qiuwenchen on 2022/9/2.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n#include \"CPPDeclaration.h\"\n#include \"CPPORM.h\"\n#include \"Delete.hpp\"\n#include \"RecyclableHandle.hpp\"\n#include \"TableOperation.hpp\"\n#include \"Value.hpp\"\n\nnamespace WCDB {\n\ntemplate<class ObjectType>\nclass TableORMOperation : public TableOperation {\npublic:\n#pragma mark - ChainCall\n    /**\n     @brief Generate a `WCDB::Insert` to do an insertion or replacement.\n     */\n    Insert<ObjectType> prepareInsert()\n    {\n        return Insert<ObjectType>(getDatabaseHolder()).intoTable(getTableName());\n    }\n\n    /**\n     @brief Generate a `WCDB::Delete` to do a deletion.\n     */\n    Delete prepareDelete()\n    {\n        return Delete(getDatabaseHolder()).fromTable(getTableName());\n    }\n\n    /**\n     @brief Generate a `WCDB::Update` to do an update.\n     */\n    Update<ObjectType> prepareUpdate()\n    {\n        return Update<ObjectType>(getDatabaseHolder()).table(getTableName());\n    }\n\n    /**\n     @brief Generate a `WCDB::Select` to do an object selection.\n     */\n    Select<ObjectType> prepareSelect()\n    {\n        return Select<ObjectType>(getDatabaseHolder()).fromTable(getTableName());\n    }\n\n#pragma mark - Insert\n    /**\n     @brief Execute inserting with one object on specific(or all) fields. otherwise it will be executed within the existing transaction.\n     @return True if no error occurs.\n     */\n    bool insertObject(const ObjectType &obj, const Fields &fields = Fields())\n    {\n        auto insert = prepareInsert().value(obj);\n        if (fields.size() > 0) {\n            insert.onFields(fields);\n        }\n        return insert.execute();\n    }\n\n    /**\n     @brief Execute inserting with multi objects on specific(or all) fields.\n     @note  It will run embedded transaction while objs.size>1. The embedded transaction means that it will run a transaction if it's not in other transaction, otherwise it will be executed within the existing transaction.\n     @return True if no error occurs.\n     */\n    bool insertObjects(const ValueArray<ObjectType> &objs, const Fields &fields = Fields())\n    {\n        if (objs.size() == 0) {\n            return true;\n        }\n        auto insert = prepareInsert().values(objs);\n        if (fields.size() > 0) {\n            insert.onFields(fields);\n        }\n        return insert.execute();\n    }\n\n    /**\n     @brief Execute inserting with multi objects on specific(or all) fields.\n     @note  It will run embedded transaction while objs.size>1. The embedded transaction means that it will run a transaction if it's not in other transaction, otherwise it will be executed within the existing transaction.\n     @return True if no error occurs.\n     */\n    bool insertObjects(const ValueArray<ObjectType *> &objs, const Fields &fields = Fields())\n    {\n        if (objs.size() == 0) {\n            return true;\n        }\n        auto insert = prepareInsert().values(objs);\n        if (fields.size() > 0) {\n            insert.onFields(fields);\n        }\n        return insert.execute();\n    }\n\n    /**\n     @brief Execute inserting with multi objects on specific(or all) fields.\n     @note  It will run embedded transaction while objs.size>1. The embedded transaction means that it will run a transaction if it's not in other transaction, otherwise it will be executed within the existing transaction.\n     @return True if no error occurs.\n     */\n    bool insertObjects(const ValueArray<std::shared_ptr<ObjectType>> &objs,\n                       const Fields &fields = Fields())\n    {\n        if (objs.size() == 0) {\n            return true;\n        }\n        auto insert = prepareInsert().values(objs);\n        if (fields.size() > 0) {\n            insert.onFields(fields);\n        }\n        return insert.execute();\n    }\n\n    /**\n     @brief Execute inserting with one object on specific(or all) fields.\n     It will replace the original row while they have same primary key or row id.\n     @return True if no error occurs.\n     */\n    bool insertOrReplaceObject(const ObjectType &obj, const Fields &fields = Fields())\n    {\n        auto insert = prepareInsert().orReplace().value(obj);\n        if (fields.size() > 0) {\n            insert.onFields(fields);\n        }\n        return insert.execute();\n    }\n\n    /**\n     @brief Execute inserting with multi objects on specific(or all) fields.\n     It will replace the original row while they have same primary key or row id.\n     @note  It will run embedded transaction while objs.size>1. The embedded transaction means that it will run a transaction if it's not in other transaction, otherwise it will be executed within the existing transaction.\n     @return True if no error occurs.\n     */\n    bool insertOrReplaceObjects(const ValueArray<ObjectType> &objs,\n                                const Fields &fields = Fields())\n    {\n        if (objs.size() == 0) {\n            return true;\n        }\n        auto insert = prepareInsert().orReplace().values(objs);\n        if (fields.size() > 0) {\n            insert.onFields(fields);\n        }\n        return insert.execute();\n    }\n\n    /**\n     @brief Execute inserting with multi objects on specific(or all) fields.\n     It will replace the original row while they have same primary key or row id.\n     @note  It will run embedded transaction while objs.size>1. The embedded transaction means that it will run a transaction if it's not in other transaction, otherwise it will be executed within the existing transaction.\n     @return True if no error occurs.\n     */\n    bool insertOrReplaceObjects(const ValueArray<ObjectType *> &objs,\n                                const Fields &fields = Fields())\n    {\n        if (objs.size() == 0) {\n            return true;\n        }\n        auto insert = prepareInsert().orReplace().values(objs);\n        if (fields.size() > 0) {\n            insert.onFields(fields);\n        }\n        return insert.execute();\n    }\n\n    /**\n     @brief Execute inserting with multi objects on specific(or all) fields.\n     It will replace the original row while they have same primary key or row id.\n     @note  It will run embedded transaction while objs.size>1. The embedded transaction means that it will run a transaction if it's not in other transaction, otherwise it will be executed within the existing transaction.\n     @return True if no error occurs.\n     */\n    bool insertOrReplaceObjects(const ValueArray<std::shared_ptr<ObjectType>> &objs,\n                                const Fields &fields = Fields())\n    {\n        if (objs.size() == 0) {\n            return true;\n        }\n        auto insert = prepareInsert().orReplace().values(objs);\n        if (fields.size() > 0) {\n            insert.onFields(fields);\n        }\n        return insert.execute();\n    }\n\n    /**\n     @brief Execute inserting with one object on specific(or all) fields.\n     It will ignore the object while there already exists the same primary key or row id in current table.\n     @return True if no error occurs.\n     */\n    bool insertOrIgnoreObject(const ObjectType &obj, const Fields &fields = Fields())\n    {\n        auto insert = prepareInsert().orIgnore().value(obj);\n        if (fields.size() > 0) {\n            insert.onFields(fields);\n        }\n        return insert.execute();\n    }\n\n    /**\n     @brief Execute inserting with multi objects on specific(or all) fields.\n     It will ignore the object while there already exists the same primary key or row id in current table.\n     @note  It will run embedded transaction while objs.size>1. The embedded transaction means that it will run a transaction if it's not in other transaction, otherwise it will be executed within the existing transaction.\n     @return True if no error occurs.\n     */\n    bool insertOrIgnoreObjects(const ValueArray<ObjectType> &objs,\n                               const Fields &fields = Fields())\n    {\n        if (objs.size() == 0) {\n            return true;\n        }\n        auto insert = prepareInsert().orIgnore().values(objs);\n        if (fields.size() > 0) {\n            insert.onFields(fields);\n        }\n        return insert.execute();\n    }\n\n    /**\n     @brief Execute inserting with multi objects on specific(or all) fields.\n     It will ignore the object while there already exists the same primary key or row id in current table.\n     @note  It will run embedded transaction while objs.size>1. The embedded transaction means that it will run a transaction if it's not in other transaction, otherwise it will be executed within the existing transaction.\n     @return True if no error occurs.\n     */\n    bool insertOrIgnoreObjects(const ValueArray<ObjectType *> &objs,\n                               const Fields &fields = Fields())\n    {\n        if (objs.size() == 0) {\n            return true;\n        }\n        auto insert = prepareInsert().orIgnore().values(objs);\n        if (fields.size() > 0) {\n            insert.onFields(fields);\n        }\n        return insert.execute();\n    }\n\n    /**\n     @brief Execute inserting with multi objects on specific(or all) fields.\n     It will ignore the object while there already exists the same primary key or row id in current table.\n     @note  It will run embedded transaction while objs.size>1. The embedded transaction means that it will run a transaction if it's not in other transaction, otherwise it will be executed within the existing transaction.\n     @return True if no error occurs.\n     */\n    bool insertOrIgnoreObjects(const ValueArray<std::shared_ptr<ObjectType>> &objs,\n                               const Fields &fields = Fields())\n    {\n        if (objs.size() == 0) {\n            return true;\n        }\n        auto insert = prepareInsert().orIgnore().values(objs);\n        if (fields.size() > 0) {\n            insert.onFields(fields);\n        }\n        return insert.execute();\n    }\n\n#pragma mark - Delete\n    /**\n     @brief Execute deleting.\n     @return True if no error occurs.\n     */\n    bool deleteObjects(const Expression &where = Expression(),\n                       const OrderingTerms &orders = OrderingTerms(),\n                       const Expression &limit = Expression())\n    {\n        auto delete_ = prepareDelete();\n        configStatement(delete_, where, orders, limit, Expression());\n        return delete_.execute();\n    }\n\n#pragma mark - Update\n    /**\n     @brief Execute updating with object on specific(or all) fields.\n     @return True if no error occurs.\n     */\n    bool updateObject(const ObjectType &obj,\n                      const Fields &fields,\n                      const Expression &where = Expression(),\n                      const OrderingTerms &orders = OrderingTerms(),\n                      const Expression &limit = Expression(),\n                      const Expression &offset = Expression())\n    {\n        auto update = prepareUpdate().set(fields).toObject(&obj);\n        configStatement(update, where, orders, limit, offset);\n        return update.execute();\n    }\n\n#pragma mark - Select\n    /**\n     @brief Get an object by specific selecting.\n     */\n    Optional<ObjectType> getFirstObject(const Expression &where = Expression(),\n                                        const OrderingTerms &orders = OrderingTerms(),\n                                        const Expression &offset = Expression())\n    {\n        auto select = prepareSelect();\n        configStatement(select, where, orders, Expression(1), offset);\n        return select.firstObject();\n    }\n\n    /**\n     @brief Get an object on specific fields by specific selecting.\n     */\n    Optional<ObjectType>\n    getFirstObjectWithFields(const ResultFields &resultFields,\n                             const Expression &where = Expression(),\n                             const OrderingTerms &orders = OrderingTerms(),\n                             const Expression &offset = Expression())\n    {\n        auto select = prepareSelect().onResultFields(resultFields);\n        configStatement(select, where, orders, Expression(1), offset);\n        return select.firstObject();\n    }\n\n    /**\n     @brief Get objects by specific selecting.\n     */\n    OptionalValueArray<ObjectType>\n    getAllObjects(const Expression &where = Expression(),\n                  const OrderingTerms &orders = OrderingTerms(),\n                  const Expression &limit = Expression(),\n                  const Expression &offset = Expression())\n    {\n        auto select = prepareSelect();\n        configStatement(select, where, orders, limit, offset);\n        return select.allObjects();\n    }\n\n    /**\n     @brief Get objects on specific fields by specific selecting.\n     */\n    OptionalValueArray<ObjectType>\n    getAllObjectsWithFields(const ResultFields &resultFields,\n                            const Expression &where = Expression(),\n                            const OrderingTerms &orders = OrderingTerms(),\n                            const Expression &limit = Expression(),\n                            const Expression &offset = Expression())\n    {\n        auto select = prepareSelect().onResultFields(resultFields);\n        configStatement(select, where, orders, limit, offset);\n        return select.allObjects();\n    }\n\nprotected:\n    virtual ~TableORMOperation() override = default;\n};\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/cpp/Operation/TableOperation.cpp",
    "content": "//\n// Created by qiuwenchen on 2022/9/2.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"TableOperation.hpp\"\n#include \"Assertion.hpp\"\n#include \"Handle.hpp\"\n#include \"InnerHandle.hpp\"\n\n#define GetHandleOrReturnValue(writeHint, value)                               \\\n    RecyclableHandle handle = getHandleHolder(writeHint);                      \\\n    if (handle == nullptr) {                                                   \\\n        return value;                                                          \\\n    }\n\nnamespace WCDB {\n\nTableOperation::~TableOperation() = default;\n\nbool TableOperation::insertRows(const MultiRowsValue &rows, const Columns &columns)\n{\n    auto insertAction = [&](Handle &handle) {\n        StatementInsert insert = StatementInsert()\n                                 .insertIntoTable(getTableName())\n                                 .columns(columns)\n                                 .values(BindParameter::bindParameters(columns.size()));\n        if (!handle.prepare(insert)) {\n            assignErrorToDatabase(handle.getError());\n            return false;\n        }\n        for (const OneRowValue &row : rows) {\n            WCTRemedialAssert(columns.size() == row.size(),\n                              \"Number of values is not equal to number of columns\",\n                              handle.finalize();\n                              return false;) handle.reset();\n            handle.bindRow(row);\n            if (!handle.step()) {\n                assignErrorToDatabase(handle.getError());\n                handle.finalize();\n                return false;\n            }\n        }\n        handle.finalize();\n        return true;\n    };\n    GetHandleOrReturnValue(true, false);\n    Handle newHandle = Handle(handle);\n    if (rows.size() == 0) {\n        return true;\n    } else if (rows.size() == 1) {\n        return insertAction(newHandle);\n    } else {\n        bool succeed = newHandle.lazyRunTransaction(insertAction);\n        if (!succeed) {\n            assignErrorToDatabase(newHandle.getError());\n        }\n        return succeed;\n    }\n}\n\nbool TableOperation::insertOrReplaceRows(const MultiRowsValue &rows, const Columns &columns)\n{\n    auto insertAction = [&](Handle &handle) {\n        StatementInsert insert = StatementInsert()\n                                 .insertIntoTable(getTableName())\n                                 .orReplace()\n                                 .columns(columns)\n                                 .values(BindParameter::bindParameters(columns.size()));\n        if (!handle.prepare(insert)) {\n            assignErrorToDatabase(handle.getError());\n            return false;\n        }\n        for (const OneRowValue &row : rows) {\n            WCTRemedialAssert(columns.size() == row.size(),\n                              \"Number of values is not equal to number of columns\",\n                              handle.finalize();\n                              return false;) handle.reset();\n            handle.bindRow(row);\n            if (!handle.step()) {\n                assignErrorToDatabase(handle.getError());\n                handle.finalize();\n                return false;\n            }\n        }\n        handle.finalize();\n        return true;\n    };\n    GetHandleOrReturnValue(true, false);\n    Handle newHandle = Handle(handle);\n    if (rows.size() == 0) {\n        return true;\n    } else if (rows.size() == 1) {\n        return insertAction(newHandle);\n    } else {\n        bool succeed = newHandle.lazyRunTransaction(insertAction);\n        if (!succeed) {\n            assignErrorToDatabase(newHandle.getError());\n        }\n        return succeed;\n    }\n}\n\nbool TableOperation::insertOrIgnoreRows(const MultiRowsValue &rows, const Columns &columns)\n{\n    auto insertAction = [&](Handle &handle) {\n        StatementInsert insert = StatementInsert()\n                                 .insertIntoTable(getTableName())\n                                 .orIgnore()\n                                 .columns(columns)\n                                 .values(BindParameter::bindParameters(columns.size()));\n        if (!handle.prepare(insert)) {\n            assignErrorToDatabase(handle.getError());\n            return false;\n        }\n        for (const OneRowValue &row : rows) {\n            WCTRemedialAssert(columns.size() == row.size(),\n                              \"Number of values is not equal to number of columns\",\n                              handle.finalize();\n                              return false;) handle.reset();\n            handle.bindRow(row);\n            if (!handle.step()) {\n                assignErrorToDatabase(handle.getError());\n                handle.finalize();\n                return false;\n            }\n        }\n        handle.finalize();\n        return true;\n    };\n    GetHandleOrReturnValue(true, false);\n    Handle newHandle = Handle(handle);\n    if (rows.size() == 0) {\n        return true;\n    } else if (rows.size() == 1) {\n        return insertAction(newHandle);\n    } else {\n        bool succeed = newHandle.lazyRunTransaction(insertAction);\n        if (!succeed) {\n            assignErrorToDatabase(newHandle.getError());\n        }\n        return succeed;\n    }\n}\n\nbool TableOperation::updateRow(const OneRowValue &row,\n                               const Columns &columns,\n                               const Expression &where,\n                               const OrderingTerms &orders,\n                               const Expression &limit,\n                               const Expression &offset)\n{\n    WCTRemedialAssert(columns.size() > 0, \"Number of columns can not be zero\", return false;)\n    WCTRemedialAssert(columns.size() == row.size(),\n                      \"Number of values in this row is not equal to number of columns\",\n                      return false;) StatementUpdate update\n    = StatementUpdate().update(getTableName());\n    for (int i = 0; i < columns.size(); i++) {\n        update.set(columns[i]).to(WCDB::BindParameter(i + 1));\n    }\n    configStatement(update, where, orders, limit, offset);\n    GetHandleOrReturnValue(true, false);\n    bool succeed = false;\n    if ((succeed = handle->prepare(update))) {\n        handle->bindRow(row);\n        succeed = handle->step();\n        handle->finalize();\n    }\n    if (!succeed) {\n        assignErrorToDatabase(handle->getError());\n    }\n    return succeed;\n}\n\nbool TableOperation::deleteValues(const Expression &where,\n                                  const OrderingTerms &orders,\n                                  const Expression &limit,\n                                  const Expression &offset)\n{\n    StatementDelete delete_ = StatementDelete().deleteFrom(getTableName());\n    configStatement(delete_, where, orders, limit, offset);\n    GetHandleOrReturnValue(true, false);\n    bool succeed = handle->execute(delete_);\n    if (!succeed) {\n        assignErrorToDatabase(handle->getError());\n    }\n    return succeed;\n}\n\nOptionalValue TableOperation::selectValue(const ResultColumn &column,\n                                          const Expression &where,\n                                          const OrderingTerms &orders,\n                                          const Expression &offset)\n{\n    auto select = StatementSelect().select(column).from(getTableName());\n    configStatement(select, where, orders, Expression(1), offset);\n    return getValueFromStatement(select);\n}\n\nOptionalOneColumn TableOperation::selectOneColumn(const ResultColumn &column,\n                                                  const Expression &where,\n                                                  const OrderingTerms &orders,\n                                                  const Expression &limit,\n                                                  const Expression &offset)\n{\n    auto select = StatementSelect().select(column).from(getTableName());\n    configStatement(select, where, orders, limit, offset);\n    return getOneColumnFromStatement(select);\n}\n\nOptionalOneRow TableOperation::selectOneRow(const ResultColumns &columns,\n                                            const Expression &where,\n                                            const OrderingTerms &orders,\n                                            const Expression &offset)\n{\n    auto select = StatementSelect().select(columns).from(getTableName());\n    configStatement(select, where, orders, Expression(1), offset);\n    return getOneRowFromStatement(select);\n}\n\nOptionalMultiRows TableOperation::selectAllRow(const ResultColumns &columns,\n                                               const Expression &where,\n                                               const OrderingTerms &orders,\n                                               const Expression &limit,\n                                               const Expression &offset)\n{\n    auto select = StatementSelect().select(columns).from(getTableName());\n    configStatement(select, where, orders, limit, offset);\n    return getAllRowsFromStatement(select);\n}\n\nOptionalValue TableOperation::getValueFromStatement(const Statement &statement, int index)\n{\n    OptionalValue result;\n    GetHandleOrReturnValue(false, result);\n    if (!handle->prepare(statement)) {\n        assignErrorToDatabase(handle->getError());\n        return result;\n    }\n    bool succeed = false;\n    if ((succeed = handle->step()) && !handle->done()) {\n        result = handle->getValue(index);\n    }\n    handle->finalize();\n    if (!succeed) {\n        assignErrorToDatabase(handle->getError());\n    }\n    return result;\n}\n\nOptionalOneColumn\nTableOperation::getOneColumnFromStatement(const Statement &statement, int index)\n{\n    OptionalOneColumn result;\n    GetHandleOrReturnValue(false, result);\n\n    if (!handle->prepare(statement)) {\n        assignErrorToDatabase(handle->getError());\n        return result;\n    }\n    result = handle->getOneColumn(index);\n    handle->finalize();\n    if (!result.succeed()) {\n        assignErrorToDatabase(handle->getError());\n    }\n    return result;\n}\n\nOptionalOneRow TableOperation::getOneRowFromStatement(const Statement &statement)\n{\n    OptionalOneRow result;\n    GetHandleOrReturnValue(false, result);\n    if (!handle->prepare(statement)) {\n        assignErrorToDatabase(handle->getError());\n        return result;\n    }\n    bool succeed = false;\n    if ((succeed = handle->step()) && !handle->done()) {\n        result = handle->getOneRow();\n    }\n    handle->finalize();\n    if (!succeed) {\n        assignErrorToDatabase(handle->getError());\n    }\n    return result;\n}\n\nOptionalMultiRows TableOperation::getAllRowsFromStatement(const Statement &statement)\n{\n    OptionalMultiRows result;\n    GetHandleOrReturnValue(false, false);\n    if (!handle->prepare(statement)) {\n        assignErrorToDatabase(handle->getError());\n        return result;\n    }\n    result = handle->getAllRows();\n    handle->finalize();\n    if (!result.succeed()) {\n        assignErrorToDatabase(handle->getError());\n    }\n    return result;\n}\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/cpp/Operation/TableOperation.hpp",
    "content": "//\n// Created by qiuwenchen on 2022/9/2.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n#include \"BaseOperation.hpp\"\n#include \"Value.hpp\"\n\nnamespace WCDB {\n\nclass WCDB_API TableOperation : public BaseOperation {\n#pragma mark - Insert\npublic:\n    /**\n     @brief Execute inserting with multi rows of values.\n     @note  It will run embedded transaction while rows.size>1. The embedded transaction means that it will run a transaction if it's not in other transaction, otherwise it will be executed within the existing transaction.\n     @return True if no error occurs.\n     */\n    bool insertRows(const MultiRowsValue &rows, const Columns &columns);\n\n    /**\n     @brief Execute inserting with multi rows of values.\n     It will replace the original row while they have same primary key or row id.\n     @note  It will run embedded transaction while rows.size>1. The embedded transaction means that it will run a transaction if it's not in other transaction, otherwise it will be executed within the existing transaction.\n     @return True if no error occurs.\n     */\n    bool insertOrReplaceRows(const MultiRowsValue &rows, const Columns &columns);\n\n    /**\n     @brief Execute inserting with multi rows of values.\n     It will ignore the row while there already exists the same primary key or row id in current table.\n     @note  It will run embedded transaction while rows.size>1. The embedded transaction means that it will run a transaction if it's not in other transaction, otherwise it will be executed within the existing transaction.\n     @return True if no error occurs.\n     */\n    bool insertOrIgnoreRows(const MultiRowsValue &rows, const Columns &columns);\n\n#pragma mark - Update\npublic:\n    /**\n     @brief Execute updating with one row of values.\n     @return True if no error occurs.\n     */\n    bool updateRow(const OneRowValue &row,\n                   const Columns &columns,\n                   const Expression &where = Expression(),\n                   const OrderingTerms &orders = OrderingTerms(),\n                   const Expression &limit = Expression(),\n                   const Expression &offset = Expression());\n\n#pragma mark - delete\npublic:\n    /**\n     @brief Execute deleting.\n     @return True if no error occurs.\n     */\n    bool deleteValues(const Expression &where = Expression(),\n                      const OrderingTerms &orders = OrderingTerms(),\n                      const Expression &limit = Expression(),\n                      const Expression &offset = Expression());\n\n#pragma mark - Select\npublic:\n    /**\n     @brief Get one value by specific selecting.\n     */\n    OptionalValue selectValue(const ResultColumn &column,\n                              const Expression &where = Expression(),\n                              const OrderingTerms &orders = OrderingTerms(),\n                              const Expression &offset = Expression());\n\n    /**\n     @brief Get  one column of values by specific selecting.\n     */\n    OptionalOneColumn selectOneColumn(const ResultColumn &column,\n                                      const Expression &where = Expression(),\n                                      const OrderingTerms &orders = OrderingTerms(),\n                                      const Expression &offset = Expression(),\n                                      const Expression &limit = Expression());\n\n    /**\n     @brief Get  one row of values by specific selecting.\n     */\n    OptionalOneRow selectOneRow(const ResultColumns &columns,\n                                const Expression &where = Expression(),\n                                const OrderingTerms &orders = OrderingTerms(),\n                                const Expression &offset = Expression());\n\n    /**\n     @brief Get  all row of values by specific selecting.\n     */\n    OptionalMultiRows selectAllRow(const ResultColumns &columns,\n                                   const Expression &where = Expression(),\n                                   const OrderingTerms &orders = OrderingTerms(),\n                                   const Expression &limit = Expression(),\n                                   const Expression &offset = Expression());\n\n#pragma mark - Statement\npublic:\n    /**\n     @brief Get one value from specific statement.\n     @param statement The statement to execute.\n     @param index The index of result column, starting from 0.\n     @return A value.\n     */\n    OptionalValue getValueFromStatement(const Statement &statement, int index = 0);\n\n    /**\n     @brief Get one column of value from specific statement.\n     @param statement The statement to execute.\n     @param index The index of result column, starting from 0.\n     @return A value array.\n     */\n    OptionalOneRow getOneColumnFromStatement(const Statement &statement, int index = 0);\n\n    /**\n     @brief Get one row of value from specific statement.\n     @param statement The statement to execute.\n     @return A value array.\n     */\n    OptionalOneRow getOneRowFromStatement(const Statement &statement);\n\n    /**\n     @brief Get all rows of value from specific statement.\n     @param statement The statement to execute.\n     @return Two-dimensional array of values.\n     */\n    OptionalMultiRows getAllRowsFromStatement(const Statement &statement);\n\nprotected:\n    virtual ~TableOperation() override = 0;\n    virtual const StringView &getTableName() const = 0;\n};\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/cpp/WCDBCpp.h",
    "content": "//\n// Created by qiuwenchen on 2022/8/10.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#ifdef __cplusplus\n#if __cplusplus < 201402L && !defined(_WIN32)\n#error `CLANG_CXX_LANGUAGE_STANDARD = gnu++14` and `CLANG_CXX_LIBRARY = libc++` build settings are required.\n#endif\n#else // __cplusplus\n#error C++ environment is required.\n#endif // __cplusplus\n\n// WCDB may fail to compile since there are few frameworks that define `offset` as a macro.\n#ifdef offset\n#error Symbol `offset` should not be defined as a macro since it's a common used word.\n#endif\n\n#include \"Builtin.h\"\n#include \"CPPORM.h\"\n#include \"CPPORMMacro.h\"\n#include \"CppInterface.h\"\n#include \"WINQ.h\"\n"
  },
  {
    "path": "src/cpp/builtin/Builtin.h",
    "content": "//\n// Created by qiuwenchen on 2022/12/13.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"Master.hpp\"\n#include \"Sequence.hpp\"\n"
  },
  {
    "path": "src/cpp/builtin/Master.cpp",
    "content": "//\n// Created by qiuwenchen on 2022/10/27.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"Master.hpp\"\n\nnamespace WCDB {\n\nconst StringView& Master::tableName = Syntax::masterTable;\n\nWCDB_CPP_ORM_IMPLEMENTATION_BEGIN(Master)\n\nWCDB_CPP_SYNTHESIZE(type)\nWCDB_CPP_SYNTHESIZE(name)\nWCDB_CPP_SYNTHESIZE_COLUMN(tblName, \"tbl_name\")\nWCDB_CPP_SYNTHESIZE(rootpage)\nWCDB_CPP_SYNTHESIZE(sql)\n\nWCDB_CPP_ORM_IMPLEMENTATION_END\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/cpp/builtin/Master.hpp",
    "content": "//\n// Created by qiuwenchen on 2022/10/27.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"CPPORM.h\"\n#include \"CPPORMMacro.h\"\n\nnamespace WCDB {\n\n/**\n Builtin ORM for `sqlite_master` table. For further information, see https://www.sqlite.org/schematab.html .\n */\nclass WCDB_API Master {\npublic:\n    static const StringView& tableName;\n\n    StringView type;\n    StringView name;\n    StringView tblName;\n    int rootpage;\n    StringView sql;\n\n    WCDB_CPP_ORM_DECLARATION(Master);\n};\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/cpp/builtin/Sequence.cpp",
    "content": "//\n// Created by qiuwenchen on 2022/10/27.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"Sequence.hpp\"\n\nnamespace WCDB {\n\nconst StringView& Sequence::tableName = Syntax::sequenceTable;\n\nWCDB_CPP_ORM_IMPLEMENTATION_BEGIN(Sequence)\n\nWCDB_CPP_SYNTHESIZE(name)\nWCDB_CPP_SYNTHESIZE(seq)\n\nWCDB_CPP_ORM_IMPLEMENTATION_END\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/cpp/builtin/Sequence.hpp",
    "content": "//\n// Created by qiuwenchen on 2022/10/27.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"CPPORM.h\"\n#include \"CPPORMMacro.h\"\n\nnamespace WCDB {\n\n/**\n Builtin ORM for `sqlite_sequence` table. For further information, see https://sqlite.org/autoinc.html .\n */\nclass WCDB_API Sequence {\npublic:\n    static const StringView& tableName;\n\n    StringView name;\n    StringView seq;\n\n    WCDB_CPP_ORM_DECLARATION(Sequence);\n};\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/cpp/chaincall/ChainCall.cpp",
    "content": "//\n// Created by qiuwenchen on 2022/8/29.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"ChainCall.hpp\"\n#include \"Assertion.hpp\"\n#include \"Handle.hpp\"\n#include \"InnerHandle.hpp\"\n\nnamespace WCDB {\n\nBaseChainCall::BaseChainCall(Recyclable<InnerDatabase*> databaseHolder)\n: m_handle(std::shared_ptr<Handle>(new Handle(databaseHolder)))\n{\n}\n\nBaseChainCall::BaseChainCall(const BaseChainCall& other)\n: m_handle(other.m_handle) {\n\n};\n\nBaseChainCall::BaseChainCall(BaseChainCall&& other) : m_handle(other.m_handle)\n{\n}\n\nBaseChainCall& BaseChainCall::operator=(const BaseChainCall& other)\n{\n    m_handle = other.m_handle;\n    return *this;\n}\n\nBaseChainCall::~BaseChainCall() = default;\n\nconst Error& BaseChainCall::getError() const\n{\n    return m_error;\n}\n\nint BaseChainCall::getChanges() const\n{\n    return m_changes;\n}\n\nbool BaseChainCall::checkHandle(bool writeHint)\n{\n    return m_handle->getOrGenerateHandle(writeHint) != nullptr;\n}\n\nvoid BaseChainCall::saveChangesAndError(bool succeed)\n{\n    m_changes = m_handle->getChanges();\n    if (!succeed) {\n        m_error = m_handle->getError();\n    }\n}\n\nvoid BaseChainCall::assertError(const UnsafeStringView& message)\n{\n    WCTRemedialAssert(false, message, return;);\n}\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/cpp/chaincall/ChainCall.hpp",
    "content": "//\n// Created by qiuwenchen on 2022/8/29.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"CPPDeclaration.h\"\n#include \"Recyclable.hpp\"\n#include \"WCDBError.hpp\"\n\nnamespace WCDB {\n\nclass WCDB_API BaseChainCall {\npublic:\n    BaseChainCall() = delete;\n    BaseChainCall(const BaseChainCall &);\n    BaseChainCall &operator=(const BaseChainCall &);\n    BaseChainCall(BaseChainCall &&other);\n    virtual ~BaseChainCall() = 0;\n\n    /**\n     @brief The error generated by current statement.\n     Since it is too cumbersome to get the error after every operation, it‘s better to use monitoring interfaces to obtain errors and print them to the log.\n     @see   `static Database::globalTraceError()`\n     @see   `Database::traceError()`\n     @return WCDB::Error\n     */\n    const Error &getError() const;\n\n    /**\n     @brief Get the number of changed rows in the most recent call.\n     It should be called after executing successfully.\n     */\n    int getChanges() const;\n\nprotected:\n    bool checkHandle(bool writeHint);\n    void saveChangesAndError(bool succeed);\n    void assertError(const UnsafeStringView &message);\n    BaseChainCall(Recyclable<InnerDatabase *> databaseHolder);\n    std::shared_ptr<Handle> m_handle;\n    int m_changes;\n    Error m_error;\n};\n\ntemplate<class StatementType>\nclass ChainCall : public BaseChainCall {\n    static_assert(std::is_base_of<Statement, StatementType>::value, \"\");\n\npublic:\n    /**\n     @brief The statement that `ChainCall` will execute.\n     You can customize this statement directly to implement the capabilities not provided by `ChainCall`.\n     */\n    StatementType &getStatement() { return m_statement; }\n\nprotected:\n    ChainCall(Recyclable<InnerDatabase *> databaseHolder)\n    : BaseChainCall(databaseHolder)\n    {\n    }\n    virtual ~ChainCall() override = default;\n\n    StatementType m_statement;\n};\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/cpp/chaincall/Delete.cpp",
    "content": "//\n// Created by qiuwenchen on 2022/9/2.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"Delete.hpp\"\n#include \"Handle.hpp\"\n\nnamespace WCDB {\n\nDelete::~Delete() = default;\n\nDelete::Delete(Recyclable<InnerDatabase *> databaseHolder)\n: ChainCall(databaseHolder)\n{\n}\n\nDelete &Delete::fromTable(const UnsafeStringView &tableName)\n{\n    m_statement.deleteFrom(tableName);\n    return *this;\n}\n\nDelete &Delete::where(const Expression &condition)\n{\n    m_statement.where(condition);\n    return *this;\n}\n\nDelete &Delete::orders(const OrderingTerms &orders)\n{\n    m_statement.orders(orders);\n    return *this;\n}\n\nDelete &Delete::limit(const Expression &limit)\n{\n    m_statement.limit(limit);\n    return *this;\n}\n\nDelete &Delete::offset(const Expression &offset)\n{\n    m_statement.offset(offset);\n    return *this;\n}\n\nbool Delete::execute()\n{\n    if (!checkHandle(true)) {\n        return false;\n    }\n    bool result = m_handle->execute(m_statement);\n    saveChangesAndError(result);\n    m_handle->invalidate();\n    return result;\n}\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/cpp/chaincall/Delete.hpp",
    "content": "//\n// Created by qiuwenchen on 2022/8/31.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"CPPORM.h\"\n#include \"ChainCall.hpp\"\n#include \"ValueArray.hpp\"\n\nnamespace WCDB {\n\nclass WCDB_API Delete final : public ChainCall<StatementDelete> {\n    template<class ObjectType>\n    friend class TableORMOperation;\n    friend class HandleORMOperation;\n\npublic:\n    ~Delete() override;\n\n    /**\n     @brief WINQ interface for SQL.\n     @param tableName The name of the table to delete data from.\n     @return this\n     */\n    Delete &fromTable(const UnsafeStringView &tableName);\n\n    /**\n     @brief WINQ interface for SQL.\n     @param condition condition\n     @return this\n     */\n    Delete &where(const Expression &condition);\n\n    /**\n     @brief WINQ interface for SQL.\n     @param orders order list\n     @return this\n     */\n    Delete &orders(const OrderingTerms &orders);\n\n    /**\n     @brief WINQ interface for SQL.\n     @param limit limit\n     @return this\n     */\n    Delete &limit(const Expression &limit);\n\n    /**\n     @brief WINQ interface for SQL.\n     @param offset offset\n     @return this\n     */\n    Delete &offset(const Expression &offset);\n\n    /**\n     @brief Execute the delete SQL.\n     @return True if no error occurs.\n     */\n    bool execute();\n\nprivate:\n    Delete(Recyclable<InnerDatabase *> databaseHolder);\n};\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/cpp/chaincall/Insert.hpp",
    "content": "//\n// Created by qiuwenchen on 2022/8/30.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"CPPORM.h\"\n#include \"CaseInsensitiveList.hpp\"\n#include \"ChainCall.hpp\"\n#include \"ValueArray.hpp\"\n#include <assert.h>\n#include <memory>\n#include <stdlib.h>\n\nnamespace WCDB {\n\ntemplate<class ObjectType>\nclass Insert final : public ChainCall<StatementInsert> {\n    friend class TableORMOperation<ObjectType>;\n    friend class HandleORMOperation;\n\n    WCDB_CPP_ORM_STATIC_ASSERT_FOR_OBJECT_TYPE\n\npublic:\n    ~Insert() override final = default;\n\n    /**\n     @brief WINQ interface for SQL.\n     @return this\n     */\n    Insert<ObjectType>& orReplace()\n    {\n        m_statement.orReplace();\n        return *this;\n    }\n\n    /**\n     @brief WINQ interface for SQL.\n     @return this\n     */\n    Insert<ObjectType>& orIgnore()\n    {\n        m_statement.orIgnore();\n        return *this;\n    }\n\n    /**\n     @brief WINQ interface for SQL.\n     @param table The name of the table to insert objects to.\n     @return this\n     */\n    Insert<ObjectType>& intoTable(const UnsafeStringView& table)\n    {\n        m_statement.insertIntoTable(table);\n        return *this;\n    }\n\n    /**\n     @brief WINQ interface for SQL.\n     @param fields Do a partial insertion with the specific fields.\n     @return this\n     */\n    Insert<ObjectType>& onFields(const Fields& fields)\n    {\n        m_fields = fields;\n        m_statement.columns(fields).values(BindParameter::bindParameters(fields.size()));\n        return *this;\n    }\n\n    /**\n     @brief Insert one object.\n     @param object Object to be inserted into table.\n     @warning You should hold the memory of this object before you execute insert.\n     @return this.\n     */\n    Insert<ObjectType>& value(const ObjectType& object)\n    {\n        m_obj = &object;\n        m_valueType = ValueType::SingleObject;\n        return *this;\n    }\n\n    /**\n     @brief Insert an array of objects.\n     @param objects Objects to be inserted into table.\n     @warning You should hold the memory of objects before you execute insert.\n     @return this.\n     */\n    Insert<ObjectType>& values(const ValueArray<ObjectType>& objects)\n    {\n        m_objArr = &objects;\n        m_valueType = ValueType::ObjectArray;\n        return *this;\n    }\n\n    /**\n     @brief Insert an array of objects.\n     @param objects Objects to be inserted into table.\n     @warning You should hold the memory of objects before you execute insert.\n     @return this.\n     */\n    Insert<ObjectType>& values(const ValueArray<ObjectType*>& objects)\n    {\n        m_objPtrArr = &objects;\n        m_valueType = ValueType::ObjectPtrArray;\n        return *this;\n    }\n\n    /**\n     @brief Insert an array of objects.\n     @param objects Objects to be inserted into table.\n     @warning You should hold the memory of objects before you execute insert.\n     @return this.\n     */\n    Insert<ObjectType>& values(const ValueArray<std::shared_ptr<ObjectType>>& objects)\n    {\n        m_objSharedPtrArr = &objects;\n        m_valueType = ValueType::ObjectSharedPtrArray;\n        return *this;\n    }\n\n    /**\n     @brief Execute the insert statement.\n            Note that it will run embedded transaction while values.count>1 .\n            The embedded transaction means that it will run a transaction if it's not in other transaction, otherwise it will be executed within the existing transaction.\n     @return True if no error occurs.\n     */\n    bool execute()\n    {\n        bool succeed = true;\n        size_t count = getObjectCount();\n        if (count > 0) {\n            if (!checkHandle(true)) {\n                return false;\n            }\n            if (count > 1) {\n                succeed = m_handle->runTransaction([&](Handle& handle) {\n                    WCDB_UNUSED(handle);\n                    return realExecute();\n                });\n            } else {\n                succeed = realExecute();\n            }\n            saveChangesAndError(succeed);\n        }\n        m_handle->invalidate();\n        return succeed;\n    }\n\nprotected:\n    Insert(Recyclable<InnerDatabase*> databaseHolder)\n    : ChainCall(databaseHolder), m_valueType(ValueType::Invalid), m_obj(nullptr)\n    {\n    }\n\nprivate:\n    bool realExecute()\n    {\n        if (m_fields.size() == 0) {\n            m_fields = ObjectType::allFields();\n        }\n        if (m_statement.syntax().columns.empty()) {\n            m_statement.columns(m_fields).values(\n            BindParameter::bindParameters(m_fields.size()));\n        }\n        std::vector<bool> autoIncrementsOfDefinitions;\n        if (!m_statement.syntax().conflictActionValid()) {\n            for (const Field& field : m_fields) {\n                // auto increment?\n                const ColumnDef* def\n                = field.syntax().getTableBinding()->getColumnDef(field.syntax().name);\n                if (def == nullptr) {\n                    assertError(\"Related columndef is not found.\");\n                    return false;\n                }\n                autoIncrementsOfDefinitions.push_back(def->syntax().isAutoIncrement());\n            }\n        }\n        bool succeed = false;\n        if (m_handle->prepare(m_statement)) {\n            succeed = true;\n            size_t count = getObjectCount();\n            for (size_t i = 0; i < count; i++) {\n                const ObjectType& obj = getObjectAtIndex(i);\n                succeed = stepOneObject(obj, autoIncrementsOfDefinitions);\n                if (!(succeed)) {\n                    break;\n                }\n            }\n            m_handle->finalize();\n        }\n        return succeed;\n    }\n\n    bool stepOneObject(const ObjectType& obj, const std::vector<bool>& autoIncrementsOfDefinitions)\n    {\n        m_handle->reset();\n        int index = 1;\n        assert(!obj.isAutoIncrement || !m_statement.syntax().conflictActionValid());\n        for (const Field& field : m_fields) {\n            if (autoIncrementsOfDefinitions.empty()\n                || !autoIncrementsOfDefinitions[index - 1] || !obj.isAutoIncrement) {\n                m_handle->bindObject(obj, field, index);\n            } else {\n                m_handle->bindNull(index);\n            }\n            ++index;\n        }\n        if (!m_handle->step()) {\n            return false;\n        }\n        *obj.lastInsertedRowID = m_handle->getLastInsertedRowID();\n        return true;\n    }\n\n    size_t getObjectCount() const\n    {\n        switch (m_valueType) {\n        case ValueType::SingleObject:\n            return 1;\n        case ValueType::ObjectArray:\n            return m_objArr->size();\n        case ValueType::ObjectPtrArray:\n            return m_objPtrArr->size();\n        case ValueType::ObjectSharedPtrArray:\n            return m_objSharedPtrArr->size();\n        default:\n            return 0;\n        }\n    }\n\n    const ObjectType& getObjectAtIndex(size_t index)\n    {\n        switch (m_valueType) {\n        case ValueType::SingleObject:\n            return *m_obj;\n        case ValueType::ObjectArray:\n            return (*m_objArr)[index];\n        case ValueType::ObjectPtrArray:\n            return *((*m_objPtrArr)[index]);\n        case ValueType::ObjectSharedPtrArray:\n            return *((*m_objSharedPtrArr)[index]);\n        default:\n            abort();\n        }\n    }\n\n    Fields m_fields;\n\n    enum class ValueType : signed char {\n        Invalid = 0,\n        SingleObject,\n        ObjectArray,\n        ObjectPtrArray,\n        ObjectSharedPtrArray,\n    };\n    ValueType m_valueType = ValueType::Invalid;\n\n    union {\n        const ObjectType* m_obj;\n        const ValueArray<ObjectType>* m_objArr;\n        const ValueArray<ObjectType*>* m_objPtrArr;\n        const ValueArray<std::shared_ptr<ObjectType>>* m_objSharedPtrArr;\n    };\n};\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/cpp/chaincall/MultiObject.cpp",
    "content": "//\n// Created by qiuwenchen on 2022/10/24.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"MultiObject.hpp\"\n#include \"Assertion.hpp\"\n\nnamespace WCDB {\n\nMultiObject::MultiObject() = default;\n\nMultiObject::~MultiObject() = default;\n\nbool MultiObject::operator==(const MultiObject& other) const\n{\n    if (m_objs.size() != other.m_objs.size()) {\n        return false;\n    }\n    for (auto iter = m_objs.begin(); iter != m_objs.end(); iter++) {\n        auto otherIter = other.m_objs.find(iter->first);\n        if (otherIter == other.m_objs.end()) {\n            return false;\n        }\n        if (iter->second != otherIter->second) {\n            return false;\n        }\n    }\n    return true;\n}\n\nbool MultiObject::operator!=(const MultiObject& other) const\n{\n    return !(operator==(other));\n}\n\nbool MultiObject::ObjectValue::operator==(const ObjectValue& other) const\n{\n    StringViewSet checkedFields;\n    for (auto iter = m_fields.begin(); iter != m_fields.end(); iter++) {\n        const StringView& columnName\n        = iter->syntax().expression.getOrCreate().column().name;\n        checkedFields.insert(columnName);\n        const Value& myValue = m_values.at(columnName);\n        auto otherIter = other.m_values.find(columnName);\n        if (otherIter == other.m_values.end()) {\n            if (!myValue.isEmpty()) {\n                return false;\n            }\n        } else if (myValue != otherIter->second) {\n            return false;\n        }\n    }\n    for (auto iter = other.m_fields.begin(); iter != other.m_fields.end(); iter++) {\n        const StringView& columnName\n        = iter->syntax().expression.getOrCreate().column().name;\n        if (checkedFields.find(columnName) != checkedFields.end()) {\n            continue;\n        }\n        const Value& otherValue = other.m_values.at(columnName);\n        if (!otherValue.isEmpty()) {\n            return false;\n        }\n    }\n    return true;\n}\n\nbool MultiObject::ObjectValue::operator!=(const ObjectValue& other) const\n{\n    return !(operator==(other));\n}\n\nvoid MultiObject::addField(const UnsafeStringView& table, const ResultField& field, const Value& value)\n{\n    WCTAssert(table.length() > 0);\n    auto iter = m_objs.find(table);\n    if (iter == m_objs.end()) {\n        ObjectValue obj;\n        obj.addField(field, value);\n        m_objs[table] = obj;\n    } else {\n        iter->second.addField(field, value);\n    }\n}\n\nvoid MultiObject::ObjectValue::addField(const ResultField& field, const Value& value)\n{\n    const StringView& columnName\n    = field.syntax().expression.getOrCreate().column().name;\n    WCTRemedialAssert(\n    columnName.length() > 0,\n    StringView::formatted(\"invalid result column %s\", field.getDescription().data()),\n    return;);\n    WCTAssert(m_values.find(columnName) == m_values.end());\n    m_fields.push_back(field);\n    m_values[columnName] = value;\n}\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/cpp/chaincall/MultiObject.hpp",
    "content": "//\n// Created by qiuwenchen on 2022/10/24.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"CPPORM.h\"\n\nnamespace WCDB {\n\nclass WCDB_API MultiObject {\n    friend class StatementOperation;\n\npublic:\n    MultiObject();\n    ~MultiObject();\n\n    /**\n     @brief Get result of specified table.\n     @param table Table name.\n     @return an object of specified type.\n     */\n    template<class ObjectType>\n    Optional<ObjectType> objectAtTable(const UnsafeStringView& table)\n    {\n        WCDB_CPP_ORM_STATIC_ASSERT_FOR_OBJECT_TYPE\n        auto iter = m_objs.find(table);\n        if (iter == m_objs.end()) {\n            return Optional<ObjectType>();\n        }\n        ObjectType result;\n        ObjectValue& objValue = iter->second;\n        for (ResultField& field : objValue.m_fields) {\n            const StringView& fieldName\n            = field.syntax().expression.getOrCreate().column().name;\n            field.setValue(result, objValue.m_values[fieldName]);\n        }\n        return result;\n    }\n\n    /**\n     @brief add an object as result of the specified table.\n     @param obj The object to add.\n     @param table Table name.\n     */\n    template<class ObjectType>\n    void addObject(const ObjectType& obj, const UnsafeStringView& table)\n    {\n        WCDB_CPP_ORM_STATIC_ASSERT_FOR_OBJECT_TYPE\n        const Fields fields = ObjectType::allFields();\n        for (const Field& field : fields) {\n            addField(table, field, field.getValue(obj));\n        }\n    }\n\n    bool operator==(const MultiObject& other) const;\n    bool operator!=(const MultiObject& other) const;\n\nprotected:\n    void addField(const UnsafeStringView& table, const ResultField& field, const Value& value);\n\nprivate:\n    typedef struct ObjectValue {\n        ResultFields m_fields;\n        StringViewMap<Value> m_values;\n        void addField(const ResultField& field, const Value& value);\n        bool operator==(const ObjectValue& other) const;\n        bool operator!=(const ObjectValue& other) const;\n    } ObjectValue;\n    StringViewMap<ObjectValue> m_objs;\n};\n\ntypedef Optional<MultiObject> OptionalMultiObject;\ntypedef OptionalValueArray<MultiObject> OptionalMultiObjectArray;\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/cpp/chaincall/MultiSelect.cpp",
    "content": "//\n// Created by qiuwenchen on 2022/10/25.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"MultiSelect.hpp\"\n#include \"Assertion.hpp\"\n#include \"Handle.hpp\"\n#include \"MultiObject.hpp\"\n#include \"ResultField.hpp\"\n\nnamespace WCDB {\n\nMultiSelect::~MultiSelect() = default;\n\nMultiSelect::MultiSelect(Recyclable<InnerDatabase *> databaseHolder)\n: ChainCall(databaseHolder)\n{\n}\n\nMultiSelect &MultiSelect::fromTables(const ValueArray<StringView> &tableNames)\n{\n    WCTRemedialAssert(tableNames.size() != 0, \"Table names can't be empty.\", return *this;);\n    TablesOrSubqueries tables;\n    for (const StringView &name : tableNames) {\n        tables.push_back(name);\n    }\n    m_statement.from(tables);\n    return *this;\n}\n\nMultiSelect &MultiSelect::where(const Expression &condition)\n{\n    m_statement.where(condition);\n    return *this;\n}\n\nMultiSelect &MultiSelect::orders(const OrderingTerms &orders)\n{\n    m_statement.orders(orders);\n    return *this;\n}\n\nMultiSelect &MultiSelect::limit(const Expression &limit)\n{\n    m_statement.limit(limit);\n    return *this;\n}\n\nMultiSelect &MultiSelect::offset(const Expression &offset)\n{\n    m_statement.offset(offset);\n    return *this;\n}\n\nMultiSelect &MultiSelect::onResultFields(const ResultFields &resultFields)\n{\n    m_fields = resultFields;\n    m_statement.select(resultFields);\n    return *this;\n}\n\nbool MultiSelect::prepareStatement()\n{\n    if (m_handle->isPrepared()) {\n        return true;\n    }\n    return m_handle->prepare(m_statement);\n}\n\nOptionalMultiObject MultiSelect::firstMultiObject()\n{\n    OptionalMultiObject object;\n    WCTRemedialAssert(m_fields.size() != 0, \"Result columns can't be empty.\", return object;);\n    bool succeed = false;\n    if ((succeed = prepareStatement())) {\n        if ((succeed = m_handle->step()) && !m_handle->done()) {\n            object = m_handle->extractOneMultiObject(m_fields);\n        }\n        m_handle->finalize();\n    }\n    saveChangesAndError(succeed);\n    m_handle->invalidate();\n    return object;\n}\n\nOptionalMultiObjectArray MultiSelect::allMultiObjects()\n{\n    OptionalMultiObjectArray objects;\n    WCTRemedialAssert(\n    m_fields.size() != 0, \"Result columns can't be empty.\", return objects;);\n    if (prepareStatement()) {\n        objects = m_handle->extractAllMultiObjects(m_fields);\n        m_handle->finalize();\n    }\n    saveChangesAndError(objects.succeed());\n    m_handle->invalidate();\n    return objects;\n}\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/cpp/chaincall/MultiSelect.hpp",
    "content": "//\n// Created by qiuwenchen on 2022/10/25.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"ChainCall.hpp\"\n#include \"MultiObject.hpp\"\n\nnamespace WCDB {\n\nclass WCDB_API MultiSelect : public ChainCall<StatementSelect> {\n    template<class ObjectType>\n    friend class TableORMOperation;\n    friend class HandleORMOperation;\n\npublic:\n    ~MultiSelect();\n\n    /**\n     @brief WINQ interface for SQL.\n     @param condition condition\n     @return this\n     */\n    MultiSelect &where(const Expression &condition);\n\n    /**\n     @brief WINQ interface for SQL.\n     @param orders order list\n     @return this\n     */\n    MultiSelect &orders(const OrderingTerms &orders);\n\n    /**\n     @brief WINQ interface for SQL.\n     @param limit limit\n     @return this\n     */\n    MultiSelect &limit(const Expression &limit);\n\n    /**\n     @brief WINQ interface for SQL.\n     @param offset offset\n     @return this\n     */\n    MultiSelect &offset(const Expression &offset);\n\n    /**\n     @brief WINQ interface for SQL.\n     @param resultFields The column results to be selected.\n     @return this\n     */\n    MultiSelect &onResultFields(const ResultFields &resultFields);\n\n    /**\n     @brief WINQ interface for SQL.\n     @param tableNames The names of the tables to query data from.\n     @return this\n     */\n    MultiSelect &fromTables(const ValueArray<StringView> &tableNames);\n\n    /**\n     @brief Get first selected objects.\n     \n         Optional<WCDB::MultiObject> multiObject = multiSelect.firstMultiObject();\n         if(multiObject.succeed()) {\n             TestClass1 object1 = multiObject.value().objectAtTable<TestClass1>(\"table1\");\n             TestClass2 object2 = multiObject.value().objectAtTable<TestClass2>(\"table2\");\n         }\n\n     @return See the example above\n     */\n    OptionalMultiObject firstMultiObject();\n\n    /**\n     @brief Get all selected objects.\n     @return Array with all selected objects.\n     */\n    OptionalMultiObjectArray allMultiObjects();\n\nprotected:\n    MultiSelect(Recyclable<InnerDatabase *> databaseHolder);\n\nprivate:\n    bool prepareStatement();\n    ResultFields m_fields;\n};\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/cpp/chaincall/Select.hpp",
    "content": "//\n// Created by qiuwenchen on 2022/8/31.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"CPPORM.h\"\n#include \"ChainCall.hpp\"\n\nnamespace WCDB {\n\ntemplate<class ObjectType>\nclass Select final : public ChainCall<StatementSelect> {\n    friend class TableORMOperation<ObjectType>;\n    friend class HandleORMOperation;\n\n    WCDB_CPP_ORM_STATIC_ASSERT_FOR_OBJECT_TYPE\n\npublic:\n    ~Select() override final = default;\n\n    /**\n     WINQ interface for SQL.\n     @param condition condition\n     @return this\n     */\n    Select<ObjectType> &where(const Expression &condition)\n    {\n        m_statement.where(condition);\n        return *this;\n    }\n\n    /**\n     @brief WINQ interface for SQL.\n     @param orders order list\n     @return this\n     */\n    Select<ObjectType> &orders(const OrderingTerms &orders)\n    {\n        m_statement.orders(orders);\n        return *this;\n    }\n\n    /**\n     @brief WINQ interface for SQL.\n     @param limit limit\n     @return this\n     */\n    Select<ObjectType> &limit(const Expression &limit)\n    {\n        m_statement.limit(limit);\n        return *this;\n    }\n\n    /**\n     @brief WINQ interface for SQL.\n     @param offset offset\n     @return this\n     */\n    Select<ObjectType> &offset(const Expression &offset)\n    {\n        m_statement.offset(offset);\n        return *this;\n    }\n\n    /**\n     @brief WINQ interface for SQL.\n     @param tableName The name of the table to query data from.\n     @return this\n     */\n    Select<ObjectType> &fromTable(const UnsafeStringView &tableName)\n    {\n        m_statement.from(tableName);\n        return *this;\n    }\n\n    /**\n     @brief WINQ interface for SQL.\n     @param resultFields The column results to be selected.\n     @return this\n     */\n    Select<ObjectType> &onResultFields(const ResultFields &resultFields)\n    {\n        m_fields = resultFields;\n        m_statement.select(resultFields);\n        return *this;\n    }\n\n    /**\n     @brief Get all selected objects.\n     @return The array collection of ObjectType.\n     */\n    OptionalValueArray<ObjectType> allObjects()\n    {\n        OptionalValueArray<ObjectType> objects;\n        if (prepareStatement()) {\n            objects = m_handle->extractAllObjects<ObjectType>(m_fields);\n            m_handle->finalize();\n        }\n        saveChangesAndError(objects.succeed());\n        m_handle->invalidate();\n        return objects;\n    }\n\n    /**\n     @brief Get first selected object.\n     */\n    Optional<ObjectType> firstObject()\n    {\n        Optional<ObjectType> object;\n        bool succeed = false;\n        if ((succeed = prepareStatement())) {\n            if ((succeed = m_handle->step()) && !m_handle->done()) {\n                object = m_handle->extractOneObject<ObjectType>(m_fields);\n            }\n            m_handle->finalize();\n        }\n        saveChangesAndError(succeed);\n        m_handle->invalidate();\n        return object;\n    }\n\nprotected:\n    Select(Recyclable<InnerDatabase *> databaseHolder)\n    : ChainCall(databaseHolder)\n    {\n    }\n\nprivate:\n    bool prepareStatement()\n    {\n        if (m_handle->isPrepared()) {\n            return true;\n        }\n        if (m_fields.size() == 0) {\n            m_fields = ObjectType::allFields();\n        }\n        if (m_statement.syntax().select.getOrCreate().resultColumns.size() == 0) {\n            m_statement.select(m_fields);\n        }\n        if (m_statement.syntax().orderingTerms.empty()) {\n            const Binding &binding = ObjectType::getObjectRelationBinding();\n            const StatementCreateTable &statement = binding.statementTable;\n            if (!statement.syntax().withoutRowid) {\n                m_statement.order(OrderingTerm::ascendingRowid());\n            }\n        }\n        return m_handle->prepare(m_statement);\n    }\n    ResultFields m_fields;\n};\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/cpp/chaincall/Update.hpp",
    "content": "//\n// Created by qiuwenchen on 2022/8/31.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"CPPORM.h\"\n#include \"ChainCall.hpp\"\n#include \"ValueArray.hpp\"\n\nnamespace WCDB {\n\ntemplate<class ObjectType>\nclass Update final : public ChainCall<StatementUpdate> {\n    WCDB_CPP_ORM_STATIC_ASSERT_FOR_OBJECT_TYPE\n    friend class TableORMOperation<ObjectType>;\n    friend class HandleORMOperation;\n\npublic:\n    ~Update() override final = default;\n\n    /**\n     @brief WINQ interface for SQL.\n     @param table The name of the table to update content.\n     @return this\n     */\n    Update<ObjectType> &table(const UnsafeStringView &table)\n    {\n        m_statement.update(table);\n        return *this;\n    }\n\n    /**\n     @brief WINQ interface for SQL.\n     @param fields The fields used to specify the columns where data is updated.\n     @return this\n     */\n    Update<ObjectType> &set(const Fields &fields)\n    {\n        m_fields = fields;\n        int bindParameterIndex = 1;\n        for (const Field &field : fields) {\n            m_statement.set(field).to(WCDB::BindParameter(bindParameterIndex));\n            ++bindParameterIndex;\n        }\n        return *this;\n    }\n\n    /**\n     @brief WINQ interface for SQL.\n     @param condition condition\n     @return this\n     */\n    Update<ObjectType> &where(const Expression &condition)\n    {\n        m_statement.where(condition);\n        return *this;\n    }\n\n    /**\n     @brief WINQ interface for SQL.\n     @param orders order list\n     @return this\n     */\n    Update<ObjectType> &orders(const OrderingTerms orders)\n    {\n        m_statement.orders(orders);\n        return *this;\n    }\n\n    /**\n     @brief WINQ interface for SQL.\n     @param limit limit\n     @return this\n     */\n    Update<ObjectType> &limit(const Expression &limit)\n    {\n        m_statement.limit(limit);\n        return *this;\n    }\n\n    /**\n     @brief WINQ interface for SQL.\n     @param offset offset\n     @return this\n     */\n    Update<ObjectType> &offset(const Expression &offset)\n    {\n        m_statement.offset(offset);\n        return *this;\n    }\n\n    /**\n     @brief Execute the update statement with one object.\n     @param obj Object to be updated into table.\n     @return this.\n     */\n    Update<ObjectType> &toObject(const ObjectType &obj)\n    {\n        m_obj = obj;\n        m_objptr = &(m_obj.value());\n        return *this;\n    }\n\n    /**\n     @brief Execute the update statement with one value.\n     @param value Value to be updated into table.\n     @return this.\n     */\n    Update<ObjectType> &toValue(const Value &value)\n    {\n        m_row = { value };\n        m_rowptr = &(m_row.value());\n        return *this;\n    }\n\n    /**\n     @brief Execute the update statement with one row of value.\n     @param row The row to be updated into table.\n     @return this.\n     */\n    Update<ObjectType> &toRow(const OneRowValue &row)\n    {\n        m_row = row;\n        m_rowptr = &(m_row.value());\n        return *this;\n    }\n\n    /**\n     @brief Execute the update statement.\n     @return True if no error occurs.\n     */\n    bool execute()\n    {\n        bool result = true;\n        if (m_objptr != nullptr || m_rowptr != nullptr) {\n            if (!checkHandle(true)) {\n                return false;\n            }\n            result = false;\n            if (m_handle->prepare(m_statement)) {\n                if (m_objptr != nullptr) {\n                    m_handle->bindObject(*m_objptr, m_fields);\n                } else {\n                    m_handle->bindRow(*m_rowptr);\n                }\n                result = m_handle->step();\n                m_handle->finalize();\n            }\n            saveChangesAndError(result);\n        }\n        m_handle->invalidate();\n        return result;\n    }\n\nprotected:\n    Update(Recyclable<InnerDatabase *> databaseHolder)\n    : ChainCall(databaseHolder)\n    {\n    }\n\n    Update<ObjectType> &toObject(const ObjectType *objptr)\n    {\n        m_objptr = objptr;\n        return *this;\n    }\n\n    Update<ObjectType> &toRow(const OneRowValue *rowptr)\n    {\n        m_rowptr = rowptr;\n        return *this;\n    }\n\nprivate:\n    Fields m_fields;\n    OptionalOneRow m_row;\n    const OneRowValue *m_rowptr = nullptr;\n\n    Optional<ObjectType> m_obj;\n    const ObjectType *m_objptr = nullptr;\n};\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/cpp/core/CPPDeclaration.h",
    "content": "//\n// Created by qiuwenchen on 2022/8/31.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"WINQ.h\"\n\n#define WCDB_CPP_ORM_STATIC_ASSERT_FOR_OBJECT_TYPE                                             \\\n    static_assert(ObjectType::isObjectRelationMapped, \"This class has no ORM configuration.\"); \\\n    static_assert(std::is_constructible<ObjectType>::value,                                    \\\n                  \"This class must have default constructor.\");                                \\\n    static_assert(std::is_copy_assignable<ObjectType>::value                                   \\\n                  && std::is_copy_constructible<ObjectType>::value,                            \\\n                  \"This class must be copy constructible and copy assignable.\");\n\nnamespace WCDB {\n\nclass BaseAccessor;\nclass Field;\nclass ResultField;\nclass Binding;\n\ntypedef SyntaxList<Field> Fields;\ntypedef SyntaxList<ResultField> ResultFields;\n\nclass HandleOperation;\nclass HandleORMOperation;\nclass StatementOperation;\nclass TableOperation;\ntemplate<class ObjectType>\nclass TableORMOperation;\n\nclass InnerDatabase;\nclass Database;\nclass InnerHandle;\nclass Handle;\nclass HandleStatement;\nclass PreparedStatement;\n\nclass BaseChainCall;\n\ntemplate<class ObjectType>\nclass Table;\n\nclass MultiObject;\n\ntemplate<class ObjectType>\nclass Insert;\n\ntemplate<class ObjectType>\nclass Update;\n\nclass Delete;\n\ntemplate<class ObjectType>\nclass Select;\n\nclass MultiSelect;\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/cpp/core/CppInterface.h",
    "content": "//\n// Created by qiuwenchen on 2022/8/9.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"Database.hpp\"\n#include \"Handle.hpp\"\n#include \"PreparedStatement.hpp\"\n#include \"Table.hpp\"\n#include \"Tag.hpp\"\n\n#include \"Delete.hpp\"\n#include \"Insert.hpp\"\n#include \"MultiSelect.hpp\"\n#include \"Select.hpp\"\n#include \"Update.hpp\"\n"
  },
  {
    "path": "src/cpp/core/Database.cpp",
    "content": "//\n// Created by qiuwenchen on 2022/8/3.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"Database.hpp\"\n#include \"CipherConfig.hpp\"\n#include \"CommonCore.hpp\"\n#include \"CompressionCenter.hpp\"\n#include \"CompressionConst.hpp\"\n#include \"CoreConst.h\"\n#include \"CustomConfig.hpp\"\n#include \"DBOperationNotifier.hpp\"\n#include \"FileManager.hpp\"\n#include \"Global.hpp\"\n#include \"InnerDatabase.hpp\"\n#include \"Path.hpp\"\n#include \"WCDBVersion.h\"\n\nnamespace WCDB {\n\n#pragma mark - Basic\n\nDatabase::Database(const UnsafeStringView& path, bool readOnly)\n{\n    m_databaseHolder = CommonCore::shared().getOrCreateDatabase(Path::normalize(path));\n    m_innerDatabase = m_databaseHolder.get();\n    if (readOnly) {\n        m_innerDatabase->setReadOnly();\n    }\n}\n\nDatabase::Database(const Database&) = default;\n\nDatabase& Database::operator=(const Database&) = default;\n\nDatabase::~Database() = default;\n\nDatabase::Database(Recyclable<InnerDatabase*> database)\n: m_databaseHolder(database), m_innerDatabase(database.get())\n{\n}\n\nDatabase::Database(InnerDatabase* database) : m_innerDatabase(database)\n{\n    m_databaseHolder = RecyclableDatabase(m_innerDatabase, nullptr);\n}\n\nDatabase Database::createInMemoryDatabase()\n{\n    InnerDatabase* database = new InnerDatabase(\":memory:\");\n    database->setInMemory();\n    RecyclableDatabase databaseHolder\n    = RecyclableDatabase(database, [](WCDB::InnerDatabase* db) { delete db; });\n    return Database(databaseHolder);\n}\n\nRecyclableHandle Database::getHandleHolder(bool writeHint)\n{\n    return m_databaseHolder->getHandle(writeHint);\n}\n\nRecyclable<InnerDatabase*> Database::getDatabaseHolder()\n{\n    return m_databaseHolder;\n}\n\nvoid Database::setTag(const long& tag)\n{\n    m_innerDatabase->setTag(tag);\n}\n\nlong Database::getTag() const\n{\n    return m_innerDatabase->getTag();\n}\n\nconst StringView& Database::getPath() const\n{\n    return m_innerDatabase->getPath();\n}\n\nconst Error& Database::getError() const\n{\n    return m_innerDatabase->getThreadedError();\n}\n\nHandle Database::getHandle()\n{\n    return Handle(m_databaseHolder);\n}\n\nbool Database::canOpen() const\n{\n    return m_innerDatabase->canOpen();\n}\n\nbool Database::isOpened() const\n{\n    return m_innerDatabase->isOpened();\n}\n\nvoid Database::close(const Database::ClosedCallback& onClosed)\n{\n    m_innerDatabase->close(onClosed);\n}\n\nvoid Database::blockade()\n{\n    m_innerDatabase->blockade();\n}\n\nbool Database::isBlockaded() const\n{\n    return m_innerDatabase->isBlockaded();\n}\n\nvoid Database::unblockade()\n{\n    m_innerDatabase->unblockade();\n}\n\n#pragma mark - CheckPoint\n\nbool Database::truncateCheckpoint()\n{\n    return m_innerDatabase->checkpoint(false, InnerDatabase::CheckPointMode::Truncate);\n}\n\nbool Database::passiveCheckpoint()\n{\n    return m_innerDatabase->checkpoint(false, InnerDatabase::CheckPointMode::Passive);\n}\n\nvoid Database::enableAutoCheckpoint(bool enable)\n{\n    CommonCore::shared().enableAutoCheckpoint(m_innerDatabase, enable);\n}\n\n#pragma mark - Vacuum\n\nbool Database::vacuum(ProgressUpdateCallback onProgressUpdated)\n{\n    return m_innerDatabase->vacuum(onProgressUpdated);\n}\n\nvoid Database::enableAutoVacuum(bool incremental)\n{\n    m_innerDatabase->enableAutoVacuum(incremental);\n}\n\nbool Database::incrementalVacuum(int pages)\n{\n    return m_innerDatabase->incrementalVacuum(pages);\n}\n\n#if defined(_WIN32)\nvoid Database::setUIThreadId(std::thread::id uiThreadId)\n{\n    Thread::setUIThreadId(uiThreadId);\n}\n#endif\n\n#pragma mark - Monitor\n\nvoid Database::globalTraceError(Database::ErrorNotification trace)\n{\n    CommonCore::shared().setNotificationWhenErrorTraced(trace);\n}\n\nvoid Database::traceError(ErrorNotification trace)\n{\n    CommonCore::shared().setNotificationWhenErrorTraced(getPath(), trace);\n}\n\nstatic_assert(sizeof(Database::PerformanceInfo) == sizeof(InnerHandle::PerformanceInfo), \"\");\nstatic_assert(offsetof(Database::PerformanceInfo, tablePageReadCount)\n              == offsetof(InnerHandle::PerformanceInfo, tablePageReadCount),\n              \"\");\nstatic_assert(offsetof(Database::PerformanceInfo, tablePageWriteCount)\n              == offsetof(InnerHandle::PerformanceInfo, tablePageWriteCount),\n              \"\");\nstatic_assert(offsetof(Database::PerformanceInfo, indexPageReadCount)\n              == offsetof(InnerHandle::PerformanceInfo, indexPageReadCount),\n              \"\");\nstatic_assert(offsetof(Database::PerformanceInfo, indexPageWriteCount)\n              == offsetof(InnerHandle::PerformanceInfo, indexPageWriteCount),\n              \"\");\nstatic_assert(offsetof(Database::PerformanceInfo, overflowPageReadCount)\n              == offsetof(InnerHandle::PerformanceInfo, overflowPageReadCount),\n              \"\");\nstatic_assert(offsetof(Database::PerformanceInfo, overflowPageWriteCount)\n              == offsetof(InnerHandle::PerformanceInfo, overflowPageWriteCount),\n              \"\");\nstatic_assert(offsetof(Database::PerformanceInfo, costInNanoseconds)\n              == offsetof(InnerHandle::PerformanceInfo, costInNanoseconds),\n              \"\");\n\nvoid Database::globalTracePerformance(Database::PerformanceNotification trace)\n{\n    if (trace != nullptr) {\n        CommonCore::shared().setNotificationWhenPerformanceGlobalTraced(\n        [trace](long tag,\n                const UnsafeStringView& path,\n                const void* handleIdentifier,\n                const UnsafeStringView& sql,\n                const InnerHandle::PerformanceInfo& info) {\n            PerformanceInfo newInfo;\n            memcpy(&newInfo, &info, sizeof(info));\n            trace(tag, path, (uint64_t) handleIdentifier, sql, newInfo);\n        });\n    } else {\n        CommonCore::shared().setNotificationWhenPerformanceGlobalTraced(nullptr);\n    }\n}\n\nvoid Database::tracePerformance(Database::PerformanceNotification trace)\n{\n    if (trace != nullptr) {\n        m_innerDatabase->setConfig(\n        PerformanceTraceConfigName,\n        std::static_pointer_cast<Config>(std::make_shared<PerformanceTraceConfig>(\n        [trace](long tag,\n                const UnsafeStringView& path,\n                const void* handleIdentifier,\n                const UnsafeStringView& sql,\n                const InnerHandle::PerformanceInfo& info) {\n            PerformanceInfo newInfo;\n            memcpy(&newInfo, &info, sizeof(info));\n            trace(tag, path, (uint64_t) handleIdentifier, sql, newInfo);\n        })),\n        Configs::Priority::Highest);\n    } else {\n        m_innerDatabase->removeConfig(PerformanceTraceConfigName);\n    }\n}\n\nvoid Database::globalTraceSQL(Database::SQLNotification trace)\n{\n    CommonCore::shared().setNotificationForSQLGLobalTraced(trace);\n}\n\nvoid Database::traceSQL(Database::SQLNotification trace)\n{\n    if (trace != nullptr) {\n        m_innerDatabase->setConfig(\n        SQLTraceConfigName,\n        std::static_pointer_cast<Config>(std::make_shared<SQLTraceConfig>(trace)),\n        Configs::Priority::Highest);\n    } else {\n        m_innerDatabase->removeConfig(SQLTraceConfigName);\n    }\n}\n\nvoid Database::setFullSQLTraceEnable(bool enable)\n{\n    m_innerDatabase->setFullSQLTraceEnable(enable);\n}\n\nconst StringView& Database::MonitorInfoKeyHandleCount = WCDB::MonitorInfoKeyHandleCount;\nconst StringView& Database::MonitorInfoKeySchemaUsage = WCDB::MonitorInfoKeySchemaUsage;\nconst StringView& Database::MonitorInfoKeyHandleOpenTime = WCDB::MonitorInfoKeyHandleOpenTime;\nconst StringView& Database::MonitorInfoKeyHandleOpenCPUTime\n= WCDB::MonitorInfoKeyHandleOpenCPUTime;\nconst StringView& Database::MonitorInfoKeyTableCount = WCDB::MonitorInfoKeyTableCount;\nconst StringView& Database::MonitorInfoKeyIndexCount = WCDB::MonitorInfoKeyIndexCount;\nconst StringView& Database::MonitorInfoKeyTriggerCount = WCDB::MonitorInfoKeyTriggerCount;\n\nvoid Database::globalTraceDatabaseOperation(DBOperationTrace trace)\n{\n    if (trace != nullptr) {\n        DBOperationNotifier::shared().setNotification([=](InnerDatabase* innerDatabase,\n                                                          DBOperationNotifier::Operation operation,\n                                                          StringViewMap<Value>& info) {\n            Database database = Database(innerDatabase);\n            trace(database, (Operation) operation, info);\n        });\n    } else {\n        DBOperationNotifier::shared().setNotification(nullptr);\n    }\n}\n\nvoid Database::globalTraceBusy(BusyTrace trace, double timeOut)\n{\n    CommonCore::shared().setBusyMonitor(trace, timeOut);\n}\n\n#pragma mark - File\n\nbool Database::removeFiles()\n{\n    return m_innerDatabase->removeFiles();\n}\n\nbool Database::moveFiles(const UnsafeStringView& directory)\n{\n    return m_innerDatabase->moveFiles(directory);\n}\n\nstd::list<StringView> Database::getPaths() const\n{\n    return m_innerDatabase->getPaths();\n}\n\nOptional<size_t> Database::getFilesSize() const\n{\n    return m_innerDatabase->getFilesSize();\n}\n\n#pragma mark - FTS\n\nvoid Database::enableAutoMergeFTS5Index(bool flag)\n{\n    CommonCore::shared().enableAutoMergeFTSIndex(m_innerDatabase, flag);\n}\n\nvoid Database::addTokenizer(const UnsafeStringView& tokenize)\n{\n    StringView configName\n    = StringView::formatted(\"%s%s\", TokenizeConfigPrefix.data(), tokenize.data());\n    m_innerDatabase->setConfig(\n    configName, CommonCore::shared().tokenizerConfig(tokenize), Configs::Priority::Higher);\n}\n\nvoid Database::registerTokenizer(const UnsafeStringView& name, const TokenizerModule& module)\n{\n    CommonCore::shared().registerTokenizer(name, module);\n}\n\nvoid Database::addAuxiliaryFunction(const UnsafeStringView& functionName)\n{\n    StringView configName = StringView::formatted(\n    \"%s%s\", AuxiliaryFunctionConfigPrefix.data(), functionName.data());\n    m_innerDatabase->setConfig(configName,\n                               CommonCore::shared().auxiliaryFunctionConfig(functionName),\n                               Configs::Priority::Higher);\n}\n\nvoid Database::registerAuxiliaryFunction(const UnsafeStringView& name,\n                                         const FTS5AuxiliaryFunctionModule& module)\n{\n    CommonCore::shared().registerAuxiliaryFunction(name, module);\n}\n\nvoid Database::configSymbolDetector(SymbolDetector detector)\n{\n    FTSTokenizerUtil::configSymbolDetector(detector);\n}\n\nvoid Database::configUnicodeNormalizer(UnicodeNormalizer normalizer)\n{\n    FTSTokenizerUtil::configUnicodeNormalizer(normalizer);\n}\n\nvoid Database::configPinyinConverter(PinYinConverter converter)\n{\n    FTSTokenizerUtil::configPinyinConverter(converter);\n}\n\nvoid Database::configTraditionalChineseConverter(TraditionalChineseConverter converter)\n{\n    FTSTokenizerUtil::configTraditionalChineseConverter(converter);\n}\n\n#pragma mark - Memory\n\nvoid Database::purge()\n{\n    m_innerDatabase->purge();\n}\n\nvoid Database::purgeAll()\n{\n    CommonCore::shared().purgeDatabasePool();\n}\n\n#pragma mark - Repair\n\nvoid Database::setNotificationWhenCorrupted(Database::CorruptionNotification onCorrupted)\n{\n    CommonCore::shared().setNotificationWhenDatabaseCorrupted(\n    getPath(), [onCorrupted](InnerDatabase* innerDatabase) {\n        Database database = Database(innerDatabase);\n        onCorrupted(database);\n    });\n}\n\nbool Database::checkIfCorrupted()\n{\n    m_innerDatabase->checkIntegrity(false);\n    return isAlreadyCorrupted();\n}\n\nbool Database::isAlreadyCorrupted()\n{\n    return CommonCore::shared().isFileObservedCorrupted(getPath());\n}\n\nvoid Database::enableAutoBackup(bool flag)\n{\n    CommonCore::shared().enableAutoBackup(m_innerDatabase, flag);\n}\n\nbool Database::backup()\n{\n    return m_innerDatabase->backup(false);\n}\n\nvoid Database::filterBackup(Database::BackupFilter tableShouldBeBackedUp)\n{\n    m_innerDatabase->filterBackup(tableShouldBeBackedUp);\n}\n\nbool Database::deposit()\n{\n    return m_innerDatabase->deposit();\n}\n\nbool Database::removeDeposited()\n{\n    return m_innerDatabase->removeDeposited();\n}\n\nbool Database::containsDeposited() const\n{\n    return m_innerDatabase->containsDeposited();\n}\n\ndouble Database::retrieve(Database::ProgressUpdateCallback onProgressUpdated)\n{\n    return m_innerDatabase->retrieve(onProgressUpdated);\n}\n\n#pragma mark - Config\n\nvoid Database::setCipherKey(const UnsafeData& cipherKey, int cipherPageSize, CipherVersion cipherVersion)\n{\n    if (cipherKey.size() > 0) {\n        m_innerDatabase->setConfig(\n        CipherConfigName,\n        std::static_pointer_cast<Config>(std::make_shared<CipherConfig>(\n        cipherKey, cipherPageSize, cipherVersion)),\n        Configs::Priority::Highest);\n    } else {\n        m_innerDatabase->removeConfig(CipherConfigName);\n    }\n}\n\nvoid Database::setDefaultCipherConfiguration(CipherVersion version)\n{\n    CommonCore::shared().setDefaultCipherConfiguration(version);\n}\n\nvoid Database::setConfig(const UnsafeStringView& name,\n                         Invocation invocation,\n                         Invocation unInvocation,\n                         Priority priority)\n{\n    m_innerDatabase->purge();\n    InnerDatabase* database = m_innerDatabase;\n    CustomConfig::Invocation configInvocation\n    = [invocation, database](InnerHandle* innerHandle) -> bool {\n        Handle handle = Handle(RecyclableDatabase(database, nullptr), innerHandle);\n        return invocation(handle);\n    };\n    CustomConfig::Invocation configUninvocation = nullptr;\n    if (unInvocation != nullptr) {\n        configUninvocation = [unInvocation, database](InnerHandle* innerHandle) -> bool {\n            Handle handle = Handle(RecyclableDatabase(database, nullptr), innerHandle);\n            return unInvocation(handle);\n        };\n    }\n    m_innerDatabase->setConfig(name,\n                               std::static_pointer_cast<Config>(std::make_shared<CustomConfig>(\n                               configInvocation, configUninvocation)),\n                               priority);\n}\n\nvoid Database::removeConfig(const UnsafeStringView& name)\n{\n    m_innerDatabase->removeConfig(name);\n}\n\nbool Database::setDefaultTemporaryDirectory(const UnsafeStringView& directory)\n{\n    return CommonCore::shared().setDefaultTemporaryDirectory(directory);\n}\n\nvoid Database::registerScalarFunction(const ScalarFunctionModule& module,\n                                      const UnsafeStringView& name)\n{\n    CommonCore::shared().registerScalarFunction(name, module);\n}\n\nvoid Database::addScalarFunction(const UnsafeStringView& name)\n{\n    WCDB::StringView configName = WCDB::StringView::formatted(\n    \"%s%s\", WCDB::ScalarFunctionConfigPrefix.data(), name.data());\n    m_innerDatabase->setConfig(configName,\n                               WCDB::CommonCore::shared().scalarFunctionConfig(name),\n                               WCDB::Configs::Priority::Higher);\n}\n\nvoid Database::enableLiteMode(bool enable)\n{\n    m_innerDatabase->setLiteModeEnable(enable);\n}\n\n#ifndef _WIN32\n\nvoid Database::registerPOSIXOpen(POSIXOpen open)\n{\n    Global::shared().registerPOSIXOpen(open);\n}\n\nvoid Database::registerPOSIXClose(POSIXClose close)\n{\n    Global::shared().registerPOSIXClose(close);\n}\n\n#endif\n\n#pragma mark - Migration\n\nvoid Database::addMigration(const UnsafeStringView& sourcePath,\n                            const UnsafeData& sourceCipher,\n                            const TableFilter& filter)\n{\n    InnerDatabase::MigrationTableFilter callback = nullptr;\n    if (filter != nullptr) {\n        callback = [filter](MigrationUserInfo& userInfo) {\n            MigrationInfo info;\n            info.table = userInfo.getTable();\n            info.sourceTable = userInfo.getSourceTable();\n            filter(info);\n            if (info.sourceTable.length() > 0) {\n                userInfo.setSource(info.sourceTable);\n                userInfo.setFilter(info.filterCondition);\n            }\n        };\n    }\n    m_innerDatabase->addMigration(sourcePath, sourceCipher, callback);\n}\n\nbool Database::stepMigration()\n{\n    auto done = m_innerDatabase->stepMigration(false);\n    return done.succeed();\n}\n\nvoid Database::enableAutoMigration(bool flag)\n{\n    CommonCore::shared().enableAutoMigrate(m_innerDatabase, flag);\n}\n\nvoid Database::setNotificationWhenMigrated(Database::MigratedCallback onMigrated)\n{\n    InnerDatabase::MigratedCallback callback = nullptr;\n    if (onMigrated != nullptr) {\n        callback = [onMigrated](InnerDatabase* innerDatabase,\n                                const MigrationBaseInfo* baseInfo) {\n            Optional<MigrationInfo> info;\n            if (baseInfo != nullptr) {\n                info = MigrationInfo();\n                info->table = baseInfo->getTable();\n                info->sourceTable = baseInfo->getSourceTable();\n            }\n            Database database = Database(innerDatabase);\n            onMigrated(database, info);\n        };\n    }\n    m_innerDatabase->setNotificationWhenMigrated(callback);\n}\n\nbool Database::isMigrated() const\n{\n    return m_innerDatabase->isMigrated();\n}\n\n#pragma mark - Compression\n\nDatabase::CompressionInfo::CompressionInfo(void* innerInfo)\n: m_innerInfo(innerInfo)\n{\n}\n\nconst StringView& Database::CompressionInfo::getTableName() const\n{\n    return ((CompressionTableInfo*) m_innerInfo)->getTable();\n}\n\nvoid Database::CompressionInfo::addZSTDNormalCompressField(const Field& field)\n{\n    CompressionColumnInfo columnInfo(field, CompressionType::Normal);\n    ((CompressionTableUserInfo*) m_innerInfo)->addCompressingColumn(columnInfo);\n}\n\nvoid Database::CompressionInfo::addZSTDDictCompressField(const Field& field, DictId dictId)\n{\n    CompressionColumnInfo columnInfo(field, CompressionType::Dict);\n    columnInfo.setCommonDict(dictId);\n    ((CompressionTableUserInfo*) m_innerInfo)->addCompressingColumn(columnInfo);\n}\n\nvoid Database::CompressionInfo::addZSTDDictCompressField(const Field& field,\n                                                         const Field& matchField,\n                                                         const std::map<int64_t, DictId>& dictIds)\n{\n    if (dictIds.empty()) {\n        return;\n    }\n    CompressionColumnInfo columnInfo(field, matchField);\n    for (const auto& iter : dictIds) {\n        if (iter.first == DictDefaultMatchValue) {\n            columnInfo.setCommonDict(iter.second);\n        } else {\n            columnInfo.addMatchDict(iter.first, iter.second);\n        }\n    }\n    ((CompressionTableUserInfo*) m_innerInfo)->addCompressingColumn(columnInfo);\n}\n\nvoid Database::CompressionInfo::enableReplaceCompresssion()\n{\n    ((CompressionTableUserInfo*) m_innerInfo)->enableReplaceCompresssion();\n}\n\nOptional<Data> Database::trainDict(const std::vector<std::string>& strings, DictId dictId)\n{\n    int index = 0;\n    return CompressionCenter::shared().trainDict(dictId, [&]() -> Optional<UnsafeData> {\n        if (index < strings.size()) {\n            const std::string& string = strings[index];\n            index++;\n            return UnsafeData((unsigned char*) string.data(), string.size());\n        } else {\n            return NullOpt;\n        }\n    });\n}\n\nOptional<Data> Database::trainDict(const std::vector<Data>& datas, DictId dictId)\n{\n    int index = 0;\n    return CompressionCenter::shared().trainDict(dictId, [&]() -> Optional<UnsafeData> {\n        if (index < datas.size()) {\n            const Data& data = datas[index];\n            index++;\n            return data;\n        } else {\n            return NullOpt;\n        }\n    });\n}\n\nbool Database::registerZSTDDict(const UnsafeData& dict, DictId dictId)\n{\n    return CompressionCenter::shared().registerDict(dictId, dict);\n}\n\nvoid Database::setCompression(const CompressionFilter& filter)\n{\n    InnerDatabase::CompressionTableFilter callback = nullptr;\n    if (filter != nullptr) {\n        callback = [filter](CompressionTableUserInfo& userInfo) {\n            CompressionInfo info(&userInfo);\n            filter(info);\n        };\n        StringView configName = StringView::formatted(\n        \"%s%s\", ScalarFunctionConfigPrefix.data(), DecompressFunctionName.data());\n        m_innerDatabase->setConfig(\n        configName,\n        CommonCore::shared().scalarFunctionConfig(DecompressFunctionName),\n        Configs::Priority::Higher);\n    }\n    m_innerDatabase->addCompression(callback);\n}\n\nvoid Database::disableCompresssNewData(bool disable)\n{\n    m_innerDatabase->setCanCompressNewData(!disable);\n}\n\nbool Database::stepCompression()\n{\n    return m_innerDatabase->stepCompression(false).succeed();\n}\n\nvoid Database::enableAutoCompression(bool flag)\n{\n    CommonCore::shared().enableAutoCompress(m_innerDatabase, flag);\n}\n\nvoid Database::setNotificationWhenCompressed(const CompressedCallback& onCompressd)\n{\n    InnerDatabase::CompressedCallback callback = nullptr;\n    if (onCompressd != nullptr) {\n        callback = [onCompressd](InnerDatabase* innerDatabase,\n                                 const CompressionTableBaseInfo* info) {\n            Database database = Database(innerDatabase);\n            if (info != nullptr) {\n                onCompressd(database, info->getTable());\n            } else {\n                onCompressd(database, NullOpt);\n            }\n        };\n    }\n    m_innerDatabase->setNotificationWhenCompressed(callback);\n}\n\nbool Database::isCompressed() const\n{\n    return m_innerDatabase->isCompressed();\n}\n\nbool Database::rollbackCompression(ProgressUpdateCallback onProgressUpdated)\n{\n    return m_innerDatabase->rollbackCompression(onProgressUpdated);\n}\n\n#pragma mark - Version\n\nconst StringView Database::getVersion()\n{\n    return StringView(WCDB_VERSION_STRING);\n}\n\nconst StringView Database::getSourceId()\n{\n    return StringView(WCDB_SOURCE_ID);\n}\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/cpp/core/Database.hpp",
    "content": "//\n// Created by qiuwenchen on 2022/8/3.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n#include \"AuxiliaryFunctionModule.hpp\"\n#include \"FTSTokenizerUtil.hpp\"\n#include \"Handle.hpp\"\n#include \"HandleORMOperation.hpp\"\n#include \"Statement.hpp\"\n#include \"TokenizerModule.hpp\"\n#include \"WCDBError.hpp\"\n#include <thread>\n\nnamespace WCDB {\n\nclass BaseTable;\n\nclass WCDB_API Database final : public HandleORMOperation {\n    friend BaseTable;\n\npublic:\n    /**\n     @brief Init a database from path.\n     @note  All database objects with same path share the same core. So you can create multiple database objects. WCDB will manage them automatically.\n            WCDB will not generate a sqlite db handle until the first operation, which is also called as lazy initialization.\n     @warning Once a database is opened in read-only mode, it cannot be writable in the current process any more.\n     @param path Path to your database\n     */\n    Database(const UnsafeStringView &path, bool readOnly = false);\n    Database() = delete;\n    Database(const Database &);\n    Database &operator=(const Database &);\n    ~Database() override;\n\n    /**\n     @brief Init a in-memory database.\n     @Note  Since In-memory database share one DB handle among all threads, it does not support multi-threaded concurrent operation.\n     @return WCTDatabase\n     */\n    static Database createInMemoryDatabase();\n\nprotected:\n    Database(Recyclable<InnerDatabase *> database);\n\nprivate:\n    Database(InnerDatabase *database);\n    RecyclableHandle getHandleHolder(bool writeHint) override final;\n    Recyclable<InnerDatabase *> getDatabaseHolder() override final;\n    Recyclable<InnerDatabase *> m_databaseHolder;\n    InnerDatabase *m_innerDatabase;\n\n#pragma mark - Basic\npublic:\n    /**\n     @brief Set the tag of the database\n     @Note The `WCDB::Error` generated by the database will carry its tag. You can set the same tag for related databases for classification.\n     */\n    void setTag(const long &tag);\n\n    /**\n     @brief Get the tag of the database. Tag is 0 by default.\n     */\n    long getTag() const;\n\n    /**\n     @brief Get the file path of the database\n     */\n    const StringView &getPath() const;\n\n    /**\n     @brief Get the most recent error for current database in the current thread.\n     Since it is too cumbersome to get the error after every database operation,\n     it‘s better to use monitoring interfaces to obtain database errors and print them to the log.\n     @see   `static Database::globalTraceError()`\n     @see   `Database::traceError()`\n     @return WCDB::Error\n     */\n    const Error &getError() const;\n\n    /**\n     @brief Create a `WCDB::Handle` for current database.\n     `WCDB::Handle` is a wrapper for sqlite db handle of type `sqlite3*`, \n     and the sqlite db handle is lazy initialized and will not be actually generated until the first operation on current handle takes place.\n     @note  All `WCDB::Handle` created by the current database in the current thread will share the same sqlite db handle internally, \n     so it can avoid the deadlock between different sqlite db handles in some extreme cases.\n     @return A `WCDB::Handle` object.\n     */\n    Handle getHandle();\n\n    /**\n     @brief Check whether the database can be opened.\n     Since WCDB is using lazy initialization, you can create an instance of `WCDB::Database` even the database can't open.\n     So you can call this to check whether the database can be opened.\n     @return False if an error occurs during sqlite db handle initialization.\n     */\n    bool canOpen() const;\n\n    /**\n     @brief Check database is already opened.\n     @return isOpened\n     */\n    bool isOpened() const;\n\n    /**\n     Trigger on database closed.\n     */\n    typedef std::function<void(void)> ClosedCallback;\n\n    /**\n     @brief close the database.\n            Since Multi-threaded operation is supported in WCDB, other operations in different thread can open the closed database. \n            So this function can make sure database is closed in the \"onClosed\" closure. All other operations will be blocked until this function returns.\n            A close operation consists of 4 steps:\n                1. blockade, which blocks all other operations.\n                2. close, which waits until all sqlite db handles return and closes them.\n                3. onClosed, which trigger the callback.\n                4. unblokade, which unblocks all other operations.\n            You can simply call close() to do all steps above or call these separately.\n            Since this function will wait until all sqlite db handles return, it may lead to deadlock in some bad practice.\n            The key to avoid deadlock is to make sure all WCDB objects in current thread is dealloced. In detail:\n                1. You should not keep WCDB objects, including `WCDB::Handle`, `WCDB::PreparedStatement`, `WCDB::Insert`, `WCDB::Delete`, `WCDB::Update`, `WCDB::Select`, `WCDB::MultiSelect`. These objects should not be kept. You should get them, use them, then release them right away.\n                2. WCDB objects may not be out of its' scope.\n                The best practice is to call close: in sub-thread and display a loading animation in main thread.\n\n     @param onClosed Trigger on database closed.\n     */\n    void close(const ClosedCallback &onClosed = nullptr);\n\n    /**\n     @brief Blockade the database.\n     @see `Database::close()`\n     */\n    void blockade();\n\n    /**\n     @brief Check whether database is blockaded.\n     @see `Database::close()`\n     @return isBlockaded\n     */\n    bool isBlockaded() const;\n\n    /**\n     @brief Unblockade the database.\n     @see `Database::close()`\n     */\n    void unblockade();\n\n#pragma mark - CheckPoint\n\n    /**\n     @brief Checkpoint the current database with truncate mode.\n     */\n    bool truncateCheckpoint();\n\n    /**\n     @brief Checkpoint the current database with passive mode.\n     */\n    bool passiveCheckpoint();\n\n    /**\n     @brief Enable or disable auto-checkpoint for current database.\n     Note that auto-checkpoint is enabled by default.\n     */\n    void enableAutoCheckpoint(bool enable);\n\n#pragma mark - Vacuum\n\n    /**\n     Triggered when operation progresses, you can return false to stop the operation.\n     */\n    typedef std::function<bool /* continue flag */ (double progress /* percentage */, double increment /* increment */)> ProgressUpdateCallback;\n\n    /**\n     @brief Vacuum current database.\n     It can be used to vacuum a database of any size with limited memory usage.\n     @see   `Database::ProgressUpdateCallback`.\n     @return true if vacuum succeed.\n     */\n    bool vacuum(ProgressUpdateCallback onProgressUpdated);\n\n    /**\n     @brief The wrapper of `PRAGMA auto_vacuum`\n     */\n    void enableAutoVacuum(bool incremental);\n\n    /**\n     @brief The wrapper of `PRAGMA incremental_vacuum`\n     */\n    bool incrementalVacuum(int pages);\n\n#if defined(_WIN32)\n    /**\n     @brief Config the id of UI thread.\n     When multiple threads compete for the lock of the database, the UI thread can acquire the lock with high priority.\n     */\n    static void setUIThreadId(std::thread::id uiThreadId);\n#endif\n\n#pragma mark - Monitor\npublic:\n    /**\n     Trigger when error occurs\n     */\n    typedef std::function<void(const Error &)> ErrorNotification;\n\n    /**\n     @brief You can register a reporter to monitor all errors.\n     \n         WCDB::Database::globalTraceError([](const WCDB::Error &error){\n             printf(\"%s\", error.getDescription().data());\n         });\n     \n     @param trace closure\n     @see `ErrorNotification`\n     */\n    static void globalTraceError(ErrorNotification trace);\n\n    /**\n     @brief You can register a reporter to monitor all errors of current database.\n     @param trace closure\n     @see `ErrorNotification`\n     */\n    void traceError(ErrorNotification trace);\n\n    typedef struct PerformanceInfo {\n        int tablePageReadCount;\n        int tablePageWriteCount;\n        int indexPageReadCount;\n        int indexPageWriteCount;\n        int overflowPageReadCount;\n        int overflowPageWriteCount;\n        int64_t costInNanoseconds;\n    } PerformanceInfo;\n\n    /**\n     Triggered when a transaction or a normal sql ends.\n     */\n    typedef std::function<void(long tag, const UnsafeStringView &path, uint64_t handleIdentifier, const UnsafeStringView &sql, const PerformanceInfo &info)> PerformanceNotification;\n\n    /**\n     @brief You can register a tracer to monitor the performance of all SQLs.\n     It returns\n         1. Every SQL executed by the database.\n         2. Time consuming in nanoseconds.\n         3. Number of reads and writes on different types of db pages.\n         4. Tag of database.\n         5. Path of database.\n         6. The id of the handle executing this SQL.\n     @note  You should register trace before all db operations. Global tracer and db tracer do not interfere with each other.\n     \n         WCDB::Database::globalTracePerformance([](long tag,\n                                                   const WCDB::UnsafeStringView &path,\n                                                   const void *handleIdentifier\n                                                   const WCDB::UnsafeStringView &sql,\n                                                   const PerformanceInfo &info) {\n             printf(\"Tag: %ld\", tag);\n             printf(\"Path: %s\", path.data());\n             printf(\"The handle with id %p took %lld nanoseconds to execute %s\",\n                    handleIdentifier,\n                    info.costInNanoseconds,\n                    sql.data());\n         });\n     \n     @warning Tracer may cause WCDB performance degradation, according to your needs to choose whether to open.\n     */\n    static void globalTracePerformance(PerformanceNotification trace);\n\n    /**\n     @brief You can register a tracer to monitor the performance of all SQLs executed in the current database.\n     @warning Tracer may cause WCDB performance degradation, according to your needs to choose whether to open.\n     @param trace closure\n     @see `PerformanceNotification`\n     */\n    void tracePerformance(PerformanceNotification trace);\n\n    /**\n     Triggered when a SQL is executed.\n     */\n    typedef std::function<void(\n    long tag, const UnsafeStringView &path, const void *handleIdentifier, const UnsafeStringView &sql, const UnsafeStringView &info)>\n    SQLNotification;\n\n    /**\n     @brief You can register a tracer to monitor the execution of all SQLs.\n     It returns:\n         1. Every SQL executed by the database.\n         2. Tag of database.\n         3. Path of database.\n         4. The id of the handle executing this SQL.\n         5. Detailed execution information of SQL. It is valid only when full sql trace is enable.\n     \n     @note  You should register trace before all db operations. Global tracer and db tracer do not interfere with each other.\n     \n         WCDB::Database::globalTraceSQL([](long tag,\n                                           const WCDB::UnsafeStringView &path,\n                                           const WCDB::UnsafeStringView &sql,\n                                           const void *handleIdentifier\n                                           const WCDB::UnsafeStringView &info) {\n             printf(\"Tag: %ld\", tag);\n             printf(\"Path: %s\", path.data());\n             printf(\"The handle with id %p executed %s\",\n                    handleIdentifier,\n                    sql.data());\n             printf(\"Excution info %s\", info.data());\n         });\n     \n     @warning Tracer may cause WCDB performance degradation, according to your needs to choose whether to open.\n     @see `SQLNotification`\n     @param trace closure\n     */\n    static void globalTraceSQL(SQLNotification trace);\n\n    /**\n     @brief You can register a tracer to monitor the execution of all SQLs executed in the current database.\n     @note  You should register trace before all db operations.\n     @warning Tracer may cause WCDB performance degradation, according to your needs to choose whether to open.\n     @param trace trace\n     @see `SQLNotification`\n     */\n    void traceSQL(SQLNotification trace);\n\n    /**\n     @brief Enable to collect more SQL execution information in SQL tracer.\n     @note  The detailed execution information of sql will include all bind parameters, step counts of `SELECT` statement,\n        last inserted rowid of `INSERT` statement, changes of `UPDATE` and `DELETE` statements.\n        These infomation will be returned in the last parameter of `SQLNotification`.\n     @warning Collecting these infomation will significantly reduce the performance of WCDB,\n        please enable it only when necessary, and disable it when unnecessary.\n     @see `SQLNotification`\n     @param enable enable or not.\n     */\n    void setFullSQLTraceEnable(bool enable);\n\n    enum Operation : short {\n        Create = 0,\n        SetTag,\n        OpenHandle,\n    };\n    /**\n     Triggered when a specific event of database occurs.\n     */\n    typedef std::function<void(Database &,            /* database */\n                               Operation,             /* type of operation*/\n                               StringViewMap<Value> & /* infos about current operation */\n                               )>\n    DBOperationTrace;\n\n    /**\n     The following are the keys in the infos from the callback of database operation monitoring.\n     */\n    // The number of alive handles to the current database.\n    static const StringView &MonitorInfoKeyHandleCount;\n    // The time in microseconds spent to open and config the handle.\n    static const StringView &MonitorInfoKeyHandleOpenTime;\n    // The cpu time in microseconds spent to open and config the handle.\n    static const StringView &MonitorInfoKeyHandleOpenCPUTime;\n    // The memory in bytes used to store the schema in sqlite handle.\n    static const StringView &MonitorInfoKeySchemaUsage;\n    // Number of tables in current database.\n    static const StringView &MonitorInfoKeyTableCount;\n    // Number of indexes in current database.\n    static const StringView &MonitorInfoKeyIndexCount;\n    // Number of triggers in current database.\n    static const StringView &MonitorInfoKeyTriggerCount;\n\n    /**\n     @brief You can register a tracer to these database events:\n         1. creating a database object for the first time;\n         2. setting a tag on the database;\n         3. opening a new database handle.\n     @param trace closure.\n     @see `DBOperationTrace`\n     */\n    static void globalTraceDatabaseOperation(DBOperationTrace trace);\n\n    typedef std::function<void(long /* tag */, const UnsafeStringView & /* path */, uint64_t /* id of the thread being waited on */, const UnsafeStringView & /* sql executing in the thread being waited on */\n                               )>\n    BusyTrace;\n\n    /**\n     @brief You can register a tracer to database busy events.\n     It returns:\n         1. Tag of database being busy.\n         2. Path of database being busy.\n         3. ID of the thread being waited on.\n         4. SQL executing in the thread being waited on.\n     @warning Since the tracer will be called back synchronously\n        when the database operation is blocked and times out,\n        you can neither directly access the busy database\n        nor perform heavy operation in the tracer.\n     @see `BusyTrace`\n     @param trace tracer.\n     @param timeOut timeout in seconds for blocking database operation\n     */\n    static void globalTraceBusy(BusyTrace trace, double timeOut);\n\n#pragma mark - File\npublic:\n    /**\n     @brief Remove all database-related files.\n     @return True if all files are removed.\n     */\n    bool removeFiles();\n\n    /**\n     @brief Move all database-related files to another directory safely.\n     @warning Since file operation is not atomic, There may be some accidents during this period. \n     For example, app may crash while db file is moved to destination and wal file is not.\n     Then none of destination and source contains the whole data.\n     This interface can make sure all of your data is in source or destination.\n     @param directory destination\n     @return True if all files are moved.\n     */\n    bool moveFiles(const UnsafeStringView &directory);\n\n    /**\n     @brief Paths to all database-related files.\n     @return paths\n     */\n    std::list<StringView> getPaths() const;\n\n    /**\n     @brief Get the space used by the database files.\n     @return The sum of files size in bytes.\n     */\n    Optional<size_t> getFilesSize() const;\n\n#pragma mark - FTS\npublic:\n    /**\n     @brief Enable to automatically merge b-tree segments of fts5 index after modifying the content in fts5 table.\n     The merge operation will be performed in a separate sub-thread, and will be suspended when it detects that other threads need to modify the fts table. So it will improve the performance of modifying the fts5 table.\n     Using auto-merge, WCDB can maintain only one segment per level in the fts5 index structure. So it will significantly improve the search performance of the fts5 index.\n     @param flag to enable auto-merge.\n     */\n    void enableAutoMergeFTS5Index(bool flag);\n\n    /**\n     @brief Setup tokenizer with name for current database.\n     It's recommended to use the builtin tokenizers defined in `FTSConst.h`.\n     @Note  You can set up the built-in tokenizers of sqlite and the tokenizers implemented by WCDB directly. If you want to use your custom tokenizer, you should firstly register it through `static Database::registerTokenizer()`.\n     @see   `static Database::registerTokenizer()`\n     */\n    void addTokenizer(const UnsafeStringView &tokenize);\n\n    /**\n     @brief Register custom tokenizer.\n     @Note  The custom tokenizer needs to inherit `WCDB::AbstractFTSTokenizer`.\n     @param module Tokenizer module for fts. You can use WCDB::FTS3TokenizerModuleTemplate to construct your custom tokenizer as tokenizer module for fts3/4, or use WCDB::FTS5TokenizerModuleTemplate to construct for fts5.\n     @param name Name of tokenizer.\n     */\n    static void\n    registerTokenizer(const UnsafeStringView &name, const TokenizerModule &module);\n\n    /**\n     @brief Setup auxiliary function with name for current database.\n     You can use the builtin tokenizers defined in `FTSConst.h`.\n     @Note  You can set up the built-in auxiliary functions of sqlite and the auxiliary functions implemented by WCDB directly. If you want to use your custom auxiliary function, you should firstly register it through `static Database::registerAuxiliaryFunction()`.\n     @see   `static Database::registerAuxiliaryFunction()`\n     */\n    void addAuxiliaryFunction(const UnsafeStringView &functionName);\n\n    /**\n     @brief Register custom auxiliary function for fts5.\n     @Note  The custom auxiliary function needs to inherit `WCDB::AbstractFTS5AuxiliaryFunctionObject`.\n     @param module Auxiliary function module for fts5. You can use `WCDB::FTS5AuxiliaryFunctionTemplate` to construct your custom auxiliary function as auxiliary function module.\n     @param name Name of auxiliary function.\n     */\n    static void registerAuxiliaryFunction(const UnsafeStringView &name,\n                                          const FTS5AuxiliaryFunctionModule &module);\n\n    /**\n     Triggered when WCDB implemented tokenizers parsing input content.\n     Return true if the input unicode character is symbol.\n     */\n    typedef unsigned short UnicodeChar;\n    typedef std::function<bool(UnicodeChar)> SymbolDetector;\n\n    /**\n     @brief Configure a symbol detector.\n     @warning You should configure a symbol detector before you use WCDB implemented tokenizers.\n     @param detector Symbol detector.\n     @see   `SymbolDetector`.\n     */\n    static void configSymbolDetector(SymbolDetector detector);\n\n    /**\n     Triggered when WCDB implemented tokenizers parsing input content.\n     Return the normalized unicode charecter of the input unicode character.\n     */\n    typedef std::function<StringView(const UnsafeStringView &)> UnicodeNormalizer;\n\n    /**\n     @brief Configure a unicode normalizer.\n     @warning You should configure a unicode normalizer before you use WCDB implemented tokenizers.\n     @param normalizer Unicode normalizer.\n     @see   `UnicodeNormalizer`.\n     */\n    static void configUnicodeNormalizer(UnicodeNormalizer normalizer);\n\n    /**\n     Triggered when `WCDB::BuiltinTokenizer::Pinyin` parsing input content.\n     Return the pinyin vecter of the input Chiniese character.\n     */\n    typedef std::function<std::vector<StringView>(const UnsafeStringView &)> PinYinConverter;\n\n    /**\n     @brief Configure a converter from Chinese characters to their pinyins.\n     @warning You should config this converter before using `WCDB::BuiltinTokenizer::Pinyin`.\n     @param converter pinyin converter.\n     @see   `BuiltinTokenizer::PinYin`.\n     */\n    static void configPinyinConverter(PinYinConverter converter);\n\n    /**\n     Triggered when the WCDB implemented tokenizers with `WCDB::BuiltinTokenizer::Parameter::SimplifyChinese` parsing input content.\n     Return the simplify Chiniese character of the input Chiniese character.\n     */\n    typedef std::function<const StringView(const UnsafeStringView &)> TraditionalChineseConverter;\n\n    /**\n     @brief Configure a converter from traditional Chinese characters to their simplified Chinese characters.\n     @warning You should config this converter before using the WCDB implemented tokenizers with `BuiltinTokenizer::Parameter::SimplifyChinese`.\n     @param converter traditional Chinese character converter.\n     @see   `TraditionalChineseConverter`.\n     */\n    static void configTraditionalChineseConverter(TraditionalChineseConverter converter);\n\n#pragma mark - Memory\n    /**\n     @brief Purge all free memory of this database.\n     WCDB will cache and reuse some sqlite db handles to improve performance.\n     The max count of free sqlite db handles is same as the number of concurrent threads supported by the hardware implementation.\n     You can call it to save some memory.\n     */\n    void purge();\n\n    /**\n     @brief Purge all free memory of all databases.\n     Note that WCDB will call this interface automatically while it receives memory warning on iOS.\n     @see   `purge`\n     */\n    static void purgeAll();\n\n#pragma mark - Repair\n    /**\n     Triggered when a database is confirmed to be corrupted.\n     */\n    typedef std::function<void(Database &)> CorruptionNotification;\n\n    /**\n     @brief Register database corruption notification callback.\n     If the current database reports an error of `SQLITE_CORRUPT` or `SQLITE_NOTADB` during operation, \n     WCDB will asynchronously use `PRAGMA integrity_check` to check whether this database is truly corrupted.\n     Once confirmed, WCDB will notify you through the callback registered by this function.\n     In the callback, you can delete the corrupted database or try to repair the database.\n     @see   `Database::removeFiles()`\n     @see   `Database::retrieve()`\n     @param onCorrupted The callback for database corruption.\n     */\n    void setNotificationWhenCorrupted(CorruptionNotification onCorrupted);\n\n    /**\n     @brief Check if the current database is corrupted.\n     @warning Since this function will check all the contents of the database until it finds something corrupted, it may take a lot of time to come to a conclusion.\n     @return True if the current database is corrupted.\n     */\n    bool checkIfCorrupted();\n\n    /**\n     @brief Check if the current database is already observed corrupted by WCDB.\n     @note  It only checks a internal flag of current database.\n     @return True if the current database is already corrupted.\n     */\n    bool isAlreadyCorrupted();\n\n    /**\n     @brief Enable database to automatically backup itself after there are updates.\n     The backup content mainly includes the SQL statements related to table creation and all leaf page numbers of each table in database. \n     And the backup file name is the database file name plus \"-first.material\" and \"-last.material\" suffixes.\n     @note  Auto-backup do not degrade IO performance of the database.\n     @param flag to enable auto-backup.\n     */\n    void enableAutoBackup(bool flag);\n\n    /**\n     @brief Back up the database manually.\n     @see   `Database::enableAutoBackup()`\n     @return True if the database is backuped successfully.\n     */\n    bool backup();\n\n    /**\n     Triggered before backup of each table. Return false to skip backup of this table.\n     */\n    typedef std::function<bool(const UnsafeStringView &table)> BackupFilter;\n\n    /**\n     @brief Set a filter to tell which table should be backed up.\n     The filter will be called for every table in database. \n     If there are some tables that do not need to be backed up, return false when these table names are passed into the filter.\n     @param tableShouldBeBackedUp block.\n     @see   `BackupFilter`\n     */\n    void filterBackup(BackupFilter tableShouldBeBackedUp);\n\n    /**\n     @brief Move the current database to a temporary directory and create a new database at current path.\n     This method is designed for conditions where the database is corrupted and cannot be repaired temporarily.\n     It can deposit the corrupted database to a new location and create a temporary database for the user.\n     The contents of the deposited database will be restored when you recover the database.\n     @note  This function can be called multiple times without loss of data.\n     @return True if new database is successfully created.\n     */\n    bool deposit();\n\n    /**\n     @brief Remove deposited data.\n     @see   `Database::deposit()`\n     @return True if all deposited data is removed.\n     */\n    bool removeDeposited();\n\n    /**\n     @brief Check whether there is deposited data.\n     @see   `Database::deposit()`\n     @return True if deposited data exists.\n     */\n    bool containsDeposited() const;\n\n    /**\n     @brief Recover data from a corruped db.\n     If there is a valid backup of this database, most of the uncorrupted data can be recovered, \n     otherwise WCDB will try to read all the data that can still be accessed, starting from the first page of the database.\n     In the extreme case where this database is not backed up and the first page is corrupted, no data can be recovered.\n     @warning Since repairing a database requires reading all uncorrupted data and writing them to a new database, it may take a lot of time to finish the job. \n     During this period, you'd better display a loading view on the screen and present the processing percentage.\n     @param onProgressUpdated block.\n     @see   `ProgressUpdateCallback`\n     @return Percentage of repaired data. 0 or less then 0 means data recovery failed. 1 means data is fully recovered.\n     */\n    double retrieve(ProgressUpdateCallback onProgressUpdated);\n\n#pragma mark - Config\n    enum CipherVersion : int {\n        DefaultVersion = 0,\n        Version1,\n        Version2,\n        Version3,\n        Version4,\n    };\n    /**\n     @brief Set cipher key for a database.\n     For an encrypted database, you must call it before all other operation.\n     The cipher page size defaults to 4096 in WCDB, but it defaults to 1024 in other databases. \n     So for an existing database created by other database framework, you should set it to 1024.\n     Otherwise, you'd better to use cipher page size with 4096 or simply call setCipherKey: interface to get better performance.\n     \n     @note  If your database is created with the default configuration of WCDB 1.0.x, please set cipherVersion to `CipherVersion::Version3`.\n     \n     @param cipherKey Cipher key.\n     @param cipherPageSize Cipher Page Size\n     @param cipherVersion Use the default configuration of a specific version of sqlcipher\n     */\n    void setCipherKey(const UnsafeData &cipherKey,\n                      int cipherPageSize = 4096,\n                      CipherVersion cipherVersion = CipherVersion::DefaultVersion);\n\n    /**\n     @brief Force SQLCipher to operate with the default settings consistent with that major version number as the default.\n     @note  It works the same as `PRAGMA cipher_default_compatibility`.\n     \n     @param version The specified sqlcipher major version.\n     */\n    static void setDefaultCipherConfiguration(CipherVersion version);\n\n    /**\n     Configuration\n     */\n    using Invocation = std::function<bool(Handle &)>;\n    enum Priority : int {\n        Highest = std::numeric_limits<int>::min(), // Only for cipher config\n        High = -100,\n        Default = 0,\n        Low = 100,\n    };\n    /**\n     @brief Set config for this database.\n     @note Since WCDB is a multi-handle database, an executing handle will not apply this config immediately. Instead, all handles will run this config before its next operation.\n     @warning If you want to add cipher config, please use `Priority::Highest`.\n     \n         database.setConfig(\"demo\", [](WCDB::Handle &handle){\n             return handle.execute(WCDB::StatementPragma().pragma(WCDB::Pragma::secureDelete()).to(true));\n         });\n     */\n    void setConfig(const UnsafeStringView &name,\n                   Invocation invocation,\n                   Invocation unInvocation = nullptr,\n                   Priority priority = Priority::Default);\n\n    /**\n     @brief Remove a config.\n     */\n    void removeConfig(const UnsafeStringView &name);\n\n    /**\n    @brief Set the default directory for temporary database files. If not set, an existing directory will be selected as the temporary database files directory in the following order:\n        1. TMPDIR environment value;\n        2. /Var/tmp;\n        3. /usr/tmp;\n        4. /tmp;\n        5. The current working directory (\".\")\n    Please see: https://www.sqlite.org/tempfiles.html\n    @param directory a global temporary directory.\n    @return true if directory exists or create directory success.\n    */\n    static bool setDefaultTemporaryDirectory(const UnsafeStringView &directory);\n\n    /**\n     @brief Register custom scalar function.\n     @Note  The custom scalar function needs to inherit `WCDB::AbstractScalarFunctionObject`.\n     @param module Scalar function module. You can use WCDB::ScalarFunctionTemplate to construct your custom scalar function as scalar function module.\n     @param name Name of scalar function.\n     */\n    static void registerScalarFunction(const ScalarFunctionModule &module,\n                                       const UnsafeStringView &name);\n\n    /**\n     @brief Setup scalar function with name for current database.\n     @Note  You can set up the built-in scalar functions of sqlite and the scalar functions implemented by WCDB directly. If you want to use your custom scalar function, you should firstly register it through `static Database::registerScalarFunction()`.\n     @see   `static Database::registerScalarFunction()`\n     */\n    void addScalarFunction(const UnsafeStringView &name);\n\n    /**\n     @brief Enable/Disable Lite mode.\n     Lite mode is disabled by default.\n     In lite mode, the journal mode and synchronous flag of current database will be set to `OFF`,\n     which will significantly reduces IO, improve performance, and also increase the probability of data corruption.\n     @warning You can not rollback transaction or backup data in lite mode.\n     */\n    void enableLiteMode(bool enable);\n\n#ifndef _WIN32\n    /**\n     @brief Register an open interface to replace the default one.\n     You can use it to implement file descriptor sanitizer, file open error monitoring, etc.\n     */\n    typedef int (*POSIXOpen)(const char *, int, int);\n    static void registerPOSIXOpen(POSIXOpen open);\n\n    /**\n     @brief Register an close interface to replace the default one.\n     You can use it to implement file descriptor sanitizer, file open error monitoring, etc.\n     */\n    typedef int (*POSIXClose)(int);\n    static void registerPOSIXClose(POSIXClose close);\n#endif\n\n#pragma mark - Migration\n    typedef struct MigrationInfo {\n        StringView table;           // Target table of migration\n        StringView sourceTable;     // Source table of migration\n        Expression filterCondition; // Filter condition of source table\n    } MigrationInfo;\n\n    /**\n     Triggered at any time when WCDB needs to know whether a table in the current database needs to migrate data, \n     mainly including creating a new table, reading and writing a table, and starting to migrate a new table.\n     If the current table does not need to migrate data, you need to set the sourceTable in `WCDB::Database::MigrationInfo` to empty string.\n     */\n    typedef std::function<void(MigrationInfo &)> TableFilter;\n\n    /**\n     @brief Configure which tables in the current database need to migrate data, and the source table they need to migrate data from.\n     Once configured, you can treat the target table as if it already has all the data of the source table, and can read and write these data through the target table. \n     WCDB will internally convert your CRUD operations on the target table into the CRUD operations on both the target table and the source table appropriately.\n     You neither need to be aware of the existence of the source table, nor care about the progress of data migration.\n     @warning  The column definition of the target table must be exactly the same as the column definition of the source table. \n     The database does not record the state of the migration to disk, so if you have data to migrate, you need to use this function to configure the migration before executing any statements on current database.\n     @note  If the source table is in the current database, you can set sourcePath to empty string.\n     @note  If the source table is not in the current database, the database containing the source table will be attached to the current database before the migration is complete. After migration, source tables will be dropped.\n     @see   `MigrationFilter`\n     */\n    void addMigration(const UnsafeStringView &sourcePath,\n                      const UnsafeData &sourceCipher,\n                      const TableFilter &filter);\n\n    /**\n     @brief Manually spend about 0.01 sec. to migrate data. \n     You can call this function periodically until all data is migrated.\n     @return True if no error occurred.\n     */\n    bool stepMigration();\n\n    /**\n     @brief Configure the database to automatically step migration every two seconds.\n     @param flag to enable auto-migration.\n     */\n    void enableAutoMigration(bool flag);\n\n    /**\n     Triggered when a table or a database is migrated completely. \n     When a table is migrated successfully, tableInfo will carry the information of the table.\n     When a database is migrated, tableInfo has no value.\n     */\n    typedef std::function<void(Database &database, Optional<MigrationInfo> tableInfo)> MigratedCallback;\n\n    /**\n     @brief Register a callback for migration notification. \n     The callback will be called when each table completes the migration.\n     @param onMigrated closure\n     @see   `MigratedCallback`\n     */\n    void setNotificationWhenMigrated(MigratedCallback onMigrated);\n\n    /**\n     @brief Check if all tables in the database has finished migration.\n     @note  It only check an internal flag of database.\n     @return True if all tables in the database has finished migration.\n     */\n    bool isMigrated() const;\n\n#pragma mark - Compression\n\n    typedef unsigned char DictId;\n    static constexpr const int64_t DictDefaultMatchValue = INT64_MAX;\n\n    class CompressionInfo {\n    public:\n        /**\n         @brief The table to be compressed.\n         */\n        const StringView &getTableName() const;\n\n        /**\n         @brief Configure to compress all data in the specified column with the default zstd compression algorithm.\n         */\n        void addZSTDNormalCompressField(const Field &field);\n\n        /**\n         @brief Configure to compress all data in the specified column with a registered zstd dict.\n         */\n        void addZSTDDictCompressField(const Field &field, DictId dictId);\n\n        /**\n         @brief Configure to compress all data in the specified column with multi registered zstd dict.\n         Which dict to use when compressing is based on the value of the specified matching column.\n         @note You can use `DictDefaultMatchValue` to specify a default dict.\n         @warning The matching column must be an integer column.\n         */\n        void\n        addZSTDDictCompressField(const Field &field,\n                                 const Field &matchField,\n                                 const std::map<int64_t /* Value of match column */, DictId> &dictIds);\n\n        /**\n         @brief Enable to replace original compression format.\n         After activation, you can use `Database::stepCompression()` or `Database::enableAutoCompression()` to recompress the existing data with the new compression configuration.\n         */\n        void enableReplaceCompresssion();\n\n    protected:\n        friend class Database;\n        CompressionInfo(void *innerInfo);\n\n    private:\n        void *m_innerInfo;\n    };\n\n    /**\n     @brief Train a zstd formalized dict with a set of sample strings.\n     @Warning The total size of all samples cannot exceed 4G.\n     @param strings samples.\n     @param dictId spercified id of the result dict. It can not be zero.\n     @return a dict of 100KB if succeed.\n     */\n    static Optional<Data> trainDict(const std::vector<std::string> &strings, DictId dictId);\n\n    /**\n     @brief Train a zstd formalized dict with a set of sample datas.\n     @Warning The total size of all samples cannot exceed 4G.\n     @param datas samples.\n     @param dictId spercified id of the result dict. It can not be zero.\n     @return a dict of 100KB if succeed.\n     */\n    static Optional<Data> trainDict(const std::vector<Data> &datas, DictId dictId);\n\n    /**\n     @brief Register a zstd dict in to WCDB.\n     @Note You must register a dict before using it.\n     @param dict dict data.\n     @param dictId id of the dict. It can not be zero.\n     @return true if the dictionary can be successfully decoded and the dictId does not conflict with a registered dict.\n     */\n    static bool registerZSTDDict(const UnsafeData &dict, DictId dictId);\n\n    /**\n     Triggered at any time when WCDB needs to know whether a table in the current database needs to compress data,\n     mainly including creating a new table, reading and writing a table,and starting to compress a new table.\n     If the current table does not need to compress data, you don't need to config WCTCompressionUserInfo.\n     */\n    typedef std::function<void(CompressionInfo &)> CompressionFilter;\n\n    /**\n     @brief Configure which tables in the current database need to compress data.\n     Once configured, newly written data will be compressed immediately and synchronously,\n     and you can use `Database::stepCompression()` and `Database::enableAutoCompression()` to compress existing data.\n     @warning  You need to use this method to configure the compression before executing any statements on current database.\n     @see   `Database::CompressionFilter`\n     */\n    void setCompression(const CompressionFilter &filter);\n\n    /**\n     @brief Configure not to compress new data written to the current database.\n     This configuration is mainly used to deal with some emergency scenarios.\n     It allows already compressed data to be read normally, but new data is no longer compressed.\n     @param disable disable compression or not.\n     */\n    void disableCompresssNewData(bool disable);\n\n    /**\n     @brief Manually compress 100 rows of existing data. \n     You can call this method periodically until all data is compressed.\n     @return true if no error occurred.\n     */\n    bool stepCompression();\n\n    /**\n     @brief Configure the database to automatically compress 100 rows of existing data every two seconds.\n     @param flag to enable auto-compression.\n     */\n    void enableAutoCompression(bool flag);\n\n    /**\n     Triggered when a table is compressed completely.\n     When a table is compressed successfully, tableName will be valid.\n     When a database is totally compressed, tableName will be NullOpt.\n     */\n    typedef std::function<void(Database &database, Optional<StringView> tableName)> CompressedCallback;\n\n    /**\n     @brief Register a callback for compression notification. \n     The callback will be called when each table completes the compression.\n     @see   `Database::CompressedCallback`\n     */\n    void setNotificationWhenCompressed(const CompressedCallback &onCompressd);\n\n    /**\n     @brief Check if all tables in the database has finished compression.\n     @note  It only check an internal flag of database.\n     @return true if all tables in the database has finished compression.\n     */\n    bool isCompressed() const;\n\n    /**\n     @brief Decompress all compressed data in the database and resave them.\n     @note  It will clear all compression status and progress, and disables automatic compression.\n     @warning If the rollback process is interrupted or failed, the data may be in a mixed state of compressed and uncompressed.\n     @return true if all operation succeed.\n     */\n    bool rollbackCompression(ProgressUpdateCallback onProgressUpdated);\n\n#pragma mark - Version\n    /**\n     Version of WCDB.\n     */\n    static const StringView getVersion();\n\n    /**\n     Source id of WCDB. It varies from each build of WCDB.\n     */\n    static const StringView getSourceId();\n};\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/cpp/core/Handle.cpp",
    "content": "//\n// Created by qiuwenchen on 2022/8/3.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"Handle.hpp\"\n#include \"InnerDatabase.hpp\"\n#include \"InnerHandle.hpp\"\n#include \"RecyclableHandle.hpp\"\n\n#define GetInnerHandleOrReturnValue(value)                                     \\\n    InnerHandle* handle = getOrGenerateHandle();                               \\\n    if (handle == nullptr) {                                                   \\\n        return value;                                                          \\\n    }\n\n#define GetInnerHandleOrReturn                                                 \\\n    InnerHandle* handle = getOrGenerateHandle();                               \\\n    if (handle == nullptr) {                                                   \\\n        return;                                                                \\\n    }\n\nnamespace WCDB {\n\nHandle::Handle(Recyclable<InnerDatabase*> database)\n: m_databaseHolder(database), m_innerHandle(nullptr)\n{\n}\n\nHandle::Handle(RecyclableHandle handle)\n: m_handleHolder(handle), m_innerHandle(handle.get())\n{\n}\n\nHandle::Handle(Recyclable<InnerDatabase*> database, InnerHandle* handle)\n: m_databaseHolder(database), m_innerHandle(handle)\n{\n}\n\nHandle::Handle(Handle&& other)\n: m_databaseHolder(std::move(other.m_databaseHolder))\n, m_handleHolder(std::move(other.m_handleHolder))\n, m_innerHandle(other.m_innerHandle)\n{\n}\n\nHandle::~Handle()\n{\n    invalidate();\n};\n\nInnerHandle* Handle::getOrGenerateHandle(bool writeHint)\n{\n    if (m_innerHandle == nullptr) {\n        m_handleHolder = m_databaseHolder->getHandle(writeHint);\n        if (m_handleHolder != nullptr) {\n            m_innerHandle = m_handleHolder.get();\n        }\n    }\n    return m_innerHandle;\n}\n\nHandleStatement* Handle::getInnerHandleStatement()\n{\n    GetInnerHandleOrReturnValue(nullptr);\n    return handle->m_mainStatement;\n}\n\nRecyclableHandle Handle::getHandleHolder(bool)\n{\n    getOrGenerateHandle(false);\n    if (m_handleHolder != nullptr) {\n        return m_handleHolder;\n    } else {\n        return RecyclableHandle(\n        std::shared_ptr<InnerHandle>(m_innerHandle, [](InnerHandle*) {}), nullptr);\n    }\n}\n\nRecyclable<InnerDatabase*> Handle::getDatabaseHolder()\n{\n    WCTAssert(m_databaseHolder != nullptr);\n    return m_databaseHolder;\n}\n\nvoid Handle::invalidate()\n{\n    m_innerHandle = nullptr;\n    m_handleHolder = nullptr;\n}\n\nlong long Handle::getLastInsertedRowID()\n{\n    GetInnerHandleOrReturnValue(0);\n    return handle->getLastInsertedRowID();\n}\n\nint Handle::getChanges()\n{\n    GetInnerHandleOrReturnValue(0);\n    return handle->getChanges();\n}\n\nint Handle::getTotalChange()\n{\n    GetInnerHandleOrReturnValue(0);\n    return handle->getTotalChange();\n}\n\nconst Error& Handle::getError()\n{\n    if (m_innerHandle != nullptr) {\n        return m_innerHandle->getError();\n    }\n    if (m_databaseHolder != nullptr) {\n        return m_databaseHolder->getThreadedError();\n    }\n    static Error* error = new Error();\n    return *error;\n}\n\nOptionalPreparedStatement Handle::getOrCreatePreparedStatement(const Statement& statement)\n{\n    OptionalPreparedStatement result;\n    GetInnerHandleOrReturnValue(result);\n    HandleStatement* preparedStatement = handle->getOrCreatePreparedStatement(statement);\n    if (preparedStatement == nullptr) {\n        return result;\n    }\n    return PreparedStatement(preparedStatement);\n}\n\nvoid Handle::finalizeAllStatement()\n{\n    GetInnerHandleOrReturn;\n    handle->finalizeStatements();\n}\n\nvoid Handle::attachCancellationSignal(const CancellationSignal& signal)\n{\n    GetInnerHandleOrReturn;\n    handle->attachCancellationSignal(signal.m_signal);\n}\n\nvoid Handle::detachCancellationSignal()\n{\n    GetInnerHandleOrReturn;\n    handle->detachCancellationSignal();\n}\n\nHandle::CancellationSignal::CancellationSignal()\n: m_signal(std::make_shared<bool>(false)) {};\n\nHandle::CancellationSignal::~CancellationSignal() = default;\n\nvoid Handle::CancellationSignal::cancel()\n{\n    *m_signal = true;\n}\n\nvoid Handle::tryPreloadAllPages()\n{\n    GetInnerHandleOrReturn;\n    handle->tryPreloadAllPages();\n}\n\nvoid Handle::setFileChunkSize(size_t size)\n{\n    GetInnerHandleOrReturn;\n    handle->setFileChunkSize((int) size);\n}\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/cpp/core/Handle.hpp",
    "content": "//\n// Created by qiuwenchen on 2022/8/3.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n#include \"HandleORMOperation.hpp\"\n#include \"HandleOperation.hpp\"\n#include \"PreparedStatement.hpp\"\n#include \"Statement.hpp\"\n\nnamespace WCDB {\n\nclass WCDB_API Handle final : public StatementOperation, public HandleORMOperation {\n    friend class Database;\n    friend class HandleOperation;\n    friend class TableOperation;\n    friend class BaseChainCall;\n    friend class Delete;\n\n#pragma mark - Basic\nprotected:\n    Handle() = delete;\n    Handle(const Handle&) = delete;\n    Handle& operator=(const Handle&) = delete;\n\n    Handle(RecyclableHandle handle);\n    Handle(Recyclable<InnerDatabase*> database);\n    Handle(Recyclable<InnerDatabase*> database, InnerHandle* handle);\n\n    InnerHandle* getOrGenerateHandle(bool writeHint = false);\n    HandleStatement* getInnerHandleStatement() override final;\n    RecyclableHandle getHandleHolder(bool writeHint) override final;\n    Recyclable<InnerDatabase*> getDatabaseHolder() override final;\n\nprivate:\n    Recyclable<InnerDatabase*> m_databaseHolder;\n    RecyclableHandle m_handleHolder;\n    InnerHandle* m_innerHandle;\n\npublic:\n    Handle(Handle&& other);\n    ~Handle() override;\n\n    /**\n     @brief Recycle the sqlite db handle inside, and the current handle will no longer be able to perform other operations.\n     @warning If you use obtain current handle through `Database::getHandle()`, you need to call its invalidate function when you are done with it, otherwise you will receive an Assert Failure.\n     */\n    void invalidate();\n\n    /**\n     @brief The wrapper of `sqlite3_last_insert_rowid`.\n     @note It is for the statement previously prepared by `Handle::prepare()`.\n     */\n    long long getLastInsertedRowID();\n\n    /**\n     @brief The wrapper of `sqlite3_changes`.\n     */\n    int getChanges();\n\n    class CancellationSignal {\n        friend class Handle;\n\n    public:\n        CancellationSignal();\n        ~CancellationSignal();\n        /**\n         @brief Cancel all operations of the attached handle.\n         */\n        void cancel();\n\n    private:\n        std::shared_ptr<volatile bool> m_signal;\n    };\n\n    /**\n     @brief The wrapper of `sqlite3_progress_handler`.\n     \n     You can asynchronously cancel all operations on the current handle through `CancellationSignal`.\n     \n         WCDB::Handle::CancellationSignal signal;\n         auto future = std::async(std::launch::async, [=](){\n            WCDB::Handle handle = database.getHandle();\n            handle.attachCancellationSignal(signal);\n     \n            // Do some time-consuming database operations.\n     \n            handle.detachCancellationSignal();\n         });\n         signal.cancel();\n     \n     @warning Note that you can use `CancellationSignal` in multiple threads,\n     but you can only use the current handle in the thread that you got it.\n     */\n    void attachCancellationSignal(const CancellationSignal& signal);\n\n    /**\n     @brief Detach the attached `CancellationSignal`.\n            `CancellationSignal` can be automatically detached when the current handle deconstruct.\n     */\n    void detachCancellationSignal();\n\n    /**\n     @brief The wrapper of `sqlite3_total_changes`.\n     */\n    int getTotalChange();\n\n    /**\n     @brief Get the most recent error for current handle in the current thread.\n            Since it is too cumbersome to get the error after every operation, it‘s better to use monitoring interfaces to obtain errors and print them to the log.\n     @see   `static Database::globalTraceError()`\n     @see   `Database::traceError()`\n     @return WCDB::Error\n     */\n    const Error& getError();\n\n    /**\n     @brief Try to preload all database pages into memory.\n     This may help to improve read performance on some slow devices.\n     */\n    void tryPreloadAllPages();\n\n    /**\n     @brief The wrapper of `SQLITE_FCNTL_CHUNK_SIZE`\n     The db files will be extended and truncated in chunks of a size specified by the user.\n     */\n    void setFileChunkSize(size_t size);\n\n#pragma mark - Multi Statement\npublic:\n    /**\n     @brief Use `sqlite3_prepare` internally to prepare a new statement, and wrap the `sqlite3_stmt` generated by `sqlite3_prepare` into `WCDB::PreparedStatement` to return.\n     If the statement has been prepared by this function before, and you have not used `Handle::invalidate()` or `Handle::finalizeAllStatement()` to finalize it, then you can use this function to regain the previously generated `sqlite3_stmt`.\n     @note  This function is designed for the situation where you need to use multiple statements at the same time to do complex database operations. You can prepare a new statement without finalizing the previous statements, so that you can save the time of analyzing SQL syntax.\n     If you only need to use one statement, or you no longer need to use the previous statements when you use a new statement, it is recommended to use `HandleOperation::execute()` or `StatementOperation::prepare()`.\n     @see   `HandleOperation::execute()`\n     @see   `StatementOperation::prepare()`\n     @param statement The SQL statememt needed to prepare.\n     @return a `WCDB::PreparedStatement` object with `sqlite3_stmt` inside, or nil if error occurs.\n     */\n    OptionalPreparedStatement getOrCreatePreparedStatement(const Statement& statement);\n\n    /**\n     @brief Use `sqlite3_finalize` to finalize all `sqlite3_stmt` generate by current handle.\n     @note  `Handle::invalidate()` will internally call the current function.\n     */\n    void finalizeAllStatement();\n};\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/cpp/core/PreparedStatement.cpp",
    "content": "//\n// Created by qiuwenchen on 2022/8/3.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"PreparedStatement.hpp\"\n#include \"HandleStatement.hpp\"\n\nnamespace WCDB {\n\nPreparedStatement::PreparedStatement(HandleStatement* handleStatement)\n: m_innerHandleStatement(handleStatement)\n{\n}\n\nPreparedStatement::PreparedStatement(PreparedStatement&& other)\n: m_innerHandleStatement(other.m_innerHandleStatement)\n{\n}\n\nPreparedStatement::~PreparedStatement() = default;\n\nHandleStatement* PreparedStatement::getInnerHandleStatement()\n{\n    return m_innerHandleStatement;\n}\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/cpp/core/PreparedStatement.hpp",
    "content": "//\n// Created by qiuwenchen on 2022/8/3.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n#include \"CPPDeclaration.h\"\n#include \"Statement.hpp\"\n#include \"StatementOperation.hpp\"\n\nnamespace WCDB {\n\nclass WCDB_API PreparedStatement final : public StatementOperation {\n    friend class Handle;\n\npublic:\n    PreparedStatement(PreparedStatement &&other);\n    ~PreparedStatement() override;\n\nprotected:\n    PreparedStatement() = delete;\n    PreparedStatement(const PreparedStatement &) = delete;\n    PreparedStatement &operator=(const PreparedStatement &) = delete;\n    PreparedStatement(HandleStatement *handleStatement);\n\n    HandleStatement *getInnerHandleStatement() override final;\n    using StatementOperation::prepare;\n    using StatementOperation::isPrepared;\n    using StatementOperation::finalize;\n\nprivate:\n    HandleStatement *m_innerHandleStatement;\n};\n\ntypedef Optional<PreparedStatement> OptionalPreparedStatement;\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/cpp/core/Table.cpp",
    "content": "//\n// Created by qiuwenchen on 2022/8/28.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"Table.hpp\"\n#include \"Database.hpp\"\n#include \"Handle.hpp\"\n#include \"InnerDatabase.hpp\"\n#include \"StatementDropIndex.hpp\"\n\nnamespace WCDB {\n\nBaseTable::BaseTable(Recyclable<InnerDatabase*> databaseHolder, const UnsafeStringView& tableName)\n: m_tableName(tableName)\n, m_databaseHolder(databaseHolder)\n, m_innerDatabase(databaseHolder.get())\n{\n}\n\nBaseTable::BaseTable(const BaseTable&) = default;\n\nBaseTable::~BaseTable() = default;\n\nBaseTable& BaseTable::operator=(const BaseTable&) = default;\n\nconst Error& BaseTable::getError() const\n{\n    return m_innerDatabase->getThreadedError();\n}\n\nRecyclableHandle BaseTable::getHandle(bool writeHint)\n{\n    return m_databaseHolder->getHandle(writeHint);\n}\n\nconst StringView& BaseTable::getTableName() const\n{\n    return m_tableName;\n}\n\nDatabase BaseTable::getDatabase() const\n{\n    return Database(m_databaseHolder);\n}\n\nStringView BaseTable::getIndexNameWithSuffix(const UnsafeStringView& suffix) const\n{\n    return StringView::formatted(\"%s%s\", m_tableName.data(), suffix.data());\n}\n\nbool BaseTable::dropIndexWithSuffix(const UnsafeStringView& suffix)\n{\n    return m_innerDatabase->execute(\n    StatementDropIndex().dropIndex(getIndexNameWithSuffix(suffix)).ifExists());\n}\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/cpp/core/Table.hpp",
    "content": "//\n// Created by qiuwenchen on 2022/8/28.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n#include \"TableORMOperation.hpp\"\n\nnamespace WCDB {\n\nclass WCDB_API BaseTable {\npublic:\n    BaseTable() = delete;\n    BaseTable(const BaseTable &);\n    BaseTable &operator=(const BaseTable &);\n    virtual ~BaseTable() = 0;\n\n#pragma mark - Basic\n    /**\n     @brief Get the most recent error for the database of current table in the current thread.\n            Since it is too cumbersome to get the error after every database operation, it‘s better to use monitoring interfaces to obtain database errors and print them to the log.\n     @see   `static Database::globalTraceError()`\n     @see   `Database::traceError()`\n     @return WCDB::Error\n     */\n    const Error &getError() const;\n\n    /**\n     @brief Get the name of the table.\n     */\n    const StringView &getTableName() const;\n\n    /**\n     @brief Get the related database\n     */\n\n    Database getDatabase() const;\n\n    /**\n     @brief Drop index with name tableName + suffix.\n     */\n    bool dropIndexWithSuffix(const UnsafeStringView &suffix);\n\nprotected:\n    BaseTable(Recyclable<InnerDatabase *> database, const UnsafeStringView &tableName);\n    RecyclableHandle getHandle(bool writeHint);\n    StringView getIndexNameWithSuffix(const UnsafeStringView &suffix) const;\n\n    StringView m_tableName;\n    Recyclable<InnerDatabase *> m_databaseHolder;\n    InnerDatabase *m_innerDatabase;\n};\n\ntemplate<class ObjectType>\nclass Table final : public BaseTable, public TableORMOperation<ObjectType> {\n    friend class HandleORMOperation;\n\n    WCDB_CPP_ORM_STATIC_ASSERT_FOR_OBJECT_TYPE\n\nprotected:\n    Table(Recyclable<InnerDatabase *> database, const UnsafeStringView &tableName)\n    : BaseTable(database, tableName)\n    {\n    }\n\nprivate:\n    RecyclableHandle getHandleHolder(bool writeHint) override final\n    {\n        return getHandle(writeHint);\n    }\n    Recyclable<InnerDatabase *> getDatabaseHolder() override final\n    {\n        return m_databaseHolder;\n    }\n\npublic:\n    Table() = delete;\n    Table(const Table &) = default;\n    Table &operator=(const Table &) = default;\n    ~Table() override final = default;\n\n    const StringView &getTableName() const override final\n    {\n        return BaseTable::getTableName();\n    }\n\n    using ORMType = ObjectType;\n};\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/cpp/orm/CPPORM.h",
    "content": "//\n// Created by qiuwenchen on 2022/8/26.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"Binding.hpp\"\n#include \"FTSTokenizerUtil.hpp\"\n#include \"Field.hpp\"\n#include \"MemberPointer.hpp\"\n#include \"ResultField.hpp\"\n#include \"RunTimeAccessor.hpp\"\n#include \"STDOptionalAccessor.hpp\"\n#include \"SharedPtrAccessor.hpp\"\n#include \"WCDBOptionalAccessor.hpp\"\n"
  },
  {
    "path": "src/cpp/orm/binding/Accessor.cpp",
    "content": "//\n// Created by qiuwenchen on 2022/8/26.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"Accessor.hpp\"\n#include \"Notifier.hpp\"\n\nnamespace WCDB {\n\nBaseAccessor::BaseAccessor() = default;\n\nBaseAccessor::~BaseAccessor() = default;\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/cpp/orm/binding/Accessor.hpp",
    "content": "//\n// Created by qiuwenchen on 2022/8/26.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n#include \"ColumnType.hpp\"\n#include \"MemberPointer.hpp\"\n#include \"WCDBError.hpp\"\n\nnamespace WCDB {\n\nclass WCDB_API BaseAccessor {\npublic:\n    BaseAccessor();\n    virtual ~BaseAccessor() = 0;\n    virtual ColumnType getColumnType() const = 0;\n};\n\ntemplate<class O, WCDB::ColumnType t>\nclass Accessor : public BaseAccessor {\nprotected:\n    using UnderlyingType = typename WCDB::ColumnTypeInfo<t>::UnderlyingType;\n    using ORMType = O;\n\npublic:\n    virtual ~Accessor() override = default;\n    ColumnType getColumnType() const override final { return t; };\n\n    virtual bool isNull(const ORMType&) const = 0;\n    virtual void setNull(ORMType& instance) const = 0;\n    virtual void setValue(ORMType& instance, const UnderlyingType& value) const = 0;\n    virtual UnderlyingType getValue(const ORMType& instance) const = 0;\n};\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/cpp/orm/binding/Binding.cpp",
    "content": "//\n// Created by qiuwenchen on 2022/8/26.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"Binding.hpp\"\n#include \"Accessor.hpp\"\n#include \"Assertion.hpp\"\n#include \"Field.hpp\"\n\nnamespace WCDB {\n\nBinding::Binding() : BaseBinding() {};\n\nBinding::~Binding() {};\n\n#pragma mark - Inherit\nvoid Binding::inherit(const Binding &binding)\n{\n    m_columnDefs.insert(\n    m_columnDefs.end(), binding.m_columnDefs.begin(), binding.m_columnDefs.end());\n    m_constraints.insert(binding.m_constraints.begin(), binding.m_constraints.end());\n    m_indexes.insert(binding.m_indexes.begin(), binding.m_indexes.end());\n    m_fields.insert(m_fields.end(), binding.m_fields.begin(), binding.m_fields.end());\n}\n\n#pragma mark - Field\n\nconst Field &\nBinding::registerField(void *memberPointer, const UnsafeStringView &name, BaseAccessor *accessor)\n{\n    m_fieldMap[memberPointer] = std::make_pair(name, accessor);\n    m_columnDefs.emplace_back(\n    std::make_pair(name, ColumnDef(name, accessor->getColumnType())));\n    m_fields.emplace_back(name, accessor);\n    m_fields.back().syntax().tableBinding = this;\n    return m_fields.back();\n}\n\nconst StringView &Binding::getColumnName(void *memberPointer) const\n{\n    auto iter = m_fieldMap.find(memberPointer);\n    WCTAssert(iter != m_fieldMap.end());\n    return iter->second.first;\n}\n\nconst BaseAccessor *Binding::getAccessor(void *memberPointer) const\n{\n    auto iter = m_fieldMap.find(memberPointer);\n    WCTAssert(iter != m_fieldMap.end());\n    return iter->second.second;\n}\n\nconst Fields &Binding::allFields() const\n{\n    return m_fields;\n}\n\n#pragma mark - ColumnDef\nColumnDef *Binding::getColumnDef(void *memberPointer)\n{\n    const StringView &name = getColumnName(memberPointer);\n    return BaseBinding::getColumnDef(name);\n}\n\n#pragma mark - IndexColumn\nIndexedColumn Binding::getIndexColumn(void *memberPointer)\n{\n    const StringView &name = getColumnName(memberPointer);\n    return IndexedColumn(name);\n}\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/cpp/orm/binding/Binding.hpp",
    "content": "//\n// Created by qiuwenchen on 2022/8/26.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"BaseBinding.hpp\"\n#include \"CPPDeclaration.h\"\n#include \"Field.hpp\"\n#include <map>\n\nnamespace WCDB {\n\ntemplate<typename Base, typename Derive>\nvoid assertFirstBaseClass()\n{\n    int offsetOfBase = (char*) (Base*) (Derive*) 0x1000 - (char*) (Derive*) 0x1000;\n    // Base must be the first base class of Derive\n    assert(offsetOfBase == 0);\n    WCDB_UNUSED(offsetOfBase);\n}\n\nclass WCDB_API Binding final : public BaseBinding {\npublic:\n    Binding();\n    ~Binding() override;\n\n#pragma mark - Inherit\npublic:\n    void inherit(const Binding& binding);\n\n#pragma mark - Field\npublic:\n    const Field&\n    registerField(void* memberPointer, const UnsafeStringView& name, BaseAccessor* accessor);\n    const StringView& getColumnName(void* memberPointer) const;\n    const BaseAccessor* getAccessor(void* memberPointer) const;\n    const Fields& allFields() const;\n\nprivate:\n    using FieldMap = std::map<void*, std::pair<StringView, BaseAccessor*>>;\n    FieldMap m_fieldMap;\n    Fields m_fields;\n\n#pragma mark - ColumnDef\npublic:\n    using BaseBinding::getColumnDef;\n    ColumnDef* getColumnDef(void* memberPointer);\n\n#pragma mark - IndexColumn\npublic:\n    IndexedColumn getIndexColumn(void* memberPointer);\n};\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/cpp/orm/binding/Field.cpp",
    "content": "//\n// Created by qiuwenchen on 2022/8/26.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"Field.hpp\"\n#include \"Accessor.hpp\"\n#include \"Assertion.hpp\"\n#include \"Binding.hpp\"\n#include \"ResultField.hpp\"\n\nnamespace WCDB {\n\n#pragma mark - Field\n\nField::Field(const UnsafeStringView& name, const BaseAccessor* accessor)\n: Column(name), m_accessor(accessor)\n{\n}\n\nField::Field(const BaseAccessor* accessor, const Column& column)\n: Column(column), m_accessor(accessor)\n{\n}\n\nField::~Field() = default;\n\nconst BaseAccessor* Field::getAccessor() const\n{\n    return m_accessor;\n}\n\nvoid Field::configWithBinding(const Binding& binding, void* memberPointer)\n{\n    syntax().name = binding.getColumnName(memberPointer);\n    syntax().tableBinding = static_cast<const BaseBinding*>(&binding);\n    m_accessor = binding.getAccessor(memberPointer);\n}\n\nField Field::table(const UnsafeStringView& table) const\n{\n    return Field(m_accessor, Column(*this).table(table));\n}\n\nField Field::schema(const Schema& schema) const\n{\n    return Field(m_accessor, Column(*this).schema(schema));\n}\n\nResultField Field::redirect(const ResultColumn& resultColumn) const\n{\n    return ResultField(resultColumn, m_accessor);\n}\n\n#pragma mark - Fields\nFields::~SyntaxList() = default;\n\nExpression Fields::count() const\n{\n    return Expression::function(\"count\").invokeAll();\n}\n\n#ifndef __linux__\nResultFields Fields::redirect(const ResultColumns& resultColumns) const\n{\n    ResultFields result;\n    auto field = begin();\n    auto resultColumn = resultColumns.begin();\n    while (field != end() && resultColumn != resultColumns.end()) {\n        result.push_back(ResultField(*resultColumn, field->getAccessor()));\n        ++field;\n        ++resultColumn;\n    }\n    return result;\n}\n#endif\n\nResultFields Fields::redirect(RedirectAction action) const\n{\n    WCTRemedialAssert(action != nullptr, \"Redirect block can't be null.\", return *this;);\n    ResultFields results;\n    for (const auto& field : *this) {\n        results.push_back(ResultField(action(field), field.getAccessor()));\n    }\n    return results;\n}\n\nExpressions Fields::table(const StringView& table) const\n{\n    Expressions expressions;\n    for (const auto& field : *this) {\n        expressions.push_back(field.table(table));\n    }\n    return expressions;\n}\n\nFields Fields::fieldsByAddingNewFields(const Fields& fields) const\n{\n    Fields newFields = *this;\n    newFields.insert(newFields.begin(), fields.begin(), fields.end());\n    return newFields;\n}\n\nFields& Fields::addingNewFields(const Fields& fields)\n{\n    insert(end(), fields.begin(), fields.end());\n    return *this;\n}\n\nbool Fields::isEqual(const Field& left, const Field& right)\n{\n    return left.getAccessor() == right.getAccessor()\n           && left.getDescription() == right.getDescription();\n}\n\nFields Fields::fieldsByRemovingFields(const Fields& fields) const\n{\n    Fields newFields;\n    for (const auto& field : *this) {\n        if (std::find_if(fields.begin(),\n                         fields.end(),\n                         std::bind(&Fields::isEqual, field, std::placeholders::_1))\n            == fields.end()) {\n            newFields.push_back(field);\n        }\n    }\n    return newFields;\n}\n\nFields& Fields::removingFields(const Fields& fields)\n{\n    for (const auto& field : fields) {\n        auto iter = std::find_if(\n        begin(), end(), std::bind(&Fields::isEqual, field, std::placeholders::_1));\n        if (iter != end()) {\n            erase(iter);\n        }\n    }\n    return *this;\n}\n\n#pragma mark - Convertible\n\nExpression ExpressionConvertible<Field>::asExpression(const Field& field)\n{\n    return Expression((const Column&) field);\n}\n\nIndexedColumn IndexedColumnConvertible<Field>::asIndexedColumn(const Field& field)\n{\n    return Expression((const Column&) field);\n}\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/cpp/orm/binding/Field.hpp",
    "content": "//\n// Created by qiuwenchen on 2022/8/26.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"Accessor.hpp\"\n#include \"CPPDeclaration.h\"\n#include \"MemberPointer.hpp\"\n\nnamespace WCDB {\n\n#pragma mark - Field\n\nclass WCDB_API Field final : public Column {\n    friend class ResultField;\n    friend class SyntaxList<Field>;\n    friend class StatementOperation;\n\npublic:\n    Field() = delete;\n    Field(const UnsafeStringView& name, const BaseAccessor* accessor);\n    ~Field() override;\n\n    template<class ORMType, typename FieldType>\n    Field(FieldType ORMType::* memberPointer)\n    {\n        static_assert(ORMType::isObjectRelationMapped, \"This class has no ORM configuration.\");\n        static_assert(IsFieldMemberPointer<FieldType ORMType::*>::value,\n                      \"Field should be initialize with a member field pointer, not a member function pointer\");\n\n        void* voidPointer = castMemberPointer(memberPointer);\n        const Binding& binding = ORMType::getObjectRelationBinding();\n        configWithBinding(binding, voidPointer);\n    }\n\n    Field table(const UnsafeStringView& table) const;\n    Field schema(const Schema& schema) const;\n    ResultField redirect(const ResultColumn& resultColumn) const;\n\n    template<class ObjectType>\n    Value getValue(const ObjectType& obj) const\n    {\n        WCDB_CPP_ORM_STATIC_ASSERT_FOR_OBJECT_TYPE\n        switch (m_accessor->getColumnType()) {\n        case ColumnType::Integer: {\n            auto intAccessor\n            = static_cast<const Accessor<ObjectType, ColumnType::Integer>*>(m_accessor);\n            if (!intAccessor->isNull(obj)) {\n                return intAccessor->getValue(obj);\n            } else {\n                return Value();\n            }\n        } break;\n        case ColumnType::Float: {\n            auto floatAccessor\n            = static_cast<const Accessor<ObjectType, ColumnType::Float>*>(m_accessor);\n            if (!floatAccessor->isNull(obj)) {\n                return floatAccessor->getValue(obj);\n            } else {\n                return Value();\n            }\n        } break;\n        case ColumnType::Text: {\n            auto textAccessor\n            = static_cast<const Accessor<ObjectType, ColumnType::Text>*>(m_accessor);\n            if (!textAccessor->isNull(obj)) {\n                return textAccessor->getValue(obj);\n            } else {\n                return Value();\n            }\n        } break;\n        case ColumnType::BLOB: {\n            auto blobAccessor\n            = static_cast<const Accessor<ObjectType, ColumnType::BLOB>*>(m_accessor);\n            if (!blobAccessor->isNull(obj)) {\n                return blobAccessor->getValue(obj);\n            } else {\n                return Value();\n            }\n        } break;\n        case ColumnType::Null: {\n            return nullptr;\n        } break;\n        default:\n            assert(0);\n            break;\n        }\n        return nullptr;\n    }\n\nprotected:\n    const BaseAccessor* getAccessor() const;\n\nprivate:\n    Field(const BaseAccessor* accessor, const Column& column);\n    void configWithBinding(const Binding& binding, void* memberPointer);\n    const BaseAccessor* m_accessor;\n};\n\n#pragma mark - Fields\n\ntemplate<>\nclass WCDB_API SyntaxList<Field> final : public _SyntaxList<Field> {\npublic:\n    using _SyntaxList<Field>::_SyntaxList;\n    ~SyntaxList() override;\n\n#ifndef __linux__\n    ResultFields redirect(const ResultColumns& resultColumns) const;\n#endif\n\n    typedef std::function<ResultColumn(const Field&)> RedirectAction;\n    ResultFields redirect(RedirectAction action) const;\n\n    // It's not the count of the list, but the SQL function `count(*)`.\n    Expression count() const;\n\n    Expressions table(const StringView& table) const;\n\n    Fields fieldsByAddingNewFields(const Fields& fields) const;\n    Fields& addingNewFields(const Fields& fields);\n\n    Fields fieldsByRemovingFields(const Fields& fields) const;\n    Fields& removingFields(const Fields& fields);\n\nprivate:\n    static bool isEqual(const Field& left, const Field& right);\n};\n\n#pragma mark - Convertible\n\ntemplate<>\nclass WCDB_API ExpressionConvertible<Field> final : public std::true_type {\npublic:\n    static Expression asExpression(const Field& field);\n};\n\ntemplate<>\nclass WCDB_API IndexedColumnConvertible<Field> final : public std::true_type {\npublic:\n    static IndexedColumn asIndexedColumn(const Field& field);\n};\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/cpp/orm/binding/ResultField.cpp",
    "content": "//\n// Created by qiuwenchen on 2022/8/27.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"ResultField.hpp\"\n#include \"Accessor.hpp\"\n#include \"Binding.hpp\"\n#include \"Field.hpp\"\n#include \"WINQ.h\"\n\nnamespace WCDB {\n\nResultField::ResultField(const Field& field)\n: ResultColumn(field), m_accessor(field.getAccessor())\n{\n}\n\nResultField::ResultField(const ResultColumn& resultColumn, const BaseAccessor* assessor)\n: ResultColumn(resultColumn), m_accessor(assessor)\n{\n}\n\nResultField::~ResultField() = default;\n\nvoid ResultField::configWithBinding(const Binding& binding, void* memberPointer)\n{\n    syntax().expression = Expression(binding.getColumnName(memberPointer));\n    m_accessor = binding.getAccessor(memberPointer);\n}\n\nconst BaseAccessor* ResultField::getAccessor() const\n{\n    return m_accessor;\n}\n\nResultFields::~SyntaxList() = default;\n\nResultFields\nResultFields::resultColumnsByAddingNewResultColumns(const ResultFields& resultColumns) const\n{\n    ResultFields newResultColumns = *this;\n    newResultColumns.insert(\n    newResultColumns.end(), resultColumns.begin(), resultColumns.end());\n    return newResultColumns;\n}\n\nResultFields& ResultFields::addingNewResultColumns(const ResultFields& resultColumns)\n{\n    insert(end(), resultColumns.begin(), resultColumns.end());\n    return *this;\n}\n\nbool ResultFields::isEqual(const ResultField& left, const ResultField& right)\n{\n    return left.getAccessor() == right.getAccessor()\n           && left.getDescription().compare(right.getDescription()) == 0;\n}\n\nResultFields\nResultFields::resultColumnsByRemovingResultColumns(const ResultFields& resultColumns) const\n{\n    ResultFields newResultColumns;\n    for (const auto& resultColumn : *this) {\n        if (std::find_if(resultColumns.begin(),\n                         resultColumns.end(),\n                         std::bind(&ResultFields::isEqual, resultColumn, std::placeholders::_1))\n            == resultColumns.end()) {\n            newResultColumns.push_back(resultColumn);\n        }\n    }\n    return newResultColumns;\n}\n\nResultFields& ResultFields::removingResultColumns(const ResultFields& resultColumns)\n{\n    for (const auto& resultColumn : resultColumns) {\n        auto iter = std::find_if(\n        begin(), end(), std::bind(&ResultFields::isEqual, resultColumn, std::placeholders::_1));\n        if (iter != end()) {\n            erase(iter);\n        }\n    }\n    return *this;\n}\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/cpp/orm/binding/ResultField.hpp",
    "content": "//\n// Created by qiuwenchen on 2022/8/27.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"Accessor.hpp\"\n#include \"CPPDeclaration.h\"\n#include \"MemberPointer.hpp\"\n\nnamespace WCDB {\n\nclass WCDB_API ResultField final : public ResultColumn {\n    friend class SyntaxList<ResultField>;\n    friend class StatementOperation;\n\npublic:\n    ResultField() = delete;\n\n    ResultField(const Field& field);\n    ResultField(const ResultColumn& resultColumn, const BaseAccessor* assessor);\n    ~ResultField() override;\n\n    template<class ORMType, typename FieldType>\n    ResultField(FieldType ORMType::* memberPointer)\n    {\n        static_assert(ORMType::isObjectRelationMapped, \"This class has no ORM configuration.\");\n        static_assert(IsFieldMemberPointer<FieldType ORMType::*>::value,\n                      \"Field should be initialize with a member field pointer, not a member function pointer\");\n\n        void* voidPointer = castMemberPointer(memberPointer);\n        const Binding& binding = ORMType::getObjectRelationBinding();\n        configWithBinding(binding, voidPointer);\n    }\n\n    template<class ObjectType>\n    void setValue(ObjectType& obj, const Value& value) const\n    {\n        WCDB_CPP_ORM_STATIC_ASSERT_FOR_OBJECT_TYPE\n        bool notNull = !value.isNull();\n        switch (m_accessor->getColumnType()) {\n        case ColumnType::Integer: {\n            auto intAccessor\n            = static_cast<const Accessor<ObjectType, ColumnType::Integer>*>(m_accessor);\n            if (notNull) {\n                intAccessor->setValue(obj, value.intValue());\n            } else {\n                intAccessor->setNull(obj);\n            }\n        } break;\n        case ColumnType::Float: {\n            auto floatAccessor\n            = static_cast<const Accessor<ObjectType, ColumnType::Float>*>(m_accessor);\n            if (notNull) {\n                floatAccessor->setValue(obj, value.floatValue());\n            } else {\n                floatAccessor->setNull(obj);\n            }\n        } break;\n        case ColumnType::Text: {\n            auto textAccessor\n            = static_cast<const Accessor<ObjectType, ColumnType::Text>*>(m_accessor);\n            if (notNull) {\n                textAccessor->setValue(obj, value.textValue());\n            } else {\n                textAccessor->setNull(obj);\n            }\n        } break;\n        case ColumnType::BLOB: {\n            auto blobAccessor\n            = static_cast<const Accessor<ObjectType, ColumnType::BLOB>*>(m_accessor);\n            if (notNull) {\n                blobAccessor->setValue(obj, value.blobValue());\n            } else {\n                blobAccessor->setNull(obj);\n            }\n        } break;\n        default:\n            assert(0);\n            break;\n        }\n    }\n\nprotected:\n    const BaseAccessor* getAccessor() const;\n\nprivate:\n    void configWithBinding(const Binding& binding, void* memberPointer);\n    const BaseAccessor* m_accessor;\n};\n\ntemplate<>\nclass WCDB_API SyntaxList<ResultField> final : public _SyntaxList<ResultField> {\npublic:\n    using _SyntaxList<ResultField>::_SyntaxList;\n    ~SyntaxList() override;\n\n    ResultFields\n    resultColumnsByAddingNewResultColumns(const ResultFields& resultColumns) const;\n    ResultFields& addingNewResultColumns(const ResultFields& resultColumns);\n\n    ResultFields\n    resultColumnsByRemovingResultColumns(const ResultFields& resultColumns) const;\n    ResultFields& removingResultColumns(const ResultFields& resultColumns);\n\nprivate:\n    static bool isEqual(const ResultField& left, const ResultField& right);\n};\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/cpp/orm/binding/RunTimeAccessor.hpp",
    "content": "//\n// Created by qiuwenchen on 2022/9/7.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"Accessor.hpp\"\n\nnamespace WCDB {\n\ntemplate<class ORMType, typename FieldType, typename Enable = void>\nclass BaseRuntimeAccessor\n: public Accessor<ORMType, (ColumnType) ColumnInfo<FieldType>::type> {\nprotected:\n    using Super = Accessor<ORMType, (ColumnType) ColumnInfo<FieldType>::type>;\n    using UnderlyingType = typename Super::UnderlyingType;\n\n    FieldType ORMType::*m_memberPointer;\n\npublic:\n    BaseRuntimeAccessor(FieldType ORMType::*memberPointer)\n    : m_memberPointer(memberPointer)\n    {\n        static_assert(IsFieldMemberPointer<FieldType ORMType::*>::value,\n                      \"Field should be initialize with a member field pointer, not a member function pointer\");\n    }\n    virtual ~BaseRuntimeAccessor() override = default;\n\n    UnderlyingType getValue(const ORMType &instance) const override final\n    {\n        return (UnderlyingType) (instance.*m_memberPointer);\n    }\n};\n\ntemplate<class ORMType, typename FieldType, typename Enable = void>\nclass RuntimeNullAccessor : public BaseRuntimeAccessor<ORMType, FieldType> {\nprotected:\n    using Super = BaseRuntimeAccessor<ORMType, FieldType>;\n\npublic:\n    RuntimeNullAccessor(FieldType ORMType::*memberPointer)\n    : Super(memberPointer)\n    {\n    }\n    virtual ~RuntimeNullAccessor() override = default;\n\n    bool isNull(const ORMType &) const override final { return false; }\n\n    void setNull(ORMType &) const override final {}\n};\n\ntemplate<class ORMType, typename FieldType>\nclass RuntimeNullAccessor<ORMType,\n                          FieldType,\n                          typename std::enable_if<std::is_integral<FieldType>::value || std::is_enum<FieldType>::value\n                                                  || std::is_floating_point<FieldType>::value>::type>\n: public BaseRuntimeAccessor<ORMType, FieldType> {\nprotected:\n    using Super = BaseRuntimeAccessor<ORMType, FieldType>;\n\npublic:\n    RuntimeNullAccessor(FieldType ORMType::*memberPointer)\n    : Super(memberPointer)\n    {\n    }\n    virtual ~RuntimeNullAccessor() override = default;\n\n    bool isNull(const ORMType &) const override final { return false; }\n\n    void setNull(ORMType &instance) const override final\n    {\n        instance.*Super::m_memberPointer = (FieldType) NULL;\n    }\n};\n\ntemplate<class ORMType, typename FieldType>\nclass RuntimeNullAccessor<ORMType, FieldType, typename std::enable_if<std::is_pointer<FieldType>::value>::type>\n: public BaseRuntimeAccessor<ORMType, FieldType> {\nprotected:\n    using Super = BaseRuntimeAccessor<ORMType, FieldType>;\n\npublic:\n    RuntimeNullAccessor(FieldType ORMType::*memberPointer)\n    : Super(memberPointer)\n    {\n    }\n    virtual ~RuntimeNullAccessor() override = default;\n\n    bool isNull(const ORMType &instance) const override final\n    {\n        return instance.*Super::m_memberPointer == nullptr;\n    }\n\n    void setNull(ORMType &instance) const override final\n    {\n        instance.*Super::m_memberPointer = nullptr;\n    }\n};\n\ntemplate<class ORMType, typename FieldType>\nclass RuntimeNullAccessor<ORMType, FieldType, typename std::enable_if<std::is_array<FieldType>::value && !std::is_const<FieldType>::value>::type>\n: public BaseRuntimeAccessor<ORMType, FieldType> {\nprotected:\n    using Super = BaseRuntimeAccessor<ORMType, FieldType>;\n\npublic:\n    RuntimeNullAccessor(FieldType ORMType::*memberPointer)\n    : Super(memberPointer)\n    {\n    }\n    virtual ~RuntimeNullAccessor() override = default;\n\n    bool isNull(const ORMType &instance) const override final\n    {\n        return instance.*Super::m_memberPointer == nullptr;\n    }\n\n    void setNull(ORMType &instance) const override final\n    {\n        size_t length = sizeof(FieldType) / sizeof(char);\n        memset(instance.*Super::m_memberPointer, 0, length);\n    }\n};\n\ntemplate<class ORMType, typename FieldType, typename Enable = void>\nclass RuntimeAccessor final : public RuntimeNullAccessor<ORMType, FieldType> {\nprivate:\n    using Super = RuntimeNullAccessor<ORMType, FieldType>;\n    using UnderlyingType = typename Super::UnderlyingType;\n\npublic:\n    RuntimeAccessor(FieldType ORMType::*memberPointer)\n    : RuntimeNullAccessor<ORMType, FieldType>(memberPointer)\n    {\n    }\n    virtual ~RuntimeAccessor() override final = default;\n\n    void setValue(ORMType &instance, const UnderlyingType &value) const override final\n    {\n        instance.*Super::m_memberPointer = (FieldType) value;\n    }\n};\n\ntemplate<class ORMType, typename FieldType>\nclass RuntimeAccessor<ORMType, FieldType, typename std::enable_if<ColumnIsTextType<FieldType>::value>::type> final\n: public RuntimeNullAccessor<ORMType, FieldType> {\nprivate:\n    using Super = RuntimeNullAccessor<ORMType, FieldType>;\n    using UnderlyingType = typename Super::UnderlyingType;\n\npublic:\n    RuntimeAccessor(FieldType ORMType::*memberPointer)\n    : RuntimeNullAccessor<ORMType, FieldType>(memberPointer)\n    {\n    }\n    ~RuntimeAccessor() override final = default;\n\n    void setValue(ORMType &instance, const UnderlyingType &value) const override final\n    {\n        ColumnIsTextType<FieldType>::setToUnderlyingType(\n        instance.*Super::m_memberPointer, value);\n    }\n};\n\ntemplate<class ORMType, typename FieldType>\nclass RuntimeAccessor<ORMType, FieldType, typename std::enable_if<ColumnIsBLOBType<FieldType>::value>::type> final\n: public RuntimeNullAccessor<ORMType, FieldType> {\nprivate:\n    using Super = RuntimeNullAccessor<ORMType, FieldType>;\n    using UnderlyingType = typename Super::UnderlyingType;\n\npublic:\n    RuntimeAccessor(FieldType ORMType::*memberPointer)\n    : RuntimeNullAccessor<ORMType, FieldType>(memberPointer)\n    {\n    }\n    ~RuntimeAccessor() override final = default;\n\n    void setValue(ORMType &instance, const UnderlyingType &value) const override final\n    {\n        ColumnIsBLOBType<FieldType>::setToUnderlyingType(\n        instance.*Super::m_memberPointer, value);\n    }\n};\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/cpp/orm/binding/STDOptionalAccessor.hpp",
    "content": "//\n// Created by qiuwenchen on 2023/11/1.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"RunTimeAccessor.hpp\"\n#include <memory>\n\nnamespace WCDB {\n\n#if defined(__cplusplus) && __cplusplus > 201402L\n\ntemplate<class ORMType, typename FieldType>\nclass BaseRuntimeAccessor<ORMType, FieldType, typename std::enable_if<IsSTDOptional<FieldType>::value>::type>\n: public Accessor<ORMType, (ColumnType) ColumnInfo<typename FieldType::value_type>::type> {\nprotected:\n    using Super\n    = Accessor<ORMType, (ColumnType) ColumnInfo<typename FieldType::value_type>::type>;\n    using UnderlyingType = typename Super::UnderlyingType;\n\n    FieldType ORMType::*m_memberPointer;\n\npublic:\n    BaseRuntimeAccessor(FieldType ORMType::*memberPointer)\n    : m_memberPointer(memberPointer)\n    {\n        static_assert(IsFieldMemberPointer<FieldType ORMType::*>::value,\n                      \"Field should be initialize with a member field pointer, not a member function pointer\");\n    }\n    virtual ~BaseRuntimeAccessor() override = default;\n\n    UnderlyingType getValue(const ORMType &instance) const override final\n    {\n        return (UnderlyingType) (instance.*m_memberPointer).value();\n    }\n};\n\ntemplate<class ORMType, typename FieldType>\nclass RuntimeNullAccessor<ORMType, FieldType, typename std::enable_if<IsSTDOptional<FieldType>::value>::type>\n: public BaseRuntimeAccessor<ORMType, FieldType> {\nprotected:\n    using Super = BaseRuntimeAccessor<ORMType, FieldType>;\n\npublic:\n    RuntimeNullAccessor(FieldType ORMType::*memberPointer)\n    : Super(memberPointer)\n    {\n    }\n    virtual ~RuntimeNullAccessor() override = default;\n\n    bool isNull(const ORMType &instance) const override\n    {\n        return !(instance.*Super::m_memberPointer).has_value();\n    }\n\n    void setNull(ORMType &instance) const override\n    {\n        instance.*Super::m_memberPointer = std::nullopt;\n    }\n};\n\ntemplate<class ORMType, typename FieldType>\nclass RuntimeAccessor<\nORMType,\nFieldType,\ntypename std::enable_if<IsSTDOptional<FieldType>::value && !ColumnIsBLOBType<typename FieldType::value_type>::value\n                        && !ColumnIsTextType<typename FieldType::value_type>::value\n                        && !std::is_enum<typename FieldType::value_type>::value>::type>\nfinal : public RuntimeNullAccessor<ORMType, FieldType> {\nprivate:\n    using Super = RuntimeNullAccessor<ORMType, FieldType>;\n    using UnderlyingType = typename Super::UnderlyingType;\n\npublic:\n    RuntimeAccessor(FieldType ORMType::*memberPointer)\n    : RuntimeNullAccessor<ORMType, FieldType>(memberPointer)\n    {\n    }\n    ~RuntimeAccessor() override final = default;\n\n    void setValue(ORMType &instance, const UnderlyingType &value) const override final\n    {\n        instance.*Super::m_memberPointer\n        = std::make_optional<typename FieldType::value_type>(value);\n    }\n};\n\ntemplate<class ORMType, typename FieldType>\nclass RuntimeAccessor<\nORMType,\nFieldType,\ntypename std::enable_if<IsSTDOptional<FieldType>::value && !ColumnIsBLOBType<typename FieldType::value_type>::value\n                        && !ColumnIsTextType<typename FieldType::value_type>::value\n                        && std::is_enum<typename FieldType::value_type>::value>::type>\nfinal : public RuntimeNullAccessor<ORMType, FieldType> {\nprivate:\n    using Super = RuntimeNullAccessor<ORMType, FieldType>;\n    using UnderlyingType = typename Super::UnderlyingType;\n\npublic:\n    RuntimeAccessor(FieldType ORMType::*memberPointer)\n    : RuntimeNullAccessor<ORMType, FieldType>(memberPointer)\n    {\n    }\n    ~RuntimeAccessor() override final = default;\n\n    void setValue(ORMType &instance, const UnderlyingType &value) const override final\n    {\n        instance.*Super::m_memberPointer\n        = std::make_optional<typename FieldType::value_type>(\n        (typename FieldType::value_type) value);\n    }\n};\n\ntemplate<class ORMType, typename FieldType>\nclass RuntimeAccessor<ORMType, FieldType, typename std::enable_if<IsSTDOptional<FieldType>::value && ColumnIsTextType<typename FieldType::value_type>::value>::type> final\n: public RuntimeNullAccessor<ORMType, FieldType> {\nprivate:\n    using Super = RuntimeNullAccessor<ORMType, FieldType>;\n    using UnderlyingType = typename Super::UnderlyingType;\n\npublic:\n    RuntimeAccessor(FieldType ORMType::*memberPointer)\n    : RuntimeNullAccessor<ORMType, FieldType>(memberPointer)\n    {\n    }\n    ~RuntimeAccessor() override final = default;\n\n    void setValue(ORMType &instance, const UnderlyingType &value) const override final\n    {\n        instance.*Super::m_memberPointer\n        = std::make_optional<typename FieldType::value_type>();\n        ColumnIsTextType<typename FieldType::value_type>::setToUnderlyingType(\n        (instance.*Super::m_memberPointer).value(), value);\n    }\n};\n\ntemplate<class ORMType, typename FieldType>\nclass RuntimeAccessor<ORMType, FieldType, typename std::enable_if<IsSTDOptional<FieldType>::value && ColumnIsBLOBType<typename FieldType::value_type>::value>::type> final\n: public RuntimeNullAccessor<ORMType, FieldType> {\nprivate:\n    using Super = RuntimeNullAccessor<ORMType, FieldType>;\n    using UnderlyingType = typename Super::UnderlyingType;\n\npublic:\n    RuntimeAccessor(FieldType ORMType::*memberPointer)\n    : RuntimeNullAccessor<ORMType, FieldType>(memberPointer)\n    {\n    }\n    ~RuntimeAccessor() override final = default;\n\n    void setValue(ORMType &instance, const UnderlyingType &value) const override final\n    {\n        instance.*Super::m_memberPointer\n        = std::make_optional<typename FieldType::value_type>();\n        ColumnIsBLOBType<typename FieldType::value_type>::setToUnderlyingType(\n        (instance.*Super::m_memberPointer).value(), value);\n    }\n};\n\n#endif\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/cpp/orm/binding/SharedPtrAccessor.hpp",
    "content": "//\n// Created by qiuwenchen on 2023/10/30.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"RunTimeAccessor.hpp\"\n#include <memory>\n\nnamespace WCDB {\n\ntemplate<class ORMType, typename FieldType>\nclass BaseRuntimeAccessor<ORMType, FieldType, typename std::enable_if<IsSTDSharedPtr<FieldType>::value>::type>\n: public Accessor<ORMType, (ColumnType) ColumnInfo<typename FieldType::element_type>::type> {\nprotected:\n    using Super\n    = Accessor<ORMType, (ColumnType) ColumnInfo<typename FieldType::element_type>::type>;\n    using UnderlyingType = typename Super::UnderlyingType;\n\n    FieldType ORMType::*m_memberPointer;\n\npublic:\n    BaseRuntimeAccessor(FieldType ORMType::*memberPointer)\n    : m_memberPointer(memberPointer)\n    {\n        static_assert(IsFieldMemberPointer<FieldType ORMType::*>::value,\n                      \"Field should be initialize with a member field pointer, not a member function pointer\");\n    }\n    virtual ~BaseRuntimeAccessor() override = default;\n\n    UnderlyingType getValue(const ORMType &instance) const override final\n    {\n        return (UnderlyingType) * (instance.*m_memberPointer);\n    }\n};\n\ntemplate<class ORMType, typename FieldType>\nclass RuntimeNullAccessor<ORMType, FieldType, typename std::enable_if<IsSTDSharedPtr<FieldType>::value>::type>\n: public BaseRuntimeAccessor<ORMType, FieldType> {\nprotected:\n    using Super = BaseRuntimeAccessor<ORMType, FieldType>;\n\npublic:\n    RuntimeNullAccessor(FieldType ORMType::*memberPointer)\n    : Super(memberPointer)\n    {\n    }\n    virtual ~RuntimeNullAccessor() override = default;\n\n    bool isNull(const ORMType &instance) const override\n    {\n        return instance.*Super::m_memberPointer == nullptr;\n    }\n\n    void setNull(ORMType &instance) const override\n    {\n        instance.*Super::m_memberPointer = nullptr;\n    }\n};\n\ntemplate<class ORMType, typename FieldType>\nclass RuntimeAccessor<\nORMType,\nFieldType,\ntypename std::enable_if<IsSTDSharedPtr<FieldType>::value && !ColumnIsBLOBType<typename FieldType::element_type>::value\n                        && !ColumnIsTextType<typename FieldType::element_type>::value\n                        && !std::is_enum<typename FieldType::element_type>::value>::type>\nfinal : public RuntimeNullAccessor<ORMType, FieldType> {\nprivate:\n    using Super = RuntimeNullAccessor<ORMType, FieldType>;\n    using UnderlyingType = typename Super::UnderlyingType;\n\npublic:\n    RuntimeAccessor(FieldType ORMType::*memberPointer)\n    : RuntimeNullAccessor<ORMType, FieldType>(memberPointer)\n    {\n    }\n    ~RuntimeAccessor() override final = default;\n\n    void setValue(ORMType &instance, const UnderlyingType &value) const override final\n    {\n        instance.*Super::m_memberPointer\n        = std::make_shared<typename FieldType::element_type>(value);\n    }\n};\n\ntemplate<class ORMType, typename FieldType>\nclass RuntimeAccessor<\nORMType,\nFieldType,\ntypename std::enable_if<IsSTDSharedPtr<FieldType>::value && !ColumnIsBLOBType<typename FieldType::element_type>::value\n                        && !ColumnIsTextType<typename FieldType::element_type>::value\n                        && std::is_enum<typename FieldType::element_type>::value>::type>\nfinal : public RuntimeNullAccessor<ORMType, FieldType> {\nprivate:\n    using Super = RuntimeNullAccessor<ORMType, FieldType>;\n    using UnderlyingType = typename Super::UnderlyingType;\n\npublic:\n    RuntimeAccessor(FieldType ORMType::*memberPointer)\n    : RuntimeNullAccessor<ORMType, FieldType>(memberPointer)\n    {\n    }\n    ~RuntimeAccessor() override final = default;\n\n    void setValue(ORMType &instance, const UnderlyingType &value) const override final\n    {\n        instance.*Super::m_memberPointer\n        = std::make_shared<typename FieldType::element_type>(\n        (typename FieldType::element_type) value);\n    }\n};\n\ntemplate<class ORMType, typename FieldType>\nclass RuntimeAccessor<ORMType, FieldType, typename std::enable_if<IsSTDSharedPtr<FieldType>::value && ColumnIsTextType<typename FieldType::element_type>::value>::type> final\n: public RuntimeNullAccessor<ORMType, FieldType> {\nprivate:\n    using Super = RuntimeNullAccessor<ORMType, FieldType>;\n    using UnderlyingType = typename Super::UnderlyingType;\n\npublic:\n    RuntimeAccessor(FieldType ORMType::*memberPointer)\n    : RuntimeNullAccessor<ORMType, FieldType>(memberPointer)\n    {\n    }\n    ~RuntimeAccessor() override final = default;\n\n    void setValue(ORMType &instance, const UnderlyingType &value) const override final\n    {\n        instance.*Super::m_memberPointer\n        = std::make_shared<typename FieldType::element_type>();\n        ColumnIsTextType<typename FieldType::element_type>::setToUnderlyingType(\n        *(instance.*Super::m_memberPointer), value);\n    }\n};\n\ntemplate<class ORMType, typename FieldType>\nclass RuntimeAccessor<ORMType, FieldType, typename std::enable_if<IsSTDSharedPtr<FieldType>::value && ColumnIsBLOBType<typename FieldType::element_type>::value>::type> final\n: public RuntimeNullAccessor<ORMType, FieldType> {\nprivate:\n    using Super = RuntimeNullAccessor<ORMType, FieldType>;\n    using UnderlyingType = typename Super::UnderlyingType;\n\npublic:\n    RuntimeAccessor(FieldType ORMType::*memberPointer)\n    : RuntimeNullAccessor<ORMType, FieldType>(memberPointer)\n    {\n    }\n    ~RuntimeAccessor() override final = default;\n\n    void setValue(ORMType &instance, const UnderlyingType &value) const override final\n    {\n        instance.*Super::m_memberPointer\n        = std::make_shared<typename FieldType::element_type>();\n        ColumnIsBLOBType<typename FieldType::element_type>::setToUnderlyingType(\n        *(instance.*Super::m_memberPointer), value);\n    }\n};\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/cpp/orm/binding/WCDBOptionalAccessor.hpp",
    "content": "//\n// Created by qiuwenchen on 2023/11/1.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"RunTimeAccessor.hpp\"\n#include <memory>\n\nnamespace WCDB {\n\ntemplate<class ORMType, typename FieldType>\nclass BaseRuntimeAccessor<ORMType, FieldType, typename std::enable_if<IsWCDBOptional<FieldType>::value>::type>\n: public Accessor<ORMType, (ColumnType) ColumnInfo<typename FieldType::ValueType>::type> {\nprotected:\n    using Super\n    = Accessor<ORMType, (ColumnType) ColumnInfo<typename FieldType::ValueType>::type>;\n    using UnderlyingType = typename Super::UnderlyingType;\n\n    FieldType ORMType::*m_memberPointer;\n\npublic:\n    BaseRuntimeAccessor(FieldType ORMType::*memberPointer)\n    : m_memberPointer(memberPointer)\n    {\n        static_assert(IsFieldMemberPointer<FieldType ORMType::*>::value,\n                      \"Field should be initialize with a member field pointer, not a member function pointer\");\n    }\n    virtual ~BaseRuntimeAccessor() override = default;\n\n    UnderlyingType getValue(const ORMType &instance) const override final\n    {\n        return (UnderlyingType) (instance.*m_memberPointer).value();\n    }\n};\n\ntemplate<class ORMType, typename FieldType>\nclass RuntimeNullAccessor<ORMType, FieldType, typename std::enable_if<IsWCDBOptional<FieldType>::value>::type>\n: public BaseRuntimeAccessor<ORMType, FieldType> {\nprotected:\n    using Super = BaseRuntimeAccessor<ORMType, FieldType>;\n\npublic:\n    RuntimeNullAccessor(FieldType ORMType::*memberPointer)\n    : Super(memberPointer)\n    {\n    }\n    virtual ~RuntimeNullAccessor() override = default;\n\n    bool isNull(const ORMType &instance) const override\n    {\n        return !(instance.*Super::m_memberPointer).hasValue();\n    }\n\n    void setNull(ORMType &instance) const override\n    {\n        instance.*Super::m_memberPointer = NullOpt;\n    }\n};\n\ntemplate<class ORMType, typename FieldType>\nclass RuntimeAccessor<\nORMType,\nFieldType,\ntypename std::enable_if<IsWCDBOptional<FieldType>::value && !ColumnIsBLOBType<typename FieldType::ValueType>::value\n                        && !ColumnIsTextType<typename FieldType::ValueType>::value\n                        && !std::is_enum<typename FieldType::ValueType>::value>::type>\nfinal : public RuntimeNullAccessor<ORMType, FieldType> {\nprivate:\n    using Super = RuntimeNullAccessor<ORMType, FieldType>;\n    using UnderlyingType = typename Super::UnderlyingType;\n\npublic:\n    RuntimeAccessor(FieldType ORMType::*memberPointer)\n    : RuntimeNullAccessor<ORMType, FieldType>(memberPointer)\n    {\n    }\n    ~RuntimeAccessor() override final = default;\n\n    void setValue(ORMType &instance, const UnderlyingType &value) const override final\n    {\n        instance.*Super::m_memberPointer = Optional<typename FieldType::ValueType>(value);\n    }\n};\n\ntemplate<class ORMType, typename FieldType>\nclass RuntimeAccessor<\nORMType,\nFieldType,\ntypename std::enable_if<IsWCDBOptional<FieldType>::value && !ColumnIsBLOBType<typename FieldType::ValueType>::value\n                        && !ColumnIsTextType<typename FieldType::ValueType>::value\n                        && std::is_enum<typename FieldType::ValueType>::value>::type>\nfinal : public RuntimeNullAccessor<ORMType, FieldType> {\nprivate:\n    using Super = RuntimeNullAccessor<ORMType, FieldType>;\n    using UnderlyingType = typename Super::UnderlyingType;\n\npublic:\n    RuntimeAccessor(FieldType ORMType::*memberPointer)\n    : RuntimeNullAccessor<ORMType, FieldType>(memberPointer)\n    {\n    }\n    ~RuntimeAccessor() override final = default;\n\n    void setValue(ORMType &instance, const UnderlyingType &value) const override final\n    {\n        instance.*Super::m_memberPointer\n        = Optional<typename FieldType::ValueType>((typename FieldType::ValueType) value);\n    }\n};\n\ntemplate<class ORMType, typename FieldType>\nclass RuntimeAccessor<ORMType, FieldType, typename std::enable_if<IsWCDBOptional<FieldType>::value && ColumnIsTextType<typename FieldType::ValueType>::value>::type> final\n: public RuntimeNullAccessor<ORMType, FieldType> {\nprivate:\n    using Super = RuntimeNullAccessor<ORMType, FieldType>;\n    using UnderlyingType = typename Super::UnderlyingType;\n    using ValueType = typename FieldType::ValueType;\n\npublic:\n    RuntimeAccessor(FieldType ORMType::*memberPointer)\n    : RuntimeNullAccessor<ORMType, FieldType>(memberPointer)\n    {\n    }\n    ~RuntimeAccessor() override final = default;\n\n    void setValue(ORMType &instance, const UnderlyingType &value) const override final\n    {\n        instance.*Super::m_memberPointer = ValueType();\n        ColumnIsTextType<typename FieldType::ValueType>::setToUnderlyingType(\n        (instance.*Super::m_memberPointer).value(), value);\n    }\n};\n\ntemplate<class ORMType, typename FieldType>\nclass RuntimeAccessor<ORMType, FieldType, typename std::enable_if<IsWCDBOptional<FieldType>::value && ColumnIsBLOBType<typename FieldType::ValueType>::value>::type> final\n: public RuntimeNullAccessor<ORMType, FieldType> {\nprivate:\n    using Super = RuntimeNullAccessor<ORMType, FieldType>;\n    using UnderlyingType = typename Super::UnderlyingType;\n    using ValueType = typename FieldType::ValueType;\n\npublic:\n    RuntimeAccessor(FieldType ORMType::*memberPointer)\n    : RuntimeNullAccessor<ORMType, FieldType>(memberPointer)\n    {\n    }\n    ~RuntimeAccessor() override final = default;\n\n    void setValue(ORMType &instance, const UnderlyingType &value) const override final\n    {\n        instance.*Super::m_memberPointer = ValueType();\n        ColumnIsBLOBType<typename FieldType::ValueType>::setToUnderlyingType(\n        (instance.*Super::m_memberPointer).value(), value);\n    }\n};\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/cpp/orm/fts/FTSTokenizerUtil.cpp",
    "content": "//\n// Created by qiuwenchen on 2022/8/27.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"FTSTokenizerUtil.hpp\"\n#include \"StatementCreateVirtualTable.hpp\"\n#include <cstdarg>\n\nnamespace WCDB {\n\nStringView FTSTokenizerUtil::tokenize(const char* name, ...)\n{\n    StringView tokenizerPrefix = Syntax::CreateVirtualTableSTMT::tokenizerPreFix();\n    std::ostringstream stream;\n    stream << tokenizerPrefix.data() << name;\n    va_list pArgs;\n    va_start(pArgs, name);\n    const char* parameter = nullptr;\n    while ((parameter = va_arg(pArgs, const char*)) != nullptr) {\n        stream << ' ' << parameter;\n    }\n    return WCDB::StringView(stream.str());\n}\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/cpp/orm/fts/FTSTokenizerUtil.hpp",
    "content": "//\n// Created by qiuwenchen on 2022/8/27.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"BaseTokenizerUtil.hpp\"\n#include \"FTSConst.h\"\n\nnamespace WCDB {\n\nclass WCDB_API FTSTokenizerUtil final : public BaseTokenizerUtil {\npublic:\n    static StringView tokenize(const char* name, ...);\n};\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/cpp/orm/macro/CPPBindingMacro.h",
    "content": "//\n// Created by qiuwenchen on 2022/8/27.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"Macro.h\"\n#include <mutex>\n\n#define __WCDB_CPP_ORM_COMMON_DECLARATION(className)                               \\\n    std::shared_ptr<long long> lastInsertedRowID = std::make_shared<long long>(0); \\\n    bool isAutoIncrement = false;                                                  \\\n    using WCDBORMType = className;                                                 \\\n    constexpr static bool isObjectRelationMapped = true;\n\n#define __WCDB_CPP_ORM_ALL_PROPERTIES_IMPLEMENTATION                           \\\n    {                                                                          \\\n        return getObjectRelationBinding().allFields();                         \\\n    }\n\n#define __WCDB_CPP_ORM_GET_BINDING_IMPLEMENTATIONP_START                       \\\n    {                                                                          \\\n        static WCDB::Binding* g_binding = new WCDB::Binding();                 \\\n        static std::once_flag g_flag;                                          \\\n    std::call_once(g_flag, [&](){\n#define __WCDB_CPP_ORM_IMPLEMENTATION_END                                      \\\n    });                                                                        \\\n    return *g_binding;                                                         \\\n    }\n\n#define __WCDB_CPP_INHERIT_ORM(baseClass)                                                         \\\n    static_assert(std::is_base_of<baseClass, WCDBORMType>::value,                                 \\\n                  \"You can only inherit ORM from base class\");                                    \\\n    static_assert(baseClass::isObjectRelationMapped, \"The base class has no ORM configuration.\"); \\\n    WCDB::assertFirstBaseClass<baseClass, WCDBORMType>();                                         \\\n    g_binding->inherit(baseClass::getObjectRelationBinding());\n"
  },
  {
    "path": "src/cpp/orm/macro/CPPColumnConstraintMacro.h",
    "content": "//\n// Created by qiuwenchen on 2022/8/28.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"Macro.h\"\n\n#define __WCDB_CPP_COLUMN_CONSTRAINT_BEGIN(fieldName)                          \\\n    {                                                                          \\\n        static_assert(has_synthesized_##fieldName,                             \\\n                      \"You need to synthesize this field before you use it\");  \\\n        WCDB::ColumnConstraint columnConstraint;\n\n#define __WCDB_CPP_COLUMN_CONSTRAINT_END(fieldName)                              \\\n    WCDB::ColumnDef* columnDef                                                   \\\n    = g_binding->getColumnDef(WCDB::castMemberPointer(&WCDBORMType::fieldName)); \\\n    columnDef->constraint(columnConstraint);                                     \\\n    }\n\n// primary\n#define __WCDB_CPP_ORDERED_PRIMARY_IMP(fieldName, order_, autoIncrement_)      \\\n    __WCDB_CPP_COLUMN_CONSTRAINT_BEGIN(fieldName)                              \\\n    columnConstraint.primaryKey().order(order_);                               \\\n    WCDB_IF(autoIncrement_, columnConstraint.autoIncrement());                 \\\n    __WCDB_CPP_COLUMN_CONSTRAINT_END(fieldName)\n\n#define __WCDB_CPP_PRIMARY_IMP(fieldName, autoIncrement_)                      \\\n    __WCDB_CPP_COLUMN_CONSTRAINT_BEGIN(fieldName)                              \\\n    columnConstraint.primaryKey();                                             \\\n    WCDB_IF(autoIncrement_, columnConstraint.autoIncrement());                 \\\n    __WCDB_CPP_COLUMN_CONSTRAINT_END(fieldName)\n\n#define __WCDB_CPP_PRIMARY_ENABLE_AUTOINCREMENT_FOR_EXISTING_TABLE             \\\n    g_binding->enableAutoIncrementForExistingTable();\n\n// not null\n#define __WCDB_CPP_NOT_NULL_IMP(fieldName)                                     \\\n    __WCDB_CPP_COLUMN_CONSTRAINT_BEGIN(fieldName)                              \\\n    columnConstraint.notNull();                                                \\\n    __WCDB_CPP_COLUMN_CONSTRAINT_END(fieldName)\n\n// unique\n#define __WCDB_CPP_UNIQUE_IMP(fieldName)                                       \\\n    __WCDB_CPP_COLUMN_CONSTRAINT_BEGIN(fieldName)                              \\\n    columnConstraint.unique();                                                 \\\n    __WCDB_CPP_COLUMN_CONSTRAINT_END(fieldName)\n\n// default\n#define __WCDB_CPP_DEFAULT_IMP(fieldName, defaultValue)                        \\\n    __WCDB_CPP_COLUMN_CONSTRAINT_BEGIN(fieldName)                              \\\n    columnConstraint.default_(defaultValue);                                   \\\n    __WCDB_CPP_COLUMN_CONSTRAINT_END(fieldName)\n\n// check\n#define __WCDB_CPP_CHECK_IMP(fieldName, condition)                             \\\n    __WCDB_CPP_COLUMN_CONSTRAINT_BEGIN(fieldName)                              \\\n    columnConstraint.check(condition);                                         \\\n    __WCDB_CPP_COLUMN_CONSTRAINT_END(fieldName)\n\n// unindexed for fts\n#define __WCDB_CPP_UNINDEXED_IMP(fieldName)                                    \\\n    __WCDB_CPP_COLUMN_CONSTRAINT_BEGIN(fieldName)                              \\\n    columnConstraint.unIndexed();                                              \\\n    __WCDB_CPP_COLUMN_CONSTRAINT_END(fieldName)\n"
  },
  {
    "path": "src/cpp/orm/macro/CPPFieldMacro.h",
    "content": "//\n// Created by qiuwenchen on 2022/8/27.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"Macro.h\"\n\n#define __WCDB_CPP_SYNTHESIZE_IMP(fieldName, columnName)                                          \\\n    auto _mp_##fieldName = &WCDBORMType::fieldName;                                               \\\n    constexpr bool has_synthesized_##fieldName = true;                                            \\\n    static const char* _columnName_##fieldName = columnName;                                      \\\n    WCDB_UNUSED(has_synthesized_##fieldName);                                                     \\\n    auto& _field_##fieldName = g_binding->registerField(                                          \\\n    WCDB::castMemberPointer(_mp_##fieldName),                                                     \\\n    WCDB::StringView::makeConstant(_columnName_##fieldName),                                      \\\n    new WCDB::RuntimeAccessor<WCDBORMType, WCDB::getMemberType<decltype(_mp_##fieldName)>::type>( \\\n    _mp_##fieldName));                                                                            \\\n    WCDB_UNUSED(_field_##fieldName);\n"
  },
  {
    "path": "src/cpp/orm/macro/CPPIndexMacro.h",
    "content": "//\n// Created by qiuwenchen on 2022/8/27.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"Macro.h\"\n\n#define __WCDB_CPP_INDEX_BEGIN(indexSuffixName)                                \\\n    {                                                                          \\\n        WCDB::BaseBinding::Index &index = g_binding->getOrCreateIndex(indexSuffixName);\n\n#define __WCDB_CPP_INDEX_BEGIN_WITH_FIELD_NAME(indexSuffixName, fieldName)              \\\n    {                                                                                   \\\n        static_assert(has_synthesized_##fieldName,                                      \\\n                      \"You need to synthesize this field before you use it\");           \\\n        WCDB::BaseBinding::Index &index = g_binding->getOrCreateIndex(indexSuffixName); \\\n        auto temp_memory_point = &WCDBORMType::fieldName;                               \\\n        WCDB_UNUSED(temp_memory_point);\n\n#define __WCDB_CPP_INDEX_END }\n\n#define __WCDB_CPP_ORDERED_INDEX_IMP(indexSuffixName, fieldName, order_, isUnique) \\\n    __WCDB_CPP_INDEX_BEGIN_WITH_FIELD_NAME(indexSuffixName, fieldName)             \\\n    WCDB_IF(isUnique, index.statement.unique();)                                   \\\n    index.statement.indexed(_field_##fieldName.asIndex().order(order_));           \\\n    __WCDB_CPP_INDEX_END\n\n#define __WCDB_CPP_INDEX_IMP(indexSuffixName, fieldName, isUnique)             \\\n    __WCDB_CPP_INDEX_BEGIN_WITH_FIELD_NAME(indexSuffixName, fieldName)         \\\n    WCDB_IF(isUnique, index.statement.unique();)                               \\\n    index.statement.indexed(_field_##fieldName.asIndex());                     \\\n    __WCDB_CPP_INDEX_END\n\n#define __WCDB_CPP_INDEX_FOR_NEWLY_CREATED_TABLE_ONLY_IMP(indexSuffixName)           \\\n    __WCDB_CPP_INDEX_BEGIN(indexSuffixName)                                          \\\n    index.action = WCDB::BaseBinding::Index::Action::CreateForNewlyCreatedTableOnly; \\\n    __WCDB_CPP_INDEX_END\n\n#define __WCDB_CPP_INDEX_TO_BE_DROPPED(indexSuffixName)                        \\\n    __WCDB_CPP_INDEX_BEGIN(indexSuffixName)                                    \\\n    index.action = WCDB::BaseBinding::Index::Action::Drop;                     \\\n    __WCDB_CPP_INDEX_END\n"
  },
  {
    "path": "src/cpp/orm/macro/CPPORMMacro.h",
    "content": "//\n// Created by qiuwenchen on 2022/8/27.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"CPPBindingMacro.h\"\n#include \"CPPColumnConstraintMacro.h\"\n#include \"CPPFieldMacro.h\"\n#include \"CPPIndexMacro.h\"\n#include \"CPPTableConstraintMacro.h\"\n#include \"CPPVirtualTableMacro.h\"\n#include \"Macro.h\"\n\n#define WCDB_FIELD(memberPointer) WCDB::Field(&memberPointer)\n\n#define WCDB_CPP_ORM_DECLARATION(className)                                    \\\npublic:                                                                        \\\n    __WCDB_CPP_ORM_COMMON_DECLARATION(className)                               \\\n    static const WCDB::Fields &allFields();                                    \\\n    static const WCDB::Binding &getObjectRelationBinding();\n\n#define WCDB_CPP_ORM_DECLARE_AND_START_IMPLEMENT(className)                                             \\\npublic:                                                                                                 \\\n    __WCDB_CPP_ORM_COMMON_DECLARATION(className)                                                        \\\n    static const WCDB::Fields &allFields()                                                              \\\n    __WCDB_CPP_ORM_ALL_PROPERTIES_IMPLEMENTATION static const WCDB::Binding &getObjectRelationBinding() \\\n    __WCDB_CPP_ORM_GET_BINDING_IMPLEMENTATIONP_START\n\n#define WCDB_CPP_ORM_IMPLEMENTATION_BEGIN(className)                                                                    \\\n    using _wcdb_orm_##className = className;                                                                            \\\n    const WCDB::Fields &_wcdb_orm_##className::allFields()                                                              \\\n    __WCDB_CPP_ORM_ALL_PROPERTIES_IMPLEMENTATION const WCDB::Binding &_wcdb_orm_##className::getObjectRelationBinding() \\\n    __WCDB_CPP_ORM_GET_BINDING_IMPLEMENTATIONP_START\n\n#define WCDB_CPP_ORM_IMPLEMENTATION_END __WCDB_CPP_ORM_IMPLEMENTATION_END\n\n#define WCDB_CPP_INHERIT_ORM(baseClass) __WCDB_CPP_INHERIT_ORM(baseClass)\n\n#define WCDB_CPP_SYNTHESIZE(fieldName)                                         \\\n    __WCDB_CPP_SYNTHESIZE_IMP(fieldName, WCDB_STRINGIFY(fieldName))\n\n#define WCDB_CPP_SYNTHESIZE_COLUMN(fieldName, columnName)                      \\\n    __WCDB_CPP_SYNTHESIZE_IMP(fieldName, columnName)\n\n// Column Constraint\n#define WCDB_CPP_PRIMARY(fieldName) __WCDB_CPP_PRIMARY_IMP(fieldName, false)\n\n#define WCDB_CPP_PRIMARY_ASC(fieldName)                                        \\\n    __WCDB_CPP_ORDERED_PRIMARY_IMP(fieldName, WCDB::Order::ASC, false)\n\n#define WCDB_CPP_PRIMARY_DESC(fieldName)                                       \\\n    __WCDB_CPP_ORDERED_PRIMARY_IMP(fieldName, WCDB::Order::DESC, false)\n\n#define WCDB_CPP_PRIMARY_AUTO_INCREMENT(fieldName)                             \\\n    __WCDB_CPP_PRIMARY_IMP(fieldName, true)\n\n#define WCDB_CPP_PRIMARY_ASC_AUTO_INCREMENT(fieldName)                         \\\n    __WCDB_CPP_ORDERED_PRIMARY_IMP(fieldName, WCDB::Order::ASC, true)\n\n#define WCDB_CPP_PRIMARY_ENABLE_AUTOINCREMENT_FOR_EXISTING_TABLE               \\\n    __WCDB_CPP_PRIMARY_ENABLE_AUTOINCREMENT_FOR_EXISTING_TABLE\n\n#define WCDB_CPP_NOT_NULL(fieldName) __WCDB_CPP_NOT_NULL_IMP(fieldName)\n\n#define WCDB_CPP_UNIQUE(fieldName) __WCDB_CPP_UNIQUE_IMP(fieldName)\n\n#define WCDB_CPP_DEFAULT(fieldName, defaultValue)                              \\\n    __WCDB_CPP_DEFAULT_IMP(fieldName, defaultValue)\n\n#define WCDB_CPP_CHECK(fieldName, condition)                                   \\\n    __WCDB_CPP_CHECK_IMP(fieldName, condition)\n\n//For FTS\n#define WCDB_CPP_NOTINDEXED(fieldName) __WCDB_CPP_NOTINDEXED_IMP(fieldName)\n\n// Table Constraint\n#define WCDB_CPP_WITHOUT_ROWID __WCDB_CPP_WITHOUT_ROWID\n\n#define WCDB_CPP_MULTI_PRIMARY(constraintName, fieldName)                      \\\n    __WCDB_CPP_MULTI_PRIMARY_IMP(constraintName, fieldName)\n\n#define WCDB_CPP_MULTI_PRIMARY_ASC(constraintName, fieldName)                  \\\n    __WCDB_CPP_ORDERED_MULTI_PRIMARY_IMP(constraintName, fieldName, WCDB::Order::ASC)\n\n#define WCDB_CPP_MULTI_PRIMARY_DESC(constraintName, fieldName)                 \\\n    __WCDB_CPP_ORDERED_MULTI_PRIMARY_IMP(constraintName, fieldName, WCDB::Order::DESC)\n\n#define WCDB_CPP_MULTI_UNIQUE(constraintName, fieldName)                       \\\n    __WCDB_CPP_MULTI_UNIQUE_IMP(constraintName, fieldName)\n\n#define WCDB_CPP_MULTI_UNIQUE_ASC(constraintName, fieldName)                   \\\n    __WCDB_CPP_ORDERED_MULTI_UNIQUE_IMP(constraintName, fieldName, WCDB::Order::ASC)\n\n#define WCDB_CPP_MULTI_UNIQUE_DESC(constraintName, fieldName)                  \\\n    __WCDB_CPP_ORDERED_MULTI_UNIQUE_IMP(constraintName, fieldName, WCDB::Order::DESC)\n\n// Index\n#define WCDB_CPP_INDEX(indexSuffixName, fieldName)                             \\\n    __WCDB_CPP_INDEX_IMP(indexSuffixName, fieldName, false)\n\n#define WCDB_CPP_INDEX_ASC(indexSuffixName, fieldName)                         \\\n    __WCDB_CPP_ORDERED_INDEX_IMP(indexSuffixName, fieldName, WCDB::Order::ASC, false)\n\n#define WCDB_CPP_INDEX_DESC(indexSuffixName, fieldName)                        \\\n    __WCDB_CPP_ORDERED_INDEX_IMP(indexSuffixName, fieldName, WCDB::Order::DESC, false)\n\n#define WCDB_CPP_UNIQUE_INDEX(indexSuffixName, fieldName)                      \\\n    __WCDB_CPP_INDEX_IMP(indexSuffixName, fieldName, true)\n\n#define WCDB_CPP_UNIQUE_INDEX_ASC(indexSuffixName, fieldName)                  \\\n    __WCDB_CPP_ORDERED_INDEX_IMP(indexSuffixName, fieldName, WCDB::Order::ASC, true)\n\n#define WCDB_CPP_UNIQUE_INDEX_DESC(indexSuffixName, fieldName)                 \\\n    __WCDB_CPP_ORDERED_INDEX_IMP(indexSuffixName, fieldName, WCDB::Order::DESC, true)\n\n// Index Operation\n#define WCDB_CPP_INDEX_FOR_NEWLY_CREATED_TABLE_ONLY(indexSuffixName)           \\\n    __WCDB_CPP_INDEX_FOR_NEWLY_CREATED_TABLE_ONLY_IMP(indexSuffixName)\n\n#define WCDB_CPP_INDEX_TO_BE_DROPPED(indexSuffixName)                          \\\n    __WCDB_CPP_INDEX_TO_BE_DROPPED(indexSuffixName)\n\n// Virtual Table Argument\n#define WCDB_CPP_VIRTUAL_TABLE_ARGUMENT(argument)                              \\\n    __WCDB_CPP_VIRTUAL_TABLE_ARGUMENT_IMP(argument)\n\n#define WCDB_CPP_VIRTUAL_TABLE_TOKENIZE(tokenizeName)                          \\\n    __WCDB_CPP_VIRTUAL_TABLE_ARGUMENT_IMP(                                     \\\n    WCDB::FTSTokenizerUtil::tokenize(tokenizeName, nullptr))\n\n#define WCDB_CPP_VIRTUAL_TABLE_TOKENIZE_WITH_PARAMETERS(tokenizeName, ...)     \\\n    __WCDB_CPP_VIRTUAL_TABLE_ARGUMENT_IMP(                                     \\\n    WCDB::FTSTokenizerUtil::tokenize(tokenizeName, __VA_ARGS__, nullptr))\n\n#define WCDB_CPP_VIRTUAL_TABLE_EXTERNAL_CONTENT(tableName)                     \\\n    __WCDB_CPP_VIRTUAL_TABLE_ARGUMENT_IMP(                                     \\\n    WCDB::StatementCreateVirtualTable::externalContent(tableName))\n\n#define WCDB_CPP_VIRTUAL_TABLE_MODULE(moduleName)                              \\\n    __WCDB_CPP_VIRTUAL_TABLE_MODULE_IMP(moduleName)\n\n#define WCDB_CPP_UNINDEXED(propertyName) __WCDB_CPP_UNINDEXED_IMP(propertyName)\n"
  },
  {
    "path": "src/cpp/orm/macro/CPPTableConstraintMacro.h",
    "content": "//\n// Created by qiuwenchen on 2022/8/27.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#define __WCDB_CPP_TABLE_CONSTRAINT_BEGIN(constraintName, fieldName)           \\\n    {                                                                          \\\n        static_assert(has_synthesized_##fieldName,                             \\\n                      \"You need to synthesize this field before you use it\");  \\\n        WCDB::TableConstraint& tableConstraint                                 \\\n        = g_binding->getOrCreateTableConstraint(constraintName);               \\\n        auto temp_memory_point = &WCDBORMType::fieldName;                      \\\n        WCDB_UNUSED(temp_memory_point);\n\n#define __WCDB_CPP_TABLE_CONSTRAINT_END(constraintName, fieldName) }\n\n// multi-primary\n#define __WCDB_CPP_MULTI_PRIMARY_IMP(constraintName, fieldName)                \\\n    __WCDB_CPP_TABLE_CONSTRAINT_BEGIN(constraintName, fieldName)               \\\n    tableConstraint.primaryKey().indexed(_field_##fieldName.asIndex());        \\\n    __WCDB_CPP_TABLE_CONSTRAINT_END(constraintName, fieldName)\n\n#define __WCDB_CPP_ORDERED_MULTI_PRIMARY_IMP(constraintName, fieldName, order_)       \\\n    __WCDB_CPP_TABLE_CONSTRAINT_BEGIN(constraintName, fieldName)                      \\\n    tableConstraint.primaryKey().indexed(_field_##fieldName.asIndex().order(order_)); \\\n    __WCDB_CPP_TABLE_CONSTRAINT_END(constraintName, fieldName)\n\n// multi-unique\n#define __WCDB_CPP_MULTI_UNIQUE_IMP(constraintName, fieldName)                 \\\n    __WCDB_CPP_TABLE_CONSTRAINT_BEGIN(constraintName, fieldName)               \\\n    tableConstraint.unique().indexed(_field_##fieldName.asIndex());            \\\n    __WCDB_CPP_TABLE_CONSTRAINT_END(constraintName, fieldName)\n\n#define __WCDB_CPP_ORDERED_MULTI_UNIQUE_IMP(constraintName, fieldName, order_)    \\\n    __WCDB_CPP_TABLE_CONSTRAINT_BEGIN(constraintName, fieldName)                  \\\n    tableConstraint.unique().indexed(_field_##fieldName.asIndex().order(order_)); \\\n    __WCDB_CPP_TABLE_CONSTRAINT_END(constraintName, fieldName)\n\n#define __WCDB_CPP_WITHOUT_ROWID                                               \\\n    {                                                                          \\\n        WCDB::StatementCreateTable& statement = binding.statementTable;        \\\n        statement.withoutRowID();                                              \\\n    }\n"
  },
  {
    "path": "src/cpp/orm/macro/CPPVirtualTableMacro.h",
    "content": "//\n// Created by qiuwenchen on 2022/8/28.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"Macro.h\"\n\n#define __WCDB_CPP_VIRTUAL_TABLE_BEGIN()                                       \\\n    {                                                                          \\\n        WCDB::StatementCreateVirtualTable& statement = g_binding->statementVirtualTable;\n\n#define __WCDB_CPP_VIRTUAL_TABLE_END() }\n\n#define __WCDB_CPP_VIRTUAL_TABLE_ARGUMENT_IMP(argument_)                       \\\n    __WCDB_CPP_VIRTUAL_TABLE_BEGIN()                                           \\\n    statement.argument(argument_);                                             \\\n    __WCDB_CPP_VIRTUAL_TABLE_END()\n\n#define __WCDB_CPP_VIRTUAL_TABLE_MODULE_IMP(moduleName)                        \\\n    __WCDB_CPP_VIRTUAL_TABLE_BEGIN()                                           \\\n    statement.usingModule(moduleName);                                         \\\n    __WCDB_CPP_VIRTUAL_TABLE_END()\n"
  },
  {
    "path": "src/cpp/tests/common/CPPBaseTestCase.h",
    "content": "//\n// Created by qiuwenchen on 2022/8/10.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import <XCTest/XCTest.h>\n\n@class Dispatch;\n@class Random;\n\n@interface CPPBaseTestCase : XCTestCase\n\n@property (class, nonatomic, readonly) NSString* root;\n@property (class, nonatomic, readonly) NSString* cacheRoot;\n\n@property (nonatomic, readonly) NSString* cacheDirectory;\n@property (nonatomic, readonly) NSString* directory;\n\n@property (nonatomic, readonly) NSString* className;\n@property (nonatomic, readonly) NSString* testName;\n\n@property (nonatomic, readonly) NSFileManager* fileManager;\n@property (nonatomic, readonly) Random* random;\n\n@property (nonatomic, readonly) Dispatch* dispatch;\n\n- (void)log:(NSString*)format, ...;\n\n@end\n"
  },
  {
    "path": "src/cpp/tests/common/CPPBaseTestCase.mm",
    "content": "//\n// Created by qiuwenchen on 2022/8/10.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"CPPBaseTestCase.h\"\n#import \"Dispatch.h\"\n#import \"NSObject+TestCase.h\"\n#import \"Random.h\"\n#import \"TestCaseAssertion.h\"\n#import \"TestCaseLog.h\"\n#import <Foundation/Foundation.h>\n#if TEST_WCDB_OBJC\n#import <WCDBOBjc/WCDBCpp.h>\n#elif TEST_WCDB_CPP\n#import <WCDBCpp/WCDBCpp.h>\n#else\n#import <WCDB/WCDBCpp.h>\n#endif\n\n@implementation CPPBaseTestCase {\n    Random *_random;\n    NSString *_className;\n    NSString *_testName;\n    NSString *_directory;\n    Dispatch *_dispatch;\n}\n\n+ (void)initialize\n{\n    if (self.class == CPPBaseTestCase.class) {\n        TestCaseAssertTrue([NSThread isMainThread]);\n        pthread_setname_np(\"com.Tencent.WCDB.Main\");\n    }\n}\n\n+ (void)breakpoint\n{\n}\n\n- (void)setUp\n{\n    [super setUp];\n\n    self.continueAfterFailure = NO;\n\n    [Random shared].stable = NO;\n\n    WCDB::Database::globalTracePerformance(nullptr);\n    WCDB::Database::globalTraceSQL(nullptr);\n    Class selfClass = self.class;\n    WCDB::Database::globalTraceError([selfClass](const WCDB::Error &error) {\n        NSThread *currentThread = [NSThread currentThread];\n        NSString *threadName = currentThread.name;\n        if (threadName.length == 0) {\n            threadName = [NSString stringWithFormat:@\"%p\", currentThread];\n        }\n        switch (error.level) {\n        case WCDB::Error::Level::Debug:\n#ifndef DEBUG\n            break;\n#endif\n            // passthrough\n        default:\n            TestCaseLog(@\"%@ Thread %@: %s\", currentThread.isMainThread ? @\"*\" : @\"-\", threadName, error.getDescription().data());\n            break;\n        }\n\n        switch (error.level) {\n        case WCDB::Error::Level::Error:\n            [selfClass breakpoint];\n            break;\n        case WCDB::Error::Level::Fatal:\n            abort();\n            break;\n        default:\n            break;\n        }\n    });\n\n#if DEBUG\n    [self log:@\"debuggable.\"];\n#endif\n\n    NSString *directory = self.directory;\n    NSString *abbreviatedPath = directory.stringByAbbreviatingWithTildeInPath;\n    if (abbreviatedPath.length > 0) {\n        directory = abbreviatedPath;\n    }\n    [self log:@\"run at %@\", directory];\n\n    [self refreshDirectory];\n}\n\n- (void)tearDown\n{\n    [Random shared].stable = NO;\n\n    [self.dispatch waitUntilDone];\n\n    WCDB::Database::globalTracePerformance(nullptr);\n    WCDB::Database::globalTraceSQL(nullptr);\n    WCDB::Database::globalTraceError(nullptr);\n    [self cleanDirectory];\n    [super tearDown];\n}\n\n- (Random *)random\n{\n    return [Random shared];\n}\n\n- (NSString *)testName\n{\n    @synchronized(self) {\n        if (_testName == nil) {\n            NSString *name = self.name;\n            NSRegularExpression *regex = [NSRegularExpression regularExpressionWithPattern:@\"\\\\[\\\\w+ (\\\\w+).*\\\\]\" options:NSRegularExpressionCaseInsensitive error:nil];\n            NSTextCheckingResult *match = [regex firstMatchInString:name options:0 range:NSMakeRange(0, [name length])];\n            _testName = [name substringWithRange:[match rangeAtIndex:1]];\n        }\n        return _testName;\n    }\n}\n\n- (void)refreshDirectory\n{\n    [self cleanDirectory];\n    TestCaseAssertTrue([self.fileManager createDirectoryAtPath:self.directory\n                                   withIntermediateDirectories:YES\n                                                    attributes:nil\n                                                         error:nil]);\n}\n\n- (void)cleanDirectory\n{\n    if ([self.fileManager fileExistsAtPath:self.directory]) {\n        NSError *error;\n        TestCaseAssertTrue([self.fileManager removeItemAtPath:self.directory error:&error]);\n    }\n}\n\n- (NSString *)className\n{\n    @synchronized(self) {\n        if (_className == nil) {\n            _className = NSStringFromClass(self.class);\n        }\n        return _className;\n    }\n}\n\n+ (NSString *)root\n{\n    return [[[NSTemporaryDirectory() stringByAppendingPathComponent:@\"WCDBCpp\"] stringByAppendingPathComponent:[NSBundle mainBundle].bundleIdentifier] test_stringByStandardizingPath];\n}\n\n+ (NSString *)cacheRoot\n{\n    return [[[NSTemporaryDirectory() stringByAppendingPathComponent:@\"WCDBCpp\"] stringByAppendingPathComponent:[[NSBundle mainBundle].bundleIdentifier stringByAppendingString:@\".Cache\"]] test_stringByStandardizingPath];\n}\n\n- (NSString *)directory\n{\n    @synchronized(self) {\n        if (_directory == nil) {\n            _directory = [[self.class.root stringByAppendingPathComponent:self.className] stringByAppendingPathComponent:self.testName];\n        }\n        return _directory;\n    }\n}\n\n- (NSFileManager *)fileManager\n{\n    return [NSFileManager defaultManager];\n}\n\n- (Dispatch *)dispatch\n{\n    @synchronized(self) {\n        if (_dispatch == nil) {\n            _dispatch = [[Dispatch alloc] init];\n        }\n        return _dispatch;\n    }\n}\n\n- (void)log:(NSString *)format, ...\n{\n    va_list ap;\n    va_start(ap, format);\n    NSString *description = [[NSString alloc] initWithFormat:format arguments:ap];\n    va_end(ap);\n    NSString *log = [NSString stringWithFormat:@\"Test Case '%@' %@\", self.name, description];\n    TestCaseLog(@\"%@\", log);\n}\n\n@end\n"
  },
  {
    "path": "src/cpp/tests/common/CPPCRUDTestCase.h",
    "content": "//\n// Created by qiuwenchen on 2022/8/14.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"CPPTableTestCase.h\"\n\n@interface CPPCRUDTestCase : CPPTableTestCase\n\n#pragma mark - object\n@property (nonatomic, readonly) CPPTestCaseObject& object1;\n@property (nonatomic, readonly) CPPTestCaseObject& object2;\n@property (nonatomic, readonly) WCDB::ValueArray<CPPTestCaseObject>& objects;\n- (void)insertPresetObjects;\n\n#pragma mark - value\n@property (nonatomic, readonly) WCDB::OneRowValue row1;\n@property (nonatomic, readonly) WCDB::OneRowValue row2;\n@property (nonatomic, readonly) WCDB::MultiRowsValue rows;\n\n- (void)insertPresetRows;\n- (int64_t)nextIdentifier;\n- (int)allRowsCount;\n@end\n"
  },
  {
    "path": "src/cpp/tests/common/CPPCRUDTestCase.mm",
    "content": "//\n// Created by qiuwenchen on 2022/8/14.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"CPPCRUDTestCase.h\"\n#import \"CPPTestCase.h\"\n\n@implementation CPPCRUDTestCase {\n    CPPTestCaseObject _object1;\n    CPPTestCaseObject _object2;\n    WCDB::ValueArray<CPPTestCaseObject> _objects;\n\n    WCDB::OneRowValue _row1;\n    WCDB::OneRowValue _row2;\n    WCDB::MultiRowsValue _rows;\n}\n\n- (void)setUp\n{\n    [super setUp];\n    _object1 = [Random.shared testCaseObjectWithIdentifier:1];\n    _object2 = [Random.shared testCaseObjectWithIdentifier:2];\n    _objects = { _object1, _object2 };\n\n    _row1 = [Random.shared testCaseValuesWithCount:1 startingFromIdentifier:1][0];\n    _row2 = [Random.shared testCaseValuesWithCount:1 startingFromIdentifier:2][0];\n    _rows = { self.row1, self.row2 };\n}\n\n- (CPPTestCaseObject &)object1\n{\n    return _object1;\n}\n\n- (CPPTestCaseObject &)object2\n{\n    return _object2;\n}\n\n- (WCDB::ValueArray<CPPTestCaseObject> &)objects\n{\n    return _objects;\n}\n\n- (void)insertPresetObjects\n{\n    TestCaseAssertTrue([self createObjectTable]);\n    TestCaseAssertTrue(self.database->insertObjects(_objects, self.tableName.UTF8String));\n    self.database->close();\n}\n\n- (WCDB::OneRowValue)row1\n{\n    return _row1;\n}\n\n- (WCDB::OneRowValue)row2\n{\n    return _row2;\n}\n\n- (WCDB::MultiRowsValue)rows\n{\n    return _rows;\n}\n\n- (int64_t)nextIdentifier\n{\n    return 3;\n}\n\n- (int)allRowsCount\n{\n    WCDB::OptionalValue value = self.database->getValueFromStatement(WCDB::StatementSelect().select(WCDB::Expression::function(\"count\").invokeAll()).from(self.tableName.UTF8String));\n    TestCaseAssertTrue(value.succeed());\n    return value.value();\n}\n\n- (void)insertPresetRows\n{\n    TestCaseAssertTrue([self createValueTable]);\n    TestCaseAssertTrue(self.database->insertRows(self.rows, self.columns, self.tableName.UTF8String));\n    self.database->close();\n}\n\n@end\n"
  },
  {
    "path": "src/cpp/tests/common/CPPDatabaseTestCase.h",
    "content": "//\n// Created by qiuwenchen on 2022/8/10.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"CPPBaseTestCase.h\"\n#if TEST_WCDB_OBJC\n#import <WCDBOBjc/WCDBCpp.h>\n#elif TEST_WCDB_CPP\n#import <WCDBCpp/WCDBCpp.h>\n#else\n#import <WCDB/WCDBCpp.h>\n#endif\n\ntypedef NS_ENUM(NSUInteger, DatabaseTestCaseExpect) {\n    DatabaseTestCaseExpectAllSQLs = 0,\n    DatabaseTestCaseExpectFirstFewSQLs,\n    DatabaseTestCaseExpectSomeSQLs,\n};\n\n@interface CPPDatabaseTestCase : CPPBaseTestCase\n\n#pragma mark - Path\n@property (nonatomic, retain) NSString* path;\n\n#pragma mark - Database\n@property (readonly, nonatomic) WCDB::Database* database;\n\n@property (nonatomic, readonly) NSString* walPath;\n@property (nonatomic, readonly) NSString* factoryPath;\n@property (nonatomic, readonly) NSString* firstMaterialPath;\n@property (nonatomic, readonly) NSString* lastMaterialPath;\n@property (nonatomic, readonly) NSString* journalPath;\n@property (nonatomic, readonly) NSString* shmPath;\n@property (nonatomic, readonly) NSString* factoryRestorePath;\n\n@property (nonatomic, readonly) int headerSize;\n@property (nonatomic, readonly) int pageSize;\n@property (nonatomic, readonly) int walHeaderSize;\n@property (nonatomic, readonly) int walFrameHeaderSize;\n@property (nonatomic, readonly) int walFrameSize;\n\n#pragma mark - SQL\n+ (void)enableSQLTrace;\n+ (void)disableSQLTrace;\n\n+ (void)enablePerformanceTrace;\n+ (void)disablePerformanceTrace;\n\n#pragma mark - Test\n@property (nonatomic, readonly) NSTimeInterval delayForTolerance;\n\n@property (nonatomic, assign) BOOL expectSQLsInAllThreads;\n@property (nonatomic, assign) DatabaseTestCaseExpect expectMode;\n\n- (void)doTestSQLs:(NSArray<NSString*>*)expectedSQLs\n       inOperation:(BOOL (^)())block;\n\n- (unsigned long)getNumberOfPages;\n\n- (unsigned long)getNumberOfWalFrames;\n\n@end\n"
  },
  {
    "path": "src/cpp/tests/common/CPPDatabaseTestCase.mm",
    "content": "//\n// Created by qiuwenchen on 2022/8/10.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"CPPDatabaseTestCase.h\"\n#import \"NSObject+TestCase.h\"\n#import \"Random+WCDB.h\"\n#import \"Random.h\"\n#import \"TestCaseAssertion.h\"\n#import \"TestCaseLog.h\"\n#import \"TestCaseResult.h\"\n\n@implementation CPPDatabaseTestCase {\n    WCDB::Database *_database;\n    NSString *_path;\n}\n\n- (void)setUp\n{\n    [super setUp];\n\n    self.expectSQLsInAllThreads = NO;\n    self.expectMode = DatabaseTestCaseExpectAllSQLs;\n}\n\n- (void)tearDown\n{\n    if (_database != nullptr) {\n        _database->close();\n        delete _database;\n    }\n    [super tearDown];\n}\n\n#pragma mark - Path\n- (void)setPath:(NSString *)path\n{\n    @synchronized(self) {\n        _path = path;\n        if (_database != nullptr) {\n            _database->close();\n            delete _database;\n        }\n        _database = new WCDB::Database(path.UTF8String);\n    }\n}\n\n- (NSString *)path\n{\n    @synchronized(self) {\n        if (_path == nil) {\n            _path = [self.directory stringByAppendingPathComponent:@\"testDatabase\"];\n        }\n        return _path;\n    }\n}\n\n#pragma mark - Database\n- (WCDB::Database *)database\n{\n    @synchronized(self) {\n        if (_database == nullptr) {\n            _database = new WCDB::Database(self.path.UTF8String);\n            _database->setTag(Random.shared.tag);\n        }\n        return _database;\n    }\n}\n\n- (NSString *)walPath\n{\n    return [self.path stringByAppendingString:@\"-wal\"];\n}\n\n- (NSString *)firstMaterialPath\n{\n    return [self.path stringByAppendingString:@\"-first.material\"];\n}\n\n- (NSString *)lastMaterialPath\n{\n    return [self.path stringByAppendingString:@\"-last.material\"];\n}\n\n- (NSString *)factoryPath\n{\n    return [self.path stringByAppendingString:@\".factory\"];\n}\n\n- (NSString *)journalPath\n{\n    return [self.path stringByAppendingString:@\"-journal\"];\n}\n\n- (NSString *)shmPath\n{\n    return [self.path stringByAppendingString:@\"-shm\"];\n}\n\n- (NSString *)factoryRestorePath\n{\n    return [self.factoryPath stringByAppendingPathComponent:@\"restore\"];\n}\n\n- (int)headerSize\n{\n    return 100;\n}\n\n- (int)pageSize\n{\n    return 4096;\n}\n\n- (int)walHeaderSize\n{\n    return 32;\n}\n\n- (int)walFrameHeaderSize\n{\n    return 24;\n}\n\n- (int)walFrameSize\n{\n    return self.walFrameHeaderSize + self.pageSize;\n}\n\n#pragma mark - SQL\n// For debugging only\n+ (void)enableSQLTrace\n{\n    WCDB::Database::globalTraceSQL([](long, const WCDB::UnsafeStringView &, const void *, const WCDB::UnsafeStringView &sql, const WCDB::UnsafeStringView &) {\n        NSThread *currentThread = [NSThread currentThread];\n        NSString *threadName = currentThread.name;\n        if (threadName.length == 0) {\n            threadName = [NSString stringWithFormat:@\"%p\", currentThread];\n        }\n        TestCaseLog(@\"%@ Thread %@: %s\", currentThread.isMainThread ? @\"*\" : @\"-\", threadName, sql.data());\n    });\n}\n\n+ (void)disableSQLTrace\n{\n    WCDB::Database::globalTraceSQL(nullptr);\n}\n\n+ (void)enablePerformanceTrace\n{\n    WCDB::Database::globalTracePerformance([=](long, const WCDB::UnsafeStringView &, uint64_t, const WCDB::UnsafeStringView &sql, const WCDB::Database::PerformanceInfo &info) {\n        NSThread *currentThread = [NSThread currentThread];\n        NSString *threadName = currentThread.name;\n        if (threadName.length == 0) {\n            threadName = [NSString stringWithFormat:@\"%p\", currentThread];\n        }\n        NSString *description = [NSString stringWithFormat:@\"%s\", sql.data()];\n        TestCaseLog(@\"%@ Thread %@: %@ %.2f\", currentThread.isMainThread ? @\"*\" : @\"-\", threadName, description, ((double) info.costInNanoseconds) / 1E9);\n    });\n}\n\n+ (void)disablePerformanceTrace\n{\n    WCDB::Database::globalTracePerformance(nullptr);\n}\n\n#pragma mark - Test\n- (void)doTestSQLs:(NSArray<NSString *> *)testSQLs inOperation:(BOOL (^)())block\n{\n    TestCaseAssertTrue(testSQLs != nil);\n    TestCaseAssertTrue(block != nil);\n    TestCaseAssertTrue([testSQLs isKindOfClass:NSArray.class]);\n    do {\n        TestCaseResult *trace = [TestCaseResult no];\n        NSMutableArray<NSString *> *expectedSQLs = [NSMutableArray arrayWithArray:testSQLs];\n        NSThread *tracedThread = [NSThread currentThread];\n        __weak CPPDatabaseTestCase *weakSelf = self;\n        self.database->traceSQL([weakSelf, tracedThread, expectedSQLs, trace](long, const WCDB::UnsafeStringView &, const void *, const WCDB::UnsafeStringView &sql, const WCDB::UnsafeStringView &) {\n            CPPDatabaseTestCase *strongSelf = weakSelf;\n            if (!strongSelf.expectSQLsInAllThreads && tracedThread != [NSThread currentThread]) {\n                // skip other thread sqls due to the setting\n                return;\n            }\n            if (trace.isNO) {\n                return;\n            }\n            @synchronized(expectedSQLs) {\n                [strongSelf doTestSQLAsExpected:expectedSQLs sql:sql];\n            }\n        });\n        if (self.expectMode != DatabaseTestCaseExpectSomeSQLs) {\n            if (!self.database->canOpen()) {\n                TestCaseFailure();\n                break;\n            }\n        }\n\n        [trace makeYES];\n        @autoreleasepool {\n            if (!block()) {\n                TestCaseFailure();\n                break;\n            }\n        }\n        @synchronized(expectedSQLs) {\n            if (expectedSQLs.count != 0) {\n                TestCaseLog(@\"Reminding: %@\", expectedSQLs);\n                TestCaseFailure();\n                break;\n            }\n        }\n        [trace makeNO];\n    } while (false);\n    self.database->traceSQL(nullptr);\n}\n\n- (void)doTestSQLAsExpected:(NSMutableArray<NSString *> *)expectedSQLs sql:(const WCDB::UnsafeStringView &)cppSql\n{\n    NSString *sql = [NSString stringWithUTF8String:cppSql.data()];\n    switch (self.expectMode) {\n    case DatabaseTestCaseExpectAllSQLs:\n        if ([expectedSQLs.firstObject isEqualToString:sql]) {\n            [expectedSQLs removeObjectAtIndex:0];\n        } else {\n            TestCaseAssertStringEqual(expectedSQLs.firstObject, sql);\n        }\n        break;\n    case DatabaseTestCaseExpectFirstFewSQLs:\n        if ([expectedSQLs.firstObject isEqualToString:sql]) {\n            [expectedSQLs removeObjectAtIndex:0];\n        } else if (expectedSQLs.count != 0) {\n            TestCaseAssertStringEqual(expectedSQLs.firstObject, sql);\n        }\n        break;\n    case DatabaseTestCaseExpectSomeSQLs:\n        for (NSUInteger i = 0; i < expectedSQLs.count; ++i) {\n            if ([expectedSQLs[i] isEqualToString:sql]) {\n                [expectedSQLs removeObjectAtIndex:i];\n                break;\n            }\n        }\n        break;\n    }\n}\n\n- (NSTimeInterval)delayForTolerance\n{\n    return 2;\n}\n\n- (unsigned long)getNumberOfPages\n{\n    unsigned long result = 0;\n    if ([[NSFileManager defaultManager] fileExistsAtPath:self.path]) {\n        NSError *error;\n        size_t size = (size_t) ((NSNumber *) [[NSFileManager defaultManager] attributesOfItemAtPath:self.path error:&error][NSFileSize]).unsignedLongLongValue;\n        if (error == nil) {\n            int numberOfPages = (int) (size / self.pageSize);\n            result = numberOfPages > 0 ? numberOfPages : 0;\n        } else {\n            TestCaseLog(@\"%@\", error);\n        }\n    } else {\n        result = 0;\n    }\n    return result;\n}\n\n- (unsigned long)getNumberOfWalFrames\n{\n    unsigned long result = 0;\n    NSError *error;\n    if ([[NSFileManager defaultManager] fileExistsAtPath:self.walPath]) {\n        size_t size = (size_t) ((NSNumber *) [[NSFileManager defaultManager] attributesOfItemAtPath:self.walPath error:&error][NSFileSize]).unsignedLongLongValue;\n        if (error == nil) {\n            if (size == 0) {\n                result = 0;\n            } else if (size > self.walHeaderSize) {\n                if ((size - self.walHeaderSize) % self.walFrameSize == 0) {\n                    result = (size - self.walHeaderSize) / self.walFrameSize;\n                }\n            }\n        } else {\n            TestCaseLog(@\"%@\", error);\n        }\n    } else {\n        result = 0;\n    }\n    return result;\n}\n\n@end\n"
  },
  {
    "path": "src/cpp/tests/common/CPPORMTestUtil.h",
    "content": "//\n// Created by qiuwenchen on 2022/9/5.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"TestCaseAssertion.h\"\n#if TEST_WCDB_OBJC\n#import <WCDBOBjc/CPPORM.h>\n#elif TEST_WCDB_CPP\n#import <WCDBCpp/CPPORM.h>\n#else\n#import <WCDB/CPPORM.h>\n#endif\n#if TEST_WCDB_OBJC\n#import <WCDBOBjc/Value.hpp>\n#elif TEST_WCDB_CPP\n#import <WCDBCpp/Value.hpp>\n#else\n#import <WCDB/Value.hpp>\n#endif\n\n@class CPPTableTestCase;\n\n#pragma mark - Create table\n\ntemplate<class ObjectType>\nBOOL CPPTestTableCreate(CPPTableTestCase* testCase)\n{\n    return testCase.database->createTable<ObjectType>(testCase.tableName.UTF8String);\n}\n\ntemplate<class ObjectType>\nBOOL CPPTestVirtualTableCreate(CPPTableTestCase* testCase)\n{\n    return testCase.database->createVirtualTable<ObjectType>(testCase.tableName.UTF8String);\n}\n\n#pragma mark - extract value\n\ntemplate<class ObjectType>\nWCDB::OneRowValue CPPOneRowValueExtract(const ObjectType& obj)\n{\n    return CPPOneRowValueExtract(obj, ObjectType::allFields());\n}\n\ntemplate<class ObjectType>\nWCDB::OneRowValue CPPOneRowValueExtract(const ObjectType& obj, const WCDB::Fields& fields)\n{\n    WCDB::OneRowValue row;\n    for (const WCDB::Field& field : fields) {\n        row.push_back(field.getValue<ObjectType>(obj));\n    }\n    return row;\n}\n\ntemplate<class ObjectType>\nWCDB::MultiRowsValue CPPMultiRowValueExtract(const WCDB::ValueArray<ObjectType>& objs)\n{\n    return CPPMultiRowValueExtract(objs, ObjectType::allFields());\n}\n\ntemplate<class ObjectType>\nWCDB::MultiRowsValue CPPMultiRowValueExtract(const WCDB::ValueArray<ObjectType>& objs, const WCDB::Fields& fields)\n{\n    WCDB::MultiRowsValue rows;\n    for (const ObjectType& obj : objs) {\n        rows.push_back(CPPOneRowValueExtract(obj, fields));\n    }\n    return rows;\n}\n"
  },
  {
    "path": "src/cpp/tests/common/CPPTableTestCase.h",
    "content": "//\n// Created by qiuwenchen on 2022/8/13.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"CPPDatabaseTestCase.h\"\n#import \"CPPTestCaseObject.h\"\n\n@interface CPPTableTestCase : CPPDatabaseTestCase\n\n@property (nonatomic, retain) NSString *tableName;\n- (BOOL)dropTable;\n\n#pragma mark - Object\n@property (nonatomic, readonly) WCDB::Table<CPPTestCaseObject> &table;\n- (BOOL)createObjectTable;\n\n- (void)doTestObjects:(const WCDB::ValueArray<CPPTestCaseObject> &)objects\n               andSQL:(NSString *)sql\n    afterModification:(BOOL (^)())block;\n\n- (void)doTestObjects:(const WCDB::ValueArray<CPPTestCaseObject> &)objects\n              andSQLs:(NSArray<NSString *> *)sqls\n    afterModification:(BOOL (^)())block;\n\n- (void)doTestObjects:(const WCDB::ValueArray<CPPTestCaseObject> &)objects\n            andNumber:(int)numberOfInsertSQLs\n         ofInsertSQLs:(NSString *)insertSQL\n       afterInsertion:(BOOL (^)())block;\n\n- (void)doTestObject:(const CPPTestCaseObject &)object\n              andSQL:(NSString *)sql\n         bySelecting:(WCDB::Optional<CPPTestCaseObject> (^)())block;\n\n- (void)doTestObjects:(const WCDB::ValueArray<CPPTestCaseObject> &)objects\n               andSQL:(NSString *)sql\n          bySelecting:(WCDB::OptionalValueArray<CPPTestCaseObject> (^)())block;\n\n- (void)doTestObjects:(const WCDB::ValueArray<CPPTestCaseObject> &)expectedObjects\n              andSQLs:(NSArray<NSString *> *)expectedSQLs\n          bySelecting:(WCDB::OptionalValueArray<CPPTestCaseObject> (^)())block;\n\n- (WCDB::ValueArray<CPPTestCaseObject>)getAllObjects;\n\n#pragma mark - Value\n- (BOOL)createValueTable;\n- (WCDB::Columns)columns;\n- (WCDB::ResultColumns)resultColumns;\n\n- (void)doTestRow:(const WCDB::OneRowValue &)row\n           andSQL:(NSString *)sql\n      bySelecting:(WCDB::OptionalOneRow (^)())block;\n\n- (void)doTestColumn:(const WCDB::OneColumnValue &)column\n              andSQL:(NSString *)sql\n         bySelecting:(WCDB::OptionalOneColumn (^)())block;\n\n- (void)doTestValue:(const WCDB::Value &)value\n             andSQL:(NSString *)sql\n        bySelecting:(WCDB::OptionalValue (^)())block;\n\n- (void)doTestRows:(const WCDB::MultiRowsValue &)rows\n            andSQL:(NSString *)sql\n       bySelecting:(WCDB::OptionalMultiRows (^)())block;\n\n- (void)doTestRows:(const WCDB::MultiRowsValue &)rows\n           andSQLs:(NSArray<NSString *> *)sqls\n       bySelecting:(WCDB::OptionalMultiRows (^)())block;\n\n- (WCDB::MultiRowsValue)getAllvalues;\n\n- (void)check:(const WCDB::MultiRowsValue &)selected isEqualTo:(const WCDB::MultiRowsValue &)expectedRows;\n\n@end\n"
  },
  {
    "path": "src/cpp/tests/common/CPPTableTestCase.mm",
    "content": "//\n// Created by qiuwenchen on 2022/8/13.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"CPPTableTestCase.h\"\n#import \"CPPORMTestUtil.h\"\n#import \"TestCaseAssertion.h\"\n#import <Foundation/Foundation.h>\n\n@interface CPPTableTestCase () {\n    std::shared_ptr<WCDB::Table<CPPTestCaseObject>> m_table;\n}\n@end\n\n@implementation CPPTableTestCase\n\n- (NSString*)tableName\n{\n    @synchronized(self) {\n        if (_tableName == nil) {\n            _tableName = @\"testTable\";\n        }\n        return _tableName;\n    }\n}\n\n#pragma mark - Object\n- (WCDB::Table<CPPTestCaseObject>&)table\n{\n    if (!m_table) {\n        m_table = std::make_shared<WCDB::Table<CPPTestCaseObject>>(self.database->getTable<CPPTestCaseObject>(self.tableName.UTF8String));\n    }\n    return *m_table.get();\n}\n\n- (BOOL)createObjectTable\n{\n    return self.database->createTable<CPPTestCaseObject>(self.tableName.UTF8String);\n}\n\n- (void)doTestObjects:(const WCDB::ValueArray<CPPTestCaseObject>&)objects\n               andSQL:(NSString*)sql\n    afterModification:(BOOL (^)())block\n{\n    [self doTestObjects:objects andSQLs:@[ sql ] afterModification:block];\n}\n\n- (void)doTestObjects:(const WCDB::ValueArray<CPPTestCaseObject>&)objects\n              andSQLs:(NSArray<NSString*>*)sqls\n    afterModification:(BOOL (^)())block\n{\n    TestCaseAssertTrue(sqls.count > 0);\n    [self doTestSQLs:sqls inOperation:block];\n    WCDB::ValueArray<CPPTestCaseObject> selected = [self getAllObjects];\n    [self check:CPPMultiRowValueExtract(selected) isEqualTo:CPPMultiRowValueExtract(objects)];\n}\n\n- (void)doTestObjects:(const WCDB::ValueArray<CPPTestCaseObject>&)objects\n            andNumber:(int)numberOfInsertSQLs\n         ofInsertSQLs:(NSString*)insertSQL\n       afterInsertion:(BOOL (^)())block\n{\n    TestCaseAssertTrue(numberOfInsertSQLs > 0);\n    TestCaseAssertTrue(insertSQL != nil);\n    NSMutableArray<NSString*>* sqls = [NSMutableArray array];\n    if (numberOfInsertSQLs > 1) {\n        [sqls addObject:@\"BEGIN IMMEDIATE\"];\n    }\n    for (int i = 0; i < numberOfInsertSQLs; ++i) {\n        [sqls addObject:insertSQL];\n    }\n    if (numberOfInsertSQLs > 1) {\n        [sqls addObject:@\"COMMIT\"];\n    }\n    [self doTestObjects:objects\n                andSQLs:sqls\n      afterModification:block];\n}\n\n- (void)doTestObject:(const CPPTestCaseObject&)object\n              andSQL:(NSString*)sql\n         bySelecting:(WCDB::Optional<CPPTestCaseObject> (^)())block\n{\n    [self doTestObjects:object\n                andSQLs:@[ sql ]\n            bySelecting:^WCDB::OptionalValueArray<CPPTestCaseObject> {\n                const WCDB::Optional<CPPTestCaseObject> result = block();\n                TestCaseAssertTrue(result.succeed());\n                return { result.value() };\n            }];\n}\n\n- (void)doTestObjects:(const WCDB::ValueArray<CPPTestCaseObject>&)expectedObjects\n               andSQL:(NSString*)sql\n          bySelecting:(WCDB::OptionalValueArray<CPPTestCaseObject> (^)())block\n{\n    [self doTestObjects:expectedObjects andSQLs:@[ sql ] bySelecting:block];\n}\n\n- (void)doTestObjects:(const WCDB::ValueArray<CPPTestCaseObject>&)expectedObjects\n              andSQLs:(NSArray<NSString*>*)expectedSQLs\n          bySelecting:(WCDB::OptionalValueArray<CPPTestCaseObject> (^)())block\n{\n    __block WCDB::ValueArray<CPPTestCaseObject> selected;\n    [self doTestSQLs:expectedSQLs\n         inOperation:^BOOL {\n             auto values = block();\n             TestCaseAssertTrue(values.succeed());\n             selected = values.value();\n             return selected.size() > 0;\n         }];\n    [self check:CPPMultiRowValueExtract(selected) isEqualTo:CPPMultiRowValueExtract(expectedObjects)];\n}\n\n- (WCDB::ValueArray<CPPTestCaseObject>)getAllObjects\n{\n    auto allObject = self.table.getAllObjects();\n    TestCaseAssertTrue(allObject.succeed());\n    return allObject.value();\n}\n\n#pragma mark - Value\n\n- (BOOL)createValueTable\n{\n    WCDB::StatementCreateTable createTable = WCDB::StatementCreateTable().createTable(self.tableName.UTF8String);\n    createTable.define(WCDB::ColumnDef(\"identifier\", WCDB::ColumnType::Integer).constraint(WCDB::ColumnConstraint().primaryKey().autoIncrement()));\n    createTable.define(WCDB::ColumnDef(\"content\", WCDB::ColumnType::Text));\n    return self.database->execute(createTable);\n}\n\n- (BOOL)dropTable\n{\n    return self.database->dropTable(self.tableName.UTF8String);\n}\n\n- (WCDB::Columns)columns\n{\n    return {\n        WCDB::Column(\"identifier\"),\n        WCDB::Column(\"content\"),\n    };\n}\n- (WCDB::ResultColumns)resultColumns\n{\n    return self.columns;\n}\n\n- (void)doTestRow:(const WCDB::OneRowValue&)row\n           andSQL:(NSString*)sql\n      bySelecting:(WCDB::OptionalOneRow (^)())block\n{\n    TestCaseAssertTrue(row.size() > 0);\n    TestCaseAssertTrue(sql != nil);\n    [self doTestRows:{ row }\n             andSQLs:@[ sql ]\n         bySelecting:^WCDB::OptionalMultiRows {\n             WCDB::OptionalOneRow result = block();\n             TestCaseAssertTrue(result.succeed());\n             return { result.value() };\n         }];\n}\n\n- (void)doTestColumn:(const WCDB::OneColumnValue&)column\n              andSQL:(NSString*)sql\n         bySelecting:(WCDB::OptionalOneColumn (^)())block\n{\n    TestCaseAssertTrue(sql != nil);\n    TestCaseAssertTrue(column.size() > 0);\n    WCDB::MultiRowsValue rows;\n    for (WCDB::Value value : column) {\n        rows.push_back({ value });\n    }\n    [self doTestRows:rows\n             andSQLs:@[ sql ]\n         bySelecting:^WCDB::OptionalMultiRows {\n             WCDB::OptionalOneColumn result = block();\n             TestCaseAssertTrue(result.succeed());\n             WCDB::MultiRowsValue resultRows;\n             for (WCDB::Value value : result.value()) {\n                 resultRows.push_back({ value });\n             }\n             return resultRows;\n         }];\n}\n\n- (void)doTestValue:(const WCDB::Value&)value\n             andSQL:(NSString*)sql\n        bySelecting:(WCDB::OptionalValue (^)())block\n{\n    TestCaseAssertTrue(sql != nil);\n    [self doTestRows:{ { value } }\n             andSQLs:@[ sql ]\n         bySelecting:^WCDB::OptionalMultiRows {\n             WCDB::OptionalValue result = block();\n             TestCaseAssertTrue(result.succeed());\n             static_assert(std::is_constructible<WCDB::MultiRowsValue, std::vector<std::vector<WCDB::Value>>>::value, \"\");\n             WCDB::MultiRowsValue values = { { result.value() } };\n\n             return values;\n         }];\n}\n\n- (void)doTestRows:(const WCDB::MultiRowsValue&)rows\n            andSQL:(NSString*)sql\n       bySelecting:(WCDB::OptionalMultiRows (^)())block\n{\n    TestCaseAssertTrue(sql != nil);\n    [self doTestRows:rows andSQLs:@[ sql ] bySelecting:block];\n}\n\n- (void)doTestRows:(const WCDB::MultiRowsValue&)expectedRows\n           andSQLs:(NSArray<NSString*>*)expectedSQLs\n       bySelecting:(WCDB::OptionalMultiRows (^)())block\n{\n    __block WCDB::MultiRowsValue selected;\n    [self doTestSQLs:expectedSQLs\n         inOperation:^BOOL {\n             auto values = block();\n             TestCaseAssertTrue(values.succeed());\n             selected = values.value();\n             return values.succeed();\n         }];\n    [self check:selected isEqualTo:expectedRows];\n}\n\n- (void)check:(const WCDB::MultiRowsValue&)selected isEqualTo:(const WCDB::MultiRowsValue&)expectedRows\n{\n    TestCaseAssertEqual(selected.size(), expectedRows.size());\n    for (int i = 0; i < selected.size(); i++) {\n        const WCDB::OneRowValue& selectedRow = selected[i];\n        const WCDB::OneRowValue& expectedRow = expectedRows[i];\n        TestCaseAssertEqual(selectedRow.size(), expectedRow.size());\n        for (int j = 0; j < selectedRow.size(); j++) {\n            TestCaseAssertEqual(selectedRow[j], expectedRow[j]);\n        }\n    }\n}\n\n- (WCDB::MultiRowsValue)getAllvalues\n{\n    auto values = self.database->getAllRowsFromStatement(WCDB::StatementSelect().select(self.resultColumns).from(self.tableName.UTF8String));\n    TestCaseAssertTrue(values.succeed());\n    return values.value();\n}\n\n@end\n"
  },
  {
    "path": "src/cpp/tests/common/CPPTestCase.h",
    "content": "//\n// Created by qiuwenchen on 2022/8/10.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"CPPBaseTestCase.h\"\n#import \"CPPCRUDTestCase.h\"\n#import \"CPPDatabaseTestCase.h\"\n#import \"CPPORMTestUtil.h\"\n#import \"CPPTableTestCase.h\"\n#import \"CPPTestCaseAssertion.h\"\n#import \"CPPTestCaseObject.h\"\n#import \"Dispatch.h\"\n#import \"NSObject+TestCase.h\"\n#import \"Random+CPPTestObject.h\"\n#import \"Random+WCDB.h\"\n#import \"Random.h\"\n#import \"Signpost.h\"\n#import \"TestCaseAssertion.h\"\n#import \"TestCaseLog.h\"\n#import \"TestCaseMacro.h\"\n#if TEST_WCDB_OBJC\n#import <WCDBOBjc/WCDBCpp.h>\n#elif TEST_WCDB_CPP\n#import <WCDBCpp/WCDBCpp.h>\n#else\n#import <WCDB/WCDBCpp.h>\n#endif\n"
  },
  {
    "path": "src/cpp/tests/common/CPPTestCaseAssertion.h",
    "content": "//\n// Created by qiuwenchen on 2022/8/13.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"TestCaseAssertion.h\"\n#import <Foundation/Foundation.h>\n#define TestCaseAssertCPPStringEqual(left, right)                   \\\n    {                                                               \\\n        NSString* _left = [NSString stringWithUTF8String:(left)];   \\\n        NSString* _right = [NSString stringWithUTF8String:(right)]; \\\n        TestCaseHintStringEqual(_left, _right);                     \\\n        TestCaseAssertTrue([_left isEqualToString:_right]);         \\\n    }\n"
  },
  {
    "path": "src/cpp/tests/common/CPPTestCaseObject.cpp",
    "content": "//\n// Created by qiuwenchen on 2022/9/7.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"CPPTestCaseObject.h\"\n\nCPPTestCaseObject::CPPTestCaseObject() = default;\n\nCPPTestCaseObject::CPPTestCaseObject(int id, const char *text)\n: identifier(id), content(text)\n{\n}\n\nCPPTestCaseObject::CPPTestCaseObject(int id, const std::string &text)\n: identifier(id), content(text)\n{\n}\n\nCPPTestCaseObject::CPPTestCaseObject(int id) : identifier(id)\n{\n}\n\nbool CPPTestCaseObject::operator==(const CPPTestCaseObject &other)\n{\n    return identifier == other.identifier && content.compare(other.content) == 0;\n}\n\nCPPTestCaseObject::~CPPTestCaseObject() = default;\n\nCPPTestCaseObject CPPTestCaseObject::autoIncrementObject(const std::string &text)\n{\n    CPPTestCaseObject obj = CPPTestCaseObject(0, text);\n    obj.isAutoIncrement = true;\n    return obj;\n}\n\nCPPTestCaseObject CPPTestCaseObject::autoIncrementObject(const char *text)\n{\n    CPPTestCaseObject obj = CPPTestCaseObject(0, text);\n    obj.isAutoIncrement = true;\n    return obj;\n}\n\nWCDB_CPP_ORM_IMPLEMENTATION_BEGIN(CPPTestCaseObject)\nWCDB_CPP_SYNTHESIZE(identifier)\nWCDB_CPP_SYNTHESIZE(content)\nWCDB_CPP_PRIMARY_ASC_AUTO_INCREMENT(identifier)\nWCDB_CPP_ORM_IMPLEMENTATION_END\n"
  },
  {
    "path": "src/cpp/tests/common/CPPTestCaseObject.h",
    "content": "//\n// Created by qiuwenchen on 2022/9/7.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#if TEST_WCDB_OBJC\n#import <WCDBOBjc/WCDBCpp.h>\n#elif TEST_WCDB_CPP\n#import <WCDBCpp/WCDBCpp.h>\n#else\n#import <WCDB/WCDBCpp.h>\n#endif\n\nclass CPPTestCaseObject {\npublic:\n    CPPTestCaseObject();\n    CPPTestCaseObject(int id, const char *text);\n    CPPTestCaseObject(int id, const std::string &text);\n    CPPTestCaseObject(int id);\n    ~CPPTestCaseObject();\n    static CPPTestCaseObject autoIncrementObject(const std::string &text);\n    static CPPTestCaseObject autoIncrementObject(const char *text);\n\n    bool operator==(const CPPTestCaseObject &other);\n\n    int identifier = 0;\n    std::string content;\n\n    WCDB_CPP_ORM_DECLARATION(CPPTestCaseObject)\n};\n"
  },
  {
    "path": "src/cpp/tests/common/Random+CPPTestObject.h",
    "content": "//\n// Created by qiuwenchen on 2022/8/13.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"CPPTestCaseObject.h\"\n#import \"Random.h\"\n#if TEST_WCDB_OBJC\n#import <WCDBOBjc/Value.hpp>\n#elif TEST_WCDB_CPP\n#import <WCDBCpp/Value.hpp>\n#else\n#import <WCDB/Value.hpp>\n#endif\n\n@interface Random (CPPTestObject)\n\n- (WCDB::MultiRowsValue)testCaseValuesWithCount:(NSUInteger)count startingFromIdentifier:(int64_t)identifier;\n\n- (WCDB::MultiRowsValue)autoIncrementTestCaseValuesWithCount:(NSUInteger)count;\n\n- (CPPTestCaseObject)testCaseObjectWithIdentifier:(int)identifier;\n\n- (CPPTestCaseObject)autoIncrementTestCaseObject;\n\n- (CPPTestCaseObject)autoIncrementTestCaseObjectWithIdentifier:(int)identifier;\n\n- (WCDB::ValueArray<CPPTestCaseObject>)testCaseObjectsWithCount:(NSUInteger)count startingFromIdentifier:(int)identifier;\n\n- (WCDB::ValueArray<CPPTestCaseObject>)autoIncrementTestCaseObjectsWithCount:(NSUInteger)count;\n\n@end\n"
  },
  {
    "path": "src/cpp/tests/common/Random+CPPTestObject.mm",
    "content": "//\n// Created by qiuwenchen on 2022/8/13.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"Random+CPPTestObject.h\"\n#import <Foundation/Foundation.h>\n\n@implementation Random (CPPTestObject)\n\n- (WCDB::MultiRowsValue)testCaseValuesWithCount:(NSUInteger)count startingFromIdentifier:(int64_t)identifier\n{\n    WCDB::MultiRowsValue result;\n    for (int i = 0; i < count; i++) {\n        WCDB::OneRowValue row;\n        row.emplace_back(i + identifier);\n        row.emplace_back(self.string.UTF8String);\n        result.push_back(row);\n    }\n    return result;\n}\n\n- (WCDB::MultiRowsValue)autoIncrementTestCaseValuesWithCount:(NSUInteger)count\n{\n    WCDB::MultiRowsValue result;\n    for (int i = 0; i < count; i++) {\n        WCDB::OneRowValue row;\n        row.emplace_back(i);\n        row.emplace_back(self.string.UTF8String);\n        result.push_back(row);\n    }\n    return result;\n}\n\n- (CPPTestCaseObject)testCaseObjectWithIdentifier:(int)identifier\n{\n    return CPPTestCaseObject(identifier, self.string.UTF8String);\n}\n\n- (CPPTestCaseObject)autoIncrementTestCaseObject\n{\n    return [self autoIncrementTestCaseObjectWithIdentifier:0];\n}\n\n- (CPPTestCaseObject)autoIncrementTestCaseObjectWithIdentifier:(int)identifier\n{\n    CPPTestCaseObject obj = CPPTestCaseObject::autoIncrementObject(self.string.UTF8String);\n    obj.identifier = identifier;\n    obj.isAutoIncrement = true;\n    return obj;\n}\n\n- (WCDB::ValueArray<CPPTestCaseObject>)testCaseObjectsWithCount:(NSUInteger)count startingFromIdentifier:(int)identifier\n{\n    WCDB::ValueArray<CPPTestCaseObject> result;\n    for (NSUInteger i = identifier; i < identifier + count; ++i) {\n        result.push_back([self testCaseObjectWithIdentifier:(int) i]);\n    }\n    return result;\n}\n\n- (WCDB::ValueArray<CPPTestCaseObject>)autoIncrementTestCaseObjectsWithCount:(NSUInteger)count\n{\n    WCDB::ValueArray<CPPTestCaseObject> result;\n    for (NSUInteger i = 0; i < count; ++i) {\n        result.push_back([self autoIncrementTestCaseObject]);\n    }\n    return result;\n}\n\n@end\n"
  },
  {
    "path": "src/cpp/tests/fts/CPPFTS3Object.h",
    "content": "//\n// Created by qiuwenchen on 2022/10/29.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include <WCDB/WCDBCpp.h>\n\nclass CPPFTS3Object {\npublic:\n    CPPFTS3Object();\n    CPPFTS3Object(WCDB::UnsafeStringView cont, WCDB::UnsafeStringView ext);\n    WCDB::StringView content;\n    WCDB::StringView extension;\n    bool operator==(const CPPFTS3Object& other);\n    WCDB_CPP_ORM_DECLARATION(CPPFTS3Object);\n};\n\nclass CPPFTS3SymbolObject {\npublic:\n    CPPFTS3SymbolObject();\n    WCDB::StringView content;\n    bool operator==(const CPPFTS3SymbolObject& other);\n    WCDB_CPP_ORM_DECLARATION(CPPFTS3SymbolObject);\n};\n"
  },
  {
    "path": "src/cpp/tests/fts/CPPFTS3Object.mm",
    "content": "//\n// Created by qiuwenchen on 2022/10/29.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"CPPFTS3Object.h\"\n\nCPPFTS3Object::CPPFTS3Object() = default;\n\nCPPFTS3Object::CPPFTS3Object(WCDB::UnsafeStringView cont, WCDB::UnsafeStringView ext)\n: content(cont)\n, extension(ext)\n{\n}\n\nWCDB_CPP_ORM_IMPLEMENTATION_BEGIN(CPPFTS3Object)\nWCDB_CPP_SYNTHESIZE(content)\nWCDB_CPP_SYNTHESIZE(extension)\n\nWCDB_CPP_VIRTUAL_TABLE_MODULE(WCDB::Module::FTS3)\nWCDB_CPP_VIRTUAL_TABLE_TOKENIZE_WITH_PARAMETERS(WCDB::BuiltinTokenizer::OneOrBinary, WCDB::BuiltinTokenizer::Parameter::SimplifyChinese)\nWCDB_CPP_ORM_IMPLEMENTATION_END\n\nbool CPPFTS3Object::operator==(const CPPFTS3Object &other)\n{\n    return content.compare(other.content) == 0 && extension.compare(other.extension) == 0;\n}\n\nCPPFTS3SymbolObject::CPPFTS3SymbolObject() = default;\n\nWCDB_CPP_ORM_IMPLEMENTATION_BEGIN(CPPFTS3SymbolObject)\n\nWCDB_CPP_SYNTHESIZE(content)\nWCDB_CPP_VIRTUAL_TABLE_MODULE(WCDB::Module::FTS3)\nWCDB_CPP_VIRTUAL_TABLE_TOKENIZE_WITH_PARAMETERS(WCDB::BuiltinTokenizer::OneOrBinary, WCDB::BuiltinTokenizer::Parameter::NeedSymbol)\n\nWCDB_CPP_ORM_IMPLEMENTATION_END\n\nbool CPPFTS3SymbolObject::operator==(const CPPFTS3SymbolObject &other)\n{\n    return content.compare(other.content) == 0;\n}\n"
  },
  {
    "path": "src/cpp/tests/fts/CPPFTS3Tests.mm",
    "content": "//\n// Created by qiuwenchen on 2022/10/29.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"CPPFTS3Object.h\"\n#import \"CPPTestCase.h\"\n#import <Foundation/Foundation.h>\n\n@interface CPPFTS3Tests : CPPTableTestCase {\n    std::shared_ptr<WCDB::Table<CPPFTS3Object>> m_ftsTable;\n}\n\n@property (nonatomic, readonly) WCDB::Table<CPPFTS3Object> &ftsTable;\n\n@end\n\n@implementation CPPFTS3Tests\n\n- (void)setUp\n{\n    [super setUp];\n    self.expectMode = DatabaseTestCaseExpectFirstFewSQLs;\n    self.database->addTokenizer(WCDB::BuiltinTokenizer::OneOrBinary);\n    WCDB::Database::configSymbolDetector([](WCDB::Database::UnicodeChar theChar) {\n        if (theChar < 0xC0) {\n            if (!(theChar >= 0x30 && theChar <= 0x39) && !((theChar >= 0x41 && theChar <= 0x5a) || (theChar >= 0x61 && theChar <= 0x7a))) {\n                return true;\n            }\n        }\n        return false;\n    });\n    WCDB::Database::configTraditionalChineseConverter([](const WCDB::UnsafeStringView &token) {\n        if (token.compare(\"們\") == 0) {\n            return WCDB::StringView(\"们\");\n        } else if (token.compare(\"員\") == 0) {\n            return WCDB::StringView(\"员\");\n        }\n        return WCDB::StringView(token);\n    });\n    TestCaseAssertTrue(self.database->createVirtualTable<CPPFTS3Object>(self.tableName.UTF8String));\n    TestCaseAssertTrue(self.database->insertObjects<CPPFTS3Object>(CPPFTS3Object(\"dummy content\", \"dummy extension\"), self.tableName.UTF8String));\n}\n\n- (WCDB::Table<CPPFTS3Object> &)ftsTable\n{\n    if (!m_ftsTable) {\n        m_ftsTable = std::make_shared<WCDB::Table<CPPFTS3Object>>(self.database->getTable<CPPFTS3Object>(self.tableName.UTF8String));\n    }\n    return *m_ftsTable.get();\n}\n\n- (void)test_chinese\n{\n    CPPFTS3Object object(\"苹果树\", \"\");\n    TestCaseAssertTrue(self.ftsTable.insertObjects(object));\n    [self doTestRows:{ CPPOneRowValueExtract(object) }\n              andSQL:@\"SELECT content, extension FROM testTable WHERE content MATCH '苹' ORDER BY rowid ASC\"\n         bySelecting:^WCDB::OptionalMultiRows {\n             return CPPMultiRowValueExtract(self.ftsTable.getAllObjects(WCDB_FIELD(CPPFTS3Object::content).match(\"苹\")).value());\n         }];\n    [self doTestRows:{ CPPOneRowValueExtract(object) }\n              andSQL:@\"SELECT content, extension FROM testTable WHERE content MATCH '苹果' ORDER BY rowid ASC\"\n         bySelecting:^WCDB::OptionalMultiRows {\n             return CPPMultiRowValueExtract(self.ftsTable.getAllObjects(WCDB_FIELD(CPPFTS3Object::content).match(\"苹果\")).value());\n         }];\n    [self doTestRows:{ CPPOneRowValueExtract(object) }\n              andSQL:@\"SELECT content, extension FROM testTable WHERE content MATCH '苹果树' ORDER BY rowid ASC\"\n         bySelecting:^WCDB::OptionalMultiRows {\n             return CPPMultiRowValueExtract(self.ftsTable.getAllObjects(WCDB_FIELD(CPPFTS3Object::content).match(\"苹果树\")).value());\n         }];\n    [self doTestRows:{ CPPOneRowValueExtract(object) }\n              andSQL:@\"SELECT content, extension FROM testTable WHERE content MATCH '果树' ORDER BY rowid ASC\"\n         bySelecting:^WCDB::OptionalMultiRows {\n             return CPPMultiRowValueExtract(self.ftsTable.getAllObjects(WCDB_FIELD(CPPFTS3Object::content).match(\"果树\")).value());\n         }];\n    [self doTestRows:{ CPPOneRowValueExtract(object) }\n              andSQL:@\"SELECT content, extension FROM testTable WHERE content MATCH '树' ORDER BY rowid ASC\"\n         bySelecting:^WCDB::OptionalMultiRows {\n             return CPPMultiRowValueExtract(self.ftsTable.getAllObjects(WCDB_FIELD(CPPFTS3Object::content).match(\"树\")).value());\n         }];\n}\n\n- (void)test_traditional_chinese\n{\n    CPPFTS3Object object(\"我們是程序員\", \"\");\n    TestCaseAssertTrue(self.ftsTable.insertObjects(object));\n    [self doTestRows:{ CPPOneRowValueExtract(object) }\n              andSQL:@\"SELECT content, extension FROM testTable WHERE content MATCH '我們是程序員' ORDER BY rowid ASC\"\n         bySelecting:^WCDB::OptionalMultiRows {\n             return CPPMultiRowValueExtract(self.ftsTable.getAllObjects(WCDB_FIELD(CPPFTS3Object::content).match(\"我們是程序員\")).value());\n         }];\n    [self doTestRows:{ CPPOneRowValueExtract(object) }\n              andSQL:@\"SELECT content, extension FROM testTable WHERE content MATCH '我们是程序员' ORDER BY rowid ASC\"\n         bySelecting:^WCDB::OptionalMultiRows {\n             return CPPMultiRowValueExtract(self.ftsTable.getAllObjects(WCDB_FIELD(CPPFTS3Object::content).match(\"我们是程序员\")).value());\n         }];\n}\n\n- (void)test_english\n{\n    CPPFTS3Object object(\"WCDB is a cross-platform database framework developed by WeChat.\", \"\");\n    TestCaseAssertTrue(self.ftsTable.insertObjects(object));\n\n    [self doTestRows:{ CPPOneRowValueExtract(object) }\n              andSQL:@\"SELECT content, extension FROM testTable WHERE content MATCH 'WCDB' ORDER BY rowid ASC\"\n         bySelecting:^WCDB::OptionalMultiRows {\n             return CPPMultiRowValueExtract(self.ftsTable.getAllObjects(WCDB_FIELD(CPPFTS3Object::content).match(\"WCDB\")).value());\n         }];\n    [self doTestRows:{ CPPOneRowValueExtract(object) }\n              andSQL:@\"SELECT content, extension FROM testTable WHERE content MATCH 'WeChat' ORDER BY rowid ASC\"\n         bySelecting:^WCDB::OptionalMultiRows {\n             return CPPMultiRowValueExtract(self.ftsTable.getAllObjects(WCDB_FIELD(CPPFTS3Object::content).match(\"WeChat\")).value());\n         }];\n\n    // case insensitive\n    [self doTestRows:{ CPPOneRowValueExtract(object) }\n              andSQL:@\"SELECT content, extension FROM testTable WHERE content MATCH 'DATABASE' ORDER BY rowid ASC\"\n         bySelecting:^WCDB::OptionalMultiRows {\n             return CPPMultiRowValueExtract(self.ftsTable.getAllObjects(WCDB_FIELD(CPPFTS3Object::content).match(\"DATABASE\")).value());\n         }];\n\n    // stemming\n    [self doTestRows:{ CPPOneRowValueExtract(object) }\n              andSQL:@\"SELECT content, extension FROM testTable WHERE content MATCH 'developer' ORDER BY rowid ASC\"\n         bySelecting:^WCDB::OptionalMultiRows {\n             return CPPMultiRowValueExtract(self.ftsTable.getAllObjects(WCDB_FIELD(CPPFTS3Object::content).match(\"developer\")).value());\n         }];\n\n    // prefix\n    [self doTestRows:{ CPPOneRowValueExtract(object) }\n              andSQL:@\"SELECT content, extension FROM testTable WHERE content MATCH 'plat*' ORDER BY rowid ASC\"\n         bySelecting:^WCDB::OptionalMultiRows {\n             return CPPMultiRowValueExtract(self.ftsTable.getAllObjects(WCDB_FIELD(CPPFTS3Object::content).match(\"plat*\")).value());\n         }];\n\n    // phrase\n    [self doTestRows:{ CPPOneRowValueExtract(object) }\n              andSQL:@\"SELECT content, extension FROM testTable WHERE content MATCH 'dat* fram*' ORDER BY rowid ASC\"\n         bySelecting:^WCDB::OptionalMultiRows {\n             return CPPMultiRowValueExtract(self.ftsTable.getAllObjects(WCDB_FIELD(CPPFTS3Object::content).match(\"dat* fram*\")).value());\n         }];\n\n    // bad case\n    [self doTestRows:{}\n              andSQL:@\"SELECT content, extension FROM testTable WHERE content MATCH 'Hello' ORDER BY rowid ASC\"\n         bySelecting:^WCDB::OptionalMultiRows {\n             return CPPMultiRowValueExtract(self.ftsTable.getAllObjects(WCDB_FIELD(CPPFTS3Object::content).match(\"Hello\")).value());\n         }];\n}\n\n- (void)test_number\n{\n    CPPFTS3Object object(\"123 456 789\", \"\");\n    TestCaseAssertTrue(self.ftsTable.insertObjects(object));\n\n    [self doTestRows:{ CPPOneRowValueExtract(object) }\n              andSQL:@\"SELECT content, extension FROM testTable WHERE content MATCH '123' ORDER BY rowid ASC\"\n         bySelecting:^WCDB::OptionalMultiRows {\n             return CPPMultiRowValueExtract(self.ftsTable.getAllObjects(WCDB_FIELD(CPPFTS3Object::content).match(\"123\")).value());\n         }];\n    [self doTestRows:{ CPPOneRowValueExtract(object) }\n              andSQL:@\"SELECT content, extension FROM testTable WHERE content MATCH '456' ORDER BY rowid ASC\"\n         bySelecting:^WCDB::OptionalMultiRows {\n             return CPPMultiRowValueExtract(self.ftsTable.getAllObjects(WCDB_FIELD(CPPFTS3Object::content).match(\"456\")).value());\n         }];\n    [self doTestRows:{ CPPOneRowValueExtract(object) }\n              andSQL:@\"SELECT content, extension FROM testTable WHERE content MATCH '789' ORDER BY rowid ASC\"\n         bySelecting:^WCDB::OptionalMultiRows {\n             return CPPMultiRowValueExtract(self.ftsTable.getAllObjects(WCDB_FIELD(CPPFTS3Object::content).match(\"789\")).value());\n         }];\n\n    // bad case\n    [self doTestRows:{}\n              andSQL:@\"SELECT content, extension FROM testTable WHERE content MATCH '567' ORDER BY rowid ASC\"\n         bySelecting:^WCDB::OptionalMultiRows {\n             return CPPMultiRowValueExtract(self.ftsTable.getAllObjects(WCDB_FIELD(CPPFTS3Object::content).match(\"567\")).value());\n         }];\n}\n\n- (void)test_mixed\n{\n    CPPFTS3Object object(\"中文English日本語123\", \"\");\n    TestCaseAssertTrue(self.ftsTable.insertObjects(object));\n\n    [self doTestRows:{ CPPOneRowValueExtract(object) }\n              andSQL:@\"SELECT content, extension FROM testTable WHERE content MATCH '中' ORDER BY rowid ASC\"\n         bySelecting:^WCDB::OptionalMultiRows {\n             return CPPMultiRowValueExtract(self.ftsTable.getAllObjects(WCDB_FIELD(CPPFTS3Object::content).match(\"中\")).value());\n         }];\n    [self doTestRows:{ CPPOneRowValueExtract(object) }\n              andSQL:@\"SELECT content, extension FROM testTable WHERE content MATCH 'English' ORDER BY rowid ASC\"\n         bySelecting:^WCDB::OptionalMultiRows {\n             return CPPMultiRowValueExtract(self.ftsTable.getAllObjects(WCDB_FIELD(CPPFTS3Object::content).match(\"English\")).value());\n         }];\n    [self doTestRows:{ CPPOneRowValueExtract(object) }\n              andSQL:@\"SELECT content, extension FROM testTable WHERE content MATCH '語' ORDER BY rowid ASC\"\n         bySelecting:^WCDB::OptionalMultiRows {\n             return CPPMultiRowValueExtract(self.ftsTable.getAllObjects(WCDB_FIELD(CPPFTS3Object::content).match(\"語\")).value());\n         }];\n    [self doTestRows:{ CPPOneRowValueExtract(object) }\n              andSQL:@\"SELECT content, extension FROM testTable WHERE content MATCH '123' ORDER BY rowid ASC\"\n         bySelecting:^WCDB::OptionalMultiRows {\n             return CPPMultiRowValueExtract(self.ftsTable.getAllObjects(WCDB_FIELD(CPPFTS3Object::content).match(\"123\")).value());\n         }];\n}\n\n- (void)test_column_match\n{\n    CPPFTS3Object content(\"error_prone\", \"\");\n    TestCaseAssertTrue(self.ftsTable.insertObjects(content));\n\n    CPPFTS3Object extension(\"\", \"error_prone\");\n    TestCaseAssertTrue(self.ftsTable.insertObjects(extension));\n\n    [self doTestRows:{ CPPOneRowValueExtract(content) }\n              andSQL:@\"SELECT content, extension FROM testTable WHERE content MATCH 'error_prone' ORDER BY rowid ASC\"\n         bySelecting:^WCDB::OptionalMultiRows {\n             return CPPMultiRowValueExtract(self.ftsTable.getAllObjects(WCDB_FIELD(CPPFTS3Object::content).match(\"error_prone\")).value());\n         }];\n    [self doTestRows:{ CPPOneRowValueExtract(extension) }\n              andSQL:@\"SELECT content, extension FROM testTable WHERE extension MATCH 'error_prone' ORDER BY rowid ASC\"\n         bySelecting:^WCDB::OptionalMultiRows {\n             return CPPMultiRowValueExtract(self.ftsTable.getAllObjects(WCDB_FIELD(CPPFTS3Object::extension).match(\"error_prone\")).value());\n         }];\n    [self doTestRows:{ CPPOneRowValueExtract(content), CPPOneRowValueExtract(extension) }\n              andSQL:@\"SELECT content, extension FROM testTable WHERE testTable MATCH 'error_prone' ORDER BY rowid ASC\"\n         bySelecting:^WCDB::OptionalMultiRows {\n             return CPPMultiRowValueExtract(self.ftsTable.getAllObjects(WCDB::Column(self.tableName.UTF8String).match(\"error_prone\")).value());\n         }];\n    [self doTestRows:{ CPPOneRowValueExtract(content) }\n              andSQL:@\"SELECT content, extension FROM testTable WHERE testTable MATCH 'content: error_prone' ORDER BY rowid ASC\"\n         bySelecting:^WCDB::OptionalMultiRows {\n             return CPPMultiRowValueExtract(self.ftsTable.getAllObjects(WCDB::Column(self.tableName.UTF8String).match(\"content: error_prone\")).value());\n         }];\n    [self doTestRows:{ CPPOneRowValueExtract(extension) }\n              andSQL:@\"SELECT content, extension FROM testTable WHERE testTable MATCH 'extension: error_prone' ORDER BY rowid ASC\"\n         bySelecting:^WCDB::OptionalMultiRows {\n             return CPPMultiRowValueExtract(self.ftsTable.getAllObjects(WCDB::Column(self.tableName.UTF8String).match(\"extension: error_prone\")).value());\n         }];\n}\n\n- (void)test_near_query\n{\n    CPPFTS3Object objectWithOneGaps(\"Cowherd one WeaverGirl\", \"\");\n    TestCaseAssertTrue(self.ftsTable.insertObjects(objectWithOneGaps));\n\n    CPPFTS3Object objectWithTenGaps(\"Cowherd one two three four five six seven eight nine ten WeaverGirl\", \"\");\n    TestCaseAssertTrue(self.ftsTable.insertObjects(objectWithTenGaps));\n\n    CPPFTS3Object objectWithEleventGaps(\"Cowherd one two three four five six seven eight nine ten eleven WeaverGirl\", \"\");\n    TestCaseAssertTrue(self.ftsTable.insertObjects(objectWithEleventGaps));\n\n    [self doTestRows:{ CPPOneRowValueExtract(objectWithOneGaps) }\n              andSQL:@\"SELECT content, extension FROM testTable WHERE content MATCH 'Cowherd NEAR/1 WeaverGirl' ORDER BY rowid ASC\"\n         bySelecting:^WCDB::OptionalMultiRows {\n             return CPPMultiRowValueExtract(self.ftsTable.getAllObjects(WCDB_FIELD(CPPFTS3Object::content).match(\"Cowherd NEAR/1 WeaverGirl\")).value());\n         }];\n    [self doTestRows:{ CPPOneRowValueExtract(objectWithOneGaps), CPPOneRowValueExtract(objectWithTenGaps) }\n              andSQL:@\"SELECT content, extension FROM testTable WHERE content MATCH 'Cowherd NEAR/10 WeaverGirl' ORDER BY rowid ASC\"\n         bySelecting:^WCDB::OptionalMultiRows {\n             return CPPMultiRowValueExtract(self.ftsTable.getAllObjects(WCDB_FIELD(CPPFTS3Object::content).match(\"Cowherd NEAR/10 WeaverGirl\")).value());\n         }];\n    [self doTestRows:{ CPPOneRowValueExtract(objectWithOneGaps), CPPOneRowValueExtract(objectWithTenGaps), CPPOneRowValueExtract(objectWithEleventGaps) }\n              andSQL:@\"SELECT content, extension FROM testTable WHERE content MATCH 'Cowherd NEAR/11 WeaverGirl' ORDER BY rowid ASC\"\n         bySelecting:^WCDB::OptionalMultiRows {\n             return CPPMultiRowValueExtract(self.ftsTable.getAllObjects(WCDB_FIELD(CPPFTS3Object::content).match(\"Cowherd NEAR/11 WeaverGirl\")).value());\n         }];\n\n    // default behaviours\n    [self doTestRows:{ CPPOneRowValueExtract(objectWithOneGaps), CPPOneRowValueExtract(objectWithTenGaps) }\n              andSQL:@\"SELECT content, extension FROM testTable WHERE content MATCH 'Cowherd NEAR WeaverGirl' ORDER BY rowid ASC\"\n         bySelecting:^WCDB::OptionalMultiRows {\n             return CPPMultiRowValueExtract(self.ftsTable.getAllObjects(WCDB_FIELD(CPPFTS3Object::content).match(\"Cowherd NEAR WeaverGirl\")).value());\n         }];\n}\n\n- (void)test_operator\n{\n    CPPFTS3Object ab(\"a b\", \"\");\n    TestCaseAssertTrue(self.ftsTable.insertObjects(ab));\n\n    CPPFTS3Object bc(\"b c\", \"\");\n    TestCaseAssertTrue(self.ftsTable.insertObjects(bc));\n\n    CPPFTS3Object cd(\"c d\", \"\");\n    TestCaseAssertTrue(self.ftsTable.insertObjects(cd));\n\n    [self doTestRows:{ CPPOneRowValueExtract(bc) }\n              andSQL:@\"SELECT content, extension FROM testTable WHERE content MATCH 'b AND c' ORDER BY rowid ASC\"\n         bySelecting:^WCDB::OptionalMultiRows {\n             return CPPMultiRowValueExtract(self.ftsTable.getAllObjects(WCDB_FIELD(CPPFTS3Object::content).match(\"b AND c\")).value());\n         }];\n    [self doTestRows:{ CPPOneRowValueExtract(ab), CPPOneRowValueExtract(bc), CPPOneRowValueExtract(cd) }\n              andSQL:@\"SELECT content, extension FROM testTable WHERE content MATCH 'b OR c' ORDER BY rowid ASC\"\n         bySelecting:^WCDB::OptionalMultiRows {\n             return CPPMultiRowValueExtract(self.ftsTable.getAllObjects(WCDB_FIELD(CPPFTS3Object::content).match(\"b OR c\")).value());\n         }];\n    [self doTestRows:{ CPPOneRowValueExtract(ab) }\n              andSQL:@\"SELECT content, extension FROM testTable WHERE content MATCH 'b NOT c' ORDER BY rowid ASC\"\n         bySelecting:^WCDB::OptionalMultiRows {\n             return CPPMultiRowValueExtract(self.ftsTable.getAllObjects(WCDB_FIELD(CPPFTS3Object::content).match(\"b NOT c\")).value());\n         }];\n}\n\n- (void)test_offsets\n{\n    CPPFTS3Object object(\"one two three four\", \"five six seven eight nine ten\");\n    TestCaseAssertTrue(self.ftsTable.insertObjects(object));\n\n    // The return value of [offsets] is grouped by every four numbers.\n    // 1. The serial number of matched column in the table\n    // 2. The serial number of matching term in the query\n    // 3. The byte offset of matched term\n    // 4. The byte length of matched term\n    // In conclusion, every group show that the word at offset [3.] length [4.] in the column [1.] is matching the query [2.].\n\n    // Note that offsets interface is not recommended since the column order may be undefined due to ORM.\n\n    [self doTestValue:\n          \"0 1 4 3 \"  // The word at offset 4 length 3 in the column [content] is matching the query [t*], which is \"two\".\n          \"0 1 8 5 \"  // The word at offset 8 length 5 in the column [content] is matching the query [t*], which is \"three\".\n          \"0 0 14 4 \" // The word at offset 14 length 4 in the column [content] is matching the query [f*], which is \"four\".\n          \"1 0 0 4 \"  // The word at offset 0 length 4 in the column [extension] is matching the query [f*], which is \"five\".\n          \"1 1 26 3\"  // The word at offset 26 length 3 in the column [extension] is matching the query [t*], which is \"ten\".\n               andSQL:@\"SELECT offsets(testTable) FROM testTable WHERE testTable MATCH 'f* t*' ORDER BY rowid ASC\"\n          bySelecting:^WCDB::OptionalValue {\n              WCDB::Column tableColumn(self.tableName.UTF8String);\n              return self.database->getValueFromStatement(WCDB::StatementSelect().select(tableColumn.offsets()).from(self.tableName.UTF8String).where(tableColumn.match(\"f* t*\")).order(WCDB::OrderingTerm::ascendingRowid()));\n          }];\n}\n\n//- (void)test_snippet\n//{\n//    CPPFTS3Object easyToUse(\"Easy-to-use\", \"Through WCDB, you can get objects from database in one line code.\");\n//    TestCaseAssertTrue(self.ftsTable.insertObjects(easyToUse));\n//\n//    CPPFTS3Object efficient(\"Efficient\", \"Through the framework layer and sqlcipher source optimization, WCDB have more efficient performance.\");\n//    TestCaseAssertTrue(self.ftsTable.insertObjects(efficient));\n//\n//    CPPFTS3Object complete(\"Complete\", \"Encryption Support, Corruption recovery, Anti-injection.\");\n//    TestCaseAssertTrue(self.ftsTable.insertObjects(complete));\n//\n//    [self doTestColumn:{ \"dummy /* extension */\"\n//                         \"...WCDB have more /* efficient */ performance.\",\n//                         \"/* Encryption */ Support, Corruption recovery...\" }\n//                andSQL:@\"SELECT snippet(testTable, '/* ', ' */', '...', -1, 5) FROM testTable WHERE extension MATCH 'e*' ORDER BY rowid ASC\"\n//           bySelecting:^WCDB::OptionalOneColumn {\n//               const char *startMatchText = \"/* \";\n//               const char *endMatchText = \" */\";\n//               const char *ellipses = \"...\";\n//               int columnNumber = -1;\n//               int approximateNumberOfTokens = 5;\n//               return self.database->getOneColumnFromStatement(WCDB::StatementSelect().select(WCDB::Column(self.tableName.UTF8String).snippet(startMatchText, endMatchText, ellipses, columnNumber, approximateNumberOfTokens)).from(self.tableName.UTF8String).where(WCDB_FIELD(CPPFTS3Object::extension).match(\"e*\")).order(WCDB::OrderingTerm::ascendingRowid()));\n//           }];\n//}\n\n@end\n\n@interface CPPFTS3SymbolTests : CPPTableTestCase\n\n@end\n\n@implementation CPPFTS3SymbolTests\n\n- (void)setUp\n{\n    [super setUp];\n    self.expectMode = DatabaseTestCaseExpectFirstFewSQLs;\n    self.database->addTokenizer(WCDB::BuiltinTokenizer::OneOrBinary);\n    WCDB::Database::configSymbolDetector([](WCDB::Database::UnicodeChar theChar) {\n        if (theChar < 0xC0) {\n            if (!(theChar >= 0x30 && theChar <= 0x39) && !((theChar >= 0x41 && theChar <= 0x5a) || (theChar >= 0x61 && theChar <= 0x7a))) {\n                return true;\n            }\n        }\n        return false;\n    });\n    TestCaseAssertTrue(self.database->createVirtualTable<CPPFTS3SymbolObject>(self.tableName.UTF8String));\n    CPPFTS3SymbolObject object;\n    object.content = \"!@#$%^&*(()))_+\";\n    TestCaseAssertTrue(self.database->insertObjects<CPPFTS3SymbolObject>(object, self.tableName.UTF8String));\n}\n\n- (void)test_symbol\n{\n    CPPFTS3SymbolObject content;\n    content.content = \"#￥%…'  '！@…&*\";\n    TestCaseAssertTrue(self.database->insertObjects<CPPFTS3SymbolObject>(content, self.tableName.UTF8String));\n\n    content.content = \"！@…&*'  '\\\"#￥%…\";\n    TestCaseAssertTrue(self.database->insertObjects<CPPFTS3SymbolObject>(content, self.tableName.UTF8String));\n\n    NSArray *querys = @[ @\"！@…&*'  '\\\"\\\"#￥%…\", @\"！@…&*'  '\\\"\\\"\" ];\n    for (NSString *query in querys) {\n        [self doTestRows:{ CPPOneRowValueExtract(content) }\n                  andSQL:[NSString stringWithFormat:@\"SELECT content FROM testTable WHERE content MATCH '%@' ORDER BY rowid ASC\", [query stringByReplacingOccurrencesOfString:@\"'\" withString:@\"''\"]]\n             bySelecting:^WCDB::OptionalMultiRows {\n                 return CPPMultiRowValueExtract(self.database->getAllObjects<CPPFTS3SymbolObject>(self.tableName.UTF8String, WCDB_FIELD(CPPFTS3SymbolObject::content).match(query.UTF8String)).value());\n             }];\n    }\n\n    content.content = \"abc*123_@567\";\n    TestCaseAssertTrue(self.database->insertObjects<CPPFTS3SymbolObject>(content, self.tableName.UTF8String));\n\n    content.content = \"abc@123*def_567\";\n    TestCaseAssertTrue(self.database->insertObjects<CPPFTS3SymbolObject>(content, self.tableName.UTF8String));\n\n    querys = @[ @\"abc@123*def_567\", @\"abc@123*def\" ];\n    for (NSString *query in querys) {\n        [self doTestRows:{ CPPOneRowValueExtract(content) }\n                  andSQL:[NSString stringWithFormat:@\"SELECT content FROM testTable WHERE content MATCH '%@' ORDER BY rowid ASC\", query]\n             bySelecting:^WCDB::OptionalMultiRows {\n                 return CPPMultiRowValueExtract(self.database->getAllObjects<CPPFTS3SymbolObject>(self.tableName.UTF8String, WCDB_FIELD(CPPFTS3SymbolObject::content).match(query.UTF8String)).value());\n             }];\n    }\n}\n\n@end\n"
  },
  {
    "path": "src/cpp/tests/fts/CPPFTS5Object.h",
    "content": "//\n// Created by qiuwenchen on 2022/10/30.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include <WCDB/WCDBCpp.h>\n\nclass CPPFTS5Object {\npublic:\n    CPPFTS5Object();\n    CPPFTS5Object(WCDB::UnsafeStringView cont, WCDB::UnsafeStringView ext);\n    WCDB::StringView content;\n    WCDB::StringView extension;\n    bool operator==(const CPPFTS5Object& other);\n    WCDB_CPP_ORM_DECLARATION(CPPFTS5Object);\n};\n\nclass CPPFTS5PinyinObject {\npublic:\n    CPPFTS5PinyinObject();\n    WCDB::StringView content;\n    bool operator==(const CPPFTS5PinyinObject& other);\n    WCDB_CPP_ORM_DECLARATION(CPPFTS5PinyinObject);\n};\n\nclass CPPFTS5SymbolObject {\npublic:\n    CPPFTS5SymbolObject();\n    WCDB::StringView content;\n    bool operator==(const CPPFTS5SymbolObject& other);\n    WCDB_CPP_ORM_DECLARATION(CPPFTS5SymbolObject);\n};\n"
  },
  {
    "path": "src/cpp/tests/fts/CPPFTS5Object.mm",
    "content": "//\n// Created by qiuwenchen on 2022/10/30.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"CPPFTS5Object.h\"\n\nCPPFTS5Object::CPPFTS5Object() = default;\n\nCPPFTS5Object::CPPFTS5Object(WCDB::UnsafeStringView cont, WCDB::UnsafeStringView ext)\n: content(cont)\n, extension(ext)\n{\n}\n\nWCDB_CPP_ORM_IMPLEMENTATION_BEGIN(CPPFTS5Object)\nWCDB_CPP_SYNTHESIZE(content)\nWCDB_CPP_SYNTHESIZE(extension)\n\nWCDB_CPP_VIRTUAL_TABLE_MODULE(WCDB::Module::FTS5)\nWCDB_CPP_VIRTUAL_TABLE_TOKENIZE_WITH_PARAMETERS(WCDB::BuiltinTokenizer::Verbatim, WCDB::BuiltinTokenizer::Parameter::SimplifyChinese)\nWCDB_CPP_ORM_IMPLEMENTATION_END\n\nbool CPPFTS5Object::operator==(const CPPFTS5Object &other)\n{\n    return content.compare(other.content) == 0 && extension.compare(other.extension) == 0;\n}\n\nCPPFTS5PinyinObject::CPPFTS5PinyinObject() = default;\n\nWCDB_CPP_ORM_IMPLEMENTATION_BEGIN(CPPFTS5PinyinObject)\n\nWCDB_CPP_SYNTHESIZE(content)\nWCDB_CPP_VIRTUAL_TABLE_MODULE(WCDB::Module::FTS5)\nWCDB_CPP_VIRTUAL_TABLE_TOKENIZE(WCDB::BuiltinTokenizer::Pinyin)\n\nWCDB_CPP_ORM_IMPLEMENTATION_END\n\nbool CPPFTS5PinyinObject::operator==(const CPPFTS5PinyinObject &other)\n{\n    return content.compare(other.content) == 0;\n}\n\nCPPFTS5SymbolObject::CPPFTS5SymbolObject() = default;\n\nWCDB_CPP_ORM_IMPLEMENTATION_BEGIN(CPPFTS5SymbolObject)\n\nWCDB_CPP_SYNTHESIZE(content)\nWCDB_CPP_VIRTUAL_TABLE_MODULE(WCDB::Module::FTS5)\nWCDB_CPP_VIRTUAL_TABLE_TOKENIZE_WITH_PARAMETERS(WCDB::BuiltinTokenizer::Verbatim, WCDB::BuiltinTokenizer::Parameter::NeedSymbol)\n\nWCDB_CPP_ORM_IMPLEMENTATION_END\n\nbool CPPFTS5SymbolObject::operator==(const CPPFTS5SymbolObject &other)\n{\n    return content.compare(other.content) == 0;\n}\n"
  },
  {
    "path": "src/cpp/tests/fts/CPPFTS5Tests.mm",
    "content": "//\n// Created by qiuwenchen on 2022/10/30.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"CPPFTS5Object.h\"\n#import \"CPPTestCase.h\"\n#import <Foundation/Foundation.h>\n\n@interface CPPFTS5Tests : CPPTableTestCase {\n    std::shared_ptr<WCDB::Table<CPPFTS5Object>> m_ftsTable;\n}\n\n@property (nonatomic, readonly) WCDB::Table<CPPFTS5Object> &ftsTable;\n\n@end\n\n@implementation CPPFTS5Tests\n\n- (void)setUp\n{\n    [super setUp];\n    self.expectMode = DatabaseTestCaseExpectFirstFewSQLs;\n    self.database->addTokenizer(WCDB::BuiltinTokenizer::Verbatim);\n    WCDB::Database::configSymbolDetector([](WCDB::Database::UnicodeChar theChar) {\n        if (theChar < 0xC0) {\n            if (!(theChar >= 0x30 && theChar <= 0x39) && !((theChar >= 0x41 && theChar <= 0x5a) || (theChar >= 0x61 && theChar <= 0x7a))) {\n                return true;\n            }\n        }\n        return false;\n    });\n    WCDB::Database::configTraditionalChineseConverter([](const WCDB::UnsafeStringView &token) {\n        if (token.compare(\"們\") == 0) {\n            return WCDB::StringView(\"们\");\n        } else if (token.compare(\"員\") == 0) {\n            return WCDB::StringView(\"员\");\n        }\n        return WCDB::StringView(token);\n    });\n    TestCaseAssertTrue(self.database->createVirtualTable<CPPFTS5Object>(self.tableName.UTF8String));\n    TestCaseAssertTrue(self.database->insertObjects<CPPFTS5Object>(CPPFTS5Object(\"dummy content\", \"dummy extension\"), self.tableName.UTF8String));\n}\n\n- (WCDB::Table<CPPFTS5Object> &)ftsTable\n{\n    if (!m_ftsTable) {\n        m_ftsTable = std::make_shared<WCDB::Table<CPPFTS5Object>>(self.database->getTable<CPPFTS5Object>(self.tableName.UTF8String));\n    }\n    return *m_ftsTable.get();\n}\n\n- (void)test_chinese\n{\n    CPPFTS5Object object(\"苹果树\", \"\");\n    TestCaseAssertTrue(self.ftsTable.insertObjects(object));\n    [self doTestRows:{ CPPOneRowValueExtract(object) }\n              andSQL:@\"SELECT content, extension FROM testTable WHERE content MATCH '苹' ORDER BY rowid ASC\"\n         bySelecting:^WCDB::OptionalMultiRows {\n             return CPPMultiRowValueExtract(self.ftsTable.getAllObjects(WCDB_FIELD(CPPFTS5Object::content).match(\"苹\")).value());\n         }];\n    [self doTestRows:{ CPPOneRowValueExtract(object) }\n              andSQL:@\"SELECT content, extension FROM testTable WHERE content MATCH '苹果' ORDER BY rowid ASC\"\n         bySelecting:^WCDB::OptionalMultiRows {\n             return CPPMultiRowValueExtract(self.ftsTable.getAllObjects(WCDB_FIELD(CPPFTS5Object::content).match(\"苹果\")).value());\n         }];\n    [self doTestRows:{ CPPOneRowValueExtract(object) }\n              andSQL:@\"SELECT content, extension FROM testTable WHERE content MATCH '苹果树' ORDER BY rowid ASC\"\n         bySelecting:^WCDB::OptionalMultiRows {\n             return CPPMultiRowValueExtract(self.ftsTable.getAllObjects(WCDB_FIELD(CPPFTS5Object::content).match(\"苹果树\")).value());\n         }];\n    [self doTestRows:{ CPPOneRowValueExtract(object) }\n              andSQL:@\"SELECT content, extension FROM testTable WHERE content MATCH '果树' ORDER BY rowid ASC\"\n         bySelecting:^WCDB::OptionalMultiRows {\n             return CPPMultiRowValueExtract(self.ftsTable.getAllObjects(WCDB_FIELD(CPPFTS5Object::content).match(\"果树\")).value());\n         }];\n    [self doTestRows:{ CPPOneRowValueExtract(object) }\n              andSQL:@\"SELECT content, extension FROM testTable WHERE content MATCH '树' ORDER BY rowid ASC\"\n         bySelecting:^WCDB::OptionalMultiRows {\n             return CPPMultiRowValueExtract(self.ftsTable.getAllObjects(WCDB_FIELD(CPPFTS5Object::content).match(\"树\")).value());\n         }];\n}\n\n- (void)test_traditional_chinese\n{\n    CPPFTS5Object object(\"我們是程序員\", \"\");\n    TestCaseAssertTrue(self.ftsTable.insertObjects(object));\n    [self doTestRows:{ CPPOneRowValueExtract(object) }\n              andSQL:@\"SELECT content, extension FROM testTable WHERE content MATCH '我們是程序員' ORDER BY rowid ASC\"\n         bySelecting:^WCDB::OptionalMultiRows {\n             return CPPMultiRowValueExtract(self.ftsTable.getAllObjects(WCDB_FIELD(CPPFTS5Object::content).match(\"我們是程序員\")).value());\n         }];\n    [self doTestRows:{ CPPOneRowValueExtract(object) }\n              andSQL:@\"SELECT content, extension FROM testTable WHERE content MATCH '我们是程序员' ORDER BY rowid ASC\"\n         bySelecting:^WCDB::OptionalMultiRows {\n             return CPPMultiRowValueExtract(self.ftsTable.getAllObjects(WCDB_FIELD(CPPFTS5Object::content).match(\"我们是程序员\")).value());\n         }];\n}\n\n- (void)test_english\n{\n    CPPFTS5Object object(\"WCDB is a cross-platform database framework developed by WeChat.\", \"\");\n    TestCaseAssertTrue(self.ftsTable.insertObjects(object));\n\n    [self doTestRows:{ CPPOneRowValueExtract(object) }\n              andSQL:@\"SELECT content, extension FROM testTable WHERE content MATCH 'WCDB' ORDER BY rowid ASC\"\n         bySelecting:^WCDB::OptionalMultiRows {\n             return CPPMultiRowValueExtract(self.ftsTable.getAllObjects(WCDB_FIELD(CPPFTS5Object::content).match(\"WCDB\")).value());\n         }];\n    [self doTestRows:{ CPPOneRowValueExtract(object) }\n              andSQL:@\"SELECT content, extension FROM testTable WHERE content MATCH 'WeChat' ORDER BY rowid ASC\"\n         bySelecting:^WCDB::OptionalMultiRows {\n             return CPPMultiRowValueExtract(self.ftsTable.getAllObjects(WCDB_FIELD(CPPFTS5Object::content).match(\"WeChat\")).value());\n         }];\n\n    // case insensitive\n    [self doTestRows:{ CPPOneRowValueExtract(object) }\n              andSQL:@\"SELECT content, extension FROM testTable WHERE content MATCH 'DATABASE' ORDER BY rowid ASC\"\n         bySelecting:^WCDB::OptionalMultiRows {\n             return CPPMultiRowValueExtract(self.ftsTable.getAllObjects(WCDB_FIELD(CPPFTS5Object::content).match(\"DATABASE\")).value());\n         }];\n\n    // stemming\n    [self doTestRows:{ CPPOneRowValueExtract(object) }\n              andSQL:@\"SELECT content, extension FROM testTable WHERE content MATCH 'developer' ORDER BY rowid ASC\"\n         bySelecting:^WCDB::OptionalMultiRows {\n             return CPPMultiRowValueExtract(self.ftsTable.getAllObjects(WCDB_FIELD(CPPFTS5Object::content).match(\"developer\")).value());\n         }];\n\n    // prefix\n    [self doTestRows:{ CPPOneRowValueExtract(object) }\n              andSQL:@\"SELECT content, extension FROM testTable WHERE content MATCH 'plat*' ORDER BY rowid ASC\"\n         bySelecting:^WCDB::OptionalMultiRows {\n             return CPPMultiRowValueExtract(self.ftsTable.getAllObjects(WCDB_FIELD(CPPFTS5Object::content).match(\"plat*\")).value());\n         }];\n\n    // phrase\n    [self doTestRows:{ CPPOneRowValueExtract(object) }\n              andSQL:@\"SELECT content, extension FROM testTable WHERE content MATCH 'dat* fram*' ORDER BY rowid ASC\"\n         bySelecting:^WCDB::OptionalMultiRows {\n             return CPPMultiRowValueExtract(self.ftsTable.getAllObjects(WCDB_FIELD(CPPFTS5Object::content).match(\"dat* fram*\")).value());\n         }];\n\n    // bad case\n    [self doTestRows:{}\n              andSQL:@\"SELECT content, extension FROM testTable WHERE content MATCH 'Hello' ORDER BY rowid ASC\"\n         bySelecting:^WCDB::OptionalMultiRows {\n             return CPPMultiRowValueExtract(self.ftsTable.getAllObjects(WCDB_FIELD(CPPFTS5Object::content).match(\"Hello\")).value());\n         }];\n}\n\n- (void)test_number\n{\n    CPPFTS5Object object(\"123 456 789\", \"\");\n    TestCaseAssertTrue(self.ftsTable.insertObjects(object));\n\n    [self doTestRows:{ CPPOneRowValueExtract(object) }\n              andSQL:@\"SELECT content, extension FROM testTable WHERE content MATCH '123' ORDER BY rowid ASC\"\n         bySelecting:^WCDB::OptionalMultiRows {\n             return CPPMultiRowValueExtract(self.ftsTable.getAllObjects(WCDB_FIELD(CPPFTS5Object::content).match(\"123\")).value());\n         }];\n    [self doTestRows:{ CPPOneRowValueExtract(object) }\n              andSQL:@\"SELECT content, extension FROM testTable WHERE content MATCH '456' ORDER BY rowid ASC\"\n         bySelecting:^WCDB::OptionalMultiRows {\n             return CPPMultiRowValueExtract(self.ftsTable.getAllObjects(WCDB_FIELD(CPPFTS5Object::content).match(\"456\")).value());\n         }];\n    [self doTestRows:{ CPPOneRowValueExtract(object) }\n              andSQL:@\"SELECT content, extension FROM testTable WHERE content MATCH '789' ORDER BY rowid ASC\"\n         bySelecting:^WCDB::OptionalMultiRows {\n             return CPPMultiRowValueExtract(self.ftsTable.getAllObjects(WCDB_FIELD(CPPFTS5Object::content).match(\"789\")).value());\n         }];\n\n    // bad case\n    [self doTestRows:{}\n              andSQL:@\"SELECT content, extension FROM testTable WHERE content MATCH '567' ORDER BY rowid ASC\"\n         bySelecting:^WCDB::OptionalMultiRows {\n             return CPPMultiRowValueExtract(self.ftsTable.getAllObjects(WCDB_FIELD(CPPFTS5Object::content).match(\"567\")).value());\n         }];\n}\n\n- (void)test_mixed\n{\n    CPPFTS5Object object(\"中文English日本語123\", \"\");\n    TestCaseAssertTrue(self.ftsTable.insertObjects(object));\n\n    [self doTestRows:{ CPPOneRowValueExtract(object) }\n              andSQL:@\"SELECT content, extension FROM testTable WHERE content MATCH '中' ORDER BY rowid ASC\"\n         bySelecting:^WCDB::OptionalMultiRows {\n             return CPPMultiRowValueExtract(self.ftsTable.getAllObjects(WCDB_FIELD(CPPFTS5Object::content).match(\"中\")).value());\n         }];\n    [self doTestRows:{ CPPOneRowValueExtract(object) }\n              andSQL:@\"SELECT content, extension FROM testTable WHERE content MATCH 'English' ORDER BY rowid ASC\"\n         bySelecting:^WCDB::OptionalMultiRows {\n             return CPPMultiRowValueExtract(self.ftsTable.getAllObjects(WCDB_FIELD(CPPFTS5Object::content).match(\"English\")).value());\n         }];\n    [self doTestRows:{ CPPOneRowValueExtract(object) }\n              andSQL:@\"SELECT content, extension FROM testTable WHERE content MATCH '語' ORDER BY rowid ASC\"\n         bySelecting:^WCDB::OptionalMultiRows {\n             return CPPMultiRowValueExtract(self.ftsTable.getAllObjects(WCDB_FIELD(CPPFTS5Object::content).match(\"語\")).value());\n         }];\n    [self doTestRows:{ CPPOneRowValueExtract(object) }\n              andSQL:@\"SELECT content, extension FROM testTable WHERE content MATCH '123' ORDER BY rowid ASC\"\n         bySelecting:^WCDB::OptionalMultiRows {\n             return CPPMultiRowValueExtract(self.ftsTable.getAllObjects(WCDB_FIELD(CPPFTS5Object::content).match(\"123\")).value());\n         }];\n}\n\n- (void)test_column_match\n{\n    CPPFTS5Object content(\"error_prone\", \"\");\n    TestCaseAssertTrue(self.ftsTable.insertObjects(content));\n\n    CPPFTS5Object extension(\"\", \"error_prone\");\n    TestCaseAssertTrue(self.ftsTable.insertObjects(extension));\n\n    [self doTestRows:{ CPPOneRowValueExtract(content) }\n              andSQL:@\"SELECT content, extension FROM testTable WHERE content MATCH 'error_prone' ORDER BY rowid ASC\"\n         bySelecting:^WCDB::OptionalMultiRows {\n             return CPPMultiRowValueExtract(self.ftsTable.getAllObjects(WCDB_FIELD(CPPFTS5Object::content).match(\"error_prone\")).value());\n         }];\n    [self doTestRows:{ CPPOneRowValueExtract(extension) }\n              andSQL:@\"SELECT content, extension FROM testTable WHERE extension MATCH 'error_prone' ORDER BY rowid ASC\"\n         bySelecting:^WCDB::OptionalMultiRows {\n             return CPPMultiRowValueExtract(self.ftsTable.getAllObjects(WCDB_FIELD(CPPFTS5Object::extension).match(\"error_prone\")).value());\n         }];\n    [self doTestRows:{ CPPOneRowValueExtract(content), CPPOneRowValueExtract(extension) }\n              andSQL:@\"SELECT content, extension FROM testTable WHERE testTable MATCH 'error_prone' ORDER BY rowid ASC\"\n         bySelecting:^WCDB::OptionalMultiRows {\n             return CPPMultiRowValueExtract(self.ftsTable.getAllObjects(WCDB::Column(self.tableName.UTF8String).match(\"error_prone\")).value());\n         }];\n    [self doTestRows:{ CPPOneRowValueExtract(content) }\n              andSQL:@\"SELECT content, extension FROM testTable WHERE testTable MATCH 'content: error_prone' ORDER BY rowid ASC\"\n         bySelecting:^WCDB::OptionalMultiRows {\n             return CPPMultiRowValueExtract(self.ftsTable.getAllObjects(WCDB::Column(self.tableName.UTF8String).match(\"content: error_prone\")).value());\n         }];\n    [self doTestRows:{ CPPOneRowValueExtract(extension) }\n              andSQL:@\"SELECT content, extension FROM testTable WHERE testTable MATCH 'extension: error_prone' ORDER BY rowid ASC\"\n         bySelecting:^WCDB::OptionalMultiRows {\n             return CPPMultiRowValueExtract(self.ftsTable.getAllObjects(WCDB::Column(self.tableName.UTF8String).match(\"extension: error_prone\")).value());\n         }];\n}\n\n- (void)test_auto_merge\n{\n    self.database->enableAutoMergeFTS5Index(true);\n    for (int i = 0; i < 14; i++) {\n        CPPFTS5Object object(Random.shared.chineseString.UTF8String, \"\");\n        TestCaseAssertTrue(self.ftsTable.insertObjects(object));\n        WCDB::OptionalValue count = self.database->getValueFromStatement(WCDB::StatementSelect().select(WCDB::Column(\"segid\").count().distinct()).from(WCDB::StringView::formatted(\"%s_idx\", self.tableName.UTF8String)));\n        TestCaseAssertTrue(count.succeed());\n        TestCaseAssertTrue(count.value() == i + 2);\n    }\n\n    [NSThread sleepForTimeInterval:2.5];\n\n    WCDB::OptionalValue count = self.database->getValueFromStatement(WCDB::StatementSelect().select(WCDB::Column(\"segid\").count().distinct()).from(WCDB::StringView::formatted(\"%s_idx\", self.tableName.UTF8String)));\n    TestCaseAssertTrue(count.succeed());\n    TestCaseAssertTrue(count.value() == 1);\n}\n\n- (void)test_thread_conflict\n{\n    self.database->enableAutoMergeFTS5Index(true);\n    for (int i = 0; i < 1000; i++) {\n        CPPFTS5Object object(Random.shared.chineseString.UTF8String, \"\");\n        TestCaseAssertTrue(self.ftsTable.insertObjects(object));\n    }\n    [NSThread sleepForTimeInterval:1.8];\n    int totalCount = 10000;\n    double maxCost = 0;\n    for (int i = 0; i < totalCount; i++) {\n        if (i > 0 && i % (totalCount / 10) == 0) {\n            TestCaseLog(@\"insert progress %d%%\", i * 100 / totalCount);\n        }\n        NSDate *start = [NSDate date];\n        self.database->runTransaction([&](WCDB::Handle &) {\n            maxCost = MAX([[NSDate date] timeIntervalSinceDate:start], maxCost);\n            CPPFTS5Object object(Random.shared.chineseString.UTF8String, \"\");\n            TestCaseAssertTrue(self.ftsTable.insertObjects(object));\n            return true;\n        });\n        [NSThread sleepForTimeInterval:0.0001];\n    }\n    [NSThread sleepForTimeInterval:10];\n    WCDB::OptionalValue count = self.database->getValueFromStatement(WCDB::StatementSelect().select(WCDB::Column(\"segid\").count().distinct()).from(WCDB::StringView::formatted(\"%s_idx\", self.tableName.UTF8String)));\n    TestCaseAssertTrue(count.succeed());\n    TestCaseAssertTrue(count.value().intValue() < 8);\n    TestCaseAssertTrue(maxCost < 0.1);\n}\n\n@end\n\n@interface CPPFTS5PinyinTests : CPPTableTestCase\n\n@end\n\n@implementation CPPFTS5PinyinTests\n\n- (void)setUp\n{\n    [super setUp];\n    self.expectMode = DatabaseTestCaseExpectFirstFewSQLs;\n    std::map<WCDB::UnsafeStringView, std::vector<WCDB::UnsafeStringView>> pinyinDict = {\n        { \"单\", { \"shan\", \"dan\", \"chan\" } },\n        { \"于\", { \"yu\" } },\n        { \"骑\", { \"qi\" } },\n        { \"模\", { \"mo\", \"mu\" } },\n        { \"具\", { \"ju\" } },\n        { \"车\", { \"che\" } }\n    };\n    WCDB::Database::configPinyinConverter([=](const WCDB::UnsafeStringView &token) {\n        if (pinyinDict.find(token) == pinyinDict.end()) {\n            return std::vector<WCDB::StringView>();\n        }\n        auto pinyins = pinyinDict.at(token);\n        std::vector<WCDB::StringView> result;\n        for (auto pinyin : pinyins) {\n            result.emplace_back(pinyin);\n        }\n        return result;\n    });\n    WCDB::Database::configSymbolDetector([](WCDB::Database::UnicodeChar theChar) {\n        if (theChar < 0xC0) {\n            if (!(theChar >= 0x30 && theChar <= 0x39) && !((theChar >= 0x41 && theChar <= 0x5a) || (theChar >= 0x61 && theChar <= 0x7a))) {\n                return true;\n            }\n        }\n        return false;\n    });\n    self.database->addTokenizer(WCDB::BuiltinTokenizer::Pinyin);\n\n    TestCaseAssertTrue(self.database->createVirtualTable<CPPFTS5PinyinObject>(self.tableName.UTF8String));\n    CPPFTS5PinyinObject object;\n    object.content = \"测试内容\";\n    TestCaseAssertTrue(self.database->insertObjects<CPPFTS5PinyinObject>(object, self.tableName.UTF8String));\n}\n\n- (void)test_pinyin\n{\n    CPPFTS5PinyinObject content;\n    content.content = \"单于骑模具单车\";\n    TestCaseAssertTrue(self.database->insertObjects<CPPFTS5PinyinObject>(content, self.tableName.UTF8String));\n\n    NSArray *querys = @[\n        @\"\\\"shan yu qi mu ju dan che\\\"\",\n        @\"\\\"chan yu qi mo ju shan che\\\"\",\n        @\"\\\"dan yu qi mo ju chan che\\\"\",\n        @\"\\\"dan yu qi mu ju ch\\\"*\",\n        @\"\\\"dan yu qi mo ju d\\\"*\",\n        @\"\\\"s y q m j d c\\\"\",\n        @\"\\\"c y q m j s c\\\"\",\n        @\"\\\"c y q m j\\\"\",\n    ];\n    for (NSString *query in querys) {\n        [self doTestRows:{ CPPOneRowValueExtract(content) }\n                  andSQL:[NSString stringWithFormat:@\"SELECT content FROM testTable WHERE content MATCH '%@' ORDER BY rowid ASC\", query]\n             bySelecting:^WCDB::OptionalMultiRows {\n                 return CPPMultiRowValueExtract(self.database->getAllObjects<CPPFTS5PinyinObject>(self.tableName.UTF8String, WCDB_FIELD(CPPFTS5PinyinObject::content).match(query.UTF8String)).value());\n             }];\n    }\n}\n\n@end\n\n@interface CPPFTS5SymbolTests : CPPTableTestCase\n\n@end\n\n@implementation CPPFTS5SymbolTests\n\n- (void)setUp\n{\n    [super setUp];\n    self.expectMode = DatabaseTestCaseExpectFirstFewSQLs;\n    self.database->addTokenizer(WCDB::BuiltinTokenizer::Verbatim);\n    self.database->addAuxiliaryFunction(WCDB::BuiltinAuxiliaryFunction::SubstringMatchInfo);\n    WCDB::Database::configSymbolDetector([](WCDB::Database::UnicodeChar theChar) {\n        if (theChar < 0xC0) {\n            if (!(theChar >= 0x30 && theChar <= 0x39) && !((theChar >= 0x41 && theChar <= 0x5a) || (theChar >= 0x61 && theChar <= 0x7a))) {\n                return true;\n            }\n        }\n        return false;\n    });\n    TestCaseAssertTrue(self.database->createVirtualTable<CPPFTS5SymbolObject>(self.tableName.UTF8String));\n    CPPFTS5SymbolObject object;\n    object.content = \"!@#$%^&*(()))_+\";\n    TestCaseAssertTrue(self.database->insertObjects<CPPFTS5SymbolObject>(object, self.tableName.UTF8String));\n}\n\n- (void)test_symbol\n{\n    CPPFTS5SymbolObject content;\n    content.content = \"#￥%…'  '！@…&*\";\n    TestCaseAssertTrue(self.database->insertObjects<CPPFTS5SymbolObject>(content, self.tableName.UTF8String));\n\n    content.content = \"！@…&*'  '\\\"#￥%…\";\n    TestCaseAssertTrue(self.database->insertObjects<CPPFTS5SymbolObject>(content, self.tableName.UTF8String));\n\n    NSArray *querys = @[ @\"\\\"！@…&*'  '\\\"\\\"#￥%…\\\"\", @\"\\\"！@…&*'  '\\\"\\\"\\\"*\" ];\n    for (NSString *query in querys) {\n        [self doTestRows:{ CPPOneRowValueExtract(content) }\n                  andSQL:[NSString stringWithFormat:@\"SELECT content FROM testTable WHERE content MATCH '%@' ORDER BY rowid ASC\", [query stringByReplacingOccurrencesOfString:@\"'\" withString:@\"''\"]]\n             bySelecting:^WCDB::OptionalMultiRows {\n                 return CPPMultiRowValueExtract(self.database->getAllObjects<CPPFTS5SymbolObject>(self.tableName.UTF8String, WCDB_FIELD(CPPFTS5SymbolObject::content).match(query.UTF8String)).value());\n             }];\n    }\n\n    content.content = \"abc*123_@567\";\n    TestCaseAssertTrue(self.database->insertObjects<CPPFTS5SymbolObject>(content, self.tableName.UTF8String));\n\n    content.content = \"abc@123*def_567\";\n    TestCaseAssertTrue(self.database->insertObjects<CPPFTS5SymbolObject>(content, self.tableName.UTF8String));\n\n    querys = @[ @\"\\\"abc@123*def_567\\\"\", @\"\\\"abc@123*def\\\"*\" ];\n    for (NSString *query in querys) {\n        [self doTestRows:{ CPPOneRowValueExtract(content) }\n                  andSQL:[NSString stringWithFormat:@\"SELECT content FROM testTable WHERE content MATCH '%@' ORDER BY rowid ASC\", query]\n             bySelecting:^WCDB::OptionalMultiRows {\n                 return CPPMultiRowValueExtract(self.database->getAllObjects<CPPFTS5SymbolObject>(self.tableName.UTF8String, WCDB_FIELD(CPPFTS5SymbolObject::content).match(query.UTF8String)).value());\n             }];\n    }\n}\n\n- (void)test_substring_match_info\n{\n    CPPFTS5SymbolObject content;\n    content.content = \"多级,分隔符,串联子串1;多级,分隔符,串联子串2;多级,分隔符,串联子串3\";\n    TestCaseAssertTrue(self.database->insertObjects<CPPFTS5SymbolObject>(content, self.tableName.UTF8String));\n    [self doTestValue:\"1,2;串联;子串2;6;\"\n               andSQL:@\"SELECT substring_match_info(testTable, 0, ';,') FROM testTable WHERE content MATCH '子串2'\"\n          bySelecting:^WCDB::OptionalValue {\n              return self.database->getValueFromStatement(WCDB::StatementSelect().select(WCDB::Expression::function(WCDB::BuiltinAuxiliaryFunction::SubstringMatchInfo).invoke().arguments({ WCDB::Column(self.tableName.UTF8String), 0, \";,\" })).from(self.tableName.UTF8String).where(WCDB_FIELD(CPPFTS5SymbolObject::content).match(\"子串2\")));\n          }];\n}\n\n@end\n"
  },
  {
    "path": "src/cpp/tests/interface/CPPConfigTests.mm",
    "content": "//\n// Created by qiuwenchen on 2022/8/10.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"CPPTestCase.h\"\n\n@interface CPPConfigTests : CPPDatabaseTestCase\n\n@property (nonatomic, readonly) NSString* configName;\n\n@end\n\nbool g_hasOpened = false;\nbool g_hasClosed = false;\n\nint newOpen(const char* path, int flag, int mode)\n{\n    g_hasOpened = true;\n    return ::open(path, flag, mode);\n}\n\nint newClose(int fd)\n{\n    g_hasClosed = true;\n    return ::close(fd);\n}\n\n@implementation CPPConfigTests {\n    NSString* _configName;\n}\n\n- (NSString*)configName\n{\n    @synchronized(self) {\n        if (_configName == nil) {\n            _configName = Random.shared.string;\n        }\n        return _configName;\n    }\n}\n\n- (void)tearDown\n{\n    self.database->removeConfig(self.configName.UTF8String);\n    [super tearDown];\n}\n\n- (void)test_open_close\n{\n    WCDB::Database::registerPOSIXOpen(newOpen);\n    WCDB::Database::registerPOSIXClose(newClose);\n    TestCaseAssertTrue(self.database->canOpen());\n    self.database->close();\n    TestCaseAssertTrue(g_hasOpened && g_hasClosed);\n    WCDB::Database::registerPOSIXOpen(nullptr);\n    WCDB::Database::registerPOSIXClose(nullptr);\n    g_hasOpened = false;\n    g_hasClosed = false;\n    TestCaseAssertTrue(self.database->canOpen());\n    self.database->close();\n    TestCaseAssertTrue(!g_hasOpened && !g_hasClosed);\n}\n\n- (void)test_config\n{\n    WCDB::StatementPragma setSecureDelete = WCDB::StatementPragma().pragma(WCDB::Pragma::secureDelete()).to(true);\n    WCDB::StatementPragma unsetSecureDelete = WCDB::StatementPragma().pragma(WCDB::Pragma::secureDelete()).to(false);\n    WCDB::StatementPragma getSecureDelete = WCDB::StatementPragma().pragma(WCDB::Pragma::secureDelete());\n\n    BOOL uninvoked = NO;\n    {\n        self.database->setConfig(\n        self.configName.UTF8String, [&](WCDB::Handle& handle) { return handle.execute(setSecureDelete); }, [&](WCDB::Handle& handle) {\n            uninvoked = YES;\n            return handle.execute(unsetSecureDelete); });\n\n        self.expectMode = DatabaseTestCaseExpectSomeSQLs;\n        [self doTestSQLs:@[ @\"PRAGMA secure_delete = TRUE\" ]\n             inOperation:^BOOL {\n                 self.database->close();\n                 return self.database->canOpen();\n             }];\n        TestCaseAssertTrue(self.database->getValueFromStatement(getSecureDelete).value());\n    }\n    {\n        // uninvocation\n        self.database->removeConfig(self.configName.UTF8String);\n\n        TestCaseAssertTrue(self.database->canOpen());\n        TestCaseAssertTrue(uninvoked);\n\n        auto value = self.database->getValueFromStatement(getSecureDelete);\n        TestCaseAssertTrue(value.succeed());\n        TestCaseAssertFalse(value.value());\n    }\n}\n\n- (void)test_config_out_of_scope\n{\n    [self.dispatch async:^{\n        WCDB::StatementPragma setSecureDelete = WCDB::StatementPragma().pragma(WCDB::Pragma::secureDelete()).to(true);\n        WCDB::Database db1(self.path.UTF8String);\n        db1.setConfig(\n        self.configName.UTF8String, [=](WCDB::Handle& handle) { return handle.execute(setSecureDelete); });\n    }];\n    [self.dispatch waitUntilDone];\n    WCDB::Database db2(self.path.UTF8String);\n    TestCaseAssertTrue(db2.canOpen());\n}\n\n- (void)test_config_failed\n{\n    self.database->setConfig(self.configName.UTF8String, [](WCDB::Handle&) {\n        return false;\n    });\n\n    TestCaseAssertFalse(self.database->canOpen());\n}\n\n- (void)test_uninvoke_failed\n{\n    self.database->setConfig(\n    self.configName.UTF8String, [](WCDB::Handle&) { return true; }, [](WCDB::Handle&) { return false; });\n\n    TestCaseAssertTrue(self.database->canOpen());\n\n    self.database->removeConfig(self.configName.UTF8String);\n\n    TestCaseAssertFalse(self.database->canOpen());\n}\n\n- (void)test_ordered_config\n{\n    NSString* config1 = [self.configName stringByAppendingString:@\"_1\"];\n    NSString* config2 = [self.configName stringByAppendingString:@\"_2\"];\n    NSString* config3 = [self.configName stringByAppendingString:@\"_3\"];\n\n    int step = 0;\n\n    self.database->setConfig(config1.UTF8String, [&step](WCDB::Handle&) {\n        ++step;\n        return step == 2;\n    });\n\n    self.database->setConfig(\n    config2.UTF8String, [&step](WCDB::Handle&) {\n        ++step;\n        return step == 3;\n    },\n    nil,\n    WCDB::Database::Priority::Low);\n\n    self.database->setConfig(\n    config3.UTF8String, [&step](WCDB::Handle&) {\n        ++step;\n        return step == 1;\n    },\n    nil,\n    WCDB::Database::Priority::High);\n\n    TestCaseAssertTrue(self.database->canOpen());\n\n    TestCaseAssertEqual(step, 3);\n}\n\n- (void)test_cipher\n{\n    NSData* cipher = Random.shared.data;\n    NSData* wrongCipher = [Random.shared dataOtherThan:cipher];\n\n    self.database->setCipherKey(WCDB::UnsafeData((unsigned char*) cipher.bytes, cipher.length));\n    TestCaseAssertTrue(self.database->canOpen());\n\n    self.database->close();\n    self.database->setCipherKey(WCDB::UnsafeData((unsigned char*) wrongCipher.bytes, wrongCipher.length));\n    TestCaseAssertFalse(self.database->canOpen());\n}\n\n- (void)test_cipher_with_page_size\n{\n    NSData* cipher = Random.shared.data;\n    int pageSize = 8 * 1024;\n    int wrongPageSize = 16 * 1024;\n\n    self.database->setCipherKey(WCDB::UnsafeData((unsigned char*) cipher.bytes, cipher.length), pageSize);\n    TestCaseAssertTrue(self.database->canOpen());\n\n    self.database->close();\n    self.database->setCipherKey(WCDB::UnsafeData((unsigned char*) cipher.bytes, cipher.length), wrongPageSize);\n    TestCaseAssertFalse(self.database->canOpen());\n}\n\n- (void)test_cipher_with_diferent_version\n{\n    NSData* cipher = Random.shared.data;\n    int pageSize = 4096;\n    self.database->setCipherKey(WCDB::UnsafeData((unsigned char*) cipher.bytes, cipher.length), pageSize, WCDB::Database::CipherVersion::Version3);\n    TestCaseAssertTrue(self.database->canOpen());\n\n    self.database->close();\n    self.database->setCipherKey(WCDB::UnsafeData((unsigned char*) cipher.bytes, cipher.length), pageSize);\n    TestCaseAssertFalse(self.database->canOpen());\n\n    WCDB::Database::setDefaultCipherConfiguration(WCDB::Database::CipherVersion::Version3);\n    TestCaseAssertTrue(self.database->canOpen());\n\n    self.database->removeFiles();\n    self.database->setCipherKey(WCDB::UnsafeData((unsigned char*) cipher.bytes, cipher.length), pageSize, WCDB::Database::CipherVersion::Version4);\n    TestCaseAssertTrue(self.database->canOpen());\n    self.database->close();\n\n    self.database->setCipherKey(WCDB::UnsafeData((unsigned char*) cipher.bytes, cipher.length), pageSize);\n    TestCaseAssertFalse(self.database->canOpen());\n    WCDB::Database::setDefaultCipherConfiguration(WCDB::Database::CipherVersion::Version4);\n    TestCaseAssertTrue(self.database->canOpen());\n}\n\n- (void)testSetTemporaryDirectory\n{\n    TestCaseAssertFalse(WCDB::Database::setDefaultTemporaryDirectory(\"wrongDir\"));\n\n    NSString* tempDir = [NSTemporaryDirectory() stringByAppendingPathComponent:@\"dbTempDir\"];\n    TestCaseAssertTrue(WCDB::Database::setDefaultTemporaryDirectory(tempDir.UTF8String));\n    WCDB::StatementPragma getDirStatement = WCDB::StatementPragma().pragma(WCDB::Pragma(\"temp_store_directory\"));\n    WCDB::OptionalValue dir = self.database->getValueFromStatement(getDirStatement);\n    TestCaseAssertTrue(dir.valueOr(\"\").textValue().compare(tempDir.UTF8String) == 0);\n\n    TestCaseAssertTrue(WCDB::Database::setDefaultTemporaryDirectory(NULL));\n    dir = self.database->getValueFromStatement(getDirStatement);\n    TestCaseAssertTrue(dir.hasValue() && dir.value().textValue().length() == 0);\n}\n\n@end\n"
  },
  {
    "path": "src/cpp/tests/interface/CPPDatabaseTest.mm",
    "content": "//\n// Created by qiuwenchen on 2022/8/14.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"CPPTestCase.h\"\n\n@interface CPPDatabaseTests : CPPCRUDTestCase\n\n@end\n\n@implementation CPPDatabaseTests\n\n- (void)test_tag\n{\n    TestCaseAssertNotEqual(self.database->getTag(), WCDB::Tag::invalid());\n    WCDB::Database another = WCDB::Database(self.path.UTF8String);\n    TestCaseAssertEqual(self.database->getTag(), another.getTag());\n}\n\n- (void)test_path\n{\n    TestCaseAssertCPPStringEqual(self.database->getPath().data(), self.path.UTF8String);\n}\n\n- (void)test_open_and_close\n{\n    TestCaseAssertFalse(self.database->isOpened());\n    TestCaseAssertTrue(self.database->canOpen());\n    TestCaseAssertTrue(self.database->isOpened());\n    self.database->close();\n    TestCaseAssertFalse(self.database->isOpened());\n}\n\n- (void)test_blockade\n{\n    self.database->blockade();\n    __block NSDate* subthread;\n    [self.dispatch async:^{\n        TestCaseAssertTrue(self.database->canOpen());\n        subthread = [NSDate date];\n    }];\n    [NSThread sleepForTimeInterval:1];\n    NSDate* main = [NSDate date];\n    self.database->unblockade();\n    [self.dispatch waitUntilDone];\n    TestCaseAssertTrue([main compare:subthread] == NSOrderedAscending);\n}\n\n- (void)test_blockaded_close\n{\n    NSDate* main = [NSDate date];\n    NSDate* subthread = [NSDate date];\n    self.database->close([&]() {\n        [self.dispatch async:^{\n            TestCaseAssertTrue(self.database->canOpen());\n            subthread = [NSDate date];\n        }];\n        [NSThread sleepForTimeInterval:1];\n        main = [NSDate date];\n    });\n    [self.dispatch waitUntilDone];\n    TestCaseAssertTrue([main compare:subthread] == NSOrderedAscending);\n}\n\n- (void)test_readonly\n{\n    WCDB::OneRowValue row = [Random.shared autoIncrementTestCaseValuesWithCount:1][0];\n    TestCaseAssertTrue([self createValueTable]);\n    TestCaseAssertTrue(self.database->insertRows(row, self.columns, self.tableName.UTF8String));\n\n    self.database->close([=]() {\n        for (const WCDB::UnsafeStringView path : self.database->getPaths()) {\n            NSString* nsPath = [NSString stringWithUTF8String:path.data()];\n            if ([self.fileManager fileExistsAtPath:nsPath]) {\n                TestCaseAssertTrue([self.fileManager setAttributes:@{ NSFileImmutable : @(YES) } ofItemAtPath:nsPath error:nil]);\n            }\n        }\n    });\n\n    TestCaseAssertTrue(self.database->canOpen());\n    auto values = self.database->selectAllRow(self.resultColumns, self.tableName.UTF8String);\n    TestCaseAssertTrue(values.succeed() && values.value().size() == 1);\n    XCTAssertFalse(self.database->insertRows(row, self.columns, self.tableName.UTF8String));\n\n    // reset attribute\n    for (const WCDB::UnsafeStringView path : self.database->getPaths()) {\n        NSString* nsPath = [NSString stringWithUTF8String:path.data()];\n        if ([self.fileManager fileExistsAtPath:nsPath]) {\n            TestCaseAssertTrue([self.fileManager setAttributes:@{ NSFileImmutable : @(NO) } ofItemAtPath:nsPath error:nil]);\n        }\n    }\n}\n\n- (void)test_get_error\n{\n    TestCaseAssertFalse(self.database->insertObject(CPPTestCaseObject(), \"notExistTable\"));\n    TestCaseAssertFalse(self.database->getError().isOK());\n    TestCaseAssertTrue(self.database->getError().getMessage().contain(\"notExistTable\"));\n}\n\n- (void)test_feature_run_while_closing\n{\n    TestCaseAssertTrue(self.database->canOpen());\n    TestCaseAssertTrue(self.database->isOpened());\n    self.database->close([=]() {\n        TestCaseAssertTrue(self.database->execute(WCDB::StatementPragma().pragma(WCDB::Pragma::userVersion()).to(123)));\n    });\n    TestCaseAssertFalse(self.database->isOpened());\n}\n\n- (void)test_purge\n{\n    // acquire handle\n    TestCaseAssertTrue(self.database->execute(WCDB::StatementPragma().pragma(WCDB::Pragma::userVersion())));\n\n    TestCaseAssertTrue(self.database->isOpened());\n    self.database->purge();\n    TestCaseAssertFalse(self.database->isOpened());\n}\n\n- (void)test_purge_all\n{\n    // acquire handle\n    TestCaseAssertTrue(self.database->execute(WCDB::StatementPragma().pragma(WCDB::Pragma::userVersion())));\n\n    TestCaseAssertTrue(self.database->isOpened());\n    WCDB::Database::purgeAll();\n    TestCaseAssertFalse(self.database->isOpened());\n}\n\n- (void)test_checkpoint\n{\n    WCDB::MultiRowsValue rows = [Random.shared autoIncrementTestCaseValuesWithCount:100];\n\n    TestCaseAssertTrue([self createValueTable]);\n\n    unsigned long walFrameNum = 0;\n    for (int i = 0; i < 100; i++) {\n        auto value = self.database->getValueFromStatement(WCDB::StatementSelect().select(WCDB::Column::all().count()).from(self.tableName.UTF8String));\n        TestCaseAssertTrue(value.succeed() && value.value().intValue() == i);\n        TestCaseAssertTrue(self.database->insertRows(rows[i], self.columns, self.tableName.UTF8String));\n        self.database->passiveCheckpoint();\n        self.database->close([&]() {\n            if (walFrameNum != 0) {\n                TestCaseAssertTrue(walFrameNum == [self getNumberOfWalFrames]);\n            } else {\n                walFrameNum = [self getNumberOfWalFrames];\n            }\n            TestCaseAssertTrue(walFrameNum > 0);\n            for (const WCDB::UnsafeStringView& path : self.database->getPaths()) {\n                NSString* nsPath = [NSString stringWithUTF8String:path.data()];\n                if (path.hasSuffix(\"wal\")) {\n                    TestCaseAssertTrue([self.fileManager fileExistsAtPath:nsPath]);\n                    TestCaseAssertTrue([self.fileManager getFileSizeIfExists:nsPath] > 32);\n                } else if (path.hasSuffix(\"shm\")) {\n                    TestCaseAssertTrue([self.fileManager fileExistsAtPath:nsPath]);\n                    TestCaseAssertTrue([self.fileManager getFileSizeIfExists:nsPath] >= 32 * 1024);\n                }\n            }\n        });\n    }\n}\n\n- (void)test_open_fail\n{\n    auto database = WCDB::Database(self.directory.UTF8String);\n    TestCaseAssertFalse(database.canOpen());\n    TestCaseAssertFalse(database.selectValue(WCDB::Column::all().count(), WCDB::Master::tableName).succeed());\n    WCDB::Handle handle = database.getHandle();\n    TestCaseAssertFalse(handle.selectValue(WCDB::Column::all().count(), WCDB::Master::tableName).succeed());\n    TestCaseAssertFalse(database.createTable<CPPTestCaseObject>(self.tableName.UTF8String));\n    WCDB::Table<CPPTestCaseObject> table = database.getTable<CPPTestCaseObject>(self.tableName.UTF8String);\n    TestCaseAssertFalse(table.selectValue(WCDB::Column::all().count()).succeed());\n}\n\n- (void)test_backup\n{\n    [self insertPresetObjects];\n    TestCaseAssertFalse([self.fileManager fileExistsAtPath:[self firstMaterialPath]]);\n    TestCaseAssertFalse([self.fileManager fileExistsAtPath:[self lastMaterialPath]]);\n\n    TestCaseAssertTrue(self.database->backup());\n    TestCaseAssertTrue([self.fileManager fileExistsAtPath:[self firstMaterialPath]]);\n    TestCaseAssertFalse([self.fileManager fileExistsAtPath:[self lastMaterialPath]]);\n\n    TestCaseAssertTrue(self.database->backup());\n    TestCaseAssertTrue([self.fileManager fileExistsAtPath:[self firstMaterialPath]]);\n    TestCaseAssertTrue([self.fileManager fileExistsAtPath:[self lastMaterialPath]]);\n}\n\n- (void)test_retrive\n{\n    [self insertPresetObjects];\n    TestCaseAssertTrue(self.database->retrieve(nullptr) == 1);\n    [self check:CPPMultiRowValueExtract(self.objects)\n      isEqualTo:CPPMultiRowValueExtract([self getAllObjects])];\n}\n\n- (void)test_vacuum\n{\n    [self insertPresetObjects];\n    TestCaseAssertTrue(self.database->vacuum(nullptr));\n    [self check:CPPMultiRowValueExtract(self.objects)\n      isEqualTo:CPPMultiRowValueExtract([self getAllObjects])];\n}\n\n- (void)test_auto_vacuum\n{\n    self.database->enableAutoVacuum(false);\n    auto autoVacuum = self.database->getValueFromStatement(WCDB::StatementPragma().pragma(WCDB::Pragma::autoVacuum()));\n    TestCaseAssertTrue(autoVacuum.succeed() && autoVacuum.value() == 1);\n\n    self.database->enableAutoVacuum(true);\n    autoVacuum = self.database->getValueFromStatement(WCDB::StatementPragma().pragma(WCDB::Pragma::autoVacuum()));\n    TestCaseAssertTrue(autoVacuum.succeed() && autoVacuum.value() == 2);\n}\n\n- (void)test_incremental_vacuum\n{\n    self.database->enableAutoVacuum(true);\n    [self insertPresetRows];\n    TestCaseAssertTrue(self.database->truncateCheckpoint());\n    TestCaseAssertTrue(self.database->dropTable(self.tableName.UTF8String));\n    TestCaseAssertTrue(self.database->truncateCheckpoint());\n    auto freelist = self.database->getValueFromStatement(WCDB::StatementPragma().pragma(WCDB::Pragma::freelistCount()));\n    TestCaseAssertTrue(freelist.succeed() && freelist.value().intValue() > 0);\n\n    TestCaseAssertTrue(self.database->incrementalVacuum(0));\n\n    freelist = self.database->getValueFromStatement(WCDB::StatementPragma().pragma(WCDB::Pragma::freelistCount()));\n    TestCaseAssertTrue(freelist.succeed() && freelist.value().intValue() == 0);\n}\n\n- (void)test_migration\n{\n    CPPTestCaseObject oldObject1 = CPPTestCaseObject(1, \"a\");\n    CPPTestCaseObject oldObject2 = CPPTestCaseObject(2, \"b\");\n    CPPTestCaseObject oldObject3 = CPPTestCaseObject(3, \"c\");\n\n    NSData* sourceCipher = [Random.shared dataWithLength:101];\n    NSData* targetCipher = [Random.shared dataWithLength:101];\n\n    WCDB::Database sourceDatabase([self.path stringByAppendingString:@\"_source\"].UTF8String);\n    sourceDatabase.setCipherKey(WCDB::UnsafeData((unsigned char*) sourceCipher.bytes, sourceCipher.length));\n\n    NSString* sourceTableName = @\"sourceTable\";\n    TestCaseAssertTrue(sourceDatabase.createTable<CPPTestCaseObject>(sourceTableName.UTF8String));\n    WCDB::Table<CPPTestCaseObject> sourceTable = sourceDatabase.getTable<CPPTestCaseObject>(sourceTableName.UTF8String);\n\n    TestCaseAssertTrue(sourceTable.insertObjects({ oldObject1, oldObject2, oldObject3 }));\n\n    WCDB::Database targetDatabase(self.path.UTF8String);\n    targetDatabase.setCipherKey(WCDB::UnsafeData((unsigned char*) targetCipher.bytes, targetCipher.length));\n\n    targetDatabase.addMigration(sourceDatabase.getPath(),\n                                WCDB::UnsafeData((unsigned char*) sourceCipher.bytes, sourceCipher.length),\n                                [=](WCDB::Database::MigrationInfo& info) {\n                                    if (info.table.compare(self.tableName.UTF8String) == 0) {\n                                        info.sourceTable = sourceTableName.UTF8String;\n                                        info.filterCondition = WCDB_FIELD(CPPTestCaseObject::identifier) > 2;\n                                    }\n                                });\n\n    TestCaseAssertTrue(targetDatabase.createTable<CPPTestCaseObject>(self.tableName.UTF8String));\n    WCDB::Table<CPPTestCaseObject> targetTable = targetDatabase.getTable<CPPTestCaseObject>(self.tableName.UTF8String);\n\n    TestCaseAssertTrue(targetTable.selectValue(WCDB::Column::all().count()).value() == 1);\n\n    TestCaseAssertTrue(targetTable.deleteObjects(WCDB_FIELD(CPPTestCaseObject::identifier) == 2));\n    TestCaseAssertTrue(sourceTable.selectValue(WCDB::Column::all().count()).value() == 3);\n\n    TestCaseAssertTrue(targetTable.updateRow({ \"newContent\" }, WCDB_FIELD(CPPTestCaseObject::content), WCDB_FIELD(CPPTestCaseObject::identifier) == 3));\n    TestCaseAssertCPPStringEqual(targetTable.selectValue(WCDB_FIELD(CPPTestCaseObject::content), WCDB_FIELD(CPPTestCaseObject::identifier) == 3).value().textValue().data(), \"newContent\");\n\n    TestCaseAssertTrue(targetTable.deleteObjects(WCDB_FIELD(CPPTestCaseObject::identifier) == 3));\n    TestCaseAssertTrue(targetTable.selectValue(WCDB::Column::all().count()).value() == 0);\n    TestCaseAssertTrue(sourceTable.selectValue(WCDB::Column::all().count()).value() == 2);\n\n    TestCaseAssertTrue(targetTable.insertObjects(CPPTestCaseObject(4, \"d\")));\n    auto newObject = targetTable.getFirstObject(WCDB_FIELD(CPPTestCaseObject::identifier) == 4);\n    TestCaseAssertTrue(newObject.valueOrDefault().content.compare(\"d\") == 0);\n    TestCaseAssertTrue(sourceTable.selectValue(WCDB::Column::all().count()).value() == 2);\n    TestCaseAssertTrue(targetTable.selectValue(WCDB::Column::all().count()).value() == 1);\n\n    targetDatabase.close();\n    TestCaseAssertFalse(targetDatabase.isMigrated());\n\n    WCDB::StringView migratedTable;\n    targetDatabase.setNotificationWhenMigrated([&migratedTable, self](WCDB::Database&, WCDB::Optional<WCDB::Database::MigrationInfo> info) {\n        if (info.valueOrDefault().table.compare(self.tableName.UTF8String) == 0) {\n            migratedTable = info.value().sourceTable;\n        }\n    });\n    while (!targetDatabase.isMigrated()) {\n        TestCaseAssertTrue(targetDatabase.stepMigration());\n    }\n    TestCaseAssertCPPStringEqual(migratedTable.data(), sourceTableName.UTF8String);\n}\n\n- (void)test_normal_compress\n{\n    [[Random shared] setStringType:RandomStringType_English];\n    TestCaseAssertTrue([self createObjectTable]);\n    auto preInsertObjects = [[Random shared] testCaseObjectsWithCount:2 startingFromIdentifier:1];\n    auto newInsertObjects = [[Random shared] testCaseObjectsWithCount:2 startingFromIdentifier:3];\n    TestCaseAssertTrue(self.table.insertObjects(preInsertObjects));\n\n    self.database->setCompression([](WCDB::Database::CompressionInfo& info) {\n        info.addZSTDNormalCompressField(WCDB_FIELD(CPPTestCaseObject::content));\n    });\n\n    bool tableCompressed = false;\n    bool databaseCompressed = false;\n    self.database->setNotificationWhenCompressed([&](WCDB::Database& database, WCDB::Optional<WCDB::StringView> table) {\n        TestCaseAssertEqual(database.getTag(), self.database->getTag());\n        TestCaseAssertCPPStringEqual(database.getPath().data(), self.database->getPath().data());\n        if (table.hasValue()) {\n            if (table.value().equal(self.tableName.UTF8String)) {\n                tableCompressed = true;\n            }\n        } else {\n            databaseCompressed = true;\n        }\n    });\n\n    TestCaseAssertFalse(self.database->isCompressed());\n    TestCaseAssertTrue(self.database->stepCompression());\n    TestCaseAssertTrue(self.database->stepCompression());\n    TestCaseAssertTrue(self.database->isCompressed());\n    TestCaseAssertTrue(tableCompressed && databaseCompressed);\n\n    TestCaseAssertTrue(self.table.insertObjects(newInsertObjects));\n    auto count = self.database->getValueFromStatement(WCDB::StatementSelect().select(WCDB::Column().count()).from(self.tableName.UTF8String).where(WCDB::Column(\"WCDB_CT_content\") == 4));\n    TestCaseAssertTrue(count.value() == 4);\n\n    preInsertObjects.insert(preInsertObjects.end(), newInsertObjects.begin(), newInsertObjects.end());\n\n    [self check:CPPMultiRowValueExtract(preInsertObjects)\n      isEqualTo:CPPMultiRowValueExtract([self getAllObjects])];\n\n    [[Random shared] setStringType:RandomStringType_Default];\n}\n\n- (void)test_dict_compress\n{\n    [[Random shared] setStringType:RandomStringType_English];\n    TestCaseAssertTrue([self createObjectTable]);\n    auto preInsertObjects = [[Random shared] testCaseObjectsWithCount:2 startingFromIdentifier:1];\n    auto newInsertObjects = [[Random shared] testCaseObjectsWithCount:2 startingFromIdentifier:3];\n    TestCaseAssertTrue(self.table.insertObjects(preInsertObjects));\n\n    std::vector<std::string> samples;\n    for (int i = 0; i < 1000; i++) {\n        samples.push_back(std::string([[Random shared] string].UTF8String));\n    }\n    auto dict = WCDB::Database::trainDict(samples, 1);\n    TestCaseAssertTrue(dict.succeed());\n    TestCaseAssertTrue(WCDB::Database::registerZSTDDict(dict.value(), 1));\n\n    self.database->setCompression([](WCDB::Database::CompressionInfo& info) {\n        info.addZSTDDictCompressField(WCDB_FIELD(CPPTestCaseObject::content), 1);\n    });\n\n    TestCaseAssertFalse(self.database->isCompressed());\n    TestCaseAssertTrue(self.database->stepCompression());\n    TestCaseAssertTrue(self.database->stepCompression());\n    TestCaseAssertTrue(self.database->isCompressed());\n\n    TestCaseAssertTrue(self.table.insertObjects(newInsertObjects));\n    auto count = self.database->getValueFromStatement(WCDB::StatementSelect().select(WCDB::Column().count()).from(self.tableName.UTF8String).where(WCDB::Column(\"WCDB_CT_content\") == 2));\n    TestCaseAssertTrue(count.value() == 4);\n\n    preInsertObjects.insert(preInsertObjects.end(), newInsertObjects.begin(), newInsertObjects.end());\n\n    [self check:CPPMultiRowValueExtract(preInsertObjects)\n      isEqualTo:CPPMultiRowValueExtract([self getAllObjects])];\n\n    [[Random shared] setStringType:RandomStringType_Default];\n}\n\n- (void)test_multi_dict_compress\n{\n    [[Random shared] setStringType:RandomStringType_English];\n    TestCaseAssertTrue([self createObjectTable]);\n    auto preInsertObjects = [[Random shared] testCaseObjectsWithCount:2 startingFromIdentifier:1];\n    auto newInsertObjects = [[Random shared] testCaseObjectsWithCount:2 startingFromIdentifier:3];\n    TestCaseAssertTrue(self.table.insertObjects(preInsertObjects));\n\n    std::vector<std::string> samples;\n    for (int i = 0; i < 1000; i++) {\n        samples.push_back(std::string([[Random shared] string].UTF8String));\n    }\n    auto dict = WCDB::Database::trainDict(samples, 2);\n    TestCaseAssertTrue(dict.succeed());\n    TestCaseAssertTrue(WCDB::Database::registerZSTDDict(dict.value(), 2));\n\n    samples.clear();\n    for (int i = 0; i < 1000; i++) {\n        samples.push_back(std::string([[Random shared] string].UTF8String));\n    }\n    auto dict2 = WCDB::Database::trainDict(samples, 3);\n    TestCaseAssertTrue(dict2.succeed());\n    TestCaseAssertTrue(WCDB::Database::registerZSTDDict(dict2.value(), 3));\n\n    samples.clear();\n    for (int i = 0; i < 1000; i++) {\n        samples.push_back(std::string([[Random shared] string].UTF8String));\n    }\n    auto dict3 = WCDB::Database::trainDict(samples, 4);\n    TestCaseAssertTrue(dict3.succeed());\n    TestCaseAssertTrue(WCDB::Database::registerZSTDDict(dict3.value(), 4));\n\n    self.database->setCompression([](WCDB::Database::CompressionInfo& info) {\n        info.addZSTDDictCompressField(WCDB_FIELD(CPPTestCaseObject::content), WCDB_FIELD(CPPTestCaseObject::identifier), { { 1, 2 }, { 2, 3 }, { WCDB::Database::DictDefaultMatchValue, 4 } });\n    });\n\n    TestCaseAssertFalse(self.database->isCompressed());\n    TestCaseAssertTrue(self.database->stepCompression());\n    TestCaseAssertTrue(self.database->stepCompression());\n    TestCaseAssertTrue(self.database->isCompressed());\n\n    TestCaseAssertTrue(self.table.insertObjects(newInsertObjects));\n    auto count = self.database->getValueFromStatement(WCDB::StatementSelect().select(WCDB::Column().count()).from(self.tableName.UTF8String).where(WCDB::Column(\"WCDB_CT_content\") == 2));\n    TestCaseAssertTrue(count.value() == 4);\n\n    preInsertObjects.insert(preInsertObjects.end(), newInsertObjects.begin(), newInsertObjects.end());\n\n    [self check:CPPMultiRowValueExtract(preInsertObjects)\n      isEqualTo:CPPMultiRowValueExtract([self getAllObjects])];\n\n    [[Random shared] setStringType:RandomStringType_Default];\n}\n\n- (void)test_load_all_data\n{\n    TestCaseAssertTrue([self createObjectTable]);\n    int objectCount = 0;\n    size_t minDBSize = 20 * 1024 * 1024;\n    size_t curDBSize = 0;\n    int batchCount = 10000;\n    auto des = WCDB_FIELD(CPPTestCaseObject::content).substr(0, 1).getDescription();\n    do {\n        TestCaseAssertTrue(self.table.insertObjects([Random.shared autoIncrementTestCaseObjectsWithCount:batchCount]));\n        TestCaseAssertTrue(self.database->truncateCheckpoint());\n        curDBSize = [self.fileManager getFileSizeIfExists:[NSString stringWithCString:self.database->getPath().data() encoding:NSUTF8StringEncoding]];\n        objectCount += batchCount;\n    } while (curDBSize < minDBSize);\n\n    self.database->close();\n    WCDB::Database::purgeAll();\n    TestCaseAssertTrue(self.database->canOpen());\n\n    NSDate* start = [NSDate date];\n    auto contents = self.table.selectOneColumn(WCDB_FIELD(CPPTestCaseObject::content).substr(0, 0));\n    TestCaseAssertTrue(contents.hasValue() && contents.value().size() == objectCount);\n    double cost1 = [[NSDate date] timeIntervalSinceDate:start];\n\n    self.database->close();\n    WCDB::Database::purgeAll();\n\n    self.database->setConfig(\"LoadAllData\", [](WCDB::Handle& handle) {\n        handle.tryPreloadAllPages();\n        return true;\n    });\n    TestCaseAssertTrue(self.database->canOpen());\n\n    start = [NSDate date];\n\n    contents = self.table.selectOneColumn(WCDB_FIELD(CPPTestCaseObject::content).substr(0, 0));\n    TestCaseAssertTrue(contents.hasValue() && contents.value().size() == objectCount);\n\n    double cost2 = [[NSDate date] timeIntervalSinceDate:start];\n\n    TestCaseAssertTrue(cost1 > cost2);\n}\n\n- (void)test_in_memory_db\n{\n    NSString* tableName = @\"testTable\";\n    {\n        auto database = WCDB::Database::createInMemoryDatabase();\n\n        auto object = [[Random shared] autoIncrementTestCaseObject];\n\n        TestCaseAssertTrue(database.createTable<CPPTestCaseObject>(tableName.UTF8String));\n        for (int i = 0; i < 100; i++) {\n            TestCaseAssertTrue(database.insertObject(object, tableName.UTF8String));\n        }\n        TestCaseAssertTrue(database.selectValue(CPPTestCaseObject::allFields().count(), tableName.UTF8String).value().intValue() == 100);\n        TestCaseAssertTrue(database.passiveCheckpoint());\n        database.close();\n        TestCaseAssertFalse([self.fileManager fileExistsAtPath:[NSString stringWithCString:database.getPath().data() encoding:NSUTF8StringEncoding]]);\n    }\n    {\n        auto database = WCDB::Database::createInMemoryDatabase();\n        TestCaseAssertTrue(database.selectValue(CPPTestCaseObject::allFields().count(), tableName.UTF8String).failed());\n    }\n}\n\n@end\n"
  },
  {
    "path": "src/cpp/tests/interface/CPPFileTests.mm",
    "content": "//\n// Created by qiuwenchen on 2022/8/10.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"CPPTestCase.h\"\n\n@interface CPPFileTests : CPPDatabaseTestCase\n\n@property (nonatomic, readonly) NSArray<NSString*>* dummyPaths;\n\n@end\n\n@implementation CPPFileTests\n\n- (void)setUp\n{\n    [super setUp];\n    _dummyPaths = [self allDummyPaths:self.path];\n}\n\n- (NSArray<NSString*>*)allDummyPaths:(NSString*)path\n{\n    return @[\n        path,\n        [path stringByAppendingString:@\"-wal\"],\n        [path stringByAppendingString:@\"-first.material\"],\n        [path stringByAppendingString:@\"-last.material\"],\n        [path stringByAppendingString:@\"-incremental.material\"],\n        [[path stringByAppendingString:@\".factory\"] stringByAppendingPathComponent:path.lastPathComponent],\n        [path stringByAppendingString:@\"-journal\"],\n        [path stringByAppendingString:@\"-shm\"],\n    ];\n}\n\n- (BOOL)createDummyFiles\n{\n    return [self createDummyFiles:[NSData data]];\n}\n\n- (BOOL)createDummyFiles:(NSData*)data\n{\n    if (data == nil) {\n        TestCaseFailure();\n        return NO;\n    }\n    for (NSString* path in self.dummyPaths) {\n        if (![self.fileManager createDirectoryAtPath:path.stringByDeletingLastPathComponent withIntermediateDirectories:YES attributes:nil error:nil]) {\n            TestCaseFailure();\n            return NO;\n        }\n        if ([self.fileManager fileExistsAtPath:path]) {\n            continue;\n        }\n        if (![self.fileManager createFileAtPath:path contents:data attributes:nil]) {\n            TestCaseFailure();\n            return NO;\n        }\n    }\n    return YES;\n}\n\n- (BOOL)allFilesExists\n{\n    return [self allFilesExists:[self getAllFilePaths]];\n}\n\n- (NSArray*)getAllFilePaths\n{\n    NSMutableArray* paths = [[NSMutableArray alloc] init];\n    for (const WCDB::UnsafeStringView& path : self.database->getPaths()) {\n        [paths addObject:[NSString stringWithUTF8String:path.data()]];\n    }\n    return paths;\n}\n\n- (BOOL)allFilesExists:(NSArray<NSString*>*)paths\n{\n    for (NSString* path in paths) {\n        if (![self.fileManager fileExistsAtPath:path]) {\n            TestCaseFailure();\n            return NO;\n        }\n    }\n    return YES;\n}\n\n- (BOOL)noneFilesExists\n{\n    return [self noneFilesExists:[self getAllFilePaths]];\n}\n\n- (BOOL)noneFilesExists:(NSArray<NSString*>*)paths\n{\n    for (NSString* path in paths) {\n        if ([self.fileManager fileExistsAtPath:path]) {\n            TestCaseFailure();\n            return NO;\n        }\n    }\n    return YES;\n}\n\n- (void)test_remove_files\n{\n    TestCaseAssertTrue([self createDummyFiles]);\n    TestCaseAssertTrue([self allFilesExists]);\n    TestCaseAssertTrue(self.database->canOpen());\n    TestCaseAssertTrue(self.database->isOpened());\n    TestCaseAssertTrue(self.database->removeFiles());\n    TestCaseAssertFalse(self.database->isOpened());\n    TestCaseAssertTrue([self noneFilesExists]);\n}\n\n- (void)test_move_files\n{\n    NSString* filename = self.path.lastPathComponent;\n\n    NSString* movedDirectory = [self.directory stringByAppendingPathComponent:@\"moved\"];\n    NSString* movedDatabase = [movedDirectory stringByAppendingPathComponent:filename];\n    NSArray<NSString*>* movedPaths = [self allDummyPaths:movedDatabase];\n\n    TestCaseAssertTrue([self noneFilesExists:movedPaths]);\n\n    TestCaseAssertTrue(self.database->canOpen());\n    TestCaseAssertTrue(self.database->isOpened());\n\n    TestCaseAssertTrue([self createDummyFiles]);\n    TestCaseAssertTrue([self allFilesExists:self.dummyPaths]);\n    TestCaseAssertTrue(self.database->moveFiles(movedDirectory.UTF8String));\n\n    TestCaseAssertFalse(self.database->isOpened());\n    TestCaseAssertTrue([self noneFilesExists:self.dummyPaths]);\n    TestCaseAssertTrue([self allFilesExists:movedPaths]);\n}\n\n- (void)test_files_size\n{\n    NSData* dummyData = [@\"testData\" dataUsingEncoding:NSUTF8StringEncoding];\n    TestCaseAssertTrue([self createDummyFiles:dummyData]);\n    NSInteger fileSize = self.database->getFilesSize().value();\n    TestCaseAssertEqual(fileSize, dummyData.length * self.dummyPaths.count);\n}\n\n- (void)test_files_size_failed\n{\n    NSData* dummyData = [@\"testData\" dataUsingEncoding:NSUTF8StringEncoding];\n\n    // bad guy\n    TestCaseAssertTrue([self.fileManager removeItemAtPath:self.directory error:nil]);\n    TestCaseAssertTrue([self.fileManager createFileAtPath:self.directory contents:dummyData attributes:nil]);\n\n    auto fileSizeOptional = self.database->getFilesSize();\n    TestCaseAssertTrue(!fileSizeOptional.succeed());\n}\n\n- (void)test_feature_auto_create_immediate_directory\n{\n    NSString* directory = [[[[[[self.directory stringByAppendingPathComponent:@\"immediate\"] stringByAppendingPathComponent:@\"directory\"] stringByAppendingPathComponent:@\"will\"] stringByAppendingPathComponent:@\"be\"] stringByAppendingPathComponent:@\"created\"] stringByAppendingPathComponent:@\"automatically\"];\n    NSString* path = [directory stringByAppendingPathComponent:self.path.lastPathComponent];\n\n    WCDB::Database database(path.UTF8String);\n    TestCaseAssertTrue(database.canOpen());\n\n    BOOL isDirectory = NO;\n    TestCaseAssertTrue([self.fileManager fileExistsAtPath:directory isDirectory:&isDirectory]);\n    TestCaseAssertTrue(isDirectory);\n}\n\n- (void)test_feature_path_normalized\n{\n    NSString* path = [self.directory stringByAppendingString:@\"//directory//database\"];\n    WCDB::Database database(path.UTF8String);\n    TestCaseAssertTrue(database.canOpen());\n\n    NSString* normalizedPath = [[[NSString stringWithFormat:@\"%@\", self.directory] stringByAppendingPathComponent:@\"directory\"] stringByAppendingPathComponent:@\"database\"];\n    TestCaseAssertTrue([[NSString stringWithUTF8String:database.getPath().data()] isEqualToString:normalizedPath]);\n}\n\n@end\n"
  },
  {
    "path": "src/cpp/tests/interface/CPPHandleTest.mm",
    "content": "//\n// Created by 陈秋文 on 2023/8/13.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"CPPTestCase.h\"\n#import <Foundation/Foundation.h>\n\n@interface CPPHandleTests : CPPTableTestCase\n\n@end\n\n@implementation CPPHandleTests\n\n- (void)test_cancellation_signal\n{\n    TestCaseAssertTrue([self createValueTable]);\n    WCDB::MultiRowsValue rows = [Random.shared testCaseValuesWithCount:10000 startingFromIdentifier:0];\n    TestCaseAssertTrue(self.database->insertRows(rows, self.columns, self.tableName.UTF8String));\n    bool hasTestInterrupt = false;\n    self.database->traceError([&](const WCDB::Error &error) {\n        if (error.level != WCDB::Error::Level::Error) {\n            return;\n        }\n        XCTAssertTrue(error.code() == WCDB::Error::Code::Interrupt);\n        hasTestInterrupt = true;\n    });\n    WCDB::Handle::CancellationSignal signal;\n    [self.dispatch async:^{\n        WCDB::Handle handle = self.database->getHandle();\n        handle.attachCancellationSignal(signal);\n        auto allRows = handle.selectAllRow(self.columns, self.tableName.UTF8String);\n        XCTAssertFalse(allRows.succeed());\n        handle.invalidate();\n    }];\n    usleep(10000);\n    signal.cancel();\n    [self.dispatch waitUntilDone];\n    TestCaseAssertTrue(hasTestInterrupt);\n    self.database->traceSQL(nullptr);\n}\n\n- (void)test_write_with_handle_count_limit\n{\n    int maxHandleCount = 0;\n    WCDB::Database::globalTraceDatabaseOperation([&](WCDB::Database &,\n                                                     WCDB::Database::Operation operationType,\n                                                     WCDB::StringViewMap<WCDB::Value> &info) {\n        if (operationType != WCDB::Database::Operation::OpenHandle) {\n            return;\n        }\n        auto iter = info.find(WCDB::Database::MonitorInfoKeyHandleCount);\n        if (iter != info.end()) {\n            maxHandleCount = std::max(maxHandleCount, (int) iter->second.intValue());\n        }\n    });\n    TestCaseAssertTrue([self createObjectTable]);\n    auto table = self.table;\n    for (int i = 0; i < 40; i++) {\n        [self.dispatch async:^{\n            switch (i % 4) {\n            case 0: {\n                auto objects = [Random.shared testCaseObjectsWithCount:100 startingFromIdentifier:i * 100];\n                TestCaseAssertTrue(self.table.insertObjects(objects));\n            } break;\n            case 1: {\n                TestCaseAssertTrue(self.table.updateRow(\"abc\", WCDB_FIELD(CPPTestCaseObject::content), WCDB_FIELD(CPPTestCaseObject::identifier) > (i - 1) * 100 && WCDB_FIELD(CPPTestCaseObject::identifier) <= i * 100));\n            } break;\n            case 2: {\n                TestCaseAssertTrue(self.table.deleteObjects(WCDB_FIELD(CPPTestCaseObject::identifier) > ((i - 2) * 100 + 50) && WCDB_FIELD(CPPTestCaseObject::identifier) <= i * 100));\n            } break;\n            case 3: {\n                TestCaseAssertTrue(self.database->runTransaction([&](WCDB::Handle &) {\n                    return self.table.updateRow(\"abc2\", WCDB_FIELD(CPPTestCaseObject::content), WCDB_FIELD(CPPTestCaseObject::identifier) > (i - 1) * 100 && WCDB_FIELD(CPPTestCaseObject::identifier) <= i * 100);\n                }));\n            } break;\n\n            default:\n                break;\n            }\n            usleep(100000);\n        }];\n    }\n    [self.dispatch waitUntilDone];\n    TestCaseAssertTrue(maxHandleCount <= 4);\n    WCDB::Database::globalTraceDatabaseOperation(nullptr);\n}\n\n- (void)test_read_with_handle_count_limit\n{\n    int maxHandleCount = 0;\n    WCDB::Database::globalTraceDatabaseOperation([&](WCDB::Database &,\n                                                     WCDB::Database::Operation operationType,\n                                                     WCDB::StringViewMap<WCDB::Value> &info) {\n        if (operationType != WCDB::Database::Operation::OpenHandle) {\n            return;\n        }\n        auto iter = info.find(WCDB::Database::MonitorInfoKeyHandleCount);\n        if (iter != info.end()) {\n            maxHandleCount = std::max(maxHandleCount, (int) iter->second.intValue());\n        }\n    });\n    TestCaseAssertTrue([self createObjectTable]);\n    auto objects = [Random.shared testCaseObjectsWithCount:32000 startingFromIdentifier:0];\n    TestCaseAssertTrue(self.table.insertObjects(objects));\n\n    for (int i = 0; i < 320; i++) {\n        [self.dispatch async:^{\n            switch (i % 5) {\n            case 0: {\n                auto ret = self.table.getAllObjects(WCDB::Expression(), WCDB::OrderingTerms(), 100, i * 100);\n                TestCaseAssertTrue(ret.valueOrDefault().size() == 100);\n            } break;\n            case 1: {\n                auto value = self.database->getValueFromStatement(WCDB::StatementSelect().select(CPPTestCaseObject::allFields().count()).from(self.tableName.UTF8String));\n                TestCaseAssertTrue(value.valueOrDefault().intValue() == 32000);\n            } break;\n            case 2: {\n                auto column = self.table.selectOneColumn(WCDB_FIELD(CPPTestCaseObject::content), WCDB::Expression(), WCDB::OrderingTerms(), 100, i * 100);\n                TestCaseAssertTrue(column.valueOrDefault().size() == 100);\n            } break;\n            case 3: {\n                auto rows = self.table.selectAllRow(CPPTestCaseObject::allFields(), WCDB::Expression(), WCDB::OrderingTerms(), 100, i * 100);\n                TestCaseAssertTrue(rows.valueOrDefault().size() == 100);\n            } break;\n            case 4: {\n                auto row = self.table.selectOneRow(CPPTestCaseObject::allFields(), WCDB::Expression(), WCDB_FIELD(CPPTestCaseObject::identifier).asOrder(WCDB::Order::DESC));\n                TestCaseAssertTrue(row.valueOrDefault().size() == 2);\n            } break;\n\n            default:\n                break;\n            }\n\n            usleep(100000);\n        }];\n    }\n\n    [self.dispatch waitUntilDone];\n    TestCaseAssertTrue(maxHandleCount > 4 && maxHandleCount <= 32);\n    WCDB::Database::globalTraceDatabaseOperation(nullptr);\n}\n\n- (void)test_read_write_with_handle_count_limit\n{\n    int maxHandleCount = 0;\n    WCDB::Database::globalTraceDatabaseOperation([&](WCDB::Database &,\n                                                     WCDB::Database::Operation operationType,\n                                                     WCDB::StringViewMap<WCDB::Value> &info) {\n        if (operationType != WCDB::Database::Operation::OpenHandle) {\n            return;\n        }\n        auto iter = info.find(WCDB::Database::MonitorInfoKeyHandleCount);\n        if (iter != info.end()) {\n            maxHandleCount = std::max(maxHandleCount, (int) iter->second.intValue());\n        }\n    });\n\n    TestCaseAssertTrue([self createObjectTable]);\n    auto objects = [Random.shared testCaseObjectsWithCount:32000 startingFromIdentifier:0];\n    TestCaseAssertTrue(self.table.insertObjects(objects));\n\n    for (int i = 0; i < 320; i++) {\n        if (i % 8 == 0) {\n            [self.dispatch async:^{\n                auto newObjects = [Random.shared testCaseObjectsWithCount:100 startingFromIdentifier:i * 100 + 32000];\n                TestCaseAssertTrue(self.table.insertObjects(newObjects));\n                usleep(100000);\n            }];\n        } else {\n            [self.dispatch async:^{\n                auto ret = self.table.getAllObjects(WCDB::Expression(), WCDB::OrderingTerms(), 100, i * 100);\n                TestCaseAssertTrue(ret.hasValue() && ret.value().size() == 100);\n                usleep(100000);\n            }];\n        }\n    }\n\n    [self.dispatch waitUntilDone];\n    TestCaseAssertTrue(maxHandleCount > 4 && maxHandleCount <= 32);\n    WCDB::Database::globalTraceDatabaseOperation(nullptr);\n}\n\n@end\n"
  },
  {
    "path": "src/cpp/tests/interface/CPPTableTest.mm",
    "content": "//\n// Created by qiuwenchen on 2023/10/27.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import <Foundation/Foundation.h>\n\n#import \"CPPTestCase.h\"\n\n@interface CPPTableTests : CPPTableTestCase\n\n@end\n\n@implementation CPPTableTests\n\n- (void)test_table_name\n{\n    TestCaseAssertCPPStringEqual(self.table.getTableName().data(), self.tableName.UTF8String);\n}\n\n- (void)test_database\n{\n    TestCaseAssertCPPStringEqual(self.table.getDatabase().getPath().data(), self.path.UTF8String);\n}\n\n@end\n"
  },
  {
    "path": "src/cpp/tests/interface/CPPTraceTest.mm",
    "content": "//\n// Created by qiuwenchen on 2022/8/13.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"CPPTestCase.h\"\n\n@interface CPPTraceTests : CPPTableTestCase\n\n@end\n\n@implementation CPPTraceTests\n\n- (void)test_trace_sql\n{\n    WCDB::StatementPragma statement = WCDB::StatementPragma().pragma(WCDB::Pragma::userVersion());\n\n    BOOL tested = NO;\n    self.database->traceSQL([&](long tag, const WCDB::UnsafeStringView &path, const void *, const WCDB::UnsafeStringView &sql, const WCDB::UnsafeStringView &) {\n        XCTAssertEqual(tag, self.database->getTag());\n        XCTAssertTrue(path.equal(self.database->getPath()));\n        if (strcmp(sql.data(), statement.getDescription().data()) == 0) {\n            tested = YES;\n        }\n    });\n    TestCaseAssertTrue(self.database->execute(statement));\n    TestCaseAssertTrue(tested);\n\n    self.database->traceSQL(nullptr);\n}\n\n- (void)test_trace_performance\n{\n    TestCaseAssertTrue([self createObjectTable]);\n\n    std::vector<CPPTestCaseObject> objects;\n    for (int i = 0; i < 1000; i++) {\n        objects.emplace_back(0, [Random.shared stringWithLength:4096].UTF8String);\n        objects.back().isAutoIncrement = true;\n    }\n    int testCount = 0;\n    self.database->tracePerformance(nullptr);\n    self.database->tracePerformance([&](long tag, const WCDB::UnsafeStringView &path, uint64_t, const WCDB::UnsafeStringView &sql, const WCDB::Database::PerformanceInfo &info) {\n        XCTAssertEqual(tag, self.database->getTag());\n        XCTAssertTrue(path.equal(self.database->getPath()));\n        if (sql.hasPrefix(\"COMMIT\")) {\n            XCTAssertTrue(info.costInNanoseconds > 0);\n            XCTAssertTrue(info.tablePageWriteCount > 0);\n            XCTAssertTrue(info.indexPageWriteCount == 0);\n            XCTAssertTrue(info.overflowPageWriteCount > 0);\n            XCTAssertTrue(info.tablePageReadCount == 0);\n            XCTAssertTrue(info.indexPageReadCount == 0);\n            XCTAssertTrue(info.overflowPageReadCount == 0);\n            testCount++;\n        } else if (sql.hasPrefix(\"CREATE INDEX\")) {\n            XCTAssertTrue(info.costInNanoseconds > 0);\n            XCTAssertTrue(info.tablePageWriteCount == 1);\n            XCTAssertTrue(info.indexPageWriteCount > 0);\n            XCTAssertTrue(info.overflowPageWriteCount == objects.size());\n            XCTAssertTrue(info.tablePageReadCount > 0);\n            XCTAssertTrue(info.indexPageReadCount >= 0);\n            XCTAssertTrue(info.overflowPageReadCount == objects.size());\n            testCount++;\n        } else if (sql.hasPrefix(\"SELECT\")) {\n            XCTAssertTrue(info.costInNanoseconds > 0);\n            XCTAssertTrue(info.tablePageWriteCount == 0);\n            XCTAssertTrue(info.indexPageWriteCount == 0);\n            XCTAssertTrue(info.overflowPageWriteCount == 0);\n            testCount++;\n            if (sql.hasSuffix(\"ORDER BY content\")) {\n                XCTAssertTrue(info.tablePageReadCount == 0);\n                XCTAssertTrue(info.indexPageReadCount > 0);\n                XCTAssertTrue(info.overflowPageReadCount == objects.size());\n            } else {\n                XCTAssertTrue(info.tablePageReadCount > 0);\n                XCTAssertTrue(info.indexPageReadCount == 0);\n                XCTAssertTrue(info.overflowPageReadCount == objects.size());\n            }\n        }\n    });\n    TestCaseAssertTrue(self.table.insertObjects(objects));\n    TestCaseAssertTrue(self.database->execute(WCDB::StatementCreateIndex().createIndex(\"testIndex\").table(self.tableName).indexed(WCDB_FIELD(CPPTestCaseObject::content))));\n    TestCaseAssertTrue(self.table.getAllObjects().value().size() == objects.size());\n    TestCaseAssertTrue(self.table.getAllObjects(WCDB::Expression(), WCDB_FIELD(CPPTestCaseObject::content)).value().size() == objects.size());\n    TestCaseAssertTrue(testCount == 4);\n    self.database->tracePerformance(nil);\n}\n\n- (void)test_global_trace_error\n{\n    BOOL tested = NO;\n    WCDB::Database::globalTraceError(nullptr);\n    WCDB::Database::globalTraceError([&](const WCDB::Error &error) {\n        if (error.level == WCDB::Error::Level::Error\n            && strcmp(error.getPath().data(), self.path.UTF8String) == 0\n            && error.getTag().value() == self.database->getTag()\n            && error.code() == WCDB::Error::Code::Error\n            && strcmp(error.getSQL().data(), \"SELECT 1 FROM dummy\") == 0) {\n            tested = YES;\n        }\n    });\n\n    TestCaseAssertTrue(self.database->canOpen());\n    TestCaseAssertFalse(self.database->execute(WCDB::StatementSelect().select(1).from(\"dummy\")));\n    TestCaseAssertTrue(tested);\n}\n\n- (void)test_trace_error\n{\n    BOOL tested = NO;\n    self.database->traceError([&](const WCDB::Error &error) {\n        TestCaseAssertCPPStringEqual(error.getPath().data(), self.path.UTF8String);\n        TestCaseAssertEqual(error.getTag().value(), self.database->getTag());\n        if (error.level == WCDB::Error::Level::Error\n            && error.code() == WCDB::Error::Code::Error\n            && strcmp(error.getSQL().data(), \"SELECT 1 FROM dummy\") == 0) {\n            tested = YES;\n        }\n    });\n\n    TestCaseAssertTrue(self.database->canOpen());\n    TestCaseAssertFalse(self.database->execute(WCDB::StatementSelect().select(1).from(\"dummy\")));\n    TestCaseAssertTrue(tested);\n}\n\n- (void)test_global_trace_sql\n{\n    WCDB::StatementPragma statement = WCDB::StatementPragma().pragma(WCDB::Pragma::userVersion());\n\n    BOOL tested = NO;\n    WCDB::Database::globalTraceSQL([&](long tag, const WCDB::UnsafeStringView &path, const void *, const WCDB::UnsafeStringView &sql, const WCDB::UnsafeStringView &) {\n        if (!path.equal(self.database->getPath())) {\n            return;\n        }\n        XCTAssertEqual(tag, self.database->getTag());\n        if (strcmp(sql.data(), statement.getDescription().data()) == 0) {\n            tested = YES;\n        }\n    });\n    TestCaseAssertTrue(self.database->execute(statement));\n    TestCaseAssertTrue(tested);\n\n    WCDB::Database::globalTraceError(nullptr);\n}\n\n- (void)test_global_trace_performance\n{\n    std::vector<CPPTestCaseObject> objects;\n    for (int i = 0; i < 1000; i++) {\n        objects.emplace_back(0, [Random.shared stringWithLength:4096].UTF8String);\n        objects.back().isAutoIncrement = true;\n    }\n    int testCount = 0;\n    bool lastSQLIsInsert = false;\n    WCDB::Database::globalTracePerformance([&](long tag, const WCDB::UnsafeStringView &path, uint64_t, const WCDB::UnsafeStringView &sql, const WCDB::Database::PerformanceInfo &info) {\n        if (!path.equal(self.database->getPath())) {\n            return;\n        }\n        XCTAssertEqual(tag, self.database->getTag());\n        XCTAssertTrue(path.equal(self.database->getPath()));\n        if (sql.hasPrefix(\"COMMIT\") && lastSQLIsInsert) {\n            XCTAssertTrue(info.costInNanoseconds > 0);\n            XCTAssertTrue(info.tablePageWriteCount > 0);\n            XCTAssertTrue(info.indexPageWriteCount == 0);\n            XCTAssertTrue(info.overflowPageWriteCount > 0);\n            XCTAssertTrue(info.tablePageReadCount == 0);\n            XCTAssertTrue(info.indexPageReadCount == 0);\n            XCTAssertTrue(info.overflowPageReadCount == 0);\n            testCount++;\n        } else if (sql.hasPrefix(\"CREATE INDEX\")) {\n            XCTAssertTrue(info.costInNanoseconds > 0);\n            XCTAssertTrue(info.tablePageWriteCount == 1);\n            XCTAssertTrue(info.indexPageWriteCount > 0);\n            XCTAssertTrue(info.overflowPageWriteCount == objects.size());\n            XCTAssertTrue(info.tablePageReadCount > 0);\n            XCTAssertTrue(info.indexPageReadCount >= 0);\n            XCTAssertTrue(info.overflowPageReadCount == objects.size());\n            testCount++;\n        } else if (sql.hasPrefix(\"SELECT\")) {\n            XCTAssertTrue(info.costInNanoseconds > 0);\n            XCTAssertTrue(info.tablePageWriteCount == 0);\n            XCTAssertTrue(info.indexPageWriteCount == 0);\n            XCTAssertTrue(info.overflowPageWriteCount == 0);\n            testCount++;\n            if (sql.hasSuffix(\"ORDER BY content\")) {\n                XCTAssertTrue(info.tablePageReadCount == 0);\n                XCTAssertTrue(info.indexPageReadCount > 0);\n                XCTAssertTrue(info.overflowPageReadCount == objects.size());\n            } else {\n                XCTAssertTrue(info.tablePageReadCount > 0);\n                XCTAssertTrue(info.indexPageReadCount == 0);\n                XCTAssertTrue(info.overflowPageReadCount == objects.size());\n            }\n        }\n        lastSQLIsInsert = sql.hasPrefix(\"INSERT\");\n    });\n    TestCaseAssertTrue([self createObjectTable]);\n    TestCaseAssertTrue(self.table.insertObjects(objects));\n    TestCaseAssertTrue(self.database->execute(WCDB::StatementCreateIndex().createIndex(\"testIndex\").table(self.tableName).indexed(WCDB_FIELD(CPPTestCaseObject::content))));\n    TestCaseAssertTrue(self.table.getAllObjects().value().size() == objects.size());\n    TestCaseAssertTrue(self.table.getAllObjects(WCDB::Expression(), WCDB_FIELD(CPPTestCaseObject::content)).value().size() == objects.size());\n    TestCaseAssertTrue(testCount == 4);\n    WCDB::Database::globalTracePerformance(nil);\n}\n\n- (void)test_trace_db_operation\n{\n    long tag = 0;\n    WCDB::StringView path;\n    int openHandleCount = 0;\n    int tableCount = 0;\n    int indexCount = 0;\n    WCDB::Database::globalTraceDatabaseOperation([&](WCDB::Database &database,\n                                                     WCDB::Database::Operation operation,\n                                                     WCDB::StringViewMap<WCDB::Value> &info) {\n        switch (operation) {\n        case WCDB::Database::Operation::Create:\n            path = database.getPath();\n            break;\n        case WCDB::Database::Operation::SetTag:\n            tag = database.getTag();\n            break;\n        case WCDB::Database::Operation::OpenHandle: {\n            openHandleCount++;\n            TestCaseAssertTrue(info[WCDB::Database::MonitorInfoKeyHandleCount].intValue() == 1);\n            TestCaseAssertTrue(info[WCDB::Database::MonitorInfoKeyHandleOpenTime].intValue() > 0);\n            TestCaseAssertTrue(info[WCDB::Database::MonitorInfoKeyHandleOpenCPUTime].intValue() > 0);\n            TestCaseAssertTrue(info[WCDB::Database::MonitorInfoKeySchemaUsage].intValue() > 0);\n            TestCaseAssertTrue(info[WCDB::Database::MonitorInfoKeyTriggerCount].intValue() == 0);\n            tableCount = (int) info[WCDB::Database::MonitorInfoKeyTableCount].intValue();\n            indexCount = (int) info[WCDB::Database::MonitorInfoKeyIndexCount].intValue();\n        } break;\n        }\n    });\n    TestCaseAssertTrue([self createValueTable]);\n    TestCaseAssertTrue(self.database->execute(WCDB::StatementCreateIndex()\n                                              .createIndex(\"testIndex\")\n                                              .table(self.tableName)\n                                              .indexed(WCDB_FIELD(CPPTestCaseObject::content))));\n\n    TestCaseAssertTrue(tag = self.database->getTag());\n    TestCaseAssertCPPStringEqual(path.data(), self.database->getPath().data());\n    TestCaseAssertTrue(openHandleCount == 1);\n\n    self.database->close();\n    TestCaseAssertTrue(self.database->insertRows([Random.shared autoIncrementTestCaseValuesWithCount:10], self.columns, self.tableName.UTF8String));\n\n    TestCaseAssertTrue(openHandleCount == 2);\n    TestCaseAssertTrue(tableCount == 4);\n    TestCaseAssertTrue(indexCount == 1);\n    WCDB::Database::globalTraceDatabaseOperation(nullptr);\n}\n\n- (void)test_global_trace_busy\n{\n    uint64_t testTid = 0;\n    WCDB::Database::globalTraceBusy([&](long tag, const WCDB::UnsafeStringView &path, uint64_t tid, const WCDB::UnsafeStringView &sql) {\n        XCTAssertTrue(tag == self.database->getTag());\n        TestCaseAssertCPPStringEqual(path.data(), self.database->getPath().data());\n        TestCaseAssertCPPStringEqual(sql.data(), \"INSERT INTO testTable(identifier, content) VALUES(?1, ?2)\");\n        testTid = tid;\n    },\n                                    0.1);\n\n    XCTAssertTrue([self createObjectTable]);\n    __block uint64_t dispatchTid = 0;\n    auto objects = [Random.shared testCaseObjectsWithCount:100000 startingFromIdentifier:1];\n    [self.dispatch async:^{\n        pthread_threadid_np(nullptr, &dispatchTid);\n        XCTAssertTrue(self.table.insertObjects(objects));\n    }];\n    usleep(100000);\n    XCTAssertTrue(self.table.insertObjects([Random.shared autoIncrementTestCaseObject]));\n\n    [self.dispatch waitUntilDone];\n    XCTAssertTrue(testTid != 0 && testTid == dispatchTid);\n    WCDB::Database::globalTraceBusy(nullptr, 0);\n}\n\n@end\n"
  },
  {
    "path": "src/cpp/tests/operation/ChainCallTests.mm",
    "content": "//\n// Created by qiuwenchen on 2022/9/8.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"CPPTestCase.h\"\n\n@interface ChainCallTests : CPPCRUDTestCase\n@property (nonatomic, strong) NSString* tableName2;\n@end\n\n@implementation ChainCallTests\n\n- (void)setUp\n{\n    [super setUp];\n    self.tableName2 = @\"testTable2\";\n}\n\n#pragma mark - Delete\n- (void)test_database_delete\n{\n    WCDB::Delete delete_ = self.database->prepareDelete().fromTable(self.tableName.UTF8String);\n    TestCaseAssertSQLEqual(delete_.getStatement(), @\"DELETE FROM testTable\");\n}\n\n- (void)test_table_delete\n{\n    WCDB::Delete delete_ = self.table.prepareDelete();\n    TestCaseAssertSQLEqual(delete_.getStatement(), @\"DELETE FROM testTable\");\n}\n\n- (void)test_handle_delete\n{\n    WCDB::Delete delete_ = self.database->getHandle().prepareDelete().fromTable(self.tableName.UTF8String);\n    TestCaseAssertSQLEqual(delete_.getStatement(), @\"DELETE FROM testTable\");\n}\n\n#pragma mark - Insert\n- (void)test_database_insert\n{\n    WCDB::Insert<CPPTestCaseObject> insert = self.database->prepareInsert<CPPTestCaseObject>().intoTable(self.tableName.UTF8String).onFields(CPPTestCaseObject::allFields());\n    TestCaseAssertSQLEqual(insert.getStatement(), @\"INSERT INTO testTable(identifier, content) VALUES(?1, ?2)\");\n}\n\n- (void)test_table_insert\n{\n    WCDB::Insert<CPPTestCaseObject> insert = self.table.prepareInsert().onFields(CPPTestCaseObject::allFields());\n    TestCaseAssertSQLEqual(insert.getStatement(), @\"INSERT INTO testTable(identifier, content) VALUES(?1, ?2)\");\n}\n\n- (void)test_handle_insert\n{\n    WCDB::Insert<CPPTestCaseObject> insert = self.database->getHandle().prepareInsert<CPPTestCaseObject>().intoTable(self.tableName.UTF8String).onFields(CPPTestCaseObject::allFields());\n    TestCaseAssertSQLEqual(insert.getStatement(), @\"INSERT INTO testTable(identifier, content) VALUES(?1, ?2)\");\n}\n\n#pragma mark - Update\n- (void)test_database_update\n{\n    WCDB::Update<CPPTestCaseObject> update = self.database->prepareUpdate<CPPTestCaseObject>().table(self.tableName.UTF8String).set(WCDB_FIELD(CPPTestCaseObject::content));\n    TestCaseAssertSQLEqual(update.getStatement(), @\"UPDATE testTable SET content = ?1\");\n}\n\n- (void)test_table_update\n{\n    WCDB::Update<CPPTestCaseObject> update = self.table.prepareUpdate().set(WCDB_FIELD(CPPTestCaseObject::content));\n    TestCaseAssertSQLEqual(update.getStatement(), @\"UPDATE testTable SET content = ?1\");\n}\n\n- (void)test_handle_update\n{\n    WCDB::Update<CPPTestCaseObject> update = self.database->getHandle().prepareUpdate<CPPTestCaseObject>().table(self.tableName.UTF8String).set(WCDB_FIELD(CPPTestCaseObject::content));\n    TestCaseAssertSQLEqual(update.getStatement(), @\"UPDATE testTable SET content = ?1\");\n}\n\n#pragma mark - Select\n- (void)test_database_select\n{\n    WCDB::Select<CPPTestCaseObject> select = self.database->prepareSelect<CPPTestCaseObject>().fromTable(self.tableName.UTF8String).onResultFields(CPPTestCaseObject::allFields()).where(WCDB_FIELD(CPPTestCaseObject::identifier) == 1);\n    TestCaseAssertSQLEqual(select.getStatement(), @\"SELECT identifier, content FROM testTable WHERE identifier == 1\");\n}\n\n- (void)test_table_select\n{\n    WCDB::Select<CPPTestCaseObject> select = self.table.prepareSelect().onResultFields(CPPTestCaseObject::allFields()).where(WCDB_FIELD(CPPTestCaseObject::identifier) == 1);\n    TestCaseAssertSQLEqual(select.getStatement(), @\"SELECT identifier, content FROM testTable WHERE identifier == 1\");\n}\n\n- (void)test_handle_select\n{\n    WCDB::Select<CPPTestCaseObject> select = self.database->getHandle().prepareSelect<CPPTestCaseObject>().fromTable(self.tableName.UTF8String).onResultFields(CPPTestCaseObject::allFields()).where(WCDB_FIELD(CPPTestCaseObject::identifier) == 1);\n    TestCaseAssertSQLEqual(select.getStatement(), @\"SELECT identifier, content FROM testTable WHERE identifier == 1\");\n}\n\n#pragma mark - MultiSelect\n- (void)test_database_multiselect\n{\n    WCDB::ResultFields resultColumns\n    = CPPTestCaseObject::allFields()\n      .redirect([self](const WCDB::Field& field) -> WCDB::ResultColumn {\n          return field.table(self.tableName.UTF8String);\n      })\n      .addingNewResultColumns(CPPTestCaseObject::allFields().redirect([self](const WCDB::Field& field) -> WCDB::ResultColumn {\n          return field.table(self.tableName2.UTF8String);\n      }));\n    WCDB::MultiSelect select = self.database->prepareMultiSelect().onResultFields(resultColumns).fromTables({ self.tableName.UTF8String, self.tableName2.UTF8String }).where(WCDB_FIELD(CPPTestCaseObject::identifier).table(self.tableName.UTF8String) == WCDB_FIELD(CPPTestCaseObject::identifier).table(self.tableName2.UTF8String));\n    TestCaseAssertSQLEqual(select.getStatement(), @\"SELECT testTable.identifier, testTable.content, testTable2.identifier, testTable2.content FROM testTable, testTable2 WHERE testTable.identifier == testTable2.identifier\");\n}\n\n- (void)test_handle_multiselect\n{\n    WCDB::ResultFields resultColumns\n    = CPPTestCaseObject::allFields()\n      .redirect([self](const WCDB::Field& field) -> WCDB::ResultColumn {\n          return field.table(self.tableName.UTF8String);\n      })\n      .addingNewResultColumns(CPPTestCaseObject::allFields().redirect([self](const WCDB::Field& field) -> WCDB::ResultColumn {\n          return field.table(self.tableName2.UTF8String);\n      }));\n    WCDB::MultiSelect select = self.database->getHandle().prepareMultiSelect().onResultFields(resultColumns).fromTables({ self.tableName.UTF8String, self.tableName2.UTF8String }).where(WCDB_FIELD(CPPTestCaseObject::identifier).table(self.tableName.UTF8String) == WCDB_FIELD(CPPTestCaseObject::identifier).table(self.tableName2.UTF8String));\n    TestCaseAssertSQLEqual(select.getStatement(), @\"SELECT testTable.identifier, testTable.content, testTable2.identifier, testTable2.content FROM testTable, testTable2 WHERE testTable.identifier == testTable2.identifier\");\n}\n\n@end\n"
  },
  {
    "path": "src/cpp/tests/operation/HandleOperationTests.mm",
    "content": "//\n// Created by qiuwenchen on 2022/8/15.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"CPPTestCase.h\"\n\n@interface HandleOperationTests : CPPCRUDTestCase\n\n@property (nonatomic, assign) std::shared_ptr<WCDB::Handle> handle;\n\n@end\n\n@implementation HandleOperationTests\n\n- (void)setUp\n{\n    [super setUp];\n    self.handle = std::make_shared<WCDB::Handle>(self.database->getHandle());\n    [self insertPresetRows];\n}\n\n- (void)tearDown\n{\n    if (_handle->isPrepared()) {\n        _handle->finalize();\n    }\n    _handle = nil;\n    [super tearDown];\n}\n\n#pragma mark - handle\n- (void)test_handle_insert_row\n{\n    WCDB::OneRowValue row = [Random.shared testCaseValuesWithCount:1 startingFromIdentifier:[self nextIdentifier]][0];\n    [self doTestSQLs:@[ @\"INSERT INTO testTable(identifier, content) VALUES(?1, ?2)\" ]\n         inOperation:^BOOL {\n             return self.handle->insertRows(row, self.columns, self.tableName.UTF8String);\n         }];\n    TestCaseAssertTrue([self allRowsCount] == 3);\n}\n\n- (void)test_handle_insert_or_replace_row\n{\n    WCDB::OneRowValue row = [Random.shared testCaseValuesWithCount:1 startingFromIdentifier:[self nextIdentifier] - 1][0];\n    [self doTestSQLs:@[ @\"INSERT OR REPLACE INTO testTable(identifier, content) VALUES(?1, ?2)\" ]\n         inOperation:^BOOL {\n             return self.handle->insertOrReplaceRows(row, self.columns, self.tableName.UTF8String);\n         }];\n    TestCaseAssertTrue([self allRowsCount] == 2);\n}\n\n- (void)test_handle_insert_or_ignore_row\n{\n    WCDB::OneRowValue row = [Random.shared testCaseValuesWithCount:1 startingFromIdentifier:[self nextIdentifier] - 1][0];\n    [self doTestSQLs:@[ @\"INSERT OR IGNORE INTO testTable(identifier, content) VALUES(?1, ?2)\" ]\n         inOperation:^BOOL {\n             return self.handle->insertOrIgnoreRows(row, self.columns, self.tableName.UTF8String);\n         }];\n    TestCaseAssertTrue([self allRowsCount] == 2);\n}\n\n- (void)test_handle_insert_multi_rows\n{\n    WCDB::MultiRowsValue rows = [Random.shared testCaseValuesWithCount:2 startingFromIdentifier:[self nextIdentifier]];\n    self.expectMode = DatabaseTestCaseExpectSomeSQLs;\n    [self doTestSQLs:@[ @\"BEGIN IMMEDIATE\",\n                        @\"INSERT INTO testTable(identifier, content) VALUES(?1, ?2)\",\n                        @\"COMMIT\" ]\n         inOperation:^BOOL {\n             return self.handle->insertRows(rows, self.columns, self.tableName.UTF8String);\n         }];\n    TestCaseAssertTrue([self allRowsCount] == 4);\n}\n\n- (void)test_handle_insert_or_replace_multi_rows\n{\n    WCDB::MultiRowsValue rows = [Random.shared testCaseValuesWithCount:2 startingFromIdentifier:[self nextIdentifier] - 2];\n    self.expectMode = DatabaseTestCaseExpectSomeSQLs;\n    [self doTestSQLs:@[ @\"BEGIN IMMEDIATE\",\n                        @\"INSERT OR REPLACE INTO testTable(identifier, content) VALUES(?1, ?2)\",\n                        @\"COMMIT\" ]\n         inOperation:^BOOL {\n             return self.handle->insertOrReplaceRows(rows, self.columns, self.tableName.UTF8String);\n         }];\n    TestCaseAssertTrue([self allRowsCount] == 2);\n}\n\n- (void)test_handle_insert_or_ignore_multi_rows\n{\n    WCDB::MultiRowsValue rows = [Random.shared testCaseValuesWithCount:2 startingFromIdentifier:[self nextIdentifier] - 2];\n    self.expectMode = DatabaseTestCaseExpectSomeSQLs;\n    [self doTestSQLs:@[ @\"BEGIN IMMEDIATE\",\n                        @\"INSERT OR IGNORE INTO testTable(identifier, content) VALUES(?1, ?2)\",\n                        @\"COMMIT\" ]\n         inOperation:^BOOL {\n             return self.handle->insertOrIgnoreRows(rows, self.columns, self.tableName.UTF8String);\n         }];\n    TestCaseAssertTrue([self allRowsCount] == 2);\n}\n\n- (void)test_handle_update_value\n{\n    [self doTestSQLs:@[ @\"UPDATE testTable SET content = ?1 WHERE identifier == 2\" ]\n         inOperation:^BOOL {\n             return self.handle->updateRow(self.row1[1], WCDB::Column(\"content\"), self.tableName.UTF8String, WCDB::Column(\"identifier\") == self.row2[0]);\n         }];\n    TestCaseAssertTrue([self allRowsCount] == 2);\n}\n\n- (void)test_handle_update_values\n{\n    [self doTestSQLs:@[ @\"UPDATE testTable SET identifier = ?1, content = ?2 WHERE identifier == 1\" ]\n         inOperation:^BOOL {\n             return self.handle->updateRow(self.row1, self.columns, self.tableName.UTF8String, WCDB::Column(\"identifier\") == self.row1[0]);\n         }];\n    TestCaseAssertTrue([self allRowsCount] == 2);\n}\n\n- (void)test_handle_delete\n{\n    [self doTestSQLs:@[ @\"DELETE FROM testTable WHERE identifier == 1\" ]\n         inOperation:^BOOL {\n             return self.handle->deleteValues(self.tableName.UTF8String, WCDB::Column(\"identifier\") == 1);\n         }];\n    TestCaseAssertTrue([self allRowsCount] == 1);\n}\n\n- (void)test_handle_select_value\n{\n    [self doTestValue:self.row1[0]\n               andSQL:@\"SELECT identifier FROM testTable LIMIT 1\"\n          bySelecting:^WCDB::OptionalValue {\n              return self.handle->selectValue(WCDB::Column(\"identifier\"), self.tableName.UTF8String);\n          }];\n}\n\n- (void)test_handle_select_value_where\n{\n    [self doTestValue:self.row1[0]\n               andSQL:@\"SELECT identifier FROM testTable WHERE identifier == 1 LIMIT 1\"\n          bySelecting:^WCDB::OptionalValue {\n              return self.handle->selectValue(WCDB::Column(\"identifier\"), self.tableName.UTF8String, WCDB::Column(\"identifier\") == 1);\n          }];\n}\n\n- (void)test_handle_select_one_column\n{\n    [self doTestColumn:{ self.row1[0], self.row2[0] }\n                andSQL:@\"SELECT identifier FROM testTable\"\n           bySelecting:^WCDB::OptionalOneColumn {\n               return self.handle->selectOneColumn(WCDB::Column(\"identifier\"), self.tableName.UTF8String);\n           }];\n}\n\n- (void)test_handle_select_one_column_where\n{\n    [self doTestColumn:self.row1[0]\n                andSQL:@\"SELECT identifier FROM testTable WHERE identifier == 1\"\n           bySelecting:^WCDB::OptionalOneColumn {\n               return self.handle->selectOneColumn(WCDB::Column(\"identifier\"), self.tableName.UTF8String, WCDB::Column(\"identifier\") == 1);\n           }];\n}\n\n- (void)test_handle_select_one_column_where_order\n{\n    [self doTestColumn:self.row1[0]\n                andSQL:@\"SELECT identifier FROM testTable WHERE identifier == 1 ORDER BY identifier\"\n           bySelecting:^WCDB::OptionalOneColumn {\n               return self.handle->selectOneColumn(WCDB::Column(\"identifier\"), self.tableName.UTF8String, WCDB::Column(\"identifier\") == 1, WCDB::Column(\"identifier\"));\n           }];\n}\n\n- (void)test_handle_select_one_column_where_order_limit\n{\n    [self doTestColumn:self.row1[0]\n                andSQL:@\"SELECT identifier FROM testTable WHERE identifier == 1 ORDER BY identifier ASC LIMIT 1\"\n           bySelecting:^WCDB::OptionalOneColumn {\n               return self.handle->selectOneColumn(WCDB::Column(\"identifier\"), self.tableName.UTF8String, WCDB::Column(\"identifier\") == 1, WCDB::Column(\"identifier\").asOrder(WCDB::Order::ASC), 1);\n           }];\n}\n\n- (void)test_handle_select_one_row\n{\n    [self doTestRow:self.row1\n             andSQL:@\"SELECT identifier, content FROM testTable LIMIT 1\"\n        bySelecting:^WCDB::OptionalOneColumn {\n            return self.handle->selectOneRow(self.columns, self.tableName.UTF8String);\n        }];\n}\n\n- (void)test_handle_select_one_row_where\n{\n    [self doTestRow:self.row1\n             andSQL:@\"SELECT identifier, content FROM testTable WHERE identifier == 1 LIMIT 1\"\n        bySelecting:^WCDB::OptionalOneColumn {\n            return self.handle->selectOneRow(self.columns, self.tableName.UTF8String, WCDB::Column(\"identifier\") == 1);\n        }];\n}\n\n- (void)test_handle_select_all_row\n{\n    [self doTestRows:self.rows\n              andSQL:@\"SELECT identifier, content FROM testTable\"\n         bySelecting:^WCDB::OptionalMultiRows {\n             return self.handle->selectAllRow(self.columns, self.tableName.UTF8String);\n         }];\n}\n\n- (void)test_handle_select_all_row_where\n{\n    [self doTestRows:{ self.row1 }\n              andSQL:@\"SELECT identifier, content FROM testTable WHERE identifier == 1\"\n         bySelecting:^WCDB::OptionalMultiRows {\n             return self.handle->selectAllRow(self.columns, self.tableName.UTF8String, WCDB::Column(\"identifier\") == 1);\n         }];\n}\n\n- (void)test_handle_select_all_row_where_order\n{\n    [self doTestRows:{ self.row1 }\n              andSQL:@\"SELECT identifier, content FROM testTable WHERE identifier == 1 ORDER BY identifier\"\n         bySelecting:^WCDB::OptionalMultiRows {\n             return self.handle->selectAllRow(self.columns, self.tableName.UTF8String, WCDB::Column(\"identifier\") == 1, WCDB::Column(\"identifier\"));\n         }];\n}\n\n- (void)test_handle_select_all_row_where_order_limit\n{\n    [self doTestRows:{ self.row1 }\n              andSQL:@\"SELECT identifier, content FROM testTable WHERE identifier == 1 ORDER BY identifier ASC LIMIT 1\"\n         bySelecting:^WCDB::OptionalMultiRows {\n             return self.handle->selectAllRow(self.columns, self.tableName.UTF8String, WCDB::Column(\"identifier\") == 1, WCDB::Column(\"identifier\").asOrder(WCDB::Order::ASC), 1);\n         }];\n}\n\n#pragma mark - database\n- (void)test_database_insert_row\n{\n    WCDB::OneRowValue row = [Random.shared testCaseValuesWithCount:1 startingFromIdentifier:[self nextIdentifier]][0];\n    [self doTestSQLs:@[ @\"INSERT INTO testTable(identifier, content) VALUES(?1, ?2)\" ]\n         inOperation:^BOOL {\n             return self.database->insertRows(row, self.columns, self.tableName.UTF8String);\n         }];\n    TestCaseAssertTrue([self allRowsCount] == 3);\n}\n\n- (void)test_database_insert_or_replace_row\n{\n    WCDB::OneRowValue row = [Random.shared testCaseValuesWithCount:1 startingFromIdentifier:[self nextIdentifier] - 1][0];\n    [self doTestSQLs:@[ @\"INSERT OR REPLACE INTO testTable(identifier, content) VALUES(?1, ?2)\" ]\n         inOperation:^BOOL {\n             return self.database->insertOrReplaceRows(row, self.columns, self.tableName.UTF8String);\n         }];\n    TestCaseAssertTrue([self allRowsCount] == 2);\n}\n\n- (void)test_database_insert_or_ignore_row\n{\n    WCDB::OneRowValue row = [Random.shared testCaseValuesWithCount:1 startingFromIdentifier:[self nextIdentifier] - 1][0];\n    [self doTestSQLs:@[ @\"INSERT OR IGNORE INTO testTable(identifier, content) VALUES(?1, ?2)\" ]\n         inOperation:^BOOL {\n             return self.database->insertOrIgnoreRows(row, self.columns, self.tableName.UTF8String);\n         }];\n    TestCaseAssertTrue([self allRowsCount] == 2);\n}\n\n- (void)test_database_insert_multi_rows\n{\n    WCDB::MultiRowsValue rows = [Random.shared testCaseValuesWithCount:2 startingFromIdentifier:[self nextIdentifier]];\n    self.expectMode = DatabaseTestCaseExpectSomeSQLs;\n    [self doTestSQLs:@[ @\"BEGIN IMMEDIATE\",\n                        @\"INSERT INTO testTable(identifier, content) VALUES(?1, ?2)\",\n                        @\"COMMIT\" ]\n         inOperation:^BOOL {\n             return self.database->insertRows(rows, self.columns, self.tableName.UTF8String);\n         }];\n    TestCaseAssertTrue([self allRowsCount] == 4);\n}\n\n- (void)test_database_insert_or_replace_multi_rows\n{\n    WCDB::MultiRowsValue rows = [Random.shared testCaseValuesWithCount:2 startingFromIdentifier:[self nextIdentifier] - 2];\n    self.expectMode = DatabaseTestCaseExpectSomeSQLs;\n    [self doTestSQLs:@[ @\"BEGIN IMMEDIATE\",\n                        @\"INSERT OR REPLACE INTO testTable(identifier, content) VALUES(?1, ?2)\",\n                        @\"COMMIT\" ]\n         inOperation:^BOOL {\n             return self.database->insertOrReplaceRows(rows, self.columns, self.tableName.UTF8String);\n         }];\n    TestCaseAssertTrue([self allRowsCount] == 2);\n}\n\n- (void)test_database_insert_or_ignore_multi_rows\n{\n    WCDB::MultiRowsValue rows = [Random.shared testCaseValuesWithCount:2 startingFromIdentifier:[self nextIdentifier] - 2];\n    self.expectMode = DatabaseTestCaseExpectSomeSQLs;\n    [self doTestSQLs:@[ @\"BEGIN IMMEDIATE\",\n                        @\"INSERT OR IGNORE INTO testTable(identifier, content) VALUES(?1, ?2)\",\n                        @\"COMMIT\" ]\n         inOperation:^BOOL {\n             return self.database->insertOrIgnoreRows(rows, self.columns, self.tableName.UTF8String);\n         }];\n    TestCaseAssertTrue([self allRowsCount] == 2);\n}\n\n- (void)test_database_update_value\n{\n    [self doTestSQLs:@[ @\"UPDATE testTable SET content = ?1 WHERE identifier == 2\" ]\n         inOperation:^BOOL {\n             return self.database->updateRow(self.row1[1], WCDB::Column(\"content\"), self.tableName.UTF8String, WCDB::Column(\"identifier\") == self.row2[0]);\n         }];\n    TestCaseAssertTrue([self allRowsCount] == 2);\n}\n\n- (void)test_database_update_values\n{\n    [self doTestSQLs:@[ @\"UPDATE testTable SET identifier = ?1, content = ?2 WHERE identifier == 1\" ]\n         inOperation:^BOOL {\n             return self.database->updateRow(self.row1, self.columns, self.tableName.UTF8String, WCDB::Column(\"identifier\") == self.row1[0]);\n         }];\n    TestCaseAssertTrue([self allRowsCount] == 2);\n}\n\n- (void)test_database_delete\n{\n    [self doTestSQLs:@[ @\"DELETE FROM testTable WHERE identifier == 1\" ]\n         inOperation:^BOOL {\n             return self.database->deleteValues(self.tableName.UTF8String, WCDB::Column(\"identifier\") == 1);\n         }];\n    TestCaseAssertTrue([self allRowsCount] == 1);\n}\n\n- (void)test_database_select_value\n{\n    [self doTestValue:self.row1[0]\n               andSQL:@\"SELECT identifier FROM testTable LIMIT 1\"\n          bySelecting:^WCDB::OptionalValue {\n              return self.database->selectValue(WCDB::Column(\"identifier\"), self.tableName.UTF8String);\n          }];\n}\n\n- (void)test_database_select_value_where\n{\n    [self doTestValue:self.row1[0]\n               andSQL:@\"SELECT identifier FROM testTable WHERE identifier == 1 LIMIT 1\"\n          bySelecting:^WCDB::OptionalValue {\n              return self.database->selectValue(WCDB::Column(\"identifier\"), self.tableName.UTF8String, WCDB::Column(\"identifier\") == 1);\n          }];\n}\n\n- (void)test_database_select_one_column\n{\n    [self doTestColumn:{ self.row1[0], self.row2[0] }\n                andSQL:@\"SELECT identifier FROM testTable\"\n           bySelecting:^WCDB::OptionalOneColumn {\n               return self.database->selectOneColumn(WCDB::Column(\"identifier\"), self.tableName.UTF8String);\n           }];\n}\n\n- (void)test_database_select_one_column_where\n{\n    [self doTestColumn:self.row1[0]\n                andSQL:@\"SELECT identifier FROM testTable WHERE identifier == 1\"\n           bySelecting:^WCDB::OptionalOneColumn {\n               return self.database->selectOneColumn(WCDB::Column(\"identifier\"), self.tableName.UTF8String, WCDB::Column(\"identifier\") == 1);\n           }];\n}\n\n- (void)test_database_select_one_column_where_order\n{\n    [self doTestColumn:self.row1[0]\n                andSQL:@\"SELECT identifier FROM testTable WHERE identifier == 1 ORDER BY identifier\"\n           bySelecting:^WCDB::OptionalOneColumn {\n               return self.database->selectOneColumn(WCDB::Column(\"identifier\"), self.tableName.UTF8String, WCDB::Column(\"identifier\") == 1, WCDB::Column(\"identifier\"));\n           }];\n}\n\n- (void)test_database_select_one_column_where_order_limit\n{\n    [self doTestColumn:self.row1[0]\n                andSQL:@\"SELECT identifier FROM testTable WHERE identifier == 1 ORDER BY identifier ASC LIMIT 1\"\n           bySelecting:^WCDB::OptionalOneColumn {\n               return self.database->selectOneColumn(WCDB::Column(\"identifier\"), self.tableName.UTF8String, WCDB::Column(\"identifier\") == 1, WCDB::Column(\"identifier\").asOrder(WCDB::Order::ASC), 1);\n           }];\n}\n\n- (void)test_database_select_one_row\n{\n    [self doTestRow:self.row1\n             andSQL:@\"SELECT identifier, content FROM testTable LIMIT 1\"\n        bySelecting:^WCDB::OptionalOneColumn {\n            return self.database->selectOneRow(self.columns, self.tableName.UTF8String);\n        }];\n}\n\n- (void)test_database_select_one_row_where\n{\n    [self doTestRow:self.row1\n             andSQL:@\"SELECT identifier, content FROM testTable WHERE identifier == 1 LIMIT 1\"\n        bySelecting:^WCDB::OptionalOneColumn {\n            return self.database->selectOneRow(self.columns, self.tableName.UTF8String, WCDB::Column(\"identifier\") == 1);\n        }];\n}\n\n- (void)test_database_select_all_row\n{\n    [self doTestRows:self.rows\n              andSQL:@\"SELECT identifier, content FROM testTable\"\n         bySelecting:^WCDB::OptionalMultiRows {\n             return self.database->selectAllRow(self.columns, self.tableName.UTF8String);\n         }];\n}\n\n- (void)test_database_select_all_row_where\n{\n    [self doTestRows:{ self.row1 }\n              andSQL:@\"SELECT identifier, content FROM testTable WHERE identifier == 1\"\n         bySelecting:^WCDB::OptionalMultiRows {\n             return self.database->selectAllRow(self.columns, self.tableName.UTF8String, WCDB::Column(\"identifier\") == 1);\n         }];\n}\n\n- (void)test_database_select_all_row_where_order\n{\n    [self doTestRows:{ self.row1 }\n              andSQL:@\"SELECT identifier, content FROM testTable WHERE identifier == 1 ORDER BY identifier\"\n         bySelecting:^WCDB::OptionalMultiRows {\n             return self.database->selectAllRow(self.columns, self.tableName.UTF8String, WCDB::Column(\"identifier\") == 1, WCDB::Column(\"identifier\"));\n         }];\n}\n\n- (void)test_database_select_all_row_where_order_limit\n{\n    [self doTestRows:{ self.row1 }\n              andSQL:@\"SELECT identifier, content FROM testTable WHERE identifier == 1 ORDER BY identifier ASC LIMIT 1\"\n         bySelecting:^WCDB::OptionalMultiRows {\n             return self.database->selectAllRow(self.columns, self.tableName.UTF8String, WCDB::Column(\"identifier\") == 1, WCDB::Column(\"identifier\").asOrder(WCDB::Order::ASC), 1);\n         }];\n}\n\n@end\n"
  },
  {
    "path": "src/cpp/tests/operation/ORMDeleteTests.mm",
    "content": "//\n// Created by qiuwenchen on 2022/9/7.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"CPPTestCase.h\"\n\n@interface ORMDeleteTests : CPPCRUDTestCase\n\n@end\n\n@implementation ORMDeleteTests\n\n- (void)setUp\n{\n    [super setUp];\n    [self insertPresetObjects];\n}\n\n#pragma mark - Database - Delete\n\n- (void)test_database_delete\n{\n    [self doTestObjects:{}\n                 andSQL:@\"DELETE FROM testTable\"\n      afterModification:^BOOL {\n          return self.database->deleteObjects(self.tableName.UTF8String);\n      }];\n}\n\n- (void)test_database_delete_where\n{\n    [self doTestObjects:self.object1\n                 andSQL:@\"DELETE FROM testTable WHERE identifier == 2\"\n      afterModification:^BOOL {\n          return self.database->deleteObjects(self.tableName.UTF8String, WCDB_FIELD(CPPTestCaseObject::identifier) == 2);\n      }];\n}\n\n- (void)test_database_delete_where_order_limit\n{\n    [self doTestObjects:self.object1\n                 andSQL:@\"DELETE FROM testTable WHERE identifier > 0 ORDER BY identifier DESC LIMIT 1\"\n      afterModification:^BOOL {\n          return self.database->deleteObjects(self.tableName.UTF8String, WCDB_FIELD(CPPTestCaseObject::identifier) > 0, WCDB_FIELD(CPPTestCaseObject::identifier).asOrder(WCDB::Order::DESC), 1);\n      }];\n}\n\n#pragma mark - Table - Delete\n- (void)test_table_delete\n{\n    [self doTestObjects:{}\n                 andSQL:@\"DELETE FROM testTable\"\n      afterModification:^BOOL {\n          return self.table.deleteObjects();\n      }];\n}\n\n- (void)test_table_delete_where\n{\n    [self doTestObjects:self.object1\n                 andSQL:@\"DELETE FROM testTable WHERE identifier == 2\"\n      afterModification:^BOOL {\n          return self.table.deleteObjects(WCDB_FIELD(CPPTestCaseObject::identifier) == 2);\n      }];\n}\n\n- (void)test_table_delete_where_order_limit\n{\n    [self doTestObjects:self.object1\n                 andSQL:@\"DELETE FROM testTable WHERE identifier > 0 ORDER BY identifier DESC LIMIT 1\"\n      afterModification:^BOOL {\n          return self.table.deleteObjects(WCDB_FIELD(CPPTestCaseObject::identifier) > 0, WCDB_FIELD(CPPTestCaseObject::identifier).asOrder(WCDB::Order::DESC), 1);\n      }];\n}\n\n@end\n"
  },
  {
    "path": "src/cpp/tests/operation/ORMInsertTests.mm",
    "content": "//\n// Created by qiuwenchen on 2022/9/7.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"CPPTestCase.h\"\n\n@interface ORMInsertTests : CPPCRUDTestCase\n\n@property (nonatomic, assign) CPPTestCaseObject renewedObject1;\n@property (nonatomic, assign) CPPTestCaseObject renewedObject2;\n\n@property (nonatomic, assign) CPPTestCaseObject renewedPartialObject1;\n@property (nonatomic, assign) CPPTestCaseObject renewedPartialObject2;\n\n@property (nonatomic, assign) CPPTestCaseObject object3;\n@property (nonatomic, assign) CPPTestCaseObject object4;\n\n@property (nonatomic, assign) CPPTestCaseObject partialObject3;\n@property (nonatomic, assign) CPPTestCaseObject partialObject4;\n\n@end\n\n@implementation ORMInsertTests\n\n- (void)setUp\n{\n    [super setUp];\n    [self insertPresetObjects];\n    self.renewedObject1 = [Random.shared testCaseObjectWithIdentifier:1];\n    self.renewedObject2 = [Random.shared testCaseObjectWithIdentifier:2];\n    self.renewedPartialObject1 = CPPTestCaseObject(1);\n    self.renewedPartialObject2 = CPPTestCaseObject(2);\n    self.object3 = [Random.shared testCaseObjectWithIdentifier:3];\n    self.object4 = [Random.shared testCaseObjectWithIdentifier:4];\n    self.partialObject3 = CPPTestCaseObject(3);\n    self.partialObject4 = CPPTestCaseObject(4);\n}\n\n#pragma mark - Auto Increment\n- (void)test_auto_increment\n{\n    __block CPPTestCaseObject autoIncrementObject = CPPTestCaseObject::autoIncrementObject(self.object3.content);\n    [self doTestObjects:{ self.object1, self.object2, self.object3 }\n              andNumber:1\n           ofInsertSQLs:@\"INSERT INTO testTable(identifier, content) VALUES(?1, ?2)\"\n         afterInsertion:^BOOL {\n             BOOL result = self.database->insertObjects<CPPTestCaseObject>(autoIncrementObject, self.tableName.UTF8String);\n             if (result) {\n                 autoIncrementObject.identifier = (int) *autoIncrementObject.lastInsertedRowID;\n             }\n             return result;\n         }];\n    TestCaseAssertTrue(autoIncrementObject == self.object3);\n}\n\n- (void)test_auto_increment_with_partial_insert\n{\n    __block CPPTestCaseObject autoIncrementObject = CPPTestCaseObject::autoIncrementObject(self.object3.content);\n    [self doTestObjects:{ self.object1, self.object2, self.object3 }\n              andNumber:1\n           ofInsertSQLs:@\"INSERT INTO testTable(content) VALUES(?1)\"\n         afterInsertion:^BOOL {\n             BOOL result = self.database->insertObjects<CPPTestCaseObject>(autoIncrementObject, self.tableName.UTF8String, WCDB_FIELD(CPPTestCaseObject::content));\n             if (result) {\n                 autoIncrementObject.identifier = (int) *autoIncrementObject.lastInsertedRowID;\n             }\n             return result;\n         }];\n    TestCaseAssertTrue(autoIncrementObject == self.object3);\n}\n\n#pragma mark - Database - Insert\n- (void)test_database_insert_object\n{\n    [self doTestObjects:{ self.object1, self.object2, self.object3 }\n              andNumber:1\n           ofInsertSQLs:@\"INSERT INTO testTable(identifier, content) VALUES(?1, ?2)\"\n         afterInsertion:^BOOL {\n             return self.database->insertObjects<CPPTestCaseObject>(self.object3, self.tableName.UTF8String);\n         }];\n}\n\n- (void)test_database_insert_objects\n{\n    [self doTestObjects:{ self.object1, self.object2, self.object3, self.object4 }\n              andNumber:2\n           ofInsertSQLs:@\"INSERT INTO testTable(identifier, content) VALUES(?1, ?2)\"\n         afterInsertion:^BOOL {\n             return self.database->insertObjects<CPPTestCaseObject>({ self.object3, self.object4 }, self.tableName.UTF8String);\n         }];\n}\n\n- (void)test_database_insert_objects_ptr\n{\n    [self doTestObjects:{ self.object1, self.object2, self.object3, self.object4 }\n              andNumber:2\n           ofInsertSQLs:@\"INSERT INTO testTable(identifier, content) VALUES(?1, ?2)\"\n         afterInsertion:^BOOL {\n             WCDB::ValueArray<CPPTestCaseObject *> objects = { &self->_object3, &self->_object4 };\n             return self.database->insertObjects<CPPTestCaseObject>(objects, self.tableName.UTF8String);\n         }];\n}\n\n- (void)test_database_insert_objects_shared_ptr\n{\n    [self doTestObjects:{ self.object1, self.object2, self.object3, self.object4 }\n              andNumber:2\n           ofInsertSQLs:@\"INSERT INTO testTable(identifier, content) VALUES(?1, ?2)\"\n         afterInsertion:^BOOL {\n             return self.database->insertObjects<CPPTestCaseObject>({ std::make_shared<CPPTestCaseObject>(self->_object3), std::make_shared<CPPTestCaseObject>(self->_object4) }, self.tableName.UTF8String);\n         }];\n}\n\n#pragma mark - Database - Insert or Replace\n- (void)test_database_insert_or_replace_object\n{\n    [self doTestObjects:{ self.renewedObject1, self.object2 }\n              andNumber:1\n           ofInsertSQLs:@\"INSERT OR REPLACE INTO testTable(identifier, content) VALUES(?1, ?2)\"\n         afterInsertion:^BOOL {\n             return self.database->insertOrReplaceObjects<CPPTestCaseObject>(self.renewedObject1, self.tableName.UTF8String);\n         }];\n}\n\n- (void)test_database_insert_or_replace_objects\n{\n    [self doTestObjects:{ self.renewedObject1, self.renewedObject2 }\n              andNumber:2\n           ofInsertSQLs:@\"INSERT OR REPLACE INTO testTable(identifier, content) VALUES(?1, ?2)\"\n         afterInsertion:^BOOL {\n             return self.database->insertOrReplaceObjects<CPPTestCaseObject>({ self.renewedObject1, self.renewedObject2 }, self.tableName.UTF8String);\n         }];\n}\n\n- (void)test_database_insert_or_replace_objects_ptr\n{\n    [self doTestObjects:{ self.renewedObject1, self.renewedObject2 }\n              andNumber:2\n           ofInsertSQLs:@\"INSERT OR REPLACE INTO testTable(identifier, content) VALUES(?1, ?2)\"\n         afterInsertion:^BOOL {\n             WCDB::ValueArray<CPPTestCaseObject *> objects = { &self->_renewedObject1, &self->_renewedObject2 };\n             return self.database->insertOrReplaceObjects<CPPTestCaseObject>(objects, self.tableName.UTF8String);\n         }];\n}\n\n- (void)test_database_insert_or_replace_objects_sharedPtr\n{\n    [self doTestObjects:{ self.renewedObject1, self.renewedObject2 }\n              andNumber:2\n           ofInsertSQLs:@\"INSERT OR REPLACE INTO testTable(identifier, content) VALUES(?1, ?2)\"\n         afterInsertion:^BOOL {\n             return self.database->insertOrReplaceObjects<CPPTestCaseObject>({ std::make_shared<CPPTestCaseObject>(self->_renewedObject1),\n                                                                               std::make_shared<CPPTestCaseObject>(self->_renewedObject2) },\n                                                                             self.tableName.UTF8String);\n         }];\n}\n\n#pragma mark - Database - Insert or Ignore\n- (void)test_database_insert_or_ignore_object\n{\n    [self doTestObjects:{ self.object1, self.object2 }\n              andNumber:1\n           ofInsertSQLs:@\"INSERT OR IGNORE INTO testTable(identifier, content) VALUES(?1, ?2)\"\n         afterInsertion:^BOOL {\n             return self.database->insertOrIgnoreObjects<CPPTestCaseObject>(self.renewedObject1, self.tableName.UTF8String);\n         }];\n}\n\n- (void)test_database_insert_or_ignore_objects\n{\n    [self doTestObjects:{ self.object1, self.object2 }\n              andNumber:2\n           ofInsertSQLs:@\"INSERT OR IGNORE INTO testTable(identifier, content) VALUES(?1, ?2)\"\n         afterInsertion:^BOOL {\n             return self.database->insertOrIgnoreObjects<CPPTestCaseObject>({ self.renewedObject1, self.renewedObject2 }, self.tableName.UTF8String);\n         }];\n}\n\n- (void)test_database_insert_or_ignore_objects_ptr\n{\n    [self doTestObjects:{ self.object1, self.object2 }\n              andNumber:2\n           ofInsertSQLs:@\"INSERT OR IGNORE INTO testTable(identifier, content) VALUES(?1, ?2)\"\n         afterInsertion:^BOOL {\n             WCDB::ValueArray<CPPTestCaseObject *> objects = { &self->_renewedObject1, &self->_renewedObject2 };\n             return self.database->insertOrIgnoreObjects<CPPTestCaseObject>(objects, self.tableName.UTF8String);\n         }];\n}\n\n- (void)test_database_insert_or_ignore_objects_shared_ptr\n{\n    [self doTestObjects:{ self.object1, self.object2 }\n              andNumber:2\n           ofInsertSQLs:@\"INSERT OR IGNORE INTO testTable(identifier, content) VALUES(?1, ?2)\"\n         afterInsertion:^BOOL {\n             return self.database->insertOrIgnoreObjects<CPPTestCaseObject>({ std::make_shared<CPPTestCaseObject>(self->_renewedObject1),\n                                                                              std::make_shared<CPPTestCaseObject>(self->_renewedObject2) },\n                                                                            self.tableName.UTF8String);\n         }];\n}\n\n#pragma mark - Database - Partial Insert\n- (void)test_database_insert_object_on_properties\n{\n    [self doTestObjects:{ self.object1, self.object2, self.partialObject3 }\n              andNumber:1\n           ofInsertSQLs:@\"INSERT INTO testTable(identifier) VALUES(?1)\"\n         afterInsertion:^BOOL {\n             return self.database->insertObjects<CPPTestCaseObject>(self.object3, self.tableName.UTF8String, WCDB_FIELD(CPPTestCaseObject::identifier));\n         }];\n}\n\n- (void)test_database_insert_objects_on_properties\n{\n    [self doTestObjects:{ self.object1, self.object2, self.partialObject3, self.partialObject4 }\n              andNumber:2\n           ofInsertSQLs:@\"INSERT INTO testTable(identifier) VALUES(?1)\"\n         afterInsertion:^BOOL {\n             return self.database->insertObjects<CPPTestCaseObject>({ self.object3, self.object4 }, self.tableName.UTF8String, WCDB_FIELD(CPPTestCaseObject::identifier));\n         }];\n}\n\n- (void)test_database_insert_objects_ptr_on_properties\n{\n    [self doTestObjects:{ self.object1, self.object2, self.partialObject3, self.partialObject4 }\n              andNumber:2\n           ofInsertSQLs:@\"INSERT INTO testTable(identifier) VALUES(?1)\"\n         afterInsertion:^BOOL {\n             WCDB::ValueArray<CPPTestCaseObject *> objects = { &self->_object3, &self->_object4 };\n             return self.database->insertObjects<CPPTestCaseObject>(objects, self.tableName.UTF8String, WCDB_FIELD(CPPTestCaseObject::identifier));\n         }];\n}\n\n- (void)test_database_insert_objects_shared_ptr_on_properties\n{\n    [self doTestObjects:{ self.object1, self.object2, self.partialObject3, self.partialObject4 }\n              andNumber:2\n           ofInsertSQLs:@\"INSERT INTO testTable(identifier) VALUES(?1)\"\n         afterInsertion:^BOOL {\n             return self.database->insertObjects<CPPTestCaseObject>({ std::make_shared<CPPTestCaseObject>(self->_object3),\n                                                                      std::make_shared<CPPTestCaseObject>(self->_object4) },\n                                                                    self.tableName.UTF8String,\n                                                                    WCDB_FIELD(CPPTestCaseObject::identifier));\n         }];\n}\n\n#pragma mark - Database - Partial Insert or Replace\n- (void)test_database_insert_or_replace_object_on_properties\n{\n    [self doTestObjects:{ self.renewedPartialObject1, self.object2 }\n              andNumber:1\n           ofInsertSQLs:@\"INSERT OR REPLACE INTO testTable(identifier) VALUES(?1)\"\n         afterInsertion:^BOOL {\n             return self.database->insertOrReplaceObjects<CPPTestCaseObject>(self.object1, self.tableName.UTF8String, WCDB_FIELD(CPPTestCaseObject::identifier));\n         }];\n}\n\n- (void)test_database_insert_or_replace_objects_on_properties\n{\n    [self doTestObjects:{ self.renewedPartialObject1, self.renewedPartialObject2 }\n              andNumber:2\n           ofInsertSQLs:@\"INSERT OR REPLACE INTO testTable(identifier) VALUES(?1)\"\n         afterInsertion:^BOOL {\n             return self.database->insertOrReplaceObjects<CPPTestCaseObject>({ self.object1, self.object2 }, self.tableName.UTF8String, WCDB_FIELD(CPPTestCaseObject::identifier));\n         }];\n}\n\n#pragma mark - Database - Partial Insert or Ignore\n- (void)test_database_insert_or_ignore_object_on_properties\n{\n    [self doTestObjects:{ self.object1, self.object2 }\n              andNumber:1\n           ofInsertSQLs:@\"INSERT OR IGNORE INTO testTable(identifier) VALUES(?1)\"\n         afterInsertion:^BOOL {\n             return self.database->insertOrIgnoreObjects<CPPTestCaseObject>(self.object1, self.tableName.UTF8String, WCDB_FIELD(CPPTestCaseObject::identifier));\n         }];\n}\n\n- (void)test_database_insert_or_ignore_objects_on_properties\n{\n    [self doTestObjects:{ self.object1, self.object2 }\n              andNumber:2\n           ofInsertSQLs:@\"INSERT OR IGNORE INTO testTable(identifier) VALUES(?1)\"\n         afterInsertion:^BOOL {\n             return self.database->insertOrIgnoreObjects<CPPTestCaseObject>({ self.object1, self.object2 }, self.tableName.UTF8String, WCDB_FIELD(CPPTestCaseObject::identifier));\n         }];\n}\n\n#pragma mark - Table - Insert\n- (void)test_table_insert_object\n{\n    [self doTestObjects:{ self.object1, self.object2, self.object3 }\n              andNumber:1\n           ofInsertSQLs:@\"INSERT INTO testTable(identifier, content) VALUES(?1, ?2)\"\n         afterInsertion:^BOOL {\n             return self.table.insertObjects(self.object3);\n         }];\n}\n\n- (void)test_table_insert_objects\n{\n    [self doTestObjects:{ self.object1, self.object2, self.object3, self.object4 }\n              andNumber:2\n           ofInsertSQLs:@\"INSERT INTO testTable(identifier, content) VALUES(?1, ?2)\"\n         afterInsertion:^BOOL {\n             return self.table.insertObjects({ self.object3, self.object4 });\n         }];\n}\n\n- (void)test_table_insert_objects_ptr\n{\n    [self doTestObjects:{ self.object1, self.object2, self.object3, self.object4 }\n              andNumber:2\n           ofInsertSQLs:@\"INSERT INTO testTable(identifier, content) VALUES(?1, ?2)\"\n         afterInsertion:^BOOL {\n             WCDB::ValueArray<CPPTestCaseObject *> objects = { &self->_object3, &self->_object4 };\n             return self.table.insertObjects(objects);\n         }];\n}\n\n- (void)test_table_insert_objects_shared_ptr\n{\n    [self doTestObjects:{ self.object1, self.object2, self.object3, self.object4 }\n              andNumber:2\n           ofInsertSQLs:@\"INSERT INTO testTable(identifier, content) VALUES(?1, ?2)\"\n         afterInsertion:^BOOL {\n             return self.table.insertObjects({ std::make_shared<CPPTestCaseObject>(self->_object3),\n                                               std::make_shared<CPPTestCaseObject>(self->_object4) });\n         }];\n}\n\n#pragma mark - Table - Insert or Replace\n- (void)test_table_insert_or_replace_object\n{\n    [self doTestObjects:{ self.renewedObject1, self.object2 }\n              andNumber:1\n           ofInsertSQLs:@\"INSERT OR REPLACE INTO testTable(identifier, content) VALUES(?1, ?2)\"\n         afterInsertion:^BOOL {\n             return self.table.insertOrReplaceObjects(self.renewedObject1);\n         }];\n}\n\n- (void)test_table_insert_or_replace_objects\n{\n    [self doTestObjects:{ self.renewedObject1, self.renewedObject2 }\n              andNumber:2\n           ofInsertSQLs:@\"INSERT OR REPLACE INTO testTable(identifier, content) VALUES(?1, ?2)\"\n         afterInsertion:^BOOL {\n             return self.table.insertOrReplaceObjects({ self.renewedObject1, self.renewedObject2 });\n         }];\n}\n\n- (void)test_table_insert_or_replace_objects_ptr\n{\n    [self doTestObjects:{ self.renewedObject1, self.renewedObject2 }\n              andNumber:2\n           ofInsertSQLs:@\"INSERT OR REPLACE INTO testTable(identifier, content) VALUES(?1, ?2)\"\n         afterInsertion:^BOOL {\n             WCDB::ValueArray<CPPTestCaseObject *> objects = { &self->_renewedObject1, &self->_renewedObject2 };\n             return self.table.insertOrReplaceObjects(objects);\n         }];\n}\n\n- (void)test_table_insert_or_replace_objects_shared_ptr\n{\n    [self doTestObjects:{ self.renewedObject1, self.renewedObject2 }\n              andNumber:2\n           ofInsertSQLs:@\"INSERT OR REPLACE INTO testTable(identifier, content) VALUES(?1, ?2)\"\n         afterInsertion:^BOOL {\n             return self.table.insertOrReplaceObjects({ std::make_shared<CPPTestCaseObject>(self->_renewedObject1),\n                                                        std::make_shared<CPPTestCaseObject>(self->_renewedObject2) });\n         }];\n}\n\n#pragma mark - Table - Insert or Ignore\n- (void)test_table_insert_or_ignore_object\n{\n    [self doTestObjects:{ self.object1, self.object2 }\n              andNumber:1\n           ofInsertSQLs:@\"INSERT OR IGNORE INTO testTable(identifier, content) VALUES(?1, ?2)\"\n         afterInsertion:^BOOL {\n             return self.table.insertOrIgnoreObjects(self.renewedObject1);\n         }];\n}\n\n- (void)test_table_insert_or_ignore_objects\n{\n    [self doTestObjects:{ self.object1, self.object2 }\n              andNumber:2\n           ofInsertSQLs:@\"INSERT OR IGNORE INTO testTable(identifier, content) VALUES(?1, ?2)\"\n         afterInsertion:^BOOL {\n             return self.table.insertOrIgnoreObjects({ self.renewedObject1, self.renewedObject2 });\n         }];\n}\n\n- (void)test_table_insert_or_ignore_objects_ptr\n{\n    [self doTestObjects:{ self.object1, self.object2 }\n              andNumber:2\n           ofInsertSQLs:@\"INSERT OR IGNORE INTO testTable(identifier, content) VALUES(?1, ?2)\"\n         afterInsertion:^BOOL {\n             WCDB::ValueArray<CPPTestCaseObject *> objects = { &self->_renewedObject1, &self->_renewedObject2 };\n             return self.table.insertOrIgnoreObjects(objects);\n         }];\n}\n\n- (void)test_table_insert_or_ignore_objects_shared_ptr\n{\n    [self doTestObjects:{ self.object1, self.object2 }\n              andNumber:2\n           ofInsertSQLs:@\"INSERT OR IGNORE INTO testTable(identifier, content) VALUES(?1, ?2)\"\n         afterInsertion:^BOOL {\n             return self.table.insertOrIgnoreObjects({ std::make_shared<CPPTestCaseObject>(self->_renewedObject1),\n                                                       std::make_shared<CPPTestCaseObject>(self->_renewedObject2) });\n         }];\n}\n\n#pragma mark - Table - Partial Insert\n- (void)test_table_insert_object_on_properties\n{\n    [self doTestObjects:{ self.object1, self.object2, self.partialObject3 }\n              andNumber:1\n           ofInsertSQLs:@\"INSERT INTO testTable(identifier) VALUES(?1)\"\n         afterInsertion:^BOOL {\n             return self.table.insertObjects(self.object3, WCDB_FIELD(CPPTestCaseObject::identifier));\n         }];\n}\n\n- (void)test_table_insert_objects_on_properties\n{\n    [self doTestObjects:{ self.object1, self.object2, self.partialObject3, self.partialObject4 }\n              andNumber:2\n           ofInsertSQLs:@\"INSERT INTO testTable(identifier) VALUES(?1)\"\n         afterInsertion:^BOOL {\n             return self.table.insertObjects({ self.object3, self.object4 }, WCDB_FIELD(CPPTestCaseObject::identifier));\n         }];\n}\n\n#pragma mark - Table - Partial Insert or Replace\n- (void)test_table_insert_or_replace_object_on_properties\n{\n    [self doTestObjects:{ self.renewedPartialObject1, self.object2 }\n              andNumber:1\n           ofInsertSQLs:@\"INSERT OR REPLACE INTO testTable(identifier) VALUES(?1)\"\n         afterInsertion:^BOOL {\n             return self.table.insertOrReplaceObjects(self.object1, WCDB_FIELD(CPPTestCaseObject::identifier));\n         }];\n}\n\n- (void)test_table_insert_or_replace_objects_on_properties\n{\n    [self doTestObjects:{ self.renewedPartialObject1, self.renewedPartialObject2 }\n              andNumber:2\n           ofInsertSQLs:@\"INSERT OR REPLACE INTO testTable(identifier) VALUES(?1)\"\n         afterInsertion:^BOOL {\n             return self.table.insertOrReplaceObjects({ self.object1, self.object2 }, WCDB_FIELD(CPPTestCaseObject::identifier));\n         }];\n}\n\n#pragma mark - Table - Partial Insert or Ignore\n- (void)test_table_insert_or_ignore_object_on_properties\n{\n    [self doTestObjects:{ self.object1, self.object2 }\n              andNumber:1\n           ofInsertSQLs:@\"INSERT OR IGNORE INTO testTable(identifier) VALUES(?1)\"\n         afterInsertion:^BOOL {\n             return self.table.insertOrIgnoreObjects(self.object1, WCDB_FIELD(CPPTestCaseObject::identifier));\n         }];\n}\n\n- (void)test_table_insert_or_ignore_objects_on_properties\n{\n    [self doTestObjects:{ self.object1, self.object2 }\n              andNumber:2\n           ofInsertSQLs:@\"INSERT OR IGNORE INTO testTable(identifier) VALUES(?1)\"\n         afterInsertion:^BOOL {\n             return self.table.insertOrIgnoreObjects({ self.object1, self.object2 }, WCDB_FIELD(CPPTestCaseObject::identifier));\n         }];\n}\n\n#pragma mark - Handle - Insert\n- (void)test_handle_insert_object\n{\n    [self doTestObjects:{ self.object1, self.object2, self.object3 }\n              andNumber:1\n           ofInsertSQLs:@\"INSERT INTO testTable(identifier, content) VALUES(?1, ?2)\"\n         afterInsertion:^BOOL {\n             return self.database->getHandle().insertObjects<CPPTestCaseObject>(self.object3, self.tableName.UTF8String);\n         }];\n}\n\n- (void)test_handle_insert_objects\n{\n    [self doTestObjects:{ self.object1, self.object2, self.object3, self.object4 }\n              andNumber:2\n           ofInsertSQLs:@\"INSERT INTO testTable(identifier, content) VALUES(?1, ?2)\"\n         afterInsertion:^BOOL {\n             return self.database->getHandle().insertObjects<CPPTestCaseObject>({ self.object3, self.object4 }, self.tableName.UTF8String);\n         }];\n}\n\n#pragma mark - Handle - Insert or Replace\n- (void)test_handle_insert_or_replace_object\n{\n    [self doTestObjects:{ self.renewedObject1, self.object2 }\n              andNumber:1\n           ofInsertSQLs:@\"INSERT OR REPLACE INTO testTable(identifier, content) VALUES(?1, ?2)\"\n         afterInsertion:^BOOL {\n             return self.database->getHandle().insertOrReplaceObjects<CPPTestCaseObject>(self.renewedObject1, self.tableName.UTF8String);\n         }];\n}\n\n- (void)test_handle_insert_or_replace_objects\n{\n    [self doTestObjects:{ self.renewedObject1, self.renewedObject2 }\n              andNumber:2\n           ofInsertSQLs:@\"INSERT OR REPLACE INTO testTable(identifier, content) VALUES(?1, ?2)\"\n         afterInsertion:^BOOL {\n             return self.database->getHandle().insertOrReplaceObjects<CPPTestCaseObject>({ self.renewedObject1, self.renewedObject2 }, self.tableName.UTF8String);\n         }];\n}\n\n#pragma mark - Handle - Insert or Ignore\n- (void)test_handle_insert_or_ignore_object\n{\n    [self doTestObjects:{ self.object1, self.object2 }\n              andNumber:1\n           ofInsertSQLs:@\"INSERT OR IGNORE INTO testTable(identifier, content) VALUES(?1, ?2)\"\n         afterInsertion:^BOOL {\n             return self.database->getHandle().insertOrIgnoreObjects<CPPTestCaseObject>(self.renewedObject1, self.tableName.UTF8String);\n         }];\n}\n\n- (void)test_handle_insert_or_ignore_objects\n{\n    [self doTestObjects:{ self.object1, self.object2 }\n              andNumber:2\n           ofInsertSQLs:@\"INSERT OR IGNORE INTO testTable(identifier, content) VALUES(?1, ?2)\"\n         afterInsertion:^BOOL {\n             return self.database->getHandle().insertOrIgnoreObjects<CPPTestCaseObject>({ self.renewedObject1, self.renewedObject2 }, self.tableName.UTF8String);\n         }];\n}\n\n#pragma mark - Handle - Partial Insert\n- (void)test_handle_insert_object_on_properties\n{\n    [self doTestObjects:{ self.object1, self.object2, self.partialObject3 }\n              andNumber:1\n           ofInsertSQLs:@\"INSERT INTO testTable(identifier) VALUES(?1)\"\n         afterInsertion:^BOOL {\n             return self.database->getHandle().insertObjects<CPPTestCaseObject>(self.object3, self.tableName.UTF8String, WCDB_FIELD(CPPTestCaseObject::identifier));\n         }];\n}\n\n- (void)test_handle_insert_objects_on_properties\n{\n    [self doTestObjects:{ self.object1, self.object2, self.partialObject3, self.partialObject4 }\n              andNumber:2\n           ofInsertSQLs:@\"INSERT INTO testTable(identifier) VALUES(?1)\"\n         afterInsertion:^BOOL {\n             return self.database->getHandle().insertObjects<CPPTestCaseObject>({ self.object3, self.object4 }, self.tableName.UTF8String, WCDB_FIELD(CPPTestCaseObject::identifier));\n         }];\n}\n\n#pragma mark - Handle - Partial Insert or Replace\n- (void)test_handle_insert_or_replace_object_on_properties\n{\n    [self doTestObjects:{ self.renewedPartialObject1, self.object2 }\n              andNumber:1\n           ofInsertSQLs:@\"INSERT OR REPLACE INTO testTable(identifier) VALUES(?1)\"\n         afterInsertion:^BOOL {\n             return self.database->getHandle().insertOrReplaceObjects<CPPTestCaseObject>(self.object1, self.tableName.UTF8String, WCDB_FIELD(CPPTestCaseObject::identifier));\n         }];\n}\n\n- (void)test_handle_insert_or_replace_objects_on_properties\n{\n    [self doTestObjects:{ self.renewedPartialObject1, self.renewedPartialObject2 }\n              andNumber:2\n           ofInsertSQLs:@\"INSERT OR REPLACE INTO testTable(identifier) VALUES(?1)\"\n         afterInsertion:^BOOL {\n             return self.database->getHandle().insertOrReplaceObjects<CPPTestCaseObject>({ self.object1, self.object2 }, self.tableName.UTF8String, WCDB_FIELD(CPPTestCaseObject::identifier));\n         }];\n}\n\n#pragma mark - Handle - Partial Insert or Ignore\n- (void)test_handle_insert_or_ignore_object_on_properties\n{\n    [self doTestObjects:{ self.object1, self.object2 }\n              andNumber:1\n           ofInsertSQLs:@\"INSERT OR IGNORE INTO testTable(identifier) VALUES(?1)\"\n         afterInsertion:^BOOL {\n             return self.database->getHandle().insertOrIgnoreObjects<CPPTestCaseObject>(self.object1, self.tableName.UTF8String, WCDB_FIELD(CPPTestCaseObject::identifier));\n         }];\n}\n\n- (void)test_handle_insert_or_ignore_objects_on_properties\n{\n    [self doTestObjects:{ self.object1, self.object2 }\n              andNumber:2\n           ofInsertSQLs:@\"INSERT OR IGNORE INTO testTable(identifier) VALUES(?1)\"\n         afterInsertion:^BOOL {\n             return self.database->getHandle().insertOrIgnoreObjects<CPPTestCaseObject>({ self.object1, self.object2 }, self.tableName.UTF8String, WCDB_FIELD(CPPTestCaseObject::identifier));\n         }];\n}\n\n@end\n"
  },
  {
    "path": "src/cpp/tests/operation/ORMMultiSelectTests.mm",
    "content": "//\n// Created by qiuwenchen on 2022/10/26.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"CPPTestCase.h\"\n#import <Foundation/Foundation.h>\n\n@interface ORMMultiSelectTests : CPPCRUDTestCase\n\n@property (nonatomic, assign) NSString* tableName2;\n\n@property (nonatomic, assign) CPPTestCaseObject object1InTable2;\n@property (nonatomic, assign) CPPTestCaseObject object2InTable2;\n@property (nonatomic, assign) WCDB::ValueArray<CPPTestCaseObject> objectsInTable2;\n\n@end\n\n@implementation ORMMultiSelectTests\n\n- (void)setUp\n{\n    [super setUp];\n\n    self.tableName2 = @\"testTable2\";\n    self.object1InTable2 = [[Random shared] testCaseObjectWithIdentifier:1];\n    self.object2InTable2 = [[Random shared] testCaseObjectWithIdentifier:2];\n    self.objectsInTable2 = { self.object1InTable2, self.object2InTable2 };\n\n    [self insertPresetObjects];\n    TestCaseAssertTrue(self.database->createTable<CPPTestCaseObject>(self.tableName2.UTF8String));\n    TestCaseAssertTrue(self.database->insertObjects(self.objectsInTable2, self.tableName2.UTF8String));\n    self.database->close();\n}\n\n- (void)tearDown\n{\n    TestCaseAssertTrue(self.database->dropTable(self.tableName2.UTF8String));\n    [super tearDown];\n}\n\n- (void)doTestMultiObjects:(const WCDB::ValueArray<WCDB::MultiObject>&)multiObjects\n                    andSQL:(NSString*)sql\n               bySelecting:(WCDB::OptionalMultiObjectArray (^)())block\n{\n    TestCaseAssertTrue(multiObjects.size() > 0);\n    TestCaseAssertTrue(sql.length > 0);\n    __block WCDB::ValueArray<WCDB::MultiObject> results;\n    [self doTestSQLs:@[ sql ]\n         inOperation:^BOOL {\n             auto values = block();\n             TestCaseAssertTrue(values.succeed());\n             results = values.value();\n             return results.size() > 0;\n         }];\n    TestCaseAssertTrue(multiObjects.size() == results.size());\n    for (int i = 0; i < multiObjects.size(); i++) {\n        TestCaseAssertTrue(multiObjects[i] == results[i]);\n    }\n}\n\n#pragma mark - Database\n- (void)test_database_next\n{\n    WCDB::MultiObject multiObj;\n    multiObj.addObject(self.object1, self.tableName.UTF8String);\n    multiObj.addObject(self.object1InTable2, self.tableName2.UTF8String);\n    TestCaseAssertTrue(self.object1 == multiObj.objectAtTable<CPPTestCaseObject>(self.tableName.UTF8String).value());\n    TestCaseAssertTrue(self.object1InTable2 == multiObj.objectAtTable<CPPTestCaseObject>(self.tableName2.UTF8String).value());\n    [self doTestMultiObjects:multiObj\n                      andSQL:@\"SELECT testTable.identifier, testTable.content, testTable2.identifier, testTable2.content FROM testTable, testTable2 WHERE testTable.identifier == testTable2.identifier\"\n                 bySelecting:^WCDB::OptionalMultiObjectArray {\n                     WCDB::ResultFields resultColumns\n                     = CPPTestCaseObject::allFields()\n                       .redirect([self](const WCDB::Field& field) -> WCDB::ResultColumn {\n                           return field.table(self.tableName.UTF8String);\n                       })\n                       .addingNewResultColumns(CPPTestCaseObject::allFields().redirect([self](const WCDB::Field& field) -> WCDB::ResultColumn {\n                           return field.table(self.tableName2.UTF8String);\n                       }));\n\n                     WCDB::MultiSelect select = self.database->prepareMultiSelect().onResultFields(resultColumns).fromTables({ self.tableName.UTF8String, self.tableName2.UTF8String }).where(WCDB_FIELD(CPPTestCaseObject::identifier).table(self.tableName.UTF8String) == WCDB_FIELD(CPPTestCaseObject::identifier).table(self.tableName2.UTF8String));\n                     return select.firstMultiObject();\n                 }];\n}\n\n- (void)test_database_all\n{\n    WCDB::MultiObject multiObj1;\n    multiObj1.addObject(self.object1, self.tableName.UTF8String);\n    multiObj1.addObject(self.object1InTable2, self.tableName2.UTF8String);\n    TestCaseAssertTrue(self.object1 == multiObj1.objectAtTable<CPPTestCaseObject>(self.tableName.UTF8String).value());\n    TestCaseAssertTrue(self.object1InTable2 == multiObj1.objectAtTable<CPPTestCaseObject>(self.tableName2.UTF8String).value());\n    WCDB::MultiObject multiObj2;\n    multiObj2.addObject(self.object2, self.tableName.UTF8String);\n    multiObj2.addObject(self.object2InTable2, self.tableName2.UTF8String);\n    TestCaseAssertTrue(self.object2 == multiObj2.objectAtTable<CPPTestCaseObject>(self.tableName.UTF8String).value());\n    TestCaseAssertTrue(self.object2InTable2 == multiObj2.objectAtTable<CPPTestCaseObject>(self.tableName2.UTF8String).value());\n    [self doTestMultiObjects:{ multiObj1, multiObj2 }\n                      andSQL:@\"SELECT testTable.identifier, testTable.content, testTable2.identifier, testTable2.content FROM testTable, testTable2 WHERE testTable.identifier == testTable2.identifier\"\n                 bySelecting:^WCDB::OptionalMultiObjectArray {\n                     WCDB::ResultFields resultColumns\n                     = CPPTestCaseObject::allFields()\n                       .redirect([self](const WCDB::Field& field) -> WCDB::ResultColumn {\n                           return field.table(self.tableName.UTF8String);\n                       })\n                       .addingNewResultColumns(CPPTestCaseObject::allFields().redirect([self](const WCDB::Field& field) -> WCDB::ResultColumn {\n                           return field.table(self.tableName2.UTF8String);\n                       }));\n                     WCDB::MultiSelect select = self.database->prepareMultiSelect().onResultFields(resultColumns).fromTables({ self.tableName.UTF8String, self.tableName2.UTF8String }).where(WCDB_FIELD(CPPTestCaseObject::identifier).table(self.tableName.UTF8String) == WCDB_FIELD(CPPTestCaseObject::identifier).table(self.tableName2.UTF8String));\n                     return select.allMultiObjects();\n                 }];\n}\n\n#pragma mark - Handle\n- (void)test_handle_next\n{\n    WCDB::MultiObject multiObj;\n    multiObj.addObject(self.object1, self.tableName.UTF8String);\n    multiObj.addObject(self.object1InTable2, self.tableName2.UTF8String);\n    TestCaseAssertTrue(self.object1 == multiObj.objectAtTable<CPPTestCaseObject>(self.tableName.UTF8String).value());\n    TestCaseAssertTrue(self.object1InTable2 == multiObj.objectAtTable<CPPTestCaseObject>(self.tableName2.UTF8String).value());\n    [self doTestMultiObjects:multiObj\n                      andSQL:@\"SELECT testTable.identifier, testTable.content, testTable2.identifier, testTable2.content FROM testTable, testTable2 WHERE testTable.identifier == testTable2.identifier\"\n                 bySelecting:^WCDB::OptionalMultiObjectArray {\n                     WCDB::ResultFields resultColumns\n                     = CPPTestCaseObject::allFields()\n                       .redirect([self](const WCDB::Field& field) -> WCDB::ResultColumn {\n                           return field.table(self.tableName.UTF8String);\n                       })\n                       .addingNewResultColumns(CPPTestCaseObject::allFields().redirect([self](const WCDB::Field& field) -> WCDB::ResultColumn {\n                           return field.table(self.tableName2.UTF8String);\n                       }));\n\n                     WCDB::MultiSelect select = self.database->getHandle().prepareMultiSelect().onResultFields(resultColumns).fromTables({ self.tableName.UTF8String, self.tableName2.UTF8String }).where(WCDB_FIELD(CPPTestCaseObject::identifier).table(self.tableName.UTF8String) == WCDB_FIELD(CPPTestCaseObject::identifier).table(self.tableName2.UTF8String));\n                     return select.firstMultiObject();\n                 }];\n}\n\n- (void)test_handle_all\n{\n    WCDB::MultiObject multiObj1;\n    multiObj1.addObject(self.object1, self.tableName.UTF8String);\n    multiObj1.addObject(self.object1InTable2, self.tableName2.UTF8String);\n    TestCaseAssertTrue(self.object1 == multiObj1.objectAtTable<CPPTestCaseObject>(self.tableName.UTF8String).value());\n    TestCaseAssertTrue(self.object1InTable2 == multiObj1.objectAtTable<CPPTestCaseObject>(self.tableName2.UTF8String).value());\n    WCDB::MultiObject multiObj2;\n    multiObj2.addObject(self.object2, self.tableName.UTF8String);\n    multiObj2.addObject(self.object2InTable2, self.tableName2.UTF8String);\n    TestCaseAssertTrue(self.object2 == multiObj2.objectAtTable<CPPTestCaseObject>(self.tableName.UTF8String).value());\n    TestCaseAssertTrue(self.object2InTable2 == multiObj2.objectAtTable<CPPTestCaseObject>(self.tableName2.UTF8String).value());\n    [self doTestMultiObjects:{ multiObj1, multiObj2 }\n                      andSQL:@\"SELECT testTable.identifier, testTable.content, testTable2.identifier, testTable2.content FROM testTable, testTable2 WHERE testTable.identifier == testTable2.identifier\"\n                 bySelecting:^WCDB::OptionalMultiObjectArray {\n                     WCDB::ResultFields resultColumns\n                     = CPPTestCaseObject::allFields()\n                       .redirect([self](const WCDB::Field& field) -> WCDB::ResultColumn {\n                           return field.table(self.tableName.UTF8String);\n                       })\n                       .addingNewResultColumns(CPPTestCaseObject::allFields().redirect([self](const WCDB::Field& field) -> WCDB::ResultColumn {\n                           return field.table(self.tableName2.UTF8String);\n                       }));\n                     WCDB::MultiSelect select = self.database->getHandle().prepareMultiSelect().onResultFields(resultColumns).fromTables({ self.tableName.UTF8String, self.tableName2.UTF8String }).where(WCDB_FIELD(CPPTestCaseObject::identifier).table(self.tableName.UTF8String) == WCDB_FIELD(CPPTestCaseObject::identifier).table(self.tableName2.UTF8String));\n                     return select.allMultiObjects();\n                 }];\n}\n\n@end\n"
  },
  {
    "path": "src/cpp/tests/operation/ORMSelectTests.mm",
    "content": "//\n// Created by qiuwenchen on 2022/9/8.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"CPPTestCase.h\"\n\n@interface ORMSelectTests : CPPCRUDTestCase\n\n@property (nonatomic, assign) CPPTestCaseObject partialObject1;\n@property (nonatomic, assign) CPPTestCaseObject partialObject2;\n@property (nonatomic, assign) WCDB::ValueArray<CPPTestCaseObject> partialObjects;\n\n@property (nonatomic, assign) WCDB::OneRowValue partialRow1;\n@property (nonatomic, assign) WCDB::OneRowValue partialRow2;\n@property (nonatomic, assign) WCDB::MultiRowsValue partialRows;\n\n@property (nonatomic, assign) WCDB::Value value1;\n@property (nonatomic, assign) WCDB::Value value2;\n@property (nonatomic, assign) WCDB::OneColumnValue column;\n\n@end\n\n@implementation ORMSelectTests\n\n- (void)setUp\n{\n    [super setUp];\n    _partialObject1 = CPPTestCaseObject(1);\n    _partialObject2 = CPPTestCaseObject(2);\n    _partialObjects = { self.partialObject1, self.partialObject2 };\n    [self insertPresetObjects];\n\n    _partialRow1 = { 1 };\n    _partialRow2 = { 2 };\n    _partialRows = { _partialRow1, _partialRow2 };\n\n    _value1 = 1;\n    _value2 = 2;\n    _column = { _value1, _value2 };\n}\n\n#pragma mark - Database - Get Object\n- (void)test_database_get_object\n{\n    [self doTestObject:self.object1\n                andSQL:@\"SELECT identifier, content FROM testTable ORDER BY rowid ASC LIMIT 1\"\n           bySelecting:^WCDB::Optional<CPPTestCaseObject> {\n               return self.database->getFirstObject<CPPTestCaseObject>(self.tableName.UTF8String);\n           }];\n}\n\n- (void)test_database_get_object_where\n{\n    [self doTestObject:self.object2\n                andSQL:@\"SELECT identifier, content FROM testTable WHERE identifier == 2 ORDER BY rowid ASC LIMIT 1\"\n           bySelecting:^WCDB::Optional<CPPTestCaseObject> {\n               return self.database->getFirstObject<CPPTestCaseObject>(self.tableName.UTF8String, WCDB_FIELD(CPPTestCaseObject::identifier) == 2);\n           }];\n}\n\n- (void)test_database_get_object_where_orders\n{\n    [self doTestObject:self.object2\n                andSQL:@\"SELECT identifier, content FROM testTable WHERE identifier > 0 ORDER BY identifier DESC LIMIT 1\"\n           bySelecting:^WCDB::Optional<CPPTestCaseObject> {\n               return self.database->getFirstObject<CPPTestCaseObject>(self.tableName.UTF8String, WCDB_FIELD(CPPTestCaseObject::identifier) > 0, WCDB_FIELD(CPPTestCaseObject::identifier).asOrder(WCDB::Order::DESC));\n           }];\n}\n\n- (void)test_database_get_object_where_orders_offset\n{\n    [self doTestObject:self.object1\n                andSQL:@\"SELECT identifier, content FROM testTable WHERE identifier > 0 ORDER BY identifier DESC LIMIT 1 OFFSET 1\"\n           bySelecting:^WCDB::Optional<CPPTestCaseObject> {\n               return self.database->getFirstObject<CPPTestCaseObject>(self.tableName.UTF8String, WCDB_FIELD(CPPTestCaseObject::identifier) > 0, WCDB_FIELD(CPPTestCaseObject::identifier).asOrder(WCDB::Order::DESC), 1);\n           }];\n}\n\n#pragma mark - Database - Get Objects\n- (void)test_database_get_objects\n{\n    [self doTestObjects:self.objects\n                 andSQL:@\"SELECT identifier, content FROM testTable ORDER BY rowid ASC\"\n            bySelecting:^WCDB::OptionalValueArray<CPPTestCaseObject> {\n                return self.database->getAllObjects<CPPTestCaseObject>(self.tableName.UTF8String);\n            }];\n}\n\n- (void)test_database_get_objects_where\n{\n    [self doTestObjects:self.object1\n                 andSQL:@\"SELECT identifier, content FROM testTable WHERE identifier == 1 ORDER BY rowid ASC\"\n            bySelecting:^WCDB::OptionalValueArray<CPPTestCaseObject> {\n                return self.database->getAllObjects<CPPTestCaseObject>(self.tableName.UTF8String, WCDB_FIELD(CPPTestCaseObject::identifier) == 1);\n            }];\n}\n\n- (void)test_database_get_objects_where_orders\n{\n    [self doTestObjects:{ self.object2, self.object1 }\n                 andSQL:@\"SELECT identifier, content FROM testTable WHERE identifier > 0 ORDER BY identifier DESC\"\n            bySelecting:^WCDB::OptionalValueArray<CPPTestCaseObject> {\n                return self.database->getAllObjects<CPPTestCaseObject>(self.tableName.UTF8String, WCDB_FIELD(CPPTestCaseObject::identifier) > 0, WCDB_FIELD(CPPTestCaseObject::identifier).asOrder(WCDB::Order::DESC));\n            }];\n}\n\n- (void)test_database_get_objects_where_orders_limit\n{\n    [self doTestObjects:self.object2\n                 andSQL:@\"SELECT identifier, content FROM testTable WHERE identifier > 0 ORDER BY identifier DESC LIMIT 1\"\n            bySelecting:^WCDB::OptionalValueArray<CPPTestCaseObject> {\n                return self.database->getAllObjects<CPPTestCaseObject>(self.tableName.UTF8String, WCDB_FIELD(CPPTestCaseObject::identifier) > 0, WCDB_FIELD(CPPTestCaseObject::identifier).asOrder(WCDB::Order::DESC), 1);\n            }];\n}\n\n- (void)test_database_get_objects_where_orders_limit_offset\n{\n    [self doTestObjects:self.object1\n                 andSQL:@\"SELECT identifier, content FROM testTable WHERE identifier > 0 ORDER BY identifier DESC LIMIT 1 OFFSET 1\"\n            bySelecting:^WCDB::OptionalValueArray<CPPTestCaseObject> {\n                return self.database->getAllObjects<CPPTestCaseObject>(self.tableName.UTF8String, WCDB_FIELD(CPPTestCaseObject::identifier) > 0, WCDB_FIELD(CPPTestCaseObject::identifier).asOrder(WCDB::Order::DESC), 1, 1);\n            }];\n}\n\n#pragma mark - Database - Get Part Of Object\n- (void)test_database_get_object_on_result_columns\n{\n    [self doTestObject:self.partialObject1\n                andSQL:@\"SELECT identifier FROM testTable ORDER BY rowid ASC LIMIT 1\"\n           bySelecting:^WCDB::Optional<CPPTestCaseObject> {\n               return self.database->getFirstObjectWithFields<CPPTestCaseObject>(self.tableName.UTF8String, WCDB_FIELD(CPPTestCaseObject::identifier));\n           }];\n}\n\n- (void)test_database_get_object_on_result_columns_where\n{\n    [self doTestObject:self.partialObject1\n                andSQL:@\"SELECT identifier FROM testTable WHERE identifier == 1 ORDER BY rowid ASC LIMIT 1\"\n           bySelecting:^WCDB::Optional<CPPTestCaseObject> {\n               return self.database->getFirstObjectWithFields<CPPTestCaseObject>(self.tableName.UTF8String, WCDB_FIELD(CPPTestCaseObject::identifier), WCDB_FIELD(CPPTestCaseObject::identifier) == 1);\n           }];\n}\n\n- (void)test_database_get_object_on_result_columns_where_orders\n{\n    [self doTestObject:self.partialObject2\n                andSQL:@\"SELECT identifier FROM testTable WHERE identifier > 0 ORDER BY identifier DESC LIMIT 1\"\n           bySelecting:^WCDB::Optional<CPPTestCaseObject> {\n               return self.database->getFirstObjectWithFields<CPPTestCaseObject>(self.tableName.UTF8String, WCDB_FIELD(CPPTestCaseObject::identifier), WCDB_FIELD(CPPTestCaseObject::identifier) > 0, WCDB_FIELD(CPPTestCaseObject::identifier).asOrder(WCDB::Order::DESC));\n           }];\n}\n\n- (void)test_database_get_object_on_result_columns_where_orders_offset\n{\n    [self doTestObject:self.partialObject1\n                andSQL:@\"SELECT identifier FROM testTable WHERE identifier > 0 ORDER BY identifier DESC LIMIT 1 OFFSET 1\"\n           bySelecting:^WCDB::Optional<CPPTestCaseObject> {\n               return self.database->getFirstObjectWithFields<CPPTestCaseObject>(self.tableName.UTF8String, WCDB_FIELD(CPPTestCaseObject::identifier), WCDB_FIELD(CPPTestCaseObject::identifier) > 0, WCDB_FIELD(CPPTestCaseObject::identifier).asOrder(WCDB::Order::DESC), 1);\n           }];\n}\n\n#pragma mark - Database - Get Part Of Objects\n- (void)test_database_get_objects_on_result_columns\n{\n    [self doTestObjects:self.partialObjects\n                 andSQL:@\"SELECT identifier FROM testTable ORDER BY rowid ASC\"\n            bySelecting:^WCDB::OptionalValueArray<CPPTestCaseObject> {\n                return self.database->getAllObjectsWithFields<CPPTestCaseObject>(self.tableName.UTF8String, WCDB_FIELD(CPPTestCaseObject::identifier));\n            }];\n}\n\n- (void)test_database_get_objects_on_result_columns_where\n{\n    [self doTestObjects:self.partialObject1\n                 andSQL:@\"SELECT identifier FROM testTable WHERE identifier == 1 ORDER BY rowid ASC\"\n            bySelecting:^WCDB::OptionalValueArray<CPPTestCaseObject> {\n                return self.database->getAllObjectsWithFields<CPPTestCaseObject>(self.tableName.UTF8String, WCDB_FIELD(CPPTestCaseObject::identifier), WCDB_FIELD(CPPTestCaseObject::identifier) == 1);\n            }];\n}\n\n- (void)test_database_get_objects_on_result_columns_where_orders\n{\n    [self doTestObjects:{ self.partialObject2, self.partialObject1 }\n                 andSQL:@\"SELECT identifier FROM testTable WHERE identifier > 0 ORDER BY identifier DESC\"\n            bySelecting:^WCDB::OptionalValueArray<CPPTestCaseObject> {\n                return self.database->getAllObjectsWithFields<CPPTestCaseObject>(self.tableName.UTF8String, WCDB_FIELD(CPPTestCaseObject::identifier), WCDB_FIELD(CPPTestCaseObject::identifier) > 0, WCDB_FIELD(CPPTestCaseObject::identifier).asOrder(WCDB::Order::DESC));\n            }];\n}\n\n- (void)test_database_get_objects_on_result_columns_where_orders_limit\n{\n    [self doTestObjects:self.partialObject2\n                 andSQL:@\"SELECT identifier FROM testTable WHERE identifier > 0 ORDER BY identifier DESC LIMIT 1\"\n            bySelecting:^WCDB::OptionalValueArray<CPPTestCaseObject> {\n                return self.database->getAllObjectsWithFields<CPPTestCaseObject>(self.tableName.UTF8String, WCDB_FIELD(CPPTestCaseObject::identifier), WCDB_FIELD(CPPTestCaseObject::identifier) > 0, WCDB_FIELD(CPPTestCaseObject::identifier).asOrder(WCDB::Order::DESC), 1);\n            }];\n}\n\n- (void)test_database_get_objects_on_result_columns_where_orders_limit_offset\n{\n    [self doTestObjects:self.partialObject1\n                 andSQL:@\"SELECT identifier FROM testTable WHERE identifier > 0 ORDER BY identifier DESC LIMIT 1 OFFSET 1\"\n            bySelecting:^WCDB::OptionalValueArray<CPPTestCaseObject> {\n                return self.database->getAllObjectsWithFields<CPPTestCaseObject>(self.tableName.UTF8String, WCDB_FIELD(CPPTestCaseObject::identifier), WCDB_FIELD(CPPTestCaseObject::identifier) > 0, WCDB_FIELD(CPPTestCaseObject::identifier).asOrder(WCDB::Order::DESC), 1, 1);\n            }];\n}\n\n#pragma mark - Database - Get Value\n- (void)test_database_get_value\n{\n    [self doTestValue:self.object1.identifier\n               andSQL:@\"SELECT identifier FROM testTable LIMIT 1\"\n          bySelecting:^WCDB::OptionalValue {\n              return self.database->selectValue(WCDB_FIELD(CPPTestCaseObject::identifier), self.tableName.UTF8String);\n          }];\n}\n\n- (void)test_database_get_value_where\n{\n    [self doTestValue:self.object2.identifier\n               andSQL:@\"SELECT identifier FROM testTable WHERE identifier == 2 LIMIT 1\"\n          bySelecting:^WCDB::OptionalValue {\n              return self.database->selectValue(WCDB_FIELD(CPPTestCaseObject::identifier), self.tableName.UTF8String, WCDB_FIELD(CPPTestCaseObject::identifier) == 2);\n          }];\n}\n\n- (void)test_database_get_value_where_orders\n{\n    [self doTestValue:self.object2.identifier\n               andSQL:@\"SELECT identifier FROM testTable WHERE identifier > 0 ORDER BY identifier DESC LIMIT 1\"\n          bySelecting:^WCDB::OptionalValue {\n              return self.database->selectValue(WCDB_FIELD(CPPTestCaseObject::identifier), self.tableName.UTF8String, WCDB_FIELD(CPPTestCaseObject::identifier) > 0, WCDB_FIELD(CPPTestCaseObject::identifier).asOrder(WCDB::Order::DESC));\n          }];\n}\n\n- (void)test_database_get_value_where_orders_offset\n{\n    [self doTestValue:self.object1.identifier\n               andSQL:@\"SELECT identifier FROM testTable WHERE identifier > 0 ORDER BY identifier DESC LIMIT 1 OFFSET 1\"\n          bySelecting:^WCDB::OptionalValue {\n              return self.database->selectValue(WCDB_FIELD(CPPTestCaseObject::identifier), self.tableName.UTF8String, WCDB_FIELD(CPPTestCaseObject::identifier) > 0, WCDB_FIELD(CPPTestCaseObject::identifier).asOrder(WCDB::Order::DESC), 1);\n          }];\n}\n\n#pragma mark - Database - Get Row\n\n- (void)test_database_get_row\n{\n    [self doTestRow:{ self.object1.identifier, self.object1.content }\n             andSQL:@\"SELECT identifier, content FROM testTable LIMIT 1\"\n        bySelecting:^WCDB::OptionalOneRow {\n            return self.database->selectOneRow(CPPTestCaseObject::allFields(), self.tableName.UTF8String);\n        }];\n}\n\n- (void)test_database_get_row_where\n{\n    [self doTestRow:{ self.object2.identifier, self.object2.content }\n             andSQL:@\"SELECT identifier, content FROM testTable WHERE identifier == 2 LIMIT 1\"\n        bySelecting:^WCDB::OptionalOneRow {\n            return self.database->selectOneRow(CPPTestCaseObject::allFields(), self.tableName.UTF8String, WCDB_FIELD(CPPTestCaseObject::identifier) == 2);\n        }];\n}\n\n- (void)test_database_get_row_where_orders\n{\n    [self doTestRow:{ self.object2.identifier, self.object2.content }\n             andSQL:@\"SELECT identifier, content FROM testTable WHERE identifier > 0 ORDER BY identifier DESC LIMIT 1\"\n        bySelecting:^WCDB::OptionalOneRow {\n            return self.database->selectOneRow(CPPTestCaseObject::allFields(), self.tableName.UTF8String, WCDB_FIELD(CPPTestCaseObject::identifier) > 0, WCDB_FIELD(CPPTestCaseObject::identifier).asOrder(WCDB::Order::DESC));\n        }];\n}\n\n- (void)test_database_get_row_where_orders_offset\n{\n    [self doTestRow:{ self.object1.identifier, self.object1.content }\n             andSQL:@\"SELECT identifier, content FROM testTable WHERE identifier > 0 ORDER BY identifier DESC LIMIT 1 OFFSET 1\"\n        bySelecting:^WCDB::OptionalOneRow {\n            return self.database->selectOneRow(CPPTestCaseObject::allFields(), self.tableName.UTF8String, WCDB_FIELD(CPPTestCaseObject::identifier) > 0, WCDB_FIELD(CPPTestCaseObject::identifier).asOrder(WCDB::Order::DESC), 1);\n        }];\n}\n\n#pragma mark - Database - Get Column\n- (void)test_database_get_column\n{\n    [self doTestColumn:{ self.object1.identifier, self.object2.identifier }\n                andSQL:@\"SELECT identifier FROM testTable\"\n           bySelecting:^WCDB::OptionalOneColumn {\n               return self.database->selectOneColumn(WCDB_FIELD(CPPTestCaseObject::identifier), self.tableName.UTF8String);\n           }];\n}\n\n- (void)test_database_get_column_where\n{\n    [self doTestColumn:{ self.object1.identifier }\n                andSQL:@\"SELECT identifier FROM testTable WHERE identifier == 1\"\n           bySelecting:^WCDB::OptionalOneColumn {\n               return self.database->selectOneColumn(WCDB_FIELD(CPPTestCaseObject::identifier), self.tableName.UTF8String, WCDB_FIELD(CPPTestCaseObject::identifier) == 1);\n           }];\n}\n\n- (void)test_database_get_column_where_orders\n{\n    [self doTestColumn:{ self.object2.identifier, self.object1.identifier }\n                andSQL:@\"SELECT identifier FROM testTable WHERE identifier > 0 ORDER BY identifier DESC\"\n           bySelecting:^WCDB::OptionalOneColumn {\n               return self.database->selectOneColumn(WCDB_FIELD(CPPTestCaseObject::identifier), self.tableName.UTF8String, WCDB_FIELD(CPPTestCaseObject::identifier) > 0, WCDB_FIELD(CPPTestCaseObject::identifier).asOrder(WCDB::Order::DESC));\n           }];\n}\n\n- (void)test_database_get_column_where_orders_limit\n{\n    [self doTestColumn:{ self.object2.identifier }\n                andSQL:@\"SELECT identifier FROM testTable WHERE identifier > 0 ORDER BY identifier DESC LIMIT 1\"\n           bySelecting:^WCDB::OptionalOneColumn {\n               return self.database->selectOneColumn(WCDB_FIELD(CPPTestCaseObject::identifier), self.tableName.UTF8String, WCDB_FIELD(CPPTestCaseObject::identifier) > 0, WCDB_FIELD(CPPTestCaseObject::identifier).asOrder(WCDB::Order::DESC), 1);\n           }];\n}\n\n- (void)test_database_get_column_where_orders_limit_offset\n{\n    [self doTestColumn:{ self.object1.identifier }\n                andSQL:@\"SELECT identifier FROM testTable WHERE identifier > 0 ORDER BY identifier DESC LIMIT 1 OFFSET 1\"\n           bySelecting:^WCDB::OptionalOneColumn {\n               return self.database->selectOneColumn(WCDB_FIELD(CPPTestCaseObject::identifier), self.tableName.UTF8String, WCDB_FIELD(CPPTestCaseObject::identifier) > 0, WCDB_FIELD(CPPTestCaseObject::identifier).asOrder(WCDB::Order::DESC), 1, 1);\n           }];\n}\n\n#pragma mark - Database - Get Rows\n- (void)test_database_get_rows\n{\n    [self doTestRows:{ { self.object1.identifier, self.object1.content },\n                       { self.object2.identifier, self.object2.content } }\n              andSQL:@\"SELECT identifier, content FROM testTable\"\n         bySelecting:^WCDB::OptionalMultiRows {\n             return self.database->selectAllRow(CPPTestCaseObject::allFields(), self.tableName.UTF8String);\n         }];\n}\n\n- (void)test_database_get_rows_where\n{\n    [self doTestRows:{ { self.object1.identifier, self.object1.content } }\n              andSQL:@\"SELECT identifier, content FROM testTable WHERE identifier == 1\"\n         bySelecting:^WCDB::OptionalMultiRows {\n             return self.database->selectAllRow(CPPTestCaseObject::allFields(), self.tableName.UTF8String, WCDB_FIELD(CPPTestCaseObject::identifier) == 1);\n         }];\n}\n\n- (void)test_database_get_rows_where_orders\n{\n    [self doTestRows:{ { self.object2.identifier, self.object2.content },\n                       { self.object1.identifier, self.object1.content } }\n              andSQL:@\"SELECT identifier, content FROM testTable WHERE identifier > 0 ORDER BY identifier DESC\"\n         bySelecting:^WCDB::OptionalMultiRows {\n             return self.database->selectAllRow(CPPTestCaseObject::allFields(), self.tableName.UTF8String, WCDB_FIELD(CPPTestCaseObject::identifier) > 0, WCDB_FIELD(CPPTestCaseObject::identifier).asOrder(WCDB::Order::DESC));\n         }];\n}\n\n- (void)test_database_get_rows_where_orders_limit\n{\n    [self doTestRows:{ { self.object2.identifier, self.object2.content } }\n              andSQL:@\"SELECT identifier, content FROM testTable WHERE identifier > 0 ORDER BY identifier DESC LIMIT 1\"\n         bySelecting:^WCDB::OptionalMultiRows {\n             return self.database->selectAllRow(CPPTestCaseObject::allFields(), self.tableName.UTF8String, WCDB_FIELD(CPPTestCaseObject::identifier) > 0, WCDB_FIELD(CPPTestCaseObject::identifier).asOrder(WCDB::Order::DESC), 1);\n         }];\n}\n\n- (void)test_database_get_rows_where_orders_limit_offset\n{\n    [self doTestRows:{ { self.object1.identifier, self.object1.content } }\n              andSQL:@\"SELECT identifier, content FROM testTable WHERE identifier > 0 ORDER BY identifier DESC LIMIT 1 OFFSET 1\"\n         bySelecting:^WCDB::OptionalMultiRows {\n             return self.database->selectAllRow(CPPTestCaseObject::allFields(), self.tableName.UTF8String, WCDB_FIELD(CPPTestCaseObject::identifier) > 0, WCDB_FIELD(CPPTestCaseObject::identifier).asOrder(WCDB::Order::DESC), 1, 1);\n         }];\n}\n\n#pragma mark - Database - Get From Statement\n- (void)test_database_get_row_from_statement\n{\n    [self doTestRow:self.partialRow1\n             andSQL:@\"SELECT identifier FROM testTable ORDER BY rowid ASC LIMIT 1\"\n        bySelecting:^WCDB::OptionalOneRow {\n            return self.database->getOneRowFromStatement(WCDB::StatementSelect().select(WCDB_FIELD(CPPTestCaseObject::identifier)).from(self.tableName.UTF8String).order(WCDB::OrderingTerm::ascendingRowid()).limit(1));\n        }];\n}\n\n- (void)test_database_get_column_from_statement\n{\n    [self doTestColumn:self.column\n                andSQL:@\"SELECT identifier FROM testTable ORDER BY rowid ASC\"\n           bySelecting:^WCDB::OptionalOneColumn {\n               return self.database->getOneColumnFromStatement(WCDB::StatementSelect().select(WCDB_FIELD(CPPTestCaseObject::identifier)).from(self.tableName.UTF8String).order(WCDB::OrderingTerm::ascendingRowid()));\n           }];\n}\n\n- (void)test_database_get_value_from_statement\n{\n    [self doTestValue:self.value1\n               andSQL:@\"SELECT identifier FROM testTable ORDER BY rowid ASC LIMIT 1\"\n          bySelecting:^WCDB::OptionalValue {\n              return self.database->getValueFromStatement(WCDB::StatementSelect().select(WCDB_FIELD(CPPTestCaseObject::identifier)).from(self.tableName.UTF8String).order(WCDB::OrderingTerm::ascendingRowid()).limit(1));\n          }];\n}\n\n- (void)test_database_get_rows_from_statement\n{\n    [self doTestRows:self.partialRows\n              andSQL:@\"SELECT identifier FROM testTable ORDER BY rowid ASC\"\n         bySelecting:^WCDB::OptionalMultiRows {\n             return self.database->getAllRowsFromStatement(WCDB::StatementSelect().select(WCDB_FIELD(CPPTestCaseObject::identifier)).from(self.tableName.UTF8String).order(WCDB::OrderingTerm::ascendingRowid()));\n         }];\n}\n\n#pragma mark - Table - Get Object\n- (void)test_table_get_object\n{\n    [self doTestObject:self.object1\n                andSQL:@\"SELECT identifier, content FROM testTable ORDER BY rowid ASC LIMIT 1\"\n           bySelecting:^WCDB::Optional<CPPTestCaseObject> {\n               return self.table.getFirstObject();\n           }];\n}\n\n- (void)test_table_get_object_where\n{\n    [self doTestObject:self.object2\n                andSQL:@\"SELECT identifier, content FROM testTable WHERE identifier == 2 ORDER BY rowid ASC LIMIT 1\"\n           bySelecting:^WCDB::Optional<CPPTestCaseObject> {\n               return self.table.getFirstObject(WCDB_FIELD(CPPTestCaseObject::identifier) == 2);\n           }];\n}\n\n- (void)test_table_get_object_where_orders\n{\n    [self doTestObject:self.object2\n                andSQL:@\"SELECT identifier, content FROM testTable WHERE identifier > 0 ORDER BY identifier DESC LIMIT 1\"\n           bySelecting:^WCDB::Optional<CPPTestCaseObject> {\n               return self.table.getFirstObject(WCDB_FIELD(CPPTestCaseObject::identifier) > 0, WCDB_FIELD(CPPTestCaseObject::identifier).asOrder(WCDB::Order::DESC));\n           }];\n}\n\n- (void)test_table_get_object_where_orders_offset\n{\n    [self doTestObject:self.object1\n                andSQL:@\"SELECT identifier, content FROM testTable WHERE identifier > 0 ORDER BY identifier DESC LIMIT 1 OFFSET 1\"\n           bySelecting:^WCDB::Optional<CPPTestCaseObject> {\n               return self.table.getFirstObject(WCDB_FIELD(CPPTestCaseObject::identifier) > 0, WCDB_FIELD(CPPTestCaseObject::identifier).asOrder(WCDB::Order::DESC), 1);\n           }];\n}\n\n#pragma mark - Table - Get Objects\n- (void)test_table_get_objects\n{\n    [self doTestObjects:self.objects\n                 andSQL:@\"SELECT identifier, content FROM testTable ORDER BY rowid ASC\"\n            bySelecting:^WCDB::OptionalValueArray<CPPTestCaseObject> {\n                return self.table.getAllObjects();\n            }];\n}\n\n- (void)test_table_get_objects_where\n{\n    [self doTestObjects:self.object1\n                 andSQL:@\"SELECT identifier, content FROM testTable WHERE identifier == 1 ORDER BY rowid ASC\"\n            bySelecting:^WCDB::OptionalValueArray<CPPTestCaseObject> {\n                return self.table.getAllObjects(WCDB_FIELD(CPPTestCaseObject::identifier) == 1);\n            }];\n}\n\n- (void)test_table_get_objects_where_orders\n{\n    [self doTestObjects:{ self.object2, self.object1 }\n                 andSQL:@\"SELECT identifier, content FROM testTable WHERE identifier > 0 ORDER BY identifier DESC\"\n            bySelecting:^WCDB::OptionalValueArray<CPPTestCaseObject> {\n                return self.table.getAllObjects(WCDB_FIELD(CPPTestCaseObject::identifier) > 0, WCDB_FIELD(CPPTestCaseObject::identifier).asOrder(WCDB::Order::DESC));\n            }];\n}\n\n- (void)test_table_get_objects_where_orders_limit\n{\n    [self doTestObjects:self.object2\n                 andSQL:@\"SELECT identifier, content FROM testTable WHERE identifier > 0 ORDER BY identifier DESC LIMIT 1\"\n            bySelecting:^WCDB::OptionalValueArray<CPPTestCaseObject> {\n                return self.table.getAllObjects(WCDB_FIELD(CPPTestCaseObject::identifier) > 0, WCDB_FIELD(CPPTestCaseObject::identifier).asOrder(WCDB::Order::DESC), 1);\n            }];\n}\n\n- (void)test_table_get_objects_where_orders_limit_offset\n{\n    [self doTestObjects:self.object1\n                 andSQL:@\"SELECT identifier, content FROM testTable WHERE identifier > 0 ORDER BY identifier DESC LIMIT 1 OFFSET 1\"\n            bySelecting:^WCDB::OptionalValueArray<CPPTestCaseObject> {\n                return self.table.getAllObjects(WCDB_FIELD(CPPTestCaseObject::identifier) > 0, WCDB_FIELD(CPPTestCaseObject::identifier).asOrder(WCDB::Order::DESC), 1, 1);\n            }];\n}\n\n#pragma mark - Table - Get Part Of Object\n- (void)test_table_get_object_on_result_columns\n{\n    [self doTestObject:self.partialObject1\n                andSQL:@\"SELECT identifier FROM testTable ORDER BY rowid ASC LIMIT 1\"\n           bySelecting:^WCDB::Optional<CPPTestCaseObject> {\n               return self.table.getFirstObjectWithFields(WCDB_FIELD(CPPTestCaseObject::identifier));\n           }];\n}\n\n- (void)test_table_get_object_on_result_columns_where\n{\n    [self doTestObject:self.partialObject1\n                andSQL:@\"SELECT identifier FROM testTable WHERE identifier == 1 ORDER BY rowid ASC LIMIT 1\"\n           bySelecting:^WCDB::Optional<CPPTestCaseObject> {\n               return self.table.getFirstObjectWithFields(WCDB_FIELD(CPPTestCaseObject::identifier), WCDB_FIELD(CPPTestCaseObject::identifier) == 1);\n           }];\n}\n\n- (void)test_table_get_object_on_result_columns_where_orders\n{\n    [self doTestObject:self.partialObject2\n                andSQL:@\"SELECT identifier FROM testTable WHERE identifier > 0 ORDER BY identifier DESC LIMIT 1\"\n           bySelecting:^WCDB::Optional<CPPTestCaseObject> {\n               return self.table.getFirstObjectWithFields(WCDB_FIELD(CPPTestCaseObject::identifier), WCDB_FIELD(CPPTestCaseObject::identifier) > 0, WCDB_FIELD(CPPTestCaseObject::identifier).asOrder(WCDB::Order::DESC));\n           }];\n}\n\n- (void)test_table_get_object_on_result_columns_where_orders_offset\n{\n    [self doTestObject:self.partialObject1\n                andSQL:@\"SELECT identifier FROM testTable WHERE identifier > 0 ORDER BY identifier DESC LIMIT 1 OFFSET 1\"\n           bySelecting:^WCDB::Optional<CPPTestCaseObject> {\n               return self.table.getFirstObjectWithFields(WCDB_FIELD(CPPTestCaseObject::identifier), WCDB_FIELD(CPPTestCaseObject::identifier) > 0, WCDB_FIELD(CPPTestCaseObject::identifier).asOrder(WCDB::Order::DESC), 1);\n           }];\n}\n\n#pragma mark - Table - Get Part Of Objects\n- (void)test_table_get_objects_on_result_columns\n{\n    [self doTestObjects:self.partialObjects\n                 andSQL:@\"SELECT identifier FROM testTable ORDER BY rowid ASC\"\n            bySelecting:^WCDB::OptionalValueArray<CPPTestCaseObject> {\n                return self.table.getAllObjectsWithFields(WCDB_FIELD(CPPTestCaseObject::identifier));\n            }];\n}\n\n- (void)test_table_get_objects_on_result_columns_where\n{\n    [self doTestObjects:self.partialObject1\n                 andSQL:@\"SELECT identifier FROM testTable WHERE identifier == 1 ORDER BY rowid ASC\"\n            bySelecting:^WCDB::OptionalValueArray<CPPTestCaseObject> {\n                return self.table.getAllObjectsWithFields(WCDB_FIELD(CPPTestCaseObject::identifier), WCDB_FIELD(CPPTestCaseObject::identifier) == 1);\n            }];\n}\n\n- (void)test_table_get_objects_on_result_columns_where_orders\n{\n    [self doTestObjects:{ self.partialObject2, self.partialObject1 }\n                 andSQL:@\"SELECT identifier FROM testTable WHERE identifier > 0 ORDER BY identifier DESC\"\n            bySelecting:^WCDB::OptionalValueArray<CPPTestCaseObject> {\n                return self.table.getAllObjectsWithFields(WCDB_FIELD(CPPTestCaseObject::identifier), WCDB_FIELD(CPPTestCaseObject::identifier) > 0, WCDB_FIELD(CPPTestCaseObject::identifier).asOrder(WCDB::Order::DESC));\n            }];\n}\n\n- (void)test_table_get_objects_on_result_columns_where_orders_limit\n{\n    [self doTestObjects:self.partialObject2\n                 andSQL:@\"SELECT identifier FROM testTable WHERE identifier > 0 ORDER BY identifier DESC LIMIT 1\"\n            bySelecting:^WCDB::OptionalValueArray<CPPTestCaseObject> {\n                return self.table.getAllObjectsWithFields(WCDB_FIELD(CPPTestCaseObject::identifier), WCDB_FIELD(CPPTestCaseObject::identifier) > 0, WCDB_FIELD(CPPTestCaseObject::identifier).asOrder(WCDB::Order::DESC), 1);\n            }];\n}\n\n- (void)test_table_get_objects_on_result_columns_where_orders_limit_offset\n{\n    [self doTestObjects:self.partialObject1\n                 andSQL:@\"SELECT identifier FROM testTable WHERE identifier > 0 ORDER BY identifier DESC LIMIT 1 OFFSET 1\"\n            bySelecting:^WCDB::OptionalValueArray<CPPTestCaseObject> {\n                return self.table.getAllObjectsWithFields(WCDB_FIELD(CPPTestCaseObject::identifier), WCDB_FIELD(CPPTestCaseObject::identifier) > 0, WCDB_FIELD(CPPTestCaseObject::identifier).asOrder(WCDB::Order::DESC), 1, 1);\n            }];\n}\n\n#pragma mark - Table - Get Value\n- (void)test_table_get_value\n{\n    [self doTestValue:self.object1.identifier\n               andSQL:@\"SELECT identifier FROM testTable LIMIT 1\"\n          bySelecting:^WCDB::OptionalValue {\n              return self.table.selectValue(WCDB_FIELD(CPPTestCaseObject::identifier));\n          }];\n}\n\n- (void)test_table_get_value_where\n{\n    [self doTestValue:self.object2.identifier\n               andSQL:@\"SELECT identifier FROM testTable WHERE identifier == 2 LIMIT 1\"\n          bySelecting:^WCDB::OptionalValue {\n              return self.table.selectValue(WCDB_FIELD(CPPTestCaseObject::identifier), WCDB_FIELD(CPPTestCaseObject::identifier) == 2);\n          }];\n}\n\n- (void)test_table_get_value_where_orders\n{\n    [self doTestValue:self.object2.identifier\n               andSQL:@\"SELECT identifier FROM testTable WHERE identifier > 0 ORDER BY identifier DESC LIMIT 1\"\n          bySelecting:^WCDB::OptionalValue {\n              return self.table.selectValue(WCDB_FIELD(CPPTestCaseObject::identifier), WCDB_FIELD(CPPTestCaseObject::identifier) > 0, WCDB_FIELD(CPPTestCaseObject::identifier).asOrder(WCDB::Order::DESC));\n          }];\n}\n\n- (void)test_table_get_value_where_orders_offset\n{\n    [self doTestValue:self.object1.identifier\n               andSQL:@\"SELECT identifier FROM testTable WHERE identifier > 0 ORDER BY identifier DESC LIMIT 1 OFFSET 1\"\n          bySelecting:^WCDB::OptionalValue {\n              return self.table.selectValue(WCDB_FIELD(CPPTestCaseObject::identifier), WCDB_FIELD(CPPTestCaseObject::identifier) > 0, WCDB_FIELD(CPPTestCaseObject::identifier).asOrder(WCDB::Order::DESC), 1);\n          }];\n}\n\n#pragma mark - Table - Get Row\n\n- (void)test_table_get_row\n{\n    [self doTestRow:{ self.object1.identifier, self.object1.content }\n             andSQL:@\"SELECT identifier, content FROM testTable LIMIT 1\"\n        bySelecting:^WCDB::OptionalOneRow {\n            return self.table.selectOneRow(CPPTestCaseObject::allFields());\n        }];\n}\n\n- (void)test_table_get_row_where\n{\n    [self doTestRow:{ self.object2.identifier, self.object2.content }\n             andSQL:@\"SELECT identifier, content FROM testTable WHERE identifier == 2 LIMIT 1\"\n        bySelecting:^WCDB::OptionalOneRow {\n            return self.table.selectOneRow(CPPTestCaseObject::allFields(), WCDB_FIELD(CPPTestCaseObject::identifier) == 2);\n        }];\n}\n\n- (void)test_table_get_row_where_orders\n{\n    [self doTestRow:{ self.object2.identifier, self.object2.content }\n             andSQL:@\"SELECT identifier, content FROM testTable WHERE identifier > 0 ORDER BY identifier DESC LIMIT 1\"\n        bySelecting:^WCDB::OptionalOneRow {\n            return self.table.selectOneRow(CPPTestCaseObject::allFields(), WCDB_FIELD(CPPTestCaseObject::identifier) > 0, WCDB_FIELD(CPPTestCaseObject::identifier).asOrder(WCDB::Order::DESC));\n        }];\n}\n\n- (void)test_table_get_row_where_orders_offset\n{\n    [self doTestRow:{ self.object1.identifier, self.object1.content }\n             andSQL:@\"SELECT identifier, content FROM testTable WHERE identifier > 0 ORDER BY identifier DESC LIMIT 1 OFFSET 1\"\n        bySelecting:^WCDB::OptionalOneRow {\n            return self.table.selectOneRow(CPPTestCaseObject::allFields(), WCDB_FIELD(CPPTestCaseObject::identifier) > 0, WCDB_FIELD(CPPTestCaseObject::identifier).asOrder(WCDB::Order::DESC), 1);\n        }];\n}\n\n#pragma mark - Table - Get Column\n- (void)test_table_get_column\n{\n    [self doTestColumn:{ self.object1.identifier, self.object2.identifier }\n                andSQL:@\"SELECT identifier FROM testTable\"\n           bySelecting:^WCDB::OptionalOneColumn {\n               return self.table.selectOneColumn(WCDB_FIELD(CPPTestCaseObject::identifier));\n           }];\n}\n\n- (void)test_table_get_column_where\n{\n    [self doTestColumn:{ self.object1.identifier }\n                andSQL:@\"SELECT identifier FROM testTable WHERE identifier == 1\"\n           bySelecting:^WCDB::OptionalOneColumn {\n               return self.table.selectOneColumn(WCDB_FIELD(CPPTestCaseObject::identifier), WCDB_FIELD(CPPTestCaseObject::identifier) == 1);\n           }];\n}\n\n- (void)test_table_get_column_where_orders\n{\n    [self doTestColumn:{ self.object2.identifier, self.object1.identifier }\n                andSQL:@\"SELECT identifier FROM testTable WHERE identifier > 0 ORDER BY identifier DESC\"\n           bySelecting:^WCDB::OptionalOneColumn {\n               return self.table.selectOneColumn(WCDB_FIELD(CPPTestCaseObject::identifier), WCDB_FIELD(CPPTestCaseObject::identifier) > 0, WCDB_FIELD(CPPTestCaseObject::identifier).asOrder(WCDB::Order::DESC));\n           }];\n}\n\n- (void)test_table_get_column_where_orders_limit\n{\n    [self doTestColumn:{ self.object2.identifier }\n                andSQL:@\"SELECT identifier FROM testTable WHERE identifier > 0 ORDER BY identifier DESC LIMIT 1\"\n           bySelecting:^WCDB::OptionalOneColumn {\n               return self.table.selectOneColumn(WCDB_FIELD(CPPTestCaseObject::identifier), WCDB_FIELD(CPPTestCaseObject::identifier) > 0, WCDB_FIELD(CPPTestCaseObject::identifier).asOrder(WCDB::Order::DESC), 1);\n           }];\n}\n\n- (void)test_table_get_column_where_orders_limit_offset\n{\n    [self doTestColumn:{ self.object1.identifier }\n                andSQL:@\"SELECT identifier FROM testTable WHERE identifier > 0 ORDER BY identifier DESC LIMIT 1 OFFSET 1\"\n           bySelecting:^WCDB::OptionalOneColumn {\n               return self.table.selectOneColumn(WCDB_FIELD(CPPTestCaseObject::identifier), WCDB_FIELD(CPPTestCaseObject::identifier) > 0, WCDB_FIELD(CPPTestCaseObject::identifier).asOrder(WCDB::Order::DESC), 1, 1);\n           }];\n}\n\n#pragma mark - Table - Get Rows\n- (void)test_table_get_rows\n{\n    [self doTestRows:{ { self.object1.identifier, self.object1.content },\n                       { self.object2.identifier, self.object2.content } }\n              andSQL:@\"SELECT identifier, content FROM testTable\"\n         bySelecting:^WCDB::OptionalMultiRows {\n             return self.table.selectAllRow(CPPTestCaseObject::allFields());\n         }];\n}\n\n- (void)test_table_get_rows_where\n{\n    [self doTestRows:{ { self.object1.identifier, self.object1.content } }\n              andSQL:@\"SELECT identifier, content FROM testTable WHERE identifier == 1\"\n         bySelecting:^WCDB::OptionalMultiRows {\n             return self.table.selectAllRow(CPPTestCaseObject::allFields(), WCDB_FIELD(CPPTestCaseObject::identifier) == 1);\n         }];\n}\n\n- (void)test_table_get_rows_where_orders\n{\n    [self doTestRows:{ { self.object2.identifier, self.object2.content },\n                       { self.object1.identifier, self.object1.content } }\n              andSQL:@\"SELECT identifier, content FROM testTable WHERE identifier > 0 ORDER BY identifier DESC\"\n         bySelecting:^WCDB::OptionalMultiRows {\n             return self.table.selectAllRow(CPPTestCaseObject::allFields(), WCDB_FIELD(CPPTestCaseObject::identifier) > 0, WCDB_FIELD(CPPTestCaseObject::identifier).asOrder(WCDB::Order::DESC));\n         }];\n}\n\n- (void)test_table_get_rows_where_orders_limit\n{\n    [self doTestRows:{ { self.object2.identifier, self.object2.content } }\n              andSQL:@\"SELECT identifier, content FROM testTable WHERE identifier > 0 ORDER BY identifier DESC LIMIT 1\"\n         bySelecting:^WCDB::OptionalMultiRows {\n             return self.table.selectAllRow(CPPTestCaseObject::allFields(), WCDB_FIELD(CPPTestCaseObject::identifier) > 0, WCDB_FIELD(CPPTestCaseObject::identifier).asOrder(WCDB::Order::DESC), 1);\n         }];\n}\n\n- (void)test_table_get_rows_where_orders_limit_offset\n{\n    [self doTestRows:{ { self.object1.identifier, self.object1.content } }\n              andSQL:@\"SELECT identifier, content FROM testTable WHERE identifier > 0 ORDER BY identifier DESC LIMIT 1 OFFSET 1\"\n         bySelecting:^WCDB::OptionalMultiRows {\n             return self.table.selectAllRow(CPPTestCaseObject::allFields(), WCDB_FIELD(CPPTestCaseObject::identifier) > 0, WCDB_FIELD(CPPTestCaseObject::identifier).asOrder(WCDB::Order::DESC), 1, 1);\n         }];\n}\n\n#pragma mark - Table - Get From Statement\n- (void)test_table_get_row_from_statement\n{\n    [self doTestRow:self.partialRow1\n             andSQL:@\"SELECT identifier FROM testTable ORDER BY rowid ASC LIMIT 1\"\n        bySelecting:^WCDB::OptionalOneRow {\n            return self.table.getOneRowFromStatement(WCDB::StatementSelect().select(WCDB_FIELD(CPPTestCaseObject::identifier)).from(self.tableName.UTF8String).order(WCDB::OrderingTerm::ascendingRowid()).limit(1));\n        }];\n}\n\n- (void)test_table_get_column_from_statement\n{\n    [self doTestColumn:self.column\n                andSQL:@\"SELECT identifier FROM testTable ORDER BY rowid ASC\"\n           bySelecting:^WCDB::OptionalOneColumn {\n               return self.table.getOneColumnFromStatement(WCDB::StatementSelect().select(WCDB_FIELD(CPPTestCaseObject::identifier)).from(self.tableName.UTF8String).order(WCDB::OrderingTerm::ascendingRowid()));\n           }];\n}\n\n- (void)test_table_get_value_from_statement\n{\n    [self doTestValue:self.value1\n               andSQL:@\"SELECT identifier FROM testTable ORDER BY rowid ASC LIMIT 1\"\n          bySelecting:^WCDB::OptionalValue {\n              return self.table.getValueFromStatement(WCDB::StatementSelect().select(WCDB_FIELD(CPPTestCaseObject::identifier)).from(self.tableName.UTF8String).order(WCDB::OrderingTerm::ascendingRowid()).limit(1));\n          }];\n}\n\n- (void)test_table_get_rows_from_statement\n{\n    [self doTestRows:self.partialRows\n              andSQL:@\"SELECT identifier FROM testTable ORDER BY rowid ASC\"\n         bySelecting:^WCDB::OptionalMultiRows {\n             return self.table.getAllRowsFromStatement(WCDB::StatementSelect().select(WCDB_FIELD(CPPTestCaseObject::identifier)).from(self.tableName.UTF8String).order(WCDB::OrderingTerm::ascendingRowid()));\n         }];\n}\n\n#pragma mark - Handle - Get Object\n- (void)test_handle_get_object\n{\n    [self doTestObject:self.object1\n                andSQL:@\"SELECT identifier, content FROM testTable ORDER BY rowid ASC LIMIT 1\"\n           bySelecting:^WCDB::Optional<CPPTestCaseObject> {\n               return self.database->getHandle().getFirstObject<CPPTestCaseObject>(self.tableName.UTF8String);\n           }];\n}\n\n- (void)test_handle_get_object_where\n{\n    [self doTestObject:self.object2\n                andSQL:@\"SELECT identifier, content FROM testTable WHERE identifier == 2 ORDER BY rowid ASC LIMIT 1\"\n           bySelecting:^WCDB::Optional<CPPTestCaseObject> {\n               return self.database->getHandle().getFirstObject<CPPTestCaseObject>(self.tableName.UTF8String, WCDB_FIELD(CPPTestCaseObject::identifier) == 2);\n           }];\n}\n\n- (void)test_handle_get_object_where_orders\n{\n    [self doTestObject:self.object2\n                andSQL:@\"SELECT identifier, content FROM testTable WHERE identifier > 0 ORDER BY identifier DESC LIMIT 1\"\n           bySelecting:^WCDB::Optional<CPPTestCaseObject> {\n               return self.database->getHandle().getFirstObject<CPPTestCaseObject>(self.tableName.UTF8String, WCDB_FIELD(CPPTestCaseObject::identifier) > 0, WCDB_FIELD(CPPTestCaseObject::identifier).asOrder(WCDB::Order::DESC));\n           }];\n}\n\n- (void)test_handle_get_object_where_orders_offset\n{\n    [self doTestObject:self.object1\n                andSQL:@\"SELECT identifier, content FROM testTable WHERE identifier > 0 ORDER BY identifier DESC LIMIT 1 OFFSET 1\"\n           bySelecting:^WCDB::Optional<CPPTestCaseObject> {\n               return self.database->getHandle().getFirstObject<CPPTestCaseObject>(self.tableName.UTF8String, WCDB_FIELD(CPPTestCaseObject::identifier) > 0, WCDB_FIELD(CPPTestCaseObject::identifier).asOrder(WCDB::Order::DESC), 1);\n           }];\n}\n\n#pragma mark - Handle - Get Objects\n- (void)test_handle_get_objects\n{\n    [self doTestObjects:self.objects\n                 andSQL:@\"SELECT identifier, content FROM testTable ORDER BY rowid ASC\"\n            bySelecting:^WCDB::OptionalValueArray<CPPTestCaseObject> {\n                return self.database->getHandle().getAllObjects<CPPTestCaseObject>(self.tableName.UTF8String);\n            }];\n}\n\n- (void)test_handle_get_objects_where\n{\n    [self doTestObjects:self.object1\n                 andSQL:@\"SELECT identifier, content FROM testTable WHERE identifier == 1 ORDER BY rowid ASC\"\n            bySelecting:^WCDB::OptionalValueArray<CPPTestCaseObject> {\n                return self.database->getHandle().getAllObjects<CPPTestCaseObject>(self.tableName.UTF8String, WCDB_FIELD(CPPTestCaseObject::identifier) == 1);\n            }];\n}\n\n- (void)test_handle_get_objects_where_orders\n{\n    [self doTestObjects:{ self.object2, self.object1 }\n                 andSQL:@\"SELECT identifier, content FROM testTable WHERE identifier > 0 ORDER BY identifier DESC\"\n            bySelecting:^WCDB::OptionalValueArray<CPPTestCaseObject> {\n                return self.database->getHandle().getAllObjects<CPPTestCaseObject>(self.tableName.UTF8String, WCDB_FIELD(CPPTestCaseObject::identifier) > 0, WCDB_FIELD(CPPTestCaseObject::identifier).asOrder(WCDB::Order::DESC));\n            }];\n}\n\n- (void)test_handle_get_objects_where_orders_limit\n{\n    [self doTestObjects:self.object2\n                 andSQL:@\"SELECT identifier, content FROM testTable WHERE identifier > 0 ORDER BY identifier DESC LIMIT 1\"\n            bySelecting:^WCDB::OptionalValueArray<CPPTestCaseObject> {\n                return self.database->getHandle().getAllObjects<CPPTestCaseObject>(self.tableName.UTF8String, WCDB_FIELD(CPPTestCaseObject::identifier) > 0, WCDB_FIELD(CPPTestCaseObject::identifier).asOrder(WCDB::Order::DESC), 1);\n            }];\n}\n\n- (void)test_handle_get_objects_where_orders_limit_offset\n{\n    [self doTestObjects:self.object1\n                 andSQL:@\"SELECT identifier, content FROM testTable WHERE identifier > 0 ORDER BY identifier DESC LIMIT 1 OFFSET 1\"\n            bySelecting:^WCDB::OptionalValueArray<CPPTestCaseObject> {\n                return self.database->getHandle().getAllObjects<CPPTestCaseObject>(self.tableName.UTF8String, WCDB_FIELD(CPPTestCaseObject::identifier) > 0, WCDB_FIELD(CPPTestCaseObject::identifier).asOrder(WCDB::Order::DESC), 1, 1);\n            }];\n}\n\n#pragma mark - Handle - Get Part Of Object\n- (void)test_handle_get_object_on_result_columns\n{\n    [self doTestObject:self.partialObject1\n                andSQL:@\"SELECT identifier FROM testTable ORDER BY rowid ASC LIMIT 1\"\n           bySelecting:^WCDB::Optional<CPPTestCaseObject> {\n               return self.database->getHandle().getFirstObjectWithFields<CPPTestCaseObject>(self.tableName.UTF8String, WCDB_FIELD(CPPTestCaseObject::identifier));\n           }];\n}\n\n- (void)test_handle_get_object_on_result_columns_where\n{\n    [self doTestObject:self.partialObject1\n                andSQL:@\"SELECT identifier FROM testTable WHERE identifier == 1 ORDER BY rowid ASC LIMIT 1\"\n           bySelecting:^WCDB::Optional<CPPTestCaseObject> {\n               return self.database->getHandle().getFirstObjectWithFields<CPPTestCaseObject>(self.tableName.UTF8String, WCDB_FIELD(CPPTestCaseObject::identifier), WCDB_FIELD(CPPTestCaseObject::identifier) == 1);\n           }];\n}\n\n- (void)test_handle_get_object_on_result_columns_where_orders\n{\n    [self doTestObject:self.partialObject2\n                andSQL:@\"SELECT identifier FROM testTable WHERE identifier > 0 ORDER BY identifier DESC LIMIT 1\"\n           bySelecting:^WCDB::Optional<CPPTestCaseObject> {\n               return self.database->getHandle().getFirstObjectWithFields<CPPTestCaseObject>(self.tableName.UTF8String, WCDB_FIELD(CPPTestCaseObject::identifier), WCDB_FIELD(CPPTestCaseObject::identifier) > 0, WCDB_FIELD(CPPTestCaseObject::identifier).asOrder(WCDB::Order::DESC));\n           }];\n}\n\n- (void)test_handle_get_object_on_result_columns_where_orders_offset\n{\n    [self doTestObject:self.partialObject1\n                andSQL:@\"SELECT identifier FROM testTable WHERE identifier > 0 ORDER BY identifier DESC LIMIT 1 OFFSET 1\"\n           bySelecting:^WCDB::Optional<CPPTestCaseObject> {\n               return self.database->getHandle().getFirstObjectWithFields<CPPTestCaseObject>(self.tableName.UTF8String, WCDB_FIELD(CPPTestCaseObject::identifier), WCDB_FIELD(CPPTestCaseObject::identifier) > 0, WCDB_FIELD(CPPTestCaseObject::identifier).asOrder(WCDB::Order::DESC), 1);\n           }];\n}\n\n#pragma mark - Handle - Get Part Of Objects\n- (void)test_handle_get_objects_on_result_columns\n{\n    [self doTestObjects:self.partialObjects\n                 andSQL:@\"SELECT identifier FROM testTable ORDER BY rowid ASC\"\n            bySelecting:^WCDB::OptionalValueArray<CPPTestCaseObject> {\n                return self.database->getHandle().getAllObjectsWithFields<CPPTestCaseObject>(self.tableName.UTF8String, WCDB_FIELD(CPPTestCaseObject::identifier));\n            }];\n}\n\n- (void)test_handle_get_objects_on_result_columns_where\n{\n    [self doTestObjects:self.partialObject1\n                 andSQL:@\"SELECT identifier FROM testTable WHERE identifier == 1 ORDER BY rowid ASC\"\n            bySelecting:^WCDB::OptionalValueArray<CPPTestCaseObject> {\n                return self.database->getHandle().getAllObjectsWithFields<CPPTestCaseObject>(self.tableName.UTF8String, WCDB_FIELD(CPPTestCaseObject::identifier), WCDB_FIELD(CPPTestCaseObject::identifier) == 1);\n            }];\n}\n\n- (void)test_handle_get_objects_on_result_columns_where_orders\n{\n    [self doTestObjects:{ self.partialObject2, self.partialObject1 }\n                 andSQL:@\"SELECT identifier FROM testTable WHERE identifier > 0 ORDER BY identifier DESC\"\n            bySelecting:^WCDB::OptionalValueArray<CPPTestCaseObject> {\n                return self.database->getHandle().getAllObjectsWithFields<CPPTestCaseObject>(self.tableName.UTF8String, WCDB_FIELD(CPPTestCaseObject::identifier), WCDB_FIELD(CPPTestCaseObject::identifier) > 0, WCDB_FIELD(CPPTestCaseObject::identifier).asOrder(WCDB::Order::DESC));\n            }];\n}\n\n- (void)test_handle_get_objects_on_result_columns_where_orders_limit\n{\n    [self doTestObjects:self.partialObject2\n                 andSQL:@\"SELECT identifier FROM testTable WHERE identifier > 0 ORDER BY identifier DESC LIMIT 1\"\n            bySelecting:^WCDB::OptionalValueArray<CPPTestCaseObject> {\n                return self.database->getHandle().getAllObjectsWithFields<CPPTestCaseObject>(self.tableName.UTF8String, WCDB_FIELD(CPPTestCaseObject::identifier), WCDB_FIELD(CPPTestCaseObject::identifier) > 0, WCDB_FIELD(CPPTestCaseObject::identifier).asOrder(WCDB::Order::DESC), 1);\n            }];\n}\n\n- (void)test_handle_get_objects_on_result_columns_where_orders_limit_offset\n{\n    [self doTestObjects:self.partialObject1\n                 andSQL:@\"SELECT identifier FROM testTable WHERE identifier > 0 ORDER BY identifier DESC LIMIT 1 OFFSET 1\"\n            bySelecting:^WCDB::OptionalValueArray<CPPTestCaseObject> {\n                return self.database->getHandle().getAllObjectsWithFields<CPPTestCaseObject>(self.tableName.UTF8String, WCDB_FIELD(CPPTestCaseObject::identifier), WCDB_FIELD(CPPTestCaseObject::identifier) > 0, WCDB_FIELD(CPPTestCaseObject::identifier).asOrder(WCDB::Order::DESC), 1, 1);\n            }];\n}\n\n#pragma mark - Handle - Get Value\n- (void)test_handle_get_value\n{\n    [self doTestValue:self.object1.identifier\n               andSQL:@\"SELECT identifier FROM testTable LIMIT 1\"\n          bySelecting:^WCDB::OptionalValue {\n              return self.database->getHandle().selectValue(WCDB_FIELD(CPPTestCaseObject::identifier), self.tableName.UTF8String);\n          }];\n}\n\n- (void)test_handle_get_value_where\n{\n    [self doTestValue:self.object2.identifier\n               andSQL:@\"SELECT identifier FROM testTable WHERE identifier == 2 LIMIT 1\"\n          bySelecting:^WCDB::OptionalValue {\n              return self.database->getHandle().selectValue(WCDB_FIELD(CPPTestCaseObject::identifier), self.tableName.UTF8String, WCDB_FIELD(CPPTestCaseObject::identifier) == 2);\n          }];\n}\n\n- (void)test_handle_get_value_where_orders\n{\n    [self doTestValue:self.object2.identifier\n               andSQL:@\"SELECT identifier FROM testTable WHERE identifier > 0 ORDER BY identifier DESC LIMIT 1\"\n          bySelecting:^WCDB::OptionalValue {\n              return self.database->getHandle().selectValue(WCDB_FIELD(CPPTestCaseObject::identifier), self.tableName.UTF8String, WCDB_FIELD(CPPTestCaseObject::identifier) > 0, WCDB_FIELD(CPPTestCaseObject::identifier).asOrder(WCDB::Order::DESC));\n          }];\n}\n\n- (void)test_handle_get_value_where_orders_offset\n{\n    [self doTestValue:self.object1.identifier\n               andSQL:@\"SELECT identifier FROM testTable WHERE identifier > 0 ORDER BY identifier DESC LIMIT 1 OFFSET 1\"\n          bySelecting:^WCDB::OptionalValue {\n              return self.database->getHandle().selectValue(WCDB_FIELD(CPPTestCaseObject::identifier), self.tableName.UTF8String, WCDB_FIELD(CPPTestCaseObject::identifier) > 0, WCDB_FIELD(CPPTestCaseObject::identifier).asOrder(WCDB::Order::DESC), 1);\n          }];\n}\n\n#pragma mark - Handle - Get Row\n\n- (void)test_handle_get_row\n{\n    [self doTestRow:{ self.object1.identifier, self.object1.content }\n             andSQL:@\"SELECT identifier, content FROM testTable LIMIT 1\"\n        bySelecting:^WCDB::OptionalOneRow {\n            return self.database->getHandle().selectOneRow(CPPTestCaseObject::allFields(), self.tableName.UTF8String);\n        }];\n}\n\n- (void)test_handle_get_row_where\n{\n    [self doTestRow:{ self.object2.identifier, self.object2.content }\n             andSQL:@\"SELECT identifier, content FROM testTable WHERE identifier == 2 LIMIT 1\"\n        bySelecting:^WCDB::OptionalOneRow {\n            return self.database->getHandle().selectOneRow(CPPTestCaseObject::allFields(), self.tableName.UTF8String, WCDB_FIELD(CPPTestCaseObject::identifier) == 2);\n        }];\n}\n\n- (void)test_handle_get_row_where_orders\n{\n    [self doTestRow:{ self.object2.identifier, self.object2.content }\n             andSQL:@\"SELECT identifier, content FROM testTable WHERE identifier > 0 ORDER BY identifier DESC LIMIT 1\"\n        bySelecting:^WCDB::OptionalOneRow {\n            return self.database->getHandle().selectOneRow(CPPTestCaseObject::allFields(), self.tableName.UTF8String, WCDB_FIELD(CPPTestCaseObject::identifier) > 0, WCDB_FIELD(CPPTestCaseObject::identifier).asOrder(WCDB::Order::DESC));\n        }];\n}\n\n- (void)test_handle_get_row_where_orders_offset\n{\n    [self doTestRow:{ self.object1.identifier, self.object1.content }\n             andSQL:@\"SELECT identifier, content FROM testTable WHERE identifier > 0 ORDER BY identifier DESC LIMIT 1 OFFSET 1\"\n        bySelecting:^WCDB::OptionalOneRow {\n            return self.database->getHandle().selectOneRow(CPPTestCaseObject::allFields(), self.tableName.UTF8String, WCDB_FIELD(CPPTestCaseObject::identifier) > 0, WCDB_FIELD(CPPTestCaseObject::identifier).asOrder(WCDB::Order::DESC), 1);\n        }];\n}\n\n#pragma mark - Handle - Get Column\n- (void)test_handle_get_column\n{\n    [self doTestColumn:{ self.object1.identifier, self.object2.identifier }\n                andSQL:@\"SELECT identifier FROM testTable\"\n           bySelecting:^WCDB::OptionalOneColumn {\n               return self.database->getHandle().selectOneColumn(WCDB_FIELD(CPPTestCaseObject::identifier), self.tableName.UTF8String);\n           }];\n}\n\n- (void)test_handle_get_column_where\n{\n    [self doTestColumn:{ self.object1.identifier }\n                andSQL:@\"SELECT identifier FROM testTable WHERE identifier == 1\"\n           bySelecting:^WCDB::OptionalOneColumn {\n               return self.database->getHandle().selectOneColumn(WCDB_FIELD(CPPTestCaseObject::identifier), self.tableName.UTF8String, WCDB_FIELD(CPPTestCaseObject::identifier) == 1);\n           }];\n}\n\n- (void)test_handle_get_column_where_orders\n{\n    [self doTestColumn:{ self.object2.identifier, self.object1.identifier }\n                andSQL:@\"SELECT identifier FROM testTable WHERE identifier > 0 ORDER BY identifier DESC\"\n           bySelecting:^WCDB::OptionalOneColumn {\n               return self.database->getHandle().selectOneColumn(WCDB_FIELD(CPPTestCaseObject::identifier), self.tableName.UTF8String, WCDB_FIELD(CPPTestCaseObject::identifier) > 0, WCDB_FIELD(CPPTestCaseObject::identifier).asOrder(WCDB::Order::DESC));\n           }];\n}\n\n- (void)test_handle_get_column_where_orders_limit\n{\n    [self doTestColumn:{ self.object2.identifier }\n                andSQL:@\"SELECT identifier FROM testTable WHERE identifier > 0 ORDER BY identifier DESC LIMIT 1\"\n           bySelecting:^WCDB::OptionalOneColumn {\n               return self.database->getHandle().selectOneColumn(WCDB_FIELD(CPPTestCaseObject::identifier), self.tableName.UTF8String, WCDB_FIELD(CPPTestCaseObject::identifier) > 0, WCDB_FIELD(CPPTestCaseObject::identifier).asOrder(WCDB::Order::DESC), 1);\n           }];\n}\n\n- (void)test_handle_get_column_where_orders_limit_offset\n{\n    [self doTestColumn:{ self.object1.identifier }\n                andSQL:@\"SELECT identifier FROM testTable WHERE identifier > 0 ORDER BY identifier DESC LIMIT 1 OFFSET 1\"\n           bySelecting:^WCDB::OptionalOneColumn {\n               return self.database->getHandle().selectOneColumn(WCDB_FIELD(CPPTestCaseObject::identifier), self.tableName.UTF8String, WCDB_FIELD(CPPTestCaseObject::identifier) > 0, WCDB_FIELD(CPPTestCaseObject::identifier).asOrder(WCDB::Order::DESC), 1, 1);\n           }];\n}\n\n#pragma mark - Handle - Get Rows\n- (void)test_handle_get_rows\n{\n    [self doTestRows:{ { self.object1.identifier, self.object1.content },\n                       { self.object2.identifier, self.object2.content } }\n              andSQL:@\"SELECT identifier, content FROM testTable\"\n         bySelecting:^WCDB::OptionalMultiRows {\n             return self.database->getHandle().selectAllRow(CPPTestCaseObject::allFields(), self.tableName.UTF8String);\n         }];\n}\n\n- (void)test_handle_get_rows_where\n{\n    [self doTestRows:{ { self.object1.identifier, self.object1.content } }\n              andSQL:@\"SELECT identifier, content FROM testTable WHERE identifier == 1\"\n         bySelecting:^WCDB::OptionalMultiRows {\n             return self.database->getHandle().selectAllRow(CPPTestCaseObject::allFields(), self.tableName.UTF8String, WCDB_FIELD(CPPTestCaseObject::identifier) == 1);\n         }];\n}\n\n- (void)test_handle_get_rows_where_orders\n{\n    [self doTestRows:{ { self.object2.identifier, self.object2.content },\n                       { self.object1.identifier, self.object1.content } }\n              andSQL:@\"SELECT identifier, content FROM testTable WHERE identifier > 0 ORDER BY identifier DESC\"\n         bySelecting:^WCDB::OptionalMultiRows {\n             return self.database->getHandle().selectAllRow(CPPTestCaseObject::allFields(), self.tableName.UTF8String, WCDB_FIELD(CPPTestCaseObject::identifier) > 0, WCDB_FIELD(CPPTestCaseObject::identifier).asOrder(WCDB::Order::DESC));\n         }];\n}\n\n- (void)test_handle_get_rows_where_orders_limit\n{\n    [self doTestRows:{ { self.object2.identifier, self.object2.content } }\n              andSQL:@\"SELECT identifier, content FROM testTable WHERE identifier > 0 ORDER BY identifier DESC LIMIT 1\"\n         bySelecting:^WCDB::OptionalMultiRows {\n             return self.database->getHandle().selectAllRow(CPPTestCaseObject::allFields(), self.tableName.UTF8String, WCDB_FIELD(CPPTestCaseObject::identifier) > 0, WCDB_FIELD(CPPTestCaseObject::identifier).asOrder(WCDB::Order::DESC), 1);\n         }];\n}\n\n- (void)test_handle_get_rows_where_orders_limit_offset\n{\n    [self doTestRows:{ { self.object1.identifier, self.object1.content } }\n              andSQL:@\"SELECT identifier, content FROM testTable WHERE identifier > 0 ORDER BY identifier DESC LIMIT 1 OFFSET 1\"\n         bySelecting:^WCDB::OptionalMultiRows {\n             return self.database->getHandle().selectAllRow(CPPTestCaseObject::allFields(), self.tableName.UTF8String, WCDB_FIELD(CPPTestCaseObject::identifier) > 0, WCDB_FIELD(CPPTestCaseObject::identifier).asOrder(WCDB::Order::DESC), 1, 1);\n         }];\n}\n\n#pragma mark - Handle - Get From Statement\n- (void)test_handle_get_row_from_statement\n{\n    [self doTestRow:self.partialRow1\n             andSQL:@\"SELECT identifier FROM testTable ORDER BY rowid ASC LIMIT 1\"\n        bySelecting:^WCDB::OptionalOneRow {\n            return self.database->getHandle().getOneRowFromStatement(WCDB::StatementSelect().select(WCDB_FIELD(CPPTestCaseObject::identifier)).from(self.tableName.UTF8String).order(WCDB::OrderingTerm::ascendingRowid()).limit(1));\n        }];\n}\n\n- (void)test_handle_get_column_from_statement\n{\n    [self doTestColumn:self.column\n                andSQL:@\"SELECT identifier FROM testTable ORDER BY rowid ASC\"\n           bySelecting:^WCDB::OptionalOneColumn {\n               return self.database->getHandle().getOneColumnFromStatement(WCDB::StatementSelect().select(WCDB_FIELD(CPPTestCaseObject::identifier)).from(self.tableName.UTF8String).order(WCDB::OrderingTerm::ascendingRowid()));\n           }];\n}\n\n- (void)test_handle_get_value_from_statement\n{\n    [self doTestValue:self.value1\n               andSQL:@\"SELECT identifier FROM testTable ORDER BY rowid ASC LIMIT 1\"\n          bySelecting:^WCDB::OptionalValue {\n              return self.database->getHandle().getValueFromStatement(WCDB::StatementSelect().select(WCDB_FIELD(CPPTestCaseObject::identifier)).from(self.tableName.UTF8String).order(WCDB::OrderingTerm::ascendingRowid()).limit(1));\n          }];\n}\n\n- (void)test_handle_get_rows_from_statement\n{\n    [self doTestRows:self.partialRows\n              andSQL:@\"SELECT identifier FROM testTable ORDER BY rowid ASC\"\n         bySelecting:^WCDB::OptionalMultiRows {\n             return self.database->getHandle().getAllRowsFromStatement(WCDB::StatementSelect().select(WCDB_FIELD(CPPTestCaseObject::identifier)).from(self.tableName.UTF8String).order(WCDB::OrderingTerm::ascendingRowid()));\n         }];\n}\n\n@end\n"
  },
  {
    "path": "src/cpp/tests/operation/ORMUpdateTests.mm",
    "content": "//\n// Created by qiuwenchen on 2022/9/8.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"CPPTestCase.h\"\n\n@interface ORMUpdateTests : CPPCRUDTestCase\n\n@property (nonatomic, assign) std::string renewedContent;\n\n@property (nonatomic, assign) CPPTestCaseObject renewObject;\n@property (nonatomic, assign) WCDB::OneRowValue renewRow;\n@property (nonatomic, assign) WCDB::OneColumnValue renewValue;\n\n@property (nonatomic, assign) CPPTestCaseObject renewedObject1;\n@property (nonatomic, assign) CPPTestCaseObject renewedObject2;\n\n@end\n\n@implementation ORMUpdateTests\n\n- (void)setUp\n{\n    [super setUp];\n    [self insertPresetObjects];\n    _renewedContent = Random.shared.string.UTF8String;\n    _renewObject = CPPTestCaseObject(0, _renewedContent);\n    _renewRow = { _renewedContent };\n    _renewValue = _renewedContent;\n    _renewedObject1 = CPPTestCaseObject(1, _renewedContent);\n    _renewedObject2 = CPPTestCaseObject(2, _renewedContent);\n}\n\n#pragma mark - Database - Update Properties To Object\n- (void)test_database_update_table_set_properties_to_object\n{\n    [self doTestObjects:{ self.renewedObject1, self.renewedObject2 }\n                 andSQL:@\"UPDATE testTable SET content = ?1\"\n      afterModification:^BOOL {\n          return self.database->updateObject<CPPTestCaseObject>(self.renewObject, WCDB_FIELD(CPPTestCaseObject::content), self.tableName.UTF8String);\n      }];\n}\n\n- (void)test_database_update_table_set_properties_to_object_where\n{\n    [self doTestObjects:{ self.renewedObject1, self.object2 }\n                 andSQL:@\"UPDATE testTable SET content = ?1 WHERE identifier == 1\"\n      afterModification:^BOOL {\n          return self.database->updateObject<CPPTestCaseObject>(self.renewObject, WCDB_FIELD(CPPTestCaseObject::content), self.tableName.UTF8String, WCDB_FIELD(CPPTestCaseObject::identifier) == 1);\n      }];\n}\n\n- (void)test_database_update_table_set_properties_to_object_where_orders_limit\n{\n    [self doTestObjects:{ self.object1, self.renewedObject2 }\n                 andSQL:@\"UPDATE testTable SET content = ?1 WHERE identifier > 0 ORDER BY identifier DESC LIMIT 1\"\n      afterModification:^BOOL {\n          return self.database->updateObject<CPPTestCaseObject>(self.renewObject, WCDB_FIELD(CPPTestCaseObject::content), self.tableName.UTF8String, WCDB_FIELD(CPPTestCaseObject::identifier) > 0, WCDB_FIELD(CPPTestCaseObject::identifier).asOrder(WCDB::Order::DESC), 1);\n      }];\n}\n\n- (void)test_database_update_table_set_properties_to_object_where_orders_limit_offset\n{\n    [self doTestObjects:{ self.renewedObject1, self.object2 }\n                 andSQL:@\"UPDATE testTable SET content = ?1 WHERE identifier > 0 ORDER BY identifier DESC LIMIT 1 OFFSET 1\"\n      afterModification:^BOOL {\n          return self.database->updateObject<CPPTestCaseObject>(self.renewObject, WCDB_FIELD(CPPTestCaseObject::content), self.tableName.UTF8String, WCDB_FIELD(CPPTestCaseObject::identifier) > 0, WCDB_FIELD(CPPTestCaseObject::identifier).asOrder(WCDB::Order::DESC), 1, 1);\n      }];\n}\n\n#pragma mark - Database - Update Properties To Row\n- (void)test_database_update_table_set_properties_to_row\n{\n    [self doTestObjects:{ self.renewedObject1, self.renewedObject2 }\n                 andSQL:@\"UPDATE testTable SET content = ?1\"\n      afterModification:^BOOL {\n          return self.database->updateRow(self.renewRow, WCDB_FIELD(CPPTestCaseObject::content), self.tableName.UTF8String);\n      }];\n}\n\n- (void)test_database_update_table_set_properties_to_row_where\n{\n    [self doTestObjects:{ self.renewedObject1, self.object2 }\n                 andSQL:@\"UPDATE testTable SET content = ?1 WHERE identifier == 1\"\n      afterModification:^BOOL {\n          return self.database->updateRow(self.renewRow, WCDB_FIELD(CPPTestCaseObject::content), self.tableName.UTF8String, WCDB_FIELD(CPPTestCaseObject::identifier) == 1);\n      }];\n}\n\n- (void)test_database_update_table_set_properties_to_row_where_orders_limit_offset\n{\n    [self doTestObjects:{ self.renewedObject1, self.object2 }\n                 andSQL:@\"UPDATE testTable SET content = ?1 WHERE identifier > 0 ORDER BY identifier DESC LIMIT 1 OFFSET 1\"\n      afterModification:^BOOL {\n          return self.database->updateRow(self.renewRow, WCDB_FIELD(CPPTestCaseObject::content), self.tableName.UTF8String, WCDB_FIELD(CPPTestCaseObject::identifier) > 0, WCDB_FIELD(CPPTestCaseObject::identifier).asOrder(WCDB::Order::DESC), 1, 1);\n      }];\n}\n\n#pragma mark - Database - Update Property To Value\n- (void)test_database_update_table_set_property_to_value\n{\n    [self doTestObjects:{ self.renewedObject1, self.renewedObject2 }\n                 andSQL:@\"UPDATE testTable SET content = ?1\"\n      afterModification:^BOOL {\n          return self.database->updateRow(self.renewValue, WCDB_FIELD(CPPTestCaseObject::content), self.tableName.UTF8String);\n      }];\n}\n\n- (void)test_database_update_table_set_property_to_value_where\n{\n    [self doTestObjects:{ self.renewedObject1, self.object2 }\n                 andSQL:@\"UPDATE testTable SET content = ?1 WHERE identifier == 1\"\n      afterModification:^BOOL {\n          return self.database->updateRow(self.renewValue, WCDB_FIELD(CPPTestCaseObject::content), self.tableName.UTF8String, WCDB_FIELD(CPPTestCaseObject::identifier) == 1);\n      }];\n}\n\n- (void)test_database_update_table_set_property_to_value_where_orders_limit\n{\n    [self doTestObjects:{ self.object1, self.renewedObject2 }\n                 andSQL:@\"UPDATE testTable SET content = ?1 WHERE identifier > 0 ORDER BY identifier DESC LIMIT 1\"\n      afterModification:^BOOL {\n          return self.database->updateRow(self.renewValue, WCDB_FIELD(CPPTestCaseObject::content), self.tableName.UTF8String, WCDB_FIELD(CPPTestCaseObject::identifier) > 0, WCDB_FIELD(CPPTestCaseObject::identifier).asOrder(WCDB::Order::DESC), 1);\n      }];\n}\n\n- (void)test_database_update_table_set_property_to_value_where_orders_limit_offset\n{\n    [self doTestObjects:{ self.renewedObject1, self.object2 }\n                 andSQL:@\"UPDATE testTable SET content = ?1 WHERE identifier > 0 ORDER BY identifier DESC LIMIT 1 OFFSET 1\"\n      afterModification:^BOOL {\n          return self.database->updateRow(self.renewValue, WCDB_FIELD(CPPTestCaseObject::content), self.tableName.UTF8String, WCDB_FIELD(CPPTestCaseObject::identifier) > 0, WCDB_FIELD(CPPTestCaseObject::identifier).asOrder(WCDB::Order::DESC), 1, 1);\n      }];\n}\n\n#pragma mark - Table - Update Properties To Object\n- (void)test_table_update_table_set_properties_to_object\n{\n    [self doTestObjects:{ self.renewedObject1, self.renewedObject2 }\n                 andSQL:@\"UPDATE testTable SET content = ?1\"\n      afterModification:^BOOL {\n          return self.table.updateObject(self.renewObject, WCDB_FIELD(CPPTestCaseObject::content));\n      }];\n}\n\n- (void)test_table_update_table_set_properties_to_object_where\n{\n    [self doTestObjects:{ self.renewedObject1, self.object2 }\n                 andSQL:@\"UPDATE testTable SET content = ?1 WHERE identifier == 1\"\n      afterModification:^BOOL {\n          return self.table.updateObject(self.renewObject, WCDB_FIELD(CPPTestCaseObject::content), WCDB_FIELD(CPPTestCaseObject::identifier) == 1);\n      }];\n}\n\n- (void)test_table_update_table_set_properties_to_object_where_orders_limit\n{\n    [self doTestObjects:{ self.object1, self.renewedObject2 }\n                 andSQL:@\"UPDATE testTable SET content = ?1 WHERE identifier > 0 ORDER BY identifier DESC LIMIT 1\"\n      afterModification:^BOOL {\n          return self.table.updateObject(self.renewObject, WCDB_FIELD(CPPTestCaseObject::content), WCDB_FIELD(CPPTestCaseObject::identifier) > 0, WCDB_FIELD(CPPTestCaseObject::identifier).asOrder(WCDB::Order::DESC), 1);\n      }];\n}\n\n- (void)test_table_update_table_set_properties_to_object_where_orders_limit_offset\n{\n    [self doTestObjects:{ self.renewedObject1, self.object2 }\n                 andSQL:@\"UPDATE testTable SET content = ?1 WHERE identifier > 0 ORDER BY identifier DESC LIMIT 1 OFFSET 1\"\n      afterModification:^BOOL {\n          return self.table.updateObject(self.renewObject, WCDB_FIELD(CPPTestCaseObject::content), WCDB_FIELD(CPPTestCaseObject::identifier) > 0, WCDB_FIELD(CPPTestCaseObject::identifier).asOrder(WCDB::Order::DESC), 1, 1);\n      }];\n}\n\n#pragma mark - Table - Update Properties To Row\n- (void)test_table_update_table_set_properties_to_row\n{\n    [self doTestObjects:{ self.renewedObject1, self.renewedObject2 }\n                 andSQL:@\"UPDATE testTable SET content = ?1\"\n      afterModification:^BOOL {\n          return self.table.updateRow(self.renewRow, WCDB_FIELD(CPPTestCaseObject::content));\n      }];\n}\n\n- (void)test_table_update_table_set_properties_to_row_where\n{\n    [self doTestObjects:{ self.renewedObject1, self.object2 }\n                 andSQL:@\"UPDATE testTable SET content = ?1 WHERE identifier == 1\"\n      afterModification:^BOOL {\n          return self.table.updateRow(self.renewRow, WCDB_FIELD(CPPTestCaseObject::content), WCDB_FIELD(CPPTestCaseObject::identifier) == 1);\n      }];\n}\n\n- (void)test_table_update_table_set_properties_to_row_where_orders_limit_offset\n{\n    [self doTestObjects:{ self.renewedObject1, self.object2 }\n                 andSQL:@\"UPDATE testTable SET content = ?1 WHERE identifier > 0 ORDER BY identifier DESC LIMIT 1 OFFSET 1\"\n      afterModification:^BOOL {\n          return self.table.updateRow(self.renewRow, WCDB_FIELD(CPPTestCaseObject::content), WCDB_FIELD(CPPTestCaseObject::identifier) > 0, WCDB_FIELD(CPPTestCaseObject::identifier).asOrder(WCDB::Order::DESC), 1, 1);\n      }];\n}\n\n#pragma mark - Table - Update Property To Value\n- (void)test_table_update_table_set_property_to_value\n{\n    [self doTestObjects:{ self.renewedObject1, self.renewedObject2 }\n                 andSQL:@\"UPDATE testTable SET content = ?1\"\n      afterModification:^BOOL {\n          return self.table.updateRow(self.renewValue, WCDB_FIELD(CPPTestCaseObject::content));\n      }];\n}\n\n- (void)test_table_update_table_set_property_to_value_where\n{\n    [self doTestObjects:{ self.renewedObject1, self.object2 }\n                 andSQL:@\"UPDATE testTable SET content = ?1 WHERE identifier == 1\"\n      afterModification:^BOOL {\n          return self.table.updateRow(self.renewValue, WCDB_FIELD(CPPTestCaseObject::content), WCDB_FIELD(CPPTestCaseObject::identifier) == 1);\n      }];\n}\n\n- (void)test_table_update_table_set_property_to_value_where_orders_limit\n{\n    [self doTestObjects:{ self.object1, self.renewedObject2 }\n                 andSQL:@\"UPDATE testTable SET content = ?1 WHERE identifier > 0 ORDER BY identifier DESC LIMIT 1\"\n      afterModification:^BOOL {\n          return self.table.updateRow(self.renewValue, WCDB_FIELD(CPPTestCaseObject::content), WCDB_FIELD(CPPTestCaseObject::identifier) > 0, WCDB_FIELD(CPPTestCaseObject::identifier).asOrder(WCDB::Order::DESC), 1);\n      }];\n}\n\n- (void)test_table_update_table_set_property_to_value_where_orders_limit_offset\n{\n    [self doTestObjects:{ self.renewedObject1, self.object2 }\n                 andSQL:@\"UPDATE testTable SET content = ?1 WHERE identifier > 0 ORDER BY identifier DESC LIMIT 1 OFFSET 1\"\n      afterModification:^BOOL {\n          return self.table.updateRow(self.renewValue, WCDB_FIELD(CPPTestCaseObject::content), WCDB_FIELD(CPPTestCaseObject::identifier) > 0, WCDB_FIELD(CPPTestCaseObject::identifier).asOrder(WCDB::Order::DESC), 1, 1);\n      }];\n}\n\n#pragma mark - Handle - Update Properties To Object\n- (void)test_handle_update_table_set_properties_to_object\n{\n    [self doTestObjects:{ self.renewedObject1, self.renewedObject2 }\n                 andSQL:@\"UPDATE testTable SET content = ?1\"\n      afterModification:^BOOL {\n          return self.database->getHandle().updateObject<CPPTestCaseObject>(self.renewObject, WCDB_FIELD(CPPTestCaseObject::content), self.tableName.UTF8String);\n      }];\n}\n\n- (void)test_handle_update_table_set_properties_to_object_where\n{\n    [self doTestObjects:{ self.renewedObject1, self.object2 }\n                 andSQL:@\"UPDATE testTable SET content = ?1 WHERE identifier == 1\"\n      afterModification:^BOOL {\n          return self.database->getHandle().updateObject<CPPTestCaseObject>(self.renewObject, WCDB_FIELD(CPPTestCaseObject::content), self.tableName.UTF8String, WCDB_FIELD(CPPTestCaseObject::identifier) == 1);\n      }];\n}\n\n- (void)test_handle_update_table_set_properties_to_object_where_orders_limit\n{\n    [self doTestObjects:{ self.object1, self.renewedObject2 }\n                 andSQL:@\"UPDATE testTable SET content = ?1 WHERE identifier > 0 ORDER BY identifier DESC LIMIT 1\"\n      afterModification:^BOOL {\n          return self.database->getHandle().updateObject<CPPTestCaseObject>(self.renewObject, WCDB_FIELD(CPPTestCaseObject::content), self.tableName.UTF8String, WCDB_FIELD(CPPTestCaseObject::identifier) > 0, WCDB_FIELD(CPPTestCaseObject::identifier).asOrder(WCDB::Order::DESC), 1);\n      }];\n}\n\n- (void)test_handle_update_table_set_properties_to_object_where_orders_limit_offset\n{\n    [self doTestObjects:{ self.renewedObject1, self.object2 }\n                 andSQL:@\"UPDATE testTable SET content = ?1 WHERE identifier > 0 ORDER BY identifier DESC LIMIT 1 OFFSET 1\"\n      afterModification:^BOOL {\n          return self.database->getHandle().updateObject<CPPTestCaseObject>(self.renewObject, WCDB_FIELD(CPPTestCaseObject::content), self.tableName.UTF8String, WCDB_FIELD(CPPTestCaseObject::identifier) > 0, WCDB_FIELD(CPPTestCaseObject::identifier).asOrder(WCDB::Order::DESC), 1, 1);\n      }];\n}\n\n#pragma mark - Handle - Update Properties To Row\n- (void)test_handle_update_table_set_properties_to_row\n{\n    [self doTestObjects:{ self.renewedObject1, self.renewedObject2 }\n                 andSQL:@\"UPDATE testTable SET content = ?1\"\n      afterModification:^BOOL {\n          return self.database->getHandle().updateRow(self.renewRow, WCDB_FIELD(CPPTestCaseObject::content), self.tableName.UTF8String);\n      }];\n}\n\n- (void)test_handle_update_table_set_properties_to_row_where\n{\n    [self doTestObjects:{ self.renewedObject1, self.object2 }\n                 andSQL:@\"UPDATE testTable SET content = ?1 WHERE identifier == 1\"\n      afterModification:^BOOL {\n          return self.database->getHandle().updateRow(self.renewRow, WCDB_FIELD(CPPTestCaseObject::content), self.tableName.UTF8String, WCDB_FIELD(CPPTestCaseObject::identifier) == 1);\n      }];\n}\n\n- (void)test_handle_update_table_set_properties_to_row_where_orders_limit_offset\n{\n    [self doTestObjects:{ self.renewedObject1, self.object2 }\n                 andSQL:@\"UPDATE testTable SET content = ?1 WHERE identifier > 0 ORDER BY identifier DESC LIMIT 1 OFFSET 1\"\n      afterModification:^BOOL {\n          return self.database->getHandle().updateRow(self.renewRow, WCDB_FIELD(CPPTestCaseObject::content), self.tableName.UTF8String, WCDB_FIELD(CPPTestCaseObject::identifier) > 0, WCDB_FIELD(CPPTestCaseObject::identifier).asOrder(WCDB::Order::DESC), 1, 1);\n      }];\n}\n\n#pragma mark - Handle - Update Property To Value\n- (void)test_handle_update_table_set_property_to_value\n{\n    [self doTestObjects:{ self.renewedObject1, self.renewedObject2 }\n                 andSQL:@\"UPDATE testTable SET content = ?1\"\n      afterModification:^BOOL {\n          return self.database->getHandle().updateRow(self.renewValue, WCDB_FIELD(CPPTestCaseObject::content), self.tableName.UTF8String);\n      }];\n}\n\n- (void)test_handle_update_table_set_property_to_value_where\n{\n    [self doTestObjects:{ self.renewedObject1, self.object2 }\n                 andSQL:@\"UPDATE testTable SET content = ?1 WHERE identifier == 1\"\n      afterModification:^BOOL {\n          return self.database->getHandle().updateRow(self.renewValue, WCDB_FIELD(CPPTestCaseObject::content), self.tableName.UTF8String, WCDB_FIELD(CPPTestCaseObject::identifier) == 1);\n      }];\n}\n\n- (void)test_handle_update_table_set_property_to_value_where_orders_limit\n{\n    [self doTestObjects:{ self.object1, self.renewedObject2 }\n                 andSQL:@\"UPDATE testTable SET content = ?1 WHERE identifier > 0 ORDER BY identifier DESC LIMIT 1\"\n      afterModification:^BOOL {\n          return self.database->getHandle().updateRow(self.renewValue, WCDB_FIELD(CPPTestCaseObject::content), self.tableName.UTF8String, WCDB_FIELD(CPPTestCaseObject::identifier) > 0, WCDB_FIELD(CPPTestCaseObject::identifier).asOrder(WCDB::Order::DESC), 1);\n      }];\n}\n\n- (void)test_handle_update_table_set_property_to_value_where_orders_limit_offset\n{\n    [self doTestObjects:{ self.renewedObject1, self.object2 }\n                 andSQL:@\"UPDATE testTable SET content = ?1 WHERE identifier > 0 ORDER BY identifier DESC LIMIT 1 OFFSET 1\"\n      afterModification:^BOOL {\n          return self.database->getHandle().updateRow(self.renewValue, WCDB_FIELD(CPPTestCaseObject::content), self.tableName.UTF8String, WCDB_FIELD(CPPTestCaseObject::identifier) > 0, WCDB_FIELD(CPPTestCaseObject::identifier).asOrder(WCDB::Order::DESC), 1, 1);\n      }];\n}\n\n@end\n"
  },
  {
    "path": "src/cpp/tests/operation/StatementOperationTests.mm",
    "content": "//\n// Created by qiuwenchen on 2022/8/14.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"CPPTestCase.h\"\n\n@interface StatementOperationTests : CPPCRUDTestCase\n\n@property (nonatomic, assign) std::shared_ptr<WCDB::Handle> handle;\n@property (nonatomic, assign) WCDB::StatementInsert statementInsert;\n@property (nonatomic, assign) WCDB::StatementSelect statementSelect;\n\n@end\n\n@implementation StatementOperationTests\n\n- (void)setUp\n{\n    [super setUp];\n\n    _statementInsert = WCDB::StatementInsert()\n                       .insertIntoTable(self.tableName.UTF8String)\n                       .columns(self.columns)\n                       .values({ 3, WCDB::BindParameter(1) });\n\n    _statementSelect = WCDB::StatementSelect()\n                       .select(WCDB::Column(\"content\"))\n                       .from(self.tableName.UTF8String)\n                       .where(WCDB::Column(\"identifier\") == 3);\n\n    self.handle = std::make_shared<WCDB::Handle>(self.database->getHandle());\n    [self insertPresetRows];\n}\n\n- (void)tearDown\n{\n    if (_handle->isPrepared()) {\n        _handle->finalize();\n    }\n    _handle = nil;\n    [super tearDown];\n}\n\n#pragma mark - Execute\n- (void)test_execute\n{\n    [self doTestSQLs:@[ @\"PRAGMA user_version = 123\" ]\n         inOperation:^BOOL {\n             return self.handle->execute(WCDB::StatementPragma().pragma(WCDB::Pragma::userVersion()).to(123));\n         }];\n}\n\n#pragma mark - Prepare\n- (void)test_prepare\n{\n    WCDB::StatementPragma statement = WCDB::StatementPragma().pragma(WCDB::Pragma::userVersion()).to(123);\n    TestCaseAssertFalse(self.handle->isPrepared());\n    TestCaseAssertTrue(self.handle->prepare(statement));\n    TestCaseAssertTrue(self.handle->isPrepared());\n    self.handle->finalize();\n    TestCaseAssertFalse(self.handle->isPrepared());\n}\n\n#pragma mark - Step\n- (void)test_step\n{\n    [self doTestSQLs:@[ @\"INSERT INTO testTable(identifier, content) VALUES(?1, ?2)\", @\"INSERT INTO testTable(identifier, content) VALUES(?1, ?2)\" ]\n         inOperation:^BOOL {\n             WCDB::StatementInsert statement = WCDB::StatementInsert().insertIntoTable(self.tableName.UTF8String).column(WCDB::Column(\"identifier\")).column(WCDB::Column(\"content\")).values(WCDB::BindParameter::bindParameters(2));\n             if (!self.handle->prepare(statement)) {\n                 return NO;\n             }\n\n             self.handle->bindValue(3, 1);\n             self.handle->bindValue(Random.shared.string.UTF8String, 2);\n             if (!self.handle->step()) {\n                 return NO;\n             }\n\n             self.handle->reset();\n             self.handle->bindRow({ 4, Random.shared.string.UTF8String });\n             BOOL succeed = self.handle->step() && self.handle->done();\n             self.handle->finalize();\n             return succeed;\n         }];\n}\n\n#pragma mark - State\n- (void)test_readonly\n{\n    {\n        WCDB::StatementPragma statement = WCDB::StatementPragma().pragma(WCDB::Pragma::userVersion());\n        TestCaseAssertTrue(self.handle->prepare(statement));\n        TestCaseAssertTrue(self.handle->isReadOnly());\n        self.handle->finalize();\n    }\n    {\n        WCDB::StatementPragma statement = WCDB::StatementPragma().pragma(WCDB::Pragma::userVersion()).to(123);\n        TestCaseAssertTrue(self.handle->prepare(statement));\n        TestCaseAssertFalse(self.handle->isReadOnly());\n        self.handle->finalize();\n    }\n}\n\n- (void)test_changes\n{\n    TestCaseAssertTrue(self.handle->execute(WCDB::StatementDelete().deleteFrom(self.tableName.UTF8String)));\n    TestCaseAssertEqual(self.handle->getChanges(), self.rows.size());\n}\n\n- (void)test_get_last_inserted\n{\n    WCDB::StatementInsert statement = WCDB::StatementInsert().insertIntoTable(self.tableName.UTF8String).column(\"identifier\").column(\"content\").value(nullptr).value(Random.shared.string.UTF8String);\n    TestCaseAssertTrue(self.handle->execute(statement));\n    TestCaseAssertEqual(self.handle->getLastInsertedRowID(), 3);\n}\n\n#pragma mark - Bind && Get\n- (void)test_integer\n{\n    int64_t value = Random.shared.int64;\n    {\n        TestCaseAssertTrue(self.handle->prepare(self.statementInsert));\n        self.handle->bindInteger(value);\n\n        TestCaseAssertTrue(self.handle->step());\n        self.handle->finalize();\n    }\n    {\n        TestCaseAssertTrue(self.handle->prepare(self.statementSelect));\n        TestCaseAssertTrue(self.handle->step());\n        TestCaseAssertEqual(self.handle->getInteger(), value);\n        self.handle->finalize();\n    }\n}\n\n- (void)test_integer_value\n{\n    int64_t value = Random.shared.int64;\n    {\n        TestCaseAssertTrue(self.handle->prepare(self.statementInsert));\n        self.handle->bindValue(value);\n\n        TestCaseAssertTrue(self.handle->step());\n        self.handle->finalize();\n    }\n    {\n        TestCaseAssertTrue(self.handle->prepare(self.statementSelect));\n        TestCaseAssertTrue(self.handle->step());\n        TestCaseAssertEqual(self.handle->getValue().intValue(), value);\n        self.handle->finalize();\n    }\n}\n\n- (void)test_double\n{\n    double value = 1.2;\n    {\n        TestCaseAssertTrue(self.handle->prepare(self.statementInsert));\n        self.handle->bindDouble(value);\n\n        TestCaseAssertTrue(self.handle->step());\n        self.handle->finalize();\n    }\n    {\n        TestCaseAssertTrue(self.handle->prepare(self.statementSelect));\n        TestCaseAssertTrue(self.handle->step());\n        TestCaseAssertEqual(self.handle->getDouble(), value);\n        self.handle->finalize();\n    }\n}\n\n- (void)test_double_value\n{\n    double value = 1.2;\n    {\n        TestCaseAssertTrue(self.handle->prepare(self.statementInsert));\n        self.handle->bindValue(value);\n\n        TestCaseAssertTrue(self.handle->step());\n        self.handle->finalize();\n    }\n    {\n        TestCaseAssertTrue(self.handle->prepare(self.statementSelect));\n        TestCaseAssertTrue(self.handle->step());\n        TestCaseAssertEqual(self.handle->getValue().floatValue(), value);\n        self.handle->finalize();\n    }\n}\n\n- (void)test_null\n{\n    {\n        TestCaseAssertTrue(self.handle->prepare(self.statementInsert));\n        self.handle->bindNull();\n\n        TestCaseAssertTrue(self.handle->step());\n        self.handle->finalize();\n    }\n    {\n        TestCaseAssertTrue(self.handle->prepare(self.statementSelect));\n        TestCaseAssertTrue(self.handle->step());\n        TestCaseAssertEqual(self.handle->getType(), WCDB::ColumnType::Null);\n        self.handle->finalize();\n    }\n}\n\n- (void)test_null_value\n{\n    {\n        TestCaseAssertTrue(self.handle->prepare(self.statementInsert));\n        self.handle->bindValue(nullptr);\n\n        TestCaseAssertTrue(self.handle->step());\n        self.handle->finalize();\n    }\n    {\n        TestCaseAssertTrue(self.handle->prepare(self.statementSelect));\n        TestCaseAssertTrue(self.handle->step());\n        TestCaseAssertEqual(self.handle->getValue(), nullptr);\n        self.handle->finalize();\n    }\n}\n\n- (void)test_string\n{\n    NSString* value = Random.shared.string;\n    TestCaseAssertTrue(value != nil);\n    {\n        TestCaseAssertTrue(self.handle->prepare(self.statementInsert));\n        self.handle->bindText(value.UTF8String);\n\n        TestCaseAssertTrue(self.handle->step());\n        self.handle->finalize();\n    }\n    {\n        TestCaseAssertTrue(self.handle->prepare(self.statementSelect));\n        TestCaseAssertTrue(self.handle->step());\n        TestCaseAssertCPPStringEqual(self.handle->getText().data(), value.UTF8String);\n        self.handle->finalize();\n    }\n}\n\n- (void)test_string_value\n{\n    NSString* value = Random.shared.string;\n    TestCaseAssertTrue(value != nil);\n    {\n        TestCaseAssertTrue(self.handle->prepare(self.statementInsert));\n        self.handle->bindValue(value.UTF8String);\n\n        TestCaseAssertTrue(self.handle->step());\n        self.handle->finalize();\n    }\n    {\n        TestCaseAssertTrue(self.handle->prepare(self.statementSelect));\n        TestCaseAssertTrue(self.handle->step());\n        TestCaseAssertCPPStringEqual(self.handle->getValue().textValue().data(), value.UTF8String);\n        self.handle->finalize();\n    }\n}\n\n- (void)test_data\n{\n    NSData* value = Random.shared.data;\n    TestCaseAssertTrue(value != nil);\n    {\n        TestCaseAssertTrue(self.handle->prepare(self.statementInsert));\n        self.handle->bindBLOB(WCDB::UnsafeData((unsigned char*) value.bytes, value.length));\n\n        TestCaseAssertTrue(self.handle->step());\n        self.handle->finalize();\n    }\n    {\n        TestCaseAssertTrue(self.handle->prepare(self.statementSelect));\n        TestCaseAssertTrue(self.handle->step());\n        WCDB::UnsafeData result = self.handle->getBLOB();\n        TestCaseAssertTrue(result.size() == value.length && memcmp(result.buffer(), value.bytes, result.size()) == 0);\n        self.handle->finalize();\n    }\n}\n\n- (void)test_data_value\n{\n    NSData* value = Random.shared.data;\n    TestCaseAssertTrue(value != nil);\n    {\n        TestCaseAssertTrue(self.handle->prepare(self.statementInsert));\n        self.handle->bindValue(WCDB::UnsafeData((unsigned char*) value.bytes, value.length));\n\n        TestCaseAssertTrue(self.handle->step());\n        self.handle->finalize();\n    }\n    {\n        TestCaseAssertTrue(self.handle->prepare(self.statementSelect));\n        TestCaseAssertTrue(self.handle->step());\n        WCDB::Data result = self.handle->getValue();\n        TestCaseAssertTrue(result.size() == value.length && memcmp(result.buffer(), value.bytes, result.size()) == 0);\n        self.handle->finalize();\n    }\n}\n\n- (void)test_bind_index\n{\n    NSString* value = Random.shared.string;\n    TestCaseAssertTrue(value != nil);\n    {\n        WCDB::BindParameter parameter = WCDB::BindParameter::colon(\"data\");\n        WCDB::Statement insert = WCDB::StatementInsert()\n                                 .insertIntoTable(self.tableName.UTF8String)\n                                 .columns({ \"identifier\", \"content\" })\n                                 .values({ 3, parameter });\n        TestCaseAssertTrue(self.handle->prepare(insert));\n        self.handle->bindText(value.UTF8String, self.handle->bindParameterIndex(parameter.getDescription()));\n\n        TestCaseAssertTrue(self.handle->step());\n        self.handle->finalize();\n    }\n    {\n        TestCaseAssertTrue(self.handle->prepare(self.statementSelect));\n        TestCaseAssertTrue(self.handle->step());\n        TestCaseAssertCPPStringEqual(self.handle->getText().data(), value.UTF8String);\n        self.handle->finalize();\n    }\n}\n\n@end\n"
  },
  {
    "path": "src/cpp/tests/orm/CPPORMTests.mm",
    "content": "//\n// Created by qiuwenchen on 2022/9/5.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"CPPAllTypesObject.h\"\n#import \"CPPColumnConstraintAutoIncrement.hpp\"\n#import \"CPPColumnConstraintAutoIncrementAsc.hpp\"\n#import \"CPPColumnConstraintDefault.hpp\"\n#import \"CPPColumnConstraintEnablePrimaryAutoIncrement.hpp\"\n#import \"CPPColumnConstraintPrimary.hpp\"\n#import \"CPPColumnConstraintPrimaryAsc.hpp\"\n#import \"CPPColumnConstraintPrimaryDesc.hpp\"\n#import \"CPPColumnConstraintUnique.hpp\"\n#import \"CPPDropIndexObject.hpp\"\n#import \"CPPFieldObject.h\"\n#import \"CPPIndexObject.hpp\"\n#import \"CPPInheritObject.hpp\"\n#import \"CPPNewFieldObject.h\"\n#import \"CPPNewRemapObject.hpp\"\n#import \"CPPNewlyCreatedTableIndexObject.hpp\"\n#import \"CPPOldRemapObject.hpp\"\n#import \"CPPSTDOptionalAllTypesObject.h\"\n#import \"CPPSharedPtrAllTypesObject.h\"\n#import \"CPPTableConstraintObject.hpp\"\n#import \"CPPTestCase.h\"\n#import \"CPPVirtualTableFTS4Object.hpp\"\n#import \"CPPVirtualTableFTS5Object.hpp\"\n#import \"CPPWCDBOptionalAllTypesObject.h\"\n#import <Foundation/Foundation.h>\n\n@interface CPPORMTests : CPPCRUDTestCase\n\n@end\n\n@implementation CPPORMTests\n\n- (void)setUp\n{\n    [super setUp];\n    self.expectMode = DatabaseTestCaseExpectSomeSQLs;\n}\n\n- (void)doTestCreateTableAndIndexSQLsAsExpected:(NSArray<NSString*>*)expected inOperation:(BOOL (^)())block\n{\n    TestCaseAssertTrue(expected != nil);\n    NSMutableArray* sqls = [NSMutableArray array];\n    [sqls addObject:@\"BEGIN IMMEDIATE\"];\n    [sqls addObjectsFromArray:expected];\n    [sqls addObject:@\"COMMIT\"];\n    [self doTestSQLs:sqls inOperation:block];\n}\n\n#pragma mark - field\n- (void)test_field\n{\n    NSArray<NSString*>* expected = @[ @\"CREATE TABLE IF NOT EXISTS testTable(field INTEGER, differentName INTEGER)\" ];\n    [self doTestCreateTableAndIndexSQLsAsExpected:expected\n                                      inOperation:^BOOL {\n                                          return CPPTestTableCreate<CPPFieldObject>(self);\n                                      }];\n}\n\n#pragma mark - table constraint\n- (void)test_table_constraint\n{\n    NSArray<NSString*>* expected = @[ @\"CREATE TABLE IF NOT EXISTS testTable(multiPrimary INTEGER, multiPrimaryAsc INTEGER, multiPrimaryDesc INTEGER, multiUnique INTEGER, multiUniqueAsc INTEGER, multiUniqueDesc INTEGER, CONSTRAINT multi_primary PRIMARY KEY(multiPrimary, multiPrimaryAsc ASC, multiPrimaryDesc DESC), CONSTRAINT multi_unique UNIQUE(multiUnique, multiUniqueAsc ASC, multiUniqueDesc DESC))\" ];\n    [self doTestCreateTableAndIndexSQLsAsExpected:expected\n                                      inOperation:^BOOL {\n                                          return CPPTestTableCreate<CPPTableConstraintObject>(self);\n                                      }];\n}\n\n- (void)test_all_types\n{\n    NSArray<NSString*>* expected = @[ @\"CREATE TABLE IF NOT EXISTS testTable(type TEXT, enumValue INTEGER, enumClassValue INTEGER, literalEnumValue INTEGER, trueOrFalseValue INTEGER, charValue INTEGER, unsignedCharValue INTEGER, shortValue INTEGER, unsignedShortValue INTEGER, intValue INTEGER, unsignedIntValue INTEGER, int32Value INTEGER, int64Value INTEGER, uint32Value INTEGER, uint64Value INTEGER, floatValue REAL, doubleValue REAL, constCharpValue TEXT, charpValue TEXT, constCharArrValue TEXT, charArrValue TEXT, stdStringValue TEXT, unsafeStringViewValue TEXT, stringViewValue TEXT, blobValue BLOB, unsafeDataValue BLOB, dataValue BLOB, constUnsignedCharArrValue BLOB, unsignedCharArrValue BLOB)\" ];\n    [self doTestCreateTableAndIndexSQLsAsExpected:expected\n                                      inOperation:^BOOL {\n                                          return CPPTestTableCreate<CPPAllTypesObject>(self);\n                                      }];\n\n    WCDB::Table<CPPAllTypesObject> table = self.database->getTable<CPPAllTypesObject>(self.tableName.UTF8String);\n\n    CPPAllTypesObject maxObject = CPPAllTypesObject::maxObject();\n    TestCaseAssertTrue(table.insertObjects(maxObject));\n\n    CPPAllTypesObject minObject = CPPAllTypesObject::minObject();\n    TestCaseAssertTrue(table.insertObjects(minObject));\n\n    CPPAllTypesObject emptyObject = CPPAllTypesObject::emptyObject();\n    TestCaseAssertTrue(table.insertObjects(emptyObject));\n\n    CPPAllTypesObject randomObject = CPPAllTypesObject::randomObject();\n    TestCaseAssertTrue(table.insertObjects(randomObject));\n\n    XCTAssertTrue(table.insertRows({ \"null\" }, WCDB_FIELD(CPPAllTypesObject::type)));\n\n    CPPAllTypesObject selectedMaxObject = table.getFirstObject(WCDB_FIELD(CPPAllTypesObject::type) == maxObject.type).value();\n    TestCaseAssertTrue(selectedMaxObject == maxObject);\n\n    CPPAllTypesObject selectedMinObject = table.getFirstObject(WCDB_FIELD(CPPAllTypesObject::type) == minObject.type).value();\n    TestCaseAssertTrue(selectedMinObject == minObject);\n\n    CPPAllTypesObject selectedEmptyObject = table.getFirstObject(WCDB_FIELD(CPPAllTypesObject::type) == emptyObject.type).value();\n    TestCaseAssertTrue(selectedEmptyObject == emptyObject);\n\n    CPPAllTypesObject selectedRandomObject = table.getFirstObject(WCDB_FIELD(CPPAllTypesObject::type) == randomObject.type).value();\n    TestCaseAssertTrue(selectedRandomObject == randomObject);\n\n    TestCaseAssertTrue(table.getValueFromStatement(WCDB::StatementSelect().select(WCDB_FIELD(CPPAllTypesObject::constCharArrValue)).from(self.tableName.UTF8String)).value() == maxObject.constCharArrValue);\n\n    TestCaseAssertTrue(table.getValueFromStatement(WCDB::StatementSelect().select(WCDB_FIELD(CPPAllTypesObject::constUnsignedCharArrValue)).from(self.tableName.UTF8String)).value() == maxObject.constUnsignedCharArrValue);\n\n    CPPAllTypesObject selectedNullObject = table.getFirstObject(WCDB_FIELD(CPPAllTypesObject::type) == \"null\").value();\n    TestCaseAssertTrue(selectedNullObject == emptyObject);\n}\n\n- (void)test_all_shared_ptr_types\n{\n    NSArray<NSString*>* expected = @[ @\"CREATE TABLE IF NOT EXISTS testTable(type TEXT, enumValue INTEGER, enumClassValue INTEGER, literalEnumValue INTEGER, trueOrFalseValue INTEGER, charValue INTEGER, unsignedCharValue INTEGER, shortValue INTEGER, unsignedShortValue INTEGER, intValue INTEGER, unsignedIntValue INTEGER, int32Value INTEGER, int64Value INTEGER, uint32Value INTEGER, uint64Value INTEGER, floatValue REAL, doubleValue REAL, constCharpValue TEXT, charpValue TEXT, stdStringValue TEXT, unsafeStringViewValue TEXT, stringViewValue TEXT, blobValue BLOB, unsafeDataValue BLOB, dataValue BLOB)\" ];\n    [self doTestCreateTableAndIndexSQLsAsExpected:expected\n                                      inOperation:^BOOL {\n                                          return CPPTestTableCreate<CPPSharedPtrAllTypesObject>(self);\n                                      }];\n\n    WCDB::Table<CPPSharedPtrAllTypesObject> table = self.database->getTable<CPPSharedPtrAllTypesObject>(self.tableName.UTF8String);\n\n    CPPSharedPtrAllTypesObject maxObject = CPPSharedPtrAllTypesObject::maxObject();\n    TestCaseAssertTrue(table.insertObjects(maxObject));\n\n    CPPSharedPtrAllTypesObject minObject = CPPSharedPtrAllTypesObject::minObject();\n    TestCaseAssertTrue(table.insertObjects(minObject));\n\n    CPPSharedPtrAllTypesObject emptyObject = CPPSharedPtrAllTypesObject::emptyObject();\n    TestCaseAssertTrue(table.insertObjects(emptyObject));\n\n    CPPSharedPtrAllTypesObject randomObject = CPPSharedPtrAllTypesObject::randomObject();\n    TestCaseAssertTrue(table.insertObjects(randomObject));\n\n    XCTAssertTrue(table.insertRows({ \"null\" }, WCDB_FIELD(CPPSharedPtrAllTypesObject::type)));\n\n    CPPSharedPtrAllTypesObject selectedMaxObject = table.getFirstObject(WCDB_FIELD(CPPSharedPtrAllTypesObject::type) == maxObject.type).value();\n    TestCaseAssertTrue(selectedMaxObject == maxObject);\n\n    CPPSharedPtrAllTypesObject selectedMinObject = table.getFirstObject(WCDB_FIELD(CPPSharedPtrAllTypesObject::type) == minObject.type).value();\n    TestCaseAssertTrue(selectedMinObject == minObject);\n\n    CPPSharedPtrAllTypesObject selectedEmptyObject = table.getFirstObject(WCDB_FIELD(CPPSharedPtrAllTypesObject::type) == emptyObject.type).value();\n    TestCaseAssertTrue(selectedEmptyObject == emptyObject);\n\n    CPPSharedPtrAllTypesObject selectedRandomObject = table.getFirstObject(WCDB_FIELD(CPPSharedPtrAllTypesObject::type) == randomObject.type).value();\n    TestCaseAssertTrue(selectedRandomObject == randomObject);\n\n    CPPSharedPtrAllTypesObject selectedNullObject = table.getFirstObject(WCDB_FIELD(CPPSharedPtrAllTypesObject::type) == \"null\").value();\n    TestCaseAssertTrue(selectedNullObject == emptyObject);\n}\n\n#if defined(__cplusplus) && __cplusplus > 201402L\n\n- (void)test_all_std_optional_types\n{\n    NSArray<NSString*>* expected = @[ @\"CREATE TABLE IF NOT EXISTS testTable(type TEXT, enumValue INTEGER, enumClassValue INTEGER, literalEnumValue INTEGER, trueOrFalseValue INTEGER, charValue INTEGER, unsignedCharValue INTEGER, shortValue INTEGER, unsignedShortValue INTEGER, intValue INTEGER, unsignedIntValue INTEGER, int32Value INTEGER, int64Value INTEGER, uint32Value INTEGER, uint64Value INTEGER, floatValue REAL, doubleValue REAL, constCharpValue TEXT, charpValue TEXT, stdStringValue TEXT, unsafeStringViewValue TEXT, stringViewValue TEXT, blobValue BLOB, unsafeDataValue BLOB, dataValue BLOB)\" ];\n    [self doTestCreateTableAndIndexSQLsAsExpected:expected\n                                      inOperation:^BOOL {\n                                          return CPPTestTableCreate<CPPSTDOptionalAllTypesObject>(self);\n                                      }];\n\n    WCDB::Table<CPPSTDOptionalAllTypesObject> table = self.database->getTable<CPPSTDOptionalAllTypesObject>(self.tableName.UTF8String);\n\n    CPPSTDOptionalAllTypesObject maxObject = CPPSTDOptionalAllTypesObject::maxObject();\n    TestCaseAssertTrue(table.insertObjects(maxObject));\n\n    CPPSTDOptionalAllTypesObject minObject = CPPSTDOptionalAllTypesObject::minObject();\n    TestCaseAssertTrue(table.insertObjects(minObject));\n\n    CPPSTDOptionalAllTypesObject emptyObject = CPPSTDOptionalAllTypesObject::emptyObject();\n    TestCaseAssertTrue(table.insertObjects(emptyObject));\n\n    CPPSTDOptionalAllTypesObject randomObject = CPPSTDOptionalAllTypesObject::randomObject();\n    TestCaseAssertTrue(table.insertObjects(randomObject));\n\n    XCTAssertTrue(table.insertRows({ \"null\" }, WCDB_FIELD(CPPSTDOptionalAllTypesObject::type)));\n\n    CPPSTDOptionalAllTypesObject selectedMaxObject = table.getFirstObject(WCDB_FIELD(CPPSTDOptionalAllTypesObject::type) == maxObject.type).value();\n    TestCaseAssertTrue(selectedMaxObject == maxObject);\n\n    CPPSTDOptionalAllTypesObject selectedMinObject = table.getFirstObject(WCDB_FIELD(CPPSTDOptionalAllTypesObject::type) == minObject.type).value();\n    TestCaseAssertTrue(selectedMinObject == minObject);\n\n    CPPSTDOptionalAllTypesObject selectedEmptyObject = table.getFirstObject(WCDB_FIELD(CPPSTDOptionalAllTypesObject::type) == emptyObject.type).value();\n    TestCaseAssertTrue(selectedEmptyObject == emptyObject);\n\n    CPPSTDOptionalAllTypesObject selectedRandomObject = table.getFirstObject(WCDB_FIELD(CPPSTDOptionalAllTypesObject::type) == randomObject.type).value();\n    TestCaseAssertTrue(selectedRandomObject == randomObject);\n\n    CPPSTDOptionalAllTypesObject selectedNullObject = table.getFirstObject(WCDB_FIELD(CPPSTDOptionalAllTypesObject::type) == \"null\").value();\n    TestCaseAssertTrue(selectedNullObject == emptyObject);\n}\n\n#endif\n\n- (void)test_all_wcdb_optional_types\n{\n    NSArray<NSString*>* expected = @[ @\"CREATE TABLE IF NOT EXISTS testTable(type TEXT, enumValue INTEGER, enumClassValue INTEGER, literalEnumValue INTEGER, trueOrFalseValue INTEGER, charValue INTEGER, unsignedCharValue INTEGER, shortValue INTEGER, unsignedShortValue INTEGER, intValue INTEGER, unsignedIntValue INTEGER, int32Value INTEGER, int64Value INTEGER, uint32Value INTEGER, uint64Value INTEGER, floatValue REAL, doubleValue REAL, constCharpValue TEXT, charpValue TEXT, stdStringValue TEXT, unsafeStringViewValue TEXT, stringViewValue TEXT, blobValue BLOB, unsafeDataValue BLOB, dataValue BLOB)\" ];\n    [self doTestCreateTableAndIndexSQLsAsExpected:expected\n                                      inOperation:^BOOL {\n                                          return CPPTestTableCreate<CPPWCDBOptionalAllTypesObject>(self);\n                                      }];\n\n    WCDB::Table<CPPWCDBOptionalAllTypesObject> table = self.database->getTable<CPPWCDBOptionalAllTypesObject>(self.tableName.UTF8String);\n\n    CPPWCDBOptionalAllTypesObject maxObject = CPPWCDBOptionalAllTypesObject::maxObject();\n    TestCaseAssertTrue(table.insertObjects(maxObject));\n\n    CPPWCDBOptionalAllTypesObject minObject = CPPWCDBOptionalAllTypesObject::minObject();\n    TestCaseAssertTrue(table.insertObjects(minObject));\n\n    CPPWCDBOptionalAllTypesObject emptyObject = CPPWCDBOptionalAllTypesObject::emptyObject();\n    TestCaseAssertTrue(table.insertObjects(emptyObject));\n\n    CPPWCDBOptionalAllTypesObject randomObject = CPPWCDBOptionalAllTypesObject::randomObject();\n    TestCaseAssertTrue(table.insertObjects(randomObject));\n\n    XCTAssertTrue(table.insertRows({ \"null\" }, WCDB_FIELD(CPPWCDBOptionalAllTypesObject::type)));\n\n    CPPWCDBOptionalAllTypesObject selectedMaxObject = table.getFirstObject(WCDB_FIELD(CPPWCDBOptionalAllTypesObject::type) == maxObject.type).value();\n    TestCaseAssertTrue(selectedMaxObject == maxObject);\n\n    CPPWCDBOptionalAllTypesObject selectedMinObject = table.getFirstObject(WCDB_FIELD(CPPWCDBOptionalAllTypesObject::type) == minObject.type).value();\n    TestCaseAssertTrue(selectedMinObject == minObject);\n\n    CPPWCDBOptionalAllTypesObject selectedEmptyObject = table.getFirstObject(WCDB_FIELD(CPPWCDBOptionalAllTypesObject::type) == emptyObject.type).value();\n    TestCaseAssertTrue(selectedEmptyObject == emptyObject);\n\n    CPPWCDBOptionalAllTypesObject selectedRandomObject = table.getFirstObject(WCDB_FIELD(CPPWCDBOptionalAllTypesObject::type) == randomObject.type).value();\n    TestCaseAssertTrue(selectedRandomObject == randomObject);\n\n    CPPWCDBOptionalAllTypesObject selectedNullObject = table.getFirstObject(WCDB_FIELD(CPPWCDBOptionalAllTypesObject::type) == \"null\").value();\n    TestCaseAssertTrue(selectedNullObject == emptyObject);\n}\n\n- (void)test_all_properties\n{\n    TestCaseAssertEqual(2, CPPFieldObject::allFields().size());\n    TestCaseAssertSQLEqual(CPPFieldObject::allFields(), @\"field, differentName\");\n}\n\n#pragma mark - column constraint\n- (void)test_column_constraint_primary\n{\n    NSArray<NSString*>* expected = @[\n        @\"CREATE TABLE IF NOT EXISTS testTable(value INTEGER PRIMARY KEY)\",\n    ];\n    [self doTestCreateTableAndIndexSQLsAsExpected:expected\n                                      inOperation:^BOOL {\n                                          return CPPTestTableCreate<CPPColumnConstraintPrimary>(self);\n                                      }];\n}\n\n- (void)test_column_constraint_primary_asc\n{\n    NSArray<NSString*>* expected = @[\n        @\"CREATE TABLE IF NOT EXISTS testTable(value INTEGER PRIMARY KEY ASC)\",\n    ];\n    [self doTestCreateTableAndIndexSQLsAsExpected:expected\n                                      inOperation:^BOOL {\n                                          return CPPTestTableCreate<CPPColumnConstraintPrimaryAsc>(self);\n                                      }];\n}\n\n- (void)test_column_constraint_primary_desc\n{\n    NSArray<NSString*>* expected = @[\n        @\"CREATE TABLE IF NOT EXISTS testTable(value INTEGER PRIMARY KEY DESC)\",\n    ];\n    [self doTestCreateTableAndIndexSQLsAsExpected:expected\n                                      inOperation:^BOOL {\n                                          return CPPTestTableCreate<CPPColumnConstraintPrimaryDesc>(self);\n                                      }];\n}\n\n- (void)test_column_constraint_auto_increment\n{\n    NSArray<NSString*>* expected = @[\n        @\"CREATE TABLE IF NOT EXISTS testTable(value INTEGER PRIMARY KEY AUTOINCREMENT)\",\n    ];\n    [self doTestCreateTableAndIndexSQLsAsExpected:expected\n                                      inOperation:^BOOL {\n                                          return CPPTestTableCreate<CPPColumnConstraintAutoIncrement>(self);\n                                      }];\n}\n\n- (void)test_column_constraint_auto_increment_asc\n{\n    NSArray<NSString*>* expected = @[\n        @\"CREATE TABLE IF NOT EXISTS testTable(value INTEGER PRIMARY KEY ASC AUTOINCREMENT)\",\n    ];\n    [self doTestCreateTableAndIndexSQLsAsExpected:expected\n                                      inOperation:^BOOL {\n                                          return CPPTestTableCreate<CPPColumnConstraintAutoIncrementAsc>(self);\n                                      }];\n}\n\n- (void)test_column_constraint_unique\n{\n    NSArray<NSString*>* expected = @[\n        @\"CREATE TABLE IF NOT EXISTS testTable(value INTEGER UNIQUE)\",\n    ];\n    [self doTestCreateTableAndIndexSQLsAsExpected:expected\n                                      inOperation:^BOOL {\n                                          return CPPTestTableCreate<CPPColumnConstraintUnique>(self);\n                                      }];\n}\n\n- (void)test_column_constraint_default\n{\n    NSArray<NSString*>* expected = @[\n        @\"CREATE TABLE IF NOT EXISTS testTable(value INTEGER DEFAULT 1)\",\n    ];\n    [self doTestCreateTableAndIndexSQLsAsExpected:expected\n                                      inOperation:^BOOL {\n                                          return CPPTestTableCreate<CPPColumnConstraintDefault>(self);\n                                      }];\n}\n\n- (void)test_column_constraint_primary_enable_auto_increment_for_existing_table\n{\n    TestCaseAssertTrue(self.database->createTable<CPPColumnConstraintPrimaryNotAutoIncrement>(self.tableName.UTF8String));\n    CPPColumnConstraintPrimaryNotAutoIncrement obj;\n    obj.id = 1;\n    obj.isAutoIncrement = true;\n    TestCaseAssertTrue(self.database->insertObjects<CPPColumnConstraintPrimaryNotAutoIncrement>(obj, self.tableName.UTF8String));\n    TestCaseAssertTrue(*obj.lastInsertedRowID == 1LL);\n\n    TestCaseAssertTrue(self.database->createTable<CPPColumnConstraintEnablePrimaryAutoIncrement>(self.tableName.UTF8String));\n\n    TestCaseAssertTrue(self.database->deleteObjects(self.tableName.UTF8String));\n\n    CPPColumnConstraintEnablePrimaryAutoIncrement obj2;\n    obj2.isAutoIncrement = true;\n    TestCaseAssertTrue(self.database->insertObjects<CPPColumnConstraintEnablePrimaryAutoIncrement>(obj2, self.tableName.UTF8String));\n    TestCaseAssertTrue(*obj2.lastInsertedRowID == 2LL);\n}\n\n#pragma mark - index\n- (void)test_index\n{\n    NSArray<NSString*>* expected = @[\n        @\"CREATE TABLE IF NOT EXISTS testTable(index_ INTEGER, indexAsc INTEGER, indexDesc INTEGER, uniqueIndex INTEGER, uniqueIndexAsc INTEGER, uniqueIndexDesc INTEGER, multiIndex INTEGER, multiIndexAsc INTEGER, multiIndexDesc INTEGER)\",\n        @\"CREATE INDEX IF NOT EXISTS testTable_index ON testTable(index_)\",\n        @\"CREATE INDEX IF NOT EXISTS testTable_index_asc ON testTable(indexAsc ASC)\",\n        @\"CREATE INDEX IF NOT EXISTS testTable_index_desc ON testTable(indexDesc DESC)\",\n        @\"CREATE INDEX IF NOT EXISTS testTable_multi_index ON testTable(multiIndex, multiIndexAsc ASC, multiIndexDesc DESC)\",\n        @\"CREATE UNIQUE INDEX IF NOT EXISTS testTable_unique_index ON testTable(uniqueIndex)\",\n        @\"CREATE UNIQUE INDEX IF NOT EXISTS testTable_unique_index_asc ON testTable(uniqueIndexAsc ASC)\",\n        @\"CREATE UNIQUE INDEX IF NOT EXISTS testTable_unique_index_desc ON testTable(uniqueIndexDesc DESC)\",\n    ];\n    [self doTestCreateTableAndIndexSQLsAsExpected:expected\n                                      inOperation:^BOOL {\n                                          return CPPTestTableCreate<CPPIndexObject>(self);\n                                      }];\n}\n\n#pragma mark - remap\n- (void)test_remap\n{\n    {\n        NSArray<NSString*>* expected = @[ @\"CREATE TABLE IF NOT EXISTS testTable(value INTEGER)\" ];\n        [self doTestCreateTableAndIndexSQLsAsExpected:expected\n                                          inOperation:^BOOL {\n                                              return CPPTestTableCreate<CPPOldRemapObject>(self);\n                                          }];\n    }\n    // remap\n    {\n        NSArray<NSString*>* expected = @[ @\"PRAGMA main.table_info('testTable')\", @\"ALTER TABLE main.testTable ADD COLUMN newValue INTEGER\", @\"CREATE INDEX IF NOT EXISTS testTable_index ON testTable(value)\" ];\n        [self doTestCreateTableAndIndexSQLsAsExpected:expected\n                                          inOperation:^BOOL {\n                                              return CPPTestTableCreate<CPPNewRemapObject>(self);\n                                          }];\n    }\n}\n\n- (void)test_remap_with_extra_actions\n{\n    {\n        NSArray<NSString*>* expected = @[ @\"CREATE TABLE IF NOT EXISTS testTable(value INTEGER)\" ];\n        [self doTestCreateTableAndIndexSQLsAsExpected:expected\n                                          inOperation:^BOOL {\n                                              return CPPTestTableCreate<CPPOldRemapObject>(self);\n                                          }];\n    }\n    // remap\n    {\n        NSArray<NSString*>* expected = @[ @\"PRAGMA main.table_info('testTable')\", @\"ALTER TABLE main.testTable ADD COLUMN newValue INTEGER\" ];\n        [self doTestCreateTableAndIndexSQLsAsExpected:expected\n                                          inOperation:^BOOL {\n                                              return CPPTestTableCreate<CPPNewlyCreatedTableIndexObject>(self);\n                                          }];\n    }\n    TestCaseAssertTrue([self dropTable]);\n    // newly create\n    {\n        NSArray<NSString*>* expected = @[ @\"CREATE TABLE IF NOT EXISTS testTable(value INTEGER, newValue INTEGER)\", @\"CREATE INDEX IF NOT EXISTS testTable_index ON testTable(value)\" ];\n        [self doTestCreateTableAndIndexSQLsAsExpected:expected\n                                          inOperation:^BOOL {\n                                              return CPPTestTableCreate<CPPNewlyCreatedTableIndexObject>(self);\n                                          }];\n    }\n    // drop index\n    {\n        NSArray<NSString*>* expected = @[ @\"PRAGMA main.table_info('testTable')\", @\"DROP INDEX IF EXISTS testTable_index\" ];\n        [self doTestCreateTableAndIndexSQLsAsExpected:expected\n                                          inOperation:^BOOL {\n                                              return CPPTestTableCreate<CPPDropIndexObject>(self);\n                                          }];\n    }\n}\n\n#pragma mark - virtual table\n- (void)test_virtual_table_fts3\n{\n    self.database->addTokenizer(WCDB::BuiltinTokenizer::OneOrBinary);\n    NSString* expected = @\"CREATE VIRTUAL TABLE IF NOT EXISTS testTable USING fts4(tokenize = wcdb_one_or_binary, content='contentTable', identifier INTEGER, content TEXT, notindexed=identifier)\";\n    [self doTestSQLs:@[ expected ]\n         inOperation:^BOOL {\n             return CPPTestVirtualTableCreate<CPPVirtualTableFTS4Object>(self);\n         }];\n}\n\n- (void)test_virtual_table_fts5\n{\n    NSString* expected = @\"CREATE VIRTUAL TABLE IF NOT EXISTS testTable USING fts5(tokenize = 'porter', content='contentTable', identifier UNINDEXED, content)\";\n    [self doTestSQLs:@[ expected ]\n         inOperation:^BOOL {\n             return CPPTestVirtualTableCreate<CPPVirtualTableFTS5Object>(self);\n         }];\n}\n\n#pragma mark - auto add column\n- (void)test_auto_add_column\n{\n    NSString* fakeTable = @\"fakeTable\";\n    TestCaseAssertTrue(self.database->createTable<CPPNewFieldObject>(fakeTable.UTF8String));\n\n    [self testAutoAddColumn:WCDB_FIELD(CPPNewFieldObject::insertValue)\n                  isSucceed:YES\n                  byExecute:^bool {\n                      return self.database->insertObjects<CPPNewFieldObject>(CPPNewFieldObject(), self.tableName.UTF8String);\n                  }];\n\n    [self testAutoAddColumn:WCDB_FIELD(CPPNewFieldObject::updateValue)\n                  isSucceed:YES\n                  byExecute:^bool {\n                      return self.database->updateRow(1, WCDB_FIELD(CPPNewFieldObject::updateValue), self.tableName.UTF8String);\n                  }];\n\n    [self testAutoAddColumn:WCDB_FIELD(CPPNewFieldObject::deleteValue)\n                  isSucceed:YES\n                  byExecute:^bool {\n                      return self.database->deleteObjects(self.tableName.UTF8String, WCDB_FIELD(CPPNewFieldObject::deleteValue) == 1);\n                  }];\n\n    [self testAutoAddColumn:WCDB_FIELD(CPPNewFieldObject::deleteValue)\n                  isSucceed:YES\n                  byExecute:^bool {\n                      return self.database->deleteObjects(self.tableName.UTF8String, WCDB_FIELD(CPPNewFieldObject::deleteValue).table(self.tableName.UTF8String) == 1);\n                  }];\n\n    [self testAutoAddColumn:WCDB_FIELD(CPPNewFieldObject::deleteValue)\n                  isSucceed:NO\n                  byExecute:^bool {\n                      return self.database->deleteObjects(self.tableName.UTF8String, WCDB_FIELD(CPPNewFieldObject::deleteValue).table(fakeTable.UTF8String) == 1);\n                  }];\n\n    [self testAutoAddColumn:WCDB_FIELD(CPPNewFieldObject::deleteValue)\n                  isSucceed:NO\n                  byExecute:^bool {\n                      return self.database->deleteObjects(self.tableName.UTF8String, WCDB_FIELD(CPPNewFieldObject::deleteValue).table(self.tableName.UTF8String).schema(\"notExistSchema\") == 1);\n                  }];\n\n    [self testAutoAddColumn:WCDB_FIELD(CPPNewFieldObject::selectValue)\n                  isSucceed:YES\n                  byExecute:^bool {\n                      return self.database->selectOneColumn(WCDB_FIELD(CPPNewFieldObject::selectValue), self.tableName.UTF8String).succeed();\n                  }];\n\n    [self testAutoAddColumn:WCDB_FIELD(CPPNewFieldObject::selectValue)\n                  isSucceed:YES\n                  byExecute:^bool {\n                      return self.database->selectOneColumn(WCDB_FIELD(CPPNewFieldObject::insertValue), self.tableName.UTF8String, WCDB_FIELD(CPPNewFieldObject::selectValue) == 1).succeed();\n                  }];\n\n    [self testAutoAddColumn:WCDB_FIELD(CPPNewFieldObject::selectValue)\n                  isSucceed:YES\n                  byExecute:^bool {\n                      return self.database->selectOneColumn(WCDB_FIELD(CPPNewFieldObject::insertValue), self.tableName.UTF8String, WCDB::Expression(), WCDB_FIELD(CPPNewFieldObject::selectValue).asOrder()).succeed();\n                  }];\n\n    [self testAutoAddColumn:WCDB_FIELD(CPPNewFieldObject::selectValue)\n                  isSucceed:YES\n                  byExecute:^bool {\n                      return self.database->selectOneColumn(WCDB_FIELD(CPPNewFieldObject::insertValue), self.tableName.UTF8String, WCDB::Expression(), WCDB_FIELD(CPPNewFieldObject::selectValue).table(self.tableName.UTF8String).asOrder()).succeed();\n                  }];\n\n    [self testAutoAddColumn:WCDB_FIELD(CPPNewFieldObject::selectValue)\n                  isSucceed:NO\n                  byExecute:^bool {\n                      return self.database->selectOneColumn(WCDB_FIELD(CPPNewFieldObject::insertValue), self.tableName.UTF8String, WCDB::Expression(), WCDB_FIELD(CPPNewFieldObject::selectValue).table(fakeTable.UTF8String).asOrder()).succeed();\n                  }];\n\n    [self testAutoAddColumn:WCDB_FIELD(CPPNewFieldObject::selectValue)\n                  isSucceed:NO\n                  byExecute:^bool {\n                      return self.database->selectOneColumn(WCDB_FIELD(CPPNewFieldObject::insertValue), self.tableName.UTF8String, WCDB::Expression(), WCDB_FIELD(CPPNewFieldObject::selectValue).table(self.tableName.UTF8String).schema(\"notExistSchema\").asOrder()).succeed();\n                  }];\n\n    [self testAutoAddColumn:WCDB_FIELD(CPPNewFieldObject::multiSelectValue)\n                  isSucceed:YES\n                  byExecute:^bool {\n                      WCDB::MultiSelect multiSelect = self.database->prepareMultiSelect();\n                      multiSelect.onResultFields({ WCDB_FIELD(CPPNewFieldObject::multiSelectValue).table(self.tableName.UTF8String), WCDB_FIELD(CPPNewFieldObject::multiSelectValue).table(fakeTable.UTF8String) }).fromTables({ self.tableName.UTF8String, fakeTable.UTF8String });\n                      return multiSelect.allMultiObjects().succeed();\n                  }];\n\n    [self testAutoAddColumn:WCDB_FIELD(CPPNewFieldObject::multiSelectValue)\n                  isSucceed:NO\n                  byExecute:^bool {\n                      WCDB::MultiSelect multiSelect = self.database->prepareMultiSelect();\n                      multiSelect.onResultFields({ WCDB_FIELD(CPPNewFieldObject::multiSelectValue).table(self.tableName.UTF8String).schema(\"notExistSchema\"), WCDB_FIELD(CPPNewFieldObject::multiSelectValue).table(fakeTable.UTF8String) }).fromTables({ self.tableName.UTF8String, fakeTable.UTF8String });\n                      return multiSelect.allMultiObjects().succeed();\n                  }];\n\n    [self testAutoAddColumn:WCDB_FIELD(CPPNewFieldObject::primaryValue)\n                  isSucceed:NO\n                  byExecute:^bool {\n                      return self.database->selectOneColumn(WCDB_FIELD(CPPNewFieldObject::insertValue), self.tableName.UTF8String, WCDB_FIELD(CPPNewFieldObject::primaryValue) == 1).succeed();\n                  }];\n\n    [self testAutoAddColumn:WCDB_FIELD(CPPNewFieldObject::uniqueValue)\n                  isSucceed:NO\n                  byExecute:^bool {\n                      return self.database->selectOneColumn(WCDB_FIELD(CPPNewFieldObject::insertValue), self.tableName.UTF8String, WCDB_FIELD(CPPNewFieldObject::uniqueValue) == 1).succeed();\n                  }];\n}\n\n- (void)testAutoAddColumn:(const WCDB::Field&)newField isSucceed:(BOOL)isSucceed byExecute:(bool (^)())block\n{\n    auto createTable = WCDB::StatementCreateTable().createTable(self.tableName.UTF8String);\n    auto binding = const_cast<WCDB::Binding*>(&CPPNewFieldObject::getObjectRelationBinding());\n    auto fields = CPPNewFieldObject::allFields().fieldsByRemovingFields(newField);\n    for (const WCDB::Field& field : fields) {\n        createTable.define(*binding->getColumnDef(field.getDescription()));\n    }\n    NSString* propertyName = [NSString stringWithUTF8String:newField.getDescription().data()];\n    TestCaseAssertTrue(self.database->execute(createTable));\n    bool autoAdded = false;\n    self.database->traceError([&](const WCDB::Error& error) {\n        if (error.getMessage().compare(\"Auto add column\") != 0) {\n            return;\n        }\n        autoAdded = YES;\n        TestCaseAssertTrue(error.infos.at(\"Table\").textValue().compare(self.tableName.UTF8String) == 0);\n        TestCaseAssertTrue(error.infos.at(\"Column\").textValue().compare(propertyName.UTF8String) == 0);\n    });\n    TestCaseAssertTrue(block() == isSucceed);\n    TestCaseAssertTrue(autoAdded || !isSucceed);\n    TestCaseAssertTrue(self.database->dropTable(self.tableName.UTF8String));\n    self.database->traceError(nullptr);\n}\n\n- (void)test_redirect_field\n{\n    [self insertPresetObjects];\n    auto object = self.table.getFirstObjectWithFields(WCDB_FIELD(CPPTestCaseObject::identifier).redirect(WCDB_FIELD(CPPTestCaseObject::identifier).max()));\n    XCTAssertTrue(object.valueOrDefault().identifier == self.objects[1].identifier);\n}\n\n#pragma mark - inherit\n- (void)test_inherit\n{\n    NSArray<NSString*>* expected = @[\n        @\"CREATE TABLE IF NOT EXISTS testTable(value1 INTEGER PRIMARY KEY, value2 REAL, value3 INTEGER, value4 TEXT, value5 BLOB UNIQUE)\",\n        @\"CREATE INDEX IF NOT EXISTS testTable_value2 ON testTable(value2)\",\n        @\"CREATE INDEX IF NOT EXISTS testTable_value3_value4 ON testTable(value3, value4)\"\n    ];\n    [self doTestCreateTableAndIndexSQLsAsExpected:expected\n                                      inOperation:^BOOL {\n                                          return CPPTestTableCreate<CPPInheritObject>(self);\n                                      }];\n\n    CPPInheritObject object;\n    object.value1 = 1;\n    object.value2 = 2.0;\n    object.value3 = 3;\n    object.value4 = \"abc\";\n    NSData* data = Random.shared.data;\n    object.value5 = WCDB::Data((const unsigned char*) data.bytes, data.length);\n    [self doTestSQLs:@[ @\"INSERT INTO testTable(value1, value2, value3, value4, value5) VALUES(?1, ?2, ?3, ?4, ?5)\",\n                        @\"UPDATE testTable SET value4 = ?1 WHERE value1 == 1\",\n                        @\"SELECT value1, value2, value3, value4, value5 FROM testTable WHERE value2 == 2 ORDER BY rowid ASC LIMIT 1\",\n                        @\"DELETE FROM testTable WHERE value3 == 3\" ]\n         inOperation:^BOOL {\n             XCTAssertTrue(self.database->insertObject<CPPInheritBase1>(object, self.tableName.UTF8String, CPPInheritObject::allFields()));\n             CPPInheritObject object2;\n             object2.value4 = \"def\";\n             XCTAssertTrue(self.database->updateObject<CPPInheritBase1>(object2, { WCDB_FIELD(CPPInheritObject::value4) }, self.tableName.UTF8String, WCDB_FIELD(CPPInheritBase1::value1) == 1));\n             auto ret = self.database->getFirstObject<CPPInheritObject>(self.tableName.UTF8String, WCDB_FIELD(CPPInheritObject::value2) == 2);\n             XCTAssertTrue(ret.succeed());\n             XCTAssertTrue(ret.value().value2 == 2.0 && ret.value().value3 == 3 && ret.value().value4 == \"def\");\n             XCTAssertTrue(memcmp((const void*) ret.value().value5.buffer(), data.bytes, data.length) == 0);\n             XCTAssertTrue(self.database->deleteObjects(self.tableName.UTF8String, WCDB_FIELD(CPPInheritBase2::value3) == 3));\n             return true;\n         }];\n\n    auto count = self.database->selectValue(WCDB::Column::all().count(), self.tableName.UTF8String);\n    XCTAssertTrue(count.succeed() && count.value() == 0);\n}\n\n@end\n"
  },
  {
    "path": "src/cpp/tests/orm/alltypes/CPPAllTypesObject.h",
    "content": "//\n// Created by qiuwenchen on 2022/9/5.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#if TEST_WCDB_OBJC\n#import <WCDBOBjc/WCDBCpp.h>\n#elif TEST_WCDB_CPP\n#import <WCDBCpp/WCDBCpp.h>\n#else\n#import <WCDB/WCDBCpp.h>\n#endif\n\nenum EnumType {\n    Min = std::numeric_limits<int>::min(),\n    Zero = 0,\n    Max = std::numeric_limits<int>::max(),\n};\n\nenum class EnumClassType {\n    Min = std::numeric_limits<int>::min(),\n    Zero = 0,\n    Max = std::numeric_limits<int>::max(),\n};\n\ntypedef enum {\n    EnumMin = std::numeric_limits<int>::min(),\n    EnumZero = 0,\n    EnumMax = std::numeric_limits<int>::max(),\n} LiteralEnum;\n\nclass CPPAllTypesObject {\npublic:\n    WCDB::StringView type;\n\n    // Enum\n    EnumType enumValue;\n    EnumClassType enumClassValue;\n    LiteralEnum literalEnumValue;\n\n    // Bool\n    bool trueOrFalseValue;\n\n    // Integer\n    char charValue;\n    unsigned char unsignedCharValue;\n    short shortValue;\n    unsigned short unsignedShortValue;\n    int intValue;\n    unsigned int unsignedIntValue;\n    int32_t int32Value;\n    int64_t int64Value;\n    uint32_t uint32Value;\n    uint64_t uint64Value;\n\n    // Float\n    float floatValue;\n    double doubleValue;\n\n    // String\n    const char* constCharpValue;\n    char* charpValue;\n    const char constCharArrValue[6] = \"hello\";\n    char charArrValue[100];\n    std::string stdStringValue;\n    WCDB::UnsafeStringView unsafeStringViewValue;\n    WCDB::StringView stringViewValue;\n\n    // BLOB\n    std::vector<unsigned char> blobValue;\n    WCDB::UnsafeData unsafeDataValue;\n    WCDB::Data dataValue;\n    const unsigned char constUnsignedCharArrValue[6] = \"world\";\n    unsigned char unsignedCharArrValue[100];\n\n    WCDB_CPP_ORM_DECLARATION(CPPAllTypesObject)\n\nprivate:\n    void copyFrom(const CPPAllTypesObject& other);\n\npublic:\n    static CPPAllTypesObject maxObject();\n    static CPPAllTypesObject minObject();\n    static CPPAllTypesObject emptyObject();\n    static CPPAllTypesObject randomObject();\n\n    bool operator==(const CPPAllTypesObject& other);\n    CPPAllTypesObject& operator=(const CPPAllTypesObject& other);\n    CPPAllTypesObject(const CPPAllTypesObject& other);\n    CPPAllTypesObject(CPPAllTypesObject&& other);\n    CPPAllTypesObject();\n    ~CPPAllTypesObject();\n};\n"
  },
  {
    "path": "src/cpp/tests/orm/alltypes/CPPAllTypesObject.mm",
    "content": "//\n// Created by qiuwenchen on 2022/9/5.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"CPPAllTypesObject.h\"\n#import \"Random.h\"\n\nWCDB_CPP_ORM_IMPLEMENTATION_BEGIN(CPPAllTypesObject)\n\nWCDB_CPP_SYNTHESIZE(type)\n\nWCDB_CPP_SYNTHESIZE(enumValue)\nWCDB_CPP_SYNTHESIZE(enumClassValue)\nWCDB_CPP_SYNTHESIZE(literalEnumValue)\n\nWCDB_CPP_SYNTHESIZE(trueOrFalseValue)\n\nWCDB_CPP_SYNTHESIZE(charValue)\nWCDB_CPP_SYNTHESIZE(unsignedCharValue)\nWCDB_CPP_SYNTHESIZE(shortValue)\nWCDB_CPP_SYNTHESIZE(unsignedShortValue)\nWCDB_CPP_SYNTHESIZE(intValue)\nWCDB_CPP_SYNTHESIZE(unsignedIntValue)\nWCDB_CPP_SYNTHESIZE(int32Value)\nWCDB_CPP_SYNTHESIZE(int64Value)\nWCDB_CPP_SYNTHESIZE(uint32Value)\nWCDB_CPP_SYNTHESIZE(uint64Value)\n\nWCDB_CPP_SYNTHESIZE(floatValue)\nWCDB_CPP_SYNTHESIZE(doubleValue)\n\nWCDB_CPP_SYNTHESIZE(constCharpValue)\nWCDB_CPP_SYNTHESIZE(charpValue)\nWCDB_CPP_SYNTHESIZE(constCharArrValue)\nWCDB_CPP_SYNTHESIZE(charArrValue)\nWCDB_CPP_SYNTHESIZE(stdStringValue)\nWCDB_CPP_SYNTHESIZE(unsafeStringViewValue)\nWCDB_CPP_SYNTHESIZE(stringViewValue)\n\nWCDB_CPP_SYNTHESIZE(blobValue)\nWCDB_CPP_SYNTHESIZE(unsafeDataValue)\nWCDB_CPP_SYNTHESIZE(dataValue)\nWCDB_CPP_SYNTHESIZE(constUnsignedCharArrValue)\nWCDB_CPP_SYNTHESIZE(unsignedCharArrValue)\n\nWCDB_CPP_ORM_IMPLEMENTATION_END\n\nCPPAllTypesObject CPPAllTypesObject::maxObject()\n{\n    CPPAllTypesObject object;\n    object.type = \"max\";\n#define ASSIGN_WITH_TYPED_MAX_VALUE(field, type) \\\n    object.field = std::numeric_limits<type>::max()\n#define ASSIGN_WITH_MAX_VALUE(field) \\\n    ASSIGN_WITH_TYPED_MAX_VALUE(field, decltype(object.field))\n\n    object.enumValue = EnumType::Max;\n    object.enumClassValue = EnumClassType::Max;\n    object.literalEnumValue = LiteralEnum::EnumMax;\n\n    ASSIGN_WITH_MAX_VALUE(trueOrFalseValue);\n\n    ASSIGN_WITH_MAX_VALUE(charValue);\n    ASSIGN_WITH_MAX_VALUE(unsignedCharValue);\n    ASSIGN_WITH_MAX_VALUE(shortValue);\n    ASSIGN_WITH_MAX_VALUE(unsignedShortValue);\n    ASSIGN_WITH_MAX_VALUE(intValue);\n    ASSIGN_WITH_MAX_VALUE(unsignedIntValue);\n    ASSIGN_WITH_MAX_VALUE(int32Value);\n    ASSIGN_WITH_MAX_VALUE(int64Value);\n    ASSIGN_WITH_MAX_VALUE(uint32Value);\n    ASSIGN_WITH_MAX_VALUE(uint64Value);\n\n    ASSIGN_WITH_MAX_VALUE(floatValue);\n    ASSIGN_WITH_MAX_VALUE(doubleValue);\n\n    object.constCharpValue = \"\";\n    object.charpValue = (char*) \"\";\n\n    return object;\n}\n\nCPPAllTypesObject CPPAllTypesObject::minObject()\n{\n    CPPAllTypesObject object;\n    object.type = \"min\";\n\n#define ASSIGN_WITH_TYPED_MIN_VALUE(field, type) \\\n    object.field = std::numeric_limits<type>::min()\n#define ASSIGN_WITH_MIN_VALUE(field) ASSIGN_WITH_TYPED_MIN_VALUE(field, decltype(object.field))\n\n    object.enumValue = EnumType::Min;\n    object.enumClassValue = EnumClassType::Min;\n    object.literalEnumValue = LiteralEnum::EnumMin;\n\n    ASSIGN_WITH_MIN_VALUE(trueOrFalseValue);\n\n    ASSIGN_WITH_MIN_VALUE(charValue);\n    ASSIGN_WITH_MIN_VALUE(unsignedCharValue);\n    ASSIGN_WITH_MIN_VALUE(shortValue);\n    ASSIGN_WITH_MIN_VALUE(unsignedShortValue);\n    ASSIGN_WITH_MIN_VALUE(intValue);\n    ASSIGN_WITH_MIN_VALUE(unsignedIntValue);\n    ASSIGN_WITH_MIN_VALUE(int32Value);\n    ASSIGN_WITH_MIN_VALUE(int64Value);\n    ASSIGN_WITH_MIN_VALUE(uint32Value);\n    ASSIGN_WITH_MIN_VALUE(uint64Value);\n\n    ASSIGN_WITH_MIN_VALUE(floatValue);\n    ASSIGN_WITH_MIN_VALUE(doubleValue);\n\n    object.constCharpValue = \"\";\n    object.charpValue = (char*) \"\";\n\n    return object;\n}\n\nCPPAllTypesObject CPPAllTypesObject::emptyObject()\n{\n    CPPAllTypesObject object;\n    object.type = \"empty\";\n    object.enumValue = EnumType::Zero;\n    object.enumClassValue = EnumClassType::Zero;\n    object.literalEnumValue = EnumZero;\n\n    object.trueOrFalseValue = false;\n\n    object.charValue = 0;\n    object.unsignedCharValue = 0;\n    object.shortValue = 0;\n    object.unsignedShortValue = 0;\n    object.intValue = 0;\n    object.unsignedIntValue = 0;\n    object.int32Value = 0;\n    object.int64Value = 0;\n    object.uint32Value = 0;\n    object.uint64Value = 0;\n\n    object.floatValue = 0;\n    object.doubleValue = 0;\n\n    object.constCharpValue = nullptr;\n    object.charpValue = nullptr;\n    memset(object.charArrValue, 0, 100);\n    memset(object.unsignedCharArrValue, 0, 100);\n    return object;\n}\n\nCPPAllTypesObject CPPAllTypesObject::randomObject()\n{\n    CPPAllTypesObject object;\n    object.type = \"random\";\n    object.enumValue = EnumType::Zero;\n    object.enumClassValue = EnumClassType::Zero;\n    object.literalEnumValue = EnumZero;\n\n    Random* random = [Random shared];\n\n    object.trueOrFalseValue = random.boolean;\n\n    object.charValue = random.int8;\n    object.unsignedCharValue = random.uint8;\n    object.shortValue = random.int16;\n    object.unsignedShortValue = random.uint16;\n    object.intValue = random.int32;\n    object.unsignedIntValue = random.uint32;\n    object.int32Value = random.int32;\n    object.int64Value = random.int64;\n    object.uint32Value = random.uint32;\n    object.uint64Value = random.uint64;\n\n    object.floatValue = random.float_;\n    object.doubleValue = random.double_;\n\n    object.stringViewValue = random.string.UTF8String;\n    object.stdStringValue = random.string.UTF8String;\n    object.constCharpValue = object.stdStringValue.data();\n    object.charpValue = const_cast<char*>(object.stdStringValue.data());\n    object.unsafeStringViewValue = object.stringViewValue;\n    memcpy(object.charArrValue, [random stringWithLength:99].UTF8String, 100);\n\n    NSData* data = random.data;\n    const unsigned char* buffer = (const unsigned char*) data.bytes;\n    object.blobValue.assign(buffer, buffer + data.length);\n    data = random.data;\n    buffer = (const unsigned char*) data.bytes;\n    object.dataValue = WCDB::Data(buffer, data.length);\n    object.unsafeDataValue = object.dataValue;\n    memcpy(object.unsignedCharArrValue, [random dataWithLength:100].bytes, 100);\n\n    return object;\n}\n\nbool CPPAllTypesObject::operator==(const CPPAllTypesObject& other)\n{\n    bool equal = enumValue == other.enumValue\n                 && enumClassValue == other.enumClassValue\n                 && literalEnumValue == other.literalEnumValue\n                 && trueOrFalseValue == other.trueOrFalseValue\n                 && charValue == other.charValue\n                 && unsignedCharValue == other.unsignedCharValue\n                 && shortValue == other.shortValue\n                 && unsignedShortValue == other.unsignedShortValue\n                 && intValue == other.intValue\n                 && unsignedIntValue == other.unsignedIntValue\n                 && int32Value == other.int32Value\n                 && int64Value == other.int64Value\n                 && uint32Value == other.uint32Value\n                 && uint64Value == other.uint64Value\n                 && floatValue == other.floatValue\n                 && doubleValue == other.doubleValue;\n    if (!equal) {\n        return equal;\n    }\n    if (!stringViewValue.equal(other.stringViewValue)) {\n        return false;\n    }\n    if (!unsafeStringViewValue.equal(other.unsafeStringViewValue)) {\n        return false;\n    }\n    if ((constCharpValue == nullptr && other.constCharpValue != nullptr) || (constCharpValue != nullptr && other.constCharpValue == nullptr) || (constCharpValue != nullptr && other.constCharpValue != nullptr && strcmp(constCharpValue, other.constCharpValue) != 0)) {\n        return false;\n    }\n    if ((charpValue == nullptr && other.charpValue != nullptr) || (charpValue != nullptr && other.charpValue == nullptr) || (charpValue != nullptr && other.charpValue != nullptr && strcmp(charpValue, other.charpValue) != 0)) {\n        return false;\n    }\n    if (stdStringValue.compare(other.stdStringValue) != 0) {\n        return false;\n    }\n    if (strcmp(charArrValue, other.charArrValue) != 0) {\n        return false;\n    }\n    if (strcmp(constCharArrValue, other.constCharArrValue) != 0) {\n        return false;\n    }\n    if (blobValue != other.blobValue) {\n        return false;\n    }\n    if (dataValue != other.dataValue) {\n        return false;\n    }\n    if (unsafeDataValue != other.unsafeDataValue) {\n        return false;\n    }\n    if (memcmp(constUnsignedCharArrValue, other.constUnsignedCharArrValue, 6) != 0) {\n        return false;\n    }\n    if (memcmp(unsignedCharArrValue, other.unsignedCharArrValue, 100) != 0) {\n        return false;\n    }\n    return true;\n}\n\nvoid CPPAllTypesObject::copyFrom(const CPPAllTypesObject& other)\n{\n    type = other.type;\n    enumValue = other.enumValue;\n    enumClassValue = other.enumClassValue;\n    literalEnumValue = other.literalEnumValue;\n    trueOrFalseValue = other.trueOrFalseValue;\n    charValue = other.charValue;\n    unsignedCharValue = other.unsignedCharValue;\n    shortValue = other.shortValue;\n    unsignedShortValue = other.unsignedShortValue;\n    intValue = other.intValue;\n    unsignedIntValue = other.unsignedIntValue;\n    int32Value = other.int32Value;\n    int64Value = other.int64Value;\n    uint32Value = other.uint32Value;\n    uint64Value = other.uint64Value;\n    floatValue = other.floatValue;\n    doubleValue = other.doubleValue;\n    constCharpValue = other.constCharpValue;\n    charpValue = other.charpValue;\n    memcpy(charArrValue, other.charArrValue, 100);\n    stdStringValue = other.stdStringValue;\n    unsafeStringViewValue = other.unsafeStringViewValue;\n    stringViewValue = other.stringViewValue;\n    blobValue = other.blobValue;\n    unsafeDataValue = other.unsafeDataValue;\n    dataValue = other.dataValue;\n    memcpy(unsignedCharArrValue, other.unsignedCharArrValue, 100);\n}\n\nCPPAllTypesObject& CPPAllTypesObject::operator=(const CPPAllTypesObject& other)\n{\n    copyFrom(other);\n    return *this;\n}\n\nCPPAllTypesObject::CPPAllTypesObject(const CPPAllTypesObject& other)\n{\n    copyFrom(other);\n}\n\nCPPAllTypesObject::CPPAllTypesObject(CPPAllTypesObject&& other)\n{\n    copyFrom(other);\n}\n\nCPPAllTypesObject::CPPAllTypesObject() = default;\nCPPAllTypesObject::~CPPAllTypesObject() = default;\n"
  },
  {
    "path": "src/cpp/tests/orm/alltypes/CPPSTDOptionalAllTypesObject.h",
    "content": "//\n// Created by qiuwenchen on 2023/11/1.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"CPPAllTypesObject.h\"\n\n#if defined(__cplusplus) && __cplusplus > 201402L\n\nclass CPPSTDOptionalAllTypesObject {\npublic:\n    WCDB::StringView type;\n\n    // Enum\n    std::optional<EnumType> enumValue;\n    std::optional<EnumClassType> enumClassValue;\n    std::optional<LiteralEnum> literalEnumValue;\n\n    // Bool\n    std::optional<bool> trueOrFalseValue;\n\n    // Integer\n    std::optional<char> charValue;\n    std::optional<unsigned char> unsignedCharValue;\n    std::optional<short> shortValue;\n    std::optional<unsigned short> unsignedShortValue;\n    std::optional<int> intValue;\n    std::optional<unsigned int> unsignedIntValue;\n    std::optional<int32_t> int32Value;\n    std::optional<int64_t> int64Value;\n    std::optional<uint32_t> uint32Value;\n    std::optional<uint64_t> uint64Value;\n\n    // Float\n    std::optional<float> floatValue;\n    std::optional<double> doubleValue;\n\n    // String\n    std::optional<const char*> constCharpValue;\n    std::optional<char*> charpValue;\n    std::optional<std::string> stdStringValue;\n    std::optional<WCDB::UnsafeStringView> unsafeStringViewValue;\n    std::optional<WCDB::StringView> stringViewValue;\n\n    // BLOB\n    std::optional<std::vector<unsigned char>> blobValue;\n    std::optional<WCDB::UnsafeData> unsafeDataValue;\n    std::optional<WCDB::Data> dataValue;\n\n    WCDB_CPP_ORM_DECLARATION(CPPSTDOptionalAllTypesObject)\n\nprivate:\n    void copyFrom(const CPPSTDOptionalAllTypesObject& other);\n\npublic:\n    static CPPSTDOptionalAllTypesObject maxObject();\n    static CPPSTDOptionalAllTypesObject minObject();\n    static CPPSTDOptionalAllTypesObject emptyObject();\n    static CPPSTDOptionalAllTypesObject randomObject();\n\n    bool operator==(const CPPSTDOptionalAllTypesObject& other);\n    CPPSTDOptionalAllTypesObject& operator=(const CPPSTDOptionalAllTypesObject& other);\n    CPPSTDOptionalAllTypesObject(const CPPSTDOptionalAllTypesObject& other);\n    CPPSTDOptionalAllTypesObject(CPPSTDOptionalAllTypesObject&& other);\n    CPPSTDOptionalAllTypesObject();\n    ~CPPSTDOptionalAllTypesObject();\n};\n\n#endif\n"
  },
  {
    "path": "src/cpp/tests/orm/alltypes/CPPSTDOptionalAllTypesObject.mm",
    "content": "//\n// Created by qiuwenchen on 2023/11/1.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"CPPSTDOptionalAllTypesObject.h\"\n#import <Foundation/Foundation.h>\n\n#import \"Random.h\"\n\n#if defined(__cplusplus) && __cplusplus > 201402L\n\nWCDB_CPP_ORM_IMPLEMENTATION_BEGIN(CPPSTDOptionalAllTypesObject)\n\nWCDB_CPP_SYNTHESIZE(type)\n\nWCDB_CPP_SYNTHESIZE(enumValue)\nWCDB_CPP_SYNTHESIZE(enumClassValue)\nWCDB_CPP_SYNTHESIZE(literalEnumValue)\n\nWCDB_CPP_SYNTHESIZE(trueOrFalseValue)\n\nWCDB_CPP_SYNTHESIZE(charValue)\nWCDB_CPP_SYNTHESIZE(unsignedCharValue)\nWCDB_CPP_SYNTHESIZE(shortValue)\nWCDB_CPP_SYNTHESIZE(unsignedShortValue)\nWCDB_CPP_SYNTHESIZE(intValue)\nWCDB_CPP_SYNTHESIZE(unsignedIntValue)\nWCDB_CPP_SYNTHESIZE(int32Value)\nWCDB_CPP_SYNTHESIZE(int64Value)\nWCDB_CPP_SYNTHESIZE(uint32Value)\nWCDB_CPP_SYNTHESIZE(uint64Value)\n\nWCDB_CPP_SYNTHESIZE(floatValue)\nWCDB_CPP_SYNTHESIZE(doubleValue)\n\nWCDB_CPP_SYNTHESIZE(constCharpValue)\nWCDB_CPP_SYNTHESIZE(charpValue)\nWCDB_CPP_SYNTHESIZE(stdStringValue)\nWCDB_CPP_SYNTHESIZE(unsafeStringViewValue)\nWCDB_CPP_SYNTHESIZE(stringViewValue)\n\nWCDB_CPP_SYNTHESIZE(blobValue)\nWCDB_CPP_SYNTHESIZE(unsafeDataValue)\nWCDB_CPP_SYNTHESIZE(dataValue)\n\nWCDB_CPP_ORM_IMPLEMENTATION_END\n\nCPPSTDOptionalAllTypesObject CPPSTDOptionalAllTypesObject::maxObject()\n{\n    CPPSTDOptionalAllTypesObject object;\n    object.type = \"max\";\n\n    object.enumValue = std::make_optional<EnumType>(EnumType::Max);\n    object.enumClassValue = std::make_optional<EnumClassType>(EnumClassType::Max);\n    object.literalEnumValue = std::make_optional<LiteralEnum>(LiteralEnum::EnumMax);\n\n#define ASSIGN_WITH_TYPED_MAX_VALUE(field, type) \\\n    object.field = std::make_optional<typename type::value_type>(std::numeric_limits<typename type::value_type>::max())\n#define ASSIGN_WITH_MAX_VALUE(field) \\\n    ASSIGN_WITH_TYPED_MAX_VALUE(field, decltype(object.field))\n\n    ASSIGN_WITH_MAX_VALUE(trueOrFalseValue);\n\n    ASSIGN_WITH_MAX_VALUE(charValue);\n    ASSIGN_WITH_MAX_VALUE(unsignedCharValue);\n    ASSIGN_WITH_MAX_VALUE(shortValue);\n    ASSIGN_WITH_MAX_VALUE(unsignedShortValue);\n    ASSIGN_WITH_MAX_VALUE(intValue);\n    ASSIGN_WITH_MAX_VALUE(unsignedIntValue);\n    ASSIGN_WITH_MAX_VALUE(int32Value);\n    ASSIGN_WITH_MAX_VALUE(int64Value);\n    ASSIGN_WITH_MAX_VALUE(uint32Value);\n    ASSIGN_WITH_MAX_VALUE(uint64Value);\n\n    ASSIGN_WITH_MAX_VALUE(floatValue);\n    ASSIGN_WITH_MAX_VALUE(doubleValue);\n\n    return object;\n}\n\nCPPSTDOptionalAllTypesObject CPPSTDOptionalAllTypesObject::minObject()\n{\n    CPPSTDOptionalAllTypesObject object;\n    object.type = \"min\";\n\n    object.enumValue = std::make_optional<EnumType>(EnumType::Min);\n    object.enumClassValue = std::make_optional<EnumClassType>(EnumClassType::Min);\n    object.literalEnumValue = std::make_optional<LiteralEnum>(LiteralEnum::EnumMin);\n\n#define ASSIGN_WITH_TYPED_MIN_VALUE(field, type) \\\n    object.field = std::make_optional<typename type::value_type>(std::numeric_limits<typename type::value_type>::min())\n#define ASSIGN_WITH_MIN_VALUE(field) ASSIGN_WITH_TYPED_MIN_VALUE(field, decltype(object.field))\n\n    ASSIGN_WITH_MIN_VALUE(trueOrFalseValue);\n\n    ASSIGN_WITH_MIN_VALUE(charValue);\n    ASSIGN_WITH_MIN_VALUE(unsignedCharValue);\n    ASSIGN_WITH_MIN_VALUE(shortValue);\n    ASSIGN_WITH_MIN_VALUE(unsignedShortValue);\n    ASSIGN_WITH_MIN_VALUE(intValue);\n    ASSIGN_WITH_MIN_VALUE(unsignedIntValue);\n    ASSIGN_WITH_MIN_VALUE(int32Value);\n    ASSIGN_WITH_MIN_VALUE(int64Value);\n    ASSIGN_WITH_MIN_VALUE(uint32Value);\n    ASSIGN_WITH_MIN_VALUE(uint64Value);\n\n    ASSIGN_WITH_MIN_VALUE(floatValue);\n    ASSIGN_WITH_MIN_VALUE(doubleValue);\n\n    return object;\n}\n\nCPPSTDOptionalAllTypesObject CPPSTDOptionalAllTypesObject::emptyObject()\n{\n    CPPSTDOptionalAllTypesObject object;\n    object.type = \"empty\";\n    return object;\n}\n\nCPPSTDOptionalAllTypesObject CPPSTDOptionalAllTypesObject::randomObject()\n{\n    CPPSTDOptionalAllTypesObject object;\n    object.type = \"random\";\n\n    object.enumValue = std::make_optional<EnumType>(EnumType::Zero);\n    object.enumClassValue = std::make_optional<EnumClassType>(EnumClassType::Zero);\n    object.literalEnumValue = std::make_optional<LiteralEnum>(LiteralEnum::EnumZero);\n\n    Random* random = [Random shared];\n\n#define OPTIONAL_RANDOM_VALUE(value) std::make_optional<decltype(value)>(value)\n\n    object.trueOrFalseValue = OPTIONAL_RANDOM_VALUE((bool) random.boolean);\n\n    object.charValue = OPTIONAL_RANDOM_VALUE((char) random.int8);\n    object.unsignedCharValue = OPTIONAL_RANDOM_VALUE(random.uint8);\n    object.shortValue = OPTIONAL_RANDOM_VALUE(random.int16);\n    object.unsignedShortValue = OPTIONAL_RANDOM_VALUE(random.uint16);\n    object.intValue = OPTIONAL_RANDOM_VALUE(random.int32);\n    object.unsignedIntValue = OPTIONAL_RANDOM_VALUE(random.uint32);\n    object.int32Value = OPTIONAL_RANDOM_VALUE(random.int32);\n    object.int64Value = OPTIONAL_RANDOM_VALUE(random.int64);\n    object.uint32Value = OPTIONAL_RANDOM_VALUE(random.uint32);\n    object.uint64Value = OPTIONAL_RANDOM_VALUE(random.uint64);\n\n    object.floatValue = OPTIONAL_RANDOM_VALUE(random.float_);\n    object.doubleValue = OPTIONAL_RANDOM_VALUE(random.double_);\n\n    object.stringViewValue = OPTIONAL_RANDOM_VALUE((WCDB::StringView) random.string.UTF8String);\n    object.stdStringValue = OPTIONAL_RANDOM_VALUE((std::string) random.string.UTF8String);\n    object.constCharpValue = OPTIONAL_RANDOM_VALUE(object.stdStringValue->data());\n    object.charpValue = OPTIONAL_RANDOM_VALUE(const_cast<char*>(object.stdStringValue->data()));\n    object.unsafeStringViewValue = object.stringViewValue;\n\n    NSData* data = random.data;\n    const unsigned char* buffer = (const unsigned char*) data.bytes;\n    object.blobValue = std::make_optional<std::vector<unsigned char>>();\n    object.blobValue->assign(buffer, buffer + data.length);\n    data = random.data;\n    buffer = (const unsigned char*) data.bytes;\n    object.dataValue = OPTIONAL_RANDOM_VALUE(WCDB::Data(buffer, data.length));\n    object.unsafeDataValue = object.dataValue;\n\n    return object;\n}\n\nbool CPPSTDOptionalAllTypesObject::operator==(const CPPSTDOptionalAllTypesObject& other)\n{\n    bool equal = enumValue == other.enumValue\n                 && enumClassValue == other.enumClassValue\n                 && literalEnumValue == other.literalEnumValue\n                 && trueOrFalseValue == other.trueOrFalseValue\n                 && charValue == other.charValue\n                 && unsignedCharValue == other.unsignedCharValue\n                 && shortValue == other.shortValue\n                 && unsignedShortValue == other.unsignedShortValue\n                 && intValue == other.intValue\n                 && unsignedIntValue == other.unsignedIntValue\n                 && int32Value == other.int32Value\n                 && int64Value == other.int64Value\n                 && uint32Value == other.uint32Value\n                 && uint64Value == other.uint64Value\n                 && floatValue == other.floatValue\n                 && doubleValue == other.doubleValue\n                 && stringViewValue == other.stringViewValue\n                 && unsafeStringViewValue == other.unsafeStringViewValue\n                 && unsafeStringViewValue == other.unsafeStringViewValue\n                 && stdStringValue == other.stdStringValue\n                 && blobValue == other.blobValue\n                 && dataValue == other.dataValue\n                 && unsafeDataValue == other.unsafeDataValue;\n    if (!equal) {\n        return equal;\n    }\n#define CheckNullEquelOrReturn(value)                                                                                       \\\n    if ((value != std::nullopt && other.value == std::nullopt) || (value == std::nullopt && other.value != std::nullopt)) { \\\n        return false;                                                                                                       \\\n    }\n    CheckNullEquelOrReturn(constCharpValue);\n    if (constCharpValue != other.constCharpValue && strcmp(*constCharpValue, *other.constCharpValue) != 0) {\n        return false;\n    }\n    CheckNullEquelOrReturn(charpValue);\n    if (charpValue != other.charpValue && strcmp(*charpValue, *other.charpValue) != 0) {\n        return false;\n    }\n    return true;\n}\n\nvoid CPPSTDOptionalAllTypesObject::copyFrom(const CPPSTDOptionalAllTypesObject& other)\n{\n    type = other.type;\n    enumValue = other.enumValue;\n    enumClassValue = other.enumClassValue;\n    literalEnumValue = other.literalEnumValue;\n    trueOrFalseValue = other.trueOrFalseValue;\n    charValue = other.charValue;\n    unsignedCharValue = other.unsignedCharValue;\n    shortValue = other.shortValue;\n    unsignedShortValue = other.unsignedShortValue;\n    intValue = other.intValue;\n    unsignedIntValue = other.unsignedIntValue;\n    int32Value = other.int32Value;\n    int64Value = other.int64Value;\n    uint32Value = other.uint32Value;\n    uint64Value = other.uint64Value;\n    floatValue = other.floatValue;\n    doubleValue = other.doubleValue;\n    constCharpValue = other.constCharpValue;\n    charpValue = other.charpValue;\n    stdStringValue = other.stdStringValue;\n    unsafeStringViewValue = other.unsafeStringViewValue;\n    stringViewValue = other.stringViewValue;\n    blobValue = other.blobValue;\n    unsafeDataValue = other.unsafeDataValue;\n    dataValue = other.dataValue;\n}\n\nCPPSTDOptionalAllTypesObject& CPPSTDOptionalAllTypesObject::operator=(const CPPSTDOptionalAllTypesObject& other)\n{\n    copyFrom(other);\n    return *this;\n}\n\nCPPSTDOptionalAllTypesObject::CPPSTDOptionalAllTypesObject(const CPPSTDOptionalAllTypesObject& other)\n{\n    copyFrom(other);\n}\n\nCPPSTDOptionalAllTypesObject::CPPSTDOptionalAllTypesObject(CPPSTDOptionalAllTypesObject&& other)\n{\n    copyFrom(other);\n}\n\nCPPSTDOptionalAllTypesObject::CPPSTDOptionalAllTypesObject() = default;\nCPPSTDOptionalAllTypesObject::~CPPSTDOptionalAllTypesObject() = default;\n\n#endif\n"
  },
  {
    "path": "src/cpp/tests/orm/alltypes/CPPSharedPtrAllTypesObject.h",
    "content": "//\n// Created by qiuwenchen on 2023/10/31.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"CPPAllTypesObject.h\"\n\nclass CPPSharedPtrAllTypesObject {\npublic:\n    WCDB::StringView type;\n\n    // Enum\n    std::shared_ptr<EnumType> enumValue;\n    std::shared_ptr<EnumClassType> enumClassValue;\n    std::shared_ptr<LiteralEnum> literalEnumValue;\n\n    // Bool\n    std::shared_ptr<bool> trueOrFalseValue;\n\n    // Integer\n    std::shared_ptr<char> charValue;\n    std::shared_ptr<unsigned char> unsignedCharValue;\n    std::shared_ptr<short> shortValue;\n    std::shared_ptr<unsigned short> unsignedShortValue;\n    std::shared_ptr<int> intValue;\n    std::shared_ptr<unsigned int> unsignedIntValue;\n    std::shared_ptr<int32_t> int32Value;\n    std::shared_ptr<int64_t> int64Value;\n    std::shared_ptr<uint32_t> uint32Value;\n    std::shared_ptr<uint64_t> uint64Value;\n\n    // Float\n    std::shared_ptr<float> floatValue;\n    std::shared_ptr<double> doubleValue;\n\n    // String\n    std::shared_ptr<const char*> constCharpValue;\n    std::shared_ptr<char*> charpValue;\n    std::shared_ptr<std::string> stdStringValue;\n    std::shared_ptr<WCDB::UnsafeStringView> unsafeStringViewValue;\n    std::shared_ptr<WCDB::StringView> stringViewValue;\n\n    // BLOB\n    std::shared_ptr<std::vector<unsigned char>> blobValue;\n    std::shared_ptr<WCDB::UnsafeData> unsafeDataValue;\n    std::shared_ptr<WCDB::Data> dataValue;\n\n    WCDB_CPP_ORM_DECLARATION(CPPSharedPtrAllTypesObject)\n\nprivate:\n    void copyFrom(const CPPSharedPtrAllTypesObject& other);\n\npublic:\n    static CPPSharedPtrAllTypesObject maxObject();\n    static CPPSharedPtrAllTypesObject minObject();\n    static CPPSharedPtrAllTypesObject emptyObject();\n    static CPPSharedPtrAllTypesObject randomObject();\n\n    bool operator==(const CPPSharedPtrAllTypesObject& other);\n    CPPSharedPtrAllTypesObject& operator=(const CPPSharedPtrAllTypesObject& other);\n    CPPSharedPtrAllTypesObject(const CPPSharedPtrAllTypesObject& other);\n    CPPSharedPtrAllTypesObject(CPPSharedPtrAllTypesObject&& other);\n    CPPSharedPtrAllTypesObject();\n    ~CPPSharedPtrAllTypesObject();\n};\n"
  },
  {
    "path": "src/cpp/tests/orm/alltypes/CPPSharedPtrAllTypesObject.mm",
    "content": "//\n// Created by qiuwenchen on 2023/10/31.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"CPPSharedPtrAllTypesObject.h\"\n#import <Foundation/Foundation.h>\n\n#import \"Random.h\"\n\nWCDB_CPP_ORM_IMPLEMENTATION_BEGIN(CPPSharedPtrAllTypesObject)\n\nWCDB_CPP_SYNTHESIZE(type)\n\nWCDB_CPP_SYNTHESIZE(enumValue)\nWCDB_CPP_SYNTHESIZE(enumClassValue)\nWCDB_CPP_SYNTHESIZE(literalEnumValue)\n\nWCDB_CPP_SYNTHESIZE(trueOrFalseValue)\n\nWCDB_CPP_SYNTHESIZE(charValue)\nWCDB_CPP_SYNTHESIZE(unsignedCharValue)\nWCDB_CPP_SYNTHESIZE(shortValue)\nWCDB_CPP_SYNTHESIZE(unsignedShortValue)\nWCDB_CPP_SYNTHESIZE(intValue)\nWCDB_CPP_SYNTHESIZE(unsignedIntValue)\nWCDB_CPP_SYNTHESIZE(int32Value)\nWCDB_CPP_SYNTHESIZE(int64Value)\nWCDB_CPP_SYNTHESIZE(uint32Value)\nWCDB_CPP_SYNTHESIZE(uint64Value)\n\nWCDB_CPP_SYNTHESIZE(floatValue)\nWCDB_CPP_SYNTHESIZE(doubleValue)\n\nWCDB_CPP_SYNTHESIZE(constCharpValue)\nWCDB_CPP_SYNTHESIZE(charpValue)\nWCDB_CPP_SYNTHESIZE(stdStringValue)\nWCDB_CPP_SYNTHESIZE(unsafeStringViewValue)\nWCDB_CPP_SYNTHESIZE(stringViewValue)\n\nWCDB_CPP_SYNTHESIZE(blobValue)\nWCDB_CPP_SYNTHESIZE(unsafeDataValue)\nWCDB_CPP_SYNTHESIZE(dataValue)\n\nWCDB_CPP_ORM_IMPLEMENTATION_END\n\nCPPSharedPtrAllTypesObject CPPSharedPtrAllTypesObject::maxObject()\n{\n    CPPSharedPtrAllTypesObject object;\n    object.type = \"max\";\n\n    object.enumValue = std::make_shared<EnumType>(EnumType::Max);\n    object.enumClassValue = std::make_shared<EnumClassType>(EnumClassType::Max);\n    object.literalEnumValue = std::make_shared<LiteralEnum>(LiteralEnum::EnumMax);\n\n#define ASSIGN_WITH_TYPED_MAX_VALUE(field, type) \\\n    object.field = std::make_shared<typename type::element_type>(std::numeric_limits<typename type::element_type>::max())\n#define ASSIGN_WITH_MAX_VALUE(field) \\\n    ASSIGN_WITH_TYPED_MAX_VALUE(field, decltype(object.field))\n\n    ASSIGN_WITH_MAX_VALUE(trueOrFalseValue);\n\n    ASSIGN_WITH_MAX_VALUE(charValue);\n    ASSIGN_WITH_MAX_VALUE(unsignedCharValue);\n    ASSIGN_WITH_MAX_VALUE(shortValue);\n    ASSIGN_WITH_MAX_VALUE(unsignedShortValue);\n    ASSIGN_WITH_MAX_VALUE(intValue);\n    ASSIGN_WITH_MAX_VALUE(unsignedIntValue);\n    ASSIGN_WITH_MAX_VALUE(int32Value);\n    ASSIGN_WITH_MAX_VALUE(int64Value);\n    ASSIGN_WITH_MAX_VALUE(uint32Value);\n    ASSIGN_WITH_MAX_VALUE(uint64Value);\n\n    ASSIGN_WITH_MAX_VALUE(floatValue);\n    ASSIGN_WITH_MAX_VALUE(doubleValue);\n\n    return object;\n}\n\nCPPSharedPtrAllTypesObject CPPSharedPtrAllTypesObject::minObject()\n{\n    CPPSharedPtrAllTypesObject object;\n    object.type = \"min\";\n\n    object.enumValue = std::make_shared<EnumType>(EnumType::Min);\n    object.enumClassValue = std::make_shared<EnumClassType>(EnumClassType::Min);\n    object.literalEnumValue = std::make_shared<LiteralEnum>(LiteralEnum::EnumMin);\n\n#define ASSIGN_WITH_TYPED_MIN_VALUE(field, type) \\\n    object.field = std::make_shared<typename type::element_type>(std::numeric_limits<typename type::element_type>::min())\n#define ASSIGN_WITH_MIN_VALUE(field) ASSIGN_WITH_TYPED_MIN_VALUE(field, decltype(object.field))\n\n    ASSIGN_WITH_MIN_VALUE(trueOrFalseValue);\n\n    ASSIGN_WITH_MIN_VALUE(charValue);\n    ASSIGN_WITH_MIN_VALUE(unsignedCharValue);\n    ASSIGN_WITH_MIN_VALUE(shortValue);\n    ASSIGN_WITH_MIN_VALUE(unsignedShortValue);\n    ASSIGN_WITH_MIN_VALUE(intValue);\n    ASSIGN_WITH_MIN_VALUE(unsignedIntValue);\n    ASSIGN_WITH_MIN_VALUE(int32Value);\n    ASSIGN_WITH_MIN_VALUE(int64Value);\n    ASSIGN_WITH_MIN_VALUE(uint32Value);\n    ASSIGN_WITH_MIN_VALUE(uint64Value);\n\n    ASSIGN_WITH_MIN_VALUE(floatValue);\n    ASSIGN_WITH_MIN_VALUE(doubleValue);\n\n    return object;\n}\n\nCPPSharedPtrAllTypesObject CPPSharedPtrAllTypesObject::emptyObject()\n{\n    CPPSharedPtrAllTypesObject object;\n    object.type = \"empty\";\n    return object;\n}\n\nCPPSharedPtrAllTypesObject CPPSharedPtrAllTypesObject::randomObject()\n{\n    CPPSharedPtrAllTypesObject object;\n    object.type = \"random\";\n\n    object.enumValue = std::make_shared<EnumType>(EnumType::Zero);\n    object.enumClassValue = std::make_shared<EnumClassType>(EnumClassType::Zero);\n    object.literalEnumValue = std::make_shared<LiteralEnum>(LiteralEnum::EnumZero);\n\n    Random* random = [Random shared];\n\n#define SHARED_RANDOM_VALUE(value) std::make_shared<decltype(value)>(value)\n\n    object.trueOrFalseValue = SHARED_RANDOM_VALUE((bool) random.boolean);\n\n    object.charValue = SHARED_RANDOM_VALUE((char) random.int8);\n    object.unsignedCharValue = SHARED_RANDOM_VALUE(random.uint8);\n    object.shortValue = SHARED_RANDOM_VALUE(random.int16);\n    object.unsignedShortValue = SHARED_RANDOM_VALUE(random.uint16);\n    object.intValue = SHARED_RANDOM_VALUE(random.int32);\n    object.unsignedIntValue = SHARED_RANDOM_VALUE(random.uint32);\n    object.int32Value = SHARED_RANDOM_VALUE(random.int32);\n    object.int64Value = SHARED_RANDOM_VALUE(random.int64);\n    object.uint32Value = SHARED_RANDOM_VALUE(random.uint32);\n    object.uint64Value = SHARED_RANDOM_VALUE(random.uint64);\n\n    object.floatValue = SHARED_RANDOM_VALUE(random.float_);\n    object.doubleValue = SHARED_RANDOM_VALUE(random.double_);\n\n    object.stringViewValue = SHARED_RANDOM_VALUE((WCDB::StringView) random.string.UTF8String);\n    object.stdStringValue = SHARED_RANDOM_VALUE((std::string) random.string.UTF8String);\n    object.constCharpValue = SHARED_RANDOM_VALUE((const char*) object.stdStringValue->data());\n    object.charpValue = SHARED_RANDOM_VALUE(const_cast<char*>(object.stdStringValue->data()));\n    object.unsafeStringViewValue = object.stringViewValue;\n\n    NSData* data = random.data;\n    const unsigned char* buffer = (const unsigned char*) data.bytes;\n    object.blobValue = std::make_shared<std::vector<unsigned char>>();\n    object.blobValue->assign(buffer, buffer + data.length);\n    data = random.data;\n    buffer = (const unsigned char*) data.bytes;\n    object.dataValue = SHARED_RANDOM_VALUE(WCDB::Data(buffer, data.length));\n    object.unsafeDataValue = object.dataValue;\n\n    return object;\n}\n\nbool CPPSharedPtrAllTypesObject::operator==(const CPPSharedPtrAllTypesObject& other)\n{\n#define CheckLiteralEquelOrReturn(value)                                                                \\\n    if ((value != nullptr && other.value == nullptr) || (value == nullptr && other.value != nullptr)) { \\\n        return false;                                                                                   \\\n    }                                                                                                   \\\n    if (value != other.value && *value != *other.value) {                                               \\\n        return false;                                                                                   \\\n    }\n    CheckLiteralEquelOrReturn(enumValue);\n    CheckLiteralEquelOrReturn(enumClassValue);\n    CheckLiteralEquelOrReturn(literalEnumValue);\n    CheckLiteralEquelOrReturn(trueOrFalseValue);\n    CheckLiteralEquelOrReturn(charValue);\n    CheckLiteralEquelOrReturn(unsignedCharValue);\n    CheckLiteralEquelOrReturn(shortValue);\n    CheckLiteralEquelOrReturn(unsignedShortValue);\n    CheckLiteralEquelOrReturn(intValue);\n    CheckLiteralEquelOrReturn(unsignedIntValue);\n    CheckLiteralEquelOrReturn(int32Value);\n    CheckLiteralEquelOrReturn(int64Value);\n    CheckLiteralEquelOrReturn(uint32Value);\n    CheckLiteralEquelOrReturn(uint64Value);\n    CheckLiteralEquelOrReturn(floatValue);\n    CheckLiteralEquelOrReturn(doubleValue);\n\n#define CheckNullEquelOrReturn(value)                                                                   \\\n    if ((value != nullptr && other.value == nullptr) || (value == nullptr && other.value != nullptr)) { \\\n        return false;                                                                                   \\\n    }\n\n#define CheckObjectEqualOrReturn(value)                   \\\n    if (value != other.value && *value != *other.value) { \\\n        return false;                                     \\\n    }\n\n    CheckNullEquelOrReturn(stringViewValue);\n    CheckObjectEqualOrReturn(stringViewValue);\n\n    CheckNullEquelOrReturn(unsafeStringViewValue);\n    CheckObjectEqualOrReturn(unsafeStringViewValue);\n\n    CheckNullEquelOrReturn(constCharpValue);\n    if (constCharpValue != other.constCharpValue && strcmp(*constCharpValue, *other.constCharpValue) != 0) {\n        return false;\n    }\n    CheckNullEquelOrReturn(charpValue);\n    if (charpValue != other.charpValue && strcmp(*charpValue, *other.charpValue) != 0) {\n        return false;\n    }\n\n    CheckNullEquelOrReturn(stdStringValue);\n    CheckObjectEqualOrReturn(stdStringValue);\n\n    CheckNullEquelOrReturn(blobValue);\n    CheckObjectEqualOrReturn(blobValue);\n\n    CheckNullEquelOrReturn(dataValue);\n    CheckObjectEqualOrReturn(dataValue);\n\n    CheckNullEquelOrReturn(unsafeDataValue);\n    CheckObjectEqualOrReturn(unsafeDataValue);\n    return true;\n}\n\nvoid CPPSharedPtrAllTypesObject::copyFrom(const CPPSharedPtrAllTypesObject& other)\n{\n    type = other.type;\n    enumValue = other.enumValue;\n    enumClassValue = other.enumClassValue;\n    literalEnumValue = other.literalEnumValue;\n    trueOrFalseValue = other.trueOrFalseValue;\n    charValue = other.charValue;\n    unsignedCharValue = other.unsignedCharValue;\n    shortValue = other.shortValue;\n    unsignedShortValue = other.unsignedShortValue;\n    intValue = other.intValue;\n    unsignedIntValue = other.unsignedIntValue;\n    int32Value = other.int32Value;\n    int64Value = other.int64Value;\n    uint32Value = other.uint32Value;\n    uint64Value = other.uint64Value;\n    floatValue = other.floatValue;\n    doubleValue = other.doubleValue;\n    constCharpValue = other.constCharpValue;\n    charpValue = other.charpValue;\n    stdStringValue = other.stdStringValue;\n    unsafeStringViewValue = other.unsafeStringViewValue;\n    stringViewValue = other.stringViewValue;\n    blobValue = other.blobValue;\n    unsafeDataValue = other.unsafeDataValue;\n    dataValue = other.dataValue;\n}\n\nCPPSharedPtrAllTypesObject& CPPSharedPtrAllTypesObject::operator=(const CPPSharedPtrAllTypesObject& other)\n{\n    copyFrom(other);\n    return *this;\n}\n\nCPPSharedPtrAllTypesObject::CPPSharedPtrAllTypesObject(const CPPSharedPtrAllTypesObject& other)\n{\n    copyFrom(other);\n}\n\nCPPSharedPtrAllTypesObject::CPPSharedPtrAllTypesObject(CPPSharedPtrAllTypesObject&& other)\n{\n    copyFrom(other);\n}\n\nCPPSharedPtrAllTypesObject::CPPSharedPtrAllTypesObject() = default;\nCPPSharedPtrAllTypesObject::~CPPSharedPtrAllTypesObject() = default;\n"
  },
  {
    "path": "src/cpp/tests/orm/alltypes/CPPWCDBOptionalAllTypesObject.h",
    "content": "//\n// Created by qiuwenchen on 2023/11/1.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"CPPAllTypesObject.h\"\n\nclass CPPWCDBOptionalAllTypesObject {\npublic:\n    WCDB::StringView type;\n\n    // Enum\n    WCDB::Optional<EnumType> enumValue;\n    WCDB::Optional<EnumClassType> enumClassValue;\n    WCDB::Optional<LiteralEnum> literalEnumValue;\n\n    // Bool\n    WCDB::Optional<bool> trueOrFalseValue;\n\n    // Integer\n    WCDB::Optional<char> charValue;\n    WCDB::Optional<unsigned char> unsignedCharValue;\n    WCDB::Optional<short> shortValue;\n    WCDB::Optional<unsigned short> unsignedShortValue;\n    WCDB::Optional<int> intValue;\n    WCDB::Optional<unsigned int> unsignedIntValue;\n    WCDB::Optional<int32_t> int32Value;\n    WCDB::Optional<int64_t> int64Value;\n    WCDB::Optional<uint32_t> uint32Value;\n    WCDB::Optional<uint64_t> uint64Value;\n\n    // Float\n    WCDB::Optional<float> floatValue;\n    WCDB::Optional<double> doubleValue;\n\n    // String\n    WCDB::Optional<const char*> constCharpValue;\n    WCDB::Optional<char*> charpValue;\n    WCDB::Optional<std::string> stdStringValue;\n    WCDB::Optional<WCDB::UnsafeStringView> unsafeStringViewValue;\n    WCDB::Optional<WCDB::StringView> stringViewValue;\n\n    // BLOB\n    WCDB::Optional<std::vector<unsigned char>> blobValue;\n    WCDB::Optional<WCDB::UnsafeData> unsafeDataValue;\n    WCDB::Optional<WCDB::Data> dataValue;\n\n    WCDB_CPP_ORM_DECLARATION(CPPWCDBOptionalAllTypesObject)\n\nprivate:\n    void copyFrom(const CPPWCDBOptionalAllTypesObject& other);\n\npublic:\n    static CPPWCDBOptionalAllTypesObject maxObject();\n    static CPPWCDBOptionalAllTypesObject minObject();\n    static CPPWCDBOptionalAllTypesObject emptyObject();\n    static CPPWCDBOptionalAllTypesObject randomObject();\n\n    bool operator==(const CPPWCDBOptionalAllTypesObject& other);\n    CPPWCDBOptionalAllTypesObject& operator=(const CPPWCDBOptionalAllTypesObject& other);\n    CPPWCDBOptionalAllTypesObject(const CPPWCDBOptionalAllTypesObject& other);\n    CPPWCDBOptionalAllTypesObject(CPPWCDBOptionalAllTypesObject&& other);\n    CPPWCDBOptionalAllTypesObject();\n    ~CPPWCDBOptionalAllTypesObject();\n};\n"
  },
  {
    "path": "src/cpp/tests/orm/alltypes/CPPWCDBOptionalAllTypesObject.mm",
    "content": "//\n// Created by qiuwenchen on 2023/11/1.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"CPPWCDBOptionalAllTypesObject.h\"\n#import <Foundation/Foundation.h>\n\n#import \"Random.h\"\n\nWCDB_CPP_ORM_IMPLEMENTATION_BEGIN(CPPWCDBOptionalAllTypesObject)\n\nWCDB_CPP_SYNTHESIZE(type)\n\nWCDB_CPP_SYNTHESIZE(enumValue)\nWCDB_CPP_SYNTHESIZE(enumClassValue)\nWCDB_CPP_SYNTHESIZE(literalEnumValue)\n\nWCDB_CPP_SYNTHESIZE(trueOrFalseValue)\n\nWCDB_CPP_SYNTHESIZE(charValue)\nWCDB_CPP_SYNTHESIZE(unsignedCharValue)\nWCDB_CPP_SYNTHESIZE(shortValue)\nWCDB_CPP_SYNTHESIZE(unsignedShortValue)\nWCDB_CPP_SYNTHESIZE(intValue)\nWCDB_CPP_SYNTHESIZE(unsignedIntValue)\nWCDB_CPP_SYNTHESIZE(int32Value)\nWCDB_CPP_SYNTHESIZE(int64Value)\nWCDB_CPP_SYNTHESIZE(uint32Value)\nWCDB_CPP_SYNTHESIZE(uint64Value)\n\nWCDB_CPP_SYNTHESIZE(floatValue)\nWCDB_CPP_SYNTHESIZE(doubleValue)\n\nWCDB_CPP_SYNTHESIZE(constCharpValue)\nWCDB_CPP_SYNTHESIZE(charpValue)\nWCDB_CPP_SYNTHESIZE(stdStringValue)\nWCDB_CPP_SYNTHESIZE(unsafeStringViewValue)\nWCDB_CPP_SYNTHESIZE(stringViewValue)\n\nWCDB_CPP_SYNTHESIZE(blobValue)\nWCDB_CPP_SYNTHESIZE(unsafeDataValue)\nWCDB_CPP_SYNTHESIZE(dataValue)\n\nWCDB_CPP_ORM_IMPLEMENTATION_END\n\nCPPWCDBOptionalAllTypesObject CPPWCDBOptionalAllTypesObject::maxObject()\n{\n    CPPWCDBOptionalAllTypesObject object;\n    object.type = \"max\";\n\n    object.enumValue = EnumType::Max;\n    object.enumClassValue = EnumClassType::Max;\n    object.literalEnumValue = LiteralEnum::EnumMax;\n\n#define ASSIGN_WITH_TYPED_MAX_VALUE(field, type) \\\n    object.field = WCDB::Optional<typename type::ValueType>(std::numeric_limits<typename type::ValueType>::max())\n#define ASSIGN_WITH_MAX_VALUE(field) \\\n    ASSIGN_WITH_TYPED_MAX_VALUE(field, decltype(object.field))\n\n    ASSIGN_WITH_MAX_VALUE(trueOrFalseValue);\n\n    ASSIGN_WITH_MAX_VALUE(charValue);\n    ASSIGN_WITH_MAX_VALUE(unsignedCharValue);\n    ASSIGN_WITH_MAX_VALUE(shortValue);\n    ASSIGN_WITH_MAX_VALUE(unsignedShortValue);\n    ASSIGN_WITH_MAX_VALUE(intValue);\n    ASSIGN_WITH_MAX_VALUE(unsignedIntValue);\n    ASSIGN_WITH_MAX_VALUE(int32Value);\n    ASSIGN_WITH_MAX_VALUE(int64Value);\n    ASSIGN_WITH_MAX_VALUE(uint32Value);\n    ASSIGN_WITH_MAX_VALUE(uint64Value);\n\n    ASSIGN_WITH_MAX_VALUE(floatValue);\n    ASSIGN_WITH_MAX_VALUE(doubleValue);\n\n    return object;\n}\n\nCPPWCDBOptionalAllTypesObject CPPWCDBOptionalAllTypesObject::minObject()\n{\n    CPPWCDBOptionalAllTypesObject object;\n    object.type = \"min\";\n\n    object.enumValue = EnumType::Min;\n    object.enumClassValue = EnumClassType::Min;\n    object.literalEnumValue = LiteralEnum::EnumMin;\n\n#define ASSIGN_WITH_TYPED_MIN_VALUE(field, type) \\\n    object.field = WCDB::Optional<typename type::ValueType>(std::numeric_limits<typename type::ValueType>::min())\n#define ASSIGN_WITH_MIN_VALUE(field) ASSIGN_WITH_TYPED_MIN_VALUE(field, decltype(object.field))\n\n    ASSIGN_WITH_MIN_VALUE(trueOrFalseValue);\n\n    ASSIGN_WITH_MIN_VALUE(charValue);\n    ASSIGN_WITH_MIN_VALUE(unsignedCharValue);\n    ASSIGN_WITH_MIN_VALUE(shortValue);\n    ASSIGN_WITH_MIN_VALUE(unsignedShortValue);\n    ASSIGN_WITH_MIN_VALUE(intValue);\n    ASSIGN_WITH_MIN_VALUE(unsignedIntValue);\n    ASSIGN_WITH_MIN_VALUE(int32Value);\n    ASSIGN_WITH_MIN_VALUE(int64Value);\n    ASSIGN_WITH_MIN_VALUE(uint32Value);\n    ASSIGN_WITH_MIN_VALUE(uint64Value);\n\n    ASSIGN_WITH_MIN_VALUE(floatValue);\n    ASSIGN_WITH_MIN_VALUE(doubleValue);\n\n    return object;\n}\n\nCPPWCDBOptionalAllTypesObject CPPWCDBOptionalAllTypesObject::emptyObject()\n{\n    CPPWCDBOptionalAllTypesObject object;\n    object.type = \"empty\";\n    return object;\n}\n\nCPPWCDBOptionalAllTypesObject CPPWCDBOptionalAllTypesObject::randomObject()\n{\n    CPPWCDBOptionalAllTypesObject object;\n    object.type = \"random\";\n\n    object.enumValue = EnumType::Zero;\n    object.enumClassValue = EnumClassType::Zero;\n    object.literalEnumValue = LiteralEnum::EnumZero;\n\n    Random* random = [Random shared];\n\n#define OPTIONAL_RANDOM_VALUE(value) WCDB::Optional<decltype(value)>(value)\n\n    object.trueOrFalseValue = OPTIONAL_RANDOM_VALUE((bool) random.boolean);\n\n    object.charValue = OPTIONAL_RANDOM_VALUE((char) random.int8);\n    object.unsignedCharValue = OPTIONAL_RANDOM_VALUE(random.uint8);\n    object.shortValue = OPTIONAL_RANDOM_VALUE(random.int16);\n    object.unsignedShortValue = OPTIONAL_RANDOM_VALUE(random.uint16);\n    object.intValue = OPTIONAL_RANDOM_VALUE(random.int32);\n    object.unsignedIntValue = OPTIONAL_RANDOM_VALUE(random.uint32);\n    object.int32Value = OPTIONAL_RANDOM_VALUE(random.int32);\n    object.int64Value = OPTIONAL_RANDOM_VALUE(random.int64);\n    object.uint32Value = OPTIONAL_RANDOM_VALUE(random.uint32);\n    object.uint64Value = OPTIONAL_RANDOM_VALUE(random.uint64);\n\n    object.floatValue = OPTIONAL_RANDOM_VALUE(random.float_);\n    object.doubleValue = OPTIONAL_RANDOM_VALUE(random.double_);\n\n    object.stringViewValue = OPTIONAL_RANDOM_VALUE((WCDB::StringView) random.string.UTF8String);\n    object.stdStringValue = OPTIONAL_RANDOM_VALUE((std::string) random.string.UTF8String);\n    object.constCharpValue = OPTIONAL_RANDOM_VALUE(object.stdStringValue->data());\n    object.charpValue = OPTIONAL_RANDOM_VALUE(const_cast<char*>(object.stdStringValue->data()));\n    object.unsafeStringViewValue = object.stringViewValue;\n\n    NSData* data = random.data;\n    const unsigned char* buffer = (const unsigned char*) data.bytes;\n    object.blobValue = WCDB::Optional<std::vector<unsigned char>>();\n    object.blobValue->assign(buffer, buffer + data.length);\n    data = random.data;\n    buffer = (const unsigned char*) data.bytes;\n    object.dataValue = OPTIONAL_RANDOM_VALUE(WCDB::Data(buffer, data.length));\n    object.unsafeDataValue = object.dataValue;\n\n    return object;\n}\n\nbool CPPWCDBOptionalAllTypesObject::operator==(const CPPWCDBOptionalAllTypesObject& other)\n{\n    bool equal = enumValue == other.enumValue\n                 && enumClassValue == other.enumClassValue\n                 && literalEnumValue == other.literalEnumValue\n                 && trueOrFalseValue == other.trueOrFalseValue\n                 && charValue == other.charValue\n                 && unsignedCharValue == other.unsignedCharValue\n                 && shortValue == other.shortValue\n                 && unsignedShortValue == other.unsignedShortValue\n                 && intValue == other.intValue\n                 && unsignedIntValue == other.unsignedIntValue\n                 && int32Value == other.int32Value\n                 && int64Value == other.int64Value\n                 && uint32Value == other.uint32Value\n                 && uint64Value == other.uint64Value\n                 && floatValue == other.floatValue\n                 && doubleValue == other.doubleValue\n                 && stringViewValue == other.stringViewValue\n                 && unsafeStringViewValue == other.unsafeStringViewValue\n                 && unsafeStringViewValue == other.unsafeStringViewValue\n                 && stdStringValue == other.stdStringValue\n                 && blobValue == other.blobValue\n                 && dataValue == other.dataValue\n                 && unsafeDataValue == other.unsafeDataValue;\n    if (!equal) {\n        return equal;\n    }\n#define CheckNullEquelOrReturn(value)                                                                                           \\\n    if ((value != WCDB::NullOpt && other.value == WCDB::NullOpt) || (value == WCDB::NullOpt && other.value != WCDB::NullOpt)) { \\\n        return false;                                                                                                           \\\n    }\n    CheckNullEquelOrReturn(constCharpValue);\n    if (constCharpValue != other.constCharpValue && strcmp(*constCharpValue, *other.constCharpValue) != 0) {\n        return false;\n    }\n    CheckNullEquelOrReturn(charpValue);\n    if (charpValue != other.charpValue && strcmp(*charpValue, *other.charpValue) != 0) {\n        return false;\n    }\n    return true;\n}\n\nvoid CPPWCDBOptionalAllTypesObject::copyFrom(const CPPWCDBOptionalAllTypesObject& other)\n{\n    type = other.type;\n    enumValue = other.enumValue;\n    enumClassValue = other.enumClassValue;\n    literalEnumValue = other.literalEnumValue;\n    trueOrFalseValue = other.trueOrFalseValue;\n    charValue = other.charValue;\n    unsignedCharValue = other.unsignedCharValue;\n    shortValue = other.shortValue;\n    unsignedShortValue = other.unsignedShortValue;\n    intValue = other.intValue;\n    unsignedIntValue = other.unsignedIntValue;\n    int32Value = other.int32Value;\n    int64Value = other.int64Value;\n    uint32Value = other.uint32Value;\n    uint64Value = other.uint64Value;\n    floatValue = other.floatValue;\n    doubleValue = other.doubleValue;\n    constCharpValue = other.constCharpValue;\n    charpValue = other.charpValue;\n    stdStringValue = other.stdStringValue;\n    unsafeStringViewValue = other.unsafeStringViewValue;\n    stringViewValue = other.stringViewValue;\n    blobValue = other.blobValue;\n    unsafeDataValue = other.unsafeDataValue;\n    dataValue = other.dataValue;\n}\n\nCPPWCDBOptionalAllTypesObject& CPPWCDBOptionalAllTypesObject::operator=(const CPPWCDBOptionalAllTypesObject& other)\n{\n    copyFrom(other);\n    return *this;\n}\n\nCPPWCDBOptionalAllTypesObject::CPPWCDBOptionalAllTypesObject(const CPPWCDBOptionalAllTypesObject& other)\n{\n    copyFrom(other);\n}\n\nCPPWCDBOptionalAllTypesObject::CPPWCDBOptionalAllTypesObject(CPPWCDBOptionalAllTypesObject&& other)\n{\n    copyFrom(other);\n}\n\nCPPWCDBOptionalAllTypesObject::CPPWCDBOptionalAllTypesObject() = default;\nCPPWCDBOptionalAllTypesObject::~CPPWCDBOptionalAllTypesObject() = default;\n"
  },
  {
    "path": "src/cpp/tests/orm/column_constraint/CPPColumnConstraintAutoIncrement.cpp",
    "content": "//\n// Created by qiuwenchen on 2022/9/7.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"CPPColumnConstraintAutoIncrement.hpp\"\n\nWCDB_CPP_ORM_IMPLEMENTATION_BEGIN(CPPColumnConstraintAutoIncrement)\nWCDB_CPP_SYNTHESIZE(value)\nWCDB_CPP_PRIMARY_AUTO_INCREMENT(value)\nWCDB_CPP_ORM_IMPLEMENTATION_END\n"
  },
  {
    "path": "src/cpp/tests/orm/column_constraint/CPPColumnConstraintAutoIncrement.hpp",
    "content": "//\n// Created by qiuwenchen on 2022/9/7.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#if TEST_WCDB_OBJC\n#import <WCDBOBjc/WCDBCpp.h>\n#elif TEST_WCDB_CPP\n#import <WCDBCpp/WCDBCpp.h>\n#else\n#import <WCDB/WCDBCpp.h>\n#endif\n\nclass CPPColumnConstraintAutoIncrement {\n    int value;\n    WCDB_CPP_ORM_DECLARATION(CPPColumnConstraintAutoIncrement)\n};\n"
  },
  {
    "path": "src/cpp/tests/orm/column_constraint/CPPColumnConstraintAutoIncrementAsc.cpp",
    "content": "//\n// Created by qiuwenchen on 2022/9/7.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"CPPColumnConstraintAutoIncrementAsc.hpp\"\n\nWCDB_CPP_ORM_IMPLEMENTATION_BEGIN(CPPColumnConstraintAutoIncrementAsc)\nWCDB_CPP_SYNTHESIZE(value)\nWCDB_CPP_PRIMARY_ASC_AUTO_INCREMENT(value)\nWCDB_CPP_ORM_IMPLEMENTATION_END\n"
  },
  {
    "path": "src/cpp/tests/orm/column_constraint/CPPColumnConstraintAutoIncrementAsc.hpp",
    "content": "//\n// Created by qiuwenchen on 2022/9/7.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#if TEST_WCDB_OBJC\n#import <WCDBOBjc/WCDBCpp.h>\n#elif TEST_WCDB_CPP\n#import <WCDBCpp/WCDBCpp.h>\n#else\n#import <WCDB/WCDBCpp.h>\n#endif\n\nclass CPPColumnConstraintAutoIncrementAsc {\n    int value;\n    WCDB_CPP_ORM_DECLARATION(CPPColumnConstraintAutoIncrementAsc)\n};\n"
  },
  {
    "path": "src/cpp/tests/orm/column_constraint/CPPColumnConstraintDefault.cpp",
    "content": "//\n// Created by qiuwenchen on 2022/9/7.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"CPPColumnConstraintDefault.hpp\"\n\nWCDB_CPP_ORM_IMPLEMENTATION_BEGIN(CPPColumnConstraintDefault)\nWCDB_CPP_SYNTHESIZE(value)\nWCDB_CPP_DEFAULT(value, 1.0)\nWCDB_CPP_ORM_IMPLEMENTATION_END\n"
  },
  {
    "path": "src/cpp/tests/orm/column_constraint/CPPColumnConstraintDefault.hpp",
    "content": "//\n// Created by qiuwenchen on 2022/9/7.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#if TEST_WCDB_OBJC\n#import <WCDBOBjc/WCDBCpp.h>\n#elif TEST_WCDB_CPP\n#import <WCDBCpp/WCDBCpp.h>\n#else\n#import <WCDB/WCDBCpp.h>\n#endif\n\nclass CPPColumnConstraintDefault {\n    int value;\n    WCDB_CPP_ORM_DECLARATION(CPPColumnConstraintDefault)\n};\n"
  },
  {
    "path": "src/cpp/tests/orm/column_constraint/CPPColumnConstraintEnablePrimaryAutoIncrement.cpp",
    "content": "//\n// Created by qiuwenchen on 2023/7/6.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"CPPColumnConstraintEnablePrimaryAutoIncrement.hpp\"\n\nWCDB_CPP_ORM_IMPLEMENTATION_BEGIN(CPPColumnConstraintEnablePrimaryAutoIncrement)\nWCDB_CPP_SYNTHESIZE(id)\nWCDB_CPP_PRIMARY_AUTO_INCREMENT(id)\nWCDB_CPP_PRIMARY_ENABLE_AUTOINCREMENT_FOR_EXISTING_TABLE\nWCDB_CPP_ORM_IMPLEMENTATION_END\n\nWCDB_CPP_ORM_IMPLEMENTATION_BEGIN(CPPColumnConstraintPrimaryNotAutoIncrement)\nWCDB_CPP_SYNTHESIZE(id)\nWCDB_CPP_PRIMARY(id)\nWCDB_CPP_ORM_IMPLEMENTATION_END\n"
  },
  {
    "path": "src/cpp/tests/orm/column_constraint/CPPColumnConstraintEnablePrimaryAutoIncrement.hpp",
    "content": "//\n// Created by qiuwenchen on 2023/7/6.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#if TEST_WCDB_OBJC\n#import <WCDBOBjc/WCDBCpp.h>\n#elif TEST_WCDB_CPP\n#import <WCDBCpp/WCDBCpp.h>\n#else\n#import <WCDB/WCDBCpp.h>\n#endif\n\nclass CPPColumnConstraintEnablePrimaryAutoIncrement {\npublic:\n    int id;\n    WCDB_CPP_ORM_DECLARATION(CPPColumnConstraintEnablePrimaryAutoIncrement)\n};\n\nclass CPPColumnConstraintPrimaryNotAutoIncrement {\npublic:\n    int id;\n    WCDB_CPP_ORM_DECLARATION(CPPColumnConstraintPrimaryNotAutoIncrement)\n};\n"
  },
  {
    "path": "src/cpp/tests/orm/column_constraint/CPPColumnConstraintPrimary.cpp",
    "content": "//\n// Created by qiuwenchen on 2022/9/7.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"CPPColumnConstraintPrimary.hpp\"\n\nWCDB_CPP_ORM_IMPLEMENTATION_BEGIN(CPPColumnConstraintPrimary)\nWCDB_CPP_SYNTHESIZE(value)\nWCDB_CPP_PRIMARY(value)\nWCDB_CPP_ORM_IMPLEMENTATION_END\n"
  },
  {
    "path": "src/cpp/tests/orm/column_constraint/CPPColumnConstraintPrimary.hpp",
    "content": "//\n// Created by qiuwenchen on 2022/9/7.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#if TEST_WCDB_OBJC\n#import <WCDBOBjc/WCDBCpp.h>\n#elif TEST_WCDB_CPP\n#import <WCDBCpp/WCDBCpp.h>\n#else\n#import <WCDB/WCDBCpp.h>\n#endif\n\nclass CPPColumnConstraintPrimary {\n    int value;\n    WCDB_CPP_ORM_DECLARATION(CPPColumnConstraintPrimary)\n};\n"
  },
  {
    "path": "src/cpp/tests/orm/column_constraint/CPPColumnConstraintPrimaryAsc.cpp",
    "content": "//\n// Created by qiuwenchen on 2022/9/7.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"CPPColumnConstraintPrimaryAsc.hpp\"\n\nWCDB_CPP_ORM_IMPLEMENTATION_BEGIN(CPPColumnConstraintPrimaryAsc)\nWCDB_CPP_SYNTHESIZE(value)\nWCDB_CPP_PRIMARY_ASC(value)\nWCDB_CPP_ORM_IMPLEMENTATION_END\n"
  },
  {
    "path": "src/cpp/tests/orm/column_constraint/CPPColumnConstraintPrimaryAsc.hpp",
    "content": "//\n// Created by qiuwenchen on 2022/9/7.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#if TEST_WCDB_OBJC\n#import <WCDBOBjc/WCDBCpp.h>\n#elif TEST_WCDB_CPP\n#import <WCDBCpp/WCDBCpp.h>\n#else\n#import <WCDB/WCDBCpp.h>\n#endif\n\nclass CPPColumnConstraintPrimaryAsc {\n    int value;\n    WCDB_CPP_ORM_DECLARATION(CPPColumnConstraintPrimaryAsc)\n};\n"
  },
  {
    "path": "src/cpp/tests/orm/column_constraint/CPPColumnConstraintPrimaryDesc.cpp",
    "content": "//\n// Created by qiuwenchen on 2022/9/7.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"CPPColumnConstraintPrimaryDesc.hpp\"\n\nWCDB_CPP_ORM_IMPLEMENTATION_BEGIN(CPPColumnConstraintPrimaryDesc)\nWCDB_CPP_SYNTHESIZE(value)\nWCDB_CPP_PRIMARY_DESC(value)\nWCDB_CPP_ORM_IMPLEMENTATION_END\n"
  },
  {
    "path": "src/cpp/tests/orm/column_constraint/CPPColumnConstraintPrimaryDesc.hpp",
    "content": "//\n// Created by qiuwenchen on 2022/9/7.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#if TEST_WCDB_OBJC\n#import <WCDBOBjc/WCDBCpp.h>\n#elif TEST_WCDB_CPP\n#import <WCDBCpp/WCDBCpp.h>\n#else\n#import <WCDB/WCDBCpp.h>\n#endif\n\nclass CPPColumnConstraintPrimaryDesc {\n    int value;\n    WCDB_CPP_ORM_DECLARATION(CPPColumnConstraintPrimaryDesc)\n};\n"
  },
  {
    "path": "src/cpp/tests/orm/column_constraint/CPPColumnConstraintUnique.cpp",
    "content": "//\n// Created by qiuwenchen on 2022/9/7.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"CPPColumnConstraintUnique.hpp\"\n\nWCDB_CPP_ORM_IMPLEMENTATION_BEGIN(CPPColumnConstraintUnique)\nWCDB_CPP_SYNTHESIZE(value)\nWCDB_CPP_UNIQUE(value)\nWCDB_CPP_ORM_IMPLEMENTATION_END\n"
  },
  {
    "path": "src/cpp/tests/orm/column_constraint/CPPColumnConstraintUnique.hpp",
    "content": "//\n// Created by qiuwenchen on 2022/9/7.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#if TEST_WCDB_OBJC\n#import <WCDBOBjc/WCDBCpp.h>\n#elif TEST_WCDB_CPP\n#import <WCDBCpp/WCDBCpp.h>\n#else\n#import <WCDB/WCDBCpp.h>\n#endif\n\nclass CPPColumnConstraintUnique {\n    int value;\n    WCDB_CPP_ORM_DECLARATION(CPPColumnConstraintUnique)\n};\n"
  },
  {
    "path": "src/cpp/tests/orm/field/CPPFieldObject.h",
    "content": "//\n// Created by qiuwenchen on 2022/9/5.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#if TEST_WCDB_OBJC\n#import <WCDBOBjc/WCDBCpp.h>\n#elif TEST_WCDB_CPP\n#import <WCDBCpp/WCDBCpp.h>\n#else\n#import <WCDB/WCDBCpp.h>\n#endif\n\nclass CPPFieldObject {\n    int field;\n    int fieldWithDifferentName;\n    WCDB_CPP_ORM_DECLARE_AND_START_IMPLEMENT(CPPFieldObject)\n    WCDB_CPP_SYNTHESIZE(field)\n    WCDB_CPP_SYNTHESIZE_COLUMN(fieldWithDifferentName, \"differentName\")\n    WCDB_CPP_ORM_IMPLEMENTATION_END\n};\n"
  },
  {
    "path": "src/cpp/tests/orm/field/CPPNewFieldObject.h",
    "content": "//\n// Created by qiuwenchen on 2022/12/4.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#if TEST_WCDB_OBJC\n#import <WCDBOBjc/WCDBCpp.h>\n#elif TEST_WCDB_CPP\n#import <WCDBCpp/WCDBCpp.h>\n#else\n#import <WCDB/WCDBCpp.h>\n#endif\n\nclass CPPNewFieldObject {\npublic:\n    int primaryValue;\n    int uniqueValue;\n    int insertValue;\n    int updateValue;\n    int selectValue;\n    int multiSelectValue;\n    int deleteValue;\n    int indexValue;\n    WCDB_CPP_ORM_DECLARE_AND_START_IMPLEMENT(CPPNewFieldObject)\n    WCDB_CPP_SYNTHESIZE(primaryValue)\n    WCDB_CPP_SYNTHESIZE(uniqueValue)\n    WCDB_CPP_SYNTHESIZE(insertValue)\n    WCDB_CPP_SYNTHESIZE(updateValue)\n    WCDB_CPP_SYNTHESIZE(selectValue)\n    WCDB_CPP_SYNTHESIZE(multiSelectValue)\n    WCDB_CPP_SYNTHESIZE(deleteValue)\n    WCDB_CPP_PRIMARY(primaryValue)\n    WCDB_CPP_UNIQUE(uniqueValue)\n    WCDB_CPP_ORM_IMPLEMENTATION_END\n};\n"
  },
  {
    "path": "src/cpp/tests/orm/index_object/CPPIndexObject.cpp",
    "content": "//\n// Created by qiuwenchen on 2022/9/7.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"CPPIndexObject.hpp\"\n\nWCDB_CPP_ORM_IMPLEMENTATION_BEGIN(CPPIndexObject)\n\nWCDB_CPP_SYNTHESIZE(index_)\nWCDB_CPP_SYNTHESIZE(indexAsc)\nWCDB_CPP_SYNTHESIZE(indexDesc)\nWCDB_CPP_SYNTHESIZE(uniqueIndex)\nWCDB_CPP_SYNTHESIZE(uniqueIndexAsc)\nWCDB_CPP_SYNTHESIZE(uniqueIndexDesc)\nWCDB_CPP_SYNTHESIZE(multiIndex)\nWCDB_CPP_SYNTHESIZE(multiIndexAsc)\nWCDB_CPP_SYNTHESIZE(multiIndexDesc)\n\nWCDB_CPP_INDEX(\"_index\", index_)\nWCDB_CPP_INDEX_ASC(\"_index_asc\", indexAsc)\nWCDB_CPP_INDEX_DESC(\"_index_desc\", indexDesc)\n\nWCDB_CPP_UNIQUE_INDEX(\"_unique_index\", uniqueIndex)\nWCDB_CPP_UNIQUE_INDEX_ASC(\"_unique_index_asc\", uniqueIndexAsc)\nWCDB_CPP_UNIQUE_INDEX_DESC(\"_unique_index_desc\", uniqueIndexDesc)\n\nWCDB_CPP_INDEX(\"_multi_index\", multiIndex)\nWCDB_CPP_INDEX_ASC(\"_multi_index\", multiIndexAsc)\nWCDB_CPP_INDEX_DESC(\"_multi_index\", multiIndexDesc)\n\nWCDB_CPP_ORM_IMPLEMENTATION_END\n"
  },
  {
    "path": "src/cpp/tests/orm/index_object/CPPIndexObject.hpp",
    "content": "//\n// Created by qiuwenchen on 2022/9/7.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include <WCDB/WCDBCpp.h>\n\nclass CPPIndexObject {\n    int index_;\n    int indexAsc;\n    int indexDesc;\n\n    int uniqueIndex;\n    int uniqueIndexAsc;\n    int uniqueIndexDesc;\n\n    int multiIndex;\n    int multiIndexAsc;\n    int multiIndexDesc;\n\n    WCDB_CPP_ORM_DECLARATION(CPPIndexObject)\n};\n"
  },
  {
    "path": "src/cpp/tests/orm/inherit/CPPInheritObject.cpp",
    "content": "//\n// Created by qiuwenchen on 2023/10/29.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"CPPInheritObject.hpp\"\n\nWCDB_CPP_ORM_IMPLEMENTATION_BEGIN(CPPInheritBase1);\nWCDB_CPP_SYNTHESIZE(value1)\nWCDB_CPP_SYNTHESIZE(value2)\nWCDB_CPP_PRIMARY(value1)\nWCDB_CPP_INDEX(\"_value2\", value2)\nWCDB_CPP_ORM_IMPLEMENTATION_END\n\nWCDB_CPP_ORM_IMPLEMENTATION_BEGIN(CPPInheritBase2)\nWCDB_CPP_INHERIT_ORM(CPPInheritBase1)\nWCDB_CPP_SYNTHESIZE(value3)\nWCDB_CPP_SYNTHESIZE(value4)\nWCDB_CPP_INDEX(\"_value3_value4\", value3)\nWCDB_CPP_INDEX(\"_value3_value4\", value4)\nWCDB_CPP_ORM_IMPLEMENTATION_END\n\nWCDB_CPP_ORM_IMPLEMENTATION_BEGIN(CPPInheritObject)\nWCDB_CPP_INHERIT_ORM(CPPInheritBase2)\nWCDB_CPP_SYNTHESIZE(value5)\nWCDB_CPP_UNIQUE(value5)\nWCDB_CPP_ORM_IMPLEMENTATION_END\n"
  },
  {
    "path": "src/cpp/tests/orm/inherit/CPPInheritObject.hpp",
    "content": "//\n// Created by qiuwenchen on 2023/10/29.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#if TEST_WCDB_OBJC\n#import <WCDBOBjc/WCDBCpp.h>\n#elif TEST_WCDB_CPP\n#import <WCDBCpp/WCDBCpp.h>\n#else\n#import <WCDB/WCDBCpp.h>\n#endif\n\nclass CPPInheritBase1 {\npublic:\n    int value1;\n    double value2;\n    WCDB_CPP_ORM_DECLARATION(CPPInheritBase1);\n};\n\nclass CPPInheritBase2 : public CPPInheritBase1 {\npublic:\n    long value3;\n    std::string value4;\n    WCDB_CPP_ORM_DECLARATION(CPPInheritBase2);\n};\n\nclass CPPInheritObject : public CPPInheritBase2 {\npublic:\n    WCDB::Data value5;\n    WCDB_CPP_ORM_DECLARATION(CPPInheritObject);\n};\n"
  },
  {
    "path": "src/cpp/tests/orm/rebind/CPPDropIndexObject.cpp",
    "content": "//\n// Created by qiuwenchen on 2022/9/7.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"CPPDropIndexObject.hpp\"\n\nWCDB_CPP_ORM_IMPLEMENTATION_BEGIN(CPPDropIndexObject)\n\n// bind renamedValue to the old column \"value\"\nWCDB_CPP_SYNTHESIZE_COLUMN(renamedValue, \"value\")\nWCDB_CPP_SYNTHESIZE(newValue)\n\n// index will be dropped\nWCDB_CPP_INDEX_TO_BE_DROPPED(\"_index\")\n\nWCDB_CPP_ORM_IMPLEMENTATION_END\n"
  },
  {
    "path": "src/cpp/tests/orm/rebind/CPPDropIndexObject.hpp",
    "content": "//\n// Created by qiuwenchen on 2022/9/7.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#if TEST_WCDB_OBJC\n#import <WCDBOBjc/WCDBCpp.h>\n#elif TEST_WCDB_CPP\n#import <WCDBCpp/WCDBCpp.h>\n#else\n#import <WCDB/WCDBCpp.h>\n#endif\n\nclass CPPDropIndexObject {\n    int renamedValue;\n    int newValue;\n    WCDB_CPP_ORM_DECLARATION(CPPDropIndexObject)\n};\n"
  },
  {
    "path": "src/cpp/tests/orm/rebind/CPPNewRemapObject.cpp",
    "content": "//\n// Created by qiuwenchen on 2022/9/7.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"CPPNewRemapObject.hpp\"\n\nWCDB_CPP_ORM_IMPLEMENTATION_BEGIN(CPPNewRemapObject)\n\n// bind renamedValue to the old column \"value\"\nWCDB_CPP_SYNTHESIZE_COLUMN(renamedValue, \"value\")\nWCDB_CPP_SYNTHESIZE(newValue)\n\n// add index after rebind\nWCDB_CPP_INDEX(\"_index\", renamedValue)\n\nWCDB_CPP_ORM_IMPLEMENTATION_END\n"
  },
  {
    "path": "src/cpp/tests/orm/rebind/CPPNewRemapObject.hpp",
    "content": "//\n// Created by qiuwenchen on 2022/9/7.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#if TEST_WCDB_OBJC\n#import <WCDBOBjc/WCDBCpp.h>\n#elif TEST_WCDB_CPP\n#import <WCDBCpp/WCDBCpp.h>\n#else\n#import <WCDB/WCDBCpp.h>\n#endif\n\nclass CPPNewRemapObject {\n    int renamedValue;\n    int newValue;\n    WCDB_CPP_ORM_DECLARATION(CPPNewRemapObject)\n};\n"
  },
  {
    "path": "src/cpp/tests/orm/rebind/CPPNewlyCreatedTableIndexObject.cpp",
    "content": "//\n// Created by qiuwenchen on 2022/9/7.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"CPPNewlyCreatedTableIndexObject.hpp\"\n\nWCDB_CPP_ORM_IMPLEMENTATION_BEGIN(CPPNewlyCreatedTableIndexObject)\n\n// bind renamedValue to the old column \"value\"\nWCDB_CPP_SYNTHESIZE_COLUMN(renamedValue, \"value\")\nWCDB_CPP_SYNTHESIZE(newValue)\n\n// index will not be created for non-newly-created-table\nWCDB_CPP_INDEX_FOR_NEWLY_CREATED_TABLE_ONLY(\"_index\")\nWCDB_CPP_INDEX(\"_index\", renamedValue)\n\nWCDB_CPP_ORM_IMPLEMENTATION_END\n"
  },
  {
    "path": "src/cpp/tests/orm/rebind/CPPNewlyCreatedTableIndexObject.hpp",
    "content": "//\n// Created by qiuwenchen on 2022/9/7.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#if TEST_WCDB_OBJC\n#import <WCDBOBjc/WCDBCpp.h>\n#elif TEST_WCDB_CPP\n#import <WCDBCpp/WCDBCpp.h>\n#else\n#import <WCDB/WCDBCpp.h>\n#endif\n\nclass CPPNewlyCreatedTableIndexObject {\n    int renamedValue;\n    int newValue;\n    WCDB_CPP_ORM_DECLARATION(CPPNewlyCreatedTableIndexObject)\n};\n"
  },
  {
    "path": "src/cpp/tests/orm/rebind/CPPOldRemapObject.cpp",
    "content": "//\n// Created by qiuwenchen on 2022/9/7.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"CPPOldRemapObject.hpp\"\n\nWCDB_CPP_ORM_IMPLEMENTATION_BEGIN(CPPOldRemapObject)\nWCDB_CPP_SYNTHESIZE(value)\nWCDB_CPP_ORM_IMPLEMENTATION_END\n"
  },
  {
    "path": "src/cpp/tests/orm/rebind/CPPOldRemapObject.hpp",
    "content": "//\n// Created by qiuwenchen on 2022/9/7.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#if TEST_WCDB_OBJC\n#import <WCDBOBjc/WCDBCpp.h>\n#elif TEST_WCDB_CPP\n#import <WCDBCpp/WCDBCpp.h>\n#else\n#import <WCDB/WCDBCpp.h>\n#endif\n\nclass CPPOldRemapObject {\n    int value;\n    WCDB_CPP_ORM_DECLARATION(CPPOldRemapObject)\n};\n"
  },
  {
    "path": "src/cpp/tests/orm/table_constraint/CPPTableConstraintObject.cpp",
    "content": "//\n// Created by qiuwenchen on 2022/9/5.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"CPPTableConstraintObject.hpp\"\n\nWCDB_CPP_ORM_IMPLEMENTATION_BEGIN(CPPTableConstraintObject)\n\nWCDB_CPP_SYNTHESIZE(multiPrimary)\nWCDB_CPP_SYNTHESIZE(multiPrimaryAsc)\nWCDB_CPP_SYNTHESIZE(multiPrimaryDesc)\nWCDB_CPP_SYNTHESIZE(multiUnique)\nWCDB_CPP_SYNTHESIZE(multiUniqueAsc)\nWCDB_CPP_SYNTHESIZE(multiUniqueDesc)\n\nWCDB_CPP_MULTI_PRIMARY(\"multi_primary\", multiPrimary)\nWCDB_CPP_MULTI_PRIMARY_ASC(\"multi_primary\", multiPrimaryAsc)\nWCDB_CPP_MULTI_PRIMARY_DESC(\"multi_primary\", multiPrimaryDesc)\n\nWCDB_CPP_MULTI_UNIQUE(\"multi_unique\", multiUnique)\nWCDB_CPP_MULTI_UNIQUE_ASC(\"multi_unique\", multiUniqueAsc)\nWCDB_CPP_MULTI_UNIQUE_DESC(\"multi_unique\", multiUniqueDesc)\n\nWCDB_CPP_ORM_IMPLEMENTATION_END\n"
  },
  {
    "path": "src/cpp/tests/orm/table_constraint/CPPTableConstraintObject.hpp",
    "content": "//\n// Created by qiuwenchen on 2022/9/5.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#if TEST_WCDB_OBJC\n#import <WCDBOBjc/WCDBCpp.h>\n#elif TEST_WCDB_CPP\n#import <WCDBCpp/WCDBCpp.h>\n#else\n#import <WCDB/WCDBCpp.h>\n#endif\n\nclass CPPTableConstraintObject {\n    int multiPrimary;\n    int multiPrimaryAsc;\n    int multiPrimaryDesc;\n    int multiUnique;\n    int multiUniqueAsc;\n    int multiUniqueDesc;\n    WCDB_CPP_ORM_DECLARATION(CPPTableConstraintObject);\n};\n"
  },
  {
    "path": "src/cpp/tests/orm/virtual_table/CPPVirtualTableFTS4Object.cpp",
    "content": "//\n// Created by qiuwenchen on 2022/11/6.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"CPPVirtualTableFTS4Object.hpp\"\n\nWCDB_CPP_ORM_IMPLEMENTATION_BEGIN(CPPVirtualTableFTS4Object)\n\nWCDB_CPP_SYNTHESIZE(identifier)\nWCDB_CPP_SYNTHESIZE(content)\n\nWCDB_CPP_VIRTUAL_TABLE_MODULE(WCDB::Module::FTS4)\n\nWCDB_CPP_VIRTUAL_TABLE_TOKENIZE(WCDB::BuiltinTokenizer::OneOrBinary)\n\nWCDB_CPP_VIRTUAL_TABLE_EXTERNAL_CONTENT(\"contentTable\")\n\nWCDB_CPP_UNINDEXED(identifier)\n\nWCDB_CPP_ORM_IMPLEMENTATION_END\n"
  },
  {
    "path": "src/cpp/tests/orm/virtual_table/CPPVirtualTableFTS4Object.hpp",
    "content": "//\n// Created by qiuwenchen on 2022/11/6.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#if TEST_WCDB_OBJC\n#import <WCDBOBjc/WCDBCpp.h>\n#elif TEST_WCDB_CPP\n#import <WCDBCpp/WCDBCpp.h>\n#else\n#import <WCDB/WCDBCpp.h>\n#endif\n\nclass CPPVirtualTableFTS4Object {\npublic:\n    int identifier;\n    std::string content;\n    WCDB_CPP_ORM_DECLARATION(CPPVirtualTableFTS4Object);\n};\n"
  },
  {
    "path": "src/cpp/tests/orm/virtual_table/CPPVirtualTableFTS5Object.cpp",
    "content": "//\n// Created by qiuwenchen on 2022/11/6.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"CPPVirtualTableFTS5Object.hpp\"\n\nWCDB_CPP_ORM_IMPLEMENTATION_BEGIN(CPPVirtualTableFTS5Object)\n\nWCDB_CPP_SYNTHESIZE(identifier)\nWCDB_CPP_SYNTHESIZE(content)\n\nWCDB_CPP_VIRTUAL_TABLE_MODULE(WCDB::Module::FTS5)\n\nWCDB_CPP_VIRTUAL_TABLE_TOKENIZE(WCDB::BuiltinTokenizer::Porter)\n\nWCDB_CPP_VIRTUAL_TABLE_EXTERNAL_CONTENT(\"contentTable\")\n\nWCDB_CPP_UNINDEXED(identifier)\n\nWCDB_CPP_ORM_IMPLEMENTATION_END\n"
  },
  {
    "path": "src/cpp/tests/orm/virtual_table/CPPVirtualTableFTS5Object.hpp",
    "content": "//\n// Created by qiuwenchen on 2022/11/6.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#if TEST_WCDB_OBJC\n#import <WCDBOBjc/WCDBCpp.h>\n#elif TEST_WCDB_CPP\n#import <WCDBCpp/WCDBCpp.h>\n#else\n#import <WCDB/WCDBCpp.h>\n#endif\n\nclass CPPVirtualTableFTS5Object {\npublic:\n    int identifier;\n    std::string content;\n    WCDB_CPP_ORM_DECLARATION(CPPVirtualTableFTS5Object);\n};\n"
  },
  {
    "path": "src/java/.gitignore",
    "content": "/local.properties\n/.idea/caches\n/.idea/libraries\n/.idea/modules.xml\n/.idea/workspace.xml\n/.idea/navEditor.xml\n/.idea/assetWizardSettings.xml\n/build\n/captures\n*.iml\n.gradle\n.externalNativeBuild"
  },
  {
    "path": "src/java/annotation/.gitignore",
    "content": "/build"
  },
  {
    "path": "src/java/annotation/build.gradle",
    "content": "plugins {\n    id 'java-library'\n}\napply from: file('../gradle/WeChatPublish.gradle')\n\ngroup 'com.tencent.wcdb'\nversion file('../../../VERSION').text.trim()\n\njava {\n    sourceCompatibility = JavaVersion.VERSION_1_8\n    targetCompatibility = JavaVersion.VERSION_1_8\n}"
  },
  {
    "path": "src/java/annotation/src/main/java/com/tencent/wcdb/FTSModule.java",
    "content": "// Created by chenqiuwen on 2023/11/3.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdb;\n\nimport java.lang.annotation.ElementType;\nimport java.lang.annotation.Retention;\nimport java.lang.annotation.RetentionPolicy;\nimport java.lang.annotation.Target;\n\n@Target(ElementType.TYPE)\n@Retention(RetentionPolicy.SOURCE)\npublic @interface FTSModule {\n    FTSVersion version() default FTSVersion.NONE;\n\n    String tokenizer() default \"\";\n\n    String[] tokenizerParameters() default {};\n\n    String externalTable() default \"\";\n}\n"
  },
  {
    "path": "src/java/annotation/src/main/java/com/tencent/wcdb/FTSVersion.java",
    "content": "// Created by chenqiuwen on 2023/11/3.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdb;\n\npublic enum FTSVersion {\n    NONE, FTS3, FTS4, FTS5\n}\n"
  },
  {
    "path": "src/java/annotation/src/main/java/com/tencent/wcdb/MultiIndexes.java",
    "content": "// Created by qiuwenchen on 2023/3/30.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage com.tencent.wcdb;\n\nimport java.lang.annotation.ElementType;\nimport java.lang.annotation.Retention;\nimport java.lang.annotation.RetentionPolicy;\nimport java.lang.annotation.Target;\n\n@Target(ElementType.TYPE)\n@Retention(RetentionPolicy.SOURCE)\npublic @interface MultiIndexes {\n    String name() default \"\";\n\n    String[] columns();\n}\n"
  },
  {
    "path": "src/java/annotation/src/main/java/com/tencent/wcdb/MultiPrimary.java",
    "content": "// Created by qiuwenchen on 2023/3/30.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdb;\n\nimport java.lang.annotation.ElementType;\nimport java.lang.annotation.Retention;\nimport java.lang.annotation.RetentionPolicy;\nimport java.lang.annotation.Target;\n\n@Target(ElementType.TYPE)\n@Retention(RetentionPolicy.SOURCE)\npublic @interface MultiPrimary {\n    String[] columns();\n}\n"
  },
  {
    "path": "src/java/annotation/src/main/java/com/tencent/wcdb/MultiUnique.java",
    "content": "// Created by qiuwenchen on 2023/3/30.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage com.tencent.wcdb;\n\nimport java.lang.annotation.ElementType;\nimport java.lang.annotation.Retention;\nimport java.lang.annotation.RetentionPolicy;\nimport java.lang.annotation.Target;\n\n@Target(ElementType.TYPE)\n@Retention(RetentionPolicy.SOURCE)\npublic @interface MultiUnique {\n    String[] columns();\n}\n"
  },
  {
    "path": "src/java/annotation/src/main/java/com/tencent/wcdb/WCDBDefault.java",
    "content": "// Created by qiuwenchen on 2023/6/27.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdb;\n\nimport java.lang.annotation.ElementType;\nimport java.lang.annotation.Retention;\nimport java.lang.annotation.RetentionPolicy;\nimport java.lang.annotation.Target;\n\n@Target(ElementType.FIELD)\n@Retention(RetentionPolicy.SOURCE)\npublic @interface WCDBDefault {\n    long intValue() default 0;\n\n    double doubleValue() default 0;\n\n    String textValue() default \"\";\n}\n"
  },
  {
    "path": "src/java/annotation/src/main/java/com/tencent/wcdb/WCDBField.java",
    "content": "// Created by qiuwenchen on 2023/3/30.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage com.tencent.wcdb;\n\nimport java.lang.annotation.ElementType;\nimport java.lang.annotation.Retention;\nimport java.lang.annotation.RetentionPolicy;\nimport java.lang.annotation.Target;\n\n@Target(ElementType.FIELD)\n@Retention(RetentionPolicy.SOURCE)\npublic @interface WCDBField {\n    String columnName() default \"\";\n\n    boolean isPrimary() default false;\n\n    boolean isAutoIncrement() default false;\n\n    boolean enableAutoIncrementForExistingTable() default false;\n\n    boolean isUnique() default false;\n\n    boolean isNotNull() default false;\n\n    boolean isNotIndexed() default false;\n}\n"
  },
  {
    "path": "src/java/annotation/src/main/java/com/tencent/wcdb/WCDBIndex.java",
    "content": "// Created by qiuwenchen on 2023/3/30.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage com.tencent.wcdb;\n\nimport java.lang.annotation.ElementType;\nimport java.lang.annotation.Retention;\nimport java.lang.annotation.RetentionPolicy;\nimport java.lang.annotation.Target;\n\n@Target(ElementType.FIELD)\n@Retention(RetentionPolicy.SOURCE)\npublic @interface WCDBIndex {\n    String name() default \"\";\n\n    boolean isUnique() default false;\n}\n"
  },
  {
    "path": "src/java/annotation/src/main/java/com/tencent/wcdb/WCDBTableCoding.java",
    "content": "// Created by qiuwenchen on 2023/3/30.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage com.tencent.wcdb;\n\nimport java.lang.annotation.ElementType;\nimport java.lang.annotation.Inherited;\nimport java.lang.annotation.Retention;\nimport java.lang.annotation.RetentionPolicy;\nimport java.lang.annotation.Target;\n\n@Inherited\n@Target(ElementType.TYPE)\n@Retention(RetentionPolicy.SOURCE)\npublic @interface WCDBTableCoding {\n    MultiIndexes[] multiIndexes() default {};\n\n    MultiPrimary[] multiPrimaries() default {};\n\n    MultiUnique[] multiUnique() default {};\n\n    boolean isWithoutRowId() default false;\n\n    FTSModule ftsModule() default @FTSModule();\n}\n"
  },
  {
    "path": "src/java/build.gradle",
    "content": "// Top-level build file where you can add configuration options common to all sub-projects/modules.\n\nbuildscript {\n    ext {\n        kotlin_version = '1.7.10'\n    }\n    repositories {\n        mavenCentral()\n        google()\n    }\n\n    dependencies {\n        classpath 'com.android.tools.build:gradle:8.8.0'\n        classpath \"org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version\"\n\n        // NOTE: Do not place your application dependencies here; they belong\n        // in the individual module build.gradle files\n    }\n}\n\ndef myVersion = file('../../VERSION').text.trim()\nallprojects {\n    group 'com.tencent.wcdb'\n    version myVersion\n\n    repositories {\n        mavenCentral()\n        google()\n    }\n}\n\ntasks.register('publishAllToMavenLocal') {\n    group = 'publishing'\n    dependsOn gradle.includedBuild('annotation').task(':publishToMavenLocal')\n    dependsOn gradle.includedBuild('builder').task(':compiler:publishToMavenLocal')\n    dependsOn gradle.includedBuild('builder').task(':gradle-plugin:publishToMavenLocal')\n    dependsOn tasks.findByPath(':main:publishToMavenLocal')\n    dependsOn tasks.findByPath(':compat:publishToMavenLocal')\n}\n\ntasks.register('publishAll') {\n    group = 'publishing'\n    dependsOn gradle.includedBuild('annotation').task(':publish')\n    dependsOn gradle.includedBuild('builder').task(':compiler:publish')\n    dependsOn gradle.includedBuild('builder').task(':gradle-plugin:publish')\n    dependsOn tasks.findByPath(':main:publish')\n    dependsOn tasks.findByPath(':compat:publish')\n}\n"
  },
  {
    "path": "src/java/builder/.gitignore",
    "content": "/local.properties\n/.idea/caches\n/.idea/libraries\n/.idea/modules.xml\n/.idea/workspace.xml\n/.idea/navEditor.xml\n/.idea/assetWizardSettings.xml\n/build\n/captures\n*.iml\n.gradle\n.externalNativeBuild"
  },
  {
    "path": "src/java/builder/build.gradle",
    "content": "buildscript {\n    ext {\n        kotlin_version = '1.7.10'\n    }\n\n    repositories {\n        mavenCentral()\n        google()\n    }\n\n    dependencies {\n        classpath \"org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version\"\n\n        // NOTE: Do not place your application dependencies here; they belong\n        // in the individual module build.gradle files\n    }\n}\n\ndef myVersion = file('../../../VERSION').text.trim()\nallprojects {\n    group 'com.tencent.wcdb'\n    version myVersion\n\n    repositories {\n        mavenCentral()\n        google()\n    }\n}"
  },
  {
    "path": "src/java/builder/compiler/.gitignore",
    "content": "/build"
  },
  {
    "path": "src/java/builder/compiler/build.gradle",
    "content": "plugins {\n    id 'java-library'\n    id 'org.jetbrains.kotlin.jvm'\n}\napply from: rootProject.file('../gradle/WeChatPublish.gradle')\n\njava {\n    sourceCompatibility = JavaVersion.VERSION_1_8\n    targetCompatibility = JavaVersion.VERSION_1_8\n}\n\ndependencies {\n    implementation fileTree(dir: 'libs', include: ['*.jar'])\n    implementation \"com.tencent.wcdb:annotation:${project.getFullVersion()}\"\n    implementation 'com.google.devtools.ksp:symbol-processing-api:1.7.10-1.0.6'\n}\n"
  },
  {
    "path": "src/java/builder/compiler/src/main/java/com/tencent/wcdb/compiler/JavaAnnotationProcessor.java",
    "content": "// Created by qiuwenchen on 2023/3/30.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage com.tencent.wcdb.compiler;\n\nimport java.io.BufferedWriter;\nimport java.io.IOException;\nimport java.util.ArrayList;\nimport java.util.Collections;\nimport java.util.HashSet;\nimport java.util.Map;\nimport java.util.Set;\n\nimport javax.annotation.processing.AbstractProcessor;\nimport javax.annotation.processing.Filer;\nimport javax.annotation.processing.Messager;\nimport javax.annotation.processing.ProcessingEnvironment;\nimport javax.annotation.processing.RoundEnvironment;\nimport javax.annotation.processing.SupportedOptions;\nimport javax.lang.model.SourceVersion;\nimport javax.lang.model.element.AnnotationMirror;\nimport javax.lang.model.element.AnnotationValue;\nimport javax.lang.model.element.Element;\nimport javax.lang.model.element.ElementKind;\nimport javax.lang.model.element.ExecutableElement;\nimport javax.lang.model.element.Modifier;\nimport javax.lang.model.element.TypeElement;\nimport javax.lang.model.util.Elements;\nimport javax.tools.Diagnostic;\nimport javax.lang.model.util.Types;\nimport javax.tools.JavaFileObject;\n\nimport com.tencent.wcdb.*;\nimport com.tencent.wcdb.compiler.resolvedInfo.ColumnInfo;\nimport com.tencent.wcdb.compiler.resolvedInfo.MultiIndexesInfo;\nimport com.tencent.wcdb.compiler.resolvedInfo.MultiPrimaryInfo;\nimport com.tencent.wcdb.compiler.resolvedInfo.MultiUniqueInfo;\nimport com.tencent.wcdb.compiler.resolvedInfo.TableConfigInfo;\n\n@SupportedOptions(value = {\"verbose\"})\npublic class JavaAnnotationProcessor extends AbstractProcessor {\n\n    public static final String OPTION_VERBOSE = \"verbose\";\n    private static final String TAB = \"    \";\n    Filer filer;\n    Messager msg;\n    Types typeUtil;\n    Elements elementUtil;\n    private boolean writerRoundDone = false;\n    private int round = 0;\n    private boolean verbose = true;\n    private int primaryKeyCount = 0;\n\n    private TableConfigInfo tableConstraintInfo;\n    private ArrayList<ColumnInfo> allFieldInfo;\n\n    @Override\n    public synchronized void init(ProcessingEnvironment processingEnvironment) {\n        super.init(processingEnvironment);\n        verbose = Boolean.parseBoolean(processingEnvironment.getOptions().get(OPTION_VERBOSE));\n        filer = processingEnvironment.getFiler();\n        msg = processingEnvironment.getMessager();\n        typeUtil = processingEnvironment.getTypeUtils();\n        elementUtil = processingEnvironment.getElementUtils();\n    }\n\n    @Override\n    public Set<String> getSupportedAnnotationTypes() {\n        return Collections.singleton(WCDBTableCoding.class.getCanonicalName());\n    }\n\n    @Override\n    public SourceVersion getSupportedSourceVersion() {\n        return SourceVersion.latest();\n    }\n\n    @Override\n    public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment env) {\n        try {\n            round++;\n            verboseLog(\"WCDB Processing round \" + round + \", new annotations: \" +\n                    !annotations.isEmpty() + \", processingOver: \" + env.processingOver());\n            if (env.processingOver()) {\n                if (!annotations.isEmpty()) {\n                    msg.printMessage(Diagnostic.Kind.ERROR,\n                            \"Unexpected WCDB processing state: annotations still available after processing over\");\n                    return false;\n                }\n            }\n\n            if (annotations.isEmpty()) {\n                return false;\n            }\n\n            if (writerRoundDone) {\n                msg.printMessage(Diagnostic.Kind.ERROR,\n                        \"Unexpected WCDB processing state: annotations still available after writing.\");\n            }\n\n            Set<? extends Element> elements = env.getElementsAnnotatedWith(WCDBTableCoding.class);\n            for (Element element : elements) {\n                if (!checkClassElement(element)) {\n                    return false;\n                }\n\n                primaryKeyCount = 0;\n                WCDBTableCoding config = element.getAnnotation(WCDBTableCoding.class);\n                assert config != null;\n                FTSModule ftsModule = getFTSModule(element, config);\n                if (!checkFTSModule(element, ftsModule)) {\n                    return false;\n                }\n                tableConstraintInfo = TableConfigInfo.Companion.resolve(config, ftsModule);\n                allFieldInfo = new ArrayList<>();\n\n                verboseLog(\"WCDB Processing: \" + element);\n\n                for (Element enclosedElement : element.getEnclosedElements()) {\n                    if (enclosedElement.getKind() != ElementKind.FIELD) {\n                        continue;\n                    }\n                    WCDBField fieldAnnotation = enclosedElement.getAnnotation(WCDBField.class);\n                    if (fieldAnnotation == null) {\n                        continue;\n                    }\n                    WCDBDefault defaultValueAnnotation = enclosedElement.getAnnotation(WCDBDefault.class);\n                    WCDBIndex indexAnnotation = enclosedElement.getAnnotation(WCDBIndex.class);\n                    if (!checkFieldElement(enclosedElement, fieldAnnotation, indexAnnotation, defaultValueAnnotation)) {\n                        allFieldInfo.clear();\n                        break;\n                    }\n                    verboseLog(\"Found WCDBField: \" + enclosedElement\n                            + \" \" + enclosedElement.asType().toString());\n                    allFieldInfo.add(ColumnInfo.Companion.resolve(enclosedElement, fieldAnnotation, indexAnnotation, defaultValueAnnotation));\n                }\n\n                if (!checkColumnInTableConstraint(element)) {\n                    return false;\n                }\n\n                if (allFieldInfo.size() > 0) {\n                    createORMFile((TypeElement) element);\n                }\n            }\n            writerRoundDone = true;\n\n        } catch (RuntimeException e) {\n            // IntelliJ does not handle exceptions nicely, so log and print a message\n            e.printStackTrace();\n            msg.printMessage(Diagnostic.Kind.ERROR,\n                    \"Unexpected error in WCDBAnnotationProcessor: \" + e);\n        }\n        return true;\n    }\n\n    private void verboseLog(String content) {\n        if (verbose) {\n            msg.printMessage(Diagnostic.Kind.NOTE, content);\n        }\n    }\n\n    private boolean checkClassElement(Element element) {\n        if (element.getKind() != ElementKind.CLASS) {\n            msg.printMessage(Diagnostic.Kind.ERROR,\n                    \"@WCDBTableCoding is only valid for classes\", element);\n            return false;\n        }\n        Set<Modifier> modifiers = element.getModifiers();\n        if (modifiers.contains(Modifier.PRIVATE) || modifiers.contains(Modifier.PROTECTED)) {\n            msg.printMessage(Diagnostic.Kind.ERROR,\n                    \"The class with annotation @WCDBTableCoding can not be private or protected\", element);\n            return false;\n        }\n        if (modifiers.contains(Modifier.ABSTRACT)) {\n            msg.printMessage(Diagnostic.Kind.ERROR,\n                    \"The class with annotation @WCDBTableCoding can not be abstract\", element);\n            return false;\n        }\n        return true;\n    }\n\n    private FTSModule getFTSModule(Element element, WCDBTableCoding config) {\n        for (AnnotationMirror mirror : element.getAnnotationMirrors()) {\n            if (mirror.getAnnotationType().toString().equals(WCDBTableCoding.class.getName())) {\n                Map<? extends ExecutableElement, ? extends AnnotationValue> elementValues = mirror.getElementValues();\n                for (Map.Entry<? extends ExecutableElement, ? extends AnnotationValue> entry : elementValues.entrySet()) {\n                    if (entry.getKey().getSimpleName().toString().equals(\"ftsModule\")) {\n                        return config.ftsModule();\n                    }\n                }\n\n            }\n        }\n        return null;\n    }\n\n    private boolean checkFTSModule(Element element, FTSModule ftsModule) {\n        if (ftsModule == null) {\n            return true;\n        }\n        if (ftsModule.version() == FTSVersion.NONE) {\n            if (!ftsModule.tokenizer().isEmpty() || ftsModule.tokenizerParameters().length > 0) {\n                msg.printMessage(Diagnostic.Kind.ERROR,\n                        \"You need to config fts version in @FTSModule\", element);\n                return false;\n            }\n            return true;\n        }\n        if (ftsModule.tokenizer().isEmpty()) {\n            msg.printMessage(Diagnostic.Kind.ERROR,\n                    \"You need to config a tokenizer in @FTSModule\", element);\n            return false;\n        }\n        return true;\n    }\n\n    private boolean checkFieldElement(Element element, WCDBField fieldAnnotation, WCDBIndex indexAnnotation, WCDBDefault defaultValueAnnotation) {\n        if (element.getModifiers().contains(Modifier.PRIVATE) || element.getModifiers().contains(Modifier.PROTECTED)) {\n            msg.printMessage(Diagnostic.Kind.ERROR,\n                    \"The field with annotation @WCDBField can not be private or protected\", element);\n            return false;\n        }\n        String type = element.asType().toString();\n        if (!JavaFieldORMInfo.allTypes.contains(type)) {\n            String info = \"The type \" + type + \" of field \" + element.toString() +\n                    \" in \" + element.getEnclosingElement().getSimpleName() + \" is Unsupported!\\n\"\n                    + \"WCDB only supports Java basic types and byte[].\";\n            msg.printMessage(Diagnostic.Kind.ERROR, info, element);\n            return false;\n        }\n        if (fieldAnnotation.isPrimary()) {\n            primaryKeyCount++;\n            if (primaryKeyCount > 1) {\n                String info = \"@WCDBField can only configure one primary key in \" + element.getEnclosingElement().getSimpleName()\n                        + \". If multiple primary keys are required, configure multiPrimaries in @WCDBTableCoding. \";\n                msg.printMessage(Diagnostic.Kind.ERROR, info, element);\n                return false;\n            }\n            if (fieldAnnotation.isAutoIncrement()) {\n                if (!JavaFieldORMInfo.allInfo.get(type).columnType.equals(\"Integer\")) {\n                    String info = \"Auto-increment field must be integer\";\n                    msg.printMessage(Diagnostic.Kind.ERROR, info, element);\n                    return false;\n                }\n            }\n            if (indexAnnotation != null) {\n                String info = element.getEnclosingElement().getSimpleName() +\n                        \" is confined as primary key, so it does not need to configure @WCDBIndex\";\n                msg.printMessage(Diagnostic.Kind.ERROR, info, element);\n                return false;\n            }\n        } else if (fieldAnnotation.isAutoIncrement()) {\n            String info = \"Only the primary key can be configured as auto-increment\";\n            msg.printMessage(Diagnostic.Kind.ERROR, info, element);\n            return false;\n        }\n        if (defaultValueAnnotation != null) {\n            int valueCount = 0;\n            boolean typeMissMatch = false;\n            String columnType = JavaFieldORMInfo.allInfo.get(type).columnType;\n            if (defaultValueAnnotation.intValue() != 0) {\n                valueCount++;\n                if (!columnType.equals(\"Integer\")) {\n                    typeMissMatch = true;\n                }\n            }\n            if (defaultValueAnnotation.doubleValue() != 0) {\n                valueCount++;\n                if (!columnType.equals(\"Float\")) {\n                    typeMissMatch = true;\n                }\n            }\n            if (defaultValueAnnotation.textValue().length() > 0) {\n                valueCount++;\n                if (!columnType.equals(\"Text\")) {\n                    typeMissMatch = true;\n                }\n            }\n            if (valueCount > 1) {\n                msg.printMessage(Diagnostic.Kind.ERROR, \"Only one default value can be configured for a field\", element);\n                return false;\n            } else if (typeMissMatch) {\n                if (columnType.equals(\"BLOB\")) {\n                    msg.printMessage(Diagnostic.Kind.ERROR, \"Assigning a default value to BLOB is unsupported\", element);\n                } else {\n                    msg.printMessage(Diagnostic.Kind.ERROR, \"Default value should be a \" + columnType, element);\n                }\n                return false;\n            }\n        }\n        return true;\n    }\n\n    private boolean checkColumnInTableConstraint(Element element) {\n        if (tableConstraintInfo.getMultiIndexes().isEmpty() &&\n                tableConstraintInfo.getMultiPrimaries().isEmpty() &&\n                tableConstraintInfo.getMultiUnique().isEmpty()) {\n            return true;\n        }\n        Set<String> allColumns = new HashSet<>();\n        for (ColumnInfo columnInfo : allFieldInfo) {\n            allColumns.add(columnInfo.getColumnName().isEmpty() ? columnInfo.getPropertyName() : columnInfo.getColumnName());\n        }\n\n        for (MultiIndexesInfo multiIndexes : tableConstraintInfo.getMultiIndexes()) {\n            for (String column : multiIndexes.getColumns()) {\n                if (!allColumns.contains(column)) {\n                    msg.printMessage(Diagnostic.Kind.ERROR, \"Can't find column \\\"\" + column + \"\\\" in class orm config.\", element);\n                    return false;\n                }\n            }\n        }\n\n        for (MultiPrimaryInfo multiPrimary : tableConstraintInfo.getMultiPrimaries()) {\n            for (String column : multiPrimary.getColumns()) {\n                if (!allColumns.contains(column)) {\n                    msg.printMessage(Diagnostic.Kind.ERROR, \"Can't find column \\\"\" + column + \"\\\" in class orm config.\", element);\n                    return false;\n                }\n            }\n        }\n\n        for (MultiUniqueInfo multiUnique : tableConstraintInfo.getMultiUnique()) {\n            for (String column : multiUnique.getColumns()) {\n                if (!allColumns.contains(column)) {\n                    msg.printMessage(Diagnostic.Kind.ERROR, \"Can't find column \\\"\" + column + \"\\\" in class orm config.\", element);\n                    return false;\n                }\n            }\n        }\n\n        return true;\n    }\n\n    private void createORMFile(TypeElement element) throws RuntimeException {\n        String packageName = elementUtil.getPackageOf(element).toString();\n        String className = String.valueOf(element.getSimpleName());\n        String ormClassName = \"DB\" + element.getSimpleName();\n\n        JavaCodeGenerator codeGenerator = new JavaCodeGenerator();\n        codeGenerator.packageName = packageName;\n        codeGenerator.className = className;\n        codeGenerator.ormClassName = ormClassName;\n        codeGenerator.tableConstraintInfo = tableConstraintInfo;\n        codeGenerator.allColumnInfo = allFieldInfo;\n\n        String javaCode = codeGenerator.generate();\n\n        BufferedWriter writer = null;\n        try {\n            JavaFileObject outputFile = filer.createSourceFile(packageName + \".\" + ormClassName);\n            writer = new BufferedWriter(outputFile.openWriter());\n            writer.write(javaCode);\n        } catch (IOException e) {\n            throw new RuntimeException(\"Could not write source for \" + element.getSimpleName(), e);\n        } finally {\n            if (writer != null) {\n                try {\n                    writer.close();\n                } catch (IOException e) {\n                    //Silent\n                }\n            }\n        }\n    }\n}"
  },
  {
    "path": "src/java/builder/compiler/src/main/java/com/tencent/wcdb/compiler/JavaCodeGenerator.java",
    "content": "// Created by qiuwenchen on 2023/6/21.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdb.compiler;\n\nimport com.tencent.wcdb.compiler.resolvedInfo.ColumnInfo;\nimport com.tencent.wcdb.compiler.resolvedInfo.FTSModuleInfo;\nimport com.tencent.wcdb.compiler.resolvedInfo.MultiIndexesInfo;\nimport com.tencent.wcdb.compiler.resolvedInfo.MultiPrimaryInfo;\nimport com.tencent.wcdb.compiler.resolvedInfo.MultiUniqueInfo;\nimport com.tencent.wcdb.compiler.resolvedInfo.TableConfigInfo;\n\nimport java.util.HashMap;\nimport java.util.List;\nimport java.util.Map;\n\npublic class JavaCodeGenerator {\n    public String packageName;\n    public String className;\n    public String ormClassName;\n    public TableConfigInfo tableConstraintInfo;\n    public List<ColumnInfo> allColumnInfo;\n\n    private StringBuilder builder;\n    private static final String TAB = \"\\t\";\n\n    public String generate() {\n        builder = new StringBuilder();\n        builder.append(\"package \").append(packageName).append(\";\\n\\n\");\n\n        generateImport();\n\n        builder.append(\"public class \").append(ormClassName).append(\" implements TableBinding<\").append(className).append(\"> {\\n\");\n        builder.append(TAB + \"private static final Binding baseBinding;\\n\");\n        builder.append(TAB + \"public static final \").append(ormClassName).append(\" INSTANCE;\\n\\n\");\n\n        generateFields();\n\n        builder.append(\"\\n\");\n        builder.append(TAB + \"static {\\n\\n\");\n        builder.append(TAB + TAB + \"baseBinding = new Binding();\\n\");\n        builder.append(TAB + TAB + \"INSTANCE = new \").append(ormClassName).append(\"();\\n\\n\");\n        generateColumns();\n        generateTableConfig();\n        builder.append(TAB + \"}\\n\\n\");\n\n        generateBindingType();\n        generateBindingFields();\n        generateBaseBinding();\n\n        generateExtractObject();\n        generateBindObject();\n\n        generateAutoIncrementConfig();\n\n        builder.append(\"}\");\n        return builder.toString();\n    }\n\n    private void generateImport() {\n        builder.append(\"import com.tencent.wcdb.core.PreparedStatement;\\n\");\n        builder.append(\"import com.tencent.wcdb.orm.*;\\n\");\n        builder.append(\"import com.tencent.wcdb.winq.Column;\\n\");\n        builder.append(\"import com.tencent.wcdb.winq.ColumnConstraint;\\n\");\n        builder.append(\"import com.tencent.wcdb.winq.ColumnDef;\\n\");\n        builder.append(\"import com.tencent.wcdb.winq.ColumnType;\\n\");\n        builder.append(\"import com.tencent.wcdb.winq.StatementCreateIndex;\\n\");\n        builder.append(\"import com.tencent.wcdb.winq.TableConstraint;\\n\\n\");\n    }\n\n    private void generateFields() {\n        for (ColumnInfo info : allColumnInfo) {\n            builder.append(TAB + \"public static final Field<\").append(className).append(\"> \")\n                    .append(info.getPropertyName()).append(\";\\n\");\n        }\n    }\n\n    private void generateColumns() {\n        int fieldId = 1;\n        for (ColumnInfo columnInfo : allColumnInfo) {\n            JavaFieldORMInfo ormInfo = JavaFieldORMInfo.allInfo.get(columnInfo.getPropertyType());\n            assert ormInfo != null;\n\n            String propertyName = columnInfo.getPropertyName();\n            String columnName = columnInfo.getColumnName();\n            if (columnName.length() == 0) {\n                columnName = propertyName;\n            }\n\n            builder.append(TAB + TAB).append(propertyName).append(\" = new Field(\\\"\")\n                    .append(columnName).append(\"\\\", INSTANCE, \").append(fieldId).append(\", \")\n                    .append(columnInfo.isPrimary() && columnInfo.isAutoIncrement()).append(\", \")\n                    .append(columnInfo.isPrimary()).append(\");\\n\");\n\n            fieldId++;\n\n            builder.append(TAB + TAB + \"ColumnDef \").append(propertyName)\n                    .append(\"Def = new ColumnDef(\").append(propertyName)\n                    .append(\", ColumnType.\").append(ormInfo.columnType).append(\");\\n\");\n\n            String constraintPrefix = TAB + TAB + propertyName + \"Def.constraint(new ColumnConstraint()\";\n\n            if (columnInfo.isPrimary()) {\n                builder.append(constraintPrefix).append(\".primaryKey()\").append(columnInfo.isAutoIncrement() ? \".autoIncrement());\\n\" : \");\\n\");\n            }\n\n            if (columnInfo.getDefaultValue() != null) {\n                if (ormInfo.columnType.equals(\"Integer\")) {\n                    builder.append(constraintPrefix).append(\".defaultTo(\").append(columnInfo.getDefaultValue().getIntValue()).append(\"));\\n\");\n                } else if (ormInfo.columnType.equals(\"Float\")) {\n                    builder.append(constraintPrefix).append(\".defaultTo(\").append(columnInfo.getDefaultValue().getDoubleValue()).append(\"));\\n\");\n                } else {\n                    builder.append(constraintPrefix).append(\".defaultTo(\\\"\").append(columnInfo.getDefaultValue().getTextValue()).append(\"\\\"));\\n\");\n                }\n            }\n\n            if (columnInfo.isUnique()) {\n                builder.append(constraintPrefix).append(\".unique()\").append(\");\\n\");\n            }\n\n            if (columnInfo.isNotNull()) {\n                builder.append(constraintPrefix).append(\".notNull()\").append(\");\\n\");\n            }\n\n            if (columnInfo.isNotIndexed()) {\n                builder.append(constraintPrefix).append(\".unIndex()\").append(\");\\n\");\n            }\n\n            builder.append(TAB + TAB + \"baseBinding.addColumnDef(\").append(propertyName).append(\"Def);\\n\");\n\n            if (columnInfo.getEnableAutoIncrementForExistingTable()) {\n                builder.append(TAB + TAB + \"baseBinding.enableAutoIncrementForExistingTable();\\n\");\n            }\n\n            if (!columnInfo.getHasIndex()) {\n                continue;\n            }\n            String indexName = columnInfo.getIndexName();\n            boolean isFullName = true;\n            if (indexName.length() == 0) {\n                isFullName = false;\n                indexName = \"_\" + columnName + \"_index\";\n            }\n\n            builder.append(TAB + TAB + \"baseBinding.addIndex(\\\"\")\n                    .append(indexName).append(\"\\\", \").append(isFullName)\n                    .append(\", new StatementCreateIndex().ifNotExist()\");\n\n            if (columnInfo.getIndexIsUnique()) {\n                builder.append(\".unique()\");\n            }\n            builder.append(\".indexedBy(\").append(propertyName).append(\"));\\n\\n\");\n        }\n    }\n\n    private void generateTableConfig() {\n\n        Map<String, ColumnInfo> allColumns = new HashMap<>();\n        for (ColumnInfo columnInfo : allColumnInfo) {\n            allColumns.put(columnInfo.getColumnName().isEmpty() ? columnInfo.getPropertyName() : columnInfo.getColumnName(), columnInfo);\n        }\n\n        for (MultiIndexesInfo indexes : tableConstraintInfo.getMultiIndexes()) {\n            String indexName = indexes.getName();\n            boolean isFullName = true;\n            if (indexName.length() == 0) {\n                isFullName = false;\n                indexName = \"_\" + String.join(\"_\", indexes.getColumns()) + \"_index\";\n            }\n            builder.append(TAB + TAB + \"baseBinding.addIndex(\\\"\").append(indexName).append(\"\\\", \").append(isFullName)\n                    .append(\", new StatementCreateIndex().ifNotExist().indexedBy(new Column[]{\\n\" + TAB + TAB + TAB);\n            for (String column : indexes.getColumns()) {\n                builder.append(allColumns.get(column).getPropertyName()).append(\", \");\n            }\n            builder.append(\"\\n\" + TAB + TAB + \"}));\\n\");\n        }\n\n        for (MultiPrimaryInfo primaries : tableConstraintInfo.getMultiPrimaries()) {\n            builder.append(TAB + TAB + \"baseBinding.addTableConstraint(new TableConstraint().primaryKey().indexedBy(new Column[]{\\n\" + TAB + TAB + TAB);\n            for (String column : primaries.getColumns()) {\n                builder.append(allColumns.get(column).getPropertyName()).append(\", \");\n            }\n            builder.append(\"\\n\" + TAB + TAB + \"}));\\n\");\n        }\n\n        for (MultiUniqueInfo uniques : tableConstraintInfo.getMultiUnique()) {\n            builder.append(TAB + TAB + \"baseBinding.addTableConstraint(new TableConstraint().unique().indexedBy(new Column[]{\\n\" + TAB + TAB + TAB);\n            for (String column : uniques.getColumns()) {\n                builder.append(allColumns.get(column).getPropertyName()).append(\", \");\n            }\n            builder.append(\"\\n\" + TAB + TAB + \"}));\\n\");\n        }\n\n        if (tableConstraintInfo.isWithoutRowId()) {\n            builder.append(TAB + TAB + \"baseBinding.configWithoutRowId();\\n\");\n        }\n\n        FTSModuleInfo ftsModuleInfo = tableConstraintInfo.getFtsModule();\n        if (ftsModuleInfo == null || ftsModuleInfo.getFtsVersion().isEmpty()) {\n            return;\n        }\n\n        builder.append(TAB + TAB + \"baseBinding.configVirtualModule(\\\"\").append(ftsModuleInfo.getFtsVersion()).append(\"\\\");\\n\");\n\n        StringBuilder tokenizer = new StringBuilder(\"tokenize = \");\n        tokenizer.append(ftsModuleInfo.getTokenizer());\n        for (String para : ftsModuleInfo.getTokenizerParameters()) {\n            tokenizer.append(\" \").append(para);\n        }\n        builder.append(TAB + TAB + \"baseBinding.configVirtualModuleArgument(\\\"\").append(tokenizer).append(\"\\\");\\n\");\n        if (!ftsModuleInfo.getExternalTable().isEmpty()) {\n            builder.append(TAB + TAB + \"baseBinding.configVirtualModuleArgument(\\\"content='\").append(ftsModuleInfo.getExternalTable()).append(\"'\\\");\\n\");\n        }\n    }\n\n    private void generateBindingType() {\n        builder.append(TAB + \"@Override\\n\");\n        builder.append(TAB + \"public Class<\").append(className).append(\"> bindingType() {\\n\");\n        builder.append(TAB + TAB + \"return \").append(className).append(\".class;\\n\");\n        builder.append(TAB + \"}\\n\\n\");\n    }\n\n    private void generateBindingFields() {\n        builder.append(TAB + \"@Override\\n\");\n        builder.append(TAB + \"public Field<\").append(className).append(\">[] allBindingFields() {\\n\");\n        builder.append(TAB + TAB + \"return new Field[]{\");\n        for (ColumnInfo columnInfo : allColumnInfo) {\n            builder.append(columnInfo.getPropertyName()).append(\", \");\n        }\n        builder.append(\"};\\n\" + TAB + \"}\\n\\n\");\n\n        builder.append(TAB + \"public static Field<\").append(className).append(\">[] allFields() {\\n\");\n        builder.append(TAB + TAB + \"return new Field[]{\");\n        for (ColumnInfo columnInfo : allColumnInfo) {\n            builder.append(columnInfo.getPropertyName()).append(\", \");\n        }\n        builder.append(\"};\\n\" + TAB + \"}\\n\\n\");\n    }\n\n    private void generateBaseBinding() {\n        builder.append(TAB + \"@Override\\n\");\n        builder.append(TAB + \"public Binding baseBinding() {\\n\");\n        builder.append(TAB + TAB + \"return baseBinding;\\n\");\n        builder.append(TAB + \"}\\n\\n\");\n    }\n\n    private void generateExtractObject() {\n        builder.append(TAB + \"@Override\\n\");\n        builder.append(TAB + \"public <R extends \").append(className).append(\"> R extractObject(Field<\")\n                .append(className).append(\">[] fields, PreparedStatement preparedStatement, Class<R> cls) throws ReflectiveOperationException {\\n\");\n        builder.append(TAB + TAB + \"R newOne = cls.newInstance();\\n\");\n        builder.append(TAB + TAB + \"int index = 0;\\n\");\n        builder.append(TAB + TAB + \"for(Field<\").append(className).append(\"> field : fields) {\\n\");\n        builder.append(TAB + TAB + TAB + \"switch (field.getFieldId()) {\\n\");\n        int index = 1;\n        for (ColumnInfo columnInfo : allColumnInfo) {\n            JavaFieldORMInfo info = JavaFieldORMInfo.allInfo.get(columnInfo.getPropertyType());\n            assert info != null;\n\n            builder.append(TAB + TAB + TAB + TAB + \"case \").append(index).append(\":\\n\");\n            if (info.nullable) {\n                builder.append(TAB + TAB + TAB + TAB + TAB + \"if (preparedStatement.getColumnType(index) != ColumnType.Null) {\\n\");\n                builder.append(TAB + TAB + TAB + TAB + TAB + TAB + \"newOne.\").append(columnInfo.getPropertyName())\n                        .append(\" = \").append(info.fieldSetter).append(\"(index);\\n\");\n                builder.append(TAB + TAB + TAB + TAB + TAB + \"}\\n\");\n            } else {\n                builder.append(TAB + TAB + TAB + TAB + TAB + \"newOne.\").append(columnInfo.getPropertyName())\n                        .append(\" = \").append(info.fieldSetter).append(\"(index);\\n\");\n            }\n            builder.append(TAB + TAB + TAB + TAB + TAB + \"break;\\n\");\n\n            index++;\n        }\n\n        builder.append(TAB + TAB + TAB + TAB + \"default:\\n\");\n        builder.append(TAB + TAB + TAB + TAB + TAB + \"assert false : \\\"Invalid id \\\" + field.getFieldId() + \\\" of field \\\" + field.getDescription() + \\\" in \")\n                .append(className).append(\".\\\";\\n\");\n        builder.append(TAB + TAB + TAB + \"}\\n\");\n        builder.append(TAB + TAB + TAB + \"index++;\\n\");\n        builder.append(TAB + TAB + \"}\\n\");\n        builder.append(TAB + TAB + \"return newOne;\\n\");\n        builder.append(TAB + \"}\\n\\n\");\n    }\n\n    private void generateBindObject() {\n        builder.append(TAB + \"@Override\\n\");\n        builder.append(TAB + \"public void bindField(\").append(className).append(\" object, Field<\")\n                .append(className).append(\"> field, int index, PreparedStatement preparedStatement) {\\n\");\n        builder.append(TAB + TAB + \"switch (field.getFieldId()) {\\n\");\n        int index = 1;\n        for (ColumnInfo columnInfo : allColumnInfo) {\n            String type = columnInfo.getPropertyType();\n            JavaFieldORMInfo info = JavaFieldORMInfo.allInfo.get(type);\n            String field = columnInfo.getPropertyName();\n            assert info != null;\n\n            builder.append(TAB + TAB + TAB + \"case \").append(index).append(\":\\n\");\n            if (info.nullable) {\n                builder.append(TAB + TAB + TAB + TAB + \"if ( object.\").append(field)\n                        .append(\" != null ) {\\n\");\n                builder.append(TAB + TAB + TAB + TAB + TAB + \"preparedStatement.\").append(info.fieldGetter)\n                        .append(\"(object.\").append(field).append(\", index);\\n\");\n                builder.append(TAB + TAB + TAB + TAB + \"} else {\\n\");\n                builder.append(TAB + TAB + TAB + TAB + TAB + \"preparedStatement.bindNull(index);\\n\");\n                builder.append(TAB + TAB + TAB + TAB + \"}\\n\");\n            } else {\n                builder.append(TAB + TAB + TAB + TAB + \"preparedStatement.\").append(info.fieldGetter)\n                        .append(\"(object.\").append(field).append(\", index);\\n\");\n            }\n\n            builder.append(TAB + TAB + TAB + TAB + \"break;\\n\");\n\n            index++;\n        }\n\n        builder.append(TAB + TAB + TAB + \"default:\\n\");\n        builder.append(TAB + TAB + TAB + TAB + \"assert false : \\\"Invalid id \\\" + field.getFieldId() + \\\" of field \\\" + field.getDescription() + \\\" in \")\n                .append(className).append(\".\\\";\\n\");\n        builder.append(TAB + TAB + \"}\\n\");\n        builder.append(TAB + \"}\\n\\n\");\n    }\n\n    private void generateAutoIncrementConfig() {\n        builder.append(TAB + \"@Override\\n\");\n        builder.append(TAB + \"public boolean isAutoIncrement(\").append(className).append(\" object) {\\n\");\n        ColumnInfo autoIncrementColumn = null;\n        for (ColumnInfo info : allColumnInfo) {\n            if (info.isAutoIncrement() && info.isPrimary()) {\n                autoIncrementColumn = info;\n                break;\n            }\n        }\n        if (autoIncrementColumn != null) {\n            builder.append(TAB + TAB + \"return object.\").append(autoIncrementColumn.getPropertyName()).append(\" == 0;\\n\");\n        } else {\n            builder.append(TAB + TAB + \"return false;\\n\");\n        }\n        builder.append(TAB + \"}\\n\\n\");\n\n        builder.append(TAB + \"@Override\\n\");\n        builder.append(TAB + \"public void setLastInsertRowId(\").append(className).append(\" object, long lastInsertRowId) {\\n\");\n        if (autoIncrementColumn != null) {\n            builder.append(TAB + TAB + \"object.\").append(autoIncrementColumn.getPropertyName())\n                    .append(\" = (\").append(autoIncrementColumn.getPropertyType()).append(\") lastInsertRowId;\\n\");\n        }\n        builder.append(TAB + \"}\\n\\n\");\n    }\n}\n"
  },
  {
    "path": "src/java/builder/compiler/src/main/java/com/tencent/wcdb/compiler/JavaFieldORMInfo.java",
    "content": "// Created by qiuwenchen on 2023/4/23.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdb.compiler;\n\nimport java.util.HashMap;\nimport java.util.Set;\n\npublic final class JavaFieldORMInfo {\n    public static final HashMap<String, JavaFieldORMInfo> allInfo = new HashMap<String, JavaFieldORMInfo>() {\n        {\n            put(\"boolean\", new JavaFieldORMInfo(\"Integer\", false, \"bindBool\", \"preparedStatement.getBool\"));\n            put(\"java.lang.Boolean\", new JavaFieldORMInfo(\"Integer\", true, \"bindBool\", \"preparedStatement.getBool\"));\n            put(\"byte\", new JavaFieldORMInfo(\"Integer\", false, \"bindInteger\", \"preparedStatement.getByte\"));\n            put(\"java.lang.Byte\", new JavaFieldORMInfo(\"Integer\", true, \"bindInteger\", \"preparedStatement.getByte\"));\n            put(\"short\", new JavaFieldORMInfo(\"Integer\", false, \"bindInteger\", \"preparedStatement.getShort\"));\n            put(\"java.lang.Short\", new JavaFieldORMInfo(\"Integer\", true, \"bindInteger\", \"preparedStatement.getShort\"));\n            put(\"int\", new JavaFieldORMInfo(\"Integer\", false, \"bindInteger\", \"preparedStatement.getInt\"));\n            put(\"java.lang.Integer\", new JavaFieldORMInfo(\"Integer\", true, \"bindInteger\", \"preparedStatement.getInt\"));\n            put(\"long\", new JavaFieldORMInfo(\"Integer\", false, \"bindInteger\", \"preparedStatement.getLong\"));\n            put(\"java.lang.Long\", new JavaFieldORMInfo(\"Integer\", true, \"bindInteger\", \"preparedStatement.getLong\"));\n            put(\"float\", new JavaFieldORMInfo(\"Float\", false, \"bindDouble\", \"preparedStatement.getFloat\"));\n            put(\"java.lang.Float\", new JavaFieldORMInfo(\"Float\", true, \"bindDouble\", \"preparedStatement.getFloat\"));\n            put(\"double\", new JavaFieldORMInfo(\"Float\", false, \"bindDouble\", \"preparedStatement.getDouble\"));\n            put(\"java.lang.Double\", new JavaFieldORMInfo(\"Float\", true, \"bindDouble\", \"preparedStatement.getDouble\"));\n            put(\"java.lang.String\", new JavaFieldORMInfo(\"Text\", true, \"bindText\", \"preparedStatement.getText\"));\n            put(\"byte[]\", new JavaFieldORMInfo(\"BLOB\", true, \"bindBLOB\", \"preparedStatement.getBLOB\"));\n        }\n    };\n\n    public static final Set<String> allTypes = allInfo.keySet();\n\n    private JavaFieldORMInfo(String type, boolean nullable, String getter, String setter) {\n        this.columnType = type;\n        this.nullable = nullable;\n        this.fieldGetter = getter;\n        this.fieldSetter = setter;\n    }\n\n    String columnType;\n    boolean nullable;\n    String fieldGetter;\n    String fieldSetter;\n}\n"
  },
  {
    "path": "src/java/builder/compiler/src/main/java/com/tencent/wcdb/compiler/KotlinAnnotationProcessor.kt",
    "content": "// Created by qiuwenchen on 2023/6/20.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdb.compiler\n\nimport com.google.devtools.ksp.processing.*\nimport com.google.devtools.ksp.symbol.*\nimport com.google.devtools.ksp.validate\nimport com.tencent.wcdb.WCDBDefault\nimport com.tencent.wcdb.WCDBField\nimport com.tencent.wcdb.WCDBIndex\nimport com.tencent.wcdb.WCDBTableCoding\nimport com.tencent.wcdb.compiler.resolvedInfo.ColumnInfo\nimport com.tencent.wcdb.compiler.resolvedInfo.FTSModuleInfo\nimport com.tencent.wcdb.compiler.resolvedInfo.TableConfigInfo\nimport kotlin.reflect.KClass\n\nconst val OPTION_VERBOSE = \"verbose\"\n\ninternal class KotlinAnnotationProcessor(private val environment: SymbolProcessorEnvironment) :\n    KSVisitorVoid(), SymbolProcessor {\n    class Provider : SymbolProcessorProvider {\n        override fun create(environment: SymbolProcessorEnvironment): SymbolProcessor {\n            return KotlinAnnotationProcessor(environment)\n        }\n    }\n\n    private var verbose = false\n    private var isKotlin = false\n    private var primaryKeyCount = 0;\n    private var tableConstraintInfo: TableConfigInfo? = null\n    private val allPropertyInfo = mutableListOf<ColumnInfo>()\n\n    override fun process(resolver: Resolver): List<KSAnnotated> {\n        environment.logger.warn(\"WCDB KSP Processing\")\n        verbose = environment.options.contains(OPTION_VERBOSE)\n        val symbols = resolver.getSymbolsWithAnnotation(WCDBTableCoding::class.qualifiedName!!)\n        val ret = mutableListOf<KSAnnotated>()\n        symbols.toList().forEach {\n            if (!it.validate())\n                ret.add(it)\n            else\n                it.accept(this, Unit)\n        }\n        return ret\n    }\n\n    override fun visitClassDeclaration(classDeclaration: KSClassDeclaration, data: Unit) {\n\n        verboseLog(\"WCDB Processing: ${classDeclaration.qualifiedName!!.asString()}\")\n\n        if (!checkClass(classDeclaration)) {\n            return\n        }\n\n        tableConstraintInfo = TableConfigInfo.resolve(\n            getAnnotation(classDeclaration, WCDBTableCoding::class),\n            environment.logger\n        )\n        if (tableConstraintInfo == null) {\n            environment.logger.error(\n                \"Failed to resolve @WCDBTableCoding in ${classDeclaration.qualifiedName!!.asString()}!\",\n                classDeclaration\n            )\n            return\n        }\n        isKotlin = classDeclaration.containingFile!!.fileName.endsWith(\".kt\")\n        primaryKeyCount = 0;\n        allPropertyInfo.clear()\n\n        for (property in classDeclaration.getAllProperties()) {\n\n            val fieldAnnotation = getAnnotation(property, WCDBField::class) ?: continue\n            val indexAnnotation = getAnnotation(property, WCDBIndex::class)\n            val defaultValueAnnotation = getAnnotation(property, WCDBDefault::class)\n\n            val resolvedColumnInfo =\n                ColumnInfo.resolve(\n                    property,\n                    fieldAnnotation,\n                    indexAnnotation,\n                    defaultValueAnnotation,\n                    environment.logger\n                )\n                    ?: return\n\n            if (!checkProperty(property, resolvedColumnInfo)) return\n\n            verboseLog(\"Found WCDBField: ${property.simpleName.asString()}\")\n            allPropertyInfo.add(resolvedColumnInfo)\n        }\n\n        if (!checkColumnInTableConstraint(classDeclaration)) {\n            return\n        }\n\n        if (allPropertyInfo.isNotEmpty()) {\n            createORMFile(classDeclaration)\n        }\n    }\n\n    private fun verboseLog(content: String) {\n        if (verbose) {\n            environment.logger.info(content)\n        }\n    }\n\n    private fun checkClass(classDeclaration: KSClassDeclaration): Boolean {\n        if (classDeclaration.classKind != ClassKind.CLASS) {\n            environment.logger.error(\n                \"@WCDBTableCoding can only be apply to normal class\",\n                classDeclaration\n            )\n            return false\n        }\n        val modifiers = classDeclaration.modifiers\n        if (modifiers.contains(Modifier.PRIVATE) || modifiers.contains(Modifier.PROTECTED)) {\n            environment.logger.error(\n                \"The class with annotation @WCDBTableCoding can not be private or protected\",\n                classDeclaration\n            )\n            return false\n        }\n        if (modifiers.contains(Modifier.ABSTRACT)) {\n            environment.logger.error(\n                \"The class with annotation @WCDBTableCoding can not be abstract\",\n                classDeclaration\n            )\n            return false\n        }\n        return true\n    }\n\n    private fun checkFTSModule(\n        classDeclaration: KSClassDeclaration,\n        ftsModuleInfo: FTSModuleInfo?\n    ): Boolean {\n        if (ftsModuleInfo == null) {\n            return true\n        }\n        if (ftsModuleInfo.ftsVersion.isEmpty()) {\n            if (ftsModuleInfo.tokenizer.isNotEmpty() || ftsModuleInfo.tokenizerParameters.isNotEmpty()) {\n                environment.logger.error(\n                    \"You need to config fts version in @FTSModule\",\n                    classDeclaration\n                )\n                return false\n            }\n            return true\n        }\n        if (ftsModuleInfo.tokenizer.isEmpty()) {\n            environment.logger.error(\n                \"You need to config a tokenizer in @FTSModule\",\n                classDeclaration\n            )\n            return false\n        }\n        return true\n    }\n\n    private fun <T : Any> getAnnotation(\n        declaration: KSDeclaration,\n        annotationClass: KClass<T>\n    ): KSAnnotation? {\n        return declaration.annotations.find {\n            it.shortName.asString() == annotationClass.simpleName!! &&\n                    it.annotationType.resolve().declaration.qualifiedName!!.asString() == annotationClass.qualifiedName!!\n        }\n    }\n\n    private fun checkProperty(\n        declaration: KSPropertyDeclaration,\n        columnInfo: ColumnInfo\n    ): Boolean {\n        val modifier = declaration.modifiers\n        if (modifier.contains(Modifier.PRIVATE) || modifier.contains(Modifier.PROTECTED)) {\n            environment.logger.error(\n                \"The field with annotation @WCDBField can not be private or protected\",\n                declaration\n            )\n            return false\n        }\n        if (!AllKotlinPropertyTypes.contains(columnInfo.propertyType)) {\n            var message = \"\"\"\n                    The type ${columnInfo.propertyType} of field ${declaration.simpleName.asString()} in \n                    ${declaration.parentDeclaration!!.qualifiedName!!.asString()} is Unsupported!\n                    \"\"\"\n            message += if (!isKotlin) {\n                \"WCDB only supports Java basic types and byte[].\"\n            } else {\n                \"WCDB only supports Kotlin basic types and ByteArray.\"\n            }\n            environment.logger.error(message, declaration)\n            return false\n        }\n        if (columnInfo.isPrimary) {\n            primaryKeyCount++\n            if (primaryKeyCount > 1) {\n                val message = \"\"\"@WCDBField can only configure one primary key in \n                    ${declaration.parentDeclaration!!.qualifiedName!!.asString()}. \n                    If multiple primary keys are required, configure multiPrimaries in @WCDBTableCoding. \n                    \"\"\"\n                environment.logger.error(message, declaration)\n                return false\n            }\n            if (columnInfo.isAutoIncrement) {\n                if (AllKotlinPropertyORMInfo[columnInfo.propertyType]?.columnType != \"Integer\") {\n                    environment.logger.error(\"Auto-increment field must be integer\", declaration)\n                    return false\n                }\n            }\n            if (columnInfo.hasIndex) {\n                environment.logger.error(\n                    \"${declaration.simpleName.asString()} is confined as primary key, so it does not need to configure @WCDBIndex\",\n                    declaration\n                )\n                return false\n            }\n        } else if (columnInfo.isAutoIncrement) {\n            environment.logger.error(\n                \"Only the primary key can be configured as auto-increment\",\n                declaration\n            )\n            return false\n        }\n        if (columnInfo.defaultValue != null) {\n            var valueCount = 0\n            val columnType = AllKotlinPropertyORMInfo[columnInfo.propertyType]!!.columnType\n            var typeMissMatch = false\n            if (columnInfo.defaultValue!!.intValue != 0L) {\n                valueCount++\n                if (columnType != \"Integer\") {\n                    typeMissMatch = true\n                }\n            }\n            if (columnInfo.defaultValue!!.doubleValue != 0.0) {\n                valueCount++\n                if (columnType != \"Float\") {\n                    typeMissMatch = true\n                }\n            }\n            if (columnInfo.defaultValue!!.textValue.isNotEmpty()) {\n                valueCount++\n                if (columnType != \"Text\") {\n                    typeMissMatch = true\n                }\n            }\n            if (valueCount > 1) {\n                environment.logger.error(\n                    \"Only one default value can be configured for a field\",\n                    declaration\n                )\n                return false\n            } else if (typeMissMatch) {\n                if (columnType == \"BLOB'\") {\n                    environment.logger.error(\n                        \"Assigning a default value to BLOB is unsupported\",\n                        declaration\n                    )\n                } else {\n                    environment.logger.error(\n                        \"Default value should be a $columnType\",\n                        declaration\n                    )\n                }\n                return false\n            }\n        }\n        return true\n    }\n\n    private fun checkColumnInTableConstraint(classDeclaration: KSClassDeclaration): Boolean {\n        if (tableConstraintInfo!!.multiIndexes.isEmpty() &&\n            tableConstraintInfo!!.multiPrimaries.isEmpty() &&\n            tableConstraintInfo!!.multiUnique.isEmpty()\n        ) {\n            return true;\n        }\n\n        val allColumns = allPropertyInfo.map { columnInfo ->\n            if (columnInfo.columnName.isEmpty()) columnInfo.propertyName else columnInfo.columnName\n        }.toSet()\n\n        for (multiIndexes in tableConstraintInfo!!.multiIndexes) {\n            for (column in multiIndexes.columns) {\n                if (!allColumns.contains(column)) {\n                    environment.logger.error(\n                        \"Can't find column \\\"$column\\\" in class orm config.\",\n                        classDeclaration\n                    )\n                    return false\n                }\n            }\n        }\n\n        for (multiPrimaries in tableConstraintInfo!!.multiPrimaries) {\n            for (column in multiPrimaries.columns) {\n                if (!allColumns.contains(column)) {\n                    environment.logger.error(\n                        \"Can't find column \\\"$column\\\" in class orm config.\",\n                        classDeclaration\n                    )\n                    return false\n                }\n            }\n        }\n\n        for (multiUnique in tableConstraintInfo!!.multiUnique) {\n            for (column in multiUnique.columns) {\n                if (!allColumns.contains(column)) {\n                    environment.logger.error(\n                        \"Can't find column \\\"$column\\\" in class orm config.\",\n                        classDeclaration\n                    )\n                    return false\n                }\n            }\n        }\n        return true\n    }\n\n    private fun createORMFile(classDeclaration: KSClassDeclaration) {\n        val className = classDeclaration.simpleName.asString()\n        val ormClassName = \"DB${className}\"\n        val packageName = classDeclaration.containingFile!!.packageName.asString()\n        val code: String\n\n        if (isKotlin) {\n            val codeGenerator = KotlinCodeGenerator()\n            codeGenerator.packageName = packageName\n            codeGenerator.className = className\n            codeGenerator.ormClassName = ormClassName\n            codeGenerator.tableConstraintInfo = tableConstraintInfo!!\n            codeGenerator.allColumnInfo = allPropertyInfo\n            code = codeGenerator.generate()\n        } else {\n            for (propertyInfo in allPropertyInfo) {\n                propertyInfo.propertyType = K2JTypeMap[propertyInfo.propertyType]!!\n            }\n            val codeGenerator = JavaCodeGenerator()\n            codeGenerator.packageName = packageName\n            codeGenerator.className = className\n            codeGenerator.ormClassName = ormClassName\n            codeGenerator.tableConstraintInfo = tableConstraintInfo\n            codeGenerator.allColumnInfo = allPropertyInfo\n            code = codeGenerator.generate()\n        }\n\n        val file = environment.codeGenerator.createNewFile(\n            Dependencies(\n                false,\n                classDeclaration.containingFile!!\n            ),\n            packageName,\n            ormClassName,\n            if (isKotlin) \"kt\" else \"java\"\n        )\n        file.write(code.toByteArray())\n        file.close()\n    }\n}"
  },
  {
    "path": "src/java/builder/compiler/src/main/java/com/tencent/wcdb/compiler/KotlinCodeGenerator.kt",
    "content": "// Created by qiuwenchen on 2023/6/25.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdb.compiler\n\nimport com.tencent.wcdb.compiler.resolvedInfo.ColumnInfo\nimport com.tencent.wcdb.compiler.resolvedInfo.TableConfigInfo\n\nprivate const val TAB = \"\\t\"\n\nclass KotlinCodeGenerator {\n    lateinit var packageName: String\n    lateinit var className: String\n    lateinit var ormClassName: String\n    lateinit var tableConstraintInfo: TableConfigInfo\n    lateinit var allColumnInfo: List<ColumnInfo>\n    private lateinit var builder: StringBuilder\n\n    fun generate(): String {\n        builder = StringBuilder()\n        builder.append(\"package $packageName\\n\\n\")\n        generateImport()\n        builder.append(\"object $ormClassName: TableBinding<$className> {\\n\")\n\n        builder.append(\"${TAB}private final val baseBinding: Binding\\n\")\n        generateFields()\n        builder.append(\"\\n${TAB}init {\\n\")\n        builder.append(\"$TAB${TAB}baseBinding = Binding()\\n\")\n        generateColumns()\n        generateTableConfig()\n        builder.append(\"$TAB}\\n\\n\")\n\n        generateBindingType()\n        generateBindingFields()\n        generateBaseBinding()\n        generateExtractObject()\n        generateBindObject()\n        generateAutoIncrementConfig()\n        builder.append(\"}\\n\\n\")\n        return builder.toString()\n    }\n\n    private fun generateImport() {\n        builder.append(\"import com.tencent.wcdb.core.PreparedStatement\\n\")\n        builder.append(\"import com.tencent.wcdb.orm.*\\n\")\n        builder.append(\"import com.tencent.wcdb.winq.Column\\n\")\n        builder.append(\"import com.tencent.wcdb.winq.ColumnConstraint\\n\")\n        builder.append(\"import com.tencent.wcdb.winq.ColumnDef\\n\")\n        builder.append(\"import com.tencent.wcdb.winq.ColumnType\\n\")\n        builder.append(\"import com.tencent.wcdb.winq.StatementCreateIndex\\n\")\n        builder.append(\"import com.tencent.wcdb.winq.TableConstraint\\n\\n\")\n    }\n\n    private fun generateFields() {\n        for ((propertyName) in allColumnInfo) {\n            builder.append(\"${TAB}@JvmField\\n\")\n            builder.append(\"${TAB}final val $propertyName : Field<$className>\\n\")\n        }\n    }\n\n    private fun generateColumns() {\n        var fieldId = 1\n        for (columnInfo in allColumnInfo) {\n            val ormInfo = AllKotlinPropertyORMInfo[columnInfo.propertyType]!!\n            val propertyName = columnInfo.propertyName\n            var columnName = columnInfo.columnName\n            if (columnName.isEmpty()) {\n                columnName = propertyName\n            }\n\n            builder.append(\n                \"$TAB$TAB${propertyName} = Field(\\\"$columnName\\\", this, \" +\n                        \"$fieldId, ${columnInfo.isPrimary && columnInfo.isAutoIncrement}, \" +\n                        \"${columnInfo.isPrimary})\\n\"\n            )\n            fieldId++\n\n            builder.append(\"$TAB${TAB}val ${propertyName}Def = ColumnDef($propertyName, ColumnType.${ormInfo.columnType})\\n\")\n\n            val constraintPrefix =\n                \"$TAB$TAB${propertyName}Def.constraint(\\n$TAB$TAB${TAB}ColumnConstraint()\"\n            if (columnInfo.isPrimary) {\n                builder.append(constraintPrefix).append(\".primaryKey()\")\n                    .append(if (columnInfo.isAutoIncrement) \".autoIncrement()\\n$TAB$TAB)\\n\" else \"\\n$TAB$TAB)\\n\")\n            }\n            if (columnInfo.defaultValue != null) {\n                if (ormInfo.columnType == \"Integer\") {\n                    builder.append(constraintPrefix)\n                        .append(\".defaultTo(${columnInfo.defaultValue!!.intValue})\\n$TAB$TAB)\\n\")\n                } else if (ormInfo.columnType == \"Float\") {\n                    builder.append(constraintPrefix)\n                        .append(\".defaultTo(${columnInfo.defaultValue!!.doubleValue})\\n$TAB$TAB)\\n\")\n                } else {\n                    builder.append(constraintPrefix)\n                        .append(\".defaultTo(\\\"${columnInfo.defaultValue!!.textValue}\\\")\\n$TAB$TAB)\\n\")\n                }\n            }\n            if (columnInfo.isUnique) {\n                builder.append(constraintPrefix).append(\".unique()\\n$TAB$TAB)\\n\")\n            }\n            if (columnInfo.isNotNull) {\n                builder.append(constraintPrefix).append(\".notNull()\\n$TAB$TAB)\\n\")\n            }\n            if (columnInfo.isNotIndexed) {\n                builder.append(constraintPrefix).append(\".unIndex()\\n$TAB$TAB)\\n\")\n            }\n            builder.append(\"$TAB${TAB}baseBinding.addColumnDef(${propertyName}Def)\\n\")\n\n            if (columnInfo.enableAutoIncrementForExistingTable) {\n                builder.append(\"$TAB${TAB}baseBinding.enableAutoIncrementForExistingTable()\\n\")\n            }\n\n            if (!columnInfo.hasIndex) {\n                continue\n            }\n            var indexName = columnInfo.indexName\n            var isFullName = true\n            if (indexName.isEmpty()) {\n                indexName = \"_${columnName}_index\"\n                isFullName = false\n            }\n            builder.append(\"$TAB${TAB}baseBinding.addIndex(\\\"$indexName\\\" , $isFullName, StatementCreateIndex().ifNotExist()\")\n            if (columnInfo.indexIsUnique) {\n                builder.append(\".unique()\")\n            }\n            builder.append(\".indexedBy($propertyName))\\n\\n\")\n        }\n    }\n\n    private fun generateTableConfig() {\n        val allColumns: MutableMap<String, ColumnInfo> = HashMap()\n        for (columnInfo in allColumnInfo) {\n            allColumns[columnInfo.columnName.ifEmpty { columnInfo.propertyName }] = columnInfo\n        }\n        for ((name, columns) in tableConstraintInfo.multiIndexes) {\n            var indexName = name\n            var isFullName = true\n            if (indexName.isEmpty()) {\n                indexName = columns.joinToString(\"_\", \"_\", \"_index\")\n                isFullName = false\n            }\n            builder.append(\"$TAB${TAB}baseBinding.addIndex(\\\"$indexName\\\", $isFullName, StatementCreateIndex().ifNotExist().indexedBy(\\n$TAB$TAB$TAB\")\n            for (column in columns) {\n                builder.append(allColumns[column]!!.propertyName).append(\", \")\n            }\n            builder.append(\"\\n$TAB$TAB))\\n\")\n        }\n        for ((columns) in tableConstraintInfo.multiPrimaries) {\n            builder.append(\"$TAB${TAB}baseBinding.addTableConstraint(TableConstraint().primaryKey().indexedBy(\\n$TAB$TAB$TAB\")\n            for (column in columns) {\n                builder.append(allColumns[column]!!.propertyName).append(\", \")\n            }\n            builder.append(\"\\n$TAB$TAB))\\n\")\n        }\n        for ((columns) in tableConstraintInfo.multiUnique) {\n            builder.append(\"$TAB${TAB}baseBinding.addTableConstraint(TableConstraint().unique().indexedBy(\\n$TAB$TAB$TAB\")\n            for (column in columns) {\n                builder.append(allColumns[column]!!.propertyName).append(\", \")\n            }\n            builder.append(\"\\n$TAB$TAB))\\n\")\n        }\n        if (tableConstraintInfo.isWithoutRowId) {\n            builder.append(\"$TAB${TAB}baseBinding.configWithoutRowId()\")\n        }\n\n        val ftsModuleInfo = tableConstraintInfo.ftsModule\n        if (ftsModuleInfo == null || ftsModuleInfo.ftsVersion.isEmpty()) {\n            return\n        }\n\n        builder.append(\"$TAB${TAB}baseBinding.configVirtualModule(\\\"${ftsModuleInfo.ftsVersion}\\\")\\n\")\n\n        val tokenizer = java.lang.StringBuilder(\"tokenize = \")\n        tokenizer.append(ftsModuleInfo.tokenizer)\n        for (para in ftsModuleInfo.tokenizerParameters) {\n            tokenizer.append(\" \").append(para)\n        }\n        builder.append(\"$TAB${TAB}baseBinding.configVirtualModuleArgument(\\\"$tokenizer\\\")\\n\")\n        if (ftsModuleInfo.externalTable.isNotEmpty()) {\n            builder.append(\"$TAB${TAB}baseBinding.configVirtualModuleArgument(\\\"content='${ftsModuleInfo.externalTable}'\\\");\\n\")\n        }\n    }\n\n    private fun generateBindingType() {\n        builder.append(\"${TAB}override fun bindingType() = $className::class.java\\n\")\n    }\n\n    private fun generateBindingFields() {\n        builder.append(\"${TAB}override fun allBindingFields() = allFields()\\n\")\n        builder.append(\"${TAB}@JvmStatic\\n\")\n        builder.append(\"${TAB}fun allFields() = arrayOf(\")\n        for ((propertyName) in allColumnInfo) {\n            builder.append(propertyName).append(\", \")\n        }\n        builder.append(\")\\n\")\n    }\n\n    private fun generateBaseBinding() {\n        builder.append(\"${TAB}override fun baseBinding() = baseBinding\\n\")\n    }\n\n    private fun generateExtractObject() {\n        builder.append(\"${TAB}override fun <R : $className> extractObject(\\n\")\n        builder.append(\"$TAB${TAB}fields: Array<Field<$className>>,\\n\")\n        builder.append(\"$TAB${TAB}preparedStatement: PreparedStatement,\\n\")\n        builder.append(\"$TAB${TAB}cls: Class<R>\\n\")\n        builder.append(\"$TAB): R  {\\n\")\n        builder.append(\"$TAB${TAB}val newOne = cls.newInstance()\\n\")\n        builder.append(\"$TAB${TAB}var index = 0\\n\")\n        builder.append(\"$TAB${TAB}for (field in fields) {\\n\")\n        builder.append(\"$TAB$TAB${TAB}when (field.fieldId) {\\n\")\n        var index = 1\n        for ((propertyName, propertyType, nullable) in allColumnInfo) {\n            val info = AllKotlinPropertyORMInfo[propertyType]!!\n            if (nullable) {\n                builder.append(\"$TAB$TAB$TAB$TAB${index} -> {\\n\")\n                builder.append(\"$TAB$TAB$TAB$TAB${TAB}if ( preparedStatement.getColumnType(index) != ColumnType.Null) {\\n\")\n                builder.append(\"$TAB$TAB$TAB$TAB$TAB${TAB}newOne.$propertyName = preparedStatement.${info.setter}\\n\")\n                builder.append(\"$TAB$TAB$TAB$TAB${TAB}}\\n\")\n                builder.append(\"$TAB$TAB$TAB${TAB}}\\n\")\n            } else {\n                builder.append(\"$TAB$TAB$TAB$TAB${index} -> newOne.$propertyName = preparedStatement.${info.setter}\\n\")\n            }\n            index++\n        }\n        builder.append(\"$TAB$TAB$TAB${TAB}else -> assert(false) {\\n\")\n        builder.append(\"$TAB$TAB$TAB$TAB$TAB\\\"Invalid id \\\" + field.getFieldId() + \\\" of field \\\" + field.getDescription() + \\\" in $className.\\\"\\n\")\n        builder.append(\"$TAB$TAB$TAB$TAB}\\n\")\n        builder.append(\"$TAB$TAB$TAB}\\n\")\n        builder.append(\"$TAB$TAB${TAB}index++\\n\")\n        builder.append(\"$TAB$TAB}\\n\")\n        builder.append(\"$TAB${TAB}return newOne\\n\")\n        builder.append(\"$TAB}\\n\\n\")\n    }\n\n    private fun generateBindObject() {\n        builder.append(\"${TAB}override fun bindField(\\n\")\n        builder.append(\"$TAB${TAB}`object`: $className,\\n\")\n        builder.append(\"$TAB${TAB}field: Field<$className>,\\n\")\n        builder.append(\"$TAB${TAB}index: Int,\\n\")\n        builder.append(\"$TAB${TAB}preparedStatement: PreparedStatement\\n\")\n        builder.append(\"$TAB) {\\n\")\n        builder.append(\"$TAB${TAB}when (field.fieldId) {\\n\")\n        var index = 1\n        for ((propertyName, propertyType, nullable) in allColumnInfo) {\n            val info = AllKotlinPropertyORMInfo[propertyType]!!\n            if (nullable) {\n                builder.append(\"$TAB$TAB$TAB${index} -> {\\n\")\n                builder.append(\"$TAB$TAB$TAB${TAB}if (`object`.$propertyName != null) {\\n\")\n                builder.append(\"$TAB$TAB$TAB$TAB${TAB}preparedStatement.${info.getter}(`object`.$propertyName, index)\\n\")\n                builder.append(\"$TAB$TAB$TAB${TAB}} else {\\n\")\n                builder.append(\"$TAB$TAB$TAB$TAB${TAB}preparedStatement.bindNull(index)\\n\")\n                builder.append(\"$TAB$TAB$TAB${TAB}}\\n\")\n                builder.append(\"$TAB$TAB${TAB}}\\n\")\n            } else {\n                builder.append(\"$TAB$TAB$TAB${index} -> preparedStatement.${info.getter}(`object`.$propertyName, index)\\n\")\n            }\n            index++\n        }\n        builder.append(\"$TAB$TAB${TAB}else -> assert(false) {\\n\")\n        builder.append(\"$TAB$TAB$TAB$TAB\\\"Invalid id \\\" + field.getFieldId() + \\\" of field \\\" + field.getDescription() + \\\" in $className.\\\"\\n\")\n        builder.append(\"$TAB$TAB$TAB}\\n\")\n        builder.append(\"$TAB$TAB}\\n\")\n        builder.append(\"$TAB}\\n\\n\")\n    }\n\n    private fun generateAutoIncrementConfig() {\n        builder.append(\"${TAB}override fun isAutoIncrement(`object`: $className): Boolean {\\n\")\n        var autoIncrementColumn: ColumnInfo? = null\n        for (info in allColumnInfo) {\n            if (info.isAutoIncrement && info.isPrimary) {\n                autoIncrementColumn = info\n                break\n            }\n        }\n        if (autoIncrementColumn != null) {\n            val propertyType = autoIncrementColumn.propertyType\n            when (propertyType) {\n                \"kotlin.Long\" -> {\n                    builder.append(\"$TAB${TAB}return `object`.${autoIncrementColumn.propertyName} == 0L\\n\")\n                }\n                else -> {\n                    builder.append(\"$TAB${TAB}return `object`.${autoIncrementColumn.propertyName} == 0\\n\")\n                }\n            }\n        } else {\n            builder.append(\"$TAB${TAB}return false\\n\")\n        }\n        builder.append(\"$TAB}\\n\\n\")\n\n        builder.append(\"${TAB}override fun setLastInsertRowId(`object`: $className, lastInsertRowId: Long) {\\n\")\n        if (autoIncrementColumn != null) {\n            var convert = \"\"\n            when (autoIncrementColumn.propertyType) {\n                Char::class.qualifiedName!! -> convert = \".toInt().toChar()\"\n                Byte::class.qualifiedName!! -> convert = \".toByte()\"\n                Short::class.qualifiedName!! -> convert = \".toShort()\"\n                Int::class.qualifiedName!! -> convert = \".toInt()\"\n            }\n            builder.append(\"$TAB${TAB}`object`.${autoIncrementColumn.propertyName} = lastInsertRowId$convert\\n\")\n        }\n        builder.append(\"$TAB}\\n\\n\")\n    }\n}"
  },
  {
    "path": "src/java/builder/compiler/src/main/java/com/tencent/wcdb/compiler/KotlinPropertyORMInfo.kt",
    "content": "// Created by qiuwenchen on 2023/6/20.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdb.compiler\n\ninternal val AllKotlinPropertyORMInfo = mapOf<String, KotlinPropertyORMInfo>(\n    Boolean::class.qualifiedName!! to KotlinPropertyORMInfo(\n        \"Integer\",\n        \"bindBool\",\n        \"getBool(index)\"\n    ),\n    Byte::class.qualifiedName!! to KotlinPropertyORMInfo(\n        \"Integer\",\n        \"bindInteger\",\n        \"getByte(index)\"\n    ),\n    Short::class.qualifiedName!! to KotlinPropertyORMInfo(\n        \"Integer\",\n        \"bindInteger\",\n        \"getShort(index)\"\n    ),\n    Int::class.qualifiedName!! to KotlinPropertyORMInfo(\"Integer\", \"bindInteger\", \"getInt(index)\"),\n    Long::class.qualifiedName!! to KotlinPropertyORMInfo(\n        \"Integer\",\n        \"bindInteger\",\n        \"getLong(index)\"\n    ),\n    Float::class.qualifiedName!! to KotlinPropertyORMInfo(\"Float\", \"bindDouble\", \"getFloat(index)\"),\n    Double::class.qualifiedName!! to KotlinPropertyORMInfo(\n        \"Float\",\n        \"bindDouble\",\n        \"getDouble(index)\"\n    ),\n    String::class.qualifiedName!! to KotlinPropertyORMInfo(\"Text\", \"bindText\", \"getText(index)\"),\n    ByteArray::class.qualifiedName!! to KotlinPropertyORMInfo(\"BLOB\", \"bindBLOB\", \"getBLOB(index)\"),\n)\n\ninternal val AllKotlinPropertyTypes = AllKotlinPropertyORMInfo.keys\n\ninternal val K2JTypeMap = mapOf<String, String>(\n    Boolean::class.qualifiedName!! to \"boolean\",\n    Byte::class.qualifiedName!! to \"byte\",\n    Short::class.qualifiedName!! to \"short\",\n    Int::class.qualifiedName!! to \"int\",\n    Long::class.qualifiedName!! to \"long\",\n    Float::class.qualifiedName!! to \"float\",\n    Double::class.qualifiedName!! to \"double\",\n    String::class.qualifiedName!! to \"java.lang.String\",\n    ByteArray::class.qualifiedName!! to \"byte[]\",\n)\n\ninternal data class KotlinPropertyORMInfo(\n    val columnType: String,\n    val getter: String,\n    val setter: String\n) {\n}"
  },
  {
    "path": "src/java/builder/compiler/src/main/java/com/tencent/wcdb/compiler/resolvedInfo/ColumnInfo.kt",
    "content": "// Created by qiuwenchen on 2023/6/21.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage com.tencent.wcdb.compiler.resolvedInfo\n\nimport com.google.devtools.ksp.processing.KSPLogger\nimport com.google.devtools.ksp.symbol.KSAnnotation\nimport com.google.devtools.ksp.symbol.KSPropertyDeclaration\nimport com.google.devtools.ksp.symbol.Nullability\nimport com.tencent.wcdb.WCDBDefault\nimport com.tencent.wcdb.WCDBField\nimport com.tencent.wcdb.WCDBIndex\nimport javax.lang.model.element.Element\n\ndata class ColumnInfo(\n    var propertyName: String = \"\",\n    var propertyType: String = \"\",\n    var nullable: Boolean = false,\n    var columnName: String = \"\",\n    var isPrimary: Boolean = false,\n    var isAutoIncrement: Boolean = false,\n    var enableAutoIncrementForExistingTable: Boolean = false,\n    var defaultValue: DefaultValueInfo? = null,\n    var isUnique: Boolean = false,\n    var isNotNull: Boolean = false,\n    var isNotIndexed: Boolean = false,\n    var hasIndex: Boolean = false,\n    var indexName: String = \"\",\n    var indexIsUnique: Boolean = false,\n) {\n    companion object {\n        fun resolve(\n            propertyDeclaration: KSPropertyDeclaration,\n            fieldAnnotation: KSAnnotation,\n            indexAnnotation: KSAnnotation?,\n            defaultValueAnnotation: KSAnnotation?,\n            logger: KSPLogger\n        ): ColumnInfo? {\n            val resolvedInfo = ColumnInfo()\n            resolvedInfo.propertyName = propertyDeclaration.simpleName.asString()\n            resolvedInfo.propertyType =\n                propertyDeclaration.type.resolve().declaration.qualifiedName!!.asString()\n            resolvedInfo.nullable =\n                propertyDeclaration.type.resolve().nullability == Nullability.NULLABLE\n            for (argument in fieldAnnotation.arguments) {\n                val value = argument.value ?: continue\n                when (argument.name?.asString()) {\n                    \"columnName\" -> resolvedInfo.columnName = value as String\n                    \"isPrimary\" -> resolvedInfo.isPrimary = value as Boolean\n                    \"isAutoIncrement\" -> resolvedInfo.isAutoIncrement = value as Boolean\n                    \"enableAutoIncrementForExistingTable\" -> resolvedInfo.enableAutoIncrementForExistingTable =\n                        value as Boolean\n\n                    \"isUnique\" -> resolvedInfo.isUnique = value as Boolean\n                    \"isNotNull\" -> resolvedInfo.isNotNull = value as Boolean\n                    \"isNotIndexed\" -> resolvedInfo.isNotIndexed = value as Boolean\n                    else -> {\n                        logger.error(\"Unrecognized field ${argument.name?.asString()} in WCDBField\")\n                        return null\n                    }\n                }\n            }\n            if (indexAnnotation != null) {\n                resolvedInfo.hasIndex = true\n                for (argument in indexAnnotation.arguments) {\n                    val value = argument.value ?: continue\n                    when (argument.name?.asString()) {\n                        \"name\" -> resolvedInfo.indexName = value as String\n                        \"isUnique\" -> resolvedInfo.indexIsUnique = value as Boolean\n                        else -> {\n                            logger.error(\"Unrecognized field ${argument.name?.asString()} in WCDBIndex\")\n                            return null\n                        }\n                    }\n                }\n            }\n            if (defaultValueAnnotation != null) {\n                resolvedInfo.defaultValue =\n                    DefaultValueInfo.resolve(defaultValueAnnotation, logger);\n            }\n\n            return resolvedInfo\n        }\n\n        fun resolve(\n            fieldElement: Element,\n            fieldAnnotation: WCDBField,\n            indexAnnotation: WCDBIndex?,\n            defaultValue: WCDBDefault?\n        ): ColumnInfo {\n            val resolvedInfo = ColumnInfo()\n            resolvedInfo.propertyName = fieldElement.toString()\n            resolvedInfo.propertyType = fieldElement.asType().toString()\n            resolvedInfo.columnName = fieldAnnotation.columnName\n            resolvedInfo.isPrimary = fieldAnnotation.isPrimary\n            resolvedInfo.isAutoIncrement = fieldAnnotation.isAutoIncrement\n            resolvedInfo.enableAutoIncrementForExistingTable =\n                fieldAnnotation.enableAutoIncrementForExistingTable\n            resolvedInfo.isUnique = fieldAnnotation.isUnique\n            resolvedInfo.isNotNull = fieldAnnotation.isNotNull\n            resolvedInfo.isNotIndexed = fieldAnnotation.isNotIndexed\n            if (indexAnnotation != null) {\n                resolvedInfo.hasIndex = true\n                resolvedInfo.indexName = indexAnnotation.name\n                resolvedInfo.indexIsUnique = indexAnnotation.isUnique\n            }\n            if (defaultValue != null) {\n                resolvedInfo.defaultValue = DefaultValueInfo.resolve(defaultValue)\n            }\n            return resolvedInfo\n        }\n    }\n}"
  },
  {
    "path": "src/java/builder/compiler/src/main/java/com/tencent/wcdb/compiler/resolvedInfo/DefaultValueInfo.kt",
    "content": "// Created by qiuwenchen on 2023/6/27.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdb.compiler.resolvedInfo\n\nimport com.google.devtools.ksp.processing.KSPLogger\nimport com.google.devtools.ksp.symbol.KSAnnotation\nimport com.tencent.wcdb.WCDBDefault\nimport javax.swing.LookAndFeel\n\ndata class DefaultValueInfo(\n    var intValue: Long = 0,\n    var doubleValue: Double = 0.0,\n    var textValue: String = \"\",\n) {\n    companion object {\n        fun resolve(defaultValueAnnotation: KSAnnotation, logger: KSPLogger): DefaultValueInfo? {\n            val resolvedInfo = DefaultValueInfo()\n            for (argument in defaultValueAnnotation.arguments) {\n                val value = argument.value ?: continue\n                when (argument.name?.asString()) {\n                    \"intValue\" -> {\n                        if (value is Int) {\n                            resolvedInfo.intValue = value.toLong()\n                        } else if (value is Long) {\n                            resolvedInfo.intValue = value\n                        } else {\n                            logger.error(\"Unrecognized int value type ${value::class} in WCDBDefault\")\n                            return null\n                        }\n                    }\n\n                    \"doubleValue\" -> resolvedInfo.doubleValue = value as Double\n                    \"textValue\" -> resolvedInfo.textValue = value as String\n                    else -> {\n                        logger.error(\"Unrecognized field ${argument.name?.asString()} in WCDBDefault\")\n                        return null\n                    }\n                }\n            }\n            return resolvedInfo\n        }\n\n        fun resolve(defaultValue: WCDBDefault): DefaultValueInfo {\n            val resolvedInfo = DefaultValueInfo()\n            resolvedInfo.intValue = defaultValue.intValue\n            resolvedInfo.doubleValue = defaultValue.doubleValue\n            resolvedInfo.textValue = defaultValue.textValue\n            return resolvedInfo\n        }\n    }\n}"
  },
  {
    "path": "src/java/builder/compiler/src/main/java/com/tencent/wcdb/compiler/resolvedInfo/FTSModuleInfo.kt",
    "content": "// Created by chenqiuwen on 2023/11/4.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdb.compiler.resolvedInfo\n\nimport com.google.devtools.ksp.processing.KSPLogger\nimport com.google.devtools.ksp.symbol.KSAnnotation\nimport com.google.devtools.ksp.symbol.KSClassDeclaration\nimport com.google.devtools.ksp.symbol.KSType\nimport com.google.devtools.ksp.symbol.KSTypeParameter\nimport com.tencent.wcdb.*\n\ndata class FTSModuleInfo(\n    var ftsVersion: String = \"\",\n    var tokenizer: String = \"\",\n    var tokenizerParameters: MutableList<String> = mutableListOf(),\n    var externalTable: String = \"\",\n) {\n    companion object {\n        fun resolve(annotation: KSAnnotation?, logger: KSPLogger): FTSModuleInfo? {\n            if (annotation == null) {\n                return null\n            }\n            assert(annotation.shortName.asString() == \"FTSModule\")\n            val resolvedInfo = FTSModuleInfo()\n            for (argument in annotation.arguments) {\n                val value = argument.value ?: continue\n                when (argument.name?.asString()) {\n                    \"version\" -> {\n                        val valueName = when (value) {\n                            is KSType -> value.declaration.toString()\n                            is KSClassDeclaration -> value.simpleName.asString()\n                            else -> {\n                                logger.error(\"Invalid type of 'version' argument value\")\n                                return null\n                            }\n                        }\n                        when (valueName) {\n                            FTSVersion.NONE.name -> resolvedInfo.ftsVersion = \"\"\n                            FTSVersion.FTS3.name -> resolvedInfo.ftsVersion = \"fts3\"\n                            FTSVersion.FTS4.name -> resolvedInfo.ftsVersion = \"fts4\"\n                            FTSVersion.FTS5.name -> resolvedInfo.ftsVersion = \"fts5\"\n                            else -> {\n                                logger.error(\"Unrecognized FTSVersion ${valueName} in FTSModule\")\n                                return null\n                            }\n                        }\n                    }\n\n                    \"tokenizer\" -> resolvedInfo.tokenizer = value as String\n                    \"tokenizerParameters\" -> {\n                        if (!resolveValueToList(\n                                value,\n                                String::class,\n                                resolvedInfo.tokenizerParameters\n                            )\n                        ) {\n                            logger.error(\n                                \"Unresolved tokenizerParameters $value \" +\n                                        \"with type ${value::class.qualifiedName} in FTSModule\"\n                            )\n                            return null\n                        }\n                    }\n\n                    \"externalTable\" -> resolvedInfo.externalTable = value as String\n                    else -> {\n                        logger.error(\"Unrecognized field ${argument.name?.asString()} in FTSModule\")\n                        return null\n                    }\n                }\n            }\n            return resolvedInfo\n        }\n\n        fun resolve(ftsModule: FTSModule?): FTSModuleInfo? {\n            if (ftsModule == null) {\n                return null\n            }\n            val resolvedInfo = FTSModuleInfo()\n            when (ftsModule.version) {\n                FTSVersion.NONE -> resolvedInfo.ftsVersion = \"\"\n                FTSVersion.FTS3 -> resolvedInfo.ftsVersion = \"fts3\"\n                FTSVersion.FTS4 -> resolvedInfo.ftsVersion = \"fts4\"\n                FTSVersion.FTS5 -> resolvedInfo.ftsVersion = \"fts5\"\n            }\n            resolvedInfo.tokenizer = ftsModule.tokenizer\n            resolvedInfo.tokenizerParameters = ftsModule.tokenizerParameters.toMutableList()\n            resolvedInfo.externalTable = ftsModule.externalTable\n            return resolvedInfo\n        }\n    }\n}"
  },
  {
    "path": "src/java/builder/compiler/src/main/java/com/tencent/wcdb/compiler/resolvedInfo/MultiIndexesInfo.kt",
    "content": "// Created by qiuwenchen on 2023/6/21.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdb.compiler.resolvedInfo\n\nimport com.google.devtools.ksp.processing.KSPLogger\nimport com.google.devtools.ksp.symbol.KSAnnotation\nimport com.tencent.wcdb.MultiIndexes\n\ndata class MultiIndexesInfo(\n    var name: String = \"\",\n    var columns: MutableList<String> = mutableListOf()\n) {\n    companion object {\n        fun resolve(annotation: KSAnnotation?, logger: KSPLogger): MultiIndexesInfo? {\n            if (annotation == null) {\n                return null\n            }\n            assert(annotation.shortName.asString() == \"MultiIndexes\")\n            val resolvedInfo = MultiIndexesInfo()\n            for (argument in annotation.arguments) {\n                val value = argument.value ?: continue\n                when (argument.name?.asString()) {\n                    \"name\" -> {\n                        resolvedInfo.name = value as String\n                    }\n\n                    \"columns\" -> {\n                        if (!resolveValueToList(value, String::class, resolvedInfo.columns)) {\n                            logger.error(\n                                \"Unresolved columns $value \" +\n                                        \"with type ${value::class.qualifiedName} in MultiIndexes\"\n                            )\n                            return null\n                        }\n                    }\n\n                    else -> {\n                        logger.error(\"Unrecognized field ${argument.name?.asString()} in MultiIndexes\")\n                        return null\n                    }\n                }\n            }\n            return resolvedInfo\n        }\n\n        fun resolve(multiIndexes: MultiIndexes): MultiIndexesInfo {\n            val resolvedInfo = MultiIndexesInfo()\n            resolvedInfo.name = multiIndexes.name\n            resolvedInfo.columns.addAll(multiIndexes.columns)\n            return resolvedInfo\n        }\n    }\n}"
  },
  {
    "path": "src/java/builder/compiler/src/main/java/com/tencent/wcdb/compiler/resolvedInfo/MultiPrimaryInfo.kt",
    "content": "// Created by qiuwenchen on 2023/6/21.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdb.compiler.resolvedInfo\n\nimport com.google.devtools.ksp.processing.KSPLogger\nimport com.google.devtools.ksp.symbol.KSAnnotation\nimport com.tencent.wcdb.MultiPrimary\n\ndata class MultiPrimaryInfo(\n    var columns: MutableList<String> = mutableListOf()\n) {\n    companion object {\n        fun resolve(annotation: KSAnnotation?, logger: KSPLogger): MultiPrimaryInfo? {\n            if (annotation == null) {\n                return null\n            }\n            assert(annotation.shortName.asString() == \"MultiPrimary\")\n            val resolvedInfo = MultiPrimaryInfo()\n            for (argument in annotation.arguments) {\n                val value = argument.value ?: continue\n                when (argument.name?.asString()) {\n                    \"columns\" -> {\n                        if (!resolveValueToList(value, String::class, resolvedInfo.columns)) {\n                            logger.error(\n                                \"Unresolved columns $value \" +\n                                        \"with type ${value::class.qualifiedName} in MultiPrimary\"\n                            )\n                            return null\n                        }\n                    }\n\n                    else -> {\n                        logger.error(\"Unrecognized field ${argument.name?.asString()} in MultiPrimary\")\n                        return null\n                    }\n                }\n            }\n            return resolvedInfo\n        }\n\n        fun resolve(multiPrimary: MultiPrimary): MultiPrimaryInfo {\n            val resolvedInfo = MultiPrimaryInfo()\n            resolvedInfo.columns.addAll(multiPrimary.columns)\n            return resolvedInfo\n        }\n    }\n}"
  },
  {
    "path": "src/java/builder/compiler/src/main/java/com/tencent/wcdb/compiler/resolvedInfo/MultiUniqueInfo.kt",
    "content": "// Created by qiuwenchen on 2023/6/21.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdb.compiler.resolvedInfo\n\nimport com.google.devtools.ksp.processing.KSPLogger\nimport com.google.devtools.ksp.symbol.KSAnnotation\nimport com.tencent.wcdb.MultiPrimary\nimport com.tencent.wcdb.MultiUnique\n\ndata class MultiUniqueInfo(\n    var columns: MutableList<String> = mutableListOf()\n) {\n    companion object {\n        fun resolve(annotation: KSAnnotation?, logger: KSPLogger): MultiUniqueInfo? {\n            if (annotation == null) {\n                return null\n            }\n            assert(annotation.shortName.asString() == \"MultiUnique\")\n            val resolvedInfo = MultiUniqueInfo()\n            for (argument in annotation.arguments) {\n                val value = argument.value ?: continue\n                when (argument.name?.asString()) {\n                    \"columns\" -> {\n                        if (!resolveValueToList(value, String::class, resolvedInfo.columns)) {\n                            logger.error(\n                                \"Unresolved columns $value \" +\n                                        \"with type ${value::class.qualifiedName} in MultiUnique\"\n                            )\n                            return null\n                        }\n                    }\n\n                    else -> {\n                        logger.error(\"Unrecognized field ${argument.name?.asString()} in MultiUnique\")\n                        return null\n                    }\n                }\n            }\n            return resolvedInfo\n        }\n\n        fun resolve(multiUnique: MultiUnique): MultiUniqueInfo {\n            val resolvedInfo = MultiUniqueInfo()\n            resolvedInfo.columns.addAll(multiUnique.columns)\n            return resolvedInfo\n        }\n    }\n}"
  },
  {
    "path": "src/java/builder/compiler/src/main/java/com/tencent/wcdb/compiler/resolvedInfo/ResolveTool.kt",
    "content": "// Created by qiuwenchen on 2023/6/21.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdb.compiler.resolvedInfo\n\nimport kotlin.reflect.KClass\n\ninternal fun <T : Any> resolveValueToList(\n    value: Any,\n    kClass: KClass<T>,\n    list: MutableList<T>\n): Boolean {\n    if (kClass.isInstance(value)) {\n        @Suppress(\"UNCHECKED_CAST\")\n        list.add(value as T)\n    } else if (value is ArrayList<*>) {\n        @Suppress(\"UNCHECKED_CAST\")\n        val array = value as ArrayList<T>\n        if (array.isNotEmpty()) {\n            list.addAll(array)\n        }\n    } else {\n        return false\n    }\n    return true\n}"
  },
  {
    "path": "src/java/builder/compiler/src/main/java/com/tencent/wcdb/compiler/resolvedInfo/TableConfigInfo.kt",
    "content": "// Created by qiuwenchen on 2023/6/21.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdb.compiler.resolvedInfo\n\nimport com.google.devtools.ksp.processing.KSPLogger\nimport com.google.devtools.ksp.symbol.KSAnnotation\nimport com.tencent.wcdb.FTSModule\nimport com.tencent.wcdb.WCDBTableCoding\n\ndata class TableConfigInfo(\n    var multiIndexes: MutableList<MultiIndexesInfo> = mutableListOf(),\n    var multiPrimaries: MutableList<MultiPrimaryInfo> = mutableListOf(),\n    var multiUnique: MutableList<MultiUniqueInfo> = mutableListOf(),\n    var ftsModule: FTSModuleInfo? = null,\n    var isWithoutRowId: Boolean = false\n) {\n    companion object {\n        fun resolve(annotation: KSAnnotation?, logger: KSPLogger): TableConfigInfo? {\n            if (annotation == null) {\n                return null\n            }\n            val resolvedAnnotation = TableConfigInfo()\n            for (argument in annotation.arguments) {\n                val value = argument.value ?: continue\n                val annotationList = mutableListOf<KSAnnotation>()\n                when (argument.name?.asString()) {\n                    \"multiIndexes\" -> {\n                        if (!resolveValueToList(value, KSAnnotation::class, annotationList)) {\n                            logger.error(\n                                \"Unresolved multiIndexes $value \" +\n                                        \"with type ${value::class.qualifiedName} in WCDBTableCoding\"\n                            )\n                            return null\n                        }\n                        for (subAnnotation in annotationList) {\n                            val multiIndexes =\n                                MultiIndexesInfo.resolve(subAnnotation, logger) ?: return null\n                            resolvedAnnotation.multiIndexes.add(multiIndexes)\n                        }\n                    }\n\n                    \"multiPrimaries\" -> {\n                        if (!resolveValueToList(value, KSAnnotation::class, annotationList)) {\n                            logger.error(\n                                \"Unresolved multiPrimaries $value \" +\n                                        \"with type ${value::class.qualifiedName} in WCDBTableCoding\"\n                            )\n                            return null\n                        }\n                        for (subAnnotation in annotationList) {\n                            val multiPrimaries =\n                                MultiPrimaryInfo.resolve(subAnnotation, logger) ?: return null\n                            resolvedAnnotation.multiPrimaries.add(multiPrimaries)\n                        }\n                    }\n\n                    \"multiUnique\" -> {\n                        if (!resolveValueToList(value, KSAnnotation::class, annotationList)) {\n                            logger.error(\n                                \"Unresolved multiUnique $value \" +\n                                        \"with type ${value::class.qualifiedName} in WCDBTableCoding\"\n                            )\n                            return null\n                        }\n                        for (subAnnotation in annotationList) {\n                            val multiUnique =\n                                MultiUniqueInfo.resolve(subAnnotation, logger) ?: return null\n                            resolvedAnnotation.multiUnique.add(multiUnique)\n                        }\n                    }\n\n                    \"isWithoutRowId\" -> {\n                        resolvedAnnotation.isWithoutRowId = value as Boolean\n                    }\n\n                    \"ftsModule\" -> {\n                        val ftsModuleAnnotation = value as KSAnnotation\n                        resolvedAnnotation.ftsModule =\n                            FTSModuleInfo.resolve(ftsModuleAnnotation, logger)\n                    }\n\n                    else -> {\n                        logger.error(\"Unrecognized field ${argument.name?.asString()} in WCDBTableCoding\")\n                        return null\n                    }\n                }\n            }\n            return resolvedAnnotation\n        }\n\n        fun resolve(tableCoding: WCDBTableCoding, ftsModule: FTSModule?): TableConfigInfo {\n            val resolvedAnnotation = TableConfigInfo()\n            resolvedAnnotation.isWithoutRowId = tableCoding.isWithoutRowId\n            for (multiIndexes in tableCoding.multiIndexes) {\n                resolvedAnnotation.multiIndexes.add(MultiIndexesInfo.resolve(multiIndexes))\n            }\n            for (multiPrimary in tableCoding.multiPrimaries) {\n                resolvedAnnotation.multiPrimaries.add(MultiPrimaryInfo.resolve(multiPrimary))\n            }\n            for (multiUnique in tableCoding.multiUnique) {\n                resolvedAnnotation.multiUnique.add(MultiUniqueInfo.resolve(multiUnique))\n            }\n            resolvedAnnotation.ftsModule = FTSModuleInfo.resolve(ftsModule)\n            return resolvedAnnotation\n        }\n    }\n}"
  },
  {
    "path": "src/java/builder/compiler/src/main/java/com/tencent/wcdb/core/PreparedStatement.java",
    "content": "// Created by qiuwenchen on 2023/4/19.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage com.tencent.wcdb.core;\n\nimport com.tencent.wcdb.winq.ColumnType;\n\nimport java.util.ArrayList;\n\npublic class PreparedStatement {\n    //    public boolean checkPrepared() { throw new UnsatisfiedLinkError(); }\n//    public void step() throws WCDBException { throw new UnsatisfiedLinkError(); }\n//    public void reset() { throw new UnsatisfiedLinkError(); }\n//    public void finalizeStatement() { throw new UnsatisfiedLinkError(); }\n//    public boolean isDone() { throw new UnsatisfiedLinkError(); }\n    public void bindBool(boolean value, int index) {\n        throw new UnsatisfiedLinkError();\n    }\n\n    public void bindInteger(long value, int index) {\n        throw new UnsatisfiedLinkError();\n    }\n\n    public void bindDouble(double value, int index) {\n        throw new UnsatisfiedLinkError();\n    }\n\n    public void bindText(String value, int index) {\n        throw new UnsatisfiedLinkError();\n    }\n\n    public void bindBLOB(byte[] value, int index) {\n        throw new UnsatisfiedLinkError();\n    }\n\n    public void bindNull(int index) {\n        throw new UnsatisfiedLinkError();\n    }\n\n    //    public void bindValue(Value value, int index) { throw new UnsatisfiedLinkError(); }\n//    public void bindRow(Value[] row) { throw new UnsatisfiedLinkError(); }\n//    public <T> void bindObject(T obj, TableBinding<T> binding) { throw new UnsatisfiedLinkError(); }\n//    public <T> void bindObject(T obj, Field<T> field, int index) { throw new UnsatisfiedLinkError(); }\n//    public <T> void bindObject(T obj, Field<T>[] fields) { throw new UnsatisfiedLinkError(); }\n//    public int bindParameterIndex(String parameterName) { throw new UnsatisfiedLinkError(); }\n    public ColumnType getColumnType(int index) {\n        throw new UnsatisfiedLinkError();\n    }\n\n    public boolean getBool(int index) {\n        throw new UnsatisfiedLinkError();\n    }\n\n    public long getInteger(int index) {\n        throw new UnsatisfiedLinkError();\n    }\n\n    public double getDouble(int index) {\n        throw new UnsatisfiedLinkError();\n    }\n\n    public String getText(int index) {\n        throw new UnsatisfiedLinkError();\n    }\n\n    public byte[] getBLOB(int index) {\n        throw new UnsatisfiedLinkError();\n    }\n\n    //    public Value getValue(int index) { throw new UnsatisfiedLinkError(); }\n//    public Value[] getOneRow() { throw new UnsatisfiedLinkError(); }\n//    public ArrayList<Value> getOneColumn() throws WCDBException { throw new UnsatisfiedLinkError(); }\n//    public ArrayList<Value[]> getMultiRows() throws WCDBException { throw new UnsatisfiedLinkError(); }\n//    public <T> T getOneObject(Field<T>[] fields) { throw new UnsatisfiedLinkError(); }\n//    public <T> ArrayList<T> getAllObjects(Field<T>[] fields) throws WCDBException { throw new UnsatisfiedLinkError(); }\n    public int getColumnCount() {\n        throw new UnsatisfiedLinkError();\n    }\n//    public String getColumnName(int index) { throw new UnsatisfiedLinkError(); }\n//    public String getOriginalColumnName(int index) { throw new UnsatisfiedLinkError(); }\n//    public String getColumnTableName(int index) { throw new UnsatisfiedLinkError(); }\n//    public boolean isReadOnly() { throw new UnsatisfiedLinkError(); }\n}\n"
  },
  {
    "path": "src/java/builder/compiler/src/main/java/com/tencent/wcdb/fts/BuiltinTokenizer.java",
    "content": "// Created by chenqiuwen on 2023/11/4.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdb.fts;\n\npublic class BuiltinTokenizer {\n    // SQLite builtin tokenizer\n    public final static String Simple = \"simple\";\n    public final static String Porter = \"porter\";\n    public final static String ICU = \"icu\";\n    public final static String Unicode61 = \"unicode61\";\n\n    // WCDB Builtin tokenizer\n    public final static String OneOrBinary = \"wcdb_one_or_binary\";// Only for FTS3/4\n    public final static String MMICU = \"mmicu\";\n    public final static String Verbatim = \"wcdb_verbatim\";// Only for FTS5\n    public final static String Pinyin = \"wcdb_pinyin\";// Only for FTS5\n\n    // Tokenizer parameters for WCDB Builtin tokenizer\n    public class Parameter {\n        public final static String NeedSymbol = \"need_symbol\";\n        public final static String SimplifyChinese = \"chinese_traditional_to_simplified\";\n        public final static String SkipStemming = \"skip_stemming\";\n    }\n}\n"
  },
  {
    "path": "src/java/builder/compiler/src/main/java/com/tencent/wcdb/orm/Binding.java",
    "content": "// Created by chenqiuwen on 2023/4/19.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the &quot;License&quot;); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an &quot;AS IS&quot; BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdb.orm;\n\nimport com.tencent.wcdb.winq.ColumnDef;\nimport com.tencent.wcdb.winq.StatementCreateIndex;\nimport com.tencent.wcdb.winq.TableConstraint;\n\npublic class Binding {\n    public Binding() {\n        throw new UnsatisfiedLinkError();\n    }\n\n    public void addColumnDef(ColumnDef def) {\n        throw new UnsatisfiedLinkError();\n    }\n\n    public void addIndex(String indexPrefix, StatementCreateIndex createIndex) {\n        throw new UnsatisfiedLinkError();\n    }\n\n    public void addTableConstraint(TableConstraint constraint) {\n        throw new UnsatisfiedLinkError();\n    }\n\n    public Binding configVirtualModule(String module) {\n        throw new UnsatisfiedLinkError();\n    }\n\n    public void configVirtualModuleArgument(String argument) {\n        throw new UnsatisfiedLinkError();\n    }\n}\n"
  },
  {
    "path": "src/java/builder/compiler/src/main/java/com/tencent/wcdb/orm/Field.java",
    "content": "// Created by qiuwenchen on 2023/3/30.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage com.tencent.wcdb.orm;\n\nimport com.tencent.wcdb.winq.Column;\n\npublic class Field<T> extends Column {\n    //    public TableBinding<T> getTableBinding() { throw new UnsatisfiedLinkError(); }\n    public int getFieldId() {\n        throw new UnsatisfiedLinkError();\n    }\n\n    //    public boolean isAutoIncrement() { throw new UnsatisfiedLinkError(); }\n    public Field(String name, TableBinding<T> binding, int fieldId, boolean isAutoIncrement) {\n        throw new UnsatisfiedLinkError();\n    }\n//    public String getName() { throw new UnsatisfiedLinkError(); }\n//    public Field<T> table(String tableName) { throw new UnsatisfiedLinkError(); }\n\n//    @Override\n//    public Field<T> of(String schema) {\n//        Field<T> field = copySelf();\n//        Schema newSchema = new Schema(schema);\n//        field.inSchema(field.cppObj, newSchema.getCppObj());\n//        return field;\n//    }\n//\n//    @Override\n//    public Field<T> of(Schema schema) {\n//        Field<T> field = copySelf();\n//        field.inSchema(field.cppObj, schema.getCppObj());\n//        return field;\n//    }\n//\n//    public static <T> TableBinding<T> getBinding(Field<T> field) {\n//        assert field != null;\n//        if(field != null) {\n//            assert field.getTableBinding() != null;\n//            return field.getTableBinding();\n//        }\n//        return null;\n//    }\n//\n//    public static <T> TableBinding<T> getBinding(Field<T>[] fields) {\n//        assert fields != null && fields.length > 0;\n//        Field field = fields[0];\n//        return getBinding(field);\n//    }\n}\n"
  },
  {
    "path": "src/java/builder/compiler/src/main/java/com/tencent/wcdb/orm/TableBinding.java",
    "content": "// Created by qiuwenchen on 2023/3/30.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage com.tencent.wcdb.orm;\n\nimport com.tencent.wcdb.core.PreparedStatement;\n\npublic interface TableBinding<T> {\n    public Class<T> bindingType();\n\n    public Field<T>[] allBindingFields();\n\n    public Binding baseBinding();\n\n    public T extractObject(Field<T>[] fields, PreparedStatement preparedStatement);\n\n    public void bindField(T object, Field<T> field, int index, PreparedStatement preparedStatement);\n\n    public boolean isAutoIncrement(T object);\n\n    public void setLastInsertRowId(T object, long lastInsertRowId);\n}\n"
  },
  {
    "path": "src/java/builder/compiler/src/main/java/com/tencent/wcdb/winq/Column.java",
    "content": "// Created by qiuwenchen on 2023/3/31.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdb.winq;\n\npublic class Column extends ExpressionOperable {\n//    public Column(String name) { throw new UnsatisfiedLinkError(); }\n\n//    public Column table(String table) {\n//        inTable(cppObj, table);\n//        return this;\n//    }\n//\n//    protected native void inTable(long column, String table);\n//\n//    public Column of(Schema schema) {\n//        inSchema(cppObj, schema.getCppObj());\n//        return this;\n//    }\n//\n//    public Column of(String schema) {\n//        return of(new Schema(schema));\n//    }\n//\n//    protected native void inSchema(long column, long schema);\n//\n//    protected Column() {\n//    }\n//\n//    public static Column all() {\n//        Column ret = new Column();\n//        ret.cppObj = allColumn();\n//        return ret;\n//    }\n//\n//    private static native long allColumn();\n//\n//    public static Column rowId() {\n//        Column ret = new Column();\n//        ret.cppObj = rowidColumn();\n//        return ret;\n//    }\n//\n//    private static native long rowidColumn();\n//\n//    public OrderingTerm order(Order order) {\n//        return new OrderingTerm(this).order(order);\n//    }\n//\n//    public ColumnDef asDef(ColumnType columnType) {\n//        return new ColumnDef(this, columnType);\n//    }\n}\n"
  },
  {
    "path": "src/java/builder/compiler/src/main/java/com/tencent/wcdb/winq/ColumnConstraint.java",
    "content": "// Created by chenqiuwen on 2023/4/3.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage com.tencent.wcdb.winq;\n\npublic class ColumnConstraint extends Identifier {\n    public ColumnConstraint() {\n        throw new UnsatisfiedLinkError();\n    }\n\n    public ColumnConstraint(String columnName) {\n        throw new UnsatisfiedLinkError();\n    }\n\n    public ColumnConstraint primaryKey() {\n        throw new UnsatisfiedLinkError();\n    }\n\n    public ColumnConstraint order(Order order) {\n        throw new UnsatisfiedLinkError();\n    }\n\n    public ColumnConstraint conflict(ConflictAction action) {\n        throw new UnsatisfiedLinkError();\n    }\n\n    public ColumnConstraint autoIncrement() {\n        throw new UnsatisfiedLinkError();\n    }\n\n    public ColumnConstraint notNull() {\n        throw new UnsatisfiedLinkError();\n    }\n\n    public ColumnConstraint unique() {\n        throw new UnsatisfiedLinkError();\n    }\n\n    //    public ColumnConstraint check(Expression expression) { throw new UnsatisfiedLinkError(); }\n    public ColumnConstraint defaultTo(boolean value) {\n        throw new UnsatisfiedLinkError();\n    }\n\n    public ColumnConstraint defaultTo(long value) {\n        throw new UnsatisfiedLinkError();\n    }\n\n    public ColumnConstraint defaultTo(double value) {\n        throw new UnsatisfiedLinkError();\n    }\n\n    public ColumnConstraint defaultTo(String value) {\n        throw new UnsatisfiedLinkError();\n    }\n\n    //    public ColumnConstraint defaultTo(ExpressionConvertible value) { throw new UnsatisfiedLinkError(); }\n    public ColumnConstraint collate(String collation) {\n        throw new UnsatisfiedLinkError();\n    }\n\n    public ColumnConstraint foreignKey(ForeignKey foreignKey) {\n        throw new UnsatisfiedLinkError();\n    }\n\n    public ColumnConstraint unIndex() {\n        throw new UnsatisfiedLinkError();\n    }\n}\n"
  },
  {
    "path": "src/java/builder/compiler/src/main/java/com/tencent/wcdb/winq/ColumnDef.java",
    "content": "// Created by qiuwenchen on 2023/4/7.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdb.winq;\n\npublic class ColumnDef {\n    public ColumnDef(String columnName) {\n        throw new UnsatisfiedLinkError();\n    }\n\n    public ColumnDef(Column column) {\n        throw new UnsatisfiedLinkError();\n    }\n\n    public ColumnDef(String columnName, ColumnType columnType) {\n        throw new UnsatisfiedLinkError();\n    }\n\n    public ColumnDef(Column column, ColumnType columnType) {\n        throw new UnsatisfiedLinkError();\n    }\n\n    public ColumnDef constraint(ColumnConstraint constraint) {\n        throw new UnsatisfiedLinkError();\n    }\n//    public ColumnDef makePrimary() { throw new UnsatisfiedLinkError(); }\n//    public ColumnDef makePrimary(boolean isAutoIncrement) { throw new UnsatisfiedLinkError(); }\n//    public ColumnDef makeDefaultTo(boolean value) { throw new UnsatisfiedLinkError(); }\n//    public ColumnDef makeDefaultTo(long value) { throw new UnsatisfiedLinkError(); }\n//    public ColumnDef makeDefaultTo(double value) { throw new UnsatisfiedLinkError(); }\n//    public ColumnDef makeDefaultTo(String value) { throw new UnsatisfiedLinkError(); }\n//    public ColumnDef makeDefaultTo(ExpressionConvertible value) { throw new UnsatisfiedLinkError(); }\n//    public ColumnDef makeUnique() { throw new UnsatisfiedLinkError(); }\n//    public ColumnDef makeNotNull() { throw new UnsatisfiedLinkError(); }\n//    public ColumnDef makeForeignKey(ForeignKey foreignKey) { throw new UnsatisfiedLinkError(); }\n//    public ColumnDef makeNotIndexed() { throw new UnsatisfiedLinkError(); }\n}\n"
  },
  {
    "path": "src/java/builder/compiler/src/main/java/com/tencent/wcdb/winq/ColumnType.java",
    "content": "// Created by qiuwenchen on 2023/4/7.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdb.winq;\n\npublic enum ColumnType {\n    Null(0),\n    Integer(1),\n    Float(2),\n    Text(3),\n    BLOB(4);\n\n    private int value;\n\n    private ColumnType(int value) {\n        this.value = value;\n    }\n\n    public static ColumnType valueOf(int value) {\n        switch (value) {\n            case 1:\n                return Integer;\n            case 2:\n                return Float;\n            case 3:\n                return Text;\n            case 4:\n                return BLOB;\n            default:\n                return Null;\n        }\n    }\n}\n"
  },
  {
    "path": "src/java/builder/compiler/src/main/java/com/tencent/wcdb/winq/ConflictAction.java",
    "content": "// Created by qiuwenchen on 2023/4/6.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdb.winq;\n\npublic enum ConflictAction {\n    None, Replace, Rollback, Abort, Fail, Ignore\n}\n"
  },
  {
    "path": "src/java/builder/compiler/src/main/java/com/tencent/wcdb/winq/ExpressionOperable.java",
    "content": "//\n// Created by qiuwenchen on 2023/3/30.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage com.tencent.wcdb.winq;\n\npublic abstract class ExpressionOperable extends Identifier {\n}\n"
  },
  {
    "path": "src/java/builder/compiler/src/main/java/com/tencent/wcdb/winq/ForeignKey.java",
    "content": "// Created by qiuwenchen on 2023/4/6.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdb.winq;\n\npublic class ForeignKey extends Identifier {\n}\n"
  },
  {
    "path": "src/java/builder/compiler/src/main/java/com/tencent/wcdb/winq/Identifier.java",
    "content": "// Created by qiuwenchen on 2023/3/30.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage com.tencent.wcdb.winq;\n\npublic class Identifier {\n    public Identifier asIdentifier() {\n        return this;\n    }\n\n    public String getDescription() {\n        throw new UnsatisfiedLinkError();\n    }\n}\n"
  },
  {
    "path": "src/java/builder/compiler/src/main/java/com/tencent/wcdb/winq/IndexedColumnConvertible.java",
    "content": "// Created by qiuwenchen on 2023/4/7.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdb.winq;\n\npublic interface IndexedColumnConvertible {\n    Identifier asIdentifier();\n}\n"
  },
  {
    "path": "src/java/builder/compiler/src/main/java/com/tencent/wcdb/winq/Order.java",
    "content": "//\n// Created by qiuwenchen on 2023/4/4.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage com.tencent.wcdb.winq;\n\npublic enum Order {\n    Asc, Desc;\n}\n"
  },
  {
    "path": "src/java/builder/compiler/src/main/java/com/tencent/wcdb/winq/Schema.java",
    "content": "// Created by qiuwenchen on 2023/3/31.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdb.winq;\n\npublic class Schema extends Identifier {\n    public Schema(String name) {\n        throw new UnsatisfiedLinkError();\n    }\n\n    public static Schema main() {\n        throw new UnsatisfiedLinkError();\n    }\n\n    public static Schema temp() {\n        throw new UnsatisfiedLinkError();\n    }\n}\n"
  },
  {
    "path": "src/java/builder/compiler/src/main/java/com/tencent/wcdb/winq/StatementCreateIndex.java",
    "content": "// Created by chenqiuwen on 2023/4/10.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdb.winq;\n\npublic class StatementCreateIndex {\n    public StatementCreateIndex() {\n        throw new UnsatisfiedLinkError();\n    }\n\n    public StatementCreateIndex createIndex(String indexName) {\n        throw new UnsatisfiedLinkError();\n    }\n\n    public StatementCreateIndex unique() {\n        throw new UnsatisfiedLinkError();\n    }\n\n    public StatementCreateIndex ifNotExist() {\n        throw new UnsatisfiedLinkError();\n    }\n\n    public StatementCreateIndex of(String schemaName) {\n        throw new UnsatisfiedLinkError();\n    }\n\n    public StatementCreateIndex of(Schema schema) {\n        throw new UnsatisfiedLinkError();\n    }\n\n    public StatementCreateIndex on(String tableName) {\n        throw new UnsatisfiedLinkError();\n    }\n\n    public StatementCreateIndex indexedBy(IndexedColumnConvertible... indexedColumnConvertible) {\n        throw new UnsatisfiedLinkError();\n    }\n\n    public StatementCreateIndex indexedBy(IndexedColumnConvertible indexedColumnConvertible) {\n        throw new UnsatisfiedLinkError();\n    }\n\n    public StatementCreateIndex indexedBy(String... indexedColumnNames) {\n        throw new UnsatisfiedLinkError();\n    }\n\n    public StatementCreateIndex indexedBy(String indexedColumnName) {\n        throw new UnsatisfiedLinkError();\n    }\n//    public StatementCreateIndex where(Expression condition) { throw new UnsatisfiedLinkError(); }\n}\n"
  },
  {
    "path": "src/java/builder/compiler/src/main/java/com/tencent/wcdb/winq/TableConstraint.java",
    "content": "// Created by chenqiuwen on 2023/4/9.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdb.winq;\n\npublic class TableConstraint extends Identifier {\n    public TableConstraint() {\n        throw new UnsatisfiedLinkError();\n    }\n\n    public TableConstraint(String name) {\n        throw new UnsatisfiedLinkError();\n    }\n\n    public TableConstraint primaryKey() {\n        throw new UnsatisfiedLinkError();\n    }\n\n    public TableConstraint unique() {\n        throw new UnsatisfiedLinkError();\n    }\n\n    public TableConstraint indexedBy(IndexedColumnConvertible indexedColumn) {\n        throw new UnsatisfiedLinkError();\n    }\n\n    public TableConstraint indexedBy(IndexedColumnConvertible... indexedColumns) {\n        throw new UnsatisfiedLinkError();\n    }\n\n    public TableConstraint indexedBy(String indexedColumn) {\n        throw new UnsatisfiedLinkError();\n    }\n\n    public TableConstraint indexedBy(String... indexedColumns) {\n        throw new UnsatisfiedLinkError();\n    }\n\n    public TableConstraint onConflict(ConflictAction action) {\n        throw new UnsatisfiedLinkError();\n    }\n\n    //    public TableConstraint check(Expression expression) { throw new UnsatisfiedLinkError(); }\n    public TableConstraint foreignKey(ForeignKey foreignKey, String... columns) {\n        throw new UnsatisfiedLinkError();\n    }\n\n    public TableConstraint foreignKey(ForeignKey foreignKey, Column... columns) {\n        throw new UnsatisfiedLinkError();\n    }\n}\n"
  },
  {
    "path": "src/java/builder/compiler/src/main/resources/META-INF/gradle/incremental.annotation.processors",
    "content": "com.tencent.wcdb.compiler.JavaAnnotationProcessor,isolating"
  },
  {
    "path": "src/java/builder/compiler/src/main/resources/META-INF/services/com.google.devtools.ksp.processing.SymbolProcessorProvider",
    "content": "com.tencent.wcdb.compiler.KotlinAnnotationProcessor$Provider"
  },
  {
    "path": "src/java/builder/compiler/src/main/resources/META-INF/services/javax.annotation.processing.Processor",
    "content": "com.tencent.wcdb.compiler.JavaAnnotationProcessor"
  },
  {
    "path": "src/java/builder/gradle-plugin/.gitignore",
    "content": "/build"
  },
  {
    "path": "src/java/builder/gradle-plugin/build.gradle",
    "content": "plugins {\n    id 'groovy'\n    id 'java-gradle-plugin'\n}\napply from: rootProject.file('../gradle/WeChatPublish.gradle')\n\ngradlePlugin {\n    automatedPublishing false\n    plugins {\n        wcdbPlugin {\n            id = 'com.tencent.wcdb.gradle'\n            implementationClass = 'com.tencent.wcdb.gradle.WCDBPlugin'\n        }\n    }\n}\n\ndef genVersionTask = tasks.register('generateVersionProperties') {\n    def propFile = file(\"$buildDir/generated/wcdb-gradle-plugin.properties\")\n    outputs.file propFile\n    outputs.upToDateWhen { false }\n    doLast {\n        mkdir propFile.parentFile\n        propFile.text = \"version=${project.getFullVersion()}\"\n    }\n}\n\nprocessResources {\n    from genVersionTask\n}\n\ndependencies {\n    implementation \"com.tencent.wcdb:compiler:${project.getFullVersion()}\"\n    compileOnly gradleApi()\n    compileOnly 'com.android.tools.build:gradle:8.1.2'\n}\n\nconfigurations.all {\n    resolutionStrategy.dependencySubstitution {\n        substitute module('com.tencent.wcdb:compiler') using project(':compiler')\n    }\n}\n"
  },
  {
    "path": "src/java/builder/gradle-plugin/src/main/groovy/com/tencent/wcdb/gradle/WCDBOrmSourceDirectorySet.groovy",
    "content": "package com.tencent.wcdb.gradle\n\nimport org.gradle.api.Project\nimport org.gradle.api.internal.file.DefaultSourceDirectorySet\nimport org.gradle.api.internal.file.FileCollectionFactory\nimport org.gradle.api.internal.file.collections.DefaultDirectoryFileTreeFactory\nimport org.gradle.api.internal.tasks.TaskDependencyFactory\nimport org.gradle.api.model.ObjectFactory\nimport org.gradle.api.tasks.util.PatternSet\nimport org.gradle.internal.Factory\n\nimport javax.inject.Inject\n/**\n * The backing class of the autogen extension added to sourceSets, e.g., sourceSets.main.autogen\n */\nclass WCDBOrmSourceDirectorySet extends DefaultSourceDirectorySet {\n\n    private static final Factory<PatternSet> sPatternSetFactory = new Factory<PatternSet>() {\n        @Override\n        PatternSet create() {\n            return new PatternSet()\n        }\n    }\n\n    @Inject\n    WCDBOrmSourceDirectorySet(Project project, String name) {\n        super(name, \"$name WCDB ORM source\", sPatternSetFactory,\n                project.services.get(TaskDependencyFactory),\n                project.services.get(FileCollectionFactory),\n                new DefaultDirectoryFileTreeFactory(), project.services.get(ObjectFactory))\n\n        srcDir(\"src/${name}/wcdbOrm\")\n        include('**/*.java')\n        include('**/*.kt')\n    }\n}"
  },
  {
    "path": "src/java/builder/gradle-plugin/src/main/groovy/com/tencent/wcdb/gradle/WCDBOrmSourceDirectorySetG7.groovy",
    "content": "package com.tencent.wcdb.gradle\n\nimport org.gradle.api.Project\nimport org.gradle.api.internal.file.DefaultSourceDirectorySet\nimport org.gradle.api.internal.file.FileCollectionFactory\nimport org.gradle.api.internal.file.collections.DefaultDirectoryFileTreeFactory\nimport org.gradle.api.internal.tasks.TaskDependencyFactory\nimport org.gradle.api.model.ObjectFactory\nimport org.gradle.api.tasks.util.PatternSet\nimport org.gradle.internal.Factory\n\nimport javax.inject.Inject\n/**\n * The backing class of the autogen extension added to sourceSets, e.g., sourceSets.main.autogen\n */\nclass WCDBOrmSourceDirectorySetG7 extends DefaultSourceDirectorySet {\n\n    private static final Factory<PatternSet> sPatternSetFactory = new Factory<PatternSet>() {\n        @Override\n        PatternSet create() {\n            return new PatternSet()\n        }\n    }\n\n    @Inject\n    WCDBOrmSourceDirectorySetG7(Project project, String name) {\n        super(name, \"$name WCDB ORM source\", sPatternSetFactory,\n                //project.services.get(TaskDependencyFactory),\n                project.services.get(FileCollectionFactory),\n                new DefaultDirectoryFileTreeFactory(), project.services.get(ObjectFactory))\n\n        srcDir(\"src/${name}/wcdbOrm\")\n        include('**/*.java')\n        include('**/*.kt')\n    }\n}"
  },
  {
    "path": "src/java/builder/gradle-plugin/src/main/groovy/com/tencent/wcdb/gradle/WCDBPlugin.groovy",
    "content": "package com.tencent.wcdb.gradle\n\nimport com.android.build.api.dsl.ApplicationExtension\nimport com.android.build.api.dsl.CommonExtension\nimport com.android.build.api.dsl.LibraryExtension\nimport com.android.build.gradle.AppPlugin\nimport com.android.build.gradle.LibraryPlugin\nimport com.android.build.gradle.api.BaseVariant\nimport org.gradle.api.DomainObjectSet\nimport org.gradle.api.GradleException\nimport org.gradle.api.Plugin\nimport org.gradle.api.Project\nimport org.gradle.api.file.SourceDirectorySet\nimport org.gradle.api.internal.file.DefaultSourceDirectorySet\nimport org.gradle.api.plugins.JavaPlugin\nimport org.gradle.api.tasks.SourceSet\nimport org.gradle.api.tasks.SourceSetContainer\nimport org.gradle.api.tasks.compile.JavaCompile\nimport org.gradle.util.GradleVersion\n\nclass WCDBPlugin implements Plugin<Project> {\n    private static final boolean isG8 = GradleVersion.current().baseVersion >= GradleVersion.version(\"8.0\")\n\n    @Override\n    void apply(Project project) {\n        if (!project.plugins.hasPlugin(JavaPlugin) &&\n            !project.plugins.hasPlugin(AppPlugin) &&\n            !project.plugins.hasPlugin(LibraryPlugin)) {\n\n            throw new GradleException(\"WCDBPlugin: Java or Android application/library plugin required.\")\n        }\n\n        project.configurations.maybeCreate(\"wcdbOrmClasspath\")\n        project.dependencies.add(\"wcdbOrmClasspath\", \"com.tencent.wcdb:annotation:${pluginVersion}\")\n        project.dependencies.add(\"wcdbOrmClasspath\", \"com.tencent.wcdb:compiler:${pluginVersion}\")\n\n        final CommonExtension android = (project.plugins.hasPlugin(AppPlugin) || project.plugins.hasPlugin(LibraryPlugin)) ?\n            project.extensions.getByName('android') : null\n\n        if (android != null) {\n            android.sourceSets.configureEach {\n                if (isG8) {\n                    it.extensions.create(SourceDirectorySet, 'wcdbOrm', WCDBOrmSourceDirectorySet, it.name)\n                } else {\n                    it.extensions.create(SourceDirectorySet, 'wcdbOrm', WCDBOrmSourceDirectorySetG7, it.name)\n                }\n            }\n\n            project.afterEvaluate {\n                android.sourceSets.configureEach {\n                    // Add wcdbOrm sourceSet to 'java'\n                    java.srcDirs(wcdbOrm.getSrcDirs().toArray())\n                }\n            }\n\n            def variantConfigure = { BaseVariant variant ->\n                def vName = variant.name\n                def cvName = vName.capitalize()\n                def androidSourceSetNames = variant.sourceSets*.name\n                def destDir = new File(project.buildDir, \"generated/sources/wcdb/${vName}\")\n\n                def generateTask = project.tasks.register(\"generate${cvName}WcdbOrm\", JavaCompile) {\n                    androidSourceSetNames.each {\n                        SourceDirectorySet origSs = android.sourceSets.getByName(it).wcdbOrm\n                        def ss = new DefaultSourceDirectorySet(origSs)\n                        ss.setSrcDirs(origSs.srcDirs)\n                        ss.setIncludes(['**/*.java'])\n                        source(ss)\n                    }\n                    classpath = project.configurations.wcdbOrmClasspath\n                    options.annotationProcessorPath = project.configurations.wcdbOrmClasspath\n                    options.compilerArgs.addAll([\"-proc:only\", \"-implicit:none\"])\n                    destinationDirectory = destDir\n                }\n\n                variant.registerJavaGeneratingTask(generateTask, destDir)\n            }\n            getNotTestVariants(android).configureEach(variantConfigure)\n            android.testVariants.configureEach(variantConfigure)\n        } else {\n            final SourceSetContainer sourceSets = project.sourceSets\n            sourceSets.configureEach {\n                if (isG8) {\n                    it.extensions.create(SourceDirectorySet, 'wcdbOrm', WCDBOrmSourceDirectorySet, project, it.name)\n                } else {\n                    it.extensions.create(SourceDirectorySet, 'wcdbOrm', WCDBOrmSourceDirectorySetG7, project, it.name)\n                }\n            }\n\n            project.afterEvaluate {\n                sourceSets.configureEach {\n                    java.srcDirs(wcdbOrm.getSrcDirs().toArray())\n\n                    def ssName = SourceSet.isMain(it) ? '' : it.name.capitalize()\n                    def destDir = new File(project.buildDir, \"generated/sources/wcdb/${ssName}\")\n                    def generateTask = project.tasks.register(\"generate${ssName}WcdbOrm\", JavaCompile) {\n                        SourceDirectorySet origSs = wcdbOrm\n                        def ss = new DefaultSourceDirectorySet(origSs)\n                        ss.setSrcDirs(origSs.srcDirs)\n                        ss.setIncludes(['**/*.java'])\n                        source(ss)\n\n                        classpath = project.configurations.wcdbOrmClasspath\n                        options.annotationProcessorPath = project.configurations.wcdbOrmClasspath\n                        options.compilerArgs.addAll([\"-proc:only\", \"-implicit:none\"])\n                        destinationDirectory = destDir\n                    }\n                }\n            }\n        }\n    }\n\n    private static DomainObjectSet<? extends BaseVariant> getNotTestVariants(CommonExtension android) {\n        if (android instanceof ApplicationExtension) {\n            return ((ApplicationExtension) android).applicationVariants\n        } else {\n            return ((LibraryExtension) android).libraryVariants\n        }\n    }\n\n    private static String myVersion = null\n    private static String getPluginVersion() {\n        if (myVersion == null) {\n            def prop = new Properties()\n            prop.load(getClassLoader().getResourceAsStream('wcdb-gradle-plugin.properties'))\n            myVersion = prop.getProperty('version')\n        }\n        return myVersion\n    }\n}"
  },
  {
    "path": "src/java/builder/settings.gradle",
    "content": "includeBuild('../annotation') {\n    dependencySubstitution {\n        substitute module('com.tencent.wcdb:annotation') using project(':')\n    }\n}\n\ninclude ':compiler'\ninclude ':gradle-plugin'\n"
  },
  {
    "path": "src/java/compat/.gitignore",
    "content": "/build"
  },
  {
    "path": "src/java/compat/build.gradle",
    "content": "plugins { id 'com.android.library' }\napply from: rootProject.file('gradle/WeChatPublish.gradle')\n\nandroid {\n    namespace 'com.tencent.wcdb.compat'\n    compileSdk 33\n\n    defaultConfig {\n        minSdk 21\n        targetSdk 33\n\n        testInstrumentationRunner \"androidx.test.runner.AndroidJUnitRunner\"\n    }\n\n    buildTypes {\n        release {\n            minifyEnabled false\n            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'\n        }\n    }\n\n    compileOptions {\n        sourceCompatibility JavaVersion.VERSION_1_8\n        targetCompatibility JavaVersion.VERSION_1_8\n    }\n}\n\ndependencies {\n    implementation 'org.jetbrains:annotations:13.0'\n    androidTestImplementation 'androidx.test.ext:junit:1.1.5'\n    androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'\n    implementation project(':main')\n}"
  },
  {
    "path": "src/java/compat/proguard-rules.pro",
    "content": "# Add project specific ProGuard rules here.\n# You can control the set of applied configuration files using the\n# proguardFiles setting in build.gradle.\n#\n# For more details, see\n#   http://developer.android.com/guide/developing/tools/proguard.html\n\n# If your project uses WebView with JS, uncomment the following\n# and specify the fully qualified class name to the JavaScript interface\n# class:\n#-keepclassmembers class fqcn.of.javascript.interface.for.webview {\n#   public *;\n#}\n\n# Uncomment this to preserve the line number information for\n# debugging stack traces.\n#-keepattributes SourceFile,LineNumberTable\n\n# If you keep the line number information, uncomment this to\n# hide the original source file name.\n#-renamesourcefileattribute SourceFile"
  },
  {
    "path": "src/java/compat/src/main/AndroidManifest.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<manifest xmlns:android=\"http://schemas.android.com/apk/res/android\" xmlns:tools=\"http://schemas.android.com/tools\">\n</manifest>"
  },
  {
    "path": "src/java/compat/src/main/java/com/tencent/wcdb/compat/DatabaseErrorHandler.java",
    "content": "package com.tencent.wcdb.compat;\n\n/**\n * An interface to let apps define an action to take when database corruption is detected.\n */\npublic interface DatabaseErrorHandler {\n\n    /**\n     * The method invoked when database corruption is detected.\n     *\n     * @param db the {@link SQLiteDatabase} object representing the database on which corruption\n     *           is detected.\n     */\n    void onCorruption(SQLiteDatabase db);\n}"
  },
  {
    "path": "src/java/compat/src/main/java/com/tencent/wcdb/compat/DatabaseUtils.java",
    "content": "package com.tencent.wcdb.compat;\n\nimport android.os.CancellationSignal;\n\nimport com.tencent.wcdb.core.Handle;\n\npublic final class DatabaseUtils {\n    private DatabaseUtils() {\n    }\n\n    public static long longForQuery(SQLiteDatabase db, String sql, Object[] selectionArgs) {\n        try (SQLiteStatement stmt = db.compileStatement(sql)) {\n            stmt.bindAllArgs(selectionArgs);\n            return stmt.simpleQueryForLong();\n        }\n    }\n\n    public static String stringForQuery(SQLiteDatabase db, String sql, Object[] selectionArgs) {\n        try (SQLiteStatement stmt = db.compileStatement(sql)) {\n            stmt.bindAllArgs(selectionArgs);\n            return stmt.simpleQueryForString();\n        }\n    }\n\n    static void bindCancellationSignal(Handle handle, CancellationSignal cancellationSignal) {\n        if (cancellationSignal == null) return;\n\n        final Handle.CancellationSignal cs = new Handle.CancellationSignal();\n        cancellationSignal.setOnCancelListener(new CancellationSignal.OnCancelListener() {\n            @Override\n            public void onCancel() {\n                cs.cancel();\n            }\n        });\n\n        if (cancellationSignal.isCanceled()) {\n            cs.cancel();\n        }\n\n        handle.attachCancellationSignal(cs);\n    }\n}\n"
  },
  {
    "path": "src/java/compat/src/main/java/com/tencent/wcdb/compat/SQLiteCipherSpec.java",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdb.compat;\n\nimport android.database.sqlite.SQLiteException;\n\n/**\n * Describes encryption options for SQLite databases.\n */\npublic class SQLiteCipherSpec {\n\n    public static final int HMAC_DEFAULT = -1;\n    public static final int HMAC_SHA1 = 0;\n    public static final int HMAC_SHA256 = 1;\n    public static final int HMAC_SHA512 = 2;\n\n    static final String[] HMAC_ALGO_MAPPING = new String[]{\n            \"HMAC_SHA1\", \"HMAC_SHA256\", \"HMAC_SHA512\"\n    };\n    static final String[] PBKDF2_ALGO_MAPPING = new String[]{\n            \"PBKDF2_HMAC_SHA1\", \"PBKDF2_HMAC_SHA256\", \"PBKDF2_HMAC_SHA512\"\n    };\n\n    /**\n     * KDF iteration times to generate encryption keys, 0 for default value.\n     *\n     * <p>Typical values are 4000 for SQLCipher version 1.x and 2.x, 64000 for\n     * version 3.x. For databases created by WCDB itself, leave it 0.</p>\n     */\n    public int kdfIteration;\n\n    /**\n     * Whether HMAC should be used.\n     *\n     * <p>Defaulted to {@code false} for SQLCipher 1.x, and {@code true} otherwise.\n     * Must be set to the same value as when the database is created, or the database\n     * cannot be opened and {@link SQLiteException} is thrown.</p>\n     */\n    public boolean hmacEnabled = true;\n\n    /**\n     * Which algorithm should be used in HMAC.\n     *\n     * <p>Defaulted to {@code HMAC_SHA1} for SQLCipher 3.x and below, {@code HMAC_SHA512}\n     * for 4.x. Must be set to the same value as when the database is created, or the database\n     * cannot be opened and {@link SQLiteException} is thrown.</p>\n     */\n    public int hmacAlgorithm = HMAC_DEFAULT;\n\n    /**\n     * Which algorithm should be used in key derivation.\n     *\n     * <p>Defaulted to {@code HMAC_SHA1} for SQLCipher 3.x and below, {@code HMAC_SHA512}\n     * for 4.x. Must be set to the same value as when the database is created, or the database\n     * cannot be opened and {@link SQLiteException} is thrown.</p>\n     */\n    public int kdfAlgorithm = HMAC_DEFAULT;\n\n    /**\n     * Page size to use.\n     *\n     * <p>Page size must be set to the same value as when the database is created, in order to\n     * open existing encrypted database. For databases created by WCDB itself, leave it to\n     * the default is preferred for most applications. If database cannot be opened and\n     * {@link SQLiteException} is thrown, try setting it to 1024 or 4096.\n     * </p>\n     */\n    public int pageSize = 4096;\n\n    int cipherVersion = 0;\n\n    /**\n     * Create a new object with default values.\n     */\n    public SQLiteCipherSpec() {\n    }\n\n    /**\n     * Create a new object as a copy of an existed one.\n     *\n     * @param rhs The object to be copied\n     */\n    public SQLiteCipherSpec(SQLiteCipherSpec rhs) {\n        kdfIteration = rhs.kdfIteration;\n        hmacEnabled = rhs.hmacEnabled;\n        hmacAlgorithm = rhs.hmacAlgorithm;\n        kdfAlgorithm = rhs.kdfAlgorithm;\n        cipherVersion = rhs.cipherVersion;\n        pageSize = rhs.pageSize;\n    }\n\n    /**\n     * Set KDF iteration times to be used.\n     *\n     * @param iter New iteration times value\n     * @return This object to allow for chaining of calls to set methods\n     * @see #kdfIteration\n     */\n    public SQLiteCipherSpec setKDFIteration(int iter) {\n        if (kdfIteration != iter) {\n            kdfIteration = iter;\n            cipherVersion = -1;\n        }\n        return this;\n    }\n\n    /**\n     * Set whether to use HMAC in encryption. Default to true.\n     *\n     * @param enabled Whether to use HMAC\n     * @return This object to allow for chaining of calls to set methods\n     * @see #hmacEnabled\n     */\n    public SQLiteCipherSpec withHMACEnabled(boolean enabled) {\n        if (hmacEnabled != enabled) {\n            hmacEnabled = enabled;\n            cipherVersion = -1;\n        }\n        return this;\n    }\n\n    /**\n     * Set algorithm to be used in HMAC.\n     *\n     * @param algo Algorithm defined by {@code HMAC_*}\n     * @return This object to allow for chaining of calls to set methods\n     * @see #hmacAlgorithm\n     */\n    public SQLiteCipherSpec setHmacAlgorithm(int algo) {\n        if (hmacAlgorithm != algo) {\n            hmacAlgorithm = algo;\n            cipherVersion = -1;\n        }\n        return this;\n    }\n\n    /**\n     * Set algorithm to be used in PBKDF.\n     *\n     * @param algo Algorithm defined by {@code HMAC_*}\n     * @return This object to allow for chaining of calls to set methods\n     * @see #kdfAlgorithm\n     */\n    public SQLiteCipherSpec setKdfAlgorithm(int algo) {\n        if (kdfAlgorithm != algo) {\n            kdfAlgorithm = algo;\n            cipherVersion = -1;\n        }\n        return this;\n    }\n\n    /**\n     * Set the page size to use. The page size should be a power of two.\n     *\n     * @param size Page size in byte\n     * @return This object to allow for chaining of calls to set methods\n     * @see #pageSize\n     */\n    public SQLiteCipherSpec setPageSize(int size) {\n        pageSize = size;\n        return this;\n    }\n\n    /**\n     * Set SQLCipher version compatibility. The version should be 1-4 which\n     * represent SQLCipher 1.x to 4.x. This method overwrites HMAC and KDF\n     * iteration settings.\n     *\n     * @param version SQLCipher version, should be within 1 to 4\n     * @return This object to allow for chaining of calls to set methods\n     * @see #kdfIteration\n     * @see #hmacEnabled\n     * @see #hmacAlgorithm\n     * @see #kdfAlgorithm\n     */\n    public SQLiteCipherSpec setSQLCipherVersion(int version) {\n        switch (version) {\n            case 1:\n                cipherVersion = 1;\n                hmacEnabled = false;\n                kdfIteration = 4000;\n                hmacAlgorithm = HMAC_SHA1;\n                kdfAlgorithm = HMAC_SHA1;\n                break;\n            case 2:\n                cipherVersion = 2;\n                hmacEnabled = true;\n                kdfIteration = 4000;\n                hmacAlgorithm = HMAC_SHA1;\n                kdfAlgorithm = HMAC_SHA1;\n                break;\n            case 3:\n                cipherVersion = 3;\n                hmacEnabled = true;\n                kdfIteration = 64000;\n                hmacAlgorithm = HMAC_SHA1;\n                kdfAlgorithm = HMAC_SHA1;\n                break;\n            case 4:\n                cipherVersion = 4;\n                hmacEnabled = true;\n                kdfIteration = 256000;\n                hmacAlgorithm = HMAC_SHA512;\n                kdfAlgorithm = HMAC_SHA512;\n                break;\n            default:\n                throw new IllegalArgumentException(\"Unsupported SQLCipher version: \" + version);\n        }\n        return this;\n    }\n}\n"
  },
  {
    "path": "src/java/compat/src/main/java/com/tencent/wcdb/compat/SQLiteDatabase.java",
    "content": "package com.tencent.wcdb.compat;\n\nimport android.content.ContentValues;\nimport android.database.Cursor;\nimport android.database.SQLException;\nimport android.database.sqlite.SQLiteQueryBuilder;\nimport android.database.sqlite.SQLiteTransactionListener;\nimport android.os.CancellationSignal;\nimport android.os.OperationCanceledException;\nimport android.text.TextUtils;\n\nimport com.tencent.wcdb.base.Value;\nimport com.tencent.wcdb.base.WCDBException;\nimport com.tencent.wcdb.base.WCDBInterruptException;\nimport com.tencent.wcdb.core.Database;\nimport com.tencent.wcdb.core.Handle;\nimport com.tencent.wcdb.core.PreparedStatement;\nimport com.tencent.wcdb.winq.StatementInsert;\n\nimport org.jetbrains.annotations.NotNull;\n\nimport java.util.List;\n\n/**\n * Exposes methods to manage a SQLite database.\n * <p/>\n * <p>\n * SQLiteDatabase has methods to create, delete, execute SQL commands, and\n * perform other common database management tasks.\n * </p><p>\n * See the Notepad sample application in the SDK for an example of creating\n * and managing a database.\n * </p><p>\n * Database names must be unique within an application, not across all applications.\n * </p>\n * <p/>\n * <h3>Localized Collation - ORDER BY</h3>\n * <p>\n * In addition to SQLite's default <code>BINARY</code> collator, Android supplies\n * two more, <code>LOCALIZED</code>, which changes with the system's current locale,\n * and <code>UNICODE</code>, which is the Unicode Collation Algorithm and not tailored\n * to the current locale.\n * </p>\n */\npublic final class SQLiteDatabase {\n    private final Database mDB;\n\n    SQLiteDatabase(Database db) {\n        mDB = db;\n    }\n\n    /**\n     * When a constraint violation occurs, an immediate ROLLBACK occurs,\n     * thus ending the current transaction, and the command aborts with a\n     * return code of SQLITE_CONSTRAINT. If no transaction is active\n     * (other than the implied transaction that is created on every command)\n     * then this algorithm works the same as ABORT.\n     */\n    public static final int CONFLICT_ROLLBACK = 1;\n\n    /**\n     * When a constraint violation occurs,no ROLLBACK is executed\n     * so changes from prior commands within the same transaction\n     * are preserved. This is the default behavior.\n     */\n    public static final int CONFLICT_ABORT = 2;\n\n    /**\n     * When a constraint violation occurs, the command aborts with a return\n     * code SQLITE_CONSTRAINT. But any changes to the database that\n     * the command made prior to encountering the constraint violation\n     * are preserved and are not backed out.\n     */\n    public static final int CONFLICT_FAIL = 3;\n\n    /**\n     * When a constraint violation occurs, the one row that contains\n     * the constraint violation is not inserted or changed.\n     * But the command continues executing normally. Other rows before and\n     * after the row that contained the constraint violation continue to be\n     * inserted or updated normally. No error is returned.\n     */\n    public static final int CONFLICT_IGNORE = 4;\n\n    /**\n     * When a UNIQUE constraint violation occurs, the pre-existing rows that\n     * are causing the constraint violation are removed prior to inserting\n     * or updating the current row. Thus the insert or update always occurs.\n     * The command continues executing normally. No error is returned.\n     * If a NOT NULL constraint violation occurs, the NULL value is replaced\n     * by the default value for that column. If the column has no default\n     * value, then the ABORT algorithm is used. If a CHECK constraint\n     * violation occurs then the IGNORE algorithm is used. When this conflict\n     * resolution strategy deletes rows in order to satisfy a constraint,\n     * it does not invoke delete triggers on those rows.\n     * This behavior might change in a future release.\n     */\n    public static final int CONFLICT_REPLACE = 5;\n\n    /**\n     * Use the following when no conflict action is specified.\n     */\n    public static final int CONFLICT_NONE = 0;\n\n    private static final String[] CONFLICT_VALUES = new String[]\n            {\"\", \" OR ROLLBACK \", \" OR ABORT \", \" OR FAIL \", \" OR IGNORE \", \" OR REPLACE \"};\n\n\n    public Database getInnerDB() {\n        return mDB;\n    }\n\n    /**\n     * Attempts to release memory that SQLite holds but does not require to\n     * operate properly. Typically this memory will come from the page cache.\n     *\n     * @return the number of bytes actually released\n     */\n    public static int releaseMemory() {\n        Database.purgeAll();\n        // TODO: implement bytes actually released\n        return 0;\n    }\n\n    private static final class Transaction {\n        Transaction parent;\n        SQLiteTransactionListener listener;\n        boolean markedSuccessful;\n        boolean childFailed;\n    }\n\n    private final ThreadLocal<Transaction> mTransactionStack = new ThreadLocal<>();\n\n    private static void throwIfNoTransaction(Transaction stack) {\n        if (stack == null) {\n            throw new IllegalStateException(\"Cannot perform this operation because \"\n                    + \"there is no current transaction.\");\n        }\n    }\n\n    private static void throwIfTransactionMarkedSuccessful(Transaction stack) {\n        if (stack != null && stack.markedSuccessful) {\n            throw new IllegalStateException(\"Cannot perform this operation because \"\n                    + \"the transaction has already been marked successful.  The only \"\n                    + \"thing you can do now is call endTransaction().\");\n        }\n    }\n\n    public boolean isOpen() {\n        return mDB.isOpened();\n    }\n\n    /**\n     * Close all handle of current database\n     */\n    public void close() {\n        mDB.close();\n    }\n\n    /**\n     * Begins a transaction in EXCLUSIVE mode.\n     * <p>\n     * Transactions can be nested.\n     * When the outer transaction is ended all of\n     * the work done in that transaction and all of the nested transactions will be committed or\n     * rolled back. The changes will be rolled back if any transaction is ended without being\n     * marked as clean (by calling setTransactionSuccessful). Otherwise they will be committed.\n     * </p>\n     * <p>Here is the standard idiom for transactions:\n     * <p/>\n     * <pre>\n     *   db.beginTransaction();\n     *   try {\n     *     ...\n     *     db.setTransactionSuccessful();\n     *   } finally {\n     *     db.endTransaction();\n     *   }\n     * </pre>\n     */\n    public void beginTransaction() {\n        beginTransactionWithListener(null);\n    }\n\n    /**\n     * Begins a transaction in IMMEDIATE mode. Transactions can be nested. When\n     * the outer transaction is ended all of the work done in that transaction\n     * and all of the nested transactions will be committed or rolled back. The\n     * changes will be rolled back if any transaction is ended without being\n     * marked as clean (by calling setTransactionSuccessful). Otherwise they\n     * will be committed.\n     * <p/>\n     * Here is the standard idiom for transactions:\n     * <p/>\n     * <pre>\n     *   db.beginTransactionNonExclusive();\n     *   try {\n     *     ...\n     *     db.setTransactionSuccessful();\n     *   } finally {\n     *     db.endTransaction();\n     *   }\n     * </pre>\n     */\n    public void beginTransactionNonExclusive() {\n        beginTransactionWithListener(null);\n    }\n\n    /**\n     * Begins a transaction in EXCLUSIVE mode.\n     * <p>\n     * Transactions can be nested.\n     * When the outer transaction is ended all of\n     * the work done in that transaction and all of the nested transactions will be committed or\n     * rolled back. The changes will be rolled back if any transaction is ended without being\n     * marked as clean (by calling setTransactionSuccessful). Otherwise they will be committed.\n     * </p>\n     * <p>Here is the standard idiom for transactions:\n     * <p/>\n     * <pre>\n     *   db.beginTransactionWithListener(listener);\n     *   try {\n     *     ...\n     *     db.setTransactionSuccessful();\n     *   } finally {\n     *     db.endTransaction();\n     *   }\n     * </pre>\n     *\n     * @param transactionListener listener that should be notified when the transaction begins,\n     *                            commits, or is rolled back, either explicitly or by a call to\n     *                            {@link #yieldIfContendedSafely}.\n     */\n    public void beginTransactionWithListener(SQLiteTransactionListener transactionListener) {\n        Transaction stack = mTransactionStack.get();\n        throwIfTransactionMarkedSuccessful(stack);\n        if (stack == null) {\n            // No savepoint support here for compatibility\n            mDB.beginTransaction();\n        }\n\n        if (transactionListener != null) {\n            try {\n                transactionListener.onBegin();\n            } catch (RuntimeException e) {\n                if (stack == null) {\n                    mDB.rollbackTransaction();\n                }\n                throw e;\n            }\n        }\n\n        Transaction transaction = new Transaction();\n        transaction.listener = transactionListener;\n        transaction.parent = stack;\n        mTransactionStack.set(transaction);\n    }\n\n    /**\n     * Begins a transaction in IMMEDIATE mode. Transactions can be nested. When\n     * the outer transaction is ended all of the work done in that transaction\n     * and all of the nested transactions will be committed or rolled back. The\n     * changes will be rolled back if any transaction is ended without being\n     * marked as clean (by calling setTransactionSuccessful). Otherwise they\n     * will be committed.\n     * <p/>\n     * Here is the standard idiom for transactions:\n     * <p/>\n     * <pre>\n     *   db.beginTransactionWithListenerNonExclusive(listener);\n     *   try {\n     *     ...\n     *     db.setTransactionSuccessful();\n     *   } finally {\n     *     db.endTransaction();\n     *   }\n     * </pre>\n     *\n     * @param transactionListener listener that should be notified when the\n     *                            transaction begins, commits, or is rolled back, either\n     *                            explicitly or by a call to {@link #yieldIfContendedSafely}.\n     */\n    public void beginTransactionWithListenerNonExclusive(SQLiteTransactionListener transactionListener) {\n        beginTransactionWithListener(transactionListener);\n    }\n\n    /**\n     * End a transaction. See beginTransaction for notes about how to use this and when transactions\n     * are committed and rolled back.\n     */\n    public void endTransaction() {\n        Transaction stack = mTransactionStack.get();\n        throwIfNoTransaction(stack);\n\n        boolean successful = stack.markedSuccessful && !stack.childFailed;\n        SQLiteTransactionListener listener = stack.listener;\n        RuntimeException listenerException = null;\n        if (listener != null) {\n            try {\n                if (successful) {\n                    listener.onCommit();\n                } else {\n                    listener.onRollback();\n                }\n            } catch (RuntimeException e) {\n                listenerException = e;\n                successful = false;\n            }\n        }\n\n        Transaction parent = stack.parent;\n        mTransactionStack.set(parent);\n\n        if (parent != null) {\n            if (!successful) {\n                parent.childFailed = true;\n            }\n        } else if (successful) {\n            mDB.commitTransaction();\n        } else {\n            mDB.rollbackTransaction();\n        }\n\n        if (listenerException != null) {\n            throw listenerException;\n        }\n    }\n\n    /**\n     * Marks the current transaction as successful. Do not do any more database work between\n     * calling this and calling endTransaction. Do as little non-database work as possible in that\n     * situation too. If any errors are encountered between this and endTransaction the transaction\n     * will still be committed.\n     *\n     * @throws IllegalStateException if the current thread is not in a transaction or the\n     *                               transaction is already marked as successful.\n     */\n    public void setTransactionSuccessful() {\n        Transaction stack = mTransactionStack.get();\n        throwIfNoTransaction(stack);\n        throwIfTransactionMarkedSuccessful(stack);\n        stack.markedSuccessful = true;\n    }\n\n    /**\n     * Returns true if the current thread has a transaction pending.\n     *\n     * @return True if the current thread is in a transaction.\n     */\n    public boolean inTransaction() {\n        return mDB.isInTransaction();\n    }\n\n    // TODO: implement yield methods\n\n    /**\n     * Gets the database version.\n     *\n     * @return the database version\n     */\n    public int getVersion() {\n        return mDB.getValueFromSQL(\"PRAGMA user_version\").getInt();\n    }\n\n    /**\n     * Sets the database version.\n     *\n     * @param version the new database version\n     */\n    public void setVersion(int version) {\n        mDB.execute(\"PRAGMA user_version = \" + version);\n    }\n\n    /**\n     * Returns the maximum size the database may grow to.\n     *\n     * @return the new maximum database size\n     */\n    public long getMaximumSize() {\n        long pageCount = mDB.getValueFromSQL(\"PRAGMA max_page_count\").getLong();\n        return pageCount * getPageSize();\n    }\n\n    /**\n     * Sets the maximum size the database will grow to. The maximum size cannot\n     * be set below the current size.\n     *\n     * @param numBytes the maximum database size, in bytes\n     * @return the new maximum database size\n     * @deprecated use new {@code setConfig} methods to change configs to databases\n     */\n    public long setMaximumSize(long numBytes) {\n        long pageSize = getPageSize();\n        long numPages = numBytes / pageSize;\n        // If numBytes isn't a multiple of pageSize, bump up a page\n        if ((numBytes % pageSize) != 0) {\n            numPages++;\n        }\n        long newPageCount = mDB.getValueFromSQL(\"PRAGMA max_page_count = \" + numPages).getLong();\n        return newPageCount * pageSize;\n    }\n\n    /**\n     * Returns the current database page size, in bytes.\n     *\n     * @return the database page size, in bytes\n     */\n    public long getPageSize() {\n        return mDB.getValueFromSQL(\"PRAGMA page_size\").getLong();\n    }\n\n    /**\n     * Sets the database page size. The page size must be a power of two. This\n     * method does not work if any data has been written to the database file,\n     * and must be called right after the database has been created.\n     *\n     * @param numBytes the database page size, in bytes\n     * @deprecated use new {@code setConfig} methods to change configs to databases\n     */\n    public void setPageSize(long numBytes) {\n        mDB.execute(\"PRAGMA page_size = \" + numBytes);\n    }\n\n    /**\n     * Compiles an SQL statement into a reusable pre-compiled statement object.\n     * The parameters are identical to {@link #execSQL(String)}. You may put ?s in the\n     * statement and fill in those values with {@link SQLiteStatement#bindString}\n     * and {@link SQLiteStatement#bindLong} each time you want to run the\n     * statement. Statements may not return result sets larger than 1x1.\n     * <p>\n     * No two threads should be using the same {@link SQLiteStatement} at the same time.\n     *\n     * @param sql The raw SQL statement, may contain ? for unknown values to be\n     *            bound later.\n     * @return A pre-compiled {@link SQLiteStatement} object. Note that\n     * {@link SQLiteStatement}s are not synchronized, see the documentation for more details.\n     */\n    public SQLiteStatement compileStatement(String sql) {\n        return new SQLiteStatement(mDB, sql, null);\n    }\n\n    /**\n     * Query the given URL, returning a {@link Cursor} over the result set.\n     *\n     * @param distinct      true if you want each row to be unique, false otherwise.\n     * @param table         The table name to compile the query against.\n     * @param columns       A list of which columns to return. Passing null will\n     *                      return all columns, which is discouraged to prevent reading\n     *                      data from storage that isn't going to be used.\n     * @param selection     A filter declaring which rows to return, formatted as an\n     *                      SQL WHERE clause (excluding the WHERE itself). Passing null\n     *                      will return all rows for the given table.\n     * @param selectionArgs You may include ?s in selection, which will be\n     *                      replaced by the values from selectionArgs, in order that they\n     *                      appear in the selection. The values will be bound as Strings.\n     * @param groupBy       A filter declaring how to group rows, formatted as an SQL\n     *                      GROUP BY clause (excluding the GROUP BY itself). Passing null\n     *                      will cause the rows to not be grouped.\n     * @param having        A filter declare which row groups to include in the cursor,\n     *                      if row grouping is being used, formatted as an SQL HAVING\n     *                      clause (excluding the HAVING itself). Passing null will cause\n     *                      all row groups to be included, and is required when row\n     *                      grouping is not being used.\n     * @param orderBy       How to order the rows, formatted as an SQL ORDER BY clause\n     *                      (excluding the ORDER BY itself). Passing null will use the\n     *                      default sort order, which may be unordered.\n     * @param limit         Limits the number of rows returned by the query,\n     *                      formatted as LIMIT clause. Passing null denotes no LIMIT clause.\n     * @return A {@link Cursor} object, which is positioned before the first entry. Note that\n     * {@link Cursor}s are not synchronized, see the documentation for more details.\n     * @see Cursor\n     */\n    public Cursor query(boolean distinct, String table, String[] columns,\n                        String selection, String[] selectionArgs, String groupBy,\n                        String having, String orderBy, String limit) {\n        return query(distinct, table, columns, selection, selectionArgs, groupBy, having, orderBy,\n                limit, null);\n    }\n\n    /**\n     * Query the given URL, returning a {@link Cursor} over the result set.\n     *\n     * @param distinct           true if you want each row to be unique, false otherwise.\n     * @param table              The table name to compile the query against.\n     * @param columns            A list of which columns to return. Passing null will\n     *                           return all columns, which is discouraged to prevent reading\n     *                           data from storage that isn't going to be used.\n     * @param selection          A filter declaring which rows to return, formatted as an\n     *                           SQL WHERE clause (excluding the WHERE itself). Passing null\n     *                           will return all rows for the given table.\n     * @param selectionArgs      You may include ?s in selection, which will be\n     *                           replaced by the values from selectionArgs, in order that they\n     *                           appear in the selection. The values will be bound as Strings.\n     * @param groupBy            A filter declaring how to group rows, formatted as an SQL\n     *                           GROUP BY clause (excluding the GROUP BY itself). Passing null\n     *                           will cause the rows to not be grouped.\n     * @param having             A filter declare which row groups to include in the cursor,\n     *                           if row grouping is being used, formatted as an SQL HAVING\n     *                           clause (excluding the HAVING itself). Passing null will cause\n     *                           all row groups to be included, and is required when row\n     *                           grouping is not being used.\n     * @param orderBy            How to order the rows, formatted as an SQL ORDER BY clause\n     *                           (excluding the ORDER BY itself). Passing null will use the\n     *                           default sort order, which may be unordered.\n     * @param limit              Limits the number of rows returned by the query,\n     *                           formatted as LIMIT clause. Passing null denotes no LIMIT clause.\n     * @param cancellationSignal A signal to cancel the operation in progress, or null if none.\n     *                           If the operation is canceled, then {@link OperationCanceledException} will be thrown\n     *                           when the query is executed.\n     * @return A {@link Cursor} object, which is positioned before the first entry. Note that\n     * {@link Cursor}s are not synchronized, see the documentation for more details.\n     * @see Cursor\n     */\n    public Cursor query(boolean distinct, String table, String[] columns,\n                        String selection, String[] selectionArgs, String groupBy,\n                        String having, String orderBy, String limit, CancellationSignal cancellationSignal) {\n        String sql = SQLiteQueryBuilder.buildQueryString(\n                distinct, table, columns, selection, groupBy, having, orderBy, limit);\n        return rawQuery(sql, selectionArgs, cancellationSignal);\n    }\n\n    /**\n     * Query the given table, returning a {@link Cursor} over the result set.\n     *\n     * @param table         The table name to compile the query against.\n     * @param columns       A list of which columns to return. Passing null will\n     *                      return all columns, which is discouraged to prevent reading\n     *                      data from storage that isn't going to be used.\n     * @param selection     A filter declaring which rows to return, formatted as an\n     *                      SQL WHERE clause (excluding the WHERE itself). Passing null\n     *                      will return all rows for the given table.\n     * @param selectionArgs You may include ?s in selection, which will be\n     *                      replaced by the values from selectionArgs, in order that they\n     *                      appear in the selection. The values will be bound as Strings.\n     * @param groupBy       A filter declaring how to group rows, formatted as an SQL\n     *                      GROUP BY clause (excluding the GROUP BY itself). Passing null\n     *                      will cause the rows to not be grouped.\n     * @param having        A filter declare which row groups to include in the cursor,\n     *                      if row grouping is being used, formatted as an SQL HAVING\n     *                      clause (excluding the HAVING itself). Passing null will cause\n     *                      all row groups to be included, and is required when row\n     *                      grouping is not being used.\n     * @param orderBy       How to order the rows, formatted as an SQL ORDER BY clause\n     *                      (excluding the ORDER BY itself). Passing null will use the\n     *                      default sort order, which may be unordered.\n     * @return A {@link Cursor} object, which is positioned before the first entry. Note that\n     * {@link Cursor}s are not synchronized, see the documentation for more details.\n     * @see Cursor\n     */\n    public Cursor query(String table, String[] columns, String selection,\n                        String[] selectionArgs, String groupBy, String having,\n                        String orderBy) {\n\n        return query(false, table, columns, selection, selectionArgs, groupBy,\n                having, orderBy, null /* limit */);\n    }\n\n    /**\n     * Query the given table, returning a {@link Cursor} over the result set.\n     *\n     * @param table         The table name to compile the query against.\n     * @param columns       A list of which columns to return. Passing null will\n     *                      return all columns, which is discouraged to prevent reading\n     *                      data from storage that isn't going to be used.\n     * @param selection     A filter declaring which rows to return, formatted as an\n     *                      SQL WHERE clause (excluding the WHERE itself). Passing null\n     *                      will return all rows for the given table.\n     * @param selectionArgs You may include ?s in selection, which will be\n     *                      replaced by the values from selectionArgs, in order that they\n     *                      appear in the selection. The values will be bound as Strings.\n     * @param groupBy       A filter declaring how to group rows, formatted as an SQL\n     *                      GROUP BY clause (excluding the GROUP BY itself). Passing null\n     *                      will cause the rows to not be grouped.\n     * @param having        A filter declare which row groups to include in the cursor,\n     *                      if row grouping is being used, formatted as an SQL HAVING\n     *                      clause (excluding the HAVING itself). Passing null will cause\n     *                      all row groups to be included, and is required when row\n     *                      grouping is not being used.\n     * @param orderBy       How to order the rows, formatted as an SQL ORDER BY clause\n     *                      (excluding the ORDER BY itself). Passing null will use the\n     *                      default sort order, which may be unordered.\n     * @param limit         Limits the number of rows returned by the query,\n     *                      formatted as LIMIT clause. Passing null denotes no LIMIT clause.\n     * @return A {@link Cursor} object, which is positioned before the first entry. Note that\n     * {@link Cursor}s are not synchronized, see the documentation for more details.\n     * @see Cursor\n     */\n    public Cursor query(String table, String[] columns, String selection,\n                        String[] selectionArgs, String groupBy, String having,\n                        String orderBy, String limit) {\n\n        return query(false, table, columns, selection, selectionArgs, groupBy,\n                having, orderBy, limit);\n    }\n\n    /**\n     * Runs the provided SQL and returns a {@link Cursor} over the result set.\n     *\n     * @param sql           the SQL query. The SQL string must not be ; terminated\n     * @param selectionArgs You may include ?s in where clause in the query,\n     *                      which will be replaced by the values from selectionArgs. The\n     *                      values will be bound as Strings.\n     * @return A {@link Cursor} object, which is positioned before the first entry. Note that\n     * {@link Cursor}s are not synchronized, see the documentation for more details.\n     */\n    public Cursor rawQuery(String sql, Object[] selectionArgs) {\n        return rawQuery(sql, selectionArgs, null);\n    }\n\n    /**\n     * Runs the provided SQL and returns a {@link Cursor} over the result set.\n     *\n     * @param sql                the SQL query. The SQL string must not be ; terminated\n     * @param selectionArgs      You may include ?s in where clause in the query,\n     *                           which will be replaced by the values from selectionArgs. The\n     *                           values will be bound as Strings.\n     * @param cancellationSignal A signal to cancel the operation in progress, or null if none.\n     *                           If the operation is canceled, then {@link OperationCanceledException} will be thrown\n     *                           when the query is executed.\n     * @return A {@link Cursor} object, which is positioned before the first entry. Note that\n     * {@link Cursor}s are not synchronized, see the documentation for more details.\n     */\n    public Cursor rawQuery(String sql, Object[] selectionArgs,\n                           CancellationSignal cancellationSignal) {\n        try (Handle handle = mDB.getHandle(false)) {\n            DatabaseUtils.bindCancellationSignal(handle, cancellationSignal);\n\n            PreparedStatement stmt = handle.preparedWithMainStatement(sql);\n            if (selectionArgs != null) {\n                int nArgs = selectionArgs.length;\n                for (int i = 0; i < nArgs; ++i) {\n                    stmt.bindValue(new Value(selectionArgs[i]), i + 1);\n                }\n            }\n\n            String[] columnNames = new String[stmt.getColumnCount()];\n            for (int i = 0; i < columnNames.length; ++i) {\n                columnNames[i] = stmt.getColumnName(i);\n            }\n\n            List<Value[]> result = stmt.getMultiRows();\n            stmt.finalizeStatement();\n            return new ValueCursor(result, columnNames);\n        } catch (WCDBInterruptException e) {\n            throw (OperationCanceledException) (new OperationCanceledException().initCause(e));\n        }\n    }\n\n    /**\n     * Convenience method for inserting a row into the database.\n     *\n     * @param table          the table to insert the row into\n     * @param nullColumnHack optional; may be <code>null</code>.\n     *                       SQL doesn't allow inserting a completely empty row without\n     *                       naming at least one column name.  If your provided <code>values</code> is\n     *                       empty, no column names are known and an empty row can't be inserted.\n     *                       If not set to null, the <code>nullColumnHack</code> parameter\n     *                       provides the name of nullable column name to explicitly insert a NULL into\n     *                       in the case where your <code>values</code> is empty.\n     * @param values         this map contains the initial column values for the\n     *                       row. The keys should be the column names and the values the\n     *                       column values\n     * @return the row ID of the newly inserted row, or -1 if an error occurred\n     */\n    public long insert(String table, String nullColumnHack, ContentValues values) {\n        try {\n            return insertWithOnConflict(table, nullColumnHack, values, CONFLICT_NONE);\n        } catch (WCDBException e) {\n            // TODO: print logs\n            //Log.e(TAG, \"Error inserting \" + values, e);\n            return -1;\n        }\n    }\n\n    /**\n     * Convenience method for inserting a row into the database.\n     *\n     * @param table          the table to insert the row into\n     * @param nullColumnHack optional; may be <code>null</code>.\n     *                       SQL doesn't allow inserting a completely empty row without\n     *                       naming at least one column name.  If your provided <code>values</code> is\n     *                       empty, no column names are known and an empty row can't be inserted.\n     *                       If not set to null, the <code>nullColumnHack</code> parameter\n     *                       provides the name of nullable column name to explicitly insert a NULL into\n     *                       in the case where your <code>values</code> is empty.\n     * @param values         this map contains the initial column values for the\n     *                       row. The keys should be the column names and the values the\n     *                       column values\n     * @return the row ID of the newly inserted row, or -1 if an error occurred\n     * @throws SQLException\n     */\n    public long insertOrThrow(String table, String nullColumnHack, ContentValues values)\n            throws SQLException {\n        return insertWithOnConflict(table, nullColumnHack, values, CONFLICT_NONE);\n    }\n\n    /**\n     * Convenience method for replacing a row in the database.\n     * Inserts a new row if a row does not already exist.\n     *\n     * @param table          the table in which to replace the row\n     * @param nullColumnHack optional; may be <code>null</code>.\n     *                       SQL doesn't allow inserting a completely empty row without\n     *                       naming at least one column name.  If your provided <code>initialValues</code> is\n     *                       empty, no column names are known and an empty row can't be inserted.\n     *                       If not set to null, the <code>nullColumnHack</code> parameter\n     *                       provides the name of nullable column name to explicitly insert a NULL into\n     *                       in the case where your <code>initialValues</code> is empty.\n     * @param initialValues  this map contains the initial column values for\n     *                       the row. The keys should be the column names and the values the column values.\n     * @return the row ID of the newly inserted row, or -1 if an error occurred\n     */\n    public long replace(String table, String nullColumnHack, ContentValues initialValues) {\n        try {\n            return insertWithOnConflict(table, nullColumnHack, initialValues,\n                    CONFLICT_REPLACE);\n        } catch (SQLException e) {\n            // TODO: print logs\n            //Log.e(TAG, \"Error inserting \" + initialValues, e);\n            return -1;\n        }\n    }\n\n    /**\n     * Convenience method for replacing a row in the database.\n     * Inserts a new row if a row does not already exist.\n     *\n     * @param table          the table in which to replace the row\n     * @param nullColumnHack optional; may be <code>null</code>.\n     *                       SQL doesn't allow inserting a completely empty row without\n     *                       naming at least one column name.  If your provided <code>initialValues</code> is\n     *                       empty, no column names are known and an empty row can't be inserted.\n     *                       If not set to null, the <code>nullColumnHack</code> parameter\n     *                       provides the name of nullable column name to explicitly insert a NULL into\n     *                       in the case where your <code>initialValues</code> is empty.\n     * @param initialValues  this map contains the initial column values for\n     *                       the row. The keys should be the column names and the values the column values.\n     * @return the row ID of the newly inserted row, or -1 if an error occurred\n     * @throws SQLException\n     */\n    public long replaceOrThrow(String table, String nullColumnHack,\n                               ContentValues initialValues) throws SQLException {\n        return insertWithOnConflict(table, nullColumnHack, initialValues,\n                CONFLICT_REPLACE);\n    }\n\n    /**\n     * General method for inserting a row into the database.\n     *\n     * @param table             the table to insert the row into\n     * @param nullColumnHack    optional; may be <code>null</code>.\n     *                          SQL doesn't allow inserting a completely empty row without\n     *                          naming at least one column name.  If your provided <code>initialValues</code> is\n     *                          empty, no column names are known and an empty row can't be inserted.\n     *                          If not set to null, the <code>nullColumnHack</code> parameter\n     *                          provides the name of nullable column name to explicitly insert a NULL into\n     *                          in the case where your <code>initialValues</code> is empty.\n     * @param initialValues     this map contains the initial column values for the\n     *                          row. The keys should be the column names and the values the\n     *                          column values\n     * @param conflictAlgorithm for insert conflict resolver\n     * @return the row ID of the newly inserted row OR <code>-1</code> if either the\n     * input parameter <code>conflictAlgorithm</code> = {@link #CONFLICT_IGNORE}\n     * or an error occurred.\n     */\n    public long insertWithOnConflict(String table, String nullColumnHack,\n                                     ContentValues initialValues, int conflictAlgorithm) {\n        String[] columns;\n        Object[] bindArgs;\n        int size = (initialValues != null && initialValues.size() > 0)\n                ? initialValues.size() : 0;\n        if (size > 0) {\n            bindArgs = new Object[size];\n            columns = new String[size];\n            int i = 0;\n            for (String colName : initialValues.keySet()) {\n                columns[i] = colName;\n                bindArgs[i++] = initialValues.get(colName);\n            }\n        } else {\n            columns = new String[]{nullColumnHack};\n            bindArgs = new Object[]{null};\n        }\n\n        StatementInsert insert = new StatementInsert().insertInto(table);\n        switch (conflictAlgorithm) {\n            case CONFLICT_NONE:\n                break;\n            case CONFLICT_ROLLBACK:\n                insert.orRollback();\n                break;\n            case CONFLICT_ABORT:\n                insert.orAbort();\n                break;\n            case CONFLICT_FAIL:\n                insert.orFail();\n                break;\n            case CONFLICT_IGNORE:\n                insert.orIgnore();\n                break;\n            case CONFLICT_REPLACE:\n                insert.orReplace();\n                break;\n        }\n        insert.columns(columns).valuesWithBindParameters(bindArgs.length);\n        try (Handle handle = mDB.getHandle(true)) {\n            PreparedStatement stmt = handle.preparedWithMainStatement(insert);\n            for (int i = 0; i < bindArgs.length; ++i) {\n                stmt.bindValue(new Value(bindArgs[i]), i + 1);\n            }\n            do {\n                stmt.step();\n            } while (!stmt.isDone());\n            stmt.finalizeStatement();\n            return handle.getLastInsertedRowId();\n        }\n    }\n\n    /**\n     * Convenience method for deleting rows in the database.\n     *\n     * @param table       the table to delete from\n     * @param whereClause the optional WHERE clause to apply when deleting.\n     *                    Passing null will delete all rows.\n     * @param whereArgs   You may include ?s in the where clause, which\n     *                    will be replaced by the values from whereArgs. The values\n     *                    will be bound as Strings.\n     * @return the number of rows affected if a whereClause is passed in, 0\n     * otherwise. To remove all rows and get a count pass \"1\" as the\n     * whereClause.\n     */\n    public int delete(String table, String whereClause, String[] whereArgs) {\n        String sql = \"DELETE FROM \" + table +\n                (!TextUtils.isEmpty(whereClause) ? \" WHERE \" + whereClause : \"\");\n        try (Handle handle = mDB.getHandle(true)) {\n            PreparedStatement stmt = handle.preparedWithMainStatement(sql);\n            if (whereArgs != null) {\n                for (int i = 0; i < whereArgs.length; ++i) {\n                    stmt.bindText(whereArgs[i], i + 1);\n                }\n            }\n            do {\n                stmt.step();\n            } while (!stmt.isDone());\n            stmt.finalizeStatement();\n            return handle.getChanges();\n        }\n    }\n\n    /**\n     * Convenience method for updating rows in the database.\n     *\n     * @param table       the table to update in\n     * @param values      a map from column names to new column values. null is a\n     *                    valid value that will be translated to NULL.\n     * @param whereClause the optional WHERE clause to apply when updating.\n     *                    Passing null will update all rows.\n     * @param whereArgs   You may include ?s in the where clause, which\n     *                    will be replaced by the values from whereArgs. The values\n     *                    will be bound as Strings.\n     * @return the number of rows affected\n     */\n    public int update(String table, ContentValues values, String whereClause, String[] whereArgs) {\n        return updateWithOnConflict(table, values, whereClause, whereArgs, CONFLICT_NONE);\n    }\n\n    /**\n     * Convenience method for updating rows in the database.\n     *\n     * @param table             the table to update in\n     * @param values            a map from column names to new column values. null is a\n     *                          valid value that will be translated to NULL.\n     * @param whereClause       the optional WHERE clause to apply when updating.\n     *                          Passing null will update all rows.\n     * @param whereArgs         You may include ?s in the where clause, which\n     *                          will be replaced by the values from whereArgs. The values\n     *                          will be bound as Strings.\n     * @param conflictAlgorithm for update conflict resolver\n     * @return the number of rows affected\n     */\n    public int updateWithOnConflict(String table, ContentValues values,\n                                    String whereClause, String[] whereArgs, int conflictAlgorithm) {\n        StringBuilder sql = new StringBuilder(120);\n        sql.append(\"UPDATE \");\n        sql.append(CONFLICT_VALUES[conflictAlgorithm]);\n        sql.append(table);\n        sql.append(\" SET \");\n\n        // move all bind args to one array\n        int setValuesSize = values.size();\n        int bindArgsSize = (whereArgs == null) ? setValuesSize : (setValuesSize + whereArgs.length);\n        Object[] bindArgs = new Object[bindArgsSize];\n        int i = 0;\n        for (String colName : values.keySet()) {\n            sql.append((i > 0) ? \",\" : \"\");\n            sql.append(colName);\n            bindArgs[i++] = values.get(colName);\n            sql.append(\"=?\");\n        }\n        if (whereArgs != null) {\n            for (i = setValuesSize; i < bindArgsSize; i++) {\n                bindArgs[i] = whereArgs[i - setValuesSize];\n            }\n        }\n        if (!TextUtils.isEmpty(whereClause)) {\n            sql.append(\" WHERE \");\n            sql.append(whereClause);\n        }\n        try (Handle handle = mDB.getHandle(true)) {\n            PreparedStatement stmt = handle.preparedWithMainStatement(sql.toString());\n            for (i = 0; i < bindArgsSize; ++i) {\n                stmt.bindValue(new Value(bindArgs[i]), i + 1);\n            }\n            do {\n                stmt.step();\n            } while (!stmt.isDone());\n            stmt.finalizeStatement();\n            return handle.getChanges();\n        }\n    }\n\n    /**\n     * Execute a single SQL statement that is NOT a SELECT\n     * or any other SQL statement that returns data.\n     * <p>\n     * It has no means to return any data (such as the number of affected rows).\n     * Instead, you're encouraged to use {@link #insert(String, String, ContentValues)},\n     * {@link #update(String, ContentValues, String, String[])}, et al, when possible.\n     * </p>\n     * <p>\n     * When using {@link #enableWriteAheadLogging()}, journal_mode is\n     * automatically managed by this class. So, do not set journal_mode\n     * using \"PRAGMA journal_mode'<value>\" statement if your app is using\n     * {@link #enableWriteAheadLogging()}\n     * </p>\n     * <p>\n     * Note that {@code PRAGMA} values which apply on a per-connection basis\n     * should <em>not</em> be configured using this method; you should instead\n     * use {@link #execPerConnectionSQL} to ensure that they are uniformly\n     * applied to all current and future connections.\n     * </p>\n     *\n     * @param sql the SQL statement to be executed. Multiple statements separated by semicolons are\n     *            not supported.\n     * @throws SQLException if the SQL string is invalid\n     */\n    public void execSQL(String sql) {\n        execSQL(sql, null);\n    }\n\n    /**\n     * Execute a single SQL statement that is NOT a SELECT/INSERT/UPDATE/DELETE.\n     * <p>\n     * For INSERT statements, use any of the following instead.\n     * <ul>\n     *   <li>{@link #insert(String, String, ContentValues)}</li>\n     *   <li>{@link #insertOrThrow(String, String, ContentValues)}</li>\n     *   <li>{@link #insertWithOnConflict(String, String, ContentValues, int)}</li>\n     * </ul>\n     * <p>\n     * For UPDATE statements, use any of the following instead.\n     * <ul>\n     *   <li>{@link #update(String, ContentValues, String, String[])}</li>\n     *   <li>{@link #updateWithOnConflict(String, ContentValues, String, String[], int)}</li>\n     * </ul>\n     * <p>\n     * For DELETE statements, use any of the following instead.\n     * <ul>\n     *   <li>{@link #delete(String, String, String[])}</li>\n     * </ul>\n     * <p>\n     * For example, the following are good candidates for using this method:\n     * <ul>\n     *   <li>ALTER TABLE</li>\n     *   <li>CREATE or DROP table / trigger / view / index / virtual table</li>\n     *   <li>REINDEX</li>\n     *   <li>RELEASE</li>\n     *   <li>SAVEPOINT</li>\n     *   <li>PRAGMA that returns no data</li>\n     * </ul>\n     * </p>\n     * <p>\n     * When using {@link #enableWriteAheadLogging()}, journal_mode is\n     * automatically managed by this class. So, do not set journal_mode\n     * using \"PRAGMA journal_mode'<value>\" statement if your app is using\n     * {@link #enableWriteAheadLogging()}\n     * </p>\n     * <p>\n     * Note that {@code PRAGMA} values which apply on a per-connection basis\n     * should <em>not</em> be configured using this method; you should instead\n     * use {@link #execPerConnectionSQL} to ensure that they are uniformly\n     * applied to all current and future connections.\n     * </p>\n     *\n     * @param sql      the SQL statement to be executed. Multiple statements separated by semicolons are\n     *                 not supported.\n     * @param bindArgs only byte[], String, Long and Double are supported in bindArgs.\n     * @throws SQLException if the SQL string is invalid\n     */\n    public int execSQL(String sql, Object[] bindArgs) {\n        return execSQL(sql, bindArgs, null);\n    }\n\n    public int execSQL(String sql, Object[] bindArgs, CancellationSignal cancellationSignal) {\n        try (SQLiteStatement stmt = new SQLiteStatement(mDB, sql, bindArgs)) {\n            return stmt.execute(cancellationSignal);\n        }\n    }\n\n    /**\n     * Gets the path to the database file.\n     *\n     * @return The path to the database file.\n     */\n    public String getPath() {\n        return mDB.getPath();\n    }\n\n    @Override\n    public String toString() {\n        return \"SQLiteDatabase: \" + getPath();\n    }\n\n    public static SQLiteDatabase wrap(Database db) {\n        return new SQLiteDatabase(db);\n    }\n\n    /**\n     * Open the database according to the flags {@link #OPEN_READWRITE}\n     * {@link #OPEN_READONLY} {@link #CREATE_IF_NECESSARY} and/or {@link #NO_LOCALIZED_COLLATORS}.\n     * <p/>\n     * <p>Sets the locale of the database to the  the system's current locale.\n     * Call {@link #setLocale} if you would like something else.</p>\n     *\n     * @param path    to database file to open and/or create\n     * @param factory an optional factory class that is called to instantiate a\n     *                cursor when query is called, or null for default\n     * @param flags   to control database access mode\n     * @return the newly opened database\n     * @throws SQLiteException if the database cannot be opened\n     */\n    public static SQLiteDatabase openDatabase(String path) {\n        return openDatabase(path, null, null, null);\n    }\n\n    public static SQLiteDatabase openDatabase(String path, DatabaseErrorHandler errorHandler) {\n        return openDatabase(path, null, null, errorHandler);\n    }\n\n    public static SQLiteDatabase openDatabase(String path, byte[] password, SQLiteCipherSpec cipher) {\n        return openDatabase(path, password, cipher, null);\n    }\n\n    /**\n     * Open the database according to the flags {@link #OPEN_READWRITE}\n     * {@link #OPEN_READONLY} {@link #CREATE_IF_NECESSARY} and/or {@link #NO_LOCALIZED_COLLATORS}.\n     * <p/>\n     * <p>Sets the locale of the database to the  the system's current locale.\n     * Call {@link #setLocale} if you would like something else.</p>\n     * <p/>\n     * <p>Accepts input param: a concrete instance of {@link DatabaseErrorHandler} to be\n     * used to handle corruption when sqlite reports database corruption.</p>\n     *\n     * @param path         to database file to open and/or create\n     * @param password     password to the encrypted database, or null for plain-text database\n     * @param cipher       cipher description, or null for default settings\n     * @param errorHandler the {@link DatabaseErrorHandler} obj to be used to handle corruption\n     *                     when sqlite reports database corruption\n     * @return the newly opened database\n     * @throws SQLiteException if the database cannot be opened\n     */\n    public static SQLiteDatabase openDatabase(String path, byte[] password, final SQLiteCipherSpec cipher,\n                                              final DatabaseErrorHandler errorHandler) {\n        Database db = new Database(path);\n        if (password != null) {\n            if (cipher == null) {\n                db.setCipherKey(password);\n            } else {\n                if (cipher.cipherVersion >= 0) {\n                    db.setCipherKey(password, cipher.pageSize, kCipherVersionMapping[cipher.cipherVersion]);\n                } else {\n                    db.setCipherKey(password, cipher.pageSize);\n                    db.setConfig(\"com.Tencent.WCDB.Config.CipherSpecCompat\", new Database.Config() {\n                        @Override\n                        public void onInvocation(@NotNull Handle handle) throws WCDBException {\n                            handle.execute(\"PRAGMA cipher_use_hmac = \" + cipher.hmacEnabled);\n                            if (cipher.kdfIteration != 0) {\n                                handle.execute(\"PRAGMA kdf_iter = \" + cipher.kdfIteration);\n                            }\n                            if (cipher.hmacAlgorithm != SQLiteCipherSpec.HMAC_DEFAULT) {\n                                handle.execute(\"PRAGMA cipher_hmac_algorithm = \" +\n                                        SQLiteCipherSpec.HMAC_ALGO_MAPPING[cipher.hmacAlgorithm]);\n                            }\n                            if (cipher.kdfAlgorithm != SQLiteCipherSpec.HMAC_DEFAULT) {\n                                handle.execute(\"PRAGMA cipher_kdf_algorithm = \" +\n                                        SQLiteCipherSpec.PBKDF2_ALGO_MAPPING[cipher.kdfAlgorithm]);\n                            }\n                        }\n                    }, Database.ConfigPriority.highest);\n                }\n            }\n        }\n\n        final SQLiteDatabase dbObj = new SQLiteDatabase(db);\n        Database.CorruptionNotification corruptionNotification = new Database.CorruptionNotification() {\n            private final DatabaseErrorHandler mHandler = (errorHandler == null) ?\n                    sDefaultErrorHandler : errorHandler;\n\n            @Override\n            public void onCorrupted(Database database) {\n                mHandler.onCorruption(dbObj);\n            }\n        };\n        db.setNotificationWhenCorrupted(corruptionNotification);\n\n        if (!db.canOpen()) {\n            corruptionNotification.onCorrupted(db);\n            Handle handle = db.getHandle();     // May throw\n            handle.invalidate();\n        }\n        return dbObj;\n    }\n\n    private static final Database.CipherVersion[] kCipherVersionMapping = Database.CipherVersion.values();\n\n    private static final DatabaseErrorHandler sDefaultErrorHandler = new DatabaseErrorHandler() {\n        @Override\n        public void onCorruption(SQLiteDatabase dbObj) {\n            Database db = dbObj.getInnerDB();\n            db.removeFiles();\n        }\n    };\n}\n"
  },
  {
    "path": "src/java/compat/src/main/java/com/tencent/wcdb/compat/SQLiteStatement.java",
    "content": "package com.tencent.wcdb.compat;\n\nimport android.database.sqlite.SQLiteClosable;\nimport android.database.sqlite.SQLiteDoneException;\nimport android.os.CancellationSignal;\nimport android.text.TextUtils;\n\nimport com.tencent.wcdb.base.Value;\nimport com.tencent.wcdb.core.Database;\nimport com.tencent.wcdb.core.Handle;\nimport com.tencent.wcdb.core.PreparedStatement;\n\nimport java.util.ArrayList;\nimport java.util.Arrays;\n\npublic final class SQLiteStatement extends SQLiteClosable {\n    private final Database mDB;\n    private final String mSql;\n    private final ArrayList<Object> mBindArgs = new ArrayList<>();\n\n    SQLiteStatement(Database db, String sql, Object[] bindArgs) {\n        mDB = db;\n        mSql = sql;\n        if (bindArgs != null) {\n            mBindArgs.addAll(Arrays.asList(bindArgs));\n        }\n    }\n\n    private void execute(Handle handle, CancellationSignal cancellationSignal) {\n        DatabaseUtils.bindCancellationSignal(handle, cancellationSignal);\n\n        PreparedStatement stmt = handle.preparedWithMainStatement(mSql);\n        int i = 1;\n        for (Object arg : mBindArgs) {\n            stmt.bindValue(new Value(arg), i++);\n        }\n        do {\n            stmt.step();\n        } while (!stmt.isDone());\n        stmt.finalizeStatement();\n    }\n\n    private Value executeForValue(Handle handle, CancellationSignal cancellationSignal) {\n        DatabaseUtils.bindCancellationSignal(handle, cancellationSignal);\n\n        PreparedStatement stmt = handle.preparedWithMainStatement(mSql);\n        int i = 1;\n        for (Object arg : mBindArgs) {\n            stmt.bindValue(new Value(arg), i++);\n        }\n        stmt.step();\n        if (stmt.isDone()) {\n            throw new SQLiteDoneException();\n        }\n        Value result = stmt.getValue(0);\n        stmt.finalizeStatement();\n        return result;\n    }\n\n    /**\n     * @see #execute(CancellationSignal)\n     * Executes a readonly database-operation without support for cancellation.\n     */\n    public int execute() {\n        return execute(null);\n    }\n\n    /**\n     * Executes a readonly database-operation with support for cancellation.\n     *\n     * @param cancellationSignal The CancellationSignal to cancel the operation if requested.\n     *                           This allows the operation to be stopped in progress, useful for\n     *                           long-running queries or operations that the user may wish to cancel.\n     * @return The number of changes made by the operation if it is not read-only; otherwise, returns 0.\n     * This provides insight into how many rows were affected in the case of a modification.\n     * @throws android.database.SQLException If the SQL string is invalid for\n     *                                       some reason\n     */\n    public int execute(CancellationSignal cancellationSignal) {\n        try (Handle handle = mDB.getHandle(!TextUtils.isEmpty(mSql) && !mSql.toLowerCase().startsWith(\"select\"))) {\n            execute(handle, cancellationSignal);\n            return handle.getChanges();\n        }\n    }\n\n    /**\n     * Execute this SQL statement, if the number of rows affected by execution of this SQL\n     * statement is of any importance to the caller - for example, UPDATE / DELETE SQL statements.\n     *\n     * @return the number of rows affected by this SQL statement execution.\n     * @throws android.database.SQLException If the SQL string is invalid for\n     *                                       some reason\n     */\n    public int executeUpdateDelete() {\n        return executeUpdateDelete(null);\n    }\n\n    public int executeUpdateDelete(CancellationSignal cancellationSignal) {\n        try (Handle handle = mDB.getHandle(true)) {\n            execute(handle, cancellationSignal);\n            return handle.getChanges();\n        }\n    }\n\n    /**\n     * Execute this SQL statement and return the ID of the row inserted due to this call.\n     * The SQL statement should be an INSERT for this to be a useful call.\n     *\n     * @return the row ID of the last row inserted, if this insert is successful. -1 otherwise.\n     * @throws android.database.SQLException If the SQL string is invalid for\n     *                                       some reason\n     */\n    public long executeInsert() {\n        return executeInsert(null);\n    }\n\n    public long executeInsert(CancellationSignal cancellationSignal) {\n        try (Handle handle = mDB.getHandle(true)) {\n            execute(handle, cancellationSignal);\n            return handle.getLastInsertedRowId();\n        }\n    }\n\n    /**\n     * Execute a statement that returns a 1 by 1 table with a numeric value.\n     * For example, SELECT COUNT(*) FROM table;\n     *\n     * @return The result of the query.\n     * @throws android.database.sqlite.SQLiteDoneException if the query returns zero rows\n     */\n    public long simpleQueryForLong() {\n        return simpleQueryForLong(null);\n    }\n\n    public long simpleQueryForLong(CancellationSignal cancellationSignal) {\n        // since just query, we can use read-only mode\n        try (Handle handle = mDB.getHandle(false)) {\n            return executeForValue(handle, cancellationSignal).getLong();\n        }\n    }\n\n    /**\n     * Execute a statement that returns a 1 by 1 table with a text value.\n     * For example, SELECT COUNT(*) FROM table;\n     *\n     * @return The result of the query.\n     * @throws android.database.sqlite.SQLiteDoneException if the query returns zero rows\n     */\n    public String simpleQueryForString() {\n        return simpleQueryForString(null);\n    }\n\n    public String simpleQueryForString(CancellationSignal cancellationSignal) {\n        try (Handle handle = mDB.getHandle(false)) {\n            return executeForValue(handle, cancellationSignal).getText();\n        }\n    }\n\n    /**\n     * Bind a NULL value to this statement. The value remains bound until\n     * {@link #clearBindings} is called.\n     *\n     * @param index The 1-based index to the parameter to bind null to\n     */\n    public void bindNull(int index) {\n        bind(index, null);\n    }\n\n    /**\n     * Bind a long value to this statement. The value remains bound until\n     * {@link #clearBindings} is called.\n     * addToBindArgs\n     *\n     * @param index The 1-based index to the parameter to bind\n     * @param value The value to bind\n     */\n    public void bindLong(int index, long value) {\n        bind(index, value);\n    }\n\n    /**\n     * Bind a double value to this statement. The value remains bound until\n     * {@link #clearBindings} is called.\n     *\n     * @param index The 1-based index to the parameter to bind\n     * @param value The value to bind\n     */\n    public void bindDouble(int index, double value) {\n        bind(index, value);\n    }\n\n    /**\n     * Bind a String value to this statement. The value remains bound until\n     * {@link #clearBindings} is called.\n     *\n     * @param index The 1-based index to the parameter to bind\n     * @param value The value to bind, must not be null\n     */\n    public void bindString(int index, String value) {\n        if (value == null) {\n            throw new IllegalArgumentException(\"the bind value at index \" + index + \" is null\");\n        }\n        bind(index, value);\n    }\n\n    /**\n     * Bind a byte array value to this statement. The value remains bound until\n     * {@link #clearBindings} is called.\n     *\n     * @param index The 1-based index to the parameter to bind\n     * @param value The value to bind, must not be null\n     */\n    public void bindBlob(int index, byte[] value) {\n        if (value == null) {\n            throw new IllegalArgumentException(\"the bind value at index \" + index + \" is null\");\n        }\n        bind(index, value);\n    }\n\n    public void bindAllArgs(Object[] bindArgs) {\n        if (bindArgs == null) return;\n\n        int length = bindArgs.length;\n        if (mBindArgs.size() < length) {\n            mBindArgs.ensureCapacity(length);\n            do {\n                mBindArgs.add(null);\n            } while (mBindArgs.size() < length);\n        }\n        for (int i = 0; i < length; ++i) {\n            mBindArgs.set(i, bindArgs[i]);\n        }\n    }\n\n    /**\n     * Clears all existing bindings. Unset bindings are treated as NULL.\n     */\n    public void clearBindings() {\n        mBindArgs.clear();\n    }\n\n    @Override\n    protected void onAllReferencesReleased() {\n        clearBindings();\n    }\n\n    private void bind(int index, Object value) {\n        if (index < 1) {\n            throw new IllegalArgumentException(\"Cannot bind argument at index \"\n                    + index + \" because the index is out of range.\");\n        }\n\n        if (mBindArgs.size() < index) {\n            mBindArgs.ensureCapacity(index);\n            do {\n                mBindArgs.add(null);\n            } while (mBindArgs.size() < index);\n        }\n        mBindArgs.set(index - 1, value);\n    }\n\n    @Override\n    public String toString() {\n        return \"SQLiteProgram: \" + mSql;\n    }\n}\n"
  },
  {
    "path": "src/java/compat/src/main/java/com/tencent/wcdb/compat/ValueCursor.java",
    "content": "package com.tencent.wcdb.compat;\n\nimport android.database.AbstractCursor;\n\nimport com.tencent.wcdb.base.Value;\nimport com.tencent.wcdb.winq.ColumnType;\n\nimport java.util.List;\n\nclass ValueCursor extends AbstractCursor {\n    private final List<Value[]> mRows;\n    private final String[] mColumnNames;\n\n    ValueCursor(List<Value[]> rows, String[] columnNames) {\n        mRows = rows;\n        mColumnNames = columnNames;\n    }\n\n    @Override\n    public int getCount() {\n        return mRows.size();\n    }\n\n    @Override\n    public String[] getColumnNames() {\n        return mColumnNames;\n    }\n\n    @Override\n    public int getType(int column) {\n        Value[] row = mRows.get(mPos);\n        // At this time, type ordinal just match the FIELD_XXX value.\n        return row[column].getType().ordinal();\n    }\n\n    @Override\n    public String getString(int column) {\n        Value[] row = mRows.get(mPos);\n        return row[column].getText();\n    }\n\n    @Override\n    public short getShort(int column) {\n        Value[] row = mRows.get(mPos);\n        return (short) row[column].getLong();\n    }\n\n    @Override\n    public int getInt(int column) {\n        Value[] row = mRows.get(mPos);\n        return row[column].getInt();\n    }\n\n    @Override\n    public long getLong(int column) {\n        Value[] row = mRows.get(mPos);\n        return row[column].getLong();\n    }\n\n    @Override\n    public float getFloat(int column) {\n        Value[] row = mRows.get(mPos);\n        return (float) row[column].getDouble();\n    }\n\n    @Override\n    public double getDouble(int column) {\n        Value[] row = mRows.get(mPos);\n        return row[column].getDouble();\n    }\n\n    @Override\n    public byte[] getBlob(int column) {\n        Value[] row = mRows.get(mPos);\n        return row[column].getBLOB();\n    }\n\n    @Override\n    public boolean isNull(int column) {\n        Value[] row = mRows.get(mPos);\n        return row[column].getType() == ColumnType.Null;\n    }\n}"
  },
  {
    "path": "src/java/gradle/WeChatPublish.gradle",
    "content": "Class extensionClass\n\n// Detect supported plugin modules\nif (plugins.hasPlugin('com.android.library')) {\n    // Android library mode\n    extensionClass = WeChatAndroidLibraryPublishExtension\n} else if (plugins.hasPlugin('java')) {\n    // Java library mode\n    if (plugins.hasPlugin('java-gradle-plugin')) {\n        extensionClass = WeChatGradlePluginPublishExtension\n    } else {\n        extensionClass = WeChatJavaLibraryPublishExtension\n    }\n} else {\n    // TODO: Support more languages\n    throw new GradleException('This plugin must be applied after \"java\" or \"com.android.library\" plugin')\n}\n\n// Register wechatPublish extension\nextensions.create('wechatPublish', extensionClass, project)\next.artifactId = name\next.getFullVersion = { return extensions.getByType(WeChatPublishExtension).getFullVersion() }\n\nclass WeChatPublishExtension {\n\n    boolean isSnapshot = true\n    private String versionSuffix = ''\n    protected boolean printModules = false\n\n    boolean withJavadoc = true\n    boolean withSources = true\n    boolean withNativeSymbols = true\n    boolean withDependencies = true\n\n    boolean publishToBintray = false /* Deprecated */\n\n    boolean publishAllVariants = false\n    Set<String> publishVariants = []\n\n    boolean publishAllFlavors = true\n    Set<String> publishFlavors = []\n    String defaultFlavor\n\n    boolean checkRemoteArtifactExistence = false\n\n    private final Project project\n    private boolean usedDefaultIsSnapshot = true\n\n    private final ArrayList<Closure> mavenPublishClosures = []\n\n    protected final ArrayList<Closure> pomClosures = []\n\n    WeChatPublishExtension(Project proj) {\n        project = proj\n        fillDefaultConfiguration()\n        proj.afterEvaluate { this.publish() }\n    }\n\n    protected final String uncapitalize(String str) {\n        if (str == null || str.isEmpty()) {\n            return str\n        }\n        return \"\" + Character.toLowerCase(str.charAt(0)) + str.substring(1)\n    }\n\n    protected void publish() {\n        // Load local gradle script\n        applyLocalScript()\n\n        // Verify configuration values\n        verifyPublishConfiguration()\n\n        // Emit Maven DSL\n        // Apply plugins if not done already\n        if (!project.plugins.hasPlugin('maven-publish')) {\n            project.plugins.apply('maven-publish')\n        }\n\n        mountAdditionalLogic(project)\n\n        emitPublicationDSL(project)\n\n        if (project.hasProperty('signingKeyId') || project.hasProperty('signing.keyId')) {\n            if (!project.plugins.hasPlugin('signing')) {\n                project.plugins.apply('signing')\n            }\n            emitSigningConfig(project)\n        }\n\n        emitRepositoryDSL(project)\n    }\n\n    void bintrayPackage(Closure cl) {\n         // if (cl != null)\n         //     bintrayConfigureClosures << cl\n    }\n\n    void publishToMaven(Closure cl) {\n        if (cl != null)\n            mavenPublishClosures << cl\n    }\n\n    void pom(Closure cl) {\n        if (cl != null)\n            pomClosures << cl\n    }\n\n    void publishToBintray(Closure cl) {\n         if (cl != null) {\n             publishToBintray = true\n             // bintrayConfigureClosures << cl\n         }\n    }\n\n    String getFullVersion() {\n        def ver = version + versionSuffix\n        if (isSnapshot && !ver.endsWith('-SNAPSHOT'))\n            ver += '-SNAPSHOT'\n        return ver\n    }\n\n    protected void fillDefaultConfiguration() {\n        isSnapshot = !project.rootProject.hasProperty('release')\n        printModules = project.rootProject.hasProperty('printModules')\n        if (project.rootProject.hasProperty('versionSuffix'))\n            versionSuffix = project.rootProject.versionSuffix\n    }\n\n    private void applyLocalScript() {\n        def localScriptFile\n        if (project.rootProject.hasProperty('repoScript')) {\n            // Repo script file specified using -PrepoScript=xxx argument, use that script.\n            def repoScript = project.rootProject.property('repoScript')\n            if (!repoScript.startsWith('/'))\n                repoScript = \"${System.getProperty('user.dir')}/${repoScript}\"\n            localScriptFile = new File(repoScript)\n        } else {\n            // No -PrepoScript=xxx argument, try 'local.gradle' in projectDir then rootProjectDir\n            localScriptFile = project.file('local.gradle')\n            if (!localScriptFile.file)\n                localScriptFile = project.rootProject.file('local.gradle')\n        }\n\n        if (localScriptFile.file) {\n            project.apply from: localScriptFile\n        }\n    }\n\n    private void verifyPublishConfiguration() {\n        // Warn default artifactId, groupId, version\n        if (groupId.empty) {\n            groupId = 'com.tencent.mm'\n            System.err.println \"groupId not specified, used default value: ${groupId}\"\n        }\n\n        if (version == 'unspecified') {\n            version = '0.1'\n            System.err.println \"version not specified, used default value: ${version}\"\n        }\n        checkVersion()\n\n        if (!usedDefaultIsSnapshot) {\n            System.err.println 'isSnapshot should be avoided in build scripts.'\n        }\n\n        if (isSnapshot) {\n            // Bintray does not allow SNAPSHOT publish\n            publishToBintray = false\n        }\n\n        project.ext.fullVersion = fullVersion\n    }\n\n    private void checkVersion() {\n        // Support Maven or Conan version\n        if (!(fullVersion ==~ /\\d+\\.\\d+(?:\\.\\d+)?(?:\\.\\d+)?(?:-[\\w-]+)?/) &&\n            !(fullVersion ==~ /\\d+\\.\\d+(?:\\.\\d+)?(?:-[\\w_-]+(?:\\.[\\w_-]+)*)?(?:\\+[\\w_-]+(?:\\.[\\w_-]+)*)?/)) {\n            def message = \"Invalid version: ${fullVersion}\"\n            if (!isSnapshot)\n                throw new GradleException(message)\n            System.err.println(message)\n        }\n    }\n\n    final protected String getPublicationName() {\n        String result = \"\"\n        artifactId.split(\"[-_]\").each { result += it.capitalize() }\n        return uncapitalize(result)\n    }\n\n    protected void mountAdditionalLogic(Project project) {}\n\n    protected void emitPublicationDSL(Project project) {}\n\n    private void emitSigningConfig(Project project) {\n        project.ext['signing.keyId'] = project.findProperty(\"signingKeyId\")\n        project.ext['signing.password'] = project.findProperty(\"signingPassword\")\n        project.ext['signing.secretKeyRingFile'] = project.findProperty(\"signingSecretKeyRingFile\")\n        project.signing {\n            project.publishing.publications.all { publication ->\n                sign publication\n            }\n        }\n    }\n\n    private void emitRepositoryDSL(Project project) {\n        mavenPublishClosures.each { cl ->\n            project.publishing.repositories {\n                maven {\n                    cl.delegate = delegate\n                    cl()\n                }\n            }\n        }\n\n        if (publishToBintray) {\n            System.err.println(\"[WeChatPublish] [W] 'publishToBintray' was deprecated and ignored now, consider migrate to MavenCentral instead.\")\n        }\n    }\n\n    protected void validateArtifactNotExists(Project project, String groupId, String artifactId, String version) {\n        if (!checkRemoteArtifactExistence) {\n            return\n        }\n        if (isSnapshot) {\n            System.out.println(\"[WeChatPublish] [I] Snapshot version, skip artifact existance validation.\")\n            return\n        }\n        project.gradle.taskGraph.whenReady {\n            project.publishing.repositories.each { repo ->\n                def conn\n                try {\n                    def repoUrlStr = repo.url.toString()\n                    if (repoUrlStr.startsWith('https://')) {\n                        repoUrlStr = 'http://' + repoUrlStr.substring(8)\n                    }\n                    def url = new URL(\"${repoUrlStr}/${groupId.replace('.', '/')}/${artifactId}/${version}\")\n                    conn = url.openConnection() as HttpURLConnection\n                    conn.setRequestMethod('GET')\n                    conn.connectTimeout = 3000\n                    conn.readTimeout = 5000\n                    try {\n                        def respHttpCode = conn.responseCode\n                        if (respHttpCode == 200 || respHttpCode == 302) {\n                            throw new GradleException(\"Artifact ${groupId}:${artifactId}:${version} has already exist in repo ${repoUrlStr}\")\n                        }\n                    } catch (SocketTimeoutException e) {\n                        System.err.println(\"Timeout when checking if '${groupId}:${artifactId}:${version}' exists in '${repoUrlStr}'.\")\n                    }\n                } finally {\n                    try {\n                        conn.disconnect()\n                    } catch (ignored) {\n                        // Ignored.\n                    }\n                }\n            }\n        }\n    }\n\n    String getArtifactId() {\n        return project.artifactId\n    }\n\n    void setArtifactId(String id) {\n        project.artifactId = id\n    }\n\n    String getGroupId() {\n        return project.group\n    }\n\n    void setGroupId(String id) {\n        project.group = id\n    }\n\n    String getVersion() {\n        return project.version\n    }\n\n    void setVersion(String ver) {\n        project.version = ver\n    }\n\n    void setIsSnapshot(boolean v) {\n        isSnapshot = v\n        usedDefaultIsSnapshot = false\n    }\n}\n\nclass WeChatJavaLibraryPublishExtension extends WeChatPublishExtension {\n\n    WeChatJavaLibraryPublishExtension(Project project) {\n        super(project)\n    }\n\n    @Override\n    protected void mountAdditionalLogic(Project project) {\n        // Print module description if needed\n        if (printModules) {\n            def printTask = project.tasks.register('printPublishArtifactInfo') {\n                doFirst {\n                    println \"@@@WeChatPublish@@@ ${groupId}:${artifactId}:${fullVersion}\"\n                }\n            }\n            project.tasks.named('compileJava') {\n                dependsOn printTask\n            }\n        }\n    }\n\n    @Override\n    protected void emitPublicationDSL(Project project) {\n\n        def sourcesJarTask = project.tasks.register('sourcesJar', Jar) {\n            archiveClassifier = 'sources'\n\n            def srcDirs = []\n            def sources = project.sourceSets.main\n            ['java', 'groovy', 'scala', 'kotlin'].each {\n                if (sources.hasProperty(it))\n                    srcDirs << sources[it].srcDirs\n            }\n\n            from srcDirs\n        }\n\n        def javadocTask = project.tasks.named('javadoc', Javadoc)\n        javadocTask.configure {\n            title = null\n            options {\n                memberLevel = JavadocMemberLevel.PUBLIC\n            }\n            it\n        }\n\n        def javadocJarTask = project.tasks.register('javadocJar', Jar) {\n            dependsOn javadocTask\n            archiveClassifier = 'javadoc'\n            from javadocTask.get().destinationDir\n        }\n        // TODO: upload javadoc to documentation site\n\n        project.publishing.publications.create(publicationName, MavenPublication) {\n            from project.components.java\n\n            groupId this.groupId\n            artifactId this.artifactId\n            version this.fullVersion\n\n            validateArtifactNotExists(project, groupId, artifactId, version)\n\n            // Emit sourcesJar task\n            if (withSources) {\n                artifact sourcesJarTask\n            }\n\n            // Emit javadocJar task\n            if (withJavadoc) {\n                artifact javadocJarTask\n            }\n\n            pomClosures.each { pom it }\n        }\n    }\n}\n\nclass WeChatGradlePluginPublishExtension extends WeChatJavaLibraryPublishExtension {\n    WeChatGradlePluginPublishExtension(Project project) {\n        super(project)\n    }\n\n    @Override\n    protected void emitPublicationDSL(Project project) {\n        PublicationContainer publications = project.publishing.publications\n        def pluginExtension = project.extensions.getByType(GradlePluginDevelopmentExtension)\n        if (pluginExtension.automatedPublishing) {\n            // Publications are added by the plugin, nothing to do.\n            // Version to publish may be wrong.\n            return\n        }\n\n        super.emitPublicationDSL(project)\n        def mainPublication = publications.getByName(publicationName) as MavenPublication\n        for (plugin in pluginExtension.plugins) {\n            publications.create(\"${plugin.name}PluginMarkerMaven\", MavenPublication) {\n                alias true\n                artifactId \"${plugin.id}.gradle.plugin\"\n                groupId plugin.id\n                version this.fullVersion\n                pom {\n                    name.set(plugin.displayName)\n                    description.set(plugin.description)\n                    withXml {\n                        def node = asNode().appendNode('dependencies').appendNode('dependency')\n                        node.appendNode('groupId', mainPublication.groupId)\n                        node.appendNode('artifactId', mainPublication.artifactId)\n                        node.appendNode('version', mainPublication.version)\n                    }\n                }\n            }\n        }\n    }\n}\n\nclass WeChatAndroidLibraryPublishExtension extends WeChatPublishExtension {\n\n    WeChatAndroidLibraryPublishExtension(Project project) {\n        super(project)\n    }\n\n    @Override\n    protected void mountAdditionalLogic(Project project) {\n        // Print module description if needed\n        if (printModules) {\n            def printTask = project.tasks.register('printPublishArtifactInfo') {\n                doFirst {\n                    println \"@@@WeChatPublish@@@ ${groupId}:${artifactId}:${fullVersion}\"\n                }\n            }\n            project.tasks.named('preBuild') {\n                dependsOn printTask\n            }\n        }\n    }\n\n    @Override\n    protected void emitPublicationDSL(Project project) {\n        HashSet<String> emittedFlavors = new HashSet<>()\n        def android = project.android\n        def hasReleaseVariant = false\n\n        android.libraryVariants.all { variant ->\n            def variantName = variant.name\n            def cVariantName = variantName.capitalize()\n\n            def flavorName = variant.flavorName\n            def variantOnlyName = uncapitalize(variantName.substring(flavorName.length(), variantName.length()))\n            def hasFlavor = variant.flavorName != null && !variant.flavorName.isEmpty()\n\n            if (flavorName == defaultFlavor)\n                flavorName = ''\n            def cFlavorName = flavorName.capitalize()\n\n            if (!publishAllFlavors && !flavorName.empty && !publishFlavors.contains(flavorName))\n                return\n\n            def generateSourcesTask = project.tasks.named(\"generate${cVariantName}Sources\")\n\n            def javadocTask = project.tasks.register(\"javadoc${cVariantName}\", Javadoc) {\n                group = 'documentation'\n                title = null\n\n                def classpathFiles = project.files(android.getBootClasspath().join(File.pathSeparator))\n                classpathFiles += project.configurations.named(\"${variantName}RuntimeClasspath\").get().fileCollection()\n                doFirst { classpath += classpathFiles }\n\n                source = variant.javaCompileProvider.get().source\n                options {\n                    memberLevel = JavadocMemberLevel.PUBLIC\n                }\n                destinationDir = project.file(\"${project.buildDir}/docs/javadoc\")\n                exclude '**/BuildConfig.java'\n                exclude '**/R.java'\n                failOnError false\n\n                dependsOn generateSourcesTask\n            }\n\n            def javadocJarTask = project.tasks.register(\"javadocJar${cVariantName}\", Jar) {\n                archiveClassifier = 'javadoc'\n                from javadocTask.get().destinationDir\n                dependsOn javadocTask\n            }\n\n            def sourcesJarTask = project.tasks.register(\"sourcesJar${cVariantName}\", Jar) {\n                archiveClassifier = 'sources'\n\n                def srcDirs = []\n                variant.sourceSets.each { sources ->\n                    ['java', 'groovy', 'scala', 'kotlin'].each {\n                        if (sources.hasProperty(it))\n                            srcDirs << sources[it].srcDirs\n                    }\n                }\n\n                from srcDirs\n                dependsOn generateSourcesTask\n            }\n\n            TaskProvider<Zip> nativeSymbolZipTask = null\n            try {\n                def externalNativeBuildTask = project.tasks.named(\"externalNativeBuild${cVariantName}\")\n\n                nativeSymbolZipTask = project.tasks.register(\"nativeSymbolZip${cVariantName}\", Zip) {\n                    archiveClassifier = \"${variantOnlyName}Symbols\"\n                    def objFolder = externalNativeBuildTask.get().soFolder.asFile.get()\n                    from(objFolder) {\n                        include '*/*.so'\n                        exclude 'obj'\n                    }\n                    from(\"${objFolder}/obj\") {\n                        include '*/*.so'\n                    }\n                    dependsOn externalNativeBuildTask\n                }\n\n                externalNativeBuildTask.configure {\n                    doLast {\n                        // If externalNativeBuild generates no shared library files,\n                        // remove symbols artifact from the publication.\n                        if (nativeSymbolZipTask.get().inputs.sourceFiles.empty) {\n                            def publication = project.publishing.publications\n                                    .getByName(\"${publicationName}${cFlavorName}\")\n                            publication.artifacts.removeIf {\n                                it.file == nativeSymbolZipTask.get().archivePath\n                            }\n                        }\n                    }\n                }\n            } catch (UnknownTaskException e) {\n                // no external build task, okay\n            }\n\n            TaskProvider<Task> bundleTask\n            try {\n                bundleTask = project.tasks.named(\"bundle${cVariantName}Aar\")\n            } catch (UnknownTaskException e) {\n                bundleTask = project.tasks.named(\"bundle${cVariantName}\")\n            }\n\n            project.publishing.publications {\n                \"${publicationName}${cFlavorName}\"(MavenPublication) {\n                    if (variantOnlyName == 'release') {\n                        hasReleaseVariant = true\n\n                        artifact(source: bundleTask, classifier: null)\n\n                        if (withSources) {\n                            artifact(source: sourcesJarTask, classifier: 'sources')\n                        }\n                        if (withJavadoc) {\n                            artifact(source: javadocJarTask, classifier: 'javadoc')\n                        }\n                        if (withNativeSymbols && nativeSymbolZipTask != null) {\n                            artifact(source: nativeSymbolZipTask, classifier: 'symbols')\n                        }\n                    } else if (publishAllVariants || publishVariants.contains(variantOnlyName)) {\n                        artifact(source: bundleTask, classifier: variantOnlyName)\n\n                        if (withNativeSymbols && nativeSymbolZipTask != null) {\n                            artifact(source: nativeSymbolZipTask, classifier: \"${variantOnlyName}Symbols\")\n                        }\n                    }\n\n                    if (!emittedFlavors.contains(flavorName)) {\n                        emittedFlavors << flavorName\n\n                        groupId this.groupId\n                        version this.fullVersion\n\n                        if (hasFlavor) {\n                            def currFlavor = variant.productFlavors.get(0)\n                            def actualArtifactIdSuffix = ''\n                            if (currFlavor.ext.has('artifactIdSuffix')) {\n                                actualArtifactIdSuffix = currFlavor.ext.artifactIdSuffix\n                                int firstNotBarPos = 0\n                                while (firstNotBarPos < actualArtifactIdSuffix.length()\n                                        && actualArtifactIdSuffix.charAt(firstNotBarPos) == '-') {\n                                    ++firstNotBarPos\n                                }\n                                actualArtifactIdSuffix = actualArtifactIdSuffix.substring(firstNotBarPos)\n                            } else {\n                                actualArtifactIdSuffix = flavorName\n                            }\n                            artifactId actualArtifactIdSuffix.empty ?\n                                    this.artifactId : \"${this.artifactId}-${actualArtifactIdSuffix}\"\n                        } else {\n                            artifactId this.artifactId\n                        }\n\n                        validateArtifactNotExists(project, groupId, artifactId, version)\n\n                        pom {\n                            packaging 'aar'\n\n                            withXml {\n                                // Resolve dependencies\n                                final depsNode = asNode().appendNode('dependencies')\n                                final addDep = { Dependency dep, String scope ->\n                                    if (dep.group == null || dep.version == null || dep.name == null\n                                            || dep.name == \"unspecified\")\n                                        return // ignore invalid dependencies\n\n                                    // Determine actual artifactId for the dependency\n                                    def artifactId = dep.name\n                                    def version = dep.version\n                                    if (dep instanceof ProjectDependency) {\n                                        def p = (dep as ProjectDependency).dependencyProject\n                                        if (p.hasProperty('artifactId'))\n                                            artifactId = p.property('artifactId')\n                                        if (p.hasProperty('fullVersion'))\n                                            version = p.property('fullVersion')\n                                    }\n\n                                    def node = depsNode.appendNode('dependency')\n                                    node.appendNode('groupId', dep.group)\n                                    node.appendNode('artifactId', artifactId)\n                                    node.appendNode('version', version)\n                                    node.appendNode('scope', scope)\n\n                                    if (!dep.transitive) {\n                                        // If this dependency is transitive, we should force exclude all its dependencies them from the POM\n                                        final exclusionNode = node.appendNode('exclusions').appendNode('exclusion')\n                                        exclusionNode.appendNode('groupId', '*')\n                                        exclusionNode.appendNode('artifactId', '*')\n                                    } else if (!dep.properties.excludeRules.empty) {\n                                        // Otherwise add specified exclude rules\n                                        final exclusions = node.appendNode('exclusions')\n                                        dep.properties.excludeRules.each { ExcludeRule rule ->\n                                            def exclusionNode = exclusions.appendNode('exclusion')\n                                            exclusionNode.appendNode('groupId', rule.group ?: '*')\n                                            exclusionNode.appendNode('artifactId', rule.module ?: '*')\n                                        }\n                                    }\n                                }\n\n                                if (withDependencies) {\n                                    def visitedDeps = [] as Set<Dependency>\n\n                                    [\n                                            'compile':            'compile',\n                                            'api':                'compile',\n                                            'implementation':     'compile',\n                                            'runtimeOnly':        'runtime',\n                                            'provided':           'runtime'\n                                    ].each { conf, scope ->\n                                        if (project.configurations.find {\n                                            it.name.equals(conf)\n                                        }) {\n                                            project.configurations[conf].allDependencies.each {\n                                                if (visitedDeps.contains(it)) {\n                                                    return\n                                                }\n                                                addDep(it, scope)\n                                                visitedDeps.add(it)\n                                            }\n                                        }\n                                    }\n                                }\n                            }\n                        }\n                    }\n                }\n            }\n\n            pomClosures.each { cl ->\n                project.publishing.publications {\n                    \"${publicationName}${cFlavorName}\"(MavenPublication) {\n                        pom cl\n                    }\n                }\n            }\n        } // android.libraryVariants.all\n\n        // Check whether \"release\" variant is published\n        project.afterEvaluate {\n            if (!hasReleaseVariant)\n                throw new GradleException('Publishing Android library require \"release\" variant')\n        }\n    }\n}\n"
  },
  {
    "path": "src/java/gradle/wrapper/gradle-wrapper.properties",
    "content": "#Fri Mar 17 16:04:14 CST 2023\ndistributionBase=GRADLE_USER_HOME\ndistributionUrl=https\\://services.gradle.org/distributions/gradle-8.10.2-bin.zip\ndistributionPath=wrapper/dists\nzipStorePath=wrapper/dists\nzipStoreBase=GRADLE_USER_HOME\n"
  },
  {
    "path": "src/java/gradle.properties",
    "content": "# Project-wide Gradle settings.\n# IDE (e.g. Android Studio) users:\n# Gradle settings configured through the IDE *will override*\n# any settings specified in this file.\n# For more details on how to configure your build environment visit\n# http://www.gradle.org/docs/current/userguide/build_environment.html\n# Specifies the JVM arguments used for the daemon process.\n# The setting is particularly useful for tweaking memory settings.\norg.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8\n# When configured, Gradle will run in incubating parallel mode.\n# This option should only be used with decoupled projects. More details, visit\n# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects\n# org.gradle.parallel=true\n# AndroidX package structure to make it clearer which packages are bundled with the\n# Android operating system, and which are packaged with your app's APK\n# https://developer.android.com/topic/libraries/support-library/androidx-rn\nandroid.useAndroidX=true\n# Enables namespacing of each library's R class so that its R class includes only the\n# resources declared in the library itself and none from the library's dependencies,\n# thereby reducing the size of the R class for that library\nandroid.nonTransitiveRClass=true"
  },
  {
    "path": "src/java/gradlew",
    "content": "#!/usr/bin/env sh\n\n#\n# Copyright 2015 the original author or authors.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n#      https://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n#\n\n##############################################################################\n##\n##  Gradle start up script for UN*X\n##\n##############################################################################\n\n# Attempt to set APP_HOME\n# Resolve links: $0 may be a link\nPRG=\"$0\"\n# Need this for relative symlinks.\nwhile [ -h \"$PRG\" ] ; do\n    ls=`ls -ld \"$PRG\"`\n    link=`expr \"$ls\" : '.*-> \\(.*\\)$'`\n    if expr \"$link\" : '/.*' > /dev/null; then\n        PRG=\"$link\"\n    else\n        PRG=`dirname \"$PRG\"`\"/$link\"\n    fi\ndone\nSAVED=\"`pwd`\"\ncd \"`dirname \\\"$PRG\\\"`/\" >/dev/null\nAPP_HOME=\"`pwd -P`\"\ncd \"$SAVED\" >/dev/null\n\nAPP_NAME=\"Gradle\"\nAPP_BASE_NAME=`basename \"$0\"`\n\n# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.\nDEFAULT_JVM_OPTS='\"-Xmx64m\" \"-Xms64m\"'\n\n# Use the maximum available, or set MAX_FD != -1 to use that value.\nMAX_FD=\"maximum\"\n\nwarn () {\n    echo \"$*\"\n}\n\ndie () {\n    echo\n    echo \"$*\"\n    echo\n    exit 1\n}\n\n# OS specific support (must be 'true' or 'false').\ncygwin=false\nmsys=false\ndarwin=false\nnonstop=false\ncase \"`uname`\" in\n  CYGWIN* )\n    cygwin=true\n    ;;\n  Darwin* )\n    darwin=true\n    ;;\n  MINGW* )\n    msys=true\n    ;;\n  NONSTOP* )\n    nonstop=true\n    ;;\nesac\n\nCLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar\n\n\n# Determine the Java command to use to start the JVM.\nif [ -n \"$JAVA_HOME\" ] ; then\n    if [ -x \"$JAVA_HOME/jre/sh/java\" ] ; then\n        # IBM's JDK on AIX uses strange locations for the executables\n        JAVACMD=\"$JAVA_HOME/jre/sh/java\"\n    else\n        JAVACMD=\"$JAVA_HOME/bin/java\"\n    fi\n    if [ ! -x \"$JAVACMD\" ] ; then\n        die \"ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME\n\nPlease set the JAVA_HOME variable in your environment to match the\nlocation of your Java installation.\"\n    fi\nelse\n    JAVACMD=\"java\"\n    which java >/dev/null 2>&1 || die \"ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.\n\nPlease set the JAVA_HOME variable in your environment to match the\nlocation of your Java installation.\"\nfi\n\n# Increase the maximum file descriptors if we can.\nif [ \"$cygwin\" = \"false\" -a \"$darwin\" = \"false\" -a \"$nonstop\" = \"false\" ] ; then\n    MAX_FD_LIMIT=`ulimit -H -n`\n    if [ $? -eq 0 ] ; then\n        if [ \"$MAX_FD\" = \"maximum\" -o \"$MAX_FD\" = \"max\" ] ; then\n            MAX_FD=\"$MAX_FD_LIMIT\"\n        fi\n        ulimit -n $MAX_FD\n        if [ $? -ne 0 ] ; then\n            warn \"Could not set maximum file descriptor limit: $MAX_FD\"\n        fi\n    else\n        warn \"Could not query maximum file descriptor limit: $MAX_FD_LIMIT\"\n    fi\nfi\n\n# For Darwin, add options to specify how the application appears in the dock\nif $darwin; then\n    GRADLE_OPTS=\"$GRADLE_OPTS \\\"-Xdock:name=$APP_NAME\\\" \\\"-Xdock:icon=$APP_HOME/media/gradle.icns\\\"\"\nfi\n\n# For Cygwin or MSYS, switch paths to Windows format before running java\nif [ \"$cygwin\" = \"true\" -o \"$msys\" = \"true\" ] ; then\n    APP_HOME=`cygpath --path --mixed \"$APP_HOME\"`\n    CLASSPATH=`cygpath --path --mixed \"$CLASSPATH\"`\n\n    JAVACMD=`cygpath --unix \"$JAVACMD\"`\n\n    # We build the pattern for arguments to be converted via cygpath\n    ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`\n    SEP=\"\"\n    for dir in $ROOTDIRSRAW ; do\n        ROOTDIRS=\"$ROOTDIRS$SEP$dir\"\n        SEP=\"|\"\n    done\n    OURCYGPATTERN=\"(^($ROOTDIRS))\"\n    # Add a user-defined pattern to the cygpath arguments\n    if [ \"$GRADLE_CYGPATTERN\" != \"\" ] ; then\n        OURCYGPATTERN=\"$OURCYGPATTERN|($GRADLE_CYGPATTERN)\"\n    fi\n    # Now convert the arguments - kludge to limit ourselves to /bin/sh\n    i=0\n    for arg in \"$@\" ; do\n        CHECK=`echo \"$arg\"|egrep -c \"$OURCYGPATTERN\" -`\n        CHECK2=`echo \"$arg\"|egrep -c \"^-\"`                                 ### Determine if an option\n\n        if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then                    ### Added a condition\n            eval `echo args$i`=`cygpath --path --ignore --mixed \"$arg\"`\n        else\n            eval `echo args$i`=\"\\\"$arg\\\"\"\n        fi\n        i=`expr $i + 1`\n    done\n    case $i in\n        0) set -- ;;\n        1) set -- \"$args0\" ;;\n        2) set -- \"$args0\" \"$args1\" ;;\n        3) set -- \"$args0\" \"$args1\" \"$args2\" ;;\n        4) set -- \"$args0\" \"$args1\" \"$args2\" \"$args3\" ;;\n        5) set -- \"$args0\" \"$args1\" \"$args2\" \"$args3\" \"$args4\" ;;\n        6) set -- \"$args0\" \"$args1\" \"$args2\" \"$args3\" \"$args4\" \"$args5\" ;;\n        7) set -- \"$args0\" \"$args1\" \"$args2\" \"$args3\" \"$args4\" \"$args5\" \"$args6\" ;;\n        8) set -- \"$args0\" \"$args1\" \"$args2\" \"$args3\" \"$args4\" \"$args5\" \"$args6\" \"$args7\" ;;\n        9) set -- \"$args0\" \"$args1\" \"$args2\" \"$args3\" \"$args4\" \"$args5\" \"$args6\" \"$args7\" \"$args8\" ;;\n    esac\nfi\n\n# Escape application args\nsave () {\n    for i do printf %s\\\\n \"$i\" | sed \"s/'/'\\\\\\\\''/g;1s/^/'/;\\$s/\\$/' \\\\\\\\/\" ; done\n    echo \" \"\n}\nAPP_ARGS=`save \"$@\"`\n\n# Collect all arguments for the java command, following the shell quoting and substitution rules\neval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS \"\\\"-Dorg.gradle.appname=$APP_BASE_NAME\\\"\" -classpath \"\\\"$CLASSPATH\\\"\" org.gradle.wrapper.GradleWrapperMain \"$APP_ARGS\"\n\nexec \"$JAVACMD\" \"$@\"\n"
  },
  {
    "path": "src/java/gradlew.bat",
    "content": "@rem\r\n@rem Copyright 2015 the original author or authors.\r\n@rem\r\n@rem Licensed under the Apache License, Version 2.0 (the \"License\");\r\n@rem you may not use this file except in compliance with the License.\r\n@rem You may obtain a copy of the License at\r\n@rem\r\n@rem      https://www.apache.org/licenses/LICENSE-2.0\r\n@rem\r\n@rem Unless required by applicable law or agreed to in writing, software\r\n@rem distributed under the License is distributed on an \"AS IS\" BASIS,\r\n@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n@rem See the License for the specific language governing permissions and\r\n@rem limitations under the License.\r\n@rem\r\n\r\n@if \"%DEBUG%\" == \"\" @echo off\r\n@rem ##########################################################################\r\n@rem\r\n@rem  Gradle startup script for Windows\r\n@rem\r\n@rem ##########################################################################\r\n\r\n@rem Set local scope for the variables with windows NT shell\r\nif \"%OS%\"==\"Windows_NT\" setlocal\r\n\r\nset DIRNAME=%~dp0\r\nif \"%DIRNAME%\" == \"\" set DIRNAME=.\r\nset APP_BASE_NAME=%~n0\r\nset APP_HOME=%DIRNAME%\r\n\r\n@rem Resolve any \".\" and \"..\" in APP_HOME to make it shorter.\r\nfor %%i in (\"%APP_HOME%\") do set APP_HOME=%%~fi\r\n\r\n@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.\r\nset DEFAULT_JVM_OPTS=\"-Xmx64m\" \"-Xms64m\"\r\n\r\n@rem Find java.exe\r\nif defined JAVA_HOME goto findJavaFromJavaHome\r\n\r\nset JAVA_EXE=java.exe\r\n%JAVA_EXE% -version >NUL 2>&1\r\nif \"%ERRORLEVEL%\" == \"0\" goto execute\r\n\r\necho.\r\necho ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.\r\necho.\r\necho Please set the JAVA_HOME variable in your environment to match the\r\necho location of your Java installation.\r\n\r\ngoto fail\r\n\r\n:findJavaFromJavaHome\r\nset JAVA_HOME=%JAVA_HOME:\"=%\r\nset JAVA_EXE=%JAVA_HOME%/bin/java.exe\r\n\r\nif exist \"%JAVA_EXE%\" goto execute\r\n\r\necho.\r\necho ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%\r\necho.\r\necho Please set the JAVA_HOME variable in your environment to match the\r\necho location of your Java installation.\r\n\r\ngoto fail\r\n\r\n:execute\r\n@rem Setup the command line\r\n\r\nset CLASSPATH=%APP_HOME%\\gradle\\wrapper\\gradle-wrapper.jar\r\n\r\n\r\n@rem Execute Gradle\r\n\"%JAVA_EXE%\" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% \"-Dorg.gradle.appname=%APP_BASE_NAME%\" -classpath \"%CLASSPATH%\" org.gradle.wrapper.GradleWrapperMain %*\r\n\r\n:end\r\n@rem End local scope for the variables with windows NT shell\r\nif \"%ERRORLEVEL%\"==\"0\" goto mainEnd\r\n\r\n:fail\r\nrem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of\r\nrem the _cmd.exe /c_ return code!\r\nif  not \"\" == \"%GRADLE_EXIT_CONSOLE%\" exit 1\r\nexit /b 1\r\n\r\n:mainEnd\r\nif \"%OS%\"==\"Windows_NT\" endlocal\r\n\r\n:omega\r\n"
  },
  {
    "path": "src/java/kotlin-test/.gitignore",
    "content": "/build"
  },
  {
    "path": "src/java/kotlin-test/build.gradle",
    "content": "plugins {\n    id 'com.android.application'\n    id 'org.jetbrains.kotlin.android'\n    id 'com.google.devtools.ksp' version '1.7.10-1.0.6'\n}\n\nandroid {\n    namespace 'com.tencent.wcdbtest'\n    compileSdk 33\n\n    defaultConfig {\n        applicationId \"com.tencent.wcdbtest\"\n        minSdk 21\n        targetSdk 33\n        versionCode 1\n        versionName \"1.0\"\n\n        testInstrumentationRunner \"androidx.test.runner.AndroidJUnitRunner\"\n    }\n\n    buildTypes {\n        release {\n            minifyEnabled true\n            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'\n            signingConfig signingConfigs.debug\n        }\n    }\n    kotlinOptions {\n        jvmTarget = '1.8'\n    }\n    sourceSets {\n        release {\n            main.kotlin.srcDirs += 'build/generated/ksp/release/kotlin'\n            main.kotlin.srcDirs += 'build/generated/ksp/release/java'\n        }\n        debug {\n            main.kotlin.srcDirs += 'build/generated/ksp/debug/kotlin'\n            main.kotlin.srcDirs += 'build/generated/ksp/debug/java'\n            androidTest.kotlin.srcDirs += 'build/generated/ksp/debugAndroidTest/kotlin'\n            androidTest.kotlin.srcDirs += 'build/generated/ksp/debugAndroidTest/java'\n        }\n    }\n}\n\ndependencies {\n    implementation 'androidx.activity:activity-compose:1.4.0'\n    androidTestImplementation 'androidx.test.ext:junit:1.1.5'\n    androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'\n\n    implementation project(':main')\n    implementation \"com.tencent.wcdb:annotation:${project.version}\"\n    ksp \"com.tencent.wcdb:compiler:${project.version}\"\n\n    androidTestImplementation project(':main')\n    kspAndroidTest \"com.tencent.wcdb:compiler:${project.version}\"\n}"
  },
  {
    "path": "src/java/kotlin-test/proguard-rules.pro",
    "content": "# Add project specific ProGuard rules here.\n# You can control the set of applied configuration files using the\n# proguardFiles setting in build.gradle.\n#\n# For more details, see\n#   http://developer.android.com/guide/developing/tools/proguard.html\n\n# If your project uses WebView with JS, uncomment the following\n# and specify the fully qualified class name to the JavaScript interface\n# class:\n#-keepclassmembers class fqcn.of.javascript.interface.for.webview {\n#   public *;\n#}\n\n# Uncomment this to preserve the line number information for\n# debugging stack traces.\n#-keepattributes SourceFile,LineNumberTable\n\n# If you keep the line number information, uncomment this to\n# hide the original source file name.\n#-renamesourcefileattribute SourceFile"
  },
  {
    "path": "src/java/kotlin-test/src/androidTest/java/com/tencent/wcdbtest/base/BaseTestCase.kt",
    "content": "// Created by chenqiuwen on 2023/6/24.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdbtest.base\n\nimport com.tencent.wcdb.base.WCDBException\nimport com.tencent.wcdb.core.Database\nimport org.junit.Before\nimport org.junit.BeforeClass\nimport org.junit.Rule\nimport org.junit.rules.TemporaryFolder\nimport java.io.File\n\nopen class BaseTestCase {\n    var currentDirectory: String? = null\n\n    @Before\n    @Throws(WCDBException::class)\n    open fun setup() {\n        currentDirectory = tempFolder.root.path + File.separator + javaClass.simpleName\n        logInfo(\"Current directory: $currentDirectory\")\n    }\n\n    @get:Rule\n    var tempFolder = TemporaryFolder()\n\n    companion object {\n        @BeforeClass\n        @JvmStatic\n        fun globalSetUp() {\n            Database.globalTracePerformance(null)\n            Database.globalTraceSQL(null)\n            Database.globalTraceException { exception ->\n                if (exception.level.ordinal >= WCDBException.Level.Error.ordinal) {\n                    logError(exception.toString())\n                } else {\n                    logInfo(exception.toString())\n                }\n                assert(exception.level != WCDBException.Level.Fatal)\n            }\n        }\n\n        fun logInfo(msg: String?, vararg args: Any?) {\n            var log = msg\n            if (args.isNotEmpty()) {\n                log = String.format(msg!!, *args)\n            }\n            println(log)\n        }\n\n        fun logError(msg: String?, vararg args: Any?) {\n            var log = msg\n            if (args.isNotEmpty()) {\n                log = String.format(msg!!, *args)\n            }\n            System.err.println(log)\n        }\n\n        fun sleep(millisecond: Long) {\n            try {\n                Thread.sleep(millisecond)\n            } catch (e: InterruptedException) {\n                logError(\"sleep fail with error $e\")\n            }\n        }\n    }\n}"
  },
  {
    "path": "src/java/kotlin-test/src/androidTest/java/com/tencent/wcdbtest/base/CRUDTestCase.kt",
    "content": "// Created by chenqiuwen on 2023/6/24.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdbtest.base\n\nimport com.tencent.wcdb.base.WCDBException\nimport com.tencent.wcdb.core.Handle\nimport com.tencent.wcdb.winq.Column\nimport org.junit.After\nimport org.junit.Before\n\nopen class CRUDTestCase : TableTestCase() {\n    protected lateinit var object1: TestObject\n    protected lateinit var object2: TestObject\n    protected lateinit var objects: List<TestObject>\n    protected var nextId = 3\n    protected var id = Column(\"id\")\n    protected var content = Column(\"content\")\n    protected lateinit var handle: Handle\n\n    @Before\n    @Throws(WCDBException::class)\n    override fun setup() {\n        super.setup()\n        object1 = RandomTool.testObjectWithId(1)\n        object2 = RandomTool.testObjectWithId(2)\n        objects = listOf(object1, object2)\n        handle = database.handle\n        table = database.getTable(tableName, DBTestObject)\n    }\n\n    @After\n    override fun teardown() {\n        handle.invalidate()\n        super.teardown()\n    }\n\n    @Throws(WCDBException::class)\n    fun insertPresetObjects() {\n        createTable()\n        table.insertObjects(objects)\n    }\n\n    fun allRowsCount(): Long {\n        return try {\n            database.getValue(Column.all().count(), tableName)!!.long\n        } catch (e: WCDBException) {\n            throw RuntimeException(e)\n        }\n    }\n}"
  },
  {
    "path": "src/java/kotlin-test/src/androidTest/java/com/tencent/wcdbtest/base/DatabaseTestCase.kt",
    "content": "// Created by chenqiuwen on 2023/6/24.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdbtest.base\n\nimport com.tencent.wcdb.base.WCDBException\nimport com.tencent.wcdb.core.Database\nimport org.junit.After\nimport org.junit.Assert\nimport org.junit.Before\nimport java.io.File\nimport java.util.*\n\ntypealias TestOperation = () -> Unit\n\nopen class DatabaseTestCase : BaseTestCase() {\n    enum class Expect {\n        AllSQLs, FirstFewSQLs, SomeSQLs\n    }\n\n    var path: String = \"\"\n    var fileName: String = \"\"\n    var database: Database = Database(\"\")\n    var expectMode: Expect = Expect.AllSQLs\n\n    @Before\n    @Throws(WCDBException::class)\n    override fun setup() {\n        super.setup()\n        expectMode = Expect.AllSQLs\n        fileName = \"testDatabase\"\n        path = currentDirectory + File.separator + fileName\n        database = Database(path)\n        database.tag = 10001\n    }\n\n    @After\n    open fun teardown() {\n        database.close()\n    }\n\n    fun doTestSQL(sql: String, operation: TestOperation) {\n        doTestSQLs(arrayOf(sql), operation)\n    }\n\n    fun doTestSQLs(sqls: Array<String>, operation: TestOperation) {\n        Assert.assertNotNull(sqls)\n        Assert.assertNotNull(operation)\n        do {\n            val trace = WrappedValue()\n            trace.boolValue = false\n            val expectedSQLs = mutableListOf(*sqls)\n            val thread = Thread.currentThread()\n            database.traceSQL { _, _, _, sql, _ ->\n                if (Thread.currentThread().id != thread.id) {\n                    return@traceSQL\n                }\n                if (!trace.boolValue) {\n                    return@traceSQL\n                }\n                doTestSQLAsExpected(expectedSQLs, sql)\n            }\n            if (expectMode != Expect.SomeSQLs) {\n                if (!database.canOpen()) {\n                    Assert.fail()\n                    break\n                }\n            }\n            trace.boolValue = true\n            try {\n                operation()\n            } catch (e: WCDBException) {\n                throw RuntimeException(e)\n            }\n            if (expectedSQLs.isNotEmpty()) {\n                logError(\"Reminding: $expectedSQLs\")\n                Assert.fail()\n                break\n            }\n            trace.boolValue = false\n        } while (false)\n        database.traceSQL(null)\n    }\n\n    private fun doTestSQLAsExpected(expectedSQLs: MutableList<String>, sql: String) {\n        when (expectMode) {\n            Expect.AllSQLs -> {\n                if (expectedSQLs[0] == sql) {\n                    expectedSQLs.removeAt(0)\n                } else {\n                    Assert.assertEquals(expectedSQLs[0], sql)\n                }\n            }\n\n            Expect.FirstFewSQLs -> {\n                if (expectedSQLs.size > 0 && expectedSQLs[0] == sql) {\n                    expectedSQLs.removeAt(0)\n                } else if (expectedSQLs.size != 0) {\n                    Assert.assertEquals(expectedSQLs[0], sql)\n                }\n            }\n\n            Expect.SomeSQLs -> {\n                var i = 0\n                while (i < expectedSQLs.size) {\n                    if (expectedSQLs[i] == sql) {\n                        expectedSQLs.removeAt(i)\n                        break\n                    }\n                    i++\n                }\n            }\n        }\n    }\n}"
  },
  {
    "path": "src/java/kotlin-test/src/androidTest/java/com/tencent/wcdbtest/base/ObjectCRUDTestCase.kt",
    "content": "// Created by chenqiuwen on 2023/6/24.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdbtest.base\n\nimport com.tencent.wcdb.base.WCDBException\nimport org.junit.Before\n\nopen class ObjectCRUDTestCase : CRUDTestCase() {\n    @Before\n    @Throws(WCDBException::class)\n    override fun setup() {\n        super.setup()\n        insertPresetObjects()\n    }\n}"
  },
  {
    "path": "src/java/kotlin-test/src/androidTest/java/com/tencent/wcdbtest/base/RandomTool.kt",
    "content": "// Created by chenqiuwen on 2023/6/24.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdbtest.base\n\nimport com.tencent.wcdb.base.Value\nimport java.util.*\n\nobject RandomTool {\n    @JvmOverloads\n    fun string(length: Int = 100): String {\n        val str = \"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789\"\n        val random = Random()\n        val stringBuffer = StringBuilder(length)\n        for (i in 0 until length) {\n            val number = random.nextInt(62)\n            stringBuffer.append(str[number])\n        }\n        return stringBuffer.toString()\n    }\n\n    @JvmOverloads\n    fun bytes(length: Int = 100): ByteArray {\n        val random = Random()\n        val bytes = ByteArray(length)\n        random.nextBytes(bytes)\n        return bytes\n    }\n\n    fun autoIncrementTestCaseObjects(count: Int): Array<TestObject?> {\n        val objects = arrayOfNulls<TestObject>(count)\n        for (i in 0 until count) {\n            objects[i] = TestObject.createAutoIncrementObject(string())\n        }\n        return objects\n    }\n\n    fun testObjectWithId(id: Int): TestObject {\n        return TestObject.createObject(id, string())\n    }\n\n    fun testRowWithId(id: Int): Array<Value> {\n        return arrayOf(Value(id.toLong()), Value(string()))\n    }\n}"
  },
  {
    "path": "src/java/kotlin-test/src/androidTest/java/com/tencent/wcdbtest/base/TableTestCase.kt",
    "content": "// Created by chenqiuwen on 2023/6/24.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdbtest.base\n\nimport com.tencent.wcdb.base.WCDBException\nimport com.tencent.wcdb.core.Table\nimport com.tencent.wcdb.orm.TableBinding\nimport org.junit.Assert\nimport java.util.*\n\ntypealias SelectingObjectOperation = () -> List<TestObject?>\n\nopen class TableTestCase : DatabaseTestCase() {\n    var tableName = \"testTable\"\n    var tableBinding: TableBinding<TestObject> = DBTestObject\n    var isVirtualTable = false\n    lateinit var table: Table<TestObject>\n\n    @Throws(WCDBException::class)\n    fun createTable() {\n        if (!isVirtualTable) {\n            database.createTable(tableName, tableBinding)\n        } else {\n            database.createVirtualTable(tableName, tableBinding)\n        }\n        table = database.getTable(tableName, tableBinding)\n    }\n\n    @Throws(WCDBException::class)\n    fun createVirtualTable() {\n        database.createVirtualTable(tableName, tableBinding)\n        table = database.getTable(tableName, tableBinding)\n    }\n\n    @Throws(WCDBException::class)\n    fun dropTable() {\n        database.dropTable(tableName)\n    }\n\n    fun doTestObjectsAfterInsert(\n        objects: List<Any>,\n        insertCount: Int,\n        sqls: Array<String>,\n        operation: TestOperation\n    ) {\n        var newSqls = sqls\n        if (insertCount > 1) {\n            val list: MutableList<String> = mutableListOf(*sqls)\n            list.add(0, \"BEGIN IMMEDIATE\")\n            list.add(\"COMMIT\")\n            newSqls = list.toTypedArray()\n        }\n        doTestObjectsAfterOperation(objects, newSqls, operation)\n    }\n\n    fun doTestObjectsAfterOperation(\n        objects: List<Any>,\n        sql: String,\n        operation: TestOperation\n    ) {\n        doTestObjectsAfterOperation(objects, arrayOf(sql), operation)\n    }\n\n    fun doTestObjectsAfterOperation(\n        objects: List<Any>,\n        sqls: Array<String>,\n        operation: TestOperation\n    ) {\n        doTestSQLs(sqls, operation)\n        val allObjects: List<TestObject> = try {\n            this.allObjects\n        } catch (e: WCDBException) {\n            throw RuntimeException(e)\n        }\n        Assert.assertTrue(\n            (objects.isEmpty() && allObjects.isEmpty()) ||\n                    objects == allObjects\n        )\n    }\n\n    fun doTestObjectBySelecting(\n        `object`: TestObject,\n        sql: String,\n        operation: SelectingObjectOperation\n    ) {\n        doTestObjectBySelecting(listOf(`object`), arrayOf(sql), operation)\n    }\n\n    fun doTestObjectBySelecting(\n        objects: List<TestObject>,\n        sql: String,\n        operation: SelectingObjectOperation\n    ) {\n        doTestObjectBySelecting(objects, arrayOf(sql), operation)\n    }\n\n    fun doTestObjectBySelecting(\n        objects: List<TestObject>,\n        sqls: Array<String>,\n        operation: SelectingObjectOperation\n    ) {\n        val selecting = mutableListOf<TestObject?>()\n        doTestSQLs(sqls) {\n            selecting.addAll(operation())\n        }\n        Assert.assertTrue(\n            (objects.isEmpty() && selecting.isEmpty()) ||\n                    objects == selecting\n        )\n    }\n\n    @get:Throws(WCDBException::class)\n    val allObjects: List<TestObject>\n        get() = table.allObjects\n}"
  },
  {
    "path": "src/java/kotlin-test/src/androidTest/java/com/tencent/wcdbtest/base/TestObject.kt",
    "content": "// Created by chenqiuwen on 2023/6/24.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdbtest.base\n\nimport com.tencent.wcdb.WCDBField\nimport com.tencent.wcdb.WCDBTableCoding\n\n@WCDBTableCoding\nclass TestObject {\n    @WCDBField(isPrimary = true, isAutoIncrement = true)\n    var id = 0\n\n    @WCDBField\n    var content: String? = null\n\n    override fun equals(other: Any?): Boolean {\n        return if (other is TestObject) {\n            if (other.id != id) {\n                return false\n            }\n            if (content == null) {\n                return other.content == null || other.content!!.isEmpty()\n            } else if (other.content == null) {\n                return content!!.isEmpty()\n            }\n            other.content == content\n        } else {\n            super.equals(other)\n        }\n    }\n\n    companion object {\n        fun createObject(id: Int, content: String?): TestObject {\n            val obj = TestObject()\n            obj.id = id\n            obj.content = content\n            return obj\n        }\n\n        fun createPartialObject(id: Int): TestObject {\n            val obj = TestObject()\n            obj.id = id\n            return obj\n        }\n\n        fun createAutoIncrementObject(content: String?): TestObject {\n            val obj = TestObject()\n            obj.id = 0\n            obj.content = content\n            return obj\n        }\n    }\n}"
  },
  {
    "path": "src/java/kotlin-test/src/androidTest/java/com/tencent/wcdbtest/base/WrappedValue.kt",
    "content": "// Created by chenqiuwen on 2023/6/24.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdbtest.base\n\nclass WrappedValue {\n    var boolValue = false\n    var intValue: Long = 0\n    var stringValue: String? = null\n    var doubleValue = 0.0\n\n    companion object {\n        fun currentTime(): WrappedValue {\n            val date = WrappedValue()\n            date.intValue = System.currentTimeMillis()\n            return date\n        }\n    }\n}"
  },
  {
    "path": "src/java/kotlin-test/src/androidTest/java/com/tencent/wcdbtest/crud/ObjectDeleteTest.kt",
    "content": "// Created by qiuwenchen on 2023/6/25.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdbtest.crud\n\nimport com.tencent.wcdb.winq.Order\nimport com.tencent.wcdbtest.base.DBTestObject\nimport com.tencent.wcdbtest.base.ObjectCRUDTestCase\n\nclass ObjectDeleteTest : ObjectCRUDTestCase() {\n    @org.junit.Test\n    fun testDatabaseDelete() {\n        doTestSQL(\"DELETE FROM testTable\") {\n            database.deleteObjects(tableName)\n        }\n        org.junit.Assert.assertEquals(allRowsCount(), 0)\n    }\n\n    @org.junit.Test\n    fun testDatabaseDeleteWhere() {\n        doTestSQL(\"DELETE FROM testTable WHERE id == 1\") {\n            database.deleteObjects(\n                tableName,\n                DBTestObject.id.eq(1)\n            )\n        }\n        org.junit.Assert.assertEquals(allRowsCount(), 1)\n    }\n\n    @org.junit.Test\n    fun testDatabaseDeleteOrderLimit() {\n        doTestSQL(\"DELETE FROM testTable ORDER BY content DESC LIMIT 1\") {\n            database.deleteObjects(\n                tableName,\n                DBTestObject.content.order(Order.Desc),\n                1\n            )\n        }\n        org.junit.Assert.assertEquals(allRowsCount(), 1)\n    }\n\n    @org.junit.Test\n    fun testDatabaseDeleteOrderLimitOffset() {\n        doTestSQL(\"DELETE FROM testTable ORDER BY content DESC LIMIT 1 OFFSET 1\") {\n            database.deleteObjects(\n                tableName,\n                DBTestObject.content.order(Order.Desc),\n                1,\n                1\n            )\n        }\n        org.junit.Assert.assertEquals(allRowsCount(), 1)\n    }\n\n    @org.junit.Test\n    fun testDatabaseDeleteWhereOrderLimit() {\n        doTestSQL(\"DELETE FROM testTable WHERE id IN(1, 3) ORDER BY content DESC LIMIT 1\") {\n            database.deleteObjects(\n                tableName,\n                DBTestObject.id.`in`(1, 3),\n                DBTestObject.content.order(Order.Desc),\n                1\n            )\n        }\n        org.junit.Assert.assertEquals(allRowsCount(), 1)\n    }\n\n    @org.junit.Test\n    fun testDatabaseDeleteWhereOrderLimitOffset() {\n        doTestSQL(\"DELETE FROM testTable WHERE id IN(1, 2) ORDER BY content DESC LIMIT 1 OFFSET 1\") {\n            database.deleteObjects(\n                tableName,\n                DBTestObject.id.`in`(1, 2),\n                DBTestObject.content.order(Order.Desc),\n                1,\n                1\n            )\n        }\n        org.junit.Assert.assertEquals(allRowsCount(), 1)\n    }\n\n    @org.junit.Test\n    fun testTableDelete() {\n        doTestSQL(\"DELETE FROM testTable\") { table.deleteObjects() }\n        org.junit.Assert.assertEquals(allRowsCount(), 0)\n    }\n\n    @org.junit.Test\n    fun testTableDeleteWhere() {\n        doTestSQL(\"DELETE FROM testTable WHERE id == 1\") { table.deleteObjects(DBTestObject.id.eq(1)) }\n        org.junit.Assert.assertEquals(allRowsCount(), 1)\n    }\n\n    @org.junit.Test\n    fun testTableDeleteOrderLimit() {\n        doTestSQL(\"DELETE FROM testTable ORDER BY content DESC LIMIT 1\") {\n            table.deleteObjects(\n                DBTestObject.content.order(Order.Desc),\n                1\n            )\n        }\n        org.junit.Assert.assertEquals(allRowsCount(), 1)\n    }\n\n    @org.junit.Test\n    fun testTableDeleteOrderLimitOffset() {\n        doTestSQL(\"DELETE FROM testTable ORDER BY content DESC LIMIT 1 OFFSET 1\") {\n            table.deleteObjects(\n                DBTestObject.content.order(Order.Desc),\n                1,\n                1\n            )\n        }\n        org.junit.Assert.assertEquals(allRowsCount(), 1)\n    }\n\n    @org.junit.Test\n    fun testTableDeleteWhereOrderLimit() {\n        doTestSQL(\"DELETE FROM testTable WHERE id IN(1, 3) ORDER BY content DESC LIMIT 1\") {\n            table.deleteObjects(\n                DBTestObject.id.`in`(1, 3),\n                DBTestObject.content.order(Order.Desc),\n                1\n            )\n        }\n        org.junit.Assert.assertEquals(allRowsCount(), 1)\n    }\n\n    @org.junit.Test\n    fun testTableDeleteWhereOrderLimitOffset() {\n        doTestSQL(\"DELETE FROM testTable WHERE id IN(1, 2) ORDER BY content DESC LIMIT 1 OFFSET 1\") {\n            table.deleteObjects(\n                DBTestObject.id.`in`(1, 2),\n                DBTestObject.content.order(Order.Desc),\n                1,\n                1\n            )\n        }\n        org.junit.Assert.assertEquals(allRowsCount(), 1)\n    }\n\n    @org.junit.Test\n    fun testHandleDelete() {\n        doTestSQL(\"DELETE FROM testTable\") { handle.deleteObjects(tableName) }\n        org.junit.Assert.assertEquals(allRowsCount(), 0)\n    }\n\n    @org.junit.Test\n    fun testHandleDeleteWhere() {\n        doTestSQL(\"DELETE FROM testTable WHERE id == 1\") {\n            handle.deleteObjects(\n                tableName,\n                DBTestObject.id.eq(1)\n            )\n        }\n        org.junit.Assert.assertEquals(allRowsCount(), 1)\n    }\n\n    @org.junit.Test\n    fun testHandleDeleteOrderLimit() {\n        doTestSQL(\"DELETE FROM testTable ORDER BY content DESC LIMIT 1\") {\n            handle.deleteObjects(\n                tableName,\n                DBTestObject.content.order(Order.Desc),\n                1\n            )\n        }\n        org.junit.Assert.assertEquals(allRowsCount(), 1)\n    }\n\n    @org.junit.Test\n    fun testHandleDeleteOrderLimitOffset() {\n        doTestSQL(\"DELETE FROM testTable ORDER BY content DESC LIMIT 1 OFFSET 1\") {\n            handle.deleteObjects(\n                tableName,\n                DBTestObject.content.order(Order.Desc),\n                1,\n                1\n            )\n        }\n        org.junit.Assert.assertEquals(allRowsCount(), 1)\n    }\n\n    @org.junit.Test\n    fun testHandleDeleteWhereOrderLimit() {\n        doTestSQL(\"DELETE FROM testTable WHERE id IN(1, 3) ORDER BY content DESC LIMIT 1\") {\n            handle.deleteObjects(\n                tableName,\n                DBTestObject.id.`in`(1, 3),\n                DBTestObject.content.order(Order.Desc),\n                1\n            )\n        }\n        org.junit.Assert.assertEquals(allRowsCount(), 1)\n    }\n\n    @org.junit.Test\n    fun testHandleDeleteWhereOrderLimitOffset() {\n        doTestSQL(\"DELETE FROM testTable WHERE id IN(1, 2) ORDER BY content DESC LIMIT 1 OFFSET 1\") {\n            handle.deleteObjects(\n                tableName,\n                DBTestObject.id.`in`(1, 2),\n                DBTestObject.content.order(Order.Desc),\n                1,\n                1\n            )\n        }\n        org.junit.Assert.assertEquals(allRowsCount(), 1)\n    }\n}"
  },
  {
    "path": "src/java/kotlin-test/src/androidTest/java/com/tencent/wcdbtest/crud/ObjectInsertTest.kt",
    "content": "// Created by qiuwenchen on 2023/6/25.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdbtest.crud\n\nimport com.tencent.wcdb.base.WCDBException\nimport com.tencent.wcdbtest.base.DBTestObject\nimport com.tencent.wcdbtest.base.ObjectCRUDTestCase\nimport com.tencent.wcdbtest.base.RandomTool\nimport com.tencent.wcdbtest.base.TestObject\nimport org.junit.Assert\nimport org.junit.Before\nimport org.junit.Test\n\nclass ObjectInsertTest : ObjectCRUDTestCase() {\n    private lateinit var renewObject1: TestObject\n    private lateinit var renewObject2: TestObject\n    private lateinit var renewedPartialObject1: TestObject\n    private lateinit var renewedPartialObject2: TestObject\n    private lateinit var object3: TestObject\n    private lateinit var object4: TestObject\n    private lateinit var partialObject3: TestObject\n    private lateinit var partialObject4: TestObject\n\n    @Before\n    @Throws(WCDBException::class)\n    override fun setup() {\n        super.setup()\n        renewObject1 = RandomTool.testObjectWithId(1)\n        renewObject2 = RandomTool.testObjectWithId(2)\n        renewedPartialObject1 = TestObject.createPartialObject(1)\n        renewedPartialObject2 = TestObject.createPartialObject(2)\n        object3 = RandomTool.testObjectWithId(3)\n        object4 = RandomTool.testObjectWithId(4)\n        partialObject3 = TestObject.createPartialObject(3)\n        partialObject4 = TestObject.createPartialObject(4)\n    }\n\n    @Test\n    fun testDatabaseAutoIncrement() {\n        val autoIncrementObject = TestObject.createAutoIncrementObject(\n            object3.content\n        )\n        doTestObjectsAfterInsert(\n            listOf(object1, object2, object3), 1, arrayOf(\n                \"INSERT INTO testTable(id, content) VALUES(?1, ?2)\"\n            )\n        ) { database.insertObject(autoIncrementObject, DBTestObject.allFields(), tableName) }\n        Assert.assertEquals(autoIncrementObject, object3)\n    }\n\n    @Test\n    fun testDatabaseAutoIncrementWithPartialInsert() {\n        val autoIncrementObject = TestObject.createAutoIncrementObject(\n            object3.content\n        )\n        doTestObjectsAfterInsert(\n            listOf(object1, object2, object3), 1, arrayOf(\n                \"INSERT INTO testTable(content) VALUES(?1)\"\n            )\n        ) {\n            database.insertObject(\n                autoIncrementObject,\n                arrayOf(DBTestObject.content),\n                tableName\n            )\n        }\n        Assert.assertEquals(autoIncrementObject, object3)\n    }\n\n    @Test\n    fun testDatabaseInsertObject() {\n        doTestObjectsAfterInsert(\n            listOf(object1, object2, object3), 1, arrayOf(\n                \"INSERT INTO testTable(id, content) VALUES(?1, ?2)\"\n            )\n        ) { database.insertObject(object3, DBTestObject.allFields(), tableName) }\n    }\n\n    @Test\n    fun testDatabaseInsertObjects() {\n        expectMode = Expect.SomeSQLs\n        doTestObjectsAfterInsert(\n            listOf(object1, object2, object3, object4), 2, arrayOf(\n                \"INSERT INTO testTable(id, content) VALUES(?1, ?2)\"\n            )\n        ) { database.insertObjects(listOf(object3, object4), DBTestObject.allFields(), tableName) }\n    }\n\n    @Test\n    fun testDatabaseInsertOrReplaceObject() {\n        doTestObjectsAfterInsert(\n            listOf(renewObject1, object2), 1, arrayOf(\n                \"INSERT OR REPLACE INTO testTable(id, content) VALUES(?1, ?2)\"\n            )\n        ) { database.insertOrReplaceObject(renewObject1, DBTestObject.allFields(), tableName) }\n    }\n\n    @Test\n    fun testDatabaseInsertOrReplaceObjects() {\n        expectMode = Expect.SomeSQLs\n        doTestObjectsAfterInsert(\n            listOf(renewObject1, renewObject2), 2, arrayOf(\n                \"INSERT OR REPLACE INTO testTable(id, content) VALUES(?1, ?2)\"\n            )\n        ) {\n            database.insertOrReplaceObjects(\n                listOf(renewObject1, renewObject2),\n                DBTestObject.allFields(),\n                tableName\n            )\n        }\n    }\n\n    @Test\n    fun testDatabaseInsertOrIgnoreObject() {\n        doTestObjectsAfterInsert(\n            listOf(object1, object2), 1, arrayOf(\n                \"INSERT OR IGNORE INTO testTable(id, content) VALUES(?1, ?2)\"\n            )\n        ) { database.insertOrIgnoreObject(renewObject1, DBTestObject.allFields(), tableName) }\n    }\n\n    @Test\n    fun testDatabaseInsertOrIgnoreObjects() {\n        expectMode = Expect.SomeSQLs\n        doTestObjectsAfterInsert(\n            listOf(object1, object2), 2, arrayOf(\n                \"INSERT OR IGNORE INTO testTable(id, content) VALUES(?1, ?2)\"\n            )\n        ) {\n            database.insertOrIgnoreObjects(\n                listOf(renewObject1, renewObject2),\n                DBTestObject.allFields(),\n                tableName\n            )\n        }\n    }\n\n    @Test\n    fun testDatabaseInsertObjectOnFields() {\n        doTestObjectsAfterInsert(\n            listOf(object1, object2, partialObject3), 1, arrayOf(\n                \"INSERT INTO testTable(id) VALUES(?1)\"\n            )\n        ) { database.insertObject(object3, arrayOf(DBTestObject.id), tableName) }\n    }\n\n    @Test\n    fun testDatabaseInsertObjectsOnFields() {\n        expectMode = Expect.SomeSQLs\n        doTestObjectsAfterInsert(\n            listOf(object1, object2, partialObject3, partialObject4), 2, arrayOf(\n                \"INSERT INTO testTable(id) VALUES(?1)\"\n            )\n        ) {\n            database.insertObjects(\n                listOf(object3, object4),\n                arrayOf(DBTestObject.id),\n                tableName\n            )\n        }\n    }\n\n    @Test\n    fun testDatabaseInsertOrReplaceObjectOnFields() {\n        doTestObjectsAfterInsert(\n            listOf(renewedPartialObject1, object2), 1, arrayOf(\n                \"INSERT OR REPLACE INTO testTable(id) VALUES(?1)\"\n            )\n        ) { database.insertOrReplaceObject(object1, arrayOf(DBTestObject.id), tableName) }\n    }\n\n    @Test\n    fun testDatabaseInsertOrReplaceObjectsOnFields() {\n        expectMode = Expect.SomeSQLs\n        doTestObjectsAfterInsert(\n            listOf(renewedPartialObject1, renewedPartialObject2), 2, arrayOf(\n                \"INSERT OR REPLACE INTO testTable(id) VALUES(?1)\"\n            )\n        ) {\n            database.insertOrReplaceObjects(\n                listOf(object1, object2), arrayOf(\n                    DBTestObject.id\n                ), tableName\n            )\n        }\n    }\n\n    @Test\n    fun testDatabaseInsertOrIgnoreObjectOnFields() {\n        doTestObjectsAfterInsert(\n            listOf(object1, object2), 1, arrayOf(\n                \"INSERT OR IGNORE INTO testTable(id) VALUES(?1)\"\n            )\n        ) { database.insertOrIgnoreObject(object1, arrayOf(DBTestObject.id), tableName) }\n    }\n\n    @Test\n    fun testDatabaseInsertOrIgnoreObjectsOnFields() {\n        expectMode = Expect.SomeSQLs\n        doTestObjectsAfterInsert(\n            listOf(object1, object2), 2, arrayOf(\n                \"INSERT OR IGNORE INTO testTable(id) VALUES(?1)\"\n            )\n        ) {\n            database.insertOrIgnoreObjects(\n                listOf(object1, object2), arrayOf(\n                    DBTestObject.id\n                ), tableName\n            )\n        }\n    }\n\n    @Test\n    fun testTableAutoIncrement() {\n        val autoIncrementObject = TestObject.createAutoIncrementObject(\n            object3.content\n        )\n        doTestObjectsAfterInsert(\n            listOf(object1, object2, object3), 1, arrayOf(\n                \"INSERT INTO testTable(id, content) VALUES(?1, ?2)\"\n            )\n        ) { table.insertObject(autoIncrementObject) }\n        Assert.assertEquals(autoIncrementObject, object3)\n    }\n\n    @Test\n    fun testTableAutoIncrementWithPartialInsert() {\n        val autoIncrementObject = TestObject.createAutoIncrementObject(\n            object3.content\n        )\n        doTestObjectsAfterInsert(\n            listOf(object1, object2, object3), 1, arrayOf(\n                \"INSERT INTO testTable(content) VALUES(?1)\"\n            )\n        ) { table.insertObject(autoIncrementObject, arrayOf(DBTestObject.content)) }\n        Assert.assertEquals(autoIncrementObject, object3)\n    }\n\n    @Test\n    fun testTableInsertObject() {\n        doTestObjectsAfterInsert(\n            listOf(object1, object2, object3), 1, arrayOf(\n                \"INSERT INTO testTable(id, content) VALUES(?1, ?2)\"\n            )\n        ) { table.insertObject(object3) }\n    }\n\n    @Test\n    fun testTableInsertObjects() {\n        expectMode = Expect.SomeSQLs\n        doTestObjectsAfterInsert(\n            listOf(object1, object2, object3, object4), 2, arrayOf(\n                \"INSERT INTO testTable(id, content) VALUES(?1, ?2)\"\n            )\n        ) { table.insertObjects(listOf(object3, object4)) }\n    }\n\n    @Test\n    fun testTableInsertOrReplaceObject() {\n        doTestObjectsAfterInsert(\n            listOf(renewObject1, object2), 1, arrayOf(\n                \"INSERT OR REPLACE INTO testTable(id, content) VALUES(?1, ?2)\"\n            )\n        ) { table.insertOrReplaceObject(renewObject1) }\n    }\n\n    @Test\n    fun testTableInsertOrReplaceObjects() {\n        expectMode = Expect.SomeSQLs\n        doTestObjectsAfterInsert(\n            listOf(renewObject1, renewObject2), 2, arrayOf(\n                \"INSERT OR REPLACE INTO testTable(id, content) VALUES(?1, ?2)\"\n            )\n        ) { table.insertOrReplaceObjects(listOf(renewObject1, renewObject2)) }\n    }\n\n    @Test\n    fun testTableInsertOrIgnoreObject() {\n        doTestObjectsAfterInsert(\n            listOf(object1, object2), 1, arrayOf(\n                \"INSERT OR IGNORE INTO testTable(id, content) VALUES(?1, ?2)\"\n            )\n        ) { table.insertOrIgnoreObject(renewObject1) }\n    }\n\n    @Test\n    fun testTableInsertOrIgnoreObjects() {\n        expectMode = Expect.SomeSQLs\n        doTestObjectsAfterInsert(\n            listOf(object1, object2), 2, arrayOf(\n                \"INSERT OR IGNORE INTO testTable(id, content) VALUES(?1, ?2)\"\n            )\n        ) { table.insertOrIgnoreObjects(listOf(renewObject1, renewObject2)) }\n    }\n\n    @Test\n    fun testTableInsertObjectOnFields() {\n        doTestObjectsAfterInsert(\n            listOf(object1, object2, partialObject3), 1, arrayOf(\n                \"INSERT INTO testTable(id) VALUES(?1)\"\n            )\n        ) { table.insertObject(object3, arrayOf(DBTestObject.id)) }\n    }\n\n    @Test\n    fun testTableInsertObjectsOnFields() {\n        expectMode = Expect.SomeSQLs\n        doTestObjectsAfterInsert(\n            listOf(object1, object2, partialObject3, partialObject4), 2, arrayOf(\n                \"INSERT INTO testTable(id) VALUES(?1)\"\n            )\n        ) { table.insertObjects(listOf(object3, object4), arrayOf(DBTestObject.id)) }\n    }\n\n    @Test\n    fun testTableInsertOrReplaceObjectOnFields() {\n        doTestObjectsAfterInsert(\n            listOf(renewedPartialObject1, object2), 1, arrayOf(\n                \"INSERT OR REPLACE INTO testTable(id) VALUES(?1)\"\n            )\n        ) { table.insertOrReplaceObject(object1, arrayOf(DBTestObject.id)) }\n    }\n\n    @Test\n    fun testTableInsertOrReplaceObjectsOnFields() {\n        expectMode = Expect.SomeSQLs\n        doTestObjectsAfterInsert(\n            listOf(renewedPartialObject1, renewedPartialObject2), 2, arrayOf(\n                \"INSERT OR REPLACE INTO testTable(id) VALUES(?1)\"\n            )\n        ) {\n            table.insertOrReplaceObjects(\n                listOf(object1, object2),\n                arrayOf(DBTestObject.id)\n            )\n        }\n    }\n\n    @Test\n    fun testTableInsertOrIgnoreObjectOnFields() {\n        doTestObjectsAfterInsert(\n            listOf(object1, object2), 1, arrayOf(\n                \"INSERT OR IGNORE INTO testTable(id) VALUES(?1)\"\n            )\n        ) { table.insertOrIgnoreObject(object1, arrayOf(DBTestObject.id)) }\n    }\n\n    @Test\n    fun testTableInsertOrIgnoreObjectsOnFields() {\n        expectMode = Expect.SomeSQLs\n        doTestObjectsAfterInsert(\n            listOf(object1, object2), 2, arrayOf(\n                \"INSERT OR IGNORE INTO testTable(id) VALUES(?1)\"\n            )\n        ) {\n            table.insertOrIgnoreObjects(\n                listOf(object1, object2),\n                arrayOf(DBTestObject.id)\n            )\n        }\n    }\n\n    @Test\n    fun testHandleAutoIncrement() {\n        val autoIncrementObject = TestObject.createAutoIncrementObject(\n            object3.content\n        )\n        doTestObjectsAfterInsert(\n            listOf(object1, object2, object3), 1, arrayOf(\n                \"INSERT INTO testTable(id, content) VALUES(?1, ?2)\"\n            )\n        ) { handle.insertObject(autoIncrementObject, DBTestObject.allFields(), tableName) }\n        Assert.assertEquals(autoIncrementObject, object3)\n    }\n\n    @Test\n    fun testHandleAutoIncrementWithPartialInsert() {\n        val autoIncrementObject = TestObject.createAutoIncrementObject(\n            object3.content\n        )\n        doTestObjectsAfterInsert(\n            listOf(object1, object2, object3), 1, arrayOf(\n                \"INSERT INTO testTable(content) VALUES(?1)\"\n            )\n        ) {\n            handle.insertObject(\n                autoIncrementObject,\n                arrayOf(DBTestObject.content),\n                tableName\n            )\n        }\n        Assert.assertEquals(autoIncrementObject, object3)\n    }\n\n    @Test\n    fun testHandleInsertObject() {\n        doTestObjectsAfterInsert(\n            listOf(object1, object2, object3), 1, arrayOf(\n                \"INSERT INTO testTable(id, content) VALUES(?1, ?2)\"\n            )\n        ) { handle.insertObject(object3, DBTestObject.allFields(), tableName) }\n    }\n\n    @Test\n    fun testHandleInsertObjects() {\n        expectMode = Expect.SomeSQLs\n        doTestObjectsAfterInsert(\n            listOf(object1, object2, object3, object4), 2, arrayOf(\n                \"INSERT INTO testTable(id, content) VALUES(?1, ?2)\"\n            )\n        ) { handle.insertObjects(listOf(object3, object4), DBTestObject.allFields(), tableName) }\n    }\n\n    @Test\n    fun testHandleInsertOrReplaceObject() {\n        doTestObjectsAfterInsert(\n            listOf(renewObject1, object2), 1, arrayOf(\n                \"INSERT OR REPLACE INTO testTable(id, content) VALUES(?1, ?2)\"\n            )\n        ) { handle.insertOrReplaceObject(renewObject1, DBTestObject.allFields(), tableName) }\n    }\n\n    @Test\n    fun testHandleInsertOrReplaceObjects() {\n        expectMode = Expect.SomeSQLs\n        doTestObjectsAfterInsert(\n            listOf(renewObject1, renewObject2), 2, arrayOf(\n                \"INSERT OR REPLACE INTO testTable(id, content) VALUES(?1, ?2)\"\n            )\n        ) {\n            handle.insertOrReplaceObjects(\n                listOf(renewObject1, renewObject2),\n                DBTestObject.allFields(),\n                tableName\n            )\n        }\n    }\n\n    @Test\n    fun testHandleInsertOrIgnoreObject() {\n        doTestObjectsAfterInsert(\n            listOf(object1, object2), 1, arrayOf(\n                \"INSERT OR IGNORE INTO testTable(id, content) VALUES(?1, ?2)\"\n            )\n        ) { handle.insertOrIgnoreObject(renewObject1, DBTestObject.allFields(), tableName) }\n    }\n\n    @Test\n    fun testHandleInsertOrIgnoreObjects() {\n        expectMode = Expect.SomeSQLs\n        doTestObjectsAfterInsert(\n            listOf(object1, object2), 2, arrayOf(\n                \"INSERT OR IGNORE INTO testTable(id, content) VALUES(?1, ?2)\"\n            )\n        ) {\n            handle.insertOrIgnoreObjects(\n                listOf(renewObject1, renewObject2),\n                DBTestObject.allFields(),\n                tableName\n            )\n        }\n    }\n\n    @Test\n    fun testHandleInsertObjectOnFields() {\n        doTestObjectsAfterInsert(\n            listOf(object1, object2, partialObject3), 1, arrayOf(\n                \"INSERT INTO testTable(id) VALUES(?1)\"\n            )\n        ) { handle.insertObject(object3, arrayOf(DBTestObject.id), tableName) }\n    }\n\n    @Test\n    fun testHandleInsertObjectsOnFields() {\n        expectMode = Expect.SomeSQLs\n        doTestObjectsAfterInsert(\n            listOf(object1, object2, partialObject3, partialObject4), 2, arrayOf(\n                \"INSERT INTO testTable(id) VALUES(?1)\"\n            )\n        ) {\n            handle.insertObjects(\n                listOf(object3, object4),\n                arrayOf(DBTestObject.id),\n                tableName\n            )\n        }\n    }\n\n    @Test\n    fun testHandleInsertOrReplaceObjectOnFields() {\n        doTestObjectsAfterInsert(\n            listOf(renewedPartialObject1, object2), 1, arrayOf(\n                \"INSERT OR REPLACE INTO testTable(id) VALUES(?1)\"\n            )\n        ) { handle.insertOrReplaceObject(object1, arrayOf(DBTestObject.id), tableName) }\n    }\n\n    @Test\n    fun testHandleInsertOrReplaceObjectsOnFields() {\n        expectMode = Expect.SomeSQLs\n        doTestObjectsAfterInsert(\n            listOf(renewedPartialObject1, renewedPartialObject2), 2, arrayOf(\n                \"INSERT OR REPLACE INTO testTable(id) VALUES(?1)\"\n            )\n        ) {\n            handle.insertOrReplaceObjects(\n                listOf(object1, object2), arrayOf(\n                    DBTestObject.id\n                ), tableName\n            )\n        }\n    }\n\n    @Test\n    fun testHandleInsertOrIgnoreObjectOnFields() {\n        doTestObjectsAfterInsert(\n            listOf(object1, object2), 1, arrayOf(\n                \"INSERT OR IGNORE INTO testTable(id) VALUES(?1)\"\n            )\n        ) { handle.insertOrIgnoreObject(object1, arrayOf(DBTestObject.id), tableName) }\n    }\n\n    @Test\n    fun testHandleInsertOrIgnoreObjectsOnFields() {\n        expectMode = Expect.SomeSQLs\n        doTestObjectsAfterInsert(\n            listOf(object1, object2), 2, arrayOf(\n                \"INSERT OR IGNORE INTO testTable(id) VALUES(?1)\"\n            )\n        ) {\n            handle.insertOrIgnoreObjects(\n                listOf(object1, object2),\n                arrayOf(DBTestObject.id),\n                tableName\n            )\n        }\n    }\n}"
  },
  {
    "path": "src/java/kotlin-test/src/androidTest/java/com/tencent/wcdbtest/crud/ObjectSelectTest.kt",
    "content": "// Created by qiuwenchen on 2023/6/25.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdbtest.crud\n\nimport com.tencent.wcdb.base.WCDBException\nimport com.tencent.wcdb.winq.Order\nimport com.tencent.wcdbtest.base.DBTestObject\nimport com.tencent.wcdbtest.base.ObjectCRUDTestCase\nimport com.tencent.wcdbtest.base.TestObject\nimport org.junit.Before\nimport org.junit.Test\n\nclass ObjectSelectTest : ObjectCRUDTestCase() {\n    private lateinit var partialObject1: TestObject\n    private lateinit var partialObject2: TestObject\n    private lateinit var partialObjects: List<TestObject>\n\n    @Before\n    @Throws(WCDBException::class)\n    override fun setup() {\n        super.setup()\n        partialObject1 = TestObject.createPartialObject(1)\n        partialObject2 = TestObject.createPartialObject(2)\n        partialObjects = listOf(partialObject1, partialObject2)\n    }\n\n    @Test\n    fun testDatabaseGetObject() {\n        doTestObjectBySelecting(object1, \"SELECT id, content FROM testTable\") {\n            listOf(\n                database.getFirstObject(\n                    DBTestObject.allFields(), tableName\n                )\n            )\n        }\n    }\n\n    @Test\n    fun testDatabaseGetObjectWhere() {\n        doTestObjectBySelecting(object2, \"SELECT id, content FROM testTable WHERE id == 2\") {\n            listOf(\n                database.getFirstObject(\n                    DBTestObject.allFields(), tableName, DBTestObject.id.eq(2)\n                )\n            )\n        }\n    }\n\n    @Test\n    fun testDatabaseGetObjectWhereOrder() {\n        doTestObjectBySelecting(\n            object2,\n            \"SELECT id, content FROM testTable WHERE id > 0 ORDER BY id DESC\"\n        ) {\n            listOf(\n                database.getFirstObject(\n                    DBTestObject.allFields(),\n                    tableName,\n                    DBTestObject.id.gt(0),\n                    DBTestObject.id.order(Order.Desc)\n                )\n            )\n        }\n    }\n\n    @Test\n    fun testDatabaseGetObjectWhereOrderOffset() {\n        doTestObjectBySelecting(\n            object1,\n            \"SELECT id, content FROM testTable WHERE id > 0 ORDER BY id DESC LIMIT 1 OFFSET 1\"\n        ) {\n            listOf(\n                database.getFirstObject(\n                    DBTestObject.allFields(),\n                    tableName,\n                    DBTestObject.id.gt(0),\n                    DBTestObject.id.order(Order.Desc),\n                    1\n                )\n            )\n        }\n    }\n\n    @Test\n    fun testDatabaseGetObjectOrder() {\n        doTestObjectBySelecting(object2, \"SELECT id, content FROM testTable ORDER BY id DESC\") {\n            listOf(\n                database.getFirstObject(\n                    DBTestObject.allFields(), tableName, DBTestObject.id.order(Order.Desc)\n                )\n            )\n        }\n    }\n\n    @Test\n    fun testDatabaseGetObjectOrderOffset() {\n        doTestObjectBySelecting(\n            object1,\n            \"SELECT id, content FROM testTable ORDER BY id DESC LIMIT 1 OFFSET 1\"\n        ) {\n            listOf(\n                database.getFirstObject(\n                    DBTestObject.allFields(), tableName, DBTestObject.id.order(Order.Desc), 1\n                )\n            )\n        }\n    }\n\n    @Test\n    fun testDatabaseGetObjects() {\n        doTestObjectBySelecting(objects, \"SELECT id, content FROM testTable\") {\n            database.getAllObjects(\n                DBTestObject.allFields(), tableName\n            )\n        }\n    }\n\n    @Test\n    fun testDatabaseGetObjectsWhere() {\n        doTestObjectBySelecting(object1, \"SELECT id, content FROM testTable WHERE id == 1\") {\n            database.getAllObjects(\n                DBTestObject.allFields(), tableName, DBTestObject.id.eq(1)\n            )\n        }\n    }\n\n    @Test\n    fun testDatabaseGetObjectsWhereOrder() {\n        doTestObjectBySelecting(\n            listOf(object2, object1),\n            \"SELECT id, content FROM testTable WHERE id > 0 ORDER BY id DESC\"\n        ) {\n            database.getAllObjects(\n                DBTestObject.allFields(),\n                tableName,\n                DBTestObject.id.gt(0),\n                DBTestObject.id.order(Order.Desc)\n            )\n        }\n    }\n\n    @Test\n    fun testDatabaseGetObjectsWhereOrderLimit() {\n        doTestObjectBySelecting(\n            object2,\n            \"SELECT id, content FROM testTable WHERE id > 0 ORDER BY id DESC LIMIT 1\"\n        ) {\n            database.getAllObjects(\n                DBTestObject.allFields(),\n                tableName,\n                DBTestObject.id.gt(0),\n                DBTestObject.id.order(Order.Desc),\n                1\n            )\n        }\n    }\n\n    @Test\n    fun testDatabaseGetObjectsWhereOrderLimitOffset() {\n        doTestObjectBySelecting(\n            object1,\n            \"SELECT id, content FROM testTable WHERE id > 0 ORDER BY id DESC LIMIT 1 OFFSET 1\"\n        ) {\n            database.getAllObjects(\n                DBTestObject.allFields(),\n                tableName,\n                DBTestObject.id.gt(0),\n                DBTestObject.id.order(Order.Desc),\n                1,\n                1\n            )\n        }\n    }\n\n    @Test\n    fun testDatabaseGetObjectsOrder() {\n        doTestObjectBySelecting(\n            listOf(object2, object1),\n            \"SELECT id, content FROM testTable ORDER BY id DESC\"\n        ) {\n            database.getAllObjects(\n                DBTestObject.allFields(), tableName, DBTestObject.id.order(Order.Desc)\n            )\n        }\n    }\n\n    @Test\n    fun testDatabaseGetObjectsOrderLimit() {\n        doTestObjectBySelecting(\n            object2,\n            \"SELECT id, content FROM testTable ORDER BY id DESC LIMIT 1\"\n        ) {\n            database.getAllObjects(\n                DBTestObject.allFields(), tableName, DBTestObject.id.order(Order.Desc), 1\n            )\n        }\n    }\n\n    @Test\n    fun testDatabaseGetObjectsOrderLimitOffset() {\n        doTestObjectBySelecting(\n            object1,\n            \"SELECT id, content FROM testTable ORDER BY id DESC LIMIT 1 OFFSET 1\"\n        ) {\n            database.getAllObjects(\n                DBTestObject.allFields(), tableName, DBTestObject.id.order(Order.Desc), 1, 1\n            )\n        }\n    }\n\n    @Test\n    fun testDatabaseGetObjectOnFields() {\n        doTestObjectBySelecting(partialObject1, \"SELECT id FROM testTable\") {\n            listOf(\n                database.getFirstObject(\n                    arrayOf(\n                        DBTestObject.id\n                    ), tableName\n                )\n            )\n        }\n    }\n\n    @Test\n    fun testDatabaseGetObjectOnFieldsWhere() {\n        doTestObjectBySelecting(partialObject2, \"SELECT id FROM testTable WHERE id == 2\") {\n            listOf(\n                database.getFirstObject(\n                    arrayOf(\n                        DBTestObject.id\n                    ), tableName, DBTestObject.id.eq(2)\n                )\n            )\n        }\n    }\n\n    @Test\n    fun testDatabaseGetObjectOnFieldsWhereOrder() {\n        doTestObjectBySelecting(\n            partialObject2,\n            \"SELECT id FROM testTable WHERE id > 0 ORDER BY id DESC\"\n        ) {\n            listOf(\n                database.getFirstObject(\n                    arrayOf(\n                        DBTestObject.id\n                    ), tableName, DBTestObject.id.gt(0), DBTestObject.id.order(Order.Desc)\n                )\n            )\n        }\n    }\n\n    @Test\n    fun testDatabaseGetObjectOnFieldsWhereOrderOffset() {\n        doTestObjectBySelecting(\n            partialObject1,\n            \"SELECT id FROM testTable WHERE id > 0 ORDER BY id DESC LIMIT 1 OFFSET 1\"\n        ) {\n            listOf(\n                database.getFirstObject(\n                    arrayOf(\n                        DBTestObject.id\n                    ), tableName, DBTestObject.id.gt(0), DBTestObject.id.order(Order.Desc), 1\n                )\n            )\n        }\n    }\n\n    @Test\n    fun testDatabaseGetObjectOnFieldsOrder() {\n        doTestObjectBySelecting(partialObject2, \"SELECT id FROM testTable ORDER BY id DESC\") {\n            listOf(\n                database.getFirstObject(\n                    arrayOf(\n                        DBTestObject.id\n                    ), tableName, DBTestObject.id.order(Order.Desc)\n                )\n            )\n        }\n    }\n\n    @Test\n    fun testDatabaseGetObjectOnFieldsOrderOffset() {\n        doTestObjectBySelecting(\n            partialObject1,\n            \"SELECT id FROM testTable ORDER BY id DESC LIMIT 1 OFFSET 1\"\n        ) {\n            listOf(\n                database.getFirstObject(\n                    arrayOf(\n                        DBTestObject.id\n                    ), tableName, DBTestObject.id.order(Order.Desc), 1\n                )\n            )\n        }\n    }\n\n    @Test\n    fun testDatabaseGetObjectsOnFields() {\n        doTestObjectBySelecting(\n            partialObjects,\n            \"SELECT id FROM testTable\"\n        ) {\n            database.getAllObjects(\n                arrayOf(\n                    DBTestObject.id\n                ), tableName\n            )\n        }\n    }\n\n    @Test\n    fun testDatabaseGetObjectsOnFieldsWhere() {\n        doTestObjectBySelecting(\n            partialObject1,\n            \"SELECT id FROM testTable WHERE id == 1\"\n        ) {\n            database.getAllObjects(\n                arrayOf(\n                    DBTestObject.id\n                ), tableName, DBTestObject.id.eq(1)\n            )\n        }\n    }\n\n    @Test\n    fun testDatabaseGetObjectsOnFieldsWhereOrder() {\n        doTestObjectBySelecting(\n            listOf(partialObject2, partialObject1),\n            \"SELECT id FROM testTable WHERE id > 0 ORDER BY id DESC\"\n        ) {\n            database.getAllObjects(\n                arrayOf(\n                    DBTestObject.id\n                ), tableName, DBTestObject.id.gt(0), DBTestObject.id.order(Order.Desc)\n            )\n        }\n    }\n\n    @Test\n    fun testDatabaseGetObjectsOnFieldsWhereOrderLimit() {\n        doTestObjectBySelecting(\n            partialObject2,\n            \"SELECT id FROM testTable WHERE id > 0 ORDER BY id DESC LIMIT 1\"\n        ) {\n            database.getAllObjects(\n                arrayOf(\n                    DBTestObject.id\n                ), tableName, DBTestObject.id.gt(0), DBTestObject.id.order(Order.Desc), 1\n            )\n        }\n    }\n\n    @Test\n    fun testDatabaseGetObjectsOnFieldsWhereOrderLimitOffset() {\n        doTestObjectBySelecting(\n            partialObject1,\n            \"SELECT id FROM testTable WHERE id > 0 ORDER BY id DESC LIMIT 1 OFFSET 1\"\n        ) {\n            database.getAllObjects(\n                arrayOf(\n                    DBTestObject.id\n                ), tableName, DBTestObject.id.gt(0), DBTestObject.id.order(Order.Desc), 1, 1\n            )\n        }\n    }\n\n    @Test\n    fun testDatabaseGetObjectsOnFieldsOrder() {\n        doTestObjectBySelecting(\n            listOf(partialObject2, partialObject1),\n            \"SELECT id FROM testTable ORDER BY id DESC\"\n        ) {\n            database.getAllObjects(\n                arrayOf(\n                    DBTestObject.id\n                ), tableName, DBTestObject.id.order(Order.Desc)\n            )\n        }\n    }\n\n    @Test\n    fun testDatabaseGetObjectsOnFieldsOrderLimit() {\n        doTestObjectBySelecting(\n            partialObject2,\n            \"SELECT id FROM testTable ORDER BY id DESC LIMIT 1\"\n        ) {\n            database.getAllObjects(\n                arrayOf(\n                    DBTestObject.id\n                ), tableName, DBTestObject.id.order(Order.Desc), 1\n            )\n        }\n    }\n\n    @Test\n    fun testDatabaseGetObjectsOnFieldsOrderLimitOffset() {\n        doTestObjectBySelecting(\n            partialObject1,\n            \"SELECT id FROM testTable ORDER BY id DESC LIMIT 1 OFFSET 1\"\n        ) {\n            database.getAllObjects(\n                arrayOf(\n                    DBTestObject.id\n                ), tableName, DBTestObject.id.order(Order.Desc), 1, 1\n            )\n        }\n    }\n\n    @Test\n    fun testTableGetObject() {\n        doTestObjectBySelecting(object1, \"SELECT id, content FROM testTable\") {\n            listOf(\n                table.getFirstObject(\n                    DBTestObject.allFields()\n                )\n            )\n        }\n    }\n\n    @Test\n    fun testTableGetObjectWhere() {\n        doTestObjectBySelecting(object2, \"SELECT id, content FROM testTable WHERE id == 2\") {\n            listOf(\n                table.getFirstObject(\n                    DBTestObject.allFields(), DBTestObject.id.eq(2)\n                )\n            )\n        }\n    }\n\n    @Test\n    fun testTableGetObjectWhereOrder() {\n        doTestObjectBySelecting(\n            object2,\n            \"SELECT id, content FROM testTable WHERE id > 0 ORDER BY id DESC\"\n        ) {\n            listOf(\n                table.getFirstObject(\n                    DBTestObject.allFields(),\n                    DBTestObject.id.gt(0),\n                    DBTestObject.id.order(Order.Desc)\n                )\n            )\n        }\n    }\n\n    @Test\n    fun testTableGetObjectWhereOrderOffset() {\n        doTestObjectBySelecting(\n            object1,\n            \"SELECT id, content FROM testTable WHERE id > 0 ORDER BY id DESC LIMIT 1 OFFSET 1\"\n        ) {\n            listOf(\n                table.getFirstObject(\n                    DBTestObject.allFields(),\n                    DBTestObject.id.gt(0),\n                    DBTestObject.id.order(Order.Desc),\n                    1\n                )\n            )\n        }\n    }\n\n    @Test\n    fun testTableGetObjectOrder() {\n        doTestObjectBySelecting(object2, \"SELECT id, content FROM testTable ORDER BY id DESC\") {\n            listOf(\n                table.getFirstObject(\n                    DBTestObject.allFields(), DBTestObject.id.order(Order.Desc)\n                )\n            )\n        }\n    }\n\n    @Test\n    fun testTableGetObjectOrderOffset() {\n        doTestObjectBySelecting(\n            object1,\n            \"SELECT id, content FROM testTable ORDER BY id DESC LIMIT 1 OFFSET 1\"\n        ) {\n            listOf(\n                table.getFirstObject(\n                    DBTestObject.allFields(), DBTestObject.id.order(Order.Desc), 1\n                )\n            )\n        }\n    }\n\n    @Test\n    fun testTableGetObjects() {\n        doTestObjectBySelecting(objects, \"SELECT id, content FROM testTable\") {\n            table.getAllObjects(\n                DBTestObject.allFields()\n            )\n        }\n    }\n\n    @Test\n    fun testTableGetObjectsWhere() {\n        doTestObjectBySelecting(object1, \"SELECT id, content FROM testTable WHERE id == 1\") {\n            table.getAllObjects(\n                DBTestObject.allFields(), DBTestObject.id.eq(1)\n            )\n        }\n    }\n\n    @Test\n    fun testTableGetObjectsWhereOrder() {\n        doTestObjectBySelecting(\n            listOf(object2, object1),\n            \"SELECT id, content FROM testTable WHERE id > 0 ORDER BY id DESC\"\n        ) {\n            table.getAllObjects(\n                DBTestObject.allFields(), DBTestObject.id.gt(0), DBTestObject.id.order(Order.Desc)\n            )\n        }\n    }\n\n    @Test\n    fun testTableGetObjectsWhereOrderLimit() {\n        doTestObjectBySelecting(\n            object2,\n            \"SELECT id, content FROM testTable WHERE id > 0 ORDER BY id DESC LIMIT 1\"\n        ) {\n            table.getAllObjects(\n                DBTestObject.allFields(),\n                DBTestObject.id.gt(0),\n                DBTestObject.id.order(Order.Desc),\n                1\n            )\n        }\n    }\n\n    @Test\n    fun testTableGetObjectsWhereOrderLimitOffset() {\n        doTestObjectBySelecting(\n            object1,\n            \"SELECT id, content FROM testTable WHERE id > 0 ORDER BY id DESC LIMIT 1 OFFSET 1\"\n        ) {\n            table.getAllObjects(\n                DBTestObject.allFields(),\n                DBTestObject.id.gt(0),\n                DBTestObject.id.order(Order.Desc),\n                1,\n                1\n            )\n        }\n    }\n\n    @Test\n    fun testTableGetObjectsOrder() {\n        doTestObjectBySelecting(\n            listOf(object2, object1),\n            \"SELECT id, content FROM testTable ORDER BY id DESC\"\n        ) {\n            table.getAllObjects(\n                DBTestObject.allFields(), DBTestObject.id.order(Order.Desc)\n            )\n        }\n    }\n\n    @Test\n    fun testTableGetObjectsOrderLimit() {\n        doTestObjectBySelecting(\n            object2,\n            \"SELECT id, content FROM testTable ORDER BY id DESC LIMIT 1\"\n        ) {\n            table.getAllObjects(\n                DBTestObject.allFields(), DBTestObject.id.order(Order.Desc), 1\n            )\n        }\n    }\n\n    @Test\n    fun testTableGetObjectsOrderLimitOffset() {\n        doTestObjectBySelecting(\n            object1,\n            \"SELECT id, content FROM testTable ORDER BY id DESC LIMIT 1 OFFSET 1\"\n        ) {\n            table.getAllObjects(\n                DBTestObject.allFields(), DBTestObject.id.order(Order.Desc), 1, 1\n            )\n        }\n    }\n\n    @Test\n    fun testTableGetObjectOnFields() {\n        doTestObjectBySelecting(partialObject1, \"SELECT id FROM testTable\") {\n            listOf(\n                table.getFirstObject(\n                    arrayOf(\n                        DBTestObject.id\n                    )\n                )\n            )\n        }\n    }\n\n    @Test\n    fun testTableGetObjectOnFieldsWhere() {\n        doTestObjectBySelecting(partialObject2, \"SELECT id FROM testTable WHERE id == 2\") {\n            listOf(\n                table.getFirstObject(\n                    arrayOf(\n                        DBTestObject.id\n                    ), DBTestObject.id.eq(2)\n                )\n            )\n        }\n    }\n\n    @Test\n    fun testTableGetObjectOnFieldsWhereOrder() {\n        doTestObjectBySelecting(\n            partialObject2,\n            \"SELECT id FROM testTable WHERE id > 0 ORDER BY id DESC\"\n        ) {\n            listOf(\n                table.getFirstObject(\n                    arrayOf(\n                        DBTestObject.id\n                    ), DBTestObject.id.gt(0), DBTestObject.id.order(Order.Desc)\n                )\n            )\n        }\n    }\n\n    @Test\n    fun testTableGetObjectOnFieldsWhereOrderOffset() {\n        doTestObjectBySelecting(\n            partialObject1,\n            \"SELECT id FROM testTable WHERE id > 0 ORDER BY id DESC LIMIT 1 OFFSET 1\"\n        ) {\n            listOf(\n                table.getFirstObject(\n                    arrayOf(\n                        DBTestObject.id\n                    ), DBTestObject.id.gt(0), DBTestObject.id.order(Order.Desc), 1\n                )\n            )\n        }\n    }\n\n    @Test\n    fun testTableGetObjectOnFieldsOrder() {\n        doTestObjectBySelecting(partialObject2, \"SELECT id FROM testTable ORDER BY id DESC\") {\n            listOf(\n                table.getFirstObject(\n                    arrayOf(\n                        DBTestObject.id\n                    ), DBTestObject.id.order(Order.Desc)\n                )\n            )\n        }\n    }\n\n    @Test\n    fun testTableGetObjectOnFieldsOrderOffset() {\n        doTestObjectBySelecting(\n            partialObject1,\n            \"SELECT id FROM testTable ORDER BY id DESC LIMIT 1 OFFSET 1\"\n        ) {\n            listOf(\n                table.getFirstObject(\n                    arrayOf(\n                        DBTestObject.id\n                    ), DBTestObject.id.order(Order.Desc), 1\n                )\n            )\n        }\n    }\n\n    @Test\n    fun testTableGetObjectsOnFields() {\n        doTestObjectBySelecting(\n            partialObjects,\n            \"SELECT id FROM testTable\"\n        ) {\n            table.getAllObjects(\n                arrayOf(\n                    DBTestObject.id\n                )\n            )\n        }\n    }\n\n    @Test\n    fun testTableGetObjectsOnFieldsWhere() {\n        doTestObjectBySelecting(\n            partialObject1,\n            \"SELECT id FROM testTable WHERE id == 1\"\n        ) {\n            table.getAllObjects(\n                arrayOf(\n                    DBTestObject.id\n                ), DBTestObject.id.eq(1)\n            )\n        }\n    }\n\n    @Test\n    fun testTableGetObjectsOnFieldsWhereOrder() {\n        doTestObjectBySelecting(\n            listOf(partialObject2, partialObject1),\n            \"SELECT id FROM testTable WHERE id > 0 ORDER BY id DESC\"\n        ) {\n            table.getAllObjects(\n                arrayOf(\n                    DBTestObject.id\n                ), DBTestObject.id.gt(0), DBTestObject.id.order(Order.Desc)\n            )\n        }\n    }\n\n    @Test\n    fun testTableGetObjectsOnFieldsWhereOrderLimit() {\n        doTestObjectBySelecting(\n            partialObject2,\n            \"SELECT id FROM testTable WHERE id > 0 ORDER BY id DESC LIMIT 1\"\n        ) {\n            table.getAllObjects(\n                arrayOf(\n                    DBTestObject.id\n                ), DBTestObject.id.gt(0), DBTestObject.id.order(Order.Desc), 1\n            )\n        }\n    }\n\n    @Test\n    fun testTableGetObjectsOnFieldsWhereOrderLimitOffset() {\n        doTestObjectBySelecting(\n            partialObject1,\n            \"SELECT id FROM testTable WHERE id > 0 ORDER BY id DESC LIMIT 1 OFFSET 1\"\n        ) {\n            table.getAllObjects(\n                arrayOf(\n                    DBTestObject.id\n                ), DBTestObject.id.gt(0), DBTestObject.id.order(Order.Desc), 1, 1\n            )\n        }\n    }\n\n    @Test\n    fun testTableGetObjectsOnFieldsOrder() {\n        doTestObjectBySelecting(\n            listOf(partialObject2, partialObject1),\n            \"SELECT id FROM testTable ORDER BY id DESC\"\n        ) {\n            table.getAllObjects(\n                arrayOf(\n                    DBTestObject.id\n                ), DBTestObject.id.order(Order.Desc)\n            )\n        }\n    }\n\n    @Test\n    fun testTableGetObjectsOnFieldsOrderLimit() {\n        doTestObjectBySelecting(\n            partialObject2,\n            \"SELECT id FROM testTable ORDER BY id DESC LIMIT 1\"\n        ) {\n            table.getAllObjects(\n                arrayOf(\n                    DBTestObject.id\n                ), DBTestObject.id.order(Order.Desc), 1\n            )\n        }\n    }\n\n    @Test\n    fun testTableGetObjectsOnFieldsOrderLimitOffset() {\n        doTestObjectBySelecting(\n            partialObject1,\n            \"SELECT id FROM testTable ORDER BY id DESC LIMIT 1 OFFSET 1\"\n        ) {\n            table.getAllObjects(\n                arrayOf(\n                    DBTestObject.id\n                ), DBTestObject.id.order(Order.Desc), 1, 1\n            )\n        }\n    }\n\n    @Test\n    fun testTableGetObjectWithoutField() {\n        doTestObjectBySelecting(\n            object1,\n            \"SELECT id, content FROM testTable\"\n        ) { listOf(table.firstObject) }\n    }\n\n    @Test\n    fun testTableGetObjectWithoutFieldWhere() {\n        doTestObjectBySelecting(object2, \"SELECT id, content FROM testTable WHERE id == 2\") {\n            listOf(\n                table.getFirstObject(\n                    DBTestObject.id.eq(2)\n                )\n            )\n        }\n    }\n\n    @Test\n    fun testTableGetObjectWithoutFieldWhereOrder() {\n        doTestObjectBySelecting(\n            object2,\n            \"SELECT id, content FROM testTable WHERE id > 0 ORDER BY id DESC\"\n        ) {\n            listOf(\n                table.getFirstObject(\n                    DBTestObject.id.gt(0), DBTestObject.id.order(Order.Desc)\n                )\n            )\n        }\n    }\n\n    @Test\n    fun testTableGetObjectWithoutFieldWhereOrderOffset() {\n        doTestObjectBySelecting(\n            object1,\n            \"SELECT id, content FROM testTable WHERE id > 0 ORDER BY id DESC LIMIT 1 OFFSET 1\"\n        ) {\n            listOf(\n                table.getFirstObject(\n                    DBTestObject.id.gt(0), DBTestObject.id.order(Order.Desc), 1\n                )\n            )\n        }\n    }\n\n    @Test\n    fun testTableGetObjectWithoutFieldOrder() {\n        doTestObjectBySelecting(object2, \"SELECT id, content FROM testTable ORDER BY id DESC\") {\n            listOf(\n                table.getFirstObject(\n                    DBTestObject.id.order(Order.Desc)\n                )\n            )\n        }\n    }\n\n    @Test\n    fun testTableGetObjectWithoutFieldOrderOffset() {\n        doTestObjectBySelecting(\n            object1,\n            \"SELECT id, content FROM testTable ORDER BY id DESC LIMIT 1 OFFSET 1\"\n        ) {\n            listOf(\n                table.getFirstObject(\n                    DBTestObject.id.order(Order.Desc), 1\n                )\n            )\n        }\n    }\n\n    @Test\n    fun testTableGetObjectsWithoutFields() {\n        doTestObjectBySelecting(objects, \"SELECT id, content FROM testTable\") { table.allObjects }\n    }\n\n    @Test\n    fun testTableGetObjectsWithoutFieldsWhere() {\n        doTestObjectBySelecting(object1, \"SELECT id, content FROM testTable WHERE id == 1\") {\n            table.getAllObjects(\n                DBTestObject.id.eq(1)\n            )\n        }\n    }\n\n    @Test\n    fun testTableGetObjectsWithoutFieldsWhereOrder() {\n        doTestObjectBySelecting(\n            listOf(object2, object1),\n            \"SELECT id, content FROM testTable WHERE id > 0 ORDER BY id DESC\"\n        ) {\n            table.getAllObjects(\n                DBTestObject.id.gt(0), DBTestObject.id.order(Order.Desc)\n            )\n        }\n    }\n\n    @Test\n    fun testTableGetObjectsWithoutFieldsWhereOrderLimit() {\n        doTestObjectBySelecting(\n            object2,\n            \"SELECT id, content FROM testTable WHERE id > 0 ORDER BY id DESC LIMIT 1\"\n        ) {\n            table.getAllObjects(\n                DBTestObject.id.gt(0), DBTestObject.id.order(Order.Desc), 1\n            )\n        }\n    }\n\n    @Test\n    fun testTableGetObjectsWithoutFieldsWhereOrderLimitOffset() {\n        doTestObjectBySelecting(\n            object1,\n            \"SELECT id, content FROM testTable WHERE id > 0 ORDER BY id DESC LIMIT 1 OFFSET 1\"\n        ) {\n            table.getAllObjects(\n                DBTestObject.id.gt(0), DBTestObject.id.order(Order.Desc), 1, 1\n            )\n        }\n    }\n\n    @Test\n    fun testTableGetObjectsWithoutFieldsOrder() {\n        doTestObjectBySelecting(\n            listOf(object2, object1),\n            \"SELECT id, content FROM testTable ORDER BY id DESC\"\n        ) {\n            table.getAllObjects(\n                DBTestObject.id.order(Order.Desc)\n            )\n        }\n    }\n\n    @Test\n    fun testTableGetObjectsWithoutFieldsOrderLimit() {\n        doTestObjectBySelecting(\n            object2,\n            \"SELECT id, content FROM testTable ORDER BY id DESC LIMIT 1\"\n        ) {\n            table.getAllObjects(\n                DBTestObject.id.order(Order.Desc), 1\n            )\n        }\n    }\n\n    @Test\n    fun testTableGetObjectsWithoutFieldsOrderLimitOffset() {\n        doTestObjectBySelecting(\n            object1,\n            \"SELECT id, content FROM testTable ORDER BY id DESC LIMIT 1 OFFSET 1\"\n        ) {\n            table.getAllObjects(\n                DBTestObject.id.order(Order.Desc), 1, 1\n            )\n        }\n    }\n\n    @Test\n    fun testHandleGetObject() {\n        doTestObjectBySelecting(object1, \"SELECT id, content FROM testTable\") {\n            listOf(\n                handle.getFirstObject(\n                    DBTestObject.allFields(), tableName\n                )\n            )\n        }\n    }\n\n    @Test\n    fun testHandleGetObjectWhere() {\n        doTestObjectBySelecting(object2, \"SELECT id, content FROM testTable WHERE id == 2\") {\n            listOf(\n                handle.getFirstObject(\n                    DBTestObject.allFields(), tableName, DBTestObject.id.eq(2)\n                )\n            )\n        }\n    }\n\n    @Test\n    fun testHandleGetObjectWhereOrder() {\n        doTestObjectBySelecting(\n            object2,\n            \"SELECT id, content FROM testTable WHERE id > 0 ORDER BY id DESC\"\n        ) {\n            listOf(\n                handle.getFirstObject(\n                    DBTestObject.allFields(),\n                    tableName,\n                    DBTestObject.id.gt(0),\n                    DBTestObject.id.order(Order.Desc)\n                )\n            )\n        }\n    }\n\n    @Test\n    fun testHandleGetObjectWhereOrderOffset() {\n        doTestObjectBySelecting(\n            object1,\n            \"SELECT id, content FROM testTable WHERE id > 0 ORDER BY id DESC LIMIT 1 OFFSET 1\"\n        ) {\n            listOf(\n                handle.getFirstObject(\n                    DBTestObject.allFields(),\n                    tableName,\n                    DBTestObject.id.gt(0),\n                    DBTestObject.id.order(Order.Desc),\n                    1\n                )\n            )\n        }\n    }\n\n    @Test\n    fun testHandleGetObjectOrder() {\n        doTestObjectBySelecting(object2, \"SELECT id, content FROM testTable ORDER BY id DESC\") {\n            listOf(\n                handle.getFirstObject(\n                    DBTestObject.allFields(), tableName, DBTestObject.id.order(Order.Desc)\n                )\n            )\n        }\n    }\n\n    @Test\n    fun testHandleGetObjectOrderOffset() {\n        doTestObjectBySelecting(\n            object1,\n            \"SELECT id, content FROM testTable ORDER BY id DESC LIMIT 1 OFFSET 1\"\n        ) {\n            listOf(\n                handle.getFirstObject(\n                    DBTestObject.allFields(), tableName, DBTestObject.id.order(Order.Desc), 1\n                )\n            )\n        }\n    }\n\n    @Test\n    fun testHandleGetObjects() {\n        doTestObjectBySelecting(objects, \"SELECT id, content FROM testTable\") {\n            handle.getAllObjects(\n                DBTestObject.allFields(), tableName\n            )\n        }\n    }\n\n    @Test\n    fun testHandleGetObjectsWhere() {\n        doTestObjectBySelecting(object1, \"SELECT id, content FROM testTable WHERE id == 1\") {\n            handle.getAllObjects(\n                DBTestObject.allFields(), tableName, DBTestObject.id.eq(1)\n            )\n        }\n    }\n\n    @Test\n    fun testHandleGetObjectsWhereOrder() {\n        doTestObjectBySelecting(\n            listOf(object2, object1),\n            \"SELECT id, content FROM testTable WHERE id > 0 ORDER BY id DESC\"\n        ) {\n            handle.getAllObjects(\n                DBTestObject.allFields(),\n                tableName,\n                DBTestObject.id.gt(0),\n                DBTestObject.id.order(Order.Desc)\n            )\n        }\n    }\n\n    @Test\n    fun testHandleGetObjectsWhereOrderLimit() {\n        doTestObjectBySelecting(\n            object2,\n            \"SELECT id, content FROM testTable WHERE id > 0 ORDER BY id DESC LIMIT 1\"\n        ) {\n            handle.getAllObjects(\n                DBTestObject.allFields(),\n                tableName,\n                DBTestObject.id.gt(0),\n                DBTestObject.id.order(Order.Desc),\n                1\n            )\n        }\n    }\n\n    @Test\n    fun testHandleGetObjectsWhereOrderLimitOffset() {\n        doTestObjectBySelecting(\n            object1,\n            \"SELECT id, content FROM testTable WHERE id > 0 ORDER BY id DESC LIMIT 1 OFFSET 1\"\n        ) {\n            handle.getAllObjects(\n                DBTestObject.allFields(),\n                tableName,\n                DBTestObject.id.gt(0),\n                DBTestObject.id.order(Order.Desc),\n                1,\n                1\n            )\n        }\n    }\n\n    @Test\n    fun testHandleGetObjectsOrder() {\n        doTestObjectBySelecting(\n            listOf(object2, object1),\n            \"SELECT id, content FROM testTable ORDER BY id DESC\"\n        ) {\n            handle.getAllObjects(\n                DBTestObject.allFields(), tableName, DBTestObject.id.order(Order.Desc)\n            )\n        }\n    }\n\n    @Test\n    fun testHandleGetObjectsOrderLimit() {\n        doTestObjectBySelecting(\n            object2,\n            \"SELECT id, content FROM testTable ORDER BY id DESC LIMIT 1\"\n        ) {\n            handle.getAllObjects(\n                DBTestObject.allFields(), tableName, DBTestObject.id.order(Order.Desc), 1\n            )\n        }\n    }\n\n    @Test\n    fun testHandleGetObjectsOrderLimitOffset() {\n        doTestObjectBySelecting(\n            object1,\n            \"SELECT id, content FROM testTable ORDER BY id DESC LIMIT 1 OFFSET 1\"\n        ) {\n            handle.getAllObjects(\n                DBTestObject.allFields(), tableName, DBTestObject.id.order(Order.Desc), 1, 1\n            )\n        }\n    }\n\n    @Test\n    fun testHandleGetObjectOnFields() {\n        doTestObjectBySelecting(partialObject1, \"SELECT id FROM testTable\") {\n            listOf(\n                handle.getFirstObject(\n                    arrayOf(\n                        DBTestObject.id\n                    ), tableName\n                )\n            )\n        }\n    }\n\n    @Test\n    fun testHandleGetObjectOnFieldsWhere() {\n        doTestObjectBySelecting(partialObject2, \"SELECT id FROM testTable WHERE id == 2\") {\n            listOf(\n                handle.getFirstObject(\n                    arrayOf(\n                        DBTestObject.id\n                    ), tableName, DBTestObject.id.eq(2)\n                )\n            )\n        }\n    }\n\n    @Test\n    fun testHandleGetObjectOnFieldsWhereOrder() {\n        doTestObjectBySelecting(\n            partialObject2,\n            \"SELECT id FROM testTable WHERE id > 0 ORDER BY id DESC\"\n        ) {\n            listOf(\n                handle.getFirstObject(\n                    arrayOf(\n                        DBTestObject.id\n                    ), tableName, DBTestObject.id.gt(0), DBTestObject.id.order(Order.Desc)\n                )\n            )\n        }\n    }\n\n    @Test\n    fun testHandleGetObjectOnFieldsWhereOrderOffset() {\n        doTestObjectBySelecting(\n            partialObject1,\n            \"SELECT id FROM testTable WHERE id > 0 ORDER BY id DESC LIMIT 1 OFFSET 1\"\n        ) {\n            listOf(\n                handle.getFirstObject(\n                    arrayOf(\n                        DBTestObject.id\n                    ), tableName, DBTestObject.id.gt(0), DBTestObject.id.order(Order.Desc), 1\n                )\n            )\n        }\n    }\n\n    @Test\n    fun testHandleGetObjectOnFieldsOrder() {\n        doTestObjectBySelecting(partialObject2, \"SELECT id FROM testTable ORDER BY id DESC\") {\n            listOf(\n                handle.getFirstObject(\n                    arrayOf(\n                        DBTestObject.id\n                    ), tableName, DBTestObject.id.order(Order.Desc)\n                )\n            )\n        }\n    }\n\n    @Test\n    fun testHandleGetObjectOnFieldsOrderOffset() {\n        doTestObjectBySelecting(\n            partialObject1,\n            \"SELECT id FROM testTable ORDER BY id DESC LIMIT 1 OFFSET 1\"\n        ) {\n            listOf(\n                handle.getFirstObject(\n                    arrayOf(\n                        DBTestObject.id\n                    ), tableName, DBTestObject.id.order(Order.Desc), 1\n                )\n            )\n        }\n    }\n\n    @Test\n    fun testHandleGetObjectsOnFields() {\n        doTestObjectBySelecting(\n            partialObjects,\n            \"SELECT id FROM testTable\"\n        ) {\n            handle.getAllObjects(\n                arrayOf(\n                    DBTestObject.id\n                ), tableName\n            )\n        }\n    }\n\n    @Test\n    fun testHandleGetObjectsOnFieldsWhere() {\n        doTestObjectBySelecting(\n            partialObject1,\n            \"SELECT id FROM testTable WHERE id == 1\"\n        ) {\n            handle.getAllObjects(\n                arrayOf(\n                    DBTestObject.id\n                ), tableName, DBTestObject.id.eq(1)\n            )\n        }\n    }\n\n    @Test\n    fun testHandleGetObjectsOnFieldsWhereOrder() {\n        doTestObjectBySelecting(\n            listOf(partialObject2, partialObject1),\n            \"SELECT id FROM testTable WHERE id > 0 ORDER BY id DESC\"\n        ) {\n            handle.getAllObjects(\n                arrayOf(\n                    DBTestObject.id\n                ), tableName, DBTestObject.id.gt(0), DBTestObject.id.order(Order.Desc)\n            )\n        }\n    }\n\n    @Test\n    fun testHandleGetObjectsOnFieldsWhereOrderLimit() {\n        doTestObjectBySelecting(\n            partialObject2,\n            \"SELECT id FROM testTable WHERE id > 0 ORDER BY id DESC LIMIT 1\"\n        ) {\n            handle.getAllObjects(\n                arrayOf(\n                    DBTestObject.id\n                ), tableName, DBTestObject.id.gt(0), DBTestObject.id.order(Order.Desc), 1\n            )\n        }\n    }\n\n    @Test\n    fun testHandleGetObjectsOnFieldsWhereOrderLimitOffset() {\n        doTestObjectBySelecting(\n            partialObject1,\n            \"SELECT id FROM testTable WHERE id > 0 ORDER BY id DESC LIMIT 1 OFFSET 1\"\n        ) {\n            handle.getAllObjects(\n                arrayOf(\n                    DBTestObject.id\n                ), tableName, DBTestObject.id.gt(0), DBTestObject.id.order(Order.Desc), 1, 1\n            )\n        }\n    }\n\n    @Test\n    fun testHandleGetObjectsOnFieldsOrder() {\n        doTestObjectBySelecting(\n            listOf(partialObject2, partialObject1),\n            \"SELECT id FROM testTable ORDER BY id DESC\"\n        ) {\n            handle.getAllObjects(\n                arrayOf(\n                    DBTestObject.id\n                ), tableName, DBTestObject.id.order(Order.Desc)\n            )\n        }\n    }\n\n    @Test\n    fun testHandleGetObjectsOnFieldsOrderLimit() {\n        doTestObjectBySelecting(\n            partialObject2,\n            \"SELECT id FROM testTable ORDER BY id DESC LIMIT 1\"\n        ) {\n            handle.getAllObjects(\n                arrayOf(\n                    DBTestObject.id\n                ), tableName, DBTestObject.id.order(Order.Desc), 1\n            )\n        }\n    }\n\n    @Test\n    fun testHandleGetObjectsOnFieldsOrderLimitOffset() {\n        doTestObjectBySelecting(\n            partialObject1,\n            \"SELECT id FROM testTable ORDER BY id DESC LIMIT 1 OFFSET 1\"\n        ) {\n            handle.getAllObjects(\n                arrayOf(\n                    DBTestObject.id\n                ), tableName, DBTestObject.id.order(Order.Desc), 1, 1\n            )\n        }\n    }\n}"
  },
  {
    "path": "src/java/kotlin-test/src/androidTest/java/com/tencent/wcdbtest/crud/ObjectUpdateTest.kt",
    "content": "// Created by qiuwenchen on 2023/6/25.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdbtest.crud\n\nimport com.tencent.wcdb.base.WCDBException\nimport com.tencent.wcdb.winq.Order\nimport com.tencent.wcdbtest.base.DBTestObject\nimport com.tencent.wcdbtest.base.ObjectCRUDTestCase\nimport com.tencent.wcdbtest.base.RandomTool\nimport com.tencent.wcdbtest.base.TestObject\nimport org.junit.Before\nimport org.junit.Test\n\nclass ObjectUpdateTest : ObjectCRUDTestCase() {\n    private lateinit var renewObject: TestObject\n    private lateinit var renewedObject1: TestObject\n    private lateinit var renewedObject2: TestObject\n\n    @Before\n    @Throws(WCDBException::class)\n    override fun setup() {\n        super.setup()\n        val renewContent = RandomTool.string()\n        renewObject = TestObject.createObject(0, renewContent)\n        renewedObject1 = TestObject.createObject(1, renewContent)\n        renewedObject2 = TestObject.createObject(2, renewContent)\n    }\n\n    @Test\n    fun testDatabaseUpdateObject() {\n        doTestObjectsAfterOperation(\n            listOf(renewedObject1, renewedObject2),\n            \"UPDATE testTable SET content = ?1\"\n        ) { database.updateObject(renewObject, DBTestObject.content, tableName) }\n    }\n\n    @Test\n    fun testDatabaseUpdateObjectWhere() {\n        doTestObjectsAfterOperation(\n            listOf(renewedObject1, object2),\n            \"UPDATE testTable SET content = ?1 WHERE id == 1\"\n        ) {\n            database.updateObject(\n                renewObject,\n                DBTestObject.content,\n                tableName,\n                DBTestObject.id.eq(1)\n            )\n        }\n    }\n\n    @Test\n    fun testDatabaseUpdateObjectWhereOrderLimit() {\n        doTestObjectsAfterOperation(\n            listOf(object1, renewedObject2),\n            \"UPDATE testTable SET content = ?1 WHERE id > 0 ORDER BY id DESC LIMIT 1\"\n        ) {\n            database.updateObject(\n                renewObject,\n                DBTestObject.content,\n                tableName,\n                DBTestObject.id.gt(0),\n                DBTestObject.id.order(Order.Desc), 1\n            )\n        }\n    }\n\n    @Test\n    fun testDatabaseUpdateObjectWhereOrderLimitOffset() {\n        doTestObjectsAfterOperation(\n            listOf(renewedObject1, object2),\n            \"UPDATE testTable SET content = ?1 WHERE id > 0 ORDER BY id DESC LIMIT 1 OFFSET 1\"\n        ) {\n            database.updateObject(\n                renewObject,\n                DBTestObject.content,\n                tableName,\n                DBTestObject.id.gt(0),\n                DBTestObject.id.order(Order.Desc), 1, 1\n            )\n        }\n    }\n\n    @Test\n    fun testDatabaseUpdateObjectOrderLimit() {\n        doTestObjectsAfterOperation(\n            listOf(object1, renewedObject2),\n            \"UPDATE testTable SET content = ?1 ORDER BY id DESC LIMIT 1\"\n        ) {\n            database.updateObject(\n                renewObject,\n                DBTestObject.content,\n                tableName,\n                DBTestObject.id.order(Order.Desc), 1\n            )\n        }\n    }\n\n    @Test\n    fun testDatabaseUpdateObjectOrderLimitOffset() {\n        doTestObjectsAfterOperation(\n            listOf(renewedObject1, object2),\n            \"UPDATE testTable SET content = ?1 ORDER BY id DESC LIMIT 1 OFFSET 1\"\n        ) {\n            database.updateObject(\n                renewObject,\n                DBTestObject.content,\n                tableName,\n                DBTestObject.id.order(Order.Desc), 1, 1\n            )\n        }\n    }\n\n    @Test\n    fun testTableUpdateObject() {\n        doTestObjectsAfterOperation(\n            listOf(renewedObject1, renewedObject2),\n            \"UPDATE testTable SET content = ?1\"\n        ) { table.updateObject(renewObject, DBTestObject.content) }\n    }\n\n    @Test\n    fun testTableUpdateObjectWhere() {\n        doTestObjectsAfterOperation(\n            listOf(renewedObject1, object2),\n            \"UPDATE testTable SET content = ?1 WHERE id == 1\"\n        ) { table.updateObject(renewObject, DBTestObject.content, DBTestObject.id.eq(1)) }\n    }\n\n    @Test\n    fun testTableUpdateObjectWhereOrderLimit() {\n        doTestObjectsAfterOperation(\n            listOf(object1, renewedObject2),\n            \"UPDATE testTable SET content = ?1 WHERE id > 0 ORDER BY id DESC LIMIT 1\"\n        ) {\n            table.updateObject(\n                renewObject,\n                DBTestObject.content,\n                DBTestObject.id.gt(0),\n                DBTestObject.id.order(Order.Desc), 1\n            )\n        }\n    }\n\n    @Test\n    fun testTableUpdateObjectWhereOrderLimitOffset() {\n        doTestObjectsAfterOperation(\n            listOf(renewedObject1, object2),\n            \"UPDATE testTable SET content = ?1 WHERE id > 0 ORDER BY id DESC LIMIT 1 OFFSET 1\"\n        ) {\n            table.updateObject(\n                renewObject,\n                DBTestObject.content,\n                DBTestObject.id.gt(0),\n                DBTestObject.id.order(Order.Desc), 1, 1\n            )\n        }\n    }\n\n    @Test\n    fun testTableUpdateObjectOrderLimit() {\n        doTestObjectsAfterOperation(\n            listOf(object1, renewedObject2),\n            \"UPDATE testTable SET content = ?1 ORDER BY id DESC LIMIT 1\"\n        ) {\n            table.updateObject(\n                renewObject,\n                DBTestObject.content,\n                DBTestObject.id.order(Order.Desc), 1\n            )\n        }\n    }\n\n    @Test\n    fun testTableUpdateObjectOrderLimitOffset() {\n        doTestObjectsAfterOperation(\n            listOf(renewedObject1, object2),\n            \"UPDATE testTable SET content = ?1 ORDER BY id DESC LIMIT 1 OFFSET 1\"\n        ) {\n            table.updateObject(\n                renewObject,\n                DBTestObject.content,\n                DBTestObject.id.order(Order.Desc), 1, 1\n            )\n        }\n    }\n\n    @Test\n    fun testHandleUpdateObject() {\n        doTestObjectsAfterOperation(\n            listOf(renewedObject1, renewedObject2),\n            \"UPDATE testTable SET content = ?1\"\n        ) { handle.updateObject(renewObject, DBTestObject.content, tableName) }\n    }\n\n    @Test\n    fun testHandleUpdateObjectWhere() {\n        doTestObjectsAfterOperation(\n            listOf(renewedObject1, object2),\n            \"UPDATE testTable SET content = ?1 WHERE id == 1\"\n        ) {\n            handle.updateObject(\n                renewObject,\n                DBTestObject.content,\n                tableName,\n                DBTestObject.id.eq(1)\n            )\n        }\n    }\n\n    @Test\n    fun testHandleUpdateObjectWhereOrderLimit() {\n        doTestObjectsAfterOperation(\n            listOf(object1, renewedObject2),\n            \"UPDATE testTable SET content = ?1 WHERE id > 0 ORDER BY id DESC LIMIT 1\"\n        ) {\n            handle.updateObject(\n                renewObject,\n                DBTestObject.content,\n                tableName,\n                DBTestObject.id.gt(0),\n                DBTestObject.id.order(Order.Desc), 1\n            )\n        }\n    }\n\n    @Test\n    fun testHandleUpdateObjectWhereOrderLimitOffset() {\n        doTestObjectsAfterOperation(\n            listOf(renewedObject1, object2),\n            \"UPDATE testTable SET content = ?1 WHERE id > 0 ORDER BY id DESC LIMIT 1 OFFSET 1\"\n        ) {\n            handle.updateObject(\n                renewObject,\n                DBTestObject.content,\n                tableName,\n                DBTestObject.id.gt(0),\n                DBTestObject.id.order(Order.Desc), 1, 1\n            )\n        }\n    }\n\n    @Test\n    fun testHandleUpdateObjectOrderLimit() {\n        doTestObjectsAfterOperation(\n            listOf(object1, renewedObject2),\n            \"UPDATE testTable SET content = ?1 ORDER BY id DESC LIMIT 1\"\n        ) {\n            handle.updateObject(\n                renewObject,\n                DBTestObject.content,\n                tableName,\n                DBTestObject.id.order(Order.Desc), 1\n            )\n        }\n    }\n\n    @Test\n    fun testHandleUpdateObjectOrderLimitOffset() {\n        doTestObjectsAfterOperation(\n            listOf(renewedObject1, object2),\n            \"UPDATE testTable SET content = ?1 ORDER BY id DESC LIMIT 1 OFFSET 1\"\n        ) {\n            handle.updateObject(\n                renewObject,\n                DBTestObject.content,\n                tableName,\n                DBTestObject.id.order(Order.Desc), 1, 1\n            )\n        }\n    }\n}"
  },
  {
    "path": "src/java/kotlin-test/src/androidTest/java/com/tencent/wcdbtest/orm/ORMTest.kt",
    "content": "// Created by qiuwenchen on 2023/6/25.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdbtest.orm\n\nimport com.tencent.wcdb.base.Value\nimport com.tencent.wcdb.base.WCDBException\nimport com.tencent.wcdb.core.Database.ExceptionTracer\nimport com.tencent.wcdb.fts.BuiltinTokenizer\nimport com.tencent.wcdb.orm.Field\nimport com.tencent.wcdb.winq.ColumnDef\nimport com.tencent.wcdb.winq.ColumnType\nimport com.tencent.wcdb.winq.Order\nimport com.tencent.wcdb.winq.StatementCreateTable\nimport com.tencent.wcdbtest.base.DatabaseTestCase\nimport com.tencent.wcdbtest.base.TestOperation\nimport com.tencent.wcdbtest.base.WrappedValue\nimport com.tencent.wcdbtest.orm.testclass.*\nimport org.junit.Assert\nimport org.junit.Before\nimport org.junit.Test\nimport java.util.*\n\nclass ORMTest : DatabaseTestCase() {\n    private var tableName = \"testTable\"\n\n    @Before\n    @Throws(WCDBException::class)\n    override fun setup() {\n        super.setup()\n        expectMode = Expect.SomeSQLs\n    }\n\n    private fun doTestCreateTableAndIndexSQLsAsExpected(\n        sqls: Array<String>,\n        operation: TestOperation\n    ) {\n        Assert.assertNotNull(sqls)\n        Assert.assertNotNull(operation)\n        val newSqls: MutableList<String> = ArrayList()\n        newSqls.add(\"BEGIN IMMEDIATE\")\n        newSqls.addAll(listOf(*sqls))\n        newSqls.add(\"COMMIT\")\n        doTestSQLs(newSqls.toTypedArray(), operation)\n    }\n\n    @Test\n    fun testField() {\n        doTestCreateTableAndIndexSQLsAsExpected(arrayOf(\"CREATE TABLE IF NOT EXISTS testTable(field INTEGER, differentName INTEGER)\")) {\n            database.createTable(\n                tableName,\n                DBFieldObject\n            )\n        }\n        doTestCreateTableAndIndexSQLsAsExpected(arrayOf(\"CREATE TABLE IF NOT EXISTS newTable(field INTEGER, differentName INTEGER)\")) {\n            database.createTable(\n                \"newTable\",\n                DBFieldObject\n            )\n        }\n    }\n\n    @Test\n    fun testAllField() {\n        Assert.assertEquals(DBFieldObject.allFields().size.toLong(), 2)\n        Assert.assertEquals(DBFieldObject.allFields()[0].description, \"field\")\n        Assert.assertEquals(DBFieldObject.allFields()[1].description, \"differentName\")\n    }\n\n    @Test\n    @Throws(WCDBException::class)\n    fun testAllType() {\n        doTestCreateTableAndIndexSQLsAsExpected(\n            arrayOf(\n                \"CREATE TABLE IF NOT EXISTS testTable(type TEXT, \" +\n                        \"aBoolean INTEGER, aBoolean2 INTEGER, \" +\n                        \"aByte INTEGER, aByte2 INTEGER, \" +\n                        \"aShort INTEGER, aShort2 INTEGER, \" +\n                        \"anInt INTEGER, integer INTEGER, \" +\n                        \"aLong INTEGER, aLong2 INTEGER, \" +\n                        \"aFloat REAL, aFloat2 REAL, \" +\n                        \"aDouble REAL, aDouble2 REAL, \" +\n                        \"string TEXT, bytes BLOB, bytes2 BLOB)\"\n            )\n        ) { database.createTable(tableName, DBAllTypeObject) }\n        val table = database.getTable(tableName, DBAllTypeObject)\n        val max = AllTypeObject.maxObject()\n        val min = AllTypeObject.minObject()\n        val random = AllTypeObject.randomObject()\n        val empty = AllTypeObject.emptyObject()\n        table.insertObjects(listOf(max, min, random, empty))\n        Assert.assertTrue(\n            max == table.getFirstObject(\n                DBAllTypeObject.allFields(),\n                DBAllTypeObject.type.eq(max.type)\n            )\n        )\n        Assert.assertTrue(\n            min == table.getFirstObject(\n                DBAllTypeObject.allFields(),\n                DBAllTypeObject.type.eq(min.type)\n            )\n        )\n        Assert.assertTrue(\n            empty == table.getFirstObject(\n                DBAllTypeObject.allFields(),\n                DBAllTypeObject.type.eq(empty.type)\n            )\n        )\n        Assert.assertTrue(\n            random == table.getFirstObject(\n                DBAllTypeObject.allFields(),\n                DBAllTypeObject.type.eq(random.type)\n            )\n        )\n        table.insertRow(arrayOf(Value(\"null\")), arrayOf(DBAllTypeObject.type))\n        Assert.assertTrue(\n            empty == table.getFirstObject(\n                DBAllTypeObject.allFields(),\n                DBAllTypeObject.type.eq(\"null\")\n            )\n        )\n    }\n\n    @Test\n    fun testColumnConstraint() {\n        doTestCreateTableAndIndexSQLsAsExpected(\n            arrayOf(\n                \"CREATE TABLE IF NOT EXISTS testTable(value INTEGER PRIMARY KEY)\"\n            )\n        ) {\n            database.createTable(tableName, DBColumnConstraintPrimaryObject)\n            database.dropTable(\"testTable\")\n        }\n        doTestCreateTableAndIndexSQLsAsExpected(\n            arrayOf(\n                \"CREATE TABLE IF NOT EXISTS testTable(value INTEGER PRIMARY KEY AUTOINCREMENT)\"\n            )\n        ) {\n            database.createTable(tableName, DBColumnConstraintAutoIncrementObject)\n            database.dropTable(\"testTable\")\n        }\n        doTestCreateTableAndIndexSQLsAsExpected(\n            arrayOf(\n                \"CREATE TABLE IF NOT EXISTS testTable(value INTEGER UNIQUE)\"\n            )\n        ) {\n            database.createTable(tableName, DBColumnConstraintUniqueObject)\n            database.dropTable(\"testTable\")\n        }\n        doTestCreateTableAndIndexSQLsAsExpected(\n            arrayOf(\n                \"CREATE TABLE IF NOT EXISTS testTable(intValue INTEGER DEFAULT 1, floatValue REAL DEFAULT 1.1000000000000001, stringValue TEXT DEFAULT 'abc')\"\n            )\n        ) {\n            database.createTable(tableName, DBColumnConstraintDefaultObject)\n            database.dropTable(\"testTable\")\n        }\n        doTestCreateTableAndIndexSQLsAsExpected(\n            arrayOf(\n                \"CREATE TABLE IF NOT EXISTS testTable(intValue INTEGER DEFAULT 0, floatValue REAL DEFAULT 0, stringValue TEXT DEFAULT '')\"\n            )\n        ) {\n            database.createTable(tableName, DBColumnConstraintDefaultZeroObject)\n            database.dropTable(\"testTable\")\n        }\n        doTestCreateTableAndIndexSQLsAsExpected(\n            arrayOf(\n                \"CREATE TABLE IF NOT EXISTS testTable(text TEXT NOT NULL)\"\n            )\n        ) {\n            database.createTable(tableName, DBColumnConstraintNotNullObject)\n            database.dropTable(\"testTable\")\n        }\n    }\n\n    @Test\n    fun testTableConstraint() {\n        doTestCreateTableAndIndexSQLsAsExpected(\n            arrayOf(\n                \"CREATE TABLE IF NOT EXISTS testTable(multiPrimary1 INTEGER, multiPrimary2 INTEGER, multiPrimary3 INTEGER, \" +\n                        \"multiUnique1 INTEGER, multiUnique2 INTEGER, multiUnique3 INTEGER, \" +\n                        \"multiIndex1 INTEGER, multiIndex2 INTEGER, multiIndex3 INTEGER, \" +\n                        \"PRIMARY KEY(multiPrimary1, multiPrimary2, multiPrimary3), \" +\n                        \"UNIQUE(multiUnique1, multiUnique2, multiUnique3))\",\n                \"CREATE INDEX IF NOT EXISTS specifiedNameIndex ON testTable(multiIndex1, multiIndex2, multiIndex3)\",\n                \"CREATE INDEX IF NOT EXISTS testTable_multiIndex1_multiIndex2_index ON testTable(multiIndex1, multiIndex2)\"\n            )\n        ) { database.createTable(tableName, DBTableConstraintObject) }\n    }\n\n    @Test\n    fun testRemap() {\n        doTestCreateTableAndIndexSQLsAsExpected(\n            arrayOf(\n                \"CREATE TABLE IF NOT EXISTS testTable(value INTEGER)\"\n            )\n        ) { database.createTable(\"testTable\", DBOldRemapObject) }\n        doTestCreateTableAndIndexSQLsAsExpected(\n            arrayOf(\n                \"PRAGMA main.table_info('testTable')\",\n                \"ALTER TABLE main.testTable ADD COLUMN newValue INTEGER\",\n                \"CREATE INDEX IF NOT EXISTS testTable_value_index ON testTable(value)\"\n            )\n        ) { database.createTable(\"testTable\", DBNewRemapObject) }\n    }\n\n    @Test\n    fun testIndex() {\n        doTestCreateTableAndIndexSQLsAsExpected(\n            arrayOf(\n                \"CREATE TABLE IF NOT EXISTS testTable(index_ INTEGER, uniqueIndex INTEGER)\",\n                \"CREATE INDEX IF NOT EXISTS testTable_index__index ON testTable(index_)\",\n                \"CREATE UNIQUE INDEX IF NOT EXISTS specifiedNameIndex ON testTable(uniqueIndex)\"\n            )\n        ) { database.createTable(tableName, DBIndexObject) }\n    }\n\n    @Test\n    fun testIndex2() {\n        doTestCreateTableAndIndexSQLsAsExpected(\n            arrayOf(\n                \"CREATE TABLE IF NOT EXISTS testTable(index_ INTEGER, uniqueIndex INTEGER)\",\n                \"CREATE INDEX IF NOT EXISTS testTable_index__index ON testTable(index_)\",\n                \"CREATE UNIQUE INDEX IF NOT EXISTS specifiedNameIndex ON testTable(uniqueIndex)\"\n            )\n        ) { database.createTable(tableName, DBDataIndexObject) }\n    }\n\n    @Test\n    @Throws(WCDBException::class)\n    fun testFTS3() {\n        doTestSQLs(\n            arrayOf(\n                \"CREATE VIRTUAL TABLE IF NOT EXISTS testTable USING fts3(tokenize = wcdb_one_or_binary skip_stemming, id INTEGER, content TEXT, notindexed=id)\"\n            )\n        ) {\n            database.addTokenizer(BuiltinTokenizer.OneOrBinary)\n            database.createVirtualTable(tableName, DBFTS3TestObject)\n        }\n    }\n\n    @Test\n    @Throws(WCDBException::class)\n    fun testFTS5() {\n        doTestSQLs(\n            arrayOf(\n                \"CREATE VIRTUAL TABLE IF NOT EXISTS testTable USING fts5(tokenize = 'wcdb_verbatim skip_stemming chinese_traditional_to_simplified', content='contentTable', id UNINDEXED, content)\"\n            )\n        ) {\n            database.addTokenizer(BuiltinTokenizer.Verbatim)\n            database.createVirtualTable(tableName, DBFTS5TestObject)\n        }\n    }\n\n    @Test\n    @Throws(WCDBException::class)\n    fun testAutoAddColumn() {\n        val fakeTable = \"fakeTable\"\n        val fakeSchema = \"notExistSchema\"\n        database.createTable(fakeTable, DBAutoAddColumnObject)\n        doTestAutoAddColumn(DBAutoAddColumnObject.insertValue, true) {\n            database.insertObject(\n                AutoAddColumnObject(), DBAutoAddColumnObject.allFields(), tableName\n            )\n        }\n        doTestAutoAddColumn(DBAutoAddColumnObject.updateValue, true) {\n            database.updateValue(\n                1,\n                DBAutoAddColumnObject.updateValue,\n                tableName\n            )\n        }\n        doTestAutoAddColumn(DBAutoAddColumnObject.deleteValue, true) {\n            database.deleteObjects(\n                tableName,\n                DBAutoAddColumnObject.deleteValue.eq(1)\n            )\n        }\n        doTestAutoAddColumn(DBAutoAddColumnObject.deleteValue, true) {\n            database.deleteObjects(\n                tableName,\n                DBAutoAddColumnObject.deleteValue.table(tableName).eq(1)\n            )\n        }\n        doTestAutoAddColumn(DBAutoAddColumnObject.deleteValue, false) {\n            database.deleteObjects(\n                tableName,\n                DBAutoAddColumnObject.deleteValue.table(fakeTable).eq(1)\n            )\n        }\n        doTestAutoAddColumn(DBAutoAddColumnObject.deleteValue, false) {\n            database.deleteObjects(\n                tableName,\n                DBAutoAddColumnObject.deleteValue.table(tableName).of(fakeSchema).eq(1)\n            )\n        }\n        doTestAutoAddColumn(DBAutoAddColumnObject.selectValue, true) {\n            database.getOneColumn(\n                DBAutoAddColumnObject.selectValue,\n                tableName\n            )\n        }\n        doTestAutoAddColumn(DBAutoAddColumnObject.selectValue, true) {\n            database.getOneColumn(\n                DBAutoAddColumnObject.insertValue,\n                tableName,\n                DBAutoAddColumnObject.selectValue.eq(1)\n            )\n        }\n        doTestAutoAddColumn(DBAutoAddColumnObject.selectValue, true) {\n            database.getOneColumn(\n                DBAutoAddColumnObject.insertValue,\n                tableName,\n                DBAutoAddColumnObject.selectValue.order(Order.Asc)\n            )\n        }\n        doTestAutoAddColumn(DBAutoAddColumnObject.selectValue, true) {\n            database.getOneColumn(\n                DBAutoAddColumnObject.insertValue,\n                tableName,\n                DBAutoAddColumnObject.selectValue.table(tableName).order(Order.Asc)\n            )\n        }\n        doTestAutoAddColumn(DBAutoAddColumnObject.selectValue, false) {\n            database.getOneColumn(\n                DBAutoAddColumnObject.insertValue,\n                tableName,\n                DBAutoAddColumnObject.selectValue.table(fakeTable).order(Order.Asc)\n            )\n        }\n        doTestAutoAddColumn(DBAutoAddColumnObject.selectValue, false) {\n            database.getOneColumn(\n                DBAutoAddColumnObject.insertValue,\n                tableName,\n                DBAutoAddColumnObject.selectValue.table(tableName).of(fakeSchema).order(Order.Asc)\n            )\n        }\n        doTestAutoAddColumn(DBAutoAddColumnObject.primaryValue, false) {\n            database.getOneColumn(\n                DBAutoAddColumnObject.primaryValue,\n                tableName\n            )\n        }\n        doTestAutoAddColumn(DBAutoAddColumnObject.uniqueValue, false) {\n            database.getOneColumn(\n                DBAutoAddColumnObject.uniqueValue,\n                tableName\n            )\n        }\n    }\n\n    @Throws(WCDBException::class)\n    fun doTestAutoAddColumn(\n        removeField: Field<AutoAddColumnObject>,\n        succeed: Boolean,\n        operation: TestOperation\n    ) {\n        val columnName = removeField.name\n        val createTable = StatementCreateTable().createTable(tableName)\n        val columnDefs: MutableList<ColumnDef> = ArrayList()\n        for (field in DBAutoAddColumnObject.allFields()) {\n            if (field.description != columnName) {\n                columnDefs.add(ColumnDef(field, ColumnType.Integer))\n            }\n        }\n        createTable.define(*columnDefs.toTypedArray())\n        database.execute(createTable)\n        val added = WrappedValue()\n        database.traceException(ExceptionTracer { exception ->\n            if (exception.message() != \"Auto add column\") {\n                return@ExceptionTracer\n            }\n            added.boolValue = true\n            Assert.assertEquals(exception.info[\"Table\"] as String?, tableName)\n            Assert.assertEquals(exception.info[\"Column\"] as String?, columnName)\n        })\n        var hasError = false\n        try {\n            operation()\n        } catch (e: WCDBException) {\n            hasError = true\n        }\n        Assert.assertEquals(succeed, !hasError)\n        Assert.assertEquals(succeed, added.boolValue)\n        database.dropTable(tableName)\n        database.traceException(null)\n    }\n\n    @Test\n    @Throws(WCDBException::class)\n    fun testPrimaryEnableAutoIncrementForExistingTable() {\n        database.createTable(tableName, DBPrimaryNotAutoIncrementObject)\n        val obj1 = PrimaryNotAutoIncrementObject()\n        obj1.id = 1\n        database.insertObject(obj1, DBPrimaryNotAutoIncrementObject.allFields(), tableName)\n\n        database.createTable(tableName, DBPrimaryEnableAutoIncrementObject)\n        database.deleteObjects(tableName)\n\n        val obj2 = PrimaryEnableAutoIncrementObject()\n        database.insertObject(obj2, DBPrimaryEnableAutoIncrementObject.allFields(), tableName)\n        Assert.assertEquals(obj2.id, 2)\n    }\n}"
  },
  {
    "path": "src/java/kotlin-test/src/androidTest/java/com/tencent/wcdbtest/orm/testclass/AllTypeObject.kt",
    "content": "// Created by qiuwenchen on 2023/6/25.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdbtest.orm.testclass\n\nimport com.tencent.wcdb.WCDBField\nimport com.tencent.wcdb.WCDBTableCoding\nimport com.tencent.wcdbtest.base.RandomTool\nimport java.util.*\n\n@WCDBTableCoding\nclass AllTypeObject {\n    @WCDBField\n    var type: String = \"\"\n\n    //Integer\n    @WCDBField\n    var aBoolean = false\n\n    @WCDBField\n    var aBoolean2: Boolean? = null\n\n    @WCDBField\n    var aByte: Byte = 0\n\n    @WCDBField\n    var aByte2: Byte? = null\n\n    @WCDBField\n    var aShort: Short = 0\n\n    @WCDBField\n    var aShort2: Short? = null\n\n    @WCDBField\n    var anInt = 0\n\n    @WCDBField\n    var integer: Int? = null\n\n    @WCDBField\n    var aLong: Long = 0\n\n    @WCDBField\n    var aLong2: Long? = null\n\n    // Float\n    @WCDBField\n    var aFloat = 0f\n\n    @WCDBField\n    var aFloat2: Float? = null\n\n    @WCDBField\n    var aDouble = 0.0\n\n    @WCDBField\n    var aDouble2: Double? = null\n\n    // String\n    @WCDBField\n    var string: String? = null\n\n    // BLOB\n    @WCDBField\n    var bytes: ByteArray = byteArrayOf()\n\n    @WCDBField\n    var bytes2: ByteArray? = null\n\n    override fun equals(other: Any?): Boolean {\n        if (this === other) return true\n        if (javaClass != other?.javaClass) return false\n\n        other as AllTypeObject\n\n        if (aBoolean != other.aBoolean) return false\n        if (aBoolean2 != other.aBoolean2) return false\n        if (aByte != other.aByte) return false\n        if (aByte2 != other.aByte2) return false\n        if (aShort != other.aShort) return false\n        if (aShort2 != other.aShort2) return false\n        if (anInt != other.anInt) return false\n        if (integer != other.integer) return false\n        if (aLong != other.aLong) return false\n        if (aLong2 != other.aLong2) return false\n        if (aFloat != other.aFloat) return false\n        if (aFloat2 != other.aFloat2) return false\n        if (aDouble != other.aDouble) return false\n        if (aDouble2 != other.aDouble2) return false\n        if (string != other.string) return false\n        if (!bytes.contentEquals(other.bytes)) return false\n        if (bytes2 != null) {\n            if (other.bytes2 == null) return false\n            if (!bytes2.contentEquals(other.bytes2)) return false\n        } else if (other.bytes2 != null) return false\n\n        return true\n    }\n\n\n    companion object {\n        fun maxObject(): AllTypeObject {\n            val max = AllTypeObject()\n            max.type = \"max\"\n            max.aBoolean = true\n            max.aBoolean2 = true\n            max.aByte = Byte.MAX_VALUE\n            max.aByte2 = Byte.MAX_VALUE\n            max.aShort = Short.MAX_VALUE\n            max.aShort2 = Short.MAX_VALUE\n            max.anInt = Int.MAX_VALUE\n            max.integer = Int.MAX_VALUE\n            max.aLong = Long.MAX_VALUE\n            max.aLong2 = Long.MAX_VALUE\n            max.aFloat = Float.MAX_VALUE\n            max.aFloat2 = Float.MAX_VALUE\n            max.aDouble = Double.MAX_VALUE\n            max.aDouble2 = Double.MAX_VALUE\n            max.string = RandomTool.string()\n            max.bytes = RandomTool.bytes()\n            max.bytes2 = RandomTool.bytes()\n            return max\n        }\n\n        fun minObject(): AllTypeObject {\n            val min = AllTypeObject()\n            min.type = \"min\"\n            min.aBoolean = false\n            min.aBoolean2 = false\n            min.aByte = Byte.MIN_VALUE\n            min.aByte2 = Byte.MIN_VALUE\n            min.aShort = Short.MIN_VALUE\n            min.aShort2 = Short.MIN_VALUE\n            min.anInt = Int.MIN_VALUE\n            min.integer = Int.MIN_VALUE\n            min.aLong = Long.MIN_VALUE\n            min.aLong2 = Long.MIN_VALUE\n            min.aFloat = Float.MIN_VALUE\n            min.aFloat2 = Float.MIN_VALUE\n            min.aDouble = Double.MIN_VALUE\n            min.aDouble2 = Double.MIN_VALUE\n            min.string = RandomTool.string()\n            min.bytes = RandomTool.bytes()\n            min.bytes2 = RandomTool.bytes()\n            return min\n        }\n\n        fun randomObject(): AllTypeObject {\n            val random = Random()\n            val `object` = AllTypeObject()\n            `object`.type = \"random\"\n            `object`.aBoolean = random.nextBoolean()\n            `object`.aBoolean2 = random.nextBoolean()\n            `object`.aByte = random.nextInt().toByte()\n            `object`.aByte2 = random.nextInt().toByte()\n            `object`.aShort = random.nextInt().toShort()\n            `object`.aShort2 = random.nextInt().toShort()\n            `object`.anInt = random.nextInt()\n            `object`.integer = random.nextInt()\n            `object`.aLong = random.nextLong()\n            `object`.aLong2 = random.nextLong()\n            `object`.aFloat = random.nextFloat()\n            `object`.aFloat2 = random.nextFloat()\n            `object`.aDouble = random.nextDouble()\n            `object`.aDouble2 = random.nextDouble()\n            `object`.string = RandomTool.string()\n            `object`.bytes = RandomTool.bytes()\n            `object`.bytes2 = RandomTool.bytes()\n            return `object`\n        }\n\n        fun emptyObject(): AllTypeObject {\n            val empty = AllTypeObject()\n            empty.type = \"empty\"\n            empty.bytes = byteArrayOf()\n            return empty\n        }\n    }\n}"
  },
  {
    "path": "src/java/kotlin-test/src/androidTest/java/com/tencent/wcdbtest/orm/testclass/AutoAddColumnObject.kt",
    "content": "// Created by qiuwenchen on 2023/6/25.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdbtest.orm.testclass\n\nimport com.tencent.wcdb.WCDBField\nimport com.tencent.wcdb.WCDBTableCoding\n\n@WCDBTableCoding\nclass AutoAddColumnObject {\n    @WCDBField(isPrimary = true)\n    var primaryValue = 0\n\n    @WCDBField(isUnique = true)\n    var uniqueValue = 0\n\n    @WCDBField\n    var insertValue = 0\n\n    @WCDBField\n    var updateValue = 0\n\n    @WCDBField\n    var selectValue = 0\n\n    @WCDBField\n    var multiSelectValue = 0\n\n    @WCDBField\n    var deleteValue = 0\n\n    @WCDBField\n    var indexValue = 0\n}"
  },
  {
    "path": "src/java/kotlin-test/src/androidTest/java/com/tencent/wcdbtest/orm/testclass/ColumnConstraintAutoIncrementObject.kt",
    "content": "// Created by qiuwenchen on 2023/6/25.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdbtest.orm.testclass\n\nimport com.tencent.wcdb.WCDBField\nimport com.tencent.wcdb.WCDBTableCoding\n\n@WCDBTableCoding\nclass ColumnConstraintAutoIncrementObject {\n    @WCDBField(isPrimary = true, isAutoIncrement = true)\n    var value = 0\n}"
  },
  {
    "path": "src/java/kotlin-test/src/androidTest/java/com/tencent/wcdbtest/orm/testclass/ColumnConstraintDefaultObject.kt",
    "content": "// Created by qiuwenchen on 2023/6/25.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdbtest.orm.testclass\n\nimport com.tencent.wcdb.WCDBDefault\nimport com.tencent.wcdb.WCDBField\nimport com.tencent.wcdb.WCDBTableCoding\n\n@WCDBTableCoding\nclass ColumnConstraintDefaultObject {\n    @WCDBField\n    @WCDBDefault(intValue = 1)\n    var intValue = 0\n\n    @WCDBField\n    @WCDBDefault(doubleValue = 1.1)\n    var floatValue = 0f\n\n    @WCDBField\n    @WCDBDefault(textValue = \"abc\")\n    var stringValue: String? = null\n}"
  },
  {
    "path": "src/java/kotlin-test/src/androidTest/java/com/tencent/wcdbtest/orm/testclass/ColumnConstraintDefaultZeroObject.kt",
    "content": "// Created by chenqiuwen on 2023/7/26.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdbtest.orm.testclass\n\nimport com.tencent.wcdb.WCDBDefault\nimport com.tencent.wcdb.WCDBField\nimport com.tencent.wcdb.WCDBTableCoding\n\n@WCDBTableCoding\nclass ColumnConstraintDefaultZeroObject {\n    @WCDBField\n    @WCDBDefault(intValue = 0)\n    var intValue = 0\n\n    @WCDBField\n    @WCDBDefault(doubleValue = 0.0)\n    var floatValue = 0f\n\n    @WCDBField\n    @WCDBDefault(textValue = \"\")\n    var stringValue: String? = null\n}"
  },
  {
    "path": "src/java/kotlin-test/src/androidTest/java/com/tencent/wcdbtest/orm/testclass/ColumnConstraintNotNullObject.kt",
    "content": "// Created by qiuwenchen on 2023/6/25.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdbtest.orm.testclass\n\nimport com.tencent.wcdb.WCDBField\nimport com.tencent.wcdb.WCDBTableCoding\n\n@WCDBTableCoding\nclass ColumnConstraintNotNullObject {\n    @WCDBField(isNotNull = true)\n    var text: String? = null\n}"
  },
  {
    "path": "src/java/kotlin-test/src/androidTest/java/com/tencent/wcdbtest/orm/testclass/ColumnConstraintPrimaryObject.kt",
    "content": "// Created by qiuwenchen on 2023/6/25.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdbtest.orm.testclass\n\nimport com.tencent.wcdb.WCDBField\nimport com.tencent.wcdb.WCDBTableCoding\n\n@WCDBTableCoding\nclass ColumnConstraintPrimaryObject {\n    @WCDBField(isPrimary = true)\n    var value = 0\n}"
  },
  {
    "path": "src/java/kotlin-test/src/androidTest/java/com/tencent/wcdbtest/orm/testclass/ColumnConstraintUniqueObject.kt",
    "content": "// Created by qiuwenchen on 2023/6/25.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdbtest.orm.testclass\n\nimport com.tencent.wcdb.WCDBField\nimport com.tencent.wcdb.WCDBTableCoding\n\n@WCDBTableCoding\nclass ColumnConstraintUniqueObject {\n    @WCDBField(isUnique = true)\n    var value = 0\n}"
  },
  {
    "path": "src/java/kotlin-test/src/androidTest/java/com/tencent/wcdbtest/orm/testclass/DataIndexObject.kt",
    "content": "// Created by qiuwenchen on 2023/6/25.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdbtest.orm.testclass\n\nimport com.tencent.wcdb.WCDBField\nimport com.tencent.wcdb.WCDBIndex\nimport com.tencent.wcdb.WCDBTableCoding\nimport java.util.jar.Attributes.Name\n\n@WCDBTableCoding\ndata class DataIndexObject(\n    @WCDBField\n    @WCDBIndex\n    var index_: Int = 0,\n\n    @WCDBField\n    @WCDBIndex(name = \"specifiedNameIndex\", isUnique = true)\n    var uniqueIndex: Int = 0\n) {\n}"
  },
  {
    "path": "src/java/kotlin-test/src/androidTest/java/com/tencent/wcdbtest/orm/testclass/FTS3TestObject.kt",
    "content": "// Created by chenqiuwen on 2023/11/4.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdbtest.orm.testclass\n\nimport com.tencent.wcdb.FTSModule\nimport com.tencent.wcdb.FTSVersion\nimport com.tencent.wcdb.WCDBField\nimport com.tencent.wcdb.WCDBTableCoding\nimport com.tencent.wcdb.fts.BuiltinTokenizer\n\n@WCDBTableCoding(\n    ftsModule = FTSModule(\n        version = FTSVersion.FTS3,\n        tokenizer = BuiltinTokenizer.OneOrBinary,\n        tokenizerParameters = [BuiltinTokenizer.Parameter.SkipStemming]\n    )\n)\nclass FTS3TestObject {\n    @WCDBField(isNotIndexed = true)\n    var id: Int = 0\n\n    @WCDBField\n    var content: String = \"\"\n}"
  },
  {
    "path": "src/java/kotlin-test/src/androidTest/java/com/tencent/wcdbtest/orm/testclass/FTS5TestObject.kt",
    "content": "// Created by chenqiuwen on 2023/11/4.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage com.tencent.wcdbtest.orm.testclass\n\nimport com.tencent.wcdb.FTSModule\nimport com.tencent.wcdb.FTSVersion\nimport com.tencent.wcdb.WCDBField\nimport com.tencent.wcdb.WCDBTableCoding\nimport com.tencent.wcdb.fts.BuiltinTokenizer\n\n@WCDBTableCoding(\n    ftsModule = FTSModule(\n        version = FTSVersion.FTS5,\n        tokenizer = BuiltinTokenizer.Verbatim,\n        tokenizerParameters = [BuiltinTokenizer.Parameter.SkipStemming, BuiltinTokenizer.Parameter.SimplifyChinese],\n        externalTable = \"contentTable\"\n    )\n)\nclass FTS5TestObject {\n    @WCDBField(isNotIndexed = true)\n    var id: Int = 0\n\n    @WCDBField\n    var content: String = \"\"\n}"
  },
  {
    "path": "src/java/kotlin-test/src/androidTest/java/com/tencent/wcdbtest/orm/testclass/FieldObject.kt",
    "content": "// Created by qiuwenchen on 2023/6/25.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdbtest.orm.testclass\n\nimport com.tencent.wcdb.WCDBField\nimport com.tencent.wcdb.WCDBTableCoding\n\n@WCDBTableCoding\nclass FieldObject {\n    @WCDBField\n    var field = 0\n\n    @WCDBField(columnName = \"differentName\")\n    var fieldWithDifferentName = 0\n}"
  },
  {
    "path": "src/java/kotlin-test/src/androidTest/java/com/tencent/wcdbtest/orm/testclass/IndexObject.kt",
    "content": "// Created by qiuwenchen on 2023/6/25.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage com.tencent.wcdbtest.orm.testclass\n\nimport com.tencent.wcdb.WCDBField\nimport com.tencent.wcdb.WCDBIndex\nimport com.tencent.wcdb.WCDBTableCoding\n\n@WCDBTableCoding\nclass IndexObject {\n    @WCDBField\n    @WCDBIndex\n    var index_: Int = 0\n\n    @WCDBField\n    @WCDBIndex(name = \"specifiedNameIndex\", isUnique = true)\n    var uniqueIndex: Int = 0\n}"
  },
  {
    "path": "src/java/kotlin-test/src/androidTest/java/com/tencent/wcdbtest/orm/testclass/NewRemapObject.kt",
    "content": "// Created by qiuwenchen on 2023/6/25.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdbtest.orm.testclass\n\nimport com.tencent.wcdb.WCDBField\nimport com.tencent.wcdb.WCDBIndex\nimport com.tencent.wcdb.WCDBTableCoding\n\n@WCDBTableCoding\nclass NewRemapObject {\n    @WCDBField(columnName = \"value\")\n    @WCDBIndex\n    var renamedValue = 0\n\n    @WCDBField\n    var newValue = 0\n}"
  },
  {
    "path": "src/java/kotlin-test/src/androidTest/java/com/tencent/wcdbtest/orm/testclass/OldRemapObject.kt",
    "content": "// Created by qiuwenchen on 2023/6/25.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdbtest.orm.testclass\n\nimport com.tencent.wcdb.WCDBField\nimport com.tencent.wcdb.WCDBTableCoding\n\n@WCDBTableCoding\nclass OldRemapObject {\n    @WCDBField\n    var value = 0\n}"
  },
  {
    "path": "src/java/kotlin-test/src/androidTest/java/com/tencent/wcdbtest/orm/testclass/PrimaryEnableAutoIncrementObject.kt",
    "content": "// Created by qiuwenchen on 2023/7/7.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdbtest.orm.testclass\n\nimport com.tencent.wcdb.WCDBField\nimport com.tencent.wcdb.WCDBTableCoding\n\n@WCDBTableCoding\nclass PrimaryEnableAutoIncrementObject {\n    @WCDBField(isPrimary = true, isAutoIncrement = true, enableAutoIncrementForExistingTable = true)\n    var id: Int = 0\n}"
  },
  {
    "path": "src/java/kotlin-test/src/androidTest/java/com/tencent/wcdbtest/orm/testclass/PrimaryNotAutoIncrementObject.kt",
    "content": "// Created by qiuwenchen on 2023/7/7.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage com.tencent.wcdbtest.orm.testclass\n\nimport com.tencent.wcdb.WCDBField\nimport com.tencent.wcdb.WCDBTableCoding\n\n@WCDBTableCoding\nclass PrimaryNotAutoIncrementObject {\n    @WCDBField(isPrimary = true, isAutoIncrement = true, enableAutoIncrementForExistingTable = true)\n    var id: Int = 0\n}"
  },
  {
    "path": "src/java/kotlin-test/src/androidTest/java/com/tencent/wcdbtest/orm/testclass/TableConstraintObject.kt",
    "content": "// Created by qiuwenchen on 2023/6/25.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdbtest.orm.testclass\n\nimport com.tencent.wcdb.*\n\n@WCDBTableCoding(\n    multiPrimaries = [MultiPrimary(columns = [\"multiPrimary1\", \"multiPrimary2\", \"multiPrimary3\"])],\n    multiUnique = [MultiUnique(columns = [\"multiUnique1\", \"multiUnique2\", \"multiUnique3\"])],\n    multiIndexes = [\n        MultiIndexes(\n            name = \"specifiedNameIndex\",\n            columns = [\"multiIndex1\", \"multiIndex2\", \"multiIndex3\"]\n        ),\n        MultiIndexes(columns = [\"multiIndex1\", \"multiIndex2\"])\n    ]\n)\nclass TableConstraintObject {\n    @WCDBField\n    var multiPrimary1 = 0\n\n    @WCDBField\n    var multiPrimary2 = 0\n\n    @WCDBField(columnName = \"multiPrimary3\")\n    var multiPrimary = 0\n\n    @WCDBField\n    var multiUnique1 = 0\n\n    @WCDBField\n    var multiUnique2 = 0\n\n    @WCDBField(columnName = \"multiUnique3\")\n    var multiUnique = 0\n\n    @WCDBField\n    var multiIndex1 = 0\n\n    @WCDBField\n    var multiIndex2 = 0\n\n    @WCDBField(columnName = \"multiIndex3\")\n    var multiIndex = 0\n}"
  },
  {
    "path": "src/java/kotlin-test/src/main/AndroidManifest.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<manifest xmlns:android=\"http://schemas.android.com/apk/res/android\">\n\n    <application\n        android:allowBackup=\"true\"\n        android:label=\"ProguardTest\"\n        android:supportsRtl=\"true\">\n        <activity\n            android:name=\".MainActivity\"\n            android:exported=\"true\">\n            <intent-filter>\n                <action android:name=\"android.intent.action.MAIN\" />\n                <category android:name=\"android.intent.category.LAUNCHER\" />\n            </intent-filter>\n        </activity>\n    </application>\n\n</manifest>"
  },
  {
    "path": "src/java/kotlin-test/src/main/java/com/tencent/wcdbtest/MainActivity.kt",
    "content": "// Created by qiuwenchen on 2024/4/27.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage com.tencent.wcdbtest\n\nimport android.os.Bundle\nimport android.os.Process\nimport androidx.activity.ComponentActivity\nimport com.tencent.wcdb.base.WCDBException\nimport com.tencent.wcdb.core.Database\nimport com.tencent.wcdb.core.Database.SQLTracer\nimport com.tencent.wcdb.core.Table\nimport com.tencent.wcdb.winq.Pragma\nimport com.tencent.wcdb.winq.StatementPragma\nimport com.tencent.wcdb.winq.StatementSelect\nimport java.io.File\nimport java.lang.Thread.sleep\nimport kotlin.concurrent.thread\n\nclass MainActivity : ComponentActivity() {\n    private var database: Database? = null\n    private var tableName = \"testTable\"\n    private var table: Table<TestObject>? = null\n    override fun onCreate(savedInstanceState: Bundle?) {\n        super.onCreate(savedInstanceState)\n        database = Database(cacheDir.path + File.separator + \"temp.db\")\n        table = database?.getTable(tableName, DBTestObject)\n        thread(start = true) {\n            println(\"start test proguard\")\n            execute { testBusyRetry() }\n            execute { testReadOnly() }\n            execute { testConfigFail() }\n            execute { testGlobalTraceError() }\n            execute { testGlobalTraceSQL() }\n            execute { testZSTDNormalCompress() }\n            println(\"all proguard tests are finished!\")\n        }\n    }\n\n    private fun execute(test: () -> Unit) {\n        database?.removeFiles()\n        database?.createTable(tableName, DBTestObject)\n        test()\n    }\n\n    private fun testBusyRetry() {\n        val testTid = WrappedValue()\n        Database.globalTraceBusy({ tag, path, tid, sql ->\n            require(tag == database?.tag)\n            require(path == database?.path)\n            require(sql == \"INSERT INTO testTable(id, content) VALUES(?1, ?2)\")\n            testTid.intValue = tid\n        }, 0.1)\n        val objects = RandomTool.autoIncrementTestCaseObjects(100000)\n        val dispatchTid = WrappedValue()\n        val thread = Thread {\n            dispatchTid.intValue = Process.myTid().toLong()\n            database?.insertObjects(objects, DBTestObject.allFields(), tableName)\n        }\n        thread.start()\n        sleep(100)\n        database?.insertObject(\n            RandomTool.testObjectWithId(100001),\n            DBTestObject.allFields(),\n            tableName\n        )\n        thread.join()\n        require(testTid.intValue != 0L && testTid.intValue == dispatchTid.intValue)\n        Database.globalTraceBusy(null, 0.0)\n    }\n\n    private fun testZSTDNormalCompress() {\n        val preInsertObject = RandomTool.autoIncrementTestCaseObjects(2)\n        table?.insertObjects(preInsertObject)\n        database?.setCompression { info -> info.addZSTDNormalCompress(DBTestObject.content) }\n        val tableCompressed = WrappedValue()\n        val databaseCompressed = WrappedValue()\n        database?.setNotificationWhenCompressed { notifiedDatabase, table ->\n            require(database?.tag == notifiedDatabase.tag)\n            require(database?.path == notifiedDatabase.path)\n            if (table != null) {\n                if (table == tableName) {\n                    tableCompressed.boolValue = true\n                }\n            } else {\n                databaseCompressed.boolValue = true\n            }\n        }\n        require(!database?.isCompressed!!)\n        database?.stepCompression()\n        database?.stepCompression()\n        require(database!!.isCompressed)\n        require(tableCompressed.boolValue && databaseCompressed.boolValue)\n    }\n\n    private fun testReadOnly() {\n        table!!.insertObject(TestObject.createAutoIncrementObject(RandomTool.string()))\n        database!!.close {\n            for (path in database!!.paths) {\n                val file = File(path)\n                if (file.exists()) {\n                    file.setReadOnly()\n                }\n            }\n        }\n        require(database!!.canOpen())\n        val objects = table!!.allObjects\n        require(objects.size == 1)\n        var failed = false\n        try {\n            table!!.insertObject(TestObject.createAutoIncrementObject(RandomTool.string()))\n        } catch (e: WCDBException) {\n            failed = true\n        }\n        require(failed)\n    }\n\n    private fun testConfigFail() {\n        database!!.setConfig(\"testConfig\") { handle ->\n            handle.execute(StatementSelect().select(\"testColumn\").from(\"testTable\"))\n        }\n        require(!database!!.canOpen())\n        database!!.setConfig(\"testConfig\", null)\n    }\n\n    private fun testGlobalTraceError() {\n        val tested = WrappedValue()\n        Database.globalTraceException(null)\n        Database.globalTraceException { exception ->\n            if (exception.level == WCDBException.Level.Error &&\n                exception.path() == database!!.path &&\n                exception.tag() == database!!.tag &&\n                exception.code == WCDBException.Code.Error &&\n                exception.sql() == \"SELECT 1 FROM dummy\" &&\n                exception.message() == \"no such table: dummy\"\n            ) {\n                tested.boolValue = true\n            }\n        }\n        require(database!!.canOpen())\n        try {\n            database!!.execute(StatementSelect().select(\"1\").from(\"dummy\"))\n        } catch (e: WCDBException) {\n            require(tested.boolValue)\n        } finally {\n            require(tested.boolValue)\n        }\n    }\n\n    private fun testGlobalTraceSQL() {\n        val statement = StatementPragma().pragma(Pragma.userVersion)\n        val tested = WrappedValue()\n        database!!.close();\n        Database.globalTraceSQL(null)\n        Database.globalTraceSQL(SQLTracer { tag, path, handleId, sql, info ->\n            if (database!!.path != path) {\n                return@SQLTracer\n            }\n            require(tag == database!!.tag)\n            if (sql == statement.description) {\n                tested.boolValue = true\n            }\n        })\n        database!!.execute(statement)\n        require(tested.boolValue)\n        Database.globalTraceSQL(null)\n    }\n}"
  },
  {
    "path": "src/java/kotlin-test/src/main/java/com/tencent/wcdbtest/RandomTool.kt",
    "content": "// Created by qiuwenchen on 2024/4/27.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage com.tencent.wcdbtest\n\nimport com.tencent.wcdb.base.Value\nimport java.util.*\n\nobject RandomTool {\n    @JvmOverloads\n    fun string(length: Int = 100): String {\n        val str = \"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789\"\n        val random = Random()\n        val stringBuffer = StringBuilder(length)\n        for (i in 0 until length) {\n            val number = random.nextInt(62)\n            stringBuffer.append(str[number])\n        }\n        return stringBuffer.toString()\n    }\n\n    @JvmOverloads\n    fun bytes(length: Int = 100): ByteArray {\n        val random = Random()\n        val bytes = ByteArray(length)\n        random.nextBytes(bytes)\n        return bytes\n    }\n\n    fun autoIncrementTestCaseObjects(count: Int): List<TestObject?> {\n        val objects = mutableListOf<TestObject?>()\n        for (i in 0 until count) {\n            objects.add(TestObject.createAutoIncrementObject(string()))\n        }\n        return objects\n    }\n\n    fun testObjectWithId(id: Int): TestObject {\n        return TestObject.createObject(id, string())\n    }\n\n    fun testRowWithId(id: Int): Array<Value> {\n        return arrayOf(Value(id.toLong()), Value(string()))\n    }\n}"
  },
  {
    "path": "src/java/kotlin-test/src/main/java/com/tencent/wcdbtest/TestObject.kt",
    "content": "// Created by qiuwenchen on 2024/4/27.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdbtest\n\nimport com.tencent.wcdb.WCDBField\nimport com.tencent.wcdb.WCDBTableCoding\n\n@WCDBTableCoding\nclass TestObject {\n    @WCDBField(isPrimary = true, isAutoIncrement = true)\n    var id = 0\n\n    @WCDBField\n    var content: String? = null\n\n    override fun equals(other: Any?): Boolean {\n        return if (other is TestObject) {\n            if (other.id != id) {\n                return false\n            }\n            if (content == null) {\n                return other.content == null || other.content!!.isEmpty()\n            } else if (other.content == null) {\n                return content!!.isEmpty()\n            }\n            other.content == content\n        } else {\n            super.equals(other)\n        }\n    }\n\n    companion object {\n        fun createObject(id: Int, content: String?): TestObject {\n            val obj = TestObject()\n            obj.id = id\n            obj.content = content\n            return obj\n        }\n\n        fun createPartialObject(id: Int): TestObject {\n            val obj = TestObject()\n            obj.id = id\n            return obj\n        }\n\n        fun createAutoIncrementObject(content: String?): TestObject {\n            val obj = TestObject()\n            obj.id = 0\n            obj.content = content\n            return obj\n        }\n    }\n}"
  },
  {
    "path": "src/java/kotlin-test/src/main/java/com/tencent/wcdbtest/WrappedValue.kt",
    "content": "// Created by qiuwenchen on 2024/4/27.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage com.tencent.wcdbtest\n\nclass WrappedValue {\n    var boolValue = false\n    var intValue: Long = 0\n    var stringValue: String? = null\n    var doubleValue = 0.0\n\n    companion object {\n        fun currentTime(): WrappedValue {\n            val date = WrappedValue()\n            date.intValue = System.currentTimeMillis()\n            return date\n        }\n    }\n}"
  },
  {
    "path": "src/java/main/.gitignore",
    "content": "/build\n/.cxx"
  },
  {
    "path": "src/java/main/build.gradle",
    "content": "plugins {id 'com.android.library'}\napply from: rootProject.file('gradle/WeChatPublish.gradle')\n\nandroid {\n    namespace 'com.tencent.wcdb.core'\n    compileSdk 33\n\n    defaultConfig {\n        minSdk 21\n        targetSdk 33\n\n        consumerProguardFiles 'proguard-rules.pro'\n\n        testInstrumentationRunner \"androidx.test.runner.AndroidJUnitRunner\"\n        externalNativeBuild {\n            cmake {\n                arguments \"-DANDROID_STL=c++_shared\"\n            }\n        }\n    }\n\n    buildTypes {\n        release {\n            minifyEnabled false\n            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'\n        }\n    }\n\n    compileOptions {\n        sourceCompatibility JavaVersion.VERSION_1_8\n        targetCompatibility JavaVersion.VERSION_1_8\n    }\n\n    externalNativeBuild {\n        cmake {\n            path 'src/main/cpp/CMakeLists.txt'\n        }\n    }\n}\n\ndependencies {\n    implementation 'org.jetbrains:annotations:13.0'\n}"
  },
  {
    "path": "src/java/main/proguard-rules.pro",
    "content": "# Add project specific ProGuard rules here.\n# You can control the set of applied configuration files using the\n# proguardFiles setting in build.gradle.\n#\n# For more details, see\n#   http://developer.android.com/guide/developing/tools/proguard.html\n\n# If your project uses WebView with JS, uncomment the following\n# and specify the fully qualified class name to the JavaScript interface\n# class:\n#-keepclassmembers class fqcn.of.javascript.interface.for.webview {\n#   public *;\n#}\n\n# Uncomment this to preserve the line number information for\n# debugging stack traces.\n#-keepattributes SourceFile,LineNumberTable\n\n# If you keep the line number information, uncomment this to\n# hide the original source file name.\n#-renamesourcefileattribute SourceFile\n\n# Keep all native functions\n-keepclasseswithmembers,includedescriptorclasses class com.tencent.wcdb.** {\n    native <methods>;\n}\n\n# Keep all exception classes\n-keep class com.tencent.wcdb.**.*Exception\n\n# Keep all c callback functions\n-keep,includedescriptorclasses class com.tencent.wcdb.core.Database {\n    void onBusyTrace(com.tencent.wcdb.core.Database$BusyTracer, long, java.lang.String, long, java.lang.String);\n    void onClose(com.tencent.wcdb.core.Database$CloseCallBack);\n    boolean onConfig(long, com.tencent.wcdb.core.Database$Config);\n    void onCorrupted(com.tencent.wcdb.core.Database$CorruptionNotification, long);\n    void onEnumerateInfo(java.util.HashMap, java.lang.String, int, long, double, java.lang.String);\n    void onTraceException(com.tencent.wcdb.core.Database$ExceptionTracer, long);\n    void filterCompress(com.tencent.wcdb.core.Database$CompressionFilter, long, java.lang.String);\n    boolean onProgressUpdate(com.tencent.wcdb.core.Database$ProgressMonitor, double, double);\n    void onTableCompressed(com.tencent.wcdb.core.Database$CompressionNotification, long, java.lang.String);\n    void onTableMigrated(com.tencent.wcdb.core.Database$MigrationNotification, long, java.lang.String, java.lang.String);\n    void onTraceOperation(com.tencent.wcdb.core.Database$OperationTracer, long, int, long);\n    void onTracePerformance(com.tencent.wcdb.core.Database$PerformanceTracer, long, java.lang.String, long, java.lang.String, long, int[]);\n    void onTraceSQL(com.tencent.wcdb.core.Database$SQLTracer, long, java.lang.String, long, java.lang.String, java.lang.String);\n    boolean checkTableShouldBeBackup(com.tencent.wcdb.core.Database$BackupFilter, java.lang.String);\n}\n\n-keep,includedescriptorclasses class com.tencent.wcdb.base.WCDBException {\n    void addInfo(java.lang.String, int, long, double, java.lang.String);\n}\n\n-keep,includedescriptorclasses class com.tencent.wcdb.core.Handle {\n    int onPausableTransaction(long, com.tencent.wcdb.core.PausableTransaction, boolean);\n    boolean onTransaction(long, com.tencent.wcdb.core.Transaction);\n}"
  },
  {
    "path": "src/java/main/src/main/AndroidManifest.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<manifest xmlns:android=\"http://schemas.android.com/apk/res/android\"\n    xmlns:tools=\"http://schemas.android.com/tools\">\n</manifest>"
  },
  {
    "path": "src/java/main/src/main/cpp/CMakeLists.txt",
    "content": "\n# For more information about using CMake with Android Studio, read the\n# documentation: https://d.android.com/studio/projects/add-native-code.html\n\n# Sets the minimum version of CMake required to build the native library.\n\ncmake_minimum_required(VERSION 3.13)\n\n# Declares and names the project.\n\nproject(WCDB_Android)\n\ninclude(../../../../../utility.cmake)\n\nset(TARGET_NAME \"WCDB\")\nset(WCDB_BRIDGE ON)\nset(SKIP_WCONAN ON)\nset(BUILD_SHARED_LIBS ON)\n\nadd_subdirectory(../../../../.. ${CMAKE_CURRENT_BINARY_DIR}/wcdb)\n\nset(WCDB_JNI_SRC_DIR ${CMAKE_CURRENT_LIST_DIR})\n\nfile(GLOB_RECURSE WCDB_JNI_SRC\n    ${WCDB_JNI_SRC_DIR}/*.cpp\n    ${WCDB_JNI_SRC_DIR}/*.c\n    ${WCDB_JNI_SRC_DIR}/*.h)\n\nrecursive_subdirs(WCDB_JNI_INCLUDES ${WCDB_JNI_SRC_DIR})\n\n# Creates and names a library, sets it as either STATIC\n# or SHARED, and provides the relative paths to its source code.\n# You can define multiple libraries, and CMake builds them for you.\n# Gradle automatically packages shared libraries with your APK.\n\ntarget_sources(${TARGET_NAME} PUBLIC ${WCDB_JNI_SRC})\ntarget_include_directories(${TARGET_NAME} PUBLIC ${WCDB_JNI_INCLUDES})\n"
  },
  {
    "path": "src/java/main/src/main/cpp/JNIBinding.c",
    "content": "// Created by qiuwenchen on 2023/3/30.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"BindParameterJNI.h\"\n#include \"BindingJNI.h\"\n#include \"ColumnConstraintJNI.h\"\n#include \"ColumnDefJNI.h\"\n#include \"ColumnJNI.h\"\n#include \"CommonTableExpressionJNI.h\"\n#include \"CoreJNI.h\"\n#include \"DatabaseExtendJNI.h\"\n#include \"DatabaseJNI.h\"\n#include \"ErrorJNI.h\"\n#include \"ExpressionJNI.h\"\n#include \"ExpressionOperableJNI.h\"\n#include \"ForeignKeyJNI.h\"\n#include \"FrameSpecJNI.h\"\n#include \"HandleJNI.h\"\n#include \"HandleStatementJNI.h\"\n#include \"IndexedColumnJNI.h\"\n#include \"JoinJNI.h\"\n#include \"LiteralValueJNI.h\"\n#include \"OrderingTermJNI.h\"\n#include \"PragmaJNI.h\"\n#include \"QualifiedTableJNI.h\"\n#include \"RaiseFunctionJNI.h\"\n#include \"ResultColumnJNI.h\"\n#include \"SchemaJNI.h\"\n#include \"StatementAlterTableJNI.h\"\n#include \"StatementAnalyzeJNI.h\"\n#include \"StatementAttachJNI.h\"\n#include \"StatementBeginJNI.h\"\n#include \"StatementCommitJNI.h\"\n#include \"StatementCreateTableJNI.h\"\n#include \"StatementCreateTriggerJNI.h\"\n#include \"StatementCreateViewJNI.h\"\n#include \"StatementCreateVirtualTableJNI.h\"\n#include \"StatementCreateindexJNI.h\"\n#include \"StatementDeleteJNI.h\"\n#include \"StatementDetachJNI.h\"\n#include \"StatementDropIndexJNI.h\"\n#include \"StatementDropTableJNI.h\"\n#include \"StatementDropTriggerJNI.h\"\n#include \"StatementDropViewJNI.h\"\n#include \"StatementExplainJNI.h\"\n#include \"StatementInsertJNI.h\"\n#include \"StatementPragmaJNI.h\"\n#include \"StatementReindexJNI.h\"\n#include \"StatementReleaseJNI.h\"\n#include \"StatementRollbackJNI.h\"\n#include \"StatementSelectJNI.h\"\n#include \"StatementUpdateJNI.h\"\n#include \"StatementVacuumJNI.h\"\n#include \"TableConstraintJNI.h\"\n#include \"TableOrSubqueryJNI.h\"\n#include \"UpsertJNI.h\"\n#include \"WindowDefJNI.h\"\n#include \"WinqJNI.h\"\n\n#define WCDBJNIMultiTypeSignature \"IJDLjava/lang/String;\"\n#define WCDBJNIObjectOrStringSignature \"IJLjava/lang/String;\"\n#define WCDBJNIObjectOrIntegerSignature \"IJ\"\n#define WCDBJNICommonArraySignature \"I[J[D[Ljava/lang/String;\"\n#define WCDBJNIObjectOrStringArraySignature \"I[J[Ljava/lang/String;\"\n#define WCDBJNIMultiTypeArraySignature \"[I[J[D[Ljava/lang/String;\"\n\n#define WCDBJNIRegister(className, methodList)                                 \\\n    { className, (JNINativeMethod *) &methodList, sizeof(methodList) / sizeof(JNINativeMethod) }\n\ntypedef struct JNIBinding {\n    const char *className;\n    JNINativeMethod *methods;\n    int methodCount;\n} JNIBinding;\n\nstatic const JNINativeMethod g_objectBridgeMethods[] = {\n    { \"releaseCPPObject\", \"(J)V\", (void *) WCDBJNI(Base, releaseObject) },\n};\n\nstatic const JNINativeMethod g_winqBridgeMethods[] = {\n    { \"getDescription\", \"(J)\" WCDBJNIStringSignature \"\", (void *) WCDBJNI(Winq, getDescription) },\n    { \"isWriteStatement\", \"(J)Z\", (void *) WCDBJNI(Winq, isWriteStatement) },\n};\n\nstatic const JNINativeMethod g_literalValueMethods[] = {\n    { \"createCppObj\", \"(\" WCDBJNIMultiTypeSignature \")J\", (void *) WCDBJNILiteralValueFuncName(create) },\n    { \"createCurrentTime\", \"()J\", (void *) WCDBJNILiteralValueFuncName(createWithCurrentTime) },\n    { \"createCurrentDate\", \"()J\", (void *) WCDBJNILiteralValueFuncName(createWithCurrentDate) },\n    { \"createCurrentTimeStamp\", \"()J\", (void *) WCDBJNILiteralValueFuncName(createWithCurrentTimestamp) },\n};\n\nstatic const JNINativeMethod g_schemaMethods[] = {\n    { \"createCppObj\", \"(\" WCDBJNIStringSignature \")J\", (void *) WCDBJNISchemaFuncName(createWithName) },\n    { \"createMainCppObj\", \"()J\", (void *) WCDBJNISchemaFuncName(main) },\n    { \"createTempCppObj\", \"()J\", (void *) WCDBJNISchemaFuncName(temp) },\n};\n\nstatic const JNINativeMethod g_columnMethods[] = {\n    { \"createCppObj\", \"(\" WCDBJNIStringSignature \"J)J\", (void *) WCDBJNIColumnFuncName(createWithName) },\n    { \"copy\", \"(J)J\", (void *) WCDBJNIColumnFuncName(copy) },\n    { \"inTable\", \"(J\" WCDBJNIStringSignature \")V\", (void *) WCDBJNIColumnFuncName(inTable) },\n    { \"ofSchema\", \"(J\" WCDBJNIObjectOrStringSignature \")V\", (void *) WCDBJNIColumnFuncName(ofSchema) },\n    { \"configAlias\", \"(J\" WCDBJNIStringSignature \")J\", (void *) WCDBJNIColumnFuncName(configAlias) },\n    { \"allColumn\", \"()J\", (void *) WCDBJNIColumnFuncName(createAll) },\n    { \"rowidColumn\", \"()J\", (void *) WCDBJNIColumnFuncName(createRowId) },\n};\n\nstatic const JNINativeMethod g_bindParameterMethods[] = {\n    { \"createCppObj\", \"(I)J\", (void *) WCDBJNIBindParameterFuncName(createQuestionSignType) },\n    { \"createCppObj\",\n      \"(\" WCDBJNIStringSignature \")J\",\n      (void *) WCDBJNIBindParameterFuncName(createColonSignType) },\n    { \"createCppObjs\", \"(I)[J\", (void *) WCDBJNIBindParameterFuncName(bindParameters) },\n    { \"atBindParameter\",\n      \"(\" WCDBJNIStringSignature \")J\",\n      (void *) WCDBJNIBindParameterFuncName(createAtSignType) },\n    { \"dollarBindParameter\",\n      \"(\" WCDBJNIStringSignature \")J\",\n      (void *) WCDBJNIBindParameterFuncName(createDollarSignType) },\n};\n\nstatic const JNINativeMethod g_expressionMethods[] = {\n    { \"createCppObj\", \"(IJ)J\", (void *) WCDBJNIExpressionFuncName(create) },\n    { \"createWithFunction\",\n      \"(\" WCDBJNIStringSignature \")J\",\n      (void *) WCDBJNIExpressionFuncName(createWithFunction) },\n    { \"schema\", \"(J\" WCDBJNIObjectOrStringSignature \")V\", (void *) WCDBJNIExpressionFuncName(setWithSchema) },\n    { \"distinct\", \"(J)V\", (void *) WCDBJNIExpressionFuncName(distinct) },\n    { \"invoke\", \"(J)V\", (void *) WCDBJNIExpressionFuncName(invoke) },\n    { \"invokeAll\", \"(J)V\", (void *) WCDBJNIExpressionFuncName(invokeAll) },\n    { \"argument\", \"(J\" WCDBJNIMultiTypeSignature \")V\", (void *) WCDBJNIExpressionFuncName(setArgument) },\n    { \"escape\", \"(J\" WCDBJNIStringSignature \")V\", (void *) WCDBJNIExpressionFuncName(escapeWith) },\n    { \"createWithExistStatement\", \"(J)J\", (void *) WCDBJNIExpressionFuncName(createWithExistStatement) },\n    { \"createWithNotExistStatement\", \"(J)J\", (void *) WCDBJNIExpressionFuncName(createWithNotExistStatement) },\n    { \"cast\", \"(\" WCDBJNIObjectOrStringSignature \")J\", (void *) WCDBJNIExpressionFuncName(cast) },\n    { \"as\", \"(JI)V\", (void *) WCDBJNIExpressionFuncName(as) },\n    { \"as\", \"(J\" WCDBJNIStringSignature \")J\", (void *) WCDBJNIExpressionFuncName(configAlias) },\n    { \"caseWithExp\",\n      \"(\" WCDBJNIObjectOrStringSignature \")J\",\n      (void *) WCDBJNIExpressionFuncName(caseWithExp) },\n    { \"setWithWhenExp\",\n      \"(J\" WCDBJNIMultiTypeSignature \")V\",\n      (void *) WCDBJNIExpressionFuncName(setWithWhenExp) },\n    { \"setWithThenExp\",\n      \"(J\" WCDBJNIMultiTypeSignature \")V\",\n      (void *) WCDBJNIExpressionFuncName(setWithThenExp) },\n    { \"setWithElseExp\",\n      \"(J\" WCDBJNIMultiTypeSignature \")V\",\n      (void *) WCDBJNIExpressionFuncName(setWithElseExp) },\n    { \"createWithWindowFunction\",\n      \"(\" WCDBJNIStringSignature \")J\",\n      (void *) WCDBJNIExpressionFuncName(createWithWindowFunction) },\n    { \"filter\", \"(JJ)V\", (void *) WCDBJNIExpressionFuncName(filter) },\n    { \"overWindowDef\", \"(JJ)V\", (void *) WCDBJNIExpressionFuncName(overWindowDef) },\n    { \"overWindow\", \"(J\" WCDBJNIStringSignature \")V\", (void *) WCDBJNIExpressionFuncName(overWindow) },\n\n};\n\nstatic const JNINativeMethod g_expressionOperationMethods[] = {\n    { \"nullOperate\", \"(IJZ)J\", (void *) WCDBJNIExpressionOperableFuncName(nullOperate) },\n    { \"binaryOperate\",\n      \"(IJ\" WCDBJNIMultiTypeSignature \"IZ)J\",\n      (void *) WCDBJNIExpressionOperableFuncName(binaryOperate) },\n    { \"betweenOperate\",\n      \"(IJ\" WCDBJNIMultiTypeSignature WCDBJNIMultiTypeSignature \"Z)J\",\n      (void *) WCDBJNIExpressionOperableFuncName(betweenOperate) },\n    { \"in\",\n      \"(IJ\" WCDBJNICommonArraySignature \"Z)J\",\n      (void *) WCDBJNIExpressionOperableFuncName(inOperate) },\n    { \"inTable\",\n      \"(\" WCDBJNIObjectOrStringSignature \"Z)J\",\n      (void *) WCDBJNIExpressionOperableFuncName(inTableOperate) },\n    { \"inFunction\",\n      \"(\" WCDBJNIObjectOrStringSignature \"Z)J\",\n      (void *) WCDBJNIExpressionOperableFuncName(inFunctionOperate) },\n    { \"inSelect\", \"(IJJZ)J\", (void *) WCDBJNIExpressionOperableFuncName(inSelectionOperate) },\n    { \"collate\",\n      \"(\" WCDBJNIObjectOrStringSignature \")J\",\n      (void *) WCDBJNIExpressionOperableFuncName(collateOperate) },\n};\n\nstatic const JNINativeMethod g_columnConstraintMethods[] = {\n    { \"createCppObject\",\n      \"(\" WCDBJNIStringSignature \")J\",\n      (void *) WCDBJNIColumnConstraintFuncName(create) },\n    { \"configPrimaryKey\", \"(J)V\", (void *) WCDBJNIColumnConstraintFuncName(configPrimaryKey) },\n    { \"configOrder\", \"(JI)V\", (void *) WCDBJNIColumnConstraintFuncName(configOrder) },\n    { \"configConflictAction\", \"(JI)V\", (void *) WCDBJNIColumnConstraintFuncName(configConflictAction) },\n    { \"configAutoIncrement\", \"(J)V\", (void *) WCDBJNIColumnConstraintFuncName(configAutoIncrement) },\n    { \"configNotNull\", \"(J)V\", (void *) WCDBJNIColumnConstraintFuncName(configNotNull) },\n    { \"configUnique\", \"(J)V\", (void *) WCDBJNIColumnConstraintFuncName(configUnique) },\n    { \"configCheck\", \"(JJ)V\", (void *) WCDBJNIColumnConstraintFuncName(configCheck) },\n    { \"defaultTo\",\n      \"(J\" WCDBJNIMultiTypeSignature \")V\",\n      (void *) WCDBJNIColumnConstraintFuncName(configDefaultValue) },\n    { \"configCollate\",\n      \"(J\" WCDBJNIStringSignature \")V\",\n      (void *) WCDBJNIColumnConstraintFuncName(configCollation) },\n    { \"configForeignKey\", \"(JJ)V\", (void *) WCDBJNIColumnConstraintFuncName(configForeignKey) },\n    { \"configUnIndex\", \"(J)V\", (void *) WCDBJNIColumnConstraintFuncName(configUnindexed) },\n};\n\nstatic const JNINativeMethod g_orderingTermMethods[] = {\n    { \"createCppObj\", \"(IJ)J\", (void *) WCDBJNIOrderingTermFuncName(create) },\n    { \"collate\", \"(J\" WCDBJNIStringSignature \")V\", (void *) WCDBJNIOrderingTermFuncName(configCollation) },\n    { \"order\", \"(JI)V\", (void *) WCDBJNIOrderingTermFuncName(configOrder) },\n};\n\nstatic const JNINativeMethod g_columnDefMethods[] = {\n    { \"createCppObj\",\n      \"(\" WCDBJNIObjectOrStringSignature \"I)J\",\n      (void *) WCDBJNIColumnDefFuncName(create) },\n    { \"constraint\", \"(JJ)V\", (void *) WCDBJNIColumnDefFuncName(configConstraint) },\n};\n\nstatic const JNINativeMethod g_indexedColumnMethods[] = {\n    { \"createCppObj\",\n      \"(\" WCDBJNIObjectOrStringSignature \")J\",\n      (void *) WCDBJNIIndexedColumnFuncName(create) },\n    { \"collate\", \"(J\" WCDBJNIStringSignature \")V\", (void *) WCDBJNIIndexedColumnFuncName(configCollation) },\n    { \"order\", \"(JI)V\", (void *) WCDBJNIIndexedColumnFuncName(configOrder) },\n};\n\nstatic const JNINativeMethod g_tableOrSubqueryMethods[] = {\n    { \"createCppObj\",\n      \"(\" WCDBJNIObjectOrStringSignature \")J\",\n      (void *) WCDBJNITableOrSubqueryFuncName(create) },\n    { \"createCppObj\",\n      \"(\" WCDBJNIObjectOrStringArraySignature \")J\",\n      (void *) WCDBJNITableOrSubqueryFuncName(createWithTableOrSubqueries) },\n    { \"createWithFunction\",\n      \"(\" WCDBJNIStringSignature \")J\",\n      (void *) WCDBJNITableOrSubqueryFuncName(createWithFunction) },\n    { \"schema\",\n      \"(J\" WCDBJNIObjectOrStringSignature \")V\",\n      (void *) WCDBJNITableOrSubqueryFuncName(configSchema) },\n    { \"as\", \"(J\" WCDBJNIStringSignature \")V\", (void *) WCDBJNITableOrSubqueryFuncName(configAlias) },\n    { \"notIndexed\", \"(J)V\", (void *) WCDBJNITableOrSubqueryFuncName(configNotIndexed) },\n    { \"indexedBy\",\n      \"(J\" WCDBJNIStringSignature \")V\",\n      (void *) WCDBJNITableOrSubqueryFuncName(configIndexName) },\n    { \"argument\", \"(J\" WCDBJNIMultiTypeSignature \")V\", (void *) WCDBJNITableOrSubqueryFuncName(argument) },\n};\n\nstatic const JNINativeMethod g_qualifiedTableMethods[] = {\n    { \"createCppObj\", \"(\" WCDBJNIStringSignature \")J\", (void *) WCDBJNIQualifiedTableFuncName(create) },\n    { \"schema\",\n      \"(J\" WCDBJNIObjectOrStringSignature \")V\",\n      (void *) WCDBJNIQualifiedTableFuncName(configSchema) },\n    { \"alias\", \"(J\" WCDBJNIStringSignature \")V\", (void *) WCDBJNIQualifiedTableFuncName(configAlias) },\n    { \"indexed\", \"(J\" WCDBJNIStringSignature \")V\", (void *) WCDBJNIQualifiedTableFuncName(configIndex) },\n    { \"notIndexed\", \"(J)V\", (void *) WCDBJNIQualifiedTableFuncName(configNotIndexed) },\n};\n\nstatic const JNINativeMethod g_resultColumnMethods[] = {\n    { \"createCppObj\",\n      \"(\" WCDBJNIObjectOrStringSignature \")J\",\n      (void *) WCDBJNIResultColumnFuncName(create) },\n    { \"configAlias\", \"(J\" WCDBJNIStringSignature \")V\", (void *) WCDBJNIResultColumnFuncName(configAlias) },\n};\n\nstatic const JNINativeMethod g_tableConstraintMethods[] = {\n    { \"createCppObj\", \"(\" WCDBJNIStringSignature \")J\", (void *) WCDBJNITableConstraintFuncName(create) },\n    { \"configPrimaryKey\", \"(J)V\", (void *) WCDBJNITableConstraintFuncName(configPrimaryKey) },\n    { \"configUnique\", \"(J)V\", (void *) WCDBJNITableConstraintFuncName(configUnique) },\n    { \"configIndexedColumn\",\n      \"(J\" WCDBJNIObjectOrStringArraySignature \")V\",\n      (void *) WCDBJNITableConstraintFuncName(configIndexedColumn) },\n    { \"configConfliction\", \"(JI)V\", (void *) WCDBJNITableConstraintFuncName(configConfliction) },\n    { \"configCheckExpression\", \"(JJ)V\", (void *) WCDBJNITableConstraintFuncName(configCheckCondition) },\n    { \"configForeignKey\",\n      \"(J\" WCDBJNIObjectOrStringArraySignature \"J)V\",\n      (void *) WCDBJNITableConstraintFuncName(configForeignKey) },\n};\n\nstatic const JNINativeMethod g_pragmaMethods[] = {\n    { \"createCppObj\", \"(\" WCDBJNIStringSignature \")J\", (void *) WCDBJNIPragmaFuncName(create) },\n};\n\nstatic const JNINativeMethod g_commonTableExpressionMethods[] = {\n    { \"createCPPObject\",\n      \"(\" WCDBJNIStringSignature \")J\",\n      (void *) WCDBJNICommonTableExpressionFuncName(createWithTable) },\n    { \"configColumn\", \"(JJ)V\", (void *) WCDBJNICommonTableExpressionFuncName(configColumn) },\n    { \"configSelect\", \"(JJ)V\", (void *) WCDBJNICommonTableExpressionFuncName(configSelectStatement) },\n};\n\nstatic const JNINativeMethod g_foreignKeyMethods[] = {\n    { \"createCPPObj\", \"()J\", (void *) WCDBJNIForeignKeyFuncName(createCppObject) },\n    { \"configReference\",\n      \"(J\" WCDBJNIStringSignature \")V\",\n      (void *) WCDBJNIForeignKeyFuncName(configReferencesTable) },\n    { \"configColumns\",\n      \"(J\" WCDBJNIObjectOrStringArraySignature \")V\",\n      (void *) WCDBJNIForeignKeyFuncName(configColumns) },\n    { \"configOnDeleteAction\", \"(JI)V\", (void *) WCDBJNIForeignKeyFuncName(configOnDeleteAction) },\n    { \"configOnUpdateAction\", \"(JI)V\", (void *) WCDBJNIForeignKeyFuncName(configOnUpdateAction) },\n    { \"configMatch\", \"(JI)V\", (void *) WCDBJNIForeignKeyFuncName(configMatch) },\n    { \"configDeferrable\", \"(JI)V\", (void *) WCDBJNIForeignKeyFuncName(configDeferrable) },\n    { \"configNotDeferrable\", \"(JI)V\", (void *) WCDBJNIForeignKeyFuncName(configNotDeferrable) },\n};\n\nstatic const JNINativeMethod g_frameSpecMethods[] = {\n    { \"createCppObj\", \"()J\", (void *) WCDBJNIFrameSpecFuncName(createCppObj) },\n    { \"configRange\", \"(J)V\", (void *) WCDBJNIFrameSpecFuncName(configRange) },\n    { \"configRows\", \"(J)V\", (void *) WCDBJNIFrameSpecFuncName(configRows) },\n    { \"configUnboundedPreceding\", \"(J)V\", (void *) WCDBJNIFrameSpecFuncName(configUnboundedPreceding) },\n    { \"configPreceding\",\n      \"(J\" WCDBJNIObjectOrIntegerSignature \")V\",\n      (void *) WCDBJNIFrameSpecFuncName(configPreceding) },\n    { \"configCurrentRow\", \"(J)V\", (void *) WCDBJNIFrameSpecFuncName(configCurrentRow) },\n    { \"configBetweenUnboundedPreceding\",\n      \"(J)V\",\n      (void *) WCDBJNIFrameSpecFuncName(configBetweenUnboundedPreceding) },\n    { \"configBetweenPreceding\",\n      \"(J\" WCDBJNIObjectOrIntegerSignature \")V\",\n      (void *) WCDBJNIFrameSpecFuncName(configBetweenPreceding) },\n    { \"configBetweenCurrentRow\", \"(J)V\", (void *) WCDBJNIFrameSpecFuncName(configBetweenCurrentRow) },\n    { \"configBetweenFollowing\",\n      \"(J\" WCDBJNIObjectOrIntegerSignature \")V\",\n      (void *) WCDBJNIFrameSpecFuncName(configBetweenFollowing) },\n    { \"configAndPreceding\", \"(JIJ)V\", (void *) WCDBJNIFrameSpecFuncName(configAndPreceding) },\n    { \"configAndUnboundedFollowing\", \"(J)V\", (void *) WCDBJNIFrameSpecFuncName(configAndUnboundedFollowing) },\n    { \"configAndFollowing\",\n      \"(J\" WCDBJNIObjectOrIntegerSignature \")V\",\n      (void *) WCDBJNIFrameSpecFuncName(configAndFollowing) },\n    { \"configAndCurrentRow\", \"(J)V\", (void *) WCDBJNIFrameSpecFuncName(configAndCurrentRow) },\n};\n\nstatic const JNINativeMethod g_joinMethods[] = {\n    { \"createCppObj\", \"(\" WCDBJNIObjectOrStringSignature \")J\", (void *) WCDBJNIJoinFuncName(createCppObj) },\n    { \"configWith\", \"(J\" WCDBJNIObjectOrStringSignature \")V\", (void *) WCDBJNIJoinFuncName(configWith) },\n    { \"configJoin\", \"(J\" WCDBJNIObjectOrStringSignature \")V\", (void *) WCDBJNIJoinFuncName(configWithJoin) },\n    { \"configWithLeftOuterJoin\",\n      \"(J\" WCDBJNIObjectOrStringSignature \")V\",\n      (void *) WCDBJNIJoinFuncName(configWithLeftOuterJoin) },\n    { \"configWithLeftJoin\",\n      \"(J\" WCDBJNIObjectOrStringSignature \")V\",\n      (void *) WCDBJNIJoinFuncName(configWithLeftJoin) },\n    { \"configWithInnerJoin\",\n      \"(J\" WCDBJNIObjectOrStringSignature \")V\",\n      (void *) WCDBJNIJoinFuncName(configWithInnerJoin) },\n    { \"configWithCrossJoin\",\n      \"(J\" WCDBJNIObjectOrStringSignature \")V\",\n      (void *) WCDBJNIJoinFuncName(configWithCrossJoin) },\n    { \"configWithNaturalJoin\",\n      \"(J\" WCDBJNIObjectOrStringSignature \")V\",\n      (void *) WCDBJNIJoinFuncName(configWithNaturalJoin) },\n    { \"configWithNaturalLeftOuterJoin\",\n      \"(J\" WCDBJNIObjectOrStringSignature \")V\",\n      (void *) WCDBJNIJoinFuncName(configWithNaturalLeftOuterJoin) },\n    { \"configWithNaturalLeftJoin\",\n      \"(J\" WCDBJNIObjectOrStringSignature \")V\",\n      (void *) WCDBJNIJoinFuncName(configWithNaturalLeftJoin) },\n    { \"configWithNaturalInnerJoin\",\n      \"(J\" WCDBJNIObjectOrStringSignature \")V\",\n      (void *) WCDBJNIJoinFuncName(configWithNaturalInnerJoin) },\n    { \"configWithNaturalCrossJoin\",\n      \"(J\" WCDBJNIObjectOrStringSignature \")V\",\n      (void *) WCDBJNIJoinFuncName(configWithNaturalCrossJoin) },\n    { \"configOn\", \"(JJ)V\", (void *) WCDBJNIJoinFuncName(configOn) },\n    { \"configUsingColumn\",\n      \"(J\" WCDBJNIObjectOrStringArraySignature \")V\",\n      (void *) WCDBJNIJoinFuncName(configUsingColumn) },\n};\n\nstatic const JNINativeMethod g_raiseFunctionMethods[] = {\n    { \"createCppObj\", \"()J\", (void *) WCDBJNIRaiseFunctionFuncName(createCppObj) },\n    { \"setAction\", \"(JI\" WCDBJNIStringSignature \")V\", (void *) WCDBJNIRaiseFunctionFuncName(setAction) },\n};\n\nstatic const JNINativeMethod g_upsertMethods[] = {\n    { \"createCppObj\", \"()J\", (void *) WCDBJNIUpsertFuncName(createCppObj) },\n    { \"configIndexedColumn\",\n      \"(J\" WCDBJNIObjectOrStringArraySignature \")V\",\n      (void *) WCDBJNIUpsertFuncName(configIndexedColumn) },\n    { \"configWhere\", \"(JJ)V\", (void *) WCDBJNIUpsertFuncName(configWhere) },\n    { \"configDoNothing\", \"(J)V\", (void *) WCDBJNIUpsertFuncName(configDoNothing) },\n    { \"configDoUpdate\", \"(J)V\", (void *) WCDBJNIUpsertFuncName(configDoUpdate) },\n    { \"configSetColumns\",\n      \"(J\" WCDBJNIObjectOrStringArraySignature \")V\",\n      (void *) WCDBJNIUpsertFuncName(configSetColumns) },\n    { \"configToValue\", \"(J\" WCDBJNIMultiTypeSignature \")V\", (void *) WCDBJNIUpsertFuncName(configToValue) },\n};\n\nstatic const JNINativeMethod g_windowDefMethods[] = {\n    { \"createCppObj\", \"()J\", (void *) WCDBJNIWindowDefFuncName(createCppObj) },\n    { \"configPartitions\",\n      \"(J\" WCDBJNIMultiTypeArraySignature \")V\",\n      (void *) WCDBJNIWindowDefFuncName(configPartitions) },\n    { \"configOrders\", \"(J[J)V\", (void *) WCDBJNIWindowDefFuncName(configOrders) },\n    { \"configFrameSpec\", \"(JJ)V\", (void *) WCDBJNIWindowDefFuncName(configFrameSpec) },\n};\n\nstatic const JNINativeMethod g_statementBeginMethods[] = {\n    { \"createCppObj\", \"(I)J\", (void *) WCDBJNIStatementBeginFuncName(create) },\n};\n\nstatic const JNINativeMethod g_statementCommitMethods[] = {\n    { \"createCppObj\", \"()J\", (void *) WCDBJNIStatementCommitFuncName(create) },\n};\n\nstatic const JNINativeMethod g_statementCreateIndexMethods[] = {\n    { \"createCppObj\", \"()J\", (void *) WCDBJNIStatementCreateIndexFuncName(create) },\n    { \"createIndex\",\n      \"(J\" WCDBJNIStringSignature \")V\",\n      (void *) WCDBJNIStatementCreateIndexFuncName(configIndex) },\n    { \"configUnique\", \"(J)V\", (void *) WCDBJNIStatementCreateIndexFuncName(configUnique) },\n    { \"configIfNotExist\", \"(J)V\", (void *) WCDBJNIStatementCreateIndexFuncName(configIfNotExist) },\n    { \"configSchema\",\n      \"(J\" WCDBJNIObjectOrStringSignature \")V\",\n      (void *) WCDBJNIStatementCreateIndexFuncName(configSchema) },\n    { \"configTableName\",\n      \"(J\" WCDBJNIStringSignature \")V\",\n      (void *) WCDBJNIStatementCreateIndexFuncName(configTable) },\n    { \"configIndexedColumns\",\n      \"(J\" WCDBJNIObjectOrStringArraySignature \")V\",\n      (void *) WCDBJNIStatementCreateIndexFuncName(configIndexedColumns) },\n    { \"configCondition\", \"(JJ)V\", (void *) WCDBJNIStatementCreateIndexFuncName(configWhere) },\n};\n\nstatic const JNINativeMethod g_statementCreateTableMethods[] = {\n    { \"createCppObj\", \"()J\", (void *) WCDBJNIStatementCreateTableFuncName(create) },\n    { \"configTableName\",\n      \"(J\" WCDBJNIStringSignature \")V\",\n      (void *) WCDBJNIStatementCreateTableFuncName(configTableName) },\n    { \"configTemp\", \"(J)V\", (void *) WCDBJNIStatementCreateTableFuncName(configTemp) },\n    { \"configIfNotExist\", \"(J)V\", (void *) WCDBJNIStatementCreateTableFuncName(configIfNotExist) },\n    { \"configSchema\",\n      \"(J\" WCDBJNIObjectOrStringSignature \")V\",\n      (void *) WCDBJNIStatementCreateTableFuncName(configSchema) },\n    { \"configAs\", \"(JJ)V\", (void *) WCDBJNIStatementCreateTableFuncName(configAs) },\n    { \"configColumn\", \"(JJ)V\", (void *) WCDBJNIStatementCreateTableFuncName(configColumn) },\n    { \"configColumns\", \"(J[J)V\", (void *) WCDBJNIStatementCreateTableFuncName(configColumns) },\n    { \"configConstraints\", \"(J[J)V\", (void *) WCDBJNIStatementCreateTableFuncName(configConstraints) },\n    { \"configWithoutRowid\", \"(J)V\", (void *) WCDBJNIStatementCreateTableFuncName(configWithoutRowid) },\n};\n\nstatic const JNINativeMethod g_statementCreateVirtualTableMethods[] = {\n    { \"createCppObj\", \"()J\", (void *) WCDBJNIStatementCreateVirtualTableFuncName(createCppObj) },\n    { \"configTable\",\n      \"(J\" WCDBJNIStringSignature \")V\",\n      (void *) WCDBJNIStatementCreateVirtualTableFuncName(configTable) },\n    { \"configIfNotExist\", \"(J)V\", (void *) WCDBJNIStatementCreateVirtualTableFuncName(configIfNotExist) },\n    { \"configSchema\",\n      \"(J\" WCDBJNIObjectOrStringSignature \")V\",\n      (void *) WCDBJNIStatementCreateVirtualTableFuncName(configSchema) },\n    { \"configModule\",\n      \"(J\" WCDBJNIStringSignature \")V\",\n      (void *) WCDBJNIStatementCreateVirtualTableFuncName(configModule) },\n    { \"configArguments\",\n      \"(J[\" WCDBJNIStringSignature \")V\",\n      (void *) WCDBJNIStatementCreateVirtualTableFuncName(configArguments) },\n};\n\nstatic const JNINativeMethod g_statementDeleteMethods[] = {\n    { \"createCppObj\", \"()J\", (void *) WCDBJNIStatementDeleteFuncName(create) },\n    { \"configWith\", \"(J[J)V\", (void *) WCDBJNIStatementDeleteFuncName(configWith) },\n    { \"configRecursive\", \"(J)V\", (void *) WCDBJNIStatementDeleteFuncName(configRecursive) },\n    { \"configTable\",\n      \"(J\" WCDBJNIObjectOrStringSignature \")V\",\n      (void *) WCDBJNIStatementDeleteFuncName(configTable) },\n    { \"configCondition\", \"(JJ)V\", (void *) WCDBJNIStatementDeleteFuncName(configCondition) },\n    { \"configOrders\", \"(J[J)V\", (void *) WCDBJNIStatementDeleteFuncName(configOrders) },\n    { \"configLimitRange\", \"(JIJIJ)V\", (void *) WCDBJNIStatementDeleteFuncName(configLimitRange) },\n    { \"configLimitCount\", \"(JIJ)V\", (void *) WCDBJNIStatementDeleteFuncName(configLimitCount) },\n    { \"configOffset\", \"(JIJ)V\", (void *) WCDBJNIStatementDeleteFuncName(configOffset) },\n};\n\nstatic const JNINativeMethod g_statementDropTableMethods[] = {\n    { \"createCppObj\", \"()J\", (void *) WCDBJNIStatementDropTableFuncName(create) },\n    { \"configSchema\",\n      \"(J\" WCDBJNIObjectOrStringSignature \")V\",\n      (void *) WCDBJNIStatementDropTableFuncName(configSchema) },\n    { \"configTableName\",\n      \"(J\" WCDBJNIStringSignature \")V\",\n      (void *) WCDBJNIStatementDropTableFuncName(configTableName) },\n    { \"configIfExist\", \"(J)V\", (void *) WCDBJNIStatementDropTableFuncName(configIfExist) },\n};\n\nstatic const JNINativeMethod g_statementInsertMethods[] = {\n    { \"createCppObj\", \"()J\", (void *) WCDBJNIStatementInsertFuncName(create) },\n    { \"configWith\", \"(J[J)V\", (void *) WCDBJNIStatementInsertFuncName(configWith) },\n    { \"configRecursive\", \"(J)V\", (void *) WCDBJNIStatementInsertFuncName(configRecursive) },\n    { \"configSchema\",\n      \"(J\" WCDBJNIObjectOrStringSignature \")V\",\n      (void *) WCDBJNIStatementInsertFuncName(configSchema) },\n    { \"configTableName\",\n      \"(J\" WCDBJNIStringSignature \")V\",\n      (void *) WCDBJNIStatementInsertFuncName(configTableName) },\n    { \"configConflictAction\", \"(JI)V\", (void *) WCDBJNIStatementInsertFuncName(configConfliction) },\n    { \"configAlias\", \"(J\" WCDBJNIStringSignature \")V\", (void *) WCDBJNIStatementInsertFuncName(configAs) },\n    { \"configColumns\",\n      \"(J\" WCDBJNIObjectOrStringArraySignature \")V\",\n      (void *) WCDBJNIStatementInsertFuncName(configColumns) },\n    { \"configValuesWithBindParameters\",\n      \"(JI)V\",\n      (void *) WCDBJNIStatementInsertFuncName(configValuesWithBindParameters) },\n    { \"configValues\",\n      \"(J\" WCDBJNIMultiTypeArraySignature \")V\",\n      (void *) WCDBJNIStatementInsertFuncName(configValues) },\n    { \"configValues\", \"(JJ)V\", (void *) WCDBJNIStatementInsertFuncName(configSelect) },\n    { \"configDefaultValues\", \"(J)V\", (void *) WCDBJNIStatementInsertFuncName(configDefaultValues) },\n    { \"configUpsert\", \"(JJ)V\", (void *) WCDBJNIStatementInsertFuncName(configUpsert) },\n};\n\nstatic const JNINativeMethod g_statementPragmaMethods[] = {\n    { \"createCppObj\", \"()J\", (void *) WCDBJNIStatementPragmaFuncName(create) },\n    { \"configSchema\",\n      \"(J\" WCDBJNIObjectOrStringSignature \")V\",\n      (void *) WCDBJNIStatementPragmaFuncName(configSchema) },\n    { \"configPragma\", \"(JJ)V\", (void *) WCDBJNIStatementPragmaFuncName(configPragma) },\n    { \"configWithValue\",\n      \"(J\" WCDBJNIMultiTypeSignature \")V\",\n      (void *) WCDBJNIStatementPragmaFuncName(configWithValue) },\n    { \"configToValue\",\n      \"(J\" WCDBJNIMultiTypeSignature \")V\",\n      (void *) WCDBJNIStatementPragmaFuncName(configToValue) },\n};\n\nstatic const JNINativeMethod g_statementSelectMethods[] = {\n    { \"createCppObj\", \"()J\", (void *) WCDBJNIStatementSelectFuncName(create) },\n    { \"configWith\", \"(J[J)V\", (void *) WCDBJNIStatementSelectFuncName(configWith) },\n    { \"configRecursive\", \"(J)V\", (void *) WCDBJNIStatementSelectFuncName(configRecursive) },\n    { \"configResultColumns\",\n      \"(J\" WCDBJNIMultiTypeArraySignature \")V\",\n      (void *) WCDBJNIStatementSelectFuncName(configResultColumns) },\n    { \"configDistinct\", \"(J)V\", (void *) WCDBJNIStatementSelectFuncName(configDistiction) },\n    { \"configTableOrSubqueries\",\n      \"(J\" WCDBJNIMultiTypeArraySignature \")V\",\n      (void *) WCDBJNIStatementSelectFuncName(configTableOrSubqueries) },\n    { \"configCondition\", \"(JJ)V\", (void *) WCDBJNIStatementSelectFuncName(configCondition) },\n    { \"configGroups\",\n      \"(J\" WCDBJNIMultiTypeArraySignature \")V\",\n      (void *) WCDBJNIStatementSelectFuncName(configGroups) },\n    { \"configHaving\", \"(JJ)V\", (void *) WCDBJNIStatementSelectFuncName(configHaving) },\n    { \"configUnion\", \"(J)V\", (void *) WCDBJNIStatementSelectFuncName(configUnion) },\n    { \"configUnionAll\", \"(J)V\", (void *) WCDBJNIStatementSelectFuncName(configUnionAll) },\n    { \"configIntersect\", \"(J)V\", (void *) WCDBJNIStatementSelectFuncName(configIntersect) },\n    { \"configExcept\", \"(J)V\", (void *) WCDBJNIStatementSelectFuncName(configExcept) },\n    { \"configOrders\", \"(J[J)V\", (void *) WCDBJNIStatementSelectFuncName(configOrders) },\n    { \"configLimitRange\", \"(JIJIJ)V\", (void *) WCDBJNIStatementSelectFuncName(configLimitRange) },\n    { \"configLimitCount\", \"(JIJ)V\", (void *) WCDBJNIStatementSelectFuncName(configLimitCount) },\n    { \"configOffset\", \"(JIJ)V\", (void *) WCDBJNIStatementSelectFuncName(configOffset) },\n};\n\nstatic const JNINativeMethod g_statementUpdateMethods[] = {\n    { \"createCppObj\", \"()J\", (void *) WCDBJNIStatementUpdateFuncName(create) },\n    { \"configWith\", \"(J[J)V\", (void *) WCDBJNIStatementUpdateFuncName(configWith) },\n    { \"configRecursive\", \"(J)V\", (void *) WCDBJNIStatementUpdateFuncName(configRecursive) },\n    { \"configTable\",\n      \"(J\" WCDBJNIObjectOrStringSignature \")V\",\n      (void *) WCDBJNIStatementUpdateFuncName(configTable) },\n    { \"configConflictAction\", \"(JI)V\", (void *) WCDBJNIStatementInsertFuncName(configConfliction) },\n    { \"configColumnsToBindParameters\",\n      \"(J\" WCDBJNIObjectOrStringArraySignature \")V\",\n      (void *) WCDBJNIStatementUpdateFuncName(configColumnsWithBindParameter) },\n    { \"configColumnsToValues\",\n      \"(J\" WCDBJNIObjectOrStringArraySignature WCDBJNIMultiTypeArraySignature \")V\",\n      (void *) WCDBJNIStatementUpdateFuncName(configColumnsToValues) },\n    { \"configColumns\",\n      \"(J\" WCDBJNIObjectOrStringArraySignature \")V\",\n      (void *) WCDBJNIStatementUpdateFuncName(configColumns) },\n    { \"configToValue\",\n      \"(J\" WCDBJNIMultiTypeSignature \")V\",\n      (void *) WCDBJNIStatementUpdateFuncName(configValue) },\n    { \"configCondition\", \"(JJ)V\", (void *) WCDBJNIStatementUpdateFuncName(configCondition) },\n    { \"configOrders\", \"(J[J)V\", (void *) WCDBJNIStatementUpdateFuncName(configOrders) },\n    { \"configLimitRange\", \"(JIJIJ)V\", (void *) WCDBJNIStatementUpdateFuncName(configLimitRange) },\n    { \"configLimitCount\", \"(JIJ)V\", (void *) WCDBJNIStatementUpdateFuncName(configLimitCount) },\n    { \"configOffset\", \"(JIJ)V\", (void *) WCDBJNIStatementUpdateFuncName(configOffset) },\n};\n\nstatic const JNINativeMethod g_statementAlterTableMethods[] = {\n    { \"createCppObj\", \"()J\", (void *) WCDBJNIStatementAlterTableFuncName(createCppObj) },\n    { \"configTable\",\n      \"(J\" WCDBJNIStringSignature \")V\",\n      (void *) WCDBJNIStatementAlterTableFuncName(configTable) },\n    { \"configSchema\",\n      \"(J\" WCDBJNIObjectOrStringSignature \")V\",\n      (void *) WCDBJNIStatementAlterTableFuncName(configSchema) },\n    { \"configRenameToTable\",\n      \"(J\" WCDBJNIStringSignature \")V\",\n      (void *) WCDBJNIStatementAlterTableFuncName(configRenameToTable) },\n    { \"configRenameColumn\",\n      \"(J\" WCDBJNIObjectOrStringSignature \")V\",\n      (void *) WCDBJNIStatementAlterTableFuncName(configRenameColumn) },\n    { \"configRenameToColumn\",\n      \"(J\" WCDBJNIObjectOrStringSignature \")V\",\n      (void *) WCDBJNIStatementAlterTableFuncName(configRenameToColumn) },\n    { \"configAddColumn\", \"(JJ)V\", (void *) WCDBJNIStatementAlterTableFuncName(configAddColumn) },\n};\n\nstatic const JNINativeMethod g_statementAnalyzeMethods[] = {\n    { \"createCppObj\", \"()J\", (void *) WCDBJNIStatementAnalyzeFuncName(createCppObj) },\n    { \"configToAnalyze\", \"(J)V\", (void *) WCDBJNIStatementAnalyzeFuncName(toAnalyze) },\n    { \"configSchema\",\n      \"(J\" WCDBJNIObjectOrStringSignature \")V\",\n      (void *) WCDBJNIStatementAnalyzeFuncName(configSchema) },\n    { \"configTable\",\n      \"(J\" WCDBJNIStringSignature \")V\",\n      (void *) WCDBJNIStatementAnalyzeFuncName(configTable) },\n    { \"configIndex\",\n      \"(J\" WCDBJNIStringSignature \")V\",\n      (void *) WCDBJNIStatementAnalyzeFuncName(configIndex) },\n};\n\nstatic const JNINativeMethod g_statementAttachMethods[] = {\n    { \"createCppObj\", \"()J\", (void *) WCDBJNIStatementAttachFuncName(createCppObj) },\n    { \"configPath\",\n      \"(J\" WCDBJNIObjectOrStringSignature \")V\",\n      (void *) WCDBJNIStatementAttachFuncName(configPath) },\n    { \"configSchema\",\n      \"(J\" WCDBJNIObjectOrStringSignature \")V\",\n      (void *) WCDBJNIStatementAttachFuncName(configSchema) },\n    { \"configKey\",\n      \"(J\" WCDBJNIObjectOrStringSignature \")V\",\n      (void *) WCDBJNIStatementAttachFuncName(configKey) },\n};\n\nstatic const JNINativeMethod g_statementDetachMethods[] = {\n    { \"createCppObj\", \"()J\", (void *) WCDBJNIStatementDetachFuncName(createCppObj) },\n    { \"configSchema\",\n      \"(J\" WCDBJNIObjectOrStringSignature \")V\",\n      (void *) WCDBJNIStatementDetachFuncName(configSchema) },\n};\n\nstatic const JNINativeMethod g_statementCreateTriggerMethods[] = {\n    { \"createCppObj\", \"()J\", (void *) WCDBJNIStatementCreateTriggerFuncName(createCppObj) },\n    { \"configTrigger\",\n      \"(J\" WCDBJNIStringSignature \")V\",\n      (void *) WCDBJNIStatementCreateTriggerFuncName(configTrigger) },\n    { \"configSchema\",\n      \"(J\" WCDBJNIObjectOrStringSignature \")V\",\n      (void *) WCDBJNIStatementCreateTriggerFuncName(configSchema) },\n    { \"configTemp\", \"(J)V\", (void *) WCDBJNIStatementCreateTriggerFuncName(configTemp) },\n    { \"configIfNotExist\", \"(J)V\", (void *) WCDBJNIStatementCreateTriggerFuncName(configIfNotExist) },\n    { \"configBefore\", \"(J)V\", (void *) WCDBJNIStatementCreateTriggerFuncName(configBefore) },\n    { \"configAfter\", \"(J)V\", (void *) WCDBJNIStatementCreateTriggerFuncName(configAfter) },\n    { \"configInsteadOf\", \"(J)V\", (void *) WCDBJNIStatementCreateTriggerFuncName(configInsteadOf) },\n    { \"configDelete\", \"(J)V\", (void *) WCDBJNIStatementCreateTriggerFuncName(configDelete) },\n    { \"configInsert\", \"(J)V\", (void *) WCDBJNIStatementCreateTriggerFuncName(configInsert) },\n    { \"configUpdate\", \"(J)V\", (void *) WCDBJNIStatementCreateTriggerFuncName(configUpdate) },\n    { \"configColumns\",\n      \"(J\" WCDBJNIObjectOrStringArraySignature \")V\",\n      (void *) WCDBJNIStatementCreateTriggerFuncName(configColumns) },\n    { \"configTable\",\n      \"(J\" WCDBJNIStringSignature \")V\",\n      (void *) WCDBJNIStatementCreateTriggerFuncName(configTable) },\n    { \"configDelete\", \"(J)V\", (void *) WCDBJNIStatementCreateTriggerFuncName(configDelete) },\n    { \"configInsert\", \"(J)V\", (void *) WCDBJNIStatementCreateTriggerFuncName(configInsert) },\n    { \"configUpdate\", \"(J)V\", (void *) WCDBJNIStatementCreateTriggerFuncName(configUpdate) },\n    { \"configForEachRow\", \"(J)V\", (void *) WCDBJNIStatementCreateTriggerFuncName(configForEachRow) },\n    { \"configWhen\", \"(JJ)V\", (void *) WCDBJNIStatementCreateTriggerFuncName(configWhen) },\n    { \"executeInsert\", \"(JJ)V\", (void *) WCDBJNIStatementCreateTriggerFuncName(executeInsert) },\n    { \"executeUpdate\", \"(JJ)V\", (void *) WCDBJNIStatementCreateTriggerFuncName(executeUpdate) },\n    { \"executeDelete\", \"(JJ)V\", (void *) WCDBJNIStatementCreateTriggerFuncName(executeDelete) },\n    { \"executeSelect\", \"(JJ)V\", (void *) WCDBJNIStatementCreateTriggerFuncName(executeSelect) },\n};\n\nstatic const JNINativeMethod g_statementCreateViewMethods[] = {\n    { \"createCppObj\", \"()J\", (void *) WCDBJNIStatementCreateViewFuncName(createCppObj) },\n    { \"configView\",\n      \"(J\" WCDBJNIStringSignature \")V\",\n      (void *) WCDBJNIStatementCreateViewFuncName(configView) },\n    { \"configSchema\",\n      \"(J\" WCDBJNIObjectOrStringSignature \")V\",\n      (void *) WCDBJNIStatementCreateViewFuncName(configSchema) },\n    { \"configTemp\", \"(J)V\", (void *) WCDBJNIStatementCreateViewFuncName(configTemp) },\n    { \"configIfNotExist\", \"(J)V\", (void *) WCDBJNIStatementCreateViewFuncName(configIfNotExist) },\n    { \"configColumns\",\n      \"(J\" WCDBJNIObjectOrStringArraySignature \")V\",\n      (void *) WCDBJNIStatementCreateViewFuncName(configColumns) },\n    { \"configAs\", \"(JJ)V\", (void *) WCDBJNIStatementCreateViewFuncName(configAs) },\n};\n\nstatic const JNINativeMethod g_statementDropIndexMethods[] = {\n    { \"createCppObj\", \"()J\", (void *) WCDBJNIStatementDropIndexFuncName(createCppObj) },\n    { \"configIndex\",\n      \"(J\" WCDBJNIStringSignature \")V\",\n      (void *) WCDBJNIStatementDropIndexFuncName(configIndex) },\n    { \"configSchema\",\n      \"(J\" WCDBJNIObjectOrStringSignature \")V\",\n      (void *) WCDBJNIStatementDropIndexFuncName(configSchema) },\n    { \"configIfExist\", \"(J)V\", (void *) WCDBJNIStatementDropIndexFuncName(configIfExist) },\n};\n\nstatic const JNINativeMethod g_statementDropTriggerMethods[] = {\n    { \"createCppObj\", \"()J\", (void *) WCDBJNIStatementDropTriggerFuncName(createCppObj) },\n    { \"configTrigger\",\n      \"(J\" WCDBJNIStringSignature \")V\",\n      (void *) WCDBJNIStatementDropTriggerFuncName(configTrigger) },\n    { \"configSchema\",\n      \"(J\" WCDBJNIObjectOrStringSignature \")V\",\n      (void *) WCDBJNIStatementDropTriggerFuncName(configSchema) },\n    { \"configIfExist\", \"(J)V\", (void *) WCDBJNIStatementDropTriggerFuncName(configIfExist) },\n};\n\nstatic const JNINativeMethod g_statementDropViewMethods[] = {\n    { \"createCppObj\", \"()J\", (void *) WCDBJNIStatementDropViewFuncName(createCppObj) },\n    { \"configView\",\n      \"(J\" WCDBJNIStringSignature \")V\",\n      (void *) WCDBJNIStatementDropViewFuncName(configView) },\n    { \"configSchema\",\n      \"(J\" WCDBJNIObjectOrStringSignature \")V\",\n      (void *) WCDBJNIStatementDropViewFuncName(configSchema) },\n    { \"configIfExist\", \"(J)V\", (void *) WCDBJNIStatementDropViewFuncName(configIfExist) },\n};\n\nstatic const JNINativeMethod g_statementExplainMethods[] = {\n    { \"createCppObj\", \"()J\", (void *) WCDBJNIStatementExplainFuncName(createCppObj) },\n    { \"explain\", \"(JJZ)V\", (void *) WCDBJNIStatementExplainFuncName(explain) },\n};\n\nstatic const JNINativeMethod g_statementReindexMethods[] = {\n    { \"createCppObj\", \"()J\", (void *) WCDBJNIStatementReindexFuncName(createCppObj) },\n    { \"configCollation\",\n      \"(J\" WCDBJNIStringSignature \")V\",\n      (void *) WCDBJNIStatementReindexFuncName(configCollation) },\n    { \"configTable\",\n      \"(J\" WCDBJNIStringSignature \")V\",\n      (void *) WCDBJNIStatementReindexFuncName(configTable) },\n    { \"configIndex\",\n      \"(J\" WCDBJNIStringSignature \")V\",\n      (void *) WCDBJNIStatementReindexFuncName(configIndex) },\n    { \"configSchema\",\n      \"(J\" WCDBJNIObjectOrStringSignature \")V\",\n      (void *) WCDBJNIStatementReindexFuncName(configSchema) },\n};\n\nstatic const JNINativeMethod g_statementReleaseMethods[] = {\n    { \"createCppObj\", \"()J\", (void *) WCDBJNIStatementReleaseFuncName(createCppObj) },\n    { \"configSavepoint\",\n      \"(J\" WCDBJNIStringSignature \")V\",\n      (void *) WCDBJNIStatementReleaseFuncName(configSavepoint) },\n};\n\nstatic const JNINativeMethod g_statementRollbackMethods[] = {\n    { \"createCppObj\", \"()J\", (void *) WCDBJNIStatementRollbackFuncName(createCppObj) },\n    { \"configSavepoint\",\n      \"(J\" WCDBJNIStringSignature \")V\",\n      (void *) WCDBJNIStatementRollbackFuncName(configSavepoint) },\n};\n\nstatic const JNINativeMethod g_statementVacuumMethods[] = {\n    { \"createCppObj\", \"()J\", (void *) WCDBJNIStatementVacuumFuncName(createCppObj) },\n    { \"configSchema\",\n      \"(J\" WCDBJNIObjectOrStringSignature \")V\",\n      (void *) WCDBJNIStatementVacuumFuncName(configSchema) },\n};\n\nstatic const JNINativeMethod g_tableBindingMethods[] = {\n    { \"createCppObj\", \"()J\", (void *) WCDBJNIBindingFuncName(create) },\n    { \"addColumnDef\", \"(JJ)V\", (void *) WCDBJNIBindingFuncName(addColumnDef) },\n    { \"enableAutoIncrementForExistingTable\",\n      \"(J)V\",\n      (void *) WCDBJNIBindingFuncName(enableAutoIncrementForExistingTable) },\n    { \"addIndex\", \"(J\" WCDBJNIStringSignature \"ZJ)V\", (void *) WCDBJNIBindingFuncName(addIndex) },\n    { \"addTableConstraint\", \"(JJ)V\", (void *) WCDBJNIBindingFuncName(addTableConstraint) },\n    { \"configVirtualModule\",\n      \"(J\" WCDBJNIStringSignature \")V\",\n      (void *) WCDBJNIBindingFuncName(configVirtualModule) },\n    { \"configVirtualModuleArgument\",\n      \"(J\" WCDBJNIStringSignature \")V\",\n      (void *) WCDBJNIBindingFuncName(configVirtualModuleArgument) },\n    { \"configWithoutRowId\", \"(J)V\", (void *) WCDBJNIBindingFuncName(configWithoutRowId) },\n    { \"createTable\", \"(J\" WCDBJNIStringSignature \"J)Z\", (void *) WCDBJNIBindingFuncName(createTable) },\n    { \"createVirtualTable\",\n      \"(J\" WCDBJNIStringSignature \"J)Z\",\n      (void *) WCDBJNIBindingFuncName(createVirtualTable) },\n    { \"getBaseBinding\", \"(J)J\", (void *) WCDBJNIBindingFuncName(getBaseBinding) },\n};\n\nstatic const JNINativeMethod g_exceptionMethods[] = {\n    { \"getLevel\", \"(J)I\", (void *) WCDBJNIErrorFuncName(getLevel) },\n    { \"getCode\", \"(J)I\", (void *) WCDBJNIErrorFuncName(getCode) },\n    { \"getMessage\", \"(J)\" WCDBJNIStringSignature, (void *) WCDBJNIErrorFuncName(getMessage) },\n    { \"enumerateInfo\", \"(J)V\", (void *) WCDBJNIErrorFuncName(enumerateInfo) },\n};\n\nstatic const JNINativeMethod g_handleStatementMethods[] = {\n    { \"getError\", \"(J)J\", (void *) WCDBJNIHandleStatementFuncName(getError) },\n    { \"prepare\", \"(JJ)Z\", (void *) WCDBJNIHandleStatementFuncName(prepare) },\n    { \"prepareSQL\", \"(J\" WCDBJNIStringSignature \")Z\", (void *) WCDBJNIHandleStatementFuncName(prepareSQL) },\n    { \"checkPrepared\", \"(J)Z\", (void *) WCDBJNIHandleStatementFuncName(checkPrepared) },\n    { \"step\", \"(J)Z\", (void *) WCDBJNIHandleStatementFuncName(step) },\n    { \"reset\", \"(J)V\", (void *) WCDBJNIHandleStatementFuncName(reset) },\n    { \"clearBindings\", \"(J)V\", (void *) WCDBJNIHandleStatementFuncName(clearBindings) },\n    { \"finalize\", \"(J)V\", (void *) WCDBJNIHandleStatementFuncName(finalize) },\n    { \"isDone\", \"(J)Z\", (void *) WCDBJNIHandleStatementFuncName(isDone) },\n    { \"bindInteger\", \"(JJI)V\", (void *) WCDBJNIHandleStatementFuncName(bindInteger) },\n    { \"bindDouble\", \"(JDI)V\", (void *) WCDBJNIHandleStatementFuncName(bindDouble) },\n    { \"bindText\", \"(J\" WCDBJNIStringSignature \"I)V\", (void *) WCDBJNIHandleStatementFuncName(bindText) },\n    { \"bindBLOB\", \"(J[BI)V\", (void *) WCDBJNIHandleStatementFuncName(bindBLOB) },\n    { \"bindNull\", \"(JI)V\", (void *) WCDBJNIHandleStatementFuncName(bindNull) },\n    { \"getColumnType\", \"(JI)I\", (void *) WCDBJNIHandleStatementFuncName(getColumnType) },\n    { \"getInteger\", \"(JI)J\", (void *) WCDBJNIHandleStatementFuncName(getInteger) },\n    { \"getDouble\", \"(JI)D\", (void *) WCDBJNIHandleStatementFuncName(getDouble) },\n    { \"getText\", \"(JI)\" WCDBJNIStringSignature, (void *) WCDBJNIHandleStatementFuncName(getText) },\n    { \"getBLOB\", \"(JI)[B\", (void *) WCDBJNIHandleStatementFuncName(getBLOB) },\n    { \"getColumnCount\", \"(J)I\", (void *) WCDBJNIHandleStatementFuncName(getColumnCount) },\n    { \"bindParameterIndex\",\n      \"(J\" WCDBJNIStringSignature \")I\",\n      (void *) WCDBJNIHandleStatementFuncName(bindParameterIndex) },\n    { \"getColumnName\",\n      \"(JI)\" WCDBJNIStringSignature,\n      (void *) WCDBJNIHandleStatementFuncName(getColumnName) },\n    { \"getOriginalColumnName\",\n      \"(JI)\" WCDBJNIStringSignature,\n      (void *) WCDBJNIHandleStatementFuncName(getOriginalColumnName) },\n    { \"getColumnTableName\",\n      \"(JI)\" WCDBJNIStringSignature,\n      (void *) WCDBJNIHandleStatementFuncName(getColumnTableName) },\n    { \"getColumnName\",\n      \"(JI)\" WCDBJNIStringSignature,\n      (void *) WCDBJNIHandleStatementFuncName(getColumnName) },\n    { \"isReadOnly\", \"(J)Z\", (void *) WCDBJNIHandleStatementFuncName(isReadOnly) },\n};\n\nstatic const JNINativeMethod g_handleMethods[] = {\n    { \"getError\", \"(J)J\", (void *) WCDBJNIHandleFuncName(getError) },\n    { \"getOrCreatePreparedStatement\", \"(JJ)J\", (void *) WCDBJNIHandleFuncName(getOrCreatePreparedStatement) },\n    { \"getOrCreatePreparedStatementWithSQL\",\n      \"(J\" WCDBJNIStringSignature \")J\",\n      (void *) WCDBJNIHandleFuncName(getOrCreatePreparedStatementWithSQL) },\n    { \"prepareNewStatement\", \"(JJ)J\", (void *) WCDBJNIHandleFuncName(prepareNewStatement) },\n    { \"prepareNewStatementWithSQL\",\n      \"(J\" WCDBJNIStringSignature \")J\",\n      (void *) WCDBJNIHandleFuncName(prepareNewStatementWithSQL) },\n    { \"getMainStatement\", \"(J)J\", (void *) WCDBJNIHandleFuncName(getMainStatement) },\n    { \"finalizeAndReturnPreparedStatement\", \"(JJ)V\", (void *) WCDBJNIHandleFuncName(finalizeAndReturnPreparedStatement) },\n    { \"finalizeAllStatements\", \"(J)V\", (void *) WCDBJNIHandleFuncName(finalizeAllStatements) },\n    { \"execute\", \"(JJ)Z\", (void *) WCDBJNIHandleFuncName(execute) },\n    { \"executeSQL\", \"(J\" WCDBJNIStringSignature \")Z\", (void *) WCDBJNIHandleFuncName(executeSQL) },\n    { \"tableExist\", \"(J\" WCDBJNIStringSignature \")I\", (void *) WCDBJNIHandleFuncName(tableExist) },\n    { \"getChanges\", \"(J)I\", (void *) WCDBJNIHandleFuncName(getChanges) },\n    { \"getTotalChanges\", \"(J)I\", (void *) WCDBJNIHandleFuncName(getTotalChanges) },\n    { \"getLastInsertedRowId\", \"(J)J\", (void *) WCDBJNIHandleFuncName(getLastInsertRowid) },\n    { \"isInTransaction\", \"(J)Z\", (void *) WCDBJNIHandleFuncName(isInTransaction) },\n    { \"beginTransaction\", \"(J)Z\", (void *) WCDBJNIHandleFuncName(beginTransaction) },\n    { \"commitTransaction\", \"(J)Z\", (void *) WCDBJNIHandleFuncName(commitTransaction) },\n    { \"rollbackTransaction\", \"(J)V\", (void *) WCDBJNIHandleFuncName(rollbackTransaction) },\n    { \"runTransaction\",\n      \"(JLcom/tencent/wcdb/core/Transaction;)Z\",\n      (void *) WCDBJNIHandleFuncName(runTransaction) },\n    { \"runPausableTransaction\",\n      \"(JLcom/tencent/wcdb/core/PausableTransaction;)Z\",\n      (void *) WCDBJNIHandleFuncName(runPausableTransaction) },\n    { \"createCancellationSignal\", \"()J\", (void *) WCDBJNIHandleFuncName(createCancellationSignal) },\n    { \"cancelSignal\", \"(J)V\", (void *) WCDBJNIHandleFuncName(cancelSignal) },\n    { \"attachCancellationSignal\", \"(JJ)V\", (void *) WCDBJNIHandleFuncName(attachCancellationSignal) },\n    { \"detachCancellationSignal\", \"(J)V\", (void *) WCDBJNIHandleFuncName(detachCancellationSignal) },\n};\n\nstatic const JNINativeMethod g_databaseMethods[] = {\n    { \"createDatabase\", \"(\" WCDBJNIStringSignature \"ZZ)J\", (void *) WCDBJNICoreFuncName(createDatabase) },\n    { \"setDefaultCipherVersion\", \"(I)V\", (void *) WCDBJNICoreFuncName(setDefaultCipherConfig) },\n    { \"getNumberOfAliveHandle\", \"(J)I\", (void *) WCDBJNIDatabaseFuncName(getNumberOfAliveHandle) },\n    { \"getError\", \"(J)J\", (void *) WCDBJNIDatabaseFuncName(getError) },\n    { \"getThreadedError\", \"()J\", (void *) WCDBJNICoreFuncName(getThreadedError) },\n    { \"getPath\", \"(J)\" WCDBJNIStringSignature, (void *) WCDBJNIDatabaseFuncName(getPath) },\n    { \"getPaths\", \"(J)Ljava/util/List;\", (void *) WCDBJNIDatabaseFuncName(getPaths) },\n    { \"setTag\", \"(JJ)V\", (void *) WCDBJNIDatabaseFuncName(setTag) },\n    { \"getTag\", \"(J)J\", (void *) WCDBJNIDatabaseFuncName(getTag) },\n    { \"canOpen\", \"(J)Z\", (void *) WCDBJNIDatabaseFuncName(canOpen) },\n    { \"isOpened\", \"(J)Z\", (void *) WCDBJNIDatabaseFuncName(isOpened) },\n    { \"close\",\n      \"(J\" WCDBJNIDatabaseSignature \"$CloseCallBack;)V\",\n      (void *) WCDBJNIDatabaseFuncName(close) },\n    { \"blockade\", \"(J)V\", (void *) WCDBJNIDatabaseFuncName(blockade) },\n    { \"unblockade\", \"(J)V\", (void *) WCDBJNIDatabaseFuncName(unblockade) },\n    { \"isBlockaded\", \"(J)Z\", (void *) WCDBJNIDatabaseFuncName(isBlockaded) },\n    { \"purge\", \"(J)V\", (void *) WCDBJNIDatabaseFuncName(purge) },\n    { \"purgeAll\", \"()V\", (void *) WCDBJNICoreFuncName(purgeAllDatabase) },\n    { \"releaseSQLiteMemory\", \"(I)V\", (void *) WCDBJNICoreFuncName(releaseSQLiteMemory) },\n    { \"setSoftHeapLimit\", \"(J)V\", (void *) WCDBJNICoreFuncName(setSoftHeapLimit) },\n    { \"getHandle\", \"(JZ)J\", (void *) WCDBJNIDatabaseFuncName(getHandle) },\n    { \"setCipherKey\", \"(J[BII)V\", (void *) WCDBJNIDatabaseFuncName(configCipher) },\n    { \"setConfig\",\n      \"(J\" WCDBJNIStringSignature WCDBJNIDatabaseSignature\n      \"$Config;\" WCDBJNIDatabaseSignature \"$Config;I)V\",\n      (void *) WCDBJNIDatabaseFuncName(config) },\n    { \"enableLiteMode\", \"(JZ)V\", (void *) WCDBJNIDatabaseFuncName(enableLiteMode) },\n    { \"globalTracePerformance\",\n      \"(\" WCDBJNIDatabaseSignature \"$PerformanceTracer;)V\",\n      (void *) WCDBJNIDatabaseFuncName(globalTracePerformance) },\n    { \"tracePerformance\",\n      \"(J\" WCDBJNIDatabaseSignature \"$PerformanceTracer;)V\",\n      (void *) WCDBJNIDatabaseFuncName(tracePerformance) },\n    { \"globalTraceSQL\",\n      \"(\" WCDBJNIDatabaseSignature \"$SQLTracer;)V\",\n      (void *) WCDBJNIDatabaseFuncName(globalTraceSQL) },\n    { \"traceSQL\",\n      \"(J\" WCDBJNIDatabaseSignature \"$SQLTracer;)V\",\n      (void *) WCDBJNIDatabaseFuncName(traceSQL) },\n    { \"setFullSQLTraceEnable\", \"(JZ)V\", (void *) WCDBJNIDatabaseFuncName(setFullSQLTraceEnable) },\n    { \"globalTraceException\",\n      \"(\" WCDBJNIDatabaseSignature \"$ExceptionTracer;)V\",\n      (void *) WCDBJNIDatabaseFuncName(globalTraceError) },\n    { \"traceException\",\n      \"(J\" WCDBJNIDatabaseSignature \"$ExceptionTracer;)V\",\n      (void *) WCDBJNIDatabaseFuncName(traceError) },\n    { \"globalTraceDatabaseOperation\",\n      \"(\" WCDBJNIDatabaseSignature \"$OperationTracer;)V\",\n      (void *) WCDBJNIDatabaseFuncName(globalTraceOperation) },\n    { \"globalTraceBusy\",\n      \"(\" WCDBJNIDatabaseSignature \"$BusyTracer;D)V\",\n      (void *) WCDBJNIDatabaseFuncName(globalTraceDatabaseBusy) },\n    { \"enumerateInfo\", \"(Ljava/util/HashMap;J)V\", (void *) WCDBJNIDatabaseFuncName(enumerateInfo) },\n    { \"removeFiles\", \"(J)Z\", (void *) WCDBJNIDatabaseFuncName(removeFiles) },\n    { \"moveFile\", \"(J\" WCDBJNIStringSignature \")Z\", (void *) WCDBJNIDatabaseFuncName(moveFile) },\n    { \"getFileSize\", \"(J)J\", (void *) WCDBJNIDatabaseFuncName(getFileSize) },\n    { \"addTokenizer\", \"(J\" WCDBJNIStringSignature \")V\", (void *) WCDBJNIDatabaseFuncName(addTokenizer) },\n    { \"configPinyinDict\",\n      \"([\" WCDBJNIStringSignature \"[[\" WCDBJNIStringSignature \")V\",\n      (void *) WCDBJNIDatabaseFuncName(configPinyinDict) },\n    { \"configTraditionalChineseDict\",\n      \"([\" WCDBJNIStringSignature \"[\" WCDBJNIStringSignature \")V\",\n      (void *) WCDBJNIDatabaseFuncName(configTraditionalChineseDict) },\n\n    { \"addAuxiliaryFunction\",\n      \"(J\" WCDBJNIStringSignature \")V\",\n      (void *) WCDBJNIDatabaseFuncName(addAuxiliaryFunction) },\n    { \"setNotificationWhenCorrupted\",\n      \"(J\" WCDBJNIDatabaseSignature \"$CorruptionNotification;)V\",\n      (void *) WCDBJNIDatabaseFuncName(setNotificationWhenCorrupted) },\n    { \"checkIfCorrupted\", \"(J)Z\", (void *) WCDBJNIDatabaseFuncName(checkIfCorrupted) },\n    { \"checkIfIsAlreadyCorrupted\", \"(J)Z\", (void *) WCDBJNIDatabaseFuncName(checkIfIsAlreadyCorrupted) },\n    { \"enableAutoBackup\", \"(JZ)V\", (void *) WCDBJNIDatabaseFuncName(enableAutoBackup) },\n    { \"backup\", \"(J)Z\", (void *) WCDBJNIDatabaseFuncName(backup) },\n    { \"filterBackup\",\n      \"(J\" WCDBJNIDatabaseSignature \"$BackupFilter;)V\",\n      (void *) WCDBJNIDatabaseFuncName(filterBackup) },\n    { \"retrieve\",\n      \"(J\" WCDBJNIDatabaseSignature \"$ProgressMonitor;)D\",\n      (void *) WCDBJNIDatabaseFuncName(retrieve) },\n    { \"vacuum\",\n      \"(J\" WCDBJNIDatabaseSignature \"$ProgressMonitor;)Z\",\n      (void *) WCDBJNIDatabaseFuncName(vacuum) },\n    { \"enableAutoVacuum\", \"(JZ)V\", (void *) WCDBJNIDatabaseFuncName(enableAutoVacuum) },\n    { \"incrementalVacuum\", \"(JI)Z\", (void *) WCDBJNIDatabaseFuncName(incrementalVacuum) },\n    { \"deposit\", \"(J)Z\", (void *) WCDBJNIDatabaseFuncName(deposit) },\n    { \"removeDepositedFiles\", \"(J)Z\", (void *) WCDBJNIDatabaseFuncName(removeDepositedFiles) },\n    { \"containDepositedFiles\", \"(J)Z\", (void *) WCDBJNIDatabaseFuncName(containDepositedFiles) },\n    { \"passiveCheckpoint\", \"(J)Z\", (void *) WCDBJNIDatabaseFuncName(passiveCheckpoint) },\n    { \"truncateCheckpoint\", \"(J)Z\", (void *) WCDBJNIDatabaseFuncName(truncateCheckpoint) },\n    { \"setAutoCheckpointEnable\", \"(JZ)V\", (void *) WCDBJNIDatabaseFuncName(setAutoCheckpointEnable) },\n    { \"setAutoCheckpointMinFrames\", \"(I)V\", (void *) WCDBJNICoreFuncName(setAutoCheckpointMinFrames) },\n    { \"addMigrationSource\",\n      \"(J\" WCDBJNIStringSignature \"[B\" WCDBJNIDatabaseSignature \"$MigrationFilter;)V\",\n      (void *) WCDBJNIDatabaseFuncName(addMigrationSource) },\n    { \"setMigrationInfo\",\n      \"(JJ\" WCDBJNIStringSignature \"J)V\",\n      (void *) WCDBJNIDatabaseFuncName(setMigrationInfo) },\n    { \"stepMigration\", \"(J)Z\", (void *) WCDBJNIDatabaseFuncName(stepMigration) },\n    { \"enableAutoMigration\", \"(JZ)V\", (void *) WCDBJNIDatabaseFuncName(enableAutoMigration) },\n    { \"setNotificationWhenMigrated\",\n      \"(J\" WCDBJNIDatabaseSignature \"$MigrationNotification;)V\",\n      (void *) WCDBJNIDatabaseFuncName(setNotificationWhenMigrated) },\n    { \"isMigrated\", \"(J)Z\", (void *) WCDBJNIDatabaseFuncName(isMigrated) },\n    { \"trainDict\", \"([\" WCDBJNIStringSignature \"B)[B\", (void *) WCDBJNIDatabaseFuncName(trainDictWithStrings) },\n    { \"trainDict\", \"([[BB)[B\", (void *) WCDBJNIDatabaseFuncName(trainDictWithDatas) },\n    { \"nativeRegisterDict\", \"([BB)Z\", (void *) WCDBJNIDatabaseFuncName(registerDict) },\n    { \"addZSTDNormalCompress\", \"(JJ)V\", (void *) WCDBJNIDatabaseFuncName(addZSTDNormalCompress) },\n    { \"addZSTDDictCompress\", \"(JJB)V\", (void *) WCDBJNIDatabaseFuncName(addZSTDDictCompress) },\n    { \"addZSTDMultiDictCompress\", \"(JJJ[J[B)V\", (void *) WCDBJNIDatabaseFuncName(addZSTDMultiDictCompress) },\n    { \"enableReplaceCompression\", \"(J)V\", (void *) WCDBJNIDatabaseFuncName(enableReplaceCompression) },\n    { \"setCompression\",\n      \"(J\" WCDBJNIDatabaseSignature \"$CompressionFilter;)V\",\n      (void *) WCDBJNIDatabaseFuncName(setCompression) },\n    { \"disableCompressNewData\", \"(JZ)V\", (void *) WCDBJNIDatabaseFuncName(disableCompressNewData) },\n    { \"stepCompression\", \"(J)Z\", (void *) WCDBJNIDatabaseFuncName(stepCompression) },\n    { \"enableAutoCompression\", \"(JZ)V\", (void *) WCDBJNIDatabaseFuncName(enableAutoCompression) },\n    { \"setNotificationWhenCompressed\",\n      \"(J\" WCDBJNIDatabaseSignature \"$CompressionNotification;)V\",\n      (void *) WCDBJNIDatabaseFuncName(setNotificationWhenCompressed) },\n    { \"isCompressed\", \"(J)Z\", (void *) WCDBJNIDatabaseFuncName(isCompressed) },\n    { \"rollbackCompression\",\n      \"(J\" WCDBJNIDatabaseSignature \"$ProgressMonitor;)Z\",\n      (void *) WCDBJNIDatabaseFuncName(rollbackCompression) },\n};\n\nstatic const JNIBinding g_bindingInfo[] = {\n    WCDBJNIRegister(\"com/tencent/wcdb/base/CppObject\", g_objectBridgeMethods),\n    WCDBJNIRegister(\"com/tencent/wcdb/winq/Identifier\", g_winqBridgeMethods),\n    WCDBJNIRegister(\"com/tencent/wcdb/winq/LiteralValue\", g_literalValueMethods),\n    WCDBJNIRegister(\"com/tencent/wcdb/winq/Schema\", g_schemaMethods),\n    WCDBJNIRegister(\"com/tencent/wcdb/winq/Column\", g_columnMethods),\n    WCDBJNIRegister(\"com/tencent/wcdb/winq/BindParameter\", g_bindParameterMethods),\n    WCDBJNIRegister(\"com/tencent/wcdb/winq/Expression\", g_expressionMethods),\n    WCDBJNIRegister(\"com/tencent/wcdb/winq/ExpressionOperable\", g_expressionOperationMethods),\n    WCDBJNIRegister(\"com/tencent/wcdb/winq/ColumnConstraint\", g_columnConstraintMethods),\n    WCDBJNIRegister(\"com/tencent/wcdb/winq/OrderingTerm\", g_orderingTermMethods),\n    WCDBJNIRegister(\"com/tencent/wcdb/winq/ColumnDef\", g_columnDefMethods),\n    WCDBJNIRegister(\"com/tencent/wcdb/winq/IndexedColumn\", g_indexedColumnMethods),\n    WCDBJNIRegister(\"com/tencent/wcdb/winq/TableOrSubquery\", g_tableOrSubqueryMethods),\n    WCDBJNIRegister(\"com/tencent/wcdb/winq/QualifiedTable\", g_qualifiedTableMethods),\n    WCDBJNIRegister(\"com/tencent/wcdb/winq/ResultColumn\", g_resultColumnMethods),\n    WCDBJNIRegister(\"com/tencent/wcdb/winq/TableConstraint\", g_tableConstraintMethods),\n    WCDBJNIRegister(\"com/tencent/wcdb/winq/Pragma\", g_pragmaMethods),\n    WCDBJNIRegister(\"com/tencent/wcdb/winq/CommonTableExpression\", g_commonTableExpressionMethods),\n    WCDBJNIRegister(\"com/tencent/wcdb/winq/ForeignKey\", g_foreignKeyMethods),\n    WCDBJNIRegister(\"com/tencent/wcdb/winq/FrameSpec\", g_frameSpecMethods),\n    WCDBJNIRegister(\"com/tencent/wcdb/winq/Join\", g_joinMethods),\n    WCDBJNIRegister(\"com/tencent/wcdb/winq/RaiseFunction\", g_raiseFunctionMethods),\n    WCDBJNIRegister(\"com/tencent/wcdb/winq/Upsert\", g_upsertMethods),\n    WCDBJNIRegister(\"com/tencent/wcdb/winq/WindowDef\", g_windowDefMethods),\n    WCDBJNIRegister(\"com/tencent/wcdb/winq/StatementAlterTable\", g_statementAlterTableMethods),\n    WCDBJNIRegister(\"com/tencent/wcdb/winq/StatementAnalyze\", g_statementAnalyzeMethods),\n    WCDBJNIRegister(\"com/tencent/wcdb/winq/StatementAttach\", g_statementAttachMethods),\n    WCDBJNIRegister(\"com/tencent/wcdb/winq/StatementBegin\", g_statementBeginMethods),\n    WCDBJNIRegister(\"com/tencent/wcdb/winq/StatementCommit\", g_statementCommitMethods),\n    WCDBJNIRegister(\"com/tencent/wcdb/winq/StatementCreateIndex\", g_statementCreateIndexMethods),\n    WCDBJNIRegister(\"com/tencent/wcdb/winq/StatementCreateTable\", g_statementCreateTableMethods),\n    WCDBJNIRegister(\"com/tencent/wcdb/winq/StatementCreateVirtualTable\",\n                    g_statementCreateVirtualTableMethods),\n    WCDBJNIRegister(\"com/tencent/wcdb/winq/StatementCreateTrigger\", g_statementCreateTriggerMethods),\n    WCDBJNIRegister(\"com/tencent/wcdb/winq/StatementCreateView\", g_statementCreateViewMethods),\n    WCDBJNIRegister(\"com/tencent/wcdb/winq/StatementDelete\", g_statementDeleteMethods),\n    WCDBJNIRegister(\"com/tencent/wcdb/winq/StatementDetach\", g_statementDetachMethods),\n    WCDBJNIRegister(\"com/tencent/wcdb/winq/StatementDropIndex\", g_statementDropIndexMethods),\n    WCDBJNIRegister(\"com/tencent/wcdb/winq/StatementDropTable\", g_statementDropTableMethods),\n    WCDBJNIRegister(\"com/tencent/wcdb/winq/StatementDropTrigger\", g_statementDropTriggerMethods),\n    WCDBJNIRegister(\"com/tencent/wcdb/winq/StatementDropView\", g_statementDropViewMethods),\n    WCDBJNIRegister(\"com/tencent/wcdb/winq/StatementExplain\", g_statementExplainMethods),\n    WCDBJNIRegister(\"com/tencent/wcdb/winq/StatementInsert\", g_statementInsertMethods),\n    WCDBJNIRegister(\"com/tencent/wcdb/winq/StatementPragma\", g_statementPragmaMethods),\n    WCDBJNIRegister(\"com/tencent/wcdb/winq/StatementReindex\", g_statementReindexMethods),\n    WCDBJNIRegister(\"com/tencent/wcdb/winq/StatementRelease\", g_statementReleaseMethods),\n    WCDBJNIRegister(\"com/tencent/wcdb/winq/StatementRollback\", g_statementRollbackMethods),\n    WCDBJNIRegister(\"com/tencent/wcdb/winq/StatementSelect\", g_statementSelectMethods),\n    WCDBJNIRegister(\"com/tencent/wcdb/winq/StatementUpdate\", g_statementUpdateMethods),\n    WCDBJNIRegister(\"com/tencent/wcdb/winq/StatementVacuum\", g_statementVacuumMethods),\n    WCDBJNIRegister(\"com/tencent/wcdb/orm/Binding\", g_tableBindingMethods),\n    WCDBJNIRegister(\"com/tencent/wcdb/base/WCDBException\", g_exceptionMethods),\n    WCDBJNIRegister(\"com/tencent/wcdb/core/PreparedStatement\", g_handleStatementMethods),\n    WCDBJNIRegister(\"com/tencent/wcdb/core/Handle\", g_handleMethods),\n    WCDBJNIRegister(\"com/tencent/wcdb/core/Database\", g_databaseMethods),\n};\n\nJNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *unused)\n{\n    JNIEnv *env = NULL;\n    jint result = JNI_ERR;\n\n    if ((*vm)->GetEnv(vm, (void **) &env, JNI_VERSION_1_6) != JNI_OK) {\n        return result;\n    }\n\n    for (int i = 0; i < sizeof(g_bindingInfo) / sizeof(JNIBinding); i++) {\n        jclass clazz = (*env)->FindClass(env, g_bindingInfo[i].className);\n        if (clazz == NULL) {\n            (*env)->DeleteLocalRef(env, clazz);\n            return result;\n        }\n        if ((*env)->RegisterNatives(\n            env, clazz, g_bindingInfo[i].methods, g_bindingInfo[i].methodCount)\n            < 0) {\n            return result;\n        }\n        (*env)->DeleteLocalRef(env, clazz);\n    }\n    WCDBJNIInitJClasses(env);\n    result = JNI_VERSION_1_6;\n    return result;\n}\n"
  },
  {
    "path": "src/java/main/src/main/cpp/base/ErrorJNI.c",
    "content": "// Created by qiuwenchen on 2023/4/21.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"ErrorJNI.h\"\n#include \"ErrorBridge.h\"\n#include \"assert.h\"\n\njlong WCDBJNIErrorClassMethod(getLevel, jlong error)\n{\n    WCDBJNIBridgeStruct(CPPError, error);\n    return WCDBErrorGetLevel(errorStruct);\n}\n\njlong WCDBJNIErrorClassMethod(getCode, jlong error)\n{\n    WCDBJNIBridgeStruct(CPPError, error);\n    return WCDBErrorGetCode(errorStruct);\n}\n\njstring WCDBJNIErrorClassMethod(getMessage, jlong error)\n{\n    WCDBJNIBridgeStruct(CPPError, error);\n    WCDBJNICreateJStringAndReturn(WCDBErrorGetMsg(errorStruct));\n}\n\ntypedef struct JNIContext {\n    JNIEnv *env;\n    jobject object;\n} JNIContext;\n\nvoid WCDBJNIErrorEnumerateInfoCallback(JNIContext *context, const char *key, CPPCommonValue value)\n{\n    JNIEnv *env = context->env;\n    static jmethodID g_methodId = NULL;\n    jlong intValue = 0;\n    double doubleValue = 0;\n    const char *stringValue = NULL;\n    switch (value.type) {\n    case WCDBBridgedType_Int:\n        intValue = (jlong) value.intValue;\n        break;\n    case WCDBBridgedType_Double:\n        doubleValue = value.doubleValue;\n        break;\n    case WCDBBridgedType_String:\n        stringValue = (const char *) value.intValue;\n        break;\n    default:\n        break;\n    }\n\n    if (g_methodId == NULL) {\n        g_methodId = (*env)->GetMethodID(\n        env, WCDBJNIGetExceptionClass(), \"addInfo\", \"(Ljava/lang/String;IJDLjava/lang/String;)V\");\n        if (g_methodId == NULL) {\n            assert(0);\n            return;\n        }\n    }\n    WCDBJNICreateJavaString(key);\n    WCDBJNICreateJavaString(stringValue);\n    (*env)->CallVoidMethod(\n    env, context->object, g_methodId, jkey, (int) value.type, intValue, doubleValue, jstringValue);\n}\n\nvoid WCDBJNIErrorObjectMethod(enumerateInfo, jlong error)\n{\n    WCDBJNIBridgeStruct(CPPError, error);\n    JNIContext context;\n    context.env = env;\n    context.object = obj;\n    WCDBErrorEnumerateAllInfo(\n    errorStruct, (void *) &context, (StringViewMapEnumerator) &WCDBJNIErrorEnumerateInfoCallback);\n}\n"
  },
  {
    "path": "src/java/main/src/main/cpp/base/ErrorJNI.h",
    "content": "// Created by qiuwenchen on 2023/4/21.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"WCDBJNI.h\"\n\n#define WCDBJNIErrorFuncName(funcName) WCDBJNI(Error, funcName)\n#define WCDBJNIErrorObjectMethod(funcName, ...)                                \\\n    WCDBJNIObjectMethod(Error, funcName, __VA_ARGS__)\n#define WCDBJNIErrorClassMethodWithNoArg(funcName)                             \\\n    WCDBJNIClassMethodWithNoArg(Error, funcName)\n#define WCDBJNIErrorClassMethod(funcName, ...)                                 \\\n    WCDBJNIClassMethod(Error, funcName, __VA_ARGS__)\n\njlong WCDBJNIErrorClassMethod(getLevel, jlong error);\njlong WCDBJNIErrorClassMethod(getCode, jlong error);\njstring WCDBJNIErrorClassMethod(getMessage, jlong error);\nvoid WCDBJNIErrorObjectMethod(enumerateInfo, jlong error);\n"
  },
  {
    "path": "src/java/main/src/main/cpp/base/WCDBExtendJNI.cpp",
    "content": "// Created by chenqiuwen on 2024/10/31.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"WCDBJNI.h\"\n#include <thread>\n\nclass DetachVM {\npublic:\n    ~DetachVM()\n    {\n        if (g_vm != NULL) {\n            g_vm->DetachCurrentThread();\n        }\n    }\n};\n\nvoid WCDBJNIRegisterDetachVM()\n{\n    thread_local DetachVM detachVm;\n}\n"
  },
  {
    "path": "src/java/main/src/main/cpp/base/WCDBJNI.c",
    "content": "// Created by qiuwenchen on 2023/3/30.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"WCDBJNI.h\"\n#include \"ObjectBridge.h\"\n#include \"assert.h\"\n#include <string.h>\n\n#define LIKELY(exp) (__builtin_expect((exp) != 0, true))\n#define UNLIKELY(exp) (__builtin_expect((exp) != 0, false))\n\nJavaVM* g_vm = NULL;\n\nvoid WCDBJNIDestructContext(jobject config)\n{\n    WCDBJNITryGetEnvOr(return);\n    (*env)->DeleteGlobalRef(env, config);\n    WCDBJNITryDetach;\n}\n\nvoid WCDBJNIClassMethod(Base, releaseObject, long long cppObject)\n{\n    WCDBReleaseCPPObject((CPPObject*) cppObject);\n}\n\njclass g_databaseClass = NULL;\njclass g_handleClass = NULL;\njclass g_exceptionClass = NULL;\n\nvoid WCDBJNIInitJClasses(JNIEnv* env)\n{\n    g_databaseClass = (*env)->FindClass(env, \"com/tencent/wcdb/core/Database\");\n    WCDBJNICreateGlobalRel(g_databaseClass);\n    assert(g_databaseClass != NULL);\n\n    g_handleClass = (*env)->FindClass(env, \"com/tencent/wcdb/core/Handle\");\n    WCDBJNICreateGlobalRel(g_handleClass);\n    assert(g_handleClass != NULL);\n\n    g_exceptionClass = (*env)->FindClass(env, \"com/tencent/wcdb/base/WCDBException\");\n    WCDBJNICreateGlobalRel(g_exceptionClass);\n    assert(g_exceptionClass != NULL);\n}\n\njclass WCDBJNIGetDatabaseClass()\n{\n    return g_databaseClass;\n}\n\njclass WCDBJNIGetHandleClass()\n{\n    return g_handleClass;\n}\n\njclass WCDBJNIGetExceptionClass()\n{\n    return g_exceptionClass;\n}\n\nstatic jsize utf16_to_utf8_length(const jchar* src, jsize src_len);\nstatic void utf16_to_utf8(const jchar* src, jsize src_len, char* dst, jsize dst_len);\nstatic jsize utf8_to_utf16_length(const char* u8str, jsize u8len);\nstatic jchar* utf8_to_utf16(const char* u8str, jsize u8len, jchar* u16str, jsize u16len);\n\nvoid WCDBJNIGetUTF8String(JNIEnv* env, jstring value, char** utf8String, const jchar** utf16String, bool critical)\n{\n    if (UNLIKELY(value == NULL)) {\n        *utf8String = NULL;\n        return;\n    }\n    jsize utf16Length = (*env)->GetStringLength(env, value);\n    if (LIKELY(critical)) {\n        *utf16String = (*env)->GetStringCritical(env, value, 0);\n    } else {\n        *utf16String = (*env)->GetStringChars(env, value, 0);\n    }\n    jsize utf8Length = utf16_to_utf8_length(*utf16String, utf16Length);\n    char** preAllocSlot = WCDBPreAllocStringMemorySlot(1);\n    if (UNLIKELY(preAllocSlot == NULL)) {\n        *utf8String = NULL;\n        return;\n    }\n    WCDBAllocStringMemory(preAllocSlot, (int) utf8Length);\n    if (UNLIKELY(*preAllocSlot == NULL)) {\n        *utf8String = NULL;\n        return;\n    }\n    *utf8String = *preAllocSlot;\n    utf16_to_utf8(*utf16String, utf16Length, *utf8String, utf8Length);\n}\n\nvoid WCDBJNIGetUTF8StringArray(JNIEnv* env, jobjectArray value, char*** stringArray, int* length)\n{\n    if (UNLIKELY(value == NULL)) {\n        return;\n    }\n    int valueLength = (*env)->GetArrayLength(env, value);\n    if (UNLIKELY(valueLength <= 0)) {\n        return;\n    }\n    char** preAllocSlot = WCDBPreAllocStringMemorySlot(valueLength);\n    if (UNLIKELY(preAllocSlot == NULL)) {\n        return;\n    }\n    for (int i = 0; i < valueLength; i++) {\n        jstring curString = (jstring) (*env)->GetObjectArrayElement(env, value, i);\n        if (UNLIKELY(curString == NULL)) {\n            continue;\n        }\n        jsize utf16Length = (*env)->GetStringLength(env, curString);\n        const jchar* utf16String = (*env)->GetStringCritical(env, curString, 0);\n        jsize utf8Length = utf16_to_utf8_length(utf16String, utf16Length);\n        char** curSlot = preAllocSlot + i;\n        WCDBAllocStringMemory(curSlot, utf8Length);\n        if (UNLIKELY(*curSlot == NULL)) {\n            (*env)->ReleaseStringCritical(env, curString, utf16String);\n            (*env)->DeleteLocalRef(env, curString);\n            WCDBClearAllocatedMemory(valueLength);\n            return;\n        }\n        utf16_to_utf8(utf16String, utf16Length, *curSlot, utf8Length);\n        (*env)->ReleaseStringCritical(env, curString, utf16String);\n        (*env)->DeleteLocalRef(env, curString);\n    }\n    *length = valueLength;\n    *stringArray = preAllocSlot;\n}\n\njstring WCDBJNICreateJString(JNIEnv* env, const char* utf8String)\n{\n    if (utf8String == NULL) {\n        return NULL;\n    }\n    jsize u8len = (jsize) strlen(utf8String);\n    jsize utf16Length = utf8_to_utf16_length(utf8String, u8len);\n    jchar* utf16Buffer = NULL;\n    bool needFree = false;\n    if (LIKELY(utf16Length < 1000)) {\n        utf16Buffer = alloca((utf16Length + 1) * sizeof(jchar));\n    } else {\n        utf16Buffer = malloc((utf16Length + 1) * sizeof(jchar));\n        needFree = true;\n    }\n    if (UNLIKELY(utf16Buffer == NULL)) {\n        return NULL;\n    }\n    jchar* utf16End = utf8_to_utf16(utf8String, u8len, utf16Buffer, utf16Length + 1);\n    jstring ret;\n    if (LIKELY(utf16End > utf16Buffer)) {\n        ret = (*env)->NewString(env, utf16Buffer, utf16End - utf16Buffer);\n    } else {\n        ret = (*env)->NewString(env, utf16Buffer, 0);\n    }\n    if (UNLIKELY(needFree)) {\n        free(utf16Buffer);\n    }\n    return ret;\n}\n\n/*\n * The code below is copied from:\n * https://cs.android.com/android/platform/superproject/main/+/main:system/core/libutils/Unicode.cpp;l=1?q=Unicode.cpp&ss=android%2Fplatform%2Fsuperproject%2Fmain\n */\n\n// is_any_surrogate() returns true if w is either a high or low surrogate\nstatic bool is_any_surrogate(jchar w)\n{\n    return (w & 0xf800) == 0xd800;\n}\n\n// is_surrogate_pair() returns true if w1 and w2 form a valid surrogate pair\nstatic bool is_surrogate_pair(jchar w1, jchar w2)\n{\n    return ((w1 & 0xfc00) == 0xd800) && ((w2 & 0xfc00) == 0xdc00);\n}\n\nstatic jsize utf16_to_utf8_length(const jchar* src, jsize src_len)\n{\n    if (src == NULL || src_len == 0) return 0;\n\n    const jchar* const end = src + src_len;\n    const jchar* in = src;\n    jsize utf8_len = 0;\n\n    while (in < end) {\n        jchar w = *in++;\n        if (LIKELY(w < 0x0080)) {\n            utf8_len += 1;\n            continue;\n        }\n        if (LIKELY(w < 0x0800)) {\n            utf8_len += 2;\n            continue;\n        }\n        if (LIKELY(!is_any_surrogate(w))) {\n            utf8_len += 3;\n            continue;\n        }\n        if (in < end && is_surrogate_pair(w, *in)) {\n            utf8_len += 4;\n            in++;\n            continue;\n        }\n        /* skip if at the end of the string or invalid surrogate pair */\n    }\n    return utf8_len;\n}\n\nstatic void utf16_to_utf8(const jchar* src, jsize src_len, char* dst, jsize dst_len)\n{\n    if (src == NULL || src_len == 0 || dst == NULL) {\n        return;\n    }\n\n    const jchar* in = src;\n    const jchar* const in_end = src + src_len;\n    char* out = dst;\n    const char* const out_end = dst + dst_len;\n    jchar w2;\n\n    while (in < in_end) {\n        jchar w = *in++;\n        if (LIKELY(w < 0x0080)) {\n            if (out + 1 > out_end) abort();\n            *out++ = (char) (w & 0xff);\n            continue;\n        }\n        if (LIKELY(w < 0x0800)) {\n            if (out + 2 > out_end) abort();\n            *out++ = (char) (0xc0 | ((w >> 6) & 0x1f));\n            *out++ = (char) (0x80 | ((w >> 0) & 0x3f));\n            continue;\n        }\n        if (LIKELY(!is_any_surrogate(w))) {\n            if (out + 3 > out_end) abort();\n            *out++ = (char) (0xe0 | ((w >> 12) & 0xf));\n            *out++ = (char) (0x80 | ((w >> 6) & 0x3f));\n            *out++ = (char) (0x80 | ((w >> 0) & 0x3f));\n            continue;\n        }\n        /* surrogate pair */\n        if (in < in_end && (w2 = *in, is_surrogate_pair(w, w2))) {\n            if (out + 4 > out_end) abort();\n            jint dw = (jint) (0x10000 + ((w - 0xd800) << 10) + (w2 - 0xdc00));\n            *out++ = (char) (0xf0 | ((dw >> 18) & 0x07));\n            *out++ = (char) (0x80 | ((dw >> 12) & 0x3f));\n            *out++ = (char) (0x80 | ((dw >> 6) & 0x3f));\n            *out++ = (char) (0x80 | ((dw >> 0) & 0x3f));\n            in++;\n        }\n        /* We reach here in two cases:\n         *  1) (in == in_end), which means end of the input string\n         *  2) (w2 & 0xfc00) != 0xdc00, which means invalid surrogate pair\n         * In either case, we intentionally do nothing and skip\n         */\n    }\n    *out = '\\0';\n}\n\nstatic uint32_t utf8_4b_to_utf32(uint8_t c1, uint8_t c2, uint8_t c3, uint8_t c4)\n{\n    return ((c1 & 0x07) << 18) | ((c2 & 0x3f) << 12) | ((c3 & 0x3f) << 6) | (c4 & 0x3f);\n}\n\n// TODO: current behavior of converting UTF8 to UTF-16 has a few issues below\n//\n// 1. invalid trailing bytes (i.e. not b'10xxxxxx) are treated as valid trailing\n//    bytes and follows normal conversion rules\n// 2. invalid leading byte (b'10xxxxxx) is treated as a valid single UTF-8 byte\n// 3. invalid leading byte (b'11111xxx) is treated as a valid leading byte\n//    (same as b'11110xxx) for a 4-byte UTF-8 sequence\n// 4. an invalid 4-byte UTF-8 sequence that translates to a codepoint < U+10000\n//    will be converted as a valid UTF-16 character\n//\n// We keep the current behavior as is but with warnings logged, so as not to\n// break compatibility.  However, this needs to be addressed later.\n\nstatic jsize utf8_to_utf16_length(const char* u8str, jsize u8len)\n{\n    const char* const in_end = u8str + u8len;\n    const char* in = u8str;\n    jsize utf16_len = 0;\n\n    while (in < in_end) {\n        uint8_t c = *in;\n        utf16_len++;\n        if (LIKELY((c & 0x80) == 0)) {\n            in++;\n            continue;\n        }\n        if (UNLIKELY(c < 0xc0)) {\n            in++;\n            continue;\n        }\n        if (LIKELY(c < 0xe0)) {\n            in += 2;\n            continue;\n        }\n        if (LIKELY(c < 0xf0)) {\n            in += 3;\n            continue;\n        } else {\n            uint8_t c2, c3, c4;\n            c2 = in[1];\n            c3 = in[2];\n            c4 = in[3];\n            if (utf8_4b_to_utf32(c, c2, c3, c4) >= 0x10000) {\n                utf16_len++;\n            }\n            in += 4;\n            continue;\n        }\n    }\n    if (in == in_end) {\n        return utf16_len;\n    }\n    return 0;\n}\n\nstatic jchar*\nutf8_to_utf16_no_null_terminator(const char* src, jsize srcLen, jchar* dst, jsize dstLen)\n{\n    if (src == NULL || srcLen == 0 || dstLen == 0) {\n        return dst;\n    }\n\n    const char* const in_end = src + srcLen;\n    const char* in = src;\n    const jchar* const out_end = dst + dstLen;\n    jchar* out = dst;\n    uint8_t c, c2, c3, c4;\n    uint32_t w;\n\n    while (in < in_end && out < out_end) {\n        c = *in++;\n        if (LIKELY((c & 0x80) == 0)) {\n            *out++ = (jchar) (c);\n            continue;\n        }\n        if (UNLIKELY(c < 0xc0)) {\n            ;\n            *out++ = (jchar) (c);\n            continue;\n        }\n        if (LIKELY(c < 0xe0)) {\n            if (UNLIKELY(in + 1 > in_end)) {\n                return out;\n            }\n            c2 = *in++;\n            *out++ = (jchar) (((c & 0x1f) << 6) | (c2 & 0x3f));\n            continue;\n        }\n        if (LIKELY(c < 0xf0)) {\n            if (UNLIKELY(in + 2 > in_end)) {\n                return out;\n            }\n            c2 = *in++;\n            c3 = *in++;\n            *out++ = (jchar) (((c & 0x0f) << 12) | ((c2 & 0x3f) << 6) | (c3 & 0x3f));\n            continue;\n        } else {\n            if (UNLIKELY(in + 3 > in_end)) {\n                return out;\n            }\n            if (UNLIKELY(c >= 0xf8)) {\n                //error\n            }\n            // Multiple UTF16 characters with surrogates\n            c2 = *in++;\n            c3 = *in++;\n            c4 = *in++;\n            w = utf8_4b_to_utf32(c, c2, c3, c4);\n            if (UNLIKELY(w < 0x10000)) {\n                *out++ = (jchar) (w);\n            } else {\n                if (UNLIKELY(out + 2 > out_end)) {\n                    // Ooops.... not enough room for this surrogate pair.\n                    return out;\n                }\n                *out++ = (jchar) (((w - 0x10000) >> 10) + 0xd800);\n                *out++ = (jchar) (((w - 0x10000) & 0x3ff) + 0xdc00);\n            }\n            continue;\n        }\n    }\n    return out;\n}\n\nstatic jchar* utf8_to_utf16(const char* u8str, jsize u8len, jchar* u16str, jsize u16len)\n{\n    jchar* end = utf8_to_utf16_no_null_terminator(u8str, u8len, u16str, u16len - 1);\n    *end = 0;\n    return end;\n}"
  },
  {
    "path": "src/java/main/src/main/cpp/base/WCDBJNI.h",
    "content": "// Created by qiuwenchen on 2023/3/30.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"Macro.h\"\n#include \"ObjectBridge.h\"\n#include <jni.h>\n#include <stdlib.h>\n#include <sys/prctl.h>\n\n#define WCDBJNIStringSignature \"Ljava/lang/String;\"\n\n#define WCDBJNI(className, funcName) WCDBJNI##className##_##funcName\n\n#define WCDBJNIObjectMethodWithNoArg(className, funcName)                      \\\n    WCDBJNI(className, funcName)(JNIEnv * env, jobject object)\n\n#define WCDBJNIObjectMethod(className, funcName, ...)                          \\\n    WCDBJNI(className, funcName)(JNIEnv * env, jobject obj, __VA_ARGS__)\n\n#define WCDBJNIClassMethodWithNoArg(className, funcName)                       \\\n    WCDBJNI(className, funcName)(JNIEnv * env, jclass classType)\n\n#define WCDBJNIClassMethod(className, funcName, ...)                           \\\n    WCDBJNI(className, funcName)(JNIEnv * env, jclass classType, __VA_ARGS__)\n\n#define WCDBJNIBridgeStruct(type, value)                                       \\\n    type value##Struct = { (CPPObject *) value }\n\n#define WCDBJNIGetString(value)                                                \\\n    char *value##String = NULL;                                                \\\n    const jchar *value##_utf16String = NULL;                                   \\\n    WCDBJNIGetUTF8String(env, value, &value##String, &value##_utf16String, false);\n\n#define WCDBJNIReleaseString(value)                                            \\\n    if (value##_utf16String != NULL) {                                         \\\n        (*env)->ReleaseStringChars(env, value, value##_utf16String);           \\\n    }                                                                          \\\n    WCDBClearAllPreAllocatedMemory();\n\n#define WCDBJNIGetStringCritical(value)                                        \\\n    char *value##String = NULL;                                                \\\n    const jchar *value##_utf16String = NULL;                                   \\\n    WCDBJNIGetUTF8String(env, value, &value##String, &value##_utf16String, true);\n\n#define WCDBJNIReleaseStringCritical(value)                                    \\\n    if (value##_utf16String != NULL) {                                         \\\n        (*env)->ReleaseStringCritical(env, value, value##_utf16String);        \\\n    }                                                                          \\\n    WCDBClearAllPreAllocatedMemory();\n\n#define WCDBJNIGetByteArray(value)                                                \\\n    const unsigned char *value##Array = NULL;                                     \\\n    int value##Length = 0;                                                        \\\n    WCDB_UNUSED(value##Length);                                                   \\\n    if (value != NULL) {                                                          \\\n        value##Length = (*env)->GetArrayLength(env, value);                       \\\n        value##Array                                                              \\\n        = (const unsigned char *) (*env)->GetByteArrayElements(env, value, NULL); \\\n    }\n\n#define WCDBJNIReleaseByteArray(value)                                           \\\n    if (value##Array != NULL) {                                                  \\\n        (*env)->ReleaseByteArrayElements(env, value, (jbyte *) value##Array, 0); \\\n    }\n\n#define WCDBJNIGetByteArrayCritical(value)                                             \\\n    const unsigned char *value##Array = NULL;                                          \\\n    int value##Length = 0;                                                             \\\n    WCDB_UNUSED(value##Length);                                                        \\\n    if (value != NULL) {                                                               \\\n        value##Length = (*env)->GetArrayLength(env, value);                            \\\n        value##Array                                                                   \\\n        = (const unsigned char *) (*env)->GetPrimitiveArrayCritical(env, value, NULL); \\\n    }\n\n#define WCDBJNIReleaseByteArrayCritical(value)                                        \\\n    if (value##Array != NULL) {                                                       \\\n        (*env)->ReleasePrimitiveArrayCritical(env, value, (jbyte *) value##Array, 0); \\\n    }\n\n#define WCDBJNIGetLongArray(value)                                             \\\n    const jlong *value##Array = NULL;                                          \\\n    int value##Length = 0;                                                     \\\n    WCDB_UNUSED(value##Length);                                                \\\n    if (value != NULL) {                                                       \\\n        value##Array = (*env)->GetLongArrayElements(env, value, NULL);         \\\n        value##Length = (*env)->GetArrayLength(env, value);                    \\\n    }\n\n#define WCDBJNIReleaseLongArray(value)                                                   \\\n    if (value##Array != NULL) {                                                          \\\n        (*env)->ReleaseLongArrayElements(env, value, (jlong *) value##Array, JNI_ABORT); \\\n    }\n\n#define WCDBJNIGetCppPointerArrayCritical(value)                               \\\n    const void **value##Array = NULL;                                          \\\n    const jlong *value##LongArray = NULL;                                      \\\n    int value##Length = 0;                                                     \\\n    WCDB_UNUSED(value##Length);                                                \\\n    if (value != NULL) {                                                       \\\n        value##Length = (*env)->GetArrayLength(env, value);                    \\\n        value##LongArray                                                       \\\n        = (const jlong *) (*env)->GetPrimitiveArrayCritical(env, value, NULL); \\\n        if (sizeof(void *) == sizeof(jlong) || value##Length == 0) {           \\\n            value##Array = (const void **) value##LongArray;                   \\\n        } else {                                                               \\\n            value##Array = alloca(sizeof(void *) * value##Length);             \\\n            for (int i = 0; i < value##Length; i++) {                          \\\n                value##Array[i] = (void *) value##LongArray[i];                \\\n            }                                                                  \\\n        }                                                                      \\\n    }\n\n#define WCDBJNIReleaseCppPointerArrayCritical(value)                                     \\\n    if (value##LongArray != NULL) {                                                      \\\n        (*env)->ReleasePrimitiveArrayCritical(env, value, (void *) value##LongArray, 0); \\\n    }\n\n#define WCDBJNIGetIntArray(value)                                              \\\n    const jint *value##Array = NULL;                                           \\\n    int value##Length = 0;                                                     \\\n    WCDB_UNUSED(value##Length);                                                \\\n    if (value != NULL) {                                                       \\\n        value##Array = (*env)->GetIntArrayElements(env, value, NULL);          \\\n        value##Length = (*env)->GetArrayLength(env, value);                    \\\n    }\n\n#define WCDBJNIReleaseIntArray(value)                                                  \\\n    if (value##Array != NULL) {                                                        \\\n        (*env)->ReleaseIntArrayElements(env, value, (jint *) value##Array, JNI_ABORT); \\\n    }\n\n#define WCDBJNIGetDoubleArray(value)                                           \\\n    const jdouble *value##Array = NULL;                                        \\\n    int value##Length = 0;                                                     \\\n    WCDB_UNUSED(value##Length);                                                \\\n    if (value != NULL) {                                                       \\\n        value##Array = (*env)->GetDoubleArrayElements(env, value, NULL);       \\\n        value##Length = (*env)->GetArrayLength(env, value);                    \\\n    }\n\n#define WCDBJNIReleaseDoubleArray(value)                                                     \\\n    if (value##Array != NULL) {                                                              \\\n        (*env)->ReleaseDoubleArrayElements(env, value, (jdouble *) value##Array, JNI_ABORT); \\\n    }\n\n#define WCDBJNIGetStringArray(value)                                           \\\n    int value##Length = 0;                                                     \\\n    WCDB_UNUSED(value##Length);                                                \\\n    char **value##CharArray = NULL;                                            \\\n    WCDBJNIGetUTF8StringArray(env, value, &value##CharArray, &value##Length);\n\n#define WCDBJNIReleaseStringArray(value) WCDBClearAllPreAllocatedMemory();\n\n#define WCDBJNICommonValueParameter(parameter)                                 \\\n    jint parameter##_type, jlong parameter##_long, jdouble parameter##_double, \\\n    jstring parameter##_string\n\n#define WCDBJNICreateCommonValue(parameter, isCritical)                        \\\n    CPPCommonValue parameter##_common;                                         \\\n    parameter##_common.type = parameter##_type;                                \\\n    const bool parameter##_isCritical = isCritical;                            \\\n    const jchar *parameter##_utf16String = NULL;                               \\\n    switch (parameter##_type) {                                                \\\n    case WCDBBridgedType_Bool:                                                 \\\n    case WCDBBridgedType_UInt:                                                 \\\n    case WCDBBridgedType_Int:                                                  \\\n        parameter##_common.intValue = parameter##_long;                        \\\n        break;                                                                 \\\n    case WCDBBridgedType_Double:                                               \\\n        parameter##_common.doubleValue = parameter##_double;                   \\\n        break;                                                                 \\\n    case WCDBBridgedType_String:                                               \\\n        WCDBJNIGetUTF8String(env,                                              \\\n                             parameter##_string,                               \\\n                             (char **) &parameter##_common.intValue,           \\\n                             &parameter##_utf16String,                         \\\n                             parameter##_isCritical);                          \\\n        break;                                                                 \\\n    default:                                                                   \\\n        parameter##_common.intValue = parameter##_long;                        \\\n        break;                                                                 \\\n    }\n\n#define WCDBJNITryReleaseStringInCommonValue(parameter)                                      \\\n    if (parameter##_type == WCDBBridgedType_String                                           \\\n        && parameter##_common.intValue != 0 && parameter##_utf16String != NULL) {            \\\n        if (parameter##_isCritical) {                                                        \\\n            (*env)->ReleaseStringCritical(env, parameter##_string, parameter##_utf16String); \\\n        } else {                                                                             \\\n            (*env)->ReleaseStringChars(env, parameter##_string, parameter##_utf16String);    \\\n        }                                                                                    \\\n    }\n\n#define WCDBJNIObjectOrStringParameter(parameter)                              \\\n    jint parameter##_type, jlong parameter##_long, jstring parameter##_string\n\n#define WCDBJNICreateObjectOrStringCommonValue(parameter, isCritical)          \\\n    CPPCommonValue parameter##_common;                                         \\\n    parameter##_common.type = parameter##_type;                                \\\n    const jchar *parameter##_utf16String = NULL;                               \\\n    const bool parameter##_isCritical = isCritical;                            \\\n    if (parameter##_type == WCDBBridgedType_String) {                          \\\n        WCDBJNIGetUTF8String(env,                                              \\\n                             parameter##_string,                               \\\n                             (char **) &parameter##_common.intValue,           \\\n                             &parameter##_utf16String,                         \\\n                             parameter##_isCritical);                          \\\n    } else {                                                                   \\\n        parameter##_common.intValue = parameter##_long;                        \\\n    }\n\n#define WCDBJNIObjectOrIntegerParameter(parameter)                             \\\n    jint parameter##_type, jlong parameter##_long\n\n#define WCDBJNICreateObjectOrIntegerCommonValue(parameter)                     \\\n    CPPCommonValue parameter##_common;                                         \\\n    parameter##_common.type = parameter##_type;                                \\\n    parameter##_common.intValue = parameter##_long;\n\n#define WCDBJNICommonArrayParameter(parameter)                                 \\\n    jint parameter##_type, jlongArray parameter##_longArray,                   \\\n    jdoubleArray parameter##_doubleArray, jobjectArray parameter##_stringArray\n\n#define WCDBJNICreateCommonArrayWithAction(parameter, action)                                     \\\n    CPPCommonArray parameter##_commonArray;                                                       \\\n    parameter##_commonArray.type = parameter##_type;                                              \\\n    if (parameter##_type < WCDBBridgedType_Double || parameter##_type > WCDBBridgedType_String) { \\\n        WCDBJNIGetLongArray(parameter##_longArray);                                               \\\n        parameter##_commonArray.length = parameter##_longArrayLength;                             \\\n        parameter##_commonArray.buffer = (const void **) parameter##_longArrayArray;              \\\n        action;                                                                                   \\\n        WCDBJNIReleaseLongArray(parameter##_longArray);                                           \\\n    } else if (parameter##_type == WCDBBridgedType_String) {                                      \\\n        WCDBJNIGetStringArray(parameter##_stringArray);                                           \\\n        parameter##_commonArray.length = parameter##_stringArrayLength;                           \\\n        parameter##_commonArray.buffer = (const void **) parameter##_stringArrayCharArray;        \\\n        action;                                                                                   \\\n        WCDBJNIReleaseStringArray(parameter##_stringArray);                                       \\\n    } else {                                                                                      \\\n        WCDBJNIGetDoubleArray(parameter##_doubleArray);                                           \\\n        parameter##_commonArray.length = parameter##_doubleArrayLength;                           \\\n        parameter##_commonArray.buffer = (const void **) parameter##_doubleArrayArray;            \\\n        action;                                                                                   \\\n        WCDBJNIReleaseDoubleArray(parameter##_doubleArray);                                       \\\n    }\n\n#define WCDBJNIObjectOrStringArrayParameter(parameter)                         \\\n    jint parameter##_type, jlongArray parameter##_longArray, jobjectArray parameter##_stringArray\n\n#define WCDBJNICreateObjectOrStringArrayCriticalWithAction(parameter, action)                     \\\n    CPPCommonArray parameter##_commonArray;                                                       \\\n    parameter##_commonArray.type = parameter##_type;                                              \\\n    if (parameter##_type < WCDBBridgedType_Double || parameter##_type > WCDBBridgedType_String) { \\\n        const jlong *parameter##_longArrayArray = NULL;                                           \\\n        int parameter##_longArrayLength = 0;                                                      \\\n        if (parameter##_longArray != NULL) {                                                      \\\n            parameter##_longArrayLength                                                           \\\n            = (*env)->GetArrayLength(env, parameter##_longArray);                                 \\\n            parameter##_longArrayArray                                                            \\\n            = (*env)->GetPrimitiveArrayCritical(env, parameter##_longArray, NULL);                \\\n        }                                                                                         \\\n        parameter##_commonArray.length = parameter##_longArrayLength;                             \\\n        parameter##_commonArray.buffer = (const void **) parameter##_longArrayArray;              \\\n        action;                                                                                   \\\n        if (parameter##_longArrayArray != NULL) {                                                 \\\n            (*env)->ReleasePrimitiveArrayCritical(                                                \\\n            env, parameter##_longArray, (void *) parameter##_longArrayArray, 0);                  \\\n        }                                                                                         \\\n    } else if (parameter##_type == WCDBBridgedType_String) {                                      \\\n        WCDBJNIGetStringArray(parameter##_stringArray);                                           \\\n        parameter##_commonArray.length = parameter##_stringArrayLength;                           \\\n        parameter##_commonArray.buffer = (const void **) parameter##_stringArrayCharArray;        \\\n        action;                                                                                   \\\n        WCDBJNIReleaseStringArray(parameter##_stringArray);                                       \\\n    }\n\n#define WCDBJNIMultiTypeArrayParameter(parameter)                              \\\n    jintArray parameter##_types, jlongArray parameter##_longValues,            \\\n    jdoubleArray parameter##_doubleValues, jobjectArray parameter##_stringValues\n\n#define WCDBJNICreateMultiTypeArray(parameter)                                      \\\n    WCDBJNIGetIntArray(parameter##_types);                                          \\\n    WCDBJNIGetLongArray(parameter##_longValues);                                    \\\n    WCDBJNIGetDoubleArray(parameter##_doubleValues);                                \\\n    WCDBJNIGetStringArray(parameter##_stringValues);                                \\\n    CPPMultiTypeArray parameter##Array;                                             \\\n    parameter##Array.totalLength = parameter##_typesLength;                         \\\n    parameter##Array.types = (const enum WCDBBridgedType *) parameter##_typesArray; \\\n    parameter##Array.intValues = (const long long *) parameter##_longValuesArray;   \\\n    parameter##Array.doubleValues = (const double *) parameter##_doubleValuesArray; \\\n    parameter##Array.stringValues = (const char **) parameter##_stringValuesCharArray;\n\n#define WCDBJNIReleaseMultiTypeArray(parameter)                                \\\n    WCDBJNIReleaseIntArray(parameter##_types);                                 \\\n    WCDBJNIReleaseLongArray(parameter##_longValues);                           \\\n    WCDBJNIReleaseDoubleArray(parameter##_doubleValues);                       \\\n    WCDBJNIReleaseStringArray(parameter##_stringValues);\n\n#define WCDBJNICreateJStringAndReturn(action)                                  \\\n    return WCDBJNICreateJString(env, action)\n\n#define WCDBJNICreateJavaString(value)                                         \\\n    jstring j##value = WCDBJNICreateJString(env, value)\n\n#define WCDBJNIFindClass(valueName, signature, action)                         \\\n    static jclass valueName = NULL;                                            \\\n    if (valueName == NULL) {                                                   \\\n        valueName = (*env)->FindClass(env, signature);                         \\\n        WCDBJNICreateGlobalRel(valueName);                                     \\\n    }                                                                          \\\n    assert(valueName != NULL);                                                 \\\n    if (valueName == NULL) {                                                   \\\n        action;                                                                \\\n    }\n\n#define WCDBJNIGetObjectMethodId(valueName, class, methodName, signature)      \\\n    static jmethodID valueName = NULL;                                         \\\n    if (valueName == NULL) {                                                   \\\n        valueName = (*env)->GetMethodID(env, class, methodName, signature);    \\\n    }                                                                          \\\n    assert(valueName != NULL);\n\n#define WCDBJNICreateGlobalRel(value)                                          \\\n    if (value != NULL) {                                                       \\\n        value = (*env)->NewGlobalRef(env, value);                              \\\n    }\n\nextern JavaVM *g_vm;\n\n#define WCDBJNITryGetVM                                                        \\\n    if (g_vm == NULL) {                                                        \\\n        (*env)->GetJavaVM(env, &g_vm);                                         \\\n        assert(g_vm != NULL);                                                  \\\n    }\n\n#define WCDBJNITryGetEnvOr(action)                                             \\\n    JNIEnv *env;                                                               \\\n    int getEnvStat = (*g_vm)->GetEnv(g_vm, (void **) &env, JNI_VERSION_1_6);   \\\n    bool needDetach = false;                                                   \\\n    if (getEnvStat == JNI_EDETACHED) {                                         \\\n        char thread_name[16];                                                  \\\n        if (prctl(PR_GET_NAME, thread_name, NULL, NULL, NULL) != 0) {          \\\n            assert(0);                                                         \\\n            action;                                                            \\\n        }                                                                      \\\n        JavaVMAttachArgs args;                                                 \\\n        args.group = NULL;                                                     \\\n        args.name = thread_name;                                               \\\n        args.version = JNI_VERSION_1_6;                                        \\\n        if ((*g_vm)->AttachCurrentThread(g_vm, &env, &args) != 0) {            \\\n            assert(0);                                                         \\\n            action;                                                            \\\n        }                                                                      \\\n        needDetach = JNI_TRUE;                                                 \\\n    }\n\n#define WCDBJNITryDetach                                                       \\\n    if (needDetach) {                                                          \\\n        WCDBJNIRegisterDetachVM();                                             \\\n    }\n\nWCDB_EXTERN_C_BEGIN\n\nvoid WCDBJNIDestructContext(jobject config);\n\nvoid WCDBJNIClassMethod(Base, releaseObject, long long cppObject);\n\nvoid WCDBJNIInitJClasses(JNIEnv *env);\n\njclass WCDBJNIGetDatabaseClass();\njclass WCDBJNIGetHandleClass();\njclass WCDBJNIGetExceptionClass();\n\nvoid WCDBJNIGetUTF8String(\nJNIEnv *env, jstring value, char **utf8String, const jchar **utf16String, bool critical);\nvoid WCDBJNIGetUTF8StringArray(JNIEnv *env, jobjectArray value, char ***stringArray, int *length);\njstring WCDBJNICreateJString(JNIEnv *env, const char *utf8String);\nvoid WCDBJNIRegisterDetachVM();\n\nWCDB_EXTERN_C_END"
  },
  {
    "path": "src/java/main/src/main/cpp/core/BindingJNI.c",
    "content": "// Created by chenqiuwen on 2023/4/19.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"BindingJNI.h\"\n#include \"BindingBridge.h\"\n\njlong WCDBJNIBindingClassMethodWithNoArg(create)\n{\n    return (jlong) WCDBBindingCreate().innerValue;\n}\n\nvoid WCDBJNIBindingClassMethod(addColumnDef, jlong self, jlong columnDef)\n{\n    WCDBJNIBridgeStruct(CPPBinding, self);\n    WCDBJNIBridgeStruct(CPPColumnDef, columnDef);\n    WCDBBindingAddColumnDef(selfStruct, columnDefStruct);\n}\n\nvoid WCDBJNIBindingClassMethod(enableAutoIncrementForExistingTable, jlong self)\n{\n    WCDBJNIBridgeStruct(CPPBinding, self);\n    WCDBBindingEnableAutoIncrementForExistingTable(selfStruct);\n}\n\nvoid WCDBJNIBindingClassMethod(addIndex, jlong self, jstring indexNameOrSuffix, jboolean isFullName, jlong createIndex)\n{\n    WCDBJNIBridgeStruct(CPPBinding, self);\n    WCDBJNIBridgeStruct(CPPStatementCreateIndex, createIndex);\n    WCDBJNIGetStringCritical(indexNameOrSuffix);\n    WCDBBindingAddIndex(selfStruct, indexNameOrSuffixString, isFullName, createIndexStruct);\n    WCDBJNIReleaseStringCritical(indexNameOrSuffix);\n}\n\nvoid WCDBJNIBindingClassMethod(addTableConstraint, jlong self, jlong constraint)\n{\n    WCDBJNIBridgeStruct(CPPBinding, self);\n    WCDBJNIBridgeStruct(CPPTableConstraint, constraint);\n    WCDBBindingAddTableConstraint(selfStruct, constraintStruct);\n}\n\nvoid WCDBJNIBindingClassMethod(configVirtualModule, jlong self, jstring moduleName)\n{\n    WCDBJNIBridgeStruct(CPPBinding, self);\n    WCDBJNIGetStringCritical(moduleName);\n    WCDBBindingConfigVirtualModule(selfStruct, moduleNameString);\n    WCDBJNIReleaseStringCritical(moduleName);\n}\n\nvoid WCDBJNIBindingClassMethod(configVirtualModuleArgument, jlong self, jstring argument)\n{\n    WCDBJNIBridgeStruct(CPPBinding, self);\n    WCDBJNIGetStringCritical(argument);\n    WCDBBindingConfigVirtualModuleArgument(selfStruct, argumentString);\n    WCDBJNIReleaseStringCritical(argument);\n}\n\nvoid WCDBJNIBindingClassMethod(configWithoutRowId, jlong self)\n{\n    WCDBJNIBridgeStruct(CPPBinding, self);\n    WCDBBindingConfigWithoutRowId(selfStruct);\n}\n\njboolean WCDBJNIBindingClassMethod(createTable, jlong self, jstring tableName, jlong handle)\n{\n    WCDBJNIBridgeStruct(CPPBinding, self);\n    WCDBJNIBridgeStruct(CPPHandle, handle);\n    WCDBJNIGetString(tableName);\n    jboolean ret = WCDBBindingCreateTable(selfStruct, tableNameString, handleStruct);\n    WCDBJNIReleaseString(tableName);\n    return ret;\n}\n\njboolean WCDBJNIBindingClassMethod(createVirtualTable, jlong self, jstring tableName, jlong handle)\n{\n    WCDBJNIBridgeStruct(CPPBinding, self);\n    WCDBJNIBridgeStruct(CPPHandle, handle);\n    WCDBJNIGetString(tableName);\n    jboolean ret = WCDBBindingCreateVirtualTable(selfStruct, tableNameString, handleStruct);\n    WCDBJNIReleaseString(tableName);\n    return ret;\n}\n\njlong WCDBJNIBindingClassMethod(getBaseBinding, jlong self)\n{\n    WCDBJNIBridgeStruct(CPPBinding, self);\n    return (jlong) WCDBBindingGetBaseBinding(selfStruct);\n}\n"
  },
  {
    "path": "src/java/main/src/main/cpp/core/BindingJNI.h",
    "content": "// Created by chenqiuwen on 2023/4/19.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"WCDBJNI.h\"\n\n#define WCDBJNIBindingFuncName(funcName) WCDBJNI(Binding, funcName)\n#define WCDBJNIBindingObjectMethod(funcName, ...)                              \\\n    WCDBJNIObjectMethod(Binding, funcName, __VA_ARGS__)\n#define WCDBJNIBindingObjectMethodWithNoArg(funcName)                          \\\n    WCDBJNIObjectMethodWithNoArg(Binding, funcName)\n#define WCDBJNIBindingClassMethodWithNoArg(funcName)                           \\\n    WCDBJNIClassMethodWithNoArg(Binding, funcName)\n#define WCDBJNIBindingClassMethod(funcName, ...)                               \\\n    WCDBJNIClassMethod(Binding, funcName, __VA_ARGS__)\n\njlong WCDBJNIBindingClassMethodWithNoArg(create);\nvoid WCDBJNIBindingClassMethod(addColumnDef, jlong self, jlong columnDef);\nvoid WCDBJNIBindingClassMethod(enableAutoIncrementForExistingTable, jlong self);\nvoid WCDBJNIBindingClassMethod(\naddIndex, jlong self, jstring indexNameOrSuffix, jboolean isFullName, jlong createIndex);\nvoid WCDBJNIBindingClassMethod(addTableConstraint, jlong self, jlong constraint);\nvoid WCDBJNIBindingClassMethod(configVirtualModule, jlong self, jstring moduleName);\nvoid WCDBJNIBindingClassMethod(configVirtualModuleArgument, jlong self, jstring argument);\nvoid WCDBJNIBindingClassMethod(configWithoutRowId, jlong self);\njboolean WCDBJNIBindingClassMethod(createTable, jlong self, jstring tableName, jlong handle);\njboolean\nWCDBJNIBindingClassMethod(createVirtualTable, jlong self, jstring tableName, jlong handle);\njlong WCDBJNIBindingClassMethod(getBaseBinding, jlong self);\n"
  },
  {
    "path": "src/java/main/src/main/cpp/core/CoreJNI.c",
    "content": "// Created by chenqiuwen on 2023/5/3.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"CoreJNI.h\"\n#include \"CoreBridge.h\"\n\njlong WCDBJNICoreClassMethod(createDatabase, jstring path, jboolean readonly, jboolean inMemory)\n{\n    WCDBJNIGetString(path);\n    jlong ret = (jlong) WCDBCoreCreateDatabase(pathString, readonly, inMemory).innerValue;\n    WCDBJNIReleaseString(path);\n    return ret;\n}\n\nvoid WCDBJNICoreClassMethod(setDefaultCipherConfig, jint version)\n{\n    WCDBCoreSetDefaultCipherConfig(version);\n}\n\nvoid WCDBJNICoreClassMethodWithNoArg(purgeAllDatabase)\n{\n    WCDBCorePurgeAllDatabase();\n}\n\nvoid WCDBJNICoreClassMethod(releaseSQLiteMemory, jint bytes)\n{\n    WCDBCoreReleaseSQLiteMemory(bytes);\n}\n\nvoid WCDBJNICoreClassMethod(setSoftHeapLimit, jlong limit)\n{\n    WCDBCoreSetSoftHeapLimit((int64_t) limit);\n}\n\nvoid WCDBJNICoreClassMethod(setAutoCheckpointMinFrames, jint frames)\n{\n    WCDBCoreSetAutoCheckpointMinFrames(frames);\n}\n\njlong WCDBJNICoreClassMethodWithNoArg(getThreadedError)\n{\n    return (jlong) WCDBCoreGetThreadedError().innerValue;\n}\n"
  },
  {
    "path": "src/java/main/src/main/cpp/core/CoreJNI.h",
    "content": "// Created by chenqiuwen on 2023/5/3.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n#include \"WCDBJNI.h\"\n\n#define WCDBJNICoreFuncName(funcName) WCDBJNI(Core, funcName)\n#define WCDBJNICoreObjectMethod(funcName, ...)                                 \\\n    WCDBJNIObjectMethod(Core, funcName, __VA_ARGS__)\n#define WCDBJNICoreObjectMethodWithNoArg(funcName)                             \\\n    WCDBJNIObjectMethodWithNoArg(Core, funcName)\n#define WCDBJNICoreClassMethodWithNoArg(funcName)                              \\\n    WCDBJNIClassMethodWithNoArg(Core, funcName)\n#define WCDBJNICoreClassMethod(funcName, ...)                                  \\\n    WCDBJNIClassMethod(Core, funcName, __VA_ARGS__)\n\njlong WCDBJNICoreClassMethod(createDatabase, jstring path, jboolean readonly, jboolean inMemory);\nvoid WCDBJNICoreClassMethod(setDefaultCipherConfig, jint version);\nvoid WCDBJNICoreClassMethodWithNoArg(purgeAllDatabase);\nvoid WCDBJNICoreClassMethod(releaseSQLiteMemory, jint bytes);\nvoid WCDBJNICoreClassMethod(setSoftHeapLimit, jlong limit);\nvoid WCDBJNICoreClassMethod(setAutoCheckpointMinFrames, jint frames);\njlong WCDBJNICoreClassMethodWithNoArg(getThreadedError);"
  },
  {
    "path": "src/java/main/src/main/cpp/core/DatabaseExtendJNI.cpp",
    "content": "// Created by qiuwenchen on 2024/2/21.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"DatabaseExtendJNI.h\"\n#include \"BaseTokenizerUtil.hpp\"\n\nvoid WCDBJNIDatabaseClassMethod(configPinyinDict, jobjectArray keys, jobjectArray values)\n{\n    auto* cppPinyinDict = new WCDB::StringViewMap<std::vector<WCDB::StringView>>();\n    int count = keys != nullptr ? env->GetArrayLength(keys) : 0;\n    for (int i = 0; i < count; i++) {\n        auto key = (jstring) env->GetObjectArrayElement(keys, i);\n        WCDBJNIGetStringCritical(key);\n        WCDB::StringView cppKey(keyString);\n        WCDBClearAllPreAllocatedMemory();\n        env->ReleaseStringCritical(key, key_utf16String);\n        if (cppKey.empty()) {\n            continue;\n        }\n\n        std::vector<WCDB::StringView> cppValues;\n        auto valueArray = (jobjectArray) env->GetObjectArrayElement(values, i);\n        int valueCount = valueArray != nullptr ? env->GetArrayLength(valueArray) : 0;\n        for (int j = 0; j < valueCount; j++) {\n            auto value = (jstring) env->GetObjectArrayElement(valueArray, j);\n            WCDBJNIGetStringCritical(value);\n            WCDB::StringView cppValue(valueString);\n            env->ReleaseStringCritical(value, value_utf16String);\n            WCDBClearAllPreAllocatedMemory();\n            if (cppValue.empty()) {\n                continue;\n            }\n            cppValues.push_back(cppValue);\n        }\n        if (cppValues.empty()) {\n            continue;\n        }\n        cppPinyinDict->insert_or_assign(cppKey, cppValues);\n    }\n    WCDB::BaseTokenizerUtil::configPinyinDict(cppPinyinDict);\n}\n\nvoid WCDBJNIDatabaseClassMethod(configTraditionalChineseDict, jobjectArray keys, jobjectArray values)\n{\n    auto* cppTraditionalChineseDict = new WCDB::StringViewMap<WCDB::StringView>();\n    int count = keys != nullptr ? env->GetArrayLength(keys) : 0;\n    for (int i = 0; i < count; i++) {\n        auto key = (jstring) env->GetObjectArrayElement(keys, i);\n        WCDBJNIGetStringCritical(key);\n        WCDB::StringView cppKey(keyString);\n        WCDBClearAllPreAllocatedMemory();\n        env->ReleaseStringCritical(key, key_utf16String);\n        if (cppKey.empty()) {\n            continue;\n        }\n\n        auto value = (jstring) env->GetObjectArrayElement(values, i);\n        WCDBJNIGetStringCritical(value);\n        WCDB::StringView cppValue(valueString);\n        env->ReleaseStringCritical(value, value_utf16String);\n        WCDBClearAllPreAllocatedMemory();\n        if (cppValue.empty()) {\n            continue;\n        }\n        cppTraditionalChineseDict->insert_or_assign(cppKey, cppValue);\n    }\n    WCDB::BaseTokenizerUtil::configTraditionalChineseDict(cppTraditionalChineseDict);\n}"
  },
  {
    "path": "src/java/main/src/main/cpp/core/DatabaseExtendJNI.h",
    "content": "// Created by qiuwenchen on 2024/2/21.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"DatabaseJNI.h\"\n\nWCDB_EXTERN_C_BEGIN\n\nvoid WCDBJNIDatabaseClassMethod(configPinyinDict, jobjectArray keys, jobjectArray values);\nvoid WCDBJNIDatabaseClassMethod(configTraditionalChineseDict, jobjectArray keys, jobjectArray values);\n\nWCDB_EXTERN_C_END"
  },
  {
    "path": "src/java/main/src/main/cpp/core/DatabaseJNI.c",
    "content": "// Created by chenqiuwen on 2023/5/3.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"DatabaseJNI.h\"\n#include \"CoreBridge.h\"\n#include \"DatabaseBridge.h\"\n#include \"FTSBridge.h\"\n#include <assert.h>\n#include <string.h>\n\n#define WCDBJNITryGetDatabaseMethodId(name, signature, action)                        \\\n    static jmethodID g_methodId = NULL;                                               \\\n    if (g_methodId == NULL) {                                                         \\\n        g_methodId                                                                    \\\n        = (*env)->GetStaticMethodID(env, WCDBJNIGetDatabaseClass(), name, signature); \\\n        if (g_methodId == NULL) {                                                     \\\n            assert(0);                                                                \\\n            action;                                                                   \\\n        }                                                                             \\\n    }\n\njlong WCDBJNIDatabaseClassMethod(getError, jlong self)\n{\n    WCDBJNIBridgeStruct(CPPDatabase, self);\n    return (jlong) WCDBDatabaseGetError(selfStruct).innerValue;\n}\n\njlong WCDBJNIDatabaseClassMethod(getTag, jlong self)\n{\n    WCDBJNIBridgeStruct(CPPDatabase, self);\n    return (jlong) WCDBDatabaseGetTag(selfStruct);\n}\n\nvoid WCDBJNIDatabaseClassMethod(setTag, jlong self, jlong tag)\n{\n    WCDBJNIBridgeStruct(CPPDatabase, self);\n    WCDBDatabaseSetTag(selfStruct, tag);\n}\n\njstring WCDBJNIDatabaseClassMethod(getPath, jlong self)\n{\n    WCDBJNIBridgeStruct(CPPDatabase, self);\n    WCDBJNICreateJStringAndReturn(WCDBDatabaseGetPath(selfStruct));\n}\n\ntypedef struct StringEnumeratorContext {\n    JNIEnv* env;\n    jobject array;\n    jclass arrayClass;\n} StringEnumeratorContext;\n\nvoid WCDBJNIStringEnumerator(StringEnumeratorContext* context, const char* string)\n{\n    JNIEnv* env = context->env;\n    WCDBJNIGetObjectMethodId(g_addMethod, context->arrayClass, \"add\", \"(Ljava/lang/Object;)Z\");\n    if (g_addMethod == NULL) {\n        return;\n    }\n    WCDBJNICreateJavaString(string);\n    (*env)->CallBooleanMethod(env, context->array, g_addMethod, jstring);\n}\n\njobject WCDBJNIDatabaseClassMethod(getPaths, jlong self)\n{\n    WCDBJNIBridgeStruct(CPPDatabase, self);\n    WCDBJNIFindClass(g_arrayClass, \"java/util/ArrayList\", return NULL);\n    WCDBJNIGetObjectMethodId(g_arrayInit, g_arrayClass, \"<init>\", \"()V\");\n    jobject arrayList = (*env)->NewObject(env, g_arrayClass, g_arrayInit);\n    StringEnumeratorContext context;\n    context.env = env;\n    context.array = arrayList;\n    context.arrayClass = g_arrayClass;\n    WCDBDatabaseGetPaths(selfStruct, &context, (WCDBStringEnumerater) WCDBJNIStringEnumerator);\n    return arrayList;\n}\n\njlong WCDBJNIDatabaseClassMethod(getHandle, jlong self, jboolean writeHint)\n{\n    WCDBJNIBridgeStruct(CPPDatabase, self);\n    return (jlong) WCDBDatabaseGetHandle(selfStruct, writeHint).innerValue;\n}\n\njboolean WCDBJNIDatabaseClassMethod(canOpen, jlong self)\n{\n    WCDBJNIBridgeStruct(CPPDatabase, self);\n    return WCDBDatabaseCanOpen(selfStruct);\n}\n\njboolean WCDBJNIDatabaseClassMethod(isOpened, jlong self)\n{\n    WCDBJNIBridgeStruct(CPPDatabase, self);\n    return WCDBDatabaseIsOpened(selfStruct);\n}\n\njboolean WCDBJNIDatabaseClassMethod(isBlockaded, jlong self)\n{\n    WCDBJNIBridgeStruct(CPPDatabase, self);\n    return WCDBDatabaseIsBlockaded(selfStruct);\n}\n\ntypedef struct CloseDatabaseContext {\n    JNIEnv* env;\n    jobject callback;\n} CloseDatabaseContext;\n\nvoid WCDBJNIDatabaseCloseCallback(CloseDatabaseContext* context)\n{\n    JNIEnv* env = context->env;\n    WCDBJNITryGetDatabaseMethodId(\n    \"onClose\", \"(\" WCDBJNIDatabaseSignature \"$CloseCallBack;)V\", return);\n    (*env)->CallStaticVoidMethod(\n    env, WCDBJNIGetDatabaseClass(), g_methodId, context->callback);\n}\n\nvoid WCDBJNIDatabaseClassMethod(close, jlong self, jobject callback)\n{\n    WCDBJNIBridgeStruct(CPPDatabase, self);\n    if (callback != NULL) {\n        CloseDatabaseContext context;\n        context.env = env;\n        context.callback = callback;\n        WCDBDatabaseClose(selfStruct, &context, (WCDBDatabaseCloseCallback) WCDBJNIDatabaseCloseCallback);\n    } else {\n        WCDBDatabaseClose(selfStruct, NULL, NULL);\n    }\n}\n\nvoid WCDBJNIDatabaseClassMethod(blockade, jlong self)\n{\n    WCDBJNIBridgeStruct(CPPDatabase, self);\n    WCDBDatabaseBlockade(selfStruct);\n}\n\nvoid WCDBJNIDatabaseClassMethod(unblockade, jlong self)\n{\n    WCDBJNIBridgeStruct(CPPDatabase, self);\n    WCDBDatabaseUnblockade(selfStruct);\n}\n\nvoid WCDBJNIDatabaseClassMethod(purge, jlong self)\n{\n    WCDBJNIBridgeStruct(CPPDatabase, self);\n    WCDBDatabasePurge(selfStruct);\n}\n\nvoid WCDBJNIDatabaseClassMethod(configCipher, jlong self, jbyteArray cipherKey, jint pageSize, jint cipherVersion)\n{\n    WCDBJNIBridgeStruct(CPPDatabase, self);\n    WCDBJNIGetByteArrayCritical(cipherKey);\n    WCDBDatabaseConfigCipher(\n    selfStruct, cipherKeyArray, cipherKeyLength, pageSize, cipherVersion);\n    WCDBJNIReleaseByteArrayCritical(cipherKey);\n}\n\nbool WCDBJNIDatabaseConfig(jobject config, CPPHandle handle)\n{\n    WCDBJNITryGetEnvOr(return false);\n    WCDBJNITryGetDatabaseMethodId(\n    \"onConfig\", \"(J\" WCDBJNIDatabaseSignature \"$Config;)Z\", return false);\n    jboolean ret = (*env)->CallStaticBooleanMethod(\n    env, WCDBJNIGetDatabaseClass(), g_methodId, (jlong) handle.innerValue, config);\n    if ((*env)->ExceptionCheck(env)) {\n        (*env)->ExceptionClear(env);\n        ret = false;\n    }\n    WCDBJNITryDetach;\n    return ret;\n}\n\nvoid WCDBJNIDatabaseClassMethod(\nconfig, jlong self, jstring name, jobject invocation, jobject unInvocation, jint priority)\n{\n    WCDBJNITryGetVM;\n    WCDBJNIBridgeStruct(CPPDatabase, self);\n    WCDBJNICreateGlobalRel(invocation);\n    WCDBJNICreateGlobalRel(unInvocation);\n    WCDBJNIGetString(name);\n    WCDBDatabaseConfig(selfStruct,\n                       nameString,\n                       invocation != NULL ? WCDBJNIDatabaseConfig : NULL,\n                       invocation,\n                       unInvocation != NULL ? WCDBJNIDatabaseConfig : NULL,\n                       unInvocation,\n                       priority,\n                       WCDBJNIDestructContext);\n    WCDBJNIReleaseString(name);\n}\n\nvoid WCDBJNIDatabaseClassMethod(enableLiteMode, jlong self, jboolean enable)\n{\n    WCDBJNIBridgeStruct(CPPDatabase, self);\n    WCDBDatabaseEnableLiteMode(selfStruct, enable);\n}\n\nvoid WCDBJNIDatabasePerformanceTrace(jobject tracer,\n                                     long tag,\n                                     const char* path,\n                                     unsigned long long handleId,\n                                     const char* sql,\n                                     const CPPPerformanceInfo* info)\n{\n    WCDBJNITryGetEnvOr(return);\n    WCDBJNITryGetDatabaseMethodId(\"onTracePerformance\",\n                                  \"(\" WCDBJNIDatabaseSignature \"$PerformanceTracer;J\" WCDBJNIStringSignature\n                                  \"J\" WCDBJNIStringSignature \"J[I)V\",\n                                  return);\n    WCDBJNICreateJavaString(path);\n    WCDBJNICreateJavaString(sql);\n    jint size = sizeof(CPPPerformanceInfo) / sizeof(int) - 2;\n    jintArray infoValues = (*env)->NewIntArray(env, size);\n    if (infoValues != NULL) {\n        (*env)->SetIntArrayRegion(env, infoValues, 0, size, (jint*) info);\n    }\n    (*env)->CallStaticVoidMethod(env,\n                                 WCDBJNIGetDatabaseClass(),\n                                 g_methodId,\n                                 tracer,\n                                 (jlong) tag,\n                                 jpath,\n                                 (jlong) handleId,\n                                 jsql,\n                                 (jlong) info->costInNanoseconds,\n                                 infoValues);\n    WCDBJNITryDetach;\n}\n\nvoid WCDBJNIDatabaseClassMethod(globalTracePerformance, jobject tracer)\n{\n    WCDBJNITryGetVM;\n    WCDBJNICreateGlobalRel(tracer);\n    WCDBDatabaseGlobalTracePerformance(\n    tracer != NULL ? WCDBJNIDatabasePerformanceTrace : NULL, tracer, WCDBJNIDestructContext);\n}\n\nvoid WCDBJNIDatabaseClassMethod(tracePerformance, jlong self, jobject tracer)\n{\n    WCDBJNITryGetVM;\n    WCDBJNIBridgeStruct(CPPDatabase, self);\n    WCDBJNICreateGlobalRel(tracer);\n    WCDBDatabaseTracePerformance(\n    selfStruct, tracer != NULL ? WCDBJNIDatabasePerformanceTrace : NULL, tracer, WCDBJNIDestructContext);\n}\n\nvoid WCDBJNIDatabaseSQLTrace(jobject tracer,\n                             long tag,\n                             const char* path,\n                             unsigned long long handleId,\n                             const char* sql,\n                             const char* info)\n{\n    WCDBJNITryGetEnvOr(return);\n    WCDBJNITryGetDatabaseMethodId(\"onTraceSQL\",\n                                  \"(\" WCDBJNIDatabaseSignature \"$SQLTracer;J\" WCDBJNIStringSignature\n                                  \"J\" WCDBJNIStringSignature WCDBJNIStringSignature \")V\",\n                                  return);\n    WCDBJNICreateJavaString(path);\n    WCDBJNICreateJavaString(sql);\n    WCDBJNICreateJavaString(info);\n    (*env)->CallStaticVoidMethod(\n    env, WCDBJNIGetDatabaseClass(), g_methodId, tracer, (jlong) tag, jpath, (jlong) handleId, jsql, jinfo);\n    WCDBJNITryDetach;\n}\n\nvoid WCDBJNIDatabaseClassMethod(globalTraceSQL, jobject tracer)\n{\n    WCDBJNITryGetVM;\n    WCDBJNICreateGlobalRel(tracer);\n    WCDBDatabaseGlobalTraceSQL(\n    tracer != NULL ? WCDBJNIDatabaseSQLTrace : NULL, tracer, WCDBJNIDestructContext);\n}\n\nvoid WCDBJNIDatabaseClassMethod(traceSQL, jlong self, jobject tracer)\n{\n    WCDBJNITryGetVM;\n    WCDBJNIBridgeStruct(CPPDatabase, self);\n    WCDBJNICreateGlobalRel(tracer);\n    WCDBDatabaseTraceSQL(\n    selfStruct, tracer != NULL ? WCDBJNIDatabaseSQLTrace : NULL, tracer, WCDBJNIDestructContext);\n}\n\nvoid WCDBJNIDatabaseClassMethod(setFullSQLTraceEnable, jlong self, jboolean enable)\n{\n    WCDBJNIBridgeStruct(CPPDatabase, self);\n    WCDBDatabaseSetFullSQLTraceEnable(selfStruct, enable);\n}\n\nvoid WCDBJNIDatabaseErrorTrace(jobject tracer, CPPError error)\n{\n    WCDBJNITryGetEnvOr(return);\n    WCDBJNITryGetDatabaseMethodId(\n    \"onTraceException\", \"(\" WCDBJNIDatabaseSignature \"$ExceptionTracer;J)V\", return);\n    (*env)->CallStaticVoidMethod(\n    env, WCDBJNIGetDatabaseClass(), g_methodId, tracer, (jlong) error.innerValue);\n    WCDBJNITryDetach;\n}\n\nvoid WCDBJNIDatabaseClassMethod(globalTraceError, jobject tracer)\n{\n    WCDBJNITryGetVM;\n    WCDBJNICreateGlobalRel(tracer);\n    WCDBDatabaseGlobalTraceError(\n    tracer != NULL ? WCDBJNIDatabaseErrorTrace : NULL, tracer, WCDBJNIDestructContext);\n}\n\nvoid WCDBJNIDatabaseClassMethod(traceError, jlong self, jobject tracer)\n{\n    WCDBJNITryGetVM;\n    WCDBJNIBridgeStruct(CPPDatabase, self);\n    WCDBJNICreateGlobalRel(tracer);\n    WCDBDatabaseTraceError(\n    selfStruct, tracer != NULL ? WCDBJNIDatabaseErrorTrace : NULL, tracer, WCDBJNIDestructContext);\n}\n\nvoid WCDBJNIDatabaseOperationTrace(jobject tracer, CPPDatabase database, long operation, const void* info)\n{\n    WCDBJNITryGetEnvOr(return);\n    WCDBJNITryGetDatabaseMethodId(\n    \"onTraceOperation\", \"(\" WCDBJNIDatabaseSignature \"$OperationTracer;JIJ)V\", return);\n    (*env)->CallStaticVoidMethod(env,\n                                 WCDBJNIGetDatabaseClass(),\n                                 g_methodId,\n                                 tracer,\n                                 (jlong) database.innerValue,\n                                 (jint) operation,\n                                 (jlong) info);\n    WCDBJNITryDetach;\n}\n\nvoid WCDBJNIDatabaseClassMethod(globalTraceOperation, jobject tracer)\n{\n    WCDBJNITryGetVM;\n    WCDBJNICreateGlobalRel(tracer);\n    WCDBDatabaseGlobalTraceOperation(\n    (tracer != NULL ? (WCDBOperationTracer) WCDBJNIDatabaseOperationTrace : NULL),\n    tracer,\n    WCDBJNIDestructContext);\n}\n\ntypedef struct JNIEnumerateInfoContext {\n    JNIEnv* env;\n    jobject object;\n} JNIEnumerateInfoContext;\n\nvoid WCDBJNIDatabaseEnumerateInfoCallback(JNIEnumerateInfoContext* context,\n                                          const char* key,\n                                          CPPCommonValue value)\n{\n    JNIEnv* env = context->env;\n    jlong intValue = 0;\n    double doubleValue = 0;\n    const char* stringValue = NULL;\n    switch (value.type) {\n    case WCDBBridgedType_Int:\n        intValue = (jlong) value.intValue;\n        break;\n    case WCDBBridgedType_Double:\n        doubleValue = value.doubleValue;\n        break;\n    case WCDBBridgedType_String:\n        stringValue = (const char*) value.intValue;\n        break;\n    default:\n        break;\n    }\n    WCDBJNITryGetDatabaseMethodId(\"onEnumerateInfo\",\n                                  \"(Ljava/util/HashMap;\" WCDBJNIStringSignature\n                                  \"IJD\" WCDBJNIStringSignature \")V\",\n                                  return);\n    WCDBJNICreateJavaString(key);\n    WCDBJNICreateJavaString(stringValue);\n    (*env)->CallStaticVoidMethod(env,\n                                 WCDBJNIGetDatabaseClass(),\n                                 g_methodId,\n                                 context->object,\n                                 jkey,\n                                 (int) value.type,\n                                 intValue,\n                                 doubleValue,\n                                 jstringValue);\n}\n\nvoid WCDBJNIDatabaseClassMethod(enumerateInfo, jobject javaInfo, jlong cppInfo)\n{\n    JNIEnumerateInfoContext context;\n    context.object = javaInfo;\n    context.env = env;\n    WCDBEnumerateStringViewMap((const void*) cppInfo,\n                               (void*) &context,\n                               (StringViewMapEnumerator) WCDBJNIDatabaseEnumerateInfoCallback);\n}\n\nvoid WCDBJNIDatabaseBusyTrace(jobject tracer, long tag, const char* path, jlong tid, const char* sql)\n{\n    WCDBJNITryGetEnvOr(return);\n    WCDBJNITryGetDatabaseMethodId(\"onBusyTrace\",\n                                  \"(\" WCDBJNIDatabaseSignature \"$BusyTracer;J\" WCDBJNIStringSignature\n                                  \"J\" WCDBJNIStringSignature \")V\",\n                                  return);\n    WCDBJNICreateJavaString(path);\n    WCDBJNICreateJavaString(sql);\n    (*env)->CallStaticVoidMethod(\n    env, WCDBJNIGetDatabaseClass(), g_methodId, tracer, (jlong) tag, jpath, (jlong) tid, jsql);\n    WCDBJNITryDetach;\n}\n\nvoid WCDBJNIDatabaseClassMethod(globalTraceDatabaseBusy, jobject tracer, jdouble timeOut)\n{\n    WCDBJNITryGetVM;\n    WCDBJNICreateGlobalRel(tracer);\n    WCDBCoreGlobalTraceBusy(\n    (tracer != NULL ? (WCDBBusyTracer) WCDBJNIDatabaseBusyTrace : NULL), timeOut, tracer, WCDBJNIDestructContext);\n}\n\njboolean WCDBJNIDatabaseClassMethod(removeFiles, jlong self)\n{\n    WCDBJNIBridgeStruct(CPPDatabase, self);\n    return WCDBDatabaseRemoveFile(selfStruct);\n}\n\njboolean WCDBJNIDatabaseClassMethod(moveFile, jlong self, jstring destination)\n{\n    WCDBJNIBridgeStruct(CPPDatabase, self);\n    WCDBJNIGetString(destination);\n    jboolean ret = WCDBDatabaseMoveFile(selfStruct, destinationString);\n    WCDBJNIReleaseString(destination);\n    return ret;\n}\n\njlong WCDBJNIDatabaseClassMethod(getFileSize, jlong self)\n{\n    WCDBJNIBridgeStruct(CPPDatabase, self);\n    OptionalUInt64 size = WCDBDatabaseGetFileSize(selfStruct);\n    return size.hasValue ? size.value : -1;\n}\n\nvoid WCDBJNIDatabaseClassMethod(addTokenizer, jlong self, jstring tokenizer)\n{\n    WCDBJNIBridgeStruct(CPPDatabase, self);\n    WCDBJNIGetString(tokenizer);\n    WCDBDatabaseAddTokenizer(selfStruct, tokenizerString);\n    WCDBJNIReleaseString(tokenizer);\n}\n\nvoid WCDBJNIDatabaseClassMethod(addAuxiliaryFunction, jlong self, jstring auxiliaryFunction)\n{\n    WCDBJNIBridgeStruct(CPPDatabase, self);\n    WCDBJNIGetString(auxiliaryFunction);\n    WCDBDatabaseAddAuxiliaryFunction(selfStruct, auxiliaryFunctionString);\n    WCDBJNIReleaseString(auxiliaryFunction);\n}\n\nvoid WCDBJNIDatabaseCorrupted(jobject notification, CPPDatabase database)\n{\n    WCDBJNITryGetEnvOr(return);\n    WCDBJNITryGetDatabaseMethodId(\n    \"onCorrupted\", \"(\" WCDBJNIDatabaseSignature \"$CorruptionNotification;J)V\", return);\n    (*env)->CallStaticVoidMethod(\n    env, WCDBJNIGetDatabaseClass(), g_methodId, notification, (jlong) database.innerValue);\n    WCDBJNITryDetach;\n}\n\nvoid WCDBJNIDatabaseClassMethod(setNotificationWhenCorrupted, jlong self, jobject notification)\n{\n    WCDBJNIBridgeStruct(CPPDatabase, self);\n    WCDBJNITryGetVM;\n    WCDBJNICreateGlobalRel(notification);\n    WCDBDatabaseSetNotificationWhenCorrupted(\n    selfStruct, notification != NULL ? WCDBJNIDatabaseCorrupted : NULL, notification, WCDBJNIDestructContext);\n}\n\njboolean WCDBJNIDatabaseClassMethod(checkIfCorrupted, jlong self)\n{\n    WCDBJNIBridgeStruct(CPPDatabase, self);\n    return WCDBDatabaseCheckIfCorrupted(selfStruct);\n}\n\njboolean WCDBJNIDatabaseClassMethod(checkIfIsAlreadyCorrupted, jlong self)\n{\n    WCDBJNIBridgeStruct(CPPDatabase, self);\n    return WCDBDatabaseCheckIsAlreadyCorrupted(selfStruct);\n}\n\nvoid WCDBJNIDatabaseClassMethod(enableAutoBackup, jlong self, jboolean enable)\n{\n    WCDBJNIBridgeStruct(CPPDatabase, self);\n    WCDBDatabaseEnableAutoBackup(selfStruct, enable);\n}\n\njboolean WCDBJNIDatabaseClassMethod(backup, jlong self)\n{\n    WCDBJNIBridgeStruct(CPPDatabase, self);\n    return WCDBDatabaseBackup(selfStruct);\n}\n\nbool WCDBJNIDatabaseTableShouldBeBackup(jobject filter, const char* table)\n{\n    WCDBJNITryGetEnvOr(return false);\n    WCDBJNITryGetDatabaseMethodId(\"checkTableShouldBeBackup\",\n                                  \"(\" WCDBJNIDatabaseSignature\n                                  \"$BackupFilter;\" WCDBJNIStringSignature \")Z\",\n                                  return false);\n    WCDBJNICreateJavaString(table);\n    bool ret = (*env)->CallStaticBooleanMethod(\n    env, WCDBJNIGetDatabaseClass(), g_methodId, filter, jtable);\n    if ((*env)->ExceptionCheck(env)) {\n        (*env)->ExceptionClear(env);\n        ret = false;\n    }\n    WCDBJNITryDetach;\n    return ret;\n}\n\nvoid WCDBJNIDatabaseClassMethod(filterBackup, jlong self, jobject tableShouldBeBackup)\n{\n    WCDBJNIBridgeStruct(CPPDatabase, self);\n    WCDBJNITryGetVM;\n    WCDBJNICreateGlobalRel(tableShouldBeBackup);\n    WCDBDatabaseFilterBackup(\n    selfStruct,\n    tableShouldBeBackup != NULL ? WCDBJNIDatabaseTableShouldBeBackup : NULL,\n    tableShouldBeBackup,\n    WCDBJNIDestructContext);\n}\n\njboolean WCDBJNIDatabaseClassMethod(deposit, jlong self)\n{\n    WCDBJNIBridgeStruct(CPPDatabase, self);\n    return WCDBDatabaseDeposit(selfStruct);\n}\n\njboolean WCDBJNIDatabaseClassMethod(removeDepositedFiles, jlong self)\n{\n    WCDBJNIBridgeStruct(CPPDatabase, self);\n    return WCDBDatabaseRemoveDepositedFiles(selfStruct);\n}\n\njboolean WCDBJNIDatabaseClassMethod(containDepositedFiles, jlong self)\n{\n    WCDBJNIBridgeStruct(CPPDatabase, self);\n    return WCDBDatabaseContainDepositedFiles(selfStruct);\n}\n\nbool WCDBJNIDatabaseOnProgressUpdate(jobject monitor, double percentage, double increment)\n{\n    WCDBJNITryGetEnvOr(return false);\n    WCDBJNITryGetDatabaseMethodId(\n    \"onProgressUpdate\", \"(\" WCDBJNIDatabaseSignature \"$ProgressMonitor;DD)Z\", return false);\n    bool ret = (*env)->CallStaticBooleanMethod(\n    env, WCDBJNIGetDatabaseClass(), g_methodId, monitor, (jdouble) percentage, (jdouble) increment);\n    WCDBJNITryDetach;\n    return ret;\n}\n\njdouble WCDBJNIDatabaseClassMethod(retrieve, jlong self, jobject onProgressUpdate)\n{\n    WCDBJNIBridgeStruct(CPPDatabase, self);\n    WCDBJNITryGetVM;\n    WCDBJNICreateGlobalRel(onProgressUpdate);\n    return WCDBDatabaseRetrieve(\n    selfStruct,\n    onProgressUpdate != NULL ? (WCDBProgressUpdate) WCDBJNIDatabaseOnProgressUpdate : NULL,\n    onProgressUpdate,\n    WCDBJNIDestructContext);\n}\n\njdouble WCDBJNIDatabaseClassMethod(vacuum, jlong self, jobject onProgressUpdate)\n{\n    WCDBJNIBridgeStruct(CPPDatabase, self);\n    WCDBJNITryGetVM;\n    WCDBJNICreateGlobalRel(onProgressUpdate);\n    return WCDBDatabaseVacuum(\n    selfStruct,\n    onProgressUpdate != NULL ? (WCDBProgressUpdate) WCDBJNIDatabaseOnProgressUpdate : NULL,\n    onProgressUpdate,\n    WCDBJNIDestructContext);\n}\n\nvoid WCDBJNIDatabaseClassMethod(enableAutoVacuum, jlong self, jboolean incremental)\n{\n    WCDBJNIBridgeStruct(CPPDatabase, self);\n    WCDBDatabaseEnableAutoVacuum(selfStruct, incremental);\n}\n\njboolean WCDBJNIDatabaseClassMethod(incrementalVacuum, jlong self, jint pageCount)\n{\n    WCDBJNIBridgeStruct(CPPDatabase, self);\n    return WCDBDatabaseIncrementalVacuum(selfStruct, pageCount);\n}\n\njboolean WCDBJNIDatabaseClassMethod(passiveCheckpoint, jlong self)\n{\n    WCDBJNIBridgeStruct(CPPDatabase, self);\n    return WCDBDatabasePassiveCheckpoint(selfStruct);\n}\n\njboolean WCDBJNIDatabaseClassMethod(truncateCheckpoint, jlong self)\n{\n    WCDBJNIBridgeStruct(CPPDatabase, self);\n    return WCDBDatabaseTruncateCheckpoint(selfStruct);\n}\n\nvoid WCDBJNIDatabaseClassMethod(setAutoCheckpointEnable, jlong self, jboolean enable)\n{\n    WCDBJNIBridgeStruct(CPPDatabase, self);\n    WCDBCoreSetAutoCheckpointEnable(selfStruct, (bool) enable);\n}\n\nvoid WCDBJNIDatabaseFilterMigrate(jobject filter, const char* table, void* info, WCDBMigrationInfoSetter setter)\n{\n    WCDBJNITryGetEnvOr(return);\n    WCDBJNITryGetDatabaseMethodId(\"filterMigrate\",\n                                  \"(\" WCDBJNIDatabaseSignature\n                                  \"$MigrationFilter;JJ\" WCDBJNIStringSignature \")V\",\n                                  return);\n    WCDBJNICreateJavaString(table);\n    (*env)->CallStaticVoidMethod(\n    env, WCDBJNIGetDatabaseClass(), g_methodId, filter, (jlong) setter, (jlong) info, jtable);\n    WCDBJNITryDetach;\n}\n\nvoid WCDBJNIDatabaseClassMethod(\naddMigrationSource, jlong self, jstring sourcePath, jbyteArray cipherKey, jobject filter)\n{\n    WCDBJNIBridgeStruct(CPPDatabase, self);\n    WCDBJNITryGetVM;\n    WCDBJNICreateGlobalRel(filter);\n    WCDBJNIGetString(sourcePath);\n    WCDBJNIGetByteArrayCritical(cipherKey);\n    WCDBDatabaseAddMigration(selfStruct,\n                             sourcePathString,\n                             cipherKeyArray,\n                             cipherKeyLength,\n                             filter != NULL ? WCDBJNIDatabaseFilterMigrate : NULL,\n                             filter,\n                             WCDBJNIDestructContext);\n    WCDBJNIReleaseByteArrayCritical(cipherKey);\n    WCDBJNIReleaseString(sourcePath);\n}\n\nvoid WCDBJNIDatabaseClassMethod(setMigrationInfo, jlong infoSetter, jlong info, jstring sourceTable, jlong filterCondition)\n{\n    WCDBJNIGetStringCritical(sourceTable);\n    WCDBJNIBridgeStruct(CPPExpression, filterCondition);\n    ((WCDBMigrationInfoSetter) infoSetter)((void*) info, sourceTableString, filterConditionStruct);\n    WCDBJNIReleaseStringCritical(sourceTable);\n}\n\njboolean WCDBJNIDatabaseClassMethod(stepMigration, jlong self)\n{\n    WCDBJNIBridgeStruct(CPPDatabase, self);\n    return WCDBDatabaseStepMigration(selfStruct);\n}\n\nvoid WCDBJNIDatabaseClassMethod(enableAutoMigration, jlong self, jboolean flag)\n{\n    WCDBJNIBridgeStruct(CPPDatabase, self);\n    WCDBDatabaseEnableAutoMigration(selfStruct, flag);\n}\n\nvoid WCDBJNIDatabaseOnTableMigrate(jobject notification,\n                                   CPPDatabase database,\n                                   const char* table,\n                                   const char* sourceTable)\n{\n    WCDBJNITryGetEnvOr(return);\n    WCDBJNITryGetDatabaseMethodId(\n    \"onTableMigrated\",\n    \"(\" WCDBJNIDatabaseSignature\n    \"$MigrationNotification;J\" WCDBJNIStringSignature WCDBJNIStringSignature \")V\",\n    return);\n    WCDBJNICreateJavaString(table);\n    WCDBJNICreateJavaString(sourceTable);\n    (*env)->CallStaticVoidMethod(\n    env, WCDBJNIGetDatabaseClass(), g_methodId, notification, (jlong) database.innerValue, jtable, jsourceTable);\n    WCDBJNITryDetach;\n}\n\nvoid WCDBJNIDatabaseClassMethod(setNotificationWhenMigrated, jlong self, jobject onMigrated)\n{\n    WCDBJNIBridgeStruct(CPPDatabase, self);\n    WCDBJNITryGetVM;\n    WCDBJNICreateGlobalRel(onMigrated);\n    WCDBDatabaseSetNotificationWhenMigrated(\n    selfStruct, onMigrated != NULL ? WCDBJNIDatabaseOnTableMigrate : NULL, onMigrated, WCDBJNIDestructContext);\n}\n\njboolean WCDBJNIDatabaseClassMethod(isMigrated, jlong self)\n{\n    WCDBJNIBridgeStruct(CPPDatabase, self);\n    return WCDBDatabaseIsMigrated(selfStruct);\n}\n\ntypedef struct DataEnumeratorContext {\n    JNIEnv* env;\n    bool isString;\n    jint totalCount;\n    jint index;\n    jobjectArray* objects;\n    jobject preObject;\n    jbyte* preContent;\n} DataEnumeratorContext;\n\nvoid WCDBJNITryReleaseLastElement(DataEnumeratorContext* context)\n{\n    if (context->preObject == NULL || context->preContent == NULL) {\n        return;\n    }\n    JNIEnv* env = context->env;\n    if (context->isString) {\n        (*env)->ReleaseStringCritical(\n        env, context->preObject, (const jchar*) context->preContent);\n        WCDBClearAllPreAllocatedMemory();\n    } else {\n        (*env)->ReleasePrimitiveArrayCritical(\n        env, context->preObject, context->preContent, 0);\n    }\n    context->preContent = NULL;\n    context->preObject = NULL;\n}\n\nCPPData WCDBJNIDataEnumerator(DataEnumeratorContext* context)\n{\n    CPPData ret;\n    if (context->index >= context->totalCount) {\n        ret.buffer = NULL;\n        ret.size = 0;\n        return ret;\n    }\n    WCDBJNITryReleaseLastElement(context);\n    JNIEnv* env = context->env;\n    if (context->isString) {\n        jstring string = (jstring) (*env)->GetObjectArrayElement(\n        env, context->objects, context->index);\n        WCDBJNIGetStringCritical(string);\n        ret.buffer = (unsigned char*) stringString;\n        ret.size = stringString != NULL ? strlen(stringString) : 0;\n        context->preObject = string;\n        context->preContent = (jbyte*) string_utf16String;\n    } else {\n        jbyteArray array = (jbyteArray) (*env)->GetObjectArrayElement(\n        env, context->objects, context->index);\n        WCDBJNIGetByteArrayCritical(array);\n        ret.buffer = (unsigned char*) arrayArray;\n        ret.size = arrayLength;\n        context->preObject = array;\n        context->preContent = (jbyte*) arrayArray;\n    }\n    context->index++;\n    return ret;\n}\n\njbyteArray\nWCDBJNIDatabaseClassMethod(trainDictWithStrings, jobjectArray stringArray, jbyte dictId)\n{\n    DataEnumeratorContext context;\n    context.env = env;\n    context.isString = true;\n    context.totalCount\n    = stringArray != NULL ? (*env)->GetArrayLength(env, stringArray) : 0;\n    context.objects = stringArray;\n    context.preObject = NULL;\n    context.preContent = NULL;\n    context.index = 0;\n    CPPData dict = WCDBDatabaseTrainDict(\n    dictId, (WCDBDataEnumerator) WCDBJNIDataEnumerator, &context);\n    WCDBJNITryReleaseLastElement(&context);\n    jbyteArray ret = NULL;\n    if (dict.size > 0 && dict.buffer != NULL) {\n        ret = (*env)->NewByteArray(env, dict.size);\n        (*env)->SetByteArrayRegion(env, ret, 0, dict.size, (const jbyte*) dict.buffer);\n        free(dict.buffer);\n    }\n    return ret;\n}\n\njbyteArray WCDBJNIDatabaseClassMethod(trainDictWithDatas, jobjectArray dataArray, jbyte dictId)\n{\n    DataEnumeratorContext context;\n    context.env = env;\n    context.isString = false;\n    context.totalCount = dataArray != NULL ? (*env)->GetArrayLength(env, dataArray) : 0;\n    context.objects = dataArray;\n    context.preObject = NULL;\n    context.preContent = NULL;\n    context.index = 0;\n    CPPData dict = WCDBDatabaseTrainDict(\n    dictId, (WCDBDataEnumerator) WCDBJNIDataEnumerator, &context);\n    WCDBJNITryReleaseLastElement(&context);\n    jbyteArray ret = NULL;\n    if (dict.size > 0 && dict.buffer != NULL) {\n        ret = (*env)->NewByteArray(env, dict.size);\n        (*env)->SetByteArrayRegion(env, ret, 0, dict.size, (const jbyte*) dict.buffer);\n        free(dict.buffer);\n    }\n    return ret;\n}\n\njboolean WCDBJNIDatabaseClassMethod(registerDict, jbyteArray dict, jbyte dictId)\n{\n    WCDBJNIGetByteArray(dict);\n    bool ret = WCDBDatabaseRegisterDict(dictArray, dictLength, dictId);\n    WCDBJNIReleaseByteArray(dict);\n    return ret;\n}\n\nvoid WCDBJNIDatabaseClassMethod(addZSTDNormalCompress, jlong info, jlong column)\n{\n    WCDBJNIBridgeStruct(CPPColumn, column);\n    WCDBDatabaseSetZSTDNormalCompress((void*) info, columnStruct);\n}\n\nvoid WCDBJNIDatabaseClassMethod(addZSTDDictCompress, jlong info, jlong column, jbyte dictId)\n{\n    WCDBJNIBridgeStruct(CPPColumn, column);\n    WCDBDatabaseSetZSTDDictCompress((void*) info, columnStruct, dictId);\n}\n\nvoid WCDBJNIDatabaseClassMethod(addZSTDMultiDictCompress,\n                                jlong info,\n                                jlong column,\n                                jlong matchColumn,\n                                jlongArray values,\n                                jbyteArray dictIds)\n{\n    WCDBJNIGetLongArray(values);\n    WCDBJNIGetByteArray(dictIds);\n    WCDBJNIBridgeStruct(CPPColumn, column);\n    WCDBJNIBridgeStruct(CPPColumn, matchColumn);\n    WCDBDatabaseSetZSTDMultiDictCompress(\n    (void*) info, columnStruct, matchColumnStruct, (const long long*) valuesArray, dictIdsArray, dictIdsLength);\n    WCDBJNIReleaseLongArray(values);\n    WCDBJNIReleaseByteArray(dictIds);\n}\n\nvoid WCDBJNIDatabaseClassMethod(enableReplaceCompression, jlong info)\n{\n    WCDBDatabaseEnableReplaceCompresssion((void*) info);\n}\n\nvoid WCDBJNIDatabaseFilterCompress(jobject filter, const char* table, void* info)\n{\n    WCDBJNITryGetEnvOr(return);\n    WCDBJNITryGetDatabaseMethodId(\"filterCompress\",\n                                  \"(\" WCDBJNIDatabaseSignature\n                                  \"$CompressionFilter;J\" WCDBJNIStringSignature \")V\",\n                                  return);\n    WCDBJNICreateJavaString(table);\n    (*env)->CallStaticVoidMethod(\n    env, WCDBJNIGetDatabaseClass(), g_methodId, filter, (jlong) info, jtable);\n    WCDBJNITryDetach;\n}\n\nvoid WCDBJNIDatabaseClassMethod(setCompression, jlong self, jobject filter)\n{\n    WCDBJNIBridgeStruct(CPPDatabase, self);\n    WCDBJNICreateGlobalRel(filter);\n    WCDBDatabaseSetCompression(\n    selfStruct, filter != NULL ? WCDBJNIDatabaseFilterCompress : NULL, filter, WCDBJNIDestructContext);\n}\n\nvoid WCDBJNIDatabaseClassMethod(disableCompressNewData, jlong self, jboolean disable)\n{\n    WCDBJNIBridgeStruct(CPPDatabase, self);\n    WCDBDatabaseDisableCompressNewData(selfStruct, disable);\n}\n\njboolean WCDBJNIDatabaseClassMethod(stepCompression, jlong self)\n{\n    WCDBJNIBridgeStruct(CPPDatabase, self);\n    return WCDBDatabaseStepCompression(selfStruct);\n}\n\nvoid WCDBJNIDatabaseClassMethod(enableAutoCompression, jlong self, jboolean enable)\n{\n    WCDBJNIBridgeStruct(CPPDatabase, self);\n    WCDBDatabaseEnableAutoCompression(selfStruct, enable);\n}\n\nvoid WCDBJNIDatabaseOnTableCompressed(jobject notification, CPPDatabase database, const char* table)\n{\n    WCDBJNITryGetEnvOr(return);\n    WCDBJNITryGetDatabaseMethodId(\"onTableCompressed\",\n                                  \"(\" WCDBJNIDatabaseSignature\n                                  \"$CompressionNotification;J\" WCDBJNIStringSignature \")V\",\n                                  return);\n    WCDBJNICreateJavaString(table);\n    (*env)->CallStaticVoidMethod(\n    env, WCDBJNIGetDatabaseClass(), g_methodId, notification, (jlong) database.innerValue, jtable);\n    WCDBJNITryDetach;\n}\n\nvoid WCDBJNIDatabaseClassMethod(setNotificationWhenCompressed, jlong self, jobject onCompressed)\n{\n    WCDBJNIBridgeStruct(CPPDatabase, self);\n    WCDBJNITryGetVM;\n    WCDBJNICreateGlobalRel(onCompressed);\n    WCDBDatabaseSetNotificationWhenCompressed(\n    selfStruct, onCompressed != NULL ? WCDBJNIDatabaseOnTableCompressed : NULL, onCompressed, WCDBJNIDestructContext);\n}\n\njboolean WCDBJNIDatabaseClassMethod(isCompressed, jlong self)\n{\n    WCDBJNIBridgeStruct(CPPDatabase, self);\n    return WCDBDatabaseIsCompressed(selfStruct);\n}\n\njdouble WCDBJNIDatabaseClassMethod(rollbackCompression, jlong self, jobject onProgressUpdate)\n{\n    WCDBJNIBridgeStruct(CPPDatabase, self);\n    WCDBJNITryGetVM;\n    WCDBJNICreateGlobalRel(onProgressUpdate);\n    return WCDBDatabaseRollbackCompression(\n    selfStruct,\n    onProgressUpdate != NULL ? (WCDBProgressUpdate) WCDBJNIDatabaseOnProgressUpdate : NULL,\n    onProgressUpdate,\n    WCDBJNIDestructContext);\n}\n\njint WCDBJNIDatabaseClassMethod(getNumberOfAliveHandle, jlong self)\n{\n    WCDBJNIBridgeStruct(CPPDatabase, self);\n    return WCDBDatabaseGetAliveHandleCount(selfStruct);\n}\n"
  },
  {
    "path": "src/java/main/src/main/cpp/core/DatabaseJNI.h",
    "content": "// Created by chenqiuwen on 2023/5/3.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n#include \"WCDBJNI.h\"\n\n#define WCDBJNIDatabaseFuncName(funcName) WCDBJNI(Database, funcName)\n#define WCDBJNIDatabaseObjectMethod(funcName, ...)                             \\\n    WCDBJNIObjectMethod(Database, funcName, __VA_ARGS__)\n#define WCDBJNIDatabaseObjectMethodWithNoArg(funcName)                         \\\n    WCDBJNIObjectMethodWithNoArg(Database, funcName)\n#define WCDBJNIDatabaseClassMethodWithNoArg(funcName)                          \\\n    WCDBJNIClassMethodWithNoArg(Database, funcName)\n#define WCDBJNIDatabaseClassMethod(funcName, ...)                              \\\n    WCDBJNIClassMethod(Database, funcName, __VA_ARGS__)\n\n#define WCDBJNIDatabaseSignature \"Lcom/tencent/wcdb/core/Database\"\n\njlong WCDBJNIDatabaseClassMethod(getError, jlong self);\njlong WCDBJNIDatabaseClassMethod(getTag, jlong self);\nvoid WCDBJNIDatabaseClassMethod(setTag, jlong self, jlong tag);\njstring WCDBJNIDatabaseClassMethod(getPath, jlong self);\njobject WCDBJNIDatabaseClassMethod(getPaths, jlong self);\njlong WCDBJNIDatabaseClassMethod(getHandle, jlong self, jboolean writeHint);\n\njboolean WCDBJNIDatabaseClassMethod(canOpen, jlong self);\njboolean WCDBJNIDatabaseClassMethod(isOpened, jlong self);\njboolean WCDBJNIDatabaseClassMethod(isBlockaded, jlong self);\nvoid WCDBJNIDatabaseClassMethod(close, jlong self, jobject callback);\nvoid WCDBJNIDatabaseClassMethod(blockade, jlong self);\nvoid WCDBJNIDatabaseClassMethod(unblockade, jlong self);\nvoid WCDBJNIDatabaseClassMethod(purge, jlong self);\n\nvoid WCDBJNIDatabaseClassMethod(configCipher, jlong self, jbyteArray cipherKey, jint pageSize, jint cipherVersion);\nvoid WCDBJNIDatabaseClassMethod(\nconfig, jlong self, jstring name, jobject invocation, jobject unInvocation, jint priority);\n\nvoid WCDBJNIDatabaseClassMethod(enableLiteMode, jlong self, jboolean enable);\n\nvoid WCDBJNIDatabaseClassMethod(globalTracePerformance, jobject tracer);\nvoid WCDBJNIDatabaseClassMethod(tracePerformance, jlong self, jobject tracer);\n\nvoid WCDBJNIDatabaseClassMethod(globalTraceSQL, jobject tracer);\nvoid WCDBJNIDatabaseClassMethod(traceSQL, jlong self, jobject tracer);\nvoid WCDBJNIDatabaseClassMethod(setFullSQLTraceEnable, jlong self, jboolean enable);\n\nvoid WCDBJNIDatabaseClassMethod(globalTraceError, jobject tracer);\nvoid WCDBJNIDatabaseClassMethod(traceError, jlong self, jobject tracer);\n\nvoid WCDBJNIDatabaseClassMethod(globalTraceOperation, jobject tracer);\nvoid WCDBJNIDatabaseClassMethod(enumerateInfo, jobject javaInfo, jlong cppInfo);\n\nvoid WCDBJNIDatabaseClassMethod(globalTraceDatabaseBusy, jobject tracer, jdouble timeOut);\n\njboolean WCDBJNIDatabaseClassMethod(removeFiles, jlong self);\njboolean WCDBJNIDatabaseClassMethod(moveFile, jlong self, jstring destination);\n\njlong WCDBJNIDatabaseClassMethod(getFileSize, jlong self);\n\nvoid WCDBJNIDatabaseClassMethod(addTokenizer, jlong self, jstring tokenizer);\nvoid WCDBJNIDatabaseClassMethod(addAuxiliaryFunction, jlong self, jstring auxiliaryFunction);\n\nvoid WCDBJNIDatabaseClassMethod(setNotificationWhenCorrupted, jlong self, jobject notification);\njboolean WCDBJNIDatabaseClassMethod(checkIfCorrupted, jlong self);\njboolean WCDBJNIDatabaseClassMethod(checkIfIsAlreadyCorrupted, jlong self);\nvoid WCDBJNIDatabaseClassMethod(enableAutoBackup, jlong self, jboolean enable);\njboolean WCDBJNIDatabaseClassMethod(backup, jlong self);\nvoid WCDBJNIDatabaseClassMethod(filterBackup, jlong self, jobject tableShouldBeBackup);\njboolean WCDBJNIDatabaseClassMethod(deposit, jlong self);\njboolean WCDBJNIDatabaseClassMethod(removeDepositedFiles, jlong self);\njboolean WCDBJNIDatabaseClassMethod(containDepositedFiles, jlong self);\njdouble WCDBJNIDatabaseClassMethod(retrieve, jlong self, jobject onProgressUpdate);\njdouble WCDBJNIDatabaseClassMethod(vacuum, jlong self, jobject onProgressUpdate);\nvoid WCDBJNIDatabaseClassMethod(enableAutoVacuum, jlong self, jboolean incremental);\njboolean WCDBJNIDatabaseClassMethod(incrementalVacuum, jlong self, jint pageCount);\n\njboolean WCDBJNIDatabaseClassMethod(passiveCheckpoint, jlong self);\njboolean WCDBJNIDatabaseClassMethod(truncateCheckpoint, jlong self);\nvoid WCDBJNIDatabaseClassMethod(setAutoCheckpointEnable, jlong self, jboolean enable);\n\nvoid WCDBJNIDatabaseClassMethod(addMigrationSource,\n                                jlong self,\n                                jstring sourcePath,\n                                jbyteArray cipherKey,\n                                jobject filter);\nvoid WCDBJNIDatabaseClassMethod(setMigrationInfo,\n                                jlong infoSetter,\n                                jlong info,\n                                jstring sourceTable,\n                                jlong filterCondition);\njboolean WCDBJNIDatabaseClassMethod(stepMigration, jlong self);\nvoid WCDBJNIDatabaseClassMethod(enableAutoMigration, jlong self, jboolean flag);\nvoid WCDBJNIDatabaseClassMethod(setNotificationWhenMigrated, jlong self, jobject onMigrated);\njboolean WCDBJNIDatabaseClassMethod(isMigrated, jlong self);\n\njbyteArray\nWCDBJNIDatabaseClassMethod(trainDictWithStrings, jobjectArray stringArray, jbyte dictId);\njbyteArray\nWCDBJNIDatabaseClassMethod(trainDictWithDatas, jobjectArray dataArray, jbyte dictId);\njboolean WCDBJNIDatabaseClassMethod(registerDict, jbyteArray dict, jbyte dictId);\nvoid WCDBJNIDatabaseClassMethod(addZSTDNormalCompress, jlong info, jlong column);\nvoid WCDBJNIDatabaseClassMethod(addZSTDDictCompress, jlong info, jlong column, jbyte dictId);\nvoid WCDBJNIDatabaseClassMethod(addZSTDMultiDictCompress,\n                                jlong info,\n                                jlong column,\n                                jlong matchColumn,\n                                jlongArray values,\n                                jbyteArray dictIds);\nvoid WCDBJNIDatabaseClassMethod(enableReplaceCompression, jlong info);\nvoid WCDBJNIDatabaseClassMethod(setCompression, jlong self, jobject filter);\nvoid WCDBJNIDatabaseClassMethod(disableCompressNewData, jlong self, jboolean disable);\njboolean WCDBJNIDatabaseClassMethod(stepCompression, jlong self);\nvoid WCDBJNIDatabaseClassMethod(enableAutoCompression, jlong self, jboolean enable);\nvoid WCDBJNIDatabaseClassMethod(setNotificationWhenCompressed, jlong self, jobject onCompressed);\njboolean WCDBJNIDatabaseClassMethod(isCompressed, jlong self);\njdouble WCDBJNIDatabaseClassMethod(rollbackCompression, jlong self, jobject onProgressUpdate);\n\njint WCDBJNIDatabaseClassMethod(getNumberOfAliveHandle, jlong self);\n"
  },
  {
    "path": "src/java/main/src/main/cpp/core/HandleJNI.c",
    "content": "// Created by qiuwenchen on 2023/4/28.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"HandleJNI.h\"\n#include \"HandleBridge.h\"\n#include \"assert.h\"\n\njlong WCDBJNIHandleClassMethod(getError, jlong self)\n{\n    WCDBJNIBridgeStruct(CPPHandle, self);\n    return (jlong) WCDBHandleGetError(selfStruct).innerValue;\n}\n\njlong WCDBJNIHandleClassMethod(getOrCreatePreparedStatement, jlong self, jlong statement)\n{\n    WCDBJNIBridgeStruct(CPPHandle, self);\n    return (jlong) WCDBHandleGetOrCreatePreparedStatement(selfStruct, (CPPObject *) statement)\n    .innerValue;\n}\n\njlong WCDBJNIHandleClassMethod(getOrCreatePreparedStatementWithSQL, jlong self, jstring sql)\n{\n    WCDBJNIBridgeStruct(CPPHandle, self);\n    WCDBJNIGetString(sql);\n    jlong ret = (jlong) WCDBHandleGetOrCreatePreparedSQL(selfStruct, sqlString).innerValue;\n    WCDBJNIReleaseString(sql);\n    return ret;\n}\n\njlong WCDBJNIHandleClassMethod(prepareNewStatement, jlong self, jlong statement)\n{\n    WCDBJNIBridgeStruct(CPPHandle, self);\n    return (jlong) WCDBHandlePrepareNewStatement(selfStruct, (CPPObject *) statement)\n    .innerValue;\n}\n\njlong WCDBJNIHandleClassMethod(prepareNewStatementWithSQL, jlong self, jstring sql)\n{\n    WCDBJNIBridgeStruct(CPPHandle, self);\n    WCDBJNIGetString(sql);\n    jlong ret = (jlong) WCDBHandlePrepareNewStatementSQL(selfStruct, sqlString).innerValue;\n    WCDBJNIReleaseString(sql);\n    return ret;\n}\n\njlong WCDBJNIHandleClassMethod(getMainStatement, jlong self)\n{\n    WCDBJNIBridgeStruct(CPPHandle, self);\n    return (jlong) WCDBHandleGetMainStatement(selfStruct).innerValue;\n}\n\nvoid WCDBJNIHandleClassMethod(finalizeAndReturnPreparedStatement, jlong self, jlong stmt)\n{\n    WCDBJNIBridgeStruct(CPPHandle, self);\n    WCDBJNIBridgeStruct(CPPHandleStatement, stmt);\n    WCDBHandleFinalizeAndReturnPreparedStatement(selfStruct, stmtStruct);\n}\n\nvoid WCDBJNIHandleClassMethod(finalizeAllStatements, jlong self)\n{\n    WCDBJNIBridgeStruct(CPPHandle, self);\n    WCDBHandleFinalizeStatements(selfStruct);\n}\n\njboolean WCDBJNIHandleClassMethod(execute, jlong self, jlong statement)\n{\n    WCDBJNIBridgeStruct(CPPHandle, self);\n    return WCDBHandleExecute(selfStruct, (CPPObject *) statement);\n}\n\njboolean WCDBJNIHandleClassMethod(executeSQL, jlong self, jstring sql)\n{\n    WCDBJNIBridgeStruct(CPPHandle, self);\n    WCDBJNIGetString(sql);\n    jlong ret = (jlong) WCDBHandleExecuteSQL(selfStruct, sqlString);\n    WCDBJNIReleaseString(sql);\n    return ret;\n}\n\njint WCDBJNIHandleClassMethod(tableExist, jlong self, jstring table)\n{\n    WCDBJNIBridgeStruct(CPPHandle, self);\n    WCDBJNIGetString(table);\n    OptionalBool ret = WCDBHandleExistTable(selfStruct, tableString);\n    WCDBJNIReleaseString(table);\n    return ret.hasValue ? (jint) ret.value : 2;\n}\n\njint WCDBJNIHandleClassMethod(getChanges, jlong self)\n{\n    WCDBJNIBridgeStruct(CPPHandle, self);\n    return WCDBHandleGetChange(selfStruct);\n}\n\njint WCDBJNIHandleClassMethod(getTotalChanges, jlong self)\n{\n    WCDBJNIBridgeStruct(CPPHandle, self);\n    return WCDBHandleGetTotalChange(selfStruct);\n}\n\njlong WCDBJNIHandleClassMethod(getLastInsertRowid, jlong self)\n{\n    WCDBJNIBridgeStruct(CPPHandle, self);\n    return WCDBHandleGetLastInsertedRowID(selfStruct);\n}\n\njboolean WCDBJNIHandleClassMethod(isInTransaction, jlong self)\n{\n    WCDBJNIBridgeStruct(CPPHandle, self);\n    return WCDBHandleIsInTransaction(selfStruct);\n}\n\njboolean WCDBJNIHandleClassMethod(beginTransaction, jlong self)\n{\n    WCDBJNIBridgeStruct(CPPHandle, self);\n    return WCDBHandleBeginTransaction(selfStruct);\n}\n\njboolean WCDBJNIHandleClassMethod(commitTransaction, jlong self)\n{\n    WCDBJNIBridgeStruct(CPPHandle, self);\n    return WCDBHandleCommitTransaction(selfStruct);\n}\n\nvoid WCDBJNIHandleClassMethod(rollbackTransaction, jlong self)\n{\n    WCDBJNIBridgeStruct(CPPHandle, self);\n    return WCDBHandleRollbackTransaction(selfStruct);\n}\n\ntypedef struct TransactionContext {\n    JNIEnv *env;\n    jobject handle;\n    jobject transaction;\n} TransactionContext;\n\nbool WCDBJNIHandleTransactionCallBack(TransactionContext *context, CPPHandle handle)\n{\n    JNIEnv *env = context->env;\n\n    static jmethodID g_methodId = NULL;\n    if (g_methodId == NULL) {\n        g_methodId = (*env)->GetMethodID(\n        env, WCDBJNIGetHandleClass(), \"onTransaction\", \"(JLcom/tencent/wcdb/core/Transaction;)Z\");\n        if (g_methodId == NULL) {\n            assert(0);\n            return false;\n        }\n    }\n    jboolean ret = (*env)->CallBooleanMethod(\n    env, context->handle, g_methodId, (jlong) handle.innerValue, context->transaction);\n    if ((*env)->ExceptionCheck(env)) {\n        ret = false;\n    }\n    return ret;\n}\n\njboolean WCDBJNIHandleObjectMethod(runTransaction, jlong self, jobject transaction)\n{\n    WCDBJNIBridgeStruct(CPPHandle, self);\n    TransactionContext context;\n    context.env = env;\n    context.handle = obj;\n    context.transaction = transaction;\n    return WCDBHandleRunTransaction(\n    selfStruct, &context, (TransactionCallback) WCDBJNIHandleTransactionCallBack);\n}\n\nbool WCDBJNIHandlePausableTransactionCallBack(TransactionContext *context,\n                                              CPPHandle handle,\n                                              bool *stop,\n                                              bool isNewTransaction)\n{\n    JNIEnv *env = context->env;\n\n    static jmethodID g_methodId = NULL;\n    if (g_methodId == NULL) {\n        g_methodId = (*env)->GetMethodID(\n        env, WCDBJNIGetHandleClass(), \"onPausableTransaction\", \"(JLcom/tencent/wcdb/core/PausableTransaction;Z)I\");\n        if (g_methodId == NULL) {\n            assert(0);\n            return false;\n        }\n    }\n    jint ret = (*env)->CallIntMethod(\n    env, context->handle, g_methodId, (jlong) handle.innerValue, context->transaction, isNewTransaction);\n    if ((*env)->ExceptionCheck(env)) {\n        ret = 2;\n    }\n    if (ret == 2) {\n        return false;\n    } else {\n        *stop = ret == 1;\n        return true;\n    }\n}\n\njboolean WCDBJNIHandleObjectMethod(runPausableTransaction, jlong self, jobject transaction)\n{\n    WCDBJNIBridgeStruct(CPPHandle, self);\n    TransactionContext context;\n    context.env = env;\n    context.handle = obj;\n    context.transaction = transaction;\n    return WCDBHandleRunPausableTransaction(\n    selfStruct, &context, (PausableTransaction) WCDBJNIHandlePausableTransactionCallBack);\n}\n\njlong WCDBJNIHandleClassMethodWithNoArg(createCancellationSignal)\n{\n    jlong ret = (jlong) WCDBCancellationSignalCreate().innerValue;\n    return ret;\n}\n\nvoid WCDBJNIHandleClassMethod(cancelSignal, jlong signal)\n{\n    WCDBJNIBridgeStruct(CPPCancellationSignal, signal);\n    WCDBCancellationSignalCancel(signalStruct);\n}\n\nvoid WCDBJNIHandleClassMethod(attachCancellationSignal, jlong self, jlong signal)\n{\n    WCDBJNIBridgeStruct(CPPHandle, self);\n    WCDBJNIBridgeStruct(CPPCancellationSignal, signal);\n    WCDBHandleAttachCancellationSignal(selfStruct, signalStruct);\n}\n\nvoid WCDBJNIHandleClassMethod(detachCancellationSignal, jlong self)\n{\n    WCDBJNIBridgeStruct(CPPHandle, self);\n    WCDBHandleDettachCancellationSignal(selfStruct);\n}\n"
  },
  {
    "path": "src/java/main/src/main/cpp/core/HandleJNI.h",
    "content": "// Created by qiuwenchen on 2023/4/28.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"WCDBJNI.h\"\n\n#define WCDBJNIHandleFuncName(funcName) WCDBJNI(Handle, funcName)\n#define WCDBJNIHandleObjectMethod(funcName, ...)                               \\\n    WCDBJNIObjectMethod(Handle, funcName, __VA_ARGS__)\n#define WCDBJNIHandleObjectMethodWithNoArg(funcName)                           \\\n    WCDBJNIObjectMethodWithNoArg(Handle, funcName)\n#define WCDBJNIHandleClassMethodWithNoArg(funcName)                            \\\n    WCDBJNIClassMethodWithNoArg(Handle, funcName)\n#define WCDBJNIHandleClassMethod(funcName, ...)                                \\\n    WCDBJNIClassMethod(Handle, funcName, __VA_ARGS__)\n\njlong WCDBJNIHandleClassMethod(getError, jlong self);\njlong WCDBJNIHandleClassMethod(getOrCreatePreparedStatement, jlong self, jlong statement);\njlong WCDBJNIHandleClassMethod(getOrCreatePreparedStatementWithSQL, jlong self, jstring sql);\njlong WCDBJNIHandleClassMethod(prepareNewStatement, jlong self, jlong statement);\njlong WCDBJNIHandleClassMethod(prepareNewStatementWithSQL, jlong self, jstring sql);\njlong WCDBJNIHandleClassMethod(getMainStatement, jlong self);\nvoid WCDBJNIHandleClassMethod(finalizeAndReturnPreparedStatement, jlong self, jlong stmt);\nvoid WCDBJNIHandleClassMethod(finalizeAllStatements, jlong self);\njboolean WCDBJNIHandleClassMethod(execute, jlong self, jlong statement);\njboolean WCDBJNIHandleClassMethod(executeSQL, jlong self, jstring sql);\njint WCDBJNIHandleClassMethod(tableExist, jlong self, jstring table);\n\njint WCDBJNIHandleClassMethod(getChanges, jlong self);\njint WCDBJNIHandleClassMethod(getTotalChanges, jlong self);\njlong WCDBJNIHandleClassMethod(getLastInsertRowid, jlong self);\n\njboolean WCDBJNIHandleClassMethod(isInTransaction, jlong self);\njboolean WCDBJNIHandleClassMethod(beginTransaction, jlong self);\njboolean WCDBJNIHandleClassMethod(commitTransaction, jlong self);\nvoid WCDBJNIHandleClassMethod(rollbackTransaction, jlong self);\n\njboolean WCDBJNIHandleObjectMethod(runTransaction, jlong self, jobject transaction);\njboolean WCDBJNIHandleObjectMethod(runPausableTransaction, jlong self, jobject transaction);\n\njlong WCDBJNIHandleClassMethodWithNoArg(createCancellationSignal);\nvoid WCDBJNIHandleClassMethod(cancelSignal, jlong signal);\n\nvoid WCDBJNIHandleClassMethod(attachCancellationSignal, jlong self, jlong signal);\nvoid WCDBJNIHandleClassMethod(detachCancellationSignal, jlong self);\n"
  },
  {
    "path": "src/java/main/src/main/cpp/core/HandleStatementJNI.c",
    "content": "// Created by qiuwenchen on 2023/4/20.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"HandleStatementJNI.h\"\n#include \"HandleStatementBridge.h\"\n\njlong WCDBJNIHandleStatementClassMethod(getError, jlong self)\n{\n    WCDBJNIBridgeStruct(CPPHandleStatement, self);\n    return (jlong) WCDBHandleStatementGetError(selfStruct).innerValue;\n}\n\njboolean WCDBJNIHandleStatementClassMethod(prepare, jlong self, jlong statement)\n{\n    WCDBJNIBridgeStruct(CPPHandleStatement, self);\n    return WCDBHandleStatementPrepare(selfStruct, (CPPObject *) statement);\n}\n\njboolean WCDBJNIHandleStatementClassMethod(prepareSQL, jlong self, jstring sql)\n{\n    WCDBJNIBridgeStruct(CPPHandleStatement, self);\n    WCDBJNIGetString(sql);\n    jboolean ret = WCDBHandleStatementPrepareSQL(selfStruct, sqlString);\n    WCDBJNIReleaseString(sql);\n    return ret;\n}\n\njboolean WCDBJNIHandleStatementClassMethod(checkPrepared, jlong self)\n{\n    WCDBJNIBridgeStruct(CPPHandleStatement, self);\n    return WCDBHandleStatementCheckPrepared(selfStruct);\n}\n\njboolean WCDBJNIHandleStatementClassMethod(step, jlong self)\n{\n    WCDBJNIBridgeStruct(CPPHandleStatement, self);\n    return WCDBHandleStatementStep(selfStruct);\n}\n\nvoid WCDBJNIHandleStatementClassMethod(reset, jlong self)\n{\n    WCDBJNIBridgeStruct(CPPHandleStatement, self);\n    WCDBHandleStatementReset(selfStruct);\n}\n\nvoid WCDBJNIHandleStatementClassMethod(clearBindings, jlong self)\n{\n    WCDBJNIBridgeStruct(CPPHandleStatement, self);\n    WCDBHandleStatementClearBindings(selfStruct);\n}\n\nvoid WCDBJNIHandleStatementClassMethod(finalize, jlong self)\n{\n    WCDBJNIBridgeStruct(CPPHandleStatement, self);\n    WCDBHandleStatementFinalize(selfStruct);\n}\n\njboolean WCDBJNIHandleStatementClassMethod(isDone, jlong self)\n{\n    WCDBJNIBridgeStruct(CPPHandleStatement, self);\n    return WCDBHandleStatementIsDone(selfStruct);\n}\n\nvoid WCDBJNIHandleStatementClassMethod(bindInteger, jlong self, jlong value, jint index)\n{\n    WCDBJNIBridgeStruct(CPPHandleStatement, self);\n    WCDBHandleStatementBindInteger(selfStruct, index, value);\n}\n\nvoid WCDBJNIHandleStatementClassMethod(bindDouble, jlong self, jdouble value, jint index)\n{\n    WCDBJNIBridgeStruct(CPPHandleStatement, self);\n    WCDBHandleStatementBindDouble(selfStruct, index, value);\n}\n\nvoid WCDBJNIHandleStatementClassMethod(bindText, jlong self, jstring value, jint index)\n{\n    WCDBJNIBridgeStruct(CPPHandleStatement, self);\n    int valueLength = 0;\n    const jchar *valueUTF16String = NULL;\n    if (value != NULL) {\n        valueLength = (*env)->GetStringLength(env, value);\n        valueUTF16String = (*env)->GetStringCritical(env, value, 0);\n    }\n    WCDBHandleStatementBindText16(\n    selfStruct, index, (const short *) valueUTF16String, valueLength);\n    if (valueUTF16String != NULL) {\n        (*env)->ReleaseStringCritical(env, value, valueUTF16String);\n    }\n}\n\nvoid WCDBJNIHandleStatementClassMethod(bindBLOB, jlong self, jbyteArray value, jint index)\n{\n    WCDBJNIBridgeStruct(CPPHandleStatement, self);\n    WCDBJNIGetByteArrayCritical(value);\n    WCDBHandleStatementBindBlob(selfStruct, index, valueArray, valueLength);\n    WCDBJNIReleaseByteArrayCritical(value);\n}\n\nvoid WCDBJNIHandleStatementClassMethod(bindNull, jlong self, jint index)\n{\n    WCDBJNIBridgeStruct(CPPHandleStatement, self);\n    WCDBHandleStatementBindNull(selfStruct, index);\n}\n\njint WCDBJNIHandleStatementClassMethod(bindParameterIndex, jlong self, jstring parameterName)\n{\n    WCDBJNIBridgeStruct(CPPHandleStatement, self);\n    WCDBJNIGetString(parameterName);\n    jint index = WCDBHandleStatementBindParameterIndex(selfStruct, parameterNameString);\n    WCDBJNIReleaseString(parameterName);\n    return index;\n}\n\njint WCDBJNIHandleStatementClassMethod(getColumnType, jlong self, jint index)\n{\n    WCDBJNIBridgeStruct(CPPHandleStatement, self);\n    return WCDBHandleStatementGetColumnType(selfStruct, index);\n}\n\njlong WCDBJNIHandleStatementClassMethod(getInteger, jlong self, jint index)\n{\n    WCDBJNIBridgeStruct(CPPHandleStatement, self);\n    return WCDBHandleStatementGetInteger(selfStruct, index);\n}\n\njdouble WCDBJNIHandleStatementClassMethod(getDouble, jlong self, jint index)\n{\n    WCDBJNIBridgeStruct(CPPHandleStatement, self);\n    return WCDBHandleStatementGetDouble(selfStruct, index);\n}\n\njstring WCDBJNIHandleStatementClassMethod(getText, jlong self, jint index)\n{\n    WCDBJNIBridgeStruct(CPPHandleStatement, self);\n    const jchar *utf16Value\n    = (const jchar *) WCDBHandleStatementGetText16(selfStruct, index);\n    jsize utf16ValueLength = WCDBHandleStatementGetText16Length(selfStruct, index);\n    return (*env)->NewString(env, utf16Value, utf16ValueLength);\n}\n\njbyteArray WCDBJNIHandleStatementClassMethod(getBLOB, jlong self, jint index)\n{\n    WCDBJNIBridgeStruct(CPPHandleStatement, self);\n    jbyte *buffer = (jbyte *) WCDBHandleStatementGetBlob(selfStruct, index);\n    jsize size = (jsize) WCDBHandleStatementGetColumnSize(selfStruct, index);\n    if (buffer == NULL || size == 0) {\n        return (*env)->NewByteArray(env, 0);\n    }\n    jbyteArray array = (*env)->NewByteArray(env, size);\n    if (array != NULL) {\n        (*env)->SetByteArrayRegion(env, array, 0, size, buffer);\n    }\n    return array;\n}\n\njint WCDBJNIHandleStatementClassMethod(getColumnCount, jlong self)\n{\n    WCDBJNIBridgeStruct(CPPHandleStatement, self);\n    return WCDBHandleStatementGetColumnCount(selfStruct);\n}\n\njstring WCDBJNIHandleStatementClassMethod(getColumnName, jlong self, jint index)\n{\n    WCDBJNIBridgeStruct(CPPHandleStatement, self);\n    WCDBJNICreateJStringAndReturn(WCDBHandleStatementGetColumnName(selfStruct, index));\n}\n\njstring WCDBJNIHandleStatementClassMethod(getOriginalColumnName, jlong self, jint index)\n{\n    WCDBJNIBridgeStruct(CPPHandleStatement, self);\n    WCDBJNICreateJStringAndReturn(WCDBHandleStatementGetOriginalColumnName(selfStruct, index));\n}\n\njstring WCDBJNIHandleStatementClassMethod(getColumnTableName, jlong self, jint index)\n{\n    WCDBJNIBridgeStruct(CPPHandleStatement, self);\n    WCDBJNICreateJStringAndReturn(WCDBHandleStatementGetColumnTableName(selfStruct, index));\n}\n\njboolean WCDBJNIHandleStatementClassMethod(isReadOnly, jlong self)\n{\n    WCDBJNIBridgeStruct(CPPHandleStatement, self);\n    return WCDBHandleStatementIsReadOnly(selfStruct);\n}\n"
  },
  {
    "path": "src/java/main/src/main/cpp/core/HandleStatementJNI.h",
    "content": "// Created by qiuwenchen on 2023/4/20.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"WCDBJNI.h\"\n\n#define WCDBJNIHandleStatementFuncName(funcName)                               \\\n    WCDBJNI(HandleStatement, funcName)\n#define WCDBJNIHandleStatementObjectMethod(funcName, ...)                      \\\n    WCDBJNIObjectMethod(HandleStatement, funcName, __VA_ARGS__)\n#define WCDBJNIHandleStatementObjectMethodWithNoArg(funcName)                  \\\n    WCDBJNIObjectMethodWithNoArg(HandleStatement, funcName)\n#define WCDBJNIHandleStatementClassMethodWithNoArg(funcName)                   \\\n    WCDBJNIClassMethodWithNoArg(HandleStatement, funcName)\n#define WCDBJNIHandleStatementClassMethod(funcName, ...)                       \\\n    WCDBJNIClassMethod(HandleStatement, funcName, __VA_ARGS__)\n\njlong WCDBJNIHandleStatementClassMethod(getError, jlong self);\njboolean WCDBJNIHandleStatementClassMethod(prepare, jlong self, jlong statement);\njboolean WCDBJNIHandleStatementClassMethod(prepareSQL, jlong self, jstring sql);\njboolean WCDBJNIHandleStatementClassMethod(checkPrepared, jlong self);\njboolean WCDBJNIHandleStatementClassMethod(step, jlong self);\nvoid WCDBJNIHandleStatementClassMethod(reset, jlong self);\nvoid WCDBJNIHandleStatementClassMethod(clearBindings, jlong self);\nvoid WCDBJNIHandleStatementClassMethod(finalize, jlong self);\njboolean WCDBJNIHandleStatementClassMethod(isDone, jlong self);\nvoid WCDBJNIHandleStatementClassMethod(bindInteger, jlong self, jlong value, jint index);\nvoid WCDBJNIHandleStatementClassMethod(bindDouble, jlong self, jdouble value, jint index);\nvoid WCDBJNIHandleStatementClassMethod(bindText, jlong self, jstring value, jint index);\nvoid WCDBJNIHandleStatementClassMethod(bindBLOB, jlong self, jbyteArray value, jint index);\nvoid WCDBJNIHandleStatementClassMethod(bindNull, jlong self, jint index);\njint WCDBJNIHandleStatementClassMethod(bindParameterIndex, jlong self, jstring parameterName);\njint WCDBJNIHandleStatementClassMethod(getColumnType, jlong self, jint index);\njlong WCDBJNIHandleStatementClassMethod(getInteger, jlong self, jint index);\njdouble WCDBJNIHandleStatementClassMethod(getDouble, jlong self, jint index);\njstring WCDBJNIHandleStatementClassMethod(getText, jlong self, jint index);\njbyteArray WCDBJNIHandleStatementClassMethod(getBLOB, jlong self, jint index);\njint WCDBJNIHandleStatementClassMethod(getColumnCount, jlong self);\njstring WCDBJNIHandleStatementClassMethod(getColumnName, jlong self, jint index);\njstring WCDBJNIHandleStatementClassMethod(getOriginalColumnName, jlong self, jint index);\njstring WCDBJNIHandleStatementClassMethod(getColumnTableName, jlong self, jint index);\njboolean WCDBJNIHandleStatementClassMethod(isReadOnly, jlong self);\n"
  },
  {
    "path": "src/java/main/src/main/cpp/winq/Statement/StatementAlterTableJNI.c",
    "content": "// Created by chenqiuwen on 2023/6/11.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"StatementAlterTableJNI.h\"\n#include \"StatementAlterTableBridge.h\"\n\njlong WCDBJNIStatementAlterTableClassMethodWithNoArg(createCppObj)\n{\n    return (jlong) WCDBStatementAlterTableCreate().innerValue;\n}\n\nvoid WCDBJNIStatementAlterTableClassMethod(configTable, jlong self, jstring table)\n{\n    WCDBJNIBridgeStruct(CPPStatementAlterTable, self);\n    WCDBJNIGetStringCritical(table);\n    WCDBStatementAlterTableConfigTable(selfStruct, tableString);\n    WCDBJNIReleaseStringCritical(table);\n}\n\nvoid WCDBJNIStatementAlterTableClassMethod(configSchema,\n                                           jlong self,\n                                           WCDBJNIObjectOrStringParameter(schema))\n{\n    WCDBJNIBridgeStruct(CPPStatementAlterTable, self);\n    WCDBJNICreateObjectOrStringCommonValue(schema, true);\n    WCDBStatementAlterTableConfigSchema2(selfStruct, schema_common);\n    WCDBJNITryReleaseStringInCommonValue(schema);\n}\n\nvoid WCDBJNIStatementAlterTableClassMethod(configRenameToTable, jlong self, jstring table)\n{\n    WCDBJNIBridgeStruct(CPPStatementAlterTable, self);\n    WCDBJNIGetStringCritical(table);\n    WCDBStatementAlterTableConfigRenameToTable(selfStruct, tableString);\n    WCDBJNIReleaseStringCritical(table);\n}\n\nvoid WCDBJNIStatementAlterTableClassMethod(configRenameColumn,\n                                           jlong self,\n                                           WCDBJNIObjectOrStringParameter(column))\n{\n    WCDBJNIBridgeStruct(CPPStatementAlterTable, self);\n    WCDBJNICreateObjectOrStringCommonValue(column, true);\n    WCDBStatementAlterTableConfigRenameColumn2(selfStruct, column_common);\n    WCDBJNITryReleaseStringInCommonValue(column);\n}\n\nvoid WCDBJNIStatementAlterTableClassMethod(configRenameToColumn,\n                                           jlong self,\n                                           WCDBJNIObjectOrStringParameter(column))\n{\n    WCDBJNIBridgeStruct(CPPStatementAlterTable, self);\n    WCDBJNICreateObjectOrStringCommonValue(column, true);\n    WCDBStatementAlterTableConfigRenameToColumn2(selfStruct, column_common);\n    WCDBJNITryReleaseStringInCommonValue(column);\n}\n\nvoid WCDBJNIStatementAlterTableClassMethod(configAddColumn, jlong self, jlong columnDef)\n{\n    WCDBJNIBridgeStruct(CPPStatementAlterTable, self);\n    WCDBJNIBridgeStruct(CPPColumnDef, columnDef);\n    WCDBStatementAlterTableConfigAddColumn(selfStruct, columnDefStruct);\n}\n"
  },
  {
    "path": "src/java/main/src/main/cpp/winq/Statement/StatementAlterTableJNI.h",
    "content": "// Created by chenqiuwen on 2023/6/11.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"WCDBJNI.h\"\n\n#pragma once\n#define WCDBJNIStatementAlterTableFuncName(funcName)                           \\\n    WCDBJNI(StatementAlterTable, funcName)\n#define WCDBJNIStatementAlterTableObjectMethod(funcName, ...)                  \\\n    WCDBJNIObjectMethod(StatementAlterTable, funcName, __VA_ARGS__)\n#define WCDBJNIStatementAlterTableClassMethodWithNoArg(funcName)               \\\n    WCDBJNIClassMethodWithNoArg(StatementAlterTable, funcName)\n#define WCDBJNIStatementAlterTableClassMethod(funcName, ...)                   \\\n    WCDBJNIClassMethod(StatementAlterTable, funcName, __VA_ARGS__)\n\njlong WCDBJNIStatementAlterTableClassMethodWithNoArg(createCppObj);\nvoid WCDBJNIStatementAlterTableClassMethod(configTable, jlong self, jstring table);\nvoid WCDBJNIStatementAlterTableClassMethod(configSchema,\n                                           jlong self,\n                                           WCDBJNIObjectOrStringParameter(schema));\nvoid WCDBJNIStatementAlterTableClassMethod(configRenameToTable, jlong self, jstring table);\nvoid WCDBJNIStatementAlterTableClassMethod(configRenameColumn,\n                                           jlong self,\n                                           WCDBJNIObjectOrStringParameter(column));\nvoid WCDBJNIStatementAlterTableClassMethod(configRenameToColumn,\n                                           jlong self,\n                                           WCDBJNIObjectOrStringParameter(column));\nvoid WCDBJNIStatementAlterTableClassMethod(configAddColumn, jlong self, jlong columnDef);\n"
  },
  {
    "path": "src/java/main/src/main/cpp/winq/Statement/StatementAnalyzeJNI.c",
    "content": "// Created by chenqiuwen on 2023/6/11.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"StatementAnalyzeJNI.h\"\n#include \"StatementAnalyzeBridge.h\"\n\njlong WCDBJNIStatementAnalyzeClassMethodWithNoArg(createCppObj)\n{\n    return (jlong) WCDBStatementAnalyzeCreate().innerValue;\n}\n\nvoid WCDBJNIStatementAnalyzeClassMethod(toAnalyze, jlong analyze)\n{\n    WCDBJNIBridgeStruct(CPPStatementAnalyze, analyze);\n    WCDBStatementAnalyzeToAnalyze(analyzeStruct);\n}\n\nvoid WCDBJNIStatementAnalyzeClassMethod(configSchema,\n                                        jlong analyze,\n                                        WCDBJNIObjectOrStringParameter(schema))\n{\n    WCDBJNIBridgeStruct(CPPStatementAnalyze, analyze);\n    WCDBJNICreateObjectOrStringCommonValue(schema, true);\n    WCDBStatementAnalyzeConfigSchema2(analyzeStruct, schema_common);\n    WCDBJNITryReleaseStringInCommonValue(schema);\n}\n\nvoid WCDBJNIStatementAnalyzeClassMethod(configTable, jlong analyze, jstring table)\n{\n    WCDBJNIBridgeStruct(CPPStatementAnalyze, analyze);\n    WCDBJNIGetStringCritical(table);\n    WCDBStatementAnalyzeConfigTable(analyzeStruct, tableString);\n    WCDBJNIReleaseStringCritical(table);\n}\n\nvoid WCDBJNIStatementAnalyzeClassMethod(configIndex, jlong analyze, jstring index)\n{\n    WCDBJNIBridgeStruct(CPPStatementAnalyze, analyze);\n    WCDBJNIGetStringCritical(index);\n    WCDBStatementAnalyzeConfigIndex(analyzeStruct, indexString);\n    WCDBJNIReleaseStringCritical(index);\n}\n"
  },
  {
    "path": "src/java/main/src/main/cpp/winq/Statement/StatementAnalyzeJNI.h",
    "content": "// Created by chenqiuwen on 2023/6/11.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"WCDBJNI.h\"\n\n#pragma once\n#define WCDBJNIStatementAnalyzeFuncName(funcName)                              \\\n    WCDBJNI(StatementAnalyze, funcName)\n#define WCDBJNIStatementAnalyzeObjectMethod(funcName, ...)                     \\\n    WCDBJNIObjectMethod(StatementAnalyze, funcName, __VA_ARGS__)\n#define WCDBJNIStatementAnalyzeClassMethodWithNoArg(funcName)                  \\\n    WCDBJNIClassMethodWithNoArg(StatementAnalyze, funcName)\n#define WCDBJNIStatementAnalyzeClassMethod(funcName, ...)                      \\\n    WCDBJNIClassMethod(StatementAnalyze, funcName, __VA_ARGS__)\n\njlong WCDBJNIStatementAnalyzeClassMethodWithNoArg(createCppObj);\nvoid WCDBJNIStatementAnalyzeClassMethod(toAnalyze, jlong analyze);\nvoid WCDBJNIStatementAnalyzeClassMethod(configSchema,\n                                        jlong analyze,\n                                        WCDBJNIObjectOrStringParameter(schema));\nvoid WCDBJNIStatementAnalyzeClassMethod(configTable, jlong analyze, jstring table);\nvoid WCDBJNIStatementAnalyzeClassMethod(configIndex, jlong analyze, jstring index);\n"
  },
  {
    "path": "src/java/main/src/main/cpp/winq/Statement/StatementAttachJNI.c",
    "content": "// Created by chenqiuwen on 2023/6/11.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"StatementAttachJNI.h\"\n#include \"StatementAttachBridge.h\"\n\njlong WCDBJNIStatementAttachClassMethodWithNoArg(createCppObj)\n{\n    return (jlong) WCDBStatementAttachCreate().innerValue;\n}\n\nvoid WCDBJNIStatementAttachClassMethod(configPath, jlong self, WCDBJNIObjectOrStringParameter(path))\n{\n    WCDBJNIBridgeStruct(CPPStatementAttach, self);\n    WCDBJNICreateObjectOrStringCommonValue(path, true);\n    WCDBStatementAttachConfigPath2(selfStruct, path_common);\n    WCDBJNITryReleaseStringInCommonValue(path);\n}\n\nvoid WCDBJNIStatementAttachClassMethod(configSchema,\n                                       jlong self,\n                                       WCDBJNIObjectOrStringParameter(schema))\n{\n    WCDBJNIBridgeStruct(CPPStatementAttach, self);\n    WCDBJNICreateObjectOrStringCommonValue(schema, true);\n    WCDBStatementAttachConfigSchema2(selfStruct, schema_common);\n    WCDBJNITryReleaseStringInCommonValue(schema);\n}\n\nvoid WCDBJNIStatementAttachClassMethod(configKey, jlong self, WCDBJNIObjectOrStringParameter(key))\n{\n    WCDBJNIBridgeStruct(CPPStatementAttach, self);\n    WCDBJNICreateObjectOrStringCommonValue(key, true);\n    WCDBStatementAttachConfigKey2(selfStruct, key_common);\n    WCDBJNITryReleaseStringInCommonValue(key);\n}\n"
  },
  {
    "path": "src/java/main/src/main/cpp/winq/Statement/StatementAttachJNI.h",
    "content": "// Created by chenqiuwen on 2023/6/11.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"WCDBJNI.h\"\n\n#pragma once\n#define WCDBJNIStatementAttachFuncName(funcName)                               \\\n    WCDBJNI(StatementAttach, funcName)\n#define WCDBJNIStatementAttachObjectMethod(funcName, ...)                      \\\n    WCDBJNIObjectMethod(StatementAttach, funcName, __VA_ARGS__)\n#define WCDBJNIStatementAttachClassMethodWithNoArg(funcName)                   \\\n    WCDBJNIClassMethodWithNoArg(StatementAttach, funcName)\n#define WCDBJNIStatementAttachClassMethod(funcName, ...)                       \\\n    WCDBJNIClassMethod(StatementAttach, funcName, __VA_ARGS__)\n\njlong WCDBJNIStatementAttachClassMethodWithNoArg(createCppObj);\nvoid WCDBJNIStatementAttachClassMethod(configPath,\n                                       jlong self,\n                                       WCDBJNIObjectOrStringParameter(path));\nvoid WCDBJNIStatementAttachClassMethod(configSchema,\n                                       jlong self,\n                                       WCDBJNIObjectOrStringParameter(schema));\nvoid WCDBJNIStatementAttachClassMethod(configKey, jlong self, WCDBJNIObjectOrStringParameter(key));"
  },
  {
    "path": "src/java/main/src/main/cpp/winq/Statement/StatementBeginJNI.c",
    "content": "// Created by chenqiuwen on 2023/4/9.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"StatementBeginJNI.h\"\n#include \"StatementBeginBridge.h\"\n\njlong WCDBJNIStatementBeginClassMethod(create, jint type)\n{\n    CPPStatementBegin begin = WCDBStatementBeginCreate();\n    WCDBStatementBeginConfigType(begin, type);\n    return (jlong) begin.innerValue;\n}\n"
  },
  {
    "path": "src/java/main/src/main/cpp/winq/Statement/StatementBeginJNI.h",
    "content": "// Created by chenqiuwen on 2023/4/9.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n#include \"WCDBJNI.h\"\n\n#define WCDBJNIStatementBeginFuncName(funcName)                                \\\n    WCDBJNI(StatementBegin, funcName)\n#define WCDBJNIStatementBeginObjectMethod(funcName, ...)                       \\\n    WCDBJNIObjectMethod(StatementBegin, funcName, __VA_ARGS__)\n#define WCDBJNIStatementBeginClassMethodWithNoArg(funcName)                    \\\n    WCDBJNIClassMethodWithNoArg(StatementBegin, funcName)\n#define WCDBJNIStatementBeginClassMethod(funcName, ...)                        \\\n    WCDBJNIClassMethod(StatementBegin, funcName, __VA_ARGS__)\n\njlong WCDBJNIStatementBeginClassMethod(create, jint type);\n"
  },
  {
    "path": "src/java/main/src/main/cpp/winq/Statement/StatementCommitJNI.c",
    "content": "// Created by chenqiuwen on 2023/4/9.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"StatementCommitJNI.h\"\n#include \"StatementCommitBridge.h\"\n\njlong WCDBJNIStatementCommitClassMethodWithNoArg(create)\n{\n    return (jlong) WCDBStatementCommitCreate().innerValue;\n}\n"
  },
  {
    "path": "src/java/main/src/main/cpp/winq/Statement/StatementCommitJNI.h",
    "content": "// Created by chenqiuwen on 2023/4/9.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"WCDBJNI.h\"\n\n#define WCDBJNIStatementCommitFuncName(funcName)                               \\\n    WCDBJNI(StatementCommit, funcName)\n#define WCDBJNIStatementCommitObjectMethod(funcName, ...)                      \\\n    WCDBJNIObjectMethod(StatementCommit, funcName, __VA_ARGS__)\n#define WCDBJNIStatementCommitObjectMethodWithNoArg(funcName)                  \\\n    WCDBJNIObjectMethodWithNoArg(StatementCommit, funcName)\n#define WCDBJNIStatementCommitClassMethodWithNoArg(funcName)                   \\\n    WCDBJNIClassMethodWithNoArg(StatementCommit, funcName)\n\njlong WCDBJNIStatementCommitClassMethodWithNoArg(create);\n"
  },
  {
    "path": "src/java/main/src/main/cpp/winq/Statement/StatementCreateTableJNI.c",
    "content": "// Created by qiuwenchen on 2023/4/11.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"StatementCreateTableJNI.h\"\n#include \"StatementCreateTableBridge.h\"\n\njlong WCDBJNIStatementCreateTableClassMethodWithNoArg(create)\n{\n    return (jlong) WCDBStatementCreateTableCreate().innerValue;\n}\n\nvoid WCDBJNIStatementCreateTableClassMethod(configTableName, jlong self, jstring tableName)\n{\n    WCDBJNIBridgeStruct(CPPStatementCreateTable, self);\n    WCDBJNIGetStringCritical(tableName);\n    WCDBStatementCreateTableConfigTable(selfStruct, tableNameString);\n    WCDBJNIReleaseStringCritical(tableName);\n}\n\nvoid WCDBJNIStatementCreateTableClassMethod(configSchema,\n                                            jlong self,\n                                            WCDBJNIObjectOrStringParameter(schema))\n{\n    WCDBJNIBridgeStruct(CPPStatementCreateTable, self);\n    WCDBJNICreateObjectOrStringCommonValue(schema, true);\n    WCDBStatementCreateTableConfigSchema2(selfStruct, schema_common);\n    WCDBJNITryReleaseStringInCommonValue(schema);\n}\n\nvoid WCDBJNIStatementCreateTableClassMethod(configTemp, jlong self)\n{\n    WCDBJNIBridgeStruct(CPPStatementCreateTable, self);\n    WCDBStatementCreateTableConfigTemp(selfStruct);\n}\n\nvoid WCDBJNIStatementCreateTableClassMethod(configIfNotExist, jlong self)\n{\n    WCDBJNIBridgeStruct(CPPStatementCreateTable, self);\n    WCDBStatementCreateTableConfigIfNotExist(selfStruct);\n}\n\nvoid WCDBJNIStatementCreateTableClassMethod(configAs, jlong self, jlong select)\n{\n    WCDBJNIBridgeStruct(CPPStatementCreateTable, self);\n    WCDBJNIBridgeStruct(CPPStatementSelect, select);\n    WCDBStatementCreateTableConfigAs(selfStruct, selectStruct);\n}\n\nvoid WCDBJNIStatementCreateTableClassMethod(configColumn, jlong self, jlong column)\n{\n    WCDBJNIBridgeStruct(CPPStatementCreateTable, self);\n    WCDBJNIBridgeStruct(CPPColumnDef, column);\n    WCDBStatementCreateTableConfigColumn(selfStruct, columnStruct);\n}\n\nvoid WCDBJNIStatementCreateTableClassMethod(configColumns, jlong self, jlongArray columns)\n{\n    WCDBJNIBridgeStruct(CPPStatementCreateTable, self);\n    WCDBJNIGetCppPointerArrayCritical(columns);\n    WCDBStatementCreateTableConfigColumns(\n    selfStruct, (const CPPColumnDef *) columnsArray, columnsLength);\n    WCDBJNIReleaseCppPointerArrayCritical(columns);\n}\n\nvoid WCDBJNIStatementCreateTableClassMethod(configConstraints, jlong self, jlongArray constraints)\n{\n    WCDBJNIBridgeStruct(CPPStatementCreateTable, self);\n    WCDBJNIGetCppPointerArrayCritical(constraints);\n    WCDBStatementCreateTableConfigTableConstraints(\n    selfStruct, (const CPPTableConstraint *) constraintsArray, constraintsLength);\n    WCDBJNIReleaseCppPointerArrayCritical(constraints)\n}\n\nvoid WCDBJNIStatementCreateTableClassMethod(configWithoutRowid, jlong self)\n{\n    WCDBJNIBridgeStruct(CPPStatementCreateTable, self);\n    WCDBStatementCreateTableConfigWithoutRowId(selfStruct);\n}\n"
  },
  {
    "path": "src/java/main/src/main/cpp/winq/Statement/StatementCreateTableJNI.h",
    "content": "// Created by qiuwenchen on 2023/4/11.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"WCDBJNI.h\"\n\n#define WCDBJNIStatementCreateTableFuncName(funcName)                          \\\n    WCDBJNI(StatementCreateTable, funcName)\n#define WCDBJNIStatementCreateTableObjectMethod(funcName, ...)                 \\\n    WCDBJNIObjectMethod(StatementCreateTable, funcName, __VA_ARGS__)\n#define WCDBJNIStatementCreateTableObjectMethodWithNoArg(funcName)             \\\n    WCDBJNIObjectMethodWithNoArg(StatementCreateTable, funcName)\n#define WCDBJNIStatementCreateTableClassMethodWithNoArg(funcName)              \\\n    WCDBJNIClassMethodWithNoArg(StatementCreateTable, funcName)\n#define WCDBJNIStatementCreateTableClassMethod(funcName, ...)                  \\\n    WCDBJNIClassMethod(StatementCreateTable, funcName, __VA_ARGS__)\n\njlong WCDBJNIStatementCreateTableClassMethodWithNoArg(create);\nvoid WCDBJNIStatementCreateTableClassMethod(configTableName, jlong self, jstring tableName);\nvoid WCDBJNIStatementCreateTableClassMethod(configSchema,\n                                            jlong self,\n                                            WCDBJNIObjectOrStringParameter(schema));\nvoid WCDBJNIStatementCreateTableClassMethod(configTemp, jlong self);\nvoid WCDBJNIStatementCreateTableClassMethod(configIfNotExist, jlong self);\nvoid WCDBJNIStatementCreateTableClassMethod(configAs, jlong self, jlong select);\nvoid WCDBJNIStatementCreateTableClassMethod(configColumn, jlong self, jlong column);\nvoid WCDBJNIStatementCreateTableClassMethod(configColumns, jlong self, jlongArray columns);\nvoid WCDBJNIStatementCreateTableClassMethod(configConstraints, jlong self, jlongArray constraints);\nvoid WCDBJNIStatementCreateTableClassMethod(configWithoutRowid, jlong self);"
  },
  {
    "path": "src/java/main/src/main/cpp/winq/Statement/StatementCreateTriggerJNI.c",
    "content": "// Created by chenqiuwen on 2023/6/11.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"StatementCreateTriggerJNI.h\"\n#include \"StatementCreateTriggerBridge.h\"\n\njlong WCDBJNIStatementCreateTriggerClassMethodWithNoArg(createCppObj)\n{\n    return (jlong) WCDBStatementCreateTriggerCreate().innerValue;\n}\n\nvoid WCDBJNIStatementCreateTriggerClassMethod(configTrigger, jlong self, jstring name)\n{\n    WCDBJNIBridgeStruct(CPPStatementCreateTrigger, self);\n    WCDBJNIGetStringCritical(name);\n    WCDBStatementCreateTriggerConfigTrigger(selfStruct, nameString);\n    WCDBJNIReleaseStringCritical(name);\n}\n\nvoid WCDBJNIStatementCreateTriggerClassMethod(configSchema,\n                                              jlong self,\n                                              WCDBJNIObjectOrStringParameter(schema))\n{\n    WCDBJNIBridgeStruct(CPPStatementCreateTrigger, self);\n    WCDBJNICreateObjectOrStringCommonValue(schema, true);\n    WCDBStatementCreateTriggerConfigSchema2(selfStruct, schema_common);\n    WCDBJNITryReleaseStringInCommonValue(schema);\n}\n\nvoid WCDBJNIStatementCreateTriggerClassMethod(configTemp, jlong self)\n{\n    WCDBJNIBridgeStruct(CPPStatementCreateTrigger, self);\n    WCDBStatementCreateTriggerConfigTemp(selfStruct);\n}\n\nvoid WCDBJNIStatementCreateTriggerClassMethod(configIfNotExist, jlong self)\n{\n    WCDBJNIBridgeStruct(CPPStatementCreateTrigger, self);\n    WCDBStatementCreateTriggerConfigIfNotExist(selfStruct);\n}\n\nvoid WCDBJNIStatementCreateTriggerClassMethod(configBefore, jlong self)\n{\n    WCDBJNIBridgeStruct(CPPStatementCreateTrigger, self);\n    WCDBStatementCreateTriggerConfigBefore(selfStruct);\n}\n\nvoid WCDBJNIStatementCreateTriggerClassMethod(configAfter, jlong self)\n{\n    WCDBJNIBridgeStruct(CPPStatementCreateTrigger, self);\n    WCDBStatementCreateTriggerConfigAfter(selfStruct);\n}\n\nvoid WCDBJNIStatementCreateTriggerClassMethod(configInsteadOf, jlong self)\n{\n    WCDBJNIBridgeStruct(CPPStatementCreateTrigger, self);\n    WCDBStatementCreateTriggerConfigInsteadOf(selfStruct);\n}\n\nvoid WCDBJNIStatementCreateTriggerClassMethod(configDelete, jlong self)\n{\n    WCDBJNIBridgeStruct(CPPStatementCreateTrigger, self);\n    WCDBStatementCreateTriggerConfigDelete(selfStruct);\n}\n\nvoid WCDBJNIStatementCreateTriggerClassMethod(configInsert, jlong self)\n{\n    WCDBJNIBridgeStruct(CPPStatementCreateTrigger, self);\n    WCDBStatementCreateTriggerConfigInsert(selfStruct);\n}\n\nvoid WCDBJNIStatementCreateTriggerClassMethod(configUpdate, jlong self)\n{\n    WCDBJNIBridgeStruct(CPPStatementCreateTrigger, self);\n    WCDBStatementCreateTriggerConfigUpdate(selfStruct);\n}\n\nvoid WCDBJNIStatementCreateTriggerClassMethod(configColumns,\n                                              jlong self,\n                                              WCDBJNIObjectOrStringArrayParameter(columns))\n{\n    WCDBJNIBridgeStruct(CPPStatementCreateTrigger, self);\n    WCDBJNICreateObjectOrStringArrayCriticalWithAction(\n    columns, WCDBStatementCreateTriggerConfigColumns2(selfStruct, columns_commonArray));\n}\n\nvoid WCDBJNIStatementCreateTriggerClassMethod(configTable, jlong self, jstring table)\n{\n    WCDBJNIBridgeStruct(CPPStatementCreateTrigger, self);\n    WCDBJNIGetStringCritical(table);\n    WCDBStatementCreateTriggerConfigTable(selfStruct, tableString);\n    WCDBJNIReleaseStringCritical(table);\n}\n\nvoid WCDBJNIStatementCreateTriggerClassMethod(configForEachRow, jlong self)\n{\n    WCDBJNIBridgeStruct(CPPStatementCreateTrigger, self);\n    WCDBStatementCreateTriggerConfigForEachRow(selfStruct);\n}\n\nvoid WCDBJNIStatementCreateTriggerClassMethod(configWhen, jlong self, jlong expression)\n{\n    WCDBJNIBridgeStruct(CPPStatementCreateTrigger, self);\n    WCDBJNIBridgeStruct(CPPExpression, expression);\n    WCDBStatementCreateTriggerConfigWhen(selfStruct, expressionStruct);\n}\n\nvoid WCDBJNIStatementCreateTriggerClassMethod(executeInsert, jlong self, jlong insert)\n{\n    WCDBJNIBridgeStruct(CPPStatementCreateTrigger, self);\n    WCDBJNIBridgeStruct(CPPStatementInsert, insert);\n    WCDBStatementCreateTriggerExecuteInsert(selfStruct, insertStruct);\n}\n\nvoid WCDBJNIStatementCreateTriggerClassMethod(executeUpdate, jlong self, jlong update)\n{\n    WCDBJNIBridgeStruct(CPPStatementCreateTrigger, self);\n    WCDBJNIBridgeStruct(CPPStatementUpdate, update);\n    WCDBStatementCreateTriggerExecuteUpdate(selfStruct, updateStruct);\n}\n\nvoid WCDBJNIStatementCreateTriggerClassMethod(executeDelete, jlong self, jlong delete_)\n{\n    WCDBJNIBridgeStruct(CPPStatementCreateTrigger, self);\n    WCDBJNIBridgeStruct(CPPStatementDelete, delete_);\n    WCDBStatementCreateTriggerExecuteDelete(selfStruct, delete_Struct);\n}\n\nvoid WCDBJNIStatementCreateTriggerClassMethod(executeSelect, jlong self, jlong select)\n{\n    WCDBJNIBridgeStruct(CPPStatementCreateTrigger, self);\n    WCDBJNIBridgeStruct(CPPStatementSelect, select);\n    WCDBStatementCreateTriggerExecuteSelect(selfStruct, selectStruct);\n}\n"
  },
  {
    "path": "src/java/main/src/main/cpp/winq/Statement/StatementCreateTriggerJNI.h",
    "content": "// Created by chenqiuwen on 2023/6/11.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"WCDBJNI.h\"\n\n#define WCDBJNIStatementCreateTriggerFuncName(funcName)                        \\\n    WCDBJNI(StatementCreateTrigger, funcName)\n#define WCDBJNIStatementCreateTriggerObjectMethod(funcName, ...)               \\\n    WCDBJNIObjectMethod(StatementCreateTrigger, funcName, __VA_ARGS__)\n#define WCDBJNIStatementCreateTriggerObjectMethodWithNoArg(funcName)           \\\n    WCDBJNIObjectMethodWithNoArg(StatementCreateTrigger, funcName)\n#define WCDBJNIStatementCreateTriggerClassMethodWithNoArg(funcName)            \\\n    WCDBJNIClassMethodWithNoArg(StatementCreateTrigger, funcName)\n#define WCDBJNIStatementCreateTriggerClassMethod(funcName, ...)                \\\n    WCDBJNIClassMethod(StatementCreateTrigger, funcName, __VA_ARGS__)\n\njlong WCDBJNIStatementCreateTriggerClassMethodWithNoArg(createCppObj);\n\nvoid WCDBJNIStatementCreateTriggerClassMethod(configTrigger, jlong self, jstring name);\nvoid WCDBJNIStatementCreateTriggerClassMethod(configSchema,\n                                              jlong self,\n                                              WCDBJNIObjectOrStringParameter(schema));\nvoid WCDBJNIStatementCreateTriggerClassMethod(configTemp, jlong self);\nvoid WCDBJNIStatementCreateTriggerClassMethod(configIfNotExist, jlong self);\n\nvoid WCDBJNIStatementCreateTriggerClassMethod(configBefore, jlong self);\nvoid WCDBJNIStatementCreateTriggerClassMethod(configAfter, jlong self);\nvoid WCDBJNIStatementCreateTriggerClassMethod(configInsteadOf, jlong self);\n\nvoid WCDBJNIStatementCreateTriggerClassMethod(configDelete, jlong self);\nvoid WCDBJNIStatementCreateTriggerClassMethod(configInsert, jlong self);\nvoid WCDBJNIStatementCreateTriggerClassMethod(configUpdate, jlong self);\n\nvoid WCDBJNIStatementCreateTriggerClassMethod(configColumns,\n                                              jlong self,\n                                              WCDBJNIObjectOrStringArrayParameter(columns));\nvoid WCDBJNIStatementCreateTriggerClassMethod(configTable, jlong self, jstring table);\nvoid WCDBJNIStatementCreateTriggerClassMethod(configForEachRow, jlong self);\nvoid WCDBJNIStatementCreateTriggerClassMethod(configWhen, jlong self, jlong expression);\n\nvoid WCDBJNIStatementCreateTriggerClassMethod(executeInsert, jlong self, jlong insert);\nvoid WCDBJNIStatementCreateTriggerClassMethod(executeUpdate, jlong self, jlong update);\nvoid WCDBJNIStatementCreateTriggerClassMethod(executeDelete, jlong self, jlong delete_);\nvoid WCDBJNIStatementCreateTriggerClassMethod(executeSelect, jlong self, jlong select);\n"
  },
  {
    "path": "src/java/main/src/main/cpp/winq/Statement/StatementCreateViewJNI.c",
    "content": "// Created by chenqiuwen on 2023/6/11.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"StatementCreateViewJNI.h\"\n#include \"StatementCreateViewBridge.h\"\n\njlong WCDBJNIStatementCreateViewClassMethodWithNoArg(createCppObj)\n{\n    return (jlong) WCDBStatementCreateViewCreate().innerValue;\n}\n\nvoid WCDBJNIStatementCreateViewClassMethod(configView, jlong self, jstring name)\n{\n    WCDBJNIBridgeStruct(CPPStatementCreateView, self);\n    WCDBJNIGetStringCritical(name);\n    WCDBStatementCreateViewConfigView(selfStruct, nameString);\n    WCDBJNIReleaseStringCritical(name);\n}\n\nvoid WCDBJNIStatementCreateViewClassMethod(configSchema,\n                                           jlong self,\n                                           WCDBJNIObjectOrStringParameter(schema))\n{\n    WCDBJNIBridgeStruct(CPPStatementCreateView, self);\n    WCDBJNICreateObjectOrStringCommonValue(schema, true);\n    WCDBStatementCreateViewConfigSchema2(selfStruct, schema_common);\n    WCDBJNITryReleaseStringInCommonValue(schema);\n}\n\nvoid WCDBJNIStatementCreateViewClassMethod(configTemp, jlong self)\n{\n    WCDBJNIBridgeStruct(CPPStatementCreateView, self);\n    WCDBStatementCreateViewConfigTemp(selfStruct);\n}\n\nvoid WCDBJNIStatementCreateViewClassMethod(configIfNotExist, jlong self)\n{\n    WCDBJNIBridgeStruct(CPPStatementCreateView, self);\n    WCDBStatementCreateViewConfigIfNotExist(selfStruct);\n}\n\nvoid WCDBJNIStatementCreateViewClassMethod(configAs, jlong self, jlong select)\n{\n    WCDBJNIBridgeStruct(CPPStatementCreateView, self);\n    WCDBJNIBridgeStruct(CPPStatementSelect, select);\n    WCDBStatementCreateViewConfigAs(selfStruct, selectStruct);\n}\n\nvoid WCDBJNIStatementCreateViewClassMethod(configColumns,\n                                           jlong self,\n                                           WCDBJNIObjectOrStringArrayParameter(columns))\n{\n    WCDBJNIBridgeStruct(CPPStatementCreateView, self);\n    WCDBJNICreateObjectOrStringArrayCriticalWithAction(\n    columns, WCDBStatementCreateViewConfigColumns2(selfStruct, columns_commonArray));\n}\n"
  },
  {
    "path": "src/java/main/src/main/cpp/winq/Statement/StatementCreateViewJNI.h",
    "content": "// Created by chenqiuwen on 2023/6/11.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"WCDBJNI.h\"\n\n#define WCDBJNIStatementCreateViewFuncName(funcName)                           \\\n    WCDBJNI(StatementCreateView, funcName)\n#define WCDBJNIStatementCreateViewObjectMethod(funcName, ...)                  \\\n    WCDBJNIObjectMethod(StatementCreateView, funcName, __VA_ARGS__)\n#define WCDBJNIStatementCreateViewObjectMethodWithNoArg(funcName)              \\\n    WCDBJNIObjectMethodWithNoArg(StatementCreateView, funcName)\n#define WCDBJNIStatementCreateViewClassMethodWithNoArg(funcName)               \\\n    WCDBJNIClassMethodWithNoArg(StatementCreateView, funcName)\n#define WCDBJNIStatementCreateViewClassMethod(funcName, ...)                   \\\n    WCDBJNIClassMethod(StatementCreateView, funcName, __VA_ARGS__)\n\njlong WCDBJNIStatementCreateViewClassMethodWithNoArg(createCppObj);\n\nvoid WCDBJNIStatementCreateViewClassMethod(configView, jlong self, jstring name);\nvoid WCDBJNIStatementCreateViewClassMethod(configSchema,\n                                           jlong self,\n                                           WCDBJNIObjectOrStringParameter(schema));\nvoid WCDBJNIStatementCreateViewClassMethod(configTemp, jlong self);\nvoid WCDBJNIStatementCreateViewClassMethod(configIfNotExist, jlong self);\nvoid WCDBJNIStatementCreateViewClassMethod(configAs, jlong self, jlong select);\nvoid WCDBJNIStatementCreateViewClassMethod(configColumns,\n                                           jlong self,\n                                           WCDBJNIObjectOrStringArrayParameter(columns));\n"
  },
  {
    "path": "src/java/main/src/main/cpp/winq/Statement/StatementCreateVirtualTableJNI.c",
    "content": "// Created by chenqiuwen on 2023/11/4.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"StatementCreateVirtualTableJNI.h\"\n#include \"StatementCreateVirtualTableBridge.h\"\n\njlong WCDBJNIStatementCreateVirtualTableClassMethodWithNoArg(createCppObj)\n{\n    return (jlong) WCDBStatementCreateVirtualTableCreate().innerValue;\n}\n\nvoid WCDBJNIStatementCreateVirtualTableClassMethod(configTable, jlong self, jstring name)\n{\n    WCDBJNIGetString(name);\n    WCDBJNIBridgeStruct(CPPStatementCreateVirtualTable, self);\n    WCDBStatementCreateVirtualTableConfigTable(selfStruct, nameString);\n    WCDBJNIReleaseString(name);\n}\n\nvoid WCDBJNIStatementCreateVirtualTableClassMethod(configSchema,\n                                                   jlong self,\n                                                   WCDBJNIObjectOrStringParameter(schema))\n{\n    WCDBJNIBridgeStruct(CPPStatementCreateVirtualTable, self);\n    WCDBJNICreateObjectOrStringCommonValue(schema, true);\n    WCDBStatementCreateVirtualTableConfigSchema2(selfStruct, schema_common);\n    WCDBJNITryReleaseStringInCommonValue(schema);\n}\n\nvoid WCDBJNIStatementCreateVirtualTableClassMethod(configIfNotExist, jlong self)\n{\n    WCDBJNIBridgeStruct(CPPStatementCreateVirtualTable, self);\n    WCDBStatementCreateVirtualTableConfigIfNotExist(selfStruct);\n}\n\nvoid WCDBJNIStatementCreateVirtualTableClassMethod(configModule, jlong self, jstring module)\n{\n    WCDBJNIBridgeStruct(CPPStatementCreateVirtualTable, self);\n    WCDBJNIGetString(module);\n    WCDBStatementCreateVirtualTableConfigModule(selfStruct, moduleString);\n    WCDBJNIReleaseString(module);\n}\n\nvoid WCDBJNIStatementCreateVirtualTableClassMethod(configArguments, jlong self, jobjectArray arguments)\n{\n    WCDBJNIBridgeStruct(CPPStatementCreateVirtualTable, self);\n    WCDBJNIGetStringArray(arguments);\n    WCDBStatementCreateVirtualTableConfigArguments(\n    selfStruct, (const char *const *) argumentsCharArray, argumentsLength);\n    WCDBJNIReleaseStringArray(arguments);\n}\n"
  },
  {
    "path": "src/java/main/src/main/cpp/winq/Statement/StatementCreateVirtualTableJNI.h",
    "content": "// Created by chenqiuwen on 2023/11/4.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"WCDBJNI.h\"\n\n#define WCDBJNIStatementCreateVirtualTableFuncName(funcName)                   \\\n    WCDBJNI(StatementCreateVirtualTable, funcName)\n#define WCDBJNIStatementCreateVirtualTableObjectMethod(funcName, ...)          \\\n    WCDBJNIObjectMethod(StatementCreateVirtualTable, funcName, __VA_ARGS__)\n#define WCDBJNIStatementCreateVirtualTableObjectMethodWithNoArg(funcName)      \\\n    WCDBJNIObjectMethodWithNoArg(StatementCreateVirtualTable, funcName)\n#define WCDBJNIStatementCreateVirtualTableClassMethodWithNoArg(funcName)       \\\n    WCDBJNIClassMethodWithNoArg(StatementCreateVirtualTable, funcName)\n#define WCDBJNIStatementCreateVirtualTableClassMethod(funcName, ...)           \\\n    WCDBJNIClassMethod(StatementCreateVirtualTable, funcName, __VA_ARGS__)\n\njlong WCDBJNIStatementCreateVirtualTableClassMethodWithNoArg(createCppObj);\n\nvoid WCDBJNIStatementCreateVirtualTableClassMethod(configTable, jlong self, jstring name);\nvoid WCDBJNIStatementCreateVirtualTableClassMethod(configSchema,\n                                                   jlong self,\n                                                   WCDBJNIObjectOrStringParameter(schema));\nvoid WCDBJNIStatementCreateVirtualTableClassMethod(configIfNotExist, jlong self);\nvoid WCDBJNIStatementCreateVirtualTableClassMethod(configModule, jlong self, jstring module);\nvoid WCDBJNIStatementCreateVirtualTableClassMethod(configArguments, jlong self, jobjectArray arguments);\n"
  },
  {
    "path": "src/java/main/src/main/cpp/winq/Statement/StatementCreateindexJNI.c",
    "content": "// Created by chenqiuwen on 2023/4/9.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"StatementCreateindexJNI.h\"\n#include \"StatementCreateIndexBridge.h\"\n\njlong WCDBJNIStatementCreateIndexClassMethodWithNoArg(create)\n{\n    return (jlong) WCDBStatementCreateIndexCreate().innerValue;\n}\n\nvoid WCDBJNIStatementCreateIndexClassMethod(configIndex, jlong self, jstring name)\n{\n    WCDBJNIBridgeStruct(CPPStatementCreateIndex, self);\n    WCDBJNIGetStringCritical(name);\n    WCDBStatementCreateIndexConfigIndexName(selfStruct, nameString);\n    WCDBJNIReleaseStringCritical(name);\n}\n\nvoid WCDBJNIStatementCreateIndexClassMethod(configSchema,\n                                            jlong self,\n                                            WCDBJNIObjectOrStringParameter(schema))\n{\n    WCDBJNIBridgeStruct(CPPStatementCreateIndex, self);\n    WCDBJNICreateObjectOrStringCommonValue(schema, true);\n    WCDBStatementCreateIndexConfigSchema2(selfStruct, schema_common);\n    WCDBJNITryReleaseStringInCommonValue(schema);\n}\n\nvoid WCDBJNIStatementCreateIndexClassMethod(configUnique, jlong self)\n{\n    WCDBJNIBridgeStruct(CPPStatementCreateIndex, self);\n    WCDBStatementCreateIndexConfigUniqe(selfStruct);\n}\n\nvoid WCDBJNIStatementCreateIndexClassMethod(configIfNotExist, jlong self)\n{\n    WCDBJNIBridgeStruct(CPPStatementCreateIndex, self);\n    WCDBStatementCreateIndexConfigIfNotExist(selfStruct);\n}\n\nvoid WCDBJNIStatementCreateIndexClassMethod(configTable, jlong self, jstring tableName)\n{\n    WCDBJNIBridgeStruct(CPPStatementCreateIndex, self);\n    WCDBJNIGetStringCritical(tableName);\n    WCDBStatementCreateIndexConfigTable(selfStruct, tableNameString);\n    WCDBJNIReleaseStringCritical(tableName);\n}\n\nvoid WCDBJNIStatementCreateIndexClassMethod(configIndexedColumns,\n                                            jlong self,\n                                            WCDBJNIObjectOrStringArrayParameter(indexColumns))\n{\n    WCDBJNIBridgeStruct(CPPStatementCreateIndex, self);\n    WCDBJNICreateObjectOrStringArrayCriticalWithAction(\n    indexColumns, WCDBStatementCreateIndexConfigIndexColumns2(selfStruct, indexColumns_commonArray));\n}\n\nvoid WCDBJNIStatementCreateIndexClassMethod(configWhere, jlong self, jlong condition)\n{\n    WCDBJNIBridgeStruct(CPPStatementCreateIndex, self);\n    WCDBJNIBridgeStruct(CPPExpression, condition);\n    WCDBStatementCreateIndexConfigWhere(selfStruct, conditionStruct);\n}"
  },
  {
    "path": "src/java/main/src/main/cpp/winq/Statement/StatementCreateindexJNI.h",
    "content": "// Created by chenqiuwen on 2023/4/9.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"WCDBJNI.h\"\n\n#define WCDBJNIStatementCreateIndexFuncName(funcName)                          \\\n    WCDBJNI(StatementCreateIndex, funcName)\n#define WCDBJNIStatementCreateIndexObjectMethod(funcName, ...)                 \\\n    WCDBJNIObjectMethod(StatementCreateIndex, funcName, __VA_ARGS__)\n#define WCDBJNIStatementCreateIndexObjectMethodWithNoArg(funcName)             \\\n    WCDBJNIObjectMethodWithNoArg(StatementCreateIndex, funcName)\n#define WCDBJNIStatementCreateIndexClassMethodWithNoArg(funcName)              \\\n    WCDBJNIClassMethodWithNoArg(StatementCreateIndex, funcName)\n#define WCDBJNIStatementCreateIndexClassMethod(funcName, ...)                  \\\n    WCDBJNIClassMethod(StatementCreateIndex, funcName, __VA_ARGS__)\n\njlong WCDBJNIStatementCreateIndexClassMethodWithNoArg(create);\nvoid WCDBJNIStatementCreateIndexClassMethod(configIndex, jlong self, jstring name);\nvoid WCDBJNIStatementCreateIndexClassMethod(configSchema,\n                                            jlong self,\n                                            WCDBJNIObjectOrStringParameter(schema));\nvoid WCDBJNIStatementCreateIndexClassMethod(configUnique, jlong self);\nvoid WCDBJNIStatementCreateIndexClassMethod(configIfNotExist, jlong self);\nvoid WCDBJNIStatementCreateIndexClassMethod(configTable, jlong self, jstring tableName);\nvoid WCDBJNIStatementCreateIndexClassMethod(configIndexedColumns,\n                                            jlong self,\n                                            WCDBJNIObjectOrStringArrayParameter(indexColumns));\nvoid WCDBJNIStatementCreateIndexClassMethod(configWhere, jlong self, jlong condition);\n"
  },
  {
    "path": "src/java/main/src/main/cpp/winq/Statement/StatementDeleteJNI.c",
    "content": "// Created by qiuwenchen on 2023/4/11.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"StatementDeleteJNI.h\"\n#include \"StatementDeleteBridge.h\"\n\njlong WCDBJNIStatementDeleteClassMethodWithNoArg(create)\n{\n    return (jlong) WCDBStatementDeleteCreate().innerValue;\n}\n\nvoid WCDBJNIStatementDeleteClassMethod(configWith, jlong self, jlongArray expressions)\n{\n    WCDBJNIBridgeStruct(CPPStatementDelete, self);\n    WCDBJNIGetCppPointerArrayCritical(expressions);\n    WCDBStatementDeleteConfigWith(\n    selfStruct, (const CPPCommonTableExpression *) expressionsArray, expressionsLength);\n    WCDBJNIReleaseCppPointerArrayCritical(expressions);\n}\n\nvoid WCDBJNIStatementDeleteClassMethod(configRecursive, jlong self)\n{\n    WCDBJNIBridgeStruct(CPPStatementDelete, self);\n    WCDBStatementDeleteConfigRecursive(selfStruct);\n}\n\nvoid WCDBJNIStatementDeleteClassMethod(configTable, jlong self, WCDBJNIObjectOrStringParameter(table))\n{\n    WCDBJNIBridgeStruct(CPPStatementDelete, self);\n    WCDBJNICreateObjectOrStringCommonValue(table, true);\n    WCDBStatementDeleteConfigDeleteFrom2(selfStruct, table_common);\n    WCDBJNITryReleaseStringInCommonValue(table);\n}\n\nvoid WCDBJNIStatementDeleteClassMethod(configCondition, jlong self, jlong condition)\n{\n    WCDBJNIBridgeStruct(CPPStatementDelete, self);\n    WCDBJNIBridgeStruct(CPPExpression, condition);\n    WCDBStatementDeleteConfigWhere(selfStruct, conditionStruct);\n}\n\nvoid WCDBJNIStatementDeleteClassMethod(configOrders, jlong self, jlongArray orders)\n{\n    WCDBJNIBridgeStruct(CPPStatementDelete, self);\n    WCDBJNIGetCppPointerArrayCritical(orders);\n    WCDBStatementDeleteConfigOrder(\n    selfStruct, (const CPPOrderingTerm *) ordersArray, ordersLength);\n    WCDBJNIReleaseCppPointerArrayCritical(orders);\n}\n\nvoid WCDBJNIStatementDeleteClassMethod(\nconfigLimitRange, jlong self, jint fromType, jlong from, jint toType, jlong to)\n{\n    WCDBJNIBridgeStruct(CPPStatementDelete, self);\n    CPPCommonValue from_common;\n    from_common.type = fromType;\n    from_common.intValue = from;\n    CPPCommonValue to_common;\n    to_common.type = toType;\n    to_common.intValue = to;\n    WCDBStatementDeleteConfigLimitRange2(selfStruct, from_common, to_common);\n}\n\nvoid WCDBJNIStatementDeleteClassMethod(configLimitCount, jlong self, jint type, jlong limit)\n{\n    WCDBJNIBridgeStruct(CPPStatementDelete, self);\n    CPPCommonValue limit_common;\n    limit_common.type = type;\n    limit_common.intValue = limit;\n    WCDBStatementDeleteConfigLimitCount2(selfStruct, limit_common);\n}\n\nvoid WCDBJNIStatementDeleteClassMethod(configOffset, jlong self, jint type, jlong offset)\n{\n    WCDBJNIBridgeStruct(CPPStatementDelete, self);\n    CPPCommonValue offset_common;\n    offset_common.type = type;\n    offset_common.intValue = offset;\n    WCDBStatementDeleteConfigOffset2(selfStruct, offset_common);\n}\n"
  },
  {
    "path": "src/java/main/src/main/cpp/winq/Statement/StatementDeleteJNI.h",
    "content": "// Created by qiuwenchen on 2023/4/11.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"WCDBJNI.h\"\n\n#define WCDBJNIStatementDeleteFuncName(funcName)                               \\\n    WCDBJNI(StatementDelete, funcName)\n#define WCDBJNIStatementDeleteObjectMethod(funcName, ...)                      \\\n    WCDBJNIObjectMethod(StatementDelete, funcName, __VA_ARGS__)\n#define WCDBJNIStatementDeleteObjectMethodWithNoArg(funcName)                  \\\n    WCDBJNIObjectMethodWithNoArg(StatementDelete, funcName)\n#define WCDBJNIStatementDeleteClassMethodWithNoArg(funcName)                   \\\n    WCDBJNIClassMethodWithNoArg(StatementDelete, funcName)\n#define WCDBJNIStatementDeleteClassMethod(funcName, ...)                       \\\n    WCDBJNIClassMethod(StatementDelete, funcName, __VA_ARGS__)\n\njlong WCDBJNIStatementDeleteClassMethodWithNoArg(create);\n\nvoid WCDBJNIStatementDeleteClassMethod(configWith, jlong self, jlongArray expressions);\nvoid WCDBJNIStatementDeleteClassMethod(configRecursive, jlong self);\n\nvoid WCDBJNIStatementDeleteClassMethod(configTable,\n                                       jlong self,\n                                       WCDBJNIObjectOrStringParameter(table));\nvoid WCDBJNIStatementDeleteClassMethod(configCondition, jlong self, jlong condition);\nvoid WCDBJNIStatementDeleteClassMethod(configOrders, jlong self, jlongArray orders);\nvoid WCDBJNIStatementDeleteClassMethod(\nconfigLimitRange, jlong self, jint fromType, jlong from, jint toType, jlong to);\nvoid WCDBJNIStatementDeleteClassMethod(configLimitCount, jlong self, jint type, jlong limit);\nvoid WCDBJNIStatementDeleteClassMethod(configOffset, jlong self, jint type, jlong offset);\n"
  },
  {
    "path": "src/java/main/src/main/cpp/winq/Statement/StatementDetachJNI.c",
    "content": "// Created by chenqiuwen on 2023/6/11.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"StatementDetachJNI.h\"\n#include \"StatementDetachBridge.h\"\n\njlong WCDBJNIStatementDetachClassMethodWithNoArg(createCppObj)\n{\n    return (jlong) WCDBStatementDetachCreate().innerValue;\n}\n\nvoid WCDBJNIStatementDetachClassMethod(configSchema,\n                                       jlong self,\n                                       WCDBJNIObjectOrStringParameter(schema))\n{\n    WCDBJNIBridgeStruct(CPPStatementDetach, self);\n    WCDBJNICreateObjectOrStringCommonValue(schema, true);\n    WCDBStatementDetachConfigSchema2(selfStruct, schema_common);\n    WCDBJNITryReleaseStringInCommonValue(schema);\n}"
  },
  {
    "path": "src/java/main/src/main/cpp/winq/Statement/StatementDetachJNI.h",
    "content": "// Created by chenqiuwen on 2023/6/11.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"WCDBJNI.h\"\n\n#define WCDBJNIStatementDetachFuncName(funcName)                               \\\n    WCDBJNI(StatementDetach, funcName)\n#define WCDBJNIStatementDetachObjectMethod(funcName, ...)                      \\\n    WCDBJNIObjectMethod(StatementDetach, funcName, __VA_ARGS__)\n#define WCDBJNIStatementDetachObjectMethodWithNoArg(funcName)                  \\\n    WCDBJNIObjectMethodWithNoArg(StatementDetach, funcName)\n#define WCDBJNIStatementDetachClassMethodWithNoArg(funcName)                   \\\n    WCDBJNIClassMethodWithNoArg(StatementDetach, funcName)\n#define WCDBJNIStatementDetachClassMethod(funcName, ...)                       \\\n    WCDBJNIClassMethod(StatementDetach, funcName, __VA_ARGS__)\n\njlong WCDBJNIStatementDetachClassMethodWithNoArg(createCppObj);\nvoid WCDBJNIStatementDetachClassMethod(configSchema,\n                                       jlong self,\n                                       WCDBJNIObjectOrStringParameter(schema));\n"
  },
  {
    "path": "src/java/main/src/main/cpp/winq/Statement/StatementDropIndexJNI.c",
    "content": "// Created by chenqiuwen on 2023/6/11.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"StatementDropIndexJNI.h\"\n#include \"StatementDropIndexBridge.h\"\n\njlong WCDBJNIStatementDropIndexClassMethodWithNoArg(createCppObj)\n{\n    return (jlong) WCDBStatementDropIndexCreate().innerValue;\n}\n\nvoid WCDBJNIStatementDropIndexClassMethod(configSchema,\n                                          jlong self,\n                                          WCDBJNIObjectOrStringParameter(schema))\n{\n    WCDBJNIBridgeStruct(CPPStatementDropIndex, self);\n    WCDBJNICreateObjectOrStringCommonValue(schema, true);\n    WCDBStatementDropIndexConfigSchema2(selfStruct, schema_common);\n    WCDBJNITryReleaseStringInCommonValue(schema);\n}\n\nvoid WCDBJNIStatementDropIndexClassMethod(configIndex, jlong self, jstring indexName)\n{\n    WCDBJNIBridgeStruct(CPPStatementDropIndex, self);\n    WCDBJNIGetStringCritical(indexName);\n    WCDBStatementDropIndexConfigIndex(selfStruct, indexNameString);\n    WCDBJNIReleaseStringCritical(indexName);\n}\n\nvoid WCDBJNIStatementDropIndexClassMethod(configIfExist, jlong self)\n{\n    WCDBJNIBridgeStruct(CPPStatementDropIndex, self);\n    WCDBStatementDropIndexConfigIfExists(selfStruct);\n}\n"
  },
  {
    "path": "src/java/main/src/main/cpp/winq/Statement/StatementDropIndexJNI.h",
    "content": "// Created by chenqiuwen on 2023/6/11.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n#include \"WCDBJNI.h\"\n\n#define WCDBJNIStatementDropIndexFuncName(funcName)                            \\\n    WCDBJNI(StatementDropIndex, funcName)\n#define WCDBJNIStatementDropIndexObjectMethod(funcName, ...)                   \\\n    WCDBJNIObjectMethod(StatementDropIndex, funcName, __VA_ARGS__)\n#define WCDBJNIStatementDropIndexObjectMethodWithNoArg(funcName)               \\\n    WCDBJNIObjectMethodWithNoArg(StatementDropIndex, funcName)\n#define WCDBJNIStatementDropIndexClassMethodWithNoArg(funcName)                \\\n    WCDBJNIClassMethodWithNoArg(StatementDropIndex, funcName)\n#define WCDBJNIStatementDropIndexClassMethod(funcName, ...)                    \\\n    WCDBJNIClassMethod(StatementDropIndex, funcName, __VA_ARGS__)\n\njlong WCDBJNIStatementDropIndexClassMethodWithNoArg(createCppObj);\nvoid WCDBJNIStatementDropIndexClassMethod(configSchema,\n                                          jlong self,\n                                          WCDBJNIObjectOrStringParameter(schema));\nvoid WCDBJNIStatementDropIndexClassMethod(configIndex, jlong self, jstring indexName);\nvoid WCDBJNIStatementDropIndexClassMethod(configIfExist, jlong self);\n"
  },
  {
    "path": "src/java/main/src/main/cpp/winq/Statement/StatementDropTableJNI.c",
    "content": "// Created by qiuwenchen on 2023/4/12.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"StatementDropTableJNI.h\"\n#include \"StatementDropTableBridge.h\"\n\njlong WCDBJNIStatementDropTableClassMethodWithNoArg(create)\n{\n    return (jlong) WCDBStatementDropTableCreate().innerValue;\n}\n\nvoid WCDBJNIStatementDropTableClassMethod(configSchema,\n                                          jlong self,\n                                          WCDBJNIObjectOrStringParameter(schema))\n{\n    WCDBJNIBridgeStruct(CPPStatementDropTable, self);\n    WCDBJNICreateObjectOrStringCommonValue(schema, true);\n    WCDBStatementDropTableConfigSchema2(selfStruct, schema_common);\n    WCDBJNITryReleaseStringInCommonValue(schema);\n}\n\nvoid WCDBJNIStatementDropTableClassMethod(configTableName, jlong self, jstring tableName)\n{\n    WCDBJNIBridgeStruct(CPPStatementDropTable, self);\n    WCDBJNIGetStringCritical(tableName);\n    WCDBStatementDropTableConfigTable(selfStruct, tableNameString);\n    WCDBJNIReleaseStringCritical(tableName);\n}\n\nvoid WCDBJNIStatementDropTableClassMethod(configIfExist, jlong self)\n{\n    WCDBJNIBridgeStruct(CPPStatementDropTable, self);\n    WCDBStatementDropTableConfigIfExists(selfStruct);\n}"
  },
  {
    "path": "src/java/main/src/main/cpp/winq/Statement/StatementDropTableJNI.h",
    "content": "// Created by qiuwenchen on 2023/4/12.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"WCDBJNI.h\"\n\n#define WCDBJNIStatementDropTableFuncName(funcName)                            \\\n    WCDBJNI(StatementDropTable, funcName)\n#define WCDBJNIStatementDropTableObjectMethod(funcName, ...)                   \\\n    WCDBJNIObjectMethod(StatementDropTable, funcName, __VA_ARGS__)\n#define WCDBJNIStatementDropTableObjectMethodWithNoArg(funcName)               \\\n    WCDBJNIObjectMethodWithNoArg(StatementDropTable, funcName)\n#define WCDBJNIStatementDropTableClassMethodWithNoArg(funcName)                \\\n    WCDBJNIClassMethodWithNoArg(StatementDropTable, funcName)\n#define WCDBJNIStatementDropTableClassMethod(funcName, ...)                    \\\n    WCDBJNIClassMethod(StatementDropTable, funcName, __VA_ARGS__)\n\njlong WCDBJNIStatementDropTableClassMethodWithNoArg(create);\nvoid WCDBJNIStatementDropTableClassMethod(configSchema,\n                                          jlong self,\n                                          WCDBJNIObjectOrStringParameter(schema));\nvoid WCDBJNIStatementDropTableClassMethod(configTableName, jlong self, jstring tableName);\nvoid WCDBJNIStatementDropTableClassMethod(configIfExist, jlong self);"
  },
  {
    "path": "src/java/main/src/main/cpp/winq/Statement/StatementDropTriggerJNI.c",
    "content": "// Created by chenqiuwen on 2023/6/11.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"StatementDropTriggerJNI.h\"\n#include \"StatementDropTriggerBridge.h\"\n\njlong WCDBJNIStatementDropTriggerClassMethodWithNoArg(createCppObj)\n{\n    return (jlong) WCDBStatementDropTriggerCreate().innerValue;\n}\n\nvoid WCDBJNIStatementDropTriggerClassMethod(configSchema,\n                                            jlong self,\n                                            WCDBJNIObjectOrStringParameter(schema))\n{\n    WCDBJNIBridgeStruct(CPPStatementDropTrigger, self);\n    WCDBJNICreateObjectOrStringCommonValue(schema, true);\n    WCDBStatementDropTriggerConfigSchema2(selfStruct, schema_common);\n    WCDBJNITryReleaseStringInCommonValue(schema);\n}\n\nvoid WCDBJNIStatementDropTriggerClassMethod(configTrigger, jlong self, jstring triggerName)\n{\n    WCDBJNIBridgeStruct(CPPStatementDropTrigger, self);\n    WCDBJNIGetStringCritical(triggerName);\n    WCDBStatementDropTriggerConfigTrigger(selfStruct, triggerNameString);\n    WCDBJNIReleaseStringCritical(triggerName);\n}\n\nvoid WCDBJNIStatementDropTriggerClassMethod(configIfExist, jlong self)\n{\n    WCDBJNIBridgeStruct(CPPStatementDropTrigger, self);\n    WCDBStatementDropTriggerConfigIfExists(selfStruct);\n}\n"
  },
  {
    "path": "src/java/main/src/main/cpp/winq/Statement/StatementDropTriggerJNI.h",
    "content": "// Created by chenqiuwen on 2023/6/11.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n#include \"WCDBJNI.h\"\n\n#define WCDBJNIStatementDropTriggerFuncName(funcName)                          \\\n    WCDBJNI(StatementDropTrigger, funcName)\n#define WCDBJNIStatementDropTriggerObjectMethod(funcName, ...)                 \\\n    WCDBJNIObjectMethod(StatementDropTrigger, funcName, __VA_ARGS__)\n#define WCDBJNIStatementDropTriggerObjectMethodWithNoArg(funcName)             \\\n    WCDBJNIObjectMethodWithNoArg(StatementDropTrigger, funcName)\n#define WCDBJNIStatementDropTriggerClassMethodWithNoArg(funcName)              \\\n    WCDBJNIClassMethodWithNoArg(StatementDropTrigger, funcName)\n#define WCDBJNIStatementDropTriggerClassMethod(funcName, ...)                  \\\n    WCDBJNIClassMethod(StatementDropTrigger, funcName, __VA_ARGS__)\n\njlong WCDBJNIStatementDropTriggerClassMethodWithNoArg(createCppObj);\nvoid WCDBJNIStatementDropTriggerClassMethod(configSchema,\n                                            jlong self,\n                                            WCDBJNIObjectOrStringParameter(schema));\nvoid WCDBJNIStatementDropTriggerClassMethod(configTrigger, jlong self, jstring triggerName);\nvoid WCDBJNIStatementDropTriggerClassMethod(configIfExist, jlong self);\n"
  },
  {
    "path": "src/java/main/src/main/cpp/winq/Statement/StatementDropViewJNI.c",
    "content": "// Created by chenqiuwen on 2023/6/11.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"StatementDropViewJNI.h\"\n#include \"StatementDropViewBridge.h\"\n\njlong WCDBJNIStatementDropViewClassMethodWithNoArg(createCppObj)\n{\n    return (jlong) WCDBStatementDropViewCreate().innerValue;\n}\n\nvoid WCDBJNIStatementDropViewClassMethod(configSchema,\n                                         jlong self,\n                                         WCDBJNIObjectOrStringParameter(schema))\n{\n    WCDBJNIBridgeStruct(CPPStatementDropView, self);\n    WCDBJNICreateObjectOrStringCommonValue(schema, true);\n    WCDBStatementDropViewConfigSchema2(selfStruct, schema_common);\n    WCDBJNITryReleaseStringInCommonValue(schema);\n}\n\nvoid WCDBJNIStatementDropViewClassMethod(configView, jlong self, jstring viewName)\n{\n    WCDBJNIBridgeStruct(CPPStatementDropView, self);\n    WCDBJNIGetStringCritical(viewName);\n    WCDBStatementDropViewConfigView(selfStruct, viewNameString);\n    WCDBJNIReleaseStringCritical(viewName);\n}\n\nvoid WCDBJNIStatementDropViewClassMethod(configIfExist, jlong self)\n{\n    WCDBJNIBridgeStruct(CPPStatementDropView, self);\n    WCDBStatementDropViewConfigIfExists(selfStruct);\n}\n"
  },
  {
    "path": "src/java/main/src/main/cpp/winq/Statement/StatementDropViewJNI.h",
    "content": "// Created by chenqiuwen on 2023/6/11.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n#include \"WCDBJNI.h\"\n\n#define WCDBJNIStatementDropViewFuncName(funcName)                             \\\n    WCDBJNI(StatementDropView, funcName)\n#define WCDBJNIStatementDropViewObjectMethod(funcName, ...)                    \\\n    WCDBJNIObjectMethod(StatementDropView, funcName, __VA_ARGS__)\n#define WCDBJNIStatementDropViewObjectMethodWithNoArg(funcName)                \\\n    WCDBJNIObjectMethodWithNoArg(StatementDropView, funcName)\n#define WCDBJNIStatementDropViewClassMethodWithNoArg(funcName)                 \\\n    WCDBJNIClassMethodWithNoArg(StatementDropView, funcName)\n#define WCDBJNIStatementDropViewClassMethod(funcName, ...)                     \\\n    WCDBJNIClassMethod(StatementDropView, funcName, __VA_ARGS__)\n\njlong WCDBJNIStatementDropViewClassMethodWithNoArg(createCppObj);\nvoid WCDBJNIStatementDropViewClassMethod(configSchema,\n                                         jlong self,\n                                         WCDBJNIObjectOrStringParameter(schema));\nvoid WCDBJNIStatementDropViewClassMethod(configView, jlong self, jstring viewName);\nvoid WCDBJNIStatementDropViewClassMethod(configIfExist, jlong self);\n"
  },
  {
    "path": "src/java/main/src/main/cpp/winq/Statement/StatementExplainJNI.c",
    "content": "//\n// Created by qiuwenchen on 2023/6/12.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"StatementExplainJNI.h\"\n#include \"StatementExplainBridge.h\"\n\njlong WCDBJNIStatementExplainClassMethodWithNoArg(createCppObj)\n{\n    return (jlong) WCDBStatementExplainCreate().innerValue;\n}\n\nvoid WCDBJNIStatementExplainClassMethod(explain, jlong self, jlong statement, jboolean queryPlan)\n{\n    WCDBJNIBridgeStruct(CPPStatementExplain, self);\n    WCDBStatementExplain(selfStruct, (CPPObject *) statement, queryPlan);\n}"
  },
  {
    "path": "src/java/main/src/main/cpp/winq/Statement/StatementExplainJNI.h",
    "content": "// Created by qiuwenchen on 2023/6/12.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n#include \"WCDBJNI.h\"\n\n#define WCDBJNIStatementExplainFuncName(funcName)                              \\\n    WCDBJNI(StatementExplain, funcName)\n#define WCDBJNIStatementExplainObjectMethod(funcName, ...)                     \\\n    WCDBJNIObjectMethod(StatementExplain, funcName, __VA_ARGS__)\n#define WCDBJNIStatementExplainObjectMethodWithNoArg(funcName)                 \\\n    WCDBJNIObjectMethodWithNoArg(StatementExplain, funcName)\n#define WCDBJNIStatementExplainClassMethodWithNoArg(funcName)                  \\\n    WCDBJNIClassMethodWithNoArg(StatementExplain, funcName)\n#define WCDBJNIStatementExplainClassMethod(funcName, ...)                      \\\n    WCDBJNIClassMethod(StatementExplain, funcName, __VA_ARGS__)\n\njlong WCDBJNIStatementExplainClassMethodWithNoArg(createCppObj);\nvoid WCDBJNIStatementExplainClassMethod(explain, jlong self, jlong statement, jboolean queryPlan);\n"
  },
  {
    "path": "src/java/main/src/main/cpp/winq/Statement/StatementInsertJNI.c",
    "content": "// Created by qiuwenchen on 2023/4/12.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"StatementInsertJNI.h\"\n#include \"StatementInsertBridge.h\"\n\njlong WCDBJNIStatementInsertClassMethodWithNoArg(create)\n{\n    return (jlong) WCDBStatementInsertCreate().innerValue;\n}\n\nvoid WCDBJNIStatementInsertClassMethod(configWith, jlong self, jlongArray expressions)\n{\n    WCDBJNIBridgeStruct(CPPStatementInsert, self);\n    WCDBJNIGetCppPointerArrayCritical(expressions);\n    WCDBStatementInsertConfigWith(\n    selfStruct, (const CPPCommonTableExpression *) expressionsArray, expressionsLength);\n    WCDBJNIReleaseCppPointerArrayCritical(expressions);\n}\n\nvoid WCDBJNIStatementInsertClassMethod(configRecursive, jlong self)\n{\n    WCDBJNIBridgeStruct(CPPStatementInsert, self);\n    WCDBStatementInsertConfigRecursive(selfStruct);\n}\n\nvoid WCDBJNIStatementInsertClassMethod(configTableName, jlong self, jstring tableName)\n{\n    WCDBJNIBridgeStruct(CPPStatementInsert, self);\n    WCDBJNIGetStringCritical(tableName);\n    WCDBStatementInsertConfigTable(selfStruct, tableNameString);\n    WCDBJNIReleaseStringCritical(tableName);\n}\n\nvoid WCDBJNIStatementInsertClassMethod(configSchema,\n                                       jlong self,\n                                       WCDBJNIObjectOrStringParameter(schema))\n{\n    WCDBJNIBridgeStruct(CPPStatementInsert, self);\n    WCDBJNICreateObjectOrStringCommonValue(schema, true);\n    WCDBStatementInsertConfigSchema2(selfStruct, schema_common);\n    WCDBJNITryReleaseStringInCommonValue(schema);\n}\n\nvoid WCDBJNIStatementInsertClassMethod(configConfliction, jlong self, jint action)\n{\n    WCDBJNIBridgeStruct(CPPStatementInsert, self);\n    WCDBStatementInsertConfigConfiction(selfStruct, action);\n}\n\nvoid WCDBJNIStatementInsertClassMethod(configAs, jlong self, jstring alias)\n{\n    WCDBJNIBridgeStruct(CPPStatementInsert, self);\n    WCDBJNIGetStringCritical(alias);\n    WCDBStatementInsertConfigAlias(selfStruct, aliasString);\n    WCDBJNIReleaseStringCritical(alias);\n}\n\nvoid WCDBJNIStatementInsertClassMethod(configColumns,\n                                       jlong self,\n                                       WCDBJNIObjectOrStringArrayParameter(columns))\n{\n    WCDBJNIBridgeStruct(CPPStatementInsert, self);\n    WCDBJNICreateObjectOrStringArrayCriticalWithAction(\n    columns, WCDBStatementInsertConfigColumns2(selfStruct, columns_commonArray));\n}\n\nvoid WCDBJNIStatementInsertClassMethod(configValues, jlong self, WCDBJNIMultiTypeArrayParameter(value))\n{\n    WCDBJNIBridgeStruct(CPPStatementInsert, self);\n    WCDBJNICreateMultiTypeArray(value);\n    WCDBStatementInsertConfigValuesWithMultiTypeArray(selfStruct, valueArray);\n    WCDBJNIReleaseMultiTypeArray(value);\n}\n\nvoid WCDBJNIStatementInsertClassMethod(configValuesWithBindParameters, jlong self, jint count)\n{\n    WCDBJNIBridgeStruct(CPPStatementInsert, self);\n    WCDBStatementInsertConfigValuesWithBindParameters(selfStruct, count);\n}\n\nvoid WCDBJNIStatementInsertClassMethod(configSelect, jlong self, jlong select)\n{\n    WCDBJNIBridgeStruct(CPPStatementInsert, self);\n    WCDBJNIBridgeStruct(CPPStatementSelect, select);\n    WCDBStatementInsertConfigSelect(selfStruct, selectStruct);\n}\n\nvoid WCDBJNIStatementInsertClassMethod(configDefaultValues, jlong self)\n{\n    WCDBJNIBridgeStruct(CPPStatementInsert, self);\n    WCDBStatementInsertConfigDefaultValues(selfStruct);\n}\n\nvoid WCDBJNIStatementInsertClassMethod(configUpsert, jlong self, jlong upsert)\n{\n    WCDBJNIBridgeStruct(CPPStatementInsert, self);\n    WCDBJNIBridgeStruct(CPPUpsert, upsert);\n    WCDBStatementInsertConfigUpsert(selfStruct, upsertStruct);\n}\n"
  },
  {
    "path": "src/java/main/src/main/cpp/winq/Statement/StatementInsertJNI.h",
    "content": "// Created by qiuwenchen on 2023/4/12.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"WCDBJNI.h\"\n\n#define WCDBJNIStatementInsertFuncName(funcName)                               \\\n    WCDBJNI(StatementInsert, funcName)\n#define WCDBJNIStatementInsertObjectMethod(funcName, ...)                      \\\n    WCDBJNIObjectMethod(StatementInsert, funcName, __VA_ARGS__)\n#define WCDBJNIStatementInsertObjectMethodWithNoArg(funcName)                  \\\n    WCDBJNIObjectMethodWithNoArg(StatementInsert, funcName)\n#define WCDBJNIStatementInsertClassMethodWithNoArg(funcName)                   \\\n    WCDBJNIClassMethodWithNoArg(StatementInsert, funcName)\n#define WCDBJNIStatementInsertClassMethod(funcName, ...)                       \\\n    WCDBJNIClassMethod(StatementInsert, funcName, __VA_ARGS__)\n\njlong WCDBJNIStatementInsertClassMethodWithNoArg(create);\nvoid WCDBJNIStatementInsertClassMethod(configWith, jlong self, jlongArray expressions);\nvoid WCDBJNIStatementInsertClassMethod(configRecursive, jlong self);\nvoid WCDBJNIStatementInsertClassMethod(configTableName, jlong self, jstring tableName);\nvoid WCDBJNIStatementInsertClassMethod(configSchema,\n                                       jlong self,\n                                       WCDBJNIObjectOrStringParameter(schema));\nvoid WCDBJNIStatementInsertClassMethod(configConfliction, jlong self, jint action);\nvoid WCDBJNIStatementInsertClassMethod(configAs, jlong self, jstring alias);\nvoid WCDBJNIStatementInsertClassMethod(configColumns,\n                                       jlong self,\n                                       WCDBJNIObjectOrStringArrayParameter(columns));\nvoid WCDBJNIStatementInsertClassMethod(configValues,\n                                       jlong self,\n                                       WCDBJNIMultiTypeArrayParameter(value));\nvoid WCDBJNIStatementInsertClassMethod(configValuesWithBindParameters, jlong self, jint count);\nvoid WCDBJNIStatementInsertClassMethod(configSelect, jlong self, jlong select);\nvoid WCDBJNIStatementInsertClassMethod(configDefaultValues, jlong self);\nvoid WCDBJNIStatementInsertClassMethod(configUpsert, jlong self, jlong upsert);"
  },
  {
    "path": "src/java/main/src/main/cpp/winq/Statement/StatementPragmaJNI.c",
    "content": "// Created by chenqiuwen on 2023/4/12.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"StatementPragmaJNI.h\"\n#include \"StatementPragmaBridge.h\"\n\njlong WCDBJNIStatementPragmaClassMethodWithNoArg(create)\n{\n    return (jlong) WCDBStatementPragmaCreate().innerValue;\n}\nvoid WCDBJNIStatementPragmaClassMethod(configSchema,\n                                       jlong self,\n                                       WCDBJNIObjectOrStringParameter(schema))\n{\n    WCDBJNIBridgeStruct(CPPStatementPragma, self);\n    WCDBJNICreateObjectOrStringCommonValue(schema, true);\n    WCDBStatementPragmaConfigSchema2(selfStruct, schema_common);\n    WCDBJNITryReleaseStringInCommonValue(schema);\n}\n\nvoid WCDBJNIStatementPragmaClassMethod(configPragma, jlong self, jlong pragma)\n{\n    WCDBJNIBridgeStruct(CPPStatementPragma, self);\n    WCDBJNIBridgeStruct(CPPPragma, pragma);\n    WCDBStatementPragmaConfigPragma(selfStruct, pragmaStruct);\n}\n\nvoid WCDBJNIStatementPragmaClassMethod(configToValue, jlong self, WCDBJNICommonValueParameter(value))\n{\n    WCDBJNIBridgeStruct(CPPStatementPragma, self);\n    WCDBJNICreateCommonValue(value, true);\n    WCDBStatementPragmaConfigToValue2(selfStruct, value_common);\n    WCDBJNITryReleaseStringInCommonValue(value);\n}\n\nvoid WCDBJNIStatementPragmaClassMethod(configWithValue, jlong self, WCDBJNICommonValueParameter(value))\n{\n    WCDBJNIBridgeStruct(CPPStatementPragma, self);\n    WCDBJNICreateCommonValue(value, true);\n    WCDBStatementPragmaConfigWithValue2(selfStruct, value_common);\n    WCDBJNITryReleaseStringInCommonValue(value);\n}\n"
  },
  {
    "path": "src/java/main/src/main/cpp/winq/Statement/StatementPragmaJNI.h",
    "content": "// Created by chenqiuwen on 2023/4/12.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"WCDBJNI.h\"\n\n#define WCDBJNIStatementPragmaFuncName(funcName)                               \\\n    WCDBJNI(StatementPragma, funcName)\n#define WCDBJNIStatementPragmaObjectMethod(funcName, ...)                      \\\n    WCDBJNIObjectMethod(StatementPragma, funcName, __VA_ARGS__)\n#define WCDBJNIStatementPragmaObjectMethodWithNoArg(funcName)                  \\\n    WCDBJNIObjectMethodWithNoArg(StatementPragma, funcName)\n#define WCDBJNIStatementPragmaClassMethodWithNoArg(funcName)                   \\\n    WCDBJNIClassMethodWithNoArg(StatementPragma, funcName)\n#define WCDBJNIStatementPragmaClassMethod(funcName, ...)                       \\\n    WCDBJNIClassMethod(StatementPragma, funcName, __VA_ARGS__)\n\njlong WCDBJNIStatementPragmaClassMethodWithNoArg(create);\nvoid WCDBJNIStatementPragmaClassMethod(configSchema,\n                                       jlong self,\n                                       WCDBJNIObjectOrStringParameter(schema));\nvoid WCDBJNIStatementPragmaClassMethod(configPragma, jlong self, jlong pragma);\nvoid WCDBJNIStatementPragmaClassMethod(configToValue,\n                                       jlong self,\n                                       WCDBJNICommonValueParameter(value));\nvoid WCDBJNIStatementPragmaClassMethod(configWithValue,\n                                       jlong self,\n                                       WCDBJNICommonValueParameter(value));\n"
  },
  {
    "path": "src/java/main/src/main/cpp/winq/Statement/StatementReindexJNI.c",
    "content": "// Created by qiuwenchen on 2023/6/12.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"StatementReindexJNI.h\"\n#include \"StatementReindexBridge.h\"\n\njlong WCDBJNIStatementReindexClassMethodWithNoArg(createCppObj)\n{\n    return (jlong) WCDBStatementReIndexCreate().innerValue;\n}\n\nvoid WCDBJNIStatementReindexClassMethod(configCollation, jlong self, jstring collation)\n{\n    WCDBJNIBridgeStruct(CPPStatementReIndex, self);\n    WCDBJNIGetStringCritical(collation);\n    WCDBStatementReIndexConfigCollation(selfStruct, collationString);\n    WCDBJNIReleaseStringCritical(collation);\n}\n\nvoid WCDBJNIStatementReindexClassMethod(configTable, jlong self, jstring name)\n{\n    WCDBJNIBridgeStruct(CPPStatementReIndex, self);\n    WCDBJNIGetStringCritical(name);\n    WCDBStatementReIndexConfigTable(selfStruct, nameString);\n    WCDBJNIReleaseStringCritical(name);\n}\n\nvoid WCDBJNIStatementReindexClassMethod(configIndex, jlong self, jstring name)\n{\n    WCDBJNIBridgeStruct(CPPStatementReIndex, self);\n    WCDBJNIGetStringCritical(name);\n    WCDBStatementReIndexConfigIndex(selfStruct, nameString);\n    WCDBJNIReleaseStringCritical(name);\n}\n\nvoid WCDBJNIStatementReindexClassMethod(configSchema,\n                                        jlong self,\n                                        WCDBJNIObjectOrStringParameter(schema))\n{\n    WCDBJNIBridgeStruct(CPPStatementReIndex, self);\n    WCDBJNICreateObjectOrStringCommonValue(schema, true);\n    WCDBStatementReIndexConfigSchema2(selfStruct, schema_common);\n    WCDBJNITryReleaseStringInCommonValue(schema);\n}\n"
  },
  {
    "path": "src/java/main/src/main/cpp/winq/Statement/StatementReindexJNI.h",
    "content": "// Created by qiuwenchen on 2023/6/12.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"WCDBJNI.h\"\n\n#define WCDBJNIStatementReindexFuncName(funcName)                              \\\n    WCDBJNI(StatementReindex, funcName)\n#define WCDBJNIStatementReindexObjectMethod(funcName, ...)                     \\\n    WCDBJNIObjectMethod(StatementReindex, funcName, __VA_ARGS__)\n#define WCDBJNIStatementReindexObjectMethodWithNoArg(funcName)                 \\\n    WCDBJNIObjectMethodWithNoArg(StatementReindex, funcName)\n#define WCDBJNIStatementReindexClassMethodWithNoArg(funcName)                  \\\n    WCDBJNIClassMethodWithNoArg(StatementReindex, funcName)\n#define WCDBJNIStatementReindexClassMethod(funcName, ...)                      \\\n    WCDBJNIClassMethod(StatementReindex, funcName, __VA_ARGS__)\n\njlong WCDBJNIStatementReindexClassMethodWithNoArg(createCppObj);\n\nvoid WCDBJNIStatementReindexClassMethod(configCollation, jlong self, jstring collation);\nvoid WCDBJNIStatementReindexClassMethod(configTable, jlong self, jstring name);\nvoid WCDBJNIStatementReindexClassMethod(configIndex, jlong self, jstring name);\nvoid WCDBJNIStatementReindexClassMethod(configSchema,\n                                        jlong self,\n                                        WCDBJNIObjectOrStringParameter(schema));"
  },
  {
    "path": "src/java/main/src/main/cpp/winq/Statement/StatementReleaseJNI.c",
    "content": "// Created by qiuwenchen on 2023/6/12.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"StatementReleaseJNI.h\"\n#include \"StatementReleaseBridge.h\"\n\njlong WCDBJNIStatementReleaseClassMethodWithNoArg(createCppObj)\n{\n    return (jlong) WCDBStatementReleaseCreate().innerValue;\n}\n\nvoid WCDBJNIStatementReleaseClassMethod(configSavepoint, jlong self, jstring savepoint)\n{\n    WCDBJNIBridgeStruct(CPPStatementRelease, self);\n    WCDBJNIGetStringCritical(savepoint);\n    WCDBStatementReleaseConfigSavepoint(selfStruct, savepointString);\n    WCDBJNIReleaseStringCritical(savepoint);\n}\n"
  },
  {
    "path": "src/java/main/src/main/cpp/winq/Statement/StatementReleaseJNI.h",
    "content": "// Created by qiuwenchen on 2023/6/12.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"WCDBJNI.h\"\n\n#define WCDBJNIStatementReleaseFuncName(funcName)                              \\\n    WCDBJNI(StatementRelease, funcName)\n#define WCDBJNIStatementReleaseObjectMethod(funcName, ...)                     \\\n    WCDBJNIObjectMethod(StatementRelease, funcName, __VA_ARGS__)\n#define WCDBJNIStatementReleaseObjectMethodWithNoArg(funcName)                 \\\n    WCDBJNIObjectMethodWithNoArg(StatementRelease, funcName)\n#define WCDBJNIStatementReleaseClassMethodWithNoArg(funcName)                  \\\n    WCDBJNIClassMethodWithNoArg(StatementRelease, funcName)\n#define WCDBJNIStatementReleaseClassMethod(funcName, ...)                      \\\n    WCDBJNIClassMethod(StatementRelease, funcName, __VA_ARGS__)\n\njlong WCDBJNIStatementReleaseClassMethodWithNoArg(createCppObj);\nvoid WCDBJNIStatementReleaseClassMethod(configSavepoint, jlong self, jstring savepoint);\n"
  },
  {
    "path": "src/java/main/src/main/cpp/winq/Statement/StatementRollbackJNI.c",
    "content": "// Created by qiuwenchen on 2023/6/12.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"StatementRollbackJNI.h\"\n#include \"StatementRollbackBridge.h\"\n\njlong WCDBJNIStatementRollbackClassMethodWithNoArg(createCppObj)\n{\n    return (jlong) WCDBStatementRollbackCreate().innerValue;\n}\n\nvoid WCDBJNIStatementRollbackClassMethod(configSavepoint, jlong self, jstring savepoint)\n{\n    WCDBJNIBridgeStruct(CPPStatementRollback, self);\n    WCDBJNIGetStringCritical(savepoint);\n    WCDBStatementRollbackConfigSavepoint(selfStruct, savepointString);\n    WCDBJNIReleaseStringCritical(savepoint);\n}"
  },
  {
    "path": "src/java/main/src/main/cpp/winq/Statement/StatementRollbackJNI.h",
    "content": "// Created by qiuwenchen on 2023/6/12.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"WCDBJNI.h\"\n\n#define WCDBJNIStatementRollbackFuncName(funcName)                             \\\n    WCDBJNI(StatementRollback, funcName)\n#define WCDBJNIStatementRollbackObjectMethod(funcName, ...)                    \\\n    WCDBJNIObjectMethod(StatementRollback, funcName, __VA_ARGS__)\n#define WCDBJNIStatementRollbackObjectMethodWithNoArg(funcName)                \\\n    WCDBJNIObjectMethodWithNoArg(StatementRollback, funcName)\n#define WCDBJNIStatementRollbackClassMethodWithNoArg(funcName)                 \\\n    WCDBJNIClassMethodWithNoArg(StatementRollback, funcName)\n#define WCDBJNIStatementRollbackClassMethod(funcName, ...)                     \\\n    WCDBJNIClassMethod(StatementRollback, funcName, __VA_ARGS__)\n\njlong WCDBJNIStatementRollbackClassMethodWithNoArg(createCppObj);\nvoid WCDBJNIStatementRollbackClassMethod(configSavepoint, jlong self, jstring savepoint);\n"
  },
  {
    "path": "src/java/main/src/main/cpp/winq/Statement/StatementSelectJNI.c",
    "content": "// Created by qiuwenchen on 2023/4/13.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"StatementSelectJNI.h\"\n#include \"StatementSelectBridge.h\"\n\njlong WCDBJNIStatementSelectClassMethodWithNoArg(create)\n{\n    return (jlong) WCDBStatementSelectCreate().innerValue;\n}\n\nvoid WCDBJNIStatementSelectClassMethod(configWith, jlong self, jlongArray expressions)\n{\n    WCDBJNIBridgeStruct(CPPStatementSelect, self);\n    WCDBJNIGetCppPointerArrayCritical(expressions);\n    WCDBStatementSelectConfigWith(\n    selfStruct, (const CPPCommonTableExpression *) expressionsArray, expressionsLength);\n    WCDBJNIReleaseCppPointerArrayCritical(expressions);\n}\n\nvoid WCDBJNIStatementSelectClassMethod(configRecursive, jlong self)\n{\n    WCDBJNIBridgeStruct(CPPStatementSelect, self);\n    WCDBStatementSelectConfigRecursive(selfStruct);\n}\n\nvoid WCDBJNIStatementSelectClassMethod(configResultColumns,\n                                       jlong self,\n                                       WCDBJNIMultiTypeArrayParameter(resultColumns))\n{\n    WCDBJNIBridgeStruct(CPPStatementSelect, self);\n    WCDBJNICreateMultiTypeArray(resultColumns);\n    WCDBStatementSelectConfigResultColumns2(selfStruct, resultColumnsArray);\n    WCDBJNIReleaseMultiTypeArray(resultColumns);\n}\n\nvoid WCDBJNIStatementSelectClassMethod(configDistiction, jlong self)\n{\n    WCDBJNIBridgeStruct(CPPStatementSelect, self);\n    WCDBStatementSelectConfigDistinct(selfStruct);\n}\n\nvoid WCDBJNIStatementSelectClassMethod(configTableOrSubqueries,\n                                       jlong self,\n                                       WCDBJNIMultiTypeArrayParameter(tableOrSubqueries))\n{\n    WCDBJNIBridgeStruct(CPPStatementSelect, self);\n    WCDBJNICreateMultiTypeArray(tableOrSubqueries);\n    WCDBStatementSelectConfigFromTableOrSubqueries2(selfStruct, tableOrSubqueriesArray);\n    WCDBJNIReleaseMultiTypeArray(tableOrSubqueries);\n}\n\nvoid WCDBJNIStatementSelectClassMethod(configCondition, jlong self, jlong condition)\n{\n    WCDBJNIBridgeStruct(CPPStatementSelect, self);\n    WCDBJNIBridgeStruct(CPPExpression, condition);\n    WCDBStatementSelectConfigWhere(selfStruct, conditionStruct);\n}\n\nvoid WCDBJNIStatementSelectClassMethod(configGroups,\n                                       jlong self,\n                                       WCDBJNIMultiTypeArrayParameter(groups))\n{\n    WCDBJNIBridgeStruct(CPPStatementSelect, self);\n    WCDBJNICreateMultiTypeArray(groups);\n    WCDBStatementSelectConfigGroups2(selfStruct, groupsArray);\n    WCDBJNIReleaseMultiTypeArray(groups);\n}\n\nvoid WCDBJNIStatementSelectClassMethod(configHaving, jlong self, jlong expression)\n{\n    WCDBJNIBridgeStruct(CPPStatementSelect, self);\n    WCDBJNIBridgeStruct(CPPExpression, expression);\n    WCDBStatementSelectConfigHaving(selfStruct, expressionStruct);\n}\n\nvoid WCDBJNIStatementSelectClassMethod(configUnion, jlong self)\n{\n    WCDBJNIBridgeStruct(CPPStatementSelect, self);\n    WCDBStatementSelectConfigUnion(selfStruct);\n}\n\nvoid WCDBJNIStatementSelectClassMethod(configUnionAll, jlong self)\n{\n    WCDBJNIBridgeStruct(CPPStatementSelect, self);\n    WCDBStatementSelectConfigUnionAll(selfStruct);\n}\n\nvoid WCDBJNIStatementSelectClassMethod(configIntersect, jlong self)\n{\n    WCDBJNIBridgeStruct(CPPStatementSelect, self);\n    WCDBStatementSelectConfigIntersect(selfStruct);\n}\n\nvoid WCDBJNIStatementSelectClassMethod(configExcept, jlong self)\n{\n    WCDBJNIBridgeStruct(CPPStatementSelect, self);\n    WCDBStatementSelectConfigExcept(selfStruct);\n}\n\nvoid WCDBJNIStatementSelectClassMethod(configOrders, jlong self, jlongArray orders)\n{\n    WCDBJNIBridgeStruct(CPPStatementSelect, self);\n    WCDBJNIGetCppPointerArrayCritical(orders);\n    WCDBStatementSelectConfigOrders(\n    selfStruct, (const CPPOrderingTerm *) ordersArray, ordersLength);\n    WCDBJNIReleaseCppPointerArrayCritical(orders);\n}\n\nvoid WCDBJNIStatementSelectClassMethod(\nconfigLimitRange, jlong self, jint fromType, jlong from, jint toType, jlong to)\n{\n    WCDBJNIBridgeStruct(CPPStatementSelect, self);\n    CPPCommonValue from_common;\n    from_common.type = fromType;\n    from_common.intValue = from;\n    CPPCommonValue to_common;\n    to_common.type = toType;\n    to_common.intValue = to;\n    WCDBStatementSelectConfigLimitRange2(selfStruct, from_common, to_common);\n}\n\nvoid WCDBJNIStatementSelectClassMethod(configLimitCount, jlong self, jint type, jlong limit)\n{\n    WCDBJNIBridgeStruct(CPPStatementSelect, self);\n    CPPCommonValue limit_common;\n    limit_common.type = type;\n    limit_common.intValue = limit;\n    WCDBStatementSelectConfigLimitCount2(selfStruct, limit_common);\n}\n\nvoid WCDBJNIStatementSelectClassMethod(configOffset, jlong self, jint type, jlong offset)\n{\n    WCDBJNIBridgeStruct(CPPStatementSelect, self);\n    CPPCommonValue offset_common;\n    offset_common.type = type;\n    offset_common.intValue = offset;\n    WCDBStatementSelectConfigOffset2(selfStruct, offset_common);\n}\n"
  },
  {
    "path": "src/java/main/src/main/cpp/winq/Statement/StatementSelectJNI.h",
    "content": "// Created by qiuwenchen on 2023/4/13.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"WCDBJNI.h\"\n\n#define WCDBJNIStatementSelectFuncName(funcName)                               \\\n    WCDBJNI(StatementSelect, funcName)\n#define WCDBJNIStatementSelectObjectMethod(funcName, ...)                      \\\n    WCDBJNIObjectMethod(StatementSelect, funcName, __VA_ARGS__)\n#define WCDBJNIStatementSelectObjectMethodWithNoArg(funcName)                  \\\n    WCDBJNIObjectMethodWithNoArg(StatementSelect, funcName)\n#define WCDBJNIStatementSelectClassMethodWithNoArg(funcName)                   \\\n    WCDBJNIClassMethodWithNoArg(StatementSelect, funcName)\n#define WCDBJNIStatementSelectClassMethod(funcName, ...)                       \\\n    WCDBJNIClassMethod(StatementSelect, funcName, __VA_ARGS__)\n\njlong WCDBJNIStatementSelectClassMethodWithNoArg(create);\n\nvoid WCDBJNIStatementSelectClassMethod(configWith, jlong self, jlongArray expressions);\nvoid WCDBJNIStatementSelectClassMethod(configRecursive, jlong self);\n\nvoid WCDBJNIStatementSelectClassMethod(configResultColumns,\n                                       jlong self,\n                                       WCDBJNIMultiTypeArrayParameter(resultColumns));\nvoid WCDBJNIStatementSelectClassMethod(configDistiction, jlong self);\nvoid WCDBJNIStatementSelectClassMethod(configTableOrSubqueries,\n                                       jlong self,\n                                       WCDBJNIMultiTypeArrayParameter(tableOrSubqueries));\nvoid WCDBJNIStatementSelectClassMethod(configCondition, jlong self, jlong condition);\nvoid WCDBJNIStatementSelectClassMethod(configGroups,\n                                       jlong self,\n                                       WCDBJNIMultiTypeArrayParameter(groups));\nvoid WCDBJNIStatementSelectClassMethod(configHaving, jlong self, jlong expression);\nvoid WCDBJNIStatementSelectClassMethod(configUnion, jlong self);\nvoid WCDBJNIStatementSelectClassMethod(configUnionAll, jlong self);\nvoid WCDBJNIStatementSelectClassMethod(configIntersect, jlong self);\nvoid WCDBJNIStatementSelectClassMethod(configExcept, jlong self);\nvoid WCDBJNIStatementSelectClassMethod(configOrders, jlong self, jlongArray orders);\nvoid WCDBJNIStatementSelectClassMethod(\nconfigLimitRange, jlong self, jint fromType, jlong from, jint toType, jlong to);\nvoid WCDBJNIStatementSelectClassMethod(configLimitCount, jlong self, jint type, jlong limit);\nvoid WCDBJNIStatementSelectClassMethod(configOffset, jlong self, jint type, jlong offset);\n"
  },
  {
    "path": "src/java/main/src/main/cpp/winq/Statement/StatementUpdateJNI.c",
    "content": "// Created by chenqiuwen on 2023/4/13.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"StatementUpdateJNI.h\"\n#include \"StatementUpdateBridge.h\"\n\njlong WCDBJNIStatementUpdateClassMethodWithNoArg(create)\n{\n    return (jlong) WCDBStatementUpdateCreate().innerValue;\n}\n\nvoid WCDBJNIStatementUpdateClassMethod(configWith, jlong self, jlongArray expressions)\n{\n    WCDBJNIBridgeStruct(CPPStatementUpdate, self);\n    WCDBJNIGetCppPointerArrayCritical(expressions);\n    WCDBStatementUpdateConfigWith(\n    selfStruct, (const CPPCommonTableExpression *) expressionsArray, expressionsLength);\n    WCDBJNIReleaseCppPointerArrayCritical(expressions);\n}\n\nvoid WCDBJNIStatementUpdateClassMethod(configRecursive, jlong self)\n{\n    WCDBJNIBridgeStruct(CPPStatementUpdate, self);\n    WCDBStatementUpdateConfigRecursive(selfStruct);\n}\n\nvoid WCDBJNIStatementUpdateClassMethod(configTable, jlong self, WCDBJNIObjectOrStringParameter(table))\n{\n    WCDBJNIBridgeStruct(CPPStatementUpdate, self);\n    WCDBJNICreateObjectOrStringCommonValue(table, true);\n    WCDBStatementUpdateConfigTable2(selfStruct, table_common);\n    WCDBJNITryReleaseStringInCommonValue(table);\n}\n\nvoid WCDBJNIStatementUpdateClassMethod(configConfliction, jlong self, jint action)\n{\n    WCDBJNIBridgeStruct(CPPStatementUpdate, self);\n    WCDBStatementUpdateConfigConfiction(selfStruct, action);\n}\n\nvoid WCDBJNIStatementUpdateClassMethod(configColumns,\n                                       jlong self,\n                                       WCDBJNIObjectOrStringArrayParameter(columns))\n{\n    WCDBJNIBridgeStruct(CPPStatementUpdate, self);\n    WCDBJNICreateObjectOrStringArrayCriticalWithAction(\n    columns, WCDBStatementUpdateConfigColumns2(selfStruct, columns_commonArray));\n}\n\nvoid WCDBJNIStatementUpdateClassMethod(configValue, jlong self, WCDBJNICommonValueParameter(value))\n{\n    WCDBJNIBridgeStruct(CPPStatementUpdate, self);\n    WCDBJNICreateCommonValue(value, true);\n    WCDBStatementUpdateConfigValue2(selfStruct, value_common);\n    WCDBJNITryReleaseStringInCommonValue(value);\n}\n\nvoid WCDBJNIStatementUpdateClassMethod(configColumnsToValues,\n                                       jlong self,\n                                       WCDBJNIObjectOrStringArrayParameter(columns),\n                                       WCDBJNIMultiTypeArrayParameter(values))\n{\n    WCDBJNIBridgeStruct(CPPStatementUpdate, self);\n    WCDBJNICreateMultiTypeArray(values);\n    WCDBJNICreateObjectOrStringArrayCriticalWithAction(\n    columns, WCDBStatementUpdateConfigColumnsToValues(selfStruct, columns_commonArray, valuesArray));\n    WCDBJNIReleaseMultiTypeArray(values);\n}\n\nvoid WCDBJNIStatementUpdateClassMethod(configColumnsWithBindParameter,\n                                       jlong self,\n                                       WCDBJNIObjectOrStringArrayParameter(columns))\n{\n    WCDBJNIBridgeStruct(CPPStatementUpdate, self);\n    WCDBJNICreateObjectOrStringArrayCriticalWithAction(\n    columns, WCDBStatementUpdateConfigColumnsToBindParameters(selfStruct, columns_commonArray));\n}\n\nvoid WCDBJNIStatementUpdateClassMethod(configCondition, jlong self, jlong condition)\n{\n    WCDBJNIBridgeStruct(CPPStatementUpdate, self);\n    WCDBJNIBridgeStruct(CPPExpression, condition);\n    WCDBStatementUpdateConfigCondition(selfStruct, conditionStruct);\n}\n\nvoid WCDBJNIStatementUpdateClassMethod(configOrders, jlong self, jlongArray orders)\n{\n    WCDBJNIBridgeStruct(CPPStatementUpdate, self);\n    WCDBJNIGetCppPointerArrayCritical(orders);\n    WCDBStatementUpdateConfigOrders(\n    selfStruct, (const CPPOrderingTerm *) ordersArray, ordersLength);\n    WCDBJNIReleaseCppPointerArrayCritical(orders);\n}\n\nvoid WCDBJNIStatementUpdateClassMethod(\nconfigLimitRange, jlong self, jint fromType, jlong from, jint toType, jlong to)\n{\n    WCDBJNIBridgeStruct(CPPStatementUpdate, self);\n    CPPCommonValue from_common;\n    from_common.type = fromType;\n    from_common.intValue = from;\n    CPPCommonValue to_common;\n    to_common.type = toType;\n    to_common.intValue = to;\n    WCDBStatementUpdateConfigLimitRange2(selfStruct, from_common, to_common);\n}\n\nvoid WCDBJNIStatementUpdateClassMethod(configLimitCount, jlong self, jint type, jlong limit)\n{\n    WCDBJNIBridgeStruct(CPPStatementUpdate, self);\n    CPPCommonValue limit_common;\n    limit_common.type = type;\n    limit_common.intValue = limit;\n    WCDBStatementUpdateConfigLimitCount2(selfStruct, limit_common);\n}\n\nvoid WCDBJNIStatementUpdateClassMethod(configOffset, jlong self, jint type, jlong offset)\n{\n    WCDBJNIBridgeStruct(CPPStatementUpdate, self);\n    CPPCommonValue offset_common;\n    offset_common.type = type;\n    offset_common.intValue = offset;\n    WCDBStatementUpdateConfigOffset2(selfStruct, offset_common);\n}\n"
  },
  {
    "path": "src/java/main/src/main/cpp/winq/Statement/StatementUpdateJNI.h",
    "content": "// Created by chenqiuwen on 2023/4/13.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"WCDBJNI.h\"\n\n#define WCDBJNIStatementUpdateFuncName(funcName)                               \\\n    WCDBJNI(StatementUpdate, funcName)\n#define WCDBJNIStatementUpdateObjectMethod(funcName, ...)                      \\\n    WCDBJNIObjectMethod(StatementUpdate, funcName, __VA_ARGS__)\n#define WCDBJNIStatementUpdateObjectMethodWithNoArg(funcName)                  \\\n    WCDBJNIObjectMethodWithNoArg(StatementUpdate, funcName)\n#define WCDBJNIStatementUpdateClassMethodWithNoArg(funcName)                   \\\n    WCDBJNIClassMethodWithNoArg(StatementUpdate, funcName)\n#define WCDBJNIStatementUpdateClassMethod(funcName, ...)                       \\\n    WCDBJNIClassMethod(StatementUpdate, funcName, __VA_ARGS__)\n\njlong WCDBJNIStatementUpdateClassMethodWithNoArg(create);\n\nvoid WCDBJNIStatementUpdateClassMethod(configWith, jlong self, jlongArray expressions);\nvoid WCDBJNIStatementUpdateClassMethod(configRecursive, jlong self);\n\nvoid WCDBJNIStatementUpdateClassMethod(configTable,\n                                       jlong self,\n                                       WCDBJNIObjectOrStringParameter(table));\nvoid WCDBJNIStatementUpdateClassMethod(configConfliction, jlong self, jint action);\nvoid WCDBJNIStatementUpdateClassMethod(configColumns,\n                                       jlong self,\n                                       WCDBJNIObjectOrStringArrayParameter(columns));\nvoid WCDBJNIStatementUpdateClassMethod(configValue, jlong self, WCDBJNICommonValueParameter(value));\nvoid WCDBJNIStatementUpdateClassMethod(configColumnsToValues,\n                                       jlong self,\n                                       WCDBJNIObjectOrStringArrayParameter(columns),\n                                       WCDBJNIMultiTypeArrayParameter(values));\nvoid WCDBJNIStatementUpdateClassMethod(configColumnsWithBindParameter,\n                                       jlong self,\n                                       WCDBJNIObjectOrStringArrayParameter(columns));\nvoid WCDBJNIStatementUpdateClassMethod(configCondition, jlong self, jlong condition);\nvoid WCDBJNIStatementUpdateClassMethod(configOrders, jlong self, jlongArray orders);\nvoid WCDBJNIStatementUpdateClassMethod(\nconfigLimitRange, jlong self, jint fromType, jlong from, jint toType, jlong to);\nvoid WCDBJNIStatementUpdateClassMethod(configLimitCount, jlong self, jint type, jlong limit);\nvoid WCDBJNIStatementUpdateClassMethod(configOffset, jlong self, jint type, jlong offset);\n"
  },
  {
    "path": "src/java/main/src/main/cpp/winq/Statement/StatementVacuumJNI.c",
    "content": "// Created by qiuwenchen on 2023/6/13.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"StatementVacuumJNI.h\"\n#include \"StatementVacuumBridge.h\"\n\njlong WCDBJNIStatementVacuumClassMethodWithNoArg(createCppObj)\n{\n    CPPStatementVacuum vacuum = WCDBStatementVacuumCreate();\n    WCDBStatementVacuumConfigAll(vacuum);\n    return (jlong) vacuum.innerValue;\n}\n\nvoid WCDBJNIStatementVacuumClassMethod(configSchema,\n                                       jlong self,\n                                       WCDBJNIObjectOrStringParameter(schema))\n{\n    WCDBJNIBridgeStruct(CPPStatementVacuum, self);\n    WCDBJNICreateObjectOrStringCommonValue(schema, true);\n    WCDBStatementVacuumConfigSchema2(selfStruct, schema_common);\n    WCDBJNITryReleaseStringInCommonValue(schema);\n}"
  },
  {
    "path": "src/java/main/src/main/cpp/winq/Statement/StatementVacuumJNI.h",
    "content": "// Created by qiuwenchen on 2023/6/13.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"WCDBJNI.h\"\n\n#define WCDBJNIStatementVacuumFuncName(funcName)                               \\\n    WCDBJNI(StatementVacuum, funcName)\n#define WCDBJNIStatementVacuumObjectMethod(funcName, ...)                      \\\n    WCDBJNIObjectMethod(StatementVacuum, funcName, __VA_ARGS__)\n#define WCDBJNIStatementVacuumObjectMethodWithNoArg(funcName)                  \\\n    WCDBJNIObjectMethodWithNoArg(StatementVacuum, funcName)\n#define WCDBJNIStatementVacuumClassMethodWithNoArg(funcName)                   \\\n    WCDBJNIClassMethodWithNoArg(StatementVacuum, funcName)\n#define WCDBJNIStatementVacuumClassMethod(funcName, ...)                       \\\n    WCDBJNIClassMethod(StatementVacuum, funcName, __VA_ARGS__)\n\njlong WCDBJNIStatementVacuumClassMethodWithNoArg(createCppObj);\nvoid WCDBJNIStatementVacuumClassMethod(configSchema,\n                                       jlong self,\n                                       WCDBJNIObjectOrStringParameter(schema));\n"
  },
  {
    "path": "src/java/main/src/main/cpp/winq/WinqJNI.c",
    "content": "// Created by qiuwenchen on 2023/3/30.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"WinqJNI.h\"\n#include \"WinqBridge.h\"\n\njstring WCDBJNIClassMethod(Winq, getDescription, long long statement)\n{\n    WCDBJNICreateJStringAndReturn(WCDBWinqGetDescription((CPPObject *) statement));\n}\n\njboolean WCDBJNIClassMethod(Winq, isWriteStatement, long long statement)\n{\n    return WCDBStatementNeedToWrite((CPPObject *) statement);\n}\n"
  },
  {
    "path": "src/java/main/src/main/cpp/winq/WinqJNI.h",
    "content": "// Created by qiuwenchen on 2023/3/30.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n#include \"WCDBJNI.h\"\n\njstring JNIEXPORT WCDBJNIClassMethod(Winq, getDescription, long long statement);\njboolean JNIEXPORT WCDBJNIClassMethod(Winq, isWriteStatement, long long statement);"
  },
  {
    "path": "src/java/main/src/main/cpp/winq/identifier/BindParameterJNI.c",
    "content": "// Created by qiuwenchen on 2023/3/31.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"BindParameterJNI.h\"\n#include \"BindParameterBridge.h\"\n\njlong WCDBJNIBindParameterClassMethod(createQuestionSignType, jint num)\n{\n    return (jlong) WCDBBindparameterCreateQuestionSignType(num).innerValue;\n}\n\njlong WCDBJNIBindParameterClassMethod(createAtSignType, jstring name)\n{\n    WCDBJNIGetStringCritical(name);\n    jlong ret = (jlong) WCDBBindparameterCreateAtSignType(nameString).innerValue;\n    WCDBJNIReleaseStringCritical(name);\n    return ret;\n}\n\njlong WCDBJNIBindParameterClassMethod(createColonSignType, jstring name)\n{\n    WCDBJNIGetStringCritical(name);\n    jlong ret = (jlong) WCDBBindparameterCreateColonSignType(nameString).innerValue;\n    WCDBJNIReleaseStringCritical(name);\n    return ret;\n}\n\njlong WCDBJNIBindParameterClassMethod(createDollarSignType, jstring name)\n{\n    WCDBJNIGetStringCritical(name);\n    jlong ret = (jlong) WCDBBindparameterCreateDollarSignType(nameString).innerValue;\n    WCDBJNIReleaseStringCritical(name);\n    return ret;\n}\n\njlongArray WCDBJNIBindParameterClassMethod(bindParameters, jint size)\n{\n    jlongArray result = (*env)->NewLongArray(env, size);\n    jlong* buffers = alloca(size * sizeof(jlong));\n    for (int i = 0; i < size; i++) {\n        buffers[i] = (jlong) WCDBBindparameterCreateQuestionSignType(i + 1).innerValue;\n    }\n    (*env)->SetLongArrayRegion(env, result, 0, size, buffers);\n    return result;\n}\n"
  },
  {
    "path": "src/java/main/src/main/cpp/winq/identifier/BindParameterJNI.h",
    "content": "// Created by qiuwenchen on 2023/3/31.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n#include \"WCDBJNI.h\"\n\n#define WCDBJNIBindParameterFuncName(funcName) WCDBJNI(BindParameter, funcName)\n#define WCDBJNIBindParameterObjectMethod(funcName, ...)                        \\\n    WCDBJNIObjectMethod(BindParameter, funcName, __VA_ARGS__)\n#define WCDBJNIBindParameterClassMethod(funcName, ...)                         \\\n    WCDBJNIClassMethod(BindParameter, funcName, __VA_ARGS__)\n\njlong WCDBJNIBindParameterClassMethod(createQuestionSignType, jint num);\njlong WCDBJNIBindParameterClassMethod(createAtSignType, jstring name);\njlong WCDBJNIBindParameterClassMethod(createColonSignType, jstring name);\njlong WCDBJNIBindParameterClassMethod(createDollarSignType, jstring name);\njlongArray WCDBJNIBindParameterClassMethod(bindParameters, jint size);\n"
  },
  {
    "path": "src/java/main/src/main/cpp/winq/identifier/ColumnConstraintJNI.c",
    "content": "// Created by chenqiuwen on 2023/4/3.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"ColumnConstraintJNI.h\"\n#include \"ColumnConstraintBridge.h\"\n\njlong WCDBJNIColumnConstraintClassMethod(create, jstring name)\n{\n    WCDBJNIGetStringCritical(name);\n    jlong ret = (jlong) WCDBColumnConstraintCreate(nameString).innerValue;\n    WCDBJNIReleaseStringCritical(name);\n    return ret;\n}\n\nvoid WCDBJNIColumnConstraintClassMethod(configPrimaryKey, jlong constraint)\n{\n    WCDBJNIBridgeStruct(CPPColumnConstraint, constraint);\n    WCDBColumnConstraintConfigPrimaryKey(constraintStruct);\n}\n\nvoid WCDBJNIColumnConstraintClassMethod(configOrder, jlong constraint, jint order)\n{\n    WCDBJNIBridgeStruct(CPPColumnConstraint, constraint);\n    WCDBColumnConstraintConfigOrder(constraintStruct, order);\n}\n\nvoid WCDBJNIColumnConstraintClassMethod(configConflictAction, jlong constraint, jint conflictAction)\n{\n    WCDBJNIBridgeStruct(CPPColumnConstraint, constraint);\n    WCDBColumnConstraintConfigCoflictAction(constraintStruct, conflictAction);\n}\n\nvoid WCDBJNIColumnConstraintClassMethod(configAutoIncrement, jlong constraint)\n{\n    WCDBJNIBridgeStruct(CPPColumnConstraint, constraint);\n    WCDBColumnConstraintConfigAutoIncrement(constraintStruct);\n}\n\nvoid WCDBJNIColumnConstraintClassMethod(configNotNull, jlong constraint)\n{\n    WCDBJNIBridgeStruct(CPPColumnConstraint, constraint);\n    WCDBColumnConstraintConfigNotNull(constraintStruct);\n}\n\nvoid WCDBJNIColumnConstraintClassMethod(configUnique, jlong constraint)\n{\n    WCDBJNIBridgeStruct(CPPColumnConstraint, constraint);\n    WCDBColumnConstraintConfigUnique(constraintStruct);\n}\n\nvoid WCDBJNIColumnConstraintClassMethod(configCheck, jlong constraint, jlong expression)\n{\n    WCDBJNIBridgeStruct(CPPColumnConstraint, constraint);\n    WCDBJNIBridgeStruct(CPPExpression, expression);\n    WCDBColumnConstraintConfigCheck(constraintStruct, expressionStruct);\n}\n\nvoid WCDBJNIColumnConstraintClassMethod(configDefaultValue,\n                                        jlong constraint,\n                                        WCDBJNICommonValueParameter(value))\n{\n    WCDBJNIBridgeStruct(CPPColumnConstraint, constraint);\n    WCDBJNICreateCommonValue(value, true);\n    WCDBColumnConstraintConfigDefaultValue2(constraintStruct, value_common);\n    WCDBJNITryReleaseStringInCommonValue(value);\n}\n\nvoid WCDBJNIColumnConstraintClassMethod(configCollation, jlong constraint, jstring collation)\n{\n    WCDBJNIBridgeStruct(CPPColumnConstraint, constraint);\n    WCDBJNIGetStringCritical(collation);\n    WCDBColumnConstraintConfigCollation(constraintStruct, collationString);\n    WCDBJNIReleaseStringCritical(collation);\n}\n\nvoid WCDBJNIColumnConstraintClassMethod(configForeignKey, jlong constraint, jlong foreignKey)\n{\n    WCDBJNIBridgeStruct(CPPColumnConstraint, constraint);\n    WCDBJNIBridgeStruct(CPPForeignKey, foreignKey);\n    WCDBColumnConstraintConfigForeignKey(constraintStruct, foreignKeyStruct);\n}\n\nvoid WCDBJNIColumnConstraintClassMethod(configUnindexed, jlong constraint)\n{\n    WCDBJNIBridgeStruct(CPPColumnConstraint, constraint);\n    WCDBColumnConstraintConfigUnIndexed(constraintStruct);\n}\n"
  },
  {
    "path": "src/java/main/src/main/cpp/winq/identifier/ColumnConstraintJNI.h",
    "content": "// Created by chenqiuwen on 2023/4/3.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"WCDBJNI.h\"\n\n#define WCDBJNIColumnConstraintFuncName(funcName)                              \\\n    WCDBJNI(ColumnConstraint, funcName)\n#define WCDBJNIColumnConstraintObjectMethod(funcName, ...)                     \\\n    WCDBJNIObjectMethod(ColumnConstraint, funcName, __VA_ARGS__)\n#define WCDBJNIColumnConstraintClassMethodWithNoArg(funcName)                  \\\n    WCDBJNIClassMethodWithNoArg(ColumnConstraint, funcName)\n#define WCDBJNIColumnConstraintClassMethod(funcName, ...)                      \\\n    WCDBJNIClassMethod(ColumnConstraint, funcName, __VA_ARGS__)\n\njlong WCDBJNIColumnConstraintClassMethod(create, jstring name);\n\nvoid WCDBJNIColumnConstraintClassMethod(configPrimaryKey, jlong constraint);\n\nvoid WCDBJNIColumnConstraintClassMethod(configOrder, jlong constraint, jint order);\n\nvoid WCDBJNIColumnConstraintClassMethod(configConflictAction, jlong constraint, jint conflictAction);\n\nvoid WCDBJNIColumnConstraintClassMethod(configAutoIncrement, jlong constraint);\n\nvoid WCDBJNIColumnConstraintClassMethod(configNotNull, jlong constraint);\n\nvoid WCDBJNIColumnConstraintClassMethod(configUnique, jlong constraint);\n\nvoid WCDBJNIColumnConstraintClassMethod(configCheck, jlong constraint, jlong expression);\n\nvoid WCDBJNIColumnConstraintClassMethod(configDefaultValue,\n                                        jlong constraint,\n                                        WCDBJNICommonValueParameter(value));\n\nvoid WCDBJNIColumnConstraintClassMethod(configCollation, jlong constraint, jstring collation);\n\nvoid WCDBJNIColumnConstraintClassMethod(configForeignKey, jlong constraint, jlong foreignKey);\n\nvoid WCDBJNIColumnConstraintClassMethod(configUnindexed, jlong constraint);\n"
  },
  {
    "path": "src/java/main/src/main/cpp/winq/identifier/ColumnDefJNI.c",
    "content": "// Created by qiuwenchen on 2023/4/7.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"ColumnDefJNI.h\"\n#include \"ColumnDefBridge.h\"\n\njlong WCDBJNIColumnDefClassMethod(create, WCDBJNIObjectOrStringParameter(column), jint columnType)\n{\n    WCDBJNICreateObjectOrStringCommonValue(column, true);\n    jlong ret = 0;\n    if (columnType != 0) {\n        ret = (jlong) WCDBColumnDefCreateWithType2(column_common, columnType).innerValue;\n    } else {\n        ret = (jlong) WCDBColumnDefCreateWithoutType2(column_common).innerValue;\n    }\n    WCDBJNITryReleaseStringInCommonValue(column);\n    return ret;\n}\n\nvoid WCDBJNIColumnDefClassMethod(configConstraint, jlong columnDef, jlong constraint)\n{\n    WCDBJNIBridgeStruct(CPPColumnDef, columnDef);\n    WCDBJNIBridgeStruct(CPPColumnConstraint, constraint);\n    WCDBColumnDefConfigConstraint(columnDefStruct, constraintStruct);\n}"
  },
  {
    "path": "src/java/main/src/main/cpp/winq/identifier/ColumnDefJNI.h",
    "content": "// Created by qiuwenchen on 2023/4/7.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"WCDBJNI.h\"\n\n#define WCDBJNIColumnDefFuncName(funcName) WCDBJNI(ColumnDef, funcName)\n#define WCDBJNIColumnDefObjectMethod(funcName, ...)                            \\\n    WCDBJNIObjectMethod(ColumnDef, funcName, __VA_ARGS__)\n#define WCDBJNIColumnDefClassMethodWithNoArg(funcName)                         \\\n    WCDBJNIClassMethodWithNoArg(ColumnDef, funcName)\n#define WCDBJNIColumnDefClassMethod(funcName, ...)                             \\\n    WCDBJNIClassMethod(ColumnDef, funcName, __VA_ARGS__)\n\njlong WCDBJNIColumnDefClassMethod(create, WCDBJNIObjectOrStringParameter(column), jint columnType);\n\nvoid WCDBJNIColumnDefClassMethod(configConstraint, jlong columnDef, jlong constraint);"
  },
  {
    "path": "src/java/main/src/main/cpp/winq/identifier/ColumnJNI.c",
    "content": "// Created by qiuwenchen on 2023/3/30.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"ColumnJNI.h\"\n#include \"ColumnBridge.h\"\n\njlong WCDBJNIColumnClassMethodWithNoArg(createAll)\n{\n    return (jlong) WCDBColumnCreateAll().innerValue;\n}\n\njlong WCDBJNIColumnClassMethodWithNoArg(createRowId)\n{\n    return (jlong) WCDBColumnCreateRowId().innerValue;\n}\n\njlong WCDBJNIColumnClassMethod(createWithName, jstring name, jlong binding)\n{\n    WCDBJNIGetStringCritical(name);\n    jlong ret\n    = (jlong) WCDBColumnCreateWithName2(nameString, (const void *) binding).innerValue;\n    WCDBJNIReleaseStringCritical(name);\n    return ret;\n}\n\njlong WCDBJNIColumnClassMethod(copy, jlong column)\n{\n    WCDBJNIBridgeStruct(CPPColumn, column);\n    return (jlong) WCDBColumnCopy(columnStruct).innerValue;\n}\n\nvoid WCDBJNIColumnClassMethod(inTable, jlong column, jstring table)\n{\n    WCDBJNIGetStringCritical(table);\n    WCDBJNIBridgeStruct(CPPColumn, column);\n    WCDBColumnInTable(columnStruct, tableString);\n    WCDBJNIReleaseStringCritical(table);\n}\n\nvoid WCDBJNIColumnClassMethod(ofSchema, jlong column, WCDBJNIObjectOrStringParameter(schema))\n{\n    WCDBJNIBridgeStruct(CPPColumn, column);\n    WCDBJNICreateObjectOrStringCommonValue(schema, true);\n    WCDBColumnOfSchema2(columnStruct, schema_common);\n    WCDBJNITryReleaseStringInCommonValue(schema);\n}\n\njlong WCDBJNIColumnClassMethod(configAlias, jlong column, jstring alias)\n{\n    WCDBJNIBridgeStruct(CPPColumn, column);\n    WCDBJNIGetString(alias);\n    jlong ret = (jlong) WCDBColumnConfigAlias(columnStruct, aliasString).innerValue;\n    WCDBJNIReleaseString(alias);\n    return ret;\n}\n"
  },
  {
    "path": "src/java/main/src/main/cpp/winq/identifier/ColumnJNI.h",
    "content": "// Created by qiuwenchen on 2023/3/30.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"WCDBJNI.h\"\n\n#define WCDBJNIColumnFuncName(funcName) WCDBJNI(Column, funcName)\n#define WCDBJNIColumnObjectMethod(funcName, ...)                               \\\n    WCDBJNIObjectMethod(Column, funcName, __VA_ARGS__)\n#define WCDBJNIColumnClassMethodWithNoArg(funcName)                            \\\n    WCDBJNIClassMethodWithNoArg(Column, funcName)\n#define WCDBJNIColumnClassMethod(funcName, ...)                                \\\n    WCDBJNIClassMethod(Column, funcName, __VA_ARGS__)\n\njlong WCDBJNIColumnClassMethodWithNoArg(createAll);\n\njlong WCDBJNIColumnClassMethodWithNoArg(createRowId);\n\njlong WCDBJNIColumnClassMethod(createWithName, jstring name, jlong binding);\n\njlong WCDBJNIColumnClassMethod(copy, jlong column);\n\nvoid WCDBJNIColumnClassMethod(inTable, jlong column, jstring table);\n\nvoid WCDBJNIColumnClassMethod(ofSchema, jlong column, WCDBJNIObjectOrStringParameter(schema));\n\njlong WCDBJNIColumnClassMethod(configAlias, jlong column, jstring alias);\n"
  },
  {
    "path": "src/java/main/src/main/cpp/winq/identifier/CommonTableExpressionJNI.c",
    "content": "// Created by qiuwenchen on 2023/5/16.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"CommonTableExpressionJNI.h\"\n#include \"CommonTableExpressionBridge.h\"\n\njlong WCDBJNICommonTableExpressionClassMethod(createWithTable, jstring tableName)\n{\n    WCDBJNIGetStringCritical(tableName);\n    jlong ret = (jlong) WCDBCommonTableExpressionCreate(tableNameString).innerValue;\n    WCDBJNIReleaseStringCritical(tableName);\n    return ret;\n}\n\nvoid WCDBJNICommonTableExpressionClassMethod(configColumn, jlong self, jlong column)\n{\n    WCDBJNIBridgeStruct(CPPCommonTableExpression, self);\n    WCDBJNIBridgeStruct(CPPColumn, column);\n    WCDBCommonTableExpressionAddColumn(selfStruct, columnStruct);\n}\n\nvoid WCDBJNICommonTableExpressionClassMethod(configSelectStatement, jlong self, jlong select)\n{\n    WCDBJNIBridgeStruct(CPPCommonTableExpression, self);\n    WCDBJNIBridgeStruct(CPPStatementSelect, select);\n    WCDBCommonTableExpressionAsSelection(selfStruct, selectStruct);\n}"
  },
  {
    "path": "src/java/main/src/main/cpp/winq/identifier/CommonTableExpressionJNI.h",
    "content": "// Created by qiuwenchen on 2023/5/16.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"WCDBJNI.h\"\n\n#define WCDBJNICommonTableExpressionFuncName(funcName)                         \\\n    WCDBJNI(CommonTableExpression, funcName)\n#define WCDBJNICommonTableExpressionObjectMethod(funcName, ...)                \\\n    WCDBJNIObjectMethod(CommonTableExpression, funcName, __VA_ARGS__)\n#define WCDBJNICommonTableExpressionClassMethodWithNoArg(funcName)             \\\n    WCDBJNIClassMethodWithNoArg(CommonTableExpression, funcName)\n#define WCDBJNICommonTableExpressionClassMethod(funcName, ...)                 \\\n    WCDBJNIClassMethod(CommonTableExpression, funcName, __VA_ARGS__)\n\njlong WCDBJNICommonTableExpressionClassMethod(createWithTable, jstring tableName);\nvoid WCDBJNICommonTableExpressionClassMethod(configColumn, jlong self, jlong column);\nvoid WCDBJNICommonTableExpressionClassMethod(configSelectStatement, jlong self, jlong select);"
  },
  {
    "path": "src/java/main/src/main/cpp/winq/identifier/ExpressionJNI.c",
    "content": "// Created by qiuwenchen on 2023/3/31.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"ExpressionJNI.h\"\n#include \"ExpressionBridge.h\"\n\njlong WCDBJNIExpressionClassMethod(create, int type, jlong object)\n{\n    CPPCommonValue commonValue;\n    commonValue.type = type;\n    commonValue.intValue = object;\n    long ret = (jlong) WCDBExpressionCreate(commonValue).innerValue;\n    return ret;\n}\n\njlong WCDBJNIExpressionClassMethod(createWithFunction, jstring funcName)\n{\n    WCDBJNIGetStringCritical(funcName);\n    jlong ret = (jlong) WCDBExpressionCreateWithFunction(funcNameString).innerValue;\n    WCDBJNIReleaseStringCritical(funcName);\n    return ret;\n}\n\njlong WCDBJNIExpressionClassMethod(createWithExistStatement, jlong select)\n{\n    WCDBJNIBridgeStruct(CPPStatementSelect, select);\n    return (jlong) WCDBExpressionCreateWithExistStatement(selectStruct).innerValue;\n}\n\njlong WCDBJNIExpressionClassMethod(createWithNotExistStatement, jlong select)\n{\n    WCDBJNIBridgeStruct(CPPStatementSelect, select);\n    return (jlong) WCDBExpressionCreateWithNotExistStatement(selectStruct).innerValue;\n}\n\nvoid WCDBJNIExpressionClassMethod(setWithSchema,\n                                  jlong expression,\n                                  WCDBJNIObjectOrStringParameter(schema))\n{\n    WCDBJNIBridgeStruct(CPPExpression, expression);\n    WCDBJNICreateObjectOrStringCommonValue(schema, true);\n    WCDBExpressionSetWithSchema2(expressionStruct, schema_common);\n    WCDBJNITryReleaseStringInCommonValue(schema);\n}\n\nvoid WCDBJNIExpressionClassMethod(setArgument, jlong expression, WCDBJNICommonValueParameter(argument))\n{\n    WCDBJNIBridgeStruct(CPPExpression, expression);\n    WCDBJNICreateCommonValue(argument, true);\n    WCDBExpressionSetArgument(expressionStruct, argument_common);\n    WCDBJNITryReleaseStringInCommonValue(argument);\n}\n\nvoid WCDBJNIExpressionClassMethod(invoke, jlong expression)\n{\n    WCDBJNIBridgeStruct(CPPExpression, expression);\n    WCDBExpressionInvoke(expressionStruct);\n}\n\nvoid WCDBJNIExpressionClassMethod(invokeAll, jlong expression)\n{\n    WCDBJNIBridgeStruct(CPPExpression, expression);\n    WCDBExpressionInvokeAll(expressionStruct);\n}\n\nvoid WCDBJNIExpressionClassMethod(distinct, jlong expression)\n{\n    WCDBJNIBridgeStruct(CPPExpression, expression);\n    WCDBExpressionDistinct(expressionStruct);\n}\n\njlong WCDBJNIExpressionClassMethod(cast, WCDBJNIObjectOrStringParameter(expression))\n{\n    WCDBJNICreateObjectOrStringCommonValue(expression, true);\n    jlong ret = (jlong) WCDBExpressionCast2(expression_common).innerValue;\n    WCDBJNITryReleaseStringInCommonValue(expression);\n    return ret;\n}\n\nvoid WCDBJNIExpressionClassMethod(as, jlong expression, jint type)\n{\n    WCDBJNIBridgeStruct(CPPExpression, expression);\n    WCDBExpressionAs(expressionStruct, type);\n}\n\njlong WCDBJNIExpressionClassMethod(configAlias, jlong expression, jstring alias)\n{\n    WCDBJNIBridgeStruct(CPPExpression, expression);\n    WCDBJNIGetString(alias);\n    jlong ret = (jlong) WCDBExpressionConfigAlias(expressionStruct, aliasString).innerValue;\n    WCDBJNIReleaseString(alias);\n    return ret;\n}\n\njlong WCDBJNIExpressionClassMethod(caseWithExp, WCDBJNIObjectOrStringParameter(expression))\n{\n    if (expression_type == 0) {\n        return (jlong) WCDBExpressionCase().innerValue;\n    }\n    WCDBJNICreateObjectOrStringCommonValue(expression, true);\n    jlong ret = (jlong) WCDBExpressionCaseWithExp2(expression_common).innerValue;\n    WCDBJNITryReleaseStringInCommonValue(expression);\n    return ret;\n}\n\njlong WCDBJNIExpressionClassMethodWithNoArg(case_)\n{\n    return (jlong) WCDBExpressionCase().innerValue;\n}\n\nvoid WCDBJNIExpressionClassMethod(setWithWhenExp, jlong expression, WCDBJNICommonValueParameter(when))\n{\n    WCDBJNIBridgeStruct(CPPExpression, expression);\n    WCDBJNICreateCommonValue(when, true);\n    WCDBExpressionSetWithWhenExp2(expressionStruct, when_common);\n    WCDBJNITryReleaseStringInCommonValue(when);\n}\n\nvoid WCDBJNIExpressionClassMethod(setWithThenExp, jlong expression, WCDBJNICommonValueParameter(then))\n{\n    WCDBJNIBridgeStruct(CPPExpression, expression);\n    WCDBJNICreateCommonValue(then, true);\n    WCDBExpressionSetWithThenExp2(expressionStruct, then_common);\n    WCDBJNITryReleaseStringInCommonValue(then);\n}\n\nvoid WCDBJNIExpressionClassMethod(setWithElseExp, jlong expression, WCDBJNICommonValueParameter(else_))\n{\n    WCDBJNIBridgeStruct(CPPExpression, expression);\n    WCDBJNICreateCommonValue(else_, true);\n    WCDBExpressionSetWithElseExp2(expressionStruct, else__common);\n    WCDBJNITryReleaseStringInCommonValue(else_);\n}\n\nvoid WCDBJNIExpressionClassMethod(escapeWith, jlong expression, jstring content)\n{\n    WCDBJNIBridgeStruct(CPPExpression, expression);\n    WCDBJNIGetStringCritical(content);\n    WCDBExpressionEscapeWith2(expressionStruct, contentString);\n    WCDBJNIReleaseStringCritical(content);\n}\n\njlong WCDBJNIExpressionClassMethod(createWithWindowFunction, jstring funcName)\n{\n    WCDBJNIGetStringCritical(funcName);\n    jlong ret = (jlong) WCDBExpressionCreateWithWindowFunction(funcNameString).innerValue;\n    WCDBJNIReleaseStringCritical(funcName);\n    return ret;\n}\n\nvoid WCDBJNIExpressionClassMethod(filter, jlong expression, jlong condition)\n{\n    WCDBJNIBridgeStruct(CPPExpression, expression);\n    WCDBJNIBridgeStruct(CPPExpression, condition);\n    WCDBExpressionFilter(expressionStruct, conditionStruct);\n}\n\nvoid WCDBJNIExpressionClassMethod(overWindowDef, jlong expression, jlong def)\n{\n    WCDBJNIBridgeStruct(CPPExpression, expression);\n    WCDBJNIBridgeStruct(CPPWindowDef, def);\n    WCDBExpressionOverWindowDef(expressionStruct, defStruct);\n}\n\nvoid WCDBJNIExpressionClassMethod(overWindow, jlong expression, jstring window)\n{\n    WCDBJNIBridgeStruct(CPPExpression, expression);\n    WCDBJNIGetStringCritical(window);\n    WCDBExpressionOverWindow(expressionStruct, windowString);\n    WCDBJNIReleaseStringCritical(window);\n}\n"
  },
  {
    "path": "src/java/main/src/main/cpp/winq/identifier/ExpressionJNI.h",
    "content": "// Created by qiuwenchen on 2023/3/31.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"WCDBJNI.h\"\n\n#define WCDBJNIExpressionFuncName(funcName) WCDBJNI(Expression, funcName)\n#define WCDBJNIExpressionObjectMethod(funcName, ...)                           \\\n    WCDBJNIObjectMethod(Expression, funcName, __VA_ARGS__)\n#define WCDBJNIExpressionClassMethodWithNoArg(funcName)                        \\\n    WCDBJNIClassMethodWithNoArg(Expression, funcName)\n#define WCDBJNIExpressionClassMethod(funcName, ...)                            \\\n    WCDBJNIClassMethod(Expression, funcName, __VA_ARGS__)\n\njlong WCDBJNIExpressionClassMethod(create, int type, jlong object);\n\njlong WCDBJNIExpressionClassMethod(createWithFunction, jstring func);\njlong WCDBJNIExpressionClassMethod(createWithExistStatement, jlong select);\njlong WCDBJNIExpressionClassMethod(createWithNotExistStatement, jlong select);\n\nvoid WCDBJNIExpressionClassMethod(setWithSchema,\n                                  jlong expression,\n                                  WCDBJNIObjectOrStringParameter(schema));\nvoid WCDBJNIExpressionClassMethod(setArgument,\n                                  jlong expression,\n                                  WCDBJNICommonValueParameter(argument));\n\nvoid WCDBJNIExpressionClassMethod(invoke, jlong expression);\nvoid WCDBJNIExpressionClassMethod(invokeAll, jlong expression);\n\nvoid WCDBJNIExpressionClassMethod(distinct, jlong expression);\n\njlong WCDBJNIExpressionClassMethod(cast, WCDBJNIObjectOrStringParameter(expression));\nvoid WCDBJNIExpressionClassMethod(as, jlong expression, jint type);\n\njlong WCDBJNIExpressionClassMethod(configAlias, jlong expression, jstring alias);\n\njlong WCDBJNIExpressionClassMethod(caseWithExp, WCDBJNIObjectOrStringParameter(expression));\nvoid WCDBJNIExpressionClassMethod(setWithWhenExp,\n                                  jlong expression,\n                                  WCDBJNICommonValueParameter(when));\nvoid WCDBJNIExpressionClassMethod(setWithThenExp,\n                                  jlong expression,\n                                  WCDBJNICommonValueParameter(then));\nvoid WCDBJNIExpressionClassMethod(setWithElseExp,\n                                  jlong expression,\n                                  WCDBJNICommonValueParameter(else_));\n\nvoid WCDBJNIExpressionClassMethod(escapeWith, jlong expression, jstring content);\n\njlong WCDBJNIExpressionClassMethod(createWithWindowFunction, jstring func);\nvoid WCDBJNIExpressionClassMethod(filter, jlong expression, jlong condition);\nvoid WCDBJNIExpressionClassMethod(overWindowDef, jlong expression, jlong def);\nvoid WCDBJNIExpressionClassMethod(overWindow, jlong expression, jstring window);"
  },
  {
    "path": "src/java/main/src/main/cpp/winq/identifier/ExpressionOperableJNI.c",
    "content": "// Created by chenqiuwen on 2023/4/1.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"ExpressionOperableJNI.h\"\n#include \"ExpressionOperatableBridge.h\"\n#include <alloca.h>\n\njlong WCDBJNIExpressionOperableClassMethod(nullOperate, jint operandType, jlong operand, jboolean isNot)\n{\n    CPPCommonValue operand_common;\n    operand_common.type = operandType;\n    operand_common.intValue = operand;\n    return (jlong) WCDBExpressionNullOperate2(operand_common, isNot).innerValue;\n}\n\njlong WCDBJNIExpressionOperableClassMethod(binaryOperate,\n                                           jint leftType,\n                                           jlong left,\n                                           WCDBJNICommonValueParameter(right),\n                                           jint operatorType,\n                                           jboolean isNot)\n{\n    CPPCommonValue left_common;\n    left_common.type = leftType;\n    left_common.intValue = left;\n    WCDBJNICreateCommonValue(right, true);\n    jlong ret = (jlong) WCDBExpressionBinaryOperate2(\n                left_common, right_common, operatorType, isNot)\n                .innerValue;\n    WCDBJNITryReleaseStringInCommonValue(right);\n    return ret;\n}\n\njlong WCDBJNIExpressionOperableClassMethod(betweenOperate,\n                                           jint operandType,\n                                           jlong operand,\n                                           WCDBJNICommonValueParameter(left),\n                                           WCDBJNICommonValueParameter(right),\n                                           jboolean isNot)\n{\n    CPPCommonValue operand_common;\n    operand_common.type = operandType;\n    operand_common.intValue = operand;\n    WCDBJNICreateCommonValue(left, false);\n    WCDBJNICreateCommonValue(right, false);\n    jlong ret = (jlong) WCDBExpressionBetweenOperate2(\n                operand_common, left_common, right_common, isNot)\n                .innerValue;\n    WCDBJNITryReleaseStringInCommonValue(left);\n    WCDBJNITryReleaseStringInCommonValue(right);\n    return ret;\n}\n\njlong WCDBJNIExpressionOperableClassMethod(inOperate,\n                                           jint operandType,\n                                           jlong operand,\n                                           WCDBJNICommonArrayParameter(values),\n                                           jboolean isNot)\n{\n    CPPCommonValue operand_common;\n    operand_common.type = operandType;\n    operand_common.intValue = operand;\n    jlong ret = 0;\n    WCDBJNICreateCommonArrayWithAction(\n    values,\n    ret\n    = (jlong) WCDBExpressionInOperate(operand_common, values_commonArray, isNot).innerValue);\n    return ret;\n}\n\njlong WCDBJNIExpressionOperableClassMethod(\ninTableOperate, jint operandType, jlong operand, jstring table, jboolean isNot)\n{\n    CPPCommonValue operand_common;\n    operand_common.type = operandType;\n    operand_common.intValue = operand;\n    WCDBJNIGetStringCritical(table);\n    jlong ret\n    = (jlong) WCDBExpressionInTableOperate2(operand_common, tableString, isNot).innerValue;\n    WCDBJNIReleaseStringCritical(table);\n    return ret;\n}\n\njlong WCDBJNIExpressionOperableClassMethod(\ninFunctionOperate, jint operandType, jlong operand, jstring func, jboolean isNot)\n{\n    CPPCommonValue operand_common;\n    operand_common.type = operandType;\n    operand_common.intValue = operand;\n    WCDBJNIGetStringCritical(func);\n    jlong ret = (jlong) WCDBExpressionInFunctionOperate2(operand_common, funcString, isNot)\n                .innerValue;\n    WCDBJNIReleaseStringCritical(func);\n    return ret;\n}\n\njlong WCDBJNIExpressionOperableClassMethod(\ninSelectionOperate, jint operandType, jlong operand, jlong select, jboolean isNot)\n{\n    CPPCommonValue operand_common;\n    operand_common.type = operandType;\n    operand_common.intValue = operand;\n    WCDBJNIBridgeStruct(CPPStatementSelect, select);\n    return (jlong) WCDBExpressionInSelectionOperate2(operand_common, selectStruct, isNot)\n    .innerValue;\n}\n\njlong WCDBJNIExpressionOperableClassMethod(collateOperate, jint operandType, jlong operand, jstring collation)\n{\n    CPPCommonValue operand_common;\n    operand_common.type = operandType;\n    operand_common.intValue = operand;\n    WCDBJNIGetStringCritical(collation);\n    jlong ret\n    = (jlong) WCDBExpressionCollateOperate2(operand_common, collationString).innerValue;\n    WCDBJNIReleaseStringCritical(collation);\n    return ret;\n}"
  },
  {
    "path": "src/java/main/src/main/cpp/winq/identifier/ExpressionOperableJNI.h",
    "content": "// Created by chenqiuwen on 2023/4/1.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"WCDBJNI.h\"\n\n#define WCDBJNIExpressionOperableFuncName(funcName)                            \\\n    WCDBJNI(ExpressionOperable, funcName)\n#define WCDBJNIExpressionOperableObjectMethod(funcName, ...)                   \\\n    WCDBJNIObjectMethod(ExpressionOperable, funcName, __VA_ARGS__)\n#define WCDBJNIExpressionOperableClassMethodWithNoArg(funcName)                \\\n    WCDBJNIClassMethodWithNoArg(ExpressionOperable, funcName)\n#define WCDBJNIExpressionOperableClassMethod(funcName, ...)                    \\\n    WCDBJNIClassMethod(ExpressionOperable, funcName, __VA_ARGS__)\n\njlong WCDBJNIExpressionOperableClassMethod(nullOperate, jint operandType, jlong operand, jboolean isNot);\n\njlong WCDBJNIExpressionOperableClassMethod(binaryOperate,\n                                           jint leftType,\n                                           jlong left,\n                                           WCDBJNICommonValueParameter(right),\n                                           jint operatorType,\n                                           jboolean isNot);\n\njlong WCDBJNIExpressionOperableClassMethod(betweenOperate,\n                                           jint operandType,\n                                           jlong operand,\n                                           WCDBJNICommonValueParameter(left),\n                                           WCDBJNICommonValueParameter(right),\n                                           jboolean isNot);\n\njlong WCDBJNIExpressionOperableClassMethod(inOperate,\n                                           jint operandType,\n                                           jlong operand,\n                                           WCDBJNICommonArrayParameter(values),\n                                           jboolean isNot);\n\njlong WCDBJNIExpressionOperableClassMethod(\ninTableOperate, jint operandType, jlong operand, jstring table, jboolean isNot);\n\njlong WCDBJNIExpressionOperableClassMethod(\ninFunctionOperate, jint operandType, jlong operand, jstring func, jboolean isNot);\n\njlong WCDBJNIExpressionOperableClassMethod(\ninSelectionOperate, jint operandType, jlong operand, jlong select, jboolean isNot);\n\njlong WCDBJNIExpressionOperableClassMethod(collateOperate, jint operandType, jlong operand, jstring collation);"
  },
  {
    "path": "src/java/main/src/main/cpp/winq/identifier/ForeignKeyJNI.c",
    "content": "// Created by qiuwenchen on 2023/6/8.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"ForeignKeyJNI.h\"\n#include \"ForeignKeyBridge.h\"\n\njlong WCDBJNIForeignKeyClassMethodWithNoArg(createCppObject)\n{\n    return (jlong) WCDBForeignKeyCreate().innerValue;\n}\n\nvoid WCDBJNIForeignKeyClassMethod(configReferencesTable, jlong self, jstring table)\n{\n    WCDBJNIGetStringCritical(table);\n    WCDBJNIBridgeStruct(CPPForeignKey, self);\n    WCDBForeignKeyConfigReferencesTable(selfStruct, tableString);\n    WCDBJNIReleaseStringCritical(table);\n}\n\nvoid WCDBJNIForeignKeyClassMethod(configColumns,\n                                  jlong self,\n                                  WCDBJNIObjectOrStringArrayParameter(column))\n{\n    WCDBJNIBridgeStruct(CPPForeignKey, self);\n    WCDBJNICreateObjectOrStringArrayCriticalWithAction(\n    column, WCDBForeignKeyAddColumn2(selfStruct, column_commonArray);)\n}\n\nvoid WCDBJNIForeignKeyClassMethod(configOnDeleteAction, jlong self, jint action)\n{\n    WCDBJNIBridgeStruct(CPPForeignKey, self);\n    switch (action) {\n    case 0:\n        WCDBForeignKeyConfigOnDeleteSetNull(selfStruct);\n        break;\n    case 1:\n        WCDBForeignKeyConfigOnDeleteSetDefault(selfStruct);\n        break;\n    case 2:\n        WCDBForeignKeyConfigOnDeleteCascade(selfStruct);\n        break;\n    case 3:\n        WCDBForeignKeyConfigOnDeleteRestrict(selfStruct);\n        break;\n    case 4:\n        WCDBForeignKeyConfigOnDeleteNoAction(selfStruct);\n        break;\n    }\n}\n\nvoid WCDBJNIForeignKeyClassMethod(configOnUpdateAction, jlong self, jint action)\n{\n    WCDBJNIBridgeStruct(CPPForeignKey, self);\n    switch (action) {\n    case 0:\n        WCDBForeignKeyConfigOnUpdateSetNull(selfStruct);\n        break;\n    case 1:\n        WCDBForeignKeyConfigOnUpdateSetDefault(selfStruct);\n        break;\n    case 2:\n        WCDBForeignKeyConfigOnUpdateCascade(selfStruct);\n        break;\n    case 3:\n        WCDBForeignKeyConfigOnUpdateRestrict(selfStruct);\n        break;\n    case 4:\n        WCDBForeignKeyConfigOnUpdateNoAction(selfStruct);\n        break;\n    }\n}\n\nvoid WCDBJNIForeignKeyClassMethod(configMatch, jlong self, jint match)\n{\n    WCDBJNIBridgeStruct(CPPForeignKey, self);\n    WCDBForeignKeyConfigMatch(selfStruct, match);\n}\n\nvoid WCDBJNIForeignKeyClassMethod(configDeferrable, jlong self, jint type)\n{\n    WCDBJNIBridgeStruct(CPPForeignKey, self);\n    switch (type) {\n    case 0:\n        WCDBForeignKeyConfigDeferrable(selfStruct);\n        break;\n    case 1:\n        WCDBForeignKeyConfigDeferrableInitiallyDeferred(selfStruct);\n        break;\n    case 2:\n        WCDBForeignKeyConfigDeferrableInitiallyImmediate(selfStruct);\n        break;\n    }\n}\n\nvoid WCDBJNIForeignKeyClassMethod(configNotDeferrable, jlong self, jint type)\n{\n    WCDBJNIBridgeStruct(CPPForeignKey, self);\n    switch (type) {\n    case 0:\n        WCDBForeignKeyConfigNotDeferrable(selfStruct);\n        break;\n    case 1:\n        WCDBForeignKeyConfigNotDeferrableInitiallyDeferred(selfStruct);\n        break;\n    case 2:\n        WCDBForeignKeyConfigNotDeferrableInitiallyImmediate(selfStruct);\n        break;\n    }\n}"
  },
  {
    "path": "src/java/main/src/main/cpp/winq/identifier/ForeignKeyJNI.h",
    "content": "// Created by qiuwenchen on 2023/6/8.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"WCDBJNI.h\"\n\n#define WCDBJNIForeignKeyFuncName(funcName) WCDBJNI(ForeignKey, funcName)\n#define WCDBJNIForeignKeyObjectMethod(funcName, ...)                           \\\n    WCDBJNIObjectMethod(ForeignKey, funcName, __VA_ARGS__)\n#define WCDBJNIForeignKeyClassMethodWithNoArg(funcName)                        \\\n    WCDBJNIClassMethodWithNoArg(ForeignKey, funcName)\n#define WCDBJNIForeignKeyClassMethod(funcName, ...)                            \\\n    WCDBJNIClassMethod(ForeignKey, funcName, __VA_ARGS__)\n\njlong WCDBJNIForeignKeyClassMethodWithNoArg(createCppObject);\n\nvoid WCDBJNIForeignKeyClassMethod(configReferencesTable, jlong self, jstring table);\nvoid WCDBJNIForeignKeyClassMethod(configColumns,\n                                  jlong self,\n                                  WCDBJNIObjectOrStringArrayParameter(column));\n\nvoid WCDBJNIForeignKeyClassMethod(configOnDeleteAction, jlong self, jint action);\n\nvoid WCDBJNIForeignKeyClassMethod(configOnUpdateAction, jlong self, jint action);\n\nvoid WCDBJNIForeignKeyClassMethod(configMatch, jlong self, jint match);\n\nvoid WCDBJNIForeignKeyClassMethod(configDeferrable, jlong self, jint type);\nvoid WCDBJNIForeignKeyClassMethod(configNotDeferrable, jlong self, jint type);\n"
  },
  {
    "path": "src/java/main/src/main/cpp/winq/identifier/FrameSpecJNI.c",
    "content": "// Created by qiuwenchen on 2023/6/9.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"FrameSpecJNI.h\"\n#include \"FrameSpecBridge.h\"\n\njlong WCDBJNIFrameSpecClassMethodWithNoArg(createCppObj)\n{\n    return (jlong) WCDBFrameSpecCreate().innerValue;\n}\n\nvoid WCDBJNIFrameSpecClassMethod(configRange, jlong self)\n{\n    WCDBJNIBridgeStruct(CPPFrameSpec, self);\n    WCDBFrameSpecConfigRange(selfStruct);\n}\n\nvoid WCDBJNIFrameSpecClassMethod(configRows, jlong self)\n{\n    WCDBJNIBridgeStruct(CPPFrameSpec, self);\n    WCDBFrameSpecConfigRows(selfStruct);\n}\n\nvoid WCDBJNIFrameSpecClassMethod(configUnboundedPreceding, jlong self)\n{\n    WCDBJNIBridgeStruct(CPPFrameSpec, self);\n    WCDBFrameSpecConfigUnboundedPreceding(selfStruct);\n}\n\nvoid WCDBJNIFrameSpecClassMethod(configPreceding,\n                                 jlong self,\n                                 WCDBJNIObjectOrIntegerParameter(expression))\n{\n    WCDBJNIBridgeStruct(CPPFrameSpec, self);\n    WCDBJNICreateObjectOrIntegerCommonValue(expression);\n    WCDBFrameSpecConfigPreceding2(selfStruct, expression_common);\n}\n\nvoid WCDBJNIFrameSpecClassMethod(configCurrentRow, jlong self)\n{\n    WCDBJNIBridgeStruct(CPPFrameSpec, self);\n    WCDBFrameSpecConfigCurrentRow(selfStruct);\n}\n\nvoid WCDBJNIFrameSpecClassMethod(configBetweenUnboundedPreceding, jlong self)\n{\n    WCDBJNIBridgeStruct(CPPFrameSpec, self);\n    WCDBFrameSpecConfigBetweenUnboundedPreceding(selfStruct);\n}\n\nvoid WCDBJNIFrameSpecClassMethod(configBetweenPreceding,\n                                 jlong self,\n                                 WCDBJNIObjectOrIntegerParameter(expression))\n{\n    WCDBJNIBridgeStruct(CPPFrameSpec, self);\n    WCDBJNICreateObjectOrIntegerCommonValue(expression);\n    WCDBFrameSpecConfigBetweenPreceding2(selfStruct, expression_common);\n}\n\nvoid WCDBJNIFrameSpecClassMethod(configBetweenCurrentRow, jlong self)\n{\n    WCDBJNIBridgeStruct(CPPFrameSpec, self);\n    WCDBFrameSpecConfigBetweenCurrentRow(selfStruct);\n}\n\nvoid WCDBJNIFrameSpecClassMethod(configBetweenFollowing,\n                                 jlong self,\n                                 WCDBJNIObjectOrIntegerParameter(expression))\n{\n    WCDBJNIBridgeStruct(CPPFrameSpec, self);\n    WCDBJNICreateObjectOrIntegerCommonValue(expression);\n    WCDBFrameSpecConfigBetweenFollowing2(selfStruct, expression_common);\n}\n\nvoid WCDBJNIFrameSpecClassMethod(configAndPreceding,\n                                 jlong self,\n                                 WCDBJNIObjectOrIntegerParameter(expression))\n{\n    WCDBJNIBridgeStruct(CPPFrameSpec, self);\n    WCDBJNICreateObjectOrIntegerCommonValue(expression);\n    WCDBFrameSpecConfigAndPreceding2(selfStruct, expression_common);\n}\n\nvoid WCDBJNIFrameSpecClassMethod(configAndCurrentRow, jlong self)\n{\n    WCDBJNIBridgeStruct(CPPFrameSpec, self);\n    WCDBFrameSpecConfigAndCurrentRow(selfStruct);\n}\n\nvoid WCDBJNIFrameSpecClassMethod(configAndFollowing,\n                                 jlong self,\n                                 WCDBJNIObjectOrIntegerParameter(expression))\n{\n    WCDBJNIBridgeStruct(CPPFrameSpec, self);\n    WCDBJNICreateObjectOrIntegerCommonValue(expression);\n    WCDBFrameSpecConfigAndFollowing2(selfStruct, expression_common);\n}\n\nvoid WCDBJNIFrameSpecClassMethod(configAndUnboundedFollowing, jlong self)\n{\n    WCDBJNIBridgeStruct(CPPFrameSpec, self);\n    WCDBFrameSpecConfigAndUnboundedFollowing(selfStruct);\n}\n"
  },
  {
    "path": "src/java/main/src/main/cpp/winq/identifier/FrameSpecJNI.h",
    "content": "// Created by qiuwenchen on 2023/6/9.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"WCDBJNI.h\"\n\n#define WCDBJNIFrameSpecFuncName(funcName) WCDBJNI(FrameSpec, funcName)\n#define WCDBJNIFrameSpecObjectMethod(funcName, ...)                            \\\n    WCDBJNIObjectMethod(FrameSpec, funcName, __VA_ARGS__)\n#define WCDBJNIFrameSpecClassMethodWithNoArg(funcName)                         \\\n    WCDBJNIClassMethodWithNoArg(FrameSpec, funcName)\n#define WCDBJNIFrameSpecClassMethod(funcName, ...)                             \\\n    WCDBJNIClassMethod(FrameSpec, funcName, __VA_ARGS__)\n\njlong WCDBJNIFrameSpecClassMethodWithNoArg(createCppObj);\nvoid WCDBJNIFrameSpecClassMethod(configRange, jlong self);\nvoid WCDBJNIFrameSpecClassMethod(configRows, jlong self);\nvoid WCDBJNIFrameSpecClassMethod(configUnboundedPreceding, jlong self);\nvoid WCDBJNIFrameSpecClassMethod(configPreceding,\n                                 jlong self,\n                                 WCDBJNIObjectOrIntegerParameter(expression));\nvoid WCDBJNIFrameSpecClassMethod(configCurrentRow, jlong self);\nvoid WCDBJNIFrameSpecClassMethod(configBetweenUnboundedPreceding, jlong self);\nvoid WCDBJNIFrameSpecClassMethod(configBetweenPreceding,\n                                 jlong self,\n                                 WCDBJNIObjectOrIntegerParameter(expression));\nvoid WCDBJNIFrameSpecClassMethod(configBetweenCurrentRow, jlong self);\nvoid WCDBJNIFrameSpecClassMethod(configBetweenFollowing,\n                                 jlong self,\n                                 WCDBJNIObjectOrIntegerParameter(expression));\nvoid WCDBJNIFrameSpecClassMethod(configAndPreceding,\n                                 jlong self,\n                                 WCDBJNIObjectOrIntegerParameter(expression));\nvoid WCDBJNIFrameSpecClassMethod(configAndCurrentRow, jlong self);\nvoid WCDBJNIFrameSpecClassMethod(configAndFollowing,\n                                 jlong self,\n                                 WCDBJNIObjectOrIntegerParameter(expression));\nvoid WCDBJNIFrameSpecClassMethod(configAndUnboundedFollowing, jlong self);\n"
  },
  {
    "path": "src/java/main/src/main/cpp/winq/identifier/IndexedColumnJNI.c",
    "content": "// Created by qiuwenchen on 2023/4/7.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"IndexedColumnJNI.h\"\n#include \"IndexedColumnBridge.h\"\n\njlong WCDBJNIIndexedColumnClassMethod(create, WCDBJNIObjectOrStringParameter(column))\n{\n    WCDBJNICreateObjectOrStringCommonValue(column, true);\n    jlong ret = (jlong) WCDBIndexedColumnCreate(column_common).innerValue;\n    WCDBJNITryReleaseStringInCommonValue(column);\n    return ret;\n}\n\nvoid WCDBJNIIndexedColumnClassMethod(configCollation, jlong indexedColumn, jstring collation)\n{\n    WCDBJNIBridgeStruct(CPPIndexedColumn, indexedColumn);\n    WCDBJNIGetStringCritical(collation);\n    WCDBIndexedColumnConfigCollation(indexedColumnStruct, collationString);\n    WCDBJNIReleaseStringCritical(collation);\n}\n\nvoid WCDBJNIIndexedColumnClassMethod(configOrder, jlong indexedColumn, jint order)\n{\n    WCDBJNIBridgeStruct(CPPIndexedColumn, indexedColumn);\n    WCDBIndexedColumnConfigOrder(indexedColumnStruct, order);\n}"
  },
  {
    "path": "src/java/main/src/main/cpp/winq/identifier/IndexedColumnJNI.h",
    "content": "// Created by qiuwenchen on 2023/4/7.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"WCDBJNI.h\"\n\n#define WCDBJNIIndexedColumnFuncName(funcName) WCDBJNI(IndexedColumn, funcName)\n#define WCDBJNIIndexedColumnObjectMethod(funcName, ...)                        \\\n    WCDBJNIObjectMethod(IndexedColumn, funcName, __VA_ARGS__)\n#define WCDBJNIIndexedColumnClassMethodWithNoArg(funcName)                     \\\n    WCDBJNIClassMethodWithNoArg(IndexedColumn, funcName)\n#define WCDBJNIIndexedColumnClassMethod(funcName, ...)                         \\\n    WCDBJNIClassMethod(IndexedColumn, funcName, __VA_ARGS__)\n\njlong WCDBJNIIndexedColumnClassMethod(create, WCDBJNIObjectOrStringParameter(column));\n\nvoid WCDBJNIIndexedColumnClassMethod(configCollation, jlong indexedColumn, jstring collation);\n\nvoid WCDBJNIIndexedColumnClassMethod(configOrder, jlong indexedColumn, jint order);\n"
  },
  {
    "path": "src/java/main/src/main/cpp/winq/identifier/JoinJNI.c",
    "content": "// Created by qiuwenchen on 2023/6/9.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"JoinJNI.h\"\n#include \"JoinBridge.h\"\n\njlong WCDBJNIJoinClassMethod(createCppObj, WCDBJNIObjectOrStringParameter(query))\n{\n    WCDBJNICreateObjectOrStringCommonValue(query, true);\n    jlong ret = (jlong) WCDBJoinCreateWithTableOrSubquery2(query_common).innerValue;\n    WCDBJNITryReleaseStringInCommonValue(query);\n    return ret;\n}\n\nvoid WCDBJNIJoinClassMethod(configWith, jlong join, WCDBJNIObjectOrStringParameter(query))\n{\n    WCDBJNIBridgeStruct(CPPJoin, join);\n    WCDBJNICreateObjectOrStringCommonValue(query, true);\n    WCDBJoinWith2(joinStruct, query_common);\n    WCDBJNITryReleaseStringInCommonValue(query);\n}\n\nvoid WCDBJNIJoinClassMethod(configWithJoin, jlong join, WCDBJNIObjectOrStringParameter(query))\n{\n    WCDBJNIBridgeStruct(CPPJoin, join);\n    WCDBJNICreateObjectOrStringCommonValue(query, true);\n    WCDBJoinWithJoin2(joinStruct, query_common);\n    WCDBJNITryReleaseStringInCommonValue(query);\n}\n\nvoid WCDBJNIJoinClassMethod(configWithLeftOuterJoin, jlong join, WCDBJNIObjectOrStringParameter(query))\n{\n    WCDBJNIBridgeStruct(CPPJoin, join);\n    WCDBJNICreateObjectOrStringCommonValue(query, true);\n    WCDBJoinWithLeftOuterJoin2(joinStruct, query_common);\n    WCDBJNITryReleaseStringInCommonValue(query);\n}\n\nvoid WCDBJNIJoinClassMethod(configWithLeftJoin, jlong join, WCDBJNIObjectOrStringParameter(query))\n{\n    WCDBJNIBridgeStruct(CPPJoin, join);\n    WCDBJNICreateObjectOrStringCommonValue(query, true);\n    WCDBJoinWithLeftJoin2(joinStruct, query_common);\n    WCDBJNITryReleaseStringInCommonValue(query);\n}\n\nvoid WCDBJNIJoinClassMethod(configWithInnerJoin, jlong join, WCDBJNIObjectOrStringParameter(query))\n{\n    WCDBJNIBridgeStruct(CPPJoin, join);\n    WCDBJNICreateObjectOrStringCommonValue(query, true);\n    WCDBJoinWithInnerJoin2(joinStruct, query_common);\n    WCDBJNITryReleaseStringInCommonValue(query);\n}\n\nvoid WCDBJNIJoinClassMethod(configWithCrossJoin, jlong join, WCDBJNIObjectOrStringParameter(query))\n{\n    WCDBJNIBridgeStruct(CPPJoin, join);\n    WCDBJNICreateObjectOrStringCommonValue(query, true);\n    WCDBJoinWithCrossJoin2(joinStruct, query_common);\n    WCDBJNITryReleaseStringInCommonValue(query);\n}\n\nvoid WCDBJNIJoinClassMethod(configWithNaturalJoin, jlong join, WCDBJNIObjectOrStringParameter(query))\n{\n    WCDBJNIBridgeStruct(CPPJoin, join);\n    WCDBJNICreateObjectOrStringCommonValue(query, true);\n    WCDBJoinWithNaturalJoin2(joinStruct, query_common);\n    WCDBJNITryReleaseStringInCommonValue(query);\n}\n\nvoid WCDBJNIJoinClassMethod(configWithNaturalLeftOuterJoin,\n                            jlong join,\n                            WCDBJNIObjectOrStringParameter(query))\n{\n    WCDBJNIBridgeStruct(CPPJoin, join);\n    WCDBJNICreateObjectOrStringCommonValue(query, true);\n    WCDBJoinWithNaturalLeftOuterJoin2(joinStruct, query_common);\n    WCDBJNITryReleaseStringInCommonValue(query);\n}\n\nvoid WCDBJNIJoinClassMethod(configWithNaturalLeftJoin,\n                            jlong join,\n                            WCDBJNIObjectOrStringParameter(query))\n{\n    WCDBJNIBridgeStruct(CPPJoin, join);\n    WCDBJNICreateObjectOrStringCommonValue(query, true);\n    WCDBJoinWithNaturalLeftJoin2(joinStruct, query_common);\n    WCDBJNITryReleaseStringInCommonValue(query);\n}\n\nvoid WCDBJNIJoinClassMethod(configWithNaturalInnerJoin,\n                            jlong join,\n                            WCDBJNIObjectOrStringParameter(query))\n{\n    WCDBJNIBridgeStruct(CPPJoin, join);\n    WCDBJNICreateObjectOrStringCommonValue(query, true);\n    WCDBJoinWithNaturalInnerJoin2(joinStruct, query_common);\n    WCDBJNITryReleaseStringInCommonValue(query);\n}\n\nvoid WCDBJNIJoinClassMethod(configWithNaturalCrossJoin,\n                            jlong join,\n                            WCDBJNIObjectOrStringParameter(query))\n{\n    WCDBJNIBridgeStruct(CPPJoin, join);\n    WCDBJNICreateObjectOrStringCommonValue(query, true);\n    WCDBJoinWithNaturalCrossJoin2(joinStruct, query_common);\n    WCDBJNITryReleaseStringInCommonValue(query);\n}\n\nvoid WCDBJNIJoinClassMethod(configOn, jlong join, jlong expression)\n{\n    WCDBJNIBridgeStruct(CPPJoin, join);\n    WCDBJNIBridgeStruct(CPPExpression, expression);\n    WCDBJoinConfigOn(joinStruct, expressionStruct);\n}\n\nvoid WCDBJNIJoinClassMethod(configUsingColumn,\n                            jlong join,\n                            WCDBJNIObjectOrStringArrayParameter(columns))\n{\n    WCDBJNIBridgeStruct(CPPJoin, join);\n    WCDBJNICreateObjectOrStringArrayCriticalWithAction(\n    columns, WCDBJoinConfigUsingColumn2(joinStruct, columns_commonArray));\n}"
  },
  {
    "path": "src/java/main/src/main/cpp/winq/identifier/JoinJNI.h",
    "content": "// Created by qiuwenchen on 2023/6/9.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"WCDBJNI.h\"\n\n#define WCDBJNIJoinFuncName(funcName) WCDBJNI(Join, funcName)\n#define WCDBJNIJoinObjectMethod(funcName, ...)                                 \\\n    WCDBJNIObjectMethod(Join, funcName, __VA_ARGS__)\n#define WCDBJNIJoinClassMethodWithNoArg(funcName)                              \\\n    WCDBJNIClassMethodWithNoArg(Join, funcName)\n#define WCDBJNIJoinClassMethod(funcName, ...)                                  \\\n    WCDBJNIClassMethod(Join, funcName, __VA_ARGS__)\n\njlong WCDBJNIJoinClassMethod(createCppObj, WCDBJNIObjectOrStringParameter(query));\nvoid WCDBJNIJoinClassMethod(configWith, jlong join, WCDBJNIObjectOrStringParameter(query));\nvoid WCDBJNIJoinClassMethod(configWithJoin, jlong join, WCDBJNIObjectOrStringParameter(query));\nvoid WCDBJNIJoinClassMethod(configWithLeftOuterJoin,\n                            jlong join,\n                            WCDBJNIObjectOrStringParameter(query));\nvoid WCDBJNIJoinClassMethod(configWithLeftJoin, jlong join, WCDBJNIObjectOrStringParameter(query));\nvoid WCDBJNIJoinClassMethod(configWithInnerJoin, jlong join, WCDBJNIObjectOrStringParameter(query));\nvoid WCDBJNIJoinClassMethod(configWithCrossJoin, jlong join, WCDBJNIObjectOrStringParameter(query));\nvoid WCDBJNIJoinClassMethod(configWithNaturalJoin,\n                            jlong join,\n                            WCDBJNIObjectOrStringParameter(query));\nvoid WCDBJNIJoinClassMethod(configWithNaturalLeftOuterJoin,\n                            jlong join,\n                            WCDBJNIObjectOrStringParameter(query));\nvoid WCDBJNIJoinClassMethod(configWithNaturalLeftJoin,\n                            jlong join,\n                            WCDBJNIObjectOrStringParameter(query));\nvoid WCDBJNIJoinClassMethod(configWithNaturalInnerJoin,\n                            jlong join,\n                            WCDBJNIObjectOrStringParameter(query));\nvoid WCDBJNIJoinClassMethod(configWithNaturalCrossJoin,\n                            jlong join,\n                            WCDBJNIObjectOrStringParameter(query));\nvoid WCDBJNIJoinClassMethod(configOn, jlong join, jlong expression);\nvoid WCDBJNIJoinClassMethod(configUsingColumn,\n                            jlong join,\n                            WCDBJNIObjectOrStringArrayParameter(columns));"
  },
  {
    "path": "src/java/main/src/main/cpp/winq/identifier/LiteralValueJNI.c",
    "content": "// Created by qiuwenchen on 2023/3/30.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"LiteralValueJNI.h\"\n#include \"LiteralValueBridge.h\"\n\njlong WCDBJNILiteralValueClassMethod(create, WCDBJNICommonValueParameter(value))\n{\n    WCDBJNICreateCommonValue(value, true);\n    jlong ret = (jlong) WCDBLiteralValueCreate(value_common).innerValue;\n    WCDBJNITryReleaseStringInCommonValue(value);\n    return ret;\n}\n\njlong WCDBJNILiteralValueClassMethod(createWithInt64, jlong value)\n{\n    return (jlong) WCDBLiteralValueCreateWithInt64(value).innerValue;\n}\n\njlong WCDBJNILiteralValueClassMethod(createWithBool, jboolean value)\n{\n    return (jlong) WCDBLiteralValueCreateWithBool(value).innerValue;\n}\n\njlong WCDBJNILiteralValueClassMethod(createWithDouble, jdouble value)\n{\n    return (jlong) WCDBLiteralValueCreateWithDouble(value).innerValue;\n}\n\njlong WCDBJNILiteralValueClassMethod(createWithString, jstring value)\n{\n    WCDBJNIGetStringCritical(value);\n    jlong result = (jlong) WCDBLiteralValueCreateWithString(valueString).innerValue;\n    WCDBJNIReleaseStringCritical(value);\n    return result;\n}\n\njlong WCDBJNILiteralValueClassMethodWithNoArg(createWithCurrentTime)\n{\n    return (jlong) WCDBLiteralValueCreateWithCurrentTime().innerValue;\n}\n\njlong WCDBJNILiteralValueClassMethodWithNoArg(createWithCurrentDate)\n{\n    return (jlong) WCDBLiteralValueCreateWithCurrentDate().innerValue;\n}\n\njlong WCDBJNILiteralValueClassMethodWithNoArg(createWithCurrentTimestamp)\n{\n    return (jlong) WCDBLiteralValueCreateWithCurrentTimestamp().innerValue;\n}"
  },
  {
    "path": "src/java/main/src/main/cpp/winq/identifier/LiteralValueJNI.h",
    "content": "// Created by qiuwenchen on 2023/3/30.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"WCDBJNI.h\"\n\n#define WCDBJNILiteralValueFuncName(funcName) WCDBJNI(LiteralValue, funcName)\n#define WCDBJNILiteralValueObjectMethod(funcName, ...)                         \\\n    WCDBJNIObjectMethod(LiteralValue, funcName, __VA_ARGS__)\n#define WCDBJNILiteralValueClassMethodWithNoArg(funcName)                      \\\n    WCDBJNIClassMethodWithNoArg(LiteralValue, funcName)\n#define WCDBJNILiteralValueClassMethod(funcName, ...)                          \\\n    WCDBJNIClassMethod(LiteralValue, funcName, __VA_ARGS__)\n\njlong WCDBJNILiteralValueClassMethod(create, WCDBJNICommonValueParameter(value));\n\njlong WCDBJNILiteralValueClassMethodWithNoArg(createWithCurrentTime);\n\njlong WCDBJNILiteralValueClassMethodWithNoArg(createWithCurrentDate);\n\njlong WCDBJNILiteralValueClassMethodWithNoArg(createWithCurrentTimestamp);\n"
  },
  {
    "path": "src/java/main/src/main/cpp/winq/identifier/OrderingTermJNI.c",
    "content": "// Created by chenqiuwen on 2023/4/6.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"OrderingTermJNI.h\"\n#include \"OrderingTermBridge.h\"\n\njlong WCDBJNIOrderingTermClassMethod(create, jint type, jlong expression)\n{\n    CPPCommonValue common_expression;\n    common_expression.type = type;\n    common_expression.intValue = expression;\n    return (jlong) WCDBOrderingTermCreate2(common_expression).innerValue;\n}\n\nvoid WCDBJNIOrderingTermClassMethod(configCollation, jlong object, jstring collation)\n{\n    WCDBJNIBridgeStruct(CPPOrderingTerm, object);\n    WCDBJNIGetStringCritical(collation);\n    WCDBOrderingTermConfigCollation(objectStruct, collationString);\n    WCDBJNIReleaseStringCritical(collation);\n}\n\nvoid WCDBJNIOrderingTermClassMethod(configOrder, jlong object, jint order)\n{\n    WCDBJNIBridgeStruct(CPPOrderingTerm, object);\n    WCDBOrderingTermConfigOrder(objectStruct, order);\n}"
  },
  {
    "path": "src/java/main/src/main/cpp/winq/identifier/OrderingTermJNI.h",
    "content": "// Created by chenqiuwen on 2023/4/6.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n#include \"WCDBJNI.h\"\n\n#define WCDBJNIOrderingTermFuncName(funcName) WCDBJNI(OrderingTerm, funcName)\n#define WCDBJNIOrderingTermObjectMethod(funcName, ...)                         \\\n    WCDBJNIObjectMethod(OrderingTerm, funcName, __VA_ARGS__)\n#define WCDBJNIOrderingTermClassMethodWithNoArg(funcName)                      \\\n    WCDBJNIClassMethodWithNoArg(OrderingTerm, funcName)\n#define WCDBJNIOrderingTermClassMethod(funcName, ...)                          \\\n    WCDBJNIClassMethod(OrderingTerm, funcName, __VA_ARGS__)\n\njlong WCDBJNIOrderingTermClassMethod(create, jint type, jlong expression);\n\nvoid WCDBJNIOrderingTermClassMethod(configCollation, jlong object, jstring collation);\n\nvoid WCDBJNIOrderingTermClassMethod(configOrder, jlong object, jint order);\n"
  },
  {
    "path": "src/java/main/src/main/cpp/winq/identifier/PragmaJNI.c",
    "content": "// Created by chenqiuwen on 2023/4/9.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"PragmaJNI.h\"\n#include \"PragmaBridge.h\"\n\njlong WCDBJNIPragmaClassMethod(create, jstring name)\n{\n    WCDBJNIGetStringCritical(name);\n    jlong ret = (jlong) WCDBPragmaCreateWithName(nameString).innerValue;\n    WCDBJNIReleaseStringCritical(name);\n    return ret;\n}\n"
  },
  {
    "path": "src/java/main/src/main/cpp/winq/identifier/PragmaJNI.h",
    "content": "// Created by chenqiuwen on 2023/4/9.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"WCDBJNI.h\"\n\n#define WCDBJNIPragmaFuncName(funcName) WCDBJNI(Pragma, funcName)\n#define WCDBJNIPragmaObjectMethod(funcName, ...)                               \\\n    WCDBJNIObjectMethod(Pragma, funcName, __VA_ARGS__)\n#define WCDBJNIPragmaClassMethodWithNoArg(funcName)                            \\\n    WCDBJNIClassMethodWithNoArg(Pragma, funcName)\n#define WCDBJNIPragmaClassMethod(funcName, ...)                                \\\n    WCDBJNIClassMethod(Pragma, funcName, __VA_ARGS__)\n\njlong WCDBJNIPragmaClassMethod(create, jstring name);"
  },
  {
    "path": "src/java/main/src/main/cpp/winq/identifier/QualifiedTableJNI.c",
    "content": "// Created by chenqiuwen on 2023/4/8.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"QualifiedTableJNI.h\"\n#include \"QualifiedTableBridge.h\"\n\njlong WCDBJNIQualifiedTableClassMethod(create, jstring tableName)\n{\n    WCDBJNIGetStringCritical(tableName);\n    jlong ret = (jlong) WCDBQualifiedTableCreateWithTable(tableNameString).innerValue;\n    WCDBJNIReleaseStringCritical(tableName);\n    return ret;\n}\n\nvoid WCDBJNIQualifiedTableClassMethod(configSchema, jlong self, WCDBJNIObjectOrStringParameter(schema))\n{\n    WCDBJNIBridgeStruct(CPPQualifiedTable, self);\n    WCDBJNICreateObjectOrStringCommonValue(schema, true);\n    WCDBQualifiedTableConfigSchema2(selfStruct, schema_common);\n    WCDBJNITryReleaseStringInCommonValue(schema);\n}\n\nvoid WCDBJNIQualifiedTableClassMethod(configAlias, jlong self, jstring alias)\n{\n    WCDBJNIBridgeStruct(CPPQualifiedTable, self);\n    WCDBJNIGetStringCritical(alias);\n    WCDBQualifiedTableConfigAliasName(selfStruct, aliasString);\n    WCDBJNIReleaseStringCritical(alias);\n}\n\nvoid WCDBJNIQualifiedTableClassMethod(configIndex, jlong self, jstring index)\n{\n    WCDBJNIBridgeStruct(CPPQualifiedTable, self);\n    WCDBJNIGetStringCritical(index);\n    WCDBQualifiedTableConfigIndexName(selfStruct, indexString);\n    WCDBJNIReleaseStringCritical(index);\n}\n\nvoid WCDBJNIQualifiedTableClassMethod(configNotIndexed, jlong self)\n{\n    WCDBJNIBridgeStruct(CPPQualifiedTable, self);\n    WCDBQualifiedTableConfigNoIndexed(selfStruct);\n}"
  },
  {
    "path": "src/java/main/src/main/cpp/winq/identifier/QualifiedTableJNI.h",
    "content": "// Created by chenqiuwen on 2023/4/8.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"WCDBJNI.h\"\n\n#define WCDBJNIQualifiedTableFuncName(funcName)                                \\\n    WCDBJNI(QualifiedTable, funcName)\n#define WCDBJNIQualifiedTableObjectMethod(funcName, ...)                       \\\n    WCDBJNIObjectMethod(QualifiedTable, funcName, __VA_ARGS__)\n#define WCDBJNIQualifiedTableClassMethodWithNoArg(funcName)                    \\\n    WCDBJNIClassMethodWithNoArg(QualifiedTable, funcName)\n#define WCDBJNIQualifiedTableClassMethod(funcName, ...)                        \\\n    WCDBJNIClassMethod(QualifiedTable, funcName, __VA_ARGS__)\n\njlong WCDBJNIQualifiedTableClassMethod(create, jstring tableName);\nvoid WCDBJNIQualifiedTableClassMethod(configSchema,\n                                      jlong self,\n                                      WCDBJNIObjectOrStringParameter(schema));\nvoid WCDBJNIQualifiedTableClassMethod(configAlias, jlong self, jstring alias);\nvoid WCDBJNIQualifiedTableClassMethod(configIndex, jlong self, jstring index);\nvoid WCDBJNIQualifiedTableClassMethod(configNotIndexed, jlong self);\n"
  },
  {
    "path": "src/java/main/src/main/cpp/winq/identifier/RaiseFunctionJNI.c",
    "content": "// Created by qiuwenchen on 2023/6/9.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"RaiseFunctionJNI.h\"\n#include \"RaiseFunctionBridge.h\"\n\njlong WCDBJNIRaiseFunctionClassMethodWithNoArg(createCppObj)\n{\n    return (jlong) WCDBRaiseFunctionCreate().innerValue;\n}\n\nvoid WCDBJNIRaiseFunctionClassMethod(setAction, jlong self, jint action, jstring errMsg)\n{\n    WCDBJNIBridgeStruct(CPPRaiseFunction, self);\n    WCDBJNIGetStringCritical(errMsg);\n    WCDBRaiseFunctionSetAction(selfStruct, action, errMsgString);\n    WCDBJNIReleaseStringCritical(errMsg);\n}"
  },
  {
    "path": "src/java/main/src/main/cpp/winq/identifier/RaiseFunctionJNI.h",
    "content": "// Created by qiuwenchen on 2023/6/9.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"WCDBJNI.h\"\n\n#define WCDBJNIRaiseFunctionFuncName(funcName) WCDBJNI(RaiseFunction, funcName)\n#define WCDBJNIRaiseFunctionObjectMethod(funcName, ...)                        \\\n    WCDBJNIObjectMethod(RaiseFunction, funcName, __VA_ARGS__)\n#define WCDBJNIRaiseFunctionClassMethodWithNoArg(funcName)                     \\\n    WCDBJNIClassMethodWithNoArg(RaiseFunction, funcName)\n#define WCDBJNIRaiseFunctionClassMethod(funcName, ...)                         \\\n    WCDBJNIClassMethod(RaiseFunction, funcName, __VA_ARGS__)\n\njlong WCDBJNIRaiseFunctionClassMethodWithNoArg(createCppObj);\nvoid WCDBJNIRaiseFunctionClassMethod(setAction, jlong self, jint action, jstring errMsg);\n"
  },
  {
    "path": "src/java/main/src/main/cpp/winq/identifier/ResultColumnJNI.c",
    "content": "// Created by chenqiuwen on 2023/4/8.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"ResultColumnJNI.h\"\n#include \"ResultColumnBridge.h\"\n\njlong WCDBJNIResultColumnClassMethod(create, WCDBJNIObjectOrStringParameter(column))\n{\n    WCDBJNICreateObjectOrStringCommonValue(column, true);\n    jlong ret = (jlong) WCDBResultColumnCreate(column_common).innerValue;\n    WCDBJNITryReleaseStringInCommonValue(column);\n    return ret;\n}\n\nvoid WCDBJNIResultColumnClassMethod(configAlias, jlong object, jstring alias)\n{\n    WCDBJNIBridgeStruct(CPPResultColumn, object);\n    WCDBJNIGetStringCritical(alias);\n    WCDBResultColumnConfigAlias(objectStruct, aliasString);\n    WCDBJNIReleaseStringCritical(alias);\n}\n"
  },
  {
    "path": "src/java/main/src/main/cpp/winq/identifier/ResultColumnJNI.h",
    "content": "// Created by chenqiuwen on 2023/4/8.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"WCDBJNI.h\"\n\n#define WCDBJNIResultColumnFuncName(funcName) WCDBJNI(ResultColumn, funcName)\n#define WCDBJNIResultColumnObjectMethod(funcName, ...)                         \\\n    WCDBJNIObjectMethod(ResultColumn, funcName, __VA_ARGS__)\n#define WCDBJNIResultColumnClassMethodWithNoArg(funcName)                      \\\n    WCDBJNIClassMethodWithNoArg(ResultColumn, funcName)\n#define WCDBJNIResultColumnClassMethod(funcName, ...)                          \\\n    WCDBJNIClassMethod(ResultColumn, funcName, __VA_ARGS__)\n\njlong WCDBJNIResultColumnClassMethod(create, WCDBJNIObjectOrStringParameter(column));\n\nvoid WCDBJNIResultColumnClassMethod(configAlias, jlong object, jstring alias);"
  },
  {
    "path": "src/java/main/src/main/cpp/winq/identifier/SchemaJNI.c",
    "content": "// Created by qiuwenchen on 2023/3/31.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"SchemaJNI.h\"\n#include \"SchemaBridge.h\"\n\njlong WCDBJNISchemaClassMethod(createWithName, jstring name)\n{\n    WCDBJNIGetStringCritical(name);\n    jlong ret = (jlong) WCDBSchemaCreateWithName(nameString).innerValue;\n    WCDBJNIReleaseStringCritical(name);\n    return ret;\n}\n\njlong WCDBJNISchemaClassMethodWithNoArg(main)\n{\n    return (jlong) WCDBSchemaMain().innerValue;\n}\n\njlong WCDBJNISchemaClassMethodWithNoArg(temp)\n{\n    return (jlong) WCDBSchemaTemp().innerValue;\n}"
  },
  {
    "path": "src/java/main/src/main/cpp/winq/identifier/SchemaJNI.h",
    "content": "// Created by qiuwenchen on 2023/3/31.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"WCDBJNI.h\"\n\n#define WCDBJNISchemaFuncName(funcName) WCDBJNI(Schema, funcName)\n#define WCDBJNISchemaObjectMethod(funcName, ...)                               \\\n    WCDBJNIObjectMethod(Schema, funcName, __VA_ARGS__)\n#define WCDBJNISchemaClassMethodWithNoArg(funcName)                            \\\n    WCDBJNIClassMethodWithNoArg(Schema, funcName)\n#define WCDBJNISchemaClassMethod(funcName, ...)                                \\\n    WCDBJNIClassMethod(Schema, funcName, __VA_ARGS__)\n\njlong WCDBJNISchemaClassMethod(createWithName, jstring name);\n\njlong WCDBJNISchemaClassMethodWithNoArg(main);\n\njlong WCDBJNISchemaClassMethodWithNoArg(temp);"
  },
  {
    "path": "src/java/main/src/main/cpp/winq/identifier/TableConstraintJNI.c",
    "content": "// Created by chenqiuwen on 2023/4/8.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"TableConstraintJNI.h\"\n#include \"TableConstraintBridge.h\"\n\njlong WCDBJNITableConstraintClassMethod(create, jstring name)\n{\n    WCDBJNIGetStringCritical(name);\n    jlong ret = (jlong) WCDBTableConstraintCreate(nameString).innerValue;\n    WCDBJNIReleaseStringCritical(name);\n    return ret;\n}\n\nvoid WCDBJNITableConstraintClassMethod(configPrimaryKey, jlong constraint)\n{\n    WCDBJNIBridgeStruct(CPPTableConstraint, constraint);\n    WCDBTableConstraintConfigPrimaryKey(constraintStruct);\n}\n\nvoid WCDBJNITableConstraintClassMethod(configUnique, jlong constraint)\n{\n    WCDBJNIBridgeStruct(CPPTableConstraint, constraint);\n    WCDBTableConstraintConfigUnique(constraintStruct);\n}\n\nvoid WCDBJNITableConstraintClassMethod(configIndexedColumn,\n                                       jlong constraint,\n                                       WCDBJNIObjectOrStringArrayParameter(indexedColumns))\n{\n    WCDBJNIBridgeStruct(CPPTableConstraint, constraint);\n    WCDBJNICreateObjectOrStringArrayCriticalWithAction(\n    indexedColumns,\n    WCDBTableConstraintConfigIndexedColumn2(constraintStruct, indexedColumns_commonArray));\n}\n\nvoid WCDBJNITableConstraintClassMethod(configConfliction, jlong constraint, int conflictAction)\n{\n    WCDBJNIBridgeStruct(CPPTableConstraint, constraint);\n    WCDBTableConstraintConfigConfliction(constraintStruct, conflictAction);\n}\n\nvoid WCDBJNITableConstraintClassMethod(configCheckCondition, jlong constraint, jlong expression)\n{\n    WCDBJNIBridgeStruct(CPPTableConstraint, constraint);\n    WCDBJNIBridgeStruct(CPPExpression, expression);\n    WCDBTableConstraintConfigCheckCondition(constraintStruct, expressionStruct);\n}\n\nvoid WCDBJNITableConstraintClassMethod(configForeignKey,\n                                       jlong constraint,\n                                       WCDBJNIObjectOrStringArrayParameter(columns),\n                                       jlong foreignKey)\n{\n    WCDBJNIBridgeStruct(CPPTableConstraint, constraint);\n    WCDBJNIBridgeStruct(CPPForeignKey, foreignKey);\n    WCDBJNICreateObjectOrStringArrayCriticalWithAction(\n    columns, WCDBTableConstraintConfigForeignKey2(constraintStruct, columns_commonArray, foreignKeyStruct));\n}\n"
  },
  {
    "path": "src/java/main/src/main/cpp/winq/identifier/TableConstraintJNI.h",
    "content": "// Created by chenqiuwen on 2023/4/8.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"WCDBJNI.h\"\n\n#define WCDBJNITableConstraintFuncName(funcName)                               \\\n    WCDBJNI(TableConstraint, funcName)\n#define WCDBJNITableConstraintObjectMethod(funcName, ...)                      \\\n    WCDBJNIObjectMethod(TableConstraint, funcName, __VA_ARGS__)\n#define WCDBJNITableConstraintClassMethodWithNoArg(funcName)                   \\\n    WCDBJNIClassMethodWithNoArg(TableConstraint, funcName)\n#define WCDBJNITableConstraintClassMethod(funcName, ...)                       \\\n    WCDBJNIClassMethod(TableConstraint, funcName, __VA_ARGS__)\n\njlong WCDBJNITableConstraintClassMethod(create, jstring name);\nvoid WCDBJNITableConstraintClassMethod(configPrimaryKey, jlong constraint);\nvoid WCDBJNITableConstraintClassMethod(configUnique, jlong constraint);\nvoid WCDBJNITableConstraintClassMethod(configIndexedColumn,\n                                       jlong constraint,\n                                       WCDBJNIObjectOrStringArrayParameter(indexedColumns));\nvoid WCDBJNITableConstraintClassMethod(configConfliction, jlong constraint, int conflictAction);\nvoid WCDBJNITableConstraintClassMethod(configCheckCondition, jlong constraint, jlong expression);\nvoid WCDBJNITableConstraintClassMethod(configForeignKey,\n                                       jlong constraint,\n                                       WCDBJNIObjectOrStringArrayParameter(columns),\n                                       jlong foreignKey);\n"
  },
  {
    "path": "src/java/main/src/main/cpp/winq/identifier/TableOrSubqueryJNI.c",
    "content": "// Created by qiuwenchen on 2023/4/7.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"TableOrSubqueryJNI.h\"\n#include \"TableOrSubqueryBridge.h\"\n\njlong WCDBJNITableOrSubqueryClassMethod(create, WCDBJNIObjectOrStringParameter(tableOrSubquery))\n{\n    WCDBJNICreateObjectOrStringCommonValue(tableOrSubquery, true);\n    jlong ret = (jlong) WCDBTableOrSubqueryCreate(tableOrSubquery_common).innerValue;\n    WCDBJNITryReleaseStringInCommonValue(tableOrSubquery);\n    return ret;\n}\n\njlong WCDBJNITableOrSubqueryClassMethod(createWithFunction, jstring funcName)\n{\n    WCDBJNIGetStringCritical(funcName);\n    jlong ret = (jlong) WCDBTableOrSubqueryCreateWithFunction(funcNameString).innerValue;\n    WCDBJNIReleaseStringCritical(funcName);\n    return ret;\n}\n\njlong WCDBJNITableOrSubqueryClassMethod(createWithTableOrSubqueries,\n                                        WCDBJNIObjectOrStringArrayParameter(subquaries))\n{\n    jlong ret = 0;\n    WCDBJNICreateObjectOrStringArrayCriticalWithAction(\n    subquaries,\n    ret = (jlong) WCDBTableOrSubqueryCreateWithTableOrSubqueries2(subquaries_commonArray)\n          .innerValue) return ret;\n}\n\nvoid WCDBJNITableOrSubqueryClassMethod(configSchema,\n                                       jlong tableOrSubquery,\n                                       WCDBJNIObjectOrStringParameter(schema))\n{\n    WCDBJNIBridgeStruct(CPPTableOrSubquery, tableOrSubquery);\n    WCDBJNICreateObjectOrStringCommonValue(schema, true);\n    WCDBTableOrSubqueryConfigSchema2(tableOrSubqueryStruct, schema_common);\n    WCDBJNITryReleaseStringInCommonValue(schema);\n}\n\nvoid WCDBJNITableOrSubqueryClassMethod(configAlias, jlong tableOrSubquery, jstring alias)\n{\n    WCDBJNIBridgeStruct(CPPTableOrSubquery, tableOrSubquery);\n    WCDBJNIGetStringCritical(alias);\n    WCDBTableOrSubqueryConfigAs(tableOrSubqueryStruct, aliasString);\n    WCDBJNIReleaseStringCritical(alias);\n}\n\nvoid WCDBJNITableOrSubqueryClassMethod(configNotIndexed, jlong tableOrSubquery)\n{\n    WCDBJNIBridgeStruct(CPPTableOrSubquery, tableOrSubquery);\n    WCDBTableOrSubqueryConfigNotIndexed(tableOrSubqueryStruct);\n}\n\nvoid WCDBJNITableOrSubqueryClassMethod(configIndexName, jlong tableOrSubquery, jstring index)\n{\n    WCDBJNIBridgeStruct(CPPTableOrSubquery, tableOrSubquery);\n    WCDBJNIGetStringCritical(index);\n    WCDBTableOrSubqueryConfigIndexName(tableOrSubqueryStruct, indexString);\n    WCDBJNIReleaseStringCritical(index);\n}\n\nvoid WCDBJNITableOrSubqueryClassMethod(argument,\n                                       jlong tableOrSubquery,\n                                       WCDBJNICommonValueParameter(argument))\n{\n    WCDBJNIBridgeStruct(CPPTableOrSubquery, tableOrSubquery);\n    WCDBJNICreateCommonValue(argument, true);\n    WCDBTableOrSubqueryConfigArgument(tableOrSubqueryStruct, argument_common);\n    WCDBJNITryReleaseStringInCommonValue(argument);\n}"
  },
  {
    "path": "src/java/main/src/main/cpp/winq/identifier/TableOrSubqueryJNI.h",
    "content": "// Created by qiuwenchen on 2023/4/7.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"WCDBJNI.h\"\n\n#define WCDBJNITableOrSubqueryFuncName(funcName)                               \\\n    WCDBJNI(TableOrSubquery, funcName)\n#define WCDBJNITableOrSubqueryObjectMethod(funcName, ...)                      \\\n    WCDBJNIObjectMethod(TableOrSubquery, funcName, __VA_ARGS__)\n#define WCDBJNITableOrSubqueryClassMethodWithNoArg(funcName)                   \\\n    WCDBJNIClassMethodWithNoArg(TableOrSubquery, funcName)\n#define WCDBJNITableOrSubqueryClassMethod(funcName, ...)                       \\\n    WCDBJNIClassMethod(TableOrSubquery, funcName, __VA_ARGS__)\n\njlong WCDBJNITableOrSubqueryClassMethod(create, WCDBJNIObjectOrStringParameter(tableOrSubquery));\n\njlong WCDBJNITableOrSubqueryClassMethod(createWithTableOrSubqueries,\n                                        WCDBJNIObjectOrStringArrayParameter(subquaries));\n\njlong WCDBJNITableOrSubqueryClassMethod(createWithFunction, jstring funcName);\n\nvoid WCDBJNITableOrSubqueryClassMethod(configSchema,\n                                       jlong tableOrSubquery,\n                                       WCDBJNIObjectOrStringParameter(schema));\n\nvoid WCDBJNITableOrSubqueryClassMethod(configAlias, jlong tableOrSubquery, jstring alias);\n\nvoid WCDBJNITableOrSubqueryClassMethod(configNotIndexed, jlong tableOrSubquery);\n\nvoid WCDBJNITableOrSubqueryClassMethod(configIndexName, jlong tableOrSubquery, jstring index);\n\nvoid WCDBJNITableOrSubqueryClassMethod(argument,\n                                       jlong tableOrSubquery,\n                                       WCDBJNICommonValueParameter(argument));\n"
  },
  {
    "path": "src/java/main/src/main/cpp/winq/identifier/UpsertJNI.c",
    "content": "// Created by qiuwenchen on 2023/6/9.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"UpsertJNI.h\"\n#include \"UpsertBridge.h\"\n\njlong WCDBJNIUpsertClassMethodWithNoArg(createCppObj)\n{\n    return (jlong) WCDBUpsertCreate().innerValue;\n}\n\nvoid WCDBJNIUpsertClassMethod(configIndexedColumn,\n                              jlong upsert,\n                              WCDBJNIObjectOrStringArrayParameter(columns))\n{\n    WCDBJNIBridgeStruct(CPPUpsert, upsert);\n    WCDBJNICreateObjectOrStringArrayCriticalWithAction(\n    columns, WCDBUpsertConfigIndexdColumn2(upsertStruct, columns_commonArray));\n}\n\nvoid WCDBJNIUpsertClassMethod(configWhere, jlong upsert, jlong expression)\n{\n    WCDBJNIBridgeStruct(CPPUpsert, upsert);\n    WCDBJNIBridgeStruct(CPPExpression, expression);\n    WCDBUpsertConfigWhere(upsertStruct, expressionStruct);\n}\n\nvoid WCDBJNIUpsertClassMethod(configDoNothing, jlong upsert)\n{\n    WCDBJNIBridgeStruct(CPPUpsert, upsert);\n    WCDBUpsertConfigDoNothing(upsertStruct);\n}\n\nvoid WCDBJNIUpsertClassMethod(configDoUpdate, jlong upsert)\n{\n    WCDBJNIBridgeStruct(CPPUpsert, upsert);\n    WCDBUpsertConfigDoUpdate(upsertStruct);\n}\n\nvoid WCDBJNIUpsertClassMethod(configSetColumns,\n                              jlong upsert,\n                              WCDBJNIObjectOrStringArrayParameter(columns))\n{\n    WCDBJNIBridgeStruct(CPPUpsert, upsert);\n    WCDBJNICreateObjectOrStringArrayCriticalWithAction(\n    columns, WCDBUpsertConfigSetColumns2(upsertStruct, columns_commonArray));\n}\n\nvoid WCDBJNIUpsertClassMethod(configToValue, jlong upsert, WCDBJNICommonValueParameter(expression))\n{\n    WCDBJNIBridgeStruct(CPPUpsert, upsert);\n    WCDBJNICreateCommonValue(expression, true);\n    WCDBUpsertConfigToValue2(upsertStruct, expression_common);\n    WCDBJNITryReleaseStringInCommonValue(expression);\n}"
  },
  {
    "path": "src/java/main/src/main/cpp/winq/identifier/UpsertJNI.h",
    "content": "// Created by qiuwenchen on 2023/6/9.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n\n#include \"WCDBJNI.h\"\n\n#define WCDBJNIUpsertFuncName(funcName) WCDBJNI(Upsert, funcName)\n#define WCDBJNIUpsertObjectMethod(funcName, ...)                               \\\n    WCDBJNIObjectMethod(Upsert, funcName, __VA_ARGS__)\n#define WCDBJNIUpsertClassMethodWithNoArg(funcName)                            \\\n    WCDBJNIClassMethodWithNoArg(Upsert, funcName)\n#define WCDBJNIUpsertClassMethod(funcName, ...)                                \\\n    WCDBJNIClassMethod(Upsert, funcName, __VA_ARGS__)\n\njlong WCDBJNIUpsertClassMethodWithNoArg(createCppObj);\nvoid WCDBJNIUpsertClassMethod(configIndexedColumn,\n                              jlong upsert,\n                              WCDBJNIObjectOrStringArrayParameter(columns));\nvoid WCDBJNIUpsertClassMethod(configWhere, jlong upsert, jlong expression);\nvoid WCDBJNIUpsertClassMethod(configDoNothing, jlong upsert);\nvoid WCDBJNIUpsertClassMethod(configDoUpdate, jlong upsert);\nvoid WCDBJNIUpsertClassMethod(configSetColumns,\n                              jlong upsert,\n                              WCDBJNIObjectOrStringArrayParameter(columns));\nvoid WCDBJNIUpsertClassMethod(configToValue, jlong upsert, WCDBJNICommonValueParameter(expression));\n"
  },
  {
    "path": "src/java/main/src/main/cpp/winq/identifier/WindowDefJNI.c",
    "content": "// Created by chenqiuwen on 2023/6/10.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"WindowDefJNI.h\"\n#include \"WindowDefBridge.h\"\n\njlong WCDBJNIWindowDefClassMethodWithNoArg(createCppObj)\n{\n    return (jlong) WCDBWindowDefCreate().innerValue;\n}\n\nvoid WCDBJNIWindowDefClassMethod(configPartitions,\n                                 jlong self,\n                                 WCDBJNIMultiTypeArrayParameter(partitions))\n{\n    WCDBJNIBridgeStruct(CPPWindowDef, self);\n    WCDBJNICreateMultiTypeArray(partitions);\n    WCDBWindowDefConfigPartition2(selfStruct, partitionsArray);\n    WCDBJNIReleaseMultiTypeArray(partitions);\n}\n\nvoid WCDBJNIWindowDefClassMethod(configOrders, jlong self, jlongArray orders)\n{\n    WCDBJNIBridgeStruct(CPPWindowDef, self);\n    WCDBJNIGetCppPointerArrayCritical(orders);\n    WCDBWindowDefConfigOrder(selfStruct, (const CPPOrderingTerm *) ordersArray, ordersLength);\n    WCDBJNIReleaseCppPointerArrayCritical(orders);\n}\n\nvoid WCDBJNIWindowDefClassMethod(configFrameSpec, jlong self, jlong frameSpec)\n{\n    WCDBJNIBridgeStruct(CPPWindowDef, self);\n    WCDBJNIBridgeStruct(CPPFrameSpec, frameSpec);\n    WCDBWindowDefConfigFrameSpec(selfStruct, frameSpecStruct);\n}"
  },
  {
    "path": "src/java/main/src/main/cpp/winq/identifier/WindowDefJNI.h",
    "content": "// Created by chenqiuwen on 2023/6/10.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#pragma once\n#include \"WCDBJNI.h\"\n\n#define WCDBJNIWindowDefFuncName(funcName) WCDBJNI(WindowDef, funcName)\n#define WCDBJNIWindowDefObjectMethod(funcName, ...)                            \\\n    WCDBJNIObjectMethod(WindowDef, funcName, __VA_ARGS__)\n#define WCDBJNIWindowDefClassMethodWithNoArg(funcName)                         \\\n    WCDBJNIClassMethodWithNoArg(WindowDef, funcName)\n#define WCDBJNIWindowDefClassMethod(funcName, ...)                             \\\n    WCDBJNIClassMethod(WindowDef, funcName, __VA_ARGS__)\n\njlong WCDBJNIWindowDefClassMethodWithNoArg(createCppObj);\nvoid WCDBJNIWindowDefClassMethod(configPartitions,\n                                 jlong self,\n                                 WCDBJNIMultiTypeArrayParameter(partitions));\nvoid WCDBJNIWindowDefClassMethod(configOrders, jlong self, jlongArray orders);\nvoid WCDBJNIWindowDefClassMethod(configFrameSpec, jlong self, jlong frameSpec);\n"
  },
  {
    "path": "src/java/main/src/main/java/com/tencent/wcdb/base/CppObject.java",
    "content": "// Created by qiuwenchen on 2023/3/30.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage com.tencent.wcdb.base;\n\npublic class CppObject implements CppObjectConvertible {\n    static {\n        System.loadLibrary(\"WCDB\");\n    }\n\n    @Override\n    protected void finalize() throws Throwable {\n        long cObj = cppObj;\n        cppObj = 0;\n        if (cObj != 0) {\n            releaseCPPObject(cObj);\n        }\n        super.finalize();\n    }\n\n    protected long cppObj = 0;\n\n    public static long get(CppObject obj) {\n        if (obj == null) {\n            return 0;\n        }\n        return obj.cppObj;\n    }\n\n    public static long get(CppObjectConvertible obj) {\n        if (obj == null) {\n            return 0;\n        }\n        return obj.asCppObject().cppObj;\n    }\n\n    protected static native void releaseCPPObject(long obj);\n\n    @Override\n    public CppObject asCppObject() {\n        return this;\n    }\n}\n"
  },
  {
    "path": "src/java/main/src/main/java/com/tencent/wcdb/base/CppObjectConvertible.java",
    "content": "//\n// Created by chenqiuwen on 2023/8/26.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdb.base;\n\npublic interface CppObjectConvertible {\n    CppObject asCppObject();\n}\n"
  },
  {
    "path": "src/java/main/src/main/java/com/tencent/wcdb/base/Value.java",
    "content": "// Created by qiuwenchen on 2023/4/26.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdb.base;\n\nimport com.tencent.wcdb.winq.ColumnType;\n\nimport org.jetbrains.annotations.Nullable;\n\nimport java.util.Arrays;\nimport java.util.Objects;\n\npublic class Value {\n\n    public Value() {\n        this.value = null;\n    }\n\n    public Value(boolean value) {\n        this.value = (long) (value ? 1 : 0);\n    }\n\n    public Value(byte value) {\n        this.value = (long) value;\n    }\n\n    public Value(int value) {\n        this.value = (long) value;\n    }\n\n    public Value(long value) {\n        this.value = value;\n    }\n\n    public Value(float value) {\n        this.value = (double) value;\n    }\n\n    public Value(double value) {\n        this.value = value;\n    }\n\n    public Value(@Nullable String value) {\n        this.value = value;\n    }\n\n    public Value(@Nullable byte[] value) {\n        this.value = value;\n    }\n\n    public Value(@Nullable Object value) {\n        if (value == null) {\n            this.value = null;\n            return;\n        }\n        Class<?> cls = value.getClass();\n        if (cls == Long.class || cls == Double.class || cls == String.class || cls == byte[].class) {\n            this.value = value;\n        } else if (cls == Integer.class || cls == Short.class || cls == Byte.class) {\n            this.value = ((Number) value).longValue();\n        } else if (cls == Float.class) {\n            this.value = ((Number) value).doubleValue();\n        } else {\n            this.value = value.toString();\n        }\n    }\n\n    public Value(@Nullable Value other) {\n        this(other == null ? null : other.value);\n    }\n\n    public ColumnType getType() {\n        if (value == null) return ColumnType.Null;\n        Class<?> cls = value.getClass();\n        if (cls == Long.class) return ColumnType.Integer;\n        if (cls == String.class) return ColumnType.Text;\n        if (cls == byte[].class) return ColumnType.BLOB;\n        if (cls == Double.class) return ColumnType.Float;\n        throw new AssertionError();\n    }\n\n    public boolean getBool() {\n        return getLong() != 0;\n    }\n\n    public byte getByte() {\n        return (byte) getLong();\n    }\n\n    public short getShort() {\n        return (short) getLong();\n    }\n\n    public int getInt() {\n        return (int) getLong();\n    }\n\n    public long getLong() {\n        if (value instanceof Long) return (Long) value;\n        if (value instanceof Double) return (long) value;\n        if (value instanceof String) {\n            try {\n                return Long.parseLong((String) value);\n            } catch (NumberFormatException e) {\n            }\n        }\n        return 0L;\n    }\n\n    public float getFloat() {\n        return (float) getDouble();\n    }\n\n    public double getDouble() {\n        if (value instanceof Double) return (Double) value;\n        if (value instanceof Long) return (double) value;\n        if (value instanceof String) {\n            try {\n                return Double.parseDouble((String) value);\n            } catch (NumberFormatException e) {\n            }\n        }\n        return 0.0;\n    }\n\n    @Nullable\n    public String getText() {\n        if (value instanceof String) return (String) value;\n        if (value instanceof byte[]) return new String((byte[]) value);\n        return (value == null) ? null : value.toString();\n    }\n\n    @Nullable\n    public byte[] getBLOB() {\n        if (value == null) return null;\n        if (value instanceof byte[]) return (byte[]) value;\n        return value.toString().getBytes();\n    }\n\n    @Override\n    public boolean equals(Object obj) {\n        if (obj == this || obj == value) return true;\n        if (obj instanceof Value) {\n            Value v2 = (Value) obj;\n            switch (getType()) {\n                case Null:\n                    return v2.getLong() == 0L;\n                case Integer:\n                    return ((Long) value) == v2.getLong();\n                case Float:\n                    return ((Double) value) == v2.getDouble();\n                case Text:\n                    return value.equals(v2.getText());\n                case BLOB:\n                    return Arrays.equals((byte[]) value, v2.getBLOB());\n            }\n            assert false;\n        }\n        return Objects.deepEquals(obj, value);\n    }\n\n    @Override\n    public int hashCode() {\n        return (value == null) ? 0 : value.hashCode();\n    }\n\n    private final Object value;\n}\n"
  },
  {
    "path": "src/java/main/src/main/java/com/tencent/wcdb/base/WCDBCorruptOrIOException.java",
    "content": "// Created by qiuwenchen on 2023/8/17.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdb.base;\n\npublic class WCDBCorruptOrIOException extends WCDBException {\n    WCDBCorruptOrIOException(Level level, Code code, long cppObj) {\n        super(level, code, cppObj);\n    }\n}\n"
  },
  {
    "path": "src/java/main/src/main/java/com/tencent/wcdb/base/WCDBException.java",
    "content": "// Created by qiuwenchen on 2023/3/30.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage com.tencent.wcdb.base;\n\nimport org.jetbrains.annotations.NotNull;\nimport org.jetbrains.annotations.Nullable;\n\nimport java.util.LinkedHashMap;\nimport java.util.Map;\n\npublic class WCDBException extends RuntimeException {\n    public enum Level {\n        Ignore,\n        Debug,\n        Notice,\n        Warning,\n        Error,\n        Fatal,\n        Unknown;\n\n        public static Level valueOf(int value) {\n            switch (value) {\n                case 1:\n                    return Ignore;\n                case 2:\n                    return Debug;\n                case 3:\n                    return Notice;\n                case 4:\n                    return Warning;\n                case 5:\n                    return Error;\n                case 6:\n                    return Fatal;\n            }\n            return Unknown;\n        }\n\n        @NotNull\n        @Override\n        public String toString() {\n            switch (this) {\n                case Ignore:\n                    return \"IGNORE\";\n                case Debug:\n                    return \"DEBUG\";\n                case Notice:\n                    return \"NOTICE\";\n                case Warning:\n                    return \"WARNING\";\n                case Error:\n                    return \"ERROR\";\n                case Fatal:\n                    return \"FATAL\";\n                default:\n                    return \"UNKNOWN\";\n            }\n        }\n    }\n\n    public enum Code {\n        OK(0),\n        Error(1),\n        Internal(2),\n        Permission(3),\n        Abort(4),\n        Busy(5),\n        Locked(6),\n        NoMemory(7),\n        Readonly(8),\n        Interrupt(9),\n        IOError(10),\n        Corrupt(11),\n        NotFound(12),\n        Full(13),\n        CantOpen(14),\n        Protocol(15),\n        Empty(16),\n        Schema(17),\n        Exceed(18),\n        Constraint(19),\n        Mismatch(20),\n        Misuse(21),\n        NoLargeFileSupport(22),\n        Authorization(23),\n        Format(24),\n        Range(25),\n        NotADatabase(26),\n        Notice(27),\n        Warning(28),\n        Row(100),\n        Done(101),\n        Unknown(-1);\n        private final int value;\n\n        Code(int value) {\n            this.value = value;\n        }\n\n        public static Code valueOf(int value) {\n            switch (value) {\n                case 0:\n                    return OK;\n                case 1:\n                    return Error;\n                case 2:\n                    return Internal;\n                case 3:\n                    return Permission;\n                case 4:\n                    return Abort;\n                case 5:\n                    return Busy;\n                case 6:\n                    return Locked;\n                case 7:\n                    return NoMemory;\n                case 8:\n                    return Readonly;\n                case 9:\n                    return Interrupt;\n                case 10:\n                    return IOError;\n                case 11:\n                    return Corrupt;\n                case 12:\n                    return NotFound;\n                case 13:\n                    return Full;\n                case 14:\n                    return CantOpen;\n                case 15:\n                    return Protocol;\n                case 16:\n                    return Empty;\n                case 17:\n                    return Schema;\n                case 18:\n                    return Exceed;\n                case 19:\n                    return Constraint;\n                case 20:\n                    return Mismatch;\n                case 21:\n                    return Misuse;\n                case 22:\n                    return NoLargeFileSupport;\n                case 23:\n                    return Authorization;\n                case 24:\n                    return Format;\n                case 25:\n                    return Range;\n                case 26:\n                    return NotADatabase;\n                case 27:\n                    return Notice;\n                case 28:\n                    return Warning;\n                case 100:\n                    return Row;\n                case 101:\n                    return Done;\n                default:\n                    return Unknown;\n            }\n        }\n\n        public int value() {\n            return this.value;\n        }\n    }\n\n    public enum ExtendCode {\n        ErrorMissingCollseq(257),       // Code.Error | (1 << 8)\n        ErrorRetry(513),                // Code.Error | (2 << 8)\n        ErrorSnapshot(769),             // Code.Error | (3 << 8)\n        IOErrorRead(266),               // Code.IOError | (1 << 8)\n        IOErrorShortRead(522),          // Code.IOError | (2 << 8)\n        IOErrorWrite(778),              // Code.IOError | (3 << 8)\n        IOErrorFsync(1034),             // Code.IOError | (4 << 8)\n        IOErrorDirFsync(1290),          // Code.IOError | (5 << 8)\n        IOErrorTruncate(1546),          // Code.IOError | (6 << 8)\n        IOErrorFstat(1802),             // Code.IOError | (7 << 8)\n        IOErrorUnlock(2058),            // Code.IOError | (8 << 8)\n        IOErrorRdlock(2314),            // Code.IOError | (9 << 8)\n        IOErrorDelete(2570),            // Code.IOError | (10 << 8)\n        IOErrorBlocked(2826),           // Code.IOError | (11 << 8)\n        IOErrorNoMemory(3082),          // Code.IOError | (12 << 8)\n        IOErrorAccess(3338),            // Code.IOError | (13 << 8)\n        IOErrorCheckReservedLock(3594), // Code.IOError | (14 << 8)\n        IOErrorLock(3850),              // Code.IOError | (15 << 8)\n        IOErrorClose(4106),             // Code.IOError | (16 << 8)\n        IOErrorDirClose(4362),          // Code.IOError | (17 << 8)\n        IOErrorShmOpen(4618),           // Code.IOError | (18 << 8)\n        IOErrorShmSize(4874),           // Code.IOError | (19 << 8)\n        IOErrorShmLock(5130),           // Code.IOError | (20 << 8)\n        IOErrorShmMap(5386),            // Code.IOError | (21 << 8)\n        IOErrorSeek(5642),              // Code.IOError | (22 << 8)\n        IOErrorDeleteNoEntry(5898),     // Code.IOError | (23 << 8)\n        IOErrorMmap(6154),              // Code.IOError | (24 << 8)\n        IOErrorGetTempPath(6410),       // Code.IOError | (25 << 8)\n        IOErrorConvPath(6666),          // Code.IOError | (26 << 8)\n        IOErrorVnode(6922),             // Code.IOError | (27 << 8)\n        IOErrorAuthorization(7178),     // Code.IOError | (28 << 8)\n        IOErrorBeginAtomic(7434),       // Code.IOError | (29 << 8)\n        IOErrorCommitAtomic(7690),      // Code.IOError | (30 << 8)\n        IOErrorRollbackAtomic(7946),    // Code.IOError | (31 << 8)\n        LockedSharedCache(262),         // Code.Locked | (1 << 8)\n        LockedVirtualTable(518),        // Code.Locked | (2 << 8)\n        BusyRecovery(261),              // Code.Busy | (1 << 8)\n        BusySnapshot(517),              // Code.Busy | (2 << 8)\n        CantOpenNoTempDir(270),         // Code.CantOpen | (1 << 8)\n        CantOpenIsDir(526),             // Code.CantOpen | (2 << 8)\n        CantOpenFullPath(782),          // Code.CantOpen | (3 << 8)\n        CantOpenConvPath(1038),         // Code.CantOpen | (4 << 8)\n        CantOpenDirtyWal(1294),         // Code.CantOpen | (5 << 8)\n        CorruptVirtualTable(267),       // Code.Corrupt | (1 << 8)\n        CorruptSequence(523),           // Code.Corrupt | (2 << 8)\n        ReadonlyRecovery(264),          // Code.Readonly | (1 << 8)\n        ReadonlyCantLock(520),          // Code.Readonly | (2 << 8)\n        ReadonlyRollback(776),          // Code.Readonly | (3 << 8)\n        ReadonlyDatabaseMoved(1032),    // Code.Readonly | (4 << 8)\n        ReadonlyCantInit(1288),         // Code.Readonly | (5 << 8)\n        ReadonlyDirectory(1544),        // Code.Readonly | (6 << 8)\n        AbortRollback(516),             // Code.Abort | (2 << 8)\n        ConstraintCheck(275),           // Code.Constraint | (1 << 8)\n        ConstraintCommitHook(531),      // Code.Constraint | (2 << 8)\n        ConstraintForeignKey(787),      // Code.Constraint | (3 << 8)\n        ConstraintFunction(1043),       // Code.Constraint | (4 << 8)\n        ConstraintNotNull(1299),        // Code.Constraint | (5 << 8)\n        ConstraintPrimaryKey(1555),     // Code.Constraint | (6 << 8)\n        ConstraintTrigger(1811),        // Code.Constraint | (7 << 8)\n        ConstraintUnique(2067),         // Code.Constraint | (8 << 8)\n        ConstraintVirtualTable(2323),   // Code.Constraint | (9 << 8)\n        ConstraintRowID(2579),          // Code.Constraint | (10 << 8)\n        NoticeRecoverWal(283),          // Code.Notice | (1 << 8)\n        NoticeRecoverRollback(539),     // Code.Notice | (2 << 8)\n        WarningAutoIndex(284),          // Code.Warning | (1 << 8)\n        AuthorizationUser(279),         // Code.Authorization | (1 << 8)\n        OKLoadPermanently(256),         // Code.OK | (1 << 8)\n        Unknown(-1);\n        private final int value;\n\n        ExtendCode(int value) {\n            this.value = value;\n        }\n\n        public static ExtendCode valueOf(int value) {\n            switch (value) {\n                case 257:\n                    return ErrorMissingCollseq;\n                case 513:\n                    return ErrorRetry;\n                case 769:\n                    return ErrorSnapshot;\n                case 266:\n                    return IOErrorRead;\n                case 522:\n                    return IOErrorShortRead;\n                case 778:\n                    return IOErrorWrite;\n                case 1034:\n                    return IOErrorFsync;\n                case 1290:\n                    return IOErrorDirFsync;\n                case 1546:\n                    return IOErrorTruncate;\n                case 1802:\n                    return IOErrorFstat;\n                case 2058:\n                    return IOErrorUnlock;\n                case 2314:\n                    return IOErrorRdlock;\n                case 2570:\n                    return IOErrorDelete;\n                case 2826:\n                    return IOErrorBlocked;\n                case 3082:\n                    return IOErrorNoMemory;\n                case 3338:\n                    return IOErrorAccess;\n                case 3594:\n                    return IOErrorCheckReservedLock;\n                case 3850:\n                    return IOErrorLock;\n                case 4106:\n                    return IOErrorClose;\n                case 4362:\n                    return IOErrorDirClose;\n                case 4618:\n                    return IOErrorShmOpen;\n                case 4874:\n                    return IOErrorShmSize;\n                case 5130:\n                    return IOErrorShmLock;\n                case 5386:\n                    return IOErrorShmMap;\n                case 5642:\n                    return IOErrorSeek;\n                case 5898:\n                    return IOErrorDeleteNoEntry;\n                case 6154:\n                    return IOErrorMmap;\n                case 6410:\n                    return IOErrorGetTempPath;\n                case 6666:\n                    return IOErrorConvPath;\n                case 6922:\n                    return IOErrorVnode;\n                case 7178:\n                    return IOErrorAuthorization;\n                case 7434:\n                    return IOErrorBeginAtomic;\n                case 7690:\n                    return IOErrorCommitAtomic;\n                case 7946:\n                    return IOErrorRollbackAtomic;\n                case 262:\n                    return LockedSharedCache;\n                case 518:\n                    return LockedVirtualTable;\n                case 261:\n                    return BusyRecovery;\n                case 517:\n                    return BusySnapshot;\n                case 270:\n                    return CantOpenNoTempDir;\n                case 526:\n                    return CantOpenIsDir;\n                case 782:\n                    return CantOpenFullPath;\n                case 1038:\n                    return CantOpenConvPath;\n                case 1294:\n                    return CantOpenDirtyWal;\n                case 267:\n                    return CorruptVirtualTable;\n                case 523:\n                    return CorruptSequence;\n                case 264:\n                    return ReadonlyRecovery;\n                case 520:\n                    return ReadonlyCantLock;\n                case 776:\n                    return ReadonlyRollback;\n                case 1032:\n                    return ReadonlyDatabaseMoved;\n                case 1288:\n                    return ReadonlyCantInit;\n                case 1544:\n                    return ReadonlyDirectory;\n                case 516:\n                    return AbortRollback;\n                case 275:\n                    return ConstraintCheck;\n                case 531:\n                    return ConstraintCommitHook;\n                case 787:\n                    return ConstraintForeignKey;\n                case 1043:\n                    return ConstraintFunction;\n                case 1299:\n                    return ConstraintNotNull;\n                case 1555:\n                    return ConstraintPrimaryKey;\n                case 1811:\n                    return ConstraintTrigger;\n                case 2067:\n                    return ConstraintUnique;\n                case 2323:\n                    return ConstraintVirtualTable;\n                case 2579:\n                    return ConstraintRowID;\n                case 283:\n                    return NoticeRecoverWal;\n                case 539:\n                    return NoticeRecoverRollback;\n                case 284:\n                    return WarningAutoIndex;\n                case 279:\n                    return AuthorizationUser;\n                case 256:\n                    return OKLoadPermanently;\n                default:\n                    return Unknown;\n            }\n        }\n\n        public int value() {\n            return this.value;\n        }\n    }\n\n    public enum Key {\n        tag(\"Tag\"),\n        path(\"Path\"),\n        type(\"Type\"),\n        source(\"Source\"),\n        SQL(\"SQL\"),\n        extendedCode(\"ExtCode\"),\n        message(\"Message\");\n\n        private final String value;\n\n        Key(String value) {\n            this.value = value;\n        }\n\n        String getValue() {\n            return value;\n        }\n    }\n\n    public final Level level;\n    public final Code code;\n    public final Map<String, Object> info;\n\n    WCDBException(Level level, Code code, long cppObj) {\n        this.level = level;\n        this.code = code;\n        String message = getMessage(cppObj);\n        info = new LinkedHashMap<>();\n        info.put(Key.message.value, message);\n        enumerateInfo(cppObj);\n    }\n\n    public static WCDBException createException(long cppObj) {\n        Level level = Level.valueOf(getLevel(cppObj));\n        Code code = Code.valueOf(getCode(cppObj));\n        if (level != Level.Error) {\n            return new WCDBNormalException(level, code, cppObj);\n        }\n        if (code == Code.Interrupt) {\n            return new WCDBInterruptException(level, code, cppObj);\n        } else if (code == Code.Permission ||\n                code == Code.Readonly ||\n                code == Code.IOError ||\n                code == Code.Corrupt ||\n                code == Code.Full ||\n                code == Code.CantOpen ||\n                code == Code.NotADatabase) {\n            return new WCDBCorruptOrIOException(level, code, cppObj);\n        } else {\n            return new WCDBNormalException(level, code, cppObj);\n        }\n    }\n\n    private static native int getLevel(long error);\n\n    private static native int getCode(long error);\n\n    private static native String getMessage(long error);\n\n    private native void enumerateInfo(long cppError);\n\n    private void addInfo(String key, int valueType, long intValue, double doubleValue, String stringValue) {\n        if (valueType == 3) {\n            info.put(key, intValue);\n        } else if (valueType == 5) {\n            info.put(key, doubleValue);\n        } else if (valueType == 6) {\n            info.put(key, stringValue);\n        }\n    }\n\n    public long tag() {\n        Object tag = info.get(Key.tag.getValue());\n        if (tag != null) {\n            return (Long) tag;\n        }\n        return 0;\n    }\n\n    public ExtendCode extendCode() {\n        Object code = info.get(Key.extendedCode.getValue());\n        if (code != null) {\n            return ExtendCode.valueOf(((Long) code).intValue());\n        }\n        return ExtendCode.Unknown;\n    }\n\n    @Nullable\n    public String message() {\n        return (String) info.get(Key.message.getValue());\n    }\n\n    @Nullable\n    public String sql() {\n        return (String) info.get(Key.SQL.getValue());\n    }\n\n    @Nullable\n    public String path() {\n        return (String) info.get(Key.path.getValue());\n    }\n\n    @Override\n    public String getMessage() {\n        StringBuilder sb = new StringBuilder(256);\n        sb.append(\"Code: \").append(code.value());\n        for (Map.Entry<String, Object> entry : info.entrySet()) {\n            sb.append(\"; \").append(entry.getKey()).append(\": \").append(entry.getValue());\n        }\n        return sb.toString();\n    }\n\n    @NotNull\n    public String toStringForLog() {\n        return \"[WCDB] [\" + level + \"] \" + getMessage();\n    }\n}\n"
  },
  {
    "path": "src/java/main/src/main/java/com/tencent/wcdb/base/WCDBInterruptException.java",
    "content": "// Created by qiuwenchen on 2023/8/17.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdb.base;\n\npublic class WCDBInterruptException extends WCDBException {\n    WCDBInterruptException(Level level, Code code, long cppObj) {\n        super(level, code, cppObj);\n\n    }\n}\n"
  },
  {
    "path": "src/java/main/src/main/java/com/tencent/wcdb/base/WCDBNormalException.java",
    "content": "// Created by qiuwenchen on 2023/8/17.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdb.base;\n\npublic class WCDBNormalException extends WCDBException {\n    WCDBNormalException(Level level, Code code, long cppObj) {\n        super(level, code, cppObj);\n\n    }\n}\n"
  },
  {
    "path": "src/java/main/src/main/java/com/tencent/wcdb/chaincall/ChainCall.java",
    "content": "// Created by chenqiuwen on 2023/5/1.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdb.chaincall;\n\nimport com.tencent.wcdb.base.WCDBException;\nimport com.tencent.wcdb.core.Handle;\nimport com.tencent.wcdb.winq.Statement;\n\nimport org.jetbrains.annotations.NotNull;\n\npublic class ChainCall<T extends Statement> {\n    Handle handle;\n    int changes = 0;\n    T statement;\n    boolean needChanges = true;\n    boolean autoInvalidateHandle = false;\n\n    public ChainCall(@NotNull Handle handle, boolean needChanges, boolean autoInvalidateHandle) {\n        this.handle = handle;\n        this.needChanges = needChanges;\n        this.autoInvalidateHandle = autoInvalidateHandle;\n    }\n\n    protected void updateChanges() throws WCDBException {\n        if (needChanges) {\n            changes = handle.getChanges();\n        }\n    }\n\n    public void invalidateHandle() {\n        if (autoInvalidateHandle) {\n            handle.invalidate();\n        }\n    }\n\n    /**\n     * Get the number of changed rows in the most recent call.\n     *\n     * @return the number of changed rows.\n     */\n    public int getChanges() {\n        return changes;\n    }\n\n    /**\n     * The statement that `ChainCall` will execute.\n     * You can customize this statement directly to implement the capabilities not provided by `ChainCall`.\n     *\n     * @return the current statement.\n     */\n    @NotNull\n    public T getStatement() {\n        return statement;\n    }\n}\n"
  },
  {
    "path": "src/java/main/src/main/java/com/tencent/wcdb/chaincall/Delete.java",
    "content": "// Created by chenqiuwen on 2023/5/2.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdb.chaincall;\n\nimport com.tencent.wcdb.base.WCDBException;\nimport com.tencent.wcdb.core.Handle;\nimport com.tencent.wcdb.winq.Expression;\nimport com.tencent.wcdb.winq.ExpressionConvertible;\nimport com.tencent.wcdb.winq.OrderingTerm;\nimport com.tencent.wcdb.winq.StatementDelete;\n\nimport org.jetbrains.annotations.NotNull;\nimport org.jetbrains.annotations.Nullable;\n\npublic class Delete extends ChainCall<StatementDelete> {\n    public Delete(@NotNull Handle handle, boolean needChanges, boolean autoInvalidateHandle) {\n        super(handle, needChanges, autoInvalidateHandle);\n        statement = new StatementDelete();\n    }\n\n    /**\n     * WINQ interface for SQL.\n     *\n     * @param table The name of the table to delete data from.\n     * @return this\n     */\n    @NotNull\n    public Delete fromTable(@NotNull String table) {\n        statement.deleteFrom(table);\n        return this;\n    }\n\n    /**\n     * WINQ interface for SQL.\n     *\n     * @param condition condition\n     * @return this.\n     */\n    @NotNull\n    public Delete where(@Nullable Expression condition) {\n        statement.where(condition);\n        return this;\n    }\n\n    /**\n     * WINQ interface for SQL.\n     *\n     * @param orders order list\n     * @return this.\n     */\n    @NotNull\n    public Delete orderBy(@Nullable OrderingTerm... orders) {\n        statement.orderBy(orders);\n        return this;\n    }\n\n    /**\n     * WINQ interface for SQL.\n     *\n     * @param count limit count.\n     * @return this.\n     */\n    @NotNull\n    public Delete limit(long count) {\n        statement.limit(count);\n        return this;\n    }\n\n    /**\n     * WINQ interface for SQL.\n     *\n     * @param count limit expression.\n     * @return this.\n     */\n    @NotNull\n    public Delete limit(@NotNull ExpressionConvertible count) {\n        statement.limit(count);\n        return this;\n    }\n\n    /**\n     * WINQ interface for SQL.\n     *\n     * @param offset offset number.\n     * @return this.\n     */\n    @NotNull\n    public Delete offset(long offset) {\n        statement.offset(offset);\n        return this;\n    }\n\n    /**\n     * WINQ interface for SQL.\n     *\n     * @param offset offset expression.\n     * @return this.\n     */\n    @NotNull\n    public Delete offset(@Nullable ExpressionConvertible offset) {\n        statement.offset(offset);\n        return this;\n    }\n\n    /**\n     * Execute the delete SQL.\n     *\n     * @return this.\n     * @throws WCDBException if any error occurs.\n     */\n    @NotNull\n    public Delete execute() throws WCDBException {\n        try {\n            handle.execute(statement);\n        } finally {\n            updateChanges();\n            invalidateHandle();\n        }\n        return this;\n    }\n}\n"
  },
  {
    "path": "src/java/main/src/main/java/com/tencent/wcdb/chaincall/Insert.java",
    "content": "// Created by chenqiuwen on 2023/5/1.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdb.chaincall;\n\nimport com.tencent.wcdb.base.WCDBException;\nimport com.tencent.wcdb.core.Handle;\nimport com.tencent.wcdb.core.PreparedStatement;\nimport com.tencent.wcdb.core.Transaction;\nimport com.tencent.wcdb.orm.Field;\nimport com.tencent.wcdb.orm.TableBinding;\nimport com.tencent.wcdb.winq.StatementInsert;\n\nimport org.jetbrains.annotations.NotNull;\nimport org.jetbrains.annotations.Nullable;\n\nimport java.util.Collection;\nimport java.util.Collections;\n\npublic class Insert<T> extends ChainCall<StatementInsert> {\n    private boolean hasConflictAction = false;\n    private Field<T>[] fields = null;\n    private Collection<T> values = null;\n    private long lastInsertRowId = 0;\n\n    public Insert(@NotNull Handle handle, boolean needChanges, boolean autoInvalidateHandle) {\n        super(handle, needChanges, autoInvalidateHandle);\n        statement = new StatementInsert();\n    }\n\n    /**\n     * WINQ interface for SQL.\n     *\n     * @return this.\n     */\n    @NotNull\n    public Insert<T> orReplace() {\n        hasConflictAction = true;\n        statement.orReplace();\n        return this;\n    }\n\n    /**\n     * WINQ interface for SQL.\n     *\n     * @return this.\n     */\n    @NotNull\n    public Insert<T> orIgnore() {\n        hasConflictAction = true;\n        statement.orIgnore();\n        return this;\n    }\n\n    /**\n     * WINQ interface for SQL.\n     *\n     * @param table The name of the table to delete data from.\n     * @return this\n     */\n    @NotNull\n    public Insert<T> intoTable(@NotNull String table) {\n        statement.insertInto(table);\n        return this;\n    }\n\n    /**\n     * WINQ interface for SQL.\n     *\n     * @param fields Do a partial insertion with the specific fields.\n     * @return this.\n     */\n    @SafeVarargs\n    @NotNull\n    public final Insert<T> onFields(@NotNull Field<T>... fields) {\n        this.fields = fields;\n        statement.columns(fields).valuesWithBindParameters(fields.length);\n        return this;\n    }\n\n    /**\n     * Insert an object.\n     *\n     * @param object The object to be inserted into table.\n     * @return this.\n     */\n    @NotNull\n    public Insert<T> value(@Nullable T object) {\n        values = Collections.singleton(object);\n        return this;\n    }\n\n    /**\n     * Insert a batch of objects\n     *\n     * @param objects Objects to be inserted into table.\n     * @return this.\n     */\n    @NotNull\n    public Insert<T> values(@NotNull Collection<T> objects) {\n        values = objects;\n        return this;\n    }\n\n    /**\n     * Execute the insert statement.\n     * Note that it will run embedded transaction while values.count>1.\n     * The embedded transaction means that it will run a transaction if it's not in other transaction, otherwise it will be executed within the existing transaction.\n     *\n     * @return this.\n     * @throws WCDBException if no error occurs.\n     */\n    @NotNull\n    public Insert<T> execute() throws WCDBException {\n        if (values.size() == 0) {\n            return this;\n        }\n        assert fields != null && fields.length > 0;\n        try {\n            if (values.size() > 1) {\n                handle.runTransaction(new Transaction() {\n                    @Override\n                    public boolean insideTransaction(@NotNull Handle handle) throws WCDBException {\n                        realExecute();\n                        return true;\n                    }\n                });\n            } else {\n                realExecute();\n            }\n        } finally {\n            invalidateHandle();\n        }\n        return this;\n    }\n\n    /**\n     * Get the rowid of the last inserted object.\n     *\n     * @return rowid.\n     */\n    public long getLastInsertRowId() {\n        return lastInsertRowId;\n    }\n\n    private void realExecute() throws WCDBException {\n        TableBinding<T> binding = Field.getBinding(fields);\n        PreparedStatement preparedStatement = handle.preparedWithMainStatement(statement);\n        lastInsertRowId = 0;\n        for (T object : values) {\n            preparedStatement.reset();\n            int index = 1;\n            boolean isAutoIncrement = !hasConflictAction && binding.isAutoIncrement(object);\n            for (Field<T> field : fields) {\n                if (isAutoIncrement && field.isAutoIncrement()) {\n                    preparedStatement.bindNull(index);\n                } else {\n                    binding.bindField(object, field, index, preparedStatement);\n                }\n                index++;\n            }\n            preparedStatement.step();\n            if (isAutoIncrement) {\n                binding.setLastInsertRowId(object, handle.getLastInsertedRowId());\n            }\n        }\n        if (values.size() > 0) {\n            lastInsertRowId = handle.getLastInsertedRowId();\n        }\n        updateChanges();\n        preparedStatement.finalizeStatement();\n    }\n\n}\n"
  },
  {
    "path": "src/java/main/src/main/java/com/tencent/wcdb/chaincall/Select.java",
    "content": "// Created by chenqiuwen on 2023/5/2.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdb.chaincall;\n\nimport com.tencent.wcdb.base.WCDBException;\nimport com.tencent.wcdb.core.Handle;\nimport com.tencent.wcdb.core.PreparedStatement;\nimport com.tencent.wcdb.orm.Field;\nimport com.tencent.wcdb.winq.Expression;\nimport com.tencent.wcdb.winq.ExpressionConvertible;\nimport com.tencent.wcdb.winq.OrderingTerm;\nimport com.tencent.wcdb.winq.StatementSelect;\n\nimport org.jetbrains.annotations.NotNull;\nimport org.jetbrains.annotations.Nullable;\n\nimport java.util.List;\n\npublic class Select<T> extends ChainCall<StatementSelect> {\n    private Field<T>[] fields = null;\n\n    public Select(@NotNull Handle handle, boolean needChanges, boolean autoInvalidateHandle) {\n        super(handle, needChanges, autoInvalidateHandle);\n        statement = new StatementSelect();\n    }\n\n    /**\n     * WINQ interface for SQL.\n     *\n     * @param fields The column results to be selected.\n     * @return this\n     */\n    @SafeVarargs\n    @NotNull\n    public final Select<T> select(@NotNull Field<T>... fields) {\n        this.fields = fields;\n        statement.select(fields);\n        return this;\n    }\n\n    /**\n     * WINQ interface for SQL.\n     *\n     * @param condition condition.\n     * @return this.\n     */\n    @NotNull\n    public Select<T> where(@Nullable Expression condition) {\n        statement.where(condition);\n        return this;\n    }\n\n    /**\n     * WINQ interface for SQL.\n     *\n     * @param order order term.\n     * @return this.\n     */\n    @NotNull\n    public Select<T> orderBy(@Nullable OrderingTerm order) {\n        statement.orderBy(order);\n        return this;\n    }\n\n    /**\n     * WINQ interface for SQL.\n     *\n     * @param orders order list.\n     * @return this.\n     */\n    @NotNull\n    public Select<T> orderBy(@Nullable OrderingTerm... orders) {\n        statement.orderBy(orders);\n        return this;\n    }\n\n    /**\n     * WINQ interface for SQL.\n     *\n     * @param count limit count.\n     * @return this.\n     */\n    @NotNull\n    public Select<T> limit(long count) {\n        statement.limit(count);\n        return this;\n    }\n\n    /**\n     * WINQ interface for SQL.\n     *\n     * @param count limit expression.\n     * @return this.\n     */\n    @NotNull\n    public Select<T> limit(@Nullable ExpressionConvertible count) {\n        statement.limit(count);\n        return this;\n    }\n\n    /**\n     * WINQ interface for SQL.\n     *\n     * @param offset offset number.\n     * @return this.\n     */\n    @NotNull\n    public Select<T> offset(long offset) {\n        statement.offset(offset);\n        return this;\n    }\n\n    /**\n     * WINQ interface for SQL.\n     *\n     * @param offset offset expression.\n     * @return this.\n     */\n    @NotNull\n    public Select<T> offset(@Nullable ExpressionConvertible offset) {\n        statement.offset(offset);\n        return this;\n    }\n\n    /**\n     * WINQ interface for SQL.\n     *\n     * @param tableName The name of the table to query data from.\n     * @return this.\n     */\n    @NotNull\n    public Select<T> from(@NotNull String tableName) {\n        statement.from(tableName);\n        return this;\n    }\n\n    /**\n     * Get first selected object.\n     *\n     * @return a selected object.\n     * @throws WCDBException if any error occurs.\n     */\n    @Nullable\n    public T firstObject() throws WCDBException {\n        return firstObject(Field.getBindClass(fields));\n    }\n\n    /**\n     * Get first selected object.\n     *\n     * @param cls A derived class of java orm class.\n     * @return The selected derived class object.\n     * @throws WCDBException if any error occurs.\n     */\n    @Nullable\n    public <R extends T> R firstObject(Class<R> cls) throws WCDBException {\n        R ret = null;\n        PreparedStatement preparedStatement = null;\n        try {\n            preparedStatement = prepareStatement();\n            preparedStatement.step();\n            if (!preparedStatement.isDone()) {\n                ret = preparedStatement.getOneObject(fields, cls);\n            }\n        } finally {\n            if (preparedStatement != null) {\n                preparedStatement.finalizeStatement();\n            }\n            invalidateHandle();\n        }\n        return ret;\n    }\n\n    /**\n     * Get all selected objects.\n     *\n     * @return A list of objects.\n     * @throws WCDBException if any error occurs.\n     */\n    @NotNull\n    public List<T> allObjects() throws WCDBException {\n        return allObjects(Field.getBindClass(fields));\n    }\n\n    /**\n     * Get all selected objects.\n     *\n     * @param cls A derived class of java orm class.\n     * @return All selected derived class object.\n     * @throws WCDBException if any error occurs.\n     */\n    @NotNull\n    public <R extends T> List<R> allObjects(Class<R> cls) throws WCDBException {\n        List<R> ret;\n        PreparedStatement preparedStatement = null;\n        try {\n            preparedStatement = prepareStatement();\n            ret = preparedStatement.getAllObjects(fields, cls);\n        } finally {\n            if (preparedStatement != null) {\n                preparedStatement.finalizeStatement();\n            }\n            invalidateHandle();\n        }\n        return ret;\n    }\n\n    private PreparedStatement prepareStatement() throws WCDBException {\n        return handle.preparedWithMainStatement(statement);\n    }\n}\n"
  },
  {
    "path": "src/java/main/src/main/java/com/tencent/wcdb/chaincall/Update.java",
    "content": "// Created by chenqiuwen on 2023/5/2.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage com.tencent.wcdb.chaincall;\n\nimport com.tencent.wcdb.base.Value;\nimport com.tencent.wcdb.base.WCDBException;\nimport com.tencent.wcdb.core.Handle;\nimport com.tencent.wcdb.core.PreparedStatement;\nimport com.tencent.wcdb.orm.Field;\nimport com.tencent.wcdb.orm.TableBinding;\nimport com.tencent.wcdb.winq.Expression;\nimport com.tencent.wcdb.winq.ExpressionConvertible;\nimport com.tencent.wcdb.winq.OrderingTerm;\nimport com.tencent.wcdb.winq.StatementUpdate;\n\nimport org.jetbrains.annotations.NotNull;\nimport org.jetbrains.annotations.Nullable;\n\npublic class Update<T> extends ChainCall<StatementUpdate> {\n    private Field<T>[] fields = null;\n    private T object = null;\n    private Value[] row = null;\n\n    public Update(@NotNull Handle handle, boolean needChanges, boolean autoInvalidateHandle) {\n        super(handle, needChanges, autoInvalidateHandle);\n        statement = new StatementUpdate();\n    }\n\n    /**\n     * WINQ interface for SQL.\n     *\n     * @param table The name of the table to update content.\n     * @return this.\n     */\n    @NotNull\n    public Update<T> table(@NotNull String table) {\n        statement.update(table);\n        return this;\n    }\n\n    /**\n     * WINQ interface for SQL.\n     *\n     * @param fields The fields used to specify the columns where data is updated.\n     * @return this.\n     */\n    @SafeVarargs\n    @NotNull\n    public final Update<T> set(@NotNull Field<T>... fields) {\n        this.fields = fields;\n        statement.setColumnsToBindParameters(fields);\n        return this;\n    }\n\n    /**\n     * WINQ interface for SQL.\n     *\n     * @param object The object to be updated into table.\n     * @return this.\n     */\n    @NotNull\n    public Update<T> toObject(@Nullable T object) {\n        this.object = object;\n        return this;\n    }\n\n    /**\n     * WINQ interface for SQL.\n     *\n     * @param value Value to be updated into table.\n     * @return this.\n     */\n    @NotNull\n    public Update<T> toValue(@Nullable Value value) {\n        return toRow(value);\n    }\n\n    /**\n     * WINQ interface for SQL.\n     *\n     * @param value Byte value to be updated into table.\n     * @return this.\n     */\n    @NotNull\n    public Update<T> toValue(byte value) {\n        return toRow(new Value(value));\n    }\n\n    /**\n     * WINQ interface for SQL.\n     *\n     * @param value Short value to be updated into table.\n     * @return this.\n     */\n    @NotNull\n    public Update<T> toValue(short value) {\n        return toRow(new Value(value));\n    }\n\n    /**\n     * WINQ interface for SQL.\n     *\n     * @param value Int value to be updated into table.\n     * @return this.\n     */\n    @NotNull\n    public Update<T> toValue(int value) {\n        return toRow(new Value(value));\n    }\n\n    /**\n     * WINQ interface for SQL.\n     *\n     * @param value Long value to be updated into table.\n     * @return this.\n     */\n    @NotNull\n    public Update<T> toValue(long value) {\n        return toRow(new Value(value));\n    }\n\n    /**\n     * WINQ interface for SQL.\n     *\n     * @param value String value to be updated into table.\n     * @return this.\n     */\n    @NotNull\n    public Update<T> toValue(@Nullable String value) {\n\n        return toRow(new Value(value));\n    }\n\n    /**\n     * WINQ interface for SQL.\n     *\n     * @param value Byte[] value to be updated into table.\n     * @return this.\n     */\n    @NotNull\n    public Update<T> toValue(@Nullable byte[] value) {\n        return toRow(new Value(value));\n    }\n\n    /**\n     * WINQ interface for SQL.\n     *\n     * @param value Float value to be updated into table.\n     * @return this.\n     */\n    @NotNull\n    public Update<T> toValue(float value) {\n        return toRow(new Value(value));\n    }\n\n    /**\n     * WINQ interface for SQL.\n     *\n     * @param value Double value to be updated into table.\n     * @return this.\n     */\n    @NotNull\n    public Update<T> toValue(double value) {\n        return toRow(new Value(value));\n    }\n\n    /**\n     * WINQ interface for SQL.\n     *\n     * @param row The row to be updated into table.\n     * @return this.\n     */\n    @NotNull\n    public Update<T> toRow(@Nullable Value... row) {\n        this.row = row;\n        return this;\n    }\n\n    /**\n     * WINQ interface for SQL.\n     *\n     * @param condition condition.\n     * @return this.\n     */\n    @NotNull\n    public Update<T> where(@Nullable Expression condition) {\n        statement.where(condition);\n        return this;\n    }\n\n    /**\n     * WINQ interface for SQL.\n     *\n     * @param order order term.\n     * @return this.\n     */\n    @NotNull\n    public Update<T> orderBy(@Nullable OrderingTerm order) {\n        statement.orderBy(order);\n        return this;\n    }\n\n    /**\n     * WINQ interface for SQL.\n     *\n     * @param orders Order list.\n     * @return this.\n     */\n    @NotNull\n    public Update<T> orderBy(@Nullable OrderingTerm... orders) {\n        statement.orderBy(orders);\n        return this;\n    }\n\n    /**\n     * WINQ interface for SQL.\n     *\n     * @param count limit count.\n     * @return this.\n     */\n    @NotNull\n    public Update<T> limit(short count) {\n        statement.limit(count);\n        return this;\n    }\n\n    /**\n     * WINQ interface for SQL.\n     *\n     * @param count limit count.\n     * @return this.\n     */\n    @NotNull\n    public Update<T> limit(int count) {\n        statement.limit(count);\n        return this;\n    }\n\n    /**\n     * WINQ interface for SQL.\n     *\n     * @param count limit count.\n     * @return this.\n     */\n    @NotNull\n    public Update<T> limit(long count) {\n        statement.limit(count);\n        return this;\n    }\n\n    /**\n     * WINQ interface for SQL.\n     *\n     * @param count limit expression.\n     * @return this.\n     */\n    @NotNull\n    public Update<T> limit(@Nullable ExpressionConvertible count) {\n        statement.limit(count);\n        return this;\n    }\n\n    /**\n     * WINQ interface for SQL.\n     *\n     * @param offset offset number.\n     * @return this.\n     */\n    @NotNull\n    public Update<T> offset(short offset) {\n        statement.offset(offset);\n        return this;\n    }\n\n    /**\n     * WINQ interface for SQL.\n     *\n     * @param offset offset number.\n     * @return this.\n     */\n    @NotNull\n    public Update<T> offset(int offset) {\n        statement.offset(offset);\n        return this;\n    }\n\n    /**\n     * WINQ interface for SQL.\n     *\n     * @param offset offset number.\n     * @return this.\n     */\n    @NotNull\n    public Update<T> offset(long offset) {\n        statement.offset(offset);\n        return this;\n    }\n\n    /**\n     * WINQ interface for SQL.\n     *\n     * @param offset offset expression.\n     * @return this.\n     */\n    @NotNull\n    public Update<T> offset(@Nullable ExpressionConvertible offset) {\n        statement.offset(offset);\n        return this;\n    }\n\n    /**\n     * Execute the update statement.\n     *\n     * @return this.\n     * @throws WCDBException if any error occurs.\n     */\n    @NotNull\n    public Update<T> execute() throws WCDBException {\n        TableBinding<T> binding = Field.getBinding(fields);\n        PreparedStatement preparedStatement = null;\n        try {\n            preparedStatement = handle.preparedWithMainStatement(statement);\n            if (object != null) {\n                preparedStatement.bindObject(object, fields);\n            } else if (row != null) {\n                preparedStatement.bindRow(row);\n            }\n            preparedStatement.step();\n            updateChanges();\n        } finally {\n            if (preparedStatement != null) {\n                preparedStatement.finalizeStatement();\n            }\n            invalidateHandle();\n        }\n        return this;\n    }\n}\n"
  },
  {
    "path": "src/java/main/src/main/java/com/tencent/wcdb/core/Database.java",
    "content": "// Created by qiuwenchen on 2023/3/30.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage com.tencent.wcdb.core;\n\nimport com.tencent.wcdb.base.CppObject;\nimport com.tencent.wcdb.base.Value;\nimport com.tencent.wcdb.base.WCDBException;\nimport com.tencent.wcdb.orm.Field;\nimport com.tencent.wcdb.winq.Expression;\n\nimport org.jetbrains.annotations.NotNull;\nimport org.jetbrains.annotations.Nullable;\n\nimport java.util.HashMap;\nimport java.util.List;\nimport java.util.Map;\n\npublic class Database extends HandleORMOperation {\n    private Database() {\n    }\n\n    /**\n     * Init a database from path.\n     * All database objects with same path share the same core. So you can create multiple database objects. WCDB will manage them automatically.\n     * WCDB will not generate a sqlite db handle until the first operation, which is also called as lazy initialization.\n     *\n     * @param path Path to your database\n     */\n    public Database(@NotNull String path) {\n        cppObj = createDatabase(path, false, false);\n    }\n\n    /**\n     * Init a database from path.\n     * All database objects with same path share the same core. So you can create multiple database objects. WCDB will manage them automatically.\n     * WCDB will not generate a sqlite db handle until the first operation, which is also called as lazy initialization.\n     *\n     * Note that once a database is opened in read-only mode,\n     * it cannot be writable in the current process any more.\n     *\n     * @param path Path to your database\n     */\n    public Database(@NotNull String path, boolean readonly) {\n        cppObj = createDatabase(path, readonly, false);\n    }\n\n    /**\n     * Init a in-memory database.\n     * Since In-memory database share one DB handle among all threads, it does not support multi-threaded concurrent operation.\n     */\n    public static Database createInMemoryDatabase() {\n        long cppObj = createDatabase(\"\", false, true);\n        Database database = new Database();\n        database.cppObj = cppObj;\n        return database;\n    }\n\n    private static native long createDatabase(String path, boolean readonly, boolean inMemory);\n\n    /**\n     * Get the file path of the database.\n     */\n    @NotNull\n    public String getPath() {\n        return getPath(cppObj);\n    }\n\n    private static native String getPath(long self);\n\n    /**\n     * Set the tag of the database\n     * The {@code WCDBException} generated by the database will carry its tag.\n     * You can set the same tag for related databases for classification.\n     *\n     * @param tag The tag of the database\n     */\n    public void setTag(long tag) {\n        setTag(cppObj, tag);\n    }\n\n    private static native void setTag(long self, long tag);\n\n    /**\n     * Get the tag of the database. Tag is 0 by default.\n     */\n    public long getTag() {\n        return getTag(cppObj);\n    }\n\n    private static native long getTag(long self);\n\n    /**\n     * Check whether the database can be opened.\n     * Since WCDB is using lazy initialization, you can create an instance of {@code Database} even the database can't open.\n     *\n     * @return true if an error occurs during sqlite db handle initialization.\n     */\n    public boolean canOpen() {\n        return canOpen(cppObj);\n    }\n\n    private static native boolean canOpen(long self);\n\n    /**\n     * Check database is already opened.\n     *\n     * @return true if the databse is opened\n     */\n    public boolean isOpened() {\n        return isOpened(cppObj);\n    }\n\n    private static native boolean isOpened(long self);\n\n    public interface CloseCallBack {\n        /**\n         * Triggered on database closed.\n         *\n         * @throws WCDBException if any error occurs.\n         */\n        void onClose() throws WCDBException;\n    }\n\n    private static void onClose(@NotNull CloseCallBack callBack) throws WCDBException {\n        callBack.onClose();\n    }\n\n    /**\n     * Close the database.\n     * Since Multi-threaded operation is supported in WCDB, other operations in different thread can open the closed database.\n     * So this function can make sure database is closed in the callback. All other operations will be blocked until this function returns.\n     * A close operation consists of 4 steps:\n     * 1. blockade, which blocks all other operations.\n     * 2. close, which waits until all sqlite db handles return and closes them.\n     * 3. onClosed, which trigger the callback.\n     * 4. unblokade, which unblocks all other operations.\n     * You can simply call close: to do all steps above or call these separately.\n     * Since this function will wait until all sqlite db handles return, it may lead to deadlock in some bad practice.\n     * The key to avoid deadlock is to invalidate all alive {@code Handle} in current thread before you call this interface.\n     *\n     * @param callBack on database is closed.\n     * @throws WCDBException if any error occurs.\n     */\n    public void close(@Nullable CloseCallBack callBack) {\n        if (cppObj != 0) {\n            close(cppObj, callBack);\n        }\n    }\n\n    /**\n     * Close the database without a callback.\n     *\n     * @throws WCDBException if any error occurs。\n     * @see #close(CloseCallBack)\n     */\n    public void close() {\n        close(cppObj, null);\n    }\n\n    private static native void close(long self, CloseCallBack callBack);\n\n    /**\n     * Blockade the database.\n     *\n     * @see #close(CloseCallBack)\n     */\n    public void blockade() {\n        blockade(cppObj);\n    }\n\n    private static native void blockade(long self);\n\n    /**\n     * Unblockade the database.\n     *\n     * @see #close(CloseCallBack)\n     */\n    public void unblockade() {\n        unblockade(cppObj);\n    }\n\n    private static native void unblockade(long self);\n\n    /**\n     * Check whether database is blockaded.\n     *\n     * @return true if the database is blockaded\n     * @see #close(CloseCallBack)\n     */\n    public boolean isBlockaded() {\n        return isBlockaded(cppObj);\n    }\n\n    private static native boolean isBlockaded(long self);\n\n    /**\n     * Create a {@code Handle} for current database.\n     * {@code Handle} is a wrapper for sqlite db handle of type {@code sqlite3*},\n     * and the sqlite db handle is lazy initialized and will not be actually generated until the first operation on current handle takes place.\n     * Note that All {@code Handle} created by the current database in the current thread will share the same sqlite db handle internally,\n     * so it can avoid the deadlock between different sqlite db handles in some extreme cases.\n     *\n     * @return A {@code Handle} object.\n     */\n    @NotNull\n    public Handle getHandle() {\n        return new Handle(this, false);\n    }\n\n    /**\n     * Create a {@code Handle} for current database.\n     *\n     * @param writeHint a hint as to whether the current handle will be used to write content\n     * @return A {@code Handle}object.\n     * @see #getHandle()\n     */\n    @Override\n    @NotNull\n    public Handle getHandle(boolean writeHint) {\n        return new Handle(this, writeHint);\n    }\n\n    static native long getHandle(long self, boolean writeHint);\n\n    /**\n     * Purge all free memory of this database.\n     * WCDB will cache and reuse some sqlite db handles to improve performance.\n     * The max count of free sqlite db handles is same as the number of concurrent threads supported by the hardware implementation.\n     * You can call it to save some memory.\n     */\n    public void purge() {\n        purge(cppObj);\n    }\n\n    private static native void purge(long self);\n\n    /**\n     * Purge all free memory of all databases.\n     *\n     * @see #purge()\n     */\n    public static native void purgeAll();\n\n    /**\n     * Get number of alive handles of current database.\n     *\n     * @return number of alive handles.\n     */\n    public int getNumberOfAliveHandle() {\n        return getNumberOfAliveHandle(cppObj);\n    }\n\n    private static native int getNumberOfAliveHandle(long self);\n\n    /**\n     * Use {@code sqlite3_release_memory} internally to free memory.\n     *\n     * @param bytes Number of bytes need to be freed.\n     */\n    public static native void releaseSQLiteMemory(int bytes);\n\n    /**\n     * Use {@code sqlite3_soft_heap_limit64} internally to set soft limit of heap memory\n     *\n     * @param limit Number of bytes to limit.\n     */\n    public static native void setSoftHeapLimit(long limit);\n\n    public interface ProgressMonitor {\n        /**\n         * Triggered when operation progresses, you can return false to stop the operation.\n         *\n         * @param percentage The percentage of current status.\n         * @param increment  The increment from last status.\n         * @return True to continue current operation.\n         */\n        boolean onProgressUpdate(double percentage, double increment);\n    }\n\n    private static boolean onProgressUpdate(ProgressMonitor progress, double percentage, double increment) {\n        return progress.onProgressUpdate(percentage, increment);\n    }\n\n    /**\n     * Vacuum current database.\n     * It can be used to vacuum a database of any size with limited memory usage.\n     *\n     * @param monitor A progress monitor.\n     * @throws WCDBException if any error occurs.\n     */\n    public void vacuum(@Nullable ProgressMonitor monitor) throws WCDBException {\n        if (!vacuum(cppObj, monitor)) {\n            throw createException();\n        }\n    }\n\n    private static native boolean vacuum(long self, ProgressMonitor monitor);\n\n    /**\n     * The wrapper of {@code PRAGMA auto_vacuum}\n     */\n    public void enableAutoVacuum(boolean incremental) {\n        enableAutoVacuum(cppObj, incremental);\n    }\n\n    private static native void enableAutoVacuum(long self, boolean incremental);\n\n    /**\n     * The wrapper of {@code PRAGMA incremental_vacuum}\n     */\n    public void incrementalVacuum(int pages) throws WCDBException {\n        if (!incrementalVacuum(cppObj, pages)) {\n            throw createException();\n        }\n    }\n\n    private static native boolean incrementalVacuum(long self, int pages);\n\n    WCDBException createException() {\n        return WCDBException.createException(getError(cppObj));\n    }\n\n    private static WCDBException createThreadedException() {\n        return WCDBException.createException(getThreadedError());\n    }\n\n    private static native long getError(long self);\n\n    private static native long getThreadedError();\n\n    /**\n     * Get paths to all database-related files.\n     *\n     * @return all related paths\n     */\n    @NotNull\n    public List<String> getPaths() {\n        return getPaths(cppObj);\n    }\n\n    private static native List<String> getPaths(long self);\n\n    /**\n     * Remove all database-related files.\n     *\n     * @throws WCDBException if any error occurs.\n     */\n    public void removeFiles() throws WCDBException {\n        if (!removeFiles(cppObj)) {\n            throw createException();\n        }\n    }\n\n    private static native boolean removeFiles(long self);\n\n    /**\n     * Move all database-related files to another directory safely.\n     * Since file operation is not atomic, There may be some accidents during this period.\n     * For example, app may crash while db file is moved to destination and wal file is not.\n     * Then none of destination and source contains the whole data.\n     * This interface can make sure all of your data is in source or destination.\n     *\n     * @param destination folder\n     * @throws WCDBException if any error occurs.\n     */\n    public void moveFile(@NotNull String destination) throws WCDBException {\n        if (!moveFile(cppObj, destination)) {\n            throw createException();\n        }\n    }\n\n    private static native boolean moveFile(long self, String destination);\n\n    /**\n     * Get the space used by the database files.\n     *\n     * @return number of bytes used by database files.\n     * @throws WCDBException if any error occurs.\n     */\n    public long getFileSize() throws WCDBException {\n        long ret = getFileSize(cppObj);\n        if (ret < 0) {\n            throw createException();\n        }\n        return ret;\n    }\n\n    private static native long getFileSize(long self);\n\n    /**\n     * Main version of sqlcipher\n     */\n    public enum CipherVersion {\n        defaultVersion, version1, version2, version3, version4\n    }\n\n    /**\n     * Set cipher key for a database.\n     * For an encrypted database, you must call it before all other operation.\n     * The cipher page size defaults to 4096 in WCDB, but it defaults to 1024 in other databases.\n     * So for an existing database created by other database framework, you should set it to 1024.\n     * Otherwise, you'd better to use cipher page size with 4096 or simply call setCipherKey: interface to get better performance.\n     * If your database is created with the default configuration of WCDB 1.0.x, please set cipherVersion to {@code CipherVersion.version3}.\n     *\n     * @param key      Cipher key.\n     * @param pageSize The page size of database.\n     * @param version  Main version of sqlcipher.\n     */\n    public void setCipherKey(@NotNull byte[] key, int pageSize, CipherVersion version) {\n        setCipherKey(cppObj, key, pageSize, version.ordinal());\n    }\n\n    /**\n     * Set cipher key for a database.\n     *\n     * @param key      Cipher key.\n     * @param pageSize The page size of database\n     * @see #setCipherKey(long, byte[], int, int)\n     */\n    public void setCipherKey(@NotNull byte[] key, int pageSize) {\n        setCipherKey(key, pageSize, CipherVersion.defaultVersion);\n    }\n\n    /**\n     * Set cipher key for a database.\n     *\n     * @param key Cipher key.\n     * @see #setCipherKey(long, byte[], int, int)\n     */\n    public void setCipherKey(@NotNull byte[] key) {\n        setCipherKey(key, 4096);\n    }\n\n    private static native void setCipherKey(long self, byte[] key, int pageSize, int version);\n\n    /**\n     * Force sqlcipher to operate with the default settings consistent with that major version number as the default.\n     * It works the same as {@code PRAGMA cipher_default_compatibility}.\n     *\n     * @param version The specified sqlcipher major version.\n     */\n    public static void setDefaultCipherVersion(CipherVersion version) {\n        setDefaultCipherVersion(version.ordinal());\n    }\n\n    private static native void setDefaultCipherVersion(int version);\n\n\n    public interface Config {\n        /**\n         * Triggered when a handle is opened, reused, invalidated or closed.\n         *\n         * @param handle The handle need to be configured.\n         * @throws WCDBException if any error occurs.\n         */\n        void onInvocation(@NotNull Handle handle) throws WCDBException;\n    }\n\n    private static boolean onConfig(long cppHandle, Config config) {\n        Handle handle = new Handle(cppHandle, null);\n        boolean ret = true;\n        try {\n            config.onInvocation(handle);\n        } catch (WCDBException e) {\n            ret = false;\n        }\n        return ret;\n    }\n\n\n    /**\n     * Priority of config.\n     * The higher the priority, the earlier it will be executed.\n     * Note that the highest priority is only for cipher config.\n     */\n    public enum ConfigPriority {\n        low, default_, high, highest\n    }\n\n    /**\n     * Set config for this database.\n     * Since WCDB is a multi-handle database, an executing handle will not apply this config immediately.\n     * Instead, all handles will run this config before its next operation.\n     * Note that if you want to add cipher config, please use {@code ConfigPriority.highest}.\n     *\n     * @param configName   name of config. It should be different from each other.\n     * @param invocation   a config will be triggered when a handle is open or reuse.\n     * @param unInvocation a config will be triggered when a handle is invalidated or closed.\n     * @param priority     priority of config. It determines the execute order of configs.\n     */\n    public void setConfig(@NotNull String configName, @Nullable Config invocation, @Nullable Config unInvocation, ConfigPriority priority) {\n        int cppPriority = 0;\n        switch (priority) {\n            case low:\n                cppPriority = 100;\n                break;\n            case high:\n                cppPriority = -100;\n                break;\n            case highest:\n                cppPriority = -2147483648;\n                break;\n        }\n        setConfig(cppObj, configName, invocation, unInvocation, cppPriority);\n    }\n\n    /**\n     * Set config for this database.\n     *\n     * @param configName The name of config. It should be different from each other.\n     * @param invocation A config will be triggered when a handle is open or reuse.\n     * @param priority   Priority of config. It determines the execute order of configs.\n     * @see #setConfig(String, Config, Config, ConfigPriority)\n     */\n    public void setConfig(@NotNull String configName, @Nullable Config invocation, ConfigPriority priority) {\n        setConfig(configName, invocation, null, priority);\n    }\n\n    /**\n     * Set config for this database with default priority.\n     *\n     * @param configName The name of config. It should be different from each other.\n     * @param invocation A config will be triggered when a handle is open or reuse.\n     * @see #setConfig(String, Config, Config, ConfigPriority)\n     */\n    public void setConfig(@NotNull String configName, @Nullable Config invocation) {\n        setConfig(configName, invocation, ConfigPriority.default_);\n    }\n\n    private static native void setConfig(long self, String configName, Config invocation, Config unInvocation, int priority);\n\n    /**\n     * Enable/Disable Lite mode.\n     * Lite mode is disabled by default.\n     * In lite mode, the journal mode and synchronous flag of current database will be set to `OFF`,\n     * which will significantly reduces IO, improve performance, and also increase the probability of data corruption.\n     * Note that you can not rollback transaction or backup data in lite mode.\n     *\n     * @param enable A flag to enable lite mode\n     */\n    public void enableLiteMode(boolean enable) {\n        enableLiteMode(cppObj, enable);\n    }\n\n    private static native void enableLiteMode(long self, boolean enable);\n\n    public static class PerformanceInfo {\n        public int tablePageReadCount;\n        public int tablePageWriteCount;\n        public int indexPageReadCount;\n        public int indexPageWriteCount;\n        public int overflowPageReadCount;\n        public int overflowPageWriteCount;\n        public long costInNanoseconds;\n    }\n\n    public interface PerformanceTracer {\n        /**\n         * Triggered when a transaction or a normal sql ends.\n         *\n         * @param tag      Tag of the database where sql is executed\n         * @param path     Path of the database where sql is executed\n         * @param handleId Id of the handle where sql is executed\n         * @param sql      The executed sql.\n         * @param info     Detail performance Info.\n         */\n        void onTrace(long tag, @NotNull String path, long handleId, @NotNull String sql, @NotNull PerformanceInfo info);\n    }\n\n    private static void onTracePerformance(PerformanceTracer tracer, long tag, String path, long handleId, String sql, long costInNanoseconds, int[] infoValues) {\n        PerformanceInfo info = null;\n        if (infoValues != null && infoValues.length == 6) {\n            info = new PerformanceInfo();\n            info.tablePageReadCount = infoValues[0];\n            info.tablePageWriteCount = infoValues[1];\n            info.indexPageReadCount = infoValues[2];\n            info.indexPageWriteCount = infoValues[3];\n            info.overflowPageReadCount = infoValues[4];\n            info.overflowPageWriteCount = infoValues[5];\n            info.costInNanoseconds = costInNanoseconds;\n        }\n        assert info != null;\n        tracer.onTrace(tag, path, handleId, sql, info);\n    }\n\n    /**\n     * You can register a tracer to monitor the performance of all SQLs.\n     * It returns\n     * 1. Every SQL executed by the database.\n     * 2. Time consuming in nanoseconds.\n     * 3. Number of reads and writes on different types of db pages.\n     * 4. Tag of database.\n     * 5. Path of database.\n     * 6. The id of the handle executing this SQL.\n     * You should register trace before all db operations. Global tracer and db tracer do not interfere with each other.\n     * Note that trace may cause WCDB performance degradation, according to your needs to choose whether to open.\n     *\n     * @param tracer of performance.\n     */\n    public static native void globalTracePerformance(@Nullable PerformanceTracer tracer);\n\n\n    /**\n     * You can register a tracer to monitor the performance of all SQLs executed in the current database.\n     *\n     * @param tracer of performance.\n     * @see #globalTracePerformance(PerformanceTracer)\n     */\n    public void tracePerformance(@Nullable PerformanceTracer tracer) {\n        tracePerformance(cppObj, tracer);\n    }\n\n    private static native void tracePerformance(long self, PerformanceTracer tracer);\n\n\n    public interface SQLTracer {\n        /**\n         * Triggered when a SQL is executed.\n         *\n         * @param tag      Tag of the database where sql is executed.\n         * @param path     Path of the database where sql is executed.\n         * @param handleId Id of the handle where sql is executed.\n         * @param sql      The executed sql.\n         * @param info     The detail info of executed sql. It is valid only when full sql trace is enable.\n         */\n        void onTrace(long tag, @NotNull String path, long handleId, @NotNull String sql, @NotNull String info);\n    }\n\n    private static void onTraceSQL(SQLTracer tracer, long tag, String path, long handleId, String sql, String info) {\n        tracer.onTrace(tag, path, handleId, sql, info);\n    }\n\n    /**\n     * You can register a tracer to monitor the execution of all SQLs.\n     * It returns:\n     * 1. Every SQL executed by the database.\n     * 2. Tag of database.\n     * 3. Path of database.\n     * 4. The id of the handle executing this SQL.\n     * 5. Detailed execution information of SQL. It is valid only when full sql trace is enable.\n     * You should register trace before all db operations. Global tracer and db tracer do not interfere with each other.\n     * Note that tracer may cause WCDB performance degradation, according to your needs to choose whether to open.\n     *\n     * @param tracer A tracer of sql.\n     * @see #setFullSQLTraceEnable(boolean)\n     */\n    public static native void globalTraceSQL(@Nullable SQLTracer tracer);\n\n    /**\n     * You can register a tracer to monitor the execution of all SQLs executed in the current database.\n     * You should register trace before all db operations. Global tracer and db tracer do not interfere with each other.\n     *\n     * @param tracer A tracer of sql.\n     * @see #globalTraceSQL(SQLTracer)\n     */\n    public void traceSQL(@Nullable SQLTracer tracer) {\n        traceSQL(cppObj, tracer);\n    }\n\n    private static native void traceSQL(long self, SQLTracer tracer);\n\n    /**\n     * Enable to collect more SQL execution information in SQL tracer.\n     * The detailed execution information of sql will include all bind parameters, step counts of {@code SELECT} statement,\n     * last inserted rowid of {@code INSERT} statement, changes of {@code UPDATE} and {@code DELETE} statements.\n     * These information will be returned in the last parameter of {@code SQLNotification}.\n     * Collecting these information will significantly reduce the performance of WCDB,\n     * please enable it only when necessary, and disable it when unnecessary.\n     *\n     * @param enable A flag to enable full sql trace.\n     */\n    public void setFullSQLTraceEnable(boolean enable) {\n        setFullSQLTraceEnable(cppObj, enable);\n    }\n\n    private static native void setFullSQLTraceEnable(long self, boolean enable);\n\n    public interface ExceptionTracer {\n        /**\n         * Triggered synchronously before the database throws an WCDBException.\n         *\n         * @param exception The exception to be thrown.\n         */\n        void onTrace(@NotNull WCDBException exception);\n    }\n\n    private static void onTraceException(ExceptionTracer tracer, long cppError) {\n        tracer.onTrace(WCDBException.createException(cppError));\n    }\n\n    /**\n     * You can register a reporter to monitor all database exceptions.\n     *\n     * @param tracer The exception tracer.\n     */\n    public static native void globalTraceException(@Nullable ExceptionTracer tracer);\n\n    /**\n     * You can register a reporter to monitor all exceptions of current database.\n     *\n     * @param tracer The exception tracer.\n     */\n    public void traceException(@Nullable ExceptionTracer tracer) {\n        traceException(cppObj, tracer);\n    }\n\n    private static native void traceException(long self, ExceptionTracer tracer);\n\n    /**\n     * Operation type of current database.\n     */\n    public enum Operation {\n        Create, SetTag, OpenHandle\n    }\n\n    public interface OperationTracer {\n        /**\n         * Triggered when a specific event of database occurs.\n         *\n         * @param database  The database where the event occurred.\n         * @param operation The event type.\n         * @param info      Detail info of event. It is only valid when the event type is Operation.OpenHandle\n         */\n        void onTrace(@NotNull Database database, Operation operation, @NotNull HashMap<String, Value> info);\n    }\n\n    /**\n     * The following are the keys in the info from the callback of database operation monitoring.\n     */\n    public static String OperationInfoKeyHandleCount = \"HandleCount\"; // The number of alive handles to the current database.\n    public static String OperationInfoKeyOpenTime = \"OpenTime\"; // The time in microseconds spent to open and config the handle.\n    public static String OperationInfoKeyOpenCPUTime = \"OpenCPUTime\"; // The cpu time in microseconds spent to open and config the handle.\n    public static String OperationInfoKeySchemaUsage = \"SchemaUsage\"; // The memory in bytes used to store the schema in sqlite handle.\n    public static String OperationInfoKeyTableCount = \"TableCount\"; // Number of tables in current database.\n    public static String OperationInfoKeyIndexCount = \"IndexCount\"; // Number of indexes in current database.\n    public static String OperationInfoKeyTriggerCount = \"TriggerCount\"; // Number of triggers in current database.\n\n    private static void onTraceOperation(OperationTracer tracer, long cppDatabase, int cppOperation, long info) {\n        Database database = new Database();\n        database.cppObj = cppDatabase;\n        Operation operation = Operation.Create;\n        switch (cppOperation) {\n            case 1:\n                operation = Operation.SetTag;\n                break;\n            case 2:\n                operation = Operation.OpenHandle;\n                break;\n        }\n        HashMap<String, Value> javaInfo = new HashMap<>();\n        enumerateInfo(javaInfo, info);\n        tracer.onTrace(database, operation, javaInfo);\n    }\n\n    private static native void enumerateInfo(HashMap<String, Value> javaInfo, long cppInfo);\n\n    private static void onEnumerateInfo(HashMap<String, Value> javaInfo,\n                                        String key,\n                                        int type,\n                                        long intValue,\n                                        double doubleValue,\n                                        String stringValue) {\n        if (type == 3) {\n            javaInfo.put(key, new Value(intValue));\n        } else if (type == 5) {\n            javaInfo.put(key, new Value(doubleValue));\n        } else if (type == 6) {\n            javaInfo.put(key, new Value(stringValue));\n        }\n    }\n\n    /**\n     * You can register a tracer to these database events:\n     * 1. creating a database object for the first time;\n     * 2. setting a tag on the database;\n     * 3. opening a new database handle.\n     *\n     * @param tracer The tracer to event.\n     * @see com.tencent.wcdb.core.Database.OperationTracer\n     */\n    public static native void globalTraceDatabaseOperation(@Nullable OperationTracer tracer);\n\n    public interface BusyTracer {\n        /**\n         * Triggered synchronously when the database operation is blocked.\n         *\n         * @param tag  Tag of database being busy.\n         * @param path Path of database being busy.\n         * @param tid  The id of the thread being waited on.\n         * @param sql  The sql executing in the thread being waited on.\n         */\n        void onTrace(long tag, @NotNull String path, long tid, @NotNull String sql);\n    }\n\n    /**\n     * You can register a tracer to database busy events.\n     * It returns:\n     * 1. Tag of database being busy.\n     * 2. Path of database being busy.\n     * 3. ID of the thread being waited on.\n     * 4. SQL executing in the thread being waited on.\n     * Since the tracer will be called back synchronously when the database operation is blocked and times out,\n     * you can neither directly access the busy database nor perform heavy operation in the tracer.\n     *\n     * @param tracer  The tracer of busy event.\n     * @param timeOut Timeout in seconds for blocking database operation.\n     */\n    public static native void globalTraceBusy(@Nullable BusyTracer tracer, double timeOut);\n\n    private static void onBusyTrace(BusyTracer tracer, long tag, String path, long tid, String sql) {\n        tracer.onTrace(tag, path, tid, sql);\n    }\n\n    /**\n     * Setup tokenizer with name for current database.\n     * You can use the builtin tokenizers defined in {@link com.tencent.wcdb.fts.BuiltinTokenizer}.\n     *\n     * @param tokenizer Name of tokenizer.\n     * @see com.tencent.wcdb.fts.BuiltinTokenizer\n     */\n    public void addTokenizer(@NotNull String tokenizer) {\n        addTokenizer(cppObj, tokenizer);\n    }\n\n    private static native void addTokenizer(long self, String tokenizer);\n\n    /**\n     * Configure the mapping relationship between Chinese characters and their pinyin.\n     * It is designed for the builtin pinyin tokenizer.\n     *\n     * @param pinyinDict The keys are Chinese characters, and the values are the corresponding pinyin lists.\n     * @see com.tencent.wcdb.fts.BuiltinTokenizer#Pinyin\n     */\n    public static void configPinyinDict(@NotNull Map<String, List<String>> pinyinDict) {\n        String[] keys = pinyinDict.keySet().toArray(new String[0]);\n        if (keys.length == 0) {\n            return;\n        }\n        String[][] values = new String[keys.length][];\n        for (int i = 0; i < keys.length; i++) {\n            List<String> pinyin = pinyinDict.get(keys[i]);\n            if (pinyin == null) {\n                continue;\n            }\n            values[i] = pinyin.toArray(new String[0]);\n        }\n        configPinyinDict(keys, values);\n    }\n\n    private static native void configPinyinDict(String[] keys, String[][] values);\n\n    /**\n     * Configure the mapping relationship between traditional Chinese characters and simplified Chinese characters.\n     * This is designed for the tokenizers configured with SimplifyChinese.\n     *\n     * @param traditionalChineseDict The keys are simplified Chinese characters, and the values are the corresponding Traditional Chinese characters.\n     * @see com.tencent.wcdb.fts.BuiltinTokenizer.Parameter#SimplifyChinese\n     */\n    public static void configTraditionalChineseDict(@NotNull Map<String, String> traditionalChineseDict) {\n        String[] keys = traditionalChineseDict.keySet().toArray(new String[0]);\n        if (keys.length == 0) {\n            return;\n        }\n        String[] values = new String[keys.length];\n        for (int i = 0; i < keys.length; i++) {\n            values[i] = traditionalChineseDict.get(keys[i]);\n        }\n        configTraditionalChineseDict(keys, values);\n    }\n\n    private static native void configTraditionalChineseDict(String[] keys, String[] values);\n\n    /**\n     * Setup auxiliary function with name for current database.\n     * You can use the auxiliary function defined in {@link com.tencent.wcdb.fts.BuiltinFTSAuxiliaryFunction}.\n     *\n     * @param auxiliaryFunction The function name.\n     */\n    public void addAuxiliaryFunction(@NotNull String auxiliaryFunction) {\n        addAuxiliaryFunction(cppObj, auxiliaryFunction);\n    }\n\n    private static native void addAuxiliaryFunction(long self, String auxiliaryFunction);\n\n    public interface CorruptionNotification {\n        /**\n         * Triggered when a database is confirmed to be corrupted.\n         *\n         * @param database The corrupted database.\n         */\n        void onCorrupted(@NotNull Database database);\n    }\n\n    private static void onCorrupted(CorruptionNotification monitor, long cppDatabase) {\n        Database database = new Database();\n        database.cppObj = cppDatabase;\n        monitor.onCorrupted(database);\n    }\n\n    /**\n     * Register database corruption notification callback.\n     * If the current database reports an error of {@code SQLITE_CORRUPT} or {@code SQLITE_NOTADB} during operation,\n     * WCDB will asynchronously use {@code PRAGMA integrity_check} to check whether this database is truly corrupted.\n     * Once confirmed, WCDB will notify you through the callback registered by this function.\n     * In the callback, you can delete the corrupted database or try to repair the database.\n     *\n     * @param monitor The corruption monitor.\n     */\n    public void setNotificationWhenCorrupted(@Nullable CorruptionNotification monitor) {\n        setNotificationWhenCorrupted(cppObj, monitor);\n    }\n\n    private static native void setNotificationWhenCorrupted(long self, CorruptionNotification monitor);\n\n    /**\n     * Check if the current database is corrupted.\n     * Since this function will check all the contents of the database until it finds something corrupted, it may take a lot of time to come to a conclusion.\n     *\n     * @return True if the current database is corrupted.\n     */\n    public boolean checkIfCorrupted() {\n        return checkIfCorrupted(cppObj);\n    }\n\n    private static native boolean checkIfCorrupted(long self);\n\n    /**\n     * Check if the current database is already observed corrupted by WCDB.\n     * It only checks a internal flag of current database.\n     *\n     * @return True if the current database is already corrupted.\n     */\n    public boolean checkIfIsAlreadyCorrupted() {\n        return checkIfIsAlreadyCorrupted(cppObj);\n    }\n\n    private static native boolean checkIfIsAlreadyCorrupted(long self);\n\n    /**\n     * Enable database to automatically backup itself after there are updates.\n     * The backup content mainly includes the SQL statements related to table creation and all leaf page numbers of each table in database.\n     * And the backup file name is the database file name plus \"-first.material\" and \"-last.material\" suffixes.\n     * Auto-backup do not degrade IO performance of the database.\n     *\n     * @param enable A flag to enable auto-backup.\n     */\n    public void enableAutoBackup(boolean enable) {\n        enableAutoBackup(cppObj, enable);\n    }\n\n    private static native void enableAutoBackup(long self, boolean enable);\n\n    /**\n     * Back up the database manually.\n     *\n     * @throws WCDBException if any error occurs.\n     * @see #enableAutoBackup(boolean)\n     */\n    public void backup() throws WCDBException {\n        if (!backup(cppObj)) {\n            throw createException();\n        }\n    }\n\n    private static native boolean backup(long self);\n\n    public interface BackupFilter {\n        /**\n         * Triggered before backup of each table.\n         * Return false to skip backup of this table.\n         *\n         * @param tableName The name of tables need to be backed up.\n         * @return True if current table needs to be backed up.\n         */\n        boolean tableShouldBeBackup(@NotNull String tableName);\n    }\n\n    private static boolean checkTableShouldBeBackup(BackupFilter filter, String tableName) {\n        return filter.tableShouldBeBackup(tableName);\n    }\n\n    /**\n     * Set a filter to tell which table should be backed up.\n     * The filter will be called for every table in database.\n     * If there are some tables that do not need to be backed up, return false when these table names are passed into the filter.\n     *\n     * @param filter A table filter.\n     */\n    public void filterBackup(@Nullable BackupFilter filter) {\n        filterBackup(cppObj, filter);\n    }\n\n    private static native void filterBackup(long self, BackupFilter filter);\n\n    /**\n     * Recover data from a corruped db.\n     * If there is a valid backup of this database, most of the uncorrupted data can be recovered,\n     * otherwise WCDB will try to read all the data that can still be accessed, starting from the first page of the database.\n     * In the extreme case where this database is not backed up and the first page is corrupted, no data can be recovered.\n     * Since repairing a database requires reading all uncorrupted data and writing them to a new database, it may take a lot of time to finish the job.\n     * During this period, you'd better display a loading view on the screen and present the processing percentage.\n     *\n     * @param monitor A progress monitor.\n     * @return Percentage of repaired data. 0 or less then 0 means data recovery failed. 1 means data is fully recovered.\n     * @throws WCDBException if any error occurs.\n     */\n    public double retrieve(@Nullable ProgressMonitor monitor) throws WCDBException {\n        double score = retrieve(cppObj, monitor);\n        if (score < 0) {\n            throw createException();\n        }\n        return score;\n    }\n\n    private static native double retrieve(long self, ProgressMonitor monitor);\n\n    /**\n     * Move the current database to a temporary directory and create a new database at current path.\n     * This method is designed for conditions where the database is corrupted and cannot be repaired temporarily.\n     * It can deposit the corrupted database to a new location and create a temporary database for the user.\n     * The contents of the deposited database will be restored when you recover the database.\n     * This function can be called multiple times without loss of data.\n     *\n     * @throws WCDBException if any error occurs.\n     */\n    public void deposit() throws WCDBException {\n        if (!deposit(cppObj)) {\n            throw createException();\n        }\n    }\n\n    private static native boolean deposit(long self);\n\n    /**\n     * Remove deposited data.\n     *\n     * @throws WCDBException if any error occurs.\n     * @see #deposit()\n     */\n    public void removeDepositedFiles() throws WCDBException {\n        if (!removeDepositedFiles(cppObj)) {\n            throw createException();\n        }\n    }\n\n    private static native boolean removeDepositedFiles(long self);\n\n    /**\n     * Check whether there is deposited data.\n     *\n     * @return True if deposited data exists.\n     * @see #deposit()\n     */\n    public boolean containDepositedFiles() {\n        return containDepositedFiles(cppObj);\n    }\n\n    private static native boolean containDepositedFiles(long self);\n\n    /**\n     * Checkpoint the current database with passive mode.\n     *\n     * @throws WCDBException if any error occurs.\n     */\n    public void passiveCheckpoint() throws WCDBException {\n        if (!passiveCheckpoint(cppObj)) {\n            throw createException();\n        }\n    }\n\n    private static native boolean passiveCheckpoint(long self);\n\n    /**\n     * Checkpoint the current database with truncate mode.\n     *\n     * @throws WCDBException if any error occurs.\n     */\n    public void truncateCheckpoint() throws WCDBException {\n        if (!truncateCheckpoint(cppObj)) {\n            throw createException();\n        }\n    }\n\n    private static native boolean truncateCheckpoint(long self);\n\n    /**\n     * Enable to auto checkpoint current database.\n     * By default, WCDB performs checkpoints on all databases asynchronously.\n     * This method is only used for testing.\n     * Note that auto-backup of the database also relies on auto-checkpoint.\n     * The auto-backup will also disable when auto-checkpoint is disable.\n     *\n     * @param enable A flag to enable auto-checkpoint.\n     */\n    public void setAutoCheckpointEnable(boolean enable) {\n        setAutoCheckpointEnable(cppObj, enable);\n    }\n\n    private static native void setAutoCheckpointEnable(long self, boolean enable);\n\n    public static class MigrationInfo {\n        public String table;                // Target table of migration\n        public String sourceTable;          // Source table of migration\n        public Expression filterCondition;  // Filter condition of source table\n    }\n\n    public static native void setAutoCheckpointMinFrames(int frames);\n\n    public interface MigrationFilter {\n        /**\n         * Triggered at any time when WCDB needs to know whether a table in the current database needs to migrate data,\n         * mainly including creating a new table, reading and writing a table, and starting to migrate a new table.\n         * If the current table does not need to migrate data, you need to set the sourceTable in {@link MigrationInfo} to empty string.\n         *\n         * @param info Migration configuration info of a table.\n         */\n        void filterMigrate(@NotNull MigrationInfo info);\n    }\n\n    private static void filterMigrate(MigrationFilter filter, long cppInfoSetter, long cppInfo, String table) {\n        MigrationInfo info = new MigrationInfo();\n        info.table = table;\n        filter.filterMigrate(info);\n        setMigrationInfo(cppInfoSetter, cppInfo, info.sourceTable, CppObject.get(info.filterCondition));\n    }\n\n    private static native void setMigrationInfo(long cppInfoSetter, long cppInfo, String sourceTable, long filterCondition);\n\n    /**\n     * Configure which tables in the current database need to migrate data, and the source table they need to migrate data from.\n     * Once configured, you can treat the target table as if it already has all the data of the source table, and can read and write these data through the target table.\n     * WCDB will internally convert your CRUD operations on the target table into the CRUD operations on both the target table and the source table appropriately.\n     * You neither need to be aware of the existence of the source table, nor care about the progress of data migration.\n     * Note that The column definition of the target table must be exactly the same as the column definition of the source table.\n     * The database does not record the state of the migration to disk, so if you have data to migrate, you need to use this function to configure the migration before executing any statements on current database.\n     * If the source table is in the current database, you can set sourcePath to empty string.\n     * If the source table is not in the current database, the database containing the source table will be attached to the current database before the migration is complete. After migration, source tables will be dropped.\n     *\n     * @param sourcePath   Path of the source database for migration. It must be null if this is not a cross-database migration.\n     * @param sourceCipher Cipher of the source database for migration. It must be null if this is not a cross-database migration.\n     * @param filter       A filter to config migration relationship of all tables.\n     */\n    public void addMigrationSource(@NotNull String sourcePath, @Nullable byte[] sourceCipher, @NotNull MigrationFilter filter) {\n        addMigrationSource(cppObj, sourcePath, sourceCipher, filter);\n    }\n\n\n    /**\n     * Configure which tables in the current database need to migrate data, and the source table they need to migrate data from.\n     *\n     * @param sourcePath Path of the source database for migration. It must be null if this is not a cross-database migration.\n     * @param filter     A filter to config migration relationship of all tables.\n     * @see #addMigrationSource(String, byte[], MigrationFilter)\n     */\n    public void addMigrationSource(@NotNull String sourcePath, @NotNull MigrationFilter filter) {\n        addMigrationSource(sourcePath, null, filter);\n    }\n\n    private static native void addMigrationSource(long self, String sourcePath, byte[] sourceCipher, MigrationFilter filter);\n\n    /**\n     * Manually spend about 0.01 sec. to migrate data.\n     * You can call this function periodically until all data is migrated.\n     *\n     * @throws WCDBException if any error occurs.\n     */\n    public void stepMigration() throws WCDBException {\n        if (!stepMigration(cppObj)) {\n            throw createException();\n        }\n    }\n\n    private static native boolean stepMigration(long self);\n\n    /**\n     * Configure the database to automatically step migration every two seconds.\n     *\n     * @param enable A flag to enable auto-migration.\n     */\n    public void enableAutoMigration(boolean enable) {\n        enableAutoMigration(cppObj, enable);\n    }\n\n    private static native void enableAutoMigration(long self, boolean enable);\n\n    public interface MigrationNotification {\n        /**\n         * Triggered when a table or a database is migrated completely.\n         * When a table is migrated successfully, tableInfo will carry the information of the table.\n         * When a database is migrated, info has no value.\n         *\n         * @param database The target database being migrated.\n         * @param info     Table info of migration.\n         */\n        void onMigrated(@NotNull Database database, @Nullable MigrationInfo info);\n    }\n\n    private static void onTableMigrated(MigrationNotification notification, long cppDatabase, String table, String sourceTable) {\n        Database database = new Database();\n        database.cppObj = cppDatabase;\n        MigrationInfo info = null;\n        if (table != null && table.length() > 0) {\n            info = new MigrationInfo();\n            info.table = table;\n            info.sourceTable = sourceTable;\n        }\n        notification.onMigrated(database, info);\n    }\n\n    /**\n     * Register a callback for migration notification.\n     * The callback will be called when each table completes the migration.\n     *\n     * @param notification A notification callback.\n     */\n    public void setNotificationWhenMigrated(@Nullable MigrationNotification notification) {\n        setNotificationWhenMigrated(cppObj, notification);\n    }\n\n    private static native void setNotificationWhenMigrated(long self, MigrationNotification notification);\n\n    /**\n     * Check if all tables in the database has finished migration.\n     * It only check an internal flag of database.\n     *\n     * @return True if all tables in the database has finished migration.\n     */\n    public boolean isMigrated() {\n        return isMigrated(cppObj);\n    }\n\n    private static native boolean isMigrated(long self);\n\n    /**\n     * Train a zstd formalized dict with a set of sample strings.\n     * Note that the total size of all samples cannot exceed 4G.\n     *\n     * @param samples sample strings.\n     * @param dictId  Id of the result id. DictId must be an integer between 1 and 999.\n     * @return A new zstd dict.\n     * @throws WCDBException if any error occurs.\n     */\n    @NotNull\n    public static byte[] trainDictWithString(@NotNull List<String> samples, byte dictId) throws WCDBException {\n        byte[] dict = trainDict(samples.toArray(new String[0]), dictId);\n        if (dict == null || dict.length == 0) {\n            throw createThreadedException();\n        }\n        return dict;\n    }\n\n    private static native byte[] trainDict(String[] samples, byte dictId);\n\n    /**\n     * Train a zstd formalized dict with a set of sample datas.\n     * Note that the total size of all samples cannot exceed 4G.\n     *\n     * @param samples sample data.\n     * @param dictId  Id of the result id. DictId must be an integer between 1 and 999.\n     * @return A new zstd dict.\n     * @throws WCDBException if any error occurs.\n     */\n    @NotNull\n    public static byte[] trainDictWithData(@NotNull List<byte[]> samples, byte dictId) throws WCDBException {\n        byte[] dict = trainDict(samples.toArray(new byte[0][]), dictId);\n        if (dict == null || dict.length == 0) {\n            throw createThreadedException();\n        }\n        return dict;\n    }\n\n    private static native byte[] trainDict(byte[][] samples, byte dictId);\n\n    /**\n     * Register a zstd dict in to WCDB.\n     * You must register a dict before using it.\n     *\n     * @param dict   Dict data\n     * @param dictId Id of the dict.\n     * @throws WCDBException if any error occurs.\n     */\n    public static void registerDict(@NotNull byte[] dict, byte dictId) throws WCDBException {\n        if (!nativeRegisterDict(dict, dictId)) {\n            throw createThreadedException();\n        }\n    }\n\n    private static native boolean nativeRegisterDict(byte[] dict, byte dictId);\n\n    public static final long DictDefaultMatchValue = Long.MAX_VALUE;\n\n    public static class CompressionInfo {\n        public String table; // The table to be compressed.\n\n        /**\n         * Configure to compress all data in the specified column with the default zstd compression algorithm.\n         *\n         * @param field The column to be compressed.\n         */\n        public <T> void addZSTDNormalCompress(@NotNull Field<T> field) {\n            Database.addZSTDNormalCompress(cppInfo, CppObject.get(field));\n        }\n\n        /**\n         * Configure to compress all data in the specified column with a registered zstd dict.\n         *\n         * @param field  The column to be compressed.\n         * @param dictId The id of zstd dict to use.\n         */\n        public <T> void addZSTDDictCompress(@NotNull Field<T> field, byte dictId) {\n            Database.addZSTDDictCompress(cppInfo, CppObject.get(field), dictId);\n        }\n\n        /**\n         * Enable to replace original compression format.\n         * After activation, you can use {@link Database#stepCompression()} and {@link Database#enableAutoCompression(boolean)}\n         * to recompress the existing data with the new compression configuration.\n         */\n        public <T> void enableReplaceCompression() {\n            Database.enableReplaceCompression(cppInfo);\n        }\n\n        /**\n         * Configure to compress all data in the specified column with multi registered zstd dict.\n         * Which dict to use when compressing is based on the value of the specified matching column.\n         * Note that you can use {@code DictDefaultMatchValue} to specify a default dict.\n         *\n         * @param field      The column to be compressed.\n         * @param matchField The column used to distinguish different dict.\n         * @param dicts      The matching relationship between the dict id and the value of the matching column.\n         */\n        public <T> void addZSTDMultiDictCompress(@NotNull Field<T> field, @NotNull Field<T> matchField, @NotNull Map<Long, Byte> dicts) {\n            long[] values = new long[dicts.size()];\n            byte[] dictIds = new byte[dicts.size()];\n            int index = 0;\n            for (Map.Entry<Long, Byte> entry : dicts.entrySet()) {\n                values[index] = entry.getKey();\n                dictIds[index] = entry.getValue();\n                index++;\n            }\n            Database.addZSTDMultiDictCompress(cppInfo, CppObject.get(field), CppObject.get(matchField), values, dictIds);\n        }\n\n        CompressionInfo(long cppInfo, String table) {\n            this.cppInfo = cppInfo;\n            this.table = table;\n        }\n\n        private long cppInfo;\n    }\n\n    private static native void addZSTDNormalCompress(long cppInfo, long cppColumn);\n\n    private static native void addZSTDDictCompress(long cppInfo, long cppColumn, byte dictId);\n\n    private static native void addZSTDMultiDictCompress(long cppInfo, long cppColumn, long cppMatchColumn, long[] values, byte[] dictIds);\n\n    private static native void enableReplaceCompression(long cppInfo);\n\n    public interface CompressionFilter {\n        /**\n         * Triggered at any time when WCDB needs to know whether a table in the current database needs to compress data,\n         * mainly including creating a new table, reading and writing a table,and starting to compress a new table.\n         * If the current table does not need to compress data, you don't need to config CompressionInfo.\n         *\n         * @param info An object used to configure the compression.\n         */\n        void filterCompress(@NotNull CompressionInfo info);\n    }\n\n    private static void filterCompress(CompressionFilter filter, long cppInfo, String table) {\n        CompressionInfo info = new CompressionInfo(cppInfo, table);\n        filter.filterCompress(info);\n    }\n\n    /**\n     * Configure which tables in the current database need to compress data.\n     * Once configured, newly written data will be compressed immediately and synchronously,\n     * and you can use {@link Database#stepCompression()} and {@link Database#enableAutoCompression(boolean)} to compress existing data.\n     * Note that you need to use this method to configure the compression before executing any statements on current database.\n     *\n     * @param filter A filter to config compression.\n     */\n    public void setCompression(@Nullable CompressionFilter filter) {\n        setCompression(cppObj, filter);\n    }\n\n    private static native void setCompression(long self, CompressionFilter filter);\n\n    /**\n     * Configure not to compress new data written to the current database.\n     * This configuration is mainly used to deal with some emergency scenarios.\n     * It allows already compressed data to be read normally, but new data is no longer compressed.\n     *\n     * @param disable disable compression or not.\n     */\n    public void disableCompressNewData(boolean disable) {\n        disableCompressNewData(cppObj, disable);\n    }\n\n    private static native void disableCompressNewData(long self, boolean disable);\n\n    /**\n     * Manually compress 100 rows of existing data.\n     * You can call this method periodically until all data is compressed.\n     *\n     * @throws WCDBException if any error occurs.\n     */\n    public void stepCompression() throws WCDBException {\n        if (!stepCompression(cppObj)) {\n            throw createException();\n        }\n    }\n\n    private static native boolean stepCompression(long self);\n\n    /**\n     * Configure the database to automatically compress 100 rows of existing data every two seconds.\n     *\n     * @param enable A flag to enable auto-compression.\n     */\n    public void enableAutoCompression(boolean enable) {\n        enableAutoCompression(cppObj, enable);\n    }\n\n    private static native void enableAutoCompression(long self, boolean enable);\n\n    public interface CompressionNotification {\n        /**\n         * Triggered when a table is compressed completely.\n         * When a table is compressed successfully, tableName will be not null.\n         * When a database is totally compressed, tableName will be null.\n         *\n         * @param database  The compressing database.\n         * @param tableName The compressed table.\n         */\n        void onCompressed(@NotNull Database database, @Nullable String tableName);\n    }\n\n    private static void onTableCompressed(CompressionNotification notification, long cppDatabase, String table) {\n        Database database = new Database();\n        database.cppObj = cppDatabase;\n        notification.onCompressed(database, table);\n    }\n\n    /**\n     * Register a callback for compression notification.\n     * The callback will be called when each table completes the compression.\n     *\n     * @param notification The notification callback.\n     */\n    public void setNotificationWhenCompressed(@Nullable CompressionNotification notification) {\n        setNotificationWhenCompressed(cppObj, notification);\n    }\n\n    private static native void setNotificationWhenCompressed(long self, CompressionNotification notification);\n\n    /**\n     * Check if all tables in the database has finished compression.\n     * It only check an internal flag of database.\n     *\n     * @return true if all tables in the database has finished compression.\n     */\n    public boolean isCompressed() {\n        return isCompressed(cppObj);\n    }\n\n    private static native boolean isCompressed(long self);\n\n    /**\n     * Decompress all compressed data in the database and resave them.\n     * It will clear all compression status and progress, and disables automatic compression.\n     * If the rollback process is interrupted or failed, the data may be in a mixed state of compressed and uncompressed.\n     *\n     * @param monitor A progress monitor.\n     * @throws WCDBException if any error occurs.\n     */\n    public void rollbackCompression(@Nullable ProgressMonitor monitor) throws WCDBException {\n        if (!rollbackCompression(cppObj, monitor)) {\n            throw createException();\n        }\n    }\n\n    private static native boolean rollbackCompression(long self, ProgressMonitor monitor);\n\n    @Override\n    boolean autoInvalidateHandle() {\n        return true;\n    }\n\n    @Override\n    Database getDatabase() {\n        return this;\n    }\n}\n"
  },
  {
    "path": "src/java/main/src/main/java/com/tencent/wcdb/core/Handle.java",
    "content": "// Created by qiuwenchen on 2023/4/19.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage com.tencent.wcdb.core;\n\nimport com.tencent.wcdb.base.CppObject;\nimport com.tencent.wcdb.base.WCDBException;\nimport com.tencent.wcdb.winq.Statement;\n\nimport org.jetbrains.annotations.NotNull;\n\npublic class Handle extends HandleORMOperation implements AutoCloseable {\n    private PreparedStatement mainStatement = null;\n    private final Database database;\n\n    private boolean writeHint = false;\n\n    Handle(Database database, boolean writeHint) {\n        this.database = database;\n        this.writeHint = writeHint;\n    }\n\n    Handle(long cppObj, Database database) {\n        this.cppObj = cppObj;\n        this.database = database;\n    }\n\n    public long getCppHandle() throws WCDBException {\n        if (cppObj == 0) {\n            assert database != null;\n            cppObj = Database.getHandle(CppObject.get(database), writeHint);\n            if (cppObj == 0) {\n                throw database.createException();\n            }\n        }\n        return cppObj;\n    }\n\n    WCDBException createException() {\n        return WCDBException.createException(getError(cppObj));\n    }\n\n    static native long getError(long self);\n\n    /**\n     * Use {@code sqlite3_prepare} internally to prepare a new statement, and wrap the {@code sqlite3_stmt} generated by {@code sqlite3_prepare} into {@link PreparedStatement} to return.\n     * If the statement has been prepared by this function before, and you have not used {@link Handle#invalidate()}, {@link Handle#close()}, {@link Handle#finalizeAllStatements()}.\n     * then you can use this function to regain the previously generated {@code sqlite3_stmt}.\n     * Note that this function is designed for the situation where you need to use multiple statements at the same time to do complex database operations.\n     * You can prepare a new statement without finalizing the previous statements, so that you can save the time of analyzing SQL syntax.\n     * If you only need to use one statement, or you no longer need to use the previous statements when you use a new statement,\n     * it is recommended to use {@link HandleOperation#execute(Statement)} or {@link Handle#preparedWithMainStatement(Statement)}.\n     *\n     * @param statement The statement to prepare.\n     * @return A wrapper of {@code sqlite3_stmt}.\n     * @throws WCDBException of any error occurs.\n     * @see #preparedWithMainStatement(Statement)\n     */\n    @NotNull\n    public PreparedStatement getOrCreatePreparedStatement(@NotNull Statement statement) throws WCDBException {\n        long cppPreparedStatement = getOrCreatePreparedStatement(getCppHandle(), CppObject.get(statement));\n        if (cppPreparedStatement == 0) {\n            throw createException();\n        }\n        return new PreparedStatement(cppPreparedStatement);\n    }\n\n    static native long getOrCreatePreparedStatement(long self, long statement);\n\n    /**\n     * Use {@code sqlite3_prepare} internally to prepare a new statement, and wrap the {@code sqlite3_stmt} generated by {@code sqlite3_prepare} into {@link PreparedStatement} to return.\n     * Note that you should not execute sql string on any migrating or compressing table.\n     *\n     * @param sql The sql string to prepare.\n     * @return A wrapper of {@code sqlite3_stmt}.\n     * @throws WCDBException of any error occurs.\n     * @see #preparedWithMainStatement(Statement)\n     */\n    @NotNull\n    public PreparedStatement getOrCreatePreparedStatement(@NotNull String sql) throws WCDBException {\n        long cppPreparedStatement = getOrCreatePreparedStatementWithSQL(getCppHandle(), sql);\n        if (cppPreparedStatement == 0) {\n            throw createException();\n        }\n        return new PreparedStatement(cppPreparedStatement);\n    }\n\n    static native long getOrCreatePreparedStatementWithSQL(long self, String sql);\n\n    /**\n     * Use {@code sqlite3_prepare} internally to prepare a new statement, each call creates a brand-new {@code sqlite3_stmt}.\n     * Unlike {@link Handle#getOrCreatePreparedStatement(Statement)}, the statement will NOT be cached internally.\n     * Unlike {@link Handle#preparedWithMainStatement(Statement)}, multiple such statements can be active at the same time.\n     * This is designed for Android cursor-like patterns where you need interleaved statement usage\n     * without occupying the main statement and without automatic caching.\n     * You MUST call {@link Handle#finalizeAndReturnPreparedStatement(PreparedStatement)} when done.\n     *\n     * @param statement The statement to prepare.\n     * @return A wrapper of {@code sqlite3_stmt}.\n     * @throws WCDBException if any error occurs.\n     * @see #finalizeAndReturnPreparedStatement(PreparedStatement)\n     */\n    @NotNull\n    public PreparedStatement prepareNewStatement(@NotNull Statement statement) throws WCDBException {\n        long cppPreparedStatement = prepareNewStatement(getCppHandle(), CppObject.get(statement));\n        if (cppPreparedStatement == 0) {\n            throw createException();\n        }\n        return new PreparedStatement(cppPreparedStatement);\n    }\n\n    static native long prepareNewStatement(long self, long statement);\n\n    /**\n     * Use {@code sqlite3_prepare} internally to prepare a new statement from SQL string.\n     * Note that you should not execute sql string on any migrating or compressing table.\n     *\n     * @param sql The sql string to prepare.\n     * @return A wrapper of {@code sqlite3_stmt}.\n     * @throws WCDBException if any error occurs.\n     * @see #prepareNewStatement(Statement)\n     * @see #finalizeAndReturnPreparedStatement(PreparedStatement)\n     */\n    @NotNull\n    public PreparedStatement prepareNewStatement(@NotNull String sql) throws WCDBException {\n        long cppPreparedStatement = prepareNewStatementWithSQL(getCppHandle(), sql);\n        if (cppPreparedStatement == 0) {\n            throw createException();\n        }\n        return new PreparedStatement(cppPreparedStatement);\n    }\n\n    static native long prepareNewStatementWithSQL(long self, String sql);\n\n    /**\n     * Finalize and return a statement previously created by {@link Handle#prepareNewStatement(Statement)}.\n     * After calling this, the statement must not be used anymore.\n     *\n     * @param stmt The statement to finalize and return.\n     */\n    public void finalizeAndReturnPreparedStatement(@NotNull PreparedStatement stmt) {\n        long stmtCppObj = CppObject.get(stmt);\n        if (cppObj != 0 && stmtCppObj != 0) {\n            finalizeAndReturnPreparedStatement(cppObj, stmtCppObj);\n        }\n    }\n\n    static native void finalizeAndReturnPreparedStatement(long self, long stmt);\n\n    /**\n     * Use {@code sqlite3_prepare} internally to prepare a new statement.\n     * You should firstly use {@link PreparedStatement#finalizeStatement()} to finalize the previous statement prepared by this method.\n     * If you need to prepare multiple statements at the same time, {@link Handle#getOrCreatePreparedStatement(Statement)} is recommended.\n     *\n     * @param statement The statement to prepare.\n     * @return A wrapper of {@code sqlite3_stmt}.\n     * @throws WCDBException of any error occurs.\n     */\n    @NotNull\n    public PreparedStatement preparedWithMainStatement(@NotNull Statement statement) throws WCDBException {\n        if (mainStatement == null) {\n            mainStatement = new PreparedStatement(getMainStatement(getCppHandle()));\n            mainStatement.autoFinalize = true;\n        }\n        mainStatement.prepare(statement);\n        return mainStatement;\n    }\n\n    /**\n     * Use {@code sqlite3_prepare} internally to prepare a new statement.\n     * Note that you should not execute sql string on any migrating or compressing table.\n     *\n     * @param sql The sql string to prepare.\n     * @return A wrapper of {@code sqlite3_stmt}.\n     * @throws WCDBException of any error occurs.\n     * @see #preparedWithMainStatement(Statement)\n     */\n    @NotNull\n    public PreparedStatement preparedWithMainStatement(@NotNull String sql) throws WCDBException {\n        if (mainStatement == null) {\n            mainStatement = new PreparedStatement(getMainStatement(getCppHandle()));\n            mainStatement.autoFinalize = true;\n        }\n        mainStatement.prepare(sql);\n        return mainStatement;\n    }\n\n    static native long getMainStatement(long self);\n\n    /**\n     * Use {@code sqlite3_finalize} to finalize all {@code sqlite3_stmt} generate by current handle.\n     * {@link Handle#invalidate()} will internally call the current function.\n     */\n    public void finalizeAllStatements() {\n        if (cppObj != 0) {\n            finalizeAllStatements(cppObj);\n        }\n    }\n\n\n    static native void finalizeAllStatements(long self);\n\n    /**\n     * Recycle the sqlite db handle inside, and the current handle will no longer be able to perform other operations.\n     * If you use obtain current handle through {@link Database#getHandle()}, you need to call its invalidate method when you are done with it, otherwise you will receive an Assert Failure.\n     */\n    public void invalidate() {\n        mainStatement = null;\n        if (cppObj != 0) {\n            releaseCPPObject(cppObj);\n            cppObj = 0;\n            writeHint = false;\n        }\n    }\n\n    /**\n     * Sample to {@link Handle#invalidate()}\n     */\n    @Override\n    public void close() {\n        invalidate();\n    }\n\n    static native int tableExist(long self, String tableName);\n\n    static native boolean execute(long self, long statement);\n\n    static native boolean executeSQL(long self, String sql);\n\n    /**\n     * The wrapper of {@code sqlite3_changes}.\n     *\n     * @return changes.\n     */\n    public int getChanges() throws WCDBException {\n        return getChanges(getCppHandle());\n    }\n\n    static native int getChanges(long self);\n\n    /**\n     * The wrapper of {@code sqlite3_total_changes}.\n     *\n     * @return changes.\n     */\n    public int getTotalChanges() throws WCDBException {\n        return getTotalChanges(getCppHandle());\n    }\n\n    static native int getTotalChanges(long self);\n\n    /**\n     * The wrapper of {@code sqlite3_last_insert_rowid}.\n     *\n     * @return the rowid of the last inserted row.\n     * @throws WCDBException if any error occurs.\n     */\n    public long getLastInsertedRowId() throws WCDBException {\n        return getLastInsertedRowId(getCppHandle());\n    }\n\n    static native long getLastInsertedRowId(long self);\n\n    static native boolean isInTransaction(long self);\n\n    static native boolean beginTransaction(long self);\n\n    static native boolean commitTransaction(long self);\n\n    static native void rollbackTransaction(long self);\n\n    @Override\n    Handle getHandle(boolean writeHint) {\n        return this;\n    }\n\n    @Override\n    Database getDatabase() {\n        return database;\n    }\n\n    @Override\n    boolean autoInvalidateHandle() {\n        return false;\n    }\n\n    private boolean onTransaction(long cppHandle, Transaction transaction) {\n        Handle handle = new Handle(cppHandle, database);\n        boolean ret;\n        try {\n            ret = transaction.insideTransaction(handle);\n        } catch (WCDBException e) {\n            ret = false;\n        }\n        return ret;\n    }\n\n    native boolean runTransaction(long self, Transaction transaction);\n\n    private int onPausableTransaction(long cppHandle, PausableTransaction transaction, boolean isNewTransaction) {\n        Handle handle = new Handle(cppHandle, database);\n        int ret;\n        try {\n            ret = transaction.insideTransaction(handle, isNewTransaction) ? 1 : 0;\n        } catch (WCDBException e) {\n            ret = 2;\n        }\n        return ret;\n    }\n\n    native boolean runPausableTransaction(long self, PausableTransaction transaction);\n\n\n    public static class CancellationSignal extends CppObject {\n        public CancellationSignal() {\n            cppObj = createCancellationSignal();\n        }\n\n        /**\n         * Cancel all operations of the attached handle.\n         */\n        public void cancel() {\n            cancelSignal(cppObj);\n        }\n    }\n\n    private static native long createCancellationSignal();\n\n    private static native void cancelSignal(long signal);\n\n    /**\n     * The wrapper of {@code sqlite3_progress_handler}.\n     * You can asynchronously cancel all operations on the current handle through {@link CancellationSignal}.\n     * Note that you can use {@link CancellationSignal} in multiple threads,\n     * but you can only use the current handle in the thread that you got it.\n     *\n     * @param signal A signal to cancel operation.\n     * @throws WCDBException if any error occurs.\n     */\n    public void attachCancellationSignal(@NotNull CancellationSignal signal) throws WCDBException {\n        attachCancellationSignal(getCppHandle(), CppObject.get(signal));\n    }\n\n    private static native void attachCancellationSignal(long self, long signal);\n\n    /**\n     * Detach the attached {@link CancellationSignal}.\n     * {@link CancellationSignal} can be automatically detached when the current handle deconstruct.\n     */\n    public void detachCancellationSignal() {\n        if (cppObj != 0) {\n            detachCancellationSignal(cppObj);\n        }\n    }\n\n    private static native void detachCancellationSignal(long self);\n\n}\n"
  },
  {
    "path": "src/java/main/src/main/java/com/tencent/wcdb/core/HandleORMOperation.java",
    "content": "// Created by chenqiuwen on 2023/5/2.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage com.tencent.wcdb.core;\n\nimport com.tencent.wcdb.base.WCDBException;\nimport com.tencent.wcdb.chaincall.Delete;\nimport com.tencent.wcdb.chaincall.Insert;\nimport com.tencent.wcdb.chaincall.Select;\nimport com.tencent.wcdb.chaincall.Update;\nimport com.tencent.wcdb.orm.Field;\nimport com.tencent.wcdb.orm.TableBinding;\nimport com.tencent.wcdb.winq.Expression;\nimport com.tencent.wcdb.winq.OrderingTerm;\nimport com.tencent.wcdb.winq.StatementDropIndex;\nimport com.tencent.wcdb.winq.StatementDropTable;\n\nimport org.jetbrains.annotations.NotNull;\nimport org.jetbrains.annotations.Nullable;\n\nimport java.util.Collection;\nimport java.util.List;\n\npublic abstract class HandleORMOperation extends HandleOperation {\n    abstract Database getDatabase();\n\n    /**\n     * Create table and indexes from ORM binding if not exists.\n     * It will run embedded transaction, and add newly defined columns automatically.\n     * The embedded transaction means that it will run a transaction if it's not in other transaction, otherwise it will be executed within the existing transaction.\n     *\n     * @param tableName This would be the name of the table and the prefix of the index names.\n     * @param binding   ORM binding of table.\n     * @throws WCDBException if any error occurs.\n     */\n    public <T> void createTable(@NotNull String tableName, @NotNull TableBinding<T> binding) throws WCDBException {\n        Handle handle = getHandle(true);\n        try {\n            if (!binding.baseBinding().createTable(tableName, handle)) {\n                throw handle.createException();\n            }\n        } finally {\n            if (autoInvalidateHandle() && handle != null) {\n                handle.invalidate();\n            }\n        }\n    }\n\n    /**\n     * Create virtual table from ORM if not exists.\n     *\n     * @param tableName The name of the virtual table to be created.\n     * @param binding   ORM binding of table.\n     * @throws WCDBException if any error occurs.\n     * @see <a href=\"http://www.sqlite.org/vtab.html\">http://www.sqlite.org/vtab.html</a>\n     */\n    public <T> void createVirtualTable(@NotNull String tableName, @NotNull TableBinding<T> binding) throws WCDBException {\n        Handle handle = getHandle(true);\n        try {\n            if (!binding.baseBinding().createVirtualTable(tableName, handle)) {\n                throw handle.createException();\n            }\n        } finally {\n            if (autoInvalidateHandle() && handle != null) {\n                handle.invalidate();\n            }\n        }\n    }\n\n    /**\n     * Check the existence of the table.\n     *\n     * @param tableName The name of the table to be checked.\n     * @return true if table exists.\n     * @throws WCDBException if any error occurs.\n     */\n    public boolean tableExist(@NotNull String tableName) throws WCDBException {\n        Handle handle = getHandle(false);\n        int ret = Handle.tableExist(handle.getCppHandle(), tableName);\n        WCDBException exception = null;\n        if (ret > 1) {\n            exception = handle.createException();\n        }\n        if (autoInvalidateHandle()) {\n            handle.invalidate();\n        }\n        if (exception != null) {\n            throw exception;\n        }\n        return ret == 1;\n    }\n\n    /**\n     * Get a wrapper from an existing table.\n     *\n     * @param tableName The name of the table.\n     * @param binding   The ORM binding of table.\n     * @return Table object.\n     */\n    @NotNull\n    public <T> Table<T> getTable(@NotNull String tableName, @NotNull TableBinding<T> binding) {\n        return new Table<T>(tableName, binding, getDatabase());\n    }\n\n    /**\n     * Drop table if exists.\n     *\n     * @param tableName The name of the table to be dropped.\n     * @throws WCDBException if any error occurs.\n     */\n    public void dropTable(@NotNull String tableName) throws WCDBException {\n        execute(new StatementDropTable().dropTable(tableName).ifExist());\n    }\n\n    /**\n     * Drop index if exists.\n     *\n     * @param indexName The name of the index to be dropped.\n     * @throws WCDBException if any error occurs.\n     */\n    public void dropIndex(@NotNull String indexName) throws WCDBException {\n        execute(new StatementDropIndex().dropIndex(indexName).ifExist());\n    }\n\n    /**\n     * Generate a {@link Insert} to do an insertion or replacement.\n     *\n     * @return An {@link Insert} object.\n     */\n    @NotNull\n    public <T> Insert<T> prepareInsert() {\n        return new Insert<T>(getHandle(true), false, autoInvalidateHandle());\n    }\n\n    /**\n     * Generate a {@link Update} to do an update.\n     *\n     * @return An {@link Update} object.\n     */\n    @NotNull\n    public <T> Update<T> prepareUpdate() {\n        return new Update<T>(getHandle(true), false, autoInvalidateHandle());\n    }\n\n    /**\n     * Generate a {@link Select} to do an object selection.\n     *\n     * @return An {@link Select} object.\n     */\n    @NotNull\n    public <T> Select<T> prepareSelect() {\n        return new Select<T>(getHandle(false), false, autoInvalidateHandle());\n    }\n\n    /**\n     * Generate a {@link Delete} to do a deletion.\n     *\n     * @return An {@link Delete} object.\n     */\n    @NotNull\n    public Delete prepareDelete() {\n        return new Delete(getHandle(true), false, autoInvalidateHandle());\n    }\n\n    /**\n     * Execute inserting with one object on specific(or all) fields.\n     *\n     * @param object    The object to insert.\n     * @param fields    specific(or all) fields.\n     * @param tableName The table to insert.\n     * @throws WCDBException if any error occurs.\n     */\n    public <T> void insertObject(@Nullable T object, @NotNull Field<T>[] fields, @NotNull String tableName) throws WCDBException {\n        this.<T>prepareInsert().intoTable(tableName).value(object).onFields(fields).execute();\n    }\n\n    /**\n     * Execute inserting with one object on specific(or all) fields.\n     * It will replace the original row while they have same primary key or row id.\n     *\n     * @param object    The object to insert.\n     * @param fields    specific(or all) fields.\n     * @param tableName The table to insert.\n     * @throws WCDBException if any error occurs.\n     */\n    public <T> void insertOrReplaceObject(@Nullable T object, @NotNull Field<T>[] fields, @NotNull String tableName) throws WCDBException {\n        this.<T>prepareInsert().orReplace().intoTable(tableName).value(object).onFields(fields).execute();\n    }\n\n    /**\n     * Execute inserting with one object on specific(or all) fields.\n     * It will ignore the object while there already exists the same primary key or row id in current table.\n     *\n     * @param object    The object to insert.\n     * @param fields    specific(or all) fields.\n     * @param tableName The table to insert.\n     * @throws WCDBException if any error occurs.\n     */\n    public <T> void insertOrIgnoreObject(@Nullable T object, @NotNull Field<T>[] fields, @NotNull String tableName) throws WCDBException {\n        this.<T>prepareInsert().orIgnore().intoTable(tableName).value(object).onFields(fields).execute();\n    }\n\n    /**\n     * Execute inserting with multi objects on specific(or all) fields.\n     * It will run embedded transaction while objects.size()>1. The embedded transaction means that it will run a transaction if it's not in other transaction, otherwise it will be executed within the existing transaction.\n     *\n     * @param objects   The objects to insert.\n     * @param fields    specific(or all) fields.\n     * @param tableName The table to insert.\n     * @throws WCDBException if any error occurs.\n     */\n    public <T> void insertObjects(@NotNull Collection<T> objects, @NotNull Field<T>[] fields, @NotNull String tableName) throws WCDBException {\n        this.<T>prepareInsert().intoTable(tableName).values(objects).onFields(fields).execute();\n    }\n\n    /**\n     * Execute inserting with multi objects on specific(or all) fields.\n     * It will replace the original row while they have same primary key or row id.\n     * It will run embedded transaction while objects.size()>1. The embedded transaction means that it will run a transaction if it's not in other transaction, otherwise it will be executed within the existing transaction.\n     *\n     * @param objects   The objects to insert.\n     * @param fields    specific(or all) fields.\n     * @param tableName The table to insert.\n     * @throws WCDBException if any error occurs.\n     */\n    public <T> void insertOrReplaceObjects(@NotNull Collection<T> objects, @NotNull Field<T>[] fields, @NotNull String tableName) throws WCDBException {\n        this.<T>prepareInsert().orReplace().intoTable(tableName).values(objects).onFields(fields).execute();\n    }\n\n    /**\n     * Execute inserting with multi objects on specific(or all) fields.\n     * It will ignore the object while there already exists the same primary key or row id in current table.\n     * It will run embedded transaction while objects.size()>1. The embedded transaction means that it will run a transaction if it's not in other transaction, otherwise it will be executed within the existing transaction.\n     *\n     * @param objects   The objects to insert.\n     * @param fields    specific(or all) fields.\n     * @param tableName The table to insert.\n     * @throws WCDBException if any error occurs.\n     */\n    public <T> void insertOrIgnoreObjects(@NotNull Collection<T> objects, @NotNull Field<T>[] fields, @NotNull String tableName) throws WCDBException {\n        this.<T>prepareInsert().orIgnore().intoTable(tableName).values(objects).onFields(fields).execute();\n    }\n\n    public void deleteObjects(@NotNull String tableName) throws WCDBException {\n        prepareDelete().fromTable(tableName).execute();\n    }\n\n    public void deleteObjects(@NotNull String tableName, @Nullable Expression condition) throws WCDBException {\n        prepareDelete().fromTable(tableName).where(condition).execute();\n    }\n\n    public void deleteObjects(@NotNull String tableName, @Nullable Expression condition, @Nullable OrderingTerm order, long limit) throws WCDBException {\n        prepareDelete().fromTable(tableName).where(condition).orderBy(order).limit(limit).execute();\n    }\n\n    public void deleteObjects(@NotNull String tableName, @Nullable Expression condition, @Nullable OrderingTerm order, long limit, long offset) throws WCDBException {\n        prepareDelete().fromTable(tableName).where(condition).orderBy(order).limit(limit).offset(offset).execute();\n    }\n\n    public void deleteObjects(@NotNull String tableName, @Nullable OrderingTerm order, long limit) throws WCDBException {\n        prepareDelete().fromTable(tableName).orderBy(order).limit(limit).execute();\n    }\n\n    public void deleteObjects(@NotNull String tableName, @Nullable OrderingTerm order, long limit, long offset) throws WCDBException {\n        prepareDelete().fromTable(tableName).orderBy(order).limit(limit).offset(offset).execute();\n    }\n\n    public <T> void updateObject(@Nullable T object, @NotNull Field<T> field, @NotNull String tableName) throws WCDBException {\n        this.<T>prepareUpdate().table(tableName).set(field).toObject(object).execute();\n    }\n\n    public <T> void updateObject(@Nullable T object, @NotNull Field<T> field, @NotNull String tableName, @Nullable Expression condition) throws WCDBException {\n        this.<T>prepareUpdate().table(tableName).set(field).toObject(object).where(condition).execute();\n    }\n\n    public <T> void updateObject(@Nullable T object, @NotNull Field<T> field, @NotNull String tableName, @Nullable Expression condition, @Nullable OrderingTerm order, long limit) throws WCDBException {\n        this.<T>prepareUpdate().table(tableName).set(field).toObject(object).where(condition).orderBy(order).limit(limit).execute();\n    }\n\n    public <T> void updateObject(@Nullable T object, @NotNull Field<T> field, @NotNull String tableName, @Nullable Expression condition, @Nullable OrderingTerm order, long limit, long offset) throws WCDBException {\n        this.<T>prepareUpdate().table(tableName).set(field).toObject(object).where(condition).orderBy(order).limit(limit).offset(offset).execute();\n    }\n\n    public <T> void updateObject(@Nullable T object, @NotNull Field<T> field, @NotNull String tableName, @Nullable OrderingTerm order, long limit) throws WCDBException {\n        this.<T>prepareUpdate().table(tableName).set(field).toObject(object).orderBy(order).limit(limit).execute();\n    }\n\n    public <T> void updateObject(@Nullable T object, @NotNull Field<T> field, @NotNull String tableName, @Nullable OrderingTerm order, long limit, long offset) throws WCDBException {\n        this.<T>prepareUpdate().table(tableName).set(field).toObject(object).orderBy(order).limit(limit).offset(offset).execute();\n    }\n\n    public <T> void updateObject(@Nullable T object, @NotNull Field<T>[] fields, @NotNull String tableName) throws WCDBException {\n        this.<T>prepareUpdate().table(tableName).set(fields).toObject(object).execute();\n    }\n\n    public <T> void updateObject(@Nullable T object, @NotNull Field<T>[] fields, @NotNull String tableName, @Nullable Expression condition) throws WCDBException {\n        this.<T>prepareUpdate().table(tableName).set(fields).toObject(object).where(condition).execute();\n    }\n\n    public <T> void updateObject(@Nullable T object, @NotNull Field<T>[] fields, @NotNull String tableName, @Nullable Expression condition, @Nullable OrderingTerm order, long limit) throws WCDBException {\n        this.<T>prepareUpdate().table(tableName).set(fields).toObject(object).where(condition).orderBy(order).limit(limit).execute();\n    }\n\n    public <T> void updateObject(@Nullable T object, @NotNull Field<T>[] fields, @NotNull String tableName, @Nullable Expression condition, @Nullable OrderingTerm order, long limit, long offset) throws WCDBException {\n        this.<T>prepareUpdate().table(tableName).set(fields).toObject(object).where(condition).orderBy(order).limit(limit).offset(offset).execute();\n    }\n\n    public <T> void updateObject(@Nullable T object, @NotNull Field<T>[] fields, @NotNull String tableName, @Nullable OrderingTerm order, long limit) throws WCDBException {\n        this.<T>prepareUpdate().table(tableName).set(fields).toObject(object).orderBy(order).limit(limit).execute();\n    }\n\n    public <T> void updateObject(@Nullable T object, @NotNull Field<T>[] fields, @NotNull String tableName, @Nullable OrderingTerm order, long limit, long offset) throws WCDBException {\n        this.<T>prepareUpdate().table(tableName).set(fields).toObject(object).orderBy(order).limit(limit).offset(offset).execute();\n    }\n\n    @Nullable\n    public <T> T getFirstObject(@NotNull Field<T>[] fields, @NotNull String tableName) throws WCDBException {\n        return this.<T>prepareSelect().select(fields).from(tableName).firstObject();\n    }\n\n    @Nullable\n    public <T, R extends T> R getFirstObject(@NotNull Field<T>[] fields, @NotNull String tableName, @NotNull Class<R> cls) throws WCDBException {\n        return this.<T>prepareSelect().select(fields).from(tableName).firstObject(cls);\n    }\n\n    @Nullable\n    public <T> T getFirstObject(@NotNull Field<T>[] fields, @NotNull String tableName, @Nullable Expression condition) throws WCDBException {\n        return this.<T>prepareSelect().select(fields).from(tableName).where(condition).firstObject();\n    }\n\n    @Nullable\n    public <T, R extends T> R getFirstObject(@NotNull Field<T>[] fields, @NotNull String tableName, @Nullable Expression condition, @NotNull Class<R> cls) throws WCDBException {\n        return this.<T>prepareSelect().select(fields).from(tableName).where(condition).firstObject(cls);\n    }\n\n    @Nullable\n    public <T> T getFirstObject(@NotNull Field<T>[] fields, @NotNull String tableName, @Nullable Expression condition, @Nullable OrderingTerm order) throws WCDBException {\n        return this.<T>prepareSelect().select(fields).from(tableName).where(condition).orderBy(order).firstObject();\n    }\n\n    @Nullable\n    public <T, R extends T> R getFirstObject(@NotNull Field<T>[] fields, @NotNull String tableName, @Nullable Expression condition, @Nullable OrderingTerm order, @NotNull Class<R> cls) throws WCDBException {\n        return this.<T>prepareSelect().select(fields).from(tableName).where(condition).orderBy(order).firstObject(cls);\n    }\n\n    @Nullable\n    public <T> T getFirstObject(@NotNull Field<T>[] fields, @NotNull String tableName, @Nullable Expression condition, @Nullable OrderingTerm order, long offset) throws WCDBException {\n        return this.<T>prepareSelect().select(fields).from(tableName).where(condition).orderBy(order).limit(1).offset(offset).firstObject();\n    }\n\n    @Nullable\n    public <T, R extends T> R getFirstObject(@NotNull Field<T>[] fields, @NotNull String tableName, @Nullable Expression condition, @Nullable OrderingTerm order, long offset, @NotNull Class<R> cls) throws WCDBException {\n        return this.<T>prepareSelect().select(fields).from(tableName).where(condition).orderBy(order).limit(1).offset(offset).firstObject(cls);\n    }\n\n    @Nullable\n    public <T> T getFirstObject(@NotNull Field<T>[] fields, @NotNull String tableName, @Nullable OrderingTerm order) throws WCDBException {\n        return this.<T>prepareSelect().select(fields).from(tableName).orderBy(order).firstObject();\n    }\n\n    @Nullable\n    public <T, R extends T> R getFirstObject(@NotNull Field<T>[] fields, @NotNull String tableName, @Nullable OrderingTerm order, @NotNull Class<R> cls) throws WCDBException {\n        return this.<T>prepareSelect().select(fields).from(tableName).orderBy(order).firstObject(cls);\n    }\n\n    @Nullable\n    public <T> T getFirstObject(@NotNull Field<T>[] fields, @NotNull String tableName, @Nullable OrderingTerm order, long offset) throws WCDBException {\n        return this.<T>prepareSelect().select(fields).from(tableName).orderBy(order).limit(1).offset(offset).firstObject();\n    }\n\n    @Nullable\n    public <T, R extends T> R getFirstObject(@NotNull Field<T>[] fields, @NotNull String tableName, @Nullable OrderingTerm order, long offset, @NotNull Class<R> cls) throws WCDBException {\n        return this.<T>prepareSelect().select(fields).from(tableName).orderBy(order).limit(1).offset(offset).firstObject(cls);\n    }\n\n    @NotNull\n    public <T> List<T> getAllObjects(@NotNull Field<T>[] fields, @NotNull String tableName) throws WCDBException {\n        return this.<T>prepareSelect().select(fields).from(tableName).allObjects();\n    }\n\n    @NotNull\n    public <T, R extends T> List<R> getAllObjects(@NotNull Field<T>[] fields, @NotNull String tableName, @NotNull Class<R> cls) throws WCDBException {\n        return this.<T>prepareSelect().select(fields).from(tableName).allObjects(cls);\n    }\n\n    @NotNull\n    public <T> List<T> getAllObjects(@NotNull Field<T>[] fields, @NotNull String tableName, @Nullable Expression condition) throws WCDBException {\n        return this.<T>prepareSelect().select(fields).from(tableName).where(condition).allObjects();\n    }\n\n    @NotNull\n    public <T, R extends T> List<R> getAllObjects(@NotNull Field<T>[] fields, @NotNull String tableName, @Nullable Expression condition, @NotNull Class<R> cls) throws WCDBException {\n        return this.<T>prepareSelect().select(fields).from(tableName).where(condition).allObjects(cls);\n    }\n\n    @NotNull\n    public <T> List<T> getAllObjects(@NotNull Field<T>[] fields, @NotNull String tableName, @Nullable Expression condition, @Nullable OrderingTerm order) throws WCDBException {\n        return this.<T>prepareSelect().select(fields).from(tableName).where(condition).orderBy(order).allObjects();\n    }\n\n    @NotNull\n    public <T, R extends T> List<R> getAllObjects(@NotNull Field<T>[] fields, @NotNull String tableName, @Nullable Expression condition, @Nullable OrderingTerm order, @NotNull Class<R> cls) throws WCDBException {\n        return this.<T>prepareSelect().select(fields).from(tableName).where(condition).orderBy(order).allObjects(cls);\n    }\n\n    @NotNull\n    public <T> List<T> getAllObjects(@NotNull Field<T>[] fields, @NotNull String tableName, @Nullable Expression condition, @Nullable OrderingTerm order, long limit) throws WCDBException {\n        return this.<T>prepareSelect().select(fields).from(tableName).where(condition).orderBy(order).limit(limit).allObjects();\n    }\n\n    @NotNull\n    public <T, R extends T> List<R> getAllObjects(@NotNull Field<T>[] fields, @NotNull String tableName, @Nullable Expression condition, @Nullable OrderingTerm order, long limit, @NotNull Class<R> cls) throws WCDBException {\n        return this.<T>prepareSelect().select(fields).from(tableName).where(condition).orderBy(order).limit(limit).allObjects(cls);\n    }\n\n    @NotNull\n    public <T> List<T> getAllObjects(@NotNull Field<T>[] fields, @NotNull String tableName, @Nullable Expression condition, @Nullable OrderingTerm order, long limit, long offset) throws WCDBException {\n        return this.<T>prepareSelect().select(fields).from(tableName).where(condition).orderBy(order).limit(limit).offset(offset).allObjects();\n    }\n\n    @NotNull\n    public <T, R extends T> List<R> getAllObjects(@NotNull Field<T>[] fields, @NotNull String tableName, @Nullable Expression condition, @Nullable OrderingTerm order, long limit, long offset, @NotNull Class<R> cls) throws WCDBException {\n        return this.<T>prepareSelect().select(fields).from(tableName).where(condition).orderBy(order).limit(limit).offset(offset).allObjects(cls);\n    }\n\n    @NotNull\n    public <T> List<T> getAllObjects(@NotNull Field<T>[] fields, @NotNull String tableName, @Nullable OrderingTerm order) throws WCDBException {\n        return this.<T>prepareSelect().select(fields).from(tableName).orderBy(order).allObjects();\n    }\n\n    @NotNull\n    public <T, R extends T> List<R> getAllObjects(@NotNull Field<T>[] fields, @NotNull String tableName, @Nullable OrderingTerm order, @NotNull Class<R> cls) throws WCDBException {\n        return this.<T>prepareSelect().select(fields).from(tableName).orderBy(order).allObjects(cls);\n    }\n\n    @NotNull\n    public <T> List<T> getAllObjects(@NotNull Field<T>[] fields, @NotNull String tableName, @Nullable OrderingTerm order, long limit) throws WCDBException {\n        return this.<T>prepareSelect().select(fields).from(tableName).orderBy(order).limit(limit).allObjects();\n    }\n\n    @NotNull\n    public <T, R extends T> List<R> getAllObjects(@NotNull Field<T>[] fields, @NotNull String tableName, @Nullable OrderingTerm order, long limit, @NotNull Class<R> cls) throws WCDBException {\n        return this.<T>prepareSelect().select(fields).from(tableName).orderBy(order).limit(limit).allObjects(cls);\n    }\n\n    @NotNull\n    public <T> List<T> getAllObjects(@NotNull Field<T>[] fields, @NotNull String tableName, @Nullable OrderingTerm order, long limit, long offset) throws WCDBException {\n        return this.<T>prepareSelect().select(fields).from(tableName).orderBy(order).limit(limit).offset(offset).allObjects();\n    }\n\n    @NotNull\n    public <T, R extends T> List<R> getAllObjects(@NotNull Field<T>[] fields, @NotNull String tableName, @Nullable OrderingTerm order, long limit, long offset, @NotNull Class<R> cls) throws WCDBException {\n        return this.<T>prepareSelect().select(fields).from(tableName).orderBy(order).limit(limit).offset(offset).allObjects(cls);\n    }\n}\n"
  },
  {
    "path": "src/java/main/src/main/java/com/tencent/wcdb/core/HandleOperation.java",
    "content": "// Created by qiuwenchen on 2023/3/30.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage com.tencent.wcdb.core;\n\nimport com.tencent.wcdb.base.CppObject;\nimport com.tencent.wcdb.base.Value;\nimport com.tencent.wcdb.base.WCDBException;\nimport com.tencent.wcdb.winq.Column;\nimport com.tencent.wcdb.winq.ConflictAction;\nimport com.tencent.wcdb.winq.Expression;\nimport com.tencent.wcdb.winq.OrderingTerm;\nimport com.tencent.wcdb.winq.ResultColumnConvertible;\nimport com.tencent.wcdb.winq.Statement;\nimport com.tencent.wcdb.winq.StatementDelete;\nimport com.tencent.wcdb.winq.StatementInsert;\nimport com.tencent.wcdb.winq.StatementSelect;\nimport com.tencent.wcdb.winq.StatementUpdate;\n\nimport org.jetbrains.annotations.NotNull;\nimport org.jetbrains.annotations.Nullable;\n\nimport java.util.Collection;\nimport java.util.Collections;\nimport java.util.List;\n\npublic abstract class HandleOperation extends CppObject {\n    abstract Handle getHandle(boolean writeHint);\n\n    abstract boolean autoInvalidateHandle();\n\n    /**\n     * Execute inserting with one row of values.\n     *\n     * @param row       One row of value.\n     * @param columns   Corresponding column of values.\n     * @param tableName The table to insert value.\n     * @throws WCDBException if any error occurs.\n     */\n    public void insertRow(@NotNull Value[] row, @Nullable Column[] columns, @NotNull String tableName) throws WCDBException {\n        insertRows(Collections.singleton(row), columns, tableName);\n    }\n\n    /**\n     * Execute inserting with multi rows of values.\n     * It will run embedded transaction while rows.size()>1.\n     * The embedded transaction means that it will run a transaction if it's not in other transaction,\n     * otherwise it will be executed within the existing transaction.\n     *\n     * @param rows      Multi rows of value.\n     * @param columns   Corresponding column of values.\n     * @param tableName The table to insert value.\n     * @throws WCDBException if any error occurs.\n     */\n    public void insertRows(@NotNull Collection<Value[]> rows, @Nullable Column[] columns, @NotNull String tableName) throws WCDBException {\n        insertRows(rows, columns, tableName, ConflictAction.None);\n    }\n\n    /**\n     * Execute inserting with one row of values.\n     * It will replace the original row while they have same primary key or row id.\n     *\n     * @param row       One row of value.\n     * @param columns   Corresponding column of values.\n     * @param tableName The table to insert value.\n     * @throws WCDBException if any error occurs.\n     */\n    public void insertOrReplaceRow(@NotNull Value[] row, @Nullable Column[] columns, @NotNull String tableName) throws WCDBException {\n        insertOrReplaceRows(Collections.singleton(row), columns, tableName);\n    }\n\n    /**\n     * Execute inserting with multi rows of values.\n     * It will replace the original row while they have same primary key or row id.\n     * It will run embedded transaction while rows.size()>1.\n     * The embedded transaction means that it will run a transaction if it's not in other transaction,\n     * otherwise it will be executed within the existing transaction.\n     *\n     * @param rows      Multi rows of value.\n     * @param columns   Corresponding column of values.\n     * @param tableName The table to insert value.\n     * @throws WCDBException if any error occurs.\n     */\n    public void insertOrReplaceRows(@NotNull Collection<Value[]> rows, @Nullable Column[] columns, @NotNull String tableName) throws WCDBException {\n        insertRows(rows, columns, tableName, ConflictAction.Replace);\n    }\n\n    /**\n     * Execute inserting with one row of values.\n     * It will ignore the row while there already exists the same primary key or row id in current table.\n     *\n     * @param row       One row of value.\n     * @param columns   Corresponding column of values.\n     * @param tableName The table to insert value.\n     * @throws WCDBException if any error occurs.\n     */\n    public void insertOrIgnoreRow(@NotNull Value[] row, @Nullable Column[] columns, @NotNull String tableName) throws WCDBException {\n        insertOrIgnoreRows(Collections.singleton(row), columns, tableName);\n    }\n\n    /**\n     * Execute inserting with multi rows of values.\n     * It will ignore the row while there already exists the same primary key or row id in current table.\n     * It will run embedded transaction while rows.size()>1.\n     * The embedded transaction means that it will run a transaction if it's not in other transaction,\n     * otherwise it will be executed within the existing transaction.\n     *\n     * @param rows      Multi rows of value.\n     * @param columns   Corresponding column of values.\n     * @param tableName The table to insert value.\n     * @throws WCDBException if any error occurs.\n     */\n    public void insertOrIgnoreRows(@NotNull Collection<Value[]> rows, @Nullable Column[] columns, @NotNull String tableName) throws WCDBException {\n        insertRows(rows, columns, tableName, ConflictAction.Ignore);\n    }\n\n    private void insertRows(final Collection<Value[]> rows, Column[] columns, String tableName, ConflictAction action) throws WCDBException {\n        final StatementInsert insert = new StatementInsert().insertInto(tableName).columns(columns).valuesWithBindParameters(columns.length);\n        if (action == ConflictAction.Replace) {\n            insert.orReplace();\n        } else if (action == ConflictAction.Ignore) {\n            insert.orIgnore();\n        }\n        Handle handle = getHandle(true);\n        try {\n            if (rows.size() > 1) {\n                handle.runTransaction(new Transaction() {\n                    @Override\n                    public boolean insideTransaction(@NotNull Handle handle) throws WCDBException {\n                        insertRows(rows, insert, handle);\n                        return true;\n                    }\n                });\n            } else {\n                insertRows(rows, insert, handle);\n            }\n        } finally {\n            if (autoInvalidateHandle()) {\n                handle.invalidate();\n            }\n        }\n    }\n\n    private void insertRows(Collection<Value[]> rows, StatementInsert insert, Handle handle) throws WCDBException {\n        PreparedStatement preparedStatement = handle.preparedWithMainStatement(insert);\n        for (Value[] row : rows) {\n            preparedStatement.reset();\n            preparedStatement.bindRow(row);\n            preparedStatement.step();\n        }\n        preparedStatement.finalizeStatement();\n    }\n\n    public void updateValue(int value, @NotNull Column column, @NotNull String tableName) throws WCDBException {\n        updateRow(new Value[]{new Value(value)}, new Column[]{column}, tableName);\n    }\n\n    public void updateValue(int value, @NotNull Column column, @NotNull String tableName, @Nullable Expression condition) throws WCDBException {\n        updateRow(new Value[]{new Value(value)}, new Column[]{column}, tableName, condition);\n    }\n\n    public void updateValue(int value, @NotNull Column column, @NotNull String tableName, @Nullable Expression condition, @Nullable OrderingTerm order, int limit) throws WCDBException {\n        updateRow(new Value[]{new Value(value)}, new Column[]{column}, tableName, condition, order, limit);\n    }\n\n    public void updateValue(int value, @NotNull Column column, @NotNull String tableName, @Nullable Expression condition, @Nullable OrderingTerm order, int limit, int offset) throws WCDBException {\n        updateRow(new Value[]{new Value(value)}, new Column[]{column}, tableName, condition, order, limit, offset);\n    }\n\n    public void updateValue(int value, @NotNull Column column, @NotNull String tableName, @Nullable OrderingTerm order, int limit) throws WCDBException {\n        updateRow(new Value[]{new Value(value)}, new Column[]{column}, tableName, order, limit);\n    }\n\n    public void updateValue(int value, @NotNull Column column, @NotNull String tableName, @Nullable OrderingTerm order, int limit, int offset) throws WCDBException {\n        updateRow(new Value[]{new Value(value)}, new Column[]{column}, tableName, order, limit, offset);\n    }\n\n    public void updateValue(long value, @NotNull Column column, @NotNull String tableName) throws WCDBException {\n        updateRow(new Value[]{new Value(value)}, new Column[]{column}, tableName);\n    }\n\n    public void updateValue(double value, @NotNull Column column, @NotNull String tableName, @Nullable Expression condition) throws WCDBException {\n        updateRow(new Value[]{new Value(value)}, new Column[]{column}, tableName, condition);\n    }\n\n    public void updateValue(double value, @NotNull Column column, @NotNull String tableName, @Nullable Expression condition, @Nullable OrderingTerm order, int limit) throws WCDBException {\n        updateRow(new Value[]{new Value(value)}, new Column[]{column}, tableName, condition, order, limit);\n    }\n\n    public void updateValue(double value, @NotNull Column column, @NotNull String tableName, @Nullable Expression condition, @Nullable OrderingTerm order, int limit, int offset) throws WCDBException {\n        updateRow(new Value[]{new Value(value)}, new Column[]{column}, tableName, condition, order, limit, offset);\n    }\n\n    public void updateValue(double value, @NotNull Column column, @NotNull String tableName, @Nullable OrderingTerm order, int limit) throws WCDBException {\n        updateRow(new Value[]{new Value(value)}, new Column[]{column}, tableName, order, limit);\n    }\n\n    public void updateValue(double value, @NotNull Column column, @NotNull String tableName, @Nullable OrderingTerm order, int limit, int offset) throws WCDBException {\n        updateRow(new Value[]{new Value(value)}, new Column[]{column}, tableName, order, limit, offset);\n    }\n\n    public void updateValue(@Nullable String value, @NotNull Column column, @NotNull String tableName) throws WCDBException {\n        updateRow(new Value[]{new Value(value)}, new Column[]{column}, tableName);\n    }\n\n    public void updateValue(@Nullable String value, @NotNull Column column, @NotNull String tableName, @Nullable Expression condition) throws WCDBException {\n        updateRow(new Value[]{new Value(value)}, new Column[]{column}, tableName, condition);\n    }\n\n    public void updateValue(@Nullable String value, @NotNull Column column, @NotNull String tableName, @Nullable Expression condition, @Nullable OrderingTerm order, int limit) throws WCDBException {\n        updateRow(new Value[]{new Value(value)}, new Column[]{column}, tableName, condition, order, limit);\n    }\n\n    public void updateValue(@Nullable String value, @NotNull Column column, @NotNull String tableName, @Nullable Expression condition, @Nullable OrderingTerm order, int limit, int offset) throws WCDBException {\n        updateRow(new Value[]{new Value(value)}, new Column[]{column}, tableName, condition, order, limit, offset);\n    }\n\n    public void updateValue(@Nullable String value, @NotNull Column column, @NotNull String tableName, @Nullable OrderingTerm order, int limit) throws WCDBException {\n        updateRow(new Value[]{new Value(value)}, new Column[]{column}, tableName, order, limit);\n    }\n\n    public void updateValue(@Nullable String value, @NotNull Column column, @NotNull String tableName, @Nullable OrderingTerm order, int limit, int offset) throws WCDBException {\n        updateRow(new Value[]{new Value(value)}, new Column[]{column}, tableName, order, limit, offset);\n    }\n\n    public void updateValue(@Nullable byte[] value, @NotNull Column column, @NotNull String tableName) throws WCDBException {\n        updateRow(new Value[]{new Value(value)}, new Column[]{column}, tableName);\n    }\n\n    public void updateValue(@Nullable byte[] value, @NotNull Column column, @NotNull String tableName, @Nullable Expression condition) throws WCDBException {\n        updateRow(new Value[]{new Value(value)}, new Column[]{column}, tableName, condition);\n    }\n\n    public void updateValue(@Nullable byte[] value, @NotNull Column column, @NotNull String tableName, @Nullable Expression condition, @Nullable OrderingTerm order, int limit) throws WCDBException {\n        updateRow(new Value[]{new Value(value)}, new Column[]{column}, tableName, condition, order, limit);\n    }\n\n    public void updateValue(@Nullable byte[] value, @NotNull Column column, @NotNull String tableName, @Nullable Expression condition, @Nullable OrderingTerm order, int limit, int offset) throws WCDBException {\n        updateRow(new Value[]{new Value(value)}, new Column[]{column}, tableName, condition, order, limit, offset);\n    }\n\n    public void updateValue(@Nullable byte[] value, @NotNull Column column, @NotNull String tableName, @Nullable OrderingTerm order, int limit) throws WCDBException {\n        updateRow(new Value[]{new Value(value)}, new Column[]{column}, tableName, order, limit);\n    }\n\n    public void updateValue(@Nullable byte[] value, @NotNull Column column, @NotNull String tableName, @Nullable OrderingTerm order, int limit, int offset) throws WCDBException {\n        updateRow(new Value[]{new Value(value)}, new Column[]{column}, tableName, order, limit, offset);\n    }\n\n    public void updateValue(@Nullable Value value, @NotNull Column column, @NotNull String tableName) throws WCDBException {\n        if (value == null) {\n            value = new Value();\n        }\n        updateRow(new Value[]{value}, new Column[]{column}, tableName);\n    }\n\n    public void updateValue(@Nullable Value value, @NotNull Column column, @NotNull String tableName, @Nullable Expression condition) throws WCDBException {\n        if (value == null) {\n            value = new Value();\n        }\n        updateRow(new Value[]{value}, new Column[]{column}, tableName, condition);\n    }\n\n    public void updateValue(@Nullable Value value, @NotNull Column column, @NotNull String tableName, @Nullable Expression condition, @Nullable OrderingTerm order, int limit) throws WCDBException {\n        if (value == null) {\n            value = new Value();\n        }\n        updateRow(new Value[]{value}, new Column[]{column}, tableName, condition, order, limit);\n    }\n\n    public void updateValue(@Nullable Value value, @NotNull Column column, @NotNull String tableName, @Nullable Expression condition, @Nullable OrderingTerm order, int limit, int offset) throws WCDBException {\n        updateRow(new Value[]{value}, new Column[]{column}, tableName, condition, order, limit, offset);\n    }\n\n    public void updateValue(@Nullable Value value, @NotNull Column column, @NotNull String tableName, @Nullable OrderingTerm order, int limit) throws WCDBException {\n        if (value == null) {\n            value = new Value();\n        }\n        updateRow(new Value[]{value}, new Column[]{column}, tableName, order, limit);\n    }\n\n    public void updateValue(@Nullable Value value, @NotNull Column column, @NotNull String tableName, @Nullable OrderingTerm order, int limit, int offset) throws WCDBException {\n        updateRow(new Value[]{value}, new Column[]{column}, tableName, order, limit, offset);\n    }\n\n    public void updateRow(@NotNull Value[] row, @NotNull Column[] columns, @NotNull String tableName) throws WCDBException {\n        StatementUpdate update = new StatementUpdate().update(tableName).setColumnsToBindParameters(columns);\n        updateRow(row, update);\n    }\n\n    public void updateRow(@NotNull Value[] row, @NotNull Column[] columns, @NotNull String tableName, @Nullable Expression condition) throws WCDBException {\n        StatementUpdate update = new StatementUpdate().update(tableName).setColumnsToBindParameters(columns).where(condition);\n        updateRow(row, update);\n    }\n\n    public void updateRow(@NotNull Value[] row, @NotNull Column[] columns, @NotNull String tableName, @Nullable Expression condition, @Nullable OrderingTerm order, int limit) throws WCDBException {\n        StatementUpdate update = new StatementUpdate().update(tableName).setColumnsToBindParameters(columns).where(condition).orderBy(order).limit(limit);\n        updateRow(row, update);\n    }\n\n    public void updateRow(@NotNull Value[] row, @NotNull Column[] columns, @NotNull String tableName, @Nullable Expression condition, @Nullable OrderingTerm order, int limit, int offset) throws WCDBException {\n        StatementUpdate update = new StatementUpdate().update(tableName).setColumnsToBindParameters(columns).where(condition).orderBy(order).limit(limit).offset(offset);\n        updateRow(row, update);\n    }\n\n    public void updateRow(@NotNull Value[] row, @NotNull Column[] columns, @NotNull String tableName, @Nullable OrderingTerm order, int limit) throws WCDBException {\n        StatementUpdate update = new StatementUpdate().update(tableName).setColumnsToBindParameters(columns).orderBy(order).limit(limit);\n        updateRow(row, update);\n    }\n\n    public void updateRow(@NotNull Value[] row, @NotNull Column[] columns, @NotNull String tableName, @Nullable OrderingTerm order, int limit, int offset) throws WCDBException {\n        StatementUpdate update = new StatementUpdate().update(tableName).setColumnsToBindParameters(columns).orderBy(order).limit(limit).offset(offset);\n        updateRow(row, update);\n    }\n\n    private void updateRow(@NotNull Value[] row, StatementUpdate update) throws WCDBException {\n        Handle handle = getHandle(true);\n        PreparedStatement preparedStatement = null;\n        try {\n            preparedStatement = handle.preparedWithMainStatement(update);\n            preparedStatement.bindRow(row);\n            preparedStatement.step();\n        } finally {\n            if (preparedStatement != null) {\n                preparedStatement.finalizeStatement();\n            }\n            if (autoInvalidateHandle()) {\n                handle.invalidate();\n            }\n        }\n    }\n\n    public void deleteValue(@NotNull String tableName) throws WCDBException {\n        StatementDelete delete = new StatementDelete().deleteFrom(tableName);\n        deleteValue(delete);\n    }\n\n    public void deleteValue(@NotNull String tableName, @Nullable Expression condition) throws WCDBException {\n        StatementDelete delete = new StatementDelete().deleteFrom(tableName).where(condition);\n        deleteValue(delete);\n    }\n\n    public void deleteValue(@NotNull String tableName, @Nullable Expression condition, @Nullable OrderingTerm orderingTerm, int limit) throws WCDBException {\n        StatementDelete delete = new StatementDelete().deleteFrom(tableName).where(condition).orderBy(orderingTerm).limit(limit);\n        deleteValue(delete);\n    }\n\n    public void deleteValue(@NotNull String tableName, @Nullable Expression condition, @Nullable OrderingTerm orderingTerm, int limit, int offset) throws WCDBException {\n        StatementDelete delete = new StatementDelete().deleteFrom(tableName).where(condition).orderBy(orderingTerm).limit(limit).offset(offset);\n        deleteValue(delete);\n    }\n\n    public void deleteValue(@NotNull String tableName, @Nullable OrderingTerm orderingTerm, int limit) throws WCDBException {\n        StatementDelete delete = new StatementDelete().deleteFrom(tableName).orderBy(orderingTerm).limit(limit);\n        deleteValue(delete);\n    }\n\n    public void deleteValue(@NotNull String tableName, @Nullable OrderingTerm orderingTerm, int limit, int offset) throws WCDBException {\n        StatementDelete delete = new StatementDelete().deleteFrom(tableName).orderBy(orderingTerm).limit(limit).offset(offset);\n        deleteValue(delete);\n    }\n\n    private void deleteValue(StatementDelete delete) throws WCDBException {\n        Handle handle = getHandle(true);\n        try {\n            handle.execute(delete);\n        } finally {\n            if (autoInvalidateHandle()) {\n                handle.invalidate();\n            }\n        }\n    }\n\n    @Nullable\n    public Value getValue(@NotNull ResultColumnConvertible column, @NotNull String tableName) throws WCDBException {\n        return getValueFromStatement(new StatementSelect().select(column).from(tableName));\n    }\n\n    @Nullable\n    public Value getValue(@NotNull ResultColumnConvertible column, @NotNull String tableName, @Nullable Expression condition) throws WCDBException {\n        return getValueFromStatement(new StatementSelect().select(column).from(tableName).where(condition));\n    }\n\n    @Nullable\n    public Value getValue(@NotNull ResultColumnConvertible column, @NotNull String tableName, @Nullable Expression condition, @Nullable OrderingTerm order) throws WCDBException {\n        return getValueFromStatement(new StatementSelect().select(column).from(tableName).where(condition).orderBy(order));\n    }\n\n    @Nullable\n    public Value getValue(@NotNull ResultColumnConvertible column, @NotNull String tableName, @Nullable Expression condition, @Nullable OrderingTerm order, int offset) throws WCDBException {\n        return getValueFromStatement(new StatementSelect().select(column).from(tableName).where(condition).orderBy(order).limit(1).offset(offset));\n    }\n\n    @Nullable\n    public Value getValue(@NotNull ResultColumnConvertible column, @NotNull String tableName, @Nullable OrderingTerm order) throws WCDBException {\n        return getValueFromStatement(new StatementSelect().select(column).from(tableName).orderBy(order));\n    }\n\n    @Nullable\n    public Value getValue(@NotNull ResultColumnConvertible column, @NotNull String tableName, @Nullable OrderingTerm order, int offset) throws WCDBException {\n        return getValueFromStatement(new StatementSelect().select(column).from(tableName).orderBy(order).limit(1).offset(offset));\n    }\n\n    @NotNull\n    public List<Value> getOneColumn(@NotNull ResultColumnConvertible column, @NotNull String tableName) throws WCDBException {\n        return getOneColumnFromStatement(new StatementSelect().select(column).from(tableName));\n    }\n\n    @NotNull\n    public List<Value> getOneColumn(@NotNull ResultColumnConvertible column, @NotNull String tableName, @Nullable Expression condition) throws WCDBException {\n        return getOneColumnFromStatement(new StatementSelect().select(column).from(tableName).where(condition));\n    }\n\n    @NotNull\n    public List<Value> getOneColumn(@NotNull ResultColumnConvertible column, @NotNull String tableName, @Nullable Expression condition, @Nullable OrderingTerm order) throws WCDBException {\n        return getOneColumnFromStatement(new StatementSelect().select(column).from(tableName).where(condition).orderBy(order));\n    }\n\n    @NotNull\n    public List<Value> getOneColumn(@NotNull ResultColumnConvertible column, @NotNull String tableName, @Nullable Expression condition, @Nullable OrderingTerm order, int limit) throws WCDBException {\n        return getOneColumnFromStatement(new StatementSelect().select(column).from(tableName).where(condition).orderBy(order).limit(limit));\n    }\n\n    @NotNull\n    public List<Value> getOneColumn(@NotNull ResultColumnConvertible column, @NotNull String tableName, @Nullable Expression condition, @Nullable OrderingTerm order, int limit, int offset) throws WCDBException {\n        return getOneColumnFromStatement(new StatementSelect().select(column).from(tableName).where(condition).orderBy(order).limit(limit).offset(offset));\n    }\n\n    @NotNull\n    public List<Value> getOneColumn(@NotNull ResultColumnConvertible column, @NotNull String tableName, @Nullable OrderingTerm order) throws WCDBException {\n        return getOneColumnFromStatement(new StatementSelect().select(column).from(tableName).orderBy(order));\n    }\n\n    @NotNull\n    public List<Value> getOneColumn(@NotNull ResultColumnConvertible column, @NotNull String tableName, @Nullable OrderingTerm order, int limit) throws WCDBException {\n        return getOneColumnFromStatement(new StatementSelect().select(column).from(tableName).orderBy(order).limit(limit));\n    }\n\n    @NotNull\n    public List<Value> getOneColumn(@NotNull ResultColumnConvertible column, @NotNull String tableName, @Nullable OrderingTerm order, int limit, int offset) throws WCDBException {\n        return getOneColumnFromStatement(new StatementSelect().select(column).from(tableName).orderBy(order).limit(limit).offset(offset));\n    }\n\n    @Nullable\n    public Value[] getOneRow(@NotNull ResultColumnConvertible[] columns, @NotNull String tableName) throws WCDBException {\n        return getOneRowFromStatement(new StatementSelect().select(columns).from(tableName));\n    }\n\n    @Nullable\n    public Value[] getOneRow(@NotNull ResultColumnConvertible[] columns, @NotNull String tableName, @Nullable Expression condition) throws WCDBException {\n        return getOneRowFromStatement(new StatementSelect().select(columns).from(tableName).where(condition));\n    }\n\n    @Nullable\n    public Value[] getOneRow(@NotNull ResultColumnConvertible[] columns, @NotNull String tableName, @Nullable Expression condition, @Nullable OrderingTerm orderingTerm) throws WCDBException {\n        return getOneRowFromStatement(new StatementSelect().select(columns).from(tableName).where(condition).orderBy(orderingTerm));\n    }\n\n    @Nullable\n    public Value[] getOneRow(@NotNull ResultColumnConvertible[] columns, @NotNull String tableName, @Nullable Expression condition, @Nullable OrderingTerm orderingTerm, int offset) throws WCDBException {\n        return getOneRowFromStatement(new StatementSelect().select(columns).from(tableName).where(condition).orderBy(orderingTerm).limit(1).offset(offset));\n    }\n\n    @Nullable\n    public Value[] getOneRow(@NotNull ResultColumnConvertible[] columns, @NotNull String tableName, @Nullable OrderingTerm orderingTerm) throws WCDBException {\n        return getOneRowFromStatement(new StatementSelect().select(columns).from(tableName).orderBy(orderingTerm));\n    }\n\n    @Nullable\n    public Value[] getOneRow(@NotNull ResultColumnConvertible[] columns, @NotNull String tableName, @Nullable OrderingTerm orderingTerm, int offset) throws WCDBException {\n        return getOneRowFromStatement(new StatementSelect().select(columns).from(tableName).orderBy(orderingTerm).limit(1).offset(offset));\n    }\n\n    @NotNull\n    public List<Integer> getOneColumnInt(@NotNull ResultColumnConvertible column, @NotNull String tableName) throws WCDBException {\n        return getOneColumnIntFromStatement(new StatementSelect().select(column).from(tableName));\n    }\n\n    @NotNull\n    public List<Integer> getOneColumnInt(@NotNull ResultColumnConvertible column, @NotNull String tableName, @Nullable Expression condition) throws WCDBException {\n        return getOneColumnIntFromStatement(new StatementSelect().select(column).from(tableName).where(condition));\n    }\n\n    @NotNull\n    public List<Integer> getOneColumnInt(@NotNull ResultColumnConvertible column, @NotNull String tableName, @Nullable Expression condition, @Nullable OrderingTerm order) throws WCDBException {\n        return getOneColumnIntFromStatement(new StatementSelect().select(column).from(tableName).where(condition).orderBy(order));\n    }\n\n    @NotNull\n    public List<Integer> getOneColumnInt(@NotNull ResultColumnConvertible column, @NotNull String tableName, @Nullable Expression condition, @Nullable OrderingTerm order, int limit) throws WCDBException {\n        return getOneColumnIntFromStatement(new StatementSelect().select(column).from(tableName).where(condition).orderBy(order).limit(limit));\n    }\n\n    @NotNull\n    public List<Integer> getOneColumnInt(@NotNull ResultColumnConvertible column, @NotNull String tableName, @Nullable Expression condition, @Nullable OrderingTerm order, int limit, int offset) throws WCDBException {\n        return getOneColumnIntFromStatement(new StatementSelect().select(column).from(tableName).where(condition).orderBy(order).limit(limit).offset(offset));\n    }\n\n    @NotNull\n    public List<Integer> getOneColumnInt(@NotNull ResultColumnConvertible column, @NotNull String tableName, @Nullable OrderingTerm order) throws WCDBException {\n        return getOneColumnIntFromStatement(new StatementSelect().select(column).from(tableName).orderBy(order));\n    }\n\n    @NotNull\n    public List<Integer> getOneColumnInt(@NotNull ResultColumnConvertible column, @NotNull String tableName, @Nullable OrderingTerm order, int limit) throws WCDBException {\n        return getOneColumnIntFromStatement(new StatementSelect().select(column).from(tableName).orderBy(order).limit(limit));\n    }\n\n    @NotNull\n    public List<Integer> getOneColumnInt(@NotNull ResultColumnConvertible column, @NotNull String tableName, @Nullable OrderingTerm order, int limit, int offset) throws WCDBException {\n        return getOneColumnIntFromStatement(new StatementSelect().select(column).from(tableName).orderBy(order).limit(limit).offset(offset));\n    }\n\n    @NotNull\n    public List<Long> getOneColumnLong(@NotNull ResultColumnConvertible column, @NotNull String tableName) throws WCDBException {\n        return getOneColumnLongFromStatement(new StatementSelect().select(column).from(tableName));\n    }\n\n    @NotNull\n    public List<Long> getOneColumnLong(@NotNull ResultColumnConvertible column, @NotNull String tableName, @Nullable Expression condition) throws WCDBException {\n        return getOneColumnLongFromStatement(new StatementSelect().select(column).from(tableName).where(condition));\n    }\n\n    @NotNull\n    public List<Long> getOneColumnLong(@NotNull ResultColumnConvertible column, @NotNull String tableName, @Nullable Expression condition, @Nullable OrderingTerm order) throws WCDBException {\n        return getOneColumnLongFromStatement(new StatementSelect().select(column).from(tableName).where(condition).orderBy(order));\n    }\n\n    @NotNull\n    public List<Long> getOneColumnLong(@NotNull ResultColumnConvertible column, @NotNull String tableName, @Nullable Expression condition, @Nullable OrderingTerm order, int limit) throws WCDBException {\n        return getOneColumnLongFromStatement(new StatementSelect().select(column).from(tableName).where(condition).orderBy(order).limit(limit));\n    }\n\n    @NotNull\n    public List<Long> getOneColumnLong(@NotNull ResultColumnConvertible column, @NotNull String tableName, @Nullable Expression condition, @Nullable OrderingTerm order, int limit, int offset) throws WCDBException {\n        return getOneColumnLongFromStatement(new StatementSelect().select(column).from(tableName).where(condition).orderBy(order).limit(limit).offset(offset));\n    }\n\n    @NotNull\n    public List<Long> getOneColumnLong(@NotNull ResultColumnConvertible column, @NotNull String tableName, @Nullable OrderingTerm order) throws WCDBException {\n        return getOneColumnLongFromStatement(new StatementSelect().select(column).from(tableName).orderBy(order));\n    }\n\n    @NotNull\n    public List<Long> getOneColumnLong(@NotNull ResultColumnConvertible column, @NotNull String tableName, @Nullable OrderingTerm order, int limit) throws WCDBException {\n        return getOneColumnLongFromStatement(new StatementSelect().select(column).from(tableName).orderBy(order).limit(limit));\n    }\n\n    @NotNull\n    public List<Long> getOneColumnLong(@NotNull ResultColumnConvertible column, @NotNull String tableName, @Nullable OrderingTerm order, int limit, int offset) throws WCDBException {\n        return getOneColumnLongFromStatement(new StatementSelect().select(column).from(tableName).orderBy(order).limit(limit).offset(offset));\n    }\n\n    @NotNull\n    public List<Float> getOneColumnFloat(@NotNull ResultColumnConvertible column, @NotNull String tableName) throws WCDBException {\n        return getOneColumnFloatFromStatement(new StatementSelect().select(column).from(tableName));\n    }\n\n    @NotNull\n    public List<Float> getOneColumnFloat(@NotNull ResultColumnConvertible column, @NotNull String tableName, @Nullable Expression condition) throws WCDBException {\n        return getOneColumnFloatFromStatement(new StatementSelect().select(column).from(tableName).where(condition));\n    }\n\n    @NotNull\n    public List<Float> getOneColumnFloat(@NotNull ResultColumnConvertible column, @NotNull String tableName, @Nullable Expression condition, @Nullable OrderingTerm order) throws WCDBException {\n        return getOneColumnFloatFromStatement(new StatementSelect().select(column).from(tableName).where(condition).orderBy(order));\n    }\n\n    @NotNull\n    public List<Float> getOneColumnFloat(@NotNull ResultColumnConvertible column, @NotNull String tableName, @Nullable Expression condition, @Nullable OrderingTerm order, int limit) throws WCDBException {\n        return getOneColumnFloatFromStatement(new StatementSelect().select(column).from(tableName).where(condition).orderBy(order).limit(limit));\n    }\n\n    @NotNull\n    public List<Float> getOneColumnFloat(@NotNull ResultColumnConvertible column, @NotNull String tableName, @Nullable Expression condition, @Nullable OrderingTerm order, int limit, int offset) throws WCDBException {\n        return getOneColumnFloatFromStatement(new StatementSelect().select(column).from(tableName).where(condition).orderBy(order).limit(limit).offset(offset));\n    }\n\n    @NotNull\n    public List<Float> getOneColumnFloat(@NotNull ResultColumnConvertible column, @NotNull String tableName, @Nullable OrderingTerm order) throws WCDBException {\n        return getOneColumnFloatFromStatement(new StatementSelect().select(column).from(tableName).orderBy(order));\n    }\n\n    @NotNull\n    public List<Float> getOneColumnFloat(@NotNull ResultColumnConvertible column, @NotNull String tableName, @Nullable OrderingTerm order, int limit) throws WCDBException {\n        return getOneColumnFloatFromStatement(new StatementSelect().select(column).from(tableName).orderBy(order).limit(limit));\n    }\n\n    @NotNull\n    public List<Float> getOneColumnFloat(@NotNull ResultColumnConvertible column, @NotNull String tableName, @Nullable OrderingTerm order, int limit, int offset) throws WCDBException {\n        return getOneColumnFloatFromStatement(new StatementSelect().select(column).from(tableName).orderBy(order).limit(limit).offset(offset));\n    }\n\n    @NotNull\n    public List<Double> getOneColumnDouble(@NotNull ResultColumnConvertible column, @NotNull String tableName) throws WCDBException {\n        return getOneColumnDoubleFromStatement(new StatementSelect().select(column).from(tableName));\n    }\n\n    @NotNull\n    public List<Double> getOneColumnDouble(@NotNull ResultColumnConvertible column, @NotNull String tableName, @Nullable Expression condition) throws WCDBException {\n        return getOneColumnDoubleFromStatement(new StatementSelect().select(column).from(tableName).where(condition));\n    }\n\n    @NotNull\n    public List<Double> getOneColumnDouble(@NotNull ResultColumnConvertible column, @NotNull String tableName, @Nullable Expression condition, @Nullable OrderingTerm order) throws WCDBException {\n        return getOneColumnDoubleFromStatement(new StatementSelect().select(column).from(tableName).where(condition).orderBy(order));\n    }\n\n    @NotNull\n    public List<Double> getOneColumnDouble(@NotNull ResultColumnConvertible column, @NotNull String tableName, @Nullable Expression condition, @Nullable OrderingTerm order, int limit) throws WCDBException {\n        return getOneColumnDoubleFromStatement(new StatementSelect().select(column).from(tableName).where(condition).orderBy(order).limit(limit));\n    }\n\n    @NotNull\n    public List<Double> getOneColumnDouble(@NotNull ResultColumnConvertible column, @NotNull String tableName, @Nullable Expression condition, @Nullable OrderingTerm order, int limit, int offset) throws WCDBException {\n        return getOneColumnDoubleFromStatement(new StatementSelect().select(column).from(tableName).where(condition).orderBy(order).limit(limit).offset(offset));\n    }\n\n    @NotNull\n    public List<Double> getOneColumnDouble(@NotNull ResultColumnConvertible column, @NotNull String tableName, @Nullable OrderingTerm order) throws WCDBException {\n        return getOneColumnDoubleFromStatement(new StatementSelect().select(column).from(tableName).orderBy(order));\n    }\n\n    @NotNull\n    public List<Double> getOneColumnDouble(@NotNull ResultColumnConvertible column, @NotNull String tableName, @Nullable OrderingTerm order, int limit) throws WCDBException {\n        return getOneColumnDoubleFromStatement(new StatementSelect().select(column).from(tableName).orderBy(order).limit(limit));\n    }\n\n    @NotNull\n    public List<Double> getOneColumnDouble(@NotNull ResultColumnConvertible column, @NotNull String tableName, @Nullable OrderingTerm order, int limit, int offset) throws WCDBException {\n        return getOneColumnDoubleFromStatement(new StatementSelect().select(column).from(tableName).orderBy(order).limit(limit).offset(offset));\n    }\n\n    @NotNull\n    public List<String> getOneColumnString(@NotNull ResultColumnConvertible column, @NotNull String tableName) throws WCDBException {\n        return getOneColumnStringFromStatement(new StatementSelect().select(column).from(tableName));\n    }\n\n    @NotNull\n    public List<String> getOneColumnString(@NotNull ResultColumnConvertible column, @NotNull String tableName, @Nullable Expression condition) throws WCDBException {\n        return getOneColumnStringFromStatement(new StatementSelect().select(column).from(tableName).where(condition));\n    }\n\n    @NotNull\n    public List<String> getOneColumnString(@NotNull ResultColumnConvertible column, @NotNull String tableName, @Nullable Expression condition, @Nullable OrderingTerm order) throws WCDBException {\n        return getOneColumnStringFromStatement(new StatementSelect().select(column).from(tableName).where(condition).orderBy(order));\n    }\n\n    @NotNull\n    public List<String> getOneColumnString(@NotNull ResultColumnConvertible column, @NotNull String tableName, @Nullable Expression condition, @Nullable OrderingTerm order, int limit) throws WCDBException {\n        return getOneColumnStringFromStatement(new StatementSelect().select(column).from(tableName).where(condition).orderBy(order).limit(limit));\n    }\n\n    @NotNull\n    public List<String> getOneColumnString(@NotNull ResultColumnConvertible column, @NotNull String tableName, @Nullable Expression condition, @Nullable OrderingTerm order, int limit, int offset) throws WCDBException {\n        return getOneColumnStringFromStatement(new StatementSelect().select(column).from(tableName).where(condition).orderBy(order).limit(limit).offset(offset));\n    }\n\n    @NotNull\n    public List<String> getOneColumnString(@NotNull ResultColumnConvertible column, @NotNull String tableName, @Nullable OrderingTerm order) throws WCDBException {\n        return getOneColumnStringFromStatement(new StatementSelect().select(column).from(tableName).orderBy(order));\n    }\n\n    @NotNull\n    public List<String> getOneColumnString(@NotNull ResultColumnConvertible column, @NotNull String tableName, @Nullable OrderingTerm order, int limit) throws WCDBException {\n        return getOneColumnStringFromStatement(new StatementSelect().select(column).from(tableName).orderBy(order).limit(limit));\n    }\n\n    @NotNull\n    public List<String> getOneColumnString(@NotNull ResultColumnConvertible column, @NotNull String tableName, @Nullable OrderingTerm order, int limit, int offset) throws WCDBException {\n        return getOneColumnStringFromStatement(new StatementSelect().select(column).from(tableName).orderBy(order).limit(limit).offset(offset));\n    }\n\n    @NotNull\n    public List<byte[]> getOneColumnBLOB(@NotNull ResultColumnConvertible column, @NotNull String tableName) throws WCDBException {\n        return getOneColumnBLOBFromStatement(new StatementSelect().select(column).from(tableName));\n    }\n\n    @NotNull\n    public List<byte[]> getOneColumnBLOB(@NotNull ResultColumnConvertible column, @NotNull String tableName, @Nullable Expression condition) throws WCDBException {\n        return getOneColumnBLOBFromStatement(new StatementSelect().select(column).from(tableName).where(condition));\n    }\n\n    @NotNull\n    public List<byte[]> getOneColumnBLOB(@NotNull ResultColumnConvertible column, @NotNull String tableName, @Nullable Expression condition, @Nullable OrderingTerm order) throws WCDBException {\n        return getOneColumnBLOBFromStatement(new StatementSelect().select(column).from(tableName).where(condition).orderBy(order));\n    }\n\n    @NotNull\n    public List<byte[]> getOneColumnBLOB(@NotNull ResultColumnConvertible column, @NotNull String tableName, @Nullable Expression condition, @Nullable OrderingTerm order, int limit) throws WCDBException {\n        return getOneColumnBLOBFromStatement(new StatementSelect().select(column).from(tableName).where(condition).orderBy(order).limit(limit));\n    }\n\n    @NotNull\n    public List<byte[]> getOneColumnBLOB(@NotNull ResultColumnConvertible column, @NotNull String tableName, @Nullable Expression condition, @Nullable OrderingTerm order, int limit, int offset) throws WCDBException {\n        return getOneColumnBLOBFromStatement(new StatementSelect().select(column).from(tableName).where(condition).orderBy(order).limit(limit).offset(offset));\n    }\n\n    @NotNull\n    public List<byte[]> getOneColumnBLOB(@NotNull ResultColumnConvertible column, @NotNull String tableName, @Nullable OrderingTerm order) throws WCDBException {\n        return getOneColumnBLOBFromStatement(new StatementSelect().select(column).from(tableName).orderBy(order));\n    }\n\n    @NotNull\n    public List<byte[]> getOneColumnBLOB(@NotNull ResultColumnConvertible column, @NotNull String tableName, @Nullable OrderingTerm order, int limit) throws WCDBException {\n        return getOneColumnBLOBFromStatement(new StatementSelect().select(column).from(tableName).orderBy(order).limit(limit));\n    }\n\n    @NotNull\n    public List<byte[]> getOneColumnBLOB(@NotNull ResultColumnConvertible column, @NotNull String tableName, @Nullable OrderingTerm order, int limit, int offset) throws WCDBException {\n        return getOneColumnBLOBFromStatement(new StatementSelect().select(column).from(tableName).orderBy(order).limit(limit).offset(offset));\n    }\n\n    @NotNull\n    public List<Value[]> getAllRows(@NotNull ResultColumnConvertible[] columns, @NotNull String tableName) throws WCDBException {\n        return getAllRowsFromStatement(new StatementSelect().select(columns).from(tableName));\n    }\n\n    @NotNull\n    public List<Value[]> getAllRows(@NotNull ResultColumnConvertible[] columns, @NotNull String tableName, @Nullable Expression condition) throws WCDBException {\n        return getAllRowsFromStatement(new StatementSelect().select(columns).from(tableName).where(condition));\n    }\n\n    @NotNull\n    public List<Value[]> getAllRows(@NotNull ResultColumnConvertible[] columns, @NotNull String tableName, @Nullable Expression condition, @Nullable OrderingTerm order) throws WCDBException {\n        return getAllRowsFromStatement(new StatementSelect().select(columns).from(tableName).where(condition).orderBy(order));\n    }\n\n    @NotNull\n    public List<Value[]> getAllRows(@NotNull ResultColumnConvertible[] columns, @NotNull String tableName, @Nullable Expression condition, @Nullable OrderingTerm order, int limit) throws WCDBException {\n        return getAllRowsFromStatement(new StatementSelect().select(columns).from(tableName).where(condition).orderBy(order).limit(limit));\n    }\n\n    @NotNull\n    public List<Value[]> getAllRows(@NotNull ResultColumnConvertible[] columns, @NotNull String tableName, @Nullable Expression condition, @Nullable OrderingTerm order, int limit, int offset) throws WCDBException {\n        return getAllRowsFromStatement(new StatementSelect().select(columns).from(tableName).where(condition).orderBy(order).limit(limit).offset(offset));\n    }\n\n    @NotNull\n    public List<Value[]> getAllRows(@NotNull ResultColumnConvertible[] columns, @NotNull String tableName, @Nullable OrderingTerm order) throws WCDBException {\n        return getAllRowsFromStatement(new StatementSelect().select(columns).from(tableName).orderBy(order));\n    }\n\n    @NotNull\n    public List<Value[]> getAllRows(@NotNull ResultColumnConvertible[] columns, @NotNull String tableName, @Nullable OrderingTerm order, int limit) throws WCDBException {\n        return getAllRowsFromStatement(new StatementSelect().select(columns).from(tableName).orderBy(order).limit(limit));\n    }\n\n    @NotNull\n    public List<Value[]> getAllRows(@NotNull ResultColumnConvertible[] columns, @NotNull String tableName, @Nullable OrderingTerm order, int limit, int offset) throws WCDBException {\n        return getAllRowsFromStatement(new StatementSelect().select(columns).from(tableName).orderBy(order).limit(limit).offset(offset));\n    }\n\n    @Nullable\n    public Value getValueFromStatement(@NotNull Statement statement) throws WCDBException {\n        Handle handle = getHandle(false);\n        Value ret = null;\n        PreparedStatement preparedStatement = null;\n        try {\n            preparedStatement = handle.preparedWithMainStatement(statement);\n            preparedStatement.step();\n            if (!preparedStatement.isDone()) {\n                ret = preparedStatement.getValue(0);\n            }\n        } finally {\n            if (preparedStatement != null) {\n                preparedStatement.finalizeStatement();\n            }\n            if (autoInvalidateHandle()) {\n                handle.invalidate();\n            }\n        }\n        return ret;\n    }\n\n    @Nullable\n    public Value getValueFromSQL(@NotNull String sql) throws WCDBException {\n        Handle handle = getHandle(false);\n        Value ret = null;\n        PreparedStatement preparedStatement = null;\n        try {\n            preparedStatement = handle.preparedWithMainStatement(sql);\n            preparedStatement.step();\n            if (!preparedStatement.isDone()) {\n                ret = preparedStatement.getValue(0);\n            }\n        } finally {\n            if (preparedStatement != null) {\n                preparedStatement.finalizeStatement();\n            }\n            if (autoInvalidateHandle()) {\n                handle.invalidate();\n            }\n        }\n        return ret;\n    }\n\n    @Nullable\n    public Value[] getOneRowFromStatement(@NotNull Statement statement) throws WCDBException {\n        Handle handle = getHandle(false);\n        Value[] ret = null;\n        PreparedStatement preparedStatement = null;\n        try {\n            preparedStatement = handle.preparedWithMainStatement(statement);\n            preparedStatement.step();\n            if (!preparedStatement.isDone()) {\n                ret = preparedStatement.getOneRow();\n            }\n        } finally {\n            if (preparedStatement != null) {\n                preparedStatement.finalizeStatement();\n            }\n            if (autoInvalidateHandle()) {\n                handle.invalidate();\n            }\n        }\n        return ret;\n    }\n\n    @Nullable\n    public Value[] getOneRowFromSQL(@NotNull String sql) throws WCDBException {\n        Handle handle = getHandle(false);\n        Value[] ret = null;\n        PreparedStatement preparedStatement = null;\n        try {\n            preparedStatement = handle.preparedWithMainStatement(sql);\n            preparedStatement.step();\n            if (!preparedStatement.isDone()) {\n                ret = preparedStatement.getOneRow();\n            }\n        } finally {\n            if (preparedStatement != null) {\n                preparedStatement.finalizeStatement();\n            }\n            if (autoInvalidateHandle()) {\n                handle.invalidate();\n            }\n        }\n        return ret;\n    }\n\n    @NotNull\n    public List<Value> getOneColumnFromStatement(@NotNull Statement statement) throws WCDBException {\n        Handle handle = getHandle(false);\n        List<Value> ret;\n        PreparedStatement preparedStatement = null;\n        try {\n            preparedStatement = handle.preparedWithMainStatement(statement);\n            ret = preparedStatement.getOneColumn();\n        } finally {\n            if (preparedStatement != null) {\n                preparedStatement.finalizeStatement();\n            }\n            if (autoInvalidateHandle()) {\n                handle.invalidate();\n            }\n        }\n        return ret;\n    }\n\n    @NotNull\n    public List<Integer> getOneColumnIntFromStatement(@NotNull Statement statement) throws WCDBException {\n        Handle handle = getHandle(false);\n        List<Integer> ret;\n        PreparedStatement preparedStatement = null;\n        try {\n            preparedStatement = handle.preparedWithMainStatement(statement);\n            ret = preparedStatement.getOneColumnInt();\n        } finally {\n            if (preparedStatement != null) {\n                preparedStatement.finalizeStatement();\n            }\n            if (autoInvalidateHandle()) {\n                handle.invalidate();\n            }\n        }\n        return ret;\n    }\n\n    @NotNull\n    public List<Long> getOneColumnLongFromStatement(@NotNull Statement statement) throws WCDBException {\n        Handle handle = getHandle(false);\n        List<Long> ret;\n        PreparedStatement preparedStatement = null;\n        try {\n            preparedStatement = handle.preparedWithMainStatement(statement);\n            ret = preparedStatement.getOneColumnLong();\n        } finally {\n            if (preparedStatement != null) {\n                preparedStatement.finalizeStatement();\n            }\n            if (autoInvalidateHandle()) {\n                handle.invalidate();\n            }\n        }\n        return ret;\n    }\n\n    @NotNull\n    public List<Float> getOneColumnFloatFromStatement(@NotNull Statement statement) throws WCDBException {\n        Handle handle = getHandle(false);\n        List<Float> ret;\n        PreparedStatement preparedStatement = null;\n        try {\n            preparedStatement = handle.preparedWithMainStatement(statement);\n            ret = preparedStatement.getOneColumnFloat();\n        } finally {\n            if (preparedStatement != null) {\n                preparedStatement.finalizeStatement();\n            }\n            if (autoInvalidateHandle()) {\n                handle.invalidate();\n            }\n        }\n        return ret;\n    }\n\n    @NotNull\n    public List<Double> getOneColumnDoubleFromStatement(@NotNull Statement statement) throws WCDBException {\n        Handle handle = getHandle(false);\n        List<Double> ret;\n        PreparedStatement preparedStatement = null;\n        try {\n            preparedStatement = handle.preparedWithMainStatement(statement);\n            ret = preparedStatement.getOneColumnDouble();\n        } finally {\n            if (preparedStatement != null) {\n                preparedStatement.finalizeStatement();\n            }\n            if (autoInvalidateHandle()) {\n                handle.invalidate();\n            }\n        }\n        return ret;\n    }\n\n    @NotNull\n    public List<String> getOneColumnStringFromStatement(@NotNull Statement statement) throws WCDBException {\n        Handle handle = getHandle(false);\n        List<String> ret;\n        PreparedStatement preparedStatement = null;\n        try {\n            preparedStatement = handle.preparedWithMainStatement(statement);\n            ret = preparedStatement.getOneColumnString();\n        } finally {\n            if (preparedStatement != null) {\n                preparedStatement.finalizeStatement();\n            }\n            if (autoInvalidateHandle()) {\n                handle.invalidate();\n            }\n        }\n        return ret;\n    }\n\n    @NotNull\n    public List<byte[]> getOneColumnBLOBFromStatement(@NotNull Statement statement) throws WCDBException {\n        Handle handle = getHandle(false);\n        List<byte[]> ret;\n        PreparedStatement preparedStatement = null;\n        try {\n            preparedStatement = handle.preparedWithMainStatement(statement);\n            ret = preparedStatement.getOneColumnBLOB();\n        } finally {\n            if (preparedStatement != null) {\n                preparedStatement.finalizeStatement();\n            }\n            if (autoInvalidateHandle()) {\n                handle.invalidate();\n            }\n        }\n        return ret;\n    }\n\n    @NotNull\n    public List<Value> getOneColumnFromSQL(@NotNull String sql) throws WCDBException {\n        Handle handle = getHandle(false);\n        List<Value> ret;\n        PreparedStatement preparedStatement = null;\n        try {\n            preparedStatement = handle.preparedWithMainStatement(sql);\n            ret = preparedStatement.getOneColumn();\n        } finally {\n            if (preparedStatement != null) {\n                preparedStatement.finalizeStatement();\n            }\n            if (autoInvalidateHandle()) {\n                handle.invalidate();\n            }\n        }\n        return ret;\n    }\n\n    @NotNull\n    public List<Value[]> getAllRowsFromStatement(@NotNull Statement statement) throws WCDBException {\n        Handle handle = getHandle(false);\n        List<Value[]> ret;\n        PreparedStatement preparedStatement = null;\n        try {\n            preparedStatement = handle.preparedWithMainStatement(statement);\n            ret = preparedStatement.getMultiRows();\n        } finally {\n            if (preparedStatement != null) {\n                preparedStatement.finalizeStatement();\n            }\n            if (autoInvalidateHandle()) {\n                handle.invalidate();\n            }\n        }\n        return ret;\n    }\n\n    @NotNull\n    public List<Value[]> getAllRowsFromSQL(@NotNull String sql) throws WCDBException {\n        Handle handle = getHandle(false);\n        List<Value[]> ret;\n        PreparedStatement preparedStatement = null;\n        try {\n            preparedStatement = handle.preparedWithMainStatement(sql);\n            ret = preparedStatement.getMultiRows();\n        } finally {\n            if (preparedStatement != null) {\n                preparedStatement.finalizeStatement();\n            }\n            if (autoInvalidateHandle()) {\n                handle.invalidate();\n            }\n        }\n        return ret;\n    }\n\n    /**\n     * Execute a statement directly.\n     *\n     * @param statement The statement to execute.\n     * @throws WCDBException if any error occurs.\n     */\n    public void execute(@NotNull Statement statement) throws WCDBException {\n        Handle handle = getHandle(statement.isWriteStatement());\n        WCDBException exception = null;\n        if (!Handle.execute(handle.getCppHandle(), CppObject.get(statement))) {\n            exception = handle.createException();\n        }\n        if (autoInvalidateHandle()) {\n            handle.invalidate();\n        }\n        if (exception != null) {\n            throw exception;\n        }\n    }\n\n    /**\n     * Execute a sql string directly.\n     * Note that you should no execute sql string on a migrating or compressing table.\n     *\n     * @param sql The sql string to execute.\n     * @throws WCDBException if any error occurs.\n     */\n    public void execute(@NotNull String sql) throws WCDBException {\n        Handle handle = getHandle(false);\n        WCDBException exception = null;\n        if (!Handle.executeSQL(handle.getCppHandle(), sql)) {\n            exception = handle.createException();\n        }\n        if (autoInvalidateHandle()) {\n            handle.invalidate();\n        }\n        if (exception != null) {\n            throw exception;\n        }\n    }\n\n    /**\n     * Check whether the current database has begun a transaction in the current thread with {@code sqlite3_get_autocommit}.\n     *\n     * @return True if current database has begun a transaction in the current thread.\n     * @throws WCDBException if any error occurs.\n     */\n    public boolean isInTransaction() throws WCDBException {\n        Handle handle = null;\n        boolean res;\n        try {\n            handle = getHandle(false);\n            res = Handle.isInTransaction(handle.getCppHandle());\n        } finally {\n            if (handle != null && autoInvalidateHandle()) {\n                handle.invalidate();\n            }\n        }\n        return res;\n    }\n\n    /**\n     * Begin a transaction.\n     * Separate interface of {@link HandleOperation#runTransaction(Transaction)}\n     * You should call {@link HandleOperation#beginTransaction()}, {@link HandleOperation#commitTransaction()}, {@link HandleOperation#rollbackTransaction()} and all other operations in same thread.\n     *\n     * @throws WCDBException if any error occurs.\n     */\n    public void beginTransaction() throws WCDBException {\n        Handle handle = getHandle(true);\n        WCDBException exception = null;\n        if (!Handle.beginTransaction(handle.getCppHandle())) {\n            exception = handle.createException();\n        }\n        if (autoInvalidateHandle()) {\n            handle.invalidate();\n        }\n        if (exception != null) {\n            throw exception;\n        }\n    }\n\n    /**\n     * Commit current transaction.\n     * Separate interface of {@link HandleOperation#runTransaction(Transaction)}\n     * You should call {@link HandleOperation#beginTransaction()}, {@link HandleOperation#commitTransaction()}, {@link HandleOperation#rollbackTransaction()} and all other operations in same thread.\n     *\n     * @throws WCDBException if any error occurs.\n     */\n    public void commitTransaction() throws WCDBException {\n        Handle handle = getHandle(true);\n        WCDBException exception = null;\n        if (!Handle.commitTransaction(handle.getCppHandle())) {\n            exception = handle.createException();\n        }\n        if (autoInvalidateHandle()) {\n            handle.invalidate();\n        }\n        if (exception != null) {\n            throw exception;\n        }\n    }\n\n    /**\n     * Rollback current transaction.\n     * Separate interface of {@link HandleOperation#runTransaction(Transaction)}\n     * You should call {@link HandleOperation#beginTransaction()}, {@link HandleOperation#commitTransaction()}, {@link HandleOperation#rollbackTransaction()} and all other operations in same thread.\n     *\n     * @throws WCDBException if any error occurs.\n     */\n    public void rollbackTransaction() throws WCDBException {\n        Handle handle = getHandle(true);\n        Handle.rollbackTransaction(handle.getCppHandle());\n        if (autoInvalidateHandle()) {\n            handle.invalidate();\n        }\n    }\n\n    /**\n     * Run a transaction in a closure. Transaction supports nesting.\n     *\n     * @param transaction The operation inside transaction.\n     * @throws WCDBException if any error occurs.\n     */\n    public void runTransaction(@NotNull Transaction transaction) throws WCDBException {\n        Handle handle = getHandle(true);\n        WCDBException exception = null;\n        if (!handle.runTransaction(handle.getCppHandle(), transaction)) {\n            exception = handle.createException();\n        }\n        if (autoInvalidateHandle()) {\n            handle.invalidate();\n        }\n        if (exception != null) {\n            throw exception;\n        }\n    }\n\n    /**\n     * Run a pausable transaction in a closure.\n     * Firstly, WCDB will begin a transaction and call the block.\n     * After the block is finished, WCDB will check whether the main thread is suspended due to the current transaction.\n     * If not, it will call the block again; if it is, it will temporarily commit the current transaction.\n     * Once database operations in main thread are finished, WCDB will rebegin a new transaction in the current thread and call the block.\n     * This process will be repeated until the return value of the block is specified as true, or some error occurs during the transaction.\n     * You can use pausable transaction to do some long term database operations, such as data cleaning or data migration, and avoid to block the main thread.\n     * <pre>\n     *     <code>\n     *         database.runPausableTransaction(new PausableTransaction() {\n     *             public boolean insideTransaction(Handle handle, boolean isNewTransaction) throws WCDBException {\n     *                 if(isNewTransaction) {\n     *                     // Do some initialization for new transaction.\n     *                 }\n     *                 // Perform a small amount of data processing.\n     *                 if( Error occurs ) {\n     *                     throws WCDBException;\n     *                 }\n     *                 if( All database operations are finished ) {\n     *                     return true;\n     *                 }\n     *                 return false;\n     *             }\n     *         });\n     *     </code>\n     * </pre>\n     *\n     * @param transaction The operation inside transaction.\n     * @throws WCDBException if any error occurs.\n     */\n    public void runPausableTransaction(@NotNull PausableTransaction transaction) throws WCDBException {\n        Handle handle = getHandle(true);\n        WCDBException exception = null;\n        if (!handle.runPausableTransaction(handle.getCppHandle(), transaction)) {\n            exception = handle.createException();\n        }\n        if (autoInvalidateHandle()) {\n            handle.invalidate();\n        }\n        if (exception != null) {\n            throw exception;\n        }\n    }\n}\n"
  },
  {
    "path": "src/java/main/src/main/java/com/tencent/wcdb/core/PausableTransaction.java",
    "content": "// Created by qiuwenchen on 2023/5/23.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdb.core;\n\nimport com.tencent.wcdb.base.WCDBException;\n\nimport org.jetbrains.annotations.NotNull;\n\npublic interface PausableTransaction {\n    /**\n     * Triggered when a new transaction is begun successfully or the main thread isn't suspended due to the current transaction.\n     *\n     * @param handle           current handle\n     * @param isNewTransaction ture if is a new transaction.\n     * @return true to finish transaction.\n     * @throws WCDBException if any error occurs.\n     */\n    boolean insideTransaction(@NotNull Handle handle, boolean isNewTransaction) throws WCDBException;\n}\n"
  },
  {
    "path": "src/java/main/src/main/java/com/tencent/wcdb/core/PreparedStatement.java",
    "content": "// Created by qiuwenchen on 2023/4/19.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage com.tencent.wcdb.core;\n\nimport com.tencent.wcdb.base.CppObject;\nimport com.tencent.wcdb.base.Value;\nimport com.tencent.wcdb.base.WCDBException;\nimport com.tencent.wcdb.orm.Field;\nimport com.tencent.wcdb.orm.TableBinding;\nimport com.tencent.wcdb.winq.ColumnType;\nimport com.tencent.wcdb.winq.Statement;\n\nimport org.jetbrains.annotations.NotNull;\nimport org.jetbrains.annotations.Nullable;\n\nimport java.util.ArrayList;\nimport java.util.Collections;\nimport java.util.List;\n\npublic class PreparedStatement extends CppObject {\n    boolean autoFinalize = false;\n    int columnCount = -1;\n\n    PreparedStatement(long cppObj) {\n        this.cppObj = cppObj;\n    }\n\n    private WCDBException createException() {\n        return WCDBException.createException(getError(cppObj));\n    }\n\n    private static native long getError(long self);\n\n    void prepare(Statement statement) throws WCDBException {\n        if (!prepare(cppObj, CppObject.get(statement))) {\n            throw createException();\n        }\n    }\n\n    private static native boolean prepare(long self, long statement);\n\n    void prepare(String sql) throws WCDBException {\n        if (!prepareSQL(cppObj, sql)) {\n            throw createException();\n        }\n    }\n\n    private static native boolean prepareSQL(long self, String sql);\n\n    /**\n     * Check if there is a statement previously prepared.\n     *\n     * @return True if there is a prepared statement.\n     */\n    public boolean checkPrepared() {\n        return checkPrepared(cppObj);\n    }\n\n    private static native boolean checkPrepared(long self);\n\n    /**\n     * It is a wrapper for {@code sqlite3_step}.\n     *\n     * @throws WCDBException if any error occurs.\n     */\n    public void step() throws WCDBException {\n        if (!step(cppObj)) {\n            if (autoFinalize) {\n                finalizeStatement();\n            }\n            throw createException();\n        }\n    }\n\n    private static native boolean step(long self);\n\n    /**\n     * It is a wrapper for {@code sqlite3_reset}.\n     */\n    public void reset() {\n        reset(cppObj);\n    }\n\n    private static native void reset(long self);\n\n    /**\n     * It is a wrapper for {@code sqlite3_clear_bindings}.\n     */\n    public void clearBindings() {\n        clearBindings(cppObj);\n    }\n\n    private static native void clearBindings(long self);\n\n    /**\n     * Finalize the statement previously prepared.\n     */\n    public void finalizeStatement() {\n        finalize(cppObj);\n    }\n\n    private static native void finalize(long self);\n\n    /**\n     * Check if you can continue stepping.\n     *\n     * @return true if you can continue stepping.\n     */\n    public boolean isDone() {\n        return isDone(cppObj);\n    }\n\n    private static native boolean isDone(long self);\n\n    /**\n     * The wrapper of {@code sqlite3_bind_int64}.\n     */\n    public void bindBool(boolean value, int index) {\n        bindInteger(cppObj, value ? 1 : 0, index);\n    }\n\n    /**\n     * The wrapper of {@code sqlite3_bind_int64}.\n     */\n    public void bindBool(@Nullable Boolean value, int index) {\n        if (value != null) {\n            bindInteger(cppObj, value ? 1 : 0, index);\n        } else {\n            bindNull(index);\n        }\n    }\n\n    /**\n     * The wrapper of {@code sqlite3_bind_int64}.\n     */\n    public void bindInteger(byte value, int index) {\n        bindInteger(cppObj, value, index);\n    }\n\n    /**\n     * The wrapper of {@code sqlite3_bind_int64}.\n     */\n    public void bindInteger(@Nullable Byte value, int index) {\n        if (value != null) {\n            bindInteger(cppObj, value, index);\n        } else {\n            bindNull(index);\n        }\n    }\n\n    /**\n     * The wrapper of {@code sqlite3_bind_int64}.\n     */\n    public void bindInteger(short value, int index) {\n        bindInteger(cppObj, value, index);\n    }\n\n    /**\n     * The wrapper of {@code sqlite3_bind_int64}.\n     */\n    public void bindInteger(@Nullable Short value, int index) {\n        if (value != null) {\n            bindInteger(cppObj, value, index);\n        } else {\n            bindNull(index);\n        }\n    }\n\n    /**\n     * The wrapper of {@code sqlite3_bind_int64}.\n     */\n    public void bindInteger(int value, int index) {\n        bindInteger(cppObj, value, index);\n    }\n\n    /**\n     * The wrapper of {@code sqlite3_bind_int64}.\n     */\n    public void bindInteger(@Nullable Integer value, int index) {\n        if (value != null) {\n            bindInteger(cppObj, value, index);\n        } else {\n            bindNull(index);\n        }\n    }\n\n    /**\n     * The wrapper of {@code sqlite3_bind_int64}.\n     */\n    public void bindInteger(long value, int index) {\n        bindInteger(cppObj, value, index);\n    }\n\n    /**\n     * The wrapper of {@code sqlite3_bind_int64}.\n     */\n    public void bindInteger(@Nullable Long value, int index) {\n        if (value != null) {\n            bindInteger(cppObj, value, index);\n        } else {\n            bindNull(index);\n        }\n    }\n\n    private static native void bindInteger(long self, long value, int index);\n\n    /**\n     * The wrapper of {@code sqlite3_bind_double}.\n     */\n    public void bindDouble(float value, int index) {\n        bindDouble(cppObj, value, index);\n    }\n\n    /**\n     * The wrapper of {@code sqlite3_bind_double}.\n     */\n    public void bindDouble(@Nullable Float value, int index) {\n        if (value != null) {\n            bindDouble(cppObj, value, index);\n        } else {\n            bindNull(index);\n        }\n    }\n\n    /**\n     * The wrapper of {@code sqlite3_bind_double}.\n     */\n    public void bindDouble(double value, int index) {\n        bindDouble(cppObj, value, index);\n    }\n\n    /**\n     * The wrapper of {@code sqlite3_bind_double}.\n     */\n    public void bindDouble(@Nullable Double value, int index) {\n        if (value != null) {\n            bindDouble(cppObj, value, index);\n        } else {\n            bindNull(index);\n        }\n    }\n\n    private static native void bindDouble(long self, double value, int index);\n\n    /**\n     * The wrapper of {@code sqlite3_bind_text}.\n     */\n    public void bindText(@Nullable String value, int index) {\n        if (value == null) {\n            bindNull(index);\n            return;\n        }\n        bindText(cppObj, value, index);\n    }\n\n    private static native void bindText(long self, String value, int index);\n\n    /**\n     * The wrapper of {@code sqlite3_bind_blob}.\n     */\n    public void bindBLOB(@Nullable byte[] value, int index) {\n        if (value == null) {\n            bindNull(index);\n            return;\n        }\n        bindBLOB(cppObj, value, index);\n    }\n\n    private static native void bindBLOB(long self, byte[] value, int index);\n\n    /**\n     * The wrapper of {@code sqlite3_bind_null}.\n     */\n    public void bindNull(int index) {\n        bindNull(cppObj, index);\n    }\n\n    private static native void bindNull(long self, int index);\n\n    /**\n     * The wrapper of {@code sqlite3_bind_*}.\n     * It will call the appropriate routine according to the column type returned by {@code value.getType()}.\n     */\n    public void bindValue(@Nullable Value value, int index) {\n        if (value == null) {\n            bindNull(index);\n            return;\n        }\n        switch (value.getType()) {\n            case Integer:\n                bindInteger(value.getLong(), index);\n                return;\n            case Float:\n                bindDouble(value.getDouble(), index);\n                return;\n            case Text:\n                bindText(value.getText(), index);\n                return;\n            case BLOB:\n                bindBLOB(value.getBLOB(), index);\n                return;\n            case Null:\n                bindNull(index);\n        }\n    }\n\n    /**\n     * The wrapper of {@code sqlite3_bind_*} for binding an array of value.\n     * It will call the appropriate routine according to the column type returned by {@code value.getType()}.\n     *\n     * @param row An array of value.\n     */\n    public void bindRow(@NotNull Value[] row) {\n        int index = 1;\n        for (Value value : row) {\n            bindValue(value, index);\n            index++;\n        }\n    }\n\n    /**\n     * The wrapper of {@code sqlite3_bind_*} for binding all fields of object.\n     * It will call the appropriate routine according to the data type of field.\n     *\n     * @param obj     the object to bind.\n     * @param binding ORM binding info of the object.\n     */\n    public <T> void bindObject(@Nullable T obj, @NotNull TableBinding<T> binding) {\n        if (obj == null) {\n            return;\n        }\n        int index = 1;\n        for (Field<T> field : binding.allBindingFields()) {\n            binding.bindField(obj, field, index, this);\n            index++;\n        }\n    }\n\n    /**\n     * The wrapper of {@code sqlite3_bind_*} for binding field of object to index.\n     * It will call the appropriate routine according to the data type of field.\n     *\n     * @param obj   the object to bind.\n     * @param field the specific field to bind.\n     */\n    public <T> void bindObject(@Nullable T obj, @NotNull Field<T> field, int index) {\n        if (obj == null) {\n            bindNull(index);\n            return;\n        }\n        TableBinding<T> binding = field.getTableBinding();\n        assert binding != null;\n        binding.bindField(obj, field, index, this);\n    }\n\n    /**\n     * The wrapper of {@code sqlite3_bind_*} for binding the specified properties of object.\n     * It will call the appropriate routine according to the data type of properties.\n     *\n     * @param obj    the object to bind.\n     * @param fields the specific fields to bind.\n     */\n    public <T> void bindObject(@Nullable T obj, @NotNull Field<T>[] fields) {\n        if (obj == null || fields.length == 0) {\n            return;\n        }\n        int index = 1;\n        TableBinding<T> binding = fields[0].getTableBinding();\n        assert binding != null;\n        for (Field<T> field : fields) {\n            binding.bindField(obj, field, index, this);\n            index++;\n        }\n    }\n\n    /**\n     * The wrapper of {@code sqlite3_bind_parameter_index}.\n     */\n    public int bindParameterIndex(String parameterName) {\n        return bindParameterIndex(cppObj, parameterName);\n    }\n\n    private static native int bindParameterIndex(long self, String parameterName);\n\n    /**\n     * The wrapper of {@code sqlite3_column_type}.\n     */\n    public ColumnType getColumnType(int index) {\n        return ColumnType.valueOf(getColumnType(cppObj, index));\n    }\n\n    private static native int getColumnType(long self, int index);\n\n    /**\n     * The wrapper of {@code sqlite3_column_int64}\n     */\n    public boolean getBool(int index) {\n        return getInteger(cppObj, index) > 0;\n    }\n\n    /**\n     * The wrapper of {@code sqlite3_column_int64}\n     */\n    public byte getByte(int index) {\n        return (byte) getInteger(cppObj, index);\n    }\n\n    /**\n     * The wrapper of {@code sqlite3_column_int64}\n     */\n    public short getShort(int index) {\n        return (short) getInteger(cppObj, index);\n    }\n\n    /**\n     * The wrapper of {@code sqlite3_column_int64}\n     */\n    public int getInt(int index) {\n        return (int) getInteger(cppObj, index);\n    }\n\n    /**\n     * The wrapper of {@code sqlite3_column_int64}\n     */\n    public long getLong(int index) {\n        return getInteger(cppObj, index);\n    }\n\n    private static native long getInteger(long self, int index);\n\n    /**\n     * The wrapper of {@code sqlite3_column_double}\n     */\n    public float getFloat(int index) {\n        return (float) getDouble(cppObj, index);\n    }\n\n    /**\n     * The wrapper of {@code sqlite3_column_double}\n     */\n    public double getDouble(int index) {\n        return getDouble(cppObj, index);\n    }\n\n    private static native double getDouble(long self, int index);\n\n    /**\n     * The wrapper of {@code sqlite3_column_text}\n     */\n    @NotNull\n    public String getText(int index) {\n        return getText(cppObj, index);\n    }\n\n    private static native String getText(long self, int index);\n\n    /**\n     * The wrapper of {@code sqlite3_column_blob}\n     */\n    @NotNull\n    public byte[] getBLOB(int index) {\n        return getBLOB(cppObj, index);\n    }\n\n    private static native byte[] getBLOB(long self, int index);\n\n    /**\n     * The wrapper of {@code sqlite3_column_*}\n     */\n    @NotNull\n    public Value getValue(int index) {\n        switch (getColumnType(cppObj, index)) {\n            case 1:\n                return new Value(getInteger(cppObj, index));\n            case 2:\n                return new Value(getDouble(cppObj, index));\n            case 3:\n                return new Value(getText(cppObj, index));\n            case 4:\n                return new Value(getBLOB(cppObj, index));\n            default:\n                return new Value();\n        }\n    }\n\n    /**\n     * Extract all values of current row.\n     *\n     * @return An array of value.\n     */\n    @NotNull\n    public Value[] getOneRow() {\n        int count = getColumnCount();\n        if (count == 0) {\n            return new Value[]{};\n        }\n        Value[] row = new Value[count];\n        for (int i = 0; i < count; i++) {\n            row[i] = getValue(i);\n        }\n        return row;\n    }\n\n    /**\n     * Extract all the values of the column of index in the result.\n     *\n     * @return An list of Value.\n     * @throws WCDBException if any error occurs.\n     */\n    @NotNull\n    public List<Value> getOneColumn() throws WCDBException {\n        List<Value> column = new ArrayList<Value>();\n        step();\n        while (!isDone(cppObj)) {\n            column.add(getValue(0));\n            step();\n        }\n        return column;\n    }\n\n    /**\n     * Extract all the values of the column of index in the result.\n     *\n     * @return An list of Integer.\n     * @throws WCDBException if any error occurs.\n     */\n    @NotNull\n    public List<Integer> getOneColumnInt() throws WCDBException {\n        List<Integer> column = new ArrayList<Integer>();\n        step();\n        while (!isDone(cppObj)) {\n            column.add((int) getLong(0));\n            step();\n        }\n        return column;\n    }\n\n    /**\n     * Extract all the values of the column of index in the result.\n     *\n     * @return An list of Long.\n     * @throws WCDBException if any error occurs.\n     */\n    @NotNull\n    public List<Long> getOneColumnLong() throws WCDBException {\n        List<Long> column = new ArrayList<Long>();\n        step();\n        while (!isDone(cppObj)) {\n            column.add(getLong(0));\n            step();\n        }\n        return column;\n    }\n\n    /**\n     * Extract all the values of the column of index in the result.\n     *\n     * @return An list of Float.\n     * @throws WCDBException if any error occurs.\n     */\n    @NotNull\n    public List<Float> getOneColumnFloat() throws WCDBException {\n        List<Float> column = new ArrayList<Float>();\n        step();\n        while (!isDone(cppObj)) {\n            column.add((float) getDouble(0));\n            step();\n        }\n        return column;\n    }\n\n    /**\n     * Extract all the values of the column of index in the result.\n     *\n     * @return An list of Double.\n     * @throws WCDBException if any error occurs.\n     */\n    @NotNull\n    public List<Double> getOneColumnDouble() throws WCDBException {\n        List<Double> column = new ArrayList<Double>();\n        step();\n        while (!isDone(cppObj)) {\n            column.add(getDouble(0));\n            step();\n        }\n        return column;\n    }\n\n    /**\n     * Extract all the values of the column of index in the result.\n     *\n     * @return An list of String.\n     * @throws WCDBException if any error occurs.\n     */\n    @NotNull\n    public List<String> getOneColumnString() throws WCDBException {\n        List<String> column = new ArrayList<String>();\n        step();\n        while (!isDone(cppObj)) {\n            column.add(getText(0));\n            step();\n        }\n        return column;\n    }\n\n    /**\n     * Extract all the values of the column of index in the result.\n     *\n     * @return An list of Data.\n     * @throws WCDBException if any error occurs.\n     */\n    @NotNull\n    public List<byte[]> getOneColumnBLOB() throws WCDBException {\n        List<byte[]> column = new ArrayList<byte[]>();\n        step();\n        while (!isDone(cppObj)) {\n            column.add(getBLOB(0));\n            step();\n        }\n        return column;\n    }\n\n    /**\n     * Extract all the values in the result.\n     *\n     * @return A two-dimensional array of value.\n     * @throws WCDBException if any error occurs.\n     */\n    @NotNull\n    public List<Value[]> getMultiRows() throws WCDBException {\n        List<Value[]> rows = new ArrayList<Value[]>();\n        step();\n        while (!isDone(cppObj)) {\n            rows.add(getOneRow());\n            step();\n        }\n        return rows;\n    }\n\n    /**\n     * Extract the values of the current row and assign them into the specified fields of a new object.\n     *\n     * @param fields the specified fields.\n     * @return an object.\n     */\n    @NotNull\n    public <T> T getOneObject(@NotNull Field<T>[] fields) {\n        return getOneObject(fields, Field.getBindClass(fields));\n    }\n\n    /**\n     * Extract the values of the current row and assign them into the specified fields of a new object.\n     *\n     * @param fields the specified fields.\n     * @param cls    derived class of orm class.\n     * @return an object of derived classes of orm class.\n     */\n    @NotNull\n    public <T, R extends T> R getOneObject(@NotNull Field<T>[] fields, @NotNull Class<R> cls) {\n        assert fields.length > 0;\n\n        try {\n            return fields[0].getTableBinding().extractObject(fields, this, cls);\n        } catch (ReflectiveOperationException e) {\n            throw new RuntimeException(e);\n        }\n    }\n\n    /**\n     * Extract the values of all rows in the result and assign them into the specified fields of new objects.\n     *\n     * @param fields the specified fields.\n     * @return an list of objects.\n     * @throws WCDBException if any error occurs.\n     */\n    @NotNull\n    public <T> List<T> getAllObjects(@NotNull Field<T>[] fields) throws WCDBException {\n        return getAllObjects(fields, Field.getBindClass(fields));\n    }\n\n    /**\n     * Extract the values of all rows in the result and assign them into the specified fields of new objects.\n     *\n     * @param fields the specified fields.\n     * @param cls    derived class of orm class.\n     * @return a list of objects of derived class of orm class.\n     * @throws WCDBException if any error occurs.\n     */\n    @NotNull\n    public <T, R extends T> List<R> getAllObjects(@NotNull Field<T>[] fields, @NotNull Class<R> cls) throws WCDBException {\n        assert fields.length > 0;\n        TableBinding<T> tb = fields[0].getTableBinding();\n\n        List<R> objs = new ArrayList<>();\n        step();\n        try {\n            while (!isDone(cppObj)) {\n                objs.add(tb.extractObject(fields, this, cls));\n                step();\n            }\n        } catch (ReflectiveOperationException e) {\n            throw new RuntimeException(e);\n        }\n        return objs;\n    }\n\n    /**\n     * The wrapper of {@code sqlite3_column_count}.\n     *\n     * @return number of columns.\n     */\n    public int getColumnCount() {\n        if (columnCount == -1) {\n            columnCount = getColumnCount(cppObj);\n        }\n        return columnCount;\n    }\n\n    private static native int getColumnCount(long self);\n\n    /**\n     * The wrapper of {@code sqlite3_column_name}.\n     *\n     * @param index of column.\n     * @return name of column.\n     */\n    @NotNull\n    public String getColumnName(int index) {\n        return getColumnName(cppObj, index);\n    }\n\n    private static native String getColumnName(long self, int index);\n\n    /**\n     * The wrapper of {@code sqlite3_column_origin_name}.\n     *\n     * @param index of column.\n     * @return name of column.\n     */\n    @NotNull\n    public String getOriginalColumnName(int index) {\n        return getOriginalColumnName(cppObj, index);\n    }\n\n    private static native String getOriginalColumnName(long self, int index);\n\n    /**\n     * The wrapper of {@code sqlite3_column_table_name}.\n     *\n     * @param index of column.\n     * @return table name.\n     */\n    @NotNull\n    public String getColumnTableName(int index) {\n        return getColumnTableName(cppObj, index);\n    }\n\n    private static native String getColumnTableName(long self, int index);\n\n    /**\n     * The wrapper of {@code sqlite3_stmt_readonly}.\n     */\n    public boolean isReadOnly() {\n        return isReadOnly(cppObj);\n    }\n\n    private static native boolean isReadOnly(long self);\n\n}\n"
  },
  {
    "path": "src/java/main/src/main/java/com/tencent/wcdb/core/Table.java",
    "content": "//\n// Created by qiuwenchen on 2023/3/30.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage com.tencent.wcdb.core;\n\nimport com.tencent.wcdb.orm.TableBinding;\n\npublic class Table<T> extends TableORMOperation<T> {\n    Table(String tableName, TableBinding<T> binding, Database database) {\n        super();\n        this.tableName = tableName;\n        this.binding = binding;\n        this.database = database;\n        assert tableName != null && tableName.length() > 0;\n        assert binding != null;\n        assert database != null;\n    }\n}\n\n"
  },
  {
    "path": "src/java/main/src/main/java/com/tencent/wcdb/core/TableORMOperation.java",
    "content": "// Created by qiuwenchen on 2023/3/30.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage com.tencent.wcdb.core;\n\nimport com.tencent.wcdb.chaincall.Delete;\nimport com.tencent.wcdb.chaincall.Insert;\nimport com.tencent.wcdb.chaincall.Select;\nimport com.tencent.wcdb.chaincall.Update;\nimport com.tencent.wcdb.orm.Field;\nimport com.tencent.wcdb.orm.TableBinding;\nimport com.tencent.wcdb.base.WCDBException;\nimport com.tencent.wcdb.winq.Expression;\nimport com.tencent.wcdb.winq.OrderingTerm;\n\nimport org.jetbrains.annotations.NotNull;\nimport org.jetbrains.annotations.Nullable;\n\nimport java.util.Collection;\nimport java.util.List;\n\npublic class TableORMOperation<T> extends TableOperation {\n    TableBinding<T> binding = null;\n\n    TableORMOperation() {\n        super();\n    }\n\n    /**\n     * Get orm binding.\n     */\n    @NotNull\n    public TableBinding<T> getBinding() {\n        return binding;\n    }\n\n    /**\n     * Generate a {@link Insert} to do an insertion or replacement.\n     *\n     * @return An {@link Insert} object.\n     */\n    @NotNull\n    public Insert<T> prepareInsert() {\n        Insert<T> insert = new Insert<T>(database.getHandle(true), false, true);\n        insert.intoTable(tableName);\n        return insert;\n    }\n\n    /**\n     * Generate a {@link Update} to do an update.\n     *\n     * @return An {@link Update} object.\n     */\n    @NotNull\n    public Update<T> prepareUpdate() {\n        Update<T> update = new Update<T>(database.getHandle(true), false, true);\n        update.table(tableName);\n        return update;\n    }\n\n    /**\n     * Generate a {@link Select} to do an object selection.\n     *\n     * @return An {@link Select} object.\n     */\n    @NotNull\n    public Select<T> prepareSelect() {\n        Select<T> select = new Select<T>(database.getHandle(false), false, true);\n        select.from(tableName);\n        return select;\n    }\n\n    /**\n     * Generate a {@link Delete} to do a deletion.\n     *\n     * @return An {@link Delete} object.\n     */\n    @NotNull\n    public Delete prepareDelete() throws WCDBException {\n        Delete delete = new Delete(database.getHandle(true), false, true);\n        delete.fromTable(tableName);\n        return delete;\n    }\n\n    /**\n     * Execute inserting with one object on all fields.\n     *\n     * @param object The object to insert..\n     * @throws WCDBException if any error occurs.\n     */\n    public void insertObject(@Nullable T object) throws WCDBException {\n        prepareInsert().value(object).onFields(binding.allBindingFields()).execute();\n    }\n\n    /**\n     * Execute inserting with one object on specific(or all) fields.\n     *\n     * @param object The object to insert.\n     * @param fields specific(or all) fields.\n     * @throws WCDBException if any error occurs.\n     */\n    public void insertObject(@Nullable T object, @NotNull Field<T>[] fields) throws WCDBException {\n        prepareInsert().value(object).onFields(fields).execute();\n    }\n\n    /**\n     * Execute inserting with one object on all fields.\n     * It will replace the original row while they have same primary key or row id.\n     *\n     * @param object The object to insert.\n     * @throws WCDBException if any error occurs.\n     */\n    public void insertOrReplaceObject(@Nullable T object) throws WCDBException {\n        prepareInsert().orReplace().value(object).onFields(binding.allBindingFields()).execute();\n    }\n\n    /**\n     * Execute inserting with one object on specific(or all) fields.\n     * It will replace the original row while they have same primary key or row id.\n     *\n     * @param object The object to insert.\n     * @param fields specific(or all) fields.\n     * @throws WCDBException if any error occurs.\n     */\n    public void insertOrReplaceObject(@Nullable T object, @NotNull Field<T>[] fields) throws WCDBException {\n        prepareInsert().orReplace().value(object).onFields(fields).execute();\n    }\n\n    /**\n     * Execute inserting with one object on all fields.\n     * It will ignore the object while there already exists the same primary key or row id in current table.\n     *\n     * @param object The object to insert.\n     * @throws WCDBException if any error occurs.\n     */\n    public void insertOrIgnoreObject(@Nullable T object) throws WCDBException {\n        prepareInsert().orIgnore().value(object).onFields(binding.allBindingFields()).execute();\n    }\n\n    /**\n     * Execute inserting with one object on specific(or all) fields.\n     * It will ignore the object while there already exists the same primary key or row id in current table.\n     *\n     * @param object The object to insert.\n     * @param fields specific(or all) fields.\n     * @throws WCDBException if any error occurs.\n     */\n    public void insertOrIgnoreObject(@Nullable T object, @NotNull Field<T>[] fields) throws WCDBException {\n        prepareInsert().orIgnore().value(object).onFields(fields).execute();\n    }\n\n    /**\n     * Execute inserting with multi objects on all fields.\n     * It will run embedded transaction while objects.size()>1. The embedded transaction means that it will run a transaction if it's not in other transaction, otherwise it will be executed within the existing transaction.\n     *\n     * @param objects The objects to insert.\n     * @throws WCDBException if any error occurs.\n     */\n    public void insertObjects(@NotNull Collection<T> objects) throws WCDBException {\n        prepareInsert().values(objects).onFields(binding.allBindingFields()).execute();\n    }\n\n    /**\n     * Execute inserting with multi objects on specific(or all) fields.\n     * It will run embedded transaction while objects.size()>1. The embedded transaction means that it will run a transaction if it's not in other transaction, otherwise it will be executed within the existing transaction.\n     *\n     * @param objects The objects to insert.\n     * @param fields  specific(or all) fields.\n     * @throws WCDBException if any error occurs.\n     */\n    public void insertObjects(@NotNull Collection<T> objects, @NotNull Field<T>[] fields) throws WCDBException {\n        prepareInsert().values(objects).onFields(fields).execute();\n    }\n\n    /**\n     * Execute inserting with multi objects on all fields.\n     * It will replace the original row while they have same primary key or row id.\n     * It will run embedded transaction while objects.size()>1. The embedded transaction means that it will run a transaction if it's not in other transaction, otherwise it will be executed within the existing transaction.\n     *\n     * @param objects The objects to insert.\n     * @throws WCDBException if any error occurs.\n     */\n    public void insertOrReplaceObjects(@NotNull Collection<T> objects) throws WCDBException {\n        prepareInsert().orReplace().values(objects).onFields(binding.allBindingFields()).execute();\n    }\n\n    /**\n     * Execute inserting with multi objects on specific(or all) fields.\n     * It will replace the original row while they have same primary key or row id.\n     * It will run embedded transaction while objects.size()>1. The embedded transaction means that it will run a transaction if it's not in other transaction, otherwise it will be executed within the existing transaction.\n     *\n     * @param objects The objects to insert.\n     * @param fields  specific(or all) fields.\n     * @throws WCDBException if any error occurs.\n     */\n    public void insertOrReplaceObjects(@NotNull Collection<T> objects, @NotNull Field<T>[] fields) throws WCDBException {\n        prepareInsert().orReplace().values(objects).onFields(fields).execute();\n    }\n\n    /**\n     * Execute inserting with multi objects on all fields.\n     * It will ignore the object while there already exists the same primary key or row id in current table.\n     * It will run embedded transaction while objects.size()>1. The embedded transaction means that it will run a transaction if it's not in other transaction, otherwise it will be executed within the existing transaction.\n     *\n     * @param objects The objects to insert.\n     * @throws WCDBException if any error occurs.\n     */\n    public void insertOrIgnoreObjects(@NotNull Collection<T> objects) throws WCDBException {\n        prepareInsert().orIgnore().values(objects).onFields(binding.allBindingFields()).execute();\n    }\n\n    /**\n     * Execute inserting with multi objects on specific(or all) fields.\n     * It will ignore the object while there already exists the same primary key or row id in current table.\n     * It will run embedded transaction while objects.size()>1. The embedded transaction means that it will run a transaction if it's not in other transaction, otherwise it will be executed within the existing transaction.\n     *\n     * @param objects The objects to insert.\n     * @param fields  specific(or all) fields.\n     * @throws WCDBException if any error occurs.\n     */\n    public void insertOrIgnoreObjects(@NotNull Collection<T> objects, @NotNull Field<T>[] fields) throws WCDBException {\n        prepareInsert().orIgnore().values(objects).onFields(fields).execute();\n    }\n\n    public void deleteObjects() throws WCDBException {\n        prepareDelete().execute();\n    }\n\n    public void deleteObjects(@Nullable Expression condition) throws WCDBException {\n        prepareDelete().where(condition).execute();\n    }\n\n    public void deleteObjects(@Nullable Expression condition, @Nullable OrderingTerm order, long limit) throws WCDBException {\n        prepareDelete().where(condition).orderBy(order).limit(limit).execute();\n    }\n\n    public void deleteObjects(@Nullable Expression condition, @Nullable OrderingTerm order, long limit, long offset) throws WCDBException {\n        prepareDelete().where(condition).orderBy(order).limit(limit).offset(offset).execute();\n    }\n\n    public void deleteObjects(@Nullable OrderingTerm order, long limit) throws WCDBException {\n        prepareDelete().orderBy(order).limit(limit).execute();\n    }\n\n    public void deleteObjects(@Nullable OrderingTerm order, long limit, long offset) throws WCDBException {\n        prepareDelete().orderBy(order).limit(limit).offset(offset).execute();\n    }\n\n    public void updateObject(@Nullable T object) throws WCDBException {\n        prepareUpdate().set(binding.allBindingFields()).toObject(object).execute();\n    }\n\n    public void updateObject(@Nullable T object, @Nullable Expression condition) throws WCDBException {\n        prepareUpdate().set(binding.allBindingFields()).toObject(object).where(condition).execute();\n    }\n\n    public void updateObject(@Nullable T object, @Nullable Expression condition, @Nullable OrderingTerm order, long limit) throws WCDBException {\n        prepareUpdate().set(binding.allBindingFields()).toObject(object).where(condition).orderBy(order).limit(limit).execute();\n    }\n\n    public void updateObject(@Nullable T object, @Nullable Expression condition, @Nullable OrderingTerm order, long limit, long offset) throws WCDBException {\n        prepareUpdate().set(binding.allBindingFields()).toObject(object).where(condition).orderBy(order).limit(limit).offset(offset).execute();\n    }\n\n    public void updateObject(@Nullable T object, @Nullable OrderingTerm order, long limit) throws WCDBException {\n        prepareUpdate().set(binding.allBindingFields()).toObject(object).orderBy(order).limit(limit).execute();\n    }\n\n    public void updateObject(@Nullable T object, @Nullable OrderingTerm order, long limit, long offset) throws WCDBException {\n        prepareUpdate().set(binding.allBindingFields()).toObject(object).orderBy(order).limit(limit).offset(offset).execute();\n    }\n\n    public void updateObject(@Nullable T object, @NotNull Field<T> field) throws WCDBException {\n        prepareUpdate().set(field).toObject(object).execute();\n    }\n\n    public void updateObject(@Nullable T object, @NotNull Field<T> field, @Nullable Expression condition) throws WCDBException {\n        prepareUpdate().set(field).toObject(object).where(condition).execute();\n    }\n\n    public void updateObject(@Nullable T object, @NotNull Field<T> field, @Nullable Expression condition, @Nullable OrderingTerm order, long limit) throws WCDBException {\n        prepareUpdate().set(field).toObject(object).where(condition).orderBy(order).limit(limit).execute();\n    }\n\n    public void updateObject(@Nullable T object, @NotNull Field<T> field, @Nullable Expression condition, @Nullable OrderingTerm order, long limit, long offset) throws WCDBException {\n        prepareUpdate().set(field).toObject(object).where(condition).orderBy(order).limit(limit).offset(offset).execute();\n    }\n\n    public void updateObject(@Nullable T object, @NotNull Field<T> field, @Nullable OrderingTerm order, long limit) throws WCDBException {\n        prepareUpdate().set(field).toObject(object).orderBy(order).limit(limit).execute();\n    }\n\n    public void updateObject(@Nullable T object, @NotNull Field<T> field, @Nullable OrderingTerm order, long limit, long offset) throws WCDBException {\n        prepareUpdate().set(field).toObject(object).orderBy(order).limit(limit).offset(offset).execute();\n    }\n\n    public void updateObject(@Nullable T object, @NotNull Field<T>[] fields) throws WCDBException {\n        prepareUpdate().set(fields).toObject(object).execute();\n    }\n\n    public void updateObject(@Nullable T object, @NotNull Field<T>[] fields, @Nullable Expression condition) throws WCDBException {\n        prepareUpdate().set(fields).toObject(object).where(condition).execute();\n    }\n\n    public void updateObject(@Nullable T object, @NotNull Field<T>[] fields, @Nullable Expression condition, @Nullable OrderingTerm order, long limit) throws WCDBException {\n        prepareUpdate().set(fields).toObject(object).where(condition).orderBy(order).limit(limit).execute();\n    }\n\n    public void updateObject(@Nullable T object, @NotNull Field<T>[] fields, @Nullable Expression condition, @Nullable OrderingTerm order, long limit, long offset) throws WCDBException {\n        prepareUpdate().set(fields).toObject(object).where(condition).orderBy(order).limit(limit).offset(offset).execute();\n    }\n\n    public void updateObject(@Nullable T object, @NotNull Field<T>[] fields, @Nullable OrderingTerm order, long limit) throws WCDBException {\n        prepareUpdate().set(fields).toObject(object).orderBy(order).limit(limit).execute();\n    }\n\n    public void updateObject(@Nullable T object, @NotNull Field<T>[] fields, @Nullable OrderingTerm order, long limit, long offset) throws WCDBException {\n        prepareUpdate().set(fields).toObject(object).orderBy(order).limit(limit).offset(offset).execute();\n    }\n\n    @Nullable\n    public T getFirstObject() throws WCDBException {\n        return prepareSelect().select(binding.allBindingFields()).firstObject();\n    }\n\n    @Nullable\n    public <R extends T> R getFirstObject(@NotNull Class<R> cls) throws WCDBException {\n        return prepareSelect().select(binding.allBindingFields()).firstObject(cls);\n    }\n\n    @Nullable\n    public T getFirstObject(@Nullable Expression condition) throws WCDBException {\n        return prepareSelect().select(binding.allBindingFields()).where(condition).firstObject();\n    }\n\n    @Nullable\n    public <R extends T> R getFirstObject(@Nullable Expression condition, @NotNull Class<R> cls) throws WCDBException {\n        return prepareSelect().select(binding.allBindingFields()).where(condition).firstObject(cls);\n    }\n\n    @Nullable\n    public T getFirstObject(@Nullable Expression condition, @Nullable OrderingTerm order) throws WCDBException {\n        return prepareSelect().select(binding.allBindingFields()).where(condition).orderBy(order).firstObject();\n    }\n\n    @Nullable\n    public <R extends T> R getFirstObject(@Nullable Expression condition, @Nullable OrderingTerm order, @NotNull Class<R> cls) throws WCDBException {\n        return prepareSelect().select(binding.allBindingFields()).where(condition).orderBy(order).firstObject(cls);\n    }\n\n    @Nullable\n    public T getFirstObject(@Nullable Expression condition, @Nullable OrderingTerm order, long offset) throws WCDBException {\n        return prepareSelect().select(binding.allBindingFields()).where(condition).orderBy(order).limit(1).offset(offset).firstObject();\n    }\n\n    @Nullable\n    public <R extends T> R getFirstObject(@Nullable Expression condition, @Nullable OrderingTerm order, long offset, @NotNull Class<R> cls) throws WCDBException {\n        return prepareSelect().select(binding.allBindingFields()).where(condition).orderBy(order).limit(1).offset(offset).firstObject(cls);\n    }\n\n    @Nullable\n    public T getFirstObject(@Nullable OrderingTerm order) throws WCDBException {\n        return prepareSelect().select(binding.allBindingFields()).orderBy(order).firstObject();\n    }\n\n    @Nullable\n    public <R extends T> R getFirstObject(@Nullable OrderingTerm order, @NotNull Class<R> cls) throws WCDBException {\n        return prepareSelect().select(binding.allBindingFields()).orderBy(order).firstObject(cls);\n    }\n\n    @Nullable\n    public T getFirstObject(@Nullable OrderingTerm order, long offset) throws WCDBException {\n        return prepareSelect().select(binding.allBindingFields()).orderBy(order).limit(1).offset(offset).firstObject();\n    }\n\n    @Nullable\n    public <R extends T> R getFirstObject(@Nullable OrderingTerm order, long offset, @NotNull Class<R> cls) throws WCDBException {\n        return prepareSelect().select(binding.allBindingFields()).orderBy(order).limit(1).offset(offset).firstObject(cls);\n    }\n\n    @Nullable\n    public T getFirstObject(@NotNull Field<T>[] fields) throws WCDBException {\n        return prepareSelect().select(fields).firstObject();\n    }\n\n    @Nullable\n    public <R extends T> R getFirstObject(@NotNull Field<T>[] fields, @NotNull Class<R> cls) throws WCDBException {\n        return prepareSelect().select(fields).firstObject(cls);\n    }\n\n    @Nullable\n    public T getFirstObject(@NotNull Field<T>[] fields, @Nullable Expression condition) throws WCDBException {\n        return prepareSelect().select(fields).where(condition).firstObject();\n    }\n\n    @Nullable\n    public <R extends T> R getFirstObject(@NotNull Field<T>[] fields, @Nullable Expression condition, @NotNull Class<R> cls) throws WCDBException {\n        return prepareSelect().select(fields).where(condition).firstObject(cls);\n    }\n\n    @Nullable\n    public T getFirstObject(@NotNull Field<T>[] fields, @Nullable Expression condition, @Nullable OrderingTerm order) throws WCDBException {\n        return prepareSelect().select(fields).where(condition).orderBy(order).firstObject();\n    }\n\n    @Nullable\n    public <R extends T> R getFirstObject(@NotNull Field<T>[] fields, @Nullable Expression condition, @Nullable OrderingTerm order, @NotNull Class<R> cls) throws WCDBException {\n        return prepareSelect().select(fields).where(condition).orderBy(order).firstObject(cls);\n    }\n\n    @Nullable\n    public T getFirstObject(@NotNull Field<T>[] fields, @Nullable Expression condition, @Nullable OrderingTerm order, long offset) throws WCDBException {\n        return prepareSelect().select(fields).where(condition).orderBy(order).limit(1).offset(offset).firstObject();\n    }\n\n    @Nullable\n    public <R extends T> R getFirstObject(@NotNull Field<T>[] fields, @Nullable Expression condition, @Nullable OrderingTerm order, long offset, @NotNull Class<R> cls) throws WCDBException {\n        return prepareSelect().select(fields).where(condition).orderBy(order).limit(1).offset(offset).firstObject(cls);\n    }\n\n    @Nullable\n    public T getFirstObject(@NotNull Field<T>[] fields, @Nullable OrderingTerm order) throws WCDBException {\n        return prepareSelect().select(fields).orderBy(order).firstObject();\n    }\n\n    @Nullable\n    public <R extends T> R getFirstObject(@NotNull Field<T>[] fields, @Nullable OrderingTerm order, @NotNull Class<R> cls) throws WCDBException {\n        return prepareSelect().select(fields).orderBy(order).firstObject(cls);\n    }\n\n    @Nullable\n    public T getFirstObject(@NotNull Field<T>[] fields, @Nullable OrderingTerm order, long offset) throws WCDBException {\n        return prepareSelect().select(fields).orderBy(order).limit(1).offset(offset).firstObject();\n    }\n\n    @Nullable\n    public <R extends T> R getFirstObject(@NotNull Field<T>[] fields, @Nullable OrderingTerm order, long offset, @NotNull Class<R> cls) throws WCDBException {\n        return prepareSelect().select(fields).orderBy(order).limit(1).offset(offset).firstObject(cls);\n    }\n\n    @NotNull\n    public List<T> getAllObjects() throws WCDBException {\n        return prepareSelect().select(binding.allBindingFields()).allObjects();\n    }\n\n    @NotNull\n    public <R extends T> List<R> getAllObjects(@NotNull Class<R> cls) throws WCDBException {\n        return prepareSelect().select(binding.allBindingFields()).allObjects(cls);\n    }\n\n    @NotNull\n    public List<T> getAllObjects(@Nullable Expression condition) throws WCDBException {\n        return prepareSelect().select(binding.allBindingFields()).where(condition).allObjects();\n    }\n\n    @NotNull\n    public <R extends T> List<R> getAllObjects(@Nullable Expression condition, @NotNull Class<R> cls) throws WCDBException {\n        return prepareSelect().select(binding.allBindingFields()).where(condition).allObjects(cls);\n    }\n\n    @NotNull\n    public List<T> getAllObjects(@Nullable Expression condition, @Nullable OrderingTerm order) throws WCDBException {\n        return prepareSelect().select(binding.allBindingFields()).where(condition).orderBy(order).allObjects();\n    }\n\n    @NotNull\n    public <R extends T> List<R> getAllObjects(@Nullable Expression condition, @Nullable OrderingTerm order, @NotNull Class<R> cls) throws WCDBException {\n        return prepareSelect().select(binding.allBindingFields()).where(condition).orderBy(order).allObjects(cls);\n    }\n\n    @NotNull\n    public List<T> getAllObjects(@Nullable Expression condition, @Nullable OrderingTerm order, long limit) throws WCDBException {\n        return prepareSelect().select(binding.allBindingFields()).where(condition).orderBy(order).limit(limit).allObjects();\n    }\n\n    @NotNull\n    public <R extends T> List<R> getAllObjects(@Nullable Expression condition, @Nullable OrderingTerm order, long limit, @NotNull Class<R> cls) throws WCDBException {\n        return prepareSelect().select(binding.allBindingFields()).where(condition).orderBy(order).limit(limit).allObjects(cls);\n    }\n\n    @NotNull\n    public List<T> getAllObjects(@Nullable Expression condition, @Nullable OrderingTerm order, long limit, long offset) throws WCDBException {\n        return prepareSelect().select(binding.allBindingFields()).where(condition).orderBy(order).limit(limit).offset(offset).allObjects();\n    }\n\n    @NotNull\n    public <R extends T> List<R> getAllObjects(@Nullable Expression condition, @Nullable OrderingTerm order, long limit, long offset, @NotNull Class<R> cls) throws WCDBException {\n        return prepareSelect().select(binding.allBindingFields()).where(condition).orderBy(order).limit(limit).offset(offset).allObjects(cls);\n    }\n\n    @NotNull\n    public List<T> getAllObjects(@Nullable OrderingTerm order) throws WCDBException {\n        return prepareSelect().select(binding.allBindingFields()).orderBy(order).allObjects();\n    }\n\n    @NotNull\n    public <R extends T> List<R> getAllObjects(@Nullable OrderingTerm order, @NotNull Class<R> cls) throws WCDBException {\n        return prepareSelect().select(binding.allBindingFields()).orderBy(order).allObjects(cls);\n    }\n\n    @NotNull\n    public List<T> getAllObjects(@Nullable OrderingTerm order, long limit) throws WCDBException {\n        return prepareSelect().select(binding.allBindingFields()).orderBy(order).limit(limit).allObjects();\n    }\n\n    @NotNull\n    public <R extends T> List<R> getAllObjects(@Nullable OrderingTerm order, long limit, @NotNull Class<R> cls) throws WCDBException {\n        return prepareSelect().select(binding.allBindingFields()).orderBy(order).limit(limit).allObjects(cls);\n    }\n\n    @NotNull\n    public List<T> getAllObjects(@Nullable OrderingTerm order, long limit, long offset) throws WCDBException {\n        return prepareSelect().select(binding.allBindingFields()).orderBy(order).limit(limit).offset(offset).allObjects();\n    }\n\n    @NotNull\n    public <R extends T> List<R> getAllObjects(@Nullable OrderingTerm order, long limit, long offset, @NotNull Class<R> cls) throws WCDBException {\n        return prepareSelect().select(binding.allBindingFields()).orderBy(order).limit(limit).offset(offset).allObjects(cls);\n    }\n\n    @NotNull\n    public List<T> getAllObjects(@NotNull Field<T>[] fields) throws WCDBException {\n        return prepareSelect().select(fields).allObjects();\n    }\n\n    @NotNull\n    public <R extends T> List<R> getAllObjects(@NotNull Field<T>[] fields, @NotNull Class<R> cls) throws WCDBException {\n        return prepareSelect().select(fields).allObjects(cls);\n    }\n\n    @NotNull\n    public List<T> getAllObjects(@NotNull Field<T>[] fields, @Nullable Expression condition) throws WCDBException {\n        return prepareSelect().select(fields).where(condition).allObjects();\n    }\n\n    @NotNull\n    public <R extends T> List<R> getAllObjects(@NotNull Field<T>[] fields, @Nullable Expression condition, @NotNull Class<R> cls) throws WCDBException {\n        return prepareSelect().select(fields).where(condition).allObjects(cls);\n    }\n\n    @NotNull\n    public List<T> getAllObjects(@NotNull Field<T>[] fields, @Nullable Expression condition, @Nullable OrderingTerm order) throws WCDBException {\n        return prepareSelect().select(fields).where(condition).orderBy(order).allObjects();\n    }\n\n    @NotNull\n    public <R extends T> List<R> getAllObjects(@NotNull Field<T>[] fields, @Nullable Expression condition, @Nullable OrderingTerm order, @NotNull Class<R> cls) throws WCDBException {\n        return prepareSelect().select(fields).where(condition).orderBy(order).allObjects(cls);\n    }\n\n    @NotNull\n    public List<T> getAllObjects(@NotNull Field<T>[] fields, @Nullable Expression condition, @Nullable OrderingTerm order, long limit) throws WCDBException {\n        return prepareSelect().select(fields).where(condition).orderBy(order).limit(limit).allObjects();\n    }\n\n    @NotNull\n    public <R extends T> List<R> getAllObjects(@NotNull Field<T>[] fields, @Nullable Expression condition, @Nullable OrderingTerm order, long limit, @NotNull Class<R> cls) throws WCDBException {\n        return prepareSelect().select(fields).where(condition).orderBy(order).limit(limit).allObjects(cls);\n    }\n\n    @NotNull\n    public List<T> getAllObjects(@NotNull Field<T>[] fields, @Nullable Expression condition, @Nullable OrderingTerm order, long limit, long offset) throws WCDBException {\n        return prepareSelect().select(fields).where(condition).orderBy(order).limit(limit).offset(offset).allObjects();\n    }\n\n    @NotNull\n    public <R extends T> List<R> getAllObjects(@NotNull Field<T>[] fields, @Nullable Expression condition, @Nullable OrderingTerm order, long limit, long offset, @NotNull Class<R> cls) throws WCDBException {\n        return prepareSelect().select(fields).where(condition).orderBy(order).limit(limit).offset(offset).allObjects(cls);\n    }\n\n    @NotNull\n    public List<T> getAllObjects(@NotNull Field<T>[] fields, @Nullable OrderingTerm order) throws WCDBException {\n        return prepareSelect().select(fields).orderBy(order).allObjects();\n    }\n\n    @NotNull\n    public <R extends T> List<R> getAllObjects(@NotNull Field<T>[] fields, @Nullable OrderingTerm order, @NotNull Class<R> cls) throws WCDBException {\n        return prepareSelect().select(fields).orderBy(order).allObjects(cls);\n    }\n\n    @NotNull\n    public List<T> getAllObjects(@NotNull Field<T>[] fields, @Nullable OrderingTerm order, long limit) throws WCDBException {\n        return prepareSelect().select(fields).orderBy(order).limit(limit).allObjects();\n    }\n\n    @NotNull\n    public <R extends T> List<R> getAllObjects(@NotNull Field<T>[] fields, @Nullable OrderingTerm order, long limit, @NotNull Class<R> cls) throws WCDBException {\n        return prepareSelect().select(fields).orderBy(order).limit(limit).allObjects(cls);\n    }\n\n    @NotNull\n    public List<T> getAllObjects(@NotNull Field<T>[] fields, @Nullable OrderingTerm order, long limit, long offset) throws WCDBException {\n        return prepareSelect().select(fields).orderBy(order).limit(limit).offset(offset).allObjects();\n    }\n\n    @NotNull\n    public <R extends T> List<R> getAllObjects(@NotNull Field<T>[] fields, @Nullable OrderingTerm order, long limit, long offset, @NotNull Class<R> cls) throws WCDBException {\n        return prepareSelect().select(fields).orderBy(order).limit(limit).offset(offset).allObjects(cls);\n    }\n}\n"
  },
  {
    "path": "src/java/main/src/main/java/com/tencent/wcdb/core/TableOperation.java",
    "content": "// Created by chenqiuwen on 2023/5/3.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdb.core;\n\nimport com.tencent.wcdb.base.Value;\nimport com.tencent.wcdb.base.WCDBException;\nimport com.tencent.wcdb.winq.Column;\nimport com.tencent.wcdb.winq.ConflictAction;\nimport com.tencent.wcdb.winq.Expression;\nimport com.tencent.wcdb.winq.OrderingTerm;\nimport com.tencent.wcdb.winq.ResultColumnConvertible;\nimport com.tencent.wcdb.winq.Statement;\nimport com.tencent.wcdb.winq.StatementDelete;\nimport com.tencent.wcdb.winq.StatementInsert;\nimport com.tencent.wcdb.winq.StatementSelect;\nimport com.tencent.wcdb.winq.StatementUpdate;\n\nimport org.jetbrains.annotations.NotNull;\nimport org.jetbrains.annotations.Nullable;\n\nimport java.util.Collection;\nimport java.util.Collections;\nimport java.util.List;\n\npublic class TableOperation {\n    String tableName = null;\n    Database database = null;\n\n    /**\n     * Get table name.\n     */\n    @NotNull\n    public String getTableName() {\n        return tableName;\n    }\n\n    /**\n     * Get related database.\n     */\n    @NotNull\n    public Database getDatabase() {\n        return database;\n    }\n\n    /**\n     * Execute inserting with one row of values.\n     *\n     * @param row     One row of value.\n     * @param columns Corresponding column of values.\n     * @throws WCDBException if any error occurs.\n     */\n    public void insertRow(@NotNull Value[] row, @Nullable Column[] columns) throws WCDBException {\n        insertRows(Collections.singleton(row), columns);\n    }\n\n    /**\n     * Execute inserting with multi rows of values.\n     * It will run embedded transaction while rows.size()>1.\n     * The embedded transaction means that it will run a transaction if it's not in other transaction,\n     * otherwise it will be executed within the existing transaction.\n     *\n     * @param rows    Multi rows of value.\n     * @param columns Corresponding column of values.\n     * @throws WCDBException if any error occurs.\n     */\n    public void insertRows(@NotNull Collection<Value[]> rows, @Nullable Column[] columns) throws WCDBException {\n        insertRows(rows, columns, ConflictAction.None);\n    }\n\n    /**\n     * Execute inserting with one row of values.\n     * It will replace the original row while they have same primary key or row id.\n     *\n     * @param row     One row of value.\n     * @param columns Corresponding column of values.\n     * @throws WCDBException if any error occurs.\n     */\n    public void insertOrReplaceRow(@NotNull Value[] row, @Nullable Column[] columns) throws WCDBException {\n        insertOrReplaceRows(Collections.singleton(row), columns);\n    }\n\n    /**\n     * Execute inserting with multi rows of values.\n     * It will replace the original row while they have same primary key or row id.\n     * It will run embedded transaction while rows.size()>1.\n     * The embedded transaction means that it will run a transaction if it's not in other transaction,\n     * otherwise it will be executed within the existing transaction.\n     *\n     * @param rows    Multi rows of value.\n     * @param columns Corresponding column of values.\n     * @throws WCDBException if any error occurs.\n     */\n    public void insertOrReplaceRows(@NotNull Collection<Value[]> rows, @Nullable Column[] columns) throws WCDBException {\n        insertRows(rows, columns, ConflictAction.Replace);\n    }\n\n    /**\n     * Execute inserting with one row of values.\n     * It will ignore the row while there already exists the same primary key or row id in current table.\n     *\n     * @param row     One row of value.\n     * @param columns Corresponding column of values.\n     * @throws WCDBException if any error occurs.\n     */\n    public void insertOrIgnoreRow(@NotNull Value[] row, @Nullable Column[] columns) throws WCDBException {\n        insertOrIgnoreRows(Collections.singleton(row), columns);\n    }\n\n    /**\n     * Execute inserting with multi rows of values.\n     * It will ignore the row while there already exists the same primary key or row id in current table.\n     * It will run embedded transaction while rows.size()>1.\n     * The embedded transaction means that it will run a transaction if it's not in other transaction,\n     * otherwise it will be executed within the existing transaction.\n     *\n     * @param rows    Multi rows of value.\n     * @param columns Corresponding column of values.\n     * @throws WCDBException if any error occurs.\n     */\n    public void insertOrIgnoreRows(@NotNull Collection<Value[]> rows, @Nullable Column[] columns) throws WCDBException {\n        insertRows(rows, columns, ConflictAction.Ignore);\n    }\n\n    private void insertRows(final Collection<Value[]> rows, Column[] columns, ConflictAction action) throws WCDBException {\n        final StatementInsert insert = new StatementInsert().insertInto(tableName).columns(columns).valuesWithBindParameters(columns.length);\n        if (action == ConflictAction.Replace) {\n            insert.orReplace();\n        } else if (action == ConflictAction.Ignore) {\n            insert.orIgnore();\n        }\n        Handle handle = database.getHandle(true);\n        try {\n            if (rows.size() > 1) {\n                handle.runTransaction(new Transaction() {\n                    @Override\n                    public boolean insideTransaction(@NotNull Handle handle) throws WCDBException {\n                        insertRows(rows, insert, handle);\n                        return true;\n                    }\n                });\n            } else {\n                insertRows(rows, insert, handle);\n            }\n        } finally {\n            handle.invalidate();\n        }\n    }\n\n    private void insertRows(Collection<Value[]> rows, StatementInsert insert, Handle handle) throws WCDBException {\n        PreparedStatement preparedStatement = handle.preparedWithMainStatement(insert);\n        for (Value[] row : rows) {\n            preparedStatement.reset();\n            preparedStatement.bindRow(row);\n            preparedStatement.step();\n        }\n        preparedStatement.finalizeStatement();\n    }\n\n    public void updateValue(int value, @NotNull Column column) throws WCDBException {\n        updateRow(new Value[]{new Value(value)}, new Column[]{column});\n    }\n\n    public void updateValue(int value, @NotNull Column column, @Nullable Expression condition) throws WCDBException {\n        updateRow(new Value[]{new Value(value)}, new Column[]{column}, condition);\n    }\n\n    public void updateValue(int value, @NotNull Column column, @Nullable Expression condition, @Nullable OrderingTerm order, int limit) throws WCDBException {\n        updateRow(new Value[]{new Value(value)}, new Column[]{column}, condition, order, limit);\n    }\n\n    public void updateValue(int value, @NotNull Column column, @Nullable Expression condition, @Nullable OrderingTerm order, int limit, int offset) throws WCDBException {\n        updateRow(new Value[]{new Value(value)}, new Column[]{column}, condition, order, limit, offset);\n    }\n\n    public void updateValue(int value, @NotNull Column column, @Nullable OrderingTerm order, int limit) throws WCDBException {\n        updateRow(new Value[]{new Value(value)}, new Column[]{column}, order, limit);\n    }\n\n    public void updateValue(int value, @NotNull Column column, @Nullable OrderingTerm order, int limit, int offset) throws WCDBException {\n        updateRow(new Value[]{new Value(value)}, new Column[]{column}, order, limit, offset);\n    }\n\n    public void updateValue(long value, @NotNull Column column) throws WCDBException {\n        updateRow(new Value[]{new Value(value)}, new Column[]{column});\n    }\n\n    public void updateValue(long value, @NotNull Column column, @Nullable Expression condition) throws WCDBException {\n        updateRow(new Value[]{new Value(value)}, new Column[]{column}, condition);\n    }\n\n    public void updateValue(long value, @NotNull Column column, @Nullable Expression condition, @Nullable OrderingTerm order, int limit) throws WCDBException {\n        updateRow(new Value[]{new Value(value)}, new Column[]{column}, condition, order, limit);\n    }\n\n    public void updateValue(long value, @NotNull Column column, @Nullable Expression condition, @Nullable OrderingTerm order, int limit, int offset) throws WCDBException {\n        updateRow(new Value[]{new Value(value)}, new Column[]{column}, condition, order, limit, offset);\n    }\n\n    public void updateValue(long value, @NotNull Column column, @Nullable OrderingTerm order, int limit) throws WCDBException {\n        updateRow(new Value[]{new Value(value)}, new Column[]{column}, order, limit);\n    }\n\n    public void updateValue(long value, @NotNull Column column, @Nullable OrderingTerm order, int limit, int offset) throws WCDBException {\n        updateRow(new Value[]{new Value(value)}, new Column[]{column}, order, limit, offset);\n    }\n\n    public void updateValue(float value, @NotNull Column column) throws WCDBException {\n        updateRow(new Value[]{new Value(value)}, new Column[]{column});\n    }\n\n    public void updateValue(float value, @NotNull Column column, @Nullable Expression condition) throws WCDBException {\n        updateRow(new Value[]{new Value(value)}, new Column[]{column}, condition);\n    }\n\n    public void updateValue(float value, @NotNull Column column, @Nullable Expression condition, @Nullable OrderingTerm order, int limit) throws WCDBException {\n        updateRow(new Value[]{new Value(value)}, new Column[]{column}, condition, order, limit);\n    }\n\n    public void updateValue(float value, @NotNull Column column, @Nullable Expression condition, @Nullable OrderingTerm order, int limit, int offset) throws WCDBException {\n        updateRow(new Value[]{new Value(value)}, new Column[]{column}, condition, order, limit, offset);\n    }\n\n    public void updateValue(float value, @NotNull Column column, @Nullable OrderingTerm order, int limit) throws WCDBException {\n        updateRow(new Value[]{new Value(value)}, new Column[]{column}, order, limit);\n    }\n\n    public void updateValue(float value, @NotNull Column column, @Nullable OrderingTerm order, int limit, int offset) throws WCDBException {\n        updateRow(new Value[]{new Value(value)}, new Column[]{column}, order, limit, offset);\n    }\n\n    public void updateValue(double value, @NotNull Column column) throws WCDBException {\n        updateRow(new Value[]{new Value(value)}, new Column[]{column});\n    }\n\n    public void updateValue(double value, @NotNull Column column, @Nullable Expression condition) throws WCDBException {\n        updateRow(new Value[]{new Value(value)}, new Column[]{column}, condition);\n    }\n\n    public void updateValue(double value, @NotNull Column column, @Nullable Expression condition, @Nullable OrderingTerm order, int limit) throws WCDBException {\n        updateRow(new Value[]{new Value(value)}, new Column[]{column}, condition, order, limit);\n    }\n\n    public void updateValue(double value, @NotNull Column column, @Nullable Expression condition, @Nullable OrderingTerm order, int limit, int offset) throws WCDBException {\n        updateRow(new Value[]{new Value(value)}, new Column[]{column}, condition, order, limit, offset);\n    }\n\n    public void updateValue(double value, @NotNull Column column, @Nullable OrderingTerm order, int limit) throws WCDBException {\n        updateRow(new Value[]{new Value(value)}, new Column[]{column}, order, limit);\n    }\n\n    public void updateValue(double value, @NotNull Column column, @Nullable OrderingTerm order, int limit, int offset) throws WCDBException {\n        updateRow(new Value[]{new Value(value)}, new Column[]{column}, order, limit, offset);\n    }\n\n    public void updateValue(@Nullable String value, @NotNull Column column) throws WCDBException {\n        updateRow(new Value[]{new Value(value)}, new Column[]{column});\n    }\n\n    public void updateValue(@Nullable String value, @NotNull Column column, @Nullable Expression condition) throws WCDBException {\n        updateRow(new Value[]{new Value(value)}, new Column[]{column}, condition);\n    }\n\n    public void updateValue(@Nullable String value, @NotNull Column column, @Nullable Expression condition, @Nullable OrderingTerm order, int limit) throws WCDBException {\n        updateRow(new Value[]{new Value(value)}, new Column[]{column}, condition, order, limit);\n    }\n\n    public void updateValue(@Nullable String value, @NotNull Column column, @Nullable Expression condition, @Nullable OrderingTerm order, int limit, int offset) throws WCDBException {\n        updateRow(new Value[]{new Value(value)}, new Column[]{column}, condition, order, limit, offset);\n    }\n\n    public void updateValue(@Nullable String value, @NotNull Column column, @Nullable OrderingTerm order, int limit) throws WCDBException {\n        updateRow(new Value[]{new Value(value)}, new Column[]{column}, order, limit);\n    }\n\n    public void updateValue(@Nullable String value, @NotNull Column column, @Nullable OrderingTerm order, int limit, int offset) throws WCDBException {\n        updateRow(new Value[]{new Value(value)}, new Column[]{column}, order, limit, offset);\n    }\n\n    public void updateValue(@Nullable byte[] value, @NotNull Column column) throws WCDBException {\n        updateRow(new Value[]{new Value(value)}, new Column[]{column});\n    }\n\n    public void updateValue(@Nullable byte[] value, @NotNull Column column, @Nullable Expression condition) throws WCDBException {\n        updateRow(new Value[]{new Value(value)}, new Column[]{column}, condition);\n    }\n\n    public void updateValue(@Nullable byte[] value, @NotNull Column column, @Nullable Expression condition, @Nullable OrderingTerm order, int limit) throws WCDBException {\n        updateRow(new Value[]{new Value(value)}, new Column[]{column}, condition, order, limit);\n    }\n\n    public void updateValue(@Nullable byte[] value, @NotNull Column column, @Nullable Expression condition, @Nullable OrderingTerm order, int limit, int offset) throws WCDBException {\n        updateRow(new Value[]{new Value(value)}, new Column[]{column}, condition, order, limit, offset);\n    }\n\n    public void updateValue(@Nullable byte[] value, @NotNull Column column, @Nullable OrderingTerm order, int limit) throws WCDBException {\n        updateRow(new Value[]{new Value(value)}, new Column[]{column}, order, limit);\n    }\n\n    public void updateValue(@Nullable byte[] value, @NotNull Column column, @Nullable OrderingTerm order, int limit, int offset) throws WCDBException {\n        updateRow(new Value[]{new Value(value)}, new Column[]{column}, order, limit, offset);\n    }\n\n    public void updateValue(@Nullable Value value, @NotNull Column column) throws WCDBException {\n        updateRow(new Value[]{value}, new Column[]{column});\n    }\n\n    public void updateValue(@Nullable Value value, @NotNull Column column, @Nullable Expression condition) throws WCDBException {\n        updateRow(new Value[]{value}, new Column[]{column}, condition);\n    }\n\n    public void updateValue(@Nullable Value value, @NotNull Column column, @Nullable Expression condition, @Nullable OrderingTerm order, int limit) throws WCDBException {\n        updateRow(new Value[]{value}, new Column[]{column}, condition, order, limit);\n    }\n\n    public void updateValue(@Nullable Value value, @NotNull Column column, @Nullable Expression condition, @Nullable OrderingTerm order, int limit, int offset) throws WCDBException {\n        updateRow(new Value[]{value}, new Column[]{column}, condition, order, limit, offset);\n    }\n\n    public void updateValue(@Nullable Value value, @NotNull Column column, @Nullable OrderingTerm order, int limit) throws WCDBException {\n        updateRow(new Value[]{value}, new Column[]{column}, order, limit);\n    }\n\n    public void updateValue(@Nullable Value value, @NotNull Column column, @Nullable OrderingTerm order, int limit, int offset) throws WCDBException {\n        updateRow(new Value[]{value}, new Column[]{column}, order, limit, offset);\n    }\n\n    public void updateRow(@NotNull Value[] row, @NotNull Column[] columns) throws WCDBException {\n        StatementUpdate update = new StatementUpdate().update(tableName).setColumnsToBindParameters(columns);\n        updateRow(row, update);\n    }\n\n    public void updateRow(@NotNull Value[] row, @NotNull Column[] columns, @Nullable Expression condition) throws WCDBException {\n        StatementUpdate update = new StatementUpdate().update(tableName).setColumnsToBindParameters(columns).where(condition);\n        updateRow(row, update);\n    }\n\n    public void updateRow(@NotNull Value[] row, @NotNull Column[] columns, @Nullable Expression condition, @Nullable OrderingTerm order, int limit) throws WCDBException {\n        StatementUpdate update = new StatementUpdate().update(tableName).setColumnsToBindParameters(columns).where(condition).orderBy(order).limit(limit);\n        updateRow(row, update);\n    }\n\n    public void updateRow(@NotNull Value[] row, @NotNull Column[] columns, @Nullable Expression condition, @Nullable OrderingTerm order, int limit, int offset) throws WCDBException {\n        StatementUpdate update = new StatementUpdate().update(tableName).setColumnsToBindParameters(columns).where(condition).orderBy(order).limit(limit).offset(offset);\n        updateRow(row, update);\n    }\n\n    public void updateRow(@NotNull Value[] row, @NotNull Column[] columns, @Nullable OrderingTerm order, int limit) throws WCDBException {\n        StatementUpdate update = new StatementUpdate().update(tableName).setColumnsToBindParameters(columns).orderBy(order).limit(limit);\n        updateRow(row, update);\n    }\n\n    public void updateRow(@NotNull Value[] row, @NotNull Column[] columns, @Nullable OrderingTerm order, int limit, int offset) throws WCDBException {\n        StatementUpdate update = new StatementUpdate().update(tableName).setColumnsToBindParameters(columns).orderBy(order).limit(limit).offset(offset);\n        updateRow(row, update);\n    }\n\n    private void updateRow(@NotNull Value[] row, StatementUpdate update) throws WCDBException {\n        Handle handle = database.getHandle(true);\n        PreparedStatement preparedStatement = null;\n        try {\n            preparedStatement = handle.preparedWithMainStatement(update);\n            preparedStatement.bindRow(row);\n            preparedStatement.step();\n        } finally {\n            if (preparedStatement != null) {\n                preparedStatement.finalizeStatement();\n            }\n            handle.invalidate();\n        }\n    }\n\n    public void deleteValue() throws WCDBException {\n        StatementDelete delete = new StatementDelete().deleteFrom(tableName);\n        deleteValue(delete);\n    }\n\n    public void deleteValue(@Nullable Expression condition) throws WCDBException {\n        StatementDelete delete = new StatementDelete().deleteFrom(tableName).where(condition);\n        deleteValue(delete);\n    }\n\n    public void deleteValue(@Nullable Expression condition, @Nullable OrderingTerm orderingTerm, int limit) throws WCDBException {\n        StatementDelete delete = new StatementDelete().deleteFrom(tableName).where(condition).orderBy(orderingTerm).limit(limit);\n        deleteValue(delete);\n    }\n\n    public void deleteValue(@Nullable Expression condition, @Nullable OrderingTerm orderingTerm, int limit, int offset) throws WCDBException {\n        StatementDelete delete = new StatementDelete().deleteFrom(tableName).where(condition).orderBy(orderingTerm).limit(limit).offset(offset);\n        deleteValue(delete);\n    }\n\n    public void deleteValue(@Nullable OrderingTerm orderingTerm, int limit) throws WCDBException {\n        StatementDelete delete = new StatementDelete().deleteFrom(tableName).orderBy(orderingTerm).limit(limit);\n        deleteValue(delete);\n    }\n\n    public void deleteValue(@Nullable OrderingTerm orderingTerm, int limit, int offset) throws WCDBException {\n        StatementDelete delete = new StatementDelete().deleteFrom(tableName).orderBy(orderingTerm).limit(limit).offset(offset);\n        deleteValue(delete);\n    }\n\n    private void deleteValue(StatementDelete delete) throws WCDBException {\n        Handle handle = database.getHandle(true);\n        try {\n            handle.execute(delete);\n        } finally {\n            handle.invalidate();\n        }\n    }\n\n    @Nullable\n    public Value getValue(@NotNull ResultColumnConvertible column) throws WCDBException {\n        return getValueFromStatement(new StatementSelect().select(column).from(tableName));\n    }\n\n    @Nullable\n    public Value getValue(@NotNull ResultColumnConvertible column, @Nullable Expression condition) throws WCDBException {\n        return getValueFromStatement(new StatementSelect().select(column).from(tableName).where(condition));\n    }\n\n    @Nullable\n    public Value getValue(@NotNull ResultColumnConvertible column, @Nullable Expression condition, @Nullable OrderingTerm order) throws WCDBException {\n        return getValueFromStatement(new StatementSelect().select(column).from(tableName).where(condition).orderBy(order));\n    }\n\n    @Nullable\n    public Value getValue(@NotNull ResultColumnConvertible column, @Nullable Expression condition, @Nullable OrderingTerm order, int offset) throws WCDBException {\n        return getValueFromStatement(new StatementSelect().select(column).from(tableName).where(condition).orderBy(order).limit(1).offset(offset));\n    }\n\n    @Nullable\n    public Value getValue(@NotNull ResultColumnConvertible column, @Nullable OrderingTerm order) throws WCDBException {\n        return getValueFromStatement(new StatementSelect().select(column).from(tableName).orderBy(order));\n    }\n\n    @Nullable\n    public Value getValue(@NotNull ResultColumnConvertible column, @Nullable OrderingTerm order, int offset) throws WCDBException {\n        return getValueFromStatement(new StatementSelect().select(column).from(tableName).orderBy(order).limit(1).offset(offset));\n    }\n\n    @NotNull\n    public List<Value> getOneColumn(@NotNull ResultColumnConvertible column) throws WCDBException {\n        return getOneColumnFromStatement(new StatementSelect().select(column).from(tableName));\n    }\n\n    @NotNull\n    public List<Value> getOneColumn(@NotNull ResultColumnConvertible column, @Nullable Expression condition) throws WCDBException {\n        return getOneColumnFromStatement(new StatementSelect().select(column).from(tableName).where(condition));\n    }\n\n    @NotNull\n    public List<Value> getOneColumn(@NotNull ResultColumnConvertible column, @Nullable Expression condition, @Nullable OrderingTerm order) throws WCDBException {\n        return getOneColumnFromStatement(new StatementSelect().select(column).from(tableName).where(condition).orderBy(order));\n    }\n\n    @NotNull\n    public List<Value> getOneColumn(@NotNull ResultColumnConvertible column, @Nullable Expression condition, @Nullable OrderingTerm order, int limit) throws WCDBException {\n        return getOneColumnFromStatement(new StatementSelect().select(column).from(tableName).where(condition).orderBy(order).limit(limit));\n    }\n\n    @NotNull\n    public List<Value> getOneColumn(@NotNull ResultColumnConvertible column, @Nullable Expression condition, @Nullable OrderingTerm order, int limit, int offset) throws WCDBException {\n        return getOneColumnFromStatement(new StatementSelect().select(column).from(tableName).where(condition).orderBy(order).limit(limit).offset(offset));\n    }\n\n    @NotNull\n    public List<Value> getOneColumn(@NotNull ResultColumnConvertible column, @Nullable OrderingTerm order) throws WCDBException {\n        return getOneColumnFromStatement(new StatementSelect().select(column).from(tableName).orderBy(order));\n    }\n\n    @NotNull\n    public List<Value> getOneColumn(@NotNull ResultColumnConvertible column, @Nullable OrderingTerm order, int limit) throws WCDBException {\n        return getOneColumnFromStatement(new StatementSelect().select(column).from(tableName).orderBy(order).limit(limit));\n    }\n\n    @NotNull\n    public List<Value> getOneColumn(@NotNull ResultColumnConvertible column, @Nullable OrderingTerm order, int limit, int offset) throws WCDBException {\n        return getOneColumnFromStatement(new StatementSelect().select(column).from(tableName).orderBy(order).limit(limit).offset(offset));\n    }\n\n    @Nullable\n    public Value[] getOneRow(@NotNull ResultColumnConvertible[] columns) throws WCDBException {\n        return getOneRowFromStatement(new StatementSelect().select(columns).from(tableName));\n    }\n\n    @Nullable\n    public Value[] getOneRow(@NotNull ResultColumnConvertible[] columns, @Nullable Expression condition) throws WCDBException {\n        return getOneRowFromStatement(new StatementSelect().select(columns).from(tableName).where(condition));\n    }\n\n    @Nullable\n    public Value[] getOneRow(@NotNull ResultColumnConvertible[] columns, @Nullable Expression condition, @Nullable OrderingTerm orderingTerm) throws WCDBException {\n        return getOneRowFromStatement(new StatementSelect().select(columns).from(tableName).where(condition).orderBy(orderingTerm));\n    }\n\n    @Nullable\n    public Value[] getOneRow(@NotNull ResultColumnConvertible[] columns, @Nullable Expression condition, @Nullable OrderingTerm orderingTerm, int offset) throws WCDBException {\n        return getOneRowFromStatement(new StatementSelect().select(columns).from(tableName).where(condition).orderBy(orderingTerm).limit(1).offset(offset));\n    }\n\n    @Nullable\n    public Value[] getOneRow(@NotNull ResultColumnConvertible[] columns, @Nullable OrderingTerm orderingTerm) throws WCDBException {\n        return getOneRowFromStatement(new StatementSelect().select(columns).from(tableName).orderBy(orderingTerm));\n    }\n\n    @Nullable\n    public Value[] getOneRow(@NotNull ResultColumnConvertible[] columns, @Nullable OrderingTerm orderingTerm, int offset) throws WCDBException {\n        return getOneRowFromStatement(new StatementSelect().select(columns).from(tableName).orderBy(orderingTerm).limit(1).offset(offset));\n    }\n\n    @NotNull\n    public List<Integer> getOneColumnInt(@NotNull ResultColumnConvertible column) throws WCDBException {\n        return getOneColumnIntFromStatement(new StatementSelect().select(column).from(tableName));\n    }\n\n    @NotNull\n    public List<Integer> getOneColumnInt(@NotNull ResultColumnConvertible column, @Nullable Expression condition) throws WCDBException {\n        return getOneColumnIntFromStatement(new StatementSelect().select(column).from(tableName).where(condition));\n    }\n\n    @NotNull\n    public List<Integer> getOneColumnInt(@NotNull ResultColumnConvertible column, @Nullable Expression condition, @Nullable OrderingTerm order) throws WCDBException {\n        return getOneColumnIntFromStatement(new StatementSelect().select(column).from(tableName).where(condition).orderBy(order));\n    }\n\n    @NotNull\n    public List<Integer> getOneColumnInt(@NotNull ResultColumnConvertible column, @Nullable Expression condition, @Nullable OrderingTerm order, int limit) throws WCDBException {\n        return getOneColumnIntFromStatement(new StatementSelect().select(column).from(tableName).where(condition).orderBy(order).limit(limit));\n    }\n\n    @NotNull\n    public List<Integer> getOneColumnInt(@NotNull ResultColumnConvertible column, @Nullable Expression condition, @Nullable OrderingTerm order, int limit, int offset) throws WCDBException {\n        return getOneColumnIntFromStatement(new StatementSelect().select(column).from(tableName).where(condition).orderBy(order).limit(limit).offset(offset));\n    }\n\n    @NotNull\n    public List<Integer> getOneColumnInt(@NotNull ResultColumnConvertible column, @Nullable OrderingTerm order) throws WCDBException {\n        return getOneColumnIntFromStatement(new StatementSelect().select(column).from(tableName).orderBy(order));\n    }\n\n    @NotNull\n    public List<Integer> getOneColumnInt(@NotNull ResultColumnConvertible column, @Nullable OrderingTerm order, int limit) throws WCDBException {\n        return getOneColumnIntFromStatement(new StatementSelect().select(column).from(tableName).orderBy(order).limit(limit));\n    }\n\n    @NotNull\n    public List<Integer> getOneColumnInt(@NotNull ResultColumnConvertible column, @Nullable OrderingTerm order, int limit, int offset) throws WCDBException {\n        return getOneColumnIntFromStatement(new StatementSelect().select(column).from(tableName).orderBy(order).limit(limit).offset(offset));\n    }\n\n    @NotNull\n    public List<Long> getOneColumnLong(@NotNull ResultColumnConvertible column) throws WCDBException {\n        return getOneColumnLongFromStatement(new StatementSelect().select(column).from(tableName));\n    }\n\n    @NotNull\n    public List<Long> getOneColumnLong(@NotNull ResultColumnConvertible column, @Nullable Expression condition) throws WCDBException {\n        return getOneColumnLongFromStatement(new StatementSelect().select(column).from(tableName).where(condition));\n    }\n\n    @NotNull\n    public List<Long> getOneColumnLong(@NotNull ResultColumnConvertible column, @Nullable Expression condition, @Nullable OrderingTerm order) throws WCDBException {\n        return getOneColumnLongFromStatement(new StatementSelect().select(column).from(tableName).where(condition).orderBy(order));\n    }\n\n    @NotNull\n    public List<Long> getOneColumnLong(@NotNull ResultColumnConvertible column, @Nullable Expression condition, @Nullable OrderingTerm order, int limit) throws WCDBException {\n        return getOneColumnLongFromStatement(new StatementSelect().select(column).from(tableName).where(condition).orderBy(order).limit(limit));\n    }\n\n    @NotNull\n    public List<Long> getOneColumnLong(@NotNull ResultColumnConvertible column, @Nullable Expression condition, @Nullable OrderingTerm order, int limit, int offset) throws WCDBException {\n        return getOneColumnLongFromStatement(new StatementSelect().select(column).from(tableName).where(condition).orderBy(order).limit(limit).offset(offset));\n    }\n\n    @NotNull\n    public List<Long> getOneColumnLong(@NotNull ResultColumnConvertible column, @Nullable OrderingTerm order) throws WCDBException {\n        return getOneColumnLongFromStatement(new StatementSelect().select(column).from(tableName).orderBy(order));\n    }\n\n    @NotNull\n    public List<Long> getOneColumnLong(@NotNull ResultColumnConvertible column, @Nullable OrderingTerm order, int limit) throws WCDBException {\n        return getOneColumnLongFromStatement(new StatementSelect().select(column).from(tableName).orderBy(order).limit(limit));\n    }\n\n    @NotNull\n    public List<Long> getOneColumnLong(@NotNull ResultColumnConvertible column, @Nullable OrderingTerm order, int limit, int offset) throws WCDBException {\n        return getOneColumnLongFromStatement(new StatementSelect().select(column).from(tableName).orderBy(order).limit(limit).offset(offset));\n    }\n\n    @NotNull\n    public List<Float> getOneColumnFloat(@NotNull ResultColumnConvertible column) throws WCDBException {\n        return getOneColumnFloatFromStatement(new StatementSelect().select(column).from(tableName));\n    }\n\n    @NotNull\n    public List<Float> getOneColumnFloat(@NotNull ResultColumnConvertible column, @Nullable Expression condition) throws WCDBException {\n        return getOneColumnFloatFromStatement(new StatementSelect().select(column).from(tableName).where(condition));\n    }\n\n    @NotNull\n    public List<Float> getOneColumnFloat(@NotNull ResultColumnConvertible column, @Nullable Expression condition, @Nullable OrderingTerm order) throws WCDBException {\n        return getOneColumnFloatFromStatement(new StatementSelect().select(column).from(tableName).where(condition).orderBy(order));\n    }\n\n    @NotNull\n    public List<Float> getOneColumnFloat(@NotNull ResultColumnConvertible column, @Nullable Expression condition, @Nullable OrderingTerm order, int limit) throws WCDBException {\n        return getOneColumnFloatFromStatement(new StatementSelect().select(column).from(tableName).where(condition).orderBy(order).limit(limit));\n    }\n\n    @NotNull\n    public List<Float> getOneColumnFloat(@NotNull ResultColumnConvertible column, @Nullable Expression condition, @Nullable OrderingTerm order, int limit, int offset) throws WCDBException {\n        return getOneColumnFloatFromStatement(new StatementSelect().select(column).from(tableName).where(condition).orderBy(order).limit(limit).offset(offset));\n    }\n\n    @NotNull\n    public List<Float> getOneColumnFloat(@NotNull ResultColumnConvertible column, @Nullable OrderingTerm order) throws WCDBException {\n        return getOneColumnFloatFromStatement(new StatementSelect().select(column).from(tableName).orderBy(order));\n    }\n\n    @NotNull\n    public List<Float> getOneColumnFloat(@NotNull ResultColumnConvertible column, @Nullable OrderingTerm order, int limit) throws WCDBException {\n        return getOneColumnFloatFromStatement(new StatementSelect().select(column).from(tableName).orderBy(order).limit(limit));\n    }\n\n    @NotNull\n    public List<Float> getOneColumnFloat(@NotNull ResultColumnConvertible column, @Nullable OrderingTerm order, int limit, int offset) throws WCDBException {\n        return getOneColumnFloatFromStatement(new StatementSelect().select(column).from(tableName).orderBy(order).limit(limit).offset(offset));\n    }\n\n    @NotNull\n    public List<Double> getOneColumnDouble(@NotNull ResultColumnConvertible column) throws WCDBException {\n        return getOneColumnDoubleFromStatement(new StatementSelect().select(column).from(tableName));\n    }\n\n    @NotNull\n    public List<Double> getOneColumnDouble(@NotNull ResultColumnConvertible column, @Nullable Expression condition) throws WCDBException {\n        return getOneColumnDoubleFromStatement(new StatementSelect().select(column).from(tableName).where(condition));\n    }\n\n    @NotNull\n    public List<Double> getOneColumnDouble(@NotNull ResultColumnConvertible column, @Nullable Expression condition, @Nullable OrderingTerm order) throws WCDBException {\n        return getOneColumnDoubleFromStatement(new StatementSelect().select(column).from(tableName).where(condition).orderBy(order));\n    }\n\n    @NotNull\n    public List<Double> getOneColumnDouble(@NotNull ResultColumnConvertible column, @Nullable Expression condition, @Nullable OrderingTerm order, int limit) throws WCDBException {\n        return getOneColumnDoubleFromStatement(new StatementSelect().select(column).from(tableName).where(condition).orderBy(order).limit(limit));\n    }\n\n    @NotNull\n    public List<Double> getOneColumnDouble(@NotNull ResultColumnConvertible column, @Nullable Expression condition, @Nullable OrderingTerm order, int limit, int offset) throws WCDBException {\n        return getOneColumnDoubleFromStatement(new StatementSelect().select(column).from(tableName).where(condition).orderBy(order).limit(limit).offset(offset));\n    }\n\n    @NotNull\n    public List<Double> getOneColumnDouble(@NotNull ResultColumnConvertible column, @Nullable OrderingTerm order) throws WCDBException {\n        return getOneColumnDoubleFromStatement(new StatementSelect().select(column).from(tableName).orderBy(order));\n    }\n\n    @NotNull\n    public List<Double> getOneColumnDouble(@NotNull ResultColumnConvertible column, @Nullable OrderingTerm order, int limit) throws WCDBException {\n        return getOneColumnDoubleFromStatement(new StatementSelect().select(column).from(tableName).orderBy(order).limit(limit));\n    }\n\n    @NotNull\n    public List<Double> getOneColumnDouble(@NotNull ResultColumnConvertible column, @Nullable OrderingTerm order, int limit, int offset) throws WCDBException {\n        return getOneColumnDoubleFromStatement(new StatementSelect().select(column).from(tableName).orderBy(order).limit(limit).offset(offset));\n    }\n\n    @NotNull\n    public List<String> getOneColumnString(@NotNull ResultColumnConvertible column) throws WCDBException {\n        return getOneColumnStringFromStatement(new StatementSelect().select(column).from(tableName));\n    }\n\n    @NotNull\n    public List<String> getOneColumnString(@NotNull ResultColumnConvertible column, @Nullable Expression condition) throws WCDBException {\n        return getOneColumnStringFromStatement(new StatementSelect().select(column).from(tableName).where(condition));\n    }\n\n    @NotNull\n    public List<String> getOneColumnString(@NotNull ResultColumnConvertible column, @Nullable Expression condition, @Nullable OrderingTerm order) throws WCDBException {\n        return getOneColumnStringFromStatement(new StatementSelect().select(column).from(tableName).where(condition).orderBy(order));\n    }\n\n    @NotNull\n    public List<String> getOneColumnString(@NotNull ResultColumnConvertible column, @Nullable Expression condition, @Nullable OrderingTerm order, int limit) throws WCDBException {\n        return getOneColumnStringFromStatement(new StatementSelect().select(column).from(tableName).where(condition).orderBy(order).limit(limit));\n    }\n\n    @NotNull\n    public List<String> getOneColumnString(@NotNull ResultColumnConvertible column, @Nullable Expression condition, @Nullable OrderingTerm order, int limit, int offset) throws WCDBException {\n        return getOneColumnStringFromStatement(new StatementSelect().select(column).from(tableName).where(condition).orderBy(order).limit(limit).offset(offset));\n    }\n\n    @NotNull\n    public List<String> getOneColumnString(@NotNull ResultColumnConvertible column, @Nullable OrderingTerm order) throws WCDBException {\n        return getOneColumnStringFromStatement(new StatementSelect().select(column).from(tableName).orderBy(order));\n    }\n\n    @NotNull\n    public List<String> getOneColumnString(@NotNull ResultColumnConvertible column, @Nullable OrderingTerm order, int limit) throws WCDBException {\n        return getOneColumnStringFromStatement(new StatementSelect().select(column).from(tableName).orderBy(order).limit(limit));\n    }\n\n    @NotNull\n    public List<String> getOneColumnString(@NotNull ResultColumnConvertible column, @Nullable OrderingTerm order, int limit, int offset) throws WCDBException {\n        return getOneColumnStringFromStatement(new StatementSelect().select(column).from(tableName).orderBy(order).limit(limit).offset(offset));\n    }\n\n    @NotNull\n    public List<byte[]> getOneColumnBLOB(@NotNull ResultColumnConvertible column) throws WCDBException {\n        return getOneColumnBLOBFromStatement(new StatementSelect().select(column).from(tableName));\n    }\n\n    @NotNull\n    public List<byte[]> getOneColumnBLOB(@NotNull ResultColumnConvertible column, @Nullable Expression condition) throws WCDBException {\n        return getOneColumnBLOBFromStatement(new StatementSelect().select(column).from(tableName).where(condition));\n    }\n\n    @NotNull\n    public List<byte[]> getOneColumnBLOB(@NotNull ResultColumnConvertible column, @Nullable Expression condition, @Nullable OrderingTerm order) throws WCDBException {\n        return getOneColumnBLOBFromStatement(new StatementSelect().select(column).from(tableName).where(condition).orderBy(order));\n    }\n\n    @NotNull\n    public List<byte[]> getOneColumnBLOB(@NotNull ResultColumnConvertible column, @Nullable Expression condition, @Nullable OrderingTerm order, int limit) throws WCDBException {\n        return getOneColumnBLOBFromStatement(new StatementSelect().select(column).from(tableName).where(condition).orderBy(order).limit(limit));\n    }\n\n    @NotNull\n    public List<byte[]> getOneColumnBLOB(@NotNull ResultColumnConvertible column, @Nullable Expression condition, @Nullable OrderingTerm order, int limit, int offset) throws WCDBException {\n        return getOneColumnBLOBFromStatement(new StatementSelect().select(column).from(tableName).where(condition).orderBy(order).limit(limit).offset(offset));\n    }\n\n    @NotNull\n    public List<byte[]> getOneColumnBLOB(@NotNull ResultColumnConvertible column, @Nullable OrderingTerm order) throws WCDBException {\n        return getOneColumnBLOBFromStatement(new StatementSelect().select(column).from(tableName).orderBy(order));\n    }\n\n    @NotNull\n    public List<byte[]> getOneColumnBLOB(@NotNull ResultColumnConvertible column, @Nullable OrderingTerm order, int limit) throws WCDBException {\n        return getOneColumnBLOBFromStatement(new StatementSelect().select(column).from(tableName).orderBy(order).limit(limit));\n    }\n\n    @NotNull\n    public List<byte[]> getOneColumnBLOB(@NotNull ResultColumnConvertible column, @Nullable OrderingTerm order, int limit, int offset) throws WCDBException {\n        return getOneColumnBLOBFromStatement(new StatementSelect().select(column).from(tableName).orderBy(order).limit(limit).offset(offset));\n    }\n\n    @NotNull\n    public List<Value[]> getAllRows(@NotNull ResultColumnConvertible[] columns) throws WCDBException {\n        return getAllRowsFromStatement(new StatementSelect().select(columns).from(tableName));\n    }\n\n    @NotNull\n    public List<Value[]> getAllRows(@NotNull ResultColumnConvertible[] columns, @Nullable Expression condition) throws WCDBException {\n        return getAllRowsFromStatement(new StatementSelect().select(columns).from(tableName).where(condition));\n    }\n\n    @NotNull\n    public List<Value[]> getAllRows(@NotNull ResultColumnConvertible[] columns, @Nullable Expression condition, @Nullable OrderingTerm order) throws WCDBException {\n        return getAllRowsFromStatement(new StatementSelect().select(columns).from(tableName).where(condition).orderBy(order));\n    }\n\n    @NotNull\n    public List<Value[]> getAllRows(@NotNull ResultColumnConvertible[] columns, @Nullable Expression condition, @Nullable OrderingTerm order, int limit) throws WCDBException {\n        return getAllRowsFromStatement(new StatementSelect().select(columns).from(tableName).where(condition).orderBy(order).limit(limit));\n    }\n\n    @NotNull\n    public List<Value[]> getAllRows(@NotNull ResultColumnConvertible[] columns, @Nullable Expression condition, @Nullable OrderingTerm order, int limit, int offset) throws WCDBException {\n        return getAllRowsFromStatement(new StatementSelect().select(columns).from(tableName).where(condition).orderBy(order).limit(limit).offset(offset));\n    }\n\n    @NotNull\n    public List<Value[]> getAllRows(@NotNull ResultColumnConvertible[] columns, @Nullable OrderingTerm order) throws WCDBException {\n        return getAllRowsFromStatement(new StatementSelect().select(columns).from(tableName).orderBy(order));\n    }\n\n    @NotNull\n    public List<Value[]> getAllRows(@NotNull ResultColumnConvertible[] columns, @Nullable OrderingTerm order, int limit) throws WCDBException {\n        return getAllRowsFromStatement(new StatementSelect().select(columns).from(tableName).orderBy(order).limit(limit));\n    }\n\n    @NotNull\n    public List<Value[]> getAllRows(@NotNull ResultColumnConvertible[] columns, @Nullable OrderingTerm order, int limit, int offset) throws WCDBException {\n        return getAllRowsFromStatement(new StatementSelect().select(columns).from(tableName).orderBy(order).limit(limit).offset(offset));\n    }\n\n    @Nullable\n    public Value getValueFromStatement(@NotNull Statement statement) throws WCDBException {\n        Handle handle = database.getHandle(false);\n        Value ret = null;\n        PreparedStatement preparedStatement = null;\n        try {\n            preparedStatement = handle.preparedWithMainStatement(statement);\n            preparedStatement.step();\n            if (!preparedStatement.isDone()) {\n                ret = preparedStatement.getValue(0);\n            }\n        } finally {\n            if (preparedStatement != null) {\n                preparedStatement.finalizeStatement();\n            }\n            handle.invalidate();\n        }\n        return ret;\n    }\n\n    @Nullable\n    public Value[] getOneRowFromStatement(@NotNull Statement statement) throws WCDBException {\n        Handle handle = database.getHandle(false);\n        Value[] ret = null;\n        PreparedStatement preparedStatement = null;\n        try {\n            preparedStatement = handle.preparedWithMainStatement(statement);\n            preparedStatement.step();\n            if (!preparedStatement.isDone()) {\n                ret = preparedStatement.getOneRow();\n            }\n        } finally {\n            if (preparedStatement != null) {\n                preparedStatement.finalizeStatement();\n            }\n            handle.invalidate();\n        }\n        return ret;\n    }\n\n    @NotNull\n    public List<Value> getOneColumnFromStatement(@NotNull Statement statement) throws WCDBException {\n        Handle handle = database.getHandle(false);\n        List<Value> ret;\n        PreparedStatement preparedStatement = null;\n        try {\n            preparedStatement = handle.preparedWithMainStatement(statement);\n            ret = preparedStatement.getOneColumn();\n        } finally {\n            if (preparedStatement != null) {\n                preparedStatement.finalizeStatement();\n            }\n            handle.invalidate();\n        }\n        return ret;\n    }\n\n    @NotNull\n    public List<Integer> getOneColumnIntFromStatement(@NotNull Statement statement) throws WCDBException {\n        Handle handle = database.getHandle(false);\n        List<Integer> ret;\n        PreparedStatement preparedStatement = null;\n        try {\n            preparedStatement = handle.preparedWithMainStatement(statement);\n            ret = preparedStatement.getOneColumnInt();\n        } finally {\n            if (preparedStatement != null) {\n                preparedStatement.finalizeStatement();\n            }\n            handle.invalidate();\n        }\n        return ret;\n    }\n\n    @NotNull\n    public List<Long> getOneColumnLongFromStatement(@NotNull Statement statement) throws WCDBException {\n        Handle handle = database.getHandle(false);\n        List<Long> ret;\n        PreparedStatement preparedStatement = null;\n        try {\n            preparedStatement = handle.preparedWithMainStatement(statement);\n            ret = preparedStatement.getOneColumnLong();\n        } finally {\n            if (preparedStatement != null) {\n                preparedStatement.finalizeStatement();\n            }\n            handle.invalidate();\n        }\n        return ret;\n    }\n\n    @NotNull\n    public List<Float> getOneColumnFloatFromStatement(@NotNull Statement statement) throws WCDBException {\n        Handle handle = database.getHandle(false);\n        List<Float> ret;\n        PreparedStatement preparedStatement = null;\n        try {\n            preparedStatement = handle.preparedWithMainStatement(statement);\n            ret = preparedStatement.getOneColumnFloat();\n        } finally {\n            if (preparedStatement != null) {\n                preparedStatement.finalizeStatement();\n            }\n            handle.invalidate();\n        }\n        return ret;\n    }\n\n    @NotNull\n    public List<Double> getOneColumnDoubleFromStatement(@NotNull Statement statement) throws WCDBException {\n        Handle handle = database.getHandle(false);\n        List<Double> ret;\n        PreparedStatement preparedStatement = null;\n        try {\n            preparedStatement = handle.preparedWithMainStatement(statement);\n            ret = preparedStatement.getOneColumnDouble();\n        } finally {\n            if (preparedStatement != null) {\n                preparedStatement.finalizeStatement();\n            }\n            handle.invalidate();\n        }\n        return ret;\n    }\n\n    @NotNull\n    public List<String> getOneColumnStringFromStatement(@NotNull Statement statement) throws WCDBException {\n        Handle handle = database.getHandle(false);\n        List<String> ret;\n        PreparedStatement preparedStatement = null;\n        try {\n            preparedStatement = handle.preparedWithMainStatement(statement);\n            ret = preparedStatement.getOneColumnString();\n        } finally {\n            if (preparedStatement != null) {\n                preparedStatement.finalizeStatement();\n            }\n            handle.invalidate();\n        }\n        return ret;\n    }\n\n    @NotNull\n    public List<byte[]> getOneColumnBLOBFromStatement(@NotNull Statement statement) throws WCDBException {\n        Handle handle = database.getHandle(false);\n        List<byte[]> ret;\n        PreparedStatement preparedStatement = null;\n        try {\n            preparedStatement = handle.preparedWithMainStatement(statement);\n            ret = preparedStatement.getOneColumnBLOB();\n        } finally {\n            if (preparedStatement != null) {\n                preparedStatement.finalizeStatement();\n            }\n            handle.invalidate();\n        }\n        return ret;\n    }\n\n    @NotNull\n    public List<Value[]> getAllRowsFromStatement(@NotNull Statement statement) throws WCDBException {\n        Handle handle = database.getHandle(false);\n        List<Value[]> ret;\n        PreparedStatement preparedStatement = null;\n        try {\n            preparedStatement = handle.preparedWithMainStatement(statement);\n            ret = preparedStatement.getMultiRows();\n        } finally {\n            if (preparedStatement != null) {\n                preparedStatement.finalizeStatement();\n            }\n            handle.invalidate();\n        }\n        return ret;\n    }\n}"
  },
  {
    "path": "src/java/main/src/main/java/com/tencent/wcdb/core/Transaction.java",
    "content": "// Created by qiuwenchen on 2023/5/23.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdb.core;\n\nimport com.tencent.wcdb.base.WCDBException;\n\nimport org.jetbrains.annotations.NotNull;\n\npublic interface Transaction {\n    /**\n     * Triggered when a new transaction is begun successfully.\n     *\n     * @param handle current handle of database.\n     * @return true to commit transaction.\n     * @throws WCDBException if any error occurs.\n     */\n    boolean insideTransaction(@NotNull Handle handle) throws WCDBException;\n}\n"
  },
  {
    "path": "src/java/main/src/main/java/com/tencent/wcdb/fts/BuiltinFTSAuxiliaryFunction.java",
    "content": "// Created by chenqiuwen on 2024/1/1.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdb.fts;\n\npublic class BuiltinFTSAuxiliaryFunction {\n    /**\n     * `SubstringMatchInfo` is a WCDB implemented auxiliary function for fts5.\n     * When you need to concat multiple contents together with multi-level separators and save them in a single column of the fts5 table,\n     * you can use this auxiliary function to improve the accuracy of searching for the contents of this column.\n     * Suppose you have a friend named 张三, whose address is 广州 and 上海, and phone number is 12345 and 67890.\n     * You can use semicolon and comma as two-level separators to concat your friend's information into \"张三;广州,上海;12345,67890\" and save it in a column named \"friends\" in an fts5 table.\n     * Then you can use following code to search your friend:\n     *\n     * <pre>\n     *      <code>\n     *          fts5Table.getOneColumnString(new Column(fts5Table.tableName).substringMatchInfo(0, \";,\"), new Column(\"friends\").match(\"州\"));\n     *      </code>\n     *  </pre>\n     * <p>\n     * The first argument of SubstringMatchInfo is a column named with table name.\n     * The second argument is the index of the colum you need to search. The index is are numbered starting from 0.\n     * The third parameter is the separator used when concating the content, which should be arranged according to their level.\n     * Then you will get this string result \"1,0;广;州;3;\".\n     * The result is made by concating a variety of information with the separator you passed in.\n     * The first part of the result \"1,0\" gives the hierarchical position of the matched content within matched column.\n     * The second part \"广;州\" is the original text of the matching content, you can use it for highlighting.\n     * The third part \"3\" is the byte offset of the matching content in the original text, you can use it to sort the results.\n     * Note that The search results may contain some empty strings, which are invalid results.\n     * This kind of results appear when the content of some rows contain the tokens you are searching for,\n     * but these tokens are located in different parts separated by separators.\n     * You just need to ignore these results.\n     */\n    public final static String SubstringMatchInfo = \"substring_match_info\";\n}\n"
  },
  {
    "path": "src/java/main/src/main/java/com/tencent/wcdb/fts/BuiltinTokenizer.java",
    "content": "// Created by chenqiuwen on 2023/11/4.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdb.fts;\n\nimport java.util.Map;\n\npublic class BuiltinTokenizer {\n    /**\n     * The following four are sqlite built-in fts tokenizers.\n     * `Simple` tokenizer can be used in fts3/4 and the others can be used in fts3/4/5.\n     * You can use `com.tencent.wcdb.FTSModule` annotation to config fts tokenizer for a Java ORM class.\n     */\n    public final static String Simple = \"simple\";\n    public final static String Porter = \"porter\";\n    public final static String ICU = \"icu\";\n    public final static String Unicode61 = \"unicode61\";\n\n    /**\n     * `OneOrBinary` is a WCDB implemented tokenizer for fts3/4.\n     * Consecutive English letters will be recognized as an English token, and this token will be stemmed using the porter stemming algorithm.\n     * Continuous Arabic numerals will be recognized as a single numeric token.\n     * For other Unicode characters, each character will be recognized as one token.\n     * For example, the sentence \"The phone number of 张三 is 12345\" will be split into these tokens: \"the\", \"phone\", \"number\", \"of\", \"张\", \"三\", \"is\", \"12345\".\n     * You can use `com.tencent.wcdb.FTSModule` annotation to config fts tokenizer for a Java ORM class.\n     */\n    public final static String OneOrBinary = \"wcdb_one_or_binary\";\n\n    /**\n     * Deprecated tokenizer for fts3/4.\n     */\n    public final static String MMICU = \"mmicu\";\n\n    /**\n     * `Verbatim` is a WCDB implemented tokenizer for fts5.\n     * It has the same tokenize rules as `OneOrBinary`.\n     * You can use `com.tencent.wcdb.FTSModule annotation` to config fts tokenizer for a Java ORM class.\n     *\n     * @see #OneOrBinary\n     */\n    public final static String Verbatim = \"wcdb_verbatim\";\n\n    /**\n     * `Pinyin` is a WCDB implemented tokenizer for fts5.\n     * It is designed for pinyin search.\n     * You can use the simplified or full pinyin of Chinese characters to search for Chinese characters.\n     * Before using this tokenizer, you need to use `Database.configPinyinDict()` to configure the mapping relationship between Chinese characters and their pinyin.\n     * You can use `com.tencent.wcdb.FTSModule annotation` to config fts tokenizer for a Java ORM class.\n     *\n     * @see com.tencent.wcdb.core.Database#configPinyinDict(Map)\n     */\n    public final static String Pinyin = \"wcdb_pinyin\";\n\n    /**\n     * The following two are optional parameters for WCDB implemented tokenizers.\n     * You can configure these parameters on the `tokenizerParameters` attribute of `com.tencent.wcdb.FTSModule` annotation.\n     */\n    public static class Parameter {\n        /**\n         * `SimplifyChinese` enables the tokenizer to convert each traditional Chinese character into a simplified Chinese character,\n         * so that you can use Simplified Chinese characters to search Traditional Chinese characters.\n         * Note that you need to use `Database.configTraditionalChineseDict()` to config the mapping relationship between traditional Chinese characters and simplified Chinese characters.\n         *\n         * @see com.tencent.wcdb.core.Database#configTraditionalChineseDict(Map)\n         */\n        public final static String SimplifyChinese = \"chinese_traditional_to_simplified\";\n\n        /**\n         * `SkipStemming` will disable the stemming during tokenization.\n         */\n        public final static String SkipStemming = \"skip_stemming\";\n    }\n}\n"
  },
  {
    "path": "src/java/main/src/main/java/com/tencent/wcdb/orm/Binding.java",
    "content": "// Created by chenqiuwen on 2023/4/19.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the &quot;License&quot;); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an &quot;AS IS&quot; BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdb.orm;\n\nimport com.tencent.wcdb.base.CppObject;\nimport com.tencent.wcdb.base.WCDBException;\nimport com.tencent.wcdb.core.Handle;\nimport com.tencent.wcdb.winq.ColumnDef;\nimport com.tencent.wcdb.winq.StatementCreateIndex;\nimport com.tencent.wcdb.winq.TableConstraint;\n\npublic class Binding extends CppObject {\n    private long baseBinding = 0;\n\n    public Binding() {\n        cppObj = createCppObj();\n    }\n\n    private static native long createCppObj();\n\n    public void addColumnDef(ColumnDef def) {\n        addColumnDef(cppObj, CppObject.get(def));\n    }\n\n    private static native void addColumnDef(long self, long columnDef);\n\n    public void enableAutoIncrementForExistingTable() {\n        enableAutoIncrementForExistingTable(cppObj);\n    }\n\n    private static native void enableAutoIncrementForExistingTable(long self);\n\n    public void addIndex(String indexNameOrSuffix, boolean isFullName, StatementCreateIndex createIndex) {\n        addIndex(cppObj, indexNameOrSuffix, isFullName, CppObject.get(createIndex));\n    }\n\n    private static native void addIndex(long self, String indexNameOrSuffix, boolean isFullName, long createIndex);\n\n    public void addTableConstraint(TableConstraint constraint) {\n        addTableConstraint(cppObj, CppObject.get(constraint));\n    }\n\n    private static native void addTableConstraint(long self, long tableConstraint);\n\n    public Binding configVirtualModule(String module) {\n        configVirtualModule(cppObj, module);\n        return this;\n    }\n\n    private static native void configVirtualModule(long self, String module);\n\n    public void configVirtualModuleArgument(String argument) {\n        configVirtualModuleArgument(cppObj, argument);\n    }\n\n    private static native void configVirtualModuleArgument(long self, String argument);\n\n    public void configWithoutRowId() {\n        configWithoutRowId(cppObj);\n    }\n\n    private static native void configWithoutRowId(long self);\n\n    public boolean createTable(String tableName, Handle handle) throws WCDBException {\n        return createTable(cppObj, tableName, handle.getCppHandle());\n    }\n\n    private static native boolean createTable(long self, String tableName, long handle);\n\n    public boolean createVirtualTable(String tableName, Handle handle) throws WCDBException {\n        return createVirtualTable(cppObj, tableName, handle.getCppHandle());\n    }\n\n    private static native boolean createVirtualTable(long self, String tableName, long handle);\n\n    long getBaseBinding() {\n        if (baseBinding == 0) {\n            baseBinding = getBaseBinding(cppObj);\n        }\n        return baseBinding;\n    }\n\n    private static native long getBaseBinding(long self);\n}\n"
  },
  {
    "path": "src/java/main/src/main/java/com/tencent/wcdb/orm/Field.java",
    "content": "// Created by qiuwenchen on 2023/3/30.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage com.tencent.wcdb.orm;\n\nimport com.tencent.wcdb.winq.Column;\nimport com.tencent.wcdb.winq.Schema;\n\nimport org.jetbrains.annotations.NotNull;\n\npublic class Field<T> extends Column {\n    protected TableBinding<T> binding = null;\n\n    public TableBinding<T> getTableBinding() {\n        return binding;\n    }\n\n    private int fieldId = 0;\n\n    public int getFieldId() {\n        return fieldId;\n    }\n\n    private String name;\n\n    public String getName() {\n        return name;\n    }\n\n    private boolean isAutoIncrement = false;\n\n    public boolean isAutoIncrement() {\n        return isAutoIncrement;\n    }\n\n    private boolean isPrimaryKey = false;\n\n    public boolean isPrimaryKey() {\n        return isPrimaryKey;\n    }\n\n    public Field(String name, TableBinding<T> binding, int fieldId, boolean isAutoIncrement, boolean isPrimaryKey) {\n        super(name, binding.baseBinding().getBaseBinding());\n        this.name = name;\n        this.binding = binding;\n        this.fieldId = fieldId;\n        this.isAutoIncrement = isAutoIncrement;\n        this.isPrimaryKey = isPrimaryKey;\n    }\n\n    protected Field() {\n        super();\n    }\n\n    protected Field<T> copySelf() {\n        Field<T> field = new Field<T>();\n        field.cppObj = copy(cppObj);\n        field.name = name;\n        field.fieldId = fieldId;\n        field.isAutoIncrement = isAutoIncrement;\n        field.isPrimaryKey = isPrimaryKey;\n        field.binding = binding;\n        return field;\n    }\n\n    @NotNull\n    public Field<T> table(String tableName) {\n        Field<T> field = copySelf();\n        field.inTable(field.cppObj, tableName);\n        return field;\n    }\n\n    @Override\n    @NotNull\n    public Field<T> of(String schema) {\n        Field<T> field = copySelf();\n        field.ofSchema(schema);\n        return field;\n    }\n\n    @Override\n    @NotNull\n    public Field<T> of(Schema schema) {\n        Field<T> field = copySelf();\n        field.ofSchema(schema);\n        return field;\n    }\n\n    @NotNull\n    public static <T> TableBinding<T> getBinding(@NotNull Field<T> field) {\n        assert field.getTableBinding() != null;\n        return field.getTableBinding();\n    }\n\n    @SafeVarargs\n    @NotNull\n    public static <T> TableBinding<T> getBinding(@NotNull Field<T>... fields) {\n        assert fields.length > 0;\n        Field<T> field = fields[0];\n        return getBinding(field);\n    }\n\n    @SafeVarargs\n    @NotNull\n    public static <T> Class<T> getBindClass(@NotNull Field<T>... fields) {\n        assert fields.length > 0;\n        return fields[0].binding.bindingType();\n    }\n}\n"
  },
  {
    "path": "src/java/main/src/main/java/com/tencent/wcdb/orm/TableBinding.java",
    "content": "// Created by qiuwenchen on 2023/3/30.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage com.tencent.wcdb.orm;\n\nimport com.tencent.wcdb.core.PreparedStatement;\n\npublic interface TableBinding<T> {\n    Class<T> bindingType();\n\n    Field<T>[] allBindingFields();\n\n    Binding baseBinding();\n\n    <R extends T> R extractObject(Field<T>[] fields, PreparedStatement preparedStatement, Class<R> cls) throws ReflectiveOperationException;\n\n    void bindField(T object, Field<T> field, int index, PreparedStatement preparedStatement);\n\n    boolean isAutoIncrement(T object);\n\n    void setLastInsertRowId(T object, long lastInsertRowId);\n}\n"
  },
  {
    "path": "src/java/main/src/main/java/com/tencent/wcdb/winq/BindParameter.java",
    "content": "// Created by qiuwenchen on 2023/3/31.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdb.winq;\n\nimport org.jetbrains.annotations.NotNull;\n\npublic class BindParameter extends Identifier implements ExpressionConvertible {\n    @Override\n    protected int getType() {\n        return CPPType.BindParameter;\n    }\n\n    @NotNull\n    @Override\n    public Identifier asIdentifier() {\n        return this;\n    }\n\n    public BindParameter(int num) {\n        cppObj = createCppObj(num);\n    }\n\n    private BindParameter() {\n    }\n\n    private static native long createCppObj(int num);\n\n    public BindParameter(@NotNull String name) {\n        cppObj = createCppObj(name);\n    }\n\n    private static native long createCppObj(String name);\n\n    public static BindParameter at(@NotNull String name) {\n        BindParameter ret = new BindParameter();\n        ret.cppObj = atBindParameter(name);\n        return ret;\n    }\n\n    private static native long atBindParameter(String name);\n\n    public static BindParameter colon(@NotNull String name) {\n        return new BindParameter(name);\n    }\n\n    public static BindParameter dollar(@NotNull String name) {\n        BindParameter ret = new BindParameter();\n        ret.cppObj = dollarBindParameter(name);\n        return ret;\n    }\n\n    private static native long dollarBindParameter(String name);\n\n    public static BindParameter[] bindParameters(int num) {\n        if (num == 0) {\n            return new BindParameter[]{};\n        }\n        BindParameter[] bindParameters = new BindParameter[num];\n        long[] cppObjs = createCppObjs(num);\n        for (int i = 0; i < num; i++) {\n            bindParameters[i] = new BindParameter();\n            bindParameters[i].cppObj = cppObjs[i];\n        }\n        return bindParameters;\n    }\n\n    private static native long[] createCppObjs(int num);\n\n    public static final BindParameter def = new BindParameter(0); //?\n    public static final BindParameter _1 = new BindParameter(1); //?1\n    public static final BindParameter _2 = new BindParameter(2); //?2\n    public static final BindParameter _3 = new BindParameter(3); //?3\n    public static final BindParameter _4 = new BindParameter(4); //?4\n    public static final BindParameter _5 = new BindParameter(5); //?5\n    public static final BindParameter _6 = new BindParameter(6); //?6\n    public static final BindParameter _7 = new BindParameter(7); //?7\n    public static final BindParameter _8 = new BindParameter(8); //?8\n    public static final BindParameter _9 = new BindParameter(9); //?9\n    public static final BindParameter _10 = new BindParameter(10); //?10\n\n}\n"
  },
  {
    "path": "src/java/main/src/main/java/com/tencent/wcdb/winq/Column.java",
    "content": "// Created by qiuwenchen on 2023/3/31.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdb.winq;\n\nimport com.tencent.wcdb.base.CppObject;\n\nimport org.jetbrains.annotations.NotNull;\nimport org.jetbrains.annotations.Nullable;\n\npublic class Column extends ExpressionOperable implements IndexedColumnConvertible, ResultColumnConvertible {\n\n    @Override\n    protected int getType() {\n        return CPPType.Column;\n    }\n\n    public Column(@NotNull String name) {\n        cppObj = createCppObj(name, 0);\n    }\n\n    protected Column(String name, long tableBinding) {\n        cppObj = createCppObj(name, tableBinding);\n    }\n\n    private static native long createCppObj(String name, long tableBinding);\n\n    protected native long copy(long self);\n\n    @NotNull\n    public Column table(@Nullable String table) {\n        inTable(cppObj, table);\n        return this;\n    }\n\n    protected native void inTable(long column, String table);\n\n    @NotNull\n    public Column of(@Nullable Schema schema) {\n        ofSchema(cppObj, Identifier.getCppType(schema), CppObject.get(schema), null);\n        return this;\n    }\n\n    @NotNull\n    public Column of(@Nullable String schema) {\n        ofSchema(cppObj, CPPType.String, 0, schema);\n        return this;\n    }\n\n    protected void ofSchema(Schema schema) {\n        ofSchema(cppObj, Identifier.getCppType(schema), CppObject.get(schema), null);\n    }\n\n    protected void ofSchema(String schema) {\n        ofSchema(cppObj, CPPType.String, 0, schema);\n    }\n\n    protected native void ofSchema(long column, int type, long schema, String schemaName);\n\n    @NotNull\n    public ResultColumn as(@Nullable String alias) {\n        return new ResultColumn(configAlias(cppObj, alias));\n    }\n\n    private native static long configAlias(long self, String alias);\n\n    protected Column() {\n    }\n\n    public static Column all() {\n        Column ret = new Column();\n        ret.cppObj = allColumn();\n        return ret;\n    }\n\n    private static native long allColumn();\n\n    @NotNull\n    public static Column rowId() {\n        Column ret = new Column();\n        ret.cppObj = rowidColumn();\n        return ret;\n    }\n\n    private static native long rowidColumn();\n\n    @NotNull\n    public OrderingTerm order(Order order) {\n        return new OrderingTerm(this).order(order);\n    }\n\n    @NotNull\n    public ColumnDef asDef(ColumnType columnType) {\n        return new ColumnDef(this, columnType);\n    }\n}\n"
  },
  {
    "path": "src/java/main/src/main/java/com/tencent/wcdb/winq/ColumnConstraint.java",
    "content": "// Created by chenqiuwen on 2023/4/3.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage com.tencent.wcdb.winq;\n\nimport com.tencent.wcdb.base.CppObject;\n\nimport org.jetbrains.annotations.NotNull;\nimport org.jetbrains.annotations.Nullable;\n\npublic class ColumnConstraint extends Identifier {\n    @Override\n    protected int getType() {\n        return CPPType.ColumnConstraint;\n    }\n\n    public ColumnConstraint() {\n        cppObj = createCppObject(null);\n    }\n\n    public ColumnConstraint(@NotNull String columnName) {\n        cppObj = createCppObject(columnName);\n    }\n\n    private static native long createCppObject(String columnName);\n\n    @NotNull\n    public ColumnConstraint primaryKey() {\n        configPrimaryKey(cppObj);\n        return this;\n    }\n\n    private static native void configPrimaryKey(long self);\n\n    @NotNull\n    public ColumnConstraint order(Order order) {\n        configOrder(cppObj, order.ordinal() + 1);\n        return this;\n    }\n\n    private static native void configOrder(long self, int order);\n\n    @NotNull\n    public ColumnConstraint conflict(ConflictAction action) {\n        configConflictAction(cppObj, action.ordinal());\n        return this;\n    }\n\n    private static native void configConflictAction(long self, int action);\n\n    @NotNull\n    public ColumnConstraint autoIncrement() {\n        configAutoIncrement(cppObj);\n        return this;\n    }\n\n    private static native void configAutoIncrement(long self);\n\n    @NotNull\n    public ColumnConstraint notNull() {\n        configNotNull(cppObj);\n        return this;\n    }\n\n    private static native void configNotNull(long self);\n\n    @NotNull\n    public ColumnConstraint unique() {\n        configUnique(cppObj);\n        return this;\n    }\n\n    private static native void configUnique(long self);\n\n    @NotNull\n    public ColumnConstraint check(@Nullable Expression expression) {\n        configCheck(cppObj, CppObject.get(expression));\n        return this;\n    }\n\n    private static native void configCheck(long self, long expression);\n\n    @NotNull\n    public ColumnConstraint defaultTo(boolean value) {\n        defaultTo(cppObj, CPPType.Bool, value ? 1 : 0, 0, null);\n        return this;\n    }\n\n    @NotNull\n    public ColumnConstraint defaultTo(byte value) {\n        defaultTo(cppObj, CPPType.Int, value, 0, null);\n        return this;\n    }\n\n    @NotNull\n    public ColumnConstraint defaultTo(short value) {\n        defaultTo(cppObj, CPPType.Int, value, 0, null);\n        return this;\n    }\n\n    @NotNull\n    public ColumnConstraint defaultTo(int value) {\n        defaultTo(cppObj, CPPType.Int, value, 0, null);\n        return this;\n    }\n\n    @NotNull\n    public ColumnConstraint defaultTo(long value) {\n        defaultTo(cppObj, CPPType.Int, value, 0, null);\n        return this;\n    }\n\n    @NotNull\n    public ColumnConstraint defaultTo(float value) {\n        defaultTo(cppObj, CPPType.Double, 0, value, null);\n        return this;\n    }\n\n    @NotNull\n    public ColumnConstraint defaultTo(double value) {\n        defaultTo(cppObj, CPPType.Double, 0, value, null);\n        return this;\n    }\n\n    @NotNull\n    public ColumnConstraint defaultTo(@Nullable String value) {\n        if (value != null) {\n            defaultTo(cppObj, CPPType.String, 0, 0, value);\n        } else {\n            defaultTo(cppObj, CPPType.Null, 0, 0, null);\n        }\n\n        return this;\n    }\n\n    @NotNull\n    public ColumnConstraint defaultTo(@Nullable ExpressionConvertible value) {\n        defaultTo(cppObj, Identifier.getCppType(value), CppObject.get(value), 0, null);\n        return this;\n    }\n\n    private static native void defaultTo(long self, int type, long intValue, double doubleValue, String stringValue);\n\n    @NotNull\n    public ColumnConstraint collate(@NotNull String collation) {\n        configCollate(cppObj, collation);\n        return this;\n    }\n\n    private static native void configCollate(long self, String collation);\n\n    @NotNull\n    public ColumnConstraint foreignKey(@Nullable ForeignKey foreignKey) {\n        configForeignKey(cppObj, CppObject.get(foreignKey));\n        return this;\n    }\n\n    private static native void configForeignKey(long self, long foreignKey);\n\n    @NotNull\n    public ColumnConstraint unIndex() {\n        configUnIndex(cppObj);\n        return this;\n    }\n\n    private static native void configUnIndex(long self);\n}\n"
  },
  {
    "path": "src/java/main/src/main/java/com/tencent/wcdb/winq/ColumnDef.java",
    "content": "// Created by qiuwenchen on 2023/4/7.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdb.winq;\n\nimport com.tencent.wcdb.base.CppObject;\n\nimport org.jetbrains.annotations.NotNull;\nimport org.jetbrains.annotations.Nullable;\n\npublic class ColumnDef extends Identifier {\n    @Override\n    protected int getType() {\n        return CPPType.ColumnDef;\n    }\n\n    public ColumnDef(@NotNull String columnName) {\n        cppObj = createCppObj(CPPType.String, 0, columnName, 0);\n    }\n\n    public ColumnDef(@NotNull Column column) {\n        cppObj = createCppObj(Identifier.getCppType(column), CppObject.get(column), null, 0);\n    }\n\n    public ColumnDef(@NotNull String columnName, ColumnType columnType) {\n        cppObj = createCppObj(CPPType.String, 0, columnName, columnType.ordinal());\n    }\n\n    public ColumnDef(@NotNull Column column, ColumnType columnType) {\n        cppObj = createCppObj(Identifier.getCppType(column), CppObject.get(column), null, columnType.ordinal());\n    }\n\n    private static native long createCppObj(int type, long column, String columnName, int columnType);\n\n    @NotNull\n    public ColumnDef constraint(ColumnConstraint constraint) {\n        constraint(cppObj, CppObject.get(constraint));\n        return this;\n    }\n\n    private static native void constraint(long columnDef, long columnConstraint);\n\n    @NotNull\n    public ColumnDef makePrimary() {\n        return constraint(new ColumnConstraint().primaryKey());\n    }\n\n    @NotNull\n    public ColumnDef makePrimary(boolean isAutoIncrement) {\n        return constraint(new ColumnConstraint().primaryKey().autoIncrement());\n    }\n\n    @NotNull\n    public ColumnDef makeDefaultTo(boolean value) {\n        return constraint(new ColumnConstraint().defaultTo(value));\n    }\n\n    @NotNull\n    public ColumnDef makeDefaultTo(byte value) {\n        return constraint(new ColumnConstraint().defaultTo(value));\n    }\n\n    @NotNull\n    public ColumnDef makeDefaultTo(short value) {\n        return constraint(new ColumnConstraint().defaultTo(value));\n    }\n\n    @NotNull\n    public ColumnDef makeDefaultTo(int value) {\n        return constraint(new ColumnConstraint().defaultTo(value));\n    }\n\n    @NotNull\n    public ColumnDef makeDefaultTo(long value) {\n        return constraint(new ColumnConstraint().defaultTo(value));\n    }\n\n    @NotNull\n    public ColumnDef makeDefaultTo(float value) {\n        return constraint(new ColumnConstraint().defaultTo(value));\n    }\n\n    @NotNull\n    public ColumnDef makeDefaultTo(double value) {\n        return constraint(new ColumnConstraint().defaultTo(value));\n    }\n\n    @NotNull\n    public ColumnDef makeDefaultTo(@Nullable String value) {\n        return constraint(new ColumnConstraint().defaultTo(value));\n    }\n\n    @NotNull\n    public ColumnDef makeDefaultTo(@Nullable ExpressionConvertible value) {\n        return constraint(new ColumnConstraint().defaultTo(value));\n    }\n\n    @NotNull\n    public ColumnDef makeUnique() {\n        return constraint(new ColumnConstraint().unique());\n    }\n\n    @NotNull\n    public ColumnDef makeNotNull() {\n        return constraint(new ColumnConstraint().notNull());\n    }\n\n    @NotNull\n    public ColumnDef makeForeignKey(@Nullable ForeignKey foreignKey) {\n        return constraint(new ColumnConstraint().foreignKey(foreignKey));\n    }\n\n    @NotNull\n    public ColumnDef makeNotIndexed() {\n        return constraint(new ColumnConstraint().unIndex());\n    }\n}\n"
  },
  {
    "path": "src/java/main/src/main/java/com/tencent/wcdb/winq/ColumnType.java",
    "content": "// Created by qiuwenchen on 2023/4/7.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdb.winq;\n\npublic enum ColumnType {\n    Null(0),\n    Integer(1),\n    Float(2),\n    Text(3),\n    BLOB(4);\n\n    private final int value;\n\n    ColumnType(int value) {\n        this.value = value;\n    }\n\n    public static ColumnType valueOf(int value) {\n        switch (value) {\n            case 1:\n                return Integer;\n            case 2:\n                return Float;\n            case 3:\n                return Text;\n            case 4:\n                return BLOB;\n            default:\n                return Null;\n        }\n    }\n}\n"
  },
  {
    "path": "src/java/main/src/main/java/com/tencent/wcdb/winq/CommonTableExpression.java",
    "content": "// Created by qiuwenchen on 2023/5/16.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdb.winq;\n\nimport com.tencent.wcdb.base.CppObject;\n\nimport org.jetbrains.annotations.NotNull;\nimport org.jetbrains.annotations.Nullable;\n\npublic class CommonTableExpression extends Identifier {\n    @Override\n    protected int getType() {\n        return CPPType.CommonTableExpression;\n    }\n\n    public CommonTableExpression(@NotNull String tableName) {\n        cppObj = createCPPObject(tableName);\n    }\n\n    private static native long createCPPObject(String tableName);\n\n    @NotNull\n    public CommonTableExpression column(@Nullable Column column) {\n        configColumn(cppObj, CppObject.get(column));\n        return this;\n    }\n\n    private static native void configColumn(long self, long column);\n\n    @NotNull\n    public CommonTableExpression as(@Nullable StatementSelect select) {\n        configSelect(cppObj, CppObject.get(select));\n        return this;\n    }\n\n    private static native void configSelect(long self, long select);\n\n}\n"
  },
  {
    "path": "src/java/main/src/main/java/com/tencent/wcdb/winq/ConflictAction.java",
    "content": "// Created by qiuwenchen on 2023/4/6.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdb.winq;\n\npublic enum ConflictAction {\n    None, Replace, Rollback, Abort, Fail, Ignore\n}\n"
  },
  {
    "path": "src/java/main/src/main/java/com/tencent/wcdb/winq/Expression.java",
    "content": "// Created by qiuwenchen on 2023/3/30.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage com.tencent.wcdb.winq;\n\nimport com.tencent.wcdb.base.CppObject;\n\nimport org.jetbrains.annotations.NotNull;\nimport org.jetbrains.annotations.Nullable;\n\npublic class Expression extends ExpressionOperable implements IndexedColumnConvertible, ResultColumnConvertible {\n    @Override\n    protected int getType() {\n        return CPPType.Expression;\n    }\n\n    Expression() {\n    }\n\n    public Expression(@Nullable LiteralValue value) {\n        cppObj = createCppObj(Identifier.getCppType(value), CppObject.get(value));\n    }\n\n    public Expression(@Nullable BindParameter bindParameter) {\n        cppObj = createCppObj(Identifier.getCppType(bindParameter), CppObject.get(bindParameter));\n    }\n\n    public Expression(@Nullable Column column) {\n        cppObj = createCppObj(Identifier.getCppType(column), CppObject.get(column));\n    }\n\n    public Expression(@Nullable StatementSelect select) {\n        cppObj = createCppObj(Identifier.getCppType(select), CppObject.get(select));\n    }\n\n    private static native long createCppObj(int type, long intValue);\n\n    @NotNull\n    public static Expression function(@NotNull String funcName) {\n        return createExpression(createWithFunction(funcName));\n    }\n\n    private static native long createWithFunction(String func);\n\n    @NotNull\n    public Expression schema(@Nullable String schema) {\n        schema(cppObj, CPPType.String, 0, schema);\n        return this;\n    }\n\n    @NotNull\n    public Expression schema(@Nullable Schema schema) {\n        schema(cppObj, Identifier.getCppType(schema), CppObject.get(schema), null);\n        return this;\n    }\n\n    private static native void schema(long self, int type, long schema, String schemaName);\n\n    @NotNull\n    public Expression distinct() {\n        distinct(cppObj);\n        return this;\n    }\n\n    private static native void distinct(long self);\n\n    @NotNull\n    public Expression invoke() {\n        invoke(cppObj);\n        return this;\n    }\n\n    private static native void invoke(long self);\n\n    @NotNull\n    public Expression invokeAll() {\n        invokeAll(cppObj);\n        return this;\n    }\n\n    private static native void invokeAll(long self);\n\n    @NotNull\n    public Expression argument(boolean arg) {\n        argument(cppObj, CPPType.Bool, arg ? 1 : 0, 0, null);\n        return this;\n    }\n\n    @NotNull\n    public Expression argument(byte arg) {\n        argument(cppObj, CPPType.Int, arg, 0, null);\n        return this;\n    }\n\n    @NotNull\n    public Expression argument(short arg) {\n        argument(cppObj, CPPType.Int, arg, 0, null);\n        return this;\n    }\n\n    @NotNull\n    public Expression argument(int arg) {\n        argument(cppObj, CPPType.Int, arg, 0, null);\n        return this;\n    }\n\n    @NotNull\n    public Expression argument(long arg) {\n        argument(cppObj, CPPType.Int, arg, 0, null);\n        return this;\n    }\n\n    @NotNull\n    public Expression argument(float arg) {\n        argument(cppObj, CPPType.Double, 0, arg, null);\n        return this;\n    }\n\n    @NotNull\n    public Expression argument(double arg) {\n        argument(cppObj, CPPType.Double, 0, arg, null);\n        return this;\n    }\n\n    @NotNull\n    public Expression argument(@Nullable String arg) {\n        if (arg != null) {\n            argument(cppObj, CPPType.String, 0, 0, arg);\n        } else {\n            argument(cppObj, CPPType.Null, 0, 0, null);\n        }\n        return this;\n    }\n\n    @NotNull\n    public Expression argument(@Nullable ExpressionConvertible arg) {\n        argument(cppObj, Identifier.getCppType(arg), CppObject.get(arg), 0, null);\n        return this;\n    }\n\n    private static native void argument(long self, int type, long intValue, double doubleValue, String stringValue);\n\n    @NotNull\n    public Expression escape(@NotNull String content) {\n        escape(cppObj, content);\n        return this;\n    }\n\n    private static native void escape(long self, String stringValue);\n\n    @NotNull\n    public static Expression exists(@NotNull StatementSelect select) {\n        Expression exp = new Expression();\n        exp.cppObj = createWithExistStatement(CppObject.get(select));\n        return exp;\n    }\n\n    private static native long createWithExistStatement(long select);\n\n    @NotNull\n    public static Expression notExists(@NotNull StatementSelect select) {\n        Expression exp = new Expression();\n        exp.cppObj = createWithNotExistStatement(CppObject.get(select));\n        return exp;\n    }\n\n    private static native long createWithNotExistStatement(long select);\n\n\n    @NotNull\n    public static Expression cast(@NotNull String columnName) {\n        Expression ret = new Expression();\n        ret.cppObj = cast(CPPType.String, 0, columnName);\n        return ret;\n    }\n\n    @NotNull\n    public static Expression cast(@NotNull ExpressionConvertible expression) {\n        Expression ret = new Expression();\n        ret.cppObj = cast(Identifier.getCppType(expression), CppObject.get(expression), null);\n        return ret;\n    }\n\n    private static native long cast(int type, long object, String columnName);\n\n    @NotNull\n    public Expression as(ColumnType type) {\n        as(cppObj, type.ordinal());\n        return this;\n    }\n\n    @NotNull\n    public ResultColumn as(@Nullable String alias) {\n        return new ResultColumn(as(cppObj, alias));\n    }\n\n    private static native long as(long self, String alias);\n\n    private static native void as(long self, int type);\n\n    @NotNull\n    public static Expression case_() {\n        Expression ret = new Expression();\n        ret.cppObj = caseWithExp(0, 0, null);\n        return ret;\n    }\n\n    @NotNull\n    public static Expression case_(@Nullable String columnName) {\n        if (columnName == null) {\n            return case_();\n        }\n        Expression ret = new Expression();\n        ret.cppObj = caseWithExp(CPPType.String, 0, columnName);\n        return ret;\n    }\n\n    @NotNull\n    public static Expression case_(@Nullable ExpressionConvertible expression) {\n        Expression ret = new Expression();\n        ret.cppObj = caseWithExp(Identifier.getCppType(expression),\n                CppObject.get(expression), null);\n        return ret;\n    }\n\n    private static native long caseWithExp(int type, long object, String columnName);\n\n    @NotNull\n    public Expression when(boolean arg) {\n        setWithWhenExp(cppObj, CPPType.Bool, arg ? 1 : 0, 0, null);\n        return this;\n    }\n\n    @NotNull\n    public Expression when(byte arg) {\n        setWithWhenExp(cppObj, CPPType.Int, arg, 0, null);\n        return this;\n    }\n\n    @NotNull\n    public Expression when(short arg) {\n        setWithWhenExp(cppObj, CPPType.Int, arg, 0, null);\n        return this;\n    }\n\n    @NotNull\n    public Expression when(int arg) {\n        setWithWhenExp(cppObj, CPPType.Int, arg, 0, null);\n        return this;\n    }\n\n    @NotNull\n    public Expression when(long arg) {\n        setWithWhenExp(cppObj, CPPType.Int, arg, 0, null);\n        return this;\n    }\n\n    @NotNull\n    public Expression when(float arg) {\n        setWithWhenExp(cppObj, CPPType.Double, 0, arg, null);\n        return this;\n    }\n\n    @NotNull\n    public Expression when(double arg) {\n        setWithWhenExp(cppObj, CPPType.Double, 0, arg, null);\n        return this;\n    }\n\n    @NotNull\n    public Expression when(@Nullable String arg) {\n        if (arg != null) {\n            setWithWhenExp(cppObj, CPPType.String, 0, 0, arg);\n        } else {\n            setWithWhenExp(cppObj, CPPType.Null, 0, 0, null);\n        }\n        return this;\n    }\n\n    @NotNull\n    public Expression when(@Nullable ExpressionConvertible arg) {\n        setWithWhenExp(cppObj, Identifier.getCppType(arg), CppObject.get(arg), 0, null);\n        return this;\n    }\n\n    private static native void setWithWhenExp(long self, int type, long intValue, double doubleValue, String stringValue);\n\n    @NotNull\n    public Expression then(boolean arg) {\n        setWithThenExp(cppObj, CPPType.Bool, arg ? 1 : 0, 0, null);\n        return this;\n    }\n\n    @NotNull\n    public Expression then(byte arg) {\n        setWithThenExp(cppObj, CPPType.Int, arg, 0, null);\n        return this;\n    }\n\n    @NotNull\n    public Expression then(short arg) {\n        setWithThenExp(cppObj, CPPType.Int, arg, 0, null);\n        return this;\n    }\n\n    @NotNull\n    public Expression then(int arg) {\n        setWithThenExp(cppObj, CPPType.Int, arg, 0, null);\n        return this;\n    }\n\n    @NotNull\n    public Expression then(long arg) {\n        setWithThenExp(cppObj, CPPType.Int, arg, 0, null);\n        return this;\n    }\n\n    @NotNull\n    public Expression then(float arg) {\n        setWithThenExp(cppObj, CPPType.Double, 0, arg, null);\n        return this;\n    }\n\n    @NotNull\n    public Expression then(double arg) {\n        setWithThenExp(cppObj, CPPType.Double, 0, arg, null);\n        return this;\n    }\n\n    @NotNull\n    public Expression then(@Nullable String arg) {\n        if (arg != null) {\n            setWithThenExp(cppObj, CPPType.String, 0, 0, arg);\n        } else {\n            setWithThenExp(cppObj, CPPType.Null, 0, 0, null);\n        }\n        return this;\n    }\n\n    @NotNull\n    public Expression then(@Nullable ExpressionConvertible arg) {\n        setWithThenExp(cppObj, Identifier.getCppType(arg), CppObject.get(arg), 0, null);\n\n        return this;\n    }\n\n    private static native void setWithThenExp(long self, int type, long intValue, double doubleValue, String stringValue);\n\n    @NotNull\n    public Expression else_(boolean arg) {\n        setWithElseExp(cppObj, CPPType.Bool, arg ? 1 : 0, 0, null);\n        return this;\n    }\n\n    @NotNull\n    public Expression else_(byte arg) {\n        setWithElseExp(cppObj, CPPType.Int, arg, 0, null);\n        return this;\n    }\n\n    @NotNull\n    public Expression else_(short arg) {\n        setWithElseExp(cppObj, CPPType.Int, arg, 0, null);\n        return this;\n    }\n\n    @NotNull\n    public Expression else_(int arg) {\n        setWithElseExp(cppObj, CPPType.Int, arg, 0, null);\n        return this;\n    }\n\n    @NotNull\n    public Expression else_(long arg) {\n        setWithElseExp(cppObj, CPPType.Int, arg, 0, null);\n        return this;\n    }\n\n    @NotNull\n    public Expression else_(float arg) {\n        setWithElseExp(cppObj, CPPType.Double, 0, arg, null);\n        return this;\n    }\n\n    @NotNull\n    public Expression else_(double arg) {\n        setWithElseExp(cppObj, CPPType.Double, 0, arg, null);\n        return this;\n    }\n\n    @NotNull\n    public Expression else_(@Nullable String arg) {\n        if (arg != null) {\n            setWithElseExp(cppObj, CPPType.String, 0, 0, arg);\n        } else {\n            setWithElseExp(cppObj, CPPType.Null, 0, 0, null);\n        }\n        return this;\n    }\n\n    @NotNull\n    public Expression else_(@Nullable ExpressionConvertible arg) {\n        setWithElseExp(cppObj, Identifier.getCppType(arg), CppObject.get(arg), 0, null);\n        return this;\n    }\n\n    private static native void setWithElseExp(long self, int type, long intValue, double doubleValue, String stringValue);\n\n    @NotNull\n    public static Expression windowFunction(@NotNull String funcName) {\n        Expression ret = new Expression();\n        ret.cppObj = createWithWindowFunction(funcName);\n        return ret;\n    }\n\n    private static native long createWithWindowFunction(String funcName);\n\n    @NotNull\n    public Expression filter(@NotNull Expression condition) {\n        filter(cppObj, condition.cppObj);\n        return this;\n    }\n\n    private static native void filter(long self, long condition);\n\n    @NotNull\n    public Expression over(@NotNull WindowDef windowDef) {\n        overWindowDef(cppObj, CppObject.get(windowDef));\n        return this;\n    }\n\n    private static native void overWindowDef(long self, long windowDef);\n\n    @NotNull\n    public Expression over(@NotNull String window) {\n        overWindow(cppObj, window);\n        return this;\n    }\n\n    private static native void overWindow(long self, String window);\n}\n"
  },
  {
    "path": "src/java/main/src/main/java/com/tencent/wcdb/winq/ExpressionConvertible.java",
    "content": "// Created by qiuwenchen on 2023/3/30.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage com.tencent.wcdb.winq;\n\npublic interface ExpressionConvertible extends IdentifierConvertible {\n}\n"
  },
  {
    "path": "src/java/main/src/main/java/com/tencent/wcdb/winq/ExpressionOperable.java",
    "content": "// Created by qiuwenchen on 2023/3/30.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage com.tencent.wcdb.winq;\n\nimport com.tencent.wcdb.base.CppObject;\nimport com.tencent.wcdb.base.Value;\n\nimport org.jetbrains.annotations.NotNull;\nimport org.jetbrains.annotations.Nullable;\n\nimport java.util.List;\nimport java.util.Set;\n\n\npublic abstract class ExpressionOperable extends Identifier implements ExpressionConvertible {\n\n    @NotNull\n    public Expression isNull() {\n        return nullOperate(false);\n    }\n\n    @NotNull\n    public Expression notNull() {\n        return nullOperate(true);\n    }\n\n    /*\n        Binary operation\n     */\n\n    @NotNull\n    public Expression or(@Nullable ExpressionConvertible operand) {\n        return binaryOperate(operand, BinaryOperatorType.Or, false);\n    }\n\n    @NotNull\n    public Expression and(@Nullable ExpressionConvertible operand) {\n        return binaryOperate(operand, BinaryOperatorType.And, false);\n    }\n\n    @NotNull\n    public Expression multiply(@Nullable ExpressionConvertible operand) {\n        return binaryOperate(operand, BinaryOperatorType.Multiply, false);\n    }\n\n    @NotNull\n    public Expression multiply(byte operand) {\n        return binaryOperate(operand, BinaryOperatorType.Multiply, false);\n    }\n\n    @NotNull\n    public Expression multiply(short operand) {\n        return binaryOperate(operand, BinaryOperatorType.Multiply, false);\n    }\n\n    @NotNull\n    public Expression multiply(int operand) {\n        return binaryOperate(operand, BinaryOperatorType.Multiply, false);\n    }\n\n    @NotNull\n    public Expression multiply(long operand) {\n        return binaryOperate(operand, BinaryOperatorType.Multiply, false);\n    }\n\n    @NotNull\n    public Expression multiply(float operand) {\n        return binaryOperate(operand, BinaryOperatorType.Multiply, false);\n    }\n\n    @NotNull\n    public Expression multiply(double operand) {\n        return binaryOperate(operand, BinaryOperatorType.Multiply, false);\n    }\n\n    @NotNull\n    public Expression divide(@NotNull ExpressionConvertible operand) {\n        return binaryOperate(operand, BinaryOperatorType.Divide, false);\n    }\n\n    @NotNull\n    public Expression divide(byte operand) {\n        return binaryOperate(operand, BinaryOperatorType.Divide, false);\n    }\n\n    @NotNull\n    public Expression divide(short operand) {\n        return binaryOperate(operand, BinaryOperatorType.Divide, false);\n    }\n\n    @NotNull\n    public Expression divide(int operand) {\n        return binaryOperate(operand, BinaryOperatorType.Divide, false);\n    }\n\n    @NotNull\n    public Expression divide(long operand) {\n        return binaryOperate(operand, BinaryOperatorType.Divide, false);\n    }\n\n    @NotNull\n    public Expression divide(float operand) {\n        return binaryOperate(operand, BinaryOperatorType.Divide, false);\n    }\n\n    @NotNull\n    public Expression divide(double operand) {\n        return binaryOperate(operand, BinaryOperatorType.Divide, false);\n    }\n\n    @NotNull\n    public Expression mod(@NotNull ExpressionConvertible operand) {\n        return binaryOperate(operand, BinaryOperatorType.Modulo, false);\n    }\n\n    @NotNull\n    public Expression mod(byte operand) {\n        return binaryOperate(operand, BinaryOperatorType.Modulo, false);\n    }\n\n    @NotNull\n    public Expression mod(short operand) {\n        return binaryOperate(operand, BinaryOperatorType.Modulo, false);\n    }\n\n    @NotNull\n    public Expression mod(int operand) {\n        return binaryOperate(operand, BinaryOperatorType.Modulo, false);\n    }\n\n    @NotNull\n    public Expression mod(long operand) {\n        return binaryOperate(operand, BinaryOperatorType.Modulo, false);\n    }\n\n    @NotNull\n    public Expression mod(float operand) {\n        return binaryOperate(operand, BinaryOperatorType.Modulo, false);\n    }\n\n    @NotNull\n    public Expression mod(double operand) {\n        return binaryOperate(operand, BinaryOperatorType.Modulo, false);\n    }\n\n    @NotNull\n    public Expression add(@Nullable ExpressionConvertible operand) {\n        return binaryOperate(operand, BinaryOperatorType.Plus, false);\n    }\n\n    @NotNull\n    public Expression add(byte operand) {\n        return binaryOperate(operand, BinaryOperatorType.Plus, false);\n    }\n\n    @NotNull\n    public Expression add(short operand) {\n        return binaryOperate(operand, BinaryOperatorType.Plus, false);\n    }\n\n    @NotNull\n    public Expression add(int operand) {\n        return binaryOperate(operand, BinaryOperatorType.Plus, false);\n    }\n\n    @NotNull\n    public Expression add(long operand) {\n        return binaryOperate(operand, BinaryOperatorType.Plus, false);\n    }\n\n    @NotNull\n    public Expression add(float operand) {\n        return binaryOperate(operand, BinaryOperatorType.Plus, false);\n    }\n\n    @NotNull\n    public Expression add(double operand) {\n        return binaryOperate(operand, BinaryOperatorType.Plus, false);\n    }\n\n    @NotNull\n    public Expression minus(@Nullable ExpressionConvertible operand) {\n        return binaryOperate(operand, BinaryOperatorType.Minus, false);\n    }\n\n    @NotNull\n    public Expression minus(byte operand) {\n        return binaryOperate(operand, BinaryOperatorType.Minus, false);\n    }\n\n    @NotNull\n    public Expression minus(short operand) {\n        return binaryOperate(operand, BinaryOperatorType.Minus, false);\n    }\n\n    @NotNull\n    public Expression minus(int operand) {\n        return binaryOperate(operand, BinaryOperatorType.Minus, false);\n    }\n\n    @NotNull\n    public Expression minus(long operand) {\n        return binaryOperate(operand, BinaryOperatorType.Minus, false);\n    }\n\n    @NotNull\n    public Expression minus(float operand) {\n        return binaryOperate(operand, BinaryOperatorType.Minus, false);\n    }\n\n    @NotNull\n    public Expression minus(double operand) {\n        return binaryOperate(operand, BinaryOperatorType.Minus, false);\n    }\n\n    @NotNull\n    public Expression leftShift(@Nullable ExpressionConvertible operand) {\n        return binaryOperate(operand, BinaryOperatorType.LeftShift, false);\n    }\n\n    @NotNull\n    public Expression leftShift(byte operand) {\n        return binaryOperate(operand, BinaryOperatorType.LeftShift, false);\n    }\n\n    @NotNull\n    public Expression leftShift(short operand) {\n        return binaryOperate(operand, BinaryOperatorType.LeftShift, false);\n    }\n\n    @NotNull\n    public Expression leftShift(int operand) {\n        return binaryOperate(operand, BinaryOperatorType.LeftShift, false);\n    }\n\n    @NotNull\n    public Expression leftShift(long operand) {\n        return binaryOperate(operand, BinaryOperatorType.LeftShift, false);\n    }\n\n    @NotNull\n    public Expression rightShift(@Nullable ExpressionConvertible operand) {\n        return binaryOperate(operand, BinaryOperatorType.RightShift, false);\n    }\n\n    @NotNull\n    public Expression rightShift(byte operand) {\n        return binaryOperate(operand, BinaryOperatorType.RightShift, false);\n    }\n\n    @NotNull\n    public Expression rightShift(short operand) {\n        return binaryOperate(operand, BinaryOperatorType.RightShift, false);\n    }\n\n    @NotNull\n    public Expression rightShift(int operand) {\n        return binaryOperate(operand, BinaryOperatorType.RightShift, false);\n    }\n\n    @NotNull\n    public Expression rightShift(long operand) {\n        return binaryOperate(operand, BinaryOperatorType.RightShift, false);\n    }\n\n    @NotNull\n    public Expression bitAnd(@Nullable ExpressionConvertible operand) {\n        return binaryOperate(operand, BinaryOperatorType.BitwiseAnd, false);\n    }\n\n    @NotNull\n    public Expression bitAnd(byte operand) {\n        return binaryOperate(operand, BinaryOperatorType.BitwiseAnd, false);\n    }\n\n    @NotNull\n    public Expression bitAnd(short operand) {\n        return binaryOperate(operand, BinaryOperatorType.BitwiseAnd, false);\n    }\n\n    @NotNull\n    public Expression bitAnd(int operand) {\n        return binaryOperate(operand, BinaryOperatorType.BitwiseAnd, false);\n    }\n\n    @NotNull\n    public Expression bitAnd(long operand) {\n        return binaryOperate(operand, BinaryOperatorType.BitwiseAnd, false);\n    }\n\n    @NotNull\n    public Expression bitOr(@Nullable ExpressionConvertible operand) {\n        return binaryOperate(operand, BinaryOperatorType.BitwiseOr, false);\n    }\n\n    @NotNull\n    public Expression bitOr(byte operand) {\n        return binaryOperate(operand, BinaryOperatorType.BitwiseOr, false);\n    }\n\n    @NotNull\n    public Expression bitOr(short operand) {\n        return binaryOperate(operand, BinaryOperatorType.BitwiseOr, false);\n    }\n\n    @NotNull\n    public Expression bitOr(int operand) {\n        return binaryOperate(operand, BinaryOperatorType.BitwiseOr, false);\n    }\n\n    @NotNull\n    public Expression bitOr(long operand) {\n        return binaryOperate(operand, BinaryOperatorType.BitwiseOr, false);\n    }\n\n    @NotNull\n    public Expression lt(@Nullable ExpressionConvertible operand) {\n        return binaryOperate(operand, BinaryOperatorType.Less, false);\n    }\n\n    @NotNull\n    public Expression lt(byte operand) {\n        return binaryOperate(operand, BinaryOperatorType.Less, false);\n    }\n\n    @NotNull\n    public Expression lt(short operand) {\n        return binaryOperate(operand, BinaryOperatorType.Less, false);\n    }\n\n    @NotNull\n    public Expression lt(int operand) {\n        return binaryOperate(operand, BinaryOperatorType.Less, false);\n    }\n\n    @NotNull\n    public Expression lt(long operand) {\n        return binaryOperate(operand, BinaryOperatorType.Less, false);\n    }\n\n    @NotNull\n    public Expression lt(double operand) {\n        return binaryOperate(operand, BinaryOperatorType.Less, false);\n    }\n\n    @NotNull\n    public Expression lt(@Nullable String operand) {\n        return binaryOperate(operand, BinaryOperatorType.Less, false);\n    }\n\n    @NotNull\n    public Expression le(@Nullable ExpressionConvertible operand) {\n        return binaryOperate(operand, BinaryOperatorType.LessOrEqual, false);\n    }\n\n    @NotNull\n    public Expression le(byte operand) {\n        return binaryOperate(operand, BinaryOperatorType.LessOrEqual, false);\n    }\n\n    @NotNull\n    public Expression le(short operand) {\n        return binaryOperate(operand, BinaryOperatorType.LessOrEqual, false);\n    }\n\n    @NotNull\n    public Expression le(int operand) {\n        return binaryOperate(operand, BinaryOperatorType.LessOrEqual, false);\n    }\n\n    @NotNull\n    public Expression le(long operand) {\n        return binaryOperate(operand, BinaryOperatorType.LessOrEqual, false);\n    }\n\n    @NotNull\n    public Expression le(float operand) {\n        return binaryOperate(operand, BinaryOperatorType.LessOrEqual, false);\n    }\n\n    @NotNull\n    public Expression le(double operand) {\n        return binaryOperate(operand, BinaryOperatorType.LessOrEqual, false);\n    }\n\n    @NotNull\n    public Expression le(@Nullable String operand) {\n        return binaryOperate(operand, BinaryOperatorType.LessOrEqual, false);\n    }\n\n    @NotNull\n    public Expression gt(@Nullable ExpressionConvertible operand) {\n        return binaryOperate(operand, BinaryOperatorType.Greater, false);\n    }\n\n    @NotNull\n    public Expression gt(byte operand) {\n        return binaryOperate(operand, BinaryOperatorType.Greater, false);\n    }\n\n    @NotNull\n    public Expression gt(short operand) {\n        return binaryOperate(operand, BinaryOperatorType.Greater, false);\n    }\n\n    @NotNull\n    public Expression gt(int operand) {\n        return binaryOperate(operand, BinaryOperatorType.Greater, false);\n    }\n\n    @NotNull\n    public Expression gt(long operand) {\n        return binaryOperate(operand, BinaryOperatorType.Greater, false);\n    }\n\n    @NotNull\n    public Expression gt(float operand) {\n        return binaryOperate(operand, BinaryOperatorType.Greater, false);\n    }\n\n    @NotNull\n    public Expression gt(double operand) {\n        return binaryOperate(operand, BinaryOperatorType.Greater, false);\n    }\n\n    @NotNull\n    public Expression gt(@Nullable String operand) {\n        return binaryOperate(operand, BinaryOperatorType.Greater, false);\n    }\n\n    @NotNull\n    public Expression ge(@Nullable ExpressionConvertible operand) {\n        return binaryOperate(operand, BinaryOperatorType.GreaterOrEqual, false);\n    }\n\n    @NotNull\n    public Expression ge(byte operand) {\n        return binaryOperate(operand, BinaryOperatorType.GreaterOrEqual, false);\n    }\n\n    @NotNull\n    public Expression ge(short operand) {\n        return binaryOperate(operand, BinaryOperatorType.GreaterOrEqual, false);\n    }\n\n    @NotNull\n    public Expression ge(int operand) {\n        return binaryOperate(operand, BinaryOperatorType.GreaterOrEqual, false);\n    }\n\n    @NotNull\n    public Expression ge(long operand) {\n        return binaryOperate(operand, BinaryOperatorType.GreaterOrEqual, false);\n    }\n\n    @NotNull\n    public Expression ge(float operand) {\n        return binaryOperate(operand, BinaryOperatorType.GreaterOrEqual, false);\n    }\n\n    @NotNull\n    public Expression ge(double operand) {\n        return binaryOperate(operand, BinaryOperatorType.GreaterOrEqual, false);\n    }\n\n    @NotNull\n    public Expression ge(@Nullable String operand) {\n        return binaryOperate(operand, BinaryOperatorType.GreaterOrEqual, false);\n    }\n\n    @NotNull\n    public Expression eq(@Nullable ExpressionConvertible operand) {\n        return binaryOperate(operand, BinaryOperatorType.Equal, false);\n    }\n\n    @NotNull\n    public Expression eq(boolean operand) {\n        return binaryOperate(operand, BinaryOperatorType.Equal, false);\n    }\n\n    @NotNull\n    public Expression eq(byte operand) {\n        return binaryOperate(operand, BinaryOperatorType.Equal, false);\n    }\n\n    @NotNull\n    public Expression eq(short operand) {\n        return binaryOperate(operand, BinaryOperatorType.Equal, false);\n    }\n\n    @NotNull\n    public Expression eq(int operand) {\n        return binaryOperate(operand, BinaryOperatorType.Equal, false);\n    }\n\n    @NotNull\n    public Expression eq(long operand) {\n        return binaryOperate(operand, BinaryOperatorType.Equal, false);\n    }\n\n    @NotNull\n    public Expression eq(float operand) {\n        return binaryOperate(operand, BinaryOperatorType.Equal, false);\n    }\n\n    @NotNull\n    public Expression eq(double operand) {\n        return binaryOperate(operand, BinaryOperatorType.Equal, false);\n    }\n\n    @NotNull\n    public Expression eq(@Nullable String operand) {\n        return binaryOperate(operand, BinaryOperatorType.Equal, false);\n    }\n\n    @NotNull\n    public Expression notEq(@Nullable ExpressionConvertible operand) {\n        return binaryOperate(operand, BinaryOperatorType.NotEqual, false);\n    }\n\n    @NotNull\n    public Expression notEq(boolean operand) {\n        return binaryOperate(operand, BinaryOperatorType.NotEqual, false);\n    }\n\n    @NotNull\n    public Expression notEq(byte operand) {\n        return binaryOperate(operand, BinaryOperatorType.NotEqual, false);\n    }\n\n    @NotNull\n    public Expression notEq(short operand) {\n        return binaryOperate(operand, BinaryOperatorType.NotEqual, false);\n    }\n\n    @NotNull\n    public Expression notEq(int operand) {\n        return binaryOperate(operand, BinaryOperatorType.NotEqual, false);\n    }\n\n    @NotNull\n    public Expression notEq(long operand) {\n        return binaryOperate(operand, BinaryOperatorType.NotEqual, false);\n    }\n\n    @NotNull\n    public Expression notEq(float operand) {\n        return binaryOperate(operand, BinaryOperatorType.NotEqual, false);\n    }\n\n    @NotNull\n    public Expression notEq(double operand) {\n        return binaryOperate(operand, BinaryOperatorType.NotEqual, false);\n    }\n\n    @NotNull\n    public Expression notEq(@Nullable String operand) {\n        return binaryOperate(operand, BinaryOperatorType.NotEqual, false);\n    }\n\n    @NotNull\n    public Expression concat(byte operand) {\n        return binaryOperate(operand, BinaryOperatorType.Concatenate, false);\n    }\n\n    @NotNull\n    public Expression concat(short operand) {\n        return binaryOperate(operand, BinaryOperatorType.Concatenate, false);\n    }\n\n    @NotNull\n    public Expression concat(int operand) {\n        return binaryOperate(operand, BinaryOperatorType.Concatenate, false);\n    }\n\n    @NotNull\n    public Expression concat(long operand) {\n        return binaryOperate(operand, BinaryOperatorType.Concatenate, false);\n    }\n\n    @NotNull\n    public Expression concat(float operand) {\n        return binaryOperate(operand, BinaryOperatorType.Concatenate, false);\n    }\n\n    @NotNull\n    public Expression concat(double operand) {\n        return binaryOperate(operand, BinaryOperatorType.Concatenate, false);\n    }\n\n    @NotNull\n    public Expression concat(@Nullable String operand) {\n        return binaryOperate(operand, BinaryOperatorType.Concatenate, false);\n    }\n\n    @NotNull\n    public Expression concat(@Nullable ExpressionConvertible operand) {\n        return binaryOperate(operand, BinaryOperatorType.Concatenate, false);\n    }\n\n    /*\n        Between operation\n     */\n\n    @NotNull\n    public Expression between(@Nullable ExpressionConvertible begin, @Nullable ExpressionConvertible end) {\n        return createExpression(betweenOperate(Identifier.getCppType(this), CppObject.get(this),\n                Identifier.getCppType(begin), CppObject.get(begin), 0, null,\n                Identifier.getCppType(end), CppObject.get(end), 0, null,\n                false));\n    }\n\n    @NotNull\n    public Expression between(@Nullable ExpressionConvertible begin, long end) {\n        return createExpression(betweenOperate(Identifier.getCppType(this), CppObject.get(this),\n                Identifier.getCppType(begin), CppObject.get(begin), 0, null,\n                CPPType.Int, end, 0, null,\n                false));\n    }\n\n    @NotNull\n    public Expression between(@Nullable ExpressionConvertible begin, double end) {\n        return createExpression(betweenOperate(Identifier.getCppType(this), CppObject.get(this),\n                Identifier.getCppType(begin), CppObject.get(begin), 0, null,\n                CPPType.Double, 0, end, null,\n                false));\n    }\n\n    @NotNull\n    public Expression between(@Nullable ExpressionConvertible begin, String end) {\n        return createExpression(betweenOperate(Identifier.getCppType(this), CppObject.get(this),\n                Identifier.getCppType(begin), CppObject.get(begin), 0, null,\n                CPPType.String, 0, 0, end,\n                false));\n    }\n\n    @NotNull\n    public Expression between(long begin, @Nullable ExpressionConvertible end) {\n        return createExpression(betweenOperate(Identifier.getCppType(this), CppObject.get(this),\n                CPPType.Int, begin, 0, null,\n                Identifier.getCppType(end), CppObject.get(end), 0, null,\n                false));\n    }\n\n    @NotNull\n    public Expression between(long begin, long end) {\n        return createExpression(betweenOperate(Identifier.getCppType(this), CppObject.get(this),\n                CPPType.Int, begin, 0, null,\n                CPPType.Int, end, 0, null,\n                false));\n    }\n\n    @NotNull\n    public Expression between(long begin, double end) {\n        return createExpression(betweenOperate(Identifier.getCppType(this), CppObject.get(this),\n                CPPType.Int, begin, 0, null,\n                CPPType.Double, 0, end, null,\n                false));\n    }\n\n    @NotNull\n    public Expression between(long begin, @Nullable String end) {\n        return createExpression(betweenOperate(Identifier.getCppType(this), CppObject.get(this),\n                CPPType.Int, begin, 0, null,\n                CPPType.String, 0, 0, end,\n                false));\n    }\n\n    @NotNull\n    public Expression between(double begin, @Nullable ExpressionConvertible end) {\n        return createExpression(betweenOperate(Identifier.getCppType(this), CppObject.get(this),\n                CPPType.Double, 0, begin, null,\n                Identifier.getCppType(end), CppObject.get(end), 0, null,\n                false));\n    }\n\n    @NotNull\n    public Expression between(double begin, long end) {\n        return createExpression(betweenOperate(Identifier.getCppType(this), CppObject.get(this),\n                CPPType.Double, 0, begin, null,\n                CPPType.Int, end, 0, null,\n                false));\n    }\n\n    @NotNull\n    public Expression between(double begin, double end) {\n        return createExpression(betweenOperate(Identifier.getCppType(this), CppObject.get(this),\n                CPPType.Double, 0, begin, null,\n                CPPType.Double, 0, end, null,\n                false));\n    }\n\n    @NotNull\n    public Expression between(double begin, @Nullable String end) {\n        return createExpression(betweenOperate(Identifier.getCppType(this), CppObject.get(this),\n                CPPType.Double, 0, begin, null,\n                CPPType.String, 0, 0, end,\n                false));\n    }\n\n    @NotNull\n    public Expression between(@Nullable String begin, @Nullable ExpressionConvertible end) {\n        return createExpression(betweenOperate(Identifier.getCppType(this), CppObject.get(this),\n                CPPType.String, 0, 0, begin,\n                Identifier.getCppType(end), CppObject.get(end), 0, null,\n                false));\n    }\n\n    @NotNull\n    public Expression between(@Nullable String begin, long end) {\n        return createExpression(betweenOperate(Identifier.getCppType(this), CppObject.get(this),\n                CPPType.String, 0, 0, begin,\n                CPPType.Int, end, 0, null,\n                false));\n    }\n\n    @NotNull\n    public Expression between(@Nullable String begin, double end) {\n        return createExpression(betweenOperate(Identifier.getCppType(this), CppObject.get(this),\n                CPPType.String, 0, 0, begin,\n                CPPType.Double, 0, end, null,\n                false));\n    }\n\n    @NotNull\n    public Expression between(@Nullable String begin, String end) {\n        return createExpression(betweenOperate(Identifier.getCppType(this), CppObject.get(this),\n                CPPType.String, 0, 0, begin,\n                CPPType.String, 0, 0, end,\n                false));\n    }\n\n    @NotNull\n    public Expression notBetween(@Nullable ExpressionConvertible begin, @Nullable ExpressionConvertible end) {\n        return createExpression(betweenOperate(Identifier.getCppType(this), CppObject.get(this),\n                Identifier.getCppType(begin), CppObject.get(begin), 0, null,\n                Identifier.getCppType(end), CppObject.get(end), 0, null,\n                true));\n    }\n\n    @NotNull\n    public Expression notBetween(@Nullable ExpressionConvertible begin, long end) {\n        return createExpression(betweenOperate(Identifier.getCppType(this), CppObject.get(this),\n                Identifier.getCppType(begin), CppObject.get(begin), 0, null,\n                CPPType.Int, end, 0, null,\n                true));\n    }\n\n    @NotNull\n    public Expression notBetween(@Nullable ExpressionConvertible begin, double end) {\n        return createExpression(betweenOperate(Identifier.getCppType(this), CppObject.get(this),\n                Identifier.getCppType(begin), CppObject.get(begin), 0, null,\n                CPPType.Double, 0, end, null,\n                true));\n    }\n\n    @NotNull\n    public Expression notBetween(@Nullable ExpressionConvertible begin, @Nullable String end) {\n        return createExpression(betweenOperate(Identifier.getCppType(this), CppObject.get(this),\n                Identifier.getCppType(begin), CppObject.get(begin), 0, null,\n                CPPType.String, 0, 0, end,\n                true));\n    }\n\n    @NotNull\n    public Expression notBetween(long begin, @Nullable ExpressionConvertible end) {\n        return createExpression(betweenOperate(Identifier.getCppType(this), CppObject.get(this),\n                CPPType.Int, begin, 0, null,\n                Identifier.getCppType(end), CppObject.get(end), 0, null,\n                true));\n    }\n\n    @NotNull\n    public Expression notBetween(long begin, long end) {\n        return createExpression(betweenOperate(Identifier.getCppType(this), CppObject.get(this),\n                CPPType.Int, begin, 0, null,\n                CPPType.Int, end, 0, null,\n                true));\n    }\n\n    @NotNull\n    public Expression notBetween(long begin, double end) {\n        return createExpression(betweenOperate(Identifier.getCppType(this), CppObject.get(this),\n                CPPType.Int, begin, 0, null,\n                CPPType.Double, 0, end, null,\n                true));\n    }\n\n    @NotNull\n    public Expression notBetween(long begin, @Nullable String end) {\n        return createExpression(betweenOperate(Identifier.getCppType(this), CppObject.get(this),\n                CPPType.Int, begin, 0, null,\n                CPPType.String, 0, 0, end,\n                true));\n    }\n\n    @NotNull\n    public Expression notBetween(double begin, @Nullable ExpressionConvertible end) {\n        return createExpression(betweenOperate(Identifier.getCppType(this), CppObject.get(this),\n                CPPType.Double, 0, begin, null,\n                Identifier.getCppType(end), CppObject.get(end), 0, null,\n                true));\n    }\n\n    @NotNull\n    public Expression notBetween(double begin, long end) {\n        return createExpression(betweenOperate(Identifier.getCppType(this), CppObject.get(this),\n                CPPType.Double, 0, begin, null,\n                CPPType.Int, end, 0, null,\n                true));\n    }\n\n    @NotNull\n    public Expression notBetween(double begin, double end) {\n        return createExpression(betweenOperate(Identifier.getCppType(this), CppObject.get(this),\n                CPPType.Double, 0, begin, null,\n                CPPType.Double, 0, end, null,\n                true));\n    }\n\n    @NotNull\n    public Expression notBetween(double begin, @Nullable String end) {\n        return createExpression(betweenOperate(Identifier.getCppType(this), CppObject.get(this),\n                CPPType.Double, 0, begin, null,\n                CPPType.String, 0, 0, end,\n                true));\n    }\n\n    @NotNull\n    public Expression notBetween(@Nullable String begin, @Nullable ExpressionConvertible end) {\n        return createExpression(betweenOperate(Identifier.getCppType(this), CppObject.get(this),\n                CPPType.String, 0, 0, begin,\n                Identifier.getCppType(end), CppObject.get(end), 0, null,\n                true));\n    }\n\n    @NotNull\n    public Expression notBetween(@Nullable String begin, long end) {\n        return createExpression(betweenOperate(Identifier.getCppType(this), CppObject.get(this),\n                CPPType.String, 0, 0, begin,\n                CPPType.Int, end, 0, null,\n                true));\n    }\n\n    @NotNull\n    public Expression notBetween(@Nullable String begin, double end) {\n        return createExpression(betweenOperate(Identifier.getCppType(this), CppObject.get(this),\n                CPPType.String, 0, 0, begin,\n                CPPType.Double, 0, end, null,\n                true));\n    }\n\n    @NotNull\n    public Expression notBetween(@Nullable String begin, @Nullable String end) {\n        return createExpression(betweenOperate(Identifier.getCppType(this), CppObject.get(this),\n                CPPType.String, 0, 0, begin,\n                CPPType.String, 0, 0, end,\n                true));\n    }\n\n    /*\n        In operation\n     */\n\n    @NotNull\n    public Expression in(short... operands) {\n        long[] values = new long[operands.length];\n        for (int i = 0; i < operands.length; i++) {\n            values[i] = operands[i];\n        }\n        return in(values, false);\n    }\n\n    @NotNull\n    public Expression in(@NotNull Short[] operands) {\n        long[] values = new long[operands.length];\n        for (int i = 0; i < operands.length; i++) {\n            values[i] = operands[i];\n        }\n        return in(values, false);\n    }\n\n    @NotNull\n    public Expression in(int... operands) {\n        long[] values = new long[operands.length];\n        for (int i = 0; i < operands.length; i++) {\n            values[i] = operands[i];\n        }\n        return in(values, false);\n    }\n\n    @NotNull\n    public Expression in(@NotNull Integer[] operands) {\n        long[] values = new long[operands.length];\n        for (int i = 0; i < operands.length; i++) {\n            values[i] = operands[i];\n        }\n        return in(values, false);\n    }\n\n    @NotNull\n    public Expression in(long... operands) {\n        return in(operands, false);\n    }\n\n    @NotNull\n    public Expression in(@NotNull Long[] operands) {\n        return in(operands, false);\n    }\n\n    @NotNull\n    public Expression in(float... operands) {\n        double[] values = new double[operands.length];\n        for (int i = 0; i < operands.length; i++) {\n            values[i] = operands[i];\n        }\n        return in(values, false);\n    }\n\n    @NotNull\n    public Expression in(@NotNull Float[] operands) {\n        double[] values = new double[operands.length];\n        for (int i = 0; i < operands.length; i++) {\n            values[i] = operands[i];\n        }\n        return in(values, false);\n    }\n\n    @NotNull\n    public Expression in(double... operands) {\n        return in(operands, false);\n    }\n\n    @NotNull\n    public Expression in(@NotNull Double[] operands) {\n        return in(operands, false);\n    }\n\n    @NotNull\n    public Expression in(@NotNull String... operands) {\n        return in(operands, false);\n    }\n\n    @NotNull\n    public Expression in(@NotNull Value... operands) {\n        return in(operands, false);\n    }\n\n    @NotNull\n    public <T> Expression in(@NotNull Set<T> operands) {\n        return in(operands.toArray(), false);\n    }\n\n    @NotNull\n    public <T> Expression in(@NotNull List<T> operands) {\n        return in(operands.toArray(), false);\n    }\n\n    @NotNull\n    public Expression notIn(short... operands) {\n        long[] values = new long[operands.length];\n        for (int i = 0; i < operands.length; i++) {\n            values[i] = operands[i];\n        }\n        return in(values, true);\n    }\n\n    @NotNull\n    public Expression notIn(@NotNull Short[] operands) {\n        long[] values = new long[operands.length];\n        for (int i = 0; i < operands.length; i++) {\n            values[i] = operands[i];\n        }\n        return in(values, true);\n    }\n\n    @NotNull\n    public Expression notIn(int... operands) {\n        long[] values = new long[operands.length];\n        for (int i = 0; i < operands.length; i++) {\n            values[i] = operands[i];\n        }\n        return in(values, true);\n    }\n\n    @NotNull\n    public Expression notIn(@NotNull Integer[] operands) {\n        long[] values = new long[operands.length];\n        for (int i = 0; i < operands.length; i++) {\n            values[i] = operands[i];\n        }\n        return in(values, true);\n    }\n\n    @NotNull\n    public Expression notIn(long... operands) {\n        return in(operands, true);\n    }\n\n    @NotNull\n    public Expression notIn(@NotNull Long[] operands) {\n        return in(operands, true);\n    }\n\n    @NotNull\n    public Expression notIn(float... operands) {\n        double[] values = new double[operands.length];\n        for (int i = 0; i < operands.length; i++) {\n            values[i] = operands[i];\n        }\n        return in(values, true);\n    }\n\n    @NotNull\n    public Expression notIn(@NotNull Float[] operands) {\n        double[] values = new double[operands.length];\n        for (int i = 0; i < operands.length; i++) {\n            values[i] = operands[i];\n        }\n        return in(values, true);\n    }\n\n    @NotNull\n    public Expression notIn(double... operands) {\n        return in(operands, true);\n    }\n\n    @NotNull\n    public Expression notIn(@NotNull Double[] operands) {\n        return in(operands, true);\n    }\n\n    @NotNull\n    public Expression notIn(@NotNull String... operands) {\n        return in(operands, true);\n    }\n\n    @NotNull\n    public Expression notIn(@NotNull Value... operands) {\n        return in(operands, true);\n    }\n\n    @NotNull\n    public <T> Expression notIn(@NotNull Set<T> operands) {\n        return in(operands.toArray(), true);\n    }\n\n    @NotNull\n    public <T> Expression notIn(@NotNull List<T> operands) {\n        return in(operands.toArray(), true);\n    }\n\n    @NotNull\n    public Expression inTable(@NotNull String table) {\n        return inTable(table, false);\n    }\n\n    @NotNull\n    public Expression notInTable(@NotNull String table) {\n        return inTable(table, true);\n    }\n\n    @NotNull\n    public Expression inFunction(@NotNull String table) {\n        return inFunction(table, false);\n    }\n\n    @NotNull\n    public Expression notInFunction(@NotNull String table) {\n        return inFunction(table, true);\n    }\n\n    @NotNull\n    public Expression in(@NotNull StatementSelect select) {\n        return in(select, false);\n    }\n\n    @NotNull\n    public Expression notIn(@NotNull StatementSelect select) {\n        return in(select, true);\n    }\n\n    /*\n        Collate\n     */\n\n    @NotNull\n    public Expression collate(@NotNull String collation) {\n        return createExpression(collate(Identifier.getCppType(this), CppObject.get(this), collation));\n    }\n\n    /*\n        Function\n     */\n\n    @NotNull\n    public Expression substr(short start, short length) {\n        return Expression.function(\"SUBSTR\")\n                .argument(this)\n                .argument(start)\n                .argument(length);\n    }\n\n    @NotNull\n    public Expression substr(int start, int length) {\n        return Expression.function(\"SUBSTR\")\n                .argument(this)\n                .argument(start)\n                .argument(length);\n    }\n\n    @NotNull\n    public Expression substr(long start, long length) {\n        return Expression.function(\"SUBSTR\")\n                .argument(this)\n                .argument(start)\n                .argument(length);\n    }\n\n    @NotNull\n    public Expression like(@NotNull String content) {\n        return binaryOperate(content, BinaryOperatorType.Like, false);\n    }\n\n    @NotNull\n    public Expression notLike(@NotNull String content) {\n        return binaryOperate(content, BinaryOperatorType.Like, true);\n    }\n\n    @NotNull\n    public Expression glob(@NotNull String content) {\n        return binaryOperate(content, BinaryOperatorType.GLOB, false);\n    }\n\n    @NotNull\n    public Expression notGlob(@NotNull String content) {\n        return binaryOperate(content, BinaryOperatorType.GLOB, true);\n    }\n\n    @NotNull\n    public Expression match(@NotNull String content) {\n        return binaryOperate(content, BinaryOperatorType.Match, false);\n    }\n\n    @NotNull\n    public Expression notMatch(@NotNull String content) {\n        return binaryOperate(content, BinaryOperatorType.Match, true);\n    }\n\n    @NotNull\n    public Expression regexp(@NotNull String content) {\n        return binaryOperate(content, BinaryOperatorType.RegExp, false);\n    }\n\n    @NotNull\n    public Expression notRegexp(@NotNull String content) {\n        return binaryOperate(content, BinaryOperatorType.RegExp, true);\n    }\n\n    @NotNull\n    public Expression is(boolean operand) {\n        return binaryOperate(operand, BinaryOperatorType.Is, false);\n    }\n\n    @NotNull\n    public Expression is(byte operand) {\n        return binaryOperate(operand, BinaryOperatorType.Is, false);\n    }\n\n    @NotNull\n    public Expression is(short operand) {\n        return binaryOperate(operand, BinaryOperatorType.Is, false);\n    }\n\n    @NotNull\n    public Expression is(int operand) {\n        return binaryOperate(operand, BinaryOperatorType.Is, false);\n    }\n\n    @NotNull\n    public Expression is(long operand) {\n        return binaryOperate(operand, BinaryOperatorType.Is, false);\n    }\n\n    @NotNull\n    public Expression is(float operand) {\n        return binaryOperate(operand, BinaryOperatorType.Is, false);\n    }\n\n    @NotNull\n    public Expression is(double operand) {\n        return binaryOperate(operand, BinaryOperatorType.Is, false);\n    }\n\n    @NotNull\n    public Expression is(@Nullable String operand) {\n        return binaryOperate(operand, BinaryOperatorType.Is, false);\n    }\n\n    @NotNull\n    public Expression is(@Nullable ExpressionConvertible operand) {\n        return binaryOperate(operand, BinaryOperatorType.Is, false);\n    }\n\n    @NotNull\n    public Expression isNot(boolean operand) {\n        return binaryOperate(operand, BinaryOperatorType.Is, true);\n    }\n\n    @NotNull\n    public Expression isNot(byte operand) {\n        return binaryOperate(operand, BinaryOperatorType.Is, true);\n    }\n\n    @NotNull\n    public Expression isNot(short operand) {\n        return binaryOperate(operand, BinaryOperatorType.Is, true);\n    }\n\n    @NotNull\n    public Expression isNot(int operand) {\n        return binaryOperate(operand, BinaryOperatorType.Is, true);\n    }\n\n    @NotNull\n    public Expression isNot(long operand) {\n        return binaryOperate(operand, BinaryOperatorType.Is, true);\n    }\n\n    @NotNull\n    public Expression isNot(float operand) {\n        return binaryOperate(operand, BinaryOperatorType.Is, true);\n    }\n\n    @NotNull\n    public Expression isNot(double operand) {\n        return binaryOperate(operand, BinaryOperatorType.Is, true);\n    }\n\n    @NotNull\n    public Expression isNot(@Nullable String operand) {\n        return binaryOperate(operand, BinaryOperatorType.Is, true);\n    }\n\n    @NotNull\n    public Expression isNot(@Nullable ExpressionConvertible operand) {\n        return binaryOperate(operand, BinaryOperatorType.Is, true);\n    }\n\n    @NotNull\n    public Expression avg() {\n        return Expression.function(\"AVG\").argument(this);\n    }\n\n    @NotNull\n    public Expression count() {\n        return Expression.function(\"COUNT\").argument(this);\n    }\n\n    @NotNull\n    public Expression groupConcat() {\n        return Expression.function(\"GROUP_CONCAT\").argument(this);\n    }\n\n    @NotNull\n    public Expression groupConcat(String sperator) {\n        return Expression.function(\"GROUP_CONCAT\").argument(this).argument(sperator);\n    }\n\n    @NotNull\n    public Expression max() {\n        return Expression.function(\"MAX\").argument(this);\n    }\n\n    @NotNull\n    public Expression min() {\n        return Expression.function(\"MIN\").argument(this);\n    }\n\n    @NotNull\n    public Expression sum() {\n        return Expression.function(\"SUM\").argument(this);\n    }\n\n    @NotNull\n    public Expression total() {\n        return Expression.function(\"TOTAL\").argument(this);\n    }\n\n    @NotNull\n    public Expression abs() {\n        return Expression.function(\"ABS\").argument(this);\n    }\n\n    @NotNull\n    public Expression hex() {\n        return Expression.function(\"HEX\").argument(this);\n    }\n\n    @NotNull\n    public Expression length() {\n        return Expression.function(\"LENGTH\").argument(this);\n    }\n\n    @NotNull\n    public Expression lower() {\n        return Expression.function(\"LOWER\").argument(this);\n    }\n\n    @NotNull\n    public Expression upper() {\n        return Expression.function(\"UPPER\").argument(this);\n    }\n\n    @NotNull\n    public Expression round() {\n        return Expression.function(\"ROUND\").argument(this);\n    }\n\n    @NotNull\n    public Expression matchInfo() {\n        return Expression.function(\"matchInfo\").argument(this);\n    }\n\n    @NotNull\n    public Expression offsets() {\n        return Expression.function(\"offsets\").argument(this);\n    }\n\n    @NotNull\n    public Expression snippet() {\n        return Expression.function(\"snippet\").argument(this);\n    }\n\n    @NotNull\n    public Expression bm25() {\n        return Expression.function(\"bm25\").argument(this);\n    }\n\n    @NotNull\n    public Expression highlight() {\n        return Expression.function(\"highlight\").argument(this);\n    }\n\n    @NotNull\n    public Expression substringMatchInfo() {\n        return Expression.function(\"substring_match_info\").argument(this);\n    }\n\n    /*\n        Private & native\n    */\n\n    protected static Expression createExpression(long cppObj) {\n        Expression ret = new Expression();\n        ret.cppObj = cppObj;\n        return ret;\n    }\n\n    private Expression nullOperate(boolean isNot) {\n        Expression ret = new Expression();\n        ret.cppObj = nullOperate(Identifier.getCppType(this), CppObject.get(this), isNot);\n        return ret;\n    }\n\n    private static native long nullOperate(int type, long operand, boolean isNot);\n\n    private static class BinaryOperatorType {\n        final static int Concatenate = 1;\n        final static int Multiply = 2;\n        final static int Divide = 3;\n        final static int Modulo = 4;\n        final static int Plus = 5;\n        final static int Minus = 6;\n        final static int LeftShift = 7;\n        final static int RightShift = 8;\n        final static int BitwiseAnd = 9;\n        final static int BitwiseOr = 10;\n        final static int Less = 11;\n        final static int LessOrEqual = 12;\n        final static int Greater = 13;\n        final static int GreaterOrEqual = 14;\n        final static int Equal = 15;\n        final static int NotEqual = 16;\n        final static int Is = 17;\n        final static int And = 18;\n        final static int Or = 19;\n        final static int Like = 20;\n        final static int GLOB = 21;\n        final static int RegExp = 22;\n        final static int Match = 23;\n    }\n\n    private Expression binaryOperate(ExpressionConvertible operand, int type, boolean isNot) {\n        return createExpression(binaryOperate(Identifier.getCppType(this),\n                CppObject.get(this),\n                Identifier.getCppType(operand),\n                CppObject.get(operand),\n                0,\n                null,\n                type,\n                isNot));\n    }\n\n    private Expression binaryOperate(boolean operand, int type, boolean isNot) {\n        return createExpression(binaryOperate(Identifier.getCppType(this),\n                CppObject.get(this),\n                CPPType.Bool,\n                operand ? 1 : 0,\n                0,\n                null,\n                type,\n                isNot));\n    }\n\n    private Expression binaryOperate(long operand, int type, boolean isNot) {\n        return createExpression(binaryOperate(Identifier.getCppType(this),\n                CppObject.get(this),\n                CPPType.Int,\n                operand,\n                0,\n                null,\n                type,\n                isNot));\n    }\n\n    private Expression binaryOperate(double operand, int type, boolean isNot) {\n        return createExpression(binaryOperate(Identifier.getCppType(this),\n                CppObject.get(this),\n                CPPType.Double,\n                0,\n                operand,\n                null,\n                type,\n                isNot));\n    }\n\n    private Expression binaryOperate(String operand, int type, boolean isNot) {\n        return createExpression(binaryOperate(Identifier.getCppType(this),\n                CppObject.get(this),\n                CPPType.String,\n                0,\n                0,\n                operand,\n                type,\n                isNot));\n    }\n\n    private static native long binaryOperate(int leftType, long left,\n                                             int rightType, long right_long, double right_double, String right_string,\n                                             int operatorType,\n                                             boolean isNot);\n\n    private static native long betweenOperate(int operandType, long operand,\n                                              int leftType, long left_long, double left_double, String left_string,\n                                              int rightType, long right_long, double right_double, String right_string,\n                                              boolean isNot);\n\n    private Expression in(long[] operands, boolean isNot) {\n        return createExpression(in(Identifier.getCppType(this),\n                CppObject.get(this),\n                CPPType.Int,\n                operands,\n                null,\n                null,\n                isNot));\n    }\n\n    private Expression in(int type, long[] operands, boolean isNot) {\n        return createExpression(in(Identifier.getCppType(this),\n                CppObject.get(this),\n                type,\n                operands,\n                null,\n                null,\n                isNot));\n    }\n\n    private Expression in(double[] operands, boolean isNot) {\n        return createExpression(in(Identifier.getCppType(this),\n                CppObject.get(this),\n                CPPType.Double,\n                null,\n                operands,\n                null,\n                isNot));\n    }\n\n    private Expression in(String[] operands, boolean isNot) {\n        return createExpression(in(Identifier.getCppType(this),\n                CppObject.get(this),\n                CPPType.String,\n                null,\n                null,\n                operands,\n                isNot));\n    }\n\n    private static native long in(int operandType, long operand, int type, long[] longArray, double[] doubleArray, String[] stringArray, boolean isNot);\n\n    private Expression in(Object[] operands, boolean isNot) {\n        if (operands == null || operands.length == 0) {\n            return in((long[]) null, isNot);\n        }\n\n        int dataType = MultiTypeArray.getObjectType(operands[0]);\n        if (dataType == ObjectType.Identifier) {\n            long[] cppObjs = new long[operands.length];\n            for (int i = 0; i < operands.length; i++) {\n                cppObjs[i] = CppObject.get((Identifier) operands[i]);\n            }\n            return in(Identifier.getCppType((Identifier) operands[0]), cppObjs, isNot);\n        } else if (dataType == ObjectType.Value) {\n            switch (((Value) operands[0]).getType()) {\n                case Integer:\n                    long[] intArray = new long[operands.length];\n                    for (int i = 0; i < operands.length; i++) {\n                        intArray[i] = ((Value) operands[i]).getLong();\n                    }\n                    return in(intArray, isNot);\n                case Float:\n                    double[] doubleArray = new double[operands.length];\n                    for (int i = 0; i < operands.length; i++) {\n                        doubleArray[i] = ((Value) operands[i]).getDouble();\n                    }\n                    return in(doubleArray, isNot);\n                case Text:\n                    String[] textArray = new String[operands.length];\n                    for (int i = 0; i < operands.length; i++) {\n                        textArray[i] = ((Value) operands[i]).getText();\n                    }\n                    return in(textArray, isNot);\n            }\n            if (operands instanceof String[]) {\n                return in((String[]) operands, isNot);\n            } else {\n                String[] stringArray = new String[operands.length];\n                for (int i = 0; i < stringArray.length; i++) {\n                    stringArray[i] = (String) operands[i];\n                }\n                return in(stringArray, isNot);\n            }\n        } else if (dataType == ObjectType.String) {\n            if (operands instanceof String[]) {\n                return in((String[]) operands, isNot);\n            } else {\n                String[] stringArray = new String[operands.length];\n                for (int i = 0; i < stringArray.length; i++) {\n                    stringArray[i] = (String) operands[i];\n                }\n                return in(stringArray, isNot);\n            }\n        } else if (dataType < ObjectType.Float) {\n            long[] values = new long[operands.length];\n            for (int i = 0; i < operands.length; i++) {\n                switch (dataType) {\n                    case ObjectType.Null:\n                        values[i] = 0;\n                        break;\n                    case ObjectType.Bool:\n                        values[i] = (Boolean) operands[i] ? 1 : 0;\n                        break;\n                    case ObjectType.Char:\n                        values[i] = (Character) operands[i];\n                        break;\n                    case ObjectType.Short:\n                        values[i] = (Short) operands[i];\n                        break;\n                    case ObjectType.Int:\n                        values[i] = (Integer) operands[i];\n                        break;\n                    case ObjectType.Long:\n                        values[i] = (Long) operands[i];\n                        break;\n                }\n            }\n            return in(values, isNot);\n        } else if (dataType != ObjectType.Unknown) {\n            double[] values = new double[operands.length];\n            for (int i = 0; i < operands.length; i++) {\n                if (dataType == ObjectType.Float) {\n                    values[i] = (Float) operands[i];\n                } else {\n                    values[i] = (Double) operands[i];\n                }\n            }\n            return in(values, isNot);\n        }\n        return in((long[]) null);\n    }\n\n    private Expression inTable(String table, boolean isNot) {\n        return createExpression(inTable(Identifier.getCppType(this), CppObject.get(this), table, isNot));\n    }\n\n    private static native long inTable(int type, long operand, String table, boolean isNot);\n\n    private Expression inFunction(String func, boolean isNot) {\n        return createExpression(inFunction(Identifier.getCppType(this), CppObject.get(this), func, isNot));\n    }\n\n    private static native long inFunction(int type, long operand, String func, boolean isNot);\n\n    private Expression in(StatementSelect select, boolean isNot) {\n        return createExpression(inSelect(Identifier.getCppType(this), CppObject.get(this), CppObject.get(select), isNot));\n    }\n\n    private static native long inSelect(int type, long operand, long select, boolean isNot);\n\n    private static native long collate(int type, long operand, String collation);\n}\n"
  },
  {
    "path": "src/java/main/src/main/java/com/tencent/wcdb/winq/ForeignKey.java",
    "content": "// Created by qiuwenchen on 2023/4/6.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdb.winq;\n\nimport com.tencent.wcdb.base.CppObject;\n\nimport org.jetbrains.annotations.NotNull;\nimport org.jetbrains.annotations.Nullable;\n\npublic class ForeignKey extends Identifier {\n    @Override\n    protected int getType() {\n        return CPPType.ForeignKeyClause;\n    }\n\n    public ForeignKey() {\n        cppObj = createCPPObj();\n    }\n\n    private static native long createCPPObj();\n\n    @NotNull\n    public ForeignKey references(@Nullable String table) {\n        configReference(cppObj, table);\n        return this;\n    }\n\n    private static native void configReference(long self, String table);\n\n    @NotNull\n    public ForeignKey column(@Nullable Column column) {\n        configColumns(cppObj, Identifier.getCppType(column), new long[]{CppObject.get(column)}, null);\n        return this;\n    }\n\n    @NotNull\n    public ForeignKey column(@Nullable String column) {\n        configColumns(cppObj, CPPType.String, null, new String[]{column});\n        return this;\n    }\n\n    @NotNull\n    public ForeignKey columns(@Nullable Column... columns) {\n        if (columns == null || columns.length == 0) {\n            return this;\n        }\n        long[] objects = new long[columns.length];\n        for (int i = 0; i < columns.length; i++) {\n            objects[i] = CppObject.get(columns[i]);\n        }\n        configColumns(cppObj, CPPType.Column, objects, null);\n        return this;\n    }\n\n    @NotNull\n    public ForeignKey columns(@Nullable String... columns) {\n        if (columns == null || columns.length == 0) {\n            return this;\n        }\n        configColumns(cppObj, CPPType.String, null, columns);\n        return this;\n    }\n\n    private static native void configColumns(long self, int type, long[] objects, String[] columnNames);\n\n    public enum Action {\n        SetNull, SetDefault, Cascade, Restrict, NoAction\n    }\n\n    @NotNull\n    public ForeignKey onDelete(Action action) {\n        configOnDeleteAction(cppObj, action.ordinal());\n        return this;\n    }\n\n    private static native void configOnDeleteAction(long self, int action);\n\n    @NotNull\n    public ForeignKey onUpdate(Action action) {\n        configOnUpdateAction(cppObj, action.ordinal());\n        return this;\n    }\n\n    private static native void configOnUpdateAction(long self, int action);\n\n    public enum Match {\n        Simple, Full, Partial\n    }\n\n    @NotNull\n    public ForeignKey match(Match match) {\n        configMatch(cppObj, match.ordinal() + 1);\n        return this;\n    }\n\n    private static native void configMatch(long self, int match);\n\n    public enum Initially {\n        Default, Deferred, Immediate\n    }\n\n    @NotNull\n    public ForeignKey deferrable(Initially initially) {\n        configDeferrable(cppObj, initially.ordinal());\n        return this;\n    }\n\n    private static native void configDeferrable(long self, int type);\n\n    @NotNull\n    public ForeignKey notDeferrable(Initially initially) {\n        configNotDeferrable(cppObj, initially.ordinal());\n        return this;\n    }\n\n    private static native void configNotDeferrable(long self, int type);\n}\n"
  },
  {
    "path": "src/java/main/src/main/java/com/tencent/wcdb/winq/FrameSpec.java",
    "content": "// Created by qiuwenchen on 2023/6/9.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdb.winq;\n\nimport com.tencent.wcdb.base.CppObject;\n\nimport org.jetbrains.annotations.NotNull;\nimport org.jetbrains.annotations.Nullable;\n\npublic class FrameSpec extends Identifier {\n    @Override\n    protected int getType() {\n        return CPPType.FrameSpec;\n    }\n\n    public FrameSpec() {\n        cppObj = createCppObj();\n    }\n\n    private static native long createCppObj();\n\n    @NotNull\n    public FrameSpec range() {\n        configRange(cppObj);\n        return this;\n    }\n\n    private static native void configRange(long self);\n\n    @NotNull\n    public FrameSpec rows() {\n        configRows(cppObj);\n        return this;\n    }\n\n    private static native void configRows(long self);\n\n    @NotNull\n    public FrameSpec unboundedPreceding() {\n        configUnboundedPreceding(cppObj);\n        return this;\n    }\n\n    private static native void configUnboundedPreceding(long self);\n\n    @NotNull\n    public FrameSpec preceding(long offset) {\n        configPreceding(cppObj, CPPType.Int, offset);\n        return this;\n    }\n\n    @NotNull\n    public FrameSpec preceding(@Nullable ExpressionConvertible offset) {\n        configPreceding(cppObj, Identifier.getCppType(offset), CppObject.get(offset));\n        return this;\n    }\n\n    private static native void configPreceding(long self, int type, long expression);\n\n    @NotNull\n    public FrameSpec currentRow() {\n        configCurrentRow(cppObj);\n        return this;\n    }\n\n    private static native void configCurrentRow(long self);\n\n    @NotNull\n    public FrameSpec betweenUnboundedPreceding() {\n        configBetweenUnboundedPreceding(cppObj);\n        return this;\n    }\n\n    private static native void configBetweenUnboundedPreceding(long self);\n\n    @NotNull\n    public FrameSpec betweenPreceding(long offset) {\n        configBetweenPreceding(cppObj, CPPType.Int, offset);\n        return this;\n    }\n\n    @NotNull\n    public FrameSpec betweenPreceding(@Nullable ExpressionConvertible offset) {\n        configBetweenPreceding(cppObj, Identifier.getCppType(offset), CppObject.get(offset));\n        return this;\n    }\n\n    private static native void configBetweenPreceding(long self, int type, long expression);\n\n    @NotNull\n    public FrameSpec betweenCurrentRow() {\n        configBetweenCurrentRow(cppObj);\n        return this;\n    }\n\n    private static native void configBetweenCurrentRow(long self);\n\n    @NotNull\n    public FrameSpec betweenFollowing(long offset) {\n        configBetweenFollowing(cppObj, CPPType.Int, offset);\n        return this;\n    }\n\n    @NotNull\n    public FrameSpec betweenFollowing(@Nullable ExpressionConvertible offset) {\n        configBetweenFollowing(cppObj, Identifier.getCppType(offset), CppObject.get(offset));\n        return this;\n    }\n\n    private static native void configBetweenFollowing(long self, int type, long expression);\n\n    @NotNull\n    public FrameSpec andCurrentRow() {\n        configAndCurrentRow(cppObj);\n        return this;\n    }\n\n    private static native void configAndCurrentRow(long self);\n\n    @NotNull\n    public FrameSpec andPreceding(long offset) {\n        configAndPreceding(cppObj, CPPType.Int, offset);\n        return this;\n    }\n\n    @NotNull\n    public FrameSpec andPreceding(@Nullable ExpressionConvertible offset) {\n        configAndPreceding(cppObj, Identifier.getCppType(offset), CppObject.get(offset));\n        return this;\n    }\n\n    private static native void configAndPreceding(long self, int type, long expression);\n\n    @NotNull\n    public FrameSpec andUnboundedFollowing() {\n        configAndUnboundedFollowing(cppObj);\n        return this;\n    }\n\n    private static native void configAndUnboundedFollowing(long self);\n\n    @NotNull\n    public FrameSpec andFollowing(long offset) {\n        configAndFollowing(cppObj, CPPType.Int, offset);\n        return this;\n    }\n\n    @NotNull\n    public FrameSpec andFollowing(@Nullable ExpressionConvertible offset) {\n        configAndFollowing(cppObj, Identifier.getCppType(offset), CppObject.get(offset));\n        return this;\n    }\n\n    private static native void configAndFollowing(long self, int type, long expression);\n}\n"
  },
  {
    "path": "src/java/main/src/main/java/com/tencent/wcdb/winq/Identifier.java",
    "content": "// Created by qiuwenchen on 2023/3/30.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage com.tencent.wcdb.winq;\n\nimport com.tencent.wcdb.base.CppObject;\n\nimport org.jetbrains.annotations.NotNull;\n\nclass CPPType {\n    final static int Invalid = 0;\n    final static int Null = 1;\n    final static int Bool = 2;\n    final static int Int = 3;\n    final static int UInt = 4;\n    final static int Double = 5;\n    final static int String = 6;\n\n\n    final static int Column = 7;\n    final static int Schema = 8;\n    final static int ColumnDef = 9;\n    final static int ColumnConstraint = 10;\n    final static int Expression = 11;\n    final static int LiteralValue = 12;\n    final static int ForeignKeyClause = 13;\n    final static int BindParameter = 14;\n    final static int RaiseFunction = 15;\n    final static int WindowDef = 16;\n    final static int Filter = 17;\n    final static int IndexedColumn = 18;\n    final static int TableConstraint = 19;\n    final static int CommonTableExpression = 20;\n    final static int QualifiedTableName = 21;\n    final static int OrderingTerm = 22;\n    final static int UpsertClause = 23;\n    final static int Pragma = 24;\n    final static int JoinClause = 25;\n    final static int TableOrSubquery = 26;\n    final static int JoinConstraint = 27;\n    final static int SelectCore = 28;\n    final static int ResultColumn = 29;\n    final static int FrameSpec = 30;\n\n\n    final static int AlterTableSTMT = 31;\n    final static int AnalyzeSTMT = 32;\n    final static int AttachSTMT = 33;\n    final static int BeginSTMT = 34;\n    final static int CommitSTMT = 35;\n    final static int RollbackSTMT = 36;\n    final static int SavepointSTMT = 37;\n    final static int ReleaseSTMT = 38;\n    final static int CreateIndexSTMT = 39;\n    final static int CreateTableSTMT = 40;\n    final static int CreateTriggerSTMT = 41;\n    final static int SelectSTMT = 42;\n    final static int InsertSTMT = 43;\n    final static int DeleteSTMT = 44;\n    final static int UpdateSTMT = 45;\n    final static int CreateViewSTMT = 46;\n    final static int CreateVirtualTableSTMT = 47;\n    final static int DetachSTMT = 48;\n    final static int DropIndexSTMT = 49;\n    final static int DropTableSTMT = 50;\n    final static int DropTriggerSTMT = 51;\n    final static int DropViewSTMT = 52;\n    final static int PragmaSTMT = 53;\n    final static int ReindexSTMT = 54;\n    final static int VacuumSTMT = 55;\n    final static int ExplainSTMT = 56;\n}\n\npublic class Identifier extends CppObject implements IdentifierConvertible {\n    protected int getType() {\n        return CPPType.Invalid;\n    }\n\n    protected static int getCppType(Identifier identifier) {\n        if (identifier == null) {\n            return CPPType.Null;\n        }\n        return identifier.getType();\n    }\n\n    protected static int getCppType(IdentifierConvertible identifier) {\n        if (identifier == null) {\n            return CPPType.Null;\n        }\n        return identifier.asIdentifier().getType();\n    }\n\n    @NotNull\n    public Identifier asIdentifier() {\n        return this;\n    }\n\n    @NotNull\n    public String getDescription() {\n        return getDescription(cppObj);\n    }\n\n    @Override\n    @NotNull\n    public String toString() {\n        return getDescription();\n    }\n\n    static native boolean isWriteStatement(long obj);\n\n    private static native String getDescription(long obj);\n}\n"
  },
  {
    "path": "src/java/main/src/main/java/com/tencent/wcdb/winq/IdentifierConvertible.java",
    "content": "// Created by chenqiuwen on 2023/8/26.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdb.winq;\n\nimport com.tencent.wcdb.base.CppObjectConvertible;\n\nimport org.jetbrains.annotations.NotNull;\n\npublic interface IdentifierConvertible extends CppObjectConvertible {\n    @NotNull\n    Identifier asIdentifier();\n}\n"
  },
  {
    "path": "src/java/main/src/main/java/com/tencent/wcdb/winq/IndexedColumn.java",
    "content": "// Created by qiuwenchen on 2023/4/7.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdb.winq;\n\nimport com.tencent.wcdb.base.CppObject;\n\nimport org.jetbrains.annotations.NotNull;\n\npublic class IndexedColumn extends Identifier implements IndexedColumnConvertible {\n    @Override\n    protected int getType() {\n        return CPPType.IndexedColumn;\n    }\n\n    public IndexedColumn(@NotNull IndexedColumnConvertible indexedColumnConvertible) {\n        cppObj = createCppObj(Identifier.getCppType(indexedColumnConvertible), CppObject.get(indexedColumnConvertible), null);\n    }\n\n    public IndexedColumn(@NotNull String columnName) {\n        cppObj = createCppObj(CPPType.String, 0, columnName);\n    }\n\n    private static native long createCppObj(int type, long object, String columnName);\n\n    @NotNull\n    public IndexedColumn collate(String collation) {\n        collate(cppObj, collation);\n        return this;\n    }\n\n    private static native void collate(long indexedColumn, String collation);\n\n    @NotNull\n    public IndexedColumn order(Order order) {\n        order(cppObj, order.ordinal() + 1);\n        return this;\n    }\n\n    private static native void order(long indexedColumn, int order);\n}\n"
  },
  {
    "path": "src/java/main/src/main/java/com/tencent/wcdb/winq/IndexedColumnConvertible.java",
    "content": "// Created by qiuwenchen on 2023/4/7.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdb.winq;\n\npublic interface IndexedColumnConvertible extends IdentifierConvertible {\n}\n"
  },
  {
    "path": "src/java/main/src/main/java/com/tencent/wcdb/winq/Join.java",
    "content": "// Created by qiuwenchen on 2023/4/7.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage com.tencent.wcdb.winq;\n\nimport com.tencent.wcdb.base.CppObject;\n\nimport org.jetbrains.annotations.NotNull;\nimport org.jetbrains.annotations.Nullable;\n\npublic class Join extends Identifier implements TableOrSubqueryConvertible {\n    @Override\n    protected int getType() {\n        return CPPType.JoinClause;\n    }\n\n    public Join(@NotNull String tableName) {\n        cppObj = createCppObj(CPPType.String, 0, tableName);\n    }\n\n    public Join(@NotNull TableOrSubqueryConvertible tableOrSubquery) {\n        cppObj = createCppObj(Identifier.getCppType(tableOrSubquery), CppObject.get(tableOrSubquery), null);\n    }\n\n    private static native long createCppObj(int type, long object, String tableName);\n\n\n    @NotNull\n    public Join with(@NotNull String tableName) {\n        configWith(cppObj, CPPType.String, 0, tableName);\n        return this;\n    }\n\n    @NotNull\n    public Join with(@NotNull TableOrSubqueryConvertible tableOrSubquery) {\n        configWith(cppObj, Identifier.getCppType(tableOrSubquery), CppObject.get(tableOrSubquery), null);\n        return this;\n    }\n\n    private static native void configWith(long self, int type, long object, String tableName);\n\n    @NotNull\n    public Join join(@NotNull String tableName) {\n        configJoin(cppObj, CPPType.String, 0, tableName);\n        return this;\n    }\n\n    @NotNull\n    public Join join(@NotNull TableOrSubqueryConvertible tableOrSubquery) {\n        configJoin(cppObj, Identifier.getCppType(tableOrSubquery), CppObject.get(tableOrSubquery), null);\n        return this;\n    }\n\n    private static native void configJoin(long self, int type, long object, String tableName);\n\n    @NotNull\n    public Join leftOuterJoin(@NotNull String tableName) {\n        configWithLeftOuterJoin(cppObj, CPPType.String, 0, tableName);\n        return this;\n    }\n\n    @NotNull\n    public Join leftOuterJoin(@NotNull TableOrSubqueryConvertible tableOrSubquery) {\n        configWithLeftOuterJoin(cppObj, Identifier.getCppType(tableOrSubquery), CppObject.get(tableOrSubquery), null);\n        return this;\n    }\n\n    private static native void configWithLeftOuterJoin(long self, int type, long object, String tableName);\n\n    @NotNull\n    public Join leftJoin(@NotNull String tableName) {\n        configWithLeftJoin(cppObj, CPPType.String, 0, tableName);\n        return this;\n    }\n\n    @NotNull\n    public Join leftJoin(@NotNull TableOrSubqueryConvertible tableOrSubquery) {\n        configWithLeftJoin(cppObj, Identifier.getCppType(tableOrSubquery), CppObject.get(tableOrSubquery), null);\n        return this;\n    }\n\n    private static native void configWithLeftJoin(long self, int type, long object, String tableName);\n\n    @NotNull\n    public Join innerJoin(@NotNull String tableName) {\n        configWithInnerJoin(cppObj, CPPType.String, 0, tableName);\n        return this;\n    }\n\n    @NotNull\n    public Join innerJoin(@NotNull TableOrSubqueryConvertible tableOrSubquery) {\n        configWithInnerJoin(cppObj, Identifier.getCppType(tableOrSubquery), CppObject.get(tableOrSubquery), null);\n        return this;\n    }\n\n    private static native void configWithInnerJoin(long self, int type, long object, String tableName);\n\n    @NotNull\n    public Join crossJoin(@NotNull String tableName) {\n        configWithCrossJoin(cppObj, CPPType.String, 0, tableName);\n        return this;\n    }\n\n    @NotNull\n    public Join crossJoin(@NotNull TableOrSubqueryConvertible tableOrSubquery) {\n        configWithCrossJoin(cppObj, Identifier.getCppType(tableOrSubquery), CppObject.get(tableOrSubquery), null);\n        return this;\n    }\n\n    private static native void configWithCrossJoin(long self, int type, long object, String tableName);\n\n    @NotNull\n    public Join naturalJoin(@NotNull String tableName) {\n        configWithNaturalJoin(cppObj, CPPType.String, 0, tableName);\n        return this;\n    }\n\n    @NotNull\n    public Join naturalJoin(@NotNull TableOrSubqueryConvertible tableOrSubquery) {\n        configWithNaturalJoin(cppObj, Identifier.getCppType(tableOrSubquery), CppObject.get(tableOrSubquery), null);\n        return this;\n    }\n\n    private static native void configWithNaturalJoin(long self, int type, long object, String tableName);\n\n    @NotNull\n    public Join naturalLeftOuterJoin(@NotNull String tableName) {\n        configWithNaturalLeftOuterJoin(cppObj, CPPType.String, 0, tableName);\n        return this;\n    }\n\n    @NotNull\n    public Join naturalLeftOuterJoin(@NotNull TableOrSubqueryConvertible tableOrSubquery) {\n        configWithNaturalLeftOuterJoin(cppObj, Identifier.getCppType(tableOrSubquery), CppObject.get(tableOrSubquery), null);\n        return this;\n    }\n\n    private static native void configWithNaturalLeftOuterJoin(long self, int type, long object, String tableName);\n\n    @NotNull\n    public Join naturalLeftJoin(@NotNull String tableName) {\n        configWithNaturalLeftJoin(cppObj, CPPType.String, 0, tableName);\n        return this;\n    }\n\n    @NotNull\n    public Join naturalLeftJoin(@NotNull TableOrSubqueryConvertible tableOrSubquery) {\n        configWithNaturalLeftJoin(cppObj, Identifier.getCppType(tableOrSubquery), CppObject.get(tableOrSubquery), null);\n        return this;\n    }\n\n    private static native void configWithNaturalLeftJoin(long self, int type, long object, String tableName);\n\n    @NotNull\n    public Join naturalInnerJoin(@NotNull String tableName) {\n        configWithNaturalInnerJoin(cppObj, CPPType.String, 0, tableName);\n        return this;\n    }\n\n    @NotNull\n    public Join naturalInnerJoin(@NotNull TableOrSubqueryConvertible tableOrSubquery) {\n        configWithNaturalInnerJoin(cppObj, Identifier.getCppType(tableOrSubquery), CppObject.get(tableOrSubquery), null);\n        return this;\n    }\n\n    private static native void configWithNaturalInnerJoin(long self, int type, long object, String tableName);\n\n    @NotNull\n    public Join naturalCrossJoin(@NotNull String tableName) {\n        configWithNaturalCrossJoin(cppObj, CPPType.String, 0, tableName);\n        return this;\n    }\n\n    @NotNull\n    public Join naturalCrossJoin(@NotNull TableOrSubqueryConvertible tableOrSubquery) {\n        configWithNaturalCrossJoin(cppObj, Identifier.getCppType(tableOrSubquery), CppObject.get(tableOrSubquery), null);\n        return this;\n    }\n\n    private static native void configWithNaturalCrossJoin(long self, int type, long object, String tableName);\n\n    @NotNull\n    public Join on(@Nullable Expression expression) {\n        configOn(cppObj, CppObject.get(expression));\n        return this;\n    }\n\n    private static native void configOn(long self, long expression);\n\n    @NotNull\n    public Join using(@Nullable String column) {\n        configUsingColumn(cppObj, CPPType.String, null, new String[]{column});\n        return this;\n    }\n\n    @NotNull\n    public Join using(@Nullable Column column) {\n        configUsingColumn(cppObj, Identifier.getCppType(column), new long[]{CppObject.get(column)}, null);\n        return this;\n    }\n\n    @NotNull\n    public Join using(@Nullable String... columns) {\n        configUsingColumn(cppObj, CPPType.String, null, columns);\n        return this;\n    }\n\n    @NotNull\n    public Join using(@Nullable Column... columns) {\n        if (columns == null || columns.length == 0) {\n            return this;\n        }\n        long[] cppColumns = new long[columns.length];\n        for (int i = 0; i < columns.length; i++) {\n            cppColumns[i] = CppObject.get(columns[i]);\n        }\n        configUsingColumn(cppObj, CPPType.Column, cppColumns, null);\n        return this;\n    }\n\n    private static native void configUsingColumn(long self, int type, long[] columns, String[] columnNames);\n}\n"
  },
  {
    "path": "src/java/main/src/main/java/com/tencent/wcdb/winq/LiteralValue.java",
    "content": "// Created by qiuwenchen on 2023/3/30.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdb.winq;\n\nimport org.jetbrains.annotations.NotNull;\nimport org.jetbrains.annotations.Nullable;\n\npublic class LiteralValue extends Identifier implements ExpressionConvertible {\n    @Override\n    protected int getType() {\n        return CPPType.LiteralValue;\n    }\n\n    @NotNull\n    @Override\n    public Identifier asIdentifier() {\n        return this;\n    }\n\n    public LiteralValue(byte value) {\n        cppObj = createCppObj(CPPType.Int, value, 0, null);\n    }\n\n    public LiteralValue(short value) {\n        cppObj = createCppObj(CPPType.Int, value, 0, null);\n    }\n\n    public LiteralValue(int value) {\n        cppObj = createCppObj(CPPType.Int, value, 0, null);\n    }\n\n    public LiteralValue(long value) {\n        cppObj = createCppObj(CPPType.Int, value, 0, null);\n    }\n\n    public LiteralValue(float value) {\n        cppObj = createCppObj(CPPType.Double, 0, value, null);\n    }\n\n    public LiteralValue(double value) {\n        cppObj = createCppObj(CPPType.Double, 0, value, null);\n    }\n\n    public LiteralValue(boolean value) {\n        cppObj = createCppObj(CPPType.Bool, value ? 1 : 0, 0, null);\n    }\n\n    public LiteralValue(@Nullable String value) {\n        if (value == null) {\n            cppObj = createCppObj(CPPType.Null, 0, 0, null);\n        } else {\n            cppObj = createCppObj(CPPType.String, 0, 0, value);\n        }\n    }\n\n    private static native long createCppObj(int type, long intValue, double doubleValue, String stringValue);\n\n    private LiteralValue() {\n    }\n\n    @NotNull\n    public static LiteralValue currentTime() {\n        LiteralValue ret = new LiteralValue();\n        ret.cppObj = createCurrentTime();\n        return ret;\n    }\n\n    private static native long createCurrentTime();\n\n    @NotNull\n    public static LiteralValue currentDate() {\n        LiteralValue ret = new LiteralValue();\n        ret.cppObj = createCurrentDate();\n        return ret;\n    }\n\n    private static native long createCurrentDate();\n\n    @NotNull\n    public static LiteralValue currentTimeStamp() {\n        LiteralValue ret = new LiteralValue();\n        ret.cppObj = createCurrentTimeStamp();\n        return ret;\n    }\n\n    private static native long createCurrentTimeStamp();\n}\n"
  },
  {
    "path": "src/java/main/src/main/java/com/tencent/wcdb/winq/MultiTypeArray.java",
    "content": "// Created by qiuwenchen on 2023/4/14.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdb.winq;\n\nimport com.tencent.wcdb.base.CppObject;\nimport com.tencent.wcdb.base.Value;\n\nimport java.util.Arrays;\n\nclass ObjectType {\n    final static int Null = 0;\n    final static int Bool = 1;\n    final static int Char = 2;\n    final static int Byte = 3;\n    final static int Short = 4;\n    final static int Int = 5;\n    final static int Long = 6;\n    final static int Float = 7;\n    final static int Double = 8;\n    final static int String = 9;\n    final static int Identifier = 10;\n\n    final static int Value = 11;\n    final static int Unknown = 12;\n}\n\nclass MultiTypeArray {\n\n    int[] types;\n    long[] longValues;\n    double[] doubleValues;\n    String[] stringValues;\n\n    MultiTypeArray(Object[] values) {\n        int valueCount = values.length;\n        types = new int[valueCount];\n        longValues = new long[valueCount];\n        doubleValues = new double[valueCount];\n        stringValues = new String[valueCount];\n        int longIndex = 0;\n        int doubleIndex = 0;\n        int stringIndex = 0;\n\n        for (int i = 0; i < valueCount; i++) {\n            Object obj = values[i];\n            int valueType = getObjectType(obj);\n            switch (valueType) {\n                case ObjectType.Null:\n                    types[i] = CPPType.Null;\n                    longIndex++;\n                    break;\n                case ObjectType.Bool:\n                    types[i] = CPPType.Bool;\n                    longValues[longIndex] = (Boolean) obj ? 1 : 0;\n                    longIndex++;\n                    break;\n                case ObjectType.Byte:\n                    types[i] = CPPType.Int;\n                    longValues[longIndex] = (Byte) obj;\n                    longIndex++;\n                    break;\n                case ObjectType.Char:\n                    types[i] = CPPType.Int;\n                    longValues[longIndex] = (Character) obj;\n                    longIndex++;\n                    break;\n                case ObjectType.Short:\n                    types[i] = CPPType.Int;\n                    longValues[longIndex] = (Short) obj;\n                    longIndex++;\n                    break;\n                case ObjectType.Int:\n                    types[i] = CPPType.Int;\n                    longValues[longIndex] = (Integer) obj;\n                    longIndex++;\n                    break;\n                case ObjectType.Long:\n                    types[i] = CPPType.Int;\n                    longValues[longIndex] = (Long) obj;\n                    longIndex++;\n                    break;\n                case ObjectType.Float:\n                    types[i] = CPPType.Double;\n                    doubleValues[doubleIndex] = (Float) obj;\n                    doubleIndex++;\n                    break;\n                case ObjectType.Double:\n                    types[i] = CPPType.Double;\n                    doubleValues[doubleIndex] = (Double) obj;\n                    doubleIndex++;\n                    break;\n                case ObjectType.String:\n                    types[i] = CPPType.String;\n                    stringValues[stringIndex] = (String) obj;\n                    stringIndex++;\n                    break;\n                case ObjectType.Identifier:\n                    Identifier identifier = (Identifier) obj;\n                    types[i] = Identifier.getCppType(identifier);\n                    longValues[longIndex] = CppObject.get(identifier);\n                    longIndex++;\n                    break;\n                case ObjectType.Value:\n                    Value valueObj = (Value) obj;\n                    switch (valueObj.getType()) {\n                        case Null:\n                            types[i] = CPPType.Null;\n                            longIndex++;\n                            break;\n                        case Integer:\n                            types[i] = CPPType.Int;\n                            longValues[longIndex] = valueObj.getLong();\n                            longIndex++;\n                            break;\n                        case Float:\n                            types[i] = CPPType.Double;\n                            doubleValues[doubleIndex] = valueObj.getDouble();\n                            doubleIndex++;\n                            break;\n                        case Text:\n                            types[i] = CPPType.String;\n                            stringValues[stringIndex] = valueObj.getText();\n                            stringIndex++;\n                            break;\n                    }\n                    break;\n            }\n        }\n        if (stringValues.length * 0.75 > stringIndex) {\n            if (stringIndex == 0) {\n                stringValues = null;\n            } else {\n                stringValues = Arrays.copyOf(stringValues, stringIndex);\n            }\n        }\n    }\n\n    protected static int getObjectType(Object obj) {\n        if (obj == null) {\n            return ObjectType.Null;\n        } else if (obj instanceof Identifier) {\n            return ObjectType.Identifier;\n        }\n        Class cls = obj.getClass();\n        if (cls == String.class) {\n            return ObjectType.String;\n        } else if (cls == Integer.class) {\n            return ObjectType.Int;\n        } else if (cls == Float.class) {\n            return ObjectType.Float;\n        } else if (cls == Double.class) {\n            return ObjectType.Double;\n        } else if (cls == Boolean.class) {\n            return ObjectType.Bool;\n        } else if (cls == Short.class) {\n            return ObjectType.Short;\n        } else if (cls == Long.class) {\n            return ObjectType.Long;\n        } else if (cls == Character.class) {\n            return ObjectType.Char;\n        } else if (cls == Byte.class) {\n            return ObjectType.Byte;\n        } else if (cls == Value.class) {\n            return ObjectType.Value;\n        }\n        return ObjectType.Unknown;\n    }\n}\n"
  },
  {
    "path": "src/java/main/src/main/java/com/tencent/wcdb/winq/Order.java",
    "content": "//\n// Created by qiuwenchen on 2023/3/19.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdb.winq;\n\npublic enum Order {\n    Asc, Desc\n}\n"
  },
  {
    "path": "src/java/main/src/main/java/com/tencent/wcdb/winq/OrderingTerm.java",
    "content": "// Created by chenqiuwen on 2023/4/6.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdb.winq;\n\nimport com.tencent.wcdb.base.CppObject;\n\nimport org.jetbrains.annotations.NotNull;\nimport org.jetbrains.annotations.Nullable;\n\npublic class OrderingTerm extends Identifier {\n    @Override\n    protected int getType() {\n        return CPPType.OrderingTerm;\n    }\n\n    public OrderingTerm(@NotNull ExpressionConvertible expression) {\n        cppObj = createCppObj(Identifier.getCppType(expression), CppObject.get(expression));\n    }\n\n    private static native long createCppObj(int type, long expression);\n\n    @NotNull\n    public OrderingTerm collate(@Nullable String collation) {\n        collate(cppObj, collation);\n        return this;\n    }\n\n    private static native void collate(long orderingTerm, String collation);\n\n    @NotNull\n    public OrderingTerm order(Order order) {\n        order(cppObj, order.ordinal() + 1);\n        return this;\n    }\n\n    private static native void order(long orderingTerm, int order);\n\n    @NotNull\n    static public OrderingTerm ascendingRowid() {\n        return Column.rowId().order(Order.Asc);\n    }\n\n    @NotNull\n    static public OrderingTerm descendingRowid() {\n        return Column.rowId().order(Order.Desc);\n    }\n}\n"
  },
  {
    "path": "src/java/main/src/main/java/com/tencent/wcdb/winq/Pragma.java",
    "content": "// Created by chenqiuwen on 2023/4/9.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdb.winq;\n\nimport org.jetbrains.annotations.NotNull;\n\npublic class Pragma extends Identifier {\n    @Override\n    protected int getType() {\n        return CPPType.Pragma;\n    }\n\n    public Pragma(@NotNull String name) {\n        cppObj = createCppObj(name);\n    }\n\n    private static native long createCppObj(String name);\n\n    @NotNull\n    public static final Pragma applicationId = new Pragma(\"application_id\");\n\n    @NotNull\n    public static final Pragma autoVacuum = new Pragma(\"auto_vacuum\");\n\n    @NotNull\n    public static final Pragma automaticIndex = new Pragma(\"automatic_index\");\n\n    @NotNull\n    public static final Pragma busyTimeout = new Pragma(\"busy_timeout\");\n\n    @NotNull\n    public static final Pragma cacheSize = new Pragma(\"cache_size\");\n\n    @NotNull\n    public static final Pragma cacheSpill = new Pragma(\"cache_spill\");\n\n    @NotNull\n    public static final Pragma caseSensitiveLike = new Pragma(\"case_sensitive_like\");\n\n    @NotNull\n    public static final Pragma cellSizeCheck = new Pragma(\"cell_size_check\");\n\n    @NotNull\n    public static final Pragma checkpointFullfsync = new Pragma(\"checkpoint_fullfsync\");\n\n    @NotNull\n    public static final Pragma functionList = new Pragma(\"function_list\");\n\n    @NotNull\n    public static final Pragma cipher = new Pragma(\"cipher\");\n\n    @NotNull\n    public static final Pragma cipherAddRandom = new Pragma(\"cipher_add_random\");\n\n    @NotNull\n    public static final Pragma cipherDefaultKdfIter = new Pragma(\"cipher_default_kdf_iter\");\n\n    @NotNull\n    public static final Pragma cipherDefaultPageSize = new Pragma(\"cipher_default_page_size\");\n\n    @NotNull\n    public static final Pragma cipherDefaultUseHmac = new Pragma(\"cipher_default_use_hmac\");\n\n    @NotNull\n    public static final Pragma cipherMigrate = new Pragma(\"cipher_migrate\");\n\n    @NotNull\n    public static final Pragma cipherProfile = new Pragma(\"cipher_profile\");\n\n    @NotNull\n    public static final Pragma cipherProvider = new Pragma(\"cipher_provider\");\n\n    @NotNull\n    public static final Pragma cipherProviderVersion = new Pragma(\"cipher_provider_version\");\n\n    @NotNull\n    public static final Pragma cipherUseHmac = new Pragma(\"cipher_use_hmac\");\n\n    @NotNull\n    public static final Pragma cipherVersion = new Pragma(\"cipher_version\");\n\n    @NotNull\n    public static final Pragma cipherPageSize = new Pragma(\"cipher_page_size\");\n\n    @NotNull\n    public static final Pragma collationList = new Pragma(\"collation_list\");\n\n    @NotNull\n    public static final Pragma compileOptions = new Pragma(\"compile_options\");\n\n    @NotNull\n    public static final Pragma countChanges = new Pragma(\"count_changes\");\n\n    @NotNull\n    public static final Pragma dataStoreDirectory = new Pragma(\"data_store_directory\");\n\n    @NotNull\n    public static final Pragma dataVersion = new Pragma(\"data_version\");\n\n    @NotNull\n    public static final Pragma databaseList = new Pragma(\"database_list\");\n\n    @NotNull\n    public static final Pragma defaultCacheSize = new Pragma(\"default_cache_size\");\n\n    @NotNull\n    public static final Pragma deferForeignKeys = new Pragma(\"defer_foreign_keys\");\n\n    @NotNull\n    public static final Pragma emptyResultCallbacks = new Pragma(\"empty_result_callbacks\");\n\n    @NotNull\n    public static final Pragma encoding = new Pragma(\"encoding\");\n\n    @NotNull\n    public static final Pragma foreignKeyCheck = new Pragma(\"foreign_key_check\");\n\n    @NotNull\n    public static final Pragma foreignKeyList = new Pragma(\"foreign_key_list\");\n\n    @NotNull\n    public static final Pragma foreignKeys = new Pragma(\"foreign_keys\");\n\n    @NotNull\n    public static final Pragma freelistCount = new Pragma(\"freelist_count\");\n\n    @NotNull\n    public static final Pragma fullColumnNames = new Pragma(\"full_column_names\");\n\n    @NotNull\n    public static final Pragma fullfsync = new Pragma(\"fullfsync\");\n\n    @NotNull\n    public static final Pragma ignoreCheckConstraints = new Pragma(\"ignore_check_constraints\");\n\n    @NotNull\n    public static final Pragma incrementalVacuum = new Pragma(\"incremental_vacuum\");\n\n    @NotNull\n    public static final Pragma indexInfo = new Pragma(\"index_info\");\n\n    @NotNull\n    public static final Pragma indexList = new Pragma(\"index_list\");\n\n    @NotNull\n    public static final Pragma indexXinfo = new Pragma(\"index_xinfo\");\n\n    @NotNull\n    public static final Pragma integrityCheck = new Pragma(\"integrity_check\");\n\n    @NotNull\n    public static final Pragma journalMode = new Pragma(\"journal_mode\");\n\n    @NotNull\n    public static final Pragma journalSizeLimit = new Pragma(\"journal_size_limit\");\n\n    @NotNull\n    public static final Pragma key = new Pragma(\"key\");\n\n    @NotNull\n    public static final Pragma kdfIter = new Pragma(\"kdf_iter\");\n\n    @NotNull\n    public static final Pragma legacyFileFormat = new Pragma(\"legacy_file_format\");\n\n    @NotNull\n    public static final Pragma lockingMode = new Pragma(\"locking_mode\");\n\n    @NotNull\n    public static final Pragma maxPageCount = new Pragma(\"max_page_count\");\n\n    @NotNull\n    public static final Pragma mmapSize = new Pragma(\"mmap_size\");\n\n    @NotNull\n    public static final Pragma moduleList = new Pragma(\"module_list\");\n\n    @NotNull\n    public static final Pragma optimize = new Pragma(\"optimize\");\n\n    @NotNull\n    public static final Pragma pageCount = new Pragma(\"page_count\");\n\n    @NotNull\n    public static final Pragma pageSize = new Pragma(\"page_size\");\n\n    @NotNull\n    public static final Pragma parserTrace = new Pragma(\"parser_trace\");\n\n    @NotNull\n    public static final Pragma pragmaList = new Pragma(\"pragma_list\");\n\n    @NotNull\n    public static final Pragma queryOnly = new Pragma(\"query_only\");\n\n    @NotNull\n    public static final Pragma quickCheck = new Pragma(\"quick_check\");\n\n    @NotNull\n    public static final Pragma readUncommitted = new Pragma(\"read_uncommitted\");\n\n    @NotNull\n    public static final Pragma recursiveTriggers = new Pragma(\"recursive_triggers\");\n\n    @NotNull\n    public static final Pragma rekey = new Pragma(\"rekey\");\n\n    @NotNull\n    public static final Pragma reverseUnorderedSelects = new Pragma(\"reverse_unordered_selects\");\n\n    @NotNull\n    public static final Pragma schemaVersion = new Pragma(\"schema_version\");\n\n    @NotNull\n    public static final Pragma secureDelete = new Pragma(\"secure_delete\");\n\n    @NotNull\n    public static final Pragma shortColumnNames = new Pragma(\"short_column_names\");\n\n    @NotNull\n    public static final Pragma shrinkMemory = new Pragma(\"shrink_memory\");\n\n    @NotNull\n    public static final Pragma softHeapLimit = new Pragma(\"soft_heap_limit\");\n\n    @NotNull\n    public static final Pragma stats = new Pragma(\"stats\");\n\n    @NotNull\n    public static final Pragma synchronous = new Pragma(\"synchronous\");\n\n    @NotNull\n    public static final Pragma tableInfo = new Pragma(\"table_info\");\n\n    @NotNull\n    public static final Pragma tempStore = new Pragma(\"temp_store\");\n\n    @NotNull\n    public static final Pragma tempStoreDirectory = new Pragma(\"temp_store_directory\");\n\n    @NotNull\n    public static final Pragma threads = new Pragma(\"threads\");\n\n    @NotNull\n    public static final Pragma userVersion = new Pragma(\"user_version\");\n\n    @NotNull\n    public static final Pragma vdbeAddoptrace = new Pragma(\"vdbe_addoptrace\");\n\n    @NotNull\n    public static final Pragma vdbeDebug = new Pragma(\"vdbe_debug\");\n\n    @NotNull\n    public static final Pragma vdbeListing = new Pragma(\"vdbe_listing\");\n\n    @NotNull\n    public static final Pragma vdbeTrace = new Pragma(\"vdbe_trace\");\n\n    @NotNull\n    public static final Pragma walAutocheckpoint = new Pragma(\"wal_autocheckpoint\");\n\n    @NotNull\n    public static final Pragma walCheckpoint = new Pragma(\"wal_checkpoint\");\n\n    @NotNull\n    public static final Pragma writableSchema = new Pragma(\"writable_schema\");\n}\n"
  },
  {
    "path": "src/java/main/src/main/java/com/tencent/wcdb/winq/QualifiedTable.java",
    "content": "// Created by chenqiuwen on 2023/4/8.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdb.winq;\n\nimport com.tencent.wcdb.base.CppObject;\n\nimport org.jetbrains.annotations.NotNull;\nimport org.jetbrains.annotations.Nullable;\n\npublic class QualifiedTable extends Identifier {\n    @Override\n    protected int getType() {\n        return CPPType.QualifiedTableName;\n    }\n\n    public QualifiedTable(@NotNull String tableName) {\n        cppObj = createCppObj(tableName);\n    }\n\n    private static native long createCppObj(String tableName);\n\n    @NotNull\n    public QualifiedTable of(@Nullable String schema) {\n        schema(cppObj, CPPType.String, 0, schema);\n        return this;\n    }\n\n    @NotNull\n    public QualifiedTable of(@Nullable Schema schema) {\n        schema(cppObj, Identifier.getCppType(schema), CppObject.get(schema), null);\n        return this;\n    }\n\n    private static native void schema(long self, int type, long object, String schemaName);\n\n    @NotNull\n    public QualifiedTable as(@Nullable String alias) {\n        alias(cppObj, alias);\n        return this;\n    }\n\n    private static native void alias(long self, String alias);\n\n    @NotNull\n    public QualifiedTable indexed(@Nullable String indexName) {\n        indexed(cppObj, indexName);\n        return this;\n    }\n\n    private static native void indexed(long self, String indexName);\n\n    @NotNull\n    public QualifiedTable notIndexed() {\n        notIndexed(cppObj);\n        return this;\n    }\n\n    private static native void notIndexed(long self);\n\n}\n"
  },
  {
    "path": "src/java/main/src/main/java/com/tencent/wcdb/winq/RaiseFunction.java",
    "content": "// Created by qiuwenchen on 2023/6/9.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdb.winq;\n\nimport org.jetbrains.annotations.NotNull;\n\npublic class RaiseFunction extends Identifier implements ExpressionConvertible, ResultColumnConvertible {\n    @Override\n    protected int getType() {\n        return CPPType.RaiseFunction;\n    }\n\n    public RaiseFunction() {\n        cppObj = createCppObj();\n    }\n\n    private static native long createCppObj();\n\n    @NotNull\n    public RaiseFunction ignore() {\n        setAction(cppObj, 0, null);\n        return this;\n    }\n\n    @NotNull\n    public RaiseFunction rollback(@NotNull String errMsg) {\n        setAction(cppObj, 1, errMsg);\n        return this;\n    }\n\n    @NotNull\n    public RaiseFunction abort(@NotNull String errMsg) {\n        setAction(cppObj, 2, errMsg);\n        return this;\n    }\n\n    @NotNull\n    public RaiseFunction fail(@NotNull String errMsg) {\n        setAction(cppObj, 3, errMsg);\n        return this;\n    }\n\n    private static native void setAction(long self, int action, String errMsg);\n}\n"
  },
  {
    "path": "src/java/main/src/main/java/com/tencent/wcdb/winq/ResultColumn.java",
    "content": "// Created by chenqiuwen on 2023/4/8.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdb.winq;\n\nimport com.tencent.wcdb.base.CppObject;\n\nimport org.jetbrains.annotations.NotNull;\n\npublic class ResultColumn extends Identifier implements ResultColumnConvertible {\n    @Override\n    protected int getType() {\n        return CPPType.ResultColumn;\n    }\n\n    protected ResultColumn(long cppObj) {\n        this.cppObj = cppObj;\n    }\n\n    public ResultColumn(@NotNull ResultColumnConvertible resultColumnConvertible) {\n        cppObj = createCppObj(Identifier.getCppType(resultColumnConvertible), CppObject.get(resultColumnConvertible), null);\n    }\n\n    public ResultColumn(@NotNull String columnName) {\n        cppObj = createCppObj(CPPType.String, 0, columnName);\n    }\n\n    private static native long createCppObj(int type, long convertibleObj, String columnName);\n\n    @NotNull\n    public ResultColumn as(String alias) {\n        configAlias(cppObj, alias);\n        return this;\n    }\n\n    private static native void configAlias(long resultColumn, String alias);\n}\n"
  },
  {
    "path": "src/java/main/src/main/java/com/tencent/wcdb/winq/ResultColumnConvertible.java",
    "content": "// Created by chenqiuwen on 2023/4/8.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdb.winq;\n\npublic interface ResultColumnConvertible extends IdentifierConvertible {\n}\n"
  },
  {
    "path": "src/java/main/src/main/java/com/tencent/wcdb/winq/Schema.java",
    "content": "// Created by qiuwenchen on 2023/3/31.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdb.winq;\n\nimport org.jetbrains.annotations.NotNull;\n\npublic class Schema extends Identifier {\n    @Override\n    protected int getType() {\n        return CPPType.Schema;\n    }\n\n    public Schema(@NotNull String name) {\n        cppObj = createCppObj(name);\n    }\n\n    protected Schema(long cppObj) {\n        this.cppObj = cppObj;\n    }\n\n    private static native long createCppObj(String name);\n\n    @NotNull\n    public static final Schema main = new Schema(createMainCppObj());\n\n    private static native long createMainCppObj();\n\n    @NotNull\n    public static final Schema temp = new Schema(createTempCppObj());\n\n    private static native long createTempCppObj();\n}\n"
  },
  {
    "path": "src/java/main/src/main/java/com/tencent/wcdb/winq/Statement.java",
    "content": "//\n// Created by chenqiuwen on 2023/4/1.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdb.winq;\n\npublic class Statement extends Identifier {\n    public boolean isWriteStatement() {\n        return isWriteStatement(cppObj);\n    }\n}\n"
  },
  {
    "path": "src/java/main/src/main/java/com/tencent/wcdb/winq/StatementAlterTable.java",
    "content": "// Created by chenqiuwen on 2023/6/11.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdb.winq;\n\nimport com.tencent.wcdb.base.CppObject;\n\nimport org.jetbrains.annotations.NotNull;\nimport org.jetbrains.annotations.Nullable;\n\npublic class StatementAlterTable extends Statement {\n    @Override\n    protected int getType() {\n        return CPPType.AlterTableSTMT;\n    }\n\n    public StatementAlterTable() {\n        cppObj = createCppObj();\n    }\n\n    private static native long createCppObj();\n\n    @NotNull\n    public StatementAlterTable alterTable(@NotNull String tableName) {\n        configTable(cppObj, tableName);\n        return this;\n    }\n\n    private static native void configTable(long self, String tableName);\n\n    @NotNull\n    public StatementAlterTable of(@Nullable String schemaName) {\n        configSchema(cppObj, CPPType.String, 0, schemaName);\n        return this;\n    }\n\n    @NotNull\n    public StatementAlterTable of(@Nullable Schema schema) {\n        configSchema(cppObj, Identifier.getCppType(schema), CppObject.get(schema), null);\n        return this;\n    }\n\n    private static native void configSchema(long self, int type, long object, String schemaName);\n\n    @NotNull\n    public StatementAlterTable renameTo(@NotNull String tableName) {\n        configRenameToTable(cppObj, tableName);\n        return this;\n    }\n\n    private static native void configRenameToTable(long self, String tableName);\n\n    @NotNull\n    public StatementAlterTable renameColumn(@NotNull String columnName) {\n        configRenameColumn(cppObj, CPPType.String, 0, columnName);\n        return this;\n    }\n\n    @NotNull\n    public StatementAlterTable renameColumn(@NotNull Column column) {\n        configRenameColumn(cppObj, Identifier.getCppType(column), CppObject.get(column), null);\n        return this;\n    }\n\n    private static native void configRenameColumn(long self, int type, long object, String schemaName);\n\n    @NotNull\n    public StatementAlterTable toColumn(@NotNull String columnName) {\n        configRenameToColumn(cppObj, CPPType.String, 0, columnName);\n        return this;\n    }\n\n    @NotNull\n    public StatementAlterTable toColumn(@NotNull Column column) {\n        configRenameToColumn(cppObj, Identifier.getCppType(column), CppObject.get(column), null);\n        return this;\n    }\n\n    private static native void configRenameToColumn(long self, int type, long object, String schemaName);\n\n    @NotNull\n    public StatementAlterTable addColumn(@NotNull ColumnDef columnDef) {\n        configAddColumn(cppObj, CppObject.get(columnDef));\n        return this;\n    }\n\n    private static native void configAddColumn(long self, long columnDef);\n\n}\n"
  },
  {
    "path": "src/java/main/src/main/java/com/tencent/wcdb/winq/StatementAnalyze.java",
    "content": "// Created by chenqiuwen on 2023/6/11.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdb.winq;\n\nimport com.tencent.wcdb.base.CppObject;\n\nimport org.jetbrains.annotations.NotNull;\n\npublic class StatementAnalyze extends Statement {\n    @Override\n    protected int getType() {\n        return CPPType.AnalyzeSTMT;\n    }\n\n    public StatementAnalyze() {\n        cppObj = createCppObj();\n    }\n\n    private static native long createCppObj();\n\n    @NotNull\n    public StatementAnalyze analyze() {\n        configToAnalyze(cppObj);\n        return this;\n    }\n\n    private static native void configToAnalyze(long self);\n\n    @NotNull\n    public StatementAnalyze schema(@NotNull String schemaName) {\n        configSchema(cppObj, CPPType.String, 0, schemaName);\n        return this;\n    }\n\n    @NotNull\n    public StatementAnalyze schema(@NotNull Schema schema) {\n        configSchema(cppObj, Identifier.getCppType(schema), CppObject.get(schema), null);\n        return this;\n    }\n\n    private static native void configSchema(long self, int type, long object, String schemaName);\n\n    @NotNull\n    public StatementAnalyze table(@NotNull String tableName) {\n        configTable(cppObj, tableName);\n        return this;\n    }\n\n    private static native void configTable(long self, String tableName);\n\n    @NotNull\n    public StatementAnalyze index(@NotNull String indexName) {\n        configIndex(cppObj, indexName);\n        return this;\n    }\n\n    private static native void configIndex(long self, String indexName);\n}\n"
  },
  {
    "path": "src/java/main/src/main/java/com/tencent/wcdb/winq/StatementAttach.java",
    "content": "// Created by chenqiuwen on 2023/6/11.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdb.winq;\n\nimport com.tencent.wcdb.base.CppObject;\n\nimport org.jetbrains.annotations.NotNull;\nimport org.jetbrains.annotations.Nullable;\n\npublic class StatementAttach extends Statement {\n    @Override\n    protected int getType() {\n        return CPPType.AttachSTMT;\n    }\n\n    public StatementAttach() {\n        cppObj = createCppObj();\n    }\n\n    private static native long createCppObj();\n\n    @NotNull\n    public StatementAttach attach(@NotNull String path) {\n        configPath(cppObj, CPPType.String, 0, path);\n        return this;\n    }\n\n    @NotNull\n    public StatementAttach attach(@NotNull BindParameter bindParameter) {\n        configPath(cppObj, Identifier.getCppType(bindParameter), CppObject.get(bindParameter), null);\n        return this;\n    }\n\n    private static native void configPath(long self, int type, long object, String path);\n\n    @NotNull\n    public StatementAttach as(@NotNull String schemaName) {\n        configSchema(cppObj, CPPType.String, 0, schemaName);\n        return this;\n    }\n\n    @NotNull\n    public StatementAttach as(@NotNull Schema schema) {\n        configSchema(cppObj, Identifier.getCppType(schema), CppObject.get(schema), null);\n        return this;\n    }\n\n    private static native void configSchema(long self, int type, long object, String path);\n\n    @NotNull\n    public StatementAttach key(@Nullable String key) {\n        configKey(cppObj, CPPType.String, 0, key);\n        return this;\n    }\n\n    @NotNull\n    public StatementAttach key(@Nullable BindParameter bindParameter) {\n        configKey(cppObj, Identifier.getCppType(bindParameter), CppObject.get(bindParameter), null);\n        return this;\n    }\n\n    private static native void configKey(long self, int type, long object, String path);\n}\n"
  },
  {
    "path": "src/java/main/src/main/java/com/tencent/wcdb/winq/StatementBegin.java",
    "content": "// Created by chenqiuwen on 2023/4/9.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdb.winq;\n\nimport org.jetbrains.annotations.NotNull;\n\npublic class StatementBegin extends Statement {\n    static class TransactionType {\n        final static int Deferred = 0;\n        final static int Immediate = 1;\n        final static int Exclusive = 2;\n    }\n\n    public StatementBegin() {\n        cppObj = createCppObj(TransactionType.Deferred);\n    }\n\n    StatementBegin(int type) {\n        cppObj = createCppObj(type);\n    }\n\n    @Override\n    protected int getType() {\n        return CPPType.CommitSTMT;\n    }\n\n    @NotNull\n    public static StatementBegin beginDeferred() {\n        return new StatementBegin(TransactionType.Deferred);\n    }\n\n    @NotNull\n    public static StatementBegin beginImmediate() {\n        return new StatementBegin(TransactionType.Immediate);\n    }\n\n    @NotNull\n    public static StatementBegin beginExclusive() {\n        return new StatementBegin(TransactionType.Exclusive);\n    }\n\n    private static native long createCppObj(int type);\n}\n"
  },
  {
    "path": "src/java/main/src/main/java/com/tencent/wcdb/winq/StatementCommit.java",
    "content": "//\n// Created by chenqiuwen on 2023/4/9.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdb.winq;\n\npublic class StatementCommit extends Statement {\n    @Override\n    protected int getType() {\n        return CPPType.CommitSTMT;\n    }\n\n    public StatementCommit() {\n        cppObj = createCppObj();\n    }\n\n    private static native long createCppObj();\n}\n"
  },
  {
    "path": "src/java/main/src/main/java/com/tencent/wcdb/winq/StatementCreateIndex.java",
    "content": "// Created by chenqiuwen on 2023/4/10.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdb.winq;\n\nimport com.tencent.wcdb.base.CppObject;\n\nimport org.jetbrains.annotations.NotNull;\nimport org.jetbrains.annotations.Nullable;\n\npublic class StatementCreateIndex extends Statement {\n    @Override\n    protected int getType() {\n        return CPPType.CreateIndexSTMT;\n    }\n\n    public StatementCreateIndex() {\n        cppObj = createCppObj();\n    }\n\n    private static native long createCppObj();\n\n    @NotNull\n    public StatementCreateIndex createIndex(@NotNull String indexName) {\n        createIndex(cppObj, indexName);\n        return this;\n    }\n\n    private static native void createIndex(long self, String indexName);\n\n    @NotNull\n    public StatementCreateIndex unique() {\n        configUnique(cppObj);\n        return this;\n    }\n\n    private static native void configUnique(long self);\n\n    @NotNull\n    public StatementCreateIndex ifNotExist() {\n        configIfNotExist(cppObj);\n        return this;\n    }\n\n    private static native void configIfNotExist(long self);\n\n    @NotNull\n    public StatementCreateIndex of(@Nullable String schemaName) {\n        configSchema(cppObj, CPPType.String, 0, schemaName);\n        return this;\n    }\n\n    @NotNull\n    public StatementCreateIndex of(@Nullable Schema schema) {\n        configSchema(cppObj, Identifier.getCppType(schema), CppObject.get(schema), null);\n        return this;\n    }\n\n    private static native void configSchema(long self, int type, long schema, String schemaName);\n\n    @NotNull\n    public StatementCreateIndex on(@NotNull String tableName) {\n        configTableName(cppObj, tableName);\n        return this;\n    }\n\n    private static native void configTableName(long self, String tableName);\n\n    @NotNull\n    public StatementCreateIndex indexedBy(@NotNull IndexedColumnConvertible... indexedColumnConvertible) {\n        if (indexedColumnConvertible.length == 0) {\n            return this;\n        }\n        long[] columns = new long[indexedColumnConvertible.length];\n        for (int i = 0; i < indexedColumnConvertible.length; i++) {\n            columns[i] = CppObject.get(indexedColumnConvertible[i]);\n        }\n        configIndexedColumns(\n                cppObj,\n                Identifier.getCppType(indexedColumnConvertible[0]),\n                columns, null);\n        return this;\n    }\n\n    @NotNull\n    public StatementCreateIndex indexedBy(@NotNull String... indexedColumnNames) {\n        configIndexedColumns(cppObj, CPPType.String, null, indexedColumnNames);\n        return this;\n    }\n\n    private static native void configIndexedColumns(long self, int type, long[] columns, String[] columnNames);\n\n    @NotNull\n    public StatementCreateIndex where(@Nullable Expression condition) {\n        configCondition(cppObj, CppObject.get(condition));\n        return this;\n    }\n\n    private static native void configCondition(long self, long condition);\n}\n"
  },
  {
    "path": "src/java/main/src/main/java/com/tencent/wcdb/winq/StatementCreateTable.java",
    "content": "// Created by qiuwenchen on 2023/4/11.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdb.winq;\n\nimport com.tencent.wcdb.base.CppObject;\n\nimport org.jetbrains.annotations.NotNull;\nimport org.jetbrains.annotations.Nullable;\n\npublic class StatementCreateTable extends Statement {\n    @Override\n    protected int getType() {\n        return CPPType.CreateTableSTMT;\n    }\n\n    public StatementCreateTable() {\n        cppObj = createCppObj();\n    }\n\n    private static native long createCppObj();\n\n    @NotNull\n    public StatementCreateTable createTable(@NotNull String tableName) {\n        configTableName(cppObj, tableName);\n        return this;\n    }\n\n    @NotNull\n    public StatementCreateTable createTempTable(@NotNull String tableName) {\n        configTableName(cppObj, tableName);\n        configTemp(cppObj);\n        return this;\n    }\n\n    private static native void configTableName(long self, String tableName);\n\n    private static native void configTemp(long self);\n\n    @NotNull\n    public StatementCreateTable ifNotExist() {\n        configIfNotExist(cppObj);\n        return this;\n    }\n\n    private static native void configIfNotExist(long self);\n\n    @NotNull\n    public StatementCreateTable of(@Nullable String schemaName) {\n        configSchema(cppObj, CPPType.String, 0, schemaName);\n        return this;\n    }\n\n    @NotNull\n    public StatementCreateTable of(@Nullable Schema schema) {\n        configSchema(cppObj, Identifier.getCppType(schema), CppObject.get(schema), null);\n        return this;\n    }\n\n    private static native void configSchema(long self, int type, long schema, String schemaName);\n\n    @NotNull\n    public StatementCreateTable as(@NotNull StatementSelect select) {\n        configAs(cppObj, CppObject.get(select));\n        return this;\n    }\n\n    private static native void configAs(long self, long select);\n\n    @NotNull\n    public StatementCreateTable define(@NotNull ColumnDef column) {\n        configColumn(cppObj, CppObject.get(column));\n        return this;\n    }\n\n    private static native void configColumn(long self, long column);\n\n    @NotNull\n    public StatementCreateTable define(@NotNull ColumnDef... columns) {\n        if (columns.length == 0) {\n            return this;\n        }\n        long[] cppColumns = new long[columns.length];\n        for (int i = 0; i < columns.length; i++) {\n            cppColumns[i] = CppObject.get(columns[i]);\n        }\n        configColumns(cppObj, cppColumns);\n        return this;\n    }\n\n    private static native void configColumns(long self, long[] columns);\n\n    @NotNull\n    public StatementCreateTable constraint(@Nullable TableConstraint... constraints) {\n        if (constraints == null || constraints.length == 0) {\n            return this;\n        }\n        long[] cppConstraints = new long[constraints.length];\n        for (int i = 0; i < constraints.length; i++) {\n            cppConstraints[i] = CppObject.get(constraints[i]);\n        }\n        configConstraints(cppObj, cppConstraints);\n        return this;\n    }\n\n    @NotNull\n    public StatementCreateTable constraint(@Nullable TableConstraint constraint) {\n        configConstraints(cppObj, new long[]{CppObject.get(constraint)});\n        return this;\n    }\n\n    private static native void configConstraints(long self, long[] constraints);\n\n    @NotNull\n    public StatementCreateTable withoutRowid() {\n        configWithoutRowid(cppObj);\n        return this;\n    }\n\n    private static native void configWithoutRowid(long self);\n}\n"
  },
  {
    "path": "src/java/main/src/main/java/com/tencent/wcdb/winq/StatementCreateTrigger.java",
    "content": "// Created by chenqiuwen on 2023/6/11.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdb.winq;\n\nimport com.tencent.wcdb.base.CppObject;\n\nimport org.jetbrains.annotations.NotNull;\nimport org.jetbrains.annotations.Nullable;\n\npublic class StatementCreateTrigger extends Statement {\n    @Override\n    protected int getType() {\n        return CPPType.CreateTriggerSTMT;\n    }\n\n    public StatementCreateTrigger() {\n        cppObj = createCppObj();\n    }\n\n    private static native long createCppObj();\n\n    @NotNull\n    public StatementCreateTrigger createTrigger(@NotNull String name) {\n        configTrigger(cppObj, name);\n        return this;\n    }\n\n    @NotNull\n    public StatementCreateTrigger createTempTrigger(@NotNull String name) {\n        configTrigger(cppObj, name);\n        configTemp(cppObj);\n        return this;\n    }\n\n    private static native void configTrigger(long self, String name);\n\n    private static native void configTemp(long self);\n\n    @NotNull\n    public StatementCreateTrigger ofSchema(@Nullable String schemaName) {\n        configSchema(cppObj, CPPType.String, 0, schemaName);\n        return this;\n    }\n\n    @NotNull\n    public StatementCreateTrigger ofSchema(@Nullable Schema schema) {\n        configSchema(cppObj, Identifier.getCppType(schema), CppObject.get(schema), null);\n        return this;\n    }\n\n    private static native void configSchema(long self, int type, long object, String path);\n\n    @NotNull\n    public StatementCreateTrigger ifNotExist() {\n        configIfNotExist(cppObj);\n        return this;\n    }\n\n    private static native void configIfNotExist(long self);\n\n    @NotNull\n    public StatementCreateTrigger before() {\n        configBefore(cppObj);\n        return this;\n    }\n\n    private static native void configBefore(long self);\n\n    @NotNull\n    public StatementCreateTrigger after() {\n        configAfter(cppObj);\n        return this;\n    }\n\n    private static native void configAfter(long self);\n\n    @NotNull\n    public StatementCreateTrigger insteadOf() {\n        configInsteadOf(cppObj);\n        return this;\n    }\n\n    private static native void configInsteadOf(long self);\n\n    @NotNull\n    public StatementCreateTrigger delete() {\n        configDelete(cppObj);\n        return this;\n    }\n\n    private static native void configDelete(long self);\n\n    @NotNull\n    public StatementCreateTrigger insert() {\n        configInsert(cppObj);\n        return this;\n    }\n\n    private static native void configInsert(long self);\n\n    @NotNull\n    public StatementCreateTrigger update() {\n        configUpdate(cppObj);\n        return this;\n    }\n\n    private static native void configUpdate(long self);\n\n    @NotNull\n    public StatementCreateTrigger ofColumns(@NotNull Column... columns) {\n        if (columns.length == 0) {\n            return this;\n        }\n        long[] cppObjs = new long[columns.length];\n        for (int i = 0; i < columns.length; i++) {\n            cppObjs[i] = CppObject.get(columns[i]);\n        }\n        configColumns(cppObj, CPPType.Column, cppObjs, null);\n        return this;\n    }\n\n    @NotNull\n    public StatementCreateTrigger ofColumns(@NotNull String... columnNames) {\n        if (columnNames.length == 0) {\n            return this;\n        }\n        configColumns(cppObj, CPPType.String, null, columnNames);\n        return this;\n    }\n\n    private static native void configColumns(long self, int type, long[] objects, String[] columnNames);\n\n    @NotNull\n    public StatementCreateTrigger onTable(@NotNull String tableName) {\n        configTable(cppObj, tableName);\n        return this;\n    }\n\n    private static native void configTable(long self, String table);\n\n    @NotNull\n    public StatementCreateTrigger forEachRow() {\n        configForEachRow(cppObj);\n        return this;\n    }\n\n    private static native void configForEachRow(long self);\n\n    @NotNull\n    public StatementCreateTrigger when(@Nullable Expression condition) {\n        configWhen(cppObj, CppObject.get(condition));\n        return this;\n    }\n\n    private static native void configWhen(long self, long condition);\n\n    @NotNull\n    public StatementCreateTrigger execute(@Nullable StatementInsert insert) {\n        executeInsert(cppObj, CppObject.get(insert));\n        return this;\n    }\n\n    private static native void executeInsert(long self, long insert);\n\n    @NotNull\n    public StatementCreateTrigger execute(@Nullable StatementUpdate update) {\n        executeUpdate(cppObj, CppObject.get(update));\n        return this;\n    }\n\n    private static native void executeUpdate(long self, long insert);\n\n    @NotNull\n    public StatementCreateTrigger execute(@Nullable StatementDelete delete) {\n        executeDelete(cppObj, CppObject.get(delete));\n        return this;\n    }\n\n    private static native void executeDelete(long self, long insert);\n\n    @NotNull\n    public StatementCreateTrigger execute(@Nullable StatementSelect select) {\n        executeSelect(cppObj, CppObject.get(select));\n        return this;\n    }\n\n    private static native void executeSelect(long self, long insert);\n}\n"
  },
  {
    "path": "src/java/main/src/main/java/com/tencent/wcdb/winq/StatementCreateView.java",
    "content": "// Created by chenqiuwen on 2023/6/11.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdb.winq;\n\nimport com.tencent.wcdb.base.CppObject;\n\nimport org.jetbrains.annotations.NotNull;\nimport org.jetbrains.annotations.Nullable;\n\npublic class StatementCreateView extends Statement {\n    @Override\n    protected int getType() {\n        return CPPType.CreateViewSTMT;\n    }\n\n    public StatementCreateView() {\n        cppObj = createCppObj();\n    }\n\n    private static native long createCppObj();\n\n    @NotNull\n    public StatementCreateView createView(@NotNull String name) {\n        configView(cppObj, name);\n        return this;\n    }\n\n    @NotNull\n    public StatementCreateView createTempView(@NotNull String name) {\n        configView(cppObj, name);\n        configTemp(cppObj);\n        return this;\n    }\n\n    private static native void configView(long self, String name);\n\n    private static native void configTemp(long self);\n\n    @NotNull\n    public StatementCreateView of(@Nullable String schemaName) {\n        configSchema(cppObj, CPPType.String, 0, schemaName);\n        return this;\n    }\n\n    @NotNull\n    public StatementCreateView of(@Nullable Schema schema) {\n        configSchema(cppObj, Identifier.getCppType(schema), CppObject.get(schema), null);\n        return this;\n    }\n\n    private static native void configSchema(long self, int type, long object, String path);\n\n    @NotNull\n    public StatementCreateView ifNotExist() {\n        configIfNotExist(cppObj);\n        return this;\n    }\n\n    private static native void configIfNotExist(long self);\n\n    @NotNull\n    public StatementCreateView withColumns(@NotNull Column... columns) {\n        if (columns.length == 0) {\n            return this;\n        }\n        long[] cppObjs = new long[columns.length];\n        for (int i = 0; i < columns.length; i++) {\n            cppObjs[i] = CppObject.get(columns[i]);\n        }\n        configColumns(cppObj, CPPType.Column, cppObjs, null);\n        return this;\n    }\n\n    @NotNull\n    public StatementCreateView withColumns(@NotNull String... columnNames) {\n        if (columnNames.length == 0) {\n            return this;\n        }\n        configColumns(cppObj, CPPType.String, null, columnNames);\n        return this;\n    }\n\n    private static native void configColumns(long self, int type, long[] objects, String[] columnNames);\n\n    @NotNull\n    public StatementCreateView as(@NotNull StatementSelect select) {\n        configAs(cppObj, CppObject.get(select));\n        return this;\n    }\n\n    private static native void configAs(long self, long select);\n}\n"
  },
  {
    "path": "src/java/main/src/main/java/com/tencent/wcdb/winq/StatementCreateVirtualTable.java",
    "content": "// Created by chenqiuwen on 2023/11/4.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdb.winq;\n\nimport com.tencent.wcdb.base.CppObject;\n\nimport org.jetbrains.annotations.NotNull;\nimport org.jetbrains.annotations.Nullable;\n\npublic class StatementCreateVirtualTable extends Statement {\n    @Override\n    protected int getType() {\n        return CPPType.CreateVirtualTableSTMT;\n    }\n\n    public StatementCreateVirtualTable() {\n        cppObj = createCppObj();\n    }\n\n    private static native long createCppObj();\n\n    @NotNull\n    public StatementCreateVirtualTable createVirtualTable(@NotNull String name) {\n        configTable(cppObj, name);\n        return this;\n    }\n\n    private static native void configTable(long self, String name);\n\n    @NotNull\n    public StatementCreateVirtualTable of(@Nullable String schemaName) {\n        configSchema(cppObj, CPPType.String, 0, schemaName);\n        return this;\n    }\n\n    @NotNull\n    public StatementCreateVirtualTable of(@Nullable Schema schema) {\n        configSchema(cppObj, Identifier.getCppType(schema), CppObject.get(schema), null);\n        return this;\n    }\n\n    private static native void configSchema(long self, int type, long object, String path);\n\n    @NotNull\n    public StatementCreateVirtualTable ifNotExist() {\n        configIfNotExist(cppObj);\n        return this;\n    }\n\n    private static native void configIfNotExist(long self);\n\n    @NotNull\n    public StatementCreateVirtualTable usingModule(@Nullable String module) {\n        configModule(cppObj, module);\n        return this;\n    }\n\n    private static native void configModule(long self, String module);\n\n    @NotNull\n    public StatementCreateVirtualTable arguments(@Nullable String... arguments) {\n        configArguments(cppObj, arguments);\n        return this;\n    }\n\n    private static native void configArguments(long self, String[] argument);\n\n}\n"
  },
  {
    "path": "src/java/main/src/main/java/com/tencent/wcdb/winq/StatementDelete.java",
    "content": "// Created by qiuwenchen on 2023/4/11.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdb.winq;\n\nimport com.tencent.wcdb.base.CppObject;\n\nimport org.jetbrains.annotations.NotNull;\nimport org.jetbrains.annotations.Nullable;\n\npublic class StatementDelete extends Statement {\n    @Override\n    protected int getType() {\n        return CPPType.DeleteSTMT;\n    }\n\n    public StatementDelete() {\n        cppObj = createCppObj();\n    }\n\n    private static native long createCppObj();\n\n    @NotNull\n    public StatementDelete with(CommonTableExpression... expressions) {\n        if (expressions == null || expressions.length == 0) {\n            return this;\n        }\n        long[] cppExps = new long[expressions.length];\n        for (int i = 0; i < expressions.length; i++) {\n            cppExps[i] = CppObject.get(expressions[i]);\n        }\n        configWith(cppObj, cppExps);\n        return this;\n    }\n\n    @NotNull\n    public StatementDelete withRecursive(@Nullable CommonTableExpression... expressions) {\n        if (expressions == null || expressions.length == 0) {\n            return this;\n        }\n        long[] cppExps = new long[expressions.length];\n        for (int i = 0; i < expressions.length; i++) {\n            cppExps[i] = CppObject.get(expressions[i]);\n        }\n        configWith(cppObj, cppExps);\n        configRecursive(cppObj);\n        return this;\n    }\n\n    private static native void configWith(long self, long[] expressions);\n\n    private static native void configRecursive(long self);\n\n    @NotNull\n    public StatementDelete deleteFrom(@NotNull String tableName) {\n        configTable(cppObj, CPPType.String, 0, tableName);\n        return this;\n    }\n\n    @NotNull\n    public StatementDelete deleteFrom(@NotNull QualifiedTable table) {\n        configTable(cppObj, Identifier.getCppType(table), CppObject.get(table), null);\n        return this;\n    }\n\n    private static native void configTable(long self, int type, long table, String tableName);\n\n    @NotNull\n    public StatementDelete where(@Nullable Expression condition) {\n        configCondition(cppObj, CppObject.get(condition));\n        return this;\n    }\n\n    private static native void configCondition(long self, long condition);\n\n    @NotNull\n    public StatementDelete orderBy(@Nullable OrderingTerm... orders) {\n        if (orders == null || orders.length == 0) {\n            return this;\n        }\n        long[] cppOrders = new long[orders.length];\n        for (int i = 0; i < orders.length; i++) {\n            cppOrders[i] = CppObject.get(orders[i]);\n        }\n        configOrders(cppObj, cppOrders);\n        return this;\n    }\n\n    private static native void configOrders(long self, long[] orders);\n\n    @NotNull\n    public StatementDelete limit(long from, long to) {\n        configLimitRange(cppObj, CPPType.Int, from, CPPType.Int, to);\n        return this;\n    }\n\n    @NotNull\n    public StatementDelete limit(long from, @Nullable ExpressionConvertible to) {\n        configLimitRange(cppObj, CPPType.Int, from, Identifier.getCppType(to), CppObject.get(to));\n        return this;\n    }\n\n    @NotNull\n    public StatementDelete limit(@Nullable ExpressionConvertible from, @Nullable ExpressionConvertible to) {\n        configLimitRange(cppObj, Identifier.getCppType(from), CppObject.get(from), Identifier.getCppType(to), CppObject.get(to));\n        return this;\n    }\n\n    @NotNull\n    public StatementDelete limit(@Nullable ExpressionConvertible from, long to) {\n        configLimitRange(cppObj, Identifier.getCppType(from), CppObject.get(from), CPPType.Int, to);\n        return this;\n    }\n\n    private static native void configLimitRange(long self, int fromType, long from, int toType, long to);\n\n    @NotNull\n    public StatementDelete limit(long count) {\n        configLimitCount(cppObj, CPPType.Int, count);\n        return this;\n    }\n\n    @NotNull\n    public StatementDelete limit(@Nullable ExpressionConvertible count) {\n        configLimitCount(cppObj, Identifier.getCppType(count), CppObject.get(count));\n        return this;\n    }\n\n    private static native void configLimitCount(long self, int type, long count);\n\n    @NotNull\n    public StatementDelete offset(long offset) {\n        configOffset(cppObj, CPPType.Int, offset);\n        return this;\n    }\n\n    @NotNull\n    public StatementDelete offset(@Nullable ExpressionConvertible offset) {\n        configOffset(cppObj, Identifier.getCppType(offset), CppObject.get(offset));\n        return this;\n    }\n\n    private static native void configOffset(long self, int type, long count);\n}\n"
  },
  {
    "path": "src/java/main/src/main/java/com/tencent/wcdb/winq/StatementDetach.java",
    "content": "// Created by chenqiuwen on 2023/6/11.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdb.winq;\n\nimport com.tencent.wcdb.base.CppObject;\n\npublic class StatementDetach extends Statement {\n    @Override\n    protected int getType() {\n        return CPPType.DetachSTMT;\n    }\n\n    public StatementDetach() {\n        cppObj = createCppObj();\n    }\n\n    private static native long createCppObj();\n\n    public StatementDetach detach(String schemaName) {\n        configSchema(cppObj, CPPType.String, 0, schemaName);\n        return this;\n    }\n\n    public StatementDetach detach(Schema schema) {\n        configSchema(cppObj, Identifier.getCppType(schema), CppObject.get(schema), null);\n        return this;\n    }\n\n    private static native void configSchema(long self, int type, long object, String path);\n}\n"
  },
  {
    "path": "src/java/main/src/main/java/com/tencent/wcdb/winq/StatementDropIndex.java",
    "content": "// Created by chenqiuwen on 2023/6/11.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdb.winq;\n\nimport com.tencent.wcdb.base.CppObject;\n\nimport org.jetbrains.annotations.NotNull;\nimport org.jetbrains.annotations.Nullable;\n\npublic class StatementDropIndex extends Statement {\n    @Override\n    protected int getType() {\n        return CPPType.DropIndexSTMT;\n    }\n\n    public StatementDropIndex() {\n        cppObj = createCppObj();\n    }\n\n    private static native long createCppObj();\n\n    @NotNull\n    public StatementDropIndex dropIndex(@NotNull String indexName) {\n        configIndex(cppObj, indexName);\n        return this;\n    }\n\n    private static native void configIndex(long self, String indexName);\n\n    @NotNull\n    public StatementDropIndex of(@Nullable String schemaName) {\n        configSchema(cppObj, CPPType.String, 0, schemaName);\n        return this;\n    }\n\n    @NotNull\n    public StatementDropIndex of(@Nullable Schema schema) {\n        configSchema(cppObj, Identifier.getCppType(schema), CppObject.get(schema), null);\n        return this;\n    }\n\n    private static native void configSchema(long self, int type, long object, String path);\n\n    @NotNull\n    public StatementDropIndex ifExist() {\n        configIfExist(cppObj);\n        return this;\n    }\n\n    private static native void configIfExist(long self);\n}\n"
  },
  {
    "path": "src/java/main/src/main/java/com/tencent/wcdb/winq/StatementDropTable.java",
    "content": "// Created by qiuwenchen on 2023/4/12.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdb.winq;\n\nimport com.tencent.wcdb.base.CppObject;\n\nimport org.jetbrains.annotations.NotNull;\n\npublic class StatementDropTable extends Statement {\n    @Override\n    protected int getType() {\n        return CPPType.DropTableSTMT;\n    }\n\n    public StatementDropTable() {\n        cppObj = createCppObj();\n    }\n\n    private static native long createCppObj();\n\n    @NotNull\n    public StatementDropTable dropTable(@NotNull String tableName) {\n        configTableName(cppObj, tableName);\n        return this;\n    }\n\n    private static native void configTableName(long self, String tableName);\n\n    @NotNull\n    public StatementDropTable of(@NotNull String schemaName) {\n        configSchema(cppObj, CPPType.String, 0, schemaName);\n        return this;\n    }\n\n    @NotNull\n    public StatementDropTable of(@NotNull Schema schema) {\n        configSchema(cppObj, Identifier.getCppType(schema), CppObject.get(schema), null);\n        return this;\n    }\n\n    private static native void configSchema(long self, int type, long schema, String schemaName);\n\n    @NotNull\n    public StatementDropTable ifExist() {\n        configIfExist(cppObj);\n        return this;\n    }\n\n    private static native void configIfExist(long self);\n\n}\n"
  },
  {
    "path": "src/java/main/src/main/java/com/tencent/wcdb/winq/StatementDropTrigger.java",
    "content": "// Created by chenqiuwen on 2023/6/11.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdb.winq;\n\nimport com.tencent.wcdb.base.CppObject;\n\nimport org.jetbrains.annotations.NotNull;\nimport org.jetbrains.annotations.Nullable;\n\npublic class StatementDropTrigger extends Statement {\n    @Override\n    protected int getType() {\n        return CPPType.DropTriggerSTMT;\n    }\n\n    public StatementDropTrigger() {\n        cppObj = createCppObj();\n    }\n\n    private static native long createCppObj();\n\n    @NotNull\n    public StatementDropTrigger dropTrigger(@NotNull String triggerName) {\n        configTrigger(cppObj, triggerName);\n        return this;\n    }\n\n    private static native void configTrigger(long self, String triggerName);\n\n    @NotNull\n    public StatementDropTrigger of(@Nullable String schemaName) {\n        configSchema(cppObj, CPPType.String, 0, schemaName);\n        return this;\n    }\n\n    @NotNull\n    public StatementDropTrigger of(@Nullable Schema schema) {\n        configSchema(cppObj, Identifier.getCppType(schema), CppObject.get(schema), null);\n        return this;\n    }\n\n    private static native void configSchema(long self, int type, long object, String path);\n\n    @NotNull\n    public StatementDropTrigger ifExist() {\n        configIfExist(cppObj);\n        return this;\n    }\n\n    private static native void configIfExist(long self);\n}\n"
  },
  {
    "path": "src/java/main/src/main/java/com/tencent/wcdb/winq/StatementDropView.java",
    "content": "// Created by chenqiuwen on 2023/6/11.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdb.winq;\n\nimport com.tencent.wcdb.base.CppObject;\n\nimport org.jetbrains.annotations.NotNull;\nimport org.jetbrains.annotations.Nullable;\n\npublic class StatementDropView extends Statement {\n    @Override\n    protected int getType() {\n        return CPPType.DropViewSTMT;\n    }\n\n    public StatementDropView() {\n        cppObj = createCppObj();\n    }\n\n    private static native long createCppObj();\n\n    @NotNull\n    public StatementDropView dropView(@NotNull String viewName) {\n        configView(cppObj, viewName);\n        return this;\n    }\n\n    private static native void configView(long self, String viewName);\n\n    @NotNull\n    public StatementDropView of(@Nullable String schemaName) {\n        configSchema(cppObj, CPPType.String, 0, schemaName);\n        return this;\n    }\n\n    @NotNull\n    public StatementDropView of(@Nullable Schema schema) {\n        configSchema(cppObj, Identifier.getCppType(schema), CppObject.get(schema), null);\n        return this;\n    }\n\n    private static native void configSchema(long self, int type, long object, String path);\n\n    @NotNull\n    public StatementDropView ifExist() {\n        configIfExist(cppObj);\n        return this;\n    }\n\n    private static native void configIfExist(long self);\n}\n"
  },
  {
    "path": "src/java/main/src/main/java/com/tencent/wcdb/winq/StatementExplain.java",
    "content": "// Created by qiuwenchen on 2023/6/12.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdb.winq;\n\nimport com.tencent.wcdb.base.CppObject;\n\nimport org.jetbrains.annotations.NotNull;\n\npublic class StatementExplain extends Statement {\n    @Override\n    protected int getType() {\n        return CPPType.ExplainSTMT;\n    }\n\n    public StatementExplain() {\n        cppObj = createCppObj();\n    }\n\n    private static native long createCppObj();\n\n    @NotNull\n    public StatementExplain explain(@NotNull Statement statement) {\n        explain(cppObj, CppObject.get(statement), false);\n        return this;\n    }\n\n    @NotNull\n    public StatementExplain explainQueryPlan(@NotNull Statement statement) {\n        explain(cppObj, CppObject.get(statement), true);\n        return this;\n    }\n\n    private static native void explain(long self, long statement, boolean queryPlan);\n}\n"
  },
  {
    "path": "src/java/main/src/main/java/com/tencent/wcdb/winq/StatementInsert.java",
    "content": "// Created by qiuwenchen on 2023/4/12.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdb.winq;\n\nimport com.tencent.wcdb.base.CppObject;\n\nimport org.jetbrains.annotations.NotNull;\nimport org.jetbrains.annotations.Nullable;\n\npublic class StatementInsert extends Statement {\n    @Override\n    protected int getType() {\n        return CPPType.InsertSTMT;\n    }\n\n    public StatementInsert() {\n        cppObj = createCppObj();\n    }\n\n    private static native long createCppObj();\n\n    @NotNull\n    public StatementInsert with(@Nullable CommonTableExpression... expressions) {\n        if (expressions == null || expressions.length == 0) {\n            return this;\n        }\n        long[] cppExps = new long[expressions.length];\n        for (int i = 0; i < expressions.length; i++) {\n            cppExps[i] = CppObject.get(expressions[i]);\n        }\n        configWith(cppObj, cppExps);\n        return this;\n    }\n\n    @NotNull\n    public StatementInsert withRecursive(@Nullable CommonTableExpression... expressions) {\n        if (expressions == null || expressions.length == 0) {\n            return this;\n        }\n        long[] cppExps = new long[expressions.length];\n        for (int i = 0; i < expressions.length; i++) {\n            cppExps[i] = CppObject.get(expressions[i]);\n        }\n        configWith(cppObj, cppExps);\n        configRecursive(cppObj);\n        return this;\n    }\n\n    private static native void configWith(long self, long[] expressions);\n\n    private static native void configRecursive(long self);\n\n    @NotNull\n    public StatementInsert insertInto(@NotNull String tableName) {\n        configTableName(cppObj, tableName);\n        return this;\n    }\n\n    private static native void configTableName(long self, String tableName);\n\n    @NotNull\n    public StatementInsert of(@Nullable String schemaName) {\n        configSchema(cppObj, CPPType.String, 0, schemaName);\n        return this;\n    }\n\n    @NotNull\n    public StatementInsert of(@Nullable Schema schema) {\n        configSchema(cppObj, Identifier.getCppType(schema), CppObject.get(schema), null);\n        return this;\n    }\n\n    private static native void configSchema(long self, int type, long schema, String schemaName);\n\n    @NotNull\n    public StatementInsert orReplace() {\n        configConflictAction(cppObj, ConflictAction.Replace.ordinal());\n        return this;\n    }\n\n    @NotNull\n    public StatementInsert orRollback() {\n        configConflictAction(cppObj, ConflictAction.Rollback.ordinal());\n        return this;\n    }\n\n    @NotNull\n    public StatementInsert orAbort() {\n        configConflictAction(cppObj, ConflictAction.Abort.ordinal());\n        return this;\n    }\n\n    @NotNull\n    public StatementInsert orFail() {\n        configConflictAction(cppObj, ConflictAction.Fail.ordinal());\n        return this;\n    }\n\n    @NotNull\n    public StatementInsert orIgnore() {\n        configConflictAction(cppObj, ConflictAction.Ignore.ordinal());\n        return this;\n    }\n\n    private static native void configConflictAction(long self, int action);\n\n    @NotNull\n    public StatementInsert as(@Nullable String alias) {\n        configAlias(cppObj, alias);\n        return this;\n    }\n\n    private static native void configAlias(long self, String alias);\n\n    @NotNull\n    public StatementInsert columns(@NotNull Column... columns) {\n        if (columns.length == 0) {\n            return this;\n        }\n        long[] cppColumns = new long[columns.length];\n        for (int i = 0; i < columns.length; i++) {\n            cppColumns[i] = CppObject.get(columns[i]);\n        }\n        configColumns(cppObj, CPPType.Column, cppColumns, null);\n        return this;\n    }\n\n    @NotNull\n    public StatementInsert columns(@NotNull String... columnNames) {\n        if (columnNames.length == 0) {\n            return this;\n        }\n        configColumns(cppObj, CPPType.String, null, columnNames);\n        return this;\n    }\n\n    private static native void configColumns(long self, int type, long[] columns, String[] columnNames);\n\n    @NotNull\n    public StatementInsert valuesWithBindParameters(int parametersCount) {\n        configValuesWithBindParameters(cppObj, parametersCount);\n        return this;\n    }\n\n    private static native void configValuesWithBindParameters(long self, int parametersCount);\n\n    @NotNull\n    public StatementInsert values(@Nullable Object... values) {\n        if (values == null || values.length == 0) {\n            return this;\n        }\n\n        MultiTypeArray array = new MultiTypeArray(values);\n\n        configValues(cppObj, array.types, array.longValues, array.doubleValues, array.stringValues);\n        return this;\n    }\n\n    private static native void configValues(long self, int[] types, long[] longValues, double[] doubleValues, String[] stringValues);\n\n    @NotNull\n    public StatementInsert values(@NotNull StatementSelect select) {\n        configValues(cppObj, CppObject.get(select));\n        return this;\n    }\n\n    private static native void configValues(long self, long select);\n\n    @NotNull\n    public StatementInsert defaultValues() {\n        configDefaultValues(cppObj);\n        return this;\n    }\n\n    private static native void configDefaultValues(long self);\n\n    @NotNull\n    public StatementInsert upsert(@Nullable Upsert upsert) {\n        configUpsert(cppObj, CppObject.get(upsert));\n        return this;\n    }\n\n    private static native void configUpsert(long self, long upsert);\n}\n"
  },
  {
    "path": "src/java/main/src/main/java/com/tencent/wcdb/winq/StatementPragma.java",
    "content": "// Created by qiuwenchen on 2023/4/13.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdb.winq;\n\nimport com.tencent.wcdb.base.CppObject;\n\nimport org.jetbrains.annotations.NotNull;\nimport org.jetbrains.annotations.Nullable;\n\npublic class StatementPragma extends Statement {\n    @Override\n    protected int getType() {\n        return CPPType.PragmaSTMT;\n    }\n\n    public StatementPragma() {\n        cppObj = createCppObj();\n    }\n\n    private static native long createCppObj();\n\n    @NotNull\n    public StatementPragma pragma(@NotNull Pragma pragma) {\n        configPragma(cppObj, CppObject.get(pragma));\n        return this;\n    }\n\n    private static native void configPragma(long self, long pragma);\n\n    @NotNull\n    public StatementPragma of(@Nullable String schemaName) {\n        configSchema(cppObj, CPPType.String, 0, schemaName);\n        return this;\n    }\n\n    @NotNull\n    public StatementPragma of(@Nullable Schema schema) {\n        configSchema(cppObj, Identifier.getCppType(schema), CppObject.get(schema), null);\n        return this;\n    }\n\n    private static native void configSchema(long self, int type, long schema, String schemaName);\n\n    @NotNull\n    public StatementPragma withValue(boolean value) {\n        configWithValue(cppObj, CPPType.Bool, value ? 1 : 0, 0, null);\n        return this;\n    }\n\n    @NotNull\n    public StatementPragma withValue(byte value) {\n        configWithValue(cppObj, CPPType.Int, value, 0, null);\n        return this;\n    }\n\n    @NotNull\n    public StatementPragma withValue(short value) {\n        configWithValue(cppObj, CPPType.Int, value, 0, null);\n        return this;\n    }\n\n    @NotNull\n    public StatementPragma withValue(int value) {\n        configWithValue(cppObj, CPPType.Int, value, 0, null);\n        return this;\n    }\n\n    @NotNull\n    public StatementPragma withValue(long value) {\n        configWithValue(cppObj, CPPType.Int, value, 0, null);\n        return this;\n    }\n\n    @NotNull\n    public StatementPragma withValue(float value) {\n        configWithValue(cppObj, CPPType.Double, 0, value, null);\n        return this;\n    }\n\n    @NotNull\n    public StatementPragma withValue(double value) {\n        configWithValue(cppObj, CPPType.Double, 0, value, null);\n        return this;\n    }\n\n    @NotNull\n    public StatementPragma withValue(@Nullable String value) {\n        if (value != null) {\n            configWithValue(cppObj, CPPType.String, 0, 0, value);\n        } else {\n            configWithValue(cppObj, CPPType.Null, 0, 0, null);\n        }\n        return this;\n    }\n\n    private static native void configWithValue(long self, int type, long longValue, double doubleValue, String stringValue);\n\n    @NotNull\n    public StatementPragma toValue(boolean value) {\n        configToValue(cppObj, CPPType.Bool, value ? 1 : 0, 0, null);\n        return this;\n    }\n\n    @NotNull\n    public StatementPragma toValue(byte value) {\n        configToValue(cppObj, CPPType.Int, value, 0, null);\n        return this;\n    }\n\n    @NotNull\n    public StatementPragma toValue(short value) {\n        configToValue(cppObj, CPPType.Int, value, 0, null);\n        return this;\n    }\n\n    @NotNull\n    public StatementPragma toValue(int value) {\n        configToValue(cppObj, CPPType.Int, value, 0, null);\n        return this;\n    }\n\n    @NotNull\n    public StatementPragma toValue(long value) {\n        configToValue(cppObj, CPPType.Int, value, 0, null);\n        return this;\n    }\n\n    @NotNull\n    public StatementPragma toValue(float value) {\n        configToValue(cppObj, CPPType.Double, 0, value, null);\n        return this;\n    }\n\n    @NotNull\n    public StatementPragma toValue(double value) {\n        configToValue(cppObj, CPPType.Double, 0, value, null);\n        return this;\n    }\n\n    @NotNull\n    public StatementPragma toValue(@Nullable String value) {\n        if (value != null) {\n            configToValue(cppObj, CPPType.String, 0, 0, value);\n        } else {\n            configToValue(cppObj, CPPType.Null, 0, 0, null);\n        }\n        return this;\n    }\n\n    private static native void configToValue(long self, int type, long longValue, double doubleValue, String stringValue);\n}\n"
  },
  {
    "path": "src/java/main/src/main/java/com/tencent/wcdb/winq/StatementReindex.java",
    "content": "// Created by qiuwenchen on 2023/6/12.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdb.winq;\n\nimport com.tencent.wcdb.base.CppObject;\n\nimport org.jetbrains.annotations.NotNull;\nimport org.jetbrains.annotations.Nullable;\n\npublic class StatementReindex extends Statement {\n    @Override\n    protected int getType() {\n        return CPPType.ReindexSTMT;\n    }\n\n    public StatementReindex() {\n        cppObj = createCppObj();\n    }\n\n    private static native long createCppObj();\n\n    @NotNull\n    public StatementReindex reindexCollation(@Nullable String collation) {\n        configCollation(cppObj, collation);\n        return this;\n    }\n\n    private static native void configCollation(long self, String collation);\n\n    @NotNull\n    public StatementReindex reindexTable(@NotNull String table) {\n        configTable(cppObj, table);\n        return this;\n    }\n\n    private static native void configTable(long self, String table);\n\n    @NotNull\n    public StatementReindex reindex(@NotNull String index) {\n        configIndex(cppObj, index);\n        return this;\n    }\n\n    private static native void configIndex(long self, String indexName);\n\n    @NotNull\n    public StatementReindex of(@Nullable String schemaName) {\n        configSchema(cppObj, CPPType.String, 0, schemaName);\n        return this;\n    }\n\n    @NotNull\n    public StatementReindex of(@Nullable Schema schema) {\n        configSchema(cppObj, Identifier.getCppType(schema), CppObject.get(schema), null);\n        return this;\n    }\n\n    private static native void configSchema(long self, int type, long object, String path);\n}\n"
  },
  {
    "path": "src/java/main/src/main/java/com/tencent/wcdb/winq/StatementRelease.java",
    "content": "// Created by qiuwenchen on 2023/6/12.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdb.winq;\n\nimport org.jetbrains.annotations.NotNull;\n\npublic class StatementRelease extends Statement {\n    @Override\n    protected int getType() {\n        return CPPType.ReleaseSTMT;\n    }\n\n    public StatementRelease() {\n        cppObj = createCppObj();\n    }\n\n    private static native long createCppObj();\n\n    @NotNull\n    public StatementRelease release(@NotNull String savepoint) {\n        configSavepoint(cppObj, savepoint);\n        return this;\n    }\n\n    private static native void configSavepoint(long self, String savepoint);\n}\n"
  },
  {
    "path": "src/java/main/src/main/java/com/tencent/wcdb/winq/StatementRollback.java",
    "content": "// Created by qiuwenchen on 2023/6/12.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdb.winq;\n\nimport org.jetbrains.annotations.NotNull;\n\npublic class StatementRollback extends Statement {\n    @Override\n    protected int getType() {\n        return CPPType.RollbackSTMT;\n    }\n\n    public StatementRollback() {\n        cppObj = createCppObj();\n    }\n\n    private static native long createCppObj();\n\n    @NotNull\n    public StatementRollback rollbackTo(@NotNull String savepoint) {\n        configSavepoint(cppObj, savepoint);\n        return this;\n    }\n\n    private static native void configSavepoint(long self, String savepoint);\n\n}\n"
  },
  {
    "path": "src/java/main/src/main/java/com/tencent/wcdb/winq/StatementSelect.java",
    "content": "// Created by chenqiuwen on 2023/4/1.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdb.winq;\n\nimport com.tencent.wcdb.base.CppObject;\n\nimport org.jetbrains.annotations.NotNull;\nimport org.jetbrains.annotations.Nullable;\n\nimport java.util.Arrays;\n\npublic class StatementSelect extends Statement implements TableOrSubqueryConvertible {\n    @Override\n    protected int getType() {\n        return CPPType.SelectSTMT;\n    }\n\n    public StatementSelect() {\n        cppObj = createCppObj();\n    }\n\n    private static native long createCppObj();\n\n    @NotNull\n    public StatementSelect with(@Nullable CommonTableExpression... expressions) {\n        if (expressions == null || expressions.length == 0) {\n            return this;\n        }\n        long[] cppExps = new long[expressions.length];\n        for (int i = 0; i < expressions.length; i++) {\n            cppExps[i] = CppObject.get(expressions[i]);\n        }\n        configWith(cppObj, cppExps);\n        return this;\n    }\n\n    @NotNull\n    public StatementSelect withRecursive(CommonTableExpression... expressions) {\n        if (expressions == null || expressions.length == 0) {\n            return this;\n        }\n        long[] cppExps = new long[expressions.length];\n        for (int i = 0; i < expressions.length; i++) {\n            cppExps[i] = CppObject.get(expressions[i]);\n        }\n        configWith(cppObj, cppExps);\n        configRecursive(cppObj);\n        return this;\n    }\n\n    private static native void configWith(long self, long[] expressions);\n\n    private static native void configRecursive(long self);\n\n    @NotNull\n    public StatementSelect select(@NotNull ResultColumnConvertible... resultColumns) {\n        if (resultColumns.length == 0) {\n            return this;\n        }\n        int totalCount = resultColumns.length;\n        int[] types = new int[totalCount];\n        long[] cppObjs = new long[totalCount];\n        for (int i = 0; i < totalCount; i++) {\n            types[i] = Identifier.getCppType(resultColumns[i]);\n            cppObjs[i] = CppObject.get(resultColumns[i]);\n        }\n        configResultColumns(cppObj, types, cppObjs, null, null);\n        return this;\n    }\n\n    @NotNull\n    public StatementSelect select(@NotNull String... resultColumns) {\n        if (resultColumns.length == 0) {\n            return this;\n        }\n        int[] types = new int[resultColumns.length];\n        Arrays.fill(types, CPPType.String);\n        configResultColumns(cppObj, types, null, null, resultColumns);\n        return this;\n    }\n\n    @NotNull\n    public StatementSelect select(@NotNull Object... resultColumns) {\n        if (resultColumns.length == 0) {\n            return this;\n        }\n        int totalCount = resultColumns.length;\n        int[] types = new int[totalCount];\n        long[] cppObjs = new long[totalCount];\n        String[] columnNames = new String[totalCount];\n        int intIndex = 0;\n        int stringIndex = 0;\n        for (int i = 0; i < totalCount; i++) {\n            Object obj = resultColumns[i];\n            if (obj instanceof String) {\n                types[i] = CPPType.String;\n                columnNames[stringIndex] = (String) obj;\n                stringIndex++;\n            } else if (obj instanceof ResultColumnConvertible) {\n                ResultColumnConvertible resultColumn = (ResultColumnConvertible) obj;\n                types[i] = Identifier.getCppType(resultColumn);\n                cppObjs[intIndex] = CppObject.get(resultColumn);\n                intIndex++;\n            }\n        }\n        if (columnNames.length * 0.75 > stringIndex) {\n            if (stringIndex == 0) {\n                columnNames = null;\n            } else {\n                columnNames = Arrays.copyOf(columnNames, stringIndex);\n            }\n        }\n        configResultColumns(cppObj, types, cppObjs, null, columnNames);\n        return this;\n    }\n\n    private static native void configResultColumns(long self, int[] types, long[] columns, double[] unused, String[] columnNames);\n\n    @NotNull\n    public StatementSelect distinct() {\n        configDistinct(cppObj);\n        return this;\n    }\n\n    private static native void configDistinct(long self);\n\n    @NotNull\n    public StatementSelect from(@NotNull TableOrSubqueryConvertible... tableOrSubqueries) {\n        if (tableOrSubqueries.length == 0) {\n            return this;\n        }\n        int totalCount = tableOrSubqueries.length;\n        int[] types = new int[totalCount];\n        long[] cppObjs = new long[totalCount];\n        for (int i = 0; i < totalCount; i++) {\n            types[i] = Identifier.getCppType(tableOrSubqueries[i]);\n            cppObjs[i] = CppObject.get(tableOrSubqueries[i]);\n        }\n        configTableOrSubqueries(cppObj, types, cppObjs, null, null);\n        return this;\n    }\n\n    @NotNull\n    public StatementSelect from(@NotNull String... tableNames) {\n        if (tableNames.length == 0) {\n            return this;\n        }\n        int[] types = new int[tableNames.length];\n        Arrays.fill(types, CPPType.String);\n        configTableOrSubqueries(cppObj, types, null, null, tableNames);\n        return this;\n    }\n\n    @NotNull\n    public StatementSelect from(@NotNull Object... tableOrSubqueries) {\n        if (tableOrSubqueries.length == 0) {\n            return this;\n        }\n        int totalCount = tableOrSubqueries.length;\n        int[] types = new int[totalCount];\n        long[] cppObjs = new long[totalCount];\n        String[] tablNames = new String[totalCount];\n        int intIndex = 0;\n        int stringIndex = 0;\n        for (int i = 0; i < totalCount; i++) {\n            Object obj = tableOrSubqueries[i];\n            if (obj instanceof String) {\n                types[i] = CPPType.String;\n                tablNames[stringIndex] = (String) obj;\n                stringIndex++;\n            } else if (obj instanceof TableOrSubqueryConvertible) {\n                TableOrSubqueryConvertible tableOrSubquery = (TableOrSubqueryConvertible) obj;\n                types[i] = Identifier.getCppType(tableOrSubquery);\n                cppObjs[intIndex] = CppObject.get(tableOrSubquery);\n                intIndex++;\n            }\n        }\n        if (tablNames.length * 0.75 > stringIndex) {\n            if (stringIndex == 0) {\n                tablNames = null;\n            } else {\n                tablNames = Arrays.copyOf(tablNames, stringIndex);\n            }\n        }\n        configTableOrSubqueries(cppObj, types, cppObjs, null, tablNames);\n        return this;\n    }\n\n    private static native void configTableOrSubqueries(long self, int[] types, long[] tableOrSubqueries, double[] unused, String[] tableNames);\n\n    @NotNull\n    public StatementSelect where(@Nullable Expression condition) {\n        configCondition(cppObj, CppObject.get(condition));\n        return this;\n    }\n\n    private static native void configCondition(long self, long condition);\n\n    @NotNull\n    public StatementSelect groupBy(@Nullable ExpressionConvertible... expressions) {\n        if (expressions == null || expressions.length == 0) {\n            return this;\n        }\n        int totalCount = expressions.length;\n        int[] types = new int[totalCount];\n        long[] cppObjs = new long[totalCount];\n        for (int i = 0; i < totalCount; i++) {\n            types[i] = Identifier.getCppType(expressions[i]);\n            cppObjs[i] = CppObject.get(expressions[i]);\n        }\n        configGroups(cppObj, types, cppObjs, null, null);\n        return this;\n    }\n\n    @NotNull\n    public StatementSelect groupBy(@Nullable String... columnNames) {\n        if (columnNames == null || columnNames.length == 0) {\n            return this;\n        }\n        int[] types = new int[columnNames.length];\n        Arrays.fill(types, CPPType.String);\n        configGroups(cppObj, types, null, null, columnNames);\n        return this;\n    }\n\n    @NotNull\n    public StatementSelect groupBy(@Nullable Object... expressions) {\n        if (expressions == null || expressions.length == 0) {\n            return this;\n        }\n        int totalCount = expressions.length;\n        int[] types = new int[totalCount];\n        long[] cppObjs = new long[totalCount];\n        String[] columnNames = new String[totalCount];\n        int intIndex = 0;\n        int stringIndex = 0;\n        for (int i = 0; i < totalCount; i++) {\n            Object obj = expressions[i];\n            if (obj instanceof String) {\n                types[i] = CPPType.String;\n                columnNames[stringIndex] = (String) obj;\n                stringIndex++;\n            } else if (obj instanceof ExpressionConvertible) {\n                ExpressionConvertible expression = (ExpressionConvertible) obj;\n                types[i] = Identifier.getCppType(expression);\n                cppObjs[intIndex] = CppObject.get(expression);\n                intIndex++;\n            }\n        }\n        if (columnNames.length * 0.75 > stringIndex) {\n            if (stringIndex == 0) {\n                columnNames = null;\n            } else {\n                columnNames = Arrays.copyOf(columnNames, stringIndex);\n            }\n        }\n        configGroups(cppObj, types, cppObjs, null, columnNames);\n        return this;\n    }\n\n    private static native void configGroups(long self, int[] types, long[] exps, double[] unused, String[] columNames);\n\n    @NotNull\n    public StatementSelect having(@Nullable Expression expression) {\n        configHaving(cppObj, CppObject.get(expression));\n        return this;\n    }\n\n    private static native void configHaving(long self, long expression);\n\n    @NotNull\n    public StatementSelect union() {\n        configUnion(cppObj);\n        return this;\n    }\n\n    private static native void configUnion(long self);\n\n    @NotNull\n    public StatementSelect unionAll() {\n        configUnionAll(cppObj);\n        return this;\n    }\n\n    private static native void configUnionAll(long self);\n\n    @NotNull\n    public StatementSelect intersect() {\n        configIntersect(cppObj);\n        return this;\n    }\n\n    private static native void configIntersect(long self);\n\n    @NotNull\n    public StatementSelect except() {\n        configExcept(cppObj);\n        return this;\n    }\n\n    private static native void configExcept(long self);\n\n    @NotNull\n    public StatementSelect orderBy(@Nullable OrderingTerm... orders) {\n        if (orders == null || orders.length == 0) {\n            return this;\n        }\n        long[] cppOrders = new long[orders.length];\n        for (int i = 0; i < orders.length; i++) {\n            cppOrders[i] = CppObject.get(orders[i]);\n        }\n        configOrders(cppObj, cppOrders);\n        return this;\n    }\n\n    private static native void configOrders(long self, long[] orders);\n\n    @NotNull\n    public StatementSelect limit(long from, long to) {\n        configLimitRange(cppObj, CPPType.Int, from, CPPType.Int, to);\n        return this;\n    }\n\n    @NotNull\n    public StatementSelect limit(long from, @Nullable ExpressionConvertible to) {\n        configLimitRange(cppObj, CPPType.Int, from, Identifier.getCppType(to), CppObject.get(to));\n        return this;\n    }\n\n    @NotNull\n    public StatementSelect limit(@Nullable ExpressionConvertible from, @Nullable ExpressionConvertible to) {\n        configLimitRange(cppObj, Identifier.getCppType(from), CppObject.get(from), Identifier.getCppType(to), CppObject.get(to));\n        return this;\n    }\n\n    @NotNull\n    public StatementSelect limit(@Nullable ExpressionConvertible from, long to) {\n        configLimitRange(cppObj, Identifier.getCppType(from), CppObject.get(from), CPPType.Int, to);\n        return this;\n    }\n\n    private static native void configLimitRange(long self, int fromType, long from, int toType, long to);\n\n    @NotNull\n    public StatementSelect limit(long count) {\n        configLimitCount(cppObj, CPPType.Int, count);\n        return this;\n    }\n\n    @NotNull\n    public StatementSelect limit(@Nullable ExpressionConvertible count) {\n        configLimitCount(cppObj, Identifier.getCppType(count), CppObject.get(count));\n        return this;\n    }\n\n    private static native void configLimitCount(long self, int type, long count);\n\n    @NotNull\n    public StatementSelect offset(long offset) {\n        configOffset(cppObj, CPPType.Int, offset);\n        return this;\n    }\n\n    @NotNull\n    public StatementSelect offset(@Nullable ExpressionConvertible offset) {\n        configOffset(cppObj, Identifier.getCppType(offset), CppObject.get(offset));\n        return this;\n    }\n\n    private static native void configOffset(long self, int type, long count);\n}\n\n"
  },
  {
    "path": "src/java/main/src/main/java/com/tencent/wcdb/winq/StatementUpdate.java",
    "content": "// Created by chenqiuwen on 2023/4/13.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdb.winq;\n\nimport com.tencent.wcdb.base.CppObject;\n\nimport org.jetbrains.annotations.NotNull;\nimport org.jetbrains.annotations.Nullable;\n\npublic class StatementUpdate extends Statement {\n    @Override\n    protected int getType() {\n        return CPPType.UpdateSTMT;\n    }\n\n    public StatementUpdate() {\n        cppObj = createCppObj();\n    }\n\n    private static native long createCppObj();\n\n    @NotNull\n    public StatementUpdate with(@Nullable CommonTableExpression... expressions) {\n        if (expressions == null || expressions.length == 0) {\n            return this;\n        }\n        long[] cppExps = new long[expressions.length];\n        for (int i = 0; i < expressions.length; i++) {\n            cppExps[i] = CppObject.get(expressions[i]);\n        }\n        configWith(cppObj, cppExps);\n        return this;\n    }\n\n    @NotNull\n    public StatementUpdate withRecursive(@Nullable CommonTableExpression... expressions) {\n        if (expressions == null || expressions.length == 0) {\n            return this;\n        }\n        long[] cppExps = new long[expressions.length];\n        for (int i = 0; i < expressions.length; i++) {\n            cppExps[i] = CppObject.get(expressions[i]);\n        }\n        configWith(cppObj, cppExps);\n        configRecursive(cppObj);\n        return this;\n    }\n\n    private static native void configWith(long self, long[] expressions);\n\n    private static native void configRecursive(long self);\n\n    @NotNull\n    public StatementUpdate update(@NotNull String tableName) {\n        configTable(cppObj, CPPType.String, 0, tableName);\n        return this;\n    }\n\n    @NotNull\n    public StatementUpdate update(@NotNull QualifiedTable table) {\n        configTable(cppObj, Identifier.getCppType(table), CppObject.get(table), null);\n        return this;\n    }\n\n    private static native void configTable(long self, int type, long table, String tableName);\n\n    @NotNull\n    public StatementUpdate orReplace() {\n        configConflictAction(cppObj, ConflictAction.Replace.ordinal());\n        return this;\n    }\n\n    @NotNull\n    public StatementUpdate orRollback() {\n        configConflictAction(cppObj, ConflictAction.Rollback.ordinal());\n        return this;\n    }\n\n    @NotNull\n    public StatementUpdate orAbort() {\n        configConflictAction(cppObj, ConflictAction.Abort.ordinal());\n        return this;\n    }\n\n    @NotNull\n    public StatementUpdate orFail() {\n        configConflictAction(cppObj, ConflictAction.Fail.ordinal());\n        return this;\n    }\n\n    @NotNull\n    public StatementUpdate orIgnore() {\n        configConflictAction(cppObj, ConflictAction.Ignore.ordinal());\n        return this;\n    }\n\n    private static native void configConflictAction(long self, int action);\n\n    @NotNull\n    public StatementUpdate setColumnsToBindParameters(@NotNull Column... columns) {\n        if (columns.length == 0) {\n            return this;\n        }\n        long[] cppObjs = new long[columns.length];\n        for (int i = 0; i < columns.length; i++) {\n            cppObjs[i] = CppObject.get(columns[i]);\n        }\n        configColumnsToBindParameters(cppObj, CPPType.Column, cppObjs, null);\n        return this;\n    }\n\n    @NotNull\n    public StatementUpdate setColumnsToBindParameters(@NotNull String... columnNames) {\n        if (columnNames.length == 0) {\n            return this;\n        }\n        configColumnsToBindParameters(cppObj, CPPType.String, null, columnNames);\n        return this;\n    }\n\n    private static native void configColumnsToBindParameters(long self, int type, long[] columns, String[] columnNames);\n\n    @NotNull\n    public StatementUpdate setColumnsToValues(@NotNull Column[] columns, @NotNull Object[] values) {\n        if (columns.length == 0 || values.length == 0) {\n            return this;\n        }\n\n        long[] cppColumns = new long[columns.length];\n        for (int i = 0; i < columns.length; i++) {\n            cppColumns[i] = CppObject.get(columns[i]);\n        }\n\n        MultiTypeArray array = new MultiTypeArray(values);\n\n        configColumnsToValues(cppObj, CPPType.Column, cppColumns, null,\n                array.types, array.longValues, array.doubleValues, array.stringValues);\n\n        return this;\n    }\n\n    @NotNull\n    public StatementUpdate setColumnsToValues(@NotNull String[] columnNames, @NotNull Object[] values) {\n        if (columnNames.length == 0 || values.length == 0) {\n            return this;\n        }\n\n        MultiTypeArray array = new MultiTypeArray(values);\n\n        configColumnsToValues(cppObj, CPPType.String, null, columnNames,\n                array.types, array.longValues, array.doubleValues, array.stringValues);\n\n        return this;\n    }\n\n    private static native void configColumnsToValues(long self,\n                                                     int columnType,\n                                                     long[] columns,\n                                                     String[] columnNames,\n                                                     int[] valueTypes,\n                                                     long[] longValues,\n                                                     double[] doubleValues,\n                                                     String[] stringValues);\n\n    @NotNull\n    public StatementUpdate set(@NotNull Column... columns) {\n        if (columns.length == 0) {\n            return this;\n        }\n        long[] cppObjs = new long[columns.length];\n        for (int i = 0; i < columns.length; i++) {\n            cppObjs[i] = CppObject.get(columns[i]);\n        }\n        configColumns(cppObj, CPPType.Column, cppObjs, null);\n        return this;\n    }\n\n    @NotNull\n    public StatementUpdate set(@NotNull String... columnNames) {\n        if (columnNames.length == 0) {\n            return this;\n        }\n        configColumns(cppObj, CPPType.String, null, columnNames);\n        return this;\n    }\n\n    private static native void configColumns(long self, int type, long[] columns, String[] columnNames);\n\n    @NotNull\n    public StatementUpdate to(boolean arg) {\n        configToValue(cppObj, CPPType.Bool, arg ? 1 : 0, 0, null);\n        return this;\n    }\n\n    @NotNull\n    public StatementUpdate to(byte arg) {\n        configToValue(cppObj, CPPType.Int, arg, 0, null);\n        return this;\n    }\n\n    @NotNull\n    public StatementUpdate to(short arg) {\n        configToValue(cppObj, CPPType.Int, arg, 0, null);\n        return this;\n    }\n\n    @NotNull\n    public StatementUpdate to(int arg) {\n        configToValue(cppObj, CPPType.Int, arg, 0, null);\n        return this;\n    }\n\n    @NotNull\n    public StatementUpdate to(long arg) {\n        configToValue(cppObj, CPPType.Int, arg, 0, null);\n        return this;\n    }\n\n    @NotNull\n    public StatementUpdate to(float arg) {\n        configToValue(cppObj, CPPType.Double, 0, arg, null);\n        return this;\n    }\n\n    @NotNull\n    public StatementUpdate to(double arg) {\n        configToValue(cppObj, CPPType.Double, 0, arg, null);\n        return this;\n    }\n\n    @NotNull\n    public StatementUpdate to(@Nullable String arg) {\n        if (arg != null) {\n            configToValue(cppObj, CPPType.String, 0, 0, arg);\n        } else {\n            configToValue(cppObj, CPPType.Null, 0, 0, null);\n        }\n        return this;\n    }\n\n    @NotNull\n    public StatementUpdate to(@Nullable ExpressionConvertible arg) {\n        configToValue(cppObj, Identifier.getCppType(arg), CppObject.get(arg), 0, null);\n        return this;\n    }\n\n    private static native void configToValue(long self, int type, long intValue, double doubleValue, String stringValue);\n\n    @NotNull\n    public StatementUpdate where(@Nullable Expression condition) {\n        configCondition(cppObj, CppObject.get(condition));\n        return this;\n    }\n\n    private static native void configCondition(long self, long condition);\n\n    @NotNull\n    public StatementUpdate orderBy(@Nullable OrderingTerm... orders) {\n        if (orders == null || orders.length == 0) {\n            return this;\n        }\n        long[] cppOrders = new long[orders.length];\n        for (int i = 0; i < orders.length; i++) {\n            cppOrders[i] = CppObject.get(orders[i]);\n        }\n        configOrders(cppObj, cppOrders);\n        return this;\n    }\n\n    private static native void configOrders(long self, long[] orders);\n\n    @NotNull\n    public StatementUpdate limit(long from, long to) {\n        configLimitRange(cppObj, CPPType.Int, from, CPPType.Int, to);\n        return this;\n    }\n\n    @NotNull\n    public StatementUpdate limit(long from, @Nullable ExpressionConvertible to) {\n        configLimitRange(cppObj, CPPType.Int, from, Identifier.getCppType(to), CppObject.get(to));\n        return this;\n    }\n\n    @NotNull\n    public StatementUpdate limit(@Nullable ExpressionConvertible from, @Nullable ExpressionConvertible to) {\n        configLimitRange(cppObj, Identifier.getCppType(from), CppObject.get(from), Identifier.getCppType(to), CppObject.get(to));\n        return this;\n    }\n\n    @NotNull\n    public StatementUpdate limit(@Nullable ExpressionConvertible from, long to) {\n        configLimitRange(cppObj, Identifier.getCppType(from), CppObject.get(from), CPPType.Int, to);\n        return this;\n    }\n\n    private static native void configLimitRange(long self, int fromType, long from, int toType, long to);\n\n    @NotNull\n    public StatementUpdate limit(long count) {\n        configLimitCount(cppObj, CPPType.Int, count);\n        return this;\n    }\n\n    @NotNull\n    public StatementUpdate limit(@Nullable ExpressionConvertible count) {\n        configLimitCount(cppObj, Identifier.getCppType(count), CppObject.get(count));\n        return this;\n    }\n\n    private static native void configLimitCount(long self, int type, long count);\n\n    @NotNull\n    public StatementUpdate offset(long offset) {\n        configOffset(cppObj, CPPType.Int, offset);\n        return this;\n    }\n\n    @NotNull\n    public StatementUpdate offset(@Nullable ExpressionConvertible offset) {\n        configOffset(cppObj, Identifier.getCppType(offset), CppObject.get(offset));\n        return this;\n    }\n\n    private static native void configOffset(long self, int type, long count);\n}\n"
  },
  {
    "path": "src/java/main/src/main/java/com/tencent/wcdb/winq/StatementVacuum.java",
    "content": "// Created by qiuwenchen on 2023/6/13.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdb.winq;\n\nimport com.tencent.wcdb.base.CppObject;\n\nimport org.jetbrains.annotations.NotNull;\n\npublic class StatementVacuum extends Statement {\n    @Override\n    protected int getType() {\n        return CPPType.VacuumSTMT;\n    }\n\n    public StatementVacuum() {\n        cppObj = createCppObj();\n    }\n\n    private static native long createCppObj();\n\n    @NotNull\n    public StatementVacuum vacuum(@NotNull String schemaName) {\n        configSchema(cppObj, CPPType.String, 0, schemaName);\n        return this;\n    }\n\n    @NotNull\n    public StatementVacuum vacuum(@NotNull Schema schema) {\n        configSchema(cppObj, Identifier.getCppType(schema), CppObject.get(schema), null);\n        return this;\n    }\n\n    private static native void configSchema(long self, int type, long object, String path);\n}\n"
  },
  {
    "path": "src/java/main/src/main/java/com/tencent/wcdb/winq/TableConstraint.java",
    "content": "// Created by chenqiuwen on 2023/4/9.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdb.winq;\n\nimport com.tencent.wcdb.base.CppObject;\n\nimport org.jetbrains.annotations.NotNull;\nimport org.jetbrains.annotations.Nullable;\n\npublic class TableConstraint extends Identifier {\n    @Override\n    protected int getType() {\n        return CPPType.TableConstraint;\n    }\n\n    public TableConstraint() {\n        cppObj = createCppObj(null);\n    }\n\n    public TableConstraint(@Nullable String name) {\n        cppObj = createCppObj(name);\n    }\n\n    private static native long createCppObj(String name);\n\n    @NotNull\n    public TableConstraint primaryKey() {\n        configPrimaryKey(cppObj);\n        return this;\n    }\n\n    private static native void configPrimaryKey(long self);\n\n    @NotNull\n    public TableConstraint unique() {\n        configUnique(cppObj);\n        return this;\n    }\n\n    private static native void configUnique(long self);\n\n    @NotNull\n    public TableConstraint indexedBy(@NotNull IndexedColumnConvertible... indexedColumns) {\n        if (indexedColumns.length == 0) {\n            return this;\n        }\n        long[] columns = new long[indexedColumns.length];\n        for (int i = 0; i < indexedColumns.length; i++) {\n            columns[i] = CppObject.get(indexedColumns[i]);\n        }\n        configIndexedColumn(\n                cppObj,\n                Identifier.getCppType(indexedColumns[0]),\n                columns, null);\n        return this;\n    }\n\n    @NotNull\n    public TableConstraint indexedBy(@NotNull String... indexedColumns) {\n        configIndexedColumn(cppObj, CPPType.String, null, indexedColumns);\n        return this;\n    }\n\n    private static native void configIndexedColumn(long self,\n                                                   int type,\n                                                   long[] columns,\n                                                   String[] columnNames);\n\n    @NotNull\n    public TableConstraint onConflict(ConflictAction action) {\n        configConfliction(cppObj, action.ordinal());\n        return this;\n    }\n\n    private static native void configConfliction(long self, int action);\n\n    @NotNull\n    public TableConstraint check(@NotNull Expression expression) {\n        configCheckExpression(cppObj, CppObject.get(expression));\n        return this;\n    }\n\n    private static native void configCheckExpression(long self, long expression);\n\n    @NotNull\n    public TableConstraint foreignKey(@NotNull ForeignKey foreignKey, @NotNull String... columns) {\n        configForeignKey(\n                cppObj,\n                CPPType.String,\n                null,\n                columns,\n                CppObject.get(foreignKey));\n        return this;\n    }\n\n    @NotNull\n    public TableConstraint foreignKey(@NotNull ForeignKey foreignKey, @NotNull Column... columns) {\n        long[] cppObjs = new long[columns.length];\n        for (int i = 0; i < columns.length; i++) {\n            cppObjs[i] = CppObject.get(columns[i]);\n        }\n        configForeignKey(\n                cppObj,\n                CPPType.Column,\n                cppObjs,\n                null,\n                CppObject.get(foreignKey));\n        return this;\n    }\n\n    private static native void configForeignKey(long self,\n                                                int type,\n                                                long[] columns,\n                                                String[] columnNames,\n                                                long foreignKey);\n}\n"
  },
  {
    "path": "src/java/main/src/main/java/com/tencent/wcdb/winq/TableOrSubquery.java",
    "content": "// Created by qiuwenchen on 2023/4/7.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdb.winq;\n\nimport com.tencent.wcdb.base.CppObject;\n\nimport org.jetbrains.annotations.NotNull;\nimport org.jetbrains.annotations.Nullable;\n\npublic class TableOrSubquery extends Identifier implements TableOrSubqueryConvertible {\n    @Override\n    protected int getType() {\n        return CPPType.TableOrSubquery;\n    }\n\n    private TableOrSubquery() {\n    }\n\n    public TableOrSubquery(@NotNull TableOrSubqueryConvertible tableOrSubqueryConvertible) {\n        cppObj = createCppObj(Identifier.getCppType(tableOrSubqueryConvertible), CppObject.get(tableOrSubqueryConvertible),\n                null);\n    }\n\n    public TableOrSubquery(@NotNull String tableName) {\n        cppObj = createCppObj(CPPType.String, 0, tableName);\n    }\n\n    private static native long createCppObj(int type, long object, String tableName);\n\n    public TableOrSubquery(@NotNull TableOrSubqueryConvertible... tableOrSubqueries) {\n        if (tableOrSubqueries.length == 0) {\n            cppObj = createCppObj(CPPType.String, new long[]{}, null);\n            return;\n        }\n        long[] array = new long[tableOrSubqueries.length];\n        for (int i = 0; i < tableOrSubqueries.length; i++) {\n            array[i] = CppObject.get(tableOrSubqueries[i]);\n        }\n        cppObj = createCppObj(Identifier.getCppType(tableOrSubqueries[0]), array, null);\n    }\n\n    public TableOrSubquery(@NotNull String... tables) {\n        cppObj = createCppObj(CPPType.String, null, tables);\n    }\n\n    private static native long createCppObj(int type, long[] tableOrSubqueries, String[] tables);\n\n    @NotNull\n    public TableOrSubquery schema(@Nullable String schemaName) {\n        schema(cppObj, CPPType.String, 0, schemaName);\n        return this;\n    }\n\n    @NotNull\n    public TableOrSubquery schema(@Nullable Schema schema) {\n        schema(cppObj, Identifier.getCppType(schema), CppObject.get(schema), null);\n        return this;\n    }\n\n    private static native void schema(long self, int type, long schema, String schemaName);\n\n    @NotNull\n    public TableOrSubquery as(@Nullable String alias) {\n        as(cppObj, alias);\n        return this;\n    }\n\n    private static native void as(long object, String alias);\n\n    @NotNull\n    public TableOrSubquery notIndexd() {\n        notIndexed(cppObj);\n        return this;\n    }\n\n    private static native void notIndexed(long object);\n\n    @NotNull\n    public TableOrSubquery indexedBy(@Nullable String indexName) {\n        indexedBy(cppObj, indexName);\n        return this;\n    }\n\n    private static native void indexedBy(long object, String indexName);\n\n    public static TableOrSubquery function(@NotNull String funcName) {\n        TableOrSubquery tableOrSubquery = new TableOrSubquery();\n        tableOrSubquery.cppObj = createWithFunction(funcName);\n        return tableOrSubquery;\n    }\n\n    public static native long createWithFunction(String funcName);\n\n    @NotNull\n    public TableOrSubquery argument(boolean arg) {\n        argument(cppObj, CPPType.Bool, arg ? 1 : 0, 0, null);\n        return this;\n    }\n\n    @NotNull\n    public TableOrSubquery argument(byte arg) {\n        argument(cppObj, CPPType.Int, arg, 0, null);\n        return this;\n    }\n\n    @NotNull\n    public TableOrSubquery argument(short arg) {\n        argument(cppObj, CPPType.Int, arg, 0, null);\n        return this;\n    }\n\n    @NotNull\n    public TableOrSubquery argument(int arg) {\n        argument(cppObj, CPPType.Int, arg, 0, null);\n        return this;\n    }\n\n    @NotNull\n    public TableOrSubquery argument(long arg) {\n        argument(cppObj, CPPType.Int, arg, 0, null);\n        return this;\n    }\n\n    @NotNull\n    public TableOrSubquery argument(float arg) {\n        argument(cppObj, CPPType.Double, 0, arg, null);\n        return this;\n    }\n\n    @NotNull\n    public TableOrSubquery argument(double arg) {\n        argument(cppObj, CPPType.Double, 0, arg, null);\n        return this;\n    }\n\n    @NotNull\n    public TableOrSubquery argument(@Nullable String arg) {\n        if (arg != null) {\n            argument(cppObj, CPPType.String, 0, 0, arg);\n        } else {\n            argument(cppObj, CPPType.Null, 0, 0, null);\n        }\n        return this;\n    }\n\n    @NotNull\n    public TableOrSubquery argument(@Nullable ExpressionConvertible arg) {\n        argument(cppObj,\n                Identifier.getCppType(arg),\n                CppObject.get(arg),\n                0,\n                null);\n        return this;\n    }\n\n    private static native void argument(long self,\n                                        int type,\n                                        long intValue,\n                                        double doubleValue,\n                                        String stringValue);\n}\n"
  },
  {
    "path": "src/java/main/src/main/java/com/tencent/wcdb/winq/TableOrSubqueryConvertible.java",
    "content": "// Created by qiuwenchen on 2023/4/7.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdb.winq;\n\npublic interface TableOrSubqueryConvertible extends IdentifierConvertible {\n}\n"
  },
  {
    "path": "src/java/main/src/main/java/com/tencent/wcdb/winq/Upsert.java",
    "content": "// Created by qiuwenchen on 2023/6/9.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdb.winq;\n\nimport com.tencent.wcdb.base.CppObject;\n\nimport org.jetbrains.annotations.NotNull;\nimport org.jetbrains.annotations.Nullable;\n\npublic class Upsert extends Identifier {\n    @Override\n    protected int getType() {\n        return CPPType.UpsertClause;\n    }\n\n    public Upsert() {\n        cppObj = createCppObj();\n    }\n\n    private static native long createCppObj();\n\n    @NotNull\n    public Upsert onConflict() {\n        return this;\n    }\n\n    @NotNull\n    public Upsert indexedBy(@NotNull String... columnNames) {\n        configIndexedColumn(cppObj, CPPType.String, null, columnNames);\n        return this;\n    }\n\n    @NotNull\n    public Upsert indexedBy(@NotNull IndexedColumnConvertible... indexedColumns) {\n        if (indexedColumns.length == 0) {\n            return this;\n        }\n\n        long[] cppIndexedColumns = new long[indexedColumns.length];\n        for (int i = 0; i < indexedColumns.length; i++) {\n            cppIndexedColumns[i] = CppObject.get(indexedColumns[i]);\n        }\n\n        configIndexedColumn(cppObj, Identifier.getCppType(indexedColumns[0]), cppIndexedColumns, null);\n        return this;\n    }\n\n    private static native void configIndexedColumn(long self, int type, long[] columns, String[] columnNames);\n\n    @NotNull\n    public Upsert where(@Nullable Expression condition) {\n        configWhere(cppObj, CppObject.get(condition));\n        return this;\n    }\n\n    private static native void configWhere(long self, long condition);\n\n    @NotNull\n    public Upsert doNoThing() {\n        configDoNothing(cppObj);\n        return this;\n    }\n\n    private static native void configDoNothing(long self);\n\n    @NotNull\n    public Upsert doUpdate() {\n        configDoUpdate(cppObj);\n        return this;\n    }\n\n    private static native void configDoUpdate(long self);\n\n    @NotNull\n    public Upsert set(@NotNull String... columnNames) {\n        configSetColumns(cppObj, CPPType.String, null, columnNames);\n        return this;\n    }\n\n    @NotNull\n    public Upsert set(@NotNull Column... columns) {\n        if (columns.length == 0) {\n            return this;\n        }\n\n        long[] cppColumns = new long[columns.length];\n        for (int i = 0; i < columns.length; i++) {\n            cppColumns[i] = CppObject.get(columns[i]);\n        }\n\n        configSetColumns(cppObj, Identifier.getCppType(columns[0]), cppColumns, null);\n        return this;\n    }\n\n    private static native void configSetColumns(long self, int type, long[] columns, String[] columnNames);\n\n    @NotNull\n    public Upsert to(boolean value) {\n        configToValue(cppObj, CPPType.Bool, value ? 1 : 0, 0, null);\n        return this;\n    }\n\n    @NotNull\n    public Upsert to(byte value) {\n        configToValue(cppObj, CPPType.Int, value, 0, null);\n        return this;\n    }\n\n    @NotNull\n    public Upsert to(short value) {\n        configToValue(cppObj, CPPType.Int, value, 0, null);\n        return this;\n    }\n\n    @NotNull\n    public Upsert to(int value) {\n        configToValue(cppObj, CPPType.Int, value, 0, null);\n        return this;\n    }\n\n    @NotNull\n    public Upsert to(long value) {\n        configToValue(cppObj, CPPType.Int, value, 0, null);\n        return this;\n    }\n\n    @NotNull\n    public Upsert to(float value) {\n        configToValue(cppObj, CPPType.Double, 0, value, null);\n        return this;\n    }\n\n    @NotNull\n    public Upsert to(double value) {\n        configToValue(cppObj, CPPType.Double, 0, value, null);\n        return this;\n    }\n\n    @NotNull\n    public Upsert to(@Nullable String value) {\n        if (value != null) {\n            configToValue(cppObj, CPPType.String, 0, 0, value);\n        } else {\n            configToValue(cppObj, CPPType.Null, 0, 0, null);\n        }\n        return this;\n    }\n\n    @NotNull\n    public Upsert to(@Nullable ExpressionConvertible value) {\n        configToValue(cppObj, Identifier.getCppType(value), CppObject.get(value), 0, null);\n        return this;\n    }\n\n    private static native void configToValue(long self, int type, long intValue, double doubleValue, String stringValue);\n}\n"
  },
  {
    "path": "src/java/main/src/main/java/com/tencent/wcdb/winq/WindowDef.java",
    "content": "// Created by chenqiuwen on 2023/6/10.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdb.winq;\n\nimport com.tencent.wcdb.base.CppObject;\n\nimport org.jetbrains.annotations.NotNull;\nimport org.jetbrains.annotations.Nullable;\n\nimport java.util.Arrays;\n\npublic class WindowDef extends Identifier {\n    @Override\n    protected int getType() {\n        return CPPType.WindowDef;\n    }\n\n    public WindowDef() {\n        cppObj = createCppObj();\n    }\n\n    private static native long createCppObj();\n\n    @NotNull\n    public WindowDef partitionBy(@Nullable String... columnNames) {\n        if (columnNames == null || columnNames.length == 0) {\n            return this;\n        }\n        int[] types = new int[columnNames.length];\n        Arrays.fill(types, CPPType.String);\n        configPartitions(cppObj, types, null, null, columnNames);\n        return this;\n    }\n\n    @NotNull\n    public WindowDef partitionBy(@Nullable ExpressionConvertible... expressions) {\n        if (expressions == null || expressions.length == 0) {\n            return this;\n        }\n        int[] types = new int[expressions.length];\n        long[] cppObjs = new long[expressions.length];\n        for (int i = 0; i < expressions.length; i++) {\n            types[i] = Identifier.getCppType(expressions[i]);\n            cppObjs[i] = CppObject.get(expressions[i]);\n        }\n        configPartitions(cppObj, types, cppObjs, null, null);\n        return this;\n    }\n\n    private static native void configPartitions(long self, int[] types, long[] columns, double[] unused, String[] columnNames);\n\n    @NotNull\n    public WindowDef orderBy(@Nullable OrderingTerm... orders) {\n        if (orders == null || orders.length == 0) {\n            return this;\n        }\n        long[] cppOrders = new long[orders.length];\n        for (int i = 0; i < orders.length; i++) {\n            cppOrders[i] = CppObject.get(orders[i]);\n        }\n        configOrders(cppObj, cppOrders);\n        return this;\n    }\n\n    private static native void configOrders(long self, long[] orders);\n\n    @NotNull\n    public WindowDef frameSpec(@Nullable FrameSpec frameSpec) {\n        configFrameSpec(cppObj, CppObject.get(frameSpec));\n        return this;\n    }\n\n    private static native void configFrameSpec(long self, long frameSpec);\n}\n"
  },
  {
    "path": "src/java/settings.gradle",
    "content": "pluginManagement {\n    includeBuild 'builder'\n}\n\nrootProject.name = 'WCDB'\n\ninclude ':main'\ninclude ':compat'\ninclude ':test'\ninclude ':kotlin-test'\n\nincludeBuild('annotation') {\n    dependencySubstitution {\n        substitute module('com.tencent.wcdb:annotation') using project(':')\n    }\n}\n\nincludeBuild('builder') {\n    dependencySubstitution {\n        substitute module('com.tencent.wcdb:compiler') using project(':compiler')\n    }\n}"
  },
  {
    "path": "src/java/test/.gitignore",
    "content": "/build"
  },
  {
    "path": "src/java/test/build.gradle",
    "content": "plugins {\n    id 'com.android.application'\n    id 'org.jetbrains.kotlin.android'\n    id 'com.google.devtools.ksp' version '1.7.10-1.0.6'\n    id 'com.tencent.wcdb.gradle'\n}\n\nandroid {\n    namespace 'com.tencent.wcdbtest'\n    compileSdk 33\n\n    defaultConfig {\n        applicationId \"com.tencent.wcdbtest\"\n        minSdk 21\n        targetSdk 33\n        versionCode 1\n        versionName \"1.0\"\n\n        testInstrumentationRunner \"androidx.test.runner.AndroidJUnitRunner\"\n    }\n    buildTypes {\n        release {\n            signingConfig signingConfigs.debug\n        }\n    }\n\n}\n\ndependencies {\n    androidTestImplementation 'androidx.test.ext:junit:1.1.5'\n    androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'\n    implementation project(path: ':main')\n    implementation \"com.tencent.wcdb:annotation:${project.version}\"\n}"
  },
  {
    "path": "src/java/test/proguard-rules.pro",
    "content": "# Add project specific ProGuard rules here.\n# You can control the set of applied configuration files using the\n# proguardFiles setting in build.gradle.\n#\n# For more details, see\n#   http://developer.android.com/guide/developing/tools/proguard.html\n\n# If your project uses WebView with JS, uncomment the following\n# and specify the fully qualified class name to the JavaScript interface\n# class:\n#-keepclassmembers class fqcn.of.javascript.interface.for.webview {\n#   public *;\n#}\n\n# Uncomment this to preserve the line number information for\n# debugging stack traces.\n#-keepattributes SourceFile,LineNumberTable\n\n# If you keep the line number information, uncomment this to\n# hide the original source file name.\n#-renamesourcefileattribute SourceFile"
  },
  {
    "path": "src/java/test/src/androidTest/java/com/tencent/wcdbtest/base/BaseTestCase.java",
    "content": "// Created by chenqiuwen on 2023/5/7.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdbtest.base;\n\nimport org.jetbrains.annotations.NotNull;\n\nimport com.tencent.wcdb.base.WCDBException;\nimport com.tencent.wcdb.core.Database;\n\nimport org.junit.Before;\nimport org.junit.BeforeClass;\nimport org.junit.Rule;\nimport org.junit.rules.TemporaryFolder;\n\nimport java.io.File;\n\npublic class BaseTestCase {\n    public String currentDirectory;\n\n    @BeforeClass\n    public static void globalSetUp() {\n        Database.globalTracePerformance(null);\n        Database.globalTraceSQL(null);\n        Database.globalTraceException(new Database.ExceptionTracer() {\n            @Override\n            public void onTrace(@NotNull WCDBException exception) {\n                if (exception.level.ordinal() >= WCDBException.Level.Error.ordinal()) {\n                    logError(exception.toString());\n                } else {\n                    logInfo(exception.toString());\n                }\n//                assert exception.level != WCDBException.Level.Fatal;\n            }\n        });\n    }\n\n    @Before\n    public void setup() throws WCDBException {\n        currentDirectory = tempFolder.getRoot().getPath() + File.separator + getClass().getSimpleName();\n        logInfo(\"Current directory: \" + currentDirectory);\n    }\n\n    public static void logInfo(String msg, Object... args) {\n        String log = msg;\n        if (args != null && args.length > 0) {\n            log = String.format(msg, args);\n        }\n        System.out.println(log);\n    }\n\n    public static void logError(String msg, Object... args) {\n        String log = msg;\n        if (args != null && args.length > 0) {\n            log = String.format(msg, args);\n        }\n        System.err.println(log);\n    }\n\n    public static void sleep(long millisecond) {\n        try {\n            Thread.sleep(millisecond);\n        } catch (InterruptedException e) {\n            BaseTestCase.logError(\"sleep fail with error \" + e);\n        }\n    }\n\n    @Rule\n    public TemporaryFolder tempFolder = new TemporaryFolder();\n}\n"
  },
  {
    "path": "src/java/test/src/androidTest/java/com/tencent/wcdbtest/base/CRUDTestCase.java",
    "content": "// Created by chenqiuwen on 2023/5/12.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdbtest.base;\n\nimport com.tencent.wcdb.base.Value;\nimport com.tencent.wcdb.base.WCDBException;\nimport com.tencent.wcdb.core.Handle;\nimport com.tencent.wcdb.winq.Column;\n\nimport org.junit.After;\nimport org.junit.Before;\n\nimport java.util.Arrays;\nimport java.util.List;\n\npublic class CRUDTestCase extends TableTestCase {\n    protected TestObject object1;\n    protected TestObject object2;\n    protected List<TestObject> objects;\n    protected Value[] row1;\n    protected Value[] row2;\n    protected List<Value[]> rows;\n    protected int nextId = 3;\n    protected Column id = new Column(\"id\");\n    protected Column content = new Column(\"content\");\n    protected Handle handle;\n\n    @Before\n    public void setup() throws WCDBException {\n        super.setup();\n        object1 = RandomTool.testObjectWithId(1);\n        object2 = RandomTool.testObjectWithId(2);\n        objects = Arrays.asList(object1, object2);\n        row1 = RandomTool.testRowWithId(1);\n        row2 = RandomTool.testRowWithId(2);\n        rows = Arrays.asList(row1, row2);\n        handle = database.getHandle();\n        table = database.getTable(tableName, DBTestObject.INSTANCE);\n    }\n\n    @After\n    public void teardown() {\n        if (handle != null) {\n            handle.invalidate();\n            handle = null;\n        }\n        super.teardown();\n    }\n\n    public void insertPresetObjects() throws WCDBException {\n        createTable();\n        table.insertObjects(objects);\n    }\n\n    public void insertPresetRows() throws WCDBException {\n        createValueTable();\n        database.insertRows(rows, columns(), tableName);\n    }\n\n    public long allRowsCount() {\n        try {\n            return database.getValue(Column.all().count(), tableName).getLong();\n        } catch (WCDBException e) {\n            throw new RuntimeException(e);\n        }\n    }\n}\n"
  },
  {
    "path": "src/java/test/src/androidTest/java/com/tencent/wcdbtest/base/DatabaseTestCase.java",
    "content": "// Created by chenqiuwen on 2023/5/7.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdbtest.base;\n\nimport org.jetbrains.annotations.NotNull;\n\nimport com.tencent.wcdb.base.WCDBException;\nimport com.tencent.wcdb.core.Database;\n\nimport org.junit.After;\nimport org.junit.Assert;\nimport org.junit.Before;\n\nimport java.io.File;\nimport java.io.FileNotFoundException;\nimport java.io.IOException;\nimport java.io.RandomAccessFile;\nimport java.util.List;\nimport java.util.ArrayList;\nimport java.util.Arrays;\n\npublic class DatabaseTestCase extends BaseTestCase {\n    public enum Expect {\n        AllSQLs, FirstFewSQLs, SomeSQLs\n    }\n\n    public String path;\n    public String fileName;\n    public Database database;\n    public Expect expectMode;\n\n    @Before\n    public void setup() throws WCDBException {\n        super.setup();\n        expectMode = Expect.AllSQLs;\n        fileName = \"testDatabase\";\n        path = currentDirectory + File.separator + fileName;\n        database = new Database(path);\n        database.setTag(10001);\n    }\n\n    @After\n    public void teardown() {\n        database.close();\n        database = null;\n    }\n\n    public interface TestOperation {\n        void execute() throws WCDBException;\n    }\n\n    public void doTestSQL(String sql, TestOperation operation) {\n        doTestSQLs(new String[]{sql}, operation);\n    }\n\n    public void doTestSQLs(String[] sqls, TestOperation operation) {\n        Assert.assertNotNull(sqls);\n        Assert.assertNotNull(operation);\n        do {\n            final WrappedValue trace = new WrappedValue();\n            trace.boolValue = false;\n            final List<String> expectedSQLs = new ArrayList<String>(Arrays.asList(sqls));\n            final Thread thread = Thread.currentThread();\n            database.traceSQL(new Database.SQLTracer() {\n                @Override\n                public void onTrace(long tag, @NotNull String path, long handleId, @NotNull String sql, @NotNull String info) {\n                    if (Thread.currentThread().getId() != thread.getId()) {\n                        return;\n                    }\n                    if (!trace.boolValue) {\n                        return;\n                    }\n                    doTestSQLAsExpected(expectedSQLs, sql);\n                }\n            });\n            if (expectMode != Expect.SomeSQLs) {\n                if (!database.canOpen()) {\n                    Assert.fail();\n                    break;\n                }\n            }\n            trace.boolValue = true;\n            try {\n                operation.execute();\n            } catch (WCDBException e) {\n                throw new RuntimeException(e);\n            }\n\n            if (expectedSQLs.size() != 0) {\n                logError(\"Reminding: \" + expectedSQLs);\n                Assert.fail();\n                break;\n            }\n            trace.boolValue = false;\n        } while (false);\n        database.traceSQL(null);\n    }\n\n    private void doTestSQLAsExpected(List<String> expectedSQLs, String sql) {\n        switch (expectMode) {\n            case AllSQLs: {\n                if (expectedSQLs.get(0).equals(sql)) {\n                    expectedSQLs.remove(0);\n                } else {\n                    Assert.assertEquals(expectedSQLs.get(0), sql);\n                }\n            }\n            break;\n            case FirstFewSQLs: {\n\n                if (expectedSQLs.size() > 0 && expectedSQLs.get(0).equals(sql)) {\n                    expectedSQLs.remove(0);\n                } else if (expectedSQLs.size() != 0) {\n                    Assert.assertEquals(expectedSQLs.get(0), sql);\n                }\n            }\n            break;\n            case SomeSQLs: {\n                for (int i = 0; i < expectedSQLs.size(); i++) {\n                    if (expectedSQLs.get(i).equals(sql)) {\n                        expectedSQLs.remove(i);\n                        break;\n                    }\n                }\n            }\n            break;\n        }\n    }\n\n    public int headerSize() {\n        return 100;\n    }\n\n    public int pageSize() {\n        return 4096;\n    }\n\n    public int walHeaderSize() {\n        return 32;\n    }\n\n    public int walFrameHeaderSize() {\n        return 24;\n    }\n\n    public int walFrameSize() {\n        return walFrameHeaderSize() + pageSize();\n    }\n\n    public String walPath() {\n        return path + \"-wal\";\n    }\n\n    public String firstMaterialPath() {\n        return path + \"-first.material\";\n    }\n\n    public String lastMaterialPath() {\n        return path + \"-last.material\";\n    }\n\n    public String factoryPath() {\n        return path + \".factory\";\n    }\n\n    public void corruptHeader() {\n        database.close(new Database.CloseCallBack() {\n            @Override\n            public void onClose() throws WCDBException {\n                database.truncateCheckpoint();\n                File file = new File(database.getPath());\n                try {\n                    RandomAccessFile accessFile = new RandomAccessFile(file, \"rw\");\n                    accessFile.seek(0L);\n                    accessFile.write(new byte[headerSize()]);\n                } catch (FileNotFoundException e) {\n                    logError(\"File not founded: \" + e);\n                } catch (IOException e) {\n                    logError(\"IO Error: \" + e);\n                }\n            }\n        });\n    }\n}\n"
  },
  {
    "path": "src/java/test/src/androidTest/java/com/tencent/wcdbtest/base/FileTool.java",
    "content": "// Created by qiuwenchen on 2023/5/8.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdbtest.base;\n\nimport static org.junit.Assert.*;\n\nimport java.io.File;\nimport java.io.IOException;\nimport java.nio.file.Path;\nimport java.nio.file.Paths;\n\npublic class FileTool {\n    public static void createFile(String path) throws IOException {\n        File file = new File(path);\n        if (file.exists()) {\n            return;\n        }\n        File parentFile = file.getParentFile();\n        if (parentFile != null && !parentFile.exists()) {\n            assertTrue(parentFile.mkdirs());\n        }\n        assertTrue(file.createNewFile());\n    }\n\n    public static String getRealPath(String path) {\n        try {\n            Path pathObj = Paths.get(path);\n            Path realPath = pathObj.toRealPath();\n            return realPath.toString();\n        } catch (IOException e) {\n            System.err.println(\"Error: \" + e.getMessage());\n            return null;\n        }\n    }\n\n    public static boolean fileExist(String path) {\n        File file = new File(path);\n        return file.exists();\n    }\n\n    public static long getFileSize(String path) {\n        File file = new File(path);\n        if (file.exists()) {\n            return file.length();\n        } else {\n            return 0;\n        }\n    }\n}\n"
  },
  {
    "path": "src/java/test/src/androidTest/java/com/tencent/wcdbtest/base/ObjectCRUDTestCase.java",
    "content": "// Created by chenqiuwen on 2023/5/14.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdbtest.base;\n\nimport com.tencent.wcdb.base.WCDBException;\n\nimport org.junit.Before;\n\npublic class ObjectCRUDTestCase extends CRUDTestCase {\n    @Before\n    public void setup() throws WCDBException {\n        super.setup();\n        insertPresetObjects();\n    }\n}\n"
  },
  {
    "path": "src/java/test/src/androidTest/java/com/tencent/wcdbtest/base/RandomTool.java",
    "content": "// Created by chenqiuwen on 2023/5/10.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdbtest.base;\n\nimport com.tencent.wcdb.base.Value;\n\nimport java.util.ArrayList;\nimport java.util.HashMap;\nimport java.util.List;\nimport java.util.Map;\nimport java.util.Random;\n\npublic class RandomTool {\n\n    public static String string() {\n        return string(100);\n    }\n\n    public static String string(int length) {\n        String str = \"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789\";\n        Random random = new Random();\n        StringBuilder stringBuffer = new StringBuilder(length);\n        for (int i = 0; i < length; i++) {\n            int number = random.nextInt(62);\n            stringBuffer.append(str.charAt(number));\n        }\n        return stringBuffer.toString();\n    }\n\n    private static final ArrayList<String> g_englishWordArray = createEnglishWordArray();\n\n    private static ArrayList<String> createEnglishWordArray() {\n        Map<String, Integer> g_wordFrequency = new HashMap<>();\n        g_wordFrequency.put(\"a\", 408);\n        g_wordFrequency.put(\"he\", 121);\n        g_wordFrequency.put(\"but\", 86);\n        g_wordFrequency.put(\"my\", 58);\n        g_wordFrequency.put(\"if\", 51);\n        g_wordFrequency.put(\"just\", 44);\n        g_wordFrequency.put(\"people\", 33);\n        g_wordFrequency.put(\"think\", 28);\n        g_wordFrequency.put(\"because\", 25);\n        g_wordFrequency.put(\"two\", 21);\n        g_wordFrequency.put(\"very\", 19);\n        g_wordFrequency.put(\"should\", 17);\n        g_wordFrequency.put(\"work\", 15);\n        g_wordFrequency.put(\"day\", 14);\n        g_wordFrequency.put(\"oh\", 13);\n        g_wordFrequency.put(\"use\", 11);\n        g_wordFrequency.put(\"lot\", 10);\n        g_wordFrequency.put(\"mr\", 10);\n        g_wordFrequency.put(\"part\", 9);\n        g_wordFrequency.put(\"without\", 8);\n        ArrayList<String> wordArray = new ArrayList<>(1000);\n        for (Map.Entry<String, Integer> entry : g_wordFrequency.entrySet()) {\n            String word = entry.getKey();\n            int frequency = entry.getValue();\n            for (int i = 0; i < frequency; i++) {\n                wordArray.add(word);\n            }\n        }\n        return wordArray;\n    }\n\n    public static String englishString() {\n        return englishString(100);\n    }\n\n    public static String englishString(int length) {\n        StringBuilder ret = new StringBuilder();\n        for (int i = 0; i < length; i++) {\n            ret.append(g_englishWordArray.get((int) (Math.random() * 1000)));\n            ret.append(\" \");\n        }\n        return ret.toString();\n    }\n\n    public static boolean useEnglishWord = false;\n\n    public static byte[] bytes() {\n        return bytes(100);\n    }\n\n    public static byte[] bytes(int length) {\n        Random random = new Random();\n        byte[] bytes = new byte[length];\n        random.nextBytes(bytes);\n        return bytes;\n    }\n\n    public static List<TestObject> autoIncrementTestCaseObjects(int count) {\n        ArrayList<TestObject> objects = new ArrayList<>();\n        for (int i = 0; i < count; i++) {\n            objects.add(TestObject.createAutoIncrementObject(useEnglishWord ? englishString() : string()));\n        }\n        return objects;\n    }\n\n    public static List<TestObject> testCaseObjects(int startIdentifier, int count) {\n        ArrayList<TestObject> objects = new ArrayList<>();\n        for (int i = 0; i < count; i++) {\n            objects.add(TestObject.createObject(i + startIdentifier, useEnglishWord ? englishString() : string()));\n        }\n        return objects;\n    }\n\n    public static TestObject testObjectWithId(int id) {\n        return TestObject.createObject(id, useEnglishWord ? englishString() : string());\n    }\n\n    public static Value[] testRowWithId(int id) {\n        return new Value[]{new Value(id), new Value(useEnglishWord ? englishString() : string())};\n    }\n\n}\n"
  },
  {
    "path": "src/java/test/src/androidTest/java/com/tencent/wcdbtest/base/TableTestCase.java",
    "content": "// Created by qiuwenchen on 2023/5/8.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage com.tencent.wcdbtest.base;\n\nimport com.tencent.wcdb.base.WCDBException;\nimport com.tencent.wcdb.core.Table;\nimport com.tencent.wcdb.orm.TableBinding;\nimport com.tencent.wcdb.winq.Column;\nimport com.tencent.wcdb.winq.ColumnDef;\nimport com.tencent.wcdb.winq.ColumnType;\nimport com.tencent.wcdb.winq.StatementCreateTable;\n\nimport org.junit.Assert;\n\nimport java.util.Collections;\nimport java.util.List;\nimport java.util.Arrays;\nimport java.util.ArrayList;\n\npublic class TableTestCase extends DatabaseTestCase {\n    public String tableName = \"testTable\";\n    public TableBinding<TestObject> tableBinding = DBTestObject.INSTANCE;\n    public boolean isVirtualTable = false;\n    public Table<TestObject> table;\n\n    public void createTable() throws WCDBException {\n        if (!isVirtualTable) {\n            database.createTable(tableName, tableBinding);\n        } else {\n            database.createVirtualTable(tableName, tableBinding);\n        }\n        table = database.getTable(tableName, tableBinding);\n    }\n\n    public void createValueTable() throws WCDBException {\n        StatementCreateTable createTable = new StatementCreateTable().createTable(tableName);\n        createTable.define(new ColumnDef(\"id\", ColumnType.Integer).makePrimary(true));\n        createTable.define(new ColumnDef(\"content\", ColumnType.Text));\n        database.execute(createTable);\n    }\n\n    public Column[] columns() {\n        return new Column[]{new Column(\"id\"), new Column(\"content\")};\n    }\n\n    public void createVirtualTable() throws WCDBException {\n        database.createVirtualTable(tableName, tableBinding);\n        table = database.getTable(tableName, tableBinding);\n    }\n\n    public void dropTable() throws WCDBException {\n        database.dropTable(tableName);\n    }\n\n    public void doTestObjectsAfterInsert(List objects, int insertCount, String[] sqls, TestOperation operation) {\n        if (insertCount > 1) {\n            List<String> list = new ArrayList<String>(Arrays.asList(sqls));\n            list.add(0, \"BEGIN IMMEDIATE\");\n            list.add(\"COMMIT\");\n            sqls = list.toArray(new String[0]);\n        }\n        doTestObjectsAfterOperation(objects, sqls, operation);\n    }\n\n    public void doTestObjectsAfterOperation(List objects, String sql, TestOperation operation) {\n        doTestObjectsAfterOperation(objects, new String[]{sql}, operation);\n    }\n\n    public void doTestObjectsAfterOperation(List objects, String[] sqls, TestOperation operation) {\n        doTestSQLs(sqls, operation);\n        List<TestObject> allObjects;\n        try {\n            allObjects = getAllObjects();\n        } catch (WCDBException e) {\n            throw new RuntimeException(e);\n        }\n        Assert.assertTrue(((objects == null || objects.size() == 0) &&\n                (allObjects == null || allObjects.size() == 0)) || objects.equals(allObjects));\n    }\n\n    public interface SelectingObjectOperation {\n        List<TestObject> execute() throws WCDBException;\n    }\n\n    public void doTestObjectBySelecting(TestObject object, String sql, SelectingObjectOperation operation) {\n        doTestObjectBySelecting(Collections.singletonList(object), new String[]{sql}, operation);\n    }\n\n    public void doTestObjectBySelecting(List<TestObject> objects, String sql, SelectingObjectOperation operation) {\n        doTestObjectBySelecting(objects, new String[]{sql}, operation);\n    }\n\n    public void doTestObjectBySelecting(List<TestObject> objects, String[] sqls, final SelectingObjectOperation operation) {\n        final List<TestObject> selecting = new ArrayList<TestObject>();\n        doTestSQLs(sqls, new TestOperation() {\n            @Override\n            public void execute() throws WCDBException {\n                selecting.addAll(operation.execute());\n            }\n        });\n        Assert.assertTrue(((objects == null || objects.size() == 0) &&\n                selecting.size() == 0) || objects.equals(selecting));\n    }\n\n    public List<TestObject> getAllObjects() throws WCDBException {\n        return table.getAllObjects();\n    }\n}\n"
  },
  {
    "path": "src/java/test/src/androidTest/java/com/tencent/wcdbtest/base/TestObject.java",
    "content": "// Created by qiuwenchen on 2023/4/14.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdbtest.base;\n\nimport androidx.annotation.Nullable;\n\nimport com.tencent.wcdb.*;\n\n@WCDBTableCoding\npublic class TestObject {\n    @WCDBField(isPrimary = true, isAutoIncrement = true)\n    public int id;\n    @WCDBField\n    public String content;\n\n    @Override\n    public boolean equals(@Nullable Object obj) {\n        if (obj instanceof TestObject) {\n            TestObject testObject = (TestObject) obj;\n            if (testObject.id != id) {\n                return false;\n            }\n            if (content == null) {\n                return testObject.content == null || testObject.content.length() <= 0;\n            } else if (testObject.content == null) {\n                return content.length() <= 0;\n            }\n            return testObject.content.equals(content);\n        } else {\n            return super.equals(obj);\n        }\n    }\n\n    public static TestObject createObject(int id, String content) {\n        TestObject obj = new TestObject();\n        obj.id = id;\n        obj.content = content;\n        return obj;\n    }\n\n    public static TestObject createPartialObject(int id) {\n        TestObject obj = new TestObject();\n        obj.id = id;\n        return obj;\n    }\n\n    public static TestObject createAutoIncrementObject(String content) {\n        TestObject obj = new TestObject();\n        obj.id = 0;\n        obj.content = content;\n        return obj;\n    }\n}\n"
  },
  {
    "path": "src/java/test/src/androidTest/java/com/tencent/wcdbtest/base/ValueCRUDTestCase.java",
    "content": "// Created by chenqiuwen on 2023/5/14.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdbtest.base;\n\nimport com.tencent.wcdb.base.WCDBException;\n\nimport org.junit.Before;\n\npublic class ValueCRUDTestCase extends CRUDTestCase {\n    @Before\n    public void setup() throws WCDBException {\n        super.setup();\n        insertPresetRows();\n    }\n}\n"
  },
  {
    "path": "src/java/test/src/androidTest/java/com/tencent/wcdbtest/base/WinqTool.java",
    "content": "package com.tencent.wcdbtest.base;\n\nimport com.tencent.wcdb.winq.Identifier;\n\nimport org.junit.Assert;\n\npublic class WinqTool {\n    public static void winqEqual(Identifier winq, String sql) {\n        Assert.assertEquals(sql, winq.getDescription());\n    }\n}\n"
  },
  {
    "path": "src/java/test/src/androidTest/java/com/tencent/wcdbtest/base/WrappedValue.java",
    "content": "// Created by qiuwenchen on 2023/5/10.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage com.tencent.wcdbtest.base;\n\npublic class WrappedValue {\n    public boolean boolValue = false;\n    public long intValue = 0;\n    public String stringValue = null;\n    public double doubleValue = 0;\n\n    public static WrappedValue currentTime() {\n        WrappedValue date = new WrappedValue();\n        date.intValue = System.currentTimeMillis();\n        return date;\n    }\n}\n"
  },
  {
    "path": "src/java/test/src/androidTest/java/com/tencent/wcdbtest/crud/ChainCallTest.java",
    "content": "// Created by qiuwenchen on 2023/5/15.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdbtest.crud;\n\nimport com.tencent.wcdb.base.WCDBException;\nimport com.tencent.wcdb.chaincall.Delete;\nimport com.tencent.wcdb.chaincall.Insert;\nimport com.tencent.wcdb.chaincall.Select;\nimport com.tencent.wcdb.chaincall.Update;\nimport com.tencent.wcdbtest.base.DBTestObject;\nimport com.tencent.wcdbtest.base.ObjectCRUDTestCase;\nimport com.tencent.wcdbtest.base.TestObject;\n\nimport static com.tencent.wcdbtest.base.WinqTool.*;\n\nimport org.junit.Test;\n\npublic class ChainCallTest extends ObjectCRUDTestCase {\n    @Test\n    public void testDatabaseDelete() throws WCDBException {\n        Delete delete = database.prepareDelete().fromTable(tableName);\n        winqEqual(delete.getStatement(), \"DELETE FROM testTable\");\n    }\n\n    @Test\n    public void testTableDelete() throws WCDBException {\n        Delete delete = table.prepareDelete();\n        winqEqual(delete.getStatement(), \"DELETE FROM testTable\");\n    }\n\n    @Test\n    public void testHandleDelete() throws WCDBException {\n        Delete delete = handle.prepareDelete().fromTable(tableName);\n        winqEqual(delete.getStatement(), \"DELETE FROM testTable\");\n    }\n\n    @Test\n    public void testDatabaseInsert() throws WCDBException {\n        Insert<TestObject> insert = database.<TestObject>prepareInsert().intoTable(tableName).onFields(DBTestObject.allFields());\n        winqEqual(insert.getStatement(), \"INSERT INTO testTable(id, content) VALUES(?1, ?2)\");\n    }\n\n    @Test\n    public void testTableInsert() throws WCDBException {\n        Insert<TestObject> insert = table.prepareInsert().onFields(DBTestObject.allFields());\n        winqEqual(insert.getStatement(), \"INSERT INTO testTable(id, content) VALUES(?1, ?2)\");\n    }\n\n    @Test\n    public void testHandleInsert() throws WCDBException {\n        Insert<TestObject> insert = handle.<TestObject>prepareInsert().intoTable(tableName).onFields(DBTestObject.allFields());\n        winqEqual(insert.getStatement(), \"INSERT INTO testTable(id, content) VALUES(?1, ?2)\");\n    }\n\n    @Test\n    public void testDatabaseUpdate() throws WCDBException {\n        Update<TestObject> update = database.<TestObject>prepareUpdate().table(tableName).set(DBTestObject.content);\n        winqEqual(update.getStatement(), \"UPDATE testTable SET content = ?1\");\n    }\n\n    @Test\n    public void testTableUpdate() throws WCDBException {\n        Update<TestObject> update = table.prepareUpdate().set(DBTestObject.content);\n        winqEqual(update.getStatement(), \"UPDATE testTable SET content = ?1\");\n    }\n\n    @Test\n    public void testHandleUpdate() throws WCDBException {\n        Update<TestObject> update = handle.<TestObject>prepareUpdate().table(tableName).set(DBTestObject.content);\n        winqEqual(update.getStatement(), \"UPDATE testTable SET content = ?1\");\n    }\n\n    @Test\n    public void testDatabaseSelect() throws WCDBException {\n        Select<TestObject> select = database.<TestObject>prepareSelect().select(DBTestObject.allFields()).from(tableName).where(DBTestObject.id.eq(1));\n        winqEqual(select.getStatement(), \"SELECT id, content FROM testTable WHERE id == 1\");\n    }\n\n    @Test\n    public void testTableSelect() throws WCDBException {\n        Select<TestObject> select = table.prepareSelect().select(DBTestObject.allFields()).where(DBTestObject.id.eq(1));\n        winqEqual(select.getStatement(), \"SELECT id, content FROM testTable WHERE id == 1\");\n    }\n\n    @Test\n    public void testHandleSelect() throws WCDBException {\n        Select<TestObject> select = handle.<TestObject>prepareSelect().select(DBTestObject.allFields()).from(tableName).where(DBTestObject.id.eq(1));\n        winqEqual(select.getStatement(), \"SELECT id, content FROM testTable WHERE id == 1\");\n    }\n}\n"
  },
  {
    "path": "src/java/test/src/androidTest/java/com/tencent/wcdbtest/crud/FTSTest.java",
    "content": "// Created by qiuwenchen on 2024/2/22.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdbtest.crud;\n\nimport com.tencent.wcdb.core.Database;\nimport com.tencent.wcdb.core.Table;\nimport com.tencent.wcdb.fts.BuiltinTokenizer;\nimport com.tencent.wcdbtest.base.DBPinyinObject;\nimport com.tencent.wcdbtest.base.DBTestObject;\nimport com.tencent.wcdbtest.base.DBTraditionalChineseObject;\nimport com.tencent.wcdbtest.base.DatabaseTestCase;\nimport com.tencent.wcdbtest.base.PinyinObject;\nimport com.tencent.wcdbtest.base.TestObject;\nimport com.tencent.wcdbtest.base.TraditionalChineseObject;\nimport com.tencent.wcdbtest.orm.testclass.DBFTS3TestObject;\nimport com.tencent.wcdbtest.orm.testclass.DBFTS5TestObject;\nimport com.tencent.wcdbtest.orm.testclass.DBMMICUTestObject;\nimport com.tencent.wcdbtest.orm.testclass.FTS3TestObject;\nimport com.tencent.wcdbtest.orm.testclass.FTS5TestObject;\nimport com.tencent.wcdbtest.orm.testclass.MMICUTestObject;\n\nimport org.junit.Assert;\nimport org.junit.Test;\n\nimport java.util.ArrayList;\nimport java.util.Arrays;\nimport java.util.Collections;\nimport java.util.HashMap;\nimport java.util.List;\n\npublic class FTSTest extends DatabaseTestCase {\n    String tableName = \"ftsTable\";\n\n    @Test\n    public void testFTS3() {\n        database.addTokenizer(BuiltinTokenizer.OneOrBinary);\n        database.createVirtualTable(tableName, DBFTS3TestObject.INSTANCE);\n        Table<FTS3TestObject> table = database.getTable(tableName, DBFTS3TestObject.INSTANCE);\n        FTS3TestObject englishObject = new FTS3TestObject(1, \"This is English test content\");\n        FTS3TestObject chineseObject = new FTS3TestObject(2, \"这是中文测试内容\");\n        FTS3TestObject numericObject = new FTS3TestObject(1, \"123456\");\n        FTS3TestObject symbolicObject = new FTS3TestObject(1, \"abc..def\");\n        table.insertObjects(Arrays.asList(englishObject, chineseObject, numericObject, symbolicObject));\n\n        // English\n        List<FTS3TestObject> matchEnglishObjects = table.getAllObjects(DBFTS3TestObject.content.match(\"Engl*\"));\n        Assert.assertTrue(matchEnglishObjects.size() == 1 && matchEnglishObjects.get(0).content.equals(englishObject.content));\n\n        // Chinese\n        List<FTS3TestObject> matchChineseObjects = table.getAllObjects(DBFTS3TestObject.content.match(\"中文\"));\n        Assert.assertTrue(matchChineseObjects.size() == 1 && matchChineseObjects.get(0).content.equals(chineseObject.content));\n\n        // Numeric\n        List<FTS3TestObject> matchNumericObjects = table.getAllObjects(DBFTS3TestObject.content.match(\"123*\"));\n        Assert.assertTrue(matchNumericObjects.size() == 1 && matchNumericObjects.get(0).content.equals(numericObject.content));\n\n        // Symbolic\n        List<FTS3TestObject> matchSymbolicObjects = table.getAllObjects(DBFTS3TestObject.content.match(\"def*\"));\n        Assert.assertTrue(matchSymbolicObjects.size() == 1 && matchSymbolicObjects.get(0).content.equals(symbolicObject.content));\n    }\n\n    @Test\n    public void testMMICU() {\n        database.addTokenizer(BuiltinTokenizer.MMICU);\n        database.createVirtualTable(tableName, DBMMICUTestObject.INSTANCE);\n        Table<MMICUTestObject> table = database.getTable(tableName, DBMMICUTestObject.INSTANCE);\n        MMICUTestObject englishObject = new MMICUTestObject(1, \"This is English test content\");\n        MMICUTestObject chineseObject = new MMICUTestObject(2, \"这是中文测试内容\");\n        MMICUTestObject numericObject = new MMICUTestObject(1, \"123456\");\n        MMICUTestObject symbolicObject = new MMICUTestObject(1, \"abc..def\");\n        MMICUTestObject emptyObject = new MMICUTestObject(3, \"\");\n        table.insertObjects(Arrays.asList(englishObject, chineseObject, numericObject, symbolicObject));\n\n        // English\n        List<MMICUTestObject> matchEnglishObjects = table.getAllObjects(DBMMICUTestObject.content.match(\"Engl*\"));\n        Assert.assertTrue(matchEnglishObjects.size() == 1 && matchEnglishObjects.get(0).content.equals(englishObject.content));\n\n        // Chinese\n        List<MMICUTestObject> matchChineseObjects = table.getAllObjects(DBMMICUTestObject.content.match(\"中文\"));\n        Assert.assertTrue(matchChineseObjects.size() == 1 && matchChineseObjects.get(0).content.equals(chineseObject.content));\n\n        // Numeric\n        List<MMICUTestObject> matchNumericObjects = table.getAllObjects(DBMMICUTestObject.content.match(\"123*\"));\n        Assert.assertTrue(matchNumericObjects.size() == 1 && matchNumericObjects.get(0).content.equals(numericObject.content));\n\n        // Symbolic\n        List<MMICUTestObject> matchSymbolicObjects = table.getAllObjects(DBMMICUTestObject.content.match(\"def*\"));\n        Assert.assertTrue(matchSymbolicObjects.size() == 1 && matchSymbolicObjects.get(0).content.equals(symbolicObject.content));\n    }\n\n    @Test\n    public void testFTS5() {\n        database.addTokenizer(BuiltinTokenizer.Verbatim);\n        database.createVirtualTable(tableName, DBFTS5TestObject.INSTANCE);\n        Table<FTS5TestObject> table = database.getTable(tableName, DBFTS5TestObject.INSTANCE);\n        FTS5TestObject englishObject = new FTS5TestObject(1, \"This is English test content\");\n        FTS5TestObject chineseObject = new FTS5TestObject(2, \"这是中文测试内容\");\n        FTS5TestObject numericObject = new FTS5TestObject(3, \"123456\");\n        FTS5TestObject symbolicObject = new FTS5TestObject(4, \"abc..def\");\n        List<FTS5TestObject> allObjects = Arrays.asList(englishObject, chineseObject, numericObject, symbolicObject);\n        table.insertObjects(allObjects);\n\n        // External content object\n        database.createTable(\"contentTable\", DBTestObject.INSTANCE);\n        Table<TestObject> contentTable = database.getTable(\"contentTable\", DBTestObject.INSTANCE);\n        List<TestObject> allContentObjects = new ArrayList<>();\n        for (FTS5TestObject object : allObjects) {\n            TestObject contentObject = TestObject.createObject(object.id, object.content);\n            allContentObjects.add(contentObject);\n        }\n        contentTable.insertObjects(allContentObjects);\n\n        // English\n        List<FTS5TestObject> matchEnglishObjects = table.getAllObjects(DBFTS5TestObject.content.match(\"Engl*\"));\n        Assert.assertTrue(matchEnglishObjects.size() == 1 && matchEnglishObjects.get(0).content.equals(englishObject.content));\n\n        // Chinese\n        List<FTS5TestObject> matchChineseObjects = table.getAllObjects(DBFTS5TestObject.content.match(\"中文\"));\n        Assert.assertTrue(matchChineseObjects.size() == 1 && matchChineseObjects.get(0).content.equals(chineseObject.content));\n\n        // Numeric\n        List<FTS5TestObject> matchNumericObjects = table.getAllObjects(DBFTS5TestObject.content.match(\"123*\"));\n        Assert.assertTrue(matchNumericObjects.size() == 1 && matchNumericObjects.get(0).content.equals(numericObject.content));\n\n        // Symbolic\n        List<FTS5TestObject> matchSymbolicObjects = table.getAllObjects(DBFTS5TestObject.content.match(\"def*\"));\n        Assert.assertTrue(matchSymbolicObjects.size() == 1 && matchSymbolicObjects.get(0).content.equals(symbolicObject.content));\n    }\n\n    @Test\n    public void testPinyin() {\n        Database.configPinyinDict(new HashMap<String, List<String>>() {{\n            put(\"单\", Arrays.asList(\"shan\", \"dan\", \"chan\"));\n            put(\"于\", Collections.singletonList(\"yu\"));\n            put(\"骑\", Collections.singletonList(\"qi\"));\n            put(\"模\", Arrays.asList(\"mo\", \"mu\"));\n            put(\"具\", Collections.singletonList(\"ju\"));\n            put(\"车\", Collections.singletonList(\"che\"));\n        }});\n        database.addTokenizer(BuiltinTokenizer.Pinyin);\n        database.createVirtualTable(tableName, DBPinyinObject.INSTANCE);\n\n        PinyinObject obj = new PinyinObject();\n        obj.content = \"单于骑模具单车\";\n        database.insertObject(obj, DBPinyinObject.allFields(), tableName);\n\n        String[] queries = new String[]{\n                \"\\\"shan yu qi mu ju dan che\\\"\",\n                \"\\\"chan yu qi mo ju shan che\\\"\",\n                \"\\\"dan yu qi mo ju chan che\\\"\",\n                \"\\\"dan yu qi mu ju ch\\\"*\",\n                \"\\\"dan yu qi mo ju d\\\"*\",\n                \"\\\"s y q m j d c\\\"\",\n                \"\\\"c y q m j s c\\\"\",\n                \"\\\"c y q m j\\\"\"\n        };\n\n        for (String query : queries) {\n            List<PinyinObject> results = database.getAllObjects(DBPinyinObject.allFields(),\n                    tableName, DBPinyinObject.content.match(query));\n            assert results.size() == 1;\n            assert results.get(0).content.equals(obj.content);\n        }\n    }\n\n    @Test\n    public void testTraditionalChinese() {\n        Database.configTraditionalChineseDict(new HashMap<String, String>() {{\n            put(\"們\", \"们\");\n            put(\"員\", \"员\");\n        }});\n        database.addTokenizer(BuiltinTokenizer.Verbatim);\n        database.createVirtualTable(tableName, DBTraditionalChineseObject.INSTANCE);\n        Table<TraditionalChineseObject> table = database.getTable(tableName, DBTraditionalChineseObject.INSTANCE);\n\n        TraditionalChineseObject obj = new TraditionalChineseObject();\n        obj.content = \"我們是程序員\";\n        table.insertObject(obj);\n\n        List<TraditionalChineseObject> matchObject1 = table.getAllObjects(DBTraditionalChineseObject.content.match(\"我們是程序員\"));\n        Assert.assertTrue(matchObject1.size() == 1 && matchObject1.get(0).content.equals(obj.content));\n\n        List<TraditionalChineseObject> matchObject2 = table.getAllObjects(DBTraditionalChineseObject.content.match(\"我们是程序员\"));\n        Assert.assertTrue(matchObject2.size() == 1 && matchObject2.get(0).content.equals(obj.content));\n    }\n}\n"
  },
  {
    "path": "src/java/test/src/androidTest/java/com/tencent/wcdbtest/crud/ObjectDeleteTest.java",
    "content": "// Created by chenqiuwen on 2023/5/14.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdbtest.crud;\n\nimport static org.junit.Assert.assertEquals;\n\nimport com.tencent.wcdb.base.WCDBException;\nimport com.tencent.wcdb.winq.Order;\nimport com.tencent.wcdbtest.base.DBTestObject;\nimport com.tencent.wcdbtest.base.ObjectCRUDTestCase;\n\nimport org.junit.Test;\n\npublic class ObjectDeleteTest extends ObjectCRUDTestCase {\n\n    @Test\n    public void testDatabaseDelete() {\n        doTestSQL(\"DELETE FROM testTable\", new TestOperation() {\n            @Override\n            public void execute() throws WCDBException {\n                database.deleteObjects(tableName);\n            }\n        });\n        assertEquals(allRowsCount(), 0);\n    }\n\n    @Test\n    public void testDatabaseDeleteWhere() {\n        doTestSQL(\"DELETE FROM testTable WHERE id == 1\", new TestOperation() {\n            @Override\n            public void execute() throws WCDBException {\n                database.deleteObjects(tableName, DBTestObject.id.eq(1));\n            }\n        });\n        assertEquals(allRowsCount(), 1);\n    }\n\n    @Test\n    public void testDatabaseDeleteOrderLimit() {\n        doTestSQL(\"DELETE FROM testTable ORDER BY content DESC LIMIT 1\", new TestOperation() {\n            @Override\n            public void execute() throws WCDBException {\n                database.deleteObjects(tableName, DBTestObject.content.order(Order.Desc), 1);\n            }\n        });\n        assertEquals(allRowsCount(), 1);\n    }\n\n    @Test\n    public void testDatabaseDeleteOrderLimitOffset() {\n        doTestSQL(\"DELETE FROM testTable ORDER BY content DESC LIMIT 1 OFFSET 1\", new TestOperation() {\n            @Override\n            public void execute() throws WCDBException {\n                database.deleteObjects(tableName, DBTestObject.content.order(Order.Desc), 1, 1);\n            }\n        });\n        assertEquals(allRowsCount(), 1);\n    }\n\n    @Test\n    public void testDatabaseDeleteWhereOrderLimit() {\n        doTestSQL(\"DELETE FROM testTable WHERE id IN(1, 3) ORDER BY content DESC LIMIT 1\", new TestOperation() {\n            @Override\n            public void execute() throws WCDBException {\n                database.deleteObjects(tableName, DBTestObject.id.in(new int[]{1, 3}), DBTestObject.content.order(Order.Desc), 1);\n            }\n        });\n        assertEquals(allRowsCount(), 1);\n    }\n\n    @Test\n    public void testDatabaseDeleteWhereOrderLimitOffset() {\n        doTestSQL(\"DELETE FROM testTable WHERE id IN(1, 2) ORDER BY content DESC LIMIT 1 OFFSET 1\", new TestOperation() {\n            @Override\n            public void execute() throws WCDBException {\n                database.deleteObjects(tableName, DBTestObject.id.in(new int[]{1, 2}), DBTestObject.content.order(Order.Desc), 1, 1);\n            }\n        });\n        assertEquals(allRowsCount(), 1);\n    }\n\n    @Test\n    public void testTableDelete() {\n        doTestSQL(\"DELETE FROM testTable\", new TestOperation() {\n            @Override\n            public void execute() throws WCDBException {\n                table.deleteObjects();\n            }\n        });\n        assertEquals(allRowsCount(), 0);\n    }\n\n    @Test\n    public void testTableDeleteWhere() {\n        doTestSQL(\"DELETE FROM testTable WHERE id == 1\", new TestOperation() {\n            @Override\n            public void execute() throws WCDBException {\n                table.deleteObjects(DBTestObject.id.eq(1));\n            }\n        });\n        assertEquals(allRowsCount(), 1);\n    }\n\n    @Test\n    public void testTableDeleteOrderLimit() {\n        doTestSQL(\"DELETE FROM testTable ORDER BY content DESC LIMIT 1\", new TestOperation() {\n            @Override\n            public void execute() throws WCDBException {\n                table.deleteObjects(DBTestObject.content.order(Order.Desc), 1);\n            }\n        });\n        assertEquals(allRowsCount(), 1);\n    }\n\n    @Test\n    public void testTableDeleteOrderLimitOffset() {\n        doTestSQL(\"DELETE FROM testTable ORDER BY content DESC LIMIT 1 OFFSET 1\", new TestOperation() {\n            @Override\n            public void execute() throws WCDBException {\n                table.deleteObjects(DBTestObject.content.order(Order.Desc), 1, 1);\n            }\n        });\n        assertEquals(allRowsCount(), 1);\n    }\n\n    @Test\n    public void testTableDeleteWhereOrderLimit() {\n        doTestSQL(\"DELETE FROM testTable WHERE id IN(1, 3) ORDER BY content DESC LIMIT 1\", new TestOperation() {\n            @Override\n            public void execute() throws WCDBException {\n                table.deleteObjects(DBTestObject.id.in(new int[]{1, 3}), DBTestObject.content.order(Order.Desc), 1);\n            }\n        });\n        assertEquals(allRowsCount(), 1);\n    }\n\n    @Test\n    public void testTableDeleteWhereOrderLimitOffset() {\n        doTestSQL(\"DELETE FROM testTable WHERE id IN(1, 2) ORDER BY content DESC LIMIT 1 OFFSET 1\", new TestOperation() {\n            @Override\n            public void execute() throws WCDBException {\n                table.deleteObjects(DBTestObject.id.in(new int[]{1, 2}), DBTestObject.content.order(Order.Desc), 1, 1);\n            }\n        });\n        assertEquals(allRowsCount(), 1);\n    }\n\n    @Test\n    public void testHandleDelete() {\n        doTestSQL(\"DELETE FROM testTable\", new TestOperation() {\n            @Override\n            public void execute() throws WCDBException {\n                handle.deleteObjects(tableName);\n            }\n        });\n        assertEquals(allRowsCount(), 0);\n    }\n\n    @Test\n    public void testHandleDeleteWhere() {\n        doTestSQL(\"DELETE FROM testTable WHERE id == 1\", new TestOperation() {\n            @Override\n            public void execute() throws WCDBException {\n                handle.deleteObjects(tableName, DBTestObject.id.eq(1));\n            }\n        });\n        assertEquals(allRowsCount(), 1);\n    }\n\n    @Test\n    public void testHandleDeleteOrderLimit() {\n        doTestSQL(\"DELETE FROM testTable ORDER BY content DESC LIMIT 1\", new TestOperation() {\n            @Override\n            public void execute() throws WCDBException {\n                handle.deleteObjects(tableName, DBTestObject.content.order(Order.Desc), 1);\n            }\n        });\n        assertEquals(allRowsCount(), 1);\n    }\n\n    @Test\n    public void testHandleDeleteOrderLimitOffset() {\n        doTestSQL(\"DELETE FROM testTable ORDER BY content DESC LIMIT 1 OFFSET 1\", new TestOperation() {\n            @Override\n            public void execute() throws WCDBException {\n                handle.deleteObjects(tableName, DBTestObject.content.order(Order.Desc), 1, 1);\n            }\n        });\n        assertEquals(allRowsCount(), 1);\n    }\n\n    @Test\n    public void testHandleDeleteWhereOrderLimit() {\n        doTestSQL(\"DELETE FROM testTable WHERE id IN(1, 3) ORDER BY content DESC LIMIT 1\", new TestOperation() {\n            @Override\n            public void execute() throws WCDBException {\n                handle.deleteObjects(tableName, DBTestObject.id.in(new int[]{1, 3}), DBTestObject.content.order(Order.Desc), 1);\n            }\n        });\n        assertEquals(allRowsCount(), 1);\n    }\n\n    @Test\n    public void testHandleDeleteWhereOrderLimitOffset() {\n        doTestSQL(\"DELETE FROM testTable WHERE id IN(1, 2) ORDER BY content DESC LIMIT 1 OFFSET 1\", new TestOperation() {\n            @Override\n            public void execute() throws WCDBException {\n                handle.deleteObjects(tableName, DBTestObject.id.in(new int[]{1, 2}), DBTestObject.content.order(Order.Desc), 1, 1);\n            }\n        });\n        assertEquals(allRowsCount(), 1);\n    }\n}\n"
  },
  {
    "path": "src/java/test/src/androidTest/java/com/tencent/wcdbtest/crud/ObjectInsertTest.java",
    "content": "// Created by chenqiuwen on 2023/5/14.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdbtest.crud;\n\nimport com.tencent.wcdb.base.WCDBException;\nimport com.tencent.wcdb.orm.Field;\nimport com.tencent.wcdbtest.base.DBTestObject;\nimport com.tencent.wcdbtest.base.ObjectCRUDTestCase;\nimport com.tencent.wcdbtest.base.RandomTool;\nimport com.tencent.wcdbtest.base.TestObject;\n\nimport static org.junit.Assert.*;\n\nimport org.junit.Before;\nimport org.junit.Test;\n\nimport java.util.Arrays;\n\npublic class ObjectInsertTest extends ObjectCRUDTestCase {\n    TestObject renewObject1;\n    TestObject renewObject2;\n\n    TestObject renewedPartialObject1;\n    TestObject renewedPartialObject2;\n\n    TestObject object3;\n    TestObject object4;\n\n    TestObject partialObject3;\n    TestObject partialObject4;\n\n    @Before\n    public void setup() throws WCDBException {\n        super.setup();\n        renewObject1 = RandomTool.testObjectWithId(1);\n        renewObject2 = RandomTool.testObjectWithId(2);\n        renewedPartialObject1 = TestObject.createPartialObject(1);\n        renewedPartialObject2 = TestObject.createPartialObject(2);\n        object3 = RandomTool.testObjectWithId(3);\n        object4 = RandomTool.testObjectWithId(4);\n        partialObject3 = TestObject.createPartialObject(3);\n        partialObject4 = TestObject.createPartialObject(4);\n    }\n\n    @Test\n    public void testDatabaseAutoIncrement() {\n        final TestObject autoIncrementObject = TestObject.createAutoIncrementObject(object3.content);\n        doTestObjectsAfterInsert(Arrays.asList(object1, object2, object3), 1, new String[]{\n                \"INSERT INTO testTable(id, content) VALUES(?1, ?2)\"\n        }, new TestOperation() {\n            @Override\n            public void execute() throws WCDBException {\n                database.insertObject(autoIncrementObject, DBTestObject.allFields(), tableName);\n            }\n        });\n        assertEquals(autoIncrementObject, object3);\n    }\n\n    @Test\n    public void testDatabaseAutoIncrementWithPartialInsert() {\n        final TestObject autoIncrementObject = TestObject.createAutoIncrementObject(object3.content);\n        doTestObjectsAfterInsert(Arrays.asList(object1, object2, object3), 1, new String[]{\n                \"INSERT INTO testTable(content) VALUES(?1)\"\n        }, new TestOperation() {\n            @Override\n            public void execute() throws WCDBException {\n                database.insertObject(autoIncrementObject, new Field[]{DBTestObject.content}, tableName);\n            }\n        });\n        assertEquals(autoIncrementObject, object3);\n    }\n\n    @Test\n    public void testDatabaseInsertObject() {\n        doTestObjectsAfterInsert(Arrays.asList(object1, object2, object3), 1, new String[]{\n                \"INSERT INTO testTable(id, content) VALUES(?1, ?2)\"\n        }, new TestOperation() {\n            @Override\n            public void execute() throws WCDBException {\n                database.insertObject(object3, DBTestObject.allFields(), tableName);\n            }\n        });\n    }\n\n    @Test\n    public void testDatabaseInsertObjects() {\n        expectMode = Expect.SomeSQLs;\n        doTestObjectsAfterInsert(Arrays.asList(object1, object2, object3, object4), 2, new String[]{\n                \"INSERT INTO testTable(id, content) VALUES(?1, ?2)\"\n        }, new TestOperation() {\n            @Override\n            public void execute() throws WCDBException {\n                database.insertObjects(Arrays.asList(object3, object4), DBTestObject.allFields(), tableName);\n            }\n        });\n    }\n\n    @Test\n    public void testDatabaseInsertOrReplaceObject() {\n        doTestObjectsAfterInsert(Arrays.asList(renewObject1, object2), 1, new String[]{\n                \"INSERT OR REPLACE INTO testTable(id, content) VALUES(?1, ?2)\"\n        }, new TestOperation() {\n            @Override\n            public void execute() throws WCDBException {\n                database.insertOrReplaceObject(renewObject1, DBTestObject.allFields(), tableName);\n            }\n        });\n    }\n\n    @Test\n    public void testDatabaseInsertOrReplaceObjects() {\n        expectMode = Expect.SomeSQLs;\n        doTestObjectsAfterInsert(Arrays.asList(renewObject1, renewObject2), 2, new String[]{\n                \"INSERT OR REPLACE INTO testTable(id, content) VALUES(?1, ?2)\"\n        }, new TestOperation() {\n            @Override\n            public void execute() throws WCDBException {\n                database.insertOrReplaceObjects(Arrays.asList(renewObject1, renewObject2), DBTestObject.allFields(), tableName);\n            }\n        });\n    }\n\n    @Test\n    public void testDatabaseInsertOrIgnoreObject() {\n        doTestObjectsAfterInsert(Arrays.asList(object1, object2), 1, new String[]{\n                \"INSERT OR IGNORE INTO testTable(id, content) VALUES(?1, ?2)\"\n        }, new TestOperation() {\n            @Override\n            public void execute() throws WCDBException {\n                database.insertOrIgnoreObject(renewObject1, DBTestObject.allFields(), tableName);\n            }\n        });\n    }\n\n    @Test\n    public void testDatabaseInsertOrIgnoreObjects() {\n        expectMode = Expect.SomeSQLs;\n        doTestObjectsAfterInsert(Arrays.asList(object1, object2), 2, new String[]{\n                \"INSERT OR IGNORE INTO testTable(id, content) VALUES(?1, ?2)\"\n        }, new TestOperation() {\n            @Override\n            public void execute() throws WCDBException {\n                database.insertOrIgnoreObjects(Arrays.asList(renewObject1, renewObject2), DBTestObject.allFields(), tableName);\n            }\n        });\n    }\n\n    @Test\n    public void testDatabaseInsertObjectOnFields() {\n        doTestObjectsAfterInsert(Arrays.asList(object1, object2, partialObject3), 1, new String[]{\n                \"INSERT INTO testTable(id) VALUES(?1)\"\n        }, new TestOperation() {\n            @Override\n            public void execute() throws WCDBException {\n                database.insertObject(object3, new Field[]{DBTestObject.id}, tableName);\n            }\n        });\n    }\n\n    @Test\n    public void testDatabaseInsertObjectsOnFields() {\n        expectMode = Expect.SomeSQLs;\n        doTestObjectsAfterInsert(Arrays.asList(object1, object2, partialObject3, partialObject4), 2, new String[]{\n                \"INSERT INTO testTable(id) VALUES(?1)\"\n        }, new TestOperation() {\n            @Override\n            public void execute() throws WCDBException {\n                database.insertObjects(Arrays.asList(object3, object4), new Field[]{DBTestObject.id}, tableName);\n            }\n        });\n    }\n\n    @Test\n    public void testDatabaseInsertOrReplaceObjectOnFields() {\n        doTestObjectsAfterInsert(Arrays.asList(renewedPartialObject1, object2), 1, new String[]{\n                \"INSERT OR REPLACE INTO testTable(id) VALUES(?1)\"\n        }, new TestOperation() {\n            @Override\n            public void execute() throws WCDBException {\n                database.insertOrReplaceObject(object1, new Field[]{DBTestObject.id}, tableName);\n            }\n        });\n    }\n\n    @Test\n    public void testDatabaseInsertOrReplaceObjectsOnFields() {\n        expectMode = Expect.SomeSQLs;\n        doTestObjectsAfterInsert(Arrays.asList(renewedPartialObject1, renewedPartialObject2), 2, new String[]{\n                \"INSERT OR REPLACE INTO testTable(id) VALUES(?1)\"\n        }, new TestOperation() {\n            @Override\n            public void execute() throws WCDBException {\n                database.insertOrReplaceObjects(Arrays.asList(object1, object2), new Field[]{DBTestObject.id}, tableName);\n            }\n        });\n    }\n\n    @Test\n    public void testDatabaseInsertOrIgnoreObjectOnFields() {\n        doTestObjectsAfterInsert(Arrays.asList(object1, object2), 1, new String[]{\n                \"INSERT OR IGNORE INTO testTable(id) VALUES(?1)\"\n        }, new TestOperation() {\n            @Override\n            public void execute() throws WCDBException {\n                database.insertOrIgnoreObject(object1, new Field[]{DBTestObject.id}, tableName);\n            }\n        });\n    }\n\n    @Test\n    public void testDatabaseInsertOrIgnoreObjectsOnFields() {\n        expectMode = Expect.SomeSQLs;\n        doTestObjectsAfterInsert(Arrays.asList(object1, object2), 2, new String[]{\n                \"INSERT OR IGNORE INTO testTable(id) VALUES(?1)\"\n        }, new TestOperation() {\n            @Override\n            public void execute() throws WCDBException {\n                database.insertOrIgnoreObjects(Arrays.asList(object1, object2), new Field[]{DBTestObject.id}, tableName);\n            }\n        });\n    }\n\n    @Test\n    public void testTableAutoIncrement() {\n        final TestObject autoIncrementObject = TestObject.createAutoIncrementObject(object3.content);\n        doTestObjectsAfterInsert(Arrays.asList(object1, object2, object3), 1, new String[]{\n                \"INSERT INTO testTable(id, content) VALUES(?1, ?2)\"\n        }, new TestOperation() {\n            @Override\n            public void execute() throws WCDBException {\n                table.insertObject(autoIncrementObject);\n            }\n        });\n        assertEquals(autoIncrementObject, object3);\n    }\n\n    @Test\n    public void testTableAutoIncrementWithPartialInsert() {\n        final TestObject autoIncrementObject = TestObject.createAutoIncrementObject(object3.content);\n        doTestObjectsAfterInsert(Arrays.asList(object1, object2, object3), 1, new String[]{\n                \"INSERT INTO testTable(content) VALUES(?1)\"\n        }, new TestOperation() {\n            @Override\n            public void execute() throws WCDBException {\n                table.insertObject(autoIncrementObject, new Field[]{DBTestObject.content});\n            }\n        });\n        assertEquals(autoIncrementObject, object3);\n    }\n\n    @Test\n    public void testTableInsertObject() {\n        doTestObjectsAfterInsert(Arrays.asList(object1, object2, object3), 1, new String[]{\n                \"INSERT INTO testTable(id, content) VALUES(?1, ?2)\"\n        }, new TestOperation() {\n            @Override\n            public void execute() throws WCDBException {\n                table.insertObject(object3);\n            }\n        });\n    }\n\n    @Test\n    public void testTableInsertObjects() {\n        expectMode = Expect.SomeSQLs;\n        doTestObjectsAfterInsert(Arrays.asList(object1, object2, object3, object4), 2, new String[]{\n                \"INSERT INTO testTable(id, content) VALUES(?1, ?2)\"\n        }, new TestOperation() {\n            @Override\n            public void execute() throws WCDBException {\n                table.insertObjects(Arrays.asList(object3, object4));\n            }\n        });\n    }\n\n    @Test\n    public void testTableInsertOrReplaceObject() {\n        doTestObjectsAfterInsert(Arrays.asList(renewObject1, object2), 1, new String[]{\n                \"INSERT OR REPLACE INTO testTable(id, content) VALUES(?1, ?2)\"\n        }, new TestOperation() {\n            @Override\n            public void execute() throws WCDBException {\n                table.insertOrReplaceObject(renewObject1);\n            }\n        });\n    }\n\n    @Test\n    public void testTableInsertOrReplaceObjects() {\n        expectMode = Expect.SomeSQLs;\n        doTestObjectsAfterInsert(Arrays.asList(renewObject1, renewObject2), 2, new String[]{\n                \"INSERT OR REPLACE INTO testTable(id, content) VALUES(?1, ?2)\"\n        }, new TestOperation() {\n            @Override\n            public void execute() throws WCDBException {\n                table.insertOrReplaceObjects(Arrays.asList(renewObject1, renewObject2));\n            }\n        });\n    }\n\n    @Test\n    public void testTableInsertOrIgnoreObject() {\n        doTestObjectsAfterInsert(Arrays.asList(object1, object2), 1, new String[]{\n                \"INSERT OR IGNORE INTO testTable(id, content) VALUES(?1, ?2)\"\n        }, new TestOperation() {\n            @Override\n            public void execute() throws WCDBException {\n                table.insertOrIgnoreObject(renewObject1);\n            }\n        });\n    }\n\n    @Test\n    public void testTableInsertOrIgnoreObjects() {\n        expectMode = Expect.SomeSQLs;\n        doTestObjectsAfterInsert(Arrays.asList(object1, object2), 2, new String[]{\n                \"INSERT OR IGNORE INTO testTable(id, content) VALUES(?1, ?2)\"\n        }, new TestOperation() {\n            @Override\n            public void execute() throws WCDBException {\n                table.insertOrIgnoreObjects(Arrays.asList(renewObject1, renewObject2));\n            }\n        });\n    }\n\n    @Test\n    public void testTableInsertObjectOnFields() {\n        doTestObjectsAfterInsert(Arrays.asList(object1, object2, partialObject3), 1, new String[]{\n                \"INSERT INTO testTable(id) VALUES(?1)\"\n        }, new TestOperation() {\n            @Override\n            public void execute() throws WCDBException {\n                table.insertObject(object3, new Field[]{DBTestObject.id});\n            }\n        });\n    }\n\n    @Test\n    public void testTableInsertObjectsOnFields() {\n        expectMode = Expect.SomeSQLs;\n        doTestObjectsAfterInsert(Arrays.asList(object1, object2, partialObject3, partialObject4), 2, new String[]{\n                \"INSERT INTO testTable(id) VALUES(?1)\"\n        }, new TestOperation() {\n            @Override\n            public void execute() throws WCDBException {\n                table.insertObjects(Arrays.asList(object3, object4), new Field[]{DBTestObject.id});\n            }\n        });\n    }\n\n    @Test\n    public void testTableInsertOrReplaceObjectOnFields() {\n        doTestObjectsAfterInsert(Arrays.asList(renewedPartialObject1, object2), 1, new String[]{\n                \"INSERT OR REPLACE INTO testTable(id) VALUES(?1)\"\n        }, new TestOperation() {\n            @Override\n            public void execute() throws WCDBException {\n                table.insertOrReplaceObject(object1, new Field[]{DBTestObject.id});\n            }\n        });\n    }\n\n    @Test\n    public void testTableInsertOrReplaceObjectsOnFields() {\n        expectMode = Expect.SomeSQLs;\n        doTestObjectsAfterInsert(Arrays.asList(renewedPartialObject1, renewedPartialObject2), 2, new String[]{\n                \"INSERT OR REPLACE INTO testTable(id) VALUES(?1)\"\n        }, new TestOperation() {\n            @Override\n            public void execute() throws WCDBException {\n                table.insertOrReplaceObjects(Arrays.asList(object1, object2), new Field[]{DBTestObject.id});\n            }\n        });\n    }\n\n    @Test\n    public void testTableInsertOrIgnoreObjectOnFields() {\n        doTestObjectsAfterInsert(Arrays.asList(object1, object2), 1, new String[]{\n                \"INSERT OR IGNORE INTO testTable(id) VALUES(?1)\"\n        }, new TestOperation() {\n            @Override\n            public void execute() throws WCDBException {\n                table.insertOrIgnoreObject(object1, new Field[]{DBTestObject.id});\n            }\n        });\n    }\n\n    @Test\n    public void testTableInsertOrIgnoreObjectsOnFields() {\n        expectMode = Expect.SomeSQLs;\n        doTestObjectsAfterInsert(Arrays.asList(object1, object2), 2, new String[]{\n                \"INSERT OR IGNORE INTO testTable(id) VALUES(?1)\"\n        }, new TestOperation() {\n            @Override\n            public void execute() throws WCDBException {\n                table.insertOrIgnoreObjects(Arrays.asList(object1, object2), new Field[]{DBTestObject.id});\n            }\n        });\n    }\n\n    @Test\n    public void testHandleAutoIncrement() {\n        final TestObject autoIncrementObject = TestObject.createAutoIncrementObject(object3.content);\n        doTestObjectsAfterInsert(Arrays.asList(object1, object2, object3), 1, new String[]{\n                \"INSERT INTO testTable(id, content) VALUES(?1, ?2)\"\n        }, new TestOperation() {\n            @Override\n            public void execute() throws WCDBException {\n                handle.insertObject(autoIncrementObject, DBTestObject.allFields(), tableName);\n            }\n        });\n        assertEquals(autoIncrementObject, object3);\n    }\n\n    @Test\n    public void testHandleAutoIncrementWithPartialInsert() {\n        final TestObject autoIncrementObject = TestObject.createAutoIncrementObject(object3.content);\n        doTestObjectsAfterInsert(Arrays.asList(object1, object2, object3), 1, new String[]{\n                \"INSERT INTO testTable(content) VALUES(?1)\"\n        }, new TestOperation() {\n            @Override\n            public void execute() throws WCDBException {\n                handle.insertObject(autoIncrementObject, new Field[]{DBTestObject.content}, tableName);\n            }\n        });\n        assertEquals(autoIncrementObject, object3);\n    }\n\n    @Test\n    public void testHandleInsertObject() {\n        doTestObjectsAfterInsert(Arrays.asList(object1, object2, object3), 1, new String[]{\n                \"INSERT INTO testTable(id, content) VALUES(?1, ?2)\"\n        }, new TestOperation() {\n            @Override\n            public void execute() throws WCDBException {\n                handle.insertObject(object3, DBTestObject.allFields(), tableName);\n            }\n        });\n    }\n\n    @Test\n    public void testHandleInsertObjects() {\n        expectMode = Expect.SomeSQLs;\n        doTestObjectsAfterInsert(Arrays.asList(object1, object2, object3, object4), 2, new String[]{\n                \"INSERT INTO testTable(id, content) VALUES(?1, ?2)\"\n        }, new TestOperation() {\n            @Override\n            public void execute() throws WCDBException {\n                handle.insertObjects(Arrays.asList(object3, object4), DBTestObject.allFields(), tableName);\n            }\n        });\n    }\n\n    @Test\n    public void testHandleInsertOrReplaceObject() {\n        doTestObjectsAfterInsert(Arrays.asList(renewObject1, object2), 1, new String[]{\n                \"INSERT OR REPLACE INTO testTable(id, content) VALUES(?1, ?2)\"\n        }, new TestOperation() {\n            @Override\n            public void execute() throws WCDBException {\n                handle.insertOrReplaceObject(renewObject1, DBTestObject.allFields(), tableName);\n            }\n        });\n    }\n\n    @Test\n    public void testHandleInsertOrReplaceObjects() {\n        expectMode = Expect.SomeSQLs;\n        doTestObjectsAfterInsert(Arrays.asList(renewObject1, renewObject2), 2, new String[]{\n                \"INSERT OR REPLACE INTO testTable(id, content) VALUES(?1, ?2)\"\n        }, new TestOperation() {\n            @Override\n            public void execute() throws WCDBException {\n                handle.insertOrReplaceObjects(Arrays.asList(renewObject1, renewObject2), DBTestObject.allFields(), tableName);\n            }\n        });\n    }\n\n    @Test\n    public void testHandleInsertOrIgnoreObject() {\n        doTestObjectsAfterInsert(Arrays.asList(object1, object2), 1, new String[]{\n                \"INSERT OR IGNORE INTO testTable(id, content) VALUES(?1, ?2)\"\n        }, new TestOperation() {\n            @Override\n            public void execute() throws WCDBException {\n                handle.insertOrIgnoreObject(renewObject1, DBTestObject.allFields(), tableName);\n            }\n        });\n    }\n\n    @Test\n    public void testHandleInsertOrIgnoreObjects() {\n        expectMode = Expect.SomeSQLs;\n        doTestObjectsAfterInsert(Arrays.asList(object1, object2), 2, new String[]{\n                \"INSERT OR IGNORE INTO testTable(id, content) VALUES(?1, ?2)\"\n        }, new TestOperation() {\n            @Override\n            public void execute() throws WCDBException {\n                handle.insertOrIgnoreObjects(Arrays.asList(renewObject1, renewObject2), DBTestObject.allFields(), tableName);\n            }\n        });\n    }\n\n    @Test\n    public void testHandleInsertObjectOnFields() {\n        doTestObjectsAfterInsert(Arrays.asList(object1, object2, partialObject3), 1, new String[]{\n                \"INSERT INTO testTable(id) VALUES(?1)\"\n        }, new TestOperation() {\n            @Override\n            public void execute() throws WCDBException {\n                handle.insertObject(object3, new Field[]{DBTestObject.id}, tableName);\n            }\n        });\n    }\n\n    @Test\n    public void testHandleInsertObjectsOnFields() {\n        expectMode = Expect.SomeSQLs;\n        doTestObjectsAfterInsert(Arrays.asList(object1, object2, partialObject3, partialObject4), 2, new String[]{\n                \"INSERT INTO testTable(id) VALUES(?1)\"\n        }, new TestOperation() {\n            @Override\n            public void execute() throws WCDBException {\n                handle.insertObjects(Arrays.asList(object3, object4), new Field[]{DBTestObject.id}, tableName);\n            }\n        });\n    }\n\n    @Test\n    public void testHandleInsertOrReplaceObjectOnFields() {\n        doTestObjectsAfterInsert(Arrays.asList(renewedPartialObject1, object2), 1, new String[]{\n                \"INSERT OR REPLACE INTO testTable(id) VALUES(?1)\"\n        }, new TestOperation() {\n            @Override\n            public void execute() throws WCDBException {\n                handle.insertOrReplaceObject(object1, new Field[]{DBTestObject.id}, tableName);\n            }\n        });\n    }\n\n    @Test\n    public void testHandleInsertOrReplaceObjectsOnFields() {\n        expectMode = Expect.SomeSQLs;\n        doTestObjectsAfterInsert(Arrays.asList(renewedPartialObject1, renewedPartialObject2), 2, new String[]{\n                \"INSERT OR REPLACE INTO testTable(id) VALUES(?1)\"\n        }, new TestOperation() {\n            @Override\n            public void execute() throws WCDBException {\n                handle.insertOrReplaceObjects(Arrays.asList(object1, object2), new Field[]{DBTestObject.id}, tableName);\n            }\n        });\n    }\n\n    @Test\n    public void testHandleInsertOrIgnoreObjectOnFields() {\n        doTestObjectsAfterInsert(Arrays.asList(object1, object2), 1, new String[]{\n                \"INSERT OR IGNORE INTO testTable(id) VALUES(?1)\"\n        }, new TestOperation() {\n            @Override\n            public void execute() throws WCDBException {\n                handle.insertOrIgnoreObject(object1, new Field[]{DBTestObject.id}, tableName);\n            }\n        });\n    }\n\n    @Test\n    public void testHandleInsertOrIgnoreObjectsOnFields() {\n        expectMode = Expect.SomeSQLs;\n        doTestObjectsAfterInsert(Arrays.asList(object1, object2), 2, new String[]{\n                \"INSERT OR IGNORE INTO testTable(id) VALUES(?1)\"\n        }, new TestOperation() {\n            @Override\n            public void execute() throws WCDBException {\n                handle.insertOrIgnoreObjects(Arrays.asList(object1, object2), new Field[]{DBTestObject.id}, tableName);\n            }\n        });\n    }\n}\n"
  },
  {
    "path": "src/java/test/src/androidTest/java/com/tencent/wcdbtest/crud/ObjectSelectTest.java",
    "content": "// Created by chenqiuwen on 2023/5/14.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdbtest.crud;\n\nimport com.tencent.wcdb.base.WCDBException;\nimport com.tencent.wcdb.orm.Field;\nimport com.tencent.wcdb.winq.Order;\nimport com.tencent.wcdbtest.base.DBTestObject;\nimport com.tencent.wcdbtest.base.ObjectCRUDTestCase;\nimport com.tencent.wcdbtest.base.TestObject;\n\nimport org.junit.Before;\nimport org.junit.Test;\n\nimport java.util.Arrays;\nimport java.util.Collections;\nimport java.util.List;\n\npublic class ObjectSelectTest extends ObjectCRUDTestCase {\n    TestObject partialObject1;\n    TestObject partialObject2;\n    List<TestObject> partialObjects;\n\n    @Before\n    public void setup() throws WCDBException {\n        super.setup();\n        partialObject1 = TestObject.createPartialObject(1);\n        partialObject2 = TestObject.createPartialObject(2);\n        partialObjects = Arrays.asList(partialObject1, partialObject2);\n    }\n\n    @Test\n    public void testDatabaseGetObject() {\n        doTestObjectBySelecting(object1, \"SELECT id, content FROM testTable\", new SelectingObjectOperation() {\n            @Override\n            public List<TestObject> execute() throws WCDBException {\n                return Collections.singletonList(database.getFirstObject(DBTestObject.allFields(), tableName));\n            }\n        });\n    }\n\n    @Test\n    public void testDatabaseGetObjectWhere() {\n        doTestObjectBySelecting(object2, \"SELECT id, content FROM testTable WHERE id == 2\", new SelectingObjectOperation() {\n            @Override\n            public List<TestObject> execute() throws WCDBException {\n                return Collections.singletonList(database.getFirstObject(DBTestObject.allFields(), tableName, DBTestObject.id.eq(2)));\n            }\n        });\n    }\n\n    @Test\n    public void testDatabaseGetObjectWhereOrder() {\n        doTestObjectBySelecting(object2, \"SELECT id, content FROM testTable WHERE id > 0 ORDER BY id DESC\", new SelectingObjectOperation() {\n            @Override\n            public List<TestObject> execute() throws WCDBException {\n                return Collections.singletonList(database.getFirstObject(DBTestObject.allFields(), tableName, DBTestObject.id.gt(0), DBTestObject.id.order(Order.Desc)));\n            }\n        });\n    }\n\n    @Test\n    public void testDatabaseGetObjectWhereOrderOffset() {\n        doTestObjectBySelecting(object1, \"SELECT id, content FROM testTable WHERE id > 0 ORDER BY id DESC LIMIT 1 OFFSET 1\", new SelectingObjectOperation() {\n            @Override\n            public List<TestObject> execute() throws WCDBException {\n                return Collections.singletonList(database.getFirstObject(DBTestObject.allFields(), tableName, DBTestObject.id.gt(0), DBTestObject.id.order(Order.Desc), 1));\n            }\n        });\n    }\n\n    @Test\n    public void testDatabaseGetObjectOrder() {\n        doTestObjectBySelecting(object2, \"SELECT id, content FROM testTable ORDER BY id DESC\", new SelectingObjectOperation() {\n            @Override\n            public List<TestObject> execute() throws WCDBException {\n                return Collections.singletonList(database.getFirstObject(DBTestObject.allFields(), tableName, DBTestObject.id.order(Order.Desc)));\n            }\n        });\n    }\n\n    @Test\n    public void testDatabaseGetObjectOrderOffset() {\n        doTestObjectBySelecting(object1, \"SELECT id, content FROM testTable ORDER BY id DESC LIMIT 1 OFFSET 1\", new SelectingObjectOperation() {\n            @Override\n            public List<TestObject> execute() throws WCDBException {\n                return Collections.singletonList(database.getFirstObject(DBTestObject.allFields(), tableName, DBTestObject.id.order(Order.Desc), 1));\n            }\n        });\n    }\n\n    @Test\n    public void testDatabaseGetObjects() {\n        doTestObjectBySelecting(objects, \"SELECT id, content FROM testTable\", new SelectingObjectOperation() {\n            @Override\n            public List<TestObject> execute() throws WCDBException {\n                return database.getAllObjects(DBTestObject.allFields(), tableName);\n            }\n        });\n    }\n\n    @Test\n    public void testDatabaseGetObjectsWhere() {\n        doTestObjectBySelecting(object1, \"SELECT id, content FROM testTable WHERE id == 1\", new SelectingObjectOperation() {\n            @Override\n            public List<TestObject> execute() throws WCDBException {\n                return database.getAllObjects(DBTestObject.allFields(), tableName, DBTestObject.id.eq(1));\n            }\n        });\n    }\n\n    @Test\n    public void testDatabaseGetObjectsWhereOrder() {\n        doTestObjectBySelecting(Arrays.asList(object2, object1), \"SELECT id, content FROM testTable WHERE id > 0 ORDER BY id DESC\", new SelectingObjectOperation() {\n            @Override\n            public List<TestObject> execute() throws WCDBException {\n                return database.getAllObjects(DBTestObject.allFields(), tableName, DBTestObject.id.gt(0), DBTestObject.id.order(Order.Desc));\n            }\n        });\n    }\n\n    @Test\n    public void testDatabaseGetObjectsWhereOrderLimit() {\n        doTestObjectBySelecting(object2, \"SELECT id, content FROM testTable WHERE id > 0 ORDER BY id DESC LIMIT 1\", new SelectingObjectOperation() {\n            @Override\n            public List<TestObject> execute() throws WCDBException {\n                return database.getAllObjects(DBTestObject.allFields(), tableName, DBTestObject.id.gt(0), DBTestObject.id.order(Order.Desc), 1);\n            }\n        });\n    }\n\n    @Test\n    public void testDatabaseGetObjectsWhereOrderLimitOffset() {\n        doTestObjectBySelecting(object1, \"SELECT id, content FROM testTable WHERE id > 0 ORDER BY id DESC LIMIT 1 OFFSET 1\", new SelectingObjectOperation() {\n            @Override\n            public List<TestObject> execute() throws WCDBException {\n                return database.getAllObjects(DBTestObject.allFields(), tableName, DBTestObject.id.gt(0), DBTestObject.id.order(Order.Desc), 1, 1);\n            }\n        });\n    }\n\n    @Test\n    public void testDatabaseGetObjectsOrder() {\n        doTestObjectBySelecting(Arrays.asList(object2, object1), \"SELECT id, content FROM testTable ORDER BY id DESC\", new SelectingObjectOperation() {\n            @Override\n            public List<TestObject> execute() throws WCDBException {\n                return database.getAllObjects(DBTestObject.allFields(), tableName, DBTestObject.id.order(Order.Desc));\n            }\n        });\n    }\n\n    @Test\n    public void testDatabaseGetObjectsOrderLimit() {\n        doTestObjectBySelecting(object2, \"SELECT id, content FROM testTable ORDER BY id DESC LIMIT 1\", new SelectingObjectOperation() {\n            @Override\n            public List<TestObject> execute() throws WCDBException {\n                return database.getAllObjects(DBTestObject.allFields(), tableName, DBTestObject.id.order(Order.Desc), 1);\n            }\n        });\n    }\n\n    @Test\n    public void testDatabaseGetObjectsOrderLimitOffset() {\n        doTestObjectBySelecting(object1, \"SELECT id, content FROM testTable ORDER BY id DESC LIMIT 1 OFFSET 1\", new SelectingObjectOperation() {\n            @Override\n            public List<TestObject> execute() throws WCDBException {\n                return database.getAllObjects(DBTestObject.allFields(), tableName, DBTestObject.id.order(Order.Desc), 1, 1);\n            }\n        });\n    }\n\n    @Test\n    public void testDatabaseGetObjectOnFields() {\n        doTestObjectBySelecting(partialObject1, \"SELECT id FROM testTable\", new SelectingObjectOperation() {\n            @Override\n            public List<TestObject> execute() throws WCDBException {\n                return Collections.singletonList((TestObject) database.getFirstObject(new Field[]{DBTestObject.id}, tableName));\n            }\n        });\n    }\n\n    @Test\n    public void testDatabaseGetObjectOnFieldsWhere() {\n        doTestObjectBySelecting(partialObject2, \"SELECT id FROM testTable WHERE id == 2\", new SelectingObjectOperation() {\n            @Override\n            public List<TestObject> execute() throws WCDBException {\n                return Collections.singletonList((TestObject) database.getFirstObject(new Field[]{DBTestObject.id}, tableName, DBTestObject.id.eq(2)));\n            }\n        });\n    }\n\n    @Test\n    public void testDatabaseGetObjectOnFieldsWhereOrder() {\n        doTestObjectBySelecting(partialObject2, \"SELECT id FROM testTable WHERE id > 0 ORDER BY id DESC\", new SelectingObjectOperation() {\n            @Override\n            public List<TestObject> execute() throws WCDBException {\n                return Collections.singletonList((TestObject) database.getFirstObject(new Field[]{DBTestObject.id}, tableName, DBTestObject.id.gt(0), DBTestObject.id.order(Order.Desc)));\n            }\n        });\n    }\n\n    @Test\n    public void testDatabaseGetObjectOnFieldsWhereOrderOffset() {\n        doTestObjectBySelecting(partialObject1, \"SELECT id FROM testTable WHERE id > 0 ORDER BY id DESC LIMIT 1 OFFSET 1\", new SelectingObjectOperation() {\n            @Override\n            public List<TestObject> execute() throws WCDBException {\n                return Collections.singletonList((TestObject) database.getFirstObject(new Field[]{DBTestObject.id}, tableName, DBTestObject.id.gt(0), DBTestObject.id.order(Order.Desc), 1));\n            }\n        });\n    }\n\n    @Test\n    public void testDatabaseGetObjectOnFieldsOrder() {\n        doTestObjectBySelecting(partialObject2, \"SELECT id FROM testTable ORDER BY id DESC\", new SelectingObjectOperation() {\n            @Override\n            public List<TestObject> execute() throws WCDBException {\n                return Collections.singletonList((TestObject) database.getFirstObject(new Field[]{DBTestObject.id}, tableName, DBTestObject.id.order(Order.Desc)));\n            }\n        });\n    }\n\n    @Test\n    public void testDatabaseGetObjectOnFieldsOrderOffset() {\n        doTestObjectBySelecting(partialObject1, \"SELECT id FROM testTable ORDER BY id DESC LIMIT 1 OFFSET 1\", new SelectingObjectOperation() {\n            @Override\n            public List<TestObject> execute() throws WCDBException {\n                return Collections.singletonList((TestObject) database.getFirstObject(new Field[]{DBTestObject.id}, tableName, DBTestObject.id.order(Order.Desc), 1));\n            }\n        });\n    }\n\n    @Test\n    public void testDatabaseGetObjectsOnFields() {\n        doTestObjectBySelecting(partialObjects, \"SELECT id FROM testTable\", new SelectingObjectOperation() {\n            @Override\n            public List<TestObject> execute() throws WCDBException {\n                return database.getAllObjects(new Field[]{DBTestObject.id}, tableName);\n            }\n        });\n    }\n\n    @Test\n    public void testDatabaseGetObjectsOnFieldsWhere() {\n        doTestObjectBySelecting(partialObject1, \"SELECT id FROM testTable WHERE id == 1\", new SelectingObjectOperation() {\n            @Override\n            public List<TestObject> execute() throws WCDBException {\n                return database.getAllObjects(new Field[]{DBTestObject.id}, tableName, DBTestObject.id.eq(1));\n            }\n        });\n    }\n\n    @Test\n    public void testDatabaseGetObjectsOnFieldsWhereOrder() {\n        doTestObjectBySelecting(Arrays.asList(partialObject2, partialObject1), \"SELECT id FROM testTable WHERE id > 0 ORDER BY id DESC\", new SelectingObjectOperation() {\n            @Override\n            public List<TestObject> execute() throws WCDBException {\n                return database.getAllObjects(new Field[]{DBTestObject.id}, tableName, DBTestObject.id.gt(0), DBTestObject.id.order(Order.Desc));\n            }\n        });\n    }\n\n    @Test\n    public void testDatabaseGetObjectsOnFieldsWhereOrderLimit() {\n        doTestObjectBySelecting(partialObject2, \"SELECT id FROM testTable WHERE id > 0 ORDER BY id DESC LIMIT 1\", new SelectingObjectOperation() {\n            @Override\n            public List<TestObject> execute() throws WCDBException {\n                return database.getAllObjects(new Field[]{DBTestObject.id}, tableName, DBTestObject.id.gt(0), DBTestObject.id.order(Order.Desc), 1);\n            }\n        });\n    }\n\n    @Test\n    public void testDatabaseGetObjectsOnFieldsWhereOrderLimitOffset() {\n        doTestObjectBySelecting(partialObject1, \"SELECT id FROM testTable WHERE id > 0 ORDER BY id DESC LIMIT 1 OFFSET 1\", new SelectingObjectOperation() {\n            @Override\n            public List<TestObject> execute() throws WCDBException {\n                return database.getAllObjects(new Field[]{DBTestObject.id}, tableName, DBTestObject.id.gt(0), DBTestObject.id.order(Order.Desc), 1, 1);\n            }\n        });\n    }\n\n    @Test\n    public void testDatabaseGetObjectsOnFieldsOrder() {\n        doTestObjectBySelecting(Arrays.asList(partialObject2, partialObject1), \"SELECT id FROM testTable ORDER BY id DESC\", new SelectingObjectOperation() {\n            @Override\n            public List<TestObject> execute() throws WCDBException {\n                return database.getAllObjects(new Field[]{DBTestObject.id}, tableName, DBTestObject.id.order(Order.Desc));\n            }\n        });\n    }\n\n    @Test\n    public void testDatabaseGetObjectsOnFieldsOrderLimit() {\n        doTestObjectBySelecting(partialObject2, \"SELECT id FROM testTable ORDER BY id DESC LIMIT 1\", new SelectingObjectOperation() {\n            @Override\n            public List<TestObject> execute() throws WCDBException {\n                return database.getAllObjects(new Field[]{DBTestObject.id}, tableName, DBTestObject.id.order(Order.Desc), 1);\n            }\n        });\n    }\n\n    @Test\n    public void testDatabaseGetObjectsOnFieldsOrderLimitOffset() {\n        doTestObjectBySelecting(partialObject1, \"SELECT id FROM testTable ORDER BY id DESC LIMIT 1 OFFSET 1\", new SelectingObjectOperation() {\n            @Override\n            public List<TestObject> execute() throws WCDBException {\n                return database.getAllObjects(new Field[]{DBTestObject.id}, tableName, DBTestObject.id.order(Order.Desc), 1, 1);\n            }\n        });\n    }\n\n    @Test\n    public void testTableGetObject() {\n        doTestObjectBySelecting(object1, \"SELECT id, content FROM testTable\", new SelectingObjectOperation() {\n            @Override\n            public List<TestObject> execute() throws WCDBException {\n                return Collections.singletonList(table.getFirstObject(DBTestObject.allFields()));\n            }\n        });\n    }\n\n    @Test\n    public void testTableGetObjectWhere() {\n        doTestObjectBySelecting(object2, \"SELECT id, content FROM testTable WHERE id == 2\", new SelectingObjectOperation() {\n            @Override\n            public List<TestObject> execute() throws WCDBException {\n                return Collections.singletonList(table.getFirstObject(DBTestObject.allFields(), DBTestObject.id.eq(2)));\n            }\n        });\n    }\n\n    @Test\n    public void testTableGetObjectWhereOrder() {\n        doTestObjectBySelecting(object2, \"SELECT id, content FROM testTable WHERE id > 0 ORDER BY id DESC\", new SelectingObjectOperation() {\n            @Override\n            public List<TestObject> execute() throws WCDBException {\n                return Collections.singletonList(table.getFirstObject(DBTestObject.allFields(), DBTestObject.id.gt(0), DBTestObject.id.order(Order.Desc)));\n            }\n        });\n    }\n\n    @Test\n    public void testTableGetObjectWhereOrderOffset() {\n        doTestObjectBySelecting(object1, \"SELECT id, content FROM testTable WHERE id > 0 ORDER BY id DESC LIMIT 1 OFFSET 1\", new SelectingObjectOperation() {\n            @Override\n            public List<TestObject> execute() throws WCDBException {\n                return Collections.singletonList(table.getFirstObject(DBTestObject.allFields(), DBTestObject.id.gt(0), DBTestObject.id.order(Order.Desc), 1));\n            }\n        });\n    }\n\n    @Test\n    public void testTableGetObjectOrder() {\n        doTestObjectBySelecting(object2, \"SELECT id, content FROM testTable ORDER BY id DESC\", new SelectingObjectOperation() {\n            @Override\n            public List<TestObject> execute() throws WCDBException {\n                return Collections.singletonList(table.getFirstObject(DBTestObject.allFields(), DBTestObject.id.order(Order.Desc)));\n            }\n        });\n    }\n\n    @Test\n    public void testTableGetObjectOrderOffset() {\n        doTestObjectBySelecting(object1, \"SELECT id, content FROM testTable ORDER BY id DESC LIMIT 1 OFFSET 1\", new SelectingObjectOperation() {\n            @Override\n            public List<TestObject> execute() throws WCDBException {\n                return Collections.singletonList(table.getFirstObject(DBTestObject.allFields(), DBTestObject.id.order(Order.Desc), 1));\n            }\n        });\n    }\n\n    @Test\n    public void testTableGetObjects() {\n        doTestObjectBySelecting(objects, \"SELECT id, content FROM testTable\", new SelectingObjectOperation() {\n            @Override\n            public List<TestObject> execute() throws WCDBException {\n                return table.getAllObjects(DBTestObject.allFields());\n            }\n        });\n    }\n\n    @Test\n    public void testTableGetObjectsWhere() {\n        doTestObjectBySelecting(object1, \"SELECT id, content FROM testTable WHERE id == 1\", new SelectingObjectOperation() {\n            @Override\n            public List<TestObject> execute() throws WCDBException {\n                return table.getAllObjects(DBTestObject.allFields(), DBTestObject.id.eq(1));\n            }\n        });\n    }\n\n    @Test\n    public void testTableGetObjectsWhereOrder() {\n        doTestObjectBySelecting(Arrays.asList(object2, object1), \"SELECT id, content FROM testTable WHERE id > 0 ORDER BY id DESC\", new SelectingObjectOperation() {\n            @Override\n            public List<TestObject> execute() throws WCDBException {\n                return table.getAllObjects(DBTestObject.allFields(), DBTestObject.id.gt(0), DBTestObject.id.order(Order.Desc));\n            }\n        });\n    }\n\n    @Test\n    public void testTableGetObjectsWhereOrderLimit() {\n        doTestObjectBySelecting(object2, \"SELECT id, content FROM testTable WHERE id > 0 ORDER BY id DESC LIMIT 1\", new SelectingObjectOperation() {\n            @Override\n            public List<TestObject> execute() throws WCDBException {\n                return table.getAllObjects(DBTestObject.allFields(), DBTestObject.id.gt(0), DBTestObject.id.order(Order.Desc), 1);\n            }\n        });\n    }\n\n    @Test\n    public void testTableGetObjectsWhereOrderLimitOffset() {\n        doTestObjectBySelecting(object1, \"SELECT id, content FROM testTable WHERE id > 0 ORDER BY id DESC LIMIT 1 OFFSET 1\", new SelectingObjectOperation() {\n            @Override\n            public List<TestObject> execute() throws WCDBException {\n                return table.getAllObjects(DBTestObject.allFields(), DBTestObject.id.gt(0), DBTestObject.id.order(Order.Desc), 1, 1);\n            }\n        });\n    }\n\n    @Test\n    public void testTableGetObjectsOrder() {\n        doTestObjectBySelecting(Arrays.asList(object2, object1), \"SELECT id, content FROM testTable ORDER BY id DESC\", new SelectingObjectOperation() {\n            @Override\n            public List<TestObject> execute() throws WCDBException {\n                return table.getAllObjects(DBTestObject.allFields(), DBTestObject.id.order(Order.Desc));\n            }\n        });\n    }\n\n    @Test\n    public void testTableGetObjectsOrderLimit() {\n        doTestObjectBySelecting(object2, \"SELECT id, content FROM testTable ORDER BY id DESC LIMIT 1\", new SelectingObjectOperation() {\n            @Override\n            public List<TestObject> execute() throws WCDBException {\n                return table.getAllObjects(DBTestObject.allFields(), DBTestObject.id.order(Order.Desc), 1);\n            }\n        });\n    }\n\n    @Test\n    public void testTableGetObjectsOrderLimitOffset() {\n        doTestObjectBySelecting(object1, \"SELECT id, content FROM testTable ORDER BY id DESC LIMIT 1 OFFSET 1\", new SelectingObjectOperation() {\n            @Override\n            public List<TestObject> execute() throws WCDBException {\n                return table.getAllObjects(DBTestObject.allFields(), DBTestObject.id.order(Order.Desc), 1, 1);\n            }\n        });\n    }\n\n    @Test\n    public void testTableGetObjectOnFields() {\n        doTestObjectBySelecting(partialObject1, \"SELECT id FROM testTable\", new SelectingObjectOperation() {\n            @Override\n            public List<TestObject> execute() throws WCDBException {\n                return Collections.singletonList(table.getFirstObject(new Field[]{DBTestObject.id}));\n            }\n        });\n    }\n\n    @Test\n    public void testTableGetObjectOnFieldsWhere() {\n        doTestObjectBySelecting(partialObject2, \"SELECT id FROM testTable WHERE id == 2\", new SelectingObjectOperation() {\n            @Override\n            public List<TestObject> execute() throws WCDBException {\n                return Collections.singletonList(table.getFirstObject(new Field[]{DBTestObject.id}, DBTestObject.id.eq(2)));\n            }\n        });\n    }\n\n    @Test\n    public void testTableGetObjectOnFieldsWhereOrder() {\n        doTestObjectBySelecting(partialObject2, \"SELECT id FROM testTable WHERE id > 0 ORDER BY id DESC\", new SelectingObjectOperation() {\n            @Override\n            public List<TestObject> execute() throws WCDBException {\n                return Collections.singletonList(table.getFirstObject(new Field[]{DBTestObject.id}, DBTestObject.id.gt(0), DBTestObject.id.order(Order.Desc)));\n            }\n        });\n    }\n\n    @Test\n    public void testTableGetObjectOnFieldsWhereOrderOffset() {\n        doTestObjectBySelecting(partialObject1, \"SELECT id FROM testTable WHERE id > 0 ORDER BY id DESC LIMIT 1 OFFSET 1\", new SelectingObjectOperation() {\n            @Override\n            public List<TestObject> execute() throws WCDBException {\n                return Collections.singletonList(table.getFirstObject(new Field[]{DBTestObject.id}, DBTestObject.id.gt(0), DBTestObject.id.order(Order.Desc), 1));\n            }\n        });\n    }\n\n    @Test\n    public void testTableGetObjectOnFieldsOrder() {\n        doTestObjectBySelecting(partialObject2, \"SELECT id FROM testTable ORDER BY id DESC\", new SelectingObjectOperation() {\n            @Override\n            public List<TestObject> execute() throws WCDBException {\n                return Collections.singletonList(table.getFirstObject(new Field[]{DBTestObject.id}, DBTestObject.id.order(Order.Desc)));\n            }\n        });\n    }\n\n    @Test\n    public void testTableGetObjectOnFieldsOrderOffset() {\n        doTestObjectBySelecting(partialObject1, \"SELECT id FROM testTable ORDER BY id DESC LIMIT 1 OFFSET 1\", new SelectingObjectOperation() {\n            @Override\n            public List<TestObject> execute() throws WCDBException {\n                return Collections.singletonList(table.getFirstObject(new Field[]{DBTestObject.id}, DBTestObject.id.order(Order.Desc), 1));\n            }\n        });\n    }\n\n    @Test\n    public void testTableGetObjectsOnFields() {\n        doTestObjectBySelecting(partialObjects, \"SELECT id FROM testTable\", new SelectingObjectOperation() {\n            @Override\n            public List<TestObject> execute() throws WCDBException {\n                return table.getAllObjects(new Field[]{DBTestObject.id});\n            }\n        });\n    }\n\n    @Test\n    public void testTableGetObjectsOnFieldsWhere() {\n        doTestObjectBySelecting(partialObject1, \"SELECT id FROM testTable WHERE id == 1\", new SelectingObjectOperation() {\n            @Override\n            public List<TestObject> execute() throws WCDBException {\n                return table.getAllObjects(new Field[]{DBTestObject.id}, DBTestObject.id.eq(1));\n            }\n        });\n    }\n\n    @Test\n    public void testTableGetObjectsOnFieldsWhereOrder() {\n        doTestObjectBySelecting(Arrays.asList(partialObject2, partialObject1), \"SELECT id FROM testTable WHERE id > 0 ORDER BY id DESC\", new SelectingObjectOperation() {\n            @Override\n            public List<TestObject> execute() throws WCDBException {\n                return table.getAllObjects(new Field[]{DBTestObject.id}, DBTestObject.id.gt(0), DBTestObject.id.order(Order.Desc));\n            }\n        });\n    }\n\n    @Test\n    public void testTableGetObjectsOnFieldsWhereOrderLimit() {\n        doTestObjectBySelecting(partialObject2, \"SELECT id FROM testTable WHERE id > 0 ORDER BY id DESC LIMIT 1\", new SelectingObjectOperation() {\n            @Override\n            public List<TestObject> execute() throws WCDBException {\n                return table.getAllObjects(new Field[]{DBTestObject.id}, DBTestObject.id.gt(0), DBTestObject.id.order(Order.Desc), 1);\n            }\n        });\n    }\n\n    @Test\n    public void testTableGetObjectsOnFieldsWhereOrderLimitOffset() {\n        doTestObjectBySelecting(partialObject1, \"SELECT id FROM testTable WHERE id > 0 ORDER BY id DESC LIMIT 1 OFFSET 1\", new SelectingObjectOperation() {\n            @Override\n            public List<TestObject> execute() throws WCDBException {\n                return table.getAllObjects(new Field[]{DBTestObject.id}, DBTestObject.id.gt(0), DBTestObject.id.order(Order.Desc), 1, 1);\n            }\n        });\n    }\n\n    @Test\n    public void testTableGetObjectsOnFieldsOrder() {\n        doTestObjectBySelecting(Arrays.asList(partialObject2, partialObject1), \"SELECT id FROM testTable ORDER BY id DESC\", new SelectingObjectOperation() {\n            @Override\n            public List<TestObject> execute() throws WCDBException {\n                return table.getAllObjects(new Field[]{DBTestObject.id}, DBTestObject.id.order(Order.Desc));\n            }\n        });\n    }\n\n    @Test\n    public void testTableGetObjectsOnFieldsOrderLimit() {\n        doTestObjectBySelecting(partialObject2, \"SELECT id FROM testTable ORDER BY id DESC LIMIT 1\", new SelectingObjectOperation() {\n            @Override\n            public List<TestObject> execute() throws WCDBException {\n                return table.getAllObjects(new Field[]{DBTestObject.id}, DBTestObject.id.order(Order.Desc), 1);\n            }\n        });\n    }\n\n    @Test\n    public void testTableGetObjectsOnFieldsOrderLimitOffset() {\n        doTestObjectBySelecting(partialObject1, \"SELECT id FROM testTable ORDER BY id DESC LIMIT 1 OFFSET 1\", new SelectingObjectOperation() {\n            @Override\n            public List<TestObject> execute() throws WCDBException {\n                return table.getAllObjects(new Field[]{DBTestObject.id}, DBTestObject.id.order(Order.Desc), 1, 1);\n            }\n        });\n    }\n\n    @Test\n    public void testTableGetObjectWithoutField() {\n        doTestObjectBySelecting(object1, \"SELECT id, content FROM testTable\", new SelectingObjectOperation() {\n            @Override\n            public List<TestObject> execute() throws WCDBException {\n                return Collections.singletonList(table.getFirstObject());\n            }\n        });\n    }\n\n    @Test\n    public void testTableGetObjectWithoutFieldWhere() {\n        doTestObjectBySelecting(object2, \"SELECT id, content FROM testTable WHERE id == 2\", new SelectingObjectOperation() {\n            @Override\n            public List<TestObject> execute() throws WCDBException {\n                return Collections.singletonList(table.getFirstObject(DBTestObject.id.eq(2)));\n            }\n        });\n    }\n\n    @Test\n    public void testTableGetObjectWithoutFieldWhereOrder() {\n        doTestObjectBySelecting(object2, \"SELECT id, content FROM testTable WHERE id > 0 ORDER BY id DESC\", new SelectingObjectOperation() {\n            @Override\n            public List<TestObject> execute() throws WCDBException {\n                return Collections.singletonList(table.getFirstObject(DBTestObject.id.gt(0), DBTestObject.id.order(Order.Desc)));\n            }\n        });\n    }\n\n    @Test\n    public void testTableGetObjectWithoutFieldWhereOrderOffset() {\n        doTestObjectBySelecting(object1, \"SELECT id, content FROM testTable WHERE id > 0 ORDER BY id DESC LIMIT 1 OFFSET 1\", new SelectingObjectOperation() {\n            @Override\n            public List<TestObject> execute() throws WCDBException {\n                return Collections.singletonList(table.getFirstObject(DBTestObject.id.gt(0), DBTestObject.id.order(Order.Desc), 1));\n            }\n        });\n    }\n\n    @Test\n    public void testTableGetObjectWithoutFieldOrder() {\n        doTestObjectBySelecting(object2, \"SELECT id, content FROM testTable ORDER BY id DESC\", new SelectingObjectOperation() {\n            @Override\n            public List<TestObject> execute() throws WCDBException {\n                return Collections.singletonList(table.getFirstObject(DBTestObject.id.order(Order.Desc)));\n            }\n        });\n    }\n\n    @Test\n    public void testTableGetObjectWithoutFieldOrderOffset() {\n        doTestObjectBySelecting(object1, \"SELECT id, content FROM testTable ORDER BY id DESC LIMIT 1 OFFSET 1\", new SelectingObjectOperation() {\n            @Override\n            public List<TestObject> execute() throws WCDBException {\n                return Collections.singletonList(table.getFirstObject(DBTestObject.id.order(Order.Desc), 1));\n            }\n        });\n    }\n\n    @Test\n    public void testTableGetObjectsWithoutFields() {\n        doTestObjectBySelecting(objects, \"SELECT id, content FROM testTable\", new SelectingObjectOperation() {\n            @Override\n            public List<TestObject> execute() throws WCDBException {\n                return table.getAllObjects();\n            }\n        });\n    }\n\n    @Test\n    public void testTableGetObjectsWithoutFieldsWhere() {\n        doTestObjectBySelecting(object1, \"SELECT id, content FROM testTable WHERE id == 1\", new SelectingObjectOperation() {\n            @Override\n            public List<TestObject> execute() throws WCDBException {\n                return table.getAllObjects(DBTestObject.id.eq(1));\n            }\n        });\n    }\n\n    @Test\n    public void testTableGetObjectsWithoutFieldsWhereOrder() {\n        doTestObjectBySelecting(Arrays.asList(object2, object1), \"SELECT id, content FROM testTable WHERE id > 0 ORDER BY id DESC\", new SelectingObjectOperation() {\n            @Override\n            public List<TestObject> execute() throws WCDBException {\n                return table.getAllObjects(DBTestObject.id.gt(0), DBTestObject.id.order(Order.Desc));\n            }\n        });\n    }\n\n    @Test\n    public void testTableGetObjectsWithoutFieldsWhereOrderLimit() {\n        doTestObjectBySelecting(object2, \"SELECT id, content FROM testTable WHERE id > 0 ORDER BY id DESC LIMIT 1\", new SelectingObjectOperation() {\n            @Override\n            public List<TestObject> execute() throws WCDBException {\n                return table.getAllObjects(DBTestObject.id.gt(0), DBTestObject.id.order(Order.Desc), 1);\n            }\n        });\n    }\n\n    @Test\n    public void testTableGetObjectsWithoutFieldsWhereOrderLimitOffset() {\n        doTestObjectBySelecting(object1, \"SELECT id, content FROM testTable WHERE id > 0 ORDER BY id DESC LIMIT 1 OFFSET 1\", new SelectingObjectOperation() {\n            @Override\n            public List<TestObject> execute() throws WCDBException {\n                return table.getAllObjects(DBTestObject.id.gt(0), DBTestObject.id.order(Order.Desc), 1, 1);\n            }\n        });\n    }\n\n    @Test\n    public void testTableGetObjectsWithoutFieldsOrder() {\n        doTestObjectBySelecting(Arrays.asList(object2, object1), \"SELECT id, content FROM testTable ORDER BY id DESC\", new SelectingObjectOperation() {\n            @Override\n            public List<TestObject> execute() throws WCDBException {\n                return table.getAllObjects(DBTestObject.id.order(Order.Desc));\n            }\n        });\n    }\n\n    @Test\n    public void testTableGetObjectsWithoutFieldsOrderLimit() {\n        doTestObjectBySelecting(object2, \"SELECT id, content FROM testTable ORDER BY id DESC LIMIT 1\", new SelectingObjectOperation() {\n            @Override\n            public List<TestObject> execute() throws WCDBException {\n                return table.getAllObjects(DBTestObject.id.order(Order.Desc), 1);\n            }\n        });\n    }\n\n    @Test\n    public void testTableGetObjectsWithoutFieldsOrderLimitOffset() {\n        doTestObjectBySelecting(object1, \"SELECT id, content FROM testTable ORDER BY id DESC LIMIT 1 OFFSET 1\", new SelectingObjectOperation() {\n            @Override\n            public List<TestObject> execute() throws WCDBException {\n                return table.getAllObjects(DBTestObject.id.order(Order.Desc), 1, 1);\n            }\n        });\n    }\n\n    @Test\n    public void testHandleGetObject() {\n        doTestObjectBySelecting(object1, \"SELECT id, content FROM testTable\", new SelectingObjectOperation() {\n            @Override\n            public List<TestObject> execute() throws WCDBException {\n                return Collections.singletonList(handle.getFirstObject(DBTestObject.allFields(), tableName));\n            }\n        });\n    }\n\n    @Test\n    public void testHandleGetObjectWhere() {\n        doTestObjectBySelecting(object2, \"SELECT id, content FROM testTable WHERE id == 2\", new SelectingObjectOperation() {\n            @Override\n            public List<TestObject> execute() throws WCDBException {\n                return Collections.singletonList(handle.getFirstObject(DBTestObject.allFields(), tableName, DBTestObject.id.eq(2)));\n            }\n        });\n    }\n\n    @Test\n    public void testHandleGetObjectWhereOrder() {\n        doTestObjectBySelecting(object2, \"SELECT id, content FROM testTable WHERE id > 0 ORDER BY id DESC\", new SelectingObjectOperation() {\n            @Override\n            public List<TestObject> execute() throws WCDBException {\n                return Collections.singletonList(handle.getFirstObject(DBTestObject.allFields(), tableName, DBTestObject.id.gt(0), DBTestObject.id.order(Order.Desc)));\n            }\n        });\n    }\n\n    @Test\n    public void testHandleGetObjectWhereOrderOffset() {\n        doTestObjectBySelecting(object1, \"SELECT id, content FROM testTable WHERE id > 0 ORDER BY id DESC LIMIT 1 OFFSET 1\", new SelectingObjectOperation() {\n            @Override\n            public List<TestObject> execute() throws WCDBException {\n                return Collections.singletonList(handle.getFirstObject(DBTestObject.allFields(), tableName, DBTestObject.id.gt(0), DBTestObject.id.order(Order.Desc), 1));\n            }\n        });\n    }\n\n    @Test\n    public void testHandleGetObjectOrder() {\n        doTestObjectBySelecting(object2, \"SELECT id, content FROM testTable ORDER BY id DESC\", new SelectingObjectOperation() {\n            @Override\n            public List<TestObject> execute() throws WCDBException {\n                return Collections.singletonList(handle.getFirstObject(DBTestObject.allFields(), tableName, DBTestObject.id.order(Order.Desc)));\n            }\n        });\n    }\n\n    @Test\n    public void testHandleGetObjectOrderOffset() {\n        doTestObjectBySelecting(object1, \"SELECT id, content FROM testTable ORDER BY id DESC LIMIT 1 OFFSET 1\", new SelectingObjectOperation() {\n            @Override\n            public List<TestObject> execute() throws WCDBException {\n                return Collections.singletonList(handle.getFirstObject(DBTestObject.allFields(), tableName, DBTestObject.id.order(Order.Desc), 1));\n            }\n        });\n    }\n\n    @Test\n    public void testHandleGetObjects() {\n        doTestObjectBySelecting(objects, \"SELECT id, content FROM testTable\", new SelectingObjectOperation() {\n            @Override\n            public List<TestObject> execute() throws WCDBException {\n                return handle.getAllObjects(DBTestObject.allFields(), tableName);\n            }\n        });\n    }\n\n    @Test\n    public void testHandleGetObjectsWhere() {\n        doTestObjectBySelecting(object1, \"SELECT id, content FROM testTable WHERE id == 1\", new SelectingObjectOperation() {\n            @Override\n            public List<TestObject> execute() throws WCDBException {\n                return handle.getAllObjects(DBTestObject.allFields(), tableName, DBTestObject.id.eq(1));\n            }\n        });\n    }\n\n    @Test\n    public void testHandleGetObjectsWhereOrder() {\n        doTestObjectBySelecting(Arrays.asList(object2, object1), \"SELECT id, content FROM testTable WHERE id > 0 ORDER BY id DESC\", new SelectingObjectOperation() {\n            @Override\n            public List<TestObject> execute() throws WCDBException {\n                return handle.getAllObjects(DBTestObject.allFields(), tableName, DBTestObject.id.gt(0), DBTestObject.id.order(Order.Desc));\n            }\n        });\n    }\n\n    @Test\n    public void testHandleGetObjectsWhereOrderLimit() {\n        doTestObjectBySelecting(object2, \"SELECT id, content FROM testTable WHERE id > 0 ORDER BY id DESC LIMIT 1\", new SelectingObjectOperation() {\n            @Override\n            public List<TestObject> execute() throws WCDBException {\n                return handle.getAllObjects(DBTestObject.allFields(), tableName, DBTestObject.id.gt(0), DBTestObject.id.order(Order.Desc), 1);\n            }\n        });\n    }\n\n    @Test\n    public void testHandleGetObjectsWhereOrderLimitOffset() {\n        doTestObjectBySelecting(object1, \"SELECT id, content FROM testTable WHERE id > 0 ORDER BY id DESC LIMIT 1 OFFSET 1\", new SelectingObjectOperation() {\n            @Override\n            public List<TestObject> execute() throws WCDBException {\n                return handle.getAllObjects(DBTestObject.allFields(), tableName, DBTestObject.id.gt(0), DBTestObject.id.order(Order.Desc), 1, 1);\n            }\n        });\n    }\n\n    @Test\n    public void testHandleGetObjectsOrder() {\n        doTestObjectBySelecting(Arrays.asList(object2, object1), \"SELECT id, content FROM testTable ORDER BY id DESC\", new SelectingObjectOperation() {\n            @Override\n            public List<TestObject> execute() throws WCDBException {\n                return handle.getAllObjects(DBTestObject.allFields(), tableName, DBTestObject.id.order(Order.Desc));\n            }\n        });\n    }\n\n    @Test\n    public void testHandleGetObjectsOrderLimit() {\n        doTestObjectBySelecting(object2, \"SELECT id, content FROM testTable ORDER BY id DESC LIMIT 1\", new SelectingObjectOperation() {\n            @Override\n            public List<TestObject> execute() throws WCDBException {\n                return handle.getAllObjects(DBTestObject.allFields(), tableName, DBTestObject.id.order(Order.Desc), 1);\n            }\n        });\n    }\n\n    @Test\n    public void testHandleGetObjectsOrderLimitOffset() {\n        doTestObjectBySelecting(object1, \"SELECT id, content FROM testTable ORDER BY id DESC LIMIT 1 OFFSET 1\", new SelectingObjectOperation() {\n            @Override\n            public List<TestObject> execute() throws WCDBException {\n                return handle.getAllObjects(DBTestObject.allFields(), tableName, DBTestObject.id.order(Order.Desc), 1, 1);\n            }\n        });\n    }\n\n    @Test\n    public void testHandleGetObjectOnFields() {\n        doTestObjectBySelecting(partialObject1, \"SELECT id FROM testTable\", new SelectingObjectOperation() {\n            @Override\n            public List<TestObject> execute() throws WCDBException {\n                return Collections.singletonList((TestObject) handle.getFirstObject(new Field[]{DBTestObject.id}, tableName));\n            }\n        });\n    }\n\n    @Test\n    public void testHandleGetObjectOnFieldsWhere() {\n        doTestObjectBySelecting(partialObject2, \"SELECT id FROM testTable WHERE id == 2\", new SelectingObjectOperation() {\n            @Override\n            public List<TestObject> execute() throws WCDBException {\n                return Collections.singletonList((TestObject) handle.getFirstObject(new Field[]{DBTestObject.id}, tableName, DBTestObject.id.eq(2)));\n            }\n        });\n    }\n\n    @Test\n    public void testHandleGetObjectOnFieldsWhereOrder() {\n        doTestObjectBySelecting(partialObject2, \"SELECT id FROM testTable WHERE id > 0 ORDER BY id DESC\", new SelectingObjectOperation() {\n            @Override\n            public List<TestObject> execute() throws WCDBException {\n                return Collections.singletonList((TestObject) handle.getFirstObject(new Field[]{DBTestObject.id}, tableName, DBTestObject.id.gt(0), DBTestObject.id.order(Order.Desc)));\n            }\n        });\n    }\n\n    @Test\n    public void testHandleGetObjectOnFieldsWhereOrderOffset() {\n        doTestObjectBySelecting(partialObject1, \"SELECT id FROM testTable WHERE id > 0 ORDER BY id DESC LIMIT 1 OFFSET 1\", new SelectingObjectOperation() {\n            @Override\n            public List<TestObject> execute() throws WCDBException {\n                return Collections.singletonList((TestObject) handle.getFirstObject(new Field[]{DBTestObject.id}, tableName, DBTestObject.id.gt(0), DBTestObject.id.order(Order.Desc), 1));\n            }\n        });\n    }\n\n    @Test\n    public void testHandleGetObjectOnFieldsOrder() {\n        doTestObjectBySelecting(partialObject2, \"SELECT id FROM testTable ORDER BY id DESC\", new SelectingObjectOperation() {\n            @Override\n            public List<TestObject> execute() throws WCDBException {\n                return Collections.singletonList((TestObject) handle.getFirstObject(new Field[]{DBTestObject.id}, tableName, DBTestObject.id.order(Order.Desc)));\n            }\n        });\n    }\n\n    @Test\n    public void testHandleGetObjectOnFieldsOrderOffset() {\n        doTestObjectBySelecting(partialObject1, \"SELECT id FROM testTable ORDER BY id DESC LIMIT 1 OFFSET 1\", new SelectingObjectOperation() {\n            @Override\n            public List<TestObject> execute() throws WCDBException {\n                return Collections.singletonList((TestObject) handle.getFirstObject(new Field[]{DBTestObject.id}, tableName, DBTestObject.id.order(Order.Desc), 1));\n            }\n        });\n    }\n\n    @Test\n    public void testHandleGetObjectsOnFields() {\n        doTestObjectBySelecting(partialObjects, \"SELECT id FROM testTable\", new SelectingObjectOperation() {\n            @Override\n            public List<TestObject> execute() throws WCDBException {\n                return handle.getAllObjects(new Field[]{DBTestObject.id}, tableName);\n            }\n        });\n    }\n\n    @Test\n    public void testHandleGetObjectsOnFieldsWhere() {\n        doTestObjectBySelecting(partialObject1, \"SELECT id FROM testTable WHERE id == 1\", new SelectingObjectOperation() {\n            @Override\n            public List<TestObject> execute() throws WCDBException {\n                return handle.getAllObjects(new Field[]{DBTestObject.id}, tableName, DBTestObject.id.eq(1));\n            }\n        });\n    }\n\n    @Test\n    public void testHandleGetObjectsOnFieldsWhereOrder() {\n        doTestObjectBySelecting(Arrays.asList(partialObject2, partialObject1), \"SELECT id FROM testTable WHERE id > 0 ORDER BY id DESC\", new SelectingObjectOperation() {\n            @Override\n            public List<TestObject> execute() throws WCDBException {\n                return handle.getAllObjects(new Field[]{DBTestObject.id}, tableName, DBTestObject.id.gt(0), DBTestObject.id.order(Order.Desc));\n            }\n        });\n    }\n\n    @Test\n    public void testHandleGetObjectsOnFieldsWhereOrderLimit() {\n        doTestObjectBySelecting(partialObject2, \"SELECT id FROM testTable WHERE id > 0 ORDER BY id DESC LIMIT 1\", new SelectingObjectOperation() {\n            @Override\n            public List<TestObject> execute() throws WCDBException {\n                return handle.getAllObjects(new Field[]{DBTestObject.id}, tableName, DBTestObject.id.gt(0), DBTestObject.id.order(Order.Desc), 1);\n            }\n        });\n    }\n\n    @Test\n    public void testHandleGetObjectsOnFieldsWhereOrderLimitOffset() {\n        doTestObjectBySelecting(partialObject1, \"SELECT id FROM testTable WHERE id > 0 ORDER BY id DESC LIMIT 1 OFFSET 1\", new SelectingObjectOperation() {\n            @Override\n            public List<TestObject> execute() throws WCDBException {\n                return handle.getAllObjects(new Field[]{DBTestObject.id}, tableName, DBTestObject.id.gt(0), DBTestObject.id.order(Order.Desc), 1, 1);\n            }\n        });\n    }\n\n    @Test\n    public void testHandleGetObjectsOnFieldsOrder() {\n        doTestObjectBySelecting(Arrays.asList(partialObject2, partialObject1), \"SELECT id FROM testTable ORDER BY id DESC\", new SelectingObjectOperation() {\n            @Override\n            public List<TestObject> execute() throws WCDBException {\n                return handle.getAllObjects(new Field[]{DBTestObject.id}, tableName, DBTestObject.id.order(Order.Desc));\n            }\n        });\n    }\n\n    @Test\n    public void testHandleGetObjectsOnFieldsOrderLimit() {\n        doTestObjectBySelecting(partialObject2, \"SELECT id FROM testTable ORDER BY id DESC LIMIT 1\", new SelectingObjectOperation() {\n            @Override\n            public List<TestObject> execute() throws WCDBException {\n                return handle.getAllObjects(new Field[]{DBTestObject.id}, tableName, DBTestObject.id.order(Order.Desc), 1);\n            }\n        });\n    }\n\n    @Test\n    public void testHandleGetObjectsOnFieldsOrderLimitOffset() {\n        doTestObjectBySelecting(partialObject1, \"SELECT id FROM testTable ORDER BY id DESC LIMIT 1 OFFSET 1\", new SelectingObjectOperation() {\n            @Override\n            public List<TestObject> execute() throws WCDBException {\n                return handle.getAllObjects(new Field[]{DBTestObject.id}, tableName, DBTestObject.id.order(Order.Desc), 1, 1);\n            }\n        });\n    }\n}\n"
  },
  {
    "path": "src/java/test/src/androidTest/java/com/tencent/wcdbtest/crud/ObjectUpdateTest.java",
    "content": "// Created by chenqiuwen on 2023/5/14.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdbtest.crud;\n\nimport com.tencent.wcdb.base.WCDBException;\nimport com.tencent.wcdb.winq.Order;\nimport com.tencent.wcdbtest.base.DBTestObject;\nimport com.tencent.wcdbtest.base.ObjectCRUDTestCase;\nimport com.tencent.wcdbtest.base.RandomTool;\nimport com.tencent.wcdbtest.base.TestObject;\n\nimport org.junit.Before;\nimport org.junit.Test;\n\nimport java.util.Arrays;\n\npublic class ObjectUpdateTest extends ObjectCRUDTestCase {\n    TestObject renewObject;\n    TestObject renewedObject1;\n    TestObject renewedObject2;\n\n    @Before\n    public void setup() throws WCDBException {\n        super.setup();\n        String renewContent = RandomTool.string();\n        renewObject = TestObject.createObject(0, renewContent);\n        renewedObject1 = TestObject.createObject(1, renewContent);\n        renewedObject2 = TestObject.createObject(2, renewContent);\n    }\n\n    @Test\n    public void testDatabaseUpdateObject() {\n        doTestObjectsAfterOperation(Arrays.asList(renewedObject1, renewedObject2),\n                \"UPDATE testTable SET content = ?1\",\n                new TestOperation() {\n                    @Override\n                    public void execute() throws WCDBException {\n                        database.updateObject(renewObject, DBTestObject.content, tableName);\n                    }\n                });\n    }\n\n    @Test\n    public void testDatabaseUpdateObjectWhere() {\n        doTestObjectsAfterOperation(Arrays.asList(renewedObject1, object2),\n                \"UPDATE testTable SET content = ?1 WHERE id == 1\",\n                new TestOperation() {\n                    @Override\n                    public void execute() throws WCDBException {\n                        database.updateObject(renewObject, DBTestObject.content, tableName, DBTestObject.id.eq(1));\n                    }\n                });\n    }\n\n    @Test\n    public void testDatabaseUpdateObjectWhereOrderLimit() {\n        doTestObjectsAfterOperation(Arrays.asList(object1, renewedObject2),\n                \"UPDATE testTable SET content = ?1 WHERE id > 0 ORDER BY id DESC LIMIT 1\",\n                new TestOperation() {\n                    @Override\n                    public void execute() throws WCDBException {\n                        database.updateObject(renewObject,\n                                DBTestObject.content,\n                                tableName,\n                                DBTestObject.id.gt(0),\n                                DBTestObject.id.order(Order.Desc), 1);\n                    }\n                });\n    }\n\n    @Test\n    public void testDatabaseUpdateObjectWhereOrderLimitOffset() {\n        doTestObjectsAfterOperation(Arrays.asList(renewedObject1, object2),\n                \"UPDATE testTable SET content = ?1 WHERE id > 0 ORDER BY id DESC LIMIT 1 OFFSET 1\",\n                new TestOperation() {\n                    @Override\n                    public void execute() throws WCDBException {\n                        database.updateObject(renewObject,\n                                DBTestObject.content,\n                                tableName,\n                                DBTestObject.id.gt(0),\n                                DBTestObject.id.order(Order.Desc), 1, 1);\n                    }\n                });\n    }\n\n    @Test\n    public void testDatabaseUpdateObjectOrderLimit() {\n        doTestObjectsAfterOperation(Arrays.asList(object1, renewedObject2),\n                \"UPDATE testTable SET content = ?1 ORDER BY id DESC LIMIT 1\",\n                new TestOperation() {\n                    @Override\n                    public void execute() throws WCDBException {\n                        database.updateObject(renewObject,\n                                DBTestObject.content,\n                                tableName,\n                                DBTestObject.id.order(Order.Desc), 1);\n                    }\n                });\n    }\n\n    @Test\n    public void testDatabaseUpdateObjectOrderLimitOffset() {\n        doTestObjectsAfterOperation(Arrays.asList(renewedObject1, object2),\n                \"UPDATE testTable SET content = ?1 ORDER BY id DESC LIMIT 1 OFFSET 1\",\n                new TestOperation() {\n                    @Override\n                    public void execute() throws WCDBException {\n                        database.updateObject(renewObject,\n                                DBTestObject.content,\n                                tableName,\n                                DBTestObject.id.order(Order.Desc), 1, 1);\n                    }\n                });\n    }\n\n    @Test\n    public void testTableUpdateObject() {\n        doTestObjectsAfterOperation(Arrays.asList(renewedObject1, renewedObject2),\n                \"UPDATE testTable SET content = ?1\",\n                new TestOperation() {\n                    @Override\n                    public void execute() throws WCDBException {\n                        table.updateObject(renewObject, DBTestObject.content);\n                    }\n                });\n    }\n\n    @Test\n    public void testTableUpdateObjectWhere() {\n        doTestObjectsAfterOperation(Arrays.asList(renewedObject1, object2),\n                \"UPDATE testTable SET content = ?1 WHERE id == 1\",\n                new TestOperation() {\n                    @Override\n                    public void execute() throws WCDBException {\n                        table.updateObject(renewObject, DBTestObject.content, DBTestObject.id.eq(1));\n                    }\n                });\n    }\n\n    @Test\n    public void testTableUpdateObjectWhereOrderLimit() {\n        doTestObjectsAfterOperation(Arrays.asList(object1, renewedObject2),\n                \"UPDATE testTable SET content = ?1 WHERE id > 0 ORDER BY id DESC LIMIT 1\",\n                new TestOperation() {\n                    @Override\n                    public void execute() throws WCDBException {\n                        table.updateObject(renewObject,\n                                DBTestObject.content,\n                                DBTestObject.id.gt(0),\n                                DBTestObject.id.order(Order.Desc), 1);\n                    }\n                });\n    }\n\n    @Test\n    public void testTableUpdateObjectWhereOrderLimitOffset() {\n        doTestObjectsAfterOperation(Arrays.asList(renewedObject1, object2),\n                \"UPDATE testTable SET content = ?1 WHERE id > 0 ORDER BY id DESC LIMIT 1 OFFSET 1\",\n                new TestOperation() {\n                    @Override\n                    public void execute() throws WCDBException {\n                        table.updateObject(renewObject,\n                                DBTestObject.content,\n                                DBTestObject.id.gt(0),\n                                DBTestObject.id.order(Order.Desc), 1, 1);\n                    }\n                });\n    }\n\n    @Test\n    public void testTableUpdateObjectOrderLimit() {\n        doTestObjectsAfterOperation(Arrays.asList(object1, renewedObject2),\n                \"UPDATE testTable SET content = ?1 ORDER BY id DESC LIMIT 1\",\n                new TestOperation() {\n                    @Override\n                    public void execute() throws WCDBException {\n                        table.updateObject(renewObject,\n                                DBTestObject.content,\n                                DBTestObject.id.order(Order.Desc), 1);\n                    }\n                });\n    }\n\n    @Test\n    public void testTableUpdateObjectOrderLimitOffset() {\n        doTestObjectsAfterOperation(Arrays.asList(renewedObject1, object2),\n                \"UPDATE testTable SET content = ?1 ORDER BY id DESC LIMIT 1 OFFSET 1\",\n                new TestOperation() {\n                    @Override\n                    public void execute() throws WCDBException {\n                        table.updateObject(renewObject,\n                                DBTestObject.content,\n                                DBTestObject.id.order(Order.Desc), 1, 1);\n                    }\n                });\n    }\n\n    @Test\n    public void testHandleUpdateObject() {\n        doTestObjectsAfterOperation(Arrays.asList(renewedObject1, renewedObject2),\n                \"UPDATE testTable SET content = ?1\",\n                new TestOperation() {\n                    @Override\n                    public void execute() throws WCDBException {\n                        handle.updateObject(renewObject, DBTestObject.content, tableName);\n                    }\n                });\n    }\n\n    @Test\n    public void testHandleUpdateObjectWhere() {\n        doTestObjectsAfterOperation(Arrays.asList(renewedObject1, object2),\n                \"UPDATE testTable SET content = ?1 WHERE id == 1\",\n                new TestOperation() {\n                    @Override\n                    public void execute() throws WCDBException {\n                        handle.updateObject(renewObject, DBTestObject.content, tableName, DBTestObject.id.eq(1));\n                    }\n                });\n    }\n\n    @Test\n    public void testHandleUpdateObjectWhereOrderLimit() {\n        doTestObjectsAfterOperation(Arrays.asList(object1, renewedObject2),\n                \"UPDATE testTable SET content = ?1 WHERE id > 0 ORDER BY id DESC LIMIT 1\",\n                new TestOperation() {\n                    @Override\n                    public void execute() throws WCDBException {\n                        handle.updateObject(renewObject,\n                                DBTestObject.content,\n                                tableName,\n                                DBTestObject.id.gt(0),\n                                DBTestObject.id.order(Order.Desc), 1);\n                    }\n                });\n    }\n\n    @Test\n    public void testHandleUpdateObjectWhereOrderLimitOffset() {\n        doTestObjectsAfterOperation(Arrays.asList(renewedObject1, object2),\n                \"UPDATE testTable SET content = ?1 WHERE id > 0 ORDER BY id DESC LIMIT 1 OFFSET 1\",\n                new TestOperation() {\n                    @Override\n                    public void execute() throws WCDBException {\n                        handle.updateObject(renewObject,\n                                DBTestObject.content,\n                                tableName,\n                                DBTestObject.id.gt(0),\n                                DBTestObject.id.order(Order.Desc), 1, 1);\n                    }\n                });\n    }\n\n    @Test\n    public void testHandleUpdateObjectOrderLimit() {\n        doTestObjectsAfterOperation(Arrays.asList(object1, renewedObject2),\n                \"UPDATE testTable SET content = ?1 ORDER BY id DESC LIMIT 1\",\n                new TestOperation() {\n                    @Override\n                    public void execute() throws WCDBException {\n                        handle.updateObject(renewObject,\n                                DBTestObject.content,\n                                tableName,\n                                DBTestObject.id.order(Order.Desc), 1);\n                    }\n                });\n    }\n\n    @Test\n    public void testHandleUpdateObjectOrderLimitOffset() {\n        doTestObjectsAfterOperation(Arrays.asList(renewedObject1, object2),\n                \"UPDATE testTable SET content = ?1 ORDER BY id DESC LIMIT 1 OFFSET 1\",\n                new TestOperation() {\n                    @Override\n                    public void execute() throws WCDBException {\n                        handle.updateObject(renewObject,\n                                DBTestObject.content,\n                                tableName,\n                                DBTestObject.id.order(Order.Desc), 1, 1);\n                    }\n                });\n    }\n}\n"
  },
  {
    "path": "src/java/test/src/androidTest/java/com/tencent/wcdbtest/crud/PrepareNewStatementTest.java",
    "content": "// Created by chenqiuwen on 2026/3/1.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdbtest.crud;\n\nimport static org.junit.Assert.*;\n\nimport com.tencent.wcdb.base.Value;\nimport com.tencent.wcdb.base.WCDBException;\nimport com.tencent.wcdb.core.Handle;\nimport com.tencent.wcdb.core.PreparedStatement;\nimport com.tencent.wcdb.winq.BindParameter;\nimport com.tencent.wcdb.winq.Column;\nimport com.tencent.wcdb.winq.Order;\nimport com.tencent.wcdb.winq.StatementDelete;\nimport com.tencent.wcdb.winq.StatementInsert;\nimport com.tencent.wcdb.winq.StatementSelect;\nimport com.tencent.wcdb.winq.StatementUpdate;\nimport com.tencent.wcdbtest.base.RandomTool;\nimport com.tencent.wcdbtest.base.ValueCRUDTestCase;\n\nimport org.junit.Test;\n\nimport java.util.ArrayList;\nimport java.util.List;\n\npublic class PrepareNewStatementTest extends ValueCRUDTestCase {\n\n    @Test\n    public void testBasicPrepareAndFinalize() throws WCDBException {\n        StatementSelect select = new StatementSelect()\n                .select(columns())\n                .from(tableName);\n        PreparedStatement stmt = handle.prepareNewStatement(select);\n        assertNotNull(stmt);\n        assertTrue(stmt.checkPrepared());\n\n        stmt.step();\n        assertFalse(stmt.isDone());\n        assertEquals(stmt.getInt(0), 1);\n\n        handle.finalizeAndReturnPreparedStatement(stmt);\n    }\n\n    @Test\n    public void testBasicPrepareWithSQL() throws WCDBException {\n        String sql = \"SELECT id, content FROM testTable\";\n        PreparedStatement stmt = handle.prepareNewStatement(sql);\n        assertNotNull(stmt);\n        assertTrue(stmt.checkPrepared());\n\n        stmt.step();\n        assertFalse(stmt.isDone());\n\n        handle.finalizeAndReturnPreparedStatement(stmt);\n    }\n\n    @Test\n    public void testInterleavedWithMainStatement() throws WCDBException {\n        StatementSelect select = new StatementSelect()\n                .select(columns())\n                .from(tableName);\n        PreparedStatement cursor = handle.prepareNewStatement(select);\n\n        cursor.step();\n        assertFalse(cursor.isDone());\n        int firstId = cursor.getInt(0);\n        assertEquals(firstId, 1);\n\n        StatementInsert insert = new StatementInsert()\n                .insertInto(tableName)\n                .columns(columns())\n                .valuesWithBindParameters(2);\n        PreparedStatement mainStmt = handle.preparedWithMainStatement(insert);\n        mainStmt.bindInteger(3, 1);\n        mainStmt.bindText(RandomTool.string(), 2);\n        mainStmt.step();\n        mainStmt.finalizeStatement();\n\n        cursor.step();\n        assertFalse(cursor.isDone());\n        int secondId = cursor.getInt(0);\n        assertEquals(secondId, 2);\n\n        handle.finalizeAndReturnPreparedStatement(cursor);\n\n        assertEquals(allRowsCount(), 3);\n    }\n\n    @Test\n    public void testMultipleUncachedStatements() throws WCDBException {\n        StatementSelect selectAll = new StatementSelect()\n                .select(columns())\n                .from(tableName);\n        StatementSelect selectById = new StatementSelect()\n                .select(new Column(\"content\"))\n                .from(tableName)\n                .where(new Column(\"id\").eq(new BindParameter(1)));\n\n        PreparedStatement cursor1 = handle.prepareNewStatement(selectAll);\n        PreparedStatement cursor2 = handle.prepareNewStatement(selectById);\n\n        cursor1.step();\n        assertFalse(cursor1.isDone());\n        int id = cursor1.getInt(0);\n\n        cursor2.bindInteger(id, 1);\n        cursor2.step();\n        assertFalse(cursor2.isDone());\n        String content = cursor2.getText(0);\n        assertNotNull(content);\n\n        cursor1.step();\n        assertFalse(cursor1.isDone());\n\n        handle.finalizeAndReturnPreparedStatement(cursor2);\n        handle.finalizeAndReturnPreparedStatement(cursor1);\n    }\n\n    @Test\n    public void testUncachedNotCached() throws WCDBException {\n        String sql = \"SELECT id FROM testTable WHERE id = 1\";\n\n        PreparedStatement stmt1 = handle.prepareNewStatement(sql);\n        PreparedStatement stmt2 = handle.prepareNewStatement(sql);\n\n        assertNotSame(stmt1, stmt2);\n\n        stmt1.step();\n        assertFalse(stmt1.isDone());\n        assertEquals(stmt1.getInt(0), 1);\n\n        stmt2.step();\n        assertFalse(stmt2.isDone());\n        assertEquals(stmt2.getInt(0), 1);\n\n        handle.finalizeAndReturnPreparedStatement(stmt1);\n        handle.finalizeAndReturnPreparedStatement(stmt2);\n    }\n\n    @Test\n    public void testInterleavedReadWrite() throws WCDBException {\n        StatementSelect select = new StatementSelect()\n                .select(columns())\n                .from(tableName)\n                .orderBy(new Column(\"id\").order(Order.Asc));\n        StatementInsert insert = new StatementInsert()\n                .insertInto(tableName)\n                .columns(columns())\n                .valuesWithBindParameters(2);\n\n        PreparedStatement readCursor = handle.prepareNewStatement(select);\n        PreparedStatement writeCursor = handle.prepareNewStatement(insert);\n\n        List<Integer> readIds = new ArrayList<>();\n\n        readCursor.step();\n        while (!readCursor.isDone()) {\n            readIds.add(readCursor.getInt(0));\n            readCursor.step();\n        }\n        assertEquals(readIds.size(), 2);\n        assertTrue(readIds.contains(1));\n        assertTrue(readIds.contains(2));\n\n        for (int i = 3; i <= 5; i++) {\n            writeCursor.reset();\n            writeCursor.bindInteger(i, 1);\n            writeCursor.bindText(RandomTool.string(), 2);\n            writeCursor.step();\n        }\n\n        handle.finalizeAndReturnPreparedStatement(readCursor);\n        handle.finalizeAndReturnPreparedStatement(writeCursor);\n\n        assertEquals(allRowsCount(), 5);\n    }\n\n    @Test\n    public void testCursorLikePattern() throws WCDBException {\n        for (int i = 3; i <= 10; i++) {\n            database.insertRow(new Value[]{new Value(i), new Value(RandomTool.string())}, columns(), tableName);\n        }\n\n        StatementSelect select = new StatementSelect()\n                .select(columns())\n                .from(tableName)\n                .orderBy(new Column(\"id\").order(Order.Asc));\n        PreparedStatement cursor = handle.prepareNewStatement(select);\n\n        List<Value[]> allRows = new ArrayList<>();\n        cursor.step();\n        while (!cursor.isDone()) {\n            allRows.add(cursor.getOneRow());\n            cursor.step();\n        }\n\n        assertEquals(allRows.size(), 10);\n        for (int i = 0; i < allRows.size(); i++) {\n            assertEquals(allRows.get(i)[0].getLong(), i + 1);\n        }\n\n        handle.finalizeAndReturnPreparedStatement(cursor);\n    }\n\n    @Test\n    public void testMixWithCachedStatement() throws WCDBException {\n        StatementSelect selectAll = new StatementSelect()\n                .select(columns())\n                .from(tableName)\n                .orderBy(new Column(\"id\").order(Order.Asc));\n\n        PreparedStatement uncached = handle.prepareNewStatement(selectAll);\n\n        StatementInsert insert = new StatementInsert()\n                .insertInto(tableName)\n                .columns(columns())\n                .valuesWithBindParameters(2);\n        PreparedStatement cached = handle.getOrCreatePreparedStatement(insert);\n\n        uncached.step();\n        assertFalse(uncached.isDone());\n        assertEquals(uncached.getInt(0), 1);\n\n        cached.bindInteger(3, 1);\n        cached.bindText(\"cached_insert\", 2);\n        cached.step();\n        cached.finalizeStatement();\n\n        uncached.step();\n        assertFalse(uncached.isDone());\n        assertEquals(uncached.getInt(0), 2);\n\n        handle.finalizeAndReturnPreparedStatement(uncached);\n\n        assertEquals(allRowsCount(), 3);\n    }\n\n    @Test\n    public void testColumnInfo() throws WCDBException {\n        StatementSelect select = new StatementSelect()\n                .select(columns())\n                .from(tableName);\n        PreparedStatement stmt = handle.prepareNewStatement(select);\n\n        assertEquals(stmt.getColumnCount(), 2);\n        assertEquals(stmt.getColumnName(0), \"id\");\n        assertEquals(stmt.getColumnName(1), \"content\");\n\n        handle.finalizeAndReturnPreparedStatement(stmt);\n    }\n\n    @Test\n    public void testFinalizeAllStatementsCleanup() throws WCDBException {\n        PreparedStatement stmt1 = handle.prepareNewStatement(\n                new StatementSelect().select(columns()).from(tableName));\n        PreparedStatement stmt2 = handle.prepareNewStatement(\n                new StatementSelect().select(new Column(\"id\")).from(tableName));\n\n        stmt1.step();\n        stmt2.step();\n\n        handle.finalizeAllStatements();\n\n        assertFalse(stmt1.checkPrepared());\n        assertFalse(stmt2.checkPrepared());\n    }\n\n    @Test\n    public void testGetHandleWithNewStatement() throws WCDBException {\n        Handle newHandle = database.getHandle();\n        try {\n            StatementSelect select = new StatementSelect()\n                    .select(columns())\n                    .from(tableName);\n            PreparedStatement stmt = newHandle.prepareNewStatement(select);\n\n            stmt.step();\n            assertFalse(stmt.isDone());\n            assertEquals(stmt.getInt(0), 1);\n\n            newHandle.finalizeAndReturnPreparedStatement(stmt);\n        } finally {\n            newHandle.invalidate();\n        }\n    }\n\n    @Test\n    public void testAllThreeTypesCoexist() throws WCDBException {\n        StatementSelect selectAll = new StatementSelect()\n                .select(columns()).from(tableName).orderBy(new Column(\"id\").order(Order.Asc));\n        StatementInsert insert = new StatementInsert()\n                .insertInto(tableName).columns(columns()).valuesWithBindParameters(2);\n        StatementSelect selectCount = new StatementSelect()\n                .select(Column.all().count()).from(tableName);\n\n        PreparedStatement uncached = handle.prepareNewStatement(selectAll);\n        PreparedStatement cached = handle.getOrCreatePreparedStatement(selectCount);\n        PreparedStatement main = handle.preparedWithMainStatement(insert);\n\n        uncached.step();\n        assertFalse(uncached.isDone());\n        assertEquals(uncached.getInt(0), 1);\n\n        cached.step();\n        assertFalse(cached.isDone());\n        assertEquals(cached.getLong(0), 2);\n        cached.finalizeStatement();\n\n        main.bindInteger(3, 1);\n        main.bindText(\"three\", 2);\n        main.step();\n        main.finalizeStatement();\n\n        uncached.step();\n        assertFalse(uncached.isDone());\n        assertEquals(uncached.getInt(0), 2);\n\n        handle.finalizeAndReturnPreparedStatement(uncached);\n        assertEquals(allRowsCount(), 3);\n    }\n\n    @Test\n    public void testUncachedSurvivesMainReprepareCycles() throws WCDBException {\n        StatementSelect selectAll = new StatementSelect()\n                .select(columns()).from(tableName).orderBy(new Column(\"id\").order(Order.Asc));\n        PreparedStatement cursor = handle.prepareNewStatement(selectAll);\n\n        cursor.step();\n        assertFalse(cursor.isDone());\n        assertEquals(cursor.getInt(0), 1);\n\n        for (int i = 3; i <= 5; i++) {\n            StatementInsert insert = new StatementInsert()\n                    .insertInto(tableName).columns(columns()).valuesWithBindParameters(2);\n            PreparedStatement main = handle.preparedWithMainStatement(insert);\n            main.bindInteger(i, 1);\n            main.bindText(\"val_\" + i, 2);\n            main.step();\n            main.finalizeStatement();\n        }\n\n        cursor.step();\n        assertFalse(cursor.isDone());\n        assertEquals(cursor.getInt(0), 2);\n\n        handle.finalizeAndReturnPreparedStatement(cursor);\n        assertEquals(allRowsCount(), 5);\n    }\n\n    @Test\n    public void testCachedAndUncachedSameSQLIndependent() throws WCDBException {\n        StatementSelect select = new StatementSelect()\n                .select(columns()).from(tableName).orderBy(new Column(\"id\").order(Order.Asc));\n\n        PreparedStatement cached = handle.getOrCreatePreparedStatement(select);\n        PreparedStatement uncached = handle.prepareNewStatement(select);\n\n        assertNotSame(cached, uncached);\n\n        cached.step();\n        assertFalse(cached.isDone());\n        assertEquals(cached.getInt(0), 1);\n\n        uncached.step();\n        assertFalse(uncached.isDone());\n        assertEquals(uncached.getInt(0), 1);\n\n        cached.step();\n        assertFalse(cached.isDone());\n        assertEquals(cached.getInt(0), 2);\n\n        uncached.step();\n        assertFalse(uncached.isDone());\n        assertEquals(uncached.getInt(0), 2);\n\n        cached.step();\n        assertTrue(cached.isDone());\n        uncached.step();\n        assertTrue(uncached.isDone());\n\n        cached.finalizeStatement();\n        handle.finalizeAndReturnPreparedStatement(uncached);\n    }\n\n    @Test\n    public void testMainWriteWhileMultipleUncachedRead() throws WCDBException {\n        for (int i = 3; i <= 6; i++) {\n            database.insertRow(new Value[]{new Value(i), new Value(\"content_\" + i)}, columns(), tableName);\n        }\n\n        StatementSelect selectOdd = new StatementSelect()\n                .select(columns()).from(tableName)\n                .where(new Column(\"id\").mod(2).eq(1))\n                .orderBy(new Column(\"id\").order(Order.Asc));\n        StatementSelect selectEven = new StatementSelect()\n                .select(columns()).from(tableName)\n                .where(new Column(\"id\").mod(2).eq(0))\n                .orderBy(new Column(\"id\").order(Order.Asc));\n\n        PreparedStatement cursorOdd = handle.prepareNewStatement(selectOdd);\n        PreparedStatement cursorEven = handle.prepareNewStatement(selectEven);\n\n        List<Integer> oddIds = new ArrayList<>();\n        List<Integer> evenIds = new ArrayList<>();\n\n        cursorOdd.step();\n        cursorEven.step();\n\n        while (!cursorOdd.isDone() || !cursorEven.isDone()) {\n            if (!cursorOdd.isDone()) {\n                oddIds.add(cursorOdd.getInt(0));\n                cursorOdd.step();\n            }\n            if (!cursorEven.isDone()) {\n                evenIds.add(cursorEven.getInt(0));\n                cursorEven.step();\n            }\n\n            if (oddIds.size() == 1) {\n                StatementInsert insert = new StatementInsert()\n                        .insertInto(tableName).columns(columns()).valuesWithBindParameters(2);\n                PreparedStatement main = handle.preparedWithMainStatement(insert);\n                main.bindInteger(7, 1);\n                main.bindText(\"inserted_during_read\", 2);\n                main.step();\n                main.finalizeStatement();\n            }\n        }\n\n        assertEquals(oddIds.size(), 4);\n        assertEquals(evenIds.size(), 3);\n\n        handle.finalizeAndReturnPreparedStatement(cursorOdd);\n        handle.finalizeAndReturnPreparedStatement(cursorEven);\n\n        assertEquals(allRowsCount(), 7);\n    }\n\n    @Test\n    public void testUncachedResetAndReuse() throws WCDBException {\n        StatementSelect select = new StatementSelect()\n                .select(columns()).from(tableName)\n                .where(new Column(\"id\").eq(new BindParameter(1)));\n\n        PreparedStatement stmt = handle.prepareNewStatement(select);\n\n        stmt.bindInteger(1, 1);\n        stmt.step();\n        assertFalse(stmt.isDone());\n        assertEquals(stmt.getInt(0), 1);\n\n        stmt.reset();\n        stmt.clearBindings();\n\n        stmt.bindInteger(2, 1);\n        stmt.step();\n        assertFalse(stmt.isDone());\n        assertEquals(stmt.getInt(0), 2);\n\n        handle.finalizeAndReturnPreparedStatement(stmt);\n    }\n\n    @Test\n    public void testExecuteInterleaveWithUncached() throws WCDBException {\n        StatementSelect select = new StatementSelect()\n                .select(columns()).from(tableName).orderBy(new Column(\"id\").order(Order.Asc));\n        PreparedStatement cursor = handle.prepareNewStatement(select);\n\n        cursor.step();\n        assertFalse(cursor.isDone());\n        assertEquals(cursor.getInt(0), 1);\n\n        handle.execute(new StatementInsert()\n                .insertInto(tableName).columns(columns())\n                .values(new Object[]{3, \"via_execute\"}));\n\n        cursor.step();\n        assertFalse(cursor.isDone());\n        assertEquals(cursor.getInt(0), 2);\n\n        handle.finalizeAndReturnPreparedStatement(cursor);\n        assertEquals(allRowsCount(), 3);\n    }\n\n    @Test\n    public void testTransactionWithMixedStatements() throws WCDBException {\n        handle.beginTransaction();\n\n        StatementSelect selectAll = new StatementSelect()\n                .select(columns()).from(tableName).orderBy(new Column(\"id\").order(Order.Asc));\n        PreparedStatement uncachedRead = handle.prepareNewStatement(selectAll);\n\n        StatementInsert insert = new StatementInsert()\n                .insertInto(tableName).columns(columns()).valuesWithBindParameters(2);\n        PreparedStatement cachedInsert = handle.getOrCreatePreparedStatement(insert);\n\n        uncachedRead.step();\n        assertFalse(uncachedRead.isDone());\n        assertEquals(uncachedRead.getInt(0), 1);\n\n        cachedInsert.bindInteger(3, 1);\n        cachedInsert.bindText(\"in_txn_cached\", 2);\n        cachedInsert.step();\n        cachedInsert.reset();\n\n        PreparedStatement main = handle.preparedWithMainStatement(\n                new StatementInsert().insertInto(tableName).columns(columns())\n                        .values(new Object[]{4, \"in_txn_main\"}));\n        main.step();\n        main.finalizeStatement();\n\n        StatementInsert insertUncached = new StatementInsert()\n                .insertInto(tableName).columns(columns()).valuesWithBindParameters(2);\n        PreparedStatement uncachedWrite = handle.prepareNewStatement(insertUncached);\n        uncachedWrite.bindInteger(5, 1);\n        uncachedWrite.bindText(\"in_txn_uncached\", 2);\n        uncachedWrite.step();\n\n        uncachedRead.step();\n        assertFalse(uncachedRead.isDone());\n        assertEquals(uncachedRead.getInt(0), 2);\n\n        handle.finalizeAndReturnPreparedStatement(uncachedWrite);\n        handle.finalizeAndReturnPreparedStatement(uncachedRead);\n        cachedInsert.finalizeStatement();\n\n        handle.commitTransaction();\n        assertEquals(allRowsCount(), 5);\n    }\n\n    @Test\n    public void testReverseFinalizationOrder() throws WCDBException {\n        PreparedStatement s1 = handle.prepareNewStatement(\n                new StatementSelect().select(columns()).from(tableName));\n        PreparedStatement s2 = handle.prepareNewStatement(\n                new StatementSelect().select(new Column(\"id\")).from(tableName));\n        PreparedStatement s3 = handle.prepareNewStatement(\n                new StatementSelect().select(new Column(\"content\")).from(tableName));\n\n        s1.step();\n        s2.step();\n        s3.step();\n\n        assertFalse(s1.isDone());\n        assertFalse(s2.isDone());\n        assertFalse(s3.isDone());\n\n        assertEquals(s1.getColumnCount(), 2);\n        assertEquals(s2.getColumnCount(), 1);\n        assertEquals(s3.getColumnCount(), 1);\n\n        handle.finalizeAndReturnPreparedStatement(s3);\n        handle.finalizeAndReturnPreparedStatement(s1);\n        handle.finalizeAndReturnPreparedStatement(s2);\n    }\n\n    @Test\n    public void testUncachedUpdateInterleaveWithUncachedRead() throws WCDBException {\n        StatementSelect select = new StatementSelect()\n                .select(columns()).from(tableName).orderBy(new Column(\"id\").order(Order.Asc));\n        StatementUpdate update = new StatementUpdate()\n                .update(tableName)\n                .set(new Column(\"content\")).to(new BindParameter(1))\n                .where(new Column(\"id\").eq(new BindParameter(2)));\n\n        PreparedStatement readCursor = handle.prepareNewStatement(select);\n        PreparedStatement updateStmt = handle.prepareNewStatement(update);\n\n        readCursor.step();\n        assertFalse(readCursor.isDone());\n        assertEquals(readCursor.getInt(0), 1);\n\n        updateStmt.bindText(\"updated_content\", 1);\n        updateStmt.bindInteger(2, 2);\n        updateStmt.step();\n\n        readCursor.step();\n        assertFalse(readCursor.isDone());\n        assertEquals(readCursor.getInt(0), 2);\n\n        handle.finalizeAndReturnPreparedStatement(updateStmt);\n        handle.finalizeAndReturnPreparedStatement(readCursor);\n\n        Value updatedContent = database.getValue(\n                new Column(\"content\"), tableName, new Column(\"id\").eq(2));\n        assertEquals(updatedContent.getText(), \"updated_content\");\n    }\n\n    @Test\n    public void testUncachedDeleteInterleaveWithCachedRead() throws WCDBException {\n        database.insertRow(new Value[]{new Value(3), new Value(\"c3\")}, columns(), tableName);\n        assertEquals(allRowsCount(), 3);\n\n        StatementSelect select = new StatementSelect()\n                .select(columns()).from(tableName).orderBy(new Column(\"id\").order(Order.Asc));\n        StatementDelete delete = new StatementDelete()\n                .deleteFrom(tableName)\n                .where(new Column(\"id\").eq(new BindParameter(1)));\n\n        PreparedStatement cachedRead = handle.getOrCreatePreparedStatement(select);\n        PreparedStatement uncachedDelete = handle.prepareNewStatement(delete);\n\n        cachedRead.step();\n        assertFalse(cachedRead.isDone());\n        assertEquals(cachedRead.getInt(0), 1);\n\n        uncachedDelete.bindInteger(3, 1);\n        uncachedDelete.step();\n\n        cachedRead.step();\n        assertFalse(cachedRead.isDone());\n        assertEquals(cachedRead.getInt(0), 2);\n\n        cachedRead.finalizeStatement();\n        handle.finalizeAndReturnPreparedStatement(uncachedDelete);\n\n        assertEquals(allRowsCount(), 2);\n    }\n\n    @Test\n    public void testHeavyMixFiveStatements() throws WCDBException {\n        StatementSelect select1 = new StatementSelect()\n                .select(columns()).from(tableName).orderBy(new Column(\"id\").order(Order.Asc));\n        StatementSelect select2 = new StatementSelect()\n                .select(new Column(\"content\")).from(tableName)\n                .where(new Column(\"id\").eq(new BindParameter(1)));\n        StatementInsert insertStmt = new StatementInsert()\n                .insertInto(tableName).columns(columns()).valuesWithBindParameters(2);\n\n        PreparedStatement uncachedA = handle.prepareNewStatement(select1);\n        PreparedStatement uncachedB = handle.prepareNewStatement(select2);\n        PreparedStatement cached = handle.getOrCreatePreparedStatement(insertStmt);\n\n        uncachedA.step();\n        assertFalse(uncachedA.isDone());\n        int firstId = uncachedA.getInt(0);\n        assertEquals(firstId, 1);\n\n        uncachedB.bindInteger(firstId, 1);\n        uncachedB.step();\n        assertFalse(uncachedB.isDone());\n        String contentOfFirst = uncachedB.getText(0);\n        assertNotNull(contentOfFirst);\n\n        cached.bindInteger(3, 1);\n        cached.bindText(\"heavy_mix_cached\", 2);\n        cached.step();\n        cached.reset();\n\n        PreparedStatement main = handle.preparedWithMainStatement(\n                new StatementInsert().insertInto(tableName).columns(columns())\n                        .values(new Object[]{4, \"heavy_mix_main\"}));\n        main.step();\n        main.finalizeStatement();\n\n        PreparedStatement uncachedC = handle.prepareNewStatement(\n                new StatementSelect().select(Column.all().count()).from(tableName));\n        uncachedC.step();\n        assertEquals(uncachedC.getLong(0), 4);\n\n        uncachedA.step();\n        assertFalse(uncachedA.isDone());\n        assertEquals(uncachedA.getInt(0), 2);\n\n        handle.finalizeAndReturnPreparedStatement(uncachedC);\n        handle.finalizeAndReturnPreparedStatement(uncachedB);\n        handle.finalizeAndReturnPreparedStatement(uncachedA);\n        cached.finalizeStatement();\n\n        assertEquals(allRowsCount(), 4);\n    }\n\n    @Test\n    public void testUncachedReadDuringCachedBatchInsert() throws WCDBException {\n        StatementInsert insert = new StatementInsert()\n                .insertInto(tableName).columns(columns()).valuesWithBindParameters(2);\n        PreparedStatement cachedInsert = handle.getOrCreatePreparedStatement(insert);\n\n        for (int i = 3; i <= 10; i++) {\n            cachedInsert.reset();\n            cachedInsert.bindInteger(i, 1);\n            cachedInsert.bindText(\"batch_\" + i, 2);\n            cachedInsert.step();\n        }\n\n        StatementSelect select = new StatementSelect()\n                .select(columns()).from(tableName).orderBy(new Column(\"id\").order(Order.Asc));\n        PreparedStatement uncachedRead = handle.prepareNewStatement(select);\n\n        int count = 0;\n        uncachedRead.step();\n        while (!uncachedRead.isDone()) {\n            count++;\n            int id = uncachedRead.getInt(0);\n            assertTrue(id >= 1 && id <= 10);\n            uncachedRead.step();\n        }\n        assertEquals(count, 10);\n\n        cachedInsert.reset();\n        cachedInsert.bindInteger(11, 1);\n        cachedInsert.bindText(\"batch_11\", 2);\n        cachedInsert.step();\n        cachedInsert.finalizeStatement();\n\n        handle.finalizeAndReturnPreparedStatement(uncachedRead);\n        assertEquals(allRowsCount(), 11);\n    }\n\n    @Test\n    public void testMultipleMainRepreparesWithUncachedAndCached() throws WCDBException {\n        StatementSelect selectAll = new StatementSelect()\n                .select(columns()).from(tableName).orderBy(new Column(\"id\").order(Order.Asc));\n\n        PreparedStatement uncached = handle.prepareNewStatement(selectAll);\n        PreparedStatement cached = handle.getOrCreatePreparedStatement(selectAll);\n\n        uncached.step();\n        cached.step();\n        assertFalse(uncached.isDone());\n        assertFalse(cached.isDone());\n        assertEquals(uncached.getInt(0), 1);\n        assertEquals(cached.getInt(0), 1);\n\n        PreparedStatement main = handle.preparedWithMainStatement(\n                new StatementInsert().insertInto(tableName).columns(columns())\n                        .values(new Object[]{3, \"main_1\"}));\n        main.step();\n        main.finalizeStatement();\n\n        main = handle.preparedWithMainStatement(\n                new StatementInsert().insertInto(tableName).columns(columns())\n                        .values(new Object[]{4, \"main_2\"}));\n        main.step();\n        main.finalizeStatement();\n\n        main = handle.preparedWithMainStatement(\n                new StatementUpdate().update(tableName)\n                        .set(new Column(\"content\")).to(\"updated\")\n                        .where(new Column(\"id\").eq(4)));\n        main.step();\n        main.finalizeStatement();\n\n        uncached.step();\n        cached.step();\n        assertFalse(uncached.isDone());\n        assertFalse(cached.isDone());\n        assertEquals(uncached.getInt(0), 2);\n        assertEquals(cached.getInt(0), 2);\n\n        cached.finalizeStatement();\n        handle.finalizeAndReturnPreparedStatement(uncached);\n\n        assertEquals(allRowsCount(), 4);\n        Value val = database.getValue(new Column(\"content\"), tableName, new Column(\"id\").eq(4));\n        assertEquals(val.getText(), \"updated\");\n    }\n\n    @Test\n    public void testRollbackWithMixedStatements() throws WCDBException {\n        long countBefore = allRowsCount();\n\n        handle.beginTransaction();\n\n        PreparedStatement uncached = handle.prepareNewStatement(\n                new StatementInsert().insertInto(tableName).columns(columns())\n                        .valuesWithBindParameters(2));\n        uncached.bindInteger(3, 1);\n        uncached.bindText(\"will_rollback\", 2);\n        uncached.step();\n\n        PreparedStatement main = handle.preparedWithMainStatement(\n                new StatementInsert().insertInto(tableName).columns(columns())\n                        .values(new Object[]{4, \"also_rollback\"}));\n        main.step();\n        main.finalizeStatement();\n\n        handle.finalizeAndReturnPreparedStatement(uncached);\n        handle.rollbackTransaction();\n\n        assertEquals(allRowsCount(), countBefore);\n    }\n\n    @Test\n    public void testCreateAfterFinalizeAllStatements() throws WCDBException {\n        PreparedStatement s1 = handle.prepareNewStatement(\n                new StatementSelect().select(columns()).from(tableName));\n        s1.step();\n\n        handle.finalizeAllStatements();\n        assertFalse(s1.checkPrepared());\n\n        PreparedStatement s2 = handle.prepareNewStatement(\n                new StatementSelect().select(columns()).from(tableName));\n        assertNotNull(s2);\n        assertTrue(s2.checkPrepared());\n        s2.step();\n        assertFalse(s2.isDone());\n\n        handle.finalizeAndReturnPreparedStatement(s2);\n    }\n}\n"
  },
  {
    "path": "src/java/test/src/androidTest/java/com/tencent/wcdbtest/crud/StatementOperationTest.java",
    "content": "// Created by chenqiuwen on 2023/5/12.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdbtest.crud;\n\nimport com.tencent.wcdb.base.Value;\nimport com.tencent.wcdb.base.WCDBException;\nimport com.tencent.wcdb.core.PreparedStatement;\nimport com.tencent.wcdb.winq.BindParameter;\nimport com.tencent.wcdb.winq.Column;\nimport com.tencent.wcdb.winq.Pragma;\nimport com.tencent.wcdb.winq.StatementDelete;\nimport com.tencent.wcdb.winq.StatementInsert;\nimport com.tencent.wcdb.winq.StatementPragma;\nimport com.tencent.wcdb.winq.StatementSelect;\nimport com.tencent.wcdbtest.base.RandomTool;\nimport com.tencent.wcdbtest.base.ValueCRUDTestCase;\n\nimport static org.junit.Assert.*;\n\nimport org.junit.Before;\nimport org.junit.Test;\n\nimport java.util.Random;\n\npublic class StatementOperationTest extends ValueCRUDTestCase {\n    StatementSelect select;\n    StatementInsert insert;\n\n    @Before\n    public void setup() throws WCDBException {\n        super.setup();\n        insert = new StatementInsert().insertInto(tableName).columns(columns()).values(new Object[]{3, new BindParameter(1)});\n        select = new StatementSelect().select(new Column(\"content\")).from(tableName).where(new Column(\"id\").eq(3));\n    }\n\n    @Test\n    public void testExecute() {\n        doTestSQL(\"PRAGMA user_version = 123\", new TestOperation() {\n            @Override\n            public void execute() throws WCDBException {\n                handle = database.getHandle();\n                handle.execute(new StatementPragma().pragma(Pragma.userVersion).toValue(123));\n            }\n        });\n    }\n\n    @Test\n    public void testStep() {\n        doTestSQLs(new String[]{\n                \"INSERT INTO testTable(id, content) VALUES(?1, ?2)\",\n                \"INSERT INTO testTable(id, content) VALUES(?1, ?2)\"\n        }, new TestOperation() {\n            @Override\n            public void execute() throws WCDBException {\n                StatementInsert insert = new StatementInsert().insertInto(tableName).columns(columns()).valuesWithBindParameters(2);\n                PreparedStatement preparedStatement = handle.getOrCreatePreparedStatement(insert);\n                preparedStatement.bindInteger(3, 1);\n                preparedStatement.bindText(RandomTool.string(), 2);\n                preparedStatement.step();\n                assertTrue(preparedStatement.isDone());\n                preparedStatement.reset();\n                preparedStatement.bindRow(RandomTool.testRowWithId(4));\n                preparedStatement.step();\n                assertTrue(preparedStatement.isDone());\n                preparedStatement.finalizeStatement();\n            }\n        });\n    }\n\n    @Test\n    public void testReadOnly() throws WCDBException {\n        PreparedStatement statement1 = handle.preparedWithMainStatement(new StatementPragma().pragma(Pragma.userVersion));\n        PreparedStatement statement2 = handle.getOrCreatePreparedStatement(new StatementPragma().pragma(Pragma.userVersion).toValue(123));\n        assertTrue(statement1.isReadOnly());\n        assertFalse(statement2.isReadOnly());\n        statement1.finalizeStatement();\n    }\n\n    @Test\n    public void testGetChanges() throws WCDBException {\n        handle.execute(new StatementDelete().deleteFrom(tableName));\n        assertEquals(handle.getChanges(), rows.size());\n    }\n\n    @Test\n    public void testGetLastInsertRowId() throws WCDBException {\n        StatementInsert insert = new StatementInsert().insertInto(tableName).columns(columns()).values(new Object[]{null, RandomTool.string()});\n        handle.execute(insert);\n        assertEquals(handle.getLastInsertedRowId(), nextId);\n    }\n\n    @Test\n    public void testInteger() throws WCDBException {\n        long value = new Random().nextLong();\n        PreparedStatement preparedInsert = handle.getOrCreatePreparedStatement(insert);\n        preparedInsert.bindInteger(value, 1);\n        preparedInsert.step();\n        assertTrue(preparedInsert.isDone());\n        preparedInsert.finalizeStatement();\n\n        PreparedStatement prepareSelect = handle.getOrCreatePreparedStatement(select);\n        prepareSelect.step();\n        assertFalse(prepareSelect.isDone());\n        assertEquals(prepareSelect.getLong(0), value);\n    }\n\n    @Test\n    public void testIntegerValue() throws WCDBException {\n        Value value = new Value(new Random().nextLong());\n        PreparedStatement preparedInsert = handle.getOrCreatePreparedStatement(insert);\n        preparedInsert.bindValue(value, 1);\n        preparedInsert.step();\n        assertTrue(preparedInsert.isDone());\n        preparedInsert.finalizeStatement();\n\n        PreparedStatement prepareSelect = handle.getOrCreatePreparedStatement(select);\n        prepareSelect.step();\n        assertFalse(prepareSelect.isDone());\n        assertEquals(prepareSelect.getValue(0), value);\n    }\n\n    @Test\n    public void testDouble() throws WCDBException {\n        double value = new Random().nextDouble();\n        PreparedStatement preparedInsert = handle.getOrCreatePreparedStatement(insert);\n        preparedInsert.bindDouble(value, 1);\n        preparedInsert.step();\n        assertTrue(preparedInsert.isDone());\n        preparedInsert.finalizeStatement();\n\n        PreparedStatement prepareSelect = handle.getOrCreatePreparedStatement(select);\n        prepareSelect.step();\n        assertFalse(prepareSelect.isDone());\n        assertEquals(prepareSelect.getDouble(0), value, 0.0001);\n    }\n\n    @Test\n    public void testDoubleValue() throws WCDBException {\n        Value value = new Value(1.2D);\n        PreparedStatement preparedInsert = handle.getOrCreatePreparedStatement(insert);\n        preparedInsert.bindValue(value, 1);\n        preparedInsert.step();\n        assertTrue(preparedInsert.isDone());\n        preparedInsert.finalizeStatement();\n\n        PreparedStatement prepareSelect = handle.getOrCreatePreparedStatement(select);\n        prepareSelect.step();\n        assertFalse(prepareSelect.isDone());\n        assertEquals(value, prepareSelect.getValue(0));\n    }\n\n    @Test\n    public void testNull() throws WCDBException {\n        PreparedStatement preparedInsert = handle.getOrCreatePreparedStatement(insert);\n        preparedInsert.bindNull(1);\n        preparedInsert.step();\n        assertTrue(preparedInsert.isDone());\n        preparedInsert.finalizeStatement();\n\n        PreparedStatement prepareSelect = handle.getOrCreatePreparedStatement(select);\n        prepareSelect.step();\n        assertFalse(prepareSelect.isDone());\n        assertEquals(prepareSelect.getValue(0), new Value());\n    }\n\n    @Test\n    public void testNullValue() throws WCDBException {\n        Value value = new Value();\n        PreparedStatement preparedInsert = handle.getOrCreatePreparedStatement(insert);\n        preparedInsert.bindValue(value, 1);\n        preparedInsert.step();\n        assertTrue(preparedInsert.isDone());\n        preparedInsert.finalizeStatement();\n\n        PreparedStatement prepareSelect = handle.getOrCreatePreparedStatement(select);\n        prepareSelect.step();\n        assertFalse(prepareSelect.isDone());\n        assertEquals(prepareSelect.getValue(0), value);\n    }\n\n    @Test\n    public void testString() throws WCDBException {\n        String value = RandomTool.string();\n        PreparedStatement preparedInsert = handle.getOrCreatePreparedStatement(insert);\n        preparedInsert.bindText(value, 1);\n        preparedInsert.step();\n        assertTrue(preparedInsert.isDone());\n        preparedInsert.finalizeStatement();\n\n        PreparedStatement prepareSelect = handle.getOrCreatePreparedStatement(select);\n        prepareSelect.step();\n        assertFalse(prepareSelect.isDone());\n        assertEquals(prepareSelect.getText(0), value);\n    }\n\n    @Test\n    public void testStringValue() throws WCDBException {\n        Value value = new Value(RandomTool.string());\n        PreparedStatement preparedInsert = handle.getOrCreatePreparedStatement(insert);\n        preparedInsert.bindValue(value, 1);\n        preparedInsert.step();\n        assertTrue(preparedInsert.isDone());\n        preparedInsert.finalizeStatement();\n\n        PreparedStatement prepareSelect = handle.getOrCreatePreparedStatement(select);\n        prepareSelect.step();\n        assertFalse(prepareSelect.isDone());\n        assertEquals(prepareSelect.getValue(0), value);\n    }\n\n    @Test\n    public void testBLOB() throws WCDBException {\n        byte[] value = RandomTool.bytes();\n        PreparedStatement preparedInsert = handle.getOrCreatePreparedStatement(insert);\n        preparedInsert.bindBLOB(value, 1);\n        preparedInsert.step();\n        assertTrue(preparedInsert.isDone());\n        preparedInsert.finalizeStatement();\n\n        PreparedStatement prepareSelect = handle.getOrCreatePreparedStatement(select);\n        prepareSelect.step();\n        assertFalse(prepareSelect.isDone());\n        assertArrayEquals(prepareSelect.getBLOB(0), value);\n    }\n\n    @Test\n    public void testBLOBValue() throws WCDBException {\n        Value value = new Value(RandomTool.bytes());\n        PreparedStatement preparedInsert = handle.getOrCreatePreparedStatement(insert);\n        preparedInsert.bindValue(value, 1);\n        preparedInsert.step();\n        assertTrue(preparedInsert.isDone());\n        preparedInsert.finalizeStatement();\n\n        PreparedStatement prepareSelect = handle.getOrCreatePreparedStatement(select);\n        prepareSelect.step();\n        assertFalse(prepareSelect.isDone());\n        assertEquals(prepareSelect.getValue(0), value);\n    }\n\n    @Test\n    public void testBindIndex() throws WCDBException {\n        String value = RandomTool.string();\n        BindParameter parameter = BindParameter.colon(\"data\");\n        StatementInsert insert = new StatementInsert().insertInto(tableName)\n                .columns(new String[]{\"id\", \"content\"})\n                .values(new Object[]{3, parameter});\n        PreparedStatement preparedInsert = handle.getOrCreatePreparedStatement(insert);\n        preparedInsert.bindText(value, preparedInsert.bindParameterIndex(parameter.getDescription()));\n        preparedInsert.step();\n        preparedInsert.finalizeStatement();\n\n        PreparedStatement prepareSelect = handle.getOrCreatePreparedStatement(select);\n        prepareSelect.step();\n        assertEquals(prepareSelect.getText(0), value);\n        prepareSelect.finalizeStatement();\n    }\n}\n"
  },
  {
    "path": "src/java/test/src/androidTest/java/com/tencent/wcdbtest/crud/ValueDeleteWithColumnTest.java",
    "content": "// Created by chenqiuwen on 2023/5/14.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdbtest.crud;\n\nimport static org.junit.Assert.assertEquals;\n\nimport com.tencent.wcdb.base.WCDBException;\nimport com.tencent.wcdb.winq.Order;\nimport com.tencent.wcdbtest.base.ValueCRUDTestCase;\n\nimport org.junit.Test;\n\npublic class ValueDeleteWithColumnTest extends ValueCRUDTestCase {\n    @Test\n    public void testDatabaseDelete() {\n        doTestSQL(\"DELETE FROM testTable\", new TestOperation() {\n            @Override\n            public void execute() throws WCDBException {\n                database.deleteValue(tableName);\n            }\n        });\n        assertEquals(allRowsCount(), 0);\n    }\n\n    @Test\n    public void testDatabaseDeleteWhere() {\n        doTestSQL(\"DELETE FROM testTable WHERE id == 1\", new TestOperation() {\n            @Override\n            public void execute() throws WCDBException {\n                database.deleteValue(tableName, id.eq(1));\n            }\n        });\n        assertEquals(allRowsCount(), 1);\n    }\n\n    @Test\n    public void testDatabaseDeleteOrderLimit() {\n        doTestSQL(\"DELETE FROM testTable ORDER BY content DESC LIMIT 1\", new TestOperation() {\n            @Override\n            public void execute() throws WCDBException {\n                database.deleteValue(tableName, content.order(Order.Desc), 1);\n            }\n        });\n        assertEquals(allRowsCount(), 1);\n    }\n\n    @Test\n    public void testDatabaseDeleteOrderLimitOffset() {\n        doTestSQL(\"DELETE FROM testTable ORDER BY content DESC LIMIT 1 OFFSET 1\", new TestOperation() {\n            @Override\n            public void execute() throws WCDBException {\n                database.deleteValue(tableName, content.order(Order.Desc), 1, 1);\n            }\n        });\n        assertEquals(allRowsCount(), 1);\n    }\n\n    @Test\n    public void testDatabaseDeleteWhereOrderLimit() {\n        doTestSQL(\"DELETE FROM testTable WHERE id IN(1, 3) ORDER BY content DESC LIMIT 1\", new TestOperation() {\n            @Override\n            public void execute() throws WCDBException {\n                database.deleteValue(tableName, id.in(new int[]{1, 3}), content.order(Order.Desc), 1);\n            }\n        });\n        assertEquals(allRowsCount(), 1);\n    }\n\n    @Test\n    public void testDatabaseDeleteWhereOrderLimitOffset() {\n        doTestSQL(\"DELETE FROM testTable WHERE id IN(1, 2) ORDER BY content DESC LIMIT 1 OFFSET 1\", new TestOperation() {\n            @Override\n            public void execute() throws WCDBException {\n                database.deleteValue(tableName, id.in(new int[]{1, 2}), content.order(Order.Desc), 1, 1);\n            }\n        });\n        assertEquals(allRowsCount(), 1);\n    }\n\n    @Test\n    public void testHandleDelete() {\n        doTestSQL(\"DELETE FROM testTable\", new TestOperation() {\n            @Override\n            public void execute() throws WCDBException {\n                handle.deleteValue(tableName);\n            }\n        });\n        assertEquals(allRowsCount(), 0);\n    }\n\n    @Test\n    public void testHandleDeleteWhere() {\n        doTestSQL(\"DELETE FROM testTable WHERE id == 1\", new TestOperation() {\n            @Override\n            public void execute() throws WCDBException {\n                handle.deleteValue(tableName, id.eq(1));\n            }\n        });\n        assertEquals(allRowsCount(), 1);\n    }\n\n    @Test\n    public void testHandleDeleteOrderLimit() {\n        doTestSQL(\"DELETE FROM testTable ORDER BY content DESC LIMIT 1\", new TestOperation() {\n            @Override\n            public void execute() throws WCDBException {\n                handle.deleteValue(tableName, content.order(Order.Desc), 1);\n            }\n        });\n        assertEquals(allRowsCount(), 1);\n    }\n\n    @Test\n    public void testHandleDeleteOrderLimitOffset() {\n        doTestSQL(\"DELETE FROM testTable ORDER BY content DESC LIMIT 1 OFFSET 1\", new TestOperation() {\n            @Override\n            public void execute() throws WCDBException {\n                handle.deleteValue(tableName, content.order(Order.Desc), 1, 1);\n            }\n        });\n        assertEquals(allRowsCount(), 1);\n    }\n\n    @Test\n    public void testHandleDeleteWhereOrderLimit() {\n        doTestSQL(\"DELETE FROM testTable WHERE id IN(1, 3) ORDER BY content DESC LIMIT 1\", new TestOperation() {\n            @Override\n            public void execute() throws WCDBException {\n                handle.deleteValue(tableName, id.in(new int[]{1, 3}), content.order(Order.Desc), 1);\n            }\n        });\n        assertEquals(allRowsCount(), 1);\n    }\n\n    @Test\n    public void testHandleDeleteWhereOrderLimitOffset() {\n        doTestSQL(\"DELETE FROM testTable WHERE id IN(1, 2) ORDER BY content DESC LIMIT 1 OFFSET 1\", new TestOperation() {\n            @Override\n            public void execute() throws WCDBException {\n                handle.deleteValue(tableName, id.in(new int[]{1, 2}), content.order(Order.Desc), 1, 1);\n            }\n        });\n        assertEquals(allRowsCount(), 1);\n    }\n}\n"
  },
  {
    "path": "src/java/test/src/androidTest/java/com/tencent/wcdbtest/crud/ValueDeleteWithFieldTest.java",
    "content": "// Created by chenqiuwen on 2023/5/14.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdbtest.crud;\n\nimport static org.junit.Assert.assertEquals;\n\nimport com.tencent.wcdb.base.WCDBException;\nimport com.tencent.wcdb.winq.Order;\nimport com.tencent.wcdbtest.base.DBTestObject;\nimport com.tencent.wcdbtest.base.ObjectCRUDTestCase;\n\nimport org.junit.Test;\n\npublic class ValueDeleteWithFieldTest extends ObjectCRUDTestCase {\n    @Test\n    public void testDatabaseDelete() {\n        doTestSQL(\"DELETE FROM testTable\", new TestOperation() {\n            @Override\n            public void execute() throws WCDBException {\n                database.deleteValue(tableName);\n            }\n        });\n        assertEquals(allRowsCount(), 0);\n    }\n\n    @Test\n    public void testDatabaseDeleteWhere() {\n        doTestSQL(\"DELETE FROM testTable WHERE id == 1\", new TestOperation() {\n            @Override\n            public void execute() throws WCDBException {\n                database.deleteValue(tableName, DBTestObject.id.eq(1));\n            }\n        });\n        assertEquals(allRowsCount(), 1);\n    }\n\n    @Test\n    public void testDatabaseDeleteOrderLimit() {\n        doTestSQL(\"DELETE FROM testTable ORDER BY content DESC LIMIT 1\", new TestOperation() {\n            @Override\n            public void execute() throws WCDBException {\n                database.deleteValue(tableName, DBTestObject.content.order(Order.Desc), 1);\n            }\n        });\n        assertEquals(allRowsCount(), 1);\n    }\n\n    @Test\n    public void testDatabaseDeleteOrderLimitOffset() {\n        doTestSQL(\"DELETE FROM testTable ORDER BY content DESC LIMIT 1 OFFSET 1\", new TestOperation() {\n            @Override\n            public void execute() throws WCDBException {\n                database.deleteValue(tableName, DBTestObject.content.order(Order.Desc), 1, 1);\n            }\n        });\n        assertEquals(allRowsCount(), 1);\n    }\n\n    @Test\n    public void testDatabaseDeleteWhereOrderLimit() {\n        doTestSQL(\"DELETE FROM testTable WHERE id IN(1, 3) ORDER BY content DESC LIMIT 1\", new TestOperation() {\n            @Override\n            public void execute() throws WCDBException {\n                database.deleteValue(tableName, DBTestObject.id.in(new int[]{1, 3}), DBTestObject.content.order(Order.Desc), 1);\n            }\n        });\n        assertEquals(allRowsCount(), 1);\n    }\n\n    @Test\n    public void testDatabaseDeleteWhereOrderLimitOffset() {\n        doTestSQL(\"DELETE FROM testTable WHERE id IN(1, 2) ORDER BY content DESC LIMIT 1 OFFSET 1\", new TestOperation() {\n            @Override\n            public void execute() throws WCDBException {\n                database.deleteValue(tableName, DBTestObject.id.in(new int[]{1, 2}), DBTestObject.content.order(Order.Desc), 1, 1);\n            }\n        });\n        assertEquals(allRowsCount(), 1);\n    }\n\n    @Test\n    public void testTableDelete() {\n        doTestSQL(\"DELETE FROM testTable\", new TestOperation() {\n            @Override\n            public void execute() throws WCDBException {\n                table.deleteValue();\n            }\n        });\n        assertEquals(allRowsCount(), 0);\n    }\n\n    @Test\n    public void testTableDeleteWhere() {\n        doTestSQL(\"DELETE FROM testTable WHERE id == 1\", new TestOperation() {\n            @Override\n            public void execute() throws WCDBException {\n                table.deleteValue(DBTestObject.id.eq(1));\n            }\n        });\n        assertEquals(allRowsCount(), 1);\n    }\n\n    @Test\n    public void testTableDeleteOrderLimit() {\n        doTestSQL(\"DELETE FROM testTable ORDER BY content DESC LIMIT 1\", new TestOperation() {\n            @Override\n            public void execute() throws WCDBException {\n                table.deleteValue(DBTestObject.content.order(Order.Desc), 1);\n            }\n        });\n        assertEquals(allRowsCount(), 1);\n    }\n\n    @Test\n    public void testTableDeleteOrderLimitOffset() {\n        doTestSQL(\"DELETE FROM testTable ORDER BY content DESC LIMIT 1 OFFSET 1\", new TestOperation() {\n            @Override\n            public void execute() throws WCDBException {\n                table.deleteValue(DBTestObject.content.order(Order.Desc), 1, 1);\n            }\n        });\n        assertEquals(allRowsCount(), 1);\n    }\n\n    @Test\n    public void testTableDeleteWhereOrderLimit() {\n        doTestSQL(\"DELETE FROM testTable WHERE id IN(1, 3) ORDER BY content DESC LIMIT 1\", new TestOperation() {\n            @Override\n            public void execute() throws WCDBException {\n                table.deleteValue(DBTestObject.id.in(new int[]{1, 3}), DBTestObject.content.order(Order.Desc), 1);\n            }\n        });\n        assertEquals(allRowsCount(), 1);\n    }\n\n    @Test\n    public void testTableDeleteWhereOrderLimitOffset() {\n        doTestSQL(\"DELETE FROM testTable WHERE id IN(1, 2) ORDER BY content DESC LIMIT 1 OFFSET 1\", new TestOperation() {\n            @Override\n            public void execute() throws WCDBException {\n                table.deleteValue(DBTestObject.id.in(new int[]{1, 2}), DBTestObject.content.order(Order.Desc), 1, 1);\n            }\n        });\n        assertEquals(allRowsCount(), 1);\n    }\n\n    @Test\n    public void testHandleDelete() {\n        doTestSQL(\"DELETE FROM testTable\", new TestOperation() {\n            @Override\n            public void execute() throws WCDBException {\n                handle.deleteValue(tableName);\n            }\n        });\n        assertEquals(allRowsCount(), 0);\n    }\n\n    @Test\n    public void testHandleDeleteWhere() {\n        doTestSQL(\"DELETE FROM testTable WHERE id == 1\", new TestOperation() {\n            @Override\n            public void execute() throws WCDBException {\n                handle.deleteValue(tableName, DBTestObject.id.eq(1));\n            }\n        });\n        assertEquals(allRowsCount(), 1);\n    }\n\n    @Test\n    public void testHandleDeleteOrderLimit() {\n        doTestSQL(\"DELETE FROM testTable ORDER BY content DESC LIMIT 1\", new TestOperation() {\n            @Override\n            public void execute() throws WCDBException {\n                handle.deleteValue(tableName, DBTestObject.content.order(Order.Desc), 1);\n            }\n        });\n        assertEquals(allRowsCount(), 1);\n    }\n\n    @Test\n    public void testHandleDeleteOrderLimitOffset() {\n        doTestSQL(\"DELETE FROM testTable ORDER BY content DESC LIMIT 1 OFFSET 1\", new TestOperation() {\n            @Override\n            public void execute() throws WCDBException {\n                handle.deleteValue(tableName, DBTestObject.content.order(Order.Desc), 1, 1);\n            }\n        });\n        assertEquals(allRowsCount(), 1);\n    }\n\n    @Test\n    public void testHandleDeleteWhereOrderLimit() {\n        doTestSQL(\"DELETE FROM testTable WHERE id IN(1, 3) ORDER BY content DESC LIMIT 1\", new TestOperation() {\n            @Override\n            public void execute() throws WCDBException {\n                handle.deleteValue(tableName, DBTestObject.id.in(new int[]{1, 3}), DBTestObject.content.order(Order.Desc), 1);\n            }\n        });\n        assertEquals(allRowsCount(), 1);\n    }\n\n    @Test\n    public void testHandleDeleteWhereOrderLimitOffset() {\n        doTestSQL(\"DELETE FROM testTable WHERE id IN(1, 2) ORDER BY content DESC LIMIT 1 OFFSET 1\", new TestOperation() {\n            @Override\n            public void execute() throws WCDBException {\n                handle.deleteValue(tableName, DBTestObject.id.in(new int[]{1, 2}), DBTestObject.content.order(Order.Desc), 1, 1);\n            }\n        });\n        assertEquals(allRowsCount(), 1);\n    }\n}\n"
  },
  {
    "path": "src/java/test/src/androidTest/java/com/tencent/wcdbtest/crud/ValueInsertWithColumnTest.java",
    "content": "// Created by chenqiuwen on 2023/5/14.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdbtest.crud;\n\nimport static org.junit.Assert.assertEquals;\n\nimport com.tencent.wcdb.base.Value;\nimport com.tencent.wcdb.base.WCDBException;\nimport com.tencent.wcdbtest.base.RandomTool;\nimport com.tencent.wcdbtest.base.ValueCRUDTestCase;\n\nimport org.junit.Test;\n\nimport java.util.Arrays;\nimport java.util.List;\n\npublic class ValueInsertWithColumnTest extends ValueCRUDTestCase {\n    @Test\n    public void testDatabaseInsertRow() {\n        final Value[] row = RandomTool.testRowWithId(nextId);\n        doTestSQL(\"INSERT INTO testTable(id, content) VALUES(?1, ?2)\",\n                new TestOperation() {\n                    @Override\n                    public void execute() throws WCDBException {\n                        database.insertRow(row, columns(), tableName);\n                    }\n                });\n        assertEquals(allRowsCount(), 3);\n    }\n\n    @Test\n    public void testDatabaseInsertOrReplaceRow() {\n        final Value[] row = RandomTool.testRowWithId(nextId - 1);\n        doTestSQL(\"INSERT OR REPLACE INTO testTable(id, content) VALUES(?1, ?2)\",\n                new TestOperation() {\n                    @Override\n                    public void execute() throws WCDBException {\n                        database.insertOrReplaceRow(row, columns(), tableName);\n                    }\n                });\n        assertEquals(allRowsCount(), 2);\n    }\n\n    @Test\n    public void testDatabaseInsertOrIgnoreRow() {\n        final Value[] row = RandomTool.testRowWithId(nextId - 1);\n        doTestSQL(\"INSERT OR IGNORE INTO testTable(id, content) VALUES(?1, ?2)\",\n                new TestOperation() {\n                    @Override\n                    public void execute() throws WCDBException {\n                        database.insertOrIgnoreRow(row, columns(), tableName);\n                    }\n                });\n        assertEquals(allRowsCount(), 2);\n    }\n\n    @Test\n    public void testDatabaseInsertRows() {\n        final List<Value[]> rows = Arrays.asList(RandomTool.testRowWithId(nextId), RandomTool.testRowWithId(nextId + 1));\n        expectMode = Expect.SomeSQLs;\n        doTestSQLs(new String[]{\n                        \"BEGIN IMMEDIATE\",\n                        \"INSERT INTO testTable(id, content) VALUES(?1, ?2)\",\n                        \"COMMIT\"\n                },\n                new TestOperation() {\n                    @Override\n                    public void execute() throws WCDBException {\n                        database.insertRows(rows, columns(), tableName);\n                    }\n                });\n        assertEquals(allRowsCount(), 4);\n    }\n\n    @Test\n    public void testDatabaseInsertOrReplaceRows() {\n        final List<Value[]> rows = Arrays.asList(RandomTool.testRowWithId(nextId - 2), RandomTool.testRowWithId(nextId - 1));\n        expectMode = Expect.SomeSQLs;\n        doTestSQLs(new String[]{\n                        \"BEGIN IMMEDIATE\",\n                        \"INSERT OR REPLACE INTO testTable(id, content) VALUES(?1, ?2)\",\n                        \"COMMIT\"\n                },\n                new TestOperation() {\n                    @Override\n                    public void execute() throws WCDBException {\n                        database.insertOrReplaceRows(rows, columns(), tableName);\n                    }\n                });\n        assertEquals(allRowsCount(), 2);\n    }\n\n    @Test\n    public void testDatabaseInsertOrIgnoreRows() {\n        final List<Value[]> rows = Arrays.asList(RandomTool.testRowWithId(nextId - 2), RandomTool.testRowWithId(nextId - 1));\n        expectMode = Expect.SomeSQLs;\n        doTestSQLs(new String[]{\n                        \"BEGIN IMMEDIATE\",\n                        \"INSERT OR IGNORE INTO testTable(id, content) VALUES(?1, ?2)\",\n                        \"COMMIT\"\n                },\n                new TestOperation() {\n                    @Override\n                    public void execute() throws WCDBException {\n                        database.insertOrIgnoreRows(rows, columns(), tableName);\n                    }\n                });\n        assertEquals(allRowsCount(), 2);\n    }\n\n    @Test\n    public void testHandleInsertRow() {\n        final Value[] row = RandomTool.testRowWithId(nextId);\n        doTestSQL(\"INSERT INTO testTable(id, content) VALUES(?1, ?2)\",\n                new TestOperation() {\n                    @Override\n                    public void execute() throws WCDBException {\n                        handle.insertRow(row, columns(), tableName);\n                    }\n                });\n        assertEquals(allRowsCount(), 3);\n    }\n\n    @Test\n    public void testHandleInsertOrReplaceRow() {\n        final Value[] row = RandomTool.testRowWithId(nextId - 1);\n        doTestSQL(\"INSERT OR REPLACE INTO testTable(id, content) VALUES(?1, ?2)\",\n                new TestOperation() {\n                    @Override\n                    public void execute() throws WCDBException {\n                        handle.insertOrReplaceRow(row, columns(), tableName);\n                    }\n                });\n        assertEquals(allRowsCount(), 2);\n    }\n\n    @Test\n    public void testHandleInsertOrIgnoreRow() {\n        final Value[] row = RandomTool.testRowWithId(nextId - 1);\n        doTestSQL(\"INSERT OR IGNORE INTO testTable(id, content) VALUES(?1, ?2)\",\n                new TestOperation() {\n                    @Override\n                    public void execute() throws WCDBException {\n                        handle.insertOrIgnoreRow(row, columns(), tableName);\n                    }\n                });\n        assertEquals(allRowsCount(), 2);\n    }\n\n    @Test\n    public void testHandleInsertRows() {\n        final List<Value[]> rows = Arrays.asList(RandomTool.testRowWithId(nextId), RandomTool.testRowWithId(nextId + 1));\n        expectMode = Expect.SomeSQLs;\n        doTestSQLs(new String[]{\n                        \"BEGIN IMMEDIATE\",\n                        \"INSERT INTO testTable(id, content) VALUES(?1, ?2)\",\n                        \"COMMIT\"\n                },\n                new TestOperation() {\n                    @Override\n                    public void execute() throws WCDBException {\n                        handle.insertRows(rows, columns(), tableName);\n                    }\n                });\n        assertEquals(allRowsCount(), 4);\n    }\n\n    @Test\n    public void testHandleInsertOrReplaceRows() {\n        final List<Value[]> rows = Arrays.asList(RandomTool.testRowWithId(nextId - 2), RandomTool.testRowWithId(nextId - 1));\n        expectMode = Expect.SomeSQLs;\n        doTestSQLs(new String[]{\n                        \"BEGIN IMMEDIATE\",\n                        \"INSERT OR REPLACE INTO testTable(id, content) VALUES(?1, ?2)\",\n                        \"COMMIT\"\n                },\n                new TestOperation() {\n                    @Override\n                    public void execute() throws WCDBException {\n                        handle.insertOrReplaceRows(rows, columns(), tableName);\n                    }\n                });\n        assertEquals(allRowsCount(), 2);\n    }\n\n    @Test\n    public void testHandleInsertOrIgnoreRows() {\n        final List<Value[]> rows = Arrays.asList(RandomTool.testRowWithId(nextId - 2), RandomTool.testRowWithId(nextId - 1));\n        expectMode = Expect.SomeSQLs;\n        doTestSQLs(new String[]{\n                        \"BEGIN IMMEDIATE\",\n                        \"INSERT OR IGNORE INTO testTable(id, content) VALUES(?1, ?2)\",\n                        \"COMMIT\"\n                },\n                new TestOperation() {\n                    @Override\n                    public void execute() throws WCDBException {\n                        handle.insertOrIgnoreRows(rows, columns(), tableName);\n                    }\n                });\n        assertEquals(allRowsCount(), 2);\n    }\n}\n"
  },
  {
    "path": "src/java/test/src/androidTest/java/com/tencent/wcdbtest/crud/ValueInsertWithFieldTest.java",
    "content": "// Created by chenqiuwen on 2023/5/14.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdbtest.crud;\n\nimport static org.junit.Assert.assertEquals;\n\nimport com.tencent.wcdb.base.Value;\nimport com.tencent.wcdb.base.WCDBException;\nimport com.tencent.wcdbtest.base.DBTestObject;\nimport com.tencent.wcdbtest.base.ObjectCRUDTestCase;\nimport com.tencent.wcdbtest.base.RandomTool;\n\nimport org.junit.Test;\n\nimport java.util.Arrays;\nimport java.util.List;\n\npublic class ValueInsertWithFieldTest extends ObjectCRUDTestCase {\n    @Test\n    public void testDatabaseInsertRow() {\n        final Value[] row = RandomTool.testRowWithId(nextId);\n        doTestSQL(\"INSERT INTO testTable(id, content) VALUES(?1, ?2)\",\n                new TestOperation() {\n                    @Override\n                    public void execute() throws WCDBException {\n                        database.insertRow(row, DBTestObject.allFields(), tableName);\n                    }\n                });\n        assertEquals(allRowsCount(), 3);\n    }\n\n    @Test\n    public void testDatabaseInsertOrReplaceRow() {\n        final Value[] row = RandomTool.testRowWithId(nextId - 1);\n        doTestSQL(\"INSERT OR REPLACE INTO testTable(id, content) VALUES(?1, ?2)\",\n                new TestOperation() {\n                    @Override\n                    public void execute() throws WCDBException {\n                        database.insertOrReplaceRow(row, DBTestObject.allFields(), tableName);\n                    }\n                });\n        assertEquals(allRowsCount(), 2);\n    }\n\n    @Test\n    public void testDatabaseInsertOrIgnoreRow() {\n        final Value[] row = RandomTool.testRowWithId(nextId - 1);\n        doTestSQL(\"INSERT OR IGNORE INTO testTable(id, content) VALUES(?1, ?2)\",\n                new TestOperation() {\n                    @Override\n                    public void execute() throws WCDBException {\n                        database.insertOrIgnoreRow(row, DBTestObject.allFields(), tableName);\n                    }\n                });\n        assertEquals(allRowsCount(), 2);\n    }\n\n    @Test\n    public void testDatabaseInsertRows() {\n        final List<Value[]> rows = Arrays.asList(RandomTool.testRowWithId(nextId), RandomTool.testRowWithId(nextId + 1));\n        expectMode = Expect.SomeSQLs;\n        doTestSQLs(new String[]{\n                        \"BEGIN IMMEDIATE\",\n                        \"INSERT INTO testTable(id, content) VALUES(?1, ?2)\",\n                        \"COMMIT\"\n                },\n                new TestOperation() {\n                    @Override\n                    public void execute() throws WCDBException {\n                        database.insertRows(rows, DBTestObject.allFields(), tableName);\n                    }\n                });\n        assertEquals(allRowsCount(), 4);\n    }\n\n    @Test\n    public void testDatabaseInsertOrReplaceRows() {\n        final List<Value[]> rows = Arrays.asList(RandomTool.testRowWithId(nextId - 2), RandomTool.testRowWithId(nextId - 1));\n        expectMode = Expect.SomeSQLs;\n        doTestSQLs(new String[]{\n                        \"BEGIN IMMEDIATE\",\n                        \"INSERT OR REPLACE INTO testTable(id, content) VALUES(?1, ?2)\",\n                        \"COMMIT\"\n                },\n                new TestOperation() {\n                    @Override\n                    public void execute() throws WCDBException {\n                        database.insertOrReplaceRows(rows, DBTestObject.allFields(), tableName);\n                    }\n                });\n        assertEquals(allRowsCount(), 2);\n    }\n\n    @Test\n    public void testDatabaseInsertOrIgnoreRows() {\n        final List<Value[]> rows = Arrays.asList(RandomTool.testRowWithId(nextId - 2), RandomTool.testRowWithId(nextId - 1));\n        expectMode = Expect.SomeSQLs;\n        doTestSQLs(new String[]{\n                        \"BEGIN IMMEDIATE\",\n                        \"INSERT OR IGNORE INTO testTable(id, content) VALUES(?1, ?2)\",\n                        \"COMMIT\"\n                },\n                new TestOperation() {\n                    @Override\n                    public void execute() throws WCDBException {\n                        database.insertOrIgnoreRows(rows, DBTestObject.allFields(), tableName);\n                    }\n                });\n        assertEquals(allRowsCount(), 2);\n    }\n\n    @Test\n    public void testTableInsertRow() {\n        final Value[] row = RandomTool.testRowWithId(nextId);\n        doTestSQL(\"INSERT INTO testTable(id, content) VALUES(?1, ?2)\",\n                new TestOperation() {\n                    @Override\n                    public void execute() throws WCDBException {\n                        table.insertRow(row, DBTestObject.allFields());\n                    }\n                });\n        assertEquals(allRowsCount(), 3);\n    }\n\n    @Test\n    public void testTableInsertOrReplaceRow() {\n        final Value[] row = RandomTool.testRowWithId(nextId - 1);\n        doTestSQL(\"INSERT OR REPLACE INTO testTable(id, content) VALUES(?1, ?2)\",\n                new TestOperation() {\n                    @Override\n                    public void execute() throws WCDBException {\n                        table.insertOrReplaceRow(row, DBTestObject.allFields());\n                    }\n                });\n        assertEquals(allRowsCount(), 2);\n    }\n\n    @Test\n    public void testTableInsertOrIgnoreRow() {\n        final Value[] row = RandomTool.testRowWithId(nextId - 1);\n        doTestSQL(\"INSERT OR IGNORE INTO testTable(id, content) VALUES(?1, ?2)\",\n                new TestOperation() {\n                    @Override\n                    public void execute() throws WCDBException {\n                        table.insertOrIgnoreRow(row, DBTestObject.allFields());\n                    }\n                });\n        assertEquals(allRowsCount(), 2);\n    }\n\n    @Test\n    public void testTableInsertRows() {\n        final List<Value[]> rows = Arrays.asList(RandomTool.testRowWithId(nextId), RandomTool.testRowWithId(nextId + 1));\n        expectMode = Expect.SomeSQLs;\n        doTestSQLs(new String[]{\n                        \"BEGIN IMMEDIATE\",\n                        \"INSERT INTO testTable(id, content) VALUES(?1, ?2)\",\n                        \"COMMIT\"\n                },\n                new TestOperation() {\n                    @Override\n                    public void execute() throws WCDBException {\n                        table.insertRows(rows, DBTestObject.allFields());\n                    }\n                });\n        assertEquals(allRowsCount(), 4);\n    }\n\n    @Test\n    public void testTableInsertOrReplaceRows() {\n        final List<Value[]> rows = Arrays.asList(RandomTool.testRowWithId(nextId - 2), RandomTool.testRowWithId(nextId - 1));\n        expectMode = Expect.SomeSQLs;\n        doTestSQLs(new String[]{\n                        \"BEGIN IMMEDIATE\",\n                        \"INSERT OR REPLACE INTO testTable(id, content) VALUES(?1, ?2)\",\n                        \"COMMIT\"\n                },\n                new TestOperation() {\n                    @Override\n                    public void execute() throws WCDBException {\n                        table.insertOrReplaceRows(rows, DBTestObject.allFields());\n                    }\n                });\n        assertEquals(allRowsCount(), 2);\n    }\n\n    @Test\n    public void testTableInsertOrIgnoreRows() {\n        final List<Value[]> rows = Arrays.asList(RandomTool.testRowWithId(nextId - 2), RandomTool.testRowWithId(nextId - 1));\n        expectMode = Expect.SomeSQLs;\n        doTestSQLs(new String[]{\n                        \"BEGIN IMMEDIATE\",\n                        \"INSERT OR IGNORE INTO testTable(id, content) VALUES(?1, ?2)\",\n                        \"COMMIT\"\n                },\n                new TestOperation() {\n                    @Override\n                    public void execute() throws WCDBException {\n                        table.insertOrIgnoreRows(rows, DBTestObject.allFields());\n                    }\n                });\n        assertEquals(allRowsCount(), 2);\n    }\n\n    @Test\n    public void testHandleInsertRow() {\n        final Value[] row = RandomTool.testRowWithId(nextId);\n        doTestSQL(\"INSERT INTO testTable(id, content) VALUES(?1, ?2)\",\n                new TestOperation() {\n                    @Override\n                    public void execute() throws WCDBException {\n                        handle.insertRow(row, DBTestObject.allFields(), tableName);\n                    }\n                });\n        assertEquals(allRowsCount(), 3);\n    }\n\n    @Test\n    public void testHandleInsertOrReplaceRow() {\n        final Value[] row = RandomTool.testRowWithId(nextId - 1);\n        doTestSQL(\"INSERT OR REPLACE INTO testTable(id, content) VALUES(?1, ?2)\",\n                new TestOperation() {\n                    @Override\n                    public void execute() throws WCDBException {\n                        handle.insertOrReplaceRow(row, DBTestObject.allFields(), tableName);\n                    }\n                });\n        assertEquals(allRowsCount(), 2);\n    }\n\n    @Test\n    public void testHandleInsertOrIgnoreRow() {\n        final Value[] row = RandomTool.testRowWithId(nextId - 1);\n        doTestSQL(\"INSERT OR IGNORE INTO testTable(id, content) VALUES(?1, ?2)\",\n                new TestOperation() {\n                    @Override\n                    public void execute() throws WCDBException {\n                        handle.insertOrIgnoreRow(row, DBTestObject.allFields(), tableName);\n                    }\n                });\n        assertEquals(allRowsCount(), 2);\n    }\n\n    @Test\n    public void testHandleInsertRows() {\n        final List<Value[]> rows = Arrays.asList(RandomTool.testRowWithId(nextId), RandomTool.testRowWithId(nextId + 1));\n        expectMode = Expect.SomeSQLs;\n        doTestSQLs(new String[]{\n                        \"BEGIN IMMEDIATE\",\n                        \"INSERT INTO testTable(id, content) VALUES(?1, ?2)\",\n                        \"COMMIT\"\n                },\n                new TestOperation() {\n                    @Override\n                    public void execute() throws WCDBException {\n                        handle.insertRows(rows, DBTestObject.allFields(), tableName);\n                    }\n                });\n        assertEquals(allRowsCount(), 4);\n    }\n\n    @Test\n    public void testHandleInsertOrReplaceRows() {\n        final List<Value[]> rows = Arrays.asList(RandomTool.testRowWithId(nextId - 2), RandomTool.testRowWithId(nextId - 1));\n        expectMode = Expect.SomeSQLs;\n        doTestSQLs(new String[]{\n                        \"BEGIN IMMEDIATE\",\n                        \"INSERT OR REPLACE INTO testTable(id, content) VALUES(?1, ?2)\",\n                        \"COMMIT\"\n                },\n                new TestOperation() {\n                    @Override\n                    public void execute() throws WCDBException {\n                        handle.insertOrReplaceRows(rows, DBTestObject.allFields(), tableName);\n                    }\n                });\n        assertEquals(allRowsCount(), 2);\n    }\n\n    @Test\n    public void testHandleInsertOrIgnoreRows() {\n        final List<Value[]> rows = Arrays.asList(RandomTool.testRowWithId(nextId - 2), RandomTool.testRowWithId(nextId - 1));\n        expectMode = Expect.SomeSQLs;\n        doTestSQLs(new String[]{\n                        \"BEGIN IMMEDIATE\",\n                        \"INSERT OR IGNORE INTO testTable(id, content) VALUES(?1, ?2)\",\n                        \"COMMIT\"\n                },\n                new TestOperation() {\n                    @Override\n                    public void execute() throws WCDBException {\n                        handle.insertOrIgnoreRows(rows, DBTestObject.allFields(), tableName);\n                    }\n                });\n        assertEquals(allRowsCount(), 2);\n    }\n}\n"
  },
  {
    "path": "src/java/test/src/androidTest/java/com/tencent/wcdbtest/crud/ValueSelectWithColumnTest.java",
    "content": "// Created by chenqiuwen on 2023/5/14.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdbtest.crud;\n\nimport static org.junit.Assert.assertEquals;\nimport static org.junit.Assert.assertTrue;\n\nimport com.tencent.wcdb.base.WCDBException;\nimport com.tencent.wcdb.winq.Order;\nimport com.tencent.wcdb.winq.ResultColumnConvertible;\nimport com.tencent.wcdbtest.base.ValueCRUDTestCase;\n\nimport org.junit.Test;\n\npublic class ValueSelectWithColumnTest extends ValueCRUDTestCase {\n    @Test\n    public void testDatabaseGetValue() {\n        doTestSQLs(new String[]{\n                \"SELECT content FROM testTable\",\n                \"SELECT content FROM testTable WHERE id == 1\",\n                \"SELECT COUNT(content) FROM testTable ORDER BY content ASC\",\n                \"SELECT SUM(id) FROM testTable ORDER BY content ASC LIMIT 1 OFFSET 0\",\n                \"SELECT COUNT(content) FROM testTable WHERE id == 2 ORDER BY content ASC\",\n                \"SELECT SUM(id) FROM testTable WHERE id == 2 ORDER BY content ASC LIMIT 1 OFFSET 0\"\n        }, new TestOperation() {\n            @Override\n            public void execute() throws WCDBException {\n                assertTrue(database.getValue(content, tableName).getText().length() > 0);\n                assertTrue(database.getValue(content, tableName, id.eq(1)).getText().length() > 0);\n                assertEquals(2, database.getValue(content.count(), tableName, content.order(Order.Asc)).getLong());\n                assertTrue(database.getValue(id.sum(), tableName, content.order(Order.Asc), 0).getLong() > 0);\n                assertEquals(1, database.getValue(content.count(), tableName, id.eq(2), content.order(Order.Asc)).getLong());\n                assertTrue(database.getValue(id.sum(), tableName, id.eq(2), content.order(Order.Asc), 0).getLong() > 0);\n            }\n        });\n    }\n\n    @Test\n    public void testDatabaseGetColumn() {\n        doTestSQLs(new String[]{\n                \"SELECT content FROM testTable\",\n                \"SELECT content FROM testTable WHERE id == 1\",\n                \"SELECT id FROM testTable ORDER BY content ASC\",\n                \"SELECT id FROM testTable ORDER BY content ASC LIMIT 1\",\n                \"SELECT id FROM testTable ORDER BY content ASC LIMIT 1 OFFSET 1\",\n                \"SELECT content FROM testTable WHERE id == 2 ORDER BY content ASC\",\n                \"SELECT content FROM testTable WHERE id == 2 ORDER BY content ASC LIMIT 1\",\n                \"SELECT content FROM testTable WHERE id == 2 ORDER BY content ASC LIMIT 1 OFFSET 1\",\n        }, new TestOperation() {\n            @Override\n            public void execute() throws WCDBException {\n                assertEquals(2, database.getOneColumn(content, tableName).size());\n                assertTrue(database.getOneColumn(content, tableName, id.eq(1)).get(0).getText().length() > 0);\n                assertEquals(2, database.getOneColumn(id, tableName, content.order(Order.Asc)).size());\n                assertEquals(1, database.getOneColumn(id, tableName, content.order(Order.Asc), 1).size());\n                assertEquals(1, database.getOneColumn(id, tableName, content.order(Order.Asc), 1, 1).size());\n                assertEquals(1, database.getOneColumn(content, tableName, id.eq(2), content.order(Order.Asc)).size());\n                assertEquals(1, database.getOneColumn(content, tableName, id.eq(2), content.order(Order.Asc), 1).size());\n                assertEquals(0, database.getOneColumn(content, tableName, id.eq(2), content.order(Order.Asc), 1, 1).size());\n            }\n        });\n    }\n\n    @Test\n    public void testDatabaseGetRow() {\n        doTestSQLs(new String[]{\n                \"SELECT id, content FROM testTable\",\n                \"SELECT id, content FROM testTable WHERE id == 1\",\n                \"SELECT id, COUNT(content) FROM testTable ORDER BY content ASC\",\n                \"SELECT SUM(id), content FROM testTable ORDER BY content ASC LIMIT 1 OFFSET 0\",\n                \"SELECT id, COUNT(content) FROM testTable WHERE id == 2 ORDER BY content ASC\",\n                \"SELECT SUM(id), content FROM testTable WHERE id == 2 ORDER BY content ASC LIMIT 1 OFFSET 0\"\n        }, new TestOperation() {\n            @Override\n            public void execute() throws WCDBException {\n                assertEquals(2, database.getOneRow(columns(), tableName).length);\n                assertEquals(1, database.getOneRow(columns(), tableName, id.eq(1))[0].getLong());\n                assertEquals(2, database.getOneRow(new ResultColumnConvertible[]{id, content.count()}, tableName, content.order(Order.Asc))[1].getLong());\n                assertTrue(database.getOneRow(new ResultColumnConvertible[]{id.sum(), content}, tableName, content.order(Order.Asc), 0)[0].getLong() > 0);\n                assertEquals(1, database.getOneRow(new ResultColumnConvertible[]{id, content.count()}, tableName, id.eq(2), content.order(Order.Asc))[1].getLong());\n                assertTrue(database.getOneRow(new ResultColumnConvertible[]{id.sum(), content}, tableName, id.eq(2), content.order(Order.Asc), 0)[0].getLong() > 0);\n            }\n        });\n    }\n\n    @Test\n    public void testDatabaseGetRows() {\n        doTestSQLs(new String[]{\n                \"SELECT id, content FROM testTable\",\n                \"SELECT id, content FROM testTable WHERE id == 1\",\n                \"SELECT id, content FROM testTable ORDER BY content ASC\",\n                \"SELECT id, content FROM testTable ORDER BY content ASC LIMIT 1\",\n                \"SELECT id, content FROM testTable ORDER BY content ASC LIMIT 1 OFFSET 1\",\n                \"SELECT id, content FROM testTable WHERE id == 2 ORDER BY content ASC\",\n                \"SELECT id, content FROM testTable WHERE id == 2 ORDER BY content ASC LIMIT 1\",\n                \"SELECT id, content FROM testTable WHERE id == 2 ORDER BY content ASC LIMIT 1 OFFSET 1\",\n        }, new TestOperation() {\n            @Override\n            public void execute() throws WCDBException {\n                assertEquals(2, database.getAllRows(columns(), tableName).size());\n                assertTrue(database.getAllRows(columns(), tableName, id.eq(1)).get(0)[1].getText().length() > 0);\n                assertEquals(2, database.getAllRows(columns(), tableName, content.order(Order.Asc)).size());\n                assertEquals(1, database.getAllRows(columns(), tableName, content.order(Order.Asc), 1).size());\n                assertEquals(1, database.getAllRows(columns(), tableName, content.order(Order.Asc), 1, 1).size());\n                assertEquals(1, database.getAllRows(columns(), tableName, id.eq(2), content.order(Order.Asc)).size());\n                assertEquals(1, database.getAllRows(columns(), tableName, id.eq(2), content.order(Order.Asc), 1).size());\n                assertEquals(0, database.getAllRows(columns(), tableName, id.eq(2), content.order(Order.Asc), 1, 1).size());\n            }\n        });\n    }\n\n    @Test\n    public void testHandleGetValue() {\n        doTestSQLs(new String[]{\n                \"SELECT content FROM testTable\",\n                \"SELECT content FROM testTable WHERE id == 1\",\n                \"SELECT COUNT(content) FROM testTable ORDER BY content ASC\",\n                \"SELECT SUM(id) FROM testTable ORDER BY content ASC LIMIT 1 OFFSET 0\",\n                \"SELECT COUNT(content) FROM testTable WHERE id == 2 ORDER BY content ASC\",\n                \"SELECT SUM(id) FROM testTable WHERE id == 2 ORDER BY content ASC LIMIT 1 OFFSET 0\"\n        }, new TestOperation() {\n            @Override\n            public void execute() throws WCDBException {\n                assertTrue(handle.getValue(content, tableName).getText().length() > 0);\n                assertTrue(handle.getValue(content, tableName, id.eq(1)).getText().length() > 0);\n                assertEquals(2, handle.getValue(content.count(), tableName, content.order(Order.Asc)).getLong());\n                assertTrue(handle.getValue(id.sum(), tableName, content.order(Order.Asc), 0).getLong() > 0);\n                assertEquals(1, handle.getValue(content.count(), tableName, id.eq(2), content.order(Order.Asc)).getLong());\n                assertTrue(handle.getValue(id.sum(), tableName, id.eq(2), content.order(Order.Asc), 0).getLong() > 0);\n            }\n        });\n    }\n\n    @Test\n    public void testHandleGetColumn() {\n        doTestSQLs(new String[]{\n                \"SELECT content FROM testTable\",\n                \"SELECT content FROM testTable WHERE id == 1\",\n                \"SELECT id FROM testTable ORDER BY content ASC\",\n                \"SELECT id FROM testTable ORDER BY content ASC LIMIT 1\",\n                \"SELECT id FROM testTable ORDER BY content ASC LIMIT 1 OFFSET 1\",\n                \"SELECT content FROM testTable WHERE id == 2 ORDER BY content ASC\",\n                \"SELECT content FROM testTable WHERE id == 2 ORDER BY content ASC LIMIT 1\",\n                \"SELECT content FROM testTable WHERE id == 2 ORDER BY content ASC LIMIT 1 OFFSET 1\",\n        }, new TestOperation() {\n            @Override\n            public void execute() throws WCDBException {\n                assertEquals(2, handle.getOneColumn(content, tableName).size());\n                assertTrue(handle.getOneColumn(content, tableName, id.eq(1)).get(0).getText().length() > 0);\n                assertEquals(2, handle.getOneColumn(id, tableName, content.order(Order.Asc)).size());\n                assertEquals(1, handle.getOneColumn(id, tableName, content.order(Order.Asc), 1).size());\n                assertEquals(1, handle.getOneColumn(id, tableName, content.order(Order.Asc), 1, 1).size());\n                assertEquals(1, handle.getOneColumn(content, tableName, id.eq(2), content.order(Order.Asc)).size());\n                assertEquals(1, handle.getOneColumn(content, tableName, id.eq(2), content.order(Order.Asc), 1).size());\n                assertEquals(0, handle.getOneColumn(content, tableName, id.eq(2), content.order(Order.Asc), 1, 1).size());\n            }\n        });\n    }\n\n    @Test\n    public void testHandleGetRow() {\n        doTestSQLs(new String[]{\n                \"SELECT id, content FROM testTable\",\n                \"SELECT id, content FROM testTable WHERE id == 1\",\n                \"SELECT id, COUNT(content) FROM testTable ORDER BY content ASC\",\n                \"SELECT SUM(id), content FROM testTable ORDER BY content ASC LIMIT 1 OFFSET 0\",\n                \"SELECT id, COUNT(content) FROM testTable WHERE id == 2 ORDER BY content ASC\",\n                \"SELECT SUM(id), content FROM testTable WHERE id == 2 ORDER BY content ASC LIMIT 1 OFFSET 0\"\n        }, new TestOperation() {\n            @Override\n            public void execute() throws WCDBException {\n                assertEquals(2, handle.getOneRow(columns(), tableName).length);\n                assertEquals(1, handle.getOneRow(columns(), tableName, id.eq(1))[0].getLong());\n                assertEquals(2, handle.getOneRow(new ResultColumnConvertible[]{id, content.count()}, tableName, content.order(Order.Asc))[1].getLong());\n                assertTrue(handle.getOneRow(new ResultColumnConvertible[]{id.sum(), content}, tableName, content.order(Order.Asc), 0)[0].getLong() > 0);\n                assertEquals(1, handle.getOneRow(new ResultColumnConvertible[]{id, content.count()}, tableName, id.eq(2), content.order(Order.Asc))[1].getLong());\n                assertTrue(handle.getOneRow(new ResultColumnConvertible[]{id.sum(), content}, tableName, id.eq(2), content.order(Order.Asc), 0)[0].getLong() > 0);\n            }\n        });\n    }\n\n    @Test\n    public void testHandleGetRows() {\n        doTestSQLs(new String[]{\n                \"SELECT id, content FROM testTable\",\n                \"SELECT id, content FROM testTable WHERE id == 1\",\n                \"SELECT id, content FROM testTable ORDER BY content ASC\",\n                \"SELECT id, content FROM testTable ORDER BY content ASC LIMIT 1\",\n                \"SELECT id, content FROM testTable ORDER BY content ASC LIMIT 1 OFFSET 1\",\n                \"SELECT id, content FROM testTable WHERE id == 2 ORDER BY content ASC\",\n                \"SELECT id, content FROM testTable WHERE id == 2 ORDER BY content ASC LIMIT 1\",\n                \"SELECT id, content FROM testTable WHERE id == 2 ORDER BY content ASC LIMIT 1 OFFSET 1\",\n        }, new TestOperation() {\n            @Override\n            public void execute() throws WCDBException {\n                assertEquals(2, handle.getAllRows(columns(), tableName).size());\n                assertTrue(handle.getAllRows(columns(), tableName, id.eq(1)).get(0)[1].getText().length() > 0);\n                assertEquals(2, handle.getAllRows(columns(), tableName, content.order(Order.Asc)).size());\n                assertEquals(1, handle.getAllRows(columns(), tableName, content.order(Order.Asc), 1).size());\n                assertEquals(1, handle.getAllRows(columns(), tableName, content.order(Order.Asc), 1, 1).size());\n                assertEquals(1, handle.getAllRows(columns(), tableName, id.eq(2), content.order(Order.Asc)).size());\n                assertEquals(1, handle.getAllRows(columns(), tableName, id.eq(2), content.order(Order.Asc), 1).size());\n                assertEquals(0, handle.getAllRows(columns(), tableName, id.eq(2), content.order(Order.Asc), 1, 1).size());\n            }\n        });\n    }\n}\n"
  },
  {
    "path": "src/java/test/src/androidTest/java/com/tencent/wcdbtest/crud/ValueSelectWithFieldTest.java",
    "content": "// Created by chenqiuwen on 2023/5/14.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdbtest.crud;\n\nimport static org.junit.Assert.assertEquals;\nimport static org.junit.Assert.assertTrue;\n\nimport com.tencent.wcdb.base.WCDBException;\nimport com.tencent.wcdb.winq.Order;\nimport com.tencent.wcdb.winq.ResultColumnConvertible;\nimport com.tencent.wcdbtest.base.DBTestObject;\nimport com.tencent.wcdbtest.base.ObjectCRUDTestCase;\n\nimport org.junit.Test;\n\npublic class ValueSelectWithFieldTest extends ObjectCRUDTestCase {\n    @Test\n    public void testDatabaseGetValue() {\n        doTestSQLs(new String[]{\n                \"SELECT content FROM testTable\",\n                \"SELECT content FROM testTable WHERE id == 1\",\n                \"SELECT COUNT(content) FROM testTable ORDER BY content ASC\",\n                \"SELECT SUM(id) FROM testTable ORDER BY content ASC LIMIT 1 OFFSET 0\",\n                \"SELECT COUNT(content) FROM testTable WHERE id == 2 ORDER BY content ASC\",\n                \"SELECT SUM(id) FROM testTable WHERE id == 2 ORDER BY content ASC LIMIT 1 OFFSET 0\"\n        }, new TestOperation() {\n            @Override\n            public void execute() throws WCDBException {\n                assertTrue(database.getValue(DBTestObject.content, tableName).getText().length() > 0);\n                assertTrue(database.getValue(DBTestObject.content, tableName, DBTestObject.id.eq(1)).getText().length() > 0);\n                assertEquals(2, database.getValue(DBTestObject.content.count(), tableName, DBTestObject.content.order(Order.Asc)).getLong());\n                assertTrue(database.getValue(DBTestObject.id.sum(), tableName, DBTestObject.content.order(Order.Asc), 0).getLong() > 0);\n                assertEquals(1, database.getValue(DBTestObject.content.count(), tableName, DBTestObject.id.eq(2), DBTestObject.content.order(Order.Asc)).getLong());\n                assertTrue(database.getValue(DBTestObject.id.sum(), tableName, DBTestObject.id.eq(2), DBTestObject.content.order(Order.Asc), 0).getLong() > 0);\n            }\n        });\n    }\n\n    @Test\n    public void testDatabaseGetColumn() {\n        doTestSQLs(new String[]{\n                \"SELECT content FROM testTable\",\n                \"SELECT content FROM testTable WHERE id == 1\",\n                \"SELECT id FROM testTable ORDER BY content ASC\",\n                \"SELECT id FROM testTable ORDER BY content ASC LIMIT 1\",\n                \"SELECT id FROM testTable ORDER BY content ASC LIMIT 1 OFFSET 1\",\n                \"SELECT content FROM testTable WHERE id == 2 ORDER BY content ASC\",\n                \"SELECT content FROM testTable WHERE id == 2 ORDER BY content ASC LIMIT 1\",\n                \"SELECT content FROM testTable WHERE id == 2 ORDER BY content ASC LIMIT 1 OFFSET 1\",\n        }, new TestOperation() {\n            @Override\n            public void execute() throws WCDBException {\n                assertEquals(2, database.getOneColumn(DBTestObject.content, tableName).size());\n                assertTrue(database.getOneColumn(DBTestObject.content, tableName, DBTestObject.id.eq(1)).get(0).getText().length() > 0);\n                assertEquals(2, database.getOneColumn(DBTestObject.id, tableName, DBTestObject.content.order(Order.Asc)).size());\n                assertEquals(1, database.getOneColumn(DBTestObject.id, tableName, DBTestObject.content.order(Order.Asc), 1).size());\n                assertEquals(1, database.getOneColumn(DBTestObject.id, tableName, DBTestObject.content.order(Order.Asc), 1, 1).size());\n                assertEquals(1, database.getOneColumn(DBTestObject.content, tableName, DBTestObject.id.eq(2), DBTestObject.content.order(Order.Asc)).size());\n                assertEquals(1, database.getOneColumn(DBTestObject.content, tableName, DBTestObject.id.eq(2), DBTestObject.content.order(Order.Asc), 1).size());\n                assertEquals(0, database.getOneColumn(DBTestObject.content, tableName, DBTestObject.id.eq(2), DBTestObject.content.order(Order.Asc), 1, 1).size());\n            }\n        });\n    }\n\n    @Test\n    public void testDatabaseGetRow() {\n        doTestSQLs(new String[]{\n                \"SELECT id, content FROM testTable\",\n                \"SELECT id, content FROM testTable WHERE id == 1\",\n                \"SELECT id, COUNT(content) FROM testTable ORDER BY content ASC\",\n                \"SELECT SUM(id), content FROM testTable ORDER BY content ASC LIMIT 1 OFFSET 0\",\n                \"SELECT id, COUNT(content) FROM testTable WHERE id == 2 ORDER BY content ASC\",\n                \"SELECT SUM(id), content FROM testTable WHERE id == 2 ORDER BY content ASC LIMIT 1 OFFSET 0\"\n        }, new TestOperation() {\n            @Override\n            public void execute() throws WCDBException {\n                assertEquals(2, database.getOneRow(DBTestObject.allFields(), tableName).length);\n                assertEquals(1, database.getOneRow(DBTestObject.allFields(), tableName, DBTestObject.id.eq(1))[0].getLong());\n                assertEquals(2, database.getOneRow(new ResultColumnConvertible[]{DBTestObject.id, DBTestObject.content.count()}, tableName, DBTestObject.content.order(Order.Asc))[1].getLong());\n                assertTrue(database.getOneRow(new ResultColumnConvertible[]{DBTestObject.id.sum(), DBTestObject.content}, tableName, DBTestObject.content.order(Order.Asc), 0)[0].getLong() > 0);\n                assertEquals(1, database.getOneRow(new ResultColumnConvertible[]{DBTestObject.id, DBTestObject.content.count()}, tableName, DBTestObject.id.eq(2), DBTestObject.content.order(Order.Asc))[1].getLong());\n                assertTrue(database.getOneRow(new ResultColumnConvertible[]{DBTestObject.id.sum(), DBTestObject.content}, tableName, DBTestObject.id.eq(2), DBTestObject.content.order(Order.Asc), 0)[0].getLong() > 0);\n            }\n        });\n    }\n\n    @Test\n    public void testDatabaseGetRows() {\n        doTestSQLs(new String[]{\n                \"SELECT id, content FROM testTable\",\n                \"SELECT id, content FROM testTable WHERE id == 1\",\n                \"SELECT id, content FROM testTable ORDER BY content ASC\",\n                \"SELECT id, content FROM testTable ORDER BY content ASC LIMIT 1\",\n                \"SELECT id, content FROM testTable ORDER BY content ASC LIMIT 1 OFFSET 1\",\n                \"SELECT id, content FROM testTable WHERE id == 2 ORDER BY content ASC\",\n                \"SELECT id, content FROM testTable WHERE id == 2 ORDER BY content ASC LIMIT 1\",\n                \"SELECT id, content FROM testTable WHERE id == 2 ORDER BY content ASC LIMIT 1 OFFSET 1\",\n        }, new TestOperation() {\n            @Override\n            public void execute() throws WCDBException {\n                assertEquals(2, database.getAllRows(DBTestObject.allFields(), tableName).size());\n                assertTrue(database.getAllRows(DBTestObject.allFields(), tableName, DBTestObject.id.eq(1)).get(0)[1].getText().length() > 0);\n                assertEquals(2, database.getAllRows(DBTestObject.allFields(), tableName, DBTestObject.content.order(Order.Asc)).size());\n                assertEquals(1, database.getAllRows(DBTestObject.allFields(), tableName, DBTestObject.content.order(Order.Asc), 1).size());\n                assertEquals(1, database.getAllRows(DBTestObject.allFields(), tableName, DBTestObject.content.order(Order.Asc), 1, 1).size());\n                assertEquals(1, database.getAllRows(DBTestObject.allFields(), tableName, DBTestObject.id.eq(2), DBTestObject.content.order(Order.Asc)).size());\n                assertEquals(1, database.getAllRows(DBTestObject.allFields(), tableName, DBTestObject.id.eq(2), DBTestObject.content.order(Order.Asc), 1).size());\n                assertEquals(0, database.getAllRows(DBTestObject.allFields(), tableName, DBTestObject.id.eq(2), DBTestObject.content.order(Order.Asc), 1, 1).size());\n            }\n        });\n    }\n\n    @Test\n    public void testTableGetValue() {\n        doTestSQLs(new String[]{\n                \"SELECT content FROM testTable\",\n                \"SELECT content FROM testTable WHERE id == 1\",\n                \"SELECT COUNT(content) FROM testTable ORDER BY content ASC\",\n                \"SELECT SUM(id) FROM testTable ORDER BY content ASC LIMIT 1 OFFSET 0\",\n                \"SELECT COUNT(content) FROM testTable WHERE id == 2 ORDER BY content ASC\",\n                \"SELECT SUM(id) FROM testTable WHERE id == 2 ORDER BY content ASC LIMIT 1 OFFSET 0\"\n        }, new TestOperation() {\n            @Override\n            public void execute() throws WCDBException {\n                assertTrue(table.getValue(DBTestObject.content).getText().length() > 0);\n                assertTrue(table.getValue(DBTestObject.content, DBTestObject.id.eq(1)).getText().length() > 0);\n                assertEquals(2, table.getValue(DBTestObject.content.count(), DBTestObject.content.order(Order.Asc)).getLong());\n                assertTrue(table.getValue(DBTestObject.id.sum(), DBTestObject.content.order(Order.Asc), 0).getLong() > 0);\n                assertEquals(1, table.getValue(DBTestObject.content.count(), DBTestObject.id.eq(2), DBTestObject.content.order(Order.Asc)).getLong());\n                assertTrue(table.getValue(DBTestObject.id.sum(), DBTestObject.id.eq(2), DBTestObject.content.order(Order.Asc), 0).getLong() > 0);\n            }\n        });\n    }\n\n    @Test\n    public void testTableGetColumn() {\n        doTestSQLs(new String[]{\n                \"SELECT content FROM testTable\",\n                \"SELECT content FROM testTable WHERE id == 1\",\n                \"SELECT id FROM testTable ORDER BY content ASC\",\n                \"SELECT id FROM testTable ORDER BY content ASC LIMIT 1\",\n                \"SELECT id FROM testTable ORDER BY content ASC LIMIT 1 OFFSET 1\",\n                \"SELECT content FROM testTable WHERE id == 2 ORDER BY content ASC\",\n                \"SELECT content FROM testTable WHERE id == 2 ORDER BY content ASC LIMIT 1\",\n                \"SELECT content FROM testTable WHERE id == 2 ORDER BY content ASC LIMIT 1 OFFSET 1\",\n        }, new TestOperation() {\n            @Override\n            public void execute() throws WCDBException {\n                assertEquals(2, table.getOneColumn(DBTestObject.content).size());\n                assertTrue(table.getOneColumn(DBTestObject.content, DBTestObject.id.eq(1)).get(0).getText().length() > 0);\n                assertEquals(2, table.getOneColumn(DBTestObject.id, DBTestObject.content.order(Order.Asc)).size());\n                assertEquals(1, table.getOneColumn(DBTestObject.id, DBTestObject.content.order(Order.Asc), 1).size());\n                assertEquals(1, table.getOneColumn(DBTestObject.id, DBTestObject.content.order(Order.Asc), 1, 1).size());\n                assertEquals(1, table.getOneColumn(DBTestObject.content, DBTestObject.id.eq(2), DBTestObject.content.order(Order.Asc)).size());\n                assertEquals(1, table.getOneColumn(DBTestObject.content, DBTestObject.id.eq(2), DBTestObject.content.order(Order.Asc), 1).size());\n                assertEquals(0, table.getOneColumn(DBTestObject.content, DBTestObject.id.eq(2), DBTestObject.content.order(Order.Asc), 1, 1).size());\n            }\n        });\n    }\n\n    @Test\n    public void testTableGetRow() {\n        doTestSQLs(new String[]{\n                \"SELECT id, content FROM testTable\",\n                \"SELECT id, content FROM testTable WHERE id == 1\",\n                \"SELECT id, COUNT(content) FROM testTable ORDER BY content ASC\",\n                \"SELECT SUM(id), content FROM testTable ORDER BY content ASC LIMIT 1 OFFSET 0\",\n                \"SELECT id, COUNT(content) FROM testTable WHERE id == 2 ORDER BY content ASC\",\n                \"SELECT SUM(id), content FROM testTable WHERE id == 2 ORDER BY content ASC LIMIT 1 OFFSET 0\"\n        }, new TestOperation() {\n            @Override\n            public void execute() throws WCDBException {\n                assertEquals(2, table.getOneRow(DBTestObject.allFields()).length);\n                assertEquals(1, table.getOneRow(DBTestObject.allFields(), DBTestObject.id.eq(1))[0].getLong());\n                assertEquals(2, table.getOneRow(new ResultColumnConvertible[]{DBTestObject.id, DBTestObject.content.count()}, DBTestObject.content.order(Order.Asc))[1].getLong());\n                assertTrue(table.getOneRow(new ResultColumnConvertible[]{DBTestObject.id.sum(), DBTestObject.content}, DBTestObject.content.order(Order.Asc), 0)[0].getLong() > 0);\n                assertEquals(1, table.getOneRow(new ResultColumnConvertible[]{DBTestObject.id, DBTestObject.content.count()}, DBTestObject.id.eq(2), DBTestObject.content.order(Order.Asc))[1].getLong());\n                assertTrue(table.getOneRow(new ResultColumnConvertible[]{DBTestObject.id.sum(), DBTestObject.content}, DBTestObject.id.eq(2), DBTestObject.content.order(Order.Asc), 0)[0].getLong() > 0);\n            }\n        });\n    }\n\n    @Test\n    public void testTableGetRows() {\n        doTestSQLs(new String[]{\n                \"SELECT id, content FROM testTable\",\n                \"SELECT id, content FROM testTable WHERE id == 1\",\n                \"SELECT id, content FROM testTable ORDER BY content ASC\",\n                \"SELECT id, content FROM testTable ORDER BY content ASC LIMIT 1\",\n                \"SELECT id, content FROM testTable ORDER BY content ASC LIMIT 1 OFFSET 1\",\n                \"SELECT id, content FROM testTable WHERE id == 2 ORDER BY content ASC\",\n                \"SELECT id, content FROM testTable WHERE id == 2 ORDER BY content ASC LIMIT 1\",\n                \"SELECT id, content FROM testTable WHERE id == 2 ORDER BY content ASC LIMIT 1 OFFSET 1\",\n        }, new TestOperation() {\n            @Override\n            public void execute() throws WCDBException {\n                assertEquals(2, table.getAllRows(DBTestObject.allFields()).size());\n                assertTrue(table.getAllRows(DBTestObject.allFields(), DBTestObject.id.eq(1)).get(0)[1].getText().length() > 0);\n                assertEquals(2, table.getAllRows(DBTestObject.allFields(), DBTestObject.content.order(Order.Asc)).size());\n                assertEquals(1, table.getAllRows(DBTestObject.allFields(), DBTestObject.content.order(Order.Asc), 1).size());\n                assertEquals(1, table.getAllRows(DBTestObject.allFields(), DBTestObject.content.order(Order.Asc), 1, 1).size());\n                assertEquals(1, table.getAllRows(DBTestObject.allFields(), DBTestObject.id.eq(2), DBTestObject.content.order(Order.Asc)).size());\n                assertEquals(1, table.getAllRows(DBTestObject.allFields(), DBTestObject.id.eq(2), DBTestObject.content.order(Order.Asc), 1).size());\n                assertEquals(0, table.getAllRows(DBTestObject.allFields(), DBTestObject.id.eq(2), DBTestObject.content.order(Order.Asc), 1, 1).size());\n            }\n        });\n    }\n\n    @Test\n    public void testHandleGetValue() {\n        doTestSQLs(new String[]{\n                \"SELECT content FROM testTable\",\n                \"SELECT content FROM testTable WHERE id == 1\",\n                \"SELECT COUNT(content) FROM testTable ORDER BY content ASC\",\n                \"SELECT SUM(id) FROM testTable ORDER BY content ASC LIMIT 1 OFFSET 0\",\n                \"SELECT COUNT(content) FROM testTable WHERE id == 2 ORDER BY content ASC\",\n                \"SELECT SUM(id) FROM testTable WHERE id == 2 ORDER BY content ASC LIMIT 1 OFFSET 0\"\n        }, new TestOperation() {\n            @Override\n            public void execute() throws WCDBException {\n                assertTrue(handle.getValue(DBTestObject.content, tableName).getText().length() > 0);\n                assertTrue(handle.getValue(DBTestObject.content, tableName, DBTestObject.id.eq(1)).getText().length() > 0);\n                assertEquals(2, handle.getValue(DBTestObject.content.count(), tableName, DBTestObject.content.order(Order.Asc)).getLong());\n                assertTrue(handle.getValue(DBTestObject.id.sum(), tableName, DBTestObject.content.order(Order.Asc), 0).getLong() > 0);\n                assertEquals(1, handle.getValue(DBTestObject.content.count(), tableName, DBTestObject.id.eq(2), DBTestObject.content.order(Order.Asc)).getLong());\n                assertTrue(handle.getValue(DBTestObject.id.sum(), tableName, DBTestObject.id.eq(2), DBTestObject.content.order(Order.Asc), 0).getLong() > 0);\n            }\n        });\n    }\n\n    @Test\n    public void testHandleGetColumn() {\n        doTestSQLs(new String[]{\n                \"SELECT content FROM testTable\",\n                \"SELECT content FROM testTable WHERE id == 1\",\n                \"SELECT id FROM testTable ORDER BY content ASC\",\n                \"SELECT id FROM testTable ORDER BY content ASC LIMIT 1\",\n                \"SELECT id FROM testTable ORDER BY content ASC LIMIT 1 OFFSET 1\",\n                \"SELECT content FROM testTable WHERE id == 2 ORDER BY content ASC\",\n                \"SELECT content FROM testTable WHERE id == 2 ORDER BY content ASC LIMIT 1\",\n                \"SELECT content FROM testTable WHERE id == 2 ORDER BY content ASC LIMIT 1 OFFSET 1\",\n        }, new TestOperation() {\n            @Override\n            public void execute() throws WCDBException {\n                assertEquals(2, handle.getOneColumn(DBTestObject.content, tableName).size());\n                assertTrue(handle.getOneColumn(DBTestObject.content, tableName, DBTestObject.id.eq(1)).get(0).getText().length() > 0);\n                assertEquals(2, handle.getOneColumn(DBTestObject.id, tableName, DBTestObject.content.order(Order.Asc)).size());\n                assertEquals(1, handle.getOneColumn(DBTestObject.id, tableName, DBTestObject.content.order(Order.Asc), 1).size());\n                assertEquals(1, handle.getOneColumn(DBTestObject.id, tableName, DBTestObject.content.order(Order.Asc), 1, 1).size());\n                assertEquals(1, handle.getOneColumn(DBTestObject.content, tableName, DBTestObject.id.eq(2), DBTestObject.content.order(Order.Asc)).size());\n                assertEquals(1, handle.getOneColumn(DBTestObject.content, tableName, DBTestObject.id.eq(2), DBTestObject.content.order(Order.Asc), 1).size());\n                assertEquals(0, handle.getOneColumn(DBTestObject.content, tableName, DBTestObject.id.eq(2), DBTestObject.content.order(Order.Asc), 1, 1).size());\n            }\n        });\n    }\n\n    @Test\n    public void testHandleGetRow() {\n        doTestSQLs(new String[]{\n                \"SELECT id, content FROM testTable\",\n                \"SELECT id, content FROM testTable WHERE id == 1\",\n                \"SELECT id, COUNT(content) FROM testTable ORDER BY content ASC\",\n                \"SELECT SUM(id), content FROM testTable ORDER BY content ASC LIMIT 1 OFFSET 0\",\n                \"SELECT id, COUNT(content) FROM testTable WHERE id == 2 ORDER BY content ASC\",\n                \"SELECT SUM(id), content FROM testTable WHERE id == 2 ORDER BY content ASC LIMIT 1 OFFSET 0\"\n        }, new TestOperation() {\n            @Override\n            public void execute() throws WCDBException {\n                assertEquals(2, handle.getOneRow(DBTestObject.allFields(), tableName).length);\n                assertEquals(1, handle.getOneRow(DBTestObject.allFields(), tableName, DBTestObject.id.eq(1))[0].getLong());\n                assertEquals(2, handle.getOneRow(new ResultColumnConvertible[]{DBTestObject.id, DBTestObject.content.count()}, tableName, DBTestObject.content.order(Order.Asc))[1].getLong());\n                assertTrue(handle.getOneRow(new ResultColumnConvertible[]{DBTestObject.id.sum(), DBTestObject.content}, tableName, DBTestObject.content.order(Order.Asc), 0)[0].getLong() > 0);\n                assertEquals(1, handle.getOneRow(new ResultColumnConvertible[]{DBTestObject.id, DBTestObject.content.count()}, tableName, DBTestObject.id.eq(2), DBTestObject.content.order(Order.Asc))[1].getLong());\n                assertTrue(handle.getOneRow(new ResultColumnConvertible[]{DBTestObject.id.sum(), DBTestObject.content}, tableName, DBTestObject.id.eq(2), DBTestObject.content.order(Order.Asc), 0)[0].getLong() > 0);\n            }\n        });\n    }\n\n    @Test\n    public void testHandleGetRows() {\n        doTestSQLs(new String[]{\n                \"SELECT id, content FROM testTable\",\n                \"SELECT id, content FROM testTable WHERE id == 1\",\n                \"SELECT id, content FROM testTable ORDER BY content ASC\",\n                \"SELECT id, content FROM testTable ORDER BY content ASC LIMIT 1\",\n                \"SELECT id, content FROM testTable ORDER BY content ASC LIMIT 1 OFFSET 1\",\n                \"SELECT id, content FROM testTable WHERE id == 2 ORDER BY content ASC\",\n                \"SELECT id, content FROM testTable WHERE id == 2 ORDER BY content ASC LIMIT 1\",\n                \"SELECT id, content FROM testTable WHERE id == 2 ORDER BY content ASC LIMIT 1 OFFSET 1\",\n        }, new TestOperation() {\n            @Override\n            public void execute() throws WCDBException {\n                assertEquals(2, handle.getAllRows(DBTestObject.allFields(), tableName).size());\n                assertTrue(handle.getAllRows(DBTestObject.allFields(), tableName, DBTestObject.id.eq(1)).get(0)[1].getText().length() > 0);\n                assertEquals(2, handle.getAllRows(DBTestObject.allFields(), tableName, DBTestObject.content.order(Order.Asc)).size());\n                assertEquals(1, handle.getAllRows(DBTestObject.allFields(), tableName, DBTestObject.content.order(Order.Asc), 1).size());\n                assertEquals(1, handle.getAllRows(DBTestObject.allFields(), tableName, DBTestObject.content.order(Order.Asc), 1, 1).size());\n                assertEquals(1, handle.getAllRows(DBTestObject.allFields(), tableName, DBTestObject.id.eq(2), DBTestObject.content.order(Order.Asc)).size());\n                assertEquals(1, handle.getAllRows(DBTestObject.allFields(), tableName, DBTestObject.id.eq(2), DBTestObject.content.order(Order.Asc), 1).size());\n                assertEquals(0, handle.getAllRows(DBTestObject.allFields(), tableName, DBTestObject.id.eq(2), DBTestObject.content.order(Order.Asc), 1, 1).size());\n            }\n        });\n    }\n}\n"
  },
  {
    "path": "src/java/test/src/androidTest/java/com/tencent/wcdbtest/crud/ValueUpdateWithColumnTest.java",
    "content": "// Created by chenqiuwen on 2023/5/14.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage com.tencent.wcdbtest.crud;\n\nimport static org.junit.Assert.assertEquals;\nimport static org.junit.Assert.assertTrue;\n\nimport com.tencent.wcdb.base.Value;\nimport com.tencent.wcdb.base.WCDBException;\nimport com.tencent.wcdb.winq.Order;\nimport com.tencent.wcdbtest.base.ValueCRUDTestCase;\n\nimport org.junit.Test;\n\npublic class ValueUpdateWithColumnTest extends ValueCRUDTestCase {\n    @Test\n    public void testDatabaseUpdateValue() throws WCDBException {\n        doTestSQL(\"UPDATE testTable SET content = ?1\", new TestOperation() {\n            @Override\n            public void execute() throws WCDBException {\n                database.updateValue(\"newContent\", content, tableName);\n            }\n        });\n        assertEquals(database.getValue(content, tableName).getText(), \"newContent\");\n    }\n\n    @Test\n    public void testDatabaseUpdateValueWhere() throws WCDBException {\n        doTestSQLs(new String[]{\n                \"UPDATE testTable SET content = ?1 WHERE id == 1\",\n                \"UPDATE testTable SET id = ?1 WHERE content == 'newContent'\"\n        }, new TestOperation() {\n            @Override\n            public void execute() throws WCDBException {\n                database.updateValue(\"newContent\", content, tableName, id.eq(1));\n                database.updateValue(nextId, id, tableName, content.eq(\"newContent\"));\n            }\n        });\n        assertEquals(database.getValue(content, tableName, id.eq(nextId)).getText(), \"newContent\");\n        assertEquals(database.getValue(id, tableName, content.eq(\"newContent\")).getLong(), nextId);\n    }\n\n    @Test\n    public void testDatabaseUpdateValueWhereOrderLimit() throws WCDBException {\n        doTestSQLs(new String[]{\n                \"UPDATE testTable SET content = ?1 WHERE id > 0 ORDER BY id ASC LIMIT 1\",\n                \"UPDATE testTable SET id = ?1 ORDER BY content ASC LIMIT 1\"\n        }, new TestOperation() {\n            @Override\n            public void execute() throws WCDBException {\n                database.updateValue(\"newContent\", content, tableName, id.gt(0), id.order(Order.Asc), 1);\n                database.updateValue(nextId, id, tableName, content.order(Order.Asc), 1);\n            }\n        });\n        assertEquals(database.getValue(content.count(), tableName, id.eq(nextId)).getLong(), 1);\n        assertEquals(database.getValue(id.count(), tableName, content.eq(\"newContent\")).getLong(), 1);\n    }\n\n    @Test\n    public void testDatabaseUpdateValueWhereOrderLimitOffset() throws WCDBException {\n        doTestSQLs(new String[]{\n                \"UPDATE testTable SET content = ?1 WHERE id > 0 ORDER BY id ASC LIMIT 1 OFFSET 1\",\n                \"UPDATE testTable SET id = ?1 ORDER BY content ASC LIMIT 1 OFFSET 1\"\n        }, new TestOperation() {\n            @Override\n            public void execute() throws WCDBException {\n                database.updateValue(\"newContent\", content, tableName, id.gt(0), id.order(Order.Asc), 1, 1);\n                database.updateValue(nextId, id, tableName, content.order(Order.Asc), 1, 1);\n            }\n        });\n        assertEquals(database.getValue(content.count(), tableName, id.eq(nextId)).getLong(), 1);\n        assertEquals(database.getValue(id.count(), tableName, content.eq(\"newContent\")).getLong(), 1);\n    }\n\n    @Test\n    public void testDatabaseUpdateRowWhere() throws WCDBException {\n        doTestSQL(\"UPDATE testTable SET id = ?1, content = ?2 WHERE id != 1\", new TestOperation() {\n            @Override\n            public void execute() throws WCDBException {\n                database.updateRow(new Value[]{new Value(nextId), new Value(\"newContent\")}, columns(), tableName, id.notEq(1));\n            }\n        });\n        assertEquals(database.getValue(content, tableName, id.eq(nextId)).getText(), \"newContent\");\n    }\n\n    @Test\n    public void testDatabaseUpdateRowWhereOrderLimit() throws WCDBException {\n        doTestSQLs(new String[]{\n                \"UPDATE testTable SET id = ?1, content = ?2 WHERE id < 3 ORDER BY id DESC LIMIT 1\",\n                \"UPDATE testTable SET id = ?1, content = ?2 ORDER BY content DESC LIMIT 1\",\n        }, new TestOperation() {\n            @Override\n            public void execute() throws WCDBException {\n                database.updateRow(new Value[]{new Value(nextId), new Value(\"newContent\")}, columns(), tableName, id.lt(nextId), id.order(Order.Desc), 1);\n                database.updateRow(new Value[]{new Value(nextId + 1), new Value(\"newContent2\")}, columns(), tableName, content.order(Order.Desc), 1);\n            }\n        });\n        assertTrue(database.getValue(content.count(), tableName, id.eq(nextId)).getLong() +\n                database.getValue(content.count(), tableName, id.eq(nextId + 1)).getLong() >= 1);\n        assertTrue(database.getValue(id.count(), tableName, content.eq(\"newContent\")).getLong() +\n                database.getValue(id.count(), tableName, content.eq(\"newContent2\")).getLong() >= 1);\n    }\n\n    @Test\n    public void testDatabaseUpdateRowWhereOrderLimitOffset() throws WCDBException {\n        doTestSQLs(new String[]{\n                \"UPDATE testTable SET id = ?1, content = ?2 WHERE id < 3 ORDER BY id DESC LIMIT 1 OFFSET 1\",\n                \"UPDATE testTable SET id = ?1, content = ?2 ORDER BY content DESC LIMIT 1 OFFSET 1\",\n        }, new TestOperation() {\n            @Override\n            public void execute() throws WCDBException {\n                database.updateRow(new Value[]{new Value(nextId), new Value(\"newContent\")}, columns(), tableName, id.lt(nextId), id.order(Order.Desc), 1, 1);\n                database.updateRow(new Value[]{new Value(nextId + 1), new Value(\"newContent2\")}, columns(), tableName, content.order(Order.Desc), 1, 1);\n            }\n        });\n        assertTrue(database.getValue(content.count(), tableName, id.eq(nextId)).getLong() +\n                database.getValue(content.count(), tableName, id.eq(nextId + 1)).getLong() >= 1);\n        assertTrue(database.getValue(id.count(), tableName, content.eq(\"newContent\")).getLong() +\n                database.getValue(id.count(), tableName, content.eq(\"newContent2\")).getLong() >= 1);\n    }\n\n    @Test\n    public void testHandleUpdateValue() throws WCDBException {\n        doTestSQL(\"UPDATE testTable SET content = ?1\", new TestOperation() {\n            @Override\n            public void execute() throws WCDBException {\n                handle.updateValue(\"newContent\", content, tableName);\n            }\n        });\n        assertEquals(handle.getValue(content, tableName).getText(), \"newContent\");\n    }\n\n    @Test\n    public void testHandleUpdateValueWhere() throws WCDBException {\n        doTestSQLs(new String[]{\n                \"UPDATE testTable SET content = ?1 WHERE id == 1\",\n                \"UPDATE testTable SET id = ?1 WHERE content == 'newContent'\"\n        }, new TestOperation() {\n            @Override\n            public void execute() throws WCDBException {\n                handle.updateValue(\"newContent\", content, tableName, id.eq(1));\n                handle.updateValue(nextId, id, tableName, content.eq(\"newContent\"));\n            }\n        });\n        assertEquals(handle.getValue(content, tableName, id.eq(nextId)).getText(), \"newContent\");\n        assertEquals(handle.getValue(id, tableName, content.eq(\"newContent\")).getLong(), nextId);\n    }\n\n    @Test\n    public void testHandleUpdateValueWhereOrderLimit() throws WCDBException {\n        doTestSQLs(new String[]{\n                \"UPDATE testTable SET content = ?1 WHERE id > 0 ORDER BY id ASC LIMIT 1\",\n                \"UPDATE testTable SET id = ?1 ORDER BY content ASC LIMIT 1\"\n        }, new TestOperation() {\n            @Override\n            public void execute() throws WCDBException {\n                handle.updateValue(\"newContent\", content, tableName, id.gt(0), id.order(Order.Asc), 1);\n                handle.updateValue(nextId, id, tableName, content.order(Order.Asc), 1);\n            }\n        });\n        assertEquals(handle.getValue(content.count(), tableName, id.eq(nextId)).getLong(), 1);\n        assertEquals(handle.getValue(id.count(), tableName, content.eq(\"newContent\")).getLong(), 1);\n    }\n\n    @Test\n    public void testHandleUpdateValueWhereOrderLimitOffset() throws WCDBException {\n        doTestSQLs(new String[]{\n                \"UPDATE testTable SET content = ?1 WHERE id > 0 ORDER BY id ASC LIMIT 1 OFFSET 1\",\n                \"UPDATE testTable SET id = ?1 ORDER BY content ASC LIMIT 1 OFFSET 1\"\n        }, new TestOperation() {\n            @Override\n            public void execute() throws WCDBException {\n                handle.updateValue(\"newContent\", content, tableName, id.gt(0), id.order(Order.Asc), 1, 1);\n                handle.updateValue(nextId, id, tableName, content.order(Order.Asc), 1, 1);\n            }\n        });\n        assertEquals(handle.getValue(content.count(), tableName, id.eq(nextId)).getLong(), 1);\n        assertEquals(handle.getValue(id.count(), tableName, content.eq(\"newContent\")).getLong(), 1);\n    }\n\n    @Test\n    public void testHandleUpdateRowWhere() throws WCDBException {\n        doTestSQL(\"UPDATE testTable SET id = ?1, content = ?2 WHERE id != 1\", new TestOperation() {\n            @Override\n            public void execute() throws WCDBException {\n                handle.updateRow(new Value[]{new Value(nextId), new Value(\"newContent\")}, columns(), tableName, id.notEq(1));\n            }\n        });\n        assertEquals(handle.getValue(content, tableName, id.eq(nextId)).getText(), \"newContent\");\n    }\n\n    @Test\n    public void testHandleUpdateRowWhereOrderLimit() throws WCDBException {\n        doTestSQLs(new String[]{\n                \"UPDATE testTable SET id = ?1, content = ?2 WHERE id < 3 ORDER BY id DESC LIMIT 1\",\n                \"UPDATE testTable SET id = ?1, content = ?2 ORDER BY content DESC LIMIT 1\",\n        }, new TestOperation() {\n            @Override\n            public void execute() throws WCDBException {\n                handle.updateRow(new Value[]{new Value(nextId), new Value(\"newContent\")}, columns(), tableName, id.lt(nextId), id.order(Order.Desc), 1);\n                handle.updateRow(new Value[]{new Value(nextId + 1), new Value(\"newContent2\")}, columns(), tableName, content.order(Order.Desc), 1);\n            }\n        });\n        assertTrue(handle.getValue(content.count(), tableName, id.eq(nextId)).getLong() +\n                handle.getValue(content.count(), tableName, id.eq(nextId + 1)).getLong() >= 1);\n        assertTrue(handle.getValue(id.count(), tableName, content.eq(\"newContent\")).getLong() +\n                handle.getValue(id.count(), tableName, content.eq(\"newContent2\")).getLong() >= 1);\n    }\n\n    @Test\n    public void testHandleUpdateRowWhereOrderLimitOffset() throws WCDBException {\n        doTestSQLs(new String[]{\n                \"UPDATE testTable SET id = ?1, content = ?2 WHERE id < 3 ORDER BY id DESC LIMIT 1 OFFSET 1\",\n                \"UPDATE testTable SET id = ?1, content = ?2 ORDER BY content DESC LIMIT 1 OFFSET 1\",\n        }, new TestOperation() {\n            @Override\n            public void execute() throws WCDBException {\n                handle.updateRow(new Value[]{new Value(nextId), new Value(\"newContent\")}, columns(), tableName, id.lt(nextId), id.order(Order.Desc), 1, 1);\n                handle.updateRow(new Value[]{new Value(nextId + 1), new Value(\"newContent2\")}, columns(), tableName, content.order(Order.Desc), 1, 1);\n            }\n        });\n        assertTrue(handle.getValue(content.count(), tableName, id.eq(nextId)).getLong() +\n                handle.getValue(content.count(), tableName, id.eq(nextId + 1)).getLong() >= 1);\n        assertTrue(handle.getValue(id.count(), tableName, content.eq(\"newContent\")).getLong() +\n                handle.getValue(id.count(), tableName, content.eq(\"newContent2\")).getLong() >= 1);\n    }\n}\n"
  },
  {
    "path": "src/java/test/src/androidTest/java/com/tencent/wcdbtest/crud/ValueUpdateWithFieldTest.java",
    "content": "// Created by chenqiuwen on 2023/5/14.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdbtest.crud;\n\nimport static org.junit.Assert.assertEquals;\nimport static org.junit.Assert.assertTrue;\n\nimport com.tencent.wcdb.base.Value;\nimport com.tencent.wcdb.base.WCDBException;\nimport com.tencent.wcdb.winq.Order;\nimport com.tencent.wcdbtest.base.DBTestObject;\nimport com.tencent.wcdbtest.base.ObjectCRUDTestCase;\n\nimport org.junit.Test;\n\npublic class ValueUpdateWithFieldTest extends ObjectCRUDTestCase {\n\n\n    @Test\n    public void testDatabaseUpdateValue() throws WCDBException {\n        doTestSQL(\"UPDATE testTable SET content = ?1\", new TestOperation() {\n            @Override\n            public void execute() throws WCDBException {\n                database.updateValue(\"newContent\", DBTestObject.content, tableName);\n            }\n        });\n        assertEquals(database.getValue(DBTestObject.content, tableName).getText(), \"newContent\");\n    }\n\n    @Test\n    public void testDatabaseUpdateValueWhere() throws WCDBException {\n        doTestSQLs(new String[]{\n                \"UPDATE testTable SET content = ?1 WHERE id == 1\",\n                \"UPDATE testTable SET id = ?1 WHERE content == 'newContent'\"\n        }, new TestOperation() {\n            @Override\n            public void execute() throws WCDBException {\n                database.updateValue(\"newContent\", DBTestObject.content, tableName, DBTestObject.id.eq(1));\n                database.updateValue(nextId, DBTestObject.id, tableName, DBTestObject.content.eq(\"newContent\"));\n            }\n        });\n        assertEquals(database.getValue(DBTestObject.content, tableName, DBTestObject.id.eq(nextId)).getText(), \"newContent\");\n        assertEquals(database.getValue(DBTestObject.id, tableName, DBTestObject.content.eq(\"newContent\")).getLong(), nextId);\n    }\n\n    @Test\n    public void testDatabaseUpdateValueWhereOrderLimit() throws WCDBException {\n        doTestSQLs(new String[]{\n                \"UPDATE testTable SET content = ?1 WHERE id > 0 ORDER BY id ASC LIMIT 1\",\n                \"UPDATE testTable SET id = ?1 ORDER BY content ASC LIMIT 1\"\n        }, new TestOperation() {\n            @Override\n            public void execute() throws WCDBException {\n                database.updateValue(\"newContent\", DBTestObject.content, tableName, DBTestObject.id.gt(0), DBTestObject.id.order(Order.Asc), 1);\n                database.updateValue(nextId, DBTestObject.id, tableName, DBTestObject.content.order(Order.Asc), 1);\n            }\n        });\n        assertEquals(database.getValue(DBTestObject.content.count(), tableName, DBTestObject.id.eq(nextId)).getLong(), 1);\n        assertEquals(database.getValue(DBTestObject.id.count(), tableName, DBTestObject.content.eq(\"newContent\")).getLong(), 1);\n    }\n\n    @Test\n    public void testDatabaseUpdateValueWhereOrderLimitOffset() throws WCDBException {\n        doTestSQLs(new String[]{\n                \"UPDATE testTable SET content = ?1 WHERE id > 0 ORDER BY id ASC LIMIT 1 OFFSET 1\",\n                \"UPDATE testTable SET id = ?1 ORDER BY content ASC LIMIT 1 OFFSET 1\"\n        }, new TestOperation() {\n            @Override\n            public void execute() throws WCDBException {\n                database.updateValue(\"newContent\", DBTestObject.content, tableName, DBTestObject.id.gt(0), DBTestObject.id.order(Order.Asc), 1, 1);\n                database.updateValue(nextId, DBTestObject.id, tableName, DBTestObject.content.order(Order.Asc), 1, 1);\n            }\n        });\n        assertEquals(database.getValue(DBTestObject.content.count(), tableName, DBTestObject.id.eq(nextId)).getLong(), 1);\n        assertEquals(database.getValue(DBTestObject.id.count(), tableName, DBTestObject.content.eq(\"newContent\")).getLong(), 1);\n    }\n\n    @Test\n    public void testDatabaseUpdateRowWhere() throws WCDBException {\n        doTestSQL(\"UPDATE testTable SET id = ?1, content = ?2 WHERE id != 1\", new TestOperation() {\n            @Override\n            public void execute() throws WCDBException {\n                database.updateRow(new Value[]{new Value(nextId), new Value(\"newContent\")}, DBTestObject.allFields(), tableName, DBTestObject.id.notEq(1));\n            }\n        });\n        assertEquals(database.getValue(DBTestObject.content, tableName, DBTestObject.id.eq(nextId)).getText(), \"newContent\");\n    }\n\n    @Test\n    public void testDatabaseUpdateRowWhereOrderLimit() throws WCDBException {\n        doTestSQLs(new String[]{\n                \"UPDATE testTable SET id = ?1, content = ?2 WHERE id < 3 ORDER BY id DESC LIMIT 1\",\n                \"UPDATE testTable SET id = ?1, content = ?2 ORDER BY content DESC LIMIT 1\",\n        }, new TestOperation() {\n            @Override\n            public void execute() throws WCDBException {\n                database.updateRow(new Value[]{new Value(nextId), new Value(\"newContent\")}, DBTestObject.allFields(), tableName, DBTestObject.id.lt(nextId), DBTestObject.id.order(Order.Desc), 1);\n                database.updateRow(new Value[]{new Value(nextId + 1), new Value(\"newContent2\")}, DBTestObject.allFields(), tableName, DBTestObject.content.order(Order.Desc), 1);\n            }\n        });\n        assertTrue(database.getValue(DBTestObject.content.count(), tableName, DBTestObject.id.eq(nextId)).getLong() +\n                database.getValue(DBTestObject.content.count(), tableName, DBTestObject.id.eq(nextId + 1)).getLong() >= 1);\n        assertTrue(database.getValue(DBTestObject.id.count(), tableName, DBTestObject.content.eq(\"newContent\")).getLong() +\n                database.getValue(DBTestObject.id.count(), tableName, DBTestObject.content.eq(\"newContent2\")).getLong() >= 1);\n    }\n\n    @Test\n    public void testDatabaseUpdateRowWhereOrderLimitOffset() throws WCDBException {\n        doTestSQLs(new String[]{\n                \"UPDATE testTable SET id = ?1, content = ?2 WHERE id < 3 ORDER BY id DESC LIMIT 1 OFFSET 1\",\n                \"UPDATE testTable SET id = ?1, content = ?2 ORDER BY content DESC LIMIT 1 OFFSET 1\",\n        }, new TestOperation() {\n            @Override\n            public void execute() throws WCDBException {\n                database.updateRow(new Value[]{new Value(nextId), new Value(\"newContent\")}, DBTestObject.allFields(), tableName, DBTestObject.id.lt(nextId), DBTestObject.id.order(Order.Desc), 1, 1);\n                database.updateRow(new Value[]{new Value(nextId + 1), new Value(\"newContent2\")}, DBTestObject.allFields(), tableName, DBTestObject.content.order(Order.Desc), 1, 1);\n            }\n        });\n        assertTrue(database.getValue(DBTestObject.content.count(), tableName, DBTestObject.id.eq(nextId)).getLong() +\n                database.getValue(DBTestObject.content.count(), tableName, DBTestObject.id.eq(nextId + 1)).getLong() >= 1);\n        assertTrue(database.getValue(DBTestObject.id.count(), tableName, DBTestObject.content.eq(\"newContent\")).getLong() +\n                database.getValue(DBTestObject.id.count(), tableName, DBTestObject.content.eq(\"newContent2\")).getLong() >= 1);\n    }\n\n    @Test\n    public void testTableUpdateValue() throws WCDBException {\n        doTestSQL(\"UPDATE testTable SET content = ?1\", new TestOperation() {\n            @Override\n            public void execute() throws WCDBException {\n                table.updateValue(\"newContent\", DBTestObject.content);\n            }\n        });\n        assertEquals(table.getValue(DBTestObject.content).getText(), \"newContent\");\n    }\n\n    @Test\n    public void testTableUpdateValueWhere() throws WCDBException {\n        doTestSQLs(new String[]{\n                \"UPDATE testTable SET content = ?1 WHERE id == 1\",\n                \"UPDATE testTable SET id = ?1 WHERE content == 'newContent'\"\n        }, new TestOperation() {\n            @Override\n            public void execute() throws WCDBException {\n                table.updateValue(\"newContent\", DBTestObject.content, DBTestObject.id.eq(1));\n                table.updateValue(nextId, DBTestObject.id, DBTestObject.content.eq(\"newContent\"));\n            }\n        });\n        assertEquals(table.getValue(DBTestObject.content, DBTestObject.id.eq(nextId)).getText(), \"newContent\");\n        assertEquals(table.getValue(DBTestObject.id, DBTestObject.content.eq(\"newContent\")).getLong(), nextId);\n    }\n\n    @Test\n    public void testTableUpdateValueWhereOrderLimit() throws WCDBException {\n        doTestSQLs(new String[]{\n                \"UPDATE testTable SET content = ?1 WHERE id > 0 ORDER BY id ASC LIMIT 1\",\n                \"UPDATE testTable SET id = ?1 ORDER BY content ASC LIMIT 1\"\n        }, new TestOperation() {\n            @Override\n            public void execute() throws WCDBException {\n                table.updateValue(\"newContent\", DBTestObject.content, DBTestObject.id.gt(0), DBTestObject.id.order(Order.Asc), 1);\n                table.updateValue(nextId, DBTestObject.id, DBTestObject.content.order(Order.Asc), 1);\n            }\n        });\n        assertEquals(table.getValue(DBTestObject.content.count(), DBTestObject.id.eq(nextId)).getLong(), 1);\n        assertEquals(table.getValue(DBTestObject.id.count(), DBTestObject.content.eq(\"newContent\")).getLong(), 1);\n    }\n\n    @Test\n    public void testTableUpdateValueWhereOrderLimitOffset() throws WCDBException {\n        doTestSQLs(new String[]{\n                \"UPDATE testTable SET content = ?1 WHERE id > 0 ORDER BY id ASC LIMIT 1 OFFSET 1\",\n                \"UPDATE testTable SET id = ?1 ORDER BY content ASC LIMIT 1 OFFSET 1\"\n        }, new TestOperation() {\n            @Override\n            public void execute() throws WCDBException {\n                table.updateValue(\"newContent\", DBTestObject.content, DBTestObject.id.gt(0), DBTestObject.id.order(Order.Asc), 1, 1);\n                table.updateValue(nextId, DBTestObject.id, DBTestObject.content.order(Order.Asc), 1, 1);\n            }\n        });\n        assertEquals(table.getValue(DBTestObject.content.count(), DBTestObject.id.eq(nextId)).getLong(), 1);\n        assertEquals(table.getValue(DBTestObject.id.count(), DBTestObject.content.eq(\"newContent\")).getLong(), 1);\n    }\n\n    @Test\n    public void testTableUpdateRowWhere() throws WCDBException {\n        doTestSQL(\"UPDATE testTable SET id = ?1, content = ?2 WHERE id != 1\", new TestOperation() {\n            @Override\n            public void execute() throws WCDBException {\n                table.updateRow(new Value[]{new Value(nextId), new Value(\"newContent\")}, DBTestObject.allFields(), DBTestObject.id.notEq(1));\n            }\n        });\n        assertEquals(table.getValue(DBTestObject.content, DBTestObject.id.eq(nextId)).getText(), \"newContent\");\n    }\n\n    @Test\n    public void testTableUpdateRowWhereOrderLimit() throws WCDBException {\n        doTestSQLs(new String[]{\n                \"UPDATE testTable SET id = ?1, content = ?2 WHERE id < 3 ORDER BY id DESC LIMIT 1\",\n                \"UPDATE testTable SET id = ?1, content = ?2 ORDER BY content DESC LIMIT 1\",\n        }, new TestOperation() {\n            @Override\n            public void execute() throws WCDBException {\n                table.updateRow(new Value[]{new Value(nextId), new Value(\"newContent\")}, DBTestObject.allFields(), DBTestObject.id.lt(nextId), DBTestObject.id.order(Order.Desc), 1);\n                table.updateRow(new Value[]{new Value(nextId + 1), new Value(\"newContent2\")}, DBTestObject.allFields(), DBTestObject.content.order(Order.Desc), 1);\n            }\n        });\n        assertTrue(table.getValue(DBTestObject.content.count(), DBTestObject.id.eq(nextId)).getLong() +\n                table.getValue(DBTestObject.content.count(), DBTestObject.id.eq(nextId + 1)).getLong() >= 1);\n        assertTrue(table.getValue(DBTestObject.id.count(), DBTestObject.content.eq(\"newContent\")).getLong() +\n                table.getValue(DBTestObject.id.count(), DBTestObject.content.eq(\"newContent2\")).getLong() >= 1);\n    }\n\n    @Test\n    public void testTableUpdateRowWhereOrderLimitOffset() throws WCDBException {\n        doTestSQLs(new String[]{\n                \"UPDATE testTable SET id = ?1, content = ?2 WHERE id < 3 ORDER BY id DESC LIMIT 1 OFFSET 1\",\n                \"UPDATE testTable SET id = ?1, content = ?2 ORDER BY content DESC LIMIT 1 OFFSET 1\",\n        }, new TestOperation() {\n            @Override\n            public void execute() throws WCDBException {\n                table.updateRow(new Value[]{new Value(nextId), new Value(\"newContent\")}, DBTestObject.allFields(), DBTestObject.id.lt(nextId), DBTestObject.id.order(Order.Desc), 1, 1);\n                table.updateRow(new Value[]{new Value(nextId + 1), new Value(\"newContent2\")}, DBTestObject.allFields(), DBTestObject.content.order(Order.Desc), 1, 1);\n            }\n        });\n        assertTrue(table.getValue(DBTestObject.content.count(), DBTestObject.id.eq(nextId)).getLong() +\n                table.getValue(DBTestObject.content.count(), DBTestObject.id.eq(nextId + 1)).getLong() >= 1);\n        assertTrue(table.getValue(DBTestObject.id.count(), DBTestObject.content.eq(\"newContent\")).getLong() +\n                table.getValue(DBTestObject.id.count(), DBTestObject.content.eq(\"newContent2\")).getLong() >= 1);\n    }\n\n    @Test\n    public void testHandleUpdateValue() throws WCDBException {\n        doTestSQL(\"UPDATE testTable SET content = ?1\", new TestOperation() {\n            @Override\n            public void execute() throws WCDBException {\n                handle.updateValue(\"newContent\", DBTestObject.content, tableName);\n            }\n        });\n        assertEquals(handle.getValue(DBTestObject.content, tableName).getText(), \"newContent\");\n    }\n\n    @Test\n    public void testHandleUpdateValueWhere() throws WCDBException {\n        doTestSQLs(new String[]{\n                \"UPDATE testTable SET content = ?1 WHERE id == 1\",\n                \"UPDATE testTable SET id = ?1 WHERE content == 'newContent'\"\n        }, new TestOperation() {\n            @Override\n            public void execute() throws WCDBException {\n                handle.updateValue(\"newContent\", DBTestObject.content, tableName, DBTestObject.id.eq(1));\n                handle.updateValue(nextId, DBTestObject.id, tableName, DBTestObject.content.eq(\"newContent\"));\n            }\n        });\n        assertEquals(handle.getValue(DBTestObject.content, tableName, DBTestObject.id.eq(nextId)).getText(), \"newContent\");\n        assertEquals(handle.getValue(DBTestObject.id, tableName, DBTestObject.content.eq(\"newContent\")).getLong(), nextId);\n    }\n\n    @Test\n    public void testHandleUpdateValueWhereOrderLimit() throws WCDBException {\n        doTestSQLs(new String[]{\n                \"UPDATE testTable SET content = ?1 WHERE id > 0 ORDER BY id ASC LIMIT 1\",\n                \"UPDATE testTable SET id = ?1 ORDER BY content ASC LIMIT 1\"\n        }, new TestOperation() {\n            @Override\n            public void execute() throws WCDBException {\n                handle.updateValue(\"newContent\", DBTestObject.content, tableName, DBTestObject.id.gt(0), DBTestObject.id.order(Order.Asc), 1);\n                handle.updateValue(nextId, DBTestObject.id, tableName, DBTestObject.content.order(Order.Asc), 1);\n            }\n        });\n        assertEquals(handle.getValue(DBTestObject.content.count(), tableName, DBTestObject.id.eq(nextId)).getLong(), 1);\n        assertEquals(handle.getValue(DBTestObject.id.count(), tableName, DBTestObject.content.eq(\"newContent\")).getLong(), 1);\n    }\n\n    @Test\n    public void testHandleUpdateValueWhereOrderLimitOffset() throws WCDBException {\n        doTestSQLs(new String[]{\n                \"UPDATE testTable SET content = ?1 WHERE id > 0 ORDER BY id ASC LIMIT 1 OFFSET 1\",\n                \"UPDATE testTable SET id = ?1 ORDER BY content ASC LIMIT 1 OFFSET 1\"\n        }, new TestOperation() {\n            @Override\n            public void execute() throws WCDBException {\n                handle.updateValue(\"newContent\", DBTestObject.content, tableName, DBTestObject.id.gt(0), DBTestObject.id.order(Order.Asc), 1, 1);\n                handle.updateValue(nextId, DBTestObject.id, tableName, DBTestObject.content.order(Order.Asc), 1, 1);\n            }\n        });\n        assertEquals(handle.getValue(DBTestObject.content.count(), tableName, DBTestObject.id.eq(nextId)).getLong(), 1);\n        assertEquals(handle.getValue(DBTestObject.id.count(), tableName, DBTestObject.content.eq(\"newContent\")).getLong(), 1);\n    }\n\n    @Test\n    public void testHandleUpdateRowWhere() throws WCDBException {\n        doTestSQL(\"UPDATE testTable SET id = ?1, content = ?2 WHERE id != 1\", new TestOperation() {\n            @Override\n            public void execute() throws WCDBException {\n                handle.updateRow(new Value[]{new Value(nextId), new Value(\"newContent\")}, DBTestObject.allFields(), tableName, DBTestObject.id.notEq(1));\n            }\n        });\n        assertEquals(handle.getValue(DBTestObject.content, tableName, DBTestObject.id.eq(nextId)).getText(), \"newContent\");\n    }\n\n    @Test\n    public void testHandleUpdateRowWhereOrderLimit() throws WCDBException {\n        doTestSQLs(new String[]{\n                \"UPDATE testTable SET id = ?1, content = ?2 WHERE id < 3 ORDER BY id DESC LIMIT 1\",\n                \"UPDATE testTable SET id = ?1, content = ?2 ORDER BY content DESC LIMIT 1\",\n        }, new TestOperation() {\n            @Override\n            public void execute() throws WCDBException {\n                handle.updateRow(new Value[]{new Value(nextId), new Value(\"newContent\")}, DBTestObject.allFields(), tableName, DBTestObject.id.lt(nextId), DBTestObject.id.order(Order.Desc), 1);\n                handle.updateRow(new Value[]{new Value(nextId + 1), new Value(\"newContent2\")}, DBTestObject.allFields(), tableName, DBTestObject.content.order(Order.Desc), 1);\n            }\n        });\n        assertTrue(handle.getValue(DBTestObject.content.count(), tableName, DBTestObject.id.eq(nextId)).getLong() +\n                handle.getValue(DBTestObject.content.count(), tableName, DBTestObject.id.eq(nextId + 1)).getLong() >= 1);\n        assertTrue(handle.getValue(DBTestObject.id.count(), tableName, DBTestObject.content.eq(\"newContent\")).getLong() +\n                handle.getValue(DBTestObject.id.count(), tableName, DBTestObject.content.eq(\"newContent2\")).getLong() >= 1);\n    }\n\n    @Test\n    public void testHandleUpdateRowWhereOrderLimitOffset() throws WCDBException {\n        doTestSQLs(new String[]{\n                \"UPDATE testTable SET id = ?1, content = ?2 WHERE id < 3 ORDER BY id DESC LIMIT 1 OFFSET 1\",\n                \"UPDATE testTable SET id = ?1, content = ?2 ORDER BY content DESC LIMIT 1 OFFSET 1\",\n        }, new TestOperation() {\n            @Override\n            public void execute() throws WCDBException {\n                handle.updateRow(new Value[]{new Value(nextId), new Value(\"newContent\")}, DBTestObject.allFields(), tableName, DBTestObject.id.lt(nextId), DBTestObject.id.order(Order.Desc), 1, 1);\n                handle.updateRow(new Value[]{new Value(nextId + 1), new Value(\"newContent2\")}, DBTestObject.allFields(), tableName, DBTestObject.content.order(Order.Desc), 1, 1);\n            }\n        });\n        assertTrue(handle.getValue(DBTestObject.content.count(), tableName, DBTestObject.id.eq(nextId)).getLong() +\n                handle.getValue(DBTestObject.content.count(), tableName, DBTestObject.id.eq(nextId + 1)).getLong() >= 1);\n        assertTrue(handle.getValue(DBTestObject.id.count(), tableName, DBTestObject.content.eq(\"newContent\")).getLong() +\n                handle.getValue(DBTestObject.id.count(), tableName, DBTestObject.content.eq(\"newContent2\")).getLong() >= 1);\n    }\n}\n"
  },
  {
    "path": "src/java/test/src/androidTest/java/com/tencent/wcdbtest/database/CompressionTest.java",
    "content": "// Created by chenqiuwen on 2023/12/31.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdbtest.database;\n\nimport com.tencent.wcdb.base.Value;\nimport com.tencent.wcdb.base.WCDBException;\nimport com.tencent.wcdb.core.Database;\nimport com.tencent.wcdb.core.Handle;\nimport com.tencent.wcdb.core.PausableTransaction;\nimport com.tencent.wcdb.winq.Column;\nimport com.tencent.wcdb.winq.StatementSelect;\nimport com.tencent.wcdbtest.base.DBTestObject;\nimport com.tencent.wcdbtest.base.RandomTool;\nimport com.tencent.wcdbtest.base.TableTestCase;\nimport com.tencent.wcdbtest.base.TestObject;\nimport com.tencent.wcdbtest.base.WrappedValue;\n\nimport org.jetbrains.annotations.NotNull;\nimport org.junit.Assert;\nimport org.junit.Test;\n\nimport java.nio.charset.StandardCharsets;\nimport java.util.ArrayList;\nimport java.util.HashMap;\nimport java.util.List;\n\npublic class CompressionTest extends TableTestCase {\n    @Test\n    public void testZSTDNormalCompress() {\n        RandomTool.useEnglishWord = true;\n        createTable();\n        List<TestObject> preInsertObject = RandomTool.testCaseObjects(1, 2);\n        table.insertObjects(preInsertObject);\n\n        database.setCompression(new Database.CompressionFilter() {\n            @Override\n            public void filterCompress(@NotNull Database.CompressionInfo info) {\n                info.addZSTDNormalCompress(DBTestObject.content);\n            }\n        });\n\n        WrappedValue tableCompressed = new WrappedValue();\n        WrappedValue databaseCompressed = new WrappedValue();\n        database.setNotificationWhenCompressed(new Database.CompressionNotification() {\n            @Override\n            public void onCompressed(@NotNull Database notifiedDatabase, String table) {\n                Assert.assertEquals(database.getTag(), notifiedDatabase.getTag());\n                Assert.assertEquals(database.getPath(), notifiedDatabase.getPath());\n                if (table != null) {\n                    if (table.equals(tableName)) {\n                        tableCompressed.boolValue = true;\n                    }\n                } else {\n                    databaseCompressed.boolValue = true;\n                }\n            }\n        });\n\n        Assert.assertFalse(database.isCompressed());\n        database.stepCompression();\n        database.stepCompression();\n        Assert.assertTrue(database.isCompressed());\n        Assert.assertTrue(tableCompressed.boolValue && databaseCompressed.boolValue);\n\n        List<TestObject> newInsertObjects = RandomTool.testCaseObjects(3, 2);\n        table.insertObjects(newInsertObjects);\n\n        Value count = database.getValueFromStatement(new StatementSelect().select(Column.all().count()).from(tableName).where(new Column(\"WCDB_CT_content\").eq(4)));\n        Assert.assertEquals(count.getInt(), 4);\n\n        List<TestObject> allObjects = table.getAllObjects();\n        preInsertObject.addAll(newInsertObjects);\n        Assert.assertEquals(allObjects, preInsertObject);\n\n        RandomTool.useEnglishWord = false;\n    }\n\n    @Test\n    public void testZSTDDictCompress() {\n        RandomTool.useEnglishWord = true;\n        createTable();\n        List<TestObject> preInsertObject = RandomTool.testCaseObjects(1, 2);\n        table.insertObjects(preInsertObject);\n\n        ArrayList<byte[]> samples = new ArrayList<>();\n        for (int i = 0; i < 1000; i++) {\n            String sample = RandomTool.englishString();\n            samples.add(sample.getBytes(StandardCharsets.UTF_8));\n        }\n        byte[] dict = Database.trainDictWithData((List<byte[]>) samples, (byte) 1);\n        Database.registerDict(dict, (byte) 1);\n\n        database.setCompression(new Database.CompressionFilter() {\n            @Override\n            public void filterCompress(@NotNull Database.CompressionInfo info) {\n                info.addZSTDDictCompress(DBTestObject.content, (byte) 1);\n            }\n        });\n\n        Assert.assertFalse(database.isCompressed());\n        database.stepCompression();\n        database.stepCompression();\n        Assert.assertTrue(database.isCompressed());\n\n        List<TestObject> newInsertObjects = RandomTool.testCaseObjects(3, 2);\n        table.insertObjects(newInsertObjects);\n\n        Value count = database.getValueFromStatement(new StatementSelect().select(Column.all().count()).from(tableName).where(new Column(\"WCDB_CT_content\").eq(2)));\n        Assert.assertEquals(count.getInt(), 4);\n\n        List<TestObject> allObjects = table.getAllObjects();\n        preInsertObject.addAll(newInsertObjects);\n        Assert.assertEquals(allObjects, preInsertObject);\n\n        RandomTool.useEnglishWord = false;\n    }\n\n    @Test\n    public void testZSTDMultiDictCompress() {\n        RandomTool.useEnglishWord = true;\n        createTable();\n        List<TestObject> preInsertObject = RandomTool.testCaseObjects(1, 2);\n        table.insertObjects(preInsertObject);\n\n        ArrayList<String> samples = new ArrayList<>();\n        for (int i = 0; i < 1000; i++) {\n            String sample = RandomTool.englishString();\n            samples.add(sample);\n        }\n        byte[] dict1 = Database.trainDictWithString((List<String>) samples, (byte) 2);\n        Database.registerDict(dict1, (byte) 2);\n\n        samples.clear();\n        for (int i = 0; i < 1000; i++) {\n            String sample = RandomTool.englishString();\n            samples.add(sample);\n        }\n        byte[] dict2 = Database.trainDictWithString((List<String>) samples, (byte) 3);\n        Database.registerDict(dict2, (byte) 3);\n\n        samples.clear();\n        for (int i = 0; i < 1000; i++) {\n            String sample = RandomTool.englishString();\n            samples.add(sample);\n        }\n        byte[] dict3 = Database.trainDictWithString((List<String>) samples, (byte) 4);\n        Database.registerDict(dict3, (byte) 4);\n\n        database.setCompression(new Database.CompressionFilter() {\n            @Override\n            public void filterCompress(@NotNull Database.CompressionInfo info) {\n                info.addZSTDMultiDictCompress(DBTestObject.content, DBTestObject.id, new HashMap<Long, Byte>() {{\n                    put(1L, (byte) 2);\n                    put(2L, (byte) 3);\n                    put(Database.DictDefaultMatchValue, (byte) 3);\n                }});\n            }\n        });\n\n        Assert.assertFalse(database.isCompressed());\n        database.stepCompression();\n        database.stepCompression();\n        Assert.assertTrue(database.isCompressed());\n\n        List<TestObject> newInsertObjects = RandomTool.testCaseObjects(3, 2);\n        table.insertObjects(newInsertObjects);\n\n        Value count = database.getValueFromStatement(new StatementSelect().select(Column.all().count()).from(tableName).where(new Column(\"WCDB_CT_content\").eq(2)));\n        Assert.assertEquals(count.getInt(), 4);\n\n        List<TestObject> allObjects = table.getAllObjects();\n        preInsertObject.addAll(newInsertObjects);\n        Assert.assertEquals(allObjects, preInsertObject);\n\n        RandomTool.useEnglishWord = false;\n    }\n}\n"
  },
  {
    "path": "src/java/test/src/androidTest/java/com/tencent/wcdbtest/database/ConfigTest.java",
    "content": "// Created by qiuwenchen on 2023/5/10.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage com.tencent.wcdbtest.database;\n\nimport com.tencent.wcdb.base.Value;\nimport com.tencent.wcdb.base.WCDBException;\nimport com.tencent.wcdb.core.Database;\nimport com.tencent.wcdb.core.Handle;\nimport com.tencent.wcdb.core.Table;\nimport com.tencent.wcdb.winq.Column;\nimport com.tencent.wcdb.winq.Pragma;\nimport com.tencent.wcdb.winq.StatementPragma;\nimport com.tencent.wcdb.winq.StatementSelect;\nimport com.tencent.wcdbtest.base.DBTestObject;\nimport com.tencent.wcdbtest.base.FileTool;\nimport com.tencent.wcdbtest.base.RandomTool;\nimport com.tencent.wcdbtest.base.TableTestCase;\nimport com.tencent.wcdbtest.base.TestObject;\nimport com.tencent.wcdbtest.base.WrappedValue;\n\nimport org.jetbrains.annotations.NotNull;\nimport org.junit.After;\n\nimport static org.junit.Assert.*;\n\nimport org.junit.Test;\n\nimport java.util.concurrent.CountDownLatch;\nimport java.util.concurrent.ExecutorService;\nimport java.util.concurrent.Executors;\n\npublic class ConfigTest extends TableTestCase {\n    String configName = \"testConfig\";\n\n    @After\n    public void teardown() {\n        database.setConfig(configName, null);\n        super.teardown();\n    }\n\n    @Test\n    public void testConfig() throws WCDBException {\n        final StatementPragma setSecureDelete = new StatementPragma().pragma(Pragma.secureDelete).toValue(true);\n        final StatementPragma unsetSecureDelete = new StatementPragma().pragma(Pragma.secureDelete).toValue(false);\n        final StatementPragma getSecureDelete = new StatementPragma().pragma(Pragma.secureDelete);\n        final WrappedValue uninvoked = new WrappedValue();\n        database.setConfig(configName, new Database.Config() {\n            @Override\n            public void onInvocation(@NotNull Handle handle) throws WCDBException {\n                handle.execute(setSecureDelete);\n            }\n        }, new Database.Config() {\n            @Override\n            public void onInvocation(@NotNull Handle handle) throws WCDBException {\n                uninvoked.boolValue = true;\n                handle.execute(unsetSecureDelete);\n            }\n        }, Database.ConfigPriority.low);\n        expectMode = Expect.SomeSQLs;\n        doTestSQL(\"PRAGMA secure_delete = TRUE\", new TestOperation() {\n            @Override\n            public void execute() throws WCDBException {\n                database.close();\n                assertTrue(database.canOpen());\n            }\n        });\n        assertTrue(database.getValueFromStatement(getSecureDelete).getBool());\n        database.setConfig(configName, null);\n        assertTrue(database.canOpen());\n        assertTrue(uninvoked.boolValue);\n        assertFalse(database.getValueFromStatement(getSecureDelete).getBool());\n    }\n\n    @Test\n    public void testConfigFail() {\n        database.setConfig(configName, new Database.Config() {\n            @Override\n            public void onInvocation(@NotNull Handle handle) throws WCDBException {\n                handle.execute(new StatementSelect().select(\"testColumn\").from(\"testTable\"));\n            }\n        });\n        assertFalse(database.canOpen());\n    }\n\n    @Test\n    public void tesUnInvokeFail() {\n        database.setConfig(configName, new Database.Config() {\n            @Override\n            public void onInvocation(@NotNull Handle handle) throws WCDBException {\n            }\n        }, new Database.Config() {\n            @Override\n            public void onInvocation(@NotNull Handle handle) throws WCDBException {\n                handle.execute(new StatementSelect().select(\"testColumn\").from(\"testTable\"));\n            }\n        }, Database.ConfigPriority.low);\n        assertTrue(database.canOpen());\n        database.setConfig(configName, null);\n        assertFalse(database.canOpen());\n    }\n\n    @Test\n    public void testOrderConfig() {\n        String config1 = configName + \"_1\";\n        String config2 = configName + \"_2\";\n        String config3 = configName + \"_3\";\n        final WrappedValue step = new WrappedValue();\n        database.setConfig(config1, new Database.Config() {\n            @Override\n            public void onInvocation(@NotNull Handle handle) throws WCDBException {\n                assertEquals(step.intValue, 1);\n                step.intValue++;\n            }\n        });\n\n        database.setConfig(config2, new Database.Config() {\n            @Override\n            public void onInvocation(@NotNull Handle handle) throws WCDBException {\n                assertEquals(step.intValue, 2);\n                step.intValue++;\n            }\n        }, null, Database.ConfigPriority.low);\n\n        database.setConfig(config3, new Database.Config() {\n            @Override\n            public void onInvocation(@NotNull Handle handle) throws WCDBException {\n                assertEquals(step.intValue, 0);\n                step.intValue++;\n            }\n        }, null, Database.ConfigPriority.high);\n        assertTrue(database.canOpen());\n        assertEquals(step.intValue, 3);\n    }\n\n    @Test\n    public void testCipher() {\n        byte[] cipher = \"123\".getBytes();\n        byte[] wrongCipher = \"456\".getBytes();\n        database.setCipherKey(cipher);\n        assertTrue(database.canOpen());\n        database.close();\n        database.setCipherKey(wrongCipher);\n        assertFalse(database.canOpen());\n    }\n\n    @Test\n    public void testDatabasePageSize() {\n        byte[] cipher = \"123\".getBytes();\n        byte[] wrongCipher = \"456\".getBytes();\n        database.setCipherKey(cipher);\n        database.setConfig(\"page_size\", new Database.Config() {\n            @Override\n            public void onInvocation(@NotNull Handle handle) throws WCDBException {\n                handle.execute(new StatementPragma().pragma(Pragma.pageSize).toValue(16 * 1024));\n            };\n        }, Database.ConfigPriority.highest);\n        assertTrue(database.canOpen());\n        assertTrue(database.getValueFromStatement(new StatementPragma().pragma(Pragma.pageSize)).getInt() == 16 * 1024);\n    }\n\n    @Test\n    public void testCipherWithPageSize() {\n        byte[] cipher = \"123\".getBytes();\n        int pageSize = 8 * 1024;\n        int wrongPageSize = 16 * 1024;\n        database.setCipherKey(cipher, pageSize);\n        assertTrue(database.canOpen());\n        database.close();\n        database.setCipherKey(cipher, wrongPageSize);\n        assertFalse(database.canOpen());\n    }\n\n    @Test\n    public void testCipherWithDifferentVersion() throws WCDBException {\n        byte[] cipher = \"123\".getBytes();\n        int pageSize = 4096;\n        database.setCipherKey(cipher, pageSize, Database.CipherVersion.version3);\n        assertTrue(database.canOpen());\n\n        database.close();\n        database.setCipherKey(cipher, pageSize);\n        assertFalse(database.canOpen());\n\n        Database.setDefaultCipherVersion(Database.CipherVersion.version3);\n        assertTrue(database.canOpen());\n\n        database.removeFiles();\n        database.setCipherKey(cipher, pageSize, Database.CipherVersion.version4);\n        assertTrue(database.canOpen());\n        database.close();\n\n        database.setCipherKey(cipher, pageSize);\n        assertFalse(database.canOpen());\n        Database.setDefaultCipherVersion(Database.CipherVersion.version4);\n        assertTrue(database.canOpen());\n    }\n\n    @Test\n    public void testAutoVacuum() throws WCDBException {\n        database.enableAutoVacuum(false);\n        Value vacuumMode = database.getValueFromStatement(new StatementPragma().pragma(Pragma.autoVacuum));\n        assertTrue(vacuumMode != null && vacuumMode.getInt() == 1);\n\n        database.enableAutoVacuum(true);\n        vacuumMode = database.getValueFromStatement(new StatementPragma().pragma(Pragma.autoVacuum));\n        assertTrue(vacuumMode != null && vacuumMode.getInt() == 2);\n    }\n\n    @Test\n    public void testIncrementalVacuum() throws WCDBException {\n        database.enableAutoVacuum(true);\n        createTable();\n        table.insertObjects(RandomTool.autoIncrementTestCaseObjects(2));\n        database.truncateCheckpoint();\n\n        database.dropTable(tableName);\n        database.truncateCheckpoint();\n\n        Value freelist = database.getValueFromStatement(new StatementPragma().pragma(Pragma.freelistCount));\n        assertTrue(freelist != null && freelist.getInt() > 0);\n\n        database.incrementalVacuum(0);\n\n        freelist = database.getValueFromStatement(new StatementPragma().pragma(Pragma.freelistCount));\n        assertTrue(freelist != null && freelist.getInt() == 0);\n    }\n\n    @Test\n    public void testLiteMode() throws WCDBException {\n        database.enableLiteMode(true);\n        database.createTable(\"testTable\", DBTestObject.INSTANCE);\n        Table<TestObject> table = database.getTable(\"testTable\", DBTestObject.INSTANCE);\n        int numberOfTasks = 300;\n        ExecutorService executorService = Executors.newFixedThreadPool(numberOfTasks);\n        CountDownLatch latch = new CountDownLatch(numberOfTasks);\n\n        for (int i = 0; i < numberOfTasks; i++) {\n            executorService.submit(() -> {\n                try {\n                    table.insertObjects(RandomTool.autoIncrementTestCaseObjects(100));\n                } finally {\n                    latch.countDown();\n                }\n            });\n        }\n\n        try {\n            latch.await();\n        } catch (InterruptedException e) {\n            Thread.currentThread().interrupt();\n        } finally {\n            assertEquals(table.getValue(Column.all().count()).getInt(), 30000);\n            assertFalse(FileTool.fileExist(walPath()));\n            executorService.shutdown();\n        }\n    }\n}\n"
  },
  {
    "path": "src/java/test/src/androidTest/java/com/tencent/wcdbtest/database/DatabaseTest.java",
    "content": "// Created by qiuwenchen on 2023/5/11.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdbtest.database;\n\nimport androidx.test.ext.junit.runners.AndroidJUnit4;\n\nimport com.tencent.wcdb.base.WCDBException;\nimport com.tencent.wcdb.core.Database;\nimport com.tencent.wcdb.winq.Column;\nimport com.tencent.wcdb.winq.Pragma;\nimport com.tencent.wcdb.winq.StatementPragma;\nimport com.tencent.wcdbtest.base.DBTestObject;\nimport com.tencent.wcdbtest.base.FileTool;\nimport com.tencent.wcdbtest.base.RandomTool;\nimport com.tencent.wcdbtest.base.TableTestCase;\nimport com.tencent.wcdbtest.base.TestObject;\nimport com.tencent.wcdbtest.base.WrappedValue;\n\nimport static org.junit.Assert.*;\n\nimport org.junit.Test;\nimport org.junit.runner.RunWith;\n\nimport java.io.File;\nimport java.util.List;\nimport java.util.Objects;\n\n@RunWith(AndroidJUnit4.class)\npublic class DatabaseTest extends TableTestCase {\n    @Test\n    public void testTag() {\n        assertNotEquals(database.getTag(), 0);\n        Database newDatabase = new Database(database.getPath());\n        assertEquals(database.getTag(), newDatabase.getTag());\n    }\n\n    @Test\n    public void testPath() {\n        assertTrue(database.canOpen());\n        assertEquals(database.getPath(), FileTool.getRealPath(path));\n    }\n\n    @Test\n    public void testOpenAndClose() {\n        assertFalse(database.isOpened());\n        assertTrue(database.canOpen());\n        assertTrue(database.isOpened());\n        database.close();\n        assertFalse(database.isOpened());\n    }\n\n    @Test\n    public void testBlockade() throws InterruptedException {\n        database.blockade();\n        final WrappedValue time = new WrappedValue();\n        Thread thread = new Thread(new Runnable() {\n            @Override\n            public void run() {\n                assertTrue(database.canOpen());\n                time.intValue = System.currentTimeMillis();\n            }\n        });\n        thread.start();\n        sleep(1000);\n        long newTime = System.currentTimeMillis();\n        database.unblockade();\n        thread.join();\n        assertTrue(newTime < time.intValue);\n    }\n\n    @Test\n    public void testBlockadeAndClose() throws InterruptedException {\n        final WrappedValue main = WrappedValue.currentTime();\n        final WrappedValue subThread = WrappedValue.currentTime();\n        final Thread thread = new Thread(new Runnable() {\n            @Override\n            public void run() {\n                assertTrue(database.canOpen());\n                subThread.intValue = System.currentTimeMillis();\n            }\n        });\n        database.close(new Database.CloseCallBack() {\n            @Override\n            public void onClose() throws WCDBException {\n                thread.start();\n                sleep(1000);\n                main.intValue = System.currentTimeMillis();\n            }\n        });\n        thread.join();\n        assertTrue(main.intValue < subThread.intValue);\n    }\n\n    @Test\n    public void testReadOnly() throws WCDBException {\n        createTable();\n        table.insertObject(TestObject.createAutoIncrementObject(RandomTool.string()));\n\n        database.close(new Database.CloseCallBack() {\n            @Override\n            public void onClose() throws WCDBException {\n                for (String path : database.getPaths()) {\n                    File file = new File(path);\n                    if (file.exists()) {\n                        assertTrue(file.setReadOnly());\n                    }\n                }\n            }\n        });\n\n        assertTrue(database.canOpen());\n        List<TestObject> objects = table.getAllObjects();\n        assertEquals(objects.size(), 1);\n        boolean failed = false;\n        try {\n            table.insertObject(TestObject.createAutoIncrementObject(RandomTool.string()));\n        } catch (WCDBException e) {\n            failed = true;\n        }\n        assertTrue(failed);\n        for (String path : database.getPaths()) {\n            File file = new File(path);\n            if (file.exists()) {\n                assertTrue(file.setReadOnly());\n            }\n        }\n    }\n\n    @Test\n    public void testRunWhileClose() {\n        assertTrue(database.canOpen());\n        assertTrue(database.isOpened());\n        database.close(new Database.CloseCallBack() {\n            @Override\n            public void onClose() throws WCDBException {\n                database.execute(new StatementPragma().pragma(Pragma.userVersion).toValue(123));\n            }\n        });\n        assertFalse(database.isOpened());\n    }\n\n    @Test\n    public void testPurge() throws WCDBException {\n        database.execute(new StatementPragma().pragma(Pragma.userVersion).toValue(123));\n        assertTrue(database.isOpened());\n        database.purge();\n        assertFalse(database.isOpened());\n    }\n\n    @Test\n    public void testPurgeAll() throws WCDBException {\n        database.execute(new StatementPragma().pragma(Pragma.userVersion).toValue(123));\n        assertTrue(database.isOpened());\n        Database.purgeAll();\n        assertFalse(database.isOpened());\n    }\n\n    @Test\n    public void testCheckPoint() throws WCDBException {\n        createTable();\n        List<TestObject> objects = RandomTool.autoIncrementTestCaseObjects(100);\n        final WrappedValue walFrameNum = new WrappedValue();\n        for (int i = 0; i < 100; i++) {\n            assertEquals(table.getValue(Column.all().count()).getLong(), i);\n            table.insertObject(objects.get(i));\n            database.passiveCheckpoint();\n            database.close(new Database.CloseCallBack() {\n                @Override\n                public void onClose() throws WCDBException {\n                    if (walFrameNum.intValue != 0) {\n                        assertEquals(walFrameNum.intValue, getNumberOfWalFrames());\n                    } else {\n                        walFrameNum.intValue = getNumberOfWalFrames();\n                    }\n                    assertTrue(walFrameNum.intValue > 0);\n                    for (String path : database.getPaths()) {\n                        if (path.endsWith(\"wal\")) {\n                            assertTrue(FileTool.getFileSize(path) > 32);\n                        } else if (path.endsWith(\"shm\")) {\n                            assertTrue(FileTool.getFileSize(path) >= 32 * 1024);\n                        }\n                    }\n                }\n            });\n        }\n    }\n\n    @Test\n    public void testCheckPointWithLimit() throws WCDBException {\n        createTable();\n        List<TestObject> objects = RandomTool.autoIncrementTestCaseObjects(101);\n        Database.setAutoCheckpointMinFrames(100);\n        for (int i = 0; i < 100; i++) {\n            assertEquals(table.getValue(Column.all().count()).getLong(), i);\n            table.insertObject(objects.get(i));\n        }\n        int preFrame = getNumberOfWalFrames();\n        sleep(11000);\n        table.insertObject(objects.get(100));\n        assertEquals(preFrame, getNumberOfWalFrames());\n    }\n\n    @Test\n    public void testOpenFail() {\n        File folder = new File(currentDirectory);\n        assertTrue(folder.exists() || folder.mkdirs());\n        Database newDatabase = new Database(currentDirectory);\n        assertFalse(newDatabase.canOpen());\n    }\n\n    private int getNumberOfWalFrames() {\n        long size = FileTool.getFileSize(walPath());\n        if (size > walHeaderSize() && (size - walHeaderSize()) % walFrameSize() == 0) {\n            return (int) ((size - walHeaderSize()) / walFrameSize());\n        }\n        return 0;\n    }\n\n    @Test\n    public void testInMemoryDatabase() {\n        Database database = Database.createInMemoryDatabase();\n        String tableName = \"testTable\";\n        database.createTable(tableName, tableBinding);\n        List<TestObject> objects = RandomTool.autoIncrementTestCaseObjects(100);\n        database.insertObjects(objects, DBTestObject.allFields(), tableName);\n        assertEquals(100, Objects.requireNonNull(database.getValue(Column.all().count(), tableName)).getInt());\n\n        Database database2 = Database.createInMemoryDatabase();\n        assertFalse(database2.tableExist(tableName));\n    }\n}\n"
  },
  {
    "path": "src/java/test/src/androidTest/java/com/tencent/wcdbtest/database/FileTest.java",
    "content": "// Created by qiuwenchen on 2023/5/8.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdbtest.database;\n\nimport androidx.test.ext.junit.runners.AndroidJUnit4;\n\nimport com.tencent.wcdb.base.WCDBException;\nimport com.tencent.wcdb.core.Database;\nimport com.tencent.wcdbtest.base.DatabaseTestCase;\nimport com.tencent.wcdbtest.base.FileTool;\n\nimport static org.junit.Assert.*;\n\nimport org.junit.Before;\nimport org.junit.Test;\nimport org.junit.runner.RunWith;\n\nimport java.io.File;\nimport java.io.FileOutputStream;\nimport java.io.IOException;\n\n@RunWith(AndroidJUnit4.class)\npublic class FileTest extends DatabaseTestCase {\n    static String[] dummyPaths;\n\n    @Before\n    public void setup() throws WCDBException {\n        super.setup();\n        dummyPaths = allDummyPath(path);\n    }\n\n    String[] allDummyPath(String path) {\n        String[] paths = new String[7];\n        paths[0] = path;\n        paths[1] = path + \"-wal\";\n        paths[2] = path + \"-first.material\";\n        paths[3] = path + \"-last.material\";\n        paths[4] = path + \".factory\" + File.separator + new File(path).getName();\n        paths[5] = path + \"-journal\";\n        paths[6] = path + \"-shm\";\n        return paths;\n    }\n\n    void createDummyFiles() throws IOException {\n        for (String path : dummyPaths) {\n            FileTool.createFile(path);\n        }\n    }\n\n    void allFileExists(boolean exist, String[] paths) {\n        for (String path : paths) {\n            assertEquals(FileTool.fileExist(path), exist);\n        }\n    }\n\n    @Test\n    public void testRemoveFiles() throws Exception {\n        createDummyFiles();\n        allFileExists(true, dummyPaths);\n        assertTrue(database.canOpen());\n        assertTrue(database.isOpened());\n        database.removeFiles();\n        assertFalse(database.isOpened());\n        allFileExists(false, dummyPaths);\n    }\n\n    @Test\n    public void testMoveFiles() throws Exception {\n        String moveDirectory = currentDirectory + File.separator + \"move\";\n        String moveDatabase = moveDirectory + File.separator + fileName;\n        String[] movedPaths = allDummyPath(moveDatabase);\n        allFileExists(false, movedPaths);\n        assertTrue(database.canOpen());\n        assertTrue(database.isOpened());\n        createDummyFiles();\n        allFileExists(true, dummyPaths);\n        database.moveFile(moveDirectory);\n        assertFalse(database.isOpened());\n        allFileExists(false, dummyPaths);\n        allFileExists(true, movedPaths);\n    }\n\n    @Test\n    public void testGetFileSize() throws IOException, WCDBException {\n        byte[] data = new byte[10];\n        createDummyFiles();\n        for (String path : dummyPaths) {\n            FileOutputStream fileStream = new FileOutputStream(path);\n            fileStream.write(data);\n        }\n        assertEquals(database.getFileSize(), dummyPaths.length * data.length);\n    }\n\n    @Test\n    public void testAutoCreateImmediateDirectory() {\n        String newPath = currentDirectory + File.separator + \"immediate\" + File.separator + \"directory\" +\n                File.separator + \"will\" + File.separator + \"be\" + File.separator + \"created\" +\n                File.separator + \"automatically\" + File.separator + fileName;\n        Database newDatabase = new Database(newPath);\n        assertTrue(newDatabase.canOpen());\n        assertTrue(FileTool.fileExist(newPath));\n    }\n\n    @Test\n    public void testPathNormalization() {\n        String newPath = currentDirectory + \"//directory//database\";\n        Database newDatabase = new Database(newPath);\n        assertTrue(newDatabase.canOpen());\n        assertEquals(newDatabase.getPath(), FileTool.getRealPath(newPath));\n    }\n\n}\n"
  },
  {
    "path": "src/java/test/src/androidTest/java/com/tencent/wcdbtest/database/HandleTest.java",
    "content": "// Created by chenqiuwen on 2023/8/11.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdbtest.database;\n\nimport static org.junit.Assert.assertEquals;\nimport static org.junit.Assert.assertTrue;\n\nimport org.jetbrains.annotations.NotNull;\n\nimport com.tencent.wcdb.base.Value;\nimport com.tencent.wcdb.base.WCDBException;\nimport com.tencent.wcdb.core.Database;\nimport com.tencent.wcdb.core.Handle;\nimport com.tencent.wcdb.core.Transaction;\nimport com.tencent.wcdb.winq.Column;\nimport com.tencent.wcdb.winq.Order;\nimport com.tencent.wcdb.winq.StatementSelect;\nimport com.tencent.wcdbtest.base.DBTestObject;\nimport com.tencent.wcdbtest.base.RandomTool;\nimport com.tencent.wcdbtest.base.TableTestCase;\nimport com.tencent.wcdbtest.base.TestObject;\nimport com.tencent.wcdbtest.base.WrappedValue;\n\nimport org.junit.Test;\n\nimport java.util.HashMap;\nimport java.util.List;\n\npublic class HandleTest extends TableTestCase {\n    @Test\n    public void testCancellationSignal() throws WCDBException, InterruptedException {\n        createTable();\n        List<TestObject> objects = RandomTool.autoIncrementTestCaseObjects(10000);\n        database.insertObjects(objects, DBTestObject.allFields(), tableName);\n\n        WrappedValue hasTestInterrupt = new WrappedValue();\n        Handle.CancellationSignal signal = new Handle.CancellationSignal();\n        Thread thread = new Thread(new Runnable() {\n            @Override\n            public void run() {\n                Handle handle = database.getHandle();\n                try {\n                    handle.attachCancellationSignal(signal);\n                    List<TestObject> objects = handle.getAllObjects(DBTestObject.allFields(), tableName);\n                } catch (WCDBException e) {\n                    if (e.level == WCDBException.Level.Error && e.code == WCDBException.Code.Interrupt) {\n                        hasTestInterrupt.boolValue = true;\n                    }\n                } finally {\n                    handle.invalidate();\n                }\n            }\n        });\n        thread.start();\n        sleep(10);\n        signal.cancel();\n        thread.join();\n        assertTrue(hasTestInterrupt.boolValue);\n    }\n\n    @Test\n    public void testWriteWithHandleCountLimit() throws WCDBException, InterruptedException {\n        final WrappedValue maxHandleCount = new WrappedValue();\n        Database.globalTraceDatabaseOperation(new Database.OperationTracer() {\n            @Override\n            public void onTrace(@NotNull Database database, Database.Operation operation, @NotNull HashMap<String, Value> info) {\n                if (operation != Database.Operation.OpenHandle) {\n                    return;\n                }\n                Value value = info.get(Database.OperationInfoKeyHandleCount);\n                assert value != null;\n                if (value.getLong() > maxHandleCount.intValue) {\n                    maxHandleCount.intValue = value.getLong();\n                }\n            }\n        });\n        createTable();\n        Thread[] threads = new Thread[80];\n        for (int i = 0; i < 80; i++) {\n            final int finalI = i;\n            Thread thread = new Thread(new Runnable() {\n                @Override\n                public void run() {\n                    try {\n                        switch (finalI % 8) {\n                            case 0: {\n                                List<TestObject> objects = RandomTool.autoIncrementTestCaseObjects(100);\n                                table.insertObjects(objects);\n                            }\n                            break;\n                            case 1: {\n                                table.updateValue(\"abc\", DBTestObject.content, DBTestObject.id.gt((finalI - 1) * 100).and(DBTestObject.id\n                                        .lt(finalI * 100)));\n                            }\n                            break;\n                            case 2: {\n                                table.deleteObjects(DBTestObject.id.gt((finalI - 2) * 100 + 50).and(DBTestObject.id\n                                        .lt(finalI * 100)));\n                            }\n                            break;\n                            case 3: {\n                                database.runTransaction(new Transaction() {\n                                    @Override\n                                    public boolean insideTransaction(@NotNull Handle handle) throws WCDBException {\n                                        table.updateValue(\"abc2\", DBTestObject.content, DBTestObject.id.gt((finalI - 1) * 100).and(DBTestObject.id\n                                                .lt(finalI * 100)));\n                                        return true;\n                                    }\n                                });\n                            }\n                            break;\n                            case 4: {\n                                List<TestObject> objects = RandomTool.autoIncrementTestCaseObjects(100);\n                                database.insertObjects(objects, DBTestObject.allFields(), tableName);\n                            }\n                            break;\n                            case 5: {\n                                database.updateValue(\"abc\", DBTestObject.content, tableName, DBTestObject.id.gt((finalI - 1) * 100).and(DBTestObject.id\n                                        .lt(finalI * 100)));\n                            }\n                            break;\n                            case 6: {\n                                database.deleteObjects(tableName, DBTestObject.id.gt((finalI - 2) * 100 + 50).and(DBTestObject.id\n                                        .lt(finalI * 100)));\n                            }\n                            break;\n                            case 7: {\n                                database.runTransaction(new Transaction() {\n                                    @Override\n                                    public boolean insideTransaction(@NotNull Handle handle) throws WCDBException {\n                                        database.updateValue(\"abc2\", DBTestObject.content, tableName, DBTestObject.id.gt((finalI - 1) * 100).and(DBTestObject.id\n                                                .lt(finalI * 100)));\n                                        return true;\n                                    }\n                                });\n                            }\n                            break;\n                        }\n                        sleep(100);\n                    } catch (WCDBException e) {\n                        throw new RuntimeException(e);\n                    }\n                }\n            });\n            thread.start();\n            threads[i] = thread;\n        }\n        for (Thread thread : threads) {\n            thread.join();\n        }\n        assertTrue(maxHandleCount.intValue <= 4);\n        Database.globalTraceDatabaseOperation(null);\n    }\n\n    @Test\n    public void testReadWithHandleCountLimit() throws WCDBException, InterruptedException {\n        final WrappedValue maxHandleCount = new WrappedValue();\n        Database.globalTraceDatabaseOperation(new Database.OperationTracer() {\n            @Override\n            public void onTrace(@NotNull Database database, Database.Operation operation, @NotNull HashMap<String, Value> info) {\n                if (operation != Database.Operation.OpenHandle) {\n                    return;\n                }\n                Value value = info.get(Database.OperationInfoKeyHandleCount);\n                assert value != null;\n                if (value.getLong() > maxHandleCount.intValue) {\n                    maxHandleCount.intValue = value.getLong();\n                }\n            }\n        });\n        createTable();\n        List<TestObject> objects = RandomTool.autoIncrementTestCaseObjects(64000);\n        table.insertObjects(objects);\n        Thread[] threads = new Thread[640];\n        for (int i = 0; i < threads.length; i++) {\n            final int finalI = i;\n            Thread thread = new Thread(new Runnable() {\n                @Override\n                public void run() {\n                    try {\n                        switch (finalI % 10) {\n                            case 0: {\n                                List<TestObject> objects = table.getAllObjects(DBTestObject.id.order(Order.Desc), 100, finalI * 100);\n                                assertEquals(objects.size(), 100);\n                            }\n                            break;\n                            case 1: {\n                                Value count = database.getValueFromStatement(new StatementSelect().select(Column.all().count()).from(tableName));\n                                assertEquals(count.getLong(), 64000);\n                            }\n                            break;\n                            case 2: {\n                                List<Value> column = table.getOneColumn(DBTestObject.content, DBTestObject.id.order(Order.Desc), 100, finalI * 100);\n                                assertEquals(column.size(), 100);\n                            }\n                            break;\n                            case 3: {\n                                List<Value[]> rows = table.getAllRows(DBTestObject.allFields(), DBTestObject.id.order(Order.Desc), 100, finalI * 100);\n                                assertEquals(rows.size(), 100);\n                            }\n                            break;\n                            case 4: {\n                                Value[] row = table.getOneRow(DBTestObject.allFields());\n                                assertEquals(row.length, 2);\n                            }\n                            break;\n                            case 5: {\n                                List<TestObject> objects = database.getAllObjects(DBTestObject.allFields(), tableName, DBTestObject.id.order(Order.Desc), 100, finalI * 100);\n                                assertEquals(objects.size(), 100);\n                            }\n                            break;\n                            case 6: {\n                                List<Value> column = database.getOneColumn(DBTestObject.content, tableName, DBTestObject.id.order(Order.Desc), 100, finalI * 100);\n                                assertEquals(column.size(), 100);\n                            }\n                            break;\n                            case 7: {\n                                List<Value[]> rows = database.getAllRows(DBTestObject.allFields(), tableName, DBTestObject.id.order(Order.Desc), 100, finalI * 100);\n                                assertEquals(rows.size(), 100);\n                            }\n                            break;\n                            case 8: {\n                                Value[] row = database.getOneRow(DBTestObject.allFields(), tableName);\n                                assertEquals(row.length, 2);\n                            }\n                            break;\n                        }\n                        sleep(100);\n                    } catch (WCDBException e) {\n                        throw new RuntimeException(e);\n                    }\n                }\n            });\n            thread.start();\n            threads[i] = thread;\n        }\n        for (Thread thread : threads) {\n            thread.join();\n        }\n        assertTrue(maxHandleCount.intValue > 4 && maxHandleCount.intValue <= 32);\n        Database.globalTraceDatabaseOperation(null);\n    }\n\n    @Test\n    public void testReadWriteWithHandleCountLimit() throws WCDBException, InterruptedException {\n        final WrappedValue maxHandleCount = new WrappedValue();\n        Database.globalTraceDatabaseOperation(new Database.OperationTracer() {\n            @Override\n            public void onTrace(@NotNull Database database, Database.Operation operation, @NotNull HashMap<String, Value> info) {\n                if (operation != Database.Operation.OpenHandle) {\n                    return;\n                }\n                Value value = info.get(Database.OperationInfoKeyHandleCount);\n                assert value != null;\n                if (value.getLong() > maxHandleCount.intValue) {\n                    maxHandleCount.intValue = value.getLong();\n                }\n            }\n        });\n        createTable();\n        List<TestObject> objects = RandomTool.autoIncrementTestCaseObjects(32000);\n        table.insertObjects(objects);\n        Thread[] threads = new Thread[320];\n        for (int i = 0; i < threads.length; i++) {\n            int finalI = i;\n            Thread thread = new Thread(new Runnable() {\n                @Override\n                public void run() {\n                    try {\n                        if (finalI % 8 == 0) {\n                            List<TestObject> objects = RandomTool.autoIncrementTestCaseObjects(100);\n                            table.insertObjects(objects);\n                        } else {\n                            List<TestObject> objects = table.getAllObjects(DBTestObject.id.order(Order.Desc), 100, finalI * 100);\n                            assertEquals(objects.size(), 100);\n                        }\n                        sleep(100);\n                    } catch (WCDBException e) {\n                        throw new RuntimeException(e);\n                    }\n                }\n            });\n            thread.start();\n            threads[i] = thread;\n        }\n        for (Thread thread : threads) {\n            thread.join();\n        }\n        assertTrue(maxHandleCount.intValue > 4 && maxHandleCount.intValue <= 32);\n        Database.globalTraceDatabaseOperation(null);\n    }\n}\n"
  },
  {
    "path": "src/java/test/src/androidTest/java/com/tencent/wcdbtest/database/MigrationTest.java",
    "content": "// Created by chenqiuwen on 2023/5/11.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdbtest.database;\n\nimport com.tencent.wcdb.base.WCDBException;\nimport com.tencent.wcdb.core.Database;\nimport com.tencent.wcdb.core.Table;\nimport com.tencent.wcdb.winq.Column;\nimport com.tencent.wcdbtest.base.BaseTestCase;\nimport com.tencent.wcdbtest.base.DBTestObject;\nimport com.tencent.wcdbtest.base.RandomTool;\nimport com.tencent.wcdbtest.base.TestObject;\nimport com.tencent.wcdbtest.base.WrappedValue;\n\nimport static org.junit.Assert.*;\n\nimport org.jetbrains.annotations.NotNull;\nimport org.junit.Test;\n\nimport java.io.File;\nimport java.util.Arrays;\n\npublic class MigrationTest extends BaseTestCase {\n    @Test\n    public void testMigration() throws WCDBException {\n        TestObject oldObject1 = TestObject.createObject(1, \"a\");\n        TestObject oldObject2 = TestObject.createObject(2, \"b\");\n        TestObject oldObject3 = TestObject.createObject(3, \"c\");\n\n        byte[] sourceCipher = RandomTool.bytes();\n        byte[] targetCipher = RandomTool.bytes();\n\n        final Database sourceDatabase = new Database(currentDirectory + File.separator + \"sourceDatabase.sqlite3\");\n        sourceDatabase.setCipherKey(sourceCipher);\n\n        final String sourceTableName = \"sourceTable\";\n        sourceDatabase.createTable(sourceTableName, DBTestObject.INSTANCE);\n        Table<TestObject> sourceTable = sourceDatabase.getTable(sourceTableName, DBTestObject.INSTANCE);\n        sourceTable.insertObjects(Arrays.asList(oldObject1, oldObject2, oldObject3));\n\n        Database targetDatabase = new Database(currentDirectory + File.separator + \"targetDatabase.sqlite3\");\n        targetDatabase.setCipherKey(targetCipher);\n\n        final String targetTableName = \"targetTable\";\n        targetDatabase.addMigrationSource(sourceDatabase.getPath(), sourceCipher, new Database.MigrationFilter() {\n            @Override\n            public void filterMigrate(@NotNull Database.MigrationInfo info) {\n                if (info.table.equals(targetTableName)) {\n                    info.sourceTable = sourceTableName;\n                    info.filterCondition = DBTestObject.id.gt(2);\n                }\n            }\n        });\n\n        targetDatabase.createTable(targetTableName, DBTestObject.INSTANCE);\n        Table<TestObject> targetTable = targetDatabase.getTable(targetTableName, DBTestObject.INSTANCE);\n\n        assertEquals(targetTable.getValue(Column.all().count()).getLong(), 1);\n        assertEquals(sourceTable.getValue(Column.all().count()).getLong(), 3);\n\n        targetTable.updateValue(\"newContent\", DBTestObject.content, DBTestObject.id.eq(3));\n        assertEquals(targetTable.getValue(DBTestObject.content, DBTestObject.id.eq(3)).getText(), \"newContent\");\n\n        targetTable.deleteObjects(DBTestObject.id.eq(3));\n        assertEquals(targetTable.getValue(Column.all().count()).getLong(), 0);\n        assertEquals(sourceTable.getValue(Column.all().count()).getLong(), 2);\n\n        targetTable.insertObject(TestObject.createObject(4, \"d\"));\n        assertEquals(targetTable.getValue(DBTestObject.content, DBTestObject.id.eq(4)).getText(), \"d\");\n        assertEquals(targetTable.getValue(Column.all().count()).getLong(), 1);\n        assertEquals(sourceTable.getValue(Column.all().count()).getLong(), 2);\n\n        targetDatabase.close();\n        final WrappedValue migrateTable = new WrappedValue();\n        targetDatabase.setNotificationWhenMigrated(new Database.MigrationNotification() {\n            @Override\n            public void onMigrated(@NotNull Database database, Database.MigrationInfo info) {\n                if (info != null && info.table.equals(targetTableName)) {\n                    migrateTable.stringValue = info.sourceTable;\n                }\n            }\n        });\n\n        do {\n            targetDatabase.stepMigration();\n        } while (!targetDatabase.isMigrated());\n\n        assertEquals(migrateTable.stringValue, sourceTableName);\n    }\n}\n"
  },
  {
    "path": "src/java/test/src/androidTest/java/com/tencent/wcdbtest/database/RepairTest.java",
    "content": "// Created by qiuwenchen on 2023/5/11.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdbtest.database;\n\nimport com.tencent.wcdb.base.WCDBException;\nimport com.tencent.wcdb.core.Database;\nimport com.tencent.wcdb.winq.Column;\nimport com.tencent.wcdbtest.base.DBTestObject;\nimport com.tencent.wcdbtest.base.FileTool;\nimport com.tencent.wcdbtest.base.RandomTool;\nimport com.tencent.wcdbtest.base.TableTestCase;\nimport com.tencent.wcdbtest.base.TestObject;\nimport com.tencent.wcdbtest.base.WrappedValue;\n\nimport static org.junit.Assert.*;\n\nimport org.jetbrains.annotations.NotNull;\nimport org.junit.Test;\n\nimport java.util.List;\n\npublic class RepairTest extends TableTestCase {\n    List<TestObject> preInsertObjects = RandomTool.autoIncrementTestCaseObjects(2);\n\n    void executeTest(TestOperation operation) {\n        database.setCipherKey(null);\n        try {\n            createTable();\n            table.insertObjects(preInsertObjects);\n            operation.execute();\n            database.removeFiles();\n            database.setCipherKey(\"123\".getBytes());\n            createTable();\n            table.insertObjects(preInsertObjects);\n            operation.execute();\n        } catch (WCDBException e) {\n            throw new RuntimeException(e);\n        }\n    }\n\n    @Test\n    public void testBackup() {\n        executeTest(new TestOperation() {\n            @Override\n            public void execute() throws WCDBException {\n                assertFalse(FileTool.fileExist(firstMaterialPath()));\n                assertFalse(FileTool.fileExist(lastMaterialPath()));\n\n                database.backup();\n                assertTrue(FileTool.fileExist(firstMaterialPath()));\n                assertFalse(FileTool.fileExist(lastMaterialPath()));\n\n                sleep(1000);\n\n                database.backup();\n                assertTrue(FileTool.fileExist(firstMaterialPath()));\n                assertTrue(FileTool.fileExist(lastMaterialPath()));\n            }\n        });\n    }\n\n    @Test\n    public void testBackupWithFilter() throws WCDBException {\n        createTable();\n        table.insertObjects(preInsertObjects);\n        database.filterBackup(null);\n\n        database.backup();\n        assertTrue(FileTool.fileExist(firstMaterialPath()));\n        assertFalse(FileTool.fileExist(lastMaterialPath()));\n\n        database.filterBackup(new Database.BackupFilter() {\n            @Override\n            public boolean tableShouldBeBackup(@NotNull String tableName) {\n                return false;\n            }\n        });\n\n        sleep(1000);\n        database.backup();\n        assertTrue(FileTool.fileExist(firstMaterialPath()));\n        assertTrue(FileTool.fileExist(lastMaterialPath()));\n        assertTrue(FileTool.getFileSize(firstMaterialPath()) > FileTool.getFileSize(lastMaterialPath()));\n    }\n\n    //    @Test\n    public void testAutoBackup() {\n        executeTest(new TestOperation() {\n            @Override\n            public void execute() throws WCDBException {\n                database.enableAutoBackup(true);\n                TestObject newObject = TestObject.createObject(3, \"testContent\");\n                assertFalse(FileTool.fileExist(firstMaterialPath()));\n                table.insertObject(newObject);\n                database.passiveCheckpoint();\n                sleep(606000);\n                assertTrue(FileTool.fileExist(firstMaterialPath()));\n            }\n        });\n    }\n\n    @Test\n    public void testDeposit() {\n        executeTest(new TestOperation() {\n            @Override\n            public void execute() throws WCDBException {\n                // 0.\n                long num0 = table.getValue(Column.all().count()).getLong();\n                assertTrue(num0 > 0);\n                long rowId = num0;\n\n                // 1.\n                database.backup();\n                database.deposit();\n\n                long num1 = table.getValue(Column.all().count()).getLong();\n                assertEquals(num1, 0);\n\n                TestObject newObject = TestObject.createAutoIncrementObject(\"newObject\");\n                table.insertObject(newObject);\n                rowId += 1;\n                assertEquals(rowId, newObject.id);\n\n                // Make sure the new backup file is newer than the existing backup file\n                sleep(100);\n\n                // 2.\n                database.backup();\n                database.deposit();\n\n                long num2 = table.getValue(Column.all().count()).getLong();\n                assertEquals(num2, 0);\n\n                newObject.id = 0;\n                table.insertObject(newObject);\n                rowId += 1;\n                assertEquals(rowId, newObject.id);\n\n                assertTrue(FileTool.fileExist(factoryPath()));\n                assertTrue(database.containDepositedFiles());\n\n                database.removeDepositedFiles();\n                assertFalse(database.containDepositedFiles());\n                assertFalse(FileTool.fileExist(factoryPath()));\n            }\n        });\n    }\n\n    void doTestRetrieve(boolean success) throws WCDBException {\n        final WrappedValue lastPercentage = new WrappedValue();\n        double score = database.retrieve(new Database.ProgressMonitor() {\n            @Override\n            public boolean onProgressUpdate(double percentage, double increment) {\n                assertTrue(percentage - lastPercentage.doubleValue == increment && increment > 0);\n                lastPercentage.doubleValue = percentage;\n                return true;\n            }\n        });\n        assertTrue((success && score == 1.0) || (!success && score < 1.0));\n        assertEquals(lastPercentage.doubleValue, 1.0, 0.00001);\n    }\n\n    void doTestObjectsRetrieved(boolean success) {\n        List<TestObject> objects = null;\n        try {\n            objects = database.getAllObjects(DBTestObject.allFields(), tableName);\n        } catch (WCDBException e) {\n\n        }\n        if (success) {\n            assertNotNull(objects);\n            assertEquals(objects, preInsertObjects);\n        } else {\n            assertTrue(objects == null || objects.size() == 0);\n        }\n    }\n\n    @Test\n    public void testRetrieveWithBackupAndDeposit() {\n        executeTest(new TestOperation() {\n            @Override\n            public void execute() throws WCDBException {\n                database.backup();\n                database.deposit();\n                corruptHeader();\n                doTestRetrieve(true);\n                doTestObjectsRetrieved(true);\n            }\n        });\n    }\n\n    @Test\n    public void testRetrieveWithBackupAndWithoutDeposit() {\n        executeTest(new TestOperation() {\n            @Override\n            public void execute() throws WCDBException {\n                database.backup();\n                corruptHeader();\n                doTestRetrieve(true);\n                doTestObjectsRetrieved(true);\n            }\n        });\n    }\n\n    @Test\n    public void testRetrieveWithoutBackupAndWithDeposit() {\n        executeTest(new TestOperation() {\n            @Override\n            public void execute() throws WCDBException {\n                database.deposit();\n                corruptHeader();\n                doTestRetrieve(true);\n                doTestObjectsRetrieved(true);\n            }\n        });\n    }\n\n    @Test\n    public void testRetrieveWithoutBackupAndDeposit() {\n        executeTest(new TestOperation() {\n            @Override\n            public void execute() throws WCDBException {\n                corruptHeader();\n                database.deposit();\n                doTestRetrieve(false);\n                doTestObjectsRetrieved(false);\n            }\n        });\n    }\n\n    @Test\n    public void testVacuum() {\n        executeTest(new TestOperation() {\n            @Override\n            public void execute() throws WCDBException {\n                final WrappedValue lastPercentage = new WrappedValue();\n                database.vacuum(new Database.ProgressMonitor() {\n                    @Override\n                    public boolean onProgressUpdate(double percentage, double increment) {\n                        assertTrue(percentage - lastPercentage.doubleValue == increment && increment > 0);\n                        lastPercentage.doubleValue = percentage;\n                        return true;\n                    }\n                });\n                assertEquals(lastPercentage.doubleValue, 1.0, 0.00001);\n                doTestObjectsRetrieved(true);\n            }\n        });\n    }\n}\n"
  },
  {
    "path": "src/java/test/src/androidTest/java/com/tencent/wcdbtest/database/TraceTest.java",
    "content": "// Created by chenqiuwen on 2023/5/10.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdbtest.database;\n\nimport org.jetbrains.annotations.NotNull;\n\nimport androidx.test.ext.junit.runners.AndroidJUnit4;\n\nimport com.tencent.wcdb.base.Value;\nimport com.tencent.wcdb.base.WCDBException;\nimport com.tencent.wcdb.core.Database;\nimport com.tencent.wcdb.winq.Order;\nimport com.tencent.wcdb.winq.Pragma;\nimport com.tencent.wcdb.winq.StatementCreateIndex;\nimport com.tencent.wcdb.winq.StatementPragma;\nimport com.tencent.wcdb.winq.StatementSelect;\nimport com.tencent.wcdbtest.base.FileTool;\nimport com.tencent.wcdbtest.base.TestObject;\nimport com.tencent.wcdbtest.base.WrappedValue;\nimport com.tencent.wcdbtest.base.DBTestObject;\nimport com.tencent.wcdbtest.base.RandomTool;\nimport com.tencent.wcdbtest.base.TableTestCase;\n\nimport static org.junit.Assert.*;\n\nimport android.os.Process;\n\nimport org.junit.Test;\nimport org.junit.runner.RunWith;\n\nimport java.io.File;\nimport java.util.ArrayList;\nimport java.util.HashMap;\nimport java.util.List;\n\n@RunWith(AndroidJUnit4.class)\npublic class TraceTest extends TableTestCase {\n    @Test\n    public void testTraceSQL() throws WCDBException {\n        final StatementPragma statement = new StatementPragma().pragma(Pragma.userVersion);\n\n        final WrappedValue tested = new WrappedValue();\n        database.traceSQL(new Database.SQLTracer() {\n            @Override\n            public void onTrace(long tag, @NotNull String path, long handleId, @NotNull String sql, @NotNull String info) {\n                assertEquals(tag, database.getTag());\n                assertEquals(path, database.getPath());\n                if (sql.equals(statement.getDescription())) {\n                    tested.boolValue = true;\n                }\n            }\n        });\n        database.execute(statement);\n        assertTrue(tested.boolValue);\n        database.traceSQL(null);\n    }\n\n    @Test\n    public void testGlobalTraceSQL() throws WCDBException {\n        final StatementPragma statement = new StatementPragma().pragma(Pragma.userVersion);\n\n        final WrappedValue tested = new WrappedValue();\n        Database.globalTraceSQL(null);\n        Database.globalTraceSQL(new Database.SQLTracer() {\n            @Override\n            public void onTrace(long tag, @NotNull String path, long handleId, @NotNull String sql, @NotNull String info) {\n                if (!database.getPath().equals(path)) {\n                    return;\n                }\n                assertEquals(tag, database.getTag());\n                if (sql.equals(statement.getDescription())) {\n                    tested.boolValue = true;\n                }\n            }\n        });\n        database.execute(statement);\n        assertTrue(tested.boolValue);\n        Database.globalTraceSQL(null);\n    }\n\n    @Test\n    public void testTracePerformance() throws WCDBException {\n        database.removeFiles();\n        createTable();\n        database.tracePerformance(null);\n        ArrayList<TestObject> objects = new ArrayList<>();\n        for (int i = 0; i < 1000; i++) {\n            TestObject object = new TestObject();\n            object.content = RandomTool.string(4096);\n            objects.add(object);\n        }\n        WrappedValue testCount = new WrappedValue();\n        database.tracePerformance(new Database.PerformanceTracer() {\n            @Override\n            public void onTrace(long tag, @NotNull String path, long handleId, @NotNull String sql, @NotNull Database.PerformanceInfo info) {\n                assertEquals(tag, database.getTag());\n                assertEquals(path, database.getPath());\n                assertNotNull(info);\n                if (sql.startsWith(\"COMMIT\")) {\n                    assertTrue(info.costInNanoseconds > 0);\n                    assertTrue(info.tablePageWriteCount > 0);\n                    assertEquals(0, info.indexPageWriteCount);\n                    assertTrue(info.overflowPageWriteCount > 0);\n                    assertEquals(0, info.tablePageReadCount);\n                    assertEquals(0, info.indexPageReadCount);\n                    assertEquals(0, info.overflowPageReadCount);\n                    testCount.intValue++;\n                } else if (sql.startsWith(\"CREATE INDEX\")) {\n                    assertTrue(info.costInNanoseconds > 0);\n                    assertEquals(1, info.tablePageWriteCount);\n                    assertTrue(info.indexPageWriteCount > 0);\n                    assertEquals(info.overflowPageWriteCount, objects.size());\n                    assertTrue(info.tablePageReadCount > 0);\n                    assertTrue(info.indexPageReadCount >= 0);\n                    assertTrue(info.overflowPageReadCount > objects.size() / 2);\n                    testCount.intValue++;\n                } else if (sql.startsWith(\"SELECT\")) {\n                    assertTrue(info.costInNanoseconds > 0);\n                    assertEquals(0, info.tablePageWriteCount);\n                    assertEquals(0, info.indexPageWriteCount);\n                    assertEquals(0, info.overflowPageWriteCount);\n                    testCount.intValue++;\n                    if (sql.endsWith(\"ORDER BY content DESC\")) {\n                        assertEquals(0, info.tablePageReadCount);\n                        assertTrue(info.indexPageReadCount > 0);\n                        assertEquals(info.overflowPageReadCount, objects.size());\n                    } else {\n                        assertTrue(info.tablePageReadCount > 0);\n                        assertEquals(0, info.indexPageReadCount);\n                        assertEquals(info.overflowPageReadCount, objects.size());\n                    }\n                }\n            }\n        });\n        database.insertObjects(objects, DBTestObject.allFields(), tableName);\n        database.execute(new StatementCreateIndex().createIndex(\"testIndex\").on(tableName).indexedBy(DBTestObject.content));\n        assertEquals(database.getAllObjects(DBTestObject.allFields(), tableName).size(), objects.size());\n        assertEquals(database.getAllObjects(DBTestObject.allFields(), tableName, DBTestObject.content.order(Order.Desc)).size(), objects.size());\n        assertEquals(testCount.intValue, 4);\n        database.tracePerformance(null);\n    }\n\n    @Test\n    public void testGlobalTracePerformance() throws WCDBException {\n        database.removeFiles();\n        ArrayList<TestObject> objects = new ArrayList<>();\n        for (int i = 0; i < 1000; i++) {\n            TestObject object = new TestObject();\n            object.content = RandomTool.string(4096);\n            objects.add(object);\n        }\n        WrappedValue testCount = new WrappedValue();\n        WrappedValue lastSQLIsInsert = new WrappedValue();\n        Database.globalTracePerformance(null);\n        Database.globalTracePerformance(new Database.PerformanceTracer() {\n            @Override\n            public void onTrace(long tag, @NotNull String path, long handleId, @NotNull String sql, @NotNull Database.PerformanceInfo info) {\n                if (!database.getPath().equals(path)) {\n                    return;\n                }\n                assertEquals(tag, database.getTag());\n                if (sql.startsWith(\"COMMIT\") && lastSQLIsInsert.boolValue) {\n                    assertTrue(info.costInNanoseconds > 0);\n                    assertTrue(info.tablePageWriteCount > 0);\n                    assertEquals(0, info.indexPageWriteCount);\n                    assertTrue(info.overflowPageWriteCount > 0);\n                    assertEquals(0, info.tablePageReadCount);\n                    assertEquals(0, info.indexPageReadCount);\n                    assertEquals(0, info.overflowPageReadCount);\n                    testCount.intValue++;\n                } else if (sql.startsWith(\"CREATE INDEX\")) {\n                    assertTrue(info.costInNanoseconds > 0);\n                    assertEquals(1, info.tablePageWriteCount);\n                    assertTrue(info.indexPageWriteCount > 0);\n                    assertEquals(info.overflowPageWriteCount, objects.size());\n                    assertTrue(info.tablePageReadCount > 0);\n                    assertTrue(info.indexPageReadCount >= 0);\n                    assertTrue(info.overflowPageReadCount > objects.size() / 2);\n                    testCount.intValue++;\n                } else if (sql.startsWith(\"SELECT\")) {\n                    assertTrue(info.costInNanoseconds > 0);\n                    assertEquals(0, info.tablePageWriteCount);\n                    assertEquals(0, info.indexPageWriteCount);\n                    assertEquals(0, info.overflowPageWriteCount);\n                    testCount.intValue++;\n                    if (sql.endsWith(\"ORDER BY content DESC\")) {\n                        assertEquals(0, info.tablePageReadCount);\n                        assertTrue(info.indexPageReadCount > 0);\n                        assertEquals(info.overflowPageReadCount, objects.size());\n                    } else {\n                        assertTrue(info.tablePageReadCount > 0);\n                        assertEquals(0, info.indexPageReadCount);\n                        assertEquals(info.overflowPageReadCount, objects.size());\n                    }\n                }\n                lastSQLIsInsert.boolValue = sql.startsWith(\"INSERT\");\n            }\n        });\n        createTable();\n        database.insertObjects(objects, DBTestObject.allFields(), tableName);\n        database.execute(new StatementCreateIndex().createIndex(\"testIndex\").on(tableName).indexedBy(DBTestObject.content));\n        assertEquals(database.getAllObjects(DBTestObject.allFields(), tableName).size(), objects.size());\n        assertEquals(database.getAllObjects(DBTestObject.allFields(), tableName, DBTestObject.content.order(Order.Desc)).size(), objects.size());\n        assertEquals(testCount.intValue, 4);\n        Database.globalTracePerformance(null);\n    }\n\n    @Test\n    public void testTraceError() {\n        final WrappedValue tested = new WrappedValue();\n        database.traceException(new Database.ExceptionTracer() {\n            @Override\n            public void onTrace(@NotNull WCDBException exception) {\n                if (exception.level == WCDBException.Level.Error &&\n                        exception.path().equals(FileTool.getRealPath(path)) &&\n                        exception.tag() == database.getTag() &&\n                        exception.code == WCDBException.Code.Error &&\n                        exception.sql().equals(\"SELECT 1 FROM dummy\") &&\n                        exception.message().equals(\"no such table: dummy\")) {\n                    tested.boolValue = true;\n                }\n            }\n        });\n        assertTrue(database.canOpen());\n        try {\n            database.execute(new StatementSelect().select(\"1\").from(\"dummy\"));\n        } catch (WCDBException e) {\n            assertTrue(tested.boolValue);\n        } finally {\n            assertTrue(tested.boolValue);\n        }\n    }\n\n    @Test\n    public void testGlobalTraceError() {\n        final WrappedValue tested = new WrappedValue();\n        Database.globalTraceException(null);\n        Database.globalTraceException(new Database.ExceptionTracer() {\n            @Override\n            public void onTrace(@NotNull WCDBException exception) {\n                if (exception.level == WCDBException.Level.Error &&\n                        exception.path().equals(FileTool.getRealPath(path)) &&\n                        exception.tag() == database.getTag() &&\n                        exception.code == WCDBException.Code.Error &&\n                        exception.sql().equals(\"SELECT 1 FROM dummy\") &&\n                        exception.message().equals(\"no such table: dummy\")) {\n                    tested.boolValue = true;\n                }\n            }\n        });\n        assertTrue(database.canOpen());\n        try {\n            database.execute(new StatementSelect().select(\"1\").from(\"dummy\"));\n        } catch (WCDBException e) {\n            assertTrue(tested.boolValue);\n        } finally {\n            assertTrue(tested.boolValue);\n        }\n    }\n\n    @Test\n    public void testTraceDBOperation() throws WCDBException {\n        final WrappedValue tag = new WrappedValue();\n        final WrappedValue path = new WrappedValue();\n        final WrappedValue openHandleCount = new WrappedValue();\n        final WrappedValue tableCount = new WrappedValue();\n        final WrappedValue indexCount = new WrappedValue();\n        Database.globalTraceDatabaseOperation(new Database.OperationTracer() {\n            @Override\n            public void onTrace(@NotNull Database database, Database.Operation operation, @NotNull HashMap<String, Value> infos) {\n                switch (operation) {\n                    case Create:\n                        path.stringValue = database.getPath();\n                        break;\n                    case SetTag:\n                        tag.intValue = database.getTag();\n                        break;\n                    case OpenHandle:\n                        openHandleCount.intValue++;\n                        assertEquals(infos.get(Database.OperationInfoKeyHandleCount).getLong(), 1);\n                        assertTrue(infos.get(Database.OperationInfoKeyOpenTime).getLong() > 0);\n                        assertTrue(infos.get(Database.OperationInfoKeyOpenCPUTime).getLong() > 0);\n                        assertTrue(infos.get(Database.OperationInfoKeySchemaUsage).getLong() > 0);\n                        assertEquals(infos.get(Database.OperationInfoKeyTriggerCount).getLong(), 0);\n                        tableCount.intValue = infos.get(Database.OperationInfoKeyTableCount).getLong();\n                        indexCount.intValue = infos.get(Database.OperationInfoKeyIndexCount).getLong();\n                        break;\n                }\n            }\n        });\n        Database newDatabase = new Database(currentDirectory + File.separator + \"testDatabase2\");\n        newDatabase.setTag(10000);\n        newDatabase.createTable(tableName, DBTestObject.INSTANCE);\n        newDatabase.execute(new StatementCreateIndex().createIndex(\"testIndex\").on(tableName).indexedBy(DBTestObject.content));\n\n        assertEquals(tag.intValue, newDatabase.getTag());\n        assertEquals(path.stringValue, newDatabase.getPath());\n        assertEquals(openHandleCount.intValue, 1);\n\n        newDatabase.close();\n\n        newDatabase.insertObjects(RandomTool.autoIncrementTestCaseObjects(10), DBTestObject.allFields(), tableName);\n\n        assertEquals(tableCount.intValue, 4);\n        assertEquals(indexCount.intValue, 1);\n        assertEquals(openHandleCount.intValue, 2);\n        Database.globalTraceDatabaseOperation(null);\n    }\n\n    @Test\n    public void testGlobalTraceBusy() throws InterruptedException, WCDBException {\n        WrappedValue testTid = new WrappedValue();\n        Database.globalTraceBusy(new Database.BusyTracer() {\n            @Override\n            public void onTrace(long tag, @NotNull String path, long tid, @NotNull String sql) {\n                assertEquals(tag, database.getTag());\n                assertEquals(path, database.getPath());\n                assertEquals(sql, \"INSERT INTO testTable(id, content) VALUES(?1, ?2)\");\n                testTid.intValue = tid;\n            }\n        }, 0.1);\n        database.createTable(tableName, DBTestObject.INSTANCE);\n        List<TestObject> objects = RandomTool.autoIncrementTestCaseObjects(100000);\n        WrappedValue dispatchTid = new WrappedValue();\n        Thread thread = new Thread(new Runnable() {\n            @Override\n            public void run() {\n                dispatchTid.intValue = Process.myTid();\n                database.insertObjects(objects, DBTestObject.allFields(), tableName);\n            }\n        });\n        thread.start();\n        sleep(100);\n        database.insertObject(RandomTool.testObjectWithId(100001), DBTestObject.allFields(), tableName);\n        thread.join();\n        assertTrue(testTid.intValue != 0 && testTid.intValue == dispatchTid.intValue);\n    }\n\n}\n"
  },
  {
    "path": "src/java/test/src/androidTest/java/com/tencent/wcdbtest/orm/ORMTest.java",
    "content": "// Created by qiuwenchen on 2023/5/12.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage com.tencent.wcdbtest.orm;\n\nimport com.tencent.wcdb.base.Value;\nimport com.tencent.wcdb.base.WCDBException;\nimport com.tencent.wcdb.core.Database;\nimport com.tencent.wcdb.core.Table;\nimport com.tencent.wcdb.fts.BuiltinTokenizer;\nimport com.tencent.wcdb.orm.Field;\nimport com.tencent.wcdb.winq.Column;\nimport com.tencent.wcdb.winq.ColumnDef;\nimport com.tencent.wcdb.winq.ColumnType;\nimport com.tencent.wcdb.winq.Order;\nimport com.tencent.wcdb.winq.StatementCreateTable;\nimport com.tencent.wcdbtest.base.DBTestObject;\nimport com.tencent.wcdbtest.base.DatabaseTestCase;\nimport com.tencent.wcdbtest.base.WrappedValue;\nimport com.tencent.wcdbtest.orm.testclass.*;\n\nimport static org.junit.Assert.*;\n\nimport org.jetbrains.annotations.NotNull;\n\nimport org.junit.Before;\nimport org.junit.Test;\n\nimport java.util.List;\nimport java.util.Arrays;\nimport java.util.ArrayList;\n\npublic class ORMTest extends DatabaseTestCase {\n    String tableName = \"testTable\";\n\n    @Before\n    public void setup() throws WCDBException {\n        super.setup();\n        expectMode = Expect.SomeSQLs;\n    }\n\n    void doTestCreateTableAndIndexSQLsAsExpected(String[] sqls, TestOperation operation) {\n        assertNotNull(sqls);\n        assertNotNull(operation);\n        List<String> newSqls = new ArrayList<String>();\n        newSqls.add(\"BEGIN IMMEDIATE\");\n        newSqls.addAll(Arrays.asList(sqls));\n        newSqls.add(\"COMMIT\");\n        doTestSQLs(newSqls.toArray(new String[0]), operation);\n    }\n\n    @Test\n    public void testField() {\n        doTestCreateTableAndIndexSQLsAsExpected(new String[]{\"CREATE TABLE IF NOT EXISTS testTable(field INTEGER, differentName INTEGER)\"}, new TestOperation() {\n            @Override\n            public void execute() throws WCDBException {\n                database.createTable(tableName, DBFieldObject.INSTANCE);\n            }\n        });\n        doTestCreateTableAndIndexSQLsAsExpected(new String[]{\"CREATE TABLE IF NOT EXISTS newTable(field INTEGER, differentName INTEGER)\"}, new TestOperation() {\n            @Override\n            public void execute() throws WCDBException {\n                database.createTable(\"newTable\", DBFieldObject.INSTANCE);\n            }\n        });\n    }\n\n    @Test\n    public void testAllField() {\n        assertEquals(DBFieldObject.allFields().length, 2);\n        assertEquals(DBFieldObject.allFields()[0].getDescription(), \"field\");\n        assertEquals(DBFieldObject.allFields()[1].getDescription(), \"differentName\");\n    }\n\n    @Test\n    public void testAllType() throws WCDBException {\n        doTestCreateTableAndIndexSQLsAsExpected(new String[]{\n                \"CREATE TABLE IF NOT EXISTS testTable(type TEXT, \" +\n                        \"aBoolean INTEGER, aBoolean2 INTEGER, \" +\n                        \"aByte INTEGER, aByte2 INTEGER, \" +\n                        \"aShort INTEGER, aShort2 INTEGER, \" +\n                        \"anInt INTEGER, integer INTEGER, \" +\n                        \"aLong INTEGER, aLong2 INTEGER, \" +\n                        \"aFloat REAL, aFloat2 REAL, \" +\n                        \"aDouble REAL, aDouble2 REAL, \" +\n                        \"string TEXT, bytes BLOB)\"\n        }, new TestOperation() {\n            @Override\n            public void execute() throws WCDBException {\n                database.createTable(tableName, DBAllTypeObject.INSTANCE);\n            }\n        });\n        Table<AllTypeObject> table = database.getTable(tableName, DBAllTypeObject.INSTANCE);\n        AllTypeObject max = AllTypeObjectHelper.maxObject();\n        AllTypeObject min = AllTypeObjectHelper.minObject();\n        AllTypeObject random = AllTypeObjectHelper.randomObject();\n        AllTypeObject empty = AllTypeObjectHelper.emptyObject();\n        table.insertObjects(Arrays.asList(max, min, random, empty));\n\n        assertEquals(max, table.getFirstObject(DBAllTypeObject.allFields(), DBAllTypeObject.type.eq(max.type)));\n        assertEquals(min, table.getFirstObject(DBAllTypeObject.allFields(), DBAllTypeObject.type.eq(min.type)));\n        assertEquals(empty, table.getFirstObject(DBAllTypeObject.allFields(), DBAllTypeObject.type.eq(empty.type)));\n        assertEquals(random, table.getFirstObject(DBAllTypeObject.allFields(), DBAllTypeObject.type.eq(random.type)));\n\n        table.insertRow(new Value[]{new Value(\"null\")}, new Column[]{DBAllTypeObject.type});\n        assertEquals(empty, table.getFirstObject(DBAllTypeObject.allFields(), DBAllTypeObject.type.eq(\"null\")));\n    }\n\n    @Test\n    public void testColumnConstraint() {\n        doTestCreateTableAndIndexSQLsAsExpected(new String[]{\n                \"CREATE TABLE IF NOT EXISTS testTable(value INTEGER PRIMARY KEY)\"\n        }, new TestOperation() {\n            @Override\n            public void execute() throws WCDBException {\n                database.createTable(tableName, DBColumnConstraintPrimaryObject.INSTANCE);\n                database.dropTable(\"testTable\");\n            }\n        });\n\n        doTestCreateTableAndIndexSQLsAsExpected(new String[]{\n                \"CREATE TABLE IF NOT EXISTS testTable(value INTEGER PRIMARY KEY AUTOINCREMENT)\"\n        }, new TestOperation() {\n            @Override\n            public void execute() throws WCDBException {\n                database.createTable(tableName, DBColumnConstraintAutoIncrementObject.INSTANCE);\n                database.dropTable(\"testTable\");\n            }\n        });\n\n        doTestCreateTableAndIndexSQLsAsExpected(new String[]{\n                \"CREATE TABLE IF NOT EXISTS testTable(value INTEGER UNIQUE)\"\n        }, new TestOperation() {\n            @Override\n            public void execute() throws WCDBException {\n                database.createTable(tableName, DBColumnConstraintUniqueObject.INSTANCE);\n                database.dropTable(\"testTable\");\n            }\n        });\n\n        doTestCreateTableAndIndexSQLsAsExpected(new String[]{\n                \"CREATE TABLE IF NOT EXISTS testTable(intValue INTEGER DEFAULT 1, floatValue REAL DEFAULT 1.1000000000000001, stringValue TEXT DEFAULT 'abc')\"\n        }, new TestOperation() {\n            @Override\n            public void execute() throws WCDBException {\n                database.createTable(tableName, DBColumnConstraintDefaultObject.INSTANCE);\n                database.dropTable(\"testTable\");\n            }\n        });\n\n        doTestCreateTableAndIndexSQLsAsExpected(new String[]{\n                \"CREATE TABLE IF NOT EXISTS testTable(intValue INTEGER DEFAULT 0, floatValue REAL DEFAULT 0, stringValue TEXT DEFAULT '')\"\n        }, new TestOperation() {\n            @Override\n            public void execute() throws WCDBException {\n                database.createTable(tableName, DBColumnConstraintDefaultZeroObject.INSTANCE);\n                database.dropTable(\"testTable\");\n            }\n        });\n\n        doTestCreateTableAndIndexSQLsAsExpected(new String[]{\n                \"CREATE TABLE IF NOT EXISTS testTable(text TEXT NOT NULL)\"\n        }, new TestOperation() {\n            @Override\n            public void execute() throws WCDBException {\n                database.createTable(tableName, DBColumnConstraintNotNullObject.INSTANCE);\n                database.dropTable(\"testTable\");\n            }\n        });\n    }\n\n    @Test\n    public void testTableConstraint() {\n        doTestCreateTableAndIndexSQLsAsExpected(new String[]{\n                \"CREATE TABLE IF NOT EXISTS testTable(multiPrimary1 INTEGER, multiPrimary2 INTEGER, multiPrimary3 INTEGER, \" +\n                        \"multiUnique1 INTEGER, multiUnique2 INTEGER, multiUnique3 INTEGER, \" +\n                        \"multiIndex1 INTEGER, multiIndex2 INTEGER, multiIndex3 INTEGER, \" +\n                        \"PRIMARY KEY(multiPrimary1, multiPrimary2, multiPrimary3), \" +\n                        \"UNIQUE(multiUnique1, multiUnique2, multiUnique3))\",\n                \"CREATE INDEX IF NOT EXISTS specifiedNameIndex ON testTable(multiIndex1, multiIndex2, multiIndex3)\",\n                \"CREATE INDEX IF NOT EXISTS testTable_multiIndex1_multiIndex2_index ON testTable(multiIndex1, multiIndex2)\"\n        }, new TestOperation() {\n            @Override\n            public void execute() throws WCDBException {\n                database.createTable(tableName, DBTableConstraintObject.INSTANCE);\n            }\n        });\n    }\n\n    @Test\n    public void testRemap() {\n        doTestCreateTableAndIndexSQLsAsExpected(new String[]{\n                \"CREATE TABLE IF NOT EXISTS testTable(value INTEGER)\"\n        }, new TestOperation() {\n            @Override\n            public void execute() throws WCDBException {\n                database.createTable(\"testTable\", DBOldRemapObject.INSTANCE);\n            }\n        });\n        doTestCreateTableAndIndexSQLsAsExpected(new String[]{\n                \"PRAGMA main.table_info('testTable')\",\n                \"ALTER TABLE main.testTable ADD COLUMN newValue INTEGER\",\n                \"CREATE INDEX IF NOT EXISTS testTable_value_index ON testTable(value)\"\n        }, new TestOperation() {\n            @Override\n            public void execute() throws WCDBException {\n                database.createTable(\"testTable\", DBNewRemapObject.INSTANCE);\n            }\n        });\n    }\n\n    @Test\n    public void testIndex() {\n        doTestCreateTableAndIndexSQLsAsExpected(new String[]{\n                \"CREATE TABLE IF NOT EXISTS testTable(index_ INTEGER, uniqueIndex INTEGER)\",\n                \"CREATE INDEX IF NOT EXISTS testTable_index__index ON testTable(index_)\",\n                \"CREATE UNIQUE INDEX IF NOT EXISTS specifiedNameIndex ON testTable(uniqueIndex)\"\n        }, new TestOperation() {\n            @Override\n            public void execute() throws WCDBException {\n                database.createTable(tableName, DBIndexObject.INSTANCE);\n            }\n        });\n    }\n\n    @Test\n    public void testAutoAddColumn() throws WCDBException {\n        final String fakeTable = \"fakeTable\";\n        final String fakeSchema = \"notExistSchema\";\n        database.createTable(fakeTable, DBAutoAddColumnObject.INSTANCE);\n\n        doTestAutoAddColumn(DBAutoAddColumnObject.insertValue, true, new TestOperation() {\n            @Override\n            public void execute() throws WCDBException {\n                database.insertObject(new AutoAddColumnObject(), DBAutoAddColumnObject.allFields(), tableName);\n            }\n        });\n\n        doTestAutoAddColumn(DBAutoAddColumnObject.updateValue, true, new TestOperation() {\n            @Override\n            public void execute() throws WCDBException {\n                database.updateValue(1, DBAutoAddColumnObject.updateValue, tableName);\n            }\n        });\n\n        doTestAutoAddColumn(DBAutoAddColumnObject.deleteValue, true, new TestOperation() {\n            @Override\n            public void execute() throws WCDBException {\n                database.deleteObjects(tableName, DBAutoAddColumnObject.deleteValue.eq(1));\n            }\n        });\n\n        doTestAutoAddColumn(DBAutoAddColumnObject.deleteValue, true, new TestOperation() {\n            @Override\n            public void execute() throws WCDBException {\n                database.deleteObjects(tableName, DBAutoAddColumnObject.deleteValue.table(tableName).eq(1));\n            }\n        });\n\n        doTestAutoAddColumn(DBAutoAddColumnObject.deleteValue, false, new TestOperation() {\n            @Override\n            public void execute() throws WCDBException {\n                database.deleteObjects(tableName, DBAutoAddColumnObject.deleteValue.table(fakeTable).eq(1));\n            }\n        });\n\n        doTestAutoAddColumn(DBAutoAddColumnObject.deleteValue, false, new TestOperation() {\n            @Override\n            public void execute() throws WCDBException {\n                database.deleteObjects(tableName, DBAutoAddColumnObject.deleteValue.table(tableName).of(fakeSchema).eq(1));\n            }\n        });\n\n        doTestAutoAddColumn(DBAutoAddColumnObject.selectValue, true, new TestOperation() {\n            @Override\n            public void execute() throws WCDBException {\n                database.getOneColumn(DBAutoAddColumnObject.selectValue, tableName);\n            }\n        });\n\n        doTestAutoAddColumn(DBAutoAddColumnObject.selectValue, true, new TestOperation() {\n            @Override\n            public void execute() throws WCDBException {\n                database.getOneColumn(DBAutoAddColumnObject.insertValue, tableName, DBAutoAddColumnObject.selectValue.eq(1));\n            }\n        });\n\n        doTestAutoAddColumn(DBAutoAddColumnObject.selectValue, true, new TestOperation() {\n            @Override\n            public void execute() throws WCDBException {\n                database.getOneColumn(DBAutoAddColumnObject.insertValue, tableName, DBAutoAddColumnObject.selectValue.order(Order.Asc));\n            }\n        });\n\n        doTestAutoAddColumn(DBAutoAddColumnObject.selectValue, true, new TestOperation() {\n            @Override\n            public void execute() throws WCDBException {\n                database.getOneColumn(DBAutoAddColumnObject.insertValue, tableName, DBAutoAddColumnObject.selectValue.table(tableName).order(Order.Asc));\n            }\n        });\n\n        doTestAutoAddColumn(DBAutoAddColumnObject.selectValue, false, new TestOperation() {\n            @Override\n            public void execute() throws WCDBException {\n                database.getOneColumn(DBAutoAddColumnObject.insertValue, tableName, DBAutoAddColumnObject.selectValue.table(fakeTable).order(Order.Asc));\n            }\n        });\n\n        doTestAutoAddColumn(DBAutoAddColumnObject.selectValue, false, new TestOperation() {\n            @Override\n            public void execute() throws WCDBException {\n                database.getOneColumn(DBAutoAddColumnObject.insertValue, tableName, DBAutoAddColumnObject.selectValue.table(tableName).of(fakeSchema).order(Order.Asc));\n            }\n        });\n\n        doTestAutoAddColumn(DBAutoAddColumnObject.primaryValue, false, new TestOperation() {\n            @Override\n            public void execute() throws WCDBException {\n                database.getOneColumn(DBAutoAddColumnObject.primaryValue, tableName);\n            }\n        });\n\n        doTestAutoAddColumn(DBAutoAddColumnObject.uniqueValue, false, new TestOperation() {\n            @Override\n            public void execute() throws WCDBException {\n                database.getOneColumn(DBAutoAddColumnObject.uniqueValue, tableName);\n            }\n        });\n    }\n\n    void doTestAutoAddColumn(Field<AutoAddColumnObject> removeField, boolean succeed, TestOperation operation) throws WCDBException {\n        final String columnName = removeField.getName();\n        final StatementCreateTable createTable = new StatementCreateTable().createTable(tableName);\n        List<ColumnDef> columnDefs = new ArrayList<ColumnDef>();\n        for (Field<AutoAddColumnObject> field : DBAutoAddColumnObject.allFields()) {\n            if (!field.getDescription().equals(columnName)) {\n                columnDefs.add(new ColumnDef(field, ColumnType.Integer));\n            }\n        }\n\n        createTable.define(columnDefs.toArray(new ColumnDef[0]));\n        database.execute(createTable);\n        final WrappedValue added = new WrappedValue();\n        database.traceException(new Database.ExceptionTracer() {\n            @Override\n            public void onTrace(@NotNull WCDBException exception) {\n                if (!exception.message().equals(\"Auto add column\")) {\n                    return;\n                }\n                added.boolValue = true;\n                assertEquals((String) exception.info.get(\"Table\"), tableName);\n                assertEquals((String) exception.info.get(\"Column\"), columnName);\n            }\n        });\n        boolean hasError = false;\n        try {\n            operation.execute();\n        } catch (WCDBException e) {\n            hasError = true;\n        }\n        assertEquals(succeed, !hasError);\n        assertEquals(succeed, added.boolValue);\n        database.dropTable(tableName);\n        database.traceException(null);\n    }\n\n    @Test\n    public void testPrimaryKeyEnableAutoIncrementForExistingTable() throws WCDBException {\n        database.createTable(tableName, DBPrimaryNotAutoIncrementObject.INSTANCE);\n        PrimaryNotAutoIncrementObject obj1 = new PrimaryNotAutoIncrementObject();\n        obj1.id = 1;\n        database.insertObject(obj1, DBPrimaryNotAutoIncrementObject.allFields(), tableName);\n\n        database.createTable(tableName, DBPrimaryEnableAutoIncrementObject.INSTANCE);\n        database.deleteObjects(tableName);\n\n        PrimaryEnableAutoIncrementObject obj2 = new PrimaryEnableAutoIncrementObject();\n        database.insertObject(obj2, DBPrimaryEnableAutoIncrementObject.allFields(), tableName);\n        assertEquals(obj2.id, 2);\n    }\n\n    @Test\n    public void testFTS3Object() {\n        doTestSQLs(new String[]{\n                \"CREATE VIRTUAL TABLE IF NOT EXISTS testTable USING fts3(tokenize = wcdb_one_or_binary skip_stemming, id INTEGER, content TEXT, notindexed=id)\"\n        }, new TestOperation() {\n            @Override\n            public void execute() throws WCDBException {\n                database.addTokenizer(BuiltinTokenizer.OneOrBinary);\n                database.createVirtualTable(tableName, DBFTS3TestObject.INSTANCE);\n            }\n        });\n    }\n\n    @Test\n    public void testFTS5Object() {\n        doTestSQLs(new String[]{\n                \"CREATE VIRTUAL TABLE IF NOT EXISTS testTable USING fts5(tokenize = 'wcdb_verbatim skip_stemming chinese_traditional_to_simplified', content='contentTable', id UNINDEXED, content)\"\n        }, new TestOperation() {\n            @Override\n            public void execute() throws WCDBException {\n                database.addTokenizer(BuiltinTokenizer.Verbatim);\n                database.createVirtualTable(tableName, DBFTS5TestObject.INSTANCE);\n            }\n        });\n    }\n}\n"
  },
  {
    "path": "src/java/test/src/androidTest/java/com/tencent/wcdbtest/orm/testclass/AllTypeObjectHelper.java",
    "content": "package com.tencent.wcdbtest.orm.testclass;\n\nimport com.tencent.wcdbtest.base.RandomTool;\n\nimport java.util.Random;\n\npublic class AllTypeObjectHelper {\n    static public AllTypeObject maxObject() {\n        AllTypeObject max = new AllTypeObject();\n        max.type = \"max\";\n        max.aBoolean = true;\n        max.aBoolean2 = true;\n        max.aByte = Byte.MAX_VALUE;\n        max.aByte2 = Byte.MAX_VALUE;\n        max.aShort = Short.MAX_VALUE;\n        max.aShort2 = Short.MAX_VALUE;\n        max.anInt = Integer.MAX_VALUE;\n        max.integer = Integer.MAX_VALUE;\n        max.aLong = Long.MAX_VALUE;\n        max.aLong2 = Long.MAX_VALUE;\n        max.aFloat = Float.MAX_VALUE;\n        max.aFloat2 = Float.MAX_VALUE;\n        max.aDouble = Double.MAX_VALUE;\n        max.aDouble2 = Double.MAX_VALUE;\n        max.string = RandomTool.string();\n        max.bytes = RandomTool.bytes();\n        return max;\n    }\n\n    static public AllTypeObject minObject() {\n        AllTypeObject min = new AllTypeObject();\n        min.type = \"min\";\n        min.aBoolean = false;\n        min.aBoolean2 = false;\n        min.aByte = Byte.MIN_VALUE;\n        min.aByte2 = Byte.MIN_VALUE;\n        min.aShort = Short.MIN_VALUE;\n        min.aShort2 = Short.MIN_VALUE;\n        min.anInt = Integer.MIN_VALUE;\n        min.integer = Integer.MIN_VALUE;\n        min.aLong = Long.MIN_VALUE;\n        min.aLong2 = Long.MIN_VALUE;\n        min.aFloat = Float.MIN_VALUE;\n        min.aFloat2 = Float.MIN_VALUE;\n        min.aDouble = Double.MIN_VALUE;\n        min.aDouble2 = Double.MIN_VALUE;\n        min.string = RandomTool.string();\n        min.bytes = RandomTool.bytes();\n        return min;\n    }\n\n    static public AllTypeObject randomObject() {\n        Random random = new Random();\n        AllTypeObject object = new AllTypeObject();\n        object.type = \"random\";\n        object.aBoolean = random.nextBoolean();\n        object.aBoolean2 = random.nextBoolean();\n        object.aByte = (byte) random.nextInt();\n        object.aByte2 = (byte) random.nextInt();\n        object.aShort = (short) random.nextInt();\n        object.aShort2 = (short) random.nextInt();\n        object.anInt = random.nextInt();\n        object.integer = random.nextInt();\n        object.aLong = random.nextLong();\n        object.aLong2 = random.nextLong();\n        object.aFloat = random.nextFloat();\n        object.aFloat2 = random.nextFloat();\n        object.aDouble = random.nextDouble();\n        object.aDouble2 = random.nextDouble();\n        object.string = RandomTool.string();\n        object.bytes = RandomTool.bytes();\n        return object;\n    }\n\n    static public AllTypeObject emptyObject() {\n        AllTypeObject empty = new AllTypeObject();\n        empty.type = \"empty\";\n        return empty;\n    }\n}\n"
  },
  {
    "path": "src/java/test/src/androidTest/java/com/tencent/wcdbtest/sample/SimpleSample.java",
    "content": "// Created by chenqiuwen on 2023/5/22.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdbtest.sample;\n\nimport com.tencent.wcdb.base.WCDBException;\nimport com.tencent.wcdb.core.Database;\nimport com.tencent.wcdb.core.Handle;\nimport com.tencent.wcdb.core.PreparedStatement;\nimport com.tencent.wcdb.core.Table;\nimport com.tencent.wcdb.core.Transaction;\nimport com.tencent.wcdb.winq.Column;\nimport com.tencent.wcdb.winq.Order;\nimport com.tencent.wcdb.winq.Pragma;\nimport com.tencent.wcdb.winq.StatementInsert;\nimport com.tencent.wcdb.winq.StatementPragma;\nimport com.tencent.wcdb.winq.StatementSelect;\nimport com.tencent.wcdbtest.base.CRUDTestCase;\nimport com.tencent.wcdbtest.base.DBTestObject;\nimport com.tencent.wcdbtest.base.RandomTool;\nimport com.tencent.wcdbtest.base.TestObject;\n\nimport org.jetbrains.annotations.NotNull;\nimport org.junit.Test;\n\nimport java.io.File;\nimport java.util.ArrayList;\nimport java.util.List;\n\npublic class SimpleSample extends CRUDTestCase {\n    @Test\n    public void sample() throws WCDBException {\n        // Database对象可以在一个业务模块初始化的时候创建，无成本，然后跟随业务的其他逻辑的生命周期。\n        Database database = new Database(currentDirectory + File.separator + \"demoDatabase.sqlite3\");\n        // 这些配置都是在数据库实际使用的时候才生效，配置无成本\n        database.setCipherKey(\"abc\".getBytes(), 4096, Database.CipherVersion.version4);\n        // 自定义配置，一般不需要\n        database.setConfig(\"自定义配置名\", new Database.Config() {\n            @Override\n            public void onInvocation(@NotNull Handle handle) throws WCDBException {\n                // Pragma secure_delete = true\n                handle.execute(new StatementPragma().pragma(Pragma.secureDelete).toValue(true));\n            }\n        });\n\n        // 建表，不用判断表是否存在，底下会判断\n        database.createTable(\"testTable\", DBTestObject.INSTANCE);\n        // Table是数据库、表名、ORM类的封装，建议跟随database的生命周期，简单的CRUD都用Table\n        Table<TestObject> table = database.getTable(\"testTable\", DBTestObject.INSTANCE);\n        // 插入数据，这里创建的TestObject的id属性为0，因为配置了自增，插入之后会自动赋值id为最新rowid，还有insertOrReplaceObject、还有insertOrIgnoreObject接口\n        table.insertObject(TestObject.createAutoIncrementObject(RandomTool.string()));\n        // 批量插入，自动开事务\n        table.insertObjects(RandomTool.autoIncrementTestCaseObjects(100));\n        // 更新，可以用一个数据、一行数据、一个对象为单位去更新，后面还可以跟order，limit，offset参数\n        table.updateValue(\"updateContent\", DBTestObject.content, DBTestObject.id.eq(100));\n        table.updateObject(TestObject.createObject(200, \"updateContent2\"), DBTestObject.allFields(),\n                DBTestObject.id.eq(100).and(DBTestObject.content.eq(\"updateContent\")));\n        // 删除\n        table.deleteObjects(DBTestObject.id.lt(10));\n        table.deleteObjects(DBTestObject.id.order(Order.Desc), 10);\n        // 读取\n        TestObject object = table.getFirstObject(DBTestObject.id.eq(1));\n        List<TestObject> objects = table.getAllObjects(DBTestObject.id.gt(100), DBTestObject.id.order(Order.Asc), 10);\n\n        //执行事务\n        database.runTransaction(new Transaction() {\n            @Override\n            public boolean insideTransaction(@NotNull Handle handle) throws WCDBException {\n                //上面那些接口都能用，也可以用一些高阶接口，直接拼sql对象，来使用全部的sql能力\n                PreparedStatement insert = handle.getOrCreatePreparedStatement(new StatementInsert().insertInto(\"testTable\").orReplace()\n                        .columns(DBTestObject.allFields())\n                        .valuesWithBindParameters(DBTestObject.allFields().length));\n                for (int i = 0; i < 200; i++) {\n                    TestObject obj = TestObject.createObject(i, RandomTool.string());\n                    insert.reset();\n                    insert.bindObject(obj, DBTestObject.allFields());\n                    insert.step();\n                    obj.id = (int) handle.getLastInsertedRowId();\n                }\n                // select count(*) from testTable\n                int count = (int) handle.getValueFromStatement(new StatementSelect().select(Column.all().count()).from(\"testTable\")).getLong();\n\n                PreparedStatement select = handle.getOrCreatePreparedStatement(new StatementSelect().select(DBTestObject.allFields())\n                        .from(\"testTable\").where(DBTestObject.content.notNull()));\n                List<TestObject> result = new ArrayList<TestObject>();\n                select.step();\n                while (!select.isDone()) {\n                    result.add(select.getOneObject(DBTestObject.allFields()));\n                    select.step();\n                }\n                return true;//返回false回滚整个事务\n            }\n        });\n    }\n}\n"
  },
  {
    "path": "src/java/test/src/androidTest/java/com/tencent/wcdbtest/winq/BindParameterTest.java",
    "content": "// Created by chenqiuwen on 2023/3/31.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdbtest.winq;\n\n\nimport androidx.test.ext.junit.runners.AndroidJUnit4;\n\nimport com.tencent.wcdb.winq.*;\n\nimport static com.tencent.wcdbtest.base.WinqTool.winqEqual;\n\nimport org.junit.Test;\nimport org.junit.runner.RunWith;\n\n@RunWith(AndroidJUnit4.class)\npublic class BindParameterTest {\n    @Test\n    public void test() {\n        winqEqual(new BindParameter(1), \"?1\");\n        winqEqual(new BindParameter(\"testName\"), \":testName\");\n        winqEqual(BindParameter.at(\"testName\"), \"@testName\");\n        winqEqual(BindParameter.dollar(\"testName\"), \"$testName\");\n        winqEqual(BindParameter.colon(\"testName\"), \":testName\");\n        winqEqual(BindParameter.bindParameters(5)[4], \"?5\");\n\n        winqEqual(BindParameter.def, \"?\");\n        winqEqual(BindParameter._1, \"?1\");\n        winqEqual(BindParameter._2, \"?2\");\n        winqEqual(BindParameter._3, \"?3\");\n        winqEqual(BindParameter._4, \"?4\");\n        winqEqual(BindParameter._5, \"?5\");\n        winqEqual(BindParameter._6, \"?6\");\n        winqEqual(BindParameter._7, \"?7\");\n        winqEqual(BindParameter._8, \"?8\");\n        winqEqual(BindParameter._9, \"?9\");\n        winqEqual(BindParameter._10, \"?10\");\n\n    }\n}\n"
  },
  {
    "path": "src/java/test/src/androidTest/java/com/tencent/wcdbtest/winq/ColumnConstraintTest.java",
    "content": "// Created by chenqiuwen on 2023/4/6.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdbtest.winq;\n\nimport androidx.test.ext.junit.runners.AndroidJUnit4;\n\nimport com.tencent.wcdb.winq.*;\n\nimport static com.tencent.wcdbtest.base.WinqTool.winqEqual;\n\nimport org.junit.Test;\nimport org.junit.runner.RunWith;\n\n@RunWith(AndroidJUnit4.class)\npublic class ColumnConstraintTest {\n    @Test\n    public void test() {\n        winqEqual(new ColumnConstraint().primaryKey(), \"PRIMARY KEY\");\n        winqEqual(new ColumnConstraint(\"testColumnConstraint\").primaryKey(),\n                \"CONSTRAINT testColumnConstraint PRIMARY KEY\");\n        winqEqual(new ColumnConstraint().primaryKey().order(Order.Asc), \"PRIMARY KEY ASC\");\n        winqEqual(new ColumnConstraint().primaryKey().conflict(ConflictAction.Abort),\n                \"PRIMARY KEY ON CONFLICT ABORT\");\n        winqEqual(new ColumnConstraint().primaryKey().autoIncrement(), \"PRIMARY KEY AUTOINCREMENT\");\n        winqEqual(new ColumnConstraint(\"testColumnConstraint\").notNull(),\n                \"CONSTRAINT testColumnConstraint NOT NULL\");\n        winqEqual(new ColumnConstraint().notNull().conflict(ConflictAction.Abort),\n                \"NOT NULL ON CONFLICT ABORT\");\n        winqEqual(new ColumnConstraint(\"testColumnConstraint\").unique(),\n                \"CONSTRAINT testColumnConstraint UNIQUE\");\n        winqEqual(new ColumnConstraint().defaultTo(1), \"DEFAULT 1\");\n        winqEqual(new ColumnConstraint().defaultTo(false), \"DEFAULT FALSE\");\n        winqEqual(new ColumnConstraint().defaultTo(\"abc\"), \"DEFAULT 'abc'\");\n        winqEqual(new ColumnConstraint().defaultTo((ExpressionConvertible) null), \"DEFAULT NULL\");\n        winqEqual(new ColumnConstraint().collate(\"BINARY\"), \"COLLATE BINARY\");\n    }\n}\n"
  },
  {
    "path": "src/java/test/src/androidTest/java/com/tencent/wcdbtest/winq/ColumnDefTest.java",
    "content": "// Created by qiuwenchen on 2023/4/7.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdbtest.winq;\n\nimport com.tencent.wcdb.winq.*;\n\nimport androidx.test.ext.junit.runners.AndroidJUnit4;\n\nimport static com.tencent.wcdbtest.base.WinqTool.winqEqual;\n\nimport org.junit.Test;\nimport org.junit.runner.RunWith;\n\n@RunWith(AndroidJUnit4.class)\npublic class ColumnDefTest {\n    @Test\n    public void test() {\n        winqEqual(new ColumnDef(\"testColumn\"), \"testColumn\");\n        winqEqual(new ColumnDef(\"testColumn\", ColumnType.Integer), \"testColumn INTEGER\");\n        winqEqual(new ColumnDef(new Column(\"testColumn\")), \"testColumn\");\n        winqEqual(new ColumnDef(new Column(\"testColumn\"), ColumnType.Integer), \"testColumn INTEGER\");\n        winqEqual(new ColumnDef(\"testColumn\", ColumnType.Integer), \"testColumn INTEGER\");\n        winqEqual(genColumnDef().makePrimary(), \"testColumn INTEGER PRIMARY KEY\");\n        winqEqual(genColumnDef().makePrimary(true), \"testColumn INTEGER PRIMARY KEY AUTOINCREMENT\");\n        winqEqual(genColumnDef().makeNotNull(), \"testColumn INTEGER NOT NULL\");\n        winqEqual(genColumnDef().makeDefaultTo(LiteralValue.currentDate()), \"testColumn INTEGER DEFAULT CURRENT_DATE\");\n        winqEqual(genColumnDef().makeDefaultTo(LiteralValue.currentTime()), \"testColumn INTEGER DEFAULT CURRENT_TIME\");\n        winqEqual(genColumnDef().makeDefaultTo(LiteralValue.currentTimeStamp()), \"testColumn INTEGER DEFAULT CURRENT_TIMESTAMP\");\n    }\n\n    ColumnDef genColumnDef() {\n        return new ColumnDef(\"testColumn\", ColumnType.Integer);\n    }\n}\n"
  },
  {
    "path": "src/java/test/src/androidTest/java/com/tencent/wcdbtest/winq/ColumnTest.java",
    "content": "// Created by qiuwenchen on 2023/3/31.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdbtest.winq;\n\nimport androidx.test.ext.junit.runners.AndroidJUnit4;\n\nimport com.tencent.wcdb.winq.*;\n\nimport static com.tencent.wcdbtest.base.WinqTool.winqEqual;\n\nimport org.junit.Test;\nimport org.junit.runner.RunWith;\n\n@RunWith(AndroidJUnit4.class)\npublic class ColumnTest {\n    @Test\n    public void test() {\n        winqEqual(Column.all(), \"*\");\n        winqEqual(Column.rowId(), \"rowid\");\n        winqEqual(Column.rowId().as(\"rowidAlias\"), \"rowid AS rowidAlias\");\n        winqEqual(new Column(\"testColumn\"), \"testColumn\");\n        winqEqual(new Column(\"testColumn\").table(\"testTable\"), \"testTable.testColumn\");\n        winqEqual(new Column(\"testColumn\").table(\"testTable\").of(\"testSchema\"), \"testSchema.testTable.testColumn\");\n        winqEqual(new Column(\"testColumn\").table(\"testTable\").of(new Schema(\"testSchema\")), \"testSchema.testTable.testColumn\");\n    }\n}\n"
  },
  {
    "path": "src/java/test/src/androidTest/java/com/tencent/wcdbtest/winq/CommonTableExpressionTest.java",
    "content": "// Created by qiuwenchen on 2023/6/7.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdbtest.winq;\n\nimport androidx.test.ext.junit.runners.AndroidJUnit4;\n\nimport static com.tencent.wcdbtest.base.WinqTool.winqEqual;\n\nimport com.tencent.wcdb.winq.Column;\nimport com.tencent.wcdb.winq.CommonTableExpression;\nimport com.tencent.wcdb.winq.StatementSelect;\n\nimport org.junit.Test;\nimport org.junit.runner.RunWith;\n\n@RunWith(AndroidJUnit4.class)\npublic class CommonTableExpressionTest {\n    @Test\n    public void test() {\n        winqEqual(new CommonTableExpression(\"testTable\")\n                        .as(new StatementSelect().select(\"columnA\")),\n                \"testTable AS(SELECT columnA)\");\n        winqEqual(new CommonTableExpression(\"testTable\")\n                        .column(new Column(\"columnA\"))\n                        .as(new StatementSelect().select(\"columnB\")),\n                \"testTable(columnA) AS(SELECT columnB)\");\n        winqEqual(new CommonTableExpression(\"testTable\")\n                        .column(new Column(\"columnA\"))\n                        .column(new Column(\"columnB\"))\n                        .as(new StatementSelect().select(\"columnC\", \"columnD\")),\n                \"testTable(columnA, columnB) AS(SELECT columnC, columnD)\");\n    }\n}\n"
  },
  {
    "path": "src/java/test/src/androidTest/java/com/tencent/wcdbtest/winq/ExpressionTest.java",
    "content": "// Created by chenqiuwen on 2023/4/2.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdbtest.winq;\n\nimport androidx.test.ext.junit.runners.AndroidJUnit4;\n\nimport com.tencent.wcdb.base.Value;\nimport com.tencent.wcdb.winq.*;\n\nimport static com.tencent.wcdbtest.base.WinqTool.winqEqual;\n\nimport org.junit.Test;\nimport org.junit.runner.RunWith;\n\nimport java.util.List;\nimport java.util.HashSet;\nimport java.util.ArrayList;\nimport java.util.Set;\n\n@RunWith(AndroidJUnit4.class)\npublic class ExpressionTest {\n    @Test\n    public void testExpression() {\n        Column column = new Column(\"testColumn\");\n        winqEqual(new Expression(new LiteralValue(1)), \"1\");\n        winqEqual(new Expression(new LiteralValue(1.1)), \"1.1000000000000001\");\n        winqEqual(new Expression(new LiteralValue(\"abc\")), \"'abc'\");\n        winqEqual(new Expression(new LiteralValue(false)), \"FALSE\");\n        winqEqual(new Expression(new LiteralValue(true)), \"TRUE\");\n        winqEqual(new Expression(column), \"testColumn\");\n        winqEqual(new Expression(new BindParameter(1)), \"?1\");\n\n        winqEqual(Expression.exists(new StatementSelect().select(new Column(\"testColumn\"))),\n                \"EXISTS(SELECT testColumn)\");\n        winqEqual(Expression.notExists(new StatementSelect().select(new Column(\"testColumn\"))),\n                \"NOT EXISTS(SELECT testColumn)\");\n\n        winqEqual(Expression.cast(\"testColumn\").as(ColumnType.Integer),\n                \"CAST(testColumn AS INTEGER)\");\n        winqEqual(Expression.cast(column).as(ColumnType.Integer),\n                \"CAST(testColumn AS INTEGER)\");\n\n        winqEqual(Column.rowId().add(1).as(\"rowidAddOne\"), \"rowid + 1 AS rowidAddOne\");\n\n        winqEqual(Expression.case_().when(column.eq(1)).then(\"a\")\n                        .when(column.eq(2)).then(\"b\").else_(\"c\"),\n                \"CASE WHEN testColumn == 1 THEN 'a' WHEN testColumn == 2 THEN 'b' ELSE 'c' END\");\n        winqEqual(Expression.case_().when(column.eq(\"a\")).then(1)\n                        .when(column.eq(\"b\")).then(2).else_(3),\n                \"CASE WHEN testColumn == 'a' THEN 1 WHEN testColumn == 'b' THEN 2 ELSE 3 END\");\n        winqEqual(Expression.case_(column).when(\"a\").then(1)\n                        .when(\"b\").then(2).else_(3),\n                \"CASE testColumn WHEN 'a' THEN 1 WHEN 'b' THEN 2 ELSE 3 END\");\n        winqEqual(Expression.case_(column).when(1).then(\"a\")\n                        .when(2).then(\"b\").else_(\"c\"),\n                \"CASE testColumn WHEN 1 THEN 'a' WHEN 2 THEN 'b' ELSE 'c' END\");\n\n        winqEqual(Expression.windowFunction(\"testWindowFunction\")\n                        .invoke().argument(column)\n                        .filter(column.notEq(0)),\n                \"testWindowFunction(testColumn) FILTER(WHERE testColumn != 0)\");\n        winqEqual(Expression.windowFunction(\"testWindowFunction\")\n                        .invoke().argument(column)\n                        .filter(column.notEq(0)).over(\"testWindow\"),\n                \"testWindowFunction(testColumn) FILTER(WHERE testColumn != 0) OVER testWindow\");\n        winqEqual(Expression.windowFunction(\"testWindowFunction\")\n                        .invoke().argument(column)\n                        .filter(column.notEq(0))\n                        .over(new WindowDef().partitionBy(column)),\n                \"testWindowFunction(testColumn) FILTER(WHERE testColumn != 0) OVER(PARTITION BY testColumn)\");\n    }\n\n    @Test\n    public void testUnaryOperation() {\n        Column column = new Column(\"testColumn\");\n        winqEqual(column.isNull(), \"testColumn ISNULL\");\n        winqEqual(column.notNull(), \"testColumn NOTNULL\");\n    }\n\n    @Test\n    public void testBinaryOperation() {\n        Column left = new Column(\"left\");\n        Column right = new Column(\"right\");\n\n        winqEqual(left.or(right), \"left OR right\");\n        winqEqual(left.and(right), \"left AND right\");\n\n        winqEqual(left.multiply(right), \"left * right\");\n        winqEqual(left.multiply(1), \"left * 1\");\n        winqEqual(left.multiply(1.1), \"left * 1.1000000000000001\");\n\n        winqEqual(left.divide(right), \"left / right\");\n        winqEqual(left.divide(1), \"left / 1\");\n        winqEqual(left.divide(1.1), \"left / 1.1000000000000001\");\n\n        winqEqual(left.mod(right), \"left % right\");\n        winqEqual(left.mod(1), \"left % 1\");\n        winqEqual(left.mod(1.1), \"left % 1.1000000000000001\");\n\n        winqEqual(left.add(right), \"left + right\");\n        winqEqual(left.add(1), \"left + 1\");\n        winqEqual(left.add(1.1), \"left + 1.1000000000000001\");\n\n        winqEqual(left.minus(right), \"left - right\");\n        winqEqual(left.minus(1), \"left - 1\");\n        winqEqual(left.minus(1.1), \"left - 1.1000000000000001\");\n\n        winqEqual(left.leftShift(right), \"left << right\");\n        winqEqual(left.leftShift(1), \"left << 1\");\n\n        winqEqual(left.rightShift(right), \"left >> right\");\n        winqEqual(left.rightShift(1), \"left >> 1\");\n\n        winqEqual(left.bitAnd(right), \"left & right\");\n        winqEqual(left.bitAnd(1), \"left & 1\");\n\n        winqEqual(left.bitOr(right), \"left | right\");\n        winqEqual(left.bitOr(1), \"left | 1\");\n\n        winqEqual(left.lt(right), \"left < right\");\n        winqEqual(left.lt(1), \"left < 1\");\n        winqEqual(left.lt(1.1), \"left < 1.1000000000000001\");\n        winqEqual(left.lt(\"abc\"), \"left < 'abc'\");\n\n        winqEqual(left.le(right), \"left <= right\");\n        winqEqual(left.le(1), \"left <= 1\");\n        winqEqual(left.le(1.1), \"left <= 1.1000000000000001\");\n        winqEqual(left.le(\"abc\"), \"left <= 'abc'\");\n\n        winqEqual(left.gt(right), \"left > right\");\n        winqEqual(left.gt(1), \"left > 1\");\n        winqEqual(left.gt(1.1), \"left > 1.1000000000000001\");\n        winqEqual(left.gt(\"abc\"), \"left > 'abc'\");\n\n        winqEqual(left.ge(right), \"left >= right\");\n        winqEqual(left.ge(1), \"left >= 1\");\n        winqEqual(left.ge(1.1), \"left >= 1.1000000000000001\");\n        winqEqual(left.ge(\"abc\"), \"left >= 'abc'\");\n\n        winqEqual(left.eq(right), \"left == right\");\n        winqEqual(left.eq(false), \"left == FALSE\");\n        winqEqual(left.eq(1), \"left == 1\");\n        winqEqual(left.eq(1.1), \"left == 1.1000000000000001\");\n        winqEqual(left.eq(\"abc\"), \"left == 'abc'\");\n\n        winqEqual(left.notEq(right), \"left != right\");\n        winqEqual(left.notEq(false), \"left != FALSE\");\n        winqEqual(left.notEq(1), \"left != 1\");\n        winqEqual(left.notEq(1.1), \"left != 1.1000000000000001\");\n        winqEqual(left.notEq(\"abc\"), \"left != 'abc'\");\n\n        winqEqual(left.concat(right), \"left || right\");\n        winqEqual(left.concat(1), \"left || 1\");\n        winqEqual(left.concat(1.1), \"left || 1.1000000000000001\");\n        winqEqual(left.concat(\"abc\"), \"left || 'abc'\");\n    }\n\n    @Test\n    public void testBetweenOperation() {\n        Column column = new Column(\"testColumn\");\n        Column start = new Column(\"start\");\n        Column end = new Column(\"end\");\n\n\n        winqEqual(column.between(start, end), \"testColumn BETWEEN start AND end\");\n        winqEqual(column.between(start, 1), \"testColumn BETWEEN start AND 1\");\n        winqEqual(column.between(start, 1.1), \"testColumn BETWEEN start AND 1.1000000000000001\");\n        winqEqual(column.between(start, \"abc\"), \"testColumn BETWEEN start AND 'abc'\");\n\n        winqEqual(column.between(1, end), \"testColumn BETWEEN 1 AND end\");\n        winqEqual(column.between(1, 1), \"testColumn BETWEEN 1 AND 1\");\n        winqEqual(column.between(1, 1.1), \"testColumn BETWEEN 1 AND 1.1000000000000001\");\n        winqEqual(column.between(1, \"abc\"), \"testColumn BETWEEN 1 AND 'abc'\");\n\n        winqEqual(column.between(1.1, end), \"testColumn BETWEEN 1.1000000000000001 AND end\");\n        winqEqual(column.between(1.1, 1), \"testColumn BETWEEN 1.1000000000000001 AND 1\");\n        winqEqual(column.between(1.1, 1.1), \"testColumn BETWEEN 1.1000000000000001 AND 1.1000000000000001\");\n        winqEqual(column.between(1.1, \"abc\"), \"testColumn BETWEEN 1.1000000000000001 AND 'abc'\");\n\n        winqEqual(column.between(\"abc\", end), \"testColumn BETWEEN 'abc' AND end\");\n        winqEqual(column.between(\"abc\", 1), \"testColumn BETWEEN 'abc' AND 1\");\n        winqEqual(column.between(\"abc\", 1.1), \"testColumn BETWEEN 'abc' AND 1.1000000000000001\");\n        winqEqual(column.between(\"abc\", \"abc\"), \"testColumn BETWEEN 'abc' AND 'abc'\");\n\n        winqEqual(column.notBetween(start, end), \"testColumn NOT BETWEEN start AND end\");\n        winqEqual(column.notBetween(start, 1), \"testColumn NOT BETWEEN start AND 1\");\n        winqEqual(column.notBetween(start, 1.1), \"testColumn NOT BETWEEN start AND 1.1000000000000001\");\n        winqEqual(column.notBetween(start, \"abc\"), \"testColumn NOT BETWEEN start AND 'abc'\");\n\n        winqEqual(column.notBetween(1, end), \"testColumn NOT BETWEEN 1 AND end\");\n        winqEqual(column.notBetween(1, 1), \"testColumn NOT BETWEEN 1 AND 1\");\n        winqEqual(column.notBetween(1, 1.1), \"testColumn NOT BETWEEN 1 AND 1.1000000000000001\");\n        winqEqual(column.notBetween(1, \"abc\"), \"testColumn NOT BETWEEN 1 AND 'abc'\");\n\n        winqEqual(column.notBetween(1.1, end), \"testColumn NOT BETWEEN 1.1000000000000001 AND end\");\n        winqEqual(column.notBetween(1.1, 1), \"testColumn NOT BETWEEN 1.1000000000000001 AND 1\");\n        winqEqual(column.notBetween(1.1, 1.1), \"testColumn NOT BETWEEN 1.1000000000000001 AND 1.1000000000000001\");\n        winqEqual(column.notBetween(1.1, \"abc\"), \"testColumn NOT BETWEEN 1.1000000000000001 AND 'abc'\");\n\n        winqEqual(column.notBetween(\"abc\", end), \"testColumn NOT BETWEEN 'abc' AND end\");\n        winqEqual(column.notBetween(\"abc\", 1), \"testColumn NOT BETWEEN 'abc' AND 1\");\n        winqEqual(column.notBetween(\"abc\", 1.1), \"testColumn NOT BETWEEN 'abc' AND 1.1000000000000001\");\n        winqEqual(column.notBetween(\"abc\", \"abc\"), \"testColumn NOT BETWEEN 'abc' AND 'abc'\");\n    }\n\n    @Test\n    public void testInOperation() {\n        Column column = new Column(\"testColumn\");\n\n        winqEqual(column.in(new short[]{1, 2, 3}), \"testColumn IN(1, 2, 3)\");\n        Set<Short> shortSet = new HashSet<Short>();\n        shortSet.add((short) 1);\n        shortSet.add((short) 2);\n        shortSet.add((short) 3);\n        winqEqual(column.in(shortSet), \"testColumn IN(1, 2, 3)\");\n        winqEqual(column.in(new Short[]{1, 2, 3}), \"testColumn IN(1, 2, 3)\");\n        List<Short> shortList = new ArrayList<Short>();\n        shortList.add((short) 1);\n        shortList.add((short) 2);\n        shortList.add((short) 3);\n        winqEqual(column.in(shortList), \"testColumn IN(1, 2, 3)\");\n\n        winqEqual(column.in(1, 2, 3), \"testColumn IN(1, 2, 3)\");\n        winqEqual(column.in(new int[]{1, 2, 3}), \"testColumn IN(1, 2, 3)\");\n        winqEqual(column.in(new Value(1), new Value(2), new Value(3)), \"testColumn IN(1, 2, 3)\");\n        Set<Integer> intSet = new HashSet<Integer>();\n        intSet.add(1);\n        intSet.add(2);\n        intSet.add(3);\n        winqEqual(column.in(intSet), \"testColumn IN(1, 2, 3)\");\n        winqEqual(column.in(new Integer[]{1, 2, 3}), \"testColumn IN(1, 2, 3)\");\n        List<Integer> intList = new ArrayList<Integer>();\n        intList.add(1);\n        intList.add(2);\n        intList.add(3);\n        winqEqual(column.in(intList), \"testColumn IN(1, 2, 3)\");\n\n        winqEqual(column.in(new long[]{1, 2, 3}), \"testColumn IN(1, 2, 3)\");\n        Set<Long> longSet = new HashSet<Long>();\n        longSet.add(1L);\n        longSet.add(2L);\n        longSet.add(3L);\n        winqEqual(column.in(longSet), \"testColumn IN(1, 2, 3)\");\n        winqEqual(column.in(new Long[]{1L, 2L, 3L}), \"testColumn IN(1, 2, 3)\");\n        List<Long> longList = new ArrayList<Long>();\n        longList.add(1L);\n        longList.add(2L);\n        longList.add(3L);\n        winqEqual(column.in(longList), \"testColumn IN(1, 2, 3)\");\n\n        winqEqual(column.in(1.1f, 2.1f, 3.1f), \"testColumn IN(1.1000000238418579, 2.0999999046325684, 3.0999999046325684)\");\n        winqEqual(column.in(new float[]{1.1f, 2.1f, 3.1f}), \"testColumn IN(1.1000000238418579, 2.0999999046325684, 3.0999999046325684)\");\n        winqEqual(column.in(new Value(1.1f), new Value(2.1f), new Value(3.1f)), \"testColumn IN(1.1000000238418579, 2.0999999046325684, 3.0999999046325684)\");\n        Set<Float> floatSet = new HashSet<Float>();\n        floatSet.add(1.1f);\n        floatSet.add(2.1f);\n        floatSet.add(3.1f);\n        winqEqual(column.in(floatSet), \"testColumn IN(2.0999999046325684, 3.0999999046325684, 1.1000000238418579)\");\n        winqEqual(column.in(new Float[]{1.1f, 2.1f, 3.1f}), \"testColumn IN(1.1000000238418579, 2.0999999046325684, 3.0999999046325684)\");\n        List<Float> floatList = new ArrayList<Float>();\n        floatList.add(1.1f);\n        floatList.add(2.1f);\n        floatList.add(3.1f);\n        winqEqual(column.in(floatList), \"testColumn IN(1.1000000238418579, 2.0999999046325684, 3.0999999046325684)\");\n\n        winqEqual(column.in(1.1, 2.1, 3.1), \"testColumn IN(1.1000000000000001, 2.1000000000000001, 3.1000000000000001)\");\n        winqEqual(column.in(new double[]{1.1, 2.1, 3.1}), \"testColumn IN(1.1000000000000001, 2.1000000000000001, 3.1000000000000001)\");\n        winqEqual(column.in(new Value(1.1), new Value(2.1), new Value(3.1)), \"testColumn IN(1.1000000000000001, 2.1000000000000001, 3.1000000000000001)\");\n        Set<Double> doubleSet = new HashSet<Double>();\n        doubleSet.add(1.1);\n        doubleSet.add(2.1);\n        doubleSet.add(3.1);\n        winqEqual(column.in(doubleSet), \"testColumn IN(3.1000000000000001, 1.1000000000000001, 2.1000000000000001)\");\n        winqEqual(column.in(new Double[]{1.1, 2.1, 3.1}), \"testColumn IN(1.1000000000000001, 2.1000000000000001, 3.1000000000000001)\");\n        List<Double> doubleList = new ArrayList<Double>();\n        doubleList.add(1.1);\n        doubleList.add(2.1);\n        doubleList.add(3.1);\n        winqEqual(column.in(doubleList), \"testColumn IN(1.1000000000000001, 2.1000000000000001, 3.1000000000000001)\");\n\n        winqEqual(column.in(\"abc\", \"def\", \"ghi\"), \"testColumn IN('abc', 'def', 'ghi')\");\n        winqEqual(column.in(new String[]{\"abc\", \"def\", \"ghi\"}), \"testColumn IN('abc', 'def', 'ghi')\");\n        winqEqual(column.in(new Value(\"abc\"), new Value(\"def\"), new Value(\"ghi\")), \"testColumn IN('abc', 'def', 'ghi')\");\n        Set<String> stringSet = new HashSet<String>();\n        stringSet.add(\"abc\");\n        stringSet.add(\"def\");\n        stringSet.add(\"ghi\");\n        winqEqual(column.in(stringSet), \"testColumn IN('abc', 'def', 'ghi')\");\n        List<String> stringList = new ArrayList<String>();\n        stringList.add(\"abc\");\n        stringList.add(\"def\");\n        stringList.add(\"ghi\");\n        winqEqual(column.in(stringList), \"testColumn IN('abc', 'def', 'ghi')\");\n\n        winqEqual(column.inTable(\"testTable\"), \"testColumn IN testTable\");\n        winqEqual(column.inTable(\"testTable\").schema(Schema.temp), \"testColumn IN temp.testTable\");\n        winqEqual(column.inFunction(\"testFunction\").schema(Schema.main).argument(1).argument(\"abc\"), \"testColumn IN main.testFunction(1, 'abc')\");\n    }\n\n    @Test\n    public void testNotInOperation() {\n        Column column = new Column(\"testColumn\");\n\n        winqEqual(column.notIn(new short[]{1, 2, 3}), \"testColumn NOT IN(1, 2, 3)\");\n        Set<Short> shortSet = new HashSet<Short>();\n        shortSet.add((short) 1);\n        shortSet.add((short) 2);\n        shortSet.add((short) 3);\n        winqEqual(column.notIn(shortSet), \"testColumn NOT IN(1, 2, 3)\");\n        winqEqual(column.notIn(new Short[]{1, 2, 3}), \"testColumn NOT IN(1, 2, 3)\");\n        List<Short> shortList = new ArrayList<Short>();\n        shortList.add((short) 1);\n        shortList.add((short) 2);\n        shortList.add((short) 3);\n        winqEqual(column.notIn(shortList), \"testColumn NOT IN(1, 2, 3)\");\n\n        winqEqual(column.notIn(1, 2, 3), \"testColumn NOT IN(1, 2, 3)\");\n        winqEqual(column.notIn(new int[]{1, 2, 3}), \"testColumn NOT IN(1, 2, 3)\");\n        winqEqual(column.notIn(new Value(1), new Value(2), new Value(3)), \"testColumn NOT IN(1, 2, 3)\");\n        Set<Integer> intSet = new HashSet<Integer>();\n        intSet.add(1);\n        intSet.add(2);\n        intSet.add(3);\n        winqEqual(column.notIn(intSet), \"testColumn NOT IN(1, 2, 3)\");\n        winqEqual(column.notIn(new Integer[]{1, 2, 3}), \"testColumn NOT IN(1, 2, 3)\");\n        List<Integer> intList = new ArrayList<Integer>();\n        intList.add(1);\n        intList.add(2);\n        intList.add(3);\n        winqEqual(column.notIn(intList), \"testColumn NOT IN(1, 2, 3)\");\n\n        winqEqual(column.notIn(new long[]{1, 2, 3}), \"testColumn NOT IN(1, 2, 3)\");\n        Set<Long> longSet = new HashSet<Long>();\n        longSet.add(1L);\n        longSet.add(2L);\n        longSet.add(3L);\n        winqEqual(column.notIn(longSet), \"testColumn NOT IN(1, 2, 3)\");\n        winqEqual(column.notIn(new Long[]{1L, 2L, 3L}), \"testColumn NOT IN(1, 2, 3)\");\n        List<Long> longList = new ArrayList<Long>();\n        longList.add(1L);\n        longList.add(2L);\n        longList.add(3L);\n        winqEqual(column.notIn(longList), \"testColumn NOT IN(1, 2, 3)\");\n\n        winqEqual(column.notIn(1.1f, 2.1f, 3.1f), \"testColumn NOT IN(1.1000000238418579, 2.0999999046325684, 3.0999999046325684)\");\n        winqEqual(column.notIn(new float[]{1.1f, 2.1f, 3.1f}), \"testColumn NOT IN(1.1000000238418579, 2.0999999046325684, 3.0999999046325684)\");\n        winqEqual(column.notIn(new Value(1.1f), new Value(2.1f), new Value(3.1f)), \"testColumn NOT IN(1.1000000238418579, 2.0999999046325684, 3.0999999046325684)\");\n        Set<Float> floatSet = new HashSet<Float>();\n        floatSet.add(1.1f);\n        floatSet.add(2.1f);\n        floatSet.add(3.1f);\n        winqEqual(column.notIn(floatSet), \"testColumn NOT IN(2.0999999046325684, 3.0999999046325684, 1.1000000238418579)\");\n        winqEqual(column.notIn(new Float[]{1.1f, 2.1f, 3.1f}), \"testColumn NOT IN(1.1000000238418579, 2.0999999046325684, 3.0999999046325684)\");\n        List<Float> floatList = new ArrayList<Float>();\n        floatList.add(1.1f);\n        floatList.add(2.1f);\n        floatList.add(3.1f);\n        winqEqual(column.notIn(floatList), \"testColumn NOT IN(1.1000000238418579, 2.0999999046325684, 3.0999999046325684)\");\n\n        winqEqual(column.notIn(1.1, 2.1, 3.1), \"testColumn NOT IN(1.1000000000000001, 2.1000000000000001, 3.1000000000000001)\");\n        winqEqual(column.notIn(new double[]{1.1, 2.1, 3.1}), \"testColumn NOT IN(1.1000000000000001, 2.1000000000000001, 3.1000000000000001)\");\n        winqEqual(column.notIn(new Value(1.1), new Value(2.1), new Value(3.1)), \"testColumn NOT IN(1.1000000000000001, 2.1000000000000001, 3.1000000000000001)\");\n        Set<Double> doubleSet = new HashSet<Double>();\n        doubleSet.add(1.1);\n        doubleSet.add(2.1);\n        doubleSet.add(3.1);\n        winqEqual(column.notIn(doubleSet), \"testColumn NOT IN(3.1000000000000001, 1.1000000000000001, 2.1000000000000001)\");\n        winqEqual(column.notIn(new Double[]{1.1, 2.1, 3.1}), \"testColumn NOT IN(1.1000000000000001, 2.1000000000000001, 3.1000000000000001)\");\n        List<Double> doubleList = new ArrayList<Double>();\n        doubleList.add(1.1);\n        doubleList.add(2.1);\n        doubleList.add(3.1);\n        winqEqual(column.notIn(doubleList), \"testColumn NOT IN(1.1000000000000001, 2.1000000000000001, 3.1000000000000001)\");\n\n        winqEqual(column.notIn(\"abc\", \"def\", \"ghi\"), \"testColumn NOT IN('abc', 'def', 'ghi')\");\n        winqEqual(column.notIn(new String[]{\"abc\", \"def\", \"ghi\"}), \"testColumn NOT IN('abc', 'def', 'ghi')\");\n        winqEqual(column.notIn(new Value(\"abc\"), new Value(\"def\"), new Value(\"ghi\")), \"testColumn NOT IN('abc', 'def', 'ghi')\");\n        Set<String> stringSet = new HashSet<String>();\n        stringSet.add(\"abc\");\n        stringSet.add(\"def\");\n        stringSet.add(\"ghi\");\n        winqEqual(column.notIn(stringSet), \"testColumn NOT IN('abc', 'def', 'ghi')\");\n        List<String> stringList = new ArrayList<String>();\n        stringList.add(\"abc\");\n        stringList.add(\"def\");\n        stringList.add(\"ghi\");\n        winqEqual(column.notIn(stringList), \"testColumn NOT IN('abc', 'def', 'ghi')\");\n\n        winqEqual(column.notInTable(\"testTable\"), \"testColumn NOT IN testTable\");\n        winqEqual(column.notInTable(\"testTable\").schema(Schema.temp), \"testColumn NOT IN temp.testTable\");\n        winqEqual(column.notInFunction(\"testFunction\").schema(Schema.main).argument(1).argument(\"abc\"), \"testColumn NOT IN main.testFunction(1, 'abc')\");\n    }\n\n    @Test\n    public void testCollate() {\n        winqEqual(new Column(\"testColumn\").collate(\"BINARY\"), \"testColumn COLLATE BINARY\");\n    }\n\n    @Test\n    public void testFunction() {\n        Column left = new Column(\"left\");\n        String right = \"right\";\n\n        winqEqual(left.substr(1, 2), \"SUBSTR(left, 1, 2)\");\n\n        winqEqual(left.like(right), \"left LIKE 'right'\");\n\n        winqEqual(left.glob(right), \"left GLOB 'right'\");\n\n        winqEqual(left.match(right), \"left MATCH 'right'\");\n\n        winqEqual(left.regexp(right), \"left REGEXP 'right'\");\n\n        winqEqual(left.notLike(right), \"left NOT LIKE 'right'\");\n\n        winqEqual(left.notGlob(right), \"left NOT GLOB 'right'\");\n\n        winqEqual(left.notMatch(right), \"left NOT MATCH 'right'\");\n\n        winqEqual(left.notRegexp(right), \"left NOT REGEXP 'right'\");\n\n        winqEqual(left.like(right).escape(\"%\"), \"left LIKE 'right' ESCAPE '%'\");\n\n        winqEqual(left.glob(right).escape(\"%\"), \"left GLOB 'right' ESCAPE '%'\");\n\n        winqEqual(left.match(right).escape(\"%\"), \"left MATCH 'right' ESCAPE '%'\");\n\n        winqEqual(left.regexp(right).escape(\"%\"), \"left REGEXP 'right' ESCAPE '%'\");\n\n        winqEqual(left.notLike(right).escape(\"%\"), \"left NOT LIKE 'right' ESCAPE '%'\");\n\n        winqEqual(left.notGlob(right).escape(\"%\"), \"left NOT GLOB 'right' ESCAPE '%'\");\n\n        winqEqual(left.notMatch(right).escape(\"%\"), \"left NOT MATCH 'right' ESCAPE '%'\");\n\n        winqEqual(left.notRegexp(right).escape(\"%\"), \"left NOT REGEXP 'right' ESCAPE '%'\");\n\n        winqEqual(left.is(right), \"left IS 'right'\");\n\n        winqEqual(left.isNot(right), \"left IS NOT 'right'\");\n\n        winqEqual(left.avg(), \"AVG(left)\");\n\n        winqEqual(left.count().distinct(), \"COUNT(DISTINCT left)\");\n\n        winqEqual(left.groupConcat(), \"GROUP_CONCAT(left)\");\n\n        winqEqual(left.groupConcat(\"-\").distinct(), \"GROUP_CONCAT(DISTINCT left, '-')\");\n\n        winqEqual(left.max(), \"MAX(left)\");\n\n        winqEqual(left.min(), \"MIN(left)\");\n\n        winqEqual(left.sum(), \"SUM(left)\");\n\n        winqEqual(left.total(), \"TOTAL(left)\");\n\n        winqEqual(left.abs(), \"ABS(left)\");\n\n        winqEqual(left.hex(), \"HEX(left)\");\n\n        winqEqual(left.length(), \"LENGTH(left)\");\n\n        winqEqual(left.lower(), \"LOWER(left)\");\n\n        winqEqual(left.upper(), \"UPPER(left)\");\n\n        winqEqual(left.round(), \"ROUND(left)\");\n\n        winqEqual(left.matchInfo(), \"matchInfo(left)\");\n\n        winqEqual(left.offsets(), \"offsets(left)\");\n\n        winqEqual(left.snippet(), \"snippet(left)\");\n\n        winqEqual(left.bm25(), \"bm25(left)\");\n\n        winqEqual(left.highlight(), \"highlight(left)\");\n\n        winqEqual(left.substringMatchInfo(), \"substring_match_info(left)\");\n    }\n}\n"
  },
  {
    "path": "src/java/test/src/androidTest/java/com/tencent/wcdbtest/winq/ForeignKeyTest.java",
    "content": "// Created by qiuwenchen on 2023/6/8.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdbtest.winq;\n\nimport androidx.test.ext.junit.runners.AndroidJUnit4;\n\nimport static com.tencent.wcdbtest.base.WinqTool.winqEqual;\n\nimport com.tencent.wcdb.winq.Column;\nimport com.tencent.wcdb.winq.ForeignKey;\n\nimport org.junit.Test;\nimport org.junit.runner.RunWith;\n\n@RunWith(AndroidJUnit4.class)\npublic class ForeignKeyTest {\n    @Test\n    public void test() {\n        winqEqual(genForeignKey().onDelete(ForeignKey.Action.SetNull),\n                \"REFERENCES testForeignKeyTable(column1, column2) ON DELETE SET NULL\");\n        winqEqual(genForeignKey().onUpdate(ForeignKey.Action.SetDefault),\n                \"REFERENCES testForeignKeyTable(column1, column2) ON UPDATE SET DEFAULT\");\n        winqEqual(genForeignKey().onDelete(ForeignKey.Action.Cascade),\n                \"REFERENCES testForeignKeyTable(column1, column2) ON DELETE CASCADE\");\n        winqEqual(genForeignKey().onUpdate(ForeignKey.Action.Restrict),\n                \"REFERENCES testForeignKeyTable(column1, column2) ON UPDATE RESTRICT\");\n        winqEqual(genForeignKey().onDelete(ForeignKey.Action.NoAction),\n                \"REFERENCES testForeignKeyTable(column1, column2) ON DELETE NO ACTION\");\n        winqEqual(genForeignKey().deferrable(ForeignKey.Initially.Deferred),\n                \"REFERENCES testForeignKeyTable(column1, column2) DEFERRABLE INITIALLY DEFERRED\");\n        winqEqual(genForeignKey().notDeferrable(ForeignKey.Initially.Immediate),\n                \"REFERENCES testForeignKeyTable(column1, column2) NOT DEFERRABLE INITIALLY IMMEDIATE\");\n        winqEqual(genForeignKey().match(ForeignKey.Match.Simple),\n                \"REFERENCES testForeignKeyTable(column1, column2) MATCH SIMPLE\");\n    }\n\n    ForeignKey genForeignKey() {\n        return new ForeignKey().references(\"testForeignKeyTable\")\n                .columns(new Column(\"column1\"), new Column(\"column2\"));\n    }\n}\n"
  },
  {
    "path": "src/java/test/src/androidTest/java/com/tencent/wcdbtest/winq/FrameSpecTest.java",
    "content": "// Created by qiuwenchen on 2023/6/9.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdbtest.winq;\n\nimport androidx.test.ext.junit.runners.AndroidJUnit4;\n\nimport static com.tencent.wcdbtest.base.WinqTool.winqEqual;\n\nimport com.tencent.wcdb.winq.Expression;\nimport com.tencent.wcdb.winq.FrameSpec;\n\nimport org.junit.Test;\nimport org.junit.runner.RunWith;\n\n@RunWith(AndroidJUnit4.class)\npublic class FrameSpecTest {\n    @Test\n    public void test() {\n        winqEqual(new FrameSpec().range().unboundedPreceding(),\n                \"RANGE UNBOUNDED PRECEDING\");\n        winqEqual(new FrameSpec().rows().unboundedPreceding(),\n                \"ROWS UNBOUNDED PRECEDING\");\n        winqEqual(new FrameSpec().range().preceding(1),\n                \"RANGE 1 PRECEDING\");\n        winqEqual(new FrameSpec().range().currentRow(),\n                \"RANGE CURRENT ROW\");\n        winqEqual(new FrameSpec().range().betweenUnboundedPreceding().andPreceding(2),\n                \"RANGE BETWEEN UNBOUNDED PRECEDING AND 2 PRECEDING\");\n        winqEqual(new FrameSpec().range().betweenPreceding(1).andPreceding(2),\n                \"RANGE BETWEEN 1 PRECEDING AND 2 PRECEDING\");\n        winqEqual(new FrameSpec().range().betweenCurrentRow().andPreceding(2),\n                \"RANGE BETWEEN CURRENT ROW AND 2 PRECEDING\");\n        winqEqual(new FrameSpec().range().betweenFollowing(1).andPreceding(2),\n                \"RANGE BETWEEN 1 FOLLOWING AND 2 PRECEDING\");\n        winqEqual(new FrameSpec().range().betweenUnboundedPreceding().andCurrentRow(),\n                \"RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW\");\n        winqEqual(new FrameSpec().range().betweenUnboundedPreceding().andFollowing(2),\n                \"RANGE BETWEEN UNBOUNDED PRECEDING AND 2 FOLLOWING\");\n        winqEqual(new FrameSpec().range().betweenUnboundedPreceding().andUnboundedFollowing(),\n                \"RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING\");\n    }\n}\n"
  },
  {
    "path": "src/java/test/src/androidTest/java/com/tencent/wcdbtest/winq/IndexedColumnTest.java",
    "content": "// Created by qiuwenchen on 2023/4/7.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdbtest.winq;\n\nimport androidx.test.ext.junit.runners.AndroidJUnit4;\n\nimport com.tencent.wcdb.winq.*;\n\nimport static com.tencent.wcdbtest.base.WinqTool.winqEqual;\n\nimport org.junit.Test;\nimport org.junit.runner.RunWith;\n\n@RunWith(AndroidJUnit4.class)\npublic class IndexedColumnTest {\n    @Test\n    public void test() {\n        Column column = new Column(\"testColumn\");\n        Expression expression = column.abs();\n\n        winqEqual(new IndexedColumn(column), \"testColumn\");\n        winqEqual(new IndexedColumn(column).order(Order.Asc), \"testColumn ASC\");\n        winqEqual(new IndexedColumn(expression), \"ABS(testColumn)\");\n        winqEqual(new IndexedColumn(expression).order(Order.Desc), \"ABS(testColumn) DESC\");\n        winqEqual(new IndexedColumn(expression).collate(\"BINARY\"), \"ABS(testColumn) COLLATE BINARY\");\n    }\n}\n"
  },
  {
    "path": "src/java/test/src/androidTest/java/com/tencent/wcdbtest/winq/JoinTest.java",
    "content": "// Created by qiuwenchen on 2023/6/9.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdbtest.winq;\n\nimport androidx.test.ext.junit.runners.AndroidJUnit4;\n\nimport static com.tencent.wcdbtest.base.WinqTool.winqEqual;\n\nimport com.tencent.wcdb.winq.Column;\nimport com.tencent.wcdb.winq.Join;\nimport com.tencent.wcdb.winq.StatementSelect;\n\nimport org.junit.Test;\nimport org.junit.runner.RunWith;\n\n@RunWith(AndroidJUnit4.class)\npublic class JoinTest {\n    @Test\n    public void test() {\n        winqEqual(new Join(\"testTable1\").join(\"testTable2\"),\n                \"testTable1 JOIN testTable2\");\n\n        winqEqual(new Join(select1()).join(select2()),\n                select1Sql() + \" JOIN \" + select2Sql());\n\n        winqEqual(new Join(\"testTable1\").with(\"testTable2\"),\n                \"testTable1, testTable2\");\n\n        winqEqual(new Join(select1()).with(select2()),\n                select1Sql() + \", \" + select2Sql());\n\n        winqEqual(new Join(\"testTable1\").leftJoin(\"testTable2\"),\n                \"testTable1 LEFT JOIN testTable2\");\n\n        winqEqual(new Join(select1()).leftJoin(select2()),\n                select1Sql() + \" LEFT JOIN \" + select2Sql());\n\n        winqEqual(new Join(\"testTable1\").leftOuterJoin(\"testTable2\"),\n                \"testTable1 LEFT OUTER JOIN testTable2\");\n\n        winqEqual(new Join(select1()).leftOuterJoin(select2()),\n                select1Sql() + \" LEFT OUTER JOIN \" + select2Sql());\n\n        winqEqual(new Join(\"testTable1\").innerJoin(\"testTable2\"),\n                \"testTable1 INNER JOIN testTable2\");\n\n        winqEqual(new Join(select1()).innerJoin(select2()),\n                select1Sql() + \" INNER JOIN \" + select2Sql());\n\n        winqEqual(new Join(\"testTable1\").crossJoin(\"testTable2\"),\n                \"testTable1 CROSS JOIN testTable2\");\n\n        winqEqual(new Join(select1()).crossJoin(select2()),\n                select1Sql() + \" CROSS JOIN \" + select2Sql());\n\n        winqEqual(new Join(\"testTable1\").naturalJoin(\"testTable2\"),\n                \"testTable1 NATURAL JOIN testTable2\");\n\n        winqEqual(new Join(select1()).naturalJoin(select2()),\n                select1Sql() + \" NATURAL JOIN \" + select2Sql());\n\n        winqEqual(new Join(\"testTable1\").naturalLeftJoin(\"testTable2\"),\n                \"testTable1 NATURAL LEFT JOIN testTable2\");\n\n        winqEqual(new Join(select1()).naturalLeftJoin(select2()),\n                select1Sql() + \" NATURAL LEFT JOIN \" + select2Sql());\n\n        winqEqual(new Join(\"testTable1\").naturalLeftOuterJoin(\"testTable2\"),\n                \"testTable1 NATURAL LEFT OUTER JOIN testTable2\");\n\n        winqEqual(new Join(select1()).naturalLeftOuterJoin(select2()),\n                select1Sql() + \" NATURAL LEFT OUTER JOIN \" + select2Sql());\n\n        winqEqual(new Join(\"testTable1\").naturalInnerJoin(\"testTable2\"),\n                \"testTable1 NATURAL INNER JOIN testTable2\");\n\n        winqEqual(new Join(select1()).naturalInnerJoin(select2()),\n                select1Sql() + \" NATURAL INNER JOIN \" + select2Sql());\n\n        winqEqual(new Join(\"testTable1\").naturalCrossJoin(\"testTable2\"),\n                \"testTable1 NATURAL CROSS JOIN testTable2\");\n\n        winqEqual(new Join(select1()).naturalCrossJoin(select2()),\n                select1Sql() + \" NATURAL CROSS JOIN \" + select2Sql());\n\n        winqEqual(new Join(\"testTable1\").join(\"testTable2\").on(new Column(\"column1\").eq(new Column(\"column2\"))),\n                \"testTable1 JOIN testTable2 ON column1 == column2\");\n\n        winqEqual(new Join(select1()).join(select2()).on(new Column(\"column1\").eq(new Column(\"column2\"))),\n                select1Sql() + \" JOIN \" + select2Sql() + \" ON column1 == column2\");\n\n        winqEqual(new Join(\"testTable1\").join(\"testTable2\").using(new Column(\"column1\"), new Column(\"column2\")),\n                \"testTable1 JOIN testTable2 USING(column1, column2)\");\n\n        winqEqual(new Join(select1()).join(select2()).using(new Column(\"column1\"), new Column(\"column2\")),\n                select1Sql() + \" JOIN \" + select2Sql() + \" USING(column1, column2)\");\n    }\n\n    StatementSelect select1() {\n        return new StatementSelect().select(new Column(\"column1\")).from(\"testTable1\");\n    }\n\n    String select1Sql() {\n        return \"(\" + select1().getDescription() + \")\";\n    }\n\n    StatementSelect select2() {\n        return new StatementSelect().select(new Column(\"column2\")).from(\"testTable2\");\n    }\n\n    String select2Sql() {\n        return \"(\" + select2().getDescription() + \")\";\n    }\n}\n"
  },
  {
    "path": "src/java/test/src/androidTest/java/com/tencent/wcdbtest/winq/LiteralValueTest.java",
    "content": "package com.tencent.wcdbtest.winq;\n\nimport androidx.test.ext.junit.runners.AndroidJUnit4;\n\nimport com.tencent.wcdb.winq.*;\n\nimport static com.tencent.wcdbtest.base.WinqTool.winqEqual;\n\nimport org.junit.Test;\nimport org.junit.runner.RunWith;\n\n@RunWith(AndroidJUnit4.class)\npublic class LiteralValueTest {\n    @Test\n    public void test() {\n        winqEqual(new LiteralValue(1), \"1\");\n        winqEqual(new LiteralValue(false), \"FALSE\");\n        winqEqual(new LiteralValue(true), \"TRUE\");\n        winqEqual(new LiteralValue(17626545782784L), \"17626545782784\");\n        winqEqual(new LiteralValue(-9223372036854775808L), \"-9223372036854775808\");\n        winqEqual(new LiteralValue(9223372036854775807L), \"9223372036854775807\");\n        winqEqual(new LiteralValue(0.1), \"0.10000000000000001\");\n        winqEqual(new LiteralValue(\"testContent\"), \"'testContent'\");\n        winqEqual(new LiteralValue(null), \"NULL\");\n        winqEqual(LiteralValue.currentDate(), \"CURRENT_DATE\");\n        winqEqual(LiteralValue.currentTimeStamp(), \"CURRENT_TIMESTAMP\");\n        winqEqual(LiteralValue.currentTime(), \"CURRENT_TIME\");\n    }\n}"
  },
  {
    "path": "src/java/test/src/androidTest/java/com/tencent/wcdbtest/winq/OrderingTermTest.java",
    "content": "// Created by chenqiuwen on 2023/4/7.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdbtest.winq;\n\nimport androidx.test.ext.junit.runners.AndroidJUnit4;\n\nimport com.tencent.wcdb.winq.*;\n\nimport static com.tencent.wcdbtest.base.WinqTool.winqEqual;\n\nimport org.junit.Test;\nimport org.junit.runner.RunWith;\n\n@RunWith(AndroidJUnit4.class)\npublic class OrderingTermTest {\n    @Test\n    public void test() {\n        Column column = new Column(\"testColumn\");\n        winqEqual(new OrderingTerm(column), \"testColumn\");\n        winqEqual(new OrderingTerm(column).collate(\"BINARY\"),\n                \"testColumn COLLATE BINARY\");\n        winqEqual(new OrderingTerm(column).order(Order.Asc), \"testColumn ASC\");\n        winqEqual(new OrderingTerm(column).order(Order.Desc), \"testColumn DESC\");\n    }\n}\n"
  },
  {
    "path": "src/java/test/src/androidTest/java/com/tencent/wcdbtest/winq/PragmaTest.java",
    "content": "// Created by chenqiuwen on 2023/4/9.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdbtest.winq;\n\nimport androidx.test.ext.junit.runners.AndroidJUnit4;\n\nimport com.tencent.wcdb.winq.*;\n\nimport static com.tencent.wcdbtest.base.WinqTool.winqEqual;\n\nimport org.junit.Test;\nimport org.junit.runner.RunWith;\n\n@RunWith(AndroidJUnit4.class)\npublic class PragmaTest {\n    @Test\n    public void test() {\n        winqEqual(new Pragma(\"testPragma\"), \"testPragma\");\n        winqEqual(Pragma.applicationId, \"application_id\");\n        winqEqual(Pragma.autoVacuum, \"auto_vacuum\");\n        winqEqual(Pragma.automaticIndex, \"automatic_index\");\n        winqEqual(Pragma.busyTimeout, \"busy_timeout\");\n        winqEqual(Pragma.cacheSize, \"cache_size\");\n        winqEqual(Pragma.cacheSpill, \"cache_spill\");\n        winqEqual(Pragma.caseSensitiveLike, \"case_sensitive_like\");\n        winqEqual(Pragma.cellSizeCheck, \"cell_size_check\");\n        winqEqual(Pragma.checkpointFullfsync, \"checkpoint_fullfsync\");\n        winqEqual(Pragma.cipher, \"cipher\");\n        winqEqual(Pragma.cipherAddRandom, \"cipher_add_random\");\n        winqEqual(Pragma.cipherDefaultKdfIter, \"cipher_default_kdf_iter\");\n        winqEqual(Pragma.cipherDefaultPageSize, \"cipher_default_page_size\");\n        winqEqual(Pragma.cipherDefaultUseHmac, \"cipher_default_use_hmac\");\n        winqEqual(Pragma.cipherMigrate, \"cipher_migrate\");\n        winqEqual(Pragma.cipherProfile, \"cipher_profile\");\n        winqEqual(Pragma.cipherProvider, \"cipher_provider\");\n        winqEqual(Pragma.cipherProviderVersion, \"cipher_provider_version\");\n        winqEqual(Pragma.cipherUseHmac, \"cipher_use_hmac\");\n        winqEqual(Pragma.cipherVersion, \"cipher_version\");\n        winqEqual(Pragma.cipherPageSize, \"cipher_page_size\");\n        winqEqual(Pragma.collationList, \"collation_list\");\n        winqEqual(Pragma.dataVersion, \"data_version\");\n        winqEqual(Pragma.databaseList, \"database_list\");\n        winqEqual(Pragma.deferForeignKeys, \"defer_foreign_keys\");\n        winqEqual(Pragma.encoding, \"encoding\");\n        winqEqual(Pragma.foreignKeyCheck, \"foreign_key_check\");\n        winqEqual(Pragma.foreignKeyList, \"foreign_key_list\");\n        winqEqual(Pragma.foreignKeys, \"foreign_keys\");\n        winqEqual(Pragma.freelistCount, \"freelist_count\");\n        winqEqual(Pragma.fullfsync, \"fullfsync\");\n        winqEqual(Pragma.functionList, \"function_list\");\n        winqEqual(Pragma.ignoreCheckConstraints, \"ignore_check_constraints\");\n        winqEqual(Pragma.incrementalVacuum, \"incremental_vacuum\");\n        winqEqual(Pragma.indexInfo, \"index_info\");\n        winqEqual(Pragma.indexList, \"index_list\");\n        winqEqual(Pragma.indexXinfo, \"index_xinfo\");\n        winqEqual(Pragma.integrityCheck, \"integrity_check\");\n        winqEqual(Pragma.journalMode, \"journal_mode\");\n        winqEqual(Pragma.journalSizeLimit, \"journal_size_limit\");\n        winqEqual(Pragma.key, \"key\");\n        winqEqual(Pragma.kdfIter, \"kdf_iter\");\n        winqEqual(Pragma.legacyFileFormat, \"legacy_file_format\");\n        winqEqual(Pragma.lockingMode, \"locking_mode\");\n        winqEqual(Pragma.maxPageCount, \"max_page_count\");\n        winqEqual(Pragma.mmapSize, \"mmap_size\");\n        winqEqual(Pragma.moduleList, \"module_list\");\n        winqEqual(Pragma.optimize, \"optimize\");\n        winqEqual(Pragma.pageCount, \"page_count\");\n        winqEqual(Pragma.pageSize, \"page_size\");\n        winqEqual(Pragma.parserTrace, \"parser_trace\");\n        winqEqual(Pragma.pragmaList, \"pragma_list\");\n        winqEqual(Pragma.queryOnly, \"query_only\");\n        winqEqual(Pragma.quickCheck, \"quick_check\");\n        winqEqual(Pragma.readUncommitted, \"read_uncommitted\");\n        winqEqual(Pragma.recursiveTriggers, \"recursive_triggers\");\n        winqEqual(Pragma.rekey, \"rekey\");\n        winqEqual(Pragma.reverseUnorderedSelects, \"reverse_unordered_selects\");\n        winqEqual(Pragma.schemaVersion, \"schema_version\");\n        winqEqual(Pragma.secureDelete, \"secure_delete\");\n        winqEqual(Pragma.shrinkMemory, \"shrink_memory\");\n        winqEqual(Pragma.softHeapLimit, \"soft_heap_limit\");\n        winqEqual(Pragma.stats, \"stats\");\n        winqEqual(Pragma.synchronous, \"synchronous\");\n        winqEqual(Pragma.tableInfo, \"table_info\");\n        winqEqual(Pragma.tempStore, \"temp_store\");\n        winqEqual(Pragma.threads, \"threads\");\n        winqEqual(Pragma.userVersion, \"user_version\");\n        winqEqual(Pragma.vdbeAddoptrace, \"vdbe_addoptrace\");\n        winqEqual(Pragma.vdbeDebug, \"vdbe_debug\");\n        winqEqual(Pragma.vdbeListing, \"vdbe_listing\");\n        winqEqual(Pragma.vdbeTrace, \"vdbe_trace\");\n        winqEqual(Pragma.walAutocheckpoint, \"wal_autocheckpoint\");\n        winqEqual(Pragma.walCheckpoint, \"wal_checkpoint\");\n        winqEqual(Pragma.writableSchema, \"writable_schema\");\n    }\n}\n"
  },
  {
    "path": "src/java/test/src/androidTest/java/com/tencent/wcdbtest/winq/QualifiedTableTest.java",
    "content": "// Created by chenqiuwen on 2023/4/8.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdbtest.winq;\n\nimport com.tencent.wcdb.winq.*;\n\nimport androidx.test.ext.junit.runners.AndroidJUnit4;\n\nimport static com.tencent.wcdbtest.base.WinqTool.winqEqual;\n\nimport org.junit.Test;\nimport org.junit.runner.RunWith;\n\n@RunWith(AndroidJUnit4.class)\npublic class QualifiedTableTest {\n    @Test\n    public void test() {\n        winqEqual(new QualifiedTable(\"testTable\"), \"testTable\");\n        winqEqual(new QualifiedTable(\"testTable\").of(\"testSchema\"), \"testSchema.testTable\");\n        winqEqual(new QualifiedTable(\"testTable\").of(new Schema(\"testSchema\")).as(\"testAlias\"),\n                \"testSchema.testTable AS testAlias\");\n        winqEqual(new QualifiedTable(\"testTable\").indexed(\"testIndex\"), \"testTable INDEXED BY testIndex\");\n        winqEqual(new QualifiedTable(\"testTable\").notIndexed(), \"testTable NOT INDEXED\");\n    }\n}\n"
  },
  {
    "path": "src/java/test/src/androidTest/java/com/tencent/wcdbtest/winq/RaiseFunctionTest.java",
    "content": "// Created by qiuwenchen on 2023/6/9.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdbtest.winq;\n\nimport androidx.test.ext.junit.runners.AndroidJUnit4;\n\nimport static com.tencent.wcdbtest.base.WinqTool.winqEqual;\n\nimport com.tencent.wcdb.winq.RaiseFunction;\nimport com.tencent.wcdb.winq.StatementSelect;\n\nimport org.junit.Test;\nimport org.junit.runner.RunWith;\n\n@RunWith(AndroidJUnit4.class)\npublic class RaiseFunctionTest {\n    @Test\n    public void test() {\n        winqEqual(new RaiseFunction().ignore(), \"RAISE(IGNORE)\");\n        winqEqual(new RaiseFunction().rollback(\"testErrorMessage\"),\n                \"RAISE(ROLLBACK, testErrorMessage)\");\n        winqEqual(new RaiseFunction().abort(\"testErrorMessage\"),\n                \"RAISE(ABORT, testErrorMessage)\");\n        winqEqual(new RaiseFunction().fail(\"testErrorMessage\"),\n                \"RAISE(FAIL, testErrorMessage)\");\n        winqEqual(new StatementSelect().select(new RaiseFunction().ignore()),\n                \"SELECT RAISE(IGNORE)\");\n    }\n}\n"
  },
  {
    "path": "src/java/test/src/androidTest/java/com/tencent/wcdbtest/winq/ResultColumnTest.java",
    "content": "// Created by chenqiuwen on 2023/4/8.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdbtest.winq;\n\nimport androidx.test.ext.junit.runners.AndroidJUnit4;\n\nimport com.tencent.wcdb.winq.*;\n\nimport static com.tencent.wcdbtest.base.WinqTool.winqEqual;\n\nimport org.junit.Test;\nimport org.junit.runner.RunWith;\n\n@RunWith(AndroidJUnit4.class)\npublic class ResultColumnTest {\n    @Test\n    public void test() {\n        winqEqual(new ResultColumn(\"testColumn\"), \"testColumn\");\n        winqEqual(new ResultColumn(new Column(\"testColumn\")), \"testColumn\");\n        winqEqual(new ResultColumn(new Column(\"testColumn\")).as(\"testColumn2\"),\n                \"testColumn AS testColumn2\");\n        winqEqual(new ResultColumn(new Column(\"testColumn\").sum()).as(\"sum\"),\n                \"SUM(testColumn) AS sum\");\n    }\n}\n"
  },
  {
    "path": "src/java/test/src/androidTest/java/com/tencent/wcdbtest/winq/SchemaTest.java",
    "content": "// Created by qiuwenchen on 2023/3/31.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage com.tencent.wcdbtest.winq;\n\nimport androidx.test.ext.junit.runners.AndroidJUnit4;\n\nimport com.tencent.wcdb.winq.*;\n\nimport static com.tencent.wcdbtest.base.WinqTool.winqEqual;\n\nimport org.junit.Test;\nimport org.junit.runner.RunWith;\n\n@RunWith(AndroidJUnit4.class)\npublic class SchemaTest {\n    @Test\n    public void test() {\n        winqEqual(Schema.main, \"main\");\n        winqEqual(Schema.temp, \"temp\");\n        winqEqual(new Schema(\"testSchema\"), \"testSchema\");\n    }\n}\n"
  },
  {
    "path": "src/java/test/src/androidTest/java/com/tencent/wcdbtest/winq/StatementAlterTableTest.java",
    "content": "// Created by chenqiuwen on 2023/6/11.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdbtest.winq;\n\nimport androidx.test.ext.junit.runners.AndroidJUnit4;\n\nimport static com.tencent.wcdbtest.base.WinqTool.winqEqual;\n\nimport com.tencent.wcdb.winq.Column;\nimport com.tencent.wcdb.winq.ColumnDef;\nimport com.tencent.wcdb.winq.ColumnType;\nimport com.tencent.wcdb.winq.StatementAlterTable;\n\nimport org.junit.Test;\nimport org.junit.runner.RunWith;\n\n@RunWith(AndroidJUnit4.class)\npublic class StatementAlterTableTest {\n    @Test\n    public void test() {\n        winqEqual(new StatementAlterTable().alterTable(\"table1\").renameTo(\"table2\"),\n                \"ALTER TABLE table1 RENAME TO table2\");\n        winqEqual(new StatementAlterTable().alterTable(\"table1\")\n                        .of(\"testSchema\").renameTo(\"table2\"),\n                \"ALTER TABLE testSchema.table1 RENAME TO table2\");\n        winqEqual(new StatementAlterTable().alterTable(\"table1\")\n                        .addColumn(new Column(\"column1\").asDef(ColumnType.Float)),\n                \"ALTER TABLE table1 ADD COLUMN column1 REAL\");\n        winqEqual(new StatementAlterTable().alterTable(\"table1\")\n                        .renameColumn(\"column1\").toColumn(\"column2\"),\n                \"ALTER TABLE table1 RENAME COLUMN column1 TO column2\");\n        winqEqual(new StatementAlterTable().alterTable(\"table1\")\n                        .renameColumn(new Column(\"column1\")).toColumn(new Column(\"column2\")),\n                \"ALTER TABLE table1 RENAME COLUMN column1 TO column2\");\n    }\n}\n"
  },
  {
    "path": "src/java/test/src/androidTest/java/com/tencent/wcdbtest/winq/StatementAnalyzeTest.java",
    "content": "// Created by chenqiuwen on 2023/6/11.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdbtest.winq;\n\nimport androidx.test.ext.junit.runners.AndroidJUnit4;\n\nimport static com.tencent.wcdbtest.base.WinqTool.winqEqual;\n\nimport com.tencent.wcdb.winq.StatementAnalyze;\n\nimport org.junit.Test;\nimport org.junit.runner.RunWith;\n\n@RunWith(AndroidJUnit4.class)\npublic class StatementAnalyzeTest {\n    @Test\n    public void test() {\n        winqEqual(new StatementAnalyze().analyze(), \"ANALYZE\");\n        winqEqual(new StatementAnalyze().analyze().schema(\"testSchema\"),\n                \"ANALYZE testSchema\");\n        winqEqual(new StatementAnalyze().analyze().schema(\"testSchema\").table(\"testTable\"),\n                \"ANALYZE testSchema.testTable\");\n        winqEqual(new StatementAnalyze().analyze().table(\"testTable\"),\n                \"ANALYZE testTable\");\n        winqEqual(new StatementAnalyze().analyze().schema(\"testSchema\").index(\"testIndex\"),\n                \"ANALYZE testSchema.testIndex\");\n    }\n}\n"
  },
  {
    "path": "src/java/test/src/androidTest/java/com/tencent/wcdbtest/winq/StatementAttachTest.java",
    "content": "// Created by chenqiuwen on 2023/6/11.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdbtest.winq;\n\nimport androidx.test.ext.junit.runners.AndroidJUnit4;\n\nimport static com.tencent.wcdbtest.base.WinqTool.winqEqual;\n\nimport com.tencent.wcdb.winq.BindParameter;\nimport com.tencent.wcdb.winq.StatementAttach;\n\nimport org.junit.Test;\nimport org.junit.runner.RunWith;\n\n@RunWith(AndroidJUnit4.class)\npublic class StatementAttachTest {\n    @Test\n    public void test() {\n        winqEqual(new StatementAttach().attach(\"testPath\").as(\"testSchema\"),\n                \"ATTACH 'testPath' AS testSchema\");\n        winqEqual(new StatementAttach().attach(new BindParameter(1)).as(\"testSchema\"),\n                \"ATTACH ?1 AS testSchema\");\n        winqEqual(new StatementAttach().attach(\"testPath\").as(\"testSchema\").key(\"testKey\"),\n                \"ATTACH 'testPath' AS testSchema KEY 'testKey'\");\n        winqEqual(new StatementAttach().attach(new BindParameter(1)).as(\"testSchema\").key(new BindParameter(2)),\n                \"ATTACH ?1 AS testSchema KEY ?2\");\n    }\n}\n"
  },
  {
    "path": "src/java/test/src/androidTest/java/com/tencent/wcdbtest/winq/StatementBeginTest.java",
    "content": "// Created by chenqiuwen on 2023/4/9.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage com.tencent.wcdbtest.winq;\n\nimport androidx.test.ext.junit.runners.AndroidJUnit4;\n\nimport com.tencent.wcdb.winq.*;\n\nimport static com.tencent.wcdbtest.base.WinqTool.winqEqual;\n\nimport org.junit.Test;\nimport org.junit.runner.RunWith;\n\n@RunWith(AndroidJUnit4.class)\npublic class StatementBeginTest {\n    @Test\n    public void test() {\n        winqEqual(new StatementBegin(), \"BEGIN DEFERRED\");\n        winqEqual(StatementBegin.beginDeferred(), \"BEGIN DEFERRED\");\n        winqEqual(StatementBegin.beginImmediate(), \"BEGIN IMMEDIATE\");\n        winqEqual(StatementBegin.beginExclusive(), \"BEGIN EXCLUSIVE\");\n    }\n}\n"
  },
  {
    "path": "src/java/test/src/androidTest/java/com/tencent/wcdbtest/winq/StatementCommitTest.java",
    "content": "//\n// Created by chenqiuwen on 2023/4/9.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdbtest.winq;\n\nimport static com.tencent.wcdbtest.base.WinqTool.winqEqual;\n\nimport androidx.test.ext.junit.runners.AndroidJUnit4;\n\nimport com.tencent.wcdb.winq.*;\n\nimport org.junit.Test;\nimport org.junit.runner.RunWith;\n\n@RunWith(AndroidJUnit4.class)\npublic class StatementCommitTest {\n    @Test\n    public void test() {\n        winqEqual(new StatementCommit(), \"COMMIT\");\n    }\n}\n"
  },
  {
    "path": "src/java/test/src/androidTest/java/com/tencent/wcdbtest/winq/StatementCreateIndexTest.java",
    "content": "// Created by chenqiuwen on 2023/4/10.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdbtest.winq;\n\nimport androidx.test.ext.junit.runners.AndroidJUnit4;\n\nimport com.tencent.wcdb.winq.*;\n\nimport static com.tencent.wcdbtest.base.WinqTool.winqEqual;\n\nimport org.junit.Test;\nimport org.junit.runner.RunWith;\n\n@RunWith(AndroidJUnit4.class)\npublic class StatementCreateIndexTest {\n    @Test\n    public void test() {\n        IndexedColumn index1 = new IndexedColumn(\"column1\");\n        IndexedColumn index2 = new IndexedColumn(\"column2\").order(Order.Asc);\n        String indexName = \"index1\";\n        String tableName = \"table1\";\n\n        winqEqual(new StatementCreateIndex().createIndex(indexName).on(tableName)\n                        .indexedBy(new IndexedColumn[]{index1, index2}),\n                \"CREATE INDEX index1 ON table1(column1, column2 ASC)\");\n\n        winqEqual(new StatementCreateIndex().createIndex(indexName).of(\"testSchema\").on(tableName)\n                        .indexedBy(new IndexedColumn[]{index1, index2}),\n                \"CREATE INDEX testSchema.index1 ON table1(column1, column2 ASC)\");\n\n        winqEqual(new StatementCreateIndex().createIndex(indexName).unique().on(tableName).indexedBy(index2),\n                \"CREATE UNIQUE INDEX index1 ON table1(column2 ASC)\");\n\n        winqEqual(new StatementCreateIndex().createIndex(indexName).ifNotExist().on(tableName).indexedBy(\"newColumn\"),\n                \"CREATE INDEX IF NOT EXISTS index1 ON table1(newColumn)\");\n\n        winqEqual(new StatementCreateIndex().createIndex(indexName).on(tableName)\n                        .indexedBy(\"column1\", \"column2\").where(new Column(\"column1\").ge(1)),\n                \"CREATE INDEX index1 ON table1(column1, column2) WHERE column1 >= 1\");\n    }\n}\n"
  },
  {
    "path": "src/java/test/src/androidTest/java/com/tencent/wcdbtest/winq/StatementCreateTableTest.java",
    "content": "// Created by qiuwenchen on 2023/4/11.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdbtest.winq;\n\nimport androidx.test.ext.junit.runners.AndroidJUnit4;\n\nimport com.tencent.wcdb.winq.*;\n\nimport static com.tencent.wcdbtest.base.WinqTool.winqEqual;\n\nimport org.junit.Test;\nimport org.junit.runner.RunWith;\n\n@RunWith(AndroidJUnit4.class)\npublic class StatementCreateTableTest {\n    @Test\n    public void test() {\n        Column column1 = new Column(\"column1\");\n        Column column2 = new Column(\"column2\");\n\n        ColumnDef def1 = column1.asDef(ColumnType.Integer);\n        ColumnDef def2 = column2.asDef(ColumnType.Text);\n\n        TableConstraint constraint1 = new TableConstraint(\"constraint1\").primaryKey().indexedBy(column1);\n        TableConstraint constraint2 = new TableConstraint(\"constraint2\").unique().indexedBy(column2);\n\n        String table1 = \"table1\";\n\n        winqEqual(new StatementCreateTable().createTable(table1).define(def1, def2),\n                \"CREATE TABLE table1(column1 INTEGER, column2 TEXT)\");\n\n        winqEqual(new StatementCreateTable().createTempTable(table1).define(def1, def2),\n                \"CREATE TEMP TABLE table1(column1 INTEGER, column2 TEXT)\");\n\n        winqEqual(new StatementCreateTable().createTable(table1).define(def1, def2).withoutRowid(),\n                \"CREATE TABLE table1(column1 INTEGER, column2 TEXT) WITHOUT ROWID\");\n\n        winqEqual(new StatementCreateTable().createTable(table1).of(\"testSchema\").define(def1, def2),\n                \"CREATE TABLE testSchema.table1(column1 INTEGER, column2 TEXT)\");\n\n        winqEqual(new StatementCreateTable().createTable(table1).ifNotExist().define(def1, def2),\n                \"CREATE TABLE IF NOT EXISTS table1(column1 INTEGER, column2 TEXT)\");\n\n        winqEqual(new StatementCreateTable().createTable(table1).define(def1, def2)\n                        .constraint(constraint1, constraint2),\n                \"CREATE TABLE table1(column1 INTEGER, column2 TEXT, \" +\n                        \"CONSTRAINT constraint1 PRIMARY KEY(column1), \" +\n                        \"CONSTRAINT constraint2 UNIQUE(column2))\");\n    }\n}\n"
  },
  {
    "path": "src/java/test/src/androidTest/java/com/tencent/wcdbtest/winq/StatementCreateTriggerTest.java",
    "content": "// Created by chenqiuwen on 2023/6/11.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdbtest.winq;\n\nimport androidx.test.ext.junit.runners.AndroidJUnit4;\n\nimport static com.tencent.wcdbtest.base.WinqTool.winqEqual;\n\nimport com.tencent.wcdb.chaincall.Insert;\nimport com.tencent.wcdb.winq.Column;\nimport com.tencent.wcdb.winq.Expression;\nimport com.tencent.wcdb.winq.StatementCreateTrigger;\nimport com.tencent.wcdb.winq.StatementDelete;\nimport com.tencent.wcdb.winq.StatementInsert;\nimport com.tencent.wcdb.winq.StatementSelect;\nimport com.tencent.wcdb.winq.StatementUpdate;\n\nimport org.junit.Test;\nimport org.junit.runner.RunWith;\n\n@RunWith(AndroidJUnit4.class)\npublic class StatementCreateTriggerTest {\n    @Test\n    public void test() {\n        String schema = \"testSchema\";\n        String name = \"testTrigger\";\n        Column column1 = new Column(\"column1\");\n        Column column2 = new Column(\"column2\");\n        String table = \"testTable\";\n        Expression condition = column1.eq(1);\n        StatementUpdate update = new StatementUpdate().update(table).set(column1).to(2);\n        StatementInsert insert = new StatementInsert().insertInto(table).values(1);\n        StatementSelect select = new StatementSelect().select(column1);\n        StatementDelete delete = new StatementDelete().deleteFrom(table);\n\n        winqEqual(new StatementCreateTrigger().createTrigger(name).ofSchema(schema)\n                        .before().delete().onTable(table).forEachRow().when(condition).execute(update),\n                \"CREATE TRIGGER testSchema.testTrigger BEFORE DELETE ON testTable FOR EACH ROW WHEN column1 == 1 \" +\n                        \"BEGIN UPDATE testTable SET column1 = 2; END\");\n\n        winqEqual(new StatementCreateTrigger().createTempTrigger(name)\n                        .before().delete().onTable(table).forEachRow().when(condition).execute(update),\n                \"CREATE TEMP TRIGGER testTrigger BEFORE DELETE ON testTable FOR EACH ROW WHEN column1 == 1 \" +\n                        \"BEGIN UPDATE testTable SET column1 = 2; END\");\n\n        winqEqual(new StatementCreateTrigger().createTrigger(name).ofSchema(schema).ifNotExist()\n                        .before().delete().onTable(table).forEachRow().when(condition).execute(update),\n                \"CREATE TRIGGER IF NOT EXISTS testSchema.testTrigger BEFORE DELETE ON testTable FOR EACH ROW WHEN column1 == 1 \" +\n                        \"BEGIN UPDATE testTable SET column1 = 2; END\");\n\n        winqEqual(new StatementCreateTrigger().createTrigger(name)\n                        .before().delete().onTable(table).forEachRow().when(condition).execute(update),\n                \"CREATE TRIGGER testTrigger BEFORE DELETE ON testTable FOR EACH ROW WHEN column1 == 1 \" +\n                        \"BEGIN UPDATE testTable SET column1 = 2; END\");\n\n        winqEqual(new StatementCreateTrigger().createTrigger(name).ofSchema(schema)\n                        .after().delete().onTable(table).forEachRow().when(condition).execute(update),\n                \"CREATE TRIGGER testSchema.testTrigger AFTER DELETE ON testTable FOR EACH ROW WHEN column1 == 1 \" +\n                        \"BEGIN UPDATE testTable SET column1 = 2; END\");\n\n        winqEqual(new StatementCreateTrigger().createTrigger(name).ofSchema(schema)\n                        .insteadOf().delete().onTable(table).forEachRow().when(condition).execute(update),\n                \"CREATE TRIGGER testSchema.testTrigger INSTEAD OF DELETE ON testTable FOR EACH ROW WHEN column1 == 1 \" +\n                        \"BEGIN UPDATE testTable SET column1 = 2; END\");\n\n        winqEqual(new StatementCreateTrigger().createTrigger(name).ofSchema(schema)\n                        .before().insert().onTable(table).forEachRow().when(condition).execute(update),\n                \"CREATE TRIGGER testSchema.testTrigger BEFORE INSERT ON testTable FOR EACH ROW WHEN column1 == 1 \" +\n                        \"BEGIN UPDATE testTable SET column1 = 2; END\");\n\n        winqEqual(new StatementCreateTrigger().createTrigger(name).ofSchema(schema)\n                        .before().update().onTable(table).forEachRow().when(condition).execute(update),\n                \"CREATE TRIGGER testSchema.testTrigger BEFORE UPDATE ON testTable FOR EACH ROW WHEN column1 == 1 \" +\n                        \"BEGIN UPDATE testTable SET column1 = 2; END\");\n\n        winqEqual(new StatementCreateTrigger().createTrigger(name).ofSchema(schema)\n                        .before().update().ofColumns(column1).onTable(table).execute(update),\n                \"CREATE TRIGGER testSchema.testTrigger BEFORE UPDATE OF column1 ON testTable \" +\n                        \"BEGIN UPDATE testTable SET column1 = 2; END\");\n\n        winqEqual(new StatementCreateTrigger().createTrigger(name).ofSchema(schema)\n                        .before().update().ofColumns(\"column1\").onTable(table).execute(update),\n                \"CREATE TRIGGER testSchema.testTrigger BEFORE UPDATE OF column1 ON testTable \" +\n                        \"BEGIN UPDATE testTable SET column1 = 2; END\");\n\n        winqEqual(new StatementCreateTrigger().createTrigger(name).ofSchema(schema)\n                        .before().update().ofColumns(column1, column2).onTable(table).execute(update),\n                \"CREATE TRIGGER testSchema.testTrigger BEFORE UPDATE OF column1, column2 ON testTable \" +\n                        \"BEGIN UPDATE testTable SET column1 = 2; END\");\n\n        winqEqual(new StatementCreateTrigger().createTrigger(name).ofSchema(schema)\n                        .before().update().ofColumns(\"column1\", \"column2\").onTable(table).execute(update),\n                \"CREATE TRIGGER testSchema.testTrigger BEFORE UPDATE OF column1, column2 ON testTable \" +\n                        \"BEGIN UPDATE testTable SET column1 = 2; END\");\n\n        winqEqual(new StatementCreateTrigger().createTrigger(name).ofSchema(schema)\n                        .before().delete().onTable(table).forEachRow().when(condition).execute(insert),\n                \"CREATE TRIGGER testSchema.testTrigger BEFORE DELETE ON testTable FOR EACH ROW WHEN column1 == 1 \" +\n                        \"BEGIN INSERT INTO testTable VALUES(1); END\");\n\n        winqEqual(new StatementCreateTrigger().createTrigger(name).ofSchema(schema)\n                        .before().delete().onTable(table).forEachRow().when(condition).execute(delete),\n                \"CREATE TRIGGER testSchema.testTrigger BEFORE DELETE ON testTable FOR EACH ROW WHEN column1 == 1 \" +\n                        \"BEGIN DELETE FROM testTable; END\");\n\n        winqEqual(new StatementCreateTrigger().createTrigger(name).ofSchema(schema)\n                        .before().delete().onTable(table).forEachRow().when(condition).execute(select),\n                \"CREATE TRIGGER testSchema.testTrigger BEFORE DELETE ON testTable FOR EACH ROW WHEN column1 == 1 \" +\n                        \"BEGIN SELECT column1; END\");\n\n        winqEqual(new StatementCreateTrigger().createTrigger(name).ofSchema(schema)\n                        .before().delete().onTable(table).forEachRow().when(condition)\n                        .execute(update).execute(insert).execute(delete).execute(select),\n                \"CREATE TRIGGER testSchema.testTrigger BEFORE DELETE ON testTable FOR EACH ROW WHEN column1 == 1 \" +\n                        \"BEGIN UPDATE testTable SET column1 = 2; INSERT INTO testTable VALUES(1); DELETE FROM testTable; SELECT column1; END\");\n    }\n}\n"
  },
  {
    "path": "src/java/test/src/androidTest/java/com/tencent/wcdbtest/winq/StatementCreateViewTest.java",
    "content": "// Created by chenqiuwen on 2023/6/11.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdbtest.winq;\n\nimport static com.tencent.wcdbtest.base.WinqTool.winqEqual;\n\nimport com.tencent.wcdb.winq.Column;\nimport com.tencent.wcdb.winq.ResultColumnConvertible;\nimport com.tencent.wcdb.winq.StatementCreateView;\nimport com.tencent.wcdb.winq.StatementSelect;\n\nimport org.junit.Test;\n\npublic class StatementCreateViewTest {\n    @Test\n    public void test() {\n        Column column1 = new Column(\"column1\");\n        Column column2 = new Column(\"column2\");\n        StatementSelect select = new StatementSelect().select(column1, column2).from(\"testTable\");\n        String view = \"testView\";\n\n        winqEqual(new StatementCreateView().createView(\"testView\").withColumns(new Column[]{column1, column2}).as(select),\n                \"CREATE VIEW testView(column1, column2) AS SELECT column1, column2 FROM testTable\");\n\n        winqEqual(new StatementCreateView().createTempView(\"testView\").withColumns(new Column[]{column1, column2}).as(select),\n                \"CREATE TEMP VIEW testView(column1, column2) AS SELECT column1, column2 FROM testTable\");\n\n        winqEqual(new StatementCreateView().createView(\"testView\").of(\"testSchema\").withColumns(new Column[]{column1, column2}).as(select),\n                \"CREATE VIEW testSchema.testView(column1, column2) AS SELECT column1, column2 FROM testTable\");\n\n        winqEqual(new StatementCreateView().createView(\"testView\").ifNotExist().withColumns(new Column[]{column1, column2}).as(select),\n                \"CREATE VIEW IF NOT EXISTS testView(column1, column2) AS SELECT column1, column2 FROM testTable\");\n    }\n}\n"
  },
  {
    "path": "src/java/test/src/androidTest/java/com/tencent/wcdbtest/winq/StatementCreateVirtualTableTest.java",
    "content": "// Created by chenqiuwen on 2023/11/4.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdbtest.winq;\n\nimport static com.tencent.wcdbtest.base.WinqTool.winqEqual;\n\nimport com.tencent.wcdb.winq.StatementCreateVirtualTable;\n\nimport org.junit.Test;\n\npublic class StatementCreateVirtualTableTest {\n    @Test\n    public void test() {\n        String virtualTable1 = \"virtualTable1\";\n        String tokenizer = \"tokenize=WCDB\";\n        String virtualTable2 = \"virtualTable2\";\n        String module = \"testModule\";\n        String argument = \"left=right\";\n        winqEqual(new StatementCreateVirtualTable().createVirtualTable(virtualTable1).ifNotExist().usingModule(\"fts3\").arguments(tokenizer),\n                \"CREATE VIRTUAL TABLE IF NOT EXISTS virtualTable1 USING fts3(tokenize=WCDB)\");\n        winqEqual(new StatementCreateVirtualTable().createVirtualTable(virtualTable2).usingModule(module).arguments(argument),\n                \"CREATE VIRTUAL TABLE virtualTable2 USING testModule(left=right)\");\n    }\n}\n"
  },
  {
    "path": "src/java/test/src/androidTest/java/com/tencent/wcdbtest/winq/StatementDeleteTest.java",
    "content": "// Created by chenqiuwen on 2023/4/11.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdbtest.winq;\n\nimport androidx.test.ext.junit.runners.AndroidJUnit4;\n\nimport com.tencent.wcdb.winq.*;\n\nimport static com.tencent.wcdbtest.base.WinqTool.winqEqual;\n\nimport org.junit.Test;\nimport org.junit.runner.RunWith;\n\n@RunWith(AndroidJUnit4.class)\npublic class StatementDeleteTest {\n    @Test\n    public void test() {\n        Column column1 = new Column(\"column1\");\n        Column column2 = new Column(\"column2\");\n\n        winqEqual(genStatementDelete().where(column1.gt(1)),\n                \"DELETE FROM testTable WHERE column1 > 1\");\n\n        winqEqual(new StatementDelete().deleteFrom(new QualifiedTable(\"testTable\").of(\"testSchema\"))\n                        .where(column1.gt(1)),\n                \"DELETE FROM testSchema.testTable WHERE column1 > 1\");\n\n        winqEqual(genStatementDelete().orderBy(\n                        column1.order(Order.Asc), column2.order(Order.Desc)),\n                \"DELETE FROM testTable ORDER BY column1 ASC, column2 DESC\");\n\n        winqEqual(genStatementDelete().limit(1), \"DELETE FROM testTable LIMIT 1\");\n\n        winqEqual(genStatementDelete().limit(1, 2), \"DELETE FROM testTable LIMIT 1, 2\");\n\n        winqEqual(genStatementDelete().limit(1).offset(3), \"DELETE FROM testTable LIMIT 1 OFFSET 3\");\n\n        winqEqual(genStatementDelete().where(column1.gt(1))\n                        .orderBy(column1.order(Order.Asc), column2.order(Order.Desc))\n                        .limit(1).offset(2),\n                \"DELETE FROM testTable WHERE column1 > 1 ORDER BY column1 ASC, column2 DESC LIMIT 1 OFFSET 2\");\n\n        CommonTableExpression cte = new CommonTableExpression(\"tempTable\")\n                .as(new StatementSelect().select(\"testColumn\").from(\"table1\"));\n        winqEqual(new StatementDelete().with(cte).deleteFrom(\"table2\"),\n                \"WITH tempTable AS(SELECT testColumn FROM table1) DELETE FROM table2\");\n        winqEqual(new StatementDelete().withRecursive(cte).deleteFrom(\"table2\"),\n                \"WITH RECURSIVE tempTable AS(SELECT testColumn FROM table1) DELETE FROM table2\");\n    }\n\n    private StatementDelete genStatementDelete() {\n        return new StatementDelete().deleteFrom(\"testTable\");\n    }\n}\n"
  },
  {
    "path": "src/java/test/src/androidTest/java/com/tencent/wcdbtest/winq/StatementDetachTest.java",
    "content": "// Created by chenqiuwen on 2023/6/11.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdbtest.winq;\n\nimport androidx.test.ext.junit.runners.AndroidJUnit4;\n\nimport static com.tencent.wcdbtest.base.WinqTool.winqEqual;\n\nimport com.tencent.wcdb.winq.StatementDetach;\n\nimport org.junit.Test;\nimport org.junit.runner.RunWith;\n\n@RunWith(AndroidJUnit4.class)\npublic class StatementDetachTest {\n    @Test\n    public void test() {\n        winqEqual(new StatementDetach().detach(\"testSchema\"),\n                \"DETACH testSchema\");\n    }\n}\n"
  },
  {
    "path": "src/java/test/src/androidTest/java/com/tencent/wcdbtest/winq/StatementDropIndexTest.java",
    "content": "// Created by chenqiuwen on 2023/6/11.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdbtest.winq;\n\nimport org.junit.Test;\n\nimport static com.tencent.wcdbtest.base.WinqTool.winqEqual;\n\nimport com.tencent.wcdb.winq.StatementDropIndex;\n\npublic class StatementDropIndexTest {\n    @Test\n    public void test() {\n        winqEqual(new StatementDropIndex().dropIndex(\"testIndex\"),\n                \"DROP INDEX testIndex\");\n        winqEqual(new StatementDropIndex().dropIndex(\"testIndex\").ifExist(),\n                \"DROP INDEX IF EXISTS testIndex\");\n        winqEqual(new StatementDropIndex().dropIndex(\"testIndex\").of(\"testSchema\"),\n                \"DROP INDEX testSchema.testIndex\");\n    }\n}\n"
  },
  {
    "path": "src/java/test/src/androidTest/java/com/tencent/wcdbtest/winq/StatementDropTableTest.java",
    "content": "// Created by qiuwenchen on 2023/4/12.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdbtest.winq;\n\nimport androidx.test.ext.junit.runners.AndroidJUnit4;\n\nimport com.tencent.wcdb.winq.*;\n\nimport static com.tencent.wcdbtest.base.WinqTool.winqEqual;\n\nimport org.junit.Test;\nimport org.junit.runner.RunWith;\n\n@RunWith(AndroidJUnit4.class)\npublic class StatementDropTableTest {\n    @Test\n    public void test() {\n        winqEqual(new StatementDropTable().dropTable(\"testTable\"),\n                \"DROP TABLE testTable\");\n\n        winqEqual(new StatementDropTable().dropTable(\"testTable\").ifExist(),\n                \"DROP TABLE IF EXISTS testTable\");\n\n        winqEqual(new StatementDropTable().dropTable(\"testTable\").of(\"testSchema\"),\n                \"DROP TABLE testSchema.testTable\");\n\n    }\n}\n"
  },
  {
    "path": "src/java/test/src/androidTest/java/com/tencent/wcdbtest/winq/StatementDropTriggerTest.java",
    "content": "// Created by chenqiuwen on 2023/6/11.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdbtest.winq;\n\nimport org.junit.Test;\n\nimport static com.tencent.wcdbtest.base.WinqTool.winqEqual;\n\nimport com.tencent.wcdb.winq.StatementDropTrigger;\n\npublic class StatementDropTriggerTest {\n    @Test\n    public void test() {\n        winqEqual(new StatementDropTrigger().dropTrigger(\"testTrigger\"),\n                \"DROP TRIGGER testTrigger\");\n        winqEqual(new StatementDropTrigger().dropTrigger(\"testTrigger\").ifExist(),\n                \"DROP TRIGGER IF EXISTS testTrigger\");\n        winqEqual(new StatementDropTrigger().dropTrigger(\"testTrigger\").of(\"testSchema\"),\n                \"DROP TRIGGER testSchema.testTrigger\");\n    }\n}\n"
  },
  {
    "path": "src/java/test/src/androidTest/java/com/tencent/wcdbtest/winq/StatementDropViewTest.java",
    "content": "// Created by chenqiuwen on 2023/6/11.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdbtest.winq;\n\nimport org.junit.Test;\n\nimport static com.tencent.wcdbtest.base.WinqTool.winqEqual;\n\nimport com.tencent.wcdb.winq.StatementDropView;\n\npublic class StatementDropViewTest {\n    @Test\n    public void test() {\n        winqEqual(new StatementDropView().dropView(\"testView\"),\n                \"DROP VIEW testView\");\n        winqEqual(new StatementDropView().dropView(\"testView\").ifExist(),\n                \"DROP VIEW IF EXISTS testView\");\n        winqEqual(new StatementDropView().dropView(\"testView\").of(\"testSchema\"),\n                \"DROP VIEW testSchema.testView\");\n    }\n}\n"
  },
  {
    "path": "src/java/test/src/androidTest/java/com/tencent/wcdbtest/winq/StatementExplainTest.java",
    "content": "// Created by qiuwenchen on 2023/6/12.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdbtest.winq;\n\n\nimport com.tencent.wcdb.winq.StatementExplain;\nimport com.tencent.wcdb.winq.StatementSelect;\n\nimport static com.tencent.wcdbtest.base.WinqTool.winqEqual;\n\nimport org.junit.Test;\n\npublic class StatementExplainTest {\n    @Test\n    public void test() {\n        StatementSelect select = new StatementSelect().select(\"testColumn\").from(\"testTable\");\n        winqEqual(new StatementExplain().explain(select),\n                \"EXPLAIN SELECT testColumn FROM testTable\");\n        winqEqual(new StatementExplain().explainQueryPlan(select),\n                \"EXPLAIN QUERY PLAN SELECT testColumn FROM testTable\");\n    }\n}\n"
  },
  {
    "path": "src/java/test/src/androidTest/java/com/tencent/wcdbtest/winq/StatementInsertTest.java",
    "content": "// Created by chenqiuwen on 2023/4/12.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdbtest.winq;\n\nimport androidx.test.ext.junit.runners.AndroidJUnit4;\n\nimport com.tencent.wcdb.base.Value;\nimport com.tencent.wcdb.winq.*;\n\nimport static com.tencent.wcdbtest.base.WinqTool.winqEqual;\n\nimport org.junit.Test;\nimport org.junit.runner.RunWith;\n\n@RunWith(AndroidJUnit4.class)\npublic class StatementInsertTest {\n    @Test\n    public void test() {\n        Column column1 = new Column(\"column1\");\n        Column column2 = new Column(\"column2\");\n\n        winqEqual(new StatementInsert().insertInto(\"testTable\")\n                        .values(1, \"value\"),\n                \"INSERT INTO testTable VALUES(1, 'value')\");\n\n        winqEqual(new StatementInsert().insertInto(\"testTable\")\n                        .values(1, null),\n                \"INSERT INTO testTable VALUES(1, NULL)\");\n\n        winqEqual(new StatementInsert().insertInto(\"testTable\")\n                        .values(1, \"\"),\n                \"INSERT INTO testTable VALUES(1, '')\");\n\n        winqEqual(new StatementInsert().insertInto(\"testTable\")\n                        .values(null, true, 'a', 1, 1L, 1.1f, 1.1, \"value\", BindParameter._1),\n                \"INSERT INTO testTable VALUES(NULL, TRUE, 97, 1, 1, 1.1000000238418579, 1.1000000000000001, 'value', ?1)\");\n\n        winqEqual(new StatementInsert().insertInto(\"testTable\")\n                        .values(new Value(), new Value(1), new Value(1.1), new Value(\"value\")),\n                \"INSERT INTO testTable VALUES(NULL, 1, 1.1000000000000001, 'value')\");\n\n        winqEqual(new StatementInsert().insertInto(\"testTable\")\n                        .of(new Schema(\"testSchema\")).values(1, \"value\"),\n                \"INSERT INTO testSchema.testTable VALUES(1, 'value')\");\n\n        winqEqual(new StatementInsert().insertInto(\"testTable\").of(\"testSchema\")\n                        .as(\"newTable\").valuesWithBindParameters(2),\n                \"INSERT INTO testSchema.testTable AS newTable VALUES(?1, ?2)\");\n\n        winqEqual(new StatementInsert().insertInto(\"testTable\")\n                        .columns(column1, column2).values(1, 1.1f),\n                \"INSERT INTO testTable(column1, column2) VALUES(1, 1.1000000238418579)\");\n\n        winqEqual(new StatementInsert().insertInto(\"testTable\").orReplace()\n                        .values(1, new BindParameter(1)),\n                \"INSERT OR REPLACE INTO testTable VALUES(1, ?1)\");\n\n        CommonTableExpression cte = new CommonTableExpression(\"tempTable\")\n                .as(new StatementSelect().select(\"testColumn\").from(\"table1\"));\n        winqEqual(new StatementInsert().with(cte).insertInto(\"table2\")\n                        .columns(new Column(\"testColumn\")).values(1),\n                \"WITH tempTable AS(SELECT testColumn FROM table1) INSERT INTO table2(testColumn) VALUES(1)\");\n        winqEqual(new StatementInsert().withRecursive(cte).insertInto(\"table2\")\n                        .columns(new Column(\"testColumn\")).values(1),\n                \"WITH RECURSIVE tempTable AS(SELECT testColumn FROM table1) INSERT INTO table2(testColumn) VALUES(1)\");\n\n        winqEqual(new StatementInsert().insertInto(\"testTable\").columns(new Column(\"testColumn\")).defaultValues(),\n                \"INSERT INTO testTable(testColumn) DEFAULT VALUES\");\n\n        winqEqual(new StatementInsert().insertInto(\"testTable\").columns(new Column(\"testColumn\")).values(1)\n                        .upsert(new Upsert().onConflict().doNoThing()),\n                \"INSERT INTO testTable(testColumn) VALUES(1) ON CONFLICT DO NOTHING\");\n    }\n}\n"
  },
  {
    "path": "src/java/test/src/androidTest/java/com/tencent/wcdbtest/winq/StatementPragmaTest.java",
    "content": "// Created by qiuwenchen on 2023/4/13.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdbtest.winq;\n\nimport static com.tencent.wcdbtest.base.WinqTool.winqEqual;\n\nimport androidx.test.ext.junit.runners.AndroidJUnit4;\n\nimport com.tencent.wcdb.winq.*;\n\nimport org.junit.Test;\nimport org.junit.runner.RunWith;\n\n@RunWith(AndroidJUnit4.class)\npublic class StatementPragmaTest {\n    @Test\n    public void test() {\n        winqEqual(new StatementPragma().pragma(Pragma.secureDelete).toValue(\"\"),\n                \"PRAGMA secure_delete = ''\");\n        winqEqual(new StatementPragma().pragma(Pragma.pageSize), \"PRAGMA page_size\");\n        winqEqual(new StatementPragma().pragma(Pragma.secureDelete).toValue(true),\n                \"PRAGMA secure_delete = TRUE\");\n        winqEqual(new StatementPragma().pragma(Pragma.secureDelete).toValue(1),\n                \"PRAGMA secure_delete = 1\");\n        winqEqual(new StatementPragma().pragma(Pragma.secureDelete).toValue(\"abc\"),\n                \"PRAGMA secure_delete = 'abc'\");\n        winqEqual(new StatementPragma().pragma(Pragma.secureDelete).toValue(null),\n                \"PRAGMA secure_delete = NULL\");\n        winqEqual(new StatementPragma().of(\"testSchema\")\n                        .pragma(Pragma.tableInfo).withValue(\"testTable\"),\n                \"PRAGMA testSchema.table_info('testTable')\");\n    }\n}\n"
  },
  {
    "path": "src/java/test/src/androidTest/java/com/tencent/wcdbtest/winq/StatementReindexTest.java",
    "content": "// Created by qiuwenchen on 2023/6/12.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdbtest.winq;\n\nimport org.junit.Test;\n\nimport static com.tencent.wcdbtest.base.WinqTool.winqEqual;\n\nimport com.tencent.wcdb.winq.StatementReindex;\n\npublic class StatementReindexTest {\n    @Test\n    public void test() {\n        winqEqual(new StatementReindex().reindexTable(\"testTable\"),\n                \"REINDEX testTable\");\n        winqEqual(new StatementReindex().reindexTable(\"testTable\").of(\"testSchema\"),\n                \"REINDEX testSchema.testTable\");\n        winqEqual(new StatementReindex().reindex(\"testIndex\"),\n                \"REINDEX testIndex\");\n        winqEqual(new StatementReindex().reindexCollation(\"testCollation\"),\n                \"REINDEX testCollation\");\n    }\n}\n"
  },
  {
    "path": "src/java/test/src/androidTest/java/com/tencent/wcdbtest/winq/StatementReleaseTest.java",
    "content": "//\n// Created by qiuwenchen on 2023/6/12.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdbtest.winq;\n\nimport org.junit.Test;\n\nimport static com.tencent.wcdbtest.base.WinqTool.winqEqual;\n\nimport com.tencent.wcdb.winq.StatementRelease;\n\npublic class StatementReleaseTest {\n    @Test\n    public void test() {\n        winqEqual(new StatementRelease().release(\"testSavepoint\"),\n                \"RELEASE testSavepoint\");\n    }\n}\n"
  },
  {
    "path": "src/java/test/src/androidTest/java/com/tencent/wcdbtest/winq/StatementRollbackTest.java",
    "content": "//\n// Created by qiuwenchen on 2023/6/12.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdbtest.winq;\n\nimport org.junit.Test;\n\nimport static com.tencent.wcdbtest.base.WinqTool.winqEqual;\n\nimport com.tencent.wcdb.winq.StatementRollback;\n\npublic class StatementRollbackTest {\n    @Test\n    public void test() {\n        winqEqual(new StatementRollback(), \"ROLLBACK\");\n        winqEqual(new StatementRollback().rollbackTo(\"testSavepoint\"),\n                \"ROLLBACK TO testSavepoint\");\n    }\n}\n"
  },
  {
    "path": "src/java/test/src/androidTest/java/com/tencent/wcdbtest/winq/StatementSelectTest.java",
    "content": "// Created by qiuwenchen on 2023/4/13.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdbtest.winq;\n\nimport androidx.test.ext.junit.runners.AndroidJUnit4;\n\nimport com.tencent.wcdb.winq.*;\n\nimport static com.tencent.wcdbtest.base.WinqTool.winqEqual;\n\nimport org.junit.Test;\nimport org.junit.runner.RunWith;\n\n@RunWith(AndroidJUnit4.class)\npublic class StatementSelectTest {\n    @Test\n    public void test() {\n        Column column1 = new Column(\"column1\");\n        Column column2 = new Column(\"column2\");\n        String table1 = \"table1\";\n        String table2 = \"table2\";\n\n        winqEqual(new StatementSelect().select(column1).from(table1),\n                \"SELECT column1 FROM table1\");\n\n        winqEqual(new StatementSelect().select(new Column[]{column1, column2}).distinct().from(table1),\n                \"SELECT DISTINCT column1, column2 FROM table1\");\n\n        winqEqual(new StatementSelect().select(\"column1\", column2).distinct().from(table1),\n                \"SELECT DISTINCT column1, column2 FROM table1\");\n\n        winqEqual(new StatementSelect().select(\"column1\", \"column2\").distinct().from(table1),\n                \"SELECT DISTINCT column1, column2 FROM table1\");\n\n        winqEqual(new StatementSelect().select(column1).from(table1, table2),\n                \"SELECT column1 FROM table1, table2\");\n\n        winqEqual(new StatementSelect().select(column1).from(new TableOrSubquery(table1), new TableOrSubquery(table2)),\n                \"SELECT column1 FROM table1, table2\");\n\n        winqEqual(new StatementSelect().select(column1).from(table1, new TableOrSubquery(table2)),\n                \"SELECT column1 FROM table1, table2\");\n\n        winqEqual(new StatementSelect().select(column1).from(table1).where(column1.gt(1)),\n                \"SELECT column1 FROM table1 WHERE column1 > 1\");\n\n        winqEqual(new StatementSelect().select(column1).from(table1)\n                        .orderBy(column1.order(Order.Asc), column2.order(Order.Desc)),\n                \"SELECT column1 FROM table1 ORDER BY column1 ASC, column2 DESC\");\n\n        winqEqual(new StatementSelect().select(column1).from(table1).limit(1),\n                \"SELECT column1 FROM table1 LIMIT 1\");\n\n        winqEqual(new StatementSelect().select(column1).from(table1).limit(new BindParameter(1)),\n                \"SELECT column1 FROM table1 LIMIT ?1\");\n\n        winqEqual(new StatementSelect().select(column1).from(table1).limit(1, 2),\n                \"SELECT column1 FROM table1 LIMIT 1, 2\");\n\n        winqEqual(new StatementSelect().select(column1).from(table1).limit(1).offset(3),\n                \"SELECT column1 FROM table1 LIMIT 1 OFFSET 3\");\n\n        winqEqual(new StatementSelect().select(column1).from(table1).groupBy(column1),\n                \"SELECT column1 FROM table1 GROUP BY column1\");\n\n        winqEqual(new StatementSelect().select(column1).from(table1)\n                        .groupBy(new Column[]{column1, column2}).having(column1.gt(1)),\n                \"SELECT column1 FROM table1 GROUP BY column1, column2 HAVING column1 > 1\");\n\n        winqEqual(new StatementSelect().select(column1).from(\n                        new StatementSelect().select(new Column[]{column1, column2}).from(table2)),\n                \"SELECT column1 FROM (SELECT column1, column2 FROM table2)\");\n\n        winqEqual(new StatementSelect().select(column1).from(table1).union().select(column2).from(table2),\n                \"SELECT column1 FROM table1 UNION SELECT column2 FROM table2\");\n\n        winqEqual(new StatementSelect().select(column1).from(table1).unionAll().select(column2).from(table2),\n                \"SELECT column1 FROM table1 UNION ALL SELECT column2 FROM table2\");\n\n        winqEqual(new StatementSelect().select(column1).from(table1).intersect().select(column2).from(table2),\n                \"SELECT column1 FROM table1 INTERSECT SELECT column2 FROM table2\");\n\n        winqEqual(new StatementSelect().select(column1).from(table1).except().select(column2).from(table2),\n                \"SELECT column1 FROM table1 EXCEPT SELECT column2 FROM table2\");\n\n        CommonTableExpression cte = new CommonTableExpression(\"tempTable\")\n                .as(new StatementSelect().select(\"testColumn\").from(\"table1\"));\n        winqEqual(new StatementSelect().with(cte).select(\"testColumn\").from(\"tempTable\"),\n                \"WITH tempTable AS(SELECT testColumn FROM table1) SELECT testColumn FROM tempTable\");\n        winqEqual(new StatementSelect().withRecursive(cte).select(\"testColumn\").from(\"tempTable\"),\n                \"WITH RECURSIVE tempTable AS(SELECT testColumn FROM table1) SELECT testColumn FROM tempTable\");\n\n    }\n}\n"
  },
  {
    "path": "src/java/test/src/androidTest/java/com/tencent/wcdbtest/winq/StatementUpdateTest.java",
    "content": "// Created by qiuwenchen on 2023/4/14.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdbtest.winq;\n\nimport androidx.test.ext.junit.runners.AndroidJUnit4;\n\nimport com.tencent.wcdb.base.Value;\nimport com.tencent.wcdb.winq.*;\n\nimport static com.tencent.wcdbtest.base.WinqTool.winqEqual;\n\nimport org.junit.Test;\nimport org.junit.runner.RunWith;\n\n@RunWith(AndroidJUnit4.class)\npublic class StatementUpdateTest {\n    @Test\n    public void test() {\n        Column column1 = new Column(\"column1\");\n        Column column2 = new Column(\"column2\");\n\n        winqEqual(new StatementUpdate().update(\"testTable\").set(column1).to(1),\n                \"UPDATE testTable SET column1 = 1\");\n        winqEqual(new StatementUpdate().update(\"testTable\").set(column1).to(true),\n                \"UPDATE testTable SET column1 = TRUE\");\n        winqEqual(new StatementUpdate().update(\"testTable\").set(column1).to(\"abc\"),\n                \"UPDATE testTable SET column1 = 'abc'\");\n        winqEqual(new StatementUpdate().update(\"testTable\").set(column1).to(1.1),\n                \"UPDATE testTable SET column1 = 1.1000000000000001\");\n        winqEqual(new StatementUpdate().update(\"testTable\").set(column1).to((String) null),\n                \"UPDATE testTable SET column1 = NULL\");\n        winqEqual(new StatementUpdate().update(\"testTable\").orReplace().set(column1).to(1).set(column2).to(\"abc\"),\n                \"UPDATE OR REPLACE testTable SET column1 = 1, column2 = 'abc'\");\n        winqEqual(new StatementUpdate().update(\"testTable\").setColumnsToBindParameters(column1, column2),\n                \"UPDATE testTable SET column1 = ?1, column2 = ?2\");\n        winqEqual(new StatementUpdate().update(\"testTable\").setColumnsToValues(new Column[]{column1, column2}, new Object[]{1, \"abc\"}),\n                \"UPDATE testTable SET column1 = 1, column2 = 'abc'\");\n        winqEqual(new StatementUpdate().update(\"testTable\").setColumnsToValues(new Column[]{column1, column2}, new Value[]{new Value(1), new Value(\"abc\")}),\n                \"UPDATE testTable SET column1 = 1, column2 = 'abc'\");\n        winqEqual(new StatementUpdate().update(\"testTable\").set(column1).to(1).where(column1.gt(1)),\n                \"UPDATE testTable SET column1 = 1 WHERE column1 > 1\");\n        winqEqual(new StatementUpdate().update(\"testTable\").set(column1).to(1)\n                        .orderBy(column1.order(Order.Asc), column2.order(Order.Desc)),\n                \"UPDATE testTable SET column1 = 1 ORDER BY column1 ASC, column2 DESC\");\n        winqEqual(new StatementUpdate().update(\"testTable\").set(column1).to(1).limit(1),\n                \"UPDATE testTable SET column1 = 1 LIMIT 1\");\n        winqEqual(new StatementUpdate().update(\"testTable\").set(column1).to(1).limit(1, 2),\n                \"UPDATE testTable SET column1 = 1 LIMIT 1, 2\");\n        winqEqual(new StatementUpdate().update(\"testTable\").set(column1).to(1).limit(1).offset(3),\n                \"UPDATE testTable SET column1 = 1 LIMIT 1 OFFSET 3\");\n    }\n}\n"
  },
  {
    "path": "src/java/test/src/androidTest/java/com/tencent/wcdbtest/winq/StatementVacuumTest.java",
    "content": "// Created by qiuwenchen on 2023/6/13.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdbtest.winq;\n\nimport org.junit.Test;\n\nimport static com.tencent.wcdbtest.base.WinqTool.winqEqual;\n\nimport com.tencent.wcdb.winq.StatementVacuum;\n\npublic class StatementVacuumTest {\n    @Test\n    public void test() {\n        winqEqual(new StatementVacuum(), \"VACUUM\");\n        winqEqual(new StatementVacuum().vacuum(\"testSchema\"), \"VACUUM testSchema\");\n    }\n}\n"
  },
  {
    "path": "src/java/test/src/androidTest/java/com/tencent/wcdbtest/winq/TableConstraintTest.java",
    "content": "// Created by chenqiuwen on 2023/4/9.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdbtest.winq;\n\nimport androidx.test.ext.junit.runners.AndroidJUnit4;\n\nimport static com.tencent.wcdbtest.base.WinqTool.winqEqual;\n\nimport com.tencent.wcdb.winq.*;\n\nimport org.junit.Test;\nimport org.junit.runner.RunWith;\n\n@RunWith(AndroidJUnit4.class)\npublic class TableConstraintTest {\n    @Test\n    public void test() {\n        Column column1 = new Column(\"column1\");\n        Column column2 = new Column(\"column2\");\n        winqEqual(column1, \"column1\");\n        winqEqual(column2, \"column2\");\n        winqEqual(new TableConstraint(\"testConstraint\").primaryKey().indexedBy(new Column[]{column1, column2}),\n                \"CONSTRAINT testConstraint PRIMARY KEY(column1, column2)\");\n        winqEqual(new TableConstraint().primaryKey().indexedBy(new Column[]{column1, column2}),\n                \"PRIMARY KEY(column1, column2)\");\n        winqEqual(new TableConstraint().unique().indexedBy(new Column[]{column1, column2}),\n                \"UNIQUE(column1, column2)\");\n        winqEqual(new TableConstraint().unique().indexedBy(new Column[]{column1, column2}).onConflict(ConflictAction.Fail),\n                \"UNIQUE(column1, column2) ON CONFLICT FAIL\");\n        winqEqual(new TableConstraint().check(column1.gt(1)),\n                \"CHECK(column1 > 1)\");\n\n        String columnName1 = \"column1\";\n        String columnName2 = \"column2\";\n        winqEqual(new TableConstraint().primaryKey().indexedBy(columnName1, columnName2),\n                \"PRIMARY KEY(column1, column2)\");\n        winqEqual(new TableConstraint(\"testConstraint\").primaryKey().indexedBy(new String[]{columnName1, columnName2}),\n                \"CONSTRAINT testConstraint PRIMARY KEY(column1, column2)\");\n        winqEqual(new TableConstraint().unique().indexedBy(columnName1, columnName2),\n                \"UNIQUE(column1, column2)\");\n        winqEqual(new TableConstraint().unique().indexedBy(columnName1, columnName2).onConflict(ConflictAction.Fail),\n                \"UNIQUE(column1, column2) ON CONFLICT FAIL\");\n    }\n}\n"
  },
  {
    "path": "src/java/test/src/androidTest/java/com/tencent/wcdbtest/winq/TableOrSubqueryTest.java",
    "content": "// Created by qiuwenchen on 2023/4/7.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdbtest.winq;\n\nimport androidx.test.ext.junit.runners.AndroidJUnit4;\n\nimport com.tencent.wcdb.winq.*;\n\nimport static com.tencent.wcdbtest.base.WinqTool.winqEqual;\n\nimport org.junit.Test;\nimport org.junit.runner.RunWith;\n\n@RunWith(AndroidJUnit4.class)\npublic class TableOrSubqueryTest {\n    @Test\n    public void test() {\n        winqEqual(new TableOrSubquery(\"testTable\"), \"testTable\");\n        winqEqual(new TableOrSubquery(\"testTable\").schema(\"testSchema\"), \"testSchema.testTable\");\n        winqEqual(new TableOrSubquery(\"testTable\").indexedBy(\"testIndex\"), \"testTable INDEXED BY testIndex\");\n        winqEqual(new TableOrSubquery(\"testTable\").notIndexd(), \"testTable NOT INDEXED\");\n        winqEqual(new TableOrSubquery(\"testTable\").as(\"testAliasTable\"), \"testTable AS testAliasTable\");\n        winqEqual(TableOrSubquery.function(\"testFunction\"), \"testFunction()\");\n        winqEqual(TableOrSubquery.function(\"testFunction\")\n                        .argument(1).argument(\"abc\").argument((ExpressionConvertible) null).argument(new BindParameter(1)),\n                \"testFunction(1, 'abc', NULL, ?1)\");\n        winqEqual(TableOrSubquery.function(\"testFunction\").as(\"testAliasTable\"), \"testFunction() AS testAliasTable\");\n        winqEqual(new TableOrSubquery(new String[]{\"testTable1, testTable2\"}), \"(testTable1, testTable2)\");\n    }\n}\n"
  },
  {
    "path": "src/java/test/src/androidTest/java/com/tencent/wcdbtest/winq/UpsertTest.java",
    "content": "// Created by chenqiuwen on 2023/6/10.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdbtest.winq;\n\nimport androidx.test.ext.junit.runners.AndroidJUnit4;\n\nimport static com.tencent.wcdbtest.base.WinqTool.winqEqual;\n\nimport com.tencent.wcdb.winq.Column;\nimport com.tencent.wcdb.winq.ExpressionConvertible;\nimport com.tencent.wcdb.winq.Upsert;\n\nimport org.junit.Test;\nimport org.junit.runner.RunWith;\n\n@RunWith(AndroidJUnit4.class)\npublic class UpsertTest {\n    @Test\n    public void test() {\n        Column column = new Column(\"column1\");\n        Column[] columns = new Column[]{new Column(\"column2\"), new Column(\"column3\")};\n\n        winqEqual(new Upsert().onConflict().doNoThing(),\n                \"ON CONFLICT DO NOTHING\");\n        winqEqual(new Upsert().onConflict().indexedBy(column).doNoThing(),\n                \"ON CONFLICT(column1) DO NOTHING\");\n        winqEqual(new Upsert().onConflict().indexedBy(column).where(column.eq(1)).doNoThing(),\n                \"ON CONFLICT(column1) WHERE column1 == 1 DO NOTHING\");\n        winqEqual(new Upsert().onConflict().doUpdate().set(column).to((ExpressionConvertible) null),\n                \"ON CONFLICT DO UPDATE SET column1 = NULL\");\n        winqEqual(new Upsert().onConflict().doUpdate().set(column).to(true),\n                \"ON CONFLICT DO UPDATE SET column1 = TRUE\");\n        winqEqual(new Upsert().onConflict().doUpdate().set(column).to(1),\n                \"ON CONFLICT DO UPDATE SET column1 = 1\");\n        winqEqual(new Upsert().onConflict().doUpdate().set(column).to(\"abc\"),\n                \"ON CONFLICT DO UPDATE SET column1 = 'abc'\");\n        winqEqual(new Upsert().onConflict().doUpdate().set(column).to(1).set(columns).to(2),\n                \"ON CONFLICT DO UPDATE SET column1 = 1, (column2, column3) = 2\");\n        winqEqual(new Upsert().onConflict().doUpdate().set(column).to(1).where(column.eq(2)),\n                \"ON CONFLICT DO UPDATE SET column1 = 1 WHERE column1 == 2\");\n    }\n}\n"
  },
  {
    "path": "src/java/test/src/androidTest/java/com/tencent/wcdbtest/winq/WindowDefTest.java",
    "content": "// Created by chenqiuwen on 2023/6/10.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdbtest.winq;\n\nimport androidx.test.ext.junit.runners.AndroidJUnit4;\n\nimport static com.tencent.wcdbtest.base.WinqTool.winqEqual;\n\nimport com.tencent.wcdb.winq.Column;\nimport com.tencent.wcdb.winq.FrameSpec;\nimport com.tencent.wcdb.winq.Order;\nimport com.tencent.wcdb.winq.WindowDef;\n\nimport org.junit.Test;\nimport org.junit.runner.RunWith;\n\n@RunWith(AndroidJUnit4.class)\npublic class WindowDefTest {\n    @Test\n    public void test() {\n        winqEqual(new WindowDef(), \"\");\n        winqEqual(new WindowDef().partitionBy(\"column1\"),\n                \"(PARTITION BY column1)\");\n        winqEqual(new WindowDef().partitionBy(\"column1\", \"column2\"),\n                \"(PARTITION BY column1, column2)\");\n        winqEqual(new WindowDef().partitionBy(new Column(\"column1\").add(1)),\n                \"(PARTITION BY column1 + 1)\");\n        winqEqual(new WindowDef().partitionBy(new Column(\"column1\").add(1), new Column(\"column2\")),\n                \"(PARTITION BY column1 + 1, column2)\");\n        winqEqual(new WindowDef().orderBy(new Column(\"column1\").order(Order.Asc)),\n                \"(ORDER BY column1 ASC)\");\n        winqEqual(new WindowDef().frameSpec(new FrameSpec().range().unboundedPreceding()),\n                \"(RANGE UNBOUNDED PRECEDING)\");\n        winqEqual(new WindowDef().partitionBy(new Column(\"column1\").add(1), new Column(\"column2\"))\n                        .orderBy(new Column(\"column1\").order(Order.Asc))\n                        .frameSpec(new FrameSpec().range().unboundedPreceding()),\n                \"(PARTITION BY column1 + 1, column2 ORDER BY column1 ASC RANGE UNBOUNDED PRECEDING)\");\n    }\n}\n"
  },
  {
    "path": "src/java/test/src/main/AndroidManifest.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<manifest xmlns:android=\"http://schemas.android.com/apk/res/android\" xmlns:tools=\"http://schemas.android.com/tools\">\n    <application\n        android:allowBackup=\"false\"\n        android:label=\"WCDB Test\"\n        tools:ignore=\"GoogleAppIndexingWarning,MissingApplicationIcon\">\n    </application>\n\n</manifest>"
  },
  {
    "path": "src/java/test/src/main/wcdbOrm/com/tencent/wcdbtest/base/PinyinObject.java",
    "content": "// Created by qiuwenchen on 2024/2/21.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage com.tencent.wcdbtest.base;\n\nimport com.tencent.wcdb.*;\nimport com.tencent.wcdb.fts.BuiltinTokenizer;\n\n@WCDBTableCoding(\n        ftsModule = @FTSModule(\n                version = FTSVersion.FTS5,\n                tokenizer = BuiltinTokenizer.Pinyin\n        )\n)\npublic class PinyinObject {\n    @WCDBField\n    public String content;\n}\n\n"
  },
  {
    "path": "src/java/test/src/main/wcdbOrm/com/tencent/wcdbtest/base/TestObject.java",
    "content": "// Created by qiuwenchen on 2023/4/14.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdbtest.base;\n\nimport com.tencent.wcdb.WCDBField;\nimport com.tencent.wcdb.WCDBTableCoding;\n\n@WCDBTableCoding\npublic class TestObject {\n    @WCDBField(isPrimary = true, isAutoIncrement = true)\n    public int id;\n    @WCDBField\n    public String content;\n\n    @Override\n    public boolean equals(Object obj) {\n        if (obj instanceof TestObject) {\n            TestObject testObject = (TestObject) obj;\n            if (testObject.id != id) {\n                return false;\n            }\n            if (content == null) {\n                return testObject.content == null || testObject.content.length() <= 0;\n            } else if (testObject.content == null) {\n                return content.length() <= 0;\n            }\n            return testObject.content.equals(content);\n        } else {\n            return super.equals(obj);\n        }\n    }\n\n    public static TestObject createObject(int id, String content) {\n        TestObject obj = new TestObject();\n        obj.id = id;\n        obj.content = content;\n        return obj;\n    }\n\n    public static TestObject createPartialObject(int id) {\n        TestObject obj = new TestObject();\n        obj.id = id;\n        return obj;\n    }\n\n    public static TestObject createAutoIncrementObject(String content) {\n        TestObject obj = new TestObject();\n        obj.id = 0;\n        obj.content = content;\n        return obj;\n    }\n}\n"
  },
  {
    "path": "src/java/test/src/main/wcdbOrm/com/tencent/wcdbtest/base/TraditionalChineseObject.java",
    "content": "// Created by qiuwenchen on 2024/2/22.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdbtest.base;\n\nimport com.tencent.wcdb.*;\nimport com.tencent.wcdb.fts.BuiltinTokenizer;\n\n@WCDBTableCoding(\n        ftsModule = @FTSModule(\n                version = FTSVersion.FTS5,\n                tokenizer = BuiltinTokenizer.Verbatim,\n                tokenizerParameters = BuiltinTokenizer.Parameter.SimplifyChinese\n        )\n)\npublic class TraditionalChineseObject {\n    @WCDBField\n    public String content;\n}\n"
  },
  {
    "path": "src/java/test/src/main/wcdbOrm/com/tencent/wcdbtest/orm/testclass/AllTypeObject.java",
    "content": "// Created by qiuwenchen on 2023/5/12.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdbtest.orm.testclass;\n\nimport com.tencent.wcdb.*;\n\nimport java.util.Arrays;\nimport java.util.Objects;\n\n@WCDBTableCoding\npublic class AllTypeObject {\n    @WCDBField\n    public\n    String type;\n\n    //Integer\n    @WCDBField\n    boolean aBoolean;\n    @WCDBField\n    Boolean aBoolean2;\n    @WCDBField\n    byte aByte;\n    @WCDBField\n    Byte aByte2;\n    @WCDBField\n    short aShort;\n    @WCDBField\n    Short aShort2;\n    @WCDBField\n    int anInt;\n    @WCDBField\n    Integer integer;\n    @WCDBField\n    long aLong;\n    @WCDBField\n    Long aLong2;\n\n    // Float\n    @WCDBField\n    float aFloat;\n    @WCDBField\n    Float aFloat2;\n    @WCDBField\n    double aDouble;\n    @WCDBField\n    Double aDouble2;\n\n    // String\n    @WCDBField\n    String string;\n\n    // BLOB\n    @WCDBField\n    byte[] bytes;\n\n    @Override\n    public boolean equals(Object o) {\n        if (this == o) return true;\n        if (o == null || getClass() != o.getClass()) return false;\n        AllTypeObject that = (AllTypeObject) o;\n        return aBoolean == that.aBoolean &&\n                aByte == that.aByte &&\n                aShort == that.aShort &&\n                anInt == that.anInt &&\n                aLong == that.aLong &&\n                Float.compare(that.aFloat, aFloat) == 0 &&\n                Double.compare(that.aDouble, aDouble) == 0 &&\n                Objects.equals(aBoolean2, that.aBoolean2) &&\n                Objects.equals(aByte2, that.aByte2) &&\n                Objects.equals(aShort2, that.aShort2) &&\n                Objects.equals(integer, that.integer) &&\n                Objects.equals(aLong2, that.aLong2) &&\n                Objects.equals(aFloat2, that.aFloat2) &&\n                Objects.equals(aDouble2, that.aDouble2) &&\n                Objects.equals(string, that.string) &&\n                Arrays.equals(bytes, that.bytes);\n    }\n}\n"
  },
  {
    "path": "src/java/test/src/main/wcdbOrm/com/tencent/wcdbtest/orm/testclass/AutoAddColumnObject.java",
    "content": "// Created by qiuwenchen on 2023/5/12.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdbtest.orm.testclass;\n\nimport com.tencent.wcdb.*;\n\n@WCDBTableCoding\npublic class AutoAddColumnObject {\n    @WCDBField(isPrimary = true)\n    int primaryValue;\n    @WCDBField(isUnique = true)\n    int uniqueValue;\n    @WCDBField\n    int insertValue;\n    @WCDBField\n    int updateValue;\n    @WCDBField\n    int selectValue;\n    @WCDBField\n    int multiSelectValue;\n    @WCDBField\n    int deleteValue;\n    @WCDBField\n    int indexValue;\n}\n"
  },
  {
    "path": "src/java/test/src/main/wcdbOrm/com/tencent/wcdbtest/orm/testclass/ColumnConstraintAutoIncrementObject.java",
    "content": "// Created by qiuwenchen on 2023/5/12.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdbtest.orm.testclass;\n\nimport com.tencent.wcdb.*;\n\n@WCDBTableCoding\npublic class ColumnConstraintAutoIncrementObject {\n    @WCDBField(isPrimary = true, isAutoIncrement = true)\n    int value;\n}\n"
  },
  {
    "path": "src/java/test/src/main/wcdbOrm/com/tencent/wcdbtest/orm/testclass/ColumnConstraintDefaultObject.java",
    "content": "// Created by qiuwenchen on 2023/5/12.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage com.tencent.wcdbtest.orm.testclass;\n\nimport com.tencent.wcdb.*;\n\n@WCDBTableCoding\npublic class ColumnConstraintDefaultObject {\n    @WCDBField\n    @WCDBDefault(intValue = 1)\n    int intValue;\n\n    @WCDBField\n    @WCDBDefault(doubleValue = 1.1)\n    float floatValue;\n\n    @WCDBField\n    @WCDBDefault(textValue = \"abc\")\n    String stringValue;\n}\n"
  },
  {
    "path": "src/java/test/src/main/wcdbOrm/com/tencent/wcdbtest/orm/testclass/ColumnConstraintDefaultZeroObject.java",
    "content": "// Created by chenqiuwen on 2023/7/26.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdbtest.orm.testclass;\n\nimport com.tencent.wcdb.WCDBDefault;\nimport com.tencent.wcdb.WCDBField;\nimport com.tencent.wcdb.WCDBTableCoding;\n\n@WCDBTableCoding\npublic class ColumnConstraintDefaultZeroObject {\n    @WCDBField\n    @WCDBDefault(intValue = 0)\n    int intValue;\n\n    @WCDBField\n    @WCDBDefault(doubleValue = 0.0)\n    float floatValue;\n\n    @WCDBField\n    @WCDBDefault(textValue = \"\")\n    String stringValue;\n}\n"
  },
  {
    "path": "src/java/test/src/main/wcdbOrm/com/tencent/wcdbtest/orm/testclass/ColumnConstraintNotNullObject.java",
    "content": "// Created by qiuwenchen on 2023/5/12.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdbtest.orm.testclass;\n\nimport com.tencent.wcdb.*;\n\n@WCDBTableCoding\npublic class ColumnConstraintNotNullObject {\n    @WCDBField(isNotNull = true)\n    String text;\n}\n"
  },
  {
    "path": "src/java/test/src/main/wcdbOrm/com/tencent/wcdbtest/orm/testclass/ColumnConstraintPrimaryObject.java",
    "content": "// Created by qiuwenchen on 2023/5/12.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdbtest.orm.testclass;\n\nimport com.tencent.wcdb.*;\n\n@WCDBTableCoding\npublic class ColumnConstraintPrimaryObject {\n    @WCDBField(isPrimary = true)\n    int value;\n}\n"
  },
  {
    "path": "src/java/test/src/main/wcdbOrm/com/tencent/wcdbtest/orm/testclass/ColumnConstraintUniqueObject.java",
    "content": "// Created by qiuwenchen on 2023/5/12.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdbtest.orm.testclass;\n\nimport com.tencent.wcdb.*;\n\n@WCDBTableCoding\npublic class ColumnConstraintUniqueObject {\n    @WCDBField(isUnique = true)\n    int value;\n}\n"
  },
  {
    "path": "src/java/test/src/main/wcdbOrm/com/tencent/wcdbtest/orm/testclass/FTS3TestObject.java",
    "content": "// Created by chenqiuwen on 2023/11/4.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdbtest.orm.testclass;\n\nimport com.tencent.wcdb.*;\nimport com.tencent.wcdb.fts.*;\n\n@WCDBTableCoding(\n        ftsModule = @FTSModule(\n                version = FTSVersion.FTS3,\n                tokenizer = BuiltinTokenizer.OneOrBinary,\n                tokenizerParameters = BuiltinTokenizer.Parameter.SkipStemming\n        )\n)\npublic class FTS3TestObject {\n    public FTS3TestObject() {\n        this.id = 0;\n        this.content = \"\";\n    }\n\n    public FTS3TestObject(int id, String content) {\n        this.id = id;\n        this.content = content;\n    }\n\n    @WCDBField(isNotIndexed = true)\n    public int id;\n    @WCDBField\n    public\n    String content;\n}\n"
  },
  {
    "path": "src/java/test/src/main/wcdbOrm/com/tencent/wcdbtest/orm/testclass/FTS5TestObject.java",
    "content": "// Created by chenqiuwen on 2023/11/4.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdbtest.orm.testclass;\n\n\nimport com.tencent.wcdb.FTSModule;\nimport com.tencent.wcdb.FTSVersion;\nimport com.tencent.wcdb.WCDBField;\nimport com.tencent.wcdb.WCDBTableCoding;\nimport com.tencent.wcdb.fts.BuiltinTokenizer;\n\n@WCDBTableCoding(\n        ftsModule = @FTSModule(\n                version = FTSVersion.FTS5,\n                tokenizer = BuiltinTokenizer.Verbatim,\n                tokenizerParameters = {BuiltinTokenizer.Parameter.SkipStemming, BuiltinTokenizer.Parameter.SimplifyChinese},\n                externalTable = \"contentTable\"\n        )\n)\npublic class FTS5TestObject {\n    public FTS5TestObject() {\n        this.id = 0;\n        this.content = \"\";\n    }\n\n    public FTS5TestObject(int id, String content) {\n        this.id = id;\n        this.content = content;\n    }\n\n    @WCDBField(isNotIndexed = true)\n    public int id;\n    @WCDBField\n    public String content;\n}\n\n"
  },
  {
    "path": "src/java/test/src/main/wcdbOrm/com/tencent/wcdbtest/orm/testclass/FieldObject.java",
    "content": "// Created by qiuwenchen on 2023/5/12.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage com.tencent.wcdbtest.orm.testclass;\n\nimport com.tencent.wcdb.*;\n\n@WCDBTableCoding\npublic class FieldObject {\n    @WCDBField\n    int field;\n    @WCDBField(columnName = \"differentName\")\n    int fieldWithDifferentName;\n}\n"
  },
  {
    "path": "src/java/test/src/main/wcdbOrm/com/tencent/wcdbtest/orm/testclass/IndexObject.java",
    "content": "//\n// Created by qiuwenchen on 2023/5/12.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdbtest.orm.testclass;\n\nimport com.tencent.wcdb.*;\n\n@WCDBTableCoding\npublic class IndexObject {\n    @WCDBField\n    @WCDBIndex\n    int index_;\n\n    @WCDBField\n    @WCDBIndex(name = \"specifiedNameIndex\", isUnique = true)\n    int uniqueIndex;\n}\n"
  },
  {
    "path": "src/java/test/src/main/wcdbOrm/com/tencent/wcdbtest/orm/testclass/MMICUTestObject.java",
    "content": "// Created by chenqiuwen on 2024/5/19.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage com.tencent.wcdbtest.orm.testclass;\n\nimport com.tencent.wcdb.*;\nimport com.tencent.wcdb.fts.*;\n\n@WCDBTableCoding(\n        ftsModule = @FTSModule(\n                version = FTSVersion.FTS3,\n                tokenizer = BuiltinTokenizer.MMICU\n        )\n)\npublic class MMICUTestObject {\n    public MMICUTestObject() {\n        this.id = 0;\n        this.content = \"\";\n    }\n\n    public MMICUTestObject(int id, String content) {\n        this.id = id;\n        this.content = content;\n    }\n\n    @WCDBField(isNotIndexed = true)\n    public int id;\n    @WCDBField\n    public\n    String content;\n}\n"
  },
  {
    "path": "src/java/test/src/main/wcdbOrm/com/tencent/wcdbtest/orm/testclass/NewRemapObject.java",
    "content": "// Created by qiuwenchen on 2023/5/12.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdbtest.orm.testclass;\n\nimport com.tencent.wcdb.*;\n\n@WCDBTableCoding\npublic class NewRemapObject {\n    @WCDBField(columnName = \"value\")\n    @WCDBIndex\n    int renamedValue;\n    @WCDBField()\n    int newValue;\n}\n"
  },
  {
    "path": "src/java/test/src/main/wcdbOrm/com/tencent/wcdbtest/orm/testclass/OldRemapObject.java",
    "content": "// Created by qiuwenchen on 2023/5/12.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdbtest.orm.testclass;\n\nimport com.tencent.wcdb.*;\n\n@WCDBTableCoding\npublic class OldRemapObject {\n    @WCDBField\n    int value;\n}\n"
  },
  {
    "path": "src/java/test/src/main/wcdbOrm/com/tencent/wcdbtest/orm/testclass/PrimaryEnableAutoIncrementObject.java",
    "content": "// Created by qiuwenchen on 2023/7/7.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdbtest.orm.testclass;\n\nimport com.tencent.wcdb.*;\n\n@WCDBTableCoding\npublic class PrimaryEnableAutoIncrementObject {\n    @WCDBField(isPrimary = true,\n            isAutoIncrement = true,\n            enableAutoIncrementForExistingTable = true)\n    public int id;\n}\n"
  },
  {
    "path": "src/java/test/src/main/wcdbOrm/com/tencent/wcdbtest/orm/testclass/PrimaryNotAutoIncrementObject.java",
    "content": "// Created by qiuwenchen on 2023/7/7.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdbtest.orm.testclass;\n\nimport com.tencent.wcdb.*;\n\n@WCDBTableCoding\npublic class PrimaryNotAutoIncrementObject {\n    @WCDBField(isPrimary = true)\n    public int id;\n}\n"
  },
  {
    "path": "src/java/test/src/main/wcdbOrm/com/tencent/wcdbtest/orm/testclass/TableConstraintObject.java",
    "content": "// Created by qiuwenchen on 2023/5/12.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.tencent.wcdbtest.orm.testclass;\n\nimport com.tencent.wcdb.*;\n\n@WCDBTableCoding(\n        multiPrimaries = @MultiPrimary(columns = {\"multiPrimary1\", \"multiPrimary2\", \"multiPrimary3\"}),\n        multiUnique = @MultiUnique(columns = {\"multiUnique1\", \"multiUnique2\", \"multiUnique3\"}),\n        multiIndexes = {\n                @MultiIndexes(name = \"specifiedNameIndex\", columns = {\"multiIndex1\", \"multiIndex2\", \"multiIndex3\"}),\n                @MultiIndexes(columns = {\"multiIndex1\", \"multiIndex2\"})\n        }\n)\npublic class TableConstraintObject {\n    @WCDBField\n    int multiPrimary1;\n    @WCDBField\n    int multiPrimary2;\n    @WCDBField(columnName = \"multiPrimary3\")\n    int multiPrimary;\n    @WCDBField\n    int multiUnique1;\n    @WCDBField\n    int multiUnique2;\n    @WCDBField(columnName = \"multiUnique3\")\n    int multiUnique;\n    @WCDBField\n    int multiIndex1;\n    @WCDBField\n    int multiIndex2;\n    @WCDBField(columnName = \"multiIndex3\")\n    int multiIndex;\n}\n"
  },
  {
    "path": "src/objc/Interface.h",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"WCTDatabase+ChainCall.h\"\n#import \"WCTHandle+ChainCall.h\"\n#import \"WCTTable+ChainCall.h\"\n\n#import \"WCTDelete.h\"\n#import \"WCTInsert.h\"\n#import \"WCTMultiSelect.h\"\n#import \"WCTSelect.h\"\n#import \"WCTUpdate.h\"\n\n#import \"WCTDatabase+Compression.h\"\n#import \"WCTDatabase+Config.h\"\n#import \"WCTDatabase+FTS.h\"\n#import \"WCTDatabase+File.h\"\n#import \"WCTDatabase+Memory.h\"\n#import \"WCTDatabase+Migration.h\"\n#import \"WCTDatabase+Repair.h\"\n#import \"WCTDatabase+Version.h\"\n\n#import \"WCTDatabase+Handle.h\"\n#import \"WCTDatabase.h\"\n#import \"WCTHandle.h\"\n#import \"WCTPreparedStatement.h\"\n\n#import \"WCTORM.h\"\n\n#import \"WCTDatabase+Transaction.h\"\n#import \"WCTHandle+Transaction.h\"\n\n#import \"WCTDatabase+Convenient.h\"\n#import \"WCTHandle+Convenient.h\"\n#import \"WCTTable+Convenient.h\"\n\n#import \"WCTDatabase+Table.h\"\n#import \"WCTHandle+Table.h\"\n#import \"WCTTable+Table.h\"\n#import \"WCTTable.h\"\n#import \"WCTTableProtocol.h\"\n\n#import \"WCTBridgeProperty+CPP.h\"\n#import \"WCTDatabase+Monitor.h\"\n#import \"WCTError.h\"\n#import \"WCTTag.h\"\n"
  },
  {
    "path": "src/objc/WCDBObjc.h",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#ifdef __cplusplus\n#if __cplusplus < 201402L\n#error `CLANG_CXX_LANGUAGE_STANDARD = gnu++14` and `CLANG_CXX_LIBRARY = libc++` build settings are required.\n#endif\n#else // __cplusplus\n#error Objective-C++ environment is required. (By changing suffix of those files including <WCDB/WCDBObjc.h> from `.m` to `.mm`.\n#endif // __cplusplus\n\n// WCDB may fail to compile since there are few frameworks that define `offset` as a macro.\n#ifdef offset\n#error Symbol `offset` should not be defined as a macro since it's a common used word.\n#endif\n\n#import \"Interface.h\"\n#import \"WCTBuiltin.h\"\n#import \"WINQ.h\"\n\n#import \"WCTDatabase+Test.h\"\n"
  },
  {
    "path": "src/objc/bridge/WCTBridgeProperty+CPP.h",
    "content": "//\n// Created by qiuwenchen on 2022/4/21.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"WCTBridgeProperty.h\"\n#import \"WCTProperty.h\"\n\n@interface WCTBridgeProperty (CPP)\n\n+ (WCTBridgeProperty *)creatBridgeProperty:(const WCTProperty &)wctProperty;\n\n- (const WCTProperty &)wctProperty;\n\n@end\n"
  },
  {
    "path": "src/objc/bridge/WCTBridgeProperty.h",
    "content": "//\n// Created by qiuwenchen on 2022/4/21.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"Macro.h\"\n#import <Foundation/Foundation.h>\n\nWCDB_API @interface WCTBridgeProperty : NSObject\n\n@property (nonatomic, strong, readonly) NSString* _Nonnull propertyName;\n\n- (const void* _Nullable)tableBinding;\n\n@end\n\ntypedef NSArray<WCTBridgeProperty*> WCTBridgeProperties;\n"
  },
  {
    "path": "src/objc/bridge/WCTBridgeProperty.mm",
    "content": "//\n// Created by qiuwenchen on 2022/4/21.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"WCTBridgeProperty+CPP.h\"\n#import <Foundation/Foundation.h>\n\n@interface WCTBridgeProperty () {\n    const WCTProperty* m_innerProperty;\n}\n@end\n\n@implementation WCTBridgeProperty\n\n+ (WCTBridgeProperty*)creatBridgeProperty:(const WCTProperty&)wctProperty\n{\n    WCTBridgeProperty* property = [[WCTBridgeProperty alloc] init];\n    property->m_innerProperty = &wctProperty;\n    return property;\n}\n\n- (NSString*)propertyName\n{\n    return [NSString stringWithUTF8String:m_innerProperty->getDescription().data()];\n}\n\n- (const WCTProperty&)wctProperty\n{\n    return *m_innerProperty;\n}\n\n- (const void* _Nullable)tableBinding\n{\n    return self.wctProperty.syntax().getTableBinding();\n}\n\n@end\n"
  },
  {
    "path": "src/objc/builtin/NSData+WCTColumnCoding.h",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"Interface.h\"\n\n@interface NSData (WCTColumnCoding) <WCTColumnCoding>\n\n@end\n"
  },
  {
    "path": "src/objc/builtin/NSData+WCTColumnCoding.mm",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"NSData+WCTColumnCoding.h\"\n\n@implementation NSData (WCTColumnCoding)\n\n+ (instancetype)unarchiveWithWCTValue:(NSData *)value\n{\n    return value;\n}\n\n- (NSData *)archivedWCTValue\n{\n    return self;\n}\n\n+ (WCTColumnType)columnType\n{\n    return WCTColumnTypeData;\n}\n\n@end\n"
  },
  {
    "path": "src/objc/builtin/NSDate+WCTColumnCoding.h",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"Interface.h\"\n\n@interface NSDate (WCTColumnCoding) <WCTColumnCoding>\n\n@end\n"
  },
  {
    "path": "src/objc/builtin/NSDate+WCTColumnCoding.mm",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"NSDate+WCTColumnCoding.h\"\n\n@implementation NSDate (WCTColumnCoding)\n\n+ (instancetype)unarchiveWithWCTValue:(NSNumber *)value\n{\n    if (value == nil) {\n        return nil;\n    }\n    return [NSDate dateWithTimeIntervalSince1970:value.doubleValue];\n}\n\n- (NSNumber *)archivedWCTValue\n{\n    return [NSNumber numberWithDouble:self.timeIntervalSince1970];\n}\n\n+ (WCTColumnType)columnType\n{\n    return WCTColumnTypeFloat;\n}\n\n@end\n"
  },
  {
    "path": "src/objc/builtin/NSNull+WCTColumnCoding.h",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"Interface.h\"\n\n@interface NSNull (WCTColumnCoding) <WCTColumnCoding>\n\n@end\n"
  },
  {
    "path": "src/objc/builtin/NSNull+WCTColumnCoding.mm",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"NSNull+WCTColumnCoding.h\"\n\n@implementation NSNull (WCTColumnCoding)\n\n+ (instancetype)unarchiveWithWCTValue:(id)value\n{\n    WCDB_UNUSED(value);\n    return [NSNull null];\n}\n\n- (id)archivedWCTValue\n{\n    return nil;\n}\n\n+ (WCTColumnType)columnType\n{\n    return WCTColumnTypeNull;\n}\n\n@end\n"
  },
  {
    "path": "src/objc/builtin/NSNumber+WCTColumnCoding.h",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"Interface.h\"\n\n@interface NSNumber (WCTColumnCoding) <WCTColumnCoding>\n\n@end\n"
  },
  {
    "path": "src/objc/builtin/NSNumber+WCTColumnCoding.mm",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"NSNumber+WCTColumnCoding.h\"\n\n@implementation NSNumber (WCTColumnCoding)\n\n+ (instancetype)unarchiveWithWCTValue:(NSNumber *)value\n{\n    return value;\n}\n\n- (NSNumber *)archivedWCTValue\n{\n    return self;\n}\n\n+ (WCTColumnType)columnType\n{\n    return WCTColumnTypeFloat;\n}\n\n@end\n"
  },
  {
    "path": "src/objc/builtin/NSObject+WCTColumnCoding.h",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"Interface.h\"\n\n@interface NSObject (WCTColumnCoding) <WCTColumnCoding>\n\n@end\n"
  },
  {
    "path": "src/objc/builtin/NSObject+WCTColumnCoding.mm",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"Assertion.hpp\"\n#import \"Console.hpp\"\n#import \"NSObject+WCTColumnCoding.h\"\n\n@implementation NSObject (WCTColumnCoding)\n\n+ (instancetype)unarchiveWithWCTValue:(NSData *)value\n{\n    if (value != nil) {\n        return [NSKeyedUnarchiver unarchiveObjectWithData:value];\n    }\n    return nil;\n}\n\n- (NSData *)archivedWCTValue\n{\n    return [NSKeyedArchiver archivedDataWithRootObject:self];\n}\n\n+ (WCTColumnType)columnType\n{\n    return WCTColumnTypeData;\n}\n\n@end\n"
  },
  {
    "path": "src/objc/builtin/NSString+WCTColumnCoding.h",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"Interface.h\"\n\n@interface NSString (WCTColumnCoding) <WCTColumnCoding>\n\n@end\n"
  },
  {
    "path": "src/objc/builtin/NSString+WCTColumnCoding.mm",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"NSString+WCTColumnCoding.h\"\n\n@implementation NSString (WCTColumnCoding)\n\n+ (instancetype)unarchiveWithWCTValue:(NSString *)value\n{\n    return value;\n}\n\n- (NSString *)archivedWCTValue\n{\n    return self;\n}\n\n+ (WCTColumnType)columnType\n{\n    return WCTColumnTypeString;\n}\n\n@end\n"
  },
  {
    "path": "src/objc/builtin/WCTBuiltin.h",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"NSData+WCTColumnCoding.h\"\n#import \"NSDate+WCTColumnCoding.h\"\n#import \"NSNull+WCTColumnCoding.h\"\n#import \"NSNumber+WCTColumnCoding.h\"\n#import \"NSObject+WCTColumnCoding.h\"\n#import \"NSString+WCTColumnCoding.h\"\n\n#import \"WCTMaster+WCTTableCoding.h\"\n#import \"WCTSequence+WCTTableCoding.h\"\n"
  },
  {
    "path": "src/objc/builtin/WCTMaster+WCTTableCoding.h",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"Interface.h\"\n#import \"WCTMaster.h\"\n\nWCDB_API @interface WCTMaster(TableCoding)<WCTTableCoding>\n\nWCDB_PROPERTY(type)\nWCDB_PROPERTY(name)\nWCDB_PROPERTY(tblName)\nWCDB_PROPERTY(rootpage)\nWCDB_PROPERTY(sql)\n\n@end\n"
  },
  {
    "path": "src/objc/builtin/WCTMaster.h",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"Macro.h\"\n#import <Foundation/Foundation.h>\n\nNS_ASSUME_NONNULL_BEGIN\n\n/**\n Builtin ORM for `sqlite_master` table. For further information, see https://www.sqlite.org/schematab.html .\n */\n\nWCDB_API @interface WCTMaster : NSObject\n\n@property (class, nonatomic, readonly) NSString *tableName;\n\n@property (nonatomic, retain, nullable) NSString *type;\n@property (nonatomic, retain, nullable) NSString *name;\n@property (nonatomic, retain, nullable) NSString *tblName;\n@property (nonatomic, assign) int rootpage;\n@property (nonatomic, retain, nullable) NSString *sql;\n\n@end\n\nNS_ASSUME_NONNULL_END\n"
  },
  {
    "path": "src/objc/builtin/WCTMaster.mm",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"WCTMaster.h\"\n#import \"WCTMaster+WCTTableCoding.h\"\n\n@implementation WCTMaster\n\nWCDB_IMPLEMENTATION(WCTMaster)\nWCDB_SYNTHESIZE(type)\nWCDB_SYNTHESIZE(name)\nWCDB_SYNTHESIZE_COLUMN(tblName, \"tbl_name\")\nWCDB_SYNTHESIZE(rootpage)\nWCDB_SYNTHESIZE(sql)\n\n+ (NSString *)tableName\n{\n    return [NSString stringWithUTF8String:WCDB::Syntax::masterTable.data()];\n}\n\n@end\n"
  },
  {
    "path": "src/objc/builtin/WCTSequence+WCTTableCoding.h",
    "content": "//\n// Created by qiuwenchen on 2022/12/20.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"WCTMacro.h\"\n#import \"WCTSequence.h\"\n#import \"WCTTableCoding.h\"\n\nWCDB_API @interface WCTSequence(WCTTableCoding)<WCTTableCoding>\n\nWCDB_PROPERTY(name)\nWCDB_PROPERTY(seq)\n\n@end\n"
  },
  {
    "path": "src/objc/builtin/WCTSequence.h",
    "content": "//\n// Created by qiuwenchen on 2022/12/20.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import <Foundation/Foundation.h>\n\n/**\n Builtin ORM for `sqlite_sequence` table. For further information, see https://sqlite.org/autoinc.html .\n */\nWCDB_API @interface WCTSequence : NSObject\n\n+ (NSString *)tableName;\n\n@property (nonatomic, retain) NSString *name;\n@property (nonatomic, assign) int seq;\n\n@end\n"
  },
  {
    "path": "src/objc/builtin/WCTSequence.mm",
    "content": "//\n// Created by qiuwenchen on 2022/12/20.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"WCDBObjc.h\"\n#import \"WCTSequence+WCTTableCoding.h\"\n\n@implementation WCTSequence\n\nWCDB_IMPLEMENTATION(WCTSequence)\nWCDB_SYNTHESIZE(name)\nWCDB_SYNTHESIZE(seq)\n\n+ (NSString *)tableName\n{\n    return [NSString stringWithUTF8String:WCDB::Syntax::sequenceTable.data()];\n}\n\n@end\n"
  },
  {
    "path": "src/objc/chaincall/WCTChainCall+Private.h",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"WCTChainCall.h\"\n\nNS_ASSUME_NONNULL_BEGIN\n\ntypedef NS_ENUM(NSUInteger, WCTChainCallDisposeAction) {\n    WCTChainCallDisposeActionFinalizeStatement,\n    WCTChainCallDisposeActionInvalidate,\n};\n\nWCDB_API @interface WCTChainCall() {\n@protected\n    WCTHandle* _handle;\n@private\n    WCTChainCallDisposeAction _disposeAction;\n    int _changes;\n    WCTError* _error;\n}\n\n- (instancetype)initWithHandle:(WCTHandle*)handle NS_DESIGNATED_INITIALIZER;\n\n- (instancetype)invalidateWhenDispose;\n\n- (instancetype)finalizeStatementWhenDispose;\n\n- (void)tryDispose;\n\n- (void)saveChangesAndError:(BOOL)succeed;\n\n@end\n\nNS_ASSUME_NONNULL_END\n"
  },
  {
    "path": "src/objc/chaincall/WCTChainCall.h",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"WCTCommon.h\"\n\nNS_ASSUME_NONNULL_BEGIN\n\n@protocol WCTChainCallProtocol\n@required\n/**\n @brief Generate a `WCTInsert` to do an insertion or replacement.\n */\n- (WCTInsert *)prepareInsert;\n/**\n @brief Generate a `WCTDelete` to do a deletion.\n */\n- (WCTDelete *)prepareDelete;\n/**\n @brief Generate a `WCTSelect` to do an object selection.\n */\n- (WCTSelect *)prepareSelect;\n/**\n @brief Generate a `WCTUpdate` to do an update.\n */\n- (WCTUpdate *)prepareUpdate;\n@end\n\n@protocol WCTCrossTableChainCallProtocol <WCTChainCallProtocol>\n@required\n/**\n @brief Generate a `WCTMultiSelect` to do a cross table selection.\n */\n- (WCTMultiSelect *)prepareMultiSelect;\n@end\n\nWCDB_API @interface WCTChainCall : NSObject\n\n- (instancetype)init UNAVAILABLE_ATTRIBUTE;\n\n/**\n @brief Get the number of changed rows in the most recent call.\n It should be called after executing successfully.\n */\n- (int)getChanges;\n\n/**\n @brief The error generated by current statement.\n Since it is too cumbersome to get the error after every operation, it‘s better to use monitoring interfaces to obtain errors and print them to the log.\n @see   `[WCTDatabase globalTraceError:]`\n @see   `[WCTDatabase traceError:]`\n @return WCTError\n */\n- (WCTError *)error;\n\n@end\n\nNS_ASSUME_NONNULL_END\n"
  },
  {
    "path": "src/objc/chaincall/WCTChainCall.mm",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"WCTChainCall.h\"\n#import \"Assertion.hpp\"\n#import \"WCTChainCall+Private.h\"\n#import \"WCTHandle.h\"\n\n@implementation WCTChainCall\n\n- (instancetype)initWithHandle:(WCTHandle *)handle\n{\n    WCTAssert(handle != nil);\n    if (self = [super init]) {\n        _disposeAction = WCTChainCallDisposeActionFinalizeStatement;\n        _handle = handle;\n    }\n    return self;\n}\n\n- (WCTError *)error\n{\n    return _error;\n}\n\n- (int)getChanges\n{\n    return _changes;\n}\n\n- (instancetype)invalidateWhenDispose\n{\n    _disposeAction = WCTChainCallDisposeActionInvalidate;\n    return self;\n}\n\n- (instancetype)finalizeStatementWhenDispose\n{\n    _disposeAction = WCTChainCallDisposeActionFinalizeStatement;\n    return self;\n}\n\n- (void)saveChangesAndError:(BOOL)succeed\n{\n    if (succeed) {\n        _changes = [_handle getChanges];\n    } else {\n        _error = _handle.error;\n    }\n}\n\n- (void)tryDispose\n{\n    switch (_disposeAction) {\n    case WCTChainCallDisposeActionFinalizeStatement:\n        [_handle finalizeStatement];\n        break;\n    case WCTChainCallDisposeActionInvalidate: {\n        [_handle finalizeStatement];\n        [_handle invalidate];\n    } break;\n    }\n}\n\n@end\n"
  },
  {
    "path": "src/objc/chaincall/WCTDatabase+ChainCall.h",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"WCTChainCall.h\"\n#import \"WCTDatabase.h\"\n\nWCDB_API @interface WCTDatabase(ChainCall)<WCTCrossTableChainCallProtocol>\n\n@end\n"
  },
  {
    "path": "src/objc/chaincall/WCTDatabase+ChainCall.mm",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"WCTChainCall+Private.h\"\n#import \"WCTDatabase+ChainCall.h\"\n#import \"WCTDatabase+Handle.h\"\n#import \"WCTDelete.h\"\n#import \"WCTInsert.h\"\n#import \"WCTMultiSelect.h\"\n#import \"WCTSelect.h\"\n#import \"WCTUpdate.h\"\n\n@implementation WCTDatabase (ChainCall)\n\n- (WCTInsert *)prepareInsert\n{\n    return [[[WCTInsert alloc] initWithHandle:[self getHandle]] invalidateWhenDispose];\n}\n\n- (WCTDelete *)prepareDelete\n{\n    return [[[WCTDelete alloc] initWithHandle:[self getHandle]] invalidateWhenDispose];\n}\n\n- (WCTUpdate *)prepareUpdate\n{\n    return [[[WCTUpdate alloc] initWithHandle:[self getHandle]] invalidateWhenDispose];\n}\n\n- (WCTSelect *)prepareSelect\n{\n    return [[[WCTSelect alloc] initWithHandle:[self getHandle]] invalidateWhenDispose];\n}\n\n- (WCTMultiSelect *)prepareMultiSelect\n{\n    return [[[WCTMultiSelect alloc] initWithHandle:[self getHandle]] invalidateWhenDispose];\n}\n\n@end\n"
  },
  {
    "path": "src/objc/chaincall/WCTDelete.h",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"WCTChainCall.h\"\n\nNS_ASSUME_NONNULL_BEGIN\n\n/**\n Not Thread-safe\n */\nWCDB_API @interface WCTDelete : WCTChainCall\n\n/**\n @brief The statement that `WCTDelete` will execute.\n You can customize this statement directly to implement the capabilities not provided by the following methods.\n */\n- (WCDB::StatementDelete &)statement;\n\n/**\n @brief WINQ interface for SQL.\n @param tableName The name of the table to delete data from.\n @return self\n */\n- (instancetype)fromTable:(NSString *)tableName;\n\n/**\n @brief WINQ interface for SQL.\n @param condition condition\n @return self\n */\n- (instancetype)where:(const WCDB::Expression &)condition;\n\n/**\n @brief WINQ interface for SQL.\n @param orders order list\n @return self\n */\n- (instancetype)orders:(const WCDB::OrderingTerms &)orders;\n\n/**\n @brief WINQ interface for SQL.\n @param limit limit\n @return self\n */\n- (instancetype)limit:(const WCDB::Expression &)limit;\n\n/**\n @brief WINQ interface for SQL.\n @param offset offset\n @return self\n */\n- (instancetype)offset:(const WCDB::Expression &)offset;\n\n/**\n @brief Execute the delete SQL.\n @return YES if no error occurs.\n */\n- (BOOL)execute;\n\n@end\n\nNS_ASSUME_NONNULL_END\n"
  },
  {
    "path": "src/objc/chaincall/WCTDelete.mm",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"WCTDelete.h\"\n#import \"Assertion.hpp\"\n#import \"WCTChainCall+Private.h\"\n#import \"WCTHandle+Private.h\"\n#import \"WCTHandle.h\"\n#import \"WCTTryDisposeGuard.h\"\n\n@implementation WCTDelete {\n    WCDB::StatementDelete _statement;\n}\n\n- (instancetype)initWithHandle:(WCTHandle *)handle\n{\n    if (self = [super initWithHandle:handle]) {\n        [handle setWriteHint:YES];\n    }\n    return self;\n}\n\n- (WCDB::StatementDelete &)statement\n{\n    return _statement;\n}\n\n- (instancetype)fromTable:(NSString *)tableName\n{\n    _statement.deleteFrom(tableName);\n    return self;\n}\n\n- (instancetype)where:(const WCDB::Expression &)condition\n{\n    _statement.where(condition);\n    return self;\n}\n\n- (instancetype)orders:(const WCDB::OrderingTerms &)orders\n{\n    _statement.orders(orders);\n    return self;\n}\n\n- (instancetype)limit:(const WCDB::Expression &)limit\n{\n    _statement.limit(limit);\n    return self;\n}\n\n- (instancetype)offset:(const WCDB::Expression &)offset\n{\n    _statement.offset(offset);\n    return self;\n}\n\n- (BOOL)execute\n{\n    WCTTryDisposeGuard tryDisposeGuard(self);\n    bool succeed = [_handle execute:_statement];\n    [self saveChangesAndError:succeed];\n    return succeed;\n}\n\n@end\n"
  },
  {
    "path": "src/objc/chaincall/WCTHandle+ChainCall.h",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"WCTChainCall.h\"\n#import \"WCTHandle.h\"\n\nNS_ASSUME_NONNULL_BEGIN\n\nWCDB_API @interface WCTHandle(ChainCall)<WCTCrossTableChainCallProtocol>\n\n@end\n\nNS_ASSUME_NONNULL_END\n"
  },
  {
    "path": "src/objc/chaincall/WCTHandle+ChainCall.mm",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"WCTChainCall+Private.h\"\n#import \"WCTDelete.h\"\n#import \"WCTHandle+ChainCall.h\"\n#import \"WCTHandle+Private.h\"\n#import \"WCTInsert.h\"\n#import \"WCTMultiSelect.h\"\n#import \"WCTSelect.h\"\n#import \"WCTUpdate.h\"\n\n@implementation WCTHandle (ChainCall)\n\n- (WCTInsert *)prepareInsert\n{\n    return [[[WCTInsert alloc] initWithHandle:self] finalizeStatementWhenDispose];\n}\n\n- (WCTDelete *)prepareDelete\n{\n    return [[[WCTDelete alloc] initWithHandle:self] finalizeStatementWhenDispose];\n}\n\n- (WCTUpdate *)prepareUpdate\n{\n    return [[[WCTUpdate alloc] initWithHandle:self] finalizeStatementWhenDispose];\n}\n\n- (WCTSelect *)prepareSelect\n{\n    return [[[WCTSelect alloc] initWithHandle:self] finalizeStatementWhenDispose];\n}\n\n- (WCTMultiSelect *)prepareMultiSelect\n{\n    return [[[WCTMultiSelect alloc] initWithHandle:self] finalizeStatementWhenDispose];\n}\n\n@end\n"
  },
  {
    "path": "src/objc/chaincall/WCTInsert.h",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"WCTChainCall.h\"\n\nNS_ASSUME_NONNULL_BEGIN\n\n// TODO: implement insertOrUpdate through upsert feature\n/**\n Not Thread-safe\n */\nWCDB_API @interface WCTInsert<ObjectType> : WCTChainCall\n\n/**\n @brief The statement that `WCTInsert` will execute.\n You can customize this statement directly to implement the capabilities not provided by the following methods.\n */\n- (WCDB::StatementInsert &)statement;\n\n/**\n @brief WINQ interface for SQL.\n @return self\n */\n- (instancetype)orReplace;\n\n/**\n @brief WINQ interface for SQL.\n @return self\n */\n- (instancetype)orIgnore;\n\n/**\n @brief WINQ interface for SQL.\n @param tableName The name of the table to insert objects to.\n @return self\n */\n- (instancetype)intoTable:(NSString *)tableName;\n\n/**\n @brief WINQ interface for SQL.\n @param properties Do a partial insertion with the specific properties.\n @return self\n */\n- (instancetype)onProperties:(const WCTProperties &)properties;\n\n/**\n @brief Insert an array of objects.\n @param objects Objects to be inserted into table.\n @return self.\n */\n- (instancetype)values:(NSArray<ObjectType> *)objects;\n\n/**\n @brief Insert one object.\n @param object Object to be inserted into table.\n @return self.\n */\n- (instancetype)value:(ObjectType)object;\n\n/**\n @brief Execute the insert statement.\n        Note that it will run embedded transaction while objects.count>1 .\n        The embedded transaction means that it will run a transaction if it's not in other transaction, otherwise it will be executed within the existing transaction.\n @return YES if no error occurs.\n */\n- (BOOL)execute;\n\n@end\n\nNS_ASSUME_NONNULL_END\n"
  },
  {
    "path": "src/objc/chaincall/WCTInsert.mm",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"WCTInsert.h\"\n#import \"Assertion.hpp\"\n#import \"CaseInsensitiveList.hpp\"\n#import \"WCTChainCall+Private.h\"\n#import \"WCTHandle+Private.h\"\n#import \"WCTHandle+Transaction.h\"\n#import \"WCTHandle.h\"\n#import \"WCTORM.h\"\n#import \"WCTTryDisposeGuard.h\"\n\n@implementation WCTInsert {\n    WCTProperties _properties;\n    WCDB::StatementInsert _statement;\n    NSArray<WCTObject *> *_values;\n}\n\n- (instancetype)initWithHandle:(WCTHandle *)handle\n{\n    if (self = [super initWithHandle:handle]) {\n        [handle setWriteHint:YES];\n    }\n    return self;\n}\n\n- (WCDB::StatementInsert &)statement\n{\n    return _statement;\n}\n\n- (instancetype)orReplace\n{\n    _statement.orReplace();\n    return self;\n}\n\n- (instancetype)orIgnore\n{\n    _statement.orIgnore();\n    return self;\n}\n\n- (instancetype)intoTable:(NSString *)tableName\n{\n    _statement.insertIntoTable(tableName);\n    return self;\n}\n\n- (instancetype)onProperties:(const WCTProperties &)properties\n{\n    _properties = properties;\n    _statement.columns(properties)\n    .values(WCDB::BindParameter::bindParameters(properties.size()));\n    return self;\n}\n\n- (instancetype)values:(NSArray<WCTObject *> *)objects\n{\n    _values = objects;\n    return self;\n}\n\n- (instancetype)value:(WCTObject *)object\n{\n    return [self values:object != nil ? @[ object ] : nil];\n}\n\n- (BOOL)execute\n{\n    WCTTryDisposeGuard tryDisposeGuard(self);\n    BOOL succeed = YES;\n    if (_values.count > 0) {\n        if (_values.count > 1) {\n            succeed = [_handle lazyRunTransaction:^BOOL(WCTHandle *handle) {\n                WCDB_UNUSED(handle);\n                return [self realExecute];\n            }];\n        } else {\n            succeed = [self realExecute];\n        }\n        [self saveChangesAndError:succeed];\n    }\n    return succeed;\n}\n\n- (BOOL)realExecute\n{\n    Class cls = _values.firstObject.class;\n    if (_properties.empty()) {\n        _properties = [cls allProperties];\n    }\n\n    if (_statement.syntax().columns.empty()) {\n        _statement\n        .columns(_properties)\n        .values(WCDB::BindParameter::bindParameters(_properties.size()));\n    }\n\n    std::vector<BOOL> autoIncrementsOfDefinitions;\n    if (!_statement.syntax().conflictActionValid()) {\n        const auto &columnDefs = [cls objectRelationalMapping].getColumnDefs();\n        for (const WCTProperty &property : _properties) {\n            // auto increment?\n            auto iter = columnDefs.caseInsensitiveFind(property.getDescription());\n            WCTRemedialAssert(iter != columnDefs.end(), \"Related property is not found.\", return NO;);\n            autoIncrementsOfDefinitions.push_back(iter->second.syntax().isAutoIncrement());\n        }\n    }\n\n    WCDB::Optional<BOOL> respondsToSetLastInsertedRowID;\n    WCDB::Optional<BOOL> respondsToIsAutoIncrement;\n\n    BOOL succeed = NO;\n    if ([_handle prepare:_statement]) {\n        succeed = YES;\n\n        for (WCTObject *value in _values) {\n            [_handle reset];\n            int index = 1;\n\n            for (const WCTProperty &property : _properties) {\n                WCTAssert(autoIncrementsOfDefinitions.empty()\n                          || autoIncrementsOfDefinitions.size() == _properties.size());\n                if (autoIncrementsOfDefinitions.empty() || !autoIncrementsOfDefinitions[index - 1]) {\n                    [_handle bindProperty:property\n                                 ofObject:value\n                                  toIndex:index];\n                } else {\n                    if (!respondsToIsAutoIncrement.succeed()) {\n                        respondsToIsAutoIncrement = [value respondsToSelector:@selector(isAutoIncrement)];\n                    }\n                    WCTAssert(respondsToIsAutoIncrement.succeed());\n\n                    BOOL isAutoIncrement = NO;\n                    if (respondsToIsAutoIncrement.value()) {\n                        isAutoIncrement = value.isAutoIncrement;\n                    }\n                    NSAssert(!isAutoIncrement || !_statement.syntax().conflictActionValid(),\n                             @\"Auto-increment inserts do not support conflict action!\");\n                    if (isAutoIncrement) {\n                        [_handle bindNullToIndex:index];\n                    } else {\n                        [_handle bindProperty:property\n                                     ofObject:value\n                                      toIndex:index];\n                    }\n                }\n                ++index;\n            }\n            if (![_handle step]) {\n                succeed = NO;\n                break;\n            }\n\n            // setup last inserted rowid\n            if (!respondsToSetLastInsertedRowID.succeed()) {\n                respondsToSetLastInsertedRowID = [value respondsToSelector:@selector(setLastInsertedRowID:)];\n            }\n            WCTAssert(respondsToSetLastInsertedRowID.succeed());\n            if (respondsToSetLastInsertedRowID.value()) {\n                [value setLastInsertedRowID:[_handle getLastInsertedRowID]];\n            }\n        }\n        [_handle finalizeStatement];\n    }\n    WCTAssert(![_handle isPrepared]);\n    return succeed;\n}\n\n@end\n"
  },
  {
    "path": "src/objc/chaincall/WCTMultiSelect.h",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"WCTSelectable.h\"\n\nNS_ASSUME_NONNULL_BEGIN\n\n/**\n Not Thread-safe\n */\nWCDB_API @interface WCTMultiSelect : WCTSelectable\n\n/**\n @brief WINQ interface for SQL.\n @param tableNames The names of the tables to query data from.\n @return self\n */\n- (instancetype)fromTables:(NSArray<NSString *> *)tableNames;\n\n/**\n @brief WINQ interface for SQL.\n @param resultColumns The column results to be selected.\n @return self\n */\n- (instancetype)onResultColumns:(const WCTResultColumns &)resultColumns;\n\n/**\n @brief Get first selected objects.\n \n     WCTMultiObject* multiObject = [multiSelect firstMultiObject];\n     Class1* object1 = [multiObject objectForKey:tableName1];\n     Class2* object2 = [multiObject objectForKey:tableName2];\n\n @return See the example above\n */\n- (nullable WCTMultiObject *)firstMultiObject;\n\n/**\n @brief Get all selected objects. \n @return Array with all selected objects.\n */\n- (nullable NSArray<WCTMultiObject *> *)allMultiObjects;\n\n@end\n\nNS_ASSUME_NONNULL_END\n"
  },
  {
    "path": "src/objc/chaincall/WCTMultiSelect.mm",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"WCTMultiSelect.h\"\n#import \"Assertion.hpp\"\n#import \"WCTChainCall+Private.h\"\n#import \"WCTHandle+Private.h\"\n#import \"WCTHandle.h\"\n#import \"WCTORM.h\"\n#import \"WCTSelectable+Private.h\"\n#import \"WCTTryDisposeGuard.h\"\n\n@implementation WCTMultiSelect {\n    WCTResultColumns _resultColumns;\n}\n\n- (instancetype)fromTables:(NSArray<NSString *> *)tableNames\n{\n    WCTRemedialAssert(tableNames != nil, @\"Table names can't be null.\", return self;);\n    WCDB::TablesOrSubqueries tables;\n    for (NSString *tableName in tableNames) {\n        tables.push_back(tableName);\n    }\n    _statement.from(tables);\n    return self;\n}\n\n- (instancetype)onResultColumns:(const WCTResultColumns &)resultColumns\n{\n    _resultColumns = resultColumns;\n    _statement.select(resultColumns);\n    return self;\n}\n\n- (WCTMultiObject *)firstMultiObject\n{\n    WCTTryDisposeGuard tryDisposeGuard(self);\n    if (![self lazyPrepare]) {\n        [self saveChangesAndError:false];\n        return nil;\n    }\n    BOOL succeed = false;\n    if (!(succeed = [_handle step]) || [_handle done]) {\n        [self saveChangesAndError:succeed];\n        return nil;\n    }\n    [self saveChangesAndError:succeed];\n    return [_handle extractMultiObjectOnResultColumns:_resultColumns];\n}\n\n- (NSArray<WCTMultiObject *> *)allMultiObjects\n{\n    WCTTryDisposeGuard tryDisposeGuard(self);\n    if (![self lazyPrepare]) {\n        [self saveChangesAndError:false];\n        return nil;\n    }\n    NSArray<WCTMultiObject *> *results = [_handle allMultiObjectsOnResultColumns:_resultColumns];\n    [self saveChangesAndError:results != nil];\n    return results;\n}\n\n@end\n"
  },
  {
    "path": "src/objc/chaincall/WCTSelect.h",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"WCTSelectable.h\"\n\nNS_ASSUME_NONNULL_BEGIN\n/**\n Not Thread-safe\n */\nWCDB_API @interface WCTSelect<ObjectType> : WCTSelectable\n\n/**\n @brief WINQ interface for SQL.\n @param tableName The name of the table to query data from.\n @return self\n */\n- (instancetype)fromTable:(NSString *)tableName;\n\n/**\n @brief WINQ interface for SQL.\n @param resultColumns The column results to be selected.\n @return self\n */\n- (instancetype)onResultColumns:(const WCTResultColumns &)resultColumns;\n\n/**\n @brief WINQ interface for SQL.\n @param cls The class of the object to be selected.\n @return self\n */\n- (instancetype)ofClass:(Class)cls;\n\n/**\n @brief Get first selected object.\n \n @return The real type of WCTObject depends on your selection and ORM.\n */\n- (nullable ObjectType)firstObject;\n\n/**\n @brief Get all selected objects.\n @return The NSArray collection of WCTObject.\n         The real type of WCTObject depends on your selection and ORM.\n */\n- (nullable NSArray<ObjectType> *)allObjects;\n\n@end\n\nNS_ASSUME_NONNULL_END\n"
  },
  {
    "path": "src/objc/chaincall/WCTSelect.mm",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"WCTSelect.h\"\n#import \"Assertion.hpp\"\n#import \"WCTChainCall+Private.h\"\n#import \"WCTHandle.h\"\n#import \"WCTORM.h\"\n#import \"WCTSelectable+Private.h\"\n#import \"WCTTryDisposeGuard.h\"\n\n@implementation WCTSelect {\n    WCTResultColumns _resultColumns;\n    Class<WCTTableCoding> m_class;\n}\n\n- (void)willPrepare:(WCDB::StatementSelect &)statement\n{\n    if (statement.syntax().orderingTerms.empty()) {\n        WCTAssert(m_class != nil && [m_class respondsToSelector:@selector(objectRelationalMapping)]);\n        const WCTBinding &binding = [m_class objectRelationalMapping];\n        const WCDB::StatementCreateTable &createTable = binding.statementTable;\n        if (!createTable.syntax().withoutRowid) {\n            statement.order(WCDB::OrderingTerm::ascendingRowid());\n        }\n    }\n}\n\n- (instancetype)fromTable:(NSString *)tableName\n{\n    _statement.from(tableName);\n    return self;\n}\n\n- (instancetype)onResultColumns:(const WCTResultColumns &)resultColumns\n{\n    m_class = resultColumns.front().getColumnBinding().getClass();\n    _resultColumns = resultColumns;\n    _statement.select(_resultColumns);\n    return self;\n}\n\n- (instancetype)ofClass:(Class)cls\n{\n    return [self onResultColumns:[cls allProperties]];\n}\n\n- (NSArray /* <WCTObject*> */ *)allObjects\n{\n    WCTTryDisposeGuard tryDisposeGuard(self);\n    if (![self lazyPrepare]) {\n        [self saveChangesAndError:NO];\n        return nil;\n    }\n    NSArray *objects = [_handle allObjectsOnResultColumns:_resultColumns];\n    [self saveChangesAndError:objects != nil];\n    return objects;\n}\n\n- (id /* WCTObject* */)firstObject\n{\n    WCTTryDisposeGuard tryDisposeGuard(self);\n    if (![self lazyPrepare]) {\n        [self saveChangesAndError:NO];\n        return nil;\n    }\n    BOOL succeed = false;\n    if (!(succeed = [_handle step]) || [_handle done]) {\n        [self saveChangesAndError:succeed];\n        return nil;\n    }\n    [self saveChangesAndError:succeed];\n    return [_handle extractObjectOnResultColumns:_resultColumns];\n}\n\n@end\n"
  },
  {
    "path": "src/objc/chaincall/WCTSelectable+Private.h",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"WCTSelectable.h\"\n\nWCDB_API @interface WCTSelectable() {\n@protected\n    WCDB::StatementSelect _statement;\n}\n\n- (BOOL)lazyPrepare;\n\n- (void)willPrepare:(WCDB::StatementSelect &)statement;\n\n@end\n"
  },
  {
    "path": "src/objc/chaincall/WCTSelectable.h",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"WCTChainCall.h\"\n\nNS_ASSUME_NONNULL_BEGIN\n/**\n Not Thread-safe\n */\nWCDB_API @interface WCTSelectable : WCTChainCall\n\n/**\n The statement will be executed.\n You can customize this statement directly to implement the capabilities not provided by the following methods.\n */\n- (WCDB::StatementSelect &)statement;\n\n/**\n @brief WINQ interface for SQL.\n @param condition condition\n @return self\n */\n- (instancetype)where:(const WCDB::Expression &)condition;\n\n/**\n @brief WINQ interface for SQL.\n @param orders order list\n @return self\n */\n- (instancetype)orders:(const WCDB::OrderingTerms &)orders;\n\n/**\n @brief WINQ interface for SQL.\n @param limit limit\n @return self\n */\n- (instancetype)limit:(const WCDB::Expression &)limit;\n\n/**\n @brief WINQ interface for SQL.\n @param offset offset\n @return self\n */\n- (instancetype)offset:(const WCDB::Expression &)offset;\n\n@end\n\nNS_ASSUME_NONNULL_END\n"
  },
  {
    "path": "src/objc/chaincall/WCTSelectable.mm",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"WCTChainCall+Private.h\"\n#import \"WCTHandle+Private.h\"\n#import \"WCTHandle.h\"\n#import \"WCTSelectable+Private.h\"\n\n@implementation WCTSelectable\n\n- (instancetype)initWithHandle:(WCTHandle *)handle\n{\n    if (self = [super initWithHandle:handle]) {\n        [handle setWriteHint:NO];\n    }\n    return self;\n}\n\n- (WCDB::StatementSelect &)statement\n{\n    return _statement;\n}\n\n- (BOOL)lazyPrepare\n{\n    if (![_handle isPrepared]) {\n        [self willPrepare:_statement];\n        return [_handle prepare:_statement];\n    }\n    return YES;\n}\n\n- (void)willPrepare:(WCDB::StatementSelect &)statement\n{\n    WCDB_UNUSED(statement);\n}\n\n- (instancetype)where:(const WCDB::Expression &)condition\n{\n    _statement.where(condition);\n    return self;\n}\n\n- (instancetype)orders:(const WCDB::OrderingTerms &)orders\n{\n    _statement.orders(orders);\n    return self;\n}\n\n- (instancetype)limit:(const WCDB::Expression &)limit\n{\n    _statement.limit(limit);\n    return self;\n}\n\n- (instancetype)offset:(const WCDB::Expression &)offset\n{\n    _statement.offset(offset);\n    return self;\n}\n\n@end\n"
  },
  {
    "path": "src/objc/chaincall/WCTTable+ChainCall.h",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"WCTChainCall.h\"\n#import \"WCTTable.h\"\n\n/**\n Thread-safe\n */\nWCDB_API @interface WCTTable(ChainCall)<WCTChainCallProtocol>\n\n@end\n"
  },
  {
    "path": "src/objc/chaincall/WCTTable+ChainCall.mm",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"WCTChainCall+Private.h\"\n#import \"WCTDatabase+Handle.h\"\n#import \"WCTDelete.h\"\n#import \"WCTInsert.h\"\n#import \"WCTMultiSelect.h\"\n#import \"WCTORM.h\"\n#import \"WCTSelect.h\"\n#import \"WCTTable+ChainCall.h\"\n#import \"WCTTable+Private.h\"\n#import \"WCTUpdate.h\"\n\n@implementation WCTTable (ChainCall)\n\n- (WCTInsert *)prepareInsert\n{\n    return [[[[WCTInsert alloc] initWithHandle:[_database getHandle]] intoTable:_tableName] invalidateWhenDispose];\n}\n\n- (WCTDelete *)prepareDelete\n{\n    return [[[[WCTDelete alloc] initWithHandle:[_database getHandle]] fromTable:_tableName] invalidateWhenDispose];\n}\n\n- (WCTUpdate *)prepareUpdate\n{\n    return [[[[WCTUpdate alloc] initWithHandle:[_database getHandle]] table:_tableName] invalidateWhenDispose];\n}\n\n- (WCTSelect *)prepareSelect\n{\n    return [[[[[WCTSelect alloc] initWithHandle:[_database getHandle]] fromTable:_tableName] ofClass:_tableClass] invalidateWhenDispose];\n}\n\n@end\n"
  },
  {
    "path": "src/objc/chaincall/WCTTryDisposeGuard.h",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"WCTChainCall.h\"\n\nclass WCTTryDisposeGuard final {\npublic:\n    WCTTryDisposeGuard(WCTChainCall* chaincall);\n    ~WCTTryDisposeGuard();\n\n    WCTTryDisposeGuard() = delete;\n    WCTTryDisposeGuard(const WCTTryDisposeGuard&) = delete;\n    WCTTryDisposeGuard& operator=(const WCTTryDisposeGuard&) = delete;\n\nprivate:\n    WCTChainCall* m_chaincall;\n};\n"
  },
  {
    "path": "src/objc/chaincall/WCTTryDisposeGuard.mm",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"WCTTryDisposeGuard.h\"\n#import \"Assertion.hpp\"\n#import \"WCTChainCall+Private.h\"\n\nWCTTryDisposeGuard::WCTTryDisposeGuard(WCTChainCall* chaincall)\n: m_chaincall(chaincall)\n{\n    WCTAssert(m_chaincall != nil);\n}\n\nWCTTryDisposeGuard::~WCTTryDisposeGuard()\n{\n    [m_chaincall tryDispose];\n    m_chaincall = nil;\n}\n"
  },
  {
    "path": "src/objc/chaincall/WCTUpdate.h",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"WCTChainCall.h\"\n\nNS_ASSUME_NONNULL_BEGIN\n\n/**\n Not Thread-safe\n */\nWCDB_API @interface WCTUpdate<ObjectType> : WCTChainCall\n\n/**\n @brief The statement that `WCTUpdate` will execute.\n You can customize this statement directly to implement the capabilities not provided by the following methods.\n */\n- (WCDB::StatementUpdate &)statement;\n\n/**\n @brief WINQ interface for SQL.\n @param tableName The name of the table to update content.\n @return self\n */\n- (instancetype)table:(NSString *)tableName;\n\n/**\n @brief WINQ interface for SQL.\n @param properties The properties used to specify the columns where data is updated.\n @return self\n */\n- (instancetype)set:(const WCTProperties &)properties;\n\n/**\n @brief WINQ interface for SQL.\n @param condition condition\n @return self\n */\n- (instancetype)where:(const WCDB::Expression &)condition;\n\n/**\n @brief WINQ interface for SQL.\n @param orders order list\n @return self\n */\n- (instancetype)orders:(const WCDB::OrderingTerms &)orders;\n\n/**\n @brief WINQ interface for SQL.\n @param limit limit\n @return self\n */\n- (instancetype)limit:(const WCDB::Expression &)limit;\n\n/**\n @brief WINQ interface for SQL.\n @param offset offset\n @return self\n */\n- (instancetype)offset:(const WCDB::Expression &)offset;\n\n/**\n @brief Execute the update statement with one object.\n @param object Object to be updated into table.\n @return self.\n */\n- (instancetype)toObject:(ObjectType)object;\n\n/**\n @brief Execute the update statement with one value.\n @param value Value to be updated into table.\n @return self.\n */\n- (instancetype)toValue:(WCTColumnCodingValue *)value;\n\n/**\n @brief Execute the update statement with one row of value.\n @param row The row to be updated into table.\n @return self.\n */\n- (instancetype)toRow:(WCTColumnCodingRow *)row;\n\n/**\n @brief Execute the update statement.\n @return YES if no error occurs.\n */\n- (BOOL)execute;\n\n@end\n\nNS_ASSUME_NONNULL_END\n"
  },
  {
    "path": "src/objc/chaincall/WCTUpdate.mm",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"WCTUpdate.h\"\n#import \"Assertion.hpp\"\n#import \"WCTChainCall+Private.h\"\n#import \"WCTHandle+Private.h\"\n#import \"WCTHandle.h\"\n#import \"WCTORM.h\"\n#import \"WCTTryDisposeGuard.h\"\n\ntypedef NS_ENUM(NSUInteger, WCTUpdateType) {\n    WCTUpdateTypeObject,\n    WCTUpdateTypeValue,\n    WCTUpdateTypeRow,\n};\n\n@implementation WCTUpdate {\n    WCDB::StatementUpdate _statement;\n    WCTProperties _properties;\n\n    WCTUpdateType _type;\n    NSObject *_value;\n}\n\n- (instancetype)initWithHandle:(WCTHandle *)handle\n{\n    if (self = [super initWithHandle:handle]) {\n        [handle setWriteHint:YES];\n    }\n    return self;\n}\n\n- (WCDB::StatementUpdate &)statement\n{\n    return _statement;\n}\n\n- (instancetype)table:(NSString *)tableName\n{\n    _statement.update(tableName);\n    return self;\n}\n\n- (instancetype)set:(const WCTProperties &)properties\n{\n    _properties = properties;\n    int bindParameterIndex = 1;\n    for (const WCTProperty &property : properties) {\n        _statement.set(property).to(WCDB::BindParameter(bindParameterIndex));\n        ++bindParameterIndex;\n    }\n    return self;\n}\n\n- (instancetype)where:(const WCDB::Expression &)condition\n{\n    _statement.where(condition);\n    return self;\n}\n\n- (instancetype)orders:(const WCDB::OrderingTerms &)orders\n{\n    _statement.orders(orders);\n    return self;\n}\n\n- (instancetype)limit:(const WCDB::Expression &)limit\n{\n    _statement.limit(limit);\n    return self;\n}\n\n- (instancetype)offset:(const WCDB::Expression &)offset\n{\n    _statement.offset(offset);\n    return self;\n}\n\n- (instancetype)toObject:(WCTObject *)object\n{\n    _type = WCTUpdateTypeObject;\n    _value = object;\n    return self;\n}\n\n- (instancetype)toValue:(WCTColumnCodingValue *)value\n{\n    _type = WCTUpdateTypeValue;\n    _value = value;\n    return self;\n}\n\n- (instancetype)toRow:(WCTColumnCodingRow *)row\n{\n    _type = WCTUpdateTypeRow;\n    _value = row;\n    return self;\n}\n\n- (BOOL)execute\n{\n    WCTTryDisposeGuard tryDisposeGuard(self);\n    BOOL result = YES;\n    if (_value != nil) {\n        result = NO;\n        if ([_handle prepare:_statement]) {\n            switch (_type) {\n            case WCTUpdateTypeValue: {\n                WCTColumnCodingValue *value = (WCTColumnCodingValue *) _value;\n                [_handle bindValue:value toIndex:1];\n                break;\n            }\n            case WCTUpdateTypeObject: {\n                WCTObject *object = (WCTObject *) _value;\n                [_handle bindProperties:_properties ofObject:object];\n                break;\n            }\n            case WCTUpdateTypeRow: {\n                WCTColumnCodingRow *row = (WCTColumnCodingRow *) _value;\n                int index = 1;\n                for (WCTColumnCodingValue *value in row) {\n                    [_handle bindValue:value toIndex:index];\n                    ++index;\n                }\n                break;\n            }\n            }\n            result = [_handle step];\n        }\n        [self saveChangesAndError:result];\n    }\n    return result;\n}\n\n@end\n"
  },
  {
    "path": "src/objc/compression/WCTCompressionInfo+Private.h",
    "content": "//\n// Created by qiuwenchen on 2023/12/2.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"CommonCore.h\"\n#import \"WCTCompressionInfo.h\"\n\nNS_ASSUME_NONNULL_BEGIN\n\n@interface WCTCompressionBaseInfo () {\n@protected\n    const WCDB::CompressionTableBaseInfo* m_baseInfo;\n}\n\n- (instancetype)initWithBaseInfo:(const WCDB::CompressionTableBaseInfo&)info;\n\n@end\n\n@interface WCTCompressionUserInfo () {\n@protected\n    WCDB::CompressionTableUserInfo* m_userInfo;\n}\n\n- (instancetype)initWithUserInfo:(WCDB::CompressionTableUserInfo&)info;\n\n@end\n\nNS_ASSUME_NONNULL_END\n"
  },
  {
    "path": "src/objc/compression/WCTCompressionInfo.h",
    "content": "//\n// Created by qiuwenchen on 2023/12/2.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"WCTCommon.h\"\n\nNS_ASSUME_NONNULL_BEGIN\n\ntypedef unsigned char WCTDictId;\n\n#define WCTDictDefaultMatchValue INT64_MAX\n\nWCDB_API @interface WCTCompressionBaseInfo : NSObject\n\n- (instancetype)init UNAVAILABLE_ATTRIBUTE;\n\n// The table to be compressed\n@property (nonatomic, readonly) NSString *table;\n\n@end\n\nWCDB_API @interface WCTCompressionUserInfo : WCTCompressionBaseInfo\n\n/**\n @brief Configure to compress all data in the specified column with the default zstd compression algorithm.\n */\n- (void)addZSTDNormalCompressProperty:(const WCTProperty &)property;\n\n/**\n @brief Configure to compress all data in the specified column with a registered zstd dict.\n */\n- (void)addZSTDDictCompressProperty:(const WCTProperty &)property\n                         withDictId:(WCTDictId)dictId;\n\n/**\n @brief Configure to compress all data in the specified column with multi registered zstd dict.\n Which dict to use when compressing is based on the value of the specified matching column.\n @note You can use `WCTDictDefaultMatchValue` to specify a default dict.\n @warning The matching column must be an integer column.\n */\n- (void)addZSTDDictCompressProperty:(const WCTProperty &)property\n                  withMatchProperty:(const WCTProperty &)matchProperty\n                      andMatchDicts:(NSDictionary<NSNumber * /* Value of match column */, NSNumber * /* ID of dict */> *)dictIds;\n\n/**\n @brief Enable to replace original compression format.\n After activation, you can use `-[WCTDatabase stepCompression]` or `-[WCTDatabase enableAutoCompression:]` to recompress the existing data with the new compression configuration.\n */\n- (void)enableReplaceCompression;\n@end\n\nNS_ASSUME_NONNULL_END\n"
  },
  {
    "path": "src/objc/compression/WCTCompressionInfo.mm",
    "content": "//\n// Created by qiuwenchen on 2023/12/2.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"WCTCompressionInfo+Private.h\"\n#import \"WCTProperty.h\"\n#import <Foundation/Foundation.h>\n\n@implementation WCTCompressionBaseInfo\n\n- (instancetype)initWithBaseInfo:(const WCDB::CompressionTableBaseInfo &)info\n{\n    if (self = [super init]) {\n        m_baseInfo = &info;\n    }\n    return self;\n}\n\n- (NSString *)table\n{\n    const WCDB::StringView &table = m_baseInfo->getTable();\n    return [[NSString alloc] initWithBytes:table.data() length:table.length() encoding:NSUTF8StringEncoding];\n}\n\n@end\n\n@implementation WCTCompressionUserInfo\n\n- (instancetype)initWithUserInfo:(WCDB::CompressionTableUserInfo &)info\n{\n    if (self = [super initWithBaseInfo:info]) {\n        m_userInfo = &info;\n    }\n    return self;\n}\n\n- (void)addZSTDNormalCompressProperty:(const WCTProperty &)property\n{\n    WCDB::CompressionColumnInfo columnInfo(property, WCDB::CompressionType::Normal);\n    m_userInfo->addCompressingColumn(columnInfo);\n}\n\n- (void)addZSTDDictCompressProperty:(const WCTProperty &)property\n                         withDictId:(WCTDictId)dictId\n{\n    WCDB::CompressionColumnInfo columnInfo(property, WCDB::CompressionType::Dict);\n    columnInfo.setCommonDict(dictId);\n    m_userInfo->addCompressingColumn(columnInfo);\n}\n\n- (void)addZSTDDictCompressProperty:(const WCTProperty &)property withMatchProperty:(const WCTProperty &)matchProperty andMatchDicts:(nonnull NSDictionary<NSNumber *, NSNumber *> *)dictIds\n{\n    if (dictIds.count == 0) {\n        return;\n    }\n    __block WCDB::CompressionColumnInfo columnInfo(property, matchProperty);\n    [dictIds enumerateKeysAndObjectsUsingBlock:^(NSNumber *value, NSNumber *id_, BOOL *) {\n        uint64_t matchValue = value.unsignedLongLongValue;\n        WCTDictId dictId = id_.unsignedCharValue;\n        if (matchValue == WCTDictDefaultMatchValue) {\n            columnInfo.setCommonDict(dictId);\n        } else {\n            columnInfo.addMatchDict(matchValue, dictId);\n        }\n    }];\n    m_userInfo->addCompressingColumn(columnInfo);\n}\n\n- (void)enableReplaceCompression\n{\n    m_userInfo->enableReplaceCompresssion();\n}\n\n@end\n"
  },
  {
    "path": "src/objc/compression/WCTDatabase+Compression.h",
    "content": "//\n// Created by qiuwenchen on 2023/12/2.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"WCTCompressionInfo.h\"\n#import \"WCTDatabase.h\"\n\nNS_ASSUME_NONNULL_BEGIN\n\n/**\n Triggered at any time when WCDB needs to know whether a table in the current database needs to compress data,\n mainly including creating a new table, reading and writing a table,and starting to compress a new table.\n If the current table does not need to compress data, you don't need to config `WCTCompressionUserInfo`.\n */\ntypedef void (^WCTCompressionFilterBlock)(WCTCompressionUserInfo*);\n\ntypedef unsigned char WCTDictId;\n\n/**\n Triggered when a table is compressed completely.\n When a table is compressed successfully, tableInfo will carry the information of the table.\n When a database is totally compressed, tableInfo will be nil.\n */\ntypedef void (^WCTCompressdNotificationBlock)(WCTDatabase* _Nonnull database, WCTCompressionBaseInfo* _Nullable tableInfo);\n\nWCDB_API @interface WCTDatabase(Compression)\n\n/**\n @brief Train a zstd formalized dict with a set of sample strings.\n @Warning The total size of all samples cannot exceed 4G.\n @param strings samples.\n @param dictId spercified id of the result dict. It can not be zero.\n @return a dict of 100KB if succeed.\n */\n+ (NSData*)trainDictWithStrings:(NSArray<NSString*>*)strings andDictId:(WCTDictId)dictId;\n\n/**\n @brief Train a zstd formalized dict with a set of sample datas.\n @Warning The total size of all samples cannot exceed 4G.\n @param datas samples.\n @param dictId spercified id of the result dict. It can not be zero.\n @return a dict of 100KB if succeed.\n */\n+ (NSData*)trainDictWithDatas:(NSArray<NSData*>*)datas andDictId:(WCTDictId)dictId;\n\n/**\n @brief Register a zstd dict in to WCDB.\n @Note You must register a dict before using it.\n @param dict dict data.\n @param dictId id of the dict. It can not be zero.\n @return YES if the dictionary can be successfully decoded and the dictId does not conflict with a registered dict.\n */\n+ (BOOL)registerZSTDDict:(NSData*)dict andDictId:(WCTDictId)dictId;\n\n/**\n @brief Configure which tables in the current database need to compress data.\n Once configured, newly written data will be compressed immediately and synchronously,\n and you can use `-[WCTDatabase stepCompression]` and `-[WCTDatabase enableAutoCompression:]` to compress existing data.\n @see   `WCTCompressionFilterBlock`\n */\n- (void)setCompressionWithFilter:(nullable WCDB_ESCAPE WCTCompressionFilterBlock)filter;\n\n/**\n @brief Configure not to compress new data written to the current database.\n This configuration is mainly used to deal with some emergency scenarios.\n It allows already compressed data to be read normally, but new data is no longer compressed.\n @param disable disable compression or not.\n */\n- (void)disableCompresssNewData:(BOOL)disable;\n\n/**\n @brief Manually compress 100 rows of existing data.\n You can call this method periodically until all data is compressed.\n @return YES if no error occurred.\n */\n- (BOOL)stepCompression;\n\n/**\n @brief Configure the database to automatically compress 100 rows of existing data every two seconds.\n @param flag to enable auto-compression.\n */\n- (void)enableAutoCompression:(BOOL)flag;\n\n/**\n @brief Register a callback for compression notification. The callback will be called when each table completes the compression.\n @param onCompressd block\n @see   `WCTCompressdNotificationBlock`\n */\n- (void)setNotificationWhenCompressed:(nullable WCDB_ESCAPE WCTCompressdNotificationBlock)onCompressd;\n\n/**\n @brief Check if all tables in the database has finished compression.\n @note  It only check an internal flag of database.\n @return YES if all tables in the database has finished compression.\n */\n- (BOOL)isCompressed;\n\n/**\n @brief Decompress all compressed data in the database and resave them.\n @note  It will clear all compression status and progress, and disables automatic compression.\n @warning If the rollback process is interrupted or failed, the data may be in a mixed state of compressed and uncompressed.\n @return YES if all operation succeed.\n */\n- (BOOL)rollbackCompression:(nullable WCDB_ESCAPE WCTProgressUpdateBlock)onProgressUpdated;\n\n@end\n\nNS_ASSUME_NONNULL_END\n"
  },
  {
    "path": "src/objc/compression/WCTDatabase+Compression.mm",
    "content": "//\n// Created by qiuwenchen on 2023/12/2.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"CompressionCenter.hpp\"\n#import \"CompressionConst.hpp\"\n#import \"CoreConst.h\"\n#import \"WCTCompressionInfo+Private.h\"\n#import \"WCTDatabase+Compression.h\"\n#import \"WCTDatabase+Private.h\"\n#import <Foundation/Foundation.h>\n\n@implementation WCTDatabase (Compression)\n\n+ (NSData*)trainDictWithStrings:(NSArray<NSString*>*)strings andDictId:(WCTDictId)dictId\n{\n    int index = 0;\n    auto dict = WCDB::CompressionCenter::shared().trainDict(dictId, [&]() -> WCDB::Optional<WCDB::UnsafeData> {\n        if (index < strings.count) {\n            NSString* string = [strings objectAtIndex:index];\n            index++;\n            return WCDB::UnsafeData((unsigned char*) string.UTF8String, [string lengthOfBytesUsingEncoding:NSUTF8StringEncoding]);\n        } else {\n            return WCDB::NullOpt;\n        }\n    });\n    if (dict.hasValue()) {\n        return [[NSData alloc] initWithBytes:dict->buffer() length:dict->size()];\n    }\n    return nil;\n}\n\n+ (NSData*)trainDictWithDatas:(NSArray<NSData*>*)datas andDictId:(WCTDictId)dictId\n{\n    int index = 0;\n    auto dict = WCDB::CompressionCenter::shared().trainDict(dictId, [&]() -> WCDB::Optional<WCDB::UnsafeData> {\n        if (index < datas.count) {\n            NSData* data = [datas objectAtIndex:index];\n            index++;\n            return WCDB::UnsafeData((unsigned char*) data.bytes, data.length);\n        } else {\n            return WCDB::NullOpt;\n        }\n    });\n    if (dict.hasValue()) {\n        return [[NSData alloc] initWithBytes:dict->buffer() length:dict->size()];\n    }\n    return nil;\n}\n\n+ (BOOL)registerZSTDDict:(NSData*)dict andDictId:(WCTDictId)dictId\n{\n    return WCDB::CompressionCenter::shared().registerDict(dictId, dict);\n}\n\n- (void)setCompressionWithFilter:(WCTCompressionFilterBlock)filter\n{\n    WCDB::InnerDatabase::CompressionTableFilter callback = nullptr;\n    if (filter != nil) {\n        callback = [filter](WCDB::CompressionTableUserInfo& userInfo) {\n            WCTCompressionUserInfo* nsUserInfo = [[WCTCompressionUserInfo alloc] initWithUserInfo:userInfo];\n            filter(nsUserInfo);\n        };\n        WCDB::StringView configName = WCDB::StringView::formatted(\"%s%s\", WCDB::ScalarFunctionConfigPrefix.data(), WCDB::DecompressFunctionName.data());\n        _database->setConfig(configName,\n                             WCDB::CommonCore::shared().scalarFunctionConfig(WCDB::DecompressFunctionName),\n                             WCDB::Configs::Priority::Higher);\n    }\n    _database->addCompression(callback);\n}\n\n- (void)disableCompresssNewData:(BOOL)disable\n{\n    _database->setCanCompressNewData(!disable);\n}\n\n- (BOOL)stepCompression\n{\n    auto done = _database->stepCompression(false);\n    return done.succeed();\n}\n\n- (void)enableAutoCompression:(BOOL)flag\n{\n    WCDB::CommonCore::shared().enableAutoCompress(_database, flag);\n}\n\n- (void)setNotificationWhenCompressed:(WCTCompressdNotificationBlock)onCompressd\n{\n    WCDB::InnerDatabase::CompressedCallback callback = nullptr;\n    if (onCompressd != nil) {\n        callback = [onCompressd](WCDB::InnerDatabase* database,\n                                 const WCDB::CompressionTableBaseInfo* info) {\n            WCTCompressionBaseInfo* nsInfo = nil;\n            if (info != nil) {\n                nsInfo = [[WCTCompressionBaseInfo alloc] initWithBaseInfo:*info];\n            }\n            WCTDatabase* nsDatabase = [[WCTDatabase alloc] initWithUnsafeDatabase:database];\n            onCompressd(nsDatabase, nsInfo);\n        };\n    }\n    _database->setNotificationWhenCompressed(callback);\n}\n\n- (BOOL)isCompressed\n{\n    return _database->isCompressed();\n}\n\n- (BOOL)rollbackCompression:(WCTProgressUpdateBlock)onProgressUpdated\n{\n    WCDB::InnerDatabase::ProgressCallback callback = nullptr;\n    if (onProgressUpdated != nil) {\n        callback = [onProgressUpdated](double percentage, double increment) {\n            return onProgressUpdated(percentage, increment);\n        };\n    }\n    return _database->rollbackCompression(callback);\n}\n\n@end\n"
  },
  {
    "path": "src/objc/convenient/WCTConvenient.h",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"WCTCommon.h\"\n\nNS_ASSUME_NONNULL_BEGIN\n\n@protocol WCTConvenient\n#pragma mark - Get Object\n- (nullable id /* WCTObject* */)getObjectOfClass:(Class)cls\n                                       fromTable:(NSString *)tableName;\n\n- (nullable id /* WCTObject* */)getObjectOfClass:(Class)cls\n                                       fromTable:(NSString *)tableName\n                                           where:(const WCDB::Expression &)condition;\n\n- (nullable id /* WCTObject* */)getObjectOfClass:(Class)cls\n                                       fromTable:(NSString *)tableName\n                                          orders:(const WCDB::OrderingTerms &)orders;\n\n- (nullable id /* WCTObject* */)getObjectOfClass:(Class)cls\n                                       fromTable:(NSString *)tableName\n                                          offset:(const WCDB::Expression &)offset;\n\n- (nullable id /* WCTObject* */)getObjectOfClass:(Class)cls\n                                       fromTable:(NSString *)tableName\n                                           where:(const WCDB::Expression &)condition\n                                          orders:(const WCDB::OrderingTerms &)orders;\n\n- (nullable id /* WCTObject* */)getObjectOfClass:(Class)cls\n                                       fromTable:(NSString *)tableName\n                                           where:(const WCDB::Expression &)condition\n                                          offset:(const WCDB::Expression &)offset;\n\n- (nullable id /* WCTObject* */)getObjectOfClass:(Class)cls\n                                       fromTable:(NSString *)tableName\n                                          orders:(const WCDB::OrderingTerms &)orders\n                                          offset:(const WCDB::Expression &)offset;\n\n- (nullable id /* WCTObject* */)getObjectOfClass:(Class)cls\n                                       fromTable:(NSString *)tableName\n                                           where:(const WCDB::Expression &)condition\n                                          orders:(const WCDB::OrderingTerms &)orders\n                                          offset:(const WCDB::Expression &)offset;\n\n#pragma mark - Get Objects\n- (nullable NSArray /* <WCTObject*> */ *)getObjectsOfClass:(Class)cls\n                                                 fromTable:(NSString *)tableName;\n\n- (nullable NSArray /* <WCTObject*> */ *)getObjectsOfClass:(Class)cls\n                                                 fromTable:(NSString *)tableName\n                                                     where:(const WCDB::Expression &)condition;\n\n- (nullable NSArray /* <WCTObject*> */ *)getObjectsOfClass:(Class)cls\n                                                 fromTable:(NSString *)tableName\n                                                    orders:(const WCDB::OrderingTerms &)orders;\n\n- (nullable NSArray /* <WCTObject*> */ *)getObjectsOfClass:(Class)cls\n                                                 fromTable:(NSString *)tableName\n                                                     limit:(const WCDB::Expression &)limit;\n\n- (nullable NSArray /* <WCTObject*> */ *)getObjectsOfClass:(Class)cls\n                                                 fromTable:(NSString *)tableName\n                                                     where:(const WCDB::Expression &)condition\n                                                    orders:(const WCDB::OrderingTerms &)orders;\n\n- (nullable NSArray /* <WCTObject*> */ *)getObjectsOfClass:(Class)cls\n                                                 fromTable:(NSString *)tableName\n                                                     where:(const WCDB::Expression &)condition\n                                                     limit:(const WCDB::Expression &)limit;\n\n- (nullable NSArray /* <WCTObject*> */ *)getObjectsOfClass:(Class)cls\n                                                 fromTable:(NSString *)tableName\n                                                    orders:(const WCDB::OrderingTerms &)orders\n                                                     limit:(const WCDB::Expression &)limit;\n\n- (nullable NSArray /* <WCTObject*> */ *)getObjectsOfClass:(Class)cls\n                                                 fromTable:(NSString *)tableName\n                                                     limit:(const WCDB::Expression &)limit\n                                                    offset:(const WCDB::Expression &)offset;\n\n- (nullable NSArray /* <WCTObject*> */ *)getObjectsOfClass:(Class)cls\n                                                 fromTable:(NSString *)tableName\n                                                     where:(const WCDB::Expression &)condition\n                                                    orders:(const WCDB::OrderingTerms &)orders\n                                                     limit:(const WCDB::Expression &)limit;\n\n- (nullable NSArray /* <WCTObject*> */ *)getObjectsOfClass:(Class)cls\n                                                 fromTable:(NSString *)tableName\n                                                     where:(const WCDB::Expression &)condition\n                                                     limit:(const WCDB::Expression &)limit\n                                                    offset:(const WCDB::Expression &)offset;\n\n- (nullable NSArray /* <WCTObject*> */ *)getObjectsOfClass:(Class)cls\n                                                 fromTable:(NSString *)tableName\n                                                    orders:(const WCDB::OrderingTerms &)orders\n                                                     limit:(const WCDB::Expression &)limit\n                                                    offset:(const WCDB::Expression &)offset;\n\n- (nullable NSArray /* <WCTObject*> */ *)getObjectsOfClass:(Class)cls\n                                                 fromTable:(NSString *)tableName\n                                                     where:(const WCDB::Expression &)condition\n                                                    orders:(const WCDB::OrderingTerms &)orders\n                                                     limit:(const WCDB::Expression &)limit\n                                                    offset:(const WCDB::Expression &)offset;\n\n#pragma mark - Get Part Of Object\n- (nullable id /* WCTObject* */)getObjectOnResultColumns:(const WCTResultColumns &)resultColumns\n                                               fromTable:(NSString *)tableName;\n\n- (nullable id /* WCTObject* */)getObjectOnResultColumns:(const WCTResultColumns &)resultColumns\n                                               fromTable:(NSString *)tableName\n                                                   where:(const WCDB::Expression &)condition;\n\n- (nullable id /* WCTObject* */)getObjectOnResultColumns:(const WCTResultColumns &)resultColumns\n                                               fromTable:(NSString *)tableName\n                                                  orders:(const WCDB::OrderingTerms &)orders;\n\n- (nullable id /* WCTObject* */)getObjectOnResultColumns:(const WCTResultColumns &)resultColumns\n                                               fromTable:(NSString *)tableName\n                                                  offset:(const WCDB::Expression &)offset;\n\n- (nullable id /* WCTObject* */)getObjectOnResultColumns:(const WCTResultColumns &)resultColumns\n                                               fromTable:(NSString *)tableName\n                                                   where:(const WCDB::Expression &)condition\n                                                  orders:(const WCDB::OrderingTerms &)orders;\n\n- (nullable id /* WCTObject* */)getObjectOnResultColumns:(const WCTResultColumns &)resultColumns\n                                               fromTable:(NSString *)tableName\n                                                   where:(const WCDB::Expression &)condition\n                                                  offset:(const WCDB::Expression &)offset;\n\n- (nullable id /* WCTObject* */)getObjectOnResultColumns:(const WCTResultColumns &)resultColumns\n                                               fromTable:(NSString *)tableName\n                                                  orders:(const WCDB::OrderingTerms &)orders\n                                                  offset:(const WCDB::Expression &)offset;\n\n- (nullable id /* WCTObject* */)getObjectOnResultColumns:(const WCTResultColumns &)resultColumns\n                                               fromTable:(NSString *)tableName\n                                                   where:(const WCDB::Expression &)condition\n                                                  orders:(const WCDB::OrderingTerms &)orders\n                                                  offset:(const WCDB::Expression &)offset;\n\n#pragma mark - Get Part Of Objects\n- (nullable NSArray /* <WCTObject*> */ *)getObjectsOnResultColumns:(const WCTResultColumns &)resultColumns\n                                                         fromTable:(NSString *)tableName;\n\n- (nullable NSArray /* <WCTObject*> */ *)getObjectsOnResultColumns:(const WCTResultColumns &)resultColumns\n                                                         fromTable:(NSString *)tableName\n                                                             where:(const WCDB::Expression &)condition;\n\n- (nullable NSArray /* <WCTObject*> */ *)getObjectsOnResultColumns:(const WCTResultColumns &)resultColumns\n                                                         fromTable:(NSString *)tableName\n                                                            orders:(const WCDB::OrderingTerms &)orders;\n\n- (nullable NSArray /* <WCTObject*> */ *)getObjectsOnResultColumns:(const WCTResultColumns &)resultColumns\n                                                         fromTable:(NSString *)tableName\n                                                             limit:(const WCDB::Expression &)limit;\n\n- (nullable NSArray /* <WCTObject*> */ *)getObjectsOnResultColumns:(const WCTResultColumns &)resultColumns\n                                                         fromTable:(NSString *)tableName\n                                                             where:(const WCDB::Expression &)condition\n                                                            orders:(const WCDB::OrderingTerms &)orders;\n\n- (nullable NSArray /* <WCTObject*> */ *)getObjectsOnResultColumns:(const WCTResultColumns &)resultColumns\n                                                         fromTable:(NSString *)tableName\n                                                             where:(const WCDB::Expression &)condition\n                                                             limit:(const WCDB::Expression &)limit;\n\n- (nullable NSArray /* <WCTObject*> */ *)getObjectsOnResultColumns:(const WCTResultColumns &)resultColumns\n                                                         fromTable:(NSString *)tableName\n                                                            orders:(const WCDB::OrderingTerms &)orders\n                                                             limit:(const WCDB::Expression &)limit;\n\n- (nullable NSArray /* <WCTObject*> */ *)getObjectsOnResultColumns:(const WCTResultColumns &)resultColumns\n                                                         fromTable:(NSString *)tableName\n                                                             limit:(const WCDB::Expression &)limit\n                                                            offset:(const WCDB::Expression &)offset;\n\n- (nullable NSArray /* <WCTObject*> */ *)getObjectsOnResultColumns:(const WCTResultColumns &)resultColumns\n                                                         fromTable:(NSString *)tableName\n                                                             where:(const WCDB::Expression &)condition\n                                                            orders:(const WCDB::OrderingTerms &)orders\n                                                             limit:(const WCDB::Expression &)limit;\n\n- (nullable NSArray /* <WCTObject*> */ *)getObjectsOnResultColumns:(const WCTResultColumns &)resultColumns\n                                                         fromTable:(NSString *)tableName\n                                                             where:(const WCDB::Expression &)condition\n                                                             limit:(const WCDB::Expression &)limit\n                                                            offset:(const WCDB::Expression &)offset;\n\n- (nullable NSArray /* <WCTObject*> */ *)getObjectsOnResultColumns:(const WCTResultColumns &)resultColumns\n                                                         fromTable:(NSString *)tableName\n                                                            orders:(const WCDB::OrderingTerms &)orders\n                                                             limit:(const WCDB::Expression &)limit\n                                                            offset:(const WCDB::Expression &)offset;\n\n- (nullable NSArray /* <WCTObject*> */ *)getObjectsOnResultColumns:(const WCTResultColumns &)resultColumns\n                                                         fromTable:(NSString *)tableName\n                                                             where:(const WCDB::Expression &)condition\n                                                            orders:(const WCDB::OrderingTerms &)orders\n                                                             limit:(const WCDB::Expression &)limit\n                                                            offset:(const WCDB::Expression &)offset;\n\n#pragma mark - Insert\n- (BOOL)insertObject:(WCTObject *)object\n           intoTable:(NSString *)tableName;\n\n- (BOOL)insertObjects:(NSArray<WCTObject *> *)objects\n            intoTable:(NSString *)tableName;\n\n#pragma mark - Insert or Replace\n- (BOOL)insertOrReplaceObject:(WCTObject *)object\n                    intoTable:(NSString *)tableName;\n\n- (BOOL)insertOrReplaceObjects:(NSArray<WCTObject *> *)objects\n                     intoTable:(NSString *)tableName;\n\n#pragma mark - Insert or Ignore\n- (BOOL)insertOrIgnoreObject:(WCTObject *)object\n                   intoTable:(NSString *)tableName;\n\n- (BOOL)insertOrIgnoreObjects:(NSArray<WCTObject *> *)objects\n                    intoTable:(NSString *)tableName;\n\n#pragma mark - Partial Insert\n- (BOOL)insertObject:(WCTObject *)object\n        onProperties:(const WCTProperties &)properties\n           intoTable:(NSString *)tableName;\n\n- (BOOL)insertObjects:(NSArray<WCTObject *> *)objects\n         onProperties:(const WCTProperties &)properties\n            intoTable:(NSString *)tableName;\n\n#pragma mark - Partial Insert or Replace\n- (BOOL)insertOrReplaceObject:(WCTObject *)object\n                 onProperties:(const WCTProperties &)properties\n                    intoTable:(NSString *)tableName;\n\n- (BOOL)insertOrReplaceObjects:(NSArray<WCTObject *> *)objects\n                  onProperties:(const WCTProperties &)properties\n                     intoTable:(NSString *)tableName;\n\n#pragma mark - Partial Insert or Ignore\n- (BOOL)insertOrIgnoreObject:(WCTObject *)object\n                onProperties:(const WCTProperties &)properties\n                   intoTable:(NSString *)tableName;\n\n- (BOOL)insertOrIgnoreObjects:(NSArray<WCTObject *> *)objects\n                 onProperties:(const WCTProperties &)properties\n                    intoTable:(NSString *)tableName;\n\n#pragma mark - Update Properties To Object\n- (BOOL)updateTable:(NSString *)tableName\n      setProperties:(const WCTProperties &)properties\n           toObject:(WCTObject *)object;\n\n- (BOOL)updateTable:(NSString *)tableName\n      setProperties:(const WCTProperties &)properties\n           toObject:(WCTObject *)object\n              where:(const WCDB::Expression &)condition;\n\n- (BOOL)updateTable:(NSString *)tableName\n      setProperties:(const WCTProperties &)properties\n           toObject:(WCTObject *)object\n              limit:(const WCDB::Expression &)limit;\n\n- (BOOL)updateTable:(NSString *)tableName\n      setProperties:(const WCTProperties &)properties\n           toObject:(WCTObject *)object\n              where:(const WCDB::Expression &)condition\n              limit:(const WCDB::Expression &)limit;\n\n- (BOOL)updateTable:(NSString *)tableName\n      setProperties:(const WCTProperties &)properties\n           toObject:(WCTObject *)object\n             orders:(const WCDB::OrderingTerms &)orders\n              limit:(const WCDB::Expression &)limit;\n\n- (BOOL)updateTable:(NSString *)tableName\n      setProperties:(const WCTProperties &)properties\n           toObject:(WCTObject *)object\n              limit:(const WCDB::Expression &)limit\n             offset:(const WCDB::Expression &)offset;\n\n- (BOOL)updateTable:(NSString *)tableName\n      setProperties:(const WCTProperties &)properties\n           toObject:(WCTObject *)object\n              where:(const WCDB::Expression &)condition\n             orders:(const WCDB::OrderingTerms &)orders\n              limit:(const WCDB::Expression &)limit;\n\n- (BOOL)updateTable:(NSString *)tableName\n      setProperties:(const WCTProperties &)properties\n           toObject:(WCTObject *)object\n              where:(const WCDB::Expression &)condition\n              limit:(const WCDB::Expression &)limit\n             offset:(const WCDB::Expression &)offset;\n\n- (BOOL)updateTable:(NSString *)tableName\n      setProperties:(const WCTProperties &)properties\n           toObject:(WCTObject *)object\n             orders:(const WCDB::OrderingTerms &)orders\n              limit:(const WCDB::Expression &)limit\n             offset:(const WCDB::Expression &)offset;\n\n- (BOOL)updateTable:(NSString *)tableName\n      setProperties:(const WCTProperties &)properties\n           toObject:(WCTObject *)object\n              where:(const WCDB::Expression &)condition\n             orders:(const WCDB::OrderingTerms &)orders\n              limit:(const WCDB::Expression &)limit\n             offset:(const WCDB::Expression &)offset;\n\n#pragma mark - Update Properties To Row\n- (BOOL)updateTable:(NSString *)tableName\n      setProperties:(const WCTProperties &)properties\n              toRow:(WCTColumnCodingRow *)row;\n\n- (BOOL)updateTable:(NSString *)tableName\n      setProperties:(const WCTProperties &)properties\n              toRow:(WCTColumnCodingRow *)row\n              where:(const WCDB::Expression &)condition;\n\n- (BOOL)updateTable:(NSString *)tableName\n      setProperties:(const WCTProperties &)properties\n              toRow:(WCTColumnCodingRow *)row\n              limit:(const WCDB::Expression &)limit;\n\n- (BOOL)updateTable:(NSString *)tableName\n      setProperties:(const WCTProperties &)properties\n              toRow:(WCTColumnCodingRow *)row\n              where:(const WCDB::Expression &)condition\n              limit:(const WCDB::Expression &)limit;\n\n- (BOOL)updateTable:(NSString *)tableName\n      setProperties:(const WCTProperties &)properties\n              toRow:(WCTColumnCodingRow *)row\n             orders:(const WCDB::OrderingTerms &)orders\n              limit:(const WCDB::Expression &)limit;\n\n- (BOOL)updateTable:(NSString *)tableName\n      setProperties:(const WCTProperties &)properties\n              toRow:(WCTColumnCodingRow *)row\n              limit:(const WCDB::Expression &)limit\n             offset:(const WCDB::Expression &)offset;\n\n- (BOOL)updateTable:(NSString *)tableName\n      setProperties:(const WCTProperties &)properties\n              toRow:(WCTColumnCodingRow *)row\n              where:(const WCDB::Expression &)condition\n             orders:(const WCDB::OrderingTerms &)orders\n              limit:(const WCDB::Expression &)limit;\n\n- (BOOL)updateTable:(NSString *)tableName\n      setProperties:(const WCTProperties &)properties\n              toRow:(WCTColumnCodingRow *)row\n              where:(const WCDB::Expression &)condition\n              limit:(const WCDB::Expression &)limit\n             offset:(const WCDB::Expression &)offset;\n\n- (BOOL)updateTable:(NSString *)tableName\n      setProperties:(const WCTProperties &)properties\n              toRow:(WCTColumnCodingRow *)row\n             orders:(const WCDB::OrderingTerms &)orders\n              limit:(const WCDB::Expression &)limit\n             offset:(const WCDB::Expression &)offset;\n\n- (BOOL)updateTable:(NSString *)tableName\n      setProperties:(const WCTProperties &)properties\n              toRow:(WCTColumnCodingRow *)row\n              where:(const WCDB::Expression &)condition\n             orders:(const WCDB::OrderingTerms &)orders\n              limit:(const WCDB::Expression &)limit\n             offset:(const WCDB::Expression &)offset;\n\n#pragma mark - Update Property To Value\n- (BOOL)updateTable:(NSString *)tableName\n        setProperty:(const WCTProperty &)property\n            toValue:(WCTColumnCodingValue *)value;\n\n- (BOOL)updateTable:(NSString *)tableName\n        setProperty:(const WCTProperty &)property\n            toValue:(WCTColumnCodingValue *)value\n              where:(const WCDB::Expression &)condition;\n\n- (BOOL)updateTable:(NSString *)tableName\n        setProperty:(const WCTProperty &)property\n            toValue:(WCTColumnCodingValue *)value\n              limit:(const WCDB::Expression &)limit;\n\n- (BOOL)updateTable:(NSString *)tableName\n        setProperty:(const WCTProperty &)property\n            toValue:(WCTColumnCodingValue *)value\n              where:(const WCDB::Expression &)condition\n              limit:(const WCDB::Expression &)limit;\n\n- (BOOL)updateTable:(NSString *)tableName\n        setProperty:(const WCTProperty &)property\n            toValue:(WCTColumnCodingValue *)value\n             orders:(const WCDB::OrderingTerms &)orders\n              limit:(const WCDB::Expression &)limit;\n\n- (BOOL)updateTable:(NSString *)tableName\n        setProperty:(const WCTProperty &)property\n            toValue:(WCTColumnCodingValue *)value\n              limit:(const WCDB::Expression &)limit\n             offset:(const WCDB::Expression &)offset;\n\n- (BOOL)updateTable:(NSString *)tableName\n        setProperty:(const WCTProperty &)property\n            toValue:(WCTColumnCodingValue *)value\n              where:(const WCDB::Expression &)condition\n             orders:(const WCDB::OrderingTerms &)orders\n              limit:(const WCDB::Expression &)limit;\n\n- (BOOL)updateTable:(NSString *)tableName\n        setProperty:(const WCTProperty &)property\n            toValue:(WCTColumnCodingValue *)value\n              where:(const WCDB::Expression &)condition\n              limit:(const WCDB::Expression &)limit\n             offset:(const WCDB::Expression &)offset;\n\n- (BOOL)updateTable:(NSString *)tableName\n        setProperty:(const WCTProperty &)property\n            toValue:(WCTColumnCodingValue *)value\n             orders:(const WCDB::OrderingTerms &)orders\n              limit:(const WCDB::Expression &)limit\n             offset:(const WCDB::Expression &)offset;\n\n- (BOOL)updateTable:(NSString *)tableName\n        setProperty:(const WCTProperty &)property\n            toValue:(WCTColumnCodingValue *)value\n              where:(const WCDB::Expression &)condition\n             orders:(const WCDB::OrderingTerms &)orders\n              limit:(const WCDB::Expression &)limit\n             offset:(const WCDB::Expression &)offset;\n\n#pragma mark - Delete\n- (BOOL)deleteFromTable:(NSString *)tableName;\n\n- (BOOL)deleteFromTable:(NSString *)tableName\n                  where:(const WCDB::Expression &)condition;\n\n- (BOOL)deleteFromTable:(NSString *)tableName\n                  limit:(const WCDB::Expression &)limit;\n\n- (BOOL)deleteFromTable:(NSString *)tableName\n                  where:(const WCDB::Expression &)condition\n                  limit:(const WCDB::Expression &)limit;\n\n- (BOOL)deleteFromTable:(NSString *)tableName\n                 orders:(const WCDB::OrderingTerms &)orders\n                  limit:(const WCDB::Expression &)limit;\n\n- (BOOL)deleteFromTable:(NSString *)tableName\n                  limit:(const WCDB::Expression &)limit\n                 offset:(const WCDB::Expression &)offset;\n\n- (BOOL)deleteFromTable:(NSString *)tableName\n                  where:(const WCDB::Expression &)condition\n                 orders:(const WCDB::OrderingTerms &)orders\n                  limit:(const WCDB::Expression &)limit;\n\n- (BOOL)deleteFromTable:(NSString *)tableName\n                  where:(const WCDB::Expression &)condition\n                  limit:(const WCDB::Expression &)limit\n                 offset:(const WCDB::Expression &)offset;\n\n- (BOOL)deleteFromTable:(NSString *)tableName\n                 orders:(const WCDB::OrderingTerms &)orders\n                  limit:(const WCDB::Expression &)limit\n                 offset:(const WCDB::Expression &)offset;\n\n- (BOOL)deleteFromTable:(NSString *)tableName\n                  where:(const WCDB::Expression &)condition\n                 orders:(const WCDB::OrderingTerms &)orders\n                  limit:(const WCDB::Expression &)limit\n                 offset:(const WCDB::Expression &)offset;\n\n#pragma mark - Get Value\n- (nullable WCTValue *)getValueOnResultColumn:(const WCDB::ResultColumn &)resultColumn\n                                    fromTable:(NSString *)tableName;\n\n- (nullable WCTValue *)getValueOnResultColumn:(const WCDB::ResultColumn &)resultColumn\n                                    fromTable:(NSString *)tableName\n                                        where:(const WCDB::Expression &)condition;\n\n- (nullable WCTValue *)getValueOnResultColumn:(const WCDB::ResultColumn &)resultColumn\n                                    fromTable:(NSString *)tableName\n                                       orders:(const WCDB::OrderingTerms &)orders;\n\n- (nullable WCTValue *)getValueOnResultColumn:(const WCDB::ResultColumn &)resultColumn\n                                    fromTable:(NSString *)tableName\n                                       offset:(const WCDB::Expression &)offset;\n\n- (nullable WCTValue *)getValueOnResultColumn:(const WCDB::ResultColumn &)resultColumn\n                                    fromTable:(NSString *)tableName\n                                        where:(const WCDB::Expression &)condition\n                                       orders:(const WCDB::OrderingTerms &)orders;\n\n- (nullable WCTValue *)getValueOnResultColumn:(const WCDB::ResultColumn &)resultColumn\n                                    fromTable:(NSString *)tableName\n                                        where:(const WCDB::Expression &)condition\n                                       offset:(const WCDB::Expression &)offset;\n\n- (nullable WCTValue *)getValueOnResultColumn:(const WCDB::ResultColumn &)resultColumn\n                                    fromTable:(NSString *)tableName\n                                       orders:(const WCDB::OrderingTerms &)orders\n                                       offset:(const WCDB::Expression &)offset;\n\n- (nullable WCTValue *)getValueOnResultColumn:(const WCDB::ResultColumn &)resultColumn\n                                    fromTable:(NSString *)tableName\n                                        where:(const WCDB::Expression &)condition\n                                       orders:(const WCDB::OrderingTerms &)orders\n                                       offset:(const WCDB::Expression &)offset;\n\n#pragma mark - Get Row\n- (nullable WCTOneRow *)getRowOnResultColumns:(const WCDB::ResultColumns &)resultColumns\n                                    fromTable:(NSString *)tableName;\n\n- (nullable WCTOneRow *)getRowOnResultColumns:(const WCDB::ResultColumns &)resultColumns\n                                    fromTable:(NSString *)tableName\n                                        where:(const WCDB::Expression &)condition;\n\n- (nullable WCTOneRow *)getRowOnResultColumns:(const WCDB::ResultColumns &)resultColumns\n                                    fromTable:(NSString *)tableName\n                                       orders:(const WCDB::OrderingTerms &)orders;\n\n- (nullable WCTOneRow *)getRowOnResultColumns:(const WCDB::ResultColumns &)resultColumns\n                                    fromTable:(NSString *)tableName\n                                       offset:(const WCDB::Expression &)offset;\n\n- (nullable WCTOneRow *)getRowOnResultColumns:(const WCDB::ResultColumns &)resultColumns\n                                    fromTable:(NSString *)tableName\n                                        where:(const WCDB::Expression &)condition\n                                       orders:(const WCDB::OrderingTerms &)orders;\n\n- (nullable WCTOneRow *)getRowOnResultColumns:(const WCDB::ResultColumns &)resultColumns\n                                    fromTable:(NSString *)tableName\n                                        where:(const WCDB::Expression &)condition\n                                       offset:(const WCDB::Expression &)offset;\n\n- (nullable WCTOneRow *)getRowOnResultColumns:(const WCDB::ResultColumns &)resultColumns\n                                    fromTable:(NSString *)tableName\n                                       orders:(const WCDB::OrderingTerms &)orders\n                                       offset:(const WCDB::Expression &)offset;\n\n- (nullable WCTOneRow *)getRowOnResultColumns:(const WCDB::ResultColumns &)resultColumns\n                                    fromTable:(NSString *)tableName\n                                        where:(const WCDB::Expression &)condition\n                                       orders:(const WCDB::OrderingTerms &)orders\n                                       offset:(const WCDB::Expression &)offset;\n\n#pragma mark - Get Column\n- (nullable WCTOneColumn *)getColumnOnResultColumn:(const WCDB::ResultColumn &)resultColumn\n                                         fromTable:(NSString *)tableName;\n\n- (nullable WCTOneColumn *)getColumnOnResultColumn:(const WCDB::ResultColumn &)resultColumn\n                                         fromTable:(NSString *)tableName\n                                             where:(const WCDB::Expression &)condition;\n\n- (nullable WCTOneColumn *)getColumnOnResultColumn:(const WCDB::ResultColumn &)resultColumn\n                                         fromTable:(NSString *)tableName\n                                            orders:(const WCDB::OrderingTerms &)orders;\n\n- (nullable WCTOneColumn *)getColumnOnResultColumn:(const WCDB::ResultColumn &)resultColumn\n                                         fromTable:(NSString *)tableName\n                                             limit:(const WCDB::Expression &)limit;\n\n- (nullable WCTOneColumn *)getColumnOnResultColumn:(const WCDB::ResultColumn &)resultColumn\n                                         fromTable:(NSString *)tableName\n                                             where:(const WCDB::Expression &)condition\n                                            orders:(const WCDB::OrderingTerms &)orders;\n\n- (nullable WCTOneColumn *)getColumnOnResultColumn:(const WCDB::ResultColumn &)resultColumn\n                                         fromTable:(NSString *)tableName\n                                             where:(const WCDB::Expression &)condition\n                                             limit:(const WCDB::Expression &)limit;\n\n- (nullable WCTOneColumn *)getColumnOnResultColumn:(const WCDB::ResultColumn &)resultColumn\n                                         fromTable:(NSString *)tableName\n                                            orders:(const WCDB::OrderingTerms &)orders\n                                             limit:(const WCDB::Expression &)limit;\n\n- (nullable WCTOneColumn *)getColumnOnResultColumn:(const WCDB::ResultColumn &)resultColumn\n                                         fromTable:(NSString *)tableName\n                                             limit:(const WCDB::Expression &)limit\n                                            offset:(const WCDB::Expression &)offset;\n\n- (nullable WCTOneColumn *)getColumnOnResultColumn:(const WCDB::ResultColumn &)resultColumn\n                                         fromTable:(NSString *)tableName\n                                             where:(const WCDB::Expression &)condition\n                                            orders:(const WCDB::OrderingTerms &)orders\n                                             limit:(const WCDB::Expression &)limit;\n\n- (nullable WCTOneColumn *)getColumnOnResultColumn:(const WCDB::ResultColumn &)resultColumn\n                                         fromTable:(NSString *)tableName\n                                             where:(const WCDB::Expression &)condition\n                                             limit:(const WCDB::Expression &)limit\n                                            offset:(const WCDB::Expression &)offset;\n\n- (nullable WCTOneColumn *)getColumnOnResultColumn:(const WCDB::ResultColumn &)resultColumn\n                                         fromTable:(NSString *)tableName\n                                            orders:(const WCDB::OrderingTerms &)orders\n                                             limit:(const WCDB::Expression &)limit\n                                            offset:(const WCDB::Expression &)offset;\n\n- (nullable WCTOneColumn *)getColumnOnResultColumn:(const WCDB::ResultColumn &)resultColumn\n                                         fromTable:(NSString *)tableName\n                                             where:(const WCDB::Expression &)condition\n                                            orders:(const WCDB::OrderingTerms &)orders\n                                             limit:(const WCDB::Expression &)limit\n                                            offset:(const WCDB::Expression &)offset;\n\n#pragma mark - Get Rows\n- (nullable WCTColumnsXRows *)getRowsOnResultColumns:(const WCDB::ResultColumns &)resultColumns\n                                           fromTable:(NSString *)tableName;\n\n- (nullable WCTColumnsXRows *)getRowsOnResultColumns:(const WCDB::ResultColumns &)resultColumns\n                                           fromTable:(NSString *)tableName\n                                               where:(const WCDB::Expression &)condition;\n\n- (nullable WCTColumnsXRows *)getRowsOnResultColumns:(const WCDB::ResultColumns &)resultColumns\n                                           fromTable:(NSString *)tableName\n                                              orders:(const WCDB::OrderingTerms &)orders;\n\n- (nullable WCTColumnsXRows *)getRowsOnResultColumns:(const WCDB::ResultColumns &)resultColumns\n                                           fromTable:(NSString *)tableName\n                                               limit:(const WCDB::Expression &)limit;\n\n- (nullable WCTColumnsXRows *)getRowsOnResultColumns:(const WCDB::ResultColumns &)resultColumns\n                                           fromTable:(NSString *)tableName\n                                               where:(const WCDB::Expression &)condition\n                                              orders:(const WCDB::OrderingTerms &)orders;\n\n- (nullable WCTColumnsXRows *)getRowsOnResultColumns:(const WCDB::ResultColumns &)resultColumns\n                                           fromTable:(NSString *)tableName\n                                               where:(const WCDB::Expression &)condition\n                                               limit:(const WCDB::Expression &)limit;\n\n- (nullable WCTColumnsXRows *)getRowsOnResultColumns:(const WCDB::ResultColumns &)resultColumns\n                                           fromTable:(NSString *)tableName\n                                              orders:(const WCDB::OrderingTerms &)orders\n                                               limit:(const WCDB::Expression &)limit;\n\n- (nullable WCTColumnsXRows *)getRowsOnResultColumns:(const WCDB::ResultColumns &)resultColumns\n                                           fromTable:(NSString *)tableName\n                                               limit:(const WCDB::Expression &)limit\n                                              offset:(const WCDB::Expression &)offset;\n\n- (nullable WCTColumnsXRows *)getRowsOnResultColumns:(const WCDB::ResultColumns &)resultColumns\n                                           fromTable:(NSString *)tableName\n                                               where:(const WCDB::Expression &)condition\n                                              orders:(const WCDB::OrderingTerms &)orders\n                                               limit:(const WCDB::Expression &)limit;\n\n- (nullable WCTColumnsXRows *)getRowsOnResultColumns:(const WCDB::ResultColumns &)resultColumns\n                                           fromTable:(NSString *)tableName\n                                               where:(const WCDB::Expression &)condition\n                                               limit:(const WCDB::Expression &)limit\n                                              offset:(const WCDB::Expression &)offset;\n\n- (nullable WCTColumnsXRows *)getRowsOnResultColumns:(const WCDB::ResultColumns &)resultColumns\n                                           fromTable:(NSString *)tableName\n                                              orders:(const WCDB::OrderingTerms &)orders\n                                               limit:(const WCDB::Expression &)limit\n                                              offset:(const WCDB::Expression &)offset;\n\n- (nullable WCTColumnsXRows *)getRowsOnResultColumns:(const WCDB::ResultColumns &)resultColumns\n                                           fromTable:(NSString *)tableName\n                                               where:(const WCDB::Expression &)condition\n                                              orders:(const WCDB::OrderingTerms &)orders\n                                               limit:(const WCDB::Expression &)limit\n                                              offset:(const WCDB::Expression &)offset;\n\n#pragma mark - Get From Statement\n- (nullable WCTValue *)getValueFromStatement:(const WCDB::Statement &)statement;\n\n- (nullable WCTOneRow *)getRowFromStatement:(const WCDB::Statement &)statement;\n\n- (nullable WCTOneColumn *)getColumnFromStatement:(const WCDB::Statement &)statement;\n\n- (nullable WCTColumnsXRows *)getRowsFromStatement:(const WCDB::Statement &)statement;\n\n@end\n\nNS_ASSUME_NONNULL_END\n"
  },
  {
    "path": "src/objc/convenient/WCTDatabase+Convenient.h",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"WCTConvenient.h\"\n#import \"WCTDatabase.h\"\n\nNS_ASSUME_NONNULL_BEGIN\n\nWCDB_API @interface WCTDatabase(Convenient)<WCTConvenient>\n\n@end\n\nNS_ASSUME_NONNULL_END\n"
  },
  {
    "path": "src/objc/convenient/WCTDatabase+Convenient.mm",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"Assertion.hpp\"\n#import \"WCTChainCall+Private.h\"\n#import \"WCTDatabase+ChainCall.h\"\n#import \"WCTDatabase+Convenient.h\"\n#import \"WCTDatabase+Handle.h\"\n#import \"WCTDelete.h\"\n#import \"WCTHandle+Private.h\"\n#import \"WCTHandle.h\"\n#import \"WCTInsert.h\"\n#import \"WCTMultiSelect.h\"\n#import \"WCTORM.h\"\n#import \"WCTSelect.h\"\n#import \"WCTUpdate.h\"\n\n@implementation WCTDatabase (Convenient)\n#pragma mark - Get Object\n- (id /* WCTObject* */)getObjectOfClass:(Class)cls\n                              fromTable:(NSString *)tableName\n{\n    return [[[[[self prepareSelect] ofClass:cls] fromTable:tableName] limit:1] firstObject];\n}\n\n- (id /* WCTObject* */)getObjectOfClass:(Class)cls\n                              fromTable:(NSString *)tableName\n                                  where:(const WCDB::Expression &)condition\n{\n    return [[[[[[self prepareSelect] ofClass:cls] fromTable:tableName] where:condition] limit:1] firstObject];\n}\n\n- (id /* WCTObject* */)getObjectOfClass:(Class)cls\n                              fromTable:(NSString *)tableName\n                                 orders:(const WCDB::OrderingTerms &)orders\n{\n    return [[[[[[self prepareSelect] ofClass:cls] fromTable:tableName] orders:orders] limit:1] firstObject];\n}\n\n- (id /* WCTObject* */)getObjectOfClass:(Class)cls\n                              fromTable:(NSString *)tableName\n                                 offset:(const WCDB::Expression &)offset\n{\n    return [[[[[[self prepareSelect] ofClass:cls] fromTable:tableName] limit:1] offset:offset] firstObject];\n}\n\n- (id /* WCTObject* */)getObjectOfClass:(Class)cls\n                              fromTable:(NSString *)tableName\n                                  where:(const WCDB::Expression &)condition\n                                 orders:(const WCDB::OrderingTerms &)orders\n{\n    return [[[[[[[self prepareSelect] ofClass:cls] fromTable:tableName] where:condition] orders:orders] limit:1] firstObject];\n}\n\n- (id /* WCTObject* */)getObjectOfClass:(Class)cls\n                              fromTable:(NSString *)tableName\n                                  where:(const WCDB::Expression &)condition\n                                 offset:(const WCDB::Expression &)offset\n{\n    return [[[[[[[self prepareSelect] ofClass:cls] fromTable:tableName] where:condition] limit:1] offset:offset] firstObject];\n}\n\n- (id /* WCTObject* */)getObjectOfClass:(Class)cls\n                              fromTable:(NSString *)tableName\n                                 orders:(const WCDB::OrderingTerms &)orders\n                                 offset:(const WCDB::Expression &)offset\n{\n    return [[[[[[[self prepareSelect] ofClass:cls] fromTable:tableName] orders:orders] limit:1] offset:offset] firstObject];\n}\n\n- (id /* WCTObject* */)getObjectOfClass:(Class)cls\n                              fromTable:(NSString *)tableName\n                                  where:(const WCDB::Expression &)condition\n                                 orders:(const WCDB::OrderingTerms &)orders\n                                 offset:(const WCDB::Expression &)offset\n{\n    return [[[[[[[[self prepareSelect] ofClass:cls] fromTable:tableName] where:condition] orders:orders] limit:1] offset:offset] firstObject];\n}\n\n#pragma mark - Get Objects\n- (NSArray /* <WCTObject*> */ *)getObjectsOfClass:(Class)cls\n                                        fromTable:(NSString *)tableName\n{\n    return [[[[self prepareSelect] ofClass:cls] fromTable:tableName] allObjects];\n}\n\n- (NSArray /* <WCTObject*> */ *)getObjectsOfClass:(Class)cls\n                                        fromTable:(NSString *)tableName\n                                            where:(const WCDB::Expression &)condition\n{\n    return [[[[[self prepareSelect] ofClass:cls] fromTable:tableName] where:condition] allObjects];\n}\n\n- (NSArray /* <WCTObject*> */ *)getObjectsOfClass:(Class)cls\n                                        fromTable:(NSString *)tableName\n                                           orders:(const WCDB::OrderingTerms &)orders\n{\n    return [[[[[self prepareSelect] ofClass:cls] fromTable:tableName] orders:orders] allObjects];\n}\n\n- (NSArray /* <WCTObject*> */ *)getObjectsOfClass:(Class)cls\n                                        fromTable:(NSString *)tableName\n                                            limit:(const WCDB::Expression &)limit\n{\n    return [[[[[self prepareSelect] ofClass:cls] fromTable:tableName] limit:limit] allObjects];\n}\n\n- (NSArray /* <WCTObject*> */ *)getObjectsOfClass:(Class)cls\n                                        fromTable:(NSString *)tableName\n                                            where:(const WCDB::Expression &)condition\n                                           orders:(const WCDB::OrderingTerms &)orders\n{\n    return [[[[[[self prepareSelect] ofClass:cls] fromTable:tableName] where:condition] orders:orders] allObjects];\n}\n\n- (NSArray /* <WCTObject*> */ *)getObjectsOfClass:(Class)cls\n                                        fromTable:(NSString *)tableName\n                                            where:(const WCDB::Expression &)condition\n                                            limit:(const WCDB::Expression &)limit\n{\n    return [[[[[[self prepareSelect] ofClass:cls] fromTable:tableName] where:condition] limit:limit] allObjects];\n}\n\n- (NSArray /* <WCTObject*> */ *)getObjectsOfClass:(Class)cls\n                                        fromTable:(NSString *)tableName\n                                           orders:(const WCDB::OrderingTerms &)orders\n                                            limit:(const WCDB::Expression &)limit\n{\n    return [[[[[[self prepareSelect] ofClass:cls] fromTable:tableName] orders:orders] limit:limit] allObjects];\n}\n\n- (NSArray /* <WCTObject*> */ *)getObjectsOfClass:(Class)cls\n                                        fromTable:(NSString *)tableName\n                                            limit:(const WCDB::Expression &)limit\n                                           offset:(const WCDB::Expression &)offset\n{\n    return [[[[[[self prepareSelect] ofClass:cls] fromTable:tableName] limit:limit] offset:offset] allObjects];\n}\n\n- (NSArray /* <WCTObject*> */ *)getObjectsOfClass:(Class)cls\n                                        fromTable:(NSString *)tableName\n                                            where:(const WCDB::Expression &)condition\n                                           orders:(const WCDB::OrderingTerms &)orders\n                                            limit:(const WCDB::Expression &)limit\n{\n    return [[[[[[[self prepareSelect] ofClass:cls] fromTable:tableName] where:condition] orders:orders] limit:limit] allObjects];\n}\n\n- (NSArray /* <WCTObject*> */ *)getObjectsOfClass:(Class)cls\n                                        fromTable:(NSString *)tableName\n                                           orders:(const WCDB::OrderingTerms &)orders\n                                            limit:(const WCDB::Expression &)limit\n                                           offset:(const WCDB::Expression &)offset\n{\n    return [[[[[[[self prepareSelect] ofClass:cls] fromTable:tableName] orders:orders] limit:limit] offset:offset] allObjects];\n}\n\n- (NSArray /* <WCTObject*> */ *)getObjectsOfClass:(Class)cls\n                                        fromTable:(NSString *)tableName\n                                            where:(const WCDB::Expression &)condition\n                                            limit:(const WCDB::Expression &)limit\n                                           offset:(const WCDB::Expression &)offset\n{\n    return [[[[[[[self prepareSelect] ofClass:cls] fromTable:tableName] where:condition] limit:limit] offset:offset] allObjects];\n}\n\n- (NSArray /* <WCTObject*> */ *)getObjectsOfClass:(Class)cls\n                                        fromTable:(NSString *)tableName\n                                            where:(const WCDB::Expression &)condition\n                                           orders:(const WCDB::OrderingTerms &)orders\n                                            limit:(const WCDB::Expression &)limit\n                                           offset:(const WCDB::Expression &)offset\n{\n    return [[[[[[[[self prepareSelect] ofClass:cls] fromTable:tableName] where:condition] orders:orders] limit:limit] offset:offset] allObjects];\n}\n\n#pragma mark - Get Part Of Object\n- (id /* WCTObject* */)getObjectOnResultColumns:(const WCTResultColumns &)resultColumns\n                                      fromTable:(NSString *)tableName\n{\n    return [[[[[self prepareSelect] onResultColumns:resultColumns] fromTable:tableName] limit:1] firstObject];\n}\n\n- (id /* WCTObject* */)getObjectOnResultColumns:(const WCTResultColumns &)resultColumns\n                                      fromTable:(NSString *)tableName\n                                          where:(const WCDB::Expression &)condition\n{\n    return [[[[[[self prepareSelect] onResultColumns:resultColumns] fromTable:tableName] where:condition] limit:1] firstObject];\n}\n\n- (id /* WCTObject* */)getObjectOnResultColumns:(const WCTResultColumns &)resultColumns\n                                      fromTable:(NSString *)tableName\n                                         orders:(const WCDB::OrderingTerms &)orders\n{\n    return [[[[[[self prepareSelect] onResultColumns:resultColumns] fromTable:tableName] orders:orders] limit:1] firstObject];\n}\n\n- (id /* WCTObject* */)getObjectOnResultColumns:(const WCTResultColumns &)resultColumns\n                                      fromTable:(NSString *)tableName\n                                         offset:(const WCDB::Expression &)offset\n{\n    return [[[[[[self prepareSelect] onResultColumns:resultColumns] fromTable:tableName] limit:1] offset:offset] firstObject];\n}\n\n- (id /* WCTObject* */)getObjectOnResultColumns:(const WCTResultColumns &)resultColumns\n                                      fromTable:(NSString *)tableName\n                                          where:(const WCDB::Expression &)condition\n                                         orders:(const WCDB::OrderingTerms &)orders\n{\n    return [[[[[[[self prepareSelect] onResultColumns:resultColumns] fromTable:tableName] where:condition] orders:orders] limit:1] firstObject];\n}\n\n- (id /* WCTObject* */)getObjectOnResultColumns:(const WCTResultColumns &)resultColumns\n                                      fromTable:(NSString *)tableName\n                                          where:(const WCDB::Expression &)condition\n                                         offset:(const WCDB::Expression &)offset\n{\n    return [[[[[[[self prepareSelect] onResultColumns:resultColumns] fromTable:tableName] where:condition] limit:1] offset:offset] firstObject];\n}\n\n- (id /* WCTObject* */)getObjectOnResultColumns:(const WCTResultColumns &)resultColumns\n                                      fromTable:(NSString *)tableName\n                                         orders:(const WCDB::OrderingTerms &)orders\n                                         offset:(const WCDB::Expression &)offset\n{\n    return [[[[[[[self prepareSelect] onResultColumns:resultColumns] fromTable:tableName] orders:orders] limit:1] offset:offset] firstObject];\n}\n\n- (id /* WCTObject* */)getObjectOnResultColumns:(const WCTResultColumns &)resultColumns\n                                      fromTable:(NSString *)tableName\n                                          where:(const WCDB::Expression &)condition\n                                         orders:(const WCDB::OrderingTerms &)orders\n                                         offset:(const WCDB::Expression &)offset\n{\n    return [[[[[[[[self prepareSelect] onResultColumns:resultColumns] fromTable:tableName] where:condition] orders:orders] limit:1] offset:offset] firstObject];\n}\n\n#pragma mark - Get Part Of Objects\n- (NSArray /* <WCTObject*> */ *)getObjectsOnResultColumns:(const WCTResultColumns &)resultColumns\n                                                fromTable:(NSString *)tableName\n{\n    return [[[[self prepareSelect] onResultColumns:resultColumns] fromTable:tableName] allObjects];\n}\n\n- (NSArray /* <WCTObject*> */ *)getObjectsOnResultColumns:(const WCTResultColumns &)resultColumns\n                                                fromTable:(NSString *)tableName\n                                                    where:(const WCDB::Expression &)condition\n{\n    return [[[[[self prepareSelect] onResultColumns:resultColumns] fromTable:tableName] where:condition] allObjects];\n}\n\n- (NSArray /* <WCTObject*> */ *)getObjectsOnResultColumns:(const WCTResultColumns &)resultColumns\n                                                fromTable:(NSString *)tableName\n                                                   orders:(const WCDB::OrderingTerms &)orders\n{\n    return [[[[[self prepareSelect] onResultColumns:resultColumns] fromTable:tableName] orders:orders] allObjects];\n}\n\n- (NSArray /* <WCTObject*> */ *)getObjectsOnResultColumns:(const WCTResultColumns &)resultColumns\n                                                fromTable:(NSString *)tableName\n                                                    limit:(const WCDB::Expression &)limit\n{\n    return [[[[[self prepareSelect] onResultColumns:resultColumns] fromTable:tableName] limit:limit] allObjects];\n}\n\n- (NSArray /* <WCTObject*> */ *)getObjectsOnResultColumns:(const WCTResultColumns &)resultColumns\n                                                fromTable:(NSString *)tableName\n                                                    where:(const WCDB::Expression &)condition\n                                                   orders:(const WCDB::OrderingTerms &)orders\n{\n    return [[[[[[self prepareSelect] onResultColumns:resultColumns] fromTable:tableName] where:condition] orders:orders] allObjects];\n}\n\n- (NSArray /* <WCTObject*> */ *)getObjectsOnResultColumns:(const WCTResultColumns &)resultColumns\n                                                fromTable:(NSString *)tableName\n                                                    where:(const WCDB::Expression &)condition\n                                                    limit:(const WCDB::Expression &)limit\n{\n    return [[[[[[self prepareSelect] onResultColumns:resultColumns] fromTable:tableName] where:condition] limit:limit] allObjects];\n}\n\n- (NSArray /* <WCTObject*> */ *)getObjectsOnResultColumns:(const WCTResultColumns &)resultColumns\n                                                fromTable:(NSString *)tableName\n                                                   orders:(const WCDB::OrderingTerms &)orders\n                                                    limit:(const WCDB::Expression &)limit\n{\n    return [[[[[[self prepareSelect] onResultColumns:resultColumns] fromTable:tableName] orders:orders] limit:limit] allObjects];\n}\n\n- (NSArray /* <WCTObject*> */ *)getObjectsOnResultColumns:(const WCTResultColumns &)resultColumns\n                                                fromTable:(NSString *)tableName\n                                                    limit:(const WCDB::Expression &)limit\n                                                   offset:(const WCDB::Expression &)offset\n{\n    return [[[[[[self prepareSelect] onResultColumns:resultColumns] fromTable:tableName] limit:limit] offset:offset] allObjects];\n}\n\n- (NSArray /* <WCTObject*> */ *)getObjectsOnResultColumns:(const WCTResultColumns &)resultColumns\n                                                fromTable:(NSString *)tableName\n                                                    where:(const WCDB::Expression &)condition\n                                                   orders:(const WCDB::OrderingTerms &)orders\n                                                    limit:(const WCDB::Expression &)limit\n{\n    return [[[[[[[self prepareSelect] onResultColumns:resultColumns] fromTable:tableName] where:condition] orders:orders] limit:limit] allObjects];\n}\n\n- (NSArray /* <WCTObject*> */ *)getObjectsOnResultColumns:(const WCTResultColumns &)resultColumns\n                                                fromTable:(NSString *)tableName\n                                                    where:(const WCDB::Expression &)condition\n                                                    limit:(const WCDB::Expression &)limit\n                                                   offset:(const WCDB::Expression &)offset\n{\n    return [[[[[[[self prepareSelect] onResultColumns:resultColumns] fromTable:tableName] where:condition] limit:limit] offset:offset] allObjects];\n}\n\n- (NSArray /* <WCTObject*> */ *)getObjectsOnResultColumns:(const WCTResultColumns &)resultColumns\n                                                fromTable:(NSString *)tableName\n                                                   orders:(const WCDB::OrderingTerms &)orders\n                                                    limit:(const WCDB::Expression &)limit\n                                                   offset:(const WCDB::Expression &)offset\n{\n    return [[[[[[[self prepareSelect] onResultColumns:resultColumns] fromTable:tableName] orders:orders] limit:limit] offset:offset] allObjects];\n}\n\n- (NSArray /* <WCTObject*> */ *)getObjectsOnResultColumns:(const WCTResultColumns &)resultColumns\n                                                fromTable:(NSString *)tableName\n                                                    where:(const WCDB::Expression &)condition\n                                                   orders:(const WCDB::OrderingTerms &)orders\n                                                    limit:(const WCDB::Expression &)limit\n                                                   offset:(const WCDB::Expression &)offset\n{\n    return [[[[[[[[self prepareSelect] onResultColumns:resultColumns] fromTable:tableName] where:condition] orders:orders] limit:limit] offset:offset] allObjects];\n}\n\n#pragma mark - Insert\n- (BOOL)insertObject:(WCTObject *)object\n           intoTable:(NSString *)tableName\n{\n    return [[[[self prepareInsert] intoTable:tableName] value:object] execute];\n}\n\n- (BOOL)insertObjects:(NSArray<WCTObject *> *)objects\n            intoTable:(NSString *)tableName\n{\n    return [[[[self prepareInsert] intoTable:tableName] values:objects] execute];\n}\n\n#pragma mark - Insert or Replace\n- (BOOL)insertOrReplaceObject:(WCTObject *)object\n                    intoTable:(NSString *)tableName\n{\n    return [[[[[self prepareInsert] orReplace] intoTable:tableName] value:object] execute];\n}\n\n- (BOOL)insertOrReplaceObjects:(NSArray<WCTObject *> *)objects\n                     intoTable:(NSString *)tableName\n{\n    return [[[[[self prepareInsert] orReplace] intoTable:tableName] values:objects] execute];\n}\n\n#pragma mark - Insert or Ignore\n- (BOOL)insertOrIgnoreObject:(WCTObject *)object\n                   intoTable:(NSString *)tableName\n{\n    return [[[[[self prepareInsert] orIgnore] intoTable:tableName] value:object] execute];\n}\n\n- (BOOL)insertOrIgnoreObjects:(NSArray<WCTObject *> *)objects\n                    intoTable:(NSString *)tableName\n{\n    return [[[[[self prepareInsert] orIgnore] intoTable:tableName] values:objects] execute];\n}\n\n#pragma mark - Partial Insert\n- (BOOL)insertObject:(WCTObject *)object\n        onProperties:(const WCTProperties &)properties\n           intoTable:(NSString *)tableName\n{\n    return [[[[[self prepareInsert] intoTable:tableName] onProperties:properties] value:object] execute];\n}\n\n- (BOOL)insertObjects:(NSArray<WCTObject *> *)objects onProperties:(const WCTProperties &)properties intoTable:(NSString *)tableName\n{\n    return [[[[[self prepareInsert] intoTable:tableName] onProperties:properties] values:objects] execute];\n}\n\n#pragma mark - Partial Insert or Replace\n- (BOOL)insertOrReplaceObject:(WCTObject *)object onProperties:(const WCTProperties &)properties intoTable:(NSString *)tableName\n{\n    return [[[[[[self prepareInsert] orReplace] intoTable:tableName] onProperties:properties] value:object] execute];\n}\n\n- (BOOL)insertOrReplaceObjects:(NSArray<WCTObject *> *)objects onProperties:(const WCTProperties &)properties intoTable:(NSString *)tableName\n{\n    return [[[[[[self prepareInsert] orReplace] intoTable:tableName] onProperties:properties] values:objects] execute];\n}\n\n#pragma mark - Partial Insert or Ignore\n- (BOOL)insertOrIgnoreObject:(WCTObject *)object onProperties:(const WCTProperties &)properties intoTable:(NSString *)tableName\n{\n    return [[[[[[self prepareInsert] orIgnore] intoTable:tableName] onProperties:properties] value:object] execute];\n}\n\n- (BOOL)insertOrIgnoreObjects:(NSArray<WCTObject *> *)objects onProperties:(const WCTProperties &)properties intoTable:(NSString *)tableName\n{\n    return [[[[[[self prepareInsert] orIgnore] intoTable:tableName] onProperties:properties] values:objects] execute];\n}\n\n#pragma mark - Update Properties To Object\n- (BOOL)updateTable:(NSString *)tableName\n      setProperties:(const WCTProperties &)properties\n           toObject:(WCTObject *)object\n{\n    return [[[[[self prepareUpdate] table:tableName] set:properties] toObject:object] execute];\n}\n\n- (BOOL)updateTable:(NSString *)tableName\n      setProperties:(const WCTProperties &)properties\n           toObject:(WCTObject *)object\n              where:(const WCDB::Expression &)condition\n{\n    return [[[[[[self prepareUpdate] table:tableName] set:properties] toObject:object] where:condition] execute];\n}\n\n- (BOOL)updateTable:(NSString *)tableName\n      setProperties:(const WCTProperties &)properties\n           toObject:(WCTObject *)object\n              limit:(const WCDB::Expression &)limit\n{\n    return [[[[[[self prepareUpdate] table:tableName] set:properties] toObject:object] limit:limit] execute];\n}\n\n- (BOOL)updateTable:(NSString *)tableName\n      setProperties:(const WCTProperties &)properties\n           toObject:(WCTObject *)object\n              where:(const WCDB::Expression &)condition\n              limit:(const WCDB::Expression &)limit\n{\n    return [[[[[[[self prepareUpdate] table:tableName] set:properties] toObject:object] where:condition] limit:limit] execute];\n}\n\n- (BOOL)updateTable:(NSString *)tableName\n      setProperties:(const WCTProperties &)properties\n           toObject:(WCTObject *)object\n             orders:(const WCDB::OrderingTerms &)orders\n              limit:(const WCDB::Expression &)limit\n{\n    return [[[[[[[self prepareUpdate] table:tableName] set:properties] toObject:object] orders:orders] limit:limit] execute];\n}\n\n- (BOOL)updateTable:(NSString *)tableName\n      setProperties:(const WCTProperties &)properties\n           toObject:(WCTObject *)object\n              limit:(const WCDB::Expression &)limit\n             offset:(const WCDB::Expression &)offset\n{\n    return [[[[[[[self prepareUpdate] table:tableName] set:properties] toObject:object] limit:limit] offset:offset] execute];\n}\n\n- (BOOL)updateTable:(NSString *)tableName\n      setProperties:(const WCTProperties &)properties\n           toObject:(WCTObject *)object\n              where:(const WCDB::Expression &)condition\n             orders:(const WCDB::OrderingTerms &)orders\n              limit:(const WCDB::Expression &)limit\n{\n    return [[[[[[[[self prepareUpdate] table:tableName] set:properties] toObject:object] where:condition] orders:orders] limit:limit] execute];\n}\n\n- (BOOL)updateTable:(NSString *)tableName\n      setProperties:(const WCTProperties &)properties\n           toObject:(WCTObject *)object\n              where:(const WCDB::Expression &)condition\n              limit:(const WCDB::Expression &)limit\n             offset:(const WCDB::Expression &)offset\n{\n    return [[[[[[[[self prepareUpdate] table:tableName] set:properties] toObject:object] where:condition] limit:limit] offset:offset] execute];\n}\n\n- (BOOL)updateTable:(NSString *)tableName\n      setProperties:(const WCTProperties &)properties\n           toObject:(WCTObject *)object\n             orders:(const WCDB::OrderingTerms &)orders\n              limit:(const WCDB::Expression &)limit\n             offset:(const WCDB::Expression &)offset\n{\n    return [[[[[[[[self prepareUpdate] table:tableName] set:properties] toObject:object] orders:orders] limit:limit] offset:offset] execute];\n}\n\n- (BOOL)updateTable:(NSString *)tableName\n      setProperties:(const WCTProperties &)properties\n           toObject:(WCTObject *)object\n              where:(const WCDB::Expression &)condition\n             orders:(const WCDB::OrderingTerms &)orders\n              limit:(const WCDB::Expression &)limit\n             offset:(const WCDB::Expression &)offset\n{\n    return [[[[[[[[[self prepareUpdate] table:tableName] set:properties] toObject:object] where:condition] orders:orders] limit:limit] offset:offset] execute];\n}\n\n#pragma mark - Update Properties To Row\n- (BOOL)updateTable:(NSString *)tableName\n      setProperties:(const WCTProperties &)properties\n              toRow:(WCTColumnCodingRow *)row\n{\n    return [[[[[self prepareUpdate] table:tableName] set:properties] toRow:row] execute];\n}\n\n- (BOOL)updateTable:(NSString *)tableName\n      setProperties:(const WCTProperties &)properties\n              toRow:(WCTColumnCodingRow *)row\n              where:(const WCDB::Expression &)condition\n{\n    return [[[[[[self prepareUpdate] table:tableName] set:properties] toRow:row] where:condition] execute];\n}\n\n- (BOOL)updateTable:(NSString *)tableName\n      setProperties:(const WCTProperties &)properties\n              toRow:(WCTColumnCodingRow *)row\n              limit:(const WCDB::Expression &)limit\n{\n    return [[[[[[self prepareUpdate] table:tableName] set:properties] toRow:row] limit:limit] execute];\n}\n\n- (BOOL)updateTable:(NSString *)tableName\n      setProperties:(const WCTProperties &)properties\n              toRow:(WCTColumnCodingRow *)row\n              where:(const WCDB::Expression &)condition\n              limit:(const WCDB::Expression &)limit\n{\n    return [[[[[[[self prepareUpdate] table:tableName] set:properties] toRow:row] where:condition] limit:limit] execute];\n}\n\n- (BOOL)updateTable:(NSString *)tableName\n      setProperties:(const WCTProperties &)properties\n              toRow:(WCTColumnCodingRow *)row\n             orders:(const WCDB::OrderingTerms &)orders\n              limit:(const WCDB::Expression &)limit\n{\n    return [[[[[[[self prepareUpdate] table:tableName] set:properties] toRow:row] orders:orders] limit:limit] execute];\n}\n\n- (BOOL)updateTable:(NSString *)tableName\n      setProperties:(const WCTProperties &)properties\n              toRow:(WCTColumnCodingRow *)row\n              limit:(const WCDB::Expression &)limit\n             offset:(const WCDB::Expression &)offset\n{\n    return [[[[[[[self prepareUpdate] table:tableName] set:properties] toRow:row] limit:limit] offset:offset] execute];\n}\n\n- (BOOL)updateTable:(NSString *)tableName\n      setProperties:(const WCTProperties &)properties\n              toRow:(WCTColumnCodingRow *)row\n              where:(const WCDB::Expression &)condition\n             orders:(const WCDB::OrderingTerms &)orders\n              limit:(const WCDB::Expression &)limit\n{\n    return [[[[[[[[self prepareUpdate] table:tableName] set:properties] toRow:row] where:condition] orders:orders] limit:limit] execute];\n}\n\n- (BOOL)updateTable:(NSString *)tableName\n      setProperties:(const WCTProperties &)properties\n              toRow:(WCTColumnCodingRow *)row\n              where:(const WCDB::Expression &)condition\n              limit:(const WCDB::Expression &)limit\n             offset:(const WCDB::Expression &)offset\n{\n    return [[[[[[[[self prepareUpdate] table:tableName] set:properties] toRow:row] where:condition] limit:limit] offset:offset] execute];\n}\n\n- (BOOL)updateTable:(NSString *)tableName\n      setProperties:(const WCTProperties &)properties\n              toRow:(WCTColumnCodingRow *)row\n             orders:(const WCDB::OrderingTerms &)orders\n              limit:(const WCDB::Expression &)limit\n             offset:(const WCDB::Expression &)offset\n{\n    return [[[[[[[[self prepareUpdate] table:tableName] set:properties] toRow:row] orders:orders] limit:limit] offset:offset] execute];\n}\n\n- (BOOL)updateTable:(NSString *)tableName\n      setProperties:(const WCTProperties &)properties\n              toRow:(WCTColumnCodingRow *)row\n              where:(const WCDB::Expression &)condition\n             orders:(const WCDB::OrderingTerms &)orders\n              limit:(const WCDB::Expression &)limit\n             offset:(const WCDB::Expression &)offset\n{\n    return [[[[[[[[[self prepareUpdate] table:tableName] set:properties] toRow:row] where:condition] orders:orders] limit:limit] offset:offset] execute];\n}\n\n#pragma mark - Update Property To Value\n- (BOOL)updateTable:(NSString *)tableName\n        setProperty:(const WCTProperty &)property\n            toValue:(WCTColumnCodingValue *)value\n{\n    return [[[[[self prepareUpdate] table:tableName] set:property] toValue:value] execute];\n}\n\n- (BOOL)updateTable:(NSString *)tableName\n        setProperty:(const WCTProperty &)property\n            toValue:(WCTColumnCodingValue *)value\n              where:(const WCDB::Expression &)condition\n{\n    return [[[[[[self prepareUpdate] table:tableName] set:property] toValue:value] where:condition] execute];\n}\n\n- (BOOL)updateTable:(NSString *)tableName\n        setProperty:(const WCTProperty &)property\n            toValue:(WCTColumnCodingValue *)value\n              limit:(const WCDB::Expression &)limit\n{\n    return [[[[[[self prepareUpdate] table:tableName] set:property] toValue:value] limit:limit] execute];\n}\n\n- (BOOL)updateTable:(NSString *)tableName\n        setProperty:(const WCTProperty &)property\n            toValue:(WCTColumnCodingValue *)value\n              where:(const WCDB::Expression &)condition\n              limit:(const WCDB::Expression &)limit\n{\n    return [[[[[[[self prepareUpdate] table:tableName] set:property] toValue:value] where:condition] limit:limit] execute];\n}\n\n- (BOOL)updateTable:(NSString *)tableName\n        setProperty:(const WCTProperty &)property\n            toValue:(WCTColumnCodingValue *)value\n             orders:(const WCDB::OrderingTerms &)orders\n              limit:(const WCDB::Expression &)limit\n{\n    return [[[[[[[self prepareUpdate] table:tableName] set:property] toValue:value] orders:orders] limit:limit] execute];\n}\n\n- (BOOL)updateTable:(NSString *)tableName\n        setProperty:(const WCTProperty &)property\n            toValue:(WCTColumnCodingValue *)value\n              limit:(const WCDB::Expression &)limit\n             offset:(const WCDB::Expression &)offset\n{\n    return [[[[[[[self prepareUpdate] table:tableName] set:property] toValue:value] limit:limit] offset:offset] execute];\n}\n\n- (BOOL)updateTable:(NSString *)tableName\n        setProperty:(const WCTProperty &)property\n            toValue:(WCTColumnCodingValue *)value\n              where:(const WCDB::Expression &)condition\n             orders:(const WCDB::OrderingTerms &)orders\n              limit:(const WCDB::Expression &)limit\n{\n    return [[[[[[[[self prepareUpdate] table:tableName] set:property] toValue:value] where:condition] orders:orders] limit:limit] execute];\n}\n\n- (BOOL)updateTable:(NSString *)tableName\n        setProperty:(const WCTProperty &)property\n            toValue:(WCTColumnCodingValue *)value\n              where:(const WCDB::Expression &)condition\n              limit:(const WCDB::Expression &)limit\n             offset:(const WCDB::Expression &)offset\n{\n    return [[[[[[[[self prepareUpdate] table:tableName] set:property] toValue:value] where:condition] limit:limit] offset:offset] execute];\n}\n\n- (BOOL)updateTable:(NSString *)tableName\n        setProperty:(const WCTProperty &)property\n            toValue:(WCTColumnCodingValue *)value\n             orders:(const WCDB::OrderingTerms &)orders\n              limit:(const WCDB::Expression &)limit\n             offset:(const WCDB::Expression &)offset\n{\n    return [[[[[[[[self prepareUpdate] table:tableName] set:property] toValue:value] orders:orders] limit:limit] offset:offset] execute];\n}\n\n- (BOOL)updateTable:(NSString *)tableName\n        setProperty:(const WCTProperty &)property\n            toValue:(WCTColumnCodingValue *)value\n              where:(const WCDB::Expression &)condition\n             orders:(const WCDB::OrderingTerms &)orders\n              limit:(const WCDB::Expression &)limit\n             offset:(const WCDB::Expression &)offset\n{\n    return [[[[[[[[[self prepareUpdate] table:tableName] set:property] toValue:value] where:condition] orders:orders] limit:limit] offset:offset] execute];\n}\n\n#pragma mark - Delete\n- (BOOL)deleteFromTable:(NSString *)tableName\n{\n    return [[[self prepareDelete] fromTable:tableName] execute];\n}\n\n- (BOOL)deleteFromTable:(NSString *)tableName\n                  where:(const WCDB::Expression &)condition\n{\n    return [[[[self prepareDelete] fromTable:tableName] where:condition] execute];\n}\n\n- (BOOL)deleteFromTable:(NSString *)tableName\n                  limit:(const WCDB::Expression &)limit\n{\n    return [[[[self prepareDelete] fromTable:tableName] limit:limit] execute];\n}\n\n- (BOOL)deleteFromTable:(NSString *)tableName\n                  where:(const WCDB::Expression &)condition\n                  limit:(const WCDB::Expression &)limit\n{\n    return [[[[[self prepareDelete] fromTable:tableName] where:condition] limit:limit] execute];\n}\n\n- (BOOL)deleteFromTable:(NSString *)tableName\n                 orders:(const WCDB::OrderingTerms &)orders\n                  limit:(const WCDB::Expression &)limit\n{\n    return [[[[[self prepareDelete] fromTable:tableName] orders:orders] limit:limit] execute];\n}\n\n- (BOOL)deleteFromTable:(NSString *)tableName\n                  limit:(const WCDB::Expression &)limit\n                 offset:(const WCDB::Expression &)offset\n{\n    return [[[[[self prepareDelete] fromTable:tableName] limit:limit] offset:offset] execute];\n}\n\n- (BOOL)deleteFromTable:(NSString *)tableName\n                  where:(const WCDB::Expression &)condition\n                 orders:(const WCDB::OrderingTerms &)orders\n                  limit:(const WCDB::Expression &)limit\n{\n    return [[[[[[self prepareDelete] fromTable:tableName] where:condition] orders:orders] limit:limit] execute];\n}\n\n- (BOOL)deleteFromTable:(NSString *)tableName\n                  where:(const WCDB::Expression &)condition\n                  limit:(const WCDB::Expression &)limit\n                 offset:(const WCDB::Expression &)offset\n{\n    return [[[[[[self prepareDelete] fromTable:tableName] where:condition] limit:limit] offset:offset] execute];\n}\n\n- (BOOL)deleteFromTable:(NSString *)tableName\n                 orders:(const WCDB::OrderingTerms &)orders\n                  limit:(const WCDB::Expression &)limit\n                 offset:(const WCDB::Expression &)offset\n{\n    return [[[[[[self prepareDelete] fromTable:tableName] orders:orders] limit:limit] offset:offset] execute];\n}\n\n- (BOOL)deleteFromTable:(NSString *)tableName\n                  where:(const WCDB::Expression &)condition\n                 orders:(const WCDB::OrderingTerms &)orders\n                  limit:(const WCDB::Expression &)limit\n                 offset:(const WCDB::Expression &)offset\n{\n    return [[[[[[[self prepareDelete] fromTable:tableName] where:condition] orders:orders] limit:limit] offset:offset] execute];\n}\n\n#pragma mark - Get Value\n- (WCTValue *)getValueOnResultColumn:(const WCDB::ResultColumn &)resultColumn\n                           fromTable:(NSString *)tableName\n{\n    return [self getValueFromStatement:WCDB::StatementSelect().select(resultColumn).from(tableName).order(WCDB::OrderingTerm::ascendingRowid()).limit(1)];\n}\n\n- (WCTValue *)getValueOnResultColumn:(const WCDB::ResultColumn &)resultColumn\n                           fromTable:(NSString *)tableName\n                               where:(const WCDB::Expression &)condition\n{\n    return [self getValueFromStatement:WCDB::StatementSelect().select(resultColumn).from(tableName).where(condition).order(WCDB::OrderingTerm::ascendingRowid()).limit(1)];\n}\n\n- (WCTValue *)getValueOnResultColumn:(const WCDB::ResultColumn &)resultColumn\n                           fromTable:(NSString *)tableName\n                              orders:(const WCDB::OrderingTerms &)orders\n{\n    return [self getValueFromStatement:WCDB::StatementSelect().select(resultColumn).from(tableName).orders(orders).limit(1)];\n}\n\n- (WCTValue *)getValueOnResultColumn:(const WCDB::ResultColumn &)resultColumn\n                           fromTable:(NSString *)tableName\n                              offset:(const WCDB::Expression &)offset\n{\n    return [self getValueFromStatement:WCDB::StatementSelect().select(resultColumn).from(tableName).order(WCDB::OrderingTerm::ascendingRowid()).limit(1).offset(offset)];\n}\n\n- (WCTValue *)getValueOnResultColumn:(const WCDB::ResultColumn &)resultColumn\n                           fromTable:(NSString *)tableName\n                               where:(const WCDB::Expression &)condition\n                              orders:(const WCDB::OrderingTerms &)orders\n{\n    return [self getValueFromStatement:WCDB::StatementSelect().select(resultColumn).from(tableName).where(condition).orders(orders).limit(1)];\n}\n\n- (WCTValue *)getValueOnResultColumn:(const WCDB::ResultColumn &)resultColumn\n                           fromTable:(NSString *)tableName\n                               where:(const WCDB::Expression &)condition\n                              offset:(const WCDB::Expression &)offset\n{\n    return [self getValueFromStatement:WCDB::StatementSelect().select(resultColumn).from(tableName).where(condition).order(WCDB::OrderingTerm::ascendingRowid()).limit(1).offset(offset)];\n}\n\n- (WCTValue *)getValueOnResultColumn:(const WCDB::ResultColumn &)resultColumn\n                           fromTable:(NSString *)tableName\n                              orders:(const WCDB::OrderingTerms &)orders\n                              offset:(const WCDB::Expression &)offset\n{\n    return [self getValueFromStatement:WCDB::StatementSelect().select(resultColumn).from(tableName).orders(orders).limit(1).offset(offset)];\n}\n\n- (WCTValue *)getValueOnResultColumn:(const WCDB::ResultColumn &)resultColumn\n                           fromTable:(NSString *)tableName\n                               where:(const WCDB::Expression &)condition\n                              orders:(const WCDB::OrderingTerms &)orders\n                              offset:(const WCDB::Expression &)offset\n{\n    return [self getValueFromStatement:WCDB::StatementSelect().select(resultColumn).from(tableName).where(condition).orders(orders).limit(1).offset(offset)];\n}\n\n#pragma mark - Get Row\n- (WCTOneRow *)getRowOnResultColumns:(const WCDB::ResultColumns &)resultColumns\n                           fromTable:(NSString *)tableName\n{\n    return [self getRowFromStatement:WCDB::StatementSelect().select(resultColumns).from(tableName).order(WCDB::OrderingTerm::ascendingRowid()).limit(1)];\n}\n\n- (WCTOneRow *)getRowOnResultColumns:(const WCDB::ResultColumns &)resultColumns\n                           fromTable:(NSString *)tableName\n                               where:(const WCDB::Expression &)condition\n{\n    return [self getRowFromStatement:WCDB::StatementSelect().select(resultColumns).from(tableName).where(condition).order(WCDB::OrderingTerm::ascendingRowid()).limit(1)];\n}\n\n- (WCTOneRow *)getRowOnResultColumns:(const WCDB::ResultColumns &)resultColumns\n                           fromTable:(NSString *)tableName\n                              orders:(const WCDB::OrderingTerms &)orders\n{\n    return [self getRowFromStatement:WCDB::StatementSelect().select(resultColumns).from(tableName).orders(orders).limit(1)];\n}\n\n- (WCTOneRow *)getRowOnResultColumns:(const WCDB::ResultColumns &)resultColumns\n                           fromTable:(NSString *)tableName\n                              offset:(const WCDB::Expression &)offset\n{\n    return [self getRowFromStatement:WCDB::StatementSelect().select(resultColumns).from(tableName).order(WCDB::OrderingTerm::ascendingRowid()).limit(1).offset(offset)];\n}\n\n- (WCTOneRow *)getRowOnResultColumns:(const WCDB::ResultColumns &)resultColumns\n                           fromTable:(NSString *)tableName\n                               where:(const WCDB::Expression &)condition\n                              orders:(const WCDB::OrderingTerms &)orders\n{\n    return [self getRowFromStatement:WCDB::StatementSelect().select(resultColumns).from(tableName).where(condition).orders(orders).limit(1)];\n}\n\n- (WCTOneRow *)getRowOnResultColumns:(const WCDB::ResultColumns &)resultColumns\n                           fromTable:(NSString *)tableName\n                               where:(const WCDB::Expression &)condition\n                              offset:(const WCDB::Expression &)offset\n{\n    return [self getRowFromStatement:WCDB::StatementSelect().select(resultColumns).from(tableName).where(condition).order(WCDB::OrderingTerm::ascendingRowid()).limit(1).offset(offset)];\n}\n\n- (WCTOneRow *)getRowOnResultColumns:(const WCDB::ResultColumns &)resultColumns\n                           fromTable:(NSString *)tableName\n                              orders:(const WCDB::OrderingTerms &)orders\n                              offset:(const WCDB::Expression &)offset\n{\n    return [self getRowFromStatement:WCDB::StatementSelect().select(resultColumns).from(tableName).orders(orders).limit(1).offset(offset)];\n}\n\n- (WCTOneRow *)getRowOnResultColumns:(const WCDB::ResultColumns &)resultColumns\n                           fromTable:(NSString *)tableName\n                               where:(const WCDB::Expression &)condition\n                              orders:(const WCDB::OrderingTerms &)orders\n                              offset:(const WCDB::Expression &)offset\n{\n    return [self getRowFromStatement:WCDB::StatementSelect().select(resultColumns).from(tableName).where(condition).orders(orders).limit(1).offset(offset)];\n}\n\n#pragma mark - Get Column\n- (WCTOneColumn *)getColumnOnResultColumn:(const WCDB::ResultColumn &)resultColumn\n                                fromTable:(NSString *)tableName\n{\n    return [self getColumnFromStatement:WCDB::StatementSelect().select(resultColumn).from(tableName).order(WCDB::OrderingTerm::ascendingRowid())];\n}\n\n- (WCTOneColumn *)getColumnOnResultColumn:(const WCDB::ResultColumn &)resultColumn\n                                fromTable:(NSString *)tableName\n                                    where:(const WCDB::Expression &)condition\n{\n    return [self getColumnFromStatement:WCDB::StatementSelect().select(resultColumn).from(tableName).where(condition).order(WCDB::OrderingTerm::ascendingRowid())];\n}\n\n- (WCTOneColumn *)getColumnOnResultColumn:(const WCDB::ResultColumn &)resultColumn\n                                fromTable:(NSString *)tableName\n                                   orders:(const WCDB::OrderingTerms &)orders\n{\n    return [self getColumnFromStatement:WCDB::StatementSelect().select(resultColumn).from(tableName).orders(orders)];\n}\n\n- (WCTOneColumn *)getColumnOnResultColumn:(const WCDB::ResultColumn &)resultColumn\n                                fromTable:(NSString *)tableName\n                                    limit:(const WCDB::Expression &)limit\n{\n    return [self getColumnFromStatement:WCDB::StatementSelect().select(resultColumn).from(tableName).order(WCDB::OrderingTerm::ascendingRowid()).limit(limit)];\n}\n\n- (WCTOneColumn *)getColumnOnResultColumn:(const WCDB::ResultColumn &)resultColumn\n                                fromTable:(NSString *)tableName\n                                    where:(const WCDB::Expression &)condition\n                                   orders:(const WCDB::OrderingTerms &)orders\n{\n    return [self getColumnFromStatement:WCDB::StatementSelect().select(resultColumn).from(tableName).where(condition).orders(orders)];\n}\n\n- (WCTOneColumn *)getColumnOnResultColumn:(const WCDB::ResultColumn &)resultColumn\n                                fromTable:(NSString *)tableName\n                                    where:(const WCDB::Expression &)condition\n                                    limit:(const WCDB::Expression &)limit\n{\n    return [self getColumnFromStatement:WCDB::StatementSelect().select(resultColumn).from(tableName).where(condition).order(WCDB::OrderingTerm::ascendingRowid()).limit(limit)];\n}\n\n- (WCTOneColumn *)getColumnOnResultColumn:(const WCDB::ResultColumn &)resultColumn\n                                fromTable:(NSString *)tableName\n                                   orders:(const WCDB::OrderingTerms &)orders\n                                    limit:(const WCDB::Expression &)limit\n{\n    return [self getColumnFromStatement:WCDB::StatementSelect().select(resultColumn).from(tableName).orders(orders).limit(limit)];\n}\n\n- (WCTOneColumn *)getColumnOnResultColumn:(const WCDB::ResultColumn &)resultColumn\n                                fromTable:(NSString *)tableName\n                                    limit:(const WCDB::Expression &)limit\n                                   offset:(const WCDB::Expression &)offset\n{\n    return [self getColumnFromStatement:WCDB::StatementSelect().select(resultColumn).from(tableName).order(WCDB::OrderingTerm::ascendingRowid()).limit(limit).offset(offset)];\n}\n\n- (WCTOneColumn *)getColumnOnResultColumn:(const WCDB::ResultColumn &)resultColumn\n                                fromTable:(NSString *)tableName\n                                    where:(const WCDB::Expression &)condition\n                                   orders:(const WCDB::OrderingTerms &)orders\n                                    limit:(const WCDB::Expression &)limit\n{\n    return [self getColumnFromStatement:WCDB::StatementSelect().select(resultColumn).from(tableName).where(condition).orders(orders).limit(limit)];\n}\n\n- (WCTOneColumn *)getColumnOnResultColumn:(const WCDB::ResultColumn &)resultColumn\n                                fromTable:(NSString *)tableName\n                                   orders:(const WCDB::OrderingTerms &)orders\n                                    limit:(const WCDB::Expression &)limit\n                                   offset:(const WCDB::Expression &)offset\n{\n    return [self getColumnFromStatement:WCDB::StatementSelect().select(resultColumn).from(tableName).orders(orders).limit(limit).offset(offset)];\n}\n\n- (WCTOneColumn *)getColumnOnResultColumn:(const WCDB::ResultColumn &)resultColumn\n                                fromTable:(NSString *)tableName\n                                    where:(const WCDB::Expression &)condition\n                                    limit:(const WCDB::Expression &)limit\n                                   offset:(const WCDB::Expression &)offset\n{\n    return [self getColumnFromStatement:WCDB::StatementSelect().select(resultColumn).from(tableName).where(condition).order(WCDB::OrderingTerm::ascendingRowid()).limit(limit).offset(offset)];\n}\n\n- (WCTOneColumn *)getColumnOnResultColumn:(const WCDB::ResultColumn &)resultColumn\n                                fromTable:(NSString *)tableName\n                                    where:(const WCDB::Expression &)condition\n                                   orders:(const WCDB::OrderingTerms &)orders\n                                    limit:(const WCDB::Expression &)limit\n                                   offset:(const WCDB::Expression &)offset\n{\n    return [self getColumnFromStatement:WCDB::StatementSelect().select(resultColumn).from(tableName).where(condition).orders(orders).limit(limit).offset(offset)];\n}\n\n#pragma mark - Get Rows\n- (WCTColumnsXRows *)getRowsOnResultColumns:(const WCDB::ResultColumns &)resultColumns\n                                  fromTable:(NSString *)tableName\n{\n    return [self getRowsFromStatement:WCDB::StatementSelect().select(resultColumns).from(tableName).order(WCDB::OrderingTerm::ascendingRowid())];\n}\n\n- (WCTColumnsXRows *)getRowsOnResultColumns:(const WCDB::ResultColumns &)resultColumns\n                                  fromTable:(NSString *)tableName\n                                      where:(const WCDB::Expression &)condition\n{\n    return [self getRowsFromStatement:WCDB::StatementSelect().select(resultColumns).from(tableName).where(condition).order(WCDB::OrderingTerm::ascendingRowid())];\n}\n\n- (WCTColumnsXRows *)getRowsOnResultColumns:(const WCDB::ResultColumns &)resultColumns\n                                  fromTable:(NSString *)tableName\n                                     orders:(const WCDB::OrderingTerms &)orders\n{\n    return [self getRowsFromStatement:WCDB::StatementSelect().select(resultColumns).from(tableName).orders(orders)];\n}\n\n- (WCTColumnsXRows *)getRowsOnResultColumns:(const WCDB::ResultColumns &)resultColumns\n                                  fromTable:(NSString *)tableName\n                                      limit:(const WCDB::Expression &)limit\n{\n    return [self getRowsFromStatement:WCDB::StatementSelect().select(resultColumns).from(tableName).order(WCDB::OrderingTerm::ascendingRowid()).limit(limit)];\n}\n\n- (WCTColumnsXRows *)getRowsOnResultColumns:(const WCDB::ResultColumns &)resultColumns\n                                  fromTable:(NSString *)tableName\n                                      where:(const WCDB::Expression &)condition\n                                     orders:(const WCDB::OrderingTerms &)orders\n{\n    return [self getRowsFromStatement:WCDB::StatementSelect().select(resultColumns).from(tableName).where(condition).orders(orders)];\n}\n\n- (WCTColumnsXRows *)getRowsOnResultColumns:(const WCDB::ResultColumns &)resultColumns\n                                  fromTable:(NSString *)tableName\n                                      where:(const WCDB::Expression &)condition\n                                      limit:(const WCDB::Expression &)limit\n{\n    return [self getRowsFromStatement:WCDB::StatementSelect().select(resultColumns).from(tableName).where(condition).order(WCDB::OrderingTerm::ascendingRowid()).limit(limit)];\n}\n\n- (WCTColumnsXRows *)getRowsOnResultColumns:(const WCDB::ResultColumns &)resultColumns\n                                  fromTable:(NSString *)tableName\n                                     orders:(const WCDB::OrderingTerms &)orders\n                                      limit:(const WCDB::Expression &)limit\n{\n    return [self getRowsFromStatement:WCDB::StatementSelect().select(resultColumns).from(tableName).orders(orders).limit(limit)];\n}\n\n- (WCTColumnsXRows *)getRowsOnResultColumns:(const WCDB::ResultColumns &)resultColumns\n                                  fromTable:(NSString *)tableName\n                                      limit:(const WCDB::Expression &)limit\n                                     offset:(const WCDB::Expression &)offset\n{\n    return [self getRowsFromStatement:WCDB::StatementSelect().select(resultColumns).from(tableName).order(WCDB::OrderingTerm::ascendingRowid()).limit(limit).offset(offset)];\n}\n\n- (WCTColumnsXRows *)getRowsOnResultColumns:(const WCDB::ResultColumns &)resultColumns\n                                  fromTable:(NSString *)tableName\n                                      where:(const WCDB::Expression &)condition\n                                     orders:(const WCDB::OrderingTerms &)orders\n                                      limit:(const WCDB::Expression &)limit\n{\n    return [self getRowsFromStatement:WCDB::StatementSelect().select(resultColumns).from(tableName).where(condition).orders(orders).limit(limit)];\n}\n\n- (WCTColumnsXRows *)getRowsOnResultColumns:(const WCDB::ResultColumns &)resultColumns\n                                  fromTable:(NSString *)tableName\n                                     orders:(const WCDB::OrderingTerms &)orders\n                                      limit:(const WCDB::Expression &)limit\n                                     offset:(const WCDB::Expression &)offset\n{\n    return [self getRowsFromStatement:WCDB::StatementSelect().select(resultColumns).from(tableName).orders(orders).limit(limit).offset(offset)];\n}\n\n- (WCTColumnsXRows *)getRowsOnResultColumns:(const WCDB::ResultColumns &)resultColumns\n                                  fromTable:(NSString *)tableName\n                                      where:(const WCDB::Expression &)condition\n                                      limit:(const WCDB::Expression &)limit\n                                     offset:(const WCDB::Expression &)offset\n{\n    return [self getRowsFromStatement:WCDB::StatementSelect().select(resultColumns).from(tableName).where(condition).order(WCDB::OrderingTerm::ascendingRowid()).limit(limit).offset(offset)];\n}\n\n- (WCTColumnsXRows *)getRowsOnResultColumns:(const WCDB::ResultColumns &)resultColumns\n                                  fromTable:(NSString *)tableName\n                                      where:(const WCDB::Expression &)condition\n                                     orders:(const WCDB::OrderingTerms &)orders\n                                      limit:(const WCDB::Expression &)limit\n                                     offset:(const WCDB::Expression &)offset\n{\n    return [self getRowsFromStatement:WCDB::StatementSelect().select(resultColumns).from(tableName).where(condition).orders(orders).limit(limit).offset(offset)];\n}\n\n#pragma mark - Get From Statement\n- (WCTValue *)getValueFromStatement:(const WCDB::Statement &)statement\n{\n    WCTValue *result = nil;\n    WCTHandle *handle = [self getHandle];\n    [handle setWriteHint:NO];\n    if ([handle prepare:statement]) {\n        if ([handle step]) {\n            result = [handle extractValueAtIndex:0];\n        }\n        [handle finalizeStatement];\n    }\n    [handle invalidate];\n    return result;\n}\n\n- (WCTOneRow *)getRowFromStatement:(const WCDB::Statement &)statement\n{\n    WCTOneRow *result = nil;\n    WCTHandle *handle = [self getHandle];\n    [handle setWriteHint:NO];\n    if ([handle prepare:statement]) {\n        if ([handle step]) {\n            result = [handle extractRow];\n        }\n        [handle finalizeStatement];\n    };\n    [handle invalidate];\n    return result;\n}\n\n- (WCTOneColumn *)getColumnFromStatement:(const WCDB::Statement &)statement\n{\n    WCTOneColumn *result = nil;\n    WCTHandle *handle = [self getHandle];\n    [handle setWriteHint:NO];\n    if ([handle prepare:statement]) {\n        result = [handle allValues];\n        [handle finalizeStatement];\n    }\n    [handle invalidate];\n    return result;\n}\n\n- (WCTColumnsXRows *)getRowsFromStatement:(const WCDB::Statement &)statement\n{\n    WCTColumnsXRows *result = nil;\n    WCTHandle *handle = [self getHandle];\n    [handle setWriteHint:NO];\n    if ([handle prepare:statement]) {\n        result = [handle allRows];\n        [handle finalizeStatement];\n    }\n    [handle invalidate];\n    return result;\n}\n\n@end\n"
  },
  {
    "path": "src/objc/convenient/WCTHandle+Convenient.h",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"WCTConvenient.h\"\n#import \"WCTHandle.h\"\n\nNS_ASSUME_NONNULL_BEGIN\n\nWCDB_API @interface WCTHandle(Convenient)<WCTConvenient>\n\n@end\n\nNS_ASSUME_NONNULL_END\n"
  },
  {
    "path": "src/objc/convenient/WCTHandle+Convenient.mm",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"WCTChainCall+Private.h\"\n#import \"WCTDelete.h\"\n#import \"WCTHandle+ChainCall.h\"\n#import \"WCTHandle+Private.h\"\n#import \"WCTInsert.h\"\n#import \"WCTMultiSelect.h\"\n#import \"WCTORM.h\"\n#import \"WCTSelect.h\"\n#import \"WCTSelectable+Private.h\"\n#import \"WCTUpdate.h\"\n\n@implementation WCTHandle (Convenient)\n#pragma mark - Get Object\n- (id /* WCTObject* */)getObjectOfClass:(Class)cls\n                              fromTable:(NSString *)tableName\n{\n    return [[[[[self prepareSelect] ofClass:cls] fromTable:tableName] limit:1] firstObject];\n}\n\n- (id /* WCTObject* */)getObjectOfClass:(Class)cls\n                              fromTable:(NSString *)tableName\n                                  where:(const WCDB::Expression &)condition\n{\n    return [[[[[[self prepareSelect] ofClass:cls] fromTable:tableName] where:condition] limit:1] firstObject];\n}\n\n- (id /* WCTObject* */)getObjectOfClass:(Class)cls\n                              fromTable:(NSString *)tableName\n                                 orders:(const WCDB::OrderingTerms &)orders\n{\n    return [[[[[[self prepareSelect] ofClass:cls] fromTable:tableName] orders:orders] limit:1] firstObject];\n}\n\n- (id /* WCTObject* */)getObjectOfClass:(Class)cls\n                              fromTable:(NSString *)tableName\n                                 offset:(const WCDB::Expression &)offset\n{\n    return [[[[[[self prepareSelect] ofClass:cls] fromTable:tableName] limit:1] offset:offset] firstObject];\n}\n\n- (id /* WCTObject* */)getObjectOfClass:(Class)cls\n                              fromTable:(NSString *)tableName\n                                  where:(const WCDB::Expression &)condition\n                                 orders:(const WCDB::OrderingTerms &)orders\n{\n    return [[[[[[[self prepareSelect] ofClass:cls] fromTable:tableName] where:condition] orders:orders] limit:1] firstObject];\n}\n\n- (id /* WCTObject* */)getObjectOfClass:(Class)cls\n                              fromTable:(NSString *)tableName\n                                  where:(const WCDB::Expression &)condition\n                                 offset:(const WCDB::Expression &)offset\n{\n    return [[[[[[[self prepareSelect] ofClass:cls] fromTable:tableName] where:condition] limit:1] offset:offset] firstObject];\n}\n\n- (id /* WCTObject* */)getObjectOfClass:(Class)cls\n                              fromTable:(NSString *)tableName\n                                 orders:(const WCDB::OrderingTerms &)orders\n                                 offset:(const WCDB::Expression &)offset\n{\n    return [[[[[[[self prepareSelect] ofClass:cls] fromTable:tableName] orders:orders] limit:1] offset:offset] firstObject];\n}\n\n- (id /* WCTObject* */)getObjectOfClass:(Class)cls\n                              fromTable:(NSString *)tableName\n                                  where:(const WCDB::Expression &)condition\n                                 orders:(const WCDB::OrderingTerms &)orders\n                                 offset:(const WCDB::Expression &)offset\n{\n    return [[[[[[[[self prepareSelect] ofClass:cls] fromTable:tableName] where:condition] orders:orders] limit:1] offset:offset] firstObject];\n}\n\n#pragma mark - Get Objects\n- (NSArray /* <WCTObject*> */ *)getObjectsOfClass:(Class)cls\n                                        fromTable:(NSString *)tableName\n{\n    return [[[[self prepareSelect] ofClass:cls] fromTable:tableName] allObjects];\n}\n\n- (NSArray /* <WCTObject*> */ *)getObjectsOfClass:(Class)cls\n                                        fromTable:(NSString *)tableName\n                                            where:(const WCDB::Expression &)condition\n{\n    return [[[[[self prepareSelect] ofClass:cls] fromTable:tableName] where:condition] allObjects];\n}\n\n- (NSArray /* <WCTObject*> */ *)getObjectsOfClass:(Class)cls\n                                        fromTable:(NSString *)tableName\n                                           orders:(const WCDB::OrderingTerms &)orders\n{\n    return [[[[[self prepareSelect] ofClass:cls] fromTable:tableName] orders:orders] allObjects];\n}\n\n- (NSArray /* <WCTObject*> */ *)getObjectsOfClass:(Class)cls\n                                        fromTable:(NSString *)tableName\n                                            limit:(const WCDB::Expression &)limit\n{\n    return [[[[[self prepareSelect] ofClass:cls] fromTable:tableName] limit:limit] allObjects];\n}\n\n- (NSArray /* <WCTObject*> */ *)getObjectsOfClass:(Class)cls\n                                        fromTable:(NSString *)tableName\n                                            where:(const WCDB::Expression &)condition\n                                           orders:(const WCDB::OrderingTerms &)orders\n{\n    return [[[[[[self prepareSelect] ofClass:cls] fromTable:tableName] where:condition] orders:orders] allObjects];\n}\n\n- (NSArray /* <WCTObject*> */ *)getObjectsOfClass:(Class)cls\n                                        fromTable:(NSString *)tableName\n                                            where:(const WCDB::Expression &)condition\n                                            limit:(const WCDB::Expression &)limit\n{\n    return [[[[[[self prepareSelect] ofClass:cls] fromTable:tableName] where:condition] limit:limit] allObjects];\n}\n\n- (NSArray /* <WCTObject*> */ *)getObjectsOfClass:(Class)cls\n                                        fromTable:(NSString *)tableName\n                                           orders:(const WCDB::OrderingTerms &)orders\n                                            limit:(const WCDB::Expression &)limit\n{\n    return [[[[[[self prepareSelect] ofClass:cls] fromTable:tableName] orders:orders] limit:limit] allObjects];\n}\n\n- (NSArray /* <WCTObject*> */ *)getObjectsOfClass:(Class)cls\n                                        fromTable:(NSString *)tableName\n                                            limit:(const WCDB::Expression &)limit\n                                           offset:(const WCDB::Expression &)offset\n{\n    return [[[[[[self prepareSelect] ofClass:cls] fromTable:tableName] limit:limit] offset:offset] allObjects];\n}\n\n- (NSArray /* <WCTObject*> */ *)getObjectsOfClass:(Class)cls\n                                        fromTable:(NSString *)tableName\n                                            where:(const WCDB::Expression &)condition\n                                           orders:(const WCDB::OrderingTerms &)orders\n                                            limit:(const WCDB::Expression &)limit\n{\n    return [[[[[[[self prepareSelect] ofClass:cls] fromTable:tableName] where:condition] orders:orders] limit:limit] allObjects];\n}\n\n- (NSArray /* <WCTObject*> */ *)getObjectsOfClass:(Class)cls\n                                        fromTable:(NSString *)tableName\n                                           orders:(const WCDB::OrderingTerms &)orders\n                                            limit:(const WCDB::Expression &)limit\n                                           offset:(const WCDB::Expression &)offset\n{\n    return [[[[[[[self prepareSelect] ofClass:cls] fromTable:tableName] orders:orders] limit:limit] offset:offset] allObjects];\n}\n\n- (NSArray /* <WCTObject*> */ *)getObjectsOfClass:(Class)cls\n                                        fromTable:(NSString *)tableName\n                                            where:(const WCDB::Expression &)condition\n                                            limit:(const WCDB::Expression &)limit\n                                           offset:(const WCDB::Expression &)offset\n{\n    return [[[[[[[self prepareSelect] ofClass:cls] fromTable:tableName] where:condition] limit:limit] offset:offset] allObjects];\n}\n\n- (NSArray /* <WCTObject*> */ *)getObjectsOfClass:(Class)cls\n                                        fromTable:(NSString *)tableName\n                                            where:(const WCDB::Expression &)condition\n                                           orders:(const WCDB::OrderingTerms &)orders\n                                            limit:(const WCDB::Expression &)limit\n                                           offset:(const WCDB::Expression &)offset\n{\n    return [[[[[[[[self prepareSelect] ofClass:cls] fromTable:tableName] where:condition] orders:orders] limit:limit] offset:offset] allObjects];\n}\n\n#pragma mark - Get Part Of Object\n- (id /* WCTObject* */)getObjectOnResultColumns:(const WCTResultColumns &)resultColumns\n                                      fromTable:(NSString *)tableName\n{\n    return [[[[[self prepareSelect] onResultColumns:resultColumns] fromTable:tableName] limit:1] firstObject];\n}\n\n- (id /* WCTObject* */)getObjectOnResultColumns:(const WCTResultColumns &)resultColumns\n                                      fromTable:(NSString *)tableName\n                                          where:(const WCDB::Expression &)condition\n{\n    return [[[[[[self prepareSelect] onResultColumns:resultColumns] fromTable:tableName] where:condition] limit:1] firstObject];\n}\n\n- (id /* WCTObject* */)getObjectOnResultColumns:(const WCTResultColumns &)resultColumns\n                                      fromTable:(NSString *)tableName\n                                         orders:(const WCDB::OrderingTerms &)orders\n{\n    return [[[[[[self prepareSelect] onResultColumns:resultColumns] fromTable:tableName] orders:orders] limit:1] firstObject];\n}\n\n- (id /* WCTObject* */)getObjectOnResultColumns:(const WCTResultColumns &)resultColumns\n                                      fromTable:(NSString *)tableName\n                                         offset:(const WCDB::Expression &)offset\n{\n    return [[[[[[self prepareSelect] onResultColumns:resultColumns] fromTable:tableName] limit:1] offset:offset] firstObject];\n}\n\n- (id /* WCTObject* */)getObjectOnResultColumns:(const WCTResultColumns &)resultColumns\n                                      fromTable:(NSString *)tableName\n                                          where:(const WCDB::Expression &)condition\n                                         orders:(const WCDB::OrderingTerms &)orders\n{\n    return [[[[[[[self prepareSelect] onResultColumns:resultColumns] fromTable:tableName] where:condition] orders:orders] limit:1] firstObject];\n}\n\n- (id /* WCTObject* */)getObjectOnResultColumns:(const WCTResultColumns &)resultColumns\n                                      fromTable:(NSString *)tableName\n                                          where:(const WCDB::Expression &)condition\n                                         offset:(const WCDB::Expression &)offset\n{\n    return [[[[[[[self prepareSelect] onResultColumns:resultColumns] fromTable:tableName] where:condition] limit:1] offset:offset] firstObject];\n}\n\n- (id /* WCTObject* */)getObjectOnResultColumns:(const WCTResultColumns &)resultColumns\n                                      fromTable:(NSString *)tableName\n                                         orders:(const WCDB::OrderingTerms &)orders\n                                         offset:(const WCDB::Expression &)offset\n{\n    return [[[[[[[self prepareSelect] onResultColumns:resultColumns] fromTable:tableName] orders:orders] limit:1] offset:offset] firstObject];\n}\n\n- (id /* WCTObject* */)getObjectOnResultColumns:(const WCTResultColumns &)resultColumns\n                                      fromTable:(NSString *)tableName\n                                          where:(const WCDB::Expression &)condition\n                                         orders:(const WCDB::OrderingTerms &)orders\n                                         offset:(const WCDB::Expression &)offset\n{\n    return [[[[[[[[self prepareSelect] onResultColumns:resultColumns] fromTable:tableName] where:condition] orders:orders] limit:1] offset:offset] firstObject];\n}\n\n#pragma mark - Get Part Of Objects\n- (NSArray /* <WCTObject*> */ *)getObjectsOnResultColumns:(const WCTResultColumns &)resultColumns\n                                                fromTable:(NSString *)tableName\n{\n    return [[[[self prepareSelect] onResultColumns:resultColumns] fromTable:tableName] allObjects];\n}\n\n- (NSArray /* <WCTObject*> */ *)getObjectsOnResultColumns:(const WCTResultColumns &)resultColumns\n                                                fromTable:(NSString *)tableName\n                                                    where:(const WCDB::Expression &)condition\n{\n    return [[[[[self prepareSelect] onResultColumns:resultColumns] fromTable:tableName] where:condition] allObjects];\n}\n\n- (NSArray /* <WCTObject*> */ *)getObjectsOnResultColumns:(const WCTResultColumns &)resultColumns\n                                                fromTable:(NSString *)tableName\n                                                   orders:(const WCDB::OrderingTerms &)orders\n{\n    return [[[[[self prepareSelect] onResultColumns:resultColumns] fromTable:tableName] orders:orders] allObjects];\n}\n\n- (NSArray /* <WCTObject*> */ *)getObjectsOnResultColumns:(const WCTResultColumns &)resultColumns\n                                                fromTable:(NSString *)tableName\n                                                    limit:(const WCDB::Expression &)limit\n{\n    return [[[[[self prepareSelect] onResultColumns:resultColumns] fromTable:tableName] limit:limit] allObjects];\n}\n\n- (NSArray /* <WCTObject*> */ *)getObjectsOnResultColumns:(const WCTResultColumns &)resultColumns\n                                                fromTable:(NSString *)tableName\n                                                    where:(const WCDB::Expression &)condition\n                                                   orders:(const WCDB::OrderingTerms &)orders\n{\n    return [[[[[[self prepareSelect] onResultColumns:resultColumns] fromTable:tableName] where:condition] orders:orders] allObjects];\n}\n\n- (NSArray /* <WCTObject*> */ *)getObjectsOnResultColumns:(const WCTResultColumns &)resultColumns\n                                                fromTable:(NSString *)tableName\n                                                    where:(const WCDB::Expression &)condition\n                                                    limit:(const WCDB::Expression &)limit\n{\n    return [[[[[[self prepareSelect] onResultColumns:resultColumns] fromTable:tableName] where:condition] limit:limit] allObjects];\n}\n\n- (NSArray /* <WCTObject*> */ *)getObjectsOnResultColumns:(const WCTResultColumns &)resultColumns\n                                                fromTable:(NSString *)tableName\n                                                   orders:(const WCDB::OrderingTerms &)orders\n                                                    limit:(const WCDB::Expression &)limit\n{\n    return [[[[[[self prepareSelect] onResultColumns:resultColumns] fromTable:tableName] orders:orders] limit:limit] allObjects];\n}\n\n- (NSArray /* <WCTObject*> */ *)getObjectsOnResultColumns:(const WCTResultColumns &)resultColumns\n                                                fromTable:(NSString *)tableName\n                                                    limit:(const WCDB::Expression &)limit\n                                                   offset:(const WCDB::Expression &)offset\n{\n    return [[[[[[self prepareSelect] onResultColumns:resultColumns] fromTable:tableName] limit:limit] offset:offset] allObjects];\n}\n\n- (NSArray /* <WCTObject*> */ *)getObjectsOnResultColumns:(const WCTResultColumns &)resultColumns\n                                                fromTable:(NSString *)tableName\n                                                    where:(const WCDB::Expression &)condition\n                                                   orders:(const WCDB::OrderingTerms &)orders\n                                                    limit:(const WCDB::Expression &)limit\n{\n    return [[[[[[[self prepareSelect] onResultColumns:resultColumns] fromTable:tableName] where:condition] orders:orders] limit:limit] allObjects];\n}\n\n- (NSArray /* <WCTObject*> */ *)getObjectsOnResultColumns:(const WCTResultColumns &)resultColumns\n                                                fromTable:(NSString *)tableName\n                                                    where:(const WCDB::Expression &)condition\n                                                    limit:(const WCDB::Expression &)limit\n                                                   offset:(const WCDB::Expression &)offset\n{\n    return [[[[[[[self prepareSelect] onResultColumns:resultColumns] fromTable:tableName] where:condition] limit:limit] offset:offset] allObjects];\n}\n\n- (NSArray /* <WCTObject*> */ *)getObjectsOnResultColumns:(const WCTResultColumns &)resultColumns\n                                                fromTable:(NSString *)tableName\n                                                   orders:(const WCDB::OrderingTerms &)orders\n                                                    limit:(const WCDB::Expression &)limit\n                                                   offset:(const WCDB::Expression &)offset\n{\n    return [[[[[[[self prepareSelect] onResultColumns:resultColumns] fromTable:tableName] orders:orders] limit:limit] offset:offset] allObjects];\n}\n\n- (NSArray /* <WCTObject*> */ *)getObjectsOnResultColumns:(const WCTResultColumns &)resultColumns\n                                                fromTable:(NSString *)tableName\n                                                    where:(const WCDB::Expression &)condition\n                                                   orders:(const WCDB::OrderingTerms &)orders\n                                                    limit:(const WCDB::Expression &)limit\n                                                   offset:(const WCDB::Expression &)offset\n{\n    return [[[[[[[[self prepareSelect] onResultColumns:resultColumns] fromTable:tableName] where:condition] orders:orders] limit:limit] offset:offset] allObjects];\n}\n\n#pragma mark - Insert\n- (BOOL)insertObject:(WCTObject *)object\n           intoTable:(NSString *)tableName\n{\n    return [[[[self prepareInsert] intoTable:tableName] value:object] execute];\n}\n\n- (BOOL)insertObjects:(NSArray<WCTObject *> *)objects\n            intoTable:(NSString *)tableName\n{\n    return [[[[self prepareInsert] intoTable:tableName] values:objects] execute];\n}\n\n#pragma mark - Insert or Replace\n- (BOOL)insertOrReplaceObject:(WCTObject *)object\n                    intoTable:(NSString *)tableName\n{\n    return [[[[[self prepareInsert] orReplace] intoTable:tableName] value:object] execute];\n}\n\n- (BOOL)insertOrReplaceObjects:(NSArray<WCTObject *> *)objects\n                     intoTable:(NSString *)tableName\n{\n    return [[[[[self prepareInsert] orReplace] intoTable:tableName] values:objects] execute];\n}\n\n#pragma mark - Insert or Ignore\n- (BOOL)insertOrIgnoreObject:(WCTObject *)object\n                   intoTable:(NSString *)tableName\n{\n    return [[[[[self prepareInsert] orIgnore] intoTable:tableName] value:object] execute];\n}\n\n- (BOOL)insertOrIgnoreObjects:(NSArray<WCTObject *> *)objects\n                    intoTable:(NSString *)tableName\n{\n    return [[[[[self prepareInsert] orIgnore] intoTable:tableName] values:objects] execute];\n}\n\n#pragma mark - Partial Insert\n- (BOOL)insertObject:(WCTObject *)object\n        onProperties:(const WCTProperties &)properties\n           intoTable:(NSString *)tableName\n{\n    return [[[[[self prepareInsert] intoTable:tableName] onProperties:properties] value:object] execute];\n}\n\n- (BOOL)insertObjects:(NSArray<WCTObject *> *)objects onProperties:(const WCTProperties &)properties intoTable:(NSString *)tableName\n{\n    return [[[[[self prepareInsert] intoTable:tableName] onProperties:properties] values:objects] execute];\n}\n\n#pragma mark - Partial Insert or Replace\n- (BOOL)insertOrReplaceObject:(WCTObject *)object onProperties:(const WCTProperties &)properties intoTable:(NSString *)tableName\n{\n    return [[[[[[self prepareInsert] orReplace] intoTable:tableName] onProperties:properties] value:object] execute];\n}\n\n- (BOOL)insertOrReplaceObjects:(NSArray<WCTObject *> *)objects onProperties:(const WCTProperties &)properties intoTable:(NSString *)tableName\n{\n    return [[[[[[self prepareInsert] orReplace] intoTable:tableName] onProperties:properties] values:objects] execute];\n}\n\n#pragma mark - Partial Insert or Ignore\n- (BOOL)insertOrIgnoreObject:(WCTObject *)object onProperties:(const WCTProperties &)properties intoTable:(NSString *)tableName\n{\n    return [[[[[[self prepareInsert] orIgnore] intoTable:tableName] onProperties:properties] value:object] execute];\n}\n\n- (BOOL)insertOrIgnoreObjects:(NSArray<WCTObject *> *)objects onProperties:(const WCTProperties &)properties intoTable:(NSString *)tableName\n{\n    return [[[[[[self prepareInsert] orIgnore] intoTable:tableName] onProperties:properties] values:objects] execute];\n}\n\n#pragma mark - Update Properties To Object\n- (BOOL)updateTable:(NSString *)tableName\n      setProperties:(const WCTProperties &)properties\n           toObject:(WCTObject *)object\n{\n    return [[[[[self prepareUpdate] table:tableName] set:properties] toObject:object] execute];\n}\n\n- (BOOL)updateTable:(NSString *)tableName\n      setProperties:(const WCTProperties &)properties\n           toObject:(WCTObject *)object\n              where:(const WCDB::Expression &)condition\n{\n    return [[[[[[self prepareUpdate] table:tableName] set:properties] toObject:object] where:condition] execute];\n}\n\n- (BOOL)updateTable:(NSString *)tableName\n      setProperties:(const WCTProperties &)properties\n           toObject:(WCTObject *)object\n              limit:(const WCDB::Expression &)limit\n{\n    return [[[[[[self prepareUpdate] table:tableName] set:properties] toObject:object] limit:limit] execute];\n}\n\n- (BOOL)updateTable:(NSString *)tableName\n      setProperties:(const WCTProperties &)properties\n           toObject:(WCTObject *)object\n              where:(const WCDB::Expression &)condition\n              limit:(const WCDB::Expression &)limit\n{\n    return [[[[[[[self prepareUpdate] table:tableName] set:properties] toObject:object] where:condition] limit:limit] execute];\n}\n\n- (BOOL)updateTable:(NSString *)tableName\n      setProperties:(const WCTProperties &)properties\n           toObject:(WCTObject *)object\n             orders:(const WCDB::OrderingTerms &)orders\n              limit:(const WCDB::Expression &)limit\n{\n    return [[[[[[[self prepareUpdate] table:tableName] set:properties] toObject:object] orders:orders] limit:limit] execute];\n}\n\n- (BOOL)updateTable:(NSString *)tableName\n      setProperties:(const WCTProperties &)properties\n           toObject:(WCTObject *)object\n              limit:(const WCDB::Expression &)limit\n             offset:(const WCDB::Expression &)offset\n{\n    return [[[[[[[self prepareUpdate] table:tableName] set:properties] toObject:object] limit:limit] offset:offset] execute];\n}\n\n- (BOOL)updateTable:(NSString *)tableName\n      setProperties:(const WCTProperties &)properties\n           toObject:(WCTObject *)object\n              where:(const WCDB::Expression &)condition\n             orders:(const WCDB::OrderingTerms &)orders\n              limit:(const WCDB::Expression &)limit\n{\n    return [[[[[[[[self prepareUpdate] table:tableName] set:properties] toObject:object] where:condition] orders:orders] limit:limit] execute];\n}\n\n- (BOOL)updateTable:(NSString *)tableName\n      setProperties:(const WCTProperties &)properties\n           toObject:(WCTObject *)object\n              where:(const WCDB::Expression &)condition\n              limit:(const WCDB::Expression &)limit\n             offset:(const WCDB::Expression &)offset\n{\n    return [[[[[[[[self prepareUpdate] table:tableName] set:properties] toObject:object] where:condition] limit:limit] offset:offset] execute];\n}\n\n- (BOOL)updateTable:(NSString *)tableName\n      setProperties:(const WCTProperties &)properties\n           toObject:(WCTObject *)object\n             orders:(const WCDB::OrderingTerms &)orders\n              limit:(const WCDB::Expression &)limit\n             offset:(const WCDB::Expression &)offset\n{\n    return [[[[[[[[self prepareUpdate] table:tableName] set:properties] toObject:object] orders:orders] limit:limit] offset:offset] execute];\n}\n\n- (BOOL)updateTable:(NSString *)tableName\n      setProperties:(const WCTProperties &)properties\n           toObject:(WCTObject *)object\n              where:(const WCDB::Expression &)condition\n             orders:(const WCDB::OrderingTerms &)orders\n              limit:(const WCDB::Expression &)limit\n             offset:(const WCDB::Expression &)offset\n{\n    return [[[[[[[[[self prepareUpdate] table:tableName] set:properties] toObject:object] where:condition] orders:orders] limit:limit] offset:offset] execute];\n}\n\n#pragma mark - Update Properties To Row\n- (BOOL)updateTable:(NSString *)tableName\n      setProperties:(const WCTProperties &)properties\n              toRow:(WCTColumnCodingRow *)row\n{\n    return [[[[[self prepareUpdate] table:tableName] set:properties] toRow:row] execute];\n}\n\n- (BOOL)updateTable:(NSString *)tableName\n      setProperties:(const WCTProperties &)properties\n              toRow:(WCTColumnCodingRow *)row\n              where:(const WCDB::Expression &)condition\n{\n    return [[[[[[self prepareUpdate] table:tableName] set:properties] toRow:row] where:condition] execute];\n}\n\n- (BOOL)updateTable:(NSString *)tableName\n      setProperties:(const WCTProperties &)properties\n              toRow:(WCTColumnCodingRow *)row\n              limit:(const WCDB::Expression &)limit\n{\n    return [[[[[[self prepareUpdate] table:tableName] set:properties] toRow:row] limit:limit] execute];\n}\n\n- (BOOL)updateTable:(NSString *)tableName\n      setProperties:(const WCTProperties &)properties\n              toRow:(WCTColumnCodingRow *)row\n              where:(const WCDB::Expression &)condition\n              limit:(const WCDB::Expression &)limit\n{\n    return [[[[[[[self prepareUpdate] table:tableName] set:properties] toRow:row] where:condition] limit:limit] execute];\n}\n\n- (BOOL)updateTable:(NSString *)tableName\n      setProperties:(const WCTProperties &)properties\n              toRow:(WCTColumnCodingRow *)row\n             orders:(const WCDB::OrderingTerms &)orders\n              limit:(const WCDB::Expression &)limit\n{\n    return [[[[[[[self prepareUpdate] table:tableName] set:properties] toRow:row] orders:orders] limit:limit] execute];\n}\n\n- (BOOL)updateTable:(NSString *)tableName\n      setProperties:(const WCTProperties &)properties\n              toRow:(WCTColumnCodingRow *)row\n              limit:(const WCDB::Expression &)limit\n             offset:(const WCDB::Expression &)offset\n{\n    return [[[[[[[self prepareUpdate] table:tableName] set:properties] toRow:row] limit:limit] offset:offset] execute];\n}\n\n- (BOOL)updateTable:(NSString *)tableName\n      setProperties:(const WCTProperties &)properties\n              toRow:(WCTColumnCodingRow *)row\n              where:(const WCDB::Expression &)condition\n             orders:(const WCDB::OrderingTerms &)orders\n              limit:(const WCDB::Expression &)limit\n{\n    return [[[[[[[[self prepareUpdate] table:tableName] set:properties] toRow:row] where:condition] orders:orders] limit:limit] execute];\n}\n\n- (BOOL)updateTable:(NSString *)tableName\n      setProperties:(const WCTProperties &)properties\n              toRow:(WCTColumnCodingRow *)row\n              where:(const WCDB::Expression &)condition\n              limit:(const WCDB::Expression &)limit\n             offset:(const WCDB::Expression &)offset\n{\n    return [[[[[[[[self prepareUpdate] table:tableName] set:properties] toRow:row] where:condition] limit:limit] offset:offset] execute];\n}\n\n- (BOOL)updateTable:(NSString *)tableName\n      setProperties:(const WCTProperties &)properties\n              toRow:(WCTColumnCodingRow *)row\n             orders:(const WCDB::OrderingTerms &)orders\n              limit:(const WCDB::Expression &)limit\n             offset:(const WCDB::Expression &)offset\n{\n    return [[[[[[[[self prepareUpdate] table:tableName] set:properties] toRow:row] orders:orders] limit:limit] offset:offset] execute];\n}\n\n- (BOOL)updateTable:(NSString *)tableName\n      setProperties:(const WCTProperties &)properties\n              toRow:(WCTColumnCodingRow *)row\n              where:(const WCDB::Expression &)condition\n             orders:(const WCDB::OrderingTerms &)orders\n              limit:(const WCDB::Expression &)limit\n             offset:(const WCDB::Expression &)offset\n{\n    return [[[[[[[[[self prepareUpdate] table:tableName] set:properties] toRow:row] where:condition] orders:orders] limit:limit] offset:offset] execute];\n}\n\n#pragma mark - Update Property To Value\n- (BOOL)updateTable:(NSString *)tableName\n        setProperty:(const WCTProperty &)property\n            toValue:(WCTColumnCodingValue *)value\n{\n    return [[[[[self prepareUpdate] table:tableName] set:property] toValue:value] execute];\n}\n\n- (BOOL)updateTable:(NSString *)tableName\n        setProperty:(const WCTProperty &)property\n            toValue:(WCTColumnCodingValue *)value\n              where:(const WCDB::Expression &)condition\n{\n    return [[[[[[self prepareUpdate] table:tableName] set:property] toValue:value] where:condition] execute];\n}\n\n- (BOOL)updateTable:(NSString *)tableName\n        setProperty:(const WCTProperty &)property\n            toValue:(WCTColumnCodingValue *)value\n              limit:(const WCDB::Expression &)limit\n{\n    return [[[[[[self prepareUpdate] table:tableName] set:property] toValue:value] limit:limit] execute];\n}\n\n- (BOOL)updateTable:(NSString *)tableName\n        setProperty:(const WCTProperty &)property\n            toValue:(WCTColumnCodingValue *)value\n              where:(const WCDB::Expression &)condition\n              limit:(const WCDB::Expression &)limit\n{\n    return [[[[[[[self prepareUpdate] table:tableName] set:property] toValue:value] where:condition] limit:limit] execute];\n}\n\n- (BOOL)updateTable:(NSString *)tableName\n        setProperty:(const WCTProperty &)property\n            toValue:(WCTColumnCodingValue *)value\n             orders:(const WCDB::OrderingTerms &)orders\n              limit:(const WCDB::Expression &)limit\n{\n    return [[[[[[[self prepareUpdate] table:tableName] set:property] toValue:value] orders:orders] limit:limit] execute];\n}\n\n- (BOOL)updateTable:(NSString *)tableName\n        setProperty:(const WCTProperty &)property\n            toValue:(WCTColumnCodingValue *)value\n              limit:(const WCDB::Expression &)limit\n             offset:(const WCDB::Expression &)offset\n{\n    return [[[[[[[self prepareUpdate] table:tableName] set:property] toValue:value] limit:limit] offset:offset] execute];\n}\n\n- (BOOL)updateTable:(NSString *)tableName\n        setProperty:(const WCTProperty &)property\n            toValue:(WCTColumnCodingValue *)value\n              where:(const WCDB::Expression &)condition\n             orders:(const WCDB::OrderingTerms &)orders\n              limit:(const WCDB::Expression &)limit\n{\n    return [[[[[[[[self prepareUpdate] table:tableName] set:property] toValue:value] where:condition] orders:orders] limit:limit] execute];\n}\n\n- (BOOL)updateTable:(NSString *)tableName\n        setProperty:(const WCTProperty &)property\n            toValue:(WCTColumnCodingValue *)value\n              where:(const WCDB::Expression &)condition\n              limit:(const WCDB::Expression &)limit\n             offset:(const WCDB::Expression &)offset\n{\n    return [[[[[[[[self prepareUpdate] table:tableName] set:property] toValue:value] where:condition] limit:limit] offset:offset] execute];\n}\n\n- (BOOL)updateTable:(NSString *)tableName\n        setProperty:(const WCTProperty &)property\n            toValue:(WCTColumnCodingValue *)value\n             orders:(const WCDB::OrderingTerms &)orders\n              limit:(const WCDB::Expression &)limit\n             offset:(const WCDB::Expression &)offset\n{\n    return [[[[[[[[self prepareUpdate] table:tableName] set:property] toValue:value] orders:orders] limit:limit] offset:offset] execute];\n}\n\n- (BOOL)updateTable:(NSString *)tableName\n        setProperty:(const WCTProperty &)property\n            toValue:(WCTColumnCodingValue *)value\n              where:(const WCDB::Expression &)condition\n             orders:(const WCDB::OrderingTerms &)orders\n              limit:(const WCDB::Expression &)limit\n             offset:(const WCDB::Expression &)offset\n{\n    return [[[[[[[[[self prepareUpdate] table:tableName] set:property] toValue:value] where:condition] orders:orders] limit:limit] offset:offset] execute];\n}\n\n#pragma mark - Delete\n- (BOOL)deleteFromTable:(NSString *)tableName\n{\n    return [[[self prepareDelete] fromTable:tableName] execute];\n}\n\n- (BOOL)deleteFromTable:(NSString *)tableName\n                  where:(const WCDB::Expression &)condition\n{\n    return [[[[self prepareDelete] fromTable:tableName] where:condition] execute];\n}\n\n- (BOOL)deleteFromTable:(NSString *)tableName\n                  limit:(const WCDB::Expression &)limit\n{\n    return [[[[self prepareDelete] fromTable:tableName] limit:limit] execute];\n}\n\n- (BOOL)deleteFromTable:(NSString *)tableName\n                  where:(const WCDB::Expression &)condition\n                  limit:(const WCDB::Expression &)limit\n{\n    return [[[[[self prepareDelete] fromTable:tableName] where:condition] limit:limit] execute];\n}\n\n- (BOOL)deleteFromTable:(NSString *)tableName\n                 orders:(const WCDB::OrderingTerms &)orders\n                  limit:(const WCDB::Expression &)limit\n{\n    return [[[[[self prepareDelete] fromTable:tableName] orders:orders] limit:limit] execute];\n}\n\n- (BOOL)deleteFromTable:(NSString *)tableName\n                  limit:(const WCDB::Expression &)limit\n                 offset:(const WCDB::Expression &)offset\n{\n    return [[[[[self prepareDelete] fromTable:tableName] limit:limit] offset:offset] execute];\n}\n\n- (BOOL)deleteFromTable:(NSString *)tableName\n                  where:(const WCDB::Expression &)condition\n                 orders:(const WCDB::OrderingTerms &)orders\n                  limit:(const WCDB::Expression &)limit\n{\n    return [[[[[[self prepareDelete] fromTable:tableName] where:condition] orders:orders] limit:limit] execute];\n}\n\n- (BOOL)deleteFromTable:(NSString *)tableName\n                  where:(const WCDB::Expression &)condition\n                  limit:(const WCDB::Expression &)limit\n                 offset:(const WCDB::Expression &)offset\n{\n    return [[[[[[self prepareDelete] fromTable:tableName] where:condition] limit:limit] offset:offset] execute];\n}\n\n- (BOOL)deleteFromTable:(NSString *)tableName\n                 orders:(const WCDB::OrderingTerms &)orders\n                  limit:(const WCDB::Expression &)limit\n                 offset:(const WCDB::Expression &)offset\n{\n    return [[[[[[self prepareDelete] fromTable:tableName] orders:orders] limit:limit] offset:offset] execute];\n}\n\n- (BOOL)deleteFromTable:(NSString *)tableName\n                  where:(const WCDB::Expression &)condition\n                 orders:(const WCDB::OrderingTerms &)orders\n                  limit:(const WCDB::Expression &)limit\n                 offset:(const WCDB::Expression &)offset\n{\n    return [[[[[[[self prepareDelete] fromTable:tableName] where:condition] orders:orders] limit:limit] offset:offset] execute];\n}\n\n#pragma mark - Get Value\n- (WCTValue *)getValueOnResultColumn:(const WCDB::ResultColumn &)resultColumn\n                           fromTable:(NSString *)tableName\n{\n    return [self getValueFromStatement:WCDB::StatementSelect().select(resultColumn).from(tableName).order(WCDB::OrderingTerm::ascendingRowid()).limit(1)];\n}\n\n- (WCTValue *)getValueOnResultColumn:(const WCDB::ResultColumn &)resultColumn\n                           fromTable:(NSString *)tableName\n                               where:(const WCDB::Expression &)condition\n{\n    return [self getValueFromStatement:WCDB::StatementSelect().select(resultColumn).from(tableName).where(condition).order(WCDB::OrderingTerm::ascendingRowid()).limit(1)];\n}\n\n- (WCTValue *)getValueOnResultColumn:(const WCDB::ResultColumn &)resultColumn\n                           fromTable:(NSString *)tableName\n                              orders:(const WCDB::OrderingTerms &)orders\n{\n    return [self getValueFromStatement:WCDB::StatementSelect().select(resultColumn).from(tableName).orders(orders).limit(1)];\n}\n\n- (WCTValue *)getValueOnResultColumn:(const WCDB::ResultColumn &)resultColumn\n                           fromTable:(NSString *)tableName\n                              offset:(const WCDB::Expression &)offset\n{\n    return [self getValueFromStatement:WCDB::StatementSelect().select(resultColumn).from(tableName).order(WCDB::OrderingTerm::ascendingRowid()).limit(1).offset(offset)];\n}\n\n- (WCTValue *)getValueOnResultColumn:(const WCDB::ResultColumn &)resultColumn\n                           fromTable:(NSString *)tableName\n                               where:(const WCDB::Expression &)condition\n                              orders:(const WCDB::OrderingTerms &)orders\n{\n    return [self getValueFromStatement:WCDB::StatementSelect().select(resultColumn).from(tableName).where(condition).orders(orders).limit(1)];\n}\n\n- (WCTValue *)getValueOnResultColumn:(const WCDB::ResultColumn &)resultColumn\n                           fromTable:(NSString *)tableName\n                               where:(const WCDB::Expression &)condition\n                              offset:(const WCDB::Expression &)offset\n{\n    return [self getValueFromStatement:WCDB::StatementSelect().select(resultColumn).from(tableName).where(condition).order(WCDB::OrderingTerm::ascendingRowid()).limit(1).offset(offset)];\n}\n\n- (WCTValue *)getValueOnResultColumn:(const WCDB::ResultColumn &)resultColumn\n                           fromTable:(NSString *)tableName\n                              orders:(const WCDB::OrderingTerms &)orders\n                              offset:(const WCDB::Expression &)offset\n{\n    return [self getValueFromStatement:WCDB::StatementSelect().select(resultColumn).from(tableName).orders(orders).limit(1).offset(offset)];\n}\n\n- (WCTValue *)getValueOnResultColumn:(const WCDB::ResultColumn &)resultColumn\n                           fromTable:(NSString *)tableName\n                               where:(const WCDB::Expression &)condition\n                              orders:(const WCDB::OrderingTerms &)orders\n                              offset:(const WCDB::Expression &)offset\n{\n    return [self getValueFromStatement:WCDB::StatementSelect().select(resultColumn).from(tableName).where(condition).orders(orders).limit(1).offset(offset)];\n}\n\n#pragma mark - Get Row\n- (WCTOneRow *)getRowOnResultColumns:(const WCDB::ResultColumns &)resultColumns\n                           fromTable:(NSString *)tableName\n{\n    return [self getRowFromStatement:WCDB::StatementSelect().select(resultColumns).from(tableName).order(WCDB::OrderingTerm::ascendingRowid()).limit(1)];\n}\n\n- (WCTOneRow *)getRowOnResultColumns:(const WCDB::ResultColumns &)resultColumns\n                           fromTable:(NSString *)tableName\n                               where:(const WCDB::Expression &)condition\n{\n    return [self getRowFromStatement:WCDB::StatementSelect().select(resultColumns).from(tableName).where(condition).order(WCDB::OrderingTerm::ascendingRowid()).limit(1)];\n}\n\n- (WCTOneRow *)getRowOnResultColumns:(const WCDB::ResultColumns &)resultColumns\n                           fromTable:(NSString *)tableName\n                              orders:(const WCDB::OrderingTerms &)orders\n{\n    return [self getRowFromStatement:WCDB::StatementSelect().select(resultColumns).from(tableName).orders(orders).limit(1)];\n}\n\n- (WCTOneRow *)getRowOnResultColumns:(const WCDB::ResultColumns &)resultColumns\n                           fromTable:(NSString *)tableName\n                              offset:(const WCDB::Expression &)offset\n{\n    return [self getRowFromStatement:WCDB::StatementSelect().select(resultColumns).from(tableName).order(WCDB::OrderingTerm::ascendingRowid()).limit(1).offset(offset)];\n}\n\n- (WCTOneRow *)getRowOnResultColumns:(const WCDB::ResultColumns &)resultColumns\n                           fromTable:(NSString *)tableName\n                               where:(const WCDB::Expression &)condition\n                              orders:(const WCDB::OrderingTerms &)orders\n{\n    return [self getRowFromStatement:WCDB::StatementSelect().select(resultColumns).from(tableName).where(condition).orders(orders).limit(1)];\n}\n\n- (WCTOneRow *)getRowOnResultColumns:(const WCDB::ResultColumns &)resultColumns\n                           fromTable:(NSString *)tableName\n                               where:(const WCDB::Expression &)condition\n                              offset:(const WCDB::Expression &)offset\n{\n    return [self getRowFromStatement:WCDB::StatementSelect().select(resultColumns).from(tableName).where(condition).order(WCDB::OrderingTerm::ascendingRowid()).limit(1).offset(offset)];\n}\n\n- (WCTOneRow *)getRowOnResultColumns:(const WCDB::ResultColumns &)resultColumns\n                           fromTable:(NSString *)tableName\n                              orders:(const WCDB::OrderingTerms &)orders\n                              offset:(const WCDB::Expression &)offset\n{\n    return [self getRowFromStatement:WCDB::StatementSelect().select(resultColumns).from(tableName).orders(orders).limit(1).offset(offset)];\n}\n\n- (WCTOneRow *)getRowOnResultColumns:(const WCDB::ResultColumns &)resultColumns\n                           fromTable:(NSString *)tableName\n                               where:(const WCDB::Expression &)condition\n                              orders:(const WCDB::OrderingTerms &)orders\n                              offset:(const WCDB::Expression &)offset\n{\n    return [self getRowFromStatement:WCDB::StatementSelect().select(resultColumns).from(tableName).where(condition).orders(orders).limit(1).offset(offset)];\n}\n\n#pragma mark - Get Column\n- (WCTOneColumn *)getColumnOnResultColumn:(const WCDB::ResultColumn &)resultColumn\n                                fromTable:(NSString *)tableName\n{\n    return [self getColumnFromStatement:WCDB::StatementSelect().select(resultColumn).from(tableName).order(WCDB::OrderingTerm::ascendingRowid())];\n}\n\n- (WCTOneColumn *)getColumnOnResultColumn:(const WCDB::ResultColumn &)resultColumn\n                                fromTable:(NSString *)tableName\n                                    where:(const WCDB::Expression &)condition\n{\n    return [self getColumnFromStatement:WCDB::StatementSelect().select(resultColumn).from(tableName).where(condition).order(WCDB::OrderingTerm::ascendingRowid())];\n}\n\n- (WCTOneColumn *)getColumnOnResultColumn:(const WCDB::ResultColumn &)resultColumn\n                                fromTable:(NSString *)tableName\n                                   orders:(const WCDB::OrderingTerms &)orders\n{\n    return [self getColumnFromStatement:WCDB::StatementSelect().select(resultColumn).from(tableName).orders(orders)];\n}\n\n- (WCTOneColumn *)getColumnOnResultColumn:(const WCDB::ResultColumn &)resultColumn\n                                fromTable:(NSString *)tableName\n                                    limit:(const WCDB::Expression &)limit\n{\n    return [self getColumnFromStatement:WCDB::StatementSelect().select(resultColumn).from(tableName).order(WCDB::OrderingTerm::ascendingRowid()).limit(limit)];\n}\n\n- (WCTOneColumn *)getColumnOnResultColumn:(const WCDB::ResultColumn &)resultColumn\n                                fromTable:(NSString *)tableName\n                                    where:(const WCDB::Expression &)condition\n                                   orders:(const WCDB::OrderingTerms &)orders\n{\n    return [self getColumnFromStatement:WCDB::StatementSelect().select(resultColumn).from(tableName).where(condition).orders(orders)];\n}\n\n- (WCTOneColumn *)getColumnOnResultColumn:(const WCDB::ResultColumn &)resultColumn\n                                fromTable:(NSString *)tableName\n                                    where:(const WCDB::Expression &)condition\n                                    limit:(const WCDB::Expression &)limit\n{\n    return [self getColumnFromStatement:WCDB::StatementSelect().select(resultColumn).from(tableName).where(condition).order(WCDB::OrderingTerm::ascendingRowid()).limit(limit)];\n}\n\n- (WCTOneColumn *)getColumnOnResultColumn:(const WCDB::ResultColumn &)resultColumn\n                                fromTable:(NSString *)tableName\n                                   orders:(const WCDB::OrderingTerms &)orders\n                                    limit:(const WCDB::Expression &)limit\n{\n    return [self getColumnFromStatement:WCDB::StatementSelect().select(resultColumn).from(tableName).orders(orders).limit(limit)];\n}\n\n- (WCTOneColumn *)getColumnOnResultColumn:(const WCDB::ResultColumn &)resultColumn\n                                fromTable:(NSString *)tableName\n                                    limit:(const WCDB::Expression &)limit\n                                   offset:(const WCDB::Expression &)offset\n{\n    return [self getColumnFromStatement:WCDB::StatementSelect().select(resultColumn).from(tableName).order(WCDB::OrderingTerm::ascendingRowid()).limit(limit).offset(offset)];\n}\n\n- (WCTOneColumn *)getColumnOnResultColumn:(const WCDB::ResultColumn &)resultColumn\n                                fromTable:(NSString *)tableName\n                                    where:(const WCDB::Expression &)condition\n                                   orders:(const WCDB::OrderingTerms &)orders\n                                    limit:(const WCDB::Expression &)limit\n{\n    return [self getColumnFromStatement:WCDB::StatementSelect().select(resultColumn).from(tableName).where(condition).orders(orders).limit(limit)];\n}\n\n- (WCTOneColumn *)getColumnOnResultColumn:(const WCDB::ResultColumn &)resultColumn\n                                fromTable:(NSString *)tableName\n                                   orders:(const WCDB::OrderingTerms &)orders\n                                    limit:(const WCDB::Expression &)limit\n                                   offset:(const WCDB::Expression &)offset\n{\n    return [self getColumnFromStatement:WCDB::StatementSelect().select(resultColumn).from(tableName).orders(orders).limit(limit).offset(offset)];\n}\n\n- (WCTOneColumn *)getColumnOnResultColumn:(const WCDB::ResultColumn &)resultColumn\n                                fromTable:(NSString *)tableName\n                                    where:(const WCDB::Expression &)condition\n                                    limit:(const WCDB::Expression &)limit\n                                   offset:(const WCDB::Expression &)offset\n{\n    return [self getColumnFromStatement:WCDB::StatementSelect().select(resultColumn).from(tableName).where(condition).order(WCDB::OrderingTerm::ascendingRowid()).limit(limit).offset(offset)];\n}\n\n- (WCTOneColumn *)getColumnOnResultColumn:(const WCDB::ResultColumn &)resultColumn\n                                fromTable:(NSString *)tableName\n                                    where:(const WCDB::Expression &)condition\n                                   orders:(const WCDB::OrderingTerms &)orders\n                                    limit:(const WCDB::Expression &)limit\n                                   offset:(const WCDB::Expression &)offset\n{\n    return [self getColumnFromStatement:WCDB::StatementSelect().select(resultColumn).from(tableName).where(condition).orders(orders).limit(limit).offset(offset)];\n}\n\n#pragma mark - Get Rows\n- (WCTColumnsXRows *)getRowsOnResultColumns:(const WCDB::ResultColumns &)resultColumns\n                                  fromTable:(NSString *)tableName\n{\n    return [self getRowsFromStatement:WCDB::StatementSelect().select(resultColumns).from(tableName).order(WCDB::OrderingTerm::ascendingRowid())];\n}\n\n- (WCTColumnsXRows *)getRowsOnResultColumns:(const WCDB::ResultColumns &)resultColumns\n                                  fromTable:(NSString *)tableName\n                                      where:(const WCDB::Expression &)condition\n{\n    return [self getRowsFromStatement:WCDB::StatementSelect().select(resultColumns).from(tableName).where(condition).order(WCDB::OrderingTerm::ascendingRowid())];\n}\n\n- (WCTColumnsXRows *)getRowsOnResultColumns:(const WCDB::ResultColumns &)resultColumns\n                                  fromTable:(NSString *)tableName\n                                     orders:(const WCDB::OrderingTerms &)orders\n{\n    return [self getRowsFromStatement:WCDB::StatementSelect().select(resultColumns).from(tableName).orders(orders)];\n}\n\n- (WCTColumnsXRows *)getRowsOnResultColumns:(const WCDB::ResultColumns &)resultColumns\n                                  fromTable:(NSString *)tableName\n                                      limit:(const WCDB::Expression &)limit\n{\n    return [self getRowsFromStatement:WCDB::StatementSelect().select(resultColumns).from(tableName).order(WCDB::OrderingTerm::ascendingRowid()).limit(limit)];\n}\n\n- (WCTColumnsXRows *)getRowsOnResultColumns:(const WCDB::ResultColumns &)resultColumns\n                                  fromTable:(NSString *)tableName\n                                      where:(const WCDB::Expression &)condition\n                                     orders:(const WCDB::OrderingTerms &)orders\n{\n    return [self getRowsFromStatement:WCDB::StatementSelect().select(resultColumns).from(tableName).where(condition).orders(orders)];\n}\n\n- (WCTColumnsXRows *)getRowsOnResultColumns:(const WCDB::ResultColumns &)resultColumns\n                                  fromTable:(NSString *)tableName\n                                      where:(const WCDB::Expression &)condition\n                                      limit:(const WCDB::Expression &)limit\n{\n    return [self getRowsFromStatement:WCDB::StatementSelect().select(resultColumns).from(tableName).where(condition).order(WCDB::OrderingTerm::ascendingRowid()).limit(limit)];\n}\n\n- (WCTColumnsXRows *)getRowsOnResultColumns:(const WCDB::ResultColumns &)resultColumns\n                                  fromTable:(NSString *)tableName\n                                     orders:(const WCDB::OrderingTerms &)orders\n                                      limit:(const WCDB::Expression &)limit\n{\n    return [self getRowsFromStatement:WCDB::StatementSelect().select(resultColumns).from(tableName).orders(orders).limit(limit)];\n}\n\n- (WCTColumnsXRows *)getRowsOnResultColumns:(const WCDB::ResultColumns &)resultColumns\n                                  fromTable:(NSString *)tableName\n                                      limit:(const WCDB::Expression &)limit\n                                     offset:(const WCDB::Expression &)offset\n{\n    return [self getRowsFromStatement:WCDB::StatementSelect().select(resultColumns).from(tableName).order(WCDB::OrderingTerm::ascendingRowid()).limit(limit).offset(offset)];\n}\n\n- (WCTColumnsXRows *)getRowsOnResultColumns:(const WCDB::ResultColumns &)resultColumns\n                                  fromTable:(NSString *)tableName\n                                      where:(const WCDB::Expression &)condition\n                                     orders:(const WCDB::OrderingTerms &)orders\n                                      limit:(const WCDB::Expression &)limit\n{\n    return [self getRowsFromStatement:WCDB::StatementSelect().select(resultColumns).from(tableName).where(condition).orders(orders).limit(limit)];\n}\n\n- (WCTColumnsXRows *)getRowsOnResultColumns:(const WCDB::ResultColumns &)resultColumns\n                                  fromTable:(NSString *)tableName\n                                     orders:(const WCDB::OrderingTerms &)orders\n                                      limit:(const WCDB::Expression &)limit\n                                     offset:(const WCDB::Expression &)offset\n{\n    return [self getRowsFromStatement:WCDB::StatementSelect().select(resultColumns).from(tableName).orders(orders).limit(limit).offset(offset)];\n}\n\n- (WCTColumnsXRows *)getRowsOnResultColumns:(const WCDB::ResultColumns &)resultColumns\n                                  fromTable:(NSString *)tableName\n                                      where:(const WCDB::Expression &)condition\n                                      limit:(const WCDB::Expression &)limit\n                                     offset:(const WCDB::Expression &)offset\n{\n    return [self getRowsFromStatement:WCDB::StatementSelect().select(resultColumns).from(tableName).where(condition).order(WCDB::OrderingTerm::ascendingRowid()).limit(limit).offset(offset)];\n}\n\n- (WCTColumnsXRows *)getRowsOnResultColumns:(const WCDB::ResultColumns &)resultColumns\n                                  fromTable:(NSString *)tableName\n                                      where:(const WCDB::Expression &)condition\n                                     orders:(const WCDB::OrderingTerms &)orders\n                                      limit:(const WCDB::Expression &)limit\n                                     offset:(const WCDB::Expression &)offset\n{\n    return [self getRowsFromStatement:WCDB::StatementSelect().select(resultColumns).from(tableName).where(condition).orders(orders).limit(limit).offset(offset)];\n}\n\n#pragma mark - Get From Statement\n- (WCTValue *)getValueFromStatement:(const WCDB::Statement &)statement\n{\n    WCTValue *result = nil;\n    if ([self prepare:statement]) {\n        if ([self step]) {\n            result = [self extractValueAtIndex:0];\n        }\n        [self finalizeStatement];\n    }\n    return result;\n}\n\n- (WCTOneRow *)getRowFromStatement:(const WCDB::Statement &)statement\n{\n    WCTOneRow *result = nil;\n    if ([self prepare:statement]) {\n        if ([self step]) {\n            result = [self extractRow];\n        }\n        [self finalizeStatement];\n    }\n    return result;\n}\n\n- (WCTOneColumn *)getColumnFromStatement:(const WCDB::Statement &)statement\n{\n    WCTOneColumn *result = nil;\n    if ([self prepare:statement]) {\n        result = [self allValues];\n        [self finalizeStatement];\n    }\n    return result;\n}\n\n- (WCTColumnsXRows *)getRowsFromStatement:(const WCDB::Statement &)statement\n{\n    WCTColumnsXRows *result = nil;\n    if ([self prepare:statement]) {\n        result = [self allRows];\n        [self finalizeStatement];\n    }\n    return result;\n}\n\n@end\n"
  },
  {
    "path": "src/objc/convenient/WCTTable+Convenient.h",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"WCTTable.h\"\n\nNS_ASSUME_NONNULL_BEGIN\n\nWCDB_API @interface WCTTable<ObjectType>(Convenient)\n\n#pragma mark - Get Object\n- (nullable ObjectType)getObject;\n\n- (nullable ObjectType)getObjectWhere:(const WCDB::Expression &)condition;\n\n- (nullable ObjectType)getObjectOrders:(const WCDB::OrderingTerms &)orders;\n\n- (nullable ObjectType)getObjectOffset:(const WCDB::Expression &)offset;\n\n- (nullable ObjectType)getObjectWhere:(const WCDB::Expression &)condition\n                               orders:(const WCDB::OrderingTerms &)orders;\n\n- (nullable ObjectType)getObjectWhere:(const WCDB::Expression &)condition\n                               offset:(const WCDB::Expression &)offset;\n\n- (nullable ObjectType)getObjectOrders:(const WCDB::OrderingTerms &)orders\n                                offset:(const WCDB::Expression &)offset;\n\n- (nullable ObjectType)getObjectWhere:(const WCDB::Expression &)condition\n                               orders:(const WCDB::OrderingTerms &)orders\n                               offset:(const WCDB::Expression &)offset;\n\n#pragma mark - Get Objects\n- (nullable NSArray<ObjectType> *)getObjects;\n\n- (nullable NSArray<ObjectType> *)getObjectsWhere:(const WCDB::Expression &)condition;\n\n- (nullable NSArray<ObjectType> *)getObjectsOrders:(const WCDB::OrderingTerms &)orders;\n\n- (nullable NSArray<ObjectType> *)getObjectsLimit:(const WCDB::Expression &)limit;\n\n- (nullable NSArray<ObjectType> *)getObjectsWhere:(const WCDB::Expression &)condition\n                                           orders:(const WCDB::OrderingTerms &)orders;\n\n- (nullable NSArray<ObjectType> *)getObjectsWhere:(const WCDB::Expression &)condition\n                                            limit:(const WCDB::Expression &)limit;\n\n- (nullable NSArray<ObjectType> *)getObjectsOrders:(const WCDB::OrderingTerms &)orders\n                                             limit:(const WCDB::Expression &)limit;\n\n- (NSArray /* <WCTObject*> */ *)getObjectsOffset:(const WCDB::Expression &)offset\n                                           limit:(const WCDB::Expression &)limit;\n\n- (nullable NSArray<ObjectType> *)getObjectsWhere:(const WCDB::Expression &)condition\n                                           orders:(const WCDB::OrderingTerms &)orders\n                                            limit:(const WCDB::Expression &)limit;\n\n- (nullable NSArray<ObjectType> *)getObjectsWhere:(const WCDB::Expression &)condition\n                                            limit:(const WCDB::Expression &)limit\n                                           offset:(const WCDB::Expression &)offset;\n\n- (nullable NSArray<ObjectType> *)getObjectsOrders:(const WCDB::OrderingTerms &)orders\n                                             limit:(const WCDB::Expression &)limit\n                                            offset:(const WCDB::Expression &)offset;\n\n- (nullable NSArray<ObjectType> *)getObjectsWhere:(const WCDB::Expression &)condition\n                                           orders:(const WCDB::OrderingTerms &)orders\n                                            limit:(const WCDB::Expression &)limit\n                                           offset:(const WCDB::Expression &)offset;\n\n#pragma mark - Get Part Of Object\n- (nullable ObjectType)getObjectOnResultColumns:(const WCTResultColumns &)resultColumns;\n\n- (nullable ObjectType)getObjectOnResultColumns:(const WCTResultColumns &)resultColumns\n                                          where:(const WCDB::Expression &)condition;\n\n- (nullable ObjectType)getObjectOnResultColumns:(const WCTResultColumns &)resultColumns\n                                         orders:(const WCDB::OrderingTerms &)orders;\n\n- (nullable ObjectType)getObjectOnResultColumns:(const WCTResultColumns &)resultColumns\n                                         offset:(const WCDB::Expression &)offset;\n\n- (nullable ObjectType)getObjectOnResultColumns:(const WCTResultColumns &)resultColumns\n                                          where:(const WCDB::Expression &)condition\n                                         orders:(const WCDB::OrderingTerms &)orders;\n\n- (nullable ObjectType)getObjectOnResultColumns:(const WCTResultColumns &)resultColumns\n                                          where:(const WCDB::Expression &)condition\n                                         offset:(const WCDB::Expression &)offset;\n\n- (nullable ObjectType)getObjectOnResultColumns:(const WCTResultColumns &)resultColumns\n                                         orders:(const WCDB::OrderingTerms &)orders\n                                         offset:(const WCDB::Expression &)offset;\n\n- (nullable ObjectType)getObjectOnResultColumns:(const WCTResultColumns &)resultColumns\n                                          where:(const WCDB::Expression &)condition\n                                         orders:(const WCDB::OrderingTerms &)orders\n                                         offset:(const WCDB::Expression &)offset;\n\n#pragma mark - Get Part Of Objects\n- (nullable NSArray<ObjectType> *)getObjectsOnResultColumns:(const WCTResultColumns &)resultColumns;\n\n- (nullable NSArray<ObjectType> *)getObjectsOnResultColumns:(const WCTResultColumns &)resultColumns\n                                                      where:(const WCDB::Expression &)condition;\n\n- (nullable NSArray<ObjectType> *)getObjectsOnResultColumns:(const WCTResultColumns &)resultColumns\n                                                     orders:(const WCDB::OrderingTerms &)orders;\n\n- (nullable NSArray<ObjectType> *)getObjectsOnResultColumns:(const WCTResultColumns &)resultColumns\n                                                      limit:(const WCDB::Expression &)limit;\n\n- (nullable NSArray<ObjectType> *)getObjectsOnResultColumns:(const WCTResultColumns &)resultColumns\n                                                      where:(const WCDB::Expression &)condition\n                                                     orders:(const WCDB::OrderingTerms &)orders;\n\n- (nullable NSArray<ObjectType> *)getObjectsOnResultColumns:(const WCTResultColumns &)resultColumns\n                                                      where:(const WCDB::Expression &)condition\n                                                      limit:(const WCDB::Expression &)limit;\n\n- (nullable NSArray<ObjectType> *)getObjectsOnResultColumns:(const WCTResultColumns &)resultColumns\n                                                     orders:(const WCDB::OrderingTerms &)orders\n                                                      limit:(const WCDB::Expression &)limit;\n\n- (nullable NSArray<ObjectType> *)getObjectsOnResultColumns:(const WCTResultColumns &)resultColumns\n                                                      limit:(const WCDB::Expression &)limit\n                                                     offset:(const WCDB::Expression &)offset;\n\n- (nullable NSArray<ObjectType> *)getObjectsOnResultColumns:(const WCTResultColumns &)resultColumns\n                                                      where:(const WCDB::Expression &)condition\n                                                     orders:(const WCDB::OrderingTerms &)orders\n                                                      limit:(const WCDB::Expression &)limit;\n\n- (nullable NSArray<ObjectType> *)getObjectsOnResultColumns:(const WCTResultColumns &)resultColumns\n                                                      where:(const WCDB::Expression &)condition\n                                                      limit:(const WCDB::Expression &)limit\n                                                     offset:(const WCDB::Expression &)offset;\n\n- (nullable NSArray<ObjectType> *)getObjectsOnResultColumns:(const WCTResultColumns &)resultColumns\n                                                     orders:(const WCDB::OrderingTerms &)orders\n                                                      limit:(const WCDB::Expression &)limit\n                                                     offset:(const WCDB::Expression &)offset;\n\n- (nullable NSArray<ObjectType> *)getObjectsOnResultColumns:(const WCTResultColumns &)resultColumns\n                                                      where:(const WCDB::Expression &)condition\n                                                     orders:(const WCDB::OrderingTerms &)orders\n                                                      limit:(const WCDB::Expression &)limit\n                                                     offset:(const WCDB::Expression &)offset;\n\n#pragma mark - Insert\n- (BOOL)insertObject:(ObjectType)object;\n\n- (BOOL)insertObjects:(NSArray<ObjectType> *)objects;\n\n- (BOOL)insertOrReplaceObject:(ObjectType)object;\n\n- (BOOL)insertOrReplaceObjects:(NSArray<ObjectType> *)objects;\n\n- (BOOL)insertOrIgnoreObject:(ObjectType)object;\n\n- (BOOL)insertOrIgnoreObjects:(NSArray<ObjectType> *)objects;\n\n- (BOOL)insertObject:(ObjectType)object onProperties:(const WCTProperties &)properties;\n\n- (BOOL)insertObjects:(NSArray<ObjectType> *)objects onProperties:(const WCTProperties &)properties;\n\n- (BOOL)insertOrReplaceObject:(ObjectType)object onProperties:(const WCTProperties &)properties;\n\n- (BOOL)insertOrReplaceObjects:(NSArray<ObjectType> *)objects onProperties:(const WCTProperties &)properties;\n\n- (BOOL)insertOrIgnoreObject:(ObjectType)object onProperties:(const WCTProperties &)properties;\n\n- (BOOL)insertOrIgnoreObjects:(NSArray<ObjectType> *)objects onProperties:(const WCTProperties &)properties;\n\n#pragma mark - Update Properties To Object\n- (BOOL)updateProperties:(const WCTProperties &)properties\n                toObject:(ObjectType)object;\n\n- (BOOL)updateProperties:(const WCTProperties &)properties\n                toObject:(ObjectType)object\n                   where:(const WCDB::Expression &)condition;\n\n- (BOOL)updateProperties:(const WCTProperties &)properties\n                toObject:(ObjectType)object\n                   limit:(const WCDB::Expression &)limit;\n\n- (BOOL)updateProperties:(const WCTProperties &)properties\n                toObject:(ObjectType)object\n                   where:(const WCDB::Expression &)condition\n                   limit:(const WCDB::Expression &)limit;\n\n- (BOOL)updateProperties:(const WCTProperties &)properties\n                toObject:(ObjectType)object\n                  orders:(const WCDB::OrderingTerms &)orders\n                   limit:(const WCDB::Expression &)limit;\n\n- (BOOL)updateProperties:(const WCTProperties &)properties\n                toObject:(ObjectType)object\n                   limit:(const WCDB::Expression &)limit\n                  offset:(const WCDB::Expression &)offset;\n\n- (BOOL)updateProperties:(const WCTProperties &)properties\n                toObject:(ObjectType)object\n                   where:(const WCDB::Expression &)condition\n                  orders:(const WCDB::OrderingTerms &)orders\n                   limit:(const WCDB::Expression &)limit;\n\n- (BOOL)updateProperties:(const WCTProperties &)properties\n                toObject:(ObjectType)object\n                   where:(const WCDB::Expression &)condition\n                   limit:(const WCDB::Expression &)limit\n                  offset:(const WCDB::Expression &)offset;\n\n- (BOOL)updateProperties:(const WCTProperties &)properties\n                toObject:(ObjectType)object\n                  orders:(const WCDB::OrderingTerms &)orders\n                   limit:(const WCDB::Expression &)limit\n                  offset:(const WCDB::Expression &)offset;\n\n- (BOOL)updateProperties:(const WCTProperties &)properties\n                toObject:(ObjectType)object\n                   where:(const WCDB::Expression &)condition\n                  orders:(const WCDB::OrderingTerms &)orders\n                   limit:(const WCDB::Expression &)limit\n                  offset:(const WCDB::Expression &)offset;\n\n#pragma mark - Update Properties To Row\n- (BOOL)updateProperties:(const WCTProperties &)properties\n                   toRow:(WCTColumnCodingRow *)row;\n\n- (BOOL)updateProperties:(const WCTProperties &)properties\n                   toRow:(WCTColumnCodingRow *)row\n                   where:(const WCDB::Expression &)condition;\n\n- (BOOL)updateProperties:(const WCTProperties &)properties\n                   toRow:(WCTColumnCodingRow *)row\n                   limit:(const WCDB::Expression &)limit;\n\n- (BOOL)updateProperties:(const WCTProperties &)properties\n                   toRow:(WCTColumnCodingRow *)row\n                   where:(const WCDB::Expression &)condition\n                   limit:(const WCDB::Expression &)limit;\n\n- (BOOL)updateProperties:(const WCTProperties &)properties\n                   toRow:(WCTColumnCodingRow *)row\n                  orders:(const WCDB::OrderingTerms &)orders\n                   limit:(const WCDB::Expression &)limit;\n\n- (BOOL)updateProperties:(const WCTProperties &)properties\n                   toRow:(WCTColumnCodingRow *)row\n                   limit:(const WCDB::Expression &)limit\n                  offset:(const WCDB::Expression &)offset;\n\n- (BOOL)updateProperties:(const WCTProperties &)properties\n                   toRow:(WCTColumnCodingRow *)row\n                   where:(const WCDB::Expression &)condition\n                  orders:(const WCDB::OrderingTerms &)orders\n                   limit:(const WCDB::Expression &)limit;\n\n- (BOOL)updateProperties:(const WCTProperties &)properties\n                   toRow:(WCTColumnCodingRow *)row\n                   where:(const WCDB::Expression &)condition\n                   limit:(const WCDB::Expression &)limit\n                  offset:(const WCDB::Expression &)offset;\n\n- (BOOL)updateProperties:(const WCTProperties &)properties\n                   toRow:(WCTColumnCodingRow *)row\n                  orders:(const WCDB::OrderingTerms &)orders\n                   limit:(const WCDB::Expression &)limit\n                  offset:(const WCDB::Expression &)offset;\n\n- (BOOL)updateProperties:(const WCTProperties &)properties\n                   toRow:(WCTColumnCodingRow *)row\n                   where:(const WCDB::Expression &)condition\n                  orders:(const WCDB::OrderingTerms &)orders\n                   limit:(const WCDB::Expression &)limit\n                  offset:(const WCDB::Expression &)offset;\n\n#pragma mark - Update Property To Value\n- (BOOL)updateProperty:(const WCTProperty &)property\n               toValue:(WCTColumnCodingValue *)value;\n\n- (BOOL)updateProperty:(const WCTProperty &)property\n               toValue:(WCTColumnCodingValue *)value\n                 where:(const WCDB::Expression &)condition;\n\n- (BOOL)updateProperty:(const WCTProperty &)property\n               toValue:(WCTColumnCodingValue *)value\n                 limit:(const WCDB::Expression &)limit;\n\n- (BOOL)updateProperty:(const WCTProperty &)property\n               toValue:(WCTColumnCodingValue *)value\n                 where:(const WCDB::Expression &)condition\n                 limit:(const WCDB::Expression &)limit;\n\n- (BOOL)updateProperty:(const WCTProperty &)property\n               toValue:(WCTColumnCodingValue *)value\n                orders:(const WCDB::OrderingTerms &)orders\n                 limit:(const WCDB::Expression &)limit;\n\n- (BOOL)updateProperty:(const WCTProperty &)property\n               toValue:(WCTColumnCodingValue *)value\n                 limit:(const WCDB::Expression &)limit\n                offset:(const WCDB::Expression &)offset;\n\n- (BOOL)updateProperty:(const WCTProperty &)property\n               toValue:(WCTColumnCodingValue *)value\n                 where:(const WCDB::Expression &)condition\n                orders:(const WCDB::OrderingTerms &)orders\n                 limit:(const WCDB::Expression &)limit;\n\n- (BOOL)updateProperty:(const WCTProperty &)property\n               toValue:(WCTColumnCodingValue *)value\n                 where:(const WCDB::Expression &)condition\n                 limit:(const WCDB::Expression &)limit\n                offset:(const WCDB::Expression &)offset;\n\n- (BOOL)updateProperty:(const WCTProperty &)property\n               toValue:(WCTColumnCodingValue *)value\n                orders:(const WCDB::OrderingTerms &)orders\n                 limit:(const WCDB::Expression &)limit\n                offset:(const WCDB::Expression &)offset;\n\n- (BOOL)updateProperty:(const WCTProperty &)property\n               toValue:(WCTColumnCodingValue *)value\n                 where:(const WCDB::Expression &)condition\n                orders:(const WCDB::OrderingTerms &)orders\n                 limit:(const WCDB::Expression &)limit\n                offset:(const WCDB::Expression &)offset;\n\n#pragma mark - Delete\n- (BOOL)deleteObjects;\n\n- (BOOL)deleteObjectsWhere:(const WCDB::Expression &)condition;\n\n- (BOOL)deleteObjectsOrders:(const WCDB::OrderingTerms &)orders;\n\n- (BOOL)deleteObjectsLimit:(const WCDB::Expression &)limit;\n\n- (BOOL)deleteObjectsOffset:(const WCDB::Expression &)offset;\n\n- (BOOL)deleteObjectsWhere:(const WCDB::Expression &)condition\n                     limit:(const WCDB::Expression &)limit;\n\n- (BOOL)deleteObjectsOrders:(const WCDB::OrderingTerms &)orders\n                      limit:(const WCDB::Expression &)limit;\n\n- (BOOL)deleteObjectsLimit:(const WCDB::Expression &)limit\n                    offset:(const WCDB::Expression &)offset;\n\n- (BOOL)deleteObjectsWhere:(const WCDB::Expression &)condition\n                    orders:(const WCDB::OrderingTerms &)orders\n                     limit:(const WCDB::Expression &)limit;\n\n- (BOOL)deleteObjectsWhere:(const WCDB::Expression &)condition\n                     limit:(const WCDB::Expression &)limit\n                    offset:(const WCDB::Expression &)offset;\n\n- (BOOL)deleteObjectsOrders:(const WCDB::OrderingTerms &)orders\n                      limit:(const WCDB::Expression &)limit\n                     offset:(const WCDB::Expression &)offset;\n\n- (BOOL)deleteObjectsWhere:(const WCDB::Expression &)condition\n                    orders:(const WCDB::OrderingTerms &)orders\n                     limit:(const WCDB::Expression &)limit\n                    offset:(const WCDB::Expression &)offset;\n\n#pragma mark - Get Value\n- (nullable WCTValue *)getValueOnResultColumn:(const WCDB::ResultColumn &)resultColumn;\n\n- (nullable WCTValue *)getValueOnResultColumn:(const WCDB::ResultColumn &)resultColumn\n                                        where:(const WCDB::Expression &)condition;\n\n- (nullable WCTValue *)getValueOnResultColumn:(const WCDB::ResultColumn &)resultColumn\n                                       orders:(const WCDB::OrderingTerms &)orders;\n\n- (nullable WCTValue *)getValueOnResultColumn:(const WCDB::ResultColumn &)resultColumn\n                                       offset:(const WCDB::Expression &)offset;\n\n- (nullable WCTValue *)getValueOnResultColumn:(const WCDB::ResultColumn &)resultColumn\n                                        where:(const WCDB::Expression &)condition\n                                       orders:(const WCDB::OrderingTerms &)orders;\n\n- (nullable WCTValue *)getValueOnResultColumn:(const WCDB::ResultColumn &)resultColumn\n                                        where:(const WCDB::Expression &)condition\n                                       offset:(const WCDB::Expression &)offset;\n\n- (nullable WCTValue *)getValueOnResultColumn:(const WCDB::ResultColumn &)resultColumn\n                                       orders:(const WCDB::OrderingTerms &)orders\n                                       offset:(const WCDB::Expression &)offset;\n\n- (nullable WCTValue *)getValueOnResultColumn:(const WCDB::ResultColumn &)resultColumn\n                                        where:(const WCDB::Expression &)condition\n                                       orders:(const WCDB::OrderingTerms &)orders\n                                       offset:(const WCDB::Expression &)offset;\n\n#pragma mark - Get Row\n- (nullable WCTOneRow *)getRowOnResultColumns:(const WCDB::ResultColumns &)resultColumns;\n\n- (nullable WCTOneRow *)getRowOnResultColumns:(const WCDB::ResultColumns &)resultColumns\n                                        where:(const WCDB::Expression &)condition;\n\n- (nullable WCTOneRow *)getRowOnResultColumns:(const WCDB::ResultColumns &)resultColumns\n                                       orders:(const WCDB::OrderingTerms &)orders;\n\n- (nullable WCTOneRow *)getRowOnResultColumns:(const WCDB::ResultColumns &)resultColumns\n                                       offset:(const WCDB::Expression &)offset;\n\n- (nullable WCTOneRow *)getRowOnResultColumns:(const WCDB::ResultColumns &)resultColumns\n                                        where:(const WCDB::Expression &)condition\n                                       orders:(const WCDB::OrderingTerms &)orders;\n\n- (nullable WCTOneRow *)getRowOnResultColumns:(const WCDB::ResultColumns &)resultColumns\n                                        where:(const WCDB::Expression &)condition\n                                       offset:(const WCDB::Expression &)offset;\n\n- (nullable WCTOneRow *)getRowOnResultColumns:(const WCDB::ResultColumns &)resultColumns\n                                       orders:(const WCDB::OrderingTerms &)orders\n                                       offset:(const WCDB::Expression &)offset;\n\n- (nullable WCTOneRow *)getRowOnResultColumns:(const WCDB::ResultColumns &)resultColumns\n                                        where:(const WCDB::Expression &)condition\n                                       orders:(const WCDB::OrderingTerms &)orders\n                                       offset:(const WCDB::Expression &)offset;\n\n#pragma mark - Get Column\n- (nullable WCTOneColumn *)getColumnOnResultColumn:(const WCDB::ResultColumn &)resultColumn;\n\n- (nullable WCTOneColumn *)getColumnOnResultColumn:(const WCDB::ResultColumn &)resultColumn\n                                             where:(const WCDB::Expression &)condition;\n\n- (nullable WCTOneColumn *)getColumnOnResultColumn:(const WCDB::ResultColumn &)resultColumn\n                                            orders:(const WCDB::OrderingTerms &)orders;\n\n- (nullable WCTOneColumn *)getColumnOnResultColumn:(const WCDB::ResultColumn &)resultColumn\n                                             limit:(const WCDB::Expression &)limit;\n\n- (nullable WCTOneColumn *)getColumnOnResultColumn:(const WCDB::ResultColumn &)resultColumn\n                                             where:(const WCDB::Expression &)condition\n                                            orders:(const WCDB::OrderingTerms &)orders;\n\n- (nullable WCTOneColumn *)getColumnOnResultColumn:(const WCDB::ResultColumn &)resultColumn\n                                             where:(const WCDB::Expression &)condition\n                                             limit:(const WCDB::Expression &)limit;\n\n- (nullable WCTOneColumn *)getColumnOnResultColumn:(const WCDB::ResultColumn &)resultColumn\n                                            orders:(const WCDB::OrderingTerms &)orders\n                                             limit:(const WCDB::Expression &)limit;\n\n- (nullable WCTOneColumn *)getColumnOnResultColumn:(const WCDB::ResultColumn &)resultColumn\n                                             limit:(const WCDB::Expression &)limit\n                                            offset:(const WCDB::Expression &)offset;\n\n- (nullable WCTOneColumn *)getColumnOnResultColumn:(const WCDB::ResultColumn &)resultColumn\n                                             where:(const WCDB::Expression &)condition\n                                            orders:(const WCDB::OrderingTerms &)orders\n                                             limit:(const WCDB::Expression &)limit;\n\n- (nullable WCTOneColumn *)getColumnOnResultColumn:(const WCDB::ResultColumn &)resultColumn\n                                             where:(const WCDB::Expression &)condition\n                                             limit:(const WCDB::Expression &)limit\n                                            offset:(const WCDB::Expression &)offset;\n\n- (nullable WCTOneColumn *)getColumnOnResultColumn:(const WCDB::ResultColumn &)resultColumn\n                                            orders:(const WCDB::OrderingTerms &)orders\n                                             limit:(const WCDB::Expression &)limit\n                                            offset:(const WCDB::Expression &)offset;\n\n- (nullable WCTOneColumn *)getColumnOnResultColumn:(const WCDB::ResultColumn &)resultColumn\n                                             where:(const WCDB::Expression &)condition\n                                            orders:(const WCDB::OrderingTerms &)orders\n                                             limit:(const WCDB::Expression &)limit\n                                            offset:(const WCDB::Expression &)offset;\n\n#pragma mark - Get Rows\n- (nullable WCTColumnsXRows *)getRowsOnResultColumns:(const WCDB::ResultColumns &)resultColumns;\n\n- (nullable WCTColumnsXRows *)getRowsOnResultColumns:(const WCDB::ResultColumns &)resultColumns\n                                               where:(const WCDB::Expression &)condition;\n\n- (nullable WCTColumnsXRows *)getRowsOnResultColumns:(const WCDB::ResultColumns &)resultColumns\n                                              orders:(const WCDB::OrderingTerms &)orders;\n\n- (nullable WCTColumnsXRows *)getRowsOnResultColumns:(const WCDB::ResultColumns &)resultColumns\n                                               limit:(const WCDB::Expression &)limit;\n\n- (nullable WCTColumnsXRows *)getRowsOnResultColumns:(const WCDB::ResultColumns &)resultColumns\n                                               where:(const WCDB::Expression &)condition\n                                              orders:(const WCDB::OrderingTerms &)orders;\n\n- (nullable WCTColumnsXRows *)getRowsOnResultColumns:(const WCDB::ResultColumns &)resultColumns\n                                               where:(const WCDB::Expression &)condition\n                                               limit:(const WCDB::Expression &)limit;\n\n- (nullable WCTColumnsXRows *)getRowsOnResultColumns:(const WCDB::ResultColumns &)resultColumns\n                                              orders:(const WCDB::OrderingTerms &)orders\n                                               limit:(const WCDB::Expression &)limit;\n\n- (nullable WCTColumnsXRows *)getRowsOnResultColumns:(const WCDB::ResultColumns &)resultColumns\n                                               limit:(const WCDB::Expression &)limit\n                                              offset:(const WCDB::Expression &)offset;\n\n- (nullable WCTColumnsXRows *)getRowsOnResultColumns:(const WCDB::ResultColumns &)resultColumns\n                                               where:(const WCDB::Expression &)condition\n                                              orders:(const WCDB::OrderingTerms &)orders\n                                               limit:(const WCDB::Expression &)limit;\n\n- (nullable WCTColumnsXRows *)getRowsOnResultColumns:(const WCDB::ResultColumns &)resultColumns\n                                               where:(const WCDB::Expression &)condition\n                                               limit:(const WCDB::Expression &)limit\n                                              offset:(const WCDB::Expression &)offset;\n\n- (nullable WCTColumnsXRows *)getRowsOnResultColumns:(const WCDB::ResultColumns &)resultColumns\n                                              orders:(const WCDB::OrderingTerms &)orders\n                                               limit:(const WCDB::Expression &)limit\n                                              offset:(const WCDB::Expression &)offset;\n\n- (nullable WCTColumnsXRows *)getRowsOnResultColumns:(const WCDB::ResultColumns &)resultColumns\n                                               where:(const WCDB::Expression &)condition\n                                              orders:(const WCDB::OrderingTerms &)orders\n                                               limit:(const WCDB::Expression &)limit\n                                              offset:(const WCDB::Expression &)offset;\n\n@end\n\nNS_ASSUME_NONNULL_END\n"
  },
  {
    "path": "src/objc/convenient/WCTTable+Convenient.mm",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"WCTChainCall+Private.h\"\n#import \"WCTDatabase+Convenient.h\"\n#import \"WCTDelete.h\"\n#import \"WCTInsert.h\"\n#import \"WCTMultiSelect.h\"\n#import \"WCTORM.h\"\n#import \"WCTSelect.h\"\n#import \"WCTSelectable+Private.h\"\n#import \"WCTTable+ChainCall.h\"\n#import \"WCTTable+Convenient.h\"\n#import \"WCTTable+Private.h\"\n#import \"WCTUpdate.h\"\n\n@implementation WCTTable (Convenient)\n\n#pragma mark - Get Object\n- (WCTObject *)getObject\n{\n    return [[[self prepareSelect] limit:1] firstObject];\n}\n\n- (WCTObject *)getObjectWhere:(const WCDB::Expression &)condition\n{\n    return [[[[self prepareSelect] where:condition] limit:1] firstObject];\n}\n\n- (WCTObject *)getObjectOrders:(const WCDB::OrderingTerms &)orders\n{\n    return [[[[self prepareSelect] orders:orders] limit:1] firstObject];\n}\n\n- (WCTObject *)getObjectOffset:(const WCDB::Expression &)offset\n{\n    return [[[[self prepareSelect] limit:1] offset:offset] firstObject];\n}\n\n- (WCTObject *)getObjectWhere:(const WCDB::Expression &)condition\n                       orders:(const WCDB::OrderingTerms &)orders\n{\n    return [[[[[self prepareSelect] where:condition] limit:1] orders:orders] firstObject];\n}\n\n- (WCTObject *)getObjectWhere:(const WCDB::Expression &)condition\n                       offset:(const WCDB::Expression &)offset\n{\n    return [[[[[self prepareSelect] where:condition] limit:1] offset:offset] firstObject];\n}\n\n- (WCTObject *)getObjectOrders:(const WCDB::OrderingTerms &)orders\n                        offset:(const WCDB::Expression &)offset\n{\n    return [[[[[self prepareSelect] orders:orders] limit:1] offset:offset] firstObject];\n}\n\n- (WCTObject *)getObjectWhere:(const WCDB::Expression &)condition\n                       orders:(const WCDB::OrderingTerms &)orders\n                       offset:(const WCDB::Expression &)offset\n{\n    return [[[[[[self prepareSelect] where:condition] orders:orders] limit:1] offset:offset] firstObject];\n}\n\n#pragma mark - Get Objects\n- (NSArray /* <WCTObject*> */ *)getObjects\n{\n    return [[self prepareSelect] allObjects];\n}\n\n- (NSArray /* <WCTObject*> */ *)getObjectsWhere:(const WCDB::Expression &)condition\n{\n    return [[[self prepareSelect] where:condition] allObjects];\n}\n\n- (NSArray /* <WCTObject*> */ *)getObjectsOrders:(const WCDB::OrderingTerms &)orders\n{\n    return [[[self prepareSelect] orders:orders] allObjects];\n}\n\n- (NSArray /* <WCTObject*> */ *)getObjectsLimit:(const WCDB::Expression &)limit\n{\n    return [[[self prepareSelect] limit:limit] allObjects];\n}\n\n- (NSArray /* <WCTObject*> */ *)getObjectsOffset:(const WCDB::Expression &)offset\n{\n    return [[[self prepareSelect] offset:offset] allObjects];\n}\n\n- (NSArray /* <WCTObject*> */ *)getObjectsWhere:(const WCDB::Expression &)condition\n                                         orders:(const WCDB::OrderingTerms &)orders\n{\n    return [[[[self prepareSelect] where:condition] orders:orders] allObjects];\n}\n\n- (NSArray /* <WCTObject*> */ *)getObjectsWhere:(const WCDB::Expression &)condition\n                                          limit:(const WCDB::Expression &)limit\n{\n    return [[[[self prepareSelect] where:condition] limit:limit] allObjects];\n}\n\n- (NSArray /* <WCTObject*> */ *)getObjectsOrders:(const WCDB::OrderingTerms &)orders\n                                           limit:(const WCDB::Expression &)limit\n{\n    return [[[[self prepareSelect] orders:orders] limit:limit] allObjects];\n}\n\n- (NSArray /* <WCTObject*> */ *)getObjectsOffset:(const WCDB::Expression &)offset\n                                           limit:(const WCDB::Expression &)limit\n{\n    return [[[[self prepareSelect] limit:limit] offset:offset] allObjects];\n}\n\n- (NSArray /* <WCTObject*> */ *)getObjectsWhere:(const WCDB::Expression &)condition\n                                         orders:(const WCDB::OrderingTerms &)orders\n                                          limit:(const WCDB::Expression &)limit\n{\n    return [[[[[self prepareSelect] where:condition] orders:orders] limit:limit] allObjects];\n}\n\n- (NSArray /* <WCTObject*> */ *)getObjectsWhere:(const WCDB::Expression &)condition\n                                          limit:(const WCDB::Expression &)limit\n                                         offset:(const WCDB::Expression &)offset\n{\n    return [[[[[self prepareSelect] where:condition] limit:limit] offset:offset] allObjects];\n}\n\n- (NSArray /* <WCTObject*> */ *)getObjectsOrders:(const WCDB::OrderingTerms &)orders\n                                           limit:(const WCDB::Expression &)limit\n                                          offset:(const WCDB::Expression &)offset\n{\n    return [[[[[self prepareSelect] orders:orders] limit:limit] offset:offset] allObjects];\n}\n\n- (NSArray /* <WCTObject*> */ *)getObjectsWhere:(const WCDB::Expression &)condition\n                                         orders:(const WCDB::OrderingTerms &)orders\n                                          limit:(const WCDB::Expression &)limit\n                                         offset:(const WCDB::Expression &)offset\n{\n    return [[[[[[self prepareSelect] where:condition] orders:orders] limit:limit] offset:offset] allObjects];\n}\n\n#pragma mark - Get Part Of Object\n- (WCTObject *)getObjectOnResultColumns:(const WCTResultColumns &)resultColumns\n{\n    return [[[[self prepareSelect] onResultColumns:resultColumns] limit:1] firstObject];\n}\n\n- (WCTObject *)getObjectOnResultColumns:(const WCTResultColumns &)resultColumns\n                                  where:(const WCDB::Expression &)condition\n{\n    return [[[[[self prepareSelect] onResultColumns:resultColumns] where:condition] limit:1] firstObject];\n}\n\n- (WCTObject *)getObjectOnResultColumns:(const WCTResultColumns &)resultColumns\n                                 orders:(const WCDB::OrderingTerms &)orders\n{\n    return [[[[[self prepareSelect] onResultColumns:resultColumns] orders:orders] limit:1] firstObject];\n}\n\n- (WCTObject *)getObjectOnResultColumns:(const WCTResultColumns &)resultColumns\n                                 offset:(const WCDB::Expression &)offset\n{\n    return [[[[[self prepareSelect] onResultColumns:resultColumns] limit:1] offset:offset] firstObject];\n}\n\n- (WCTObject *)getObjectOnResultColumns:(const WCTResultColumns &)resultColumns\n                                  where:(const WCDB::Expression &)condition\n                                 orders:(const WCDB::OrderingTerms &)orders\n{\n    return [[[[[[self prepareSelect] onResultColumns:resultColumns] where:condition] orders:orders] limit:1] firstObject];\n}\n\n- (WCTObject *)getObjectOnResultColumns:(const WCTResultColumns &)resultColumns\n                                  where:(const WCDB::Expression &)condition\n                                 offset:(const WCDB::Expression &)offset\n{\n    return [[[[[[self prepareSelect] onResultColumns:resultColumns] where:condition] limit:1] offset:offset] firstObject];\n}\n\n- (WCTObject *)getObjectOnResultColumns:(const WCTResultColumns &)resultColumns\n                                 orders:(const WCDB::OrderingTerms &)orders\n                                 offset:(const WCDB::Expression &)offset\n{\n    return [[[[[[self prepareSelect] onResultColumns:resultColumns] orders:orders] limit:1] offset:offset] firstObject];\n}\n\n- (WCTObject *)getObjectOnResultColumns:(const WCTResultColumns &)resultColumns\n                                  where:(const WCDB::Expression &)condition\n                                 orders:(const WCDB::OrderingTerms &)orders\n                                 offset:(const WCDB::Expression &)offset\n{\n    return [[[[[[[self prepareSelect] onResultColumns:resultColumns] where:condition] orders:orders] limit:1] offset:offset] firstObject];\n}\n\n#pragma mark - Get Part Of Objects\n- (NSArray /* <WCTObject*> */ *)getObjectsOnResultColumns:(const WCTResultColumns &)resultColumns\n{\n    return [[[self prepareSelect] onResultColumns:resultColumns] allObjects];\n}\n\n- (NSArray /* <WCTObject*> */ *)getObjectsOnResultColumns:(const WCTResultColumns &)resultColumns\n                                                    where:(const WCDB::Expression &)condition\n{\n    return [[[[self prepareSelect] onResultColumns:resultColumns] where:condition] allObjects];\n}\n\n- (NSArray /* <WCTObject*> */ *)getObjectsOnResultColumns:(const WCTResultColumns &)resultColumns\n                                                   orders:(const WCDB::OrderingTerms &)orders\n{\n    return [[[[self prepareSelect] onResultColumns:resultColumns] orders:orders] allObjects];\n}\n\n- (NSArray /* <WCTObject*> */ *)getObjectsOnResultColumns:(const WCTResultColumns &)resultColumns\n                                                    limit:(const WCDB::Expression &)limit\n{\n    return [[[[self prepareSelect] onResultColumns:resultColumns] limit:limit] allObjects];\n}\n\n- (NSArray /* <WCTObject*> */ *)getObjectsOnResultColumns:(const WCTResultColumns &)resultColumns\n                                                    where:(const WCDB::Expression &)condition\n                                                   orders:(const WCDB::OrderingTerms &)orders\n{\n    return [[[[[self prepareSelect] onResultColumns:resultColumns] where:condition] orders:orders] allObjects];\n}\n\n- (NSArray /* <WCTObject*> */ *)getObjectsOnResultColumns:(const WCTResultColumns &)resultColumns\n                                                    where:(const WCDB::Expression &)condition\n                                                    limit:(const WCDB::Expression &)limit\n{\n    return [[[[[self prepareSelect] onResultColumns:resultColumns] where:condition] limit:limit] allObjects];\n}\n\n- (NSArray /* <WCTObject*> */ *)getObjectsOnResultColumns:(const WCTResultColumns &)resultColumns\n                                                   orders:(const WCDB::OrderingTerms &)orders\n                                                    limit:(const WCDB::Expression &)limit\n{\n    return [[[[[self prepareSelect] onResultColumns:resultColumns] orders:orders] limit:limit] allObjects];\n}\n\n- (NSArray /* <WCTObject*> */ *)getObjectsOnResultColumns:(const WCTResultColumns &)resultColumns\n                                                    limit:(const WCDB::Expression &)limit\n                                                   offset:(const WCDB::Expression &)offset\n{\n    return [[[[[self prepareSelect] onResultColumns:resultColumns] limit:limit] offset:offset] allObjects];\n}\n\n- (NSArray /* <WCTObject*> */ *)getObjectsOnResultColumns:(const WCTResultColumns &)resultColumns\n                                                    where:(const WCDB::Expression &)condition\n                                                   orders:(const WCDB::OrderingTerms &)orders\n                                                    limit:(const WCDB::Expression &)limit\n{\n    return [[[[[[self prepareSelect] onResultColumns:resultColumns] where:condition] orders:orders] limit:limit] allObjects];\n}\n\n- (NSArray /* <WCTObject*> */ *)getObjectsOnResultColumns:(const WCTResultColumns &)resultColumns\n                                                    where:(const WCDB::Expression &)condition\n                                                    limit:(const WCDB::Expression &)limit\n                                                   offset:(const WCDB::Expression &)offset\n{\n    return [[[[[[self prepareSelect] onResultColumns:resultColumns] where:condition] limit:limit] offset:offset] allObjects];\n}\n\n- (NSArray /* <WCTObject*> */ *)getObjectsOnResultColumns:(const WCTResultColumns &)resultColumns\n                                                   orders:(const WCDB::OrderingTerms &)orders\n                                                    limit:(const WCDB::Expression &)limit\n                                                   offset:(const WCDB::Expression &)offset\n{\n    return [[[[[[self prepareSelect] onResultColumns:resultColumns] orders:orders] limit:limit] offset:offset] allObjects];\n}\n\n- (NSArray /* <WCTObject*> */ *)getObjectsOnResultColumns:(const WCTResultColumns &)resultColumns\n                                                    where:(const WCDB::Expression &)condition\n                                                   orders:(const WCDB::OrderingTerms &)orders\n                                                    limit:(const WCDB::Expression &)limit\n                                                   offset:(const WCDB::Expression &)offset\n{\n    return [[[[[[[self prepareSelect] onResultColumns:resultColumns] where:condition] orders:orders] limit:limit] offset:offset] allObjects];\n}\n\n#pragma mark - Insert\n- (BOOL)insertObject:(WCTObject *)object\n{\n    return [[[self prepareInsert] value:object] execute];\n}\n\n- (BOOL)insertObjects:(NSArray<WCTObject *> *)objects\n{\n    return [[[self prepareInsert] values:objects] execute];\n}\n\n- (BOOL)insertOrReplaceObject:(WCTObject *)object\n{\n    return [[[[self prepareInsert] orReplace] value:object] execute];\n}\n\n- (BOOL)insertOrReplaceObjects:(NSArray<WCTObject *> *)objects\n{\n    return [[[[self prepareInsert] orReplace] values:objects] execute];\n}\n\n- (BOOL)insertOrIgnoreObject:(WCTObject *)object\n{\n    return [[[[self prepareInsert] orIgnore] value:object] execute];\n}\n\n- (BOOL)insertOrIgnoreObjects:(NSArray<WCTObject *> *)objects\n{\n    return [[[[self prepareInsert] orIgnore] values:objects] execute];\n}\n\n- (BOOL)insertObject:(WCTObject *)object onProperties:(const WCTProperties &)properties\n{\n    return [[[[self prepareInsert] onProperties:properties] value:object] execute];\n}\n\n- (BOOL)insertObjects:(NSArray<WCTObject *> *)objects onProperties:(const WCTProperties &)properties\n{\n    return [[[[self prepareInsert] onProperties:properties] values:objects] execute];\n}\n\n- (BOOL)insertOrReplaceObject:(WCTObject *)object onProperties:(const WCTProperties &)properties\n{\n    return [[[[[self prepareInsert] orReplace] onProperties:properties] value:object] execute];\n}\n\n- (BOOL)insertOrReplaceObjects:(NSArray<WCTObject *> *)objects onProperties:(const WCTProperties &)properties\n{\n    return [[[[[self prepareInsert] orReplace] onProperties:properties] values:objects] execute];\n}\n\n- (BOOL)insertOrIgnoreObject:(WCTObject *)object onProperties:(const WCTProperties &)properties\n{\n    return [[[[[self prepareInsert] orIgnore] onProperties:properties] value:object] execute];\n}\n\n- (BOOL)insertOrIgnoreObjects:(NSArray<WCTObject *> *)objects onProperties:(const WCTProperties &)properties\n{\n    return [[[[[self prepareInsert] orIgnore] onProperties:properties] values:objects] execute];\n}\n\n#pragma mark - Update Properties To Object\n- (BOOL)updateProperties:(const WCTProperties &)properties\n                toObject:(WCTObject *)object\n{\n    return [[[[self prepareUpdate] set:properties] toObject:object] execute];\n}\n\n- (BOOL)updateProperties:(const WCTProperties &)properties\n                toObject:(WCTObject *)object\n                   where:(const WCDB::Expression &)condition\n{\n    return [[[[[self prepareUpdate] set:properties] toObject:object] where:condition] execute];\n}\n\n- (BOOL)updateProperties:(const WCTProperties &)properties\n                toObject:(WCTObject *)object\n                   limit:(const WCDB::Expression &)limit\n{\n    return [[[[[self prepareUpdate] set:properties] toObject:object] limit:limit] execute];\n}\n\n- (BOOL)updateProperties:(const WCTProperties &)properties\n                toObject:(WCTObject *)object\n                   where:(const WCDB::Expression &)condition\n                   limit:(const WCDB::Expression &)limit\n{\n    return [[[[[[self prepareUpdate] set:properties] toObject:object] where:condition] limit:limit] execute];\n}\n\n- (BOOL)updateProperties:(const WCTProperties &)properties\n                toObject:(WCTObject *)object\n                  orders:(const WCDB::OrderingTerms &)orders\n                   limit:(const WCDB::Expression &)limit\n{\n    return [[[[[[self prepareUpdate] set:properties] toObject:object] orders:orders] limit:limit] execute];\n}\n\n- (BOOL)updateProperties:(const WCTProperties &)properties\n                toObject:(WCTObject *)object\n                   limit:(const WCDB::Expression &)limit\n                  offset:(const WCDB::Expression &)offset\n{\n    return [[[[[[self prepareUpdate] set:properties] toObject:object] limit:limit] offset:offset] execute];\n}\n\n- (BOOL)updateProperties:(const WCTProperties &)properties\n                toObject:(WCTObject *)object\n                   where:(const WCDB::Expression &)condition\n                  orders:(const WCDB::OrderingTerms &)orders\n                   limit:(const WCDB::Expression &)limit\n{\n    return [[[[[[[self prepareUpdate] set:properties] toObject:object] where:condition] orders:orders] limit:limit] execute];\n}\n\n- (BOOL)updateProperties:(const WCTProperties &)properties\n                toObject:(WCTObject *)object\n                   where:(const WCDB::Expression &)condition\n                   limit:(const WCDB::Expression &)limit\n                  offset:(const WCDB::Expression &)offset\n{\n    return [[[[[[[self prepareUpdate] set:properties] toObject:object] where:condition] limit:limit] offset:offset] execute];\n}\n\n- (BOOL)updateProperties:(const WCTProperties &)properties\n                toObject:(WCTObject *)object\n                  orders:(const WCDB::OrderingTerms &)orders\n                   limit:(const WCDB::Expression &)limit\n                  offset:(const WCDB::Expression &)offset\n{\n    return [[[[[[[self prepareUpdate] set:properties] toObject:object] orders:orders] limit:limit] offset:offset] execute];\n}\n\n- (BOOL)updateProperties:(const WCTProperties &)properties\n                toObject:(WCTObject *)object\n                   where:(const WCDB::Expression &)condition\n                  orders:(const WCDB::OrderingTerms &)orders\n                   limit:(const WCDB::Expression &)limit\n                  offset:(const WCDB::Expression &)offset\n{\n    return [[[[[[[[self prepareUpdate] set:properties] toObject:object] where:condition] orders:orders] limit:limit] offset:offset] execute];\n}\n\n#pragma mark - Update Properties To Row\n- (BOOL)updateProperties:(const WCTProperties &)properties\n                   toRow:(WCTColumnCodingRow *)row\n{\n    return [[[[self prepareUpdate] set:properties] toRow:row] execute];\n}\n\n- (BOOL)updateProperties:(const WCTProperties &)properties\n                   toRow:(WCTColumnCodingRow *)row\n                   where:(const WCDB::Expression &)condition\n{\n    return [[[[[self prepareUpdate] set:properties] toRow:row] where:condition] execute];\n}\n\n- (BOOL)updateProperties:(const WCTProperties &)properties\n                   toRow:(WCTColumnCodingRow *)row\n                   limit:(const WCDB::Expression &)limit\n{\n    return [[[[[self prepareUpdate] set:properties] toRow:row] limit:limit] execute];\n}\n\n- (BOOL)updateProperties:(const WCTProperties &)properties\n                   toRow:(WCTColumnCodingRow *)row\n                   where:(const WCDB::Expression &)condition\n                   limit:(const WCDB::Expression &)limit\n{\n    return [[[[[[self prepareUpdate] set:properties] toRow:row] where:condition] limit:limit] execute];\n}\n\n- (BOOL)updateProperties:(const WCTProperties &)properties\n                   toRow:(WCTColumnCodingRow *)row\n                  orders:(const WCDB::OrderingTerms &)orders\n                   limit:(const WCDB::Expression &)limit\n{\n    return [[[[[[self prepareUpdate] set:properties] toRow:row] orders:orders] limit:limit] execute];\n}\n\n- (BOOL)updateProperties:(const WCTProperties &)properties\n                   toRow:(WCTColumnCodingRow *)row\n                   limit:(const WCDB::Expression &)limit\n                  offset:(const WCDB::Expression &)offset\n{\n    return [[[[[[self prepareUpdate] set:properties] toRow:row] limit:limit] offset:offset] execute];\n}\n\n- (BOOL)updateProperties:(const WCTProperties &)properties\n                   toRow:(WCTColumnCodingRow *)row\n                   where:(const WCDB::Expression &)condition\n                  orders:(const WCDB::OrderingTerms &)orders\n                   limit:(const WCDB::Expression &)limit\n{\n    return [[[[[[[self prepareUpdate] set:properties] toRow:row] where:condition] orders:orders] limit:limit] execute];\n}\n\n- (BOOL)updateProperties:(const WCTProperties &)properties\n                   toRow:(WCTColumnCodingRow *)row\n                   where:(const WCDB::Expression &)condition\n                   limit:(const WCDB::Expression &)limit\n                  offset:(const WCDB::Expression &)offset\n{\n    return [[[[[[[self prepareUpdate] set:properties] toRow:row] where:condition] limit:limit] offset:offset] execute];\n}\n\n- (BOOL)updateProperties:(const WCTProperties &)properties\n                   toRow:(WCTColumnCodingRow *)row\n                  orders:(const WCDB::OrderingTerms &)orders\n                   limit:(const WCDB::Expression &)limit\n                  offset:(const WCDB::Expression &)offset\n{\n    return [[[[[[[self prepareUpdate] set:properties] toRow:row] orders:orders] limit:limit] offset:offset] execute];\n}\n\n- (BOOL)updateProperties:(const WCTProperties &)properties\n                   toRow:(WCTColumnCodingRow *)row\n                   where:(const WCDB::Expression &)condition\n                  orders:(const WCDB::OrderingTerms &)orders\n                   limit:(const WCDB::Expression &)limit\n                  offset:(const WCDB::Expression &)offset\n{\n    return [[[[[[[[self prepareUpdate] set:properties] toRow:row] where:condition] orders:orders] limit:limit] offset:offset] execute];\n}\n\n#pragma mark - Update Properties With Value\n- (BOOL)updateProperty:(const WCTProperty &)property\n               toValue:(WCTColumnCodingValue *)value\n{\n    return [[[[self prepareUpdate] set:property] toValue:value] execute];\n}\n\n- (BOOL)updateProperty:(const WCTProperty &)property\n               toValue:(WCTColumnCodingValue *)value\n                 where:(const WCDB::Expression &)condition\n{\n    return [[[[[self prepareUpdate] set:property] toValue:value] where:condition] execute];\n}\n\n- (BOOL)updateProperty:(const WCTProperty &)property\n               toValue:(WCTColumnCodingValue *)value\n                 limit:(const WCDB::Expression &)limit\n{\n    return [[[[[self prepareUpdate] set:property] toValue:value] limit:limit] execute];\n}\n\n- (BOOL)updateProperty:(const WCTProperty &)property\n               toValue:(WCTColumnCodingValue *)value\n                 where:(const WCDB::Expression &)condition\n                 limit:(const WCDB::Expression &)limit\n{\n    return [[[[[[self prepareUpdate] set:property] toValue:value] where:condition] limit:limit] execute];\n}\n\n- (BOOL)updateProperty:(const WCTProperty &)property\n               toValue:(WCTColumnCodingValue *)value\n                orders:(const WCDB::OrderingTerms &)orders\n                 limit:(const WCDB::Expression &)limit\n{\n    return [[[[[[self prepareUpdate] set:property] toValue:value] orders:orders] limit:limit] execute];\n}\n\n- (BOOL)updateProperty:(const WCTProperty &)property\n               toValue:(WCTColumnCodingValue *)value\n                 limit:(const WCDB::Expression &)limit\n                offset:(const WCDB::Expression &)offset\n{\n    return [[[[[[self prepareUpdate] set:property] toValue:value] limit:limit] offset:offset] execute];\n}\n\n- (BOOL)updateProperty:(const WCTProperty &)property\n               toValue:(WCTColumnCodingValue *)value\n                 where:(const WCDB::Expression &)condition\n                orders:(const WCDB::OrderingTerms &)orders\n                 limit:(const WCDB::Expression &)limit\n{\n    return [[[[[[[self prepareUpdate] set:property] toValue:value] where:condition] orders:orders] limit:limit] execute];\n}\n\n- (BOOL)updateProperty:(const WCTProperty &)property\n               toValue:(WCTColumnCodingValue *)value\n                 where:(const WCDB::Expression &)condition\n                 limit:(const WCDB::Expression &)limit\n                offset:(const WCDB::Expression &)offset\n{\n    return [[[[[[[self prepareUpdate] set:property] toValue:value] where:condition] limit:limit] offset:offset] execute];\n}\n\n- (BOOL)updateProperty:(const WCTProperty &)property\n               toValue:(WCTColumnCodingValue *)value\n                orders:(const WCDB::OrderingTerms &)orders\n                 limit:(const WCDB::Expression &)limit\n                offset:(const WCDB::Expression &)offset\n{\n    return [[[[[[[self prepareUpdate] set:property] toValue:value] orders:orders] limit:limit] offset:offset] execute];\n}\n\n- (BOOL)updateProperty:(const WCTProperty &)property\n               toValue:(WCTColumnCodingValue *)value\n                 where:(const WCDB::Expression &)condition\n                orders:(const WCDB::OrderingTerms &)orders\n                 limit:(const WCDB::Expression &)limit\n                offset:(const WCDB::Expression &)offset\n{\n    return [[[[[[[[self prepareUpdate] set:property] toValue:value] where:condition] orders:orders] limit:limit] offset:offset] execute];\n}\n\n#pragma mark - Delete\n- (BOOL)deleteObjects\n{\n    return [[self prepareDelete] execute];\n}\n\n- (BOOL)deleteObjectsWhere:(const WCDB::Expression &)condition\n{\n    return [[[self prepareDelete] where:condition] execute];\n}\n\n- (BOOL)deleteObjectsOrders:(const WCDB::OrderingTerms &)orders\n{\n    return [[[self prepareDelete] orders:orders] execute];\n}\n\n- (BOOL)deleteObjectsLimit:(const WCDB::Expression &)limit\n{\n    return [[[self prepareDelete] limit:limit] execute];\n}\n\n- (BOOL)deleteObjectsOffset:(const WCDB::Expression &)offset\n{\n    return [[[self prepareDelete] offset:offset] execute];\n}\n\n- (BOOL)deleteObjectsWhere:(const WCDB::Expression &)condition\n                     limit:(const WCDB::Expression &)limit\n{\n    return [[[[self prepareDelete] where:condition] limit:limit] execute];\n}\n\n- (BOOL)deleteObjectsOrders:(const WCDB::OrderingTerms &)orders\n                      limit:(const WCDB::Expression &)limit\n{\n    return [[[[self prepareDelete] orders:orders] limit:limit] execute];\n}\n\n- (BOOL)deleteObjectsLimit:(const WCDB::Expression &)limit\n                    offset:(const WCDB::Expression &)offset\n{\n    return [[[[self prepareDelete] limit:limit] offset:offset] execute];\n}\n\n- (BOOL)deleteObjectsWhere:(const WCDB::Expression &)condition\n                    orders:(const WCDB::OrderingTerms &)orders\n                     limit:(const WCDB::Expression &)limit\n{\n    return [[[[[self prepareDelete] where:condition] orders:orders] limit:limit] execute];\n}\n\n- (BOOL)deleteObjectsWhere:(const WCDB::Expression &)condition\n                     limit:(const WCDB::Expression &)limit\n                    offset:(const WCDB::Expression &)offset\n{\n    return [[[[[self prepareDelete] where:condition] limit:limit] offset:offset] execute];\n}\n\n- (BOOL)deleteObjectsOrders:(const WCDB::OrderingTerms &)orders\n                      limit:(const WCDB::Expression &)limit\n                     offset:(const WCDB::Expression &)offset\n{\n    return [[[[[self prepareDelete] orders:orders] limit:limit] offset:offset] execute];\n}\n\n- (BOOL)deleteObjectsWhere:(const WCDB::Expression &)condition\n                    orders:(const WCDB::OrderingTerms &)orders\n                     limit:(const WCDB::Expression &)limit\n                    offset:(const WCDB::Expression &)offset\n{\n    return [[[[[[self prepareDelete] where:condition] orders:orders] limit:limit] offset:offset] execute];\n}\n\n#pragma mark - Get Value\n- (WCTValue *)getValueOnResultColumn:(const WCDB::ResultColumn &)resultColumn\n{\n    return [_database getValueFromStatement:WCDB::StatementSelect().select(resultColumn).from(_tableName).order(WCDB::OrderingTerm::ascendingRowid()).limit(1)];\n}\n\n- (WCTValue *)getValueOnResultColumn:(const WCDB::ResultColumn &)resultColumn\n                               where:(const WCDB::Expression &)condition\n{\n    return [_database getValueFromStatement:WCDB::StatementSelect().select(resultColumn).from(_tableName).where(condition).order(WCDB::OrderingTerm::ascendingRowid()).limit(1)];\n}\n\n- (WCTValue *)getValueOnResultColumn:(const WCDB::ResultColumn &)resultColumn\n                              orders:(const WCDB::OrderingTerms &)orders\n{\n    return [_database getValueFromStatement:WCDB::StatementSelect().select(resultColumn).from(_tableName).orders(orders).limit(1)];\n}\n\n- (WCTValue *)getValueOnResultColumn:(const WCDB::ResultColumn &)resultColumn\n                              offset:(const WCDB::Expression &)offset\n{\n    return [_database getValueFromStatement:WCDB::StatementSelect().select(resultColumn).from(_tableName).order(WCDB::OrderingTerm::ascendingRowid()).limit(1).offset(offset)];\n}\n\n- (WCTValue *)getValueOnResultColumn:(const WCDB::ResultColumn &)resultColumn\n                               where:(const WCDB::Expression &)condition\n                              orders:(const WCDB::OrderingTerms &)orders\n{\n    return [_database getValueFromStatement:WCDB::StatementSelect().select(resultColumn).from(_tableName).where(condition).orders(orders).limit(1)];\n}\n\n- (WCTValue *)getValueOnResultColumn:(const WCDB::ResultColumn &)resultColumn\n                               where:(const WCDB::Expression &)condition\n                              offset:(const WCDB::Expression &)offset\n{\n    return [_database getValueFromStatement:WCDB::StatementSelect().select(resultColumn).from(_tableName).where(condition).order(WCDB::OrderingTerm::ascendingRowid()).limit(1).offset(offset)];\n}\n\n- (WCTValue *)getValueOnResultColumn:(const WCDB::ResultColumn &)resultColumn\n                              orders:(const WCDB::OrderingTerms &)orders\n                              offset:(const WCDB::Expression &)offset\n{\n    return [_database getValueFromStatement:WCDB::StatementSelect().select(resultColumn).from(_tableName).orders(orders).limit(1).offset(offset)];\n}\n\n- (WCTValue *)getValueOnResultColumn:(const WCDB::ResultColumn &)resultColumn\n                               where:(const WCDB::Expression &)condition\n                              orders:(const WCDB::OrderingTerms &)orders\n                              offset:(const WCDB::Expression &)offset\n{\n    return [_database getValueFromStatement:WCDB::StatementSelect().select(resultColumn).from(_tableName).where(condition).orders(orders).limit(1).offset(offset)];\n}\n\n#pragma mark - Get Row\n- (WCTOneRow *)getRowOnResultColumns:(const WCDB::ResultColumns &)resultColumns\n{\n    return [_database getRowFromStatement:WCDB::StatementSelect().select(resultColumns).from(_tableName).order(WCDB::OrderingTerm::ascendingRowid()).limit(1)];\n}\n\n- (WCTOneRow *)getRowOnResultColumns:(const WCDB::ResultColumns &)resultColumns\n                               where:(const WCDB::Expression &)condition\n{\n    return [_database getRowFromStatement:WCDB::StatementSelect().select(resultColumns).from(_tableName).where(condition).order(WCDB::OrderingTerm::ascendingRowid()).limit(1)];\n}\n\n- (WCTOneRow *)getRowOnResultColumns:(const WCDB::ResultColumns &)resultColumns\n                              orders:(const WCDB::OrderingTerms &)orders\n{\n    return [_database getRowFromStatement:WCDB::StatementSelect().select(resultColumns).from(_tableName).orders(orders).limit(1)];\n}\n\n- (WCTOneRow *)getRowOnResultColumns:(const WCDB::ResultColumns &)resultColumns\n                              offset:(const WCDB::Expression &)offset\n{\n    return [_database getRowFromStatement:WCDB::StatementSelect().select(resultColumns).from(_tableName).order(WCDB::OrderingTerm::ascendingRowid()).limit(1).offset(offset)];\n}\n\n- (WCTOneRow *)getRowOnResultColumns:(const WCDB::ResultColumns &)resultColumns\n                               where:(const WCDB::Expression &)condition\n                              orders:(const WCDB::OrderingTerms &)orders\n{\n    return [_database getRowFromStatement:WCDB::StatementSelect().select(resultColumns).from(_tableName).where(condition).orders(orders).limit(1)];\n}\n\n- (WCTOneRow *)getRowOnResultColumns:(const WCDB::ResultColumns &)resultColumns\n                               where:(const WCDB::Expression &)condition\n                              offset:(const WCDB::Expression &)offset\n{\n    return [_database getRowFromStatement:WCDB::StatementSelect().select(resultColumns).from(_tableName).where(condition).order(WCDB::OrderingTerm::ascendingRowid()).limit(1).offset(offset)];\n}\n\n- (WCTOneRow *)getRowOnResultColumns:(const WCDB::ResultColumns &)resultColumns\n                              orders:(const WCDB::OrderingTerms &)orders\n                              offset:(const WCDB::Expression &)offset\n{\n    return [_database getRowFromStatement:WCDB::StatementSelect().select(resultColumns).from(_tableName).orders(orders).limit(1).offset(offset)];\n}\n\n- (WCTOneRow *)getRowOnResultColumns:(const WCDB::ResultColumns &)resultColumns\n                               where:(const WCDB::Expression &)condition\n                              orders:(const WCDB::OrderingTerms &)orders\n                              offset:(const WCDB::Expression &)offset\n{\n    return [_database getRowFromStatement:WCDB::StatementSelect().select(resultColumns).from(_tableName).where(condition).orders(orders).limit(1).offset(offset)];\n}\n\n#pragma mark - Get Column\n- (WCTOneColumn *)getColumnOnResultColumn:(const WCDB::ResultColumn &)resultColumn\n{\n    return [_database getColumnFromStatement:WCDB::StatementSelect().select(resultColumn).from(_tableName).order(WCDB::OrderingTerm::ascendingRowid())];\n}\n\n- (WCTOneColumn *)getColumnOnResultColumn:(const WCDB::ResultColumn &)resultColumn\n                                    where:(const WCDB::Expression &)condition\n{\n    return [_database getColumnFromStatement:WCDB::StatementSelect().select(resultColumn).from(_tableName).where(condition).order(WCDB::OrderingTerm::ascendingRowid())];\n}\n\n- (WCTOneColumn *)getColumnOnResultColumn:(const WCDB::ResultColumn &)resultColumn\n                                   orders:(const WCDB::OrderingTerms &)orders\n{\n    return [_database getColumnFromStatement:WCDB::StatementSelect().select(resultColumn).from(_tableName).orders(orders)];\n}\n\n- (WCTOneColumn *)getColumnOnResultColumn:(const WCDB::ResultColumn &)resultColumn\n                                    limit:(const WCDB::Expression &)limit\n{\n    return [_database getColumnFromStatement:WCDB::StatementSelect().select(resultColumn).from(_tableName).order(WCDB::OrderingTerm::ascendingRowid()).limit(limit)];\n}\n\n- (WCTOneColumn *)getColumnOnResultColumn:(const WCDB::ResultColumn &)resultColumn\n                                    where:(const WCDB::Expression &)condition\n                                   orders:(const WCDB::OrderingTerms &)orders\n{\n    return [_database getColumnFromStatement:WCDB::StatementSelect().select(resultColumn).from(_tableName).where(condition).orders(orders)];\n}\n\n- (WCTOneColumn *)getColumnOnResultColumn:(const WCDB::ResultColumn &)resultColumn\n                                    where:(const WCDB::Expression &)condition\n                                    limit:(const WCDB::Expression &)limit\n{\n    return [_database getColumnFromStatement:WCDB::StatementSelect().select(resultColumn).from(_tableName).where(condition).order(WCDB::OrderingTerm::ascendingRowid()).limit(limit)];\n}\n\n- (WCTOneColumn *)getColumnOnResultColumn:(const WCDB::ResultColumn &)resultColumn\n                                   orders:(const WCDB::OrderingTerms &)orders\n                                    limit:(const WCDB::Expression &)limit\n{\n    return [_database getColumnFromStatement:WCDB::StatementSelect().select(resultColumn).from(_tableName).orders(orders).limit(limit)];\n}\n\n- (WCTOneColumn *)getColumnOnResultColumn:(const WCDB::ResultColumn &)resultColumn\n                                    limit:(const WCDB::Expression &)limit\n                                   offset:(const WCDB::Expression &)offset\n{\n    return [_database getColumnFromStatement:WCDB::StatementSelect().select(resultColumn).from(_tableName).order(WCDB::OrderingTerm::ascendingRowid()).limit(limit).offset(offset)];\n}\n\n- (WCTOneColumn *)getColumnOnResultColumn:(const WCDB::ResultColumn &)resultColumn\n                                    where:(const WCDB::Expression &)condition\n                                   orders:(const WCDB::OrderingTerms &)orders\n                                    limit:(const WCDB::Expression &)limit\n{\n    return [_database getColumnFromStatement:WCDB::StatementSelect().select(resultColumn).from(_tableName).where(condition).orders(orders).limit(limit)];\n}\n\n- (WCTOneColumn *)getColumnOnResultColumn:(const WCDB::ResultColumn &)resultColumn\n                                   orders:(const WCDB::OrderingTerms &)orders\n                                    limit:(const WCDB::Expression &)limit\n                                   offset:(const WCDB::Expression &)offset\n{\n    return [_database getColumnFromStatement:WCDB::StatementSelect().select(resultColumn).from(_tableName).orders(orders).limit(limit).offset(offset)];\n}\n\n- (WCTOneColumn *)getColumnOnResultColumn:(const WCDB::ResultColumn &)resultColumn\n                                    where:(const WCDB::Expression &)condition\n                                    limit:(const WCDB::Expression &)limit\n                                   offset:(const WCDB::Expression &)offset\n{\n    return [_database getColumnFromStatement:WCDB::StatementSelect().select(resultColumn).from(_tableName).where(condition).order(WCDB::OrderingTerm::ascendingRowid()).limit(limit).offset(offset)];\n}\n\n- (WCTOneColumn *)getColumnOnResultColumn:(const WCDB::ResultColumn &)resultColumn\n                                    where:(const WCDB::Expression &)condition\n                                   orders:(const WCDB::OrderingTerms &)orders\n                                    limit:(const WCDB::Expression &)limit\n                                   offset:(const WCDB::Expression &)offset\n{\n    return [_database getColumnFromStatement:WCDB::StatementSelect().select(resultColumn).from(_tableName).where(condition).orders(orders).limit(limit).offset(offset)];\n}\n\n#pragma mark - Get Rows\n- (WCTColumnsXRows *)getRowsOnResultColumns:(const WCDB::ResultColumns &)resultColumns\n{\n    return [_database getRowsFromStatement:WCDB::StatementSelect().select(resultColumns).from(_tableName).order(WCDB::OrderingTerm::ascendingRowid())];\n}\n\n- (WCTColumnsXRows *)getRowsOnResultColumns:(const WCDB::ResultColumns &)resultColumns\n                                      where:(const WCDB::Expression &)condition\n{\n    return [_database getRowsFromStatement:WCDB::StatementSelect().select(resultColumns).from(_tableName).where(condition).order(WCDB::OrderingTerm::ascendingRowid())];\n}\n\n- (WCTColumnsXRows *)getRowsOnResultColumns:(const WCDB::ResultColumns &)resultColumns\n                                     orders:(const WCDB::OrderingTerms &)orders\n{\n    return [_database getRowsFromStatement:WCDB::StatementSelect().select(resultColumns).from(_tableName).orders(orders)];\n}\n\n- (WCTColumnsXRows *)getRowsOnResultColumns:(const WCDB::ResultColumns &)resultColumns\n                                      limit:(const WCDB::Expression &)limit\n{\n    return [_database getRowsFromStatement:WCDB::StatementSelect().select(resultColumns).from(_tableName).order(WCDB::OrderingTerm::ascendingRowid()).limit(limit)];\n}\n\n- (WCTColumnsXRows *)getRowsOnResultColumns:(const WCDB::ResultColumns &)resultColumns\n                                      where:(const WCDB::Expression &)condition\n                                     orders:(const WCDB::OrderingTerms &)orders\n{\n    return [_database getRowsFromStatement:WCDB::StatementSelect().select(resultColumns).from(_tableName).where(condition).orders(orders)];\n}\n\n- (WCTColumnsXRows *)getRowsOnResultColumns:(const WCDB::ResultColumns &)resultColumns\n                                      where:(const WCDB::Expression &)condition\n                                      limit:(const WCDB::Expression &)limit\n{\n    return [_database getRowsFromStatement:WCDB::StatementSelect().select(resultColumns).from(_tableName).where(condition).order(WCDB::OrderingTerm::ascendingRowid()).limit(limit)];\n}\n\n- (WCTColumnsXRows *)getRowsOnResultColumns:(const WCDB::ResultColumns &)resultColumns\n                                     orders:(const WCDB::OrderingTerms &)orders\n                                      limit:(const WCDB::Expression &)limit\n{\n    return [_database getRowsFromStatement:WCDB::StatementSelect().select(resultColumns).from(_tableName).orders(orders).limit(limit)];\n}\n\n- (WCTColumnsXRows *)getRowsOnResultColumns:(const WCDB::ResultColumns &)resultColumns\n                                      limit:(const WCDB::Expression &)limit\n                                     offset:(const WCDB::Expression &)offset\n{\n    return [_database getRowsFromStatement:WCDB::StatementSelect().select(resultColumns).from(_tableName).order(WCDB::OrderingTerm::ascendingRowid()).limit(limit).offset(offset)];\n}\n\n- (WCTColumnsXRows *)getRowsOnResultColumns:(const WCDB::ResultColumns &)resultColumns\n                                      where:(const WCDB::Expression &)condition\n                                     orders:(const WCDB::OrderingTerms &)orders\n                                      limit:(const WCDB::Expression &)limit\n{\n    return [_database getRowsFromStatement:WCDB::StatementSelect().select(resultColumns).from(_tableName).where(condition).orders(orders).limit(limit)];\n}\n\n- (WCTColumnsXRows *)getRowsOnResultColumns:(const WCDB::ResultColumns &)resultColumns\n                                     orders:(const WCDB::OrderingTerms &)orders\n                                      limit:(const WCDB::Expression &)limit\n                                     offset:(const WCDB::Expression &)offset\n{\n    return [_database getRowsFromStatement:WCDB::StatementSelect().select(resultColumns).from(_tableName).orders(orders).limit(limit).offset(offset)];\n}\n\n- (WCTColumnsXRows *)getRowsOnResultColumns:(const WCDB::ResultColumns &)resultColumns\n                                      where:(const WCDB::Expression &)condition\n                                      limit:(const WCDB::Expression &)limit\n                                     offset:(const WCDB::Expression &)offset\n{\n    return [_database getRowsFromStatement:WCDB::StatementSelect().select(resultColumns).from(_tableName).where(condition).order(WCDB::OrderingTerm::ascendingRowid()).limit(limit).offset(offset)];\n}\n\n- (WCTColumnsXRows *)getRowsOnResultColumns:(const WCDB::ResultColumns &)resultColumns\n                                      where:(const WCDB::Expression &)condition\n                                     orders:(const WCDB::OrderingTerms &)orders\n                                      limit:(const WCDB::Expression &)limit\n                                     offset:(const WCDB::Expression &)offset\n{\n    return [_database getRowsFromStatement:WCDB::StatementSelect().select(resultColumns).from(_tableName).where(condition).orders(orders).limit(limit).offset(offset)];\n}\n\n@end\n"
  },
  {
    "path": "src/objc/core/WCTCommon.h",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"WCTConvertible.h\"\n#import \"WCTDeclaration.h\"\n#import \"WCTValue.h\"\n#import \"WINQ.h\"\n#import <Foundation/Foundation.h>\n"
  },
  {
    "path": "src/objc/core/WCTConvertible.h",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"WINQ.h\"\n#import <Foundation/Foundation.h>\n\nclass WCTProperty;\n\nnamespace WCDB {\n\n//NSObject Subclass\ntemplate<typename T, typename Enable = void>\nstruct IsObjCType : std::false_type {\n};\n\ntemplate<typename T>\nstruct IsObjCType<\nT,\ntypename std::enable_if<std::is_convertible<NSObject *, T>::value && std::is_pointer<T>::value>::type> : std::true_type {\n};\n\ntemplate<>\nstruct WCDB_API ColumnIsTextType<NSString *> : public std::true_type {\npublic:\n    static ColumnTypeInfo<ColumnType::Text>::UnderlyingType\n    asUnderlyingType(NSString *text);\n};\n\ntemplate<>\nstruct WCDB_API ColumnIsTextType<NSMutableString *> : public std::true_type {\npublic:\n    static ColumnTypeInfo<ColumnType::Text>::UnderlyingType\n    asUnderlyingType(NSMutableString *text);\n};\n\ntemplate<>\nclass WCDB_API LiteralValueConvertible<NSString *> final : public std::true_type {\npublic:\n    static LiteralValue asLiteralValue(NSString *string);\n};\n\ntemplate<>\nclass WCDB_API LiteralValueConvertible<NSMutableString *> final : public std::true_type {\npublic:\n    static LiteralValue asLiteralValue(NSMutableString *string);\n};\n\ntemplate<>\nclass WCDB_API LiteralValueConvertible<NSNumber *> final : public std::true_type {\npublic:\n    static LiteralValue asLiteralValue(NSNumber *number);\n};\n\ntemplate<>\nclass WCDB_API LiteralValueConvertible<NSDate *> final : public std::true_type {\npublic:\n    static LiteralValue asLiteralValue(NSDate *date);\n};\n\n#if OBJC_BOOL_IS_CHAR\ntemplate<>\nclass WCDB_API LiteralValueConvertible<BOOL> final : public std::true_type {\npublic:\n    static LiteralValue asLiteralValue(BOOL value);\n};\n#endif // OBJC_BOOL_IS_CHAR\n\ntemplate<>\nstruct WCDB_API ColumnIsBLOBType<NSData *> : public std::true_type {\npublic:\n    static ColumnTypeInfo<ColumnType::BLOB>::UnderlyingType\n    asUnderlyingType(NSData *data);\n};\n\ntemplate<>\nstruct WCDB_API ColumnIsBLOBType<NSMutableData *> : public std::true_type {\npublic:\n    static ColumnTypeInfo<ColumnType::BLOB>::UnderlyingType\n    asUnderlyingType(NSMutableData *data);\n};\n\ntemplate<>\nclass WCDB_API ExpressionConvertible<WCTProperty> final : public std::true_type {\npublic:\n    static Expression asExpression(const WCTProperty &property);\n};\n\ntemplate<>\nclass WCDB_API IndexedColumnConvertible<WCTProperty> final : public std::true_type {\npublic:\n    static IndexedColumn asIndexedColumn(const WCTProperty &property);\n};\n\n#define WCDB_DEFINE_EXPRESSIONS_CONVERTIBLE(Type)                                       \\\n    template<>                                                                          \\\n    template<>                                                                          \\\n    struct WCDB_API _SyntaxList<Expression>::Convertible<Type> final : std::true_type { \\\n        static Expressions asSyntaxList(const Type);                                    \\\n    };\n\nWCDB_DEFINE_EXPRESSIONS_CONVERTIBLE(NSArray *)\nWCDB_DEFINE_EXPRESSIONS_CONVERTIBLE(NSArray<NSString *> *)\nWCDB_DEFINE_EXPRESSIONS_CONVERTIBLE(NSArray<NSMutableString *> *)\nWCDB_DEFINE_EXPRESSIONS_CONVERTIBLE(NSArray<NSNumber *> *)\nWCDB_DEFINE_EXPRESSIONS_CONVERTIBLE(NSMutableArray *)\nWCDB_DEFINE_EXPRESSIONS_CONVERTIBLE(NSMutableArray<NSString *> *)\nWCDB_DEFINE_EXPRESSIONS_CONVERTIBLE(NSMutableArray<NSMutableString *> *)\nWCDB_DEFINE_EXPRESSIONS_CONVERTIBLE(NSMutableArray<NSNumber *> *)\n\nWCDB_DEFINE_EXPRESSIONS_CONVERTIBLE(NSSet *)\nWCDB_DEFINE_EXPRESSIONS_CONVERTIBLE(NSSet<NSString *> *)\nWCDB_DEFINE_EXPRESSIONS_CONVERTIBLE(NSSet<NSMutableString *> *)\nWCDB_DEFINE_EXPRESSIONS_CONVERTIBLE(NSSet<NSNumber *> *)\nWCDB_DEFINE_EXPRESSIONS_CONVERTIBLE(NSMutableSet *)\nWCDB_DEFINE_EXPRESSIONS_CONVERTIBLE(NSMutableSet<NSString *> *)\nWCDB_DEFINE_EXPRESSIONS_CONVERTIBLE(NSMutableSet<NSMutableString *> *)\nWCDB_DEFINE_EXPRESSIONS_CONVERTIBLE(NSMutableSet<NSNumber *> *)\n\ntemplate<typename T>\nstruct remove_ownership {\n    typedef T type;\n};\n#if __has_feature(objc_arc)\ntemplate<typename T>\nstruct remove_ownership<__unsafe_unretained T> {\n    typedef T type;\n};\ntemplate<typename T>\nstruct remove_ownership<__strong T> {\n    typedef T type;\n};\ntemplate<typename T>\nstruct remove_ownership<__weak T> {\n    typedef T type;\n};\n#endif\ntemplate<typename T>\nusing remove_ownership_t = typename remove_ownership<T>::type;\n\n} //namespace WCDB\n"
  },
  {
    "path": "src/objc/core/WCTConvertible.mm",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"WCTConvertible.h\"\n#import \"Assertion.hpp\"\n\nnamespace WCDB {\n\nColumnTypeInfo<ColumnType::Text>::UnderlyingType\nColumnIsTextType<NSString*>::asUnderlyingType(NSString* text)\n{\n    return UnsafeStringView(text.UTF8String, [text lengthOfBytesUsingEncoding:NSUTF8StringEncoding]);\n}\n\nColumnTypeInfo<ColumnType::Text>::UnderlyingType\nColumnIsTextType<NSMutableString*>::asUnderlyingType(NSMutableString* text)\n{\n    return UnsafeStringView(text.UTF8String, [text lengthOfBytesUsingEncoding:NSUTF8StringEncoding]);\n}\n\nColumnTypeInfo<ColumnType::BLOB>::UnderlyingType\nColumnIsBLOBType<NSData*>::asUnderlyingType(NSData* data)\n{\n    return UnsafeData((unsigned char*) data.bytes, (size_t) data.length);\n}\n\nColumnTypeInfo<ColumnType::BLOB>::UnderlyingType\nColumnIsBLOBType<NSMutableData*>::asUnderlyingType(NSMutableData* data)\n{\n    return UnsafeData((unsigned char*) data.bytes, (size_t) data.length);\n}\n\nExpression ExpressionConvertible<WCTProperty>::asExpression(const WCTProperty& property)\n{\n    return Expression((const Column&) property);\n}\n\nIndexedColumn IndexedColumnConvertible<WCTProperty>::asIndexedColumn(const WCTProperty& property)\n{\n    return Expression((const Column&) property);\n}\n\nLiteralValue LiteralValueConvertible<NSString*>::asLiteralValue(NSString* string)\n{\n    if (string == nil) {\n        return LiteralValue(nullptr);\n    }\n    return UnsafeStringView(string.UTF8String, [string lengthOfBytesUsingEncoding:NSUTF8StringEncoding]);\n}\n\nLiteralValue LiteralValueConvertible<NSMutableString*>::asLiteralValue(NSMutableString* string)\n{\n    if (string == nil) {\n        return LiteralValue(nullptr);\n    }\n    return UnsafeStringView(string.UTF8String, [string lengthOfBytesUsingEncoding:NSUTF8StringEncoding]);\n}\n\nLiteralValue LiteralValueConvertible<NSNumber*>::asLiteralValue(NSNumber* number)\n{\n    if (number == nil) {\n        return LiteralValue(nullptr);\n    }\n    if (number == nil || CFNumberIsFloatType((CFNumberRef) number)) {\n        return (double) number.doubleValue;\n    } else if (strcmp(number.objCType, \"Q\") == 0) {\n        // unsigned long long\n        return (uint64_t) number.unsignedLongLongValue;\n    }\n    return (int64_t) number.integerValue;\n}\n\nLiteralValue LiteralValueConvertible<NSDate*>::asLiteralValue(NSDate* date)\n{\n    if (date == nil) {\n        return LiteralValue(nullptr);\n    }\n    return [date timeIntervalSince1970];\n}\n\n#if OBJC_BOOL_IS_CHAR\nLiteralValue LiteralValueConvertible<BOOL>::asLiteralValue(BOOL value)\n{\n    return LiteralValue((bool) value);\n}\n#endif // OBJC_BOOL_IS_CHAR\n\nExpressions _SyntaxList<Expression>::Convertible<NSArray*>::asSyntaxList(const NSArray* values)\n{\n    Expressions result;\n    for (id value in values) {\n        if ([value isKindOfClass:NSString.class]) {\n            NSString* stringValue = (NSString*) value;\n            result.push_back(stringValue);\n        } else if ([value isKindOfClass:NSNumber.class]) {\n            NSNumber* number = (NSNumber*) value;\n            result.push_back(number);\n        } else {\n            NSCAssert(false, @\"Only supports converting NSNumber and NSString in array into expressions\");\n        }\n    }\n    return result;\n}\n\n#define WCDB_IMPLEMENT_EXPRESSIONS_CONVERTIBLE_OF_ARRAY(Type)                               \\\n    Expressions _SyntaxList<Expression>::Convertible<Type>::asSyntaxList(const Type values) \\\n    {                                                                                       \\\n        return _SyntaxList<Expression>::Convertible<NSArray*>::asSyntaxList(values);        \\\n    }\n\nWCDB_IMPLEMENT_EXPRESSIONS_CONVERTIBLE_OF_ARRAY(NSArray<NSString*>*)\nWCDB_IMPLEMENT_EXPRESSIONS_CONVERTIBLE_OF_ARRAY(NSArray<NSMutableString*>*)\nWCDB_IMPLEMENT_EXPRESSIONS_CONVERTIBLE_OF_ARRAY(NSArray<NSNumber*>*)\nWCDB_IMPLEMENT_EXPRESSIONS_CONVERTIBLE_OF_ARRAY(NSMutableArray*)\nWCDB_IMPLEMENT_EXPRESSIONS_CONVERTIBLE_OF_ARRAY(NSMutableArray<NSString*>*)\nWCDB_IMPLEMENT_EXPRESSIONS_CONVERTIBLE_OF_ARRAY(NSMutableArray<NSMutableString*>*)\nWCDB_IMPLEMENT_EXPRESSIONS_CONVERTIBLE_OF_ARRAY(NSMutableArray<NSNumber*>*)\n\nExpressions _SyntaxList<Expression>::Convertible<NSSet*>::asSyntaxList(const NSSet* values)\n{\n    Expressions result;\n    for (id value in values) {\n        if ([value isKindOfClass:NSString.class]) {\n            NSString* stringValue = (NSString*) value;\n            result.push_back(stringValue);\n        } else if ([value isKindOfClass:NSNumber.class]) {\n            NSNumber* number = (NSNumber*) value;\n            result.push_back(number);\n        } else {\n            NSCAssert(false, @\"Only supports converting NSNumber and NSString in set into expressions\");\n        }\n    }\n    return result;\n}\n\n#define WCDB_IMPLEMENT_EXPRESSIONS_CONVERTIBLE_OF_Set(Type)                                 \\\n    Expressions _SyntaxList<Expression>::Convertible<Type>::asSyntaxList(const Type values) \\\n    {                                                                                       \\\n        return _SyntaxList<Expression>::Convertible<NSSet*>::asSyntaxList(values);          \\\n    }\n\nWCDB_IMPLEMENT_EXPRESSIONS_CONVERTIBLE_OF_Set(NSSet<NSString*>*)\nWCDB_IMPLEMENT_EXPRESSIONS_CONVERTIBLE_OF_Set(NSSet<NSMutableString*>*)\nWCDB_IMPLEMENT_EXPRESSIONS_CONVERTIBLE_OF_Set(NSSet<NSNumber*>*)\nWCDB_IMPLEMENT_EXPRESSIONS_CONVERTIBLE_OF_Set(NSMutableSet*)\nWCDB_IMPLEMENT_EXPRESSIONS_CONVERTIBLE_OF_Set(NSMutableSet<NSString*>*)\nWCDB_IMPLEMENT_EXPRESSIONS_CONVERTIBLE_OF_Set(NSMutableSet<NSMutableString*>*)\nWCDB_IMPLEMENT_EXPRESSIONS_CONVERTIBLE_OF_Set(NSMutableSet<NSNumber*>*)\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/objc/core/WCTDatabase+Test.h",
    "content": "//\n// Created by sanhuazhang on 2019/06/03\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"WCDBObjc.h\"\n\ntypedef NS_OPTIONS(NSUInteger, WCTSimulateIOErrorOptions) {\n    WCTSimulateNoneIOError = 0,\n    WCTSimulateReadIOError = 1 << 0,\n    WCTSimulateWriteIOError = 1 << 1,\n};\n\nNS_ASSUME_NONNULL_BEGIN\n\nWCDB_API @interface WCTDatabase(Test)\n\n// Only for test\n+ (void)simulateIOError:(WCTSimulateIOErrorOptions)options;\n\n// Only for test\n- (void)enableAutoCheckpoint:(BOOL)flag;\n\n/**\n @brief Checkpoint the current database with truncate mode.\n */\n- (BOOL)truncateCheckpoint;\n\n/**\n @brief Checkpoint the current database with passive mode.\n */\n- (BOOL)passiveCheckpoint;\n\n/**\n @brief Check database is already opened.\n @return isOpened\n */\n- (BOOL)isOpened;\n\n/**\n @brief Since WCDB is using lazy initialization, [initWithPath:] never return nil even the database can't open. So you can call this to check whether the database can be opened.\n @return NO if an error occurs during sqlite db handle initialization.\n */\n- (BOOL)canOpen;\n\n/**\n @brief This interface is equivalent to -[WCTDatabase close:nil].\n @see `-[WCTDatabase close:]`\n */\n- (void)close;\n\n/**\n @brief Check whether database is blockaded.\n @see `-[WCTDatabase close:]`\n @return isBlockaded\n */\n- (BOOL)isBlockaded;\n\n/**\n @brief Blockade the database.\n @see `-[WCTDatabase close:]`\n */\n- (void)blockade;\n\n/**\n @brief Unblockade the database.\n @see `-[WCTDatabase close:]`\n */\n- (void)unblockade;\n\n@end\n\nNS_ASSUME_NONNULL_END\n"
  },
  {
    "path": "src/objc/core/WCTDatabase+Test.mm",
    "content": "//\n// Created by sanhuazhang on 2019/06/03\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"CommonCore.hpp\"\n#import \"CoreConst.h\"\n#import \"FileHandle.hpp\"\n#import \"Notifier.hpp\"\n#import \"SQLite.h\"\n#import \"WCTConvertible.h\"\n#import \"WCTDatabase+Convenient.h\"\n#import \"WCTDatabase+Private.h\"\n#import \"WCTDatabase+Test.h\"\n#include <iomanip>\n\nstatic std::atomic<WCTSimulateIOErrorOptions> &simulateIOErrorOptions()\n{\n    static std::atomic<WCTSimulateIOErrorOptions> *s_simulateIOErrorOptions = new std::atomic<WCTSimulateIOErrorOptions>(WCTSimulateNoneIOError);\n    return *s_simulateIOErrorOptions;\n}\n\nstatic ssize_t controllableWrite(int fd, const void *buf, size_t byte, off_t offset)\n{\n    if ((simulateIOErrorOptions().load() & WCTSimulateWriteIOError) != 0) {\n        return -1;\n    }\n    return pwrite(fd, buf, byte, offset);\n}\n\nstatic ssize_t controllableRead(int fd, void *buf, size_t byte, off_t offset)\n{\n    if ((simulateIOErrorOptions().load() & WCTSimulateReadIOError) != 0) {\n        return -1;\n    }\n    return pread(fd, buf, byte, offset);\n}\n\nstatic std::nullptr_t initialize()\n{\n    sqlite3_vfs *vfs = sqlite3_vfs_find(nullptr);\n    vfs->xSetSystemCall(vfs, \"pwrite\", (sqlite3_syscall_ptr) controllableWrite);\n    vfs->xSetSystemCall(vfs, \"pread\", (sqlite3_syscall_ptr) controllableRead);\n    return nullptr;\n}\n\n@implementation WCTDatabase (Test)\n\n+ (void)simulateIOError:(WCTSimulateIOErrorOptions)options\n{\n    WCDB_ONCE(initialize());\n\n    simulateIOErrorOptions().store(options);\n}\n\n- (void)enableAutoCheckpoint:(BOOL)flag\n{\n    WCDB::CommonCore::shared().enableAutoCheckpoint(_database, flag);\n}\n\n- (BOOL)truncateCheckpoint\n{\n    return _database->checkpoint(false, WCDB::InnerDatabase::CheckPointMode::Truncate);\n}\n\n- (BOOL)passiveCheckpoint\n{\n    return _database->checkpoint(false, WCDB::InnerDatabase::CheckPointMode::Passive);\n}\n\n- (BOOL)isOpened\n{\n    return _database->isOpened();\n}\n\n- (BOOL)canOpen\n{\n    return _database->canOpen();\n}\n\n- (void)close\n{\n    _database->close(nullptr);\n}\n\n- (BOOL)isBlockaded\n{\n    return _database->isBlockaded();\n}\n\n- (void)blockade\n{\n    _database->blockade();\n}\n\n- (void)unblockade\n{\n    _database->unblockade();\n}\n\n@end\n"
  },
  {
    "path": "src/objc/core/WCTDatabase+Version.h",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"WCTDatabase.h\"\n\nNS_ASSUME_NONNULL_BEGIN\n\nWCDB_API @interface WCTDatabase(Version)\n\n/**\n Version of WCDB.\n */\n@property (class, readonly, nonatomic) NSString *version;\n\n/**\n Source id of WCDB. It varies from each build of WCDB.\n */\n@property (class, readonly, nonatomic) NSString *sourceId;\n\n@end\n\nNS_ASSUME_NONNULL_END\n"
  },
  {
    "path": "src/objc/core/WCTDatabase+Version.mm",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"Macro.h\"\n#import \"WCDBVersion.h\"\n#import \"WCTDatabase+Version.h\"\n\n@implementation WCTDatabase (Version)\n\n+ (NSString *)version\n{\n    return @WCDB_VERSION_STRING;\n}\n\n+ (NSString *)sourceId\n{\n    return @WCDB_SOURCE_ID;\n}\n\n@end\n"
  },
  {
    "path": "src/objc/core/WCTDeclaration.h",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import <Foundation/Foundation.h>\n\n#ifdef __cplusplus\n\n#import \"WCTOptional.h\"\n#import \"WCTTag.h\"\n#import \"WINQ.h\"\n\n#endif // __cplusplus\n\n#pragma mark - Chain Call\n@class WCTInsert;\n@class WCTDelete;\n@class WCTUpdate;\n@class WCTSelectable;\n@class WCTSelect;\n@class WCTMultiSelect;\n\n#pragma mark - Database\n@class WCTDatabase;\n\n#pragma mark - Table\n@class WCTTable;\n\n#pragma mark - Handle\n@class WCTHandle;\n\n#pragma mark - Statement\n@class WCTPreparedStatement;\n\n#pragma mark - ORM\n\n#ifdef __cplusplus\n\nclass WCTBinding;\nclass WCTColumnBinding;\n\n#endif // __cplusplus\n\n@protocol WCTTableCoding;\n@protocol WCTColumnCoding;\n\n#ifdef __cplusplus\n\n#pragma mark - WINQ\nclass WCTProperty;\ntypedef WCDB::SyntaxList<WCTProperty> WCTProperties;\nclass WCTResultColumn;\ntypedef WCDB::SyntaxList<WCTResultColumn> WCTResultColumns;\n\nusing WCTOrder = WCDB::Order;\nstatic constexpr const WCDB::Order WCTOrderedAscending = WCDB::Order::ASC;\nstatic constexpr const WCDB::Order WCTOrderedDescending = WCDB::Order::DESC;\n\n#endif // __cplusplus\n\ntypedef NS_ENUM(NSUInteger, WCTColumnType) {\n    WCTColumnTypeNull = 0,\n    WCTColumnTypeInteger,\n    WCTColumnTypeFloat,\n    WCTColumnTypeString,\n    WCTColumnTypeData,\n};\n\n#ifdef __cplusplus\nstatic_assert((NSUInteger) WCDB::ColumnType::Null == (NSUInteger) WCTColumnTypeNull, \"\");\nstatic_assert((NSUInteger) WCDB::ColumnType::Integer == (NSUInteger) WCTColumnTypeInteger, \"\");\nstatic_assert((NSUInteger) WCDB::ColumnType::Float == (NSUInteger) WCTColumnTypeFloat, \"\");\nstatic_assert((NSUInteger) WCDB::ColumnType::Text == (NSUInteger) WCTColumnTypeString, \"\");\nstatic_assert((NSUInteger) WCDB::ColumnType::BLOB == (NSUInteger) WCTColumnTypeData, \"\");\n#endif // __cplusplus\n\n#pragma mark - Object\ntypedef NSObject<WCTTableCoding> WCTObject;\ntypedef NSDictionary<NSString * /*table name */, WCTObject *> WCTMultiObject;\n\ntypedef NSObject<WCTColumnCoding> WCTColumnCodingValue;\ntypedef NSArray<NSObject<WCTColumnCoding> *> WCTColumnCodingRow;\n\n#pragma mark - Error\n@class WCTError;\n\n#ifdef __cplusplus\n\nclass WCTOptionalBool;\nclass WCTOptionalSize;\n\n#endif // __cplusplus\n\n#pragma mark - Migration\n@class WCTMigrationBaseInfo;\n@class WCTMigrationUserInfo;\n"
  },
  {
    "path": "src/objc/core/WCTFTSTokenizerUtil.h",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"BaseTokenizerUtil.hpp\"\n#import <Foundation/Foundation.h>\n\nclass WCDB_API WCTFTSTokenizerUtil final : public WCDB::BaseTokenizerUtil {\npublic:\n    //Parameters should end with nullptr\n    static WCDB::StringView tokenize(NSString* name, ...);\n\n    static void configDefaultSymbolDetectorAndUnicodeNormalizer();\n\n    static void configPinyinDict(NSDictionary<NSString*, NSArray<NSString*>*>* pinyinDict);\n    static void configTraditionalChineseDict(NSDictionary<NSString*, NSString*>* traditionalChineseDict);\n};\n"
  },
  {
    "path": "src/objc/core/WCTFTSTokenizerUtil.mm",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"WCTFTSTokenizerUtil.h\"\n#import \"WCTCommon.h\"\n#import <CoreFoundation/CoreFoundation.h>\n#import <Foundation/Foundation.h>\n\nWCDB::StringView WCTFTSTokenizerUtil::tokenize(NSString* name, ...)\n{\n    WCDB::StringView tokenizerPrefix = WCDB::Syntax::CreateVirtualTableSTMT::tokenizerPreFix();\n    std::ostringstream stream;\n    stream << tokenizerPrefix.data() << name.UTF8String;\n    va_list pArgs;\n    va_start(pArgs, name);\n    NSString* parameter = nullptr;\n    while ((parameter = va_arg(pArgs, NSString*)) != nullptr) {\n        stream << ' ' << parameter.UTF8String;\n    }\n    return WCDB::StringView(stream.str());\n}\n\nvoid WCTFTSTokenizerUtil::configDefaultSymbolDetectorAndUnicodeNormalizer()\n{\n    static dispatch_once_t onceToken;\n    dispatch_once(&onceToken, ^{\n        //Refer to http://www.fileformat.info/info/unicode/category/index.htm\n        //Code: Cc, Cf, Z*, U000A ~ U000D, U0085, M*, P*, S* and illegal character set\n        CFMutableCharacterSetRef characterSetRef = CFCharacterSetCreateMutable(CFAllocatorGetDefault());\n        CFCharacterSetUnion(characterSetRef, CFCharacterSetGetPredefined(kCFCharacterSetControl));\n        CFCharacterSetUnion(characterSetRef, CFCharacterSetGetPredefined(kCFCharacterSetWhitespaceAndNewline));\n        CFCharacterSetUnion(characterSetRef, CFCharacterSetGetPredefined(kCFCharacterSetNonBase));\n        CFCharacterSetUnion(characterSetRef, CFCharacterSetGetPredefined(kCFCharacterSetPunctuation));\n        CFCharacterSetUnion(characterSetRef, CFCharacterSetGetPredefined(kCFCharacterSetSymbol));\n        CFCharacterSetUnion(characterSetRef, CFCharacterSetGetPredefined(kCFCharacterSetIllegal));\n        configSymbolDetector([=](UnicodeChar theChar) {\n            bool symbol = false;\n            if (characterSetRef != nil) {\n                symbol = CFCharacterSetIsCharacterMember(characterSetRef, theChar);\n            }\n            return symbol;\n        });\n        configUnicodeNormalizer([](const WCDB::UnsafeStringView& token) {\n            @autoreleasepool {\n                NSMutableString* nsToken = [[NSMutableString alloc] initWithBytes:token.data() length:token.length() encoding:NSUTF8StringEncoding];\n                CFMutableStringRef normalizationFormText = (__bridge_retained CFMutableStringRef)(nsToken);\n                CFStringNormalize(normalizationFormText, kCFStringNormalizationFormKD);\n                return WCDB::StringView(((__bridge_transfer NSString*) normalizationFormText).UTF8String);\n            }\n        });\n    });\n}\n\nvoid WCTFTSTokenizerUtil::configPinyinDict(NSDictionary<NSString*, NSArray<NSString*>*>* pinyinDict)\n{\n    WCDB::StringViewMap<std::vector<WCDB::StringView>>* cppPinyinDict = new WCDB::StringViewMap<std::vector<WCDB::StringView>>();\n    for (NSString* character in pinyinDict.allKeys) {\n        if (character.UTF8String == nil) {\n            continue;\n        }\n        WCDB::StringView key = WCDB::StringView(character.UTF8String);\n        std::vector<WCDB::StringView> value;\n        for (NSString* piniyn in pinyinDict[character]) {\n            if (piniyn.UTF8String == nil) {\n                continue;\n            }\n            value.push_back(WCDB::StringView(piniyn.UTF8String));\n        }\n        if (value.size() > 0) {\n            cppPinyinDict->insert_or_assign(key, value);\n        }\n    }\n    WCDB::BaseTokenizerUtil::configPinyinDict(cppPinyinDict);\n}\n\nvoid WCTFTSTokenizerUtil::configTraditionalChineseDict(NSDictionary<NSString*, NSString*>* traditionalChineseDict)\n{\n    WCDB::StringViewMap<WCDB::StringView>* cppTraditionalChineseDict = new WCDB::StringViewMap<WCDB::StringView>();\n    for (NSString* chinese in traditionalChineseDict.allKeys) {\n        NSString* simplifiedChinese = traditionalChineseDict[chinese];\n        if (chinese.UTF8String == nil || simplifiedChinese.UTF8String == nil) {\n            continue;\n        }\n        cppTraditionalChineseDict->insert_or_assign(WCDB::StringView(chinese.UTF8String), WCDB::StringView(simplifiedChinese.UTF8String));\n    }\n    WCDB::BaseTokenizerUtil::configTraditionalChineseDict(cppTraditionalChineseDict);\n}\n"
  },
  {
    "path": "src/objc/core/WCTFileManager.mm",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"CoreConst.h\"\n#import \"Enum.hpp\"\n#import \"FileManager.hpp\"\n#import \"Notifier.hpp\"\n#import \"StringView.hpp\"\n#import \"ThreadedErrors.hpp\"\n#import \"WCDBError.hpp\"\n#import \"WCTFoundation.h\"\n#import <Foundation/Foundation.h>\n\nnamespace WCDB {\n\nStringView FileManager::getTemporaryDirectory()\n{\n    NSString *temDir = [NSTemporaryDirectory() stringByAppendingPathComponent:@\"WCDBTrash\"];\n    return StringView(temDir.UTF8String);\n}\n\n#if TARGET_OS_IPHONE\ntemplate<>\nconstexpr const char *Enum::description(const FileProtection &fileProtection)\n{\n    switch (fileProtection) {\n    case FileProtection::None:\n        return NSFileProtectionNone.UTF8String;\n    case FileProtection::Complete:\n        return NSFileProtectionComplete.UTF8String;\n    case FileProtection::CompleteUnlessOpen:\n        return NSFileProtectionCompleteUnlessOpen.UTF8String;\n    case FileProtection::CompleteUntilFirstUserAuthentication:\n        return NSFileProtectionCompleteUntilFirstUserAuthentication.UTF8String;\n    }\n}\n\nstatic FileProtection fileProtectionForAttribute(NSString *fileAttributeProtection)\n{\n    if ([fileAttributeProtection isEqualToString:NSFileProtectionComplete]) {\n        return FileProtection::Complete;\n    } else if ([fileAttributeProtection isEqualToString:NSFileProtectionCompleteUnlessOpen]) {\n        return FileProtection::CompleteUnlessOpen;\n    } else if ([fileAttributeProtection isEqualToString:NSFileProtectionCompleteUntilFirstUserAuthentication]) {\n        return FileProtection::CompleteUntilFirstUserAuthentication;\n    }\n    return FileProtection::None;\n}\n\nbool FileManager::setFileProtection(const UnsafeStringView &path, FileProtection fileProtection)\n{\n    NSError *nsError = nil;\n    NSFileManager *fileManager = [NSFileManager defaultManager];\n    NSString *nsPath = [NSString stringWithView:path];\n    if ([fileManager setAttributes:@{NSFileProtectionKey : @(Enum::description(fileProtection))}\n                      ofItemAtPath:nsPath\n                             error:&nsError]) {\n        return true;\n    }\n    Error error(Error::Code::IOError, Error::Level::Error, nsError.description.UTF8String);\n    error.infos.insert_or_assign(ErrorStringKeySource, ErrorSourceNative);\n    error.infos.insert_or_assign(ErrorStringKeyAssociatePath, path);\n    error.infos.insert_or_assign(ErrorIntKeyExtCode, nsError.code);\n    Notifier::shared().notify(error);\n    ThreadedErrors::shared().setThreadedError(std::move(error));\n    return false;\n}\n\nOptional<FileProtection> FileManager::getFileProtection(const UnsafeStringView &path)\n{\n    NSError *nsError = nil;\n    NSFileManager *fileManager = [NSFileManager defaultManager];\n    NSString *nsPath = [NSString stringWithView:path];\n    NSDictionary *attributes = [fileManager attributesOfItemAtPath:nsPath error:&nsError];\n    if (attributes != nil) {\n        return fileProtectionForAttribute(attributes[NSFileProtectionKey]);\n    }\n    Error error(Error::Code::IOError, Error::Level::Error, nsError.description.UTF8String);\n    error.infos.insert_or_assign(ErrorStringKeySource, ErrorSourceNative);\n    error.infos.insert_or_assign(ErrorStringKeyAssociatePath, path);\n    error.infos.insert_or_assign(ErrorIntKeyExtCode, nsError.code);\n    Notifier::shared().notify(error);\n    ThreadedErrors::shared().setThreadedError(std::move(error));\n    return WCDB::NullOpt;\n}\n\n#else\nbool FileManager::setFileProtection(const UnsafeStringView &path, FileProtection fileProtection)\n{\n    WCDB_UNUSED(path);\n    WCDB_UNUSED(fileProtection);\n    return true;\n}\n\nOptional<FileProtection> FileManager::getFileProtection(const UnsafeStringView &path)\n{\n    WCDB_UNUSED(path);\n    return FileProtection::None;\n}\n#endif\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/objc/core/WCTFoundation.h",
    "content": "//\n// Created by sanhuazhang on 2019/06/12\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"StringView.hpp\"\n#import <Foundation/Foundation.h>\n\nNS_ASSUME_NONNULL_BEGIN\n\n@interface NSString (WCDB)\n\n+ (NSString *)stringWithView:(const WCDB::UnsafeStringView &)string;\n- (NSString *)wcdb_stringByStandardizingPath;\n\n@end\n\nNS_ASSUME_NONNULL_END\n"
  },
  {
    "path": "src/objc/core/WCTFoundation.mm",
    "content": "//\n// Created by sanhuazhang on 2019/06/12\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"WCTFoundation.h\"\n\n@implementation NSString (WCDB)\n\n+ (NSString*)stringWithView:(const WCDB::UnsafeStringView&)string\n{\n    return [[NSString alloc] initWithBytes:string.data() length:string.length() encoding:NSUTF8StringEncoding];\n}\n\n- (NSString*)wcdb_stringByStandardizingPath\n{\n    NSString* path = [self stringByStandardizingPath];\n#ifdef __APPLE__\n    /*\n     /var is the symlink to /private/var.\n     In most cases, -[NSString stringByStandardizingPath] will return the path with the /var prefix,\n     while in a small number of cases it will return the path with the /private/var prefix.\n     In order to avoid the inconsistency of the path of the same file, remove the /private prefix of path here\n     */\n    NSRange match = [path rangeOfString:@\"/private\"];\n    if (match.location == 0) {\n        path = [path stringByReplacingCharactersInRange:match withString:@\"\"];\n    }\n#endif\n    return path;\n}\n\n@end\n"
  },
  {
    "path": "src/objc/core/WCTOperationQueue.mm",
    "content": "//\n// Created by sanhuazhang on 2019/05/27\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"OperationQueueForMemory.hpp\"\n#import <Foundation/Foundation.h>\n\n#if TARGET_OS_IPHONE && !TARGET_OS_WATCH && !TARGET_OS_TV\n#import <UIKit/UIKit.h>\n\nnamespace WCDB {\n\nvoid *OperationQueueForMemory::registerNotificationWhenMemoryWarning()\n{\n    id observer = [[NSNotificationCenter defaultCenter]\n    addObserverForName:UIApplicationDidReceiveMemoryWarningNotification\n                object:nil\n                 queue:nil\n            usingBlock:^(NSNotification *) {\n                this->asyncPurgeWhenMemoryWarning();\n            }];\n    return (void *) CFBridgingRetain(observer);\n}\n\nvoid OperationQueueForMemory::unregisterNotificationWhenMemoryWarning(void *observer)\n{\n    NSObject *nsObserver = (__bridge NSObject *) observer;\n    [[NSNotificationCenter defaultCenter] removeObserver:nsObserver name:UIApplicationDidReceiveMemoryWarningNotification object:nil];\n    CFBridgingRelease(observer);\n}\n\n} // namespace WCDB\n#else // TARGET_OS_IPHONE && !TARGET_OS_WATCH\n\nnamespace WCDB {\n\nvoid *OperationQueueForMemory::registerNotificationWhenMemoryWarning()\n{\n    return nullptr;\n}\n\nvoid OperationQueueForMemory::unregisterNotificationWhenMemoryWarning(void *)\n{\n}\n\n} // namespace WCDB\n\n#endif // TARGET_OS_IPHONE && !TARGET_OS_WATCH\n\nnamespace WCDB {\n\nvoid OperationQueueForMemory::executeOperationWithAutoMemoryRelease(std::function<void(void)> operation)\n{\n    @autoreleasepool {\n        operation();\n    }\n}\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/objc/core/WCTOptional.h",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"WCDBOptional.hpp\"\n#import \"WCTConvertible.h\"\n#import <Foundation/Foundation.h>\n#import <type_traits>\n\ntemplate<typename T>\nclass WCTIncompleteOptional {\npublic:\n    virtual ~WCTIncompleteOptional() = default;\n\n    operator const T&() const { return value(); }\n\n    const T& value() const\n    {\n        if (m_real.succeed()) {\n            return m_real.value();\n        }\n        return m_default;\n    }\n\n    BOOL succeed() const { return m_real.succeed(); }\n    BOOL failed() const { return !succeed(); }\n\n    WCTIncompleteOptional& operator=(const T& value)\n    {\n        m_real = value;\n        return *this;\n    }\n\nprotected:\n    WCTIncompleteOptional(const T& defaultValue)\n    : m_real(WCDB::NullOpt), m_default(defaultValue)\n    {\n    }\n\n    WCTIncompleteOptional(const T& value, const T& defaultValue)\n    : m_real(value), m_default(defaultValue)\n    {\n    }\n\n    WCTIncompleteOptional(WCDB::Optional<T>&& optional, const T& defaultValue)\n    : m_real(std::move(optional)), m_default(defaultValue)\n    {\n    }\n\nprivate:\n    WCDB::Optional<T> m_real;\n    T m_default;\n};\n\ntemplate<typename T, T defaultValue>\nclass WCTFundamentalOptional : public WCTIncompleteOptional<T> {\n    using Super = WCTIncompleteOptional<T>;\n    static_assert(std::is_fundamental<T>::value || std::is_enum<T>::value, \"\");\n\npublic:\n    WCTFundamentalOptional()\n    : Super(defaultValue) {}\n\n    WCTFundamentalOptional(const WCDB::NullOpt_T&)\n    : Super(defaultValue) {}\n\n    WCTFundamentalOptional(const T& value)\n    : Super(value, defaultValue) {}\n\n    ~WCTFundamentalOptional() override = default;\n\nprotected:\n    WCTFundamentalOptional(WCDB::Optional<T>&& optional)\n    : Super(std::move(optional), defaultValue)\n    {\n    }\n};\n\nclass WCDB_API WCTOptionalBool final : public WCTFundamentalOptional<BOOL, NO> {\n    using Super = WCTFundamentalOptional<BOOL, NO>;\n\npublic:\n    using Super::WCTFundamentalOptional;\n\n    WCTOptionalBool(WCDB::Optional<bool>&& optional);\n    ~WCTOptionalBool() override;\n};\n\nclass WCDB_API WCTOptionalSize final : public WCTFundamentalOptional<NSUInteger, 0> {\n    using Super = WCTFundamentalOptional<NSUInteger, 0>;\n\npublic:\n    using Super::WCTFundamentalOptional;\n    ~WCTOptionalSize() override;\n\n    WCTOptionalSize(WCDB::Optional<size_t>&& optional);\n};\n"
  },
  {
    "path": "src/objc/core/WCTOptional.mm",
    "content": "//\n// Created by sanhuazhang on 2019/06/25\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"WCTOptional.h\"\n\nWCTOptionalBool::WCTOptionalBool(WCDB::Optional<bool>&& optional)\n: Super(optional.succeed() ? WCDB::Optional<BOOL>((BOOL) optional.value()) :\n                             WCDB::Optional<BOOL>(WCDB::NullOpt))\n{\n}\n\nWCTOptionalBool::~WCTOptionalBool() = default;\n\nWCTOptionalSize::WCTOptionalSize(WCDB::Optional<size_t>&& optional)\n: Super(optional.succeed() ? WCDB::Optional<NSUInteger>((NSUInteger) optional.value()) :\n                             WCDB::Optional<NSUInteger>(WCDB::NullOpt))\n{\n}\n\nWCTOptionalSize::~WCTOptionalSize() = default;\n"
  },
  {
    "path": "src/objc/core/WCTTag.h",
    "content": "//\n// Created by sanhuazhang on 2019/9/25.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import <stdint.h>\n\ntypedef long WCTTag;\nstatic WCTTag const WCTInvalidTag = 0;\n"
  },
  {
    "path": "src/objc/core/WCTValue.h",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"Macro.h\"\n#import \"WCTDeclaration.h\"\n\n//It's tricky here. You can use `WCTValue` as any of `NSNumber`/`NSString`/`NSData`/`NSNull`, but it actually is a `NSProxy<WCTValueProtocol>` proxy.\n//Ones have no need to understand this difference unless he/she needs to go deep into these fundamental classes.\n\nNS_ASSUME_NONNULL_BEGIN\n\n@protocol WCTValueProtocol\n\n- (nullable NSString *)stringValue;\n\n- (nullable NSNumber *)numberValue;\n\n- (nullable NSData *)dataValue;\n\n@end\n\nWCDB_API @interface NSNumber(WCTValue)<WCTValueProtocol>\n\n@end\n\nWCDB_API @interface NSData(WCTValue)<WCTValueProtocol>\n\n@end\n\nWCDB_API @interface NSString(WCTValue)<WCTValueProtocol>\n\n@end\n\nWCDB_API @interface NSNull(WCTValue)<WCTValueProtocol>\n\n@end\n\ntypedef NSObject<WCTValueProtocol> WCTValue;\ntypedef NSArray<WCTValue *> WCTOneRow;\ntypedef NSArray<WCTValue *> WCTOneColumn;\ntypedef NSArray<NSArray<WCTValue *> *> WCTColumnsXRows;\n\nNS_ASSUME_NONNULL_END\n"
  },
  {
    "path": "src/objc/core/WCTValue.mm",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"WCTValue.h\"\n#import \"Assertion.hpp\"\n#import \"CommonCore.h\"\n\n@implementation NSNumber (WCTValue)\n\n- (NSData *)dataValue\n{\n    return [self.stringValue dataUsingEncoding:NSUTF8StringEncoding];\n}\n\n- (NSNumber *)numberValue\n{\n    return self;\n}\n\n@end\n\n@implementation NSData (WCTValue)\n\n- (NSData *)dataValue\n{\n    return self;\n}\n\n- (NSString *)stringValue\n{\n    return [[NSString alloc] initWithData:self encoding:NSUTF8StringEncoding];\n}\n\n- (NSNumber *)numberValue\n{\n    return self.stringValue.numberValue;\n}\n\n@end\n\n@implementation NSString (WCTValue)\n\n- (NSData *)dataValue\n{\n    return [self dataUsingEncoding:NSUTF8StringEncoding];\n}\n\n- (NSString *)stringValue\n{\n    return self;\n}\n\n- (NSNumber *)numberValue\n{\n    NSNumberFormatter *formatter = [[NSNumberFormatter alloc] init];\n    return [formatter numberFromString:self];\n}\n\n@end\n\n@implementation NSNull (WCTValue)\n\n- (NSData *)dataValue\n{\n    return nil;\n}\n\n- (NSString *)stringValue\n{\n    return nil;\n}\n\n- (NSNumber *)numberValue\n{\n    return nil;\n}\n\n@end\n"
  },
  {
    "path": "src/objc/database/WCTDatabase+Config.h",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"ScalarFunctionTemplate.hpp\"\n#import \"WCTCommon.h\"\n#import \"WCTDatabase.h\"\n\nNS_ASSUME_NONNULL_BEGIN\n\ntypedef NS_ENUM(int, WCTCipherVersion) {\n    WCTCipherVersionDefault = 0,\n    WCTCipherVersion1,\n    WCTCipherVersion2,\n    WCTCipherVersion3,\n    WCTCipherVersion4,\n};\n\ntypedef NS_ENUM(int, WCTConfigPriority) {\n    WCTConfigPriorityHighest = INT32_MIN, // Only For cipher config\n    WCTConfigPriorityHigh = -100,\n    WCTConfigPriorityDefault = 0,\n    WCTConfigPriorityLow = 100,\n};\n\n/**\n Configuration\n */\ntypedef BOOL (^WCTConfigBlock)(WCTHandle* _Nonnull);\n\nWCDB_API @interface WCTDatabase(Config)\n\n/**\n @brief This interface is equivalent to `-[WCTDatabase setCipherKey:cipherKey andCipherPageSize:4096]`;\n @param cipherKey Cipher key.\n */\n- (void)setCipherKey:(NSData* _Nullable)cipherKey;\n\n/**\n @brief This interface is equivalent to `-[WCTDatabase setCipherKey:cipherKey andCipherPageSize:4096 andCipherViersion:WCTCipherVersionDefault]`;\n @param cipherKey Cipher key.\n @param cipherPageSize Cipher Page Size\n */\n- (void)setCipherKey:(NSData* _Nullable)cipherKey\n   andCipherPageSize:(int)cipherPageSize;\n\n/**\n @brief Set cipher key for a database.\n For an encrypted database, you must call it before all other operation.\n The cipher page size defaults to 4096 in WCDB, but it defaults to 1024 in other databases. So for an existing database created by other database framework, you should set it to 1024.\n Otherwise, you'd better to use cipher page size with 4096 or simply call setCipherKey: interface to get better performance.\n @note  If your database is created with the default configuration of WCDB 1.0.x, please set cipherVersion to WCTCipherVersion3.\n @param cipherKey Cipher key.\n @param cipherPageSize Cipher Page Size\n @param cipherVersion Use the default configuration of a specific version of sqlcipher\n */\n- (void)setCipherKey:(NSData* _Nullable)cipherKey\n   andCipherPageSize:(int)cipherPageSize\n   andCipherViersion:(WCTCipherVersion)cipherVersion;\n\n/**\n @brief Force SQLCipher to operate with the default settings consistent with that major version number as the default.\n @note  It works the same as `PRAGMA cipher_default_compatibility`.\n \n @param version The specified sqlcipher major version.\n */\n+ (void)setDefaultCipherConfiguration:(WCTCipherVersion)version;\n\n/**\n @brief Set config for this database.  \n @warning Since WCDB is a multi-handle database, an executing handle will not apply this config immediately. Instead, all handles will run this config before its next operation.\n @warning If you want to add cipher config, please use `WCTConfigPriorityHighest`.\n \n     [database setConfig:^BOOL(WCTHandle* handle) {\n        return [handle execute: WCDB::StatementPragma().pragma(WCDB::Pragma::secureDelete()).to(true)];\n     } withUninvocation:nil forName:@\"demo\" withPriority:WCTConfigPriorityDefault];\n */\n- (void)setConfig:(WCDB_ESCAPE WCTConfigBlock)invocation\n withUninvocation:(nullable WCDB_ESCAPE WCTConfigBlock)uninvocation\n          forName:(NSString*)name\n     withPriority:(WCTConfigPriority)priority;\n\n/**\n @brief This interface is equivalent to `-[WCTDatabase setConfig:config withUninvocation:uninvocation forName:name withPriority:WCTConfigPriorityDefault]`;\n */\n- (void)setConfig:(WCDB_ESCAPE WCTConfigBlock)invocation\n withUninvocation:(nullable WCDB_ESCAPE WCTConfigBlock)uninvocation\n          forName:(NSString*)name;\n\n/**\n @brief Remove a config.\n */\n- (void)removeConfigForName:(NSString*)name;\n\n/**\n @brief Enable/Disable Lite mode.\n Lite mode is disabled by default.\n In lite mode, the journal mode and synchronous flag of current database will be set to `OFF`,\n which will significantly reduces IO, improve performance, and also increase the probability of data corruption.\n @warning You can not rollback transaction or backup data in lite mode.\n */\n- (void)enableLiteMode:(BOOL)enable;\n\n/**\n @brief Register custom scalar function.\n @Note  The custom scalar function needs to inherit `WCDB::AbstractScalarFunctionObject`.\n @param module Scalar function module. You can use `WCDB::ScalarFunctionTemplate` to construct your custom scalar function as scalar function module.\n @param name Name of scalar function.\n */\n+ (void)registerScalarFunction:(const WCDB::ScalarFunctionModule&)module named:(NSString*)name;\n\n/**\n @brief Setup scalar function with name for current database.\n @Note  You can set up the built-in scalar functions of sqlite and the scalar functions implemented by WCDB directly. If you want to use your custom scalar function, you should firstly register it through `+[WCTDatabase registerScalarFunction:named:]`.\n @see   `+[WCTDatabase registerScalarFunction:named:]`\n */\n- (void)addScalarFunction:(NSString*)scalarFunctionName;\n\n/**\n  @brief These three interfaces are used to access and modify the global ABtest configuration of WCDB.\n */\n+ (void)setABTestConfigWithName:(NSString*)name\n                       andValue:(NSString*)value;\n\n+ (void)removeABTestConfigWithName:(NSString*)name;\n\n+ (NSString*)getABTestConfigWithName:(NSString*)name;\n\n@end\n\nNS_ASSUME_NONNULL_END\n"
  },
  {
    "path": "src/objc/database/WCTDatabase+Config.mm",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"Assertion.hpp\"\n#import \"CommonCore.h\"\n#import \"SQLite.h\"\n#import \"WCTDatabase+Config.h\"\n#import \"WCTDatabase+Private.h\"\n#import \"WCTHandle+Private.h\"\n\nstatic_assert((int) WCTConfigPriorityHighest == (int) WCDB::Configs::Priority::Highest, \"\");\nstatic_assert((int) WCTConfigPriorityHigh == (int) WCDB::Configs::Priority::High, \"\");\nstatic_assert((int) WCTConfigPriorityDefault == (int) WCDB::Configs::Priority::Default, \"\");\nstatic_assert((int) WCTConfigPriorityLow == (int) WCDB::Configs::Priority::Low, \"\");\n\n@implementation WCTDatabase (Config)\n\n- (void)setCipherKey:(NSData*)cipherKey\n{\n    [self setCipherKey:cipherKey andCipherPageSize:SQLITE_DEFAULT_PAGE_SIZE];\n}\n\n- (void)setCipherKey:(NSData*)cipherKey\n   andCipherPageSize:(int)cipherPageSize\n{\n    [self setCipherKey:cipherKey andCipherPageSize:cipherPageSize andCipherViersion:WCTCipherVersionDefault];\n}\n\n- (void)setCipherKey:(NSData* _Nullable)cipherKey\n   andCipherPageSize:(int)cipherPageSize\n   andCipherViersion:(WCTCipherVersion)cipherVersion\n{\n    if (cipherKey != nil) {\n        _database->setConfig(WCDB::CipherConfigName,\n                             std::static_pointer_cast<WCDB::Config>(std::make_shared<WCDB::CipherConfig>(WCDB::UnsafeData::immutable((const unsigned char*) cipherKey.bytes, (size_t) cipherKey.length), cipherPageSize, cipherVersion)),\n                             WCDB::Configs::Priority::Highest);\n    } else {\n        _database->removeConfig(WCDB::CipherConfigName);\n    }\n}\n\n+ (void)setDefaultCipherConfiguration:(WCTCipherVersion)version\n{\n    WCDB::CommonCore::shared().setDefaultCipherConfiguration(version);\n}\n\n- (void)setConfig:(WCTConfigBlock)nsInvocation\n withUninvocation:(WCTConfigBlock)nsUninvocation\n          forName:(NSString*)name\n     withPriority:(WCTConfigPriority)priority\n{\n    WCTRemedialAssert(nsInvocation != nil, \"Use [removeConfigForName:] instead.\", return;);\n    WCDB::CustomConfig::Invocation invocation = [nsInvocation, self](WCDB::InnerHandle* handle) -> bool {\n        return nsInvocation([[WCTHandle alloc] initWithDatabase:self andUnsafeHandle:handle]);\n    };\n    WCDB::CustomConfig::Invocation uninvocation = nullptr;\n    if (nsUninvocation != nil) {\n        uninvocation = [nsUninvocation, self](WCDB::InnerHandle* handle) -> bool {\n            return nsUninvocation([[WCTHandle alloc] initWithDatabase:self andUnsafeHandle:handle]);\n        };\n    }\n    _database->setConfig(name, std::static_pointer_cast<WCDB::Config>(std::make_shared<WCDB::CustomConfig>(invocation, uninvocation)), priority);\n}\n\n- (void)setConfig:(WCTConfigBlock)nsInvocation\n withUninvocation:(WCTConfigBlock)nsUninvocation\n          forName:(NSString*)name\n{\n    return [self setConfig:nsInvocation withUninvocation:nsUninvocation forName:name withPriority:WCTConfigPriorityDefault];\n}\n\n- (void)removeConfigForName:(NSString*)name\n{\n    _database->removeConfig(name);\n}\n\n- (void)enableLiteMode:(BOOL)enable\n{\n    _database->setLiteModeEnable(enable);\n}\n\n+ (void)registerScalarFunction:(const WCDB::ScalarFunctionModule&)module named:(NSString*)name\n{\n    WCDB::CommonCore::shared().registerScalarFunction(name, module);\n}\n\n- (void)addScalarFunction:(NSString*)scalarFunctionName\n{\n    WCDB::StringView configName = WCDB::StringView::formatted(\"%s%s\", WCDB::ScalarFunctionConfigPrefix.data(), scalarFunctionName.UTF8String);\n    _database->setConfig(configName,\n                         WCDB::CommonCore::shared().scalarFunctionConfig(scalarFunctionName),\n                         WCDB::Configs::Priority::Higher);\n}\n\n+ (void)setABTestConfigWithName:(NSString*)name\n                       andValue:(NSString*)value\n{\n    WCDB::CommonCore::shared().setABTestConfig(name, value);\n}\n\n+ (void)removeABTestConfigWithName:(NSString*)name\n{\n    WCDB::CommonCore::shared().removeABTestConfig(name);\n}\n\n+ (NSString*)getABTestConfigWithName:(NSString*)name\n{\n    WCDB::Optional<WCDB::StringView> value = WCDB::CommonCore::shared().getABTestConfig(name);\n    if (value.succeed()) {\n        return [NSString stringWithUTF8String:value->data()];\n    } else {\n        return nil;\n    }\n}\n\n@end\n"
  },
  {
    "path": "src/objc/database/WCTDatabase+File.h",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"WCTDatabase.h\"\n#import \"WCTOptional.h\"\n\nNS_ASSUME_NONNULL_BEGIN\n\nWCDB_API @interface WCTDatabase(File)\n\n/**\n @brief Remove all database-related files.\n @return YES if all files are removed.\n */\n- (BOOL)removeFiles;\n\n/**\n @brief Move all database-related files to another directory safely.\n @warning Since file operation is not atomic, There may be some accidents during this period. For example, app may crash while db file is moved to destination and wal file is not. Then none of destination and source contains the whole data. This interface can make sure all of your data is in source or destination. \n @param directory destination\n @return YES if all files are moved.\n */\n- (BOOL)moveFilesToDirectory:(NSString *)directory;\n\n/**\n @brief Paths to all database-related files.\n @return paths\n */\n- (NSArray<NSString *> *)paths;\n\n/**\n @brief Get the space used by the database files.\n @return The sum of files size in bytes.\n */\n- (WCTOptionalSize)getFilesSize;\n\n/**\n@brief Set the default directory for temporary database files. If not set, an existing directory will be selected as the temporary database files directory in the following order:\n    1. TMPDIR environment value;\n    2. /Var/tmp;\n    3. /usr/tmp;\n    4. /tmp;\n    5. The current working directory (\".\")\n Please see: https://www.sqlite.org/tempfiles.html\n @param directory a global temporary directory.\n @return YES if directory exists or create directory success.\n*/\n+ (BOOL)setDefaultTemporaryDatabaseFileDirectory:(NSString *_Nullable)directory;\n\n@end\n\nNS_ASSUME_NONNULL_END\n"
  },
  {
    "path": "src/objc/database/WCTDatabase+File.mm",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"WCTDatabase+File.h\"\n#import \"WCTDatabase+Private.h\"\n#import \"WCTFoundation.h\"\n\n@implementation WCTDatabase (File)\n\n- (BOOL)removeFiles\n{\n    return _database->removeFiles();\n}\n\n- (BOOL)moveFilesToDirectory:(NSString *)directory\n{\n    return _database->moveFiles(directory);\n}\n\n- (NSArray<NSString *> *)paths\n{\n    const auto &paths = _database->getPaths();\n    NSMutableArray *nsPaths = [NSMutableArray arrayWithCapacity:paths.size()];\n    for (const auto &path : paths) {\n        [nsPaths addObject:[NSString stringWithView:path]];\n    }\n    return nsPaths;\n}\n\n- (WCTOptionalSize)getFilesSize\n{\n    return _database->getFilesSize();\n}\n\n+ (BOOL)setDefaultTemporaryDatabaseFileDirectory:(NSString *_Nullable)directory\n{\n    return WCDB::CommonCore::shared().setDefaultTemporaryDirectory(directory);\n}\n\n@end\n"
  },
  {
    "path": "src/objc/database/WCTDatabase+Memory.h",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"WCTDatabase.h\"\n\nWCDB_API @interface WCTDatabase(Memory)\n\n/**\n @brief Purge all free memory of this database.\n WCDB will cache and reuse some sqlite db handles to improve performance. \n The max count of free sqlite db handles is same as the number of concurrent threads supported by the hardware implementation.\n You can call it to save some memory.\n */\n- (void)purge;\n\n/**\n @brief Purge all free memory of all databases.\n Note that WCDB will call this interface automatically while it receives memory warning on iOS.\n @see   `purge`\n */\n+ (void)purgeAll;\n\n@end\n"
  },
  {
    "path": "src/objc/database/WCTDatabase+Memory.mm",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"CommonCore.h\"\n#import \"WCTDatabase+Memory.h\"\n#import \"WCTDatabase+Private.h\"\n\n@implementation WCTDatabase (Memory)\n\n- (void)purge\n{\n    _database->purge();\n}\n\n+ (void)purgeAll\n{\n    WCDB::CommonCore::shared().purgeDatabasePool();\n}\n\n@end\n"
  },
  {
    "path": "src/objc/database/WCTDatabase+Private.h",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"CommonCore.h\"\n#import \"WCTDatabase.h\"\n\nNS_ASSUME_NONNULL_BEGIN\n\nWCDB_API @interface WCTDatabase() {\n@private\n    // Holder can be null in some case using temporary database object. e.g. inside the non-escape block\n    WCDB::RecyclableDatabase _databaseHolder;\n    BOOL m_isInMemory;\n@protected\n    WCDB::InnerDatabase *_database;\n}\n\n- (instancetype)init NS_DESIGNATED_INITIALIZER;\n\n- (instancetype)initWithUnsafeDatabase:(WCDB::InnerDatabase *)database NS_DESIGNATED_INITIALIZER;\n\n- (WCDB::RecyclableHandle)generateHandle:(BOOL)writeHint;\n\n@end\n\nNS_ASSUME_NONNULL_END\n"
  },
  {
    "path": "src/objc/database/WCTDatabase+Repair.h",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"WCTDatabase.h\"\n\nNS_ASSUME_NONNULL_BEGIN\n\n/**\n Triggered when a database is confirmed to be corrupted.\n */\ntypedef void (^WCTCorruptedNotificationBlock)(WCTDatabase *);\n\n/**\n Triggered before backup of each table. Return NO to skip backup of this table.\n */\ntypedef BOOL (^WCTBackupFilterBlock)(NSString * /* table */);\n\nWCDB_API @interface WCTDatabase(Repair)\n\n/**\n @brief Register database corruption notification callback.\n If the current database reports an error of `SQLITE_CORRUPT` or `SQLITE_NOTADB` during operation, WCDB will asynchronously use `PRAGMA integrity_check` to check whether this database is truly corrupted. Once confirmed, WCDB will notify you through the callback registered by this method. In the callback, you can delete the corrupted database or try to repair the database.\n @see   `-[WCTDatabase removeFiles]`\n @see   `-[WCTDatabase retrieve:]`\n @param onCorrupted The callback for database corruption.\n */\n- (void)setNotificationWhenCorrupted:(nullable WCDB_ESCAPE WCTCorruptedNotificationBlock)onCorrupted;\n\n/**\n @brief Check if the current database is corrupted.\n @warning Since this method will check all the contents of the database until it finds something corrupted, it may take a lot of time to come to a conclusion.\n @return YES if the current database is corrupted.\n */\n- (BOOL)checkIfCorrupted;\n\n/**\n @brief Check if the current database is already observed corrupted by WCDB.\n @note  It only checks a internal flag of current database.\n @return YES if the current database is already corrupted.\n */\n- (BOOL)isAlreadyCorrupted;\n\n/**\n @brief Enable database to automatically backup itself after there are updates.\n The backup content mainly includes the SQL statements related to table creation and all leaf page numbers of each table in database. The backup content will be saved in the same directory of the database. And the backup file name is the database file name plus \"-first.material\" and \"-last.material\" suffixes.\n @note  Auto-backup do not degrade IO performance of the database.\n @param flag to enable auto-backup.\n */\n- (void)enableAutoBackup:(BOOL)flag;\n\n/**\n @brief Back up the database manually.\n @see   `-[WCTDatabase enableAutoBackup:]`\n @return YES if the database is backuped successfully.\n */\n- (BOOL)backup;\n\n/**\n @brief Set a filter to tell which table should be backed up.\n The filter will be called for every table in database. If there are some tables that do not need to be backed up, return false when these table names are passed into the filter.\n @param tableShouldBeBackedUp block.\n @see `WCTBackupFilterBlock`\n */\n- (void)filterBackup:(nullable WCDB_ESCAPE WCTBackupFilterBlock)tableShouldBeBackedUp;\n\n/**\n @brief Move the current database to a temporary directory and create a new database at current path.\n This method is designed for conditions where the database is corrupted and cannot be repaired temporarily. It can deposit the corrupted database to a new location and create a temporary database for the user. The contents of the deposited database will be restored when you recover the database.\n @note  This method can be called multiple times without loss of data.\n @return YES if new database is successfully created.\n */\n- (BOOL)deposit;\n\n/**\n @brief Remove deposited data.\n @see   `-[WCTDatabase deposit]`\n @return YES if all deposited data is removed.\n */\n- (BOOL)removeDeposited;\n\n/**\n @brief Check whether there is deposited data.\n @see   `-[WCTDatabase deposit]`\n @return YES if deposited data exists.\n */\n- (BOOL)containsDeposited;\n\n/**\n @brief Recover data from a corruped db.\n If there is a valid backup of this database, most of the uncorrupted data can be recovered, otherwise WCDB will try to read all the data that can still be accessed, starting from the first page of the database.\n In the extreme case where this database is not backed up and the first page is corrupted, no data can be recovered.\n @warning Since repairing a database requires reading all uncorrupted data and writing them to a new database, it may take a lot of time to finish the job. During this period, you'd better display a loading view on the screen and present the processing percentage.\n @param onProgressUpdated block.\n @see   `WCTProgressUpdateBlock`.\n @return Percentage of repaired data. 0 or less then 0 means data recovery failed. 1 means data is fully recovered.\n */\n- (double)retrieve:(nullable WCDB_NO_ESCAPE WCTProgressUpdateBlock)onProgressUpdated;\n\n@end\n\nNS_ASSUME_NONNULL_END\n"
  },
  {
    "path": "src/objc/database/WCTDatabase+Repair.mm",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"Assertion.hpp\"\n#import \"CommonCore.h\"\n#import \"WCTCommon.h\"\n#import \"WCTDatabase+Private.h\"\n#import \"WCTDatabase+Repair.h\"\n#import \"WCTFoundation.h\"\n\n@implementation WCTDatabase (Repair)\n\n- (void)setNotificationWhenCorrupted:(WCTCorruptedNotificationBlock)onCorrupted\n{\n    WCDB::CommonCore::CorruptedNotification notification = nullptr;\n    if (onCorrupted != nil) {\n        notification = [onCorrupted](WCDB::InnerDatabase *database) {\n            onCorrupted([[WCTDatabase alloc] initWithUnsafeDatabase:database]);\n        };\n    }\n    WCDB::CommonCore::shared().setNotificationWhenDatabaseCorrupted(self.path, notification);\n}\n\n- (BOOL)checkIfCorrupted\n{\n    _database->checkIntegrity(false);\n    return self.isAlreadyCorrupted;\n}\n\n- (BOOL)isAlreadyCorrupted\n{\n    return WCDB::CommonCore::shared().isFileObservedCorrupted(self.path);\n}\n\n- (void)filterBackup:(WCTBackupFilterBlock)tableShouldBeBackedUp\n{\n    WCDB::InnerDatabase::BackupFilter filter = nullptr;\n    if (tableShouldBeBackedUp != nil) {\n        filter = [tableShouldBeBackedUp](const WCDB::UnsafeStringView &tableName) -> bool {\n            return tableShouldBeBackedUp([NSString stringWithView:tableName]);\n        };\n    }\n    _database->filterBackup(filter);\n}\n\n- (BOOL)deposit\n{\n    return _database->deposit();\n}\n\n- (void)enableAutoBackup:(BOOL)flag\n{\n    WCDB::CommonCore::shared().enableAutoBackup(_database, flag);\n}\n\n- (BOOL)backup\n{\n    return _database->backup(false);\n}\n\n- (double)retrieve:(WCDB_NO_ESCAPE WCTProgressUpdateBlock)onProgressUpdated\n{\n    WCDB::InnerDatabase::ProgressCallback callback = nullptr;\n    if (onProgressUpdated != nil) {\n        callback = [onProgressUpdated](double percentage, double increment) {\n            return onProgressUpdated(percentage, increment);\n        };\n    }\n    return _database->retrieve(callback);\n}\n\n- (BOOL)removeDeposited\n{\n    return _database->removeDeposited();\n}\n\n- (BOOL)containsDeposited\n{\n    return _database->containsDeposited();\n}\n\n@end\n"
  },
  {
    "path": "src/objc/database/WCTDatabase.h",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"Macro.h\"\n#import \"WCTTag.h\"\n#import <Foundation/Foundation.h>\n\nNS_ASSUME_NONNULL_BEGIN\n\n@class WCTError;\n\n/**\n Triggered when database is closed.\n */\ntypedef void (^WCTCloseBlock)(void);\n\n/**\n Triggered when operation progresses.\n */\ntypedef bool /* continue or not */ (^WCTProgressUpdateBlock)(double /* percentage */, double /* increment */);\n\nWCDB_API @interface WCTDatabase : NSObject\n\n/**\n @brief Set/Get the tag of the database. Tag is 0 by default.\n @Note The `WCTError` generated by the database will carry its tag. You can set the same tag for related databases for classification.\n */\n@property (atomic, assign) WCTTag tag;\n\n/**\n @brief Get the file path of the database\n */\n@property (readonly) NSString *path;\n\n- (instancetype)init UNAVAILABLE_ATTRIBUTE;\n\n/**\n @brief Init a database from path.\n @note  All database objects with same path share the same core. So you can create multiple database objects. WCDB will manage them automatically.\n        WCDB will not generate a sqlite db handle until the first operation, which is also called as lazy initialization.\n @param path Path to your database\n @return WCTDatabase\n */\n- (instancetype)initWithPath:(NSString *)path NS_DESIGNATED_INITIALIZER;\n\n/**\n @brief Init a readonly database from path.\n @warning Once a database is opened in read-only mode, it cannot be writable in the current process any more.\n @see `-[WCTDatabase initWithPath:]\n @param path Path to your database\n @return WCTDatabase\n */\n- (instancetype)initReadOnlyDatabaseWithPath:(NSString *)path NS_DESIGNATED_INITIALIZER;\n\n/**\n @brief Init a in-memory database.\n @Note  Since In-memory database share one DB handle among all threads, it does not support multi-threaded concurrent operation.\n @return WCTDatabase\n */\n- (instancetype)initInMemoryDatabase NS_DESIGNATED_INITIALIZER;\n\n/**\n @brief close the database.\n        Since Multi-threaded operation is supported in WCDB, other operations in different thread can open the closed database. So this method can make sure database is closed in the \"onClosed\" block. All other operations will be blocked until this method returns.\n        A close operation consists of 4 steps:\n            1. blockade, which blocks all other operations.\n            2. close, which waits until all sqlite db handles return and closes them.\n            3. onClosed, which trigger the callback.\n            4. unblokade, which unblocks all other operations.\n        You can simply call close: to do all steps above or call these separately.\n        Since this method will wait until all sqlite db handles return, it may lead to deadlock in some bad practice. The key to avoid deadlock is to make sure all WCDB objects in current thread is dealloced. In detail:\n            1. You should not keep WCDB objects, including `WCTHandle`, `WCTPreparedStatement`, `WCTInsert`, `WCTDelete`, `WCTUpdate`, `WCTSelect`, `WCTMultiSelect`. These objects should not be kept. You should get them, use them, then release them(set to nil) right away.\n            2. WCDB objects may not be out of its' scope.\n            3. Further more, those WCDB objects may be kept by NSAutoReleasePool, which is done by ARC automatically. So you should make sure that all WCDB objects in NSAutoReleasePool is drained.\n            The best practice is to call close: in sub-thread and display a loading animation in main thread.\n\n @param onClosed Trigger on database closed.\n */\n- (void)close:(WCDB_NO_ESCAPE WCTCloseBlock)onClosed;\n\n/**\n @brief Vacuum current database.\n It can be used to vacuum a database of any size with limited memory usage.\n @param onProgressUpdated block.\n @see   `WCTProgressUpdateBlock`.\n @return YES if vacuum succeed.\n */\n- (BOOL)vacuum:(nullable WCDB_NO_ESCAPE WCTProgressUpdateBlock)onProgressUpdated;\n\n/**\n @brief The wrapper of `PRAGMA auto_vacuum`\n */\n- (void)enableAutoVacuum:(BOOL)incremental;\n\n/**\n @brief The wrapper of `PRAGMA incremental_vacuum`\n */\n- (BOOL)incrementalVacuum:(int)pages;\n\n/**\n @brief Get the most recent error for current database in the current thread.\n        Since it is too cumbersome to get the error after every database operation, it‘s better to use monitoring interfaces to obtain database errors and print them to the log.\n @see   `[WCTDatabase globalTraceError:]`\n @see   `[WCTDatabase traceError:]`\n \n @return WCTError\n */\n- (WCTError *)error;\n\n@end\n\nNS_ASSUME_NONNULL_END\n"
  },
  {
    "path": "src/objc/database/WCTDatabase.mm",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"Global.hpp\"\n#import \"ThreadedErrors.hpp\"\n#import \"WCTDatabase+FTS.h\"\n#import \"WCTDatabase+Memory.h\"\n#import \"WCTDatabase+Private.h\"\n#import \"WCTError+Private.h\"\n#import \"WCTFoundation.h\"\n#import \"WCTHandle+Private.h\"\n\n@implementation WCTDatabase\n\n- (instancetype)initWithUnsafeDatabase:(WCDB::InnerDatabase *)database\n{\n    WCTAssert(database != nullptr);\n    if (self = [super init]) {\n        _databaseHolder = nullptr;\n        _database = database;\n    }\n    return self;\n}\n\n- (instancetype)initWithPath:(NSString *)path\n{\n    if (self = [super init]) {\n        path = [path wcdb_stringByStandardizingPath];\n        _databaseHolder = WCDB::CommonCore::shared().getOrCreateDatabase(WCDB::Path::normalize(path));\n        WCTAssert(_databaseHolder != nullptr);\n        _database = _databaseHolder.get();\n        WCTAssert(_database != nullptr);\n    }\n    return self;\n}\n\n- (instancetype)initReadOnlyDatabaseWithPath:(NSString *)path\n{\n    if (self = [super init]) {\n        path = [path wcdb_stringByStandardizingPath];\n        _databaseHolder = WCDB::CommonCore::shared().getOrCreateDatabase(WCDB::Path::normalize(path));\n        WCTAssert(_databaseHolder != nullptr);\n        _database = _databaseHolder.get();\n        WCTAssert(_database != nullptr);\n        _database->setReadOnly();\n    }\n    return self;\n}\n\n- (instancetype)initInMemoryDatabase\n{\n    if (self = [super init]) {\n        m_isInMemory = YES;\n        _database = new WCDB::InnerDatabase(\":memory:\");\n        _database->setInMemory();\n        WCTAssert(_database != nullptr);\n    }\n    return self;\n}\n\n- (void)dealloc\n{\n    if (m_isInMemory) {\n        delete _database;\n    }\n}\n\n- (void)setTag:(WCTTag)tag\n{\n    _database->setTag(tag);\n}\n\n- (WCTTag)tag\n{\n    return _database->getTag();\n}\n\n- (NSString *)path\n{\n    return [NSString stringWithView:_database->getPath()];\n}\n\n- (void)close:(WCDB_NO_ESCAPE WCTCloseBlock)onClosed\n{\n    std::function<void(void)> callback = nullptr;\n    if (onClosed != nil) {\n        callback = [onClosed]() {\n            onClosed();\n        };\n    }\n    _database->close(callback);\n}\n\n- (BOOL)vacuum:(WCDB_NO_ESCAPE WCTProgressUpdateBlock)onProgressUpdated\n{\n    WCDB::InnerDatabase::ProgressCallback callback = nullptr;\n    if (onProgressUpdated != nil) {\n        callback = [onProgressUpdated](double percentage, double increment) {\n            return onProgressUpdated(percentage, increment);\n        };\n    }\n    return _database->vacuum(callback);\n}\n\n- (void)enableAutoVacuum:(BOOL)incremental\n{\n    _database->enableAutoVacuum(incremental);\n}\n\n- (BOOL)incrementalVacuum:(int)pages\n{\n    return _database->incrementalVacuum(pages);\n}\n\n- (WCTError *)error\n{\n    return [[WCTError alloc] initWithError:_database->getThreadedError()];\n}\n\n- (WCDB::RecyclableHandle)generateHandle:(BOOL)writeHint\n{\n    return _database->getHandle(writeHint);\n}\n\n@end\n"
  },
  {
    "path": "src/objc/fts/WCTDatabase+FTS.h",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"FTS5AuxiliaryFunctionTemplate.hpp\"\n#import \"OneOrBinaryTokenizer.hpp\"\n#import \"PinyinTokenizer.hpp\"\n#import \"SubstringMatchInfo.hpp\"\n#import \"WCTCommon.h\"\n#import \"WCTDatabase.h\"\n#import \"WCTFTSTokenizerUtil.h\"\n\nNS_ASSUME_NONNULL_BEGIN\n\n/**\n The following three are different versions of the sqlite fts module. `WCTModuleFTS5` is recommended. You can use `WCDB_VIRTUAL_TABLE_MODULE` to config fts module for a `WCTTableCoding` class.\n */\nWCDB_EXTERN NSString* const WCTModuleFTS3;\nWCDB_EXTERN NSString* const WCTModuleFTS4;\nWCDB_EXTERN NSString* const WCTModuleFTS5;\n\n/**\n The following four are sqlite built-in fts tokenizers. `WCTTokenizerSimple` can be used in fts3/4 and the others can be used in fts3/4/5. You can use `WCDB_VIRTUAL_TABLE_TOKENIZE` to config fts tokenizer for a `WCTTableCoding` class.\n */\nWCDB_EXTERN NSString* const WCTTokenizerSimple;\nWCDB_EXTERN NSString* const WCTTokenizerPorter;\nWCDB_EXTERN NSString* const WCTTokenizerICU;\nWCDB_EXTERN NSString* const WCTTokenizerUnicode61;\n\n/**\n The following two are WCDB implemented tokenizers for fts3/4. They are the same tokenizer with different name.\n When tokenizing, symbol characters are ignored by default. Consecutive English letters will be recognized as an English token, and this token will be stemmed using the porter stemming algorithm. Continuous Arabic numerals will be recognized as a single numeric token. For other Unicode characters, each character will be recognized as one token.\n For example, the sentence \"The phone number of 张三 is 12345\" will be split into these tokens: \"the\", \"phone\", \"number\", \"of\", \"张\", \"三\", \"is\", \"12345\".\n */\nWCDB_EXTERN NSString* const WCTTokenizerOneOrBinary;\nWCDB_EXTERN NSString* const WCTTokenizerLegacyOneOrBinary; // compatible for WCTTokenizerNameWCDB before v1.1.0\n\n/**\n The following two are WCDB implemented tokenizers for fts5.\n `WCTTokenizerVerbatim` has the same tokenize rules as `WCTTokenizerOneOrBinary` or `WCTTokenizerLegacyOneOrBinary`.\n `WCTTokenizerPinyin` is designed for pinyin search. You can use the simplified or full pinyin of Chinese characters to search for Chinese characters. Before using this tokenizer, you need to use `+[WCTDatabase configPinYinDict:]` to configure the mapping relationship between Chinese characters and their pinyin.\n */\nWCDB_EXTERN NSString* const WCTTokenizerVerbatim;\nWCDB_EXTERN NSString* const WCTTokenizerPinyin;\n\n/**\n The following three are optional parameters for WCDB implemented tokenizers. You can use `WCDB_VIRTUAL_TABLE_TOKENIZE_WITH_PARAMETERS` to config fts tokenizer with parameters for a `WCTTableCoding` class.\n Configuring `WCTTokenizerParameter_NeedSymbol` allows the tokenizer to recognize each symbol character as a token.\n Configuring `WCTTokenizerParameter_SimplifyChinese` enables the tokenizer to convert each traditional Chinese character into a simplified Chinese character, so that you can use Simplified Chinese characters to search Traditional Chinese characters. Note that you need to use `+[WCTDatabase configTraditionalChineseDict:]` to configure the mapping relationship between traditional Chinese characters and simplified Chinese characters before using the tokenizer.\n Configuring `WCTTokenizerParameter_SkipStemming` will disable the stemming during tokenization.\n */\nWCDB_EXTERN NSString* const WCTTokenizerParameter_NeedSymbol;\nWCDB_EXTERN NSString* const WCTTokenizerParameter_SimplifyChinese;\nWCDB_EXTERN NSString* const WCTTokenizerParameter_SkipStemming;\n\n/**\n `WCTAuxiliaryFunction_SubstringMatchInfo` is a WCDB implemented auxiliary function for fts5.\n When you need to concat multiple contents together with multi-level separators and save them in a single column of the fts5 table, you can use this auxiliary function to improve the accuracy of searching for the contents of this column.\n Suppose you have a friend named 张三, whose address is 广州 and 上海, and phone number is 12345 and 67890. You can use semicolon and comma as two-level separators to concat your friend's information into \"张三;广州,上海;12345,67890\" and save it in a column named \"friends\" in an fts5 table. Then you can use following code to search your friend:\n \n        [fts5Table getColumnOnResultColumn:WCDB::Column(fts5Table.tableName).substringMatchInfo(0, \";,\") where:WCDB::Column(\"friends\").match(\"州\")];\n \n The first argument of SubstringMatchInfo is a column named with table name. The second argument is the index of the colum you need to search. The index is are numbered starting from 0. The third parameter is the separator used when concating the content, which should be arranged according to their level.\n Then you will get this string result \"1,0;广;州;3;\". The result is made by concating a variety of information with the separator you passed in. The first part of the result \"1,0\" gives the hierarchical position of the matched content within matched column. The second part \"广;州\" is the original text of the matching content, you can use it for highlighting. The third part \"3\" is the byte offset of the matching content in the original text, you can use it to sort the results.\n \n @warning The search results may contain some empty strings, which are invalid results. This kind of results appear when the content of some rows contain the tokens you are searching for, but these tokens are located in different parts separated by separators. You just need to ignore these results.\n */\nWCDB_EXTERN NSString* const WCTAuxiliaryFunction_SubstringMatchInfo;\n\nWCDB_API @interface WCTDatabase(FTS)\n\n/**\n @brief Enable to automatically merge b-tree segments of fts5 index after modifying the content in fts5 table.\n The merge operation will be performed in a separate sub-thread, and will be suspended when it detects that other threads need to modify the fts table. So it will improve the performance of modifying the fts5 table.\n Using auto-merge, WCDB can maintain only one segment per level in the fts5 index structure. So it will significantly improve the search performance of the fts5 index.\n @param flag to enable auto-merge.\n */\n- (void)enableAutoMergeFTS5Index:(BOOL)flag;\n\n/**\n @brief Setup tokenizer with name for current database.\n @Note  You can set up the built-in tokenizers of sqlite and the tokenizers implemented by WCDB directly. If you want to use your custom tokenizer, you should firstly register it through `+[WCTDatabase registerTokenizer:named:]`.\n @see   `+[WCTDatabase registerTokenizer:named:]`\n */\n- (void)addTokenizer:(NSString*)tokenizerName;\n\n/**\n @brief Register custom tokenizer.\n @Note  The custom tokenizer needs to inherit `WCDB::AbstractFTSTokenizer`.\n @param module Tokenizer module for fts. You can use WCDB::FTS3TokenizerModuleTemplate to construct your custom tokenizer as tokenizer module for fts3/4, or use WCDB::FTS5TokenizerModuleTemplate to construct for fts5.\n @param name Name of tokenizer.\n */\n+ (void)registerTokenizer:(const WCDB::TokenizerModule&)module named:(NSString*)name;\n\n/**\n @brief Setup auxiliary function with name for current database.\n @Note  You can set up the built-in auxiliary functions of sqlite and the auxiliary functions implemented by WCDB directly. If you want to use your custom auxiliary function, you should firstly register it through `+[WCTDatabase registerAuxiliaryFunction:named:]`.\n @see   `+[WCTDatabase registerAuxiliaryFunction:named:]`\n */\n- (void)addAuxiliaryFunction:(NSString*)auxiliaryFunctionName;\n\n/**\n @brief Register custom auxiliary function for fts5.\n @Note  The custom auxiliary function needs to inherit `WCDB::AbstractFTS5AuxiliaryFunctionObject`.\n @param module Auxiliary function module for fts5. You can use WCDB::FTS5AuxiliaryFunctionTemplate to construct your custom auxiliary function as auxiliary function module.\n @param name Name of auxiliary function.\n */\n+ (void)registerAuxiliaryFunction:(const WCDB::FTS5AuxiliaryFunctionModule&)module named:(NSString*)name;\n\n/**\n @brief Configure the mapping relationship between Chinese characters and their pinyin.\n @see   `WCTTokenizerPinyin`\n @param pinyinDict Pinyin mapping dictionary.\n */\n+ (void)configPinYinDict:(NSDictionary<NSString* /*Chinese character*/, NSArray<NSString*>*>* /*Pinyin array*/)pinyinDict;\n\n/**\n @brief Configure the mapping relationship between traditional Chinese characters and simplified Chinese characters.\n @see   `WCTTokenizerParameter_SimplifyChinese`\n @param traditionalChineseDict Traditional Chinese mapping dictionary.\n */\n+ (void)configTraditionalChineseDict:(NSDictionary<NSString* /*Traditional Chinese character*/, NSString* /*Simplified Chinese character*/>*)traditionalChineseDict;\n\n@end\n\nNS_ASSUME_NONNULL_END\n"
  },
  {
    "path": "src/objc/fts/WCTDatabase+FTS.mm",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"Assertion.hpp\"\n#import \"FTSConst.h\"\n#import \"WCTDatabase+FTS.h\"\n#import \"WCTDatabase+Private.h\"\n\nNSString* const WCTTokenizerSimple = [NSString stringWithUTF8String:WCDB::BuiltinTokenizer::Simple];\nNSString* const WCTTokenizerPorter = [NSString stringWithUTF8String:WCDB::BuiltinTokenizer::Porter];\nNSString* const WCTTokenizerICU = [NSString stringWithUTF8String:WCDB::BuiltinTokenizer::ICU];\nNSString* const WCTTokenizerUnicode61 = [NSString stringWithUTF8String:WCDB::BuiltinTokenizer::Unicode61];\nNSString* const WCTTokenizerOneOrBinary = [NSString stringWithUTF8String:WCDB::BuiltinTokenizer::OneOrBinary];\nNSString* const WCTTokenizerLegacyOneOrBinary = [NSString stringWithUTF8String:WCDB::BuiltinTokenizer::LegacyOneOrBinary];\nNSString* const WCTTokenizerVerbatim = [NSString stringWithUTF8String:WCDB::BuiltinTokenizer::Verbatim];\nNSString* const WCTTokenizerPinyin = [NSString stringWithUTF8String:WCDB::BuiltinTokenizer::Pinyin];\n\nNSString* const WCTTokenizerParameter_NeedSymbol = [NSString stringWithUTF8String:WCDB::BuiltinTokenizer::Parameter::NeedSymbol];\nNSString* const WCTTokenizerParameter_SimplifyChinese = [NSString stringWithUTF8String:WCDB::BuiltinTokenizer::Parameter::SimplifyChinese];\nNSString* const WCTTokenizerParameter_SkipStemming = [NSString stringWithUTF8String:WCDB::BuiltinTokenizer::Parameter::SkipStemming];\n\nNSString* const WCTModuleFTS3 = [NSString stringWithUTF8String:WCDB::Module::FTS3];\nNSString* const WCTModuleFTS4 = [NSString stringWithUTF8String:WCDB::Module::FTS4];\nNSString* const WCTModuleFTS5 = [NSString stringWithUTF8String:WCDB::Module::FTS5];\n\nNSString* const WCTAuxiliaryFunction_SubstringMatchInfo = [NSString stringWithUTF8String:WCDB::BuiltinAuxiliaryFunction::SubstringMatchInfo];\n\n@implementation WCTDatabase (FTS)\n\n- (void)enableAutoMergeFTS5Index:(BOOL)flag\n{\n    WCDB::CommonCore::shared().enableAutoMergeFTSIndex(_database, flag);\n}\n\n- (void)addTokenizer:(NSString*)tokenizerName\n{\n    WCTFTSTokenizerUtil::configDefaultSymbolDetectorAndUnicodeNormalizer();\n    WCDB::StringView configName = WCDB::StringView::formatted(\"%s%s\", WCDB::TokenizeConfigPrefix.data(), tokenizerName.UTF8String);\n    _database->setConfig(configName, WCDB::CommonCore::shared().tokenizerConfig(tokenizerName), WCDB::Configs::Priority::Higher);\n}\n\n+ (void)registerTokenizer:(const WCDB::TokenizerModule&)module named:(NSString*)name\n{\n    WCTRemedialAssert(name.length > 0, \"Module name can't be nil.\", return;);\n    WCDB::CommonCore::shared().registerTokenizer(name, module);\n}\n\n+ (void)configPinYinDict:(NSDictionary<NSString*, NSArray<NSString*>*>*)pinyinDict\n{\n    WCTFTSTokenizerUtil::configPinyinDict(pinyinDict);\n}\n\n+ (void)configTraditionalChineseDict:(NSDictionary<NSString*, NSString*>*)traditionalChineseDict\n{\n    WCTFTSTokenizerUtil::configTraditionalChineseDict(traditionalChineseDict);\n}\n\n- (void)addAuxiliaryFunction:(NSString*)auxiliaryFunctionName\n{\n    WCDB::StringView configName = WCDB::StringView::formatted(\"%s%s\", WCDB::AuxiliaryFunctionConfigPrefix.data(), auxiliaryFunctionName.UTF8String);\n    _database->setConfig(configName, WCDB::CommonCore::shared().auxiliaryFunctionConfig(auxiliaryFunctionName), WCDB::Configs::Priority::Higher);\n}\n\n+ (void)registerAuxiliaryFunction:(const WCDB::FTS5AuxiliaryFunctionModule&)module named:(NSString*)name\n{\n    WCTRemedialAssert(name.length > 0, \"Module name can't be nil.\", return;);\n    WCDB::CommonCore::shared().registerAuxiliaryFunction(name, module);\n}\n\n@end\n"
  },
  {
    "path": "src/objc/handle/WCTCancellationSignal+Private.h",
    "content": "//\n// Created by qiuwenchen on 2023/8/11.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"WCTCancellationSignal.h\"\n#include <memory>\n\nWCDB_API @interface WCTCancellationSignal() {\n    std::shared_ptr<volatile bool> m_signal;\n}\n- (std::shared_ptr<volatile bool>)getInnerSignal;\n@end\n"
  },
  {
    "path": "src/objc/handle/WCTCancellationSignal.h",
    "content": "//\n// Created by qiuwenchen on 2023/8/11.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"WCTCommon.h\"\n\nWCDB_API @interface WCTCancellationSignal : NSObject\n/**\n @brief Cancel all operations of the attached handle.\n @see   `-[WCTHandle attachCancellationSignal:]`\n */\n- (void)cancel;\n\n@end\n"
  },
  {
    "path": "src/objc/handle/WCTCancellationSignal.mm",
    "content": "//\n// Created by qiuwenchen on 2023/8/11.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"WCTCancellationSignal+Private.h\"\n#import <Foundation/Foundation.h>\n\n@implementation WCTCancellationSignal\n\n- (instancetype)init\n{\n    if (self = [super init]) {\n        m_signal = std::make_shared<bool>(false);\n    }\n    return self;\n}\n\n- (std::shared_ptr<volatile bool>)getInnerSignal\n{\n    return m_signal;\n}\n\n- (void)cancel\n{\n    (*m_signal) = true;\n}\n\n@end\n"
  },
  {
    "path": "src/objc/handle/WCTDatabase+Handle.h",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"WCTCommon.h\"\n#import \"WCTDatabase.h\"\n\nNS_ASSUME_NONNULL_BEGIN\n\nclass WCDB_API WCTScopedHandle {\npublic:\n    WCTScopedHandle(WCTHandle *handle = nil);\n    ~WCTScopedHandle();\n    WCTHandle *getHandle() const;\n\nprivate:\n    WCTHandle *m_handle;\n};\n\nWCDB_API @interface WCTDatabase(Handle)\n/**\n @brief Create a `WCTHandle` for current database.\n WCTHandle is a wrapper for sqlite db handle of type `sqlite3*`, and the sqlite db handle is lazy initialized and will not be actually generated until the first operation on current handle takes place.\n `WCDB_GET_SCOPED_HANDLE` is a better way to create a WCTHandle, so that the handle will be invalidated automatically when the current scope is finished.\n @note  All WCTHandles created by the current database in the current thread will share the same sqlite db handle internally, so it can avoid the deadlock between different sqlite db handles in some extreme cases.\n @return A WCTHandle object.\n */\n- (WCTHandle *)getHandle;\n\n/**\n @brief Execute a statement directly.\n @return YES if no error occurs.\n */\n- (BOOL)execute:(const WCDB::Statement &)statement;\n\n/**\n @brief Execute a sql string directly.\n @warning You should no use this method to access or modify the data in a migrating table..\n @see   `-[WCTDatabase addMigration:withFilter:]`\n @return YES if no error occurs.\n */\n- (BOOL)rawExecute:(NSString *)sql;\n\n@end\n\n#define WCDB_GET_SCOPED_HANDLE(database, handle) _WCDB_GET_SCOPED_HANDLE(database, handle, __COUNTER__)\n#define _WCDB_GET_SCOPED_HANDLE(database, handle, counter) __WCDB_GET_SCOPED_HANDLE(database, handle, counter)\n#define __WCDB_GET_SCOPED_HANDLE(database, handle, counter)        \\\n    WCTScopedHandle __scopedHandle##counter([database getHandle]); \\\n    WCTHandle *handle = __scopedHandle##counter.getHandle();\n\nNS_ASSUME_NONNULL_END\n"
  },
  {
    "path": "src/objc/handle/WCTDatabase+Handle.mm",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"WCTDatabase+Handle.h\"\n#import \"WCTDatabase+Private.h\"\n#import \"WCTHandle+Private.h\"\n\nWCTScopedHandle::WCTScopedHandle(WCTHandle *handle)\n: m_handle(handle)\n{\n}\n\nWCTScopedHandle::~WCTScopedHandle()\n{\n    if (m_handle != nil) {\n        [m_handle finalizeStatement];\n        [m_handle invalidate];\n    }\n}\n\nWCTHandle *WCTScopedHandle::getHandle() const\n{\n    return m_handle;\n}\n\n@implementation WCTDatabase (Handle)\n\n- (WCTHandle *)getHandle\n{\n    return [[WCTHandle alloc] initWithDatabase:self];\n}\n\n- (BOOL)execute:(const WCDB::Statement &)statement\n{\n    return _database->execute(statement);\n}\n\n//rawExecute should no be used to access or modify the data in a migrating table.\n- (BOOL)rawExecute:(NSString *)sql\n{\n    return _database->execute(sql);\n}\n\n@end\n"
  },
  {
    "path": "src/objc/handle/WCTHandle+Private.h",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License CPP(the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"CommonCore.h\"\n#import \"WCTHandle.h\"\n#import \"WCTTransaction.h\"\n\nNS_ASSUME_NONNULL_BEGIN\n\n#define WCTHandleAssert(remedial) WCTRemedialAssert(_handle != nullptr, \"[prepare:] or [execute:] should be called before this.\", remedial)\n\nWCDB_API @interface WCTHandle() {\n@private\n    WCTDatabase *_database;\n    WCDB::InnerHandle *_handle;\n    WCDB::RecyclableHandle _handleHolder;\n    BOOL _writeHint;\n}\n\n#pragma mark - LifeCycle\n- (instancetype)init NS_DESIGNATED_INITIALIZER;\n\n- (instancetype)initWithDatabase:(WCTDatabase *)database andUnsafeHandle:(WCDB::InnerHandle *)handle NS_DESIGNATED_INITIALIZER;\n\n- (instancetype)initWithDatabase:(WCTDatabase *)database NS_DESIGNATED_INITIALIZER;\n\n- (instancetype)initWithUnsafeHandle:(WCDB::InnerHandle *)handle NS_DESIGNATED_INITIALIZER;\n\n- (nullable WCDB::InnerHandle *)getOrGenerateHandle;\n- (void)setWriteHint:(BOOL)writeHint;\n\n- (BOOL)lazyRunTransaction:(WCTTransactionBlock)transaction;\n\n@end\n\nNS_ASSUME_NONNULL_END\n"
  },
  {
    "path": "src/objc/handle/WCTHandle.h",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"WCTCancellationSignal.h\"\n#import \"WCTCommon.h\"\n\nNS_ASSUME_NONNULL_BEGIN\n\n/**\n This class is a wrapper for sqlite db handle of type `sqlite3*`\n @warning Not Thread-safe.\n */\nWCDB_API @interface WCTHandle : NSObject\n\n/**\n You should use `WCDB_GET_SCOPED_HANDLE` or `-[WCTDatabase getHandle]` to obtain WCTHandle.\n */\n- (instancetype)init UNAVAILABLE_ATTRIBUTE;\n\n#pragma mark - Handle\n/**\n The database that generate current handle.\n */\n@property (nonatomic, readonly) WCTDatabase *database;\n\n/**\n @brief Recycle the sqlite db handle inside, and the current handle will no longer be able to perform other operations.\n @warning If you use obtain current handle through `-[WCTDatabase getHandle]`, you need to call its invalidate method when you are done with it, otherwise you will receive an Assert Failure.\n */\n- (void)invalidate;\n\n/**\n @brief Check whether the current handle still holds a sqlite db handle.\n @return YES if there is a valid sqlite db handle inside current handle.\n */\n- (BOOL)isValidated;\n\n/**\n @brief Try to get a new sqlite db handle if the current handle does not hold one inside.\n @return YES if current handle is validated.\n */\n- (BOOL)validate;\n\n#pragma mark - Statement\n\n/**\n @brief Use `sqlite3_prepare` internally to prepare a new statement, and wrap the `sqlite3_stmt` generated by `sqlite3_prepare` into `WCTPreparedStatement` to return.\n If the statement has been prepared by this method before, and you have not used `-[WCTHandle invalidate]` or `-[WCTHandle finalizeAllStatements]` to finalize it, then you can use this method to regain the previously generated `sqlite3_stmt`.\n @note  This method is designed for the situation where you need to use multiple statements at the same time to do complex database operations. You can prepare a new statement without finalizing the previous statements, so that you can save the time of analyzing SQL syntax.\n If you only need to use one statement, or you no longer need to use the previous statements when you use a new statement, it is recommended to use `-[WCTHandle execute:]` or `-[WCTHandle prepare:]`.\n @see   `-[WCTHandle execute:]`\n @see   `-[WCTHandle prepare:]`\n @param statement The SQL statememt needed to prepare.\n @return a `WCTPreparedStatement` object with `sqlite3_stmt` inside, or nil if error occurs.\n */\n- (WCTPreparedStatement *)getOrCreatePreparedStatement:(const WCDB::Statement &)statement;\n\n/**\n @brief Use `sqlite3_finalize` to finalize all `sqlite3_stmt` generate by current handle.\n @note  `-[WCTHandle invalidate]` will internally call the current method.\n */\n- (void)finalizeAllStatements;\n\n#pragma mark - Execute\n/**\n @brief Execute a statement directly.\n @warning You should firstly use `-[WCTHandle finalizeStatement]` to finalize the previous statement prepared by `-[WCTHandle prepare:]`.\n @return YES if no error occurs.\n */\n- (BOOL)execute:(const WCDB::Statement &)statement;\n\n/**\n @brief Execute a sql string directly.\n @warning You should no use this method to access or modify the data in a migrating table and you should firstly use `-[WCTHandle finalizeStatement]` to finalize the previous statement prepared by `-[WCTHandle prepare:]`.\n @see   `-[WCTDatabase addMigration:withFilter:]`\n @return YES if no error occurs.\n */\n- (BOOL)rawExecute:(NSString *)sql;\n\n#pragma mark - Prepare\n/**\n @brief Use `sqlite3_prepare` internally to prepare a new statement.\n @warning You should firstly use `-[WCTHandle finalizeStatement]` to finalize the previous statement prepared by `-[WCTHandle prepare:]`. If you need to prepare multiple statements at the same time, `-[WCTHandle getOrCreatePreparedStatement:]` is recommended.\n @see   `-[WCTHandle getOrCreatePreparedStatement:]`\n @return YES if no error occurs.\n */\n- (BOOL)prepare:(const WCDB::Statement &)statement;\n/**\n @brief Use `sqlite3_prepare` internally to prepare a sql string.\n @warning You should no use this method to access or modify the data in a migrating table and you should firstly use `-[WCTHandle finalizeStatement]` to finalize the previous statement prepared by `-[WCTHandle prepare:]`.\n @see   `-[WCTDatabase addMigration:withFilter:]`\n @return YES if no error occurs.\n */\n- (BOOL)rawPrepare:(NSString *)sql;\n\n/**\n @brief Check if there is a statement previously prepared by `-[WCTHandle prepare:]` or `-[WCTHandle rawPrepare:]`.\n @return YES if there is a prepared statement.\n */\n- (BOOL)isPrepared;\n\n/**\n @brief Finalize the statement previously prepared by `-[WCTHandle prepare:]` or `-[WCTHandle rawPrepare:]`.\n @warning You should finalize the previously prepared statement before use a new statement.\n */\n- (void)finalizeStatement;\n\n#pragma mark - Step\n/**\n @brief The wrapper of `sqlite3_step`.\n @note It is for the statement previously prepared by `-[WCTHandle prepare:]` or `-[WCTHandle rawPrepare:]`.\n @return YES if no error occurs.\n */\n- (BOOL)step;\n\n/**\n @brief The wrapper of `sqlite3_reset`.\n @note It is for the statement previously prepared by `-[WCTHandle prepare:]` or `-[WCTHandle rawPrepare:]`.\n */\n- (void)reset;\n\n/**\n @brief The wrapper of `sqlite3_clear_bindings`.\n @note It is for the statement previously prepared by `-[WCTHandle prepare:]` or `-[WCTHandle rawPrepare:]`.\n */\n- (void)clearBindings;\n\n/**\n @brief Check if you can continue stepping.\n @return YES if you can continue stepping.\n */\n- (BOOL)done;\n\n#pragma mark - State\n/**\n @brief The wrapper of `sqlite3_stmt_readonly`.\n @note It is for the statement previously prepared by `-[WCTHandle prepare:]` or `-[WCTHandle rawPrepare:]`.\n */\n- (long long)getLastInsertedRowID;\n\n/**\n @brief The wrapper of `sqlite3_changes`.\n */\n- (int)getChanges;\n\n/**\n @brief The wrapper of `sqlite3_total_changes`.\n */\n- (int)getTotalChanges;\n\n/**\n @brief The wrapper of `sqlite3_stmt_readonly`.\n It is for the statement previously prepared by `-[WCTHandle prepare:]` or `-[WCTHandle rawPrepare:]`.\n */\n- (BOOL)isStatementReadonly;\n\n#pragma mark - Bind\n/**\n @brief The wrapper of `sqlite3_bind_int64`.\n @note It is for the statement previously prepared by `-[WCTHandle prepare:]` or `-[WCTHandle rawPrepare:]`.\n */\n- (void)bindInteger:(const int64_t &)value toIndex:(int)index;\n\n/**\n @brief The wrapper of `sqlite3_bind_double`.\n @note It is for the statement previously prepared by `-[WCTHandle prepare:]` or `-[WCTHandle rawPrepare:]`.\n */\n- (void)bindDouble:(const double &)value toIndex:(int)index;\n\n/**\n @brief The wrapper of `sqlite3_bind_null`.\n @note It is for the statement previously prepared by `-[WCTHandle prepare:]` or `-[WCTHandle rawPrepare:]`.\n */\n- (void)bindNullToIndex:(int)index;\n\n/**\n @brief The wrapper of `sqlite3_bind_text`.\n @note It is for the statement previously prepared by `-[WCTHandle prepare:]` or `-[WCTHandle rawPrepare:]`.\n */\n- (void)bindString:(NSString *)string toIndex:(int)index;\n\n/**\n @brief The wrapper of `sqlite3_bind_int64`.\n @note It is for the statement previously prepared by `-[WCTHandle prepare:]` or `-[WCTHandle rawPrepare:]`.\n */\n- (void)bindData:(NSData *)data toIndex:(int)index;\n\n/**\n @brief Bind an NSNumber.\n It will call `sqlite3_bind_int64` or `sqlite3_bind_double` according to the underlying data type of NSNumber.\n @note It is for the statement previously prepared by `-[WCTHandle prepare:]` or `-[WCTHandle rawPrepare:]`.\n */\n- (void)bindNumber:(NSNumber *)number toIndex:(int)index;\n\n/**\n @brief The wrapper of `sqlite3_bind_*`.\n It will call the appropriate routine according to the column type returned by +[WCTColumnCoding columnType].\n @note It is for the statement previously prepared by `-[WCTHandle prepare:]` or `-[WCTHandle rawPrepare:]`.\n @param value WCTColumnCodingValue can be NSString, NSNumber, NSData, NSNull, nil and any NSObject that conforms to WCTColumnCoding.\n @see   `WCTColumnCoding`\n */\n- (void)bindValue:(nullable WCTColumnCodingValue *)value\n          toIndex:(int)index;\n\n/**\n @brief The wrapper of `sqlite3_bind_*` for binding property of object to index.\n It will call the appropriate routine according to the data type of property.\n @note It is for the statement previously prepared by `-[WCTHandle prepare:]` or `-[WCTHandle rawPrepare:]`.\n */\n- (void)bindProperty:(const WCTProperty &)property\n            ofObject:(WCTObject *)object\n             toIndex:(int)index;\n\n/**\n @brief The wrapper of `sqlite3_bind_*` for binding the specified properties of object.\n It will call the appropriate routine according to the data type of properties.\n @note It is for the statement previously prepared by `-[WCTHandle prepare:]` or `-[WCTHandle rawPrepare:]`.\n */\n- (void)bindProperties:(const WCTProperties &)properties\n              ofObject:(WCTObject *)object;\n\n/**\n @brief The wrapper of `sqlite3_bind_parameter_index`.\n @note It is for the statement previously prepared by `-[WCTHandle prepare:]` or `-[WCTHandle rawPrepare:]`.\n */\n- (int)bindParameterIndex:(const WCDB::BindParameter &)parameter;\n\n#pragma mark - Extract Column meta\n/**\n @brief The wrapper of `sqlite3_column_count`.\n @note It is for the statement previously prepared by `-[WCTHandle prepare:]` or `-[WCTHandle rawPrepare:]`.\n */\n- (int)extractNumberOfColumns;\n\n/**\n@brief The wrapper of `sqlite3_column_type`.\n@note It is for the statement previously prepared by `-[WCTHandle prepare:]` or `-[WCTHandle rawPrepare:]`.\n*/\n- (WCTColumnType)extractTypeAtIndex:(int)index;\n\n/**\n @brief The wrapper of `sqlite3_column_origin_name`.\n @note It is for the statement previously prepared by `-[WCTHandle prepare:]` or `-[WCTHandle rawPrepare:]`.\n */\n- (NSString *)extractOriginColumnNameAtIndex:(int)index;\n\n/**\n @brief The wrapper of `sqlite3_column_name`.\n @note It is for the statement previously prepared by `-[WCTHandle prepare:]` or `-[WCTHandle rawPrepare:]`.\n */\n- (NSString *)extractColumnNameAtIndex:(int)index;\n\n/**\n @brief The wrapper of `sqlite3_column_table_name`.\n @note It is for the statement previously prepared by `-[WCTHandle prepare:]` or `-[WCTHandle rawPrepare:]`.\n */\n- (NSString *)extractTableNameAtIndex:(int)index;\n\n#pragma mark - Extract Row Data\n/**\n @brief The wrapper of `sqlite3_column_int64`.\n @note It is for the statement previously prepared by `-[WCTHandle prepare:]` or `-[WCTHandle rawPrepare:]`.\n */\n- (int64_t)extractIntegerAtIndex:(int)index;\n\n/**\n @brief The wrapper of `sqlite3_column_double`.\n @note It is for the statement previously prepared by `-[WCTHandle prepare:]` or `-[WCTHandle rawPrepare:]`.\n */\n- (double)extractDoubleAtIndex:(int)index;\n\n/**\n @brief The wrapper of `sqlite3_column_text`.\n @note It is for the statement previously prepared by `-[WCTHandle prepare:]` or `-[WCTHandle rawPrepare:]`.\n */\n- (NSString *)extractStringAtIndex:(int)index;\n\n/**\n @brief The wrapper of `sqlite3_column_int64` and `sqlite3_column_double`.\n @note It is for the statement previously prepared by `-[WCTHandle prepare:]` or `-[WCTHandle rawPrepare:]`.\n */\n- (NSNumber *)extractNumberAtIndex:(int)index;\n\n/**\n @brief The wrapper of `sqlite3_column_blob`.\n @note It is for the statement previously prepared by `-[WCTHandle prepare:]` or `-[WCTHandle rawPrepare:]`.\n */\n- (NSData *)extractDataAtIndex:(int)index;\n\n/**\n @brief The wrapper of `sqlite3_column_*`.\n @note It is for the statement previously prepared by `-[WCTHandle prepare:]` or `-[WCTHandle rawPrepare:]`.\n @return The real type of WCTValue depends on the value in database. It could be NSNumber, NSString, NSData or nil.\n */\n- (nullable WCTValue *)extractValueAtIndex:(int)index;\n\n/**\n @brief Extract all values of current row.\n @note It is for the statement previously prepared by `-[WCTHandle prepare:]` or `-[WCTHandle rawPrepare:]`.\n @return An array of NSObject that conforms to WCTValue.\n */\n- (WCTOneRow *)extractRow;\n\n/**\n @brief Extract the values of the current row and assign them into the properties specified by resultColumns of a new WCTTableCoding object.\n @note It is for the statement previously prepared by `-[WCTHandle prepare:]` or `-[WCTHandle rawPrepare:]`.\n @return A WCTTableCoding object.\n */\n- (WCTObject *)extractObjectOnResultColumns:(const WCTResultColumns &)resultColumns;\n\n/**\n @brief Extract the results of a multi-table query in the current row.\n @note It is for the statement previously prepared by `-[WCTHandle prepare:]` or `-[WCTHandle rawPrepare:]`.\n @return A dictionary containing the result of multi-table. The keys of the dictionary are the table names, and their corresponding values are the results of these tables.\n */\n- (WCTMultiObject *)extractMultiObjectOnResultColumns:(const WCTResultColumns &)resultColumns;\n\n/**\n @brief Extract value at index and set it to the corresponding property of object.\n @note It is for the statement previously prepared by `-[WCTHandle prepare:]` or `-[WCTHandle rawPrepare:]`.\n */\n- (void)extractValueAtIndex:(int)index\n                 toProperty:(const WCTProperty &)property\n                   ofObject:(WCTObject *)object;\n\n#pragma mark - Step And Extract All Data\n/**\n @brief Extract all the values of the first column in the result.\n @note It is for the statement previously prepared by `-[WCTHandle prepare:]` or `-[WCTHandle rawPrepare:]`.\n @return An array of NSObject that conforms to WCTValue, or nil if error occurs.\n */\n- (nullable WCTOneColumn *)allValues;\n\n/**\n @brief Extract all the values of the column at index in the result.\n @note It is for the statement previously prepared by `-[WCTHandle prepare:]` or `-[WCTHandle rawPrepare:]`.\n @return An array of NSObject that conforms to WCTValue, or nil if error occurs.\n */\n- (nullable WCTOneColumn *)allValuesAtIndex:(int)index;\n\n/**\n @brief Extract all the values in the result.\n @note It is for the statement previously prepared by `-[WCTHandle prepare:]` or `-[WCTHandle rawPrepare:]`.\n @return A two-dimensional array, or nil if error occurs.\n */\n- (nullable WCTColumnsXRows *)allRows;\n\n/**\n @brief Extract the values of all rows in the result and assign them into the properties specified by resultColumns of new WCTTableCoding objects.\n @note It is for the statement previously prepared by `-[WCTHandle prepare:]` or `-[WCTHandle rawPrepare:]`.\n @return An array of WCTTableCoding object, or nil if error occurs.\n */\n- (nullable NSArray /* <WCTObject*> */ *)allObjectsOnResultColumns:(const WCTResultColumns &)resultColumns;\n\n/**\n @brief Extract the results of a multi-table query.\n @note It is for the statement previously prepared by `-[WCTHandle prepare:]` or `-[WCTHandle rawPrepare:]`.\n @return An array of WCTMultiObject, or nil if error occurs.\n */\n- (nullable NSArray<WCTMultiObject *> *)allMultiObjectsOnResultColumns:(const WCTResultColumns &)resultColumns;\n\n#pragma mark - Cancellation signal\n/**\n @brief The wrapper of `sqlite3_progress_handler`.\n \n You can asynchronously cancel all operations on the current handle through `WCTCancellationSignal`.\n \n        WCTCancellationSignal *signal = [[WCTCancellationSignal alloc] init];\n        dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{\n            WCTHandle* handle = [database getHandle];\n            [handle attachCancellationSignal:signal];\n \n            // Do some time-consuming database operations.\n \n            [handle detachCancellationSignal];\n        });\n        [signal cancel];\n \n @warning Note that you can use `WCTCancellationSignal` in multiple threads,\n but you can only use the current handle in the thread that you got it.\n */\n- (void)attachCancellationSignal:(WCTCancellationSignal *)signal;\n\n/**\n @brief Detach the attached `WCTCancellationSignal`.\n        `WCTCancellationSignal` can be automatically detached when the current handle deconstruct.\n */\n- (void)detachCancellationSignal;\n\n#pragma mark - Error\n/**\n @brief Get the most recent error for current handle in the current thread.\n        Since it is too cumbersome to get the error after every operation, it‘s better to use monitoring interfaces to obtain errors and print them to the log.\n @see   `[WCTDatabase globalTraceError:]`\n @see   `[WCTDatabase traceError:]`\n \n @return WCTError\n */\n- (WCTError *)error;\n\n@end\n\nNS_ASSUME_NONNULL_END\n"
  },
  {
    "path": "src/objc/handle/WCTHandle.mm",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"Assertion.hpp\"\n#import \"Notifier.hpp\"\n#import \"WCTCancellationSignal+Private.h\"\n#import \"WCTDatabase+Private.h\"\n#import \"WCTError+Private.h\"\n#import \"WCTFoundation.h\"\n#import \"WCTHandle+Private.h\"\n#import \"WCTHandle+Transaction.h\"\n#import \"WCTORM.h\"\n#import \"WCTPreparedStatement+Private.h\"\n\n@implementation WCTHandle\n\n#pragma mark - LifeCycle\n- (instancetype)initWithDatabase:(WCTDatabase *)database andUnsafeHandle:(WCDB::InnerHandle *)handle\n{\n    WCTAssert(database != nil);\n    WCTAssert(handle != nil);\n    if (self = [super init]) {\n        _database = database;\n        _handle = handle;\n        _handleHolder = nullptr;\n        _writeHint = NO;\n    }\n    return self;\n}\n\n- (instancetype)initWithDatabase:(WCTDatabase *)database\n{\n    WCTAssert(database != nil);\n    if (self = [super init]) {\n        _database = database;\n        _writeHint = NO;\n    }\n    return self;\n}\n\n- (instancetype)initWithUnsafeHandle:(WCDB::InnerHandle *)handle\n{\n    WCTAssert(handle != nil);\n    if (self = [super init]) {\n        _handle = handle;\n        _handleHolder = nullptr;\n        _writeHint = NO;\n    }\n    return self;\n}\n\n- (WCDB::InnerHandle *)getOrGenerateHandle\n{\n    if (_handle == nullptr) {\n        _handleHolder = [_database generateHandle:_writeHint];\n        if (_handleHolder != nullptr) {\n            _handle = _handleHolder.get();\n        }\n    }\n    return _handle;\n}\n\n- (void)setWriteHint:(BOOL)writeHint\n{\n    if (_handle == nullptr) {\n        _writeHint = writeHint;\n    }\n}\n\n#pragma mark - Statement\n\n- (WCTPreparedStatement *)getOrCreatePreparedStatement:(const WCDB::Statement &)statement\n{\n    WCDB::InnerHandle *dbHandle = [self getOrGenerateHandle];\n    if (dbHandle == nil) {\n        return nil;\n    }\n    WCDB::HandleStatement *preparedHandleStatement = dbHandle->getOrCreatePreparedStatement(statement);\n    if (preparedHandleStatement == nullptr) {\n        return nullptr;\n    }\n    return [[WCTPreparedStatement alloc] initWithHandleStatement:preparedHandleStatement];\n}\n\n- (void)finalizeAllStatements\n{\n    if (_handle != nullptr) {\n        _handle->finalizeStatements();\n    }\n}\n\n#pragma mark - Handle\n- (BOOL)validate\n{\n    return [self getOrGenerateHandle] != nullptr;\n}\n\n- (void)invalidate\n{\n    _database = nil;\n    _handle = nullptr;\n    _handleHolder = nullptr;\n    _writeHint = NO;\n}\n\n- (BOOL)isValidated\n{\n    return _handle != nullptr;\n}\n\n- (WCTDatabase *)database\n{\n    return _database;\n}\n\n#pragma mark - Execute\n- (BOOL)execute:(const WCDB::Statement &)statement\n{\n    BOOL succeed = NO;\n    WCDB::InnerHandle *handle = [self getOrGenerateHandle];\n    if (handle != nullptr) {\n        succeed = handle->execute(statement);\n    }\n    return succeed;\n}\n\n//rawExecute should no be used to access or modify the data in a migrating table.\n- (BOOL)rawExecute:(NSString *)sql\n{\n    BOOL succeed = NO;\n    WCDB::InnerHandle *handle = [self getOrGenerateHandle];\n    if (handle != nullptr) {\n        succeed = handle->execute(sql);\n    }\n    return succeed;\n}\n\n#pragma mark - Prepare\n- (BOOL)prepare:(const WCDB::Statement &)statement\n{\n    BOOL succeed = NO;\n    WCDB::InnerHandle *handle = [self getOrGenerateHandle];\n    if (handle != nullptr) {\n        succeed = handle->prepare(statement);\n    }\n    return succeed;\n}\n\n//rawPrepare should no be used to access or modify the data in a migrating table.\n- (BOOL)rawPrepare:(NSString *)sql\n{\n    BOOL succeed = NO;\n    WCDB::InnerHandle *handle = [self getOrGenerateHandle];\n    if (handle != nullptr) {\n        succeed = handle->prepare(sql);\n    }\n    return succeed;\n}\n\n- (BOOL)isPrepared\n{\n    return _handle != nullptr && _handle->isPrepared();\n}\n\n- (void)finalizeStatement\n{\n    if (_handle != nullptr) {\n        _handle->finalize();\n    }\n}\n\n#pragma mark - Step\n- (BOOL)step\n{\n    WCTHandleAssert(return NO;);\n    return _handle->step();\n}\n\n- (BOOL)done\n{\n    WCTHandleAssert(return NO;);\n    return _handle->done();\n}\n\n- (void)reset\n{\n    WCTHandleAssert(return;);\n    _handle->reset();\n}\n\n- (void)clearBindings\n{\n    WCTHandleAssert(return;);\n    _handle->clearBindings();\n}\n\n#pragma mark - State\n- (long long)getLastInsertedRowID\n{\n    WCTHandleAssert(return 0;);\n    return _handle->getLastInsertedRowID();\n}\n\n- (int)getChanges\n{\n    WCTHandleAssert(return 0;);\n    return _handle->getChanges();\n}\n\n- (int)getTotalChanges\n{\n    WCTHandleAssert(return 0;);\n    return _handle->getTotalChange();\n}\n\n- (BOOL)isStatementReadonly\n{\n    WCTHandleAssert(return NO;);\n    return _handle->isStatementReadonly();\n}\n\n#pragma mark - Bind\n- (void)bindInteger:(const int64_t &)value toIndex:(int)index\n{\n    WCTHandleAssert(return;);\n    _handle->bindInteger(value, index);\n}\n\n- (void)bindDouble:(const double &)value toIndex:(int)index\n{\n    WCTHandleAssert(return;);\n    _handle->bindDouble(value, index);\n}\n\n- (void)bindNullToIndex:(int)index\n{\n    WCTHandleAssert(return;);\n    _handle->bindNull(index);\n}\n\n- (void)bindString:(NSString *)string toIndex:(int)index\n{\n    WCTHandleAssert(return;);\n    _handle->bindText(WCDB::UnsafeStringView(string), index);\n}\n\n- (void)bindData:(NSData *)data toIndex:(int)index\n{\n    WCTHandleAssert(return;);\n    _handle->bindBLOB(data, index);\n}\n\n- (void)bindNumber:(NSNumber *)number toIndex:(int)index\n{\n    WCTHandleAssert(return;);\n    if (number == nil || CFNumberIsFloatType((CFNumberRef) number)) {\n        _handle->bindDouble(number.doubleValue, index);\n    } else {\n        _handle->bindInteger(number.integerValue, index);\n    }\n}\n\n- (void)bindValue:(WCTColumnCodingValue *)value\n          toIndex:(int)index\n{\n    WCTHandleAssert(return;);\n    WCTValue *archivedValue = [value archivedWCTValue];\n    switch ([value.class columnType]) {\n    case WCTColumnTypeNull:\n        _handle->bindNull(index);\n        break;\n    case WCTColumnTypeInteger:\n        _handle->bindInteger(archivedValue.numberValue.longLongValue, index);\n        break;\n    case WCTColumnTypeFloat:\n        _handle->bindDouble(archivedValue.numberValue.doubleValue, index);\n        break;\n    case WCTColumnTypeString:\n        _handle->bindText(WCDB::UnsafeStringView(archivedValue.stringValue), index);\n        break;\n    case WCTColumnTypeData:\n        _handle->bindBLOB((NSData *) archivedValue, index);\n        break;\n    }\n}\n\n- (void)bindProperty:(const WCTProperty &)property\n            ofObject:(WCTObject *)object\n             toIndex:(int)index\n{\n    WCTHandleAssert(return;);\n    const std::shared_ptr<const WCTBaseAccessor> &accessor = property.getColumnBinding().getAccessor();\n    switch (accessor->getAccessorType()) {\n    case WCTAccessorCpp: {\n        switch (accessor->getColumnType()) {\n        case WCDB::ColumnType::Integer: {\n            WCTCppAccessor<WCDB::ColumnType::Integer> *integerAccessor = (WCTCppAccessor<WCDB::ColumnType::Integer> *) accessor.get();\n            _handle->bindInteger(integerAccessor->getValue(object),\n                                 index);\n        } break;\n        case WCDB::ColumnType::Float: {\n            WCTCppAccessor<WCDB::ColumnType::Float> *floatAccessor = (WCTCppAccessor<WCDB::ColumnType::Float> *) accessor.get();\n            _handle->bindDouble(floatAccessor->getValue(object),\n                                index);\n        } break;\n        case WCDB::ColumnType::Text: {\n            WCTCppAccessor<WCDB::ColumnType::Text> *textAccessor = (WCTCppAccessor<WCDB::ColumnType::Text> *) accessor.get();\n            _handle->bindText(textAccessor->getValue(object),\n                              index);\n        } break;\n        case WCDB::ColumnType::BLOB: {\n            WCTCppAccessor<WCDB::ColumnType::BLOB> *blobAccessor = (WCTCppAccessor<WCDB::ColumnType::BLOB> *) accessor.get();\n            _handle->bindBLOB(blobAccessor->getValue(object), index);\n        } break;\n        case WCDB::ColumnType::Null:\n            _handle->bindNull(index);\n            break;\n        }\n    } break;\n    case WCTAccessorObjC: {\n        WCTObjCAccessor *objcAccessor = (WCTObjCAccessor *) accessor.get();\n        NSObject *value = objcAccessor->getObject(object);\n        if (value != nil) {\n            switch (accessor->getColumnType()) {\n            case WCDB::ColumnType::Integer: {\n                _handle->bindInteger(((NSNumber *) value).longLongValue, index);\n                break;\n            }\n            case WCDB::ColumnType::Float: {\n                _handle->bindDouble(((NSNumber *) value).doubleValue, index);\n                break;\n            }\n            case WCDB::ColumnType::Text: {\n                _handle->bindText((NSString *) value, index);\n                break;\n            }\n            case WCDB::ColumnType::BLOB: {\n                _handle->bindBLOB((NSData *) value, index);\n                break;\n            }\n            case WCDB::ColumnType::Null:\n                _handle->bindNull(index);\n                break;\n            }\n        } else {\n            _handle->bindNull(index);\n        }\n    } break;\n    }\n}\n\n- (void)bindProperties:(const WCTProperties &)properties\n              ofObject:(WCTObject *)object\n{\n    WCTHandleAssert(return;);\n    int index = 1;\n    for (const auto &property : properties) {\n        [self bindProperty:property ofObject:object toIndex:index];\n        ++index;\n    }\n}\n\n- (int)bindParameterIndex:(const WCDB::BindParameter &)parameter\n{\n    WCTHandleAssert(return 0;);\n    return _handle->bindParameterIndex(parameter.getDescription());\n}\n\n#pragma mark - Get\n- (int64_t)extractIntegerAtIndex:(int)index\n{\n    WCTHandleAssert(return 0;);\n    return _handle->getInteger(index);\n}\n\n- (double)extractDoubleAtIndex:(int)index\n{\n    WCTHandleAssert(return 0;);\n    return _handle->getDouble(index);\n}\n\n- (NSString *)extractStringAtIndex:(int)index\n{\n    WCTHandleAssert(return nil;);\n    return [NSString stringWithView:_handle->getText(index)];\n}\n\n- (NSNumber *)extractNumberAtIndex:(int)index\n{\n    WCTHandleAssert(return nil;);\n    switch (_handle->getColumnType(index)) {\n    case WCDB::ColumnType::Integer:\n        return [NSNumber numberWithLongLong:_handle->getInteger(index)];\n    default:\n        return [NSNumber numberWithDouble:_handle->getDouble(index)];\n    }\n}\n\n- (NSData *)extractDataAtIndex:(int)index\n{\n    WCTHandleAssert(return nil;);\n    const WCDB::UnsafeData blob = _handle->getBLOB(index);\n    return [NSData dataWithBytes:blob.buffer() length:blob.size()];\n}\n\n- (WCTValue *)extractValueAtIndex:(int)index\n{\n    WCTHandleAssert(return nil;);\n    switch ([self extractTypeAtIndex:index]) {\n    case WCTColumnTypeInteger:\n        return [NSNumber numberWithLongLong:[self extractIntegerAtIndex:index]];\n    case WCTColumnTypeFloat:\n        return [NSNumber numberWithDouble:[self extractDoubleAtIndex:index]];\n    case WCTColumnTypeString:\n        return [self extractStringAtIndex:index];\n    case WCTColumnTypeData:\n        return [self extractDataAtIndex:index];\n    case WCTColumnTypeNull:\n        return nil;\n    }\n}\n\n- (WCTColumnType)extractTypeAtIndex:(int)index\n{\n    WCTHandleAssert(return WCTColumnTypeNull;);\n    return (WCTColumnType) _handle->getColumnType(index);\n}\n\n- (int)extractNumberOfColumns\n{\n    WCTHandleAssert(return 0;);\n    return _handle->getNumberOfColumns();\n}\n\n- (NSString *)extractOriginColumnNameAtIndex:(int)index\n{\n    WCTHandleAssert(return nil;);\n    return [NSString stringWithView:_handle->getOriginColumnName(index)];\n}\n\n- (NSString *)extractColumnNameAtIndex:(int)index\n{\n    WCTHandleAssert(return nil;);\n    return [NSString stringWithView:_handle->getColumnName(index)];\n}\n\n- (NSString *)extractTableNameAtIndex:(int)index\n{\n    WCTHandleAssert(return nil;);\n    return [NSString stringWithView:_handle->getColumnTableName(index)];\n}\n\n- (WCTOneRow *)extractRow\n{\n    WCTHandleAssert(return nil;);\n    int count = [self extractNumberOfColumns];\n    NSMutableArray *row = [NSMutableArray arrayWithCapacity:count];\n    for (int index = 0; index < count; ++index) {\n        WCTValue *value = [self extractValueAtIndex:index];\n        [row addObject:value ? value : [NSNull null]];\n    }\n    return row;\n}\n\n- (WCTObject *)extractObjectOnResultColumns:(const WCTResultColumns &)resultColumns\n{\n    WCTHandleAssert(return nil;);\n    Class cls = resultColumns.front().getColumnBinding().getClass();\n    WCTObject *object = [[cls alloc] init];\n    int index = 0;\n    for (const auto &resultColumn : resultColumns) {\n        [self extractValueAtIndex:index toColumnBindingHolder:resultColumn ofObject:object];\n        ++index;\n    }\n    return object;\n}\n\n- (WCTMultiObject *)extractMultiObjectOnResultColumns:(const WCTResultColumns &)resultColumns\n{\n    NSMutableDictionary *multiObject = [NSMutableDictionary dictionary];\n    int index = 0;\n    for (const WCTResultColumn &resultColumn : resultColumns) {\n        NSString *tableName = [NSString stringWithView:_handle->getColumnTableName(index)];\n        WCTObject *object = [multiObject objectForKey:tableName];\n        if (object == nil) {\n            object = [[resultColumn.getColumnBinding().getClass() alloc] init];\n            [multiObject setObject:object forKey:tableName];\n        }\n        [self extractValueAtIndex:index\n            toColumnBindingHolder:resultColumn\n                         ofObject:object];\n        ++index;\n    }\n    return multiObject;\n}\n\n- (void)extractValueAtIndex:(int)index toProperty:(const WCTProperty &)property ofObject:(WCTObject *)object\n{\n    [self extractValueAtIndex:index toColumnBindingHolder:property ofObject:object];\n}\n\n- (void)extractValueAtIndex:(int)index\n      toColumnBindingHolder:(const WCTColumnBindingHolder &)columnBindingHolder\n                   ofObject:(WCTObject *)object\n{\n    WCTHandleAssert(return;);\n    const std::shared_ptr<const WCTBaseAccessor> &accessor = columnBindingHolder.getColumnBinding().getAccessor();\n    switch (accessor->getAccessorType()) {\n    case WCTAccessorCpp: {\n        switch (accessor->getColumnType()) {\n        case WCDB::ColumnType::Integer: {\n            WCTCppAccessor<WCDB::ColumnType::Integer> *integerAccessor = (WCTCppAccessor<WCDB::ColumnType::Integer> *) accessor.get();\n            integerAccessor->setValue(object, _handle->getInteger(index));\n        } break;\n        case WCDB::ColumnType::Float: {\n            WCTCppAccessor<WCDB::ColumnType::Float> *floatAccessor = (WCTCppAccessor<WCDB::ColumnType::Float> *) accessor.get();\n            floatAccessor->setValue(object, _handle->getDouble(index));\n        } break;\n        case WCDB::ColumnType::Text: {\n            WCTCppAccessor<WCDB::ColumnType::Text> *textAccessor = (WCTCppAccessor<WCDB::ColumnType::Text> *) accessor.get();\n            textAccessor->setValue(object, _handle->getText(index));\n        } break;\n        case WCDB::ColumnType::BLOB: {\n            WCTCppAccessor<WCDB::ColumnType::BLOB> *blobAccessor = (WCTCppAccessor<WCDB::ColumnType::BLOB> *) accessor.get();\n            blobAccessor->setValue(object, _handle->getBLOB(index));\n        } break;\n        case WCDB::ColumnType::Null: {\n            WCTCppAccessor<WCDB::ColumnType::Null> *nullAccessor = (WCTCppAccessor<WCDB::ColumnType::Null> *) accessor.get();\n            nullAccessor->setValue(object, nullptr);\n        } break;\n        }\n    } break;\n    case WCTAccessorObjC: {\n        WCTObjCAccessor *objcAccessor = (WCTObjCAccessor *) accessor.get();\n        id value = nil;\n        if (_handle->getColumnType(index) != WCDB::ColumnType::Null) {\n            switch (accessor->getColumnType()) {\n            case WCDB::ColumnType::Integer:\n                value = [NSNumber numberWithLongLong:_handle->getInteger(index)];\n                break;\n            case WCDB::ColumnType::Float:\n                value = [NSNumber numberWithDouble:_handle->getDouble(index)];\n                break;\n            case WCDB::ColumnType::Text:\n                value = [NSString stringWithView:_handle->getText(index)];\n                break;\n            case WCDB::ColumnType::BLOB: {\n                const WCDB::UnsafeData data = _handle->getBLOB(index);\n                value = [NSData dataWithBytes:data.buffer() length:data.size()];\n            } break;\n            case WCDB::ColumnType::Null:\n                value = nil;\n                break;\n            }\n        }\n        objcAccessor->setObject(object, value);\n    } break;\n    }\n}\n\n#pragma mark - Get All\n- (WCTOneColumn *)allValues\n{\n    WCTHandleAssert(return nil;);\n    return [self allValuesAtIndex:0];\n}\n\n- (WCTOneColumn *)allValuesAtIndex:(int)index\n{\n    WCTHandleAssert(return nil;);\n    NSMutableArray *column = [NSMutableArray array];\n    BOOL succeed = NO;\n    while ((succeed = [self step]) && ![self done]) {\n        WCTValue *value = [self extractValueAtIndex:index];\n        [column addObject:value ? value : [NSNull null]];\n    }\n    return succeed ? column : nil;\n}\n\n- (WCTColumnsXRows *)allRows\n{\n    WCTHandleAssert(return nil;);\n    NSMutableArray *rows = [NSMutableArray array];\n    BOOL succeed = NO;\n    while ((succeed = [self step]) && ![self done]) {\n        [rows addObject:[self extractRow]];\n    }\n    return succeed ? rows : nil;\n}\n\n- (NSArray /* <WCTObject*> */ *)allObjectsOnResultColumns:(const WCTResultColumns &)resultColumns\n{\n    WCTHandleAssert(return nil;);\n    NSMutableArray *objects = [NSMutableArray array];\n    BOOL succeed = NO;\n    while ((succeed = [self step]) && ![self done]) {\n        [objects addObject:[self extractObjectOnResultColumns:resultColumns]];\n    }\n    return succeed ? objects : nil;\n}\n\n- (NSArray<WCTMultiObject *> *)allMultiObjectsOnResultColumns:(const WCTResultColumns &)resultColumns\n{\n    WCTHandleAssert(return nil;);\n    NSMutableArray *multiObjects = [NSMutableArray array];\n    BOOL succeed = NO;\n    while ((succeed = [self step]) && ![self done]) {\n        [multiObjects addObject:[self extractMultiObjectOnResultColumns:resultColumns]];\n    }\n    return succeed ? multiObjects : nil;\n}\n\n#pragma mark - Cancellation signal\n- (void)attachCancellationSignal:(WCTCancellationSignal *)signal\n{\n    [self getOrGenerateHandle];\n    WCTHandleAssert(return;);\n    _handle->attachCancellationSignal([signal getInnerSignal]);\n}\n\n- (void)detachCancellationSignal\n{\n    WCTHandleAssert(return;);\n    _handle->detachCancellationSignal();\n}\n\n#pragma mark - Error\n- (WCTError *)error\n{\n    if (_handle != nullptr) {\n        return [[WCTError alloc] initWithError:_handle->getError()];\n    } else {\n        return _database.error;\n    }\n}\n\n#pragma mark - Helper\n- (BOOL)lazyRunTransaction:(WCTTransactionBlock)transaction\n{\n    WCDB::InnerHandle *handle = [self getOrGenerateHandle];\n    if (handle == nullptr) {\n        return NO;\n    }\n    if (handle->isInTransaction()) {\n        return transaction(self);\n    } else {\n        handle->markErrorNotAllowedWithinTransaction();\n        return [self runTransaction:transaction];\n    }\n}\n\n@end\n"
  },
  {
    "path": "src/objc/migration/WCTDatabase+Migration.h",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"WCTDatabase.h\"\n#import \"WCTMigrationInfo.h\"\n\nNS_ASSUME_NONNULL_BEGIN\n\n/**\n Triggered at any time when WCDB needs to know whether a table in the current database needs to migrate data,\n mainly including creating a new table, reading and writing a table, and starting to migrate a new table.\n If the current table does not need to migrate data, you need to set the sourceTable in `WCTMigrationUserInfo` to nil.\n */\ntypedef void (^WCTMigrationFilterBlock)(WCTMigrationUserInfo*);\n\n/**\n Triggered when a table is migrated completely.\n When a table is migrated successfully, tableInfo will carry the information of the table.\n When a database is migrated, tableInfo will .\n */\ntypedef void (^WCTMigratedNotificationBlock)(WCTDatabase* _Nonnull database, WCTMigrationBaseInfo* _Nullable tableInfo);\n\nWCDB_API @interface WCTDatabase(Migration)\n\n/**\n @brief Configure which tables in the current database need to migrate data, and the source table they need to migrate data from.\n Once configured, you can treat the target table as if it already has all the data of the source table, and can read and write these data through the target table. WCDB will internally convert your CRUD operations on the target table into the CRUD operations on both the target table and the source table appropriately. You neither need to be aware of the existence of the source table, nor care about the progress of data migration.\n @warning  The column definition of the target table must be exactly the same as the column definition of the source table. The database does not record the state of the migration to disk, so if you have data to migrate, you need to use this method to configure the migration before executing any statements on current database.\n @note  If the source table is in the current database, you can set sourceDatabasePath to nil.\n @note  If the source table is not in the current database, the database containing the source table will be attached to the current database before the migration is complete. After migration, source tables will be dropped.\n @see   `WCTMigrationFilterBlock`\n */\n- (void)addMigration:(nullable NSString*)sourceDatabasePath\n          withFilter:(nullable WCDB_ESCAPE WCTMigrationFilterBlock)filter;\n\n- (void)addMigration:(nullable NSString*)sourceDatabasePath\n    withSourceCipher:(nullable NSData*)cipher\n          withFilter:(nullable WCDB_ESCAPE WCTMigrationFilterBlock)filter;\n\n/**\n @brief Manually spend about 0.01 sec. to migrate data. You can call this method periodically until all data is migrated.\n @return YES if no error occurred.\n */\n- (BOOL)stepMigration;\n\n/**\n @brief Configure the database to automatically step migration every two seconds.\n @param flag to enable auto-migration.\n */\n- (void)enableAutoMigration:(BOOL)flag;\n\n/**\n @brief Register a callback for migration notification. The callback will be called when each table completes the migration.\n @param onMigrated block\n @see   `WCTMigratedNotificationBlock`\n */\n- (void)setNotificationWhenMigrated:(nullable WCDB_ESCAPE WCTMigratedNotificationBlock)onMigrated;\n\n/**\n @brief Check if all tables in the database has finished migration.\n @note  It only check an internal flag of database.\n @return YES if all tables in the database has finished migration.\n */\n- (BOOL)isMigrated;\n\n@end\n\nNS_ASSUME_NONNULL_END\n"
  },
  {
    "path": "src/objc/migration/WCTDatabase+Migration.mm",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"CoreConst.h\"\n#import \"WCTDatabase+Migration.h\"\n#import \"WCTDatabase+Private.h\"\n#import \"WCTMigrationInfo+Private.h\"\n\n@implementation WCTDatabase (Migration)\n\n- (void)addMigration:(nullable NSString*)sourceDatabasePath\n          withFilter:(nullable WCDB_ESCAPE WCTMigrationFilterBlock)filter\n{\n    [self addMigration:sourceDatabasePath withSourceCipher:nil withFilter:filter];\n}\n\n- (void)addMigration:(nullable NSString*)sourceDatabasePath\n    withSourceCipher:(nullable NSData*)cipher\n          withFilter:(nullable WCDB_ESCAPE WCTMigrationFilterBlock)filter\n{\n    WCDB::InnerDatabase::MigrationTableFilter callback = nullptr;\n    if (filter != nil) {\n        callback = [filter](WCDB::MigrationUserInfo& userInfo) {\n            WCTMigrationUserInfo* nsUserInfo = [[WCTMigrationUserInfo alloc] initWithBaseInfo:userInfo];\n            filter(nsUserInfo);\n            if (nsUserInfo.sourceTable.length > 0) {\n                userInfo.setSource(nsUserInfo.sourceTable);\n                userInfo.setFilter(nsUserInfo.filterCondition);\n            }\n        };\n    }\n    _database->addMigration(sourceDatabasePath, cipher, callback);\n}\n\n- (BOOL)stepMigration\n{\n    auto done = _database->stepMigration(false);\n    return done.succeed();\n}\n\n- (void)enableAutoMigration:(BOOL)flag\n{\n    WCDB::CommonCore::shared().enableAutoMigrate(_database, flag);\n}\n\n- (void)setNotificationWhenMigrated:(WCTMigratedNotificationBlock)onMigrated\n{\n    WCDB::InnerDatabase::MigratedCallback callback = nullptr;\n    if (onMigrated != nil) {\n        callback = [onMigrated](WCDB::InnerDatabase* database, const WCDB::MigrationBaseInfo* info) {\n            WCTMigrationBaseInfo* nsInfo = nil;\n            if (info != nil) {\n                nsInfo = [[WCTMigrationBaseInfo alloc] initWithBaseInfo:*info];\n            }\n            WCTDatabase* nsDatabase = [[WCTDatabase alloc] initWithUnsafeDatabase:database];\n            onMigrated(nsDatabase, nsInfo);\n        };\n    }\n    _database->setNotificationWhenMigrated(callback);\n}\n\n- (BOOL)isMigrated\n{\n    return _database->isMigrated();\n}\n\n@end\n"
  },
  {
    "path": "src/objc/migration/WCTMigrationInfo+Private.h",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"CommonCore.h\"\n#import \"WCTMigrationInfo.h\"\n\nNS_ASSUME_NONNULL_BEGIN\n\n@interface WCTMigrationBaseInfo () {\n@protected\n    NSString* _sourceTable;\n    NSString* _sourceDatabase;\n    WCDB::Expression _filterCondition;\n}\n\n- (instancetype)initWithBaseInfo:(const WCDB::MigrationBaseInfo&)info;\n\n@end\n\nNS_ASSUME_NONNULL_END\n"
  },
  {
    "path": "src/objc/migration/WCTMigrationInfo.h",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"WCTCommon.h\"\n\nNS_ASSUME_NONNULL_BEGIN\n\nWCDB_API @interface WCTMigrationBaseInfo : NSObject\n\n- (instancetype)init UNAVAILABLE_ATTRIBUTE;\n\n// Target table of migration\n@property (nonatomic, readonly) NSString* table;\n// Source table of migration\n@property (nonatomic, readonly) NSString* sourceTable;\n// Filter condition of source table\n@property (nonatomic, readonly) WCDB::Expression filterCondition;\n\n@end\n\nWCDB_API @interface WCTMigrationUserInfo : WCTMigrationBaseInfo\n\n// Set new value to sourceTable in WCTMigrationBaseInfo.\n- (void)setSourceTable:(NSString*)table;\n// Set new value to filterCondition in WCTMigrationBaseInfo.\n- (void)setFilterCondition:(const WCDB::Expression&)condition;\n\n@end\n\nNS_ASSUME_NONNULL_END\n"
  },
  {
    "path": "src/objc/migration/WCTMigrationInfo.mm",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"WCTMigrationInfo.h\"\n#import \"WCTFoundation.h\"\n#import \"WCTMigrationInfo+Private.h\"\n\n@implementation WCTMigrationBaseInfo\n\n- (instancetype)initWithBaseInfo:(const WCDB::MigrationBaseInfo &)info\n{\n    if (self = [super init]) {\n        _table = [NSString stringWithView:info.getTable()];\n        _sourceTable = [NSString stringWithView:info.getSourceTable()];\n        _filterCondition = info.getFilterCondition();\n    }\n    return self;\n}\n\n@end\n\n@implementation WCTMigrationUserInfo\n\n- (void)setSourceTable:(NSString *)table\n{\n    _sourceTable = table;\n}\n\n- (void)setFilterCondition:(const WCDB::Expression &)condition\n{\n    _filterCondition = condition;\n}\n\n@end\n"
  },
  {
    "path": "src/objc/monitor/WCTDatabase+Monitor.h",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"WCTCommon.h\"\n#import \"WCTDatabase.h\"\n#import \"WCTPerformanceInfo.h\"\n\nNS_ASSUME_NONNULL_BEGIN\n\n/**\n Trigger when error occurs\n */\ntypedef void (^WCTErrorTraceBlock)(WCTError*);\n\n/**\n Triggered when a transaction or a normal sql ends.\n */\ntypedef void (^WCTPerformanceTraceBlock)(WCTTag /* tag */, NSString* /* path */, uint64_t /*handleIdentifier*/, NSString* /* sql */, WCTPerformanceInfo* /* info */);\n\n/**\n Triggered when a SQL is executed.\n */\ntypedef void (^WCTSQLTraceBlock)(WCTTag /* tag */, NSString* /* path */, uint64_t /*handleIdentifier*/, NSString* /* sql */, NSString* /*info*/);\n\ntypedef NS_ENUM(NSUInteger, WCTDatabaseOperation) {\n    WCTDatabaseOperation_Create = 0,\n    WCTDatabaseOperation_SetTag,\n    WCTDatabaseOperation_OpenHandle,\n};\n\n/**\n Triggered when a specific event of database occurs.\n */\ntypedef void (^WCTDatabaseOperationTraceBlock)(WCTDatabase* /* database */, WCTDatabaseOperation /* type of operation*/, NSDictionary* /* infos about current operation */);\n\n/**\n Triggered when the database operation is blocked by other threads.\n */\ntypedef void (^WCTDatabaseBusyTraceBlock)(WCTTag /* tag */,\n                                          NSString* /* path */,\n                                          uint64_t /* id of the thread being waited on */,\n                                          NSString* /* sql executing in the thread being waited on */\n);\n\n/**\n The following are the keys in the infos from the callback of database operation monitoring.\n */\n// The number of alive handles to the current database\nWCDB_EXTERN NSString* const WCTDatabaseMonitorInfoKeyHandleCount;\n// The time in microseconds spent to open and config the current handle.\nWCDB_EXTERN NSString* const WCTDatabaseMonitorInfoKeyHandleOpenTime;\n// The cpu time in microseconds spent to open and config the current handle.\nWCDB_EXTERN NSString* const WCTDatabaseMonitorInfoKeyHandleOpenCPUTime;\n// The memory in bytes used to store the schema in sqlite handle.\nWCDB_EXTERN NSString* const WCTDatabaseMonitorInfoKeySchemaUsage;\n// The number of tables in the current database.\nWCDB_EXTERN NSString* const WCTDatabaseMonitorInfoKeyTableCount;\n// The number of indexes in the current database.\nWCDB_EXTERN NSString* const WCTDatabaseMonitorInfoKeyIndexCount;\n// The number of triggers in the current database.\nWCDB_EXTERN NSString* const WCTDatabaseMonitorInfoKeyTriggerCount;\n\nWCDB_API @interface WCTDatabase(Monitor)\n\n/**\n @brief You can register a reporter to monitor all errors.\n \n     [WCTDatabase globalTraceError:^(WCTError* error) {\n        NSLog(@\"%@\", error);\n     }];\n \n @param block block\n @see `WCTErrorTraceBlock`\n */\n+ (void)globalTraceError:(nullable WCDB_ESCAPE WCTErrorTraceBlock)block;\n\n/**\n @brief You can register a reporter to monitor all errors of current database,.\n @param block block\n @see `WCTErrorTraceBlock`\n */\n- (void)traceError:(nullable WCDB_ESCAPE WCTErrorTraceBlock)block;\n\n/**\n @brief You can register a tracer to monitor the performance of all SQLs.\n It returns:\n     1. Every SQL executed by the database.\n     2. Time consuming in nanoseconds.\n     3. Number of reads and writes on different types of db pages.\n     4. Tag of database.\n     5. Path of database.\n     6. The id of the handle executing this SQL.\n \n @note  You should register trace before all db operations. Global tracer and db tracer do not interfere with each other.\n \n     [WCTDatabase globalTracePerformance:^(WCTTag tag, NSString* path, uint64_t handleIdentifier, NSString* sql, WCTPerformanceInfo *info) {\n        NSLog(@\"Tag: %ld\", tag);\n        NSLog(@\"Path: %@\", path);\n        NSLog(@\"The handle with id %llu took %lld nanoseconds to execute %@\", handleIdentifier, info.costInNanoseconds, sql);\n     }];\n \n @warning Tracer may cause WCDB performance degradation, according to your needs to choose whether to open.\n @param trace trace\n @see `WCTPerformanceTraceBlock`\n */\n+ (void)globalTracePerformance:(nullable WCDB_ESCAPE WCTPerformanceTraceBlock)trace;\n\n/**\n @brief You can register a tracer to monitor the performance of all SQLs executed in the current database.\n @warning Tracer may cause WCDB performance degradation, according to your needs to choose whether to open.\n @param trace trace\n @see `WCTPerformanceTraceBlock`\n */\n- (void)tracePerformance:(nullable WCDB_ESCAPE WCTPerformanceTraceBlock)trace;\n\n/**\n @brief You can register a tracer to monitor the execution of all SQLs.\n It returns:\n     1. Every SQL executed by the database.\n     2. Tag of database.\n     3. Path of database.\n     4. The id of the handle executing this SQL.\n     5. Detailed execution information of SQL. It is valid only when full sql trace is enable.\n \n @note  You should register trace before all db operations. Global tracer and db tracer do not interfere with each other.\n \n     [WCTDatabase globalTraceSQL:^(WCTTag tag, NSString* path, uint64_t handleIdentifier, NSString* sql, NSString *info) {\n        NSLog(@\"Tag: %ld\", tag);\n        NSLog(@\"Path: %%@\", path);\n        NSLog(@\"The handle with id %llu executed %@\", handleIdentifier, sql);\n        NSLog(@\"Excution info %@\", info);\n     }];\n \n @warning Tracer may cause WCDB performance degradation, according to your needs to choose whether to open.\n @see `WCTSQLTraceBlock`\n @param trace trace\n */\n+ (void)globalTraceSQL:(nullable WCDB_ESCAPE WCTSQLTraceBlock)trace;\n\n/**\n @brief You can register a tracer to monitor the execution of all SQLs executed in the current database.\n @note  You should register trace before all db operations.\n @warning Tracer may cause WCDB performance degradation, according to your needs to choose whether to open.\n @see `WCTSQLTraceBlock`\n @param trace trace\n */\n- (void)traceSQL:(nullable WCDB_ESCAPE WCTSQLTraceBlock)trace;\n\n/**\n @brief Enable to collect more SQL execution information in SQL tracer.\n @note  The detailed execution information of sql will include all bind parameters, step counts of `SELECT` statement,\n    last inserted rowid of `INSERT` statement, changes of `UPDATE` and `DELETE` statements.\n    These infomation will be returned in the last parameter of `WCTSQLTraceBlock`.\n @warning Collecting these infomation will significantly reduce the performance of WCDB,\n    please enable it only when necessary, and disable it when unnecessary.\n @see `WCTSQLTraceBlock`\n @param enable enable or not.\n */\n- (void)enableFullSQLTrace:(BOOL)enable;\n\n/**\n @brief You can register a tracer to these database events:\n     1. creating a database object for the first time;\n     2. setting a tag on the database;\n     3. opening a new database handle.\n @see `WCTDatabaseOperationTraceBlock`\n @param trace tracer.\n */\n+ (void)globalTraceDatabaseOperation:(nullable WCDB_ESCAPE WCTDatabaseOperationTraceBlock)trace;\n\n/**\n @brief You can register a tracer to database busy events.\n It returns:\n     1. Tag of database being busy.\n     2. Path of database being busy.\n     3. ID of the thread being waited on.\n     4. SQL executing in the thread being waited on.\n @warning Since the tracer will be called back synchronously\n    when the database operation is blocked and times out,\n    you can neither directly access the busy database\n    nor perform heavy operation in the tracer.\n @see `WCTDatabaseBusyTraceBlock`\n @param trace tracer.\n @param timeOut timeout in seconds for blocking database operation\n */\n+ (void)globalTraceBusy:(nullable WCDB_ESCAPE WCTDatabaseBusyTraceBlock)trace withTimeOut:(double)timeOut;\n\n@end\n\nNS_ASSUME_NONNULL_END\n"
  },
  {
    "path": "src/objc/monitor/WCTDatabase+Monitor.mm",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"Assertion.hpp\"\n#import \"CommonCore.hpp\"\n#import \"Console.hpp\"\n#import \"DBOperationNotifier.hpp\"\n#import \"WCTConvertible.h\"\n#import \"WCTDatabase+Monitor.h\"\n#import \"WCTDatabase+Private.h\"\n#import \"WCTError+Private.h\"\n#import \"WCTFoundation.h\"\n#import \"WCTPerformanceInfo+Private.h\"\n\nnamespace WCDB {\n\nvoid CommonCore::print(const UnsafeStringView& message)\n{\n#if WCDB_DEBUG\n    NSLog(@\"%s\", message.data());\n#endif\n}\n\n} // namespace WCDB\n\nNSString* const WCTDatabaseMonitorInfoKeyHandleCount = [NSString stringWithUTF8String:WCDB::k_MonitorInfoKeyHandleCount];\nNSString* const WCTDatabaseMonitorInfoKeyHandleOpenTime = [NSString stringWithUTF8String:WCDB::k_MonitorInfoKeyHandleOpenTime];\nNSString* const WCTDatabaseMonitorInfoKeyHandleOpenCPUTime = [NSString stringWithUTF8String:WCDB::k_MonitorInfoKeyHandleOpenCPUTime];\nNSString* const WCTDatabaseMonitorInfoKeySchemaUsage = [NSString stringWithUTF8String:WCDB::k_MonitorInfoKeySchemaUsage];\nNSString* const WCTDatabaseMonitorInfoKeyTableCount = [NSString stringWithUTF8String:WCDB::k_MonitorInfoKeyTableCount];\nNSString* const WCTDatabaseMonitorInfoKeyIndexCount = [NSString stringWithUTF8String:WCDB::k_MonitorInfoKeyIndexCount];\nNSString* const WCTDatabaseMonitorInfoKeyTriggerCount = [NSString stringWithUTF8String:WCDB::k_MonitorInfoKeyTriggerCount];\n\n@implementation WCTDatabase (Monitor)\n\n+ (void)globalTraceError:(WCTErrorTraceBlock)block\n{\n    if (block != nil) {\n        WCDB::CommonCore::shared().setNotificationWhenErrorTraced([block](const WCDB::Error& error) {\n            WCTError* nsError = [[WCTError alloc] initWithError:error];\n            block(nsError);\n        });\n    } else {\n        WCDB::CommonCore::shared().setNotificationWhenErrorTraced(nullptr);\n    }\n}\n\n- (void)traceError:(nullable WCDB_ESCAPE WCTErrorTraceBlock)block\n{\n    if (block != nil) {\n        WCDB::CommonCore::shared().setNotificationWhenErrorTraced(self.path, [block](const WCDB::Error& error) {\n            WCTError* nsError = [[WCTError alloc] initWithError:error];\n            block(nsError);\n        });\n    } else {\n        WCDB::CommonCore::shared().setNotificationWhenErrorTraced(self.path, nullptr);\n    }\n}\n\n+ (void)globalTracePerformance:(WCTPerformanceTraceBlock)trace\n{\n    WCDB::InnerHandle::PerformanceNotification callback = nullptr;\n    if (trace != nil) {\n        callback = [trace](const WCDB::Tag& tag, const WCDB::UnsafeStringView& path, const void* handle, const WCDB::UnsafeStringView& sql, const WCDB::InnerHandle::PerformanceInfo& info) {\n            WCTPerformanceInfo* nsInfo = [[WCTPerformanceInfo alloc] initWithPerformanceInfo:info];\n            trace(tag, [NSString stringWithUTF8String:path.data()], (uint64_t) handle, [NSString stringWithUTF8String:sql.data()], nsInfo);\n        };\n    }\n    WCDB::CommonCore::shared().setNotificationWhenPerformanceGlobalTraced(callback);\n}\n\n- (void)tracePerformance:(WCTPerformanceTraceBlock)trace\n{\n    if (trace != nil) {\n        WCDB::InnerHandle::PerformanceNotification callback = [trace](const WCDB::Tag& tag, const WCDB::UnsafeStringView& path, const void* handle, const WCDB::UnsafeStringView& sql, const WCDB::InnerHandle::PerformanceInfo& info) {\n            WCTPerformanceInfo* nsInfo = [[WCTPerformanceInfo alloc] initWithPerformanceInfo:info];\n            trace(tag, [NSString stringWithUTF8String:path.data()], (uint64_t) handle, [NSString stringWithUTF8String:sql.data()], nsInfo);\n        };\n        _database->setConfig(WCDB::PerformanceTraceConfigName,\n                             std::static_pointer_cast<WCDB::Config>(std::make_shared<WCDB::PerformanceTraceConfig>(callback)),\n                             WCDB::Configs::Priority::Highest);\n    } else {\n        _database->removeConfig(WCDB::PerformanceTraceConfigName);\n    }\n}\n\n- (void)traceSQL:(WCTSQLTraceBlock)trace\n{\n    if (trace != nil) {\n        WCDB::InnerHandle::SQLNotification callback = [trace](const WCDB::Tag& tag,\n                                                              const WCDB::UnsafeStringView& path,\n                                                              const void* handle,\n                                                              const WCDB::UnsafeStringView& sql,\n                                                              const WCDB::UnsafeStringView& info) {\n            trace(tag, [NSString stringWithUTF8String:path.data()], (uint64_t) handle, [NSString stringWithView:sql], info.length() > 0 ? [NSString stringWithView:info.data()] : nil);\n        };\n        _database->setConfig(WCDB::SQLTraceConfigName,\n                             std::static_pointer_cast<WCDB::Config>(std::make_shared<WCDB::SQLTraceConfig>(callback)),\n                             WCDB::Configs::Priority::Highest);\n    } else {\n        _database->removeConfig(WCDB::SQLTraceConfigName);\n    }\n}\n\n+ (void)globalTraceSQL:(WCTSQLTraceBlock)trace\n{\n    WCDB::InnerHandle::SQLNotification callback = nullptr;\n    if (trace != nil) {\n        callback = [trace](const WCDB::Tag& tag,\n                           const WCDB::UnsafeStringView& path,\n                           const void* handle,\n                           const WCDB::UnsafeStringView& sql,\n                           const WCDB::UnsafeStringView& info) {\n            trace(tag, [NSString stringWithUTF8String:path.data()], (uint64_t) handle, [NSString stringWithView:sql], info.length() > 0 ? [NSString stringWithView:info.data()] : nil);\n        };\n    }\n    WCDB::CommonCore::shared().setNotificationForSQLGLobalTraced(callback);\n}\n\n- (void)enableFullSQLTrace:(BOOL)enable\n{\n    _database->setFullSQLTraceEnable(enable);\n}\n\n+ (void)globalTraceDatabaseOperation:(nullable WCDB_ESCAPE WCTDatabaseOperationTraceBlock)trace\n{\n    if (trace != nil) {\n        WCDB::DBOperationNotifier::shared().setNotification([=](WCDB::InnerDatabase* innerDatabase, WCDB::DBOperationNotifier::Operation operation, const WCDB::StringViewMap<WCDB::Value>& info) {\n            WCTDatabase* database = [[WCTDatabase alloc] initWithUnsafeDatabase:innerDatabase];\n            NSMutableDictionary* nsInfo = [[NSMutableDictionary alloc] init];\n            for (auto iter = info.begin(); iter != info.end(); iter++) {\n                NSString* key = [NSString stringWithUTF8String:iter->first.data()];\n                switch (iter->second.getType()) {\n                case WCDB::Value::Type::Integer: {\n                    nsInfo[key] = @(iter->second.intValue());\n                } break;\n                case WCDB::Value::Type::Float: {\n                    nsInfo[key] = @(iter->second.floatValue());\n                } break;\n                case WCDB::Value::Type::Text: {\n                    nsInfo[key] = [NSString stringWithUTF8String:iter->second.textValue().data()];\n                } break;\n                case WCDB::Value::Type::BLOB: {\n                    const WCDB::Data& value = iter->second.blobValue();\n                    nsInfo[key] = [NSData dataWithBytes:value.buffer() length:value.size()];\n                } break;\n                default:\n                    break;\n                }\n            }\n            trace(database, (WCTDatabaseOperation) operation, nsInfo);\n        });\n    } else {\n        WCDB::DBOperationNotifier::shared().setNotification(nil);\n    }\n}\n\n+ (void)globalTraceBusy:(nullable WCDB_ESCAPE WCTDatabaseBusyTraceBlock)trace withTimeOut:(double)timeOut\n{\n    if (trace != nil && timeOut > 0) {\n        WCDB::CommonCore::shared().setBusyMonitor([=](const WCDB::Tag& tag, const WCDB::UnsafeStringView& path, uint64_t tid, const WCDB::UnsafeStringView& sql) {\n            trace(tag, [NSString stringWithUTF8String:path.data()], tid, [NSString stringWithUTF8String:sql.data()]);\n        },\n                                                  timeOut);\n    } else {\n        WCDB::CommonCore::shared().setBusyMonitor(nullptr, 0);\n    }\n}\n\n@end\n"
  },
  {
    "path": "src/objc/monitor/WCTError+Private.h",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"CommonCore.h\"\n#import \"CoreConst.h\"\n#import \"WCTError.h\"\n\nWCDB_API @interface WCTError()\n\n- (instancetype)initWithError:(const WCDB::Error &)error;\n\n@end\n\nstatic_assert((NSUInteger) WCTErrorLevelIgnore == (NSUInteger) WCDB::Error::Level::Ignore, \"\");\nstatic_assert((NSUInteger) WCTErrorLevelDebug == (NSUInteger) WCDB::Error::Level::Debug, \"\");\nstatic_assert((NSUInteger) WCTErrorLevelWarning == (NSUInteger) WCDB::Error::Level::Warning, \"\");\nstatic_assert((NSUInteger) WCTErrorLevelError == (NSUInteger) WCDB::Error::Level::Error, \"\");\nstatic_assert((NSUInteger) WCTErrorLevelNotice == (NSUInteger) WCDB::Error::Level::Notice, \"\");\nstatic_assert((NSUInteger) WCTErrorLevelFatal == (NSUInteger) WCDB::Error::Level::Fatal, \"\");\n\nstatic_assert((NSUInteger) WCTErrorCodeOK == (NSUInteger) WCDB::Error::Code::OK, \"\");\nstatic_assert((NSUInteger) WCTErrorCodeError == (NSUInteger) WCDB::Error::Code::Error, \"\");\nstatic_assert((NSUInteger) WCTErrorCodeInternal == (NSUInteger) WCDB::Error::Code::Internal, \"\");\nstatic_assert((NSUInteger) WCTErrorCodePermission == (NSUInteger) WCDB::Error::Code::Permission, \"\");\nstatic_assert((NSUInteger) WCTErrorCodeAbort == (NSUInteger) WCDB::Error::Code::Abort, \"\");\nstatic_assert((NSUInteger) WCTErrorCodeBusy == (NSUInteger) WCDB::Error::Code::Busy, \"\");\nstatic_assert((NSUInteger) WCTErrorCodeLocked == (NSUInteger) WCDB::Error::Code::Locked, \"\");\nstatic_assert((NSUInteger) WCTErrorCodeNoMemory == (NSUInteger) WCDB::Error::Code::NoMemory, \"\");\nstatic_assert((NSUInteger) WCTErrorCodeReadonly == (NSUInteger) WCDB::Error::Code::Readonly, \"\");\nstatic_assert((NSUInteger) WCTErrorCodeInterrupt == (NSUInteger) WCDB::Error::Code::Interrupt, \"\");\nstatic_assert((NSUInteger) WCTErrorCodeIOError == (NSUInteger) WCDB::Error::Code::IOError, \"\");\nstatic_assert((NSUInteger) WCTErrorCodeCorrupt == (NSUInteger) WCDB::Error::Code::Corrupt, \"\");\nstatic_assert((NSUInteger) WCTErrorCodeNotFound == (NSUInteger) WCDB::Error::Code::NotFound, \"\");\nstatic_assert((NSUInteger) WCTErrorCodeFull == (NSUInteger) WCDB::Error::Code::Full, \"\");\nstatic_assert((NSUInteger) WCTErrorCodeCantOpen == (NSUInteger) WCDB::Error::Code::CantOpen, \"\");\nstatic_assert((NSUInteger) WCTErrorCodeProtocol == (NSUInteger) WCDB::Error::Code::Protocol, \"\");\nstatic_assert((NSUInteger) WCTErrorCodeEmpty == (NSUInteger) WCDB::Error::Code::Empty, \"\");\nstatic_assert((NSUInteger) WCTErrorCodeSchema == (NSUInteger) WCDB::Error::Code::Schema, \"\");\nstatic_assert((NSUInteger) WCTErrorCodeExceed == (NSUInteger) WCDB::Error::Code::Exceed, \"\");\nstatic_assert((NSUInteger) WCTErrorCodeConstraint == (NSUInteger) WCDB::Error::Code::Constraint, \"\");\nstatic_assert((NSUInteger) WCTErrorCodeMismatch == (NSUInteger) WCDB::Error::Code::Mismatch, \"\");\nstatic_assert((NSUInteger) WCTErrorCodeMisuse == (NSUInteger) WCDB::Error::Code::Misuse, \"\");\nstatic_assert((NSUInteger) WCTErrorCodeNoLargeFileSupport == (NSUInteger) WCDB::Error::Code::NoLargeFileSupport, \"\");\nstatic_assert((NSUInteger) WCTErrorCodeAuthorization == (NSUInteger) WCDB::Error::Code::Authorization, \"\");\nstatic_assert((NSUInteger) WCTErrorCodeFormat == (NSUInteger) WCDB::Error::Code::Format, \"\");\nstatic_assert((NSUInteger) WCTErrorCodeRange == (NSUInteger) WCDB::Error::Code::Range, \"\");\nstatic_assert((NSUInteger) WCTErrorCodeNotADatabase == (NSUInteger) WCDB::Error::Code::NotADatabase, \"\");\nstatic_assert((NSUInteger) WCTErrorCodeNotice == (NSUInteger) WCDB::Error::Code::Notice, \"\");\nstatic_assert((NSUInteger) WCTErrorCodeWarning == (NSUInteger) WCDB::Error::Code::Warning, \"\");\nstatic_assert((NSUInteger) WCTErrorCodeRow == (NSUInteger) WCDB::Error::Code::Row, \"\");\nstatic_assert((NSUInteger) WCTErrorCodeDone == (NSUInteger) WCDB::Error::Code::Done, \"\");\nstatic_assert((NSUInteger) WCTErrorCodeZstdError == (NSUInteger) WCDB::Error::Code::ZstdError, \"\");\n\nstatic_assert((NSUInteger) WCTErrorExtendedCodeErrorMissingCollseq == (NSUInteger) WCDB::Error::ExtCode::ErrorMissingCollseq, \"\");\nstatic_assert((NSUInteger) WCTErrorExtendedCodeErrorRetry == (NSUInteger) WCDB::Error::ExtCode::ErrorRetry, \"\");\nstatic_assert((NSUInteger) WCTErrorExtendedCodeErrorSnapshot == (NSUInteger) WCDB::Error::ExtCode::ErrorSnapshot, \"\");\nstatic_assert((NSUInteger) WCTErrorExtendedCodeIOErrorRead == (NSUInteger) WCDB::Error::ExtCode::IOErrorRead, \"\");\nstatic_assert((NSUInteger) WCTErrorExtendedCodeIOErrorShortRead == (NSUInteger) WCDB::Error::ExtCode::IOErrorShortRead, \"\");\nstatic_assert((NSUInteger) WCTErrorExtendedCodeIOErrorWrite == (NSUInteger) WCDB::Error::ExtCode::IOErrorWrite, \"\");\nstatic_assert((NSUInteger) WCTErrorExtendedCodeIOErrorFsync == (NSUInteger) WCDB::Error::ExtCode::IOErrorFsync, \"\");\nstatic_assert((NSUInteger) WCTErrorExtendedCodeIOErrorDirFsync == (NSUInteger) WCDB::Error::ExtCode::IOErrorDirFsync, \"\");\nstatic_assert((NSUInteger) WCTErrorExtendedCodeIOErrorTruncate == (NSUInteger) WCDB::Error::ExtCode::IOErrorTruncate, \"\");\nstatic_assert((NSUInteger) WCTErrorExtendedCodeIOErrorFstat == (NSUInteger) WCDB::Error::ExtCode::IOErrorFstat, \"\");\nstatic_assert((NSUInteger) WCTErrorExtendedCodeIOErrorUnlock == (NSUInteger) WCDB::Error::ExtCode::IOErrorUnlock, \"\");\nstatic_assert((NSUInteger) WCTErrorExtendedCodeIOErrorRdlock == (NSUInteger) WCDB::Error::ExtCode::IOErrorRdlock, \"\");\nstatic_assert((NSUInteger) WCTErrorExtendedCodeIOErrorDelete == (NSUInteger) WCDB::Error::ExtCode::IOErrorDelete, \"\");\nstatic_assert((NSUInteger) WCTErrorExtendedCodeIOErrorBlocked == (NSUInteger) WCDB::Error::ExtCode::IOErrorBlocked, \"\");\nstatic_assert((NSUInteger) WCTErrorExtendedCodeIOErrorNoMemory == (NSUInteger) WCDB::Error::ExtCode::IOErrorNoMemory, \"\");\nstatic_assert((NSUInteger) WCTErrorExtendedCodeIOErrorAccess == (NSUInteger) WCDB::Error::ExtCode::IOErrorAccess, \"\");\nstatic_assert((NSUInteger) WCTErrorExtendedCodeIOErrorCheckReservedLock == (NSUInteger) WCDB::Error::ExtCode::IOErrorCheckReservedLock, \"\");\nstatic_assert((NSUInteger) WCTErrorExtendedCodeIOErrorLock == (NSUInteger) WCDB::Error::ExtCode::IOErrorLock, \"\");\nstatic_assert((NSUInteger) WCTErrorExtendedCodeIOErrorClose == (NSUInteger) WCDB::Error::ExtCode::IOErrorClose, \"\");\nstatic_assert((NSUInteger) WCTErrorExtendedCodeIOErrorDirClose == (NSUInteger) WCDB::Error::ExtCode::IOErrorDirClose, \"\");\nstatic_assert((NSUInteger) WCTErrorExtendedCodeIOErrorShmOpen == (NSUInteger) WCDB::Error::ExtCode::IOErrorShmOpen, \"\");\nstatic_assert((NSUInteger) WCTErrorExtendedCodeIOErrorShmSize == (NSUInteger) WCDB::Error::ExtCode::IOErrorShmSize, \"\");\nstatic_assert((NSUInteger) WCTErrorExtendedCodeIOErrorShmLock == (NSUInteger) WCDB::Error::ExtCode::IOErrorShmLock, \"\");\nstatic_assert((NSUInteger) WCTErrorExtendedCodeIOErrorShmMap == (NSUInteger) WCDB::Error::ExtCode::IOErrorShmMap, \"\");\nstatic_assert((NSUInteger) WCTErrorExtendedCodeIOErrorSeek == (NSUInteger) WCDB::Error::ExtCode::IOErrorSeek, \"\");\nstatic_assert((NSUInteger) WCTErrorExtendedCodeIOErrorDeleteNoEntry == (NSUInteger) WCDB::Error::ExtCode::IOErrorDeleteNoEntry, \"\");\nstatic_assert((NSUInteger) WCTErrorExtendedCodeIOErrorMmap == (NSUInteger) WCDB::Error::ExtCode::IOErrorMmap, \"\");\nstatic_assert((NSUInteger) WCTErrorExtendedCodeIOErrorGetTempPath == (NSUInteger) WCDB::Error::ExtCode::IOErrorGetTempPath, \"\");\nstatic_assert((NSUInteger) WCTErrorExtendedCodeIOErrorConvPath == (NSUInteger) WCDB::Error::ExtCode::IOErrorConvPath, \"\");\nstatic_assert((NSUInteger) WCTErrorExtendedCodeIOErrorVnode == (NSUInteger) WCDB::Error::ExtCode::IOErrorVnode, \"\");\nstatic_assert((NSUInteger) WCTErrorExtendedCodeIOErrorAuthorization == (NSUInteger) WCDB::Error::ExtCode::IOErrorAuthorization, \"\");\nstatic_assert((NSUInteger) WCTErrorExtendedCodeIOErrorBeginAtomic == (NSUInteger) WCDB::Error::ExtCode::IOErrorBeginAtomic, \"\");\nstatic_assert((NSUInteger) WCTErrorExtendedCodeIOErrorCommitAtomic == (NSUInteger) WCDB::Error::ExtCode::IOErrorCommitAtomic, \"\");\nstatic_assert((NSUInteger) WCTErrorExtendedCodeIOErrorRollbackAtomic == (NSUInteger) WCDB::Error::ExtCode::IOErrorRollbackAtomic, \"\");\nstatic_assert((NSUInteger) WCTErrorExtendedCodeLockedSharedCache == (NSUInteger) WCDB::Error::ExtCode::LockedSharedCache, \"\");\nstatic_assert((NSUInteger) WCTErrorExtendedCodeLockedVirtualTable == (NSUInteger) WCDB::Error::ExtCode::LockedVirtualTable, \"\");\nstatic_assert((NSUInteger) WCTErrorExtendedCodeBusyRecovery == (NSUInteger) WCDB::Error::ExtCode::BusyRecovery, \"\");\nstatic_assert((NSUInteger) WCTErrorExtendedCodeBusySnapshot == (NSUInteger) WCDB::Error::ExtCode::BusySnapshot, \"\");\nstatic_assert((NSUInteger) WCTErrorExtendedCodeCantOpenNoTempDir == (NSUInteger) WCDB::Error::ExtCode::CantOpenNoTempDir, \"\");\nstatic_assert((NSUInteger) WCTErrorExtendedCodeCantOpenIsDir == (NSUInteger) WCDB::Error::ExtCode::CantOpenIsDir, \"\");\nstatic_assert((NSUInteger) WCTErrorExtendedCodeCantOpenFullPath == (NSUInteger) WCDB::Error::ExtCode::CantOpenFullPath, \"\");\nstatic_assert((NSUInteger) WCTErrorExtendedCodeCantOpenConvPath == (NSUInteger) WCDB::Error::ExtCode::CantOpenConvPath, \"\");\nstatic_assert((NSUInteger) WCTErrorExtendedCodeCantOpenDirtyWal == (NSUInteger) WCDB::Error::ExtCode::CantOpenDirtyWal, \"\");\nstatic_assert((NSUInteger) WCTErrorExtendedCodeCorruptVirtualTable == (NSUInteger) WCDB::Error::ExtCode::CorruptVirtualTable, \"\");\nstatic_assert((NSUInteger) WCTErrorExtendedCodeCorruptSequence == (NSUInteger) WCDB::Error::ExtCode::CorruptSequence, \"\");\nstatic_assert((NSUInteger) WCTErrorExtendedCodeReadonlyRecovery == (NSUInteger) WCDB::Error::ExtCode::ReadonlyRecovery, \"\");\nstatic_assert((NSUInteger) WCTErrorExtendedCodeReadonlyCantLock == (NSUInteger) WCDB::Error::ExtCode::ReadonlyCantLock, \"\");\nstatic_assert((NSUInteger) WCTErrorExtendedCodeReadonlyRollback == (NSUInteger) WCDB::Error::ExtCode::ReadonlyRollback, \"\");\nstatic_assert((NSUInteger) WCTErrorExtendedCodeReadonlyDatabaseMoved == (NSUInteger) WCDB::Error::ExtCode::ReadonlyDatabaseMoved, \"\");\nstatic_assert((NSUInteger) WCTErrorExtendedCodeReadonlyCantInit == (NSUInteger) WCDB::Error::ExtCode::ReadonlyCantInit, \"\");\nstatic_assert((NSUInteger) WCTErrorExtendedCodeReadonlyDirectory == (NSUInteger) WCDB::Error::ExtCode::ReadonlyDirectory, \"\");\nstatic_assert((NSUInteger) WCTErrorExtendedCodeAbortRollback == (NSUInteger) WCDB::Error::ExtCode::AbortRollback, \"\");\nstatic_assert((NSUInteger) WCTErrorExtendedCodeConstraintCheck == (NSUInteger) WCDB::Error::ExtCode::ConstraintCheck, \"\");\nstatic_assert((NSUInteger) WCTErrorExtendedCodeConstraintCommitHook == (NSUInteger) WCDB::Error::ExtCode::ConstraintCommitHook, \"\");\nstatic_assert((NSUInteger) WCTErrorExtendedCodeConstraintForeignKey == (NSUInteger) WCDB::Error::ExtCode::ConstraintForeignKey, \"\");\nstatic_assert((NSUInteger) WCTErrorExtendedCodeConstraintFunction == (NSUInteger) WCDB::Error::ExtCode::ConstraintFunction, \"\");\nstatic_assert((NSUInteger) WCTErrorExtendedCodeConstraintNotNull == (NSUInteger) WCDB::Error::ExtCode::ConstraintNotNull, \"\");\nstatic_assert((NSUInteger) WCTErrorExtendedCodeConstraintPrimaryKey == (NSUInteger) WCDB::Error::ExtCode::ConstraintPrimaryKey, \"\");\nstatic_assert((NSUInteger) WCTErrorExtendedCodeConstraintTrigger == (NSUInteger) WCDB::Error::ExtCode::ConstraintTrigger, \"\");\nstatic_assert((NSUInteger) WCTErrorExtendedCodeConstraintUnique == (NSUInteger) WCDB::Error::ExtCode::ConstraintUnique, \"\");\nstatic_assert((NSUInteger) WCTErrorExtendedCodeConstraintVirtualTable == (NSUInteger) WCDB::Error::ExtCode::ConstraintVirtualTable, \"\");\nstatic_assert((NSUInteger) WCTErrorExtendedCodeConstraintRowID == (NSUInteger) WCDB::Error::ExtCode::ConstraintRowID, \"\");\nstatic_assert((NSUInteger) WCTErrorExtendedCodeNoticeRecoverWal == (NSUInteger) WCDB::Error::ExtCode::NoticeRecoverWal, \"\");\nstatic_assert((NSUInteger) WCTErrorExtendedCodeNoticeRecoverRollback == (NSUInteger) WCDB::Error::ExtCode::NoticeRecoverRollback, \"\");\nstatic_assert((NSUInteger) WCTErrorExtendedCodeWarningAutoIndex == (NSUInteger) WCDB::Error::ExtCode::WarningAutoIndex, \"\");\nstatic_assert((NSUInteger) WCTErrorExtendedCodeAuthorizationUser == (NSUInteger) WCDB::Error::ExtCode::AuthorizationUser, \"\");\nstatic_assert((NSUInteger) WCTErrorExtendedCodeOKLoadPermanently == (NSUInteger) WCDB::Error::ExtCode::OKLoadPermanently, \"\");\n\nstatic_assert((int) WCTInvalidTag == (int) WCDB::TagInvalidValue, \"\");\nstatic_assert(sizeof(WCTTag) == sizeof(WCDB::Tag), \"\");\n"
  },
  {
    "path": "src/objc/monitor/WCTError.h",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"Macro.h\"\n#import \"WCTMacroUtility.h\"\n#import \"WCTTag.h\"\n#import <Foundation/Foundation.h>\n\nNS_ASSUME_NONNULL_BEGIN\n\nWCDB_EXTERN NSErrorDomain const WCTErrorDomain;\n\nWCDB_EXTERN NSErrorUserInfoKey const WCTErrorKeyPath;\nWCDB_EXTERN NSErrorUserInfoKey const WCTErrorKeySQL;\nWCDB_EXTERN NSErrorUserInfoKey const WCTErrorKeyTag;\nWCDB_EXTERN NSErrorUserInfoKey const WCTErrorKeyExtendedCode;\n\ntypedef NS_ENUM(NSUInteger, WCTErrorLevel) {\n    WCTErrorLevelIgnore = 1,\n    WCTErrorLevelDebug = 2,\n    WCTErrorLevelNotice = 3,\n    WCTErrorLevelWarning = 4,\n    WCTErrorLevelError = 5, // Only for the errors that will cause api to return false.\n    WCTErrorLevelFatal = 6, // Application should abort.\n};\n\ntypedef NS_ENUM(NSUInteger, WCTErrorCode) {\n    /**\n     * Error code for sqlite. You can check it at http://www.sqlite.org/rescode.html .\n     */\n    WCTErrorCodeOK = 0,\n    WCTErrorCodeError = 1,\n    WCTErrorCodeInternal = 2,\n    WCTErrorCodePermission = 3,\n    WCTErrorCodeAbort = 4,\n    WCTErrorCodeBusy = 5,\n    WCTErrorCodeLocked = 6,\n    WCTErrorCodeNoMemory = 7,\n    WCTErrorCodeReadonly = 8,\n    WCTErrorCodeInterrupt = 9, /* Operation terminated by sqlite3_interrupt()*/\n    WCTErrorCodeIOError = 10,\n    WCTErrorCodeCorrupt = 11,\n    WCTErrorCodeNotFound = 12,\n    WCTErrorCodeFull = 13,\n    WCTErrorCodeCantOpen = 14,\n    WCTErrorCodeProtocol = 15,\n    WCTErrorCodeEmpty = 16,\n    WCTErrorCodeSchema = 17,\n    WCTErrorCodeExceed = 18,\n    WCTErrorCodeConstraint = 19,\n    WCTErrorCodeMismatch = 20,\n    WCTErrorCodeMisuse = 21,\n    WCTErrorCodeNoLargeFileSupport = 22,\n    WCTErrorCodeAuthorization = 23,\n    WCTErrorCodeFormat = 24,\n    WCTErrorCodeRange = 25,\n    WCTErrorCodeNotADatabase = 26,\n    WCTErrorCodeNotice = 27,\n    WCTErrorCodeWarning = 28,\n    WCTErrorCodeRow = 100,\n    WCTErrorCodeDone = 101,\n    WCTErrorCodeZstdError = 1000,\n};\n\ntypedef NS_ENUM(NSUInteger, WCTErrorExtendedCode) {\n    /**\n     * Extended error code for sqlite. You can check it at http://www.sqlite.org/rescode.html .\n     */\n    WCTErrorExtendedCodeErrorMissingCollseq = ((NSUInteger) WCTErrorCodeError | (1 << 8)),         // 257\n    WCTErrorExtendedCodeErrorRetry = ((NSUInteger) WCTErrorCodeError | (2 << 8)),                  // 513\n    WCTErrorExtendedCodeErrorSnapshot = ((NSUInteger) WCTErrorCodeError | (3 << 8)),               // 769\n    WCTErrorExtendedCodeIOErrorRead = ((NSUInteger) WCTErrorCodeIOError | (1 << 8)),               // 266\n    WCTErrorExtendedCodeIOErrorShortRead = ((NSUInteger) WCTErrorCodeIOError | (2 << 8)),          // 522\n    WCTErrorExtendedCodeIOErrorWrite = ((NSUInteger) WCTErrorCodeIOError | (3 << 8)),              // 778\n    WCTErrorExtendedCodeIOErrorFsync = ((NSUInteger) WCTErrorCodeIOError | (4 << 8)),              // 1034\n    WCTErrorExtendedCodeIOErrorDirFsync = ((NSUInteger) WCTErrorCodeIOError | (5 << 8)),           // 1290\n    WCTErrorExtendedCodeIOErrorTruncate = ((NSUInteger) WCTErrorCodeIOError | (6 << 8)),           // 1546\n    WCTErrorExtendedCodeIOErrorFstat = ((NSUInteger) WCTErrorCodeIOError | (7 << 8)),              // 1802\n    WCTErrorExtendedCodeIOErrorUnlock = ((NSUInteger) WCTErrorCodeIOError | (8 << 8)),             // 2058\n    WCTErrorExtendedCodeIOErrorRdlock = ((NSUInteger) WCTErrorCodeIOError | (9 << 8)),             // 2314\n    WCTErrorExtendedCodeIOErrorDelete = ((NSUInteger) WCTErrorCodeIOError | (10 << 8)),            // 2570\n    WCTErrorExtendedCodeIOErrorBlocked = ((NSUInteger) WCTErrorCodeIOError | (11 << 8)),           // 2826\n    WCTErrorExtendedCodeIOErrorNoMemory = ((NSUInteger) WCTErrorCodeIOError | (12 << 8)),          // 3082\n    WCTErrorExtendedCodeIOErrorAccess = ((NSUInteger) WCTErrorCodeIOError | (13 << 8)),            // 3338\n    WCTErrorExtendedCodeIOErrorCheckReservedLock = ((NSUInteger) WCTErrorCodeIOError | (14 << 8)), // 3594\n    WCTErrorExtendedCodeIOErrorLock = ((NSUInteger) WCTErrorCodeIOError | (15 << 8)),              // 3850\n    WCTErrorExtendedCodeIOErrorClose = ((NSUInteger) WCTErrorCodeIOError | (16 << 8)),             // 4106\n    WCTErrorExtendedCodeIOErrorDirClose = ((NSUInteger) WCTErrorCodeIOError | (17 << 8)),          // 4362\n    WCTErrorExtendedCodeIOErrorShmOpen = ((NSUInteger) WCTErrorCodeIOError | (18 << 8)),           // 4618\n    WCTErrorExtendedCodeIOErrorShmSize = ((NSUInteger) WCTErrorCodeIOError | (19 << 8)),           // 4874\n    WCTErrorExtendedCodeIOErrorShmLock = ((NSUInteger) WCTErrorCodeIOError | (20 << 8)),           // 5130\n    WCTErrorExtendedCodeIOErrorShmMap = ((NSUInteger) WCTErrorCodeIOError | (21 << 8)),            // 5386\n    WCTErrorExtendedCodeIOErrorSeek = ((NSUInteger) WCTErrorCodeIOError | (22 << 8)),              // 5642\n    WCTErrorExtendedCodeIOErrorDeleteNoEntry = ((NSUInteger) WCTErrorCodeIOError | (23 << 8)),     // 5898\n    WCTErrorExtendedCodeIOErrorMmap = ((NSUInteger) WCTErrorCodeIOError | (24 << 8)),              // 6154\n    WCTErrorExtendedCodeIOErrorGetTempPath = ((NSUInteger) WCTErrorCodeIOError | (25 << 8)),       // 6410\n    WCTErrorExtendedCodeIOErrorConvPath = ((NSUInteger) WCTErrorCodeIOError | (26 << 8)),          // 6666\n    WCTErrorExtendedCodeIOErrorVnode = ((NSUInteger) WCTErrorCodeIOError | (27 << 8)),             // 6922\n    WCTErrorExtendedCodeIOErrorAuthorization = ((NSUInteger) WCTErrorCodeIOError | (28 << 8)),     // 7178\n    WCTErrorExtendedCodeIOErrorBeginAtomic = ((NSUInteger) WCTErrorCodeIOError | (29 << 8)),       // 7434\n    WCTErrorExtendedCodeIOErrorCommitAtomic = ((NSUInteger) WCTErrorCodeIOError | (30 << 8)),      // 7690\n    WCTErrorExtendedCodeIOErrorRollbackAtomic = ((NSUInteger) WCTErrorCodeIOError | (31 << 8)),    // 7946\n    WCTErrorExtendedCodeLockedSharedCache = ((NSUInteger) WCTErrorCodeLocked | (1 << 8)),          // 262\n    WCTErrorExtendedCodeLockedVirtualTable = ((NSUInteger) WCTErrorCodeLocked | (2 << 8)),         // 518\n    WCTErrorExtendedCodeBusyRecovery = ((NSUInteger) WCTErrorCodeBusy | (1 << 8)),                 // 261\n    WCTErrorExtendedCodeBusySnapshot = ((NSUInteger) WCTErrorCodeBusy | (2 << 8)),                 // 517\n    WCTErrorExtendedCodeCantOpenNoTempDir = ((NSUInteger) WCTErrorCodeCantOpen | (1 << 8)),        // 270\n    WCTErrorExtendedCodeCantOpenIsDir = ((NSUInteger) WCTErrorCodeCantOpen | (2 << 8)),            // 526\n    WCTErrorExtendedCodeCantOpenFullPath = ((NSUInteger) WCTErrorCodeCantOpen | (3 << 8)),         // 782\n    WCTErrorExtendedCodeCantOpenConvPath = ((NSUInteger) WCTErrorCodeCantOpen | (4 << 8)),         // 1038\n    WCTErrorExtendedCodeCantOpenDirtyWal = ((NSUInteger) WCTErrorCodeCantOpen | (5 << 8)),         // 1294\n    WCTErrorExtendedCodeCorruptVirtualTable = ((NSUInteger) WCTErrorCodeCorrupt | (1 << 8)),       // 267\n    WCTErrorExtendedCodeCorruptSequence = ((NSUInteger) WCTErrorCodeCorrupt | (2 << 8)),           // 523\n    WCTErrorExtendedCodeReadonlyRecovery = ((NSUInteger) WCTErrorCodeReadonly | (1 << 8)),         // 264\n    WCTErrorExtendedCodeReadonlyCantLock = ((NSUInteger) WCTErrorCodeReadonly | (2 << 8)),         // 520\n    WCTErrorExtendedCodeReadonlyRollback = ((NSUInteger) WCTErrorCodeReadonly | (3 << 8)),         // 776\n    WCTErrorExtendedCodeReadonlyDatabaseMoved = ((NSUInteger) WCTErrorCodeReadonly | (4 << 8)),    // 1032\n    WCTErrorExtendedCodeReadonlyCantInit = ((NSUInteger) WCTErrorCodeReadonly | (5 << 8)),         // 1288\n    WCTErrorExtendedCodeReadonlyDirectory = ((NSUInteger) WCTErrorCodeReadonly | (6 << 8)),        // 1544\n    WCTErrorExtendedCodeAbortRollback = ((NSUInteger) WCTErrorCodeAbort | (2 << 8)),               // 516\n    WCTErrorExtendedCodeConstraintCheck = ((NSUInteger) WCTErrorCodeConstraint | (1 << 8)),        // 275\n    WCTErrorExtendedCodeConstraintCommitHook = ((NSUInteger) WCTErrorCodeConstraint | (2 << 8)),   // 531\n    WCTErrorExtendedCodeConstraintForeignKey = ((NSUInteger) WCTErrorCodeConstraint | (3 << 8)),   // 787\n    WCTErrorExtendedCodeConstraintFunction = ((NSUInteger) WCTErrorCodeConstraint | (4 << 8)),     // 1043\n    WCTErrorExtendedCodeConstraintNotNull = ((NSUInteger) WCTErrorCodeConstraint | (5 << 8)),      // 1299\n    WCTErrorExtendedCodeConstraintPrimaryKey = ((NSUInteger) WCTErrorCodeConstraint | (6 << 8)),   // 1555\n    WCTErrorExtendedCodeConstraintTrigger = ((NSUInteger) WCTErrorCodeConstraint | (7 << 8)),      // 1811\n    WCTErrorExtendedCodeConstraintUnique = ((NSUInteger) WCTErrorCodeConstraint | (8 << 8)),       // 2067\n    WCTErrorExtendedCodeConstraintVirtualTable = ((NSUInteger) WCTErrorCodeConstraint | (9 << 8)), // 2323\n    WCTErrorExtendedCodeConstraintRowID = ((NSUInteger) WCTErrorCodeConstraint | (10 << 8)),       // 2579\n    WCTErrorExtendedCodeNoticeRecoverWal = ((NSUInteger) WCTErrorCodeNotice | (1 << 8)),           // 283\n    WCTErrorExtendedCodeNoticeRecoverRollback = ((NSUInteger) WCTErrorCodeNotice | (2 << 8)),      // 539\n    WCTErrorExtendedCodeWarningAutoIndex = ((NSUInteger) WCTErrorCodeWarning | (1 << 8)),          // 284\n    WCTErrorExtendedCodeAuthorizationUser = ((NSUInteger) WCTErrorCodeAuthorization | (1 << 8)),   // 279\n    WCTErrorExtendedCodeOKLoadPermanently = ((NSUInteger) WCTErrorCodeOK | (1 << 8)),              // 256\n};\n\nWCDB_API @interface WCTError : NSError\n\n- (instancetype)initWithCode:(WCTErrorCode)code\n                       level:(WCTErrorLevel)level\n                     message:(nonnull NSString *)message\n                    userInfo:(nullable NSDictionary<NSErrorUserInfoKey, id> *)userInfo NS_DESIGNATED_INITIALIZER;\n\n- (instancetype)initWithDomain:(NSErrorDomain)domain code:(NSInteger)code userInfo:(nullable NSDictionary<NSErrorUserInfoKey, id> *)dict UNAVAILABLE_ATTRIBUTE;\n\n+ (instancetype)errorWithDomain:(NSErrorDomain)domain code:(NSInteger)code userInfo:(nullable NSDictionary<NSErrorUserInfoKey, id> *)dict UNAVAILABLE_ATTRIBUTE;\n\n/**\n * Level of error.\n */\n@property (nonatomic, readonly) WCTErrorLevel level;\n\n/**\n * Text message that helps you debug it.\n */\n@property (nonatomic, readonly) NSString *message;\n\n/**\n @brief Convenient interface for checking code==0.\n @return YES for no error\n */\n- (BOOL)isOK;\n\n/**\n @brief Convenient interface for checking code==`WCTErrorCodeCorrupt` or code==`WCTErrorCodeNotADatabase`, which means database may be corrupted.\n @return YES for no error\n */\n- (BOOL)isCorruption;\n\n@end\n\nWCDB_API @interface WCTError(Path)\n\n/**\n * The file path of database that is being manipulated when an error occurs.\n */\n- (nullable NSString *)path;\n\n@end\n\nWCDB_API @interface WCTError(Tag)\n\n/**\n * The tag of database that is being manipulated when an error occurs.\n */\n- (WCTTag)tag;\n\n@end\n\nWCDB_API @interface WCTError(SQL)\n\n/**\n * The SQL is being executed when an error occurs.\n */\n- (nullable NSString *)sql;\n\n@end\n\nWCDB_API @interface WCTError(ExtendedCode)\n\n/**\n * Extended error code for sqlite. You can check it at http://www.sqlite.org/rescode.html .\n */\n- (WCTErrorExtendedCode)extendedCode;\n\n@end\n\nNS_ASSUME_NONNULL_END\n"
  },
  {
    "path": "src/objc/monitor/WCTError.mm",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"WCTError.h\"\n#import \"CoreConst.h\"\n#import \"WCTConvertible.h\"\n#import \"WCTDatabase+Monitor.h\"\n#import \"WCTError+Private.h\"\n#import \"WCTFoundation.h\"\n\nNSErrorDomain const WCTErrorDomain = @\"WCDB\";\n\nNSErrorUserInfoKey const WCTErrorKeyPath = @WCDB_ERROR_STRING_KEY_PATH;\nNSErrorUserInfoKey const WCTErrorKeySQL = @WCDB_ERROR_STRING_KEY_SQL;\nNSErrorUserInfoKey const WCTErrorKeyTag = @WCDB_ERROR_INT_KEY_TAG;\nNSErrorUserInfoKey const WCTErrorKeyExtendedCode = @WCDB_ERROR_INT_KEY_EXTCODE;\n\n@implementation WCTError\n\n- (instancetype)initWithCode:(WCTErrorCode)code\n                       level:(WCTErrorLevel)level\n                     message:(NSString *)message\n                    userInfo:(NSDictionary<NSErrorUserInfoKey, id> *)userInfo\n{\n    if (self = [super initWithDomain:WCTErrorDomain\n                                code:(NSInteger) code\n                            userInfo:userInfo]) {\n        _message = message;\n        _level = (WCTErrorLevel) level;\n    }\n    return self;\n}\n\n- (instancetype)initWithError:(const WCDB::Error &)error\n{\n    NSMutableDictionary *userInfo = [[NSMutableDictionary alloc] init];\n    if (error.infos.size() > 0) {\n        for (const auto &info : error.infos) {\n            switch (info.second.getType()) {\n            case WCDB::Value::Type::Text:\n                [userInfo setObject:[NSString stringWithView:info.second.textValue()]\n                             forKey:[NSString stringWithView:info.first]];\n                break;\n            case WCDB::Value::Type::Float:\n                [userInfo setObject:[NSNumber numberWithDouble:info.second.floatValue()] forKey:[NSString stringWithView:info.first]];\n                break;\n            case WCDB::Value::Type::Integer:\n                [userInfo setObject:[NSNumber numberWithLongLong:info.second.intValue()] forKey:[NSString stringWithView:info.first]];\n                break;\n            case WCDB::Value::Type::BLOB:\n                [userInfo setObject:[NSData dataWithBytes:info.second.blobValue().buffer() length:info.second.blobValue().size()] forKey:[NSString stringWithView:info.first]];\n                break;\n            default:\n                [userInfo setObject:[NSNull null] forKey:[NSString stringWithView:info.first]];\n                break;\n            }\n        }\n    }\n\n    return [self initWithCode:(WCTErrorCode) error.code() level:(WCTErrorLevel) error.level message:[NSString stringWithView:error.getMessage()] userInfo:userInfo];\n}\n\n- (BOOL)isOK\n{\n    return self.code == WCTErrorCodeOK;\n}\n\n- (BOOL)isCorruption\n{\n    return self.code == WCTErrorCodeCorrupt || self.code == WCTErrorCodeNotADatabase;\n}\n\n- (NSString *)stringForKey:(NSErrorUserInfoKey)key\n{\n    id value = [self.userInfo objectForKey:key];\n    if (value != nil && [value isKindOfClass:NSString.class]) {\n        return value;\n    }\n    return nil;\n}\n\n- (NSNumber *)numberForKey:(NSErrorUserInfoKey)key\n{\n    id value = [self.userInfo objectForKey:key];\n    if (value != nil && [value isKindOfClass:NSNumber.class]) {\n        return value;\n    }\n    return nil;\n}\n\n- (NSString *)description\n{\n    NSMutableString *description = nil;\n    if (self.code != WCTErrorCodeOK\n        && self.code != WCTErrorCodeRow\n        && self.code != WCTErrorCodeDone) {\n        description = [[NSMutableString alloc] initWithFormat:@\"[%s: %ld, %@]\", WCDB::Error::levelName((WCDB::Error::Level) self.level), (long) self.code, self.message];\n        [self.userInfo enumerateKeysAndObjectsUsingBlock:^(NSErrorUserInfoKey key, id value, BOOL *) {\n            if ([value isKindOfClass:NSNull.class]) {\n                [description appendFormat:@\", %@\", key];\n            } else {\n                [description appendFormat:@\", %@: %@\", key, value];\n            }\n        }];\n    }\n    return description;\n}\n\n@end\n\n@implementation WCTError (Path)\n\n- (NSString *)path\n{\n    return [self stringForKey:WCTErrorKeyPath];\n}\n\n@end\n\n@implementation WCTError (Tag)\n\n- (WCTTag)tag\n{\n    static_assert(WCTInvalidTag == 0, \"\");\n    return (WCTTag) [self numberForKey:WCTErrorKeyTag].intValue;\n}\n\n@end\n\n@implementation WCTError (SQL)\n\n- (NSString *)sql\n{\n    return [self stringForKey:WCTErrorKeySQL];\n}\n\n@end\n\n@implementation WCTError (ExtendedCode)\n\n- (WCTErrorExtendedCode)extendedCode\n{\n    return (WCTErrorExtendedCode) [self numberForKey:WCTErrorKeyExtendedCode].intValue;\n}\n\n@end\n"
  },
  {
    "path": "src/objc/monitor/WCTPerformanceInfo+Private.h",
    "content": "//\n// Created by qiuwenchen on 2023/9/28.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"InnerHandle.hpp\"\n#import \"WCTPerformanceInfo.h\"\n\n@interface WCTPerformanceInfo ()\n\n- (instancetype)initWithPerformanceInfo:(const WCDB::InnerHandle::PerformanceInfo &)info;\n\n@end\n"
  },
  {
    "path": "src/objc/monitor/WCTPerformanceInfo.h",
    "content": "//\n// Created by qiuwenchen on 2023/9/28.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"Macro.h\"\n#import <Foundation/Foundation.h>\n\nWCDB_API @interface WCTPerformanceInfo : NSObject\n\n@property (nonatomic, assign) int tablePageReadCount;\n@property (nonatomic, assign) int tablePageWriteCount;\n@property (nonatomic, assign) int indexPageReadCount;\n@property (nonatomic, assign) int indexPageWriteCount;\n@property (nonatomic, assign) int overflowPageReadCount;\n@property (nonatomic, assign) int overflowPageWriteCount;\n@property (nonatomic, assign) int64_t costInNanoseconds;\n\n@end\n"
  },
  {
    "path": "src/objc/monitor/WCTPerformanceInfo.mm",
    "content": "//\n// Created by qiuwenchen on 2023/9/28.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"WCTPerformanceInfo+Private.h\"\n#import <Foundation/Foundation.h>\n\n@implementation WCTPerformanceInfo\n\n- (instancetype)initWithPerformanceInfo:(const WCDB::InnerHandle::PerformanceInfo &)info\n{\n    if (self = [super init]) {\n        _tablePageReadCount = info.tablePageReadCount;\n        _tablePageWriteCount = info.tablePageWriteCount;\n        _indexPageReadCount = info.indexPageReadCount;\n        _indexPageWriteCount = info.indexPageWriteCount;\n        _overflowPageReadCount = info.overflowPageReadCount;\n        _overflowPageWriteCount = info.overflowPageWriteCount;\n        _costInNanoseconds = info.costInNanoseconds;\n    }\n    return self;\n}\n\n@end\n"
  },
  {
    "path": "src/objc/orm/WCTORM.h",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"WCTRuntimeCppAccessor.h\"\n#import \"WCTRuntimeObjCAccessor.h\"\n\n#import \"WCTBinding.h\"\n#import \"WCTColumnBinding.h\"\n\n#import \"WCTColumnCoding.h\"\n#import \"WCTTableCoding.h\"\n\n#import \"WCTProperty.h\"\n#import \"WCTResultColumn.h\"\n\n#import \"WCTMacro.h\"\n"
  },
  {
    "path": "src/objc/orm/accessor/WCTBaseAccessor.h",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"WCTCommon.h\"\n\ntypedef NS_ENUM(int, WCTAccessorType) {\n    WCTAccessorCpp,\n    WCTAccessorObjC,\n};\n\nclass WCDB_API WCTBaseAccessor {\npublic:\n    using InstanceType = id; //NSObject<WCTTableCoding>*\n    virtual ~WCTBaseAccessor();\n    virtual WCDB::ColumnType getColumnType() const = 0;\n    virtual WCTAccessorType getAccessorType() const = 0;\n};\n"
  },
  {
    "path": "src/objc/orm/accessor/WCTBaseAccessor.mm",
    "content": "//\n// Created by sanhuazhang on 2019/08/15\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"WCTBaseAccessor.h\"\n\nWCTBaseAccessor::~WCTBaseAccessor() = default;\n"
  },
  {
    "path": "src/objc/orm/accessor/WCTCppAccessor.h",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"WCTBaseAccessor.h\"\n\ntemplate<WCDB::ColumnType t>\nclass WCTCppAccessor : public WCTBaseAccessor {\npublic:\n    using UnderlyingType = typename WCDB::ColumnTypeInfo<t>::UnderlyingType;\n\n    virtual ~WCTCppAccessor() override = default;\n\n    WCDB::ColumnType getColumnType() const override final { return t; };\n    WCTAccessorType getAccessorType() const override final\n    {\n        return WCTAccessorCpp;\n    }\n\n    virtual void setValue(InstanceType instance, UnderlyingType value) = 0;\n    virtual UnderlyingType getValue(InstanceType instance) = 0;\n};\n"
  },
  {
    "path": "src/objc/orm/accessor/WCTObjCAccessor.h",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"WCTBaseAccessor.h\"\n#import \"WCTCommon.h\"\n#import <functional>\n#import <type_traits>\n\nclass WCDB_API WCTObjCAccessor : public WCTBaseAccessor {\npublic:\n    using OCType = id; //NSData*, NSString*, NSNumber*\n    virtual ~WCTObjCAccessor() override;\n    WCTAccessorType getAccessorType() const override final;\n\n    virtual void setObject(InstanceType instance, OCType value) = 0;\n    virtual OCType getObject(InstanceType instance) = 0;\n};\n"
  },
  {
    "path": "src/objc/orm/accessor/WCTObjCAccessor.mm",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"WCTObjCAccessor.h\"\n\nWCTObjCAccessor::~WCTObjCAccessor() = default;\n\nWCTAccessorType WCTObjCAccessor::getAccessorType() const\n{\n    return WCTAccessorObjC;\n}\n"
  },
  {
    "path": "src/objc/orm/accessor/WCTRuntimeBaseAccessor.h",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"WCTCommon.h\"\n#import <functional>\n#import <objc/runtime.h>\n\nclass WCDB_API WCTRuntimeBaseAccessor {\npublic:\n    WCTRuntimeBaseAccessor(Class cls, const WCDB::UnsafeStringView &propertyName);\n\n    virtual ~WCTRuntimeBaseAccessor();\n\nprotected:\n    SEL m_selForGetter;\n    SEL m_selForSetter;\n    IMP m_impForGetter;\n    IMP m_impForSetter;\n\n    using InstanceType = id;\n\n    static Class getPropertyClass(Class cls, const WCDB::UnsafeStringView &propertyName);\n\n    static SEL getGetterSelector(objc_property_t property,\n                                 const WCDB::UnsafeStringView &propertyName);\n    static SEL getSetterSelector(objc_property_t property,\n                                 const WCDB::UnsafeStringView &propertyName);\n    static IMP getClassMethodImplementation(Class cls, SEL selector);\n    static IMP getInstanceMethodImplementation(Class cls, SEL selector);\n\nprivate:\n    WCTRuntimeBaseAccessor(Class cls,\n                           const WCDB::UnsafeStringView &propertyName,\n                           objc_property_t property);\n};\n\ntemplate<typename PropertyType>\nclass WCTRuntimeAccessor : public WCTRuntimeBaseAccessor {\npublic:\n    using WCTRuntimeBaseAccessor::WCTRuntimeBaseAccessor;\n\n    virtual ~WCTRuntimeAccessor() override = default;\n\n    void setProperty(InstanceType instance, PropertyType value)\n    {\n        using IMPSetter = void (*)(InstanceType, SEL, PropertyType);\n        return ((IMPSetter) m_impForSetter)(instance, m_selForSetter, value);\n    }\n\n    PropertyType getProperty(InstanceType instance)\n    {\n        using IMPGetter = PropertyType (*)(id, SEL);\n        return ((IMPGetter) m_impForGetter)(instance, m_selForGetter);\n    }\n};\n"
  },
  {
    "path": "src/objc/orm/accessor/WCTRuntimeBaseAccessor.mm",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"WCTRuntimeBaseAccessor.h\"\n#import \"Assertion.hpp\"\n#import \"CommonCore.h\"\n#import \"Console.hpp\"\n#import \"StringView.hpp\"\n#import <objc/runtime.h>\n\nWCTRuntimeBaseAccessor::WCTRuntimeBaseAccessor(Class cls, const WCDB::UnsafeStringView &propertyName)\n: WCTRuntimeBaseAccessor(cls, propertyName, class_getProperty(cls, propertyName.data()))\n{\n}\n\nWCTRuntimeBaseAccessor::WCTRuntimeBaseAccessor(Class cls, const WCDB::UnsafeStringView &propertyName, objc_property_t property)\n: m_selForGetter(getGetterSelector(property, propertyName))\n, m_selForSetter(getSetterSelector(property, propertyName))\n, m_impForGetter(getInstanceMethodImplementation(cls, m_selForGetter))\n, m_impForSetter(getInstanceMethodImplementation(cls, m_selForSetter))\n{\n}\n\nWCTRuntimeBaseAccessor::~WCTRuntimeBaseAccessor() = default;\n\nSEL WCTRuntimeBaseAccessor::getGetterSelector(objc_property_t property, const WCDB::UnsafeStringView &propertyName)\n{\n    // WCTAssert(property != nil);\n    WCTAssert(!propertyName.empty());\n\n    SEL selector = nil;\n    char *getter = property ? property_copyAttributeValue(property, \"G\") : nullptr;\n    if (getter != nullptr) {\n        selector = sel_registerName(getter);\n        free(getter);\n    } else {\n        selector = sel_registerName(propertyName.data());\n    }\n    WCTAssert(selector != nil);\n    return selector;\n}\n\nSEL WCTRuntimeBaseAccessor::getSetterSelector(objc_property_t property, const WCDB::UnsafeStringView &propertyName)\n{\n    // WCTAssert(property != nil);\n    WCTAssert(!propertyName.empty());\n\n    SEL selector = nil;\n    char *setter = property ? property_copyAttributeValue(property, \"S\") : nullptr;\n    if (setter != nullptr) {\n        selector = sel_registerName(setter);\n        free(setter);\n    } else {\n        std::ostringstream stream;\n        stream << \"set\" << propertyName << \":\";\n        std::string defaultSetter = stream.str();\n        defaultSetter[3] = (char) std::toupper(defaultSetter[3]);\n        selector = sel_registerName(defaultSetter.data());\n    }\n    WCTAssert(selector != nil);\n    return selector;\n}\n\nIMP WCTRuntimeBaseAccessor::getClassMethodImplementation(Class cls, SEL selector)\n{\n    WCTAssert(cls != nil);\n    WCTAssert(selector != nil);\n    return [cls methodForSelector:selector];\n}\n\nIMP WCTRuntimeBaseAccessor::getInstanceMethodImplementation(Class cls, SEL selector)\n{\n    WCTAssert(cls != nil);\n    WCTAssert(selector != nil);\n    return [cls instanceMethodForSelector:selector];\n}\n\nClass WCTRuntimeBaseAccessor::getPropertyClass(Class cls, const WCDB::UnsafeStringView &propertyName)\n{\n    WCTAssert(cls != nil);\n    WCTAssert(!propertyName.empty());\n\n    objc_property_t property = class_getProperty(cls, propertyName.data());\n    NSString *attributes = [NSString stringWithUTF8String:property_getAttributes(property)];\n    NSArray *splitAttributes = [attributes componentsSeparatedByString:@\",\"];\n    if (splitAttributes.count > 0) {\n        NSString *encodeType = splitAttributes[0];\n        NSArray *splitEncodeTypes = [encodeType componentsSeparatedByString:@\"\\\"\"];\n        WCTRemedialAssert(splitEncodeTypes.count > 1, WCDB::StringView::formatted(\"Failed to parse the type of [%s].\", propertyName.data()), return nil;);\n        NSString *className = splitEncodeTypes[1];\n        return NSClassFromString(className);\n    }\n    return nil;\n}\n"
  },
  {
    "path": "src/objc/orm/accessor/WCTRuntimeCppAccessor.h",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"WCTCppAccessor.h\"\n#import \"WCTRuntimeBaseAccessor.h\"\n\ntemplate<typename PropertyType, typename Enable = void>\nclass WCTRuntimeCppAccessor final {};\n\ntemplate<typename PropertyType>\nclass WCTRuntimeCppAccessor<PropertyType, typename std::enable_if<WCDB::ColumnInfo<PropertyType>::isBaseType>::type> final\n: public WCTRuntimeAccessor<PropertyType>,\n  public WCTCppAccessor<(WCDB::ColumnType) WCDB::ColumnInfo<PropertyType>::type> {\n    static_assert(std::is_fundamental<PropertyType>::value || std::is_enum<PropertyType>::value,\n                  \"Only fundamental C/Cpp types is allowed. For other types, use ObjC types.\");\n\nprotected:\n    using CppAccessor = WCTCppAccessor<WCDB::ColumnInfo<PropertyType>::type>;\n    using RuntimeAccessor = WCTRuntimeAccessor<PropertyType>;\n    using InstanceType = typename RuntimeAccessor::InstanceType;\n    using UnderlyingType = typename CppAccessor::UnderlyingType;\n\npublic:\n    WCTRuntimeCppAccessor(Class cls, const WCDB::UnsafeStringView &propertyName)\n    : RuntimeAccessor(cls, propertyName), CppAccessor()\n    {\n    }\n\n    ~WCTRuntimeCppAccessor() override final = default;\n\n    void setValue(InstanceType instance, UnderlyingType value) override final\n    {\n        this->setProperty(instance, (PropertyType) value);\n    }\n\n    UnderlyingType getValue(InstanceType instance) override final\n    {\n        return (UnderlyingType) this->getProperty(instance);\n    }\n};\n"
  },
  {
    "path": "src/objc/orm/accessor/WCTRuntimeObjCAccessor.h",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"WCTObjCAccessor.h\"\n#import \"WCTRuntimeBaseAccessor.h\"\n#import <objc/runtime.h>\n\nclass WCDB_API WCTRuntimeObjCAccessor final : public WCTRuntimeAccessor<id>,\n                                              public WCTObjCAccessor {\nprotected:\n    using InstanceType = WCTObjCAccessor::InstanceType;\n    using PropertyType = NSObject *; //NSObject<WCTColumnCoding>*\n\npublic:\n    WCTRuntimeObjCAccessor(Class instanceClass, const WCDB::UnsafeStringView &propertyName, Class propCls = nil) __attribute__((always_inline));\n\n    ~WCTRuntimeObjCAccessor() override;\n\n    void setObject(InstanceType instance, OCType value) override final;\n    OCType getObject(InstanceType instance) override final;\n\nprotected:\n    WCDB::ColumnType getColumnType() const override final;\n\n    Class m_propertyClass;\n    IMP m_impForArchiveSelector;\n    IMP m_impForUnarchiveSelector;\n    const WCDB::ColumnType m_columnType;\n\n    static WCDB::ColumnType GetColumnType(Class propertyClass);\n    static SEL archiveSelector();\n    static SEL unarchiveSelector();\n};\n"
  },
  {
    "path": "src/objc/orm/accessor/WCTRuntimeObjCAccessor.mm",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"WCTRuntimeObjCAccessor.h\"\n#import \"Assertion.hpp\"\n#import \"CommonCore.h\"\n#import \"Notifier.hpp\"\n#import \"StringView.hpp\"\n#import \"WCDBError.hpp\"\n\nWCTRuntimeObjCAccessor::WCTRuntimeObjCAccessor(Class instanceClass, const WCDB::UnsafeStringView &propertyName, Class propCls)\n: WCTRuntimeAccessor<id>(instanceClass, propertyName)\n, WCTObjCAccessor()\n, m_propertyClass(propCls ? propCls : getPropertyClass(instanceClass, propertyName))\n, m_impForArchiveSelector(getInstanceMethodImplementation(m_propertyClass, archiveSelector()))\n, m_impForUnarchiveSelector(getClassMethodImplementation(m_propertyClass, unarchiveSelector()))\n, m_columnType(GetColumnType(m_propertyClass))\n{\n    WCTRemedialAssert(m_propertyClass != nil, WCDB::StringView::formatted(\"Unable to find out the %s.%s.\", NSStringFromClass(instanceClass).UTF8String, propertyName.data()), ;);\n    WCTRemedialAssert([m_propertyClass conformsToProtocol:@protocol(WCTColumnCoding)], WCDB::StringView::formatted(\"%s should conform to protocol WCTColumnCoding.\", propertyName.data()), ;);\n}\n\nWCTRuntimeObjCAccessor::~WCTRuntimeObjCAccessor() = default;\n\nvoid WCTRuntimeObjCAccessor::setObject(InstanceType instance, OCType value)\n{\n    using Unarchiver = PropertyType (*)(Class, SEL, OCType);\n    if (instance != nil) {\n        PropertyType property = ((Unarchiver) m_impForUnarchiveSelector)(m_propertyClass, unarchiveSelector(), value);\n        setProperty(instance, property);\n    }\n}\n\nWCTRuntimeObjCAccessor::OCType WCTRuntimeObjCAccessor::getObject(InstanceType instance)\n{\n    using Archiver = OCType (*)(InstanceType, SEL);\n    PropertyType property = getProperty(instance);\n    OCType value = property ? ((Archiver) m_impForArchiveSelector)(property, archiveSelector()) : nil;\n    return value;\n}\n\nWCDB::ColumnType WCTRuntimeObjCAccessor::getColumnType() const\n{\n    return m_columnType;\n}\n\nSEL WCTRuntimeObjCAccessor::archiveSelector()\n{\n    static SEL s_archiveSelector = NSSelectorFromString(@\"archivedWCTValue\");\n    return s_archiveSelector;\n}\n\nSEL WCTRuntimeObjCAccessor::unarchiveSelector()\n{\n    static SEL s_unarchiveSelector = NSSelectorFromString(@\"unarchiveWithWCTValue:\");\n    return s_unarchiveSelector;\n}\n\nWCDB::ColumnType WCTRuntimeObjCAccessor::GetColumnType(Class propertyClass)\n{\n    static SEL s_columnTypeSelector = NSSelectorFromString(@\"columnType\");\n    IMP implementation = getClassMethodImplementation(propertyClass, s_columnTypeSelector);\n    using GetColumnTyper = WCDB::ColumnType (*)(Class, SEL);\n    return ((GetColumnTyper) implementation)(propertyClass, s_columnTypeSelector);\n}\n"
  },
  {
    "path": "src/objc/orm/binding/WCTBinding.h",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"BaseBinding.hpp\"\n#import \"CaseInsensitiveList.hpp\"\n#import \"StringView.hpp\"\n#import \"WCTColumnCoding.h\"\n#import \"WCTCommon.h\"\n#import \"WCTProperty.h\"\n#import \"WCTTableCoding.h\"\n#import <map>\n\nclass WCDB_API WCTBinding final : public WCDB::BaseBinding {\n#pragma mark - Binding\npublic:\n    WCTBinding(Class cls);\n    ~WCTBinding() override;\n    static void assertNoInheritance(const WCTProperty &property, Class cls);\n\nprivate:\n    Class m_cls;\n\n#pragma mark - Property\npublic:\n    const WCTProperties &getProperties() const;\n\nprivate:\n    WCTProperties m_properties;\n\n#pragma mark - Column Def\npublic:\n    WCDB::ColumnDef *getColumnDef(const WCTProperty &property);\n};\n"
  },
  {
    "path": "src/objc/orm/binding/WCTBinding.mm",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"WCTBinding.h\"\n#import \"Assertion.hpp\"\n#import \"WCDBError.hpp\"\n#import \"WCTColumnBinding.h\"\n#import \"WCTColumnCoding.h\"\n#import \"WCTMacro.h\"\n#import \"WCTProperty.h\"\n#import \"WCTTableCoding.h\"\n#import <objc/runtime.h>\n\n#pragma mark - Binding\nWCTBinding::WCTBinding(Class cls)\n: WCDB::BaseBinding(), m_cls(cls)\n{\n    // __wcdb_\n    NSString *prefix = @WCDB_STRINGIFY(WCDB_ORM_PREFIX) \"_\";\n    // synthesize_\n    NSString *synthesize = @WCDB_STRINGIFY(WCDB_ORM_TYPE_SYNTHESIZE) \"_\";\n    NSRange synthesizeRange = NSMakeRange(prefix.length, synthesize.length);\n\n    unsigned int numberOfMethods = 0;\n    Method *methods = class_copyMethodList(object_getClass(m_cls), &numberOfMethods);\n    WCTAssert(methods != nullptr && numberOfMethods > 0);\n    NSMutableArray<NSString *> *synthesizations = [NSMutableArray<NSString *> arrayWithCapacity:numberOfMethods];\n    NSMutableArray<NSString *> *others = [NSMutableArray<NSString *> arrayWithCapacity:numberOfMethods];\n    for (unsigned int i = 0; i < numberOfMethods; i++) {\n        Method method = methods[i];\n        NSString *selName = NSStringFromSelector(method_getName(method));\n        if ([selName hasPrefix:prefix]) {\n            if ([selName compare:synthesize options:0 range:synthesizeRange] == NSOrderedSame) {\n                [synthesizations addObject:selName];\n            } else {\n                [others addObject:selName];\n            }\n        }\n    }\n    if (methods != nullptr) {\n        free(methods);\n    }\n\n    static auto s_numbericComparator = ^NSComparisonResult(NSString *str1, NSString *str2) {\n        return [str1 compare:str2 options:NSNumericSearch];\n    };\n    [synthesizations sortUsingComparator:s_numbericComparator];\n    [others sortUsingComparator:s_numbericComparator];\n\n    for (NSString *selName in synthesizations) {\n        SEL selector = NSSelectorFromString(selName);\n        IMP imp = [m_cls methodForSelector:selector];\n        const WCTProperty &property = ((const WCTProperty &(*) (Class, SEL)) imp)(m_cls, selector);\n        WCTRemedialAssert(getColumnDef(property) == nullptr, WCDB::StringView::formatted(\"Duplicated property [%s] found\", property.getDescription().data()), continue;);\n        m_properties.push_back(property);\n        m_columnDefs.push_back({ property.getDescription(), WCDB::ColumnDef(property, property.getColumnBinding().getAccessor()->getColumnType()) });\n    }\n    for (NSString *selName in others) {\n        SEL selector = NSSelectorFromString(selName);\n        IMP imp = [m_cls methodForSelector:selector];\n        ((void (*)(Class, SEL, WCTBinding &)) imp)(m_cls, selector, *this);\n    }\n\n    // additional object relational mapping\n    if ([m_cls respondsToSelector:@selector(additionalObjectRelationalMapping:)]) {\n        [m_cls additionalObjectRelationalMapping:*this];\n    }\n\n#if WCDB_WECHAT_IOS\n    // 兼容微信\n    m_columnDefs.alphabeticallyCaseInsensitiveSort();\n#endif\n}\n\nWCTBinding::~WCTBinding() = default;\n\nvoid WCTBinding::assertNoInheritance(const WCTProperty &property, Class cls)\n{\n    WCTRemedialAssert(property.getColumnBinding().getClass() == cls, \"Inheritance is not supported for ORM.\", ;);\n}\n\n#pragma mark - Property\nconst WCTProperties &WCTBinding::getProperties() const\n{\n    return m_properties;\n}\n\n#pragma mark - Column Def\nWCDB::ColumnDef *WCTBinding::getColumnDef(const WCTProperty &property)\n{\n    WCDB::StringView name = property.getDescription();\n    return BaseBinding::getColumnDef(name);\n}\n"
  },
  {
    "path": "src/objc/orm/binding/WCTColumnBinding.h",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"WCTCommon.h\"\n#import \"WCTRuntimeCppAccessor.h\"\n#import \"WCTRuntimeObjCAccessor.h\"\n\nclass WCDB_API WCTColumnBinding final {\npublic:\n    template<typename T>\n    static WCTColumnBinding generate(Class cls, const WCDB::UnsafeStringView& propertyName)\n    {\n        return WCTColumnBinding(cls, propertyName, (T*) nullptr);\n    }\n\n    template<typename T>\n    WCTColumnBinding(Class cls,\n                     const WCDB::UnsafeStringView& propertyName,\n                     T* = nullptr,\n                     typename std::enable_if<!WCDB::IsObjCType<T>::value>::type* = nullptr)\n    : WCTColumnBinding(cls,\n                       std::static_pointer_cast<WCTBaseAccessor>(\n                       std::make_shared<WCTRuntimeCppAccessor<T>>(cls, propertyName)),\n                       propertyName)\n    {\n    }\n\n    template<typename T>\n    WCTColumnBinding(Class cls,\n                     const WCDB::UnsafeStringView& propertyName,\n                     T* = nullptr,\n                     typename std::enable_if<WCDB::IsObjCType<T>::value>::type* = nullptr)\n    : WCTColumnBinding(cls,\n                       std::static_pointer_cast<WCTBaseAccessor>(\n                       std::make_shared<WCTRuntimeObjCAccessor>(cls, propertyName, [std::remove_pointer_t<WCDB::remove_ownership_t<T>> class])),\n                       propertyName)\n    {\n    }\n\n    WCTColumnBinding();\n\n    Class getClass() const;\n    const WCDB::UnsafeStringView& getPropertyName() const;\n    const std::shared_ptr<const WCTBaseAccessor>& getAccessor() const;\n\n    bool operator==(const WCTColumnBinding& other) const;\n\nprotected:\n    WCTColumnBinding(Class cls,\n                     const std::shared_ptr<const WCTBaseAccessor> accessor,\n                     const WCDB::UnsafeStringView& propertyName);\n\n    Class m_class;\n    WCDB::StringView m_propertyName;\n    std::shared_ptr<const WCTBaseAccessor> m_accessor;\n};\n\nclass WCDB_API WCTColumnBindingHolder {\npublic:\n    WCTColumnBindingHolder();\n    WCTColumnBindingHolder(const WCTColumnBinding& columnBinding);\n    virtual ~WCTColumnBindingHolder() = 0;\n\n    WCTResultColumn redirect(const WCDB::ResultColumn& resultColumn) const;\n\n    const WCTColumnBinding& getColumnBinding() const;\n\nprotected:\n    WCTColumnBinding m_columnBinding;\n};\n"
  },
  {
    "path": "src/objc/orm/binding/WCTColumnBinding.mm",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"WCTColumnBinding.h\"\n#import \"WCTResultColumn.h\"\n\nWCTColumnBinding::WCTColumnBinding(Class cls,\n                                   const std::shared_ptr<const WCTBaseAccessor> accessor,\n                                   const WCDB::UnsafeStringView& propertyName)\n: m_class(cls)\n, m_propertyName(propertyName)\n, m_accessor(accessor)\n{\n}\n\nWCTColumnBinding::WCTColumnBinding()\n: m_class(nil)\n, m_accessor(nullptr)\n{\n}\n\nClass WCTColumnBinding::getClass() const\n{\n    return m_class;\n}\n\nconst WCDB::UnsafeStringView& WCTColumnBinding::getPropertyName() const\n{\n    return m_propertyName;\n}\n\nconst std::shared_ptr<const WCTBaseAccessor>& WCTColumnBinding::getAccessor() const\n{\n    return m_accessor;\n}\n\nbool WCTColumnBinding::operator==(const WCTColumnBinding& other) const\n{\n    // ignoring accessor since it's generated by class and property\n    return m_class == other.m_class && m_propertyName == other.m_propertyName;\n}\n\nWCTColumnBindingHolder::WCTColumnBindingHolder() = default;\n\nWCTColumnBindingHolder::WCTColumnBindingHolder(const WCTColumnBinding& columnBinding)\n: m_columnBinding(columnBinding)\n{\n}\n\nWCTColumnBindingHolder::~WCTColumnBindingHolder() = default;\n\nconst WCTColumnBinding& WCTColumnBindingHolder::getColumnBinding() const\n{\n    return m_columnBinding;\n}\n\nWCTResultColumn WCTColumnBindingHolder::redirect(const WCDB::ResultColumn& resultColumn) const\n{\n    return WCTResultColumn(resultColumn, m_columnBinding);\n}\n"
  },
  {
    "path": "src/objc/orm/coding/WCTColumnCoding.h",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"WCTValue.h\"\n\nNS_ASSUME_NONNULL_BEGIN\n\n@protocol WCTColumnCoding\n@required\n+ (nullable instancetype)unarchiveWithWCTValue:(nullable WCTValue *)value;\n- (nullable WCTValue *)archivedWCTValue;\n+ (WCTColumnType)columnType;\n@end\n\nNS_ASSUME_NONNULL_END\n"
  },
  {
    "path": "src/objc/orm/coding/WCTProperty.h",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"WCTColumnBinding.h\"\n#import \"WCTCommon.h\"\n\nclass WCDB_API WCTProperty final : public WCDB::Column, public WCTColumnBindingHolder {\npublic:\n    WCTProperty();\n    WCTProperty(const WCTColumnBinding& columnBinding);\n    WCTProperty(const WCDB::UnsafeStringView& name, const WCTColumnBinding& columnBinding);\n    ~WCTProperty() override;\n\n    WCTProperty table(const WCDB::UnsafeStringView& table) const;\n    WCTProperty schema(const WCDB::Schema& schema) const;\n\nprivate:\n    WCTProperty(const WCTColumnBinding& columnBinding, const Column& column);\n    void configTableBindingRetrive();\n};\n\nnamespace WCDB {\n\ntemplate<>\nclass WCDB_API SyntaxList<WCTProperty> final : public _SyntaxList<WCTProperty> {\npublic:\n    using _SyntaxList<WCTProperty>::_SyntaxList;\n    ~SyntaxList() override;\n\n    WCTResultColumns redirect(const WCDB::ResultColumns& resultColumns) const;\n\n    typedef WCDB::ResultColumn (^WCTRedirectBlock)(const WCTProperty&);\n    WCTResultColumns redirect(WCTRedirectBlock block) const;\n\n    // It's not the count of the list, but the SQL function `count(*)`.\n    WCDB::Expression count() const;\n\n    WCDB::Expressions table(NSString* table) const;\n\n    WCTProperties propertiesByAddingNewProperties(const WCTProperties& properties) const;\n    WCTProperties& addingNewProperties(const WCTProperties& properties);\n\n    WCTProperties propertiesByRemovingProperties(const WCTProperties& properties) const;\n    WCTProperties& removingProperties(const WCTProperties& properties);\n\nprivate:\n    static bool isEqual(const WCTProperty& left, const WCTProperty& right);\n};\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/objc/orm/coding/WCTProperty.mm",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"WCTProperty.h\"\n#import \"Assertion.hpp\"\n#import \"WCTBinding.h\"\n#import \"WCTColumnBinding.h\"\n#import \"WCTResultColumn.h\"\n#import \"WCTTableCoding.h\"\n\n#pragma mark - WCTProperty\n\nWCTProperty::WCTProperty() = default;\nWCTProperty::~WCTProperty() = default;\n\nWCTProperty::WCTProperty(const WCTColumnBinding& columnBinding)\n: WCDB::Column(columnBinding.getPropertyName())\n, WCTColumnBindingHolder(columnBinding)\n{\n    configTableBindingRetrive();\n}\n\nWCTProperty::WCTProperty(const WCDB::UnsafeStringView& name, const WCTColumnBinding& columnBinding)\n: WCDB::Column(name)\n, WCTColumnBindingHolder(columnBinding)\n{\n    configTableBindingRetrive();\n}\n\nWCTProperty::WCTProperty(const WCTColumnBinding& columnBinding, const Column& column)\n: WCDB::Column(column)\n, WCTColumnBindingHolder(columnBinding)\n{\n    configTableBindingRetrive();\n}\n\nvoid WCTProperty::configTableBindingRetrive()\n{\n    Class cls = m_columnBinding.getClass();\n    syntax().tableBindingRetrive = [=]() {\n        if ([cls respondsToSelector:@selector(objectRelationalMapping)]) {\n            return static_cast<const WCDB::BaseBinding*>(&[cls objectRelationalMapping]);\n        }\n        return (const WCDB::BaseBinding*) nullptr;\n    };\n}\n\nWCTProperty WCTProperty::table(const WCDB::UnsafeStringView& table) const\n{\n    return WCTProperty(m_columnBinding, WCDB::Column(*this).table(table));\n}\n\nWCTProperty WCTProperty::schema(const WCDB::Schema& schema) const\n{\n    return WCTProperty(m_columnBinding, WCDB::Column(*this).schema(schema));\n}\n\n#pragma mark - WCTProperties\nWCTProperties::~SyntaxList() = default;\n\nWCDB::Expression WCTProperties::count() const\n{\n    return Expression::function(\"count\").invokeAll();\n}\n\nWCTResultColumns WCTProperties::redirect(const WCDB::ResultColumns& resultColumns) const\n{\n    WCTResultColumns result;\n    auto property = begin();\n    auto resultColumn = resultColumns.begin();\n    while (property != end() && resultColumn != resultColumns.end()) {\n        result.push_back(WCTResultColumn(*resultColumn, property->getColumnBinding()));\n        ++property;\n        ++resultColumn;\n    }\n    return result;\n}\n\nWCTResultColumns WCTProperties::redirect(WCTRedirectBlock block) const\n{\n    WCTRemedialAssert(block != nil, \"Redirect block can't be null.\", return *this;);\n    WCTResultColumns results;\n    for (const auto& property : *this) {\n        results.push_back(WCTResultColumn(block(property), property.getColumnBinding()));\n    }\n    return results;\n}\n\nWCDB::Expressions WCTProperties::table(NSString* table) const\n{\n    WCDB::Expressions expressions;\n    for (const auto& property : *this) {\n        expressions.push_back(property.table(table));\n    }\n    return expressions;\n}\n\nWCTProperties WCTProperties::propertiesByAddingNewProperties(const WCTProperties& properties) const\n{\n    WCTProperties newProperties = *this;\n    newProperties.insert(newProperties.begin(), properties.begin(), properties.end());\n    return newProperties;\n}\n\nWCTProperties& WCTProperties::addingNewProperties(const WCTProperties& properties)\n{\n    insert(end(), properties.begin(), properties.end());\n    return *this;\n}\n\nbool WCTProperties::isEqual(const WCTProperty& left, const WCTProperty& right)\n{\n    return left.getColumnBinding() == right.getColumnBinding() && left.getDescription() == right.getDescription();\n}\n\nWCTProperties WCTProperties::propertiesByRemovingProperties(const WCTProperties& properties) const\n{\n    WCTProperties newProperties;\n    for (const auto& property : *this) {\n        if (std::find_if(properties.begin(), properties.end(), std::bind(&WCTProperties::isEqual, property, std::placeholders::_1)) == properties.end()) {\n            newProperties.push_back(property);\n        }\n    }\n    return newProperties;\n}\n\nWCTProperties& WCTProperties::removingProperties(const WCTProperties& properties)\n{\n    for (const auto& property : properties) {\n        auto iter = std::find_if(begin(), end(), std::bind(&WCTProperties::isEqual, property, std::placeholders::_1));\n        if (iter != end()) {\n            erase(iter);\n        }\n    }\n    return *this;\n}\n"
  },
  {
    "path": "src/objc/orm/coding/WCTResultColumn.h",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"WCTColumnBinding.h\"\n#import \"WCTCommon.h\"\n\nclass WCDB_API WCTResultColumn final : public WCDB::ResultColumn, public WCTColumnBindingHolder {\npublic:\n    WCTResultColumn();\n    WCTResultColumn(const WCTProperty& property);\n    WCTResultColumn(const WCDB::ResultColumn& resultColumn,\n                    const WCTColumnBinding& columnBinding);\n    ~WCTResultColumn() override;\n};\n\nnamespace WCDB {\n\ntemplate<>\nclass WCDB_API SyntaxList<WCTResultColumn> final : public _SyntaxList<WCTResultColumn> {\npublic:\n    using _SyntaxList<WCTResultColumn>::_SyntaxList;\n    ~SyntaxList() override;\n\n    WCTResultColumns\n    resultColumnsByAddingNewResultColumns(const WCTResultColumns& resultColumns) const;\n    WCTResultColumns& addingNewResultColumns(const WCTResultColumns& resultColumns);\n\n    WCTResultColumns\n    resultColumnsByRemovingResultColumns(const WCTResultColumns& resultColumns) const;\n    WCTResultColumns& removingResultColumns(const WCTResultColumns& resultColumns);\n\nprivate:\n    static bool isEqual(const WCTResultColumn& left, const WCTResultColumn& right);\n};\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/objc/orm/coding/WCTResultColumn.mm",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"WCTResultColumn.h\"\n#import \"CommonCore.h\"\n#import \"WCTORM.h\"\n#import \"WCTProperty.h\"\n\nWCTResultColumn::WCTResultColumn() = default;\n\nWCTResultColumn::WCTResultColumn(const WCTProperty& property)\n: WCDB::ResultColumn(property)\n, WCTColumnBindingHolder(property.getColumnBinding())\n{\n}\n\nWCTResultColumn::WCTResultColumn(const WCDB::ResultColumn& resultColumn, const WCTColumnBinding& columnBinding)\n: WCDB::ResultColumn(resultColumn)\n, WCTColumnBindingHolder(columnBinding)\n{\n}\n\nWCTResultColumn::~WCTResultColumn() = default;\n\nWCTResultColumns::~SyntaxList() = default;\n\nWCTResultColumns WCTResultColumns::resultColumnsByAddingNewResultColumns(const WCTResultColumns& resultColumns) const\n{\n    WCTResultColumns newResultColumns = *this;\n    newResultColumns.insert(newResultColumns.end(), resultColumns.begin(), resultColumns.end());\n    return newResultColumns;\n}\n\nWCTResultColumns& WCTResultColumns::addingNewResultColumns(const WCTResultColumns& resultColumns)\n{\n    insert(end(), resultColumns.begin(), resultColumns.end());\n    return *this;\n}\n\nbool WCTResultColumns::isEqual(const WCTResultColumn& left, const WCTResultColumn& right)\n{\n    return left.getColumnBinding() == right.getColumnBinding() && left.getDescription() == right.getDescription();\n}\n\nWCTResultColumns WCTResultColumns::resultColumnsByRemovingResultColumns(const WCTResultColumns& resultColumns) const\n{\n    WCTResultColumns newResultColumns;\n    for (const auto& resultColumn : *this) {\n        if (std::find_if(resultColumns.begin(), resultColumns.end(), std::bind(&WCTResultColumns::isEqual, resultColumn, std::placeholders::_1)) == resultColumns.end()) {\n            newResultColumns.push_back(resultColumn);\n        }\n    }\n    return newResultColumns;\n}\n\nWCTResultColumns& WCTResultColumns::removingResultColumns(const WCTResultColumns& resultColumns)\n{\n    for (const auto& resultColumn : resultColumns) {\n        auto iter = std::find_if(begin(), end(), std::bind(&WCTResultColumns::isEqual, resultColumn, std::placeholders::_1));\n        if (iter != end()) {\n            erase(iter);\n        }\n    }\n    return *this;\n}\n"
  },
  {
    "path": "src/objc/orm/coding/WCTTableCoding.h",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#ifdef WCDB_SWIFT\n\n#import \"WCTBridgeProperty.h\"\n\n#elif __cplusplus\n\n#import \"WCTBridgeProperty+CPP.h\"\n#import \"WCTCommon.h\"\n#import \"WCTProperty.h\"\n\n#endif\n\nNS_ASSUME_NONNULL_BEGIN\n\n@protocol WCTTableCoding <NSObject>\n\n#ifdef WCDB_SWIFT\n\n@required\n+ (WCTBridgeProperties *)allBridgeProperties NS_SWIFT_NAME(allProperties());\n\n#elif __cplusplus\n\n@required\n+ (const WCTBinding &)objectRelationalMapping;\n+ (const WCTProperties &)allProperties;\n@optional\n+ (void)additionalObjectRelationalMapping:(WCTBinding &)binding;\n\n#endif\n\n@optional\n@property (nonatomic, assign) long long lastInsertedRowID;\n@property (nonatomic, assign) BOOL isAutoIncrement;\n\n@end\n\nNS_ASSUME_NONNULL_END\n"
  },
  {
    "path": "src/objc/orm/macro/WCTColumnConstraintMacro.h",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#define WCDB_ORM_TYPE_COLUMN_CONSTRAINT column_constraint\n\n#define __WCDB_COLUMN_CONSTRAINT_BEGIN(propertyName)         \\\n    +(void) WCDB_ORM_UNIQUE(WCDB_ORM_TYPE_COLUMN_CONSTRAINT) \\\n    {                                                        \\\n        WCDB_STATIC_ASSERT_EXISTS(self.propertyName);        \\\n        WCDB::ColumnConstraint columnConstraint;\n\n#define __WCDB_COLUMN_CONSTRAINT_END(propertyName)                         \\\n    binding.getColumnDef(self.propertyName)->constraint(columnConstraint); \\\n    }\n\n// primary\n#define __WCDB_ORDERED_PRIMARY_IMP(propertyName, order_, autoIncrement_) \\\n    WCDB_IF(autoIncrement_, @synthesize isAutoIncrement;)                \\\n    __WCDB_COLUMN_CONSTRAINT_BEGIN(propertyName)                         \\\n    columnConstraint.primaryKey().order(order_);                         \\\n    WCDB_IF(autoIncrement_, columnConstraint.autoIncrement());           \\\n    __WCDB_COLUMN_CONSTRAINT_END(propertyName)\n\n#define __WCDB_PRIMARY_IMP(propertyName, autoIncrement_)       \\\n    WCDB_IF(autoIncrement_, @synthesize isAutoIncrement;)      \\\n    __WCDB_COLUMN_CONSTRAINT_BEGIN(propertyName)               \\\n    columnConstraint.primaryKey();                             \\\n    WCDB_IF(autoIncrement_, columnConstraint.autoIncrement()); \\\n    __WCDB_COLUMN_CONSTRAINT_END(propertyName)\n\n#define __WCDB_PRIMARY_ENABLE_AUTOINCREMENT_FOR_EXISTING_TABLE \\\n    +(void) WCDB_ORM_UNIQUE(WCDB_ORM_TYPE_COLUMN_CONSTRAINT)   \\\n    {                                                          \\\n        binding.enableAutoIncrementForExistingTable();         \\\n    }\n\n// not null\n#define __WCDB_NOT_NULL_IMP(propertyName)        \\\n    __WCDB_COLUMN_CONSTRAINT_BEGIN(propertyName) \\\n    columnConstraint.notNull();                  \\\n    __WCDB_COLUMN_CONSTRAINT_END(propertyName)\n\n// unique\n#define __WCDB_UNIQUE_IMP(propertyName)          \\\n    __WCDB_COLUMN_CONSTRAINT_BEGIN(propertyName) \\\n    columnConstraint.unique();                   \\\n    __WCDB_COLUMN_CONSTRAINT_END(propertyName)\n\n// default\n#define __WCDB_DEFAULT_IMP(propertyName, defaultValue) \\\n    __WCDB_COLUMN_CONSTRAINT_BEGIN(propertyName)       \\\n    columnConstraint.default_(defaultValue);           \\\n    __WCDB_COLUMN_CONSTRAINT_END(propertyName)\n\n// check\n#define __WCDB_CHECK_IMP(propertyName, condition) \\\n    __WCDB_COLUMN_CONSTRAINT_BEGIN(propertyName)  \\\n    columnConstraint.check(condition);            \\\n    __WCDB_COLUMN_CONSTRAINT_END(propertyName)\n\n// unindexed for fts\n#define __WCDB_UNINDEXED_IMP(propertyName)       \\\n    __WCDB_COLUMN_CONSTRAINT_BEGIN(propertyName) \\\n    columnConstraint.unIndexed();                \\\n    __WCDB_COLUMN_CONSTRAINT_END(propertyName)\n"
  },
  {
    "path": "src/objc/orm/macro/WCTIndexMacro.h",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#define WCDB_ORM_TYPE_INDEX index\n\n#define __WCDB_INDEX_BEGIN(indexSuffixName)                                    \\\n    +(void) WCDB_ORM_UNIQUE(WCDB_ORM_TYPE_INDEX)                               \\\n    {                                                                          \\\n        WCDB::BaseBinding::Index &index = binding.getOrCreateIndex(indexSuffixName);\n\n#define __WCDB_INDEX_END(indexSuffixName) }\n\n#define __WCDB_ORDERED_INDEX_IMP(indexSuffixName, propertyName, order_, isUnique) \\\n    __WCDB_INDEX_BEGIN(indexSuffixName)                                           \\\n    WCDB_STATIC_ASSERT_EXISTS(self.propertyName);                                 \\\n    WCDB_IF(isUnique, index.statement.unique();)                                  \\\n    index.statement.indexed(self.propertyName.asIndex().order(order_));           \\\n    __WCDB_INDEX_END(indexSuffixName)\n\n#define __WCDB_INDEX_IMP(indexSuffixName, propertyName, isUnique)              \\\n    __WCDB_INDEX_BEGIN(indexSuffixName)                                        \\\n    WCDB_STATIC_ASSERT_EXISTS(self.propertyName);                              \\\n    WCDB_IF(isUnique, index.statement.unique();)                               \\\n    index.statement.indexed(self.propertyName.asIndex());                      \\\n    __WCDB_INDEX_END(indexSuffixName)\n\n#define __WCDB_INDEX_FOR_NEWLY_CREATED_TABLE_ONLY_IMP(indexSuffixName)               \\\n    __WCDB_INDEX_BEGIN(indexSuffixName)                                              \\\n    index.action = WCDB::BaseBinding::Index::Action::CreateForNewlyCreatedTableOnly; \\\n    __WCDB_INDEX_END(indexSuffixName)\n\n#define __WCDB_INDEX_TO_BE_DROPPED(indexSuffixName)                            \\\n    __WCDB_INDEX_BEGIN(indexSuffixName)                                        \\\n    index.action = WCDB::BaseBinding::Index::Action::Drop;                     \\\n    __WCDB_INDEX_END(indexSuffixName)\n"
  },
  {
    "path": "src/objc/orm/macro/WCTMacro.h",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"Macro.h\"\n\n#import \"WCTMacroUtility.h\"\n\n#import \"WCTColumnConstraintMacro.h\"\n#import \"WCTIndexMacro.h\"\n#import \"WCTPropertyMacro.h\"\n#import \"WCTTableConstraintMacro.h\"\n#import \"WCTVirtualTableMacro.h\"\n\n#define WCDB_IMPLEMENTATION(className)                                               \\\n    +(const WCTBinding &) objectRelationalMapping                                    \\\n    {                                                                                \\\n        static const WCTBinding *s_binding = new WCTBinding(className.class);        \\\n        return *s_binding;                                                           \\\n    }                                                                                \\\n    +(const WCTProperties &) allProperties                                           \\\n    {                                                                                \\\n        return [className objectRelationalMapping].getProperties();                  \\\n    }                                                                                \\\n    +(WCTBridgeProperties *) allBridgeProperties                                     \\\n    {                                                                                \\\n        NSMutableArray *properties = [[NSMutableArray alloc] init];                  \\\n        for (const WCTProperty &property : [self allProperties]) {                   \\\n            [properties addObject:[WCTBridgeProperty creatBridgeProperty:property]]; \\\n        }                                                                            \\\n        return properties;                                                           \\\n    }                                                                                \\\n    +(className *) WCDB_ORM_TYPER                                                    \\\n    {                                                                                \\\n        return nil;                                                                  \\\n    }\n\n// Property - declare column\n#define WCDB_PROPERTY(propertyName) __WCDB_PROPERTY_IMP(propertyName)\n\n// Synthesize - implement column\n#define WCDB_SYNTHESIZE(propertyName) \\\n    __WCDB_SYNTHESIZE_IMP(propertyName, propertyName, WCDB_STRINGIFY(propertyName))\n\n#define WCDB_SYNTHESIZE_COLUMN(propertyName, columnName) \\\n    __WCDB_SYNTHESIZE_IMP(propertyName, propertyName, columnName)\n\n#define WCDB_SYNTHESIZE_CUSTOM(WINQName, propertyName, columnName) \\\n    __WCDB_SYNTHESIZE_IMP(WINQName, propertyName, columnName)\n\n// Column Constraint\n#define WCDB_PRIMARY(propertyName) \\\n    __WCDB_PRIMARY_IMP(propertyName, false)\n\n#define WCDB_PRIMARY_ASC(propertyName) \\\n    __WCDB_ORDERED_PRIMARY_IMP(propertyName, WCTOrderedAscending, false)\n\n#define WCDB_PRIMARY_DESC(propertyName) \\\n    __WCDB_ORDERED_PRIMARY_IMP(propertyName, WCTOrderedDescending, false)\n\n#define WCDB_PRIMARY_AUTO_INCREMENT(propertyName) \\\n    __WCDB_PRIMARY_IMP(propertyName, true)\n\n#define WCDB_PRIMARY_ASC_AUTO_INCREMENT(propertyName) \\\n    __WCDB_ORDERED_PRIMARY_IMP(propertyName, WCTOrderedAscending, true)\n\n#define WCDB_PRIMARY_ENABLE_AUTOINCREMENT_FOR_EXISTING_TABLE \\\n    __WCDB_PRIMARY_ENABLE_AUTOINCREMENT_FOR_EXISTING_TABLE\n\n#define WCDB_NOT_NULL(propertyName) \\\n    __WCDB_NOT_NULL_IMP(propertyName)\n\n#define WCDB_UNIQUE(propertyName) \\\n    __WCDB_UNIQUE_IMP(propertyName)\n\n#define WCDB_DEFAULT(propertyName, defaultValue) \\\n    __WCDB_DEFAULT_IMP(propertyName, defaultValue)\n\n#define WCDB_CHECK(propertyName, condition) \\\n    __WCDB_CHECK_IMP(propertyName, condition)\n\n//For FTS\n#define WCDB_UNINDEXED(propertyName) \\\n    __WCDB_UNINDEXED_IMP(propertyName)\n\n// Table Constraint\n#define WCDB_WITHOUT_ROWID \\\n    __WCDB_WITHOUT_ROWID\n\n#define WCDB_MULTI_PRIMARY(constraintName, propertyName) \\\n    __WCDB_MULTI_PRIMARY_IMP(constraintName, propertyName)\n\n#define WCDB_MULTI_PRIMARY_ASC(constraintName, propertyName) \\\n    __WCDB_ORDERED_MULTI_PRIMARY_IMP(constraintName, propertyName, WCTOrderedAscending)\n\n#define WCDB_MULTI_PRIMARY_DESC(constraintName, propertyName) \\\n    __WCDB_ORDERED_MULTI_PRIMARY_IMP(constraintName, propertyName, WCTOrderedDescending)\n\n#define WCDB_MULTI_UNIQUE(constraintName, propertyName) \\\n    __WCDB_MULTI_UNIQUE_IMP(constraintName, propertyName)\n\n#define WCDB_MULTI_UNIQUE_ASC(constraintName, propertyName) \\\n    __WCDB_ORDERED_MULTI_UNIQUE_IMP(constraintName, propertyName, WCTOrderedAscending)\n\n#define WCDB_MULTI_UNIQUE_DESC(constraintName, propertyName) \\\n    __WCDB_ORDERED_MULTI_UNIQUE_IMP(constraintName, propertyName, WCTOrderedDescending)\n\n// Index\n#define WCDB_INDEX(indexSuffixName, propertyName) \\\n    __WCDB_INDEX_IMP(indexSuffixName, propertyName, false)\n\n#define WCDB_INDEX_ASC(indexSuffixName, propertyName) \\\n    __WCDB_ORDERED_INDEX_IMP(                         \\\n    indexSuffixName, propertyName, WCTOrderedAscending, false)\n\n#define WCDB_INDEX_DESC(indexSuffixName, propertyName) \\\n    __WCDB_ORDERED_INDEX_IMP(                          \\\n    indexSuffixName, propertyName, WCTOrderedDescending, false)\n\n#define WCDB_UNIQUE_INDEX(indexSuffixName, propertyName) \\\n    __WCDB_INDEX_IMP(indexSuffixName, propertyName, true)\n\n#define WCDB_UNIQUE_INDEX_ASC(indexSuffixName, propertyName) \\\n    __WCDB_ORDERED_INDEX_IMP(                                \\\n    indexSuffixName, propertyName, WCTOrderedAscending, true)\n\n#define WCDB_UNIQUE_INDEX_DESC(indexSuffixName, propertyName) \\\n    __WCDB_ORDERED_INDEX_IMP(                                 \\\n    indexSuffixName, propertyName, WCTOrderedDescending, true)\n\n// Index Operation\n#define WCDB_INDEX_FOR_NEWLY_CREATED_TABLE_ONLY(indexSuffixName) \\\n    __WCDB_INDEX_FOR_NEWLY_CREATED_TABLE_ONLY_IMP(indexSuffixName)\n\n#define WCDB_INDEX_TO_BE_DROPPED(indexSuffixName) \\\n    __WCDB_INDEX_TO_BE_DROPPED(indexSuffixName)\n\n// Virtual Table Argument\n#define WCDB_VIRTUAL_TABLE_ARGUMENT(argument) \\\n    __WCDB_VIRTUAL_TABLE_ARGUMENT_IMP(argument)\n\n#define WCDB_VIRTUAL_TABLE_TOKENIZE(tokenizeName) \\\n    __WCDB_VIRTUAL_TABLE_ARGUMENT_IMP(WCTFTSTokenizerUtil::tokenize(tokenizeName, nullptr))\n\n#define WCDB_VIRTUAL_TABLE_TOKENIZE_WITH_PARAMETERS(tokenizeName, ...) \\\n    __WCDB_VIRTUAL_TABLE_ARGUMENT_IMP(WCTFTSTokenizerUtil::tokenize(tokenizeName, __VA_ARGS__, nullptr))\n\n#define WCDB_VIRTUAL_TABLE_EXTERNAL_CONTENT(tableName) __WCDB_VIRTUAL_TABLE_ARGUMENT_IMP(WCDB::StatementCreateVirtualTable::externalContent(tableName))\n\n#define WCDB_VIRTUAL_TABLE_MODULE(moduleName) \\\n    __WCDB_VIRTUAL_TABLE_MODULE_IMP(moduleName)\n"
  },
  {
    "path": "src/objc/orm/macro/WCTMacroUtility.h",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#define WCDB_ORM_PREFIX __wcdb\n\n#define WCDB_ORM_CONCAT(a, b) WCDB_CONCAT(a, WCDB_CONCAT(_, b))\n\n#define __WCDB_ORM_TYPE_PREFIX(ORMType)                                        \\\n    WCDB_ORM_CONCAT(WCDB_ORM_PREFIX, ORMType)\n\n#define __WCDB_ORM(ORMType, suffix)                                            \\\n    WCDB_ORM_CONCAT(__WCDB_ORM_TYPE_PREFIX(ORMType), suffix)\n\n#define WCDB_ORM_UNIQUE(ORMType)                                               \\\n    __WCDB_ORM(ORMType, WCDB_UNIQUE_ID) : (WCTBinding &) binding\n"
  },
  {
    "path": "src/objc/orm/macro/WCTPropertyMacro.h",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include \"Macro.h\"\n\n// Property\n#define WCDB_ORM_TYPER __wcdbtyper\n\n#define __WCDB_PROPERTY_TYPE(className, propertyName) \\\n    decltype([className WCDB_ORM_TYPER].propertyName)\n\n#ifdef __cplusplus\n#define __WCDB_PROPERTY_IMP(propertyName) +(const WCTProperty &) propertyName;\n#elif WCDB_SWIFT\n#define __WCDB_PROPERTY_IMP(propertyName) +(WCTBridgeProperty *) swift_##propertyName NS_SWIFT_NAME(propertyName());\n#else\n#define __WCDB_PROPERTY_IMP(propertyName)\n#endif\n\n// Synthesize\n#define WCDB_ORM_TYPE_SYNTHESIZE synthesize\n\n// __wcdb_className_synthesize_uniqueID\n#define __WCDB_SYNTHESIZE_IMP(WINQName, propertyName, columnName)                                                                                                                                               \\\n    +(const WCTProperty &) WINQName                                                                                                                                                                             \\\n    {                                                                                                                                                                                                           \\\n        static const char *name = columnName;                                                                                                                                                                   \\\n        static const WCTProperty *s_property = new WCTProperty(WCDB::StringView::makeConstant(name), WCTColumnBinding::generate<__WCDB_PROPERTY_TYPE(self, propertyName)>(self, WCDB_STRINGIFY(propertyName))); \\\n        WCTBinding::assertNoInheritance(*s_property, self);                                                                                                                                                     \\\n        return *s_property;                                                                                                                                                                                     \\\n    }                                                                                                                                                                                                           \\\n    +(const WCTProperty &) WCDB_ORM_UNIQUE(WCDB_ORM_TYPE_SYNTHESIZE)                                                                                                                                            \\\n    {                                                                                                                                                                                                           \\\n        WCDB_UNUSED(binding);                                                                                                                                                                                   \\\n        return self.WINQName;                                                                                                                                                                                   \\\n    }                                                                                                                                                                                                           \\\n    +(WCTBridgeProperty *) swift_##WINQName                                                                                                                                                                     \\\n    {                                                                                                                                                                                                           \\\n        return [WCTBridgeProperty creatBridgeProperty:[self WINQName]];                                                                                                                                         \\\n    }\n"
  },
  {
    "path": "src/objc/orm/macro/WCTTableConstraintMacro.h",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#define WCDB_ORM_TYPE_TABLE_CONSTRAINT table_constraint\n\n#define __WCDB_TABLE_CONSTRAINT_BEGIN(constraintName, propertyName)            \\\n    +(void) WCDB_ORM_UNIQUE(WCDB_ORM_TYPE_TABLE_CONSTRAINT)                    \\\n    {                                                                          \\\n        WCDB_STATIC_ASSERT_EXISTS(self.propertyName);                          \\\n        WCDB::TableConstraint& tableConstraint                                 \\\n        = binding.getOrCreateTableConstraint(constraintName);\n\n#define __WCDB_TABLE_CONSTRAINT_END(constraintName, propertyName) }\n\n// multi-primary\n#define __WCDB_MULTI_PRIMARY_IMP(constraintName, propertyName)                 \\\n    __WCDB_TABLE_CONSTRAINT_BEGIN(constraintName, propertyName)                \\\n    tableConstraint.primaryKey().indexed(self.propertyName.asIndex());         \\\n    __WCDB_TABLE_CONSTRAINT_END(constraintName, propertyName)\n\n#define __WCDB_ORDERED_MULTI_PRIMARY_IMP(constraintName, propertyName, order_)       \\\n    __WCDB_TABLE_CONSTRAINT_BEGIN(constraintName, propertyName)                      \\\n    tableConstraint.primaryKey().indexed(self.propertyName.asIndex().order(order_)); \\\n    __WCDB_TABLE_CONSTRAINT_END(constraintName, propertyName)\n\n// multi-unique\n#define __WCDB_MULTI_UNIQUE_IMP(constraintName, propertyName)                  \\\n    __WCDB_TABLE_CONSTRAINT_BEGIN(constraintName, propertyName)                \\\n    tableConstraint.unique().indexed(self.propertyName.asIndex());             \\\n    __WCDB_TABLE_CONSTRAINT_END(constraintName, propertyName)\n\n#define __WCDB_ORDERED_MULTI_UNIQUE_IMP(constraintName, propertyName, order_)    \\\n    __WCDB_TABLE_CONSTRAINT_BEGIN(constraintName, propertyName)                  \\\n    tableConstraint.unique().indexed(self.propertyName.asIndex().order(order_)); \\\n    __WCDB_TABLE_CONSTRAINT_END(constraintName, propertyName)\n\n#define __WCDB_WITHOUT_ROWID                                                   \\\n    +(void) WCDB_ORM_UNIQUE(WCDB_ORM_TYPE_TABLE_CONSTRAINT)                    \\\n    {                                                                          \\\n        WCDB::StatementCreateTable& statement = binding.statementTable;        \\\n        statement.withoutRowID();                                              \\\n    }\n"
  },
  {
    "path": "src/objc/orm/macro/WCTVirtualTableMacro.h",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#define WCDB_ORM_TYPE_VIRTUAL_TABLE virtual_table\n\n#define __WCDB_VIRTUAL_TABLE_BEGIN()                                           \\\n    +(void) WCDB_ORM_UNIQUE(WCDB_ORM_TYPE_VIRTUAL_TABLE)                       \\\n    {                                                                          \\\n        WCDB::StatementCreateVirtualTable& statement = binding.statementVirtualTable;\n\n#define __WCDB_VIRTUAL_TABLE_END() }\n\n#define __WCDB_VIRTUAL_TABLE_ARGUMENT_IMP(argument_)                           \\\n    __WCDB_VIRTUAL_TABLE_BEGIN()                                               \\\n    statement.argument(argument_);                                             \\\n    __WCDB_VIRTUAL_TABLE_END()\n\n#define __WCDB_VIRTUAL_TABLE_MODULE_IMP(moduleName)                            \\\n    __WCDB_VIRTUAL_TABLE_BEGIN()                                               \\\n    statement.usingModule(moduleName);                                         \\\n    __WCDB_VIRTUAL_TABLE_END()\n"
  },
  {
    "path": "src/objc/statement/WCTPreparedStatement+Private.h",
    "content": "//\n// Created by qiuwenchen on 2020/2/24.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n#import \"CommonCore.h\"\n#import \"WCTHandle.h\"\n#import \"WCTPreparedStatement.h\"\n\nWCDB_API @interface WCTPreparedStatement() {\n@private\n    WCDB::HandleStatement* _handleStatement;\n}\n- (instancetype)initWithHandleStatement:(WCDB::HandleStatement*)handlesStatement;\n- (WCDB::HandleStatement*)getRawHandleStatement;\n@end\n"
  },
  {
    "path": "src/objc/statement/WCTPreparedStatement.h",
    "content": "//\n// Created by qiuwenchen on 2020/2/23.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n#import \"WCTCommon.h\"\nNS_ASSUME_NONNULL_BEGIN\n\n/**\n This class is a wrapper for `sqlite3_stmt`.\n @warning Not Thread-safe.\n */\nWCDB_API @interface WCTPreparedStatement : NSObject\n\n/**\n You should use `-[WCTHandle getOrCreatePreparedStatement:]` to obtain WCTPreparedStatement.\n */\n- (instancetype)init UNAVAILABLE_ATTRIBUTE;\n\n#pragma mark - Step\n/**\n @brief The wrapper of `sqlite3_step`.\n @return YES if no error occurs.\n */\n- (BOOL)step;\n\n/**\n @brief The wrapper of `sqlite3_reset`.\n */\n- (void)reset;\n\n/**\n @brief The wrapper of `sqlite3_clear_bindings`.\n */\n- (void)clearBindings;\n\n/**\n @brief Check if you can continue stepping.\n @return YES if you can continue stepping.\n */\n- (BOOL)done;\n\n#pragma mark - State\n\n/**\n @brief The wrapper of `sqlite3_stmt_readonly`.\n */\n- (BOOL)isStatementReadonly;\n\n#pragma mark - Bind\n/**\n @brief The wrapper of `sqlite3_bind_int64`.\n */\n- (void)bindInteger:(const int64_t &)value toIndex:(int)index;\n\n/**\n @brief The wrapper of `sqlite3_bind_double`.\n */\n- (void)bindDouble:(const double &)value toIndex:(int)index;\n\n/**\n @brief The wrapper of `sqlite3_bind_null`.\n */\n- (void)bindNullToIndex:(int)index;\n\n/**\n @brief The wrapper of `sqlite3_bind_text`.\n */\n- (void)bindString:(NSString *)string toIndex:(int)index;\n\n/**\n @brief The wrapper of `sqlite3_bind_int64`.\n */\n- (void)bindData:(NSData *)data toIndex:(int)index;\n\n/**\n @brief Bind an NSNumber.\n It will call `sqlite3_bind_int64` or `sqlite3_bind_double` according to the underlying data type of NSNumber.\n */\n- (void)bindNumber:(NSNumber *)number toIndex:(int)index;\n\n/**\n @brief The wrapper of `sqlite3_bind_*`.\n It will call the appropriate routine according to the column type returned by `+[WCTColumnCoding columnType]`.\n @param value WCTColumnCodingValue can be NSString, NSNumber, NSData, NSNull, nil and any NSObject that conforms to WCTColumnCoding.\n @see   `WCTColumnCoding`\n */\n- (void)bindValue:(nullable WCTColumnCodingValue *)value\n          toIndex:(int)index;\n\n/**\n @brief The wrapper of `sqlite3_bind_*` for binding property of object to index.\n It will call the appropriate routine according to the data type of property.\n */\n- (void)bindProperty:(const WCTProperty &)property\n            ofObject:(WCTObject *)object\n             toIndex:(int)index;\n\n/**\n @brief The wrapper of `sqlite3_bind_*` for binding the specified properties of object.\n It will call the appropriate routine according to the data type of properties.\n */\n- (void)bindProperties:(const WCTProperties &)properties\n              ofObject:(WCTObject *)object;\n\n/**\n @brief The wrapper of `sqlite3_bind_parameter_index`.\n */\n- (int)bindParameterIndex:(const WCDB::BindParameter &)parameter;\n\n#pragma mark - Extract Column meta\n/**\n @brief The wrapper of `sqlite3_column_count`.\n */\n- (int)extractNumberOfColumns;\n\n/**\n @brief The wrapper of `sqlite3_column_type`.\n */\n- (WCTColumnType)extractTypeAtIndex:(int)index;\n\n/**\n @brief The wrapper of `sqlite3_column_origin_name`.\n */\n- (NSString *)extractOriginColumnNameAtIndex:(int)index;\n\n/**\n @brief The wrapper of `sqlite3_column_name`.\n */\n- (NSString *)extractColumnNameAtIndex:(int)index;\n\n/**\n @brief The wrapper of `sqlite3_column_table_name`.\n */\n- (NSString *)extractTableNameAtIndex:(int)index;\n\n#pragma mark - Extract Row data\n/**\n @brief The wrapper of `sqlite3_column_int64`.\n */\n- (int64_t)extractIntegerAtIndex:(int)index;\n\n/**\n @brief The wrapper of `sqlite3_column_double`.\n */\n- (double)extractDoubleAtIndex:(int)index;\n\n/**\n @brief The wrapper of `sqlite3_column_text`.\n */\n- (NSString *)extractStringAtIndex:(int)index;\n\n/**\n @brief The wrapper of `sqlite3_column_int64` and `sqlite3_column_double`.\n */\n- (NSNumber *)extractNumberAtIndex:(int)index;\n\n/**\n @brief The wrapper of `sqlite3_column_blob`.\n */\n- (NSData *)extractDataAtIndex:(int)index;\n\n/**\n @brief The wrapper of `sqlite3_column_*`.\n @return The real type of WCTValue depends on the value in database. It could be NSNumber, NSString, NSData or nil.\n */\n- (nullable WCTValue *)extractValueAtIndex:(int)index;\n\n/**\n @brief Extract all values of current row.\n @return An array of NSObject that conforms to WCTValue.\n */\n- (WCTOneRow *)extractRow;\n\n/**\n @brief Extract the values of the current row and assign them into the properties specified by resultColumns of a new WCTTableCoding object.\n @return A WCTTableCoding object.\n */\n- (WCTObject *)extractObjectOnResultColumns:(const WCTResultColumns &)resultColumns;\n\n/**\n @brief Extract the results of a multi-table query in the current row.\n @return A dictionary containing the result of multi-table. The keys of the dictionary are the table names, and their corresponding values are the results of these tables.\n */\n- (WCTMultiObject *)extractMultiObjectOnResultColumns:(const WCTResultColumns &)resultColumns;\n\n/**\n @brief Extract value at index and set it to the corresponding property of object.\n */\n- (void)extractValueAtIndex:(int)index\n                 toProperty:(const WCTProperty &)property\n                   ofObject:(WCTObject *)object;\n\n#pragma mark - Step And Extract All Data\n/**\n @brief Extract all the values of the first column in the result.\n @return An array of NSObject that conforms to WCTValue, or nil if error occurs.\n */\n- (nullable WCTOneColumn *)allValues;\n\n/**\n @brief Extract all the values of the column at index in the result.\n @return An array of NSObject that conforms to WCTValue, or nil if error occurs.\n */\n- (nullable WCTOneColumn *)allValuesAtIndex:(int)index;\n\n/**\n @brief Extract all the values in the result.\n @return A two-dimensional array, or nil if error occurs.\n */\n- (nullable WCTColumnsXRows *)allRows;\n\n/**\n @brief Extract the values of all rows in the result and assign them into the properties specified by resultColumns of new WCTTableCoding objects.\n @return An array of WCTTableCoding object, or nil if error occurs.\n */\n- (nullable NSArray /* <WCTObject*> */ *)allObjectsOnResultColumns:(const WCTResultColumns &)resultColumns;\n\n/**\n @brief Extract the results of a multi-table query.\n @return An array of WCTMultiObject, or nil if error occurs.\n */\n- (nullable NSArray<WCTMultiObject *> *)allMultiObjectsOnResultColumns:(const WCTResultColumns &)resultColumns;\n\n@end\nNS_ASSUME_NONNULL_END\n"
  },
  {
    "path": "src/objc/statement/WCTPreparedStatement.mm",
    "content": "//\n// Created by qiuwenchen on 2020/2/24.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"WCTPreparedStatement.h\"\n#import \"WCTFoundation.h\"\n#import \"WCTHandle+Private.h\"\n#import \"WCTORM.h\"\n#import \"WCTPreparedStatement+Private.h\"\n#import <Foundation/Foundation.h>\n\n#define WCTPreparedStatementAssert(remedial) WCTRemedialAssert(_handleStatement != nullptr, \"handleStatement is null\", remedial;)\n\n@implementation WCTPreparedStatement\n\n- (instancetype)initWithHandleStatement:(WCDB::HandleStatement *)handlesStatement\n{\n    if (self = [super init]) {\n        _handleStatement = handlesStatement;\n    }\n    return self;\n}\n\n- (WCDB::HandleStatement *)getRawHandleStatement\n{\n    return _handleStatement;\n}\n\n#pragma mark - Step\n- (BOOL)step\n{\n    WCTPreparedStatementAssert(return NO);\n    return _handleStatement->step();\n}\n\n- (void)reset\n{\n    WCTPreparedStatementAssert(return);\n    _handleStatement->reset();\n}\n\n- (void)clearBindings\n{\n    WCTPreparedStatementAssert(return);\n    _handleStatement->clearBindings();\n}\n\n- (BOOL)done\n{\n    WCTPreparedStatementAssert(return NO);\n    return _handleStatement->done();\n}\n\n#pragma mark - State\n- (BOOL)isStatementReadonly\n{\n    WCTPreparedStatementAssert(return NO);\n    return _handleStatement->isReadOnly();\n}\n\n#pragma mark - Bind\n- (void)bindInteger:(const int64_t &)value toIndex:(int)index\n{\n    WCTPreparedStatementAssert(return);\n    _handleStatement->bindInteger(value, index);\n}\n\n- (void)bindDouble:(const double &)value toIndex:(int)index\n{\n    WCTPreparedStatementAssert(return);\n    _handleStatement->bindDouble(value, index);\n}\n\n- (void)bindNullToIndex:(int)index\n{\n    WCTPreparedStatementAssert(return);\n    _handleStatement->bindNull(index);\n}\n\n- (void)bindString:(NSString *)string toIndex:(int)index\n{\n    WCTPreparedStatementAssert(return);\n    _handleStatement->bindText(WCDB::UnsafeStringView(string), index);\n}\n\n- (void)bindData:(NSData *)data toIndex:(int)index\n{\n    WCTPreparedStatementAssert(return);\n    _handleStatement->bindBLOB(data, index);\n}\n\n- (void)bindNumber:(NSNumber *)number toIndex:(int)index\n{\n    WCTPreparedStatementAssert(return);\n    if (number == nil || CFNumberIsFloatType((CFNumberRef) number)) {\n        _handleStatement->bindDouble(number.doubleValue, index);\n    } else {\n        _handleStatement->bindInteger(number.integerValue, index);\n    }\n}\n\n- (void)bindValue:(WCTColumnCodingValue *)value\n          toIndex:(int)index\n{\n    WCTPreparedStatementAssert(return);\n    WCTValue *archivedValue = [value archivedWCTValue];\n    switch ([value.class columnType]) {\n    case WCTColumnTypeNull:\n        _handleStatement->bindNull(index);\n        break;\n    case WCTColumnTypeInteger:\n        _handleStatement->bindInteger(archivedValue.numberValue.longLongValue, index);\n        break;\n    case WCTColumnTypeFloat:\n        _handleStatement->bindDouble(archivedValue.numberValue.doubleValue, index);\n        break;\n    case WCTColumnTypeString:\n        _handleStatement->bindText(WCDB::UnsafeStringView(archivedValue.stringValue), index);\n        break;\n    case WCTColumnTypeData:\n        _handleStatement->bindBLOB((NSData *) archivedValue, index);\n        break;\n    }\n}\n\n- (void)bindProperty:(const WCTProperty &)property\n            ofObject:(WCTObject *)object\n             toIndex:(int)index\n{\n    WCTPreparedStatementAssert(return);\n    const std::shared_ptr<const WCTBaseAccessor> &accessor = property.getColumnBinding().getAccessor();\n    switch (accessor->getAccessorType()) {\n    case WCTAccessorCpp: {\n        switch (accessor->getColumnType()) {\n        case WCDB::ColumnType::Integer: {\n            WCTCppAccessor<WCDB::ColumnType::Integer> *integerAccessor = (WCTCppAccessor<WCDB::ColumnType::Integer> *) accessor.get();\n            _handleStatement->bindInteger(integerAccessor->getValue(object),\n                                          index);\n        } break;\n        case WCDB::ColumnType::Float: {\n            WCTCppAccessor<WCDB::ColumnType::Float> *floatAccessor = (WCTCppAccessor<WCDB::ColumnType::Float> *) accessor.get();\n            _handleStatement->bindDouble(floatAccessor->getValue(object),\n                                         index);\n        } break;\n        case WCDB::ColumnType::Text: {\n            WCTCppAccessor<WCDB::ColumnType::Text> *textAccessor = (WCTCppAccessor<WCDB::ColumnType::Text> *) accessor.get();\n            _handleStatement->bindText(textAccessor->getValue(object),\n                                       index);\n        } break;\n        case WCDB::ColumnType::BLOB: {\n            WCTCppAccessor<WCDB::ColumnType::BLOB> *blobAccessor = (WCTCppAccessor<WCDB::ColumnType::BLOB> *) accessor.get();\n            _handleStatement->bindBLOB(blobAccessor->getValue(object), index);\n        } break;\n        case WCDB::ColumnType::Null:\n            _handleStatement->bindNull(index);\n            break;\n        }\n    } break;\n    case WCTAccessorObjC: {\n        WCTObjCAccessor *objcAccessor = (WCTObjCAccessor *) accessor.get();\n        NSObject *value = objcAccessor->getObject(object);\n        if (value != nil) {\n            switch (accessor->getColumnType()) {\n            case WCDB::ColumnType::Integer: {\n                _handleStatement->bindInteger(((NSNumber *) value).longLongValue, index);\n                break;\n            }\n            case WCDB::ColumnType::Float: {\n                _handleStatement->bindDouble(((NSNumber *) value).doubleValue, index);\n                break;\n            }\n            case WCDB::ColumnType::Text: {\n                _handleStatement->bindText((NSString *) value, index);\n                break;\n            }\n            case WCDB::ColumnType::BLOB: {\n                _handleStatement->bindBLOB((NSData *) value, index);\n                break;\n            }\n            case WCDB::ColumnType::Null:\n                _handleStatement->bindNull(index);\n                break;\n            }\n        } else {\n            _handleStatement->bindNull(index);\n        }\n    } break;\n    }\n}\n\n- (void)bindProperties:(const WCTProperties &)properties\n              ofObject:(WCTObject *)object\n{\n    WCTPreparedStatementAssert(return);\n    int index = 1;\n    for (const auto &property : properties) {\n        [self bindProperty:property ofObject:object toIndex:index];\n        ++index;\n    }\n}\n\n- (int)bindParameterIndex:(const WCDB::BindParameter &)parameter\n{\n    WCTPreparedStatementAssert(return 0);\n    return _handleStatement->bindParameterIndex(parameter.getDescription());\n}\n\n#pragma mark - Get\n- (int64_t)extractIntegerAtIndex:(int)index\n{\n    WCTPreparedStatementAssert(return 0);\n    return _handleStatement->getInteger(index);\n}\n\n- (double)extractDoubleAtIndex:(int)index\n{\n    WCTPreparedStatementAssert(return 0);\n    return _handleStatement->getDouble(index);\n}\n\n- (NSString *)extractStringAtIndex:(int)index\n{\n    WCTPreparedStatementAssert(return nil);\n    return [NSString stringWithView:_handleStatement->getText(index)];\n}\n\n- (NSNumber *)extractNumberAtIndex:(int)index\n{\n    WCTPreparedStatementAssert(return nil);\n    switch (_handleStatement->getType(index)) {\n    case WCDB::ColumnType::Integer:\n        return [NSNumber numberWithLongLong:_handleStatement->getInteger(index)];\n    default:\n        return [NSNumber numberWithDouble:_handleStatement->getDouble(index)];\n    }\n}\n\n- (NSData *)extractDataAtIndex:(int)index\n{\n    WCTPreparedStatementAssert(return nil);\n    const WCDB::UnsafeData blob = _handleStatement->getBLOB(index);\n    return [NSData dataWithBytes:blob.buffer() length:blob.size()];\n}\n\n- (WCTValue *)extractValueAtIndex:(int)index\n{\n    WCTPreparedStatementAssert(return nil);\n    switch ([self extractTypeAtIndex:index]) {\n    case WCTColumnTypeInteger:\n        return [NSNumber numberWithLongLong:[self extractIntegerAtIndex:index]];\n    case WCTColumnTypeFloat:\n        return [NSNumber numberWithDouble:[self extractDoubleAtIndex:index]];\n    case WCTColumnTypeString:\n        return [self extractStringAtIndex:index];\n    case WCTColumnTypeData:\n        return [self extractDataAtIndex:index];\n    case WCTColumnTypeNull:\n        return nil;\n    }\n}\n\n- (WCTColumnType)extractTypeAtIndex:(int)index\n{\n    WCTPreparedStatementAssert(return WCTColumnTypeNull);\n    return (WCTColumnType) _handleStatement->getType(index);\n}\n\n- (int)extractNumberOfColumns\n{\n    WCTPreparedStatementAssert(return 0);\n    return _handleStatement->getNumberOfColumns();\n}\n\n- (NSString *)extractOriginColumnNameAtIndex:(int)index\n{\n    WCTPreparedStatementAssert(return nil);\n    return [NSString stringWithView:_handleStatement->getOriginColumnName(index)];\n}\n\n- (NSString *)extractColumnNameAtIndex:(int)index\n{\n    WCTPreparedStatementAssert(return nil);\n    return [NSString stringWithView:_handleStatement->getColumnName(index)];\n}\n\n- (NSString *)extractTableNameAtIndex:(int)index\n{\n    WCTPreparedStatementAssert(return nil);\n    return [NSString stringWithView:_handleStatement->getColumnTableName(index)];\n}\n\n- (WCTOneRow *)extractRow\n{\n    WCTPreparedStatementAssert(return nil);\n    int count = [self extractNumberOfColumns];\n    NSMutableArray *row = [NSMutableArray arrayWithCapacity:count];\n    for (int index = 0; index < count; ++index) {\n        WCTValue *value = [self extractValueAtIndex:index];\n        [row addObject:value ? value : [NSNull null]];\n    }\n    return row;\n}\n\n- (WCTObject *)extractObjectOnResultColumns:(const WCTResultColumns &)resultColumns\n{\n    WCTPreparedStatementAssert(return nil);\n    Class cls = resultColumns.front().getColumnBinding().getClass();\n    WCTObject *object = [[cls alloc] init];\n    int index = 0;\n    for (const auto &resultColumn : resultColumns) {\n        [self extractValueAtIndex:index toColumnBindingHolder:resultColumn ofObject:object];\n        ++index;\n    }\n    return object;\n}\n\n- (WCTMultiObject *)extractMultiObjectOnResultColumns:(const WCTResultColumns &)resultColumns\n{\n    NSMutableDictionary *multiObject = [NSMutableDictionary dictionary];\n    int index = 0;\n    for (const WCTResultColumn &resultColumn : resultColumns) {\n        NSString *tableName = [NSString stringWithView:_handleStatement->getColumnTableName(index)];\n        WCTObject *object = [multiObject objectForKey:tableName];\n        if (object == nil) {\n            object = [[resultColumn.getColumnBinding().getClass() alloc] init];\n            [multiObject setObject:object forKey:tableName];\n        }\n        [self extractValueAtIndex:index\n            toColumnBindingHolder:resultColumn\n                         ofObject:object];\n        ++index;\n    }\n    return multiObject;\n}\n\n- (void)extractValueAtIndex:(int)index toProperty:(const WCTProperty &)property ofObject:(WCTObject *)object\n{\n    [self extractValueAtIndex:index toColumnBindingHolder:property ofObject:object];\n}\n\n- (void)extractValueAtIndex:(int)index\n      toColumnBindingHolder:(const WCTColumnBindingHolder &)columnBindingHolder\n                   ofObject:(WCTObject *)object\n{\n    WCTPreparedStatementAssert(return);\n    const std::shared_ptr<const WCTBaseAccessor> &accessor = columnBindingHolder.getColumnBinding().getAccessor();\n    switch (accessor->getAccessorType()) {\n    case WCTAccessorCpp: {\n        switch (accessor->getColumnType()) {\n        case WCDB::ColumnType::Integer: {\n            WCTCppAccessor<WCDB::ColumnType::Integer> *integerAccessor = (WCTCppAccessor<WCDB::ColumnType::Integer> *) accessor.get();\n            integerAccessor->setValue(object, _handleStatement->getInteger(index));\n        } break;\n        case WCDB::ColumnType::Float: {\n            WCTCppAccessor<WCDB::ColumnType::Float> *floatAccessor = (WCTCppAccessor<WCDB::ColumnType::Float> *) accessor.get();\n            floatAccessor->setValue(object, _handleStatement->getDouble(index));\n        } break;\n        case WCDB::ColumnType::Text: {\n            WCTCppAccessor<WCDB::ColumnType::Text> *textAccessor = (WCTCppAccessor<WCDB::ColumnType::Text> *) accessor.get();\n            textAccessor->setValue(object, _handleStatement->getText(index));\n        } break;\n        case WCDB::ColumnType::BLOB: {\n            WCTCppAccessor<WCDB::ColumnType::BLOB> *blobAccessor = (WCTCppAccessor<WCDB::ColumnType::BLOB> *) accessor.get();\n            blobAccessor->setValue(object, _handleStatement->getBLOB(index));\n        } break;\n        case WCDB::ColumnType::Null: {\n            WCTCppAccessor<WCDB::ColumnType::Null> *nullAccessor = (WCTCppAccessor<WCDB::ColumnType::Null> *) accessor.get();\n            nullAccessor->setValue(object, nullptr);\n        } break;\n        }\n    } break;\n    case WCTAccessorObjC: {\n        WCTObjCAccessor *objcAccessor = (WCTObjCAccessor *) accessor.get();\n        id value = nil;\n        if (_handleStatement->getType(index) != WCDB::ColumnType::Null) {\n            switch (accessor->getColumnType()) {\n            case WCDB::ColumnType::Integer:\n                value = [NSNumber numberWithLongLong:_handleStatement->getInteger(index)];\n                break;\n            case WCDB::ColumnType::Float:\n                value = [NSNumber numberWithDouble:_handleStatement->getDouble(index)];\n                break;\n            case WCDB::ColumnType::Text:\n                value = [NSString stringWithView:_handleStatement->getText(index)];\n                break;\n            case WCDB::ColumnType::BLOB: {\n                const WCDB::UnsafeData data = _handleStatement->getBLOB(index);\n                value = [NSData dataWithBytes:data.buffer() length:data.size()];\n            } break;\n            case WCDB::ColumnType::Null:\n                value = nil;\n                break;\n            }\n        }\n        objcAccessor->setObject(object, value);\n    } break;\n    }\n}\n\n#pragma mark - Get All\n- (WCTOneColumn *)allValues\n{\n    WCTPreparedStatementAssert(return nil);\n    return [self allValuesAtIndex:0];\n}\n\n- (WCTOneColumn *)allValuesAtIndex:(int)index\n{\n    WCTPreparedStatementAssert(return nil);\n    NSMutableArray *column = [NSMutableArray array];\n    BOOL succeed = NO;\n    while ((succeed = [self step]) && ![self done]) {\n        WCTValue *value = [self extractValueAtIndex:index];\n        [column addObject:value ? value : [NSNull null]];\n    }\n    return succeed ? column : nil;\n}\n\n- (WCTColumnsXRows *)allRows\n{\n    WCTPreparedStatementAssert(return nil);\n    NSMutableArray *rows = [NSMutableArray array];\n    BOOL succeed = NO;\n    while ((succeed = [self step]) && ![self done]) {\n        [rows addObject:[self extractRow]];\n    }\n    return succeed ? rows : nil;\n}\n\n- (NSArray /* <WCTObject*> */ *)allObjectsOnResultColumns:(const WCTResultColumns &)resultColumns\n{\n    WCTPreparedStatementAssert(return nil);\n    NSMutableArray *objects = [NSMutableArray array];\n    BOOL succeed = NO;\n    while ((succeed = [self step]) && ![self done]) {\n        [objects addObject:[self extractObjectOnResultColumns:resultColumns]];\n    }\n    return succeed ? objects : nil;\n}\n\n- (NSArray<WCTMultiObject *> *)allMultiObjectsOnResultColumns:(const WCTResultColumns &)resultColumns\n{\n    WCTPreparedStatementAssert(return nil);\n    NSMutableArray *multiObjects = [NSMutableArray array];\n    BOOL succeed = NO;\n    while ((succeed = [self step]) && ![self done]) {\n        [multiObjects addObject:[self extractMultiObjectOnResultColumns:resultColumns]];\n    }\n    return succeed ? multiObjects : nil;\n}\n\n@end\n"
  },
  {
    "path": "src/objc/table/WCTDatabase+Table.h",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"WCTDatabase.h\"\n#import \"WCTTable.h\"\n#import \"WCTTableProtocol.h\"\n\nWCDB_API @interface WCTDatabase(Table)<WCTTableProtocol>\n\n@end\n"
  },
  {
    "path": "src/objc/table/WCTDatabase+Table.mm",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"Assertion.hpp\"\n#import \"WCTDatabase+Handle.h\"\n#import \"WCTDatabase+Private.h\"\n#import \"WCTDatabase+Transaction.h\"\n#import \"WCTError+Private.h\"\n#import \"WCTHandle+Private.h\"\n#import \"WCTHandle+Table.h\"\n#import \"WCTORM.h\"\n#import \"WCTTable+Private.h\"\n\n@implementation WCTDatabase (Table)\n\n- (WCTOptionalBool)tableExists:(NSString *)tableName\n{\n    return _database->tableExists(tableName);\n}\n\n- (BOOL)createTable:(NSString *)tableName\n          withClass:(Class<WCTTableCoding>)cls\n{\n    WCTRemedialAssert(tableName != nil && cls != nil, \"Class or table name can't be null.\", return NO;);\n    WCTHandle *handle = [self getHandle];\n    [handle setWriteHint:YES];\n    BOOL result = [handle remapTable:tableName toClass:cls];\n    [handle invalidate];\n    return result;\n}\n\n- (WCTTable *)getTable:(NSString *)tableName\n             withClass:(Class<WCTTableCoding>)tableClass\n{\n    WCTRemedialAssert(tableName != nil && tableClass != nil, \"Class or table name can't be null.\", return nil;);\n    return [[WCTTable alloc] initWithDatabase:self tableName:tableName tableClass:tableClass];\n}\n\n- (BOOL)createVirtualTable:(NSString *)tableName\n                 withClass:(Class<WCTTableCoding>)tableClass\n{\n    WCTRemedialAssert(tableName != nil && tableClass != nil, \"Class or table name can't be null.\", return NO;);\n    WCTHandle *handle = [self getHandle];\n    [handle setWriteHint:YES];\n    BOOL result = [handle createVirtualTable:tableName withClass:tableClass];\n    [handle invalidate];\n    return result;\n}\n\n- (BOOL)dropTable:(NSString *)tableName\n{\n    return _database->execute(WCDB::StatementDropTable().dropTable(tableName).ifExists());\n}\n\n- (BOOL)dropIndex:(NSString *)indexName\n{\n    return _database->execute(WCDB::StatementDropIndex().dropIndex(indexName).ifExists());\n}\n\n@end\n"
  },
  {
    "path": "src/objc/table/WCTHandle+Table.h",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"WCTHandle.h\"\n#import \"WCTTable.h\"\n#import \"WCTTableProtocol.h\"\n\nNS_ASSUME_NONNULL_BEGIN\n\nWCDB_API @interface WCTHandle(Table)<WCTTableProtocol>\n\n- (BOOL)remapTable:(NSString *)tableName toClass:(Class<WCTTableCoding>)tableClass;\n\n@end\n\nNS_ASSUME_NONNULL_END\n"
  },
  {
    "path": "src/objc/table/WCTHandle+Table.mm",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"Assertion.hpp\"\n#import \"CoreConst.h\"\n#import \"Notifier.hpp\"\n#import \"WCTDatabase.h\"\n#import \"WCTError+Private.h\"\n#import \"WCTHandle+Private.h\"\n#import \"WCTHandle+Table.h\"\n#import \"WCTHandle+Transaction.h\"\n#import \"WCTORM.h\"\n#import \"WCTTable+Private.h\"\n\n@implementation WCTHandle (Table)\n\n- (WCTOptionalBool)tableExists:(NSString *)tableName\n{\n    WCTOptionalBool exists;\n    WCDB::InnerHandle *handle = [self getOrGenerateHandle];\n    if (handle != nullptr) {\n        exists = handle->tableExists(tableName);\n    }\n    return exists;\n}\n\n- (BOOL)createTable:(NSString *)tableName\n          withClass:(Class<WCTTableCoding>)tableClass\n{\n    WCTRemedialAssert(tableName != nil && tableClass != nil, \"Class or table name can't be null.\", return NO;);\n    return [self remapTable:tableName toClass:tableClass];\n}\n\n- (WCTTable *)getTable:(NSString *)tableName\n             withClass:(Class<WCTTableCoding>)tableClass\n{\n    WCTRemedialAssert(tableName != nil && tableClass != nil, \"Class or table name can't be null.\", return nil;);\n    return [[WCTTable alloc] initWithDatabase:_database\n                                    tableName:tableName\n                                   tableClass:tableClass];\n}\n\n- (BOOL)createVirtualTable:(NSString *)tableName\n                 withClass:(Class<WCTTableCoding>)cls\n{\n    WCTRemedialAssert(tableName != nil && cls != nil, \"Class or table name can't be null.\", return NO;);\n    const WCTBinding &binding = [cls objectRelationalMapping];\n    WCDB::InnerHandle *innerHandle = [self getOrGenerateHandle];\n    if (innerHandle == nullptr) {\n        return NO;\n    }\n    return binding.createVirtualTable(tableName, innerHandle);\n}\n\n- (BOOL)dropTable:(NSString *)tableName\n{\n    return [self execute:WCDB::StatementDropTable().dropTable(tableName).ifExists()];\n}\n\n- (BOOL)dropIndex:(NSString *)indexName\n{\n    return [self execute:WCDB::StatementDropIndex().dropIndex(indexName).ifExists()];\n}\n\n- (BOOL)remapTable:(NSString *)tableName toClass:(Class<WCTTableCoding>)tableClass\n{\n    WCTAssert(tableName != nil && tableClass != nil);\n    WCTAssert([(id) tableClass respondsToSelector:@selector(objectRelationalMapping)] && [(id) tableClass respondsToSelector:@selector(allProperties)]);\n    const WCTBinding &binding = [tableClass objectRelationalMapping];\n    WCDB::InnerHandle *innerHandle = [self getOrGenerateHandle];\n    if (innerHandle == nullptr) {\n        return NO;\n    }\n    return binding.createTable(tableName, innerHandle);\n}\n\n@end\n"
  },
  {
    "path": "src/objc/table/WCTTable+Private.h",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"WCTDeclaration.h\"\n#import \"WCTTable.h\"\n\nWCDB_API @interface WCTTable() {\n@protected\n    WCTDatabase *_database;\n    Class _tableClass;\n    NSString *_tableName;\n}\n\n- (instancetype)initWithDatabase:(WCTDatabase *)database\n                       tableName:(NSString *)tableName\n                      tableClass:(Class<WCTTableCoding>)tableClass;\n\n@end\n"
  },
  {
    "path": "src/objc/table/WCTTable+Table.h",
    "content": "//\n// Created by sanhuazhang on 2019/9/25.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"WCTTable.h\"\n\nNS_ASSUME_NONNULL_BEGIN\n\nWCDB_API @interface WCTTable(Table)\n\n- (NSString *)indexWithSuffix:(NSString *)indexSuffix;\n\n- (BOOL)dropIndexWithSuffix:(NSString *)indexSuffix;\n\n@end\n\nNS_ASSUME_NONNULL_END\n"
  },
  {
    "path": "src/objc/table/WCTTable+Table.mm",
    "content": "//\n// Created by sanhuazhang on 2019/9/25.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"Assertion.hpp\"\n#import \"WCTDatabase+Table.h\"\n#import \"WCTTable+Table.h\"\n\n@implementation WCTTable (Table)\n\n- (NSString *)indexWithSuffix:(NSString *)indexSuffix\n{\n    return [self.tableName stringByAppendingString:indexSuffix];\n}\n\n- (BOOL)dropIndexWithSuffix:(NSString *)indexSuffix\n{\n    WCTRemedialAssert(indexSuffix != nil, \"Index suffix can't be null.\", return NO;);\n    return [self.database dropIndex:[self.tableName stringByAppendingString:indexSuffix]];\n}\n\n@end\n"
  },
  {
    "path": "src/objc/table/WCTTable.h",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import <Foundation/Foundation.h>\n\nNS_ASSUME_NONNULL_BEGIN\n\n@class WCTDatabase;\n@class WCTError;\n\nWCDB_API @interface WCTTable<ObjectType> : NSObject\n\n/**\n You should use `-[WCTDatabase getTable:withClass:]` or `-[WCTHandle getTable:withClass:]` to obtain `WCTTable`.\n */\n- (instancetype)init UNAVAILABLE_ATTRIBUTE;\n\n/**\n The name of the table.\n */\n@property (nonatomic, readonly) NSString *tableName;\n\n/**\n The class binding to this table.\n */\n@property (nonatomic, readonly) Class tableClass;\n\n/**\n The database that generate current table.\n */\n@property (nonatomic, readonly) WCTDatabase *database;\n\n/**\n @brief Get the most recent error for the database of current table in the current thread.\n        Since it is too cumbersome to get the error after every database operation, it‘s better to use monitoring interfaces to obtain database errors and print them to the log.\n @see   `[WCTDatabase globalTraceError:]`\n @see   `[WCTDatabase traceError:]`\n \n @return WCTError\n */\n- (WCTError *)error;\n\n@end\n\nNS_ASSUME_NONNULL_END\n"
  },
  {
    "path": "src/objc/table/WCTTable.mm",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"Assertion.hpp\"\n#import \"CommonCore.h\"\n#import \"WCTDatabase.h\"\n#import \"WCTError+Private.h\"\n#import \"WCTTable+Private.h\"\n\n@implementation WCTTable\n\n@synthesize tableName = _tableName;\n@synthesize tableClass = _tableClass;\n@synthesize database = _database;\n\n- (instancetype)initWithDatabase:(WCTDatabase *)database\n                       tableName:(NSString *)tableName\n                      tableClass:(Class<WCTTableCoding>)tableClass\n{\n    WCTAssert(database != nil && tableClass != nil && tableName != nil);\n    if (self = [super init]) {\n        _database = database;\n        _tableName = tableName;\n        _tableClass = tableClass;\n    }\n    return self;\n}\n\n- (WCTDatabase *)database\n{\n    return _database;\n}\n\n- (WCTError *)error\n{\n    return _database.error;\n}\n\n@end\n"
  },
  {
    "path": "src/objc/table/WCTTableProtocol.h",
    "content": "//\n// Created by sanhuazhang on 2019/9/25.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"WCTCommon.h\"\n#import \"WCTOptional.h\"\n\nNS_ASSUME_NONNULL_BEGIN\n\n@protocol WCTTableProtocol\n\n/**\n @brief Check the existence of the table.\n @param tableName The name of the table to be checked.\n @return result.\n */\n- (WCTOptionalBool)tableExists:(NSString *)tableName;\n\n/**\n @brief Get a wrapper from an existing table.\n @param tableName The name of the table.\n @param tableClass a class implement WCTTableCoding.\n @return WCTTable.\n */\n- (WCTTable *)getTable:(NSString *)tableName\n             withClass:(Class<WCTTableCoding>)tableClass;\n\n/**\n @brief Create table and indexes from ORM if not exists.\n @note  It will run embedded transaction, and add newly defined columns automatically.\n        The embedded transaction means that it will run a transaction if it's not in other transaction, otherwise it will be executed within the existing transaction.\n @param tableName This would be the name of the table and the prefix of the index names.\n @param tableClass a class implement WCTTableCoding.\n @return YES if no error occurs.\n */\n- (BOOL)createTable:(NSString *)tableName\n          withClass:(Class<WCTTableCoding>)tableClass;\n\n/**\n @brief Create virtual table from ORM if not exists.\n @see   http://www.sqlite.org/vtab.html\n @param tableName The name of the virtual table to be created.\n @param tableClass a class implement WCTTableCoding.\n @return YES if no error occurs.\n */\n- (BOOL)createVirtualTable:(NSString *)tableName\n                 withClass:(Class<WCTTableCoding>)tableClass;\n\n/**\n @brief Drop table if exists.\n @param tableName The name of the table to be dropped.\n @return YES only if no error occurs.\n */\n- (BOOL)dropTable:(NSString *)tableName;\n\n/**\n @brief Drop index if not exists.\n @param indexName The name of the index to be dropped.\n @return YES only if no error occurs.\n */\n- (BOOL)dropIndex:(NSString *)indexName;\n\n@end\n\nNS_ASSUME_NONNULL_END\n"
  },
  {
    "path": "src/objc/tests/advance/chaincall/ChainCallTests.mm",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"TestCase.h\"\n\n@interface ChainCallTests : CRUDTestCase\n\n@end\n\n@implementation ChainCallTests\n\n- (void)setUp\n{\n    [super setUp];\n    [self insertPresetObjects];\n}\n\n#pragma mark - Delete\n- (void)test_database_delete\n{\n    WCTDelete* delete_ = [[self.database prepareDelete] fromTable:self.tableName];\n    TestCaseAssertSQLEqual(delete_.statement, @\"DELETE FROM testTable\");\n}\n\n- (void)test_table_delete\n{\n    WCTDelete* delete_ = [self.table prepareDelete];\n    TestCaseAssertSQLEqual(delete_.statement, @\"DELETE FROM testTable\");\n}\n\n- (void)test_handle_delete\n{\n    WCTDelete* delete_ = [[[self.database getHandle] prepareDelete] fromTable:self.tableName];\n    TestCaseAssertSQLEqual(delete_.statement, @\"DELETE FROM testTable\");\n}\n\n#pragma mark - Insert\n- (void)test_database_insert\n{\n    WCTInsert* insert = [[[self.database prepareInsert] onProperties:TestCaseObject.allProperties] intoTable:self.tableName];\n    TestCaseAssertSQLEqual(insert.statement, @\"INSERT INTO testTable(identifier, content) VALUES(?1, ?2)\");\n}\n\n- (void)test_table_insert\n{\n    WCTInsert* insert = [[self.table prepareInsert] onProperties:TestCaseObject.allProperties];\n    TestCaseAssertSQLEqual(insert.statement, @\"INSERT INTO testTable(identifier, content) VALUES(?1, ?2)\");\n}\n\n- (void)test_handle_insert\n{\n    WCTInsert* insert = [[[[self.database getHandle] prepareInsert] onProperties:TestCaseObject.allProperties] intoTable:self.tableName];\n    TestCaseAssertSQLEqual(insert.statement, @\"INSERT INTO testTable(identifier, content) VALUES(?1, ?2)\");\n}\n\n#pragma mark - Update\n- (void)test_database_update\n{\n    WCTUpdate* update = [[[self.database prepareUpdate] table:self.tableName] set:TestCaseObject.content];\n    TestCaseAssertSQLEqual(update.statement, @\"UPDATE testTable SET content = ?1\");\n}\n\n- (void)test_table_update\n{\n    WCTUpdate* update = [[self.table prepareUpdate] set:TestCaseObject.content];\n    TestCaseAssertSQLEqual(update.statement, @\"UPDATE testTable SET content = ?1\");\n}\n\n- (void)test_handle_update\n{\n    WCTUpdate* update = [[[[self.database getHandle] prepareUpdate] table:self.tableName] set:TestCaseObject.content];\n    TestCaseAssertSQLEqual(update.statement, @\"UPDATE testTable SET content = ?1\");\n}\n\n#pragma mark - Select\n- (void)test_database_select\n{\n    WCTSelect* select = [[[self.database prepareSelect] onResultColumns:TestCaseObject.allProperties] fromTable:self.tableName];\n    TestCaseAssertSQLEqual(select.statement, @\"SELECT identifier, content FROM testTable\");\n}\n\n- (void)test_table_select\n{\n    WCTSelect* select = [[self.table prepareSelect] onResultColumns:TestCaseObject.allProperties];\n    TestCaseAssertSQLEqual(select.statement, @\"SELECT identifier, content FROM testTable\");\n}\n\n- (void)test_handle_select\n{\n    WCTSelect* select = [[[[self.database getHandle] prepareSelect] onResultColumns:TestCaseObject.allProperties] fromTable:self.tableName];\n    TestCaseAssertSQLEqual(select.statement, @\"SELECT identifier, content FROM testTable\");\n}\n\n- (void)test_check_next_object_failed_using_done\n{\n    WCTSelect* select = [[[[self.database prepareSelect] onResultColumns:TestCaseObject.allProperties] fromTable:self.tableName] limit:1];\n\n    [WCTDatabase simulateIOError:WCTSimulateWriteIOError | WCTSimulateReadIOError];\n    // oneObject is nil due to IOError, so done is false.\n    TestCaseAssertTrue([select firstObject] == nil);\n\n    [WCTDatabase simulateIOError:WCTSimulateNoneIOError];\n    // oneObject is not nil, so done is false.\n    select = [[[[self.database prepareSelect] onResultColumns:TestCaseObject.allProperties] fromTable:self.tableName] limit:1];\n    TestCaseAssertTrue([select firstObject] != nil);\n}\n\n#pragma mark - Multi Select\n- (void)test_database_multi_select\n{\n    NSString* tableName2 = @\"testTable2\";\n    WCTResultColumns resultColumns = {\n        TestCaseObject.content.redirect(TestCaseObject.content.table(self.tableName)),\n        TestCaseObject.content.redirect(TestCaseObject.content.table(tableName2)),\n    };\n    WCTMultiSelect* select = [[[[self.database prepareMultiSelect] onResultColumns:resultColumns] fromTables:@[ self.tableName, tableName2 ]] where:TestCaseObject.identifier.table(self.tableName) == TestCaseObject.identifier.table(tableName2)];\n    TestCaseAssertSQLEqual(select.statement, @\"SELECT testTable.content, testTable2.content FROM testTable, testTable2 WHERE testTable.identifier == testTable2.identifier\");\n}\n\n- (void)test_handle_multi_select\n{\n    NSString* tableName2 = @\"testTable2\";\n    WCTResultColumns resultColumns = {\n        TestCaseObject.content.redirect(TestCaseObject.content.table(self.tableName)),\n        TestCaseObject.content.redirect(TestCaseObject.content.table(tableName2)),\n    };\n    WCTMultiSelect* select = [[[[[self.database getHandle] prepareMultiSelect] onResultColumns:resultColumns] fromTables:@[ self.tableName, tableName2 ]] where:TestCaseObject.identifier.table(self.tableName) == TestCaseObject.identifier.table(tableName2)];\n    TestCaseAssertSQLEqual(select.statement, @\"SELECT testTable.content, testTable2.content FROM testTable, testTable2 WHERE testTable.identifier == testTable2.identifier\");\n}\n\n@end\n"
  },
  {
    "path": "src/objc/tests/advance/chaincall/MultiSelectTests.mm",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"TestCase.h\"\n\n@interface MultiSelectTests : CRUDTestCase\n\n@property (nonatomic, readonly) NSString* tableName2;\n\n@property (nonatomic, readonly) TestCaseObject* object1InTable2;\n@property (nonatomic, readonly) TestCaseObject* object2InTable2;\n@property (nonatomic, readonly) NSArray<TestCaseObject*>* objectsInTable2;\n\n@end\n\n@implementation MultiSelectTests {\n    NSString* _tableName2;\n\n    TestCaseObject* _object1InTable2;\n    TestCaseObject* _object2InTable2;\n    NSArray<TestCaseObject*>* _objectsInTable2;\n}\n\n- (void)setUp\n{\n    [super setUp];\n\n    [self insertPresetObjects];\n    TestCaseAssertTrue([self.database createTable:self.tableName2 withClass:self.tableClass]);\n    TestCaseAssertTrue([self.database insertObjects:self.objectsInTable2 intoTable:self.tableName2]);\n    [self.database close];\n}\n\n- (NSString*)tableName2\n{\n    @synchronized(self) {\n        if (_tableName2 == nil) {\n            _tableName2 = @\"testTable2\";\n        }\n        return _tableName2;\n    }\n}\n\n- (TestCaseObject*)object1InTable2\n{\n    @synchronized(self) {\n        if (_object1InTable2 == nil) {\n            _object1InTable2 = [Random.shared testCaseObjectWithIdentifier:1];\n        }\n        return _object1InTable2;\n    }\n}\n\n- (TestCaseObject*)object2InTable2\n{\n    @synchronized(self) {\n        if (_object2InTable2 == nil) {\n            _object2InTable2 = [Random.shared testCaseObjectWithIdentifier:2];\n        }\n        return _object2InTable2;\n    }\n}\n\n- (NSArray<TestCaseObject*>*)objectsInTable2\n{\n    @synchronized(self) {\n        if (_objectsInTable2 == nil) {\n            _objectsInTable2 = @[ self.object1InTable2, self.object2InTable2 ];\n        }\n        return _objectsInTable2;\n    }\n}\n\n- (void)tearDown\n{\n    TestCaseAssertTrue([self.database dropTable:self.tableName2]);\n    [super tearDown];\n}\n\n- (void)doTestMultiObjects:(NSArray<WCTMultiObject*>*)multiObjects\n                    andSQL:(NSString*)sql\n               bySelecting:(NSArray<WCTMultiObject*>* (^)())block\n{\n    TestCaseAssertTrue(multiObjects != nil);\n    TestCaseAssertTrue(sql != nil);\n    __block NSArray<WCTMultiObject*>* results;\n    [self doTestSQLs:@[ sql ]\n         inOperation:^BOOL {\n             results = block();\n             return results != nil;\n         }];\n    TestCaseAssertTrue([results isEqualToArray:multiObjects]);\n}\n\n#pragma mark - Database\n- (void)test_database_next\n{\n    NSArray<WCTMultiObject*>* objects = @[\n        @{\n            self.tableName : self.object1,\n            self.tableName2 : self.object1InTable2,\n        }\n    ];\n    [self doTestMultiObjects:objects\n                      andSQL:@\"SELECT testTable.identifier, testTable.content, testTable2.identifier, testTable2.content FROM testTable, testTable2 WHERE testTable.identifier == testTable2.identifier\"\n                 bySelecting:^NSArray<WCTMultiObject*>* {\n                     WCTResultColumns resultColumns\n                     = TestCaseObject.allProperties\n                       .redirect(^WCDB::ResultColumn(const WCTProperty& property) {\n                           return property.table(self.tableName);\n                       })\n                       .addingNewResultColumns(TestCaseObject.allProperties.redirect(^WCDB::ResultColumn(const WCTProperty& property) {\n                           return property.table(self.tableName2);\n                       }));\n\n                     WCTMultiSelect* select =\n                     [[[[self.database prepareMultiSelect] onResultColumns:resultColumns] fromTables:@[ self.tableName, self.tableName2 ]] where:TestCaseObject.identifier.table(self.tableName) == TestCaseObject.identifier.table(self.tableName2)];\n\n                     NSMutableArray<WCTMultiObject*>* results = [NSMutableArray<WCTMultiObject*> array];\n                     [results addObject:[select firstMultiObject]];\n                     return results;\n                 }];\n}\n\n- (void)test_database_all\n{\n    NSArray<WCTMultiObject*>* objects = @[\n        @{\n            self.tableName : self.object1,\n            self.tableName2 : self.object1InTable2,\n        },\n        @{\n            self.tableName : self.object2,\n            self.tableName2 : self.object2InTable2,\n        },\n    ];\n    [self doTestMultiObjects:objects\n                      andSQL:@\"SELECT testTable.identifier, testTable.content, testTable2.identifier, testTable2.content FROM testTable, testTable2 WHERE testTable.identifier == testTable2.identifier\"\n                 bySelecting:^NSArray<WCTMultiObject*>* {\n                     WCTResultColumns resultColumns\n                     = TestCaseObject.allProperties\n                       .redirect(^WCDB::ResultColumn(const WCTProperty& property) {\n                           return property.table(self.tableName);\n                       })\n                       .addingNewResultColumns(TestCaseObject.allProperties.redirect(^WCDB::ResultColumn(const WCTProperty& property) {\n                           return property.table(self.tableName2);\n                       }));\n\n                     WCTMultiSelect* select = [[[[self.database prepareMultiSelect] onResultColumns:resultColumns] fromTables:@[ self.tableName, self.tableName2 ]] where:TestCaseObject.identifier.table(self.tableName) == TestCaseObject.identifier.table(self.tableName2)];\n\n                     return [select allMultiObjects];\n                 }];\n}\n\n#pragma mark - Handle\n- (void)test_handle_next\n{\n    NSArray<WCTMultiObject*>* objects = @[\n        @{\n            self.tableName : self.object1,\n            self.tableName2 : self.object1InTable2,\n        }\n    ];\n    [self doTestMultiObjects:objects\n                      andSQL:@\"SELECT testTable.identifier, testTable.content, testTable2.identifier, testTable2.content FROM testTable, testTable2 WHERE testTable.identifier == testTable2.identifier\"\n                 bySelecting:^NSArray<WCTMultiObject*>* {\n                     WCTResultColumns resultColumns\n                     = TestCaseObject.allProperties\n                       .redirect(^WCDB::ResultColumn(const WCTProperty& property) {\n                           return property.table(self.tableName);\n                       })\n                       .addingNewResultColumns(TestCaseObject.allProperties.redirect(^WCDB::ResultColumn(const WCTProperty& property) {\n                           return property.table(self.tableName2);\n                       }));\n\n                     WCTMultiSelect* select = [[[[[self.database getHandle] prepareMultiSelect] onResultColumns:resultColumns] fromTables:@[ self.tableName, self.tableName2 ]] where:TestCaseObject.identifier.table(self.tableName) == TestCaseObject.identifier.table(self.tableName2)];\n\n                     NSMutableArray<WCTMultiObject*>* results = [NSMutableArray<WCTMultiObject*> array];\n                     [results addObject:[select firstMultiObject]];\n                     return results;\n                 }];\n}\n\n- (void)test_handle_all\n{\n    NSArray<WCTMultiObject*>* objects = @[\n        @{\n            self.tableName : self.object1,\n            self.tableName2 : self.object1InTable2,\n        },\n        @{\n            self.tableName : self.object2,\n            self.tableName2 : self.object2InTable2,\n        },\n    ];\n    [self doTestMultiObjects:objects\n                      andSQL:@\"SELECT testTable.identifier, testTable.content, testTable2.identifier, testTable2.content FROM testTable, testTable2 WHERE testTable.identifier == testTable2.identifier\"\n                 bySelecting:^NSArray<WCTMultiObject*>* {\n                     WCTResultColumns resultColumns\n                     = TestCaseObject.allProperties\n                       .redirect(^WCDB::ResultColumn(const WCTProperty& property) {\n                           return property.table(self.tableName);\n                       })\n                       .addingNewResultColumns(TestCaseObject.allProperties.redirect(^WCDB::ResultColumn(const WCTProperty& property) {\n                           return property.table(self.tableName2);\n                       }));\n\n                     WCTMultiSelect* select = [[[[[self.database getHandle] prepareMultiSelect] onResultColumns:resultColumns] fromTables:@[ self.tableName, self.tableName2 ]] where:TestCaseObject.identifier.table(self.tableName) == TestCaseObject.identifier.table(self.tableName2)];\n\n                     return [select allMultiObjects];\n                 }];\n}\n\n@end\n"
  },
  {
    "path": "src/objc/tests/advance/column_coding/ColumnCodingObject+WCTTableCoding.h",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"ColumnCodingObject.h\"\n#if TEST_WCDB_OBJC\n#import <WCDBOBjc/WCDBObjc.h>\n#elif TEST_WCDB_CPP\n#import <WCDBCpp/WCDBCpp.h>\n#else\n#import <WCDB/WCDBObjc.h>\n#endif\n\n@interface ColumnCodingObject (WCTTableCoding) <WCTTableCoding>\n\nWCDB_PROPERTY(integerObject)\nWCDB_PROPERTY(doubleObject)\nWCDB_PROPERTY(dataObject)\nWCDB_PROPERTY(stringObject)\n\n@end\n"
  },
  {
    "path": "src/objc/tests/advance/column_coding/ColumnCodingObject.h",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"DataCodingObject.h\"\n#import \"DoubleCodingObject.h\"\n#import \"IntegerCodingObject.h\"\n#import \"StringCodingObject.h\"\n#import <Foundation/Foundation.h>\n\n@interface ColumnCodingObject : NSObject\n\n@property (nonatomic, retain) IntegerCodingObject* integerObject;\n@property (nonatomic, retain) DoubleCodingObject* doubleObject;\n@property (nonatomic, retain) StringCodingObject* stringObject;\n@property (nonatomic, retain) DataCodingObject* dataObject;\n\n@end\n"
  },
  {
    "path": "src/objc/tests/advance/column_coding/ColumnCodingObject.mm",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"ColumnCodingObject.h\"\n#import \"ColumnCodingObject+WCTTableCoding.h\"\n#import \"TestCase.h\"\n#if TEST_WCDB_OBJC\n#import <WCDBOBjc/WCDBObjc.h>\n#elif TEST_WCDB_CPP\n#import <WCDBCpp/WCDBCpp.h>\n#else\n#import <WCDB/WCDBObjc.h>\n#endif\n\n@implementation ColumnCodingObject\n\nWCDB_IMPLEMENTATION(ColumnCodingObject)\nWCDB_SYNTHESIZE(integerObject)\nWCDB_SYNTHESIZE(doubleObject)\nWCDB_SYNTHESIZE(stringObject)\nWCDB_SYNTHESIZE(dataObject)\n\n- (BOOL)isEqual:(NSObject*)object\n{\n    if (object.class != self.class) {\n        return NO;\n    }\n    ColumnCodingObject* other = (ColumnCodingObject*) object;\n\n    return [NSObject isObject:self.integerObject nilEqualToObject:other.integerObject]\n           && [NSObject isObject:self.doubleObject nilEqualToObject:other.doubleObject]\n           && [NSObject isObject:self.stringObject nilEqualToObject:other.stringObject]\n           && [NSObject isObject:self.dataObject nilEqualToObject:other.dataObject];\n}\n\n@end\n"
  },
  {
    "path": "src/objc/tests/advance/column_coding/ColumnCodingTests.mm",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"ColumnCodingObject+WCTTableCoding.h\"\n#import \"ColumnCodingObject.h\"\n#import \"Random+ColumnCodingObject.h\"\n#import \"TestCase.h\"\n\n@interface ColumnCodingTests : CRUDTestCase\n\n@end\n\n@implementation ColumnCodingTests\n\n- (void)setUp\n{\n    [super setUp];\n    self.tableClass = ColumnCodingObject.class;\n\n    TestCaseAssertTrue([self createTable]);\n    [self.database close];\n}\n\n- (void)test\n{\n    ColumnCodingObject* object = [Random.shared columnCodingObject];\n\n    [self doTestObjects:@[ object ]\n              andNumber:1\n           ofInsertSQLs:@\"INSERT INTO testTable(integerObject, doubleObject, stringObject, dataObject) VALUES(?1, ?2, ?3, ?4)\"\n         afterInsertion:^BOOL {\n             return [self.database insertObject:object intoTable:self.tableName];\n         }];\n}\n\n@end\n"
  },
  {
    "path": "src/objc/tests/advance/column_coding/DataCodingObject+WCTColumnCoding.h",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"DataCodingObject.h\"\n#if TEST_WCDB_OBJC\n#import <WCDBOBjc/WCDBObjc.h>\n#elif TEST_WCDB_CPP\n#import <WCDBCpp/WCDBCpp.h>\n#else\n#import <WCDB/WCDBObjc.h>\n#endif\n\n@interface DataCodingObject (WCTColumnCoding) <WCTColumnCoding>\n\n@end\n"
  },
  {
    "path": "src/objc/tests/advance/column_coding/DataCodingObject+WCTColumnCoding.mm",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"DataCodingObject+WCTColumnCoding.h\"\n\n@implementation DataCodingObject (WCTColumnCoding)\n\n+ (instancetype)unarchiveWithWCTValue:(NSData *)value\n{\n    return [[DataCodingObject alloc] initWithValue:value];\n}\n\n- (NSData *)archivedWCTValue\n{\n    return self.value;\n}\n\n+ (WCTColumnType)columnType\n{\n    return WCTColumnTypeData;\n}\n\n@end\n"
  },
  {
    "path": "src/objc/tests/advance/column_coding/DataCodingObject.h",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import <Foundation/Foundation.h>\n\n@interface DataCodingObject : NSObject\n\n- (instancetype)initWithValue:(NSData*)value;\n\n@property (nonatomic, retain) NSData* value;\n\n@end\n"
  },
  {
    "path": "src/objc/tests/advance/column_coding/DataCodingObject.m",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"DataCodingObject.h\"\n\n@implementation DataCodingObject\n\n- (instancetype)initWithValue:(NSData*)value\n{\n    if (self = [super init]) {\n        _value = value;\n    }\n    return self;\n}\n\n- (BOOL)isEqual:(NSObject*)object\n{\n    if (object.class != self.class) {\n        return NO;\n    }\n    DataCodingObject* other = (DataCodingObject*) object;\n    return [other.value isEqualToData:self.value];\n}\n\n@end\n"
  },
  {
    "path": "src/objc/tests/advance/column_coding/DoubleCodingObject+WCTColumnCoding.h",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"DoubleCodingObject.h\"\n#if TEST_WCDB_OBJC\n#import <WCDBOBjc/WCDBObjc.h>\n#elif TEST_WCDB_CPP\n#import <WCDBCpp/WCDBCpp.h>\n#else\n#import <WCDB/WCDBObjc.h>\n#endif\n\n@interface DoubleCodingObject (WCTColumnCoding) <WCTColumnCoding>\n\n@end\n"
  },
  {
    "path": "src/objc/tests/advance/column_coding/DoubleCodingObject+WCTColumnCoding.mm",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"DoubleCodingObject+WCTColumnCoding.h\"\n\n@implementation DoubleCodingObject (WCTColumnCoding)\n\n+ (instancetype)unarchiveWithWCTValue:(NSNumber *)value\n{\n    return [[DoubleCodingObject alloc] initWithValue:value.doubleValue];\n}\n\n- (NSNumber *)archivedWCTValue\n{\n    return [NSNumber numberWithDouble:self.value];\n}\n\n+ (WCTColumnType)columnType\n{\n    return WCTColumnTypeFloat;\n}\n\n@end\n"
  },
  {
    "path": "src/objc/tests/advance/column_coding/DoubleCodingObject.h",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import <Foundation/Foundation.h>\n\n@interface DoubleCodingObject : NSObject\n\n- (instancetype)initWithValue:(double)value;\n\n@property (nonatomic, assign) double value;\n\n@end\n"
  },
  {
    "path": "src/objc/tests/advance/column_coding/DoubleCodingObject.m",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"DoubleCodingObject.h\"\n\n@implementation DoubleCodingObject\n\n- (instancetype)initWithValue:(double)value\n{\n    if (self = [super init]) {\n        _value = value;\n    }\n    return self;\n}\n\n- (BOOL)isEqual:(NSObject*)object\n{\n    if (object.class != self.class) {\n        return NO;\n    }\n    DoubleCodingObject* other = (DoubleCodingObject*) object;\n    return other.value == self.value;\n}\n\n@end\n"
  },
  {
    "path": "src/objc/tests/advance/column_coding/IntegerCodingObject+WCTColumnCoding.h",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"IntegerCodingObject.h\"\n#if TEST_WCDB_OBJC\n#import <WCDBOBjc/WCDBObjc.h>\n#elif TEST_WCDB_CPP\n#import <WCDBCpp/WCDBCpp.h>\n#else\n#import <WCDB/WCDBObjc.h>\n#endif\n\n@interface IntegerCodingObject (WCTColumnCoding) <WCTColumnCoding>\n\n@end\n"
  },
  {
    "path": "src/objc/tests/advance/column_coding/IntegerCodingObject+WCTColumnCoding.mm",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"IntegerCodingObject+WCTColumnCoding.h\"\n\n@implementation IntegerCodingObject (WCTColumnCoding)\n\n+ (instancetype)unarchiveWithWCTValue:(NSNumber *)value\n{\n    return [[IntegerCodingObject alloc] initWithValue:value.integerValue];\n}\n\n- (NSNumber *)archivedWCTValue\n{\n    return [NSNumber numberWithLongLong:self.value];\n}\n\n+ (WCTColumnType)columnType\n{\n    return WCTColumnTypeInteger;\n}\n\n@end\n"
  },
  {
    "path": "src/objc/tests/advance/column_coding/IntegerCodingObject.h",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import <Foundation/Foundation.h>\n\n@interface IntegerCodingObject : NSObject\n\n- (instancetype)initWithValue:(int64_t)value;\n\n@property (nonatomic, assign) int64_t value;\n\n@end\n"
  },
  {
    "path": "src/objc/tests/advance/column_coding/IntegerCodingObject.m",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"IntegerCodingObject.h\"\n\n@implementation IntegerCodingObject\n\n- (instancetype)initWithValue:(int64_t)value\n{\n    if (self = [super init]) {\n        _value = value;\n    }\n    return self;\n}\n\n- (BOOL)isEqual:(NSObject*)object\n{\n    if (object.class != self.class) {\n        return NO;\n    }\n    IntegerCodingObject* other = (IntegerCodingObject*) object;\n    return other.value == self.value;\n}\n\n@end\n"
  },
  {
    "path": "src/objc/tests/advance/column_coding/Random+ColumnCodingObject.h",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"ColumnCodingObject.h\"\n#import \"TestCase.h\"\n\n@interface Random (ColumnCodingObject)\n\n- (ColumnCodingObject *)columnCodingObject;\n\n@end\n"
  },
  {
    "path": "src/objc/tests/advance/column_coding/Random+ColumnCodingObject.mm",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"Random+ColumnCodingObject.h\"\n\n@implementation Random (ColumnCodingObject)\n\n- (ColumnCodingObject*)columnCodingObject\n{\n    ColumnCodingObject* object = [[ColumnCodingObject alloc] init];\n    object.integerObject = [[IntegerCodingObject alloc] initWithValue:self.int64];\n    object.doubleObject = [[DoubleCodingObject alloc] initWithValue:self.double_];\n    object.stringObject = [[StringCodingObject alloc] initWithValue:self.string];\n    object.dataObject = [[DataCodingObject alloc] initWithValue:self.data];\n    return object;\n}\n\n@end\n"
  },
  {
    "path": "src/objc/tests/advance/column_coding/StringCodingObject+WCTColumnCoding.h",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"StringCodingObject.h\"\n#if TEST_WCDB_OBJC\n#import <WCDBOBjc/WCDBObjc.h>\n#elif TEST_WCDB_CPP\n#import <WCDBCpp/WCDBCpp.h>\n#else\n#import <WCDB/WCDBObjc.h>\n#endif\n\n@interface StringCodingObject (WCTColumnCoding) <WCTColumnCoding>\n\n@end\n"
  },
  {
    "path": "src/objc/tests/advance/column_coding/StringCodingObject+WCTColumnCoding.mm",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"StringCodingObject+WCTColumnCoding.h\"\n\n@implementation StringCodingObject (WCTColumnCoding)\n\n+ (instancetype)unarchiveWithWCTValue:(NSString *)value\n{\n    return [[StringCodingObject alloc] initWithValue:value];\n}\n\n- (NSString *)archivedWCTValue\n{\n    return self.value;\n}\n\n+ (WCTColumnType)columnType\n{\n    return WCTColumnTypeString;\n}\n\n@end\n"
  },
  {
    "path": "src/objc/tests/advance/column_coding/StringCodingObject.h",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import <Foundation/Foundation.h>\n\n@interface StringCodingObject : NSObject\n\n- (instancetype)initWithValue:(NSString*)value;\n\n@property (nonatomic, retain) NSString* value;\n\n@end\n"
  },
  {
    "path": "src/objc/tests/advance/column_coding/StringCodingObject.m",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"StringCodingObject.h\"\n\n@implementation StringCodingObject\n\n- (instancetype)initWithValue:(NSString*)value\n{\n    if (self = [super init]) {\n        _value = value;\n    }\n    return self;\n}\n\n- (BOOL)isEqual:(NSObject*)object\n{\n    if (object.class != self.class) {\n        return NO;\n    }\n    StringCodingObject* other = (StringCodingObject*) object;\n    return [other.value isEqualToString:self.value];\n}\n\n@end\n"
  },
  {
    "path": "src/objc/tests/advance/handle/HandleTests.mm",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"TestCase.h\"\n\n@interface HandleTests : CRUDTestCase\n\n@property (nonatomic, readonly) WCTHandle* handle;\n\n@property (nonatomic, readonly) WCDB::StatementInsert statementInsert;\n\n@property (nonatomic, readonly) WCDB::StatementSelect statementSelect;\n\n@end\n\n@implementation HandleTests {\n    WCTHandle* _handle;\n}\n\n- (void)setUp\n{\n    [super setUp];\n\n    _statementInsert = WCDB::StatementInsert()\n                       .insertIntoTable(self.tableName)\n                       .columns({ TestCaseObject.identifier, TestCaseObject.content })\n                       .values({ 3, WCDB::BindParameter(1) });\n\n    _statementSelect = WCDB::StatementSelect()\n                       .select(TestCaseObject.content)\n                       .from(self.tableName)\n                       .where(TestCaseObject.identifier == 3);\n\n    [self insertPresetObjects];\n}\n\n- (WCTHandle*)handle\n{\n    @synchronized(self) {\n        if (_handle == nil) {\n            _handle = [self.database getHandle];\n        }\n        return _handle;\n    }\n}\n\n- (void)tearDown\n{\n    if ([_handle isValidated]) {\n        [_handle invalidate];\n    }\n    _handle = nil;\n    [super tearDown];\n}\n\n#pragma mark - Handle\n- (void)test_tag\n{\n    TestCaseAssertEqual(self.handle.database.tag, self.database.tag);\n}\n\n#pragma mark - Execute\n- (void)test_execute\n{\n    [self doTestSQLs:@[ @\"PRAGMA user_version = 123\" ]\n         inOperation:^BOOL {\n             return [self.handle execute:WCDB::StatementPragma().pragma(WCDB::Pragma::userVersion()).to(123)];\n         }];\n}\n\n#pragma mark - Prepare\n- (void)test_prepare\n{\n    WCDB::StatementPragma statement = WCDB::StatementPragma().pragma(WCDB::Pragma::userVersion()).to(123);\n    TestCaseAssertFalse([self.handle isPrepared]);\n    TestCaseAssertTrue([self.handle prepare:statement]);\n    TestCaseAssertTrue([self.handle isPrepared]);\n    [self.handle finalizeStatement];\n    TestCaseAssertFalse([self.handle isPrepared]);\n}\n\n#pragma mark - Step\n- (void)test_step\n{\n    [self doTestSQLs:@[ @\"INSERT INTO testTable(identifier, content) VALUES(?1, ?2)\", @\"INSERT INTO testTable(identifier, content) VALUES(?1, ?2)\" ]\n         inOperation:^BOOL {\n             WCDB::StatementInsert statement = WCDB::StatementInsert().insertIntoTable(self.tableName).column(WCDB::Column(@\"identifier\")).column(WCDB::Column(@\"content\")).values(WCDB::BindParameter::bindParameters(2));\n             if (![self.handle prepare:statement]) {\n                 return NO;\n             }\n\n             [self.handle bindInteger:3\n                              toIndex:1];\n             [self.handle bindString:Random.shared.string toIndex:2];\n             if (![self.handle step]) {\n                 return NO;\n             }\n\n             [self.handle reset];\n             [self.handle bindInteger:4 toIndex:1];\n             [self.handle bindString:Random.shared.string toIndex:2];\n             BOOL succeed = [self.handle step] && [self.handle done];\n             [self.handle finalizeStatement];\n             return succeed;\n         }];\n}\n\n#pragma mark - State\n- (void)test_readonly\n{\n    {\n        WCDB::StatementPragma statement = WCDB::StatementPragma().pragma(WCDB::Pragma::userVersion());\n        TestCaseAssertTrue([self.handle prepare:statement]);\n        TestCaseAssertTrue([self.handle isStatementReadonly]);\n        [self.handle finalizeStatement];\n    }\n    {\n        WCDB::StatementPragma statement = WCDB::StatementPragma().pragma(WCDB::Pragma::userVersion()).to(123);\n        TestCaseAssertTrue([self.handle prepare:statement]);\n        TestCaseAssertFalse([self.handle isStatementReadonly]);\n        [self.handle finalizeStatement];\n    }\n}\n\n- (void)test_changes\n{\n    TestCaseAssertTrue([self.handle execute:WCDB::StatementDelete().deleteFrom(self.tableName)]);\n    TestCaseAssertEqual([self.handle getChanges], self.objects.count);\n}\n\n- (void)test_get_last_inserted\n{\n    WCDB::StatementInsert statement = WCDB::StatementInsert().insertIntoTable(self.tableName).column(WCDB::Column(@\"identifier\")).column(WCDB::Column(@\"content\")).value(nullptr).value(Random.shared.string);\n    TestCaseAssertTrue([self.handle execute:statement]);\n    TestCaseAssertEqual([self.handle getLastInsertedRowID], 3);\n}\n\n#pragma mark - Bind && Get\n- (void)test_integer\n{\n    int64_t value = Random.shared.int64;\n    {\n        TestCaseAssertTrue([self.handle prepare:self.statementInsert]);\n        [self.handle bindInteger:value toIndex:1];\n\n        TestCaseAssertTrue([self.handle step]);\n        [self.handle finalizeStatement];\n    }\n    {\n        TestCaseAssertTrue([self.handle prepare:self.statementSelect]);\n        TestCaseAssertTrue([self.handle step]);\n        TestCaseAssertEqual([self.handle extractIntegerAtIndex:0], value);\n        [self.handle finalizeStatement];\n    }\n}\n\n- (void)test_double\n{\n    double value = 1.2;\n    {\n        TestCaseAssertTrue([self.handle prepare:self.statementInsert]);\n        [self.handle bindDouble:value toIndex:1];\n\n        TestCaseAssertTrue([self.handle step]);\n        [self.handle finalizeStatement];\n    }\n    {\n        TestCaseAssertTrue([self.handle prepare:self.statementSelect]);\n        TestCaseAssertTrue([self.handle step]);\n\n        double extractedValue = [self.handle extractDoubleAtIndex:0];\n        TestCaseAssertTrue(extractedValue == value);\n        [self.handle finalizeStatement];\n    }\n}\n\n- (void)test_null\n{\n    {\n        TestCaseAssertTrue([self.handle prepare:self.statementInsert]);\n        [self.handle bindNullToIndex:1];\n\n        TestCaseAssertTrue([self.handle step]);\n        [self.handle finalizeStatement];\n    }\n    {\n        TestCaseAssertTrue([self.handle prepare:self.statementSelect]);\n        TestCaseAssertTrue([self.handle step]);\n        TestCaseAssertEqual([self.handle extractTypeAtIndex:0], WCTColumnTypeNull);\n        [self.handle finalizeStatement];\n    }\n}\n\n- (void)test_string\n{\n    NSString* value = Random.shared.string;\n    TestCaseAssertTrue(value != nil);\n    {\n        TestCaseAssertTrue([self.handle prepare:self.statementInsert]);\n        [self.handle bindString:value toIndex:1];\n\n        TestCaseAssertTrue([self.handle step]);\n        [self.handle finalizeStatement];\n    }\n    {\n        TestCaseAssertTrue([self.handle prepare:self.statementSelect]);\n        TestCaseAssertTrue([self.handle step]);\n        TestCaseAssertTrue([[self.handle extractStringAtIndex:0] isEqualToString:value]);\n        [self.handle finalizeStatement];\n    }\n}\n\n- (void)test_number\n{\n    NSNumber* value = Random.shared.number;\n    TestCaseAssertTrue(value != nil);\n    {\n        TestCaseAssertTrue([self.handle prepare:self.statementInsert]);\n        [self.handle bindNumber:value toIndex:1];\n\n        TestCaseAssertTrue([self.handle step]);\n        [self.handle finalizeStatement];\n    }\n    {\n        TestCaseAssertTrue([self.handle prepare:self.statementSelect]);\n        TestCaseAssertTrue([self.handle step]);\n\n        NSNumber* extractedValue = [self.handle extractNumberAtIndex:0];\n        TestCaseAssertTrue(abs(value.doubleValue - extractedValue.doubleValue) / abs(extractedValue.doubleValue) < 10000000);\n        [self.handle finalizeStatement];\n    }\n}\n\n- (void)test_data\n{\n    NSData* value = Random.shared.data;\n    TestCaseAssertTrue(value != nil);\n    {\n        TestCaseAssertTrue([self.handle prepare:self.statementInsert]);\n        [self.handle bindData:value toIndex:1];\n\n        TestCaseAssertTrue([self.handle step]);\n        [self.handle finalizeStatement];\n    }\n    {\n        TestCaseAssertTrue([self.handle prepare:self.statementSelect]);\n        TestCaseAssertTrue([self.handle step]);\n        TestCaseAssertTrue([[self.handle extractDataAtIndex:0] isEqualToData:value]);\n        [self.handle finalizeStatement];\n    }\n}\n\n- (void)test_meta\n{\n    NSData* value = Random.shared.data;\n    {\n        TestCaseAssertTrue([self.handle prepare:self.statementInsert]);\n        [self.handle bindData:value toIndex:1];\n\n        TestCaseAssertTrue([self.handle step]);\n        [self.handle finalizeStatement];\n    }\n    {\n        NSString* alias = @\"testAlias\";\n        TestCaseAssertTrue([self.handle prepare:WCDB::StatementSelect()\n                                                .select(WCDB::ResultColumn(TestCaseObject.content)\n                                                        .as(alias))\n                                                .from(self.tableName)]);\n        TestCaseAssertTrue([self.handle step]);\n        TestCaseAssertEqual([self.handle extractNumberOfColumns], 1);\n        TestCaseAssertTrue([[self.handle extractOriginColumnNameAtIndex:0] isEqualToString:@\"content\"]);\n        TestCaseAssertTrue([[self.handle extractColumnNameAtIndex:0] isEqualToString:alias]);\n        TestCaseAssertTrue([[self.handle extractTableNameAtIndex:0] isEqualToString:self.tableName]);\n        [self.handle finalizeStatement];\n    }\n}\n\n- (void)test_bind_index\n{\n    NSString* value = Random.shared.string;\n    TestCaseAssertTrue(value != nil);\n    {\n        WCDB::BindParameter parameter = WCDB::BindParameter::colon(\"data\");\n        WCDB::Statement insert = WCDB::StatementInsert()\n                                 .insertIntoTable(self.tableName)\n                                 .columns({ TestCaseObject.identifier, TestCaseObject.content })\n                                 .values({ 3, parameter });\n        TestCaseAssertTrue([self.handle prepare:insert]);\n        [self.handle bindString:value toIndex:[self.handle bindParameterIndex:parameter]];\n\n        TestCaseAssertTrue([self.handle step]);\n        [self.handle finalizeStatement];\n    }\n    {\n        TestCaseAssertTrue([self.handle prepare:self.statementSelect]);\n        TestCaseAssertTrue([self.handle step]);\n        TestCaseAssertTrue([[self.handle extractStringAtIndex:0] isEqualToString:value]);\n        [self.handle finalizeStatement];\n    }\n}\n\n- (void)test_cancellation_signal\n{\n    NSArray* objects = [Random.shared testCaseObjectsWithCount:10000 startingFromIdentifier:3];\n    TestCaseAssertTrue([self.database insertObjects:objects intoTable:self.tableName]);\n\n    __block BOOL hasTestInterrupt = NO;\n    [self.database traceError:^(WCTError* error) {\n        if (error.level != WCTErrorLevelError) {\n            return;\n        }\n        XCTAssertTrue(error.code == WCTErrorCodeInterrupt);\n        hasTestInterrupt = YES;\n    }];\n    WCTCancellationSignal* signal = [[WCTCancellationSignal alloc] init];\n    [self.dispatch async:^{\n        [self.handle attachCancellationSignal:signal];\n        NSArray* allObjects = [self.handle getObjectsOfClass:TestCaseObject.class fromTable:self.tableName];\n        XCTAssertNil(allObjects);\n        [self.handle invalidate];\n    }];\n    usleep(1000);\n    [signal cancel];\n    [self.dispatch waitUntilDone];\n    TestCaseAssertTrue(hasTestInterrupt);\n    [self.database traceError:nil];\n}\n\n@end\n"
  },
  {
    "path": "src/objc/tests/basic/FileTests.mm",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"TestCase.h\"\n\n@interface FileTests : DatabaseTestCase\n\n@property (nonatomic, readonly) NSArray<NSString*>* dummyPaths;\n\n@end\n\n@implementation FileTests\n\n- (void)setUp\n{\n    [super setUp];\n    _dummyPaths = [self allDummyPaths:self.path];\n}\n\n- (NSArray<NSString*>*)allDummyPaths:(NSString*)path\n{\n    WCTDatabase* database = [[WCTDatabase alloc] initWithPath:path];\n    return @[\n        path,\n        database.walPath,\n        database.firstMaterialPath,\n        database.lastMaterialPath,\n        database.incrementalMaterialPath,\n        [database.factoryRestorePath stringByAppendingPathComponent:path.lastPathComponent],\n        database.journalPath,\n        database.shmPath,\n    ];\n}\n\n- (BOOL)createDummyFiles\n{\n    return [self createDummyFiles:[NSData data]];\n}\n\n- (BOOL)createDummyFiles:(NSData*)data\n{\n    if (data == nil) {\n        TestCaseFailure();\n        return NO;\n    }\n    for (NSString* path in self.dummyPaths) {\n        if (![self.fileManager createDirectoryAtPath:path.stringByDeletingLastPathComponent withIntermediateDirectories:YES attributes:nil error:nil]) {\n            TestCaseFailure();\n            return NO;\n        }\n        if ([self.fileManager fileExistsAtPath:path]) {\n            continue;\n        }\n        if (![self.fileManager createFileAtPath:path contents:data attributes:nil]) {\n            TestCaseFailure();\n            return NO;\n        }\n    }\n    return YES;\n}\n\n- (BOOL)allFilesExists\n{\n    return [self allFilesExists:self.database.paths];\n}\n\n- (BOOL)allFilesExists:(NSArray<NSString*>*)paths\n{\n    for (NSString* path in paths) {\n        if (![self.fileManager fileExistsAtPath:path]) {\n            TestCaseFailure();\n            return NO;\n        }\n    }\n    return YES;\n}\n\n- (BOOL)noneFilesExists\n{\n    return [self noneFilesExists:self.database.paths];\n}\n\n- (BOOL)noneFilesExists:(NSArray<NSString*>*)paths\n{\n    for (NSString* path in paths) {\n        if ([self.fileManager fileExistsAtPath:path]) {\n            TestCaseFailure();\n            return NO;\n        }\n    }\n    return YES;\n}\n\n- (void)test_remove_files\n{\n    TestCaseAssertTrue([self createDummyFiles]);\n    TestCaseAssertTrue([self allFilesExists]);\n    TestCaseAssertTrue([self.database canOpen]);\n    TestCaseAssertTrue([self.database isOpened]);\n    TestCaseAssertTrue([self.database removeFiles]);\n    TestCaseAssertFalse([self.database isOpened]);\n    TestCaseAssertTrue([self noneFilesExists]);\n}\n\n- (void)test_move_files\n{\n    NSString* filename = self.path.lastPathComponent;\n\n    NSString* movedDirectory = [self.directory stringByAppendingPathComponent:@\"moved\"];\n    NSString* movedDatabase = [movedDirectory stringByAppendingPathComponent:filename];\n    NSArray<NSString*>* movedPaths = [self allDummyPaths:movedDatabase];\n\n    TestCaseAssertTrue([self noneFilesExists:movedPaths]);\n\n    TestCaseAssertTrue([self.database canOpen]);\n    TestCaseAssertTrue([self.database isOpened]);\n\n    TestCaseAssertTrue([self createDummyFiles]);\n    TestCaseAssertTrue([self allFilesExists:self.dummyPaths]);\n    TestCaseAssertTrue([self.database moveFilesToDirectory:movedDirectory]);\n\n    TestCaseAssertFalse([self.database isOpened]);\n    TestCaseAssertTrue([self noneFilesExists:self.dummyPaths]);\n    TestCaseAssertTrue([self allFilesExists:movedPaths]);\n}\n\n- (void)test_files_size\n{\n    NSData* dummyData = [@\"testData\" dataUsingEncoding:NSUTF8StringEncoding];\n    TestCaseAssertTrue([self createDummyFiles:dummyData]);\n    NSInteger fileSize = [self.database getFilesSize];\n    TestCaseAssertEqual(fileSize, dummyData.length * self.dummyPaths.count);\n}\n\n- (void)test_files_size_failed\n{\n    NSData* dummyData = [@\"testData\" dataUsingEncoding:NSUTF8StringEncoding];\n\n    // bad guy\n    TestCaseAssertTrue([self.fileManager removeItemAtPath:self.directory error:nil]);\n    TestCaseAssertTrue([self.fileManager createFileAtPath:self.directory contents:dummyData attributes:nil]);\n\n    auto fileSizeOptional = [self.database getFilesSize];\n    TestCaseAssertTrue(fileSizeOptional.failed());\n    TestCaseAssertEqual(fileSizeOptional.value(), 0);\n}\n\n- (void)test_feature_auto_create_immediate_directory\n{\n    NSString* directory = [[[[[[self.directory stringByAppendingPathComponent:@\"immediate\"] stringByAppendingPathComponent:@\"directory\"] stringByAppendingPathComponent:@\"will\"] stringByAppendingPathComponent:@\"be\"] stringByAppendingPathComponent:@\"created\"] stringByAppendingPathComponent:@\"automatically\"];\n    NSString* path = [directory stringByAppendingPathComponent:self.path.lastPathComponent];\n\n    WCTDatabase* database = [[WCTDatabase alloc] initWithPath:path];\n    TestCaseAssertTrue([database canOpen]);\n\n    BOOL isDirectory = NO;\n    TestCaseAssertTrue([self.fileManager fileExistsAtPath:directory isDirectory:&isDirectory]);\n    TestCaseAssertTrue(isDirectory);\n}\n\n- (void)test_feature_path_normalized\n{\n    NSString* path = [self.directory stringByAppendingString:@\"//directory//database\"];\n    WCTDatabase* database = [[WCTDatabase alloc] initWithPath:path];\n    TestCaseAssertTrue([database canOpen]);\n\n    NSString* normalizedPath = [[[NSString stringWithFormat:@\"%@\", self.directory] stringByAppendingPathComponent:@\"directory\"] stringByAppendingPathComponent:@\"database\"];\n    TestCaseAssertTrue([database.path isEqualToString:normalizedPath]);\n}\n\n#if TARGET_OS_IPHONE && !TARGET_IPHONE_SIMULATOR\n- (void)test_feature_auto_set_file_protection\n{\n    TestCaseAssertTrue([self.database canOpen]);\n    TestCaseAssertTrue([self.fileManager fileExistsAtPath:self.database.path]);\n\n    [self.database close];\n\n    NSError* error;\n    NSFileProtectionType fileProtectionTypeBefore = [self.fileManager getFileProtection:self.database.path];\n    TestCaseAssertTrue(fileProtectionTypeBefore == nil\n                       || [fileProtectionTypeBefore isEqualToString:NSFileProtectionNone]\n                       || [fileProtectionTypeBefore isEqualToString:NSFileProtectionCompleteUntilFirstUserAuthentication]);\n    TestCaseAssertTrue(error == nil);\n\n    [self.fileManager setFileProtectionOfPath:self.database.path to:NSFileProtectionComplete];\n    TestCaseAssertTrue(error == nil);\n\n    // trigger\n    TestCaseAssertTrue([self.database canOpen]);\n\n    NSFileProtectionType fileProtectionTypeAfter = [self.fileManager getFileProtection:self.database.path];\n    TestCaseAssertTrue([fileProtectionTypeAfter isEqualToString:NSFileProtectionCompleteUntilFirstUserAuthentication]);\n    TestCaseAssertTrue(error == nil);\n}\n#endif\n\n@end\n"
  },
  {
    "path": "src/objc/tests/basic/ObservationTests.mm",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"CoreConst.h\"\n#import \"TestCase.h\"\n#import <set>\n#import <sys/stat.h>\n#if TARGET_OS_IPHONE && !TARGET_OS_WATCH\n#import <UIKit/UIKit.h>\n#endif\n\n@interface ObservationTests : CRUDTestCase\n\n@end\n\n@implementation ObservationTests\n\n- (void)test_corrupted_notification\n{\n    [self insertPresetObjects];\n\n    TestCaseResult* result = [TestCaseResult no];\n    [self.database setNotificationWhenCorrupted:^void(WCTDatabase* database) {\n        if (![NSThread isMainThread] && database.isBlockaded) {\n            [result makeYES];\n        }\n        [self.database removeFiles];\n    }];\n\n    TestCaseAssertTrue([self.database corruptHeaderWithinCloseAfterTruncatedCheckpoint]);\n\n    // trigger corruption\n    TestCaseAssertTrue([self.table getObjects] == nil);\n    [NSThread sleepForTimeInterval:1.0];\n    while (result.isNO) {\n    }\n    TestCaseAssertResultYES(result);\n    TestCaseAssertFalse(self.database.isAlreadyCorrupted);\n}\n\n- (void)test_feature_purge_will_not_clear_active_handle\n{\n    // acquire handle and keep it\n    WCTHandle* handle = [self.database getHandle];\n    TestCaseAssertTrue([handle execute:WCDB::StatementPragma().pragma(WCDB::Pragma::userVersion())]);\n\n    TestCaseAssertTrue([self.database isOpened]);\n    [self.database purge];\n    TestCaseAssertTrue([self.database isOpened]);\n}\n\n#if TARGET_OS_IPHONE && !TARGET_OS_WATCH\n- (void)test_feature_auto_purge_due_to_memory_warning\n{\n    __block TestCaseResult* tested = [TestCaseResult no];\n    [self.database traceError:^(WCTError* error) {\n        if (error.level == WCTErrorLevelWarning\n            && error.code == WCTErrorCodeWarning) {\n            [tested makeYES];\n        }\n    }];\n\n    TestCaseAssertTrue([self.database canOpen]);\n    [[NSNotificationCenter defaultCenter] postNotificationName:UIApplicationDidReceiveMemoryWarningNotification object:nil];\n\n    while (tested.isNO) {\n    }\n\n    [NSThread sleepForTimeInterval:2];\n    TestCaseAssertFalse([self.database isOpened]);\n\n    // sleep for other tests\n    [NSThread sleepForTimeInterval:WCDB::OperationQueueTimeIntervalForPurgingAgain];\n}\n\n- (void)test_feature_auto_purge_will_not_be_too_frequent\n{\n    __block TestCaseResult* tested = [TestCaseResult no];\n    [self.database traceError:^(WCTError* error) {\n        if (error.level == WCTErrorLevelWarning\n            && error.code == WCTErrorCodeWarning) {\n            [tested makeYES];\n        }\n    }];\n\n    TestCaseAssertTrue([self.database canOpen]);\n    [[NSNotificationCenter defaultCenter] postNotificationName:UIApplicationDidReceiveMemoryWarningNotification object:nil];\n    while (tested.isNO) {\n    }\n    [tested makeNO];\n    [NSThread sleepForTimeInterval:2];\n    TestCaseAssertFalse([self.database isOpened]);\n\n    TestCaseAssertTrue([self.database canOpen]);\n    [[NSNotificationCenter defaultCenter] postNotificationName:UIApplicationDidReceiveMemoryWarningNotification object:nil];\n    [NSThread sleepForTimeInterval:2];\n    TestCaseAssertResultNO(tested);\n    TestCaseAssertTrue([self.database isOpened]);\n\n    [NSThread sleepForTimeInterval:WCDB::OperationQueueTimeIntervalForPurgingAgain];\n    [[NSNotificationCenter defaultCenter] postNotificationName:UIApplicationDidReceiveMemoryWarningNotification object:nil];\n    while (tested.isNO) {\n    }\n    [NSThread sleepForTimeInterval:2];\n    TestCaseAssertFalse([self.database isOpened]);\n\n    // sleep for other tests\n    [NSThread sleepForTimeInterval:WCDB::OperationQueueTimeIntervalForPurgingAgain];\n}\n#endif\n\n- (void)test_feature_auto_purge_due_to_file_descriptors_warning\n{\n    int maxAllowedNumberOfFileDescriptors = getdtablesize();\n    int numberOfFileDescriptorsForTooManyFileDescriptors = int(maxAllowedNumberOfFileDescriptors * WCDB::OperationQueueRateForTooManyFileDescriptors);\n\n    NSString* dummy = [self.directory stringByAppendingPathComponent:@\"dummy\"];\n    TestCaseAssertTrue([self.fileManager createFileAtPath:dummy contents:nil attributes:nil]);\n\n    // open files until it meet the threshold\n    int numberOfAlreadyOpenedFileDescriptors = 0;\n    struct stat stats;\n    for (int i = 0; i <= maxAllowedNumberOfFileDescriptors; ++i) {\n        int rc = fstat(i, &stats);\n        if (rc == 0 || errno != EBADF) {\n            ++numberOfAlreadyOpenedFileDescriptors;\n        }\n    }\n\n    std::set<int> openedFileDescriptor;\n    do {\n        int fd = open(dummy.UTF8String, O_RDONLY);\n        TestCaseAssertTrue(fd >= 0);\n        openedFileDescriptor.emplace(fd);\n    } while (openedFileDescriptor.size() + numberOfAlreadyOpenedFileDescriptors < numberOfFileDescriptorsForTooManyFileDescriptors);\n\n    // purge will be done after a few moment.\n    __block TestCaseResult* tested = [TestCaseResult no];\n    [self.database traceError:^(WCTError* error) {\n        if (error.level == WCTErrorLevelWarning\n            && error.code == WCTErrorCodeWarning) {\n            [tested makeYES];\n        }\n    }];\n    TestCaseAssertTrue([self.database canOpen]);\n    while (tested.isNO) {\n    }\n\n    for (const auto& fd : openedFileDescriptor) {\n        TestCaseAssertTrue(close(fd) == 0);\n    }\n\n    // sleep for other tests\n    [NSThread sleepForTimeInterval:WCDB::OperationQueueTimeIntervalForPurgingAgain];\n}\n\n- (void)test_feature_auto_purge_due_to_too_many_file_descriptors\n{\n    TestCaseAssertTrue([self.database canOpen]);\n    [self.database close];\n\n    NSString* dummy = [self.directory stringByAppendingPathComponent:@\"dummy\"];\n    TestCaseAssertTrue([self.fileManager createFileAtPath:dummy contents:nil attributes:nil]);\n\n    // open files until it failed\n    std::set<int> openedFileDescriptor;\n    do {\n        int fd = open(dummy.UTF8String, O_RDONLY);\n        if (fd > 0) {\n            openedFileDescriptor.emplace(fd);\n        } else {\n            TestCaseAssertTrue(errno == EMFILE);\n            break;\n        }\n    } while (YES);\n\n    // purge will be done after a few moment.\n    __block TestCaseResult* tested = [TestCaseResult no];\n    [self.database traceError:^(WCTError* error) {\n        if (error.level == WCTErrorLevelWarning\n            && error.code == WCTErrorCodeWarning) {\n            [tested makeYES];\n        }\n    }];\n    TestCaseAssertFalse([self.database canOpen]);\n    while (tested.isNO) {\n    }\n\n    for (const auto& fd : openedFileDescriptor) {\n        TestCaseAssertTrue(close(fd) == 0);\n    }\n\n    // sleep for other tests\n    [NSThread sleepForTimeInterval:WCDB::OperationQueueTimeIntervalForPurgingAgain];\n}\n\n- (void)test_check_if_corrupted\n{\n    [self insertPresetObjects];\n\n    TestCaseAssertTrue([self.database corruptHeaderWithinCloseAfterTruncatedCheckpoint]);\n\n    TestCaseAssertTrue([self.database checkIfCorrupted]);\n    TestCaseAssertTrue(self.database.isAlreadyCorrupted);\n}\n\n@end\n"
  },
  {
    "path": "src/objc/tests/basic/TableTests.mm",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"TestCase.h\"\n\n@interface TableTests : TableTestCase\n\n@end\n\n@implementation TableTests\n\n#pragma mark - Basic\n- (void)test_drop_index_with_suffix\n{\n    TestCaseAssertTrue([self createTable]);\n\n    [self doTestSQLs:@[ @\"DROP INDEX IF EXISTS testTable_index\" ]\n         inOperation:^BOOL {\n             return [self.table dropIndexWithSuffix:@\"_index\"];\n         }];\n}\n\n- (void)test_index_with_suffix\n{\n    TestCaseAssertTrue([self createTable]);\n\n    TestCaseAssertTrue([[self.table indexWithSuffix:@\"_index\"] isEqualToString:[self.table.tableName stringByAppendingString:@\"_index\"]]);\n}\n\n#pragma mark - Database\n- (void)test_database_table_exists\n{\n    TestCaseAssertTrue([self createTable]);\n\n    TestCaseAssertOptionalTrue([self.database tableExists:self.tableName]);\n\n    TestCaseAssertOptionalFalse([self.database tableExists:@\"nonexists\"]);\n}\n\n- (void)test_database_drop_table\n{\n    [self doTestSQLs:@[ @\"DROP TABLE IF EXISTS testTable\" ]\n         inOperation:^BOOL {\n             return [self.database dropTable:self.tableName];\n         }];\n    TestCaseAssertOptionalFalse([self.database tableExists:self.tableName]);\n}\n\n- (void)test_database_drop_index\n{\n    [self doTestSQLs:@[ @\"DROP INDEX IF EXISTS testTable_index\" ]\n         inOperation:^BOOL {\n             return [self.database dropIndex:@\"testTable_index\"];\n         }];\n}\n\n#pragma mark - Handle\n- (void)test_handle_table_exists\n{\n    TestCaseAssertTrue([self createTable]);\n\n    WCTHandle* handle = [self.database getHandle];\n\n    TestCaseAssertOptionalTrue([handle tableExists:self.tableName]);\n\n    TestCaseAssertOptionalFalse([handle tableExists:@\"nonexists\"]);\n}\n\n- (void)test_handle_drop_table\n{\n    WCTHandle* handle = [self.database getHandle];\n    [self doTestSQLs:@[ @\"DROP TABLE IF EXISTS testTable\" ]\n         inOperation:^BOOL {\n             return [handle dropTable:self.tableName];\n         }];\n    TestCaseAssertOptionalFalse([handle tableExists:self.tableName]);\n}\n\n- (void)test_handle_drop_index\n{\n    WCTHandle* handle = [self.database getHandle];\n    [self doTestSQLs:@[ @\"DROP INDEX IF EXISTS testTable_index\" ]\n         inOperation:^BOOL {\n             return [handle dropIndex:@\"testTable_index\"];\n         }];\n}\n\n@end\n"
  },
  {
    "path": "src/objc/tests/benchmark/BaselineBenchmark.mm",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"ObjectsBasedBenchmark.h\"\n\n@interface BaselineBenchmark : ObjectsBasedBenchmark\n\n@end\n\n@implementation BaselineBenchmark\n\n- (void)test_write\n{\n    [self doTestWrite];\n}\n\n- (void)test_read\n{\n    [self doTestRead];\n}\n\n- (void)test_batch_read\n{\n    [self doTestBatchRead];\n}\n\n- (void)test_batch_write\n{\n    [self doTestBatchWrite];\n}\n\n- (void)test_create_index\n{\n    __block BOOL result;\n    [self\n    doMeasure:^{\n        NSString* indexName = [NSString stringWithFormat:@\"%@_index\", self.tableName];\n        WCDB::StatementCreateIndex statement = WCDB::StatementCreateIndex().createIndex(indexName).table(self.tableName).indexed(TestCaseObject.identifier);\n\n        result = [self.database execute:statement];\n    }\n    setUp:^{\n        [self setUpDatabase];\n    }\n    tearDown:^{\n        [self tearDownDatabase];\n        result = NO;\n    }\n    checkCorrectness:^{\n        TestCaseAssertTrue(result);\n    }];\n}\n\n- (void)test_winq_read\n{\n    [self\n           doMeasure:^{\n               for (int i = 0; i < self.testQuality; i++) {\n                   WCDB::StatementSelect select = WCDB::StatementSelect().select(TestCaseObject.allProperties).from(self.tableName).where(TestCaseObject.identifier == 1);\n                   WCDB::StringView description = select.getDescription();\n               }\n           }\n               setUp:nil\n            tearDown:nil\n    checkCorrectness:nil];\n}\n\n- (void)test_winq_write\n{\n    [self\n           doMeasure:^{\n               for (int i = 0; i < self.testQuality; i++) {\n                   WCDB::StatementInsert insert = WCDB::StatementInsert().insertIntoTable(self.tableName).columns(TestCaseObject.allProperties).values(WCDB::BindParameter::bindParameters(TestCaseObject.allProperties.size()));\n                   WCDB::StringView description = insert.getDescription();\n               }\n           }\n               setUp:nil\n            tearDown:nil\n    checkCorrectness:nil];\n}\n\n@end\n"
  },
  {
    "path": "src/objc/tests/benchmark/CipherBenchmark.mm",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"ObjectsBasedBenchmark.h\"\n\n@interface CipherBenchmark : ObjectsBasedBenchmark\n@property (nonatomic, readonly) NSData *cipher;\n@end\n\n@implementation CipherBenchmark {\n    NSData *_cipher;\n}\n\n- (void)setUp\n{\n    [super setUp];\n    self.factory.category = @\"cipher\";\n    [self.factory.database setCipherKey:self.cipher];\n}\n\n- (NSData *)cipher\n{\n    return [@\"cipher\" dataUsingEncoding:NSASCIIStringEncoding];\n}\n\n- (void)setUpDatabase\n{\n    [super setUpDatabase];\n    [self.database setCipherKey:self.cipher];\n}\n\n- (void)test_write\n{\n    [self doTestWrite];\n}\n\n- (void)test_read\n{\n    [self doTestRead];\n}\n\n- (void)test_batch_write\n{\n    [self doTestBatchWrite];\n}\n\n@end\n"
  },
  {
    "path": "src/objc/tests/benchmark/CompressionBenchmark.h",
    "content": "//\n// Created by qiuwenchen on 2023/12/10.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"ObjectsBasedBenchmark.h\"\n\ntypedef enum : NSUInteger {\n    CompressionMode_NoCompression = 0,\n    CompressionMode_NormalCompress,\n    CompressionMode_DictCompress,\n} CompressionMode;\n\n@interface CompressionBenchmark : ObjectsBasedBenchmark\n\n@property (nonatomic, assign) CompressionMode mode;\n\n@end\n"
  },
  {
    "path": "src/objc/tests/benchmark/CompressionBenchmark.mm",
    "content": "//\n// Created by qiuwenchen on 2023/12/10.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"CompressionBenchmark.h\"\n#import <Foundation/Foundation.h>\n\nstatic WCTDictId kDictId = 1;\n\n@implementation CompressionBenchmark\n\n- (void)setUp\n{\n    [super setUp];\n    self.testQuality = 10000;\n    switch (self.mode) {\n    case CompressionMode_NoCompression:\n        self.factory.category = @\"NoCompression\";\n        break;\n    case CompressionMode_NormalCompress:\n        self.factory.category = @\"NormalCompress\";\n        break;\n    case CompressionMode_DictCompress:\n        self.factory.category = @\"DictCompress\";\n        break;\n    }\n    [[Random shared] setStringType:RandomStringType_English];\n    [self configCompression:self.factory.database];\n\n    static dispatch_once_t onceToken;\n    dispatch_once(&onceToken, ^{\n        NSMutableArray *contents = [[NSMutableArray alloc] init];\n        for (int i = 0; i < 3000; i++) {\n            [contents addObject:[[Random shared] string]];\n        }\n        NSData *dict = [WCTDatabase trainDictWithStrings:contents andDictId:kDictId];\n        XCTAssertNotNil(dict);\n        TestCaseAssertTrue([WCTDatabase registerZSTDDict:dict andDictId:kDictId]);\n    });\n}\n\n- (void)tearDown\n{\n    [super tearDown];\n    [[Random shared] setStringType:RandomStringType_Default];\n}\n\n- (void)setUpDatabase\n{\n    [super setUpDatabase];\n    [self configCompression:self.database];\n}\n\n- (void)configCompression:(WCTDatabase *)database\n{\n    switch (self.mode) {\n    case CompressionMode_NormalCompress: {\n        [database setCompressionWithFilter:^(WCTCompressionUserInfo *info) {\n            if (![info.table isEqualToString:self.tableName]) {\n                return;\n            }\n            [info addZSTDNormalCompressProperty:TestCaseObject.content];\n        }];\n    } break;\n    case CompressionMode_DictCompress: {\n        [database setCompressionWithFilter:^(WCTCompressionUserInfo *info) {\n            if (![info.table isEqualToString:self.tableName]) {\n                return;\n            }\n            [info addZSTDDictCompressProperty:TestCaseObject.content withDictId:kDictId];\n        }];\n    } break;\n    default:\n        break;\n    }\n\n    if (self.mode == CompressionMode_NoCompression) {\n        return;\n    }\n    TestCaseAssertFalse([database isCompressed]);\n}\n\n- (void)test_read\n{\n    [self doTestRead];\n}\n\n- (void)test_batch_read\n{\n    [self doTestBatchRead];\n}\n\n- (void)test_write\n{\n    [self doTestWrite];\n}\n\n- (void)test_batch_write\n{\n    [self doTestBatchWrite];\n}\n\n- (void)test_random_read\n{\n    [self doTestRandomRead];\n}\n\n- (void)test_random_update\n{\n    [self doTestRandomUpdate];\n}\n\n- (void)test_random_delete\n{\n    [self doTestRandomDelete];\n}\n\n@end\n"
  },
  {
    "path": "src/objc/tests/benchmark/DatabaseMigrationBenchmark.mm",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"MigrationBenchmark.h\"\n\n@interface DatabaseMigrationBenchmark : MigrationBenchmark\n@end\n\n@implementation DatabaseMigrationBenchmark\n\n- (void)setUp\n{\n    self.isCrossDatabase = YES;\n    [super setUp];\n}\n\n- (void)test_read\n{\n    [self doTestRead];\n}\n\n- (void)test_write\n{\n    [self doTestWrite];\n}\n\n- (void)test_batch_write\n{\n    [self doTestBatchWrite];\n}\n\n- (void)test_migrate\n{\n    [self doTestMigrate];\n}\n\n@end\n"
  },
  {
    "path": "src/objc/tests/benchmark/DictCompressionBenchmark.mm",
    "content": "//\n// Created by qiuwenchen on 2023/12/10.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"CompressionBenchmark.h\"\n#import <Foundation/Foundation.h>\n\n@interface DictCompressionBenchmark : CompressionBenchmark\n\n@end\n\n@implementation DictCompressionBenchmark\n\n- (void)setUp\n{\n    self.mode = CompressionMode_DictCompress;\n    [super setUp];\n}\n\n- (void)test_read\n{\n    [self doTestRead];\n}\n\n- (void)test_batch_read\n{\n    [self doTestBatchRead];\n}\n\n- (void)test_write\n{\n    [self doTestWrite];\n}\n\n- (void)test_batch_write\n{\n    [self doTestBatchWrite];\n}\n\n- (void)test_random_read\n{\n    [self doTestRandomRead];\n}\n\n- (void)test_random_update\n{\n    [self doTestRandomUpdate];\n}\n\n- (void)test_random_delete\n{\n    [self doTestRandomDelete];\n}\n\n@end\n"
  },
  {
    "path": "src/objc/tests/benchmark/MigrationBenchmark.h",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"ObjectsBasedBenchmark.h\"\n\n@interface MigrationBenchmark : ObjectsBasedBenchmark\n\n- (void)doTestMigrate;\n\n@property (nonatomic, assign) BOOL isCrossDatabase;\n\n@end\n"
  },
  {
    "path": "src/objc/tests/benchmark/MigrationBenchmark.mm",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"MigrationBenchmark.h\"\n\n@interface MigrationBenchmark ()\n@property (nonatomic, retain) WCTDatabase* sourceDatabase;\n@property (nonatomic, retain) NSString* sourcePath;\n@end\n\n@implementation MigrationBenchmark {\n    WCTDatabase* _sourceDatabase;\n    NSString* _sourcePath;\n}\n\n- (void)setSourcePath:(NSString*)sourcePath\n{\n    _sourcePath = sourcePath;\n    _sourceDatabase = nil;\n}\n\n- (NSString*)sourcePath\n{\n    @synchronized(self) {\n        if (_sourcePath == nil) {\n            if (self.isCrossDatabase) {\n                _sourcePath = [self.path stringByAppendingString:@\"_source\"];\n            } else {\n                _sourcePath = self.path;\n            }\n        }\n        return _sourcePath;\n    }\n}\n\n- (WCTDatabase*)sourceDatabase\n{\n    @synchronized(self) {\n        if (_sourceDatabase == nil) {\n            _sourceDatabase = [[WCTDatabase alloc] initWithPath:self.sourcePath];\n        }\n        return _sourceDatabase;\n    }\n}\n\n- (void)setUpDatabase\n{\n    [self.factory produce:self.sourcePath];\n    self.tableName = [self.factory.tableName stringByAppendingString:@\"_migrated\"];\n\n    NSString* tableName = self.tableName;\n    NSString* path = self.path;\n    NSString* sourceTableName = self.factory.tableName;\n    NSString* sourcePath = self.sourcePath;\n    [self.database addMigration:sourcePath\n                     withFilter:^(WCTMigrationUserInfo* info) {\n                         if ([info.table isEqualToString:tableName]) {\n                             info.sourceTable = sourceTableName;\n                         }\n                     }];\n    TestCaseAssertTrue([self.database createTable:self.tableName withClass:TestCaseObject.class]);\n    TestCaseAssertTrue([self.database stepMigration]);\n    TestCaseAssertFalse([self.database isMigrated]);\n    TestCaseAssertTrue([self.database truncateCheckpoint]);\n    TestCaseAssertTrue([self.sourceDatabase truncateCheckpoint]);\n    [self.database close];\n\n    TestCaseAssertOptionalEqual([self.database getNumberOfWalFrames], 0);\n    TestCaseAssertOptionalEqual([self.sourceDatabase getNumberOfWalFrames], 0);\n    TestCaseAssertFalse([self.database isOpened]);\n}\n\n- (void)tearDownDatabase\n{\n    TestCaseAssertTrue([self.database removeFiles]);\n    TestCaseAssertTrue([self.sourceDatabase removeFiles]);\n}\n\n- (void)doTestMigrate\n{\n    self.factory.quality = 100000;\n    [self\n    doMeasure:^{\n        while ([self.database stepMigration] && ![self.database isMigrated]);\n    }\n    setUp:^{\n        [self setUpDatabase];\n    }\n    tearDown:^{\n        [self tearDownDatabase];\n    }\n    checkCorrectness:^{\n        TestCaseAssertTrue([self.database isMigrated]);\n    }];\n}\n\n@end\n"
  },
  {
    "path": "src/objc/tests/benchmark/NormalCompressionBenchmark.mm",
    "content": "//\n// Created by qiuwenchen on 2023/12/10.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"CompressionBenchmark.h\"\n#import <Foundation/Foundation.h>\n\n@interface NormalCompressionBenchmark : CompressionBenchmark\n\n@end\n\n@implementation NormalCompressionBenchmark\n\n- (void)setUp\n{\n    self.mode = CompressionMode_NormalCompress;\n    [super setUp];\n}\n\n- (void)test_read\n{\n    [self doTestRead];\n}\n\n- (void)test_batch_read\n{\n    [self doTestBatchRead];\n}\n\n- (void)test_write\n{\n    [self doTestWrite];\n}\n\n- (void)test_batch_write\n{\n    [self doTestBatchWrite];\n}\n\n- (void)test_random_read\n{\n    [self doTestRandomRead];\n}\n\n- (void)test_random_update\n{\n    [self doTestRandomUpdate];\n}\n\n- (void)test_random_delete\n{\n    [self doTestRandomDelete];\n}\n\n@end\n"
  },
  {
    "path": "src/objc/tests/benchmark/ObjectsBasedBenchmark.h",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"ObjectsBasedFactory.h\"\n#import \"TestCase.h\"\n\n@interface ObjectsBasedBenchmark : Benchmark\n\n@property (nonatomic, retain) NSString* tableName;\n\n@property (nonatomic, readonly) ObjectsBasedFactory* factory;\n\n@property (nonatomic, assign) int testQuality;\n\n- (void)setUpDatabase;\n- (void)tearDownDatabase;\n\n- (void)doTestWrite;\n\n- (void)doTestRead;\n\n- (void)doTestBatchRead;\n\n- (void)doTestBatchWrite;\n\n- (void)doTestRandomRead;\n\n- (void)doTestRandomUpdate;\n\n- (void)doTestRandomDelete;\n\n@end\n"
  },
  {
    "path": "src/objc/tests/benchmark/ObjectsBasedBenchmark.mm",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"ObjectsBasedBenchmark.h\"\n\n@implementation ObjectsBasedBenchmark {\n    ObjectsBasedFactory* _factory;\n}\n\n- (ObjectsBasedFactory*)factory\n{\n    @synchronized(self) {\n        if (_factory == nil) {\n            _factory = [[ObjectsBasedFactory alloc] initWithDirectory:self.class.cacheRoot];\n        }\n        return _factory;\n    }\n}\n\n- (void)setUp\n{\n    [super setUp];\n\n    self.factory.tolerance = 0.0f;\n    self.factory.quality = 1000000;\n\n    self.testQuality = 100000;\n    self.tableName = self.factory.tableName;\n}\n\n- (void)setUpDatabase\n{\n    [self.factory produce:self.path];\n\n    TestCaseAssertOptionalEqual([self.database getNumberOfWalFrames], 0);\n    TestCaseAssertFalse([self.database isOpened]);\n}\n\n- (void)tearDownDatabase\n{\n    [self.database removeFiles];\n}\n\n- (void)doTestWrite\n{\n    NSArray* objects = [Random.shared testCaseObjectsWithCount:self.testQuality startingFromIdentifier:(int) self.factory.quality];\n    __block BOOL result;\n    [self\n    doMeasure:^{\n        for (TestCaseObject* object in objects) {\n            if (![self.database insertObject:object intoTable:self.tableName]) {\n                result = NO;\n                return;\n            }\n        }\n        result = YES;\n    }\n    setUp:^{\n        [self setUpDatabase];\n    }\n    tearDown:^{\n        [self tearDownDatabase];\n        result = NO;\n    }\n    checkCorrectness:^{\n        TestCaseAssertTrue(result);\n    }];\n}\n\n- (void)doTestRead\n{\n    __block NSMutableArray<TestCaseObject*>* result;\n    [self\n    doMeasure:^{\n        for (int i = 1; i <= self.testQuality; i++) {\n            TestCaseObject* obj = [self.database getObjectOfClass:TestCaseObject.class fromTable:self.tableName where:TestCaseObject.identifier == i];\n            [result addObject:obj];\n        }\n    }\n    setUp:^{\n        [self setUpDatabase];\n    }\n    tearDown:^{\n        [self tearDownDatabase];\n        result = [NSMutableArray new];\n    }\n    checkCorrectness:^{\n        TestCaseAssertEqual(result.count, self.testQuality);\n    }];\n}\n\n- (void)doTestBatchRead\n{\n    __block NSArray<TestCaseObject*>* result;\n    [self\n    doMeasure:^{\n        result = [self.database getObjectsOfClass:TestCaseObject.class fromTable:self.tableName limit:self.testQuality];\n    }\n    setUp:^{\n        [self setUpDatabase];\n    }\n    tearDown:^{\n        [self tearDownDatabase];\n        result = nil;\n    }\n    checkCorrectness:^{\n        TestCaseAssertEqual(result.count, self.testQuality);\n    }];\n}\n\n- (void)doTestBatchWrite\n{\n    NSArray* objects = [Random.shared testCaseObjectsWithCount:self.testQuality startingFromIdentifier:(int) self.factory.quality];\n    __block BOOL result;\n    [self\n    doMeasure:^{\n        result = [self.database insertObjects:objects intoTable:self.tableName];\n    }\n    setUp:^{\n        [self setUpDatabase];\n    }\n    tearDown:^{\n        [self tearDownDatabase];\n        result = NO;\n    }\n    checkCorrectness:^{\n        TestCaseAssertTrue(result);\n    }];\n}\n\n- (void)doTestRandomRead\n{\n    __block NSMutableArray<TestCaseObject*>* result = [[NSMutableArray alloc] initWithCapacity:self.testQuality];\n    __block NSMutableArray<WCTValue*>* identifiers;\n    [self\n    doMeasure:^{\n        int index = 0;\n        for (int i = 1; i <= self.testQuality; i++) {\n            index = [[Random shared] uint32] % identifiers.count;\n\n            TestCaseObject* obj = [self.database getObjectOfClass:TestCaseObject.class fromTable:self.tableName where:TestCaseObject.identifier == identifiers[index].numberValue.intValue];\n            if (obj == nil) {\n                continue;\n                ;\n            }\n            [result addObject:obj];\n            [identifiers removeObjectAtIndex:index];\n        }\n    }\n    setUp:^{\n        [self setUpDatabase];\n        identifiers = (NSMutableArray<WCTValue*>*) [self.database getColumnOnResultColumn:TestCaseObject.identifier fromTable:self.tableName];\n    }\n    tearDown:^{\n        [self tearDownDatabase];\n        result = [[NSMutableArray alloc] initWithCapacity:self.testQuality];\n    }\n    checkCorrectness:^{\n        TestCaseAssertEqual(result.count, self.testQuality);\n    }];\n}\n\n- (void)doTestRandomUpdate\n{\n    __block NSMutableArray<WCTValue*>* identifiers;\n    [self\n    doMeasure:^{\n        int index = 0;\n        for (int i = 1; i <= self.testQuality; i++) {\n            index = [[Random shared] uint32] % identifiers.count;\n            TestCaseAssertTrue([self.database updateTable:self.tableName setProperty:TestCaseObject.content toValue:Random.shared.string where:TestCaseObject.identifier == identifiers[index].numberValue.intValue]);\n            [identifiers removeObjectAtIndex:index];\n        }\n    }\n    setUp:^{\n        [self setUpDatabase];\n        identifiers = (NSMutableArray<WCTValue*>*) [self.database getColumnOnResultColumn:TestCaseObject.identifier fromTable:self.tableName];\n    }\n    tearDown:^{\n        [self tearDownDatabase];\n    }\n    checkCorrectness:nil];\n}\n\n- (void)doTestRandomDelete\n{\n    __block NSMutableArray<WCTValue*>* identifiers;\n    [self\n    doMeasure:^{\n        int index = 0;\n        for (int i = 1; i <= self.testQuality; i++) {\n            index = [[Random shared] uint32] % identifiers.count;\n            TestCaseAssertTrue([self.database deleteFromTable:self.tableName where:TestCaseObject.identifier == identifiers[index].numberValue.intValue]);\n            [identifiers removeObjectAtIndex:index];\n        }\n    }\n    setUp:^{\n        [self setUpDatabase];\n        identifiers = (NSMutableArray<WCTValue*>*) [self.database getColumnOnResultColumn:TestCaseObject.identifier fromTable:self.tableName];\n    }\n    tearDown:^{\n        [self tearDownDatabase];\n    }\n    checkCorrectness:^{\n        WCTValue* count = [self.database getValueOnResultColumn:WCDB::Column::all().count() fromTable:self.tableName];\n        TestCaseAssertTrue(count.numberValue.intValue == self.factory.quality - self.testQuality);\n    }];\n}\n\n@end\n"
  },
  {
    "path": "src/objc/tests/benchmark/RetrieveBenchmark.mm",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"SizeBasedFactory.h\"\n#import \"TestCase.h\"\n\n@interface RetrieveBenchmark : Benchmark\n\n@end\n\n@implementation RetrieveBenchmark {\n    SizeBasedFactory* _factory;\n    NSData* _cipherKey;\n}\n\n- (SizeBasedFactory*)factory\n{\n    @synchronized(self) {\n        if (_factory == nil) {\n            _factory = [[SizeBasedFactory alloc] initWithDirectory:self.class.cacheRoot];\n        }\n        return _factory;\n    }\n}\n\n- (NSData*)cipherKey\n{\n    @synchronized(self) {\n        if (_cipherKey.length == 0) {\n            _cipherKey = Random.shared.data;\n        }\n        return _cipherKey;\n    }\n}\n\n- (void)setUp\n{\n    [super setUp];\n\n    self.factory.needCipher = NO;\n    [self.database setCipherKey:nil];\n    self.factory.quality = 100 * 1024 * 1024;\n    self.factory.tolerance = 0.02;\n}\n\n- (void)setUpDatabase\n{\n    TestCaseAssertTrue([self.database removeFiles]);\n    [self.factory produce:self.path];\n}\n\n- (void)tearDownDatabase\n{\n    TestCaseAssertTrue([self.database removeFiles]);\n}\n\n- (void)test_backup\n{\n    __block BOOL result;\n    [self\n    doMeasure:^{\n        result = [self.database backup];\n    }\n    setUp:^{\n        [self setUpDatabase];\n    }\n    tearDown:^{\n        [self tearDownDatabase];\n        result = NO;\n    }\n    checkCorrectness:^{\n        TestCaseAssertTrue(result);\n        TestCaseAssertTrue([self.fileManager fileExistsAtPath:self.database.firstMaterialPath]);\n    }];\n}\n\n- (void)test_cipher_backup\n{\n    __block BOOL result;\n    [self.database setCipherKey:SizeBasedFactory.commonCipherKey];\n    self.factory.needCipher = YES;\n    [self\n    doMeasure:^{\n        result = [self.database backup];\n    }\n    setUp:^{\n        [self setUpDatabase];\n    }\n    tearDown:^{\n        [self tearDownDatabase];\n        result = NO;\n    }\n    checkCorrectness:^{\n        TestCaseAssertTrue(result);\n        TestCaseAssertTrue([self.fileManager fileExistsAtPath:self.database.firstMaterialPath]);\n    }];\n}\n\n- (void)test_retrieve\n{\n    __block double score;\n    [self\n    doMeasure:^{\n        score = [self.database retrieve:nil];\n    }\n    setUp:^{\n        [self setUpDatabase];\n        TestCaseAssertTrue([self.database backup]);\n    }\n    tearDown:^{\n        [self tearDownDatabase];\n        score = 0.0f;\n    }\n    checkCorrectness:^{\n        TestCaseAssertEqual(score, 1.0f);\n    }];\n}\n\n- (void)test_cipher_retrieve\n{\n    __block double score;\n    [self.database setCipherKey:SizeBasedFactory.commonCipherKey];\n    self.factory.needCipher = YES;\n    [self\n    doMeasure:^{\n        score = [self.database retrieve:nil];\n    }\n    setUp:^{\n        [self setUpDatabase];\n        TestCaseAssertTrue([self.database backup]);\n    }\n    tearDown:^{\n        [self tearDownDatabase];\n        score = 0.0f;\n    }\n    checkCorrectness:^{\n        TestCaseAssertEqual(score, 1.0f);\n    }];\n}\n\n- (void)test_retrieve_without_backup\n{\n    __block double score;\n    [self\n    doMeasure:^{\n        score = [self.database retrieve:nil];\n    }\n    setUp:^{\n        [self setUpDatabase];\n    }\n    tearDown:^{\n        [self tearDownDatabase];\n        score = 0.0f;\n    }\n    checkCorrectness:^{\n        TestCaseAssertEqual(score, 1.0f);\n    }];\n}\n\n- (void)test_ciper_retrieve_without_backup\n{\n    __block double score;\n    [self.database setCipherKey:SizeBasedFactory.commonCipherKey];\n    self.factory.needCipher = YES;\n    [self\n    doMeasure:^{\n        score = [self.database retrieve:nil];\n    }\n    setUp:^{\n        [self setUpDatabase];\n    }\n    tearDown:^{\n        [self tearDownDatabase];\n        score = 0.0f;\n    }\n    checkCorrectness:^{\n        TestCaseAssertEqual(score, 1.0f);\n    }];\n}\n\n@end\n"
  },
  {
    "path": "src/objc/tests/benchmark/TableBenchmark.mm",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"TablesBasedFactory.h\"\n#import \"TestCase.h\"\n\n@interface TableBenchmark : Benchmark\n@property (nonatomic, readonly) TablesBasedFactory* factory;\n@end\n\n@implementation TableBenchmark {\n    TablesBasedFactory* _factory;\n}\n\n- (TablesBasedFactory*)factory\n{\n    @synchronized(self) {\n        if (_factory == nil) {\n            _factory = [[TablesBasedFactory alloc] initWithDirectory:self.class.cacheRoot];\n        }\n        return _factory;\n    }\n}\n\n- (void)setUp\n{\n    [super setUp];\n\n    self.factory.tolerance = 0.0f;\n    self.factory.quality = 100000;\n}\n\n- (void)setUpDatabase\n{\n    TestCaseAssertTrue([self.database removeFiles]);\n    [self.factory produce:self.path];\n\n    [self.database close];\n    TestCaseAssertTrue([self.database canOpen]);\n}\n\n- (void)tearDownDatabase\n{\n    [self.database removeFiles];\n}\n\n- (void)test_initialization\n{\n    __block BOOL result;\n    [self\n    doMeasure:^{\n        result = [self.database canOpen];\n    }\n    setUp:^{\n        [self setUpDatabase];\n        [self.database close]; // reset cache\n    }\n    tearDown:^{\n        [self tearDownDatabase];\n        result = NO;\n    }\n    checkCorrectness:^{\n        TestCaseAssertTrue(result);\n    }];\n}\n\n- (void)test_exists\n{\n    __block NSArray<NSString*>* tableNames;\n    __block BOOL result;\n    [self\n    doMeasure:^{\n        result = YES;\n        for (NSString* tableName in tableNames) {\n            if (![self.database tableExists:tableName]) {\n                result = NO;\n                break;\n            }\n        }\n    }\n    setUp:^{\n        [self setUpDatabase];\n        if (tableNames == nil) {\n            NSString* sqlitePattern = [NSString stringWithFormat:@\"%s%%\", WCDB::Syntax::builtinTablePrefix.data()];\n            NSString* wcdbPattern = [NSString stringWithFormat:@\"%s%%\", WCDB::Syntax::builtinWCDBTablePrefix.data()];\n\n            NSMutableArray<NSString*>* names = [NSMutableArray arrayWithCapacity:(NSUInteger) self.factory.quality];\n            for (WCTValue* value in [self.database getColumnFromStatement:WCDB::StatementSelect().select(WCTMaster.name).from(WCTMaster.tableName).where(WCTMaster.name.notLike(sqlitePattern) && WCTMaster.name.notLike(wcdbPattern))]) {\n                [names addObject:value.stringValue];\n            }\n            tableNames = [NSArray arrayWithArray:names];\n        }\n        TestCaseAssertTrue(tableNames.count == self.factory.quality);\n    }\n    tearDown:^{\n        [self tearDownDatabase];\n        result = NO;\n    }\n    checkCorrectness:^{\n        TestCaseAssertTrue(result);\n    }];\n}\n\n- (void)test_create_tables\n{\n    int numberOfTables = 100;\n    __block NSArray* tableNames = nil;\n    __block BOOL result;\n    [self\n    doMeasure:^{\n        for (NSString* tableName in tableNames) {\n            if (![self.database createTable:tableName withClass:TestCaseObject.class]) {\n                result = NO;\n                return;\n            }\n        }\n        result = YES;\n    }\n    setUp:^{\n        [self setUpDatabase];\n\n        if (tableNames == nil) {\n            tableNames = [NSArray arrayWithArray:[Random.shared tableNamesWithCount:numberOfTables]];\n        }\n    }\n    tearDown:^{\n        [self tearDownDatabase];\n        result = NO;\n    }\n    checkCorrectness:^{\n        TestCaseAssertTrue(result);\n    }];\n}\n\n@end\n"
  },
  {
    "path": "src/objc/tests/benchmark/TableMigrationBenchmark.mm",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"MigrationBenchmark.h\"\n\n@interface TableMigrationBenchmark : MigrationBenchmark\n\n@end\n\n@implementation TableMigrationBenchmark\n\n- (void)setUp\n{\n    self.isCrossDatabase = NO;\n    [super setUp];\n}\n\n- (void)test_read\n{\n    [self doTestRead];\n}\n\n- (void)test_write\n{\n    [self doTestWrite];\n}\n\n- (void)test_batch_write\n{\n    [self doTestBatchWrite];\n}\n\n- (void)test_migrate\n{\n    [self doTestMigrate];\n}\n\n@end\n"
  },
  {
    "path": "src/objc/tests/benchmark/VacuumBenchmark.mm",
    "content": "//\n// Created by qiuwenchen on 2023/12/23.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"SizeBasedFactory.h\"\n#import \"TestCase.h\"\n#import <Foundation/Foundation.h>\n\n@interface VacuumBenchmark : Benchmark\n\n@end\n\n@implementation VacuumBenchmark {\n    SizeBasedFactory* _factory;\n    NSData* _cipherKey;\n}\n\n- (SizeBasedFactory*)factory\n{\n    @synchronized(self) {\n        if (_factory == nil) {\n            _factory = [[SizeBasedFactory alloc] initWithDirectory:self.class.cacheRoot];\n        }\n        return _factory;\n    }\n}\n\n- (NSData*)cipherKey\n{\n    @synchronized(self) {\n        if (_cipherKey.length == 0) {\n            _cipherKey = Random.shared.data;\n        }\n        return _cipherKey;\n    }\n}\n\n- (void)setUp\n{\n    [super setUp];\n\n    self.factory.needCipher = NO;\n    [self.database setCipherKey:nil];\n    self.factory.quality = 100 * 1024 * 1024;\n    self.factory.tolerance = 0.02;\n}\n\n- (void)setUpDatabase\n{\n    TestCaseAssertTrue([self.database removeFiles]);\n    [self.factory produce:self.path];\n}\n\n- (void)tearDownDatabase\n{\n    TestCaseAssertTrue([self.database removeFiles]);\n}\n\n- (void)test_vacuum\n{\n    __block BOOL result;\n    [self\n    doMeasure:^{\n        result = [self.database vacuum:nil];\n    }\n    setUp:^{\n        [self setUpDatabase];\n    }\n    tearDown:^{\n        [self tearDownDatabase];\n        result = NO;\n    }\n    checkCorrectness:^{\n        TestCaseAssertTrue(result);\n    }];\n}\n\n- (void)test_cipher_vacuum\n{\n    __block BOOL result;\n    [self.database setCipherKey:SizeBasedFactory.commonCipherKey];\n    self.factory.needCipher = YES;\n    [self\n    doMeasure:^{\n        result = [self.database vacuum:nil];\n    }\n    setUp:^{\n        [self setUpDatabase];\n    }\n    tearDown:^{\n        [self tearDownDatabase];\n        result = NO;\n    }\n    checkCorrectness:^{\n        TestCaseAssertTrue(result);\n    }];\n}\n\n- (void)test_normal_vacuum\n{\n    __block BOOL result;\n    [self\n    doMeasure:^{\n        result = [self.database execute:WCDB::StatementVacuum().vacuum()];\n    }\n    setUp:^{\n        [self setUpDatabase];\n    }\n    tearDown:^{\n        [self tearDownDatabase];\n        result = NO;\n    }\n    checkCorrectness:^{\n        TestCaseAssertTrue(result);\n    }];\n}\n\n- (void)test_normal_cipher_vacuum\n{\n    __block BOOL result;\n    [self.database setCipherKey:SizeBasedFactory.commonCipherKey];\n    self.factory.needCipher = YES;\n    [self\n    doMeasure:^{\n        result = [self.database execute:WCDB::StatementVacuum().vacuum()];\n    }\n    setUp:^{\n        [self setUpDatabase];\n    }\n    tearDown:^{\n        [self tearDownDatabase];\n        result = NO;\n    }\n    checkCorrectness:^{\n        TestCaseAssertTrue(result);\n    }];\n}\n@end\n"
  },
  {
    "path": "src/objc/tests/common/BaseTestCase.h",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import <XCTest/XCTest.h>\n\n@class Dispatch;\n@class Random;\n\n@interface BaseTestCase : XCTestCase\n\n@property (class, nonatomic, readonly) NSString* root;\n@property (class, nonatomic, readonly) NSString* cacheRoot;\n\n@property (nonatomic, readonly) NSString* cacheDirectory;\n@property (nonatomic, readonly) NSString* directory;\n\n@property (nonatomic, readonly) NSString* className;\n@property (nonatomic, readonly) NSString* testName;\n\n@property (nonatomic, readonly) NSFileManager* fileManager;\n@property (nonatomic, readonly) Random* random;\n\n@property (nonatomic, readonly) Dispatch* dispatch;\n\n@property (nonatomic, assign) BOOL skipDebugLog;\n\n- (void)log:(NSString*)format, ...;\n\n@end\n"
  },
  {
    "path": "src/objc/tests/common/BaseTestCase.mm",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"BaseTestCase.h\"\n#import \"Dispatch.h\"\n#import \"NSObject+TestCase.h\"\n#import \"PrototypeFactory.h\"\n#import \"Random.h\"\n#import \"TestCaseAssertion.h\"\n#import \"TestCaseLog.h\"\n#import \"WCTDatabase+TestCase.h\"\n#if TEST_WCDB_OBJC\n#import <WCDBOBjc/WCDBObjc.h>\n#elif TEST_WCDB_CPP\n#import <WCDBCpp/WCDBCpp.h>\n#else\n#import <WCDB/WCDBObjc.h>\n#endif\n#if TEST_WCDB_OBJC\n#import <WCDBOBjc/WCTDatabase+Test.h>\n#elif TEST_WCDB_CPP\n#import <WCDBCpp/WCTDatabase+Test.h>\n#else\n#import <WCDB/WCTDatabase+Test.h>\n#endif\n\n@implementation BaseTestCase {\n    Random *_random;\n    NSString *_className;\n    NSString *_testName;\n    NSString *_directory;\n    Dispatch *_dispatch;\n}\n\n+ (void)initialize\n{\n    if (self.class == BaseTestCase.class) {\n        TestCaseAssertTrue([NSThread isMainThread]);\n        pthread_setname_np(\"com.Tencent.WCDB.Main\");\n    }\n}\n\n+ (void)breakpoint\n{\n}\n\n- (void)setUp\n{\n    [super setUp];\n\n    self.continueAfterFailure = NO;\n\n    [Random shared].stable = NO;\n\n    [WCTDatabase globalTracePerformance:nil];\n    [WCTDatabase globalTraceSQL:nil];\n    [WCTDatabase globalTraceError:^(WCTError *error) {\n        NSThread *currentThread = [NSThread currentThread];\n        NSString *threadName = currentThread.name;\n        if (threadName.length == 0) {\n            threadName = [NSString stringWithFormat:@\"%p\", currentThread];\n        }\n        switch (error.level) {\n        case WCTErrorLevelIgnore:\n        case WCTErrorLevelDebug:\n            if (self.skipDebugLog) {\n                break;\n            }\n#ifndef DEBUG\n            break;\n#endif\n        case WCTErrorLevelNotice:\n            // passthrough\n        default:\n            TestCaseLog(@\"%@ Thread %@: %@\", currentThread.isMainThread ? @\"*\" : @\"-\", threadName, error);\n            break;\n        }\n\n        switch (error.level) {\n        case WCTErrorLevelError:\n            [self.class breakpoint];\n            break;\n        case WCTErrorLevelFatal:\n            abort();\n            break;\n        default:\n            break;\n        }\n    }];\n    [WCTDatabase simulateIOError:WCTSimulateNoneIOError];\n\n#if DEBUG\n    [self log:@\"debuggable.\"];\n#endif\n\n    NSString *directory = self.directory;\n    NSString *abbreviatedPath = directory.stringByAbbreviatingWithTildeInPath;\n    if (abbreviatedPath.length > 0) {\n        directory = abbreviatedPath;\n    }\n    [self log:@\"run at %@\", directory];\n\n    [self refreshDirectory];\n}\n\n- (void)tearDown\n{\n    [Random shared].stable = NO;\n\n    [self.dispatch waitUntilDone];\n\n    [WCTDatabase globalTraceError:nil];\n    [WCTDatabase globalTraceSQL:nil];\n    [WCTDatabase globalTracePerformance:nil];\n    [WCTDatabase simulateIOError:WCTSimulateNoneIOError];\n    [self cleanDirectory];\n    [super tearDown];\n}\n\n- (Random *)random\n{\n    return [Random shared];\n}\n\n- (NSString *)testName\n{\n    @synchronized(self) {\n        if (_testName == nil) {\n            NSString *name = self.name;\n            NSRegularExpression *regex = [NSRegularExpression regularExpressionWithPattern:@\"\\\\[\\\\w+ (\\\\w+).*\\\\]\" options:NSRegularExpressionCaseInsensitive error:nil];\n            NSTextCheckingResult *match = [regex firstMatchInString:name options:0 range:NSMakeRange(0, [name length])];\n            _testName = [name substringWithRange:[match rangeAtIndex:1]];\n        }\n        return _testName;\n    }\n}\n\n- (void)refreshDirectory\n{\n    [self cleanDirectory];\n    TestCaseAssertTrue([self.fileManager createDirectoryAtPath:self.directory\n                                   withIntermediateDirectories:YES\n                                                    attributes:nil\n                                                         error:nil]);\n}\n\n- (void)cleanDirectory\n{\n    if ([self.fileManager fileExistsAtPath:self.directory]) {\n        NSError *error;\n        TestCaseAssertTrue([self.fileManager removeItemAtPath:self.directory error:&error]);\n    }\n}\n\n- (NSString *)className\n{\n    @synchronized(self) {\n        if (_className == nil) {\n            _className = NSStringFromClass(self.class);\n        }\n        return _className;\n    }\n}\n\n+ (NSString *)root\n{\n    return [[[NSTemporaryDirectory() stringByAppendingPathComponent:@\"WCDB\"] stringByAppendingPathComponent:[NSBundle mainBundle].bundleIdentifier] test_stringByStandardizingPath];\n}\n\n+ (NSString *)cacheRoot\n{\n    return [[[NSTemporaryDirectory() stringByAppendingPathComponent:@\"WCDB\"] stringByAppendingPathComponent:[[NSBundle mainBundle].bundleIdentifier stringByAppendingString:@\".Cache\"]] test_stringByStandardizingPath];\n}\n\n- (NSString *)directory\n{\n    @synchronized(self) {\n        if (_directory == nil) {\n            _directory = [[self.class.root stringByAppendingPathComponent:self.className] stringByAppendingPathComponent:self.testName];\n        }\n        return _directory;\n    }\n}\n\n- (NSFileManager *)fileManager\n{\n    return [NSFileManager defaultManager];\n}\n\n- (Dispatch *)dispatch\n{\n    @synchronized(self) {\n        if (_dispatch == nil) {\n            _dispatch = [[Dispatch alloc] init];\n        }\n        return _dispatch;\n    }\n}\n\n- (void)log:(NSString *)format, ...\n{\n    va_list ap;\n    va_start(ap, format);\n    NSString *description = [[NSString alloc] initWithFormat:format arguments:ap];\n    va_end(ap);\n    NSString *log = [NSString stringWithFormat:@\"Test Case '%@' %@\", self.name, description];\n    TestCaseLog(@\"%@\", log);\n}\n\n@end\n"
  },
  {
    "path": "src/objc/tests/common/Benchmark.h",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"DatabaseTestCase.h\"\n\n@class Signpost;\n\n@interface Benchmark : DatabaseTestCase\n\n@property (nonatomic, readonly) Signpost* signpost;\n\n- (void)doMeasure:(void (^)(void))block\n            setUp:(void (^)(void))setUpBlock\n         tearDown:(void (^)(void))tearDownBlock\n checkCorrectness:(void (^)(void))correctnessBlock;\n\n@end\n\n#define BenchmarkSignpostBegin(task) \\\n    SignpostBegin(self.signpost, task)\n\n#define BenchmarkSignpostEnd(task) \\\n    SignpostEnd(self.signpost, task)\n\n#define BenchmarkFunctionSignpostBegin() \\\n    BenchmarkSignpostBegin(__PRETTY_FUNCTION__)\n\n#define BenchmarkFunctionSignpostEnd() \\\n    BenchmarkSignpostEnd(__PRETTY_FUNCTION__)\n"
  },
  {
    "path": "src/objc/tests/common/Benchmark.mm",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"Benchmark.h\"\n#import \"Random.h\"\n#import \"Signpost.h\"\n#import \"TestCaseLog.h\"\n#if TEST_WCDB_OBJC\n#import <WCDBOBjc/WCTDatabase+Test.h>\n#elif TEST_WCDB_CPP\n#import <WCDBCpp/WCTDatabase+Test.h>\n#else\n#import <WCDB/WCTDatabase+Test.h>\n#endif\n\n@implementation Benchmark {\n    Signpost *_signpost;\n}\n\n- (void)setUp\n{\n    [super setUp];\n\n    [Random shared].stable = YES;\n}\n\n- (void)doMeasure:(void (^)(void))block\n            setUp:(void (^)(void))setUpBlock\n         tearDown:(void (^)(void))tearDownBlock\n checkCorrectness:(void (^)(void))correctnessBlock\n{\n    __block int i = 1;\n    [self measureMetrics:self.class.defaultPerformanceMetrics\n    automaticallyStartMeasuring:false\n                       forBlock:^{\n                           if (tearDownBlock != nil) {\n                               tearDownBlock();\n                           }\n\n                           if (setUpBlock != nil) {\n                               setUpBlock();\n                           }\n\n                           if (@available(iOS 12.0, macOS 10.14, *)) {\n                               BenchmarkSignpostBegin(\"measure\");\n                           } else {\n                               [NSThread sleepForTimeInterval:0.5];\n                           }\n\n                           [self log:@\"%d started.\", i];\n\n                           [self startMeasuring];\n\n                           block();\n\n                           [self stopMeasuring];\n\n                           if (@available(iOS 12.0, macOS 10.14, *)) {\n                               BenchmarkSignpostEnd(\"measure\");\n                           } else {\n                               [NSThread sleepForTimeInterval:0.5];\n                           }\n\n                           [self log:@\"%d passed.\", i];\n\n                           if (correctnessBlock != nil) {\n                               correctnessBlock();\n                           }\n\n                           if (tearDownBlock != nil) {\n                               tearDownBlock();\n                           }\n\n                           ++i;\n                       }];\n\n#if DEBUG || TARGET_IPHONE_SIMULATOR\n    TestCaseLog(@\"Benchmark is run in debug mode or simulator. The result may be untrusted.\");\n#endif\n}\n\n- (Signpost *)signpost\n{\n    @synchronized(self) {\n        if (_signpost == nil) {\n            _signpost = [[Signpost alloc] initWithSystem:[NSBundle mainBundle].bundleIdentifier andCategory:self.className];\n        }\n        return _signpost;\n    }\n}\n\n@end\n"
  },
  {
    "path": "src/objc/tests/common/CRUDTestCase.h",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"TableTestCase.h\"\n#import \"TestCaseObject+WCTTableCoding.h\"\n#import \"TestCaseObject.h\"\n\n@interface CRUDTestCase : TableTestCase\n\n@property (nonatomic, readonly) TestCaseObject* object1;\n@property (nonatomic, readonly) TestCaseObject* object2;\n@property (nonatomic, readonly) NSArray<TestCaseObject*>* objects;\n- (void)insertPresetObjects;\n\n@end\n"
  },
  {
    "path": "src/objc/tests/common/CRUDTestCase.mm",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"CRUDTestCase.h\"\n#import \"Random+TestCaseObject.h\"\n#import \"Random.h\"\n#import \"TestCaseAssertion.h\"\n#if TEST_WCDB_OBJC\n#import <WCDBOBjc/WCTDatabase+Test.h>\n#elif TEST_WCDB_CPP\n#import <WCDBCpp/WCTDatabase+Test.h>\n#else\n#import <WCDB/WCTDatabase+Test.h>\n#endif\n\n@implementation CRUDTestCase {\n    TestCaseObject* _object1;\n    TestCaseObject* _object2;\n    NSArray<TestCaseObject*>* _objects;\n}\n\n- (TestCaseObject*)object1\n{\n    @synchronized(self) {\n        if (_object1 == nil) {\n            _object1 = [Random.shared testCaseObjectWithIdentifier:1];\n        }\n        return _object1;\n    }\n}\n\n- (TestCaseObject*)object2\n{\n    @synchronized(self) {\n        if (_object2 == nil) {\n            _object2 = [Random.shared testCaseObjectWithIdentifier:2];\n        }\n        return _object2;\n    }\n}\n\n- (NSArray<TestCaseObject*>*)objects\n{\n    @synchronized(self) {\n        if (_objects == nil) {\n            _objects = @[ self.object1, self.object2 ];\n        }\n        return _objects;\n    }\n}\n\n- (void)insertPresetObjects\n{\n    TestCaseAssertTrue([self createTable]);\n    TestCaseAssertTrue([self.table insertObjects:self.objects]);\n    [self.database close];\n}\n\n@end\n"
  },
  {
    "path": "src/objc/tests/common/DatabaseTestCase.h",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"BaseTestCase.h\"\n#import \"PrototypeFactory.h\"\n#if TEST_WCDB_OBJC\n#import <WCDBOBjc/WCDBObjc.h>\n#elif TEST_WCDB_CPP\n#import <WCDBCpp/WCDBCpp.h>\n#else\n#import <WCDB/WCDBObjc.h>\n#endif\n\ntypedef NS_ENUM(NSUInteger, DatabaseTestCaseExpect) {\n    DatabaseTestCaseExpectAllSQLs = 0,\n    DatabaseTestCaseExpectFirstFewSQLs,\n    DatabaseTestCaseExpectSomeSQLs,\n};\n\n@interface DatabaseTestCase : BaseTestCase\n\n#pragma mark - Path\n@property (nonatomic, retain) NSString* path;\n\n#pragma mark - Database\n@property (readonly, nonatomic) WCTDatabase* database;\n\n#pragma mark - SQL\n+ (void)enableSQLTrace;\n+ (void)disableSQLTrace;\n\n+ (void)enablePerformanceTrace;\n+ (void)disablePerformanceTrace;\n\n#pragma mark - Test\n@property (nonatomic, readonly) NSTimeInterval delayForTolerance;\n\n@property (nonatomic, assign) BOOL expectSQLsInAllThreads;\n@property (nonatomic, assign) DatabaseTestCaseExpect expectMode;\n@property (nonatomic, assign) BOOL skipFullSQLTrace;\n@property (nonatomic, assign) BOOL logSQL;\n\n- (void)doTestSQLs:(NSArray<NSString*>*)expectedSQLs\n       inOperation:(BOOL (^)())block;\n\n@end\n"
  },
  {
    "path": "src/objc/tests/common/DatabaseTestCase.mm",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"DatabaseTestCase.h\"\n#import \"NSObject+TestCase.h\"\n#import \"Random+WCDB.h\"\n#import \"Random.h\"\n#import \"TestCaseAssertion.h\"\n#import \"TestCaseLog.h\"\n#import \"TestCaseResult.h\"\n#if TEST_WCDB_OBJC\n#import <WCDBOBjc/WCTDatabase+Test.h>\n#elif TEST_WCDB_CPP\n#import <WCDBCpp/WCTDatabase+Test.h>\n#else\n#import <WCDB/WCTDatabase+Test.h>\n#endif\n\n@implementation DatabaseTestCase {\n    WCTDatabase* _database;\n    NSString* _path;\n}\n\n- (void)setUp\n{\n    [super setUp];\n\n    self.expectSQLsInAllThreads = NO;\n    self.expectMode = DatabaseTestCaseExpectAllSQLs;\n}\n\n- (void)tearDown\n{\n    [_database close];\n    _database = nil;\n    [super tearDown];\n}\n\n#pragma mark - Path\n- (void)setPath:(NSString*)path\n{\n    @synchronized(self) {\n        _path = path;\n        _database = nil;\n    }\n}\n\n- (NSString*)path\n{\n    @synchronized(self) {\n        if (_path == nil) {\n            _path = [self.directory stringByAppendingPathComponent:@\"testDatabase\"];\n        }\n        return _path;\n    }\n}\n\n#pragma mark - Database\n- (WCTDatabase*)database\n{\n    @synchronized(self) {\n        if (_database == nil) {\n            _database = [[WCTDatabase alloc] initWithPath:self.path];\n            _database.tag = Random.shared.tag;\n        }\n        return _database;\n    }\n}\n\n#pragma mark - SQL\n// For debugging only\n+ (void)enableSQLTrace\n{\n    [WCTDatabase globalTraceSQL:^(WCTTag, NSString*, UInt64, NSString* sql, NSString*) {\n        NSThread* currentThread = [NSThread currentThread];\n        NSString* threadName = currentThread.name;\n        if (threadName.length == 0) {\n            threadName = [NSString stringWithFormat:@\"%p\", currentThread];\n        }\n        TestCaseLog(@\"%@ Thread %@: %@\", currentThread.isMainThread ? @\"*\" : @\"-\", threadName, sql);\n    }];\n}\n\n+ (void)disableSQLTrace\n{\n    [WCTDatabase globalTraceSQL:nil];\n}\n\n+ (void)enablePerformanceTrace\n{\n    [WCTDatabase globalTracePerformance:^(WCTTag, NSString*, UInt64, NSString* sql, WCTPerformanceInfo* info) {\n        NSThread* currentThread = [NSThread currentThread];\n        NSString* threadName = currentThread.name;\n        if (threadName.length == 0) {\n            threadName = [NSString stringWithFormat:@\"%p\", currentThread];\n        }\n        NSString* description = [NSString stringWithFormat:@\"%@\", sql];\n        TestCaseLog(@\"%@ Thread %@: %@ %.2f\", currentThread.isMainThread ? @\"*\" : @\"-\", threadName, description, ((double) info.costInNanoseconds) / 1e9);\n    }];\n}\n\n+ (void)disablePerformanceTrace\n{\n    [WCTDatabase globalTracePerformance:nil];\n}\n\n#pragma mark - Test\n- (void)doTestSQLs:(NSArray<NSString*>*)testSQLs inOperation:(BOOL (^)())block\n{\n    TestCaseAssertTrue(testSQLs != nil);\n    TestCaseAssertTrue(block != nil);\n    TestCaseAssertTrue([testSQLs isKindOfClass:NSArray.class]);\n    do {\n        TestCaseResult* trace = [TestCaseResult no];\n        NSMutableArray<NSString*>* expectedSQLs = [NSMutableArray arrayWithArray:testSQLs];\n        NSThread* tracedThread = [NSThread currentThread];\n        [self.database enableFullSQLTrace:!_skipFullSQLTrace];\n        [self.database traceSQL:^(WCTTag, NSString*, UInt64, NSString* sql, NSString* info) {\n            if (!self.expectSQLsInAllThreads && tracedThread != [NSThread currentThread]) {\n                // skip other thread sqls due to the setting\n                return;\n            }\n            if (trace.isNO) {\n                return;\n            }\n            @synchronized(expectedSQLs) {\n                [self checkInfo:info withSQL:sql];\n                [self doTestSQLAsExpected:expectedSQLs sql:sql];\n                if (self.logSQL) {\n                    [self log:sql];\n                }\n            }\n        }];\n        if (self.expectMode != DatabaseTestCaseExpectSomeSQLs) {\n            if (![self.database canOpen]) {\n                TestCaseFailure();\n                break;\n            }\n        }\n\n        [trace makeYES];\n        @autoreleasepool {\n            if (!block()) {\n                TestCaseFailure();\n                break;\n            }\n        }\n        @synchronized(expectedSQLs) {\n            if (expectedSQLs.count != 0) {\n                TestCaseLog(@\"Reminding: %@\", expectedSQLs);\n                TestCaseFailure();\n                break;\n            }\n        }\n        [trace makeNO];\n        [self.database enableFullSQLTrace:NO];\n    } while (false);\n    [self.database traceSQL:nil];\n}\n\n- (void)checkInfo:(NSString*)info withSQL:(NSString*)sql\n{\n    if (_skipFullSQLTrace) {\n        XCTAssertNil(info);\n        return;\n    }\n    NSArray* components = [info componentsSeparatedByString:@\";\"];\n    if (components.count > 2) {\n        for (int i = 0; i < components.count - 2; i++) {\n            NSArray* subComponents = [[components objectAtIndex:i] componentsSeparatedByString:@\":\"];\n            XCTAssertTrue(subComponents.count > 1);\n            XCTAssertTrue([subComponents.firstObject intValue] > 0);\n        }\n    }\n    if ([sql hasPrefix:@\"INSERT\"]) {\n        XCTAssertTrue(components.count > 1);\n        NSArray* subComponents = [[components objectAtIndex:components.count - 1] componentsSeparatedByString:@\":\"];\n        XCTAssertEqual(subComponents.count, 2);\n        XCTAssertTrue([subComponents[0] isEqualToString:@\"LastInsertedId\"]);\n        XCTAssertTrue([subComponents[1] intValue] >= 0);\n    } else if ([sql hasPrefix:@\"SELECT\"]) {\n        XCTAssertTrue(components.count > 0);\n        NSArray* subComponents = [[components objectAtIndex:components.count - 1] componentsSeparatedByString:@\":\"];\n        XCTAssertEqual(subComponents.count, 2);\n        XCTAssertTrue([subComponents[0] isEqualToString:@\"RowCount\"]);\n        XCTAssertTrue([subComponents[1] intValue] >= 0);\n    } else if ([sql hasPrefix:@\"DELETE\"] || [sql hasPrefix:@\"UPDATE\"]) {\n        XCTAssertTrue(components.count > 0);\n        NSArray* subComponents = [[components objectAtIndex:components.count - 1] componentsSeparatedByString:@\":\"];\n        XCTAssertEqual(subComponents.count, 2);\n        XCTAssertTrue([subComponents[0] isEqualToString:@\"Changes\"]);\n        XCTAssertTrue([subComponents[1] intValue] >= 0);\n    }\n}\n\n- (void)doTestSQLAsExpected:(NSMutableArray<NSString*>*)expectedSQLs sql:(NSString*)sql\n{\n    switch (self.expectMode) {\n    case DatabaseTestCaseExpectAllSQLs:\n        if ([expectedSQLs.firstObject isEqualToString:sql]) {\n            [expectedSQLs removeObjectAtIndex:0];\n        } else {\n            TestCaseAssertStringEqual(expectedSQLs.firstObject, sql);\n        }\n        break;\n    case DatabaseTestCaseExpectFirstFewSQLs:\n        if ([expectedSQLs.firstObject isEqualToString:sql]) {\n            [expectedSQLs removeObjectAtIndex:0];\n        } else if (expectedSQLs.count != 0) {\n            TestCaseAssertStringEqual(expectedSQLs.firstObject, sql);\n        }\n        break;\n    case DatabaseTestCaseExpectSomeSQLs:\n        for (NSUInteger i = 0; i < expectedSQLs.count; ++i) {\n            if ([expectedSQLs[i] isEqualToString:sql]) {\n                [expectedSQLs removeObjectAtIndex:i];\n                break;\n            }\n        }\n        break;\n    }\n}\n\n- (NSTimeInterval)delayForTolerance\n{\n    return 2;\n}\n\n@end\n"
  },
  {
    "path": "src/objc/tests/common/RobustyTestCase.h",
    "content": "//\n// Created by qiuwenchen on 2023/12/20.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"DatabaseTestCase.h\"\n#import \"TestCaseObject.h\"\n\n@interface RobustyTestCase : DatabaseTestCase\n@property (nonatomic, assign) NSInteger expectedDatabaseSize;\n@property (nonatomic, assign) NSInteger tableFactor;\n@property (nonatomic, readonly) NSString* tablePrefix;\n@property (nonatomic, readonly) NSArray<NSString*>* allTables;\n\n- (BOOL)fillDatabaseUntilMeetExpectedSize;\n- (NSDictionary<NSString*, NSArray<TestCaseObject*>*>*)getTableObjects;\n\n@end\n"
  },
  {
    "path": "src/objc/tests/common/RobustyTestCase.mm",
    "content": "//\n// Created by qiuwenchen on 2023/12/20.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"RobustyTestCase.h\"\n#import \"TestCase.h\"\n#import <Foundation/Foundation.h>\n\n@interface RobustyTestCase () {\n    NSArray<NSString*>* m_tables;\n}\n@end\n\n@implementation RobustyTestCase\n\n- (void)setUp\n{\n    [super setUp];\n    self.tableFactor = 1000;\n}\n\n- (NSArray<NSString*>*)allTables\n{\n    return m_tables;\n}\n\n- (NSString*)tablePrefix\n{\n    return @\"t_\";\n}\n\n- (BOOL)fillDatabaseUntilMeetExpectedSize\n{\n    NSString* currentTable = nil;\n    BOOL checkpointed = NO; // leave wal exists\n    NSMutableArray* tables = [[NSMutableArray alloc] init];\n    while (checkpointed || [self.database getFilesSize] < self.expectedDatabaseSize) {\n        @autoreleasepool {\n            if (currentTable == nil || Random.shared.uint16 % self.tableFactor == 0) {\n                currentTable = [Random.shared tableNameWithPrefix:self.tablePrefix];\n                if (![self.database createTable:currentTable withClass:TestCaseObject.class]) {\n                    TestCaseFailure();\n                    return NO;\n                }\n                [tables addObject:currentTable];\n            }\n\n            int count = 0;\n            do {\n                count = Random.shared.uint8;\n            } while (count == 0);\n            NSArray<TestCaseObject*>* objects = [Random.shared autoIncrementTestCaseObjectsWithCount:count];\n            if (![self.database insertObjects:objects intoTable:currentTable]) {\n                TestCaseFailure();\n                return NO;\n            }\n            if (Random.shared.uint8 % 100 == 0) {\n                if (![self.database passiveCheckpoint]) {\n                    TestCaseFailure();\n                    return NO;\n                }\n                checkpointed = YES;\n            } else {\n                checkpointed = NO;\n            }\n        }\n    }\n    if (![self.fileManager fileExistsAtPath:self.database.walPath]) {\n        TestCaseFailure();\n        return NO;\n    }\n    m_tables = tables;\n    return YES;\n}\n\n- (NSDictionary<NSString*, NSArray<TestCaseObject*>*>*)getTableObjects\n{\n    NSMutableDictionary<NSString*, NSArray<TestCaseObject*>*>* tableObjects = [NSMutableDictionary<NSString*, NSArray<TestCaseObject*>*> dictionary];\n    for (NSString* tableName in m_tables) {\n        @autoreleasepool {\n            NSArray<TestCaseObject*>* objects = [self.database getObjectsOfClass:TestCaseObject.class fromTable:tableName];\n            if (objects != nil) {\n                [tableObjects setObject:objects forKey:tableName];\n            }\n        }\n    }\n    return tableObjects;\n}\n\n@end\n"
  },
  {
    "path": "src/objc/tests/common/TableTestCase.h",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"DatabaseTestCase.h\"\n\n@interface TableTestCase : DatabaseTestCase\n\n@property (nonatomic, retain) WCTTable* table;\n@property (nonatomic, retain) NSString* tableName;\n@property (nonatomic, retain) Class tableClass;\n\n@property (nonatomic, assign) BOOL isVirtualTable;\n- (BOOL)createTable;\n- (BOOL)dropTable;\n\n- (void)doTestObject:(NSObject<WCTTableCoding>*)object\n              andSQL:(NSString*)sql\n   afterModification:(BOOL (^)())block;\n\n- (void)doTestObjects:(NSArray<NSObject<WCTTableCoding>*>*)objects\n               andSQL:(NSString*)sql\n    afterModification:(BOOL (^)())block;\n\n- (void)doTestObjects:(NSArray<NSObject<WCTTableCoding>*>*)objects\n              andSQLs:(NSArray<NSString*>*)sqls\n    afterModification:(BOOL (^)())block;\n\n- (void)doTestObjects:(NSArray<NSObject<WCTTableCoding>*>*)objects\n            andNumber:(int)numberOfInsertSQLs\n         ofInsertSQLs:(NSString*)insertSQL\n       afterInsertion:(BOOL (^)())block;\n\n- (void)doTestObject:(NSObject<WCTTableCoding>*)object\n              andSQL:(NSString*)sql\n         bySelecting:(NSArray<NSObject<WCTTableCoding>*>* (^)())block;\n\n- (void)doTestObjects:(NSArray<NSObject<WCTTableCoding>*>*)objects\n               andSQL:(NSString*)sql\n          bySelecting:(NSArray<NSObject<WCTTableCoding>*>* (^)())block;\n\n- (void)doTestObjects:(NSArray<NSObject<WCTTableCoding>*>*)expectedObjects\n              andSQLs:(NSArray<NSString*>*)expectedSQLs\n          bySelecting:(NSArray<NSObject<WCTTableCoding>*>* (^)())block;\n\n- (void)doTestRow:(WCTOneRow*)row\n           andSQL:(NSString*)sql\n      bySelecting:(WCTOneRow* (^)())block;\n\n- (void)doTestColumn:(WCTOneColumn*)column\n              andSQL:(NSString*)sql\n         bySelecting:(WCTOneColumn* (^)())block;\n\n- (void)doTestValue:(WCTValue*)value\n             andSQL:(NSString*)sql\n        bySelecting:(WCTValue* (^)())block;\n\n- (void)doTestRows:(WCTColumnsXRows*)rows\n            andSQL:(NSString*)sql\n       bySelecting:(WCTColumnsXRows* (^)())block;\n\n- (void)doTestRows:(WCTColumnsXRows*)rows\n           andSQLs:(NSArray<NSString*>*)sqls\n       bySelecting:(WCTColumnsXRows* (^)())block;\n\n- (NSArray<NSObject<WCTTableCoding>*>*)getAllObjects;\n\n@end\n"
  },
  {
    "path": "src/objc/tests/common/TableTestCase.mm",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"TableTestCase.h\"\n#import \"TestCaseAssertion.h\"\n#import \"TestCaseObject+WCTTableCoding.h\"\n#import \"TestCaseObject.h\"\n\n@implementation TableTestCase\n\n- (NSString*)tableName\n{\n    @synchronized(self) {\n        if (_tableName == nil) {\n            _tableName = @\"testTable\";\n        }\n        return _tableName;\n    }\n}\n\n- (Class)tableClass\n{\n    @synchronized(self) {\n        if (_tableClass == nil) {\n            _tableClass = TestCaseObject.class;\n        }\n        return _tableClass;\n    }\n}\n\n- (BOOL)createTable\n{\n    if (self.isVirtualTable) {\n        if (![self.database createVirtualTable:self.tableName withClass:self.tableClass]) {\n            return NO;\n        }\n    } else {\n        if (![self.database createTable:self.tableName withClass:self.tableClass]) {\n            return NO;\n        }\n    }\n    _table = [self.database getTable:self.tableName withClass:self.tableClass];\n    return YES;\n}\n\n- (BOOL)createVirtualTable\n{\n    if (![self.database createVirtualTable:self.tableName withClass:self.tableClass]) {\n        return NO;\n    }\n    _table = [self.database getTable:self.tableName withClass:self.tableClass];\n    return YES;\n}\n\n- (BOOL)dropTable\n{\n    BOOL result = YES;\n    if (_table != nil) {\n        result = [self.database dropTable:self.tableName];\n        _table = nil;\n    }\n    return result;\n}\n\n- (void)doTestObjects:(NSArray<NSObject<WCTTableCoding>*>*)objects\n            andNumber:(int)numberOfInsertSQLs\n         ofInsertSQLs:(NSString*)insertSQL\n       afterInsertion:(BOOL (^)())block\n{\n    TestCaseAssertTrue(numberOfInsertSQLs > 0);\n    TestCaseAssertTrue(insertSQL != nil);\n    NSMutableArray<NSString*>* sqls = [NSMutableArray array];\n    if (numberOfInsertSQLs > 1) {\n        [sqls addObject:@\"BEGIN IMMEDIATE\"];\n    }\n    for (int i = 0; i < numberOfInsertSQLs; ++i) {\n        [sqls addObject:insertSQL];\n    }\n    if (numberOfInsertSQLs > 1) {\n        [sqls addObject:@\"COMMIT\"];\n    }\n    [self doTestObjects:objects\n                andSQLs:sqls\n      afterModification:block];\n}\n\n- (void)doTestObject:(NSObject<WCTTableCoding>*)object\n              andSQL:(NSString*)sql\n   afterModification:(BOOL (^)())block\n{\n    TestCaseAssertTrue(object != nil);\n    TestCaseAssertTrue(sql != nil);\n    [self doTestObjects:@[ object ] andSQLs:@[ sql ] afterModification:block];\n}\n\n- (void)doTestObjects:(NSArray<NSObject<WCTTableCoding>*>*)objects\n               andSQL:(NSString*)sql\n    afterModification:(BOOL (^)())block\n{\n    TestCaseAssertTrue(sql != nil);\n    [self doTestObjects:objects andSQLs:@[ sql ] afterModification:block];\n}\n\n- (void)doTestObjects:(NSArray<NSObject<WCTTableCoding>*>*)expectedObjects\n              andSQLs:(NSArray<NSString*>*)expectedSQLs\n    afterModification:(BOOL (^)())block\n{\n    [self doTestSQLs:expectedSQLs inOperation:block];\n    NSArray<NSObject<WCTTableCoding>*>* allObjects = [self getAllObjects];\n    TestCaseAssertTrue([allObjects isEqualToArray:expectedObjects]);\n}\n\n- (void)doTestObject:(NSObject<WCTTableCoding>*)object\n              andSQL:(NSString*)sql\n         bySelecting:(NSArray<NSObject<WCTTableCoding>*>* (^)())block\n{\n    TestCaseAssertTrue(object != nil);\n    TestCaseAssertTrue(sql != nil);\n    [self doTestObjects:@[ object ] andSQLs:@[ sql ] bySelecting:block];\n}\n\n- (void)doTestObjects:(NSArray<NSObject<WCTTableCoding>*>*)objects\n               andSQL:(NSString*)sql\n          bySelecting:(NSArray<NSObject<WCTTableCoding>*>* (^)())block\n{\n    TestCaseAssertTrue(sql != nil);\n    [self doTestObjects:objects andSQLs:@[ sql ] bySelecting:block];\n}\n\n- (void)doTestObjects:(NSArray<NSObject<WCTTableCoding>*>*)expectedObjects\n              andSQLs:(NSArray<NSString*>*)expectedSQLs\n          bySelecting:(NSArray<NSObject<WCTTableCoding>*>* (^)())block\n{\n    __block NSArray<NSObject<WCTTableCoding>*>* selected;\n    [self doTestSQLs:expectedSQLs\n         inOperation:^BOOL {\n             selected = block();\n             return selected != nil;\n         }];\n    TestCaseAssertTrue([selected isKindOfClass:NSArray.class]);\n    TestCaseAssertTrue([selected isEqualToArray:expectedObjects]);\n}\n\n- (void)doTestRow:(WCTOneRow*)row\n           andSQL:(NSString*)sql\n      bySelecting:(WCTOneRow* (^)())block\n{\n    TestCaseAssertTrue(row != nil);\n    TestCaseAssertTrue(sql != nil);\n    [self doTestRows:@[ row ]\n             andSQLs:@[ sql ]\n         bySelecting:^WCTColumnsXRows* {\n             WCTOneRow* result = block();\n             if (result != nil) {\n                 return @[ result ];\n             }\n             return nil;\n         }];\n}\n\n- (void)doTestColumn:(WCTOneColumn*)column\n              andSQL:(NSString*)sql\n         bySelecting:(WCTOneColumn* (^)())block\n{\n    TestCaseAssertTrue(sql != nil);\n    TestCaseAssertTrue(column != nil);\n    NSMutableArray* rows = [NSMutableArray array];\n    for (WCTValue* value in column) {\n        [rows addObject:@[ value ]];\n    }\n    [self doTestRows:rows\n             andSQLs:@[ sql ]\n         bySelecting:^WCTColumnsXRows* {\n             WCTOneColumn* result = block();\n             if (result != nil) {\n                 NSMutableArray* results = [NSMutableArray array];\n                 for (WCTValue* value in column) {\n                     [results addObject:@[ value ]];\n                 }\n                 return results;\n             }\n             return nil;\n         }];\n}\n\n- (void)doTestValue:(WCTValue*)value\n             andSQL:(NSString*)sql\n        bySelecting:(WCTValue* (^)())block\n{\n    TestCaseAssertTrue(value != nil);\n    TestCaseAssertTrue(sql != nil);\n    [self doTestRows:@[ @[ value ] ]\n             andSQLs:@[ sql ]\n         bySelecting:^WCTColumnsXRows* {\n             WCTValue* result = block();\n             if (result != nil) {\n                 return @[ @[ result ] ];\n             }\n             return nil;\n         }];\n}\n\n- (void)doTestRows:(WCTColumnsXRows*)rows\n            andSQL:(NSString*)sql\n       bySelecting:(WCTColumnsXRows* (^)())block\n{\n    TestCaseAssertTrue(rows != nil);\n    TestCaseAssertTrue(sql != nil);\n    [self doTestRows:rows andSQLs:@[ sql ] bySelecting:block];\n}\n\n- (void)doTestRows:(WCTColumnsXRows*)expectedRows\n           andSQLs:(NSArray<NSString*>*)expectedSQLs\n       bySelecting:(WCTColumnsXRows* (^)())block\n{\n    __block WCTColumnsXRows* selected;\n    [self doTestSQLs:expectedSQLs\n         inOperation:^BOOL {\n             selected = block();\n             return selected != nil;\n         }];\n    TestCaseAssertTrue([selected isKindOfClass:NSArray.class]);\n    TestCaseAssertTrue([selected isEqualToArray:expectedRows]);\n}\n\n- (NSArray<NSObject<WCTTableCoding>*>*)getAllObjects\n{\n    return [self.table getObjects];\n}\n\n@end\n"
  },
  {
    "path": "src/objc/tests/common/TestCase.h",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"TestCaseAssertion.h\"\n#import \"TestCaseLog.h\"\n#import \"TestCaseMacro.h\"\n\n#import \"BaseTestCase.h\"\n#import \"Benchmark.h\"\n#import \"CRUDTestCase.h\"\n#import \"DatabaseTestCase.h\"\n#import \"RobustyTestCase.h\"\n#import \"TableTestCase.h\"\n\n#import \"Dispatch.h\"\n#import \"Random.h\"\n#import \"Signpost.h\"\n#import \"TestCaseCounter.h\"\n#import \"TestCaseResult.h\"\n\n#import \"Random+TestCaseObject.h\"\n#import \"Random+WCDB.h\"\n\n#import \"TestCaseObject+WCTTableCoding.h\"\n#import \"TestCaseObject.h\"\n\n#import \"AllTypesObject+WCTTableCoding.h\"\n#import \"AllTypesObject.h\"\n\n#import \"NSObject+TestCase.h\"\n\n#import \"ObjectsBasedFactory.h\"\n#import \"TablesBasedFactory.h\"\n\n#import \"WCTDatabase+TestCase.h\"\n#import <WCDB/WCTDatabase+Test.h>\n"
  },
  {
    "path": "src/objc/tests/common/factory/ObjectsBasedFactory.h",
    "content": "//\n// Created by sanhuazhang on 2019/07/05\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"PrototypeFactory.h\"\n#import <Foundation/Foundation.h>\n\n@interface ObjectsBasedFactory : PrototypeFactory <PrototypePreparation>\n\n@property (nonatomic, readonly) NSString* tableName;\n\n@property (nonatomic, strong) NSString* category;\n\n@end\n"
  },
  {
    "path": "src/objc/tests/common/factory/ObjectsBasedFactory.mm",
    "content": "//\n// Created by sanhuazhang on 2019/07/05\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"ObjectsBasedFactory.h\"\n#import \"Random+TestCaseObject.h\"\n#import \"Random+WCDB.h\"\n#import \"Random.h\"\n#import \"TestCaseAssertion.h\"\n#import \"TestCaseObject+WCTTableCoding.h\"\n\n@implementation ObjectsBasedFactory {\n    NSString* _tableName;\n}\n\n- (instancetype)initWithDirectory:(NSString*)directory\n{\n    if (self = [super initWithDirectory:directory]) {\n        self.delegate = self;\n    }\n    return self;\n}\n\n- (NSString*)tableName\n{\n    return @\"benchmark\";\n}\n\n- (void)preparePrototype:(WCTDatabase*)prototype currentQuality:(double)quality\n{\n    int maxNumberOfObjects = (int) self.quality;\n    int existingNumberOfObjects = (int) quality;\n    int numberOfObjects = (int) (self.quality * 0.1);\n    if (maxNumberOfObjects - existingNumberOfObjects < numberOfObjects) {\n        numberOfObjects = maxNumberOfObjects - existingNumberOfObjects;\n    }\n\n    if (existingNumberOfObjects == 0) {\n        TestCaseAssertTrue([prototype createTable:self.tableName withClass:TestCaseObject.class]);\n    }\n\n    NSArray* objects = [[Random shared] testCaseObjectsWithCount:(int) numberOfObjects startingFromIdentifier:(int) existingNumberOfObjects];\n    TestCaseAssertTrue([prototype insertObjects:objects intoTable:self.tableName]);\n}\n\n- (double)qualityOfPrototype:(WCTDatabase*)prototype\n{\n    if ([[NSFileManager defaultManager] fileExistsAtPath:prototype.path]) {\n        WCTValue* count = [prototype getValueOnResultColumn:TestCaseObject.allProperties.count() fromTable:self.tableName];\n        TestCaseAssertNotNil(count);\n        return count.numberValue.intValue;\n    }\n    return 0;\n}\n\n- (NSString*)categoryOfPrototype\n{\n    if (self.category.length > 0) {\n        return self.category;\n    } else {\n        return @\"objects\";\n    }\n}\n\n@end\n"
  },
  {
    "path": "src/objc/tests/common/factory/PrototypeFactory.h",
    "content": "//\n// Created by sanhuazhang on 2019/07/05\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import <Foundation/Foundation.h>\n\n@class WCTDatabase;\n\n@protocol PrototypePreparation <NSObject>\n@required\n- (void)preparePrototype:(WCTDatabase*)prototype currentQuality:(double)quality;\n- (double)qualityOfPrototype:(WCTDatabase*)prototype;\n- (NSString*)categoryOfPrototype;\n@optional\n- (void)configurePrototype:(WCTDatabase*)prototype;\n\n@end\n\n@interface PrototypeFactory : NSObject\n\n- (instancetype)init UNAVAILABLE_ATTRIBUTE;\n\n- (instancetype)initWithDirectory:(NSString*)directory;\n\n@property (nonatomic, retain) NSString* path;\n\n@property (nonatomic, readonly) WCTDatabase* database;\n\n@property (nonatomic, readonly) NSString* directory;\n\n@property (nonatomic, weak) id<PrototypePreparation> delegate;\n\n@property (nonatomic, assign) double tolerance;\n\n@property (nonatomic, assign) double quality;\n\n@property (nonatomic, assign) BOOL needCipher;\n\n+ (NSData*)commonCipherKey;\n\n- (void)produce:(NSString*)destination;\n\n- (void)removePrototype;\n\n@end\n"
  },
  {
    "path": "src/objc/tests/common/factory/PrototypeFactory.mm",
    "content": "//\n// Created by sanhuazhang on 2019/07/05\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"PrototypeFactory.h\"\n#import \"TestCase.h\"\n\n@interface PrototypeFactory ()\n@end\n\n@implementation PrototypeFactory {\n    WCTDatabase* _database;\n    NSString* _path;\n}\n\n+ (NSData*)commonCipherKey\n{\n    static NSData* g_cipherKey = Random.shared.data;\n    return g_cipherKey;\n}\n\n+ (void)tryCleanOldCipherDBAtDirectory:(NSString*)directory\n{\n    static NSMutableSet* g_cleanedOldDirectory = [[NSMutableSet alloc] init];\n    @synchronized(self) {\n        if (![g_cleanedOldDirectory containsObject:directory]) {\n            NSFileManager* mgr = [NSFileManager defaultManager];\n            NSString* cipherDirectory = [directory stringByAppendingPathComponent:@\"cipherPrototype\"];\n            NSArray* files = [mgr getAllFilesAtDirectory:cipherDirectory];\n            if (files.count > 0) {\n                [mgr setFileImmutable:NO ofItemsIfExistsAtPaths:files];\n                [mgr removeItemsIfExistsAtPaths:files];\n            }\n\n            [g_cleanedOldDirectory addObject:directory];\n        }\n    }\n}\n\n- (instancetype)initWithDirectory:(NSString*)directory\n{\n    if (self = [super init]) {\n        _directory = directory;\n    }\n    return self;\n}\n\n- (void)reset\n{\n    _path = nil;\n    _database = nil;\n}\n\n- (void)setDelegate:(id<PrototypePreparation>)delegate\n{\n    _delegate = delegate;\n    [self reset];\n}\n\n- (void)setQuality:(double)quality\n{\n    _quality = quality;\n    [self reset];\n}\n\n- (void)setNeedCipher:(BOOL)needCipher\n{\n    _needCipher = needCipher;\n    [PrototypeFactory tryCleanOldCipherDBAtDirectory:self.directory];\n    [self reset];\n}\n\n- (double)lowerQuality\n{\n    return self.quality * (1.0 - self.tolerance);\n}\n\n- (double)upperQuality\n{\n    return self.quality * (1.0 + self.tolerance);\n}\n\n- (NSString*)path\n{\n    @synchronized(self) {\n        if (_path == nil) {\n            NSString* fileName = [NSString stringWithFormat:@\"%@\", [NSNumber numberWithDouble:self.quality]];\n            _path = [[[self.directory stringByAppendingPathComponent:_needCipher ? @\"cipherPrototype\" : @\"prototype\"] stringByAppendingPathComponent:self.delegate.categoryOfPrototype] stringByAppendingPathComponent:fileName];\n        }\n        return _path;\n    }\n}\n\n- (WCTDatabase*)database\n{\n    @synchronized(self) {\n        if (_database == nil) {\n            _database = [[WCTDatabase alloc] initWithPath:self.path];\n            if (_needCipher) {\n                [_database setCipherKey:PrototypeFactory.commonCipherKey];\n            }\n            [self configurePrototype];\n        }\n        return _database;\n    }\n}\n\n- (void)removePrototype\n{\n    [[NSFileManager defaultManager] setFileImmutable:NO ofItemsIfExistsAtPaths:self.database.paths];\n    TestCaseAssertTrue([self.database removeFiles]);\n}\n\n- (BOOL)isExpired\n{\n    return ![[NSFileManager defaultManager] isFileImmutableOfItemAtPath:self.path]\n           || ![self isQualityTolerable:[self.delegate qualityOfPrototype:self.database]];\n}\n\n- (BOOL)isQualityTolerable:(double)quality\n{\n    return quality <= self.upperQuality && quality >= self.lowerQuality;\n}\n\n- (void)produce:(NSString*)destination\n{\n    TestCaseAssertNotNil(self.delegate);\n\n    if ([self isExpired]) {\n        TestCaseLog(@\"Prototype is expired\");\n        //        [self removePrototype];\n\n        [self prepare];\n    }\n    TestCaseLog(@\"Prototype at %@\", self.path);\n\n    [self shipping:destination];\n}\n\n- (void)shipping:(NSString*)destination\n{\n    NSFileManager* fileManager = [NSFileManager defaultManager];\n\n    TestCaseAssertOptionalEqual([self.database getNumberOfWalFrames], 0);\n    [fileManager removeItemIfExistsAtPath:self.database.shmPath];\n    [fileManager removeItemIfExistsAtPath:self.database.walPath];\n\n    // move to temp to avoid the production is immutable while test stops unexpectly.\n    NSString* tempPath = [[[fileManager temporaryDirectory] path] stringByAppendingPathComponent:@\"prototype.temp\"];\n    [fileManager setFileImmutable:NO ofItemsIfExistsAtPath:tempPath];\n    [fileManager removeItemIfExistsAtPath:tempPath];\n\n    [fileManager copyItemsIfExistsAtPath:self.path toPath:tempPath];\n    [fileManager setFileImmutable:NO ofItemsIfExistsAtPath:tempPath];\n\n    WCTDatabase* database = [[WCTDatabase alloc] initWithPath:destination];\n    TestCaseAssertTrue([database removeFiles]);\n    [fileManager copyItemsIfExistsAtPath:tempPath toPath:destination];\n\n    TestCaseLog(@\"Product at %@\", destination);\n}\n\n- (void)prepare\n{\n    double progress = 0;\n    double quality = 0;\n\n    id<PrototypePreparation> delegate = self.delegate;\n    TestCaseAssertNotNil(delegate);\n    quality = [delegate qualityOfPrototype:self.database];\n    while (quality < self.lowerQuality) {\n        @autoreleasepool {\n            [delegate preparePrototype:self.database currentQuality:quality];\n            quality = [delegate qualityOfPrototype:self.database];\n\n            // progress\n            double newProgress = quality / self.quality;\n            if (newProgress > 1.0f) {\n                newProgress = 1.0f;\n            }\n            if (newProgress - progress >= 0.01f) {\n                progress = newProgress;\n                TestCaseLog(@\"Preparing %.2f%%\", progress * 100.0f);\n            }\n        }\n    }\n\n    TestCaseAssertTrue(self.quality <= self.upperQuality);\n\n    TestCaseAssertTrue([self.database truncateCheckpoint]);\n\n    [[NSFileManager defaultManager] setFileImmutable:YES ofItemsIfExistsAtPath:self.path];\n}\n\n- (void)configurePrototype\n{\n    id<PrototypePreparation> delegate = self.delegate;\n    TestCaseAssertNotNil(delegate);\n\n    if ([delegate respondsToSelector:@selector(configurePrototype:)]) {\n        [delegate configurePrototype:self.database];\n    }\n}\n\n//- (void)willEndPreparing\n//{\n//    if (self.delegate && [self.delegate respondsToSelector:@selector(willEndPreparing:)]) {\n//        [self.delegate willEndPreparing:self.database];\n//    }\n//}\n\n@end\n"
  },
  {
    "path": "src/objc/tests/common/factory/SizeBasedFactory.h",
    "content": "//\n// Created by sanhuazhang on 2019/07/05\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"PrototypeFactory.h\"\n#import <Foundation/Foundation.h>\n\n@interface SizeBasedFactory : PrototypeFactory <PrototypePreparation>\n\n@end\n"
  },
  {
    "path": "src/objc/tests/common/factory/SizeBasedFactory.mm",
    "content": "//\n// Created by sanhuazhang on 2019/07/05\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"SizeBasedFactory.h\"\n#import \"NSObject+TestCase.h\"\n#import \"Random+TestCaseObject.h\"\n#import \"Random+WCDB.h\"\n#import \"Random.h\"\n#import \"TestCaseAssertion.h\"\n#import \"TestCaseObject+WCTTableCoding.h\"\n#import \"TestCaseObject.h\"\n#import \"WCTDatabase+Test.h\"\n#import \"WCTDatabase+TestCase.h\"\n#if TEST_WCDB_OBJC\n#import <WCDBOBjc/WCDBObjc.h>\n#elif TEST_WCDB_CPP\n#import <WCDBCpp/WCDBCpp.h>\n#else\n#import <WCDB/WCDBObjc.h>\n#endif\n\n@implementation SizeBasedFactory\n\n- (instancetype)initWithDirectory:(NSString*)directory\n{\n    if (self = [super initWithDirectory:directory]) {\n        self.delegate = self;\n    }\n    return self;\n}\n\n- (void)preparePrototype:(WCTDatabase*)prototype currentQuality:(double)quality\n{\n    WCDB_UNUSED(quality);\n\n    int numberOfObjects = (int) (self.quality * self.tolerance / 4096.0);\n    if (numberOfObjects <= 0) {\n        numberOfObjects = 1;\n    }\n\n    NSArray* objects = [Random.shared testCaseObjectsWithCount:numberOfObjects startingFromIdentifier:0];\n    NSString* tableName = Random.shared.tableName;\n    TestCaseAssertTrue([prototype runTransaction:^BOOL(WCTHandle* handle) {\n        return [handle createTable:tableName withClass:TestCaseObject.class]\n               && [handle insertObjects:objects intoTable:tableName];\n    }]);\n}\n\n- (double)qualityOfPrototype:(WCTDatabase*)prototype\n{\n    NSFileManager* fileManager = [NSFileManager defaultManager];\n    if (Random.shared.uint8 % 4 == 0) {\n        TestCaseAssertTrue([prototype passiveCheckpoint]);\n    }\n    return [fileManager getFileSizeIfExists:prototype.path];\n}\n\n- (NSString*)categoryOfPrototype\n{\n    return @\"size\";\n}\n\n@end\n"
  },
  {
    "path": "src/objc/tests/common/factory/TablesBasedFactory.h",
    "content": "//\n// Created by sanhuazhang on 2019/07/05\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"PrototypeFactory.h\"\n#import <Foundation/Foundation.h>\n\n@interface TablesBasedFactory : PrototypeFactory <PrototypePreparation>\n\n@end\n"
  },
  {
    "path": "src/objc/tests/common/factory/TablesBasedFactory.mm",
    "content": "//\n// Created by sanhuazhang on 2019/07/05\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"TablesBasedFactory.h\"\n#import \"Random+TestCaseObject.h\"\n#import \"Random+WCDB.h\"\n#import \"Random.h\"\n#import \"TestCaseAssertion.h\"\n#import \"TestCaseObject.h\"\n#if TEST_WCDB_OBJC\n#import <WCDBOBjc/WCDBObjc.h>\n#elif TEST_WCDB_CPP\n#import <WCDBCpp/WCDBCpp.h>\n#else\n#import <WCDB/WCDBObjc.h>\n#endif\n\n@implementation TablesBasedFactory\n\n- (instancetype)initWithDirectory:(NSString*)directory\n{\n    if (self = [super initWithDirectory:directory]) {\n        self.delegate = self;\n    }\n    return self;\n}\n\n- (void)preparePrototype:(WCTDatabase*)prototype currentQuality:(double)quality\n{\n    int maxNumberOfTables = (int) self.quality;\n    int existingNumberOfTables = (int) quality;\n    int numberOfTables = (int) (self.quality * 0.05);\n    if (maxNumberOfTables - existingNumberOfTables < numberOfTables) {\n        numberOfTables = maxNumberOfTables - existingNumberOfTables;\n    }\n\n    for (int i = 0; i < numberOfTables; ++i) {\n        TestCaseAssertTrue([prototype createTable:Random.shared.tableName withClass:TestCaseObject.class]);\n    }\n}\n\n- (double)qualityOfPrototype:(WCTDatabase*)prototype\n{\n    if ([[NSFileManager defaultManager] fileExistsAtPath:prototype.path]) {\n        NSString* sqlitePattern = [NSString stringWithFormat:@\"%s%%\", WCDB::Syntax::builtinTablePrefix.data()];\n        NSString* wcdbPattern = [NSString stringWithFormat:@\"%s%%\", WCDB::Syntax::builtinWCDBTablePrefix.data()];\n\n        WCTValue* count = [prototype getValueOnResultColumn:WCTMaster.allProperties.count() fromTable:WCTMaster.tableName where:WCTMaster.name.notLike(sqlitePattern) && WCTMaster.name.notLike(wcdbPattern)];\n        TestCaseAssertNotNil(count);\n        return count.numberValue.intValue;\n    }\n    return 0;\n}\n\n- (NSString*)categoryOfPrototype\n{\n    return @\"tables\";\n}\n\n@end\n"
  },
  {
    "path": "src/objc/tests/common/object/AllTypesObject+WCTTableCoding.h",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"AllTypesObject.h\"\n#if TEST_WCDB_OBJC\n#import <WCDBOBjc/WCDBObjc.h>\n#elif TEST_WCDB_CPP\n#import <WCDBCpp/WCDBCpp.h>\n#else\n#import <WCDB/WCDBObjc.h>\n#endif\n\n@interface AllTypesObject (WCTTableCoding) <WCTTableCoding>\n\nWCDB_PROPERTY(type)\n\nWCDB_PROPERTY(intValue)\nWCDB_PROPERTY(unsignedIntValue)\nWCDB_PROPERTY(int32Value)\nWCDB_PROPERTY(int64Value)\nWCDB_PROPERTY(uint32Value)\nWCDB_PROPERTY(uint64Value)\nWCDB_PROPERTY(integerValue)\nWCDB_PROPERTY(uintegerValue)\n\nWCDB_PROPERTY(floatValue)\nWCDB_PROPERTY(doubleValue)\nWCDB_PROPERTY(numberValue)\nWCDB_PROPERTY(dateValue)\n\nWCDB_PROPERTY(stringValue)\n\nWCDB_PROPERTY(dataValue)\nWCDB_PROPERTY(codingValue)\n\n@end\n"
  },
  {
    "path": "src/objc/tests/common/object/AllTypesObject.h",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import <Foundation/Foundation.h>\n#import <string>\n\ntypedef NS_ENUM(NSInteger, EnumNSType) {\n    EnumNSTypeMin = std::numeric_limits<NSInteger>::min(),\n    EnumNSTypeZero = 0,\n    EnumNSTypeMax = std::numeric_limits<NSInteger>::max(),\n};\n\ntypedef NS_OPTIONS(NSInteger, OptionNSType) {\n    OptionNSTypeMin = std::numeric_limits<NSInteger>::min(),\n    OptionNSTypeZero = 0,\n    OptionNSTypeMax = std::numeric_limits<NSInteger>::max(),\n};\n\nenum EnumType {\n    Min = std::numeric_limits<int>::min(),\n    Zero = 0,\n    Max = std::numeric_limits<int>::max(),\n};\n\nenum class EnumClassType {\n    Min = std::numeric_limits<int>::min(),\n    Zero = 0,\n    Max = std::numeric_limits<int>::max(),\n};\n\ntypedef enum {\n    EnumMin = std::numeric_limits<int>::min(),\n    EnumZero = 0,\n    EnumMax = std::numeric_limits<int>::max(),\n} LiteralEnum;\n\n@interface AllTypesObject : NSObject\n\n@property (nonatomic, assign) NSString* type;\n\n// Enum\n@property (nonatomic, assign) EnumNSType enumNSValue;\n@property (nonatomic, assign) OptionNSType optionNSValue;\n@property (nonatomic, assign) EnumType enumValue;\n@property (nonatomic, assign) EnumClassType enumClassValue;\n@property (nonatomic, assign) LiteralEnum literalEnumValue;\n\n// Bool\n@property (nonatomic, assign) bool trueOrFalseValue;\n@property (nonatomic, assign) BOOL yesOrNoValue;\n\n// Integer\n@property (nonatomic, assign) int intValue;\n@property (nonatomic, assign) unsigned int unsignedIntValue;\n@property (nonatomic, assign) int32_t int32Value;\n@property (nonatomic, assign) int64_t int64Value;\n@property (nonatomic, assign) uint32_t uint32Value;\n@property (nonatomic, assign) uint64_t uint64Value;\n@property (nonatomic, assign) NSInteger integerValue;\n@property (nonatomic, assign) NSUInteger uintegerValue;\n\n// Float\n@property (nonatomic, assign) float floatValue;\n@property (nonatomic, assign) double doubleValue;\n@property (nonatomic, retain) NSNumber* numberValue;\n@property (nonatomic, retain) NSDate* dateValue;\n\n// String\n@property (nonatomic, retain) NSString* stringValue;\n\n// BLOB\n@property (nonatomic, retain) NSData* dataValue;\n@property (nonatomic, retain) NSURL* codingValue; // all other class based NSCoding\n\n// getter && setter\n@property (nonatomic, assign, getter=renamedGet, setter=renamedSet:) int renamedGSValue;\n\n+ (AllTypesObject*)maxObject;\n+ (AllTypesObject*)minObject;\n+ (AllTypesObject*)nilObject;\n+ (AllTypesObject*)emptyObject;\n\n@end\n"
  },
  {
    "path": "src/objc/tests/common/object/AllTypesObject.mm",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"AllTypesObject.h\"\n#import \"AllTypesObject+WCTTableCoding.h\"\n#import \"NSObject+TestCase.h\"\n#if TEST_WCDB_OBJC\n#import <WCDBOBjc/WCDBObjc.h>\n#elif TEST_WCDB_CPP\n#import <WCDBCpp/WCDBCpp.h>\n#else\n#import <WCDB/WCDBObjc.h>\n#endif\n\n@implementation AllTypesObject\n\nWCDB_IMPLEMENTATION(AllTypesObject)\n\nWCDB_SYNTHESIZE(type)\n\nWCDB_SYNTHESIZE(enumNSValue)\nWCDB_SYNTHESIZE(optionNSValue)\nWCDB_SYNTHESIZE(enumValue)\nWCDB_SYNTHESIZE(enumClassValue)\nWCDB_SYNTHESIZE(literalEnumValue)\n\nWCDB_SYNTHESIZE(trueOrFalseValue)\nWCDB_SYNTHESIZE(yesOrNoValue)\n\nWCDB_SYNTHESIZE(intValue)\nWCDB_SYNTHESIZE(unsignedIntValue)\nWCDB_SYNTHESIZE(int32Value)\nWCDB_SYNTHESIZE(int64Value)\nWCDB_SYNTHESIZE(uint32Value)\nWCDB_SYNTHESIZE(uint64Value)\nWCDB_SYNTHESIZE(integerValue)\nWCDB_SYNTHESIZE(uintegerValue)\n\nWCDB_SYNTHESIZE(floatValue)\nWCDB_SYNTHESIZE(doubleValue)\nWCDB_SYNTHESIZE(numberValue)\nWCDB_SYNTHESIZE(dateValue)\n\nWCDB_SYNTHESIZE(stringValue)\n\nWCDB_SYNTHESIZE(dataValue)\nWCDB_SYNTHESIZE(codingValue)\n\nWCDB_SYNTHESIZE(renamedGSValue)\n\nWCDB_PRIMARY(type)\n\n+ (AllTypesObject *)maxObject\n{\n    AllTypesObject *object = [[AllTypesObject alloc] init];\n    object.type = @\"max\";\n\n#define ASSIGN_WITH_TYPED_MAX_VALUE(property, type) \\\n    object.property = std::numeric_limits<type>::max()\n#define ASSIGN_WITH_MAX_VALUE(property) \\\n    ASSIGN_WITH_TYPED_MAX_VALUE(property, decltype(object.property))\n\n    object.enumNSValue = EnumNSTypeMax;\n    object.optionNSValue = OptionNSTypeMax;\n    object.enumValue = EnumType::Max;\n    object.enumClassValue = EnumClassType::Max;\n    object.literalEnumValue = LiteralEnum::EnumMax;\n\n    ASSIGN_WITH_MAX_VALUE(trueOrFalseValue);\n    object.yesOrNoValue = YES;\n\n    ASSIGN_WITH_MAX_VALUE(intValue);\n    ASSIGN_WITH_MAX_VALUE(unsignedIntValue);\n    ASSIGN_WITH_MAX_VALUE(int32Value);\n    ASSIGN_WITH_MAX_VALUE(int64Value);\n    ASSIGN_WITH_MAX_VALUE(uint32Value);\n    ASSIGN_WITH_MAX_VALUE(uint64Value);\n    ASSIGN_WITH_MAX_VALUE(integerValue);\n    ASSIGN_WITH_MAX_VALUE(uintegerValue);\n\n    ASSIGN_WITH_MAX_VALUE(floatValue);\n    ASSIGN_WITH_MAX_VALUE(doubleValue);\n    object.numberValue = [NSNumber numberWithDouble:std::numeric_limits<double>::max()];\n    object.dateValue = [NSDate dateWithTimeIntervalSince1970:std::numeric_limits<double>::max()];\n\n    object.stringValue = @\"\";\n\n    object.dataValue = [NSData data];\n    object.codingValue = [NSURL URLWithString:NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES)[0]];\n\n    ASSIGN_WITH_MAX_VALUE(renamedGSValue);\n\n    return object;\n}\n\n+ (AllTypesObject *)minObject\n{\n    AllTypesObject *object = [[AllTypesObject alloc] init];\n    object.type = @\"min\";\n\n#define ASSIGN_WITH_TYPED_MIN_VALUE(property, type) \\\n    object.property = std::numeric_limits<type>::min()\n#define ASSIGN_WITH_MIN_VALUE(property) ASSIGN_WITH_TYPED_MIN_VALUE(property, decltype(object.property))\n\n    object.enumNSValue = EnumNSTypeMin;\n    object.optionNSValue = OptionNSTypeMin;\n    object.enumValue = EnumType::Min;\n    object.enumClassValue = EnumClassType::Min;\n    object.literalEnumValue = LiteralEnum::EnumMin;\n\n    ASSIGN_WITH_MIN_VALUE(trueOrFalseValue);\n    object.yesOrNoValue = NO;\n\n    ASSIGN_WITH_MIN_VALUE(intValue);\n    ASSIGN_WITH_MIN_VALUE(unsignedIntValue);\n    ASSIGN_WITH_MIN_VALUE(int32Value);\n    ASSIGN_WITH_MIN_VALUE(int64Value);\n    ASSIGN_WITH_MIN_VALUE(uint32Value);\n    ASSIGN_WITH_MIN_VALUE(uint64Value);\n    ASSIGN_WITH_MIN_VALUE(integerValue);\n    ASSIGN_WITH_MIN_VALUE(uintegerValue);\n\n    ASSIGN_WITH_MIN_VALUE(floatValue);\n    ASSIGN_WITH_MIN_VALUE(doubleValue);\n    object.numberValue = [NSNumber numberWithDouble:std::numeric_limits<double>::min()];\n    object.dateValue = [NSDate dateWithTimeIntervalSince1970:std::numeric_limits<double>::min()];\n\n    object.stringValue = @\"\";\n\n    object.dataValue = [NSData data];\n    object.codingValue = [NSURL URLWithString:NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES)[0]];\n\n    ASSIGN_WITH_MIN_VALUE(renamedGSValue);\n\n    return object;\n}\n\n+ (AllTypesObject *)nilObject\n{\n    AllTypesObject *object = [[AllTypesObject alloc] init];\n    object.type = @\"nil\";\n\n    object.enumNSValue = EnumNSTypeZero;\n    object.optionNSValue = OptionNSTypeZero;\n    object.enumValue = EnumType::Zero;\n    object.enumClassValue = EnumClassType::Zero;\n    object.literalEnumValue = EnumZero;\n\n    object.trueOrFalseValue = false;\n    object.yesOrNoValue = NO;\n\n    object.intValue = 0;\n    object.unsignedIntValue = 0;\n    object.int32Value = 0;\n    object.int64Value = 0;\n    object.uint32Value = 0;\n    object.uint64Value = 0;\n    object.integerValue = 0;\n    object.uintegerValue = 0;\n\n    object.floatValue = 0;\n    object.doubleValue = 0;\n    object.numberValue = nil;\n    object.dateValue = nil;\n\n    object.stringValue = nil;\n\n    object.dataValue = nil;\n    object.codingValue = nil;\n\n    object.renamedGSValue = 0;\n\n    return object;\n}\n\n+ (AllTypesObject *)emptyObject\n{\n    AllTypesObject *object = [[AllTypesObject alloc] init];\n    object.type = @\"empty\";\n\n    object.enumNSValue = EnumNSTypeZero;\n    object.optionNSValue = OptionNSTypeZero;\n    object.enumValue = EnumType::Zero;\n    object.enumClassValue = EnumClassType::Zero;\n    object.literalEnumValue = EnumZero;\n\n    object.trueOrFalseValue = false;\n    object.yesOrNoValue = NO;\n\n    object.intValue = 0;\n    object.unsignedIntValue = 0;\n    object.int32Value = 0;\n    object.int64Value = 0;\n    object.uint32Value = 0;\n    object.uint64Value = 0;\n    object.integerValue = 0;\n    object.uintegerValue = 0;\n\n    object.floatValue = 0;\n    object.doubleValue = 0;\n    object.numberValue = @(0);\n    object.dateValue = [NSDate dateWithTimeIntervalSince1970:0];\n\n    object.stringValue = @\"\";\n\n    object.dataValue = [NSData data];\n    object.codingValue = [NSURL URLWithString:@\"\"];\n\n    object.renamedGSValue = 0;\n\n    return object;\n}\n\n- (BOOL)isEqual:(NSObject *)object\n{\n    if (object.class != self.class) {\n        return NO;\n    }\n    AllTypesObject *other = (AllTypesObject *) object;\n    return self.enumNSValue == other.enumNSValue\n           && self.optionNSValue == other.optionNSValue\n           && self.enumValue == other.enumValue\n           && self.enumClassValue == other.enumClassValue\n           && self.literalEnumValue == other.literalEnumValue\n           && self.trueOrFalseValue == other.trueOrFalseValue\n           && self.yesOrNoValue == other.yesOrNoValue\n           && self.intValue == other.intValue\n           && self.unsignedIntValue == other.unsignedIntValue\n           && self.int32Value == other.int32Value\n           && self.int64Value == other.int64Value\n           && self.uint32Value == other.uint32Value\n           && self.uint64Value == other.uint64Value\n           && self.integerValue == other.integerValue\n           && self.uintegerValue == other.uintegerValue\n           && self.floatValue == other.floatValue\n           && self.doubleValue == other.doubleValue\n           && [NSObject isObject:self.numberValue nilEqualToObject:other.numberValue]\n           && [NSObject isObject:self.dateValue nilEqualToObject:other.dateValue]\n           && [NSObject isObject:self.stringValue nilEqualToObject:other.stringValue]\n           && [NSObject isObject:self.dataValue nilEqualToObject:other.dataValue]\n           && [NSObject isObject:self.codingValue nilEqualToObject:other.codingValue]\n           && self.renamedGSValue == other.renamedGSValue;\n}\n\n@end\n"
  },
  {
    "path": "src/objc/tests/common/object/TestCaseObject+WCTTableCoding.h",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"TestCaseObject.h\"\n#if TEST_WCDB_OBJC\n#import <WCDBOBjc/WCDBObjc.h>\n#elif TEST_WCDB_CPP\n#import <WCDBCpp/WCDBCpp.h>\n#else\n#import <WCDB/WCDBObjc.h>\n#endif\n\n@interface TestCaseObject (WCTTableCoding) <WCTTableCoding>\n\nWCDB_PROPERTY(identifier)\nWCDB_PROPERTY(content)\n\n@end\n"
  },
  {
    "path": "src/objc/tests/common/object/TestCaseObject.h",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import <Foundation/Foundation.h>\n#if TEST_WCDB_OBJC\n#import <WCDBOBjc/WCDBObjc.h>\n#elif TEST_WCDB_CPP\n#import <WCDBCpp/WCDBCpp.h>\n#else\n#import <WCDB/WCDBObjc.h>\n#endif\n\n@interface TestCaseObject : NSObject\n\n@property (nonatomic, assign) int identifier;\n@property (nonatomic, retain) NSString *content;\nWCDB_PROPERTY(identifier);\nWCDB_PROPERTY(content);\n\n+ (instancetype)objectWithIdentifier:(int)identifier andContent:(NSString *)content;\n+ (instancetype)partialObjectWithIdentifier:(int)identifier;\n+ (instancetype)autoIncrementObjectWithContent:(NSString *)content;\n\n@end\n"
  },
  {
    "path": "src/objc/tests/common/object/TestCaseObject.mm",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"TestCaseObject.h\"\n#import \"NSObject+TestCase.h\"\n#import \"TestCaseObject+WCTTableCoding.h\"\n#if TEST_WCDB_OBJC\n#import <WCDBOBjc/WCDBObjc.h>\n#elif TEST_WCDB_CPP\n#import <WCDBCpp/WCDBCpp.h>\n#else\n#import <WCDB/WCDBObjc.h>\n#endif\n\n@implementation TestCaseObject\n\nWCDB_IMPLEMENTATION(TestCaseObject)\nWCDB_SYNTHESIZE(identifier)\nWCDB_SYNTHESIZE(content)\n\nWCDB_PRIMARY_ASC_AUTO_INCREMENT(identifier)\n@synthesize lastInsertedRowID;\n\n- (BOOL)isEqual:(NSObject*)object\n{\n    if (object.class != self.class) {\n        return NO;\n    }\n    TestCaseObject* other = (TestCaseObject*) object;\n    return self.identifier == other.identifier && [NSObject isObject:self.content nilEqualToObject:other.content];\n}\n\n- (NSUInteger)hash\n{\n    NSMutableData* data = [NSMutableData data];\n    [data appendBytes:&(_identifier) length:sizeof(_identifier)];\n    [data appendData:[_content dataUsingEncoding:NSUTF8StringEncoding]];\n    return data.hash;\n}\n\n+ (instancetype)objectWithIdentifier:(int)identifier andContent:(NSString*)content\n{\n    TestCaseObject* object = [[TestCaseObject alloc] init];\n    object.identifier = identifier;\n    object.content = content;\n    return object;\n}\n\n+ (instancetype)partialObjectWithIdentifier:(int)identifier\n{\n    return [self objectWithIdentifier:identifier andContent:nil];\n}\n\n+ (instancetype)autoIncrementObjectWithContent:(NSString*)content\n{\n    TestCaseObject* object = [self objectWithIdentifier:0 andContent:content];\n    object.isAutoIncrement = YES;\n    return object;\n}\n\n@end\n"
  },
  {
    "path": "src/objc/tests/common/random/Random+TestCaseObject.h",
    "content": "//\n// Created by sanhuazhang on 2019/07/05\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"Random.h\"\n#import \"TestCaseObject.h\"\n\n@interface Random (TestCaseObject)\n\n- (TestCaseObject *)testCaseObjectWithIdentifier:(int)identifier;\n\n- (TestCaseObject *)autoIncrementTestCaseObject;\n\n- (TestCaseObject *)autoIncrementTestCaseObjectWithIdentifier:(int)identifier;\n\n- (NSArray<TestCaseObject *> *)testCaseObjectsWithCount:(NSUInteger)count startingFromIdentifier:(int)identifier;\n\n- (NSArray<TestCaseObject *> *)autoIncrementTestCaseObjectsWithCount:(NSUInteger)count;\n\n@end\n"
  },
  {
    "path": "src/objc/tests/common/random/Random+TestCaseObject.mm",
    "content": "//\n// Created by sanhuazhang on 2019/07/05\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"Random+TestCaseObject.h\"\n#import \"TestCaseObject+WCTTableCoding.h\"\n\n@implementation Random (TestCaseObject)\n\n- (TestCaseObject*)testCaseObjectWithIdentifier:(int)identifier\n{\n    return [TestCaseObject objectWithIdentifier:identifier andContent:self.string];\n}\n\n- (TestCaseObject*)testCaseObjectWithAutoIncrement\n{\n    TestCaseObject* object = [TestCaseObject objectWithIdentifier:0 andContent:self.string];\n    object.isAutoIncrement = YES;\n    return object;\n}\n\n- (TestCaseObject*)autoIncrementTestCaseObject\n{\n    return [self autoIncrementTestCaseObjectWithIdentifier:0];\n}\n\n- (TestCaseObject*)autoIncrementTestCaseObjectWithIdentifier:(int)identifier\n{\n    TestCaseObject* object = [TestCaseObject objectWithIdentifier:identifier andContent:self.string];\n    object.isAutoIncrement = YES;\n    return object;\n}\n\n- (NSArray<TestCaseObject*>*)testCaseObjectsWithCount:(NSUInteger)count startingFromIdentifier:(int)identifier\n{\n    NSMutableArray<TestCaseObject*>* objects = [NSMutableArray arrayWithCapacity:count];\n    for (NSUInteger i = identifier; i < identifier + count; ++i) {\n        [objects addObject:[self testCaseObjectWithIdentifier:(int) i]];\n    }\n    return objects;\n}\n\n- (NSArray<TestCaseObject*>*)autoIncrementTestCaseObjectsWithCount:(NSUInteger)count\n{\n    NSMutableArray<TestCaseObject*>* objects = [NSMutableArray arrayWithCapacity:count];\n    for (NSUInteger i = 0; i < count; ++i) {\n        [objects addObject:[self autoIncrementTestCaseObject]];\n    }\n    return objects;\n}\n\n@end\n"
  },
  {
    "path": "src/objc/tests/common/random/Random+WCDB.h",
    "content": "//\n// Created by sanhuazhang on 2019/07/05\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"Random.h\"\n#if TEST_WCDB_OBJC\n#import <WCDBOBjc/WCDBObjc.h>\n#elif TEST_WCDB_CPP\n#import <WCDBCpp/WCDBCpp.h>\n#else\n#import <WCDB/WCDBObjc.h>\n#endif\n\n@interface Random (WCDB)\n\n- (long)tag;\n\n- (NSString *)tableName;\n\n- (NSString *)tableNameWithPrefix:(NSString *)prefix;\n\n- (NSArray<NSString *> *)tableNamesWithCount:(int)count;\n\n@end\n"
  },
  {
    "path": "src/objc/tests/common/random/Random+WCDB.mm",
    "content": "//\n// Created by sanhuazhang on 2019/07/05\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"Random+WCDB.h\"\n\n@implementation Random (WCDB)\n\n- (long)tag\n{\n    long tag;\n    do {\n        tag = self.int32;\n    } while (tag == 0);\n    return tag;\n}\n\n- (NSString *)tableName\n{\n    return [self tableNameWithPrefix:@\"t_\"];\n}\n\n- (NSString *)tableNameWithPrefix:(NSString *)prefix\n{\n    return [NSString stringWithFormat:@\"%@%@\", prefix, self.string];\n}\n\n- (NSArray<NSString *> *)tableNamesWithCount:(int)count\n{\n    NSMutableArray<NSString *> *tableNames = [NSMutableArray array];\n    for (int i = 0; i < count; ++i) {\n        [tableNames addObject:self.tableName];\n    }\n    return tableNames;\n}\n\n@end\n"
  },
  {
    "path": "src/objc/tests/common/random/Random.h",
    "content": "//\n// Created by sanhuazhang on 2019/07/05\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import <Foundation/Foundation.h>\n\ntypedef enum : NSUInteger {\n    RandomStringType_Default = 0,\n    RandomStringType_English,\n    RandomStringType_Chinese,\n} RandomStringType;\n\n@interface Random : NSObject\n\n+ (instancetype)shared;\n\n- (void)setStable:(BOOL)stable;\n- (void)setStringType:(RandomStringType)type;\n\n- (void)reset;\n\n- (uint64_t)uint64;\n- (uint32_t)uint32;\n- (uint16_t)uint16;\n- (uint8_t)uint8;\n\n- (int64_t)int64;\n- (int32_t)int32;\n- (int16_t)int16;\n- (int8_t)int8;\n\n- (double)double_;\n- (float)float_;\n- (float)float_0_1;\n\n- (BOOL)boolean;\n\n- (NSNumber *)number;\n\n- (NSString *)string;\n- (NSString *)stringWithLength:(UInt32)length;\n- (NSString *)chineseString;\n- (NSString *)chineseStringWithLength:(UInt32)length;\n- (NSString *)englishString;\n- (NSString *)englishStringWithLength:(UInt32)length;\n\n- (NSData *)data;\n- (NSData *)dataWithLength:(NSInteger)length;\n- (NSData *)dataOtherThan:(NSData *)other;\n\n- (NSDate *)date;\n\n@end\n"
  },
  {
    "path": "src/objc/tests/common/random/Random.mm",
    "content": "//\n// Created by sanhuazhang on 2019/07/05\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"Random.h\"\n#import <random>\n\n@implementation Random {\n    std::shared_ptr<std::default_random_engine> _unstableEngine;\n    std::shared_ptr<std::default_random_engine> _stableEngine;\n    std::shared_ptr<std::uniform_int_distribution<uint64_t>> _uniformUInt64;\n    std::shared_ptr<std::uniform_int_distribution<uint32_t>> _uniformUInt32;\n    std::shared_ptr<std::uniform_int_distribution<uint8_t>> _uniformUInt8;\n    std::shared_ptr<std::uniform_int_distribution<int8_t>> _uniformInt8;\n    std::shared_ptr<std::uniform_int_distribution<uint16_t>> _uniformUInt16;\n    std::shared_ptr<std::uniform_int_distribution<int16_t>> _uniformInt16;\n    std::shared_ptr<std::uniform_int_distribution<int64_t>> _uniformInt64;\n    std::shared_ptr<std::uniform_int_distribution<int32_t>> _uniformInt32;\n    std::shared_ptr<std::uniform_int_distribution<int8_t>> _uniformBool;\n    std::shared_ptr<std::uniform_real_distribution<double>> _uniformDouble;\n    std::shared_ptr<std::uniform_real_distribution<float>> _uniformFloat;\n    std::shared_ptr<std::uniform_real_distribution<float>> _uniformFloat_0_1;\n    std::shared_ptr<std::uniform_int_distribution<unsigned char>> _uniformUChar;\n    std::shared_ptr<std::uniform_int_distribution<int>> _uniformLength;\n    BOOL _stable;\n    RandomStringType _stringType;\n}\n\n+ (instancetype)shared\n{\n    static Random *s_random = [[Random alloc] init];\n    return s_random;\n}\n\n- (void)setStable:(BOOL)stable\n{\n    @synchronized(self) {\n        _stable = stable;\n    }\n}\n\n- (void)setStringType:(RandomStringType)type\n{\n    @synchronized(self) {\n        _stringType = type;\n    }\n}\n\n- (void)reset\n{\n    _stableEngine.reset();\n    _unstableEngine.reset();\n    _uniformUInt64.reset();\n    _uniformUInt32.reset();\n    _uniformUInt8.reset();\n    _uniformInt64.reset();\n    _uniformInt32.reset();\n    _uniformBool.reset();\n    _uniformDouble.reset();\n    _uniformFloat.reset();\n    _uniformFloat_0_1.reset();\n    _uniformUChar.reset();\n    _uniformUChar.reset();\n    _uniformLength.reset();\n}\n\n- (std::shared_ptr<std::default_random_engine> &)engine\n{\n    @synchronized(self) {\n        if (_stable) {\n            if (_stableEngine == nullptr) {\n                _stableEngine = std::make_shared<std::default_random_engine>(0);\n            }\n            return _stableEngine;\n        } else {\n            if (_unstableEngine == nullptr) {\n                std::random_device rd;\n                _unstableEngine = std::make_shared<std::default_random_engine>(rd());\n            }\n            return _unstableEngine;\n        }\n    }\n}\n- (std::shared_ptr<std::uniform_int_distribution<uint64_t>> &)uniformUInt64\n{\n    @synchronized(self) {\n        if (_uniformUInt64 == nullptr) {\n            _uniformUInt64 = std::make_shared<std::uniform_int_distribution<uint64_t>>(std::numeric_limits<uint64_t>::min(), std::numeric_limits<uint64_t>::max());\n        }\n        return _uniformUInt64;\n    }\n}\n- (std::shared_ptr<std::uniform_int_distribution<uint32_t>> &)uniformUInt32\n{\n    @synchronized(self) {\n        if (_uniformUInt32 == nullptr) {\n            _uniformUInt32 = std::make_shared<std::uniform_int_distribution<uint32_t>>(std::numeric_limits<uint32_t>::min(), std::numeric_limits<uint32_t>::max());\n        }\n        return _uniformUInt32;\n    }\n}\n- (std::shared_ptr<std::uniform_int_distribution<uint8_t>> &)uniformUInt8\n{\n    @synchronized(self) {\n        if (_uniformUInt8 == nullptr) {\n            _uniformUInt8 = std::make_shared<std::uniform_int_distribution<uint8_t>>(std::numeric_limits<uint8_t>::min(), std::numeric_limits<uint8_t>::max());\n        }\n        return _uniformUInt8;\n    }\n}\n- (std::shared_ptr<std::uniform_int_distribution<int8_t>> &)uniformInt8\n{\n    @synchronized(self) {\n        if (_uniformInt8 == nullptr) {\n            _uniformInt8 = std::make_shared<std::uniform_int_distribution<int8_t>>(std::numeric_limits<int8_t>::min(), std::numeric_limits<int8_t>::max());\n        }\n        return _uniformInt8;\n    }\n}\n- (std::shared_ptr<std::uniform_int_distribution<uint16_t>> &)uniformUInt16\n{\n    @synchronized(self) {\n        if (_uniformUInt16 == nullptr) {\n            _uniformUInt16 = std::make_shared<std::uniform_int_distribution<uint16_t>>(std::numeric_limits<uint16_t>::min(), std::numeric_limits<uint16_t>::max());\n        }\n        return _uniformUInt16;\n    }\n}\n- (std::shared_ptr<std::uniform_int_distribution<int16_t>> &)uniformInt16\n{\n    @synchronized(self) {\n        if (_uniformInt16 == nullptr) {\n            _uniformInt16 = std::make_shared<std::uniform_int_distribution<int16_t>>(std::numeric_limits<int16_t>::min(), std::numeric_limits<int16_t>::max());\n        }\n        return _uniformInt16;\n    }\n}\n- (std::shared_ptr<std::uniform_int_distribution<int64_t>> &)uniformInt64\n{\n    @synchronized(self) {\n        if (_uniformInt64 == nullptr) {\n            _uniformInt64 = std::make_shared<std::uniform_int_distribution<int64_t>>(std::numeric_limits<int64_t>::min(), std::numeric_limits<int64_t>::max());\n        }\n        return _uniformInt64;\n    }\n}\n- (std::shared_ptr<std::uniform_int_distribution<int32_t>> &)uniformInt32\n{\n    @synchronized(self) {\n        if (_uniformInt32 == nullptr) {\n            _uniformInt32 = std::make_shared<std::uniform_int_distribution<int32_t>>(std::numeric_limits<int32_t>::min(), std::numeric_limits<int32_t>::max());\n        }\n        return _uniformInt32;\n    }\n}\n- (std::shared_ptr<std::uniform_int_distribution<int8_t>> &)uniformBool\n{\n    @synchronized(self) {\n        if (_uniformBool == nullptr) {\n            _uniformBool = std::make_shared<std::uniform_int_distribution<int8_t>>(std::numeric_limits<bool>::min(), std::numeric_limits<bool>::max());\n        }\n        return _uniformBool;\n    }\n}\n- (std::shared_ptr<std::uniform_real_distribution<double>> &)uniformDouble\n{\n    @synchronized(self) {\n        if (_uniformDouble == nullptr) {\n            _uniformDouble = std::make_shared<std::uniform_real_distribution<double>>(std::numeric_limits<double>::min(), std::numeric_limits<double>::max());\n        }\n        return _uniformDouble;\n    }\n}\n- (std::shared_ptr<std::uniform_real_distribution<float>> &)uniformFloat\n{\n    @synchronized(self) {\n        if (_uniformFloat == nullptr) {\n            _uniformFloat = std::make_shared<std::uniform_real_distribution<float>>(std::numeric_limits<float>::min(), std::numeric_limits<float>::max());\n        }\n        return _uniformFloat;\n    }\n}\n- (std::shared_ptr<std::uniform_real_distribution<float>> &)uniformFloat_0_1\n{\n    @synchronized(self) {\n        if (_uniformFloat_0_1 == nullptr) {\n            _uniformFloat_0_1 = std::make_shared<std::uniform_real_distribution<float>>(0, 1);\n        }\n        return _uniformFloat_0_1;\n    }\n}\n- (std::shared_ptr<std::uniform_int_distribution<unsigned char>> &)uniformUChar\n{\n    @synchronized(self) {\n        if (_uniformUChar == nullptr) {\n            _uniformUChar = std::make_shared<std::uniform_int_distribution<unsigned char>>(std::numeric_limits<unsigned char>::min(), std::numeric_limits<unsigned char>::max());\n        }\n        return _uniformUChar;\n    }\n}\n\n- (std::shared_ptr<std::uniform_int_distribution<int>> &)uniformLength\n{\n    @synchronized(self) {\n        if (_uniformLength == nullptr) {\n            if (_stable) {\n                _uniformLength = std::make_shared<std::uniform_int_distribution<int>>(100, 100);\n            } else {\n                _uniformLength = std::make_shared<std::uniform_int_distribution<int>>(1, 100);\n            }\n        }\n        return _uniformLength;\n    }\n}\n\n- (uint64_t)uint64\n{\n    return (*self.uniformUInt64.get())(*self.engine.get());\n}\n\n- (uint32_t)uint32\n{\n    return (*self.uniformUInt32.get())(*self.engine.get());\n}\n\n- (uint8_t)uint8\n{\n    return (*self.uniformUInt8.get())(*self.engine.get());\n}\n\n- (int8_t)int8\n{\n    return (*self.uniformInt8.get())(*self.engine.get());\n}\n\n- (uint16_t)uint16\n{\n    return (*self.uniformUInt16.get())(*self.engine.get());\n}\n\n- (int16_t)int16\n{\n    return (*self.uniformInt16.get())(*self.engine.get());\n}\n\n- (int64_t)int64\n{\n    return (*self.uniformInt64.get())(*self.engine.get());\n}\n\n- (int32_t)int32\n{\n    return (*self.uniformInt32.get())(*self.engine.get());\n}\n\n- (double)double_\n{\n    return (*self.uniformDouble.get())(*self.engine.get());\n}\n\n- (float)float_\n{\n    return (*self.uniformFloat.get())(*self.engine.get());\n}\n\n- (float)float_0_1\n{\n    return (*self.uniformFloat_0_1.get())(*self.engine.get());\n}\n\n- (BOOL)boolean\n{\n    return (*self.uniformBool.get())(*self.engine.get());\n}\n\n- (NSNumber *)number\n{\n    switch (self.uint8 % 3) {\n    case 0:\n        return [NSNumber numberWithInt:self.int32];\n    case 1:\n        return [NSNumber numberWithLongLong:self.uint64];\n    case 2:\n        return [NSNumber numberWithDouble:self.double_];\n    }\n    return nil;\n}\n\n- (int)length\n{\n    return (*self.uniformLength.get())(*self.engine.get());\n}\n\n- (NSString *)string\n{\n    switch (_stringType) {\n    case RandomStringType_Default:\n        return [self stringWithLength:self.length];\n    case RandomStringType_English:\n        return [self englishStringWithLength:100];\n    case RandomStringType_Chinese:\n        return [self chineseStringWithLength:self.length];\n    }\n}\n\n- (NSString *)stringWithLength:(UInt32)length\n{\n    static const char alphanum[] =\n    \"0123456789\"\n    \"ABCDEFGHIJKLMNOPQRSTUVWXYZ\"\n    \"abcdefghijklmnopqrstuvwxyz\";\n    char result[std::numeric_limits<uint16_t>::max() + 1];\n    for (int i = 0; i < length; ++i) {\n        result[i] = alphanum[self.uint8 % (sizeof(alphanum) - 1)];\n    }\n    result[length] = '\\0';\n    return [NSString stringWithUTF8String:result];\n}\n\n- (NSString *)chineseString\n{\n    return [self chineseStringWithLength:self.length];\n}\n\n- (NSString *)chineseStringWithLength:(UInt32)length\n{\n    NSStringEncoding gbkEncoding = CFStringConvertEncodingToNSStringEncoding(kCFStringEncodingGB_18030_2000);\n    NSMutableString *string = [NSMutableString string];\n    for (int i = 0; i < length; i++) {\n        UInt8 randomH = 0xA1 + self.uint8 % (0xFE - 0xA1 + 1);\n        UInt8 randomL = 0xB0 + self.uint8 % (0xF7 - 0xB0 + 1);\n        UInt32 number = (randomH << 8) + randomL;\n        NSData *data = [NSData dataWithBytes:&number length:2];\n        [string appendString:[[NSString alloc] initWithData:data encoding:gbkEncoding]];\n    }\n    return string;\n}\n\n- (NSString *)englishString\n{\n    return [self englishStringWithLength:100];\n}\n\n- (NSString *)englishStringWithLength:(UInt32)length\n{\n    static NSArray<NSString *> *g_wordArray;\n    static dispatch_once_t onceToken;\n    dispatch_once(&onceToken, ^{\n        NSDictionary<NSString *, NSNumber *> *g_wordFrequency = @{\n            @\"a\" : @408,\n            @\"he\" : @121,\n            @\"but\" : @86,\n            @\"my\" : @58,\n            @\"if\" : @51,\n            @\"just\" : @44,\n            @\"people\" : @33,\n            @\"think\" : @28,\n            @\"because\" : @25,\n            @\"two\" : @21,\n            @\"very\" : @19,\n            @\"should\" : @17,\n            @\"work\" : @15,\n            @\"day\" : @14,\n            @\"oh\" : @13,\n            @\"use\" : @11,\n            @\"lot\" : @10,\n            @\"mr\" : @10,\n            @\"part\" : @9,\n            @\"without\" : @8,\n        };\n        NSMutableArray *wordArray = [[NSMutableArray alloc] initWithCapacity:1000];\n        [g_wordFrequency enumerateKeysAndObjectsUsingBlock:^(NSString *word, NSNumber *frequency, BOOL *) {\n            for (int i = 0; i < frequency.intValue; i++) {\n                [wordArray addObject:word];\n            }\n        }];\n        g_wordArray = wordArray;\n    });\n    NSMutableString *ret = [[NSMutableString alloc] init];\n    for (int i = 0; i < length; i++) {\n        [ret appendString:g_wordArray[self.uint16 % 1000]];\n        [ret appendString:@\" \"];\n    }\n    return ret;\n}\n\n- (NSData *)data\n{\n    return [self dataWithLength:self.length];\n}\n\n- (NSData *)dataWithLength:(NSInteger)length\n{\n    NSMutableData *data = [NSMutableData data];\n    [data increaseLengthBy:length];\n    unsigned char *bytes = (unsigned char *) data.mutableBytes;\n    for (NSUInteger i = 0; i < length; ++i) {\n        bytes[i] = (*self.uniformUChar.get())(*self.engine.get());\n    }\n    return [NSData dataWithData:data];\n}\n\n- (NSData *)dataOtherThan:(NSData *)other\n{\n    NSData *data;\n    do {\n        data = self.data;\n    } while ([other isEqualToData:data]);\n    return data;\n}\n\n- (NSDate *)date\n{\n    return [NSDate dateWithTimeIntervalSince1970:self.double_];\n}\n\n@end\n"
  },
  {
    "path": "src/objc/tests/common/utility/Dispatch.h",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import <Foundation/Foundation.h>\n\ntypedef void (^DispatchBlock)(void);\n\n@interface Dispatch : NSObject\n\n- (void)async:(DispatchBlock)block;\n\n- (void)waitUntilDone;\n\n@end\n"
  },
  {
    "path": "src/objc/tests/common/utility/Dispatch.mm",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"Dispatch.h\"\n\n@implementation Dispatch {\n    dispatch_queue_t _queue;\n    dispatch_group_t _group;\n}\n\n- (instancetype)init\n{\n    if (self = [super init]) {\n        _queue = dispatch_queue_create(\"com.Tencent.TestCase\", DISPATCH_QUEUE_CONCURRENT);\n        _group = dispatch_group_create();\n    }\n    return self;\n}\n\n- (void)async:(DispatchBlock)block\n{\n    dispatch_group_async(_group, _queue, block);\n}\n\n- (void)waitUntilDone\n{\n    dispatch_group_wait(_group, DISPATCH_TIME_FOREVER);\n}\n\n@end\n"
  },
  {
    "path": "src/objc/tests/common/utility/NSObject+TestCase.h",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import <Foundation/Foundation.h>\n#if TEST_WCDB_OBJC\n#import <WCDBOBjc/WCDBObjc.h>\n#elif TEST_WCDB_CPP\n#import <WCDBCpp/WCDBCpp.h>\n#else\n#import <WCDB/WCDBObjc.h>\n#endif\n\n@interface NSObject (TestCase)\n\n+ (BOOL)isObject:(NSObject *)left nilEqualToObject:(NSObject *)right;\n\n@end\n\n@interface NSArray (TestCase)\n\n- (NSArray *)reversedArray;\n\n@end\n\n@interface NSString (TestCase)\n\n+ (NSArray<NSString *> *)pathsByReplacingPaths:(NSArray<NSString *> *)paths withDirectory:(NSString *)directory;\n+ (NSString *)pathByReplacingPath:(NSString *)path withDirectory:(NSString *)directory;\n- (NSString *)test_stringByStandardizingPath;\n+ (NSString *)createPreciseStringFromDouble:(double)doubleValue;\n\n@end\n\n@interface NSFileManager (TestCase)\n\n- (unsigned long long)getFileSizeIfExists:(NSString *)path;\n- (void)copyItemsIfExistsAtPath:(NSString *)path toPath:(NSString *)destination;\n- (void)removeItemIfExistsAtPath:(NSString *)path;\n- (void)removeItemsIfExistsAtPaths:(NSArray<NSString *> *)paths;\n- (void)setFileImmutable:(BOOL)immutable ofItemsIfExistsAtPath:(NSString *)path;\n- (void)setFileImmutable:(BOOL)immutable ofItemsIfExistsAtPaths:(NSArray<NSString *> *)paths;\n- (BOOL)isFileImmutableOfItemAtPath:(NSString *)path;\n- (NSArray *)getAllFilesAtDirectory:(NSString *)directory;\n\n#if TARGET_OS_IPHONE && !TARGET_IPHONE_SIMULATOR\n- (void)setFileProtectionOfPath:(NSString *)path to:(NSFileProtectionType)type;\n- (NSFileProtectionType)getFileProtection:(NSString *)path;\n#endif\n\n@end\n"
  },
  {
    "path": "src/objc/tests/common/utility/NSObject+TestCase.mm",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"NSObject+TestCase.h\"\n#import \"TestCaseAssertion.h\"\n#import \"TestCaseLog.h\"\n\n@implementation NSObject (TestCase)\n\n+ (BOOL)isObject:(NSObject *)left nilEqualToObject:(NSObject *)right\n{\n    return (left == nil && right == nil) || [left isEqual:right];\n}\n\n@end\n\n@implementation NSArray (TestCase)\n\n- (NSArray *)reversedArray\n{\n    return self.reverseObjectEnumerator.allObjects;\n}\n\n@end\n\n@implementation NSString (TestCase)\n\n+ (NSString *)pathByReplacingPath:(NSString *)path withDirectory:(NSString *)directory\n{\n    return [directory stringByAppendingPathComponent:path.lastPathComponent];\n}\n\n+ (NSArray<NSString *> *)pathsByReplacingPaths:(NSArray<NSString *> *)paths withDirectory:(NSString *)directory\n{\n    NSMutableArray<NSString *> *newPaths = [NSMutableArray arrayWithCapacity:paths.count];\n    for (NSString *path in paths) {\n        [newPaths addObject:[NSString pathByReplacingPath:path withDirectory:directory]];\n    }\n    return newPaths;\n}\n\n- (NSString *)test_stringByStandardizingPath\n{\n    NSString *path = [self stringByStandardizingPath];\n#if TARGET_OS_IPHONE && !TARGET_IPHONE_SIMULATOR\n    /*\n     /var is the symlink to /private/var.\n     In most cases, -[NSString stringByStandardizingPath] will return the path with the /var prefix,\n     while in a small number of cases it will return the path with the /private/var prefix.\n     In order to avoid the inconsistency of the path of the same file, remove the /private prefix of path here\n     */\n    NSRange match = [path rangeOfString:@\"/private\"];\n    if (match.location == 0) {\n        path = [path stringByReplacingCharactersInRange:match withString:@\"\"];\n    }\n#endif\n    return path;\n}\n\n+ (NSString *)createPreciseStringFromDouble:(double)doubleValue\n{\n    std::ostringstream stream;\n    stream.precision(std::numeric_limits<double>::max_digits10);\n    stream << doubleValue;\n    return [NSString stringWithUTF8String:stream.str().data()];\n}\n\n@end\n\n@implementation NSFileManager (TestCase)\n\n- (unsigned long long)getFileSizeIfExists:(NSString *)path\n{\n    unsigned long long size = 0;\n    NSFileManager *fileManager = [NSFileManager defaultManager];\n    if ([fileManager fileExistsAtPath:path]) {\n        NSError *error;\n        size = [[fileManager attributesOfItemAtPath:path error:&error] fileSize];\n        TestCaseAssertNil(error);\n    }\n    return size;\n}\n\n- (void)copyItemsIfExistsAtPath:(NSString *)path toPath:(NSString *)destination\n{\n    [self removeItemIfExistsAtPath:destination];\n    if ([self fileExistsAtPath:path]) {\n        NSError *error;\n        [self copyItemAtPath:path toPath:destination error:&error];\n        TestCaseAssertNil(error);\n    }\n}\n\n- (void)copyItemsIfExistsAtPaths:(NSArray<NSString *> *)paths toDirectory:(NSString *)directory\n{\n    for (NSString *path in paths.reversedArray) {\n        NSString *newPath = [NSString pathByReplacingPath:path withDirectory:directory];\n        // remove existing file\n        [self removeItemIfExistsAtPath:newPath];\n        if ([self fileExistsAtPath:path]) {\n            NSError *error;\n            [self copyItemAtPath:path toPath:newPath error:&error];\n            TestCaseAssertNil(error);\n        }\n    }\n}\n\n- (void)removeItemIfExistsAtPath:(NSString *)path\n{\n    if ([self fileExistsAtPath:path]) {\n        NSError *error;\n        [self removeItemAtPath:path error:&error];\n        TestCaseAssertNil(error);\n    }\n}\n\n- (void)removeItemsIfExistsAtPaths:(NSArray<NSString *> *)paths\n{\n    for (NSString *path in paths.reversedArray) {\n        [self removeItemIfExistsAtPath:path];\n    }\n}\n\n- (void)setFileImmutable:(BOOL)immutable ofItemsIfExistsAtPath:(NSString *)path\n{\n    if ([self fileExistsAtPath:path]) {\n        NSError *error;\n        TestCaseAssertTrue([self setAttributes:@{ NSFileImmutable : @(immutable) } ofItemAtPath:path error:&error]);\n        TestCaseAssertNil(error);\n    }\n}\n\n- (void)setFileImmutable:(BOOL)immutable ofItemsIfExistsAtPaths:(NSArray<NSString *> *)paths\n{\n    for (NSString *path in paths.reversedArray) {\n        [self setFileImmutable:immutable ofItemsIfExistsAtPath:path];\n    }\n}\n\n- (BOOL)isFileImmutableOfItemAtPath:(NSString *)path\n{\n    BOOL immutable = NO;\n    if ([self fileExistsAtPath:path]) {\n        NSError *error;\n        immutable = [self attributesOfItemAtPath:path error:&error].fileIsImmutable;\n        TestCaseAssertNil(error);\n    }\n    return immutable;\n}\n\n- (NSArray *)getAllFilesAtDirectory:(NSString *)directory\n{\n    NSFileManager *mgr = [NSFileManager defaultManager];\n    if (![mgr fileExistsAtPath:directory]) {\n        return nil;\n    }\n    NSMutableArray *directories = [[NSMutableArray alloc] initWithObjects:directory, nil];\n    NSString *currentDir;\n    NSMutableArray *result = [[NSMutableArray alloc] init];\n    NSString *currentPath;\n    BOOL isDir = NO;\n    BOOL isExist = NO;\n    while (directories.count > 0) {\n        currentDir = directories.lastObject;\n        [directories removeLastObject];\n        NSError *error;\n        NSArray *files = [mgr contentsOfDirectoryAtPath:currentDir error:&error];\n        TestCaseAssertNil(error);\n        for (NSString *file in files) {\n            currentPath = [currentDir stringByAppendingPathComponent:file];\n            isExist = [mgr fileExistsAtPath:currentPath isDirectory:&isDir];\n            if (isDir) {\n                [directories addObject:currentPath];\n            } else if (isExist) {\n                [result addObject:currentPath];\n            }\n        }\n    }\n    return result;\n}\n\n#if TARGET_OS_IPHONE && !TARGET_IPHONE_SIMULATOR\n- (void)setFileProtectionOfPath:(NSString *)path to:(NSFileProtectionType)type\n{\n    if ([self fileExistsAtPath:path]) {\n        NSError *error;\n        TestCaseAssertTrue([self setAttributes:@{ NSFileProtectionKey : type } ofItemAtPath:path error:&error]);\n        TestCaseAssertNil(error);\n    }\n}\n\n- (NSFileProtectionType)getFileProtection:(NSString *)path\n{\n    NSError *error;\n    NSFileProtectionType type = [self attributesOfItemAtPath:path error:&error][NSFileProtectionKey];\n    TestCaseAssertNil(error);\n    return type;\n}\n#endif\n\n@end\n"
  },
  {
    "path": "src/objc/tests/common/utility/Signpost.h",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import <Foundation/Foundation.h>\n#import <os/signpost.h>\n\n@interface Signpost : NSObject\n\n- (instancetype)initWithSystem:(NSString*)system andCategory:(NSString*)category;\n@property (nonatomic, readonly) NSString* system;\n@property (nonatomic, readonly) NSString* category;\n\n@property (nonatomic, readonly) os_log_t log;\n@property (nonatomic, readonly) os_signpost_id_t identifier;\n\n@end\n\n#define SignpostBegin(signpost, task) \\\n    os_signpost_interval_begin(signpost.log, signpost.identifier, task)\n\n#define SignpostEnd(signpost, task) \\\n    os_signpost_interval_end(signpost.log, signpost.identifier, task)\n"
  },
  {
    "path": "src/objc/tests/common/utility/Signpost.mm",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"Signpost.h\"\n\n@implementation Signpost\n\n- (instancetype)initWithSystem:(NSString *)system andCategory:(NSString *)category\n{\n    if (self = [super init]) {\n        _system = system;\n        _category = category;\n        _log = os_log_create(system.UTF8String, category.UTF8String);\n        if (@available(iOS 12.0, macOS 10.14, *)) {\n            _identifier = os_signpost_id_generate(_log);\n        }\n    }\n    return self;\n}\n\n@end\n"
  },
  {
    "path": "src/objc/tests/common/utility/TestCaseAssertion.h",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"TestCaseLog.h\"\n#import <Foundation/Foundation.h>\n#import <XCTest/XCTestAssertions.h>\n\n#define TestCaseHintStringEqual(expect, but)        \\\n    {                                               \\\n        BOOL _equal = [expect isEqualToString:but]; \\\n        if (!_equal) {                              \\\n            TestCaseLog(                            \\\n            @\"\\nept: [%@]\"                          \\\n             \"\\nbut: [%@]\"                          \\\n             \"\\ncom: [%@]\",                         \\\n            expect,                                 \\\n            but,                                    \\\n            [expect commonPrefixWithString:but      \\\n                                   options:0]);     \\\n        }                                           \\\n    }\n\n#define TestCaseFailure() XCTAssertTrue(false)\n\n#define TestCaseAssertTrue(cond) XCTAssertTrue(cond)\n\n#define TestCaseAssertFalse(cond) XCTAssertFalse(cond)\n\n#define TestCaseAssertEqual(left, right) \\\n    TestCaseAssertTrue((left) == (right))\n\n#define TestCaseAssertNotEqual(left, right) \\\n    TestCaseAssertTrue((left) != (right))\n\n#define TestCaseAssertObjectEqual(left, right) XCTAssertEqualObjects(left, right)\n\n#define TestCaseAssertSQLEqual(_sql, _expected)              \\\n    {                                                        \\\n        NSString* __sql = @((_sql).getDescription().data()); \\\n        NSString* __expected = (_expected);                  \\\n        TestCaseAssertStringEqual(__sql, __expected);        \\\n    }\n\n#define TestCaseAssertStringEqual(left, right)              \\\n    {                                                       \\\n        NSString* _left = (left);                           \\\n        NSString* _right = (right);                         \\\n        TestCaseHintStringEqual(_left, _right);             \\\n        TestCaseAssertTrue([_left isEqualToString:_right]); \\\n    }\n\n#define TestCaseAssertResultYES(result) \\\n    TestCaseAssertTrue(result.isYES)\n\n#define TestCaseAssertResultNO(result) \\\n    TestCaseAssertTrue(result.isNO)\n\n#define TestCaseAssertOptionalEqual(optional, expected)   \\\n    {                                                     \\\n        auto _optional = optional;                        \\\n        TestCaseAssertFalse(_optional.failed());          \\\n        TestCaseAssertEqual(_optional.value(), expected); \\\n    }\n\n#define TestCaseAssertOptionalTrue(optional) \\\n    TestCaseAssertOptionalEqual(optional, YES)\n\n#define TestCaseAssertOptionalFalse(optional) \\\n    TestCaseAssertOptionalEqual(optional, NO)\n\n#define TestCaseAssertNil(object) \\\n    TestCaseAssertTrue(object == nil)\n\n#define TestCaseAssertNotNil(object) \\\n    TestCaseAssertTrue(object != nil)\n"
  },
  {
    "path": "src/objc/tests/common/utility/TestCaseCounter.h",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import <Foundation/Foundation.h>\n\n@interface TestCaseCounter : NSObject\n\n+ (instancetype)value:(int)value;\n- (instancetype)initWithValue:(int)value;\n\n- (int)value;\n- (void)setValue:(int)value;\n\n- (void)increment;\n- (void)decrement;\n\n@end\n"
  },
  {
    "path": "src/objc/tests/common/utility/TestCaseCounter.mm",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"TestCaseCounter.h\"\n#import <atomic>\n\n@implementation TestCaseCounter {\n    std::atomic<int> m_i;\n}\n\n+ (instancetype)value:(int)value\n{\n    return [[self alloc] initWithValue:value];\n}\n\n- (instancetype)initWithValue:(int)value\n{\n    if (self = [super init]) {\n        m_i.store(value);\n    }\n    return self;\n}\n\n- (int)value\n{\n    return m_i.load();\n}\n\n- (void)setValue:(int)value\n{\n    m_i.store(value);\n}\n\n- (void)increment\n{\n    ++m_i;\n}\n\n- (void)decrement\n{\n    --m_i;\n}\n\n@end\n"
  },
  {
    "path": "src/objc/tests/common/utility/TestCaseLog.h",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import <Foundation/Foundation.h>\n\nvoid TestCaseLog(NSString *format, ...);\nvoid TestCaseLogv(NSString *format, va_list args);\n"
  },
  {
    "path": "src/objc/tests/common/utility/TestCaseLog.mm",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"TestCaseLog.h\"\n\nvoid TestCaseLog(NSString *format, ...)\n{\n    va_list ap;\n    va_start(ap, format);\n    TestCaseLogv(format, ap);\n    va_end(ap);\n}\n\nvoid TestCaseLogv(NSString *format, va_list args)\n{\n    printf(\"%s\\n\", [[NSString alloc] initWithFormat:format arguments:args].UTF8String);\n}\n"
  },
  {
    "path": "src/objc/tests/common/utility/TestCaseMacro.h",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#define weakify(variable)                                                                   \\\n    __attribute__((objc_ownership(weak))) __typeof__(variable) WCDB_CONCAT(weak_, variable) \\\n    = (variable);\n\n#define strongify(variable)                                                           \\\n    _Pragma(\"clang diagnostic push\") _Pragma(\"clang diagnostic ignored \\\"-Wshadow\\\"\") \\\n    __attribute__((objc_ownership(strong))) __typeof__(variable) self                 \\\n    = WCDB_CONCAT(weak_, variable);                                                   \\\n    _Pragma(\"clang diagnostic pop\")\n\n#define strongify_or_return(variable)                                          \\\n    strongify(variable) if (variable == nil)                                   \\\n    {                                                                          \\\n        return;                                                                \\\n    }\n"
  },
  {
    "path": "src/objc/tests/common/utility/TestCaseResult.h",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import <Foundation/Foundation.h>\n\n@interface TestCaseResult : NSObject\n\n+ (instancetype)yes;\n+ (instancetype)no;\n- (instancetype)initWithValue:(BOOL)value;\n\n// atmoic\n@property (atomic, assign) BOOL value;\n- (void)makeYES;\n- (void)makeNO;\n\n- (BOOL)isYES;\n- (BOOL)isNO;\n\n@end\n"
  },
  {
    "path": "src/objc/tests/common/utility/TestCaseResult.mm",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"TestCaseResult.h\"\n\n@implementation TestCaseResult\n\n+ (instancetype)yes\n{\n    return [[self alloc] initWithValue:YES];\n}\n\n+ (instancetype)no\n{\n    return [[self alloc] initWithValue:NO];\n}\n\n- (instancetype)initWithValue:(BOOL)value\n{\n    if (self = [super init]) {\n        self.value = value;\n    }\n    return self;\n}\n\n- (void)makeYES\n{\n    self.value = YES;\n}\n\n- (void)makeNO\n{\n    self.value = NO;\n}\n\n- (BOOL)isYES\n{\n    return self.value;\n}\n\n- (BOOL)isNO\n{\n    return !self.isYES;\n}\n\n@end\n"
  },
  {
    "path": "src/objc/tests/common/utility/WCTDatabase+TestCase.h",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#if TEST_WCDB_OBJC\n#import <WCDBOBjc/WCDBObjc.h>\n#elif TEST_WCDB_CPP\n#import <WCDBCpp/WCDBCpp.h>\n#else\n#import <WCDB/WCDBObjc.h>\n#endif\n\nNS_ASSUME_NONNULL_BEGIN\n\ntypedef NSData* _Nonnull (^WCTCorruptDataBlock)(int size);\n\n@interface WCTDatabase (TestCase)\n\n@property (nonatomic, readonly) NSString* walPath;\n@property (nonatomic, readonly) NSString* factoryPath;\n@property (nonatomic, readonly) NSString* incrementalMaterialPath;\n@property (nonatomic, readonly) NSString* firstMaterialPath;\n@property (nonatomic, readonly) NSString* lastMaterialPath;\n@property (nonatomic, readonly) NSString* journalPath;\n@property (nonatomic, readonly) NSString* shmPath;\n@property (nonatomic, readonly) NSString* factoryRestorePath;\n\n@property (nonatomic, readonly) int headerSize;\n@property (nonatomic, readonly) int pageSize;\n@property (nonatomic, readonly) int walHeaderSize;\n@property (nonatomic, readonly) int walFrameHeaderSize;\n@property (nonatomic, readonly) int walFrameSize;\n\n- (WCTOptionalSize)getNumberOfPages;\n\n- (WCTOptionalSize)getNumberOfWalFrames;\n\n- (BOOL)corruptHeaderWithinCloseAfterTruncatedCheckpoint;\n\n- (void)corruptPage:(int)i;\n- (void)corruptPage:(int)i withData:(WCTCorruptDataBlock)block;\n\n- (void)corruptWalFrame:(int)i;\n\n- (BOOL)corruptCompletely;\n\n- (WCTOptionalBool)isAlreadyCheckpointed;\n\n- (WCTOptionalBool)isAlreadyTruncateCheckpointed;\n\n@end\n\nNS_ASSUME_NONNULL_END\n"
  },
  {
    "path": "src/objc/tests/common/utility/WCTDatabase+TestCase.mm",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"CoreConst.h\"\n#import \"TestCaseLog.h\"\n#import \"WCTDatabase+TestCase.h\"\n#if TEST_WCDB_OBJC\n#import <WCDBOBjc/WCTDatabase+Test.h>\n#elif TEST_WCDB_CPP\n#import <WCDBCpp/WCTDatabase+Test.h>\n#else\n#import <WCDB/WCTDatabase+Test.h>\n#endif\n\n@implementation WCTDatabase (TestCase)\n\n- (NSString *)walPath\n{\n    return [self.path stringByAppendingString:@\"-wal\"];\n}\n\n- (NSString *)incrementalMaterialPath\n{\n    return [self.path stringByAppendingString:@\"-incremental.material\"];\n}\n\n- (NSString *)firstMaterialPath\n{\n    return [self.path stringByAppendingString:@\"-first.material\"];\n}\n\n- (NSString *)lastMaterialPath\n{\n    return [self.path stringByAppendingString:@\"-last.material\"];\n}\n\n- (NSString *)factoryPath\n{\n    return [self.path stringByAppendingString:@\".factory\"];\n}\n\n- (NSString *)journalPath\n{\n    return [self.path stringByAppendingString:@\"-journal\"];\n}\n\n- (NSString *)shmPath\n{\n    return [self.path stringByAppendingString:@\"-shm\"];\n}\n\n- (NSString *)factoryRestorePath\n{\n    return [self.factoryPath stringByAppendingPathComponent:@\"restore\"];\n}\n\n- (int)headerSize\n{\n    return 100;\n}\n\n- (int)pageSize\n{\n    return 4096;\n}\n\n- (int)walHeaderSize\n{\n    return 32;\n}\n\n- (int)walFrameHeaderSize\n{\n    return 24;\n}\n\n- (int)walFrameSize\n{\n    return self.walFrameHeaderSize + self.pageSize;\n}\n\n- (WCTOptionalSize)getNumberOfPages\n{\n    WCTOptionalSize result;\n    if ([[NSFileManager defaultManager] fileExistsAtPath:self.path]) {\n        NSError *error;\n        size_t size = (size_t) ((NSNumber *) [[NSFileManager defaultManager] attributesOfItemAtPath:self.path error:&error][NSFileSize]).unsignedLongLongValue;\n        if (error == nil) {\n            int numberOfPages = (int) (size / self.pageSize);\n            result = numberOfPages > 0 ? numberOfPages : 0;\n        } else {\n            TestCaseLog(@\"%@\", error);\n        }\n    } else {\n        result = 0;\n    }\n    return result;\n}\n\n- (WCTOptionalSize)getNumberOfWalFrames\n{\n    WCTOptionalSize result;\n    NSError *error;\n    if ([[NSFileManager defaultManager] fileExistsAtPath:self.walPath]) {\n        size_t size = (size_t) ((NSNumber *) [[NSFileManager defaultManager] attributesOfItemAtPath:self.walPath error:&error][NSFileSize]).unsignedLongLongValue;\n        if (error == nil) {\n            if (size == 0) {\n                result = 0;\n            } else if (size > self.walHeaderSize) {\n                result = (size - self.walHeaderSize) / self.walFrameSize;\n            }\n        } else {\n            TestCaseLog(@\"%@\", error);\n        }\n    } else {\n        result = 0;\n    }\n    return result;\n}\n\n- (BOOL)corruptHeaderWithinCloseAfterTruncatedCheckpoint\n{\n    __block BOOL result = NO;\n    [self close:^{\n        result = [self truncateCheckpoint];\n\n        NSFileHandle *fileHandle = [NSFileHandle fileHandleForUpdatingAtPath:self.path];\n        NSMutableData *emptyData = [NSMutableData data];\n        [emptyData increaseLengthBy:self.headerSize];\n        [fileHandle writeData:emptyData];\n        [fileHandle closeFile];\n    }];\n    return result;\n}\n\n- (void)corruptWalFrame:(int)i\n{\n    NSFileHandle *fileHandle = [NSFileHandle fileHandleForUpdatingAtPath:self.walPath];\n    [fileHandle seekToFileOffset:self.walHeaderSize + (i - 1) * self.walFrameSize];\n    NSMutableData *emptyData = [NSMutableData data];\n    [emptyData increaseLengthBy:self.walFrameSize];\n    [fileHandle writeData:emptyData];\n    [fileHandle closeFile];\n}\n\n- (void)corruptPage:(int)i\n{\n    [self corruptPage:i\n             withData:^NSData *(int size) {\n                 return [NSMutableData dataWithLength:size];\n             }];\n}\n\n- (void)corruptPage:(int)i withData:(WCTCorruptDataBlock)block\n{\n    NSFileHandle *fileHandle = [NSFileHandle fileHandleForUpdatingAtPath:self.path];\n    [fileHandle seekToFileOffset:(i - 1) * self.pageSize];\n    [fileHandle writeData:block(self.pageSize)];\n    [fileHandle closeFile];\n}\n\n- (BOOL)corruptCompletely\n{\n    auto numberOfPages = [self getNumberOfPages];\n    if (numberOfPages.failed()) {\n        return NO;\n    }\n    for (int i = 0; i < numberOfPages.value(); ++i) {\n        [self corruptPage:i + 1];\n    }\n    auto numberOfWalFrames = [self getNumberOfWalFrames];\n    if (numberOfWalFrames.failed()) {\n        return NO;\n    }\n    for (int i = 0; i < numberOfWalFrames.value(); ++i) {\n        [self corruptWalFrame:i + 1];\n    }\n    return YES;\n}\n\n- (WCTOptionalBool)isAlreadyCheckpointed\n{\n    WCTOptionalSize frames = [self getNumberOfWalFrames];\n    if (frames.failed()) {\n        return WCDB::NullOpt;\n    }\n    if (frames.value() == 0) {\n        return YES;\n    }\n\n    BOOL exists = [[NSFileManager defaultManager] fileExistsAtPath:self.shmPath];\n    if (!exists) {\n        return WCDB::NullOpt;\n    }\n\n    NSFileHandle *fileHandle = [NSFileHandle fileHandleForReadingAtPath:self.shmPath];\n\n    [fileHandle seekToFileOffset:16];\n    NSData *data = [fileHandle readDataOfLength:4];\n    if (data == nil) {\n        return WCDB::NullOpt;\n    }\n    uint32_t maxFrame = *(uint32_t *) data.bytes;\n\n    [fileHandle seekToFileOffset:96];\n    data = [fileHandle readDataOfLength:4];\n    if (data == nil) {\n        return WCDB::NullOpt;\n    }\n    uint32_t backfill = *(uint32_t *) data.bytes;\n\n    [fileHandle closeFile];\n\n    return backfill >= maxFrame;\n}\n\n- (WCTOptionalBool)isAlreadyTruncateCheckpointed\n{\n    WCTOptionalSize frames = [self getNumberOfWalFrames];\n    if (frames.failed()) {\n        return WCDB::NullOpt;\n    }\n    return frames.value() == 0;\n}\n\n@end\n"
  },
  {
    "path": "src/objc/tests/compression/common/CompressionTestCase.h",
    "content": "//\n// Created by qiuwenchen on 2023/12/3.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"CompressionTestObject.h\"\n#import \"TestCase.h\"\n\ntypedef enum : NSUInteger {\n    CompressionMode_Normal = 0,\n    CompressionMode_Dict,\n    CompressionMode_VariousDict,\n} CompressionMode;\n\ntypedef enum : NSUInteger {\n    CompressionStatus_uncompressed = 0,\n    CompressionStatus_startCompressed,\n    CompressionStatus_finishCompressed,\n} CompressionStatus;\n\ntypedef enum : NSUInteger {\n    MigrationStatus_noMigration = 0,\n    MigrationStatus_unmigrated,\n    MigrationStatus_startMigrate,\n} MigrationStatus;\n\n@interface CompressionTestCase : TableTestCase\n\n@property (nonatomic, assign) CompressionMode mode;\n@property (nonatomic, assign) BOOL compressTwoColumn;\n@property (nonatomic, assign) CompressionStatus compressionStatus;\n@property (nonatomic, assign) MigrationStatus migrationStatus;\n@property (nonatomic, assign) BOOL needCipher;\n\n@property (nonatomic, strong) NSString* anotherTable;\n\n- (NSString*)sourceSchema;\n- (NSString*)uncompressTableName;\n- (WCTTable*)uncompressTable;\n- (NSDictionary<NSNumber*, NSNumber*>*)matchDictForText;\n- (NSDictionary<NSNumber*, NSNumber*>*)matchDictForBLOB;\n- (NSArray<CompressionTestObject*>*)originObjects;\n\n- (void)configCompression;\n- (void)configCompressFilter;\n- (void)reconfigCompressionFilter;\n- (void)clearData;\n- (void)doTestCompression:(void (^)(void))operation;\n- (void)executeModify:(BOOL (^)(WCTTable*))modify andSQLs:(NSArray<NSString*>*)sqls;\n- (void)executeSelect:(NSArray* (^)(WCTTable*) )select andSQLs:(NSArray<NSString*>*)sqls;\n\n@end\n"
  },
  {
    "path": "src/objc/tests/compression/common/CompressionTestCase.mm",
    "content": "//\n// Created by qiuwenchen on 2023/12/3.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"CompressionTestCase.h\"\n#import \"Random+CompressionTestObject.h\"\n#import <Foundation/Foundation.h>\n\n@interface CompressionTestCase () {\n    WCTTable *m_uncompressedTable;\n    WCTDatabase *m_sourceDatabase;\n    NSData *m_cipher;\n    NSArray<CompressionTestObject *> *m_objects;\n    NSString *m_sourceSchema;\n}\n@end\n\n@implementation CompressionTestCase\n\n- (void)setUp\n{\n    [super setUp];\n    static dispatch_once_t onceToken;\n    dispatch_once(&onceToken, ^{\n        for (int i = 1; i < 7; i++) {\n            NSArray<NSString *> *contents = [[Random shared] compressionStringWithCount:3000];\n            NSData *dict = [WCTDatabase trainDictWithStrings:contents andDictId:(WCTDictId) i];\n            XCTAssertNotNil(dict);\n            TestCaseAssertTrue([WCTDatabase registerZSTDDict:dict andDictId:(WCTDictId) i]);\n        }\n    });\n    m_sourceDatabase = [[WCTDatabase alloc] initWithPath:[self.path stringByAppendingString:@\"_source\"]];\n    m_objects = [Random.shared autoIncrementCompressionObjectWithCount:1000];\n    self.tableClass = CompressionTestObject.class;\n}\n\n- (NSString *)sourceSchema\n{\n    @synchronized(self) {\n        if (m_sourceSchema == nil) {\n            m_sourceSchema = [NSString stringWithFormat:@\"wcdb_migration_%u.\", WCDB::UnsafeStringView(m_sourceDatabase.path).hash()];\n        }\n        return m_sourceSchema;\n    }\n}\n\n- (NSString *)uncompressTableName\n{\n    return m_uncompressedTable.tableName;\n}\n\n- (WCTTable *)uncompressTable\n{\n    return m_uncompressedTable;\n}\n\n- (NSDictionary<NSNumber *, NSNumber *> *)matchDictForText\n{\n    return @{\n        @0 : @1,\n        @1 : @2,\n        @2 : @3,\n        @3 : @4,\n        @4 : @5,\n        @WCTDictDefaultMatchValue : @6,\n    };\n}\n\n- (NSDictionary<NSNumber *, NSNumber *> *)matchDictForBLOB\n{\n    return @{\n        @0 : @1,\n        @1 : @2,\n        @2 : @3,\n        @WCTDictDefaultMatchValue : @4,\n    };\n}\n\n- (NSArray<CompressionTestObject *> *)originObjects\n{\n    return m_objects;\n}\n\n- (void)configCompression\n{\n    [self clearData];\n    NSData *cipher = nil;\n    if (_needCipher) {\n        if (!m_cipher) {\n            m_cipher = [Random.shared data];\n        }\n    }\n    [self.database setCipherKey:cipher];\n\n    TestCaseAssertTrue([self createTable]);\n    TestCaseAssertTrue([self.database createTable:@\"uncompressedTable\" withClass:CompressionTestObject.class]);\n    m_uncompressedTable = [self.database getTable:@\"uncompressedTable\" withClass:CompressionTestObject.class];\n    TestCaseAssertTrue([m_uncompressedTable insertObjects:m_objects]);\n\n    if (_migrationStatus != MigrationStatus_noMigration) {\n        TestCaseAssertTrue([m_sourceDatabase createTable:self.tableName withClass:CompressionTestObject.class]);\n        TestCaseAssertTrue([m_sourceDatabase insertObjects:m_objects intoTable:self.tableName]);\n        [self.database addMigration:m_sourceDatabase.path\n                         withFilter:^(WCTMigrationUserInfo *info) {\n                             if ([info.table isEqualToString:self.tableName]) {\n                                 [info setSourceTable:self.tableName];\n                             }\n                         }];\n    } else {\n        [self.table insertObjects:m_objects];\n    }\n\n    [self configCompressFilter];\n    [self.database setNotificationWhenCompressed:nil];\n\n    if (self.migrationStatus == MigrationStatus_startMigrate) {\n        TestCaseAssertTrue([self.database stepMigration]);\n        TestCaseAssertFalse([self.database isMigrated]);\n    }\n    if (self.compressionStatus == CompressionStatus_startCompressed) {\n        TestCaseAssertTrue([self.database stepCompression]);\n    } else if (self.compressionStatus == CompressionStatus_finishCompressed) {\n        while (![self.database isCompressed]) {\n            TestCaseAssertTrue([self.database stepCompression]);\n        }\n    }\n}\n\n- (void)configCompressFilter\n{\n    switch (self.mode) {\n    case CompressionMode_Normal: {\n        [self.database setCompressionWithFilter:^(WCTCompressionUserInfo *info) {\n            if (![info.table isEqualToString:self.tableName] && ![info.table isEqualToString:self.anotherTable]) {\n                return;\n            }\n            [info addZSTDNormalCompressProperty:CompressionTestObject.text];\n            if (self.compressTwoColumn) {\n                [info addZSTDNormalCompressProperty:CompressionTestObject.blob];\n            }\n        }];\n    } break;\n    case CompressionMode_Dict: {\n        [self.database setCompressionWithFilter:^(WCTCompressionUserInfo *info) {\n            if (![info.table isEqualToString:self.tableName] && ![info.table isEqualToString:self.anotherTable]) {\n                return;\n            }\n            [info addZSTDDictCompressProperty:CompressionTestObject.text withDictId:1];\n            if (self.compressTwoColumn) {\n                [info addZSTDDictCompressProperty:CompressionTestObject.blob withDictId:1];\n            }\n        }];\n    } break;\n    case CompressionMode_VariousDict: {\n        [self.database setCompressionWithFilter:^(WCTCompressionUserInfo *info) {\n            if (![info.table isEqualToString:self.tableName] && ![info.table isEqualToString:self.anotherTable]) {\n                return;\n            }\n            [info addZSTDDictCompressProperty:CompressionTestObject.text\n                            withMatchProperty:CompressionTestObject.textMatchId\n                                andMatchDicts:[self matchDictForText]];\n            if (self.compressTwoColumn) {\n                [info addZSTDDictCompressProperty:CompressionTestObject.blob\n                                withMatchProperty:CompressionTestObject.blobMatchId\n                                    andMatchDicts:[self matchDictForBLOB]];\n            }\n        }];\n    } break;\n    }\n}\n\n- (void)reconfigCompressionFilter\n{\n    switch (self.mode) {\n    case CompressionMode_Normal: {\n        [self.database setCompressionWithFilter:^(WCTCompressionUserInfo *info) {\n            if (![info.table isEqualToString:self.tableName] && ![info.table isEqualToString:self.anotherTable]) {\n                return;\n            }\n            [info addZSTDDictCompressProperty:CompressionTestObject.text withDictId:1];\n            if (self.compressTwoColumn) {\n                [info addZSTDDictCompressProperty:CompressionTestObject.blob withDictId:1];\n            }\n            [info enableReplaceCompression];\n        }];\n    } break;\n    case CompressionMode_Dict: {\n        [self.database setCompressionWithFilter:^(WCTCompressionUserInfo *info) {\n            if (![info.table isEqualToString:self.tableName] && ![info.table isEqualToString:self.anotherTable]) {\n                return;\n            }\n            [info addZSTDDictCompressProperty:CompressionTestObject.text\n                            withMatchProperty:CompressionTestObject.textMatchId\n                                andMatchDicts:[self matchDictForText]];\n            if (self.compressTwoColumn) {\n                [info addZSTDDictCompressProperty:CompressionTestObject.blob\n                                withMatchProperty:CompressionTestObject.blobMatchId\n                                    andMatchDicts:[self matchDictForBLOB]];\n            }\n            [info enableReplaceCompression];\n        }];\n    } break;\n    case CompressionMode_VariousDict: {\n        [self.database setCompressionWithFilter:^(WCTCompressionUserInfo *info) {\n            if (![info.table isEqualToString:self.tableName] && ![info.table isEqualToString:self.anotherTable]) {\n                return;\n            }\n            [info addZSTDNormalCompressProperty:CompressionTestObject.text];\n            if (self.compressTwoColumn) {\n                [info addZSTDNormalCompressProperty:CompressionTestObject.blob];\n            }\n            [info enableReplaceCompression];\n        }];\n    } break;\n    }\n}\n\n- (void)clearData\n{\n    TestCaseAssertTrue([self.database removeFiles]);\n    TestCaseAssertTrue([m_sourceDatabase removeFiles]);\n    [self.database addMigration:m_sourceDatabase.path withFilter:nil];\n    [self.database setCompressionWithFilter:nil];\n}\n\n- (void)doTestCompression:(void (^)(void))operation\n{\n    for (int i = 0; i < 108; i++) {\n        int config = i;\n        [self clearData];\n\n        self.mode = (CompressionMode) (config % 3);\n        config /= 3;\n        self.compressTwoColumn = (BOOL) (config % 2);\n        config /= 2;\n        self.compressionStatus = (CompressionStatus) (config % 3);\n        config /= 3;\n        self.migrationStatus = (MigrationStatus) (config % 3);\n        config /= 3;\n        self.needCipher = (BOOL) (config % 2);\n\n        [self log:@\"execute test %d: mode %d, two column %d, compression status %d, migration status %d, need cipher %d\",\n                  i,\n                  self.mode,\n                  self.compressTwoColumn,\n                  self.compressionStatus,\n                  self.migrationStatus,\n                  self.needCipher];\n\n        [self configCompression];\n        operation();\n    }\n}\n\n- (void)executeModify:(BOOL (^)(WCTTable *))modify andSQLs:(NSArray<NSString *> *)sqls\n{\n    TestCaseAssertTrue(modify(m_uncompressedTable));\n\n    NSArray<CompressionTestObject *> *expectingObjs = [m_uncompressedTable getObjects];\n    TestCaseAssertTrue(expectingObjs.count > 0);\n    [self doTestObjects:expectingObjs\n                andSQLs:sqls\n      afterModification:^BOOL {\n          return modify(self.table);\n      }];\n    if (self.migrationStatus != MigrationStatus_noMigration) {\n        return;\n    }\n    if (expectingObjs.count < m_objects.count) {\n        return;\n    }\n    if (expectingObjs.count == m_objects.count) {\n        bool equal = true;\n        for (int i = 0; i < m_objects.count; i++) {\n            if (expectingObjs[i].text != m_objects[i].text && ![expectingObjs[i].text isEqualToString:m_objects[i].text]) {\n                equal = NO;\n                break;\n            }\n        }\n        if (equal) {\n            return;\n        }\n    }\n\n    // Check new data is compressed\n    WCTValue *compressedTextCount = [self.database getValueFromStatement:WCDB::StatementSelect().select(WCDB::Column::all().count()).from(self.tableName).where(WCDB::Column(\"WCDB_CT_text\").notNull())];\n    TestCaseAssertTrue(compressedTextCount.numberValue.intValue > 0);\n    if (self.compressionStatus == CompressionStatus_finishCompressed) {\n        TestCaseAssertTrue(compressedTextCount.numberValue.intValue == expectingObjs.count);\n    }\n    if (!self.compressTwoColumn) {\n        return;\n    }\n    if (expectingObjs.count == m_objects.count) {\n        bool equal = true;\n        for (int i = 0; i < m_objects.count; i++) {\n            if (expectingObjs[i].blob != m_objects[i].blob && ![expectingObjs[i].blob isEqualToData:m_objects[i].blob]) {\n                equal = NO;\n                break;\n            }\n        }\n        if (equal) {\n            return;\n        }\n    }\n    WCTValue *compressedBlobCount = [self.database getValueFromStatement:WCDB::StatementSelect().select(WCDB::Column::all().count()).from(self.tableName).where(WCDB::Column(\"WCDB_CT_blob\").notNull())];\n    TestCaseAssertTrue(compressedBlobCount.numberValue.intValue > 0);\n    if (self.compressionStatus == CompressionStatus_finishCompressed) {\n        TestCaseAssertTrue(compressedBlobCount.numberValue.intValue == expectingObjs.count);\n    }\n}\n\n- (void)executeSelect:(NSArray * (^)(WCTTable *) )select andSQLs:(NSArray<NSString *> *)sqls\n{\n    NSArray *expectingObjs = select(m_uncompressedTable);\n    TestCaseAssertTrue(expectingObjs.count > 0);\n    [self doTestObjects:expectingObjs\n                andSQLs:sqls\n            bySelecting:^NSArray<NSObject<WCTTableCoding> *> * {\n                return select(self.table);\n            }];\n}\n\n@end\n"
  },
  {
    "path": "src/objc/tests/compression/common/CompressionTestObject.h",
    "content": "//\n// Created by qiuwenchen on 2023/12/3.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#if TEST_WCDB_OBJC\n#import <WCDBOBjc/WCDBObjc.h>\n#elif TEST_WCDB_CPP\n#import <WCDBCpp/WCDBCpp.h>\n#else\n#import <WCDB/WCDBObjc.h>\n#endif\n\n@interface CompressionTestObject : NSObject <WCTTableCoding>\n\n@property (nonatomic, assign) int mainId;\n@property (nonatomic, assign) double subId;\n@property (nonatomic, strong) NSString* text;\n@property (nonatomic, assign) int textMatchId;\n@property (nonatomic, strong) NSData* blob;\n@property (nonatomic, assign) int blobMatchId;\n\nWCDB_PROPERTY(mainId);\nWCDB_PROPERTY(subId);\nWCDB_PROPERTY(text);\nWCDB_PROPERTY(textMatchId)\nWCDB_PROPERTY(blob);\nWCDB_PROPERTY(blobMatchId)\n\n@end\n"
  },
  {
    "path": "src/objc/tests/compression/common/CompressionTestObject.mm",
    "content": "//\n// Created by qiuwenchen on 2023/12/3.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"CompressionTestObject.h\"\n#import <Foundation/Foundation.h>\n\n@implementation CompressionTestObject\n\nWCDB_IMPLEMENTATION(CompressionTestObject)\nWCDB_SYNTHESIZE(mainId);\nWCDB_SYNTHESIZE(subId);\nWCDB_SYNTHESIZE(text);\nWCDB_SYNTHESIZE(textMatchId);\nWCDB_SYNTHESIZE(blob);\nWCDB_SYNTHESIZE(blobMatchId);\n\nWCDB_PRIMARY_AUTO_INCREMENT(mainId);\n\n- (BOOL)isEqual:(NSObject*)other\n{\n    if (other.class != self.class) {\n        return NO;\n    }\n    CompressionTestObject* otherObj = (CompressionTestObject*) other;\n    bool ret = _mainId == otherObj.mainId && _subId == otherObj.subId && ([_text isEqualToString:otherObj.text] || _text == otherObj.text) && ([_blob isEqualToData:otherObj.blob] || _blob == otherObj.blob) && _textMatchId == otherObj.textMatchId && _blobMatchId == otherObj.blobMatchId;\n    if (!ret) {\n        return false;\n    }\n    return true;\n}\n\n@end\n"
  },
  {
    "path": "src/objc/tests/compression/common/Random+CompressionTestObject.h",
    "content": "//\n// Created by qiuwenchen on 2023/12/3.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"CompressionTestObject.h\"\n#import \"TestCase.h\"\n\n@interface Random (Compression)\n\n- (CompressionTestObject *)autoIncrementCompressionObject;\n\n- (CompressionTestObject *)compressionObjectWithId:(int)identifier;\n\n- (NSArray<CompressionTestObject *> *)autoIncrementCompressionObjectWithCount:(int)count;\n\n- (NSArray<NSString *> *)compressionStringWithCount:(int)count;\n\n@end\n"
  },
  {
    "path": "src/objc/tests/compression/common/Random+CompressionTestObject.mm",
    "content": "//\n// Created by qiuwenchen on 2023/12/3.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"Random+CompressionTestObject.h\"\n#import <Foundation/Foundation.h>\n\n@implementation Random (Compression)\n\n- (CompressionTestObject*)autoIncrementCompressionObject\n{\n    CompressionTestObject* obj = [[CompressionTestObject alloc] init];\n    obj.isAutoIncrement = true;\n    obj.subId = self.double_;\n    obj.text = [self englishStringWithLength:self.uint16 % 1000];\n    obj.textMatchId = self.int8 % 6;\n    obj.blob = [[self englishStringWithLength:self.uint16 % 1000] dataUsingEncoding:NSUTF8StringEncoding];\n    obj.blobMatchId = self.int8 % 4;\n    return obj;\n}\n\n- (CompressionTestObject*)compressionObjectWithId:(int)identifier\n{\n    CompressionTestObject* obj = [[CompressionTestObject alloc] init];\n    obj.mainId = identifier;\n    obj.subId = self.double_;\n    obj.text = [self englishStringWithLength:self.uint16 % 1000];\n    obj.textMatchId = self.int8 % 6;\n    obj.blob = [[self englishStringWithLength:self.uint16 % 1000] dataUsingEncoding:NSUTF8StringEncoding];\n    obj.blobMatchId = self.int8 % 4;\n    return obj;\n}\n\n- (NSArray<CompressionTestObject*>*)autoIncrementCompressionObjectWithCount:(int)count\n{\n    NSMutableArray* ret = [[NSMutableArray alloc] init];\n    for (int i = 0; i < count; i++) {\n        [ret addObject:[self autoIncrementCompressionObject]];\n    }\n    return ret;\n}\n\n- (NSArray<NSString*>*)compressionStringWithCount:(int)count\n{\n    NSMutableArray<NSString*>* ret = [[NSMutableArray alloc] init];\n    for (int i = 0; i < count; i++) {\n        [ret addObject:self.englishString];\n    }\n    return ret;\n}\n\n@end\n"
  },
  {
    "path": "src/objc/tests/compression/compatible/CompressRobustyTests.mm",
    "content": "//\n// Created by qiuwenchen on 2023/12/18.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"TestCase.h\"\n\n@interface CompressRobustyTests : RobustyTestCase\n\n@end\n\n@implementation CompressRobustyTests\n\n- (void)setUp\n{\n    [super setUp];\n    self.skipDebugLog = YES;\n    [self.database enableAutoCheckpoint:YES];\n    self.tableFactor = 10;\n}\n\n- (NSString*)tablePrefix\n{\n    return @\"t_\";\n}\n\n- (void)do_test_feature_page_based_robusty\n{\n    NSArray* sizes = @[\n        @(10 * 1024 * 1024),\n#ifndef WCDB_QUICK_TESTS\n        @(100 * 1024 * 1024),\n        @(1024 * 1024 * 1024),\n#endif\n    ];\n    for (NSNumber* size in sizes) {\n        self.expectedDatabaseSize = size.integerValue;\n        [self.database setCompressionWithFilter:nil];\n        [self.database removeFiles];\n        TestCaseAssertTrue([self fillDatabaseUntilMeetExpectedSize]);\n\n        [self.database truncateCheckpoint];\n\n        NSString* testPath = [self.database.path stringByAppendingString:@\"-test\"];\n        WCTDatabase* database = [[WCTDatabase alloc] initWithPath:testPath];\n        [database removeFiles];\n        [self.fileManager copyItemsIfExistsAtPath:self.database.path toPath:testPath];\n        [database setCompressionWithFilter:^(WCTCompressionUserInfo* info) {\n            if ([info.table hasPrefix:[self tablePrefix]]) {\n                [info addZSTDNormalCompressProperty:TestCaseObject.content];\n            }\n        }];\n        for (int i = 0; i < 100; i++) {\n            [self.dispatch async:^{\n                for (int j = 0; j * 100 + i < self.allTables.count; j++) {\n                    NSString* tableName = [self.allTables objectAtIndex:j * 100 + i];\n                    TestCaseObject* object = [database getObjectOfClass:TestCaseObject.class fromTable:tableName];\n                    TestCaseAssertNotNil(object);\n                }\n            }];\n        }\n        [self.dispatch waitUntilDone];\n    }\n}\n\n@end\n"
  },
  {
    "path": "src/objc/tests/compression/compatible/CompressingCRUDTest.mm",
    "content": "//\n// Created by qiuwenchen on 2023/12/4.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"CompressionTestCase.h\"\n#import \"Random+CompressionTestObject.h\"\n#import <Foundation/Foundation.h>\n\n@interface CompressingCRUDTest : CompressionTestCase\n\n@end\n\n@implementation CompressingCRUDTest\n\n- (void)setUp\n{\n    [super setUp];\n    self.skipDebugLog = YES;\n    self.skipFullSQLTrace = YES;\n    self.expectMode = DatabaseTestCaseExpectSomeSQLs;\n}\n\n- (void)testInsert\n{\n    [self doTestCompression:^{\n        NSMutableArray* sqls = [[NSMutableArray alloc] init];\n        NSString* schema = self.migrationStatus == MigrationStatus_noMigration ? @\"\" : @\"main.\";\n        if (!self.compressTwoColumn) {\n            [sqls addObject:[NSString stringWithFormat:@\"INSERT INTO %@testTable(mainId, subId, text, textMatchId, blob, blobMatchId, WCDB_CT_text) VALUES(?1, ?2, ?3, ?4, ?5, ?6, ?7)\", schema]];\n        } else {\n            [sqls addObject:[NSString stringWithFormat:@\"INSERT INTO %@testTable(mainId, subId, text, textMatchId, blob, blobMatchId, WCDB_CT_text, WCDB_CT_blob) VALUES(?1, ?2, ?3, ?4, ?5, ?6, ?7, ?8)\", schema]];\n        }\n        if (self.migrationStatus != MigrationStatus_noMigration) {\n            [sqls insertObject:@\"BEGIN IMMEDIATE\" atIndex:0];\n            [sqls insertObject:[NSString stringWithFormat:@\"INSERT INTO %@testTable(mainId, subId, text, textMatchId, blob, blobMatchId) VALUES(?1, ?2, ?3, ?4, ?5, ?6)\", self.sourceSchema] atIndex:1];\n            [sqls insertObject:[NSString stringWithFormat:@\"DELETE FROM %@testTable WHERE rowid == ?1\", self.sourceSchema] atIndex:2];\n            [sqls addObject:@\"COMMIT\"];\n        }\n        CompressionTestObject* obj = [[Random shared] autoIncrementCompressionObject];\n        [self\n        executeModify:^BOOL(WCTTable* table) {\n            return [table insertObject:obj];\n        }\n              andSQLs:sqls];\n    }];\n}\n\n- (void)testInsertOrReplace\n{\n    [self doTestCompression:^{\n        NSMutableArray* sqls = [[NSMutableArray alloc] init];\n        NSString* schema = self.migrationStatus == MigrationStatus_noMigration ? @\"\" : @\"main.\";\n        if (!self.compressTwoColumn) {\n            [sqls addObject:[NSString stringWithFormat:@\"INSERT OR REPLACE INTO %@testTable(mainId, subId, text, textMatchId, blob, blobMatchId, WCDB_CT_text) VALUES(?1, ?2, ?3, ?4, ?5, ?6, ?7)\", schema]];\n        } else {\n            [sqls addObject:[NSString stringWithFormat:@\"INSERT OR REPLACE INTO %@testTable(mainId, subId, text, textMatchId, blob, blobMatchId, WCDB_CT_text, WCDB_CT_blob) VALUES(?1, ?2, ?3, ?4, ?5, ?6, ?7, ?8)\", schema]];\n        }\n        if (self.migrationStatus != MigrationStatus_noMigration) {\n            [sqls insertObject:@\"BEGIN IMMEDIATE\" atIndex:0];\n            [sqls insertObject:[NSString stringWithFormat:@\"INSERT OR REPLACE INTO %@testTable(mainId, subId, text, textMatchId, blob, blobMatchId) VALUES(?1, ?2, ?3, ?4, ?5, ?6)\", self.sourceSchema] atIndex:1];\n            [sqls insertObject:[NSString stringWithFormat:@\"DELETE FROM %@testTable WHERE rowid == ?1\", self.sourceSchema] atIndex:2];\n            [sqls addObject:@\"COMMIT\"];\n        }\n        CompressionTestObject* obj = [[Random shared] compressionObjectWithId:1];\n        [self\n        executeModify:^BOOL(WCTTable* table) {\n            return [table insertOrReplaceObject:obj];\n        }\n              andSQLs:sqls];\n    }];\n}\n\n- (void)testInsertOrIgnore\n{\n    [self doTestCompression:^{\n        NSMutableArray* sqls = [[NSMutableArray alloc] init];\n        NSString* schema = self.migrationStatus == MigrationStatus_noMigration ? @\"\" : @\"main.\";\n        if (!self.compressTwoColumn) {\n            [sqls addObject:[NSString stringWithFormat:@\"INSERT OR IGNORE INTO %@testTable(mainId, subId, text, textMatchId, blob, blobMatchId, WCDB_CT_text) VALUES(?1, ?2, ?3, ?4, ?5, ?6, ?7)\", schema]];\n        } else {\n            [sqls addObject:[NSString stringWithFormat:@\"INSERT OR IGNORE INTO %@testTable(mainId, subId, text, textMatchId, blob, blobMatchId, WCDB_CT_text, WCDB_CT_blob) VALUES(?1, ?2, ?3, ?4, ?5, ?6, ?7, ?8)\", schema]];\n        }\n        if (self.migrationStatus != MigrationStatus_noMigration) {\n            [sqls insertObject:@\"BEGIN IMMEDIATE\" atIndex:0];\n            if (self.migrationStatus == MigrationStatus_startMigrate) {\n                [sqls insertObject:[NSString stringWithFormat:@\"INSERT OR IGNORE INTO %@testTable(mainId, subId, text, textMatchId, blob, blobMatchId) VALUES(?1, ?2, ?3, ?4, ?5, ?6)\", self.sourceSchema] atIndex:1];\n                [sqls insertObject:[NSString stringWithFormat:@\"DELETE FROM %@testTable WHERE rowid == ?1\", self.sourceSchema] atIndex:2];\n            }\n            [sqls addObject:@\"COMMIT\"];\n        }\n        CompressionTestObject* obj = [[Random shared] compressionObjectWithId:1999];\n        [self\n        executeModify:^BOOL(WCTTable* table) {\n            return [table insertOrIgnoreObject:obj];\n        }\n              andSQLs:sqls];\n    }];\n}\n\n- (void)testInsertWithUpsert\n{\n    [self doTestCompression:^{\n        NSMutableArray* sqls = [[NSMutableArray alloc] init];\n        NSString* schema = self.migrationStatus == MigrationStatus_noMigration ? @\"\" : @\"main.\";\n        if (!self.compressTwoColumn) {\n            [sqls addObject:[NSString stringWithFormat:@\"INSERT INTO %@testTable(mainId, subId, text, textMatchId, blob, blobMatchId) VALUES(?1, ?2, ?3, ?4, ?5, ?6) ON CONFLICT(mainId) DO UPDATE SET text = ?3, WCDB_CT_text = NULL WHERE wcdb_decompress(text, WCDB_CT_text) LIKE '%%a%%'\", schema]];\n            if (self.mode == CompressionMode_VariousDict) {\n                [sqls addObject:@\"SELECT text, WCDB_CT_text, textMatchId FROM testTable WHERE rowid == ?\"];\n            } else {\n                [sqls addObject:@\"SELECT text, WCDB_CT_text FROM testTable WHERE rowid == ?\"];\n            }\n            [sqls addObject:@\"UPDATE testTable SET text = ?2, WCDB_CT_text = ?3 WHERE rowid == ?1\"];\n\n        } else {\n            [sqls addObject:[NSString stringWithFormat:@\"INSERT INTO %@testTable(mainId, subId, text, textMatchId, blob, blobMatchId) VALUES(?1, ?2, ?3, ?4, ?5, ?6) ON CONFLICT(mainId) DO UPDATE SET text = ?3, WCDB_CT_text = NULL WHERE wcdb_decompress(text, WCDB_CT_text) LIKE '%%a%%'\", schema]];\n            if (self.mode == CompressionMode_VariousDict) {\n                [sqls addObject:@\"SELECT text, WCDB_CT_text, textMatchId, blob, WCDB_CT_blob, blobMatchId FROM testTable WHERE rowid == ?\"];\n            } else {\n                [sqls addObject:@\"SELECT text, WCDB_CT_text, blob, WCDB_CT_blob FROM testTable WHERE rowid == ?\"];\n            }\n            [sqls addObject:@\"UPDATE testTable SET text = ?2, WCDB_CT_text = ?3, blob = ?4, WCDB_CT_blob = ?5 WHERE rowid == ?1\"];\n        }\n        if (self.migrationStatus != MigrationStatus_noMigration) {\n            [sqls insertObject:@\"BEGIN IMMEDIATE\" atIndex:0];\n            [sqls insertObject:[NSString stringWithFormat:@\"INSERT INTO %@testTable(mainId, subId, text, textMatchId, blob, blobMatchId) VALUES(?1, ?2, ?3, ?4, ?5, ?6) ON CONFLICT(mainId) DO UPDATE SET text = ?3 WHERE text LIKE '%%a%%'\", self.sourceSchema] atIndex:1];\n            [sqls insertObject:[NSString stringWithFormat:@\"DELETE FROM %@testTable WHERE rowid == ?1\", self.sourceSchema] atIndex:2];\n            [sqls addObject:@\"COMMIT\"];\n        }\n\n        CompressionTestObject* obj = [[Random shared] compressionObjectWithId:1999];\n        __block WCDB::StatementInsert insert;\n        insert.columns(CompressionTestObject.allProperties).values(WCDB::BindParameter::bindParameters(CompressionTestObject.allProperties.size()));\n        WCDB::Upsert upsert = WCDB::Upsert().onConflict().indexed(CompressionTestObject.mainId).doUpdate().set(CompressionTestObject.text).to(WCDB::BindParameter(3));\n        upsert.where(CompressionTestObject.text.like(@\"%a%\"));\n        insert.upsert(upsert);\n        [self\n        executeModify:^BOOL(WCTTable* table) {\n            insert.insertIntoTable(table.tableName);\n            WCTHandle* handle = [table.database getHandle];\n            TestCaseAssertTrue([handle prepare:insert]);\n            [handle bindProperties:CompressionTestObject.allProperties ofObject:obj];\n            TestCaseAssertTrue([handle step]);\n            [handle finalizeStatement];\n            [handle invalidate];\n            return true;\n        }\n              andSQLs:sqls];\n    }];\n}\n\n- (void)testInsertWithSelect\n{\n    [self doTestCompression:^{\n        if (self.migrationStatus != MigrationStatus_noMigration) {\n            return;\n        }\n        NSMutableArray* sqls = [[NSMutableArray alloc] init];\n        if (self.compressTwoColumn) {\n            [sqls addObject:@\"INSERT OR REPLACE INTO testTable(mainId, subId, text, textMatchId, blob, blobMatchId) SELECT mainId, subId, wcdb_decompress(text, WCDB_CT_text) AS text, textMatchId, wcdb_decompress(blob, WCDB_CT_blob) AS blob, blobMatchId FROM testTable WHERE wcdb_decompress(text, WCDB_CT_text) LIKE '%a%' ORDER BY mainId DESC LIMIT 1\"];\n            if (self.mode == CompressionMode_VariousDict) {\n                [sqls addObject:@\"SELECT text, WCDB_CT_text, textMatchId, blob, WCDB_CT_blob, blobMatchId FROM testTable WHERE rowid == ?\"];\n            } else {\n                [sqls addObject:@\"SELECT text, WCDB_CT_text, blob, WCDB_CT_blob FROM testTable WHERE rowid == ?\"];\n            }\n            [sqls addObject:@\"UPDATE testTable SET text = ?2, WCDB_CT_text = ?3, blob = ?4, WCDB_CT_blob = ?5 WHERE rowid == ?1\"];\n        } else {\n            [sqls addObject:@\"INSERT OR REPLACE INTO testTable(mainId, subId, text, textMatchId, blob, blobMatchId) SELECT mainId, subId, wcdb_decompress(text, WCDB_CT_text) AS text, textMatchId, blob, blobMatchId FROM testTable WHERE wcdb_decompress(text, WCDB_CT_text) LIKE '%a%' ORDER BY mainId DESC LIMIT 1\"];\n            if (self.mode == CompressionMode_VariousDict) {\n                [sqls addObject:@\"SELECT text, WCDB_CT_text, textMatchId FROM testTable WHERE rowid == ?\"];\n            } else {\n                [sqls addObject:@\"SELECT text, WCDB_CT_text FROM testTable WHERE rowid == ?\"];\n            }\n            [sqls addObject:@\"UPDATE testTable SET text = ?2, WCDB_CT_text = ?3 WHERE rowid == ?1\"];\n        }\n\n        WCDB::StatementSelect select;\n        select.select(CompressionTestObject.allProperties).from(self.tableName).where(CompressionTestObject.text.like(@\"%a%\")).order(CompressionTestObject.mainId.asOrder(WCDB::Order::DESC)).limit(1);\n        __block WCDB::StatementInsert insert;\n        insert.orReplace().columns(CompressionTestObject.allProperties).values(select);\n        [self\n        executeModify:^BOOL(WCTTable* table) {\n            insert.insertIntoTable(table.tableName);\n            return [table.database execute:insert];\n        }\n              andSQLs:sqls];\n    }];\n}\n\n- (void)testUpdate\n{\n    [self doTestCompression:^{\n        NSMutableArray* sqls = [[NSMutableArray alloc] init];\n        if (self.migrationStatus != MigrationStatus_noMigration) {\n            [sqls addObject:@\"BEGIN IMMEDIATE\"];\n            [sqls addObject:@\"SELECT mainId FROM temp.wcdb_union_testTable WHERE mainId == 1\"];\n            [sqls addObject:[NSString stringWithFormat:@\"UPDATE %@testTable SET subId = ?1 WHERE mainId == ?2\", self.sourceSchema]];\n            [sqls addObject:@\"UPDATE main.testTable SET subId = ?1 WHERE mainId == ?2\"];\n            [sqls addObject:@\"COMMIT\"];\n        } else {\n            [sqls addObject:@\"UPDATE testTable SET subId = ?1 WHERE mainId == 1\"];\n        }\n        [self\n        executeModify:^BOOL(WCTTable* table) {\n            return [table updateProperty:CompressionTestObject.subId toValue:@1 where:CompressionTestObject.mainId == 1];\n        }\n              andSQLs:sqls];\n    }];\n}\n\n- (void)testUpdateCompressingColumn\n{\n    [self doTestCompression:^{\n        NSMutableArray* sqls = [[NSMutableArray alloc] init];\n        if (self.migrationStatus != MigrationStatus_noMigration) {\n            [sqls addObject:@\"BEGIN IMMEDIATE\"];\n            [sqls addObject:@\"SELECT mainId FROM temp.wcdb_union_testTable WHERE text LIKE '%a%' ORDER BY mainId DESC LIMIT 20 OFFSET 5\"];\n            [sqls addObject:[NSString stringWithFormat:@\"UPDATE %@testTable SET text = ?1, blob = ?2 WHERE mainId == ?3\", self.sourceSchema]];\n            if (self.compressTwoColumn) {\n                if (self.mode == CompressionMode_VariousDict) {\n                    [sqls addObject:@\"SELECT rowid, textMatchId, blobMatchId FROM testTable WHERE mainId == ?3\"];\n                    if (self.migrationStatus == MigrationStatus_startMigrate) {\n                        [sqls addObject:@\"UPDATE main.testTable SET text = ?1, blob = ?2, WCDB_CT_text = ?4, WCDB_CT_blob = ?5 WHERE rowid == ?6\"];\n                    }\n                } else {\n                    [sqls addObject:@\"UPDATE main.testTable SET text = ?1, blob = ?2, WCDB_CT_text = ?4, WCDB_CT_blob = ?5 WHERE mainId == ?3\"];\n                }\n            } else {\n                if (self.mode == CompressionMode_VariousDict) {\n                    [sqls addObject:@\"SELECT rowid, textMatchId FROM testTable WHERE mainId == ?3\"];\n                    if (self.migrationStatus == MigrationStatus_startMigrate) {\n                        [sqls addObject:@\"UPDATE main.testTable SET text = ?1, blob = ?2, WCDB_CT_text = ?4 WHERE rowid == ?5\"];\n                    }\n                } else {\n                    [sqls addObject:@\"UPDATE main.testTable SET text = ?1, blob = ?2, WCDB_CT_text = ?4 WHERE mainId == ?3\"];\n                }\n            }\n            [sqls addObject:@\"COMMIT\"];\n        } else {\n            if (self.compressTwoColumn) {\n                if (self.mode == CompressionMode_VariousDict) {\n                    [sqls addObject:@\"SELECT rowid, textMatchId, blobMatchId FROM testTable WHERE wcdb_decompress(text, WCDB_CT_text) LIKE '%a%' ORDER BY mainId DESC LIMIT 20 OFFSET 5\"];\n                    [sqls addObject:@\"UPDATE testTable SET text = ?1, blob = ?2, WCDB_CT_text = ?3, WCDB_CT_blob = ?4 WHERE rowid == ?5\"];\n                } else {\n                    [sqls addObject:@\"UPDATE testTable SET text = ?1, blob = ?2, WCDB_CT_text = ?3, WCDB_CT_blob = ?4 WHERE wcdb_decompress(text, WCDB_CT_text) LIKE '%a%' ORDER BY mainId DESC LIMIT 20 OFFSET 5\"];\n                }\n            } else {\n                if (self.mode == CompressionMode_VariousDict) {\n                    [sqls addObject:@\"SELECT rowid, textMatchId FROM testTable WHERE wcdb_decompress(text, WCDB_CT_text) LIKE '%a%' ORDER BY mainId DESC LIMIT 20 OFFSET 5\"];\n                    [sqls addObject:@\"UPDATE testTable SET text = ?1, blob = ?2, WCDB_CT_text = ?3 WHERE rowid == ?4\"];\n                } else {\n                    [sqls addObject:@\"UPDATE testTable SET text = ?1, blob = ?2, WCDB_CT_text = ?3 WHERE wcdb_decompress(text, WCDB_CT_text) LIKE '%a%' ORDER BY mainId DESC LIMIT 20 OFFSET 5\"];\n                }\n            }\n        }\n        CompressionTestObject* obj = [Random.shared autoIncrementCompressionObject];\n        [self\n        executeModify:^BOOL(WCTTable* table) {\n            return [table updateProperties:{ CompressionTestObject.text, CompressionTestObject.blob } toObject:obj where:CompressionTestObject.text.like(@\"%a%\") orders:CompressionTestObject.mainId.asOrder(WCTOrderedDescending) limit:20 offset:5];\n        }\n              andSQLs:sqls];\n    }];\n}\n\n- (void)testUpdateCompressingColumnWithMatchType\n{\n    [self doTestCompression:^{\n        NSMutableArray* sqls = [[NSMutableArray alloc] init];\n        if (self.migrationStatus != MigrationStatus_noMigration) {\n            [sqls addObject:@\"BEGIN IMMEDIATE\"];\n            [sqls addObject:@\"SELECT mainId FROM temp.wcdb_union_testTable WHERE text LIKE '%a%' ORDER BY mainId DESC LIMIT 20 OFFSET 5\"];\n            [sqls addObject:[NSString stringWithFormat:@\"UPDATE %@testTable SET text = ?1, blob = ?2, textMatchId = ?3, blobMatchId = ?4 WHERE mainId == ?5\", self.sourceSchema]];\n            if (self.compressTwoColumn) {\n                [sqls addObject:@\"UPDATE main.testTable SET text = ?1, blob = ?2, textMatchId = ?3, blobMatchId = ?4, WCDB_CT_text = ?6, WCDB_CT_blob = ?7 WHERE mainId == ?5\"];\n            } else {\n                [sqls addObject:@\"UPDATE main.testTable SET text = ?1, blob = ?2, textMatchId = ?3, blobMatchId = ?4, WCDB_CT_text = ?6 WHERE mainId == ?5\"];\n            }\n            [sqls addObject:@\"COMMIT\"];\n        } else {\n            if (self.compressTwoColumn) {\n                [sqls addObject:@\"UPDATE testTable SET text = ?1, blob = ?2, textMatchId = ?3, blobMatchId = ?4, WCDB_CT_text = ?5, WCDB_CT_blob = ?6 WHERE wcdb_decompress(text, WCDB_CT_text) LIKE '%a%' ORDER BY mainId DESC LIMIT 20 OFFSET 5\"];\n            } else {\n                [sqls addObject:@\"UPDATE testTable SET text = ?1, blob = ?2, textMatchId = ?3, blobMatchId = ?4, WCDB_CT_text = ?5 WHERE wcdb_decompress(text, WCDB_CT_text) LIKE '%a%' ORDER BY mainId DESC LIMIT 20 OFFSET 5\"];\n            }\n        }\n        CompressionTestObject* obj = [Random.shared autoIncrementCompressionObject];\n        [self\n        executeModify:^BOOL(WCTTable* table) {\n            return [table updateProperties:{ CompressionTestObject.text,\n                                             CompressionTestObject.blob,\n                                             CompressionTestObject.textMatchId,\n                                             CompressionTestObject.blobMatchId }\n                                  toObject:obj\n                                     where:CompressionTestObject.text.like(@\"%a%\")\n                                    orders:CompressionTestObject.mainId.asOrder(WCTOrderedDescending)\n                                     limit:20\n                                    offset:5];\n        }\n              andSQLs:sqls];\n    }];\n}\n\n- (void)testUpdateCompressingColumnWithValue\n{\n    __block WCDB::StatementUpdate update;\n    update.set(CompressionTestObject.text).to(\"abc\").where(CompressionTestObject.text.like(\"%without%\")).order(CompressionTestObject.mainId.asOrder(WCDB::Order::DESC)).limit(20).offset(5);\n    [self doTestCompression:^{\n        NSMutableArray* sqls = [[NSMutableArray alloc] init];\n        if (self.migrationStatus != MigrationStatus_noMigration) {\n            [sqls addObject:@\"BEGIN IMMEDIATE\"];\n            [sqls addObject:@\"SELECT mainId FROM temp.wcdb_union_testTable WHERE text LIKE '%without%' ORDER BY mainId DESC LIMIT 20 OFFSET 5\"];\n            [sqls addObject:[NSString stringWithFormat:@\"UPDATE %@testTable SET text = 'abc' WHERE mainId == ?1\", self.sourceSchema]];\n            [sqls addObject:@\"SELECT rowid FROM testTable WHERE mainId == ?1\"];\n            if (self.migrationStatus == MigrationStatus_startMigrate) {\n                [sqls addObject:@\"UPDATE main.testTable SET text = 'abc', WCDB_CT_text = NULL WHERE rowid == ?2\"];\n                if (self.mode == CompressionMode_VariousDict) {\n                    [sqls addObject:@\"SELECT text, WCDB_CT_text, textMatchId FROM testTable WHERE rowid == ?\"];\n                } else {\n                    [sqls addObject:@\"SELECT text, WCDB_CT_text FROM testTable WHERE rowid == ?\"];\n                }\n            }\n            [sqls addObject:@\"COMMIT\"];\n        } else {\n            [sqls addObject:@\"BEGIN IMMEDIATE\"];\n            [sqls addObject:@\"SELECT rowid FROM testTable WHERE wcdb_decompress(text, WCDB_CT_text) LIKE '%without%' ORDER BY mainId DESC LIMIT 20 OFFSET 5\"];\n            [sqls addObject:@\"UPDATE testTable SET text = 'abc', WCDB_CT_text = NULL WHERE rowid == ?1\"];\n            if (self.mode == CompressionMode_VariousDict) {\n                [sqls addObject:@\"SELECT text, WCDB_CT_text, textMatchId FROM testTable WHERE rowid == ?\"];\n            } else {\n                [sqls addObject:@\"SELECT text, WCDB_CT_text FROM testTable WHERE rowid == ?\"];\n            }\n            [sqls addObject:@\"COMMIT\"];\n        }\n\n        [self\n        executeModify:^BOOL(WCTTable* table) {\n            update.update(table.tableName);\n            return [table.database execute:update];\n        }\n              andSQLs:sqls];\n    }];\n}\n\n- (void)testUpdateCompressingColumnWithMultiValue\n{\n    __block WCDB::StatementUpdate update;\n    update.set({ CompressionTestObject.text, CompressionTestObject.textMatchId }).to(WCDB::Expression({ \"abc\", 1 })).where(CompressionTestObject.text.like(\"%without%\")).order(CompressionTestObject.mainId.asOrder(WCDB::Order::DESC)).limit(20).offset(5);\n    [self doTestCompression:^{\n        NSMutableArray* sqls = [[NSMutableArray alloc] init];\n        if (self.migrationStatus != MigrationStatus_noMigration) {\n            [sqls addObject:@\"BEGIN IMMEDIATE\"];\n            [sqls addObject:@\"SELECT mainId FROM temp.wcdb_union_testTable WHERE text LIKE '%without%' ORDER BY mainId DESC LIMIT 20 OFFSET 5\"];\n            [sqls addObject:[NSString stringWithFormat:@\"UPDATE %@testTable SET (text, textMatchId) = ('abc', 1) WHERE mainId == ?1\", self.sourceSchema]];\n            [sqls addObject:@\"SELECT rowid FROM testTable WHERE mainId == ?1\"];\n            if (self.migrationStatus == MigrationStatus_startMigrate) {\n                [sqls addObject:@\"UPDATE main.testTable SET (text, textMatchId) = ('abc', 1), WCDB_CT_text = NULL WHERE rowid == ?2\"];\n                if (self.mode == CompressionMode_VariousDict) {\n                    [sqls addObject:@\"SELECT text, WCDB_CT_text, textMatchId FROM testTable WHERE rowid == ?\"];\n                } else {\n                    [sqls addObject:@\"SELECT text, WCDB_CT_text FROM testTable WHERE rowid == ?\"];\n                }\n            }\n            [sqls addObject:@\"COMMIT\"];\n        } else {\n            [sqls addObject:@\"BEGIN IMMEDIATE\"];\n            [sqls addObject:@\"SELECT rowid FROM testTable WHERE wcdb_decompress(text, WCDB_CT_text) LIKE '%without%' ORDER BY mainId DESC LIMIT 20 OFFSET 5\"];\n            [sqls addObject:@\"UPDATE testTable SET (text, textMatchId) = ('abc', 1), WCDB_CT_text = NULL WHERE rowid == ?1\"];\n            if (self.mode == CompressionMode_VariousDict) {\n                [sqls addObject:@\"SELECT text, WCDB_CT_text, textMatchId FROM testTable WHERE rowid == ?\"];\n            } else {\n                [sqls addObject:@\"SELECT text, WCDB_CT_text FROM testTable WHERE rowid == ?\"];\n            }\n            [sqls addObject:@\"COMMIT\"];\n        }\n\n        [self\n        executeModify:^BOOL(WCTTable* table) {\n            update.update(table.tableName);\n            return [table.database execute:update];\n        }\n              andSQLs:sqls];\n    }];\n}\n\n- (void)testDelete\n{\n    [self doTestCompression:^{\n        NSMutableArray* sqls = [[NSMutableArray alloc] init];\n        if (self.migrationStatus != MigrationStatus_noMigration) {\n            [sqls addObject:@\"BEGIN IMMEDIATE\"];\n            [sqls addObject:@\"SELECT mainId FROM temp.wcdb_union_testTable WHERE textMatchId == 2 ORDER BY subId ASC LIMIT 10 OFFSET 10\"];\n            [sqls addObject:[NSString stringWithFormat:@\"DELETE FROM %@testTable WHERE mainId == ?1\", self.sourceSchema]];\n            [sqls addObject:@\"DELETE FROM main.testTable WHERE mainId == ?1\"];\n            [sqls addObject:@\"COMMIT\"];\n        } else {\n            [sqls addObject:@\"DELETE FROM testTable WHERE textMatchId == 2 ORDER BY subId ASC LIMIT 10 OFFSET 10\"];\n        }\n\n        [self\n        executeModify:^BOOL(WCTTable* table) {\n            return [table deleteObjectsWhere:CompressionTestObject.textMatchId == 2 orders:CompressionTestObject.subId.asOrder(WCDB::Order::ASC) limit:10 offset:10];\n        }\n              andSQLs:sqls];\n    }];\n}\n\n- (void)testDeleteWithCompressingColumn\n{\n    [self doTestCompression:^{\n        NSMutableArray* sqls = [[NSMutableArray alloc] init];\n        if (self.migrationStatus != MigrationStatus_noMigration) {\n            [sqls addObject:@\"BEGIN IMMEDIATE\"];\n            [sqls addObject:@\"SELECT mainId FROM temp.wcdb_union_testTable WHERE text LIKE '%because%' ORDER BY subId ASC LIMIT 10 OFFSET 10\"];\n            [sqls addObject:[NSString stringWithFormat:@\"DELETE FROM %@testTable WHERE mainId == ?1\", self.sourceSchema]];\n            [sqls addObject:@\"DELETE FROM main.testTable WHERE mainId == ?1\"];\n            [sqls addObject:@\"COMMIT\"];\n        } else {\n            [sqls addObject:@\"DELETE FROM testTable WHERE wcdb_decompress(text, WCDB_CT_text) LIKE '%because%' ORDER BY subId ASC LIMIT 10 OFFSET 10\"];\n        }\n        [self\n        executeModify:^BOOL(WCTTable* table) {\n            return [table deleteObjectsWhere:CompressionTestObject.text.like(\"%because%\") orders:CompressionTestObject.subId.asOrder(WCDB::Order::ASC) limit:10 offset:10];\n        }\n              andSQLs:sqls];\n    }];\n}\n\n- (void)testDeleteWithCommonTableExpression\n{\n    [self doTestCompression:^{\n        NSMutableArray* sqls = [[NSMutableArray alloc] init];\n        if (self.migrationStatus != MigrationStatus_noMigration) {\n            [sqls addObject:@\"BEGIN IMMEDIATE\"];\n            [sqls addObject:@\"WITH testAliasTable(text) AS(SELECT text FROM temp.wcdb_union_testTable WHERE text LIKE '%without%' ORDER BY mainId LIMIT 100) SELECT mainId FROM temp.wcdb_union_testTable WHERE EXISTS(SELECT 1 FROM testAliasTable WHERE temp.wcdb_union_testTable.text == testAliasTable.text)\"];\n            [sqls addObject:[NSString stringWithFormat:@\"DELETE FROM %@testTable WHERE mainId == ?1\", self.sourceSchema]];\n            [sqls addObject:@\"DELETE FROM main.testTable WHERE mainId == ?1\"];\n            [sqls addObject:@\"COMMIT\"];\n        } else {\n            [sqls addObject:@\"WITH testAliasTable(text) AS(SELECT wcdb_decompress(text, WCDB_CT_text) AS text FROM testTable WHERE wcdb_decompress(text, WCDB_CT_text) LIKE '%without%' ORDER BY mainId LIMIT 100) DELETE FROM testTable WHERE EXISTS(SELECT 1 FROM testAliasTable WHERE wcdb_decompress(testTable.text, testTable.WCDB_CT_text) == testAliasTable.text)\"];\n        }\n        [self\n        executeModify:^BOOL(WCTTable* table) {\n            WCDB::CommonTableExpression cte(\"testAliasTable\");\n            cte.column(CompressionTestObject.text);\n            cte.as(WCDB::StatementSelect()\n                   .select(CompressionTestObject.text)\n                   .from(table.tableName)\n                   .where(CompressionTestObject.text.like(\"%without%\"))\n                   .order(CompressionTestObject.mainId.asOrder())\n                   .limit(100));\n            WCDB::StatementSelect innerSelect = WCDB::StatementSelect().select(1).from(\"testAliasTable\").where(CompressionTestObject.text.table(table.tableName) == CompressionTestObject.text.table(\"testAliasTable\"));\n            WCTDelete* delete_ = [[table prepareDelete] where:WCDB::Expression::exists(innerSelect)];\n            delete_.statement.with(cte);\n            return [delete_ execute];\n        }\n              andSQLs:sqls];\n    }];\n}\n\n- (void)testSelect\n{\n    [self doTestCompression:^{\n        NSMutableArray* sqls = [[NSMutableArray alloc] init];\n        if (self.migrationStatus != MigrationStatus_noMigration) {\n            [sqls addObject:@\"SELECT mainId, subId, text, textMatchId, blob, blobMatchId FROM temp.wcdb_union_testTable WHERE text LIKE '%two%' ORDER BY text ASC LIMIT 100 OFFSET 100\"];\n        } else {\n            if (self.compressTwoColumn) {\n                [sqls addObject:@\"SELECT mainId, subId, wcdb_decompress(text, WCDB_CT_text) AS text, textMatchId, wcdb_decompress(blob, WCDB_CT_blob) AS blob, blobMatchId FROM testTable WHERE wcdb_decompress(text, WCDB_CT_text) LIKE '%two%' ORDER BY wcdb_decompress(text, WCDB_CT_text) ASC LIMIT 100 OFFSET 100\"];\n            } else {\n                [sqls addObject:@\"SELECT mainId, subId, wcdb_decompress(text, WCDB_CT_text) AS text, textMatchId, blob, blobMatchId FROM testTable WHERE wcdb_decompress(text, WCDB_CT_text) LIKE '%two%' ORDER BY wcdb_decompress(text, WCDB_CT_text) ASC LIMIT 100 OFFSET 100\"];\n            }\n        }\n        [self\n        executeSelect:^NSArray*(WCTTable* table) {\n            return [table getObjectsWhere:CompressionTestObject.text.like(\"%two%\") orders:CompressionTestObject.text.asOrder(WCDB::Order::ASC) limit:100 offset:100];\n        }\n              andSQLs:sqls];\n    }];\n}\n\n- (void)testSelectWithCommonTableExpression\n{\n    [self doTestCompression:^{\n        NSMutableArray* sqls = [[NSMutableArray alloc] init];\n        if (self.migrationStatus != MigrationStatus_noMigration) {\n            [sqls addObject:@\"WITH testAliasTable(mainId, subId, text, textMatchId, blob, blobMatchId) AS(SELECT mainId, subId, text, textMatchId, blob, blobMatchId FROM temp.wcdb_union_testTable WHERE text LIKE '%two%' LIMIT 100) SELECT mainId, subId, text, textMatchId, blob, blobMatchId FROM testAliasTable ORDER BY subId\"];\n        } else {\n            if (self.compressTwoColumn) {\n                [sqls addObject:@\"WITH testAliasTable(mainId, subId, text, textMatchId, blob, blobMatchId) AS(SELECT mainId, subId, wcdb_decompress(text, WCDB_CT_text) AS text, textMatchId, wcdb_decompress(blob, WCDB_CT_blob) AS blob, blobMatchId FROM testTable WHERE wcdb_decompress(text, WCDB_CT_text) LIKE '%two%' LIMIT 100) SELECT mainId, subId, text, textMatchId, blob, blobMatchId FROM testAliasTable ORDER BY subId\"];\n            } else {\n                [sqls addObject:@\"WITH testAliasTable(mainId, subId, text, textMatchId, blob, blobMatchId) AS(SELECT mainId, subId, wcdb_decompress(text, WCDB_CT_text) AS text, textMatchId, blob, blobMatchId FROM testTable WHERE wcdb_decompress(text, WCDB_CT_text) LIKE '%two%' LIMIT 100) SELECT mainId, subId, text, textMatchId, blob, blobMatchId FROM testAliasTable ORDER BY subId\"];\n            }\n        }\n        [self\n        executeSelect:^NSArray*(WCTTable* table) {\n            WCTSelect* select = [[[table prepareSelect] fromTable:@\"testAliasTable\"] orders:CompressionTestObject.subId.asOrder()];\n            WCDB::CommonTableExpression cte(\"testAliasTable\");\n            cte.column(CompressionTestObject.mainId);\n            cte.column(CompressionTestObject.subId);\n            cte.column(CompressionTestObject.text);\n            cte.column(CompressionTestObject.textMatchId);\n            cte.column(CompressionTestObject.blob);\n            cte.column(CompressionTestObject.blobMatchId);\n            cte.as(WCDB::StatementSelect()\n                   .select(CompressionTestObject.allProperties)\n                   .from(table.tableName)\n                   .where(CompressionTestObject.text.like(\"%two%\"))\n                   .limit(100));\n            select.statement.with(cte);\n\n            return select.allObjects;\n        }\n              andSQLs:sqls];\n    }];\n}\n\n- (void)testSelectFromSubquery\n{\n    [self doTestCompression:^{\n        NSMutableArray* sqls = [[NSMutableArray alloc] init];\n        if (self.migrationStatus != MigrationStatus_noMigration) {\n            [sqls addObject:@\"SELECT mainId, subId, text, textMatchId, blob, blobMatchId FROM (SELECT mainId, subId, text, textMatchId, blob, blobMatchId FROM temp.wcdb_union_testTable WHERE (text LIKE '%two%') AND (blobMatchId == 2)) AS subquery ORDER BY subId\"];\n        } else {\n            if (self.compressTwoColumn) {\n                [sqls addObject:@\"SELECT mainId, subId, text, textMatchId, blob, blobMatchId FROM (SELECT mainId, subId, wcdb_decompress(text, WCDB_CT_text) AS text, textMatchId, wcdb_decompress(blob, WCDB_CT_blob) AS blob, blobMatchId FROM testTable WHERE (wcdb_decompress(text, WCDB_CT_text) LIKE '%two%') AND (blobMatchId == 2)) AS subquery ORDER BY subId\"];\n            } else {\n                [sqls addObject:@\"SELECT mainId, subId, text, textMatchId, blob, blobMatchId FROM (SELECT mainId, subId, wcdb_decompress(text, WCDB_CT_text) AS text, textMatchId, blob, blobMatchId FROM testTable WHERE (wcdb_decompress(text, WCDB_CT_text) LIKE '%two%') AND (blobMatchId == 2)) AS subquery ORDER BY subId\"];\n            }\n        }\n        [self\n        executeSelect:^NSArray*(WCTTable* table) {\n            WCTSelect* select = [[[table prepareSelect] fromTable:@\"subquery\"] orders:CompressionTestObject.subId.asOrder()];\n            WCDB::StatementSelect subquery;\n            subquery.select(CompressionTestObject.allProperties).from(table.tableName).where(CompressionTestObject.text.like(\"%two%\") && CompressionTestObject.blobMatchId == 2);\n            select.statement.from(subquery.as(@\"subquery\"));\n            return select.allObjects;\n        }\n              andSQLs:sqls];\n    }];\n}\n\n- (void)testSelectWithSubquery\n{\n    [self doTestCompression:^{\n        NSMutableArray* sqls = [[NSMutableArray alloc] init];\n        if (self.migrationStatus != MigrationStatus_noMigration) {\n            [sqls addObject:@\"SELECT mainId, subId, text, textMatchId, blob, blobMatchId FROM temp.wcdb_union_testTable WHERE text IN(SELECT text FROM temp.wcdb_union_testTable WHERE (text LIKE '%two%') AND (blobMatchId == 2)) ORDER BY subId\"];\n        } else {\n            if (self.compressTwoColumn) {\n                [sqls addObject:@\"SELECT mainId, subId, wcdb_decompress(text, WCDB_CT_text) AS text, textMatchId, wcdb_decompress(blob, WCDB_CT_blob) AS blob, blobMatchId FROM testTable WHERE wcdb_decompress(text, WCDB_CT_text) IN(SELECT wcdb_decompress(text, WCDB_CT_text) AS text FROM testTable WHERE (wcdb_decompress(text, WCDB_CT_text) LIKE '%two%') AND (blobMatchId == 2)) ORDER BY subId\"];\n            } else {\n                [sqls addObject:@\"SELECT mainId, subId, wcdb_decompress(text, WCDB_CT_text) AS text, textMatchId, blob, blobMatchId FROM testTable WHERE wcdb_decompress(text, WCDB_CT_text) IN(SELECT wcdb_decompress(text, WCDB_CT_text) AS text FROM testTable WHERE (wcdb_decompress(text, WCDB_CT_text) LIKE '%two%') AND (blobMatchId == 2)) ORDER BY subId\"];\n            }\n        }\n        [self\n        executeSelect:^NSArray*(WCTTable* table) {\n            WCTSelect* select = [[table prepareSelect] orders:CompressionTestObject.subId.asOrder()];\n            WCDB::StatementSelect subquery;\n            subquery.select(CompressionTestObject.text).from(table.tableName).where(CompressionTestObject.text.like(\"%two%\") && CompressionTestObject.blobMatchId == 2);\n            select.statement.where(CompressionTestObject.text.in(subquery));\n            return select.allObjects;\n        }\n              andSQLs:sqls];\n    }];\n}\n\n- (void)testSelectWithMultiTables\n{\n    [self doTestCompression:^{\n        NSString* newTable = @\"newTable\";\n        TestCaseAssertTrue([self.database createTable:newTable withClass:CompressionTestObject.class]);\n        TestCaseAssertTrue([self.database execute:WCDB::StatementInsert().insertIntoTable(newTable).columns(CompressionTestObject.allProperties).values(WCDB::StatementSelect().select(CompressionTestObject.allProperties).from(self.uncompressTableName))]);\n\n        NSMutableArray* sqls = [[NSMutableArray alloc] init];\n        if (self.migrationStatus != MigrationStatus_noMigration) {\n            [sqls addObject:@\"SELECT newTable.text, temp.wcdb_union_testTable.blob FROM temp.wcdb_union_testTable, newTable WHERE (newTable.text == temp.wcdb_union_testTable.text) AND (newTable.blobMatchId == 2) ORDER BY temp.wcdb_union_testTable.text\"];\n        } else {\n            if (self.compressTwoColumn) {\n                [sqls addObject:@\"SELECT newTable.text, wcdb_decompress(testTable.blob, testTable.WCDB_CT_blob) AS blob FROM testTable, newTable WHERE (newTable.text == wcdb_decompress(testTable.text, testTable.WCDB_CT_text)) AND (newTable.blobMatchId == 2) ORDER BY wcdb_decompress(testTable.text, testTable.WCDB_CT_text)\"];\n            } else {\n                [sqls addObject:@\"SELECT newTable.text, testTable.blob FROM testTable, newTable WHERE (newTable.text == wcdb_decompress(testTable.text, testTable.WCDB_CT_text)) AND (newTable.blobMatchId == 2) ORDER BY wcdb_decompress(testTable.text, testTable.WCDB_CT_text)\"];\n            }\n        }\n        [self\n        executeSelect:^NSArray*(WCTTable* table) {\n            WCTSelect* select = [[table prepareSelect] orders:CompressionTestObject.text.table(table.tableName).asOrder()];\n            [select onResultColumns:{ CompressionTestObject.text.table(newTable), CompressionTestObject.blob.table(table.tableName) }];\n            select.statement.from({ table.tableName, newTable }).where(CompressionTestObject.text.table(newTable) == CompressionTestObject.text.table(table.tableName) && CompressionTestObject.blobMatchId.table(newTable) == 2);\n            return select.allObjects;\n        }\n              andSQLs:sqls];\n    }];\n}\n\n- (void)testSelectWithJoin\n{\n    [self doTestCompression:^{\n        if (self.migrationStatus != MigrationStatus_noMigration) {\n            return;\n        }\n        NSString* newTable = @\"newTable\";\n        TestCaseAssertTrue([self.database createTable:newTable withClass:CompressionTestObject.class]);\n        TestCaseAssertTrue([self.database execute:WCDB::StatementInsert().insertIntoTable(newTable).columns(CompressionTestObject.allProperties).values(WCDB::StatementSelect().select(CompressionTestObject.allProperties).from(self.uncompressTableName))]);\n\n        NSMutableArray* sqls = [[NSMutableArray alloc] init];\n        if (self.compressTwoColumn) {\n            [sqls addObject:@\"SELECT testTable.text, newTable.blob FROM (SELECT wcdb_decompress(text, WCDB_CT_text) AS text, wcdb_decompress(blob, WCDB_CT_blob) AS blob FROM testTable WHERE textMatchId == 1) AS testTable JOIN (SELECT text, blob FROM newTable WHERE blobMatchId == 1) AS newTable ON testTable.text == newTable.text ORDER BY testTable.blob\"];\n        } else {\n            [sqls addObject:@\"SELECT testTable.text, newTable.blob FROM (SELECT wcdb_decompress(text, WCDB_CT_text) AS text, blob FROM testTable WHERE textMatchId == 1) AS testTable JOIN (SELECT text, blob FROM newTable WHERE blobMatchId == 1) AS newTable ON testTable.text == newTable.text ORDER BY testTable.blob\"];\n        }\n        [self\n        executeSelect:^NSArray*(WCTTable* table) {\n            WCTSelect* select = [[[table prepareSelect] onResultColumns:{ CompressionTestObject.text.table(table.tableName), CompressionTestObject.blob.table(newTable) }] orders:CompressionTestObject.blob.table(table.tableName)];\n            auto select1 = WCDB::StatementSelect().select({ CompressionTestObject.text, CompressionTestObject.blob }).from(table.tableName).where(CompressionTestObject.textMatchId == 1);\n            auto select2 = WCDB::StatementSelect().select({ CompressionTestObject.text, CompressionTestObject.blob }).from(newTable).where(CompressionTestObject.blobMatchId == 1);\n            WCDB::Join join;\n            join.table(select1.as(table.tableName)).join(select2.as(newTable)).on(CompressionTestObject.text.table(table.tableName) == CompressionTestObject.text.table(newTable));\n            select.statement.from(join);\n            return select.allObjects;\n        }\n              andSQLs:sqls];\n    }];\n}\n\n@end\n"
  },
  {
    "path": "src/objc/tests/compression/compatible/CompressionTests.mm",
    "content": "//\n// Created by qiuwenchen on 2023/12/7.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"CompressionRecord.hpp\"\n#import \"CompressionTestCase.h\"\n#import \"CoreConst.h\"\n#import \"Random+CompressionTestObject.h\"\n#import <Foundation/Foundation.h>\n#import <zstd/zstd.h>\n\n@interface CompressionTests : CompressionTestCase {\n    NSString* m_recordTable;\n}\n\n@end\n\n@implementation CompressionTests\n\n- (void)setUp\n{\n    [super setUp];\n    self.skipDebugLog = YES;\n    self.skipFullSQLTrace = YES;\n    self.expectMode = DatabaseTestCaseExpectSomeSQLs;\n    m_recordTable = @\"wcdb_builtin_compression_record\";\n}\n\n- (void)doTestCompress:(void (^)(void))operation\n{\n    for (int i = 0; i < 6; i++) {\n        self.anotherTable = nil;\n        [self clearData];\n        self.compressTwoColumn = (bool) (i % 2);\n        self.mode = (CompressionMode) (i / 2);\n        [self configCompression];\n        [self log:@\"execute compress test %d: mode %d, two column %d, compression status %d\",\n                  i,\n                  self.mode,\n                  self.compressTwoColumn,\n                  self.compressionStatus];\n        operation();\n    }\n}\n\n- (void)testDropTable\n{\n    [self clearData];\n    self.compressionStatus = CompressionStatus_finishCompressed;\n    [self configCompression];\n    WCTOneRow* record = [self.database getRowFromStatement:WCDB::StatementSelect().select(WCDB::Column::all()).from(m_recordTable)];\n    TestCaseAssertTrue(record.count == 3);\n    TestCaseAssertTrue([record[0].stringValue isEqualToString:self.tableName]);\n    TestCaseAssertTrue([record[1].stringValue isEqualToString:@\"text\"]);\n    TestCaseAssertTrue(record[2].numberValue.intValue == 0);\n    [self doTestSQLs:@[\n        @\"DROP TABLE IF EXISTS testTable\",\n        @\"DELETE FROM wcdb_builtin_compression_record WHERE tableName == 'testTable'\"\n    ]\n         inOperation:^BOOL {\n             return [self.database dropTable:self.table.tableName];\n         }];\n    WCTValue* count = [self.database getValueFromStatement:WCDB::StatementSelect().select(WCDB::Column::all().count()).from(m_recordTable)];\n    TestCaseAssertTrue(count.numberValue.intValue == 0);\n}\n\n- (void)testDropUncompressedTable\n{\n    [self clearData];\n    self.compressionStatus = CompressionStatus_uncompressed;\n    [self configCompression];\n    WCTOneRow* record = [self.database getRowFromStatement:WCDB::StatementSelect().select(WCDB::Column::all()).from(m_recordTable)];\n    TestCaseAssertNil(record);\n    [self doTestSQLs:@[\n        @\"DROP TABLE IF EXISTS testTable\",\n    ]\n         inOperation:^BOOL {\n             return [self.database dropTable:self.table.tableName];\n         }];\n}\n\n- (void)testRecreateTable\n{\n    [self clearData];\n    self.compressionStatus = CompressionStatus_finishCompressed;\n    [self configCompression];\n    WCTOneRow* record = [self.database getRowFromStatement:WCDB::StatementSelect().select(WCDB::Column::all()).from(m_recordTable)];\n    TestCaseAssertTrue(record.count == 3);\n    TestCaseAssertTrue([record[0].stringValue isEqualToString:self.tableName]);\n    TestCaseAssertTrue([record[1].stringValue isEqualToString:@\"text\"]);\n    TestCaseAssertTrue(record[2].numberValue.intValue == 0);\n    [self doTestSQLs:@[\n        @\"DROP TABLE IF EXISTS testTable\",\n        @\"DELETE FROM wcdb_builtin_compression_record WHERE tableName == 'testTable'\",\n        @\"CREATE TABLE IF NOT EXISTS testTable(mainId INTEGER PRIMARY KEY AUTOINCREMENT, subId REAL, text TEXT, textMatchId INTEGER, blob BLOB, blobMatchId INTEGER)\",\n        @\"ALTER TABLE main.testTable ADD COLUMN WCDB_CT_text INTEGER DEFAULT NULL\",\n        @\"INSERT INTO testTable(mainId, subId, text, textMatchId, blob, blobMatchId, WCDB_CT_text) VALUES(?1, ?2, ?3, ?4, ?5, ?6, ?7)\"\n    ]\n         inOperation:^BOOL {\n             TestCaseAssertTrue([self.database dropTable:self.table.tableName]);\n             TestCaseAssertTrue([self.database createTable:self.table.tableName withClass:self.table.tableClass]);\n             return [self.table insertObjects:self.originObjects];\n         }];\n    WCTValue* count = [self.database getValueFromStatement:WCDB::StatementSelect().select(WCDB::Column::all().count()).from(m_recordTable)];\n    TestCaseAssertTrue(count.numberValue.intValue == 0);\n}\n\n- (void)testAlterTable\n{\n    [self clearData];\n    self.compressionStatus = CompressionStatus_finishCompressed;\n    [self configCompression];\n    WCTOneRow* record = [self.database getRowFromStatement:WCDB::StatementSelect().select(WCDB::Column::all()).from(m_recordTable)];\n    TestCaseAssertTrue(record.count == 3);\n    TestCaseAssertTrue([record[0].stringValue isEqualToString:self.tableName]);\n    TestCaseAssertTrue([record[1].stringValue isEqualToString:@\"text\"]);\n    TestCaseAssertTrue(record[2].numberValue.intValue == 0);\n    [self doTestSQLs:@[\n        @\"ALTER TABLE testTable RENAME TO newTable\",\n        @\"UPDATE wcdb_builtin_compression_record SET tableName = 'newTable' WHERE tableName == 'testTable'\"\n    ]\n         inOperation:^BOOL {\n             return [self.database execute:WCDB::StatementAlterTable().alterTable(self.tableName).renameToTable(@\"newTable\")];\n         }];\n    record = [self.database getRowFromStatement:WCDB::StatementSelect().select(WCDB::Column::all()).from(m_recordTable)];\n    TestCaseAssertTrue(record.count == 3);\n    TestCaseAssertTrue([record[0].stringValue isEqualToString:@\"newTable\"]);\n    TestCaseAssertTrue([record[1].stringValue isEqualToString:@\"text\"]);\n    TestCaseAssertTrue(record[2].numberValue.intValue == 0);\n}\n\n- (void)testAlterUncompressedTable\n{\n    [self clearData];\n    self.compressionStatus = CompressionStatus_uncompressed;\n    [self configCompression];\n    WCTOneRow* record = [self.database getRowFromStatement:WCDB::StatementSelect().select(WCDB::Column::all()).from(m_recordTable)];\n    TestCaseAssertNil(record);\n    [self doTestSQLs:@[\n        @\"ALTER TABLE testTable RENAME TO newTable\"\n    ]\n         inOperation:^BOOL {\n             return [self.database execute:WCDB::StatementAlterTable().alterTable(self.tableName).renameToTable(@\"newTable\")];\n         }];\n}\n\n- (void)testCompressionType\n{\n    self.compressionStatus = CompressionStatus_finishCompressed;\n    [self doTestCompress:^{\n        WCTOneColumn* textCompressedTypes = [self.database getColumnFromStatement:WCDB::StatementSelect().select(WCDB::Column(\"WCDB_CT_text\")).distinct().from(self.tableName).order(WCDB::Column(\"WCDB_CT_text\").asOrder(WCDB::Order::ASC))];\n        TestCaseAssertTrue([textCompressedTypes count] == 2);\n        TestCaseAssertTrue(textCompressedTypes[0].numberValue.intValue == 0);\n        if (self.mode != CompressionMode_Normal) {\n            TestCaseAssertTrue(textCompressedTypes[1].numberValue.intValue == 2);\n        } else {\n            TestCaseAssertTrue(textCompressedTypes[1].numberValue.intValue == 4);\n        }\n        WCTValue* uncompressedTextCount = [self.database getValueFromStatement:WCDB::StatementSelect().select(WCDB::Column::all().count()).from(self.tableName).where(WCDB::Column(\"WCDB_CT_text\").isNull())];\n        TestCaseAssertTrue(uncompressedTextCount.numberValue.intValue == 0);\n        if (!self.compressTwoColumn) {\n            return;\n        }\n        WCTOneColumn* blobCompressedTypes = [self.database getColumnFromStatement:WCDB::StatementSelect().select(WCDB::Column(\"WCDB_CT_blob\")).distinct().from(self.tableName).order(WCDB::Column(\"WCDB_CT_blob\").asOrder(WCDB::Order::ASC))];\n        TestCaseAssertTrue([blobCompressedTypes count] == 2);\n        TestCaseAssertTrue(blobCompressedTypes[0].numberValue.intValue == 1);\n        if (self.mode != CompressionMode_Normal) {\n            TestCaseAssertTrue(blobCompressedTypes[1].numberValue.intValue == 3);\n        } else {\n            TestCaseAssertTrue(blobCompressedTypes[1].numberValue.intValue == 5);\n        }\n        WCTValue* uncompressedBlobCount = [self.database getValueFromStatement:WCDB::StatementSelect().select(WCDB::Column::all().count()).from(self.tableName).where(WCDB::Column(\"WCDB_CT_blob\").isNull())];\n        TestCaseAssertTrue(uncompressedBlobCount.numberValue.intValue == 0);\n    }];\n}\n\n- (void)testDisableCompressNewData\n{\n    self.compressionStatus = CompressionStatus_uncompressed;\n    [self.database disableCompresssNewData:YES];\n    [self doTestCompress:^{\n        NSArray* newObjects = [[Random shared] autoIncrementCompressionObjectWithCount:1000];\n        TestCaseAssertTrue([self.table insertObjects:newObjects]);\n\n        NSString* newContent = [[Random shared] englishString];\n        TestCaseAssertTrue([self.table updateProperty:CompressionTestObject.text toValue:newContent where:CompressionTestObject.textMatchId == 1]);\n\n        WCTValue* uncompressedTextCount = [self.database getValueFromStatement:WCDB::StatementSelect().select(WCDB::Column::all().count()).from(self.tableName).where(WCDB::Column(\"WCDB_CT_text\").isNull())];\n        TestCaseAssertTrue(uncompressedTextCount.numberValue.intValue == 1000 + self.originObjects.count);\n        if (!self.compressTwoColumn) {\n            return;\n        }\n        WCTValue* uncompressedBlobCount = [self.database getValueFromStatement:WCDB::StatementSelect().select(WCDB::Column::all().count()).from(self.tableName).where(WCDB::Column(\"WCDB_CT_blob\").isNull())];\n        TestCaseAssertTrue(uncompressedBlobCount.numberValue.intValue == 1000 + self.originObjects.count);\n    }];\n    [self.database disableCompresssNewData:NO];\n}\n\n- (void)testCompressDict\n{\n    self.compressionStatus = CompressionStatus_finishCompressed;\n    [self doTestCompress:^{\n        [self.database setCompressionWithFilter:nil];\n        WCDB::ResultColumns textColumns = { CompressionTestObject.text, WCDB::Column(\"WCDB_CT_text\") };\n        if (self.mode == CompressionMode_VariousDict) {\n            textColumns.push_back(CompressionTestObject.textMatchId);\n        }\n        WCTColumnsXRows* allTexts = [self.database getRowsFromStatement:WCDB::StatementSelect().select(textColumns).from(self.tableName)];\n        TestCaseAssertTrue(allTexts.count == self.originObjects.count);\n        for (WCTOneRow* row in allTexts) {\n            TestCaseAssertTrue(row.count >= 2);\n            TestCaseAssertTrue(row[1] != [NSNull null]);\n            if (row[1].numberValue.intValue == 0) {\n                continue;\n            }\n            TestCaseAssertTrue([row[0] isKindOfClass:NSData.class]);\n            int dictId = ZSTD_getDictID_fromFrame(row[0].dataValue.bytes, row[0].dataValue.length);\n            if (self.mode == CompressionMode_Normal) {\n                TestCaseAssertTrue(dictId == 0);\n            } else if (self.mode == CompressionMode_Dict) {\n                TestCaseAssertTrue(dictId == 1);\n            } else {\n                TestCaseAssertTrue(row.count == 3);\n                NSNumber* expectedDictId = [self.matchDictForText objectForKey:row[2].numberValue];\n                if (expectedDictId == nil) {\n                    expectedDictId = [self.matchDictForText objectForKey:@WCTDictDefaultMatchValue];\n                }\n                TestCaseAssertTrue(expectedDictId.intValue == dictId);\n            }\n        }\n\n        if (!self.compressTwoColumn) {\n            return;\n        }\n        WCDB::ResultColumns blobColumns = { CompressionTestObject.blob, WCDB::Column(\"WCDB_CT_blob\") };\n        if (self.mode == CompressionMode_VariousDict) {\n            blobColumns.push_back(CompressionTestObject.blobMatchId);\n        }\n        WCTColumnsXRows* allBlobs = [self.database getRowsFromStatement:WCDB::StatementSelect().select(blobColumns).from(self.tableName)];\n        TestCaseAssertTrue(allBlobs.count == self.originObjects.count);\n        for (WCTOneRow* row in allBlobs) {\n            TestCaseAssertTrue(row.count >= 2);\n            TestCaseAssertTrue(row[1] != [NSNull null]);\n            if (row[1].numberValue.intValue == 1) {\n                continue;\n            }\n            TestCaseAssertTrue([row[0] isKindOfClass:NSData.class]);\n            int dictId = ZSTD_getDictID_fromFrame(row[0].dataValue.bytes, row[0].dataValue.length);\n            if (self.mode == CompressionMode_Normal) {\n                TestCaseAssertTrue(dictId == 0);\n            } else if (self.mode == CompressionMode_Dict) {\n                TestCaseAssertTrue(dictId == 1);\n            } else {\n                TestCaseAssertTrue(row.count == 3);\n                NSNumber* expectedDictId = [self.matchDictForBLOB objectForKey:row[2].numberValue];\n                if (expectedDictId == nil) {\n                    expectedDictId = [self.matchDictForBLOB objectForKey:@WCTDictDefaultMatchValue];\n                }\n                TestCaseAssertTrue(expectedDictId.intValue == dictId);\n            }\n        }\n    }];\n}\n\n- (void)testCompress\n{\n    self.compressionStatus = CompressionStatus_uncompressed;\n    [self doTestCompress:^{\n        TestCaseAssertFalse([self.database isCompressed]);\n        __block BOOL tableCompressed = NO;\n        __block int databaseCompressed = 0;\n        NSString* expectedTableName = self.tableName;\n        WCTTag tag = self.database.tag;\n        [self.database setNotificationWhenCompressed:^(WCTDatabase* database, WCTCompressionBaseInfo* info) {\n            TestCaseAssertEqual(tag, database.tag);\n            if (info == nil) {\n                ++databaseCompressed;\n                TestCaseAssertTrue(database.isCompressed);\n            } else if ([info.table isEqualToString:expectedTableName]) {\n                TestCaseAssertFalse(tableCompressed);\n                tableCompressed = YES;\n            }\n        }];\n\n        BOOL succeed;\n        do {\n            succeed = [self.database stepCompression];\n        } while (succeed && ![self.database isCompressed]);\n        TestCaseAssertTrue(succeed);\n        TestCaseAssertTrue(self.database.isCompressed);\n\n        TestCaseAssertTrue(tableCompressed);\n        TestCaseAssertEqual(databaseCompressed, 1);\n\n        TestCaseAssertTrue([[self.table getObjects] isEqualToArray:[self.uncompressTable getObjects]]);\n\n        // Compression record\n        WCTOneRow* record = [self.database getRowFromStatement:WCDB::StatementSelect().select(WCDB::Column::all()).from(self->m_recordTable)];\n        TestCaseAssertTrue(record.count == 3);\n        TestCaseAssertTrue([record[0].stringValue isEqualToString:self.tableName]);\n        [self verifyCompressionDescription:record[1].stringValue];\n        TestCaseAssertTrue(record[2].numberValue.intValue == 0);\n\n        // Notification will receive multiple times.\n        succeed = [self.database stepCompression];\n        TestCaseAssertTrue(succeed);\n        TestCaseAssertTrue([self.database isCompressed]);\n        TestCaseAssertEqual(databaseCompressed, 2);\n    }];\n}\n\n- (void)verifyCompressionDescription:(NSString*)description\n{\n    if (self.compressTwoColumn) {\n        switch (self.mode) {\n        case CompressionMode_Normal:\n            TestCaseAssertTrue([description isEqualToString:@\"blob,text\"]);\n            break;\n        case CompressionMode_Dict:\n            TestCaseAssertTrue([description isEqualToString:@\"blob:1,text:1\"]);\n            break;\n        case CompressionMode_VariousDict:\n            TestCaseAssertTrue([description isEqualToString:@\"blob:{0:1;1:2;2:3;9223372036854775807:4},text:{0:1;1:2;2:3;3:4;4:5;9223372036854775807:6}\"]);\n            break;\n\n        default:\n            break;\n        }\n    } else {\n        switch (self.mode) {\n        case CompressionMode_Normal:\n            TestCaseAssertTrue([description isEqualToString:@\"text\"]);\n            break;\n        case CompressionMode_Dict:\n            TestCaseAssertTrue([description isEqualToString:@\"text:1\"]);\n            break;\n        case CompressionMode_VariousDict:\n            TestCaseAssertTrue([description isEqualToString:@\"text:{0:1;1:2;2:3;3:4;4:5;9223372036854775807:6}\"]);\n            break;\n\n        default:\n            break;\n        }\n    }\n}\n\n- (void)testReplaceCompression\n{\n    for (int compressionStatus = 2; compressionStatus < 3; compressionStatus++) {\n        self.compressionStatus = (CompressionStatus) compressionStatus;\n        [self doTestCompress:^{\n            [self reconfigCompressionFilter];\n            TestCaseAssertFalse([self.database isCompressed]);\n            __block BOOL tableCompressed = NO;\n            __block int databaseCompressed = 0;\n            NSString* expectedTableName = self.tableName;\n            WCTTag tag = self.database.tag;\n            [self.database setNotificationWhenCompressed:^(WCTDatabase* database, WCTCompressionBaseInfo* info) {\n                TestCaseAssertEqual(tag, database.tag);\n                if (info == nil) {\n                    ++databaseCompressed;\n                    TestCaseAssertTrue(database.isCompressed);\n                } else if ([info.table isEqualToString:expectedTableName]) {\n                    TestCaseAssertFalse(tableCompressed);\n                    tableCompressed = YES;\n                }\n            }];\n            BOOL succeed;\n            do {\n                succeed = [self.database stepCompression];\n            } while (succeed && ![self.database isCompressed]);\n            TestCaseAssertTrue(succeed);\n            TestCaseAssertTrue(self.database.isCompressed);\n            TestCaseAssertTrue([[self.table getObjects] isEqualToArray:[self.uncompressTable getObjects]]);\n\n            // Compression record\n            WCTOneRow* record = [self.database getRowFromStatement:WCDB::StatementSelect().select(WCDB::Column::all()).from(self->m_recordTable)];\n            TestCaseAssertTrue(record.count == 3);\n            TestCaseAssertTrue([record[0].stringValue isEqualToString:self.tableName]);\n            if (self.compressTwoColumn) {\n                switch (self.mode) {\n                case CompressionMode_Normal:\n                    TestCaseAssertTrue([record[1].stringValue isEqualToString:@\"blob:1,text:1\"]);\n                    break;\n                case CompressionMode_Dict:\n                    TestCaseAssertTrue([record[1].stringValue isEqualToString:@\"blob:{0:1;1:2;2:3;9223372036854775807:4},text:{0:1;1:2;2:3;3:4;4:5;9223372036854775807:6}\"]);\n                    break;\n                case CompressionMode_VariousDict:\n                    TestCaseAssertTrue([record[1].stringValue isEqualToString:@\"blob,text\"]);\n                    break;\n\n                default:\n                    break;\n                }\n            } else {\n                switch (self.mode) {\n                case CompressionMode_Normal:\n                    TestCaseAssertTrue([record[1].stringValue isEqualToString:@\"text:1\"]);\n                    break;\n                case CompressionMode_Dict:\n                    TestCaseAssertTrue([record[1].stringValue isEqualToString:@\"text:{0:1;1:2;2:3;3:4;4:5;9223372036854775807:6}\"]);\n                    break;\n                case CompressionMode_VariousDict:\n                    TestCaseAssertTrue([record[1].stringValue isEqualToString:@\"text\"]);\n                    break;\n\n                default:\n                    break;\n                }\n            }\n            TestCaseAssertTrue(record[2].numberValue.intValue == 0);\n\n            TestCaseAssertTrue(tableCompressed);\n            TestCaseAssertEqual(databaseCompressed, 1);\n\n            // Notification will receive multiple times.\n            succeed = [self.database stepCompression];\n            TestCaseAssertTrue(succeed);\n            TestCaseAssertTrue([self.database isCompressed]);\n            TestCaseAssertEqual(databaseCompressed, 2);\n        }];\n    }\n}\n\n- (void)testAutoCompress\n{\n    [self doTestCompress:^{\n        TestCaseResult* tableCompressed = [TestCaseResult no];\n        TestCaseResult* compressed = [TestCaseResult no];\n        NSString* expectedTableName = self.tableName;\n        [self.database setNotificationWhenCompressed:^(WCTDatabase*, WCTCompressionBaseInfo* tableInfo) {\n            if (tableInfo == nil) {\n                [compressed makeYES];\n            } else if ([tableInfo.table isEqualToString:expectedTableName]) {\n                [tableCompressed makeYES];\n            }\n        }];\n        [self.database enableAutoCompression:YES];\n        TestCaseAssertTrue([self.database canOpen]);\n\n        while (!tableCompressed.value) {\n            [NSThread sleepForTimeInterval:self.delayForTolerance];\n        }\n        while (!compressed.value) {\n            [NSThread sleepForTimeInterval:self.delayForTolerance];\n        }\n        TestCaseAssertResultYES(tableCompressed);\n        TestCaseAssertResultYES(compressed);\n        TestCaseAssertTrue(self.database.isCompressed);\n    }];\n}\n\n- (void)testRollbackCompression\n{\n    for (int i = 0; i < 3; i++) {\n        self.compressionStatus = (CompressionStatus) i;\n        [self doTestCompress:^{\n            __block double lastPercentage = 0;\n            __block BOOL sanity = YES;\n            bool succeed = [self.database rollbackCompression:^(double percentage, double increment) {\n                if (percentage - lastPercentage != increment\n                    || increment <= 0) {\n                    TestCaseFailure();\n                    sanity = NO;\n                }\n                lastPercentage = percentage;\n                return true;\n            }];\n            TestCaseAssertTrue(sanity);\n            TestCaseAssertTrue(succeed);\n            TestCaseAssertEqual(lastPercentage, 1.0);\n            TestCaseAssertFalse(self.database.isCompressed);\n\n            WCTValue* compressedTextCount = [self.database getValueFromStatement:WCDB::StatementSelect().select(WCDB::Column::all().count()).from(self.tableName).where(WCDB::Column(\"WCDB_CT_text\").notNull())];\n            TestCaseAssertTrue(compressedTextCount.numberValue.intValue == 0);\n            if (!self.compressTwoColumn) {\n                return;\n            }\n            WCTValue* compressedBlobCount = [self.database getValueFromStatement:WCDB::StatementSelect().select(WCDB::Column::all().count()).from(self.tableName).where(WCDB::Column(\"WCDB_CT_blob\").notNull())];\n            TestCaseAssertTrue(compressedBlobCount.numberValue.intValue == 0);\n        }];\n    }\n}\n\n- (void)test_feature_closed_database_will_not_perform_auto_compress\n{\n    [self doTestCompress:^{\n        [self.database enableAutoCompression:YES];\n\n        TestCaseAssertTrue([self.database canOpen]);\n\n        [self.database close];\n\n        [NSThread sleepForTimeInterval:self.delayForTolerance + WCDB::OperationQueueTimeIntervalForCompression];\n\n        TestCaseAssertFalse(self.database.isOpened);\n    }];\n}\n\n- (void)test_feature_auto_compress_will_stop_due_to_error\n{\n    [self.database enableAutoCheckpoint:NO];\n    [self doTestCompress:^{\n        TestCaseAssertTrue([self.database canOpen]);\n\n        TestCaseCounter* numberOfFailures = [TestCaseCounter value:0];\n        weakify(self);\n        [self.database traceError:nil];\n        [self.database traceError:^(WCTError* error) {\n            strongify_or_return(self);\n            if (error.code == WCTErrorCodeIOError\n                && error.level == WCTErrorLevelWarning) {\n                [numberOfFailures increment];\n            }\n        }];\n\n        [self.database enableAutoCompression:YES];\n        TestCaseAssertTrue([self.database canOpen]);\n        [WCTDatabase simulateIOError:WCTSimulateWriteIOError];\n\n        // wait until auto migrate stopped\n        while (numberOfFailures.value < WCDB::OperationQueueTolerableFailuresForCompression);\n\n        // wait to confirm migration is stopped.\n        [NSThread sleepForTimeInterval:2 * WCDB::OperationQueueTolerableFailuresForCompression];\n\n        TestCaseAssertTrue(numberOfFailures.value == WCDB::OperationQueueTolerableFailuresForCompression);\n\n        [WCTDatabase simulateIOError:WCTSimulateNoneIOError];\n    }];\n    [self.database enableAutoCheckpoint:YES];\n}\n\n- (void)test_feature_compress_newly_created_table_after_compressed\n{\n    self.compressionStatus = CompressionStatus_finishCompressed;\n    [self doTestCompress:^{\n        TestCaseAssertTrue(self.database.isCompressed);\n\n        self.anotherTable = @\"testAnotherTable\";\n        TestCaseAssertTrue([self.database createTable:self.anotherTable withClass:CompressionTestObject.class]);\n\n        [self.database insertObjects:[self.table getObjects] intoTable:self.anotherTable];\n\n        [self configCompressFilter];\n\n        // migrated status is reset.\n        TestCaseAssertFalse(self.database.isCompressed);\n\n        do {\n            TestCaseAssertTrue([self.database stepCompression]);\n        } while (!self.database.isCompressed);\n\n        WCTValue* uncompressedTextCount = [self.database getValueFromStatement:WCDB::StatementSelect().select(WCDB::Column::all().count()).from(self.anotherTable).where(WCDB::Column(\"WCDB_CT_text\").isNull())];\n        TestCaseAssertTrue(uncompressedTextCount.numberValue.intValue == 0);\n        if (!self.compressTwoColumn) {\n            return;\n        }\n\n        WCTValue* uncompressedBlobCount = [self.database getValueFromStatement:WCDB::StatementSelect().select(WCDB::Column::all().count()).from(self.tableName).where(WCDB::Column(\"WCDB_CT_blob\").isNull())];\n        TestCaseAssertTrue(uncompressedBlobCount.numberValue.intValue == 0);\n    }];\n}\n\n- (void)test_feature_compress_new_column_after_compressed\n{\n    self.compressionStatus = CompressionStatus_finishCompressed;\n    [self doTestCompress:^{\n        if (self.compressTwoColumn) {\n            return;\n        }\n\n        TestCaseAssertTrue(self.database.isCompressed);\n\n        self.compressTwoColumn = YES;\n\n        [self configCompressFilter];\n\n        // migrated status is reset.\n        TestCaseAssertFalse(self.database.isCompressed);\n\n        do {\n            TestCaseAssertTrue([self.database stepCompression]);\n        } while (!self.database.isCompressed);\n\n        WCTValue* uncompressedBlobCount = [self.database getValueFromStatement:WCDB::StatementSelect().select(WCDB::Column::all().count()).from(self.tableName).where(WCDB::Column(\"WCDB_CT_blob\").isNull())];\n        TestCaseAssertTrue(uncompressedBlobCount.numberValue.intValue == 0);\n    }];\n}\n\n- (void)test_compressed_content_will_persist_after_retrieving\n{\n    self.compressionStatus = CompressionStatus_finishCompressed;\n    [self doTestCompress:^{\n        [self.database retrieve:nil];\n        WCTOneRow* record = [self.database getRowFromStatement:WCDB::StatementSelect().select(WCDB::Column::all()).from(\"wcdb_builtin_compression_record\").where(WCDB::Column(\"tableName\") == self.tableName)];\n\n        TestCaseAssertTrue(record != nil && record[2].numberValue.intValue == 0);\n        [self verifyCompressionDescription:record[1].stringValue];\n\n        NSArray* objects = [self.table getObjects];\n        NSArray* originObjects = [self.uncompressTable getObjects];\n        TestCaseAssertTrue([originObjects isEqualToArray:objects]);\n\n        WCTValue* uncompressedTextCount = [self.database getValueFromStatement:WCDB::StatementSelect().select(WCDB::Column::all().count()).from(self.tableName).where(WCDB::Column(\"WCDB_CT_text\").isNull())];\n        TestCaseAssertTrue(uncompressedTextCount != nil && uncompressedTextCount.numberValue.intValue == 0);\n        if (!self.compressTwoColumn) {\n            return;\n        }\n        WCTValue* uncompressedBlobCount = [self.database getValueFromStatement:WCDB::StatementSelect().select(WCDB::Column::all().count()).from(self.tableName).where(WCDB::Column(\"WCDB_CT_blob\").isNull())];\n        TestCaseAssertTrue(uncompressedBlobCount != nil && uncompressedBlobCount.numberValue.intValue == 0);\n    }];\n}\n\n- (void)test_migrate_and_checkpoint_during_compression\n{\n    self.compressionStatus = CompressionStatus_startCompressed;\n    self.migrationStatus = MigrationStatus_unmigrated;\n    [self doTestCompress:^{\n        while (![self.database isCompressed] && ![self.database isMigrated]) {\n            if (![self.database isCompressed]) {\n                [self.database stepCompression];\n            }\n            if (![self.database isMigrated]) {\n                [self.database stepMigration];\n            }\n            [self.database passiveCheckpoint];\n        }\n\n        NSArray* objects = [self.table getObjects];\n        NSArray* originObjects = [self.uncompressTable getObjects];\n        TestCaseAssertTrue([originObjects isEqualToArray:objects]);\n    }];\n}\n\n@end\n"
  },
  {
    "path": "src/objc/tests/config/ConfigTests.mm",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"TestCase.h\"\n\n@interface ConfigTests : DatabaseTestCase\n\n@property (nonatomic, readonly) NSString* configName;\n\n@end\n\n@implementation ConfigTests {\n    NSString* _configName;\n}\n\n- (NSString*)configName\n{\n    @synchronized(self) {\n        if (_configName == nil) {\n            _configName = Random.shared.string;\n        }\n        return _configName;\n    }\n}\n\n- (void)tearDown\n{\n    [self.database removeConfigForName:self.configName];\n    [super tearDown];\n}\n\n- (void)test_config\n{\n    WCDB::StatementPragma setSecureDelete = WCDB::StatementPragma().pragma(WCDB::Pragma::secureDelete()).to(YES);\n    WCDB::StatementPragma unsetSecureDelete = WCDB::StatementPragma().pragma(WCDB::Pragma::secureDelete()).to(NO);\n    WCDB::StatementPragma getSecureDelete = WCDB::StatementPragma().pragma(WCDB::Pragma::secureDelete());\n\n    __block BOOL uninvoked = NO;\n    {\n        // invocation\n        [self.database\n        setConfig:^BOOL(WCTHandle* handle) {\n            return [handle execute:setSecureDelete];\n        }\n        withUninvocation:^BOOL(WCTHandle* handle) {\n            // customlized check uninvocation since traceSQL will be unset in the test function\n            uninvoked = YES;\n            return [handle execute:unsetSecureDelete];\n        }\n        forName:self.configName];\n\n        self.expectMode = DatabaseTestCaseExpectSomeSQLs;\n        [self doTestSQLs:@[ @\"PRAGMA secure_delete = TRUE\" ]\n             inOperation:^BOOL {\n                 [self.database close];\n                 return [self.database canOpen];\n             }];\n\n        TestCaseAssertTrue([self.database getValueFromStatement:getSecureDelete].numberValue.boolValue);\n    }\n    {\n        // uninvocation\n        [self.database removeConfigForName:self.configName];\n\n        TestCaseAssertTrue([self.database canOpen]);\n        TestCaseAssertTrue(uninvoked);\n\n        TestCaseAssertFalse([self.database getValueFromStatement:getSecureDelete].numberValue.boolValue);\n    }\n}\n\n- (void)test_config_failed\n{\n    [self.database\n           setConfig:^BOOL(WCTHandle* _Nonnull) {\n               return NO;\n           }\n    withUninvocation:nil\n             forName:self.configName];\n\n    TestCaseAssertFalse([self.database canOpen]);\n}\n\n- (void)test_uninvoke_failed\n{\n    [self.database\n    setConfig:^BOOL(WCTHandle* _Nonnull) {\n        return YES;\n    }\n    withUninvocation:^BOOL(WCTHandle* _Nonnull) {\n        return NO;\n    }\n    forName:self.configName];\n\n    TestCaseAssertTrue([self.database canOpen]);\n\n    [self.database removeConfigForName:self.configName];\n\n    TestCaseAssertFalse([self.database canOpen]);\n}\n\n- (void)test_ordered_config\n{\n    NSString* config1 = [self.configName stringByAppendingString:@\"_1\"];\n    NSString* config2 = [self.configName stringByAppendingString:@\"_2\"];\n    NSString* config3 = [self.configName stringByAppendingString:@\"_3\"];\n\n    __block int step = 0;\n\n    [self.database\n           setConfig:^BOOL(WCTHandle* handle) {\n               WCDB_UNUSED(handle);\n               ++step;\n               return step == 2;\n           }\n    withUninvocation:nil\n             forName:config1\n        withPriority:WCTConfigPriorityDefault];\n\n    [self.database\n           setConfig:^BOOL(WCTHandle* handle) {\n               WCDB_UNUSED(handle);\n               ++step;\n               return step == 3;\n           }\n    withUninvocation:nil\n             forName:config2\n        withPriority:WCTConfigPriorityLow];\n    [self.database\n           setConfig:^BOOL(WCTHandle* handle) {\n               WCDB_UNUSED(handle);\n               ++step;\n               return step == 1;\n           }\n    withUninvocation:nil\n             forName:config3\n        withPriority:WCTConfigPriorityHigh];\n\n    TestCaseAssertTrue([self.database canOpen]);\n\n    TestCaseAssertEqual(step, 3);\n}\n\n- (void)test_cipher\n{\n    NSData* cipher = Random.shared.data;\n    NSData* wrongCipher = [Random.shared dataOtherThan:cipher];\n\n    [self.database setCipherKey:cipher];\n    TestCaseAssertTrue([self.database canOpen]);\n\n    [self.database close];\n    [self.database setCipherKey:wrongCipher];\n    TestCaseAssertFalse([self.database canOpen]);\n}\n\n- (void)test_cipher_with_multi_handle\n{\n    NSData* cipher = Random.shared.data;\n    [self.database setCipherKey:cipher];\n    WCTHandle* handle = [self.database getHandle];\n    TestCaseAssertTrue([handle tableExists:@\"abc\"].succeed());\n    [self.dispatch async:^{\n        WCTHandle* newHandle = [self.database getHandle];\n        TestCaseAssertTrue([newHandle tableExists:@\"abc\"].succeed());\n    }];\n    sleep(1);\n    [self.dispatch waitUntilDone];\n}\n\n- (void)test_cipher_with_page_size\n{\n    NSData* cipher = Random.shared.data;\n    int pageSize = 8 * 1024;\n    int wrongPageSize = 16 * 1024;\n\n    [self.database setCipherKey:cipher andCipherPageSize:pageSize];\n    TestCaseAssertTrue([self.database canOpen]);\n\n    [self.database close];\n    [self.database setCipherKey:cipher andCipherPageSize:wrongPageSize];\n    TestCaseAssertFalse([self.database canOpen]);\n}\n\n- (void)test_cipher_with_diferent_version\n{\n    NSData* cipher = Random.shared.data;\n    int pageSize = 4096;\n    [self.database setCipherKey:cipher andCipherPageSize:pageSize andCipherViersion:WCTCipherVersion3];\n    TestCaseAssertTrue([self.database canOpen]);\n\n    [self.database close];\n    [self.database setCipherKey:cipher andCipherPageSize:pageSize];\n    TestCaseAssertFalse([self.database canOpen]);\n\n    [WCTDatabase setDefaultCipherConfiguration:WCTCipherVersion3];\n    TestCaseAssertTrue([self.database canOpen]);\n\n    [self.database removeFiles];\n    [self.database setCipherKey:cipher andCipherPageSize:pageSize andCipherViersion:WCTCipherVersion4];\n    TestCaseAssertTrue([self.database canOpen]);\n    [self.database close];\n\n    [self.database setCipherKey:cipher andCipherPageSize:pageSize];\n    TestCaseAssertFalse([self.database canOpen]);\n    [WCTDatabase setDefaultCipherConfiguration:WCTCipherVersion4];\n    TestCaseAssertTrue([self.database canOpen]);\n}\n\n- (void)test_abtest_config\n{\n    NSMutableDictionary* abtestDic = [[NSMutableDictionary alloc] init];\n    for (int i = 0; i < 100; i++) {\n        abtestDic[Random.shared.string] = Random.shared.string;\n    }\n    [abtestDic enumerateKeysAndObjectsUsingBlock:^(NSString* name, NSString* value, BOOL*) {\n        [WCTDatabase setABTestConfigWithName:name andValue:value];\n    }];\n\n    [abtestDic enumerateKeysAndObjectsUsingBlock:^(NSString* name, NSString* value, BOOL*) {\n        TestCaseAssertTrue([[WCTDatabase getABTestConfigWithName:name] isEqualToString:value]);\n    }];\n\n    [abtestDic enumerateKeysAndObjectsUsingBlock:^(NSString* name, NSString*, BOOL*) {\n        [WCTDatabase removeABTestConfigWithName:name];\n    }];\n\n    [abtestDic enumerateKeysAndObjectsUsingBlock:^(NSString* name, NSString*, BOOL*) {\n        TestCaseAssertTrue([WCTDatabase getABTestConfigWithName:name] == nil);\n    }];\n}\n\n- (void)testSetTemporaryDirectory\n{\n    NSString* wrongDir = @\"wrongDir\";\n    TestCaseAssertFalse([WCTDatabase setDefaultTemporaryDatabaseFileDirectory:wrongDir]);\n\n    NSString* tempDir = [NSTemporaryDirectory() stringByAppendingPathComponent:@\"dbTempDir\"];\n    TestCaseAssertTrue([WCTDatabase setDefaultTemporaryDatabaseFileDirectory:tempDir]);\n\n    WCDB::StatementPragma getDirStatement = WCDB::StatementPragma().pragma(WCDB::Pragma(\"temp_store_directory\"));\n    WCTValue* dir = [self.database getValueFromStatement:getDirStatement];\n    TestCaseAssertTrue(dir != nil && [dir.stringValue isEqualToString:tempDir]);\n\n    TestCaseAssertTrue([WCTDatabase setDefaultTemporaryDatabaseFileDirectory:nil]);\n    dir = [self.database getValueFromStatement:getDirStatement];\n    TestCaseAssertTrue(dir != nil && [dir.stringValue isEqualToString:@\"\"]);\n}\n\n- (void)test_lite_mode\n{\n    [self.database enableLiteMode:YES];\n    NSString* testTable = @\"testTable\";\n    TestCaseAssertTrue([self.database createTable:testTable withClass:TestCaseObject.class]);\n    WCTTable* table = [self.database getTable:testTable withClass:TestCaseObject.class];\n    for (int i = 0; i < 300; i++) {\n        [self.dispatch async:^{\n            TestCaseAssertTrue([table insertObjects:[[Random shared] autoIncrementTestCaseObjectsWithCount:100]]);\n        }];\n    }\n    [self.dispatch waitUntilDone];\n    WCTValue* count = [table getValueOnResultColumn:TestCaseObject.allProperties.count()];\n    TestCaseAssertTrue(count.numberValue.intValue == 30000);\n    TestCaseAssertFalse([self.fileManager fileExistsAtPath:[self.database walPath]]);\n}\n\n@end\n"
  },
  {
    "path": "src/objc/tests/config/DatabaseTests.mm",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"TestCase.h\"\n#if TEST_WCDB_OBJC\n#import <WCDBOBjc/WCTDatabase+Monitor.h>\n#elif TEST_WCDB_CPP\n#import <WCDBCpp/WCTDatabase+Monitor.h>\n#else\n#import <WCDB/WCTDatabase+Monitor.h>\n#endif\n\n@interface DatabaseTests : DatabaseTestCase\n\n@end\n\n@implementation DatabaseTests\n\n- (void)test_tag\n{\n    TestCaseAssertNotEqual(self.database.tag, WCTInvalidTag);\n    WCTDatabase* another = [[WCTDatabase alloc] initWithPath:self.path];\n    TestCaseAssertEqual(self.database.tag, another.tag);\n}\n\n- (void)test_path\n{\n    TestCaseAssertTrue([self.database.path isEqualToString:self.path]);\n}\n\n- (void)test_open_and_close\n{\n    TestCaseAssertFalse([self.database isOpened]);\n    TestCaseAssertTrue([self.database canOpen]);\n    TestCaseAssertTrue([self.database isOpened]);\n    [self.database close];\n    TestCaseAssertFalse([self.database isOpened]);\n}\n\n- (void)test_blockade\n{\n    [self.database blockade];\n    __block NSDate* subthread;\n    [self.dispatch async:^{\n        TestCaseAssertTrue([self.database canOpen]);\n        subthread = [NSDate date];\n    }];\n    [NSThread sleepForTimeInterval:1];\n    NSDate* main = [NSDate date];\n    [self.database unblockade];\n    [self.dispatch waitUntilDone];\n    TestCaseAssertTrue([main compare:subthread] == NSOrderedAscending);\n}\n\n- (void)test_blockaded_close\n{\n    __block NSDate* main;\n    __block NSDate* subthread;\n    [self.database close:^{\n        [self.dispatch async:^{\n            TestCaseAssertTrue([self.database canOpen]);\n            subthread = [NSDate date];\n        }];\n        [NSThread sleepForTimeInterval:1];\n        main = [NSDate date];\n    }];\n    [self.dispatch waitUntilDone];\n    TestCaseAssertTrue([main compare:subthread] == NSOrderedAscending);\n}\n\n- (void)test_readonly\n{\n    NSString* tableName = @\"testTable\";\n\n    TestCaseObject* object = [Random.shared autoIncrementTestCaseObject];\n\n    TestCaseAssertTrue([self.database createTable:tableName withClass:TestCaseObject.class]);\n    TestCaseAssertTrue([self.database insertObject:object intoTable:tableName]);\n\n    [self.database close:^{\n        for (NSString* path in self.database.paths) {\n            if ([self.fileManager fileExistsAtPath:path]) {\n                TestCaseAssertTrue([self.fileManager setAttributes:@{NSFileImmutable : @(YES)} ofItemAtPath:path error:nil]);\n            }\n        }\n    }];\n\n    TestCaseAssertTrue([self.database canOpen]);\n    TestCaseAssertTrue([self.database getObjectOfClass:TestCaseObject.class fromTable:tableName] != nil);\n    TestCaseAssertFalse([self.database insertObject:object intoTable:tableName]);\n\n    // reset attribute\n    for (NSString* path in self.database.paths) {\n        if ([self.fileManager fileExistsAtPath:path]) {\n            TestCaseAssertTrue([self.fileManager setAttributes:@{ NSFileImmutable : @(NO) } ofItemAtPath:path error:nil]);\n        }\n    }\n}\n\n- (void)test_readonly_database\n{\n    NSString* tableName = @\"testTable\";\n\n    TestCaseObject* object = [Random.shared autoIncrementTestCaseObject];\n\n    TestCaseAssertTrue([self.database createTable:tableName withClass:TestCaseObject.class]);\n    TestCaseAssertTrue([self.database insertObject:object intoTable:tableName]);\n\n    WCTDatabase* readOnlyDatabase = [[WCTDatabase alloc] initReadOnlyDatabaseWithPath:self.path];\n\n    TestCaseAssertTrue([readOnlyDatabase canOpen]);\n    TestCaseAssertTrue([readOnlyDatabase getObjectOfClass:TestCaseObject.class fromTable:tableName] != nil);\n    TestCaseAssertFalse([readOnlyDatabase insertObject:object intoTable:tableName]);\n\n    TestCaseAssertFalse([self.database insertObject:object intoTable:tableName]);\n}\n\n- (void)test_get_error\n{\n    TestCaseAssertFalse([self.database insertObject:[[TestCaseObject alloc] init] intoTable:@\"notExistTable\"]);\n    TestCaseAssertFalse([[self.database error] isOK]);\n    TestCaseAssertTrue([self.database.error.message containsString:@\"notExistTable\"]);\n}\n\n- (void)test_feature_run_while_closing\n{\n    TestCaseAssertTrue([self.database canOpen]);\n    TestCaseAssertTrue([self.database isOpened]);\n    [self.database close:^{\n        TestCaseAssertTrue([self.database execute:WCDB::StatementPragma().pragma(WCDB::Pragma::userVersion()).to(123)]);\n    }];\n    TestCaseAssertFalse([self.database isOpened]);\n}\n\n- (void)test_purge\n{\n    // acquire handle\n    TestCaseAssertTrue([self.database execute:WCDB::StatementPragma().pragma(WCDB::Pragma::userVersion())]);\n\n    TestCaseAssertTrue([self.database isOpened]);\n    [self.database purge];\n    TestCaseAssertFalse([self.database isOpened]);\n}\n\n- (void)test_purge_all\n{\n    // acquire handle\n    TestCaseAssertTrue([self.database execute:WCDB::StatementPragma().pragma(WCDB::Pragma::userVersion())]);\n\n    TestCaseAssertTrue([self.database isOpened]);\n    [WCTDatabase purgeAll];\n    TestCaseAssertFalse([self.database isOpened]);\n}\n\n- (void)testCheckpoint\n{\n    NSString* tableName = @\"testTable\";\n\n    TestCaseObject* object = [Random.shared autoIncrementTestCaseObject];\n\n    TestCaseAssertTrue([self.database createTable:tableName withClass:TestCaseObject.class]);\n    __block unsigned long walFrameNum = 0;\n    for (int i = 0; i < 100; i++) {\n        TestCaseAssertTrue([[self.database getRowFromStatement:WCDB::StatementSelect().select(WCDB::Expression::function(\"count\").invokeAll()).from(tableName)].firstObject numberValue].unsignedIntValue == i);\n        TestCaseAssertTrue([self.database insertObject:object intoTable:tableName]);\n        [self.database passiveCheckpoint];\n        [self.database close:^{\n            if (walFrameNum != 0) {\n                TestCaseAssertTrue(walFrameNum == [self.database getNumberOfWalFrames].value());\n            } else {\n                walFrameNum = [self.database getNumberOfWalFrames].value();\n            }\n            TestCaseAssertTrue(walFrameNum > 0);\n            for (NSString* path in self.database.paths) {\n                if ([path hasSuffix:@\"wal\"]) {\n                    TestCaseAssertTrue([self.fileManager fileExistsAtPath:path]);\n                    TestCaseAssertTrue([self.fileManager getFileSizeIfExists:path] > 32);\n                } else if ([path hasSuffix:@\"shm\"]) {\n                    TestCaseAssertTrue([self.fileManager fileExistsAtPath:path]);\n                    TestCaseAssertTrue([self.fileManager getFileSizeIfExists:path] >= 32 * 1024);\n                }\n            }\n        }];\n    }\n}\n\n- (void)testCheckpoint2\n{\n    NSString* tableName = @\"testTable\";\n\n    TestCaseObject* object = [Random.shared autoIncrementTestCaseObject];\n\n    TestCaseAssertTrue([self.database createTable:tableName withClass:TestCaseObject.class]);\n    __block unsigned long walFrameNum = 0;\n    for (int i = 0; i < 100; i++) {\n        TestCaseAssertTrue([[self.database getRowFromStatement:WCDB::StatementSelect().select(WCDB::Expression::function(\"count\").invokeAll()).from(tableName)].firstObject numberValue].unsignedIntValue == i);\n        TestCaseAssertTrue([self.database insertObject:object intoTable:tableName]);\n    }\n    [self.database passiveCheckpoint];\n    [self.database close:^{\n        if (walFrameNum != 0) {\n            TestCaseAssertTrue(walFrameNum == [self.database getNumberOfWalFrames].value());\n        } else {\n            walFrameNum = [self.database getNumberOfWalFrames].value();\n        }\n        TestCaseAssertTrue(walFrameNum > 0);\n        for (NSString* path in self.database.paths) {\n            if ([path hasSuffix:@\"wal\"]) {\n                TestCaseAssertTrue([self.fileManager fileExistsAtPath:path]);\n                TestCaseAssertTrue([self.fileManager getFileSizeIfExists:path] > 32);\n            } else if ([path hasSuffix:@\"shm\"]) {\n                TestCaseAssertTrue([self.fileManager fileExistsAtPath:path]);\n                TestCaseAssertTrue([self.fileManager getFileSizeIfExists:path] >= 32 * 1024);\n            }\n        }\n    }];\n}\n\n- (void)test_long_write_with_checkpoint\n{\n    NSString* tableName = @\"testTable\";\n    TestCaseAssertTrue([self.database createTable:tableName withClass:TestCaseObject.class]);\n\n    for (int i = 0; i < 1000; i++) {\n        for (int j = 0; j < 5; j++) {\n            NSArray<TestCaseObject*>* objs = [[Random shared] autoIncrementTestCaseObjectsWithCount:2];\n            TestCaseAssertTrue([self.database insertObjects:objs intoTable:tableName]);\n        }\n        [self.dispatch async:^{\n            [self.database passiveCheckpoint];\n        }];\n        if ([Random shared].boolean) {\n            usleep(10000);\n        }\n        TestCaseAssertTrue([self.database getValueOnResultColumn:TestCaseObject.allProperties.count() fromTable:tableName].numberValue.intValue == 10 * (1 + i));\n\n        if ([Random shared].boolean) {\n            [self.database close];\n        }\n    }\n}\n\n- (void)test_in_memory_db\n{\n    WCTDatabase* db = [[WCTDatabase alloc] initInMemoryDatabase];\n    TestCaseObject* object = [Random.shared autoIncrementTestCaseObject];\n    NSString* tableName = @\"testTable\";\n    TestCaseAssertTrue([db createTable:tableName withClass:TestCaseObject.class]);\n    for (int i = 0; i < 100; i++) {\n        TestCaseAssertTrue([db insertObject:object intoTable:tableName]);\n    }\n    TestCaseAssertTrue([[db getRowFromStatement:WCDB::StatementSelect().select(WCDB::Expression::function(\"count\").invokeAll()).from(tableName)].firstObject numberValue].unsignedIntValue == 100);\n    TestCaseAssertTrue([db passiveCheckpoint]);\n    [db close];\n    TestCaseAssertFalse([self.fileManager fileExistsAtPath:db.path]);\n    db = [[WCTDatabase alloc] initInMemoryDatabase];\n    TestCaseAssertTrue([[db getRowFromStatement:WCDB::StatementSelect().select(WCDB::Expression::function(\"count\").invokeAll()).from(tableName)].firstObject numberValue].unsignedIntValue == 0);\n}\n\n@end\n"
  },
  {
    "path": "src/objc/tests/convenient/ConvenientDeleteTests.mm",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"TestCase.h\"\n\n@interface ConvenientDeleteTests : CRUDTestCase\n\n@end\n\n@implementation ConvenientDeleteTests\n\n- (void)setUp\n{\n    [super setUp];\n    [self insertPresetObjects];\n}\n\n#pragma mark - Database - Delete\n- (void)test_database_delete\n{\n    [self doTestObjects:@[]\n                 andSQL:@\"DELETE FROM testTable\"\n      afterModification:^BOOL {\n          return [self.database deleteFromTable:self.tableName];\n      }];\n}\n\n- (void)test_database_delete_where\n{\n    [self doTestObject:self.object1\n                andSQL:@\"DELETE FROM testTable WHERE identifier == 2\"\n     afterModification:^BOOL {\n         return [self.database deleteFromTable:self.tableName where:TestCaseObject.identifier == 2];\n     }];\n}\n\n- (void)test_database_delete_limit\n{\n    [self doTestObject:self.object2\n                andSQL:@\"DELETE FROM testTable LIMIT 1\"\n     afterModification:^BOOL {\n         return [self.database deleteFromTable:self.tableName limit:1];\n     }];\n}\n\n- (void)test_database_delete_where_limit\n{\n    [self doTestObject:self.object2\n                andSQL:@\"DELETE FROM testTable WHERE identifier > 0 LIMIT 1\"\n     afterModification:^BOOL {\n         return [self.database deleteFromTable:self.tableName where:TestCaseObject.identifier > 0 limit:1];\n     }];\n}\n\n- (void)test_database_delete_orders_limit\n{\n    [self doTestObject:self.object1\n                andSQL:@\"DELETE FROM testTable ORDER BY identifier DESC LIMIT 1\"\n     afterModification:^BOOL {\n         return [self.database deleteFromTable:self.tableName orders:TestCaseObject.identifier.asOrder(WCTOrderedDescending) limit:1];\n     }];\n}\n\n- (void)test_database_delete_limit_offset\n{\n    [self doTestObject:self.object1\n                andSQL:@\"DELETE FROM testTable LIMIT 1 OFFSET 1\"\n     afterModification:^BOOL {\n         return [self.database deleteFromTable:self.tableName limit:1 offset:1];\n     }];\n}\n\n- (void)test_database_delete_where_orders_limit\n{\n    [self doTestObject:self.object1\n                andSQL:@\"DELETE FROM testTable WHERE identifier > 0 ORDER BY identifier DESC LIMIT 1\"\n     afterModification:^BOOL {\n         return [self.database deleteFromTable:self.tableName where:TestCaseObject.identifier > 0 orders:TestCaseObject.identifier.asOrder(WCTOrderedDescending) limit:1];\n     }];\n}\n\n- (void)test_database_delete_where_limit_offset\n{\n    [self doTestObject:self.object2\n                andSQL:@\"DELETE FROM testTable WHERE identifier > 0 ORDER BY identifier DESC LIMIT 1 OFFSET 1\"\n     afterModification:^BOOL {\n         return [self.database deleteFromTable:self.tableName where:TestCaseObject.identifier > 0 orders:TestCaseObject.identifier.asOrder(WCTOrderedDescending) limit:1 offset:1];\n     }];\n}\n\n- (void)test_database_delete_orders_limit_offset\n{\n    [self doTestObject:self.object2\n                andSQL:@\"DELETE FROM testTable ORDER BY identifier DESC LIMIT 1 OFFSET 1\"\n     afterModification:^BOOL {\n         return [self.database deleteFromTable:self.tableName orders:TestCaseObject.identifier.asOrder(WCTOrderedDescending) limit:1 offset:1];\n     }];\n}\n\n- (void)test_database_delete_where_orders_limit_offset\n{\n    [self doTestObject:self.object2\n                andSQL:@\"DELETE FROM testTable WHERE identifier > 0 ORDER BY identifier DESC LIMIT 1 OFFSET 1\"\n     afterModification:^BOOL {\n         return [self.database deleteFromTable:self.tableName where:TestCaseObject.identifier > 0 orders:TestCaseObject.identifier.asOrder(WCTOrderedDescending) limit:1 offset:1];\n     }];\n}\n\n#pragma mark - Table - Delete\n- (void)test_table_delete\n{\n    [self doTestObjects:@[]\n                 andSQL:@\"DELETE FROM testTable\"\n      afterModification:^BOOL {\n          return [self.table deleteObjects];\n      }];\n}\n\n- (void)test_table_delete_where\n{\n    [self doTestObject:self.object1\n                andSQL:@\"DELETE FROM testTable WHERE identifier == 2\"\n     afterModification:^BOOL {\n         return [self.table deleteObjectsWhere:TestCaseObject.identifier == 2];\n     }];\n}\n\n- (void)test_table_delete_limit\n{\n    [self doTestObject:self.object2\n                andSQL:@\"DELETE FROM testTable LIMIT 1\"\n     afterModification:^BOOL {\n         return [self.table deleteObjectsLimit:1];\n     }];\n}\n\n- (void)test_table_delete_where_limit\n{\n    [self doTestObject:self.object2\n                andSQL:@\"DELETE FROM testTable WHERE identifier > 0 LIMIT 1\"\n     afterModification:^BOOL {\n         return [self.table deleteObjectsWhere:TestCaseObject.identifier > 0 limit:1];\n     }];\n}\n\n- (void)test_table_delete_orders_limit\n{\n    [self doTestObject:self.object1\n                andSQL:@\"DELETE FROM testTable ORDER BY identifier DESC LIMIT 1\"\n     afterModification:^BOOL {\n         return [self.table deleteObjectsOrders:TestCaseObject.identifier.asOrder(WCTOrderedDescending) limit:1];\n     }];\n}\n\n- (void)test_table_delete_limit_offset\n{\n    [self doTestObject:self.object1\n                andSQL:@\"DELETE FROM testTable LIMIT 1 OFFSET 1\"\n     afterModification:^BOOL {\n         return [self.table deleteObjectsLimit:1 offset:1];\n     }];\n}\n\n- (void)test_table_delete_where_orders_limit\n{\n    [self doTestObject:self.object1\n                andSQL:@\"DELETE FROM testTable WHERE identifier > 0 ORDER BY identifier DESC LIMIT 1\"\n     afterModification:^BOOL {\n         return [self.table deleteObjectsWhere:TestCaseObject.identifier > 0 orders:TestCaseObject.identifier.asOrder(WCTOrderedDescending) limit:1];\n     }];\n}\n\n- (void)test_table_delete_where_limit_offset\n{\n    [self doTestObject:self.object2\n                andSQL:@\"DELETE FROM testTable WHERE identifier > 0 ORDER BY identifier DESC LIMIT 1 OFFSET 1\"\n     afterModification:^BOOL {\n         return [self.table deleteObjectsWhere:TestCaseObject.identifier > 0 orders:TestCaseObject.identifier.asOrder(WCTOrderedDescending) limit:1 offset:1];\n     }];\n}\n\n- (void)test_table_delete_orders_limit_offset\n{\n    [self doTestObject:self.object2\n                andSQL:@\"DELETE FROM testTable ORDER BY identifier DESC LIMIT 1 OFFSET 1\"\n     afterModification:^BOOL {\n         return [self.table deleteObjectsOrders:TestCaseObject.identifier.asOrder(WCTOrderedDescending) limit:1 offset:1];\n     }];\n}\n\n- (void)test_table_delete_where_orders_limit_offset\n{\n    [self doTestObject:self.object2\n                andSQL:@\"DELETE FROM testTable WHERE identifier > 0 ORDER BY identifier DESC LIMIT 1 OFFSET 1\"\n     afterModification:^BOOL {\n         return [self.table deleteObjectsWhere:TestCaseObject.identifier > 0 orders:TestCaseObject.identifier.asOrder(WCTOrderedDescending) limit:1 offset:1];\n     }];\n}\n\n#pragma mark - Handle - Delete\n- (void)test_handle_delete\n{\n    [self doTestObjects:@[]\n                 andSQL:@\"DELETE FROM testTable\"\n      afterModification:^BOOL {\n          return [[self.database getHandle] deleteFromTable:self.tableName];\n      }];\n}\n\n- (void)test_handle_delete_where\n{\n    [self doTestObject:self.object1\n                andSQL:@\"DELETE FROM testTable WHERE identifier == 2\"\n     afterModification:^BOOL {\n         return [[self.database getHandle] deleteFromTable:self.tableName where:TestCaseObject.identifier == 2];\n     }];\n}\n\n- (void)test_handle_delete_limit\n{\n    [self doTestObject:self.object2\n                andSQL:@\"DELETE FROM testTable LIMIT 1\"\n     afterModification:^BOOL {\n         return [[self.database getHandle] deleteFromTable:self.tableName limit:1];\n     }];\n}\n\n- (void)test_handle_delete_where_limit\n{\n    [self doTestObject:self.object2\n                andSQL:@\"DELETE FROM testTable WHERE identifier > 0 LIMIT 1\"\n     afterModification:^BOOL {\n         return [[self.database getHandle] deleteFromTable:self.tableName where:TestCaseObject.identifier > 0 limit:1];\n     }];\n}\n\n- (void)test_handle_delete_orders_limit\n{\n    [self doTestObject:self.object1\n                andSQL:@\"DELETE FROM testTable ORDER BY identifier DESC LIMIT 1\"\n     afterModification:^BOOL {\n         return [[self.database getHandle] deleteFromTable:self.tableName orders:TestCaseObject.identifier.asOrder(WCTOrderedDescending) limit:1];\n     }];\n}\n\n- (void)test_handle_delete_limit_offset\n{\n    [self doTestObject:self.object1\n                andSQL:@\"DELETE FROM testTable LIMIT 1 OFFSET 1\"\n     afterModification:^BOOL {\n         return [[self.database getHandle] deleteFromTable:self.tableName limit:1 offset:1];\n     }];\n}\n\n- (void)test_handle_delete_where_orders_limit\n{\n    [self doTestObject:self.object1\n                andSQL:@\"DELETE FROM testTable WHERE identifier > 0 ORDER BY identifier DESC LIMIT 1\"\n     afterModification:^BOOL {\n         return [[self.database getHandle] deleteFromTable:self.tableName where:TestCaseObject.identifier > 0 orders:TestCaseObject.identifier.asOrder(WCTOrderedDescending) limit:1];\n     }];\n}\n\n- (void)test_handle_delete_where_limit_offset\n{\n    [self doTestObject:self.object2\n                andSQL:@\"DELETE FROM testTable WHERE identifier > 0 ORDER BY identifier DESC LIMIT 1 OFFSET 1\"\n     afterModification:^BOOL {\n         return [[self.database getHandle] deleteFromTable:self.tableName where:TestCaseObject.identifier > 0 orders:TestCaseObject.identifier.asOrder(WCTOrderedDescending) limit:1 offset:1];\n     }];\n}\n\n- (void)test_handle_delete_orders_limit_offset\n{\n    [self doTestObject:self.object2\n                andSQL:@\"DELETE FROM testTable ORDER BY identifier DESC LIMIT 1 OFFSET 1\"\n     afterModification:^BOOL {\n         return [[self.database getHandle] deleteFromTable:self.tableName orders:TestCaseObject.identifier.asOrder(WCTOrderedDescending) limit:1 offset:1];\n     }];\n}\n\n- (void)test_handle_delete_where_orders_limit_offset\n{\n    [self doTestObject:self.object2\n                andSQL:@\"DELETE FROM testTable WHERE identifier > 0 ORDER BY identifier DESC LIMIT 1 OFFSET 1\"\n     afterModification:^BOOL {\n         return [[self.database getHandle] deleteFromTable:self.tableName where:TestCaseObject.identifier > 0 orders:TestCaseObject.identifier.asOrder(WCTOrderedDescending) limit:1 offset:1];\n     }];\n}\n\n@end\n"
  },
  {
    "path": "src/objc/tests/convenient/ConvenientInsertTests.mm",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"TestCase.h\"\n\n@interface ConvenientInsertTests : CRUDTestCase\n\n@property (nonatomic, readonly) TestCaseObject* renewedObject1;\n@property (nonatomic, readonly) TestCaseObject* renewedObject2;\n\n@property (nonatomic, readonly) TestCaseObject* renewedPartialObject1;\n@property (nonatomic, readonly) TestCaseObject* renewedPartialObject2;\n\n@property (nonatomic, readonly) TestCaseObject* object3;\n@property (nonatomic, readonly) TestCaseObject* object4;\n\n@property (nonatomic, readonly) TestCaseObject* partialObject3;\n@property (nonatomic, readonly) TestCaseObject* partialObject4;\n\n@end\n\n@implementation ConvenientInsertTests {\n    TestCaseObject* _renewedObject1;\n    TestCaseObject* _renewedObject2;\n\n    TestCaseObject* _renewedPartialObject1;\n    TestCaseObject* _renewedPartialObject2;\n\n    TestCaseObject* _object3;\n    TestCaseObject* _object4;\n\n    TestCaseObject* _partialObject3;\n    TestCaseObject* _partialObject4;\n}\n\n- (void)setUp\n{\n    [super setUp];\n    [self insertPresetObjects];\n}\n\n- (TestCaseObject*)renewedObject1\n{\n    @synchronized(self) {\n        if (_renewedObject1 == nil) {\n            _renewedObject1 = [Random.shared testCaseObjectWithIdentifier:1];\n        }\n        return _renewedObject1;\n    }\n}\n\n- (TestCaseObject*)renewedObject2\n{\n    @synchronized(self) {\n        if (_renewedObject2 == nil) {\n            _renewedObject2 = [Random.shared testCaseObjectWithIdentifier:2];\n        }\n        return _renewedObject2;\n    }\n}\n\n- (TestCaseObject*)renewedPartialObject1\n{\n    @synchronized(self) {\n        if (_renewedPartialObject1 == nil) {\n            _renewedPartialObject1 = [TestCaseObject partialObjectWithIdentifier:1];\n        }\n        return _renewedPartialObject1;\n    }\n}\n\n- (TestCaseObject*)renewedPartialObject2\n{\n    @synchronized(self) {\n        if (_renewedPartialObject2 == nil) {\n            _renewedPartialObject2 = [TestCaseObject partialObjectWithIdentifier:2];\n        }\n        return _renewedPartialObject2;\n    }\n}\n\n- (TestCaseObject*)object3\n{\n    @synchronized(self) {\n        if (_object3 == nil) {\n            _object3 = [Random.shared testCaseObjectWithIdentifier:3];\n        }\n        return _object3;\n    }\n}\n\n- (TestCaseObject*)object4\n{\n    @synchronized(self) {\n        if (_object4 == nil) {\n            _object4 = [Random.shared testCaseObjectWithIdentifier:4];\n        }\n        return _object4;\n    }\n}\n\n- (TestCaseObject*)partialObject3\n{\n    @synchronized(self) {\n        if (_partialObject3 == nil) {\n            _partialObject3 = [TestCaseObject partialObjectWithIdentifier:3];\n        }\n        return _partialObject3;\n    }\n}\n\n- (TestCaseObject*)partialObject4\n{\n    @synchronized(self) {\n        if (_partialObject4 == nil) {\n            _partialObject4 = [TestCaseObject partialObjectWithIdentifier:4];\n        }\n        return _partialObject4;\n    }\n}\n\n#pragma mark - Auto Increment\n- (void)test_auto_increment\n{\n    TestCaseObject* autoIncrementObject = [TestCaseObject autoIncrementObjectWithContent:self.object3.content];\n    [self doTestObjects:@[ self.object1, self.object2, self.object3 ]\n              andNumber:1\n           ofInsertSQLs:@\"INSERT INTO testTable(identifier, content) VALUES(?1, ?2)\"\n         afterInsertion:^BOOL {\n             BOOL result = [self.database insertObject:autoIncrementObject intoTable:self.tableName];\n             if (result) {\n                 autoIncrementObject.identifier = (int) autoIncrementObject.lastInsertedRowID;\n             }\n             return result;\n         }];\n    TestCaseAssertTrue([autoIncrementObject isEqual:self.object3]);\n}\n\n- (void)test_auto_increment_with_partial_insert\n{\n    TestCaseObject* autoIncrementObject = [TestCaseObject autoIncrementObjectWithContent:self.object3.content];\n    [self doTestObjects:@[ self.object1, self.object2, self.object3 ]\n              andNumber:1\n           ofInsertSQLs:@\"INSERT INTO testTable(content) VALUES(?1)\"\n         afterInsertion:^BOOL {\n             BOOL result = [self.database insertObject:autoIncrementObject onProperties:TestCaseObject.content intoTable:self.tableName];\n             if (result) {\n                 autoIncrementObject.identifier = (int) autoIncrementObject.lastInsertedRowID;\n             }\n             return result;\n         }];\n    TestCaseAssertTrue([autoIncrementObject isEqual:self.object3]);\n}\n\n#pragma mark - Database - Insert\n- (void)test_database_insert_object\n{\n    [self doTestObjects:@[ self.object1, self.object2, self.object3 ]\n              andNumber:1\n           ofInsertSQLs:@\"INSERT INTO testTable(identifier, content) VALUES(?1, ?2)\"\n         afterInsertion:^BOOL {\n             return [self.database insertObject:self.object3 intoTable:self.tableName];\n         }];\n}\n\n- (void)test_database_insert_objects\n{\n    [self doTestObjects:@[ self.object1, self.object2, self.object3, self.object4 ]\n              andNumber:2\n           ofInsertSQLs:@\"INSERT INTO testTable(identifier, content) VALUES(?1, ?2)\"\n         afterInsertion:^BOOL {\n             return [self.database insertObjects:@[ self.object3, self.object4 ] intoTable:self.tableName];\n         }];\n}\n\n#pragma mark - Database - Insert or Replace\n- (void)test_database_insert_or_replace_object\n{\n    [self doTestObjects:@[ self.renewedObject1, self.object2 ]\n              andNumber:1\n           ofInsertSQLs:@\"INSERT OR REPLACE INTO testTable(identifier, content) VALUES(?1, ?2)\"\n         afterInsertion:^BOOL {\n             return [self.database insertOrReplaceObject:self.renewedObject1 intoTable:self.tableName];\n         }];\n}\n\n- (void)test_database_insert_or_replace_objects\n{\n    [self doTestObjects:@[ self.renewedObject1, self.renewedObject2 ]\n              andNumber:2\n           ofInsertSQLs:@\"INSERT OR REPLACE INTO testTable(identifier, content) VALUES(?1, ?2)\"\n         afterInsertion:^BOOL {\n             return [self.database insertOrReplaceObjects:@[ self.renewedObject1, self.renewedObject2 ] intoTable:self.tableName];\n         }];\n}\n\n#pragma mark - Database - Insert or Ignore\n- (void)test_database_insert_or_ignore_object\n{\n    [self doTestObjects:@[ self.object1, self.object2 ]\n              andNumber:1\n           ofInsertSQLs:@\"INSERT OR IGNORE INTO testTable(identifier, content) VALUES(?1, ?2)\"\n         afterInsertion:^BOOL {\n             return [self.database insertOrIgnoreObject:self.renewedObject1 intoTable:self.tableName];\n         }];\n}\n\n- (void)test_database_insert_or_ignore_objects\n{\n    [self doTestObjects:@[ self.object1, self.object2 ]\n              andNumber:2\n           ofInsertSQLs:@\"INSERT OR IGNORE INTO testTable(identifier, content) VALUES(?1, ?2)\"\n         afterInsertion:^BOOL {\n             return [self.database insertOrIgnoreObjects:@[ self.renewedObject1, self.renewedObject2 ] intoTable:self.tableName];\n         }];\n}\n\n#pragma mark - Database - Partial Insert\n- (void)test_database_insert_object_on_properties\n{\n    [self doTestObjects:@[ self.object1, self.object2, self.partialObject3 ]\n              andNumber:1\n           ofInsertSQLs:@\"INSERT INTO testTable(identifier) VALUES(?1)\"\n         afterInsertion:^BOOL {\n             return [self.database insertObject:self.object3 onProperties:TestCaseObject.identifier intoTable:self.tableName];\n         }];\n}\n\n- (void)test_database_insert_objects_on_properties\n{\n    [self doTestObjects:@[ self.object1, self.object2, self.partialObject3, self.partialObject4 ]\n              andNumber:2\n           ofInsertSQLs:@\"INSERT INTO testTable(identifier) VALUES(?1)\"\n         afterInsertion:^BOOL {\n             return [self.database insertObjects:@[ self.object3, self.object4 ] onProperties:TestCaseObject.identifier intoTable:self.tableName];\n         }];\n}\n\n#pragma mark - Database - Partial Insert or Replace\n- (void)test_database_insert_or_replace_object_on_properties\n{\n    [self doTestObjects:@[ self.renewedPartialObject1, self.object2 ]\n              andNumber:1\n           ofInsertSQLs:@\"INSERT OR REPLACE INTO testTable(identifier) VALUES(?1)\"\n         afterInsertion:^BOOL {\n             return [self.database insertOrReplaceObject:self.object1 onProperties:TestCaseObject.identifier intoTable:self.tableName];\n         }];\n}\n\n- (void)test_database_insert_or_replace_objects_on_properties\n{\n    [self doTestObjects:@[ self.renewedPartialObject1, self.renewedPartialObject2 ]\n              andNumber:2\n           ofInsertSQLs:@\"INSERT OR REPLACE INTO testTable(identifier) VALUES(?1)\"\n         afterInsertion:^BOOL {\n             return [self.database insertOrReplaceObjects:@[ self.object1, self.object2 ] onProperties:TestCaseObject.identifier intoTable:self.tableName];\n         }];\n}\n\n#pragma mark - Database - Partial Insert or Ignore\n- (void)test_database_insert_or_ignore_object_on_properties\n{\n    [self doTestObjects:@[ self.object1, self.object2 ]\n              andNumber:1\n           ofInsertSQLs:@\"INSERT OR IGNORE INTO testTable(identifier) VALUES(?1)\"\n         afterInsertion:^BOOL {\n             return [self.database insertOrIgnoreObject:self.object1 onProperties:TestCaseObject.identifier intoTable:self.tableName];\n         }];\n}\n\n- (void)test_database_insert_or_ignore_objects_on_properties\n{\n    [self doTestObjects:@[ self.object1, self.object2 ]\n              andNumber:2\n           ofInsertSQLs:@\"INSERT OR IGNORE INTO testTable(identifier) VALUES(?1)\"\n         afterInsertion:^BOOL {\n             return [self.database insertOrIgnoreObjects:@[ self.object1, self.object2 ] onProperties:TestCaseObject.identifier intoTable:self.tableName];\n         }];\n}\n\n#pragma mark - Table - Insert\n- (void)test_table_insert_object\n{\n    [self doTestObjects:@[ self.object1, self.object2, self.object3 ]\n              andNumber:1\n           ofInsertSQLs:@\"INSERT INTO testTable(identifier, content) VALUES(?1, ?2)\"\n         afterInsertion:^BOOL {\n             return [self.table insertObject:self.object3];\n         }];\n}\n\n- (void)test_table_insert_objects\n{\n    [self doTestObjects:@[ self.object1, self.object2, self.object3, self.object4 ]\n              andNumber:2\n           ofInsertSQLs:@\"INSERT INTO testTable(identifier, content) VALUES(?1, ?2)\"\n         afterInsertion:^BOOL {\n             return [self.table insertObjects:@[ self.object3, self.object4 ]];\n         }];\n}\n\n#pragma mark - Table - Insert or Replace\n- (void)test_table_insert_or_replace_object\n{\n    [self doTestObjects:@[ self.renewedObject1, self.object2 ]\n              andNumber:1\n           ofInsertSQLs:@\"INSERT OR REPLACE INTO testTable(identifier, content) VALUES(?1, ?2)\"\n         afterInsertion:^BOOL {\n             return [self.table insertOrReplaceObject:self.renewedObject1];\n         }];\n}\n\n- (void)test_table_insert_or_replace_objects\n{\n    [self doTestObjects:@[ self.renewedObject1, self.renewedObject2 ]\n              andNumber:2\n           ofInsertSQLs:@\"INSERT OR REPLACE INTO testTable(identifier, content) VALUES(?1, ?2)\"\n         afterInsertion:^BOOL {\n             return [self.table insertOrReplaceObjects:@[ self.renewedObject1, self.renewedObject2 ]];\n         }];\n}\n\n#pragma mark - Table - Insert or Ignore\n- (void)test_table_insert_or_ignore_object\n{\n    [self doTestObjects:@[ self.object1, self.object2 ]\n              andNumber:1\n           ofInsertSQLs:@\"INSERT OR IGNORE INTO testTable(identifier, content) VALUES(?1, ?2)\"\n         afterInsertion:^BOOL {\n             return [self.table insertOrIgnoreObject:self.renewedObject1];\n         }];\n}\n\n- (void)test_table_insert_or_ignore_objects\n{\n    [self doTestObjects:@[ self.object1, self.object2 ]\n              andNumber:2\n           ofInsertSQLs:@\"INSERT OR IGNORE INTO testTable(identifier, content) VALUES(?1, ?2)\"\n         afterInsertion:^BOOL {\n             return [self.table insertOrIgnoreObjects:@[ self.renewedObject1, self.renewedObject2 ]];\n         }];\n}\n\n#pragma mark - Table - Partial Insert\n- (void)test_table_insert_object_on_properties\n{\n    [self doTestObjects:@[ self.object1, self.object2, self.partialObject3 ]\n              andNumber:1\n           ofInsertSQLs:@\"INSERT INTO testTable(identifier) VALUES(?1)\"\n         afterInsertion:^BOOL {\n             return [self.table insertObject:self.object3 onProperties:TestCaseObject.identifier];\n         }];\n}\n\n- (void)test_table_insert_objects_on_properties\n{\n    [self doTestObjects:@[ self.object1, self.object2, self.partialObject3, self.partialObject4 ]\n              andNumber:2\n           ofInsertSQLs:@\"INSERT INTO testTable(identifier) VALUES(?1)\"\n         afterInsertion:^BOOL {\n             return [self.table insertObjects:@[ self.object3, self.object4 ] onProperties:TestCaseObject.identifier];\n         }];\n}\n\n#pragma mark - Table - Partial Insert or Replace\n- (void)test_table_insert_or_replace_object_on_properties\n{\n    [self doTestObjects:@[ self.renewedPartialObject1, self.object2 ]\n              andNumber:1\n           ofInsertSQLs:@\"INSERT OR REPLACE INTO testTable(identifier) VALUES(?1)\"\n         afterInsertion:^BOOL {\n             return [self.table insertOrReplaceObject:self.object1 onProperties:TestCaseObject.identifier];\n         }];\n}\n\n- (void)test_table_insert_or_replace_objects_on_properties\n{\n    [self doTestObjects:@[ self.renewedPartialObject1, self.renewedPartialObject2 ]\n              andNumber:2\n           ofInsertSQLs:@\"INSERT OR REPLACE INTO testTable(identifier) VALUES(?1)\"\n         afterInsertion:^BOOL {\n             return [self.table insertOrReplaceObjects:@[ self.object1, self.object2 ] onProperties:TestCaseObject.identifier];\n         }];\n}\n\n#pragma mark - Table - Partial Insert or Replace\n- (void)test_table_insert_or_ignore_object_on_properties\n{\n    [self doTestObjects:@[ self.object1, self.object2 ]\n              andNumber:1\n           ofInsertSQLs:@\"INSERT OR IGNORE INTO testTable(identifier) VALUES(?1)\"\n         afterInsertion:^BOOL {\n             return [self.table insertOrIgnoreObject:self.object1 onProperties:TestCaseObject.identifier];\n         }];\n}\n\n- (void)test_table_insert_or_ignore_objects_on_properties\n{\n    [self doTestObjects:@[ self.object1, self.object2 ]\n              andNumber:2\n           ofInsertSQLs:@\"INSERT OR IGNORE INTO testTable(identifier) VALUES(?1)\"\n         afterInsertion:^BOOL {\n             return [self.table insertOrIgnoreObjects:@[ self.object1, self.object2 ] onProperties:TestCaseObject.identifier];\n         }];\n}\n\n#pragma mark - Handle - Insert\n- (void)test_handle_insert_object\n{\n    [self doTestObjects:@[ self.object1, self.object2, self.object3 ]\n              andNumber:1\n           ofInsertSQLs:@\"INSERT INTO testTable(identifier, content) VALUES(?1, ?2)\"\n         afterInsertion:^BOOL {\n             return [[self.database getHandle] insertObject:self.object3 intoTable:self.tableName];\n         }];\n}\n\n- (void)test_handle_insert_objects\n{\n    [self doTestObjects:@[ self.object1, self.object2, self.object3, self.object4 ]\n              andNumber:2\n           ofInsertSQLs:@\"INSERT INTO testTable(identifier, content) VALUES(?1, ?2)\"\n         afterInsertion:^BOOL {\n             return [[self.database getHandle] insertObjects:@[ self.object3, self.object4 ] intoTable:self.tableName];\n         }];\n}\n\n#pragma mark - Handle - Insert or Replace\n- (void)test_handle_insert_or_replace_object\n{\n    [self doTestObjects:@[ self.renewedObject1, self.object2 ]\n              andNumber:1\n           ofInsertSQLs:@\"INSERT OR REPLACE INTO testTable(identifier, content) VALUES(?1, ?2)\"\n         afterInsertion:^BOOL {\n             return [[self.database getHandle] insertOrReplaceObject:self.renewedObject1 intoTable:self.tableName];\n         }];\n}\n\n- (void)test_handle_insert_or_replace_objects\n{\n    [self doTestObjects:@[ self.renewedObject1, self.renewedObject2 ]\n              andNumber:2\n           ofInsertSQLs:@\"INSERT OR REPLACE INTO testTable(identifier, content) VALUES(?1, ?2)\"\n         afterInsertion:^BOOL {\n             return [[self.database getHandle] insertOrReplaceObjects:@[ self.renewedObject1, self.renewedObject2 ] intoTable:self.tableName];\n         }];\n}\n\n#pragma mark - Handle - Partial Insert\n- (void)test_handle_insert_object_on_properties\n{\n    [self doTestObjects:@[ self.object1, self.object2, self.partialObject3 ]\n              andNumber:1\n           ofInsertSQLs:@\"INSERT INTO testTable(identifier) VALUES(?1)\"\n         afterInsertion:^BOOL {\n             return [[self.database getHandle] insertObject:self.object3 onProperties:TestCaseObject.identifier intoTable:self.tableName];\n         }];\n}\n\n- (void)test_handle_insert_objects_on_properties\n{\n    [self doTestObjects:@[ self.object1, self.object2, self.partialObject3, self.partialObject4 ]\n              andNumber:2\n           ofInsertSQLs:@\"INSERT INTO testTable(identifier) VALUES(?1)\"\n         afterInsertion:^BOOL {\n             return [[self.database getHandle] insertObjects:@[ self.object3, self.object4 ] onProperties:TestCaseObject.identifier intoTable:self.tableName];\n         }];\n}\n\n#pragma mark - Handle - Partial Insert or Replace\n- (void)test_handle_insert_or_replace_object_on_properties\n{\n    [self doTestObjects:@[ self.renewedPartialObject1, self.object2 ]\n              andNumber:1\n           ofInsertSQLs:@\"INSERT OR REPLACE INTO testTable(identifier) VALUES(?1)\"\n         afterInsertion:^BOOL {\n             return [[self.database getHandle] insertOrReplaceObject:self.object1 onProperties:TestCaseObject.identifier intoTable:self.tableName];\n         }];\n}\n\n- (void)test_handle_insert_or_replace_objects_on_properties\n{\n    [self doTestObjects:@[ self.renewedPartialObject1, self.renewedPartialObject2 ]\n              andNumber:2\n           ofInsertSQLs:@\"INSERT OR REPLACE INTO testTable(identifier) VALUES(?1)\"\n         afterInsertion:^BOOL {\n             return [[self.database getHandle] insertOrReplaceObjects:@[ self.object1, self.object2 ] onProperties:TestCaseObject.identifier intoTable:self.tableName];\n         }];\n}\n\n@end\n"
  },
  {
    "path": "src/objc/tests/convenient/ConvenientSelectTests.mm",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"CRUDTestCase.h\"\n#import \"TestCase.h\"\n\n@interface ConvenientSelectTests : CRUDTestCase\n\n@property (nonatomic, readonly) TestCaseObject *partialObject1;\n@property (nonatomic, readonly) TestCaseObject *partialObject2;\n@property (nonatomic, readonly) NSArray<TestCaseObject *> *partialObjects;\n\n@property (nonatomic, readonly) WCTOneRow *partialRow1;\n@property (nonatomic, readonly) WCTOneRow *partialRow2;\n@property (nonatomic, readonly) WCTColumnsXRows *partialRows;\n\n@property (nonatomic, readonly) WCTValue *value1;\n@property (nonatomic, readonly) WCTValue *value2;\n@property (nonatomic, readonly) WCTOneColumn *column;\n\n@end\n\n@implementation ConvenientSelectTests {\n    TestCaseObject *_partialObject1;\n    TestCaseObject *_partialObject2;\n    NSArray<TestCaseObject *> *_partialObjects;\n\n    WCTOneRow *_partialRow1;\n    WCTOneRow *_partialRow2;\n    WCTColumnsXRows *_partialRows;\n\n    WCTValue *_value1;\n    WCTValue *_value2;\n    WCTOneColumn *_column;\n}\n\n- (void)setUp\n{\n    [super setUp];\n    [self insertPresetObjects];\n}\n\n- (TestCaseObject *)partialObject1\n{\n    @synchronized(self) {\n        if (_partialObject1 == nil) {\n            _partialObject1 = [TestCaseObject partialObjectWithIdentifier:1];\n        }\n        return _partialObject1;\n    }\n}\n\n- (TestCaseObject *)partialObject2\n{\n    @synchronized(self) {\n        if (_partialObject2 == nil) {\n            _partialObject2 = [TestCaseObject partialObjectWithIdentifier:2];\n        }\n        return _partialObject2;\n    }\n}\n\n- (NSArray<TestCaseObject *> *)partialObjects\n{\n    @synchronized(self) {\n        if (_partialObjects == nil) {\n            _partialObjects = @[ self.partialObject1, self.partialObject2 ];\n        }\n        return _partialObjects;\n    }\n}\n\n- (WCTOneRow *)partialRow1\n{\n    @synchronized(self) {\n        if (_partialRow1 == nil) {\n            _partialRow1 = @[ @(1) ];\n        }\n        return _partialRow1;\n    }\n}\n\n- (WCTOneRow *)partialRow2\n{\n    @synchronized(self) {\n        if (_partialRow2 == nil) {\n            _partialRow2 = @[ @(2) ];\n        }\n        return _partialRow2;\n    }\n}\n\n- (WCTColumnsXRows *)partialRows\n{\n    @synchronized(self) {\n        if (_partialRows == nil) {\n            _partialRows = @[ self.partialRow1, self.partialRow2 ];\n        }\n        return _partialRows;\n    }\n}\n\n- (WCTValue *)value1\n{\n    @synchronized(self) {\n        if (_value1 == nil) {\n            _value1 = @(1);\n        }\n        return _value1;\n    }\n}\n\n- (WCTValue *)value2\n{\n    @synchronized(self) {\n        if (_value2 == nil) {\n            _value2 = @(2);\n        }\n        return _value2;\n    }\n}\n\n- (WCTOneColumn *)column\n{\n    @synchronized(self) {\n        if (_column == nil) {\n            _column = @[ self.value1, self.value2 ];\n        }\n        return _column;\n    }\n}\n\n#pragma mark - Database - Get Object\n- (void)test_database_get_object\n{\n    [self doTestObject:self.object1\n                andSQL:@\"SELECT identifier, content FROM testTable ORDER BY rowid ASC LIMIT 1\"\n           bySelecting:^NSArray<TestCaseObject *> * {\n               return @[ [self.database getObjectOfClass:self.tableClass fromTable:self.tableName] ];\n           }];\n}\n\n- (void)test_database_get_object_where\n{\n    [self doTestObject:self.object2\n                andSQL:@\"SELECT identifier, content FROM testTable WHERE identifier == 2 ORDER BY rowid ASC LIMIT 1\"\n           bySelecting:^NSArray<TestCaseObject *> * {\n               return @[ [self.database getObjectOfClass:self.tableClass fromTable:self.tableName where:TestCaseObject.identifier == 2] ];\n           }];\n}\n\n- (void)test_database_get_object_orders\n{\n    [self doTestObject:self.object2\n                andSQL:@\"SELECT identifier, content FROM testTable ORDER BY identifier DESC LIMIT 1\"\n           bySelecting:^NSArray<TestCaseObject *> * {\n               return @[ [self.database getObjectOfClass:self.tableClass fromTable:self.tableName orders:TestCaseObject.identifier.asOrder(WCTOrderedDescending)] ];\n           }];\n}\n\n- (void)test_database_get_object_offset\n{\n    [self doTestObject:self.object2\n                andSQL:@\"SELECT identifier, content FROM testTable ORDER BY rowid ASC LIMIT 1 OFFSET 1\"\n           bySelecting:^NSArray<TestCaseObject *> * {\n               return @[ [self.database getObjectOfClass:self.tableClass fromTable:self.tableName offset:1] ];\n           }];\n}\n\n- (void)test_database_get_object_where_orders\n{\n    [self doTestObject:self.object2\n                andSQL:@\"SELECT identifier, content FROM testTable WHERE identifier > 0 ORDER BY identifier DESC LIMIT 1\"\n           bySelecting:^NSArray<TestCaseObject *> * {\n               return @[ [self.database getObjectOfClass:self.tableClass fromTable:self.tableName where:TestCaseObject.identifier > 0 orders:TestCaseObject.identifier.asOrder(WCTOrderedDescending)] ];\n           }];\n}\n\n- (void)test_database_get_object_where_offset\n{\n    [self doTestObject:self.object2\n                andSQL:@\"SELECT identifier, content FROM testTable WHERE identifier > 0 ORDER BY rowid ASC LIMIT 1 OFFSET 1\"\n           bySelecting:^NSArray<TestCaseObject *> * {\n               return @[ [self.database getObjectOfClass:self.tableClass fromTable:self.tableName where:TestCaseObject.identifier > 0 offset:1] ];\n           }];\n}\n\n- (void)test_database_get_object_orders_offset\n{\n    [self doTestObject:self.object1\n                andSQL:@\"SELECT identifier, content FROM testTable ORDER BY identifier DESC LIMIT 1 OFFSET 1\"\n           bySelecting:^NSArray<TestCaseObject *> * {\n               return @[ [self.database getObjectOfClass:self.tableClass fromTable:self.tableName orders:TestCaseObject.identifier.asOrder(WCTOrderedDescending) offset:1] ];\n           }];\n}\n\n- (void)test_database_get_object_where_orders_offset\n{\n    [self doTestObject:self.object1\n                andSQL:@\"SELECT identifier, content FROM testTable WHERE identifier > 0 ORDER BY identifier DESC LIMIT 1 OFFSET 1\"\n           bySelecting:^NSArray<TestCaseObject *> * {\n               return @[ [self.database getObjectOfClass:self.tableClass fromTable:self.tableName where:TestCaseObject.identifier > 0 orders:TestCaseObject.identifier.asOrder(WCTOrderedDescending) offset:1] ];\n           }];\n}\n\n#pragma mark - Database - Get Objects\n- (void)test_database_get_objects\n{\n    [self doTestObjects:self.objects\n                 andSQL:@\"SELECT identifier, content FROM testTable ORDER BY rowid ASC\"\n            bySelecting:^NSArray<TestCaseObject *> * {\n                return [self.database getObjectsOfClass:self.tableClass fromTable:self.tableName];\n            }];\n}\n\n- (void)test_database_get_objects_where\n{\n    [self doTestObject:self.object1\n                andSQL:@\"SELECT identifier, content FROM testTable WHERE identifier == 1 ORDER BY rowid ASC\"\n           bySelecting:^NSArray<TestCaseObject *> * {\n               return [self.database getObjectsOfClass:self.tableClass fromTable:self.tableName where:TestCaseObject.identifier == 1];\n           }];\n}\n\n- (void)test_database_get_objects_orders\n{\n    [self doTestObjects:self.objects.reversedArray\n                 andSQL:@\"SELECT identifier, content FROM testTable ORDER BY identifier DESC\"\n            bySelecting:^NSArray<TestCaseObject *> * {\n                return [self.database getObjectsOfClass:self.tableClass fromTable:self.tableName orders:TestCaseObject.identifier.asOrder(WCTOrderedDescending)];\n            }];\n}\n\n- (void)test_database_get_objects_limit\n{\n    [self doTestObject:self.object1\n                andSQL:@\"SELECT identifier, content FROM testTable ORDER BY rowid ASC LIMIT 1\"\n           bySelecting:^NSArray<TestCaseObject *> * {\n               return [self.database getObjectsOfClass:self.tableClass fromTable:self.tableName limit:1];\n           }];\n}\n\n- (void)test_database_get_objects_where_orders\n{\n    [self doTestObjects:self.objects.reversedArray\n                 andSQL:@\"SELECT identifier, content FROM testTable WHERE identifier > 0 ORDER BY identifier DESC\"\n            bySelecting:^NSArray<TestCaseObject *> * {\n                return [self.database getObjectsOfClass:self.tableClass fromTable:self.tableName where:TestCaseObject.identifier > 0 orders:TestCaseObject.identifier.asOrder(WCTOrderedDescending)];\n            }];\n}\n\n- (void)test_database_get_objects_where_limit\n{\n    [self doTestObject:self.object2\n                andSQL:@\"SELECT identifier, content FROM testTable WHERE identifier > 1 ORDER BY rowid ASC LIMIT 1\"\n           bySelecting:^NSArray<TestCaseObject *> * {\n               return [self.database getObjectsOfClass:self.tableClass fromTable:self.tableName where:TestCaseObject.identifier > 1 limit:1];\n           }];\n}\n\n- (void)test_database_get_objects_orders_limit\n{\n    [self doTestObject:self.object2\n                andSQL:@\"SELECT identifier, content FROM testTable ORDER BY identifier DESC LIMIT 1\"\n           bySelecting:^NSArray<TestCaseObject *> * {\n               return [self.database getObjectsOfClass:self.tableClass fromTable:self.tableName orders:TestCaseObject.identifier.asOrder(WCTOrderedDescending) limit:1];\n           }];\n}\n\n- (void)test_database_get_objects_limit_offset\n{\n    [self doTestObject:self.object2\n                andSQL:@\"SELECT identifier, content FROM testTable ORDER BY rowid ASC LIMIT 1 OFFSET 1\"\n           bySelecting:^NSArray<TestCaseObject *> * {\n               return [self.database getObjectsOfClass:self.tableClass fromTable:self.tableName limit:1 offset:1];\n           }];\n}\n\n- (void)test_database_get_objects_where_orders_limit\n{\n    [self doTestObject:self.object2\n                andSQL:@\"SELECT identifier, content FROM testTable WHERE identifier > 0 ORDER BY identifier DESC LIMIT 1\"\n           bySelecting:^NSArray<TestCaseObject *> * {\n               return [self.database getObjectsOfClass:self.tableClass fromTable:self.tableName where:TestCaseObject.identifier > 0 orders:TestCaseObject.identifier.asOrder(WCTOrderedDescending) limit:1];\n           }];\n}\n\n- (void)test_database_get_objects_where_limit_offset\n{\n    [self doTestObject:self.object2\n                andSQL:@\"SELECT identifier, content FROM testTable WHERE identifier > 0 ORDER BY rowid ASC LIMIT 1 OFFSET 1\"\n           bySelecting:^NSArray<TestCaseObject *> * {\n               return [self.database getObjectsOfClass:self.tableClass fromTable:self.tableName where:TestCaseObject.identifier > 0 limit:1 offset:1];\n           }];\n}\n\n- (void)test_database_get_objects_orders_limit_offset\n{\n    [self doTestObject:self.object1\n                andSQL:@\"SELECT identifier, content FROM testTable ORDER BY identifier DESC LIMIT 1 OFFSET 1\"\n           bySelecting:^NSArray<TestCaseObject *> * {\n               return [self.database getObjectsOfClass:self.tableClass fromTable:self.tableName orders:TestCaseObject.identifier.asOrder(WCTOrderedDescending) limit:1 offset:1];\n           }];\n}\n\n- (void)test_database_get_objects_where_orders_limit_offset\n{\n    [self doTestObject:self.object1\n                andSQL:@\"SELECT identifier, content FROM testTable WHERE identifier > 0 ORDER BY identifier DESC LIMIT 1 OFFSET 1\"\n           bySelecting:^NSArray<TestCaseObject *> * {\n               return [self.database getObjectsOfClass:self.tableClass fromTable:self.tableName where:TestCaseObject.identifier > 0 orders:TestCaseObject.identifier.asOrder(WCTOrderedDescending) limit:1 offset:1];\n           }];\n}\n\n#pragma mark - Database - Get Part Of Object\n- (void)test_database_get_object_on_result_columns\n{\n    [self doTestObject:self.partialObject1\n                andSQL:@\"SELECT identifier FROM testTable ORDER BY rowid ASC LIMIT 1\"\n           bySelecting:^NSArray<TestCaseObject *> * {\n               return @[ [self.database getObjectOnResultColumns:TestCaseObject.identifier fromTable:self.tableName] ];\n           }];\n}\n\n- (void)test_database_get_object_on_result_columns_where\n{\n    [self doTestObject:self.partialObject1\n                andSQL:@\"SELECT identifier FROM testTable WHERE identifier == 1 ORDER BY rowid ASC LIMIT 1\"\n           bySelecting:^NSArray<TestCaseObject *> * {\n               return @[ [self.database getObjectOnResultColumns:TestCaseObject.identifier fromTable:self.tableName where:TestCaseObject.identifier == 1] ];\n           }];\n}\n\n- (void)test_database_get_object_on_result_columns_orders\n{\n    [self doTestObject:self.partialObject2\n                andSQL:@\"SELECT identifier FROM testTable ORDER BY identifier DESC LIMIT 1\"\n           bySelecting:^NSArray<TestCaseObject *> * {\n               return @[ [self.database getObjectOnResultColumns:TestCaseObject.identifier fromTable:self.tableName orders:TestCaseObject.identifier.asOrder(WCTOrderedDescending)] ];\n           }];\n}\n\n- (void)test_database_get_object_on_result_columns_offset\n{\n    [self doTestObject:self.partialObject2\n                andSQL:@\"SELECT identifier FROM testTable ORDER BY rowid ASC LIMIT 1 OFFSET 1\"\n           bySelecting:^NSArray<TestCaseObject *> * {\n               return @[ [self.database getObjectOnResultColumns:TestCaseObject.identifier fromTable:self.tableName offset:1] ];\n           }];\n}\n\n- (void)test_database_get_object_on_result_columns_where_orders\n{\n    [self doTestObject:self.partialObject2\n                andSQL:@\"SELECT identifier FROM testTable WHERE identifier > 0 ORDER BY identifier DESC LIMIT 1\"\n           bySelecting:^NSArray<TestCaseObject *> * {\n               return @[ [self.database getObjectOnResultColumns:TestCaseObject.identifier fromTable:self.tableName where:TestCaseObject.identifier > 0 orders:TestCaseObject.identifier.asOrder(WCTOrderedDescending)] ];\n           }];\n}\n\n- (void)test_database_get_object_on_result_columns_where_offset\n{\n    [self doTestObject:self.partialObject2\n                andSQL:@\"SELECT identifier FROM testTable WHERE identifier > 0 ORDER BY rowid ASC LIMIT 1 OFFSET 1\"\n           bySelecting:^NSArray<TestCaseObject *> * {\n               return @[ [self.database getObjectOnResultColumns:TestCaseObject.identifier fromTable:self.tableName where:TestCaseObject.identifier > 0 offset:1] ];\n           }];\n}\n\n- (void)test_database_get_object_on_result_columns_orders_offset\n{\n    [self doTestObject:self.partialObject1\n                andSQL:@\"SELECT identifier FROM testTable ORDER BY identifier DESC LIMIT 1 OFFSET 1\"\n           bySelecting:^NSArray<TestCaseObject *> * {\n               return @[ [self.database getObjectOnResultColumns:TestCaseObject.identifier fromTable:self.tableName orders:TestCaseObject.identifier.asOrder(WCTOrderedDescending) offset:1] ];\n           }];\n}\n\n- (void)test_database_get_object_on_result_columns_where_orders_offset\n{\n    [self doTestObject:self.partialObject1\n                andSQL:@\"SELECT identifier FROM testTable WHERE identifier > 0 ORDER BY identifier DESC LIMIT 1 OFFSET 1\"\n           bySelecting:^NSArray<TestCaseObject *> * {\n               return @[ [self.database getObjectOnResultColumns:TestCaseObject.identifier fromTable:self.tableName where:TestCaseObject.identifier > 0 orders:TestCaseObject.identifier.asOrder(WCTOrderedDescending) offset:1] ];\n           }];\n}\n\n#pragma mark - Database - Get Part Of Objects\n- (void)test_database_get_objects_on_result_columns\n{\n    [self doTestObjects:self.partialObjects\n                 andSQL:@\"SELECT identifier FROM testTable ORDER BY rowid ASC\"\n            bySelecting:^NSArray<TestCaseObject *> * {\n                return [self.database getObjectsOnResultColumns:TestCaseObject.identifier fromTable:self.tableName];\n            }];\n}\n\n- (void)test_database_get_objects_on_result_columns_where\n{\n    [self doTestObject:self.partialObject1\n                andSQL:@\"SELECT identifier FROM testTable WHERE identifier == 1 ORDER BY rowid ASC\"\n           bySelecting:^NSArray<TestCaseObject *> * {\n               return [self.database getObjectsOnResultColumns:TestCaseObject.identifier fromTable:self.tableName where:TestCaseObject.identifier == 1];\n           }];\n}\n\n- (void)test_database_get_objects_on_result_columns_orders\n{\n    [self doTestObjects:self.partialObjects.reversedArray\n                 andSQL:@\"SELECT identifier FROM testTable ORDER BY identifier DESC\"\n            bySelecting:^NSArray<TestCaseObject *> * {\n                return [self.database getObjectsOnResultColumns:TestCaseObject.identifier fromTable:self.tableName orders:TestCaseObject.identifier.asOrder(WCTOrderedDescending)];\n            }];\n}\n\n- (void)test_database_get_objects_on_result_columns_limit\n{\n    [self doTestObject:self.partialObject1\n                andSQL:@\"SELECT identifier FROM testTable ORDER BY rowid ASC LIMIT 1\"\n           bySelecting:^NSArray<TestCaseObject *> * {\n               return [self.database getObjectsOnResultColumns:TestCaseObject.identifier fromTable:self.tableName limit:1];\n           }];\n}\n\n- (void)test_database_get_objects_on_result_columns_where_orders\n{\n    [self doTestObjects:self.partialObjects.reversedArray\n                 andSQL:@\"SELECT identifier FROM testTable WHERE identifier > 0 ORDER BY identifier DESC\"\n            bySelecting:^NSArray<TestCaseObject *> * {\n                return [self.database getObjectsOnResultColumns:TestCaseObject.identifier fromTable:self.tableName where:TestCaseObject.identifier > 0 orders:TestCaseObject.identifier.asOrder(WCTOrderedDescending)];\n            }];\n}\n\n- (void)test_database_get_objects_on_result_columns_where_limit\n{\n    [self doTestObject:self.partialObject2\n                andSQL:@\"SELECT identifier FROM testTable WHERE identifier > 1 ORDER BY rowid ASC LIMIT 1\"\n           bySelecting:^NSArray<TestCaseObject *> * {\n               return [self.database getObjectsOnResultColumns:TestCaseObject.identifier fromTable:self.tableName where:TestCaseObject.identifier > 1 limit:1];\n           }];\n}\n\n- (void)test_database_get_objects_on_result_columns_orders_limit\n{\n    [self doTestObject:self.partialObject2\n                andSQL:@\"SELECT identifier FROM testTable ORDER BY identifier DESC LIMIT 1\"\n           bySelecting:^NSArray<TestCaseObject *> * {\n               return [self.database getObjectsOnResultColumns:TestCaseObject.identifier fromTable:self.tableName orders:TestCaseObject.identifier.asOrder(WCTOrderedDescending) limit:1];\n           }];\n}\n\n- (void)test_database_get_objects_on_result_columns_limit_offset\n{\n    [self doTestObject:self.partialObject2\n                andSQL:@\"SELECT identifier FROM testTable ORDER BY rowid ASC LIMIT 1 OFFSET 1\"\n           bySelecting:^NSArray<TestCaseObject *> * {\n               return [self.database getObjectsOnResultColumns:TestCaseObject.identifier fromTable:self.tableName limit:1 offset:1];\n           }];\n}\n\n- (void)test_database_get_objects_on_result_columns_where_orders_limit\n{\n    [self doTestObject:self.partialObject2\n                andSQL:@\"SELECT identifier FROM testTable WHERE identifier > 0 ORDER BY identifier DESC LIMIT 1\"\n           bySelecting:^NSArray<TestCaseObject *> * {\n               return [self.database getObjectsOnResultColumns:TestCaseObject.identifier fromTable:self.tableName where:TestCaseObject.identifier > 0 orders:TestCaseObject.identifier.asOrder(WCTOrderedDescending) limit:1];\n           }];\n}\n\n- (void)test_database_get_objects_on_result_columns_where_limit_offset\n{\n    [self doTestObject:self.partialObject2\n                andSQL:@\"SELECT identifier FROM testTable WHERE identifier > 0 ORDER BY rowid ASC LIMIT 1 OFFSET 1\"\n           bySelecting:^NSArray<TestCaseObject *> * {\n               return [self.database getObjectsOnResultColumns:TestCaseObject.identifier fromTable:self.tableName where:TestCaseObject.identifier > 0 limit:1 offset:1];\n           }];\n}\n\n- (void)test_database_get_objects_on_result_columns_orders_limit_offset\n{\n    [self doTestObject:self.partialObject1\n                andSQL:@\"SELECT identifier FROM testTable ORDER BY identifier DESC LIMIT 1 OFFSET 1\"\n           bySelecting:^NSArray<TestCaseObject *> * {\n               return [self.database getObjectsOnResultColumns:TestCaseObject.identifier fromTable:self.tableName orders:TestCaseObject.identifier.asOrder(WCTOrderedDescending) limit:1 offset:1];\n           }];\n}\n\n- (void)test_database_get_objects_on_result_columns_where_orders_limit_offset\n{\n    [self doTestObject:self.partialObject1\n                andSQL:@\"SELECT identifier FROM testTable WHERE identifier > 0 ORDER BY identifier DESC LIMIT 1 OFFSET 1\"\n           bySelecting:^NSArray<TestCaseObject *> * {\n               return [self.database getObjectsOnResultColumns:TestCaseObject.identifier fromTable:self.tableName where:TestCaseObject.identifier > 0 orders:TestCaseObject.identifier.asOrder(WCTOrderedDescending) limit:1 offset:1];\n           }];\n}\n\n#pragma mark - Database - Get Value\n- (void)test_database_get_value\n{\n    [self doTestValue:@(self.object1.identifier)\n               andSQL:@\"SELECT identifier FROM testTable ORDER BY rowid ASC LIMIT 1\"\n          bySelecting:^WCTValue * {\n              return [self.database getValueOnResultColumn:TestCaseObject.identifier fromTable:self.tableName];\n          }];\n}\n\n- (void)test_database_get_value_where\n{\n    [self doTestValue:@(self.object2.identifier)\n               andSQL:@\"SELECT identifier FROM testTable WHERE identifier == 2 ORDER BY rowid ASC LIMIT 1\"\n          bySelecting:^WCTValue * {\n              return [self.database getValueOnResultColumn:TestCaseObject.identifier fromTable:self.tableName where:TestCaseObject.identifier == 2];\n          }];\n}\n\n- (void)test_database_get_value_orders\n{\n    [self doTestValue:@(self.object2.identifier)\n               andSQL:@\"SELECT identifier FROM testTable ORDER BY identifier DESC LIMIT 1\"\n          bySelecting:^WCTValue * {\n              return [self.database getValueOnResultColumn:TestCaseObject.identifier fromTable:self.tableName orders:TestCaseObject.identifier.asOrder(WCTOrderedDescending)];\n          }];\n}\n\n- (void)test_database_get_value_offset\n{\n    [self doTestValue:@(self.object2.identifier)\n               andSQL:@\"SELECT identifier FROM testTable ORDER BY rowid ASC LIMIT 1 OFFSET 1\"\n          bySelecting:^WCTValue * {\n              return [self.database getValueOnResultColumn:TestCaseObject.identifier fromTable:self.tableName offset:1];\n          }];\n}\n\n- (void)test_database_get_value_where_orders\n{\n    [self doTestValue:@(self.object2.identifier)\n               andSQL:@\"SELECT identifier FROM testTable WHERE identifier > 0 ORDER BY identifier DESC LIMIT 1\"\n          bySelecting:^WCTValue * {\n              return [self.database getValueOnResultColumn:TestCaseObject.identifier fromTable:self.tableName where:TestCaseObject.identifier > 0 orders:TestCaseObject.identifier.asOrder(WCTOrderedDescending)];\n          }];\n}\n\n- (void)test_database_get_value_where_offset\n{\n    [self doTestValue:@(self.object2.identifier)\n               andSQL:@\"SELECT identifier FROM testTable WHERE identifier > 0 ORDER BY rowid ASC LIMIT 1 OFFSET 1\"\n          bySelecting:^WCTValue * {\n              return [self.database getValueOnResultColumn:TestCaseObject.identifier fromTable:self.tableName where:TestCaseObject.identifier > 0 offset:1];\n          }];\n}\n\n- (void)test_database_get_value_orders_offset\n{\n    [self doTestValue:@(self.object1.identifier)\n               andSQL:@\"SELECT identifier FROM testTable ORDER BY identifier DESC LIMIT 1 OFFSET 1\"\n          bySelecting:^WCTValue * {\n              return [self.database getValueOnResultColumn:TestCaseObject.identifier fromTable:self.tableName orders:TestCaseObject.identifier.asOrder(WCTOrderedDescending) offset:1];\n          }];\n}\n\n- (void)test_database_get_value_where_orders_offset\n{\n    [self doTestValue:@(self.object1.identifier)\n               andSQL:@\"SELECT identifier FROM testTable WHERE identifier > 0 ORDER BY identifier DESC LIMIT 1 OFFSET 1\"\n          bySelecting:^WCTValue * {\n              return [self.database getValueOnResultColumn:TestCaseObject.identifier fromTable:self.tableName where:TestCaseObject.identifier > 0 orders:TestCaseObject.identifier.asOrder(WCTOrderedDescending) offset:1];\n          }];\n}\n\n#pragma mark - Database - Get Row\n- (void)test_database_get_row\n{\n    [self doTestRow:@[ @(self.object1.identifier), self.object1.content ]\n             andSQL:@\"SELECT identifier, content FROM testTable ORDER BY rowid ASC LIMIT 1\"\n        bySelecting:^WCTOneRow * {\n            return [self.database getRowOnResultColumns:TestCaseObject.allProperties fromTable:self.tableName];\n        }];\n}\n\n- (void)test_database_get_row_where\n{\n    [self doTestRow:@[ @(self.object2.identifier), self.object2.content ]\n             andSQL:@\"SELECT identifier, content FROM testTable WHERE identifier == 2 ORDER BY rowid ASC LIMIT 1\"\n        bySelecting:^WCTOneRow * {\n            return [self.database getRowOnResultColumns:TestCaseObject.allProperties fromTable:self.tableName where:TestCaseObject.identifier == 2];\n        }];\n}\n\n- (void)test_database_get_row_orders\n{\n    [self doTestRow:@[ @(self.object2.identifier), self.object2.content ]\n             andSQL:@\"SELECT identifier, content FROM testTable ORDER BY identifier DESC LIMIT 1\"\n        bySelecting:^WCTOneRow * {\n            return [self.database getRowOnResultColumns:TestCaseObject.allProperties fromTable:self.tableName orders:TestCaseObject.identifier.asOrder(WCTOrderedDescending)];\n        }];\n}\n\n- (void)test_database_get_row_offset\n{\n    [self doTestRow:@[ @(self.object2.identifier), self.object2.content ]\n             andSQL:@\"SELECT identifier, content FROM testTable ORDER BY rowid ASC LIMIT 1 OFFSET 1\"\n        bySelecting:^WCTOneRow * {\n            return [self.database getRowOnResultColumns:TestCaseObject.allProperties fromTable:self.tableName offset:1];\n        }];\n}\n\n- (void)test_database_get_row_where_orders\n{\n    [self doTestRow:@[ @(self.object2.identifier), self.object2.content ]\n             andSQL:@\"SELECT identifier, content FROM testTable WHERE identifier > 0 ORDER BY identifier DESC LIMIT 1\"\n        bySelecting:^WCTOneRow * {\n            return [self.database getRowOnResultColumns:TestCaseObject.allProperties fromTable:self.tableName where:TestCaseObject.identifier > 0 orders:TestCaseObject.identifier.asOrder(WCTOrderedDescending)];\n        }];\n}\n\n- (void)test_database_get_row_where_offset\n{\n    [self doTestRow:@[ @(self.object2.identifier), self.object2.content ]\n             andSQL:@\"SELECT identifier, content FROM testTable WHERE identifier > 0 ORDER BY rowid ASC LIMIT 1 OFFSET 1\"\n        bySelecting:^WCTOneRow * {\n            return [self.database getRowOnResultColumns:TestCaseObject.allProperties fromTable:self.tableName where:TestCaseObject.identifier > 0 offset:1];\n        }];\n}\n\n- (void)test_database_get_row_orders_offset\n{\n    [self doTestRow:@[ @(self.object1.identifier), self.object1.content ]\n             andSQL:@\"SELECT identifier, content FROM testTable ORDER BY identifier DESC LIMIT 1 OFFSET 1\"\n        bySelecting:^WCTOneRow * {\n            return [self.database getRowOnResultColumns:TestCaseObject.allProperties fromTable:self.tableName orders:TestCaseObject.identifier.asOrder(WCTOrderedDescending) offset:1];\n        }];\n}\n\n- (void)test_database_get_row_where_orders_offset\n{\n    [self doTestRow:@[ @(self.object1.identifier), self.object1.content ]\n             andSQL:@\"SELECT identifier, content FROM testTable WHERE identifier > 0 ORDER BY identifier DESC LIMIT 1 OFFSET 1\"\n        bySelecting:^WCTOneRow * {\n            return [self.database getRowOnResultColumns:TestCaseObject.allProperties fromTable:self.tableName where:TestCaseObject.identifier > 0 orders:TestCaseObject.identifier.asOrder(WCTOrderedDescending) offset:1];\n        }];\n}\n\n#pragma mark - Database - Get Column\n- (void)test_database_get_column\n{\n    [self doTestColumn:@[ @(self.object1.identifier), @(self.object2.identifier) ]\n                andSQL:@\"SELECT identifier FROM testTable ORDER BY rowid ASC\"\n           bySelecting:^WCTOneColumn * {\n               return [self.database getColumnOnResultColumn:TestCaseObject.identifier fromTable:self.tableName];\n           }];\n}\n\n- (void)test_database_get_column_where\n{\n    [self doTestColumn:@[ @(self.object1.identifier) ]\n                andSQL:@\"SELECT identifier FROM testTable WHERE identifier == 1 ORDER BY rowid ASC\"\n           bySelecting:^WCTOneColumn * {\n               return [self.database getColumnOnResultColumn:TestCaseObject.identifier fromTable:self.tableName where:TestCaseObject.identifier == 1];\n           }];\n}\n\n- (void)test_database_get_column_orders\n{\n    [self doTestColumn:@[ @(self.object2.identifier), @(self.object1.identifier) ]\n                andSQL:@\"SELECT identifier FROM testTable ORDER BY identifier DESC\"\n           bySelecting:^WCTOneColumn * {\n               return [self.database getColumnOnResultColumn:TestCaseObject.identifier fromTable:self.tableName orders:TestCaseObject.identifier.asOrder(WCTOrderedDescending)];\n           }];\n}\n\n- (void)test_database_get_column_limit\n{\n    [self doTestColumn:@[ @(self.object1.identifier) ]\n                andSQL:@\"SELECT identifier FROM testTable ORDER BY rowid ASC LIMIT 1\"\n           bySelecting:^WCTOneColumn * {\n               return [self.database getColumnOnResultColumn:TestCaseObject.identifier fromTable:self.tableName limit:1];\n           }];\n}\n\n- (void)test_database_get_column_where_orders\n{\n    [self doTestColumn:@[ @(self.object2.identifier), @(self.object1.identifier) ]\n                andSQL:@\"SELECT identifier FROM testTable WHERE identifier > 0 ORDER BY identifier DESC\"\n           bySelecting:^WCTOneColumn * {\n               return [self.database getColumnOnResultColumn:TestCaseObject.identifier fromTable:self.tableName where:TestCaseObject.identifier > 0 orders:TestCaseObject.identifier.asOrder(WCTOrderedDescending)];\n           }];\n}\n\n- (void)test_database_get_column_where_limit\n{\n    [self doTestColumn:@[ @(self.object2.identifier) ]\n                andSQL:@\"SELECT identifier FROM testTable WHERE identifier > 1 ORDER BY rowid ASC LIMIT 1\"\n           bySelecting:^WCTOneColumn * {\n               return [self.database getColumnOnResultColumn:TestCaseObject.identifier fromTable:self.tableName where:TestCaseObject.identifier > 1 limit:1];\n           }];\n}\n\n- (void)test_database_get_column_orders_limit\n{\n    [self doTestColumn:@[ @(self.object2.identifier) ]\n                andSQL:@\"SELECT identifier FROM testTable ORDER BY identifier DESC LIMIT 1\"\n           bySelecting:^WCTOneColumn * {\n               return [self.database getColumnOnResultColumn:TestCaseObject.identifier fromTable:self.tableName orders:TestCaseObject.identifier.asOrder(WCTOrderedDescending) limit:1];\n           }];\n}\n\n- (void)test_database_get_column_limit_offset\n{\n    [self doTestColumn:@[ @(self.object2.identifier) ]\n                andSQL:@\"SELECT identifier FROM testTable ORDER BY rowid ASC LIMIT 1 OFFSET 1\"\n           bySelecting:^WCTOneColumn * {\n               return [self.database getColumnOnResultColumn:TestCaseObject.identifier fromTable:self.tableName limit:1 offset:1];\n           }];\n}\n\n- (void)test_database_get_column_where_orders_limit\n{\n    [self doTestColumn:@[ @(self.object2.identifier) ]\n                andSQL:@\"SELECT identifier FROM testTable WHERE identifier > 0 ORDER BY identifier DESC LIMIT 1\"\n           bySelecting:^WCTOneColumn * {\n               return [self.database getColumnOnResultColumn:TestCaseObject.identifier fromTable:self.tableName where:TestCaseObject.identifier > 0 orders:TestCaseObject.identifier.asOrder(WCTOrderedDescending) limit:1];\n           }];\n}\n\n- (void)test_database_get_column_where_limit_offset\n{\n    [self doTestColumn:@[ @(self.object2.identifier) ]\n                andSQL:@\"SELECT identifier FROM testTable WHERE identifier > 0 ORDER BY rowid ASC LIMIT 1 OFFSET 1\"\n           bySelecting:^WCTOneColumn * {\n               return [self.database getColumnOnResultColumn:TestCaseObject.identifier fromTable:self.tableName where:TestCaseObject.identifier > 0 limit:1 offset:1];\n           }];\n}\n\n- (void)test_database_get_column_orders_limit_offset\n{\n    [self doTestColumn:@[ @(self.object1.identifier) ]\n                andSQL:@\"SELECT identifier FROM testTable ORDER BY identifier DESC LIMIT 1 OFFSET 1\"\n           bySelecting:^WCTOneColumn * {\n               return [self.database getColumnOnResultColumn:TestCaseObject.identifier fromTable:self.tableName orders:TestCaseObject.identifier.asOrder(WCTOrderedDescending) limit:1 offset:1];\n           }];\n}\n\n- (void)test_database_get_column_where_orders_limit_offset\n{\n    [self doTestColumn:@[ @(self.object1.identifier) ]\n                andSQL:@\"SELECT identifier FROM testTable WHERE identifier > 0 ORDER BY identifier DESC LIMIT 1 OFFSET 1\"\n           bySelecting:^WCTOneColumn * {\n               return [self.database getColumnOnResultColumn:TestCaseObject.identifier fromTable:self.tableName where:TestCaseObject.identifier > 0 orders:TestCaseObject.identifier.asOrder(WCTOrderedDescending) limit:1 offset:1];\n           }];\n}\n\n#pragma mark - Database - Get Rows\n- (void)test_database_get_rows\n{\n    [self doTestRows:@[ @[ @(self.object1.identifier), self.object1.content ],\n                        @[ @(self.object2.identifier), self.object2.content ] ]\n              andSQL:@\"SELECT identifier, content FROM testTable ORDER BY rowid ASC\"\n         bySelecting:^WCTColumnsXRows * {\n             return [self.database getRowsOnResultColumns:TestCaseObject.allProperties fromTable:self.tableName];\n         }];\n}\n\n- (void)test_database_get_rows_where\n{\n    [self doTestRows:@[ @[ @(self.object1.identifier), self.object1.content ] ]\n              andSQL:@\"SELECT identifier, content FROM testTable WHERE identifier == 1 ORDER BY rowid ASC\"\n         bySelecting:^WCTColumnsXRows * {\n             return [self.database getRowsOnResultColumns:TestCaseObject.allProperties fromTable:self.tableName where:TestCaseObject.identifier == 1];\n         }];\n}\n\n- (void)test_database_get_rows_orders\n{\n    [self doTestRows:@[ @[ @(self.object2.identifier), self.object2.content ],\n                        @[ @(self.object1.identifier), self.object1.content ] ]\n              andSQL:@\"SELECT identifier, content FROM testTable ORDER BY identifier DESC\"\n         bySelecting:^WCTColumnsXRows * {\n             return [self.database getRowsOnResultColumns:TestCaseObject.allProperties fromTable:self.tableName orders:TestCaseObject.identifier.asOrder(WCTOrderedDescending)];\n         }];\n}\n\n- (void)test_database_get_rows_limit\n{\n    [self doTestRows:@[ @[ @(self.object1.identifier), self.object1.content ] ]\n              andSQL:@\"SELECT identifier, content FROM testTable ORDER BY rowid ASC LIMIT 1\"\n         bySelecting:^WCTColumnsXRows * {\n             return [self.database getRowsOnResultColumns:TestCaseObject.allProperties fromTable:self.tableName limit:1];\n         }];\n}\n\n- (void)test_database_get_rows_where_orders\n{\n    [self doTestRows:@[ @[ @(self.object2.identifier), self.object2.content ],\n                        @[ @(self.object1.identifier), self.object1.content ] ]\n              andSQL:@\"SELECT identifier, content FROM testTable WHERE identifier > 0 ORDER BY identifier DESC\"\n         bySelecting:^WCTColumnsXRows * {\n             return [self.database getRowsOnResultColumns:TestCaseObject.allProperties fromTable:self.tableName where:TestCaseObject.identifier > 0 orders:TestCaseObject.identifier.asOrder(WCTOrderedDescending)];\n         }];\n}\n\n- (void)test_database_get_rows_where_limit\n{\n    [self doTestRows:@[ @[ @(self.object2.identifier), self.object2.content ] ]\n              andSQL:@\"SELECT identifier, content FROM testTable WHERE identifier > 1 ORDER BY rowid ASC LIMIT 1\"\n         bySelecting:^WCTColumnsXRows * {\n             return [self.database getRowsOnResultColumns:TestCaseObject.allProperties fromTable:self.tableName where:TestCaseObject.identifier > 1 limit:1];\n         }];\n}\n\n- (void)test_database_get_rows_orders_limit\n{\n    [self doTestRows:@[ @[ @(self.object2.identifier), self.object2.content ] ]\n              andSQL:@\"SELECT identifier, content FROM testTable ORDER BY identifier DESC LIMIT 1\"\n         bySelecting:^WCTColumnsXRows * {\n             return [self.database getRowsOnResultColumns:TestCaseObject.allProperties fromTable:self.tableName orders:TestCaseObject.identifier.asOrder(WCTOrderedDescending) limit:1];\n         }];\n}\n\n- (void)test_database_get_rows_limit_offset\n{\n    [self doTestRows:@[ @[ @(self.object2.identifier), self.object2.content ] ]\n              andSQL:@\"SELECT identifier, content FROM testTable ORDER BY rowid ASC LIMIT 1 OFFSET 1\"\n         bySelecting:^WCTColumnsXRows * {\n             return [self.database getRowsOnResultColumns:TestCaseObject.allProperties fromTable:self.tableName limit:1 offset:1];\n         }];\n}\n\n- (void)test_database_get_rows_where_orders_limit\n{\n    [self doTestRows:@[ @[ @(self.object2.identifier), self.object2.content ] ]\n              andSQL:@\"SELECT identifier, content FROM testTable WHERE identifier > 0 ORDER BY identifier DESC LIMIT 1\"\n         bySelecting:^WCTColumnsXRows * {\n             return [self.database getRowsOnResultColumns:TestCaseObject.allProperties fromTable:self.tableName where:TestCaseObject.identifier > 0 orders:TestCaseObject.identifier.asOrder(WCTOrderedDescending) limit:1];\n         }];\n}\n\n- (void)test_database_get_rows_where_limit_offset\n{\n    [self doTestRows:@[ @[ @(self.object2.identifier), self.object2.content ] ]\n              andSQL:@\"SELECT identifier, content FROM testTable WHERE identifier > 0 ORDER BY rowid ASC LIMIT 1 OFFSET 1\"\n         bySelecting:^WCTColumnsXRows * {\n             return [self.database getRowsOnResultColumns:TestCaseObject.allProperties fromTable:self.tableName where:TestCaseObject.identifier > 0 limit:1 offset:1];\n         }];\n}\n\n- (void)test_database_get_rows_orders_limit_offset\n{\n    [self doTestRows:@[ @[ @(self.object1.identifier), self.object1.content ] ]\n              andSQL:@\"SELECT identifier, content FROM testTable ORDER BY identifier DESC LIMIT 1 OFFSET 1\"\n         bySelecting:^WCTColumnsXRows * {\n             return [self.database getRowsOnResultColumns:TestCaseObject.allProperties fromTable:self.tableName orders:TestCaseObject.identifier.asOrder(WCTOrderedDescending) limit:1 offset:1];\n         }];\n}\n\n- (void)test_database_get_rows_where_orders_limit_offset\n{\n    [self doTestRows:@[ @[ @(self.object1.identifier), self.object1.content ] ]\n              andSQL:@\"SELECT identifier, content FROM testTable WHERE identifier > 0 ORDER BY identifier DESC LIMIT 1 OFFSET 1\"\n         bySelecting:^WCTColumnsXRows * {\n             return [self.database getRowsOnResultColumns:TestCaseObject.allProperties fromTable:self.tableName where:TestCaseObject.identifier > 0 orders:TestCaseObject.identifier.asOrder(WCTOrderedDescending) limit:1 offset:1];\n         }];\n}\n\n#pragma mark - Database - Get From Statement\n- (void)test_database_get_row_from_statement\n{\n    [self doTestRow:self.partialRow1\n             andSQL:@\"SELECT identifier FROM testTable ORDER BY rowid ASC LIMIT 1\"\n        bySelecting:^WCTOneRow * {\n            return [self.database getRowFromStatement:WCDB::StatementSelect().select(TestCaseObject.identifier).from(self.tableName).order(WCDB::OrderingTerm::ascendingRowid()).limit(1)];\n        }];\n}\n\n- (void)test_database_get_column_from_statement\n{\n    [self doTestColumn:self.column\n                andSQL:@\"SELECT identifier FROM testTable ORDER BY rowid ASC\"\n           bySelecting:^WCTOneColumn * {\n               return [self.database getColumnFromStatement:WCDB::StatementSelect().select(TestCaseObject.identifier).from(self.tableName).order(WCDB::OrderingTerm::ascendingRowid())];\n           }];\n}\n\n- (void)test_database_get_value_from_statement\n{\n    [self doTestValue:self.value1\n               andSQL:@\"SELECT identifier FROM testTable ORDER BY rowid ASC LIMIT 1\"\n          bySelecting:^WCTValue * {\n              return [self.database getValueFromStatement:WCDB::StatementSelect().select(TestCaseObject.identifier).from(self.tableName).order(WCDB::OrderingTerm::ascendingRowid()).limit(1)];\n          }];\n}\n\n- (void)test_database_get_rows_from_statement\n{\n    [self doTestRows:self.partialRows\n              andSQL:@\"SELECT identifier FROM testTable ORDER BY rowid ASC\"\n         bySelecting:^WCTColumnsXRows * {\n             return [self.database getRowsFromStatement:WCDB::StatementSelect().select(TestCaseObject.identifier).from(self.tableName).order(WCDB::OrderingTerm::ascendingRowid())];\n         }];\n}\n\n#pragma mark - Table - Get Object\n- (void)test_table_get_object\n{\n    [self doTestObject:self.object1\n                andSQL:@\"SELECT identifier, content FROM testTable ORDER BY rowid ASC LIMIT 1\"\n           bySelecting:^NSArray<TestCaseObject *> * {\n               return @[ [self.table getObject] ];\n           }];\n}\n\n- (void)test_table_get_object_where\n{\n    [self doTestObject:self.object2\n                andSQL:@\"SELECT identifier, content FROM testTable WHERE identifier == 2 ORDER BY rowid ASC LIMIT 1\"\n           bySelecting:^NSArray<TestCaseObject *> * {\n               return @[ [self.table getObjectWhere:TestCaseObject.identifier == 2] ];\n           }];\n}\n\n- (void)test_table_get_object_orders\n{\n    [self doTestObject:self.object2\n                andSQL:@\"SELECT identifier, content FROM testTable ORDER BY identifier DESC LIMIT 1\"\n           bySelecting:^NSArray<TestCaseObject *> * {\n               return @[ [self.table getObjectOrders:TestCaseObject.identifier.asOrder(WCTOrderedDescending)] ];\n           }];\n}\n\n- (void)test_table_get_object_offset\n{\n    [self doTestObject:self.object2\n                andSQL:@\"SELECT identifier, content FROM testTable ORDER BY rowid ASC LIMIT 1 OFFSET 1\"\n           bySelecting:^NSArray<TestCaseObject *> * {\n               return @[ [self.table getObjectOffset:1] ];\n           }];\n}\n\n- (void)test_table_get_object_where_orders\n{\n    [self doTestObject:self.object2\n                andSQL:@\"SELECT identifier, content FROM testTable WHERE identifier > 0 ORDER BY identifier DESC LIMIT 1\"\n           bySelecting:^NSArray<TestCaseObject *> * {\n               return @[ [self.table getObjectWhere:TestCaseObject.identifier > 0 orders:TestCaseObject.identifier.asOrder(WCTOrderedDescending)] ];\n           }];\n}\n\n- (void)test_table_get_object_where_offset\n{\n    [self doTestObject:self.object2\n                andSQL:@\"SELECT identifier, content FROM testTable WHERE identifier > 0 ORDER BY rowid ASC LIMIT 1 OFFSET 1\"\n           bySelecting:^NSArray<TestCaseObject *> * {\n               return @[ [self.table getObjectWhere:TestCaseObject.identifier > 0 offset:1] ];\n           }];\n}\n\n- (void)test_table_get_object_orders_offset\n{\n    [self doTestObject:self.object1\n                andSQL:@\"SELECT identifier, content FROM testTable ORDER BY identifier DESC LIMIT 1 OFFSET 1\"\n           bySelecting:^NSArray<TestCaseObject *> * {\n               return @[ [self.table getObjectOrders:TestCaseObject.identifier.asOrder(WCTOrderedDescending) offset:1] ];\n           }];\n}\n\n- (void)test_table_get_object_where_orders_offset\n{\n    [self doTestObject:self.object1\n                andSQL:@\"SELECT identifier, content FROM testTable WHERE identifier > 0 ORDER BY identifier DESC LIMIT 1 OFFSET 1\"\n           bySelecting:^NSArray<TestCaseObject *> * {\n               return @[ [self.table getObjectWhere:TestCaseObject.identifier > 0 orders:TestCaseObject.identifier.asOrder(WCTOrderedDescending) offset:1] ];\n           }];\n}\n\n#pragma mark - Table - Get Objects\n- (void)test_table_get_objects\n{\n    [self doTestObjects:self.objects\n                 andSQL:@\"SELECT identifier, content FROM testTable ORDER BY rowid ASC\"\n            bySelecting:^NSArray<TestCaseObject *> * {\n                return [self.table getObjects];\n            }];\n}\n\n- (void)test_table_get_objects_where\n{\n    [self doTestObject:self.object1\n                andSQL:@\"SELECT identifier, content FROM testTable WHERE identifier == 1 ORDER BY rowid ASC\"\n           bySelecting:^NSArray<TestCaseObject *> * {\n               return [self.table getObjectsWhere:TestCaseObject.identifier == 1];\n           }];\n}\n\n- (void)test_table_get_objects_orders\n{\n    [self doTestObjects:self.objects.reversedArray\n                 andSQL:@\"SELECT identifier, content FROM testTable ORDER BY identifier DESC\"\n            bySelecting:^NSArray<TestCaseObject *> * {\n                return [self.table getObjectsOrders:TestCaseObject.identifier.asOrder(WCTOrderedDescending)];\n            }];\n}\n\n- (void)test_table_get_objects_limit\n{\n    [self doTestObject:self.object1\n                andSQL:@\"SELECT identifier, content FROM testTable ORDER BY rowid ASC LIMIT 1\"\n           bySelecting:^NSArray<TestCaseObject *> * {\n               return [self.table getObjectsLimit:1];\n           }];\n}\n\n- (void)test_table_get_objects_where_orders\n{\n    [self doTestObjects:self.objects.reversedArray\n                 andSQL:@\"SELECT identifier, content FROM testTable WHERE identifier > 0 ORDER BY identifier DESC\"\n            bySelecting:^NSArray<TestCaseObject *> * {\n                return [self.table getObjectsWhere:TestCaseObject.identifier > 0 orders:TestCaseObject.identifier.asOrder(WCTOrderedDescending)];\n            }];\n}\n\n- (void)test_table_get_objects_where_limit\n{\n    [self doTestObject:self.object2\n                andSQL:@\"SELECT identifier, content FROM testTable WHERE identifier > 1 ORDER BY rowid ASC LIMIT 1\"\n           bySelecting:^NSArray<TestCaseObject *> * {\n               return [self.table getObjectsWhere:TestCaseObject.identifier > 1 limit:1];\n           }];\n}\n\n- (void)test_table_get_objects_orders_limit\n{\n    [self doTestObject:self.object2\n                andSQL:@\"SELECT identifier, content FROM testTable ORDER BY identifier DESC LIMIT 1\"\n           bySelecting:^NSArray<TestCaseObject *> * {\n               return [self.table getObjectsOrders:TestCaseObject.identifier.asOrder(WCTOrderedDescending) limit:1];\n           }];\n}\n\n- (void)test_table_get_objects_limit_offset\n{\n    [self doTestObject:self.object2\n                andSQL:@\"SELECT identifier, content FROM testTable ORDER BY rowid ASC LIMIT 2 OFFSET 1\"\n           bySelecting:^NSArray<TestCaseObject *> * {\n               return [self.table getObjectsOffset:1 limit:2];\n           }];\n}\n\n- (void)test_table_get_objects_where_orders_limit\n{\n    [self doTestObject:self.object2\n                andSQL:@\"SELECT identifier, content FROM testTable WHERE identifier > 0 ORDER BY identifier DESC LIMIT 1\"\n           bySelecting:^NSArray<TestCaseObject *> * {\n               return [self.table getObjectsWhere:TestCaseObject.identifier > 0 orders:TestCaseObject.identifier.asOrder(WCTOrderedDescending) limit:1];\n           }];\n}\n\n- (void)test_table_get_objects_where_limit_offset\n{\n    [self doTestObject:self.object2\n                andSQL:@\"SELECT identifier, content FROM testTable WHERE identifier > 0 ORDER BY rowid ASC LIMIT 1 OFFSET 1\"\n           bySelecting:^NSArray<TestCaseObject *> * {\n               return [self.table getObjectsWhere:TestCaseObject.identifier > 0 limit:1 offset:1];\n           }];\n}\n\n- (void)test_table_get_objects_orders_limit_offset\n{\n    [self doTestObject:self.object1\n                andSQL:@\"SELECT identifier, content FROM testTable ORDER BY identifier DESC LIMIT 1 OFFSET 1\"\n           bySelecting:^NSArray<TestCaseObject *> * {\n               return [self.table getObjectsOrders:TestCaseObject.identifier.asOrder(WCTOrderedDescending) limit:1 offset:1];\n           }];\n}\n\n- (void)test_table_get_objects_where_orders_limit_offset\n{\n    [self doTestObject:self.object1\n                andSQL:@\"SELECT identifier, content FROM testTable WHERE identifier > 0 ORDER BY identifier DESC LIMIT 1 OFFSET 1\"\n           bySelecting:^NSArray<TestCaseObject *> * {\n               return [self.table getObjectsWhere:TestCaseObject.identifier > 0 orders:TestCaseObject.identifier.asOrder(WCTOrderedDescending) limit:1 offset:1];\n           }];\n}\n\n#pragma mark - Table - Get Part Of Object\n- (void)test_table_get_object_on_result_columns\n{\n    [self doTestObject:self.partialObject1\n                andSQL:@\"SELECT identifier FROM testTable ORDER BY rowid ASC LIMIT 1\"\n           bySelecting:^NSArray<TestCaseObject *> * {\n               return @[ [self.table getObjectOnResultColumns:TestCaseObject.identifier] ];\n           }];\n}\n\n- (void)test_table_get_object_on_result_columns_where\n{\n    [self doTestObject:self.partialObject1\n                andSQL:@\"SELECT identifier FROM testTable WHERE identifier == 1 ORDER BY rowid ASC LIMIT 1\"\n           bySelecting:^NSArray<TestCaseObject *> * {\n               return @[ [self.table getObjectOnResultColumns:TestCaseObject.identifier where:TestCaseObject.identifier == 1] ];\n           }];\n}\n\n- (void)test_table_get_object_on_result_columns_orders\n{\n    [self doTestObject:self.partialObject2\n                andSQL:@\"SELECT identifier FROM testTable ORDER BY identifier DESC LIMIT 1\"\n           bySelecting:^NSArray<TestCaseObject *> * {\n               return @[ [self.table getObjectOnResultColumns:TestCaseObject.identifier orders:TestCaseObject.identifier.asOrder(WCTOrderedDescending)] ];\n           }];\n}\n\n- (void)test_table_get_object_on_result_columns_offset\n{\n    [self doTestObject:self.partialObject2\n                andSQL:@\"SELECT identifier FROM testTable ORDER BY rowid ASC LIMIT 1 OFFSET 1\"\n           bySelecting:^NSArray<TestCaseObject *> * {\n               return @[ [self.table getObjectOnResultColumns:TestCaseObject.identifier offset:1] ];\n           }];\n}\n\n- (void)test_table_get_object_on_result_columns_where_orders\n{\n    [self doTestObject:self.partialObject2\n                andSQL:@\"SELECT identifier FROM testTable WHERE identifier > 0 ORDER BY identifier DESC LIMIT 1\"\n           bySelecting:^NSArray<TestCaseObject *> * {\n               return @[ [self.table getObjectOnResultColumns:TestCaseObject.identifier where:TestCaseObject.identifier > 0 orders:TestCaseObject.identifier.asOrder(WCTOrderedDescending)] ];\n           }];\n}\n\n- (void)test_table_get_object_on_result_columns_where_offset\n{\n    [self doTestObject:self.partialObject2\n                andSQL:@\"SELECT identifier FROM testTable WHERE identifier > 0 ORDER BY rowid ASC LIMIT 1 OFFSET 1\"\n           bySelecting:^NSArray<TestCaseObject *> * {\n               return @[ [self.table getObjectOnResultColumns:TestCaseObject.identifier where:TestCaseObject.identifier > 0 offset:1] ];\n           }];\n}\n\n- (void)test_table_get_object_on_result_columns_orders_offset\n{\n    [self doTestObject:self.partialObject1\n                andSQL:@\"SELECT identifier FROM testTable ORDER BY identifier DESC LIMIT 1 OFFSET 1\"\n           bySelecting:^NSArray<TestCaseObject *> * {\n               return @[ [self.table getObjectOnResultColumns:TestCaseObject.identifier orders:TestCaseObject.identifier.asOrder(WCTOrderedDescending) offset:1] ];\n           }];\n}\n\n- (void)test_table_get_object_on_result_columns_where_orders_offset\n{\n    [self doTestObject:self.partialObject1\n                andSQL:@\"SELECT identifier FROM testTable WHERE identifier > 0 ORDER BY identifier DESC LIMIT 1 OFFSET 1\"\n           bySelecting:^NSArray<TestCaseObject *> * {\n               return @[ [self.table getObjectOnResultColumns:TestCaseObject.identifier where:TestCaseObject.identifier > 0 orders:TestCaseObject.identifier.asOrder(WCTOrderedDescending) offset:1] ];\n           }];\n}\n\n#pragma mark - Table - Get Part Of Objects\n- (void)test_table_get_objects_on_result_columns\n{\n    [self doTestObjects:self.partialObjects\n                 andSQL:@\"SELECT identifier FROM testTable ORDER BY rowid ASC\"\n            bySelecting:^NSArray<TestCaseObject *> * {\n                return [self.table getObjectsOnResultColumns:TestCaseObject.identifier];\n            }];\n}\n\n- (void)test_table_get_objects_on_result_columns_where\n{\n    [self doTestObject:self.partialObject1\n                andSQL:@\"SELECT identifier FROM testTable WHERE identifier == 1 ORDER BY rowid ASC\"\n           bySelecting:^NSArray<TestCaseObject *> * {\n               return [self.table getObjectsOnResultColumns:TestCaseObject.identifier where:TestCaseObject.identifier == 1];\n           }];\n}\n\n- (void)test_table_get_objects_on_result_columns_orders\n{\n    [self doTestObjects:self.partialObjects.reversedArray\n                 andSQL:@\"SELECT identifier FROM testTable ORDER BY identifier DESC\"\n            bySelecting:^NSArray<TestCaseObject *> * {\n                return [self.table getObjectsOnResultColumns:TestCaseObject.identifier orders:TestCaseObject.identifier.asOrder(WCTOrderedDescending)];\n            }];\n}\n\n- (void)test_table_get_objects_on_result_columns_limit\n{\n    [self doTestObject:self.partialObject1\n                andSQL:@\"SELECT identifier FROM testTable ORDER BY rowid ASC LIMIT 1\"\n           bySelecting:^NSArray<TestCaseObject *> * {\n               return [self.table getObjectsOnResultColumns:TestCaseObject.identifier limit:1];\n           }];\n}\n\n- (void)test_table_get_objects_on_result_columns_where_orders\n{\n    [self doTestObjects:self.partialObjects.reversedArray\n                 andSQL:@\"SELECT identifier FROM testTable WHERE identifier > 0 ORDER BY identifier DESC\"\n            bySelecting:^NSArray<TestCaseObject *> * {\n                return [self.table getObjectsOnResultColumns:TestCaseObject.identifier where:TestCaseObject.identifier > 0 orders:TestCaseObject.identifier.asOrder(WCTOrderedDescending)];\n            }];\n}\n\n- (void)test_table_get_objects_on_result_columns_where_limit\n{\n    [self doTestObject:self.partialObject2\n                andSQL:@\"SELECT identifier FROM testTable WHERE identifier > 1 ORDER BY rowid ASC LIMIT 1\"\n           bySelecting:^NSArray<TestCaseObject *> * {\n               return [self.table getObjectsOnResultColumns:TestCaseObject.identifier where:TestCaseObject.identifier > 1 limit:1];\n           }];\n}\n\n- (void)test_table_get_objects_on_result_columns_orders_limit\n{\n    [self doTestObject:self.partialObject2\n                andSQL:@\"SELECT identifier FROM testTable ORDER BY identifier DESC LIMIT 1\"\n           bySelecting:^NSArray<TestCaseObject *> * {\n               return [self.table getObjectsOnResultColumns:TestCaseObject.identifier orders:TestCaseObject.identifier.asOrder(WCTOrderedDescending) limit:1];\n           }];\n}\n\n- (void)test_table_get_objects_on_result_columns_limit_offset\n{\n    [self doTestObject:self.partialObject2\n                andSQL:@\"SELECT identifier FROM testTable ORDER BY rowid ASC LIMIT 1 OFFSET 1\"\n           bySelecting:^NSArray<TestCaseObject *> * {\n               return [self.table getObjectsOnResultColumns:TestCaseObject.identifier limit:1 offset:1];\n           }];\n}\n\n- (void)test_table_get_objects_on_result_columns_where_orders_limit\n{\n    [self doTestObject:self.partialObject2\n                andSQL:@\"SELECT identifier FROM testTable WHERE identifier > 0 ORDER BY identifier DESC LIMIT 1\"\n           bySelecting:^NSArray<TestCaseObject *> * {\n               return [self.table getObjectsOnResultColumns:TestCaseObject.identifier where:TestCaseObject.identifier > 0 orders:TestCaseObject.identifier.asOrder(WCTOrderedDescending) limit:1];\n           }];\n}\n\n- (void)test_table_get_objects_on_result_columns_where_limit_offset\n{\n    [self doTestObject:self.partialObject2\n                andSQL:@\"SELECT identifier FROM testTable WHERE identifier > 0 ORDER BY rowid ASC LIMIT 1 OFFSET 1\"\n           bySelecting:^NSArray<TestCaseObject *> * {\n               return [self.table getObjectsOnResultColumns:TestCaseObject.identifier where:TestCaseObject.identifier > 0 limit:1 offset:1];\n           }];\n}\n\n- (void)test_table_get_objects_on_result_columns_orders_limit_offset\n{\n    [self doTestObject:self.partialObject1\n                andSQL:@\"SELECT identifier FROM testTable ORDER BY identifier DESC LIMIT 1 OFFSET 1\"\n           bySelecting:^NSArray<TestCaseObject *> * {\n               return [self.table getObjectsOnResultColumns:TestCaseObject.identifier orders:TestCaseObject.identifier.asOrder(WCTOrderedDescending) limit:1 offset:1];\n           }];\n}\n\n- (void)test_table_get_objects_on_result_columns_where_orders_limit_offset\n{\n    [self doTestObject:self.partialObject1\n                andSQL:@\"SELECT identifier FROM testTable WHERE identifier > 0 ORDER BY identifier DESC LIMIT 1 OFFSET 1\"\n           bySelecting:^NSArray<TestCaseObject *> * {\n               return [self.table getObjectsOnResultColumns:TestCaseObject.identifier where:TestCaseObject.identifier > 0 orders:TestCaseObject.identifier.asOrder(WCTOrderedDescending) limit:1 offset:1];\n           }];\n}\n\n#pragma mark - Table - Get Value\n- (void)test_table_get_value\n{\n    [self doTestValue:@(self.object1.identifier)\n               andSQL:@\"SELECT identifier FROM testTable ORDER BY rowid ASC LIMIT 1\"\n          bySelecting:^WCTValue * {\n              return [self.table getValueOnResultColumn:TestCaseObject.identifier];\n          }];\n}\n\n- (void)test_table_get_value_where\n{\n    [self doTestValue:@(self.object2.identifier)\n               andSQL:@\"SELECT identifier FROM testTable WHERE identifier == 2 ORDER BY rowid ASC LIMIT 1\"\n          bySelecting:^WCTValue * {\n              return [self.table getValueOnResultColumn:TestCaseObject.identifier where:TestCaseObject.identifier == 2];\n          }];\n}\n\n- (void)test_table_get_value_orders\n{\n    [self doTestValue:@(self.object2.identifier)\n               andSQL:@\"SELECT identifier FROM testTable ORDER BY identifier DESC LIMIT 1\"\n          bySelecting:^WCTValue * {\n              return [self.table getValueOnResultColumn:TestCaseObject.identifier orders:TestCaseObject.identifier.asOrder(WCTOrderedDescending)];\n          }];\n}\n\n- (void)test_table_get_value_offset\n{\n    [self doTestValue:@(self.object2.identifier)\n               andSQL:@\"SELECT identifier FROM testTable ORDER BY rowid ASC LIMIT 1 OFFSET 1\"\n          bySelecting:^WCTValue * {\n              return [self.table getValueOnResultColumn:TestCaseObject.identifier offset:1];\n          }];\n}\n\n- (void)test_table_get_value_where_orders\n{\n    [self doTestValue:@(self.object2.identifier)\n               andSQL:@\"SELECT identifier FROM testTable WHERE identifier > 0 ORDER BY identifier DESC LIMIT 1\"\n          bySelecting:^WCTValue * {\n              return [self.table getValueOnResultColumn:TestCaseObject.identifier where:TestCaseObject.identifier > 0 orders:TestCaseObject.identifier.asOrder(WCTOrderedDescending)];\n          }];\n}\n\n- (void)test_table_get_value_where_offset\n{\n    [self doTestValue:@(self.object2.identifier)\n               andSQL:@\"SELECT identifier FROM testTable WHERE identifier > 0 ORDER BY rowid ASC LIMIT 1 OFFSET 1\"\n          bySelecting:^WCTValue * {\n              return [self.table getValueOnResultColumn:TestCaseObject.identifier where:TestCaseObject.identifier > 0 offset:1];\n          }];\n}\n\n- (void)test_table_get_value_orders_offset\n{\n    [self doTestValue:@(self.object1.identifier)\n               andSQL:@\"SELECT identifier FROM testTable ORDER BY identifier DESC LIMIT 1 OFFSET 1\"\n          bySelecting:^WCTValue * {\n              return [self.table getValueOnResultColumn:TestCaseObject.identifier orders:TestCaseObject.identifier.asOrder(WCTOrderedDescending) offset:1];\n          }];\n}\n\n- (void)test_table_get_value_where_orders_offset\n{\n    [self doTestValue:@(self.object1.identifier)\n               andSQL:@\"SELECT identifier FROM testTable WHERE identifier > 0 ORDER BY identifier DESC LIMIT 1 OFFSET 1\"\n          bySelecting:^WCTValue * {\n              return [self.table getValueOnResultColumn:TestCaseObject.identifier where:TestCaseObject.identifier > 0 orders:TestCaseObject.identifier.asOrder(WCTOrderedDescending) offset:1];\n          }];\n}\n\n#pragma mark - Table - Get Row\n- (void)test_table_get_row\n{\n    [self doTestRow:@[ @(self.object1.identifier), self.object1.content ]\n             andSQL:@\"SELECT identifier, content FROM testTable ORDER BY rowid ASC LIMIT 1\"\n        bySelecting:^WCTOneRow * {\n            return [self.table getRowOnResultColumns:TestCaseObject.allProperties];\n        }];\n}\n\n- (void)test_table_get_row_where\n{\n    [self doTestRow:@[ @(self.object2.identifier), self.object2.content ]\n             andSQL:@\"SELECT identifier, content FROM testTable WHERE identifier == 2 ORDER BY rowid ASC LIMIT 1\"\n        bySelecting:^WCTOneRow * {\n            return [self.table getRowOnResultColumns:TestCaseObject.allProperties where:TestCaseObject.identifier == 2];\n        }];\n}\n\n- (void)test_table_get_row_orders\n{\n    [self doTestRow:@[ @(self.object2.identifier), self.object2.content ]\n             andSQL:@\"SELECT identifier, content FROM testTable ORDER BY identifier DESC LIMIT 1\"\n        bySelecting:^WCTOneRow * {\n            return [self.table getRowOnResultColumns:TestCaseObject.allProperties orders:TestCaseObject.identifier.asOrder(WCTOrderedDescending)];\n        }];\n}\n\n- (void)test_table_get_row_offset\n{\n    [self doTestRow:@[ @(self.object2.identifier), self.object2.content ]\n             andSQL:@\"SELECT identifier, content FROM testTable ORDER BY rowid ASC LIMIT 1 OFFSET 1\"\n        bySelecting:^WCTOneRow * {\n            return [self.table getRowOnResultColumns:TestCaseObject.allProperties offset:1];\n        }];\n}\n\n- (void)test_table_get_row_where_orders\n{\n    [self doTestRow:@[ @(self.object2.identifier), self.object2.content ]\n             andSQL:@\"SELECT identifier, content FROM testTable WHERE identifier > 0 ORDER BY identifier DESC LIMIT 1\"\n        bySelecting:^WCTOneRow * {\n            return [self.table getRowOnResultColumns:TestCaseObject.allProperties where:TestCaseObject.identifier > 0 orders:TestCaseObject.identifier.asOrder(WCTOrderedDescending)];\n        }];\n}\n\n- (void)test_table_get_row_where_offset\n{\n    [self doTestRow:@[ @(self.object2.identifier), self.object2.content ]\n             andSQL:@\"SELECT identifier, content FROM testTable WHERE identifier > 0 ORDER BY rowid ASC LIMIT 1 OFFSET 1\"\n        bySelecting:^WCTOneRow * {\n            return [self.table getRowOnResultColumns:TestCaseObject.allProperties where:TestCaseObject.identifier > 0 offset:1];\n        }];\n}\n\n- (void)test_table_get_row_orders_offset\n{\n    [self doTestRow:@[ @(self.object1.identifier), self.object1.content ]\n             andSQL:@\"SELECT identifier, content FROM testTable ORDER BY identifier DESC LIMIT 1 OFFSET 1\"\n        bySelecting:^WCTOneRow * {\n            return [self.table getRowOnResultColumns:TestCaseObject.allProperties orders:TestCaseObject.identifier.asOrder(WCTOrderedDescending) offset:1];\n        }];\n}\n\n- (void)test_table_get_row_where_orders_offset\n{\n    [self doTestRow:@[ @(self.object1.identifier), self.object1.content ]\n             andSQL:@\"SELECT identifier, content FROM testTable WHERE identifier > 0 ORDER BY identifier DESC LIMIT 1 OFFSET 1\"\n        bySelecting:^WCTOneRow * {\n            return [self.table getRowOnResultColumns:TestCaseObject.allProperties where:TestCaseObject.identifier > 0 orders:TestCaseObject.identifier.asOrder(WCTOrderedDescending) offset:1];\n        }];\n}\n\n#pragma mark - Table - Get Column\n- (void)test_table_get_column\n{\n    [self doTestColumn:@[ @(self.object1.identifier), @(self.object2.identifier) ]\n                andSQL:@\"SELECT identifier FROM testTable ORDER BY rowid ASC\"\n           bySelecting:^WCTOneColumn * {\n               return [self.table getColumnOnResultColumn:TestCaseObject.identifier];\n           }];\n}\n\n- (void)test_table_get_column_where\n{\n    [self doTestColumn:@[ @(self.object1.identifier) ]\n                andSQL:@\"SELECT identifier FROM testTable WHERE identifier == 1 ORDER BY rowid ASC\"\n           bySelecting:^WCTOneColumn * {\n               return [self.table getColumnOnResultColumn:TestCaseObject.identifier where:TestCaseObject.identifier == 1];\n           }];\n}\n\n- (void)test_table_get_column_orders\n{\n    [self doTestColumn:@[ @(self.object2.identifier), @(self.object1.identifier) ]\n                andSQL:@\"SELECT identifier FROM testTable ORDER BY identifier DESC\"\n           bySelecting:^WCTOneColumn * {\n               return [self.table getColumnOnResultColumn:TestCaseObject.identifier orders:TestCaseObject.identifier.asOrder(WCTOrderedDescending)];\n           }];\n}\n\n- (void)test_table_get_column_limit\n{\n    [self doTestColumn:@[ @(self.object1.identifier) ]\n                andSQL:@\"SELECT identifier FROM testTable ORDER BY rowid ASC LIMIT 1\"\n           bySelecting:^WCTOneColumn * {\n               return [self.table getColumnOnResultColumn:TestCaseObject.identifier limit:1];\n           }];\n}\n\n- (void)test_table_get_column_where_orders\n{\n    [self doTestColumn:@[ @(self.object2.identifier), @(self.object1.identifier) ]\n                andSQL:@\"SELECT identifier FROM testTable WHERE identifier > 0 ORDER BY identifier DESC\"\n           bySelecting:^WCTOneColumn * {\n               return [self.table getColumnOnResultColumn:TestCaseObject.identifier where:TestCaseObject.identifier > 0 orders:TestCaseObject.identifier.asOrder(WCTOrderedDescending)];\n           }];\n}\n\n- (void)test_table_get_column_where_limit\n{\n    [self doTestColumn:@[ @(self.object2.identifier) ]\n                andSQL:@\"SELECT identifier FROM testTable WHERE identifier > 1 ORDER BY rowid ASC LIMIT 1\"\n           bySelecting:^WCTOneColumn * {\n               return [self.table getColumnOnResultColumn:TestCaseObject.identifier where:TestCaseObject.identifier > 1 limit:1];\n           }];\n}\n\n- (void)test_table_get_column_orders_limit\n{\n    [self doTestColumn:@[ @(self.object2.identifier) ]\n                andSQL:@\"SELECT identifier FROM testTable ORDER BY identifier DESC LIMIT 1\"\n           bySelecting:^WCTOneColumn * {\n               return [self.table getColumnOnResultColumn:TestCaseObject.identifier orders:TestCaseObject.identifier.asOrder(WCTOrderedDescending) limit:1];\n           }];\n}\n\n- (void)test_table_get_column_limit_offset\n{\n    [self doTestColumn:@[ @(self.object2.identifier) ]\n                andSQL:@\"SELECT identifier FROM testTable ORDER BY rowid ASC LIMIT 1 OFFSET 1\"\n           bySelecting:^WCTOneColumn * {\n               return [self.table getColumnOnResultColumn:TestCaseObject.identifier limit:1 offset:1];\n           }];\n}\n\n- (void)test_table_get_column_where_orders_limit\n{\n    [self doTestColumn:@[ @(self.object2.identifier) ]\n                andSQL:@\"SELECT identifier FROM testTable WHERE identifier > 0 ORDER BY identifier DESC LIMIT 1\"\n           bySelecting:^WCTOneColumn * {\n               return [self.table getColumnOnResultColumn:TestCaseObject.identifier where:TestCaseObject.identifier > 0 orders:TestCaseObject.identifier.asOrder(WCTOrderedDescending) limit:1];\n           }];\n}\n\n- (void)test_table_get_column_where_limit_offset\n{\n    [self doTestColumn:@[ @(self.object2.identifier) ]\n                andSQL:@\"SELECT identifier FROM testTable WHERE identifier > 0 ORDER BY rowid ASC LIMIT 1 OFFSET 1\"\n           bySelecting:^WCTOneColumn * {\n               return [self.table getColumnOnResultColumn:TestCaseObject.identifier where:TestCaseObject.identifier > 0 limit:1 offset:1];\n           }];\n}\n\n- (void)test_table_get_column_orders_limit_offset\n{\n    [self doTestColumn:@[ @(self.object1.identifier) ]\n                andSQL:@\"SELECT identifier FROM testTable ORDER BY identifier DESC LIMIT 1 OFFSET 1\"\n           bySelecting:^WCTOneColumn * {\n               return [self.table getColumnOnResultColumn:TestCaseObject.identifier orders:TestCaseObject.identifier.asOrder(WCTOrderedDescending) limit:1 offset:1];\n           }];\n}\n\n- (void)test_table_get_column_where_orders_limit_offset\n{\n    [self doTestColumn:@[ @(self.object1.identifier) ]\n                andSQL:@\"SELECT identifier FROM testTable WHERE identifier > 0 ORDER BY identifier DESC LIMIT 1 OFFSET 1\"\n           bySelecting:^WCTOneColumn * {\n               return [self.table getColumnOnResultColumn:TestCaseObject.identifier where:TestCaseObject.identifier > 0 orders:TestCaseObject.identifier.asOrder(WCTOrderedDescending) limit:1 offset:1];\n           }];\n}\n\n#pragma mark - Table - Get Rows\n- (void)test_table_get_rows\n{\n    [self doTestRows:@[ @[ @(self.object1.identifier), self.object1.content ],\n                        @[ @(self.object2.identifier), self.object2.content ] ]\n              andSQL:@\"SELECT identifier, content FROM testTable ORDER BY rowid ASC\"\n         bySelecting:^WCTColumnsXRows * {\n             return [self.table getRowsOnResultColumns:TestCaseObject.allProperties];\n         }];\n}\n\n- (void)test_table_get_rows_where\n{\n    [self doTestRows:@[ @[ @(self.object1.identifier), self.object1.content ] ]\n              andSQL:@\"SELECT identifier, content FROM testTable WHERE identifier == 1 ORDER BY rowid ASC\"\n         bySelecting:^WCTColumnsXRows * {\n             return [self.table getRowsOnResultColumns:TestCaseObject.allProperties where:TestCaseObject.identifier == 1];\n         }];\n}\n\n- (void)test_table_get_rows_orders\n{\n    [self doTestRows:@[ @[ @(self.object2.identifier), self.object2.content ],\n                        @[ @(self.object1.identifier), self.object1.content ] ]\n              andSQL:@\"SELECT identifier, content FROM testTable ORDER BY identifier DESC\"\n         bySelecting:^WCTColumnsXRows * {\n             return [self.table getRowsOnResultColumns:TestCaseObject.allProperties orders:TestCaseObject.identifier.asOrder(WCTOrderedDescending)];\n         }];\n}\n\n- (void)test_table_get_rows_limit\n{\n    [self doTestRows:@[ @[ @(self.object1.identifier), self.object1.content ] ]\n              andSQL:@\"SELECT identifier, content FROM testTable ORDER BY rowid ASC LIMIT 1\"\n         bySelecting:^WCTColumnsXRows * {\n             return [self.table getRowsOnResultColumns:TestCaseObject.allProperties limit:1];\n         }];\n}\n\n- (void)test_table_get_rows_where_orders\n{\n    [self doTestRows:@[ @[ @(self.object2.identifier), self.object2.content ],\n                        @[ @(self.object1.identifier), self.object1.content ] ]\n              andSQL:@\"SELECT identifier, content FROM testTable WHERE identifier > 0 ORDER BY identifier DESC\"\n         bySelecting:^WCTColumnsXRows * {\n             return [self.table getRowsOnResultColumns:TestCaseObject.allProperties where:TestCaseObject.identifier > 0 orders:TestCaseObject.identifier.asOrder(WCTOrderedDescending)];\n         }];\n}\n\n- (void)test_table_get_rows_where_limit\n{\n    [self doTestRows:@[ @[ @(self.object2.identifier), self.object2.content ] ]\n              andSQL:@\"SELECT identifier, content FROM testTable WHERE identifier > 1 ORDER BY rowid ASC LIMIT 1\"\n         bySelecting:^WCTColumnsXRows * {\n             return [self.table getRowsOnResultColumns:TestCaseObject.allProperties where:TestCaseObject.identifier > 1 limit:1];\n         }];\n}\n\n- (void)test_table_get_rows_orders_limit\n{\n    [self doTestRows:@[ @[ @(self.object2.identifier), self.object2.content ] ]\n              andSQL:@\"SELECT identifier, content FROM testTable ORDER BY identifier DESC LIMIT 1\"\n         bySelecting:^WCTColumnsXRows * {\n             return [self.table getRowsOnResultColumns:TestCaseObject.allProperties orders:TestCaseObject.identifier.asOrder(WCTOrderedDescending) limit:1];\n         }];\n}\n\n- (void)test_table_get_rows_limit_offset\n{\n    [self doTestRows:@[ @[ @(self.object2.identifier), self.object2.content ] ]\n              andSQL:@\"SELECT identifier, content FROM testTable ORDER BY rowid ASC LIMIT 1 OFFSET 1\"\n         bySelecting:^WCTColumnsXRows * {\n             return [self.table getRowsOnResultColumns:TestCaseObject.allProperties limit:1 offset:1];\n         }];\n}\n\n- (void)test_table_get_rows_where_orders_limit\n{\n    [self doTestRows:@[ @[ @(self.object2.identifier), self.object2.content ] ]\n              andSQL:@\"SELECT identifier, content FROM testTable WHERE identifier > 0 ORDER BY identifier DESC LIMIT 1\"\n         bySelecting:^WCTColumnsXRows * {\n             return [self.table getRowsOnResultColumns:TestCaseObject.allProperties where:TestCaseObject.identifier > 0 orders:TestCaseObject.identifier.asOrder(WCTOrderedDescending) limit:1];\n         }];\n}\n\n- (void)test_table_get_rows_where_limit_offset\n{\n    [self doTestRows:@[ @[ @(self.object2.identifier), self.object2.content ] ]\n              andSQL:@\"SELECT identifier, content FROM testTable WHERE identifier > 0 ORDER BY rowid ASC LIMIT 1 OFFSET 1\"\n         bySelecting:^WCTColumnsXRows * {\n             return [self.table getRowsOnResultColumns:TestCaseObject.allProperties where:TestCaseObject.identifier > 0 limit:1 offset:1];\n         }];\n}\n\n- (void)test_table_get_rows_orders_limit_offset\n{\n    [self doTestRows:@[ @[ @(self.object1.identifier), self.object1.content ] ]\n              andSQL:@\"SELECT identifier, content FROM testTable ORDER BY identifier DESC LIMIT 1 OFFSET 1\"\n         bySelecting:^WCTColumnsXRows * {\n             return [self.table getRowsOnResultColumns:TestCaseObject.allProperties orders:TestCaseObject.identifier.asOrder(WCTOrderedDescending) limit:1 offset:1];\n         }];\n}\n\n- (void)test_table_get_rows_where_orders_limit_offset\n{\n    [self doTestRows:@[ @[ @(self.object1.identifier), self.object1.content ] ]\n              andSQL:@\"SELECT identifier, content FROM testTable WHERE identifier > 0 ORDER BY identifier DESC LIMIT 1 OFFSET 1\"\n         bySelecting:^WCTColumnsXRows * {\n             return [self.table getRowsOnResultColumns:TestCaseObject.allProperties where:TestCaseObject.identifier > 0 orders:TestCaseObject.identifier.asOrder(WCTOrderedDescending) limit:1 offset:1];\n         }];\n}\n\n#pragma mark - Handle - Get Object\n- (void)test_handle_get_object\n{\n    [self doTestObject:self.object1\n                andSQL:@\"SELECT identifier, content FROM testTable ORDER BY rowid ASC LIMIT 1\"\n           bySelecting:^NSArray<TestCaseObject *> * {\n               return @[ [[self.database getHandle] getObjectOfClass:self.tableClass fromTable:self.tableName] ];\n           }];\n}\n\n- (void)test_handle_get_object_where\n{\n    [self doTestObject:self.object2\n                andSQL:@\"SELECT identifier, content FROM testTable WHERE identifier == 2 ORDER BY rowid ASC LIMIT 1\"\n           bySelecting:^NSArray<TestCaseObject *> * {\n               return @[ [[self.database getHandle] getObjectOfClass:self.tableClass fromTable:self.tableName where:TestCaseObject.identifier == 2] ];\n           }];\n}\n\n- (void)test_handle_get_object_orders\n{\n    [self doTestObject:self.object2\n                andSQL:@\"SELECT identifier, content FROM testTable ORDER BY identifier DESC LIMIT 1\"\n           bySelecting:^NSArray<TestCaseObject *> * {\n               return @[ [[self.database getHandle] getObjectOfClass:self.tableClass fromTable:self.tableName orders:TestCaseObject.identifier.asOrder(WCTOrderedDescending)] ];\n           }];\n}\n\n- (void)test_handle_get_object_offset\n{\n    [self doTestObject:self.object2\n                andSQL:@\"SELECT identifier, content FROM testTable ORDER BY rowid ASC LIMIT 1 OFFSET 1\"\n           bySelecting:^NSArray<TestCaseObject *> * {\n               return @[ [[self.database getHandle] getObjectOfClass:self.tableClass fromTable:self.tableName offset:1] ];\n           }];\n}\n\n- (void)test_handle_get_object_where_orders\n{\n    [self doTestObject:self.object2\n                andSQL:@\"SELECT identifier, content FROM testTable WHERE identifier > 0 ORDER BY identifier DESC LIMIT 1\"\n           bySelecting:^NSArray<TestCaseObject *> * {\n               return @[ [[self.database getHandle] getObjectOfClass:self.tableClass fromTable:self.tableName where:TestCaseObject.identifier > 0 orders:TestCaseObject.identifier.asOrder(WCTOrderedDescending)] ];\n           }];\n}\n\n- (void)test_handle_get_object_where_offset\n{\n    [self doTestObject:self.object2\n                andSQL:@\"SELECT identifier, content FROM testTable WHERE identifier > 0 ORDER BY rowid ASC LIMIT 1 OFFSET 1\"\n           bySelecting:^NSArray<TestCaseObject *> * {\n               return @[ [[self.database getHandle] getObjectOfClass:self.tableClass fromTable:self.tableName where:TestCaseObject.identifier > 0 offset:1] ];\n           }];\n}\n\n- (void)test_handle_get_object_orders_offset\n{\n    [self doTestObject:self.object1\n                andSQL:@\"SELECT identifier, content FROM testTable ORDER BY identifier DESC LIMIT 1 OFFSET 1\"\n           bySelecting:^NSArray<TestCaseObject *> * {\n               return @[ [[self.database getHandle] getObjectOfClass:self.tableClass fromTable:self.tableName orders:TestCaseObject.identifier.asOrder(WCTOrderedDescending) offset:1] ];\n           }];\n}\n\n- (void)test_handle_get_object_where_orders_offset\n{\n    [self doTestObject:self.object1\n                andSQL:@\"SELECT identifier, content FROM testTable WHERE identifier > 0 ORDER BY identifier DESC LIMIT 1 OFFSET 1\"\n           bySelecting:^NSArray<TestCaseObject *> * {\n               return @[ [[self.database getHandle] getObjectOfClass:self.tableClass fromTable:self.tableName where:TestCaseObject.identifier > 0 orders:TestCaseObject.identifier.asOrder(WCTOrderedDescending) offset:1] ];\n           }];\n}\n\n#pragma mark - Handle - Get Objects\n- (void)test_handle_get_objects\n{\n    [self doTestObjects:self.objects\n                 andSQL:@\"SELECT identifier, content FROM testTable ORDER BY rowid ASC\"\n            bySelecting:^NSArray<TestCaseObject *> * {\n                return [[self.database getHandle] getObjectsOfClass:self.tableClass fromTable:self.tableName];\n            }];\n}\n\n- (void)test_handle_get_objects_where\n{\n    [self doTestObject:self.object1\n                andSQL:@\"SELECT identifier, content FROM testTable WHERE identifier == 1 ORDER BY rowid ASC\"\n           bySelecting:^NSArray<TestCaseObject *> * {\n               return [[self.database getHandle] getObjectsOfClass:self.tableClass fromTable:self.tableName where:TestCaseObject.identifier == 1];\n           }];\n}\n\n- (void)test_handle_get_objects_orders\n{\n    [self doTestObjects:self.objects.reversedArray\n                 andSQL:@\"SELECT identifier, content FROM testTable ORDER BY identifier DESC\"\n            bySelecting:^NSArray<TestCaseObject *> * {\n                return [[self.database getHandle] getObjectsOfClass:self.tableClass fromTable:self.tableName orders:TestCaseObject.identifier.asOrder(WCTOrderedDescending)];\n            }];\n}\n\n- (void)test_handle_get_objects_limit\n{\n    [self doTestObject:self.object1\n                andSQL:@\"SELECT identifier, content FROM testTable ORDER BY rowid ASC LIMIT 1\"\n           bySelecting:^NSArray<TestCaseObject *> * {\n               return [[self.database getHandle] getObjectsOfClass:self.tableClass fromTable:self.tableName limit:1];\n           }];\n}\n\n- (void)test_handle_get_objects_where_orders\n{\n    [self doTestObjects:self.objects.reversedArray\n                 andSQL:@\"SELECT identifier, content FROM testTable WHERE identifier > 0 ORDER BY identifier DESC\"\n            bySelecting:^NSArray<TestCaseObject *> * {\n                return [[self.database getHandle] getObjectsOfClass:self.tableClass fromTable:self.tableName where:TestCaseObject.identifier > 0 orders:TestCaseObject.identifier.asOrder(WCTOrderedDescending)];\n            }];\n}\n\n- (void)test_handle_get_objects_where_limit\n{\n    [self doTestObject:self.object2\n                andSQL:@\"SELECT identifier, content FROM testTable WHERE identifier > 1 ORDER BY rowid ASC LIMIT 1\"\n           bySelecting:^NSArray<TestCaseObject *> * {\n               return [[self.database getHandle] getObjectsOfClass:self.tableClass fromTable:self.tableName where:TestCaseObject.identifier > 1 limit:1];\n           }];\n}\n\n- (void)test_handle_get_objects_orders_limit\n{\n    [self doTestObject:self.object2\n                andSQL:@\"SELECT identifier, content FROM testTable ORDER BY identifier DESC LIMIT 1\"\n           bySelecting:^NSArray<TestCaseObject *> * {\n               return [[self.database getHandle] getObjectsOfClass:self.tableClass fromTable:self.tableName orders:TestCaseObject.identifier.asOrder(WCTOrderedDescending) limit:1];\n           }];\n}\n\n- (void)test_handle_get_objects_limit_offset\n{\n    [self doTestObject:self.object2\n                andSQL:@\"SELECT identifier, content FROM testTable ORDER BY rowid ASC LIMIT 1 OFFSET 1\"\n           bySelecting:^NSArray<TestCaseObject *> * {\n               return [[self.database getHandle] getObjectsOfClass:self.tableClass fromTable:self.tableName limit:1 offset:1];\n           }];\n}\n\n- (void)test_handle_get_objects_where_orders_limit\n{\n    [self doTestObject:self.object2\n                andSQL:@\"SELECT identifier, content FROM testTable WHERE identifier > 0 ORDER BY identifier DESC LIMIT 1\"\n           bySelecting:^NSArray<TestCaseObject *> * {\n               return [[self.database getHandle] getObjectsOfClass:self.tableClass fromTable:self.tableName where:TestCaseObject.identifier > 0 orders:TestCaseObject.identifier.asOrder(WCTOrderedDescending) limit:1];\n           }];\n}\n\n- (void)test_handle_get_objects_where_limit_offset\n{\n    [self doTestObject:self.object2\n                andSQL:@\"SELECT identifier, content FROM testTable WHERE identifier > 0 ORDER BY rowid ASC LIMIT 1 OFFSET 1\"\n           bySelecting:^NSArray<TestCaseObject *> * {\n               return [[self.database getHandle] getObjectsOfClass:self.tableClass fromTable:self.tableName where:TestCaseObject.identifier > 0 limit:1 offset:1];\n           }];\n}\n\n- (void)test_handle_get_objects_orders_limit_offset\n{\n    [self doTestObject:self.object1\n                andSQL:@\"SELECT identifier, content FROM testTable ORDER BY identifier DESC LIMIT 1 OFFSET 1\"\n           bySelecting:^NSArray<TestCaseObject *> * {\n               return [[self.database getHandle] getObjectsOfClass:self.tableClass fromTable:self.tableName orders:TestCaseObject.identifier.asOrder(WCTOrderedDescending) limit:1 offset:1];\n           }];\n}\n\n- (void)test_handle_get_objects_where_orders_limit_offset\n{\n    [self doTestObject:self.object1\n                andSQL:@\"SELECT identifier, content FROM testTable WHERE identifier > 0 ORDER BY identifier DESC LIMIT 1 OFFSET 1\"\n           bySelecting:^NSArray<TestCaseObject *> * {\n               return [[self.database getHandle] getObjectsOfClass:self.tableClass fromTable:self.tableName where:TestCaseObject.identifier > 0 orders:TestCaseObject.identifier.asOrder(WCTOrderedDescending) limit:1 offset:1];\n           }];\n}\n\n#pragma mark - Handle - Get Part Of Object\n- (void)test_handle_get_object_on_result_columns\n{\n    [self doTestObject:self.partialObject1\n                andSQL:@\"SELECT identifier FROM testTable ORDER BY rowid ASC LIMIT 1\"\n           bySelecting:^NSArray<TestCaseObject *> * {\n               return @[ [[self.database getHandle] getObjectOnResultColumns:TestCaseObject.identifier fromTable:self.tableName] ];\n           }];\n}\n\n- (void)test_handle_get_object_on_result_columns_where\n{\n    [self doTestObject:self.partialObject1\n                andSQL:@\"SELECT identifier FROM testTable WHERE identifier == 1 ORDER BY rowid ASC LIMIT 1\"\n           bySelecting:^NSArray<TestCaseObject *> * {\n               return @[ [[self.database getHandle] getObjectOnResultColumns:TestCaseObject.identifier fromTable:self.tableName where:TestCaseObject.identifier == 1] ];\n           }];\n}\n\n- (void)test_handle_get_object_on_result_columns_orders\n{\n    [self doTestObject:self.partialObject2\n                andSQL:@\"SELECT identifier FROM testTable ORDER BY identifier DESC LIMIT 1\"\n           bySelecting:^NSArray<TestCaseObject *> * {\n               return @[ [[self.database getHandle] getObjectOnResultColumns:TestCaseObject.identifier fromTable:self.tableName orders:TestCaseObject.identifier.asOrder(WCTOrderedDescending)] ];\n           }];\n}\n\n- (void)test_handle_get_object_on_result_columns_offset\n{\n    [self doTestObject:self.partialObject2\n                andSQL:@\"SELECT identifier FROM testTable ORDER BY rowid ASC LIMIT 1 OFFSET 1\"\n           bySelecting:^NSArray<TestCaseObject *> * {\n               return @[ [[self.database getHandle] getObjectOnResultColumns:TestCaseObject.identifier fromTable:self.tableName offset:1] ];\n           }];\n}\n\n- (void)test_handle_get_object_on_result_columns_where_orders\n{\n    [self doTestObject:self.partialObject2\n                andSQL:@\"SELECT identifier FROM testTable WHERE identifier > 0 ORDER BY identifier DESC LIMIT 1\"\n           bySelecting:^NSArray<TestCaseObject *> * {\n               return @[ [[self.database getHandle] getObjectOnResultColumns:TestCaseObject.identifier fromTable:self.tableName where:TestCaseObject.identifier > 0 orders:TestCaseObject.identifier.asOrder(WCTOrderedDescending)] ];\n           }];\n}\n\n- (void)test_handle_get_object_on_result_columns_where_offset\n{\n    [self doTestObject:self.partialObject2\n                andSQL:@\"SELECT identifier FROM testTable WHERE identifier > 0 ORDER BY rowid ASC LIMIT 1 OFFSET 1\"\n           bySelecting:^NSArray<TestCaseObject *> * {\n               return @[ [[self.database getHandle] getObjectOnResultColumns:TestCaseObject.identifier fromTable:self.tableName where:TestCaseObject.identifier > 0 offset:1] ];\n           }];\n}\n\n- (void)test_handle_get_object_on_result_columns_orders_offset\n{\n    [self doTestObject:self.partialObject1\n                andSQL:@\"SELECT identifier FROM testTable ORDER BY identifier DESC LIMIT 1 OFFSET 1\"\n           bySelecting:^NSArray<TestCaseObject *> * {\n               return @[ [[self.database getHandle] getObjectOnResultColumns:TestCaseObject.identifier fromTable:self.tableName orders:TestCaseObject.identifier.asOrder(WCTOrderedDescending) offset:1] ];\n           }];\n}\n\n- (void)test_handle_get_object_on_result_columns_where_orders_offset\n{\n    [self doTestObject:self.partialObject1\n                andSQL:@\"SELECT identifier FROM testTable WHERE identifier > 0 ORDER BY identifier DESC LIMIT 1 OFFSET 1\"\n           bySelecting:^NSArray<TestCaseObject *> * {\n               return @[ [[self.database getHandle] getObjectOnResultColumns:TestCaseObject.identifier fromTable:self.tableName where:TestCaseObject.identifier > 0 orders:TestCaseObject.identifier.asOrder(WCTOrderedDescending) offset:1] ];\n           }];\n}\n\n#pragma mark - Handle - Get Part Of Objects\n- (void)test_handle_get_objects_on_result_columns\n{\n    [self doTestObjects:self.partialObjects\n                 andSQL:@\"SELECT identifier FROM testTable ORDER BY rowid ASC\"\n            bySelecting:^NSArray<TestCaseObject *> * {\n                return [[self.database getHandle] getObjectsOnResultColumns:TestCaseObject.identifier fromTable:self.tableName];\n            }];\n}\n\n- (void)test_handle_get_objects_on_result_columns_where\n{\n    [self doTestObject:self.partialObject1\n                andSQL:@\"SELECT identifier FROM testTable WHERE identifier == 1 ORDER BY rowid ASC\"\n           bySelecting:^NSArray<TestCaseObject *> * {\n               return [[self.database getHandle] getObjectsOnResultColumns:TestCaseObject.identifier fromTable:self.tableName where:TestCaseObject.identifier == 1];\n           }];\n}\n\n- (void)test_handle_get_objects_on_result_columns_orders\n{\n    [self doTestObjects:self.partialObjects.reversedArray\n                 andSQL:@\"SELECT identifier FROM testTable ORDER BY identifier DESC\"\n            bySelecting:^NSArray<TestCaseObject *> * {\n                return [[self.database getHandle] getObjectsOnResultColumns:TestCaseObject.identifier fromTable:self.tableName orders:TestCaseObject.identifier.asOrder(WCTOrderedDescending)];\n            }];\n}\n\n- (void)test_handle_get_objects_on_result_columns_limit\n{\n    [self doTestObject:self.partialObject1\n                andSQL:@\"SELECT identifier FROM testTable ORDER BY rowid ASC LIMIT 1\"\n           bySelecting:^NSArray<TestCaseObject *> * {\n               return [[self.database getHandle] getObjectsOnResultColumns:TestCaseObject.identifier fromTable:self.tableName limit:1];\n           }];\n}\n\n- (void)test_handle_get_objects_on_result_columns_where_orders\n{\n    [self doTestObjects:self.partialObjects.reversedArray\n                 andSQL:@\"SELECT identifier FROM testTable WHERE identifier > 0 ORDER BY identifier DESC\"\n            bySelecting:^NSArray<TestCaseObject *> * {\n                return [[self.database getHandle] getObjectsOnResultColumns:TestCaseObject.identifier fromTable:self.tableName where:TestCaseObject.identifier > 0 orders:TestCaseObject.identifier.asOrder(WCTOrderedDescending)];\n            }];\n}\n\n- (void)test_handle_get_objects_on_result_columns_where_limit\n{\n    [self doTestObject:self.partialObject2\n                andSQL:@\"SELECT identifier FROM testTable WHERE identifier > 1 ORDER BY rowid ASC LIMIT 1\"\n           bySelecting:^NSArray<TestCaseObject *> * {\n               return [[self.database getHandle] getObjectsOnResultColumns:TestCaseObject.identifier fromTable:self.tableName where:TestCaseObject.identifier > 1 limit:1];\n           }];\n}\n\n- (void)test_handle_get_objects_on_result_columns_orders_limit\n{\n    [self doTestObject:self.partialObject2\n                andSQL:@\"SELECT identifier FROM testTable ORDER BY identifier DESC LIMIT 1\"\n           bySelecting:^NSArray<TestCaseObject *> * {\n               return [[self.database getHandle] getObjectsOnResultColumns:TestCaseObject.identifier fromTable:self.tableName orders:TestCaseObject.identifier.asOrder(WCTOrderedDescending) limit:1];\n           }];\n}\n\n- (void)test_handle_get_objects_on_result_columns_limit_offset\n{\n    [self doTestObject:self.partialObject2\n                andSQL:@\"SELECT identifier FROM testTable ORDER BY rowid ASC LIMIT 1 OFFSET 1\"\n           bySelecting:^NSArray<TestCaseObject *> * {\n               return [[self.database getHandle] getObjectsOnResultColumns:TestCaseObject.identifier fromTable:self.tableName limit:1 offset:1];\n           }];\n}\n\n- (void)test_handle_get_objects_on_result_columns_where_orders_limit\n{\n    [self doTestObject:self.partialObject2\n                andSQL:@\"SELECT identifier FROM testTable WHERE identifier > 0 ORDER BY identifier DESC LIMIT 1\"\n           bySelecting:^NSArray<TestCaseObject *> * {\n               return [[self.database getHandle] getObjectsOnResultColumns:TestCaseObject.identifier fromTable:self.tableName where:TestCaseObject.identifier > 0 orders:TestCaseObject.identifier.asOrder(WCTOrderedDescending) limit:1];\n           }];\n}\n\n- (void)test_handle_get_objects_on_result_columns_where_limit_offset\n{\n    [self doTestObject:self.partialObject2\n                andSQL:@\"SELECT identifier FROM testTable WHERE identifier > 0 ORDER BY rowid ASC LIMIT 1 OFFSET 1\"\n           bySelecting:^NSArray<TestCaseObject *> * {\n               return [[self.database getHandle] getObjectsOnResultColumns:TestCaseObject.identifier fromTable:self.tableName where:TestCaseObject.identifier > 0 limit:1 offset:1];\n           }];\n}\n\n- (void)test_handle_get_objects_on_result_columns_orders_limit_offset\n{\n    [self doTestObject:self.partialObject1\n                andSQL:@\"SELECT identifier FROM testTable ORDER BY identifier DESC LIMIT 1 OFFSET 1\"\n           bySelecting:^NSArray<TestCaseObject *> * {\n               return [[self.database getHandle] getObjectsOnResultColumns:TestCaseObject.identifier fromTable:self.tableName orders:TestCaseObject.identifier.asOrder(WCTOrderedDescending) limit:1 offset:1];\n           }];\n}\n\n- (void)test_handle_get_objects_on_result_columns_where_orders_limit_offset\n{\n    [self doTestObject:self.partialObject1\n                andSQL:@\"SELECT identifier FROM testTable WHERE identifier > 0 ORDER BY identifier DESC LIMIT 1 OFFSET 1\"\n           bySelecting:^NSArray<TestCaseObject *> * {\n               return [[self.database getHandle] getObjectsOnResultColumns:TestCaseObject.identifier fromTable:self.tableName where:TestCaseObject.identifier > 0 orders:TestCaseObject.identifier.asOrder(WCTOrderedDescending) limit:1 offset:1];\n           }];\n}\n\n#pragma mark - Handle - Get Value\n- (void)test_handle_get_value\n{\n    [self doTestValue:@(self.object1.identifier)\n               andSQL:@\"SELECT identifier FROM testTable ORDER BY rowid ASC LIMIT 1\"\n          bySelecting:^WCTValue * {\n              return [[self.database getHandle] getValueOnResultColumn:TestCaseObject.identifier fromTable:self.tableName];\n          }];\n}\n\n- (void)test_handle_get_value_where\n{\n    [self doTestValue:@(self.object2.identifier)\n               andSQL:@\"SELECT identifier FROM testTable WHERE identifier == 2 ORDER BY rowid ASC LIMIT 1\"\n          bySelecting:^WCTValue * {\n              return [[self.database getHandle] getValueOnResultColumn:TestCaseObject.identifier fromTable:self.tableName where:TestCaseObject.identifier == 2];\n          }];\n}\n\n- (void)test_handle_get_value_orders\n{\n    [self doTestValue:@(self.object2.identifier)\n               andSQL:@\"SELECT identifier FROM testTable ORDER BY identifier DESC LIMIT 1\"\n          bySelecting:^WCTValue * {\n              return [[self.database getHandle] getValueOnResultColumn:TestCaseObject.identifier fromTable:self.tableName orders:TestCaseObject.identifier.asOrder(WCTOrderedDescending)];\n          }];\n}\n\n- (void)test_handle_get_value_offset\n{\n    [self doTestValue:@(self.object2.identifier)\n               andSQL:@\"SELECT identifier FROM testTable ORDER BY rowid ASC LIMIT 1 OFFSET 1\"\n          bySelecting:^WCTValue * {\n              return [[self.database getHandle] getValueOnResultColumn:TestCaseObject.identifier fromTable:self.tableName offset:1];\n          }];\n}\n\n- (void)test_handle_get_value_where_orders\n{\n    [self doTestValue:@(self.object2.identifier)\n               andSQL:@\"SELECT identifier FROM testTable WHERE identifier > 0 ORDER BY identifier DESC LIMIT 1\"\n          bySelecting:^WCTValue * {\n              return [[self.database getHandle] getValueOnResultColumn:TestCaseObject.identifier fromTable:self.tableName where:TestCaseObject.identifier > 0 orders:TestCaseObject.identifier.asOrder(WCTOrderedDescending)];\n          }];\n}\n\n- (void)test_handle_get_value_where_offset\n{\n    [self doTestValue:@(self.object2.identifier)\n               andSQL:@\"SELECT identifier FROM testTable WHERE identifier > 0 ORDER BY rowid ASC LIMIT 1 OFFSET 1\"\n          bySelecting:^WCTValue * {\n              return [[self.database getHandle] getValueOnResultColumn:TestCaseObject.identifier fromTable:self.tableName where:TestCaseObject.identifier > 0 offset:1];\n          }];\n}\n\n- (void)test_handle_get_value_orders_offset\n{\n    [self doTestValue:@(self.object1.identifier)\n               andSQL:@\"SELECT identifier FROM testTable ORDER BY identifier DESC LIMIT 1 OFFSET 1\"\n          bySelecting:^WCTValue * {\n              return [[self.database getHandle] getValueOnResultColumn:TestCaseObject.identifier fromTable:self.tableName orders:TestCaseObject.identifier.asOrder(WCTOrderedDescending) offset:1];\n          }];\n}\n\n- (void)test_handle_get_value_where_orders_offset\n{\n    [self doTestValue:@(self.object1.identifier)\n               andSQL:@\"SELECT identifier FROM testTable WHERE identifier > 0 ORDER BY identifier DESC LIMIT 1 OFFSET 1\"\n          bySelecting:^WCTValue * {\n              return [[self.database getHandle] getValueOnResultColumn:TestCaseObject.identifier fromTable:self.tableName where:TestCaseObject.identifier > 0 orders:TestCaseObject.identifier.asOrder(WCTOrderedDescending) offset:1];\n          }];\n}\n\n#pragma mark - Handle - Get Row\n- (void)test_handle_get_row\n{\n    [self doTestRow:@[ @(self.object1.identifier), self.object1.content ]\n             andSQL:@\"SELECT identifier, content FROM testTable ORDER BY rowid ASC LIMIT 1\"\n        bySelecting:^WCTOneRow * {\n            return [[self.database getHandle] getRowOnResultColumns:TestCaseObject.allProperties fromTable:self.tableName];\n        }];\n}\n\n- (void)test_handle_get_row_where\n{\n    [self doTestRow:@[ @(self.object2.identifier), self.object2.content ]\n             andSQL:@\"SELECT identifier, content FROM testTable WHERE identifier == 2 ORDER BY rowid ASC LIMIT 1\"\n        bySelecting:^WCTOneRow * {\n            return [[self.database getHandle] getRowOnResultColumns:TestCaseObject.allProperties fromTable:self.tableName where:TestCaseObject.identifier == 2];\n        }];\n}\n\n- (void)test_handle_get_row_orders\n{\n    [self doTestRow:@[ @(self.object2.identifier), self.object2.content ]\n             andSQL:@\"SELECT identifier, content FROM testTable ORDER BY identifier DESC LIMIT 1\"\n        bySelecting:^WCTOneRow * {\n            return [[self.database getHandle] getRowOnResultColumns:TestCaseObject.allProperties fromTable:self.tableName orders:TestCaseObject.identifier.asOrder(WCTOrderedDescending)];\n        }];\n}\n\n- (void)test_handle_get_row_offset\n{\n    [self doTestRow:@[ @(self.object2.identifier), self.object2.content ]\n             andSQL:@\"SELECT identifier, content FROM testTable ORDER BY rowid ASC LIMIT 1 OFFSET 1\"\n        bySelecting:^WCTOneRow * {\n            return [[self.database getHandle] getRowOnResultColumns:TestCaseObject.allProperties fromTable:self.tableName offset:1];\n        }];\n}\n\n- (void)test_handle_get_row_where_orders\n{\n    [self doTestRow:@[ @(self.object2.identifier), self.object2.content ]\n             andSQL:@\"SELECT identifier, content FROM testTable WHERE identifier > 0 ORDER BY identifier DESC LIMIT 1\"\n        bySelecting:^WCTOneRow * {\n            return [[self.database getHandle] getRowOnResultColumns:TestCaseObject.allProperties fromTable:self.tableName where:TestCaseObject.identifier > 0 orders:TestCaseObject.identifier.asOrder(WCTOrderedDescending)];\n        }];\n}\n\n- (void)test_handle_get_row_where_offset\n{\n    [self doTestRow:@[ @(self.object2.identifier), self.object2.content ]\n             andSQL:@\"SELECT identifier, content FROM testTable WHERE identifier > 0 ORDER BY rowid ASC LIMIT 1 OFFSET 1\"\n        bySelecting:^WCTOneRow * {\n            return [[self.database getHandle] getRowOnResultColumns:TestCaseObject.allProperties fromTable:self.tableName where:TestCaseObject.identifier > 0 offset:1];\n        }];\n}\n\n- (void)test_handle_get_row_orders_offset\n{\n    [self doTestRow:@[ @(self.object1.identifier), self.object1.content ]\n             andSQL:@\"SELECT identifier, content FROM testTable ORDER BY identifier DESC LIMIT 1 OFFSET 1\"\n        bySelecting:^WCTOneRow * {\n            return [[self.database getHandle] getRowOnResultColumns:TestCaseObject.allProperties fromTable:self.tableName orders:TestCaseObject.identifier.asOrder(WCTOrderedDescending) offset:1];\n        }];\n}\n\n- (void)test_handle_get_row_where_orders_offset\n{\n    [self doTestRow:@[ @(self.object1.identifier), self.object1.content ]\n             andSQL:@\"SELECT identifier, content FROM testTable WHERE identifier > 0 ORDER BY identifier DESC LIMIT 1 OFFSET 1\"\n        bySelecting:^WCTOneRow * {\n            return [[self.database getHandle] getRowOnResultColumns:TestCaseObject.allProperties fromTable:self.tableName where:TestCaseObject.identifier > 0 orders:TestCaseObject.identifier.asOrder(WCTOrderedDescending) offset:1];\n        }];\n}\n\n#pragma mark - Handle - Get Column\n- (void)test_handle_get_column\n{\n    [self doTestColumn:@[ @(self.object1.identifier), @(self.object2.identifier) ]\n                andSQL:@\"SELECT identifier FROM testTable ORDER BY rowid ASC\"\n           bySelecting:^WCTOneColumn * {\n               return [[self.database getHandle] getColumnOnResultColumn:TestCaseObject.identifier fromTable:self.tableName];\n           }];\n}\n\n- (void)test_handle_get_column_where\n{\n    [self doTestColumn:@[ @(self.object1.identifier) ]\n                andSQL:@\"SELECT identifier FROM testTable WHERE identifier == 1 ORDER BY rowid ASC\"\n           bySelecting:^WCTOneColumn * {\n               return [[self.database getHandle] getColumnOnResultColumn:TestCaseObject.identifier fromTable:self.tableName where:TestCaseObject.identifier == 1];\n           }];\n}\n\n- (void)test_handle_get_column_orders\n{\n    [self doTestColumn:@[ @(self.object2.identifier), @(self.object1.identifier) ]\n                andSQL:@\"SELECT identifier FROM testTable ORDER BY identifier DESC\"\n           bySelecting:^WCTOneColumn * {\n               return [[self.database getHandle] getColumnOnResultColumn:TestCaseObject.identifier fromTable:self.tableName orders:TestCaseObject.identifier.asOrder(WCTOrderedDescending)];\n           }];\n}\n\n- (void)test_handle_get_column_limit\n{\n    [self doTestColumn:@[ @(self.object1.identifier) ]\n                andSQL:@\"SELECT identifier FROM testTable ORDER BY rowid ASC LIMIT 1\"\n           bySelecting:^WCTOneColumn * {\n               return [[self.database getHandle] getColumnOnResultColumn:TestCaseObject.identifier fromTable:self.tableName limit:1];\n           }];\n}\n\n- (void)test_handle_get_column_where_orders\n{\n    [self doTestColumn:@[ @(self.object2.identifier), @(self.object1.identifier) ]\n                andSQL:@\"SELECT identifier FROM testTable WHERE identifier > 0 ORDER BY identifier DESC\"\n           bySelecting:^WCTOneColumn * {\n               return [[self.database getHandle] getColumnOnResultColumn:TestCaseObject.identifier fromTable:self.tableName where:TestCaseObject.identifier > 0 orders:TestCaseObject.identifier.asOrder(WCTOrderedDescending)];\n           }];\n}\n\n- (void)test_handle_get_column_where_limit\n{\n    [self doTestColumn:@[ @(self.object2.identifier) ]\n                andSQL:@\"SELECT identifier FROM testTable WHERE identifier > 1 ORDER BY rowid ASC LIMIT 1\"\n           bySelecting:^WCTOneColumn * {\n               return [[self.database getHandle] getColumnOnResultColumn:TestCaseObject.identifier fromTable:self.tableName where:TestCaseObject.identifier > 1 limit:1];\n           }];\n}\n\n- (void)test_handle_get_column_orders_limit\n{\n    [self doTestColumn:@[ @(self.object2.identifier) ]\n                andSQL:@\"SELECT identifier FROM testTable ORDER BY identifier DESC LIMIT 1\"\n           bySelecting:^WCTOneColumn * {\n               return [[self.database getHandle] getColumnOnResultColumn:TestCaseObject.identifier fromTable:self.tableName orders:TestCaseObject.identifier.asOrder(WCTOrderedDescending) limit:1];\n           }];\n}\n\n- (void)test_handle_get_column_limit_offset\n{\n    [self doTestColumn:@[ @(self.object2.identifier) ]\n                andSQL:@\"SELECT identifier FROM testTable ORDER BY rowid ASC LIMIT 1 OFFSET 1\"\n           bySelecting:^WCTOneColumn * {\n               return [[self.database getHandle] getColumnOnResultColumn:TestCaseObject.identifier fromTable:self.tableName limit:1 offset:1];\n           }];\n}\n\n- (void)test_handle_get_column_where_orders_limit\n{\n    [self doTestColumn:@[ @(self.object2.identifier) ]\n                andSQL:@\"SELECT identifier FROM testTable WHERE identifier > 0 ORDER BY identifier DESC LIMIT 1\"\n           bySelecting:^WCTOneColumn * {\n               return [[self.database getHandle] getColumnOnResultColumn:TestCaseObject.identifier fromTable:self.tableName where:TestCaseObject.identifier > 0 orders:TestCaseObject.identifier.asOrder(WCTOrderedDescending) limit:1];\n           }];\n}\n\n- (void)test_handle_get_column_where_limit_offset\n{\n    [self doTestColumn:@[ @(self.object2.identifier) ]\n                andSQL:@\"SELECT identifier FROM testTable WHERE identifier > 0 ORDER BY rowid ASC LIMIT 1 OFFSET 1\"\n           bySelecting:^WCTOneColumn * {\n               return [[self.database getHandle] getColumnOnResultColumn:TestCaseObject.identifier fromTable:self.tableName where:TestCaseObject.identifier > 0 limit:1 offset:1];\n           }];\n}\n\n- (void)test_handle_get_column_orders_limit_offset\n{\n    [self doTestColumn:@[ @(self.object1.identifier) ]\n                andSQL:@\"SELECT identifier FROM testTable ORDER BY identifier DESC LIMIT 1 OFFSET 1\"\n           bySelecting:^WCTOneColumn * {\n               return [[self.database getHandle] getColumnOnResultColumn:TestCaseObject.identifier fromTable:self.tableName orders:TestCaseObject.identifier.asOrder(WCTOrderedDescending) limit:1 offset:1];\n           }];\n}\n\n- (void)test_handle_get_column_where_orders_limit_offset\n{\n    [self doTestColumn:@[ @(self.object1.identifier) ]\n                andSQL:@\"SELECT identifier FROM testTable WHERE identifier > 0 ORDER BY identifier DESC LIMIT 1 OFFSET 1\"\n           bySelecting:^WCTOneColumn * {\n               return [[self.database getHandle] getColumnOnResultColumn:TestCaseObject.identifier fromTable:self.tableName where:TestCaseObject.identifier > 0 orders:TestCaseObject.identifier.asOrder(WCTOrderedDescending) limit:1 offset:1];\n           }];\n}\n\n#pragma mark - Handle - Get Rows\n- (void)test_handle_get_rows\n{\n    [self doTestRows:@[ @[ @(self.object1.identifier), self.object1.content ],\n                        @[ @(self.object2.identifier), self.object2.content ] ]\n              andSQL:@\"SELECT identifier, content FROM testTable ORDER BY rowid ASC\"\n         bySelecting:^WCTColumnsXRows * {\n             return [[self.database getHandle] getRowsOnResultColumns:TestCaseObject.allProperties fromTable:self.tableName];\n         }];\n}\n\n- (void)test_handle_get_rows_where\n{\n    [self doTestRows:@[ @[ @(self.object1.identifier), self.object1.content ] ]\n              andSQL:@\"SELECT identifier, content FROM testTable WHERE identifier == 1 ORDER BY rowid ASC\"\n         bySelecting:^WCTColumnsXRows * {\n             return [[self.database getHandle] getRowsOnResultColumns:TestCaseObject.allProperties fromTable:self.tableName where:TestCaseObject.identifier == 1];\n         }];\n}\n\n- (void)test_handle_get_rows_orders\n{\n    [self doTestRows:@[ @[ @(self.object2.identifier), self.object2.content ],\n                        @[ @(self.object1.identifier), self.object1.content ] ]\n              andSQL:@\"SELECT identifier, content FROM testTable ORDER BY identifier DESC\"\n         bySelecting:^WCTColumnsXRows * {\n             return [[self.database getHandle] getRowsOnResultColumns:TestCaseObject.allProperties fromTable:self.tableName orders:TestCaseObject.identifier.asOrder(WCTOrderedDescending)];\n         }];\n}\n\n- (void)test_handle_get_rows_limit\n{\n    [self doTestRows:@[ @[ @(self.object1.identifier), self.object1.content ] ]\n              andSQL:@\"SELECT identifier, content FROM testTable ORDER BY rowid ASC LIMIT 1\"\n         bySelecting:^WCTColumnsXRows * {\n             return [[self.database getHandle] getRowsOnResultColumns:TestCaseObject.allProperties fromTable:self.tableName limit:1];\n         }];\n}\n\n- (void)test_handle_get_rows_where_orders\n{\n    [self doTestRows:@[ @[ @(self.object2.identifier), self.object2.content ],\n                        @[ @(self.object1.identifier), self.object1.content ] ]\n              andSQL:@\"SELECT identifier, content FROM testTable WHERE identifier > 0 ORDER BY identifier DESC\"\n         bySelecting:^WCTColumnsXRows * {\n             return [[self.database getHandle] getRowsOnResultColumns:TestCaseObject.allProperties fromTable:self.tableName where:TestCaseObject.identifier > 0 orders:TestCaseObject.identifier.asOrder(WCTOrderedDescending)];\n         }];\n}\n\n- (void)test_handle_get_rows_where_limit\n{\n    [self doTestRows:@[ @[ @(self.object2.identifier), self.object2.content ] ]\n              andSQL:@\"SELECT identifier, content FROM testTable WHERE identifier > 1 ORDER BY rowid ASC LIMIT 1\"\n         bySelecting:^WCTColumnsXRows * {\n             return [[self.database getHandle] getRowsOnResultColumns:TestCaseObject.allProperties fromTable:self.tableName where:TestCaseObject.identifier > 1 limit:1];\n         }];\n}\n\n- (void)test_handle_get_rows_orders_limit\n{\n    [self doTestRows:@[ @[ @(self.object2.identifier), self.object2.content ] ]\n              andSQL:@\"SELECT identifier, content FROM testTable ORDER BY identifier DESC LIMIT 1\"\n         bySelecting:^WCTColumnsXRows * {\n             return [[self.database getHandle] getRowsOnResultColumns:TestCaseObject.allProperties fromTable:self.tableName orders:TestCaseObject.identifier.asOrder(WCTOrderedDescending) limit:1];\n         }];\n}\n\n- (void)test_handle_get_rows_limit_offset\n{\n    [self doTestRows:@[ @[ @(self.object2.identifier), self.object2.content ] ]\n              andSQL:@\"SELECT identifier, content FROM testTable ORDER BY rowid ASC LIMIT 1 OFFSET 1\"\n         bySelecting:^WCTColumnsXRows * {\n             return [[self.database getHandle] getRowsOnResultColumns:TestCaseObject.allProperties fromTable:self.tableName limit:1 offset:1];\n         }];\n}\n\n- (void)test_handle_get_rows_where_orders_limit\n{\n    [self doTestRows:@[ @[ @(self.object2.identifier), self.object2.content ] ]\n              andSQL:@\"SELECT identifier, content FROM testTable WHERE identifier > 0 ORDER BY identifier DESC LIMIT 1\"\n         bySelecting:^WCTColumnsXRows * {\n             return [[self.database getHandle] getRowsOnResultColumns:TestCaseObject.allProperties fromTable:self.tableName where:TestCaseObject.identifier > 0 orders:TestCaseObject.identifier.asOrder(WCTOrderedDescending) limit:1];\n         }];\n}\n\n- (void)test_handle_get_rows_where_limit_offset\n{\n    [self doTestRows:@[ @[ @(self.object2.identifier), self.object2.content ] ]\n              andSQL:@\"SELECT identifier, content FROM testTable WHERE identifier > 0 ORDER BY rowid ASC LIMIT 1 OFFSET 1\"\n         bySelecting:^WCTColumnsXRows * {\n             return [[self.database getHandle] getRowsOnResultColumns:TestCaseObject.allProperties fromTable:self.tableName where:TestCaseObject.identifier > 0 limit:1 offset:1];\n         }];\n}\n\n- (void)test_handle_get_rows_orders_limit_offset\n{\n    [self doTestRows:@[ @[ @(self.object1.identifier), self.object1.content ] ]\n              andSQL:@\"SELECT identifier, content FROM testTable ORDER BY identifier DESC LIMIT 1 OFFSET 1\"\n         bySelecting:^WCTColumnsXRows * {\n             return [[self.database getHandle] getRowsOnResultColumns:TestCaseObject.allProperties fromTable:self.tableName orders:TestCaseObject.identifier.asOrder(WCTOrderedDescending) limit:1 offset:1];\n         }];\n}\n\n- (void)test_handle_get_rows_where_orders_limit_offset\n{\n    [self doTestRows:@[ @[ @(self.object1.identifier), self.object1.content ] ]\n              andSQL:@\"SELECT identifier, content FROM testTable WHERE identifier > 0 ORDER BY identifier DESC LIMIT 1 OFFSET 1\"\n         bySelecting:^WCTColumnsXRows * {\n             return [[self.database getHandle] getRowsOnResultColumns:TestCaseObject.allProperties fromTable:self.tableName where:TestCaseObject.identifier > 0 orders:TestCaseObject.identifier.asOrder(WCTOrderedDescending) limit:1 offset:1];\n         }];\n}\n\n#pragma mark - Handle - Get From Statement\n- (void)test_handle_get_row_from_statement\n{\n    [self doTestRow:self.partialRow1\n             andSQL:@\"SELECT identifier FROM testTable ORDER BY rowid ASC LIMIT 1\"\n        bySelecting:^WCTOneRow * {\n            return [[self.database getHandle] getRowFromStatement:WCDB::StatementSelect().select(TestCaseObject.identifier).from(self.tableName).order(WCDB::OrderingTerm::ascendingRowid()).limit(1)];\n        }];\n}\n\n- (void)test_handle_get_column_from_statement\n{\n    [self doTestColumn:self.column\n                andSQL:@\"SELECT identifier FROM testTable ORDER BY rowid ASC\"\n           bySelecting:^WCTOneColumn * {\n               return [[self.database getHandle] getColumnFromStatement:WCDB::StatementSelect().select(TestCaseObject.identifier).from(self.tableName).order(WCDB::OrderingTerm::ascendingRowid())];\n           }];\n}\n\n- (void)test_handle_get_value_from_statement\n{\n    [self doTestValue:self.value1\n               andSQL:@\"SELECT identifier FROM testTable ORDER BY rowid ASC LIMIT 1\"\n          bySelecting:^WCTValue * {\n              return [[self.database getHandle] getValueFromStatement:WCDB::StatementSelect().select(TestCaseObject.identifier).from(self.tableName).order(WCDB::OrderingTerm::ascendingRowid()).limit(1)];\n          }];\n}\n\n- (void)test_handle_get_rows_from_statement\n{\n    [self doTestRows:self.partialRows\n              andSQL:@\"SELECT identifier FROM testTable ORDER BY rowid ASC\"\n         bySelecting:^WCTColumnsXRows * {\n             return [[self.database getHandle] getRowsFromStatement:WCDB::StatementSelect().select(TestCaseObject.identifier).from(self.tableName).order(WCDB::OrderingTerm::ascendingRowid())];\n         }];\n}\n\n@end\n"
  },
  {
    "path": "src/objc/tests/convenient/ConvenientUpdateTests.mm",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"TestCase.h\"\n\n@interface ConvenientUpdateTests : CRUDTestCase\n\n@property (nonatomic, readonly) NSString* renewedContent;\n\n@property (nonatomic, readonly) TestCaseObject* renewObject;\n@property (nonatomic, readonly) WCTColumnCodingRow* renewRow;\n@property (nonatomic, readonly) WCTColumnCodingValue* renewValue;\n\n@property (nonatomic, readonly) TestCaseObject* renewedObject1;\n@property (nonatomic, readonly) TestCaseObject* renewedObject2;\n\n@end\n\n@implementation ConvenientUpdateTests {\n    NSString* _renewedContent;\n\n    TestCaseObject* _renewObject;\n    WCTColumnCodingRow* _renewRow;\n    WCTColumnCodingValue* _renewValue;\n\n    TestCaseObject* _renewedObject1;\n    TestCaseObject* _renewedObject2;\n}\n\n- (void)setUp\n{\n    [super setUp];\n\n    [self insertPresetObjects];\n}\n\n- (NSString*)renewedContent\n{\n    @synchronized(self) {\n        if (_renewedContent == nil) {\n            _renewedContent = Random.shared.string;\n        }\n        return _renewedContent;\n    }\n}\n\n- (TestCaseObject*)renewObject\n{\n    @synchronized(self) {\n        if (_renewObject == nil) {\n            TestCaseObject* object = [TestCaseObject objectWithIdentifier:0 andContent:self.renewedContent];\n            _renewObject = object;\n        }\n        return _renewObject;\n    }\n}\n\n- (WCTColumnCodingRow*)renewRow\n{\n    @synchronized(self) {\n        if (_renewRow == nil) {\n            _renewRow = @[ self.renewedContent ];\n        }\n        return _renewRow;\n    }\n}\n\n- (WCTColumnCodingValue*)renewValue\n{\n    @synchronized(self) {\n        if (_renewValue == nil) {\n            _renewValue = self.renewedContent;\n        }\n        return _renewValue;\n    }\n}\n\n- (TestCaseObject*)renewedObject1\n{\n    @synchronized(self) {\n        if (_renewedObject1 == nil) {\n            TestCaseObject* object = [TestCaseObject objectWithIdentifier:1 andContent:self.renewedContent];\n            _renewedObject1 = object;\n        }\n        return _renewedObject1;\n    }\n}\n\n- (TestCaseObject*)renewedObject2\n{\n    @synchronized(self) {\n        if (_renewedObject2 == nil) {\n            TestCaseObject* object = [TestCaseObject objectWithIdentifier:2 andContent:self.renewedContent];\n            _renewedObject2 = object;\n        }\n        return _renewedObject2;\n    }\n}\n\n#pragma mark - Database - Update Properties To Object\n- (void)test_database_update_table_set_properties_to_object\n{\n    [self doTestObjects:@[ self.renewedObject1, self.renewedObject2 ]\n                 andSQL:@\"UPDATE testTable SET content = ?1\"\n      afterModification:^BOOL {\n          return [self.database updateTable:self.tableName setProperties:TestCaseObject.content toObject:self.renewObject];\n      }];\n}\n\n- (void)test_database_update_table_set_properties_to_object_where\n{\n    [self doTestObjects:@[ self.renewedObject1, self.object2 ]\n                 andSQL:@\"UPDATE testTable SET content = ?1 WHERE identifier == 1\"\n      afterModification:^BOOL {\n          return [self.database updateTable:self.tableName setProperties:TestCaseObject.content toObject:self.renewObject where:TestCaseObject.identifier == 1];\n      }];\n}\n\n- (void)test_database_update_table_set_properties_to_object_limit\n{\n    [self doTestObjects:@[ self.renewedObject1, self.object2 ]\n                 andSQL:@\"UPDATE testTable SET content = ?1 LIMIT 1\"\n      afterModification:^BOOL {\n          return [self.database updateTable:self.tableName setProperties:TestCaseObject.content toObject:self.renewObject limit:1];\n      }];\n}\n\n- (void)test_database_update_table_set_properties_to_object_where_limit\n{\n    [self doTestObjects:@[ self.renewedObject1, self.object2 ]\n                 andSQL:@\"UPDATE testTable SET content = ?1 WHERE identifier == 1 LIMIT 1\"\n      afterModification:^BOOL {\n          return [self.database updateTable:self.tableName setProperties:TestCaseObject.content toObject:self.renewObject where:TestCaseObject.identifier == 1 limit:1];\n      }];\n}\n\n- (void)test_database_update_table_set_properties_to_object_orders_limit\n{\n    [self doTestObjects:@[ self.object1, self.renewedObject2 ]\n                 andSQL:@\"UPDATE testTable SET content = ?1 ORDER BY identifier DESC LIMIT 1\"\n      afterModification:^BOOL {\n          return [self.database updateTable:self.tableName setProperties:TestCaseObject.content toObject:self.renewObject orders:TestCaseObject.identifier.asOrder(WCTOrderedDescending) limit:1];\n      }];\n}\n\n- (void)test_database_update_table_set_properties_to_object_limit_offset\n{\n    [self doTestObjects:@[ self.object1, self.renewedObject2 ]\n                 andSQL:@\"UPDATE testTable SET content = ?1 LIMIT 1 OFFSET 1\"\n      afterModification:^BOOL {\n          return [self.database updateTable:self.tableName setProperties:TestCaseObject.content toObject:self.renewObject limit:1 offset:1];\n      }];\n}\n\n- (void)test_database_update_table_set_properties_to_object_where_orders_limit\n{\n    [self doTestObjects:@[ self.object1, self.renewedObject2 ]\n                 andSQL:@\"UPDATE testTable SET content = ?1 WHERE identifier > 0 ORDER BY identifier DESC LIMIT 1\"\n      afterModification:^BOOL {\n          return [self.database updateTable:self.tableName setProperties:TestCaseObject.content toObject:self.renewObject where:TestCaseObject.identifier > 0 orders:TestCaseObject.identifier.asOrder(WCTOrderedDescending) limit:1];\n      }];\n}\n\n- (void)test_database_update_table_set_properties_to_object_where_limit_offset\n{\n    [self doTestObjects:@[ self.object1, self.renewedObject2 ]\n                 andSQL:@\"UPDATE testTable SET content = ?1 WHERE identifier > 0 LIMIT 1 OFFSET 1\"\n      afterModification:^BOOL {\n          return [self.database updateTable:self.tableName setProperties:TestCaseObject.content toObject:self.renewObject where:TestCaseObject.identifier > 0 limit:1 offset:1];\n      }];\n}\n\n- (void)test_database_update_table_set_properties_to_object_orders_limit_offset\n{\n    [self doTestObjects:@[ self.renewedObject1, self.object2 ]\n                 andSQL:@\"UPDATE testTable SET content = ?1 ORDER BY identifier DESC LIMIT 1 OFFSET 1\"\n      afterModification:^BOOL {\n          return [self.database updateTable:self.tableName setProperties:TestCaseObject.content toObject:self.renewObject orders:TestCaseObject.identifier.asOrder(WCTOrderedDescending) limit:1 offset:1];\n      }];\n}\n\n- (void)test_database_update_table_set_properties_to_object_where_orders_limit_offset\n{\n    [self doTestObjects:@[ self.renewedObject1, self.object2 ]\n                 andSQL:@\"UPDATE testTable SET content = ?1 WHERE identifier > 0 ORDER BY identifier DESC LIMIT 1 OFFSET 1\"\n      afterModification:^BOOL {\n          return [self.database updateTable:self.tableName setProperties:TestCaseObject.content toObject:self.renewObject where:TestCaseObject.identifier > 0 orders:TestCaseObject.identifier.asOrder(WCTOrderedDescending) limit:1 offset:1];\n      }];\n}\n\n#pragma mark - Database - Update Properties To Row\n- (void)test_database_update_table_set_properties_to_row\n{\n    [self doTestObjects:@[ self.renewedObject1, self.renewedObject2 ]\n                 andSQL:@\"UPDATE testTable SET content = ?1\"\n      afterModification:^BOOL {\n          return [self.database updateTable:self.tableName setProperties:TestCaseObject.content toRow:self.renewRow];\n      }];\n}\n\n- (void)test_database_update_table_set_properties_to_row_where\n{\n    [self doTestObjects:@[ self.renewedObject1, self.object2 ]\n                 andSQL:@\"UPDATE testTable SET content = ?1 WHERE identifier == 1\"\n      afterModification:^BOOL {\n          return [self.database updateTable:self.tableName setProperties:TestCaseObject.content toRow:self.renewRow where:TestCaseObject.identifier == 1];\n      }];\n}\n\n- (void)test_database_update_table_set_properties_to_row_limit\n{\n    [self doTestObjects:@[ self.renewedObject1, self.object2 ]\n                 andSQL:@\"UPDATE testTable SET content = ?1 LIMIT 1\"\n      afterModification:^BOOL {\n          return [self.database updateTable:self.tableName setProperties:TestCaseObject.content toRow:self.renewRow limit:1];\n      }];\n}\n\n- (void)test_database_update_table_set_properties_to_row_where_limit\n{\n    [self doTestObjects:@[ self.renewedObject1, self.object2 ]\n                 andSQL:@\"UPDATE testTable SET content = ?1 WHERE identifier == 1 LIMIT 1\"\n      afterModification:^BOOL {\n          return [self.database updateTable:self.tableName setProperties:TestCaseObject.content toRow:self.renewRow where:TestCaseObject.identifier == 1 limit:1];\n      }];\n}\n\n- (void)test_database_update_table_set_properties_to_row_orders_limit\n{\n    [self doTestObjects:@[ self.object1, self.renewedObject2 ]\n                 andSQL:@\"UPDATE testTable SET content = ?1 ORDER BY identifier DESC LIMIT 1\"\n      afterModification:^BOOL {\n          return [self.database updateTable:self.tableName setProperties:TestCaseObject.content toRow:self.renewRow orders:TestCaseObject.identifier.asOrder(WCTOrderedDescending) limit:1];\n      }];\n}\n\n- (void)test_database_update_table_set_properties_to_row_limit_offset\n{\n    [self doTestObjects:@[ self.object1, self.renewedObject2 ]\n                 andSQL:@\"UPDATE testTable SET content = ?1 LIMIT 1 OFFSET 1\"\n      afterModification:^BOOL {\n          return [self.database updateTable:self.tableName setProperties:TestCaseObject.content toRow:self.renewRow limit:1 offset:1];\n      }];\n}\n\n- (void)test_database_update_table_set_properties_to_row_where_orders_limit\n{\n    [self doTestObjects:@[ self.object1, self.renewedObject2 ]\n                 andSQL:@\"UPDATE testTable SET content = ?1 WHERE identifier > 0 ORDER BY identifier DESC LIMIT 1\"\n      afterModification:^BOOL {\n          return [self.database updateTable:self.tableName setProperties:TestCaseObject.content toRow:self.renewRow where:TestCaseObject.identifier > 0 orders:TestCaseObject.identifier.asOrder(WCTOrderedDescending) limit:1];\n      }];\n}\n\n- (void)test_database_update_table_set_properties_to_row_where_limit_offset\n{\n    [self doTestObjects:@[ self.object1, self.renewedObject2 ]\n                 andSQL:@\"UPDATE testTable SET content = ?1 WHERE identifier > 0 LIMIT 1 OFFSET 1\"\n      afterModification:^BOOL {\n          return [self.database updateTable:self.tableName setProperties:TestCaseObject.content toRow:self.renewRow where:TestCaseObject.identifier > 0 limit:1 offset:1];\n      }];\n}\n\n- (void)test_database_update_table_set_properties_to_row_orders_limit_offset\n{\n    [self doTestObjects:@[ self.renewedObject1, self.object2 ]\n                 andSQL:@\"UPDATE testTable SET content = ?1 ORDER BY identifier DESC LIMIT 1 OFFSET 1\"\n      afterModification:^BOOL {\n          return [self.database updateTable:self.tableName setProperties:TestCaseObject.content toRow:self.renewRow orders:TestCaseObject.identifier.asOrder(WCTOrderedDescending) limit:1 offset:1];\n      }];\n}\n\n- (void)test_database_update_table_set_properties_to_row_where_orders_limit_offset\n{\n    [self doTestObjects:@[ self.renewedObject1, self.object2 ]\n                 andSQL:@\"UPDATE testTable SET content = ?1 WHERE identifier > 0 ORDER BY identifier DESC LIMIT 1 OFFSET 1\"\n      afterModification:^BOOL {\n          return [self.database updateTable:self.tableName setProperties:TestCaseObject.content toRow:self.renewRow where:TestCaseObject.identifier > 0 orders:TestCaseObject.identifier.asOrder(WCTOrderedDescending) limit:1 offset:1];\n      }];\n}\n\n#pragma mark - Database - Update Property To Value\n- (void)test_database_update_table_set_property_to_value\n{\n    [self doTestObjects:@[ self.renewedObject1, self.renewedObject2 ]\n                 andSQL:@\"UPDATE testTable SET content = ?1\"\n      afterModification:^BOOL {\n          return [self.database updateTable:self.tableName setProperty:TestCaseObject.content toValue:self.renewValue];\n      }];\n}\n\n- (void)test_database_update_table_set_property_to_value_where\n{\n    [self doTestObjects:@[ self.renewedObject1, self.object2 ]\n                 andSQL:@\"UPDATE testTable SET content = ?1 WHERE identifier == 1\"\n      afterModification:^BOOL {\n          return [self.database updateTable:self.tableName setProperty:TestCaseObject.content toValue:self.renewValue where:TestCaseObject.identifier == 1];\n      }];\n}\n\n- (void)test_database_update_table_set_property_to_value_limit\n{\n    [self doTestObjects:@[ self.renewedObject1, self.object2 ]\n                 andSQL:@\"UPDATE testTable SET content = ?1 LIMIT 1\"\n      afterModification:^BOOL {\n          return [self.database updateTable:self.tableName setProperty:TestCaseObject.content toValue:self.renewValue limit:1];\n      }];\n}\n\n- (void)test_database_update_table_set_property_to_value_where_limit\n{\n    [self doTestObjects:@[ self.renewedObject1, self.object2 ]\n                 andSQL:@\"UPDATE testTable SET content = ?1 WHERE identifier == 1 LIMIT 1\"\n      afterModification:^BOOL {\n          return [self.database updateTable:self.tableName setProperty:TestCaseObject.content toValue:self.renewValue where:TestCaseObject.identifier == 1 limit:1];\n      }];\n}\n\n- (void)test_database_update_table_set_property_to_value_orders_limit\n{\n    [self doTestObjects:@[ self.object1, self.renewedObject2 ]\n                 andSQL:@\"UPDATE testTable SET content = ?1 ORDER BY identifier DESC LIMIT 1\"\n      afterModification:^BOOL {\n          return [self.database updateTable:self.tableName setProperty:TestCaseObject.content toValue:self.renewValue orders:TestCaseObject.identifier.asOrder(WCTOrderedDescending) limit:1];\n      }];\n}\n\n- (void)test_database_update_table_set_property_to_value_limit_offset\n{\n    [self doTestObjects:@[ self.object1, self.renewedObject2 ]\n                 andSQL:@\"UPDATE testTable SET content = ?1 LIMIT 1 OFFSET 1\"\n      afterModification:^BOOL {\n          return [self.database updateTable:self.tableName setProperty:TestCaseObject.content toValue:self.renewValue limit:1 offset:1];\n      }];\n}\n\n- (void)test_database_update_table_set_property_to_value_where_orders_limit\n{\n    [self doTestObjects:@[ self.object1, self.renewedObject2 ]\n                 andSQL:@\"UPDATE testTable SET content = ?1 WHERE identifier > 0 ORDER BY identifier DESC LIMIT 1\"\n      afterModification:^BOOL {\n          return [self.database updateTable:self.tableName setProperty:TestCaseObject.content toValue:self.renewValue where:TestCaseObject.identifier > 0 orders:TestCaseObject.identifier.asOrder(WCTOrderedDescending) limit:1];\n      }];\n}\n\n- (void)test_database_update_table_set_property_to_value_where_limit_offset\n{\n    [self doTestObjects:@[ self.object1, self.renewedObject2 ]\n                 andSQL:@\"UPDATE testTable SET content = ?1 WHERE identifier > 0 LIMIT 1 OFFSET 1\"\n      afterModification:^BOOL {\n          return [self.database updateTable:self.tableName setProperty:TestCaseObject.content toValue:self.renewValue where:TestCaseObject.identifier > 0 limit:1 offset:1];\n      }];\n}\n\n- (void)test_database_update_table_set_property_to_value_orders_limit_offset\n{\n    [self doTestObjects:@[ self.renewedObject1, self.object2 ]\n                 andSQL:@\"UPDATE testTable SET content = ?1 ORDER BY identifier DESC LIMIT 1 OFFSET 1\"\n      afterModification:^BOOL {\n          return [self.database updateTable:self.tableName setProperty:TestCaseObject.content toValue:self.renewValue orders:TestCaseObject.identifier.asOrder(WCTOrderedDescending) limit:1 offset:1];\n      }];\n}\n\n- (void)test_database_update_table_set_property_to_value_where_orders_limit_offset\n{\n    [self doTestObjects:@[ self.renewedObject1, self.object2 ]\n                 andSQL:@\"UPDATE testTable SET content = ?1 WHERE identifier > 0 ORDER BY identifier DESC LIMIT 1 OFFSET 1\"\n      afterModification:^BOOL {\n          return [self.database updateTable:self.tableName setProperty:TestCaseObject.content toValue:self.renewValue where:TestCaseObject.identifier > 0 orders:TestCaseObject.identifier.asOrder(WCTOrderedDescending) limit:1 offset:1];\n      }];\n}\n\n#pragma mark - Table - Update Properties To Object\n- (void)test_table_update_properties_to_object\n{\n    [self doTestObjects:@[ self.renewedObject1, self.renewedObject2 ]\n                 andSQL:@\"UPDATE testTable SET content = ?1\"\n      afterModification:^BOOL {\n          return [self.table updateProperties:TestCaseObject.content toObject:self.renewObject];\n      }];\n}\n\n- (void)test_table_update_properties_to_object_where\n{\n    [self doTestObjects:@[ self.renewedObject1, self.object2 ]\n                 andSQL:@\"UPDATE testTable SET content = ?1 WHERE identifier == 1\"\n      afterModification:^BOOL {\n          return [self.table updateProperties:TestCaseObject.content toObject:self.renewObject where:TestCaseObject.identifier == 1];\n      }];\n}\n\n- (void)test_table_update_properties_to_object_limit\n{\n    [self doTestObjects:@[ self.renewedObject1, self.object2 ]\n                 andSQL:@\"UPDATE testTable SET content = ?1 LIMIT 1\"\n      afterModification:^BOOL {\n          return [self.table updateProperties:TestCaseObject.content toObject:self.renewObject limit:1];\n      }];\n}\n\n- (void)test_table_update_properties_to_object_where_limit\n{\n    [self doTestObjects:@[ self.renewedObject1, self.object2 ]\n                 andSQL:@\"UPDATE testTable SET content = ?1 WHERE identifier == 1 LIMIT 1\"\n      afterModification:^BOOL {\n          return [self.table updateProperties:TestCaseObject.content toObject:self.renewObject where:TestCaseObject.identifier == 1 limit:1];\n      }];\n}\n\n- (void)test_table_update_properties_to_object_orders_limit\n{\n    [self doTestObjects:@[ self.object1, self.renewedObject2 ]\n                 andSQL:@\"UPDATE testTable SET content = ?1 ORDER BY identifier DESC LIMIT 1\"\n      afterModification:^BOOL {\n          return [self.table updateProperties:TestCaseObject.content toObject:self.renewObject orders:TestCaseObject.identifier.asOrder(WCTOrderedDescending) limit:1];\n      }];\n}\n\n- (void)test_table_update_properties_to_object_limit_offset\n{\n    [self doTestObjects:@[ self.object1, self.renewedObject2 ]\n                 andSQL:@\"UPDATE testTable SET content = ?1 LIMIT 1 OFFSET 1\"\n      afterModification:^BOOL {\n          return [self.table updateProperties:TestCaseObject.content toObject:self.renewObject limit:1 offset:1];\n      }];\n}\n\n- (void)test_table_update_properties_to_object_where_orders_limit\n{\n    [self doTestObjects:@[ self.object1, self.renewedObject2 ]\n                 andSQL:@\"UPDATE testTable SET content = ?1 WHERE identifier > 0 ORDER BY identifier DESC LIMIT 1\"\n      afterModification:^BOOL {\n          return [self.table updateProperties:TestCaseObject.content toObject:self.renewObject where:TestCaseObject.identifier > 0 orders:TestCaseObject.identifier.asOrder(WCTOrderedDescending) limit:1];\n      }];\n}\n\n- (void)test_table_update_properties_to_object_where_limit_offset\n{\n    [self doTestObjects:@[ self.object1, self.renewedObject2 ]\n                 andSQL:@\"UPDATE testTable SET content = ?1 WHERE identifier > 0 LIMIT 1 OFFSET 1\"\n      afterModification:^BOOL {\n          return [self.table updateProperties:TestCaseObject.content toObject:self.renewObject where:TestCaseObject.identifier > 0 limit:1 offset:1];\n      }];\n}\n\n- (void)test_table_update_properties_to_object_orders_limit_offset\n{\n    [self doTestObjects:@[ self.renewedObject1, self.object2 ]\n                 andSQL:@\"UPDATE testTable SET content = ?1 ORDER BY identifier DESC LIMIT 1 OFFSET 1\"\n      afterModification:^BOOL {\n          return [self.table updateProperties:TestCaseObject.content toObject:self.renewObject orders:TestCaseObject.identifier.asOrder(WCTOrderedDescending) limit:1 offset:1];\n      }];\n}\n\n- (void)test_table_update_properties_to_object_where_orders_limit_offset\n{\n    [self doTestObjects:@[ self.renewedObject1, self.object2 ]\n                 andSQL:@\"UPDATE testTable SET content = ?1 WHERE identifier > 0 ORDER BY identifier DESC LIMIT 1 OFFSET 1\"\n      afterModification:^BOOL {\n          return [self.table updateProperties:TestCaseObject.content toObject:self.renewObject where:TestCaseObject.identifier > 0 orders:TestCaseObject.identifier.asOrder(WCTOrderedDescending) limit:1 offset:1];\n      }];\n}\n\n#pragma mark - Table - Update Properties To Row\n- (void)test_table_update_properties_to_row\n{\n    [self doTestObjects:@[ self.renewedObject1, self.renewedObject2 ]\n                 andSQL:@\"UPDATE testTable SET content = ?1\"\n      afterModification:^BOOL {\n          return [self.table updateProperties:TestCaseObject.content toRow:self.renewRow];\n      }];\n}\n\n- (void)test_table_update_properties_to_row_where\n{\n    [self doTestObjects:@[ self.renewedObject1, self.object2 ]\n                 andSQL:@\"UPDATE testTable SET content = ?1 WHERE identifier == 1\"\n      afterModification:^BOOL {\n          return [self.table updateProperties:TestCaseObject.content toRow:self.renewRow where:TestCaseObject.identifier == 1];\n      }];\n}\n\n- (void)test_table_update_properties_to_row_limit\n{\n    [self doTestObjects:@[ self.renewedObject1, self.object2 ]\n                 andSQL:@\"UPDATE testTable SET content = ?1 LIMIT 1\"\n      afterModification:^BOOL {\n          return [self.table updateProperties:TestCaseObject.content toRow:self.renewRow limit:1];\n      }];\n}\n\n- (void)test_table_update_properties_to_row_where_limit\n{\n    [self doTestObjects:@[ self.renewedObject1, self.object2 ]\n                 andSQL:@\"UPDATE testTable SET content = ?1 WHERE identifier == 1 LIMIT 1\"\n      afterModification:^BOOL {\n          return [self.table updateProperties:TestCaseObject.content toRow:self.renewRow where:TestCaseObject.identifier == 1 limit:1];\n      }];\n}\n\n- (void)test_table_update_properties_to_row_orders_limit\n{\n    [self doTestObjects:@[ self.object1, self.renewedObject2 ]\n                 andSQL:@\"UPDATE testTable SET content = ?1 ORDER BY identifier DESC LIMIT 1\"\n      afterModification:^BOOL {\n          return [self.table updateProperties:TestCaseObject.content toRow:self.renewRow orders:TestCaseObject.identifier.asOrder(WCTOrderedDescending) limit:1];\n      }];\n}\n\n- (void)test_table_update_properties_to_row_limit_offset\n{\n    [self doTestObjects:@[ self.object1, self.renewedObject2 ]\n                 andSQL:@\"UPDATE testTable SET content = ?1 LIMIT 1 OFFSET 1\"\n      afterModification:^BOOL {\n          return [self.table updateProperties:TestCaseObject.content toRow:self.renewRow limit:1 offset:1];\n      }];\n}\n\n- (void)test_table_update_properties_to_row_where_orders_limit\n{\n    [self doTestObjects:@[ self.object1, self.renewedObject2 ]\n                 andSQL:@\"UPDATE testTable SET content = ?1 WHERE identifier > 0 ORDER BY identifier DESC LIMIT 1\"\n      afterModification:^BOOL {\n          return [self.table updateProperties:TestCaseObject.content toRow:self.renewRow where:TestCaseObject.identifier > 0 orders:TestCaseObject.identifier.asOrder(WCTOrderedDescending) limit:1];\n      }];\n}\n\n- (void)test_table_update_properties_to_row_where_limit_offset\n{\n    [self doTestObjects:@[ self.object1, self.renewedObject2 ]\n                 andSQL:@\"UPDATE testTable SET content = ?1 WHERE identifier > 0 LIMIT 1 OFFSET 1\"\n      afterModification:^BOOL {\n          return [self.table updateProperties:TestCaseObject.content toRow:self.renewRow where:TestCaseObject.identifier > 0 limit:1 offset:1];\n      }];\n}\n\n- (void)test_table_update_properties_to_row_orders_limit_offset\n{\n    [self doTestObjects:@[ self.renewedObject1, self.object2 ]\n                 andSQL:@\"UPDATE testTable SET content = ?1 ORDER BY identifier DESC LIMIT 1 OFFSET 1\"\n      afterModification:^BOOL {\n          return [self.table updateProperties:TestCaseObject.content toRow:self.renewRow orders:TestCaseObject.identifier.asOrder(WCTOrderedDescending) limit:1 offset:1];\n      }];\n}\n\n- (void)test_table_update_properties_to_row_where_orders_limit_offset\n{\n    [self doTestObjects:@[ self.renewedObject1, self.object2 ]\n                 andSQL:@\"UPDATE testTable SET content = ?1 WHERE identifier > 0 ORDER BY identifier DESC LIMIT 1 OFFSET 1\"\n      afterModification:^BOOL {\n          return [self.table updateProperties:TestCaseObject.content toRow:self.renewRow where:TestCaseObject.identifier > 0 orders:TestCaseObject.identifier.asOrder(WCTOrderedDescending) limit:1 offset:1];\n      }];\n}\n\n#pragma mark - Table - Update Property To Value\n- (void)test_table_update_property_to_value\n{\n    [self doTestObjects:@[ self.renewedObject1, self.renewedObject2 ]\n                 andSQL:@\"UPDATE testTable SET content = ?1\"\n      afterModification:^BOOL {\n          return [self.table updateProperty:TestCaseObject.content toValue:self.renewValue];\n      }];\n}\n\n- (void)test_table_update_property_to_value_where\n{\n    [self doTestObjects:@[ self.renewedObject1, self.object2 ]\n                 andSQL:@\"UPDATE testTable SET content = ?1 WHERE identifier == 1\"\n      afterModification:^BOOL {\n          return [self.table updateProperty:TestCaseObject.content toValue:self.renewValue where:TestCaseObject.identifier == 1];\n      }];\n}\n\n- (void)test_table_update_property_to_value_limit\n{\n    [self doTestObjects:@[ self.renewedObject1, self.object2 ]\n                 andSQL:@\"UPDATE testTable SET content = ?1 LIMIT 1\"\n      afterModification:^BOOL {\n          return [self.table updateProperty:TestCaseObject.content toValue:self.renewValue limit:1];\n      }];\n}\n\n- (void)test_table_update_property_to_value_where_limit\n{\n    [self doTestObjects:@[ self.renewedObject1, self.object2 ]\n                 andSQL:@\"UPDATE testTable SET content = ?1 WHERE identifier == 1 LIMIT 1\"\n      afterModification:^BOOL {\n          return [self.table updateProperty:TestCaseObject.content toValue:self.renewValue where:TestCaseObject.identifier == 1 limit:1];\n      }];\n}\n\n- (void)test_table_update_property_to_value_orders_limit\n{\n    [self doTestObjects:@[ self.object1, self.renewedObject2 ]\n                 andSQL:@\"UPDATE testTable SET content = ?1 ORDER BY identifier DESC LIMIT 1\"\n      afterModification:^BOOL {\n          return [self.table updateProperty:TestCaseObject.content toValue:self.renewValue orders:TestCaseObject.identifier.asOrder(WCTOrderedDescending) limit:1];\n      }];\n}\n\n- (void)test_table_update_property_to_value_limit_offset\n{\n    [self doTestObjects:@[ self.object1, self.renewedObject2 ]\n                 andSQL:@\"UPDATE testTable SET content = ?1 LIMIT 1 OFFSET 1\"\n      afterModification:^BOOL {\n          return [self.table updateProperty:TestCaseObject.content toValue:self.renewValue limit:1 offset:1];\n      }];\n}\n\n- (void)test_table_update_property_to_value_where_orders_limit\n{\n    [self doTestObjects:@[ self.object1, self.renewedObject2 ]\n                 andSQL:@\"UPDATE testTable SET content = ?1 WHERE identifier > 0 ORDER BY identifier DESC LIMIT 1\"\n      afterModification:^BOOL {\n          return [self.table updateProperty:TestCaseObject.content toValue:self.renewValue where:TestCaseObject.identifier > 0 orders:TestCaseObject.identifier.asOrder(WCTOrderedDescending) limit:1];\n      }];\n}\n\n- (void)test_table_update_property_to_value_where_limit_offset\n{\n    [self doTestObjects:@[ self.object1, self.renewedObject2 ]\n                 andSQL:@\"UPDATE testTable SET content = ?1 WHERE identifier > 0 LIMIT 1 OFFSET 1\"\n      afterModification:^BOOL {\n          return [self.table updateProperty:TestCaseObject.content toValue:self.renewValue where:TestCaseObject.identifier > 0 limit:1 offset:1];\n      }];\n}\n\n- (void)test_table_update_property_to_value_orders_limit_offset\n{\n    [self doTestObjects:@[ self.renewedObject1, self.object2 ]\n                 andSQL:@\"UPDATE testTable SET content = ?1 ORDER BY identifier DESC LIMIT 1 OFFSET 1\"\n      afterModification:^BOOL {\n          return [self.table updateProperty:TestCaseObject.content toValue:self.renewValue orders:TestCaseObject.identifier.asOrder(WCTOrderedDescending) limit:1 offset:1];\n      }];\n}\n\n- (void)test_table_update_property_to_value_where_orders_limit_offset\n{\n    [self doTestObjects:@[ self.renewedObject1, self.object2 ]\n                 andSQL:@\"UPDATE testTable SET content = ?1 WHERE identifier > 0 ORDER BY identifier DESC LIMIT 1 OFFSET 1\"\n      afterModification:^BOOL {\n          return [self.table updateProperty:TestCaseObject.content toValue:self.renewValue where:TestCaseObject.identifier > 0 orders:TestCaseObject.identifier.asOrder(WCTOrderedDescending) limit:1 offset:1];\n      }];\n}\n\n#pragma mark - Handle - Update Properties To Object\n- (void)test_handle_update_table_set_properties_to_object\n{\n    [self doTestObjects:@[ self.renewedObject1, self.renewedObject2 ]\n                 andSQL:@\"UPDATE testTable SET content = ?1\"\n      afterModification:^BOOL {\n          return [[self.database getHandle] updateTable:self.tableName setProperties:TestCaseObject.content toObject:self.renewObject];\n      }];\n}\n\n- (void)test_handle_update_table_set_properties_to_object_where\n{\n    [self doTestObjects:@[ self.renewedObject1, self.object2 ]\n                 andSQL:@\"UPDATE testTable SET content = ?1 WHERE identifier == 1\"\n      afterModification:^BOOL {\n          return [[self.database getHandle] updateTable:self.tableName setProperties:TestCaseObject.content toObject:self.renewObject where:TestCaseObject.identifier == 1];\n      }];\n}\n\n- (void)test_handle_update_table_set_properties_to_object_limit\n{\n    [self doTestObjects:@[ self.renewedObject1, self.object2 ]\n                 andSQL:@\"UPDATE testTable SET content = ?1 LIMIT 1\"\n      afterModification:^BOOL {\n          return [[self.database getHandle] updateTable:self.tableName setProperties:TestCaseObject.content toObject:self.renewObject limit:1];\n      }];\n}\n\n- (void)test_handle_update_table_set_properties_to_object_where_limit\n{\n    [self doTestObjects:@[ self.renewedObject1, self.object2 ]\n                 andSQL:@\"UPDATE testTable SET content = ?1 WHERE identifier == 1 LIMIT 1\"\n      afterModification:^BOOL {\n          return [[self.database getHandle] updateTable:self.tableName setProperties:TestCaseObject.content toObject:self.renewObject where:TestCaseObject.identifier == 1 limit:1];\n      }];\n}\n\n- (void)test_handle_update_table_set_properties_to_object_orders_limit\n{\n    [self doTestObjects:@[ self.object1, self.renewedObject2 ]\n                 andSQL:@\"UPDATE testTable SET content = ?1 ORDER BY identifier DESC LIMIT 1\"\n      afterModification:^BOOL {\n          return [[self.database getHandle] updateTable:self.tableName setProperties:TestCaseObject.content toObject:self.renewObject orders:TestCaseObject.identifier.asOrder(WCTOrderedDescending) limit:1];\n      }];\n}\n\n- (void)test_handle_update_table_set_properties_to_object_limit_offset\n{\n    [self doTestObjects:@[ self.object1, self.renewedObject2 ]\n                 andSQL:@\"UPDATE testTable SET content = ?1 LIMIT 1 OFFSET 1\"\n      afterModification:^BOOL {\n          return [[self.database getHandle] updateTable:self.tableName setProperties:TestCaseObject.content toObject:self.renewObject limit:1 offset:1];\n      }];\n}\n\n- (void)test_handle_update_table_set_properties_to_object_where_orders_limit\n{\n    [self doTestObjects:@[ self.object1, self.renewedObject2 ]\n                 andSQL:@\"UPDATE testTable SET content = ?1 WHERE identifier > 0 ORDER BY identifier DESC LIMIT 1\"\n      afterModification:^BOOL {\n          return [[self.database getHandle] updateTable:self.tableName setProperties:TestCaseObject.content toObject:self.renewObject where:TestCaseObject.identifier > 0 orders:TestCaseObject.identifier.asOrder(WCTOrderedDescending) limit:1];\n      }];\n}\n\n- (void)test_handle_update_table_set_properties_to_object_where_limit_offset\n{\n    [self doTestObjects:@[ self.object1, self.renewedObject2 ]\n                 andSQL:@\"UPDATE testTable SET content = ?1 WHERE identifier > 0 LIMIT 1 OFFSET 1\"\n      afterModification:^BOOL {\n          return [[self.database getHandle] updateTable:self.tableName setProperties:TestCaseObject.content toObject:self.renewObject where:TestCaseObject.identifier > 0 limit:1 offset:1];\n      }];\n}\n\n- (void)test_handle_update_table_set_properties_to_object_orders_limit_offset\n{\n    [self doTestObjects:@[ self.renewedObject1, self.object2 ]\n                 andSQL:@\"UPDATE testTable SET content = ?1 ORDER BY identifier DESC LIMIT 1 OFFSET 1\"\n      afterModification:^BOOL {\n          return [[self.database getHandle] updateTable:self.tableName setProperties:TestCaseObject.content toObject:self.renewObject orders:TestCaseObject.identifier.asOrder(WCTOrderedDescending) limit:1 offset:1];\n      }];\n}\n\n- (void)test_handle_update_table_set_properties_to_object_where_orders_limit_offset\n{\n    [self doTestObjects:@[ self.renewedObject1, self.object2 ]\n                 andSQL:@\"UPDATE testTable SET content = ?1 WHERE identifier > 0 ORDER BY identifier DESC LIMIT 1 OFFSET 1\"\n      afterModification:^BOOL {\n          return [[self.database getHandle] updateTable:self.tableName setProperties:TestCaseObject.content toObject:self.renewObject where:TestCaseObject.identifier > 0 orders:TestCaseObject.identifier.asOrder(WCTOrderedDescending) limit:1 offset:1];\n      }];\n}\n\n#pragma mark - Handle - Update Properties To Row\n- (void)test_handle_update_table_set_properties_to_row\n{\n    [self doTestObjects:@[ self.renewedObject1, self.renewedObject2 ]\n                 andSQL:@\"UPDATE testTable SET content = ?1\"\n      afterModification:^BOOL {\n          return [[self.database getHandle] updateTable:self.tableName setProperties:TestCaseObject.content toRow:self.renewRow];\n      }];\n}\n\n- (void)test_handle_update_table_set_properties_to_row_where\n{\n    [self doTestObjects:@[ self.renewedObject1, self.object2 ]\n                 andSQL:@\"UPDATE testTable SET content = ?1 WHERE identifier == 1\"\n      afterModification:^BOOL {\n          return [[self.database getHandle] updateTable:self.tableName setProperties:TestCaseObject.content toRow:self.renewRow where:TestCaseObject.identifier == 1];\n      }];\n}\n\n- (void)test_handle_update_table_set_properties_to_row_limit\n{\n    [self doTestObjects:@[ self.renewedObject1, self.object2 ]\n                 andSQL:@\"UPDATE testTable SET content = ?1 LIMIT 1\"\n      afterModification:^BOOL {\n          return [[self.database getHandle] updateTable:self.tableName setProperties:TestCaseObject.content toRow:self.renewRow limit:1];\n      }];\n}\n\n- (void)test_handle_update_table_set_properties_to_row_where_limit\n{\n    [self doTestObjects:@[ self.renewedObject1, self.object2 ]\n                 andSQL:@\"UPDATE testTable SET content = ?1 WHERE identifier == 1 LIMIT 1\"\n      afterModification:^BOOL {\n          return [[self.database getHandle] updateTable:self.tableName setProperties:TestCaseObject.content toRow:self.renewRow where:TestCaseObject.identifier == 1 limit:1];\n      }];\n}\n\n- (void)test_handle_update_table_set_properties_to_row_orders_limit\n{\n    [self doTestObjects:@[ self.object1, self.renewedObject2 ]\n                 andSQL:@\"UPDATE testTable SET content = ?1 ORDER BY identifier DESC LIMIT 1\"\n      afterModification:^BOOL {\n          return [[self.database getHandle] updateTable:self.tableName setProperties:TestCaseObject.content toRow:self.renewRow orders:TestCaseObject.identifier.asOrder(WCTOrderedDescending) limit:1];\n      }];\n}\n\n- (void)test_handle_update_table_set_properties_to_row_limit_offset\n{\n    [self doTestObjects:@[ self.object1, self.renewedObject2 ]\n                 andSQL:@\"UPDATE testTable SET content = ?1 LIMIT 1 OFFSET 1\"\n      afterModification:^BOOL {\n          return [[self.database getHandle] updateTable:self.tableName setProperties:TestCaseObject.content toRow:self.renewRow limit:1 offset:1];\n      }];\n}\n\n- (void)test_handle_update_table_set_properties_to_row_where_orders_limit\n{\n    [self doTestObjects:@[ self.object1, self.renewedObject2 ]\n                 andSQL:@\"UPDATE testTable SET content = ?1 WHERE identifier > 0 ORDER BY identifier DESC LIMIT 1\"\n      afterModification:^BOOL {\n          return [[self.database getHandle] updateTable:self.tableName setProperties:TestCaseObject.content toRow:self.renewRow where:TestCaseObject.identifier > 0 orders:TestCaseObject.identifier.asOrder(WCTOrderedDescending) limit:1];\n      }];\n}\n\n- (void)test_handle_update_table_set_properties_to_row_where_limit_offset\n{\n    [self doTestObjects:@[ self.object1, self.renewedObject2 ]\n                 andSQL:@\"UPDATE testTable SET content = ?1 WHERE identifier > 0 LIMIT 1 OFFSET 1\"\n      afterModification:^BOOL {\n          return [[self.database getHandle] updateTable:self.tableName setProperties:TestCaseObject.content toRow:self.renewRow where:TestCaseObject.identifier > 0 limit:1 offset:1];\n      }];\n}\n\n- (void)test_handle_update_table_set_properties_to_row_orders_limit_offset\n{\n    [self doTestObjects:@[ self.renewedObject1, self.object2 ]\n                 andSQL:@\"UPDATE testTable SET content = ?1 ORDER BY identifier DESC LIMIT 1 OFFSET 1\"\n      afterModification:^BOOL {\n          return [[self.database getHandle] updateTable:self.tableName setProperties:TestCaseObject.content toRow:self.renewRow orders:TestCaseObject.identifier.asOrder(WCTOrderedDescending) limit:1 offset:1];\n      }];\n}\n\n- (void)test_handle_update_table_set_properties_to_row_where_orders_limit_offset\n{\n    [self doTestObjects:@[ self.renewedObject1, self.object2 ]\n                 andSQL:@\"UPDATE testTable SET content = ?1 WHERE identifier > 0 ORDER BY identifier DESC LIMIT 1 OFFSET 1\"\n      afterModification:^BOOL {\n          return [[self.database getHandle] updateTable:self.tableName setProperties:TestCaseObject.content toRow:self.renewRow where:TestCaseObject.identifier > 0 orders:TestCaseObject.identifier.asOrder(WCTOrderedDescending) limit:1 offset:1];\n      }];\n}\n\n#pragma mark - Handle - Update Property To Value\n- (void)test_handle_update_table_set_property_to_value\n{\n    [self doTestObjects:@[ self.renewedObject1, self.renewedObject2 ]\n                 andSQL:@\"UPDATE testTable SET content = ?1\"\n      afterModification:^BOOL {\n          return [[self.database getHandle] updateTable:self.tableName setProperty:TestCaseObject.content toValue:self.renewValue];\n      }];\n}\n\n- (void)test_handle_update_table_set_property_to_value_where\n{\n    [self doTestObjects:@[ self.renewedObject1, self.object2 ]\n                 andSQL:@\"UPDATE testTable SET content = ?1 WHERE identifier == 1\"\n      afterModification:^BOOL {\n          return [[self.database getHandle] updateTable:self.tableName setProperty:TestCaseObject.content toValue:self.renewValue where:TestCaseObject.identifier == 1];\n      }];\n}\n\n- (void)test_handle_update_table_set_property_to_value_limit\n{\n    [self doTestObjects:@[ self.renewedObject1, self.object2 ]\n                 andSQL:@\"UPDATE testTable SET content = ?1 LIMIT 1\"\n      afterModification:^BOOL {\n          return [[self.database getHandle] updateTable:self.tableName setProperty:TestCaseObject.content toValue:self.renewValue limit:1];\n      }];\n}\n\n- (void)test_handle_update_table_set_property_to_value_where_limit\n{\n    [self doTestObjects:@[ self.renewedObject1, self.object2 ]\n                 andSQL:@\"UPDATE testTable SET content = ?1 WHERE identifier == 1 LIMIT 1\"\n      afterModification:^BOOL {\n          return [[self.database getHandle] updateTable:self.tableName setProperty:TestCaseObject.content toValue:self.renewValue where:TestCaseObject.identifier == 1 limit:1];\n      }];\n}\n\n- (void)test_handle_update_table_set_property_to_value_orders_limit\n{\n    [self doTestObjects:@[ self.object1, self.renewedObject2 ]\n                 andSQL:@\"UPDATE testTable SET content = ?1 ORDER BY identifier DESC LIMIT 1\"\n      afterModification:^BOOL {\n          return [[self.database getHandle] updateTable:self.tableName setProperty:TestCaseObject.content toValue:self.renewValue orders:TestCaseObject.identifier.asOrder(WCTOrderedDescending) limit:1];\n      }];\n}\n\n- (void)test_handle_update_table_set_property_to_value_limit_offset\n{\n    [self doTestObjects:@[ self.object1, self.renewedObject2 ]\n                 andSQL:@\"UPDATE testTable SET content = ?1 LIMIT 1 OFFSET 1\"\n      afterModification:^BOOL {\n          return [[self.database getHandle] updateTable:self.tableName setProperty:TestCaseObject.content toValue:self.renewValue limit:1 offset:1];\n      }];\n}\n\n- (void)test_handle_update_table_set_property_to_value_where_orders_limit\n{\n    [self doTestObjects:@[ self.object1, self.renewedObject2 ]\n                 andSQL:@\"UPDATE testTable SET content = ?1 WHERE identifier > 0 ORDER BY identifier DESC LIMIT 1\"\n      afterModification:^BOOL {\n          return [[self.database getHandle] updateTable:self.tableName setProperty:TestCaseObject.content toValue:self.renewValue where:TestCaseObject.identifier > 0 orders:TestCaseObject.identifier.asOrder(WCTOrderedDescending) limit:1];\n      }];\n}\n\n- (void)test_handle_update_table_set_property_to_value_where_limit_offset\n{\n    [self doTestObjects:@[ self.object1, self.renewedObject2 ]\n                 andSQL:@\"UPDATE testTable SET content = ?1 WHERE identifier > 0 LIMIT 1 OFFSET 1\"\n      afterModification:^BOOL {\n          return [[self.database getHandle] updateTable:self.tableName setProperty:TestCaseObject.content toValue:self.renewValue where:TestCaseObject.identifier > 0 limit:1 offset:1];\n      }];\n}\n\n- (void)test_handle_update_table_set_property_to_value_orders_limit_offset\n{\n    [self doTestObjects:@[ self.renewedObject1, self.object2 ]\n                 andSQL:@\"UPDATE testTable SET content = ?1 ORDER BY identifier DESC LIMIT 1 OFFSET 1\"\n      afterModification:^BOOL {\n          return [[self.database getHandle] updateTable:self.tableName setProperty:TestCaseObject.content toValue:self.renewValue orders:TestCaseObject.identifier.asOrder(WCTOrderedDescending) limit:1 offset:1];\n      }];\n}\n\n- (void)test_handle_update_table_set_property_to_value_where_orders_limit_offset\n{\n    [self doTestObjects:@[ self.renewedObject1, self.object2 ]\n                 andSQL:@\"UPDATE testTable SET content = ?1 WHERE identifier > 0 ORDER BY identifier DESC LIMIT 1 OFFSET 1\"\n      afterModification:^BOOL {\n          return [[self.database getHandle] updateTable:self.tableName setProperty:TestCaseObject.content toValue:self.renewValue where:TestCaseObject.identifier > 0 orders:TestCaseObject.identifier.asOrder(WCTOrderedDescending) limit:1 offset:1];\n      }];\n}\n\n@end\n"
  },
  {
    "path": "src/objc/tests/fts/FTS3Object+WCTTableCoding.h",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"FTS3Object.h\"\n#if TEST_WCDB_OBJC\n#import <WCDBOBjc/WCDBObjc.h>\n#elif TEST_WCDB_CPP\n#import <WCDBCpp/WCDBCpp.h>\n#else\n#import <WCDB/WCDBObjc.h>\n#endif\n\n@interface FTS3Object (WCTTableCoding) <WCTTableCoding>\n\nWCDB_PROPERTY(content)\nWCDB_PROPERTY(extension)\n\n@end\n"
  },
  {
    "path": "src/objc/tests/fts/FTS3Object.h",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import <Foundation/Foundation.h>\n#if TEST_WCDB_OBJC\n#import <WCDBOBjc/WCDBObjc.h>\n#elif TEST_WCDB_CPP\n#import <WCDBCpp/WCDBCpp.h>\n#else\n#import <WCDB/WCDBObjc.h>\n#endif\n\n@interface FTS3Object : NSObject\n\n@property (nonatomic, retain) NSString *content;\n@property (nonatomic, retain) NSString *extension;\n\n@end\n\n@interface FTS3SymbolObject : NSObject <WCTTableCoding>\n\n@property (nonatomic, retain) NSString *content;\nWCDB_PROPERTY(content)\n\n@end\n"
  },
  {
    "path": "src/objc/tests/fts/FTS3Object.mm",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"FTS3Object.h\"\n#import \"FTS3Object+WCTTableCoding.h\"\n#import \"TestCase.h\"\n#if TEST_WCDB_OBJC\n#import <WCDBOBjc/WCDBObjc.h>\n#elif TEST_WCDB_CPP\n#import <WCDBCpp/WCDBCpp.h>\n#else\n#import <WCDB/WCDBObjc.h>\n#endif\n\n@implementation FTS3Object\n\nWCDB_IMPLEMENTATION(FTS3Object)\nWCDB_SYNTHESIZE(content)\nWCDB_SYNTHESIZE(extension)\n\nWCDB_VIRTUAL_TABLE_MODULE(WCTModuleFTS3)\nWCDB_VIRTUAL_TABLE_TOKENIZE_WITH_PARAMETERS(WCTTokenizerOneOrBinary, WCTTokenizerParameter_SimplifyChinese)\n\n- (BOOL)isEqual:(NSObject*)object\n{\n    if (object.class != self.class) {\n        return NO;\n    }\n    FTS3Object* other = (FTS3Object*) object;\n    return [NSObject isObject:self.content nilEqualToObject:other.content] && [NSObject isObject:self.extension nilEqualToObject:other.extension];\n}\n\n@end\n\n@implementation FTS3SymbolObject\n\nWCDB_IMPLEMENTATION(FTS3SymbolObject)\nWCDB_SYNTHESIZE(content)\n\nWCDB_VIRTUAL_TABLE_MODULE(WCTModuleFTS3)\nWCDB_VIRTUAL_TABLE_TOKENIZE_WITH_PARAMETERS(WCTTokenizerOneOrBinary, WCTTokenizerParameter_NeedSymbol)\n\n- (BOOL)isEqual:(NSObject*)object\n{\n    if (object.class != self.class) {\n        return NO;\n    }\n    FTS3SymbolObject* other = (FTS3SymbolObject*) object;\n    return [NSObject isObject:self.content nilEqualToObject:other.content];\n}\n\n@end\n"
  },
  {
    "path": "src/objc/tests/fts/FTS3Tests.mm",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"FTS3Object+WCTTableCoding.h\"\n#import \"FTS3Object.h\"\n#import \"TestCase.h\"\n\n@interface FTS3Tests : TableTestCase\n\n@end\n\n@implementation FTS3Tests\n\n- (void)setUp\n{\n    [super setUp];\n    self.expectMode = DatabaseTestCaseExpectFirstFewSQLs;\n    self.tableClass = FTS3Object.class;\n    self.isVirtualTable = YES;\n    [self.database addTokenizer:WCTTokenizerOneOrBinary];\n    [WCTDatabase configTraditionalChineseDict:@{\n        @\"們\" : @\"们\",\n        @\"員\" : @\"员\",\n    }];\n    TestCaseAssertTrue([self createTable]);\n\n    FTS3Object *dummy = [[FTS3Object alloc] init];\n    dummy.content = @\"dummy content\";\n    dummy.extension = @\"dummy extension\";\n    TestCaseAssertTrue([self.table insertObject:dummy]);\n}\n\n- (void)test_chinese\n{\n    FTS3Object *object = [[FTS3Object alloc] init];\n    object.content = @\"苹果树\";\n    TestCaseAssertTrue([self.table insertObject:object]);\n\n    [self doTestObject:object\n                andSQL:@\"SELECT content, extension FROM testTable WHERE content MATCH '苹' ORDER BY rowid ASC\"\n           bySelecting:^NSArray<NSObject<WCTTableCoding> *> * {\n               return [self.table getObjectsWhere:FTS3Object.content.match(\"苹\")];\n           }];\n    [self doTestObject:object\n                andSQL:@\"SELECT content, extension FROM testTable WHERE content MATCH '苹果' ORDER BY rowid ASC\"\n           bySelecting:^NSArray<NSObject<WCTTableCoding> *> * {\n               return [self.table getObjectsWhere:FTS3Object.content.match(\"苹果\")];\n           }];\n    [self doTestObject:object\n                andSQL:@\"SELECT content, extension FROM testTable WHERE content MATCH '苹果树' ORDER BY rowid ASC\"\n           bySelecting:^NSArray<NSObject<WCTTableCoding> *> * {\n               return [self.table getObjectsWhere:FTS3Object.content.match(\"苹果树\")];\n           }];\n    [self doTestObject:object\n                andSQL:@\"SELECT content, extension FROM testTable WHERE content MATCH '果树' ORDER BY rowid ASC\"\n           bySelecting:^NSArray<NSObject<WCTTableCoding> *> * {\n               return [self.table getObjectsWhere:FTS3Object.content.match(\"果树\")];\n           }];\n    [self doTestObject:object\n                andSQL:@\"SELECT content, extension FROM testTable WHERE content MATCH '树' ORDER BY rowid ASC\"\n           bySelecting:^NSArray<NSObject<WCTTableCoding> *> * {\n               return [self.table getObjectsWhere:FTS3Object.content.match(\"树\")];\n           }];\n}\n\n- (void)test_traditional_chinese\n{\n    FTS3Object *object = [[FTS3Object alloc] init];\n    object.content = @\"我們是程序員\";\n    TestCaseAssertTrue([self.table insertObject:object]);\n    [self doTestObject:object\n                andSQL:@\"SELECT content, extension FROM testTable WHERE content MATCH '我們是程序員' ORDER BY rowid ASC\"\n           bySelecting:^NSArray<NSObject<WCTTableCoding> *> * {\n               return [self.table getObjectsWhere:FTS3Object.content.match(\"我們是程序員\")];\n           }];\n    [self doTestObject:object\n                andSQL:@\"SELECT content, extension FROM testTable WHERE content MATCH '我们是程序员' ORDER BY rowid ASC\"\n           bySelecting:^NSArray<NSObject<WCTTableCoding> *> * {\n               return [self.table getObjectsWhere:FTS3Object.content.match(\"我们是程序员\")];\n           }];\n}\n\n- (void)test_english\n{\n    FTS3Object *object = [[FTS3Object alloc] init];\n    object.content = @\"WCDB is a cross-platform database framework developed by WeChat.\";\n    TestCaseAssertTrue([self.table insertObject:object]);\n\n    [self doTestObject:object\n                andSQL:@\"SELECT content, extension FROM testTable WHERE content MATCH 'WCDB' ORDER BY rowid ASC\"\n           bySelecting:^NSArray<NSObject<WCTTableCoding> *> * {\n               return [self.table getObjectsWhere:FTS3Object.content.match(\"WCDB\")];\n           }];\n    [self doTestObject:object\n                andSQL:@\"SELECT content, extension FROM testTable WHERE content MATCH 'WeChat' ORDER BY rowid ASC\"\n           bySelecting:^NSArray<NSObject<WCTTableCoding> *> * {\n               return [self.table getObjectsWhere:FTS3Object.content.match(\"WeChat\")];\n           }];\n\n    // case insensitive\n    [self doTestObject:object\n                andSQL:@\"SELECT content, extension FROM testTable WHERE content MATCH 'DATABASE' ORDER BY rowid ASC\"\n           bySelecting:^NSArray<NSObject<WCTTableCoding> *> * {\n               return [self.table getObjectsWhere:FTS3Object.content.match(\"DATABASE\")];\n           }];\n\n    // stemming\n    [self doTestObject:object\n                andSQL:@\"SELECT content, extension FROM testTable WHERE content MATCH 'developer' ORDER BY rowid ASC\"\n           bySelecting:^NSArray<NSObject<WCTTableCoding> *> * {\n               return [self.table getObjectsWhere:FTS3Object.content.match(\"developer\")];\n           }];\n\n    // prefix\n    [self doTestObject:object\n                andSQL:@\"SELECT content, extension FROM testTable WHERE content MATCH 'plat*' ORDER BY rowid ASC\"\n           bySelecting:^NSArray<NSObject<WCTTableCoding> *> * {\n               return [self.table getObjectsWhere:FTS3Object.content.match(\"plat*\")];\n           }];\n\n    // phrase\n    [self doTestObject:object\n                andSQL:@\"SELECT content, extension FROM testTable WHERE content MATCH 'dat* fram*' ORDER BY rowid ASC\"\n           bySelecting:^NSArray<NSObject<WCTTableCoding> *> * {\n               return [self.table getObjectsWhere:FTS3Object.content.match(\"dat* fram*\")];\n           }];\n\n    // bad case\n    [self doTestObjects:@[]\n                 andSQL:@\"SELECT content, extension FROM testTable WHERE content MATCH 'Hello' ORDER BY rowid ASC\"\n            bySelecting:^NSArray<NSObject<WCTTableCoding> *> * {\n                return [self.table getObjectsWhere:FTS3Object.content.match(\"Hello\")];\n            }];\n}\n\n- (void)test_number\n{\n    FTS3Object *object = [[FTS3Object alloc] init];\n    object.content = @\"123 456 789\";\n    TestCaseAssertTrue([self.table insertObject:object]);\n\n    [self doTestObject:object\n                andSQL:@\"SELECT content, extension FROM testTable WHERE content MATCH '123' ORDER BY rowid ASC\"\n           bySelecting:^NSArray<NSObject<WCTTableCoding> *> * {\n               return [self.table getObjectsWhere:FTS3Object.content.match(\"123\")];\n           }];\n    [self doTestObject:object\n                andSQL:@\"SELECT content, extension FROM testTable WHERE content MATCH '456' ORDER BY rowid ASC\"\n           bySelecting:^NSArray<NSObject<WCTTableCoding> *> * {\n               return [self.table getObjectsWhere:FTS3Object.content.match(\"456\")];\n           }];\n    [self doTestObject:object\n                andSQL:@\"SELECT content, extension FROM testTable WHERE content MATCH '789' ORDER BY rowid ASC\"\n           bySelecting:^NSArray<NSObject<WCTTableCoding> *> * {\n               return [self.table getObjectsWhere:FTS3Object.content.match(\"789\")];\n           }];\n\n    // bad case\n    [self doTestObjects:@[]\n                 andSQL:@\"SELECT content, extension FROM testTable WHERE content MATCH '567' ORDER BY rowid ASC\"\n            bySelecting:^NSArray<NSObject<WCTTableCoding> *> * {\n                return [self.table getObjectsWhere:FTS3Object.content.match(\"567\")];\n            }];\n}\n\n- (void)test_mixed\n{\n    FTS3Object *object = [[FTS3Object alloc] init];\n    object.content = @\"中文English日本語123\";\n    TestCaseAssertTrue([self.table insertObject:object]);\n\n    [self doTestObject:object\n                andSQL:@\"SELECT content, extension FROM testTable WHERE content MATCH '中' ORDER BY rowid ASC\"\n           bySelecting:^NSArray<NSObject<WCTTableCoding> *> * {\n               return [self.table getObjectsWhere:FTS3Object.content.match(\"中\")];\n           }];\n    [self doTestObject:object\n                andSQL:@\"SELECT content, extension FROM testTable WHERE content MATCH 'English' ORDER BY rowid ASC\"\n           bySelecting:^NSArray<NSObject<WCTTableCoding> *> * {\n               return [self.table getObjectsWhere:FTS3Object.content.match(\"English\")];\n           }];\n    [self doTestObject:object\n                andSQL:@\"SELECT content, extension FROM testTable WHERE content MATCH '語' ORDER BY rowid ASC\"\n           bySelecting:^NSArray<NSObject<WCTTableCoding> *> * {\n               return [self.table getObjectsWhere:FTS3Object.content.match(\"語\")];\n           }];\n    [self doTestObject:object\n                andSQL:@\"SELECT content, extension FROM testTable WHERE content MATCH '123' ORDER BY rowid ASC\"\n           bySelecting:^NSArray<NSObject<WCTTableCoding> *> * {\n               return [self.table getObjectsWhere:FTS3Object.content.match(\"123\")];\n           }];\n}\n\n- (void)test_column_match\n{\n    FTS3Object *content = [[FTS3Object alloc] init];\n    content.content = @\"error_prone\";\n    TestCaseAssertTrue([self.table insertObject:content]);\n\n    FTS3Object *extension = [[FTS3Object alloc] init];\n    extension.extension = @\"error_prone\";\n    TestCaseAssertTrue([self.table insertObject:extension]);\n\n    [self doTestObject:content\n                andSQL:@\"SELECT content, extension FROM testTable WHERE content MATCH 'error_prone' ORDER BY rowid ASC\"\n           bySelecting:^NSArray<NSObject<WCTTableCoding> *> * {\n               return [self.table getObjectsWhere:FTS3Object.content.match(\"error_prone\")];\n           }];\n    [self doTestObject:extension\n                andSQL:@\"SELECT content, extension FROM testTable WHERE extension MATCH 'error_prone' ORDER BY rowid ASC\"\n           bySelecting:^NSArray<NSObject<WCTTableCoding> *> * {\n               return [self.table getObjectsWhere:FTS3Object.extension.match(\"error_prone\")];\n           }];\n    [self doTestObjects:@[ content, extension ]\n                 andSQL:@\"SELECT content, extension FROM testTable WHERE testTable MATCH 'error_prone' ORDER BY rowid ASC\"\n            bySelecting:^NSArray<NSObject<WCTTableCoding> *> * {\n                return [self.table getObjectsWhere:WCDB::Column(self.tableName).match(\"error_prone\")];\n            }];\n    [self doTestObject:content\n                andSQL:@\"SELECT content, extension FROM testTable WHERE testTable MATCH 'content: error_prone' ORDER BY rowid ASC\"\n           bySelecting:^NSArray<NSObject<WCTTableCoding> *> * {\n               return [self.table getObjectsWhere:WCDB::Column(self.tableName).match(\"content: error_prone\")];\n           }];\n    [self doTestObject:extension\n                andSQL:@\"SELECT content, extension FROM testTable WHERE testTable MATCH 'extension: error_prone' ORDER BY rowid ASC\"\n           bySelecting:^NSArray<NSObject<WCTTableCoding> *> * {\n               return [self.table getObjectsWhere:WCDB::Column(self.tableName).match(\"extension: error_prone\")];\n           }];\n}\n\n- (void)test_near_query\n{\n    FTS3Object *objectWithOneGaps = [[FTS3Object alloc] init];\n    objectWithOneGaps.content = @\"Cowherd one WeaverGirl\";\n    TestCaseAssertTrue([self.table insertObject:objectWithOneGaps]);\n\n    FTS3Object *objectWithTenGaps = [[FTS3Object alloc] init];\n    objectWithTenGaps.content = @\"Cowherd one two three four five six seven eight nine ten WeaverGirl\";\n    TestCaseAssertTrue([self.table insertObject:objectWithTenGaps]);\n\n    FTS3Object *objectWithEleventGaps = [[FTS3Object alloc] init];\n    objectWithEleventGaps.content = @\"Cowherd one two three four five six seven eight nine ten eleven WeaverGirl\";\n    TestCaseAssertTrue([self.table insertObject:objectWithEleventGaps]);\n\n    [self doTestObject:objectWithOneGaps\n                andSQL:@\"SELECT content, extension FROM testTable WHERE content MATCH 'Cowherd NEAR/1 WeaverGirl' ORDER BY rowid ASC\"\n           bySelecting:^NSArray<NSObject<WCTTableCoding> *> * {\n               return [self.table getObjectsWhere:FTS3Object.content.match(\"Cowherd NEAR/1 WeaverGirl\")];\n           }];\n    [self doTestObjects:@[ objectWithOneGaps, objectWithTenGaps ]\n                 andSQL:@\"SELECT content, extension FROM testTable WHERE content MATCH 'Cowherd NEAR/10 WeaverGirl' ORDER BY rowid ASC\"\n            bySelecting:^NSArray<NSObject<WCTTableCoding> *> * {\n                return [self.table getObjectsWhere:FTS3Object.content.match(\"Cowherd NEAR/10 WeaverGirl\")];\n            }];\n    [self doTestObjects:@[ objectWithOneGaps, objectWithTenGaps, objectWithEleventGaps ]\n                 andSQL:@\"SELECT content, extension FROM testTable WHERE content MATCH 'Cowherd NEAR/11 WeaverGirl' ORDER BY rowid ASC\"\n            bySelecting:^NSArray<NSObject<WCTTableCoding> *> * {\n                return [self.table getObjectsWhere:FTS3Object.content.match(\"Cowherd NEAR/11 WeaverGirl\")];\n            }];\n\n    // default behaviours\n    [self doTestObjects:@[ objectWithOneGaps, objectWithTenGaps ]\n                 andSQL:@\"SELECT content, extension FROM testTable WHERE content MATCH 'Cowherd NEAR WeaverGirl' ORDER BY rowid ASC\"\n            bySelecting:^NSArray<NSObject<WCTTableCoding> *> * {\n                return [self.table getObjectsWhere:FTS3Object.content.match(\"Cowherd NEAR WeaverGirl\")];\n            }];\n}\n\n- (void)test_operator\n{\n    FTS3Object *ab = [[FTS3Object alloc] init];\n    ab.content = @\"a b\";\n    TestCaseAssertTrue([self.table insertObject:ab]);\n\n    FTS3Object *bc = [[FTS3Object alloc] init];\n    bc.content = @\"b c\";\n    TestCaseAssertTrue([self.table insertObject:bc]);\n\n    FTS3Object *cd = [[FTS3Object alloc] init];\n    cd.content = @\"c d\";\n    TestCaseAssertTrue([self.table insertObject:cd]);\n\n    [self doTestObject:bc\n                andSQL:@\"SELECT content, extension FROM testTable WHERE content MATCH 'b AND c' ORDER BY rowid ASC\"\n           bySelecting:^NSArray<NSObject<WCTTableCoding> *> * {\n               return [self.table getObjectsWhere:FTS3Object.content.match(\"b AND c\")];\n           }];\n    [self doTestObjects:@[ ab, bc, cd ]\n                 andSQL:@\"SELECT content, extension FROM testTable WHERE content MATCH 'b OR c' ORDER BY rowid ASC\"\n            bySelecting:^NSArray<NSObject<WCTTableCoding> *> * {\n                return [self.table getObjectsWhere:FTS3Object.content.match(\"b OR c\")];\n            }];\n    [self doTestObject:ab\n                andSQL:@\"SELECT content, extension FROM testTable WHERE content MATCH 'b NOT c' ORDER BY rowid ASC\"\n           bySelecting:^NSArray<NSObject<WCTTableCoding> *> * {\n               return [self.table getObjectsWhere:FTS3Object.content.match(\"b NOT c\")];\n           }];\n}\n\n- (void)test_offsets\n{\n    FTS3Object *object = [[FTS3Object alloc] init];\n    object.content = @\"one two three four\";\n    object.extension = @\"five six seven eight nine ten\";\n    TestCaseAssertTrue([self.table insertObject:object]);\n\n    // The return value of [offsets] is grouped by every four numbers.\n    // 1. The serial number of matched column in the table\n    // 2. The serial number of matching term in the query\n    // 3. The byte offset of matched term\n    // 4. The byte length of matched term\n    // In conclusion, every group show that the word at offset [3.] length [4.] in the column [1.] is matching the query [2.].\n\n    // Note that offsets interface is not recommended since the column order may be undefined due to ORM.\n\n    [self doTestValue:\n          @\"0 1 4 3 \"  // The word at offset 4 length 3 in the column [content] is matching the query [t*], which is \"two\".\n           \"0 1 8 5 \"  // The word at offset 8 length 5 in the column [content] is matching the query [t*], which is \"three\".\n           \"0 0 14 4 \" // The word at offset 14 length 4 in the column [content] is matching the query [f*], which is \"four\".\n           \"1 0 0 4 \"  // The word at offset 0 length 4 in the column [extension] is matching the query [f*], which is \"five\".\n           \"1 1 26 3\"  // The word at offset 26 length 3 in the column [extension] is matching the query [t*], which is \"ten\".\n               andSQL:@\"SELECT offsets(testTable) FROM testTable WHERE testTable MATCH 'f* t*' ORDER BY rowid ASC\"\n          bySelecting:^WCTValue * {\n              WCDB::Column tableColumn(self.tableName);\n              return [self.database getValueFromStatement:WCDB::StatementSelect().select(tableColumn.offsets()).from(self.tableName).where(tableColumn.match(@\"f* t*\")).order(WCDB::OrderingTerm::ascendingRowid())];\n          }];\n}\n\n- (void)test_snippet\n{\n    FTS3Object *easyToUse = [[FTS3Object alloc] init];\n    easyToUse.content = @\"Easy-to-use\";\n    easyToUse.extension = @\"Through WCDB, you can get objects from database in one line code.\";\n    TestCaseAssertTrue([self.table insertObject:easyToUse]);\n\n    FTS3Object *efficient = [[FTS3Object alloc] init];\n    efficient.content = @\"Efficient\";\n    efficient.extension = @\"Through the framework layer and sqlcipher source optimization, WCDB have more efficient performance.\";\n    TestCaseAssertTrue([self.table insertObject:efficient]);\n\n    FTS3Object *complete = [[FTS3Object alloc] init];\n    complete.content = @\"Complete\";\n    complete.extension = @\"Encryption Support, Corruption recovery, Anti-injection.\";\n    TestCaseAssertTrue([self.table insertObject:complete]);\n\n    [self doTestColumn:@[ @\"...WCDB have more /* efficient */ performance.\",\n                          @\"/* Encryption */ Support, Corruption recovery, Anti...\" ]\n                andSQL:@\"SELECT snippet(testTable, '/* ', ' */', '...', -1, 5) FROM testTable WHERE extension MATCH 'e*' ORDER BY rowid ASC\"\n           bySelecting:^WCTOneColumn * {\n               const char *startMatchText = \"/* \";\n               const char *endMatchText = \" */\";\n               const char *ellipses = \"...\";\n               int columnNumber = -1;\n               int approximateNumberOfTokens = 5;\n               return [self.database getColumnFromStatement:WCDB::StatementSelect().select(WCDB::Column(self.tableName).fts3Snippet(startMatchText, endMatchText, ellipses, columnNumber, approximateNumberOfTokens)).from(self.tableName).where(FTS3Object.extension.match(\"e*\")).order(WCDB::OrderingTerm::ascendingRowid())];\n           }];\n}\n\n@end\n\n@interface FTS3SymbolTests : TableTestCase\n\n@end\n\n@implementation FTS3SymbolTests\n\n- (void)setUp\n{\n    [super setUp];\n    self.expectMode = DatabaseTestCaseExpectFirstFewSQLs;\n    self.tableClass = FTS3SymbolObject.class;\n    self.isVirtualTable = YES;\n    [self.database addTokenizer:WCTTokenizerOneOrBinary];\n    TestCaseAssertTrue([self createTable]);\n\n    FTS3SymbolObject *dummy = [[FTS3SymbolObject alloc] init];\n    dummy.content = @\"!@#$%^&*(()))_+\";\n    TestCaseAssertTrue([self.table insertObject:dummy]);\n}\n\n- (void)test_symbol\n{\n    FTS3SymbolObject *content = [[FTS3SymbolObject alloc] init];\n    content.content = @\"#￥%…'  '！@…&*\";\n    TestCaseAssertTrue([self.table insertObject:content]);\n    content = [[FTS3SymbolObject alloc] init];\n    content.content = @\"！@…&*'  '\\\"#￥%…\";\n    TestCaseAssertTrue([self.table insertObject:content]);\n    NSArray *querys = @[ @\"！@…&*'  '\\\"\\\"#￥%…\", @\"！@…&*'  '\\\"\\\"\" ];\n    for (NSString *query in querys) {\n        [self doTestObject:content\n                    andSQL:[NSString stringWithFormat:@\"SELECT content FROM testTable WHERE content MATCH '%@' ORDER BY rowid ASC\", [query stringByReplacingOccurrencesOfString:@\"'\" withString:@\"''\"]]\n               bySelecting:^NSArray<NSObject<WCTTableCoding> *> * {\n                   return [self.table getObjectsWhere:FTS3SymbolObject.content.match(query)];\n               }];\n    }\n\n    content = [[FTS3SymbolObject alloc] init];\n    content.content = @\"abc*123_@567\";\n    TestCaseAssertTrue([self.table insertObject:content]);\n    content = [[FTS3SymbolObject alloc] init];\n    content.content = @\"abc@123*def_567\";\n    TestCaseAssertTrue([self.table insertObject:content]);\n    querys = @[ @\"abc@123*def_567\", @\"abc@123*def\" ];\n    for (NSString *query in querys) {\n        [self doTestObject:content\n                    andSQL:[NSString stringWithFormat:@\"SELECT content FROM testTable WHERE content MATCH '%@' ORDER BY rowid ASC\", query]\n               bySelecting:^NSArray<NSObject<WCTTableCoding> *> * {\n                   return [self.table getObjectsWhere:FTS3SymbolObject.content.match(query)];\n               }];\n    }\n}\n\n@end\n"
  },
  {
    "path": "src/objc/tests/fts/FTS5Object.h",
    "content": "//\n// Created by qiuwenchen(qiuwenchen) on 2020/10/29.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#if TEST_WCDB_OBJC\n#import <WCDBOBjc/WCDBObjc.h>\n#elif TEST_WCDB_CPP\n#import <WCDBCpp/WCDBCpp.h>\n#else\n#import <WCDB/WCDBObjc.h>\n#endif\n\n@interface FTS5Object : NSObject <WCTTableCoding>\n\n@property (nonatomic, retain) NSString *content;\n@property (nonatomic, retain) NSString *extension;\nWCDB_PROPERTY(content)\nWCDB_PROPERTY(extension)\n\n@end\n\n@interface FTS5PinyinObject : NSObject <WCTTableCoding>\n\n@property (nonatomic, retain) NSString *content;\nWCDB_PROPERTY(content)\n\n@end\n\n@interface FTS5SymbolObject : NSObject <WCTTableCoding>\n\n@property (nonatomic, retain) NSString *content;\nWCDB_PROPERTY(content)\n\n@end\n"
  },
  {
    "path": "src/objc/tests/fts/FTS5Object.mm",
    "content": "//\n// Created by qiuwenchen(qiuwenchen) on 2020/10/29.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"FTS5Object.h\"\n#import \"TestCase.h\"\n#import <Foundation/Foundation.h>\n\n@implementation FTS5Object\n\nWCDB_IMPLEMENTATION(FTS5Object)\nWCDB_SYNTHESIZE(content)\nWCDB_SYNTHESIZE(extension)\n\nWCDB_VIRTUAL_TABLE_MODULE(WCTModuleFTS5)\nWCDB_VIRTUAL_TABLE_TOKENIZE_WITH_PARAMETERS(WCTTokenizerVerbatim, WCTTokenizerParameter_SimplifyChinese)\n\n- (BOOL)isEqual:(NSObject*)object\n{\n    if (object.class != self.class) {\n        return NO;\n    }\n    FTS5Object* other = (FTS5Object*) object;\n    return [NSObject isObject:self.content nilEqualToObject:other.content] && [NSObject isObject:self.extension nilEqualToObject:other.extension];\n}\n\n@end\n\n@implementation FTS5PinyinObject\n\nWCDB_IMPLEMENTATION(FTS5PinyinObject)\nWCDB_SYNTHESIZE(content)\n\nWCDB_VIRTUAL_TABLE_MODULE(WCTModuleFTS5)\nWCDB_VIRTUAL_TABLE_TOKENIZE(WCTTokenizerPinyin)\n\n- (BOOL)isEqual:(NSObject*)object\n{\n    if (object.class != self.class) {\n        return NO;\n    }\n    FTS5PinyinObject* other = (FTS5PinyinObject*) object;\n    return [NSObject isObject:self.content nilEqualToObject:other.content];\n}\n\n@end\n\n@implementation FTS5SymbolObject\n\nWCDB_IMPLEMENTATION(FTS5SymbolObject)\nWCDB_SYNTHESIZE(content)\n\nWCDB_VIRTUAL_TABLE_MODULE(WCTModuleFTS5)\nWCDB_VIRTUAL_TABLE_TOKENIZE_WITH_PARAMETERS(WCTTokenizerVerbatim, WCTTokenizerParameter_NeedSymbol)\n\n- (BOOL)isEqual:(NSObject*)object\n{\n    if (object.class != self.class) {\n        return NO;\n    }\n    FTS5SymbolObject* other = (FTS5SymbolObject*) object;\n    return [NSObject isObject:self.content nilEqualToObject:other.content];\n}\n\n@end\n"
  },
  {
    "path": "src/objc/tests/fts/FTS5Test.mm",
    "content": "//\n// Created by qiuwenchen(qiuwenchen) on 2020/10/29.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"FTS5Object.h\"\n#import \"TestCase.h\"\n#import <Foundation/Foundation.h>\n\n@interface FTS5Tests : TableTestCase\n\n@end\n\n@implementation FTS5Tests\n\n- (void)setUp\n{\n    [super setUp];\n    self.expectMode = DatabaseTestCaseExpectFirstFewSQLs;\n    self.tableClass = FTS5Object.class;\n    self.isVirtualTable = YES;\n    [self.database addTokenizer:WCTTokenizerVerbatim];\n    [WCTDatabase configTraditionalChineseDict:@{\n        @\"們\" : @\"们\",\n        @\"員\" : @\"员\",\n    }];\n    TestCaseAssertTrue([self createTable]);\n\n    FTS5Object *dummy = [[FTS5Object alloc] init];\n    dummy.content = @\"dummy content\";\n    dummy.extension = @\"dummy extension\";\n    TestCaseAssertTrue([self.table insertObject:dummy]);\n}\n\n- (void)test_chinese\n{\n    FTS5Object *object = [[FTS5Object alloc] init];\n    object.content = @\"苹果树\";\n    TestCaseAssertTrue([self.table insertObject:object]);\n\n    [self doTestObject:object\n                andSQL:@\"SELECT content, extension FROM testTable WHERE content MATCH '苹' ORDER BY rowid ASC\"\n           bySelecting:^NSArray<NSObject<WCTTableCoding> *> * {\n               return [self.table getObjectsWhere:FTS5Object.content.match(\"苹\")];\n           }];\n    [self doTestObject:object\n                andSQL:@\"SELECT content, extension FROM testTable WHERE content MATCH '苹果' ORDER BY rowid ASC\"\n           bySelecting:^NSArray<NSObject<WCTTableCoding> *> * {\n               return [self.table getObjectsWhere:FTS5Object.content.match(\"苹果\")];\n           }];\n    [self doTestObject:object\n                andSQL:@\"SELECT content, extension FROM testTable WHERE content MATCH '苹果树' ORDER BY rowid ASC\"\n           bySelecting:^NSArray<NSObject<WCTTableCoding> *> * {\n               return [self.table getObjectsWhere:FTS5Object.content.match(\"苹果树\")];\n           }];\n    [self doTestObject:object\n                andSQL:@\"SELECT content, extension FROM testTable WHERE content MATCH '果树' ORDER BY rowid ASC\"\n           bySelecting:^NSArray<NSObject<WCTTableCoding> *> * {\n               return [self.table getObjectsWhere:FTS5Object.content.match(\"果树\")];\n           }];\n    [self doTestObject:object\n                andSQL:@\"SELECT content, extension FROM testTable WHERE content MATCH '树' ORDER BY rowid ASC\"\n           bySelecting:^NSArray<NSObject<WCTTableCoding> *> * {\n               return [self.table getObjectsWhere:FTS5Object.content.match(\"树\")];\n           }];\n}\n\n- (void)test_traditional_chinese\n{\n    FTS5Object *object = [[FTS5Object alloc] init];\n    object.content = @\"我們是程序員\";\n    TestCaseAssertTrue([self.table insertObject:object]);\n    [self doTestObject:object\n                andSQL:@\"SELECT content, extension FROM testTable WHERE content MATCH '我们是程序员' ORDER BY rowid ASC\"\n           bySelecting:^NSArray<NSObject<WCTTableCoding> *> * {\n               return [self.table getObjectsWhere:FTS5Object.content.match(\"我们是程序员\")];\n           }];\n    [self doTestObject:object\n                andSQL:@\"SELECT content, extension FROM testTable WHERE content MATCH '我們是程序員' ORDER BY rowid ASC\"\n           bySelecting:^NSArray<NSObject<WCTTableCoding> *> * {\n               return [self.table getObjectsWhere:FTS5Object.content.match(\"我們是程序員\")];\n           }];\n}\n\n- (void)test_english\n{\n    FTS5Object *object = [[FTS5Object alloc] init];\n    object.content = @\"WCDB is a cross-platform database framework developed by WeChat.\";\n    TestCaseAssertTrue([self.table insertObject:object]);\n\n    [self doTestObject:object\n                andSQL:@\"SELECT content, extension FROM testTable WHERE content MATCH 'WCDB' ORDER BY rowid ASC\"\n           bySelecting:^NSArray<NSObject<WCTTableCoding> *> * {\n               return [self.table getObjectsWhere:FTS5Object.content.match(\"WCDB\")];\n           }];\n    [self doTestObject:object\n                andSQL:@\"SELECT content, extension FROM testTable WHERE content MATCH 'WeChat' ORDER BY rowid ASC\"\n           bySelecting:^NSArray<NSObject<WCTTableCoding> *> * {\n               return [self.table getObjectsWhere:FTS5Object.content.match(\"WeChat\")];\n           }];\n\n    // case insensitive\n    [self doTestObject:object\n                andSQL:@\"SELECT content, extension FROM testTable WHERE content MATCH 'DATABASE' ORDER BY rowid ASC\"\n           bySelecting:^NSArray<NSObject<WCTTableCoding> *> * {\n               return [self.table getObjectsWhere:FTS5Object.content.match(\"DATABASE\")];\n           }];\n\n    // stemming\n    [self doTestObject:object\n                andSQL:@\"SELECT content, extension FROM testTable WHERE content MATCH 'developer' ORDER BY rowid ASC\"\n           bySelecting:^NSArray<NSObject<WCTTableCoding> *> * {\n               return [self.table getObjectsWhere:FTS5Object.content.match(\"developer\")];\n           }];\n\n    // prefix\n    [self doTestObject:object\n                andSQL:@\"SELECT content, extension FROM testTable WHERE content MATCH 'plat*' ORDER BY rowid ASC\"\n           bySelecting:^NSArray<NSObject<WCTTableCoding> *> * {\n               return [self.table getObjectsWhere:FTS5Object.content.match(\"plat*\")];\n           }];\n\n    // phrase\n    [self doTestObject:object\n                andSQL:@\"SELECT content, extension FROM testTable WHERE content MATCH 'dat* fram*' ORDER BY rowid ASC\"\n           bySelecting:^NSArray<NSObject<WCTTableCoding> *> * {\n               return [self.table getObjectsWhere:FTS5Object.content.match(\"dat* fram*\")];\n           }];\n\n    // bad case\n    [self doTestObjects:@[]\n                 andSQL:@\"SELECT content, extension FROM testTable WHERE content MATCH 'Hello' ORDER BY rowid ASC\"\n            bySelecting:^NSArray<NSObject<WCTTableCoding> *> * {\n                return [self.table getObjectsWhere:FTS5Object.content.match(\"Hello\")];\n            }];\n}\n\n- (void)test_number\n{\n    FTS5Object *object = [[FTS5Object alloc] init];\n    object.content = @\"123 456 789\";\n    TestCaseAssertTrue([self.table insertObject:object]);\n\n    [self doTestObject:object\n                andSQL:@\"SELECT content, extension FROM testTable WHERE content MATCH '123' ORDER BY rowid ASC\"\n           bySelecting:^NSArray<NSObject<WCTTableCoding> *> * {\n               return [self.table getObjectsWhere:FTS5Object.content.match(\"123\")];\n           }];\n    [self doTestObject:object\n                andSQL:@\"SELECT content, extension FROM testTable WHERE content MATCH '456' ORDER BY rowid ASC\"\n           bySelecting:^NSArray<NSObject<WCTTableCoding> *> * {\n               return [self.table getObjectsWhere:FTS5Object.content.match(\"456\")];\n           }];\n    [self doTestObject:object\n                andSQL:@\"SELECT content, extension FROM testTable WHERE content MATCH '789' ORDER BY rowid ASC\"\n           bySelecting:^NSArray<NSObject<WCTTableCoding> *> * {\n               return [self.table getObjectsWhere:FTS5Object.content.match(\"789\")];\n           }];\n\n    // bad case\n    [self doTestObjects:@[]\n                 andSQL:@\"SELECT content, extension FROM testTable WHERE content MATCH '567' ORDER BY rowid ASC\"\n            bySelecting:^NSArray<NSObject<WCTTableCoding> *> * {\n                return [self.table getObjectsWhere:FTS5Object.content.match(\"567\")];\n            }];\n}\n\n- (void)test_mixed\n{\n    FTS5Object *object = [[FTS5Object alloc] init];\n    object.content = @\"中文English日本語123\";\n    TestCaseAssertTrue([self.table insertObject:object]);\n\n    [self doTestObject:object\n                andSQL:@\"SELECT content, extension FROM testTable WHERE content MATCH '中' ORDER BY rowid ASC\"\n           bySelecting:^NSArray<NSObject<WCTTableCoding> *> * {\n               return [self.table getObjectsWhere:FTS5Object.content.match(\"中\")];\n           }];\n    [self doTestObject:object\n                andSQL:@\"SELECT content, extension FROM testTable WHERE content MATCH 'English' ORDER BY rowid ASC\"\n           bySelecting:^NSArray<NSObject<WCTTableCoding> *> * {\n               return [self.table getObjectsWhere:FTS5Object.content.match(\"English\")];\n           }];\n    [self doTestObject:object\n                andSQL:@\"SELECT content, extension FROM testTable WHERE content MATCH '語' ORDER BY rowid ASC\"\n           bySelecting:^NSArray<NSObject<WCTTableCoding> *> * {\n               return [self.table getObjectsWhere:FTS5Object.content.match(\"語\")];\n           }];\n    [self doTestObject:object\n                andSQL:@\"SELECT content, extension FROM testTable WHERE content MATCH '123' ORDER BY rowid ASC\"\n           bySelecting:^NSArray<NSObject<WCTTableCoding> *> * {\n               return [self.table getObjectsWhere:FTS5Object.content.match(\"123\")];\n           }];\n}\n\n- (void)test_column_match\n{\n    FTS5Object *content = [[FTS5Object alloc] init];\n    content.content = @\"error_prone\";\n    TestCaseAssertTrue([self.table insertObject:content]);\n\n    FTS5Object *extension = [[FTS5Object alloc] init];\n    extension.extension = @\"error_prone\";\n    TestCaseAssertTrue([self.table insertObject:extension]);\n\n    [self doTestObject:content\n                andSQL:@\"SELECT content, extension FROM testTable WHERE content MATCH 'error_prone' ORDER BY rowid ASC\"\n           bySelecting:^NSArray<NSObject<WCTTableCoding> *> * {\n               return [self.table getObjectsWhere:FTS5Object.content.match(\"error_prone\")];\n           }];\n    [self doTestObject:extension\n                andSQL:@\"SELECT content, extension FROM testTable WHERE extension MATCH 'error_prone' ORDER BY rowid ASC\"\n           bySelecting:^NSArray<NSObject<WCTTableCoding> *> * {\n               return [self.table getObjectsWhere:FTS5Object.extension.match(\"error_prone\")];\n           }];\n    [self doTestObjects:@[ content, extension ]\n                 andSQL:@\"SELECT content, extension FROM testTable WHERE testTable MATCH 'error_prone' ORDER BY rowid ASC\"\n            bySelecting:^NSArray<NSObject<WCTTableCoding> *> * {\n                return [self.table getObjectsWhere:WCDB::Column(self.tableName).match(\"error_prone\")];\n            }];\n    [self doTestObject:content\n                andSQL:@\"SELECT content, extension FROM testTable WHERE testTable MATCH 'content: error_prone' ORDER BY rowid ASC\"\n           bySelecting:^NSArray<NSObject<WCTTableCoding> *> * {\n               return [self.table getObjectsWhere:WCDB::Column(self.tableName).match(\"content: error_prone\")];\n           }];\n    [self doTestObject:extension\n                andSQL:@\"SELECT content, extension FROM testTable WHERE testTable MATCH 'extension: error_prone' ORDER BY rowid ASC\"\n           bySelecting:^NSArray<NSObject<WCTTableCoding> *> * {\n               return [self.table getObjectsWhere:WCDB::Column(self.tableName).match(\"extension: error_prone\")];\n           }];\n}\n\n- (void)test_auto_merge\n{\n    [self.database enableAutoMergeFTS5Index:YES];\n    for (int i = 0; i < 14; i++) {\n        FTS5Object *object = [[FTS5Object alloc] init];\n        object.content = Random.shared.chineseString;\n        TestCaseAssertTrue([self.table insertObject:object]);\n        WCTValue *count = [self.database getValueFromStatement:WCDB::StatementSelect().select(WCDB::Column(\"segid\").count().distinct()).from([NSString stringWithFormat:@\"%@_idx\", self.tableName])];\n        TestCaseAssertTrue(count.numberValue.intValue == i + 2);\n    }\n\n    [NSThread sleepForTimeInterval:2.5];\n\n    WCTValue *count = [self.database getValueFromStatement:WCDB::StatementSelect().select(WCDB::Column(\"segid\").count().distinct()).from([NSString stringWithFormat:@\"%@_idx\", self.tableName])];\n    TestCaseAssertTrue(count.numberValue.intValue == 1);\n}\n\n- (void)test_thread_conflict\n{\n    [self.database enableAutoMergeFTS5Index:YES];\n    for (int i = 0; i < 1000; i++) {\n        FTS5Object *object = [[FTS5Object alloc] init];\n        object.content = Random.shared.chineseString;\n        TestCaseAssertTrue([self.table insertObject:object]);\n    }\n    [NSThread sleepForTimeInterval:1.8];\n    int totalCount = 10000;\n    __block double maxCost = 0;\n    for (int i = 0; i < totalCount; i++) {\n        FTS5Object *object = [[FTS5Object alloc] init];\n        object.content = Random.shared.chineseString;\n        if (i > 0 && i % (totalCount / 10) == 0) {\n            TestCaseLog(@\"insert progress %d%%\", i * 100 / totalCount);\n        }\n        NSDate *start = [NSDate date];\n        [self.database runTransaction:^BOOL(WCTHandle *_Nonnull) {\n            maxCost = MAX([[NSDate date] timeIntervalSinceDate:start], maxCost);\n            TestCaseAssertTrue([self.table insertObject:object]);\n            return YES;\n        }];\n        [NSThread sleepForTimeInterval:0.0001];\n    }\n    [NSThread sleepForTimeInterval:10];\n    WCTValue *count = [self.database getValueFromStatement:WCDB::StatementSelect().select(WCDB::Column(\"segid\").count().distinct()).from([NSString stringWithFormat:@\"%@_idx\", self.tableName])];\n    TestCaseAssertTrue(count.numberValue.intValue < 8);\n    TestCaseAssertTrue(maxCost < 0.1);\n}\n\n@end\n\n@interface FTS5PinyinTests : TableTestCase\n\n@end\n\n@implementation FTS5PinyinTests\n\n- (void)setUp\n{\n    [WCTDatabase configPinYinDict:@{\n        @\"单\" : @[ @\"shan\", @\"dan\", @\"chan\" ],\n        @\"于\" : @[ @\"yu\" ],\n        @\"骑\" : @[ @\"qi\" ],\n        @\"模\" : @[ @\"mo\", @\"mu\" ],\n        @\"具\" : @[ @\"ju\" ],\n        @\"车\" : @[ @\"che\" ],\n    }];\n    [super setUp];\n    self.expectMode = DatabaseTestCaseExpectFirstFewSQLs;\n    self.tableClass = FTS5PinyinObject.class;\n    self.isVirtualTable = YES;\n    [self.database addTokenizer:WCTTokenizerPinyin];\n    TestCaseAssertTrue([self createTable]);\n\n    FTS5PinyinObject *dummy = [[FTS5PinyinObject alloc] init];\n    dummy.content = @\"测试内容\";\n    TestCaseAssertTrue([self.table insertObject:dummy]);\n}\n\n- (void)test_pinyin\n{\n    FTS5PinyinObject *content = [[FTS5PinyinObject alloc] init];\n    content.content = @\"单于骑模具单车\";\n    TestCaseAssertTrue([self.table insertObject:content]);\n\n    NSArray *querys = @[\n        @\"\\\"shan yu qi mu ju dan che\\\"\",\n        @\"\\\"chan yu qi mo ju shan che\\\"\",\n        @\"\\\"dan yu qi mo ju chan che\\\"\",\n        @\"\\\"dan yu qi mu ju ch\\\"*\",\n        @\"\\\"dan yu qi mo ju d\\\"*\",\n        @\"\\\"s y q m j d c\\\"\",\n        @\"\\\"c y q m j s c\\\"\",\n        @\"\\\"c y q m j\\\"\",\n    ];\n    for (NSString *query in querys) {\n        [self doTestObject:content\n                    andSQL:[NSString stringWithFormat:@\"SELECT content FROM testTable WHERE content MATCH '%@' ORDER BY rowid ASC\", query]\n               bySelecting:^NSArray<NSObject<WCTTableCoding> *> * {\n                   return [self.table getObjectsWhere:FTS5PinyinObject.content.match(query)];\n               }];\n    }\n}\n\n@end\n\n@interface FTS5SymbolTests : TableTestCase\n\n@end\n\n@implementation FTS5SymbolTests\n\n- (void)setUp\n{\n    [super setUp];\n    self.expectMode = DatabaseTestCaseExpectFirstFewSQLs;\n    self.tableClass = FTS5SymbolObject.class;\n    self.isVirtualTable = YES;\n    [self.database addTokenizer:WCTTokenizerVerbatim];\n    [self.database addAuxiliaryFunction:WCTAuxiliaryFunction_SubstringMatchInfo];\n    TestCaseAssertTrue([self createTable]);\n\n    FTS5SymbolObject *dummy = [[FTS5SymbolObject alloc] init];\n    dummy.content = @\"!@#$%^&*(()))_+\";\n    TestCaseAssertTrue([self.table insertObject:dummy]);\n}\n\n- (void)test_symbol\n{\n    FTS5SymbolObject *content = [[FTS5SymbolObject alloc] init];\n    content.content = @\"\\\"#￥%…'  '！@…&*\";\n    TestCaseAssertTrue([self.table insertObject:content]);\n    content = [[FTS5SymbolObject alloc] init];\n    content.content = @\"！@…&*'  '\\\"#￥%…\";\n    TestCaseAssertTrue([self.table insertObject:content]);\n    NSArray *querys = @[ @\"\\\"！@…&*'  '\\\"\\\"#￥%…\\\"\", @\"\\\"！@…&*'  '\\\"\\\"\\\"*\" ];\n    for (NSString *query in querys) {\n        [self doTestObject:content\n                    andSQL:[NSString stringWithFormat:@\"SELECT content FROM testTable WHERE content MATCH '%@' ORDER BY rowid ASC\", [query stringByReplacingOccurrencesOfString:@\"'\" withString:@\"''\"]]\n               bySelecting:^NSArray<NSObject<WCTTableCoding> *> * {\n                   return [self.table getObjectsWhere:FTS5SymbolObject.content.match(query)];\n               }];\n    }\n\n    content = [[FTS5SymbolObject alloc] init];\n    content.content = @\"abc*123_def@567\";\n    TestCaseAssertTrue([self.table insertObject:content]);\n    content = [[FTS5SymbolObject alloc] init];\n    content.content = @\"abc@123*def_567\";\n    TestCaseAssertTrue([self.table insertObject:content]);\n    querys = @[ @\"\\\"abc@123*def_567\\\"\", @\"\\\"abc@123*def\\\"*\" ];\n    for (NSString *query in querys) {\n        [self doTestObject:content\n                    andSQL:[NSString stringWithFormat:@\"SELECT content FROM testTable WHERE content MATCH '%@' ORDER BY rowid ASC\", query]\n               bySelecting:^NSArray<NSObject<WCTTableCoding> *> * {\n                   return [self.table getObjectsWhere:FTS5SymbolObject.content.match(query)];\n               }];\n    }\n}\n\n- (void)test_substring_match_info\n{\n    FTS5SymbolObject *content = [[FTS5SymbolObject alloc] init];\n    content.content = @\"多级,分隔符,串联子串1;多级,分隔符,串联子串2;多级,分隔符,串联子串3\";\n    TestCaseAssertTrue([self.table insertObject:content]);\n    [self doTestValue:@\"1,2;串联;子串2;6;\"\n               andSQL:@\"SELECT substring_match_info(testTable, 0, ';,') FROM testTable WHERE content MATCH '子串2'\"\n          bySelecting:^WCTValue * {\n              return [self.database getValueFromStatement:WCDB::StatementSelect().select(WCDB::FTSFunction::substringMatchInfo(WCDB::Column(self.tableName), 0, \";,\")).from(self.tableName).where(FTS5SymbolObject.content.match(@\"子串2\"))];\n          }];\n}\n\n@end\n"
  },
  {
    "path": "src/objc/tests/host/Info.plist",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">\n<plist version=\"1.0\">\n<dict>\n\t<key>CFBundleDevelopmentRegion</key>\n\t<string>$(DEVELOPMENT_LANGUAGE)</string>\n\t<key>CFBundleDisplayName</key>\n\t<string>WCDB</string>\n\t<key>CFBundleExecutable</key>\n\t<string>$(EXECUTABLE_NAME)</string>\n\t<key>CFBundleIdentifier</key>\n\t<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>\n\t<key>CFBundleInfoDictionaryVersion</key>\n\t<string>6.0</string>\n\t<key>CFBundleName</key>\n\t<string>$(PRODUCT_NAME)</string>\n\t<key>CFBundlePackageType</key>\n\t<string>APPL</string>\n\t<key>CFBundleShortVersionString</key>\n\t<string>1</string>\n\t<key>CFBundleVersion</key>\n\t<string>1</string>\n\t<key>LSRequiresIPhoneOS</key>\n\t<true/>\n\t<key>NSHumanReadableCopyright</key>\n\t<string>Copyright © 2017 Tencent. All rights reserved.</string>\n\t<key>NSPrincipalClass</key>\n\t<string>$(PRINCIPAL_CLASS)</string>\n\t<key>UIRequiresFullScreen</key>\n\t<true/>\n\t<key>UISupportedInterfaceOrientations</key>\n\t<array>\n\t\t<string>UIInterfaceOrientationPortrait</string>\n\t\t<string>UIInterfaceOrientationLandscapeLeft</string>\n\t\t<string>UIInterfaceOrientationLandscapeRight</string>\n\t</array>\n\t<key>UISupportedInterfaceOrientations~ipad</key>\n\t<array>\n\t\t<string>UIInterfaceOrientationPortrait</string>\n\t\t<string>UIInterfaceOrientationPortraitUpsideDown</string>\n\t\t<string>UIInterfaceOrientationLandscapeLeft</string>\n\t\t<string>UIInterfaceOrientationLandscapeRight</string>\n\t</array>\n</dict>\n</plist>\n"
  },
  {
    "path": "src/objc/tests/host/host.xcconfig",
    "content": "// Signing\nCODE_SIGN_IDENTITY = -\n\n// Packaging\nINFOPLIST_FILE = $(SRCROOT)/objc/tests/host/Info.plist\n\n// User-Defined\nPRINCIPAL_CLASS[sdk=iphonesimulator*] = UIApplication\nPRINCIPAL_CLASS[sdk=iphoneos*] = UIApplication\nPRINCIPAL_CLASS[sdk=macosx*] = NSApplication\n"
  },
  {
    "path": "src/objc/tests/host/main.m",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import <TargetConditionals.h>\n\n#if TARGET_OS_WATCH\n\n// watchOS doesn't support testing at this time.\nint main(int argc, const char *argv[])\n{\n    WCDB_UNUSED(argc);\n    WCDB_UNUSED(argv);\n}\n\n#elif TARGET_OS_IPHONE || TARGET_OS_TV\n\n#import <UIKit/UIKit.h>\n\n@interface AppDelegate : UIResponder <UIApplicationDelegate>\n@property (strong, nonatomic) UIWindow *window;\n@end\n\n@implementation AppDelegate\n@end\n\nint main(int argc, char *argv[])\n{\n    @autoreleasepool {\n        return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));\n    }\n}\n\n#else\n\n#import <Cocoa/Cocoa.h>\n\nint main(int argc, const char *argv[])\n{\n    @autoreleasepool {\n        return NSApplicationMain(argc, argv);\n    }\n}\n\n#endif\n"
  },
  {
    "path": "src/objc/tests/migration/common/MigrationCompatibleTestCase.mm",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"MigrationCompatibleTestCase.h\"\n\n@interface MigrationCompatibleTestCase ()\n\n@property (nonatomic, readonly) NSString* schemaName;\n\n@end\n\n@implementation MigrationCompatibleTestCase {\n    NSString* _schemaName;\n}\n\n- (void)setUp\n{\n    [super setUp];\n\n    self.expectMode = DatabaseTestCaseExpectSomeSQLs;\n\n    if (self.mode != MigrationObjectORMModeMissOneColumn && self.mode != MigrationObjectORMModeMissTwoColumn)\n        TestCaseAssertTrue([[self.table getObjectsOrders:MigrationObject.identifier.asOrder(WCTOrderedAscending)] isEqualToArray:self.objects]);\n}\n\n- (NSString*)schemaName\n{\n    @synchronized(self) {\n        if (_schemaName == nil) {\n            if (self.isCrossDatabaseMigration) {\n                _schemaName = [NSString stringWithFormat:@\"wcdb_migration_%u.\", WCDB::UnsafeStringView(self.sourcePath).hash()];\n            } else {\n                _schemaName = @\"main.\";\n            }\n        }\n        return _schemaName;\n    }\n}\n\n- (void)doTestInsert\n{\n    MigrationObject* newObject = [Random.shared migrationObjectWithIdentifier:self.objects.lastObject.identifier + 1];\n    NSMutableArray<MigrationObject*>* expectedObjects = [NSMutableArray arrayWithArray:self.objects];\n    [expectedObjects addObject:newObject];\n\n    NSMutableArray<NSString*>* sqls = [NSMutableArray array];\n    [sqls addObject:@\"BEGIN IMMEDIATE\"];\n    [sqls addObject:[NSString stringWithFormat:@\"INSERT INTO %@%@(identifier, content) VALUES(?1, ?2)\", self.schemaName, self.sourceTable]];\n    [sqls addObject:[NSString stringWithFormat:@\"DELETE FROM %@%@ WHERE rowid == ?1\", self.schemaName, self.sourceTable]];\n    if (self.mode == MigrationObjectORMModeNormal || self.mode == MigrationObjectORMModeMissOneColumn || self.mode == MigrationObjectORMModeMissTwoColumn) {\n        [sqls addObject:@\"INSERT INTO main.testTable(identifier, content, rowid) VALUES(?1, ?2, (SELECT max(rowid) + 1 FROM temp.wcdb_union_testTable))\"];\n    } else {\n        [sqls addObject:[NSString stringWithFormat:@\"INSERT INTO main.testTable(identifier, content, rowid) VALUES(?1, ?2, ?%d)\", SQLITE_MAX_VARIABLE_NUMBER]];\n    }\n    [sqls addObject:@\"COMMIT\"];\n\n    [self doTestObjects:expectedObjects\n                andSQLs:sqls\n      afterModification:^BOOL {\n          return [self.table insertObject:newObject];\n      }];\n}\n\n- (void)doTestInsertAutoIncrement\n{\n    MigrationObject* newObject = [Random.shared autoIncrementMigrationObjectWithIdentifier:self.objects.lastObject.identifier + 1];\n    NSMutableArray<MigrationObject*>* expectedObjects = [NSMutableArray arrayWithArray:self.objects];\n    [expectedObjects addObject:newObject];\n\n    NSMutableArray<NSString*>* sqls = [NSMutableArray array];\n    [sqls addObject:@\"BEGIN IMMEDIATE\"];\n    [sqls addObject:[NSString stringWithFormat:@\"INSERT INTO %@%@(identifier, content) VALUES(?1, ?2)\", self.schemaName, self.sourceTable]];\n    [sqls addObject:[NSString stringWithFormat:@\"DELETE FROM %@%@ WHERE rowid == ?1\", self.schemaName, self.sourceTable]];\n    [sqls addObject:[NSString stringWithFormat:@\"INSERT INTO main.testTable(identifier, content, rowid) VALUES(?1, ?2, ?%d)\", SQLITE_MAX_VARIABLE_NUMBER]];\n    [sqls addObject:@\"COMMIT\"];\n\n    [self doTestObjects:expectedObjects\n                andSQLs:sqls\n      afterModification:^BOOL {\n          return [self.table insertObject:newObject];\n      }];\n}\n\n- (void)doTestInsertOrReplace\n{\n    MigrationObject* newObject = [Random.shared migrationObjectWithIdentifier:self.objects.lastObject.identifier];\n    NSMutableArray<MigrationObject*>* expectedObjects = [NSMutableArray arrayWithArray:self.objects];\n    [expectedObjects removeLastObject];\n    [expectedObjects addObject:newObject];\n\n    NSMutableArray<NSString*>* sqls = [NSMutableArray array];\n    [sqls addObject:@\"BEGIN IMMEDIATE\"];\n    [sqls addObject:[NSString stringWithFormat:@\"INSERT OR REPLACE INTO %@%@(identifier, content) VALUES(?1, ?2)\", self.schemaName, self.sourceTable]];\n    [sqls addObject:[NSString stringWithFormat:@\"DELETE FROM %@%@ WHERE rowid == ?1\", self.schemaName, self.sourceTable]];\n    [sqls addObject:[NSString stringWithFormat:@\"INSERT OR REPLACE INTO main.testTable(identifier, content, rowid) VALUES(?1, ?2, ?%d)\", SQLITE_MAX_VARIABLE_NUMBER]];\n    [sqls addObject:@\"COMMIT\"];\n\n    [self doTestObjects:expectedObjects\n                andSQLs:sqls\n      afterModification:^BOOL {\n          return [self.table insertOrReplaceObject:newObject];\n      }];\n}\n\n- (void)doTestInsertOrIgnore\n{\n    MigrationObject* newObject = [Random.shared migrationObjectWithIdentifier:self.objects.lastObject.identifier];\n    NSMutableArray<MigrationObject*>* expectedObjects = [NSMutableArray arrayWithArray:self.objects];\n\n    NSMutableArray<NSString*>* sqls = [NSMutableArray array];\n    [sqls addObject:@\"BEGIN IMMEDIATE\"];\n    [sqls addObject:[NSString stringWithFormat:@\"INSERT OR IGNORE INTO %@%@(identifier, content) VALUES(?1, ?2)\", self.schemaName, self.sourceTable]];\n    [sqls addObject:@\"COMMIT\"];\n\n    [self doTestObjects:expectedObjects\n                andSQLs:sqls\n      afterModification:^BOOL {\n          return [self.table insertOrIgnoreObject:newObject];\n      }];\n}\n\n- (void)doTestInsertFailedWithConflict\n{\n    MigrationObject* newObject = [Random.shared migrationObjectWithIdentifier:self.objects.lastObject.identifier];\n\n    TestCaseAssertFalse([self.table insertObject:newObject]);\n}\n\n- (void)doTestLimitedDelete\n{\n    NSMutableArray<MigrationObject*>* expectedObjects = [NSMutableArray arrayWithArray:self.objects];\n    [expectedObjects removeObjectAtIndex:2];\n\n    NSArray<NSString*>* sqls = @[ @\"BEGIN IMMEDIATE\",\n                                  [NSString stringWithFormat:@\"DELETE FROM %@%@ WHERE rowid IN(SELECT rowid FROM temp.wcdb_union_testTable WHERE identifier > 1 ORDER BY identifier ASC LIMIT 1 OFFSET 1)\", self.schemaName, self.sourceTable],\n                                  @\"DELETE FROM main.testTable WHERE rowid IN(SELECT rowid FROM temp.wcdb_union_testTable WHERE identifier > 1 ORDER BY identifier ASC LIMIT 1 OFFSET 1)\",\n                                  @\"COMMIT\" ];\n\n    [self doTestObjects:expectedObjects\n                andSQLs:sqls\n      afterModification:^BOOL {\n          return [self.table deleteObjectsWhere:MigrationObject.identifier > 1 orders:MigrationObject.identifier.asOrder(WCTOrderedAscending) limit:1 offset:1];\n      }];\n}\n\n- (void)doTestLimitedUpdate\n{\n    NSMutableArray<MigrationObject*>* expectedObjects = [NSMutableArray arrayWithArray:self.objects];\n    MigrationObject* secondObject = [expectedObjects objectAtIndex:2];\n    MigrationObject* newSecondObject = [Random.shared migrationObjectWithIdentifier:secondObject.identifier];\n    [expectedObjects setObject:newSecondObject atIndexedSubscript:2];\n\n    NSArray<NSString*>* sqls = @[ @\"BEGIN IMMEDIATE\",\n                                  [NSString stringWithFormat:@\"UPDATE %@%@ SET content = ?1 WHERE rowid IN(SELECT rowid FROM temp.wcdb_union_testTable WHERE identifier > 1 ORDER BY identifier ASC LIMIT 1 OFFSET 1)\", self.schemaName, self.sourceTable],\n                                  @\"UPDATE main.testTable SET content = ?1 WHERE rowid IN(SELECT rowid FROM temp.wcdb_union_testTable WHERE identifier > 1 ORDER BY identifier ASC LIMIT 1 OFFSET 1)\",\n                                  @\"COMMIT\" ];\n\n    [self doTestObjects:expectedObjects\n                andSQLs:sqls\n      afterModification:^BOOL {\n          return [self.table updateProperties:MigrationObject.content toObject:newSecondObject where:MigrationObject.identifier > 1 orders:MigrationObject.identifier.asOrder(WCTOrderedAscending) limit:1 offset:1];\n      }];\n}\n\n- (void)doTestSelect\n{\n    NSString* sql = @\"SELECT identifier, content FROM temp.wcdb_union_testTable WHERE identifier == 1 ORDER BY rowid ASC\";\n\n    [self doTestObjects:@[ self.objects.firstObject ]\n                 andSQL:sql\n            bySelecting:^NSArray<NSObject<WCTTableCoding>*>* {\n                return [self.table getObjectsWhere:MigrationObject.identifier == 1];\n            }];\n}\n\n- (void)doTestDropTable\n{\n    {\n        NSArray<NSString*>* sqls = @[ @\"BEGIN IMMEDIATE\",\n                                      @\"DROP TABLE IF EXISTS main.testTable\",\n                                      [NSString stringWithFormat:@\"DELETE FROM %@%@\", self.schemaName, self.sourceTable],\n                                      @\"COMMIT\" ];\n\n        [self doTestSQLs:sqls\n             inOperation:^BOOL {\n                 return [self.database dropTable:self.tableName];\n             }];\n    }\n}\n\n- (void)doTestSubqueryWithinDelete\n{\n    NSMutableArray<MigrationObject*>* expectedObjects = [NSMutableArray arrayWithArray:self.objects];\n    [expectedObjects removeLastObject];\n\n    NSArray<NSString*>* sqls = @[ @\"BEGIN IMMEDIATE\",\n                                  [NSString stringWithFormat:@\"DELETE FROM %@%@ WHERE rowid IN(SELECT rowid FROM temp.wcdb_union_testTable WHERE temp.wcdb_union_testTable.identifier IN(SELECT max(identifier) FROM temp.wcdb_union_testTable))\", self.schemaName, self.sourceTable],\n                                  @\"DELETE FROM main.testTable WHERE rowid IN(SELECT rowid FROM temp.wcdb_union_testTable WHERE temp.wcdb_union_testTable.identifier IN(SELECT max(identifier) FROM temp.wcdb_union_testTable))\",\n                                  @\"COMMIT\" ];\n\n    [self doTestObjects:expectedObjects\n                andSQLs:sqls\n      afterModification:^BOOL {\n          return [self.table deleteObjectsWhere:MigrationObject.identifier.table(self.tableName).in(WCDB::StatementSelect().select(MigrationObject.identifier.max()).from(self.tableName))];\n      }];\n}\n\n- (void)doTestSubqueryWithinUpdate\n{\n    NSMutableArray<MigrationObject*>* expectedObjects = [NSMutableArray arrayWithArray:self.objects];\n    MigrationObject* newObject = [Random.shared migrationObjectWithIdentifier:expectedObjects.lastObject.identifier];\n    [expectedObjects removeLastObject];\n    [expectedObjects addObject:newObject];\n\n    NSArray<NSString*>* sqls = @[ @\"BEGIN IMMEDIATE\",\n                                  [NSString stringWithFormat:@\"UPDATE %@%@ SET content = ?1 WHERE rowid IN(SELECT rowid FROM temp.wcdb_union_testTable WHERE temp.wcdb_union_testTable.identifier IN(SELECT max(identifier) FROM temp.wcdb_union_testTable))\", self.schemaName, self.sourceTable],\n                                  @\"UPDATE main.testTable SET content = ?1 WHERE rowid IN(SELECT rowid FROM temp.wcdb_union_testTable WHERE temp.wcdb_union_testTable.identifier IN(SELECT max(identifier) FROM temp.wcdb_union_testTable))\",\n                                  @\"COMMIT\" ];\n\n    [self doTestObjects:expectedObjects\n                andSQLs:sqls\n      afterModification:^BOOL {\n          return [self.table updateProperties:MigrationObject.content toObject:newObject where:MigrationObject.identifier.table(self.tableName).in(WCDB::StatementSelect().select(MigrationObject.identifier.max()).from(self.tableName))];\n      }];\n}\n\n@end\n"
  },
  {
    "path": "src/objc/tests/migration/common/MigrationObject.mm",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"MigrationObject.h\"\n#import \"MigrationObject+WCTTableCoding.h\"\n#if TEST_WCDB_OBJC\n#import <WCDBOBjc/WCDBObjc.h>\n#elif TEST_WCDB_CPP\n#import <WCDBCpp/WCDBCpp.h>\n#else\n#import <WCDB/WCDBObjc.h>\n#endif\n\n@implementation MigrationObject\n\nWCDB_IMPLEMENTATION(MigrationObject)\nWCDB_SYNTHESIZE(identifier)\nWCDB_SYNTHESIZE(content)\n\n@synthesize isAutoIncrement;\n@synthesize lastInsertedRowID;\n\n+ (WCDB::StatementCreateTable)statementForCreatingSourceTable:(NSString*)tableName withMode:(MigrationObjectORMMode)mode\n{\n    switch (mode) {\n    case MigrationObjectORMModeNormal:\n        return [MigrationObject statementForCreatingNormalTable:tableName];\n    case MigrationObjectORMModePrimaryKey:\n        return [MigrationObject statementForCreatingPrimaryKeyTable:tableName];\n    case MigrationObjectORMModeAutoIncrement:\n        return [MigrationObject statementForCreatingAutoIncrementTable:tableName];\n    case MigrationObjectORMModeMissOneColumn:\n    case MigrationObjectORMModeMissTwoColumn:\n        return [MigrationObject statementForCreatingMissColumnTable:tableName];\n    }\n}\n\n+ (WCDB::StatementCreateTable)statementForCreatingTargetTable:(NSString*)tableName withMode:(MigrationObjectORMMode)mode\n{\n    switch (mode) {\n    case MigrationObjectORMModeNormal:\n    case MigrationObjectORMModeMissOneColumn:\n        return [MigrationObject statementForCreatingNormalTable:tableName];\n    case MigrationObjectORMModeMissTwoColumn:\n        return [MigrationObject statementForCreatingMissColumnTable:tableName];\n    case MigrationObjectORMModePrimaryKey:\n        return [MigrationObject statementForCreatingPrimaryKeyTable:tableName];\n    case MigrationObjectORMModeAutoIncrement:\n        return [MigrationObject statementForCreatingAutoIncrementTable:tableName];\n    }\n}\n\n+ (WCDB::StatementCreateTable)statementForCreatingNormalTable:(NSString*)tableName\n{\n    return MigrationObject.objectRelationalMapping.generateCreateTableStatement(tableName);\n}\n\n+ (WCDB::StatementCreateTable)statementForCreatingPrimaryKeyTable:(NSString*)tableName\n{\n    WCDB::StatementCreateTable statement = MigrationObject.objectRelationalMapping.generateCreateTableStatement(tableName);\n    for (auto& columnDef : statement.syntax().columnDefs) {\n        if (columnDef.column.getOrCreate().name == MigrationObject.identifier.getDescription()) {\n            WCDB::ColumnConstraint constraint;\n            constraint.primaryKey().order(WCDB::Order::ASC);\n            columnDef.constraints.push_back(constraint.syntax());\n            break;\n        }\n    }\n    return statement;\n}\n\n+ (WCDB::StatementCreateTable)statementForCreatingAutoIncrementTable:(NSString*)tableName\n{\n    WCDB::StatementCreateTable statement = MigrationObject.objectRelationalMapping.generateCreateTableStatement(tableName);\n    for (auto& columnDef : statement.syntax().columnDefs) {\n        if (columnDef.column.getOrCreate().name == MigrationObject.identifier.getDescription()) {\n            WCDB::ColumnConstraint constraint;\n            constraint.primaryKey().order(WCDB::Order::ASC).autoIncrement();\n            columnDef.constraints.push_back(constraint.syntax());\n            break;\n        }\n    }\n    return statement;\n}\n\n+ (WCDB::StatementCreateTable)statementForCreatingMissColumnTable:(NSString*)tableName\n{\n    WCDB::StatementCreateTable statement = MigrationObject.objectRelationalMapping.generateCreateTableStatement(tableName);\n    auto iterater = statement.syntax().columnDefs.begin();\n    while (iterater != statement.syntax().columnDefs.end()) {\n        if (iterater->column.getOrCreate().name == MigrationObject.content.getDescription()) {\n            statement.syntax().columnDefs.erase(iterater);\n            break;\n        }\n        iterater++;\n    }\n    return statement;\n}\n\n+ (instancetype)objectWithIdentifier:(int)identifier andContent:(NSString*)content\n{\n    MigrationObject* object = [[MigrationObject alloc] init];\n    object.identifier = identifier;\n    object.content = content;\n    return object;\n}\n\n- (BOOL)isEqual:(NSObject*)object\n{\n    if (object.class != self.class) {\n        return NO;\n    }\n    MigrationObject* other = (MigrationObject*) object;\n    return self.identifier == other.identifier && [NSObject isObject:self.content nilEqualToObject:other.content];\n}\n\n- (NSUInteger)hash\n{\n    NSMutableData* data = [NSMutableData data];\n    [data appendBytes:&(_identifier) length:sizeof(_identifier)];\n    [data appendData:[_content dataUsingEncoding:NSUTF8StringEncoding]];\n    return data.hash;\n}\n\n@end\n"
  },
  {
    "path": "src/objc/tests/migration/common/MigrationTestCase.h",
    "content": "//\n// Created by 陈秋文 on 2023/7/23.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"MigrationTestObject.h\"\n#import \"MigrationTestSourceObject.h\"\n#import \"TestCase.h\"\n\n@interface MigrationTestCase : TableTestCase\n\n@property (nonatomic, assign) BOOL startMigration;\n@property (nonatomic, assign) BOOL isCrossDatabaseMigration;\n@property (nonatomic, assign) BOOL needCipher;\n@property (nonatomic, assign) BOOL needFilter;\n@property (nonatomic, assign) int missColumnCount;\n\n@property (nonatomic, strong) Class<MigrationTestSourceObject> sourceClass;\n@property (nonatomic, strong) Class<MigrationTestObject> targetClass;\n\n@property (nonatomic, readonly) NSString* schemaName;\n@property (nonatomic, readonly) NSString* sourceTableName;\n@property (nonatomic, readonly) NSString* sourcePath;\n@property (nonatomic, readonly) WCTDatabase* sourceDatabase;\n@property (nonatomic, readonly) WCTTable* sourceTable;\n\n@property (readonly, nonatomic) NSArray<NSObject<MigrationTestSourceObject>*>* objects;\n@property (readonly, nonatomic) NSArray<NSObject<MigrationTestObject>*>* filterObjects;\n\n+ (NSArray<Class<MigrationTestObject>>*)allClasses;\n+ (NSArray<Class<MigrationTestSourceObject>>*)allSourceClasses;\n\n- (void)createTables;\n- (void)configMigration;\n- (void)clearData;\n\n@end\n"
  },
  {
    "path": "src/objc/tests/migration/common/MigrationTestCase.mm",
    "content": "//\n// Created by 陈秋文 on 2023/7/23.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"MigrationTestCase.h\"\n#import \"AutoIncrementMigrationObject.h\"\n#import \"AutoIncrementMigrationSourceObject.h\"\n#import \"IntegerPrimaryKeyMigrationObject.h\"\n#import \"IntegerPrimaryKeyMigrationSourceObject.h\"\n#import \"NormalMigrationObject.h\"\n#import \"NormalMigrationSourceObject.h\"\n#import \"Random+MigrationTestObject.h\"\n#import <Foundation/Foundation.h>\n\n@interface MigrationTestCase () {\n    NSString* _sourcePath;\n    NSString* _sourceTableName;\n    WCTDatabase* _sourceDatabase;\n    WCTTable* _sourceTable;\n    NSString* _schemaName;\n\n    NSArray<NSObject<MigrationTestSourceObject>*>* _objects;\n    NSArray<NSObject<MigrationTestObject>*>* _filterObjects;\n    NSData* _sourceCipher;\n    NSData* _targetCipher;\n}\n@end\n\n@implementation MigrationTestCase\n\n+ (NSArray<Class<MigrationTestObject>>*)allClasses\n{\n    static NSArray* g_allClasses = @[\n        NormalMigrationObject.class,\n        IntegerPrimaryKeyMigrationObject.class,\n        AutoIncrementMigrationObject.class,\n    ];\n    return g_allClasses;\n}\n\n+ (NSArray<Class<MigrationTestSourceObject>>*)allSourceClasses\n{\n    static NSArray* g_allSourceClasses = @[\n        NormalMigrationSourceObject.class,\n        IntegerPrimaryKeyMigrationSourceObject.class,\n        AutoIncrementMigrationSourceObject.class,\n    ];\n    return g_allSourceClasses;\n}\n\n- (NSString*)sourcePath\n{\n    @synchronized(self) {\n        if (_sourcePath == nil) {\n            if (self.isCrossDatabaseMigration) {\n                _sourcePath = [self.path stringByAppendingString:@\"_source\"];\n            } else {\n                _sourcePath = self.path;\n            }\n        }\n        return _sourcePath;\n    }\n}\n\n- (NSString*)sourceTableName\n{\n    @synchronized(self) {\n        if (_sourceTableName == nil) {\n            if (self.isCrossDatabaseMigration) {\n                _sourceTableName = self.tableName;\n            } else {\n                _sourceTableName = @\"testSourceTable\";\n            }\n        }\n        return _sourceTableName;\n    }\n}\n\n- (WCTTable*)sourceTable\n{\n    @synchronized(self) {\n        if (_sourceTable == nil) {\n            _sourceTable = [self.sourceDatabase getTable:self.sourceTableName\n                                               withClass:self.sourceClass];\n        }\n        return _sourceTable;\n    }\n}\n\n- (WCTDatabase*)sourceDatabase\n{\n    @synchronized(self) {\n        if (_sourceDatabase == nil) {\n            if (_isCrossDatabaseMigration) {\n                _sourceDatabase = [[WCTDatabase alloc] initWithPath:self.sourcePath];\n            } else {\n                _sourceDatabase = self.database;\n            }\n        }\n        return _sourceDatabase;\n    }\n}\n\n- (NSString*)schemaName\n{\n    @synchronized(self) {\n        if (_schemaName == nil) {\n            if (self.isCrossDatabaseMigration) {\n                _schemaName = [NSString stringWithFormat:@\"wcdb_migration_%u.\", WCDB::UnsafeStringView(self.sourcePath).hash()];\n            } else {\n                _schemaName = @\"main.\";\n            }\n        }\n        return _schemaName;\n    }\n}\n\n- (NSArray<id<MigrationTestSourceObject>>*)objects\n{\n    @synchronized(self) {\n        if (_objects == nil) {\n            _objects = (NSArray<NSObject<MigrationTestSourceObject>*>*)\n            [[Random shared] migrationObjectsWithClass:self.sourceClass\n                                              andCount:2000\n                                startingFromIdentifier:1\n                                        withoutContent:self.missColumnCount > 0];\n        }\n        return _objects;\n    }\n}\n\n- (NSArray<id<MigrationTestObject>>*)filterObjects\n{\n    @synchronized(self) {\n        if (_filterObjects == nil) {\n            NSMutableArray* filterObjects = [[NSMutableArray alloc] init];\n            for (NSObject<MigrationTestSourceObject>* sourceObject in self.objects) {\n                if (!_needFilter || sourceObject.classification == MigrationClassificationB) {\n                    id<MigrationTestObject> object = [[(Class) self.targetClass alloc] init];\n                    object.identifier = sourceObject.identifier;\n                    object.content = sourceObject.content;\n                    [filterObjects addObject:object];\n                }\n            }\n            _filterObjects = filterObjects;\n        }\n        return _filterObjects;\n    }\n}\n\n- (void)tearDown\n{\n    [self clearData];\n    [super tearDown];\n}\n\n- (void)configMigration\n{\n    [self clearData];\n\n    NSData* sourceCipher = nil;\n    NSData* targetCipher = nil;\n    if (_needCipher) {\n        if (_sourceCipher == nil) {\n            _sourceCipher = [Random.shared data];\n        }\n        if (_targetCipher == nil) {\n            _targetCipher = [Random.shared data];\n        }\n        sourceCipher = _sourceCipher;\n        targetCipher = _targetCipher;\n    }\n    [self.database setCipherKey:targetCipher];\n    [self.sourceDatabase setCipherKey:sourceCipher];\n\n    [self createTables];\n\n    TestCaseAssertTrue([self.sourceTable insertObjects:self.objects.reversedArray]);\n    [self.sourceDatabase close:^() {\n        TestCaseAssertTrue([self.sourceDatabase truncateCheckpoint]);\n    }];\n    self.table = [self.database getTable:self.tableName withClass:self.targetClass];\n\n    [self.database addMigration:self.sourcePath\n               withSourceCipher:sourceCipher\n                     withFilter:^(WCTMigrationUserInfo* info) {\n                         if ([info.table isEqualToString:self.tableName]) {\n                             [info setSourceTable:self.sourceTableName];\n                             if (self.needFilter) {\n                                 [info setFilterCondition:[self.sourceClass classification] == MigrationClassificationB];\n                             }\n                         }\n                     }];\n    TestCaseAssertTrue([self.database canOpen]);\n\n    if (_startMigration) {\n        TestCaseAssertTrue([self.database stepMigration]);\n    }\n    TestCaseAssertFalse([self.database isMigrated]);\n\n    NSArray* filterObjects = self.filterObjects;\n    NSArray* dbObjects = [self.table getObjectsOrders:[self.targetClass identifier].asOrder(WCTOrderedAscending)];\n    TestCaseAssertTrue([dbObjects isEqualToArray:filterObjects]);\n}\n\n- (void)clearData\n{\n    TestCaseAssertTrue([self.database removeFiles]);\n    TestCaseAssertTrue([self.sourceDatabase removeFiles]);\n    [self.database addMigration:self.sourcePath withFilter:nil];\n    _sourceTable = nil;\n    _sourceTableName = nil;\n    _sourcePath = nil;\n    _sourceDatabase = nil;\n    _objects = nil;\n    _filterObjects = nil;\n    _schemaName = nil;\n    self.table = nil;\n}\n\n- (void)createTables\n{\n    if (_missColumnCount == 0) {\n        TestCaseAssertTrue([self.sourceDatabase createTable:self.sourceTableName\n                                                  withClass:self.sourceClass]);\n    } else {\n        WCDB::StatementCreateTable createTable = [self.sourceClass objectRelationalMapping].generateCreateTableStatement(self.sourceTableName);\n        auto iterater = createTable.syntax().columnDefs.begin();\n        while (iterater != createTable.syntax().columnDefs.end()) {\n            if (iterater->column.getOrCreate().name == [self.sourceClass content].getDescription()) {\n                createTable.syntax().columnDefs.erase(iterater);\n                break;\n            }\n            iterater++;\n        }\n        TestCaseAssertTrue([self.sourceDatabase execute:createTable]);\n        WCDB::StatementCreateIndex createIndex = WCDB::StatementCreateIndex().createIndex(\"classification_index\").ifNotExists().indexed([self.sourceClass classification]).table(self.sourceTableName);\n        TestCaseAssertTrue([self.sourceDatabase execute:createIndex]);\n    }\n    if (_missColumnCount < 2) {\n        TestCaseAssertTrue([self.database createTable:self.tableName\n                                            withClass:self.targetClass]);\n    } else {\n        WCDB::StatementCreateTable createTable = [self.targetClass objectRelationalMapping].generateCreateTableStatement(self.tableName);\n        auto iterater = createTable.syntax().columnDefs.begin();\n        while (iterater != createTable.syntax().columnDefs.end()) {\n            if (iterater->column.getOrCreate().name == [self.targetClass content].getDescription()) {\n                createTable.syntax().columnDefs.erase(iterater);\n                break;\n            }\n            iterater++;\n        }\n        TestCaseAssertTrue([self.database execute:createTable]);\n    }\n}\n\n- (NSArray<NSObject<WCTTableCoding>*>*)getAllObjects\n{\n    return [self.table getObjectsOrders:[self.targetClass identifier].asOrder(WCTOrderedAscending)];\n}\n\n@end\n"
  },
  {
    "path": "src/objc/tests/migration/common/MigrationTestObject.h",
    "content": "//\n// Created by 陈秋文 on 2023/7/23.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#if TEST_WCDB_OBJC\n#import <WCDBOBjc/WCDBObjc.h>\n#elif TEST_WCDB_CPP\n#import <WCDBCpp/WCDBCpp.h>\n#else\n#import <WCDB/WCDBObjc.h>\n#endif\n\n#import \"MigrationTestObjectBase.h\"\n\n@protocol MigrationTestObject <WCTTableCoding>\n\n@property (nonatomic, assign) int identifier;\n@property (nonatomic, strong) NSString* content;\n\nWCDB_PROPERTY(identifier)\nWCDB_PROPERTY(content)\n\n+ (BOOL)hasIntegerPrimaryKey;\n+ (BOOL)isAutoIncrement;\n\n@end\n"
  },
  {
    "path": "src/objc/tests/migration/common/MigrationTestObjectBase.h",
    "content": "//\n// Created by qiuwenchen on 2023/7/24.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import <Foundation/Foundation.h>\n\ntypedef enum : NSUInteger {\n    MigrationClassificationA = 0,\n    MigrationClassificationB = 1,\n    MigrationClassificationC = 2,\n} MigrationClassification;\n\n@interface MigrationTestObjectBase : NSObject\n\n@property (nonatomic, assign) int identifier;\n@property (nonatomic, assign) MigrationClassification classification;\n@property (nonatomic, strong) NSString* content;\n\n@end\n"
  },
  {
    "path": "src/objc/tests/migration/common/MigrationTestObjectBase.mm",
    "content": "//\n// Created by qiuwenchen on 2023/7/24.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"MigrationTestObjectBase.h\"\n#import \"NSObject+TestCase.h\"\n\n@implementation MigrationTestObjectBase\n\n- (BOOL)isEqual:(NSObject*)object\n{\n    if (object.class != self.class) {\n        return NO;\n    }\n    MigrationTestObjectBase* other = (MigrationTestObjectBase*) object;\n    if (self.identifier != other.identifier) {\n        return NO;\n    }\n    if (self.classification != other.classification) {\n        return NO;\n    }\n    if (![NSObject isObject:self.content nilEqualToObject:other.content]) {\n        return NO;\n    }\n    return YES;\n}\n\n- (NSUInteger)hash\n{\n    NSMutableData* data = [NSMutableData data];\n    [data appendBytes:&(_identifier) length:sizeof(_identifier)];\n    [data appendData:[_content dataUsingEncoding:NSUTF8StringEncoding]];\n    return data.hash;\n}\n\n@end\n"
  },
  {
    "path": "src/objc/tests/migration/common/MigrationTestSourceObject.h",
    "content": "//\n// Created by 陈秋文 on 2023/7/23.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"MigrationTestObject.h\"\n\n@protocol MigrationTestSourceObject <MigrationTestObject>\n\n@property (nonatomic, assign) MigrationClassification classification;\nWCDB_PROPERTY(classification)\n\n@end\n"
  },
  {
    "path": "src/objc/tests/migration/common/Random+MigrationTestObject.h",
    "content": "//\n// Created by 陈秋文 on 2023/7/23.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"MigrationTestObject.h\"\n#import \"TestCase.h\"\n\n@interface Random (MigrationTestObject)\n\n- (NSObject<MigrationTestObject> *)autoIncrementMigrationObjectWithClass:(Class<MigrationTestObject>)objectClass;\n\n- (NSObject<MigrationTestObject> *)migrationObjectWithClass:(Class<MigrationTestObject>)objectClass\n                                              andIdentifier:(int)identifier;\n\n- (NSArray<NSObject<MigrationTestObject> *> *)migrationObjectsWithClass:(Class<MigrationTestObject>)objectClass\n                                                               andCount:(int)count\n                                                 startingFromIdentifier:(int)identifier\n                                                         withoutContent:(bool)noContent;\n\n@end\n"
  },
  {
    "path": "src/objc/tests/migration/common/Random+MigrationTestObject.mm",
    "content": "//\n// Created by 陈秋文 on 2023/7/23.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"MigrationTestSourceObject.h\"\n#import \"Random+MigrationTestObject.h\"\n#import <Foundation/Foundation.h>\n\n@implementation Random (MigrationTestObject)\n\n- (NSObject<MigrationTestObject>*)autoIncrementMigrationObjectWithClass:(Class<MigrationTestObject>)objectClass\n{\n    NSObject<MigrationTestObject>* object = [self migrationObjectWithClass:objectClass\n                                                             andIdentifier:Random.shared.int32\n                                                            withoutContent:NO];\n    object.isAutoIncrement = YES;\n    return object;\n}\n\n- (NSObject<MigrationTestObject>*)migrationObjectWithClass:(Class<MigrationTestObject>)objectClass\n                                             andIdentifier:(int)identifier\n{\n    return [self migrationObjectWithClass:objectClass andIdentifier:identifier withoutContent:NO];\n}\n\n- (NSObject<MigrationTestObject>*)migrationObjectWithClass:(Class<MigrationTestObject>)objectClass\n                                             andIdentifier:(int)identifier\n                                            withoutContent:(bool)noContent\n{\n    NSObject<MigrationTestObject>* object = [[(Class) objectClass alloc] init];\n    object.identifier = identifier;\n    if ([object conformsToProtocol:@protocol(MigrationTestSourceObject)]) {\n        id<MigrationTestSourceObject> sourceObject = (id<MigrationTestSourceObject>) object;\n        sourceObject.classification = (MigrationClassification) (self.uint8 % 3);\n    }\n    if (!noContent) {\n        object.content = self.string;\n    }\n    return object;\n}\n\n- (NSArray<NSObject<MigrationTestObject>*>*)migrationObjectsWithClass:(Class<MigrationTestObject>)objectClass\n                                                             andCount:(int)count\n                                               startingFromIdentifier:(int)identifier\n                                                       withoutContent:(bool)noContent\n{\n    NSMutableArray<NSObject<MigrationTestObject>*>* objects = [NSMutableArray arrayWithCapacity:count];\n    for (int i = identifier; i < identifier + count; ++i) {\n        [objects addObject:[self migrationObjectWithClass:objectClass\n                                            andIdentifier:i\n                                           withoutContent:noContent]];\n    }\n    return objects;\n}\n\n@end\n"
  },
  {
    "path": "src/objc/tests/migration/compatible/CipherMigrationTests.mm",
    "content": "//\n// Created by qiuwenchen on 2023/7/25.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"IntegerPrimaryKeyMigrationObject.h\"\n#import \"IntegerPrimaryKeyMigrationSourceObject.h\"\n#import \"MigrationTestCase.h\"\n#import <Foundation/Foundation.h>\n\n@interface CipherMigrationTests : MigrationTestCase\n@end\n\n@implementation CipherMigrationTests\n\n- (void)setUp\n{\n    [super setUp];\n    self.needCipher = YES;\n    self.sourceClass = IntegerPrimaryKeyMigrationSourceObject.class;\n    self.targetClass = IntegerPrimaryKeyMigrationObject.class;\n    self.isCrossDatabaseMigration = YES;\n    self.startMigration = YES;\n    [self configMigration];\n}\n\n- (void)test_cipher\n{\n    NSObject<MigrationTestObject>* expectedObject = self.filterObjects.lastObject;\n    NSString* sql = [NSString stringWithFormat:@\"SELECT identifier, content FROM temp.wcdb_union_testTable WHERE identifier == %d ORDER BY rowid ASC\", expectedObject.identifier];\n\n    [self doTestObjects:@[ expectedObject ]\n                 andSQL:sql\n            bySelecting:^NSArray<NSObject<WCTTableCoding>*>* {\n                return [self.table getObjectsWhere:[self.targetClass identifier] == expectedObject.identifier];\n            }];\n}\n\n- (void)test_cipher_with_multi_handle\n{\n    NSObject<MigrationTestObject>* expectedObject = self.filterObjects.lastObject;\n    WCTHandle* handle = [self.database getHandle];\n    NSArray* dbObjects = [handle getObjectsOfClass:self.targetClass\n                                         fromTable:self.tableName\n                                             where:[self.targetClass identifier] == expectedObject.identifier];\n    TestCaseAssertTrue([dbObjects isEqualToArray:@[ expectedObject ]]);\n    [self.dispatch async:^{\n        WCTHandle* newHandle = [self.database getHandle];\n        NSArray* dbObjects2 = [newHandle getObjectsOfClass:self.targetClass\n                                                 fromTable:self.tableName\n                                                     where:[self.targetClass identifier] == expectedObject.identifier];\n        TestCaseAssertTrue([dbObjects2 isEqualToArray:@[ expectedObject ]]);\n    }];\n    sleep(1);\n    [self.dispatch waitUntilDone];\n}\n\n@end\n"
  },
  {
    "path": "src/objc/tests/migration/compatible/MigrateTests.mm",
    "content": "//\n// Created by qiuwenchen on 2023/7/25.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"CoreConst.h\"\n#import \"MigrationTestCase.h\"\n#import <Foundation/Foundation.h>\n\n@interface MigrateTests : MigrationTestCase\n\n@end\n\n@implementation MigrateTests\n\n- (void)setUp\n{\n    [super setUp];\n    self.skipDebugLog = YES;\n}\n\n- (void)doTestMigrate:(void (^)(void))operation\n{\n    NSArray<Class<MigrationTestSourceObject>> *sourceClasses = [MigrationTestCase allSourceClasses];\n    NSArray<Class<MigrationTestObject>> *targetClasses = [MigrationTestCase allClasses];\n    for (Class<MigrationTestSourceObject> sourceClass in sourceClasses) {\n        for (Class<MigrationTestObject> targetClass in targetClasses) {\n            self.sourceClass = sourceClass;\n            self.targetClass = targetClass;\n\n            for (int i = 0; i < 4; i++) {\n                self.isCrossDatabaseMigration = (i & 1) > 0;\n                self.needFilter = (i & 2) > 0;\n                TestCaseLog(@\"Test migrate: sourceClass %@, targetClass %@, isCrossDatabase %d, needFilter %d\",\n                            self.sourceClass,\n                            self.targetClass,\n                            self.isCrossDatabaseMigration,\n                            self.needFilter);\n                operation();\n            }\n        }\n    }\n}\n\n- (void)doTestTableAndDatabaseMigrate:(void (^)(void))operation\n{\n    self.sourceClass = [MigrationTestCase allSourceClasses].firstObject;\n    self.targetClass = [MigrationTestCase allClasses].firstObject;\n\n    for (int i = 0; i < 2; i++) {\n        self.isCrossDatabaseMigration = i > 0;\n        [self configMigration];\n        operation();\n    }\n}\n\n- (void)test_filter\n{\n    [self doTestMigrate:^{\n        [self clearData];\n        [self createTable];\n        __block int tested = 0;\n        [self.database addMigration:self.sourcePath\n                   withSourceCipher:nil\n                         withFilter:^(WCTMigrationUserInfo *info) {\n                             if ([info.table isEqualToString:self.tableName]) {\n                                 [info setSourceTable:self.sourceTableName];\n                                 if (self.needFilter) {\n                                     [info setFilterCondition:[self.sourceClass classification] == MigrationClassificationB];\n                                 }\n                                 tested++;\n                             }\n                         }];\n        WCTValue *count = [self.table getValueOnResultColumn:WCDB::Column::all().count()];\n        TestCaseAssertTrue(count != nil && count.numberValue.intValue == 0);\n        NSArray *objects = [self.table getObjects];\n        TestCaseAssertTrue(objects != nil && objects.count == 0);\n\n        TestCaseAssertTrue(tested == 1);\n    }];\n}\n\n- (void)test_migrate\n{\n    [self doTestMigrate:^{\n        [self configMigration];\n        TestCaseAssertFalse(self.database.isMigrated);\n\n        __block BOOL tableMigrated = NO;\n        __block int migrated = 0;\n        NSString *expectedTableName = self.tableName;\n        WCTTag tag = self.database.tag;\n        [self.database setNotificationWhenMigrated:^(WCTDatabase *database, WCTMigrationBaseInfo *info) {\n            TestCaseAssertEqual(tag, database.tag);\n            if (info == nil) {\n                ++migrated;\n                TestCaseAssertTrue(database.isMigrated);\n            } else if ([info.table isEqualToString:expectedTableName]) {\n                tableMigrated = YES;\n            }\n        }];\n\n        BOOL succeed;\n        do {\n            succeed = [self.database stepMigration];\n        } while (succeed && ![self.database isMigrated]);\n        TestCaseAssertTrue(succeed);\n        TestCaseAssertTrue(self.database.isMigrated);\n\n        TestCaseAssertTrue([[self.table getObjectsOrders:[self.targetClass identifier].asOrder(WCTOrderedAscending)] isEqualToArray:self.filterObjects]);\n\n        // check source table is already dropped.\n        // It's not a good practice.\n        TestCaseAssertOptionalEqual([self.sourceDatabase tableExists:self.sourceTableName], self.needFilter);\n\n        TestCaseAssertTrue(tableMigrated);\n        TestCaseAssertEqual(migrated, 1);\n\n        // Notification will receive multiple times.\n        succeed = [self.database stepMigration];\n        TestCaseAssertTrue(succeed);\n        TestCaseAssertTrue([self.database isMigrated]);\n        TestCaseAssertEqual(migrated, 2);\n    }];\n}\n\n- (void)test_auto_migrate\n{\n    [self doTestTableAndDatabaseMigrate:^{\n        TestCaseResult *tableMigrated = [TestCaseResult no];\n        TestCaseResult *migrated = [TestCaseResult no];\n        NSString *expectedTableName = self.tableName;\n        [self.database setNotificationWhenMigrated:^(WCTDatabase *database, WCTMigrationBaseInfo *info) {\n            WCDB_UNUSED(database);\n            if (info == nil) {\n                [migrated makeYES];\n            } else if ([info.table isEqualToString:expectedTableName]) {\n                [tableMigrated makeYES];\n            }\n        }];\n        [self.database enableAutoMigration:YES];\n\n        TestCaseAssertTrue([self.database canOpen]);\n\n        while (!tableMigrated.value) {\n            [NSThread sleepForTimeInterval:self.delayForTolerance];\n        }\n        while (!migrated.value) {\n            [NSThread sleepForTimeInterval:self.delayForTolerance];\n        }\n\n        TestCaseAssertResultYES(tableMigrated);\n        TestCaseAssertResultYES(migrated);\n        TestCaseAssertTrue(self.database.isMigrated);\n    }];\n}\n\n- (void)test_feature_closed_database_will_not_perform_auto_migrate\n{\n    [self doTestTableAndDatabaseMigrate:^{\n        [self.database enableAutoMigration:YES];\n\n        TestCaseAssertTrue([self.database canOpen]);\n\n        [self.database close];\n\n        [NSThread sleepForTimeInterval:self.delayForTolerance + WCDB::OperationQueueTimeIntervalForMigration];\n\n        TestCaseAssertFalse(self.database.isOpened);\n    }];\n}\n\n- (void)test_feature_auto_migrate_will_stop_due_to_error\n{\n    [self.database enableAutoCheckpoint:NO];\n    [self doTestTableAndDatabaseMigrate:^{\n        TestCaseAssertTrue([self.database canOpen]);\n\n        TestCaseCounter *numberOfFailures = [TestCaseCounter value:0];\n        weakify(self);\n        [self.database traceError:nil];\n        [self.database traceError:^(WCTError *error) {\n            strongify_or_return(self);\n            if (error.code == WCTErrorCodeIOError\n                && error.level == WCTErrorLevelWarning) {\n                [numberOfFailures increment];\n            }\n        }];\n\n        [self.database enableAutoMigration:YES];\n        TestCaseAssertTrue([self.database canOpen]);\n        [WCTDatabase simulateIOError:WCTSimulateWriteIOError];\n\n        // wait until auto migrate stopped\n        while (numberOfFailures.value < WCDB::OperationQueueTolerableFailuresForMigration);\n\n        // wait to confirm migration is stopped.\n        [NSThread sleepForTimeInterval:2 * WCDB::OperationQueueTimeIntervalForMigration];\n\n        TestCaseAssertTrue(numberOfFailures.value == WCDB::OperationQueueTolerableFailuresForMigration);\n\n        [WCTDatabase simulateIOError:WCTSimulateNoneIOError];\n    }];\n    [self.database enableAutoCheckpoint:YES];\n}\n\n- (void)test_feature_migrate_newly_created_table_after_migrated\n{\n    [self doTestTableAndDatabaseMigrate:^{\n        NSString *anotherSourceTable = @\"testAnotherSourceTable\";\n        NSString *anotherTable = @\"testAnotherTable\";\n        TestCaseAssertTrue([self.sourceDatabase createTable:anotherSourceTable withClass:self.sourceClass]);\n        [self.database addMigration:self.sourcePath\n                         withFilter:^(WCTMigrationUserInfo *info) {\n                             if ([info.table isEqualToString:anotherTable]) {\n                                 [info setSourceTable:anotherSourceTable];\n                             }\n                         }];\n        do {\n            TestCaseAssertTrue([self.database stepMigration]);\n        } while (![self.database isMigrated]);\n        TestCaseAssertTrue(self.database.isMigrated);\n\n        TestCaseAssertTrue([self.database createTable:anotherTable withClass:self.targetClass]);\n\n        // migrated status is reset.\n        TestCaseAssertFalse(self.database.isMigrated);\n\n        do {\n            TestCaseAssertTrue([self.database stepMigration]);\n        } while (![self.database isMigrated]);\n        TestCaseAssertTrue(self.database.isMigrated);\n    }];\n}\n\n@end\n"
  },
  {
    "path": "src/objc/tests/migration/compatible/MigratingCRUDTests.mm",
    "content": "//\n// Created by 陈秋文 on 2023/7/23.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"AutoIncrementMigrationObject.h\"\n#import \"AutoIncrementMigrationSourceObject.h\"\n#import \"IntegerPrimaryKeyMigrationObject.h\"\n#import \"IntegerPrimaryKeyMigrationSourceObject.h\"\n#import \"MigrationTestCase.h\"\n#import \"NormalMigrationObject.h\"\n#import \"NormalMigrationSourceObject.h\"\n#import \"Random+MigrationTestObject.h\"\n#import <Foundation/Foundation.h>\n\n@interface MigratingCRUDTests : MigrationTestCase\n\n@end\n\n@implementation MigratingCRUDTests\n\n- (void)setUp\n{\n    [super setUp];\n    self.skipDebugLog = YES;\n    self.skipFullSQLTrace = YES;\n}\n\n- (void)doTestMigration:(void (^)(void))operation\n{\n    [self doTestMigrationWithSourceClassFilter:nil targetClassFIlter:nil andOperation:operation];\n}\n\n- (void)doTestMigrationWithSourceClassFilter:(BOOL (^)(Class<MigrationTestSourceObject>))sourceFilter\n                           targetClassFIlter:(BOOL (^)(Class<MigrationTestObject>))targetFilter\n                                andOperation:(void (^)(void))operation\n{\n    NSArray<Class<MigrationTestSourceObject>>* sourceClasses = [MigrationTestCase allSourceClasses];\n    NSArray<Class<MigrationTestObject>>* targetClasses = [MigrationTestCase allClasses];\n    if (sourceFilter != nil) {\n        sourceClasses = [sourceClasses filteredArrayUsingPredicate:[NSPredicate predicateWithBlock:^BOOL(Class<MigrationTestSourceObject> sourceClass, NSDictionary<NSString*, id>*) {\n                                           return sourceFilter(sourceClass);\n                                       }]];\n    }\n    if (targetFilter != nil) {\n        targetClasses = [targetClasses filteredArrayUsingPredicate:[NSPredicate predicateWithBlock:^BOOL(Class<MigrationTestObject> targetClass, NSDictionary<NSString*, id>*) {\n                                           return targetFilter(targetClass);\n                                       }]];\n    }\n    for (Class<MigrationTestSourceObject> sourceClass in sourceClasses) {\n        for (Class<MigrationTestObject> targetClass in targetClasses) {\n            self.sourceClass = sourceClass;\n            self.targetClass = targetClass;\n\n            for (int i = 0; i < 8; i++) {\n                self.startMigration = (i & 1) > 0;\n                self.isCrossDatabaseMigration = (i & 2) > 0;\n                self.needFilter = (i & 4) > 0;\n                for (int j = 0; j < 3; j++) {\n                    if (j == 0) {\n                        self.expectMode = DatabaseTestCaseExpectAllSQLs;\n                    } else {\n                        self.expectMode = DatabaseTestCaseExpectSomeSQLs;\n                    }\n                    self.missColumnCount = j;\n                    TestCaseLog(@\"Test migration: sourceClass %@, targetClass %@, startMigration %d, isCrossDatabase %d, needFilter %d, missColumnCount %d\",\n                                self.sourceClass,\n                                self.targetClass,\n                                self.startMigration,\n                                self.isCrossDatabaseMigration,\n                                self.needFilter,\n                                self.missColumnCount);\n                    [self configMigration];\n                    operation();\n                }\n            }\n        }\n    }\n}\n\n- (void)test_insert\n{\n    TestCaseLog(@\"Start test insert\");\n    [self doTestMigration:^{\n        NSObject<MigrationTestObject>* newObject = [Random.shared migrationObjectWithClass:self.targetClass\n                                                                             andIdentifier:self.objects.lastObject.identifier + 1];\n        NSMutableArray<NSObject<MigrationTestObject>*>* expectedObjects = [NSMutableArray arrayWithArray:self.filterObjects];\n        [expectedObjects addObject:newObject];\n\n        NSMutableArray<NSString*>* sqls = [NSMutableArray array];\n        [sqls addObject:@\"BEGIN IMMEDIATE\"];\n        [sqls addObject:[NSString stringWithFormat:@\"INSERT INTO %@%@(identifier, content) VALUES(?1, ?2)\", self.schemaName, self.sourceTableName]];\n        [sqls addObject:[NSString stringWithFormat:@\"DELETE FROM %@%@ WHERE rowid == ?1\", self.schemaName, self.sourceTableName]];\n        if ([self.targetClass isAutoIncrement]) {\n            [sqls addObject:@\"INSERT INTO main.testTable(identifier, content) VALUES(?1, ?2)\"];\n        } else if ([self.targetClass hasIntegerPrimaryKey]) {\n            [sqls addObject:@\"INSERT INTO main.testTable(identifier, content, rowid) VALUES(?1, ?2, ?3)\"];\n        } else {\n            [sqls addObject:@\"SELECT max(rowid) + 1 FROM main.testTable\"];\n            [sqls addObject:@\"INSERT INTO main.testTable(identifier, content, rowid) VALUES(?1, ?2, ?3)\"];\n        }\n        [sqls addObject:@\"COMMIT\"];\n\n        [self doTestObjects:expectedObjects\n                    andSQLs:sqls\n          afterModification:^BOOL {\n              return [self.table insertObject:newObject];\n          }];\n    }];\n}\n\n- (void)test_insert_autoIncrement\n{\n    TestCaseLog(@\"Start test insert autoincrement\");\n\n    [self doTestMigrationWithSourceClassFilter:nil\n    targetClassFIlter:^BOOL(Class<MigrationTestObject> cls) {\n        return [cls isAutoIncrement];\n    }\n    andOperation:^{\n        NSObject<MigrationTestObject>* newObject = [Random.shared autoIncrementMigrationObjectWithClass:self.targetClass];\n        NSMutableArray<NSObject<MigrationTestObject>*>* expectedObjects = [NSMutableArray arrayWithArray:self.filterObjects];\n        NSObject<MigrationTestObject>* expectedNewObject = [[(Class) self.targetClass alloc] init];\n        expectedNewObject.identifier = self.objects.lastObject.identifier + 1;\n        expectedNewObject.content = newObject.content;\n        [expectedObjects addObject:expectedNewObject];\n\n        NSMutableArray<NSString*>* sqls = [NSMutableArray array];\n        [sqls addObject:@\"BEGIN IMMEDIATE\"];\n        [sqls addObject:[NSString stringWithFormat:@\"INSERT INTO %@%@(identifier, content) VALUES(?1, ?2)\", self.schemaName, self.sourceTableName]];\n        [sqls addObject:[NSString stringWithFormat:@\"DELETE FROM %@%@ WHERE rowid == ?1\", self.schemaName, self.sourceTableName]];\n        if ([self.targetClass isAutoIncrement]) {\n            [sqls addObject:@\"INSERT INTO main.testTable(identifier, content) VALUES(?1, ?2)\"];\n        } else if ([self.targetClass hasIntegerPrimaryKey]) {\n            [sqls addObject:@\"INSERT INTO main.testTable(identifier, content, rowid) VALUES(?1, ?2, ?3)\"];\n        } else {\n            [sqls addObject:@\"SELECT max(rowid) + 1 FROM main.testTable\"];\n            [sqls addObject:@\"INSERT INTO main.testTable(identifier, content, rowid) VALUES(?1, ?2, ?3)\"];\n        }\n        [sqls addObject:@\"COMMIT\"];\n\n        [self doTestObjects:expectedObjects\n                    andSQLs:sqls\n          afterModification:^BOOL {\n              return [self.table insertObject:newObject];\n          }];\n    }];\n}\n\n- (void)test_insert_or_replace\n{\n    TestCaseLog(@\"Start test insert or replace\");\n\n    auto filter = ^BOOL(Class<MigrationTestObject> cls) {\n        return [cls hasIntegerPrimaryKey];\n    };\n\n    [self doTestMigrationWithSourceClassFilter:filter\n                             targetClassFIlter:filter\n                                  andOperation:^{\n                                      NSObject<MigrationTestObject>* newObject = [Random.shared migrationObjectWithClass:self.targetClass\n                                                                                                           andIdentifier:self.filterObjects.lastObject.identifier];\n                                      NSMutableArray<NSObject<MigrationTestObject>*>* expectedObjects = [NSMutableArray arrayWithArray:self.filterObjects];\n                                      [expectedObjects removeLastObject];\n                                      [expectedObjects addObject:newObject];\n\n                                      NSMutableArray<NSString*>* sqls = [NSMutableArray array];\n                                      [sqls addObject:@\"BEGIN IMMEDIATE\"];\n                                      [sqls addObject:[NSString stringWithFormat:@\"INSERT OR REPLACE INTO %@%@(identifier, content) VALUES(?1, ?2)\", self.schemaName, self.sourceTableName]];\n                                      [sqls addObject:[NSString stringWithFormat:@\"DELETE FROM %@%@ WHERE rowid == ?1\", self.schemaName, self.sourceTableName]];\n                                      if ([self.targetClass isAutoIncrement]) {\n                                          [sqls addObject:@\"INSERT OR REPLACE INTO main.testTable(identifier, content) VALUES(?1, ?2)\"];\n                                      } else if ([self.targetClass hasIntegerPrimaryKey]) {\n                                          [sqls addObject:@\"INSERT OR REPLACE INTO main.testTable(identifier, content, rowid) VALUES(?1, ?2, ?3)\"];\n                                      } else {\n                                          [sqls addObject:@\"SELECT max(rowid) + 1 FROM main.testTable\"];\n                                          [sqls addObject:@\"INSERT OR REPLACE INTO main.testTable(identifier, content, rowid) VALUES(?1, ?2, ?3)\"];\n                                      }\n                                      [sqls addObject:@\"COMMIT\"];\n\n                                      [self doTestObjects:expectedObjects\n                                                  andSQLs:sqls\n                                        afterModification:^BOOL {\n                                            return [self.table insertOrReplaceObject:newObject];\n                                        }];\n                                  }];\n}\n\n- (void)test_insert_or_ignore\n{\n    TestCaseLog(@\"Start test insert or ignore\");\n\n    auto filter = ^BOOL(Class<MigrationTestObject> cls) {\n        return [cls hasIntegerPrimaryKey];\n    };\n\n    [self doTestMigrationWithSourceClassFilter:filter\n                             targetClassFIlter:filter\n                                  andOperation:^{\n                                      NSObject<MigrationTestObject>* newObject = [Random.shared migrationObjectWithClass:self.targetClass\n                                                                                                           andIdentifier:self.filterObjects.lastObject.identifier];\n                                      NSMutableArray<NSObject<MigrationTestObject>*>* expectedObjects = [NSMutableArray arrayWithArray:self.filterObjects];\n\n                                      NSMutableArray<NSString*>* sqls = [NSMutableArray array];\n                                      [sqls addObject:@\"BEGIN IMMEDIATE\"];\n                                      [sqls addObject:[NSString stringWithFormat:@\"INSERT OR IGNORE INTO %@%@(identifier, content) VALUES(?1, ?2)\", self.schemaName, self.sourceTableName]];\n                                      if (self.startMigration) {\n                                          [sqls addObject:[NSString stringWithFormat:@\"DELETE FROM %@%@ WHERE rowid == ?1\", self.schemaName, self.sourceTableName]];\n                                          if ([self.targetClass isAutoIncrement]) {\n                                              [sqls addObject:@\"INSERT OR IGNORE INTO main.testTable(identifier, content) VALUES(?1, ?2)\"];\n                                          } else if ([self.targetClass hasIntegerPrimaryKey]) {\n                                              [sqls addObject:@\"INSERT OR IGNORE INTO main.testTable(identifier, content, rowid) VALUES(?1, ?2, ?3)\"];\n                                          } else {\n                                              [sqls addObject:@\"SELECT max(rowid) + 1 FROM main.testTable\"];\n                                              [sqls addObject:@\"INSERT OR IGNORE INTO main.testTable(identifier, content, rowid) VALUES(?1, ?2, ?3)\"];\n                                          }\n                                      }\n                                      [sqls addObject:@\"COMMIT\"];\n\n                                      [self doTestObjects:expectedObjects\n                                                  andSQLs:sqls\n                                        afterModification:^BOOL {\n                                            return [self.table insertOrIgnoreObject:newObject];\n                                        }];\n                                  }];\n}\n\n- (void)test_insert_fail\n{\n    TestCaseLog(@\"Start test insert fail\");\n\n    auto filter = ^BOOL(Class<MigrationTestObject> cls) {\n        return [cls hasIntegerPrimaryKey];\n    };\n\n    [self doTestMigrationWithSourceClassFilter:filter\n                             targetClassFIlter:filter\n                                  andOperation:^{\n                                      NSObject<MigrationTestObject>* newObject = [Random.shared migrationObjectWithClass:self.targetClass\n                                                                                                           andIdentifier:self.filterObjects.lastObject.identifier];\n                                      TestCaseAssertFalse([self.table insertObject:newObject]);\n                                  }];\n}\n\n- (void)test_delete_with_limit\n{\n    TestCaseLog(@\"Start test delelte with limit\");\n\n    [self doTestMigration:^{\n        NSMutableArray<NSObject<MigrationTestObject>*>* expectedObjects = [NSMutableArray arrayWithArray:self.filterObjects];\n        [expectedObjects removeObjectAtIndex:2];\n\n        NSMutableArray<NSString*>* sqls = [NSMutableArray array];\n        [sqls addObject:@\"BEGIN IMMEDIATE\"];\n        int minId = expectedObjects.firstObject.identifier;\n        if ([self.targetClass hasIntegerPrimaryKey]) {\n            [sqls addObject:[NSString stringWithFormat:@\"SELECT identifier FROM temp.wcdb_union_testTable WHERE identifier > %d ORDER BY identifier ASC LIMIT 1 OFFSET 1\", minId]];\n            [sqls addObject:[NSString stringWithFormat:@\"DELETE FROM %@%@ WHERE identifier == ?1\", self.schemaName, self.sourceTableName]];\n            [sqls addObject:@\"DELETE FROM main.testTable WHERE identifier == ?1\"];\n        } else {\n            [sqls addObject:[NSString stringWithFormat:@\"SELECT rowid FROM temp.wcdb_union_testTable WHERE identifier > %d ORDER BY identifier ASC LIMIT 1 OFFSET 1\", minId]];\n            [sqls addObject:[NSString stringWithFormat:@\"DELETE FROM %@%@ WHERE rowid == ?1\", self.schemaName, self.sourceTableName]];\n            [sqls addObject:@\"DELETE FROM main.testTable WHERE rowid == ?1\"];\n        }\n        [sqls addObject:@\"COMMIT\"];\n\n        [self doTestObjects:expectedObjects\n                    andSQLs:sqls\n          afterModification:^BOOL {\n              return [self.table deleteObjectsWhere:[self.targetClass identifier] > minId\n                                             orders:[self.targetClass identifier].asOrder(WCTOrderedAscending)\n                                              limit:1\n                                             offset:1];\n          }];\n    }];\n}\n\n- (void)test_update_with_limit\n{\n    TestCaseLog(@\"Start test update with limit\");\n\n    [self doTestMigration:^{\n        NSMutableArray<NSObject<MigrationTestObject>*>* expectedObjects = [NSMutableArray arrayWithArray:self.filterObjects];\n        NSObject<MigrationTestObject>* secondObject = [expectedObjects objectAtIndex:2];\n        NSObject<MigrationTestObject>* newSecondObject = [Random.shared migrationObjectWithClass:self.targetClass andIdentifier:secondObject.identifier];\n        [expectedObjects setObject:newSecondObject atIndexedSubscript:2];\n\n        NSMutableArray<NSString*>* sqls = [NSMutableArray array];\n        [sqls addObject:@\"BEGIN IMMEDIATE\"];\n        int minId = expectedObjects.firstObject.identifier;\n        if ([self.targetClass hasIntegerPrimaryKey]) {\n            [sqls addObject:[NSString stringWithFormat:@\"SELECT identifier FROM temp.wcdb_union_testTable WHERE identifier > %d ORDER BY identifier ASC LIMIT 1 OFFSET 1\", minId]];\n            [sqls addObject:[NSString stringWithFormat:@\"UPDATE %@%@ SET content = ?1 WHERE identifier == ?2\", self.schemaName, self.sourceTableName]];\n            [sqls addObject:@\"UPDATE main.testTable SET content = ?1 WHERE identifier == ?2\"];\n        } else {\n            [sqls addObject:[NSString stringWithFormat:@\"SELECT rowid FROM temp.wcdb_union_testTable WHERE identifier > %d ORDER BY identifier ASC LIMIT 1 OFFSET 1\", minId]];\n            [sqls addObject:[NSString stringWithFormat:@\"UPDATE %@%@ SET content = ?1 WHERE rowid == ?2\", self.schemaName, self.sourceTableName]];\n            [sqls addObject:@\"UPDATE main.testTable SET content = ?1 WHERE rowid == ?2\"];\n        }\n        [sqls addObject:@\"COMMIT\"];\n\n        [self doTestObjects:expectedObjects\n                    andSQLs:sqls\n          afterModification:^BOOL {\n              return [self.table updateProperties:[self.targetClass content]\n                                         toObject:newSecondObject\n                                            where:[self.targetClass identifier] > minId\n                                           orders:[self.targetClass identifier].asOrder(WCTOrderedAscending)\n                                            limit:1\n                                           offset:1];\n          }];\n    }];\n}\n\n- (void)test_select\n{\n    TestCaseLog(@\"Start test select\");\n    [self doTestMigration:^{\n        NSObject<MigrationTestObject>* expectedObject = self.filterObjects.lastObject;\n        NSString* sql = [NSString stringWithFormat:@\"SELECT identifier, content FROM temp.wcdb_union_testTable WHERE identifier == %d ORDER BY rowid ASC\", expectedObject.identifier];\n\n        [self doTestObjects:@[ expectedObject ]\n                     andSQL:sql\n                bySelecting:^NSArray<NSObject<WCTTableCoding>*>* {\n                    return [self.table getObjectsWhere:[self.targetClass identifier] == expectedObject.identifier];\n                }];\n\n        sql = @\"SELECT identifier, content FROM temp.wcdb_union_testTable ORDER BY identifier DESC LIMIT 1\";\n\n        [self doTestObjects:@[ expectedObject ]\n                     andSQL:sql\n                bySelecting:^NSArray<NSObject<WCTTableCoding>*>* {\n                    return [self.table getObjectsOrders:[self.targetClass identifier].asOrder(WCTOrderedDescending) limit:1];\n                }];\n    }];\n}\n\n- (void)test_drop_table\n{\n    TestCaseLog(@\"Start test drop table\");\n    [self doTestMigration:^{\n        NSArray<NSString*>* sqls = @[ @\"BEGIN IMMEDIATE\",\n                                      @\"DROP TABLE IF EXISTS main.testTable\",\n                                      self.needFilter ?\n                                      [NSString stringWithFormat:@\"DELETE FROM %@%@ WHERE %@%@.classification == 1\", self.schemaName, self.sourceTableName, self.schemaName, self.sourceTableName] :\n                                      [NSString stringWithFormat:@\"DELETE FROM %@%@\", self.schemaName, self.sourceTableName],\n                                      @\"COMMIT\" ];\n\n        if (!self.needCipher)\n\n            [self doTestSQLs:sqls\n                 inOperation:^BOOL {\n                     return [self.database dropTable:self.tableName];\n                 }];\n        TestCaseAssertEqual([self.sourceTable getValueOnResultColumn:WCDB::Column::all().count()].numberValue.intValue, self.objects.count - self.filterObjects.count);\n    }];\n}\n\n- (void)test_subquery_within_update\n{\n    TestCaseLog(@\"Start test subquery within update\");\n\n    [self doTestMigration:^{\n        NSMutableArray<NSObject<MigrationTestObject>*>* expectedObjects = [NSMutableArray arrayWithArray:self.filterObjects];\n        NSObject<MigrationTestObject>* newObject = [Random.shared migrationObjectWithClass:self.targetClass andIdentifier:expectedObjects.lastObject.identifier];\n        [expectedObjects removeLastObject];\n        [expectedObjects addObject:newObject];\n\n        NSMutableArray<NSString*>* sqls = [NSMutableArray array];\n        [sqls addObject:@\"BEGIN IMMEDIATE\"];\n        if ([self.targetClass hasIntegerPrimaryKey]) {\n            [sqls addObject:@\"SELECT identifier FROM temp.wcdb_union_testTable WHERE temp.wcdb_union_testTable.identifier IN(SELECT max(identifier) FROM temp.wcdb_union_testTable)\"];\n            [sqls addObject:[NSString stringWithFormat:@\"UPDATE %@%@ SET content = ?1 WHERE identifier == ?2\", self.schemaName, self.sourceTableName]];\n            [sqls addObject:@\"UPDATE main.testTable SET content = ?1 WHERE identifier == ?2\"];\n        } else {\n            [sqls addObject:@\"SELECT rowid FROM temp.wcdb_union_testTable WHERE temp.wcdb_union_testTable.identifier IN(SELECT max(identifier) FROM temp.wcdb_union_testTable)\"];\n            [sqls addObject:[NSString stringWithFormat:@\"UPDATE %@%@ SET content = ?1 WHERE rowid == ?2\", self.schemaName, self.sourceTableName]];\n            [sqls addObject:@\"UPDATE main.testTable SET content = ?1 WHERE rowid == ?2\"];\n        }\n        [sqls addObject:@\"COMMIT\"];\n\n        [self doTestObjects:expectedObjects\n                    andSQLs:sqls\n          afterModification:^BOOL {\n              return [self.table updateProperties:[self.targetClass content]\n                                         toObject:newObject\n                                            where:[self.targetClass identifier].table(self.tableName).in(WCDB::StatementSelect().select([self.targetClass identifier].max()).from(self.tableName))];\n          }];\n    }];\n}\n\n- (void)test_subquery_within_delete\n{\n    TestCaseLog(@\"Start test subquery within delete\");\n\n    [self doTestMigration:^{\n        NSMutableArray<NSObject<MigrationTestObject>*>* expectedObjects = [NSMutableArray arrayWithArray:self.filterObjects];\n        [expectedObjects removeLastObject];\n\n        NSMutableArray<NSString*>* sqls = [NSMutableArray array];\n        [sqls addObject:@\"BEGIN IMMEDIATE\"];\n        if ([self.targetClass hasIntegerPrimaryKey]) {\n            [sqls addObject:@\"SELECT identifier FROM temp.wcdb_union_testTable WHERE temp.wcdb_union_testTable.identifier IN(SELECT max(identifier) FROM temp.wcdb_union_testTable)\"];\n            [sqls addObject:[NSString stringWithFormat:@\"DELETE FROM %@%@ WHERE identifier == ?1\", self.schemaName, self.sourceTableName]];\n            [sqls addObject:@\"DELETE FROM main.testTable WHERE identifier == ?1\"];\n        } else {\n            [sqls addObject:@\"SELECT rowid FROM temp.wcdb_union_testTable WHERE temp.wcdb_union_testTable.identifier IN(SELECT max(identifier) FROM temp.wcdb_union_testTable)\"];\n            [sqls addObject:[NSString stringWithFormat:@\"DELETE FROM %@%@ WHERE rowid == ?1\", self.schemaName, self.sourceTableName]];\n            [sqls addObject:[NSString stringWithFormat:@\"DELETE FROM main.testTable WHERE rowid == ?1\"]];\n        }\n        [sqls addObject:@\"COMMIT\"];\n\n        [self doTestObjects:expectedObjects\n                    andSQLs:sqls\n          afterModification:^BOOL {\n              return [self.table deleteObjectsWhere:[self.targetClass identifier].table(self.tableName).in(WCDB::StatementSelect().select([self.targetClass identifier].max()).from(self.tableName))];\n          }];\n    }];\n}\n\n@end\n"
  },
  {
    "path": "src/objc/tests/migration/increment/AutoIncrementDatabaseMigratingCompatibleTests.mm",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"MigrationCompatibleTestCase.h\"\n\n@interface AutoIncrementDatabaseMigratingCompatibleTests : MigrationCompatibleTestCase\n\n@end\n\n@implementation AutoIncrementDatabaseMigratingCompatibleTests\n\n- (void)setUp\n{\n    self.mode = MigrationObjectORMModeAutoIncrement;\n    self.isCrossDatabaseMigration = YES;\n    [super setUp];\n\n    TestCaseAssertTrue([self.database stepMigration]);\n    TestCaseAssertFalse([self.database isMigrated]);\n}\n\n- (void)test_insert\n{\n    [self doTestInsert];\n}\n\n- (void)test_insert_auto_increment\n{\n    [self doTestInsertAutoIncrement];\n}\n\n- (void)test_insert_or_replace\n{\n    [self doTestInsertOrReplace];\n}\n\n- (void)test_insert_or_ignore\n{\n    [self doTestInsertOrIgnore];\n}\n\n- (void)test_insert_failed_with_conflict\n{\n    [self doTestInsertFailedWithConflict];\n}\n\n- (void)test_limited_delete\n{\n    [self doTestLimitedDelete];\n}\n\n- (void)test_limited_update\n{\n    [self doTestLimitedUpdate];\n}\n\n- (void)test_select\n{\n    [self doTestSelect];\n}\n\n- (void)test_drop_table\n{\n    [self doTestDropTable];\n}\n\n- (void)test_subquery_within_delete\n{\n    [self doTestSubqueryWithinDelete];\n}\n\n- (void)test_subquery_within_update\n{\n    [self doTestSubqueryWithinUpdate];\n}\n\n@end\n"
  },
  {
    "path": "src/objc/tests/migration/increment/AutoIncrementDatabaseMigrationCompatibleTests.mm",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"MigrationCompatibleTestCase.h\"\n\n@interface AutoIncrementDatabaseMigrationCompatibleTests : MigrationCompatibleTestCase\n\n@end\n\n@implementation AutoIncrementDatabaseMigrationCompatibleTests\n\n- (void)setUp\n{\n    self.mode = MigrationObjectORMModeAutoIncrement;\n    self.isCrossDatabaseMigration = YES;\n    [super setUp];\n}\n\n- (void)test_insert\n{\n    [self doTestInsert];\n}\n\n- (void)test_insert_auto_increment\n{\n    [self doTestInsertAutoIncrement];\n}\n\n- (void)test_insert_or_replace\n{\n    [self doTestInsertOrReplace];\n}\n\n- (void)test_insert_or_ignore\n{\n    [self doTestInsertOrIgnore];\n}\n\n- (void)test_insert_failed_with_conflict\n{\n    [self doTestInsertFailedWithConflict];\n}\n\n- (void)test_limited_delete\n{\n    [self doTestLimitedDelete];\n}\n\n- (void)test_limited_update\n{\n    [self doTestLimitedUpdate];\n}\n\n- (void)test_select\n{\n    [self doTestSelect];\n}\n\n- (void)test_drop_table\n{\n    [self doTestDropTable];\n}\n\n- (void)test_subquery_within_delete\n{\n    [self doTestSubqueryWithinDelete];\n}\n\n- (void)test_subquery_within_update\n{\n    [self doTestSubqueryWithinUpdate];\n}\n\n@end\n"
  },
  {
    "path": "src/objc/tests/migration/increment/AutoIncrementTableMigratingCompatibleTests.mm",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"MigrationCompatibleTestCase.h\"\n\n@interface AutoIncrementTableMigratingCompatibleTests : MigrationCompatibleTestCase\n\n@end\n\n@implementation AutoIncrementTableMigratingCompatibleTests\n\n- (void)setUp\n{\n    self.mode = MigrationObjectORMModeAutoIncrement;\n    self.isCrossDatabaseMigration = NO;\n    [super setUp];\n\n    TestCaseAssertTrue([self.database stepMigration]);\n    TestCaseAssertFalse([self.database isMigrated]);\n}\n\n- (void)test_insert\n{\n    [self doTestInsert];\n}\n\n- (void)test_insert_auto_increment\n{\n    [self doTestInsertAutoIncrement];\n}\n\n- (void)test_insert_or_replace\n{\n    [self doTestInsertOrReplace];\n}\n\n- (void)test_insert_or_ignore\n{\n    [self doTestInsertOrIgnore];\n}\n\n- (void)test_insert_failed_with_conflict\n{\n    [self doTestInsertFailedWithConflict];\n}\n\n- (void)test_limited_delete\n{\n    [self doTestLimitedDelete];\n}\n\n- (void)test_limited_update\n{\n    [self doTestLimitedUpdate];\n}\n\n- (void)test_select\n{\n    [self doTestSelect];\n}\n\n- (void)test_drop_table\n{\n    [self doTestDropTable];\n}\n\n- (void)test_subquery_within_delete\n{\n    [self doTestSubqueryWithinDelete];\n}\n\n- (void)test_subquery_within_update\n{\n    [self doTestSubqueryWithinUpdate];\n}\n\n@end\n"
  },
  {
    "path": "src/objc/tests/migration/increment/AutoIncrementTableMigrationCompatibleTests.mm",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"MigrationCompatibleTestCase.h\"\n\n@interface AutoIncrementTableMigrationCompatibleTests : MigrationCompatibleTestCase\n\n@end\n\n@implementation AutoIncrementTableMigrationCompatibleTests\n\n- (void)setUp\n{\n    self.mode = MigrationObjectORMModeAutoIncrement;\n    self.isCrossDatabaseMigration = NO;\n    [super setUp];\n}\n\n- (void)test_insert\n{\n    [self doTestInsert];\n}\n\n- (void)test_insert_auto_increment\n{\n    [self doTestInsertAutoIncrement];\n}\n\n- (void)test_insert_or_replace\n{\n    [self doTestInsertOrReplace];\n}\n\n- (void)test_insert_or_ignore\n{\n    [self doTestInsertOrIgnore];\n}\n\n- (void)test_insert_failed_with_conflict\n{\n    [self doTestInsertFailedWithConflict];\n}\n\n- (void)test_limited_delete\n{\n    [self doTestLimitedDelete];\n}\n\n- (void)test_limited_update\n{\n    [self doTestLimitedUpdate];\n}\n\n- (void)test_select\n{\n    [self doTestSelect];\n}\n\n- (void)test_drop_table\n{\n    [self doTestDropTable];\n}\n\n- (void)test_subquery_within_delete\n{\n    [self doTestSubqueryWithinDelete];\n}\n\n- (void)test_subquery_within_update\n{\n    [self doTestSubqueryWithinUpdate];\n}\n\n@end\n"
  },
  {
    "path": "src/objc/tests/migration/model/AutoIncrementMigrationObject.h",
    "content": "//\n// Created by 陈秋文 on 2023/7/23.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"MigrationTestObject.h\"\n\n@interface AutoIncrementMigrationObject : MigrationTestObjectBase <MigrationTestObject>\n\n@end\n"
  },
  {
    "path": "src/objc/tests/migration/model/AutoIncrementMigrationObject.mm",
    "content": "//\n// Created by 陈秋文 on 2023/7/23.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"AutoIncrementMigrationObject.h\"\n#import <Foundation/Foundation.h>\n\n@implementation AutoIncrementMigrationObject\n\nWCDB_IMPLEMENTATION(AutoIncrementMigrationObject)\nWCDB_SYNTHESIZE(identifier)\nWCDB_SYNTHESIZE(content)\n\nWCDB_PRIMARY_AUTO_INCREMENT(identifier)\n\n+ (BOOL)hasIntegerPrimaryKey\n{\n    return YES;\n}\n\n+ (BOOL)isAutoIncrement\n{\n    return YES;\n}\n\n@end\n"
  },
  {
    "path": "src/objc/tests/migration/model/AutoIncrementMigrationSourceObject.h",
    "content": "//\n// Created by 陈秋文 on 2023/7/23.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"MigrationTestSourceObject.h\"\n\n@interface AutoIncrementMigrationSourceObject : MigrationTestObjectBase <MigrationTestSourceObject>\n\n@end\n"
  },
  {
    "path": "src/objc/tests/migration/model/AutoIncrementMigrationSourceObject.mm",
    "content": "//\n// Created by 陈秋文 on 2023/7/23.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"AutoIncrementMigrationSourceObject.h\"\n#import <Foundation/Foundation.h>\n\n@implementation AutoIncrementMigrationSourceObject\n\nWCDB_IMPLEMENTATION(AutoIncrementMigrationSourceObject)\nWCDB_SYNTHESIZE(identifier)\nWCDB_SYNTHESIZE(classification)\nWCDB_SYNTHESIZE(content)\n\nWCDB_PRIMARY_AUTO_INCREMENT(identifier)\nWCDB_INDEX(\"_classification\", classification)\n\n+ (BOOL)hasIntegerPrimaryKey\n{\n    return YES;\n}\n\n+ (BOOL)isAutoIncrement\n{\n    return YES;\n}\n\n@end\n"
  },
  {
    "path": "src/objc/tests/migration/model/IntegerPrimaryKeyMigrationObject.h",
    "content": "//\n// Created by 陈秋文 on 2023/7/23.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"MigrationTestObject.h\"\n\n@interface IntegerPrimaryKeyMigrationObject : MigrationTestObjectBase <MigrationTestObject>\n\n@end\n"
  },
  {
    "path": "src/objc/tests/migration/model/IntegerPrimaryKeyMigrationObject.mm",
    "content": "//\n// Created by 陈秋文 on 2023/7/23.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"IntegerPrimaryKeyMigrationObject.h\"\n#import <Foundation/Foundation.h>\n\n@implementation IntegerPrimaryKeyMigrationObject\n\nWCDB_IMPLEMENTATION(IntegerPrimaryKeyMigrationObject)\nWCDB_SYNTHESIZE(identifier)\nWCDB_SYNTHESIZE(content)\n\nWCDB_PRIMARY(identifier)\n\n+ (BOOL)hasIntegerPrimaryKey\n{\n    return YES;\n}\n\n+ (BOOL)isAutoIncrement\n{\n    return NO;\n}\n\n@end\n"
  },
  {
    "path": "src/objc/tests/migration/model/IntegerPrimaryKeyMigrationSourceObject.h",
    "content": "//\n// Created by 陈秋文 on 2023/7/23.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"MigrationTestSourceObject.h\"\n\n@interface IntegerPrimaryKeyMigrationSourceObject : MigrationTestObjectBase <MigrationTestSourceObject>\n\n@end\n"
  },
  {
    "path": "src/objc/tests/migration/model/IntegerPrimaryKeyMigrationSourceObject.mm",
    "content": "//\n// Created by 陈秋文 on 2023/7/23.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"IntegerPrimaryKeyMigrationSourceObject.h\"\n#import <Foundation/Foundation.h>\n\n@implementation IntegerPrimaryKeyMigrationSourceObject\n\nWCDB_IMPLEMENTATION(IntegerPrimaryKeyMigrationSourceObject)\nWCDB_SYNTHESIZE(identifier)\nWCDB_SYNTHESIZE(classification)\nWCDB_SYNTHESIZE(content)\n\nWCDB_PRIMARY(identifier)\nWCDB_INDEX(\"_classification\", classification)\n\n+ (BOOL)hasIntegerPrimaryKey\n{\n    return YES;\n}\n\n+ (BOOL)isAutoIncrement\n{\n    return NO;\n}\n\n@end\n"
  },
  {
    "path": "src/objc/tests/migration/model/NormalMigrationObject.h",
    "content": "//\n// Created by 陈秋文 on 2023/7/23.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"MigrationTestObject.h\"\n\n@interface NormalMigrationObject : MigrationTestObjectBase <MigrationTestObject>\n\n@end\n"
  },
  {
    "path": "src/objc/tests/migration/model/NormalMigrationObject.mm",
    "content": "//\n// Created by 陈秋文 on 2023/7/23.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"NormalMigrationObject.h\"\n#import <Foundation/Foundation.h>\n\n@implementation NormalMigrationObject\n\nWCDB_IMPLEMENTATION(NormalMigrationObject)\nWCDB_SYNTHESIZE(identifier)\nWCDB_SYNTHESIZE(content)\n\n+ (BOOL)hasIntegerPrimaryKey\n{\n    return NO;\n}\n\n+ (BOOL)isAutoIncrement\n{\n    return NO;\n}\n\n@end\n"
  },
  {
    "path": "src/objc/tests/migration/model/NormalMigrationSourceObject.h",
    "content": "//\n// Created by 陈秋文 on 2023/7/23.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"MigrationTestSourceObject.h\"\n\n@interface NormalMigrationSourceObject : MigrationTestObjectBase <MigrationTestSourceObject>\n\n@end\n"
  },
  {
    "path": "src/objc/tests/migration/model/NormalMigrationSourceObject.mm",
    "content": "//\n// Created by 陈秋文 on 2023/7/23.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"NormalMigrationSourceObject.h\"\n#import <Foundation/Foundation.h>\n\n@implementation NormalMigrationSourceObject\n\nWCDB_IMPLEMENTATION(NormalMigrationSourceObject)\nWCDB_SYNTHESIZE(identifier)\nWCDB_SYNTHESIZE(classification)\nWCDB_SYNTHESIZE(content)\n\nWCDB_INDEX(\"_classification\", classification)\n\n+ (BOOL)hasIntegerPrimaryKey\n{\n    return NO;\n}\n\n+ (BOOL)isAutoIncrement\n{\n    return NO;\n}\n\n@end\n"
  },
  {
    "path": "src/objc/tests/migration/normal/CipherDatabaseMigratingCompatibleTests.mm",
    "content": "//\n// Created by qiuwenchen on 2023/4/25.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"MigrationCompatibleTestCase.h\"\n\n@interface CipherDatabaseMigratingCompatibleTests : MigrationCompatibleTestCase\n\n@end\n\n@implementation CipherDatabaseMigratingCompatibleTests\n\n- (void)setUp\n{\n    self.mode = MigrationObjectORMModeNormal;\n    self.isCrossDatabaseMigration = YES;\n    self.needCipher = YES;\n    [super setUp];\n\n    TestCaseAssertTrue([self.database stepMigration]);\n    TestCaseAssertFalse([self.database isMigrated]);\n}\n\n- (void)test_insert\n{\n    [self doTestInsert];\n}\n\n- (void)test_limited_delete\n{\n    [self doTestLimitedDelete];\n}\n\n- (void)test_limited_update\n{\n    [self doTestLimitedUpdate];\n}\n\n- (void)test_select\n{\n    [self doTestSelect];\n}\n\n- (void)test_drop_table\n{\n    [self doTestDropTable];\n}\n\n- (void)test_subquery_within_delete\n{\n    [self doTestSubqueryWithinDelete];\n}\n\n- (void)test_subquery_within_update\n{\n    [self doTestSubqueryWithinUpdate];\n}\n\n- (NSArray<NSObject<WCTTableCoding> *> *)getAllObjects\n{\n    return [self.table getObjectsOrders:MigrationObject.identifier.asOrder(WCTOrderedAscending)];\n}\n\n@end\n"
  },
  {
    "path": "src/objc/tests/migration/normal/CipherDatabaseMigrationCompatibleTests.mm",
    "content": "//\n// Created by qiuwenchen on 2023/4/25.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"MigrationCompatibleTestCase.h\"\n\n@interface CipherDatabaseMigrationCompatibleTests : MigrationCompatibleTestCase\n\n@end\n\n@implementation CipherDatabaseMigrationCompatibleTests\n\n- (void)setUp\n{\n    self.mode = MigrationObjectORMModeNormal;\n    self.isCrossDatabaseMigration = YES;\n    self.needCipher = YES;\n    [super setUp];\n}\n\n- (void)test_insert\n{\n    [self doTestInsert];\n}\n\n- (void)test_limited_delete\n{\n    [self doTestLimitedDelete];\n}\n\n- (void)test_limited_update\n{\n    [self doTestLimitedUpdate];\n}\n\n- (void)test_select\n{\n    [self doTestSelect];\n}\n\n- (void)test_drop_table\n{\n    [self doTestDropTable];\n}\n\n- (void)test_subquery_within_delete\n{\n    [self doTestSubqueryWithinDelete];\n}\n\n- (void)test_subquery_within_update\n{\n    [self doTestSubqueryWithinUpdate];\n}\n\n- (NSArray<NSObject<WCTTableCoding> *> *)getAllObjects\n{\n    return [self.table getObjectsOrders:MigrationObject.identifier.asOrder(WCTOrderedAscending)];\n}\n\n@end\n"
  },
  {
    "path": "src/objc/tests/migration/primary/PrimaryKeyDatabaseMigratingCompatibleTests.mm",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"MigrationCompatibleTestCase.h\"\n\n@interface PrimaryKeyDatabaseMigratingCompatibleTests : MigrationCompatibleTestCase\n\n@end\n\n@implementation PrimaryKeyDatabaseMigratingCompatibleTests\n\n- (void)setUp\n{\n    self.mode = MigrationObjectORMModePrimaryKey;\n    self.isCrossDatabaseMigration = YES;\n    [super setUp];\n\n    TestCaseAssertTrue([self.database stepMigration]);\n    TestCaseAssertFalse([self.database isMigrated]);\n}\n\n- (void)test_insert\n{\n    [self doTestInsert];\n}\n\n- (void)test_insert_or_replace\n{\n    [self doTestInsertOrReplace];\n}\n\n- (void)test_insert_or_ignore\n{\n    [self doTestInsertOrIgnore];\n}\n\n- (void)test_insert_failed_with_conflict\n{\n    [self doTestInsertFailedWithConflict];\n}\n\n- (void)test_limited_delete\n{\n    [self doTestLimitedDelete];\n}\n\n- (void)test_limited_update\n{\n    [self doTestLimitedUpdate];\n}\n\n- (void)test_select\n{\n    [self doTestSelect];\n}\n\n- (void)test_drop_table\n{\n    [self doTestDropTable];\n}\n\n- (void)test_subquery_within_delete\n{\n    [self doTestSubqueryWithinDelete];\n}\n\n- (void)test_subquery_within_update\n{\n    [self doTestSubqueryWithinUpdate];\n}\n\n@end\n"
  },
  {
    "path": "src/objc/tests/migration/primary/PrimaryKeyDatabaseMigrationCompatibleTests.mm",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"MigrationCompatibleTestCase.h\"\n\n@interface PrimaryKeyDatabaseMigrationCompatibleTests : MigrationCompatibleTestCase\n\n@end\n\n@implementation PrimaryKeyDatabaseMigrationCompatibleTests\n\n- (void)setUp\n{\n    self.mode = MigrationObjectORMModePrimaryKey;\n    self.isCrossDatabaseMigration = YES;\n    [super setUp];\n}\n\n- (void)test_insert\n{\n    [self doTestInsert];\n}\n\n- (void)test_insert_or_replace\n{\n    [self doTestInsertOrReplace];\n}\n\n- (void)test_insert_or_ignore\n{\n    [self doTestInsertOrIgnore];\n}\n\n- (void)test_insert_failed_with_conflict\n{\n    [self doTestInsertFailedWithConflict];\n}\n\n- (void)test_limited_delete\n{\n    [self doTestLimitedDelete];\n}\n\n- (void)test_limited_update\n{\n    [self doTestLimitedUpdate];\n}\n\n- (void)test_select\n{\n    [self doTestSelect];\n}\n\n- (void)test_drop_table\n{\n    [self doTestDropTable];\n}\n\n- (void)test_subquery_within_delete\n{\n    [self doTestSubqueryWithinDelete];\n}\n\n- (void)test_subquery_within_update\n{\n    [self doTestSubqueryWithinUpdate];\n}\n\n@end\n"
  },
  {
    "path": "src/objc/tests/migration/primary/PrimaryKeyTableMigratingCompatibleTests.mm",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"MigrationCompatibleTestCase.h\"\n\n@interface PrimaryKeyTableMigratingCompatibleTests : MigrationCompatibleTestCase\n\n@end\n\n@implementation PrimaryKeyTableMigratingCompatibleTests\n\n- (void)setUp\n{\n    self.mode = MigrationObjectORMModePrimaryKey;\n    self.isCrossDatabaseMigration = NO;\n    [super setUp];\n\n    TestCaseAssertTrue([self.database stepMigration]);\n    TestCaseAssertFalse([self.database isMigrated]);\n}\n\n- (void)test_insert\n{\n    [self doTestInsert];\n}\n\n- (void)test_insert_or_ignore\n{\n    [self doTestInsertOrIgnore];\n}\n\n- (void)test_insert_failed_with_conflict\n{\n    [self doTestInsertFailedWithConflict];\n}\n\n- (void)test_limited_delete\n{\n    [self doTestLimitedDelete];\n}\n\n- (void)test_limited_update\n{\n    [self doTestLimitedUpdate];\n}\n\n- (void)test_select\n{\n    [self doTestSelect];\n}\n\n- (void)test_drop_table\n{\n    [self doTestDropTable];\n}\n\n- (void)test_subquery_within_delete\n{\n    [self doTestSubqueryWithinDelete];\n}\n\n- (void)test_subquery_within_update\n{\n    [self doTestSubqueryWithinUpdate];\n}\n\n@end\n"
  },
  {
    "path": "src/objc/tests/migration/primary/PrimaryKeyTableMigrationCompatibleTests.mm",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"MigrationCompatibleTestCase.h\"\n\n@interface PrimaryKeyTableMigrationCompatibleTests : MigrationCompatibleTestCase\n\n@end\n\n@implementation PrimaryKeyTableMigrationCompatibleTests\n\n- (void)setUp\n{\n    self.mode = MigrationObjectORMModePrimaryKey;\n    self.isCrossDatabaseMigration = NO;\n    [super setUp];\n}\n\n- (void)test_insert\n{\n    [self doTestInsert];\n}\n\n- (void)test_insert_or_replace\n{\n    [self doTestInsertOrReplace];\n}\n\n- (void)test_insert_or_ignore\n{\n    [self doTestInsertOrIgnore];\n}\n\n- (void)test_insert_failed_with_conflict\n{\n    [self doTestInsertFailedWithConflict];\n}\n\n- (void)test_limited_delete\n{\n    [self doTestLimitedDelete];\n}\n\n- (void)test_limited_update\n{\n    [self doTestLimitedUpdate];\n}\n\n- (void)test_select\n{\n    [self doTestSelect];\n}\n\n- (void)test_drop_table\n{\n    [self doTestDropTable];\n}\n\n- (void)test_subquery_within_delete\n{\n    [self doTestSubqueryWithinDelete];\n}\n\n- (void)test_subquery_within_update\n{\n    [self doTestSubqueryWithinUpdate];\n}\n\n@end\n"
  },
  {
    "path": "src/objc/tests/monitor/TraceTests.mm",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"TestCase.h\"\n\n@interface TraceTests : TableTestCase\n\n@end\n\n@implementation TraceTests\n\n- (void)test_trace_sql\n{\n    WCDB::StatementPragma statement = WCDB::StatementPragma().pragma(WCDB::Pragma::userVersion());\n\n    __block BOOL tested = NO;\n    [self.database traceSQL:^(WCTTag tag, NSString* path, UInt64, NSString* sql, NSString*) {\n        XCTAssertEqual(tag, self.database.tag);\n        XCTAssertTrue([path isEqualToString:self.database.path]);\n        if ([sql isEqualToString:@(statement.getDescription().data())]) {\n            tested = YES;\n        }\n    }];\n    TestCaseAssertTrue([self.database execute:statement]);\n    TestCaseAssertTrue(tested);\n\n    [self.database traceSQL:nil];\n}\n\n- (void)test_trace_performance\n{\n    TestCaseAssertTrue([self createTable]);\n\n    NSMutableArray<TestCaseObject*>* objects = [[NSMutableArray alloc] init];\n    for (int i = 0; i < 1000; i++) {\n        TestCaseObject* object = [TestCaseObject objectWithIdentifier:0 andContent:[Random.shared stringWithLength:self.database.pageSize]];\n        object.isAutoIncrement = YES;\n        [objects addObject:object];\n    }\n    __block int testCount = 0;\n\n    [self.database tracePerformance:^(WCTTag tag, NSString* path, UInt64, NSString* sql, WCTPerformanceInfo* info) {\n        XCTAssertEqual(tag, self.database.tag);\n        XCTAssertTrue([path isEqualToString:self.database.path]);\n        XCTAssertTrue(info != nil);\n        if ([sql hasPrefix:@\"COMMIT\"]) {\n            XCTAssertTrue(info.costInNanoseconds > 0);\n            XCTAssertTrue(info.tablePageWriteCount > 0);\n            XCTAssertTrue(info.indexPageWriteCount == 0);\n            XCTAssertTrue(info.overflowPageWriteCount > 0);\n            XCTAssertTrue(info.tablePageReadCount == 0);\n            XCTAssertTrue(info.indexPageReadCount == 0);\n            XCTAssertTrue(info.overflowPageReadCount == 0);\n            testCount++;\n        } else if ([sql hasPrefix:@\"CREATE INDEX\"]) {\n            XCTAssertTrue(info.costInNanoseconds > 0);\n            XCTAssertTrue(info.tablePageWriteCount == 1);\n            XCTAssertTrue(info.indexPageWriteCount > 0);\n            XCTAssertTrue(info.overflowPageWriteCount == objects.count);\n            XCTAssertTrue(info.tablePageReadCount > 0);\n            XCTAssertTrue(info.indexPageReadCount >= 0);\n            XCTAssertTrue(info.overflowPageReadCount == objects.count);\n            testCount++;\n        } else if ([sql hasPrefix:@\"SELECT\"]) {\n            XCTAssertTrue(info.costInNanoseconds > 0);\n            XCTAssertTrue(info.tablePageWriteCount == 0);\n            XCTAssertTrue(info.indexPageWriteCount == 0);\n            XCTAssertTrue(info.overflowPageWriteCount == 0);\n            testCount++;\n            if ([sql hasSuffix:@\"ORDER BY content\"]) {\n                XCTAssertTrue(info.tablePageReadCount == 0);\n                XCTAssertTrue(info.indexPageReadCount > 0);\n                XCTAssertTrue(info.overflowPageReadCount == objects.count);\n            } else {\n                XCTAssertTrue(info.tablePageReadCount > 0);\n                XCTAssertTrue(info.indexPageReadCount == 0);\n                XCTAssertTrue(info.overflowPageReadCount == objects.count);\n            }\n        }\n    }];\n    TestCaseAssertTrue([self.database insertObjects:objects intoTable:self.tableName]);\n    TestCaseAssertTrue([self.database execute:WCDB::StatementCreateIndex().createIndex(\"testIndex\").table(self.tableName).indexed(TestCaseObject.content)]);\n    TestCaseAssertTrue([self.table getObjects].count == objects.count);\n    TestCaseAssertTrue([self.table getObjectsOrders:TestCaseObject.content].count == objects.count);\n    TestCaseAssertTrue(testCount == 4);\n\n    [self.database tracePerformance:nil];\n}\n\n- (void)test_global_trace_error\n{\n    self.tableClass = TestCaseObject.class;\n\n    __block BOOL tested = NO;\n    weakify(self);\n    [WCTDatabase globalTraceError:nil];\n    [WCTDatabase globalTraceError:^(WCTError* error) {\n        strongify_or_return(self);\n        if (error.level == WCTErrorLevelError\n            && [error.path isEqualToString:self.path]\n            && error.tag == self.database.tag\n            && error.code == WCTErrorCodeError\n            && [error.sql isEqualToString:@\"SELECT 1 FROM dummy\"]) {\n            tested = YES;\n        }\n    }];\n\n    TestCaseAssertTrue([self.database canOpen]);\n\n    TestCaseAssertFalse([self.database execute:WCDB::StatementSelect().select(1).from(@\"dummy\")]);\n\n    TestCaseAssertTrue(tested);\n    [WCTDatabase globalTraceError:nil];\n}\n\n- (void)test_database_trace_error\n{\n    self.tableClass = TestCaseObject.class;\n\n    __block BOOL tested = NO;\n    weakify(self);\n    [self.database traceError:^(WCTError* error) {\n        strongify_or_return(self);\n        TestCaseAssertTrue([error.path isEqualToString:self.path]);\n        tested = YES;\n    }];\n\n    TestCaseAssertTrue([self.database canOpen]);\n\n    TestCaseAssertFalse([self.database execute:WCDB::StatementSelect().select(1).from(@\"dummy\")]);\n    TestCaseAssertTrue(tested);\n    [self.database traceError:nil];\n}\n\n- (void)test_global_trace_sql\n{\n    WCDB::StatementPragma statement = WCDB::StatementPragma().pragma(WCDB::Pragma::userVersion());\n\n    __block BOOL tested = NO;\n    [WCTDatabase globalTraceSQL:^(WCTTag tag, NSString* path, UInt64, NSString* sql, NSString*) {\n        if (![path isEqualToString:self.database.path]) {\n            return;\n        }\n        XCTAssertEqual(tag, self.database.tag);\n        if ([sql isEqualToString:@(statement.getDescription().data())]) {\n            tested = YES;\n        }\n    }];\n    TestCaseAssertTrue([self.database execute:statement]);\n    TestCaseAssertTrue(tested);\n\n    [WCTDatabase globalTraceSQL:nil];\n}\n\n- (void)test_global_trace_performance\n{\n    NSMutableArray<TestCaseObject*>* objects = [[NSMutableArray alloc] init];\n    for (int i = 0; i < 1000; i++) {\n        TestCaseObject* object = [TestCaseObject objectWithIdentifier:0 andContent:[Random.shared stringWithLength:self.database.pageSize]];\n        object.isAutoIncrement = YES;\n        [objects addObject:object];\n    }\n    __block int testCount = 0;\n    __block bool lastSQLIsInsert = false;\n    [WCTDatabase globalTracePerformance:^(WCTTag tag, NSString* path, UInt64, NSString* sql, WCTPerformanceInfo* info) {\n        if (![path isEqualToString:self.database.path]) {\n            return;\n        }\n        XCTAssertEqual(tag, self.database.tag);\n        XCTAssertTrue(info != nil);\n        if ([sql hasPrefix:@\"COMMIT\"] && lastSQLIsInsert) {\n            XCTAssertTrue(info.costInNanoseconds > 0);\n            XCTAssertTrue(info.tablePageWriteCount > 0);\n            XCTAssertTrue(info.indexPageWriteCount == 0);\n            XCTAssertTrue(info.overflowPageWriteCount > 0);\n            XCTAssertTrue(info.tablePageReadCount == 0);\n            XCTAssertTrue(info.indexPageReadCount == 0);\n            XCTAssertTrue(info.overflowPageReadCount == 0);\n            testCount++;\n        } else if ([sql hasPrefix:@\"CREATE INDEX\"]) {\n            XCTAssertTrue(info.costInNanoseconds > 0);\n            XCTAssertTrue(info.tablePageWriteCount == 1);\n            XCTAssertTrue(info.indexPageWriteCount > 0);\n            XCTAssertTrue(info.overflowPageWriteCount == objects.count);\n            XCTAssertTrue(info.tablePageReadCount > 0);\n            XCTAssertTrue(info.indexPageReadCount >= 0);\n            XCTAssertTrue(info.overflowPageReadCount == objects.count);\n            testCount++;\n        } else if ([sql hasPrefix:@\"SELECT\"]) {\n            XCTAssertTrue(info.costInNanoseconds > 0);\n            XCTAssertTrue(info.tablePageWriteCount == 0);\n            XCTAssertTrue(info.indexPageWriteCount == 0);\n            XCTAssertTrue(info.overflowPageWriteCount == 0);\n            testCount++;\n            if ([sql hasSuffix:@\"ORDER BY content\"]) {\n                XCTAssertTrue(info.tablePageReadCount == 0);\n                XCTAssertTrue(info.indexPageReadCount > 0);\n                XCTAssertTrue(info.overflowPageReadCount == objects.count);\n            } else {\n                XCTAssertTrue(info.tablePageReadCount > 0);\n                XCTAssertTrue(info.indexPageReadCount == 0);\n                XCTAssertTrue(info.overflowPageReadCount == objects.count);\n            }\n        }\n        lastSQLIsInsert = [sql hasPrefix:@\"INSERT\"];\n    }];\n    [self createTable];\n    TestCaseAssertTrue([self.database insertObjects:objects intoTable:self.tableName]);\n    TestCaseAssertTrue([self.database execute:WCDB::StatementCreateIndex().createIndex(\"testIndex\").table(self.tableName).indexed(TestCaseObject.content)]);\n    TestCaseAssertTrue([self.table getObjects].count == objects.count);\n    TestCaseAssertTrue([self.table getObjectsOrders:TestCaseObject.content].count == objects.count);\n    TestCaseAssertTrue(testCount == 4);\n\n    [WCTDatabase globalTracePerformance:nil];\n}\n\n- (void)test_global_trace_db_operation\n{\n    __block long tag = 0;\n    __block NSString* path = nil;\n    __block int openHandleCount = 0;\n    __block int tableCount = 0;\n    __block int indexCount = 0;\n    [WCTDatabase globalTraceDatabaseOperation:^(WCTDatabase* database,\n                                                WCTDatabaseOperation operation,\n                                                NSDictionary* info) {\n        switch (operation) {\n        case WCTDatabaseOperation_Create:\n            path = database.path;\n            break;\n        case WCTDatabaseOperation_SetTag:\n            tag = database.tag;\n            break;\n        case WCTDatabaseOperation_OpenHandle: {\n            openHandleCount++;\n            TestCaseAssertTrue(((NSNumber*) info[WCTDatabaseMonitorInfoKeyHandleCount]).intValue == 1);\n            TestCaseAssertTrue(((NSNumber*) info[WCTDatabaseMonitorInfoKeyHandleOpenTime]).intValue > 0);\n            TestCaseAssertTrue(((NSNumber*) info[WCTDatabaseMonitorInfoKeyHandleOpenCPUTime]).intValue > 0);\n            TestCaseAssertTrue(((NSNumber*) info[WCTDatabaseMonitorInfoKeySchemaUsage]).intValue > 0);\n            TestCaseAssertTrue(((NSNumber*) info[WCTDatabaseMonitorInfoKeyTriggerCount]).intValue == 0);\n            tableCount = ((NSNumber*) info[WCTDatabaseMonitorInfoKeyTableCount]).intValue;\n            indexCount = ((NSNumber*) info[WCTDatabaseMonitorInfoKeyIndexCount]).intValue;\n        } break;\n        }\n    }];\n\n    TestCaseAssertTrue([self createTable]);\n    TestCaseAssertTrue([self.database execute:WCDB::StatementCreateIndex()\n                                              .createIndex(\"testIndex\")\n                                              .table(self.tableName)\n                                              .indexed(TestCaseObject.content)]);\n\n    TestCaseAssertTrue(tag == self.database.tag);\n    TestCaseAssertStringEqual(path, self.database.path);\n    TestCaseAssertTrue(openHandleCount == 1);\n\n    [self.database close];\n    TestCaseAssertTrue([self.database insertObjects:[Random.shared autoIncrementTestCaseObjectsWithCount:10] intoTable:self.tableName]);\n    TestCaseAssertTrue(openHandleCount == 2);\n    TestCaseAssertTrue(tableCount == 4);\n    TestCaseAssertTrue(indexCount == 1);\n    [WCTDatabase globalTraceDatabaseOperation:nil];\n}\n\n- (void)test_global_trace_busy\n{\n    __block uint64_t testTid = 0;\n    [WCTDatabase\n    globalTraceBusy:^(WCTTag tag, NSString* path, uint64_t tid, NSString* sql) {\n        XCTAssertTrue(tag == self.database.tag);\n        XCTAssertTrue([path isEqualToString:self.database.path]);\n        XCTAssertTrue([sql isEqualToString:@\"INSERT INTO testTable(identifier, content) VALUES(?1, ?2)\"]);\n        testTid = tid;\n    }\n        withTimeOut:0.1];\n\n    XCTAssertTrue([self createTable]);\n\n    __block uint64_t dispatchTid = 0;\n    NSArray* objects = [Random.shared testCaseObjectsWithCount:100000 startingFromIdentifier:0];\n    [self.dispatch async:^{\n        pthread_threadid_np(nullptr, &dispatchTid);\n        XCTAssertTrue([self.table insertObjects:objects]);\n    }];\n    usleep(10000);\n    XCTAssertTrue([self.table insertObject:[Random.shared autoIncrementTestCaseObject]]);\n    [self.dispatch waitUntilDone];\n    XCTAssertTrue(testTid != 0 && testTid == dispatchTid);\n    [WCTDatabase globalTraceBusy:nil withTimeOut:0];\n}\n\n@end\n"
  },
  {
    "path": "src/objc/tests/monitor/VersionTests.mm",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"TestCase.h\"\n\n@interface VersionTests : BaseTestCase\n\n@end\n\n@implementation VersionTests\n\n- (void)test\n{\n    TestCaseLog(@\"Version %@\", WCTDatabase.version);\n    TestCaseLog(@\"SourceId %@\", WCTDatabase.sourceId);\n}\n\n@end\n"
  },
  {
    "path": "src/objc/tests/orm/ORMTests.mm",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"AdditionalORMObject+WCTTableCoding.h\"\n#import \"AdditionalORMObject.h\"\n#import \"AllTypesObject+WCTTableCoding.h\"\n#import \"AllTypesObject.h\"\n#import \"ColumnConstraintAutoIncrement+WCTTableCoding.h\"\n#import \"ColumnConstraintAutoIncrement.h\"\n#import \"ColumnConstraintAutoIncrementAsc+WCTTableCoding.h\"\n#import \"ColumnConstraintAutoIncrementAsc.h\"\n#import \"ColumnConstraintCheck+WCTTableCoding.h\"\n#import \"ColumnConstraintCheck.h\"\n#import \"ColumnConstraintDefault+WCTTableCoding.h\"\n#import \"ColumnConstraintDefault.h\"\n#import \"ColumnConstraintEnablePrimaryAutoIncrement+WCTTableCoding.h\"\n#import \"ColumnConstraintNotNull+WCTTableCoding.h\"\n#import \"ColumnConstraintNotNull.h\"\n#import \"ColumnConstraintPrimary+WCTTableCoding.h\"\n#import \"ColumnConstraintPrimary.h\"\n#import \"ColumnConstraintPrimaryAsc+WCTTableCoding.h\"\n#import \"ColumnConstraintPrimaryAsc.h\"\n#import \"ColumnConstraintPrimaryDesc+WCTTableCoding.h\"\n#import \"ColumnConstraintPrimaryDesc.h\"\n#import \"ColumnConstraintUnique+WCTTableCoding.h\"\n#import \"ColumnConstraintUnique.h\"\n#import \"DropIndexObject+WCTTableCoding.h\"\n#import \"DropIndexObject.h\"\n#import \"IndexObject+WCTTableCoding.h\"\n#import \"IndexObject.h\"\n#import \"NewPropertyObject.h\"\n#import \"NewRemapObject+WCTTableCoding.h\"\n#import \"NewRemapObject.h\"\n#import \"NewlyCreatedTableIndexObject+WCTTableCoding.h\"\n#import \"NewlyCreatedTableIndexObject.h\"\n#import \"OldRemapObject+WCTTableCoding.h\"\n#import \"OldRemapObject.h\"\n#import \"PropertyObject+WCTTableCoding.h\"\n#import \"PropertyObject.h\"\n#import \"TableConstraintObject+WCTTableCoding.h\"\n#import \"TableConstraintObject.h\"\n#import \"TestCase.h\"\n#import \"VirtualTableFTS4Object+WCTTableCoding.h\"\n#import \"VirtualTableFTS4Object.h\"\n#import \"VirtualTableFTS5Object+WCTTableCoding.h\"\n#import \"VirtualTableFTS5Object.h\"\n\n@interface ORMTests : TableTestCase\n\n@end\n\n@implementation ORMTests\n\n- (void)setUp\n{\n    [super setUp];\n    self.expectMode = DatabaseTestCaseExpectSomeSQLs;\n}\n\n- (void)doTestCreateTableAndIndexSQLsAsExpected:(NSArray<NSString*>*)expected\n{\n    TestCaseAssertTrue(expected != nil);\n    NSMutableArray* sqls = [NSMutableArray array];\n    [sqls addObject:@\"BEGIN IMMEDIATE\"];\n    [sqls addObjectsFromArray:expected];\n    [sqls addObject:@\"COMMIT\"];\n    [self doTestSQLs:sqls\n         inOperation:^BOOL {\n             return [self createTable];\n         }];\n}\n\n- (void)doTestCreateVirtualTableSQLAsExpected:(NSString*)expected\n{\n    TestCaseAssertTrue(expected != nil);\n    self.expectMode = DatabaseTestCaseExpectFirstFewSQLs;\n    self.isVirtualTable = YES;\n    [self doTestSQLs:@[ expected ]\n         inOperation:^BOOL {\n             return [self createTable];\n         }];\n}\n\n#pragma mark - property\n- (void)test_property\n{\n    self.tableClass = PropertyObject.class;\n#ifndef WCDB_WECHAT_IOS\n    NSArray<NSString*>* expected = @[ @\"CREATE TABLE IF NOT EXISTS testTable(property INTEGER, differentName INTEGER)\" ];\n#else\n    NSArray<NSString*>* expected = @[ @\"CREATE TABLE IF NOT EXISTS testTable(differentName INTEGER, property INTEGER)\" ];\n#endif\n    [self doTestCreateTableAndIndexSQLsAsExpected:expected];\n}\n\n- (void)test_all_types\n{\n    self.tableClass = AllTypesObject.class;\n#ifndef WCDB_WECHAT_IOS\n    NSArray<NSString*>* expected = @[ @\"CREATE TABLE IF NOT EXISTS testTable(type TEXT PRIMARY KEY, enumNSValue INTEGER, optionNSValue INTEGER, enumValue INTEGER, enumClassValue INTEGER, literalEnumValue INTEGER, trueOrFalseValue INTEGER, yesOrNoValue INTEGER, intValue INTEGER, unsignedIntValue INTEGER, int32Value INTEGER, int64Value INTEGER, uint32Value INTEGER, uint64Value INTEGER, integerValue INTEGER, uintegerValue INTEGER, floatValue REAL, doubleValue REAL, numberValue REAL, dateValue REAL, stringValue TEXT, dataValue BLOB, codingValue BLOB, renamedGSValue INTEGER)\" ];\n#else\n    NSArray<NSString*>* expected = @[ @\"CREATE TABLE IF NOT EXISTS testTable(codingValue BLOB, dataValue BLOB, dateValue REAL, doubleValue REAL, enumClassValue INTEGER, enumNSValue INTEGER, enumValue INTEGER, floatValue REAL, int32Value INTEGER, int64Value INTEGER, integerValue INTEGER, intValue INTEGER, literalEnumValue INTEGER, numberValue REAL, optionNSValue INTEGER, renamedGSValue INTEGER, stringValue TEXT, trueOrFalseValue INTEGER, type TEXT PRIMARY KEY, uint32Value INTEGER, uint64Value INTEGER, uintegerValue INTEGER, unsignedIntValue INTEGER, yesOrNoValue INTEGER)\" ];\n#endif\n    [self doTestCreateTableAndIndexSQLsAsExpected:expected];\n\n    AllTypesObject* maxObject = [AllTypesObject maxObject];\n    TestCaseAssertTrue([self.table insertObject:maxObject]);\n\n    AllTypesObject* minObject = [AllTypesObject minObject];\n    TestCaseAssertTrue([self.table insertObject:minObject]);\n\n    AllTypesObject* emptyObject = [AllTypesObject emptyObject];\n    TestCaseAssertTrue([self.table insertObject:emptyObject]);\n\n    AllTypesObject* nilObject = [AllTypesObject nilObject];\n    TestCaseAssertTrue([self.table insertObject:nilObject]);\n\n    AllTypesObject* selectedMaxObject = [self.table getObjectWhere:AllTypesObject.type == maxObject.type];\n    TestCaseAssertTrue([selectedMaxObject isEqual:maxObject]);\n\n    AllTypesObject* selectedMinObject = [self.table getObjectWhere:AllTypesObject.type == minObject.type];\n    TestCaseAssertTrue([selectedMinObject isEqual:minObject]);\n\n    AllTypesObject* selectedEmptyObject = [self.table getObjectWhere:AllTypesObject.type == emptyObject.type];\n    TestCaseAssertTrue([selectedEmptyObject isEqual:emptyObject]);\n\n    AllTypesObject* selectedNilObject = [self.table getObjectWhere:AllTypesObject.type == nilObject.type];\n    TestCaseAssertTrue([selectedNilObject isEqual:nilObject]);\n}\n\n- (void)test_all_properties\n{\n    TestCaseAssertEqual(2, PropertyObject.allProperties.size());\n    TestCaseAssertSQLEqual(PropertyObject.allProperties, @\"property, differentName\");\n}\n\n#pragma mark - column constraint\n- (void)test_column_constraint_primary\n{\n    self.tableClass = ColumnConstraintPrimary.class;\n    NSArray<NSString*>* expected = @[\n        @\"CREATE TABLE IF NOT EXISTS testTable(value INTEGER PRIMARY KEY)\",\n    ];\n    [self doTestCreateTableAndIndexSQLsAsExpected:expected];\n}\n\n- (void)test_new_column\n{\n    self.tableClass = ColumnConstraintPrimary.class;\n    [self createTable];\n    [self.database execute:WCDB::StatementSelect().select({ WCDB::Column(\"newColumn1\").table(\"\").schema(\"newSchema\"), WCDB::Column(\"newColumn2\").table(\"newtable\") }).from(self.tableName)];\n}\n\n- (void)test_column_constraint_primary_asc\n{\n    self.tableClass = ColumnConstraintPrimaryAsc.class;\n    NSArray<NSString*>* expected = @[\n        @\"CREATE TABLE IF NOT EXISTS testTable(value INTEGER PRIMARY KEY ASC)\",\n    ];\n    [self doTestCreateTableAndIndexSQLsAsExpected:expected];\n}\n\n- (void)test_column_constraint_primary_desc\n{\n    self.tableClass = ColumnConstraintPrimaryDesc.class;\n    NSArray<NSString*>* expected = @[\n        @\"CREATE TABLE IF NOT EXISTS testTable(value INTEGER PRIMARY KEY DESC)\",\n    ];\n    [self doTestCreateTableAndIndexSQLsAsExpected:expected];\n}\n\n- (void)test_column_constraint_auto_increment\n{\n    self.tableClass = ColumnConstraintAutoIncrement.class;\n    NSArray<NSString*>* expected = @[\n        @\"CREATE TABLE IF NOT EXISTS testTable(value INTEGER PRIMARY KEY AUTOINCREMENT)\",\n    ];\n    [self doTestCreateTableAndIndexSQLsAsExpected:expected];\n}\n\n- (void)test_column_constraint_auto_increment_asc\n{\n    self.tableClass = ColumnConstraintAutoIncrementAsc.class;\n    NSArray<NSString*>* expected = @[\n        @\"CREATE TABLE IF NOT EXISTS testTable(value INTEGER PRIMARY KEY ASC AUTOINCREMENT)\",\n    ];\n    [self doTestCreateTableAndIndexSQLsAsExpected:expected];\n}\n\n- (void)test_column_constraint_unique\n{\n    self.tableClass = ColumnConstraintUnique.class;\n    NSArray<NSString*>* expected = @[\n        @\"CREATE TABLE IF NOT EXISTS testTable(value INTEGER UNIQUE)\",\n    ];\n    [self doTestCreateTableAndIndexSQLsAsExpected:expected];\n}\n\n- (void)test_column_constraint_default\n{\n    self.tableClass = ColumnConstraintDefault.class;\n    NSArray<NSString*>* expected = @[\n        @\"CREATE TABLE IF NOT EXISTS testTable(value INTEGER DEFAULT 1)\",\n    ];\n    [self doTestCreateTableAndIndexSQLsAsExpected:expected];\n}\n\n- (void)test_column_constraint_check\n{\n    self.tableClass = ColumnConstraintCheck.class;\n    NSArray<NSString*>* expected = @[\n        @\"CREATE TABLE IF NOT EXISTS testTable(value INTEGER CHECK(value > 1))\",\n    ];\n    [self doTestCreateTableAndIndexSQLsAsExpected:expected];\n}\n\n- (void)test_column_constraint_primary_enable_auto_increment_for_existing_table\n{\n    [self doTestPrimaryEnableAutoIncrement:@\"create table testTable(key integer primary key, content text)\"\n                                 expecting:true];\n\n    [self doTestPrimaryEnableAutoIncrement:@\"create table testTable(key integer primary key default 0, content text)\"\n                                 expecting:true];\n\n    [self doTestPrimaryEnableAutoIncrement:@\"create table testTable(content text, key integer primary key)\"\n                                 expecting:true];\n\n    [self doTestPrimaryEnableAutoIncrement:@\"create table testTable(content text, key integer primary key unique)\"\n                                 expecting:true];\n\n    [self doTestPrimaryEnableAutoIncrement:@\"create table testTable(content text, key integer, primary key(key))\"\n                                 expecting:true];\n\n    [self doTestPrimaryEnableAutoIncrement:@\"create table testTable(content text, key integer, primary key(key, content))\"\n                                 expecting:false];\n\n    [self doTestPrimaryEnableAutoIncrement:@\"create table testTable(content text, key int primary key)\"\n                                 expecting:false];\n\n    [self doTestPrimaryEnableAutoIncrement:@\"create table testTable(content text, key int primary key) without rowid\"\n                                 expecting:false];\n}\n\n- (void)doTestPrimaryEnableAutoIncrement:(NSString*)sql expecting:(BOOL)result\n{\n    [self.database removeFiles];\n    TestCaseAssertTrue([self.database rawExecute:sql]);\n\n    ColumnConstraintEnablePrimaryAutoIncrement* obj = [[ColumnConstraintEnablePrimaryAutoIncrement alloc] init];\n    obj.isAutoIncrement = true;\n    if (![sql containsString:@\"without rowid\"]) {\n        TestCaseAssertTrue([self.database insertObject:obj intoTable:self.tableName]);\n        TestCaseAssertTrue(obj.lastInsertedRowID == 1);\n    }\n\n    TestCaseAssertEqual([self.database createTable:self.tableName withClass:ColumnConstraintEnablePrimaryAutoIncrement.class], result);\n\n    if (result) {\n        TestCaseAssertTrue([self.database updateTable:WCTSequence.tableName setProperty:WCTSequence.seq toValue:@100 where:WCTSequence.name == self.tableName]);\n        TestCaseAssertTrue([self.database insertObject:obj intoTable:self.tableName]);\n        TestCaseAssertEqual(obj.lastInsertedRowID, 101);\n\n        TestCaseAssertTrue([self.database deleteFromTable:self.tableName where:ColumnConstraintEnablePrimaryAutoIncrement.key == 101]);\n        TestCaseAssertTrue([self.database insertObject:obj intoTable:self.tableName]);\n        TestCaseAssertEqual(obj.lastInsertedRowID, 102);\n\n        TestCaseAssertTrue([self.database updateTable:WCTSequence.tableName setProperty:WCTSequence.seq toValue:@1000 where:WCTSequence.name == self.tableName]);\n\n        [self.database close];\n        TestCaseAssertTrue([self.database insertObject:obj intoTable:self.tableName]);\n        TestCaseAssertEqual(obj.lastInsertedRowID, 1001);\n    }\n}\n\n- (void)test_config_auto_increment_whilt_executing\n{\n    TestCaseAssertTrue([self.database rawExecute:@\"create table testTable(key integer primary key, content text)\"]);\n\n    WCDB::StatementInsert insert = WCDB::StatementInsert().insertIntoTable(self.tableName);\n    insert.column(ColumnConstraintEnablePrimaryAutoIncrement.content).value(\"abc\");\n\n    WCTHandle* handle = [self.database getHandle];\n    WCTPreparedStatement* prepareStatement = [handle getOrCreatePreparedStatement:insert];\n    TestCaseAssertNotNil(prepareStatement);\n\n    [self.dispatch async:^{\n        WCTHandle* newHandle = [self.database getHandle];\n        WCTPreparedStatement* newPrepareStatement = [newHandle getOrCreatePreparedStatement:insert];\n        TestCaseAssertNotNil(newPrepareStatement);\n        TestCaseAssertNotEqual(prepareStatement, newPrepareStatement);\n        sleep(2);\n        TestCaseAssertTrue([newPrepareStatement step]);\n        TestCaseAssertTrue([newHandle getLastInsertedRowID] == 102);\n    }];\n    sleep(1);\n    TestCaseAssertTrue([self.database createTable:self.tableName withClass:ColumnConstraintEnablePrimaryAutoIncrement.class]);\n\n    TestCaseAssertTrue([self.database updateTable:WCTSequence.tableName setProperty:WCTSequence.seq toValue:@100 where:WCTSequence.name == self.tableName]);\n\n    TestCaseAssertTrue([prepareStatement step]);\n    TestCaseAssertTrue([handle getLastInsertedRowID] == 101);\n    [self.dispatch waitUntilDone];\n}\n\n#pragma mark - index\n- (void)test_index\n{\n    self.tableClass = IndexObject.class;\n    self.tableName = @\"'test@Table'\";\n    NSArray<NSString*>* expected = @[\n#ifndef WCDB_WECHAT_IOS\n        @\"CREATE TABLE IF NOT EXISTS 'test@Table'(index_ INTEGER, indexAsc INTEGER, indexDesc INTEGER, uniqueIndex INTEGER, uniqueIndexAsc INTEGER, uniqueIndexDesc INTEGER, multiIndex INTEGER, multiIndexAsc INTEGER, multiIndexDesc INTEGER)\",\n#else\n        @\"CREATE TABLE IF NOT EXISTS 'test@Table'(index_ INTEGER, indexAsc INTEGER, indexDesc INTEGER, multiIndex INTEGER, multiIndexAsc INTEGER, multiIndexDesc INTEGER, uniqueIndex INTEGER, uniqueIndexAsc INTEGER, uniqueIndexDesc INTEGER)\",\n#endif\n        @\"CREATE INDEX IF NOT EXISTS 'test@Table_index' ON 'test@Table'(index_)\",\n        @\"CREATE INDEX IF NOT EXISTS 'test@Table_index_asc' ON 'test@Table'(indexAsc ASC)\",\n        @\"CREATE INDEX IF NOT EXISTS 'test@Table_index_desc' ON 'test@Table'(indexDesc DESC)\",\n        @\"CREATE INDEX IF NOT EXISTS 'test@Table_multi_index' ON 'test@Table'(multiIndex, multiIndexAsc ASC, multiIndexDesc DESC)\",\n        @\"CREATE UNIQUE INDEX IF NOT EXISTS 'test@Table_unique_index' ON 'test@Table'(uniqueIndex)\",\n        @\"CREATE UNIQUE INDEX IF NOT EXISTS 'test@Table_unique_index_asc' ON 'test@Table'(uniqueIndexAsc ASC)\",\n        @\"CREATE UNIQUE INDEX IF NOT EXISTS 'test@Table_unique_index_desc' ON 'test@Table'(uniqueIndexDesc DESC)\",\n    ];\n    [self doTestCreateTableAndIndexSQLsAsExpected:expected];\n\n    [self dropTable];\n    self.tableName = nil;\n    expected = @[\n#ifndef WCDB_WECHAT_IOS\n        @\"CREATE TABLE IF NOT EXISTS testTable(index_ INTEGER, indexAsc INTEGER, indexDesc INTEGER, uniqueIndex INTEGER, uniqueIndexAsc INTEGER, uniqueIndexDesc INTEGER, multiIndex INTEGER, multiIndexAsc INTEGER, multiIndexDesc INTEGER)\",\n#else\n        @\"CREATE TABLE IF NOT EXISTS testTable(index_ INTEGER, indexAsc INTEGER, indexDesc INTEGER, multiIndex INTEGER, multiIndexAsc INTEGER, multiIndexDesc INTEGER, uniqueIndex INTEGER, uniqueIndexAsc INTEGER, uniqueIndexDesc INTEGER)\",\n#endif\n        @\"CREATE INDEX IF NOT EXISTS testTable_index ON testTable(index_)\",\n        @\"CREATE INDEX IF NOT EXISTS testTable_index_asc ON testTable(indexAsc ASC)\",\n        @\"CREATE INDEX IF NOT EXISTS testTable_index_desc ON testTable(indexDesc DESC)\",\n        @\"CREATE INDEX IF NOT EXISTS testTable_multi_index ON testTable(multiIndex, multiIndexAsc ASC, multiIndexDesc DESC)\",\n        @\"CREATE UNIQUE INDEX IF NOT EXISTS testTable_unique_index ON testTable(uniqueIndex)\",\n        @\"CREATE UNIQUE INDEX IF NOT EXISTS testTable_unique_index_asc ON testTable(uniqueIndexAsc ASC)\",\n        @\"CREATE UNIQUE INDEX IF NOT EXISTS testTable_unique_index_desc ON testTable(uniqueIndexDesc DESC)\",\n    ];\n    [self doTestCreateTableAndIndexSQLsAsExpected:expected];\n}\n\n#pragma mark - table constraint\n- (void)test_table_constraint\n{\n    self.tableClass = TableConstraintObject.class;\n    NSArray<NSString*>* expected = @[ @\"CREATE TABLE IF NOT EXISTS testTable(multiPrimary INTEGER, multiPrimaryAsc INTEGER, multiPrimaryDesc INTEGER, multiUnique INTEGER, multiUniqueAsc INTEGER, multiUniqueDesc INTEGER, CONSTRAINT multi_primary PRIMARY KEY(multiPrimary, multiPrimaryAsc ASC, multiPrimaryDesc DESC), CONSTRAINT multi_unique UNIQUE(multiUnique, multiUniqueAsc ASC, multiUniqueDesc DESC))\" ];\n    [self doTestCreateTableAndIndexSQLsAsExpected:expected];\n}\n\n#pragma mark - virtual table\n- (void)test_virtual_table_fts3\n{\n    self.tableClass = VirtualTableFTS4Object.class;\n    [self.database addTokenizer:WCTTokenizerOneOrBinary];\n    NSString* expected = @\"CREATE VIRTUAL TABLE IF NOT EXISTS testTable USING fts4(tokenize = wcdb_one_or_binary, content='contentTable', identifier INTEGER, content TEXT, notindexed=identifier)\";\n    [self doTestCreateVirtualTableSQLAsExpected:expected];\n}\n\n- (void)test_virtual_table_fts5\n{\n    self.tableClass = VirtualTableFTS5Object.class;\n    NSString* expected = @\"CREATE VIRTUAL TABLE IF NOT EXISTS testTable USING fts5(tokenize = 'porter', content='contentTable', identifier UNINDEXED, content)\";\n    [self doTestCreateVirtualTableSQLAsExpected:expected];\n}\n\n#pragma mark - addtional object relational mapping\n- (void)test_additional_orm\n{\n    self.tableClass = AdditionalORMObject.class;\n    NSArray<NSString*>* expected = @[ @\"CREATE TABLE IF NOT EXISTS testTable(value INTEGER PRIMARY KEY ON CONFLICT ABORT, CONSTRAINT table_constraint CHECK(value > 10))\",\n                                      @\"CREATE INDEX IF NOT EXISTS testTable_index ON testTable(value ASC)\" ];\n    [self doTestCreateTableAndIndexSQLsAsExpected:expected];\n}\n\n#pragma mark - remap\n- (void)test_remap\n{\n    self.tableName = @\"'test@Table'\";\n    {\n        self.tableClass = OldRemapObject.class;\n        NSArray<NSString*>* expected = @[ @\"CREATE TABLE IF NOT EXISTS 'test@Table'(value INTEGER)\" ];\n        [self doTestCreateTableAndIndexSQLsAsExpected:expected];\n    }\n    // remap\n    {\n        self.tableClass = NewRemapObject.class;\n        NSArray<NSString*>* expected = @[ @\"PRAGMA main.table_info('test@Table')\", @\"ALTER TABLE main.'test@Table' ADD COLUMN newValue INTEGER\", @\"CREATE INDEX IF NOT EXISTS 'test@Table_index' ON 'test@Table'(value)\" ];\n        [self doTestCreateTableAndIndexSQLsAsExpected:expected];\n    }\n    [self dropTable];\n    self.tableName = nil;\n    {\n        self.tableClass = OldRemapObject.class;\n        NSArray<NSString*>* expected = @[ @\"CREATE TABLE IF NOT EXISTS testTable(value INTEGER)\" ];\n        [self doTestCreateTableAndIndexSQLsAsExpected:expected];\n    }\n    // remap\n    {\n        self.tableClass = NewRemapObject.class;\n        NSArray<NSString*>* expected = @[ @\"PRAGMA main.table_info('testTable')\", @\"ALTER TABLE main.testTable ADD COLUMN newValue INTEGER\", @\"CREATE INDEX IF NOT EXISTS testTable_index ON testTable(value)\" ];\n        [self doTestCreateTableAndIndexSQLsAsExpected:expected];\n    }\n}\n\n- (void)test_remap_with_extra_actions\n{\n    {\n        self.tableClass = OldRemapObject.class;\n        NSArray<NSString*>* expected = @[ @\"CREATE TABLE IF NOT EXISTS testTable(value INTEGER)\" ];\n        [self doTestCreateTableAndIndexSQLsAsExpected:expected];\n    }\n    // remap\n    {\n        self.tableClass = NewlyCreatedTableIndexObject.class;\n        NSArray<NSString*>* expected = @[ @\"PRAGMA main.table_info('testTable')\", @\"ALTER TABLE main.testTable ADD COLUMN newValue INTEGER\" ];\n        [self doTestCreateTableAndIndexSQLsAsExpected:expected];\n    }\n    TestCaseAssertTrue([self dropTable]);\n    // newly create\n    {\n#ifndef WCDB_WECHAT_IOS\n        NSArray<NSString*>* expected = @[ @\"CREATE TABLE IF NOT EXISTS testTable(value INTEGER, newValue INTEGER)\", @\"CREATE INDEX IF NOT EXISTS testTable_index ON testTable(value)\" ];\n#else\n        NSArray<NSString*>* expected = @[ @\"CREATE TABLE IF NOT EXISTS testTable(newValue INTEGER, value INTEGER)\", @\"CREATE INDEX IF NOT EXISTS testTable_index ON testTable(value)\" ];\n#endif\n        [self doTestCreateTableAndIndexSQLsAsExpected:expected];\n    }\n    // drop index\n    {\n        self.tableClass = DropIndexObject.class;\n        NSArray<NSString*>* expected = @[ @\"PRAGMA main.table_info('testTable')\", @\"DROP INDEX IF EXISTS testTable_index\" ];\n        [self doTestCreateTableAndIndexSQLsAsExpected:expected];\n    }\n}\n\n#pragma mark - auto add column\n- (void)test_auto_add_column\n{\n    NSString* fakeTable = @\"fakeTable\";\n    TestCaseAssertTrue([self.database createTable:fakeTable withClass:NewPropertyObject.class]);\n\n    [self testAutoAddColumn:NewPropertyObject.insertValue\n                  isSucceed:YES\n                  byExecute:^bool {\n                      return [self.database insertObject:[[NewPropertyObject alloc] init] intoTable:self.tableName];\n                  }];\n\n    [self testAutoAddColumn:NewPropertyObject.updateValue\n                  isSucceed:YES\n                  byExecute:^bool {\n                      return [self.database updateTable:self.tableName setProperty:NewPropertyObject.updateValue toValue:@(1)];\n                  }];\n\n    [self testAutoAddColumn:NewPropertyObject.deleteValue\n                  isSucceed:YES\n                  byExecute:^bool {\n                      return [self.database deleteFromTable:self.tableName where:NewPropertyObject.deleteValue == 1];\n                  }];\n\n    [self testAutoAddColumn:NewPropertyObject.deleteValue\n                  isSucceed:YES\n                  byExecute:^bool {\n                      return [self.database deleteFromTable:self.tableName where:NewPropertyObject.deleteValue.table(self.tableName) == 1];\n                  }];\n\n    [self testAutoAddColumn:NewPropertyObject.deleteValue\n                  isSucceed:NO\n                  byExecute:^bool {\n                      return [self.database deleteFromTable:self.tableName where:NewPropertyObject.deleteValue.table(fakeTable) == 1];\n                  }];\n\n    [self testAutoAddColumn:NewPropertyObject.deleteValue\n                  isSucceed:NO\n                  byExecute:^bool {\n                      return [self.database deleteFromTable:self.tableName where:NewPropertyObject.deleteValue.table(self.tableName).schema(\"notExistSchema\") == 1];\n                  }];\n\n    [self testAutoAddColumn:NewPropertyObject.selectValue\n                  isSucceed:YES\n                  byExecute:^bool {\n                      return [self.database getColumnOnResultColumn:NewPropertyObject.selectValue fromTable:self.tableName] != nil;\n                  }];\n\n    [self testAutoAddColumn:NewPropertyObject.selectValue\n                  isSucceed:YES\n                  byExecute:^bool {\n                      return [self.database getColumnOnResultColumn:NewPropertyObject.insertValue fromTable:self.tableName where:NewPropertyObject.selectValue == 1] != nil;\n                  }];\n\n    [self testAutoAddColumn:NewPropertyObject.selectValue\n                  isSucceed:YES\n                  byExecute:^bool {\n                      return [self.database getColumnOnResultColumn:NewPropertyObject.insertValue fromTable:self.tableName orders:NewPropertyObject.selectValue] != nil;\n                  }];\n\n    [self testAutoAddColumn:NewPropertyObject.selectValue\n                  isSucceed:YES\n                  byExecute:^bool {\n                      return [self.database getColumnOnResultColumn:NewPropertyObject.insertValue fromTable:self.tableName orders:NewPropertyObject.selectValue.table(self.tableName)] != nil;\n                  }];\n\n    [self testAutoAddColumn:NewPropertyObject.selectValue\n                  isSucceed:NO\n                  byExecute:^bool {\n                      return [self.database getColumnOnResultColumn:NewPropertyObject.insertValue fromTable:self.tableName orders:NewPropertyObject.selectValue.table(fakeTable)] != nil;\n                  }];\n\n    [self testAutoAddColumn:NewPropertyObject.selectValue\n                  isSucceed:NO\n                  byExecute:^bool {\n                      return [self.database getColumnOnResultColumn:NewPropertyObject.insertValue fromTable:self.tableName orders:NewPropertyObject.selectValue.table(self.tableName).schema(\"notExistSchema\")] != nil;\n                  }];\n\n    [self testAutoAddColumn:NewPropertyObject.multiSelectValue\n                  isSucceed:YES\n                  byExecute:^bool {\n                      WCTMultiSelect* select = [self.database prepareMultiSelect];\n                      [[select onResultColumns:{ NewPropertyObject.multiSelectValue.table(self.tableName), NewPropertyObject.multiSelectValue.table(fakeTable) }] fromTables:@[ self.tableName, fakeTable ]];\n                      return select.allMultiObjects != nil;\n                  }];\n\n    [self testAutoAddColumn:NewPropertyObject.multiSelectValue\n                  isSucceed:NO\n                  byExecute:^bool {\n                      WCTMultiSelect* select = [self.database prepareMultiSelect];\n                      [[select onResultColumns:{ NewPropertyObject.multiSelectValue.table(self.tableName).schema(\"notExistSchema\"), NewPropertyObject.multiSelectValue.table(fakeTable) }] fromTables:@[ self.tableName, fakeTable ]];\n                      return select.allMultiObjects != nil;\n                  }];\n\n    [self testAutoAddColumn:NewPropertyObject.primaryValue\n                  isSucceed:NO\n                  byExecute:^bool {\n                      return [self.database getColumnOnResultColumn:NewPropertyObject.primaryValue fromTable:self.tableName] != nil;\n                  }];\n\n    [self testAutoAddColumn:NewPropertyObject.uniqueValue\n                  isSucceed:NO\n                  byExecute:^bool {\n                      return [self.database getColumnOnResultColumn:NewPropertyObject.uniqueValue fromTable:self.tableName] != nil;\n                  }];\n}\n\n- (void)testAutoAddColumn:(const WCTProperty&)newProperty isSucceed:(BOOL)isSucceed byExecute:(bool (^)())block\n{\n    auto createTable = WCDB::StatementCreateTable().createTable(self.tableName);\n    auto binding = const_cast<WCTBinding*>(&NewPropertyObject.objectRelationalMapping);\n    auto properties = NewPropertyObject.allProperties.propertiesByRemovingProperties(newProperty);\n    for (const auto& property : properties) {\n        createTable.define(*binding->getColumnDef(property));\n    }\n    NSString* propertyName = [NSString stringWithUTF8String:newProperty.getDescription().data()];\n    TestCaseAssertTrue([self.database execute:createTable]);\n    __block bool autoAdded = false;\n    [self.database traceError:^(WCTError* error) {\n        if (![error.message isEqualToString:@\"Auto add column\"]) {\n            return;\n        }\n        autoAdded = YES;\n        TestCaseAssertTrue([error.userInfo[@\"Table\"] isEqualToString:self.tableName]);\n        TestCaseAssertTrue([error.userInfo[@\"Column\"] isEqualToString:propertyName]);\n    }];\n    TestCaseAssertTrue(block() == isSucceed);\n    TestCaseAssertTrue(autoAdded || !isSucceed);\n    TestCaseAssertTrue([self.database dropTable:self.tableName]);\n    [self.database traceError:nil];\n}\n\n@end\n"
  },
  {
    "path": "src/objc/tests/orm/addtional/AdditionalORMObject+WCTTableCoding.h",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"AdditionalORMObject.h\"\n#if TEST_WCDB_OBJC\n#import <WCDBOBjc/WCDBObjc.h>\n#elif TEST_WCDB_CPP\n#import <WCDBCpp/WCDBCpp.h>\n#else\n#import <WCDB/WCDBObjc.h>\n#endif\n\n@interface AdditionalORMObject (WCTTableCoding) <WCTTableCoding>\n\nWCDB_PROPERTY(value)\n\n@end\n"
  },
  {
    "path": "src/objc/tests/orm/addtional/AdditionalORMObject.h",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import <Foundation/Foundation.h>\n\n@interface AdditionalORMObject : NSObject\n\n@property (nonatomic, assign) int value;\n\n@end\n"
  },
  {
    "path": "src/objc/tests/orm/addtional/AdditionalORMObject.mm",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"AdditionalORMObject.h\"\n#import \"AdditionalORMObject+WCTTableCoding.h\"\n#if TEST_WCDB_OBJC\n#import <WCDBOBjc/WCDBObjc.h>\n#elif TEST_WCDB_CPP\n#import <WCDBCpp/WCDBCpp.h>\n#else\n#import <WCDB/WCDBObjc.h>\n#endif\n\n@implementation AdditionalORMObject\n\nWCDB_IMPLEMENTATION(AdditionalORMObject)\nWCDB_SYNTHESIZE(value)\n\n+ (void)additionalObjectRelationalMapping:(WCTBinding &)binding\n{\n    if (self.class == AdditionalORMObject.class) {\n        // add new column constraint\n        binding.getColumnDef(AdditionalORMObject.value)\n        ->constraint(WCDB::ColumnConstraint().primaryKey().conflict(WCDB::Conflict::Abort));\n\n        // add new index\n        binding.getOrCreateIndex(@\"_index\").statement.indexed(AdditionalORMObject.value.asIndex().order(WCDB::Order::ASC));\n\n        // add new table constraint\n        binding.getOrCreateTableConstraint(@\"table_constraint\")\n        .check(AdditionalORMObject.value > 10);\n        // modify virtual table\n        // binding.statementVirtualTable\n    }\n}\n\n@end\n"
  },
  {
    "path": "src/objc/tests/orm/column_constraint/ColumnConstraintAutoIncrement+WCTTableCoding.h",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"ColumnConstraintAutoIncrement.h\"\n#if TEST_WCDB_OBJC\n#import <WCDBOBjc/WCDBObjc.h>\n#elif TEST_WCDB_CPP\n#import <WCDBCpp/WCDBCpp.h>\n#else\n#import <WCDB/WCDBObjc.h>\n#endif\n\n@interface ColumnConstraintAutoIncrement (WCTTableCoding) <WCTTableCoding>\n\nWCDB_PROPERTY(value)\n\n@end\n"
  },
  {
    "path": "src/objc/tests/orm/column_constraint/ColumnConstraintAutoIncrement.h",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import <Foundation/Foundation.h>\n\n@interface ColumnConstraintAutoIncrement : NSObject\n\n@property (nonatomic, assign) int value;\n\n@end\n"
  },
  {
    "path": "src/objc/tests/orm/column_constraint/ColumnConstraintAutoIncrement.mm",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"ColumnConstraintAutoIncrement.h\"\n#import \"ColumnConstraintAutoIncrement+WCTTableCoding.h\"\n#if TEST_WCDB_OBJC\n#import <WCDBOBjc/WCDBObjc.h>\n#elif TEST_WCDB_CPP\n#import <WCDBCpp/WCDBCpp.h>\n#else\n#import <WCDB/WCDBObjc.h>\n#endif\n\n@implementation ColumnConstraintAutoIncrement\n\nWCDB_IMPLEMENTATION(ColumnConstraintAutoIncrement)\nWCDB_SYNTHESIZE(value)\n\nWCDB_PRIMARY_AUTO_INCREMENT(value)\n\n@end\n"
  },
  {
    "path": "src/objc/tests/orm/column_constraint/ColumnConstraintAutoIncrementAsc+WCTTableCoding.h",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"ColumnConstraintAutoIncrementAsc.h\"\n#if TEST_WCDB_OBJC\n#import <WCDBOBjc/WCDBObjc.h>\n#elif TEST_WCDB_CPP\n#import <WCDBCpp/WCDBCpp.h>\n#else\n#import <WCDB/WCDBObjc.h>\n#endif\n\n@interface ColumnConstraintAutoIncrementAsc (WCTTableCoding) <WCTTableCoding>\n\nWCDB_PROPERTY(value)\n\n@end\n"
  },
  {
    "path": "src/objc/tests/orm/column_constraint/ColumnConstraintAutoIncrementAsc.h",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import <Foundation/Foundation.h>\n\n@interface ColumnConstraintAutoIncrementAsc : NSObject\n\n@property (nonatomic, assign) int value;\n\n@end\n"
  },
  {
    "path": "src/objc/tests/orm/column_constraint/ColumnConstraintAutoIncrementAsc.mm",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"ColumnConstraintAutoIncrementAsc.h\"\n#import \"ColumnConstraintAutoIncrementAsc+WCTTableCoding.h\"\n#if TEST_WCDB_OBJC\n#import <WCDBOBjc/WCDBObjc.h>\n#elif TEST_WCDB_CPP\n#import <WCDBCpp/WCDBCpp.h>\n#else\n#import <WCDB/WCDBObjc.h>\n#endif\n\n@implementation ColumnConstraintAutoIncrementAsc\n\nWCDB_IMPLEMENTATION(ColumnConstraintAutoIncrementAsc)\nWCDB_SYNTHESIZE(value)\n\nWCDB_PRIMARY_ASC_AUTO_INCREMENT(value)\n\n@end\n"
  },
  {
    "path": "src/objc/tests/orm/column_constraint/ColumnConstraintCheck+WCTTableCoding.h",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"ColumnConstraintCheck.h\"\n#if TEST_WCDB_OBJC\n#import <WCDBOBjc/WCDBObjc.h>\n#elif TEST_WCDB_CPP\n#import <WCDBCpp/WCDBCpp.h>\n#else\n#import <WCDB/WCDBObjc.h>\n#endif\n\n@interface ColumnConstraintCheck (WCTTableCoding) <WCTTableCoding>\n\nWCDB_PROPERTY(value)\n\n@end\n"
  },
  {
    "path": "src/objc/tests/orm/column_constraint/ColumnConstraintCheck.h",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import <Foundation/Foundation.h>\n\n@interface ColumnConstraintCheck : NSObject\n\n@property (nonatomic, assign) int value;\n\n@end\n"
  },
  {
    "path": "src/objc/tests/orm/column_constraint/ColumnConstraintCheck.mm",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"ColumnConstraintCheck.h\"\n#import \"ColumnConstraintCheck+WCTTableCoding.h\"\n#if TEST_WCDB_OBJC\n#import <WCDBOBjc/WCDBObjc.h>\n#elif TEST_WCDB_CPP\n#import <WCDBCpp/WCDBCpp.h>\n#else\n#import <WCDB/WCDBObjc.h>\n#endif\n\n@implementation ColumnConstraintCheck\n\nWCDB_IMPLEMENTATION(ColumnConstraintCheck)\nWCDB_SYNTHESIZE(value)\n\nWCDB_CHECK(value, ColumnConstraintCheck.value > 1)\n\n@end\n"
  },
  {
    "path": "src/objc/tests/orm/column_constraint/ColumnConstraintDefault+WCTTableCoding.h",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"ColumnConstraintDefault.h\"\n#if TEST_WCDB_OBJC\n#import <WCDBOBjc/WCDBObjc.h>\n#elif TEST_WCDB_CPP\n#import <WCDBCpp/WCDBCpp.h>\n#else\n#import <WCDB/WCDBObjc.h>\n#endif\n\n@interface ColumnConstraintDefault (WCTTableCoding) <WCTTableCoding>\n\nWCDB_PROPERTY(value)\n\n@end\n"
  },
  {
    "path": "src/objc/tests/orm/column_constraint/ColumnConstraintDefault.h",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import <Foundation/Foundation.h>\n\n@interface ColumnConstraintDefault : NSObject\n\n@property (nonatomic, assign) int value;\n\n@end\n"
  },
  {
    "path": "src/objc/tests/orm/column_constraint/ColumnConstraintDefault.mm",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"ColumnConstraintDefault.h\"\n#import \"ColumnConstraintDefault+WCTTableCoding.h\"\n#if TEST_WCDB_OBJC\n#import <WCDBOBjc/WCDBObjc.h>\n#elif TEST_WCDB_CPP\n#import <WCDBCpp/WCDBCpp.h>\n#else\n#import <WCDB/WCDBObjc.h>\n#endif\n\n@implementation ColumnConstraintDefault\n\nWCDB_IMPLEMENTATION(ColumnConstraintDefault)\nWCDB_SYNTHESIZE(value)\n\nWCDB_DEFAULT(value, 1.0)\n\n@end\n"
  },
  {
    "path": "src/objc/tests/orm/column_constraint/ColumnConstraintEnablePrimaryAutoIncrement+WCTTableCoding.h",
    "content": "//\n// Created by qiuwenchen on 2023/7/6.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"ColumnConstraintEnablePrimaryAutoIncrement.h\"\n#if TEST_WCDB_OBJC\n#import <WCDBOBjc/WCDBObjc.h>\n#elif TEST_WCDB_CPP\n#import <WCDBCpp/WCDBCpp.h>\n#else\n#import <WCDB/WCDBObjc.h>\n#endif\n\n@interface ColumnConstraintEnablePrimaryAutoIncrement (WCTTableCoding) <WCTTableCoding>\n\nWCDB_PROPERTY(key)\nWCDB_PROPERTY(content)\n\n@end\n"
  },
  {
    "path": "src/objc/tests/orm/column_constraint/ColumnConstraintEnablePrimaryAutoIncrement.h",
    "content": "//\n// Created by qiuwenchen on 2023/7/6.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import <Foundation/Foundation.h>\n\n@interface ColumnConstraintEnablePrimaryAutoIncrement : NSObject\n\n@property (nonatomic, assign) int key;\n@property (nonatomic, strong) NSString* content;\n\n@end\n"
  },
  {
    "path": "src/objc/tests/orm/column_constraint/ColumnConstraintEnablePrimaryAutoIncrement.mm",
    "content": "//\n// Created by qiuwenchen on 2023/7/6.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"ColumnConstraintEnablePrimaryAutoIncrement+WCTTableCoding.h\"\n\n@implementation ColumnConstraintEnablePrimaryAutoIncrement\n\n@synthesize lastInsertedRowID;\n\nWCDB_IMPLEMENTATION(ColumnConstraintEnablePrimaryAutoIncrement)\nWCDB_SYNTHESIZE(key)\nWCDB_SYNTHESIZE(content)\n\nWCDB_PRIMARY_AUTO_INCREMENT(key)\n\nWCDB_PRIMARY_ENABLE_AUTOINCREMENT_FOR_EXISTING_TABLE\n\n@end\n"
  },
  {
    "path": "src/objc/tests/orm/column_constraint/ColumnConstraintNotNull+WCTTableCoding.h",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"ColumnConstraintNotNull.h\"\n#if TEST_WCDB_OBJC\n#import <WCDBOBjc/WCDBObjc.h>\n#elif TEST_WCDB_CPP\n#import <WCDBCpp/WCDBCpp.h>\n#else\n#import <WCDB/WCDBObjc.h>\n#endif\n\n@interface ColumnConstraintNotNull (WCTTableCoding) <WCTTableCoding>\n\nWCDB_PROPERTY(value)\n\n@end\n"
  },
  {
    "path": "src/objc/tests/orm/column_constraint/ColumnConstraintNotNull.h",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import <Foundation/Foundation.h>\n\n@interface ColumnConstraintNotNull : NSObject\n\n@property (nonatomic, assign) int value;\n\n@end\n"
  },
  {
    "path": "src/objc/tests/orm/column_constraint/ColumnConstraintNotNull.mm",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"ColumnConstraintNotNull.h\"\n#import \"ColumnConstraintNotNull+WCTTableCoding.h\"\n#if TEST_WCDB_OBJC\n#import <WCDBOBjc/WCDBObjc.h>\n#elif TEST_WCDB_CPP\n#import <WCDBCpp/WCDBCpp.h>\n#else\n#import <WCDB/WCDBObjc.h>\n#endif\n\n@implementation ColumnConstraintNotNull\n\nWCDB_IMPLEMENTATION(ColumnConstraintNotNull)\nWCDB_SYNTHESIZE(value)\n\nWCDB_NOT_NULL(value)\n\n@end\n"
  },
  {
    "path": "src/objc/tests/orm/column_constraint/ColumnConstraintPrimary+WCTTableCoding.h",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"ColumnConstraintPrimary.h\"\n#if TEST_WCDB_OBJC\n#import <WCDBOBjc/WCDBObjc.h>\n#elif TEST_WCDB_CPP\n#import <WCDBCpp/WCDBCpp.h>\n#else\n#import <WCDB/WCDBObjc.h>\n#endif\n\n@interface ColumnConstraintPrimary (WCTTableCoding) <WCTTableCoding>\n\nWCDB_PROPERTY(value)\n\n@end\n"
  },
  {
    "path": "src/objc/tests/orm/column_constraint/ColumnConstraintPrimary.h",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import <Foundation/Foundation.h>\n\n@interface ColumnConstraintPrimary : NSObject\n\n@property (nonatomic, assign) int value;\n\n@end\n"
  },
  {
    "path": "src/objc/tests/orm/column_constraint/ColumnConstraintPrimary.mm",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"ColumnConstraintPrimary.h\"\n#import \"ColumnConstraintPrimary+WCTTableCoding.h\"\n#if TEST_WCDB_OBJC\n#import <WCDBOBjc/WCDBObjc.h>\n#elif TEST_WCDB_CPP\n#import <WCDBCpp/WCDBCpp.h>\n#else\n#import <WCDB/WCDBObjc.h>\n#endif\n\n@implementation ColumnConstraintPrimary\n\nWCDB_IMPLEMENTATION(ColumnConstraintPrimary)\nWCDB_SYNTHESIZE(value)\n\nWCDB_PRIMARY(value)\n\n@end\n"
  },
  {
    "path": "src/objc/tests/orm/column_constraint/ColumnConstraintPrimaryAsc+WCTTableCoding.h",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"ColumnConstraintPrimaryAsc.h\"\n#if TEST_WCDB_OBJC\n#import <WCDBOBjc/WCDBObjc.h>\n#elif TEST_WCDB_CPP\n#import <WCDBCpp/WCDBCpp.h>\n#else\n#import <WCDB/WCDBObjc.h>\n#endif\n\n@interface ColumnConstraintPrimaryAsc (WCTTableCoding) <WCTTableCoding>\n\nWCDB_PROPERTY(value)\n\n@end\n"
  },
  {
    "path": "src/objc/tests/orm/column_constraint/ColumnConstraintPrimaryAsc.h",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import <Foundation/Foundation.h>\n\n@interface ColumnConstraintPrimaryAsc : NSObject\n\n@property (nonatomic, assign) int value;\n\n@end\n"
  },
  {
    "path": "src/objc/tests/orm/column_constraint/ColumnConstraintPrimaryAsc.mm",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"ColumnConstraintPrimaryAsc.h\"\n#import \"ColumnConstraintPrimaryAsc+WCTTableCoding.h\"\n#if TEST_WCDB_OBJC\n#import <WCDBOBjc/WCDBObjc.h>\n#elif TEST_WCDB_CPP\n#import <WCDBCpp/WCDBCpp.h>\n#else\n#import <WCDB/WCDBObjc.h>\n#endif\n\n@implementation ColumnConstraintPrimaryAsc\n\nWCDB_IMPLEMENTATION(ColumnConstraintPrimaryAsc)\nWCDB_SYNTHESIZE(value)\n\nWCDB_PRIMARY_ASC(value)\n\n@end\n"
  },
  {
    "path": "src/objc/tests/orm/column_constraint/ColumnConstraintPrimaryDesc+WCTTableCoding.h",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"ColumnConstraintPrimaryDesc.h\"\n#if TEST_WCDB_OBJC\n#import <WCDBOBjc/WCDBObjc.h>\n#elif TEST_WCDB_CPP\n#import <WCDBCpp/WCDBCpp.h>\n#else\n#import <WCDB/WCDBObjc.h>\n#endif\n\n@interface ColumnConstraintPrimaryDesc (WCTTableCoding) <WCTTableCoding>\n\nWCDB_PROPERTY(value)\n\n@end\n"
  },
  {
    "path": "src/objc/tests/orm/column_constraint/ColumnConstraintPrimaryDesc.h",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import <Foundation/Foundation.h>\n\n@interface ColumnConstraintPrimaryDesc : NSObject\n\n@property (nonatomic, assign) int value;\n\n@end\n"
  },
  {
    "path": "src/objc/tests/orm/column_constraint/ColumnConstraintPrimaryDesc.mm",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"ColumnConstraintPrimaryDesc.h\"\n#import \"ColumnConstraintPrimaryDesc+WCTTableCoding.h\"\n#if TEST_WCDB_OBJC\n#import <WCDBOBjc/WCDBObjc.h>\n#elif TEST_WCDB_CPP\n#import <WCDBCpp/WCDBCpp.h>\n#else\n#import <WCDB/WCDBObjc.h>\n#endif\n\n@implementation ColumnConstraintPrimaryDesc\n\nWCDB_IMPLEMENTATION(ColumnConstraintPrimaryDesc)\nWCDB_SYNTHESIZE(value)\n\nWCDB_PRIMARY_DESC(value)\n\n@end\n"
  },
  {
    "path": "src/objc/tests/orm/column_constraint/ColumnConstraintUnique+WCTTableCoding.h",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"ColumnConstraintUnique.h\"\n#if TEST_WCDB_OBJC\n#import <WCDBOBjc/WCDBObjc.h>\n#elif TEST_WCDB_CPP\n#import <WCDBCpp/WCDBCpp.h>\n#else\n#import <WCDB/WCDBObjc.h>\n#endif\n\n@interface ColumnConstraintUnique (WCTTableCoding) <WCTTableCoding>\n\nWCDB_PROPERTY(value)\n\n@end\n"
  },
  {
    "path": "src/objc/tests/orm/column_constraint/ColumnConstraintUnique.h",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import <Foundation/Foundation.h>\n\n@interface ColumnConstraintUnique : NSObject\n\n@property (nonatomic, assign) int value;\n\n@end\n"
  },
  {
    "path": "src/objc/tests/orm/column_constraint/ColumnConstraintUnique.mm",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"ColumnConstraintUnique.h\"\n#import \"ColumnConstraintUnique+WCTTableCoding.h\"\n#if TEST_WCDB_OBJC\n#import <WCDBOBjc/WCDBObjc.h>\n#elif TEST_WCDB_CPP\n#import <WCDBCpp/WCDBCpp.h>\n#else\n#import <WCDB/WCDBObjc.h>\n#endif\n\n@implementation ColumnConstraintUnique\n\nWCDB_IMPLEMENTATION(ColumnConstraintUnique)\nWCDB_SYNTHESIZE(value)\n\nWCDB_UNIQUE(value)\n\n@end\n"
  },
  {
    "path": "src/objc/tests/orm/index/IndexObject+WCTTableCoding.h",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"IndexObject.h\"\n#if TEST_WCDB_OBJC\n#import <WCDBOBjc/WCDBObjc.h>\n#elif TEST_WCDB_CPP\n#import <WCDBCpp/WCDBCpp.h>\n#else\n#import <WCDB/WCDBObjc.h>\n#endif\n\n@interface IndexObject (WCTTableCoding) <WCTTableCoding>\n\nWCDB_PROPERTY(index_)\nWCDB_PROPERTY(indexAsc)\nWCDB_PROPERTY(indexDesc)\n\nWCDB_PROPERTY(uniqueIndex)\nWCDB_PROPERTY(uniqueIndexAsc)\nWCDB_PROPERTY(uniqueIndexDesc)\n\nWCDB_PROPERTY(multiIndex)\nWCDB_PROPERTY(multiIndexAsc)\nWCDB_PROPERTY(multiIndexDesc)\n\n@end\n"
  },
  {
    "path": "src/objc/tests/orm/index/IndexObject.h",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import <Foundation/Foundation.h>\n\n@interface IndexObject : NSObject\n\n@property (nonatomic, assign) int index_;\n@property (nonatomic, assign) int indexAsc;\n@property (nonatomic, assign) int indexDesc;\n\n@property (nonatomic, assign) int uniqueIndex;\n@property (nonatomic, assign) int uniqueIndexAsc;\n@property (nonatomic, assign) int uniqueIndexDesc;\n\n@property (nonatomic, assign) int multiIndex;\n@property (nonatomic, assign) int multiIndexAsc;\n@property (nonatomic, assign) int multiIndexDesc;\n\n@end\n"
  },
  {
    "path": "src/objc/tests/orm/index/IndexObject.mm",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"IndexObject.h\"\n#import \"IndexObject+WCTTableCoding.h\"\n#if TEST_WCDB_OBJC\n#import <WCDBOBjc/WCDBObjc.h>\n#elif TEST_WCDB_CPP\n#import <WCDBCpp/WCDBCpp.h>\n#else\n#import <WCDB/WCDBObjc.h>\n#endif\n\n@implementation IndexObject\n\nWCDB_IMPLEMENTATION(IndexObject)\nWCDB_SYNTHESIZE(index_)\nWCDB_SYNTHESIZE(indexAsc)\nWCDB_SYNTHESIZE(indexDesc)\n\nWCDB_SYNTHESIZE(uniqueIndex)\nWCDB_SYNTHESIZE(uniqueIndexAsc)\nWCDB_SYNTHESIZE(uniqueIndexDesc)\n\nWCDB_SYNTHESIZE(multiIndex)\nWCDB_SYNTHESIZE(multiIndexAsc)\nWCDB_SYNTHESIZE(multiIndexDesc)\n\nWCDB_INDEX(@\"_index\", index_);\nWCDB_INDEX_ASC(@\"_index_asc\", indexAsc);\nWCDB_INDEX_DESC(@\"_index_desc\", indexDesc);\n\nWCDB_UNIQUE_INDEX(@\"_unique_index\", uniqueIndex);\nWCDB_UNIQUE_INDEX_ASC(@\"_unique_index_asc\", uniqueIndexAsc);\nWCDB_UNIQUE_INDEX_DESC(@\"_unique_index_desc\", uniqueIndexDesc);\n\nWCDB_INDEX(@\"_multi_index\", multiIndex);\nWCDB_INDEX_ASC(@\"_multi_index\", multiIndexAsc);\nWCDB_INDEX_DESC(@\"_multi_index\", multiIndexDesc);\n\n@end\n"
  },
  {
    "path": "src/objc/tests/orm/property/NewPropertyObject.h",
    "content": "//\n// Created by qiuwenchen on 2022/12/4.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import <Foundation/Foundation.h>\n#if TEST_WCDB_OBJC\n#import <WCDBOBjc/WCDBObjc.h>\n#elif TEST_WCDB_CPP\n#import <WCDBCpp/WCDBCpp.h>\n#else\n#import <WCDB/WCDBObjc.h>\n#endif\n\n@interface NewPropertyObject : NSObject <WCTTableCoding>\n\n@property (nonatomic, assign) int primaryValue;\n@property (nonatomic, assign) int uniqueValue;\n@property (nonatomic, assign) int insertValue;\n@property (nonatomic, assign) int updateValue;\n@property (nonatomic, assign) int selectValue;\n@property (nonatomic, assign) int multiSelectValue;\n@property (nonatomic, assign) int deleteValue;\n@property (nonatomic, assign) int indexValue;\n\nWCDB_PROPERTY(primaryValue)\nWCDB_PROPERTY(uniqueValue)\nWCDB_PROPERTY(insertValue)\nWCDB_PROPERTY(updateValue)\nWCDB_PROPERTY(selectValue)\nWCDB_PROPERTY(multiSelectValue)\nWCDB_PROPERTY(deleteValue)\n\n@end\n"
  },
  {
    "path": "src/objc/tests/orm/property/NewPropertyObject.mm",
    "content": "//\n// Created by qiuwenchen on 2022/12/4.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"NewPropertyObject.h\"\n#import <Foundation/Foundation.h>\n\n@implementation NewPropertyObject\n\nWCDB_IMPLEMENTATION(NewPropertyObject)\nWCDB_SYNTHESIZE(primaryValue)\nWCDB_SYNTHESIZE(uniqueValue)\nWCDB_SYNTHESIZE(insertValue)\nWCDB_SYNTHESIZE(updateValue)\nWCDB_SYNTHESIZE(selectValue)\nWCDB_SYNTHESIZE(multiSelectValue)\nWCDB_SYNTHESIZE(deleteValue)\n\nWCDB_PRIMARY(primaryValue)\nWCDB_UNIQUE(uniqueValue)\n\n@end\n"
  },
  {
    "path": "src/objc/tests/orm/property/PropertyObject+WCTTableCoding.h",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"PropertyObject.h\"\n#if TEST_WCDB_OBJC\n#import <WCDBOBjc/WCDBObjc.h>\n#elif TEST_WCDB_CPP\n#import <WCDBCpp/WCDBCpp.h>\n#else\n#import <WCDB/WCDBObjc.h>\n#endif\n\n@interface PropertyObject (WCTTableCoding) <WCTTableCoding>\n\nWCDB_PROPERTY(property)\nWCDB_PROPERTY(propertyWithDifferentName)\n\n@end\n"
  },
  {
    "path": "src/objc/tests/orm/property/PropertyObject.h",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import <Foundation/Foundation.h>\n\n@interface PropertyObject : NSObject\n\n@property (nonatomic, assign) int property ;\n@property (nonatomic, assign) int propertyWithDifferentName;\n\n@end\n"
  },
  {
    "path": "src/objc/tests/orm/property/PropertyObject.mm",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"PropertyObject.h\"\n#import \"PropertyObject+WCTTableCoding.h\"\n#if TEST_WCDB_OBJC\n#import <WCDBOBjc/WCDBObjc.h>\n#elif TEST_WCDB_CPP\n#import <WCDBCpp/WCDBCpp.h>\n#else\n#import <WCDB/WCDBObjc.h>\n#endif\n\n@implementation PropertyObject\n\nWCDB_IMPLEMENTATION(PropertyObject)\nWCDB_SYNTHESIZE(property)\nWCDB_SYNTHESIZE_COLUMN(propertyWithDifferentName, \"differentName\")\n\n@end\n"
  },
  {
    "path": "src/objc/tests/orm/rebind/DropIndexObject+WCTTableCoding.h",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"DropIndexObject.h\"\n#if TEST_WCDB_OBJC\n#import <WCDBOBjc/WCDBObjc.h>\n#elif TEST_WCDB_CPP\n#import <WCDBCpp/WCDBCpp.h>\n#else\n#import <WCDB/WCDBObjc.h>\n#endif\n\n@interface DropIndexObject (WCTTableCoding) <WCTTableCoding>\n\nWCDB_PROPERTY(renamedValue)\nWCDB_PROPERTY(newValue)\n\n@end\n"
  },
  {
    "path": "src/objc/tests/orm/rebind/DropIndexObject.h",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import <Foundation/Foundation.h>\n\n@interface DropIndexObject : NSObject\n\n@property (nonatomic, assign) int renamedValue;\n@property (nonatomic, assign) int newValue;\n\n@end\n"
  },
  {
    "path": "src/objc/tests/orm/rebind/DropIndexObject.mm",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"DropIndexObject.h\"\n#import \"DropIndexObject+WCTTableCoding.h\"\n#if TEST_WCDB_OBJC\n#import <WCDBOBjc/WCDBObjc.h>\n#elif TEST_WCDB_CPP\n#import <WCDBCpp/WCDBCpp.h>\n#else\n#import <WCDB/WCDBObjc.h>\n#endif\n\n@implementation DropIndexObject\n\nWCDB_IMPLEMENTATION(DropIndexObject)\n\n// bind renamedValue to the old column \"value\"\nWCDB_SYNTHESIZE_COLUMN(renamedValue, \"value\")\nWCDB_SYNTHESIZE(newValue)\n\n// index will be dropped\nWCDB_INDEX_TO_BE_DROPPED(@\"_index\")\n\n@end\n"
  },
  {
    "path": "src/objc/tests/orm/rebind/NewRemapObject+WCTTableCoding.h",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"NewRemapObject.h\"\n#if TEST_WCDB_OBJC\n#import <WCDBOBjc/WCDBObjc.h>\n#elif TEST_WCDB_CPP\n#import <WCDBCpp/WCDBCpp.h>\n#else\n#import <WCDB/WCDBObjc.h>\n#endif\n\n@interface NewRemapObject (WCTTableCoding) <WCTTableCoding>\n\nWCDB_PROPERTY(renamedValue)\nWCDB_PROPERTY(newValue)\n\n@end\n"
  },
  {
    "path": "src/objc/tests/orm/rebind/NewRemapObject.h",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import <Foundation/Foundation.h>\n\n@interface NewRemapObject : NSObject\n\n@property (nonatomic, assign) int renamedValue;\n@property (nonatomic, assign) int newValue;\n\n@end\n"
  },
  {
    "path": "src/objc/tests/orm/rebind/NewRemapObject.mm",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"NewRemapObject.h\"\n#import \"NewRemapObject+WCTTableCoding.h\"\n#if TEST_WCDB_OBJC\n#import <WCDBOBjc/WCDBObjc.h>\n#elif TEST_WCDB_CPP\n#import <WCDBCpp/WCDBCpp.h>\n#else\n#import <WCDB/WCDBObjc.h>\n#endif\n\n@implementation NewRemapObject\n\nWCDB_IMPLEMENTATION(NewRemapObject)\n\n// bind renamedValue to the old column \"value\"\nWCDB_SYNTHESIZE_COLUMN(renamedValue, \"value\")\nWCDB_SYNTHESIZE(newValue)\n\n// add index after rebind\nWCDB_INDEX(@\"_index\", renamedValue)\n\n@end\n"
  },
  {
    "path": "src/objc/tests/orm/rebind/NewlyCreatedTableIndexObject+WCTTableCoding.h",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"NewlyCreatedTableIndexObject.h\"\n#if TEST_WCDB_OBJC\n#import <WCDBOBjc/WCDBObjc.h>\n#elif TEST_WCDB_CPP\n#import <WCDBCpp/WCDBCpp.h>\n#else\n#import <WCDB/WCDBObjc.h>\n#endif\n\n@interface NewlyCreatedTableIndexObject (WCTTableCoding) <WCTTableCoding>\n\nWCDB_PROPERTY(renamedValue)\nWCDB_PROPERTY(newValue)\n\n@end\n"
  },
  {
    "path": "src/objc/tests/orm/rebind/NewlyCreatedTableIndexObject.h",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import <Foundation/Foundation.h>\n\n@interface NewlyCreatedTableIndexObject : NSObject\n\n@property (nonatomic, assign) int renamedValue;\n@property (nonatomic, assign) int newValue;\n\n@end\n"
  },
  {
    "path": "src/objc/tests/orm/rebind/NewlyCreatedTableIndexObject.mm",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"NewlyCreatedTableIndexObject.h\"\n#import \"NewlyCreatedTableIndexObject+WCTTableCoding.h\"\n#if TEST_WCDB_OBJC\n#import <WCDBOBjc/WCDBObjc.h>\n#elif TEST_WCDB_CPP\n#import <WCDBCpp/WCDBCpp.h>\n#else\n#import <WCDB/WCDBObjc.h>\n#endif\n\n@implementation NewlyCreatedTableIndexObject\n\nWCDB_IMPLEMENTATION(NewlyCreatedTableIndexObject)\n\n// bind renamedValue to the old column \"value\"\nWCDB_SYNTHESIZE_COLUMN(renamedValue, \"value\")\nWCDB_SYNTHESIZE(newValue)\n\n// index will not be created for non-newly-created-table\nWCDB_INDEX_FOR_NEWLY_CREATED_TABLE_ONLY(\"_index\")\nWCDB_INDEX(@\"_index\", renamedValue)\n\n@end\n"
  },
  {
    "path": "src/objc/tests/orm/rebind/OldRemapObject+WCTTableCoding.h",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"OldRemapObject.h\"\n#if TEST_WCDB_OBJC\n#import <WCDBOBjc/WCDBObjc.h>\n#elif TEST_WCDB_CPP\n#import <WCDBCpp/WCDBCpp.h>\n#else\n#import <WCDB/WCDBObjc.h>\n#endif\n\n@interface OldRemapObject (WCTTableCoding) <WCTTableCoding>\n\nWCDB_PROPERTY(value)\n\n@end\n"
  },
  {
    "path": "src/objc/tests/orm/rebind/OldRemapObject.h",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import <Foundation/Foundation.h>\n\n@interface OldRemapObject : NSObject\n\n@property (nonatomic, assign) int value;\n\n@end\n"
  },
  {
    "path": "src/objc/tests/orm/rebind/OldRemapObject.mm",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"OldRemapObject.h\"\n#import \"OldRemapObject+WCTTableCoding.h\"\n#if TEST_WCDB_OBJC\n#import <WCDBOBjc/WCDBObjc.h>\n#elif TEST_WCDB_CPP\n#import <WCDBCpp/WCDBCpp.h>\n#else\n#import <WCDB/WCDBObjc.h>\n#endif\n\n@implementation OldRemapObject\n\nWCDB_IMPLEMENTATION(OldRemapObject)\nWCDB_SYNTHESIZE(value)\n\n@end\n"
  },
  {
    "path": "src/objc/tests/orm/table_constraint/TableConstraintObject+WCTTableCoding.h",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"TableConstraintObject.h\"\n#if TEST_WCDB_OBJC\n#import <WCDBOBjc/WCDBObjc.h>\n#elif TEST_WCDB_CPP\n#import <WCDBCpp/WCDBCpp.h>\n#else\n#import <WCDB/WCDBObjc.h>\n#endif\n\n@interface TableConstraintObject (WCTTableCoding) <WCTTableCoding>\n\nWCDB_PROPERTY(multiPrimary)\nWCDB_PROPERTY(multiPrimaryAsc)\nWCDB_PROPERTY(multiPrimaryDesc)\n\nWCDB_PROPERTY(multiUnique)\nWCDB_PROPERTY(multiUniqueAsc)\nWCDB_PROPERTY(multiUniqueDesc)\n\n@end\n"
  },
  {
    "path": "src/objc/tests/orm/table_constraint/TableConstraintObject.h",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import <Foundation/Foundation.h>\n\n@interface TableConstraintObject : NSObject\n\n@property (nonatomic, assign) int multiPrimary;\n@property (nonatomic, assign) int multiPrimaryAsc;\n@property (nonatomic, assign) int multiPrimaryDesc;\n\n@property (nonatomic, assign) int multiUnique;\n@property (nonatomic, assign) int multiUniqueAsc;\n@property (nonatomic, assign) int multiUniqueDesc;\n\n@end\n"
  },
  {
    "path": "src/objc/tests/orm/table_constraint/TableConstraintObject.mm",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"TableConstraintObject.h\"\n#import \"TableConstraintObject+WCTTableCoding.h\"\n#if TEST_WCDB_OBJC\n#import <WCDBOBjc/WCDBObjc.h>\n#elif TEST_WCDB_CPP\n#import <WCDBCpp/WCDBCpp.h>\n#else\n#import <WCDB/WCDBObjc.h>\n#endif\n\n@implementation TableConstraintObject\n\nWCDB_IMPLEMENTATION(TableConstraintObject)\nWCDB_SYNTHESIZE(multiPrimary)\nWCDB_SYNTHESIZE(multiPrimaryAsc)\nWCDB_SYNTHESIZE(multiPrimaryDesc)\n\nWCDB_SYNTHESIZE(multiUnique)\nWCDB_SYNTHESIZE(multiUniqueAsc)\nWCDB_SYNTHESIZE(multiUniqueDesc)\n\nWCDB_MULTI_PRIMARY(@\"multi_primary\", multiPrimary)\nWCDB_MULTI_PRIMARY_ASC(@\"multi_primary\", multiPrimaryAsc)\nWCDB_MULTI_PRIMARY_DESC(@\"multi_primary\", multiPrimaryDesc)\n\nWCDB_MULTI_UNIQUE(@\"multi_unique\", multiUnique)\nWCDB_MULTI_UNIQUE_ASC(@\"multi_unique\", multiUniqueAsc)\nWCDB_MULTI_UNIQUE_DESC(@\"multi_unique\", multiUniqueDesc)\n\n@end\n"
  },
  {
    "path": "src/objc/tests/orm/virtual_table/VirtualTableFTS4Object+WCTTableCoding.h",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"VirtualTableFTS4Object.h\"\n#if TEST_WCDB_OBJC\n#import <WCDBOBjc/WCDBObjc.h>\n#elif TEST_WCDB_CPP\n#import <WCDBCpp/WCDBCpp.h>\n#else\n#import <WCDB/WCDBObjc.h>\n#endif\n\n@interface VirtualTableFTS4Object (WCTTableCoding) <WCTTableCoding>\n\nWCDB_PROPERTY(identifier)\nWCDB_PROPERTY(content)\n\n@end\n"
  },
  {
    "path": "src/objc/tests/orm/virtual_table/VirtualTableFTS4Object.h",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import <Foundation/Foundation.h>\n\n@interface VirtualTableFTS4Object : NSObject\n\n@property (nonatomic, assign) int identifier;\n@property (nonatomic, assign) NSString* content;\n\n@end\n"
  },
  {
    "path": "src/objc/tests/orm/virtual_table/VirtualTableFTS4Object.mm",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"VirtualTableFTS4Object.h\"\n#import \"VirtualTableFTS4Object+WCTTableCoding.h\"\n#if TEST_WCDB_OBJC\n#import <WCDBOBjc/WCDBObjc.h>\n#elif TEST_WCDB_CPP\n#import <WCDBCpp/WCDBCpp.h>\n#else\n#import <WCDB/WCDBObjc.h>\n#endif\n\n@implementation VirtualTableFTS4Object\n\nWCDB_IMPLEMENTATION(VirtualTableFTS4Object)\nWCDB_SYNTHESIZE(identifier)\nWCDB_SYNTHESIZE(content)\n\nWCDB_VIRTUAL_TABLE_MODULE(WCTModuleFTS4)\n\nWCDB_VIRTUAL_TABLE_TOKENIZE(WCTTokenizerOneOrBinary)\n\nWCDB_VIRTUAL_TABLE_EXTERNAL_CONTENT(\"contentTable\")\n\nWCDB_UNINDEXED(identifier)\n\n@end\n"
  },
  {
    "path": "src/objc/tests/orm/virtual_table/VirtualTableFTS5Object+WCTTableCoding.h",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"VirtualTableFTS5Object.h\"\n#if TEST_WCDB_OBJC\n#import <WCDBOBjc/WCDBObjc.h>\n#elif TEST_WCDB_CPP\n#import <WCDBCpp/WCDBCpp.h>\n#else\n#import <WCDB/WCDBObjc.h>\n#endif\n\n@interface VirtualTableFTS5Object (WCTTableCoding) <WCTTableCoding>\n\nWCDB_PROPERTY(identifier)\nWCDB_PROPERTY(content)\n\n@end\n"
  },
  {
    "path": "src/objc/tests/orm/virtual_table/VirtualTableFTS5Object.h",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import <Foundation/Foundation.h>\n\n@interface VirtualTableFTS5Object : NSObject\n\n@property (nonatomic, assign) int identifier;\n@property (nonatomic, assign) NSString* content;\n\n@end\n"
  },
  {
    "path": "src/objc/tests/orm/virtual_table/VirtualTableFTS5Object.mm",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"VirtualTableFTS5Object.h\"\n#import \"VirtualTableFTS5Object+WCTTableCoding.h\"\n#if TEST_WCDB_OBJC\n#import <WCDBOBjc/WCDBObjc.h>\n#elif TEST_WCDB_CPP\n#import <WCDBCpp/WCDBCpp.h>\n#else\n#import <WCDB/WCDBObjc.h>\n#endif\n\n@implementation VirtualTableFTS5Object\n\nWCDB_IMPLEMENTATION(VirtualTableFTS5Object)\nWCDB_SYNTHESIZE(identifier)\nWCDB_SYNTHESIZE(content)\n\nWCDB_VIRTUAL_TABLE_MODULE(WCTModuleFTS5)\n\nWCDB_VIRTUAL_TABLE_TOKENIZE(WCTTokenizerPorter)\n\nWCDB_VIRTUAL_TABLE_EXTERNAL_CONTENT(\"contentTable\")\n\nWCDB_UNINDEXED(identifier)\n\n@end\n"
  },
  {
    "path": "src/objc/tests/repair/BackupTests.mm",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"BackupTestCase.h\"\n#import \"CoreConst.h\"\n#import \"NormalRepairTestObject.h\"\n#import \"Random+RepairTestObject.h\"\n@interface BackupTests : BackupTestCase\n\n@end\n\n@implementation BackupTests\n\n- (void)test_insert\n{\n    __block NSArray *newObjects = nil;\n    [self\n    executeFullTest:^{\n        newObjects = [[Random shared] repairObjectsWithClass:self.testClass andCount:100 startingFromIdentifier:self.objects.lastObject.identifier + 1];\n        XCTAssertTrue([self.table insertObjects:newObjects]);\n    }\n    withCheck:^{\n        NSArray<NSObject<RepairTestObject> *> *allObjects = [self.table getObjects];\n        [self checkObjects:self.objects containedIn:allObjects];\n        if (!self.corruptHeader || self.incrementalBackup) {\n            [self checkObjects:newObjects containedIn:allObjects];\n        }\n    }];\n}\n\n- (void)test_update\n{\n    [self\n    executeFullTest:^{\n        XCTAssertTrue([self.table updateProperty:[self.testClass textValue] toValue:@\"abc\" where:[self.testClass identifier] < 50]);\n    }\n    withCheck:^{\n        NSArray<NSObject<RepairTestObject> *> *allObjects = [self.table getObjects];\n        if (!self.corruptHeader || self.incrementalBackup) {\n            for (NSObject<RepairTestObject> *object in self.objects) {\n                if (object.identifier < 50) {\n                    object.textValue = @\"abc\";\n                }\n            }\n        }\n        [self checkObjects:self.objects containedIn:allObjects];\n    }];\n}\n\n- (void)test_delete\n{\n    [self\n    executeFullTest:^{\n        XCTAssertTrue([self.table deleteObjectsWhere:[self.testClass identifier] > 50]);\n    }\n    withCheck:^{\n        NSArray<NSObject<RepairTestObject> *> *allObjects = [self.table getObjects];\n        if (!self.corruptHeader || self.incrementalBackup) {\n            [self.objects removeObjectsInRange:NSMakeRange(50, 50)];\n        }\n        [self checkObjects:self.objects containedIn:allObjects];\n    }];\n}\n\n- (void)test_delete_all\n{\n    [self\n    executeFullTest:^{\n        XCTAssertTrue([self.table deleteObjects]);\n        XCTAssertTrue([self.database passiveCheckpoint]);\n        usleep(10000);\n        XCTAssertTrue([self.database backup]);\n    }\n    withCheck:^{\n        NSArray<NSObject<RepairTestObject> *> *allObjects = [self.table getObjects];\n        if (!self.incrementalBackup) {\n            TestCaseAssertTrue(allObjects.count == 0);\n        } else {\n            TestCaseAssertTrue(allObjects.firstObject.identifier == 1000);\n        }\n    }];\n}\n\n- (void)test_rename_table\n{\n    NSString *newTable = @\"newTable\";\n    [self\n    executeFullTest:^{\n        XCTAssertTrue([self.database execute:WCDB::StatementAlterTable().alterTable(self.tableName).renameToTable(newTable)]);\n        self.table = [self.database getTable:newTable withClass:self.testClass];\n    }\n    withCheck:^{\n        if (self.corruptHeader && !self.incrementalBackup) {\n            self.table = [self.database getTable:self.tableName withClass:self.testClass];\n        }\n        NSArray<NSObject<RepairTestObject> *> *allObjects = [self.table getObjects];\n        [self checkObjects:self.objects containedIn:allObjects];\n    }];\n}\n\n- (void)test_add_new_column\n{\n    NSString *newColumn = @\"newColumn\";\n    [self\n    executeFullTest:^{\n        XCTAssertTrue([self.database execute:WCDB::StatementAlterTable().alterTable(self.tableName).addColumn(WCDB::ColumnDef(newColumn, WCDB::ColumnType::Integer))]);\n    }\n    withCheck:^{\n        if (self.incrementalBackup) {\n            WCTOneRow *row = [self.database getRowFromStatement:WCDB::StatementSelect().select(WCDB::Column(newColumn)).from(self.tableName)];\n            XCTAssertTrue(row != nil && row.count == 1 && row[0] == [NSNull null]);\n        }\n        NSArray<NSObject<RepairTestObject> *> *allObjects = [self.table getObjects];\n        [self checkObjects:self.objects containedIn:allObjects];\n    }];\n}\n\n- (void)test_drop_table\n{\n    [self\n    executeFullTest:^{\n        XCTAssertTrue([self.database dropTable:self.tableName]);\n    }\n    withCheck:^{\n        if (!self.incrementalBackup) {\n            NSArray<NSObject<RepairTestObject> *> *allObjects = [self.table getObjects];\n            [self checkObjects:self.objects containedIn:allObjects];\n        } else {\n            XCTAssertFalse([self.database tableExists:self.tableName]);\n        }\n    }];\n}\n\n- (void)test_truncate_checkpoint\n{\n    [self\n    executeFullTest:^{\n        XCTAssertTrue([self.database truncateCheckpoint]);\n    }\n    withCheck:^{\n        NSArray<NSObject<RepairTestObject> *> *allObjects = [self.table getObjects];\n        if (!self.corruptHeader || self.incrementalBackup) {\n            [self checkObjects:self.objects containedIn:allObjects];\n        }\n        XCTAssertTrue(allObjects.count > 0);\n    }];\n}\n\n- (void)test_vacuum\n{\n    [self\n    executeFullTest:^{\n        XCTAssertTrue([self.database execute:WCDB::StatementVacuum().vacuum()]);\n    }\n    withCheck:^{\n        NSArray<NSObject<RepairTestObject> *> *allObjects = [self.table getObjects];\n        [self checkObjects:self.objects containedIn:allObjects];\n    }];\n}\n\n- (void)test_create_table_and_backup\n{\n    [self.database enableAutoBackup:true];\n    [self.database enableAutoCheckpoint:false];\n    size_t firstMaterialSize = 0;\n    for (int i = 0; i < 100; i++) {\n        bool ret = [self.database createTable:[NSString stringWithFormat:@\"testTable_%d\", i] withClass:NormalRepairTestObject.class];\n        XCTAssertTrue(ret);\n        [self.database passiveCheckpoint];\n        [self.database backup];\n        if (firstMaterialSize == 0) {\n            firstMaterialSize = [self.fileManager getFileSizeIfExists:self.database.firstMaterialPath];\n        }\n    }\n    size_t lastMaterialSize = [self.fileManager getFileSizeIfExists:self.database.lastMaterialPath];\n\n    TestCaseAssertTrue(lastMaterialSize < 200 * firstMaterialSize);\n    TestCaseAssertTrue([self.database retrieve:nil] > 0);\n\n    NSArray<WCTMaster *> *masters = [self.database getObjectsOfClass:WCTMaster.class fromTable:WCTMaster.tableName];\n    // They are sqlite_sequence, 100 tables and 100 indexes.\n    TestCaseAssertTrue(masters.count == 201);\n}\n\n- (void)test_dual_backup\n{\n    TestCaseAssertFalse([self.fileManager fileExistsAtPath:self.database.firstMaterialPath]);\n    TestCaseAssertFalse([self.fileManager fileExistsAtPath:self.database.lastMaterialPath]);\n\n    TestCaseAssertTrue([self.database backup]);\n    TestCaseAssertTrue([self.fileManager fileExistsAtPath:self.database.firstMaterialPath]);\n    TestCaseAssertFalse([self.fileManager fileExistsAtPath:self.database.lastMaterialPath]);\n\n    [NSThread sleepForTimeInterval:0.1];\n    TestCaseAssertTrue([self.database backup]);\n    TestCaseAssertTrue([self.fileManager fileExistsAtPath:self.database.firstMaterialPath]);\n    TestCaseAssertTrue([self.fileManager fileExistsAtPath:self.database.lastMaterialPath]);\n\n    {\n        // old one will be replaced\n        NSDate *firstBackupModifiedDate = [self.fileManager attributesOfItemAtPath:self.database.firstMaterialPath error:nil][NSFileModificationDate];\n        TestCaseAssertTrue(firstBackupModifiedDate != nil);\n        NSDate *lastBackupModifiedDate = [self.fileManager attributesOfItemAtPath:self.database.lastMaterialPath error:nil][NSFileModificationDate];\n        TestCaseAssertTrue(lastBackupModifiedDate != nil);\n        TestCaseAssertTrue([firstBackupModifiedDate compare:lastBackupModifiedDate] == NSOrderedAscending);\n    }\n\n    [NSThread sleepForTimeInterval:0.1];\n    TestCaseAssertTrue([self.database backup]);\n\n    {\n        // old one will be replaced\n        NSDate *firstBackupModifiedDate = [self.fileManager attributesOfItemAtPath:self.database.firstMaterialPath error:nil][NSFileModificationDate];\n        TestCaseAssertTrue(firstBackupModifiedDate != nil);\n        NSDate *lastBackupModifiedDate = [self.fileManager attributesOfItemAtPath:self.database.lastMaterialPath error:nil][NSFileModificationDate];\n        TestCaseAssertTrue(lastBackupModifiedDate != nil);\n        TestCaseAssertTrue([firstBackupModifiedDate compare:lastBackupModifiedDate] == NSOrderedDescending);\n    }\n}\n\n- (void)test_empty_backup\n{\n    [self executeTest:^{\n        TestCaseAssertTrue([self.database removeFiles]);\n        TestCaseAssertTrue([self.database backup]);\n    }];\n}\n\n- (void)test_filter\n{\n    [self.database filterBackup:^BOOL(NSString *tableName) {\n        if ([tableName isEqualToString:self.tableName] or [NSString stringWithFormat:@\"'%@'\", self.tableName]) {\n            return false;\n        }\n        return true;\n    }];\n    [self\n    executeFullTest:^{\n    }\n    withCheck:^{\n        XCTAssertFalse([self.database tableExists:self.tableName]);\n    }];\n}\n\n- (void)test_backup_fail\n{\n    NSFileManager *fileManager = [NSFileManager defaultManager];\n    TestCaseAssertTrue([fileManager createDirectoryAtPath:self.database.firstMaterialPath withIntermediateDirectories:YES attributes:nil error:nil]);\n    TestCaseAssertTrue([fileManager createDirectoryAtPath:self.database.lastMaterialPath withIntermediateDirectories:YES attributes:nil error:nil]);\n\n    TestCaseAssertFalse([self.database backup]);\n}\n\n- (void)test_auto_backup_when_checkpointed\n{\n    [self.database enableAutoCheckpoint:NO];\n    [self.database enableAutoBackup:YES];\n    TestCaseObject *object = [Random.shared autoIncrementTestCaseObject];\n    XCTAssertTrue([self createTable]);\n    TestCaseAssertTrue([self.table insertObject:object]);\n\n    TestCaseAssertFalse([self.fileManager fileExistsAtPath:self.database.firstMaterialPath]);\n    TestCaseAssertFalse([self.fileManager fileExistsAtPath:self.database.incrementalMaterialPath]);\n    TestCaseAssertTrue([self.database passiveCheckpoint]);\n    usleep(10000);\n\n    TestCaseAssertFalse([self.fileManager fileExistsAtPath:self.database.firstMaterialPath]);\n    TestCaseAssertFalse([self.fileManager fileExistsAtPath:self.database.incrementalMaterialPath]);\n\n    [NSThread sleepForTimeInterval:WCDB::OperationQueueTimeIntervalForBackup + self.delayForTolerance];\n    TestCaseAssertTrue([self.fileManager fileExistsAtPath:self.database.firstMaterialPath]);\n    TestCaseAssertTrue([self.fileManager fileExistsAtPath:self.database.incrementalMaterialPath]);\n\n    TestCaseAssertTrue([self.table insertObject:object]);\n    TestCaseAssertTrue([self.database passiveCheckpoint]);\n    usleep(10000);\n    TestCaseAssertFalse([self.fileManager fileExistsAtPath:self.database.lastMaterialPath]);\n\n    [NSThread sleepForTimeInterval:WCDB::OperationQueueTimeIntervalForBackup + self.delayForTolerance];\n\n    TestCaseAssertTrue([self.table insertObject:object]);\n    TestCaseAssertTrue([self.database passiveCheckpoint]);\n    usleep(10000);\n\n    TestCaseAssertTrue([self.fileManager fileExistsAtPath:self.database.lastMaterialPath]);\n}\n\n- (void)test_incremental_backup_interrupted\n{\n    __block bool tested = false;\n    [self.database traceError:^(WCTError *error) {\n        if (error.level == WCTErrorLevelWarning && [error.message isEqualToString:@\"Expired incremental Material\"]) {\n            tested = true;\n        }\n    }];\n    [self.database enableAutoBackup:YES];\n    [self.database enableAutoCheckpoint:NO];\n\n    //Initialize backup matrial\n    [self createTable];\n    XCTAssertTrue([self.table insertObjects:[Random.shared autoIncrementTestCaseObjectsWithCount:2]]);\n    XCTAssertTrue([self.database passiveCheckpoint]);\n    XCTAssertTrue([self.database backup]);\n    usleep(10000);\n    XCTAssertFalse(tested);\n\n    //Incremental backup\n    XCTAssertTrue([self.table insertObjects:[Random.shared autoIncrementTestCaseObjectsWithCount:2]]);\n    XCTAssertTrue([self.database passiveCheckpoint]);\n    usleep(10000);\n    XCTAssertFalse(tested);\n\n    [self.database enableAutoBackup:false];\n\n    //Incremental backup interrupted\n    XCTAssertTrue([self.table insertObjects:[Random.shared autoIncrementTestCaseObjectsWithCount:2]]);\n    XCTAssertTrue([self.database passiveCheckpoint]);\n    usleep(10000);\n    XCTAssertFalse(tested);\n\n    [self.database enableAutoBackup:true];\n\n    //Incremental backup matrial expired\n    XCTAssertTrue([self.table insertObjects:[Random.shared autoIncrementTestCaseObjectsWithCount:2]]);\n    XCTAssertTrue([self.database passiveCheckpoint]);\n    usleep(10000);\n    XCTAssertTrue(tested);\n}\n\n@end\n"
  },
  {
    "path": "src/objc/tests/repair/DepositTests.mm",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"BackupTestCase.h\"\n#import \"Random+RepairTestObject.h\"\n\n@interface DepositTests : BackupTestCase\n\n@end\n\n@implementation DepositTests\n\n- (void)test_desposit\n{\n    [self\n    executeTest:^{\n        int rowId = (int) self.objects.count;\n        {\n            // 1.\n            TestCaseAssertTrue([self.database backup]);\n            TestCaseAssertTrue([self.database deposit]);\n\n            NSNumber* count = [self.database getValueFromStatement:WCDB::StatementSelect().select([self.testClass allProperties].count()).from(self.tableName)].numberValue;\n            TestCaseAssertTrue(count != nil);\n            TestCaseAssertTrue(count.integerValue == 0);\n\n            if ([self.testClass isAutoIncrement]) {\n                NSObject<RepairTestObject>* object = [Random.shared repairObjectWithClass:self.testClass andIdentifier:0];\n                object.isAutoIncrement = YES;\n\n                TestCaseAssertTrue([self.table insertObject:object]);\n                ++rowId;\n                TestCaseAssertTrue(object.lastInsertedRowID == rowId);\n            }\n        }\n\n        {\n            // 2.\n            TestCaseAssertTrue([self.database backup]);\n            TestCaseAssertTrue([self.database deposit]);\n\n            NSNumber* count = [self.database getValueFromStatement:WCDB::StatementSelect().select(TestCaseObject.allProperties.count()).from(self.tableName)].numberValue;\n            TestCaseAssertTrue(count != nil);\n            TestCaseAssertTrue(count.integerValue == 0);\n\n            if ([self.testClass isAutoIncrement]) {\n                NSObject<RepairTestObject>* object = [Random.shared repairObjectWithClass:self.testClass andIdentifier:0];\n                object.isAutoIncrement = YES;\n\n                TestCaseAssertTrue([self.table insertObject:object]);\n                ++rowId;\n                TestCaseAssertTrue(object.lastInsertedRowID == rowId);\n            }\n        }\n\n        TestCaseAssertTrue([self.fileManager fileExistsAtPath:self.database.factoryPath]);\n        TestCaseAssertTrue([self.database containsDeposited]);\n        TestCaseAssertTrue([self.database removeDeposited]);\n        TestCaseAssertFalse([self.database containsDeposited]);\n        TestCaseAssertFalse([self.fileManager fileExistsAtPath:self.database.factoryPath]);\n    }];\n}\n\n@end\n"
  },
  {
    "path": "src/objc/tests/repair/RetrieveRobustyTests.mm",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"BackupTestCase.h\"\n#import \"TestCase.h\"\n\n@interface RetrieveRobustyTests : RobustyTestCase\n\n@property (nonatomic, readonly) double expectedAttackRadio;\n@property (nonatomic, readonly) double deviationForTolerance;\n\n@end\n\n@implementation RetrieveRobustyTests\n\n- (void)setUp\n{\n    [super setUp];\n    self.skipDebugLog = YES;\n    self.tableFactor = 1000;\n    [self.database enableAutoCheckpoint:YES];\n}\n\n- (double)expectedAttackRadio\n{\n    return 0.01;\n}\n\n- (double)deviationForTolerance\n{\n    return 0.05;\n}\n\n- (BOOL)shouldAttack\n{\n    return Random.shared.float_0_1 < self.expectedAttackRadio;\n}\n\n- (BOOL)isToleranceForRetrieveScore:(double)retrieveScore\n                    andObjectsScore:(double)objectsScore\n{\n    return retrieveScore < objectsScore * (1 + self.deviationForTolerance) && retrieveScore > objectsScore * (1 - self.deviationForTolerance);\n}\n\n- (double)getObjectsScoreFromRetrievedTableObjects:(NSDictionary<NSString*, NSArray<TestCaseObject*>*>*)retrievedTableObjects\n                           andExpectedTableObjects:(NSDictionary<NSString*, NSArray<TestCaseObject*>*>*)expectedTableObjects\n{\n    int totalCount = 0;\n    int matchedCount = 0;\n    for (NSString* expectedTableName in expectedTableObjects.allKeys) {\n        NSArray<TestCaseObject*>* expectedObjects = [expectedTableObjects objectForKey:expectedTableName];\n        NSSet<TestCaseObject*>* expectedObjectsSet = [NSSet setWithArray:expectedObjects];\n        TestCaseAssertTrue(expectedObjectsSet.count == expectedObjects.count);\n        totalCount += expectedObjectsSet.count;\n\n        NSArray<TestCaseObject*>* retrievedObjects = [retrievedTableObjects objectForKey:expectedTableName];\n        if (retrievedObjects.count > 0) {\n            for (TestCaseObject* retrievedObject in retrievedObjects) {\n                if ([expectedObjectsSet containsObject:retrievedObject]) {\n                    ++matchedCount;\n                }\n            }\n        }\n    }\n    return (double) matchedCount / totalCount;\n}\n\n- (double)pageBasedAttackAsExpectedRadio\n{\n    __block double attackedRatio = 0;\n\n    // make database corrupted\n    [self.database close:^{\n        int totalNumberOfPages = 0;\n        int totalNumberOfAttackedPages = 0;\n        {\n            // database\n            auto optionalNumberOfPages = [self.database getNumberOfPages];\n            TestCaseAssertFalse(optionalNumberOfPages.failed());\n            int numberOfPages = (int) optionalNumberOfPages.value();\n            totalNumberOfPages += numberOfPages;\n            for (int i = 0; i < numberOfPages; ++i) {\n                if ([self shouldAttack]) {\n                    [self.database corruptPage:i + 1];\n                    ++totalNumberOfAttackedPages;\n                }\n            }\n        }\n\n        {\n            // wal\n            WCTOptionalSize optionalNumberOfFrames = [self.database getNumberOfWalFrames];\n            TestCaseAssertFalse(optionalNumberOfFrames.failed());\n            int numberOfFrames = (int) optionalNumberOfFrames.value();\n            totalNumberOfPages += numberOfFrames;\n            for (int i = 0; i < numberOfFrames; ++i) {\n                if ([self shouldAttack]) {\n                    [self.database corruptWalFrame:i + 1];\n                    ++totalNumberOfAttackedPages;\n                }\n            }\n        }\n        attackedRatio = (float) totalNumberOfAttackedPages / totalNumberOfPages;\n    }];\n    return attackedRatio;\n}\n\n- (void)test_feature_page_based_robusty\n{\n    NSArray* sizes = @[\n        @(10 * 1024 * 1024),\n        @(100 * 1024 * 1024),\n#ifndef WCDB_QUICK_TESTS\n        @(1024 * 1024 * 1024),\n#endif\n    ];\n    [self.database enableAutoBackup:YES];\n    for (NSNumber* size in sizes) {\n        self.expectedDatabaseSize = size.integerValue;\n        [self.database removeFiles];\n        TestCaseAssertTrue([self fillDatabaseUntilMeetExpectedSize]);\n\n        NSDictionary<NSString*, NSArray<TestCaseObject*>*>* expectedTableObjects = [self getTableObjects];\n        TestCaseAssertTrue(expectedTableObjects != nil);\n\n        TestCaseAssertTrue([self.database backup]);\n\n        double attackedRadio = [self pageBasedAttackAsExpectedRadio];\n\n        double retrievedScore = [self.database retrieve:nullptr];\n\n        NSDictionary<NSString*, NSArray<TestCaseObject*>*>* retrievedTableObjects = [self getTableObjects];\n        TestCaseAssertTrue(retrievedTableObjects != nil);\n\n        double objectsScore = [self getObjectsScoreFromRetrievedTableObjects:retrievedTableObjects andExpectedTableObjects:expectedTableObjects];\n\n        TestCaseLog(@\"Radio: attacked: %.8f, expected %.8f\", attackedRadio, self.expectedAttackRadio);\n        TestCaseLog(@\"Score: retrieve: %.8f, objects: %.8f\", retrievedScore, objectsScore);\n\n        TestCaseAssertTrue([self isToleranceForRetrieveScore:retrievedScore andObjectsScore:objectsScore]);\n    }\n}\n\n@end\n"
  },
  {
    "path": "src/objc/tests/repair/RetrieveTests.mm",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"BackupTestCase.h\"\n#import \"Random+RepairTestObject.h\"\n#import \"SizeBasedFactory.h\"\n\n@interface RetrieveTests : BackupTestCase\n\n@end\n\n@implementation RetrieveTests\n\n- (void)test_empty\n{\n    [self\n    executeTest:^{\n        self.path = [self.directory stringByAppendingPathComponent:@\"empty\"];\n        TestCaseAssertEqual([self.database retrieve:nil], -1);\n        self.path = nil;\n    }];\n}\n\n- (void)doTestObjectsRetrieved\n{\n    XCTAssertTrue([[self.table getObjects] isEqualToArray:self.objects]);\n}\n\n- (void)doTestObjectsNotRetrieved\n{\n    XCTAssertFalse([self.database tableExists:self.tableName]);\n}\n\n- (void)doBackupWithIncrementalMaterial\n{\n    XCTAssertTrue([self.database backup]);\n    NSArray* objects = [[Random shared] repairObjectsWithClass:self.testClass andCount:100 startingFromIdentifier:self.objects.lastObject.identifier + 1];\n    [self.objects addObjectsFromArray:objects];\n    XCTAssertTrue([self.table insertObjects:objects]);\n\n    XCTAssertTrue([self.database passiveCheckpoint]);\n    usleep(10000);\n    XCTAssertTrue([self.database backup]);\n}\n\n- (void)doTestRetrieve\n{\n    __block double lastPercentage = 0;\n    __block BOOL sanity = YES;\n    double score = [self.database retrieve:^(double percentage, double increment) {\n        if (percentage - lastPercentage != increment\n            || increment <= 0) {\n            TestCaseFailure();\n            sanity = NO;\n        }\n        lastPercentage = percentage;\n        return true;\n    }];\n    TestCaseAssertTrue(sanity);\n    TestCaseAssertEqual(score, 1.0);\n    TestCaseAssertEqual(lastPercentage, 1.0);\n}\n\n- (void)doTestRetrieveFailed\n{\n    __block double lastPercentage = 0;\n    __block BOOL sanity = YES;\n    double score = [self.database retrieve:^(double percentage, double increment) {\n        if (percentage - lastPercentage != increment\n            || increment <= 0) {\n            TestCaseFailure();\n            sanity = NO;\n        }\n        lastPercentage = percentage;\n        return true;\n    }];\n    TestCaseAssertTrue(sanity);\n    TestCaseAssertNotEqual(score, 1.0);\n    TestCaseAssertEqual(lastPercentage, 1.0);\n}\n\n- (void)doTestRetrieveInterrupt\n{\n    __block double lastPercentage = 0;\n    __block BOOL sanity = YES;\n    float interruptPoint = Random.shared.float_0_1;\n    double score = [self.database retrieve:^(double percentage, double increment) {\n        if (percentage - lastPercentage != increment\n            || increment <= 0) {\n            TestCaseFailure();\n            sanity = NO;\n        }\n        lastPercentage = percentage;\n        return percentage < interruptPoint;\n    }];\n    TestCaseAssertTrue(sanity);\n    TestCaseAssertEqual(score, -1);\n    TestCaseAssertTrue(lastPercentage >= interruptPoint && lastPercentage < 1 && lastPercentage < interruptPoint + [self.testClass hasRowid] ? 0.1 : 0.5);\n}\n\n#pragma mark - Non-Corrupted\n- (void)test_retrieve_with_backup_and_deposit\n{\n    [self\n    executeTest:^{\n        [self doBackupWithIncrementalMaterial];\n        TestCaseAssertTrue([self.database deposit]);\n\n        [self doTestRetrieve];\n        [self doTestObjectsRetrieved];\n    }];\n}\n\n- (void)test_interrupt_retrieve_with_backup_and_deposit\n{\n    [self\n    executeTest:^{\n        [self doBackupWithIncrementalMaterial];\n        [self doTestRetrieveInterrupt];\n        [self doTestObjectsRetrieved];\n    }];\n}\n\n- (void)test_retrieve_with_backup_and_without_deposit\n{\n    __block double mechanicScore = 0;\n    __block double crawlerScore = 0;\n    __block double summaryScore = 0;\n\n    __block double mechanicCost = 0;\n    __block double crawlerCost = 0;\n    __block double summaryCost = 0;\n\n    __block double mechanicSpeed = 0;\n    __block double crawlerSpeed = 0;\n\n    __block double mechanicSize = 0;\n    __block double crawlerSize = 0;\n\n    __block double mechanicWeight = 0;\n    __block double crawlerWeight = 0;\n    [self.database traceError:^(WCTError* error) {\n        if (error.level == WCTErrorLevelNotice\n            && error.code == WCTErrorCodeNotice) {\n            NSDictionary* userInfo = error.userInfo;\n            if ([error.message isEqualToString:@\"Mechanic Retrieve Report.\"]) {\n                mechanicCost = ((NSString*) [userInfo objectForKey:@\"Cost\"]).doubleValue;\n                mechanicSize = ((NSString*) [userInfo objectForKey:@\"Size\"]).doubleValue;\n                mechanicSpeed = ((NSString*) [userInfo objectForKey:@\"Speed\"]).doubleValue;\n                mechanicWeight = ((NSString*) [userInfo objectForKey:@\"Weight\"]).doubleValue;\n                mechanicScore = ((NSString*) [userInfo objectForKey:@\"Score\"]).doubleValue;\n            } else if ([error.message isEqualToString:@\"Crawler Retrieve Report.\"]) {\n                crawlerCost = ((NSString*) [userInfo objectForKey:@\"Cost\"]).doubleValue;\n                crawlerSize = ((NSString*) [userInfo objectForKey:@\"Size\"]).doubleValue;\n                crawlerSpeed = ((NSString*) [userInfo objectForKey:@\"Speed\"]).doubleValue;\n                crawlerWeight = ((NSString*) [userInfo objectForKey:@\"Weight\"]).doubleValue;\n                crawlerScore = ((NSString*) [userInfo objectForKey:@\"Score\"]).doubleValue;\n            } else if ([error.message isEqualToString:@\"Summary Retrieve Report.\"]) {\n                summaryCost = ((NSString*) [userInfo objectForKey:@\"Cost\"]).doubleValue;\n                summaryScore = ((NSString*) [userInfo objectForKey:@\"Score\"]).doubleValue;\n            }\n        }\n    }];\n    [self\n    executeTest:^{\n        [self doBackupWithIncrementalMaterial];\n\n        [self doTestRetrieve];\n        [self doTestObjectsRetrieved];\n\n        TestCaseAssertTrue(mechanicCost > 0);\n        TestCaseAssertTrue(mechanicSize > 0);\n        TestCaseAssertEqual(mechanicScore, 1);\n        TestCaseAssertTrue(mechanicSpeed > 0);\n        TestCaseAssertEqual(mechanicWeight, 100); // for 100 percent\n\n        TestCaseAssertTrue(crawlerCost > 0);\n        TestCaseAssertTrue(crawlerSize > 0);\n        TestCaseAssertEqual(crawlerScore, 1);\n        TestCaseAssertTrue(crawlerSpeed > 0);\n        TestCaseAssertEqual(crawlerWeight, 100); // for 100 percent\n\n        TestCaseAssertTrue(summaryCost > 0);\n        TestCaseAssertEqual(summaryScore, 1);\n    }];\n}\n\n- (void)test_retrieve_without_backup_and_with_deposit\n{\n    [self\n    executeTest:^{\n        TestCaseAssertTrue([self.database deposit]);\n\n        [self doTestRetrieve];\n        [self doTestObjectsRetrieved];\n    }];\n}\n\n- (void)test_retrieve_without_backup_and_deposite\n{\n    [self\n    executeTest:^{\n        [self doTestRetrieve];\n        [self doTestObjectsRetrieved];\n    }];\n}\n\n#pragma mark - Corrupted\n- (void)test_retrieve_corrupted_with_backup_and_deposit\n{\n    [self\n    executeTest:^{\n        [self doBackupWithIncrementalMaterial];\n\n        TestCaseAssertTrue([self.database corruptHeaderWithinCloseAfterTruncatedCheckpoint]);\n\n        TestCaseAssertTrue([self.database deposit]);\n\n        [self doTestRetrieve];\n\n        [self doTestObjectsRetrieved];\n    }];\n}\n\n- (void)test_retrieve_corrupted_with_backup_and_without_deposit\n{\n    [self\n    executeTest:^{\n        [self doBackupWithIncrementalMaterial];\n\n        TestCaseAssertTrue([self.database corruptHeaderWithinCloseAfterTruncatedCheckpoint]);\n\n        [self doTestRetrieve];\n\n        [self doTestObjectsRetrieved];\n    }];\n}\n\n- (void)test_retrieve_corrupted_without_backup_and_with_deposit\n{\n    [self\n    executeTest:^{\n        TestCaseAssertTrue([self.database corruptHeaderWithinCloseAfterTruncatedCheckpoint]);\n\n        TestCaseAssertTrue([self.database deposit]);\n\n        [self doTestRetrieveFailed];\n\n        [self doTestObjectsNotRetrieved];\n    }];\n}\n\n#pragma mark - Corrupted Schema\n- (void)doCorruptSchema\n{\n    TestCaseAssertTrue([self.database execute:WCDB::StatementPragma().pragma(WCDB::Pragma::writableSchema()).to(true)]);\n    WCTMaster* indexMaster = [[WCTMaster alloc] init];\n    indexMaster.type = @\"index\";\n    indexMaster.name = @\"unexist_index\";\n    indexMaster.tblName = @\"unexist_table\";\n    indexMaster.sql = @\"CREATE INDEX unexist_index on unexist_table(unexist_column)\";\n    TestCaseAssertTrue([self.database insertObject:indexMaster intoTable:WCTMaster.tableName]);\n    [self.database close];\n    TestCaseAssertFalse([self.database canOpen]);\n}\n\n- (void)test_retrieve_corrupted_schema\n{\n    [self executeTest:^{\n        TestCaseAssertTrue([self.database backup]);\n        [self doCorruptSchema];\n        TestCaseAssertTrue([self.database retrieve:nil] > 0);\n        [self doTestObjectsRetrieved];\n    }];\n}\n\n- (void)test_auto_detect_corrupted_schema\n{\n    [self executeTest:^{\n        [self doCorruptSchema];\n        __block BOOL detectCorrupted = false;\n        [self.database setNotificationWhenCorrupted:^(WCTDatabase* _Nonnull) {\n            detectCorrupted = true;\n        }];\n        TestCaseAssertFalse([self.table insertObject:[[Random shared] repairObjectWithClass:self.testClass andIdentifier:10000]]);\n        [NSThread sleepForTimeInterval:1.0];\n        TestCaseAssertTrue(detectCorrupted);\n        TestCaseAssertTrue([self.database isAlreadyCorrupted]);\n        TestCaseAssertTrue([self.database retrieve:nil] > 0);\n        [self doTestObjectsRetrieved];\n    }];\n}\n\n#ifndef WCDB_QUICK_TESTS\n- (void)test_backup_huge_database\n{\n    self.skipDebugLog = YES;\n    SizeBasedFactory* factory = [[SizeBasedFactory alloc] initWithDirectory:self.class.cacheRoot];\n    factory.quality = 6LL * 1024 * 1024 * 1024; // 6GB > 4GB\n    factory.tolerance = 0.02;\n    [factory.database enableAutoBackup:YES];\n\n    [factory produce:self.path];\n\n    TestCaseAssertTrue([self.database backup]);\n\n    TestCaseAssertTrue([self.database corruptHeaderWithinCloseAfterTruncatedCheckpoint]);\n\n    __block double percentage = 0;\n    TestCaseAssertEqual([self.database retrieve:^(double progress, double increment) {\n                            WCDB_UNUSED(increment);\n                            double newPercentage = progress * 100.0;\n                            if (newPercentage - percentage >= 1.0) {\n                                TestCaseLog(@\"Retrieving %.2f%%\", newPercentage);\n                                percentage = newPercentage;\n                            }\n                            return true;\n                        }],\n                        1.0);\n}\n\n- (void)test_retrieve_huge_database\n{\n    self.skipDebugLog = YES;\n    SizeBasedFactory* factory = [[SizeBasedFactory alloc] initWithDirectory:self.class.cacheRoot];\n    factory.quality = 6LL * 1024 * 1024 * 1024; // 6GB > 4GB\n    [factory.database enableAutoBackup:YES];\n    factory.tolerance = 0.02;\n\n    [factory produce:self.path];\n\n    __block double percentage = 0;\n    TestCaseAssertEqual([self.database retrieve:^(double progress, double increment) {\n                            WCDB_UNUSED(increment);\n                            double newPercentage = progress * 100.0;\n                            if (newPercentage - percentage >= 1.0) {\n                                TestCaseLog(@\"Retrieving %.2f%%\", newPercentage);\n                                percentage = newPercentage;\n                            }\n                            return true;\n                        }],\n                        1.0);\n}\n#endif\n\n@end\n"
  },
  {
    "path": "src/objc/tests/repair/VacuumRobustyTests.mm",
    "content": "//\n// Created by qiuwenchen on 2023/12/20.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"TestCase.h\"\n#import <Foundation/Foundation.h>\n\n@interface VacuumRobustyTests : RobustyTestCase\n\n@end\n\n@implementation VacuumRobustyTests\n\n- (void)setUp\n{\n    [super setUp];\n    self.skipDebugLog = YES;\n    [self.database enableAutoCheckpoint:YES];\n}\n\n- (void)test_vacuum_robusty\n{\n    NSArray* sizes = @[\n        @(10 * 1024 * 1024),\n        @(100 * 1024 * 1024),\n#ifndef WCDB_QUICK_TESTS\n        @(1024 * 1024 * 1024),\n#endif\n    ];\n    for (NSNumber* size in sizes) {\n        self.expectedDatabaseSize = size.integerValue;\n        [self.database removeFiles];\n        TestCaseAssertTrue([self fillDatabaseUntilMeetExpectedSize]);\n\n        NSDictionary<NSString*, NSArray<TestCaseObject*>*>* expectedTableObjects = [self getTableObjects];\n        TestCaseAssertTrue(expectedTableObjects != nil);\n\n        TestCaseAssertTrue([self.database vacuum:nil]);\n\n        NSDictionary<NSString*, NSArray<TestCaseObject*>*>* currentTableObjects = [self getTableObjects];\n\n        TestCaseAssertTrue([currentTableObjects isEqualToDictionary:expectedTableObjects]);\n    }\n}\n\n@end\n"
  },
  {
    "path": "src/objc/tests/repair/VacuumTests.mm",
    "content": "//\n// Created by qiuwenchen on 2023/12/17.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"BackupTestCase.h\"\n#import \"CoreConst.h\"\n#import \"FTS3Object+WCTTableCoding.h\"\n#import \"FTS3Object.h\"\n#import \"FTS5Object.h\"\n#import \"Random+RepairTestObject.h\"\n#import \"SizeBasedFactory.h\"\n#import <Foundation/Foundation.h>\n\n@interface VacuumTests : BackupTestCase\n\n@end\n\n@implementation VacuumTests\n\n- (void)setUp\n{\n    [super setUp];\n    self.objectCount = 10000;\n}\n\n- (void)test_empty\n{\n    [self\n    executeTest:^{\n        self.path = [self.directory stringByAppendingPathComponent:@\"empty\"];\n        TestCaseAssertTrue([self.database vacuum:nil]);\n        self.path = nil;\n    }];\n}\n\n- (void)doTestObjectsExist\n{\n    XCTAssertTrue([[self.table getObjects] isEqualToArray:self.objects]);\n}\n\n- (void)doTestObjectsNoExist\n{\n    XCTAssertFalse([self.database tableExists:self.tableName]);\n}\n\n- (void)doTestFactoryNotExist\n{\n    XCTAssertFalse([self.fileManager fileExistsAtPath:[self.database.path stringByAppendingString:@\".factory\"]]);\n}\n\n- (void)doTestVacuum\n{\n    __block double lastPercentage = 0;\n    __block BOOL sanity = YES;\n    bool succeed = [self.database vacuum:^(double percentage, double increment) {\n        if (percentage - lastPercentage != increment\n            || increment <= 0) {\n            TestCaseFailure();\n            sanity = NO;\n        }\n        lastPercentage = percentage;\n        return true;\n    }];\n    TestCaseAssertTrue(sanity);\n    TestCaseAssertTrue(succeed);\n    TestCaseAssertEqual(lastPercentage, 1.0);\n}\n\n- (void)doTestInterruptVacuum\n{\n    __block double lastPercentage = 0;\n    __block BOOL sanity = YES;\n    float interruptPoint = Random.shared.float_0_1 * 0.6f;\n    bool succeed = [self.database vacuum:^(double percentage, double increment) {\n        if (percentage - lastPercentage != increment\n            || increment <= 0) {\n            TestCaseFailure();\n            sanity = NO;\n        }\n        lastPercentage = percentage;\n        return percentage < interruptPoint;\n    }];\n    TestCaseAssertTrue(sanity);\n    TestCaseAssertTrue(!succeed || ![self.testClass hasRowid]);\n    TestCaseAssertTrue(![self.testClass hasRowid] || (lastPercentage >= interruptPoint && lastPercentage < 1 && lastPercentage < interruptPoint + 0.5));\n}\n\n- (void)doTestVacuumFailed\n{\n    __block double lastPercentage = 0;\n    __block BOOL sanity = YES;\n    bool succeed = [self.database vacuum:^(double percentage, double increment) {\n        if (percentage - lastPercentage != increment\n            || increment <= 0) {\n            TestCaseFailure();\n            sanity = NO;\n        }\n        lastPercentage = percentage;\n        return true;\n    }];\n    TestCaseAssertTrue(sanity);\n    TestCaseAssertFalse(succeed);\n    TestCaseAssertEqual(lastPercentage, 0);\n}\n\n#pragma mark - Non-Corrupted\n- (void)test_vacuum\n{\n    [self\n    executeTest:^{\n        [self doTestVacuum];\n        [self doTestObjectsExist];\n        [self doTestFactoryNotExist];\n    }];\n}\n\n- (void)test_interrupt_vacuum\n{\n    [self\n    executeTest:^{\n        [self doTestInterruptVacuum];\n        [self doTestObjectsExist];\n        [self doTestFactoryNotExist];\n    }];\n}\n\n#pragma mark - Corrupted\n- (void)test_vacuum_corrupted\n{\n    [self\n    executeTest:^{\n        TestCaseAssertTrue([self.database corruptHeaderWithinCloseAfterTruncatedCheckpoint]);\n        [self doTestVacuumFailed];\n        [self doTestObjectsNoExist];\n        [self doTestFactoryNotExist];\n    }];\n}\n\n- (void)test_vacuum_corrupt_opened\n{\n    [self\n    executeTest:^{\n        TestCaseAssertTrue([self.database canOpen]);\n        [self.database truncateCheckpoint];\n        [self.database corruptPage:1];\n\n        [self doTestVacuumFailed];\n\n        [self.database close];\n        [self doTestObjectsNoExist];\n        [self doTestFactoryNotExist];\n    }];\n}\n\n#pragma mark - auto vacuum\n- (void)test_auto_vacuum\n{\n    [self.database enableAutoVacuum:NO];\n    WCTValue* autoVaccum = [self.database getValueFromStatement:WCDB::StatementPragma().pragma(WCDB::Pragma::autoVacuum())];\n    TestCaseAssertTrue(autoVaccum.numberValue.intValue == 1);\n\n    [self.database enableAutoVacuum:YES];\n    autoVaccum = [self.database getValueFromStatement:WCDB::StatementPragma().pragma(WCDB::Pragma::autoVacuum())];\n    TestCaseAssertTrue(autoVaccum.numberValue.intValue == 2);\n}\n\n- (void)test_incremental_vacuum\n{\n    [self.database enableAutoVacuum:YES];\n    TestCaseAssertTrue([self createTable]);\n    TestCaseAssertTrue([self.table insertObjects:[[Random shared] autoIncrementTestCaseObjectsWithCount:1000]]);\n    TestCaseAssertTrue([self.database truncateCheckpoint]);\n    TestCaseAssertTrue([self.database getNumberOfPages] > 3);\n\n    TestCaseAssertTrue([self.database dropTable:self.tableName]);\n    TestCaseAssertTrue([self.database truncateCheckpoint]);\n    TestCaseAssertTrue([self.database getNumberOfPages] > 3);\n\n    TestCaseAssertTrue([self.database incrementalVacuum:0]);\n    TestCaseAssertTrue([self.database truncateCheckpoint]);\n    WCTValue* freelist = [self.database getValueFromStatement:WCDB::StatementPragma().pragma(WCDB::Pragma::freelistCount())];\n    TestCaseAssertTrue(freelist != nil && freelist.numberValue.intValue == 0);\n    TestCaseAssertTrue([self.database getNumberOfPages] == 3);\n}\n\n- (void)test_backup_and_recover_with_incremental_vacuum\n{\n    [self.database enableAutoVacuum:NO];\n    [self.database enableAutoCheckpoint:NO];\n    [self.database enableAutoBackup:YES];\n    TestCaseObject* object = [Random.shared autoIncrementTestCaseObject];\n    XCTAssertTrue([self createTable]);\n    TestCaseAssertTrue([self.table insertObject:object]);\n\n    TestCaseAssertFalse([self.fileManager fileExistsAtPath:self.database.firstMaterialPath]);\n    TestCaseAssertFalse([self.fileManager fileExistsAtPath:self.database.incrementalMaterialPath]);\n    TestCaseAssertTrue([self.database passiveCheckpoint]);\n    usleep(10000);\n\n    TestCaseAssertFalse([self.fileManager fileExistsAtPath:self.database.firstMaterialPath]);\n    TestCaseAssertFalse([self.fileManager fileExistsAtPath:self.database.incrementalMaterialPath]);\n\n    [NSThread sleepForTimeInterval:WCDB::OperationQueueTimeIntervalForBackup + self.delayForTolerance];\n    TestCaseAssertTrue([self.fileManager fileExistsAtPath:self.database.firstMaterialPath]);\n    TestCaseAssertTrue([self.fileManager fileExistsAtPath:self.database.incrementalMaterialPath]);\n\n    TestCaseAssertTrue([self.database retrieve:nil] == 1);\n\n    WCTValue* autoVaccum = [self.database getValueFromStatement:WCDB::StatementPragma().pragma(WCDB::Pragma::autoVacuum())];\n    TestCaseAssertTrue(autoVaccum.numberValue.intValue == 1);\n}\n\n#pragma mark - FTS\n- (void)test_fts3\n{\n    self.tableClass = FTS3Object.class;\n    self.isVirtualTable = YES;\n    [self.database addTokenizer:WCTTokenizerOneOrBinary];\n    [WCTDatabase configTraditionalChineseDict:@{\n        @\"們\" : @\"们\",\n        @\"員\" : @\"员\",\n    }];\n    NSMutableArray<FTS3Object*>* objects = [[NSMutableArray alloc] init];\n    for (int i = 0; i < self.objectCount; i++) {\n        FTS3Object* object = [[FTS3Object alloc] init];\n        object.content = Random.shared.chineseString;\n        object.extension = Random.shared.englishString;\n        [objects addObject:object];\n    }\n    self.objects = objects;\n    TestCaseAssertTrue([self createTable]);\n    TestCaseAssertTrue([self.table insertObjects:objects]);\n    [self doTestVacuum];\n    [self doTestObjectsExist];\n    self.tableClass = nil;\n    self.isVirtualTable = NO;\n}\n\n- (void)test_fts5\n{\n    self.tableClass = FTS5Object.class;\n    self.isVirtualTable = YES;\n    [self.database addTokenizer:WCTTokenizerVerbatim];\n    [WCTDatabase configTraditionalChineseDict:@{\n        @\"們\" : @\"们\",\n        @\"員\" : @\"员\",\n    }];\n    NSMutableArray<FTS5Object*>* objects = [[NSMutableArray alloc] init];\n    for (int i = 0; i < self.objectCount; i++) {\n        FTS5Object* object = [[FTS5Object alloc] init];\n        object.content = Random.shared.chineseString;\n        object.extension = Random.shared.englishString;\n        [objects addObject:object];\n    }\n    self.objects = objects;\n    TestCaseAssertTrue([self createTable]);\n    TestCaseAssertTrue([self.table insertObjects:objects]);\n    [self doTestVacuum];\n    [self doTestObjectsExist];\n    self.tableClass = nil;\n    self.isVirtualTable = NO;\n}\n\n#ifndef WCDB_QUICK_TESTS\n- (void)test_vacuum_huge_database\n{\n    self.skipDebugLog = YES;\n    SizeBasedFactory* factory = [[SizeBasedFactory alloc] initWithDirectory:self.class.cacheRoot];\n    factory.quality = 6LL * 1024 * 1024 * 1024; // 6GB > 4GB\n    factory.tolerance = 0.02;\n\n    [factory produce:self.path];\n\n    __block double percentage = 0;\n    TestCaseAssertTrue([self.database vacuum:^(double progress, double increment) {\n        WCDB_UNUSED(increment);\n        double newPercentage = progress * 100.0;\n        if (newPercentage - percentage >= 1.0) {\n            TestCaseLog(@\"Retrieving %.2f%%\", newPercentage);\n            percentage = newPercentage;\n        }\n        return true;\n    }]);\n}\n#endif\n\n@end\n"
  },
  {
    "path": "src/objc/tests/repair/common/BackupTestCase.h",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"RepairTestObject.h\"\n#import \"TestCase.h\"\n\n@interface BackupTestCase : TableTestCase\n\n@property (nonatomic, assign) BOOL needCipher;\n@property (nonatomic, strong) Class<RepairTestObject> testClass;\n@property (nonatomic, assign) int objectCount;\n@property (nonatomic, readonly) NSMutableArray<NSObject<RepairTestObject>*>* objects;\n@property (nonatomic, assign) bool incrementalBackup;\n@property (nonatomic, assign) bool corruptHeader;\n\n- (void)setObjects:(NSMutableArray*)objects;\n\n- (void)executeTest:(void (^)())operation;\n\n- (void)executeFullTest:(void (^)())operation withCheck:(void (^)())check;\n\n- (void)checkObjects:(NSArray*)object containedIn:(NSArray*)allObject;\n\n@end\n"
  },
  {
    "path": "src/objc/tests/repair/common/BackupTestCase.mm",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"BackupTestCase.h\"\n#import \"AutoIncrementRepairTestObject.h\"\n#import \"CoreConst.h\"\n#import \"NormalRepairTestObject.h\"\n#import \"Random+RepairTestObject.h\"\n#import \"WithoutRowidRepairTestObject.h\"\n\n@implementation BackupTestCase {\n    NSMutableArray<NSObject<RepairTestObject>*>* m_objects;\n}\n\n+ (NSArray<Class<RepairTestObject>>*)allTestClassess\n{\n    static NSArray<Class<RepairTestObject>>* g_testClasses = @[\n        NormalRepairTestObject.class,\n        AutoIncrementRepairTestObject.class,\n        WithoutRowidRepairTestObject.class,\n    ];\n    return g_testClasses;\n}\n\n- (void)setUp\n{\n    [super setUp];\n    self.objectCount = 100;\n}\n\n- (NSMutableArray<NSObject<RepairTestObject>*>*)objects\n{\n    return m_objects;\n}\n\n- (void)setObjects:(NSMutableArray*)objects\n{\n    m_objects = (NSMutableArray<NSObject<RepairTestObject>*>*) objects;\n}\n\n- (void)executeTest:(void (^)())operation\n{\n    for (int i = 0; i < 12; i++) {\n        int config = i;\n        if (config % 2 == 0) {\n            self.tableName = @\"testTable\";\n        } else {\n            self.tableName = @\"'test@Table'\";\n        }\n        config /= 2;\n        _needCipher = (BOOL) (config % 2);\n        config /= 2;\n        _testClass = [BackupTestCase allTestClassess][config];\n        [self clearData];\n        NSData* cipher = nil;\n        if (_needCipher) {\n            cipher = [Random.shared data];\n        }\n        TestCaseLog(@\"Test repair %d: tableName %@, testClass %@, needCipher %d, incrementalBackup %d, corruptHeader %d\",\n                    i,\n                    self.tableName,\n                    self.testClass,\n                    self.needCipher,\n                    self.incrementalBackup,\n                    self.corruptHeader);\n        [self.database setCipherKey:cipher];\n        TestCaseAssertTrue([self.database createTable:self.tableName withClass:self.testClass]);\n        self.table = [self.database getTable:self.tableName withClass:self.testClass];\n\n        NSArray* objects = [[Random shared] repairObjectsWithClass:_testClass andCount:self.objectCount startingFromIdentifier:1];\n        [m_objects addObjectsFromArray:objects];\n        XCTAssertTrue([self.table insertObjects:objects]);\n\n        operation();\n    }\n}\n\n- (void)executeFullTest:(void (^)())operation withCheck:(void (^)())check\n{\n    [self.database enableAutoCheckpoint:NO];\n    for (int i = 0; i < 48; i++) {\n        int config = i;\n        if (config % 2 == 0) {\n            self.tableName = @\"testTable\";\n        } else {\n            self.tableName = @\"'test@Table'\";\n        }\n        config /= 2;\n        _needCipher = (BOOL) (config % 2);\n        config /= 2;\n        _incrementalBackup = config % 2;\n        config /= 2;\n        _corruptHeader = config % 2;\n        config /= 2;\n        _testClass = [BackupTestCase allTestClassess][config];\n\n        TestCaseLog(@\"Test repair %d: tableName %@, testClass %@, needCipher %d, incrementalBackup %d, corruptHeader %d\",\n                    i,\n                    self.tableName,\n                    self.testClass,\n                    self.needCipher,\n                    self.incrementalBackup,\n                    self.corruptHeader);\n\n        [self configRepairDatabase];\n        operation();\n\n        if (_incrementalBackup) {\n            XCTAssertTrue([self.database passiveCheckpoint]);\n            usleep(10000);\n            XCTAssertTrue([self.database backup]);\n            XCTAssertTrue([self.fileManager fileExistsAtPath:self.database.incrementalMaterialPath]);\n            XCTAssertTrue([self.fileManager fileExistsAtPath:self.database.firstMaterialPath]);\n            XCTAssertTrue([self.fileManager fileExistsAtPath:self.database.lastMaterialPath]);\n\n            NSArray* objects = [[Random shared] repairObjectsWithClass:_testClass andCount:self.objectCount startingFromIdentifier:1000];\n            if ([self.table insertObjects:objects]) {\n                [m_objects addObjectsFromArray:objects];\n            }\n\n            XCTAssertTrue([self.database passiveCheckpoint]);\n            usleep(10000);\n            XCTAssertTrue([self.database backup]);\n            XCTAssertTrue([self.fileManager fileExistsAtPath:self.database.incrementalMaterialPath]);\n            XCTAssertTrue([self.fileManager fileExistsAtPath:self.database.firstMaterialPath]);\n            XCTAssertTrue([self.fileManager fileExistsAtPath:self.database.lastMaterialPath]);\n        }\n\n        if (_corruptHeader) {\n            [self.database corruptPage:1];\n        }\n\n        XCTAssertTrue([self.database retrieve:nil] > 0);\n\n        if (check != nil) {\n            check();\n        }\n    }\n    [self.database enableAutoCheckpoint:YES];\n}\n\n- (void)checkObjects:(NSArray*)objects containedIn:(NSArray*)allObjects\n{\n    for (NSObject* object in objects) {\n        BOOL found = NO;\n        for (NSObject* currentObject in allObjects) {\n            if ([currentObject isEqual:object]) {\n                found = YES;\n                break;\n            }\n        }\n        if (!found) {\n            XCTAssertTrue(found);\n        }\n    }\n}\n\n- (void)configRepairDatabase\n{\n    [self clearData];\n    NSData* cipher = nil;\n    if (_needCipher) {\n        cipher = [Random.shared data];\n    }\n    [self.database setCipherKey:cipher];\n    TestCaseAssertTrue([self.database createTable:self.tableName withClass:self.testClass]);\n    self.table = [self.database getTable:self.tableName withClass:self.testClass];\n\n    NSArray* objects = [[Random shared] repairObjectsWithClass:_testClass andCount:self.objectCount startingFromIdentifier:1];\n    [m_objects addObjectsFromArray:objects];\n    XCTAssertTrue([self.table insertObjects:objects]);\n    XCTAssertTrue([self.database passiveCheckpoint]);\n    usleep(10000);\n    XCTAssertFalse([self.fileManager fileExistsAtPath:self.database.incrementalMaterialPath]);\n    XCTAssertFalse([self.fileManager fileExistsAtPath:self.database.firstMaterialPath]);\n    XCTAssertFalse([self.fileManager fileExistsAtPath:self.database.lastMaterialPath]);\n\n    [self.database enableAutoBackup:true];\n    XCTAssertTrue([self.database backup]);\n\n    XCTAssertTrue([self.fileManager fileExistsAtPath:self.database.incrementalMaterialPath]);\n    XCTAssertTrue([self.fileManager fileExistsAtPath:self.database.firstMaterialPath]);\n    XCTAssertFalse([self.fileManager fileExistsAtPath:self.database.lastMaterialPath]);\n}\n\n- (void)clearData\n{\n    TestCaseAssertTrue([self.database removeFiles]);\n    m_objects = [[NSMutableArray alloc] init];\n    self.table = nil;\n}\n\n@end\n"
  },
  {
    "path": "src/objc/tests/repair/common/Random+RepairTestObject.h",
    "content": "//\n// Created by 陈秋文 on 2023/9/15.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"Random.h\"\n#import \"RepairTestObject.h\"\n\n@interface Random (RepairTestObject)\n\n- (NSObject<RepairTestObject> *)repairObjectWithClass:(Class<RepairTestObject>)objectClass\n                                        andIdentifier:(int)identifier;\n\n- (NSArray<NSObject<RepairTestObject> *> *)repairObjectsWithClass:(Class<RepairTestObject>)objectClass\n                                                         andCount:(int)count\n                                           startingFromIdentifier:(int)identifier;\n\n@end\n"
  },
  {
    "path": "src/objc/tests/repair/common/Random+RepairTestObject.mm",
    "content": "//\n// Created by 陈秋文 on 2023/9/15.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"Random+RepairTestObject.h\"\n#import <Foundation/Foundation.h>\n\n@implementation Random (RepairTestObject)\n\n- (NSObject<RepairTestObject>*)repairObjectWithClass:(Class<RepairTestObject>)objectClass\n                                       andIdentifier:(int)identifier\n{\n    NSObject<RepairTestObject>* object = [[(Class) objectClass alloc] init];\n    Random* random = Random.shared;\n    object.identifier = identifier;\n    object.doubleValue = random.double_;\n    object.textValue = random.string;\n    object.blobValue = random.data;\n    return object;\n}\n\n- (NSArray<NSObject<RepairTestObject>*>*)repairObjectsWithClass:(Class<RepairTestObject>)objectClass\n                                                       andCount:(int)count\n                                         startingFromIdentifier:(int)identifier\n{\n    NSMutableArray<NSObject<RepairTestObject>*>* objects = [NSMutableArray arrayWithCapacity:count];\n    for (int i = identifier; i < identifier + count; ++i) {\n        [objects addObject:[self repairObjectWithClass:objectClass\n                                         andIdentifier:i]];\n    }\n    return objects;\n}\n\n@end\n"
  },
  {
    "path": "src/objc/tests/repair/common/RepairTestObject.h",
    "content": "//\n// Created by qiuwenchen on 2023/9/15.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#if TEST_WCDB_OBJC\n#import <WCDBOBjc/WCDBObjc.h>\n#elif TEST_WCDB_CPP\n#import <WCDBCpp/WCDBCpp.h>\n#else\n#import <WCDB/WCDBObjc.h>\n#endif\n\n#import \"RepairTestObjectBase.h\"\n\n@protocol RepairTestObject <WCTTableCoding>\n\n@property (nonatomic, assign) int identifier;\n@property (nonatomic, assign) double doubleValue;\n@property (nonatomic, strong) NSString* textValue;\n@property (nonatomic, strong) NSData* blobValue;\n\nWCDB_PROPERTY(identifier)\nWCDB_PROPERTY(doubleValue)\nWCDB_PROPERTY(textValue)\nWCDB_PROPERTY(blobValue)\n\n+ (BOOL)hasRowid;\n+ (BOOL)isAutoIncrement;\n\n@end\n"
  },
  {
    "path": "src/objc/tests/repair/common/RepairTestObjectBase.h",
    "content": "//\n// Created by qiuwenchen on 2023/9/15.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import <Foundation/Foundation.h>\n\n@interface RepairTestObjectBase : NSObject\n\n@property (nonatomic, assign) int identifier;\n@property (nonatomic, assign) double doubleValue;\n@property (nonatomic, strong) NSString* textValue;\n@property (nonatomic, strong) NSData* blobValue;\n\n@end\n"
  },
  {
    "path": "src/objc/tests/repair/common/RepairTestObjectBase.mm",
    "content": "//\n// Created by qiuwenchen on 2023/9/15.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"RepairTestObjectBase.h\"\n#import \"NSObject+TestCase.h\"\n#import <Foundation/Foundation.h>\n\n@implementation RepairTestObjectBase\n\n- (BOOL)isEqual:(NSObject*)object\n{\n    if (object.class != self.class) {\n        return NO;\n    }\n    RepairTestObjectBase* other = (RepairTestObjectBase*) object;\n    if (self.identifier != other.identifier) {\n        return NO;\n    }\n    if (self.doubleValue != other.doubleValue) {\n        return NO;\n    }\n    if (![NSObject isObject:self.textValue nilEqualToObject:other.textValue]) {\n        return NO;\n    }\n    if (![NSObject isObject:self.blobValue nilEqualToObject:other.blobValue]) {\n        return NO;\n    }\n    return YES;\n}\n\n- (NSUInteger)hash\n{\n    NSMutableData* data = [NSMutableData data];\n    [data appendBytes:&(_identifier) length:sizeof(_identifier)];\n    [data appendBytes:&(_doubleValue) length:sizeof(_doubleValue)];\n    [data appendData:[_textValue dataUsingEncoding:NSUTF8StringEncoding]];\n    [data appendData:_blobValue];\n    return data.hash;\n}\n\n@end\n"
  },
  {
    "path": "src/objc/tests/repair/model/AutoIncrementRepairTestObject.h",
    "content": "//\n// Created by qiuwenchen on 2023/9/15.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"RepairTestObject.h\"\n\n@interface AutoIncrementRepairTestObject : RepairTestObjectBase <RepairTestObject>\n\n@end\n"
  },
  {
    "path": "src/objc/tests/repair/model/AutoIncrementRepairTestObject.mm",
    "content": "//\n// Created by qiuwenchen on 2023/9/15.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"AutoIncrementRepairTestObject.h\"\n#import <Foundation/Foundation.h>\n\n@implementation AutoIncrementRepairTestObject\n\nWCDB_IMPLEMENTATION(AutoIncrementRepairTestObject)\nWCDB_SYNTHESIZE(identifier)\nWCDB_SYNTHESIZE(doubleValue)\nWCDB_SYNTHESIZE(textValue)\nWCDB_SYNTHESIZE(blobValue)\n\nWCDB_PRIMARY_AUTO_INCREMENT(identifier)\nWCDB_INDEX(\"_doubleValue\", doubleValue)\n\n@synthesize lastInsertedRowID;\n\n+ (BOOL)hasRowid\n{\n    return YES;\n}\n\n+ (BOOL)isAutoIncrement\n{\n    return true;\n}\n\n@end\n"
  },
  {
    "path": "src/objc/tests/repair/model/NormalRepairTestObject.h",
    "content": "//\n// Created by qiuwenchen on 2023/9/15.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"RepairTestObject.h\"\n\n@interface NormalRepairTestObject : RepairTestObjectBase <RepairTestObject>\n\n@end\n"
  },
  {
    "path": "src/objc/tests/repair/model/NormalRepairTestObject.mm",
    "content": "//\n// Created by qiuwenchen on 2023/9/15.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"NormalRepairTestObject.h\"\n#import <Foundation/Foundation.h>\n\n@implementation NormalRepairTestObject\n\nWCDB_IMPLEMENTATION(NormalRepairTestObject)\nWCDB_SYNTHESIZE(identifier)\nWCDB_SYNTHESIZE(doubleValue)\nWCDB_SYNTHESIZE(textValue)\nWCDB_SYNTHESIZE(blobValue)\n\nWCDB_PRIMARY(identifier)\nWCDB_INDEX(\"_doubleValue\", doubleValue)\n\n+ (BOOL)hasRowid\n{\n    return YES;\n}\n\n+ (BOOL)isAutoIncrement\n{\n    return false;\n}\n\n@end\n"
  },
  {
    "path": "src/objc/tests/repair/model/WithoutRowidRepairTestObject.h",
    "content": "//\n// Created by qiuwenchen on 2023/9/15.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"RepairTestObject.h\"\n\n@interface WithoutRowidRepairTestObject : RepairTestObjectBase <RepairTestObject>\n\n@end\n"
  },
  {
    "path": "src/objc/tests/repair/model/WithoutRowidRepairTestObject.mm",
    "content": "//\n// Created by qiuwenchen on 2023/9/15.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"WithoutRowidRepairTestObject.h\"\n#import <Foundation/Foundation.h>\n\n@implementation WithoutRowidRepairTestObject\n\nWCDB_IMPLEMENTATION(WithoutRowidRepairTestObject)\nWCDB_SYNTHESIZE(identifier)\nWCDB_SYNTHESIZE(doubleValue)\nWCDB_SYNTHESIZE(textValue)\nWCDB_SYNTHESIZE(blobValue)\n\nWCDB_PRIMARY(identifier)\nWCDB_INDEX(\"_doubleValue\", doubleValue)\nWCDB_WITHOUT_ROWID\n\n+ (BOOL)hasRowid\n{\n    return false;\n}\n\n+ (BOOL)isAutoIncrement\n{\n    return false;\n}\n\n@end\n"
  },
  {
    "path": "src/objc/tests/thread/ThreadTests.mm",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"CoreConst.h\"\n#import \"TestCase.h\"\n#include \"ThreadLocal.hpp\"\n#include <mach/mach.h>\n#include <pthread.h>\n\n// ============================================================\n// Reproduce the original crash scenario in-process.\n//\n// On a worker thread, we exploit thread_local destruction order:\n//   - A \"hook\" thread_local is initialized FIRST → destroyed LAST\n//   - threadedStorage()'s thread_local is initialized SECOND → destroyed FIRST\n// When the thread exits, the hook's destructor accesses ThreadLocal\n// after the underlying storage is already destroyed — exactly the\n// original crash path (SharedLockGuard → lockShared → getOrCreate).\n//\n// With the old unique_ptr code, this crashes (SIGSEGV).\n// With the fix (ThreadedStorage + nullptr guard), this succeeds.\n// ============================================================\n\nnamespace ThreadLocalDestructionTest {\n\nstatic std::atomic<bool> s_hookSucceeded{false};\nstatic WCDB::ThreadLocal<int> s_tl;\n\nstruct DestructionHook {\n    bool active = false;\n    ~DestructionHook()\n    {\n        if (active) {\n            s_tl.getOrCreate() = 42;\n            s_hookSucceeded.store(true);\n        }\n    }\n};\n\nstatic void* threadEntry(void*)\n{\n    // Hook initialized FIRST → its destructor registered first → destroyed LAST\n    thread_local DestructionHook hook;\n    hook.active = true;\n\n    // threadedStorage() initialized SECOND → registered second → destroyed FIRST\n    s_tl.getOrCreate() = 10;\n\n    return nullptr;\n}\n\n} // namespace ThreadLocalDestructionTest\n\n// ============================================================\n// Memory leak stress test helpers\n// ============================================================\nnamespace ThreadLocalStressTest {\n\nstatic WCDB::ThreadLocal<int> s_tls[50];\n\nstatic void* threadEntry(void*)\n{\n    for (int j = 0; j < 50; j++) {\n        s_tls[j].getOrCreate() = j;\n    }\n    return nullptr;\n}\n\n} // namespace ThreadLocalStressTest\n\nstatic size_t getPhysicalFootprint()\n{\n    task_vm_info_data_t vmInfo;\n    mach_msg_type_number_t count = TASK_VM_INFO_COUNT;\n    kern_return_t kr = task_info(mach_task_self(), TASK_VM_INFO,\n                                (task_info_t) &vmInfo, &count);\n    return kr == KERN_SUCCESS ? vmInfo.phys_footprint : 0;\n}\n\n@interface ThreadTests : TableTestCase\n\n@end\n\n@implementation ThreadTests\n\n- (void)test_feature_read_concurrency\n{\n    // trigger table initialization\n    TestCaseAssertTrue([self createTable]);\n\n    __block NSDate* read1Begin;\n    __block NSDate* read2Begin;\n    __block NSDate* read1End;\n    __block NSDate* read2End;\n    [self.dispatch async:^{\n        // Acquire read transaction. Note that it's not recommended in production environment.\n        TestCaseAssertTrue([self.database execute:WCDB::StatementBegin().beginDeferred()]);\n        TestCaseAssertTrue([self.database execute:WCDB::StatementSelect().select(1)]);\n        read1Begin = [NSDate date];\n        [NSThread sleepForTimeInterval:self.delayForTolerance];\n        read1End = [NSDate date];\n        TestCaseAssertTrue([self.database execute:WCDB::StatementRollback().rollback()]);\n    }];\n    [self.dispatch async:^{\n        // Acquire read transaction. Note that it's not recommended in production environment.\n        TestCaseAssertTrue([self.database execute:WCDB::StatementBegin().beginDeferred()]);\n        TestCaseAssertTrue([self.database execute:WCDB::StatementSelect().select(1)]);\n        read2Begin = [NSDate date];\n        [NSThread sleepForTimeInterval:self.delayForTolerance];\n        read2End = [NSDate date];\n        TestCaseAssertTrue([self.database execute:WCDB::StatementRollback().rollback()]);\n    }];\n    [self.dispatch waitUntilDone];\n\n    // Contains intersection\n    TestCaseAssertTrue([read1End compare:read2Begin] == NSOrderedDescending\n                       && [read2End compare:read1Begin] == NSOrderedDescending);\n}\n\n- (void)test_feature_read_and_write_concurrency\n{\n    // trigger table initialization\n    TestCaseAssertTrue([self createTable]);\n\n    __block NSDate* readBegin;\n    __block NSDate* writeBegin;\n    __block NSDate* readEnd;\n    __block NSDate* writeEnd;\n    [self.dispatch async:^{\n        // Acquire read transaction. Note that it's not recommended in production environment.\n        TestCaseAssertTrue([self.database execute:WCDB::StatementBegin().beginDeferred()]);\n        TestCaseAssertTrue([self.database execute:WCDB::StatementSelect().select(1)]);\n        readBegin = [NSDate date];\n        [NSThread sleepForTimeInterval:self.delayForTolerance];\n        readEnd = [NSDate date];\n        TestCaseAssertTrue([self.database execute:WCDB::StatementRollback().rollback()]);\n    }];\n    [self.dispatch async:^{\n        // Acquire write transaction.\n        TestCaseAssertTrue([self.database execute:WCDB::StatementBegin().beginImmediate()]);\n        writeBegin = [NSDate date];\n        [NSThread sleepForTimeInterval:self.delayForTolerance];\n        writeEnd = [NSDate date];\n        TestCaseAssertTrue([self.database execute:WCDB::StatementRollback().rollback()]);\n    }];\n    [self.dispatch waitUntilDone];\n\n    // Contains intersection\n    TestCaseAssertTrue([readEnd compare:writeBegin] == NSOrderedDescending\n                       && [writeEnd compare:readBegin] == NSOrderedDescending);\n}\n\n- (void)test_feature_write_serial\n{\n    // trigger table initialization\n    TestCaseAssertTrue([self createTable]);\n\n    __block NSDate* write1Begin;\n    __block NSDate* write2Begin;\n    __block NSDate* write1End;\n    __block NSDate* write2End;\n    [self.dispatch async:^{\n        // Acquire write transaction.\n        TestCaseAssertTrue([self.database execute:WCDB::StatementBegin().beginImmediate()]);\n        write1Begin = [NSDate date];\n        [NSThread sleepForTimeInterval:self.delayForTolerance];\n        write1End = [NSDate date];\n        TestCaseAssertTrue([self.database execute:WCDB::StatementRollback().rollback()]);\n    }];\n    [self.dispatch async:^{\n        // Acquire write transaction.\n        TestCaseAssertTrue([self.database execute:WCDB::StatementBegin().beginImmediate()]);\n        write2Begin = [NSDate date];\n        [NSThread sleepForTimeInterval:self.delayForTolerance];\n        write2End = [NSDate date];\n        TestCaseAssertTrue([self.database execute:WCDB::StatementRollback().rollback()]);\n    }];\n    [self.dispatch waitUntilDone];\n\n    // No intersection\n    TestCaseAssertTrue([write1Begin compare:write2End] == NSOrderedDescending\n                       || [write2Begin compare:write1End] == NSOrderedDescending);\n}\n\n- (void)test_feature_subthread_checkpoint\n{\n    // trigger subthread checkpoint\n    TestCaseAssertTrue([self createTable]);\n\n    TestCaseAssertOptionalFalse([self.database isAlreadyCheckpointed]);\n\n    [NSThread sleepForTimeInterval:WCDB::OperationQueueTimeIntervalForCheckpoint + self.delayForTolerance];\n\n    TestCaseAssertOptionalFalse([self.database isAlreadyTruncateCheckpointed]);\n    TestCaseAssertOptionalTrue([self.database isAlreadyCheckpointed]);\n}\n\n- (void)test_feature_threaded_handle\n{\n    __block int handleCount = 0;\n    [self.database\n           setConfig:^BOOL(WCTHandle*) {\n               ++handleCount;\n               return YES;\n           }\n    withUninvocation:nil\n             forName:self.testName];\n    {\n        WCTHandle* handle1 = [self.database getHandle];\n        TestCaseAssertTrue([handle1 validate]);\n        WCTHandle* handle2 = [self.database getHandle];\n        TestCaseAssertTrue([handle2 validate]);\n        WCTHandle* handle3 = [self.database getHandle];\n        TestCaseAssertTrue([handle3 validate]);\n\n        [handle1 invalidate];\n        [handle2 invalidate];\n        [handle3 invalidate];\n    }\n    TestCaseAssertEqual(handleCount, 1);\n}\n\n- (void)test_feature_transactioned_handle\n{\n    BOOL result = [self.database runTransaction:^BOOL(WCTHandle* _Nonnull) {\n        TestCaseAssertTrue([self.database isInTransaction]);\n        WCTHandle* handle = [self.database getHandle];\n        TestCaseAssertTrue([handle isInTransaction]);\n        return YES;\n    }];\n    TestCaseAssertTrue(result);\n}\n\n- (void)test_feature_threaded_transactioned_handle\n{\n    TestCaseAssertTrue([self.database beginTransaction]);\n\n    TestCaseResult* began = [TestCaseResult no];\n    TestCaseResult* tested = [TestCaseResult no];\n    [self.dispatch async:^{\n        WCTHandle* handle = [self.database getHandle];\n        TestCaseAssertFalse([handle isInTransaction]);\n        // it will not reuse transactioned handle.\n        TestCaseAssertTrue([handle validate]);\n        [began makeYES];\n        while ([tested isNO]);\n        [handle invalidate];\n    }];\n\n    while ([began isNO]);\n\n    // it will reuse transactioned handle.\n    TestCaseAssertTrue([self.database isInTransaction]);\n    [tested makeYES];\n    [self.database rollbackTransaction];\n}\n\n- (void)test_feature_max_concurrency\n{\n    [self.database enableAutoCheckpoint:NO];\n\n    NSCondition* condition = [[NSCondition alloc] init];\n    TestCaseCounter* counter = [TestCaseCounter value:0];\n    for (int i = 0; i < WCDB::HandlePoolMaxAllowedNumberOfHandles; ++i) {\n        [self.dispatch async:^{\n            WCTHandle* handle = nil;\n            @synchronized(self) {\n                handle = [self.database getHandle];\n            }\n\n            while (counter.value < i) {\n            }\n\n            TestCaseAssertTrue([handle validate]);\n\n            [counter increment];\n            [condition lock];\n            [condition wait];\n            [condition unlock];\n            [handle invalidate];\n            [counter decrement];\n        }];\n    }\n\n    while (counter.value != WCDB::HandlePoolMaxAllowedNumberOfHandles) {\n    }\n    [condition broadcast];\n    [self.dispatch waitUntilDone];\n    TestCaseAssertEqual(counter.value, 0);\n}\n\n- (void)test_feature_checkpoint_while_notice_recover_wal\n{\n    TestCaseAssertTrue([self.database truncateCheckpoint]);\n\n    // trigger subthread checkpoint\n    TestCaseAssertTrue([self createTable]);\n\n    [self.database close];\n\n    // trigger notice recover wal\n    TestCaseAssertTrue([self.database canOpen]);\n\n    TestCaseAssertOptionalFalse(self.database.isAlreadyCheckpointed);\n\n    [NSThread sleepForTimeInterval:WCDB::OperationQueueTimeIntervalForCheckpoint + self.delayForTolerance];\n\n    TestCaseAssertOptionalTrue(self.database.isAlreadyCheckpointed);\n}\n\n- (void)test_feature_busy_retry\n{\n    TestCaseResult* began = [TestCaseResult no];\n    TestCaseResult* rollbacked = [TestCaseResult no];\n    TestCaseResult* tested = [TestCaseResult no];\n    [self.dispatch async:^{\n        TestCaseAssertTrue([self.database beginTransaction]);\n        [began makeYES];\n\n        [NSThread sleepForTimeInterval:1];\n        TestCaseAssertResultNO(tested);\n        [rollbacked makeYES];\n        [self.database rollbackTransaction];\n    }];\n\n    while ([began isNO]) {\n    }\n\n    TestCaseAssertTrue([self.database beginTransaction]);\n    TestCaseAssertResultYES(rollbacked);\n    [tested makeYES];\n    [self.database rollbackTransaction];\n    [self.dispatch waitUntilDone];\n}\n\n- (void)test_write_with_handle_count_limit\n{\n    __block int maxHandleCount = 0;\n    [WCTDatabase globalTraceDatabaseOperation:^(WCTDatabase*, WCTDatabaseOperation operation, NSDictionary* info) {\n        if (operation != WCTDatabaseOperation_OpenHandle) {\n            return;\n        }\n        maxHandleCount = MAX(maxHandleCount, ((NSNumber*) info[WCTDatabaseMonitorInfoKeyHandleCount]).intValue);\n    }];\n    TestCaseAssertTrue([self createTable]);\n    for (int i = 0; i < 40; i++) {\n        [self.dispatch async:^{\n            switch (i % 4) {\n            case 0: {\n                NSArray* objects = [[Random shared] testCaseObjectsWithCount:100 startingFromIdentifier:i * 100];\n                TestCaseAssertTrue([self.table insertObjects:objects]);\n            } break;\n            case 1: {\n                TestCaseAssertTrue([self.table updateProperty:TestCaseObject.content toValue:@\"abc\" where:TestCaseObject.identifier > (i - 1) * 100 && TestCaseObject.identifier <= i * 100]);\n            } break;\n            case 2: {\n                TestCaseAssertTrue([self.table deleteObjectsWhere:TestCaseObject.identifier > ((i - 2) * 100 + 50) && TestCaseObject.identifier <= i * 100]);\n            } break;\n            case 3: {\n                TestCaseAssertTrue([self.database runTransaction:^BOOL(WCTHandle*) {\n                    return [self.table updateProperty:TestCaseObject.content toValue:@\"abc2\" where:TestCaseObject.identifier > (i - 1) * 100 && TestCaseObject.identifier <= i * 100];\n                }]);\n            } break;\n\n            default:\n                break;\n            }\n            usleep(100000);\n        }];\n    }\n    [self.dispatch waitUntilDone];\n    TestCaseAssertTrue(maxHandleCount <= 4);\n    [WCTDatabase globalTraceDatabaseOperation:nil];\n}\n\n- (void)test_read_with_handle_count_limit\n{\n    __block int maxHandleCount = 0;\n    [WCTDatabase globalTraceDatabaseOperation:^(WCTDatabase*, WCTDatabaseOperation operation, NSDictionary* info) {\n        if (operation != WCTDatabaseOperation_OpenHandle) {\n            return;\n        }\n        maxHandleCount = MAX(maxHandleCount, ((NSNumber*) info[WCTDatabaseMonitorInfoKeyHandleCount]).intValue);\n    }];\n\n    TestCaseAssertTrue([self createTable]);\n    NSArray* objects = [Random.shared testCaseObjectsWithCount:32000 startingFromIdentifier:0];\n    TestCaseAssertTrue([self.table insertObjects:objects]);\n\n    for (int i = 0; i < 320; i++) {\n        [self.dispatch async:^{\n            switch (i % 5) {\n            case 0: {\n                NSArray* ret = [self.table getObjectsOffset:i * 100 limit:100];\n                TestCaseAssertTrue([ret count] == 100);\n            } break;\n            case 1: {\n                WCTValue* value = [self.database getValueFromStatement:WCDB::StatementSelect().select(TestCaseObject.allProperties.count()).from(self.tableName)];\n                TestCaseAssertTrue(value.numberValue.intValue == 32000);\n            } break;\n            case 2: {\n                WCTOneColumn* colums = [self.table getColumnOnResultColumn:TestCaseObject.content limit:100 offset:i * 100];\n                TestCaseAssertTrue(colums.count == 100);\n            } break;\n            case 3: {\n                WCTColumnsXRows* rows = [self.table getRowsOnResultColumns:TestCaseObject.allProperties limit:100 offset:i * 100];\n                TestCaseAssertTrue(rows.count == 100);\n            } break;\n            case 4: {\n                WCTOneRow* row = [self.table getRowOnResultColumns:TestCaseObject.allProperties orders:TestCaseObject.identifier.asOrder(WCTOrderedDescending)];\n                TestCaseAssertTrue(row.count == 2);\n            } break;\n\n            default:\n                break;\n            }\n\n            usleep(100000);\n        }];\n    }\n    [self.dispatch waitUntilDone];\n    TestCaseAssertTrue(maxHandleCount > 4 && maxHandleCount <= 32);\n    [WCTDatabase globalTraceDatabaseOperation:nil];\n}\n\n- (void)test_read_write_with_handle_count_limit\n{\n    __block int maxHandleCount = 0;\n    [WCTDatabase globalTraceDatabaseOperation:^(WCTDatabase*, WCTDatabaseOperation operation, NSDictionary* info) {\n        if (operation != WCTDatabaseOperation_OpenHandle) {\n            return;\n        }\n        maxHandleCount = MAX(maxHandleCount, ((NSNumber*) info[WCTDatabaseMonitorInfoKeyHandleCount]).intValue);\n    }];\n\n    TestCaseAssertTrue([self createTable]);\n    NSArray* objects = [Random.shared testCaseObjectsWithCount:32000 startingFromIdentifier:0];\n    TestCaseAssertTrue([self.table insertObjects:objects]);\n\n    for (int i = 0; i < 320; i++) {\n        if (i % 8 == 0) {\n            [self.dispatch async:^{\n                NSArray* newObjects = [[Random shared] testCaseObjectsWithCount:100 startingFromIdentifier:i * 100 + 32000];\n                TestCaseAssertTrue([self.table insertObjects:newObjects]);\n                usleep(100000);\n            }];\n        } else {\n            [self.dispatch async:^{\n                NSArray* ret = [self.table getObjectsOffset:i * 10 limit:1000];\n                TestCaseAssertTrue([ret count] == 1000);\n                usleep(100000);\n            }];\n        }\n    }\n\n    [self.dispatch waitUntilDone];\n    TestCaseAssertTrue(maxHandleCount > 4 && maxHandleCount <= 32);\n    [WCTDatabase globalTraceDatabaseOperation:nil];\n}\n\n// Reproduce the original crash: a thread_local destructor accesses ThreadLocal\n// after threadedStorage is already destroyed — the same code path as the crash:\n//   Database::~Database → flowBack → SharedLockGuard → lockShared → getOrCreate\n//\n// With the old code (unique_ptr), this crashes with SIGSEGV.\n// With the fix (ThreadedStorage + nullptr guard), the hook succeeds.\n- (void)test_threadLocal_access_after_storage_destruction\n{\n    ThreadLocalDestructionTest::s_hookSucceeded = false;\n\n    pthread_t thread;\n    pthread_create(&thread, nullptr, ThreadLocalDestructionTest::threadEntry, nullptr);\n    pthread_join(thread, nullptr);\n\n    TestCaseAssertTrue(ThreadLocalDestructionTest::s_hookSucceeded.load());\n}\n\n// Stress test: create & destroy many threads, each touching 50 ThreadLocal<int>.\n// Verifies thread_local storage is properly cleaned up on thread exit (no leak).\n//\n// Per-thread map with 50 entries ≈ 3.5 KB.\n// 2000 threads × 3.5 KB ≈ 7 MB if leaked; ~0 if properly cleaned up.\n- (void)test_threadLocal_no_memory_leak_under_stress\n{\n    // Warm up: let the runtime/allocator settle\n    for (int i = 0; i < 200; i++) {\n        pthread_t t;\n        pthread_create(&t, nullptr, ThreadLocalStressTest::threadEntry, nullptr);\n        pthread_join(t, nullptr);\n    }\n\n    size_t memBefore = getPhysicalFootprint();\n\n    for (int i = 0; i < 2000; i++) {\n        pthread_t t;\n        pthread_create(&t, nullptr, ThreadLocalStressTest::threadEntry, nullptr);\n        pthread_join(t, nullptr);\n    }\n\n    size_t memAfter = getPhysicalFootprint();\n    size_t growth = memAfter > memBefore ? memAfter - memBefore : 0;\n    TestCaseAssertTrue(growth < 2 * 1024 * 1024);\n}\n\n- (void)test_multithread_with_error\n{\n    for (int i = 0; i < 10000; i++) {\n        [self.dispatch async:^{\n            [self.database execute:WCDB::StatementSelect().select(WCDB::Column::all()).from(@\"abc\")];\n            [self.database runTransaction:^BOOL(WCTHandle* handle) {\n                return [handle execute:WCDB::StatementSelect().select(WCDB::Column::all()).from(@\"abc\")];\n            }];\n        }];\n    }\n    [self.dispatch waitUntilDone];\n}\n\n@end\n"
  },
  {
    "path": "src/objc/tests/thread/TransactionTests.mm",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"TestCase.h\"\n\n@interface TransactionTests : CRUDTestCase\n\n@end\n\n@implementation TransactionTests\n\n- (void)setUp\n{\n    [super setUp];\n    [self insertPresetObjects];\n}\n\n#pragma mark - Database - Transaction\n- (void)test_database_commit\n{\n    [self doTestObjects:@[ self.object2 ]\n                andSQLs:@[ @\"BEGIN IMMEDIATE\", @\"DELETE FROM testTable WHERE identifier == 1\", @\"COMMIT\" ]\n      afterModification:^BOOL {\n          return [self.database runTransaction:^BOOL(WCTHandle* handle) {\n              return [handle deleteFromTable:self.tableName where:TestCaseObject.identifier == 1];\n          }];\n      }];\n}\n\n- (void)test_database_rollback\n{\n    [self doTestObjects:self.objects\n                andSQLs:@[ @\"BEGIN IMMEDIATE\", @\"DELETE FROM testTable WHERE identifier == 1\", @\"ROLLBACK\" ]\n      afterModification:^BOOL {\n          __block BOOL tested = NO;\n          __block BOOL unexpected = NO;\n          if ([self.database runTransaction:^BOOL(WCTHandle* handle) {\n                  tested = YES;\n                  if (![handle deleteFromTable:self.tableName where:TestCaseObject.identifier == 1]) {\n                      TestCaseFailure();\n                      unexpected = YES;\n                  }\n                  return NO; // rollback\n              }]) {\n              TestCaseFailure();\n              unexpected = YES;\n          }\n          return !unexpected && tested;\n      }];\n}\n\n- (void)test_database_auto_rollback\n{\n    [self doTestObjects:self.objects\n                andSQLs:@[ @\"BEGIN IMMEDIATE\", @\"DELETE FROM testTable WHERE identifier == 1\", @\"COMMIT\" ]\n      afterModification:^BOOL {\n          __block BOOL unexpected = NO;\n          __block BOOL tested = NO;\n          [WCTDatabase simulateIOError:WCTSimulateWriteIOError];\n          if ([self.database runTransaction:^BOOL(WCTHandle* handle) {\n                  tested = YES;\n                  if (![handle deleteFromTable:self.tableName where:TestCaseObject.identifier == 1]) {\n                      TestCaseFailure();\n                      unexpected = YES;\n                  }\n                  return YES; // commit failed\n              }]) {\n              TestCaseFailure();\n              unexpected = YES;\n          } else {\n              TestCaseAssertFalse([self.database isInTransaction]);\n          }\n          [WCTDatabase simulateIOError:WCTSimulateNoneIOError];\n          return !unexpected && tested;\n      }];\n}\n\n#pragma mark - Database - Seperated Transaction\n- (void)test_database_seperated_commit\n{\n    [self doTestObjects:@[ self.object2 ]\n                andSQLs:@[ @\"BEGIN IMMEDIATE\", @\"DELETE FROM testTable WHERE identifier == 1\", @\"COMMIT\" ]\n      afterModification:^BOOL {\n          return [self.database beginTransaction]\n                 && [self.database deleteFromTable:self.tableName where:TestCaseObject.identifier == 1]\n                 && [self.database commitOrRollbackTransaction];\n      }];\n}\n\n- (void)test_database_seperated_auto_rollback\n{\n    [self doTestObjects:self.objects\n                andSQLs:@[ @\"BEGIN IMMEDIATE\", @\"DELETE FROM testTable WHERE identifier == 1\", @\"COMMIT\" ]\n      afterModification:^BOOL {\n          BOOL unexpected = NO;\n          [WCTDatabase simulateIOError:WCTSimulateWriteIOError];\n          if ([self.database beginTransaction]) {\n              if (![self.database deleteFromTable:self.tableName where:TestCaseObject.identifier == 1]) {\n                  TestCaseFailure();\n                  unexpected = YES;\n              }\n              if ([self.database commitOrRollbackTransaction]) { // commit failed\n                  TestCaseFailure();\n                  unexpected = YES;\n              } else {\n                  TestCaseAssertFalse([self.database isInTransaction]);\n              }\n          } else {\n              TestCaseFailure();\n              unexpected = YES;\n          }\n          [WCTDatabase simulateIOError:WCTSimulateNoneIOError];\n          return !unexpected;\n      }];\n}\n\n- (void)test_database_seperated_rollback\n{\n    [self doTestObjects:self.objects\n                andSQLs:@[ @\"BEGIN IMMEDIATE\", @\"DELETE FROM testTable WHERE identifier == 1\", @\"ROLLBACK\" ]\n      afterModification:^BOOL {\n          if (![self.database beginTransaction]\n              || ![self.database deleteFromTable:self.tableName where:TestCaseObject.identifier == 1]) {\n              TestCaseFailure();\n              return NO;\n          }\n          [self.database rollbackTransaction];\n          return YES;\n      }];\n}\n\n#pragma mark - Database - Nested Transaction\n- (void)test_database_commit_nested\n{\n    [self doTestObjects:@[ self.object2 ]\n                andSQLs:@[ @\"BEGIN IMMEDIATE\", @\"DELETE FROM testTable WHERE identifier == 1\", @\"COMMIT\" ]\n      afterModification:^BOOL {\n          return [self.database runTransaction:^BOOL(WCTHandle* handle) {\n              return [handle deleteFromTable:self.tableName where:TestCaseObject.identifier == 1];\n          }];\n      }];\n}\n\n- (void)test_database_rollback_nested\n{\n    [self doTestObjects:self.objects\n                andSQLs:@[ @\"BEGIN IMMEDIATE\", @\"DELETE FROM testTable WHERE identifier == 1\", @\"ROLLBACK\" ]\n      afterModification:^BOOL {\n          __block BOOL unexpected = NO;\n          if ([self.database runTransaction:^BOOL(WCTHandle* handle) {\n                  if (![handle deleteFromTable:self.tableName where:TestCaseObject.identifier == 1]) {\n                      TestCaseFailure();\n                      unexpected = YES;\n                  }\n                  return NO; // rollback\n              }]) {\n              TestCaseFailure();\n              unexpected = YES;\n          }\n          return !unexpected;\n      }];\n}\n\n- (void)test_database_auto_rollback_nested\n{\n    [self doTestObjects:self.objects\n                andSQLs:@[ @\"BEGIN IMMEDIATE\", @\"DELETE FROM testTable WHERE identifier == 1\", @\"COMMIT\" ]\n      afterModification:^BOOL {\n          __block BOOL unexpected = NO;\n          [WCTDatabase simulateIOError:WCTSimulateWriteIOError];\n          if ([self.database runTransaction:^BOOL(WCTHandle* handle) {\n                  if (![handle deleteFromTable:self.tableName where:TestCaseObject.identifier == 1]) {\n                      TestCaseFailure();\n                      unexpected = YES;\n                  }\n                  return YES; // commit failed\n              }]) {\n              TestCaseFailure();\n              unexpected = YES;\n          } else {\n              TestCaseAssertFalse([self.database isInTransaction]);\n          }\n          [WCTDatabase simulateIOError:WCTSimulateNoneIOError];\n          return !unexpected;\n      }];\n}\n\n#pragma mark - Database - Is In Transaction\n- (void)test_database_is_in_transaction\n{\n    {\n        TestCaseAssertFalse([self.database isInTransaction]);\n        TestCaseAssertTrue([self.database beginTransaction]);\n        TestCaseAssertTrue([self.database isInTransaction]);\n        TestCaseAssertTrue([self.database commitOrRollbackTransaction]);\n        TestCaseAssertFalse([self.database isInTransaction]);\n    }\n    {\n        TestCaseAssertFalse([self.database isInTransaction]);\n        TestCaseAssertTrue([self.database beginTransaction]);\n        TestCaseAssertTrue([self.database isInTransaction]);\n        [self.database rollbackTransaction];\n        TestCaseAssertFalse([self.database isInTransaction]);\n    }\n}\n\n#pragma mark - Handle - Transaction\n- (void)test_handle_commit\n{\n    [self doTestObjects:@[ self.object2 ]\n                andSQLs:@[ @\"BEGIN IMMEDIATE\", @\"DELETE FROM testTable WHERE identifier == 1\", @\"COMMIT\" ]\n      afterModification:^BOOL {\n          return [[self.database getHandle] runTransaction:^BOOL(WCTHandle* handle) {\n              return [handle deleteFromTable:self.tableName where:TestCaseObject.identifier == 1];\n          }];\n      }];\n}\n\n- (void)test_handle_rollback\n{\n    [self doTestObjects:self.objects\n                andSQLs:@[ @\"BEGIN IMMEDIATE\", @\"DELETE FROM testTable WHERE identifier == 1\", @\"ROLLBACK\" ]\n      afterModification:^BOOL {\n          __block BOOL unexpected = NO;\n          __block BOOL tested = NO;\n          if ([[self.database getHandle] runTransaction:^BOOL(WCTHandle* handle) {\n                  tested = YES;\n                  if (![handle deleteFromTable:self.tableName where:TestCaseObject.identifier == 1]) {\n                      TestCaseFailure();\n                      unexpected = YES;\n                  }\n                  return NO; // rollback\n              }]) {\n              TestCaseFailure();\n              unexpected = YES;\n          }\n          return !unexpected && tested;\n      }];\n}\n\n- (void)test_handle_auto_rollback\n{\n    [self doTestObjects:self.objects\n                andSQLs:@[ @\"BEGIN IMMEDIATE\", @\"DELETE FROM testTable WHERE identifier == 1\", @\"COMMIT\" ]\n      afterModification:^BOOL {\n          __block BOOL unexpected = NO;\n          __block BOOL tested = NO;\n          [WCTDatabase simulateIOError:WCTSimulateWriteIOError];\n          WCTHandle* handle = [self.database getHandle];\n          if ([handle runTransaction:^BOOL(WCTHandle* transactionedHandle) {\n                  tested = YES;\n                  if (![transactionedHandle deleteFromTable:self.tableName where:TestCaseObject.identifier == 1]) {\n                      TestCaseFailure();\n                      unexpected = YES;\n                  }\n                  return YES; // commit failed\n              }]) {\n              TestCaseFailure();\n              unexpected = YES;\n          } else {\n              TestCaseAssertFalse([handle isInTransaction]);\n          }\n          [WCTDatabase simulateIOError:WCTSimulateNoneIOError];\n          return !unexpected && tested;\n      }];\n}\n\n#pragma mark - Handle - Seperated Transaction\n- (void)test_handle_seperated_commit\n{\n    [self doTestObjects:@[ self.object2 ]\n                andSQLs:@[ @\"BEGIN IMMEDIATE\", @\"DELETE FROM testTable WHERE identifier == 1\", @\"COMMIT\" ]\n      afterModification:^BOOL {\n          WCTHandle* handle = [self.database getHandle];\n          return [handle beginTransaction]\n                 && [handle deleteFromTable:self.tableName where:TestCaseObject.identifier == 1]\n                 && [handle commitOrRollbackTransaction];\n      }];\n}\n\n- (void)test_handle_seperated_auto_rollback\n{\n    [self doTestObjects:self.objects\n                andSQLs:@[ @\"BEGIN IMMEDIATE\", @\"DELETE FROM testTable WHERE identifier == 1\", @\"COMMIT\" ]\n      afterModification:^BOOL {\n          WCTHandle* handle = [self.database getHandle];\n          BOOL unexpected = NO;\n          [WCTDatabase simulateIOError:WCTSimulateWriteIOError];\n          if ([handle beginTransaction]) {\n              if (![handle deleteFromTable:self.tableName where:TestCaseObject.identifier == 1]) {\n                  TestCaseFailure();\n                  unexpected = YES;\n              }\n              if ([handle commitOrRollbackTransaction]) { // commit failed\n                  TestCaseFailure();\n                  unexpected = YES;\n              } else {\n                  TestCaseAssertFalse([handle isInTransaction]);\n              }\n          } else {\n              TestCaseFailure();\n              unexpected = YES;\n          }\n          [WCTDatabase simulateIOError:WCTSimulateNoneIOError];\n          return !unexpected;\n      }];\n}\n\n- (void)test_handle_seperated_rollback\n{\n    [self doTestObjects:self.objects\n                andSQLs:@[ @\"BEGIN IMMEDIATE\", @\"DELETE FROM testTable WHERE identifier == 1\", @\"ROLLBACK\" ]\n      afterModification:^BOOL {\n          WCTHandle* handle = [self.database getHandle];\n          if (![handle beginTransaction]\n              || ![handle deleteFromTable:self.tableName where:TestCaseObject.identifier == 1]) {\n              TestCaseFailure();\n              return NO;\n          }\n          [handle rollbackTransaction];\n          return YES;\n      }];\n}\n\n#pragma mark - Handle - Nested Transaction\n- (void)test_handle_commit_nested\n{\n    [self doTestObjects:@[ self.object2 ]\n                andSQLs:@[ @\"BEGIN IMMEDIATE\", @\"DELETE FROM testTable WHERE identifier == 1\", @\"COMMIT\" ]\n      afterModification:^BOOL {\n          return [[self.database getHandle] runTransaction:^BOOL(WCTHandle* handle) {\n              return [handle deleteFromTable:self.tableName where:TestCaseObject.identifier == 1];\n          }];\n      }];\n}\n\n- (void)test_handle_rollback_nested\n{\n    [self doTestObjects:self.objects\n                andSQLs:@[ @\"BEGIN IMMEDIATE\", @\"DELETE FROM testTable WHERE identifier == 1\", @\"ROLLBACK\" ]\n      afterModification:^BOOL {\n          __block BOOL unexpected = NO;\n          if ([[self.database getHandle] runTransaction:^BOOL(WCTHandle* handle) {\n                  if (![handle deleteFromTable:self.tableName where:TestCaseObject.identifier == 1]) {\n                      TestCaseFailure();\n                      unexpected = YES;\n                  }\n                  return NO; // rollback\n              }]) {\n              TestCaseFailure();\n              unexpected = YES;\n          }\n          return !unexpected;\n      }];\n}\n\n- (void)test_handle_auto_rollback_nested\n{\n    [self doTestObjects:self.objects\n                andSQLs:@[ @\"BEGIN IMMEDIATE\", @\"DELETE FROM testTable WHERE identifier == 1\", @\"COMMIT\" ]\n      afterModification:^BOOL {\n          __block BOOL unexpected = NO;\n          [WCTDatabase simulateIOError:WCTSimulateWriteIOError];\n          WCTHandle* handle = [self.database getHandle];\n          if ([handle runTransaction:^BOOL(WCTHandle* transactionedHandle) {\n                  if (![transactionedHandle deleteFromTable:self.tableName where:TestCaseObject.identifier == 1]) {\n                      TestCaseFailure();\n                      unexpected = YES;\n                  }\n                  return YES; // commit failed\n              }]) {\n              TestCaseFailure();\n              unexpected = YES;\n          } else {\n              TestCaseAssertFalse([handle isInTransaction]);\n          }\n          [WCTDatabase simulateIOError:WCTSimulateNoneIOError];\n          return !unexpected;\n      }];\n}\n\n#pragma mark - Database - Is In Transaction\n- (void)test_handle_is_in_transaction\n{\n    WCTHandle* handle = [self.database getHandle];\n    {\n        TestCaseAssertFalse([handle isInTransaction]);\n        TestCaseAssertTrue([handle beginTransaction]);\n        TestCaseAssertTrue([handle isInTransaction]);\n        TestCaseAssertTrue([handle commitOrRollbackTransaction]);\n        TestCaseAssertFalse([handle isInTransaction]);\n    }\n    {\n        TestCaseAssertFalse([handle isInTransaction]);\n        TestCaseAssertTrue([handle beginTransaction]);\n        TestCaseAssertTrue([handle isInTransaction]);\n        [handle rollbackTransaction];\n        TestCaseAssertFalse([handle isInTransaction]);\n    }\n}\n\n#pragma mark - Interspersed\n- (void)test_commit_and_commit_nested\n{\n    [self doTestObjects:@[]\n                andSQLs:@[ @\"BEGIN IMMEDIATE\", @\"DELETE FROM testTable WHERE identifier == 1\", @\"SAVEPOINT wcdb_lv_2\", @\"DELETE FROM testTable WHERE identifier == 2\", @\"RELEASE wcdb_lv_2\", @\"COMMIT\" ]\n      afterModification:^BOOL {\n          return [self.database runTransaction:^BOOL(WCTHandle* handle) {\n              return [handle deleteFromTable:self.tableName where:TestCaseObject.identifier == 1]\n                     && [handle runTransaction:^BOOL(WCTHandle* nestedHandle) {\n                            return [nestedHandle deleteFromTable:self.tableName where:TestCaseObject.identifier == 2];\n                        }]; // commit, commit nested\n          }];\n      }];\n}\n\n- (void)test_commit_and_rollback_nested\n{\n    [self doTestObjects:@[ self.object2 ]\n                andSQLs:@[ @\"BEGIN IMMEDIATE\", @\"DELETE FROM testTable WHERE identifier == 1\", @\"SAVEPOINT wcdb_lv_2\", @\"DELETE FROM testTable WHERE identifier == 2\", @\"ROLLBACK TO wcdb_lv_2\", @\"COMMIT\" ]\n      afterModification:^BOOL {\n          __block BOOL unexpected = NO;\n          __block BOOL tested = NO;\n          if (![self.database runTransaction:^BOOL(WCTHandle* handle) {\n                  if (![handle deleteFromTable:self.tableName where:TestCaseObject.identifier == 1]) {\n                      unexpected = YES;\n                  }\n                  if ([handle runTransaction:^BOOL(WCTHandle* nestedHandle) {\n                          tested = YES;\n                          if (![nestedHandle deleteFromTable:self.tableName where:TestCaseObject.identifier == 2]) {\n                              TestCaseFailure();\n                              unexpected = YES;\n                          }\n                          return NO; // rollback nested\n                      }]) {\n                      TestCaseFailure();\n                      unexpected = YES;\n                  }\n                  return YES; // commit\n              }]) {\n              TestCaseFailure();\n              unexpected = YES;\n          }\n          return !unexpected && tested;\n      }];\n}\n\n- (void)test_rollback_and_commit_nested\n{\n    [self doTestObjects:self.objects\n                andSQLs:@[ @\"BEGIN IMMEDIATE\", @\"DELETE FROM testTable WHERE identifier == 1\", @\"SAVEPOINT wcdb_lv_2\", @\"DELETE FROM testTable WHERE identifier == 2\", @\"RELEASE wcdb_lv_2\", @\"ROLLBACK\" ]\n      afterModification:^BOOL {\n          __block BOOL unexpected = NO;\n          __block BOOL tested = NO;\n          if ([self.database runTransaction:^BOOL(WCTHandle* handle) {\n                  if (![handle deleteFromTable:self.tableName where:TestCaseObject.identifier == 1]) {\n                      TestCaseFailure();\n                      unexpected = YES;\n                  }\n                  if (![handle runTransaction:^BOOL(WCTHandle* nestedHandle) {\n                          tested = YES;\n                          return [nestedHandle deleteFromTable:self.tableName where:TestCaseObject.identifier == 2]; // commit nested\n                      }]) {\n                      TestCaseFailure();\n                      unexpected = YES;\n                  }\n                  return NO; // rollback\n              }]) {\n              TestCaseFailure();\n              unexpected = YES;\n          }\n          return !unexpected && tested;\n      }];\n}\n\n- (void)test_rollback_and_rollback_nested\n{\n    [self doTestObjects:self.objects\n                andSQLs:@[ @\"BEGIN IMMEDIATE\", @\"DELETE FROM testTable WHERE identifier == 1\", @\"SAVEPOINT wcdb_lv_2\", @\"DELETE FROM testTable WHERE identifier == 2\", @\"ROLLBACK TO wcdb_lv_2\", @\"ROLLBACK\" ]\n      afterModification:^BOOL {\n          __block BOOL unexpected = NO;\n          __block BOOL tested = NO;\n          if ([self.database runTransaction:^BOOL(WCTHandle* handle) {\n                  if (![handle deleteFromTable:self.tableName where:TestCaseObject.identifier == 1]) {\n                      TestCaseFailure();\n                      unexpected = YES;\n                  }\n                  if ([handle runTransaction:^BOOL(WCTHandle* nestedHandle) {\n                          tested = YES;\n                          if (![nestedHandle deleteFromTable:self.tableName where:TestCaseObject.identifier == 2]) {\n                              TestCaseFailure();\n                              unexpected = YES;\n                          }\n                          return NO; // rollback nested\n                      }]) {\n                      TestCaseFailure();\n                      unexpected = YES;\n                  }\n                  return NO; // rollback\n              }]) {\n              TestCaseFailure();\n              unexpected = YES;\n          }\n          return !unexpected && tested;\n      }];\n}\n\n- (void)test_transaction_handle\n{\n    BOOL succeed = [self.database runTransaction:^BOOL(WCTHandle* _) {\n        WCDB_UNUSED(_);\n        WCTHandle* handle = [self.database getHandle];\n        TestCaseAssertTrue([handle isInTransaction]);\n        return YES;\n    }];\n    TestCaseAssertTrue(succeed);\n}\n\n- (void)test_feature_error_not_allowed_in_transaction\n{\n    BOOL succeed = [[self.database getHandle] runTransaction:^BOOL(WCTHandle* handle) {\n        [handle markErrorNotAllowedWithinTransaction];\n        [handle getObjectOfClass:TestCaseObject.class fromTable:@\"non-existent\"];\n        return YES;\n    }];\n    TestCaseAssertFalse(succeed);\n}\n\n- (void)test_pausable_transaction\n{\n    TestCaseAssertTrue([self dropTable]);\n    TestCaseAssertTrue([self createTable]);\n    __block int identifier = 0;\n    __block int pauseTimes = -1;\n    [self.dispatch async:^{\n        __block int i = 0;\n        __block NSDate* write1Begin = [NSDate date];\n        BOOL ret = [self.database runPausableTransactionWithOneLoop:^BOOL(WCTHandle* _Nonnull handle, BOOL* _Nonnull stop, BOOL isNewTransaction) {\n            TestCaseAssertTrue(handle.isInTransaction);\n            if (isNewTransaction) pauseTimes++;\n\n            double beginInterval = [[NSDate date] timeIntervalSinceDate:write1Begin];\n            TestCaseAssertTrue(beginInterval < 1);\n\n            WCTProperties properties = [self.tableClass allProperties];\n            WCTPreparedStatement* handleStament = [handle getOrCreatePreparedStatement:WCDB::StatementInsert().insertIntoTable(self.tableName).columns(properties).values(WCDB::BindParameter::bindParameters(properties.size()))];\n            TestCaseAssertNotNil(handleStament);\n            [handleStament reset];\n            [handleStament bindProperties:properties ofObject:[Random.shared testCaseObjectWithIdentifier:identifier++]];\n            TestCaseAssertTrue([handleStament step]);\n\n            [NSThread sleepForTimeInterval:0.1];\n            *stop = ++i > 30;\n            write1Begin = [NSDate date];\n            return YES;\n        }];\n        TestCaseAssertTrue(ret);\n    }];\n    [NSThread sleepForTimeInterval:0.5];\n    int i = 0;\n    NSDate* write2Begin;\n    do {\n        write2Begin = [NSDate date];\n        TestCaseAssertTrue([self.database execute:WCDB::StatementBegin().beginImmediate()]);\n        TestCaseAssertTrue(self.database.isInTransaction);\n        double beginInterval = [[NSDate date] timeIntervalSinceDate:write2Begin];\n        TestCaseAssertTrue(beginInterval < 1);\n        [self.table insertObject:[Random.shared testCaseObjectWithIdentifier:identifier++]];\n        [NSThread sleepForTimeInterval:0.1];\n        TestCaseAssertTrue([self.database commitOrRollbackTransaction]);\n    } while (++i < 10);\n    [self.dispatch waitUntilDone];\n    int count = [self.table getValueOnResultColumn:TestCaseObject.allProperties.count()].numberValue.intValue;\n    TestCaseAssertTrue(count == identifier);\n    TestCaseAssertTrue(pauseTimes > 1);\n}\n\n- (void)test_pausable_transaction2\n{\n    TestCaseAssertTrue([self dropTable]);\n    TestCaseAssertTrue([self createTable]);\n    __block int identifier = 0;\n    __block int pauseTime = -1;\n    [self.dispatch async:^{\n        __block int i = 0;\n        __block NSDate* write1Begin = [NSDate date];\n        WCTHandle* handle = self.database.getHandle;\n        [handle runPausableTransactionWithOneLoop:^BOOL(WCTHandle* _Nonnull, BOOL* _Nonnull stop, BOOL isNewTransaction) {\n            TestCaseAssertTrue(handle.isInTransaction);\n            if (isNewTransaction) pauseTime++;\n            double beginInterval = [[NSDate date] timeIntervalSinceDate:write1Begin];\n            TestCaseAssertTrue(beginInterval < 1);\n            WCTProperties properties = [self.tableClass allProperties];\n            WCTPreparedStatement* handleStament = [handle getOrCreatePreparedStatement:WCDB::StatementInsert().insertIntoTable(self.tableName).columns(properties).values(WCDB::BindParameter::bindParameters(properties.size()))];\n            TestCaseAssertNotNil(handleStament);\n            [handleStament reset];\n            [handleStament bindProperties:properties ofObject:[Random.shared testCaseObjectWithIdentifier:identifier++]];\n            TestCaseAssertTrue([handleStament step]);\n\n            [NSThread sleepForTimeInterval:0.1];\n            *stop = ++i > 30;\n            write1Begin = [NSDate date];\n            return YES;\n        }];\n        [handle invalidate];\n    }];\n    [NSThread sleepForTimeInterval:0.5];\n    int i = 0;\n    NSDate* write2Begin;\n    do {\n        write2Begin = [NSDate date];\n        TestCaseAssertTrue([self.database execute:WCDB::StatementBegin().beginImmediate()]);\n        TestCaseAssertTrue(self.database.isInTransaction);\n        double beginInterval = [[NSDate date] timeIntervalSinceDate:write2Begin];\n        TestCaseAssertTrue(beginInterval < 1);\n        [self.table insertObject:[Random.shared testCaseObjectWithIdentifier:identifier++]];\n        [NSThread sleepForTimeInterval:0.1];\n        TestCaseAssertTrue([self.database commitOrRollbackTransaction]);\n    } while (++i < 10);\n    [self.dispatch waitUntilDone];\n    int count = [self.table getValueOnResultColumn:TestCaseObject.allProperties.count()].numberValue.intValue;\n    TestCaseAssertTrue(count == identifier);\n    TestCaseAssertTrue(pauseTime > 1);\n}\n\n- (void)test_pausable_transaction3\n{\n    TestCaseAssertTrue([self dropTable]);\n    TestCaseAssertTrue([self createTable]);\n    __block int identifier = 0;\n    for (int loopCount = 0; loopCount < 1; loopCount++) {\n        [self.dispatch async:^{\n            @autoreleasepool {\n                __block int i = 0;\n                BOOL ret = [self.database runPausableTransactionWithOneLoop:^BOOL(WCTHandle* _Nonnull handle, BOOL* _Nonnull stop, BOOL) {\n                    TestCaseAssertTrue(handle.isInTransaction);\n                    WCTProperties properties = [self.tableClass allProperties];\n                    WCTPreparedStatement* handleStament = [handle getOrCreatePreparedStatement:WCDB::StatementInsert().insertIntoTable(self.tableName).columns(properties).values(WCDB::BindParameter::bindParameters(properties.size()))];\n                    TestCaseAssertNotNil(handleStament);\n                    [handleStament reset];\n                    [handleStament bindProperties:properties ofObject:[Random.shared testCaseObjectWithIdentifier:identifier++]];\n                    TestCaseAssertTrue([handleStament step]);\n\n                    [NSThread sleepForTimeInterval:0.1];\n                    *stop = ++i > 5;\n                    return YES;\n                }];\n                TestCaseAssertTrue(ret);\n            }\n        }];\n    }\n    [NSThread sleepForTimeInterval:0.4];\n    int i = 0;\n    int lastIdentifier = 0;\n    do {\n        TestCaseAssertTrue([self.database execute:WCDB::StatementBegin().beginImmediate()]);\n        TestCaseAssertTrue(self.database.isInTransaction);\n        TestCaseAssertTrue(identifier < 26);\n        TestCaseAssertTrue((lastIdentifier == 0 && identifier < 20) || identifier - lastIdentifier < 20);\n        lastIdentifier = identifier;\n        [self.table insertObject:[Random.shared testCaseObjectWithIdentifier:identifier++]];\n        [NSThread sleepForTimeInterval:0.5];\n        TestCaseAssertTrue([self.database commitOrRollbackTransaction]);\n    } while (++i < 5);\n    [self.dispatch waitUntilDone];\n    int count = [self.table getValueOnResultColumn:TestCaseObject.allProperties.count()].numberValue.intValue;\n    TestCaseAssertTrue(count == identifier);\n}\n\n@end\n"
  },
  {
    "path": "src/objc/tests/winq/AggregateFunctionTests.mm",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"WINQAssertion.h\"\n\n@interface AggregateFunctionTests : BaseTestCase\n\n@end\n\n@implementation AggregateFunctionTests {\n    WCDB::Expression expression1;\n    WCDB::Expression expression2;\n}\n\n- (void)setUp\n{\n    [super setUp];\n    expression1 = 1;\n    expression2 = 2;\n}\n\n- (void)test\n{\n    TestCaseAssertSQLEqual(WCDB::AggregateFunction::avg(expression1), @\"avg(1)\");\n    TestCaseAssertSQLEqual(WCDB::AggregateFunction::count(expression1), @\"count(1)\");\n    TestCaseAssertSQLEqual(WCDB::Expression::function(\"count\").invokeAll(), @\"count(*)\");\n    TestCaseAssertSQLEqual(WCDB::AggregateFunction::groupConcat(expression1), @\"group_concat(1)\");\n    TestCaseAssertSQLEqual(WCDB::AggregateFunction::groupConcat(expression1, expression2), @\"group_concat(1, 2)\");\n    TestCaseAssertSQLEqual(WCDB::AggregateFunction::max(expression1), @\"max(1)\");\n    TestCaseAssertSQLEqual(WCDB::AggregateFunction::min(expression1), @\"min(1)\");\n    TestCaseAssertSQLEqual(WCDB::AggregateFunction::sum(expression1), @\"sum(1)\");\n    TestCaseAssertSQLEqual(WCDB::AggregateFunction::total(expression1), @\"total(1)\");\n}\n\n- (void)test_column_operable\n{\n    WCDB::Column column(@\"testColumn\");\n    TestCaseAssertSQLEqual(column.avg(), @\"avg(testColumn)\");\n    TestCaseAssertSQLEqual(column.count(), @\"count(testColumn)\");\n    TestCaseAssertSQLEqual(column.groupConcat(), @\"group_concat(testColumn)\");\n    TestCaseAssertSQLEqual(column.groupConcat(expression1), @\"group_concat(testColumn, 1)\");\n    TestCaseAssertSQLEqual(column.max(), @\"max(testColumn)\");\n    TestCaseAssertSQLEqual(column.min(), @\"min(testColumn)\");\n    TestCaseAssertSQLEqual(column.sum(), @\"sum(testColumn)\");\n    TestCaseAssertSQLEqual(column.total(), @\"total(testColumn)\");\n}\n\n- (void)test_expression_operable\n{\n    WCDB::Expression column = WCDB::Column(@\"testColumn\");\n    TestCaseAssertSQLEqual(column.avg(), @\"avg(testColumn)\");\n    TestCaseAssertSQLEqual(column.count(), @\"count(testColumn)\");\n    TestCaseAssertSQLEqual(column.groupConcat(), @\"group_concat(testColumn)\");\n    TestCaseAssertSQLEqual(column.groupConcat(expression1), @\"group_concat(testColumn, 1)\");\n    TestCaseAssertSQLEqual(column.max(), @\"max(testColumn)\");\n    TestCaseAssertSQLEqual(column.min(), @\"min(testColumn)\");\n    TestCaseAssertSQLEqual(column.sum(), @\"sum(testColumn)\");\n    TestCaseAssertSQLEqual(column.total(), @\"total(testColumn)\");\n}\n\n@end\n"
  },
  {
    "path": "src/objc/tests/winq/BindParameterTests.mm",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"WINQAssertion.h\"\n\n@interface BindParameterTests : BaseTestCase\n\n@end\n\n@implementation BindParameterTests {\n    NSString* name;\n}\n\n- (void)setUp\n{\n    [super setUp];\n    name = @\"testName\";\n}\n\n- (void)test_default_constructible\n{\n    WCDB::BindParameter constructible;\n    TestCaseAssertTrue(constructible.syntax().isValid());\n    auto testingTypes = { WCDB::SQL::Type::BindParameter };\n    TestCaseAssertIterateEqual(constructible, testingTypes);\n    TestCaseAssertSQLEqual(constructible, @\"?\");\n}\n\n- (void)test_get_type\n{\n    TestCaseAssertEqual(WCDB::BindParameter().getType(), WCDB::SQL::Type::BindParameter);\n    TestCaseAssertEqual(WCDB::BindParameter::type, WCDB::SQL::Type::BindParameter);\n}\n\n- (void)test_number\n{\n    auto testingSQL = WCDB::BindParameter(1);\n    auto testingTypes = { WCDB::SQL::Type::BindParameter };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"?1\");\n}\n\n- (void)test_name\n{\n    auto testingSQL = WCDB::BindParameter(name);\n    auto testingTypes = { WCDB::SQL::Type::BindParameter };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\":testName\");\n}\n\n- (void)test_colon\n{\n    auto testingSQL = WCDB::BindParameter::colon(name);\n    auto testingTypes = { WCDB::SQL::Type::BindParameter };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\":testName\");\n}\n\n- (void)test_at\n{\n    auto testingSQL = WCDB::BindParameter::at(name);\n    auto testingTypes = { WCDB::SQL::Type::BindParameter };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"@testName\");\n}\n\n- (void)test_dollar\n{\n    auto testingSQL = WCDB::BindParameter::dollar(name);\n    auto testingTypes = { WCDB::SQL::Type::BindParameter };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"$testName\");\n}\n\n- (void)test_numbers\n{\n    auto bindParameters = WCDB::BindParameter::bindParameters(2);\n    TestCaseAssertEqual(bindParameters.size(), 2);\n    TestCaseAssertSQLEqual(bindParameters[0], @\"?1\");\n    TestCaseAssertSQLEqual(bindParameters[1], @\"?2\");\n}\n\n@end\n"
  },
  {
    "path": "src/objc/tests/winq/ColumnConstraintTests.mm",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"WINQAssertion.h\"\n\n@interface ColumnConstraintTests : BaseTestCase\n\n@end\n\n@implementation ColumnConstraintTests {\n    NSString* name;\n    WCDB::Order order;\n    WCDB::Conflict conflict;\n    WCDB::Expression condition;\n    WCDB::LiteralValue defaultValue;\n    WCDB::Expression defaultExpression;\n    NSString* collation;\n    WCDB::ForeignKey foreignKey;\n}\n\n- (void)setUp\n{\n    [super setUp];\n    name = @\"testColumnConstraint\";\n    order = WCDB::Order::ASC;\n    conflict = WCDB::Conflict::Abort;\n    condition = 1;\n    defaultValue = 1;\n    defaultExpression = 1;\n    collation = @\"BINARY\";\n    foreignKey = WCDB::ForeignKey().references(@\"testForeignTable\");\n}\n\n- (void)test_default_constructible\n{\n    WCDB::ColumnConstraint constructible;\n    TestCaseAssertFalse(constructible.syntax().isValid());\n    TestCaseAssertIterateEqual(constructible, std::list<WCDB::Syntax::Identifier::Type>());\n    TestCaseAssertTrue(constructible.getDescription().empty());\n}\n\n- (void)test_get_type\n{\n    TestCaseAssertEqual(WCDB::ColumnConstraint().getType(), WCDB::SQL::Type::ColumnConstraint);\n    TestCaseAssertEqual(WCDB::ColumnConstraint::type, WCDB::SQL::Type::ColumnConstraint);\n}\n\n- (void)test_primary_key\n{\n    auto testingSQL = WCDB::ColumnConstraint(name).primaryKey();\n\n    auto testingTypes = { WCDB::SQL::Type::ColumnConstraint };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"CONSTRAINT testColumnConstraint PRIMARY KEY\");\n}\n\n- (void)test_primary_key_without_name\n{\n    auto testingSQL = WCDB::ColumnConstraint().primaryKey();\n\n    auto testingTypes = { WCDB::SQL::Type::ColumnConstraint };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"PRIMARY KEY\");\n}\n\n- (void)test_primary_key_with_order\n{\n    auto testingSQL = WCDB::ColumnConstraint(name).primaryKey().order(WCDB::Order::ASC);\n\n    auto testingTypes = { WCDB::SQL::Type::ColumnConstraint };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"CONSTRAINT testColumnConstraint PRIMARY KEY ASC\");\n}\n\n- (void)test_primary_key_with_conflict\n{\n    auto testingSQL = WCDB::ColumnConstraint(name).primaryKey().conflict(conflict);\n\n    auto testingTypes = { WCDB::SQL::Type::ColumnConstraint };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"CONSTRAINT testColumnConstraint PRIMARY KEY ON CONFLICT ABORT\");\n}\n\n- (void)test_primary_key_with_auto_increment\n{\n    auto testingSQL = WCDB::ColumnConstraint(name).primaryKey().autoIncrement();\n\n    auto testingTypes = { WCDB::SQL::Type::ColumnConstraint };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"CONSTRAINT testColumnConstraint PRIMARY KEY AUTOINCREMENT\");\n}\n\n- (void)test_not_null\n{\n    auto testingSQL = WCDB::ColumnConstraint(name).notNull();\n\n    auto testingTypes = { WCDB::SQL::Type::ColumnConstraint };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"CONSTRAINT testColumnConstraint NOT NULL\");\n}\n\n- (void)test_not_null_with_conflict\n{\n    auto testingSQL = WCDB::ColumnConstraint(name).notNull().conflict(conflict);\n\n    auto testingTypes = { WCDB::SQL::Type::ColumnConstraint };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"CONSTRAINT testColumnConstraint NOT NULL ON CONFLICT ABORT\");\n}\n\n- (void)test_unique\n{\n    auto testingSQL = WCDB::ColumnConstraint(name).unique();\n\n    auto testingTypes = { WCDB::SQL::Type::ColumnConstraint };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"CONSTRAINT testColumnConstraint UNIQUE\");\n}\n\n- (void)test_unique_with_conflict\n{\n    auto testingSQL = WCDB::ColumnConstraint(name).unique().conflict(conflict);\n\n    auto testingTypes = { WCDB::SQL::Type::ColumnConstraint };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"CONSTRAINT testColumnConstraint UNIQUE ON CONFLICT ABORT\");\n}\n\n- (void)test_check\n{\n    auto testingSQL = WCDB::ColumnConstraint(name).check(condition);\n\n    auto testingTypes = { WCDB::SQL::Type::ColumnConstraint, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"CONSTRAINT testColumnConstraint CHECK(1)\");\n}\n\n- (void)test_default_expression\n{\n    auto testingSQL = WCDB::ColumnConstraint(name).default_(defaultExpression);\n\n    auto testingTypes = { WCDB::SQL::Type::ColumnConstraint, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"CONSTRAINT testColumnConstraint DEFAULT 1\");\n}\n\n- (void)test_collate\n{\n    auto testingSQL = WCDB::ColumnConstraint(name).collate(collation);\n\n    auto testingTypes = { WCDB::SQL::Type::ColumnConstraint };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"CONSTRAINT testColumnConstraint COLLATE BINARY\");\n}\n\n- (void)test_foreign_key\n{\n    auto testingSQL = WCDB::ColumnConstraint(name).foreignKey(foreignKey);\n\n    auto testingTypes = { WCDB::SQL::Type::ColumnConstraint, WCDB::SQL::Type::ForeignKeyClause };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"CONSTRAINT testColumnConstraint REFERENCES testForeignTable\");\n}\n\n@end\n"
  },
  {
    "path": "src/objc/tests/winq/ColumnDefTests.mm",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"WINQAssertion.h\"\n\n@interface ColumnDefTests : BaseTestCase\n\n@end\n\n@implementation ColumnDefTests {\n    WCDB::Column column;\n    WCDB::ColumnType columnType;\n    WCDB::ColumnConstraint columnConstraint1;\n    WCDB::ColumnConstraint columnConstraint2;\n}\n\n- (void)setUp\n{\n    [super setUp];\n    column = WCDB::Column(@\"testColumn\");\n    columnType = WCDB::ColumnType::Integer;\n    columnConstraint1 = WCDB::ColumnConstraint().check(1);\n    columnConstraint2 = WCDB::ColumnConstraint().check(2);\n}\n\n- (void)test_default_constructible\n{\n    WCDB::ColumnDef constructible;\n    TestCaseAssertFalse(constructible.syntax().isValid());\n    TestCaseAssertIterateEqual(constructible, std::list<WCDB::Syntax::Identifier::Type>());\n    TestCaseAssertTrue(constructible.getDescription().empty());\n}\n\n- (void)test_get_type\n{\n    TestCaseAssertEqual(WCDB::ColumnDef().getType(), WCDB::SQL::Type::ColumnDef);\n    TestCaseAssertEqual(WCDB::ColumnDef::type, WCDB::SQL::Type::ColumnDef);\n}\n\n- (void)test_column_def\n{\n    auto testingSQL = WCDB::ColumnDef(column, columnType);\n\n    auto testingTypes = { WCDB::SQL::Type::ColumnDef, WCDB::SQL::Type::Column };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"testColumn INTEGER\");\n}\n\n- (void)test_column_def_without_type\n{\n    auto testingSQL = WCDB::ColumnDef(column);\n\n    auto testingTypes = { WCDB::SQL::Type::ColumnDef, WCDB::SQL::Type::Column };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"testColumn\");\n}\n\n- (void)test_column_def_with_constraint\n{\n    auto testingSQL = WCDB::ColumnDef(column, columnType).constraint(columnConstraint1);\n\n    auto testingTypes = { WCDB::SQL::Type::ColumnDef, WCDB::SQL::Type::Column, WCDB::SQL::Type::ColumnConstraint, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"testColumn INTEGER CHECK(1)\");\n}\n\n- (void)test_column_def_with_constraints\n{\n    auto testingSQL = WCDB::ColumnDef(column, columnType).constraint(columnConstraint1).constraint(columnConstraint2);\n\n    auto testingTypes = { WCDB::SQL::Type::ColumnDef, WCDB::SQL::Type::Column, WCDB::SQL::Type::ColumnConstraint, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue, WCDB::SQL::Type::ColumnConstraint, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"testColumn INTEGER CHECK(1) CHECK(2)\");\n}\n\n@end\n"
  },
  {
    "path": "src/objc/tests/winq/ColumnOperableTests.mm",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"WINQAssertion.h\"\n\n@interface ColumnOperableTests : BaseTestCase\n\n@end\n\n@implementation ColumnOperableTests {\n    WCDB::Expression operand;\n    WCDB::Expression expression;\n    WCDB::StatementSelect select;\n    WCDB::Expressions expressions;\n    WCDB::Schema schema;\n    NSString* table;\n    WCDB::Column column;\n    NSString* function;\n}\n\n- (void)setUp\n{\n    [super setUp];\n    operand = 1;\n    expression = 2;\n    select = WCDB::StatementSelect().select(1);\n    expressions = {\n        1,\n        2,\n    };\n    schema = @\"testSchema\";\n    table = @\"testTable\";\n    function = @\"testFunction\";\n    column = WCDB::Column(@\"testColumn\");\n}\n\n- (void)test_unary_tilde\n{\n    auto testingSQL = ~column;\n    auto testingTypes = { WCDB::SQL::Type::Expression, WCDB::SQL::Type::Expression, WCDB::SQL::Type::Column };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"~testColumn\");\n}\n\n- (void)test_unary_not\n{\n    auto testingSQL = !column;\n    auto testingTypes = { WCDB::SQL::Type::Expression, WCDB::SQL::Type::Expression, WCDB::SQL::Type::Column };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"NOT testColumn\");\n}\n\n- (void)test_unary_is_null\n{\n    auto testingSQL = column.isNull();\n    auto testingTypes = { WCDB::SQL::Type::Expression, WCDB::SQL::Type::Expression, WCDB::SQL::Type::Column };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"testColumn ISNULL\");\n}\n\n- (void)test_unary_not_null\n{\n    auto testingSQL = column.notNull();\n    auto testingTypes = { WCDB::SQL::Type::Expression, WCDB::SQL::Type::Expression, WCDB::SQL::Type::Column };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"testColumn NOTNULL\");\n}\n\n- (void)test_binary_concat\n{\n    auto testingSQL = column.concat(operand);\n    auto testingTypes = { WCDB::SQL::Type::Expression, WCDB::SQL::Type::Expression, WCDB::SQL::Type::Column, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"testColumn || 1\");\n}\n\n- (void)test_binary_multiply\n{\n    auto testingSQL = column * operand;\n    auto testingTypes = { WCDB::SQL::Type::Expression, WCDB::SQL::Type::Expression, WCDB::SQL::Type::Column, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"testColumn * 1\");\n}\n\n- (void)test_binary_divide\n{\n    auto testingSQL = column / operand;\n    auto testingTypes = { WCDB::SQL::Type::Expression, WCDB::SQL::Type::Expression, WCDB::SQL::Type::Column, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"testColumn / 1\");\n}\n\n- (void)test_binary_modulo\n{\n    auto testingSQL = column % operand;\n    auto testingTypes = { WCDB::SQL::Type::Expression, WCDB::SQL::Type::Expression, WCDB::SQL::Type::Column, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"testColumn % 1\");\n}\n\n- (void)test_binary_plus\n{\n    auto testingSQL = column + operand;\n    auto testingTypes = { WCDB::SQL::Type::Expression, WCDB::SQL::Type::Expression, WCDB::SQL::Type::Column, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"testColumn + 1\");\n}\n\n- (void)test_binary_minus\n{\n    auto testingSQL = column - operand;\n    auto testingTypes = { WCDB::SQL::Type::Expression, WCDB::SQL::Type::Expression, WCDB::SQL::Type::Column, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"testColumn - 1\");\n}\n\n- (void)test_binary_left_shift\n{\n    auto testingSQL = column << operand;\n    auto testingTypes = { WCDB::SQL::Type::Expression, WCDB::SQL::Type::Expression, WCDB::SQL::Type::Column, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"testColumn << 1\");\n}\n\n- (void)test_binary_right_shift\n{\n    auto testingSQL = column >> operand;\n    auto testingTypes = { WCDB::SQL::Type::Expression, WCDB::SQL::Type::Expression, WCDB::SQL::Type::Column, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"testColumn >> 1\");\n}\n\n- (void)test_binary_bitwise_and\n{\n    auto testingSQL = column & operand;\n    auto testingTypes = { WCDB::SQL::Type::Expression, WCDB::SQL::Type::Expression, WCDB::SQL::Type::Column, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"testColumn & 1\");\n}\n\n- (void)test_binary_bitwise_or\n{\n    auto testingSQL = column | operand;\n    auto testingTypes = { WCDB::SQL::Type::Expression, WCDB::SQL::Type::Expression, WCDB::SQL::Type::Column, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"testColumn | 1\");\n}\n\n- (void)test_binary_less\n{\n    auto testingSQL = column < operand;\n    auto testingTypes = { WCDB::SQL::Type::Expression, WCDB::SQL::Type::Expression, WCDB::SQL::Type::Column, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"testColumn < 1\");\n}\n\n- (void)test_binary_less_or_equal\n{\n    auto testingSQL = column <= operand;\n    auto testingTypes = { WCDB::SQL::Type::Expression, WCDB::SQL::Type::Expression, WCDB::SQL::Type::Column, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"testColumn <= 1\");\n}\n\n- (void)test_binary_greater\n{\n    auto testingSQL = column > operand;\n    auto testingTypes = { WCDB::SQL::Type::Expression, WCDB::SQL::Type::Expression, WCDB::SQL::Type::Column, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"testColumn > 1\");\n}\n\n- (void)test_binary_greater_or_equal\n{\n    auto testingSQL = column >= operand;\n    auto testingTypes = { WCDB::SQL::Type::Expression, WCDB::SQL::Type::Expression, WCDB::SQL::Type::Column, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"testColumn >= 1\");\n}\n\n- (void)test_binary_equal\n{\n    auto testingSQL = column == operand;\n    auto testingTypes = { WCDB::SQL::Type::Expression, WCDB::SQL::Type::Expression, WCDB::SQL::Type::Column, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"testColumn == 1\");\n}\n\n- (void)test_binary_not_equal\n{\n    auto testingSQL = column != operand;\n    auto testingTypes = { WCDB::SQL::Type::Expression, WCDB::SQL::Type::Expression, WCDB::SQL::Type::Column, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"testColumn != 1\");\n}\n\n- (void)test_binary_is\n{\n    auto testingSQL = column.is(operand);\n    auto testingTypes = { WCDB::SQL::Type::Expression, WCDB::SQL::Type::Expression, WCDB::SQL::Type::Column, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"testColumn IS 1\");\n}\n\n- (void)test_binary_is_not\n{\n    auto testingSQL = column.isNot(operand);\n    auto testingTypes = { WCDB::SQL::Type::Expression, WCDB::SQL::Type::Expression, WCDB::SQL::Type::Column, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"testColumn IS NOT 1\");\n}\n\n- (void)test_binary_and\n{\n    auto testingSQL = column && operand;\n    auto testingTypes = { WCDB::SQL::Type::Expression, WCDB::SQL::Type::Expression, WCDB::SQL::Type::Column, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"testColumn AND 1\");\n}\n\n- (void)test_binary_or\n{\n    auto testingSQL = column || operand;\n    auto testingTypes = { WCDB::SQL::Type::Expression, WCDB::SQL::Type::Expression, WCDB::SQL::Type::Column, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"testColumn OR 1\");\n}\n\n- (void)test_binary_like\n{\n    auto testingSQL = column.like(operand);\n    auto testingTypes = { WCDB::SQL::Type::Expression, WCDB::SQL::Type::Expression, WCDB::SQL::Type::Column, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"testColumn LIKE 1\");\n}\n\n- (void)test_binary_not_like\n{\n    auto testingSQL = column.notLike(operand);\n    auto testingTypes = { WCDB::SQL::Type::Expression, WCDB::SQL::Type::Expression, WCDB::SQL::Type::Column, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"testColumn NOT LIKE 1\");\n}\n\n- (void)test_binary_like_escape\n{\n    auto testingSQL = column.like(operand).escape(expression);\n    auto testingTypes = { WCDB::SQL::Type::Expression, WCDB::SQL::Type::Expression, WCDB::SQL::Type::Column, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"testColumn LIKE 1 ESCAPE 2\");\n}\n\n- (void)test_binary_glob\n{\n    auto testingSQL = column.glob(operand);\n    auto testingTypes = { WCDB::SQL::Type::Expression, WCDB::SQL::Type::Expression, WCDB::SQL::Type::Column, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"testColumn GLOB 1\");\n}\n\n- (void)test_binary_not_glob\n{\n    auto testingSQL = column.notGlob(operand);\n    auto testingTypes = { WCDB::SQL::Type::Expression, WCDB::SQL::Type::Expression, WCDB::SQL::Type::Column, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"testColumn NOT GLOB 1\");\n}\n\n- (void)test_binary_match\n{\n    auto testingSQL = column.match(operand);\n    auto testingTypes = { WCDB::SQL::Type::Expression, WCDB::SQL::Type::Expression, WCDB::SQL::Type::Column, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"testColumn MATCH 1\");\n}\n\n- (void)test_binary_not_match\n{\n    auto testingSQL = column.notMatch(operand);\n    auto testingTypes = { WCDB::SQL::Type::Expression, WCDB::SQL::Type::Expression, WCDB::SQL::Type::Column, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"testColumn NOT MATCH 1\");\n}\n\n- (void)test_binary_regexp\n{\n    auto testingSQL = column.regexp(operand);\n    auto testingTypes = { WCDB::SQL::Type::Expression, WCDB::SQL::Type::Expression, WCDB::SQL::Type::Column, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"testColumn REGEXP 1\");\n}\n\n- (void)test_binary_not_regexp\n{\n    auto testingSQL = column.notRegexp(operand);\n    auto testingTypes = { WCDB::SQL::Type::Expression, WCDB::SQL::Type::Expression, WCDB::SQL::Type::Column, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"testColumn NOT REGEXP 1\");\n}\n\n- (void)test_between\n{\n    auto testingSQL = column.between(operand, expression);\n    auto testingTypes = { WCDB::SQL::Type::Expression, WCDB::SQL::Type::Expression, WCDB::SQL::Type::Column, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"testColumn BETWEEN 1 AND 2\");\n}\n\n- (void)test_between_not_between\n{\n    auto testingSQL = column.notBetween(operand, expression);\n    auto testingTypes = { WCDB::SQL::Type::Expression, WCDB::SQL::Type::Expression, WCDB::SQL::Type::Column, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"testColumn NOT BETWEEN 1 AND 2\");\n}\n\n- (void)test_in\n{\n    auto testingSQL = column.in();\n    auto testingTypes = { WCDB::SQL::Type::Expression, WCDB::SQL::Type::Expression, WCDB::SQL::Type::Column };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"testColumn IN()\");\n}\n\n- (void)test_not_in\n{\n    auto testingSQL = column.notIn();\n    auto testingTypes = { WCDB::SQL::Type::Expression, WCDB::SQL::Type::Expression, WCDB::SQL::Type::Column };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"testColumn NOT IN()\");\n}\n\n- (void)test_in_select\n{\n    auto testingSQL = column.in(select);\n    auto testingTypes = { WCDB::SQL::Type::Expression, WCDB::SQL::Type::Expression, WCDB::SQL::Type::Column, WCDB::SQL::Type::SelectSTMT, WCDB::SQL::Type::SelectCore, WCDB::SQL::Type::ResultColumn, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"testColumn IN(SELECT 1)\");\n}\n\n- (void)test_in_expressions\n{\n    auto testingSQL = column.in(expressions);\n    auto testingTypes = { WCDB::SQL::Type::Expression, WCDB::SQL::Type::Expression, WCDB::SQL::Type::Column, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"testColumn IN(1, 2)\");\n}\n\n- (void)test_in_table\n{\n    auto testingSQL = column.inTable(table).schema(schema);\n    auto testingTypes = { WCDB::SQL::Type::Expression, WCDB::SQL::Type::Expression, WCDB::SQL::Type::Column, WCDB::SQL::Type::Schema };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"testColumn IN testSchema.testTable\");\n}\n\n- (void)test_in_table_without_schema\n{\n    auto testingSQL = column.inTable(table);\n    auto testingTypes = { WCDB::SQL::Type::Expression, WCDB::SQL::Type::Expression, WCDB::SQL::Type::Column };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"testColumn IN testTable\");\n}\n\n- (void)test_in_function\n{\n    auto testingSQL = column.inFunction(function).schema(schema).invoke().arguments(expressions);\n    auto testingTypes = { WCDB::SQL::Type::Expression, WCDB::SQL::Type::Expression, WCDB::SQL::Type::Column, WCDB::SQL::Type::Schema, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"testColumn IN testSchema.testFunction(1, 2)\");\n}\n\n- (void)test_in_function_without_schema\n{\n    auto testingSQL = column.inFunction(function).invoke().arguments(expressions);\n    auto testingTypes = { WCDB::SQL::Type::Expression, WCDB::SQL::Type::Expression, WCDB::SQL::Type::Column, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"testColumn IN testFunction(1, 2)\");\n}\n\n- (void)test_in_function_without_parameter\n{\n    auto testingSQL = column.inFunction(function).schema(schema).invoke();\n    auto testingTypes = { WCDB::SQL::Type::Expression, WCDB::SQL::Type::Expression, WCDB::SQL::Type::Column, WCDB::SQL::Type::Schema };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"testColumn IN testSchema.testFunction()\");\n}\n\n@end\n"
  },
  {
    "path": "src/objc/tests/winq/ColumnTests.mm",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"WINQAssertion.h\"\n\n@interface ColumnTests : BaseTestCase\n\n@end\n\n@implementation ColumnTests {\n}\n\n- (void)setUp\n{\n    [super setUp];\n}\n\n- (void)test_default_constructible\n{\n    WCDB::Column constructible;\n    TestCaseAssertFalse(constructible.syntax().isValid());\n    TestCaseAssertIterateEqual(constructible, std::list<WCDB::Syntax::Identifier::Type>());\n    TestCaseAssertTrue(constructible.getDescription().empty());\n}\n\n- (void)test_get_type\n{\n    TestCaseAssertEqual(WCDB::Column().getType(), WCDB::SQL::Type::Column);\n    TestCaseAssertEqual(WCDB::Column::type, WCDB::SQL::Type::Column);\n}\n\n- (void)test_column\n{\n    auto testingSQL = WCDB::Column(@\"testColumn\");\n\n    auto testingTypes = { WCDB::SQL::Type::Column };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"testColumn\");\n}\n\n- (void)test_column_with_table_and_schema\n{\n    auto testingSQL = WCDB::Column(@\"testColumn\").table(@\"testTable\").schema(@\"testSchema\");\n\n    auto testingTypes = { WCDB::SQL::Type::Column, WCDB::SQL::Type::Schema };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"testSchema.testTable.testColumn\");\n}\n\n- (void)test_column_with_table_without_schema\n{\n    auto testingSQL = WCDB::Column(@\"testColumn\").table(@\"testTable\");\n\n    auto testingTypes = { WCDB::SQL::Type::Column };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"testTable.testColumn\");\n}\n\n- (void)test_rowid\n{\n    TestCaseAssertSQLEqual(WCDB::Column::rowid(), @\"rowid\");\n}\n\n- (void)test_alias\n{\n    auto testingSQL = WCDB::Column::rowid().as(\"rowidAlias\");\n\n    auto testingTypes = { WCDB::SQL::Type::ResultColumn, WCDB::SQL::Type::Expression, WCDB::SQL::Type::Column };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"rowid AS rowidAlias\");\n}\n\n- (void)test_rowid_order\n{\n    TestCaseAssertSQLEqual(WCDB::Column::rowid().asOrder(WCDB::Order::ASC), @\"rowid ASC\");\n    TestCaseAssertSQLEqual(WCDB::Column::rowid().asOrder(WCDB::Order::DESC), @\"rowid DESC\");\n}\n\n- (void)test_column_convertible\n{\n    WCDB::Column sql(@\"testColumn\");\n    NSString* expected = @\"testColumn\";\n    TestCaseAssertWINQConvertible(WCDB::Column, sql, expected);\n    TestCaseAssertWINQConvertible(WCDB::Columns, sql, expected);\n    TestCaseAssertWINQConvertible(WCDB::Expression, sql, expected);\n    TestCaseAssertWINQConvertible(WCDB::Expressions, sql, expected);\n    TestCaseAssertWINQConvertible(WCDB::IndexedColumn, sql, expected);\n    TestCaseAssertWINQConvertible(WCDB::IndexedColumns, sql, expected);\n    TestCaseAssertWINQConvertible(WCDB::ResultColumn, sql, expected);\n    TestCaseAssertWINQConvertible(WCDB::ResultColumns, sql, expected);\n    TestCaseAssertWINQConvertible(WCDB::OrderingTerm, sql, expected);\n    TestCaseAssertWINQConvertible(WCDB::OrderingTerms, sql, expected);\n}\n\n- (void)test_columns_convertible\n{\n    WCDB::Columns sqls = {\n        WCDB::Column(@\"testColumn1\"),\n        WCDB::Column(@\"testColumn2\"),\n    };\n    NSString* expected = @\"testColumn1, testColumn2\";\n    TestCaseAssertWINQConvertible(WCDB::Columns, sqls, expected);\n    TestCaseAssertWINQConvertible(WCDB::Expressions, sqls, expected);\n    TestCaseAssertWINQConvertible(WCDB::IndexedColumns, sqls, expected);\n    TestCaseAssertWINQConvertible(WCDB::ResultColumns, sqls, expected);\n    TestCaseAssertWINQConvertible(WCDB::OrderingTerms, sqls, expected);\n}\n\n- (void)test_result_column_all\n{\n    auto testingSQL = WCDB::Column::all();\n\n    auto testingTypes = { WCDB::SQL::Type::Column };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"*\");\n}\n\n- (void)test_all\n{\n    auto testingSQL = WCDB::Column::all();\n\n    auto testingTypes = { WCDB::SQL::Type::Column };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"*\");\n}\n\n- (void)test_all_with_table\n{\n    auto testingSQL = WCDB::Column::all().table(@\"testTable\");\n\n    auto testingTypes = { WCDB::SQL::Type::Column };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"testTable.*\");\n}\n\n@end\n"
  },
  {
    "path": "src/objc/tests/winq/ColumnTypeTests.mm",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"WINQAssertion.h\"\n\n@interface ColumnTypeTests : BaseTestCase\n\n@end\n\n@implementation ColumnTypeTests {\n    WCDB::Column column;\n}\n\n- (void)setUp\n{\n    [super setUp];\n    column = WCDB::Column(@\"testColumn\");\n}\n\n- (void)test_default_constructible\n{\n    WCDB::ColumnType constructible;\n    WCDB_UNUSED(constructible);\n}\n\n- (void)test_type_integer\n{\n    auto testingSQL = WCDB::ColumnDef(column, WCDB::ColumnType::Integer);\n    TestCaseAssertSQLEqual(testingSQL, @\"testColumn INTEGER\");\n}\n\n- (void)test_type_text\n{\n    auto testingSQL = WCDB::ColumnDef(column, WCDB::ColumnType::Text);\n    TestCaseAssertSQLEqual(testingSQL, @\"testColumn TEXT\");\n}\n\n- (void)test_type_blob\n{\n    auto testingSQL = WCDB::ColumnDef(column, WCDB::ColumnType::BLOB);\n    TestCaseAssertSQLEqual(testingSQL, @\"testColumn BLOB\");\n}\n\n- (void)test_type_float\n{\n    auto testingSQL = WCDB::ColumnDef(column, WCDB::ColumnType::Float);\n    TestCaseAssertSQLEqual(testingSQL, @\"testColumn REAL\");\n}\n\n- (void)test_type_null\n{\n    auto testingSQL = WCDB::ColumnDef(column, WCDB::ColumnType::Null);\n    TestCaseAssertSQLEqual(testingSQL, @\"testColumn NULL\");\n}\n\n@end\n"
  },
  {
    "path": "src/objc/tests/winq/CommonTableExpressionTests.mm",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"WINQAssertion.h\"\n\n@interface CommonTableExpressionTests : BaseTestCase\n\n@end\n\n@implementation CommonTableExpressionTests {\n    NSString* table;\n    WCDB::Column column1;\n    WCDB::Column column2;\n    WCDB::StatementSelect select;\n}\n\n- (void)setUp\n{\n    [super setUp];\n    table = @\"testTable\";\n    column1 = WCDB::Column(@\"testColumn1\");\n    column2 = WCDB::Column(@\"testColumn2\");\n    select = WCDB::StatementSelect().select(1);\n}\n\n- (void)test_default_constructible\n{\n    WCDB::CommonTableExpression constructible;\n    TestCaseAssertFalse(constructible.syntax().isValid());\n    TestCaseAssertIterateEqual(constructible, std::list<WCDB::Syntax::Identifier::Type>());\n    TestCaseAssertTrue(constructible.getDescription().empty());\n}\n\n- (void)test_get_type\n{\n    TestCaseAssertEqual(WCDB::CommonTableExpression().getType(), WCDB::SQL::Type::CommonTableExpression);\n    TestCaseAssertEqual(WCDB::CommonTableExpression::type, WCDB::SQL::Type::CommonTableExpression);\n}\n\n- (void)test_common_table_expression\n{\n    auto testingSQL = WCDB::CommonTableExpression(table).column(column1).as(select);\n\n    auto testingTypes = { WCDB::SQL::Type::CommonTableExpression, WCDB::SQL::Type::Column, WCDB::SQL::Type::SelectSTMT, WCDB::SQL::Type::SelectCore, WCDB::SQL::Type::ResultColumn, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"testTable(testColumn1) AS(SELECT 1)\");\n}\n\n- (void)test_common_table_expression_with_columns\n{\n    auto testingSQL = WCDB::CommonTableExpression(table).column(column1).column(column2).as(select);\n\n    auto testingTypes = { WCDB::SQL::Type::CommonTableExpression, WCDB::SQL::Type::Column, WCDB::SQL::Type::Column, WCDB::SQL::Type::SelectSTMT, WCDB::SQL::Type::SelectCore, WCDB::SQL::Type::ResultColumn, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"testTable(testColumn1, testColumn2) AS(SELECT 1)\");\n}\n\n- (void)test_common_table_expression_without_column\n{\n    auto testingSQL = WCDB::CommonTableExpression(table).as(select);\n\n    auto testingTypes = { WCDB::SQL::Type::CommonTableExpression, WCDB::SQL::Type::SelectSTMT, WCDB::SQL::Type::SelectCore, WCDB::SQL::Type::ResultColumn, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"testTable AS(SELECT 1)\");\n}\n\n@end\n"
  },
  {
    "path": "src/objc/tests/winq/ConflictTests.mm",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"WINQAssertion.h\"\n\n@interface ConflictTests : BaseTestCase\n\n@end\n\n@implementation ConflictTests {\n    NSString* name;\n}\n\n- (void)setUp\n{\n    [super setUp];\n    name = @\"testColumnConstraint\";\n}\n\n- (void)test_default_constructible\n{\n    WCDB::Conflict constructible;\n    WCDB_UNUSED(constructible);\n}\n\n- (void)test_conflict_abort\n{\n    auto testingSQL = WCDB::ColumnConstraint(name).primaryKey().conflict(WCDB::Conflict::Abort);\n\n    TestCaseAssertSQLEqual(testingSQL, @\"CONSTRAINT testColumnConstraint PRIMARY KEY ON CONFLICT ABORT\");\n}\n\n- (void)test_conflict_fail\n{\n    auto testingSQL = WCDB::ColumnConstraint(name).primaryKey().conflict(WCDB::Conflict::Fail);\n\n    TestCaseAssertSQLEqual(testingSQL, @\"CONSTRAINT testColumnConstraint PRIMARY KEY ON CONFLICT FAIL\");\n}\n\n- (void)test_conflict_rollback\n{\n    auto testingSQL = WCDB::ColumnConstraint(name).primaryKey().conflict(WCDB::Conflict::Rollback);\n\n    TestCaseAssertSQLEqual(testingSQL, @\"CONSTRAINT testColumnConstraint PRIMARY KEY ON CONFLICT ROLLBACK\");\n}\n\n- (void)test_conflict_ignore\n{\n    auto testingSQL = WCDB::ColumnConstraint(name).primaryKey().conflict(WCDB::Conflict::Ignore);\n\n    TestCaseAssertSQLEqual(testingSQL, @\"CONSTRAINT testColumnConstraint PRIMARY KEY ON CONFLICT IGNORE\");\n}\n\n- (void)test_conflict_replace\n{\n    auto testingSQL = WCDB::ColumnConstraint(name).primaryKey().conflict(WCDB::Conflict::Replace);\n\n    TestCaseAssertSQLEqual(testingSQL, @\"CONSTRAINT testColumnConstraint PRIMARY KEY ON CONFLICT REPLACE\");\n}\n\n@end\n"
  },
  {
    "path": "src/objc/tests/winq/CoreFunctionTests.mm",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"WINQAssertion.h\"\n\n@interface CoreFunctionTests : BaseTestCase\n\n@end\n\n@implementation CoreFunctionTests {\n    WCDB::Expression expression1;\n    WCDB::Expression expression2;\n    WCDB::Expression expression3;\n    WCDB::Expressions expressions;\n}\n\n- (void)setUp\n{\n    [super setUp];\n    expression1 = 1;\n    expression2 = 2;\n    expression3 = 3;\n    expressions = { expression1, expression2 };\n}\n\n- (void)test\n{\n    TestCaseAssertSQLEqual(WCDB::CoreFunction::abs(expression1), @\"abs(1)\");\n    TestCaseAssertSQLEqual(WCDB::CoreFunction::changes(), @\"changes()\");\n    TestCaseAssertSQLEqual(WCDB::CoreFunction::char_(expressions), @\"char(1, 2)\");\n    TestCaseAssertSQLEqual(WCDB::CoreFunction::coalesce(expressions), @\"coalesce(1, 2)\");\n    TestCaseAssertSQLEqual(WCDB::CoreFunction::glob(expression1, expression2), @\"glob(1, 2)\");\n    TestCaseAssertSQLEqual(WCDB::CoreFunction::hex(expression1), @\"hex(1)\");\n    TestCaseAssertSQLEqual(WCDB::CoreFunction::ifNull(expression1, expression2), @\"ifnull(1, 2)\");\n    TestCaseAssertSQLEqual(WCDB::CoreFunction::instr(expression1, expression2), @\"instr(1, 2)\");\n    TestCaseAssertSQLEqual(WCDB::CoreFunction::lastInsertRowID(), @\"last_insert_rowid()\");\n    TestCaseAssertSQLEqual(WCDB::CoreFunction::length(expression1), @\"length(1)\");\n    TestCaseAssertSQLEqual(WCDB::CoreFunction::like(expression1, expression2), @\"like(1, 2)\");\n    TestCaseAssertSQLEqual(WCDB::CoreFunction::like(expression1, expression2, expression3), @\"like(1, 2, 3)\");\n    TestCaseAssertSQLEqual(WCDB::CoreFunction::likelihood(expression1, expression2), @\"likelihood(1, 2)\");\n    TestCaseAssertSQLEqual(WCDB::CoreFunction::likely(expression1), @\"likely(1)\");\n    TestCaseAssertSQLEqual(WCDB::CoreFunction::lower(expression1), @\"lower(1)\");\n    TestCaseAssertSQLEqual(WCDB::CoreFunction::ltrim(expression1), @\"ltrim(1)\");\n    TestCaseAssertSQLEqual(WCDB::CoreFunction::ltrim(expression1, expression2), @\"ltrim(1, 2)\");\n    TestCaseAssertSQLEqual(WCDB::CoreFunction::max(expressions), @\"max(1, 2)\");\n    TestCaseAssertSQLEqual(WCDB::CoreFunction::min(expressions), @\"min(1, 2)\");\n    TestCaseAssertSQLEqual(WCDB::CoreFunction::nullIf(expression1, expression2), @\"nullif(1, 2)\");\n    TestCaseAssertSQLEqual(WCDB::CoreFunction::printf(expressions), @\"printf(1, 2)\");\n    TestCaseAssertSQLEqual(WCDB::CoreFunction::quote(expression1), @\"quote(1)\");\n    TestCaseAssertSQLEqual(WCDB::CoreFunction::random(), @\"random()\");\n    TestCaseAssertSQLEqual(WCDB::CoreFunction::randomBLOB(expression1), @\"randomblob(1)\");\n    TestCaseAssertSQLEqual(WCDB::CoreFunction::replace(expression1, expression2, expression3), @\"replace(1, 2, 3)\");\n    TestCaseAssertSQLEqual(WCDB::CoreFunction::round(expression1), @\"round(1)\");\n    TestCaseAssertSQLEqual(WCDB::CoreFunction::round(expression1, expression2), @\"round(1, 2)\");\n    TestCaseAssertSQLEqual(WCDB::CoreFunction::rtrim(expression1), @\"rtrim(1)\");\n    TestCaseAssertSQLEqual(WCDB::CoreFunction::rtrim(expression1, expression2), @\"rtrim(1, 2)\");\n    TestCaseAssertSQLEqual(WCDB::CoreFunction::soundex(expression1), @\"soundex(1)\");\n    TestCaseAssertSQLEqual(WCDB::CoreFunction::sqliteCompileOptionGet(expression1), @\"sqlite_compileoption_get(1)\");\n    TestCaseAssertSQLEqual(WCDB::CoreFunction::sqliteCompileOptionUsed(expression1), @\"sqlite_compileoption_used(1)\");\n    TestCaseAssertSQLEqual(WCDB::CoreFunction::sqliteOffset(expression1), @\"sqlite_offset(1)\");\n    TestCaseAssertSQLEqual(WCDB::CoreFunction::sqliteSourceID(), @\"sqlite_source_id()\");\n    TestCaseAssertSQLEqual(WCDB::CoreFunction::sqliteVersion(), @\"sqlite_version()\");\n    TestCaseAssertSQLEqual(WCDB::CoreFunction::substr(expression1, expression2), @\"substr(1, 2)\");\n    TestCaseAssertSQLEqual(WCDB::CoreFunction::substr(expression1, expression2, expression3), @\"substr(1, 2, 3)\");\n    TestCaseAssertSQLEqual(WCDB::CoreFunction::totalChanges(), @\"total_changes()\");\n    TestCaseAssertSQLEqual(WCDB::CoreFunction::trim(expression1), @\"trim(1)\");\n    TestCaseAssertSQLEqual(WCDB::CoreFunction::trim(expression1, expression2), @\"trim(1, 2)\");\n    TestCaseAssertSQLEqual(WCDB::CoreFunction::typeof_(expression1), @\"typeof(1)\");\n    TestCaseAssertSQLEqual(WCDB::CoreFunction::unicode(expression1), @\"unicode(1)\");\n    TestCaseAssertSQLEqual(WCDB::CoreFunction::unlikely(expression1), @\"unlikely(1)\");\n    TestCaseAssertSQLEqual(WCDB::CoreFunction::upper(expression1), @\"upper(1)\");\n    TestCaseAssertSQLEqual(WCDB::CoreFunction::zeroBLOB(expression1), @\"zeroblob(1)\");\n}\n\n- (void)test_column_operate\n{\n    WCDB::Column column(@\"testColumn\");\n    TestCaseAssertSQLEqual(column.abs(), @\"abs(testColumn)\");\n    TestCaseAssertSQLEqual(column.hex(), @\"hex(testColumn)\");\n    TestCaseAssertSQLEqual(column.length(), @\"length(testColumn)\");\n    TestCaseAssertSQLEqual(column.lower(), @\"lower(testColumn)\");\n    TestCaseAssertSQLEqual(column.ltrim(), @\"ltrim(testColumn)\");\n    TestCaseAssertSQLEqual(column.ltrim(expression1), @\"ltrim(testColumn, 1)\");\n    TestCaseAssertSQLEqual(column.replace(expression1, expression2), @\"replace(testColumn, 1, 2)\");\n    TestCaseAssertSQLEqual(column.round(), @\"round(testColumn)\");\n    TestCaseAssertSQLEqual(column.round(expression1), @\"round(testColumn, 1)\");\n    TestCaseAssertSQLEqual(column.rtrim(), @\"rtrim(testColumn)\");\n    TestCaseAssertSQLEqual(column.rtrim(expression1), @\"rtrim(testColumn, 1)\");\n    TestCaseAssertSQLEqual(column.substr(expression1), @\"substr(testColumn, 1)\");\n    TestCaseAssertSQLEqual(column.substr(expression1, expression2), @\"substr(testColumn, 1, 2)\");\n    TestCaseAssertSQLEqual(column.trim(), @\"trim(testColumn)\");\n    TestCaseAssertSQLEqual(column.trim(expression1), @\"trim(testColumn, 1)\");\n    TestCaseAssertSQLEqual(column.typeof_(), @\"typeof(testColumn)\");\n    TestCaseAssertSQLEqual(column.upper(), @\"upper(testColumn)\");\n}\n\n- (void)test_expression_operate\n{\n    WCDB::Expression column = WCDB::Column(@\"testColumn\");\n    TestCaseAssertSQLEqual(column.abs(), @\"abs(testColumn)\");\n    TestCaseAssertSQLEqual(column.hex(), @\"hex(testColumn)\");\n    TestCaseAssertSQLEqual(column.length(), @\"length(testColumn)\");\n    TestCaseAssertSQLEqual(column.lower(), @\"lower(testColumn)\");\n    TestCaseAssertSQLEqual(column.ltrim(), @\"ltrim(testColumn)\");\n    TestCaseAssertSQLEqual(column.ltrim(expression1), @\"ltrim(testColumn, 1)\");\n    TestCaseAssertSQLEqual(column.replace(expression1, expression2), @\"replace(testColumn, 1, 2)\");\n    TestCaseAssertSQLEqual(column.round(), @\"round(testColumn)\");\n    TestCaseAssertSQLEqual(column.round(expression1), @\"round(testColumn, 1)\");\n    TestCaseAssertSQLEqual(column.rtrim(), @\"rtrim(testColumn)\");\n    TestCaseAssertSQLEqual(column.rtrim(expression1), @\"rtrim(testColumn, 1)\");\n    TestCaseAssertSQLEqual(column.substr(expression1), @\"substr(testColumn, 1)\");\n    TestCaseAssertSQLEqual(column.substr(expression1, expression2), @\"substr(testColumn, 1, 2)\");\n    TestCaseAssertSQLEqual(column.trim(), @\"trim(testColumn)\");\n    TestCaseAssertSQLEqual(column.trim(expression1), @\"trim(testColumn, 1)\");\n    TestCaseAssertSQLEqual(column.typeof_(), @\"typeof(testColumn)\");\n    TestCaseAssertSQLEqual(column.upper(), @\"upper(testColumn)\");\n}\n\n@end\n"
  },
  {
    "path": "src/objc/tests/winq/ExpressionOperableTests.mm",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"WINQAssertion.h\"\n#include <WCDB/WCTConvertible.h>\n\n@interface ExpressionOperableTests : BaseTestCase\n\n@end\n\n@implementation ExpressionOperableTests {\n    WCDB::Expression operand;\n    WCDB::Expression expression;\n    NSString* collation;\n    WCDB::StatementSelect select;\n    WCDB::Expressions expressions;\n    WCDB::Schema schema;\n    NSString* table;\n    WCDB::Expression columnExpression;\n    NSString* function;\n}\n\n- (void)setUp\n{\n    [super setUp];\n    operand = 1;\n    expression = 2;\n    collation = @\"BINARY\";\n    select = WCDB::StatementSelect().select(1);\n    expressions = {\n        1,\n        2,\n    };\n    schema = @\"testSchema\";\n    table = @\"testTable\";\n    columnExpression = WCDB::Column(@\"testColumn\");\n    function = @\"testFunction\";\n}\n\n- (void)test_unary_tilde\n{\n    auto testingSQL = ~columnExpression;\n    auto testingTypes = { WCDB::SQL::Type::Expression, WCDB::SQL::Type::Expression, WCDB::SQL::Type::Column };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"~testColumn\");\n}\n\n- (void)test_unary_not\n{\n    auto testingSQL = !columnExpression;\n    auto testingTypes = { WCDB::SQL::Type::Expression, WCDB::SQL::Type::Expression, WCDB::SQL::Type::Column };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"NOT testColumn\");\n}\n\n- (void)test_unary_is_null\n{\n    auto testingSQL = columnExpression.isNull();\n    auto testingTypes = { WCDB::SQL::Type::Expression, WCDB::SQL::Type::Expression, WCDB::SQL::Type::Column };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"testColumn ISNULL\");\n}\n\n- (void)test_unary_not_null\n{\n    auto testingSQL = columnExpression.notNull();\n    auto testingTypes = { WCDB::SQL::Type::Expression, WCDB::SQL::Type::Expression, WCDB::SQL::Type::Column };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"testColumn NOTNULL\");\n}\n\n- (void)test_binary_concat\n{\n    auto testingSQL = columnExpression.concat(operand);\n    auto testingTypes = { WCDB::SQL::Type::Expression, WCDB::SQL::Type::Expression, WCDB::SQL::Type::Column, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"testColumn || 1\");\n}\n\n- (void)test_binary_multiply\n{\n    auto testingSQL = columnExpression * operand;\n    auto testingTypes = { WCDB::SQL::Type::Expression, WCDB::SQL::Type::Expression, WCDB::SQL::Type::Column, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"testColumn * 1\");\n}\n\n- (void)test_binary_divide\n{\n    auto testingSQL = columnExpression / operand;\n    auto testingTypes = { WCDB::SQL::Type::Expression, WCDB::SQL::Type::Expression, WCDB::SQL::Type::Column, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"testColumn / 1\");\n}\n\n- (void)test_binary_modulo\n{\n    auto testingSQL = columnExpression % operand;\n    auto testingTypes = { WCDB::SQL::Type::Expression, WCDB::SQL::Type::Expression, WCDB::SQL::Type::Column, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"testColumn % 1\");\n}\n\n- (void)test_binary_plus\n{\n    auto testingSQL = columnExpression + operand;\n    auto testingTypes = { WCDB::SQL::Type::Expression, WCDB::SQL::Type::Expression, WCDB::SQL::Type::Column, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"testColumn + 1\");\n}\n\n- (void)test_binary_minus\n{\n    auto testingSQL = columnExpression - operand;\n    auto testingTypes = { WCDB::SQL::Type::Expression, WCDB::SQL::Type::Expression, WCDB::SQL::Type::Column, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"testColumn - 1\");\n}\n\n- (void)test_binary_left_shift\n{\n    auto testingSQL = columnExpression << operand;\n    auto testingTypes = { WCDB::SQL::Type::Expression, WCDB::SQL::Type::Expression, WCDB::SQL::Type::Column, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"testColumn << 1\");\n}\n\n- (void)test_binary_right_shift\n{\n    auto testingSQL = columnExpression >> operand;\n    auto testingTypes = { WCDB::SQL::Type::Expression, WCDB::SQL::Type::Expression, WCDB::SQL::Type::Column, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"testColumn >> 1\");\n}\n\n- (void)test_binary_bitwise_and\n{\n    auto testingSQL = columnExpression & operand;\n    auto testingTypes = { WCDB::SQL::Type::Expression, WCDB::SQL::Type::Expression, WCDB::SQL::Type::Column, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"testColumn & 1\");\n}\n\n- (void)test_binary_bitwise_or\n{\n    auto testingSQL = columnExpression | operand;\n    auto testingTypes = { WCDB::SQL::Type::Expression, WCDB::SQL::Type::Expression, WCDB::SQL::Type::Column, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"testColumn | 1\");\n}\n\n- (void)test_binary_less\n{\n    auto testingSQL = columnExpression < operand;\n    auto testingTypes = { WCDB::SQL::Type::Expression, WCDB::SQL::Type::Expression, WCDB::SQL::Type::Column, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"testColumn < 1\");\n}\n\n- (void)test_binary_less_or_equal\n{\n    auto testingSQL = columnExpression <= operand;\n    auto testingTypes = { WCDB::SQL::Type::Expression, WCDB::SQL::Type::Expression, WCDB::SQL::Type::Column, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"testColumn <= 1\");\n}\n\n- (void)test_binary_greater\n{\n    auto testingSQL = columnExpression > operand;\n    auto testingTypes = { WCDB::SQL::Type::Expression, WCDB::SQL::Type::Expression, WCDB::SQL::Type::Column, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"testColumn > 1\");\n}\n\n- (void)test_binary_greater_or_equal\n{\n    auto testingSQL = columnExpression >= operand;\n    auto testingTypes = { WCDB::SQL::Type::Expression, WCDB::SQL::Type::Expression, WCDB::SQL::Type::Column, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"testColumn >= 1\");\n}\n\n- (void)test_binary_equal\n{\n    auto testingSQL = columnExpression == operand;\n    auto testingTypes = { WCDB::SQL::Type::Expression, WCDB::SQL::Type::Expression, WCDB::SQL::Type::Column, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"testColumn == 1\");\n}\n\n- (void)test_binary_equal_null\n{\n    NSString* content = nil;\n    auto testingSQL = columnExpression == content;\n    auto testingTypes = { WCDB::SQL::Type::Expression, WCDB::SQL::Type::Expression, WCDB::SQL::Type::Column };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"testColumn ISNULL\");\n}\n\n- (void)test_binary_not_equal_null\n{\n    NSString* content = nil;\n    auto testingSQL = columnExpression != content;\n    auto testingTypes = { WCDB::SQL::Type::Expression, WCDB::SQL::Type::Expression, WCDB::SQL::Type::Column };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"testColumn NOTNULL\");\n}\n\n- (void)test_binary_not_equal\n{\n    auto testingSQL = columnExpression != operand;\n    auto testingTypes = { WCDB::SQL::Type::Expression, WCDB::SQL::Type::Expression, WCDB::SQL::Type::Column, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"testColumn != 1\");\n}\n\n- (void)test_binary_is\n{\n    auto testingSQL = columnExpression.is(operand);\n    auto testingTypes = { WCDB::SQL::Type::Expression, WCDB::SQL::Type::Expression, WCDB::SQL::Type::Column, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"testColumn IS 1\");\n}\n\n- (void)test_binary_is_not\n{\n    auto testingSQL = columnExpression.isNot(operand);\n    auto testingTypes = { WCDB::SQL::Type::Expression, WCDB::SQL::Type::Expression, WCDB::SQL::Type::Column, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"testColumn IS NOT 1\");\n}\n\n- (void)test_binary_and\n{\n    auto testingSQL = columnExpression && operand;\n    auto testingTypes = { WCDB::SQL::Type::Expression, WCDB::SQL::Type::Expression, WCDB::SQL::Type::Column, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"testColumn AND 1\");\n}\n\n- (void)test_binary_or\n{\n    auto testingSQL = columnExpression || operand;\n    auto testingTypes = { WCDB::SQL::Type::Expression, WCDB::SQL::Type::Expression, WCDB::SQL::Type::Column, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"testColumn OR 1\");\n}\n\n- (void)test_binary_like\n{\n    auto testingSQL = columnExpression.like(operand);\n    auto testingTypes = { WCDB::SQL::Type::Expression, WCDB::SQL::Type::Expression, WCDB::SQL::Type::Column, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"testColumn LIKE 1\");\n}\n\n- (void)test_binary_not_like\n{\n    auto testingSQL = columnExpression.notLike(operand);\n    auto testingTypes = { WCDB::SQL::Type::Expression, WCDB::SQL::Type::Expression, WCDB::SQL::Type::Column, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"testColumn NOT LIKE 1\");\n}\n\n- (void)test_binary_like_escape\n{\n    auto testingSQL = columnExpression.like(operand).escape(expression);\n    auto testingTypes = { WCDB::SQL::Type::Expression, WCDB::SQL::Type::Expression, WCDB::SQL::Type::Column, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"testColumn LIKE 1 ESCAPE 2\");\n}\n\n- (void)test_binary_glob\n{\n    auto testingSQL = columnExpression.glob(operand);\n    auto testingTypes = { WCDB::SQL::Type::Expression, WCDB::SQL::Type::Expression, WCDB::SQL::Type::Column, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"testColumn GLOB 1\");\n}\n\n- (void)test_binary_not_glob\n{\n    auto testingSQL = columnExpression.notGlob(operand);\n    auto testingTypes = { WCDB::SQL::Type::Expression, WCDB::SQL::Type::Expression, WCDB::SQL::Type::Column, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"testColumn NOT GLOB 1\");\n}\n\n- (void)test_binary_match\n{\n    auto testingSQL = columnExpression.match(operand);\n    auto testingTypes = { WCDB::SQL::Type::Expression, WCDB::SQL::Type::Expression, WCDB::SQL::Type::Column, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"testColumn MATCH 1\");\n}\n\n- (void)test_binary_not_match\n{\n    auto testingSQL = columnExpression.notMatch(operand);\n    auto testingTypes = { WCDB::SQL::Type::Expression, WCDB::SQL::Type::Expression, WCDB::SQL::Type::Column, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"testColumn NOT MATCH 1\");\n}\n\n- (void)test_binary_regexp\n{\n    auto testingSQL = columnExpression.regexp(operand);\n    auto testingTypes = { WCDB::SQL::Type::Expression, WCDB::SQL::Type::Expression, WCDB::SQL::Type::Column, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"testColumn REGEXP 1\");\n}\n\n- (void)test_binary_not_regexp\n{\n    auto testingSQL = columnExpression.notRegexp(operand);\n    auto testingTypes = { WCDB::SQL::Type::Expression, WCDB::SQL::Type::Expression, WCDB::SQL::Type::Column, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"testColumn NOT REGEXP 1\");\n}\n\n- (void)test_collate\n{\n    auto testingSQL = columnExpression.collate(collation);\n    auto testingTypes = { WCDB::SQL::Type::Expression, WCDB::SQL::Type::Expression, WCDB::SQL::Type::Column };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"testColumn COLLATE BINARY\");\n}\n\n- (void)test_between\n{\n    auto testingSQL = columnExpression.between(operand, expression);\n    auto testingTypes = { WCDB::SQL::Type::Expression, WCDB::SQL::Type::Expression, WCDB::SQL::Type::Column, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"testColumn BETWEEN 1 AND 2\");\n}\n\n- (void)test_between_not_between\n{\n    auto testingSQL = columnExpression.notBetween(operand, expression);\n    auto testingTypes = { WCDB::SQL::Type::Expression, WCDB::SQL::Type::Expression, WCDB::SQL::Type::Column, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"testColumn NOT BETWEEN 1 AND 2\");\n}\n\n- (void)test_in\n{\n    auto testingSQL = columnExpression.in();\n    auto testingTypes = { WCDB::SQL::Type::Expression, WCDB::SQL::Type::Expression, WCDB::SQL::Type::Column };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"testColumn IN()\");\n}\n\n- (void)test_not_in\n{\n    auto testingSQL = columnExpression.notIn();\n    auto testingTypes = { WCDB::SQL::Type::Expression, WCDB::SQL::Type::Expression, WCDB::SQL::Type::Column };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"testColumn NOT IN()\");\n}\n\n- (void)test_in_select\n{\n    auto testingSQL = columnExpression.in(select);\n    auto testingTypes = { WCDB::SQL::Type::Expression, WCDB::SQL::Type::Expression, WCDB::SQL::Type::Column, WCDB::SQL::Type::SelectSTMT, WCDB::SQL::Type::SelectCore, WCDB::SQL::Type::ResultColumn, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"testColumn IN(SELECT 1)\");\n}\n\n- (void)test_not_in_select\n{\n    auto testingSQL = columnExpression.notIn(select);\n    auto testingTypes = { WCDB::SQL::Type::Expression, WCDB::SQL::Type::Expression, WCDB::SQL::Type::Column, WCDB::SQL::Type::SelectSTMT, WCDB::SQL::Type::SelectCore, WCDB::SQL::Type::ResultColumn, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"testColumn NOT IN(SELECT 1)\");\n}\n\n- (void)test_in_expressions\n{\n    auto testingSQL = columnExpression.in(expressions);\n    auto testingTypes = { WCDB::SQL::Type::Expression, WCDB::SQL::Type::Expression, WCDB::SQL::Type::Column, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"testColumn IN(1, 2)\");\n}\n\n- (void)test_not_in_expressions\n{\n    auto testingSQL = columnExpression.notIn(expressions);\n    auto testingTypes = { WCDB::SQL::Type::Expression, WCDB::SQL::Type::Expression, WCDB::SQL::Type::Column, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"testColumn NOT IN(1, 2)\");\n}\n\n- (void)test_in_table\n{\n    auto testingSQL = columnExpression.inTable(table).schema(schema);\n    auto testingTypes = { WCDB::SQL::Type::Expression, WCDB::SQL::Type::Expression, WCDB::SQL::Type::Column, WCDB::SQL::Type::Schema };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"testColumn IN testSchema.testTable\");\n}\n\n- (void)test_in_table_without_schema\n{\n    auto testingSQL = columnExpression.inTable(table);\n    auto testingTypes = { WCDB::SQL::Type::Expression, WCDB::SQL::Type::Expression, WCDB::SQL::Type::Column };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"testColumn IN testTable\");\n}\n\n- (void)test_not_in_table\n{\n    auto testingSQL = columnExpression.notInTable(table).schema(schema);\n    auto testingTypes = { WCDB::SQL::Type::Expression, WCDB::SQL::Type::Expression, WCDB::SQL::Type::Column, WCDB::SQL::Type::Schema };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"testColumn NOT IN testSchema.testTable\");\n}\n\n- (void)test_in_function\n{\n    auto testingSQL = columnExpression.inFunction(function).schema(schema).invoke().arguments(expressions);\n    auto testingTypes = { WCDB::SQL::Type::Expression, WCDB::SQL::Type::Expression, WCDB::SQL::Type::Column, WCDB::SQL::Type::Schema, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"testColumn IN testSchema.testFunction(1, 2)\");\n}\n\n- (void)test_in_function_without_schema\n{\n    auto testingSQL = columnExpression.inFunction(function).invoke().arguments(expressions);\n    auto testingTypes = { WCDB::SQL::Type::Expression, WCDB::SQL::Type::Expression, WCDB::SQL::Type::Column, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"testColumn IN testFunction(1, 2)\");\n}\n\n- (void)test_in_function_without_parameter\n{\n    auto testingSQL = columnExpression.inFunction(function).schema(schema).invoke();\n    auto testingTypes = { WCDB::SQL::Type::Expression, WCDB::SQL::Type::Expression, WCDB::SQL::Type::Column, WCDB::SQL::Type::Schema };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"testColumn IN testSchema.testFunction()\");\n}\n\n- (void)test_not_in_function\n{\n    auto testingSQL = columnExpression.notInFunction(function).schema(schema).invoke().arguments(expressions);\n    auto testingTypes = { WCDB::SQL::Type::Expression, WCDB::SQL::Type::Expression, WCDB::SQL::Type::Column, WCDB::SQL::Type::Schema, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"testColumn NOT IN testSchema.testFunction(1, 2)\");\n}\n\n@end\n"
  },
  {
    "path": "src/objc/tests/winq/ExpressionTests.mm",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"WINQAssertion.h\"\n\n@interface ExpressionTests : BaseTestCase\n\n@end\n\n@implementation ExpressionTests {\n    WCDB::LiteralValue literalValue;\n    WCDB::BindParameter bindParameter;\n    WCDB::Schema schema;\n    NSString* table;\n    WCDB::Column column;\n    WCDB::Expression expression1;\n    WCDB::Expression expression2;\n    WCDB::Expression expression3;\n    WCDB::Expression expression4;\n    WCDB::Expression expression5;\n    WCDB::Expression expression6;\n    NSString* function;\n    WCDB::ColumnType columnType;\n    WCDB::StatementSelect select;\n    WCDB::Expressions expressions;\n    WCDB::RaiseFunction raiseFunction;\n    NSString* windowFunction;\n    WCDB::Expression filter;\n    WCDB::WindowDef windowDef;\n    NSString* window;\n}\n\n- (void)setUp\n{\n    [super setUp];\n    literalValue = 1;\n    bindParameter = WCDB::BindParameter(1);\n    schema = @\"testSchema\";\n    table = @\"testTable\";\n    column = WCDB::Column(@\"testColumn\");\n    expression1 = 1;\n    expression2 = 2;\n    expression3 = 3;\n    expression4 = 4;\n    expression5 = 5;\n    expression6 = 6;\n    function = @\"testFunction\";\n    columnType = WCDB::ColumnType::Integer;\n    select = WCDB::StatementSelect().select(1);\n    expressions = {\n        1,\n        2,\n    };\n    raiseFunction = WCDB::RaiseFunction().ignore();\n    windowFunction = @\"testWindowFunction\";\n    filter = 1;\n    windowDef = WCDB::WindowDef().partition(expressions);\n    window = @\"testWindow\";\n}\n\n- (void)test_default_constructible\n{\n    WCDB::Expression constructible;\n    TestCaseAssertFalse(constructible.syntax().isValid());\n    TestCaseAssertIterateEqual(constructible, std::list<WCDB::Syntax::Identifier::Type>());\n    TestCaseAssertTrue(constructible.getDescription().empty());\n}\n\n- (void)test_get_type\n{\n    TestCaseAssertEqual(WCDB::Expression().getType(), WCDB::SQL::Type::Expression);\n    TestCaseAssertEqual(WCDB::Expression::type, WCDB::SQL::Type::Expression);\n}\n\n- (void)test_literal_value\n{\n    auto testingSQL = WCDB::Expression(literalValue);\n\n    auto testingTypes = { WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"1\");\n}\n\n- (void)test_bind_parameter\n{\n    auto testingSQL = WCDB::Expression(bindParameter);\n\n    auto testingTypes = { WCDB::SQL::Type::Expression, WCDB::SQL::Type::BindParameter };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"?1\");\n}\n\n- (void)test_column_without_table\n{\n    auto testingSQL = WCDB::Expression(column);\n\n    auto testingTypes = { WCDB::SQL::Type::Expression, WCDB::SQL::Type::Column };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"testColumn\");\n}\n\n- (void)test_function\n{\n    auto testingSQL = WCDB::Expression::function(function).distinct().invoke().argument(expression1);\n\n    auto testingTypes = { WCDB::SQL::Type::Expression, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"testFunction(DISTINCT 1)\");\n}\n\n- (void)test_function_with_arguments\n{\n    auto testingSQL = WCDB::Expression::function(function).distinct().invoke().argument(expression1).argument(expression2);\n\n    auto testingTypes = { WCDB::SQL::Type::Expression, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"testFunction(DISTINCT 1, 2)\");\n}\n\n- (void)test_function_without_distinct\n{\n    auto testingSQL = WCDB::Expression::function(function).invoke().argument(expression1);\n\n    auto testingTypes = { WCDB::SQL::Type::Expression, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"testFunction(1)\");\n}\n\n- (void)test_function_without_parameter\n{\n    auto testingSQL = WCDB::Expression::function(function);\n\n    auto testingTypes = { WCDB::SQL::Type::Expression };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"testFunction()\");\n}\n\n- (void)test_function_all\n{\n    auto testingSQL = WCDB::Expression::function(function).invokeAll();\n\n    auto testingTypes = { WCDB::SQL::Type::Expression };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"testFunction(*)\");\n}\n\n- (void)test_expression_operable\n{\n    // see ExpressionOperableTests\n}\n\n- (void)test_core_function_operable\n{\n    // see CoreFunctionTests\n}\n\n- (void)test_aggregate_function_operable\n{\n    // see AggregateFunctionTests\n}\n\n- (void)test_fts3_function_operable\n{\n    // see FTS3FunctionTests\n}\n\n- (void)test_expressions\n{\n    auto testingSQL = WCDB::Expression(expressions);\n\n    auto testingTypes = { WCDB::SQL::Type::Expression, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"(1, 2)\");\n}\n\n- (void)test_cast\n{\n    auto testingSQL = WCDB::Expression::cast(expression1).as(columnType);\n\n    auto testingTypes = { WCDB::SQL::Type::Expression, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"CAST(1 AS INTEGER)\");\n}\n\n- (void)test_alias\n{\n    auto testingSQL = (WCDB::Column::rowid() + 1).as(\"rowidAddOne\");\n    auto testingTypes = { WCDB::SQL::Type::ResultColumn, WCDB::SQL::Type::Expression, WCDB::SQL::Type::Expression, WCDB::SQL::Type::Column, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue };\n    auto types = WCDB::getTypesOfSQL(testingSQL);\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"rowid + 1 AS rowidAddOne\");\n}\n\n- (void)test_select\n{\n    auto testingSQL = WCDB::Expression(select);\n\n    auto testingTypes = { WCDB::SQL::Type::Expression, WCDB::SQL::Type::SelectSTMT, WCDB::SQL::Type::SelectCore, WCDB::SQL::Type::ResultColumn, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"(SELECT 1)\");\n}\n\n- (void)test_exists\n{\n    auto testingSQL = WCDB::Expression::exists(select);\n\n    auto testingTypes = { WCDB::SQL::Type::Expression, WCDB::SQL::Type::SelectSTMT, WCDB::SQL::Type::SelectCore, WCDB::SQL::Type::ResultColumn, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"EXISTS(SELECT 1)\");\n}\n\n- (void)test_not_exists\n{\n    auto testingSQL = WCDB::Expression::notExists(select);\n\n    auto testingTypes = { WCDB::SQL::Type::Expression, WCDB::SQL::Type::SelectSTMT, WCDB::SQL::Type::SelectCore, WCDB::SQL::Type::ResultColumn, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"NOT EXISTS(SELECT 1)\");\n}\n\n- (void)test_case\n{\n    auto testingSQL = WCDB::Expression::case_(expression1).when(expression2).then(expression3).else_(expression4);\n\n    auto testingTypes = { WCDB::SQL::Type::Expression, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"CASE 1 WHEN 2 THEN 3 ELSE 4 END\");\n}\n\n- (void)test_case_without_case\n{\n    auto testingSQL = WCDB::Expression::case_().when(expression2).then(expression3).else_(expression4);\n\n    auto testingTypes = { WCDB::SQL::Type::Expression, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"CASE WHEN 2 THEN 3 ELSE 4 END\");\n}\n\n- (void)test_case_multiple_when_then\n{\n    auto testingSQL = WCDB::Expression::case_(expression1).when(expression2).then(expression3).when(expression4).then(expression5).else_(expression6);\n\n    auto testingTypes = { WCDB::SQL::Type::Expression, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"CASE 1 WHEN 2 THEN 3 WHEN 4 THEN 5 ELSE 6 END\");\n}\n\n- (void)test_case_without_else\n{\n    auto testingSQL = WCDB::Expression::case_(expression1).when(expression2).then(expression3);\n\n    auto testingTypes = { WCDB::SQL::Type::Expression, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"CASE 1 WHEN 2 THEN 3 END\");\n}\n\n- (void)test_raise_function\n{\n    auto testingSQL = WCDB::Expression(raiseFunction);\n\n    auto testingTypes = { WCDB::SQL::Type::Expression, WCDB::SQL::Type::RaiseFunction };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"RAISE(IGNORE)\");\n}\n\n- (void)test_window_function\n{\n    auto testingSQL = WCDB::Expression::windowFunction(windowFunction).invoke().argument(expression1).over(windowDef);\n\n    auto testingTypes = { WCDB::SQL::Type::Expression, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue, WCDB::SQL::Type::WindowDef, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"testWindowFunction(1) OVER(PARTITION BY 1, 2)\");\n}\n\n- (void)test_window_function_with_arguments\n{\n    auto testingSQL = WCDB::Expression::windowFunction(windowFunction).invoke().argument(expression1).argument(expression2).over(windowDef);\n\n    auto testingTypes = { WCDB::SQL::Type::Expression, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue, WCDB::SQL::Type::WindowDef, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"testWindowFunction(1, 2) OVER(PARTITION BY 1, 2)\");\n}\n\n- (void)test_window_function_without_parameter\n{\n    auto testingSQL = WCDB::Expression::windowFunction(windowFunction).invoke().over(windowDef);\n\n    auto testingTypes = { WCDB::SQL::Type::Expression, WCDB::SQL::Type::WindowDef, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"testWindowFunction() OVER(PARTITION BY 1, 2)\");\n}\n\n- (void)test_window_function_all\n{\n    auto testingSQL = WCDB::Expression::windowFunction(windowFunction).invokeAll().over(windowDef);\n\n    auto testingTypes = { WCDB::SQL::Type::Expression, WCDB::SQL::Type::WindowDef, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"testWindowFunction(*) OVER(PARTITION BY 1, 2)\");\n}\n\n- (void)test_window_function_with_filter\n{\n    auto testingSQL = WCDB::Expression::windowFunction(windowFunction).invoke().argument(expression1).filter(filter).over(windowDef);\n\n    auto testingTypes = { WCDB::SQL::Type::Expression, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue, WCDB::SQL::Type::Filter, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue, WCDB::SQL::Type::WindowDef, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"testWindowFunction(1) FILTER(WHERE 1) OVER(PARTITION BY 1, 2)\");\n}\n\n- (void)test_window_function_with_name\n{\n    auto testingSQL = WCDB::Expression::windowFunction(windowFunction).invoke().argument(expression1).over(window);\n\n    auto testingTypes = { WCDB::SQL::Type::Expression, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"testWindowFunction(1) OVER testWindow\");\n}\n\n- (void)test_expression_convertible\n{\n    WCDB::Expression sql(1);\n    NSString* expected = @\"1\";\n    TestCaseAssertWINQConvertible(WCDB::Expression, sql, expected);\n    TestCaseAssertWINQConvertible(WCDB::Expressions, sql, expected);\n    TestCaseAssertWINQConvertible(WCDB::IndexedColumn, sql, expected);\n    TestCaseAssertWINQConvertible(WCDB::IndexedColumns, sql, expected);\n    TestCaseAssertWINQConvertible(WCDB::ResultColumn, sql, expected);\n    TestCaseAssertWINQConvertible(WCDB::ResultColumns, sql, expected);\n    TestCaseAssertWINQConvertible(WCDB::OrderingTerm, sql, expected);\n    TestCaseAssertWINQConvertible(WCDB::OrderingTerms, sql, expected);\n}\n\n- (void)test_float_precision\n{\n    auto expr = WCDB::Column(@\"testColumn\") > 123456789.123456;\n    TestCaseAssertSQLEqual(expr, @\"testColumn > 123456789.123456\");\n}\n\n- (void)test_expressions_convertible\n{\n    WCDB::Expressions sqls = {\n        1,\n        WCDB::Column(@\"testColumn\"),\n    };\n    NSString* expected = @\"1, testColumn\";\n    TestCaseAssertWINQConvertible(WCDB::Expressions, sqls, expected);\n    TestCaseAssertWINQConvertible(WCDB::IndexedColumns, sqls, expected);\n    TestCaseAssertWINQConvertible(WCDB::ResultColumns, sqls, expected);\n    TestCaseAssertWINQConvertible(WCDB::OrderingTerms, sqls, expected);\n}\n\n- (void)test_convert_NSArray_to_expressions\n{\n    NSMutableArray<NSMutableString*>* textArray = [[NSMutableArray alloc] init];\n    [textArray addObject:[[NSMutableString alloc] initWithString:@\"text1\"]];\n    [textArray addObject:[[NSMutableString alloc] initWithString:@\"text2\"]];\n    WCDB::Column textColumn = WCDB::Column(\"textColumn\");\n\n    TestCaseAssertSQLEqual(textColumn.in(textArray), @\"textColumn IN('text1', 'text2')\");\n    TestCaseAssertSQLEqual(textColumn.in((NSMutableArray<NSString*>*) textArray), @\"textColumn IN('text1', 'text2')\");\n    TestCaseAssertSQLEqual(textColumn.in((NSArray<NSString*>*) textArray), @\"textColumn IN('text1', 'text2')\");\n    TestCaseAssertSQLEqual(textColumn.in((NSArray<NSMutableString*>*) textArray), @\"textColumn IN('text1', 'text2')\");\n    TestCaseAssertSQLEqual(textColumn.in((NSMutableArray*) textArray), @\"textColumn IN('text1', 'text2')\");\n    TestCaseAssertSQLEqual(textColumn.in((NSArray*) textArray), @\"textColumn IN('text1', 'text2')\");\n\n    NSMutableArray<NSNumber*>* numberArray = [[NSMutableArray alloc] init];\n    [numberArray addObject:@(1)];\n    [numberArray addObject:@(2)];\n\n    TestCaseAssertSQLEqual(textColumn.in(numberArray), @\"textColumn IN(1, 2)\");\n    TestCaseAssertSQLEqual(textColumn.in((NSMutableArray*) numberArray), @\"textColumn IN(1, 2)\");\n    TestCaseAssertSQLEqual(textColumn.in((NSArray<NSNumber*>*) numberArray), @\"textColumn IN(1, 2)\");\n    TestCaseAssertSQLEqual(textColumn.in((NSArray*) numberArray), @\"textColumn IN(1, 2)\");\n}\n\n- (void)test_convert_NSSet_to_expressions\n{\n    NSMutableSet<NSMutableString*>* textSet = [[NSMutableSet alloc] init];\n    [textSet addObject:[[NSMutableString alloc] initWithString:@\"text1\"]];\n    [textSet addObject:[[NSMutableString alloc] initWithString:@\"text2\"]];\n    WCDB::Column textColumn = WCDB::Column(\"textColumn\");\n\n    TestCaseAssertSQLEqual(textColumn.in(textSet), @\"textColumn IN('text1', 'text2')\");\n    TestCaseAssertSQLEqual(textColumn.in((NSMutableSet<NSString*>*) textSet), @\"textColumn IN('text1', 'text2')\");\n    TestCaseAssertSQLEqual(textColumn.in((NSSet<NSString*>*) textSet), @\"textColumn IN('text1', 'text2')\");\n    TestCaseAssertSQLEqual(textColumn.in((NSSet<NSMutableString*>*) textSet), @\"textColumn IN('text1', 'text2')\");\n    TestCaseAssertSQLEqual(textColumn.in((NSMutableSet*) textSet), @\"textColumn IN('text1', 'text2')\");\n    TestCaseAssertSQLEqual(textColumn.in((NSSet*) textSet), @\"textColumn IN('text1', 'text2')\");\n\n    NSMutableSet<NSNumber*>* numberSet = [[NSMutableSet alloc] init];\n    [numberSet addObject:@(1)];\n    [numberSet addObject:@(2)];\n\n    TestCaseAssertSQLEqual(textColumn.in(numberSet), @\"textColumn IN(1, 2)\");\n    TestCaseAssertSQLEqual(textColumn.in((NSMutableSet*) numberSet), @\"textColumn IN(1, 2)\");\n    TestCaseAssertSQLEqual(textColumn.in((NSSet<NSNumber*>*) numberSet), @\"textColumn IN(1, 2)\");\n    TestCaseAssertSQLEqual(textColumn.in((NSSet*) numberSet), @\"textColumn IN(1, 2)\");\n}\n\n- (void)test_precedence\n{\n    TestCaseAssertSQLEqual(!(((column && 1) > 2) - 3), @\"NOT (((testColumn AND 1) > 2) - 3)\");\n}\n\n- (void)test_collate {\n    TestCaseAssertSQLEqual(column.is(\"abc\").collate(@\"NOCASE\"), @\"testColumn IS 'abc' COLLATE NOCASE\");\n}\n\n- (void)test_boundary\n{\n    WCDB::Expression int64Min = std::numeric_limits<int64_t>::min();\n    TestCaseAssertSQLEqual(int64Min, @\"-9223372036854775808\");\n    WCDB::Expression int64Max = std::numeric_limits<int64_t>::max();\n    TestCaseAssertSQLEqual(int64Max, @\"9223372036854775807\");\n\n    WCDB::Expression uint64Min = std::numeric_limits<uint64_t>::min();\n    TestCaseAssertSQLEqual(uint64Min, @\"0\");\n    WCDB::Expression uint64Max = std::numeric_limits<uint64_t>::max();\n    TestCaseAssertSQLEqual(uint64Max, @\"18446744073709551615\");\n\n    WCDB::Expression enumNSMin = EnumNSTypeMin;\n    TestCaseAssertSQLEqual(enumNSMin, @\"-9223372036854775808\");\n    WCDB::Expression enumNSMax = EnumNSTypeMax;\n    TestCaseAssertSQLEqual(enumNSMax, @\"9223372036854775807\");\n\n    WCDB::Expression optionNSMin = OptionNSTypeMin;\n    TestCaseAssertSQLEqual(optionNSMin, @\"-9223372036854775808\");\n    WCDB::Expression optionNSMax = OptionNSTypeMax;\n    TestCaseAssertSQLEqual(optionNSMax, @\"9223372036854775807\");\n\n    WCDB::Expression enumMin = EnumMin;\n    TestCaseAssertSQLEqual(enumMin, @\"-2147483648\");\n    WCDB::Expression enumMax = EnumMax;\n    TestCaseAssertSQLEqual(enumMax, @\"2147483647\");\n\n    WCDB::Expression enumClassMin = EnumClassType::Min;\n    TestCaseAssertSQLEqual(enumClassMin, @\"-2147483648\");\n    WCDB::Expression enumClassMax = EnumClassType::Max;\n    TestCaseAssertSQLEqual(enumClassMax, @\"2147483647\");\n\n    WCDB::LiteralValue numberMax = [NSNumber numberWithUnsignedLongLong:std::numeric_limits<uint64_t>::max()];\n    TestCaseAssertSQLEqual(numberMax, @\"18446744073709551615\");\n}\n\n@end\n"
  },
  {
    "path": "src/objc/tests/winq/FTSFunctionTests.mm",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"WINQAssertion.h\"\n\n@interface FTSFunctionTests : BaseTestCase\n\n@end\n\n@implementation FTSFunctionTests {\n    WCDB::Expression expression;\n}\n\n- (void)setUp\n{\n    [super setUp];\n    expression = WCDB::Column(@\"testColumn\");\n}\n\n- (void)test\n{\n    TestCaseAssertSQLEqual(WCDB::FTSFunction::offsets(expression), @\"offsets(testColumn)\");\n    TestCaseAssertSQLEqual(WCDB::FTSFunction::fts3Snippet(expression, \"testStart\", \"testEnd\", \"testEllipses\", 0, 0), @\"snippet(testColumn, 'testStart', 'testEnd', 'testEllipses', 0, 0)\");\n    TestCaseAssertSQLEqual(WCDB::FTSFunction::fts3Snippet(expression), @\"snippet(testColumn, '<b>', '</b>', '<b>...</b>', -1, -15)\");\n    TestCaseAssertSQLEqual(WCDB::FTSFunction::matchinfo(expression), @\"matchinfo(testColumn)\");\n\n    TestCaseAssertSQLEqual(WCDB::FTSFunction::bm25(expression), @\"bm25(testColumn)\");\n    TestCaseAssertSQLEqual(WCDB::FTSFunction::bm25(expression).arguments({ 5, 10 }), @\"bm25(testColumn, 5, 10)\");\n    TestCaseAssertSQLEqual(WCDB::FTSFunction::highlight(expression), @\"highlight(testColumn, 0, '<b>', '</b>')\");\n    TestCaseAssertSQLEqual(WCDB::FTSFunction::highlight(expression, 1, \"testStart\", \"testEnd\"), @\"highlight(testColumn, 1, 'testStart', 'testEnd')\");\n    TestCaseAssertSQLEqual(WCDB::FTSFunction::fts5Snippet(expression, 0, \"testStart\", \"testEnd\", \"testEllipses\", 0), @\"snippet(testColumn, 0, 'testStart', 'testEnd', 'testEllipses', 0)\");\n    TestCaseAssertSQLEqual(WCDB::FTSFunction::fts5Snippet(expression), @\"snippet(testColumn, 0, '<b>', '</b>', '<b>...</b>', 64)\");\n    TestCaseAssertSQLEqual(WCDB::FTSFunction::substringMatchInfo(expression, 1, \",;\"), @\"substring_match_info(testColumn, 1, ',;')\");\n}\n\n- (void)test_column_operable\n{\n    WCDB::Column column(@\"testColumn\");\n    TestCaseAssertSQLEqual(column.fts3Snippet(\"testStart\", \"testEnd\", \"testEllipses\", 0, 0), @\"snippet(testColumn, 'testStart', 'testEnd', 'testEllipses', 0, 0)\");\n    TestCaseAssertSQLEqual(column.fts3Snippet(), @\"snippet(testColumn, '<b>', '</b>', '<b>...</b>', -1, -15)\");\n    TestCaseAssertSQLEqual(column.offsets(), @\"offsets(testColumn)\");\n    TestCaseAssertSQLEqual(column.matchinfo(), @\"matchinfo(testColumn)\");\n\n    TestCaseAssertSQLEqual(column.bm25(), @\"bm25(testColumn)\");\n    TestCaseAssertSQLEqual(column.bm25().arguments({ 5, 10 }), @\"bm25(testColumn, 5, 10)\");\n    TestCaseAssertSQLEqual(column.highlight(), @\"highlight(testColumn, 0, '<b>', '</b>')\");\n    TestCaseAssertSQLEqual(column.highlight(1, \"testStart\", \"testEnd\"), @\"highlight(testColumn, 1, 'testStart', 'testEnd')\");\n    TestCaseAssertSQLEqual(column.fts5Snippet(0, \"testStart\", \"testEnd\", \"testEllipses\", 0), @\"snippet(testColumn, 0, 'testStart', 'testEnd', 'testEllipses', 0)\");\n    TestCaseAssertSQLEqual(column.fts5Snippet(), @\"snippet(testColumn, 0, '<b>', '</b>', '<b>...</b>', 64)\");\n    TestCaseAssertSQLEqual(column.substringMatchInfo(1, \",;\"), @\"substring_match_info(testColumn, 1, ',;')\");\n}\n\n- (void)test_expression_operable\n{\n    WCDB::Expression column = WCDB::Column(@\"testColumn\");\n    TestCaseAssertSQLEqual(column.fts3Snippet(\"testStart\", \"testEnd\", \"testEllipses\", 0, 0), @\"snippet(testColumn, 'testStart', 'testEnd', 'testEllipses', 0, 0)\");\n    TestCaseAssertSQLEqual(column.fts3Snippet(), @\"snippet(testColumn, '<b>', '</b>', '<b>...</b>', -1, -15)\");\n    TestCaseAssertSQLEqual(column.offsets(), @\"offsets(testColumn)\");\n    TestCaseAssertSQLEqual(column.matchinfo(), @\"matchinfo(testColumn)\");\n\n    TestCaseAssertSQLEqual(column.bm25(), @\"bm25(testColumn)\");\n    TestCaseAssertSQLEqual(column.bm25().arguments({ 5, 10 }), @\"bm25(testColumn, 5, 10)\");\n    TestCaseAssertSQLEqual(column.highlight(), @\"highlight(testColumn, 0, '<b>', '</b>')\");\n    TestCaseAssertSQLEqual(column.highlight(1, \"testStart\", \"testEnd\"), @\"highlight(testColumn, 1, 'testStart', 'testEnd')\");\n    TestCaseAssertSQLEqual(column.fts5Snippet(0, \"testStart\", \"testEnd\", \"testEllipses\", 0), @\"snippet(testColumn, 0, 'testStart', 'testEnd', 'testEllipses', 0)\");\n    TestCaseAssertSQLEqual(column.fts5Snippet(), @\"snippet(testColumn, 0, '<b>', '</b>', '<b>...</b>', 64)\");\n    TestCaseAssertSQLEqual(column.substringMatchInfo(1, \",;\"), @\"substring_match_info(testColumn, 1, ',;')\");\n}\n\n@end\n"
  },
  {
    "path": "src/objc/tests/winq/FilterTests.mm",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"WINQAssertion.h\"\n\n@interface FilterTests : BaseTestCase\n\n@end\n\n@implementation FilterTests {\n    WCDB::Expression condition;\n}\n\n- (void)setUp\n{\n    [super setUp];\n    condition = 1;\n}\n\n- (void)test_default_constructible\n{\n    WCDB::Filter constructible;\n    TestCaseAssertFalse(constructible.syntax().isValid());\n    TestCaseAssertIterateEqual(constructible, std::list<WCDB::Syntax::Identifier::Type>());\n    TestCaseAssertTrue(constructible.getDescription().empty());\n}\n\n- (void)test_get_type\n{\n    TestCaseAssertEqual(WCDB::Filter().getType(), WCDB::SQL::Type::Filter);\n    TestCaseAssertEqual(WCDB::Filter::type, WCDB::SQL::Type::Filter);\n}\n\n- (void)test_filter\n{\n    auto testingSQL = WCDB::Filter().where(condition);\n\n    auto testingTypes = { WCDB::SQL::Type::Filter, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"FILTER(WHERE 1)\");\n}\n\n@end\n"
  },
  {
    "path": "src/objc/tests/winq/ForeignKeyTests.mm",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"WINQAssertion.h\"\n\n@interface ForeignKeyTests : BaseTestCase\n\n@end\n\n@implementation ForeignKeyTests {\n    NSString* name;\n    WCDB::Column column1;\n    WCDB::Column column2;\n    WCDB::MatchType match;\n}\n\n- (void)setUp\n{\n    [super setUp];\n    name = @\"testForeignTable\";\n    column1 = WCDB::Column(@\"testColumn1\");\n    column2 = WCDB::Column(@\"testColumn2\");\n    match = WCDB::MatchType::Simple;\n}\n\n- (void)test_default_constructible\n{\n    WCDB::ForeignKey constructible;\n    TestCaseAssertFalse(constructible.syntax().isValid());\n    TestCaseAssertIterateEqual(constructible, std::list<WCDB::Syntax::Identifier::Type>());\n    TestCaseAssertTrue(constructible.getDescription().empty());\n}\n\n- (void)test_get_type\n{\n    TestCaseAssertEqual(WCDB::ForeignKey().getType(), WCDB::SQL::Type::ForeignKeyClause);\n    TestCaseAssertEqual(WCDB::ForeignKey::type, WCDB::SQL::Type::ForeignKeyClause);\n}\n\n- (void)test_foreign_table\n{\n    auto testingSQL = WCDB::ForeignKey().references(name).onDeleteSetNull().notDeferrableInitiallyDeferred();\n\n    auto testingTypes = { WCDB::SQL::Type::ForeignKeyClause };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"REFERENCES testForeignTable ON DELETE SET NULL NOT DEFERRABLE INITIALLY DEFERRED\");\n}\n\n- (void)test_foreign_table_with_column\n{\n    auto testingSQL = WCDB::ForeignKey().references(name).column(column1).onDeleteSetNull().notDeferrableInitiallyDeferred();\n\n    auto testingTypes = { WCDB::SQL::Type::ForeignKeyClause, WCDB::SQL::Type::Column };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"REFERENCES testForeignTable(testColumn1) ON DELETE SET NULL NOT DEFERRABLE INITIALLY DEFERRED\");\n}\n\n- (void)test_foreign_table_with_columns\n{\n    auto testingSQL = WCDB::ForeignKey().references(name).column(column1).column(column2).onDeleteSetNull().notDeferrableInitiallyDeferred();\n\n    auto testingTypes = { WCDB::SQL::Type::ForeignKeyClause, WCDB::SQL::Type::Column, WCDB::SQL::Type::Column };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"REFERENCES testForeignTable(testColumn1, testColumn2) ON DELETE SET NULL NOT DEFERRABLE INITIALLY DEFERRED\");\n}\n\n- (void)test_foreign_table_on_delete_set_default\n{\n    auto testingSQL = WCDB::ForeignKey().references(name).onDeleteSetDefault().notDeferrableInitiallyDeferred();\n\n    auto testingTypes = { WCDB::SQL::Type::ForeignKeyClause };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"REFERENCES testForeignTable ON DELETE SET DEFAULT NOT DEFERRABLE INITIALLY DEFERRED\");\n}\n\n- (void)test_foreign_table_on_delete_cascade\n{\n    auto testingSQL = WCDB::ForeignKey().references(name).onDeleteCascade().notDeferrableInitiallyDeferred();\n\n    auto testingTypes = { WCDB::SQL::Type::ForeignKeyClause };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"REFERENCES testForeignTable ON DELETE CASCADE NOT DEFERRABLE INITIALLY DEFERRED\");\n}\n\n- (void)test_foreign_table_on_delete_restrict\n{\n    auto testingSQL = WCDB::ForeignKey().references(name).onDeleteRestrict().notDeferrableInitiallyDeferred();\n\n    auto testingTypes = { WCDB::SQL::Type::ForeignKeyClause };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"REFERENCES testForeignTable ON DELETE RESTRICT NOT DEFERRABLE INITIALLY DEFERRED\");\n}\n\n- (void)test_foreign_table_on_delete_no_action\n{\n    auto testingSQL = WCDB::ForeignKey().references(name).onDeleteNoAction().notDeferrableInitiallyDeferred();\n\n    auto testingTypes = { WCDB::SQL::Type::ForeignKeyClause };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"REFERENCES testForeignTable ON DELETE NO ACTION NOT DEFERRABLE INITIALLY DEFERRED\");\n}\n\n- (void)test_foreign_table_on_update_set_null\n{\n    auto testingSQL = WCDB::ForeignKey().references(name).onUpdateSetNull().notDeferrableInitiallyDeferred();\n\n    auto testingTypes = { WCDB::SQL::Type::ForeignKeyClause };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"REFERENCES testForeignTable ON UPDATE SET NULL NOT DEFERRABLE INITIALLY DEFERRED\");\n}\n\n- (void)test_foreign_table_on_update_set_default\n{\n    auto testingSQL = WCDB::ForeignKey().references(name).onUpdateSetDefault().notDeferrableInitiallyDeferred();\n\n    auto testingTypes = { WCDB::SQL::Type::ForeignKeyClause };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"REFERENCES testForeignTable ON UPDATE SET DEFAULT NOT DEFERRABLE INITIALLY DEFERRED\");\n}\n\n- (void)test_foreign_table_on_update_cascade\n{\n    auto testingSQL = WCDB::ForeignKey().references(name).onUpdateCascade().notDeferrableInitiallyDeferred();\n\n    auto testingTypes = { WCDB::SQL::Type::ForeignKeyClause };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"REFERENCES testForeignTable ON UPDATE CASCADE NOT DEFERRABLE INITIALLY DEFERRED\");\n}\n\n- (void)test_foreign_table_on_update_restrict\n{\n    auto testingSQL = WCDB::ForeignKey().references(name).onUpdateRestrict().notDeferrableInitiallyDeferred();\n\n    auto testingTypes = { WCDB::SQL::Type::ForeignKeyClause };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"REFERENCES testForeignTable ON UPDATE RESTRICT NOT DEFERRABLE INITIALLY DEFERRED\");\n}\n\n- (void)test_foreign_table_on_update_no_action\n{\n    auto testingSQL = WCDB::ForeignKey().references(name).onUpdateNoAction().notDeferrableInitiallyDeferred();\n\n    auto testingTypes = { WCDB::SQL::Type::ForeignKeyClause };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"REFERENCES testForeignTable ON UPDATE NO ACTION NOT DEFERRABLE INITIALLY DEFERRED\");\n}\n\n- (void)test_foreign_table_match\n{\n    auto testingSQL = WCDB::ForeignKey().references(name).match(match).notDeferrableInitiallyDeferred();\n\n    auto testingTypes = { WCDB::SQL::Type::ForeignKeyClause };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"REFERENCES testForeignTable MATCH SIMPLE NOT DEFERRABLE INITIALLY DEFERRED\");\n}\n\n- (void)test_foreign_table_without_action\n{\n    auto testingSQL = WCDB::ForeignKey().references(name).notDeferrableInitiallyDeferred();\n\n    auto testingTypes = { WCDB::SQL::Type::ForeignKeyClause };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"REFERENCES testForeignTable NOT DEFERRABLE INITIALLY DEFERRED\");\n}\n\n- (void)test_foreign_table_with_mutiple_action\n{\n    auto testingSQL = WCDB::ForeignKey().references(name).onDeleteSetNull().onUpdateSetDefault().notDeferrableInitiallyDeferred();\n\n    auto testingTypes = { WCDB::SQL::Type::ForeignKeyClause };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"REFERENCES testForeignTable ON DELETE SET NULL ON UPDATE SET DEFAULT NOT DEFERRABLE INITIALLY DEFERRED\");\n}\n\n- (void)test_foreign_table_not_deferrable_initially_immediate\n{\n    auto testingSQL = WCDB::ForeignKey().references(name).onDeleteSetNull().notDeferrableInitiallyImmediate();\n\n    auto testingTypes = { WCDB::SQL::Type::ForeignKeyClause };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"REFERENCES testForeignTable ON DELETE SET NULL NOT DEFERRABLE INITIALLY IMMEDIATE\");\n}\n\n- (void)test_foreign_table_not_deferrable\n{\n    auto testingSQL = WCDB::ForeignKey().references(name).onDeleteSetNull().notDeferrable();\n\n    auto testingTypes = { WCDB::SQL::Type::ForeignKeyClause };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"REFERENCES testForeignTable ON DELETE SET NULL NOT DEFERRABLE\");\n}\n\n- (void)test_foreign_table_deferrable_initially_deferred\n{\n    auto testingSQL = WCDB::ForeignKey().references(name).onDeleteSetNull().deferrableInitiallyDeferred();\n\n    auto testingTypes = { WCDB::SQL::Type::ForeignKeyClause };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"REFERENCES testForeignTable ON DELETE SET NULL DEFERRABLE INITIALLY DEFERRED\");\n}\n\n- (void)test_foreign_table_deferrable_initially_immediate\n{\n    auto testingSQL = WCDB::ForeignKey().references(name).onDeleteSetNull().deferrableInitiallyImmediate();\n\n    auto testingTypes = { WCDB::SQL::Type::ForeignKeyClause };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"REFERENCES testForeignTable ON DELETE SET NULL DEFERRABLE INITIALLY IMMEDIATE\");\n}\n\n- (void)test_foreign_table_deferrable\n{\n    auto testingSQL = WCDB::ForeignKey().references(name).onDeleteSetNull().deferrable();\n\n    auto testingTypes = { WCDB::SQL::Type::ForeignKeyClause };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"REFERENCES testForeignTable ON DELETE SET NULL DEFERRABLE\");\n}\n\n@end\n"
  },
  {
    "path": "src/objc/tests/winq/FrameSpecTests.mm",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"WINQAssertion.h\"\n\n@interface FrameSpecTests : BaseTestCase\n\n@end\n\n@implementation FrameSpecTests {\n    WCDB::Expression expression1;\n    WCDB::Expression expression2;\n}\n\n- (void)setUp\n{\n    [super setUp];\n    expression1 = 1;\n    expression2 = 2;\n}\n\n- (void)test_default_constructible\n{\n    WCDB::FrameSpec constructible;\n    TestCaseAssertFalse(constructible.syntax().isValid());\n    TestCaseAssertIterateEqual(constructible, std::list<WCDB::Syntax::Identifier::Type>());\n    TestCaseAssertTrue(constructible.getDescription().empty());\n}\n\n- (void)test_get_type\n{\n    TestCaseAssertEqual(WCDB::FrameSpec().getType(), WCDB::SQL::Type::FrameSpec);\n    TestCaseAssertEqual(WCDB::FrameSpec::type, WCDB::SQL::Type::FrameSpec);\n}\n\n- (void)test_range\n{\n    auto testingSQL = WCDB::FrameSpec().range().unboundedPreceding();\n\n    auto testingTypes = { WCDB::SQL::Type::FrameSpec };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"RANGE UNBOUNDED PRECEDING\");\n}\n\n- (void)test_rows\n{\n    auto testingSQL = WCDB::FrameSpec().rows().unboundedPreceding();\n\n    auto testingTypes = { WCDB::SQL::Type::FrameSpec };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"ROWS UNBOUNDED PRECEDING\");\n}\n\n- (void)test_preceding\n{\n    auto testingSQL = WCDB::FrameSpec().range().preceding(expression1);\n\n    auto testingTypes = { WCDB::SQL::Type::FrameSpec, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"RANGE 1 PRECEDING\");\n}\n\n- (void)test_current_row\n{\n    auto testingSQL = WCDB::FrameSpec().range().currentRow();\n\n    auto testingTypes = { WCDB::SQL::Type::FrameSpec };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"RANGE CURRENT ROW\");\n}\n\n- (void)test_between_unbounded_preceding_and_preceding\n{\n    auto testingSQL = WCDB::FrameSpec().range().betweenUnboundedPreceding().andPreceding(expression2);\n\n    auto testingTypes = { WCDB::SQL::Type::FrameSpec, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"RANGE BETWEEN UNBOUNDED PRECEDING AND 2 PRECEDING\");\n}\n\n- (void)test_between_preceding_and_preceding\n{\n    auto testingSQL = WCDB::FrameSpec().range().betweenPreceding(expression1).andPreceding(expression2);\n\n    auto testingTypes = { WCDB::SQL::Type::FrameSpec, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"RANGE BETWEEN 1 PRECEDING AND 2 PRECEDING\");\n}\n\n- (void)test_between_current_row_and_preceding\n{\n    auto testingSQL = WCDB::FrameSpec().range().betweenCurrentRow().andPreceding(expression2);\n\n    auto testingTypes = { WCDB::SQL::Type::FrameSpec, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"RANGE BETWEEN CURRENT ROW AND 2 PRECEDING\");\n}\n\n- (void)test_between_following_and_preceding\n{\n    auto testingSQL = WCDB::FrameSpec().range().betweenFollowing(expression1).andPreceding(expression2);\n\n    auto testingTypes = { WCDB::SQL::Type::FrameSpec, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"RANGE BETWEEN 1 FOLLOWING AND 2 PRECEDING\");\n}\n\n- (void)test_between_unbounded_preceding_and_current_row\n{\n    auto testingSQL = WCDB::FrameSpec().range().betweenUnboundedPreceding().andCurrentRow();\n\n    auto testingTypes = { WCDB::SQL::Type::FrameSpec };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW\");\n}\n\n- (void)test_between_unbounded_preceding_and_following\n{\n    auto testingSQL = WCDB::FrameSpec().range().betweenUnboundedPreceding().andFollowing(expression2);\n\n    auto testingTypes = { WCDB::SQL::Type::FrameSpec, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"RANGE BETWEEN UNBOUNDED PRECEDING AND 2 FOLLOWING\");\n}\n\n- (void)test_between_unbounded_preceding_and_unbounded_preceding\n{\n    auto testingSQL = WCDB::FrameSpec().range().betweenUnboundedPreceding().andUnboundedFollowing();\n\n    auto testingTypes = { WCDB::SQL::Type::FrameSpec };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING\");\n}\n\n@end\n"
  },
  {
    "path": "src/objc/tests/winq/IndexedColumnTests.mm",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"WINQAssertion.h\"\n\n@interface IndexedColumnTests : BaseTestCase\n\n@end\n\n@implementation IndexedColumnTests {\n    WCDB::Column column;\n    WCDB::Expression expression;\n    NSString* collation;\n    WCDB::Order order;\n}\n\n- (void)setUp\n{\n    [super setUp];\n    column = WCDB::Column(@\"testColumn\");\n    expression = column;\n    collation = @\"BINARY\";\n    order = WCDB::Order::ASC;\n}\n\n- (void)test_default_constructible\n{\n    WCDB::IndexedColumn constructible;\n    TestCaseAssertFalse(constructible.syntax().isValid());\n    TestCaseAssertIterateEqual(constructible, std::list<WCDB::Syntax::Identifier::Type>());\n    TestCaseAssertTrue(constructible.getDescription().empty());\n}\n\n- (void)test_get_type\n{\n    TestCaseAssertEqual(WCDB::IndexedColumn().getType(), WCDB::SQL::Type::IndexedColumn);\n    TestCaseAssertEqual(WCDB::IndexedColumn::type, WCDB::SQL::Type::IndexedColumn);\n}\n\n- (void)test_column\n{\n    auto testingSQL = WCDB::IndexedColumn(column);\n\n    auto testingTypes = { WCDB::SQL::Type::IndexedColumn, WCDB::SQL::Type::Column };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"testColumn\");\n}\n\n- (void)test_expression\n{\n    auto testingSQL = WCDB::IndexedColumn(expression);\n\n    auto testingTypes = { WCDB::SQL::Type::IndexedColumn, WCDB::SQL::Type::Expression, WCDB::SQL::Type::Column };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"testColumn\");\n}\n\n- (void)test_collate\n{\n    auto testingSQL = WCDB::IndexedColumn(column).collate(collation);\n\n    auto testingTypes = { WCDB::SQL::Type::IndexedColumn, WCDB::SQL::Type::Column };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"testColumn COLLATE BINARY\");\n}\n\n- (void)test_order\n{\n    auto testingSQL = WCDB::IndexedColumn(column).order(order);\n\n    auto testingTypes = { WCDB::SQL::Type::IndexedColumn, WCDB::SQL::Type::Column };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"testColumn ASC\");\n}\n\n@end\n"
  },
  {
    "path": "src/objc/tests/winq/JoinConstraintTests.mm",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"WINQAssertion.h\"\n\n@interface JoinConstraintTests : BaseTestCase\n\n@end\n\n@implementation JoinConstraintTests {\n    WCDB::Expression expression;\n    WCDB::Columns columns;\n    WCDB::Column column1;\n    WCDB::Column column2;\n}\n\n- (void)setUp\n{\n    [super setUp];\n    expression = 1;\n    column1 = WCDB::Column(@\"testColumn1\");\n    column2 = WCDB::Column(@\"testColumn2\");\n    columns = {\n        column1,\n        column2,\n    };\n}\n\n- (void)test_default_constructible\n{\n    WCDB::JoinConstraint constructible;\n    TestCaseAssertFalse(constructible.syntax().isValid());\n    TestCaseAssertIterateEqual(constructible, std::list<WCDB::Syntax::Identifier::Type>());\n    TestCaseAssertTrue(constructible.getDescription().empty());\n}\n\n- (void)test_get_type\n{\n    TestCaseAssertEqual(WCDB::JoinConstraint().getType(), WCDB::SQL::Type::JoinConstraint);\n    TestCaseAssertEqual(WCDB::JoinConstraint::type, WCDB::SQL::Type::JoinConstraint);\n}\n\n- (void)test_on\n{\n    auto testingSQL = WCDB::JoinConstraint().on(expression);\n\n    auto testingTypes = { WCDB::SQL::Type::JoinConstraint, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"ON 1\");\n}\n\n- (void)test_using_column\n{\n    auto testingSQL = WCDB::JoinConstraint().using_().column(column1);\n\n    auto testingTypes = { WCDB::SQL::Type::JoinConstraint, WCDB::SQL::Type::Column };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"USING(testColumn1)\");\n}\n\n- (void)test_using_seperated_columns\n{\n    auto testingSQL = WCDB::JoinConstraint().using_().column(column1).column(column2);\n\n    auto testingTypes = { WCDB::SQL::Type::JoinConstraint, WCDB::SQL::Type::Column, WCDB::SQL::Type::Column };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"USING(testColumn1, testColumn2)\");\n}\n\n- (void)test_using_columns\n{\n    auto testingSQL = WCDB::JoinConstraint().using_().columns(columns);\n\n    auto testingTypes = { WCDB::SQL::Type::JoinConstraint, WCDB::SQL::Type::Column, WCDB::SQL::Type::Column };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"USING(testColumn1, testColumn2)\");\n}\n\n@end\n"
  },
  {
    "path": "src/objc/tests/winq/JoinTests.mm",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"WINQAssertion.h\"\n\n@interface JoinTests : BaseTestCase\n\n@end\n\n@implementation JoinTests {\n    WCDB::TableOrSubquery tableOrSubquery;\n    WCDB::TableOrSubquery tableOrSubquery1;\n    WCDB::TableOrSubquery tableOrSubquery2;\n}\n\n- (void)setUp\n{\n    [super setUp];\n    tableOrSubquery = @\"testTable\";\n    tableOrSubquery1 = @\"testTable1\";\n    tableOrSubquery2 = @\"testTable2\";\n}\n\n- (void)test_default_constructible\n{\n    WCDB::Join constructible;\n    TestCaseAssertFalse(constructible.syntax().isValid());\n    TestCaseAssertIterateEqual(constructible, std::list<WCDB::Syntax::Identifier::Type>());\n    TestCaseAssertTrue(constructible.getDescription().empty());\n}\n\n- (void)test_get_type\n{\n    TestCaseAssertEqual(WCDB::Join().getType(), WCDB::SQL::Type::JoinClause);\n    TestCaseAssertEqual(WCDB::Join::type, WCDB::SQL::Type::JoinClause);\n}\n\n- (void)test_join\n{\n    auto testingSQL = WCDB::Join().table(tableOrSubquery).join(tableOrSubquery1);\n\n    auto testingTypes = { WCDB::SQL::Type::JoinClause, WCDB::SQL::Type::TableOrSubquery, WCDB::SQL::Type::TableOrSubquery };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"testTable JOIN testTable1\");\n}\n\n- (void)test_join_with\n{\n    auto testingSQL = WCDB::Join().table(tableOrSubquery).with(tableOrSubquery1);\n\n    auto testingTypes = { WCDB::SQL::Type::JoinClause, WCDB::SQL::Type::TableOrSubquery, WCDB::SQL::Type::TableOrSubquery };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"testTable, testTable1\");\n}\n\n- (void)test_left_join\n{\n    auto testingSQL = WCDB::Join().table(tableOrSubquery).leftJoin(tableOrSubquery1);\n\n    auto testingTypes = { WCDB::SQL::Type::JoinClause, WCDB::SQL::Type::TableOrSubquery, WCDB::SQL::Type::TableOrSubquery };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"testTable LEFT JOIN testTable1\");\n}\n\n- (void)test_left_outer_join\n{\n    auto testingSQL = WCDB::Join().table(tableOrSubquery).leftOuterJoin(tableOrSubquery1);\n\n    auto testingTypes = { WCDB::SQL::Type::JoinClause, WCDB::SQL::Type::TableOrSubquery, WCDB::SQL::Type::TableOrSubquery };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"testTable LEFT OUTER JOIN testTable1\");\n}\n\n- (void)test_inner_join\n{\n    auto testingSQL = WCDB::Join().table(tableOrSubquery).innerJoin(tableOrSubquery1);\n\n    auto testingTypes = { WCDB::SQL::Type::JoinClause, WCDB::SQL::Type::TableOrSubquery, WCDB::SQL::Type::TableOrSubquery };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"testTable INNER JOIN testTable1\");\n}\n\n- (void)test_cross_join\n{\n    auto testingSQL = WCDB::Join().table(tableOrSubquery).crossJoin(tableOrSubquery1);\n\n    auto testingTypes = { WCDB::SQL::Type::JoinClause, WCDB::SQL::Type::TableOrSubquery, WCDB::SQL::Type::TableOrSubquery };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"testTable CROSS JOIN testTable1\");\n}\n\n- (void)test_natural_join\n{\n    auto testingSQL = WCDB::Join().table(tableOrSubquery).naturalJoin(tableOrSubquery1);\n\n    auto testingTypes = { WCDB::SQL::Type::JoinClause, WCDB::SQL::Type::TableOrSubquery, WCDB::SQL::Type::TableOrSubquery };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"testTable NATURAL JOIN testTable1\");\n}\n\n- (void)test_natural_left_join\n{\n    auto testingSQL = WCDB::Join().table(tableOrSubquery).naturalLeftJoin(tableOrSubquery1);\n\n    auto testingTypes = { WCDB::SQL::Type::JoinClause, WCDB::SQL::Type::TableOrSubquery, WCDB::SQL::Type::TableOrSubquery };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"testTable NATURAL LEFT JOIN testTable1\");\n}\n\n- (void)test_natural_left_outer_join\n{\n    auto testingSQL = WCDB::Join().table(tableOrSubquery).naturalLeftOuterJoin(tableOrSubquery1);\n\n    auto testingTypes = { WCDB::SQL::Type::JoinClause, WCDB::SQL::Type::TableOrSubquery, WCDB::SQL::Type::TableOrSubquery };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"testTable NATURAL LEFT OUTER JOIN testTable1\");\n}\n\n- (void)test_natural_inner_join\n{\n    auto testingSQL = WCDB::Join().table(tableOrSubquery).naturalInnerJoin(tableOrSubquery1);\n\n    auto testingTypes = { WCDB::SQL::Type::JoinClause, WCDB::SQL::Type::TableOrSubquery, WCDB::SQL::Type::TableOrSubquery };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"testTable NATURAL INNER JOIN testTable1\");\n}\n\n- (void)test_natural_cross_join\n{\n    auto testingSQL = WCDB::Join().table(tableOrSubquery).naturalCrossJoin(tableOrSubquery1);\n\n    auto testingTypes = { WCDB::SQL::Type::JoinClause, WCDB::SQL::Type::TableOrSubquery, WCDB::SQL::Type::TableOrSubquery };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"testTable NATURAL CROSS JOIN testTable1\");\n}\n\n- (void)test_join_with_constraint\n{\n    auto testingSQL = WCDB::Join().table(tableOrSubquery).join(tableOrSubquery1).on(1);\n\n    auto testingTypes = { WCDB::SQL::Type::JoinClause, WCDB::SQL::Type::TableOrSubquery, WCDB::SQL::Type::TableOrSubquery, WCDB::SQL::Type::JoinConstraint, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"testTable JOIN testTable1 ON 1\");\n}\n\n- (void)test_multiple_join\n{\n    auto testingSQL = WCDB::Join().table(tableOrSubquery).join(tableOrSubquery1).on(1).leftOuterJoin(tableOrSubquery2).on(2);\n\n    auto testingTypes = { WCDB::SQL::Type::JoinClause, WCDB::SQL::Type::TableOrSubquery, WCDB::SQL::Type::TableOrSubquery, WCDB::SQL::Type::JoinConstraint, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue, WCDB::SQL::Type::TableOrSubquery, WCDB::SQL::Type::JoinConstraint, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"testTable JOIN testTable1 ON 1 LEFT OUTER JOIN testTable2 ON 2\");\n}\n\n- (void)test_join_convertible\n{\n    WCDB::Join sql(WCDB::Join().table(@\"testTable\"));\n    NSString* expected = @\"(testTable)\";\n    TestCaseAssertWINQConvertible(WCDB::TableOrSubquery, sql, expected);\n    TestCaseAssertWINQConvertible(WCDB::TablesOrSubqueries, sql, expected);\n}\n\n@end\n"
  },
  {
    "path": "src/objc/tests/winq/LiteralValueTests.mm",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"WINQAssertion.h\"\n\n@interface LiteralValueTests : BaseTestCase\n\n@end\n\n@implementation LiteralValueTests\n\n- (void)setUp\n{\n    [super setUp];\n}\n\n- (void)test_default_constructible\n{\n    WCDB::LiteralValue constructible;\n    TestCaseAssertFalse(constructible.syntax().isValid());\n    TestCaseAssertIterateEqual(constructible, std::list<WCDB::Syntax::Identifier::Type>());\n    TestCaseAssertTrue(constructible.getDescription().empty());\n}\n\n- (void)test_get_type\n{\n    TestCaseAssertEqual(WCDB::LiteralValue().getType(), WCDB::SQL::Type::LiteralValue);\n    TestCaseAssertEqual(WCDB::LiteralValue::type, WCDB::SQL::Type::LiteralValue);\n}\n\n- (void)test_uint\n{\n    auto testingSQL = WCDB::LiteralValue(1);\n    auto testingTypes = { WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"1\");\n}\n\n- (void)test_int\n{\n    auto testingSQL = WCDB::LiteralValue(-1);\n    auto testingTypes = { WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"-1\");\n}\n\n- (void)test_ns_number\n{\n    auto testingSQL = WCDB::LiteralValue(@(1));\n    auto testingTypes = { WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"1\");\n}\n\n- (void)test_enum_ns\n{\n    auto testingSQL = WCDB::LiteralValue(EnumNSTypeZero);\n    auto testingTypes = { WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"0\");\n}\n\n- (void)test_option_ns\n{\n    auto testingSQL = WCDB::LiteralValue(OptionNSTypeZero);\n    auto testingTypes = { WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"0\");\n}\n\n- (void)test_enum\n{\n    auto testingSQL = WCDB::LiteralValue(EnumZero);\n    auto testingTypes = { WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"0\");\n}\n\n- (void)test_enum_class\n{\n    auto testingSQL = WCDB::LiteralValue(EnumClassType::Zero);\n    auto testingTypes = { WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"0\");\n}\n\n- (void)test_true\n{\n    auto testingSQL = WCDB::LiteralValue(true);\n    auto testingTypes = { WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"TRUE\");\n}\n\n- (void)test_false\n{\n    auto testingSQL = WCDB::LiteralValue(false);\n    auto testingTypes = { WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"FALSE\");\n}\n\n- (void)test_yes\n{\n    auto testingSQL = WCDB::LiteralValue(YES);\n    auto testingTypes = { WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"TRUE\");\n}\n\n- (void)test_no\n{\n    auto testingSQL = WCDB::LiteralValue(NO);\n    auto testingTypes = { WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"FALSE\");\n}\n\n- (void)test_float\n{\n    auto testingSQL = WCDB::LiteralValue(0.1f);\n    auto testingTypes = { WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, [NSString createPreciseStringFromDouble:0.1f]);\n}\n\n- (void)test_double\n{\n    double value = 0.1;\n    auto testingSQL = WCDB::LiteralValue(value);\n    auto testingTypes = { WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, [NSString createPreciseStringFromDouble:0.1]);\n}\n\n- (void)test_string\n{\n    auto testingSQL = WCDB::LiteralValue(\"test\");\n    auto testingTypes = { WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"'test'\");\n}\n\n- (void)test_cpp_string\n{\n    auto testingSQL = WCDB::LiteralValue(std::string(\"test\"));\n    auto testingTypes = { WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"'test'\");\n}\n\n- (void)test_ns_string\n{\n    auto testingSQL = WCDB::LiteralValue(@\"test\");\n    auto testingTypes = { WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"'test'\");\n}\n\n- (void)test_date\n{\n    NSDate* date = [[NSDate alloc] initWithTimeIntervalSince1970:100000];\n    auto testingSQL = WCDB::LiteralValue(date);\n    auto testingTypes = { WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"100000\");\n}\n\n- (void)test_null\n{\n    auto testingSQL = WCDB::LiteralValue(nullptr);\n    auto testingTypes = { WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"NULL\");\n}\n\n- (void)test_nil\n{\n    auto testingSQL = WCDB::LiteralValue(nil);\n    auto testingTypes = { WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"NULL\");\n}\n\n- (void)test_current_time\n{\n    auto testingSQL = WCDB::LiteralValue::currentTime();\n    auto testingTypes = { WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"CURRENT_TIME\");\n}\n\n- (void)test_current_date\n{\n    auto testingSQL = WCDB::LiteralValue::currentDate();\n    auto testingTypes = { WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"CURRENT_DATE\");\n}\n\n- (void)test_current_timestamp\n{\n    auto testingSQL = WCDB::LiteralValue::currentTimestamp();\n    auto testingTypes = { WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"CURRENT_TIMESTAMP\");\n}\n\n- (void)test_null_convertible\n{\n    std::nullptr_t sql = nullptr;\n    NSString* expected = @\"NULL\";\n    TestCaseAssertWINQConvertible(WCDB::LiteralValue, sql, expected);\n    TestCaseAssertWINQConvertible(WCDB::LiteralValues, sql, expected);\n    TestCaseAssertWINQConvertible(WCDB::Expression, sql, expected);\n    TestCaseAssertWINQConvertible(WCDB::Expressions, sql, expected);\n    TestCaseAssertWINQConvertible(WCDB::IndexedColumn, sql, expected);\n    TestCaseAssertWINQConvertible(WCDB::IndexedColumns, sql, expected);\n    TestCaseAssertWINQConvertible(WCDB::ResultColumn, sql, expected);\n    TestCaseAssertWINQConvertible(WCDB::ResultColumns, sql, expected);\n    TestCaseAssertWINQConvertible(WCDB::OrderingTerm, sql, expected);\n    TestCaseAssertWINQConvertible(WCDB::OrderingTerms, sql, expected);\n}\n\n- (void)test_nulls_convertible\n{\n    std::list<std::nullptr_t> sqls = { nullptr, nullptr };\n    NSString* expected = @\"NULL, NULL\";\n    TestCaseAssertWINQConvertible(WCDB::LiteralValues, sqls, expected);\n    TestCaseAssertWINQConvertible(WCDB::Expressions, sqls, expected);\n    TestCaseAssertWINQConvertible(WCDB::IndexedColumns, sqls, expected);\n    TestCaseAssertWINQConvertible(WCDB::ResultColumns, sqls, expected);\n    TestCaseAssertWINQConvertible(WCDB::OrderingTerms, sqls, expected);\n}\n\n- (void)test_int32_convertible\n{\n    int32_t sql = 1;\n    NSString* expected = @\"1\";\n    TestCaseAssertWINQConvertible(WCDB::LiteralValue, sql, expected);\n    TestCaseAssertWINQConvertible(WCDB::LiteralValues, sql, expected);\n    TestCaseAssertWINQConvertible(WCDB::Expression, sql, expected);\n    TestCaseAssertWINQConvertible(WCDB::Expressions, sql, expected);\n    TestCaseAssertWINQConvertible(WCDB::IndexedColumn, sql, expected);\n    TestCaseAssertWINQConvertible(WCDB::IndexedColumns, sql, expected);\n    TestCaseAssertWINQConvertible(WCDB::ResultColumn, sql, expected);\n    TestCaseAssertWINQConvertible(WCDB::ResultColumns, sql, expected);\n    TestCaseAssertWINQConvertible(WCDB::OrderingTerm, sql, expected);\n    TestCaseAssertWINQConvertible(WCDB::OrderingTerms, sql, expected);\n}\n\n- (void)test_int32s_convertible\n{\n    std::list<int32_t> sqls = { 1, 2 };\n    NSString* expected = @\"1, 2\";\n    TestCaseAssertWINQConvertible(WCDB::LiteralValues, sqls, expected);\n    TestCaseAssertWINQConvertible(WCDB::Expressions, sqls, expected);\n    TestCaseAssertWINQConvertible(WCDB::IndexedColumns, sqls, expected);\n    TestCaseAssertWINQConvertible(WCDB::ResultColumns, sqls, expected);\n    TestCaseAssertWINQConvertible(WCDB::OrderingTerms, sqls, expected);\n}\n\n- (void)test_int64_convertible\n{\n    int64_t sql = 1;\n    NSString* expected = @\"1\";\n    TestCaseAssertWINQConvertible(WCDB::LiteralValue, sql, expected);\n    TestCaseAssertWINQConvertible(WCDB::LiteralValues, sql, expected);\n    TestCaseAssertWINQConvertible(WCDB::Expression, sql, expected);\n    TestCaseAssertWINQConvertible(WCDB::Expressions, sql, expected);\n    TestCaseAssertWINQConvertible(WCDB::IndexedColumn, sql, expected);\n    TestCaseAssertWINQConvertible(WCDB::IndexedColumns, sql, expected);\n    TestCaseAssertWINQConvertible(WCDB::ResultColumn, sql, expected);\n    TestCaseAssertWINQConvertible(WCDB::ResultColumns, sql, expected);\n    TestCaseAssertWINQConvertible(WCDB::OrderingTerm, sql, expected);\n    TestCaseAssertWINQConvertible(WCDB::OrderingTerms, sql, expected);\n}\n\n- (void)test_int64s_convertible\n{\n    std::list<int64_t> sqls = { 1, 2 };\n    NSString* expected = @\"1, 2\";\n    TestCaseAssertWINQConvertible(WCDB::LiteralValues, sqls, expected);\n    TestCaseAssertWINQConvertible(WCDB::Expressions, sqls, expected);\n    TestCaseAssertWINQConvertible(WCDB::IndexedColumns, sqls, expected);\n    TestCaseAssertWINQConvertible(WCDB::ResultColumns, sqls, expected);\n    TestCaseAssertWINQConvertible(WCDB::OrderingTerms, sqls, expected);\n}\n\n- (void)test_uint32_convertible\n{\n    uint32_t sql = 1;\n    NSString* expected = @\"1\";\n    TestCaseAssertWINQConvertible(WCDB::LiteralValue, sql, expected);\n    TestCaseAssertWINQConvertible(WCDB::LiteralValues, sql, expected);\n    TestCaseAssertWINQConvertible(WCDB::Expression, sql, expected);\n    TestCaseAssertWINQConvertible(WCDB::Expressions, sql, expected);\n    TestCaseAssertWINQConvertible(WCDB::IndexedColumn, sql, expected);\n    TestCaseAssertWINQConvertible(WCDB::IndexedColumns, sql, expected);\n    TestCaseAssertWINQConvertible(WCDB::ResultColumn, sql, expected);\n    TestCaseAssertWINQConvertible(WCDB::ResultColumns, sql, expected);\n    TestCaseAssertWINQConvertible(WCDB::OrderingTerm, sql, expected);\n    TestCaseAssertWINQConvertible(WCDB::OrderingTerms, sql, expected);\n}\n\n- (void)test_uint32s_convertible\n{\n    std::list<uint32_t> sqls = { 1, 2 };\n    NSString* expected = @\"1, 2\";\n    TestCaseAssertWINQConvertible(WCDB::LiteralValues, sqls, expected);\n    TestCaseAssertWINQConvertible(WCDB::Expressions, sqls, expected);\n    TestCaseAssertWINQConvertible(WCDB::IndexedColumns, sqls, expected);\n    TestCaseAssertWINQConvertible(WCDB::ResultColumns, sqls, expected);\n    TestCaseAssertWINQConvertible(WCDB::OrderingTerms, sqls, expected);\n}\n\n- (void)test_uint64_convertible\n{\n    uint64_t sql = 1;\n    NSString* expected = @\"1\";\n    TestCaseAssertWINQConvertible(WCDB::LiteralValue, sql, expected);\n    TestCaseAssertWINQConvertible(WCDB::LiteralValues, sql, expected);\n    TestCaseAssertWINQConvertible(WCDB::Expression, sql, expected);\n    TestCaseAssertWINQConvertible(WCDB::Expressions, sql, expected);\n    TestCaseAssertWINQConvertible(WCDB::IndexedColumn, sql, expected);\n    TestCaseAssertWINQConvertible(WCDB::IndexedColumns, sql, expected);\n    TestCaseAssertWINQConvertible(WCDB::ResultColumn, sql, expected);\n    TestCaseAssertWINQConvertible(WCDB::ResultColumns, sql, expected);\n    TestCaseAssertWINQConvertible(WCDB::OrderingTerm, sql, expected);\n    TestCaseAssertWINQConvertible(WCDB::OrderingTerms, sql, expected);\n}\n\n- (void)test_uint64s_convertible\n{\n    std::list<uint64_t> sqls = { 1, 2 };\n    NSString* expected = @\"1, 2\";\n    TestCaseAssertWINQConvertible(WCDB::LiteralValues, sqls, expected);\n    TestCaseAssertWINQConvertible(WCDB::Expressions, sqls, expected);\n    TestCaseAssertWINQConvertible(WCDB::IndexedColumns, sqls, expected);\n    TestCaseAssertWINQConvertible(WCDB::ResultColumns, sqls, expected);\n    TestCaseAssertWINQConvertible(WCDB::OrderingTerms, sqls, expected);\n}\n\n- (void)test_float_convertible\n{\n    float sql = 1.1f;\n    NSString* expected = [NSString createPreciseStringFromDouble:sql];\n    TestCaseAssertWINQConvertible(WCDB::LiteralValue, sql, expected);\n    TestCaseAssertWINQConvertible(WCDB::LiteralValues, sql, expected);\n    TestCaseAssertWINQConvertible(WCDB::Expression, sql, expected);\n    TestCaseAssertWINQConvertible(WCDB::Expressions, sql, expected);\n    TestCaseAssertWINQConvertible(WCDB::IndexedColumn, sql, expected);\n    TestCaseAssertWINQConvertible(WCDB::IndexedColumns, sql, expected);\n    TestCaseAssertWINQConvertible(WCDB::ResultColumn, sql, expected);\n    TestCaseAssertWINQConvertible(WCDB::ResultColumns, sql, expected);\n    TestCaseAssertWINQConvertible(WCDB::OrderingTerm, sql, expected);\n    TestCaseAssertWINQConvertible(WCDB::OrderingTerms, sql, expected);\n}\n\n- (void)test_floats_convertible\n{\n    std::list<float> sqls = { 1.1f, 2.2f };\n    NSString* expected = [NSString stringWithFormat:@\"%@, %@\", [NSString createPreciseStringFromDouble:1.1f], [NSString createPreciseStringFromDouble:2.2f]];\n    ;\n    TestCaseAssertWINQConvertible(WCDB::LiteralValues, sqls, expected);\n    TestCaseAssertWINQConvertible(WCDB::Expressions, sqls, expected);\n    TestCaseAssertWINQConvertible(WCDB::IndexedColumns, sqls, expected);\n    TestCaseAssertWINQConvertible(WCDB::ResultColumns, sqls, expected);\n    TestCaseAssertWINQConvertible(WCDB::OrderingTerms, sqls, expected);\n}\n\n- (void)test_double_convertible\n{\n    double sql = 1.1;\n    NSString* expected = [NSString createPreciseStringFromDouble:sql];\n    TestCaseAssertWINQConvertible(WCDB::LiteralValue, sql, expected);\n    TestCaseAssertWINQConvertible(WCDB::LiteralValues, sql, expected);\n    TestCaseAssertWINQConvertible(WCDB::Expression, sql, expected);\n    TestCaseAssertWINQConvertible(WCDB::Expressions, sql, expected);\n    TestCaseAssertWINQConvertible(WCDB::IndexedColumn, sql, expected);\n    TestCaseAssertWINQConvertible(WCDB::IndexedColumns, sql, expected);\n    TestCaseAssertWINQConvertible(WCDB::ResultColumn, sql, expected);\n    TestCaseAssertWINQConvertible(WCDB::ResultColumns, sql, expected);\n    TestCaseAssertWINQConvertible(WCDB::OrderingTerm, sql, expected);\n    TestCaseAssertWINQConvertible(WCDB::OrderingTerms, sql, expected);\n\n    sql = [[NSDate date] timeIntervalSince1970];\n    expected = [NSString createPreciseStringFromDouble:sql];\n    TestCaseAssertWINQConvertible(WCDB::LiteralValue, sql, expected);\n    TestCaseAssertWINQConvertible(WCDB::LiteralValues, sql, expected);\n    TestCaseAssertWINQConvertible(WCDB::Expression, sql, expected);\n    TestCaseAssertWINQConvertible(WCDB::Expressions, sql, expected);\n    TestCaseAssertWINQConvertible(WCDB::IndexedColumn, sql, expected);\n    TestCaseAssertWINQConvertible(WCDB::IndexedColumns, sql, expected);\n    TestCaseAssertWINQConvertible(WCDB::ResultColumn, sql, expected);\n    TestCaseAssertWINQConvertible(WCDB::ResultColumns, sql, expected);\n    TestCaseAssertWINQConvertible(WCDB::OrderingTerm, sql, expected);\n    TestCaseAssertWINQConvertible(WCDB::OrderingTerms, sql, expected);\n}\n\n- (void)test_doubles_convertible\n{\n    std::list<double> sqls = { 1.1, 2.2 };\n    NSString* expected = [NSString stringWithFormat:@\"%@, %@\", [NSString createPreciseStringFromDouble:1.1], [NSString createPreciseStringFromDouble:2.2]];\n    TestCaseAssertWINQConvertible(WCDB::LiteralValues, sqls, expected);\n    TestCaseAssertWINQConvertible(WCDB::Expressions, sqls, expected);\n    TestCaseAssertWINQConvertible(WCDB::IndexedColumns, sqls, expected);\n    TestCaseAssertWINQConvertible(WCDB::ResultColumns, sqls, expected);\n    TestCaseAssertWINQConvertible(WCDB::OrderingTerms, sqls, expected);\n}\n\n- (void)test_bool_convertible\n{\n    bool sql = true;\n    NSString* expected = @\"TRUE\";\n    TestCaseAssertWINQConvertible(WCDB::LiteralValue, sql, expected);\n    TestCaseAssertWINQConvertible(WCDB::LiteralValues, sql, expected);\n    TestCaseAssertWINQConvertible(WCDB::Expression, sql, expected);\n    TestCaseAssertWINQConvertible(WCDB::Expressions, sql, expected);\n    TestCaseAssertWINQConvertible(WCDB::IndexedColumn, sql, expected);\n    TestCaseAssertWINQConvertible(WCDB::IndexedColumns, sql, expected);\n    TestCaseAssertWINQConvertible(WCDB::ResultColumn, sql, expected);\n    TestCaseAssertWINQConvertible(WCDB::ResultColumns, sql, expected);\n    TestCaseAssertWINQConvertible(WCDB::OrderingTerm, sql, expected);\n    TestCaseAssertWINQConvertible(WCDB::OrderingTerms, sql, expected);\n}\n\n- (void)test_bools_convertible\n{\n    std::list<bool> sqls = { true, false };\n    NSString* expected = @\"TRUE, FALSE\";\n    TestCaseAssertWINQConvertible(WCDB::LiteralValues, sqls, expected);\n    TestCaseAssertWINQConvertible(WCDB::Expressions, sqls, expected);\n    TestCaseAssertWINQConvertible(WCDB::IndexedColumns, sqls, expected);\n    TestCaseAssertWINQConvertible(WCDB::ResultColumns, sqls, expected);\n    TestCaseAssertWINQConvertible(WCDB::OrderingTerms, sqls, expected);\n}\n\n- (void)test_ns_number_convertible\n{\n    NSNumber* sql = @(1);\n    NSString* expected = @\"1\";\n    TestCaseAssertWINQConvertible(WCDB::LiteralValue, sql, expected);\n    TestCaseAssertWINQConvertible(WCDB::LiteralValues, sql, expected);\n    TestCaseAssertWINQConvertible(WCDB::Expression, sql, expected);\n    TestCaseAssertWINQConvertible(WCDB::Expressions, sql, expected);\n    TestCaseAssertWINQConvertible(WCDB::IndexedColumn, sql, expected);\n    TestCaseAssertWINQConvertible(WCDB::IndexedColumns, sql, expected);\n    TestCaseAssertWINQConvertible(WCDB::ResultColumn, sql, expected);\n    TestCaseAssertWINQConvertible(WCDB::ResultColumns, sql, expected);\n    TestCaseAssertWINQConvertible(WCDB::OrderingTerm, sql, expected);\n    TestCaseAssertWINQConvertible(WCDB::OrderingTerms, sql, expected);\n}\n\n- (void)test_ns_numbers_convertible\n{\n    std::list<NSNumber*> sqls = { @(1),\n                                  @(2) };\n    NSString* expected = @\"1, 2\";\n    TestCaseAssertWINQConvertible(WCDB::LiteralValues, sqls, expected);\n    TestCaseAssertWINQConvertible(WCDB::Expressions, sqls, expected);\n    TestCaseAssertWINQConvertible(WCDB::IndexedColumns, sqls, expected);\n    TestCaseAssertWINQConvertible(WCDB::ResultColumns, sqls, expected);\n    TestCaseAssertWINQConvertible(WCDB::OrderingTerms, sqls, expected);\n}\n\n- (void)test_const_char_p_convertible\n{\n    const char* sql = \"t\";\n\n    NSString* expected = @\"'t'\";\n    TestCaseAssertWINQConvertible(WCDB::LiteralValue, sql, expected);\n    TestCaseAssertWINQConvertible(WCDB::LiteralValues, sql, expected);\n    TestCaseAssertWINQConvertible(WCDB::Expression, sql, expected);\n    TestCaseAssertWINQConvertible(WCDB::Expressions, sql, expected);\n    TestCaseAssertWINQConvertible(WCDB::IndexedColumn, sql, expected);\n    TestCaseAssertWINQConvertible(WCDB::IndexedColumns, sql, expected);\n    TestCaseAssertWINQConvertible(WCDB::ResultColumn, sql, expected);\n    TestCaseAssertWINQConvertible(WCDB::ResultColumns, sql, expected);\n    TestCaseAssertWINQConvertible(WCDB::OrderingTerm, sql, expected);\n    TestCaseAssertWINQConvertible(WCDB::OrderingTerms, sql, expected);\n\n    TestCaseAssertWINQConvertible(WCDB::QualifiedTable, sql, @\"t\");\n    TestCaseAssertWINQConvertible(WCDB::TableOrSubquery, sql, @\"t\");\n    TestCaseAssertWINQConvertible(WCDB::TablesOrSubqueries, sql, @\"t\");\n}\n\n- (void)test_const_char_ps_convertible\n{\n    std::list<const char*> sqls = {\n        \"t1\",\n        \"t2\",\n    };\n\n    NSString* expected = @\"'t1', 't2'\";\n    TestCaseAssertWINQConvertible(WCDB::LiteralValues, sqls, expected);\n    TestCaseAssertWINQConvertible(WCDB::Expressions, sqls, expected);\n    TestCaseAssertWINQConvertible(WCDB::IndexedColumns, sqls, expected);\n    TestCaseAssertWINQConvertible(WCDB::ResultColumns, sqls, expected);\n    TestCaseAssertWINQConvertible(WCDB::OrderingTerms, sqls, expected);\n\n    TestCaseAssertWINQConvertible(WCDB::TablesOrSubqueries, sqls, @\"t1, t2\");\n}\n\n- (void)test_std_string_convertible\n{\n    std::string sql = \"t\";\n\n    NSString* expected = @\"'t'\";\n    TestCaseAssertWINQConvertible(WCDB::LiteralValue, sql, expected);\n    TestCaseAssertWINQConvertible(WCDB::LiteralValues, sql, expected);\n    TestCaseAssertWINQConvertible(WCDB::Expression, sql, expected);\n    TestCaseAssertWINQConvertible(WCDB::Expressions, sql, expected);\n    TestCaseAssertWINQConvertible(WCDB::IndexedColumn, sql, expected);\n    TestCaseAssertWINQConvertible(WCDB::IndexedColumns, sql, expected);\n    TestCaseAssertWINQConvertible(WCDB::ResultColumn, sql, expected);\n    TestCaseAssertWINQConvertible(WCDB::ResultColumns, sql, expected);\n    TestCaseAssertWINQConvertible(WCDB::OrderingTerm, sql, expected);\n    TestCaseAssertWINQConvertible(WCDB::OrderingTerms, sql, expected);\n\n    TestCaseAssertWINQConvertible(WCDB::QualifiedTable, sql, @\"t\");\n    TestCaseAssertWINQConvertible(WCDB::TableOrSubquery, sql, @\"t\");\n    TestCaseAssertWINQConvertible(WCDB::TablesOrSubqueries, sql, @\"t\");\n}\n\n- (void)test_std_strings_convertible\n{\n    std::list<std::string> sqls = {\n        \"t1\",\n        \"t2\",\n    };\n\n    NSString* expected = @\"'t1', 't2'\";\n    TestCaseAssertWINQConvertible(WCDB::LiteralValues, sqls, expected);\n    TestCaseAssertWINQConvertible(WCDB::Expressions, sqls, expected);\n    TestCaseAssertWINQConvertible(WCDB::IndexedColumns, sqls, expected);\n    TestCaseAssertWINQConvertible(WCDB::ResultColumns, sqls, expected);\n    TestCaseAssertWINQConvertible(WCDB::OrderingTerms, sqls, expected);\n\n    TestCaseAssertWINQConvertible(WCDB::TablesOrSubqueries, sqls, @\"t1, t2\");\n}\n\n- (void)test_ns_string_convertible\n{\n    NSString* sql = @\"t\";\n\n    NSString* expected = @\"'t'\";\n    TestCaseAssertWINQConvertible(WCDB::LiteralValue, sql, expected);\n    TestCaseAssertWINQConvertible(WCDB::LiteralValues, sql, expected);\n    TestCaseAssertWINQConvertible(WCDB::Expression, sql, expected);\n    TestCaseAssertWINQConvertible(WCDB::Expressions, sql, expected);\n    TestCaseAssertWINQConvertible(WCDB::IndexedColumn, sql, expected);\n    TestCaseAssertWINQConvertible(WCDB::IndexedColumns, sql, expected);\n    TestCaseAssertWINQConvertible(WCDB::ResultColumn, sql, expected);\n    TestCaseAssertWINQConvertible(WCDB::ResultColumns, sql, expected);\n    TestCaseAssertWINQConvertible(WCDB::OrderingTerm, sql, expected);\n    TestCaseAssertWINQConvertible(WCDB::OrderingTerms, sql, expected);\n\n    TestCaseAssertWINQConvertible(WCDB::QualifiedTable, sql, @\"t\");\n    TestCaseAssertWINQConvertible(WCDB::TableOrSubquery, sql, @\"t\");\n    TestCaseAssertWINQConvertible(WCDB::TablesOrSubqueries, sql, @\"t\");\n}\n\n- (void)test_ns_strings_convertible\n{\n    std::list<NSString*> sqls = {\n        @\"t1\",\n        @\"t2\",\n    };\n\n    NSString* expected = @\"'t1', 't2'\";\n    TestCaseAssertWINQConvertible(WCDB::LiteralValues, sqls, expected);\n    TestCaseAssertWINQConvertible(WCDB::Expressions, sqls, expected);\n    TestCaseAssertWINQConvertible(WCDB::IndexedColumns, sqls, expected);\n    TestCaseAssertWINQConvertible(WCDB::ResultColumns, sqls, expected);\n    TestCaseAssertWINQConvertible(WCDB::OrderingTerms, sqls, expected);\n\n    TestCaseAssertWINQConvertible(WCDB::TablesOrSubqueries, sqls, @\"t1, t2\");\n}\n\n- (void)test_literal_value_convertible\n{\n    WCDB::LiteralValue sql = 1;\n    NSString* expected = @\"1\";\n    TestCaseAssertWINQConvertible(WCDB::LiteralValue, sql, expected);\n    TestCaseAssertWINQConvertible(WCDB::LiteralValues, sql, expected);\n    TestCaseAssertWINQConvertible(WCDB::Expression, sql, expected);\n    TestCaseAssertWINQConvertible(WCDB::Expressions, sql, expected);\n    TestCaseAssertWINQConvertible(WCDB::IndexedColumn, sql, expected);\n    TestCaseAssertWINQConvertible(WCDB::IndexedColumns, sql, expected);\n    TestCaseAssertWINQConvertible(WCDB::ResultColumn, sql, expected);\n    TestCaseAssertWINQConvertible(WCDB::ResultColumns, sql, expected);\n    TestCaseAssertWINQConvertible(WCDB::OrderingTerm, sql, expected);\n    TestCaseAssertWINQConvertible(WCDB::OrderingTerms, sql, expected);\n}\n\n- (void)test_literal_values_convertible\n{\n    WCDB::LiteralValues sqls = {\n        (bool) true,\n        (int32_t) 1,\n        (std::nullptr_t) nullptr,\n        (int64_t) 2,\n        (NSNumber*) @(3),\n        (float) 1.1,\n        (double) 2.2,\n        (const char*) \"t1\",\n        (std::string) \"t2\",\n        (NSString*) @\"t3\",\n    };\n    NSString* expected = [NSString stringWithFormat:@\"TRUE, 1, NULL, 2, 3, %@, %@, 't1', 't2', 't3'\", [NSString createPreciseStringFromDouble:1.1f], [NSString createPreciseStringFromDouble:2.2]];\n    TestCaseAssertWINQConvertible(WCDB::LiteralValues, sqls, expected);\n    TestCaseAssertWINQConvertible(WCDB::Expressions, sqls, expected);\n    TestCaseAssertWINQConvertible(WCDB::IndexedColumns, sqls, expected);\n    TestCaseAssertWINQConvertible(WCDB::ResultColumns, sqls, expected);\n    TestCaseAssertWINQConvertible(WCDB::OrderingTerms, sqls, expected);\n}\n\n- (void)test_anti_injection\n{\n    NSString* injection = @\";'DROP TABLE testInjection;--\";\n    TestCaseAssertSQLEqual(WCDB::StatementSelect().select(injection).where(1), @\"SELECT ';''DROP TABLE testInjection;--' WHERE 1\");\n}\n\n- (void)test_boundary\n{\n    WCDB::LiteralValue int64Min = std::numeric_limits<int64_t>::min();\n    TestCaseAssertSQLEqual(int64Min, @\"-9223372036854775808\");\n    WCDB::LiteralValue int64Max = std::numeric_limits<int64_t>::max();\n    TestCaseAssertSQLEqual(int64Max, @\"9223372036854775807\");\n\n    WCDB::LiteralValue uint64Min = std::numeric_limits<uint64_t>::min();\n    TestCaseAssertSQLEqual(uint64Min, @\"0\");\n    WCDB::LiteralValue uint64Max = std::numeric_limits<uint64_t>::max();\n    TestCaseAssertSQLEqual(uint64Max, @\"18446744073709551615\");\n\n    WCDB::LiteralValue enumNSMin = EnumNSTypeMin;\n    TestCaseAssertSQLEqual(enumNSMin, @\"-9223372036854775808\");\n    WCDB::LiteralValue enumNSMax = EnumNSTypeMax;\n    TestCaseAssertSQLEqual(enumNSMax, @\"9223372036854775807\");\n\n    WCDB::LiteralValue optionNSMin = OptionNSTypeMin;\n    TestCaseAssertSQLEqual(optionNSMin, @\"-9223372036854775808\");\n    WCDB::LiteralValue optionNSMax = OptionNSTypeMax;\n    TestCaseAssertSQLEqual(optionNSMax, @\"9223372036854775807\");\n\n    WCDB::LiteralValue enumMin = EnumMin;\n    TestCaseAssertSQLEqual(enumMin, @\"-2147483648\");\n    WCDB::LiteralValue enumMax = EnumMax;\n    TestCaseAssertSQLEqual(enumMax, @\"2147483647\");\n\n    WCDB::LiteralValue enumClassMin = EnumClassType::Min;\n    TestCaseAssertSQLEqual(enumClassMin, @\"-2147483648\");\n    WCDB::LiteralValue enumClassMax = EnumClassType::Max;\n    TestCaseAssertSQLEqual(enumClassMax, @\"2147483647\");\n\n    WCDB::LiteralValue numberMax = [NSNumber numberWithUnsignedLongLong:std::numeric_limits<uint64_t>::max()];\n    TestCaseAssertSQLEqual(numberMax, @\"18446744073709551615\");\n}\n\n@end\n"
  },
  {
    "path": "src/objc/tests/winq/OrderTests.mm",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"WINQAssertion.h\"\n\n@interface OrderTests : BaseTestCase\n\n@end\n\n@implementation OrderTests {\n    WCDB::Column column;\n}\n\n- (void)setUp\n{\n    [super setUp];\n    column = WCDB::Column(@\"testColumn\");\n}\n\n- (void)test_default_constructible\n{\n    WCDB::Order constructible;\n    WCDB_UNUSED(constructible);\n}\n\n- (void)test_asc\n{\n    auto testingSQL = WCDB::IndexedColumn(column).order(WCDB::Order::ASC);\n    TestCaseAssertSQLEqual(testingSQL, @\"testColumn ASC\");\n}\n\n- (void)test_desc\n{\n    auto testingSQL = WCDB::IndexedColumn(column).order(WCDB::Order::DESC);\n    TestCaseAssertSQLEqual(testingSQL, @\"testColumn DESC\");\n}\n\n@end\n"
  },
  {
    "path": "src/objc/tests/winq/OrderingTermTests.mm",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"WINQAssertion.h\"\n\n@interface OrderingTermTests : BaseTestCase\n\n@end\n\n@implementation OrderingTermTests {\n    WCDB::Expression expression;\n    NSString* collation;\n}\n\n- (void)setUp\n{\n    [super setUp];\n    expression = WCDB::Column(@\"testColumn\");\n    collation = @\"BINARY\";\n}\n\n- (void)test_default_constructible\n{\n    WCDB::OrderingTerm constructible;\n    TestCaseAssertFalse(constructible.syntax().isValid());\n    TestCaseAssertIterateEqual(constructible, std::list<WCDB::Syntax::Identifier::Type>());\n    TestCaseAssertTrue(constructible.getDescription().empty());\n}\n\n- (void)test_get_type\n{\n    TestCaseAssertEqual(WCDB::OrderingTerm().getType(), WCDB::SQL::Type::OrderingTerm);\n    TestCaseAssertEqual(WCDB::OrderingTerm::type, WCDB::SQL::Type::OrderingTerm);\n}\n\n- (void)test\n{\n    auto testingSQL = WCDB::OrderingTerm(expression);\n\n    auto testingTypes = { WCDB::SQL::Type::OrderingTerm, WCDB::SQL::Type::Expression, WCDB::SQL::Type::Column };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"testColumn\");\n}\n\n- (void)test_with_collation\n{\n    auto testingSQL = WCDB::OrderingTerm(expression).collate(collation);\n\n    auto testingTypes = { WCDB::SQL::Type::OrderingTerm, WCDB::SQL::Type::Expression, WCDB::SQL::Type::Column };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"testColumn COLLATE BINARY\");\n}\n\n- (void)test_with_order\n{\n    auto testingSQL = WCDB::OrderingTerm(expression).order(WCDB::Order::ASC);\n\n    auto testingTypes = { WCDB::SQL::Type::OrderingTerm, WCDB::SQL::Type::Expression, WCDB::SQL::Type::Column };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"testColumn ASC\");\n}\n\n@end\n"
  },
  {
    "path": "src/objc/tests/winq/PragmaTests.mm",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"WINQAssertion.h\"\n\n@interface PragmaTests : BaseTestCase\n\n@end\n\n@implementation PragmaTests {\n}\n\n- (void)setUp\n{\n    [super setUp];\n}\n\n- (void)test_default_constructible\n{\n    WCDB::Pragma constructible;\n    TestCaseAssertFalse(constructible.syntax().isValid());\n    TestCaseAssertIterateEqual(constructible, std::list<WCDB::Syntax::Identifier::Type>());\n    TestCaseAssertTrue(constructible.getDescription().empty());\n}\n\n- (void)test_get_type\n{\n    TestCaseAssertEqual(WCDB::Pragma().getType(), WCDB::SQL::Type::Pragma);\n    TestCaseAssertEqual(WCDB::Pragma::type, WCDB::SQL::Type::Pragma);\n}\n\n- (void)test\n{\n    auto testingSQL = WCDB::Pragma(@\"testPragma\");\n    auto testingTypes = { WCDB::SQL::Type::Pragma };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"testPragma\");\n}\n\n- (void)test_builtin\n{\n    TestCaseAssertSQLEqual(WCDB::Pragma::applicationId(), @\"application_id\");\n    TestCaseAssertSQLEqual(WCDB::Pragma::autoVacuum(), @\"auto_vacuum\");\n    TestCaseAssertSQLEqual(WCDB::Pragma::automaticIndex(), @\"automatic_index\");\n    TestCaseAssertSQLEqual(WCDB::Pragma::busyTimeout(), @\"busy_timeout\");\n    TestCaseAssertSQLEqual(WCDB::Pragma::cacheSize(), @\"cache_size\");\n    TestCaseAssertSQLEqual(WCDB::Pragma::cacheSpill(), @\"cache_spill\");\n    TestCaseAssertSQLEqual(WCDB::Pragma::caseSensitiveLike(), @\"case_sensitive_like\");\n    TestCaseAssertSQLEqual(WCDB::Pragma::cellSizeCheck(), @\"cell_size_check\");\n    TestCaseAssertSQLEqual(WCDB::Pragma::checkpointFullfsync(), @\"checkpoint_fullfsync\");\n    TestCaseAssertSQLEqual(WCDB::Pragma::cipher(), @\"cipher\");\n    TestCaseAssertSQLEqual(WCDB::Pragma::cipherAddRandom(), @\"cipher_add_random\");\n    TestCaseAssertSQLEqual(WCDB::Pragma::cipherDefaultKdfIter(), @\"cipher_default_kdf_iter\");\n    TestCaseAssertSQLEqual(WCDB::Pragma::cipherDefaultPageSize(), @\"cipher_default_page_size\");\n    TestCaseAssertSQLEqual(WCDB::Pragma::cipherDefaultUseHmac(), @\"cipher_default_use_hmac\");\n    TestCaseAssertSQLEqual(WCDB::Pragma::cipherMigrate(), @\"cipher_migrate\");\n    TestCaseAssertSQLEqual(WCDB::Pragma::cipherProfile(), @\"cipher_profile\");\n    TestCaseAssertSQLEqual(WCDB::Pragma::cipherProvider(), @\"cipher_provider\");\n    TestCaseAssertSQLEqual(WCDB::Pragma::cipherProviderVersion(), @\"cipher_provider_version\");\n    TestCaseAssertSQLEqual(WCDB::Pragma::cipherUseHmac(), @\"cipher_use_hmac\");\n    TestCaseAssertSQLEqual(WCDB::Pragma::cipherVersion(), @\"cipher_version\");\n    TestCaseAssertSQLEqual(WCDB::Pragma::cipherPageSize(), @\"cipher_page_size\");\n    TestCaseAssertSQLEqual(WCDB::Pragma::collationList(), @\"collation_list\");\n    TestCaseAssertSQLEqual(WCDB::Pragma::dataVersion(), @\"data_version\");\n    TestCaseAssertSQLEqual(WCDB::Pragma::databaseList(), @\"database_list\");\n    TestCaseAssertSQLEqual(WCDB::Pragma::deferForeignKeys(), @\"defer_foreign_keys\");\n    TestCaseAssertSQLEqual(WCDB::Pragma::encoding(), @\"encoding\");\n    TestCaseAssertSQLEqual(WCDB::Pragma::foreignKeyCheck(), @\"foreign_key_check\");\n    TestCaseAssertSQLEqual(WCDB::Pragma::foreignKeyList(), @\"foreign_key_list\");\n    TestCaseAssertSQLEqual(WCDB::Pragma::foreignKeys(), @\"foreign_keys\");\n    TestCaseAssertSQLEqual(WCDB::Pragma::freelistCount(), @\"freelist_count\");\n    TestCaseAssertSQLEqual(WCDB::Pragma::fullfsync(), @\"fullfsync\");\n    TestCaseAssertSQLEqual(WCDB::Pragma::functionList(), @\"function_list\");\n    TestCaseAssertSQLEqual(WCDB::Pragma::ignoreCheckConstraints(), @\"ignore_check_constraints\");\n    TestCaseAssertSQLEqual(WCDB::Pragma::incrementalVacuum(), @\"incremental_vacuum\");\n    TestCaseAssertSQLEqual(WCDB::Pragma::indexInfo(), @\"index_info\");\n    TestCaseAssertSQLEqual(WCDB::Pragma::indexList(), @\"index_list\");\n    TestCaseAssertSQLEqual(WCDB::Pragma::indexXinfo(), @\"index_xinfo\");\n    TestCaseAssertSQLEqual(WCDB::Pragma::integrityCheck(), @\"integrity_check\");\n    TestCaseAssertSQLEqual(WCDB::Pragma::journalMode(), @\"journal_mode\");\n    TestCaseAssertSQLEqual(WCDB::Pragma::journalSizeLimit(), @\"journal_size_limit\");\n    TestCaseAssertSQLEqual(WCDB::Pragma::key(), @\"key\");\n    TestCaseAssertSQLEqual(WCDB::Pragma::kdfIter(), @\"kdf_iter\");\n    TestCaseAssertSQLEqual(WCDB::Pragma::legacyFileFormat(), @\"legacy_file_format\");\n    TestCaseAssertSQLEqual(WCDB::Pragma::lockingMode(), @\"locking_mode\");\n    TestCaseAssertSQLEqual(WCDB::Pragma::maxPageCount(), @\"max_page_count\");\n    TestCaseAssertSQLEqual(WCDB::Pragma::mmapSize(), @\"mmap_size\");\n    TestCaseAssertSQLEqual(WCDB::Pragma::moduleList(), @\"module_list\");\n    TestCaseAssertSQLEqual(WCDB::Pragma::optimize(), @\"optimize\");\n    TestCaseAssertSQLEqual(WCDB::Pragma::pageCount(), @\"page_count\");\n    TestCaseAssertSQLEqual(WCDB::Pragma::pageSize(), @\"page_size\");\n    TestCaseAssertSQLEqual(WCDB::Pragma::parserTrace(), @\"parser_trace\");\n    TestCaseAssertSQLEqual(WCDB::Pragma::pragmaList(), @\"pragma_list\");\n    TestCaseAssertSQLEqual(WCDB::Pragma::queryOnly(), @\"query_only\");\n    TestCaseAssertSQLEqual(WCDB::Pragma::quickCheck(), @\"quick_check\");\n    TestCaseAssertSQLEqual(WCDB::Pragma::readUncommitted(), @\"read_uncommitted\");\n    TestCaseAssertSQLEqual(WCDB::Pragma::recursiveTriggers(), @\"recursive_triggers\");\n    TestCaseAssertSQLEqual(WCDB::Pragma::rekey(), @\"rekey\");\n    TestCaseAssertSQLEqual(WCDB::Pragma::reverseUnorderedSelects(), @\"reverse_unordered_selects\");\n    TestCaseAssertSQLEqual(WCDB::Pragma::schemaVersion(), @\"schema_version\");\n    TestCaseAssertSQLEqual(WCDB::Pragma::secureDelete(), @\"secure_delete\");\n    TestCaseAssertSQLEqual(WCDB::Pragma::shrinkMemory(), @\"shrink_memory\");\n    TestCaseAssertSQLEqual(WCDB::Pragma::softHeapLimit(), @\"soft_heap_limit\");\n    TestCaseAssertSQLEqual(WCDB::Pragma::stats(), @\"stats\");\n    TestCaseAssertSQLEqual(WCDB::Pragma::synchronous(), @\"synchronous\");\n    TestCaseAssertSQLEqual(WCDB::Pragma::tableInfo(), @\"table_info\");\n    TestCaseAssertSQLEqual(WCDB::Pragma::tempStore(), @\"temp_store\");\n    TestCaseAssertSQLEqual(WCDB::Pragma::threads(), @\"threads\");\n    TestCaseAssertSQLEqual(WCDB::Pragma::userVersion(), @\"user_version\");\n    TestCaseAssertSQLEqual(WCDB::Pragma::vdbeAddoptrace(), @\"vdbe_addoptrace\");\n    TestCaseAssertSQLEqual(WCDB::Pragma::vdbeDebug(), @\"vdbe_debug\");\n    TestCaseAssertSQLEqual(WCDB::Pragma::vdbeListing(), @\"vdbe_listing\");\n    TestCaseAssertSQLEqual(WCDB::Pragma::vdbeTrace(), @\"vdbe_trace\");\n    TestCaseAssertSQLEqual(WCDB::Pragma::walAutocheckpoint(), @\"wal_autocheckpoint\");\n    TestCaseAssertSQLEqual(WCDB::Pragma::walCheckpoint(), @\"wal_checkpoint\");\n    TestCaseAssertSQLEqual(WCDB::Pragma::writableSchema(), @\"writable_schema\");\n}\n\n@end\n"
  },
  {
    "path": "src/objc/tests/winq/QualifiedTableTests.mm",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"WINQAssertion.h\"\n\n@interface QualifiedTableTests : BaseTestCase\n\n@end\n\n@implementation QualifiedTableTests {\n    WCDB::Schema schema;\n    NSString* table;\n    NSString* alias;\n    NSString* index;\n}\n\n- (void)setUp\n{\n    [super setUp];\n    schema = @\"testSchema\";\n    table = @\"testTable\";\n    alias = @\"testAlias\";\n    index = @\"testIndex\";\n}\n\n- (void)test_default_constructible\n{\n    WCDB::QualifiedTable constructible;\n    TestCaseAssertFalse(constructible.syntax().isValid());\n    TestCaseAssertIterateEqual(constructible, std::list<WCDB::Syntax::Identifier::Type>());\n    TestCaseAssertTrue(constructible.getDescription().empty());\n}\n\n- (void)test_get_type\n{\n    TestCaseAssertEqual(WCDB::QualifiedTable().getType(), WCDB::SQL::Type::QualifiedTableName);\n    TestCaseAssertEqual(WCDB::QualifiedTable::type, WCDB::SQL::Type::QualifiedTableName);\n}\n\n- (void)test_qualified_table\n{\n    auto testingSQL = WCDB::QualifiedTable(table).schema(schema);\n\n    auto testingTypes = { WCDB::SQL::Type::QualifiedTableName, WCDB::SQL::Type::Schema };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"testSchema.testTable\");\n}\n\n- (void)test_qualified_table_without_schema\n{\n    auto testingSQL = WCDB::QualifiedTable(table);\n\n    auto testingTypes = { WCDB::SQL::Type::QualifiedTableName };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"testTable\");\n}\n\n- (void)test_qualified_table_with_alias\n{\n    auto testingSQL = WCDB::QualifiedTable(table).schema(schema).as(alias);\n\n    auto testingTypes = { WCDB::SQL::Type::QualifiedTableName, WCDB::SQL::Type::Schema };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"testSchema.testTable AS testAlias\");\n}\n\n- (void)test_qualified_table_with_indexed\n{\n    auto testingSQL = WCDB::QualifiedTable(table).schema(schema).indexed(index);\n\n    auto testingTypes = { WCDB::SQL::Type::QualifiedTableName, WCDB::SQL::Type::Schema };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"testSchema.testTable INDEXED BY testIndex\");\n}\n\n- (void)test_qualified_table_without_index\n{\n    auto testingSQL = WCDB::QualifiedTable(table).schema(schema).notIndexed();\n\n    auto testingTypes = { WCDB::SQL::Type::QualifiedTableName, WCDB::SQL::Type::Schema };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"testSchema.testTable NOT INDEXED\");\n}\n\n@end\n"
  },
  {
    "path": "src/objc/tests/winq/RaiseFunctionTests.mm",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"WINQAssertion.h\"\n\n@interface RaiseFunctionTests : BaseTestCase\n\n@end\n\n@implementation RaiseFunctionTests {\n    NSString* errorMessage;\n}\n\n- (void)setUp\n{\n    [super setUp];\n    errorMessage = @\"testErrorMessage\";\n}\n\n- (void)test_default_constructible\n{\n    WCDB::RaiseFunction constructible;\n    TestCaseAssertFalse(constructible.syntax().isValid());\n    TestCaseAssertIterateEqual(constructible, std::list<WCDB::Syntax::Identifier::Type>());\n    TestCaseAssertTrue(constructible.getDescription().empty());\n}\n\n- (void)test_get_type\n{\n    TestCaseAssertEqual(WCDB::RaiseFunction().getType(), WCDB::SQL::Type::RaiseFunction);\n    TestCaseAssertEqual(WCDB::RaiseFunction::type, WCDB::SQL::Type::RaiseFunction);\n}\n\n- (void)test_ignore\n{\n    auto testingSQL = WCDB::RaiseFunction().ignore();\n\n    auto testingTypes = { WCDB::SQL::Type::RaiseFunction };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"RAISE(IGNORE)\");\n}\n\n- (void)test_rollback\n{\n    auto testingSQL = WCDB::RaiseFunction().rollback(errorMessage);\n\n    auto testingTypes = { WCDB::SQL::Type::RaiseFunction };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"RAISE(ROLLBACK, testErrorMessage)\");\n}\n\n- (void)test_abort\n{\n    auto testingSQL = WCDB::RaiseFunction().abort(errorMessage);\n\n    auto testingTypes = { WCDB::SQL::Type::RaiseFunction };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"RAISE(ABORT, testErrorMessage)\");\n}\n\n- (void)test_fail\n{\n    auto testingSQL = WCDB::RaiseFunction().fail(errorMessage);\n\n    auto testingTypes = { WCDB::SQL::Type::RaiseFunction };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"RAISE(FAIL, testErrorMessage)\");\n}\n\n- (void)test_raise_function_convertible\n{\n    WCDB::RaiseFunction sql = WCDB::RaiseFunction().ignore();\n\n    NSString* expected = @\"RAISE(IGNORE)\";\n    TestCaseAssertWINQConvertible(WCDB::Expression, sql, expected);\n    TestCaseAssertWINQConvertible(WCDB::Expressions, sql, expected);\n    TestCaseAssertWINQConvertible(WCDB::IndexedColumn, sql, expected);\n    TestCaseAssertWINQConvertible(WCDB::IndexedColumns, sql, expected);\n    TestCaseAssertWINQConvertible(WCDB::ResultColumn, sql, expected);\n    TestCaseAssertWINQConvertible(WCDB::ResultColumns, sql, expected);\n    TestCaseAssertWINQConvertible(WCDB::OrderingTerm, sql, expected);\n    TestCaseAssertWINQConvertible(WCDB::OrderingTerms, sql, expected);\n}\n\n@end\n"
  },
  {
    "path": "src/objc/tests/winq/ResultColumnTests.mm",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"WINQAssertion.h\"\n\n@interface ResultColumnTests : BaseTestCase\n\n@end\n\n@implementation ResultColumnTests {\n    WCDB::Expression expression;\n    NSString* alias;\n    NSString* table;\n}\n\n- (void)setUp\n{\n    [super setUp];\n    expression = 1;\n    alias = @\"testAlias\";\n    table = @\"testTable\";\n}\n\n- (void)test_default_constructible\n{\n    WCDB::ResultColumn constructible;\n    TestCaseAssertFalse(constructible.syntax().isValid());\n    TestCaseAssertIterateEqual(constructible, std::list<WCDB::Syntax::Identifier::Type>());\n    TestCaseAssertTrue(constructible.getDescription().empty());\n}\n\n- (void)test_get_type\n{\n    TestCaseAssertEqual(WCDB::ResultColumn().getType(), WCDB::SQL::Type::ResultColumn);\n    TestCaseAssertEqual(WCDB::ResultColumn::type, WCDB::SQL::Type::ResultColumn);\n}\n\n- (void)test_result_column\n{\n    auto testingSQL = WCDB::ResultColumn(expression);\n\n    auto testingTypes = { WCDB::SQL::Type::ResultColumn, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"1\");\n}\n\n- (void)test_result_column_with_alias\n{\n    auto testingSQL = WCDB::ResultColumn(expression).as(alias);\n\n    auto testingTypes = { WCDB::SQL::Type::ResultColumn, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"1 AS testAlias\");\n}\n\n@end\n"
  },
  {
    "path": "src/objc/tests/winq/SchemaTests.mm",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"WINQAssertion.h\"\n\n@interface SchemaTests : BaseTestCase\n\n@end\n\n@implementation SchemaTests {\n}\n\n- (void)setUp\n{\n    [super setUp];\n}\n\n- (void)test_default_constructible\n{\n    WCDB::Schema constructible;\n    TestCaseAssertTrue(!constructible.syntax().isValid());\n}\n\n- (void)test_get_type\n{\n    TestCaseAssertEqual(WCDB::Schema().getType(), WCDB::SQL::Type::Schema);\n    TestCaseAssertEqual(WCDB::Schema::type, WCDB::SQL::Type::Schema);\n}\n\n- (void)test\n{\n    auto testingSQL = WCDB::Schema(@\"testSchema\");\n\n    auto testingTypes = { WCDB::SQL::Type::Schema };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"testSchema\");\n}\n\n- (void)test_default\n{\n    TestCaseAssertSQLEqual(WCDB::Schema(), @\"\");\n}\n\n- (void)test_main\n{\n    TestCaseAssertSQLEqual(WCDB::Schema::main(), @\"main\");\n}\n\n- (void)test_temp\n{\n    TestCaseAssertSQLEqual(WCDB::Schema::temp(), @\"temp\");\n}\n\n@end\n"
  },
  {
    "path": "src/objc/tests/winq/StatementAlterTableTests.mm",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"WINQAssertion.h\"\n\n@interface StatementAlterTableTests : BaseTestCase\n\n@end\n\n@implementation StatementAlterTableTests {\n    WCDB::Schema schema;\n    NSString* table;\n    NSString* newTable;\n    WCDB::Column column;\n    WCDB::Column newColumn;\n    WCDB::ColumnDef columnDef;\n}\n\n- (void)setUp\n{\n    [super setUp];\n    schema = @\"testSchema\";\n    table = @\"testTable\";\n    newTable = @\"testNewTable\";\n    column = WCDB::Column(@\"testColumn\");\n    newColumn = WCDB::Column(@\"testNewColumn\");\n    columnDef = WCDB::ColumnDef(newColumn);\n}\n\n- (void)test_default_constructible\n{\n    WCDB::StatementAlterTable constructible;\n    TestCaseAssertFalse(constructible.syntax().isValid());\n    TestCaseAssertIterateEqual(constructible, std::list<WCDB::Syntax::Identifier::Type>());\n    TestCaseAssertTrue(constructible.getDescription().empty());\n}\n\n- (void)test_get_type\n{\n    TestCaseAssertEqual(WCDB::StatementAlterTable().getType(), WCDB::SQL::Type::AlterTableSTMT);\n    TestCaseAssertEqual(WCDB::StatementAlterTable::type, WCDB::SQL::Type::AlterTableSTMT);\n}\n\n- (void)test_alter_table_rename_to\n{\n    auto testingSQL = WCDB::StatementAlterTable().alterTable(table).schema(schema).renameToTable(newTable);\n    auto testingTypes = { WCDB::SQL::Type::AlterTableSTMT, WCDB::SQL::Type::Schema };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"ALTER TABLE testSchema.testTable RENAME TO testNewTable\");\n}\n\n- (void)test_alter_table_rename_to_without_schema\n{\n    auto testingSQL = WCDB::StatementAlterTable()\n                      .alterTable(table)\n                      .renameToTable(newTable);\n    auto testingTypes = { WCDB::SQL::Type::AlterTableSTMT };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL,\n                           @\"ALTER TABLE testTable RENAME TO testNewTable\");\n}\n\n- (void)test_alter_table_rename_column\n{\n    auto testingSQL = WCDB::StatementAlterTable()\n                      .alterTable(table)\n                      .schema(schema)\n                      .renameColumn(column)\n                      .toColumn(newColumn);\n    auto testingTypes = { WCDB::SQL::Type::AlterTableSTMT, WCDB::SQL::Type::Schema, WCDB::SQL::Type::Column, WCDB::SQL::Type::Column };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"ALTER TABLE testSchema.testTable RENAME COLUMN testColumn TO testNewColumn\");\n}\n\n- (void)test_alter_table_add_column\n{\n    auto testingSQL = WCDB::StatementAlterTable()\n                      .alterTable(table)\n                      .schema(schema)\n                      .addColumn(columnDef);\n    auto testingTypes = { WCDB::SQL::Type::AlterTableSTMT, WCDB::SQL::Type::Schema, WCDB::SQL::Type::ColumnDef, WCDB::SQL::Type::Column };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL,\n                           @\"ALTER TABLE testSchema.testTable ADD COLUMN testNewColumn\");\n}\n\n@end\n"
  },
  {
    "path": "src/objc/tests/winq/StatementAnalyzeTests.mm",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"WINQAssertion.h\"\n\n@interface StatementAnalyzeTests : BaseTestCase\n\n@end\n\n@implementation StatementAnalyzeTests {\n    WCDB::Schema schema;\n    NSString* table;\n    NSString* index;\n}\n\n- (void)setUp\n{\n    [super setUp];\n    schema = @\"testSchema\";\n    table = @\"testTable\";\n    index = @\"testIndex\";\n}\n\n- (void)test_default_constructible\n{\n    WCDB::StatementAnalyze constructible;\n    TestCaseAssertFalse(constructible.syntax().isValid());\n    TestCaseAssertIterateEqual(constructible, std::list<WCDB::Syntax::Identifier::Type>());\n    TestCaseAssertTrue(constructible.getDescription().empty());\n}\n\n- (void)test_get_type\n{\n    TestCaseAssertEqual(WCDB::StatementAnalyze().getType(), WCDB::SQL::Type::AnalyzeSTMT);\n    TestCaseAssertEqual(WCDB::StatementAnalyze::type, WCDB::SQL::Type::AnalyzeSTMT);\n}\n\n- (void)test_analyze\n{\n    auto testingSQL = WCDB::StatementAnalyze().analyze();\n    auto testingTypes = { WCDB::SQL::Type::AnalyzeSTMT };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"ANALYZE\");\n}\n\n- (void)test_analyze_schema\n{\n    auto testingSQL = WCDB::StatementAnalyze().analyze().schema(schema);\n\n    auto testingTypes = { WCDB::SQL::Type::AnalyzeSTMT, WCDB::SQL::Type::Schema };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"ANALYZE testSchema\");\n}\n\n- (void)test_analyze_table\n{\n    auto testingSQL = WCDB::StatementAnalyze().analyze().schema(schema).table(table);\n\n    auto testingTypes = { WCDB::SQL::Type::AnalyzeSTMT, WCDB::SQL::Type::Schema };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"ANALYZE testSchema.testTable\");\n}\n\n- (void)test_analyze_table_without_schema\n{\n    auto testingSQL = WCDB::StatementAnalyze().analyze().table(table);\n\n    auto testingTypes = { WCDB::SQL::Type::AnalyzeSTMT };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"ANALYZE testTable\");\n}\n\n- (void)test_analyze_index\n{\n    auto testingSQL = WCDB::StatementAnalyze().analyze().schema(schema).index(index);\n\n    auto testingTypes = { WCDB::SQL::Type::AnalyzeSTMT, WCDB::SQL::Type::Schema };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"ANALYZE testSchema.testIndex\");\n}\n\n@end\n"
  },
  {
    "path": "src/objc/tests/winq/StatementAttachTests.mm",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"WINQAssertion.h\"\n\n@interface StatementAttachTests : BaseTestCase\n\n@end\n\n@implementation StatementAttachTests {\n    NSString* path;\n    WCDB::Expression expression;\n    WCDB::Schema schema;\n}\n\n- (void)setUp\n{\n    [super setUp];\n    path = @\"testPath\";\n    expression = path;\n    schema = @\"testSchema\";\n}\n\n- (void)test_default_constructible\n{\n    WCDB::StatementAttach constructible;\n    TestCaseAssertFalse(constructible.syntax().isValid());\n    TestCaseAssertIterateEqual(constructible, std::list<WCDB::Syntax::Identifier::Type>());\n    TestCaseAssertTrue(constructible.getDescription().empty());\n}\n\n- (void)test_get_type\n{\n    TestCaseAssertEqual(WCDB::StatementAttach().getType(), WCDB::SQL::Type::AttachSTMT);\n    TestCaseAssertEqual(WCDB::StatementAttach::type, WCDB::SQL::Type::AttachSTMT);\n}\n\n- (void)test_attach\n{\n    auto testingSQL = WCDB::StatementAttach().attach(expression).as(schema);\n\n    auto testingTypes = { WCDB::SQL::Type::AttachSTMT, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue, WCDB::SQL::Type::Schema };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"ATTACH 'testPath' AS testSchema\");\n}\n\n@end\n"
  },
  {
    "path": "src/objc/tests/winq/StatementBeginTests.mm",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"WINQAssertion.h\"\n\n@interface StatementBeginTests : BaseTestCase\n\n@end\n\n@implementation StatementBeginTests {\n}\n\n- (void)setUp\n{\n    [super setUp];\n}\n\n- (void)test_default_constructible\n{\n    WCDB::StatementBegin constructible;\n    TestCaseAssertFalse(constructible.syntax().isValid());\n    TestCaseAssertIterateEqual(constructible, std::list<WCDB::Syntax::Identifier::Type>());\n    TestCaseAssertTrue(constructible.getDescription().empty());\n}\n\n- (void)test_get_type\n{\n    TestCaseAssertEqual(WCDB::StatementBegin().getType(), WCDB::SQL::Type::BeginSTMT);\n    TestCaseAssertEqual(WCDB::StatementBegin::type, WCDB::SQL::Type::BeginSTMT);\n}\n\n- (void)test_begin_deferred\n{\n    auto testingSQL = WCDB::StatementBegin().beginDeferred();\n\n    auto testingTypes = { WCDB::SQL::Type::BeginSTMT };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"BEGIN DEFERRED\");\n}\n\n- (void)test_begin_immediate\n{\n    auto testingSQL = WCDB::StatementBegin().beginImmediate();\n\n    auto testingTypes = { WCDB::SQL::Type::BeginSTMT };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"BEGIN IMMEDIATE\");\n}\n\n- (void)test_begin_exclusive\n{\n    auto testingSQL = WCDB::StatementBegin().beginExclusive();\n\n    auto testingTypes = { WCDB::SQL::Type::BeginSTMT };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"BEGIN EXCLUSIVE\");\n}\n\n@end\n"
  },
  {
    "path": "src/objc/tests/winq/StatementCommitTests.mm",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"WINQAssertion.h\"\n\n@interface StatementCommitTests : BaseTestCase\n\n@end\n\n@implementation StatementCommitTests {\n}\n\n- (void)setUp\n{\n    [super setUp];\n}\n\n- (void)test_default_constructible\n{\n    WCDB::StatementCommit constructible;\n    TestCaseAssertFalse(constructible.syntax().isValid());\n    TestCaseAssertIterateEqual(constructible, std::list<WCDB::Syntax::Identifier::Type>());\n    TestCaseAssertTrue(constructible.getDescription().empty());\n}\n\n- (void)test_get_type\n{\n    TestCaseAssertEqual(WCDB::StatementCommit().getType(), WCDB::SQL::Type::CommitSTMT);\n    TestCaseAssertEqual(WCDB::StatementCommit::type, WCDB::SQL::Type::CommitSTMT);\n}\n\n- (void)test_commit\n{\n    auto testingSQL = WCDB::StatementCommit().commit();\n\n    auto testingTypes = { WCDB::SQL::Type::CommitSTMT };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"COMMIT\");\n}\n\n@end\n"
  },
  {
    "path": "src/objc/tests/winq/StatementCreateIndexTests.mm",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"WINQAssertion.h\"\n\n@interface StatementCreateIndexTests : BaseTestCase\n\n@end\n\n@implementation StatementCreateIndexTests {\n    WCDB::Schema schema;\n    NSString* index;\n    NSString* table;\n    WCDB::IndexedColumn indexedColumn1;\n    WCDB::IndexedColumn indexedColumn2;\n    WCDB::Expression condition;\n}\n\n- (void)setUp\n{\n    [super setUp];\n\n    schema = @\"testSchema\";\n    index = @\"testIndex\";\n    table = @\"testTable\";\n    indexedColumn1 = WCDB::Column(@\"testColumn1\");\n    indexedColumn2 = WCDB::Column(@\"testColumn2\");\n    condition = 1;\n}\n\n- (void)test_default_constructible\n{\n    WCDB::StatementCreateIndex constructible;\n    TestCaseAssertFalse(constructible.syntax().isValid());\n    TestCaseAssertIterateEqual(constructible, std::list<WCDB::Syntax::Identifier::Type>());\n    TestCaseAssertTrue(constructible.getDescription().empty());\n}\n\n- (void)test_get_type\n{\n    TestCaseAssertEqual(WCDB::StatementCreateIndex().getType(), WCDB::SQL::Type::CreateIndexSTMT);\n    TestCaseAssertEqual(WCDB::StatementCreateIndex::type, WCDB::SQL::Type::CreateIndexSTMT);\n}\n\n- (void)test_create_index\n{\n    auto testingSQL = WCDB::StatementCreateIndex().createIndex(index).schema(schema).table(table).indexed(indexedColumn1);\n\n    auto testingTypes = { WCDB::SQL::Type::CreateIndexSTMT, WCDB::SQL::Type::Schema, WCDB::SQL::Type::IndexedColumn, WCDB::SQL::Type::Column };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"CREATE INDEX testSchema.testIndex ON testTable(testColumn1)\");\n}\n\n- (void)test_create_multi_index\n{\n    auto testingSQL = WCDB::StatementCreateIndex().createIndex(index).schema(schema).table(table).indexed(indexedColumn1).indexed(indexedColumn2);\n\n    auto testingTypes = { WCDB::SQL::Type::CreateIndexSTMT, WCDB::SQL::Type::Schema, WCDB::SQL::Type::IndexedColumn, WCDB::SQL::Type::Column, WCDB::SQL::Type::IndexedColumn, WCDB::SQL::Type::Column };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"CREATE INDEX testSchema.testIndex ON testTable(testColumn1, testColumn2)\");\n}\n\n- (void)test_create_unique_index\n{\n    auto testingSQL = WCDB::StatementCreateIndex().createIndex(index).schema(schema).unique().table(table).indexed(indexedColumn1);\n\n    auto testingTypes = { WCDB::SQL::Type::CreateIndexSTMT, WCDB::SQL::Type::Schema, WCDB::SQL::Type::IndexedColumn, WCDB::SQL::Type::Column };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"CREATE UNIQUE INDEX testSchema.testIndex ON testTable(testColumn1)\");\n}\n\n- (void)test_create_index_if_not_exists\n{\n    auto testingSQL = WCDB::StatementCreateIndex().createIndex(index).schema(schema).ifNotExists().table(table).indexed(indexedColumn1);\n\n    auto testingTypes = { WCDB::SQL::Type::CreateIndexSTMT, WCDB::SQL::Type::Schema, WCDB::SQL::Type::IndexedColumn, WCDB::SQL::Type::Column };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"CREATE INDEX IF NOT EXISTS testSchema.testIndex ON testTable(testColumn1)\");\n}\n\n- (void)test_create_index_without_schema\n{\n    auto testingSQL = WCDB::StatementCreateIndex().createIndex(index).table(table).indexed(indexedColumn1);\n\n    auto testingTypes = { WCDB::SQL::Type::CreateIndexSTMT, WCDB::SQL::Type::IndexedColumn, WCDB::SQL::Type::Column };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"CREATE INDEX testIndex ON testTable(testColumn1)\");\n}\n\n- (void)test_create_index_with_condition\n{\n    auto testingSQL = WCDB::StatementCreateIndex().createIndex(index).schema(schema).table(table).indexed(indexedColumn1).where(condition);\n\n    auto testingTypes = { WCDB::SQL::Type::CreateIndexSTMT, WCDB::SQL::Type::Schema, WCDB::SQL::Type::IndexedColumn, WCDB::SQL::Type::Column, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"CREATE INDEX testSchema.testIndex ON testTable(testColumn1) WHERE 1\");\n}\n\n@end\n"
  },
  {
    "path": "src/objc/tests/winq/StatementCreateTableTests.mm",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"WINQAssertion.h\"\n\n@interface StatementCreateTableTests : BaseTestCase\n\n@end\n\n@implementation StatementCreateTableTests {\n    WCDB::Schema schema;\n    NSString* table;\n    WCDB::ColumnDef columnDef1;\n    WCDB::ColumnDef columnDef2;\n    WCDB::TableConstraint tableConstraint1;\n    WCDB::TableConstraint tableConstraint2;\n    WCDB::StatementSelect select;\n}\n\n- (void)setUp\n{\n    [super setUp];\n    schema = @\"testSchema\";\n    table = @\"testTable\";\n    columnDef1 = WCDB::ColumnDef(WCDB::Column(@\"testColumn1\"), WCDB::ColumnType::Integer);\n    columnDef2 = WCDB::ColumnDef(WCDB::Column(@\"testColumn2\"), WCDB::ColumnType::Text);\n    tableConstraint1 = WCDB::TableConstraint().check(1);\n    tableConstraint2 = WCDB::TableConstraint().check(2);\n    select = WCDB::StatementSelect().select(1);\n}\n\n- (void)test_default_constructible\n{\n    WCDB::StatementCreateTable constructible;\n    TestCaseAssertFalse(constructible.syntax().isValid());\n    TestCaseAssertIterateEqual(constructible, std::list<WCDB::Syntax::Identifier::Type>());\n    TestCaseAssertTrue(constructible.getDescription().empty());\n}\n\n- (void)test_get_type\n{\n    TestCaseAssertEqual(WCDB::StatementCreateTable().getType(), WCDB::SQL::Type::CreateTableSTMT);\n    TestCaseAssertEqual(WCDB::StatementCreateTable::type, WCDB::SQL::Type::CreateTableSTMT);\n}\n\n- (void)test_create_table\n{\n    auto testingSQL = WCDB::StatementCreateTable().createTable(table).schema(schema).define(columnDef1);\n\n    auto testingTypes = { WCDB::SQL::Type::CreateTableSTMT, WCDB::SQL::Type::Schema, WCDB::SQL::Type::ColumnDef, WCDB::SQL::Type::Column };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"CREATE TABLE testSchema.testTable(testColumn1 INTEGER)\");\n}\n\n- (void)test_create_table_with_multi_defines\n{\n    auto testingSQL = WCDB::StatementCreateTable().createTable(table).schema(schema).define(columnDef1).define(columnDef2);\n\n    auto testingTypes = { WCDB::SQL::Type::CreateTableSTMT, WCDB::SQL::Type::Schema, WCDB::SQL::Type::ColumnDef, WCDB::SQL::Type::Column, WCDB::SQL::Type::ColumnDef, WCDB::SQL::Type::Column };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"CREATE TABLE testSchema.testTable(testColumn1 INTEGER, testColumn2 TEXT)\");\n}\n\n- (void)test_create_temp_table\n{\n    auto testingSQL = WCDB::StatementCreateTable().createTable(table).temp().define(columnDef1);\n\n    auto testingTypes = { WCDB::SQL::Type::CreateTableSTMT, WCDB::SQL::Type::ColumnDef, WCDB::SQL::Type::Column };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"CREATE TEMP TABLE testTable(testColumn1 INTEGER)\");\n}\n\n- (void)test_create_table_if_not_exists\n{\n    auto testingSQL = WCDB::StatementCreateTable().createTable(table).schema(schema).ifNotExists().define(columnDef1);\n\n    auto testingTypes = { WCDB::SQL::Type::CreateTableSTMT, WCDB::SQL::Type::Schema, WCDB::SQL::Type::ColumnDef, WCDB::SQL::Type::Column };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"CREATE TABLE IF NOT EXISTS testSchema.testTable(testColumn1 INTEGER)\");\n}\n\n- (void)test_create_table_without_schema\n{\n    auto testingSQL = WCDB::StatementCreateTable().createTable(table).define(columnDef1);\n\n    auto testingTypes = { WCDB::SQL::Type::CreateTableSTMT, WCDB::SQL::Type::ColumnDef, WCDB::SQL::Type::Column };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"CREATE TABLE testTable(testColumn1 INTEGER)\");\n}\n\n- (void)test_create_table_with_constraint\n{\n    auto testingSQL = WCDB::StatementCreateTable().createTable(table).schema(schema).define(columnDef1).constraint(tableConstraint1);\n\n    auto testingTypes = { WCDB::SQL::Type::CreateTableSTMT, WCDB::SQL::Type::Schema, WCDB::SQL::Type::ColumnDef, WCDB::SQL::Type::Column, WCDB::SQL::Type::TableConstraint, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"CREATE TABLE testSchema.testTable(testColumn1 INTEGER, CHECK(1))\");\n}\n\n- (void)test_create_table_with_constraints\n{\n    auto testingSQL = WCDB::StatementCreateTable().createTable(table).schema(schema).define(columnDef1).constraint(tableConstraint1).constraint(tableConstraint2);\n\n    auto testingTypes = { WCDB::SQL::Type::CreateTableSTMT, WCDB::SQL::Type::Schema, WCDB::SQL::Type::ColumnDef, WCDB::SQL::Type::Column, WCDB::SQL::Type::TableConstraint, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue, WCDB::SQL::Type::TableConstraint, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"CREATE TABLE testSchema.testTable(testColumn1 INTEGER, CHECK(1), CHECK(2))\");\n}\n\n- (void)test_create_table_without_rowid\n{\n    auto testingSQL = WCDB::StatementCreateTable().createTable(table).schema(schema).define(columnDef1).withoutRowID();\n\n    auto testingTypes = { WCDB::SQL::Type::CreateTableSTMT, WCDB::SQL::Type::Schema, WCDB::SQL::Type::ColumnDef, WCDB::SQL::Type::Column };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"CREATE TABLE testSchema.testTable(testColumn1 INTEGER) WITHOUT ROWID\");\n}\n\n- (void)test_create_table_as_select\n{\n    auto testingSQL = WCDB::StatementCreateTable().createTable(table).schema(schema).as(select);\n\n    auto testingTypes = { WCDB::SQL::Type::CreateTableSTMT, WCDB::SQL::Type::Schema, WCDB::SQL::Type::SelectSTMT, WCDB::SQL::Type::SelectCore, WCDB::SQL::Type::ResultColumn, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"CREATE TABLE testSchema.testTable AS SELECT 1\");\n}\n\n@end\n"
  },
  {
    "path": "src/objc/tests/winq/StatementCreateTriggerTests.mm",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"WINQAssertion.h\"\n\n@interface StatementCreateTriggerTests : BaseTestCase\n\n@end\n\n@implementation StatementCreateTriggerTests {\n    WCDB::Schema schema;\n    NSString* name;\n    WCDB::Column column1;\n    WCDB::Column column2;\n    NSString* table;\n    WCDB::Expression condition;\n    WCDB::StatementUpdate update;\n    WCDB::StatementSelect select;\n    WCDB::StatementInsert insert;\n    WCDB::StatementDelete delete_;\n}\n\n- (void)setUp\n{\n    [super setUp];\n    schema = @\"testSchema\";\n    name = @\"testTrigger\";\n    column1 = WCDB::Column(@\"testColumn1\");\n    column2 = WCDB::Column(@\"testColumn2\");\n    table = @\"testTable\";\n    condition = 1;\n    update = WCDB::StatementUpdate().update(table).set(WCDB::Column(@\"testColumn\")).to(1);\n    select = WCDB::StatementSelect().select(1);\n    insert = WCDB::StatementInsert().insertIntoTable(table).values(1);\n    delete_ = WCDB::StatementDelete().deleteFrom(table);\n}\n\n- (void)test_default_constructible\n{\n    WCDB::StatementCreateTrigger constructible;\n    TestCaseAssertFalse(constructible.syntax().isValid());\n    TestCaseAssertIterateEqual(constructible, std::list<WCDB::Syntax::Identifier::Type>());\n    TestCaseAssertTrue(constructible.getDescription().empty());\n}\n\n- (void)test_get_type\n{\n    TestCaseAssertEqual(WCDB::StatementCreateTrigger().getType(), WCDB::SQL::Type::CreateTriggerSTMT);\n    TestCaseAssertEqual(WCDB::StatementCreateTrigger::type, WCDB::SQL::Type::CreateTriggerSTMT);\n}\n\n- (void)test_create_trigger\n{\n    auto testingSQL = WCDB::StatementCreateTrigger().createTrigger(name).schema(schema).before().delete_().on(table).forEachRow().when(condition).execute(update);\n\n    auto testingTypes = { WCDB::SQL::Type::CreateTriggerSTMT, WCDB::SQL::Type::Schema, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue, WCDB::SQL::Type::UpdateSTMT, WCDB::SQL::Type::QualifiedTableName, WCDB::SQL::Type::Column, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"CREATE TRIGGER testSchema.testTrigger BEFORE DELETE ON testTable FOR EACH ROW WHEN 1 BEGIN UPDATE testTable SET testColumn = 1; END\");\n}\n\n- (void)test_create_temp_trigger\n{\n    auto testingSQL = WCDB::StatementCreateTrigger().createTrigger(name).temp().before().delete_().on(table).forEachRow().when(condition).execute(update);\n\n    auto testingTypes = { WCDB::SQL::Type::CreateTriggerSTMT, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue, WCDB::SQL::Type::UpdateSTMT, WCDB::SQL::Type::QualifiedTableName, WCDB::SQL::Type::Column, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"CREATE TEMP TRIGGER testTrigger BEFORE DELETE ON testTable FOR EACH ROW WHEN 1 BEGIN UPDATE testTable SET testColumn = 1; END\");\n}\n\n- (void)test_create_trigger_if_not_exists\n{\n    auto testingSQL = WCDB::StatementCreateTrigger().createTrigger(name).schema(schema).ifNotExists().before().delete_().on(table).forEachRow().when(condition).execute(update);\n\n    auto testingTypes = { WCDB::SQL::Type::CreateTriggerSTMT, WCDB::SQL::Type::Schema, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue, WCDB::SQL::Type::UpdateSTMT, WCDB::SQL::Type::QualifiedTableName, WCDB::SQL::Type::Column, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"CREATE TRIGGER IF NOT EXISTS testSchema.testTrigger BEFORE DELETE ON testTable FOR EACH ROW WHEN 1 BEGIN UPDATE testTable SET testColumn = 1; END\");\n}\n\n- (void)test_create_trigger_without_schema\n{\n    auto testingSQL = WCDB::StatementCreateTrigger().createTrigger(name).before().delete_().on(table).forEachRow().when(condition).execute(update);\n\n    auto testingTypes = { WCDB::SQL::Type::CreateTriggerSTMT, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue, WCDB::SQL::Type::UpdateSTMT, WCDB::SQL::Type::QualifiedTableName, WCDB::SQL::Type::Column, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"CREATE TRIGGER testTrigger BEFORE DELETE ON testTable FOR EACH ROW WHEN 1 BEGIN UPDATE testTable SET testColumn = 1; END\");\n}\n\n- (void)test_create_trigger_after_delete\n{\n    auto testingSQL = WCDB::StatementCreateTrigger().createTrigger(name).schema(schema).after().delete_().on(table).forEachRow().when(condition).execute(update);\n\n    auto testingTypes = { WCDB::SQL::Type::CreateTriggerSTMT, WCDB::SQL::Type::Schema, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue, WCDB::SQL::Type::UpdateSTMT, WCDB::SQL::Type::QualifiedTableName, WCDB::SQL::Type::Column, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"CREATE TRIGGER testSchema.testTrigger AFTER DELETE ON testTable FOR EACH ROW WHEN 1 BEGIN UPDATE testTable SET testColumn = 1; END\");\n}\n\n- (void)test_create_trigger_instead_of_delete\n{\n    auto testingSQL = WCDB::StatementCreateTrigger().createTrigger(name).schema(schema).insteadOf().delete_().on(table).forEachRow().when(condition).execute(update);\n\n    auto testingTypes = { WCDB::SQL::Type::CreateTriggerSTMT, WCDB::SQL::Type::Schema, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue, WCDB::SQL::Type::UpdateSTMT, WCDB::SQL::Type::QualifiedTableName, WCDB::SQL::Type::Column, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"CREATE TRIGGER testSchema.testTrigger INSTEAD OF DELETE ON testTable FOR EACH ROW WHEN 1 BEGIN UPDATE testTable SET testColumn = 1; END\");\n}\n\n- (void)test_create_trigger_before_insert\n{\n    auto testingSQL = WCDB::StatementCreateTrigger().createTrigger(name).schema(schema).before().insert().on(table).forEachRow().when(condition).execute(update);\n\n    auto testingTypes = { WCDB::SQL::Type::CreateTriggerSTMT, WCDB::SQL::Type::Schema, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue, WCDB::SQL::Type::UpdateSTMT, WCDB::SQL::Type::QualifiedTableName, WCDB::SQL::Type::Column, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"CREATE TRIGGER testSchema.testTrigger BEFORE INSERT ON testTable FOR EACH ROW WHEN 1 BEGIN UPDATE testTable SET testColumn = 1; END\");\n}\n\n- (void)test_create_trigger_before_update\n{\n    auto testingSQL = WCDB::StatementCreateTrigger().createTrigger(name).schema(schema).before().update().on(table).forEachRow().when(condition).execute(update);\n\n    auto testingTypes = { WCDB::SQL::Type::CreateTriggerSTMT, WCDB::SQL::Type::Schema, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue, WCDB::SQL::Type::UpdateSTMT, WCDB::SQL::Type::QualifiedTableName, WCDB::SQL::Type::Column, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"CREATE TRIGGER testSchema.testTrigger BEFORE UPDATE ON testTable FOR EACH ROW WHEN 1 BEGIN UPDATE testTable SET testColumn = 1; END\");\n}\n\n- (void)test_create_trigger_before_update_of_column\n{\n    auto testingSQL = WCDB::StatementCreateTrigger().createTrigger(name).schema(schema).before().update().column(column1).on(table).forEachRow().when(condition).execute(update);\n\n    auto testingTypes = { WCDB::SQL::Type::CreateTriggerSTMT, WCDB::SQL::Type::Schema, WCDB::SQL::Type::Column, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue, WCDB::SQL::Type::UpdateSTMT, WCDB::SQL::Type::QualifiedTableName, WCDB::SQL::Type::Column, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"CREATE TRIGGER testSchema.testTrigger BEFORE UPDATE OF testColumn1 ON testTable FOR EACH ROW WHEN 1 BEGIN UPDATE testTable SET testColumn = 1; END\");\n}\n\n- (void)test_create_trigger_before_update_of_columns\n{\n    auto testingSQL = WCDB::StatementCreateTrigger().createTrigger(name).schema(schema).before().update().column(column1).column(column2).on(table).forEachRow().when(condition).execute(update);\n\n    auto testingTypes = { WCDB::SQL::Type::CreateTriggerSTMT, WCDB::SQL::Type::Schema, WCDB::SQL::Type::Column, WCDB::SQL::Type::Column, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue, WCDB::SQL::Type::UpdateSTMT, WCDB::SQL::Type::QualifiedTableName, WCDB::SQL::Type::Column, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"CREATE TRIGGER testSchema.testTrigger BEFORE UPDATE OF testColumn1, testColumn2 ON testTable FOR EACH ROW WHEN 1 BEGIN UPDATE testTable SET testColumn = 1; END\");\n}\n\n- (void)test_create_trigger_without_for_each_row\n{\n    auto testingSQL = WCDB::StatementCreateTrigger().createTrigger(name).schema(schema).before().delete_().on(table).when(condition).execute(update);\n\n    auto testingTypes = { WCDB::SQL::Type::CreateTriggerSTMT, WCDB::SQL::Type::Schema, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue, WCDB::SQL::Type::UpdateSTMT, WCDB::SQL::Type::QualifiedTableName, WCDB::SQL::Type::Column, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"CREATE TRIGGER testSchema.testTrigger BEFORE DELETE ON testTable WHEN 1 BEGIN UPDATE testTable SET testColumn = 1; END\");\n}\n\n- (void)test_create_trigger_without_condition\n{\n    auto testingSQL = WCDB::StatementCreateTrigger().createTrigger(name).schema(schema).before().delete_().on(table).forEachRow().execute(update);\n\n    auto testingTypes = { WCDB::SQL::Type::CreateTriggerSTMT, WCDB::SQL::Type::Schema, WCDB::SQL::Type::UpdateSTMT, WCDB::SQL::Type::QualifiedTableName, WCDB::SQL::Type::Column, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"CREATE TRIGGER testSchema.testTrigger BEFORE DELETE ON testTable FOR EACH ROW BEGIN UPDATE testTable SET testColumn = 1; END\");\n}\n\n- (void)test_create_trigger_with_insert\n{\n    auto testingSQL = WCDB::StatementCreateTrigger().createTrigger(name).schema(schema).before().delete_().on(table).forEachRow().when(condition).execute(insert);\n\n    auto testingTypes = { WCDB::SQL::Type::CreateTriggerSTMT, WCDB::SQL::Type::Schema, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue, WCDB::SQL::Type::InsertSTMT, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"CREATE TRIGGER testSchema.testTrigger BEFORE DELETE ON testTable FOR EACH ROW WHEN 1 BEGIN INSERT INTO testTable VALUES(1); END\");\n}\n\n- (void)test_create_trigger_with_delete\n{\n    auto testingSQL = WCDB::StatementCreateTrigger().createTrigger(name).schema(schema).before().delete_().on(table).forEachRow().when(condition).execute(delete_);\n\n    auto testingTypes = { WCDB::SQL::Type::CreateTriggerSTMT, WCDB::SQL::Type::Schema, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue, WCDB::SQL::Type::DeleteSTMT, WCDB::SQL::Type::QualifiedTableName };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"CREATE TRIGGER testSchema.testTrigger BEFORE DELETE ON testTable FOR EACH ROW WHEN 1 BEGIN DELETE FROM testTable; END\");\n}\n\n- (void)test_create_trigger_with_select\n{\n    auto testingSQL = WCDB::StatementCreateTrigger().createTrigger(name).schema(schema).before().delete_().on(table).forEachRow().when(condition).execute(select);\n\n    auto testingTypes = { WCDB::SQL::Type::CreateTriggerSTMT, WCDB::SQL::Type::Schema, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue, WCDB::SQL::Type::SelectSTMT, WCDB::SQL::Type::SelectCore, WCDB::SQL::Type::ResultColumn, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"CREATE TRIGGER testSchema.testTrigger BEFORE DELETE ON testTable FOR EACH ROW WHEN 1 BEGIN SELECT 1; END\");\n}\n\n- (void)test_create_trigger_with_multiple_stmts\n{\n    auto testingSQL = WCDB::StatementCreateTrigger().createTrigger(name).schema(schema).before().delete_().on(table).forEachRow().when(condition).execute(update).execute(insert).execute(delete_).execute(select);\n\n    auto testingTypes = { WCDB::SQL::Type::CreateTriggerSTMT, WCDB::SQL::Type::Schema, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue, WCDB::SQL::Type::UpdateSTMT, WCDB::SQL::Type::QualifiedTableName, WCDB::SQL::Type::Column, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue, WCDB::SQL::Type::InsertSTMT, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue, WCDB::SQL::Type::DeleteSTMT, WCDB::SQL::Type::QualifiedTableName, WCDB::SQL::Type::SelectSTMT, WCDB::SQL::Type::SelectCore, WCDB::SQL::Type::ResultColumn, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"CREATE TRIGGER testSchema.testTrigger BEFORE DELETE ON testTable FOR EACH ROW WHEN 1 BEGIN UPDATE testTable SET testColumn = 1; INSERT INTO testTable VALUES(1); DELETE FROM testTable; SELECT 1; END\");\n}\n\n@end\n"
  },
  {
    "path": "src/objc/tests/winq/StatementCreateViewTests.mm",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"WINQAssertion.h\"\n\n@interface StatementCreateViewTests : BaseTestCase\n\n@end\n\n@implementation StatementCreateViewTests {\n    WCDB::Schema schema;\n    NSString* name;\n    WCDB::Columns columns;\n    WCDB::StatementSelect select;\n}\n\n- (void)setUp\n{\n    [super setUp];\n    schema = @\"testSchema\";\n    name = @\"testView\";\n    columns = {\n        WCDB::Column(@\"testColumn1\"),\n        WCDB::Column(@\"testColumn2\")\n    };\n    select = WCDB::StatementSelect().select(1);\n}\n\n- (void)test_default_constructible\n{\n    WCDB::StatementCreateView constructible;\n    TestCaseAssertFalse(constructible.syntax().isValid());\n    TestCaseAssertIterateEqual(constructible, std::list<WCDB::Syntax::Identifier::Type>());\n    TestCaseAssertTrue(constructible.getDescription().empty());\n}\n\n- (void)test_get_type\n{\n    TestCaseAssertEqual(WCDB::StatementCreateView().getType(), WCDB::SQL::Type::CreateViewSTMT);\n    TestCaseAssertEqual(WCDB::StatementCreateView::type, WCDB::SQL::Type::CreateViewSTMT);\n}\n\n- (void)test_create_view\n{\n    auto testingSQL = WCDB::StatementCreateView().createView(name).as(select);\n\n    auto testingTypes = { WCDB::SQL::Type::CreateViewSTMT, WCDB::SQL::Type::SelectSTMT, WCDB::SQL::Type::SelectCore, WCDB::SQL::Type::ResultColumn, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"CREATE VIEW testView AS SELECT 1\");\n}\n\n- (void)test_create_temp_view\n{\n    auto testingSQL = WCDB::StatementCreateView().createView(name).temp().as(select);\n\n    auto testingTypes = { WCDB::SQL::Type::CreateViewSTMT, WCDB::SQL::Type::SelectSTMT, WCDB::SQL::Type::SelectCore, WCDB::SQL::Type::ResultColumn, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"CREATE TEMP VIEW testView AS SELECT 1\");\n}\n\n- (void)test_create_view_if_not_exists\n{\n    auto testingSQL = WCDB::StatementCreateView().createView(name).ifNotExists().as(select);\n\n    auto testingTypes = { WCDB::SQL::Type::CreateViewSTMT, WCDB::SQL::Type::SelectSTMT, WCDB::SQL::Type::SelectCore, WCDB::SQL::Type::ResultColumn, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"CREATE VIEW IF NOT EXISTS testView AS SELECT 1\");\n}\n\n- (void)test_create_view_with_schema\n{\n    auto testingSQL = WCDB::StatementCreateView().createView(name).schema(schema).as(select);\n\n    auto testingTypes = { WCDB::SQL::Type::CreateViewSTMT, WCDB::SQL::Type::Schema, WCDB::SQL::Type::SelectSTMT, WCDB::SQL::Type::SelectCore, WCDB::SQL::Type::ResultColumn, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"CREATE VIEW testSchema.testView AS SELECT 1\");\n}\n\n- (void)test_create_view_with_columns\n{\n    auto testingSQL = WCDB::StatementCreateView().createView(name).columns(columns).as(select);\n\n    auto testingTypes = { WCDB::SQL::Type::CreateViewSTMT, WCDB::SQL::Type::Column, WCDB::SQL::Type::Column, WCDB::SQL::Type::SelectSTMT, WCDB::SQL::Type::SelectCore, WCDB::SQL::Type::ResultColumn, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"CREATE VIEW testView(testColumn1, testColumn2) AS SELECT 1\");\n}\n\n@end\n"
  },
  {
    "path": "src/objc/tests/winq/StatementCreateVirtualTableTests.mm",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"WINQAssertion.h\"\n#if TEST_WCDB_OBJC\n#import <WCDBOBjc/WCTFTSTokenizerUtil.h>\n#elif TEST_WCDB_CPP\n#import <WCDBCpp/WCTFTSTokenizerUtil.h>\n#else\n#import <WCDB/WCTFTSTokenizerUtil.h>\n#endif\n\n@interface StatementCreateVirtualTableTests : BaseTestCase\n\n@end\n\n@implementation StatementCreateVirtualTableTests {\n    WCDB::Schema schema;\n    NSString* table;\n    NSString* module;\n    WCDB::StringView argument1;\n    WCDB::ColumnDef argument2;\n}\n\n- (void)setUp\n{\n    [super setUp];\n    schema = @\"testSchema\";\n    table = @\"testTable\";\n    module = @\"testModule\";\n    argument1 = WCTFTSTokenizerUtil::tokenize(@\"testTokenize\", nil);\n    argument2 = WCDB::ColumnDef(WCDB::Column(@\"testColumn\"), WCDB::ColumnType::Integer);\n}\n\n- (void)test_default_constructible\n{\n    WCDB::StatementCreateVirtualTable constructible;\n    TestCaseAssertFalse(constructible.syntax().isValid());\n    TestCaseAssertIterateEqual(constructible, std::list<WCDB::Syntax::Identifier::Type>());\n    TestCaseAssertTrue(constructible.getDescription().empty());\n}\n\n- (void)test_get_type\n{\n    TestCaseAssertEqual(WCDB::StatementCreateVirtualTable().getType(), WCDB::SQL::Type::CreateVirtualTableSTMT);\n    TestCaseAssertEqual(WCDB::StatementCreateVirtualTable::type, WCDB::SQL::Type::CreateVirtualTableSTMT);\n}\n\n- (void)test_create_virtual_table\n{\n    auto testingSQL = WCDB::StatementCreateVirtualTable().createVirtualTable(table).schema(schema).usingModule(module).argument(argument1);\n\n    auto testingTypes = { WCDB::SQL::Type::CreateVirtualTableSTMT, WCDB::SQL::Type::Schema };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"CREATE VIRTUAL TABLE testSchema.testTable USING testModule(tokenize = testTokenize)\");\n}\n\n- (void)test_create_virtual_table_if_not_exists\n{\n    auto testingSQL = WCDB::StatementCreateVirtualTable().createVirtualTable(table).schema(schema).ifNotExists().usingModule(module).argument(argument1);\n\n    auto testingTypes = { WCDB::SQL::Type::CreateVirtualTableSTMT, WCDB::SQL::Type::Schema };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"CREATE VIRTUAL TABLE IF NOT EXISTS testSchema.testTable USING testModule(tokenize = testTokenize)\");\n}\n\n- (void)test_create_virtual_table_without_schema\n{\n    auto testingSQL = WCDB::StatementCreateVirtualTable().createVirtualTable(table).usingModule(module).argument(argument1);\n\n    auto testingTypes = { WCDB::SQL::Type::CreateVirtualTableSTMT };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"CREATE VIRTUAL TABLE testTable USING testModule(tokenize = testTokenize)\");\n}\n\n- (void)test_create_virtual_table_with_arguments\n{\n    auto testingSQL = WCDB::StatementCreateVirtualTable().createVirtualTable(table).schema(schema).usingModule(module).argument(argument1).argument(argument2);\n\n    auto testingTypes = { WCDB::SQL::Type::CreateVirtualTableSTMT, WCDB::SQL::Type::Schema };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"CREATE VIRTUAL TABLE testSchema.testTable USING testModule(tokenize = testTokenize, testColumn INTEGER)\");\n}\n\n- (void)test_create_virtual_table_without_argument\n{\n    auto testingSQL = WCDB::StatementCreateVirtualTable().createVirtualTable(table).schema(schema).usingModule(module);\n\n    auto testingTypes = { WCDB::SQL::Type::CreateVirtualTableSTMT, WCDB::SQL::Type::Schema };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"CREATE VIRTUAL TABLE testSchema.testTable USING testModule\");\n}\n\n@end\n"
  },
  {
    "path": "src/objc/tests/winq/StatementDeleteTests.mm",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"WINQAssertion.h\"\n\n@interface StatementDeleteTests : BaseTestCase\n\n@end\n\n@implementation StatementDeleteTests {\n    WCDB::CommonTableExpression with;\n    WCDB::QualifiedTable table;\n    WCDB::Expression condition;\n    WCDB::OrderingTerms orderingTerms;\n    WCDB::Expression limit;\n    WCDB::Expression limitParameter;\n}\n\n- (void)setUp\n{\n    [super setUp];\n    with = WCDB::CommonTableExpression(@\"testTable\").as(WCDB::StatementSelect().select(1));\n    table = @\"testTable\";\n    condition = 2;\n    orderingTerms = {\n        WCDB::Column(@\"testColumn1\"),\n        WCDB::Column(@\"testColumn2\"),\n    };\n    limit = 3;\n    limitParameter = 4;\n}\n\n- (void)test_default_constructible\n{\n    WCDB::StatementDelete constructible;\n    TestCaseAssertFalse(constructible.syntax().isValid());\n    TestCaseAssertIterateEqual(constructible, std::list<WCDB::Syntax::Identifier::Type>());\n    TestCaseAssertTrue(constructible.getDescription().empty());\n}\n\n- (void)test_get_type\n{\n    TestCaseAssertEqual(WCDB::StatementDelete().getType(), WCDB::SQL::Type::DeleteSTMT);\n    TestCaseAssertEqual(WCDB::StatementDelete::type, WCDB::SQL::Type::DeleteSTMT);\n}\n\n- (void)test_delete\n{\n    auto testingSQL = WCDB::StatementDelete().deleteFrom(table).where(condition).orders(orderingTerms).limit(limit).offset(limitParameter);\n\n    auto testingTypes = { WCDB::SQL::Type::DeleteSTMT, WCDB::SQL::Type::QualifiedTableName, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue, WCDB::SQL::Type::OrderingTerm, WCDB::SQL::Type::Expression, WCDB::SQL::Type::Column, WCDB::SQL::Type::OrderingTerm, WCDB::SQL::Type::Expression, WCDB::SQL::Type::Column, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"DELETE FROM testTable WHERE 2 ORDER BY testColumn1, testColumn2 LIMIT 3 OFFSET 4\");\n}\n\n- (void)test_delete_with\n{\n    auto testingSQL = WCDB::StatementDelete().with(with).deleteFrom(table).where(condition).orders(orderingTerms).limit(limit).offset(limitParameter);\n\n    auto testingTypes = { WCDB::SQL::Type::DeleteSTMT, WCDB::SQL::Type::CommonTableExpression, WCDB::SQL::Type::SelectSTMT, WCDB::SQL::Type::SelectCore, WCDB::SQL::Type::ResultColumn, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue, WCDB::SQL::Type::QualifiedTableName, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue, WCDB::SQL::Type::OrderingTerm, WCDB::SQL::Type::Expression, WCDB::SQL::Type::Column, WCDB::SQL::Type::OrderingTerm, WCDB::SQL::Type::Expression, WCDB::SQL::Type::Column, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"WITH testTable AS(SELECT 1) DELETE FROM testTable WHERE 2 ORDER BY testColumn1, testColumn2 LIMIT 3 OFFSET 4\");\n}\n\n- (void)test_delete_without_condition\n{\n    auto testingSQL = WCDB::StatementDelete().deleteFrom(table).orders(orderingTerms).limit(limit).offset(limitParameter);\n\n    auto testingTypes = { WCDB::SQL::Type::DeleteSTMT, WCDB::SQL::Type::QualifiedTableName, WCDB::SQL::Type::OrderingTerm, WCDB::SQL::Type::Expression, WCDB::SQL::Type::Column, WCDB::SQL::Type::OrderingTerm, WCDB::SQL::Type::Expression, WCDB::SQL::Type::Column, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"DELETE FROM testTable ORDER BY testColumn1, testColumn2 LIMIT 3 OFFSET 4\");\n}\n\n- (void)test_delete_without_orders\n{\n    auto testingSQL = WCDB::StatementDelete().deleteFrom(table).where(condition).limit(limit).offset(limitParameter);\n\n    auto testingTypes = { WCDB::SQL::Type::DeleteSTMT, WCDB::SQL::Type::QualifiedTableName, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"DELETE FROM testTable WHERE 2 LIMIT 3 OFFSET 4\");\n}\n\n- (void)test_delete_with_length\n{\n    auto testingSQL = WCDB::StatementDelete().deleteFrom(table).where(condition).orders(orderingTerms).limit(limit, limitParameter);\n\n    auto testingTypes = { WCDB::SQL::Type::DeleteSTMT, WCDB::SQL::Type::QualifiedTableName, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue, WCDB::SQL::Type::OrderingTerm, WCDB::SQL::Type::Expression, WCDB::SQL::Type::Column, WCDB::SQL::Type::OrderingTerm, WCDB::SQL::Type::Expression, WCDB::SQL::Type::Column, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"DELETE FROM testTable WHERE 2 ORDER BY testColumn1, testColumn2 LIMIT 3, 4\");\n}\n\n- (void)test_delete_without_offset\n{\n    auto testingSQL = WCDB::StatementDelete().deleteFrom(table).where(condition).orders(orderingTerms).limit(limit);\n\n    auto testingTypes = { WCDB::SQL::Type::DeleteSTMT, WCDB::SQL::Type::QualifiedTableName, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue, WCDB::SQL::Type::OrderingTerm, WCDB::SQL::Type::Expression, WCDB::SQL::Type::Column, WCDB::SQL::Type::OrderingTerm, WCDB::SQL::Type::Expression, WCDB::SQL::Type::Column, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"DELETE FROM testTable WHERE 2 ORDER BY testColumn1, testColumn2 LIMIT 3\");\n}\n\n@end\n"
  },
  {
    "path": "src/objc/tests/winq/StatementDetachTests.mm",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"WINQAssertion.h\"\n\n@interface StatementDetachTests : BaseTestCase\n\n@end\n\n@implementation StatementDetachTests {\n    WCDB::Schema schema;\n}\n\n- (void)setUp\n{\n    [super setUp];\n    schema = @\"testSchema\";\n}\n\n- (void)test_default_constructible\n{\n    WCDB::StatementDetach constructible;\n    TestCaseAssertFalse(constructible.syntax().isValid());\n    TestCaseAssertIterateEqual(constructible, std::list<WCDB::Syntax::Identifier::Type>());\n    TestCaseAssertTrue(constructible.getDescription().empty());\n}\n\n- (void)test_get_type\n{\n    TestCaseAssertEqual(WCDB::StatementDetach().getType(), WCDB::SQL::Type::DetachSTMT);\n    TestCaseAssertEqual(WCDB::StatementDetach::type, WCDB::SQL::Type::DetachSTMT);\n}\n\n- (void)test_detach\n{\n    auto testingSQL = WCDB::StatementDetach().detach(schema);\n\n    auto testingTypes = { WCDB::SQL::Type::DetachSTMT, WCDB::SQL::Type::Schema };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"DETACH testSchema\");\n}\n\n@end\n"
  },
  {
    "path": "src/objc/tests/winq/StatementDropIndexTests.mm",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"WINQAssertion.h\"\n\n@interface StatementDropIndexTests : BaseTestCase\n\n@end\n\n@implementation StatementDropIndexTests {\n    WCDB::Schema schema;\n    NSString* index;\n}\n\n- (void)setUp\n{\n    [super setUp];\n    schema = @\"testSchema\";\n    index = @\"testIndex\";\n}\n\n- (void)test_default_constructible\n{\n    WCDB::StatementDropIndex constructible;\n    TestCaseAssertFalse(constructible.syntax().isValid());\n    TestCaseAssertIterateEqual(constructible, std::list<WCDB::Syntax::Identifier::Type>());\n    TestCaseAssertTrue(constructible.getDescription().empty());\n}\n\n- (void)test_get_type\n{\n    TestCaseAssertEqual(WCDB::StatementDropIndex().getType(), WCDB::SQL::Type::DropIndexSTMT);\n    TestCaseAssertEqual(WCDB::StatementDropIndex::type, WCDB::SQL::Type::DropIndexSTMT);\n}\n\n- (void)test_drop_index\n{\n    auto testingSQL = WCDB::StatementDropIndex().dropIndex(index).schema(schema).ifExists();\n\n    auto testingTypes = { WCDB::SQL::Type::DropIndexSTMT, WCDB::SQL::Type::Schema };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"DROP INDEX IF EXISTS testSchema.testIndex\");\n}\n\n- (void)test_drop_index_without_if_exists\n{\n    auto testingSQL = WCDB::StatementDropIndex().dropIndex(index).schema(schema);\n\n    auto testingTypes = { WCDB::SQL::Type::DropIndexSTMT, WCDB::SQL::Type::Schema };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"DROP INDEX testSchema.testIndex\");\n}\n\n- (void)test_drop_index_without_schema\n{\n    auto testingSQL = WCDB::StatementDropIndex().dropIndex(index).ifExists();\n\n    auto testingTypes = { WCDB::SQL::Type::DropIndexSTMT };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"DROP INDEX IF EXISTS testIndex\");\n}\n\n@end\n"
  },
  {
    "path": "src/objc/tests/winq/StatementDropTableTests.mm",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"WINQAssertion.h\"\n\n@interface StatementDropTableTests : BaseTestCase\n\n@end\n\n@implementation StatementDropTableTests {\n    WCDB::Schema schema;\n    NSString* table;\n}\n\n- (void)setUp\n{\n    [super setUp];\n    schema = @\"testSchema\";\n    table = @\"testTable\";\n}\n\n- (void)test_default_constructible\n{\n    WCDB::StatementDropTable constructible;\n    TestCaseAssertFalse(constructible.syntax().isValid());\n    TestCaseAssertIterateEqual(constructible, std::list<WCDB::Syntax::Identifier::Type>());\n    TestCaseAssertTrue(constructible.getDescription().empty());\n}\n\n- (void)test_get_type\n{\n    TestCaseAssertEqual(WCDB::StatementDropTable().getType(), WCDB::SQL::Type::DropTableSTMT);\n    TestCaseAssertEqual(WCDB::StatementDropTable::type, WCDB::SQL::Type::DropTableSTMT);\n}\n\n- (void)test_drop_table\n{\n    auto testingSQL = WCDB::StatementDropTable().dropTable(table).schema(schema).ifExists();\n\n    auto testingTypes = { WCDB::SQL::Type::DropTableSTMT, WCDB::SQL::Type::Schema };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"DROP TABLE IF EXISTS testSchema.testTable\");\n}\n\n- (void)test_drop_table_without_if_exists\n{\n    auto testingSQL = WCDB::StatementDropTable().dropTable(table).schema(schema);\n\n    auto testingTypes = { WCDB::SQL::Type::DropTableSTMT, WCDB::SQL::Type::Schema };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"DROP TABLE testSchema.testTable\");\n}\n\n- (void)test_drop_table_without_schema\n{\n    auto testingSQL = WCDB::StatementDropTable().dropTable(table).ifExists();\n\n    auto testingTypes = { WCDB::SQL::Type::DropTableSTMT };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"DROP TABLE IF EXISTS testTable\");\n}\n\n@end\n"
  },
  {
    "path": "src/objc/tests/winq/StatementDropTriggerTests.mm",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"WINQAssertion.h\"\n\n@interface StatementDropTriggerTests : BaseTestCase\n\n@end\n\n@implementation StatementDropTriggerTests {\n    WCDB::Schema schema;\n    NSString* trigger;\n}\n\n- (void)setUp\n{\n    [super setUp];\n    schema = @\"testSchema\";\n    trigger = @\"testTrigger\";\n}\n\n- (void)test_default_constructible\n{\n    WCDB::StatementDropTrigger constructible;\n    TestCaseAssertFalse(constructible.syntax().isValid());\n    TestCaseAssertIterateEqual(constructible, std::list<WCDB::Syntax::Identifier::Type>());\n    TestCaseAssertTrue(constructible.getDescription().empty());\n}\n\n- (void)test_get_type\n{\n    TestCaseAssertEqual(WCDB::StatementDropTrigger().getType(), WCDB::SQL::Type::DropTriggerSTMT);\n    TestCaseAssertEqual(WCDB::StatementDropTrigger::type, WCDB::SQL::Type::DropTriggerSTMT);\n}\n\n- (void)test_drop_trigger\n{\n    auto testingSQL = WCDB::StatementDropTrigger().dropTrigger(trigger).schema(schema).ifExists();\n\n    auto testingTypes = { WCDB::SQL::Type::DropTriggerSTMT, WCDB::SQL::Type::Schema };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"DROP TRIGGER IF EXISTS testSchema.testTrigger\");\n}\n\n- (void)test_drop_trigger_without_if_exists\n{\n    auto testingSQL = WCDB::StatementDropTrigger().dropTrigger(trigger).schema(schema);\n\n    auto testingTypes = { WCDB::SQL::Type::DropTriggerSTMT, WCDB::SQL::Type::Schema };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"DROP TRIGGER testSchema.testTrigger\");\n}\n\n- (void)test_drop_trigger_without_schema\n{\n    auto testingSQL = WCDB::StatementDropTrigger().dropTrigger(trigger).ifExists();\n\n    auto testingTypes = { WCDB::SQL::Type::DropTriggerSTMT };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"DROP TRIGGER IF EXISTS testTrigger\");\n}\n\n@end\n"
  },
  {
    "path": "src/objc/tests/winq/StatementDropViewTests.mm",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"WINQAssertion.h\"\n\n@interface StatementDropViewTests : BaseTestCase\n\n@end\n\n@implementation StatementDropViewTests {\n    WCDB::Schema schema;\n    NSString* view;\n}\n\n- (void)setUp\n{\n    [super setUp];\n    schema = @\"testSchema\";\n    view = @\"testView\";\n}\n\n- (void)test_default_constructible\n{\n    WCDB::StatementDropView constructible;\n    TestCaseAssertFalse(constructible.syntax().isValid());\n    TestCaseAssertIterateEqual(constructible, std::list<WCDB::Syntax::Identifier::Type>());\n    TestCaseAssertTrue(constructible.getDescription().empty());\n}\n\n- (void)test_get_type\n{\n    TestCaseAssertEqual(WCDB::StatementDropView().getType(), WCDB::SQL::Type::DropViewSTMT);\n    TestCaseAssertEqual(WCDB::StatementDropView::type, WCDB::SQL::Type::DropViewSTMT);\n}\n\n- (void)test_drop_view\n{\n    auto testingSQL = WCDB::StatementDropView().dropView(view).schema(schema).ifExists();\n\n    auto testingTypes = { WCDB::SQL::Type::DropViewSTMT, WCDB::SQL::Type::Schema };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"DROP VIEW IF EXISTS testSchema.testView\");\n}\n\n- (void)test_drop_view_without_if_exists\n{\n    auto testingSQL = WCDB::StatementDropView().dropView(view).schema(schema);\n\n    auto testingTypes = { WCDB::SQL::Type::DropViewSTMT, WCDB::SQL::Type::Schema };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"DROP VIEW testSchema.testView\");\n}\n\n- (void)test_drop_view_without_schema\n{\n    auto testingSQL = WCDB::StatementDropView().dropView(view).ifExists();\n\n    auto testingTypes = { WCDB::SQL::Type::DropViewSTMT };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"DROP VIEW IF EXISTS testView\");\n}\n\n@end\n"
  },
  {
    "path": "src/objc/tests/winq/StatementExplainTests.mm",
    "content": "//\n// Created by sanhuazhang on 2019/08/30\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"WINQAssertion.h\"\n\n@interface StatementExplainTests : BaseTestCase\n\n@end\n\n@implementation StatementExplainTests {\n    WCDB::StatementSelect select;\n    WCDB::StatementPragma pragma;\n}\n\n- (void)setUp\n{\n    [super setUp];\n    select = WCDB::StatementSelect().select(1);\n    pragma = WCDB::StatementPragma().pragma(WCDB::Pragma::integrityCheck());\n}\n\n- (void)test_default_constructible\n{\n    WCDB::StatementExplain constructible;\n    TestCaseAssertFalse(constructible.syntax().isValid());\n    TestCaseAssertIterateEqual(constructible, std::list<WCDB::Syntax::Identifier::Type>());\n    TestCaseAssertTrue(constructible.getDescription().empty());\n}\n\n- (void)test_get_type\n{\n    TestCaseAssertEqual(WCDB::StatementExplain().getType(), WCDB::SQL::Type::ExplainSTMT);\n    TestCaseAssertEqual(WCDB::StatementExplain::type, WCDB::SQL::Type::ExplainSTMT);\n}\n\n- (void)test_explain\n{\n    auto testingSQL = WCDB::StatementExplain().explain(select);\n\n    auto testingTypes = { WCDB::SQL::Type::ExplainSTMT, WCDB::SQL::Type::SelectSTMT, WCDB::SQL::Type::SelectCore, WCDB::SQL::Type::ResultColumn, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"EXPLAIN SELECT 1\");\n}\n\n- (void)test_explain_query_plan\n{\n    auto testingSQL = WCDB::StatementExplain().explainQueryPlan(pragma);\n\n    auto testingTypes = { WCDB::SQL::Type::ExplainSTMT, WCDB::SQL::Type::PragmaSTMT, WCDB::SQL::Type::Pragma };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"EXPLAIN QUERY PLAN PRAGMA integrity_check\");\n}\n\n@end\n"
  },
  {
    "path": "src/objc/tests/winq/StatementInsertTests.mm",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"WINQAssertion.h\"\n\n@interface StatementInsertTests : BaseTestCase\n\n@end\n\n@implementation StatementInsertTests {\n    WCDB::CommonTableExpression with;\n    WCDB::Schema schema;\n    NSString* table;\n    NSString* alias;\n    WCDB::Column column1;\n    WCDB::Column column2;\n    WCDB::Columns columns;\n    WCDB::Expression expression1;\n    WCDB::Expression expression2;\n    WCDB::Expressions expressions1;\n    WCDB::Expressions expressions2;\n    WCDB::Upsert upsert;\n    WCDB::StatementSelect select;\n}\n\n- (void)setUp\n{\n    [super setUp];\n    with = WCDB::CommonTableExpression(@\"testTable\").as(WCDB::StatementSelect().select(1));\n    schema = @\"testSchema\";\n    table = @\"testTable\";\n    alias = @\"testAliasTable\";\n    column1 = WCDB::Column(@\"testColumn1\");\n    column2 = WCDB::Column(@\"testColumn2\");\n    columns = {\n        column1,\n        column2,\n    };\n    expression1 = 1;\n    expression2 = 2;\n    expressions1 = {\n        1,\n        2,\n    };\n    expressions2 = {\n        3,\n        4,\n    };\n    upsert = WCDB::Upsert().onConflict().doNothing();\n    select = WCDB::StatementSelect().select(1);\n}\n\n- (void)test_default_constructible\n{\n    WCDB::StatementInsert constructible;\n    TestCaseAssertFalse(constructible.syntax().isValid());\n    TestCaseAssertIterateEqual(constructible, std::list<WCDB::Syntax::Identifier::Type>());\n    TestCaseAssertTrue(constructible.getDescription().empty());\n}\n\n- (void)test_get_type\n{\n    TestCaseAssertEqual(WCDB::StatementInsert().getType(), WCDB::SQL::Type::InsertSTMT);\n    TestCaseAssertEqual(WCDB::StatementInsert::type, WCDB::SQL::Type::InsertSTMT);\n}\n\n- (void)test_insert\n{\n    auto testingSQL = WCDB::StatementInsert().insertIntoTable(table).schema(schema).column(column1).values(expressions1);\n\n    auto testingTypes = { WCDB::SQL::Type::InsertSTMT, WCDB::SQL::Type::Schema, WCDB::SQL::Type::Column, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"INSERT INTO testSchema.testTable(testColumn1) VALUES(1, 2)\");\n}\n\n- (void)test_insert_with_seperated_columns\n{\n    auto testingSQL = WCDB::StatementInsert().insertIntoTable(table).schema(schema).column(column1).column(column2).values(expressions1);\n\n    auto testingTypes = { WCDB::SQL::Type::InsertSTMT, WCDB::SQL::Type::Schema, WCDB::SQL::Type::Column, WCDB::SQL::Type::Column, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"INSERT INTO testSchema.testTable(testColumn1, testColumn2) VALUES(1, 2)\");\n}\n\n- (void)test_insert_with_columns\n{\n    auto testingSQL = WCDB::StatementInsert().insertIntoTable(table).schema(schema).columns(columns).values(expressions1);\n\n    auto testingTypes = { WCDB::SQL::Type::InsertSTMT, WCDB::SQL::Type::Schema, WCDB::SQL::Type::Column, WCDB::SQL::Type::Column, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"INSERT INTO testSchema.testTable(testColumn1, testColumn2) VALUES(1, 2)\");\n}\n\n- (void)test_insert_or_replace\n{\n    auto testingSQL = WCDB::StatementInsert().insertIntoTable(table).schema(schema).orReplace().column(column1).values(expressions1);\n\n    auto testingTypes = { WCDB::SQL::Type::InsertSTMT, WCDB::SQL::Type::Schema, WCDB::SQL::Type::Column, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"INSERT OR REPLACE INTO testSchema.testTable(testColumn1) VALUES(1, 2)\");\n}\n\n- (void)test_insert_or_rollback\n{\n    auto testingSQL = WCDB::StatementInsert().insertIntoTable(table).schema(schema).orRollback().column(column1).values(expressions1);\n\n    auto testingTypes = { WCDB::SQL::Type::InsertSTMT, WCDB::SQL::Type::Schema, WCDB::SQL::Type::Column, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"INSERT OR ROLLBACK INTO testSchema.testTable(testColumn1) VALUES(1, 2)\");\n}\n\n- (void)test_insert_or_abort\n{\n    auto testingSQL = WCDB::StatementInsert().insertIntoTable(table).schema(schema).orAbort().column(column1).values(expressions1);\n\n    auto testingTypes = { WCDB::SQL::Type::InsertSTMT, WCDB::SQL::Type::Schema, WCDB::SQL::Type::Column, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"INSERT OR ABORT INTO testSchema.testTable(testColumn1) VALUES(1, 2)\");\n}\n\n- (void)test_insert_or_fail\n{\n    auto testingSQL = WCDB::StatementInsert().insertIntoTable(table).schema(schema).orFail().column(column1).values(expressions1);\n\n    auto testingTypes = { WCDB::SQL::Type::InsertSTMT, WCDB::SQL::Type::Schema, WCDB::SQL::Type::Column, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"INSERT OR FAIL INTO testSchema.testTable(testColumn1) VALUES(1, 2)\");\n}\n\n- (void)test_insert_or_ignore\n{\n    auto testingSQL = WCDB::StatementInsert().insertIntoTable(table).schema(schema).orIgnore().column(column1).values(expressions1);\n\n    auto testingTypes = { WCDB::SQL::Type::InsertSTMT, WCDB::SQL::Type::Schema, WCDB::SQL::Type::Column, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"INSERT OR IGNORE INTO testSchema.testTable(testColumn1) VALUES(1, 2)\");\n}\n\n- (void)test_insert_with\n{\n    auto testingSQL = WCDB::StatementInsert().with(with).insertIntoTable(table).schema(schema).column(column1).values(expressions1);\n\n    auto testingTypes = { WCDB::SQL::Type::InsertSTMT, WCDB::SQL::Type::CommonTableExpression, WCDB::SQL::Type::SelectSTMT, WCDB::SQL::Type::SelectCore, WCDB::SQL::Type::ResultColumn, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue, WCDB::SQL::Type::Schema, WCDB::SQL::Type::Column, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"WITH testTable AS(SELECT 1) INSERT INTO testSchema.testTable(testColumn1) VALUES(1, 2)\");\n}\n\n- (void)test_insert_without_schema\n{\n    auto testingSQL = WCDB::StatementInsert().insertIntoTable(table).column(column1).values(expressions1);\n\n    auto testingTypes = { WCDB::SQL::Type::InsertSTMT, WCDB::SQL::Type::Column, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"INSERT INTO testTable(testColumn1) VALUES(1, 2)\");\n}\n\n- (void)test_insert_with_alias\n{\n    auto testingSQL = WCDB::StatementInsert().insertIntoTable(table).schema(schema).as(alias).column(column1).values(expressions1);\n\n    auto testingTypes = { WCDB::SQL::Type::InsertSTMT, WCDB::SQL::Type::Schema, WCDB::SQL::Type::Column, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"INSERT INTO testSchema.testTable AS testAliasTable(testColumn1) VALUES(1, 2)\");\n}\n\n- (void)test_insert_with_multiple_values\n{\n    auto testingSQL = WCDB::StatementInsert().insertIntoTable(table).schema(schema).column(column1).values(expressions1).values(expressions2);\n\n    auto testingTypes = { WCDB::SQL::Type::InsertSTMT, WCDB::SQL::Type::Schema, WCDB::SQL::Type::Column, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"INSERT INTO testSchema.testTable(testColumn1) VALUES(1, 2), (3, 4)\");\n}\n\n- (void)test_insert_with_seperated_values\n{\n    auto testingSQL = WCDB::StatementInsert().insertIntoTable(table).schema(schema).column(column1).value(expression1).value(expression2);\n\n    auto testingTypes = { WCDB::SQL::Type::InsertSTMT, WCDB::SQL::Type::Schema, WCDB::SQL::Type::Column, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"INSERT INTO testSchema.testTable(testColumn1) VALUES(1, 2)\");\n}\n\n- (void)test_insert_with_select\n{\n    auto testingSQL = WCDB::StatementInsert().insertIntoTable(table).schema(schema).column(column1).values(select);\n\n    auto testingTypes = { WCDB::SQL::Type::InsertSTMT, WCDB::SQL::Type::Schema, WCDB::SQL::Type::Column, WCDB::SQL::Type::SelectSTMT, WCDB::SQL::Type::SelectCore, WCDB::SQL::Type::ResultColumn, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"INSERT INTO testSchema.testTable(testColumn1) SELECT 1\");\n}\n\n- (void)test_insert_with_default_values\n{\n    auto testingSQL = WCDB::StatementInsert().insertIntoTable(table).schema(schema).column(column1).defaultValues();\n\n    auto testingTypes = { WCDB::SQL::Type::InsertSTMT, WCDB::SQL::Type::Schema, WCDB::SQL::Type::Column };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"INSERT INTO testSchema.testTable(testColumn1) DEFAULT VALUES\");\n}\n\n- (void)test_insert_with_upsert\n{\n    auto testingSQL = WCDB::StatementInsert().insertIntoTable(table).schema(schema).column(column1).values(expressions1).upsert(upsert);\n\n    auto testingTypes = { WCDB::SQL::Type::InsertSTMT, WCDB::SQL::Type::Schema, WCDB::SQL::Type::Column, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue, WCDB::SQL::Type::UpsertClause };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"INSERT INTO testSchema.testTable(testColumn1) VALUES(1, 2) ON CONFLICT DO NOTHING\");\n}\n@end\n"
  },
  {
    "path": "src/objc/tests/winq/StatementPragmaTests.mm",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"WINQAssertion.h\"\n\n@interface StatementPragmaTests : BaseTestCase\n\n@end\n\n@implementation StatementPragmaTests {\n    WCDB::Pragma pragma;\n    WCDB::Schema schema;\n    WCDB::LiteralValue value;\n}\n\n- (void)setUp\n{\n    [super setUp];\n    pragma = @\"testPragma\";\n    schema = @\"testSchema\";\n    value = 1;\n}\n\n- (void)test_default_constructible\n{\n    WCDB::StatementPragma constructible;\n    TestCaseAssertFalse(constructible.syntax().isValid());\n    TestCaseAssertIterateEqual(constructible, std::list<WCDB::Syntax::Identifier::Type>());\n    TestCaseAssertTrue(constructible.getDescription().empty());\n}\n\n- (void)test_get_type\n{\n    TestCaseAssertEqual(WCDB::StatementPragma().getType(), WCDB::SQL::Type::PragmaSTMT);\n    TestCaseAssertEqual(WCDB::StatementPragma::type, WCDB::SQL::Type::PragmaSTMT);\n}\n\n- (void)test_pragma\n{\n    auto testingSQL = WCDB::StatementPragma().pragma(pragma).schema(schema);\n\n    auto testingTypes = { WCDB::SQL::Type::PragmaSTMT, WCDB::SQL::Type::Schema, WCDB::SQL::Type::Pragma };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"PRAGMA testSchema.testPragma\");\n}\n\n- (void)test_pragma_to\n{\n    auto testingSQL = WCDB::StatementPragma().pragma(pragma).schema(schema).to(value);\n\n    auto testingTypes = { WCDB::SQL::Type::PragmaSTMT, WCDB::SQL::Type::Schema, WCDB::SQL::Type::Pragma, WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"PRAGMA testSchema.testPragma = 1\");\n}\n\n- (void)test_pragma_to_without_schema\n{\n    auto testingSQL = WCDB::StatementPragma().pragma(pragma).to(value);\n\n    auto testingTypes = { WCDB::SQL::Type::PragmaSTMT, WCDB::SQL::Type::Pragma, WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"PRAGMA testPragma = 1\");\n}\n\n- (void)test_pragma_with\n{\n    auto testingSQL = WCDB::StatementPragma().pragma(pragma).schema(schema).with(value);\n\n    auto testingTypes = { WCDB::SQL::Type::PragmaSTMT, WCDB::SQL::Type::Schema, WCDB::SQL::Type::Pragma, WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"PRAGMA testSchema.testPragma(1)\");\n}\n\n@end\n"
  },
  {
    "path": "src/objc/tests/winq/StatementReindexTests.mm",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"WINQAssertion.h\"\n\n@interface StatementReindexTests : BaseTestCase\n\n@end\n\n@implementation StatementReindexTests {\n    WCDB::Schema schema;\n    NSString* collation;\n    NSString* table;\n    NSString* index;\n}\n\n- (void)setUp\n{\n    [super setUp];\n    collation = @\"testCollation\";\n    schema = @\"testSchema\";\n    table = @\"testTable\";\n    index = @\"testIndex\";\n}\n\n- (void)test_default_constructible\n{\n    WCDB::StatementReindex constructible;\n    TestCaseAssertFalse(constructible.syntax().isValid());\n    TestCaseAssertIterateEqual(constructible, std::list<WCDB::Syntax::Identifier::Type>());\n    TestCaseAssertTrue(constructible.getDescription().empty());\n}\n\n- (void)test_get_type\n{\n    TestCaseAssertEqual(WCDB::StatementReindex().getType(), WCDB::SQL::Type::ReindexSTMT);\n    TestCaseAssertEqual(WCDB::StatementReindex::type, WCDB::SQL::Type::ReindexSTMT);\n}\n\n- (void)test_reindex\n{\n    auto testingSQL = WCDB::StatementReindex().reindex();\n\n    auto testingTypes = { WCDB::SQL::Type::ReindexSTMT };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"REINDEX\");\n}\n\n- (void)test_reindex_collation\n{\n    auto testingSQL = WCDB::StatementReindex().reindex().collation(collation);\n\n    auto testingTypes = { WCDB::SQL::Type::ReindexSTMT };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"REINDEX testCollation\");\n}\n\n- (void)test_reindex_table\n{\n    auto testingSQL = WCDB::StatementReindex().reindex().schema(schema).table(table);\n\n    auto testingTypes = { WCDB::SQL::Type::ReindexSTMT, WCDB::SQL::Type::Schema };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"REINDEX testSchema.testTable\");\n}\n\n- (void)test_reindex_table_without_schema\n{\n    auto testingSQL = WCDB::StatementReindex().reindex().table(table);\n\n    auto testingTypes = { WCDB::SQL::Type::ReindexSTMT };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"REINDEX testTable\");\n}\n\n- (void)test_reindex_index\n{\n    auto testingSQL = WCDB::StatementReindex().reindex().schema(schema).index(index);\n\n    auto testingTypes = { WCDB::SQL::Type::ReindexSTMT, WCDB::SQL::Type::Schema };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"REINDEX testSchema.testIndex\");\n}\n\n- (void)test_reindex_index_without_schema\n{\n    auto testingSQL = WCDB::StatementReindex().reindex().index(index);\n\n    auto testingTypes = { WCDB::SQL::Type::ReindexSTMT };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"REINDEX testIndex\");\n}\n\n@end\n"
  },
  {
    "path": "src/objc/tests/winq/StatementReleaseTests.mm",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"WINQAssertion.h\"\n\n@interface StatementReleaseTests : BaseTestCase\n\n@end\n\n@implementation StatementReleaseTests {\n    NSString* savepoint;\n}\n\n- (void)setUp\n{\n    [super setUp];\n    savepoint = @\"testSavepoint\";\n}\n\n- (void)test_default_constructible\n{\n    WCDB::StatementRelease constructible;\n    TestCaseAssertFalse(constructible.syntax().isValid());\n    TestCaseAssertIterateEqual(constructible, std::list<WCDB::Syntax::Identifier::Type>());\n    TestCaseAssertTrue(constructible.getDescription().empty());\n}\n\n- (void)test_get_type\n{\n    TestCaseAssertEqual(WCDB::StatementRelease().getType(), WCDB::SQL::Type::ReleaseSTMT);\n    TestCaseAssertEqual(WCDB::StatementRelease::type, WCDB::SQL::Type::ReleaseSTMT);\n}\n\n- (void)test_release\n{\n    auto testingSQL = WCDB::StatementRelease().release(savepoint);\n\n    auto testingTypes = { WCDB::SQL::Type::ReleaseSTMT };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"RELEASE testSavepoint\");\n}\n\n@end\n"
  },
  {
    "path": "src/objc/tests/winq/StatementRollbackTests.mm",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"WINQAssertion.h\"\n\n@interface StatementRollbackTests : BaseTestCase\n\n@end\n\n@implementation StatementRollbackTests {\n    NSString* savepoint;\n}\n\n- (void)setUp\n{\n    [super setUp];\n    savepoint = @\"testSavepoint\";\n}\n\n- (void)test_default_constructible\n{\n    WCDB::StatementRollback constructible;\n    TestCaseAssertFalse(constructible.syntax().isValid());\n    TestCaseAssertIterateEqual(constructible, std::list<WCDB::Syntax::Identifier::Type>());\n    TestCaseAssertTrue(constructible.getDescription().empty());\n}\n\n- (void)test_get_type\n{\n    TestCaseAssertEqual(WCDB::StatementRollback().getType(), WCDB::SQL::Type::RollbackSTMT);\n    TestCaseAssertEqual(WCDB::StatementRollback::type, WCDB::SQL::Type::RollbackSTMT);\n}\n\n- (void)test_rollback\n{\n    auto testingSQL = WCDB::StatementRollback().rollback();\n\n    auto testingTypes = { WCDB::SQL::Type::RollbackSTMT };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"ROLLBACK\");\n}\n\n- (void)test_rollback_savepoint\n{\n    auto testingSQL = WCDB::StatementRollback().rollbackToSavepoint(savepoint);\n\n    auto testingTypes = { WCDB::SQL::Type::RollbackSTMT };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"ROLLBACK TO testSavepoint\");\n}\n\n@end\n"
  },
  {
    "path": "src/objc/tests/winq/StatementSavepointTests.mm",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"WINQAssertion.h\"\n\n@interface StatementSavepointTests : BaseTestCase\n\n@end\n\n@implementation StatementSavepointTests {\n    NSString* savepoint;\n}\n\n- (void)setUp\n{\n    [super setUp];\n    savepoint = @\"testSavepoint\";\n}\n\n- (void)test_default_constructible\n{\n    WCDB::StatementSavepoint constructible;\n    TestCaseAssertFalse(constructible.syntax().isValid());\n    TestCaseAssertIterateEqual(constructible, std::list<WCDB::Syntax::Identifier::Type>());\n    TestCaseAssertTrue(constructible.getDescription().empty());\n}\n\n- (void)test_get_type\n{\n    TestCaseAssertEqual(WCDB::StatementSavepoint().getType(), WCDB::SQL::Type::SavepointSTMT);\n    TestCaseAssertEqual(WCDB::StatementSavepoint::type, WCDB::SQL::Type::SavepointSTMT);\n}\n\n- (void)test_savepoint\n{\n    auto testingSQL = WCDB::StatementSavepoint().savepoint(savepoint);\n\n    auto testingTypes = { WCDB::SQL::Type::SavepointSTMT };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"SAVEPOINT testSavepoint\");\n}\n\n@end\n"
  },
  {
    "path": "src/objc/tests/winq/StatementSelectTests.mm",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"WINQAssertion.h\"\n\n@interface StatementSelectTests : BaseTestCase\n\n@end\n\n@implementation StatementSelectTests {\n    WCDB::CommonTableExpressions commonTableExpressions;\n    WCDB::ResultColumns resultColumns;\n    WCDB::TablesOrSubqueries tablesOrSubqueries;\n    WCDB::Join join;\n    WCDB::Expression condition;\n    WCDB::Expression group1;\n    WCDB::Expression group2;\n    WCDB::Expressions groups;\n    WCDB::Expression having;\n    NSString* window1;\n    WCDB::WindowDef windowDef1;\n    NSString* window2;\n    WCDB::WindowDef windowDef2;\n    WCDB::Expression value1;\n    WCDB::Expression value2;\n    WCDB::Expressions values;\n    WCDB::OrderingTerms orderingTerms;\n    WCDB::OrderingTerm orderingTerm1;\n    WCDB::OrderingTerm orderingTerm2;\n    WCDB::Expression limit;\n    WCDB::Expression limitParameter;\n}\n\n- (void)setUp\n{\n    [super setUp];\n    commonTableExpressions = {\n        WCDB::CommonTableExpression(@\"testTable1\").column(WCDB::Column(@\"testColumn1\")).as(WCDB::StatementSelect().select(1)),\n        WCDB::CommonTableExpression(@\"testTable2\").column(WCDB::Column(@\"testColumn2\")).as(WCDB::StatementSelect().select(2)),\n    };\n    resultColumns = {\n        1,\n        2,\n    };\n    tablesOrSubqueries = {\n        @\"testTable1\",\n        @\"testTable2\",\n    };\n    join = WCDB::Join().table(@\"testTable\");\n    condition = 1;\n    group1 = 1;\n    group2 = 2;\n    groups = {\n        group1,\n        group2,\n    };\n    orderingTerm1 = 1;\n    orderingTerm2 = 2;\n    orderingTerms = {\n        orderingTerm1,\n        orderingTerm2,\n    };\n    having = 1;\n    window1 = @\"testWindow1\";\n    windowDef1 = WCDB::WindowDef().order(1);\n    window2 = @\"testWindow2\";\n    windowDef2 = WCDB::WindowDef().order(2);\n    value1 = 1;\n    value2 = 2;\n    values = {\n        value1,\n        value2,\n    };\n    limit = 1;\n    limitParameter = 2;\n}\n\n- (void)test_default_constructible\n{\n    WCDB::StatementSelect constructible;\n    TestCaseAssertFalse(constructible.syntax().isValid());\n    TestCaseAssertIterateEqual(constructible, std::list<WCDB::Syntax::Identifier::Type>());\n    TestCaseAssertTrue(constructible.getDescription().empty());\n}\n\n- (void)test_get_type\n{\n    TestCaseAssertEqual(WCDB::StatementSelect().getType(), WCDB::SQL::Type::SelectSTMT);\n    TestCaseAssertEqual(WCDB::StatementSelect::type, WCDB::SQL::Type::SelectSTMT);\n}\n\n- (void)test_select\n{\n    auto testingSQL = WCDB::StatementSelect().select(resultColumns);\n\n    auto testingTypes = { WCDB::SQL::Type::SelectSTMT, WCDB::SQL::Type::SelectCore, WCDB::SQL::Type::ResultColumn, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue, WCDB::SQL::Type::ResultColumn, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"SELECT 1, 2\");\n}\n\n- (void)test_with_select\n{\n    auto testingSQL = WCDB::StatementSelect().with(commonTableExpressions).select(resultColumns);\n\n    auto testingTypes = { WCDB::SQL::Type::SelectSTMT, WCDB::SQL::Type::CommonTableExpression, WCDB::SQL::Type::Column, WCDB::SQL::Type::SelectSTMT, WCDB::SQL::Type::SelectCore, WCDB::SQL::Type::ResultColumn, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue, WCDB::SQL::Type::CommonTableExpression, WCDB::SQL::Type::Column, WCDB::SQL::Type::SelectSTMT, WCDB::SQL::Type::SelectCore, WCDB::SQL::Type::ResultColumn, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue, WCDB::SQL::Type::SelectCore, WCDB::SQL::Type::ResultColumn, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue, WCDB::SQL::Type::ResultColumn, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"WITH testTable1(testColumn1) AS(SELECT 1), testTable2(testColumn2) AS(SELECT 2) SELECT 1, 2\");\n}\n\n- (void)test_with_recursive_select\n{\n    auto testingSQL = WCDB::StatementSelect().with(commonTableExpressions).recursive().select(resultColumns);\n\n    auto testingTypes = { WCDB::SQL::Type::SelectSTMT, WCDB::SQL::Type::CommonTableExpression, WCDB::SQL::Type::Column, WCDB::SQL::Type::SelectSTMT, WCDB::SQL::Type::SelectCore, WCDB::SQL::Type::ResultColumn, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue, WCDB::SQL::Type::CommonTableExpression, WCDB::SQL::Type::Column, WCDB::SQL::Type::SelectSTMT, WCDB::SQL::Type::SelectCore, WCDB::SQL::Type::ResultColumn, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue, WCDB::SQL::Type::SelectCore, WCDB::SQL::Type::ResultColumn, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue, WCDB::SQL::Type::ResultColumn, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"WITH RECURSIVE testTable1(testColumn1) AS(SELECT 1), testTable2(testColumn2) AS(SELECT 2) SELECT 1, 2\");\n}\n\n- (void)test_distinct_select\n{\n    auto testingSQL = WCDB::StatementSelect().select(resultColumns).distinct();\n\n    auto testingTypes = { WCDB::SQL::Type::SelectSTMT, WCDB::SQL::Type::SelectCore, WCDB::SQL::Type::ResultColumn, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue, WCDB::SQL::Type::ResultColumn, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"SELECT DISTINCT 1, 2\");\n}\n\n- (void)test_select_from_tables_or_subqueries\n{\n    auto testingSQL = WCDB::StatementSelect().select(resultColumns).from(tablesOrSubqueries);\n\n    auto testingTypes = { WCDB::SQL::Type::SelectSTMT, WCDB::SQL::Type::SelectCore, WCDB::SQL::Type::ResultColumn, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue, WCDB::SQL::Type::ResultColumn, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue, WCDB::SQL::Type::TableOrSubquery, WCDB::SQL::Type::TableOrSubquery };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"SELECT 1, 2 FROM testTable1, testTable2\");\n}\n\n- (void)test_select_from_join\n{\n    auto testingSQL = WCDB::StatementSelect().select(resultColumns).from(join);\n\n    auto testingTypes = { WCDB::SQL::Type::SelectSTMT, WCDB::SQL::Type::SelectCore, WCDB::SQL::Type::ResultColumn, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue, WCDB::SQL::Type::ResultColumn, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue, WCDB::SQL::Type::JoinClause, WCDB::SQL::Type::TableOrSubquery };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"SELECT 1, 2 FROM testTable\");\n}\n\n- (void)test_select_with_condition\n{\n    auto testingSQL = WCDB::StatementSelect().select(resultColumns).where(condition);\n\n    auto testingTypes = { WCDB::SQL::Type::SelectSTMT, WCDB::SQL::Type::SelectCore, WCDB::SQL::Type::ResultColumn, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue, WCDB::SQL::Type::ResultColumn, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"SELECT 1, 2 WHERE 1\");\n}\n\n- (void)test_select_with_group\n{\n    auto testingSQL = WCDB::StatementSelect().select(resultColumns).group(group1);\n\n    auto testingTypes = { WCDB::SQL::Type::SelectSTMT, WCDB::SQL::Type::SelectCore, WCDB::SQL::Type::ResultColumn, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue, WCDB::SQL::Type::ResultColumn, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"SELECT 1, 2 GROUP BY 1\");\n}\n\n- (void)test_select_with_seperated_groups\n{\n    auto testingSQL = WCDB::StatementSelect().select(resultColumns).group(group1).group(group2);\n\n    auto testingTypes = { WCDB::SQL::Type::SelectSTMT, WCDB::SQL::Type::SelectCore, WCDB::SQL::Type::ResultColumn, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue, WCDB::SQL::Type::ResultColumn, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"SELECT 1, 2 GROUP BY 1, 2\");\n}\n\n- (void)test_select_with_groups\n{\n    auto testingSQL = WCDB::StatementSelect().select(resultColumns).groups(groups);\n\n    auto testingTypes = { WCDB::SQL::Type::SelectSTMT, WCDB::SQL::Type::SelectCore, WCDB::SQL::Type::ResultColumn, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue, WCDB::SQL::Type::ResultColumn, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"SELECT 1, 2 GROUP BY 1, 2\");\n}\n\n- (void)test_select_with_having\n{\n    auto testingSQL = WCDB::StatementSelect().select(resultColumns).groups(groups).having(having);\n\n    auto testingTypes = { WCDB::SQL::Type::SelectSTMT, WCDB::SQL::Type::SelectCore, WCDB::SQL::Type::ResultColumn, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue, WCDB::SQL::Type::ResultColumn, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"SELECT 1, 2 GROUP BY 1, 2 HAVING 1\");\n}\n\n- (void)test_select_with_window\n{\n    auto testingSQL = WCDB::StatementSelect().select(resultColumns).window(window1).as(windowDef1);\n\n    auto testingTypes = { WCDB::SQL::Type::SelectSTMT, WCDB::SQL::Type::SelectCore, WCDB::SQL::Type::ResultColumn, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue, WCDB::SQL::Type::ResultColumn, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue, WCDB::SQL::Type::WindowDef, WCDB::SQL::Type::OrderingTerm, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"SELECT 1, 2 WINDOW testWindow1 AS (ORDER BY 1)\");\n}\n\n- (void)test_select_with_windows\n{\n    auto testingSQL = WCDB::StatementSelect().select(resultColumns).window(window1).as(windowDef1).window(window2).as(windowDef2);\n\n    auto testingTypes = { WCDB::SQL::Type::SelectSTMT, WCDB::SQL::Type::SelectCore, WCDB::SQL::Type::ResultColumn, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue, WCDB::SQL::Type::ResultColumn, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue, WCDB::SQL::Type::WindowDef, WCDB::SQL::Type::OrderingTerm, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue, WCDB::SQL::Type::WindowDef, WCDB::SQL::Type::OrderingTerm, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"SELECT 1, 2 WINDOW testWindow1 AS (ORDER BY 1), testWindow2 AS (ORDER BY 2)\");\n}\n\n- (void)test_values\n{\n    auto testingSQL = WCDB::StatementSelect().values(values);\n\n    auto testingTypes = { WCDB::SQL::Type::SelectSTMT, WCDB::SQL::Type::SelectCore, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"VALUES(1, 2)\");\n}\n\n- (void)test_seperated_values\n{\n    auto testingSQL = WCDB::StatementSelect().value(value1).value(value2);\n\n    auto testingTypes = { WCDB::SQL::Type::SelectSTMT, WCDB::SQL::Type::SelectCore, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"VALUES(1, 2)\");\n}\n\n- (void)test_multi_values\n{\n    auto testingSQL = WCDB::StatementSelect().values(values).values(values);\n\n    auto testingTypes = { WCDB::SQL::Type::SelectSTMT, WCDB::SQL::Type::SelectCore, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"VALUES(1, 2), (1, 2)\");\n}\n\n- (void)test_compound_multiple_select\n{\n    auto testingSQL = WCDB::StatementSelect().select(resultColumns).groups(groups).union_().select(resultColumns).where(condition);\n\n    auto testingTypes = { WCDB::SQL::Type::SelectSTMT, WCDB::SQL::Type::SelectCore, WCDB::SQL::Type::ResultColumn, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue, WCDB::SQL::Type::ResultColumn, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue, WCDB::SQL::Type::SelectCore, WCDB::SQL::Type::ResultColumn, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue, WCDB::SQL::Type::ResultColumn, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"SELECT 1, 2 GROUP BY 1, 2 UNION SELECT 1, 2 WHERE 1\");\n}\n\n- (void)test_compound_union\n{\n    auto testingSQL = WCDB::StatementSelect().select(resultColumns).union_().values(values);\n\n    auto testingTypes = { WCDB::SQL::Type::SelectSTMT, WCDB::SQL::Type::SelectCore, WCDB::SQL::Type::ResultColumn, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue, WCDB::SQL::Type::ResultColumn, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue, WCDB::SQL::Type::SelectCore, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"SELECT 1, 2 UNION VALUES(1, 2)\");\n}\n\n- (void)test_compound_union_all\n{\n    auto testingSQL = WCDB::StatementSelect().select(resultColumns).unionAll().values(values);\n\n    auto testingTypes = { WCDB::SQL::Type::SelectSTMT, WCDB::SQL::Type::SelectCore, WCDB::SQL::Type::ResultColumn, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue, WCDB::SQL::Type::ResultColumn, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue, WCDB::SQL::Type::SelectCore, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"SELECT 1, 2 UNION ALL VALUES(1, 2)\");\n}\n\n- (void)test_compound_intersect\n{\n    auto testingSQL = WCDB::StatementSelect().select(resultColumns).intersect().values(values);\n\n    auto testingTypes = { WCDB::SQL::Type::SelectSTMT, WCDB::SQL::Type::SelectCore, WCDB::SQL::Type::ResultColumn, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue, WCDB::SQL::Type::ResultColumn, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue, WCDB::SQL::Type::SelectCore, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"SELECT 1, 2 INTERSECT VALUES(1, 2)\");\n}\n\n- (void)test_compound_except\n{\n    auto testingSQL = WCDB::StatementSelect().select(resultColumns).except().values(values);\n\n    auto testingTypes = { WCDB::SQL::Type::SelectSTMT, WCDB::SQL::Type::SelectCore, WCDB::SQL::Type::ResultColumn, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue, WCDB::SQL::Type::ResultColumn, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue, WCDB::SQL::Type::SelectCore, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"SELECT 1, 2 EXCEPT VALUES(1, 2)\");\n}\n\n- (void)test_order\n{\n    auto testingSQL = WCDB::StatementSelect().select(resultColumns).order(orderingTerm1);\n\n    auto testingTypes = { WCDB::SQL::Type::SelectSTMT, WCDB::SQL::Type::SelectCore, WCDB::SQL::Type::ResultColumn, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue, WCDB::SQL::Type::ResultColumn, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue, WCDB::SQL::Type::OrderingTerm, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"SELECT 1, 2 ORDER BY 1\");\n}\n\n- (void)test_seperated_orders\n{\n    auto testingSQL = WCDB::StatementSelect().select(resultColumns).order(orderingTerm1).order(orderingTerm2);\n\n    auto testingTypes = { WCDB::SQL::Type::SelectSTMT, WCDB::SQL::Type::SelectCore, WCDB::SQL::Type::ResultColumn, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue, WCDB::SQL::Type::ResultColumn, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue, WCDB::SQL::Type::OrderingTerm, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue, WCDB::SQL::Type::OrderingTerm, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"SELECT 1, 2 ORDER BY 1, 2\");\n}\n\n- (void)test_orders\n{\n    auto testingSQL = WCDB::StatementSelect().select(resultColumns).orders(orderingTerms);\n\n    auto testingTypes = { WCDB::SQL::Type::SelectSTMT, WCDB::SQL::Type::SelectCore, WCDB::SQL::Type::ResultColumn, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue, WCDB::SQL::Type::ResultColumn, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue, WCDB::SQL::Type::OrderingTerm, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue, WCDB::SQL::Type::OrderingTerm, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"SELECT 1, 2 ORDER BY 1, 2\");\n}\n\n- (void)test_limit\n{\n    auto testingSQL = WCDB::StatementSelect().select(resultColumns).limit(limit);\n\n    auto testingTypes = { WCDB::SQL::Type::SelectSTMT, WCDB::SQL::Type::SelectCore, WCDB::SQL::Type::ResultColumn, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue, WCDB::SQL::Type::ResultColumn, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"SELECT 1, 2 LIMIT 1\");\n}\n\n- (void)test_limit_length\n{\n    auto testingSQL = WCDB::StatementSelect().select(resultColumns).limit(limit, limitParameter);\n\n    auto testingTypes = { WCDB::SQL::Type::SelectSTMT, WCDB::SQL::Type::SelectCore, WCDB::SQL::Type::ResultColumn, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue, WCDB::SQL::Type::ResultColumn, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"SELECT 1, 2 LIMIT 1, 2\");\n}\n\n- (void)test_limit_offset\n{\n    auto testingSQL = WCDB::StatementSelect().select(resultColumns).limit(limit).offset(limitParameter);\n\n    auto testingTypes = { WCDB::SQL::Type::SelectSTMT, WCDB::SQL::Type::SelectCore, WCDB::SQL::Type::ResultColumn, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue, WCDB::SQL::Type::ResultColumn, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"SELECT 1, 2 LIMIT 1 OFFSET 2\");\n}\n\n- (void)test_select_convertible\n{\n    WCDB::StatementSelect sql = WCDB::StatementSelect().select(1);\n    NSString* expected = @\"(SELECT 1)\";\n    TestCaseAssertWINQConvertible(WCDB::TableOrSubquery, sql, expected);\n    TestCaseAssertWINQConvertible(WCDB::TablesOrSubqueries, sql, expected);\n}\n\n@end\n"
  },
  {
    "path": "src/objc/tests/winq/StatementTests.mm",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"WINQAssertion.h\"\n\n@interface StatementTests : BaseTestCase\n\n@end\n\n@implementation StatementTests {\n}\n\n- (void)setUp\n{\n    [super setUp];\n}\n\n- (void)test\n{\n    WCDB::StatementInsert insert = WCDB::StatementInsert().insertIntoTable(@\"testTable\").values(1);\n\n    WCDB::Statement statement = insert;\n    TestCaseAssertSQLEqual(statement, @\"INSERT INTO testTable VALUES(1)\");\n\n    WCDB::Statement statement2 = statement;\n    TestCaseAssertSQLEqual(statement2, @\"INSERT INTO testTable VALUES(1)\");\n\n    WCDB::StatementInsert statement3((const WCDB::StatementInsert &) statement);\n    TestCaseAssertSQLEqual(statement3, @\"INSERT INTO testTable VALUES(1)\");\n}\n\n@end\n"
  },
  {
    "path": "src/objc/tests/winq/StatementUpdateTests.mm",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"WINQAssertion.h\"\n\n@interface StatementUpdateTests : BaseTestCase\n\n@end\n\n@implementation StatementUpdateTests {\n    WCDB::CommonTableExpression with;\n    WCDB::QualifiedTable table;\n    WCDB::Column column;\n    WCDB::Columns columns;\n    WCDB::Expression expression1;\n    WCDB::Expression expression2;\n    WCDB::Expression condition;\n    WCDB::OrderingTerm orderingTerm1;\n    WCDB::OrderingTerm orderingTerm2;\n    WCDB::OrderingTerms orderingTerms;\n    WCDB::Expression limit;\n    WCDB::Expression limitParameter;\n}\n\n- (void)setUp\n{\n    [super setUp];\n    with = WCDB::CommonTableExpression(@\"testTable\").as(WCDB::StatementSelect().select(1));\n    table = @\"testTable\";\n    column = WCDB::Column(@\"testColumn\");\n    columns = {\n        WCDB::Column(@\"testColumn1\"),\n        WCDB::Column(@\"testColumn2\"),\n    };\n    expression1 = 1;\n    expression2 = 2;\n    condition = 3;\n    orderingTerm1 = 1;\n    orderingTerm2 = 2;\n    orderingTerms = {\n        orderingTerm1,\n        orderingTerm2,\n    };\n    limit = 1;\n    limitParameter = 2;\n}\n\n- (void)test_default_constructible\n{\n    WCDB::StatementUpdate constructible;\n    TestCaseAssertFalse(constructible.syntax().isValid());\n    TestCaseAssertIterateEqual(constructible, std::list<WCDB::Syntax::Identifier::Type>());\n    TestCaseAssertTrue(constructible.getDescription().empty());\n}\n\n- (void)test_get_type\n{\n    TestCaseAssertEqual(WCDB::StatementUpdate().getType(), WCDB::SQL::Type::UpdateSTMT);\n    TestCaseAssertEqual(WCDB::StatementUpdate::type, WCDB::SQL::Type::UpdateSTMT);\n}\n\n- (void)test_update\n{\n    auto testingSQL = WCDB::StatementUpdate().update(table).set(column).to(expression1);\n\n    auto testingTypes = { WCDB::SQL::Type::UpdateSTMT, WCDB::SQL::Type::QualifiedTableName, WCDB::SQL::Type::Column, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"UPDATE testTable SET testColumn = 1\");\n}\n\n- (void)test_update_with\n{\n    auto testingSQL = WCDB::StatementUpdate().with(with).update(table).set(column).to(expression1);\n\n    auto testingTypes = { WCDB::SQL::Type::UpdateSTMT, WCDB::SQL::Type::CommonTableExpression, WCDB::SQL::Type::SelectSTMT, WCDB::SQL::Type::SelectCore, WCDB::SQL::Type::ResultColumn, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue, WCDB::SQL::Type::QualifiedTableName, WCDB::SQL::Type::Column, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"WITH testTable AS(SELECT 1) UPDATE testTable SET testColumn = 1\");\n}\n\n- (void)test_update_or_rollback\n{\n    auto testingSQL = WCDB::StatementUpdate().update(table).orRollback().set(column).to(expression1);\n\n    auto testingTypes = { WCDB::SQL::Type::UpdateSTMT, WCDB::SQL::Type::QualifiedTableName, WCDB::SQL::Type::Column, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"UPDATE OR ROLLBACK testTable SET testColumn = 1\");\n}\n\n- (void)test_update_or_abort\n{\n    auto testingSQL = WCDB::StatementUpdate().update(table).orAbort().set(column).to(expression1);\n\n    auto testingTypes = { WCDB::SQL::Type::UpdateSTMT, WCDB::SQL::Type::QualifiedTableName, WCDB::SQL::Type::Column, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"UPDATE OR ABORT testTable SET testColumn = 1\");\n}\n\n- (void)test_update_or_replace\n{\n    auto testingSQL = WCDB::StatementUpdate().update(table).orReplace().set(column).to(expression1);\n\n    auto testingTypes = { WCDB::SQL::Type::UpdateSTMT, WCDB::SQL::Type::QualifiedTableName, WCDB::SQL::Type::Column, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"UPDATE OR REPLACE testTable SET testColumn = 1\");\n}\n\n- (void)test_update_or_fail\n{\n    auto testingSQL = WCDB::StatementUpdate().update(table).orFail().set(column).to(expression1);\n\n    auto testingTypes = { WCDB::SQL::Type::UpdateSTMT, WCDB::SQL::Type::QualifiedTableName, WCDB::SQL::Type::Column, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"UPDATE OR FAIL testTable SET testColumn = 1\");\n}\n\n- (void)test_update_or_ignore\n{\n    auto testingSQL = WCDB::StatementUpdate().update(table).orIgnore().set(column).to(expression1);\n\n    auto testingTypes = { WCDB::SQL::Type::UpdateSTMT, WCDB::SQL::Type::QualifiedTableName, WCDB::SQL::Type::Column, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"UPDATE OR IGNORE testTable SET testColumn = 1\");\n}\n\n- (void)test_update_multiple\n{\n    auto testingSQL = WCDB::StatementUpdate().update(table).set(column).to(expression1).set(columns).to(expression2);\n\n    auto testingTypes = { WCDB::SQL::Type::UpdateSTMT, WCDB::SQL::Type::QualifiedTableName, WCDB::SQL::Type::Column, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue, WCDB::SQL::Type::Column, WCDB::SQL::Type::Column, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"UPDATE testTable SET testColumn = 1, (testColumn1, testColumn2) = 2\");\n}\n\n- (void)test_update_with_condition\n{\n    auto testingSQL = WCDB::StatementUpdate().update(table).set(column).to(expression1).where(condition);\n\n    auto testingTypes = { WCDB::SQL::Type::UpdateSTMT, WCDB::SQL::Type::QualifiedTableName, WCDB::SQL::Type::Column, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"UPDATE testTable SET testColumn = 1 WHERE 3\");\n}\n\n- (void)test_update_with_seperated_orders\n{\n    auto testingSQL = WCDB::StatementUpdate().update(table).set(column).to(expression1).order(orderingTerm1).order(orderingTerm2).limit(limit);\n\n    auto testingTypes = { WCDB::SQL::Type::UpdateSTMT, WCDB::SQL::Type::QualifiedTableName, WCDB::SQL::Type::Column, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue, WCDB::SQL::Type::OrderingTerm, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue, WCDB::SQL::Type::OrderingTerm, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"UPDATE testTable SET testColumn = 1 ORDER BY 1, 2 LIMIT 1\");\n}\n\n- (void)test_update_with_orders\n{\n    auto testingSQL = WCDB::StatementUpdate().update(table).set(column).to(expression1).orders(orderingTerms).limit(limit);\n\n    auto testingTypes = { WCDB::SQL::Type::UpdateSTMT, WCDB::SQL::Type::QualifiedTableName, WCDB::SQL::Type::Column, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue, WCDB::SQL::Type::OrderingTerm, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue, WCDB::SQL::Type::OrderingTerm, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"UPDATE testTable SET testColumn = 1 ORDER BY 1, 2 LIMIT 1\");\n}\n\n- (void)test_update_with_limit\n{\n    auto testingSQL = WCDB::StatementUpdate().update(table).set(column).to(expression1).limit(limit);\n\n    auto testingTypes = { WCDB::SQL::Type::UpdateSTMT, WCDB::SQL::Type::QualifiedTableName, WCDB::SQL::Type::Column, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"UPDATE testTable SET testColumn = 1 LIMIT 1\");\n}\n\n- (void)test_update_with_limit_length\n{\n    auto testingSQL = WCDB::StatementUpdate().update(table).set(column).to(expression1).limit(limit, limitParameter);\n\n    auto testingTypes = { WCDB::SQL::Type::UpdateSTMT, WCDB::SQL::Type::QualifiedTableName, WCDB::SQL::Type::Column, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"UPDATE testTable SET testColumn = 1 LIMIT 1, 2\");\n}\n\n- (void)test_update_with_limit_offset\n{\n    auto testingSQL = WCDB::StatementUpdate().update(table).set(column).to(expression1).limit(limit).offset(limitParameter);\n\n    auto testingTypes = { WCDB::SQL::Type::UpdateSTMT, WCDB::SQL::Type::QualifiedTableName, WCDB::SQL::Type::Column, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"UPDATE testTable SET testColumn = 1 LIMIT 1 OFFSET 2\");\n}\n\n@end\n"
  },
  {
    "path": "src/objc/tests/winq/StatementVacuumTests.mm",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"WINQAssertion.h\"\n\n@interface StatementVacuumTests : BaseTestCase\n\n@end\n\n@implementation StatementVacuumTests {\n    WCDB::Schema schema;\n}\n\n- (void)setUp\n{\n    [super setUp];\n    schema = @\"testSchema\";\n}\n\n- (void)test_default_constructible\n{\n    WCDB::StatementVacuum constructible;\n    TestCaseAssertFalse(constructible.syntax().isValid());\n    TestCaseAssertIterateEqual(constructible, std::list<WCDB::Syntax::Identifier::Type>());\n    TestCaseAssertTrue(constructible.getDescription().empty());\n}\n\n- (void)test_get_type\n{\n    TestCaseAssertEqual(WCDB::StatementVacuum().getType(), WCDB::SQL::Type::VacuumSTMT);\n    TestCaseAssertEqual(WCDB::StatementVacuum::type, WCDB::SQL::Type::VacuumSTMT);\n}\n\n- (void)test_vacuum\n{\n    auto testingSQL = WCDB::StatementVacuum().vacuum();\n\n    auto testingTypes = { WCDB::SQL::Type::VacuumSTMT };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"VACUUM\");\n}\n\n- (void)test_vacuum_with_schema\n{\n    auto testingSQL = WCDB::StatementVacuum().vacuum(schema);\n\n    auto testingTypes = { WCDB::SQL::Type::VacuumSTMT, WCDB::SQL::Type::Schema };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"VACUUM testSchema\");\n}\n\n@end\n"
  },
  {
    "path": "src/objc/tests/winq/StoppableIterationTests.mm",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"WINQAssertion.h\"\n\n@interface StoppableIterationTests : BaseTestCase\n\n@end\n\n@implementation StoppableIterationTests\n\n- (void)test\n{\n    auto testingSQL = WCDB::StatementInsert().insertIntoTable(\"testTable\").schema(\"testSchema\").column(WCDB::Column(\"testColumn\")).values(1);\n\n    std::list<WCDB::Syntax::Identifier::Type> types;\n    testingSQL.iterate([&types](WCDB::Syntax::Identifier& identifier, bool begin, bool& stop) {\n        if (!begin) {\n            return;\n        }\n        types.push_back(identifier.getType());\n        if (identifier.getType() == WCDB::Syntax::Identifier::Type::Schema) {\n            stop = true;\n        }\n    });\n\n    std::list<WCDB::Syntax::Identifier::Type> testingTypes = { WCDB::SQL::Type::InsertSTMT, WCDB::SQL::Type::Schema };\n\n    TestCaseAssertTypesEqual(types, testingTypes);\n}\n\n@end\n"
  },
  {
    "path": "src/objc/tests/winq/SyntaxListTests.mm",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"WINQAssertion.h\"\n\n@interface SyntaxListTests : BaseTestCase\n\n@end\n\n@implementation SyntaxListTests {\n}\n\n- (void)setUp\n{\n    [super setUp];\n}\n\n- (void)test_default_constructible\n{\n    WCDB::SyntaxList<WCDB::Expression> constructible;\n    TestCaseAssertTrue(constructible.getDescription().empty());\n}\n\nWCDB::SyntaxList<WCDB::Expression> acceptable(const WCDB::SyntaxList<WCDB::Expression>& expressions)\n{\n    return expressions;\n}\n\n- (void)test_single_construct\n{\n    TestCaseAssertSQLEqual(acceptable(WCDB::Expression(1)), @\"1\");\n}\n\n- (void)test_initial_list_construct\n{\n    std::initializer_list<WCDB::Expression> expressions = { 1, 2 };\n    TestCaseAssertSQLEqual(acceptable(expressions), @\"1, 2\");\n}\n\n- (void)test_list_construct\n{\n    std::list<WCDB::Expression> expressions = { 1, 2 };\n    TestCaseAssertSQLEqual(acceptable(expressions), @\"1, 2\");\n}\n\n- (void)test_construct_convertible\n{\n    TestCaseAssertSQLEqual(acceptable(1), @\"1\");\n}\n\n- (void)test_initial_list_construct_convertible\n{\n    std::initializer_list<WCDB::Expression> expressions = { 1, 2 };\n    TestCaseAssertSQLEqual(acceptable(expressions), @\"1, 2\");\n}\n\n- (void)test_list_construct_convertible\n{\n    std::list<WCDB::Expression> expressions = { 1, 2 };\n    TestCaseAssertSQLEqual(acceptable(expressions), @\"1, 2\");\n}\n\n- (void)test_syntax_list_construct_convertible\n{\n    WCDB::SyntaxList<WCDB::LiteralValue> values = { 1, 2 };\n    TestCaseAssertSQLEqual(acceptable(values), @\"1, 2\");\n}\n\n@end\n"
  },
  {
    "path": "src/objc/tests/winq/TableConstraintTests.mm",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"WINQAssertion.h\"\n\n@interface TableConstraintTests : BaseTestCase\n\n@end\n\n@implementation TableConstraintTests {\n    NSString* name;\n    WCDB::IndexedColumn indexedColumn1;\n    WCDB::IndexedColumn indexedColumn2;\n    WCDB::Conflict conflict;\n    WCDB::Expression condition;\n    WCDB::Column column;\n    WCDB::ForeignKey foreignKey;\n}\n\n- (void)setUp\n{\n    [super setUp];\n    name = @\"testTableConstraint\";\n    column = WCDB::Column(@\"testColumn\");\n    condition = 1;\n    indexedColumn1 = WCDB::Column(@\"testColumn1\");\n    indexedColumn2 = WCDB::Column(@\"testColumn2\");\n    conflict = WCDB::Conflict::Abort;\n    foreignKey = WCDB::ForeignKey().references(@\"testForeignTable\");\n}\n\n- (void)test_default_constructible\n{\n    WCDB::TableConstraint constructible;\n    TestCaseAssertFalse(constructible.syntax().isValid());\n    TestCaseAssertIterateEqual(constructible, std::list<WCDB::Syntax::Identifier::Type>());\n    TestCaseAssertTrue(constructible.getDescription().empty());\n}\n\n- (void)test_get_type\n{\n    TestCaseAssertEqual(WCDB::TableConstraint().getType(), WCDB::SQL::Type::TableConstraint);\n    TestCaseAssertEqual(WCDB::TableConstraint::type, WCDB::SQL::Type::TableConstraint);\n}\n\n- (void)test_primary_key\n{\n    auto testingSQL = WCDB::TableConstraint(name).primaryKey().indexed(indexedColumn1);\n\n    auto testingTypes = { WCDB::SQL::Type::TableConstraint, WCDB::SQL::Type::IndexedColumn, WCDB::SQL::Type::Column };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"CONSTRAINT testTableConstraint PRIMARY KEY(testColumn1)\");\n}\n\n- (void)test_primary_key_with_indexes\n{\n    auto testingSQL = WCDB::TableConstraint(name).primaryKey().indexed(indexedColumn1).indexed(indexedColumn2);\n\n    auto testingTypes = { WCDB::SQL::Type::TableConstraint, WCDB::SQL::Type::IndexedColumn, WCDB::SQL::Type::Column, WCDB::SQL::Type::IndexedColumn, WCDB::SQL::Type::Column };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"CONSTRAINT testTableConstraint PRIMARY KEY(testColumn1, testColumn2)\");\n}\n\n- (void)test_primary_key_without_name\n{\n    auto testingSQL = WCDB::TableConstraint().primaryKey().indexed(indexedColumn1);\n\n    auto testingTypes = { WCDB::SQL::Type::TableConstraint, WCDB::SQL::Type::IndexedColumn, WCDB::SQL::Type::Column };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"PRIMARY KEY(testColumn1)\");\n}\n\n- (void)test_primary_key_with_conflict\n{\n    auto testingSQL = WCDB::TableConstraint(name).primaryKey().indexed(indexedColumn1).conflict(conflict);\n\n    auto testingTypes = { WCDB::SQL::Type::TableConstraint, WCDB::SQL::Type::IndexedColumn, WCDB::SQL::Type::Column };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"CONSTRAINT testTableConstraint PRIMARY KEY(testColumn1) ON CONFLICT ABORT\");\n}\n\n- (void)test_unique\n{\n    auto testingSQL = WCDB::TableConstraint(name).unique().indexed(indexedColumn1);\n\n    auto testingTypes = { WCDB::SQL::Type::TableConstraint, WCDB::SQL::Type::IndexedColumn, WCDB::SQL::Type::Column };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"CONSTRAINT testTableConstraint UNIQUE(testColumn1)\");\n}\n\n- (void)test_unique_with_indexes\n{\n    auto testingSQL = WCDB::TableConstraint(name).unique().indexed(indexedColumn1).indexed(indexedColumn2);\n\n    auto testingTypes = { WCDB::SQL::Type::TableConstraint, WCDB::SQL::Type::IndexedColumn, WCDB::SQL::Type::Column, WCDB::SQL::Type::IndexedColumn, WCDB::SQL::Type::Column };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"CONSTRAINT testTableConstraint UNIQUE(testColumn1, testColumn2)\");\n}\n\n- (void)test_unique_with_conflict\n{\n    auto testingSQL = WCDB::TableConstraint(name).unique().indexed(indexedColumn1).conflict(conflict);\n\n    auto testingTypes = { WCDB::SQL::Type::TableConstraint, WCDB::SQL::Type::IndexedColumn, WCDB::SQL::Type::Column };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"CONSTRAINT testTableConstraint UNIQUE(testColumn1) ON CONFLICT ABORT\");\n}\n\n- (void)test_check\n{\n    auto testingSQL = WCDB::TableConstraint(name).check(condition);\n\n    auto testingTypes = { WCDB::SQL::Type::TableConstraint, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"CONSTRAINT testTableConstraint CHECK(1)\");\n}\n\n- (void)test_foreign_key\n{\n    auto testingSQL = WCDB::TableConstraint(name).foreignKey(column, foreignKey);\n\n    auto testingTypes = { WCDB::SQL::Type::TableConstraint, WCDB::SQL::Type::Column, WCDB::SQL::Type::ForeignKeyClause };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"CONSTRAINT testTableConstraint FOREIGN KEY(testColumn) REFERENCES testForeignTable\");\n}\n\n@end\n"
  },
  {
    "path": "src/objc/tests/winq/TableOrSubqueryTests.mm",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"WINQAssertion.h\"\n\n@interface TableOrSubqueryTests : BaseTestCase\n\n@end\n\n@implementation TableOrSubqueryTests {\n    WCDB::Schema schema;\n    NSString* table;\n    NSString* alias;\n    NSString* index;\n    NSString* function;\n    WCDB::Expression expression1;\n    WCDB::Expression expression2;\n    WCDB::Expressions expressions;\n    WCDB::TablesOrSubqueries tablesOrSubqueries;\n    WCDB::Join join;\n    WCDB::StatementSelect select;\n}\n\n- (void)setUp\n{\n    [super setUp];\n    schema = @\"testSchema\";\n    table = @\"testTable\";\n    alias = @\"testAliasTable\";\n    index = @\"testIndex\";\n    function = @\"testFunction\";\n    expression1 = 1;\n    expression2 = 2;\n    expressions = {\n        expression1,\n        expression2,\n    };\n    tablesOrSubqueries = {\n        @\"testTable1\",\n        @\"testTable2\",\n    };\n    join = WCDB::Join().table(@\"testJoinTable\");\n    select = WCDB::StatementSelect().select(1);\n}\n\n- (void)test_default_constructible\n{\n    WCDB::TableOrSubquery constructible;\n    TestCaseAssertFalse(constructible.syntax().isValid());\n    TestCaseAssertIterateEqual(constructible, std::list<WCDB::Syntax::Identifier::Type>());\n    TestCaseAssertTrue(constructible.getDescription().empty());\n}\n\n- (void)test_get_type\n{\n    TestCaseAssertEqual(WCDB::TableOrSubquery().getType(), WCDB::SQL::Type::TableOrSubquery);\n    TestCaseAssertEqual(WCDB::TableOrSubquery::type, WCDB::SQL::Type::TableOrSubquery);\n}\n\n- (void)test_table\n{\n    auto testingSQL = WCDB::TableOrSubquery(table);\n\n    auto testingTypes = { WCDB::SQL::Type::TableOrSubquery };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"testTable\");\n}\n\n- (void)test_table_with_schema\n{\n    auto testingSQL = WCDB::TableOrSubquery(table).schema(schema);\n\n    auto testingTypes = { WCDB::SQL::Type::TableOrSubquery, WCDB::SQL::Type::Schema };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"testSchema.testTable\");\n}\n\n- (void)test_table_with_alias\n{\n    auto testingSQL = WCDB::TableOrSubquery(table).as(alias);\n\n    auto testingTypes = { WCDB::SQL::Type::TableOrSubquery };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"testTable AS testAliasTable\");\n}\n\n- (void)test_table_with_index\n{\n    auto testingSQL = WCDB::TableOrSubquery(table).indexed(index);\n\n    auto testingTypes = { WCDB::SQL::Type::TableOrSubquery };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"testTable INDEXED BY testIndex\");\n}\n\n- (void)test_table_without_index\n{\n    auto testingSQL = WCDB::TableOrSubquery(table).notIndexed();\n\n    auto testingTypes = { WCDB::SQL::Type::TableOrSubquery };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"testTable NOT INDEXED\");\n}\n\n- (void)test_table_function\n{\n    auto testingSQL = WCDB::TableOrSubquery::function(function).invoke();\n\n    auto testingTypes = { WCDB::SQL::Type::TableOrSubquery };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"testFunction()\");\n}\n\n- (void)test_table_function_with_schema\n{\n    auto testingSQL = WCDB::TableOrSubquery::function(function).schema(schema).invoke();\n\n    auto testingTypes = { WCDB::SQL::Type::TableOrSubquery, WCDB::SQL::Type::Schema };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"testSchema.testFunction()\");\n}\n\n- (void)test_table_function_with_parameter\n{\n    auto testingSQL = WCDB::TableOrSubquery::function(function).invoke().argument(expression1);\n\n    auto testingTypes = { WCDB::SQL::Type::TableOrSubquery, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"testFunction(1)\");\n}\n\n- (void)test_table_function_with_seperated_parameters\n{\n    auto testingSQL = WCDB::TableOrSubquery::function(function).invoke().argument(expression1).argument(expression2);\n\n    auto testingTypes = { WCDB::SQL::Type::TableOrSubquery, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"testFunction(1, 2)\");\n}\n\n- (void)test_table_function_with_parameters\n{\n    auto testingSQL = WCDB::TableOrSubquery::function(function).invoke().arguments(expressions);\n\n    auto testingTypes = { WCDB::SQL::Type::TableOrSubquery, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"testFunction(1, 2)\");\n}\n\n- (void)test_table_function_with_alias\n{\n    auto testingSQL = WCDB::TableOrSubquery::function(function).as(alias).invoke();\n\n    auto testingTypes = { WCDB::SQL::Type::TableOrSubquery };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"testFunction() AS testAliasTable\");\n}\n\n- (void)test_tables_or_subqueries\n{\n    auto testingSQL = WCDB::TableOrSubquery(tablesOrSubqueries);\n\n    auto testingTypes = { WCDB::SQL::Type::TableOrSubquery, WCDB::SQL::Type::TableOrSubquery, WCDB::SQL::Type::TableOrSubquery };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"(testTable1, testTable2)\");\n}\n\n- (void)test_join\n{\n    auto testingSQL = WCDB::TableOrSubquery(join);\n\n    auto testingTypes = { WCDB::SQL::Type::TableOrSubquery, WCDB::SQL::Type::JoinClause, WCDB::SQL::Type::TableOrSubquery };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"(testJoinTable)\");\n}\n\n- (void)test_select\n{\n    auto testingSQL = WCDB::TableOrSubquery(select);\n\n    auto testingTypes = { WCDB::SQL::Type::TableOrSubquery, WCDB::SQL::Type::SelectSTMT, WCDB::SQL::Type::SelectCore, WCDB::SQL::Type::ResultColumn, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"(SELECT 1)\");\n}\n\n- (void)test_select_with_alias\n{\n    auto testingSQL = WCDB::TableOrSubquery(select).as(alias);\n\n    auto testingTypes = { WCDB::SQL::Type::TableOrSubquery, WCDB::SQL::Type::SelectSTMT, WCDB::SQL::Type::SelectCore, WCDB::SQL::Type::ResultColumn, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"(SELECT 1) AS testAliasTable\");\n}\n\n- (void)test_master\n{\n    TestCaseAssertSQLEqual(WCDB::TableOrSubquery::master(), @\"sqlite_master\");\n}\n\n@end\n"
  },
  {
    "path": "src/objc/tests/winq/UpsertTests.mm",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"WINQAssertion.h\"\n\n@interface UpsertTests : BaseTestCase\n\n@end\n\n@implementation UpsertTests {\n    WCDB::IndexedColumn indexedColumn1;\n    WCDB::IndexedColumn indexedColumn2;\n    WCDB::Expression condition;\n    WCDB::Columns column;\n    WCDB::Columns columns;\n    WCDB::Expression value1;\n    WCDB::Expression value2;\n    WCDB::Expression updateCondition;\n}\n\n- (void)setUp\n{\n    [super setUp];\n    column = WCDB::Column(@\"testColumn1\");\n    columns = {\n        WCDB::Column(@\"testColumn2\"),\n        WCDB::Column(@\"testColumn3\"),\n    };\n    indexedColumn1 = WCDB::Column(@\"testColumn1\");\n    indexedColumn2 = WCDB::Column(@\"testColumn2\");\n    condition = 1;\n    value1 = 2;\n    value2 = 3;\n    updateCondition = 4;\n}\n\n- (void)test_default_constructible\n{\n    WCDB::Upsert constructible;\n    TestCaseAssertFalse(constructible.syntax().isValid());\n    TestCaseAssertIterateEqual(constructible, std::list<WCDB::Syntax::Identifier::Type>());\n    TestCaseAssertTrue(constructible.getDescription().empty());\n}\n\n- (void)test_get_type\n{\n    TestCaseAssertEqual(WCDB::Upsert().getType(), WCDB::SQL::Type::UpsertClause);\n    TestCaseAssertEqual(WCDB::Upsert::type, WCDB::SQL::Type::UpsertClause);\n}\n\n- (void)test_upsert\n{\n    auto testingSQL = WCDB::Upsert().onConflict().doNothing();\n\n    auto testingTypes = { WCDB::SQL::Type::UpsertClause };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"ON CONFLICT DO NOTHING\");\n}\n\n- (void)test_with_indexed_column\n{\n    auto testingSQL = WCDB::Upsert().onConflict().indexed(indexedColumn1).doNothing();\n\n    auto testingTypes = { WCDB::SQL::Type::UpsertClause, WCDB::SQL::Type::IndexedColumn, WCDB::SQL::Type::Column };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"ON CONFLICT(testColumn1) DO NOTHING\");\n}\n\n- (void)test_with_indexed_columns\n{\n    auto testingSQL = WCDB::Upsert().onConflict().indexed(indexedColumn1).indexed(indexedColumn2).doNothing();\n\n    auto testingTypes = { WCDB::SQL::Type::UpsertClause, WCDB::SQL::Type::IndexedColumn, WCDB::SQL::Type::Column, WCDB::SQL::Type::IndexedColumn, WCDB::SQL::Type::Column };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"ON CONFLICT(testColumn1, testColumn2) DO NOTHING\");\n}\n\n- (void)test_with_indexed_column_and_condition\n{\n    auto testingSQL = WCDB::Upsert().onConflict().indexed(indexedColumn1).where(condition).doNothing();\n\n    auto testingTypes = { WCDB::SQL::Type::UpsertClause, WCDB::SQL::Type::IndexedColumn, WCDB::SQL::Type::Column, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"ON CONFLICT(testColumn1) WHERE 1 DO NOTHING\");\n}\n\n- (void)test_with_update\n{\n    auto testingSQL = WCDB::Upsert().onConflict().doUpdate().set(column).to(value1);\n\n    auto testingTypes = { WCDB::SQL::Type::UpsertClause, WCDB::SQL::Type::Column, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"ON CONFLICT DO UPDATE SET testColumn1 = 2\");\n}\n\n- (void)test_with_update_multiple\n{\n    auto testingSQL = WCDB::Upsert().onConflict().doUpdate().set(column).to(value1).set(columns).to(value2);\n\n    auto testingTypes = { WCDB::SQL::Type::UpsertClause, WCDB::SQL::Type::Column, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue, WCDB::SQL::Type::Column, WCDB::SQL::Type::Column, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"ON CONFLICT DO UPDATE SET testColumn1 = 2, (testColumn2, testColumn3) = 3\");\n}\n\n- (void)test_with_update_condition\n{\n    auto testingSQL = WCDB::Upsert().onConflict().doUpdate().set(column).to(value1).where(updateCondition);\n\n    auto testingTypes = { WCDB::SQL::Type::UpsertClause, WCDB::SQL::Type::Column, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"ON CONFLICT DO UPDATE SET testColumn1 = 2 WHERE 4\");\n}\n\n@end\n"
  },
  {
    "path": "src/objc/tests/winq/ValueTests.mm",
    "content": "//\n// Created by qiuwenchen on 2022/8/12.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"TestCase.h\"\n#import \"WINQAssertion.h\"\n#import <Foundation/Foundation.h>\n#if TEST_WCDB_OBJC\n#import <WCDBOBjc/Value.hpp>\n#elif TEST_WCDB_CPP\n#import <WCDBCpp/Value.hpp>\n#else\n#import <WCDB/Value.hpp>\n#endif\n\n@interface ValueTests : BaseTestCase\n\n@end\n\n@implementation ValueTests\n\n- (void)test_null\n{\n    WCDB::Value value;\n    TestCaseAssertTrue(value.isNull());\n    TestCaseAssertTrue(value.isEmpty());\n    TestCaseAssertTrue((int) value == 0);\n    TestCaseAssertFalse(value);\n\n    value = nullptr;\n    TestCaseAssertTrue(value.isNull());\n    TestCaseAssertTrue(value.isEmpty());\n    TestCaseAssertTrue((int) value == 0);\n    TestCaseAssertFalse(value);\n\n    value = WCDB::Value(nullptr);\n    TestCaseAssertTrue(value.isNull());\n    TestCaseAssertTrue(value.isEmpty());\n    TestCaseAssertTrue((int) value == 0);\n    TestCaseAssertFalse(value);\n\n    WCDB::LiteralValue literal = value;\n    TestCaseAssertSQLEqual(literal, @\"NULL\");\n}\n\n- (void)test_interger\n{\n    WCDB::Value value(0);\n    TestCaseAssertTrue(value.intValue() == 0);\n    TestCaseAssertTrue((int) value == 0);\n    TestCaseAssertFalse(value);\n    TestCaseAssertTrue(value.isEmpty());\n    TestCaseAssertFalse(value.isNull());\n\n    value = 1;\n    TestCaseAssertFalse(value.isNull());\n    TestCaseAssertFalse(value.isEmpty());\n    TestCaseAssertTrue((int) value == 1);\n    TestCaseAssertTrue(value);\n\n    WCDB::LiteralValue literal = value;\n    TestCaseAssertSQLEqual(literal, @\"1\");\n}\n\n- (void)test_float\n{\n    WCDB::Value value(0);\n    TestCaseAssertTrue(value.floatValue() == 0);\n    TestCaseAssertTrue((double) value == 0);\n    TestCaseAssertFalse(value);\n    TestCaseAssertTrue(value.isEmpty());\n\n    value = 1.2;\n    TestCaseAssertFalse(value.isNull());\n    TestCaseAssertFalse(value.isEmpty());\n    TestCaseAssertTrue((double) value == 1.2);\n    TestCaseAssertTrue(value);\n\n    WCDB::LiteralValue literal = value;\n    TestCaseAssertSQLEqual(literal, @\"1.2\");\n}\n\n- (void)test_string\n{\n    WCDB::Value value(\"\");\n    TestCaseAssertStringEqual([NSString stringWithUTF8String:value.textValue().data()], @\"\");\n    TestCaseAssertFalse(value.isNull());\n    TestCaseAssertTrue(value.isEmpty());\n    TestCaseAssertTrue((double) value == 0);\n    TestCaseAssertFalse(value);\n\n    value = \"1.2\";\n    TestCaseAssertStringEqual([NSString stringWithUTF8String:value.textValue().data()], @\"1.2\");\n    TestCaseAssertFalse(value.isNull());\n    TestCaseAssertFalse(value.isEmpty());\n    TestCaseAssertTrue((double) value == 1.2);\n    TestCaseAssertTrue(value);\n\n    WCDB::LiteralValue literal = value;\n    TestCaseAssertSQLEqual(literal, @\"'1.2'\");\n}\n\n- (void)test_blob\n{\n    NSData* nsData = [@\"\" dataUsingEncoding:NSUTF8StringEncoding];\n    WCDB::Value value(WCDB::UnsafeData((unsigned char*) nsData.bytes, nsData.length));\n    TestCaseAssertStringEqual([NSString stringWithUTF8String:value.textValue().data()], @\"\");\n    TestCaseAssertFalse(value.isNull());\n    TestCaseAssertTrue(value.isEmpty());\n    TestCaseAssertFalse(value);\n\n    NSData* nsData2 = [@\"1.2\" dataUsingEncoding:NSUTF8StringEncoding];\n    value = WCDB::UnsafeData((unsigned char*) nsData2.bytes, nsData2.length);\n    TestCaseAssertStringEqual([NSString stringWithUTF8String:value.textValue().data()], @\"1.2\");\n    TestCaseAssertFalse(value.isNull());\n    TestCaseAssertFalse(value.isEmpty());\n    TestCaseAssertTrue((double) value == 1.2);\n    TestCaseAssertTrue(value);\n\n    WCDB::LiteralValue literal = value;\n    TestCaseAssertSQLEqual(literal, @\"'1.2'\");\n}\n\n- (void)test_shared_ptr_interger\n{\n    WCDB::Value value(std::make_shared<int>(0));\n    TestCaseAssertTrue(value.intValue() == 0);\n    TestCaseAssertTrue((int) value == 0);\n    TestCaseAssertFalse(value);\n    TestCaseAssertTrue(value.isEmpty());\n    TestCaseAssertFalse(value.isNull());\n\n    value = std::make_shared<int>(1);\n    TestCaseAssertFalse(value.isNull());\n    TestCaseAssertFalse(value.isEmpty());\n    TestCaseAssertTrue((int) value == 1);\n    TestCaseAssertTrue(value);\n\n    WCDB::LiteralValue literal = value;\n    TestCaseAssertSQLEqual(literal, @\"1\");\n\n    value = std::shared_ptr<int>();\n    TestCaseAssertTrue(value.isNull());\n}\n\n- (void)test_shared_ptr_float\n{\n    WCDB::Value value(std::make_shared<float>(0));\n    TestCaseAssertTrue(value.floatValue() == 0);\n    TestCaseAssertTrue((double) value == 0);\n    TestCaseAssertFalse(value);\n    TestCaseAssertTrue(value.isEmpty());\n\n    value = std::make_shared<double>(1.2);\n    TestCaseAssertFalse(value.isNull());\n    TestCaseAssertFalse(value.isEmpty());\n    TestCaseAssertTrue((double) value == 1.2);\n    TestCaseAssertTrue(value);\n\n    WCDB::LiteralValue literal = value;\n    TestCaseAssertSQLEqual(literal, @\"1.2\");\n\n    value = std::shared_ptr<float>();\n    TestCaseAssertTrue(value.isNull());\n}\n\n- (void)test_shared_ptr_string\n{\n    WCDB::Value value(std::make_shared<std::string>(\"\"));\n    TestCaseAssertStringEqual([NSString stringWithUTF8String:value.textValue().data()], @\"\");\n    TestCaseAssertFalse(value.isNull());\n    TestCaseAssertTrue(value.isEmpty());\n    TestCaseAssertTrue((double) value == 0);\n    TestCaseAssertFalse(value);\n\n    value = std::make_shared<std::string>(\"1.2\");\n    TestCaseAssertStringEqual([NSString stringWithUTF8String:value.textValue().data()], @\"1.2\");\n    TestCaseAssertFalse(value.isNull());\n    TestCaseAssertFalse(value.isEmpty());\n    TestCaseAssertTrue((double) value == 1.2);\n    TestCaseAssertTrue(value);\n\n    WCDB::LiteralValue literal = value;\n    TestCaseAssertSQLEqual(literal, @\"'1.2'\");\n\n    value = std::shared_ptr<WCDB::StringView>();\n    TestCaseAssertTrue(value.isNull());\n}\n\n- (void)test_shared_ptr_blob\n{\n    NSData* nsData = [@\"\" dataUsingEncoding:NSUTF8StringEncoding];\n    WCDB::Value value(std::make_shared<WCDB::UnsafeData>((unsigned char*) nsData.bytes, nsData.length));\n    TestCaseAssertStringEqual([NSString stringWithUTF8String:value.textValue().data()], @\"\");\n    TestCaseAssertFalse(value.isNull());\n    TestCaseAssertTrue(value.isEmpty());\n    TestCaseAssertFalse(value);\n\n    NSData* nsData2 = [@\"1.2\" dataUsingEncoding:NSUTF8StringEncoding];\n    value = std::make_shared<WCDB::UnsafeData>((unsigned char*) nsData2.bytes, nsData2.length);\n    TestCaseAssertStringEqual([NSString stringWithUTF8String:value.textValue().data()], @\"1.2\");\n    TestCaseAssertFalse(value.isNull());\n    TestCaseAssertFalse(value.isEmpty());\n    TestCaseAssertTrue((double) value == 1.2);\n    TestCaseAssertTrue(value);\n\n    WCDB::LiteralValue literal = value;\n    TestCaseAssertSQLEqual(literal, @\"'1.2'\");\n\n    value = std::shared_ptr<WCDB::UnsafeData>();\n    TestCaseAssertTrue(value.isNull());\n}\n\n#if defined(__cplusplus) && __cplusplus > 201402L\n- (void)test_std_optional_interger\n{\n    WCDB::Value value(std::make_optional<int>(0));\n    TestCaseAssertTrue(value.intValue() == 0);\n    TestCaseAssertTrue((int) value == 0);\n    TestCaseAssertFalse(value);\n    TestCaseAssertTrue(value.isEmpty());\n    TestCaseAssertFalse(value.isNull());\n\n    value = std::make_optional<int>(1);\n    TestCaseAssertFalse(value.isNull());\n    TestCaseAssertFalse(value.isEmpty());\n    TestCaseAssertTrue((int) value == 1);\n    TestCaseAssertTrue(value);\n\n    WCDB::LiteralValue literal = value;\n    TestCaseAssertSQLEqual(literal, @\"1\");\n\n    value = std::optional<int>();\n    TestCaseAssertTrue(value.isNull());\n}\n\n- (void)test_std_optional_float\n{\n    WCDB::Value value(std::make_optional<float>(0));\n    TestCaseAssertTrue(value.floatValue() == 0);\n    TestCaseAssertTrue((double) value == 0);\n    TestCaseAssertFalse(value);\n    TestCaseAssertTrue(value.isEmpty());\n\n    value = std::make_optional<double>(1.2);\n    TestCaseAssertFalse(value.isNull());\n    TestCaseAssertFalse(value.isEmpty());\n    TestCaseAssertTrue((double) value == 1.2);\n    TestCaseAssertTrue(value);\n\n    WCDB::LiteralValue literal = value;\n    TestCaseAssertSQLEqual(literal, @\"1.2\");\n\n    value = std::optional<float>();\n    TestCaseAssertTrue(value.isNull());\n}\n\n- (void)test_std_optional_string\n{\n    WCDB::Value value(std::make_optional<std::string>(\"\"));\n    TestCaseAssertStringEqual([NSString stringWithUTF8String:value.textValue().data()], @\"\");\n    TestCaseAssertFalse(value.isNull());\n    TestCaseAssertTrue(value.isEmpty());\n    TestCaseAssertTrue((double) value == 0);\n    TestCaseAssertFalse(value);\n\n    value = std::make_optional<std::string>(\"1.2\");\n    TestCaseAssertStringEqual([NSString stringWithUTF8String:value.textValue().data()], @\"1.2\");\n    TestCaseAssertFalse(value.isNull());\n    TestCaseAssertFalse(value.isEmpty());\n    TestCaseAssertTrue((double) value == 1.2);\n    TestCaseAssertTrue(value);\n\n    WCDB::LiteralValue literal = value;\n    TestCaseAssertSQLEqual(literal, @\"'1.2'\");\n\n    value = std::optional<WCDB::StringView>();\n    TestCaseAssertTrue(value.isNull());\n}\n\n- (void)test_std_optional_blob\n{\n    NSData* nsData = [@\"\" dataUsingEncoding:NSUTF8StringEncoding];\n    WCDB::Value value(std::make_optional<WCDB::UnsafeData>((unsigned char*) nsData.bytes, nsData.length));\n    TestCaseAssertStringEqual([NSString stringWithUTF8String:value.textValue().data()], @\"\");\n    TestCaseAssertFalse(value.isNull());\n    TestCaseAssertTrue(value.isEmpty());\n    TestCaseAssertFalse(value);\n\n    NSData* nsData2 = [@\"1.2\" dataUsingEncoding:NSUTF8StringEncoding];\n    value = std::make_optional<WCDB::UnsafeData>((unsigned char*) nsData2.bytes, nsData2.length);\n    TestCaseAssertStringEqual([NSString stringWithUTF8String:value.textValue().data()], @\"1.2\");\n    TestCaseAssertFalse(value.isNull());\n    TestCaseAssertFalse(value.isEmpty());\n    TestCaseAssertTrue((double) value == 1.2);\n    TestCaseAssertTrue(value);\n\n    WCDB::LiteralValue literal = value;\n    TestCaseAssertSQLEqual(literal, @\"'1.2'\");\n\n    value = std::optional<WCDB::UnsafeData>();\n    TestCaseAssertTrue(value.isNull());\n}\n#endif\n\n- (void)test_wcdb_optional_interger\n{\n    WCDB::Value value(WCDB::Optional<int>(0));\n    TestCaseAssertTrue(value.intValue() == 0);\n    TestCaseAssertTrue((int) value == 0);\n    TestCaseAssertFalse(value);\n    TestCaseAssertTrue(value.isEmpty());\n    TestCaseAssertFalse(value.isNull());\n\n    value = WCDB::Optional<int>(1);\n    TestCaseAssertFalse(value.isNull());\n    TestCaseAssertFalse(value.isEmpty());\n    TestCaseAssertTrue((int) value == 1);\n    TestCaseAssertTrue(value);\n\n    WCDB::LiteralValue literal = value;\n    TestCaseAssertSQLEqual(literal, @\"1\");\n\n    value = WCDB::Optional<int>();\n    TestCaseAssertTrue(value.isNull());\n}\n\n- (void)test_wcdb_optional_float\n{\n    WCDB::Value value(WCDB::Optional<float>(0));\n    TestCaseAssertTrue(value.floatValue() == 0);\n    TestCaseAssertTrue((double) value == 0);\n    TestCaseAssertFalse(value);\n    TestCaseAssertTrue(value.isEmpty());\n\n    value = WCDB::Optional<double>(1.2);\n    TestCaseAssertFalse(value.isNull());\n    TestCaseAssertFalse(value.isEmpty());\n    TestCaseAssertTrue((double) value == 1.2);\n    TestCaseAssertTrue(value);\n\n    WCDB::LiteralValue literal = value;\n    TestCaseAssertSQLEqual(literal, @\"1.2\");\n\n    value = WCDB::Optional<float>();\n    TestCaseAssertTrue(value.isNull());\n}\n\n- (void)test_wcdb_optional_string\n{\n    WCDB::Value value(WCDB::Optional<std::string>(\"\"));\n    TestCaseAssertStringEqual([NSString stringWithUTF8String:value.textValue().data()], @\"\");\n    TestCaseAssertFalse(value.isNull());\n    TestCaseAssertTrue(value.isEmpty());\n    TestCaseAssertTrue((double) value == 0);\n    TestCaseAssertFalse(value);\n\n    value = WCDB::Optional<std::string>(\"1.2\");\n    TestCaseAssertStringEqual([NSString stringWithUTF8String:value.textValue().data()], @\"1.2\");\n    TestCaseAssertFalse(value.isNull());\n    TestCaseAssertFalse(value.isEmpty());\n    TestCaseAssertTrue((double) value == 1.2);\n    TestCaseAssertTrue(value);\n\n    WCDB::LiteralValue literal = value;\n    TestCaseAssertSQLEqual(literal, @\"'1.2'\");\n\n    value = WCDB::Optional<WCDB::StringView>();\n    TestCaseAssertTrue(value.isNull());\n}\n\n- (void)test_wcdb_optional_blob\n{\n    NSData* nsData = [@\"\" dataUsingEncoding:NSUTF8StringEncoding];\n    WCDB::Optional<WCDB::UnsafeData> data = WCDB::UnsafeData((unsigned char*) nsData.bytes, nsData.length);\n    WCDB::Value value(data);\n    TestCaseAssertStringEqual([NSString stringWithUTF8String:value.textValue().data()], @\"\");\n    TestCaseAssertFalse(value.isNull());\n    TestCaseAssertTrue(value.isEmpty());\n    TestCaseAssertFalse(value);\n\n    NSData* nsData2 = [@\"1.2\" dataUsingEncoding:NSUTF8StringEncoding];\n    data = WCDB::UnsafeData((unsigned char*) nsData2.bytes, nsData2.length);\n    value = WCDB::Optional<WCDB::UnsafeData>(data);\n    TestCaseAssertStringEqual([NSString stringWithUTF8String:value.textValue().data()], @\"1.2\");\n    TestCaseAssertFalse(value.isNull());\n    TestCaseAssertFalse(value.isEmpty());\n    TestCaseAssertTrue((double) value == 1.2);\n    TestCaseAssertTrue(value);\n\n    WCDB::LiteralValue literal = value;\n    TestCaseAssertSQLEqual(literal, @\"'1.2'\");\n\n    value = WCDB::Optional<WCDB::UnsafeData>();\n    TestCaseAssertTrue(value.isNull());\n}\n\n@end\n"
  },
  {
    "path": "src/objc/tests/winq/WCTPropertyTests.mm",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"WINQAssertion.h\"\n\n@interface WCTPropertyTests : BaseTestCase\n\n@end\n\n@implementation WCTPropertyTests {\n    WCTColumnBinding columnBinding1;\n    WCTColumnBinding columnBinding2;\n}\n\n- (void)setUp\n{\n    [super setUp];\n    columnBinding1 = WCTColumnBinding::generate<int>(TestCaseObject.class, \"identifier\");\n    columnBinding2 = WCTColumnBinding::generate<double>(TestCaseObject.class, \"content\");\n}\n\n- (void)test_default_constructible\n{\n    WCTProperty constructible;\n    TestCaseAssertFalse(constructible.syntax().isValid());\n    TestCaseAssertIterateEqual(constructible, std::list<WCDB::Syntax::Identifier::Type>());\n    TestCaseAssertTrue(constructible.getDescription().empty());\n}\n\n- (void)test_property_convertible\n{\n    WCTProperty sql(columnBinding1);\n    NSString* expected = @\"identifier\";\n    TestCaseAssertWINQConvertible(WCDB::Column, sql, expected);\n    TestCaseAssertWINQConvertible(WCDB::Columns, sql, expected);\n    TestCaseAssertWINQConvertible(WCDB::Expression, sql, expected);\n    TestCaseAssertWINQConvertible(WCDB::Expressions, sql, expected);\n    TestCaseAssertWINQConvertible(WCDB::IndexedColumn, sql, expected);\n    TestCaseAssertWINQConvertible(WCDB::IndexedColumns, sql, expected);\n    TestCaseAssertWINQConvertible(WCDB::ResultColumn, sql, expected);\n    TestCaseAssertWINQConvertible(WCDB::ResultColumns, sql, expected);\n    TestCaseAssertWINQConvertible(WCDB::OrderingTerm, sql, expected);\n    TestCaseAssertWINQConvertible(WCDB::OrderingTerms, sql, expected);\n\n    TestCaseAssertWINQConvertible(WCTProperty, sql, expected);\n    TestCaseAssertWINQConvertible(WCTProperties, sql, expected);\n    TestCaseAssertWINQConvertible(WCTResultColumn, sql, expected);\n    TestCaseAssertWINQConvertible(WCTResultColumns, sql, expected);\n}\n\n- (void)test_properties_convertible\n{\n    WCTProperties sqls = {\n        WCTProperty(columnBinding1),\n        WCTProperty(columnBinding2),\n    };\n    NSString* expected = @\"identifier, content\";\n    TestCaseAssertWINQConvertible(WCDB::Columns, sqls, expected);\n    TestCaseAssertWINQConvertible(WCDB::Expressions, sqls, expected);\n    TestCaseAssertWINQConvertible(WCDB::IndexedColumns, sqls, expected);\n    TestCaseAssertWINQConvertible(WCDB::ResultColumns, sqls, expected);\n    TestCaseAssertWINQConvertible(WCDB::OrderingTerms, sqls, expected);\n\n    TestCaseAssertWINQConvertible(WCTProperties, sqls, expected);\n    TestCaseAssertWINQConvertible(WCTResultColumns, sqls, expected);\n}\n\n- (void)test_redirect\n{\n    WCTProperty property(columnBinding1);\n    WCTResultColumn resultColumn = property.redirect(1);\n\n    TestCaseAssertSQLEqual(resultColumn, @\"1\");\n    TestCaseAssertEqual(resultColumn.getColumnBinding(), property.getColumnBinding());\n}\n\n- (void)test_as_indexed_column\n{\n    WCTProperty property(columnBinding1);\n\n    TestCaseAssertSQLEqual(property.asIndex(), @\"identifier\");\n}\n\n- (void)test_as_indexed_column_with_order\n{\n    WCTProperty property(columnBinding1);\n\n    TestCaseAssertSQLEqual(property.asIndex(WCTOrderedAscending), @\"identifier ASC\");\n}\n\n- (void)test_as_ordering_term\n{\n    WCTProperty property(columnBinding1);\n\n    TestCaseAssertSQLEqual(property.asOrder(), @\"identifier\");\n}\n\n- (void)test_as_ordering_term_with_order\n{\n    WCTProperty property(columnBinding1);\n\n    TestCaseAssertSQLEqual(property.asOrder(WCTOrderedAscending), @\"identifier ASC\");\n}\n\n- (void)test_properties_count\n{\n    WCTProperties properties = {\n        WCTProperty(columnBinding1),\n        WCTProperty(columnBinding2),\n    };\n    TestCaseAssertSQLEqual(properties.count(), @\"count(*)\");\n}\n\n- (void)test_properties_redirect\n{\n    WCTProperties properties = {\n        WCTProperty(columnBinding1),\n        WCTProperty(columnBinding2),\n    };\n    WCTResultColumns resultColumns = properties.redirect({ 1, 2 });\n    TestCaseAssertSQLEqual(resultColumns[0], @\"1\");\n    TestCaseAssertSQLEqual(resultColumns[1], @\"2\");\n    TestCaseAssertEqual(resultColumns[0].getColumnBinding(), properties[0].getColumnBinding());\n    TestCaseAssertEqual(resultColumns[1].getColumnBinding(), properties[1].getColumnBinding());\n}\n\n- (void)test_properties_redirector\n{\n    WCTProperties properties = {\n        WCTProperty(columnBinding1),\n        WCTProperty(columnBinding2),\n    };\n    WCTResultColumns resultColumns = properties.redirect([](const WCTProperty& property) -> WCDB::ResultColumn {\n        return property.table(@\"testTable\");\n    });\n    TestCaseAssertSQLEqual(resultColumns[0], @\"testTable.identifier\");\n    TestCaseAssertSQLEqual(resultColumns[1], @\"testTable.content\");\n    TestCaseAssertEqual(resultColumns[0].getColumnBinding(), properties[0].getColumnBinding());\n    TestCaseAssertEqual(resultColumns[1].getColumnBinding(), properties[1].getColumnBinding());\n}\n\n- (void)test_properties_redirect_unpaired\n{\n    {\n        WCTProperties properties = {\n            WCTProperty(columnBinding1),\n            WCTProperty(columnBinding2),\n        };\n        WCTResultColumns resultColumns = properties.redirect(1);\n        TestCaseAssertEqual(resultColumns.size(), 1);\n    }\n    {\n        WCTProperties properties = {\n            WCTProperty(columnBinding1),\n        };\n        WCTResultColumns resultColumns = properties.redirect({ 1, 2 });\n        TestCaseAssertEqual(resultColumns.size(), 1);\n    }\n}\n\n- (void)test_property_table\n{\n    WCTProperty property(columnBinding1);\n    NSString* table = @\"testTable\";\n    WCDB::Expression expression = property.table(table);\n    TestCaseAssertSQLEqual(expression, @\"testTable.identifier\");\n}\n\n- (void)test_properties_table\n{\n    WCTProperties properties = {\n        WCTProperty(columnBinding1),\n        WCTProperty(columnBinding2),\n    };\n    NSString* table = @\"testTable\";\n    WCDB::Expressions expressions = properties.table(table);\n    TestCaseAssertEqual(expressions.size(), properties.size());\n    TestCaseAssertSQLEqual(expressions[0], @\"testTable.identifier\");\n    TestCaseAssertSQLEqual(expressions[1], @\"testTable.content\");\n}\n\n- (void)test_properties_by_adding\n{\n    WCTProperties properties = {\n        WCTProperty(columnBinding1),\n        WCTProperty(columnBinding2),\n    };\n    WCTProperties newProperties = properties.addingNewProperties(properties);\n    TestCaseAssertEqual(properties.size(), 4);\n    TestCaseAssertEqual(newProperties.size(), 4);\n}\n\n- (void)test_properties_adding\n{\n    WCTProperties properties = {\n        WCTProperty(columnBinding1),\n        WCTProperty(columnBinding2),\n    };\n    WCTProperties newProperties = properties.propertiesByAddingNewProperties(properties);\n    TestCaseAssertEqual(properties.size(), 2);\n    TestCaseAssertEqual(newProperties.size(), 4);\n}\n\n- (void)test_properties_by_removing\n{\n    WCTProperties properties = {\n        WCTProperty(columnBinding1),\n        WCTProperty(columnBinding2),\n    };\n    WCTProperties newProperties = properties.removingProperties(WCTProperty(columnBinding1));\n    TestCaseAssertEqual(properties.size(), 1);\n    TestCaseAssertEqual(newProperties.size(), 1);\n}\n\n- (void)test_properties_removing\n{\n    WCTProperties properties = {\n        WCTProperty(columnBinding1),\n        WCTProperty(columnBinding2),\n    };\n    WCTProperties newProperties = properties.propertiesByRemovingProperties(WCTProperty(columnBinding1));\n    TestCaseAssertEqual(properties.size(), 2);\n    TestCaseAssertEqual(newProperties.size(), 1);\n}\n\n@end\n"
  },
  {
    "path": "src/objc/tests/winq/WCTResultColumnTests.mm",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"WINQAssertion.h\"\n\n@interface WCTResultColumnTests : BaseTestCase\n\n@end\n\n@implementation WCTResultColumnTests {\n    WCTProperty property1;\n    WCTProperty property2;\n}\n\n- (void)setUp\n{\n    [super setUp];\n    property1 = WCTProperty(WCTColumnBinding::generate<int>(TestCaseObject.class, \"identifier\"));\n    property2 = WCTProperty(WCTColumnBinding::generate<double>(TestCaseObject.class, \"content\"));\n}\n\n- (void)test_default_constructible\n{\n    WCTResultColumn constructible;\n    TestCaseAssertFalse(constructible.syntax().isValid());\n    TestCaseAssertIterateEqual(constructible, std::list<WCDB::Syntax::Identifier::Type>());\n    TestCaseAssertTrue(constructible.getDescription().empty());\n}\n\n- (void)test_property_convertible\n{\n    WCTResultColumn sql(property1);\n    NSString* expected = @\"identifier\";\n    TestCaseAssertWINQConvertible(WCDB::ResultColumn, sql, expected);\n    TestCaseAssertWINQConvertible(WCDB::ResultColumns, sql, expected);\n\n    TestCaseAssertWINQConvertible(WCTResultColumn, sql, expected);\n    TestCaseAssertWINQConvertible(WCTResultColumns, sql, expected);\n}\n\n- (void)test_properties_convertible\n{\n    WCTResultColumns sqls = {\n        property1,\n        property2,\n    };\n    NSString* expected = @\"identifier, content\";\n    TestCaseAssertWINQConvertible(WCDB::ResultColumns, sqls, expected);\n\n    TestCaseAssertWINQConvertible(WCTResultColumns, sqls, expected);\n}\n\n- (void)test_redirect\n{\n    WCTResultColumn resultColumn = property1;\n    WCTResultColumn redirected = resultColumn.redirect(1);\n\n    TestCaseAssertSQLEqual(redirected, @\"1\");\n    TestCaseAssertEqual(redirected.getColumnBinding(), resultColumn.getColumnBinding());\n}\n\n- (void)test_results_by_adding\n{\n    WCTResultColumns resultColumns = {\n        property1,\n        property2,\n    };\n    WCTResultColumns newResultColumns = resultColumns.addingNewResultColumns(resultColumns);\n    TestCaseAssertEqual(resultColumns.size(), 4);\n    TestCaseAssertEqual(newResultColumns.size(), 4);\n}\n\n- (void)test_results_adding\n{\n    WCTResultColumns resultColumns = {\n        property1,\n        property2,\n    };\n    WCTResultColumns newResultColumns = resultColumns.resultColumnsByAddingNewResultColumns(resultColumns);\n    TestCaseAssertEqual(resultColumns.size(), 2);\n    TestCaseAssertEqual(newResultColumns.size(), 4);\n}\n\n- (void)test_results_by_removing\n{\n    WCTResultColumns resultColumns = {\n        property1,\n        property2,\n    };\n    WCTResultColumns newResultColumns = resultColumns.removingResultColumns(property1);\n    TestCaseAssertEqual(resultColumns.size(), 1);\n    TestCaseAssertEqual(newResultColumns.size(), 1);\n}\n\n- (void)test_results_removing\n{\n    WCTResultColumns resultColumns = {\n        property1,\n        property2,\n    };\n    WCTResultColumns newResultColumns = resultColumns.resultColumnsByRemovingResultColumns(property1);\n    TestCaseAssertEqual(resultColumns.size(), 2);\n    TestCaseAssertEqual(newResultColumns.size(), 1);\n}\n\n@end\n"
  },
  {
    "path": "src/objc/tests/winq/WINQAssertion.h",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"TestCase.h\"\n#import <Foundation/Foundation.h>\n\nnamespace WCDB {\n\nNSString *getDescriptionOfType(WCDB::Syntax::Identifier::Type type);\nNSString *getDescriptionOfTypes(const std::list<WCDB::Syntax::Identifier::Type> &);\nstd::list<WCDB::Syntax::Identifier::Type> getTypesOfSQL(WCDB::SQL &sql);\n\n} // namespace WCDB\n\n#define TestCaseAssertIterateEqual(_sql, _expected)                                    \\\n    {                                                                                  \\\n        std::list<WCDB::Syntax::Identifier::Type> __types = WCDB::getTypesOfSQL(_sql); \\\n        std::list<WCDB::Syntax::Identifier::Type> __expected = (_expected);            \\\n        TestCaseAssertTypesEqual(__types, __expected);                                 \\\n    }\n\n#define TestCaseAssertWINQConvertible(_Type, _parameter, _sql) TestCaseAssertSQLEqual([](const _Type &_value) -> _Type { return _value; }(_parameter), _sql)\n\n#define TestCaseAssertTypesEqual(_left, _right) \\\n    TestCaseAssertStringEqual(WCDB::getDescriptionOfTypes(_left), WCDB::getDescriptionOfTypes(_right))\n"
  },
  {
    "path": "src/objc/tests/winq/WINQAssertion.mm",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"WINQAssertion.h\"\n\nnamespace WCDB {\n\nNSString* getDescriptionOfType(WCDB::Syntax::Identifier::Type type)\n{\n    switch (type) {\n    case Syntax::Identifier::Type::Column:\n        return @\"Column\";\n    case Syntax::Identifier::Type::Schema:\n        return @\"Schema\";\n    case Syntax::Identifier::Type::ColumnDef:\n        return @\"ColumnDef\";\n    case Syntax::Identifier::Type::ColumnConstraint:\n        return @\"ColumnConstraint\";\n    case Syntax::Identifier::Type::Expression:\n        return @\"Expression\";\n    case Syntax::Identifier::Type::LiteralValue:\n        return @\"LiteralValue\";\n    case Syntax::Identifier::Type::ForeignKeyClause:\n        return @\"ForeignKeyClause\";\n    case Syntax::Identifier::Type::BindParameter:\n        return @\"BindParameter\";\n    case Syntax::Identifier::Type::RaiseFunction:\n        return @\"RaiseFunction\";\n    case Syntax::Identifier::Type::WindowDef:\n        return @\"WindowDef\";\n    case Syntax::Identifier::Type::Filter:\n        return @\"Filter\";\n    case Syntax::Identifier::Type::IndexedColumn:\n        return @\"IndexedColumn\";\n    case Syntax::Identifier::Type::TableConstraint:\n        return @\"TableConstraint\";\n    case Syntax::Identifier::Type::CommonTableExpression:\n        return @\"CommonTableExpression\";\n    case Syntax::Identifier::Type::QualifiedTableName:\n        return @\"QualifiedTableName\";\n    case Syntax::Identifier::Type::OrderingTerm:\n        return @\"OrderingTerm\";\n    case Syntax::Identifier::Type::UpsertClause:\n        return @\"UpsertClause\";\n    case Syntax::Identifier::Type::Pragma:\n        return @\"Pragma\";\n    case Syntax::Identifier::Type::JoinClause:\n        return @\"JoinClause\";\n    case Syntax::Identifier::Type::TableOrSubquery:\n        return @\"TableOrSubquery\";\n    case Syntax::Identifier::Type::JoinConstraint:\n        return @\"JoinConstraint\";\n    case Syntax::Identifier::Type::SelectCore:\n        return @\"SelectCore\";\n    case Syntax::Identifier::Type::ResultColumn:\n        return @\"ResultColumn\";\n    case Syntax::Identifier::Type::FrameSpec:\n        return @\"FrameSpec\";\n    case Syntax::Identifier::Type::AlterTableSTMT:\n        return @\"AlterTableSTMT\";\n    case Syntax::Identifier::Type::AnalyzeSTMT:\n        return @\"AnalyzeSTMT\";\n    case Syntax::Identifier::Type::AttachSTMT:\n        return @\"AttachSTMT\";\n    case Syntax::Identifier::Type::BeginSTMT:\n        return @\"BeginSTMT\";\n    case Syntax::Identifier::Type::CommitSTMT:\n        return @\"CommitSTMT\";\n    case Syntax::Identifier::Type::RollbackSTMT:\n        return @\"RollbackSTMT\";\n    case Syntax::Identifier::Type::SavepointSTMT:\n        return @\"SavepointSTMT\";\n    case Syntax::Identifier::Type::ReleaseSTMT:\n        return @\"ReleaseSTMT\";\n    case Syntax::Identifier::Type::CreateIndexSTMT:\n        return @\"CreateIndexSTMT\";\n    case Syntax::Identifier::Type::CreateTableSTMT:\n        return @\"CreateTableSTMT\";\n    case Syntax::Identifier::Type::CreateTriggerSTMT:\n        return @\"CreateTriggerSTMT\";\n    case Syntax::Identifier::Type::SelectSTMT:\n        return @\"SelectSTMT\";\n    case Syntax::Identifier::Type::InsertSTMT:\n        return @\"InsertSTMT\";\n    case Syntax::Identifier::Type::DeleteSTMT:\n        return @\"DeleteSTMT\";\n    case Syntax::Identifier::Type::UpdateSTMT:\n        return @\"UpdateSTMT\";\n    case Syntax::Identifier::Type::CreateViewSTMT:\n        return @\"CreateViewSTMT\";\n    case Syntax::Identifier::Type::CreateVirtualTableSTMT:\n        return @\"CreateVirtualTableSTMT\";\n    case Syntax::Identifier::Type::DetachSTMT:\n        return @\"DetachSTMT\";\n    case Syntax::Identifier::Type::DropIndexSTMT:\n        return @\"DropIndexSTMT\";\n    case Syntax::Identifier::Type::DropTableSTMT:\n        return @\"DropTableSTMT\";\n    case Syntax::Identifier::Type::DropTriggerSTMT:\n        return @\"DropTriggerSTMT\";\n    case Syntax::Identifier::Type::DropViewSTMT:\n        return @\"DropViewSTMT\";\n    case Syntax::Identifier::Type::PragmaSTMT:\n        return @\"PragmaSTMT\";\n    case Syntax::Identifier::Type::ReindexSTMT:\n        return @\"ReindexSTMT\";\n    case Syntax::Identifier::Type::VacuumSTMT:\n        return @\"VacuumSTMT\";\n    case Syntax::Identifier::Type::ExplainSTMT:\n        return @\"ExplainSTMT\";\n    case Syntax::Identifier::Type::Invalid:\n        return @\"InvalidSTMT\";\n    }\n}\n\nstd::list<WCDB::Syntax::Identifier::Type> getTypesOfSQL(WCDB::SQL& sql)\n{\n    std::list<WCDB::Syntax::Identifier::Type> types;\n    sql.iterate([&types](WCDB::Syntax::Identifier& identifier, bool begin, bool&) {\n        if (!begin) {\n            return;\n        }\n        types.push_back(identifier.getType());\n    });\n    return types;\n}\n\nNSString* getDescriptionOfTypes(const std::list<WCDB::Syntax::Identifier::Type>& types)\n{\n    NSMutableString* description = [NSMutableString string];\n    BOOL comma = NO;\n    for (const auto& type : types) {\n        if (comma) {\n            [description appendString:@\", \"];\n        } else {\n            comma = true;\n        }\n        [description appendString:getDescriptionOfType(type)];\n    }\n    return description;\n}\n\n} // namespace WCDB\n"
  },
  {
    "path": "src/objc/tests/winq/WindowDefTests.mm",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"WINQAssertion.h\"\n\n@interface WindowDefTests : BaseTestCase\n\n@end\n\n@implementation WindowDefTests {\n    WCDB::Expressions expressions;\n    WCDB::OrderingTerms orderingTerms;\n    WCDB::FrameSpec frameSpec;\n}\n\n- (void)setUp\n{\n    [super setUp];\n    expressions = {\n        1,\n        2,\n    };\n    orderingTerms = {\n        1,\n        2,\n    };\n    frameSpec = WCDB::FrameSpec().range().unboundedPreceding();\n}\n\n- (void)test_default_constructible\n{\n    WCDB::WindowDef constructible;\n    TestCaseAssertFalse(constructible.syntax().isValid());\n    TestCaseAssertSQLEqual(constructible, @\"\");\n}\n\n- (void)test_get_type\n{\n    TestCaseAssertEqual(WCDB::WindowDef().getType(), WCDB::SQL::Type::WindowDef);\n    TestCaseAssertEqual(WCDB::WindowDef::type, WCDB::SQL::Type::WindowDef);\n}\n\n- (void)test_partition\n{\n    auto testingSQL = WCDB::WindowDef().partition(expressions);\n\n    auto testingTypes = { WCDB::SQL::Type::WindowDef, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"(PARTITION BY 1, 2)\");\n}\n\n- (void)test_order\n{\n    auto testingSQL = WCDB::WindowDef().order(orderingTerms);\n\n    auto testingTypes = { WCDB::SQL::Type::WindowDef, WCDB::SQL::Type::OrderingTerm, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue, WCDB::SQL::Type::OrderingTerm, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"(ORDER BY 1, 2)\");\n}\n\n- (void)test_framespec\n{\n    auto testingSQL = WCDB::WindowDef().framespec(frameSpec);\n\n    auto testingTypes = { WCDB::SQL::Type::WindowDef, WCDB::SQL::Type::FrameSpec };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"(RANGE UNBOUNDED PRECEDING)\");\n}\n\n- (void)test_long\n{\n    auto testingSQL = WCDB::WindowDef().partition(expressions).order(orderingTerms).framespec(frameSpec);\n\n    auto testingTypes = { WCDB::SQL::Type::WindowDef, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue, WCDB::SQL::Type::OrderingTerm, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue, WCDB::SQL::Type::OrderingTerm, WCDB::SQL::Type::Expression, WCDB::SQL::Type::LiteralValue, WCDB::SQL::Type::FrameSpec };\n    TestCaseAssertIterateEqual(testingSQL, testingTypes);\n    TestCaseAssertSQLEqual(testingSQL, @\"(PARTITION BY 1, 2 ORDER BY 1, 2 RANGE UNBOUNDED PRECEDING)\");\n}\n\n@end\n"
  },
  {
    "path": "src/objc/transaction/WCTDatabase+Transaction.h",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"WCTDatabase.h\"\n#import \"WCTTransaction.h\"\n\nWCDB_API @interface WCTDatabase(Transaction)<WCTTransactionProtocol>\n\n@end\n"
  },
  {
    "path": "src/objc/transaction/WCTDatabase+Transaction.mm",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"WCTDatabase+Private.h\"\n#import \"WCTDatabase+Transaction.h\"\n#import \"WCTHandle+Private.h\"\n\n@implementation WCTDatabase (Transaction)\n\n- (BOOL)isInTransaction\n{\n    return _database->isInTransaction();\n}\n\n- (BOOL)beginTransaction\n{\n    return _database->beginTransaction();\n}\n\n- (BOOL)commitOrRollbackTransaction\n{\n    return _database->commitOrRollbackTransaction();\n}\n\n- (void)rollbackTransaction\n{\n    return _database->rollbackTransaction();\n}\n\n- (BOOL)runTransaction:(WCDB_NO_ESCAPE WCTTransactionBlock)inTransaction\n{\n    WCTRemedialAssert(inTransaction, \"Transaction block can't be null.\", return NO;);\n    return _database->runTransaction([&inTransaction, self](WCDB::InnerHandle *handle) -> bool {\n        @autoreleasepool {\n            WCTHandle *transactionHandle = [[WCTHandle alloc] initWithDatabase:self andUnsafeHandle:handle];\n            BOOL result = inTransaction(transactionHandle);\n            [transactionHandle invalidate];\n            return result;\n        }\n    });\n}\n\n- (BOOL)runPausableTransactionWithOneLoop:(WCDB_NO_ESCAPE WCTTransactionBlockForOneLoop)inTransaction\n{\n    WCTRemedialAssert(inTransaction, \"Transaction block can't be null.\", return NO;);\n    WCTHandle *transactionHandle = nil;\n    BOOL ocStop = NO;\n    bool ret = _database->runPausableTransactionWithOneLoop([&inTransaction, self, transactionHandle, ocStop](WCDB::InnerHandle *handle, bool &stop, bool isNewTransaction) mutable -> bool {\n        @autoreleasepool {\n            if (!transactionHandle) {\n                transactionHandle = [[WCTHandle alloc] initWithDatabase:self andUnsafeHandle:handle];\n            }\n            BOOL result = inTransaction(transactionHandle, &ocStop, isNewTransaction);\n            stop = ocStop;\n            return result;\n        }\n    });\n    if (transactionHandle) {\n        [transactionHandle invalidate];\n    }\n    return ret;\n}\n\n@end\n"
  },
  {
    "path": "src/objc/transaction/WCTHandle+Transaction.h",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"WCTHandle.h\"\n#import \"WCTTransaction.h\"\n\nWCDB_API @interface WCTHandle(Transaction)<WCTTransactionProtocol>\n\n- (void)markErrorNotAllowedWithinTransaction;\n\n@end\n"
  },
  {
    "path": "src/objc/transaction/WCTHandle+Transaction.mm",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"Assertion.hpp\"\n#import \"Macro.h\"\n#import \"WCTHandle+Private.h\"\n#import \"WCTHandle+Transaction.h\"\n\n@implementation WCTHandle (Transaction)\n\n- (void)markErrorNotAllowedWithinTransaction\n{\n    WCTHandleAssert(return;);\n    WCDB::InnerHandle *handle = [self getOrGenerateHandle];\n    handle->markErrorNotAllowedWithinTransaction();\n}\n\n- (BOOL)isInTransaction\n{\n    BOOL isInTransaction = NO;\n    WCDB::InnerHandle *handle = [self getOrGenerateHandle];\n    if (handle != nullptr) {\n        isInTransaction = handle->isInTransaction();\n    }\n    return isInTransaction;\n}\n\n- (BOOL)beginTransaction\n{\n    BOOL succeed = NO;\n    WCDB::InnerHandle *handle = [self getOrGenerateHandle];\n    if (handle != nullptr) {\n        succeed = handle->beginTransaction();\n    }\n    return succeed;\n}\n\n- (BOOL)commitOrRollbackTransaction\n{\n    WCDB::InnerHandle *handle = [self getOrGenerateHandle];\n    WCTRemedialAssert(handle != nullptr && handle->isInTransaction(), \"Commit or rollback transaction should be called only after beginTransaction called.\", return NO;);\n    return handle->commitOrRollbackTransaction();\n}\n\n- (void)rollbackTransaction\n{\n    WCDB::InnerHandle *handle = [self getOrGenerateHandle];\n    WCTRemedialAssert(handle != nullptr && handle->isInTransaction(), \"Rollback transaction should be called only after beginTransaction called.\", return;);\n    handle->rollbackTransaction();\n}\n\n- (BOOL)runTransaction:(WCDB_NO_ESCAPE WCTTransactionBlock)inTransaction\n{\n    WCTRemedialAssert(inTransaction, \"Transaction block can't be null.\", return NO;);\n    BOOL succeed = NO;\n    WCDB::InnerHandle *handle = [self getOrGenerateHandle];\n    if (handle != nullptr) {\n        succeed = handle->runTransaction([&inTransaction, self](WCDB::InnerHandle *) -> bool {\n            @autoreleasepool {\n                return inTransaction(self);\n            }\n        });\n    }\n    return succeed;\n}\n\n- (BOOL)runPausableTransactionWithOneLoop:(WCDB_NO_ESCAPE WCTTransactionBlockForOneLoop)inTransaction\n{\n    WCTRemedialAssert(inTransaction, \"Transaction block can't be null.\", return NO;);\n    WCDB::InnerHandle *handle = [self getOrGenerateHandle];\n    if (handle == nullptr) {\n        return NO;\n    }\n    BOOL ocStop = NO;\n    bool ret = handle->runPausableTransactionWithOneLoop([&inTransaction, self, ocStop](WCDB::InnerHandle *, bool &stop, bool isNewTransaction) mutable -> bool {\n        @autoreleasepool {\n            BOOL result = inTransaction(self, &ocStop, isNewTransaction);\n            stop = ocStop;\n            return result;\n        }\n    });\n    return ret;\n}\n\n@end\n"
  },
  {
    "path": "src/objc/transaction/WCTTransaction.h",
    "content": "//\n// Created by sanhuazhang on 2019/05/02\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#import \"Macro.h\"\n#import \"WCTDeclaration.h\"\n\nNS_ASSUME_NONNULL_BEGIN\n\n/**\n Triggered when a new transaction is begun successfully.\n */\ntypedef BOOL (^WCTTransactionBlock)(WCTHandle* /*handle*/);\n\n/**\n Triggered when a new transaction is begun successfully or the main thread isn't suspended due to the current transaction.\n */\ntypedef BOOL (^WCTTransactionBlockForOneLoop)(WCTHandle* /*handle*/, BOOL* /*stop*/, BOOL /*isNewTransaction*/);\n\n@protocol WCTTransactionProtocol\n@required\n/**\n @brief Check whether the current database has begun a transaction in the current thread with `sqlite3_get_autocommit`.\n @return YES if current database has begun a transaction in the current thread.\n */\n- (BOOL)isInTransaction;\n\n/**\n @brief Separate interface of `-[WCTTransactionProtocol runTransaction:]`.\n @warning You should call `beginTransaction`, `commitOrRollbackTransaction`, `rollbackTransaction` and all other operations in same thread.\n @return YES only if no error occurs.\n */\n- (BOOL)beginTransaction;\n\n/**\n @brief Separate interface of `-[WCTTransactionProtocol runTransaction:]`.\n It will commit current transaction if no error occurs during the transaction, otherwise it will rollback current transaction.\n @warning You should call `beginTransaction`, `commitOrRollbackTransaction`, `rollbackTransaction` and all other operations in same thread.\n @return YES only if current transaction is committed successfully.\n */\n- (BOOL)commitOrRollbackTransaction;\n\n/**\n @brief Separate interface of `-[WCTTransactionProtocol runTransaction:]`.\n @warning You should call `beginTransaction`, `commitOrRollbackTransaction`, `rollbackTransaction` and all other operations in same thread.\n */\n- (void)rollbackTransaction;\n\n/**\n @brief Run a transaction in block. Transaction supports nesting.\n @param inTransaction Operation inside transaction.\n @return YES only if current transaction is committed successfully.\n */\n- (BOOL)runTransaction:(WCDB_NO_ESCAPE WCTTransactionBlock)inTransaction;\n\n/**\n @brief Run a pausable transaction in block.\n Firstly, WCDB will begin a transaction and call the block. \n After the block is finished, WCDB will check whether the main thread is suspended due to the current transaction.\n If not, it will call the block again; if it is, it will temporarily commit the current transaction.\n Once database operations in main thread are finished, WCDB will rebegin a new transaction in the current thread and call the block.\n This process will be repeated until the second parameter of the block is specified as true, or some error occurs during the transaction.\n You can use pausable transaction to do some long term database operations, such as data cleaning or data migration, and avoid to block the main thread.\n \n     BOOL allCommited = [database runPausableTransactionWithOneLoop:^BOOL(WCTHandle *handle, BOOL *stop, BOOL isNewTransaction) {\n         if(isNewTransaction) {\n             // Do some initialization for new transaction.\n         }\n     \n         // Perform a small amount of data processing.\n     \n         if( Error occurs ) {\n             return NO;\n         }\n         if( All database operations are finished ) {\n             *stop = YES;\n         }\n         return YES;\n     }];\n \n @param inTransaction Operation inside transaction for one loop.\n @see   `WCTTransactionBlockForOneLoop`\n @return YES only if all transactions are committed.\n */\n- (BOOL)runPausableTransactionWithOneLoop:(WCDB_NO_ESCAPE WCTTransactionBlockForOneLoop)inTransaction;\n@end\n\nNS_ASSUME_NONNULL_END\n"
  },
  {
    "path": "src/support/Base.xcconfig",
    "content": "// Architectures\nSUPPORTED_PLATFORMS = macosx iphonesimulator iphoneos watchos watchsimulator appletvos appletvsimulator\nVALID_ARCHS = $(ARCHS_STANDARD)\n\n// Build Options\nALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = NO\n\n// Deployment\nTARGETED_DEVICE_FAMILY = 1,2,3,4\nSTRIP_INSTALLED_PRODUCT = YES\nSKIP_INSTALL = YES\nIPHONEOS_DEPLOYMENT_TARGET = 11.0\nMACOSX_DEPLOYMENT_TARGET = 10.13\nTVOS_DEPLOYMENT_TARGET = 12.4\nWATCHOS_DEPLOYMENT_TARGET = 6.0\nSTRIP_SWIFT_SYMBOLS = YES\n\n// Linking\nDYLIB_COMPATIBILITY_VERSION = 1\nDYLIB_CURRENT_VERSION = 1\nOTHER_LDFLAGS[sdk=macosx*] = -framework Cocoa\nLD_RUNPATH_SEARCH_PATHS = $(inherited) @executable_path/../Frameworks @loader_path/Frameworks\nDYLIB_INSTALL_NAME_BASE = @rpath\n\n// Packaging\nDEFINES_MODULE = YES\nPRODUCT_BUNDLE_IDENTIFIER = com.Tencent.WCDB.$(PRODUCT_NAME:rfc1034identifier)\nPRODUCT_MODULE_NAME = $(PRODUCT_NAME)\nPRODUCT_NAME = $(TARGET_NAME)\n\n// Search Paths\nLIBRARY_SEARCH_PATHS[sdk=macosx*] = $(inherited) $(SDKROOT)/usr/lib/system\n\n// Versioning\nCURRENT_PROJECT_VERSION = 1\nVERSIONING_SYSTEM = apple-generic\n\n// Apple Clang - Address Sanitizer\nCLANG_ADDRESS_SANITIZER_CONTAINER_OVERFLOW = YES\n\n// Apple Clang - Code Generation\nGCC_INLINES_ARE_PRIVATE_EXTERN = YES\nGCC_NO_COMMON_BLOCKS = YES\nGCC_THREADSAFE_STATICS = YES\nGCC_SYMBOLS_PRIVATE_EXTERN = NO\n\n// Apple Clang - Custom Compiler Flags\nOTHER_CFLAGS = -fno-aligned-allocation -Wall -Wextra -Wno-sign-compare\n\n// Apple Clang - Language\nGCC_C_LANGUAGE_STANDARD = gnu11\n\n// Apple Clang - Language - C++\nCLANG_CXX_LANGUAGE_STANDARD = gnu++14\nCLANG_CXX_LIBRARY = libc++\nGCC_ENABLE_CPP_EXCEPTIONS = NO\nGCC_ENABLE_CPP_RTTI = YES\n\n// Apple Clang - Language - Modules\nCLANG_ENABLE_MODULES = YES\nCLANG_MODULES_AUTOLINK = NO\n\n// Apple Clang - Language - Objective-C\nCLANG_ENABLE_OBJC_ARC = YES\nCLANG_ENABLE_OBJC_WEAK = YES\nGCC_ENABLE_OBJC_EXCEPTIONS = NO\n\n// Apple Clang - Preprocessing\nENABLE_STRICT_OBJC_MSGSEND = YES\n\n// Apple Clang - Undefined Behavior Sanitizer\nCLANG_UNDEFINED_BEHAVIOR_SANITIZER_INTEGER = NO\nCLANG_UNDEFINED_BEHAVIOR_SANITIZER_NULLABILITY = YES\n\n// Apple Clang - Warnings - All languages\nCLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES\nGCC_WARN_CHECK_SWITCH_STATEMENTS = YES\nGCC_WARN_ABOUT_DEPRECATED_FUNCTIONS = YES\nCLANG_WARN_DOCUMENTATION_COMMENTS = YES\nCLANG_WARN_EMPTY_BODY = YES\nGCC_WARN_FOUR_CHARACTER_CONSTANTS = YES\nGCC_WARN_SHADOW = YES\nCLANG_WARN_BOOL_CONVERSION = YES\nCLANG_WARN_CONSTANT_CONVERSION = YES\nGCC_WARN_64_TO_32_BIT_CONVERSION = YES\nCLANG_WARN_ENUM_CONVERSION = YES\nCLANG_WARN_INT_CONVERSION = YES\nCLANG_WARN_FLOAT_CONVERSION = YES\nCLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES\nCLANG_WARN_INFINITE_RECURSION = YES\nGCC_WARN_INITIALIZER_NOT_FULLY_BRACKETED = YES\nGCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR\nGCC_WARN_MISSING_PARENTHESES = YES\nGCC_WARN_ABOUT_MISSING_FIELD_INITIALIZERS = YES\nGCC_WARN_ABOUT_MISSING_NEWLINE = YES\nCLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = NO\nCLANG_WARN_SEMICOLON_BEFORE_METHOD_BODY = YES\nCLANG_WARN_STRICT_PROTOTYPES = YES\nCLANG_WARN_ASSIGN_ENUM = YES\nCLANG_WARN_COMMA = YES\nCLANG_WARN_SUSPICIOUS_IMPLICIT_CONVERSION = YES\nCLANG_WARN_PRAGMA_PACK = YES\nGCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE\nGCC_TREAT_IMPLICIT_FUNCTION_DECLARATIONS_AS_ERRORS = YES\nCLANG_WARN_UNGUARDED_AVAILABILITY = YES\nGCC_WARN_UNKNOWN_PRAGMAS = YES\nCLANG_WARN_UNREACHABLE_CODE = YES\nGCC_WARN_UNUSED_PARAMETER = YES\nGCC_WARN_UNUSED_FUNCTION = YES\nGCC_WARN_UNUSED_VARIABLE = YES\nGCC_WARN_UNUSED_VALUE = YES\nGCC_WARN_UNUSED_LABEL = YES\n\n// Apple Clang - Warnings - C++\nCLANG_WARN_DELETE_NON_VIRTUAL_DTOR = YES\nCLANG_WARN__EXIT_TIME_DESTRUCTORS = YES\nGCC_WARN_NON_VIRTUAL_DESTRUCTOR = YES\nGCC_WARN_HIDDEN_VIRTUAL_FUNCTIONS = YES\nCLANG_WARN_RANGE_LOOP_ANALYSIS = YES\nCLANG_WARN_SUSPICIOUS_MOVE = YES\n\n// Apple Clang - Warning - Objective-C\nCLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR\nCLANG_WARN__DUPLICATE_METHOD_MATCH = YES\nCLANG_WARN_OBJC_IMPLICIT_ATOMIC_PROPERTIES = YES\nCLANG_WARN_OBJC_LITERAL_CONVERSION = YES\nGCC_WARN_UNDECLARED_SELECTOR = YES\nCLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR\nCLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES\nCLANG_WARN_MISSING_NOESCAPE = YES\n\n// Apple Clang - Warnings - Objective-C and ARC\nCLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES\nCLANG_WARN_OBJC_REPEATED_USE_OF_WEAK = YES\nCLANG_WARN__ARC_BRIDGE_CAST_NONARC = YES\n\n// Static Analyzer - Generic Issues\nCLANG_ANALYZER_NONNULL = YES\nCLANG_ANALYZER_MEMORY_MANAGEMENT = YES_AGGRESSIVE\nCLANG_ANALYZER_DEADCODE_DEADSTORES = YES\nCLANG_ANALYZER_USE_AFTER_MOVE = YES_AGGRESSIVE\n\n// Static Analyzer - Issues - Apple API\nCLANG_ANALYZER_GCD_PERFORMANCE = YES\nCLANG_ANALYZER_OBJC_NSCFERROR = YES\nCLANG_ANALYZER_OBJC_COLLECTIONS = YES\nCLANG_ANALYZER_GCD = YES\nCLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES\nCLANG_ANALYZER_LIBKERN_RETAIN_COUNT = YES\n\n// Static Analyzer - Issues - Objective-C\nCLANG_ANALYZER_OBJC_ATSYNC = YES\nCLANG_ANALYZER_OBJC_DEALLOC = YES\nCLANG_ANALYZER_OBJC_INCOMP_METHOD_TYPES = YES\nCLANG_ANALYZER_OBJC_GENERICS = YES\nCLANG_ANALYZER_OBJC_UNUSED_IVARS = YES\nCLANG_ANALYZER_OBJC_SELF_INIT = YES\nCLANG_ANALYZER_OBJC_RETAIN_COUNT = YES\n\n// Static Analyzer - Issues - Security\nCLANG_ANALYZER_SECURITY_FLOATLOOPCOUNTER = YES\nCLANG_ANALYZER_SECURITY_INSECUREAPI_UNCHECKEDRETURN = YES\nCLANG_ANALYZER_SECURITY_INSECUREAPI_GETPW_GETS = YES\nCLANG_ANALYZER_SECURITY_INSECUREAPI_MKSTEMP = YES\nCLANG_ANALYZER_SECURITY_INSECUREAPI_RAND = YES\nCLANG_ANALYZER_SECURITY_INSECUREAPI_STRCPY = YES\nCLANG_ANALYZER_SECURITY_INSECUREAPI_VFORK = YES\n\n//// Swift Compiler - Code Generation\n//SWIFT_DISABLE_SAFETY_CHECKS\n//SWIFT_ENFORCE_EXCLUSIVE_ACCESS\n//SWIFT_SWIFT3_OBJC_INFERENCE\n//\n//// Swift Compiler - Custom Flags\n//SWIFT_ACTIVE_COMPILATION_CONDITIONS\n//OTHER_SWIFT_FLAGS\n//\n//// Swift Compiler - General\n//SWIFT_OBJC_BRIDGING_HEADER = $(SRCROOT)/source/util/WCDB-Bridging.h\n//SWIFT_INSTALL_OBJC_HEADER\n//SWIFT_OBJC_BRIDGING_HEADER\n//SWIFT_OBJC_INTERFACE_HEADER_NAME\n//SWIFT_PRECOMPILE_BRIDGING_HEADER\n//SWIFT_REFLECTION_METADATA_LEVEL\n\n// Swift Compiler - Language\nSWIFT_VERSION = 5.0\nSWIFT_INSTALL_OBJC_HEADER = NO\n\n//// Swift Compiler - Search Paths\n//SWIFT_INCLUDE_PATHS\n//\n//// Swift Compiler = Warnings Policies\n//SWIFT_SUPPRESS_WARNINGS\n//SWIFT_TREAT_WARNINGS_AS_ERRORS\n\n// User-Defined\nENABLE_BITCODE = NO\nENABLE_BITCODE[sdk=appletv*] = YES\n"
  },
  {
    "path": "src/support/Debug.xcconfig",
    "content": "#include \"Base.xcconfig\"\n\n// Architectures\nONLY_ACTIVE_ARCH = YES\n\n// Build Options\nDEBUG_INFORMATION_FORMAT = dwarf\nVALIDATE_PRODUCT = NO\nENABLE_TESTABILITY = YES\n\n// Deployment\nDEPLOYMENT_POSTPROCESSING = NO\nCOPY_PHASE_STRIP = NO\nSTRIP_STYLE = debugging\n\n// Linking\nDEAD_CODE_STRIPPING = NO\n\n// Code Generation\nLLVM_LTO = NO\nGCC_OPTIMIZATION_LEVEL = 0\n\n// Preprocessing\nENABLE_NS_ASSERTIONS = YES\nGCC_PREPROCESSOR_DEFINITIONS = $(inherited) DEBUG=1 WCDB_DEBUG=1 WCDB_QUICK_TESTS=1\n\n// Swift Compiler - Code Generation\nSWIFT_COMPILATION_MODE = singlefile\nSWIFT_OPTIMIZATION_LEVEL = -Onone\n\n// Static Analyzer - Issues - Apple APIs\nCLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES\n\n// User-Defined\nBITCODE_GENERATION_MODE = marker\n\n"
  },
  {
    "path": "src/support/Info.plist",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">\n<plist version=\"1.0\">\n<dict>\n\t<key>CFBundleDevelopmentRegion</key>\n\t<string>en</string>\n\t<key>CFBundleExecutable</key>\n\t<string>$(EXECUTABLE_NAME)</string>\n\t<key>CFBundleIdentifier</key>\n\t<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>\n\t<key>CFBundleInfoDictionaryVersion</key>\n\t<string>6.0</string>\n\t<key>CFBundleName</key>\n\t<string>$(PRODUCT_NAME)</string>\n\t<key>CFBundlePackageType</key>\n\t<string>FMWK</string>\n\t<key>CFBundleShortVersionString</key>\n\t<string>$(MARKETING_VERSION)</string>\n\t<key>CFBundleVersion</key>\n\t<string>$(CURRENT_PROJECT_VERSION)</string>\n\t<key>NSHumanReadableCopyright</key>\n\t<string>Copyright © 2017 Tencent. All rights reserved.</string>\n</dict>\n</plist>\n"
  },
  {
    "path": "src/support/Release.xcconfig",
    "content": "#include \"Base.xcconfig\"\n\n// Architectures\nONLY_ACTIVE_ARCH = YES\n\n// Build Options\nDEBUG_INFORMATION_FORMAT = dwarf-with-dsym\nVALIDATE_PRODUCT = YES\n\n// Deployment\nDEPLOYMENT_POSTPROCESSING = YES\nCOPY_PHASE_STRIP = YES\nSTRIP_STYLE = non-global\n\n// Linking\nDEAD_CODE_STRIPPING = YES\n\n// Code Generation\nLLVM_LTO = YES\nGCC_OPTIMIZATION_LEVEL = s\n\n// Preprocessing\nENABLE_NS_ASSERTIONS = NO\nGCC_PREPROCESSOR_DEFINITIONS = $(inherited) NDEBUG=1\n\n// Swift Compiler - Code Generation\nSWIFT_COMPILATION_MODE = wholemodule\nSWIFT_OPTIMIZATION_LEVEL = -Owholemodule;\n\n// User-Defined\nBITCODE_GENERATION_MODE = bitcode\n\n"
  },
  {
    "path": "src/support/Tests.xcconfig",
    "content": "#include \"../../sqlcipher/macosx/SQLite.xcconfig\"\n\n// Architectures\nSUPPORTED_PLATFORMS = macosx iphonesimulator iphoneos appletvos appletvsimulator\n\n// Packaging\nINFOPLIST_FILE = $(SRCROOT)/support/Info.plist\n\n// Preprocessing\nGCC_PREPROCESSOR_DEFINITIONS = $(inherited) $(SQLITE_PREPROCESSOR_DEFINITIONS) WCDB_TESTS=1\n\n// Apple Clang - Language - Objective-C\nGCC_ENABLE_OBJC_EXCEPTIONS = YES\n\n// Testing\nTEST_HOST[sdk=iphonesimulator*] = $(BUILD_DIR)/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)/Host.app/Host\nTEST_HOST[sdk=iphoneos*] = $(BUILD_DIR)/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)/Host.app/Host\nTEST_HOST[sdk=macosx*] = $(BUILT_PRODUCTS_DIR)/Host.app/Contents/MacOS/Host\n"
  },
  {
    "path": "src/support/WCDB.modulemap",
    "content": "framework module WCDB {\n    requires objc\n\n\tmodule All {\n\t\theader \"WCDB.h\"\n        export *\n        requires cplusplus17\n    }\n\n\tmodule BridgeHeader {\n        header \"WCTBridgeMacro.h\"\n        header \"WCTBridgeProperty.h\"\n        header \"WCTDeclaration.h\"\n        header \"WCTValue.h\"\n        header \"WCTColumnCoding.h\"\n        header \"Macro.h\"\n        header \"WCTPropertyMacro.h\"\n        header \"WCTTableCoding.h\"\n\t\texport *\n\t}\n    \n    explicit module Private {\n        requires objc\n        umbrella header \"WCDBBridging.h\"\n        export *\n    }\n}\n"
  },
  {
    "path": "src/support/WCDB.xcconfig",
    "content": "#include \"WCDBWithoutCompression.xcconfig\"\n\nOTHER_LDFLAGS = $(inherited) -framework zstd\n\nWCDB_USE_ZSTD = 1\nGCC_PREPROCESSOR_DEFINITIONS = $(inherited) WCDB_ZSTD=$(WCDB_USE_ZSTD)\n"
  },
  {
    "path": "src/support/WCDBCpp.modulemap",
    "content": "framework module WCDBCpp {\n    requires objc\n\n\tmodule All {\n\t\theader \"WCDBCpp.h\"\n        export *\n        requires cplusplus17\n    }\n}\n"
  },
  {
    "path": "src/support/WCDBObjc.modulemap",
    "content": "framework module WCDBObjc {\n    requires objc\n\n\tmodule All {\n\t\theader \"WCDBObjc.h\"\n        export *\n        requires cplusplus17\n    }\n}\n"
  },
  {
    "path": "src/support/WCDBSwift.modulemap",
    "content": "framework module WCDBSwift {\n    module All {\n        export *\n    }\n\n    explicit module Private {\n        requires objc\n        umbrella header \"WCDBBridging.h\"\n        export *\n    }\n}\n"
  },
  {
    "path": "src/support/WCDBSwift.xcconfig",
    "content": "#include \"WCDB.xcconfig\"\n\nSWIFT_ACTIVE_COMPILATION_CONDITIONS = $(inherited) WCDB_SWIFT_TARGET\n"
  },
  {
    "path": "src/support/WCDBWithoutCompression.xcconfig",
    "content": "#include \"../../sqlcipher/macosx/SQLite.xcconfig\"\n\n// Linking\nMACH_O_TYPE = mh_dylib\n\n// Packaging\nINFOPLIST_FILE = $(SRCROOT)/support/Info.plist\nPRODUCT_BUNDLE_IDENTIFIER = com.Tencent.$(PRODUCT_NAME:rfc1034identifier)\n\n// Versioning\nMARKETING_VERSION = 1.1.0\n\n// Preprocessing\nGCC_PREPROCESSOR_DEFINITIONS = $(inherited) $(WCDB_VERSION_DEFINITIONS) $(SQLITE_PREPROCESSOR_DEFINITIONS) ZLIB_CONST=1 SQLITE_WCDB=1\n\nOTHER_SWIFT_FLAGS = -no-verify-emitted-module-interface\n"
  },
  {
    "path": "src/support/ZstdBase.xcconfig",
    "content": "// Architectures\nSUPPORTED_PLATFORMS = macosx iphoneos iphonesimulator watchos watchsimulator appletvos appletvsimulator\nVALID_ARCHS = $(ARCHS_STANDARD)\n\n// Deployment\nSKIP_INSTALL = YES\nIPHONEOS_DEPLOYMENT_TARGET = 8.0\nMACOSX_DEPLOYMENT_TARGET = 10.13\nTVOS_DEPLOYMENT_TARGET = 9.0\nWATCHOS_DEPLOYMENT_TARGET = 2.0\nDEPLOYMENT_POSTPROCESSING = NO\nCOPY_PHASE_STRIP = NO\nSTRIP_STYLE = debugging\nSTRIP_INSTALLED_PRODUCT = NO\n\n// Linking\nMACH_O_TYPE = staticlib\n\n// Package\nDEFINES_MODULE = NO\nINFOPLIST_FILE = $(SRCROOT)/support/Info.plist\nPRODUCT_NAME = zstd\nPRODUCT_MODULE_NAME = $(PRODUCT_NAME)\nPRODUCT_BUNDLE_IDENTIFIER = com.Tencent.zstd.$(PRODUCT_NAME:rfc1034identifier)\n\n// Code Generation\nGCC_INLINES_ARE_PRIVATE_EXTERN = YES\nGCC_NO_COMMON_BLOCKS = YES\n\n// Custom Compiler Flag\nOTHER_CFLAGS = -Wglobal-constructors -Wno-shorten-64-to-32 -fno-sanitize=thread\n\n// Language\nGCC_C_LANGUAGE_STANDARD = gnu11\n\n// Language - Modules\nCLANG_ENABLE_MODULES = NO\nCLANG_MODULES_AUTOLINK = NO\n\n// Warnings - All languages\nCLANG_WARN_DOCUMENTATION_COMMENTS = YES\nCLANG_WARN_EMPTY_BODY = YES\nCLANG_WARN_BOOL_CONVERSION = YES\nCLANG_WARN_CONSTANT_CONVERSION = YES\nCLANG_WARN_ENUM_CONVERSION = YES\nCLANG_WARN_INT_CONVERSION = YES\nCLANG_WARN_INFINITE_RECURSION = YES\nGCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR\nGCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE\n\n// User-Defined\nENABLE_BITCODE = NO\nENABLE_BITCODE[sdk=appletv*] = YES\n"
  },
  {
    "path": "src/support/ZstdDebug.xcconfig",
    "content": "#include \"ZstdBase.xcconfig\"\n\n// Architectures\nONLY_ACTIVE_ARCH = YES\n\n// Build Options\nDEBUG_INFORMATION_FORMAT = dwarf\n\n// Linking\nDEAD_CODE_STRIPPING = NO\n\n// Code Generation\nGCC_OPTIMIZATION_LEVEL = 0\n\n// Preprocessing\nGCC_PREPROCESSOR_DEFINITIONS = DEBUG=1 SQLITE_DEBUG=1 $(SQLITE_PREPROCESSOR_DEFINITIONS)\n\n// User-Defined\nBITCODE_GENERATION_MODE = marker\n"
  },
  {
    "path": "src/support/ZstdRelease.xcconfig",
    "content": "#include \"ZstdBase.xcconfig\"\n\n// Architectures\nONLY_ACTIVE_ARCH = NO\n\n// Build Options\nDEBUG_INFORMATION_FORMAT = dwarf-with-dsym\n\n// Linking\nDEAD_CODE_STRIPPING = YES\n\n// Code Generation\nGCC_OPTIMIZATION_LEVEL = s\n\n// Preprocessing\nGCC_PREPROCESSOR_DEFINITIONS = NDEBUG=1 $(SQLITE_PREPROCESSOR_DEFINITIONS)\n\n// User-Defined\nBITCODE_GENERATION_MODE = bitcode\n"
  },
  {
    "path": "src/swift/bridge/ErrorBridge.swift",
    "content": "//\n// Created by qiuwenchen on 2022/4/2.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport Foundation\n#if SWIFT_PACKAGE\nimport WCDB_Private\n#elseif WCDB_SWIFT_TARGET\nimport WCDBSwift.Private\n#else\nimport WCDB.Private\n#endif\n\ninternal final class ErrorBridge {\n    static func getErrorFrom(cppError error: CPPError) -> WCDBError {\n        let recycleError = ObjectBridge.createRecyclableCPPObject(error)\n        let level = WCDBError.Level(rawValue: Int(WCDBErrorGetLevel(recycleError.raw)))\n        let code = WCDBError.Code(rawValue: WCDBErrorGetCode(recycleError.raw))\n        let message = String(cString: WCDBErrorGetMsg(recycleError.raw))\n        let valueWrap: ValueWrap<[String: Value]> = ValueWrap([:])\n        let valueWrapPointer = ObjectBridge.getUntypeSwiftObject(valueWrap)\n\n        let enumerator: @convention(c) (UnsafeMutableRawPointer, UnsafePointer<CChar>, CPPCommonValue) -> Void = {\n            valueWrapPointer, key, value in\n            let valueWrap: ValueWrap<[String: Value]>? = ObjectBridge.extractTypedSwiftObject(valueWrapPointer)\n            guard let valueWrap = valueWrap else {\n                return\n            }\n            switch value.type {\n            case WCDBBridgedType_Int:\n                valueWrap.value[String(cString: key)] = Value(value.intValue)\n            case WCDBBridgedType_Double:\n                valueWrap.value[String(cString: key)] = Value(value.doubleValue)\n            case WCDBBridgedType_String:\n                valueWrap.value[String(cString: key)] = Value(String(cString: unsafeBitCast(value.intValue, to: UnsafePointer<CChar>.self)))\n            default:\n                return\n            }\n        }\n        WCDBErrorEnumerateAllInfo(error, valueWrapPointer, enumerator)\n\n        var infos = WCDBError.Infos()\n        var extInfos = WCDBError.ExtInfos()\n        for (key, value) in valueWrap.value {\n            let errorKey = WCDBError.Key(stringKey: key)\n            if errorKey != .invalidKey {\n                infos[errorKey] = value\n            } else {\n                extInfos[key] = value\n            }\n        }\n        ObjectBridge.releaseSwiftObject(valueWrapPointer)\n        infos[WCDBError.Key.message] = Value(message)\n        return WCDBError(level: level ?? .Error, code: code ?? .Error, infos: infos, extInfos: extInfos)\n    }\n}\n"
  },
  {
    "path": "src/swift/bridge/FTSBridge.swift",
    "content": "//\n// Created by qiuwenchen on 2022/11/5.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport Foundation\n#if SWIFT_PACKAGE\nimport WCDB_Private\n#elseif WCDB_SWIFT_TARGET\nimport WCDBSwift.Private\n#else\nimport WCDB.Private\n#endif\n\npublic enum TokenizerErrorCode {\n    case OK\n    case Done\n    case NoMemory\n    internal var cValue: Int32 {\n        switch self {\n        case .OK:\n            return WCDBTokenizerErrorCodeOK\n        case .Done:\n            return WCDBTokenizerErrorCodeDone\n        case .NoMemory:\n            return WCDBTokenizerErrorCodeNoMemory\n        }\n    }\n}\n\npublic protocol Tokenizer: AnyObject {\n    init(args: [String])\n    func load(input: UnsafePointer<Int8>?, length: Int, flags: Int/* flags is only used in FTS5 */)\n    func nextToken(ppToken: UnsafeMutablePointer<UnsafePointer<Int8>?>,\n                   pnBytes: UnsafeMutablePointer<Int32>,\n                   piStart: UnsafeMutablePointer<Int32>,\n                   piEnd: UnsafeMutablePointer<Int32>,\n                   pFlags: UnsafeMutablePointer<Int32>?, // pFlags is only used in FTS5\n                   piPosition: UnsafeMutablePointer<Int32>? // iPosition is only used in FTS3/4\n    ) -> TokenizerErrorCode\n}\n\ninternal final class FTSBridge {\n    static func initializeCPPAPI() {\n        WCDBSwiftSetTokenizerCreateFunction({\n            (typeId: Int32, argc: Int32, argv: UnsafePointer<UnsafePointer<Int8>>?) -> UnsafeMutableRawPointer? in\n            let type = FTSBridge.getTokenizer(of: typeId)\n            var args: [String] = []\n            if argc > 0, let argv = argv {\n                for i in 0..<argc {\n                    args.append(String(cString: argv.advanced(by: Int(i)).pointee))\n                }\n            }\n            let tokenizer = type.init(args: args)\n            return ObjectBridge.getUntypeSwiftObject(tokenizer)\n        })\n        WCDBSwiftSetTokenizerLoadInputFunction({\n            (obj: UnsafeMutableRawPointer, input: UnsafePointer<Int8>?, length: Int32, flag: Int32) in\n            let tokenizer: Tokenizer? = ObjectBridge.extractTypedSwiftObject(obj)\n            guard let tokenizer = tokenizer else {\n                return\n            }\n            tokenizer.load(input: input, length: Int(length), flags: Int(flag))\n        })\n        WCDBSwiftSetTokenizerNextTokenFunction({\n            (obj: UnsafeMutableRawPointer,\n             ppToken: UnsafeMutablePointer<UnsafePointer<Int8>?>,\n             pnBytes: UnsafeMutablePointer<Int32>,\n             piStart: UnsafeMutablePointer<Int32>,\n             piEnd: UnsafeMutablePointer<Int32>,\n             pFlags: UnsafeMutablePointer<Int32>?,\n             piPosition: UnsafeMutablePointer<Int32>?) -> Int32 in\n            let tokenizer: Tokenizer? = ObjectBridge.extractTypedSwiftObject(obj)\n            guard let tokenizer = tokenizer else {\n                return WCDBTokenizerErrorCodeNoMemory\n            }\n            return tokenizer.nextToken(ppToken: ppToken, pnBytes: pnBytes, piStart: piStart, piEnd: piEnd, pFlags: pFlags, piPosition: piPosition).cValue\n        })\n    }\n\n    static func getTokenizer(of typeId: Int32) -> Tokenizer.Type {\n        return tokenizerTypes[Int(typeId)] as! Tokenizer.Type\n    }\n\n    static func register<TokenizerType: Tokenizer>(tokenizer: TokenizerType.Type, of name: String, of version: FTSVersion) {\n        FTSBridge.initializeCPPAPI()\n        mutex.lock(); defer { mutex.unlock() }\n        tokenizerTypes[nextTypeId] = TokenizerType.self\n        WCDBCoreRegisterFTSTokenizer(name.cString, Int32(nextTypeId), version.cValue)\n        nextTypeId += 1\n        assert(nextTypeId < WCDBMaxSwiftTokenizerTypeId, \"The count of tokenizer exceeds the maximum allowed.\")\n    }\n\n    nonisolated(unsafe) private static var tokenizerTypes: [Any?] = [Any?](repeating: nil, count: Int(WCDBMaxSwiftTokenizerTypeId))\n    nonisolated(unsafe) private static var nextTypeId = 0\n    nonisolated(unsafe) private static var mutex = Mutex()\n}\n"
  },
  {
    "path": "src/swift/bridge/ObjectBridge.swift",
    "content": "//\n// Created by qiuwenchen on 2022/3/31.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport Foundation\n#if SWIFT_PACKAGE\nimport WCDB_Private\n#elseif WCDB_SWIFT_TARGET\nimport WCDBSwift.Private\n#else\nimport WCDB.Private\n#endif\n\ninternal final class ValueWrap<T> {\n    var value: T\n    init(_ value: T) {\n        self.value = value\n    }\n}\n\ninternal final class ObjectBridge {\n\n    @discardableResult\n    static func createRecyclableCPPObject<T>(_ obj: T) -> Recyclable<T> {\n        return Recyclable<T>(obj, onRecycled: {\n            let innerValue = unsafeBitCast(obj, to: UnsafeMutablePointer<CPPObject>.self)\n            WCDBReleaseCPPObject(innerValue)\n        })\n    }\n\n    static func extractTypedSwiftObject<T>(_ obj: UnsafeMutableRawPointer?) -> T? {\n        guard let obj = obj else { return nil}\n        return Unmanaged<AnyObject>.fromOpaque(obj).takeUnretainedValue() as? T\n    }\n\n    static func getUntypeSwiftObject(_ obj: AnyObject) -> UnsafeMutableRawPointer {\n        return Unmanaged<AnyObject>.passRetained(obj).toOpaque()\n    }\n\n    static let objectDestructor: @convention(c) (UnsafeMutableRawPointer) -> Void = { obj in\n        Unmanaged<AnyObject>.fromOpaque(obj).release()\n    }\n\n    static func releaseSwiftObject(_ obj: UnsafeMutableRawPointer) {\n        Unmanaged<AnyObject>.fromOpaque(obj).release()\n    }\n\n    static func initializeCPPAPI() {\n        WCDBSetReleaseSwiftObjectFunction(objectDestructor)\n    }\n\n    static func extendLifetime<Result>(_ objList: Any..., execute body: @escaping () -> Result) -> Result {\n        extendLifetime(objList, execute: body)\n    }\n\n    static func extendLifetime<Result>(_ objList: [Any], execute body: @escaping () -> Result) -> Result {\n        var execution: () -> Result = body\n        for oneObj in objList {\n            execution = { [execution] in\n                return withExtendedLifetime(oneObj, execution)\n            }\n        }\n        return execution()\n    }\n}\n"
  },
  {
    "path": "src/swift/bridge/WCTBridgeProperty.swift",
    "content": "//\n// Created by qiuwenchen on 2022/4/21.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#if WCDB_SWIFT_BRIDGE_OBJC\n\nimport Foundation\n#if SWIFT_PACKAGE\nimport WCDB_Private\n#elseif WCDB_SWIFT_TARGET\nimport WCDBSwift.Private\n#else\nimport WCDB.Private\n#endif\n\nextension WCTBridgeProperty: PropertyOperable {\n\n    public func isSwiftProperty() -> Bool {\n        return false\n    }\n\n    public var codingTableKey: CodingTableKeyBase? {\n        return nil\n    }\n\n    public var wctProperty: WCTBridgeProperty? {\n        return self\n    }\n\n    public func asProperty() -> Property {\n        let property = Property(named: propertyName, with: codingTableKey, with: wctProperty)\n        property.tableBinding = tableBinding()\n        return property\n    }\n\n    public func asColumn() -> Column {\n        return asProperty().asColumn()\n    }\n\n    public func `as`(_ propertyConvertible: PropertyConvertible) -> Property {\n        return Property(named: propertyName, with: propertyConvertible.codingTableKey, with: propertyConvertible.wctProperty)\n    }\n\n    public func `in`(table: String) -> Property {\n        return asProperty().`in`(table: table)\n    }\n\n    public func of(schema schemaConvertible: SchemaConvertible) -> Property {\n        return asProperty().of(schema: schemaConvertible)\n    }\n\n    public func asExpression() -> Expression {\n        return asColumn().asExpression()\n    }\n}\n\npublic extension Array where Element==WCTBridgeProperty {\n    var any: Column {\n        return Column.all()\n    }\n}\n\n#endif\n"
  },
  {
    "path": "src/swift/builtin/CodableType.swift",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport Foundation\n#if SWIFT_PACKAGE\nimport WCDB_Private\n#elseif WCDB_SWIFT_TARGET\nimport WCDBSwift.Private\n#else\nimport WCDB.Private\n#endif\n\n/*\n * Builtin codable implementation\n *\n * .integer32:\n *      Bool, Int, Int8, Int16, Int32, UInt, UInt8, UInt16, UInt32  \n * .integer64:\n *      Int64, UInt64\n * .float:\n *      Float, Double, Date\n * .text:\n *      String, URL\n * .BLOB:\n *      Data, Array, Dictionary, Set\n *\n */\n\n// Bultin Column Codable\nextension Int8: ColumnCodable, LiteralValueConvertible {\n    public static var columnType: ColumnType {\n        return .integer32\n    }\n    public init?(with value: Value) {\n        self = value.int32Value.toInt8()\n    }\n    public func archivedValue() -> Value {\n        return Value(self.toInt32())\n    }\n}\n\nextension Int16: ColumnCodable, LiteralValueConvertible {\n    public static var columnType: ColumnType {\n        return .integer32\n    }\n    public init?(with value: Value) {\n        self = value.int32Value.toInt16()\n    }\n    public func archivedValue() -> Value {\n        return Value(self.toInt32())\n    }\n}\n\nextension Int32: ColumnCodable, LiteralValueConvertible {\n    public static var columnType: ColumnType {\n        return .integer32\n    }\n    public init?(with value: Value) {\n        self = value.int32Value\n    }\n    public func archivedValue() -> Value {\n        return Value(self)\n    }\n}\n\nextension Int64: ColumnCodable, LiteralValueConvertible {\n    public static var columnType: ColumnType {\n        return .integer64\n    }\n    public init?(with value: Value) {\n        self = value.int64Value\n    }\n    public func archivedValue() -> Value {\n        return Value(self)\n    }\n}\n\nextension Int: ColumnCodable, LiteralValueConvertible {\n    public static var columnType: ColumnType {\n        return .integer64\n    }\n    public init?(with value: Value) {\n        self = value.int64Value.toInt()\n    }\n    public func archivedValue() -> Value {\n        return Value(self.toInt64())\n    }\n}\n\nextension UInt8: ColumnCodable, LiteralValueConvertible {\n    public static var columnType: ColumnType {\n        return .integer32\n    }\n    public init?(with value: Value) {\n        self = value.int32Value.toUInt8()\n    }\n    public func archivedValue() -> Value {\n        return Value(self.toInt32())\n    }\n}\n\nextension UInt16: ColumnCodable, LiteralValueConvertible {\n    public static var columnType: ColumnType {\n        return .integer32\n    }\n    public init?(with value: Value) {\n        self = value.int32Value.toUInt16()\n    }\n    public func archivedValue() -> Value {\n        return Value(self.toInt32())\n    }\n}\n\nextension UInt32: ColumnCodable, LiteralValueConvertible {\n    public static var columnType: ColumnType {\n        return .integer32\n    }\n    public init?(with value: Value) {\n        self = value.int32Value.toUInt32()\n    }\n    public func archivedValue() -> Value {\n        return Value(self.toInt32())\n    }\n}\n\nextension UInt64: ColumnCodable, LiteralValueConvertible {\n    public static var columnType: ColumnType {\n        return .integer64\n    }\n    public init?(with value: Value) {\n        self = value.int64Value.toUInt64()\n    }\n    public func archivedValue() -> Value {\n        return Value(self.toInt64())\n    }\n}\n\nextension UInt: ColumnCodable, LiteralValueConvertible {\n    public static var columnType: ColumnType {\n        return .integer64\n    }\n    public init?(with value: Value) {\n        self = value.int64Value.toUInt()\n    }\n    public func archivedValue() -> Value {\n        return Value(self.toInt64())\n    }\n}\n\nextension Bool: ColumnCodable, LiteralValueConvertible {\n    public static var columnType: ColumnType {\n        return .integer32\n    }\n    public init?(with value: Value) {\n        self = value.int32Value.toBool()\n    }\n    public func archivedValue() -> Value {\n        return Value(self.toInt32())\n    }\n}\n\nextension Float: ColumnCodable, LiteralValueConvertible {\n    public static var columnType: ColumnType {\n        return .float\n    }\n    public init?(with value: Value) {\n        self = value.doubleValue.toFloat()\n    }\n    public func archivedValue() -> Value {\n        return Value(self.toDouble())\n    }\n}\n\nextension Double: ColumnCodable, LiteralValueConvertible {\n    public static var columnType: ColumnType {\n        return .float\n    }\n    public init?(with value: Value) {\n        self = value.doubleValue\n    }\n    public func archivedValue() -> Value {\n        return Value(self)\n    }\n}\n\nextension String: ColumnCodable, LiteralValueConvertible {\n    public static var columnType: ColumnType {\n        return .text\n    }\n    public init?(with value: Value) {\n        self = value.stringValue\n    }\n    public func archivedValue() -> Value {\n        return Value(self)\n    }\n}\n\nextension Data: ColumnCodable, LiteralValueConvertible {\n    public static var columnType: ColumnType {\n        return .BLOB\n    }\n    public init?(with value: Value) {\n        self = value.dataValue\n    }\n    public func archivedValue() -> Value {\n        return Value(self)\n    }\n}\n\nextension Date: ColumnCodable, LiteralValueConvertible {\n    public static var columnType: ColumnType {\n        return .float\n    }\n    public init?(with value: Value) {\n        self.init(timeIntervalSince1970: value.doubleValue)\n    }\n    public func archivedValue() -> Value {\n        return Value(timeIntervalSince1970)\n    }\n}\n\nextension URL: ColumnCodable, LiteralValueConvertible {\n    public static var columnType: ColumnType {\n        return .text\n    }\n    public init?(with value: Value) {\n        self.init(string: value.stringValue)\n    }\n    public func archivedValue() -> Value {\n        return Value(self.absoluteString)\n    }\n}\n\nextension Array: ColumnCodable, ColumnCodableBase where Element: Codable {\n    public static var columnType: ColumnType {\n        return .BLOB\n    }\n    public init?(with value: Value) {\n        guard let decodable = try? JSONDecoder().decode(Array.self, from: value.dataValue) else {\n            return nil\n        }\n        self = decodable\n    }\n    public func archivedValue() -> Value {\n        guard let encoded = try? JSONEncoder().encode(self) else {\n            return Value(nil)\n        }\n        return Value(encoded)\n    }\n}\n\npublic typealias FundamentalValue = Value\n\nextension Dictionary: ColumnCodable, ColumnCodableBase where Key: Codable, Value: Codable {\n    public static var columnType: ColumnType {\n        return .BLOB\n    }\n    public init?(with value: FundamentalValue) {\n        guard let decodable = try? JSONDecoder().decode(Dictionary.self, from: value.dataValue) else {\n            return nil\n        }\n        self = decodable\n    }\n    public func archivedValue() -> FundamentalValue {\n        guard let encoded = try? JSONEncoder().encode(self) else {\n            return FundamentalValue(nil)\n        }\n        return FundamentalValue(encoded)\n    }\n}\n\nextension Set: ColumnCodable, ColumnCodableBase where Element: Codable {\n    public static var columnType: ColumnType {\n        return .BLOB\n    }\n    public init?(with value: Value) {\n        guard let decodable = try? JSONDecoder().decode(Set.self, from: value.dataValue) else {\n            return nil\n        }\n        self = decodable\n    }\n    public func archivedValue() -> Value {\n        guard let encoded = try? JSONEncoder().encode(self) else {\n            return Value(nil)\n        }\n        return Value(encoded)\n    }\n}\n\n// JSONCodable\npublic protocol ColumnJSONEncodable: ColumnEncodable {}\nextension ColumnJSONEncodable {\n    public func archivedValue() -> Value {\n        guard let encoded = try? JSONEncoder().encode(self) else {\n            return Value(nil)\n        }\n        return Value(encoded)\n    }\n}\n\npublic protocol ColumnJSONDecodable: ColumnDecodable {}\nextension ColumnJSONDecodable {\n    public init?(with value: Value) {\n        guard let decodable = try? JSONDecoder().decode(Self.self, from: value.dataValue) else {\n            return nil\n        }\n        self = decodable\n    }\n}\n\npublic protocol ColumnJSONCodable: ColumnJSONEncodable, ColumnJSONDecodable {}\nextension ColumnJSONCodable {\n    public static var columnType: ColumnType {\n        return .BLOB\n    }\n}\n"
  },
  {
    "path": "src/swift/builtin/Master.swift",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport Foundation\n#if SWIFT_PACKAGE\nimport WCDB_Private\n#elseif WCDB_SWIFT_TARGET\nimport WCDBSwift.Private\n#else\nimport WCDB.Private\n#endif\n\npublic struct Master: TableCodable {\n    public static let builtinTableName: String = \"sqlite_master\"\n\n    public var type: String?\n    public var name: String?\n    public var tableName: String?\n    public var rootpage: Int?\n    public var sql: String?\n\n    public enum CodingKeys: String, CodingTableKey {\n        public typealias Root = Master\n\n        case type\n        case name\n        case tableName = \"tbl_name\"\n        case rootpage\n        case sql\n\n        nonisolated(unsafe) public static let objectRelationalMapping = TableBinding(Master.CodingKeys.self)\n    }\n\n    public init() {}\n}\n"
  },
  {
    "path": "src/swift/core/base/BaseType.swift",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport Foundation\n#if SWIFT_PACKAGE\nimport WCDB_Private\n#elseif WCDB_SWIFT_TARGET\nimport WCDBSwift.Private\n#else\nimport WCDB.Private\n#endif\n\npublic typealias Tag = Int\n\ntypealias RecyclableCPPDatabase = Recyclable<CPPDatabase>\ntypealias RecyclableCPPHandle = Recyclable<CPPHandle>\ntypealias RecyclableCPPHandleStatement = Recyclable<CPPHandleStatement>\n"
  },
  {
    "path": "src/swift/core/base/Database+WCTTableCoding.swift",
    "content": "//\n// Created by qiuwenchen on 2022/11/13.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#if WCDB_SWIFT_BRIDGE_OBJC\n\nimport Foundation\n#if SWIFT_PACKAGE\nimport WCDB_Private\n#elseif WCDB_SWIFT_TARGET\nimport WCDBSwift.Private\n#else\nimport WCDB.Private\n#endif\n\n// WCTTable\npublic extension Database {\n    /// Get a wrapper from an existing table.\n    ///\n    /// - Parameters:\n    ///   - name: The name of the table.\n    ///   - type: A class conform to TableCodable protocol.\n    /// - Returns: Nil for a non-existent table.\n    /// - Throws: `Error`\n    func getTable<Root: WCTTableCoding>(\n        named name: String,\n        of type: Root.Type = Root.self) -> Table<Root> {\n        return Table<Root>(withDatabase: self, named: name)\n    }\n}\n\nextension Database: InsertChainCallInterfaceForObjc {}\nextension Database: SelectChainCallInterfaceForObjc {}\n\nextension Database: InsertInterfaceForObjc {}\nextension Database: UpdateInterfaceForObjc {}\nextension Database: SelectInterfaceForObjc {}\nextension Database: TableInterfaceForObjc {}\n\n#endif\n"
  },
  {
    "path": "src/swift/core/base/Database.swift",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport Foundation\n#if SWIFT_PACKAGE\nimport WCDB_Private\n#elseif WCDB_SWIFT_TARGET\nimport WCDBSwift.Private\n#else\nimport WCDB.Private\n#endif\n\n/// Thread-safe Database object\npublic class Database {\n    internal final let recyclableDatabase: RecyclableCPPDatabase\n    internal final var database: CPPDatabase {\n        return recyclableDatabase.raw\n    }\n\n    /// Init a database from path.\n    /// Note that all database objects with same path share the same core.\n    /// So you can create multiple database objects. WCDB will manage them automatically.\n    /// Note that WCDB will not generate a sqlite handle until the first operation,\n    /// which is also called as lazy initialization.\n    ///\n    /// - Parameter path: Path to your database\n    public convenience init(at path: String) {\n        self.init(at: URL(fileURLWithPath: path))\n    }\n\n    /// Init a database from file url.\n    /// Note that all database objects with same path share the same core.\n    /// So you can create multiple database objects. WCDB will manage them automatically.\n    ///\n    /// Note that WCDB will not generate a sqlite handle until the first operation,\n    /// which is also called as lazy initialization.\n    ///\n    /// Note that once a database is opened in read-only mode,\n    /// it cannot be writable in the current process any more.\n    ///\n    /// - Parameter url: File url to your database\n    public convenience init(at url: URL, readOnly: Bool = false) {\n#if swift(>=5)\n#else\n        WCDBError.fatalError(\"Swift 5 is required.\")\n#endif\n        let database = WCDBCoreCreateDatabase(url.standardizedFileURL.path, readOnly, false)\n        self.init(with: database)\n    }\n\n    /// Init a in-memory database.\n    /// Since In-memory database share one DB handle among all threads,\n    /// it does not support multi-threaded concurrent operation.\n    public static func createInMemoryDatabase() -> Database {\n        let database = WCDBCoreCreateDatabase(\"\", false, true)\n        return Database(with: database)\n    }\n\n    internal init(with cppDatabase: CPPDatabase) {\n        DispatchQueue.once(name: \"Once.ObjectBridge\", {\n            ObjectBridge.initializeCPPAPI()\n        })\n        self.recyclableDatabase = ObjectBridge.createRecyclableCPPObject(cppDatabase)\n    }\n\n    /// The tag of the database. Default to nil.\n    /// Note that core objects with same path share this tag, even they are not the same object.\n    ///\n    ///     let database1 = Database(withPath: path)\n    ///     let database2 = Database(withPath: path)\n    ///     database1.tag = 1\n    ///     print(\"Tag: \\(database2.tag!)\") // print 1\n    ///\n    public var tag: Tag? {\n        get {\n            let tag = WCDBDatabaseGetTag(database)\n            if tag != 0 {\n                return tag\n            }\n            return nil\n        }\n        set {\n            if let tag = newValue {\n                WCDBDatabaseSetTag(database, tag)\n            } else {\n                WCDBDatabaseSetTag(database, 0)\n            }\n        }\n    }\n\n    /// The path of the related database.\n    public final var path: String {\n        if let path = WCDBDatabaseGetPath(database) {\n            return String(cString: path)\n        }\n        return \"\"\n    }\n\n    /// Since WCDB is using lazy initialization,\n    /// `init(withPath:)`, `init(withFileURL:)` never failed even the database can't open.\n    /// So you can call this to check whether the database can be opened.\n    /// Return false if an error occurs during sqlite handle initialization.\n    public var canOpen: Bool {\n        return WCDBDatabaseCanOpen(database)\n    }\n\n    /// Check database is already opened.\n    public var isOpened: Bool {\n        return WCDBDatabaseIsOpened(database)\n    }\n\n    public typealias OnClosed = () throws -> Void\n\n    /// Close the database.\n    ///     Since Multi-threaded operation is supported in WCDB,\n    ///     other operations in different thread can open the closed database.\n    ///     So this method can make sure database is closed in the `onClosed` block.\n    ///     All other operations will be blocked until this method returns.\n    ///\n    /// A close operation consists of 4 steps:\n    ///     1. `blockade`, which blocks all other operations.\n    ///     2. `close`, which waits until all sqlite handles return and closes them.\n    ///     3. `onClosed`, which trigger the callback.\n    ///     4. `unblokade`, which unblocks all other opreations.\n    ///\n    /// You can simply call `close:` to do all steps above or call these separately.\n    /// Since this method will wait until all sqlite handles return, it may lead to deadlock in some bad practice.\n    ///     The key to avoid deadlock is to make sure all WCDB objects in current thread is dealloced. In detail:\n    ///     1. You should not keep WCDB objects, including `Insert`, `Delete`, `Update`, `Select`, `RowSelect`,\n    ///        `MultiSelect`, `Handle`, `PreparedStatement`. These objects should not be kept.\n    ///        You should get them, use them, then release them right away.\n    ///     2. WCDB objects may not be out of its' scope.\n    ///     The best practice is to call `close:` in sub-thread and display a loading animation in main thread.\n    ///\n    ///     //close directly\n    ///     database.close(onClosed: { () throws -> Void in\n    ///         //do something on this closed database\n    ///     })\n    ///\n    ///     //close separately\n    ///     database.blockade()\n    ///     database.close()\n    ///     //do something on this closed database\n    ///     database.unblockade()\n    ///\n    /// - Parameter onClosed: Trigger on database closed.\n    /// - Throws: Rethrows your error.\n    public func close(onClosed: @escaping OnClosed) throws {\n        var callbackError: Swift.Error?\n        let closeCallback: () -> Void = {\n            do {\n                try onClosed()\n            } catch {\n                callbackError = error\n            }\n        }\n\n        let cppCallback: @convention(c) (UnsafeMutableRawPointer) -> Void = {\n            cppContext in\n            let callbackWrap: ValueWrap<() -> Void>? = ObjectBridge.extractTypedSwiftObject(cppContext)\n            guard let callbackWrap = callbackWrap else {\n                return\n            }\n            callbackWrap.value()\n        }\n        let callbackWrap = ValueWrap(closeCallback)\n        let callbackWrapPointer = ObjectBridge.getUntypeSwiftObject(callbackWrap)\n        WCDBDatabaseClose(database, callbackWrapPointer, cppCallback)\n        ObjectBridge.objectDestructor(callbackWrapPointer)\n        if callbackError != nil {\n            throw callbackError!\n        }\n    }\n\n    /// Close the database.\n    public func close() {\n        WCDBDatabaseClose(database, nil, nil)\n    }\n\n    /// Blockade the database.\n    public func blockade() {\n        WCDBDatabaseBlockade(database)\n    }\n\n    /// Unblockade the database.\n    public func unblockade() {\n        WCDBDatabaseUnblockade(database)\n    }\n\n    /// Check whether database is blockaded.\n    public var isBlockaded: Bool {\n        return WCDBDatabaseIsBlockaded(database)\n    }\n\n    /// Purge all unused memory of this database.\n    /// WCDB will cache and reuse some sqlite handles to improve performance.\n    /// The max count of free sqlite handles is same\n    /// as the number of concurrent threads supported by the hardware implementation.\n    /// You can call it to save some memory.\n    public func purge() {\n        WCDBDatabasePurge(database)\n    }\n\n    /// Purge all unused memory of all databases.\n    /// Note that WCDB will call this interface automatically while it receives memory warning on iOS.\n    public static func purge() {\n        WCDBCorePurgeAllDatabase()\n    }\n\n    internal func getError() -> WCDBError {\n        let cppError = WCDBDatabaseGetError(database)\n        return ErrorBridge.getErrorFrom(cppError: cppError)\n    }\n\n    /// Create a `Handle` for current database.\n    /// `Handle` is a wrapper for sqlite db handle of type `sqlite3*`,\n    /// and the sqlite db handle is lazy initialized and will not be actually generated until the first operation on current handle takes place.\n    /// Note that all `Handle` created by the current database in the current thread will share the same sqlite db handle internally,\n    /// so it can avoid the deadlock between different sqlite db handles in some extreme cases.\n    /// - Parameter writeHint: A hint as to whether the handle will be used to update content in the database. It doesn't need to be precise.\n    /// - Returns: A new `Handle`.\n    /// - Throws: `Error`\n    public func getHandle(writeHint: Bool = false) throws -> Handle {\n        let cppHandle = WCDBDatabaseGetHandle(database, writeHint)\n        let handle = Handle(withCPPHandle: cppHandle, database: self)\n        if !WCDBHandleCheckValid(cppHandle) {\n            throw getError()\n        }\n        return handle\n    }\n\n    public func getDatabase() -> Database {\n        return self\n    }\n\n    /// Exec a specific sql.\n    /// Note that you can use this interface to execute a SQL that is not contained in the WCDB interface layer.\n    ///\n    /// - Parameter statement: WINQ statement\n    /// - Throws: `Error`\n    public func exec(_ statement: Statement) throws {\n        let hint = withExtendedLifetime(statement) {\n            WCDBStatementNeedToWrite($0.rawCPPObj)\n        }\n        return try getHandle(writeHint: hint).exec(statement)\n    }\n\n    public typealias ProgressUpdate = (_ percentage: Double, _ increment: Double) -> Bool /* Continue or not */\n}\n\n// Vacuum\npublic extension Database {\n    /// Vacuum current database.\n    /// It can be used to vacuum a database of any size with limited memory usage.\n    func vacuum(with progress: ProgressUpdate?) throws {\n        if let progress = progress {\n            let cppProgress: @convention(c) (UnsafeMutableRawPointer?, Double, Double) -> Bool = {\n                cppContext, percentage, increment in\n                let progressWrap: ValueWrap<ProgressUpdate>? = ObjectBridge.extractTypedSwiftObject(cppContext)\n                guard let progressWrap = progressWrap else {\n                    return false\n                }\n                return progressWrap.value(percentage, increment)\n            }\n            let progressWrap = ValueWrap(progress)\n            let progressWrapPointer = ObjectBridge.getUntypeSwiftObject(progressWrap)\n            if !WCDBDatabaseVacuum(database, cppProgress, progressWrapPointer, ObjectBridge.objectDestructor) {\n                throw getError()\n            }\n        } else {\n            if !WCDBDatabaseVacuum(database, nil, nil, nil) {\n                throw getError()\n            }\n        }\n    }\n\n    /// The wrapper of `PRAGMA auto_vacuum`\n    func enableAutoVacuum(incremental: Bool) {\n        WCDBDatabaseEnableAutoVacuum(database, incremental)\n    }\n\n    /// The wrapper of `PRAGMA incremental_vacuum`\n    func incrementalVacuum(pages: Int32) throws {\n        if !WCDBDatabaseIncrementalVacuum(database, pages) {\n            throw getError()\n        }\n    }\n}\n\n// Config\npublic extension Database {\n\n    enum CipherVersion: Int32 {\n        case defaultVerion = 0\n        case version1\n        case version2\n        case version3\n        case version4\n    }\n\n    /// Set cipher key for a database.   \n    /// For an encrypted database, you must call it before all other operation.  \n    /// The cipher page size defaults to 4096 in WCDB, but it defaults to 1024 in other databases. \n    /// So for an existing database created by other database framework, you should set it to 1024. \n    /// Otherwise, you'd better to use cipher page size with 4096 \n    /// or simply call setCipherKey: interface to get better performance.\n    /// If your database is created with the default configuration of WCDB 1.0.x, please set cipherVersion to `CipherVersion.version3`.\n    ///\n    /// - Parameters:\n    ///   - optionalKey: Cipher key. Nil for no cipher.\n    ///   - pageSize: Cipher page size.\n    ///   - cipherVersion: Use the default configuration of a specific version of sqlcipher\n    func setCipher(key optionalKey: Data?, pageSize: Int = 4096, cipherVersion: CipherVersion = .defaultVerion) {\n        if let key = optionalKey {\n            key.withUnsafeBytes { (buffer: UnsafeRawBufferPointer) in\n                WCDBDatabaseConfigCipher(database, buffer.bindMemory(to: UInt8.self).baseAddress, Int32(buffer.count), Int32(pageSize), cipherVersion.rawValue)\n            }\n        } else {\n            WCDBDatabaseConfigCipher(database, nil, 0, 0, 0)\n        }\n    }\n\n    /// Force SQLCipher to operate with the default settings consistent with that major version number as the default.\n    /// It works the same as `PRAGMA cipher_default_compatibility`.\n    ///\n    /// - Parameter version: The specified sqlcipher major version.\n    static func setDefaultCipherConfiguration(_ version: CipherVersion) {\n        WCDBCoreSetDefaultCipherConfig(version.rawValue)\n    }\n\n    enum ConfigPriority: Int32 {\n        case highest = -2147483648 // Only For cipher config\n        case high = -100\n        case `default` = 0\n        case low = 100\n    }\n\n    typealias Config = (Handle) throws -> Void\n    /// Set config for this database.\n    ///\n    /// Since WCDB is a multi-handle database, an executing handle will not apply this config immediately.  \n    /// Instead, all handles will run this config before its next operation.\n    ///\n    /// If you want to add cipher config, please use `ConfigPriority.highest`.\n    ///\n    ///     database.setConfig(named: \"demo\", withInvocation: { (handle: Handle) throws in\n    ///         try handle.exec(StatementPragma().pragma(.secureDelete).to(true))\n    ///     }, withUninvocation: { (handle: Handle) throws in\n    ///         try handle.exec(StatementPragma().pragma(.secureDelete).to(false))\n    ///     }, withPriority: .high)\n    ///\n    /// - Parameters:\n    ///   - name: The Identifier for this config\n    ///   - callback: config\n    ///   - order: The smaller number is called first\n    func setConfig(named name: String,\n                   withInvocation invocation: @escaping Config,\n                   withUninvocation uninvocation: Config? = nil,\n                   withPriority priority: ConfigPriority = ConfigPriority.default) {\n        let cppInvocation: @convention(c) (UnsafeMutableRawPointer, CPPHandle) -> Bool = {\n            cppContext, cppHandle in\n            let invocationWrap: ValueWrap<(CPPHandle) -> Bool>? = ObjectBridge.extractTypedSwiftObject(cppContext)\n            guard let invocationWrap = invocationWrap else {\n                return false\n            }\n            return invocationWrap.value(cppHandle)\n        }\n\n        let invocationBlock: (CPPHandle) -> Bool = {\n            [weak self] cppHandle in\n            guard let self = self else {\n                return false\n            }\n            let handle = Handle(withCPPHandle: cppHandle, database: self)\n            var ret = true\n            do {\n                try invocation(handle)\n            } catch {\n                ret = false\n            }\n            return ret\n        }\n        let invocationWrap = ValueWrap(invocationBlock)\n        let invocationWrapPointer = ObjectBridge.getUntypeSwiftObject(invocationWrap)\n\n        var uninvocationWrapPointer: UnsafeMutableRawPointer?\n        if let uninvocation = uninvocation {\n            let uninvocationBlock: (CPPHandle) -> Bool = {\n                [weak self] cppHandle in\n                guard let self = self else {\n                    return false\n                }\n                let handle = Handle(withCPPHandle: cppHandle, database: self)\n                var ret = true\n                do {\n                    try uninvocation(handle)\n                } catch {\n                    ret = false\n                }\n                return ret\n            }\n            let uninvocationWrap = ValueWrap(uninvocationBlock)\n            uninvocationWrapPointer = ObjectBridge.getUntypeSwiftObject(uninvocationWrap)\n        }\n        WCDBDatabaseConfig(database,\n                           name.cString,\n                           cppInvocation,\n                           invocationWrapPointer,\n                           uninvocationWrapPointer != nil ? cppInvocation : nil,\n                           uninvocationWrapPointer,\n                           priority.rawValue,\n                           ObjectBridge.objectDestructor)\n    }\n\n    /// Set the default directory for temporary database files.\n    /// If not set, an existing directory will be selected as the temporary database files directory in the following order:\n    ///     1. TMPDIR environment value;\n    ///     2. /Var/tmp;\n    ///     3. /usr/tmp;\n    ///     4. /tmp;\n    ///     5. The current working directory (\".\")\n    /// Please see: https://www.sqlite.org/tempfiles.html\n    /// - Parameter directory a global temporary directory.\n    /// - Returns: true if directory exists or create directory success.\n    static func setDefaultTemporaryDirectory(_ directory: String) -> Bool {\n        return WCDBCoreSetDefaultTemporaryDirectory(directory.cString)\n    }\n\n    struct PerformanceInfo {\n        public let tablePageReadCount: Int\n        public let tablePageWriteCount: Int\n        public let indexPageReadCount: Int\n        public let indexPageWriteCount: Int\n        public let overflowPageReadCount: Int\n        public let overflowPageWriteCount: Int\n        public let costInNanoseconds: Int64\n        init(_ cppInfo: UnsafePointer<CPPPerformanceInfo>) {\n            tablePageReadCount = Int(cppInfo.pointee.tablePageReadCount)\n            tablePageWriteCount = Int(cppInfo.pointee.tablePageWriteCount)\n            indexPageReadCount = Int(cppInfo.pointee.indexPageReadCount)\n            indexPageWriteCount = Int(cppInfo.pointee.indexPageWriteCount)\n            overflowPageReadCount = Int(cppInfo.pointee.overflowPageReadCount)\n            overflowPageWriteCount = Int(cppInfo.pointee.overflowPageWriteCount)\n            costInNanoseconds = cppInfo.pointee.costInNanoseconds\n        }\n    }\n\n    typealias PerformanceTracer = (Tag, String, UInt64, String, PerformanceInfo) -> Void // Tag, Path, handleIdentifier, SQL, Info\n\n    /// You can register a tracer to monitor the performance of all SQLs.\n    /// It returns\n    /// 1. Every SQL executed by the database.\n    /// 2. Time consuming in nanoseconds.\n    /// 3. Number of reads and writes on different types of db pages.\n    /// 4. Tag of database.\n    /// 5. Path of database.\n    /// 6. The id of the handle executing this SQL.\n    ///\n    /// Note that:\n    /// 1. You should register trace before all db operations.\n    /// 2. Global tracer will be recovered by db tracer.\n    ///\n    ///     Database.globalTracePerformance{ (tag, path, handleId, sql, info) in\n    ///         print(\"Tag: \\(tag)\")\n    ///         print(\"Path: \\(path)\")\n    ///         print(\"The handle with id \\(handleId) took \\(info.costInNanoseconds) nanoseconds to execute \\(sql)\")\n    ///     }\n    ///\n    /// Tracer may cause WCDB performance degradation, according to your needs to choose whether to open.\n    ///\n    /// - Parameter trace: trace. Nil to disable global preformance trace.\n    ///\n    static func globalTracePerformance(_ trace: @escaping PerformanceTracer) {\n        let traceWrap = ValueWrap(trace)\n        let tracePointer = ObjectBridge.getUntypeSwiftObject(traceWrap)\n        let cppTrace: @convention(c) (UnsafeMutableRawPointer?, Int, UnsafePointer<CChar>, UInt64, UnsafePointer<CChar>, UnsafePointer<CPPPerformanceInfo>) -> Void = {\n            cppTrace, tag, path, handleId, sql, cppInfo in\n            let traceWrap: ValueWrap<PerformanceTracer>? = ObjectBridge.extractTypedSwiftObject(cppTrace)\n            guard let traceWrap = traceWrap else {\n                return\n            }\n            let info = PerformanceInfo(cppInfo)\n            traceWrap.value(tag, String(cString: path), handleId, String(cString: sql), info)\n        }\n        WCDBDatabaseGlobalTracePerformance(cppTrace, tracePointer, ObjectBridge.objectDestructor)\n    }\n    static func globalTracePerformance(_ trace: Void?) {\n        WCDBDatabaseGlobalTracePerformance(nil, nil, nil)\n    }\n\n    /// You can register a reporter to monitor all errors of current database.\n    /// Tracer may cause WCDB performance degradation, according to your needs to choose whether to open.\n    ///\n    /// - Parameter trace: trace. Nil to disable preformance trace.\n    func trace(ofPerformance trace: @escaping PerformanceTracer) {\n        let traceWrap = ValueWrap(trace)\n        let traceWrapPointer = ObjectBridge.getUntypeSwiftObject(traceWrap)\n        let cppTrace: @convention(c) (UnsafeMutableRawPointer?, Int, UnsafePointer<CChar>, UInt64, UnsafePointer<CChar>, UnsafePointer<CPPPerformanceInfo>) -> Void = {\n            cppTrace, tag, path, handleId, sql, cppInfo in\n            let traceWrap: ValueWrap<PerformanceTracer>? = ObjectBridge.extractTypedSwiftObject(cppTrace)\n            guard let traceWrap = traceWrap else {\n                return\n            }\n            let info = PerformanceInfo(cppInfo)\n            traceWrap.value(tag, String(cString: path), handleId, String(cString: sql), info)\n        }\n        WCDBDatabaseTracePerformance(database, cppTrace, traceWrapPointer, ObjectBridge.objectDestructor)\n    }\n    func trace(ofPerformance: Void?) {\n        WCDBDatabaseTracePerformance(database, nil, nil, nil)\n    }\n\n    typealias SQLTracer = (Tag, String, UInt64, String, String) -> Void // Tag, Path, handleIdentifier, SQL, info\n\n    /// You can register a tracer to monitor the execution of all SQLs.\n    /// It returns\n    /// 1. Every SQL executed by the database.\n    /// 2. Tag of database.\n    /// 3. Path of database.\n    /// 4. The id of the handle executing this SQL.\n    /// 5. Detailed execution information of SQL. It is valid only when full sql trace is enable.\n    /// Note that you should register trace before all db operations.\n    ///\n    ///     Database.globalTraceSQL{ (tag, path, handleId, sql, info) in\n    ///         print(\"Tag: \\(tag)\")\n    ///         print(\"Path: \\(path)\")\n    ///         print(\"The handle with id \\(handleId) executed \\(sql)\")\n    ///         print(\"Execution info \\(info)\")\n    ///     }\n    ///\n    /// Tracer may cause WCDB performance degradation, according to your needs to choose whether to open.\n    ///\n    /// - Parameter trace: trace. Nil to disable global sql trace.\n    static func globalTraceSQL(_ trace: @escaping SQLTracer) {\n        let cppCallback: @convention(c) (UnsafeMutableRawPointer?, Int, UnsafePointer<CChar>, UInt64, UnsafePointer<CChar>, UnsafePointer<CChar>) -> Void = {\n            (cppContext, tag, path, handleId, sql, info) in\n            let traceWrap: ValueWrap<SQLTracer>? = ObjectBridge.extractTypedSwiftObject(cppContext)\n            guard let traceWrap = traceWrap else {\n                return\n            }\n            traceWrap.value(tag, String(cString: path), handleId, String(cString: sql), String(cString: info))\n        }\n        let traceWrap = ValueWrap(trace)\n        let traceWrapPointer = ObjectBridge.getUntypeSwiftObject(traceWrap)\n        WCDBDatabaseGlobalTraceSQL(cppCallback, traceWrapPointer, ObjectBridge.objectDestructor)\n    }\n    static func globalTraceSQL(_ trace: Void?) {\n        WCDBDatabaseGlobalTraceSQL(nil, nil, nil)\n    }\n\n    /// You can register a tracer to monitor the execution of all SQLs executed in the current database.\n    /// Tracer may cause WCDB performance degradation, according to your needs to choose whether to open.\n    ///\n    /// - Parameter trace: trace. Nil to disable sql trace.\n    func traceSQL(_ trace: @escaping SQLTracer) {\n        let cppCallback: @convention(c) (UnsafeMutableRawPointer?, Int, UnsafePointer<CChar>, UInt64, UnsafePointer<CChar>, UnsafePointer<CChar>) -> Void = {\n            (cppContext, tag, path, handleId, sql, info) in\n            let traceWrap: ValueWrap<SQLTracer>? = ObjectBridge.extractTypedSwiftObject(cppContext)\n            guard let traceWrap = traceWrap else {\n                return\n            }\n            traceWrap.value(tag, String(cString: path), handleId, String(cString: sql), String(cString: info))\n        }\n        let traceWrap = ValueWrap(trace)\n        let traceWrapPointer = ObjectBridge.getUntypeSwiftObject(traceWrap)\n        WCDBDatabaseTraceSQL(database, cppCallback, traceWrapPointer, ObjectBridge.objectDestructor)\n    }\n    func traceSQL(_ trace: Void?) {\n        WCDBDatabaseTraceSQL(database, nil, nil, nil)\n    }\n\n    /// Enable to collect more SQL execution information in SQL tracer.\n    ///\n    /// The detailed execution information of sql will include all bind parameters,\n    /// step counts of `SELECT` statement, last inserted rowid of `INSERT` statement,\n    /// changes of `UPDATE` and `DELETE` statements.\n    /// These infomation will be returned in the last parameter of `SQLTracer`.\n    ///\n    /// Note That collecting these infomation will significantly reduce the performance of WCDB,\n    /// please enable it only when necessary, and disable it when unnecessary.\n    ///\n    /// - Parameter enable: enable or not.\n    func setFullSQLTrace(enable: Bool) {\n        WCDBDatabaseSetFullSQLTraceEnable(database, enable)\n    }\n\n    /// You can register a reporter to monitor all errors.\n    ///\n    ///     Database.globalTraceError{ (error) in\n    ///         print(\"[WCDB] \\(error.description)\")\n    ///     }\n    ///\n    /// - Parameter errorReporter: report. Nil to disable error trace.\n    static func globalTraceError(_ errorReporter: @escaping (WCDBError) -> Void) {\n        let cppCallback: @convention(c) (UnsafeMutableRawPointer?, CPPError) -> Void = {\n            cppContext, cppError in\n            let errorReporterWrap: ValueWrap<(WCDBError) -> Void>? = ObjectBridge.extractTypedSwiftObject(cppContext)\n            guard let errorReporterWrap = errorReporterWrap else {\n                return\n            }\n            let error = ErrorBridge.getErrorFrom(cppError: cppError)\n            errorReporterWrap.value(error)\n        }\n        let errorReporterWrap = ValueWrap(errorReporter)\n        let errorReporterWrapPointer = ObjectBridge.getUntypeSwiftObject(errorReporterWrap)\n        WCDBDatabaseGlobalTraceError(cppCallback, errorReporterWrapPointer, ObjectBridge.objectDestructor)\n    }\n    static func globalTraceError(_ trace: Void?) {\n        WCDBDatabaseGlobalTraceError(nil, nil, nil)\n    }\n\n    /// You can register a reporter to monitor all errors of current database.\n    ///\n    /// - Parameter errorReporter: report. Nil to disable error trace.\n    func traceError(_ errorReporter: @escaping (WCDBError) -> Void) {\n        let cppCallback: @convention(c) (UnsafeMutableRawPointer?, CPPError) -> Void = {\n            cppContext, cppError in\n            let errorReporterWrap: ValueWrap<(WCDBError) -> Void>? = ObjectBridge.extractTypedSwiftObject(cppContext)\n            guard let errorReporterWrap = errorReporterWrap else {\n                return\n            }\n            let error = ErrorBridge.getErrorFrom(cppError: cppError)\n            errorReporterWrap.value(error)\n        }\n        let errorReporterWrap = ValueWrap(errorReporter)\n        let errorReporterWrapPointer = ObjectBridge.getUntypeSwiftObject(errorReporterWrap)\n        WCDBDatabaseTraceError(database, cppCallback, errorReporterWrapPointer, ObjectBridge.objectDestructor)\n    }\n    func traceError(_ trace: Void?) {\n        WCDBDatabaseTraceError(database, nil, nil, nil)\n    }\n\n    enum Operation: Int {\n        case Create = 0\n        case SetTag = 1\n        case OpenHandle = 2\n    }\n\n    /// The following are the keys in the infos from the callback of database operation monitoring.\n    static let OperationInfoKeyHandleCount = String(cString: WCDBDatabaseOperationTracerInfoKeyHandleCount())\n    static let OperationInfoKeyHandleOpenTime = String(cString: WCDBDatabaseOperationTracerInfoKeyHandleOpenTime())\n    static let OperationInfoKeyHandleOpenCPUTime = String(cString: WCDBDatabaseOperationTracerInfoKeyHandleOpenCPUTime())\n    static let OperationInfoKeySchemaUsage = String(cString: WCDBDatabaseOperationTracerInfoKeySchemaUsage())\n    static let OperationInfoKeyTableCount = String(cString: WCDBDatabaseOperationTracerInfoKeyTableCount())\n    static let OperationInfoKeyIndexCount = String(cString: WCDBDatabaseOperationTracerInfoKeyIndexCount())\n    static let OperationInfoKeyTriggerCount = String(cString: WCDBDatabaseOperationTracerInfoKeyTriggerCount())\n\n    typealias OperationTracer = (Database, /* database */\n                                 Database.Operation, /* type of operation*/\n                                 [String: Value]/* infos about current operation */\n    ) -> Void\n\n    /// You can register a tracer to these database events:\n    /// 1. creating a database object for the first time;\n    /// 2. setting a tag on the database;\n    /// 3. opening a new database handle.\n    ///\n    /// - Parameter trace: trace. Nil to disable error trace.\n    static func globalTraceDatabaseOperation(_ trace: @escaping OperationTracer) {\n        let tracerWrap = ValueWrap(trace)\n        let tracerWrapPointer = ObjectBridge.getUntypeSwiftObject(tracerWrap)\n        let callback: @convention(c) (UnsafeMutableRawPointer?, CPPDatabase, Int, UnsafeRawPointer) -> Void = {\n            ctx, cppDatabase, type, info in\n            let tracerWrap: ValueWrap<OperationTracer>? = ObjectBridge.extractTypedSwiftObject(ctx)\n            guard let tracerWrap = tracerWrap else {\n                return\n            }\n            let database = Database(with: cppDatabase)\n            let operation = Operation(rawValue: type) ?? .Create\n            let wrapInfo: ValueWrap<[String: Value]> = ValueWrap([:])\n            let wrapInfoPointer = ObjectBridge.getUntypeSwiftObject(wrapInfo)\n            let enumerator: @convention(c) (UnsafeMutableRawPointer, UnsafePointer<CChar>, CPPCommonValue) -> Void = {\n                valueWrapPointer, key, value in\n                let valueWrap: ValueWrap<[String: Value]>? = ObjectBridge.extractTypedSwiftObject(valueWrapPointer)\n                guard let valueWrap = valueWrap else {\n                    return\n                }\n                switch value.type {\n                case WCDBBridgedType_Int:\n                    valueWrap.value[String(cString: key)] = Value(value.intValue)\n                case WCDBBridgedType_Double:\n                    valueWrap.value[String(cString: key)] = Value(value.doubleValue)\n                case WCDBBridgedType_String:\n                    valueWrap.value[String(cString: key)] = Value(String(cString: unsafeBitCast(value.intValue, to: UnsafePointer<CChar>.self)))\n                default:\n                    return\n                }\n            }\n            WCDBEnumerateStringViewMap(info, wrapInfoPointer, enumerator)\n            tracerWrap.value(database, operation, wrapInfo.value)\n            ObjectBridge.releaseSwiftObject(wrapInfoPointer)\n        }\n        WCDBDatabaseGlobalTraceOperation(callback, tracerWrapPointer, ObjectBridge.objectDestructor)\n    }\n\n    static func globalTraceDatabaseOperation(_ trace: Void?) {\n        WCDBDatabaseGlobalTraceOperation(nil, nil, nil)\n    }\n\n    // Triggered when the database operation is blocked by other threads.\n    typealias BusyTracer = (Tag /* tag */,\n                            String /* path */,\n                            UInt64 /* id of the thread being waited on */,\n                            String /* sql executing in the thread being waited on */\n    ) -> Void\n\n    /// You can register a tracer to database busy events.\n    /// It returns:\n    /// 1. Tag of database being busy.\n    /// 2. Path of database being busy.\n    /// 3. ID of the thread being waited on.\n    /// 4. SQL executing in the thread being waited on.\n    ///\n    /// Note that the tracer will be called back synchronously\n    /// when the database operation is blocked and times out,\n    /// so you can neither directly access the busy database\n    /// nor perform heavy operation in the tracer.\n    ///\n    /// - Parameter trace: tracer. Nil to disable busy trace.\n    /// - Parameter timeOut: timeout in seconds for blocking database operation.\n    static func globalTraceBusy(_ trace: @escaping BusyTracer, timeOut: Double) {\n        let callback: @convention(c) (UnsafeMutableRawPointer?, Int, UnsafePointer<CChar>, UInt64, UnsafePointer<CChar>) -> Void = {\n            cppTrace, tag, path, tid, sql in\n            let traceWrap: ValueWrap<BusyTracer>? = ObjectBridge.extractTypedSwiftObject(cppTrace)\n            guard let traceWrap = traceWrap else {\n                return\n            }\n            traceWrap.value(tag, String(cString: path), tid, String(cString: sql))\n        }\n        let traceWrap = ValueWrap(trace)\n        let traceWrapPointer = ObjectBridge.getUntypeSwiftObject(traceWrap)\n        WCDBCoreGlobalTraceBusy(callback, timeOut, traceWrapPointer, ObjectBridge.objectDestructor)\n    }\n\n    static func globalTraceBusy(_ trace: Void?, timeOut: Double) {\n        WCDBCoreGlobalTraceBusy(nil, 0, nil, nil)\n    }\n}\n\n// File\npublic extension Database {\n\n    /// URLs to all database-related files.\n    var urls: [URL] {\n        return paths.map({ (path) -> URL in\n            return URL(fileURLWithPath: path)\n        })\n    }\n\n    /// Paths to all database-related files.\n    var paths: [String] {\n        var paths: [String] = []\n        let enumerator: (UnsafePointer<CChar>) -> Void = {\n            path in\n            paths.append(String(cString: path))\n        }\n        let cppEnumerater: @convention(c) (UnsafeMutableRawPointer?, UnsafePointer<CChar>) -> Void = {\n            cppContext, string in\n            let enumeratorWrap: ValueWrap<(UnsafePointer<CChar>) -> Void>? = ObjectBridge.extractTypedSwiftObject(cppContext)\n            guard let enumeratorWrap = enumeratorWrap else {\n                return\n            }\n            enumeratorWrap.value(string)\n        }\n        let enumeratorWrap = ValueWrap(enumerator)\n        let enumeratorWrapPointer = ObjectBridge.getUntypeSwiftObject(enumeratorWrap)\n        WCDBDatabaseGetPaths(database, enumeratorWrapPointer, cppEnumerater)\n        ObjectBridge.objectDestructor(enumeratorWrapPointer)\n        return paths\n    }\n\n    /// Remove all database-related files.  \n    /// You should call it on a closed database. Otherwise you will get a warning.\n    ///\n    /// - Throws: `Error`\n    func removeFiles() throws {\n        if !WCDBDatabaseRemoveFile(database) {\n            throw getError()\n        }\n    }\n\n    /// Move all database-related files and some extra files to directory safely.\n    ///\n    /// - Parameters:\n    ///   - directory: destination\n    /// - Throws: `Error`\n    func moveFiles(toDirectory directory: String) throws {\n        if !WCDBDatabaseMoveFile(database, directory) {\n            throw getError()\n        }\n    }\n\n    /// Get the space used by the database files.  \n    /// You should call it on a closed database. Otherwise you will get a warning.\n    ///\n    /// - Returns: The sum of files size in bytes.\n    /// - Throws: `Error`\n    func getFilesSize() throws -> UInt64 {\n        let ret = WCDBDatabaseGetFileSize(database)\n        if !ret.hasValue {\n            throw getError()\n        }\n        return ret.value\n    }\n}\n\n// Repair\npublic extension Database {\n    typealias OnCorrupted = (_ corruptedDatabase: Database) -> Void\n    /// You can register a notification callback for database corruption.\n    /// If the current database reports an error of `SQLITE_CORRUPT` or `SQLITE_NOTADB` during operation,\n    /// WCDB will asynchronously use `PRAGMA integrity_check` to check whether this database is truly corrupted.\n    /// Once confirmed, WCDB will notify you through the callback registered by this method.\n    /// In the callback, you can delete the corrupted database or try to repair the database.\n    ///\n    /// - Parameter callback: The callback of notification.\n    func setNotification(whenCorrupted callback: OnCorrupted?) {\n        if let callback = callback {\n            let cppCallback: @convention(c) (UnsafeMutableRawPointer?, CPPDatabase) -> Void = {\n                cppContext, database in\n                let callbackWrap: ValueWrap<OnCorrupted>? = ObjectBridge.extractTypedSwiftObject(cppContext)\n                guard let callbackWrap = callbackWrap else {\n                    return\n                }\n                callbackWrap.value(Database(with: database))\n            }\n            let callbackWrap = ValueWrap(callback)\n            let callbackWrapPointer = ObjectBridge.getUntypeSwiftObject(callbackWrap)\n            WCDBDatabaseSetNotificationWhenCorrupted(database, cppCallback, callbackWrapPointer, ObjectBridge.objectDestructor)\n        } else {\n            WCDBDatabaseSetNotificationWhenCorrupted(database, nil, nil, nil)\n        }\n    }\n\n    /// Check if the database is corrupted.\n    /// Since this method will check all the contents of the database until it finds something corrupted, it is time consuming and you'd better not call this method on the main thread.\n    func checkIfCorrupted() -> Bool {\n        return WCDBDatabaseCheckIfCorrupted(database)\n    }\n\n    /// Check if the database has been marked as corrupted\n    func isAlreadyCorrupted() -> Bool {\n        return WCDBDatabaseCheckIsAlreadyCorrupted(database)\n    }\n\n    /// Enable database to automatically backup itself after there are updates.\n    ///\n    /// The backup content mainly includes the SQL statements related to table creation,\n    /// and all leaf page numbers of each table in database.\n    /// The backup content will be saved in the same directory of the database.\n    /// And the backup file name is the database file name plus \"-first.material\" and \"-last.material\" suffixes.\n    ///\n    /// Auto-backup do not degrade IO performance of the database.\n    func setAutoBackup(enable flag: Bool) {\n        WCDBDatabaseEnableAutoBackup(database, flag)\n    }\n\n    /// Backup the database manually.\n    ///\n    /// The backup content will be saved in the same directory of the database.\n    /// And the backup file name is the database file name plus \"-first.material\" and \"-last.material\" suffixes.\n    func backup() throws {\n        if !WCDBDatabaseBackup(database) {\n            throw getError()\n        }\n    }\n\n    typealias BackupFiilter = (_ tableName: String) -> Bool\n\n    /// Set a filter to tell which table should be backed up.\n    ///\n    /// The filter will be called for every table in database during the initialization of backup logic.\n    /// If there are some tables that do not need to be backed up, return false when these table names are passed into the filter.\n    ///\n    /// - Parameter filter: The table filter. A table name will be pass to filter when it's called.\n    func filterBackup(tableShouldBeBackedUp filter: BackupFiilter?) {\n        if let filter = filter {\n            let cppFilter: @convention(c) (UnsafeMutableRawPointer?, UnsafePointer<CChar>) -> Bool = {\n                cppContext, cppTable in\n                let filterWrap: ValueWrap<BackupFiilter>? = ObjectBridge.extractTypedSwiftObject(cppContext)\n                guard let filterWrap = filterWrap else {\n                    return false\n                }\n                return filterWrap.value(String(cString: cppTable))\n            }\n            let filterWrap = ValueWrap(filter)\n            let filterWrapPointer = ObjectBridge.getUntypeSwiftObject(filterWrap)\n            WCDBDatabaseFilterBackup(database, cppFilter, filterWrapPointer, ObjectBridge.objectDestructor)\n        } else {\n            WCDBDatabaseFilterBackup(database, nil, nil, nil)\n        }\n    }\n\n    /// Recover data from a corruped db.\n    ///\n    /// If there is a valid backup of this database, most of the uncorrupted data can be recovered,\n    /// otherwise WCDB will try to read all the data that can still be accessed, starting from the first page of the database.\n    /// In the extreme case where this database is not backed up and the first page is corrupted, no data can be recovered.\n    ///\n    /// Since repairing a database requires reading all uncorrupted data and writing them to a new database, it may take a lot of time to finish the job.\n    /// During this period, you'd better display a loading view on the screen and present the processing percentage.\n    ///\n    /// - Parameter progress: A closure that receives the repair progress.\n    /// - Returns: Percentage of repaired data. 0 or less then 0 means data recovery failed. 1 means data is fully recovered.\n    func retrieve(with progress: ProgressUpdate?) throws -> Double {\n        var score = 0.0\n        if let progress = progress {\n            let cppProgress: @convention(c) (UnsafeMutableRawPointer?, Double, Double) -> Bool = {\n                cppContext, percentage, increment in\n                let progressWrap: ValueWrap<ProgressUpdate>? = ObjectBridge.extractTypedSwiftObject(cppContext)\n                guard let progressWrap = progressWrap else {\n                    return false\n                }\n                return progressWrap.value(percentage, increment)\n            }\n            let progressWrap = ValueWrap(progress)\n            let progressWrapPointer = ObjectBridge.getUntypeSwiftObject(progressWrap)\n            score = WCDBDatabaseRetrieve(database, cppProgress, progressWrapPointer, ObjectBridge.objectDestructor)\n        } else {\n            score = WCDBDatabaseRetrieve(database, nil, nil, nil)\n        }\n        if score < 0 {\n            throw getError()\n        }\n        return score\n    }\n\n    /// Deposit database.\n    /// This method is designed for conditions where the database is corrupted and cannot be repaired temporarily. It can deposit the corrupted database to a new location and create a temporary database for the user. The contents of the deposited database will be restored when you recover the database.\n    /// This method can be called multiple times without loss of data.\n    /// - Throws: `Error`\n    func deposit() throws {\n        if !WCDBDatabaseDeposit(database) {\n            throw getError()\n        }\n    }\n\n    /// Check whether there is deposited data.\n    func containDepositedFiles() -> Bool {\n        return WCDBDatabaseContainDepositedFiles(database)\n    }\n\n    /// Remove deposited data.\n    func removeDepositedFiles() throws {\n        if !WCDBDatabaseRemoveDepositedFiles(database) {\n            throw getError()\n        }\n    }\n}\n\n// Migration\npublic extension Database {\n    struct MigrationInfo {\n        public var table: String = \"\"           // Target table of migration\n        public var sourceTable: String?         // Source table of migration\n        public var filterCondition: Expression? // Filter condition of source table\n    }\n\n    /// Triggered at any time when WCDB needs to know whether a table in the current database needs to migrate data,\n    /// mainly including creating a new table, reading and writing a table, and starting to migrate a new table.\n    /// If the current table does not need to migrate data, you need to set the sourceTable in `MigrationInfo` to nil.\n    typealias TableFilter = (_ info: inout MigrationInfo) -> Void\n\n    /// Configure which tables in the current database need to migrate data, and the source table they need to migrate data from.\n    ///\n    /// Once configured, you can treat the target table as if it already has all the data of the source table, and can read and write these data through the target table.\n    /// WCDB will internally convert your CRUD operations on the target table into the CRUD operations on both the target table and the source table appropriately.\n    /// You neither need to be aware of the existence of the source table, nor care about the progress of data migration.\n    ///\n    /// The column definition of the target table must be exactly the same as the column definition of the source table.\n    /// The database does not record the state of the migration to disk, so if you have data to migrate, you need to use this function to configure the migration before executing any statements on current database.\n    ///\n    /// If the source table is not in the current database, the database containing the source table will be attached to the current database before the migration is complete.\n    /// After migration, source tables will be dropped.\n    ///\n    /// - Parameter sourcePath: path of source database.\n    /// - Parameter sourceCipher: cipher of source database. It is optional.\n    /// - Parameter filter: see `TableFilter`.\n    func addMigration(sourcePath: String?, sourceCipher: Data? = nil, _ filter: TableFilter?) {\n        if let filter = filter {\n            let filterWrap = ValueWrap(filter)\n            let filterPointer = ObjectBridge.getUntypeSwiftObject(filterWrap)\n            let cppFilter: @convention(c) (UnsafeMutableRawPointer?, UnsafePointer<CChar>, UnsafeMutableRawPointer, @convention(c) (UnsafeMutableRawPointer, UnsafePointer<CChar>?, CPPExpression) -> Void) -> Void  = {\n                filter, table, cppInfo, setter in\n                let filterWrap: ValueWrap<TableFilter>? = ObjectBridge.extractTypedSwiftObject(filter)\n                if let filterWrap = filterWrap {\n                    var info = MigrationInfo(table: String(cString: table))\n                    filterWrap.value(&info)\n                    if let sourceTable = info.sourceTable {\n                        if let filtercCondition = info.filterCondition {\n                            withExtendedLifetime(filtercCondition) {\n                                setter(cppInfo, sourceTable.cString, $0.cppObj)\n                            }\n                        } else {\n                            setter(cppInfo, sourceTable.cString, CPPExpression())\n                        }\n                    }\n                }\n            }\n            if let sourceCipher = sourceCipher {\n                sourceCipher.withUnsafeBytes { (buffer: UnsafeRawBufferPointer) in\n                    WCDBDatabaseAddMigration(database, sourcePath?.cString, buffer.bindMemory(to: UInt8.self).baseAddress, Int32(buffer.count), cppFilter, filterPointer, ObjectBridge.objectDestructor)\n                }\n            } else {\n                WCDBDatabaseAddMigration(database, sourcePath?.cString, nil, 0, cppFilter, filterPointer, ObjectBridge.objectDestructor)\n            }\n        } else {\n            WCDBDatabaseAddMigration(database, sourcePath?.cString, nil, 0, nil, nil, nil)\n        }\n    }\n\n    ///  Manually spend about 0.01 sec. to migrate data.\n    ///  You can call this function periodically until all data is migrated.\n    func stepMigration() throws {\n        if !WCDBDatabaseStepMigration(database) {\n            throw getError()\n        }\n    }\n\n    /// Configure the database to automatically step migration every two seconds.\n    func setAutoMigration(enable flag: Bool) {\n        WCDBDatabaseEnableAutoMigration(database, flag)\n    }\n\n    /// Check if all tables in the database has finished migration.\n    /// It only check an internal flag of database.\n    func isMigrated() -> Bool {\n        return WCDBDatabaseIsMigrated(database)\n    }\n\n    /// Triggered when a table or a database is migrated completely.\n    /// When a table is migrated successfully, tableInfo will carry the information of the table.\n    /// When a database is migrated, tableInfo has no value.\n    typealias MigratedCallback = (_ database: Database, _ tableInfo: MigrationInfo?) -> Void\n\n    /// Register a callback for migration notification.\n    /// The callback will be called when each table completes the migration.\n    ///\n    /// - Parameter callback: see `MigratedCallback`.\n    func setNotificationWhenMigrated(_ callback: MigratedCallback?) {\n        if let callback = callback {\n            let cppCallback: @convention(c) (UnsafeMutableRawPointer?, CPPDatabase, UnsafePointer<CChar>?, UnsafePointer<CChar>?) -> Void = {\n                cppContext, cppDatabase, tableName, sourceTableName in\n                let callbackWrap: ValueWrap<MigratedCallback>? = ObjectBridge.extractTypedSwiftObject(cppContext)\n                guard let callbackWrap = callbackWrap else {\n                    return\n                }\n                let database = Database(with: cppDatabase)\n                var info: MigrationInfo?\n                if let tableName = tableName,\n                   let sourceTableName = sourceTableName {\n                    info = MigrationInfo(table: String(cString: tableName),\n                                         sourceTable: String(cString: sourceTableName))\n                }\n                callbackWrap.value(database, info)\n            }\n            let callbackWrap = ValueWrap(callback)\n            let callbackWrapPointer = ObjectBridge.getUntypeSwiftObject(callbackWrap)\n            WCDBDatabaseSetNotificationWhenMigrated(database, cppCallback, callbackWrapPointer, ObjectBridge.objectDestructor)\n        } else {\n            WCDBDatabaseSetNotificationWhenMigrated(database, nil, nil, nil)\n        }\n    }\n}\n\n// Compression\npublic extension Database {\n    static let DictDefaultMatchValue = INT64_MAX\n    typealias DictId = UInt8\n\n    /// Train a zstd formalized dict with a set of sample strings.\n    ///\n    /// Note that the total size of all samples cannot exceed 4G.\n    ///\n    /// - Parameter strings: samples.\n    /// - Parameter dictId: spercified id of the result dict. It can not be zero.\n    /// - Returns: a dict of 100KB if succeed.\n    /// - Throws: `Error`\n    static func trainDict(with strings: [String], and dictId: DictId) throws -> Data {\n        try withExtendedLifetime(strings) {\n            var index = 0\n            let dataEnumerator: () -> CPPData = {\n                var ret = CPPData(buffer: nil, size: 0)\n                if index >= strings.count {\n                    return ret\n                }\n                let cstring = strings[index].cString\n                guard let cstring = cstring else {\n                    index += 1\n                    return ret\n                }\n                ret.size = UInt64(strings[index].lengthOfBytes(using: .utf8))\n                cstring.withMemoryRebound(to: UInt8.self, capacity: Int(ret.size)) { pointer in\n                    ret.buffer = UnsafeMutablePointer(mutating: pointer)\n                }\n                index += 1\n                return ret\n            }\n            let cppDataEnumerator: @convention(c) (UnsafeMutableRawPointer) -> CPPData = {\n                cppContext in\n                let enumeratorWrap: ValueWrap<() -> CPPData>? = ObjectBridge.extractTypedSwiftObject(cppContext)\n                guard let enumeratorWrap = enumeratorWrap else {\n                    return CPPData(buffer: nil, size: 0)\n                }\n                return enumeratorWrap.value()\n            }\n            let enumeratorWrap = ValueWrap(dataEnumerator)\n            let enumeratorWrapPointer = ObjectBridge.getUntypeSwiftObject(enumeratorWrap)\n            let dictData = WCDBDatabaseTrainDict(dictId, cppDataEnumerator, enumeratorWrapPointer)\n            ObjectBridge.objectDestructor(enumeratorWrapPointer)\n            if dictData.size > 0, let buffer = dictData.buffer {\n                let dict = Data(bytes: buffer, count: Int(dictData.size))\n                free(buffer)\n                return dict\n            }\n            let cppError = WCDBCoreGetThreadedError()\n            throw ErrorBridge.getErrorFrom(cppError: cppError)\n        }\n    }\n\n    /// Train a zstd formalized dict with a set of sample datas.\n    ///\n    /// Note that the total size of all samples cannot exceed 4G.\n    ///\n    /// - Parameter datas: samples.\n    /// - Parameter dictId: spercified id of the result dict. It can not be zero.\n    /// - Returns: a dict of 100KB if succeed.\n    /// - Throws: `Error`\n    static func trainDict(with datas: [Data], and dictId: DictId) throws -> Data {\n        try withExtendedLifetime(datas) {\n            var index = 0\n            let dataEnumerator: () -> CPPData = {\n                var ret = CPPData(buffer: nil, size: 0)\n                if index >= datas.count {\n                    return ret\n                }\n                ret.size = UInt64(datas[index].count)\n                datas[index].withUnsafeBytes { pointer in\n                    ret.buffer = UnsafeMutablePointer(mutating: pointer.bindMemory(to: UInt8.self).baseAddress)\n                }\n                index += 1\n                return ret\n            }\n            let cppDataEnumerator: @convention(c) (UnsafeMutableRawPointer) -> CPPData = {\n                cppContext in\n                let enumeratorWrap: ValueWrap<() -> CPPData>? = ObjectBridge.extractTypedSwiftObject(cppContext)\n                guard let enumeratorWrap = enumeratorWrap else {\n                    return CPPData(buffer: nil, size: 0)\n                }\n                return enumeratorWrap.value()\n            }\n            let enumeratorWrap = ValueWrap(dataEnumerator)\n            let enumeratorWrapPointer = ObjectBridge.getUntypeSwiftObject(enumeratorWrap)\n            let dictData = WCDBDatabaseTrainDict(dictId, cppDataEnumerator, enumeratorWrapPointer)\n            ObjectBridge.objectDestructor(enumeratorWrapPointer)\n            if dictData.size > 0, let buffer = dictData.buffer {\n                let dict = Data(bytes: buffer, count: Int(dictData.size))\n                free(buffer)\n                return dict\n            }\n            let cppError = WCDBCoreGetThreadedError()\n            throw ErrorBridge.getErrorFrom(cppError: cppError)\n        }\n    }\n\n    /// Register a zstd dict in to WCDB.\n    /// You must register a dict before using it.\n    ///\n    /// - Parameter dict: dict data.\n    /// - Parameter dictId: id of the dict. It can not be zero.\n    /// - Throws: `Error`\n    static func register(dict: Data, with dictId: DictId) throws {\n        try dict.withUnsafeBytes { (bytes: UnsafeRawBufferPointer) in\n            if !WCDBDatabaseRegisterDict(bytes.bindMemory(to: UInt8.self).baseAddress, dict.count, dictId) {\n                let cppError = WCDBCoreGetThreadedError()\n                throw ErrorBridge.getErrorFrom(cppError: cppError)\n            }\n        }\n    }\n\n    class CompressionInfo {\n        // The table to be compressed\n        public let tableName: String\n\n        // Configure to compress all data in the specified column with the default zstd compression algorithm.\n        public func addZSTDNormalCompress(to property: PropertyConvertible) {\n            let column = property.asColumn()\n            withExtendedLifetime(column) {\n                WCDBDatabaseSetZSTDNormalCompress(cppInfo, $0.cppObj)\n            }\n        }\n\n        // Configure to compress all data in the specified column with a registered zstd dict.\n        public func addZSTDDictCompress(to property: PropertyConvertible, withDict id: DictId) {\n            let column = property.asColumn()\n            withExtendedLifetime(column) {\n                WCDBDatabaseSetZSTDDictCompress(cppInfo, $0.cppObj, id)\n            }\n        }\n\n        /// Configure to compress all data in the specified column with multi registered zstd dict.\n        /// Which dict to use when compressing is based on the value of the specified matching column.\n        /// You can use `DictDefaultMatchValue` to specify a default dict.\n        ///\n        /// Note that the matching column must be an integer column.\n        public func addZSTDMultiDictCompress(to property: PropertyConvertible,\n                                             withMatchProperty matchProperty: PropertyConvertible,\n                                             andDicts dicts: [Int64/* Value of match column */: DictId]) {\n            let column = property.asColumn()\n            let matchColumn = matchProperty.asColumn()\n            ObjectBridge.extendLifetime(column, matchColumn) {\n                let keyBuffer: UnsafeMutableBufferPointer<Int64> = .allocate(capacity: dicts.count)\n                let valueBuffer: UnsafeMutableBufferPointer<UInt8> = .allocate(capacity: dicts.count)\n                var index = 0\n                for (key, value) in dicts {\n                    keyBuffer[index] = key\n                    valueBuffer[index] = value\n                    index += 1\n                }\n                WCDBDatabaseSetZSTDMultiDictCompress(self.cppInfo, column.cppObj, matchColumn.cppObj, keyBuffer.baseAddress, valueBuffer.baseAddress, Int32(dicts.count))\n                keyBuffer.deallocate()\n                valueBuffer.deallocate()\n            }\n        }\n\n        /// Enable to replace original compression format.\n        /// After activation, you can use `Database.stepCompression()` or `Database.enableAutoCompression(_:)` to recompress the existing data with the new compression configuration.\n        public func enableReplaceCompression() {\n            WCDBDatabaseEnableReplaceCompresssion(cppInfo)\n        }\n\n        internal init(with cppInfo: UnsafeMutableRawPointer, table name: String) {\n            self.cppInfo = cppInfo\n            self.tableName = name\n        }\n        private let cppInfo: UnsafeMutableRawPointer\n    }\n\n    /// Triggered at any time when WCDB needs to know whether a table in the current database needs to compress data,\n    /// mainly including creating a new table, reading and writing a table,and starting to compress a new table.\n    /// If the current table does not need to compress data, you don't need to config `CompressionInfo`.\n    typealias CompressionFilter = (_ info: inout CompressionInfo) -> Void\n\n    /// Configure which tables in the current database need to compress data.\n    /// Once configured, newly written data will be compressed immediately and synchronously,\n    /// and you can use `Database.stepCompression()` and `Database.enableAutoCompression()` to compress existing data.\n    ///\n    /// - Parameter filter: a filter to configure which tables need to be compressed and how to compress them.\n    func setCompression(with filter: CompressionFilter?) {\n        if let filter = filter {\n            let filterWrap = ValueWrap(filter)\n            let filterPointer = ObjectBridge.getUntypeSwiftObject(filterWrap)\n            let cppFilter: @convention(c) (UnsafeMutableRawPointer, UnsafePointer<CChar>, UnsafeMutableRawPointer) -> Void  = {\n                cppContext, table, cppInfo in\n                let filterWrap: ValueWrap<CompressionFilter>? = ObjectBridge.extractTypedSwiftObject(cppContext)\n                guard let filterWrap = filterWrap else {\n                    return\n                }\n                var info = CompressionInfo(with: cppInfo, table: String(cString: table))\n                filterWrap.value(&info)\n            }\n            WCDBDatabaseSetCompression(database, cppFilter, filterPointer, ObjectBridge.objectDestructor)\n        } else {\n            WCDBDatabaseSetCompression(database, nil, nil, nil)\n        }\n    }\n\n    /// Configure not to compress new data written to the current database.\n    /// This configuration is mainly used to deal with some emergency scenarios.\n    /// It allows already compressed data to be read normally, but new data is no longer compressed.\n    /// - Parameter disable: disable compression or not.\n    func disableCompressNewData(_ disable: Bool) {\n        WCDBDatabaseDisableCompressNewData(database, disable)\n    }\n\n    /// Manually compress 100 rows of existing data.\n    /// You can call this method periodically until all data is compressed.\n    ///\n    /// - Throws: `Error`\n    func stepCompression() throws {\n        if !WCDBDatabaseStepCompression(database) {\n            throw getError()\n        }\n    }\n\n    /// Configure the database to automatically compress 100 rows of data every two seconds.\n    ///\n    /// - Parameter enable: enable auto-compression or not.\n    func enableAutoCompression(_ enable: Bool) {\n        WCDBDatabaseEnableAutoCompression(database, enable)\n    }\n\n    /// Triggered when a table is compressed completely.\n    /// When a table is compressed successfully, tableName will be valid.\n    /// When a database is totally compressed, tableName will be nil.\n    typealias CompressedCallback = (_ database: Database, _ table: String?) -> Void\n\n    /// Register a callback for compression notification.\n    /// The callback will be called when each table completes the compression.\n    ///\n    /// - Parameter callback: see `CompressedCallback`.\n    func setNotificationWhenCompressed(_ callback: CompressedCallback?) {\n        if let callback = callback {\n            let cppCallback: @convention(c) (UnsafeMutableRawPointer, CPPDatabase, UnsafePointer<CChar>?) -> Void = {\n                cppContext, cppDatabase, cppTableName in\n                let callbackWrap: ValueWrap<CompressedCallback>? = ObjectBridge.extractTypedSwiftObject(cppContext)\n                guard let callbackWrap = callbackWrap else {\n                    return\n                }\n                let database = Database(with: cppDatabase)\n                var tableName: String?\n                if let cppTableName = cppTableName {\n                    tableName = String(cString: cppTableName)\n                }\n                callbackWrap.value(database, tableName)\n            }\n            let callbackWrap = ValueWrap(callback)\n            let callbackWrapPointer = ObjectBridge.getUntypeSwiftObject(callbackWrap)\n            WCDBDatabaseSetNotificationWhenCompressed(database, cppCallback, callbackWrapPointer, ObjectBridge.objectDestructor)\n        } else {\n            WCDBDatabaseSetNotificationWhenCompressed(database, nil, nil, nil)\n        }\n    }\n\n    /// Check if all tables in the database has finished compression.\n    /// It only check an internal flag of database.\n    ///\n    /// - Returns: true if all tables in the database has finished compression.\n    func isCompressed() -> Bool {\n        return WCDBDatabaseIsCompressed(database)\n    }\n\n    /// Decompress all compressed data in the database and resave them.\n    ///\n    /// It will clear all compression status and progress, and disables automatic compression.\n    /// Note that if the rollback process is interrupted or failed, the data may be in a mixed state of compressed and uncompressed.\n    ///\n    /// - Returns: true if all operation succeed.\n    func rollbackCompression(with progress: ProgressUpdate?) throws {\n        if let progress = progress {\n            let cppProgress: @convention(c) (UnsafeMutableRawPointer?, Double, Double) -> Bool = {\n                cppContext, percentage, increment in\n                let progressWrap: ValueWrap<ProgressUpdate>? = ObjectBridge.extractTypedSwiftObject(cppContext)\n                guard let progressWrap = progressWrap else {\n                    return false\n                }\n                return progressWrap.value(percentage, increment)\n            }\n            let progressWrap = ValueWrap(progress)\n            let progressWrapPointer = ObjectBridge.getUntypeSwiftObject(progressWrap)\n            if !WCDBDatabaseRollbackCompression(database, cppProgress, progressWrapPointer, ObjectBridge.objectDestructor) {\n                throw getError()\n            }\n        } else {\n            if !WCDBDatabaseRollbackCompression(database, nil, nil, nil) {\n                throw getError()\n            }\n        }\n    }\n}\n\n// FTS\npublic struct BuiltinTokenizer {\n    /// The following four are sqlite built-in fts tokenizers.\n    /// `Simple` can be used in fts3/4 and the others can be used in fts3/4/5.\n    public static let Simple = String(cString: WCDBTokenizerSimpleName())\n    public static let Porter = String(cString: WCDBTokenizerPorterName())\n    public static let ICU = String(cString: WCDBTokenizerICUName())\n    public static let Unicode61 = String(cString: WCDBTokenizerUnicode61Name())\n\n    /// `OneOrBinary`is WCDB implemented tokenizers for fts3/4.\n    /// It's compatible with WCDB tokenizer of older versions.\n    ///\n    /// When tokenizing, symbol characters are ignored by default.\n    /// Consecutive English letters will be recognized as an English token, and this token will be stemmed using the porter stemming algorithm.\n    /// Continuous Arabic numerals will be recognized as a single numeric token.\n    /// For other Unicode characters, each character will be recognized as one token.\n    ///\n    /// For example, the sentence \"The phone number of 张三 is 12345\" will be split into these tokens: \"the\", \"phone\", \"number\", \"of\", \"张\", \"三\", \"is\", \"12345\".\n    public static let OneOrBinary = String(cString: WCDBTokenizerLegacyOneOrBinaryName())\n\n    /// The following two are WCDB implemented tokenizers for fts5.\n    ///\n    /// `Verbatim` has the same tokenize rules as `OneOrBinary`.\n    /// `Pinyin` is designed for pinyin search. You can use the simplified or full pinyin of Chinese characters to search for Chinese characters.\n    /// Before using this tokenizer, you need to use `config(pinyinDict:)` to configure the mapping relationship between Chinese characters and their pinyin.\n    public static let Verbatim = String(cString: WCDBTokenizerVerbatimName())\n    public static let Pinyin = String(cString: WCDBTokenizerPinyinName())\n\n    public struct Parameter {\n        /// The following three are optional parameters for WCDB implemented tokenizers.\n        ///\n        /// Configuring `NeedSymbol` allows the tokenizer to recognize each symbol character as a token.\n        /// Configuring `SimplifyChinese` enables the tokenizer to convert each traditional Chinese character into a simplified Chinese character, so that you can use Simplified Chinese characters to search Traditional Chinese characters. Note that you need to call `config(traditionalChineseDict:)` to configure the mapping relationship between traditional Chinese characters and simplified Chinese characters before using the tokenizer.\n        /// Configuring `SkipStemming` will disable the stemming during tokenization.\n        public static let NeedSymbol = String(cString: WCDBTokenizerParameterNeedSymbolName())\n        public static let SimplifyChinese = String(cString: WCDBTokenizerParameterSimplifyChineseName())\n        public static let SkipStemming = String(cString: WCDBTokenizerParameterSkipStemmingName())\n    }\n}\n\npublic struct BuiltinAuxiliaryFunction {\n    /// `SubstringMatchInfo` is a WCDB implemented auxiliary function for fts5.\n    ///\n    /// When you need to concat multiple contents together with multi-level separators and save them in a single column of the fts5 table,\n    /// you can use this auxiliary function to improve the accuracy of searching for the contents of this column.\n    ///\n    /// Suppose you have a friend named 张三, whose address is 广州 and 上海, and phone number is 12345 and 67890.\n    /// You can use semicolon and comma as two-level separators to concat your friend's information into \"张三;广州,上海;12345,67890\",\n    /// and save it in a column named \"friends\" in an fts5 table. Then you can use following code to search your friend:\n    ///\n    ///     fts5Table.getColumn(on: Column(named: fts5Table.name).substringMatchInfo().arguments(0, \";,\"), where: Column(named: \"friends\").match(\"州\"))\n    ///\n    /// The first argument of SubstringMatchInfo is a column named with table name.\n    /// The second argument is the index of the colum you need to search. The index is are numbered starting from 0.\n    /// The third parameter is the separator used when concating the content, which should be arranged according to their level.\n    ///\n    /// Then you will get this string result \"1,0;广;州;3;\". The result is made by concating a variety of information with the separator you passed in.\n    /// The first part of the result \"1,0\" gives the hierarchical position of the matched content within matched column.\n    /// The second part \"广;州\" is the original text of the matching content, you can use it for highlighting.\n    /// The third part \"3\" is the byte offset of the matching content in the original text, you can use it to sort the results.\n    ///\n    /// The search results may contain some empty strings, which are invalid results.\n    /// This kind of results appear when the content of some rows contain the tokens you are searching for,\n    /// but these tokens are located in different parts separated by separators. You just need to ignore these results.\n    public static let SubstringMatchInfo = String(cString: WCDBAuxiliaryFunctionSubstringMatchInfoName())\n}\n\npublic extension Database {\n    /// Enable to automatically merge b-tree segments of fts5 index after modifying the content in fts5 table.\n    ///\n    /// The merge operation will be performed in a separate sub-thread, and will be suspended when it detects that other threads need to modify the fts table.\n    /// So it will improve the performance of modifying the fts5 table.\n    ///\n    /// Using auto-merge, WCDB can maintain only one segment per level in the fts5 index structure.\n    /// So it will significantly improve the search performance of the fts5 index.\n    func setAutoMergeFTS5Index(enable: Bool) {\n        WCDBDatabaseEnableAutoMergeFTS5Index(database, enable)\n    }\n\n    /// Setup tokenizer with name for current database.\n    ///\n    /// You can set up the built-in tokenizers of sqlite and the tokenizers implemented by WCDB directly.\n    /// If you want to use your custom tokenizer, you should firstly register it through `register(tokenizer:of:of:)`\n    ///\n    /// - Parameter tokenizer: Name of tokenizer.\n    func add(tokenizer: String) {\n        WCTAPIBridge.configDefaultSymbolDetectorAndUnicodeNormalizer()\n        WCDBDatabaseAddTokenizer(database, tokenizer.cString)\n    }\n\n    /// Register custom tokenizer.\n    /// The custom tokenizer needs to implement the `Tokenizer` protocal.\n    ///\n    /// - Parameters:\n    ///  - tokenizer:Type of tokenizer.\n    ///  - name: Name of Tokenizer.\n    ///  - version: version of fts.\n    static func register<TokenizerType: Tokenizer>(tokenizer: TokenizerType.Type, of name: String, of version: FTSVersion) {\n        FTSBridge.register(tokenizer: tokenizer, of: name, of: version)\n    }\n\n    /// Setup auxiliary function with name for current database.\n    ///\n    /// You can set up the built-in auxiliary functions of sqlite and the auxiliary functions implemented by WCDB directly.\n    ///\n    /// - Parameter auxFunction: Name of auxiliary function.\n    func add(auxFunction: String) {\n        WCDBDatabaseAddAuxiliaryFunction(database, auxFunction.cString)\n    }\n\n    /// Configure the mapping relationship between Chinese characters and their pinyin.\n    /// It is designed for the builtin pinyin tokenizer.\n    static func config(pinyinDict: [String /*Chinese character*/ : [String] /*Pinyin array*/]) {\n        WCTAPIBridge.configPinyinDict(pinyinDict)\n    }\n\n    /// Configure the mapping relationship between traditional Chinese characters and simplified Chinese characters.\n    static func config(traditionalChineseDict: [String /*Traditional Chinese character*/ : String /*Simplified Chinese character*/]) {\n        WCTAPIBridge.configTraditionalChineseDict(traditionalChineseDict)\n    }\n\n    /// Enable/Disable Lite mode.\n    /// Lite mode is disabled by default.\n    /// In lite mode, the journal mode and synchronous flag of current database will be set to `OFF`,\n    /// which will significantly reduces IO, improve performance, and also increase the probability of data corruption.\n    /// Note that you can not rollback transaction or backup data in lite mode.\n    func setLiteMode(enable: Bool) {\n        WCDBDatabaseEnableLiteMode(database, enable)\n    }\n}\n\n// checkpoint\npublic extension Database {\n    /// Checkpoint database in passive mode.\n    /// WCDB will automatically checkpoint databases after it changes.\n    /// You don't need to checkpoint periodically, and you don't even need to care about checkpoint.\n    func passiveCheckpoint() throws {\n        if !WCDBDatabasePassiveCheckpoint(database) {\n            throw getError()\n        }\n    }\n\n    /// Checkpoint database in truncate mode.\n    func truncateCheckpoint() throws {\n        if !WCDBDatabaseTruncateCheckpoint(database) {\n            throw getError()\n        }\n    }\n}\n\nextension Database: HandleRepresentable {}\n\nextension Database: InsertChainCallInterface {}\nextension Database: UpdateChainCallInterface {}\nextension Database: DeleteChainCallInterface {}\nextension Database: RowSelectChainCallInterface {}\nextension Database: SelectChainCallInterface {}\nextension Database: MultiSelectChainCallInterface {}\n\nextension Database: InsertInterface {}\nextension Database: UpdateInterface {}\nextension Database: DeleteInterface {}\nextension Database: RowSelectInterface {}\nextension Database: SelectInterface {}\nextension Database: StatementSelectInterface {}\nextension Database: TableInterface {}\nextension Database: TransactionInterface {}\n"
  },
  {
    "path": "src/swift/core/base/Handle+WCTTableCoding.swift",
    "content": "//\n// Created by qiuwenchen on 2022/11/13.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#if WCDB_SWIFT_BRIDGE_OBJC\n\nimport Foundation\n\nextension Handle: StatementInterfaceForObjc {}\n\nextension Handle: InsertChainCallInterfaceForObjc {}\nextension Handle: SelectChainCallInterfaceForObjc {}\n\nextension Handle: InsertInterfaceForObjc {}\nextension Handle: UpdateInterfaceForObjc {}\nextension Handle: SelectInterfaceForObjc {}\n\n#endif\n"
  },
  {
    "path": "src/swift/core/base/Handle.swift",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport Foundation\n#if SWIFT_PACKAGE\nimport WCDB_Private\n#elseif WCDB_SWIFT_TARGET\nimport WCDBSwift.Private\n#else\nimport WCDB.Private\n#endif\n\npublic final class Handle {\n    private let recyclableHandle: RecyclableCPPHandle\n    private lazy var recycleMainStatement = {\n        ObjectBridge.createRecyclableCPPObject(WCDBHandleGetMainStatement(self.cppHandle))\n    }()\n\n    internal let cppHandle: CPPHandle\n\n    internal let database: Database\n\n    internal init(withCPPHandle cppHandle: CPPHandle, database: Database) {\n        self.recyclableHandle = ObjectBridge.createRecyclableCPPObject(cppHandle)\n        self.cppHandle = cppHandle\n        self.database = database\n    }\n\n    internal func getError() -> WCDBError {\n        let cppError = WCDBHandleGetError(cppHandle)\n        return ErrorBridge.getErrorFrom(cppError: cppError)\n    }\n\n    /// Execute a statement directly.\n    ///\n    /// - Parameter statement: the statement to execute.\n    /// - Throws: `Error`\n    public func exec(_ statement: Statement) throws {\n        let executed = withExtendedLifetime(statement) {\n            WCDBHandleExecute(cppHandle, $0.rawCPPObj)\n        }\n        if !executed {\n            let cppError = WCDBHandleGetError(cppHandle)\n            throw ErrorBridge.getErrorFrom(cppError: cppError)\n        }\n    }\n\n    /// Use `sqlite3_prepare` internally to prepare a new statement,\n    /// and wrap the `sqlite3_stmt` generated by `sqlite3_prepare` into `PreparedStatement` to return.\n    ///\n    /// If the statement has been prepared by this method before, and you have not used `-[WCTHandle finalizeAllStatements]` to finalize it,\n    /// then you can use this method to regain the previously generated `sqlite3_stmt`.\n    ///\n    /// This method is designed for the situation where you need to use multiple statements at the same time to do complex database operations.\n    /// You can prepare a new statement without finalizing the previous statements, so that you can save the time of analyzing SQL syntax.\n    ///\n    /// If you only need to use one statement, or you no longer need to use the previous statements when you use a new statement,\n    /// it is recommended to use `exec(_:)` or `prepare(_:)`.\n    ///\n    /// - Parameter statement: the statement to prepare.\n    /// - Throws: `Error`\n    public func getOrCreatePreparedStatement(with statement: Statement) throws -> PreparedStatement {\n        let cppHandleStatement = withExtendedLifetime(statement) { WCDBHandleGetOrCreatePreparedStatement(cppHandle, $0.rawCPPObj)\n        }\n        let preparedStatement = PreparedStatement(with: cppHandleStatement)\n        if !WCDBHandleStatementCheckPrepared(cppHandleStatement) {\n            throw getError()\n        }\n        return preparedStatement\n    }\n\n    /// Use `sqlite3_finalize` to finalize all `sqlite3_stmt` generate by current handle.\n    public func finalizeAllStatement() {\n        WCDBHandleFinalizeStatements(cppHandle)\n    }\n\n    /// The wrapper of `sqlite3_changes`.\n    public var changes: Int {\n        return Int(WCDBHandleGetChange(cppHandle))\n    }\n\n    /// The wrapper of `sqlite3_total_changes`.\n    public var totalChanges: Int {\n        return Int(WCDBHandleGetTotalChange(cppHandle))\n    }\n\n    /// The wrapper of `sqlite3_stmt_readonly`.\n    public var lastInsertedRowID: Int64 {\n        return WCDBHandleGetLastInsertedRowID(cppHandle)\n    }\n\n    public final class CancellatiionSignal: @unchecked Sendable {\n        private let m_signal: Recyclable<CPPCancellationSignal>\n        public init() {\n            m_signal = ObjectBridge.createRecyclableCPPObject(WCDBCancellationSignalCreate())\n        }\n\n        /// Cancel all operations of the attached handle.\n        public func cancel() {\n            WCDBCancellationSignalCancel(m_signal.raw)\n        }\n\n        internal func getInnerSignal() -> CPPCancellationSignal {\n            return m_signal.raw\n        }\n    }\n\n    /// The wrapper of `sqlite3_progress_handler`.\n    ///\n    /// You can asynchronously cancel all operations on the current handle through `CancellationSignal`.\n    ///\n    ///     let signal = CancellatiionSignal()\n    ///     DispatchQueue(label: \"test\").async {\n    ///         let handle = database.getHandle()\n    ///         handle.attach(cancellationSignal: signal)\n    ///\n    ///         // Do some time-consuming database operations.\n    ///\n    ///         handle.detachCancellationSignal()\n    ///     }\n    ///     signal.cancel()\n    ///\n    /// Note that you can use `CancellationSignal` in multiple threads,\n    /// but you can only use the current handle in the thread that you got it.\n    public func attach(cancellationSignal: CancellatiionSignal) {\n        WCDBHandleAttachCancellationSignal(cppHandle, cancellationSignal.getInnerSignal())\n    }\n\n    /// Detach the attached `CancellationSignal`.\n    /// `CancellationSignal` can be automatically detached when the current handle deconstruct.\n    public func detachCancellationSignal() {\n        WCDBHandleDettachCancellationSignal(cppHandle)\n    }\n}\n\npublic protocol HandleRepresentable {\n\n    func getHandle(writeHint: Bool) throws -> Handle\n    func getDatabase() -> Database\n}\n\nextension Handle: HandleRepresentable {\n    public func getHandle(writeHint: Bool) throws -> Handle {\n        return self\n    }\n\n    public func getDatabase() -> Database {\n        return database\n    }\n}\n\nextension Handle: RawStatementmentRepresentable {\n    public func finalizeWhenError() -> Bool {\n        return true\n    }\n\n    public func getRawStatement() -> CPPHandleStatement {\n        return recycleMainStatement.raw\n    }\n\n    /// The wrapper of `sqlite3_prepare`\n    ///\n    /// - Throws: `Error`\n    public func prepare(_ statement: Statement) throws {\n        let succeed = withExtendedLifetime(statement) {\n            WCDBHandleStatementPrepare(getRawStatement(), $0.rawCPPObj)\n        }\n        if !succeed {\n            let cppError = WCDBHandleStatementGetError(getRawStatement())\n            throw ErrorBridge.getErrorFrom(cppError: cppError)\n        }\n    }\n\n    /// Check if current statement is prepared\n    public var isPrepared: Bool {\n        WCDBHandleStatementCheckPrepared(getRawStatement())\n    }\n}\n\nextension Handle: StatementInterface {}\n\nextension Handle: InsertChainCallInterface {}\nextension Handle: UpdateChainCallInterface {}\nextension Handle: DeleteChainCallInterface {}\nextension Handle: RowSelectChainCallInterface {}\nextension Handle: SelectChainCallInterface {}\nextension Handle: MultiSelectChainCallInterface {}\n\nextension Handle: InsertInterface {}\nextension Handle: UpdateInterface {}\nextension Handle: DeleteInterface {}\nextension Handle: RowSelectInterface {}\nextension Handle: SelectInterface {}\nextension Handle: StatementSelectInterface {}\nextension Handle: TableInterface {}\nextension Handle: TransactionInterface {}\n"
  },
  {
    "path": "src/swift/core/base/HandleStatement+WCTTableCoding.swift",
    "content": "//\n// Created by qiuwenchen on 2022/11/13.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#if WCDB_SWIFT_BRIDGE_OBJC\n\nimport Foundation\n#if SWIFT_PACKAGE\nimport WCDB_Private\n#elseif WCDB_SWIFT_TARGET\nimport WCDBSwift.Private\n#else\nimport WCDB.Private\n#endif\n\nextension PreparedStatement: StatementInterfaceForObjc {}\n\n#endif\n"
  },
  {
    "path": "src/swift/core/base/PreparedStatement.swift",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport Foundation\n#if SWIFT_PACKAGE\nimport WCDB_Private\n#elseif WCDB_SWIFT_TARGET\nimport WCDBSwift.Private\n#else\nimport WCDB.Private\n#endif\npublic final class PreparedStatement {\n    internal let recyclableStmt: RecyclableCPPHandleStatement\n\n    internal init(with stmt: CPPHandleStatement) {\n        self.recyclableStmt = ObjectBridge.createRecyclableCPPObject(stmt)\n    }\n}\n\npublic protocol RawStatementmentRepresentable {\n    func getRawStatement() -> CPPHandleStatement\n    func finalizeWhenError() -> Bool\n}\n\nextension PreparedStatement: RawStatementmentRepresentable {\n    public func getRawStatement() -> CPPHandleStatement {\n        return self.recyclableStmt.raw\n    }\n    public func finalizeWhenError() -> Bool {\n        return false\n    }\n}\n\nextension PreparedStatement: StatementInterface {}\n"
  },
  {
    "path": "src/swift/core/base/Table+WCTTableCoding.swift",
    "content": "//\n// Created by qiuwenchen on 2022/11/13.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#if WCDB_SWIFT_BRIDGE_OBJC\n\nimport Foundation\n#if SWIFT_PACKAGE\nimport WCDB_Private\n#elseif WCDB_SWIFT_TARGET\nimport WCDBSwift.Private\n#else\nimport WCDB.Private\n#endif\n\n/// Convenient table interface\nextension Table {\n\n    convenience init(withDatabase database: Database, named name: String, of type: Object.Type = Object.self) where Object: WCTTableCoding {\n        self.init(withDatabase: database, named: name)\n    }\n}\n\ninternal extension Table {\n\n    func internalInsert(_ objects: [Object], on propertyConvertibleList: [PropertyConvertible]? = nil, onConflict action: ConflictAction? = nil) throws where Object: WCTTableCoding {\n        let insert = Insert(with: try self.database.getHandle(writeHint: true), named: self.name, on: propertyConvertibleList, onConflict: action)\n        return try insert.execute(with: objects)\n    }\n\n    func internalUpdate(on propertyConvertibleList: [PropertyConvertible],\n                        with object: Object,\n                        where condition: Condition? = nil,\n                        orderBy orderList: [OrderBy]? = nil,\n                        limit: Limit? = nil,\n                        offset: Offset? = nil) throws where Object: WCTTableCoding {\n        let update = Update(with: try self.database.getHandle(writeHint: true), on: propertyConvertibleList, andTable: self.name)\n        if condition != nil {\n            update.where(condition!)\n        }\n        if orderList != nil {\n            update.order(by: orderList!)\n        }\n        if limit != nil {\n            if offset != nil {\n                update.limit(limit!, offset: offset!)\n            } else {\n                update.limit(limit!)\n            }\n        }\n        return try update.execute(with: object)\n    }\n\n    func internalGetObjects(on propertyConvertibleList: [PropertyConvertible],\n                           where condition: Condition? = nil,\n                           orderBy orderList: [OrderBy]? = nil,\n                           limit: Limit? = nil,\n                           offset: Offset? = nil) throws -> [Object] where Object: WCTTableCoding {\n        let select = Select(with: try self.database.getHandle(writeHint: false),\n                            on: propertyConvertibleList.isEmpty ? Object.allProperties() : propertyConvertibleList,\n                            table: self.name,\n                            isDistinct: false)\n        if condition != nil {\n            select.where(condition!)\n        }\n        if orderList != nil {\n            select.order(by: orderList!)\n        }\n        if limit != nil {\n            if offset != nil {\n                select.limit(limit!, offset: offset!)\n            } else {\n                select.limit(limit!)\n            }\n        }\n        return try select.allObjects()\n    }\n}\n\nextension Table: InsertTableInterfaceForObjc where Object: WCTTableCoding {\n\n    /// Execute inserting with `WCTTableCoding` object on specific(or all) properties\n    ///\n    /// Note that it will run embedded transaction while objects.count>1.\n    /// The embedded transaction means that it will run a transaction if it's not in other transaction,\n    /// otherwise it will be executed within the existing transaction.\n    ///\n    /// - Parameters:\n    ///   - objects: Table encodable object\n    ///   - propertyConvertibleList: `Property` or `CodingTableKey` list\n    /// - Throws: `Error`\n    public func insert(_ objects: [Object], on propertyConvertibleList: [PropertyConvertible]? = nil) throws where Object: WCTTableCoding {\n        try internalInsert(objects, on: propertyConvertibleList)\n    }\n\n    /// Execute inserting or replacing with `WCTTableCoding` object on specific(or all) properties.\n    /// It will replace the original row while they have same primary key or row id.\n    ///\n    /// Note that it will run embedded transaction while objects.count>1.\n    /// The embedded transaction means that it will run a transaction if it's not in other transaction,\n    /// otherwise it will be executed within the existing transaction.\n    ///\n    /// - Parameters:\n    ///   - objects: Table encodable object\n    ///   - propertyConvertibleList: `Property` or `CodingTableKey` list\n    /// - Throws: `Error`\n    public func insertOrReplace(_ objects: [Object], on propertyConvertibleList: [PropertyConvertible]? = nil) throws where Object: WCTTableCoding {\n        try internalInsert(objects, on: propertyConvertibleList, onConflict: .Replace)\n    }\n\n    /// Execute inserting or ignoring with `WCTTableCoding` object on specific(or all) properties.\n    /// It will ignore the object while there already exists the same primary key or row id in current table.\n    ///\n    /// Note that it will run embedded transaction while objects.count>1.\n    /// The embedded transaction means that it will run a transaction if it's not in other transaction,\n    /// otherwise it will be executed within the existing transaction.\n    ///\n    /// - Parameters:\n    ///   - objects: Table encodable object\n    ///   - propertyConvertibleList: `Property` or `CodingTableKey` list\n    /// - Throws: `Error`\n    public func insertOrIgnore(_ objects: [Object], on propertyConvertibleList: [PropertyConvertible]? = nil) throws where Object: WCTTableCoding {\n        try internalInsert(objects, on: propertyConvertibleList, onConflict: .Ignore)\n    }\n\n    /// Execute inserting with `WCTTableCoding` object on specific(or all) properties\n    ///\n    /// Note that it will run embedded transaction while objects.count>1.\n    /// The embedded transaction means that it will run a transaction if it's not in other transaction,\n    /// otherwise it will be executed within the existing transaction.\n    ///\n    /// - Parameters:\n    ///   - objects: Table encodable object\n    ///   - propertyConvertibleList: `Property` or `CodingTableKey` list\n    /// - Throws: `Error`\n    public func insert(_ objects: Object..., on propertyConvertibleList: [PropertyConvertible]? = nil) throws where Object: WCTTableCoding {\n        try internalInsert(objects, on: propertyConvertibleList)\n    }\n\n    /// Execute inserting or replacing with `WCTTableCoding` object on specific(or all) properties.\n    /// It will replace the original row while they have same primary key or row id.\n    ///\n    /// Note that it will run embedded transaction while objects.count>1.\n    /// The embedded transaction means that it will run a transaction if it's not in other transaction,\n    /// otherwise it will be executed within the existing transaction.\n    ///\n    /// - Parameters:\n    ///   - objects: Table encodable object\n    ///   - propertyConvertibleList: `Property` or `CodingTableKey` list\n    /// - Throws: `Error`\n    public func insertOrReplace(_ objects: Object..., on propertyConvertibleList: [PropertyConvertible]? = nil) throws where Object: WCTTableCoding {\n        try internalInsert(objects, on: propertyConvertibleList, onConflict: .Replace)\n    }\n\n    /// Execute inserting or ignoring with `WCTTableCoding` object on specific(or all) properties.\n    /// It will ignore the object while there already exists the same primary key or row id in current table.\n    ///\n    /// Note that it will run embedded transaction while objects.count>1.\n    /// The embedded transaction means that it will run a transaction if it's not in other transaction,\n    /// otherwise it will be executed within the existing transaction.\n    ///\n    /// - Parameters:\n    ///   - objects: Table encodable object\n    ///   - propertyConvertibleList: `Property` or `CodingTableKey` list\n    /// - Throws: `Error`\n    public func insertOrIgnore(_ objects: Object..., on propertyConvertibleList: [PropertyConvertible]? = nil) throws where Object: WCTTableCoding {\n        try internalInsert(objects, on: propertyConvertibleList, onConflict: .Ignore)\n    }\n}\n\nextension Table: UpdateTableInterfaceForObjc where Object: WCTTableCoding {\n\n    /// Execute updating with `WCTTableCoding` object on specific(or all) properties.\n    ///\n    /// - Parameters:\n    ///   - propertyConvertibleList: `Property` or `CodingTableKey` list\n    ///   - object: Table encodable object\n    ///   - condition: Expression convertible\n    ///   - orderList: Order convertible list\n    ///   - limit: Expression convertible\n    ///   - offset: Expression convertible\n    /// - Throws: `Error`\n    public func update(on propertyConvertibleList: [PropertyConvertible],\n                       with object: Object,\n                       where condition: Condition? = nil,\n                       orderBy orderList: [OrderBy]? = nil,\n                       limit: Limit? = nil,\n                       offset: Offset? = nil) throws {\n        return try internalUpdate(on: propertyConvertibleList, with: object, where: condition, orderBy: orderList, limit: limit, offset: offset)\n    }\n\n    /// Execute updating with `WCTTableCoding` object on specific(or all) properties.\n    ///\n    /// - Parameters:\n    ///   - propertyConvertibleList: `Property` or `CodingTableKey` list\n    ///   - object: Table encodable object\n    ///   - condition: Expression convertible\n    ///   - orderList: Order convertible list\n    ///   - limit: Expression convertible\n    ///   - offset: Expression convertible\n    /// - Throws: `Error`\n    public func update(on propertyConvertibleList: PropertyConvertible...,\n                       with object: Object,\n                       where condition: Condition? = nil,\n                       orderBy orderList: [OrderBy]? = nil,\n                       limit: Limit? = nil,\n                       offset: Offset? = nil) throws {\n        return try internalUpdate(on: propertyConvertibleList, with: object, where: condition, orderBy: orderList, limit: limit, offset: offset)\n    }\n\n    /// Execute updating with row on specific(or all) properties.\n    ///\n    /// - Parameters:\n    ///   - propertyConvertibleList: `Property` or `CodingTableKey` list\n    ///   - object: Table encodable object\n    ///   - condition: Expression convertible\n    ///   - orderList: Order convertible list\n    ///   - limit: Expression convertible\n    ///   - offset: Expression convertible\n    /// - Throws: `Error`\n    public func update(on propertyConvertibleList: PropertyConvertible...,\n                       with row: [ColumnEncodable],\n                       where condition: Condition? = nil,\n                       orderBy orderList: [OrderBy]? = nil,\n                       limit: Limit? = nil,\n                       offset: Offset? = nil) throws {\n        return try update(on: propertyConvertibleList,\n                          with: row,\n                          where: condition,\n                          orderBy: orderList,\n                          limit: limit,\n                          offset: offset)\n    }\n\n    /// Execute updating with row on specific(or all) properties.\n    ///\n    /// - Parameters:\n    ///   - propertyConvertibleList: `Property` or `CodingTableKey` list\n    ///   - object: Table encodable object\n    ///   - condition: Expression convertible\n    ///   - orderList: Order convertible list\n    ///   - limit: Expression convertible\n    ///   - offset: Expression convertible\n    /// - Throws: `Error`\n    public func update(on propertyConvertibleList: [PropertyConvertible],\n                       with row: [ColumnEncodable],\n                       where condition: Condition? = nil,\n                       orderBy orderList: [OrderBy]? = nil,\n                       limit: Limit? = nil,\n                       offset: Offset? = nil) throws {\n        let update = Update(with: try self.database.getHandle(writeHint: true), on: propertyConvertibleList, andTable: self.name)\n        if condition != nil {\n            update.where(condition!)\n        }\n        if orderList != nil {\n            update.order(by: orderList!)\n        }\n        if limit != nil {\n            if offset != nil {\n                update.limit(limit!, offset: offset!)\n            } else {\n                update.limit(limit!)\n            }\n        }\n        return try update.execute(with: row)\n    }\n}\n\nextension Table: SelectTableInterfaceForObjc where Object: WCTTableCoding {\n\n    /// Get objects on specific(or all) properties\n    ///\n    /// - Parameters:\n    ///   - propertyConvertibleList: `Property` or `CodingTableKey` list\n    ///   - condition: Expression convertible\n    ///   - orderList: Order convertible list\n    ///   - limit: Expression convertible\n    ///   - offset: Expression convertible\n    /// - Returns: Table decodable objects\n    /// - Throws: `Error`\n    public func getObjects(on propertyConvertibleList: [PropertyConvertible],\n                           where condition: Condition? = nil,\n                           orderBy orderList: [OrderBy]? = nil,\n                           limit: Limit? = nil,\n                           offset: Offset? = nil) throws -> [Object] {\n        return try internalGetObjects(on: propertyConvertibleList, where: condition, orderBy: orderList, limit: limit, offset: offset)\n    }\n\n    /// Get objects on specific(or all) properties\n    ///\n    /// - Parameters:\n    ///   - propertyConvertibleList: `Property` or `CodingTableKey` list\n    ///   - condition: Expression convertible\n    ///   - orderList: Order convertible list\n    ///   - limit: Expression convertible\n    ///   - offset: Expression convertible\n    /// - Returns: Table decodable objects\n    /// - Throws: `Error`\n    public func getObjects(on propertyConvertibleList: PropertyConvertible...,\n                           where condition: Condition? = nil,\n                           orderBy orderList: [OrderBy]? = nil,\n                           limit: Limit? = nil,\n                           offset: Offset? = nil) throws -> [Object] {\n        return try internalGetObjects(on: propertyConvertibleList, where: condition, orderBy: orderList, limit: limit, offset: offset)\n    }\n\n    /// Get object on specific(or all) properties\n    ///\n    /// - Parameters:\n    ///   - propertyConvertibleList: `Property` or `CodingTableKey` list\n    ///   - condition: Expression convertible\n    ///   - orderList: Order convertible list\n    ///   - offset: Expression convertible\n    /// - Returns: Table decodable objects\n    /// - Throws: `Error`\n    public func getObject(on propertyConvertibleList: [PropertyConvertible],\n                          where condition: Condition? = nil,\n                          orderBy orderList: [OrderBy]? = nil,\n                          offset: Offset? = nil) throws -> Object? {\n        return try internalGetObjects(on: propertyConvertibleList,\n                              where: condition,\n                              orderBy: orderList,\n                              limit: 1,\n                              offset: offset).first\n    }\n\n    /// Get object on specific(or all) properties\n    ///\n    /// - Parameters:\n    ///   - propertyConvertibleList: `Property` or `CodingTableKey` list\n    ///   - condition: Expression convertible\n    ///   - orderList: Order convertible list\n    ///   - offset: Expression convertible\n    /// - Returns: Table decodable objects\n    /// - Throws: `Error`\n    public func getObject(on propertyConvertibleList: PropertyConvertible...,\n                          where condition: Condition? = nil,\n                          orderBy orderList: [OrderBy]? = nil,\n                          offset: Offset? = nil) throws -> Object? {\n        return try getObjects(on: propertyConvertibleList.isEmpty ? Object.allProperties() : propertyConvertibleList,\n                              where: condition,\n                              orderBy: orderList,\n                              limit: 1,\n                              offset: offset).first\n    }\n}\n\nextension Table: TableInsertChainCallInterfaceForObjc {\n    public func prepareInsert<Root: WCTTableCoding>(of cls: Root.Type) throws -> Insert {\n        return Insert(with: try self.database.getHandle(writeHint: true), named: name, on: cls.allProperties())\n    }\n\n    public func prepareInsertOrReplace<Root: WCTTableCoding>(of cls: Root.Type) throws -> Insert {\n            return Insert(with: try self.database.getHandle(writeHint: true), named: name, on: cls.allProperties(), onConflict: .Replace)\n    }\n\n    public func prepareInsertOrIgnore<Root: WCTTableCoding>(of cls: Root.Type) throws -> Insert {\n            return Insert(with: try self.database.getHandle(writeHint: true), named: name, on: cls.allProperties(), onConflict: .Ignore)\n    }\n}\n\nextension Table: TableSelectChainCallInterfaceForObjc {\n    public func prepareSelect<Root: WCTTableCoding>(of cls: Root.Type,\n                                                    isDistinct: Bool = false) throws -> Select {\n        return Select(with: try self.database.getHandle(writeHint: false), on: cls.allProperties(), table: name, isDistinct: isDistinct)\n    }\n}\n\n#endif\n"
  },
  {
    "path": "src/swift/core/base/Table.swift",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport Foundation\n#if SWIFT_PACKAGE\nimport WCDB_Private\n#elseif WCDB_SWIFT_TARGET\nimport WCDBSwift.Private\n#else\nimport WCDB.Private\n#endif\n\n/// Convenient table interface\npublic final class Table<Object: Any>: @unchecked Sendable {\n    internal let database: Database\n    public typealias Object = Object\n\n    /// Table name\n    public let name: String\n\n    /// Table related type\n    public var rootType: Object.Type {\n        return Object.self\n    }\n\n    internal init(withDatabase database: Database, named name: String) {\n        self.database = database\n        self.name = name\n    }\n\n    convenience init(withDatabase database: Database, named name: String, of type: Object.Type = Object.self) where Object: TableCodable {\n        self.init(withDatabase: database, named: name)\n    }\n\n    convenience init(withDatabase database: Database, named name: String, of type: Object.Type = Object.self) {\n        fatalError(\"\\(Object.self) must conform to TableCodable or WCTTableCoding\")\n    }\n}\n\ninternal extension Table {\n\n    func internalInsert(_ objects: [Object], on propertyConvertibleList: [PropertyConvertible]? = nil, onConlict action: ConflictAction? = nil) throws where Object: TableEncodable {\n        let insert = Insert(with: try self.database.getHandle(writeHint: true), named: self.name, on: propertyConvertibleList, onConflict: action)\n        return try insert.execute(with: objects)\n    }\n\n    func internalUpdate(on propertyConvertibleList: [PropertyConvertible],\n                        with object: Object,\n                        where condition: Condition? = nil,\n                        orderBy orderList: [OrderBy]? = nil,\n                        limit: Limit? = nil,\n                        offset: Offset? = nil) throws where Object: TableEncodable {\n        let update = Update(with: try self.database.getHandle(writeHint: true), on: propertyConvertibleList, andTable: self.name)\n        if condition != nil {\n            update.where(condition!)\n        }\n        if orderList != nil {\n            update.order(by: orderList!)\n        }\n        if limit != nil {\n            if offset != nil {\n                update.limit(limit!, offset: offset!)\n            } else {\n                update.limit(limit!)\n            }\n        }\n        return try update.execute(with: object)\n    }\n\n    func internalGetObjects(on propertyConvertibleList: [PropertyConvertible],\n                           where condition: Condition? = nil,\n                           orderBy orderList: [OrderBy]? = nil,\n                           limit: Limit? = nil,\n                           offset: Offset? = nil) throws -> [Object] where Object: TableDecodable {\n        let select = Select(with: try self.database.getHandle(writeHint: false),\n                            on: propertyConvertibleList.isEmpty ? Object.Properties.all : propertyConvertibleList,\n                            table: self.name,\n                            isDistinct: false)\n        if condition != nil {\n            select.where(condition!)\n        }\n        if orderList != nil {\n            select.order(by: orderList!)\n        }\n        if limit != nil {\n            if offset != nil {\n                select.limit(limit!, offset: offset!)\n            } else {\n                select.limit(limit!)\n            }\n        }\n        return try select.allObjects()\n    }\n}\n\nextension Table: InsertTableInterface where Object: TableCodable {\n\n    /// Execute inserting with `TableCodable` object on specific(or all) properties\n    ///\n    /// Note that it will run embedded transaction while objects.count>1.  \n    /// The embedded transaction means that it will run a transaction if it's not in other transaction,\n    /// otherwise it will be executed within the existing transaction.\n    ///\n    /// - Parameters:\n    ///   - objects: Table encodable object\n    ///   - propertyConvertibleList: `Property` or `CodingTableKey` list\n    /// - Throws: `Error`\n    public func insert(_ objects: [Object], on propertyConvertibleList: [PropertyConvertible]? = nil) throws {\n        try internalInsert(objects, on: propertyConvertibleList)\n    }\n\n    /// Execute inserting or replacing with `TableCodable` object on specific(or all) properties.  \n    /// It will replace the original row while they have same primary key or row id.\n    ///\n    /// Note that it will run embedded transaction while objects.count>1.  \n    /// The embedded transaction means that it will run a transaction if it's not in other transaction,\n    /// otherwise it will be executed within the existing transaction.\n    ///\n    /// - Parameters:\n    ///   - objects: Table encodable object\n    ///   - propertyConvertibleList: `Property` or `CodingTableKey` list\n    /// - Throws: `Error`\n    public func insertOrReplace(_ objects: [Object], on propertyConvertibleList: [PropertyConvertible]? = nil) throws {\n        try internalInsert(objects, on: propertyConvertibleList, onConlict: .Replace)\n    }\n\n    /// Execute inserting or ignoring with `TableEncodable` object on specific(or all) properties.\n    /// It will ignore the object while there already exists the same primary key or row id in current table.\n    ///\n    /// Note that it will run embedded transaction while objects.count>1.\n    /// The embedded transaction means that it will run a transaction if it's not in other transaction,\n    /// otherwise it will be executed within the existing transaction.\n    ///\n    /// - Parameters:\n    ///   - objects: Table encodable object\n    ///   - propertyConvertibleList: `Property` or `CodingTableKey` list\n    /// - Throws: `Error`\n    public func insertOrIgnore(_ objects: [Object], on propertyConvertibleList: [PropertyConvertible]? = nil) throws {\n        try internalInsert(objects, on: propertyConvertibleList, onConlict: .Ignore)\n    }\n\n    /// Execute inserting with `TableCodable` object on specific(or all) properties\n    ///\n    /// Note that it will run embedded transaction while objects.count>1.  \n    /// The embedded transaction means that it will run a transaction if it's not in other transaction,\n    /// otherwise it will be executed within the existing transaction.\n    ///\n    /// - Parameters:\n    ///   - objects: Table encodable object\n    ///   - propertyConvertibleList: `Property` or `CodingTableKey` list\n    /// - Throws: `Error`\n    public func insert(_ objects: Object..., on propertyConvertibleList: [PropertyConvertible]? = nil) throws {\n        try internalInsert(objects, on: propertyConvertibleList)\n    }\n\n    /// Execute inserting or replacing with `TableCodable` object on specific(or all) properties.  \n    /// It will replace the original row while they have same primary key or row id.\n    ///\n    /// Note that it will run embedded transaction while objects.count>1.  \n    /// The embedded transaction means that it will run a transaction if it's not in other transaction,\n    /// otherwise it will be executed within the existing transaction.\n    ///\n    /// - Parameters:\n    ///   - objects: Table encodable object\n    ///   - propertyConvertibleList: `Property` or `CodingTableKey` list\n    /// - Throws: `Error`\n    public func insertOrReplace(_ objects: Object..., on propertyConvertibleList: [PropertyConvertible]? = nil) throws {\n        try internalInsert(objects, on: propertyConvertibleList, onConlict: .Replace)\n    }\n\n    /// Execute inserting or ignoring with `TableEncodable` object on specific(or all) properties.\n    /// It will ignore the object while there already exists the same primary key or row id in current table.\n    ///\n    /// Note that it will run embedded transaction while objects.count>1.\n    /// The embedded transaction means that it will run a transaction if it's not in other transaction,\n    /// otherwise it will be executed within the existing transaction.\n    ///\n    /// - Parameters:\n    ///   - objects: Table encodable object\n    ///   - propertyConvertibleList: `Property` or `CodingTableKey` list\n    /// - Throws: `Error`\n    public func insertOrIgnore(_ objects: Object..., on propertyConvertibleList: [PropertyConvertible]? = nil) throws {\n        try internalInsert(objects, on: propertyConvertibleList, onConlict: .Ignore)\n    }\n}\n\nextension Table: UpdateTableInterface where Object: TableEncodable {\n\n    /// Execute updating with `TableCodable` object on specific(or all) properties. \n    ///\n    /// - Parameters:\n    ///   - propertyConvertibleList: `Property` or `CodingTableKey` list\n    ///   - object: Table encodable object\n    ///   - condition: Expression convertible\n    ///   - orderList: Order convertible list\n    ///   - limit: Expression convertible\n    ///   - offset: Expression convertible\n    /// - Throws: `Error`\n    public func update(on propertyConvertibleList: [PropertyConvertible],\n                       with object: Object,\n                       where condition: Condition? = nil,\n                       orderBy orderList: [OrderBy]? = nil,\n                       limit: Limit? = nil,\n                       offset: Offset? = nil) throws {\n        return try internalUpdate(on: propertyConvertibleList, with: object, where: condition, orderBy: orderList, limit: limit, offset: offset)\n    }\n\n    /// Execute updating with `TableCodable` object on specific(or all) properties. \n    ///\n    /// - Parameters:\n    ///   - propertyConvertibleList: `Property` or `CodingTableKey` list\n    ///   - object: Table encodable object\n    ///   - condition: Expression convertible\n    ///   - orderList: Order convertible list\n    ///   - limit: Expression convertible\n    ///   - offset: Expression convertible\n    /// - Throws: `Error`\n    public func update(on propertyConvertibleList: PropertyConvertible...,\n                       with object: Object,\n                       where condition: Condition? = nil,\n                       orderBy orderList: [OrderBy]? = nil,\n                       limit: Limit? = nil,\n                       offset: Offset? = nil) throws {\n        return try internalUpdate(on: propertyConvertibleList, with: object, where: condition, orderBy: orderList, limit: limit, offset: offset)\n    }\n\n    /// Execute updating with row on specific(or all) properties. \n    ///\n    /// - Parameters:\n    ///   - propertyConvertibleList: `Property` or `CodingTableKey` list\n    ///   - row: a row of ColumnEncodable value\n    ///   - condition: Expression convertible\n    ///   - orderList: Order convertible list\n    ///   - limit: Expression convertible\n    ///   - offset: Expression convertible\n    /// - Throws: `Error`\n    public func update(on propertyConvertibleList: PropertyConvertible...,\n                       with row: ColumnEncodable?...,\n                       where condition: Condition? = nil,\n                       orderBy orderList: [OrderBy]? = nil,\n                       limit: Limit? = nil,\n                       offset: Offset? = nil) throws {\n        return try update(on: propertyConvertibleList,\n                          with: row,\n                          where: condition,\n                          orderBy: orderList,\n                          limit: limit,\n                          offset: offset)\n    }\n\n    /// Execute updating with row on specific(or all) properties.\n    ///\n    /// - Parameters:\n    ///   - propertyConvertibleList: `Property` or `CodingTableKey` list\n    ///   - row: a row of ColumnEncodable value\n    ///   - condition: Expression convertible\n    ///   - orderList: Order convertible list\n    ///   - limit: Expression convertible\n    ///   - offset: Expression convertible\n    /// - Throws: `Error`\n    public func update(on propertyConvertibleList: PropertyConvertible...,\n                       with row: [ColumnEncodable?],\n                       where condition: Condition? = nil,\n                       orderBy orderList: [OrderBy]? = nil,\n                       limit: Limit? = nil,\n                       offset: Offset? = nil) throws {\n        return try update(on: propertyConvertibleList,\n                          with: row,\n                          where: condition,\n                          orderBy: orderList,\n                          limit: limit,\n                          offset: offset)\n    }\n\n    /// Execute updating with row on specific(or all) properties.\n    ///\n    /// - Parameters:\n    ///   - propertyConvertibleList: `Property` or `CodingTableKey` list\n    ///   - row: a row of ColumnEncodable value\n    ///   - condition: Expression convertible\n    ///   - orderList: Order convertible list\n    ///   - limit: Expression convertible\n    ///   - offset: Expression convertible\n    /// - Throws: `Error`\n    public func update(on propertyConvertibleList: [PropertyConvertible],\n                       with row: ColumnEncodable?...,\n                       where condition: Condition? = nil,\n                       orderBy orderList: [OrderBy]? = nil,\n                       limit: Limit? = nil,\n                       offset: Offset? = nil) throws {\n        return try update(on: propertyConvertibleList,\n                          with: row,\n                          where: condition,\n                          orderBy: orderList,\n                          limit: limit,\n                          offset: offset)\n    }\n\n    /// Execute updating with row on specific(or all) properties. \n    ///\n    /// - Parameters:\n    ///   - propertyConvertibleList: `Property` or `CodingTableKey` list\n    ///   - row: a row of ColumnEncodable value\n    ///   - condition: Expression convertible\n    ///   - orderList: Order convertible list\n    ///   - limit: Expression convertible\n    ///   - offset: Expression convertible\n    /// - Throws: `Error`\n    public func update(on propertyConvertibleList: [PropertyConvertible],\n                       with row: [ColumnEncodable?],\n                       where condition: Condition? = nil,\n                       orderBy orderList: [OrderBy]? = nil,\n                       limit: Limit? = nil,\n                       offset: Offset? = nil) throws {\n        let update = Update(with: try self.database.getHandle(writeHint: true), on: propertyConvertibleList, andTable: self.name)\n        if condition != nil {\n            update.where(condition!)\n        }\n        if orderList != nil {\n            update.order(by: orderList!)\n        }\n        if limit != nil {\n            if offset != nil {\n                update.limit(limit!, offset: offset!)\n            } else {\n                update.limit(limit!)\n            }\n        }\n        return try update.execute(with: row)\n    }\n}\n\nextension Table: DeleteTableInterface {\n\n    /// Execute deleting \n    ///\n    /// - Parameters:\n    ///   - condition: Expression convertible\n    ///   - orderList: Order convertible list\n    ///   - limit: Expression convertible\n    ///   - offset: Expression convertible\n    /// - Throws: `Error`\n    public func delete(where condition: Condition? = nil,\n                       orderBy orderList: [OrderBy]? = nil,\n                       limit: Limit? = nil,\n                       offset: Offset? = nil) throws {\n        let delete = Delete(with: try self.database.getHandle(writeHint: true), andTableName: self.name)\n        if condition != nil {\n            delete.where(condition!)\n        }\n        if orderList != nil {\n            delete.order(by: orderList!)\n        }\n        if limit != nil {\n            if offset != nil {\n                delete.limit(limit!, offset: offset!)\n            } else {\n                delete.limit(limit!)\n            }\n        }\n        return try delete.execute()\n    }\n}\n\nextension Table: SelectTableInterface where Object: TableDecodable {\n\n    /// Get objects on specific(or all) properties\n    ///\n    /// - Parameters:\n    ///   - propertyConvertibleList: `Property` or `CodingTableKey` list\n    ///   - condition: Expression convertible\n    ///   - orderList: Order convertible list\n    ///   - limit: Expression convertible\n    ///   - offset: Expression convertible\n    /// - Returns: Table decodable objects\n    /// - Throws: `Error`\n    public func getObjects(on propertyConvertibleList: [PropertyConvertible],\n                           where condition: Condition? = nil,\n                           orderBy orderList: [OrderBy]? = nil,\n                           limit: Limit? = nil,\n                           offset: Offset? = nil) throws -> [Object] {\n        return try internalGetObjects(on: propertyConvertibleList, where: condition, orderBy: orderList, limit: limit, offset: offset)\n    }\n\n    /// Get objects on specific(or all) properties\n    ///\n    /// - Parameters:\n    ///   - propertyConvertibleList: `Property` or `CodingTableKey` list\n    ///   - condition: Expression convertible\n    ///   - orderList: Order convertible list\n    ///   - limit: Expression convertible\n    ///   - offset: Expression convertible\n    /// - Returns: Table decodable objects\n    /// - Throws: `Error`\n    public func getObjects(on propertyConvertibleList: PropertyConvertible...,\n                           where condition: Condition? = nil,\n                           orderBy orderList: [OrderBy]? = nil,\n                           limit: Limit? = nil,\n                           offset: Offset? = nil) throws -> [Object] {\n        return try internalGetObjects(on: propertyConvertibleList, where: condition, orderBy: orderList, limit: limit, offset: offset)\n    }\n\n    /// Get object on specific(or all) properties\n    ///\n    /// - Parameters:\n    ///   - propertyConvertibleList: `Property` or `CodingTableKey` list\n    ///   - condition: Expression convertible\n    ///   - orderList: Order convertible list\n    ///   - offset: Expression convertible\n    /// - Returns: Table decodable objects\n    /// - Throws: `Error`\n    public func getObject(on propertyConvertibleList: [PropertyConvertible],\n                          where condition: Condition? = nil,\n                          orderBy orderList: [OrderBy]? = nil,\n                          offset: Offset? = nil) throws -> Object? {\n        return try internalGetObjects(on: propertyConvertibleList,\n                              where: condition,\n                              orderBy: orderList,\n                              limit: 1,\n                              offset: offset).first\n    }\n\n    /// Get object on specific(or all) properties\n    ///\n    /// - Parameters:\n    ///   - propertyConvertibleList: `Property` or `CodingTableKey` list\n    ///   - condition: Expression convertible\n    ///   - orderList: Order convertible list\n    ///   - offset: Expression convertible\n    /// - Returns: Table decodable objects\n    /// - Throws: `Error`\n    public func getObject(on propertyConvertibleList: PropertyConvertible...,\n                          where condition: Condition? = nil,\n                          orderBy orderList: [OrderBy]? = nil,\n                          offset: Offset? = nil) throws -> Object? {\n        return try getObjects(on: propertyConvertibleList.isEmpty ? Object.Properties.all : propertyConvertibleList,\n                              where: condition,\n                              orderBy: orderList,\n                              limit: 1,\n                              offset: offset).first\n    }\n}\n\nextension Table: RowSelectTableInterface {\n\n    /// Get rows by specific selecting\n    ///\n    /// - Parameters:\n    ///   - resultColumnConvertibleList: WINQ column result list\n    ///   - condition: Expression convertible\n    ///   - orderList: Order convertible list\n    ///   - limit: Expression convertible\n    ///   - offset: Expression convertible\n    /// - Returns: `MultiRowsValue`\n    /// - Throws: `Error`\n    public func getRows(on resultColumnConvertibleList: [ResultColumnConvertible],\n                        where condition: Condition? = nil,\n                        orderBy orderList: [OrderBy]? = nil,\n                        limit: Limit? = nil,\n                        offset: Offset? = nil) throws -> MultiRowsValue {\n        let rowSelect = RowSelect(with: try self.database.getHandle(writeHint: false),\n                                  results: resultColumnConvertibleList,\n                                  tables: [self.name],\n                                  isDistinct: false)\n        if condition != nil {\n            rowSelect.where(condition!)\n        }\n        if orderList != nil {\n            rowSelect.order(by: orderList!)\n        }\n        if limit != nil {\n            if offset != nil {\n                rowSelect.limit(limit!, offset: offset!)\n            } else {\n                rowSelect.limit(limit!)\n            }\n        }\n        return try rowSelect.allRows()\n    }\n\n    /// Get rows by specific selecting\n    ///\n    /// - Parameters:\n    ///   - resultColumnConvertibleList: WINQ column result list\n    ///   - condition: Expression convertible\n    ///   - orderList: Order convertible list\n    ///   - limit: Expression convertible\n    ///   - offset: Expression convertible\n    /// - Returns: `MultiRowsValue`\n    /// - Throws: `Error`\n    public func getRows(on resultColumnConvertibleList: ResultColumnConvertible...,\n                        where condition: Condition? = nil,\n                        orderBy orderList: [OrderBy]? = nil,\n                        limit: Limit? = nil,\n                        offset: Offset? = nil) throws -> MultiRowsValue {\n        return try getRows(on: resultColumnConvertibleList.isEmpty ? [Column.all()] : resultColumnConvertibleList,\n                           where: condition,\n                           orderBy: orderList,\n                           limit: limit,\n                           offset: offset)\n    }\n\n    /// Get row by specific selecting\n    ///\n    /// - Parameters:\n    ///   - resultColumnConvertibleList: WINQ column result list\n    ///   - condition: Expression convertible\n    ///   - orderList: Order convertible list\n    ///   - offset: Expression convertible\n    /// - Returns: `MultiRowsValue`\n    /// - Throws: `Error`\n    public func getRow(on resultColumnConvertibleList: ResultColumnConvertible...,\n                       where condition: Condition? = nil,\n                       orderBy orderList: [OrderBy]? = nil,\n                       offset: Offset? = nil) throws -> OneRowValue {\n        return try getRows(on: resultColumnConvertibleList.isEmpty ? [Column.all()] : resultColumnConvertibleList,\n                           where: condition,\n                           orderBy: orderList,\n                           limit: 1,\n                           offset: offset).first ?? []\n    }\n\n    /// Get row by specific selecting\n    ///\n    /// - Parameters:\n    ///   - resultColumnConvertibleList: WINQ column result list\n    ///   - condition: Expression convertible\n    ///   - orderList: Order convertible list\n    ///   - offset: Expression convertible\n    /// - Returns: `MultiRowsValue`\n    /// - Throws: `Error`\n    public func getRow(on resultColumnConvertibleList: [ResultColumnConvertible],\n                       where condition: Condition? = nil,\n                       orderBy orderList: [OrderBy]? = nil,\n                       offset: Offset? = nil) throws -> OneRowValue {\n        return try getRows(on: resultColumnConvertibleList,\n                           where: condition,\n                           orderBy: orderList,\n                           limit: 1,\n                           offset: offset).first ?? []\n    }\n\n    /// Get column by specific selecting\n    ///\n    /// - Parameters:\n    ///   - resultColumnConvertible: WINQ column result\n    ///   - condition: Expression convertible\n    ///   - orderList: Order convertible list\n    ///   - limit: Expression convertible\n    ///   - offset: Expression convertible\n    /// - Returns: `OneColumnValue`\n    /// - Throws: `Error`\n    public func getColumn(on result: ResultColumnConvertible,\n                          where condition: Condition? = nil,\n                          orderBy orderList: [OrderBy]? = nil,\n                          limit: Limit? = nil,\n                          offset: Offset? = nil) throws -> OneColumnValue {\n        let rowSelect = RowSelect(with: try self.database.getHandle(writeHint: false), results: [result], tables: [self.name], isDistinct: false)\n        if condition != nil {\n            rowSelect.where(condition!)\n        }\n        if orderList != nil {\n            rowSelect.order(by: orderList!)\n        }\n        if limit != nil {\n            if offset != nil {\n                rowSelect.limit(limit!, offset: offset!)\n            } else {\n                rowSelect.limit(limit!)\n            }\n        }\n        return try rowSelect.allValues()\n    }\n\n    /// Get distinct column by specific selecting\n    ///\n    /// - Parameters:\n    ///   - resultColumnConvertible: WINQ column result\n    ///   - condition: Expression convertible\n    ///   - orderList: Order convertible list\n    ///   - limit: Expression convertible\n    ///   - offset: Expression convertible\n    /// - Returns: `OneColumnValue`\n    /// - Throws: `Error`\n    public func getDistinctColumn(on result: ResultColumnConvertible,\n                                  where condition: Condition? = nil,\n                                  orderBy orderList: [OrderBy]? = nil,\n                                  limit: Limit? = nil,\n                                  offset: Offset? = nil) throws -> OneColumnValue {\n        let rowSelect = RowSelect(with: try self.database.getHandle(writeHint: false), results: [result], tables: [self.name], isDistinct: true)\n        if condition != nil {\n            rowSelect.where(condition!)\n        }\n        if orderList != nil {\n            rowSelect.order(by: orderList!)\n        }\n        if limit != nil {\n            if offset != nil {\n                rowSelect.limit(limit!, offset: offset!)\n            } else {\n                rowSelect.limit(limit!)\n            }\n        }\n        return try rowSelect.allValues()\n    }\n\n    /// Get value by specific selecting\n    ///\n    /// - Parameters:\n    ///   - resultColumnConvertible: WINQ column result\n    ///   - condition: Expression convertible\n    ///   - orderList: Order convertible list\n    ///   - offset: Expression convertible\n    /// - Returns: `Value`\n    /// - Throws: `Error`\n    public func getValue(on result: ResultColumnConvertible,\n                         where condition: Condition? = nil,\n                         orderBy orderList: [OrderBy]? = nil,\n                         limit: Limit? = nil,\n                         offset: Offset? = nil) throws -> Value {\n        return (try getRows(on: result,\n                            where: condition,\n                            orderBy: orderList,\n                            limit: 1,\n                            offset: offset).first?.first) ?? Value(nil)\n    }\n\n    /// Get distinct value by specific selecting\n    ///\n    /// - Parameters:\n    ///   - resultColumnConvertible: WINQ column result\n    ///   - condition: Expression convertible\n    ///   - orderList: Order convertible list\n    ///   - offset: Expression convertible\n    /// - Returns: `Value`\n    /// - Throws: `Error`\n    public func getDistinctValue(on result: ResultColumnConvertible,\n                                 where condition: Condition? = nil,\n                                 orderBy orderList: [OrderBy]? = nil,\n                                 limit: Limit? = nil,\n                                 offset: Offset? = nil) throws -> Value {\n        return (try getDistinctColumn(on: result).first) ?? Value(nil)\n    }\n}\n\nextension Table: TableInsertChainCallInterface {\n    public func prepareInsert<Root: TableEncodable>(of cls: Root.Type) throws -> Insert {\n        return Insert(with: try self.database.getHandle(writeHint: true), named: name, on: cls.Properties.all)\n    }\n\n    public func prepareInsertOrReplace<Root: TableEncodable>(\n        of cls: Root.Type) throws -> Insert {\n            return Insert(with: try self.database.getHandle(writeHint: true), named: name, on: cls.Properties.all, onConflict: .Replace)\n    }\n\n    public func prepareInsertOrIgnore<Root: TableEncodable>(\n        of cls: Root.Type) throws -> Insert {\n            return Insert(with: try self.database.getHandle(writeHint: true), named: name, on: cls.Properties.all, onConflict: .Ignore)\n    }\n\n    public func prepareInsert(on propertyConvertibleList: PropertyConvertible...) throws -> Insert {\n        return try prepareInsert(on: propertyConvertibleList)\n    }\n\n    public func prepareInsertOrReplace(on propertyConvertibleList: PropertyConvertible...) throws -> Insert {\n        return try prepareInsertOrReplace(on: propertyConvertibleList)\n    }\n\n    public func prepareInsertOrIgnore(on propertyConvertibleList: PropertyConvertible...) throws -> Insert {\n        return try prepareInsertOrIgnore(on: propertyConvertibleList)\n    }\n\n    public func prepareInsert(on propertyConvertibleList: [PropertyConvertible]) throws -> Insert {\n        return Insert(with: try self.database.getHandle(writeHint: true), named: name, on: propertyConvertibleList)\n    }\n\n    public func prepareInsertOrReplace(on propertyConvertibleList: [PropertyConvertible]) throws -> Insert {\n        return Insert(with: try self.database.getHandle(writeHint: true), named: name, on: propertyConvertibleList, onConflict: .Replace)\n    }\n\n    public func prepareInsertOrIgnore(on propertyConvertibleList: [PropertyConvertible]) throws -> Insert {\n        return Insert(with: try self.database.getHandle(writeHint: true), named: name, on: propertyConvertibleList, onConflict: .Ignore)\n    }\n}\n\nextension Table: TableDeleteChainCallInterface {\n    public func prepareDelete() throws -> Delete {\n        return Delete(with: try self.database.getHandle(writeHint: true), andTableName: name)\n    }\n}\n\nextension Table: TableUpdateChainCallInterface {\n    public func prepareUpdate(on propertyConvertibleList: PropertyConvertible...) throws -> Update {\n        return try prepareUpdate(on: propertyConvertibleList)\n    }\n\n    public func prepareUpdate(on propertyConvertibleList: [PropertyConvertible]) throws -> Update {\n        return Update(with: try self.database.getHandle(writeHint: true), on: propertyConvertibleList, andTable: name)\n    }\n}\n\nextension Table: TableRowSelectChainCallInterface {\n    public func prepareRowSelect(on resultColumnConvertibleList: ResultColumnConvertible...,\n                                 isDistinct: Bool = false) throws -> RowSelect {\n        return try prepareRowSelect(on: resultColumnConvertibleList.isEmpty ?\n                                    [Column.all()] : resultColumnConvertibleList,\n                                    isDistinct: isDistinct)\n    }\n\n    public func prepareRowSelect(on resultColumnConvertibleList: [ResultColumnConvertible],\n                                 isDistinct: Bool = false) throws -> RowSelect {\n        return RowSelect(with: try self.database.getHandle(writeHint: false),\n                         results: resultColumnConvertibleList,\n                         tables: [name],\n                         isDistinct: isDistinct)\n    }\n}\n\nextension Table: TableSelectChainCallInterface {\n    public func prepareSelect<Root: TableDecodable>(of cls: Root.Type,\n                                                    isDistinct: Bool = false) throws -> Select {\n        return Select(with: try self.database.getHandle(writeHint: false), on: cls.Properties.all, table: name, isDistinct: isDistinct)\n    }\n\n    public func prepareSelect(on propertyConvertibleList: PropertyConvertible...,\n                              isDistinct: Bool = false) throws -> Select {\n        return try prepareSelect(on: propertyConvertibleList,\n                                 isDistinct: isDistinct)\n    }\n\n    public func prepareSelect(on propertyConvertibleList: [PropertyConvertible],\n                              isDistinct: Bool = false) throws -> Select {\n        return Select(with: try self.database.getHandle(writeHint: false), on: propertyConvertibleList, table: name, isDistinct: isDistinct)\n    }\n}\n"
  },
  {
    "path": "src/swift/core/binding/CheckExpressionConfig.swift",
    "content": "//\n// Created by qiuwenchen on 2022/11/10.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport Foundation\n#if SWIFT_PACKAGE\nimport WCDB_Private\n#elseif WCDB_SWIFT_TARGET\nimport WCDBSwift.Private\n#else\nimport WCDB.Private\n#endif\n\npublic final class CheckExpressionConfig: TableConfiguration {\n    private let constraints: [TableConstraint]\n\n    public func config(with tableBinding: TableBindingBase) {\n        for constraint in constraints {\n            withExtendedLifetime(constraint) {\n                WCDBBindingAddTableConstraint(tableBinding.cppBinding, $0.cppObj)\n            }\n        }\n    }\n\n    public init(@CheckExpressionBuilder _ constraintBuilder: () -> [TableConstraint]) {\n        constraints = constraintBuilder()\n    }\n\n    @resultBuilder\n    public struct CheckExpressionBuilder {\n        public static func buildBlock() -> [TableConstraint] {\n            return []\n        }\n        public static func buildBlock(_ enums: Expression...) -> [TableConstraint] {\n            return enums.map { exp in\n                TableConstraint().check(exp)\n            }\n        }\n    }\n}\n"
  },
  {
    "path": "src/swift/core/binding/ColumnConstraintConfig.swift",
    "content": "//\n// Created by qiuwenchen on 2022/11/10.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport Foundation\n#if SWIFT_PACKAGE\nimport WCDB_Private\n#elseif WCDB_SWIFT_TARGET\nimport WCDBSwift.Private\n#else\nimport WCDB.Private\n#endif\n\npublic final class ColumnConstraintConfig<CodingTableKeyType: CodingTableKey>: TableConfiguration {\n    let codingKey: CodingTableKeyType\n    private var columnConstraints: [ColumnConstraint] = []\n    private let enableAutoIncrementForExistingTable: Bool\n\n    public func config(with tableBinding: TableBindingBase) {\n        for constraint in columnConstraints {\n            WCDBBindingAddColumnConstraint(tableBinding.cppBinding, codingKey.rawValue.cString, constraint.cppObj)\n        }\n        if enableAutoIncrementForExistingTable {\n            WCDBBindingEnableAutoIncrementForExistingTable(tableBinding.cppBinding)\n        }\n    }\n\n    required public init(_ codingKey: CodingTableKeyType,\n                isPrimary: Bool = false,\n                orderBy term: Order? = nil,\n                isAutoIncrement: Bool = false,\n                enableAutoIncrementForExistingTable: Bool = false,\n                onConflict conflict: ConflictAction? = nil,\n                isNotNull: Bool = false,\n                isUnique: Bool = false,\n                defaultTo defaultValue: LiteralValue? = nil,\n                isNotIndexed: Bool = false,\n                collate: String? = nil) {\n        self.codingKey = codingKey\n        if isPrimary {\n            let constrant = ColumnConstraint()\n            constrant.primaryKey()\n            if let term = term {\n                constrant.order(term)\n            }\n            if isAutoIncrement {\n                constrant.autoIncrement()\n            }\n            if let conflict = conflict {\n                constrant.conflict(action: conflict)\n            }\n            columnConstraints.append(constrant)\n        }\n        if isNotNull {\n            columnConstraints.append(ColumnConstraint().notNull())\n        }\n        if isUnique {\n            columnConstraints.append(ColumnConstraint().unique())\n        }\n        if let defaultValue = defaultValue {\n            columnConstraints.append(ColumnConstraint().default(with: defaultValue))\n        }\n        if isNotIndexed {\n            columnConstraints.append(ColumnConstraint().unIndexed())\n        }\n        if let collate = collate, !collate.isEmpty {\n            columnConstraints.append(ColumnConstraint().collate(with: collate))\n        }\n        self.enableAutoIncrementForExistingTable = enableAutoIncrementForExistingTable\n    }\n\n    public convenience init<T: ColumnEncodable>(\n        _ codingKey: CodingTableKeyType,\n        isPrimary: Bool = false,\n        orderBy term: Order? = nil,\n        isAutoIncrement: Bool = false,\n        enableAutoIncrementForExistingTable: Bool = false,\n        onConflict conflict: ConflictAction? = nil,\n        isNotNull: Bool = false,\n        isUnique: Bool = false,\n        defaultTo defaultEncodedValue: T,\n        isNotIndexed: Bool = false) {\n        var defaultValue: LiteralValue!\n        let value = defaultEncodedValue.archivedValue()\n        switch T.columnType {\n        case .integer32:\n            defaultValue = LiteralValue(value.int32Value)\n        case .integer64:\n            defaultValue = LiteralValue(value.int64Value)\n        case .text:\n            defaultValue = LiteralValue(value.stringValue)\n        case .float:\n            defaultValue = LiteralValue(value.doubleValue)\n        case .BLOB:\n            defaultValue = LiteralValue(value.dataValue)\n        case .null:\n            defaultValue = LiteralValue(nil)\n        }\n        self.init(codingKey,\n                  isPrimary: isPrimary,\n                  orderBy: term,\n                  isAutoIncrement: isAutoIncrement,\n                  onConflict: conflict,\n                  isNotNull: isNotNull,\n                  isUnique: isUnique,\n                  defaultTo: defaultValue,\n                  isNotIndexed: isNotIndexed)\n    }\n}\n"
  },
  {
    "path": "src/swift/core/binding/ForeignKeyConfig.swift",
    "content": "//\n// Created by qiuwenchen on 2022/11/10.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport Foundation\n#if SWIFT_PACKAGE\nimport WCDB_Private\n#elseif WCDB_SWIFT_TARGET\nimport WCDBSwift.Private\n#else\nimport WCDB.Private\n#endif\n\npublic final class ForeignKeyConfig<CodingTableKeyType: CodingTableKey>: TableConfiguration {\n    let codingKeys: [CodingTableKeyType]\n    let foreignKey: ForeignKey\n\n    public init(_ codingKeys: CodingTableKeyType..., foreignKey: ForeignKey) {\n        self.codingKeys = codingKeys\n        self.foreignKey = foreignKey\n    }\n\n    public func config(with tableBinding: TableBindingBase) {\n        let tableConstraint = TableConstraint().foreignKey(codingKeys, foreignKey: foreignKey)\n        withExtendedLifetime(tableConstraint) {\n            WCDBBindingAddTableConstraint(tableBinding.cppBinding, $0.cppObj)\n        }\n    }\n}\n"
  },
  {
    "path": "src/swift/core/binding/IndexConfig.swift",
    "content": "//\n// Created by qiuwenchen on 2022/11/10.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport Foundation\n#if SWIFT_PACKAGE\nimport WCDB_Private\n#elseif WCDB_SWIFT_TARGET\nimport WCDBSwift.Private\n#else\nimport WCDB.Private\n#endif\n\npublic final class IndexConfig<CodingTableKeyType: CodingTableKey>: TableConfiguration {\n    private let indexes: [IndexedColumnConvertible]\n    private let suffix: String\n    private let unique: Bool\n\n    public func config(with tableBinding: TableBindingBase) {\n        let statement = StatementCreateIndex().ifNotExists().indexesBy(indexes)\n        if unique {\n            statement.unique()\n        }\n        withExtendedLifetime(statement) {\n            WCDBBindingAddIndex(tableBinding.cppBinding, suffix.cString, false, $0.cppObj)\n        }\n    }\n\n    required public init(_ indexes: IndexedColumnConvertible..., namedWith suffix: String, isUnique: Bool = false) {\n        self.suffix = suffix\n        self.indexes = indexes\n        unique = isUnique\n    }\n}\n"
  },
  {
    "path": "src/swift/core/binding/MultiPrimaryConfig.swift",
    "content": "//\n// Created by qiuwenchen on 2022/11/10.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport Foundation\n#if SWIFT_PACKAGE\nimport WCDB_Private\n#elseif WCDB_SWIFT_TARGET\nimport WCDBSwift.Private\n#else\nimport WCDB.Private\n#endif\n\npublic final class MultiPrimaryConfig<CodingTableKeyType: CodingTableKey>: TableConfiguration {\n\n    private let indexes: [IndexedColumnConvertible]\n    private let conflict: ConflictAction?\n\n    public func config(with tableBinding: TableBindingBase) {\n        let tableConstraint = TableConstraint().primaryKey().indexed(by: indexes)\n        if let wrappedConflict = conflict {\n            tableConstraint.onConflict(wrappedConflict)\n        }\n        withExtendedLifetime(tableConstraint) {\n            WCDBBindingAddTableConstraint(tableBinding.cppBinding, $0.cppObj)\n        }\n    }\n\n    required public init(_ indexes: IndexedColumnConvertible..., onConflict conflict: ConflictAction? = nil) {\n        self.indexes = indexes\n        self.conflict = conflict\n    }\n}\n"
  },
  {
    "path": "src/swift/core/binding/MultiUniqueConfig.swift",
    "content": "//\n// Created by qiuwenchen on 2022/11/10.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport Foundation\n#if SWIFT_PACKAGE\nimport WCDB_Private\n#elseif WCDB_SWIFT_TARGET\nimport WCDBSwift.Private\n#else\nimport WCDB.Private\n#endif\n\npublic final class MultiUniqueConfig<CodingTableKeyType: CodingTableKey>: TableConfiguration {\n    private let indexes: [IndexedColumnConvertible]\n    private let conflict: ConflictAction?\n\n    public func config(with tableBinding: TableBindingBase) {\n        let tableConstraint = TableConstraint().unique().indexed(by: indexes)\n        if let wrappedConflict = conflict {\n            tableConstraint.onConflict(wrappedConflict)\n        }\n        withExtendedLifetime(tableConstraint) {\n            WCDBBindingAddTableConstraint(tableBinding.cppBinding, $0.cppObj)\n        }\n    }\n\n    required public init(_ indexes: IndexedColumnConvertible..., onConflict conflict: ConflictAction? = nil) {\n        self.indexes = indexes\n        self.conflict = conflict\n    }\n}\n"
  },
  {
    "path": "src/swift/core/binding/Property.swift",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport Foundation\n#if SWIFT_PACKAGE\nimport WCDB_Private\n#elseif WCDB_SWIFT_TARGET\nimport WCDBSwift.Private\n#else\nimport WCDB.Private\n#endif\n\npublic protocol PropertyConvertible: ColumnConvertible, PropertyRedirectable {\n    func isSwiftProperty() -> Bool\n\n    var codingTableKey: CodingTableKeyBase? {get}\n#if WCDB_SWIFT_BRIDGE_OBJC\n    var wctProperty: WCTBridgeProperty? {get}\n#endif\n    func asProperty() -> Property\n\n    func `in`(table: String) -> Property\n\n    func of(schema schemaConvertible: SchemaConvertible) -> Property\n}\n\npublic typealias PropertyOperable = PropertyConvertible & ExpressionOperable\n\npublic final class Property: Describable {\n    public private(set) var description: String\n    public private(set) var codingTableKey: CodingTableKeyBase?\n    internal var tableBinding: UnsafeRawPointer?\n    internal var tableName: String?\n    internal var schema: SchemaConvertible?\n#if WCDB_SWIFT_BRIDGE_OBJC\n    public private(set) var wctProperty: WCTBridgeProperty?\n\n    public init(named name: String, with codingTableKey: CodingTableKeyBase?, with wctProperty: WCTBridgeProperty?) {\n        self.wctProperty = wctProperty\n        self.codingTableKey = codingTableKey\n        self.description = name\n    }\n\n    public init(named name: String, with wctProperty: WCTBridgeProperty?) {\n        self.wctProperty = wctProperty\n        self.description = name\n    }\n#endif\n    public init(named name: String, with codingTableKey: CodingTableKeyBase?) {\n        self.codingTableKey = codingTableKey\n        self.description = name\n    }\n\n    public init(with codingTableKey: CodingTableKeyBase) {\n        self.codingTableKey = codingTableKey\n        self.description = codingTableKey.stringValue\n    }\n\n    public var name: String {\n        return description\n    }\n\n    internal func copyAsNewProperty() -> Property {\n#if WCDB_SWIFT_BRIDGE_OBJC\n        let property = Property(named: description, with: codingTableKey, with: wctProperty)\n#else\n        let property = Property(named: description, with: codingTableKey)\n#endif\n        property.tableBinding = tableBinding\n        property.tableName = tableName\n        property.schema = schema\n        return property\n    }\n}\n\nextension Property: PropertyOperable {\n    public func isSwiftProperty() -> Bool {\n        return codingTableKey != nil\n    }\n\n    public func asProperty() -> Property {\n        return self\n    }\n\n    public func `in`(table: String) -> Property {\n        let property = copyAsNewProperty()\n        property.tableName = table\n        return property\n    }\n\n    public func of(schema schemaConvertible: SchemaConvertible) -> Property {\n        let property = copyAsNewProperty()\n        property.schema = schemaConvertible\n        return property\n    }\n\n    public func asColumn() -> Column {\n        let column = Column(named: name, binded: tableBinding)\n        if let tableName = tableName {\n            column.in(table: tableName)\n        }\n        if let schema = schema {\n            column.of(schema: schema)\n        }\n        return column\n    }\n}\n"
  },
  {
    "path": "src/swift/core/binding/Redirectable.swift",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport Foundation\n#if SWIFT_PACKAGE\nimport WCDB_Private\n#elseif WCDB_SWIFT_TARGET\nimport WCDBSwift.Private\n#else\nimport WCDB.Private\n#endif\n\npublic protocol PropertyRedirectable {\n    func `as`(_ propertyConvertible: PropertyConvertible) -> Property\n}\n\nextension PropertyRedirectable where Self: Describable {\n    public func `as`(_ propertyConvertible: PropertyConvertible) -> Property {\n#if WCDB_SWIFT_BRIDGE_OBJC\n        return Property(named: description, with: propertyConvertible.codingTableKey, with: propertyConvertible.wctProperty)\n#else\n        return Property(named: description, with: propertyConvertible.codingTableKey)\n#endif\n    }\n}\n\nextension Column: PropertyRedirectable {}\n\nextension ResultColumn: PropertyRedirectable {}\n\nextension Expression: PropertyRedirectable {}\n"
  },
  {
    "path": "src/swift/core/binding/TableBinding.swift",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport Foundation\n#if SWIFT_PACKAGE\nimport WCDB_Private\n#elseif WCDB_SWIFT_TARGET\nimport WCDBSwift.Private\n#else\nimport WCDB.Private\n#endif\n\npublic class TableBindingBase {\n    private let recyclableBinding: Recyclable<CPPBinding>\n    internal let cppBinding: CPPBinding\n    public init() {\n        self.cppBinding = WCDBBindingCreate()\n        self.recyclableBinding = ObjectBridge.createRecyclableCPPObject(cppBinding)\n    }\n}\n\npublic final class TableBinding<CodingTableKeyType: CodingTableKey>: TableBindingBase {\n    private let properties: [CodingTableKeyType: Property]\n    private var configBuilder: (() -> [TableConfiguration])?\n\n    public init(_ type: CodingTableKeyType.Type) {\n        var allProperties: [Property] = []\n        var properties: [CodingTableKeyType: Property] = [:]\n        var allKeys: [CodingTableKeyType] = []\n        var i = 0\n        while true {\n            guard let key = (withUnsafePointer(to: &i) {\n                return $0.withMemoryRebound(to: CodingTableKeyType?.self, capacity: 1, { return $0.pointee })\n            }) else {\n                break\n            }\n            allKeys.append(key)\n            i += 1\n        }\n\n        for key in allKeys {\n            let property = Property(with: key)\n            properties[key] = property\n            allProperties.append(property)\n        }\n\n        self.allKeys = allKeys\n        self.properties = properties\n        self.allProperties = allProperties\n        self.configBuilder = nil\n\n        super.init()\n\n        for property in allProperties {\n            property.tableBinding = WCDBBindingGetBaseBinding(cppBinding)\n        }\n\n        if let tableDecodableType = CodingTableKeyType.Root.self as? TableDecodableBase.Type {\n            let types = ColumnTypeDecoder.types(of: tableDecodableType)\n            for key in self.allKeys {\n                let columnType = types[key.stringValue]\n                assert(columnType != nil, \"It should not be failed. If you think it's a bug, please report an issue to us.\")\n                let columnDef = ColumnDef(named: key.rawValue, and: columnType!)\n                withExtendedLifetime(columnDef) {\n                    WCDBBindingAddColumnDef(cppBinding, $0.cppObj)\n                }\n            }\n\n            #if DEBUG\n            let keys = allKeys.filter({ (key) -> Bool in\n                return types.index(forKey: key.stringValue) == nil\n            })\n            assert(keys.count == 0,\n                   \"\"\"\n                   The following keys: \\(keys) can't be decoded. \\\n                   1. Try to change their definition from `let` to `var` or report an issue to us. \\\n                   2. Try to rename the `static` variable with same name.\n                   \"\"\")\n            #endif\n        }\n    }\n\n    @resultBuilder\n    public struct TableConfigurationBuilder {\n        public static func buildBlock(_ configs: TableConfiguration...) -> [TableConfiguration] {\n            return configs\n        }\n        public static func buildBlock() -> [TableConfiguration] {\n            return []\n        }\n    }\n\n    public convenience init(_ type: CodingTableKeyType.Type, @TableConfigurationBuilder _ configBuilder: @escaping () -> [TableConfiguration]) {\n        self.init(type)\n        self.configBuilder = configBuilder\n    }\n\n    let allProperties: [Property]\n    let allKeys: [CodingTableKeyType]\n\n    private lazy var primaryKey: CodingTableKeyType? = {\n        let filtered = allKeys.filter({ key in\n            WCDBBindingIsPrimaryKey(cppBinding, key.rawValue.cString)\n        })\n        guard filtered.count == 1 else {\n            assert(filtered.count == 0, \"Only one primary key is supported. Use MultiPrimaryBinding instead\")\n            return nil\n        }\n        return filtered.first!\n    }()\n\n    internal lazy var innerBinding: CPPBinding = {\n        if let configBuilder = configBuilder {\n            let configs = configBuilder()\n            for config in configs {\n                config.config(with: self)\n            }\n        }\n        return cppBinding\n    }()\n\n    typealias TypedCodingTableKeyType = CodingTableKeyType\n    func property<KeyType: CodingTableKey>(from codingTableKey: KeyType) -> Property {\n        let typedCodingTableKey = codingTableKey as? TypedCodingTableKeyType\n        assert(typedCodingTableKey != nil, \"[\\(codingTableKey)] must conform to CodingTableKey protocol.\")\n        let typedProperty = properties[typedCodingTableKey!]\n        assert(typedProperty != nil, \"It should not be failed. If you think it's a bug, please report an issue to us.\")\n        return typedProperty!\n    }\n\n    func getPrimaryKey() -> CodingTableKeyBase? {\n        return primaryKey\n    }\n}\n"
  },
  {
    "path": "src/swift/core/binding/TableConfiguration.swift",
    "content": "//\n// Created by qiuwenchen on 2022/11/10.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport Foundation\n#if SWIFT_PACKAGE\nimport WCDB_Private\n#elseif WCDB_SWIFT_TARGET\nimport WCDBSwift.Private\n#else\nimport WCDB.Private\n#endif\n\npublic protocol TableConfiguration {\n    func config(with tableBinding: TableBindingBase)\n}\n"
  },
  {
    "path": "src/swift/core/binding/VirtualTableConfig.swift",
    "content": "//\n// Created by qiuwenchen on 2022/11/10.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport Foundation\n#if SWIFT_PACKAGE\nimport WCDB_Private\n#elseif WCDB_SWIFT_TARGET\nimport WCDBSwift.Private\n#else\nimport WCDB.Private\n#endif\n\npublic final class VirtualTableConfig: TableConfiguration {\n    let module: String\n    var parameters: [String]\n\n    public func config(with tableBinding: TableBindingBase) {\n        WCDBBindingConfigVirtualModule(tableBinding.cppBinding, module.cString)\n        for parameter in parameters {\n            WCDBBindingConfigVirtualModuleArgument(tableBinding.cppBinding, parameter.cString)\n        }\n    }\n\n    public init(withModule version: FTSVersion, and tokenizer: String..., withExternalContent table: String? = nil) {\n        self.module = version.description\n        self.parameters = [\"tokenize = \\(tokenizer.joined(separateBy: \" \"))\"]\n        if let table = table {\n            self.parameters.append(\"content='\\(table)'\")\n        }\n    }\n\n    public init(withModule module: String, and parameters: String...) {\n        self.module = module\n        self.parameters = parameters\n    }\n}\n"
  },
  {
    "path": "src/swift/core/chaincall/ChainCall+WCTTableCoding.swift",
    "content": "//\n// Created by qiuwenchen on 2022/11/13.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#if WCDB_SWIFT_BRIDGE_OBJC\n\nimport Foundation\n#if SWIFT_PACKAGE\nimport WCDB_Private\n#elseif WCDB_SWIFT_TARGET\nimport WCDBSwift.Private\n#else\nimport WCDB.Private\n#endif\n\n/// ChainCall interface for inserting\npublic protocol InsertChainCallInterfaceForObjc: AnyObject {\n\n    /// Prepare chain call for inserting of `WCTTableCoding` object\n    ///\n    /// - Parameters:\n    ///   - cls: Type of table object\n    ///   - table: Table name\n    /// - Returns: `Insert`\n    func prepareInsert<Root: WCTTableCoding>(of cls: Root.Type, intoTable table: String) throws -> Insert\n\n    /// Prepare chain call for inserting or replacing of `WCTTableCoding` object\n    ///\n    /// - Parameters:\n    ///   - cls: Type of table object\n    ///   - table: Table name\n    /// - Returns: `Insert`\n    func prepareInsertOrReplace<Root: WCTTableCoding>(of cls: Root.Type, intoTable table: String) throws -> Insert\n\n    /// Prepare chain call for inserting or ignoring of `WCTTableCoding` object\n    ///\n    /// - Parameters:\n    ///   - cls: Type of table object\n    ///   - table: Table name\n    /// - Returns: `Insert`\n    func prepareInsertOrIgnore<Root: WCTTableCoding>(of cls: Root.Type, intoTable table: String) throws -> Insert\n}\n\nextension InsertChainCallInterfaceForObjc where Self: HandleRepresentable {\n    public func prepareInsert<Root: WCTTableCoding>(of cls: Root.Type, intoTable table: String) throws -> Insert {\n        return Insert(with: try getHandle(writeHint: true), named: table, on: cls.allProperties())\n    }\n\n    public func prepareInsertOrReplace<Root: WCTTableCoding>(\n        of cls: Root.Type,\n        intoTable table: String) throws -> Insert {\n            return Insert(with: try getHandle(writeHint: true), named: table, on: cls.allProperties(), onConflict: .Replace)\n    }\n\n    public func prepareInsertOrIgnore<Root: WCTTableCoding>(\n        of cls: Root.Type,\n        intoTable table: String) throws -> Insert {\n            return Insert(with: try getHandle(writeHint: true), named: table, on: cls.allProperties(), onConflict: .Ignore)\n    }\n}\n\n/// ChainCall interface for selecting\npublic protocol SelectChainCallInterfaceForObjc: AnyObject {\n\n    /// Prepare chain call for selecting of `TableDecodable` object\n    ///\n    /// - Parameters:\n    ///   - cls: Type of table decodable object\n    ///   - table: Table name\n    ///   - isDistinct: Is distinct or not\n    /// - Returns: `Select`\n    func prepareSelect<Root: WCTTableCoding>(of cls: Root.Type,\n                                             fromTable table: String,\n                                             isDistinct: Bool) throws -> Select\n}\n\nextension SelectChainCallInterfaceForObjc where Self: HandleRepresentable {\n    public func prepareSelect<Root: WCTTableCoding>(of cls: Root.Type,\n                                                    fromTable table: String,\n                                                    isDistinct: Bool = false) throws -> Select {\n        return Select(with: try getHandle(writeHint: false), on: cls.allProperties(), table: table, isDistinct: isDistinct)\n    }\n}\n\n#endif\n"
  },
  {
    "path": "src/swift/core/chaincall/ChainCall.swift",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport Foundation\n#if SWIFT_PACKAGE\nimport WCDB_Private\n#elseif WCDB_SWIFT_TARGET\nimport WCDBSwift.Private\n#else\nimport WCDB.Private\n#endif\n\n/// ChainCall interface for inserting\npublic protocol InsertChainCallInterface: AnyObject {\n\n    /// Prepare chain call for inserting of `TableEncodable` object\n    ///\n    /// - Parameters:\n    ///   - cls: Type of table object\n    ///   - table: Table name\n    /// - Returns: `Insert`\n    func prepareInsert<Root: TableEncodable>(of cls: Root.Type, intoTable table: String) throws -> Insert\n\n    /// Prepare chain call for inserting or replacing of `TableEncodable` object\n    ///\n    /// - Parameters:\n    ///   - cls: Type of table object\n    ///   - table: Table name\n    /// - Returns: `Insert`\n    func prepareInsertOrReplace<Root: TableEncodable>(of cls: Root.Type, intoTable table: String) throws -> Insert\n\n    /// Prepare chain call for inserting or ignoring of `TableEncodable` object\n    ///\n    /// - Parameters:\n    ///   - cls: Type of table object\n    ///   - table: Table name\n    /// - Returns: `Insert`\n    func prepareInsertOrIgnore<Root: TableEncodable>(of cls: Root.Type, intoTable table: String) throws -> Insert\n\n    /// Prepare chain call for inserting on specific properties\n    ///\n    /// - Parameters:\n    ///   - propertyConvertibleList: `Property` or `CodingTableKey` list \n    ///   - table: Table name\n    /// - Returns: `Insert`\n    func prepareInsert(on propertyConvertibleList: PropertyConvertible..., intoTable table: String) throws -> Insert\n\n    /// Prepare chain call for inserting or replacing on specific properties\n    ///\n    /// - Parameters:\n    ///   - propertyConvertibleList: `Property` or `CodingTableKey` list\n    ///   - table: Table name\n    /// - Returns: `Insert`\n    func prepareInsertOrReplace(on propertyConvertibleList: PropertyConvertible...,\n                                intoTable table: String) throws -> Insert\n\n    /// Prepare chain call for inserting or ignoring on specific properties\n    ///\n    /// - Parameters:\n    ///   - propertyConvertibleList: `Property` or `CodingTableKey` list\n    ///   - table: Table name\n    /// - Returns: `Insert`\n    func prepareInsertOrIgnore(on propertyConvertibleList: PropertyConvertible...,\n                                intoTable table: String) throws -> Insert\n\n    /// Prepare chain call for inserting on specific properties\n    ///\n    /// - Parameters:\n    ///   - propertyConvertibleList: `Property` or `CodingTableKey` list\n    ///   - table: Table name\n    /// - Returns: `Insert`\n    func prepareInsert(on propertyConvertibleList: [PropertyConvertible]?,\n                       intoTable table: String) throws -> Insert\n\n    /// Prepare chain call for inserting or replacing on specific properties\n    ///\n    /// - Parameters:\n    ///   - propertyConvertibleList: `Property` or `CodingTableKey` list\n    ///   - table: Table name\n    /// - Returns: `Insert`\n    func prepareInsertOrReplace(on propertyConvertibleList: [PropertyConvertible],\n                                intoTable table: String) throws -> Insert\n\n    /// Prepare chain call for inserting or ignoring on specific properties\n    ///\n    /// - Parameters:\n    ///   - propertyConvertibleList: `Property` or `CodingTableKey` list\n    ///   - table: Table name\n    /// - Returns: `Insert`\n    func prepareInsertOrIgnore(on propertyConvertibleList: [PropertyConvertible],\n                                intoTable table: String) throws -> Insert\n}\n\nextension InsertChainCallInterface where Self: HandleRepresentable {\n    public func prepareInsert<Root: TableEncodable>(of cls: Root.Type, intoTable table: String) throws -> Insert {\n        return Insert(with: try getHandle(writeHint: true), named: table, on: cls.Properties.all)\n    }\n\n    public func prepareInsertOrReplace<Root: TableEncodable>(\n        of cls: Root.Type,\n        intoTable table: String) throws -> Insert {\n            return Insert(with: try getHandle(writeHint: true), named: table, on: cls.Properties.all, onConflict: .Replace)\n    }\n\n    public func prepareInsertOrIgnore<Root: TableEncodable>(\n        of cls: Root.Type,\n        intoTable table: String) throws -> Insert {\n            return Insert(with: try getHandle(writeHint: true), named: table, on: cls.Properties.all, onConflict: .Ignore)\n    }\n\n    public func prepareInsert(on propertyConvertibleList: PropertyConvertible...,\n                              intoTable table: String) throws -> Insert {\n        return try prepareInsert(on: propertyConvertibleList, intoTable: table)\n    }\n\n    public func prepareInsertOrReplace(on propertyConvertibleList: PropertyConvertible...,\n                                       intoTable table: String) throws -> Insert {\n        return try prepareInsertOrReplace(on: propertyConvertibleList, intoTable: table)\n    }\n\n    public func prepareInsertOrIgnore(on propertyConvertibleList: PropertyConvertible...,\n                                       intoTable table: String) throws -> Insert {\n        return try prepareInsertOrIgnore(on: propertyConvertibleList, intoTable: table)\n    }\n\n    public func prepareInsert(on propertyConvertibleList: [PropertyConvertible]?,\n                              intoTable table: String) throws -> Insert {\n        return Insert(with: try getHandle(writeHint: true), named: table, on: propertyConvertibleList)\n    }\n\n    public func prepareInsertOrReplace(on propertyConvertibleList: [PropertyConvertible],\n                                       intoTable table: String) throws -> Insert {\n        return Insert(with: try getHandle(writeHint: true), named: table, on: propertyConvertibleList, onConflict: .Replace)\n    }\n\n    public func prepareInsertOrIgnore(on propertyConvertibleList: [PropertyConvertible],\n                                       intoTable table: String) throws -> Insert {\n        return Insert(with: try getHandle(writeHint: true), named: table, on: propertyConvertibleList, onConflict: .Ignore)\n    }\n}\n\n/// ChainCall interface for deleting\npublic protocol DeleteChainCallInterface: AnyObject {\n\n    /// Prepare chain call for deleting on specific properties\n    ///\n    /// - Parameter table: Table name\n    /// - Returns: `Delete`\n    func prepareDelete(fromTable table: String) throws -> Delete\n}\n\nextension DeleteChainCallInterface where Self: HandleRepresentable {\n    public func prepareDelete(fromTable table: String) throws -> Delete {\n        return Delete(with: try getHandle(writeHint: true), andTableName: table)\n    }\n}\n\n/// ChainCall interface for updating\npublic protocol UpdateChainCallInterface: AnyObject {\n\n    /// Prepare chain call for updating on specific properties\n    ///\n    /// - Parameters:\n    ///   - table: Table name\n    ///   - propertyConvertibleList: `Property` or `CodingTableKey` list\n    /// - Returns: `Update`\n    func prepareUpdate(table: String, on propertyConvertibleList: PropertyConvertible...) throws -> Update\n\n    /// Prepare chain call for updating on specific properties\n    ///\n    /// - Parameters:\n    ///   - table: Table name\n    ///   - propertyConvertibleList: `Property` or `CodingTableKey` list\n    /// - Returns: `Update`\n    func prepareUpdate(table: String, on propertyConvertibleList: [PropertyConvertible]) throws -> Update\n}\n\nextension UpdateChainCallInterface where Self: HandleRepresentable {\n    public func prepareUpdate(table: String, on propertyConvertibleList: PropertyConvertible...) throws -> Update {\n        return try prepareUpdate(table: table, on: propertyConvertibleList)\n    }\n\n    public func prepareUpdate(table: String, on propertyConvertibleList: [PropertyConvertible]) throws -> Update {\n        return Update(with: try getHandle(writeHint: true), on: propertyConvertibleList, andTable: table)\n    }\n}\n\n/// ChainCall interface for row-selecting\npublic protocol RowSelectChainCallInterface: AnyObject {\n\n    /// Prepare chain call for row-selecting on specific column results\n    ///\n    /// - Parameters:\n    ///   - resultColumnConvertibleList: `ResultColumn` list\n    ///   - tables: Table name list\n    ///   - isDistinct: Is distinct or not\n    /// - Returns: `RowSelect`\n    func prepareRowSelect(on resultColumnConvertibleList: ResultColumnConvertible...,\n                          fromTables tables: [String],\n                          isDistinct: Bool) throws -> RowSelect\n\n    /// Prepare chain call for row-selecting on specific column results\n    ///\n    /// - Parameters:\n    ///   - resultColumnConvertibleList: `ResultColumn` list\n    ///   - tables: Table name list\n    ///   - isDistinct: Is distinct or not\n    /// - Returns: `RowSelect`\n    func prepareRowSelect(on resultColumnConvertibleList: [ResultColumnConvertible],\n                          fromTables tables: [String],\n                          isDistinct: Bool) throws -> RowSelect\n\n    /// Prepare chain call for row-selecting on specific column results\n    ///\n    /// - Parameters:\n    ///   - resultColumnConvertibleList: `ResultColumn` list\n    ///   - tables: Table name\n    ///   - isDistinct: Is distinct or not\n    /// - Returns: `RowSelect`\n    func prepareRowSelect(on resultColumnConvertibleList: ResultColumnConvertible...,\n                          fromTable table: String,\n                          isDistinct: Bool) throws -> RowSelect\n\n    /// Prepare chain call for row-selecting on specific column results\n    ///\n    /// - Parameters:\n    ///   - resultColumnConvertibleList: `ResultColumn` list\n    ///   - tables: Table name\n    ///   - isDistinct: Is distinct or not\n    /// - Returns: `RowSelect`\n    func prepareRowSelect(on resultColumnConvertibleList: [ResultColumnConvertible],\n                          fromTable table: String,\n                          isDistinct: Bool) throws -> RowSelect\n}\n\nextension RowSelectChainCallInterface where Self: HandleRepresentable {\n    public func prepareRowSelect(on resultColumnConvertibleList: ResultColumnConvertible...,\n                                 fromTables tables: [String],\n                                 isDistinct: Bool = false) throws -> RowSelect {\n        return try prepareRowSelect(on: resultColumnConvertibleList.isEmpty ?\n                                    [Column.all()] : resultColumnConvertibleList,\n                                    fromTables: tables,\n                                    isDistinct: isDistinct)\n    }\n\n    public func prepareRowSelect(on resultColumnConvertibleList: [ResultColumnConvertible],\n                                 fromTables tables: [String],\n                                 isDistinct: Bool = false) throws -> RowSelect {\n        return RowSelect(with: try getHandle(writeHint: false), results: resultColumnConvertibleList, tables: tables, isDistinct: isDistinct)\n    }\n\n    public func prepareRowSelect(on resultColumnConvertibleList: ResultColumnConvertible...,\n                                 fromTable table: String,\n                                 isDistinct: Bool = false) throws -> RowSelect {\n        return try prepareRowSelect(on: resultColumnConvertibleList.isEmpty ?\n                                    [Column.all()] : resultColumnConvertibleList,\n                                    fromTable: table,\n                                    isDistinct: isDistinct)\n    }\n\n    public func prepareRowSelect(on resultColumnConvertibleList: [ResultColumnConvertible],\n                                 fromTable table: String,\n                                 isDistinct: Bool = false) throws -> RowSelect {\n        return RowSelect(with: try getHandle(writeHint: false),\n                         results: resultColumnConvertibleList,\n                         tables: [table],\n                         isDistinct: isDistinct)\n    }\n}\n\n/// ChainCall interface for selecting\npublic protocol SelectChainCallInterface: AnyObject {\n\n    /// Prepare chain call for selecting of `TableDecodable` object\n    ///\n    /// - Parameters:\n    ///   - cls: Type of table decodable object\n    ///   - table: Table name\n    ///   - isDistinct: Is distinct or not\n    /// - Returns: `Select`\n    func prepareSelect<Root: TableDecodable>(of cls: Root.Type,\n                                             fromTable table: String,\n                                             isDistinct: Bool) throws -> Select\n\n    /// Prepare chain call for selecting on specific properties\n    ///\n    /// - Parameters:\n    ///   - propertyConvertibleList: `Property` or `CodingTableKey` list\n    ///   - table: Table name\n    ///   - isDistinct: Is distinct or not\n    /// - Returns: `Select`\n    func prepareSelect(on propertyConvertibleList: PropertyConvertible...,\n                       fromTable table: String,\n                       isDistinct: Bool) throws -> Select\n\n    /// Prepare chain call for selecting on specific properties\n    ///\n    /// - Parameters:\n    ///   - propertyConvertibleList: `Property` or `CodingTableKey` list\n    ///   - table: Table name\n    ///   - isDistinct: Is distinct or not\n    /// - Returns: `Select`\n    func prepareSelect(on propertyConvertibleList: [PropertyConvertible],\n                       fromTable table: String,\n                       isDistinct: Bool) throws -> Select\n}\n\nextension SelectChainCallInterface where Self: HandleRepresentable {\n    public func prepareSelect<Root: TableDecodable>(of cls: Root.Type,\n                                                    fromTable table: String,\n                                                    isDistinct: Bool = false) throws -> Select {\n        return Select(with: try getHandle(writeHint: false), on: cls.Properties.all, table: table, isDistinct: isDistinct)\n    }\n\n    public func prepareSelect(on propertyConvertibleList: PropertyConvertible...,\n                              fromTable table: String,\n                              isDistinct: Bool = false) throws -> Select {\n        return try prepareSelect(on: propertyConvertibleList,\n                                 fromTable: table,\n                                 isDistinct: isDistinct)\n    }\n\n    public func prepareSelect(on propertyConvertibleList: [PropertyConvertible],\n                              fromTable table: String,\n                              isDistinct: Bool = false) throws -> Select {\n        return Select(with: try getHandle(writeHint: false), on: propertyConvertibleList, table: table, isDistinct: isDistinct)\n    }\n}\n\n/// ChainCall interface for multi-selecting\npublic protocol MultiSelectChainCallInterface: AnyObject {\n\n    /// Prepare chain call for multi-selecting on specific properties\n    ///\n    /// - Parameters:\n    ///   - propertyConvertibleList: `Property` or `CodingTableKey` list\n    ///   - tables: Table name list\n    /// - Returns: `MultiSelect`\n    func prepareMultiSelect(on propertyConvertibleList: PropertyConvertible...,\n                            fromTables tables: [String]) throws -> MultiSelect\n\n    /// Prepare chain call for multi-selecting on specific properties\n    ///\n    /// - Parameters:\n    ///   - propertyConvertibleList: `Property` or `CodingTableKey` list\n    ///   - tables: Table name list\n    /// - Returns: `MultiSelect`\n    func prepareMultiSelect(on propertyConvertibleList: [PropertyConvertible],\n                            fromTables tables: [String]) throws -> MultiSelect\n}\n\nextension MultiSelectChainCallInterface where Self: HandleRepresentable {\n    public func prepareMultiSelect(on propertyConvertibleList: PropertyConvertible...,\n                                   fromTables tables: [String]) throws -> MultiSelect {\n        return try prepareMultiSelect(on: propertyConvertibleList, fromTables: tables)\n    }\n\n    public func prepareMultiSelect(on propertyConvertibleList: [PropertyConvertible],\n                                   fromTables tables: [String]) throws -> MultiSelect {\n        return MultiSelect(with: try getHandle(writeHint: false), on: propertyConvertibleList, tables: tables)\n    }\n}\n"
  },
  {
    "path": "src/swift/core/chaincall/Declare.swift",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport Foundation\n#if SWIFT_PACKAGE\nimport WCDB_Private\n#elseif WCDB_SWIFT_TARGET\nimport WCDBSwift.Private\n#else\nimport WCDB.Private\n#endif\n\npublic typealias Condition = ExpressionConvertible\npublic typealias Limit = ExpressionConvertible\npublic typealias Offset = ExpressionConvertible\npublic typealias GroupBy = ExpressionConvertible\npublic typealias Having = ExpressionConvertible\npublic typealias OrderBy = OrderingTermConvertible\n"
  },
  {
    "path": "src/swift/core/chaincall/Delete.swift",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport Foundation\n#if SWIFT_PACKAGE\nimport WCDB_Private\n#elseif WCDB_SWIFT_TARGET\nimport WCDBSwift.Private\n#else\nimport WCDB.Private\n#endif\n\n/// Chain call for deleting\npublic final class Delete {\n    private var handle: Handle\n    public final let statement = StatementDelete()\n\n    /// The number of changed rows in the most recent call.\n    /// It should be called after executing successfully\n    public var changes: Int?\n\n    init(with handle: Handle, andTableName tableName: String) {\n        statement.delete(from: tableName)\n        self.handle = handle\n    }\n\n    /// WINQ interface for SQL\n    ///\n    /// - Parameter condition: Expression convertible\n    /// - Returns: `self`\n    @discardableResult\n    public func `where`(_ condition: Condition) -> Delete {\n        statement.where(condition)\n        return self\n    }\n\n    /// WINQ interface for SQL\n    ///\n    /// - Parameter orderList: Order convertible list\n    /// - Returns: `self`\n    @discardableResult\n    public func order(by orderList: OrderBy...) -> Delete {\n        return order(by: orderList)\n    }\n\n    /// WINQ interface for SQL\n    ///\n    /// - Parameter orderList: Order convertible list\n    /// - Returns: `self`\n    @discardableResult\n    public func order(by orderList: [OrderBy]) -> Delete {\n        statement.order(by: orderList)\n        return self\n    }\n\n    /// WINQ interface for SQL\n    ///\n    /// - Parameters:\n    ///   - begin: Expression convertible\n    ///   - end: Expression convertible\n    /// - Returns: `self`\n    @discardableResult\n    public func limit(from begin: Limit, to end: Limit) -> Delete {\n        statement.limit(from: begin, to: end)\n        return self\n    }\n\n    /// WINQ interface for SQL\n    ///\n    /// - Parameter limit: Expression convertible\n    /// - Returns: `self`\n    @discardableResult\n    public func limit(_ limit: Limit) -> Delete {\n        statement.limit(limit)\n        return self\n    }\n\n    /// WINQ interface for SQL\n    ///\n    /// - Parameters:\n    ///   - limit: Expression convertible\n    ///   - offset: Expression convertible\n    /// - Returns: `self`\n    @discardableResult\n    public func limit(_ limit: Limit, offset: Offset) -> Delete {\n        statement.limit(limit).offset(offset)\n        return self\n    }\n\n    /// Execute the delete chain call.\n    ///\n    /// - Throws: Error\n    public func execute() throws {\n        try handle.prepare(statement)\n        try handle.step()\n        changes = handle.changes\n        handle.finalize()\n    }\n}\n"
  },
  {
    "path": "src/swift/core/chaincall/Insert+WCTTableCoding.swift",
    "content": "//\n// Created by qiuwenchen on 2022/11/13.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#if WCDB_SWIFT_BRIDGE_OBJC\n\nimport Foundation\n#if SWIFT_PACKAGE\nimport WCDB_Private\n#elseif WCDB_SWIFT_TARGET\nimport WCDBSwift.Private\n#else\nimport WCDB.Private\n#endif\n\npublic extension Insert {\n\n    func execute<Object: WCTTableCoding>(with objects: Object...) throws {\n        try execute(with: objects)\n    }\n\n    func execute<Object: WCTTableCoding>(with objects: [Object]) throws {\n        guard objects.count > 0 else {\n            return\n        }\n        if !WCTAPIBridge.insertObjects(objects, intoTable: name,\n                                       withProperties: properties?.asWCTBridgeProperties(),\n                                       orReplace: conflict != nil ? conflict! == .Replace : false,\n                                       orIgnore: conflict != nil ? conflict! == .Ignore : false,\n                                       with: handle.cppHandle) {\n            throw handle.getError()\n        }\n    }\n}\n\n#endif\n"
  },
  {
    "path": "src/swift/core/chaincall/Insert.swift",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport Foundation\n#if SWIFT_PACKAGE\nimport WCDB_Private\n#elseif WCDB_SWIFT_TARGET\nimport WCDBSwift.Private\n#else\nimport WCDB.Private\n#endif\n\n/// Chain call for inserting\npublic final class Insert {\n    internal let handle: Handle\n    internal var properties: [PropertyConvertible]?\n    internal let name: String\n    internal var conflict: ConflictAction?\n\n    init(with handle: Handle,\n         named name: String,\n         on propertyConvertibleList: [PropertyConvertible]?,\n         onConflict action: ConflictAction? = nil) {\n        self.name = name\n        self.properties = propertyConvertibleList\n        self.conflict = action\n        self.handle = handle\n    }\n\n    public final lazy var statement: StatementInsert = StatementInsert()\n        .insert(intoTable: name).columns(properties!).onConflict(self.conflict)\n        .values(BindParameter.bindParameters(properties!.count))\n\n    /// Execute the insert chain call with objects.\n    ///\n    /// Note that it will run embedded transaction while objects.count>1.  \n    /// The embedded transaction means that it will run a transaction if it's not in other transaction,\n    /// otherwise it will be executed within the existing transaction.\n    ///\n    /// - Parameter objects: Object to be inserted\n    /// - Throws: Error\n    public func execute<Object: TableEncodable>(with objects: Object...) throws {\n        try execute(with: objects)\n    }\n\n    /// Execute the insert chain call with objects.\n    ///\n    /// Note that it will run embedded transaction while objects.count>1.  \n    /// The embedded transaction means that it will run a transaction if it's not in other transaction,\n    /// otherwise it will be executed within the existing transaction.\n    ///\n    /// - Parameter objects: Object to be inserted\n    /// - Throws: Error\n    public func execute<Object: TableEncodable>(with objects: [Object]) throws {\n        guard objects.count > 0 else {\n            return\n        }\n        let orm = Object.CodingKeys.objectRelationalMapping\n        func doInsertObject(_ handle: Handle) throws {\n            properties = properties ?? Object.Properties.all\n            try handle.prepare(statement)\n            let encoder = TableEncoder(properties!.asCodingTableKeys(), on: handle)\n            let useConfliction = conflict != nil\n            if !useConfliction {\n                encoder.primaryKeyHash = orm.getPrimaryKey()?.stringValue.hashValue\n            }\n\n            for var object in objects {\n                let isAutoIncrement = object.isAutoIncrement\n                encoder.isPrimaryKeyEncoded = !isAutoIncrement\n                try object.encode(to: encoder)\n                try handle.step()\n                assert(!useConfliction || !isAutoIncrement,\n                       \"Auto-increment inserts do not support conflict action!\")\n                if !useConfliction && isAutoIncrement {\n                    object.lastInsertedRowID = handle.lastInsertedRowID\n                }\n                handle.reset()\n            }\n            handle.finalize()\n        }\n        return objects.count == 1 ? try doInsertObject(handle) : try handle.run(transaction: doInsertObject)\n    }\n}\n"
  },
  {
    "path": "src/swift/core/chaincall/MultiSelect.swift",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport Foundation\n#if SWIFT_PACKAGE\nimport WCDB_Private\n#elseif WCDB_SWIFT_TARGET\nimport WCDBSwift.Private\n#else\nimport WCDB.Private\n#endif\n\n/// Chain call for multi-selecting\npublic final class MultiSelect: Selectable {\n    private let properties: [PropertyConvertible]\n    private lazy var keys: [CodingTableKeyBase] = {\n        self.properties.asCodingTableKeys()\n    }()\n\n    init(with handle: Handle,\n         on propertyConvertibleList: [PropertyConvertible],\n         tables: [String],\n         isDistinct: Bool = false) {\n        properties = propertyConvertibleList\n        let statement = StatementSelect().select(distinct: isDistinct, propertyConvertibleList).from(tables)\n        super.init(with: handle, statement: statement)\n    }\n\n    private typealias Generator = () throws -> TableDecodableBase\n\n    struct TypedIndexedKeys {\n        let type: TableDecodableBase.Type\n        var indexedKeys: TableDecoder.HashedKey\n        init(_ type: TableDecodableBase.Type, key: String, index: Int) {\n            self.type = type\n            self.indexedKeys = [key.hashValue: index]\n        }\n    }\n\n    private var generators: [String: Generator]?\n\n    private func getGenerators() throws -> [String: Generator] {\n        guard generators == nil else {\n            return generators!\n        }\n        var mappedKeys: [String: TypedIndexedKeys] = [:]\n        let prepareStatement = try getOrCreatePrepareStatement()\n        for (index, key) in keys.enumerated() {\n            let tableName = prepareStatement.columnTableName(atIndex: index)\n            var typedIndexedKeys: TypedIndexedKeys! = mappedKeys[tableName]\n            if typedIndexedKeys == nil {\n                let tableDecodableType = key.rootType as? TableDecodableBase.Type\n                assert(tableDecodableType != nil,\n                       \"\\(key.rootType) must conform to TableDecodable protocol.\")\n                typedIndexedKeys = TypedIndexedKeys(tableDecodableType!, key: key.stringValue, index: index)\n            } else {\n                typedIndexedKeys.indexedKeys[key.stringValue.hashValue] = index\n            }\n            mappedKeys[tableName] = typedIndexedKeys\n        }\n        var tempGenerators: [String: Generator] = [:]\n        for (tableName, typedIndexedKey) in mappedKeys {\n            let decoder = TableDecoder(typedIndexedKey.indexedKeys, on: prepareStatement)\n            let type = typedIndexedKey.type\n            let generator = { () throws -> TableDecodableBase in\n                return try type.init(from: decoder)\n            }\n            tempGenerators[tableName] = generator\n        }\n        generators = tempGenerators\n        return tempGenerators\n    }\n\n    private func extractMultiObject() throws -> [String: Any] {\n        var multiObject: [String: Any] = [:]\n#if WCDB_SWIFT_BRIDGE_OBJC\n        if properties[0].isSwiftProperty() {\n            for (tableName, generator) in try getGenerators() {\n                multiObject[tableName] = try generator()\n            }\n        } else {\n            let prepareStatement = try getOrCreatePrepareStatement()\n            multiObject = WCTAPIBridge.extractMultiObject(onResultColumns: properties.asWCTBridgeProperties(), from: prepareStatement.getRawStatement())!\n        }\n#else\n        assert(properties[0].isSwiftProperty())\n        for (tableName, generator) in try getGenerators() {\n            multiObject[tableName] = try generator()\n        }\n#endif\n        return multiObject\n    }\n\n    /// Get next selected object. You can do an iteration using it.\n    ///\n    ///     while let multiObject = try self.nextMultiObject() {\n    ///         let object1 = multiObject[tableName1]\n    ///         let object2 = multiObject[tableName2]\n    ///         //...\n    ///     }\n    ///\n    /// - Returns: Mapping from table name to object. Nil means the end of iteration.\n    /// - Throws: `Error`\n    public func nextMultiObject() throws -> [String: Any]? {\n        _ = try getOrCreatePrepareStatement()\n        guard try next() else {\n            return nil\n        }\n        return try extractMultiObject()\n    }\n\n    /// Get all selected objects.\n    ///\n    /// - Returns: Array contained mapping from table name to object.\n    /// - Throws: `Error`\n    public func allMultiObjects() throws -> [[String: Any]] {\n        var multiObjects: [[String: Any]] = []\n        _ = try getOrCreatePrepareStatement()\n        while try next() {\n            multiObjects.append(try extractMultiObject())\n        }\n        return multiObjects\n    }\n}\n"
  },
  {
    "path": "src/swift/core/chaincall/RowSelect.swift",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport Foundation\n#if SWIFT_PACKAGE\nimport WCDB_Private\n#elseif WCDB_SWIFT_TARGET\nimport WCDBSwift.Private\n#else\nimport WCDB.Private\n#endif\n\n/// Chain call for row-selecting\npublic final class RowSelect: Selectable {\n    init(with handle: Handle,\n         results resultColumnConvertibleList: [ResultColumnConvertible],\n         tables: [String],\n         isDistinct: Bool) {\n        let statement = StatementSelect().select(distinct: isDistinct, resultColumnConvertibleList).from(tables)\n        super.init(with: handle, statement: statement)\n    }\n\n    /// Get next selected row. You can do an iteration using it.\n    ///\n    ///     while let row = try rowSelect.nextRow() {\n    ///         print(row[0].int32Value)\n    ///         print(row[1].int64Value)\n    ///         print(row[2].doubleValue)\n    ///         print(row[3].stringValue)\n    ///     }\n    ///\n    /// - Returns: Array with `Value`. Nil means the end of iteration.\n    /// - Throws: `Error`\n    public func nextRow() throws -> OneRowValue? {\n        let prepareStatement = try getOrCreatePrepareStatement()\n        guard try next() else {\n            return nil\n        }\n        return prepareStatement.oneRowValue()\n    }\n\n    /// Get all selected row.\n    ///\n    /// - Returns: Array with `Array<Value>`\n    /// - Throws: `Error`\n    public func allRows() throws -> MultiRowsValue {\n        var rows: [[Value]] = []\n        let prepareStatement = try getOrCreatePrepareStatement()\n        while try next() {\n            rows.append(prepareStatement.oneRowValue())\n        }\n        return rows\n    }\n\n    /// Get next selected value. You can do an iteration using it.\n    ///\n    ///     while let value = try nextValue() {\n    ///         print(value.int32Value)\n    ///     }\n    ///\n    /// - Returns: `Value`. Nil means the end of iteration.\n    /// - Throws: `Error`\n    public func nextValue() throws -> Value? {\n        let prepareStatement = try getOrCreatePrepareStatement()\n        guard try next() else {\n            return nil\n        }\n        return prepareStatement.value(atIndex: 0)\n    }\n\n    /// Get all selected values.\n    ///\n    /// - Returns: Array with `Value`.\n    /// - Throws: `Error`\n    public func allValues() throws -> OneColumnValue {\n        let prepareStatement = try getOrCreatePrepareStatement()\n        return try prepareStatement.oneColumnValue(atIndex: 0)\n    }\n}\n"
  },
  {
    "path": "src/swift/core/chaincall/Select+WCTTableCoding.swift",
    "content": "//\n// Created by qiuwenchen on 2022/11/13.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#if WCDB_SWIFT_BRIDGE_OBJC\n\nimport Foundation\n#if SWIFT_PACKAGE\nimport WCDB_Private\n#elseif WCDB_SWIFT_TARGET\nimport WCDBSwift.Private\n#else\nimport WCDB.Private\n#endif\n\npublic extension Select {\n    /// Get next selected object with type. You can do an iteration using it.\n    ///\n    /// - Parameter type: Type of table decodable object\n    /// - Returns: Table decodable object. Nil means the end of iteration.\n    /// - Throws: `Error`\n    func nextObject<Object: WCTTableCoding>(of type: Object.Type = Object.self) throws -> Object? {\n        assert(!properties[0].isSwiftProperty(), \"Properties must belong to objc obj.\")\n        let prepareStatement = try getOrCreatePrepareStatement()\n        guard try next() else {\n            return nil\n        }\n        return WCTAPIBridge.extractObject(onResultColumns: properties.asWCTBridgeProperties(), from: prepareStatement.getRawStatement()) as? Object\n    }\n\n    /// Get all selected objects.\n    ///\n    /// - Parameter type: Type of table decodable object\n    /// - Returns: Table decodable objects.\n    /// - Throws: `Error`\n    func allObjects<Object: WCTTableCoding>(of type: Object.Type = Object.self) throws -> [Object] {\n        assert(!properties[0].isSwiftProperty(), \"Properties must belong to objc obj.\")\n        let prepareStatement = try getOrCreatePrepareStatement()\n        var objects: [Object] = []\n        while try next() {\n            if let obj = WCTAPIBridge.extractObject(onResultColumns: properties.asWCTBridgeProperties(), from: prepareStatement.getRawStatement()) {\n                objects.append(obj as! Object)\n            }\n        }\n        return objects\n    }\n}\n\n#endif\n"
  },
  {
    "path": "src/swift/core/chaincall/Select.swift",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport Foundation\n#if SWIFT_PACKAGE\nimport WCDB_Private\n#elseif WCDB_SWIFT_TARGET\nimport WCDBSwift.Private\n#else\nimport WCDB.Private\n#endif\n\npublic final class Select: Selectable {\n    internal let properties: [PropertyConvertible]\n    private lazy var keys: [CodingTableKeyBase] = {\n        self.properties.asCodingTableKeys()\n    }()\n\n    private var decoder: TableDecoder?\n\n    private func getDecoder() throws -> TableDecoder {\n        guard decoder == nil else {\n            return decoder!\n        }\n        decoder = TableDecoder(keys, on: try getOrCreatePrepareStatement())\n        return decoder!\n    }\n\n    init(with handle: Handle, on propertyConvertibleList: [PropertyConvertible], table: String, isDistinct: Bool) {\n        // TODO: Use generic to check all coding table keys conform to same root type\n        assert(propertyConvertibleList.count > 0, \"Property list must not be empty.\")\n        properties = propertyConvertibleList\n        let statement = StatementSelect().select(distinct: isDistinct, propertyConvertibleList).from(table)\n        super.init(with: handle, statement: statement)\n    }\n\n    /// Get next selected object according to the `CodingTableKey`. You can do an iteration using it.\n    ///\n    /// - Returns: Table decodable object according to the `CodingTableKey`. Nil means the end of iteration.\n    /// - Throws: `Error`\n    public func nextObject() throws -> Any? {\n        let prepareStatement = try getOrCreatePrepareStatement()\n#if WCDB_SWIFT_BRIDGE_OBJC\n        if properties[0].isSwiftProperty() {\n            guard try next() else {\n                return nil\n            }\n            let rootType = keys[0].rootType as? TableDecodableBase.Type\n            assert(rootType != nil, \"\\(keys[0].rootType) must conform to TableDecodable protocol.\")\n            return try rootType!.init(from: try getDecoder())\n        } else {\n            guard try next() else {\n                return nil\n            }\n            return WCTAPIBridge.extractObject(onResultColumns: properties.asWCTBridgeProperties(), from: prepareStatement.getRawStatement())\n        }\n#else\n        assert(properties[0].isSwiftProperty())\n        let rootType = keys[0].rootType as? TableDecodableBase.Type\n        assert(rootType != nil, \"\\(keys[0].rootType) must conform to TableDecodable protocol.\")\n        guard try next() else {\n            return nil\n        }\n        return try rootType!.init(from: try getDecoder())\n#endif\n    }\n\n    /// Get all selected objects according to the `CodingTableKey`.\n    ///\n    /// - Returns: Table decodable objects according to the `CodingTableKey`\n    /// - Throws: `Error`\n    public func allObjects() throws -> [Any] {\n        let prepareStatement = try getOrCreatePrepareStatement()\n        var objects: [Any] = []\n#if WCDB_SWIFT_BRIDGE_OBJC\n        if properties[0].isSwiftProperty() {\n            let rootType = keys[0].rootType as? TableDecodableBase.Type\n            assert(rootType != nil, \"\\(keys[0].rootType) must conform to TableDecodable protocol.\")\n            while try next() {\n                objects.append(try rootType!.init(from: try getDecoder()))\n            }\n        } else {\n            while try next() {\n                if let obj = WCTAPIBridge.extractObject(onResultColumns: properties.asWCTBridgeProperties(), from: prepareStatement.getRawStatement()) {\n                    objects.append(obj)\n                }\n            }\n        }\n#else\n        assert(properties[0].isSwiftProperty())\n        let rootType = keys[0].rootType as? TableDecodableBase.Type\n        assert(rootType != nil, \"\\(keys[0].rootType) must conform to TableDecodable protocol.\")\n        while try next() {\n            objects.append(try rootType!.init(from: try getDecoder()))\n        }\n#endif\n        return objects\n    }\n\n    /// Get next selected object with type. You can do an iteration using it.\n    ///\n    /// - Parameter type: Type of table decodable object\n    /// - Returns: Table decodable object. Nil means the end of iteration.\n    /// - Throws: `Error`\n    public func nextObject<Object: TableDecodable>(of type: Object.Type = Object.self) throws -> Object? {\n        assert(keys is [Object.CodingKeys], \"Properties must belong to \\(Object.self).CodingKeys.\")\n        let prepareStatement = try getOrCreatePrepareStatement()\n        guard try next() else {\n            return nil\n        }\n        return try Object.init(from: try getDecoder())\n    }\n\n    /// Get all selected objects.\n    ///\n    /// - Parameter type: Type of table decodable object\n    /// - Returns: Table decodable objects.\n    /// - Throws: `Error`\n    public func allObjects<Object: TableDecodable>(of type: Object.Type = Object.self) throws -> [Object] {\n        assert(keys is [Object.CodingKeys], \"Properties must belong to \\(Object.self).CodingKeys.\")\n        _ = try getOrCreatePrepareStatement()\n        var objects: [Object] = []\n        while try next() {\n            objects.append(try Object.init(from: try getDecoder()))\n        }\n        return objects\n    }\n}\n"
  },
  {
    "path": "src/swift/core/chaincall/Selectable.swift",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport Foundation\n#if SWIFT_PACKAGE\nimport WCDB_Private\n#elseif WCDB_SWIFT_TARGET\nimport WCDBSwift.Private\n#else\nimport WCDB.Private\n#endif\n\npublic class Selectable {\n    public final let statement: StatementSelect\n    private final var handle: Handle\n    private final var preparedStatement: PreparedStatement?\n\n    init(with handle: Handle, statement: StatementSelect) {\n        self.statement = statement\n        self.handle = handle\n    }\n\n    deinit {\n        handle.finalize()\n    }\n\n    final func getOrCreatePrepareStatement() throws -> PreparedStatement {\n        if preparedStatement == nil {\n            preparedStatement = try handle.getOrCreatePreparedStatement(with: statement)\n            return preparedStatement!\n        } else {\n            return preparedStatement!\n        }\n    }\n\n    // Since `next()` may throw errors, it can't conform to `Sequence` protocol to fit a `for in` loop.\n    @discardableResult\n    public final func next() throws -> Bool {\n        do {\n            return try preparedStatement!.step()\n        } catch let error {\n            preparedStatement?.finalize()\n            throw error\n        }\n    }\n\n    /// WINQ interface\n    ///\n    /// - Parameter condition: Expression convertible\n    /// - Returns: `self`\n    @discardableResult\n    public final func `where`(_ condition: Condition) -> Self {\n        statement.where(condition)\n        return self\n    }\n\n    /// WINQ interface for SQL\n    ///\n    /// - Parameter orderList: Order convertible list\n    /// - Returns: `self`\n    @discardableResult\n    public final func order(by orderConvertibleList: OrderBy...) -> Self {\n        return order(by: orderConvertibleList)\n    }\n\n    /// WINQ interface for SQL\n    ///\n    /// - Parameter orderList: Order convertible list\n    /// - Returns: `self`\n    @discardableResult\n    public final func order(by orderConvertibleList: [OrderBy]) -> Self {\n        statement.order(by: orderConvertibleList)\n        return self\n    }\n\n    /// WINQ interface for SQL\n    ///\n    /// - Parameters:\n    ///   - begin: Expression convertible\n    ///   - end: Expression convertible\n    /// - Returns: `self`\n    @discardableResult\n    public final func limit(from begin: Limit, to end: Limit) -> Self {\n        statement.limit(from: begin, to: end)\n        return self\n    }\n\n    @discardableResult\n    public final func limit(_ expressionConvertibleLimit: Limit) -> Self {\n        statement.limit(expressionConvertibleLimit)\n        return self\n    }\n\n    @discardableResult\n    public final func limit(_ expressionConvertibleLimit: Limit, offset expressionConvertibleOffset: Offset) -> Self {\n        statement.limit(expressionConvertibleLimit).offset(expressionConvertibleOffset)\n        return self\n    }\n\n    @discardableResult\n    public final func group(by expressionConvertibleGroupList: GroupBy...) -> Self {\n        return group(by: expressionConvertibleGroupList)\n    }\n\n    @discardableResult\n    public final func group(by expressionConvertibleGroupList: [GroupBy]) -> Self {\n        statement.group(by: expressionConvertibleGroupList)\n        return self\n    }\n\n    @discardableResult\n    public final func having(_ expressionConvertibleHaving: Having) -> Self {\n        statement.having(expressionConvertibleHaving)\n        return self\n    }\n}\n"
  },
  {
    "path": "src/swift/core/chaincall/TableChainCall+WCTTableCoding.swift",
    "content": "//\n// Created by qiuwenchen on 2023/4/27.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#if WCDB_SWIFT_BRIDGE_OBJC\n\nimport Foundation\n#if SWIFT_PACKAGE\nimport WCDB_Private\n#elseif WCDB_SWIFT_TARGET\nimport WCDBSwift.Private\n#else\nimport WCDB.Private\n#endif\n\n/// ChainCall interface for inserting\npublic protocol TableInsertChainCallInterfaceForObjc: AnyObject {\n\n    /// Prepare chain call for inserting of `WCTTableCoding` object\n    ///\n    /// - Parameters:\n    ///   - cls: Type of table object\n    /// - Returns: `Insert`\n    func prepareInsert<Root: WCTTableCoding>(of cls: Root.Type) throws -> Insert\n\n    /// Prepare chain call for inserting or replacing of `WCTTableCoding` object\n    ///\n    /// - Parameters:\n    ///   - cls: Type of table object\n    /// - Returns: `Insert`\n    func prepareInsertOrReplace<Root: WCTTableCoding>(of cls: Root.Type) throws -> Insert\n\n    /// Prepare chain call for inserting or ignoring of `WCTTableCoding` object\n    ///\n    /// - Parameters:\n    ///   - cls: Type of table object\n    /// - Returns: `Insert`\n    func prepareInsertOrIgnore<Root: WCTTableCoding>(of cls: Root.Type) throws -> Insert\n}\n\n/// ChainCall interface for selecting\npublic protocol TableSelectChainCallInterfaceForObjc: AnyObject {\n\n    /// Prepare chain call for selecting of `TableDecodable` object\n    ///\n    /// - Parameters:\n    ///   - cls: Type of table decodable object\n    ///   - isDistinct: Is distinct or not\n    /// - Returns: `Select`\n    func prepareSelect<Root: WCTTableCoding>(of cls: Root.Type,\n                                             isDistinct: Bool) throws -> Select\n}\n\n#endif\n"
  },
  {
    "path": "src/swift/core/chaincall/TableChainCall.swift",
    "content": "//\n// Created by qiuwenchen on 2023/4/27.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport Foundation\n\n/// ChainCall interface for inserting in Table\npublic protocol TableInsertChainCallInterface: AnyObject {\n\n    /// Prepare chain call for inserting of `TableEncodable` object\n    ///\n    /// - Parameters:\n    ///   - cls: Type of table object\n    /// - Returns: `Insert`\n    func prepareInsert<Root: TableEncodable>(of cls: Root.Type) throws -> Insert\n\n    /// Prepare chain call for inserting or replacing of `TableEncodable` object\n    ///\n    /// - Parameters:\n    ///   - cls: Type of table object\n    /// - Returns: `Insert`\n    func prepareInsertOrReplace<Root: TableEncodable>(of cls: Root.Type) throws -> Insert\n\n    /// Prepare chain call for inserting or ignoring of `TableEncodable` object\n    ///\n    /// - Parameters:\n    ///   - cls: Type of table object\n    /// - Returns: `Insert`\n    func prepareInsertOrIgnore<Root: TableEncodable>(of cls: Root.Type) throws -> Insert\n\n    /// Prepare chain call for inserting on specific properties\n    ///\n    /// - Parameters:\n    ///   - propertyConvertibleList: `Property` or `CodingTableKey` list\n    /// - Returns: `Insert`\n    func prepareInsert(on propertyConvertibleList: PropertyConvertible...) throws -> Insert\n\n    /// Prepare chain call for inserting or replacing on specific properties\n    ///\n    /// - Parameters:\n    ///   - propertyConvertibleList: `Property` or `CodingTableKey` list\n    /// - Returns: `Insert`\n    func prepareInsertOrReplace(on propertyConvertibleList: PropertyConvertible...) throws -> Insert\n\n    /// Prepare chain call for inserting or ignoring on specific properties\n    ///\n    /// - Parameters:\n    ///   - propertyConvertibleList: `Property` or `CodingTableKey` list\n    /// - Returns: `Insert`\n    func prepareInsertOrIgnore(on propertyConvertibleList: PropertyConvertible...) throws -> Insert\n\n    /// Prepare chain call for inserting on specific properties\n    ///\n    /// - Parameters:\n    ///   - propertyConvertibleList: `Property` or `CodingTableKey` list\n    /// - Returns: `Insert`\n    func prepareInsert(on propertyConvertibleList: [PropertyConvertible]) throws -> Insert\n\n    /// Prepare chain call for inserting or replacing on specific properties\n    ///\n    /// - Parameters:\n    ///   - propertyConvertibleList: `Property` or `CodingTableKey` list\n    /// - Returns: `Insert`\n    func prepareInsertOrReplace(on propertyConvertibleList: [PropertyConvertible]) throws -> Insert\n\n    /// Prepare chain call for inserting or ignoring on specific properties\n    ///\n    /// - Parameters:\n    ///   - propertyConvertibleList: `Property` or `CodingTableKey` list\n    /// - Returns: `Insert`\n    func prepareInsertOrIgnore(on propertyConvertibleList: [PropertyConvertible]) throws -> Insert\n}\n\n/// ChainCall interface for deleting in Table\npublic protocol TableDeleteChainCallInterface: AnyObject {\n\n    /// Prepare chain call for deleting on specific properties\n    ///\n    /// - Returns: `Delete`\n    func prepareDelete() throws -> Delete\n}\n\n/// ChainCall interface for updating in Table\npublic protocol TableUpdateChainCallInterface: AnyObject {\n\n    /// Prepare chain call for updating on specific properties\n    ///\n    /// - Parameters:\n    ///   - propertyConvertibleList: `Property` or `CodingTableKey` list\n    /// - Returns: `Update`\n    func prepareUpdate(on propertyConvertibleList: PropertyConvertible...) throws -> Update\n\n    /// Prepare chain call for updating on specific properties\n    ///\n    /// - Parameters:\n    ///   - propertyConvertibleList: `Property` or `CodingTableKey` list\n    /// - Returns: `Update`\n    func prepareUpdate(on propertyConvertibleList: [PropertyConvertible]) throws -> Update\n}\n\n/// ChainCall interface for row-selecting in Table\npublic protocol TableRowSelectChainCallInterface: AnyObject {\n    /// Prepare chain call for row-selecting on specific column results\n    ///\n    /// - Parameters:\n    ///   - resultColumnConvertibleList: `ResultColumn` list\n    ///   - isDistinct: Is distinct or not\n    /// - Returns: `RowSelect`\n    func prepareRowSelect(on resultColumnConvertibleList: ResultColumnConvertible...,\n                          isDistinct: Bool) throws -> RowSelect\n\n    /// Prepare chain call for row-selecting on specific column results\n    ///\n    /// - Parameters:\n    ///   - resultColumnConvertibleList: `ResultColumn` list\n    ///   - isDistinct: Is distinct or not\n    /// - Returns: `RowSelect`\n    func prepareRowSelect(on resultColumnConvertibleList: [ResultColumnConvertible],\n                          isDistinct: Bool) throws -> RowSelect\n}\n\n/// ChainCall interface for selecting in Table\npublic protocol TableSelectChainCallInterface: AnyObject {\n\n    /// Prepare chain call for selecting of `TableDecodable` object\n    ///\n    /// - Parameters:\n    ///   - cls: Type of table decodable object\n    ///   - isDistinct: Is distinct or not\n    /// - Returns: `Select`\n    func prepareSelect<Root: TableDecodable>(of cls: Root.Type,\n                                             isDistinct: Bool) throws -> Select\n\n    /// Prepare chain call for selecting on specific properties\n    ///\n    /// - Parameters:\n    ///   - propertyConvertibleList: `Property` or `CodingTableKey` list\n    ///   - isDistinct: Is distinct or not\n    /// - Returns: `Select`\n    func prepareSelect(on propertyConvertibleList: PropertyConvertible...,\n                       isDistinct: Bool) throws -> Select\n\n    /// Prepare chain call for selecting on specific properties\n    ///\n    /// - Parameters:\n    ///   - propertyConvertibleList: `Property` or `CodingTableKey` list\n    ///   - isDistinct: Is distinct or not\n    /// - Returns: `Select`\n    func prepareSelect(on propertyConvertibleList: [PropertyConvertible],\n                       isDistinct: Bool) throws -> Select\n}\n"
  },
  {
    "path": "src/swift/core/chaincall/Update+WCTTableCoding.swift",
    "content": "//\n// Created by qiuwenchen on 2022/11/13.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#if WCDB_SWIFT_BRIDGE_OBJC\n\nimport Foundation\n#if SWIFT_PACKAGE\nimport WCDB_Private\n#elseif WCDB_SWIFT_TARGET\nimport WCDBSwift.Private\n#else\nimport WCDB.Private\n#endif\n\npublic extension Update {\n    func execute<Object: WCTTableCoding>(with object: Object) throws {\n        try handle.prepare(statement)\n        WCTAPIBridge.bindProperties(properties.asWCTBridgeProperties(), ofObject: object, with: handle.getRawStatement())\n        try handle.step()\n        changes = handle.changes\n        handle.finalize()\n    }\n}\n\n#endif\n"
  },
  {
    "path": "src/swift/core/chaincall/Update.swift",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport Foundation\n#if SWIFT_PACKAGE\nimport WCDB_Private\n#elseif WCDB_SWIFT_TARGET\nimport WCDBSwift.Private\n#else\nimport WCDB.Private\n#endif\n\n/// The chain call for updating\npublic final class Update {\n    internal var handle: Handle\n    public final let statement = StatementUpdate()\n    internal let properties: [PropertyConvertible]\n    private lazy var keys: [CodingTableKeyBase] = {\n        self.properties.asCodingTableKeys()\n    }()\n\n    /// The number of changed rows in the most recent call.\n    /// It should be called after executing successfully\n    public var changes: Int?\n\n    init(with handle: Handle, on propertyConvertibleList: [PropertyConvertible], andTable table: String) {\n        self.properties = propertyConvertibleList\n        self.handle = handle\n        self.statement.update(table: table)\n        var bindIndex: Int32 = 1\n        for property in properties {\n            self.statement.set(property).to(BindParameter(bindIndex))\n            bindIndex += 1\n        }\n    }\n\n    /// WINQ interface for SQL\n    ///\n    /// - Parameter condition: Expression convertible\n    /// - Returns: `self`\n    @discardableResult\n    public func `where`(_ condition: Condition) -> Update {\n        statement.where(condition)\n        return self\n    }\n\n    /// WINQ interface for SQL\n    ///\n    /// - Parameter orderList: Order convertible list\n    /// - Returns: `self`\n    @discardableResult\n    public func order(by orderList: OrderBy...) -> Update {\n        statement.order(by: orderList)\n        return self\n    }\n\n    /// WINQ interface for SQL\n    ///\n    /// - Parameter orderList: Order convertible list\n    /// - Returns: `self`\n    @discardableResult\n    public func order(by orderList: [OrderBy]) -> Update {\n        statement.order(by: orderList)\n        return self\n    }\n\n    /// WINQ interface for SQL\n    ///\n    /// - Parameters:\n    ///   - begin: Expression convertible\n    ///   - end: Expression convertible\n    /// - Returns: `self`\n    @discardableResult\n    public func limit(from begin: Limit, to end: Limit) -> Update {\n        statement.limit(from: begin, to: end)\n        return self\n    }\n\n    /// WINQ interface for SQL\n    ///\n    /// - Parameter limit: Expression convertible\n    /// - Returns: `self`\n    @discardableResult\n    public func limit(_ limit: Limit) -> Update {\n        statement.limit(limit)\n        return self\n    }\n\n    /// WINQ interface for SQL\n    ///\n    /// - Parameters:\n    ///   - limit: Expression convertible\n    ///   - offset: Expression convertible\n    /// - Returns: `self`\n    @discardableResult\n    public func limit(_ limit: Limit, offset: Offset) -> Update {\n        statement.limit(limit).offset(offset)\n        return self\n    }\n\n    /// Execute the update chain call with object.\n    ///\n    /// - Parameter object: Table encodable object\n    /// - Throws: `Error`\n    public func execute<Object: TableEncodable>(with object: Object) throws {\n        try handle.prepare(statement)\n        let encoder = TableEncoder(keys, on: handle)\n        try object.encode(to: encoder)\n        try handle.step()\n        changes = handle.changes\n        handle.finalize()\n    }\n\n    /// Execute the update chain call with row.\n    ///\n    /// - Parameter row: Column encodable row\n    /// - Throws: `Error`\n    public func execute(with row: [ColumnEncodable?]) throws {\n        try handle.prepare(statement)\n        for (index, value) in row.enumerated() {\n            let bindingIndex = index + 1\n            if let archivedValue = value?.archivedValue() {\n                handle.bind(archivedValue, toIndex: bindingIndex)\n            } else {\n                handle.bind(nil, toIndex: bindingIndex)\n            }\n        }\n        try handle.step()\n        changes = handle.changes\n        handle.finalize()\n    }\n}\n"
  },
  {
    "path": "src/swift/core/codable/CodingTableKey.swift",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport Foundation\n#if SWIFT_PACKAGE\nimport WCDB_Private\n#elseif WCDB_SWIFT_TARGET\nimport WCDBSwift.Private\n#else\nimport WCDB.Private\n#endif\n\npublic protocol CodingTableKeyBase: CodingKey {\n    var rootType: TableCodableBase.Type {get}\n}\n\npublic protocol CodingTableKey: CodingTableKeyBase,\n    Hashable,\n    PropertyOperable,\n    RawRepresentable where RawValue == String {\n    associatedtype Root: TableCodableBase\n\n    static var all: [Property] {get}\n    static var any: Column {get}\n\n    static var objectRelationalMapping: TableBinding<Self> {get}\n\n    typealias BindColumnConstraint = ColumnConstraintConfig<Self>\n    typealias BindIndex = IndexConfig<Self>\n    typealias BindMultiPrimary = MultiPrimaryConfig<Self>\n    typealias BindMultiUnique = MultiUniqueConfig<Self>\n    typealias BindChecks = CheckExpressionConfig\n    typealias BindForeginKey = ForeignKeyConfig<Self>\n    typealias BindVirtualTable = VirtualTableConfig\n}\n\nextension CodingTableKey {\n    public var rootType: TableCodableBase.Type {\n        return Root.self\n    }\n}\n\nextension CodingTableKey {\n    public static var all: [Property] {\n        return objectRelationalMapping.allProperties\n    }\n    public static var any: Column {\n        return Column.all()\n    }\n}\n\nextension CodingTableKey {\n    public func isSwiftProperty() -> Bool {\n        return true\n    }\n\n    public var codingTableKey: CodingTableKeyBase? {\n        return self\n    }\n#if WCDB_SWIFT_BRIDGE_OBJC\n    public var wctProperty: WCTBridgeProperty? {\n        return nil\n    }\n#endif\n    public func `as`(_ propertyConvertible: PropertyConvertible) -> Property {\n        return Property(named: stringValue, with: propertyConvertible.codingTableKey)\n    }\n\n    public func asProperty() -> Property {\n        return Self.objectRelationalMapping.property(from: self)\n    }\n\n    public func `in`(table: String) -> Property {\n        return asProperty().`in`(table: table)\n    }\n\n    public func of(schema schemaConvertible: SchemaConvertible) -> Property {\n        return asProperty().of(schema: schemaConvertible)\n    }\n\n    public func asExpression() -> Expression {\n        return asColumn().asExpression()\n    }\n\n    public func asColumn() -> Column {\n        return asProperty().asColumn()\n    }\n}\n"
  },
  {
    "path": "src/swift/core/codable/ColumnCodable.swift",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport Foundation\n#if SWIFT_PACKAGE\nimport WCDB_Private\n#elseif WCDB_SWIFT_TARGET\nimport WCDBSwift.Private\n#else\nimport WCDB.Private\n#endif\n\n// Column \npublic protocol ColumnCodableBase {\n    static var columnType: ColumnType {get}\n}\n\npublic protocol ColumnEncodable: Encodable, ColumnCodableBase {\n    func archivedValue() -> Value\n}\npublic extension ColumnEncodable where Self: LiteralValueConvertible {\n    func asLiteralValue() -> LiteralValue {\n        return LiteralValue(self)\n    }\n}\n\npublic protocol ColumnDecodable: Decodable, ColumnCodableBase {\n    init?(with value: Value)\n}\n\npublic typealias ColumnCodable = ColumnEncodable & ColumnDecodable\n"
  },
  {
    "path": "src/swift/core/codable/ColumnTypeDecoder.swift",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport Foundation\n#if SWIFT_PACKAGE\nimport WCDB_Private\n#elseif WCDB_SWIFT_TARGET\nimport WCDBSwift.Private\n#else\nimport WCDB.Private\n#endif\n\ninternal final class ColumnTypeDecoder: Decoder {\n\n    private var results: [String: ColumnType] = [:]\n\n    internal static func types(of type: TableDecodableBase.Type) -> [String: ColumnType] {\n        let decoder = ColumnTypeDecoder()\n        _ = try? type.init(from: decoder)\n        return decoder.results\n    }\n\n    internal func container<Key>(keyedBy type: Key.Type) throws -> KeyedDecodingContainer<Key> where Key: CodingKey {\n        return KeyedDecodingContainer(ColumnTypeDecodingContainer<Key>(with: self))\n    }\n\n    private final class ColumnTypeDecodingContainer<CodingKeys: CodingKey>: KeyedDecodingContainerProtocol {\n\n        internal typealias Key = CodingKeys\n\n        private let decoder: ColumnTypeDecoder\n\n        private struct SizedPointer {\n            private let pointer: UnsafeMutableRawPointer\n            private let size: Int\n            init<T>(of type: T.Type = T.self) {\n                size = MemoryLayout<T>.size\n                pointer = UnsafeMutableRawPointer.allocate(byteCount: size, alignment: 1)\n                memset(pointer, 0, size)\n            }\n            internal func deallocate() {\n                pointer.deallocate()\n            }\n            internal func getPointee<T>(of type: T.Type = T.self) -> T {\n                return pointer.assumingMemoryBound(to: type).pointee\n            }\n        }\n\n        private var sizedPointers: ContiguousArray<SizedPointer>\n\n        internal init(with decoder: ColumnTypeDecoder) {\n            self.decoder = decoder\n            self.sizedPointers = ContiguousArray<SizedPointer>()\n        }\n\n        deinit {\n            for sizedPointer in sizedPointers {\n                sizedPointer.deallocate()\n            }\n        }\n\n        internal func contains(_ key: Key) -> Bool {\n            return true\n        }\n\n        internal func decodeNil(forKey key: Key) throws -> Bool {\n            decoder.results[key.stringValue] = Bool.columnType\n            return false\n        }\n\n        internal func decode(_ type: Bool.Type, forKey key: Key) throws -> Bool {\n            decoder.results[key.stringValue] = type.columnType\n            return false\n        }\n\n        internal func decode(_ type: Int.Type, forKey key: Key) throws -> Int {\n            decoder.results[key.stringValue] = type.columnType\n            return 0\n        }\n\n        internal func decode(_ type: Int8.Type, forKey key: Key) throws -> Int8 {\n            decoder.results[key.stringValue] = type.columnType\n            return 0\n        }\n\n        internal func decode(_ type: Int16.Type, forKey key: Key) throws -> Int16 {\n            decoder.results[key.stringValue] = type.columnType\n            return 0\n        }\n\n        internal func decode(_ type: Int32.Type, forKey key: Key) throws -> Int32 {\n            decoder.results[key.stringValue] = type.columnType\n            return 0\n        }\n\n        internal func decode(_ type: Int64.Type, forKey key: Key) throws -> Int64 {\n            decoder.results[key.stringValue] = type.columnType\n            return 0\n        }\n\n        internal func decode(_ type: UInt.Type, forKey key: Key) throws -> UInt {\n            decoder.results[key.stringValue] = type.columnType\n            return 0\n        }\n\n        internal func decode(_ type: UInt8.Type, forKey key: Key) throws -> UInt8 {\n            decoder.results[key.stringValue] = type.columnType\n            return 0\n        }\n\n        internal func decode(_ type: UInt16.Type, forKey key: Key) throws -> UInt16 {\n            decoder.results[key.stringValue] = type.columnType\n            return 0\n        }\n\n        internal func decode(_ type: UInt32.Type, forKey key: Key) throws -> UInt32 {\n            decoder.results[key.stringValue] = type.columnType\n            return 0\n        }\n\n        internal func decode(_ type: UInt64.Type, forKey key: Key) throws -> UInt64 {\n            decoder.results[key.stringValue] = type.columnType\n            return 0\n        }\n\n        internal func decode(_ type: Float.Type, forKey key: Key) throws -> Float {\n            decoder.results[key.stringValue] = type.columnType\n            return 0\n        }\n\n        internal func decode(_ type: Double.Type, forKey key: Key) throws -> Double {\n            decoder.results[key.stringValue] = type.columnType\n            return 0\n        }\n\n        internal func decode(_ type: String.Type, forKey key: Key) throws -> String {\n            decoder.results[key.stringValue] = type.columnType\n            return \"\"\n        }\n\n        internal func decode<T>(_ type: T.Type, forKey key: Key) throws -> T where T: Decodable {\n            // `type` must conform to ColumnDecodableBase protocol\n            let columnDecodableType = type as! ColumnDecodable.Type\n            decoder.results[key.stringValue] = columnDecodableType.columnType\n\n            let sizedPointer = SizedPointer(of: T.self)\n            sizedPointers.append(sizedPointer)\n            return sizedPointer.getPointee()\n        }\n\n        var codingPath: [CodingKey] {\n            fatalError(\"It should not be called. If you think it's a bug, please report an issue to us.\")\n        }\n\n        var allKeys: [Key] {\n            fatalError(\"It should not be called. If you think it's a bug, please report an issue to us.\")\n        }\n\n        internal func nestedContainer<NestedKey>(keyedBy type: NestedKey.Type,\n                                                 forKey key: Key)\n            throws -> KeyedDecodingContainer<NestedKey> where NestedKey: CodingKey {\n            fatalError(\"It should not be called. If you think it's a bug, please report an issue to us.\")\n        }\n\n        internal func nestedUnkeyedContainer(forKey key: Key) throws -> UnkeyedDecodingContainer {\n            fatalError(\"It should not be called. If you think it's a bug, please report an issue to us.\")\n        }\n\n        internal func superDecoder() throws -> Decoder {\n            fatalError(\"It should not be called. If you think it's a bug, please report an issue to us.\")\n        }\n\n        internal func superDecoder(forKey key: Key) throws -> Decoder {\n            fatalError(\"It should not be called. If you think it's a bug, please report an issue to us.\")\n        }\n    }\n\n    internal var codingPath: [CodingKey] {\n        fatalError(\"It should not be called. If you think it's a bug, please report an issue to us.\")\n    }\n\n    internal var userInfo: [CodingUserInfoKey: Any] {\n        fatalError(\"It should not be called. If you think it's a bug, please report an issue to us.\")\n    }\n\n    internal func unkeyedContainer() throws -> UnkeyedDecodingContainer {\n        fatalError(\"It should not be called. If you think it's a bug, please report an issue to us.\")\n    }\n\n    internal func singleValueContainer() throws -> SingleValueDecodingContainer {\n        fatalError(\"It should not be called. If you think it's a bug, please report an issue to us.\")\n    }\n}\n"
  },
  {
    "path": "src/swift/core/codable/TableCodable.swift",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport Foundation\n#if SWIFT_PACKAGE\nimport WCDB_Private\n#elseif WCDB_SWIFT_TARGET\nimport WCDBSwift.Private\n#else\nimport WCDB.Private\n#endif\n\npublic protocol TableCodableBase {}\n\npublic protocol TableEncodableBase: Encodable, TableCodableBase {}\n\npublic protocol TableEncodable: TableEncodableBase where CodingKeys.Root == Self {\n    associatedtype CodingKeys: CodingTableKey\n    typealias Properties = CodingKeys\n\n    var isAutoIncrement: Bool {get}\n    var lastInsertedRowID: Int64 {get set}\n}\n\nextension TableEncodable {\n    public var isAutoIncrement: Bool {\n        return false\n    }\n\n    public var lastInsertedRowID: Int64 {\n        get { return Int64.min }\n        set { }\n    }\n}\n\npublic protocol TableDecodableBase: Decodable, TableCodableBase {}\n\npublic protocol TableDecodable: TableDecodableBase where CodingKeys.Root == Self {\n    associatedtype CodingKeys: CodingTableKey\n    typealias Properties = CodingKeys\n}\n\npublic typealias TableCodable = TableEncodable & TableDecodable\n"
  },
  {
    "path": "src/swift/core/codable/TableDecoder.swift",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport Foundation\n#if SWIFT_PACKAGE\nimport WCDB_Private\n#elseif WCDB_SWIFT_TARGET\nimport WCDBSwift.Private\n#else\nimport WCDB.Private\n#endif\n\nfinal class TableDecoder: Decoder {\n\n    private let handleStatement: StatementInterface\n\n    typealias HashedKey = [Int: Int] // hash value -> index\n    private let hashedKeys: HashedKey\n\n    private var container: Any?\n\n    init(_ codingTableKeys: [CodingTableKeyBase], on handleStatement: StatementInterface) {\n        var hashedKeys: HashedKey = [:]\n        for (index, key) in codingTableKeys.enumerated() {\n            hashedKeys[key.stringValue.hashValue] = index\n        }\n        self.hashedKeys = hashedKeys\n        self.handleStatement = handleStatement\n    }\n\n    init(_ hashedKeys: HashedKey, on handleStatement: StatementInterface) {\n        self.hashedKeys = hashedKeys\n        self.handleStatement = handleStatement\n    }\n\n    func container<Key>(keyedBy type: Key.Type) throws -> KeyedDecodingContainer<Key> where Key: CodingKey {\n        if container == nil {\n            container = KeyedDecodingContainer(KeyedDecodingTableContainer<Key>(with: hashedKeys,\n                                                                                on: handleStatement))\n        }\n        // It should not be failed. If you think it's a bug, please report an issue to us.\n        return container as! KeyedDecodingContainer<Key>\n    }\n\n    private final class KeyedDecodingTableContainer<CodingKeys: CodingKey>: KeyedDecodingContainerProtocol {\n        typealias Key = CodingKeys\n\n        private let handleStatement: StatementInterface\n\n        private let hashedKeys: HashedKey\n\n        init(with hashedKeys: HashedKey, on handleStatement: StatementInterface) {\n            self.handleStatement = handleStatement\n            self.hashedKeys = hashedKeys\n        }\n\n        private func columnIndex(by key: Key) -> Int {\n            let index = hashedKeys[key.stringValue.hashValue]\n            assert(index != nil, \"If [\\(key)] would not be decoded, please make it optional.\")\n            return index!\n        }\n\n        private func columnIndexIfPresent(by key: Key) -> Int? {\n            return hashedKeys[key.stringValue.hashValue]\n        }\n\n        func contains(_ key: Key) -> Bool {\n            return true\n        }\n\n        // Decode\n        func decodeNil(forKey key: Key) throws -> Bool {\n            let index: Int = columnIndex(by: key)\n            return handleStatement.columnValue(atIndex: index, of: Int32.self).toBool()\n        }\n\n        func decode(_ type: Bool.Type, forKey key: Key) throws -> Bool {\n            let index: Int = columnIndex(by: key)\n            return handleStatement.columnValue(atIndex: index, of: Int32.self).toBool()\n        }\n\n        func decode(_ type: Int.Type, forKey key: Key) throws -> Int {\n            let index: Int = columnIndex(by: key)\n            return handleStatement.columnValue(atIndex: index, of: Int64.self).toInt()\n        }\n\n        func decode(_ type: Int8.Type, forKey key: Key) throws -> Int8 {\n            let index: Int = columnIndex(by: key)\n            return handleStatement.columnValue(atIndex: index, of: Int32.self).toInt8()\n        }\n\n        func decode(_ type: Int16.Type, forKey key: Key) throws -> Int16 {\n            let index: Int = columnIndex(by: key)\n            return handleStatement.columnValue(atIndex: index, of: Int32.self).toInt16()\n        }\n\n        func decode(_ type: Int32.Type, forKey key: Key) throws -> Int32 {\n            let index: Int = columnIndex(by: key)\n            return handleStatement.columnValue(atIndex: index)\n        }\n\n        func decode(_ type: Int64.Type, forKey key: Key) throws -> Int64 {\n            let index: Int = columnIndex(by: key)\n            return handleStatement.columnValue(atIndex: index)\n        }\n\n        func decode(_ type: UInt.Type, forKey key: Key) throws -> UInt {\n            let index: Int = columnIndex(by: key)\n            return handleStatement.columnValue(atIndex: index, of: Int64.self).toUInt()\n        }\n\n        func decode(_ type: UInt8.Type, forKey key: Key) throws -> UInt8 {\n            let index: Int = columnIndex(by: key)\n            return handleStatement.columnValue(atIndex: index, of: Int32.self).toUInt8()\n        }\n\n        func decode(_ type: UInt16.Type, forKey key: Key) throws -> UInt16 {\n            let index: Int = columnIndex(by: key)\n            return handleStatement.columnValue(atIndex: index, of: Int32.self).toUInt16()\n        }\n\n        func decode(_ type: UInt32.Type, forKey key: Key) throws -> UInt32 {\n            let index: Int = columnIndex(by: key)\n            return handleStatement.columnValue(atIndex: index, of: Int32.self).toUInt32()\n        }\n\n        func decode(_ type: UInt64.Type, forKey key: Key) throws -> UInt64 {\n            let index: Int = columnIndex(by: key)\n            return handleStatement.columnValue(atIndex: index, of: Int64.self).toUInt64()\n        }\n\n        func decode(_ type: Float.Type, forKey key: Key) throws -> Float {\n            let index: Int = columnIndex(by: key)\n            return handleStatement.columnValue(atIndex: index, of: Double.self).toFloat()\n        }\n\n        func decode(_ type: Double.Type, forKey key: Key) throws -> Double {\n            let index: Int = columnIndex(by: key)\n            return handleStatement.columnValue(atIndex: index)\n        }\n\n        func decode(_ type: String.Type, forKey key: Key) throws -> String {\n            let index: Int = columnIndex(by: key)\n            return handleStatement.columnValue(atIndex: index)\n        }\n\n        func decode<Object>(_ type: Object.Type, forKey key: Key) throws -> Object where Object: Decodable {\n            let index: Int = columnIndex(by: key)\n            // `key` must conform to ColumnDecodable protocol.\n            let decodableType = Object.self as! ColumnDecodable.Type\n            guard let wrappedDecoded = decodableType.init(with: handleStatement.value(atIndex: index)) else {\n                throw WCDBError(level: .Error, code: .Misuse, infos: [\n                    .message: Value(\"If [\\(key)] would be decoded as nil, please make it optional.\")\n                ])\n            }\n            // It should not be failed. If you think it's a bug, please report an issue to us.\n            return wrappedDecoded as! Object\n        }\n\n        // Decode if present\n        func decodeIfPresent(_ type: Bool.Type, forKey key: Key) throws -> Bool? {\n            guard let index = columnIndexIfPresent(by: key), handleStatement.columnType(atIndex: index) != .null else {\n                return nil\n            }\n            return handleStatement.columnValue(atIndex: index, of: Int32.self).toBool()\n        }\n\n        func decodeIfPresent(_ type: Int.Type, forKey key: Key) throws -> Int? {\n            guard let index = columnIndexIfPresent(by: key), handleStatement.columnType(atIndex: index) != .null else {\n                    return nil\n            }\n            return handleStatement.columnValue(atIndex: index, of: Int64.self).toInt()\n        }\n\n        func decodeIfPresent(_ type: Int8.Type, forKey key: Key) throws -> Int8? {\n            guard let index = columnIndexIfPresent(by: key), handleStatement.columnType(atIndex: index) != .null else {\n                    return nil\n            }\n            return handleStatement.columnValue(atIndex: index, of: Int32.self).toInt8()\n        }\n\n        func decodeIfPresent(_ type: Int16.Type, forKey key: Key) throws -> Int16? {\n            guard let index = columnIndexIfPresent(by: key), handleStatement.columnType(atIndex: index) != .null else {\n                    return nil\n            }\n            return handleStatement.columnValue(atIndex: index, of: Int32.self).toInt16()\n        }\n\n        func decodeIfPresent(_ type: Int32.Type, forKey key: Key) throws -> Int32? {\n            guard let index = columnIndexIfPresent(by: key), handleStatement.columnType(atIndex: index) != .null else {\n                    return nil\n            }\n            return handleStatement.columnValue(atIndex: index)\n        }\n\n        func decodeIfPresent(_ type: Int64.Type, forKey key: Key) throws -> Int64? {\n            guard let index = columnIndexIfPresent(by: key), handleStatement.columnType(atIndex: index) != .null else {\n                    return nil\n            }\n            return handleStatement.columnValue(atIndex: index)\n        }\n\n        func decodeIfPresent(_ type: UInt.Type, forKey key: Key) throws -> UInt? {\n            guard let index = columnIndexIfPresent(by: key), handleStatement.columnType(atIndex: index) != .null else {\n                    return nil\n            }\n            return handleStatement.columnValue(atIndex: index, of: Int64.self).toUInt()\n        }\n\n        func decodeIfPresent(_ type: UInt8.Type, forKey key: Key) throws -> UInt8? {\n            guard let index = columnIndexIfPresent(by: key), handleStatement.columnType(atIndex: index) != .null else {\n                    return nil\n            }\n            return handleStatement.columnValue(atIndex: index, of: Int32.self).toUInt8()\n        }\n\n        func decodeIfPresent(_ type: UInt16.Type, forKey key: Key) throws -> UInt16? {\n            guard let index = columnIndexIfPresent(by: key), handleStatement.columnType(atIndex: index) != .null else {\n                    return nil\n            }\n            return handleStatement.columnValue(atIndex: index, of: Int32.self).toUInt16()\n        }\n\n        func decodeIfPresent(_ type: UInt32.Type, forKey key: Key) throws -> UInt32? {\n            guard let index = columnIndexIfPresent(by: key), handleStatement.columnType(atIndex: index) != .null else {\n                    return nil\n            }\n            return handleStatement.columnValue(atIndex: index, of: Int32.self).toUInt32()\n        }\n\n        func decodeIfPresent(_ type: UInt64.Type, forKey key: Key) throws -> UInt64? {\n            guard let index = columnIndexIfPresent(by: key), handleStatement.columnType(atIndex: index) != .null else {\n                    return nil\n            }\n            return handleStatement.columnValue(atIndex: index, of: Int64.self).toUInt64()\n        }\n\n        func decodeIfPresent(_ type: Float.Type, forKey key: Key) throws -> Float? {\n            guard let index = columnIndexIfPresent(by: key), handleStatement.columnType(atIndex: index) != .null else {\n                    return nil\n            }\n            return handleStatement.columnValue(atIndex: index, of: Double.self).toFloat()\n        }\n\n        func decodeIfPresent(_ type: Double.Type, forKey key: Key) throws -> Double? {\n            guard let index = columnIndexIfPresent(by: key), handleStatement.columnType(atIndex: index) != .null else {\n                    return nil\n            }\n            return handleStatement.columnValue(atIndex: index)\n        }\n\n        func decodeIfPresent(_ type: String.Type, forKey key: Key) throws -> String? {\n            guard let index = columnIndexIfPresent(by: key), handleStatement.columnType(atIndex: index) != .null else {\n                    return nil\n            }\n            return handleStatement.columnValue(atIndex: index)\n        }\n\n        func decodeIfPresent<Object>(_ type: Object.Type, forKey key: Key) throws -> Object? where Object: Decodable {\n            guard let index = columnIndexIfPresent(by: key), handleStatement.columnType(atIndex: index) != .null else {\n                    return nil\n            }\n            // `key` must conform to ColumnDecodable protocol.\n            let decodableType = Object.self as! ColumnDecodable.Type\n            guard let wrappedDecoded = decodableType.init(with: handleStatement.value(atIndex: index)) else {\n                return nil\n            }\n            // It should not be failed. If you think it's a bug, please report an issue to us.\n            return (wrappedDecoded as! Object)\n        }\n\n        var codingPath: [CodingKey] {\n            fatalError(\"It should not be called. If you think it's a bug, please report an issue to us.\")\n        }\n\n        var allKeys: [Key] {\n            fatalError(\"It should not be called. If you think it's a bug, please report an issue to us.\")\n        }\n\n        func nestedContainer<NestedKey>(keyedBy type: NestedKey.Type,\n                                        forKey key: Key) throws -> KeyedDecodingContainer<NestedKey>\n            where NestedKey: CodingKey {\n            fatalError(\"It should not be called. If you think it's a bug, please report an issue to us.\")\n        }\n\n        func nestedUnkeyedContainer(forKey key: Key) throws -> UnkeyedDecodingContainer {\n            fatalError(\"It should not be called. If you think it's a bug, please report an issue to us.\")\n        }\n\n        func superDecoder() throws -> Swift.Decoder {\n            fatalError(\"It should not be called. If you think it's a bug, please report an issue to us.\")\n        }\n\n        func superDecoder(forKey key: Key) throws -> Swift.Decoder {\n            fatalError(\"It should not be called. If you think it's a bug, please report an issue to us.\")\n        }\n    }\n\n    var codingPath: [CodingKey] {\n        fatalError(\"It should not be called. If you think it's a bug, please report an issue to us.\")\n    }\n\n    var userInfo: [CodingUserInfoKey: Any] {\n        fatalError(\"It should not be called. If you think it's a bug, please report an issue to us.\")\n    }\n\n    func unkeyedContainer() throws -> UnkeyedDecodingContainer {\n        fatalError(\"It should not be called. If you think it's a bug, please report an issue to us.\")\n    }\n\n    func singleValueContainer() throws -> SingleValueDecodingContainer {\n        fatalError(\"It should not be called. If you think it's a bug, please report an issue to us.\")\n    }\n}\n"
  },
  {
    "path": "src/swift/core/codable/TableEncoder.swift",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport Foundation\n#if SWIFT_PACKAGE\nimport WCDB_Private\n#elseif WCDB_SWIFT_TARGET\nimport WCDBSwift.Private\n#else\nimport WCDB.Private\n#endif\n\nfinal class TableEncoder: Encoder {\n\n    private var container: Any?\n    private var keyedPrimaryKeyEncodableTableContainer: KeyedPrimaryKeyEncodableTableContainer?\n\n    private let handleStatement: StatementInterface\n\n    typealias HashedKey = [Int: Int] // hash value -> index\n    private let hashedKeys: HashedKey\n\n    var primaryKeyHash: Int?\n    var isPrimaryKeyEncoded = true\n\n    init(_ codingTableKeys: [CodingTableKeyBase],\n         on handleStatement: StatementInterface) {\n        var hashedKeys: HashedKey = [:]\n        for (index, key) in codingTableKeys.enumerated() {\n            hashedKeys[key.stringValue.hashValue] = index + 1\n        }\n        self.hashedKeys = hashedKeys\n        self.handleStatement = handleStatement\n    }\n\n    init(_ hashedKeys: HashedKey, on handleStatement: StatementInterface) {\n        self.hashedKeys = hashedKeys\n        self.handleStatement = handleStatement\n    }\n\n    func container<Key>(keyedBy type: Key.Type) -> KeyedEncodingContainer<Key> where Key: CodingKey {\n        if container == nil {\n            let keyedContainer = KeyedEncodingTableContainer<Key>(with: hashedKeys,\n                                                                  on: handleStatement)\n            keyedPrimaryKeyEncodableTableContainer = keyedContainer\n            container = KeyedEncodingContainer(keyedContainer)\n        }\n        if isPrimaryKeyEncoded {\n            keyedPrimaryKeyEncodableTableContainer?.primaryKeyHash = nil\n        } else {\n            keyedPrimaryKeyEncodableTableContainer?.primaryKeyHash = primaryKeyHash\n        }\n        return container as! KeyedEncodingContainer<Key>\n    }\n\n    private class KeyedPrimaryKeyEncodableTableContainer {\n        final var primaryKeyHash: Int?\n    }\n\n    private final class KeyedEncodingTableContainer<CodingKeys: CodingKey>: KeyedPrimaryKeyEncodableTableContainer, KeyedEncodingContainerProtocol {\n        typealias Key = CodingKeys\n\n        private let handleStatement: StatementInterface\n        private let hashedKeys: HashedKey\n\n        init(with hashedKeys: HashedKey,\n             on handleStatement: StatementInterface) {\n            self.hashedKeys = hashedKeys\n            self.handleStatement = handleStatement\n            super.init()\n        }\n\n        private func bindIndex(by hashValue: Int) -> Int? {\n            return hashedKeys[hashValue]\n        }\n\n        func bindPrimaryKeyOrReturnIndex(forKey key: Key) -> Int? {\n            let hashValue = key.stringValue.hashValue\n            guard let index = bindIndex(by: hashValue) else {\n                return nil\n            }\n            guard hashValue == primaryKeyHash else {\n                return index\n            }\n            handleStatement.bind(nil, toIndex: index)\n            return nil\n        }\n\n        func encodeNil(forKey key: Key) throws {\n            guard let index = bindPrimaryKeyOrReturnIndex(forKey: key) else {\n                return\n            }\n            handleStatement.bind(nil, toIndex: index)\n        }\n\n        func encode(_ value: Int, forKey key: Key) throws {\n            guard let index = bindPrimaryKeyOrReturnIndex(forKey: key) else {\n                return\n            }\n            handleStatement.bind(value.toInt64(), toIndex: index)\n        }\n\n        func encode(_ value: Bool, forKey key: Key) throws {\n            guard let index = bindPrimaryKeyOrReturnIndex(forKey: key) else {\n                return\n            }\n            handleStatement.bind(value.toInt32(), toIndex: index)\n        }\n\n        func encode(_ value: Float, forKey key: Key) throws {\n            guard let index = bindPrimaryKeyOrReturnIndex(forKey: key) else {\n                return\n            }\n            handleStatement.bind(value.toDouble(), toIndex: index)\n        }\n\n        func encode(_ value: Double, forKey key: Key) throws {\n            guard let index = bindPrimaryKeyOrReturnIndex(forKey: key) else {\n                return\n            }\n            handleStatement.bind(value, toIndex: index)\n        }\n\n        func encode(_ value: String, forKey key: Key) throws {\n            guard let index = bindPrimaryKeyOrReturnIndex(forKey: key) else {\n                return\n            }\n            handleStatement.bind(value, toIndex: index)\n        }\n\n        func encode<Object>(_ value: Object, forKey key: Key) throws where Object: Encodable {\n            guard let index = bindPrimaryKeyOrReturnIndex(forKey: key) else {\n                return\n            }\n            // `key` must conform to ColumnEncodable protocol.\n            let encodableColumnValue = value as! ColumnEncodable\n            handleStatement.bind(encodableColumnValue.archivedValue(), toIndex: index)\n        }\n\n        func encode(_ value: Int8, forKey key: Key) throws {\n            guard let index = bindPrimaryKeyOrReturnIndex(forKey: key) else {\n                return\n            }\n            handleStatement.bind(value.toInt32(), toIndex: index)\n        }\n\n        func encode(_ value: Int16, forKey key: Key) throws {\n            guard let index = bindPrimaryKeyOrReturnIndex(forKey: key) else {\n                return\n            }\n            handleStatement.bind(value.toInt32(), toIndex: index)\n        }\n\n        func encode(_ value: Int32, forKey key: Key) throws {\n            guard let index = bindPrimaryKeyOrReturnIndex(forKey: key) else {\n                return\n            }\n            handleStatement.bind(value, toIndex: index)\n        }\n\n        func encode(_ value: Int64, forKey key: Key) throws {\n            guard let index = bindPrimaryKeyOrReturnIndex(forKey: key) else {\n                return\n            }\n            handleStatement.bind(value, toIndex: index)\n        }\n\n        func encode(_ value: UInt, forKey key: Key) throws {\n            guard let index = bindPrimaryKeyOrReturnIndex(forKey: key) else {\n                return\n            }\n            handleStatement.bind(value.toInt64(), toIndex: index)\n        }\n\n        func encode(_ value: UInt8, forKey key: Key) throws {\n            guard let index = bindPrimaryKeyOrReturnIndex(forKey: key) else {\n                return\n            }\n            handleStatement.bind(value.toInt32(), toIndex: index)\n        }\n\n        func encode(_ value: UInt16, forKey key: Key) throws {\n            guard let index = bindPrimaryKeyOrReturnIndex(forKey: key) else {\n                return\n            }\n            handleStatement.bind(value.toInt32(), toIndex: index)\n        }\n\n        func encode(_ value: UInt32, forKey key: Key) throws {\n            guard let index = bindPrimaryKeyOrReturnIndex(forKey: key) else {\n                return\n            }\n            handleStatement.bind(value.toInt32(), toIndex: index)\n        }\n\n        func encode(_ value: UInt64, forKey key: Key) throws {\n            guard let index = bindPrimaryKeyOrReturnIndex(forKey: key) else {\n                return\n            }\n            handleStatement.bind(value.toInt64(), toIndex: index)\n        }\n\n        func encodeIfPresent(_ value: Bool?, forKey key: Key) throws {\n            guard let index = bindPrimaryKeyOrReturnIndex(forKey: key) else {\n                return\n            }\n            if let wrappedValue = value {\n                handleStatement.bind(wrappedValue.toInt32(), toIndex: index)\n            } else {\n                handleStatement.bind(nil, toIndex: index)\n            }\n        }\n\n        func encodeIfPresent(_ value: Int?, forKey key: Key) throws {\n            guard let index = bindPrimaryKeyOrReturnIndex(forKey: key) else {\n                return\n            }\n            if let wrappedValue = value {\n                handleStatement.bind(wrappedValue.toInt64(), toIndex: index)\n            } else {\n                handleStatement.bind(nil, toIndex: index)\n            }\n        }\n\n        func encodeIfPresent(_ value: Int8?, forKey key: Key) throws {\n            guard let index = bindPrimaryKeyOrReturnIndex(forKey: key) else {\n                return\n            }\n            if let wrappedValue = value {\n                handleStatement.bind(wrappedValue.toInt32(), toIndex: index)\n            } else {\n                handleStatement.bind(nil, toIndex: index)\n            }\n        }\n\n        func encodeIfPresent(_ value: Int16?, forKey key: Key) throws {\n            guard let index = bindPrimaryKeyOrReturnIndex(forKey: key) else {\n                return\n            }\n            if let wrappedValue = value {\n                handleStatement.bind(wrappedValue.toInt32(), toIndex: index)\n            } else {\n                handleStatement.bind(nil, toIndex: index)\n            }\n        }\n\n        func encodeIfPresent(_ value: Int32?, forKey key: Key) throws {\n            guard let index = bindPrimaryKeyOrReturnIndex(forKey: key) else {\n                return\n            }\n            if let wrappedValue = value {\n                handleStatement.bind(wrappedValue, toIndex: index)\n            } else {\n                handleStatement.bind(nil, toIndex: index)\n            }\n        }\n\n        func encodeIfPresent(_ value: Int64?, forKey key: Key) throws {\n            guard let index = bindPrimaryKeyOrReturnIndex(forKey: key) else {\n                return\n            }\n            if let wrappedValue = value {\n                handleStatement.bind(wrappedValue, toIndex: index)\n            } else {\n                handleStatement.bind(nil, toIndex: index)\n            }\n        }\n\n        func encodeIfPresent(_ value: UInt?, forKey key: Key) throws {\n            guard let index = bindPrimaryKeyOrReturnIndex(forKey: key) else {\n                return\n            }\n            if let wrappedValue = value {\n                handleStatement.bind(wrappedValue.toInt64(), toIndex: index)\n            } else {\n                handleStatement.bind(nil, toIndex: index)\n            }\n        }\n\n        func encodeIfPresent(_ value: UInt8?, forKey key: Key) throws {\n            guard let index = bindPrimaryKeyOrReturnIndex(forKey: key) else {\n                return\n            }\n            if let wrappedValue = value {\n                handleStatement.bind(wrappedValue.toInt32(), toIndex: index)\n            } else {\n                handleStatement.bind(nil, toIndex: index)\n            }\n        }\n\n        func encodeIfPresent(_ value: UInt16?, forKey key: Key) throws {\n            guard let index = bindPrimaryKeyOrReturnIndex(forKey: key) else {\n                return\n            }\n            if let wrappedValue = value {\n                handleStatement.bind(wrappedValue.toInt32(), toIndex: index)\n            } else {\n                handleStatement.bind(nil, toIndex: index)\n            }\n        }\n\n        func encodeIfPresent(_ value: UInt32?, forKey key: Key) throws {\n            guard let index = bindPrimaryKeyOrReturnIndex(forKey: key) else {\n                return\n            }\n            if let wrappedValue = value {\n                handleStatement.bind(wrappedValue.toInt32(), toIndex: index)\n            } else {\n                handleStatement.bind(nil, toIndex: index)\n            }\n        }\n\n        func encodeIfPresent(_ value: UInt64?, forKey key: Key) throws {\n            guard let index = bindPrimaryKeyOrReturnIndex(forKey: key) else {\n                return\n            }\n            if let wrappedValue = value {\n                handleStatement.bind(wrappedValue.toInt64(), toIndex: index)\n            } else {\n                handleStatement.bind(nil, toIndex: index)\n            }\n        }\n\n        func encodeIfPresent(_ value: Float?, forKey key: Key) throws {\n            guard let index = bindPrimaryKeyOrReturnIndex(forKey: key) else {\n                return\n            }\n            if let wrappedValue = value {\n                handleStatement.bind(wrappedValue.toDouble(), toIndex: index)\n            } else {\n                handleStatement.bind(nil, toIndex: index)\n            }\n        }\n\n        func encodeIfPresent(_ value: Double?, forKey key: Key) throws {\n            guard let index = bindPrimaryKeyOrReturnIndex(forKey: key) else {\n                return\n            }\n            if let wrappedValue = value {\n                handleStatement.bind(wrappedValue, toIndex: index)\n            } else {\n                handleStatement.bind(nil, toIndex: index)\n            }\n        }\n\n        func encodeIfPresent(_ value: String?, forKey key: Key) throws {\n            guard let index = bindPrimaryKeyOrReturnIndex(forKey: key) else {\n                return\n            }\n            if let wrappedValue = value {\n                handleStatement.bind(wrappedValue, toIndex: index)\n            } else {\n                handleStatement.bind(nil, toIndex: index)\n            }\n        }\n\n        func encodeIfPresent<Object>(_ value: Object?,\n                                     forKey key: Key) throws\n            where Object: Encodable {\n                guard let index = bindPrimaryKeyOrReturnIndex(forKey: key) else {\n                    return\n                }\n            if value != nil {\n                // `key` must conform to ColumnEncodable protocol.\n                let encodableColumnValue = value! as! ColumnEncodable\n                handleStatement.bind(encodableColumnValue.archivedValue(), toIndex: index)\n            } else {\n                handleStatement.bind(nil, toIndex: index)\n            }\n        }\n\n        var codingPath: [CodingKey] {\n            fatalError(\"It should not be called. If you think it's a bug, please report an issue to us.\")\n        }\n\n        func superEncoder() -> Swift.Encoder {\n            fatalError(\"It should not be called. If you think it's a bug, please report an issue to us.\")\n        }\n\n        func superEncoder(forKey key: Key) -> Swift.Encoder {\n            fatalError(\"It should not be called. If you think it's a bug, please report an issue to us.\")\n        }\n\n        func nestedContainer<NestedKey>(keyedBy keyType: NestedKey.Type,\n                                        forKey key: Key) -> KeyedEncodingContainer<NestedKey>\n            where NestedKey: CodingKey {\n            fatalError(\"It should not be called. If you think it's a bug, please report an issue to us.\")\n        }\n\n        func nestedUnkeyedContainer(forKey key: Key) -> UnkeyedEncodingContainer {\n            fatalError(\"It should not be called. If you think it's a bug, please report an issue to us.\")\n        }\n    }\n\n    var codingPath: [CodingKey] {\n        fatalError(\"It should not be called. If you think it's a bug, please report an issue to us.\")\n    }\n\n    var userInfo: [CodingUserInfoKey: Any] {\n        fatalError(\"It should not be called. If you think it's a bug, please report an issue to us.\")\n    }\n\n    func singleValueContainer() -> SingleValueEncodingContainer {\n        fatalError(\"It should not be called. If you think it's a bug, please report an issue to us.\")\n    }\n\n    func unkeyedContainer() -> UnkeyedEncodingContainer {\n        fatalError(\"It should not be called. If you think it's a bug, please report an issue to us.\")\n    }\n}\n"
  },
  {
    "path": "src/swift/core/interface/DeleteInterface.swift",
    "content": "//\n// Created by qiuwenchen on 2022/9/13.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport Foundation\n#if SWIFT_PACKAGE\nimport WCDB_Private\n#elseif WCDB_SWIFT_TARGET\nimport WCDBSwift.Private\n#else\nimport WCDB.Private\n#endif\n\n/// Convenient interface for deleting\npublic protocol DeleteInterface: AnyObject {\n\n    /// Execute deleting\n    ///\n    /// - Parameters:\n    ///   - table: Table name\n    ///   - condition: Expression convertible\n    ///   - orderList: Order convertible list\n    ///   - limit: Expression convertible\n    ///   - offset: Expression convertible\n    /// - Throws: `Error`\n    func delete(fromTable table: String,\n                where condition: Condition?,\n                orderBy orderList: [OrderBy]?,\n                limit: Limit?,\n                offset: Offset?) throws\n}\n\nextension DeleteInterface where Self: HandleRepresentable {\n    public func delete(fromTable table: String,\n                       where condition: Condition? = nil,\n                       orderBy orderList: [OrderBy]? = nil,\n                       limit: Limit? = nil,\n                       offset: Offset? = nil) throws {\n        let delete = Delete(with: try getHandle(writeHint: true), andTableName: table)\n        if condition != nil {\n            delete.where(condition!)\n        }\n        if orderList != nil {\n            delete.order(by: orderList!)\n        }\n        if limit != nil {\n            if offset != nil {\n                delete.limit(limit!, offset: offset!)\n            } else {\n                delete.limit(limit!)\n            }\n        }\n        return try delete.execute()\n    }\n}\n"
  },
  {
    "path": "src/swift/core/interface/InsertInterface+WCTTableCoding.swift",
    "content": "//\n// Created by qiuwenchen on 2022/11/13.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#if WCDB_SWIFT_BRIDGE_OBJC\n\nimport Foundation\n#if SWIFT_PACKAGE\nimport WCDB_Private\n#elseif WCDB_SWIFT_TARGET\nimport WCDBSwift.Private\n#else\nimport WCDB.Private\n#endif\n\npublic protocol InsertInterfaceForObjc {\n    /// Execute inserting with `WCTTableCoding` object on specific(or all) properties\n    ///\n    /// Note that it will run embedded transaction while objects.count>1.\n    /// The embedded transaction means that it will run a transaction if it's not in other transaction,\n    /// otherwise it will be executed within the existing transaction.\n    ///\n    /// - Parameters:\n    ///   - objects: Table encodable object\n    ///   - propertyConvertibleList: `Property` or `CodingTableKey` list\n    ///   - table: Table name\n    /// - Throws: `Error`\n    func insert<Object: WCTTableCoding>(\n        _ objects: Object...,\n        on propertyConvertibleList: [PropertyConvertible]?,\n        intoTable table: String) throws\n\n    /// Execute inserting with `WCTTableCoding` object on specific(or all) properties\n    ///\n    /// Note that it will run embedded transaction while objects.count>1.\n    /// The embedded transaction means that it will run a transaction if it's not in other transaction,\n    /// otherwise it will be executed within the existing transaction.\n    ///\n    /// - Parameters:\n    ///   - objects: Table encodable object\n    ///   - propertyConvertibleList: `Property` or `CodingTableKey` list\n    ///   - table: Table name\n    /// - Throws: `Error`\n    func insert<Object: WCTTableCoding>(\n        _ objects: [Object],\n        on propertyConvertibleList: [PropertyConvertible]?,\n        intoTable table: String) throws\n\n    /// Execute inserting or replacing with `WCTTableCoding` object on specific(or all) properties.\n    /// It will replace the original row while they have same primary key or row id.\n    ///\n    /// Note that it will run embedded transaction while objects.count>1.\n    /// The embedded transaction means that it will run a transaction if it's not in other transaction,\n    /// otherwise it will be executed within the existing transaction.\n    ///\n    /// - Parameters:\n    ///   - objects: Table encodable object\n    ///   - propertyConvertibleList: `Property` or `CodingTableKey` list\n    ///   - table: Table name\n    /// - Throws: `Error`\n    func insertOrReplace<Object: WCTTableCoding>(\n        _ objects: Object...,\n        on propertyConvertibleList: [PropertyConvertible]?,\n        intoTable table: String) throws\n\n    /// Execute inserting or replacing with `WCTTableCoding` object on specific(or all) properties.\n    /// It will replace the original row while they have same primary key or row id.\n    ///\n    /// Note that it will run embedded transaction while objects.count>1.\n    /// The embedded transaction means that it will run a transaction if it's not in other transaction,\n    /// otherwise it will be executed within the existing transaction.\n    ///\n    /// - Parameters:\n    ///   - objects: Table encodable object\n    ///   - propertyConvertibleList: `Property` or `CodingTableKey` list\n    ///   - table: Table name\n    /// - Throws: `Error`\n    func insertOrReplace<Object: WCTTableCoding>(\n        _ objects: [Object],\n        on propertyConvertibleList: [PropertyConvertible]?,\n        intoTable table: String) throws\n\n    /// Execute inserting or ignoring with `WCTTableCoding` object on specific(or all) properties.\n    /// It will ignore the object while there already exists the same primary key or row id in current table.\n    ///\n    /// Note that it will run embedded transaction while objects.count>1.\n    /// The embedded transaction means that it will run a transaction if it's not in other transaction,\n    /// otherwise it will be executed within the existing transaction.\n    ///\n    /// - Parameters:\n    ///   - objects: Table encodable object\n    ///   - propertyConvertibleList: `Property` or `CodingTableKey` list\n    ///   - table: Table name\n    /// - Throws: `Error`\n    func insertOrIgnore<Object: WCTTableCoding>(\n        _ objects: Object...,\n        on propertyConvertibleList: [PropertyConvertible]?,\n        intoTable table: String) throws\n\n    /// Execute inserting or ignoring with `WCTTableCoding` object on specific(or all) properties.\n    /// It will ignore the object while there already exists the same primary key or row id in current table.\n    ///\n    /// Note that it will run embedded transaction while objects.count>1.\n    /// The embedded transaction means that it will run a transaction if it's not in other transaction,\n    /// otherwise it will be executed within the existing transaction.\n    ///\n    /// - Parameters:\n    ///   - objects: Table encodable object\n    ///   - propertyConvertibleList: `Property` or `CodingTableKey` list\n    ///   - table: Table name\n    /// - Throws: `Error`\n    func insertOrIgnore<Object: WCTTableCoding>(\n        _ objects: [Object],\n        on propertyConvertibleList: [PropertyConvertible]?,\n        intoTable table: String) throws\n}\n\nextension InsertInterfaceForObjc where Self: HandleRepresentable {\n    public func insert<Object: WCTTableCoding>(\n        _ objects: [Object],\n        on propertyConvertibleList: [PropertyConvertible]? = nil,\n        intoTable table: String) throws {\n        let insert = Insert(with: try getHandle(writeHint: true), named: table, on: propertyConvertibleList)\n        return try insert.execute(with: objects)\n    }\n\n    public func insertOrReplace<Object: WCTTableCoding>(\n        _ objects: [Object],\n        on propertyConvertibleList: [PropertyConvertible]? = nil,\n        intoTable table: String) throws {\n            let insert = Insert(with: try getHandle(writeHint: true), named: table, on: propertyConvertibleList, onConflict: .Replace)\n        return try insert.execute(with: objects)\n    }\n\n    public func insertOrIgnore<Object: WCTTableCoding>(\n        _ objects: [Object],\n        on propertyConvertibleList: [PropertyConvertible]? = nil,\n        intoTable table: String) throws {\n            let insert = Insert(with: try getHandle(writeHint: true), named: table, on: propertyConvertibleList, onConflict: .Ignore)\n        return try insert.execute(with: objects)\n    }\n\n    public func insert<Object: WCTTableCoding>(\n        _ objects: Object...,\n        on propertyConvertibleList: [PropertyConvertible]? = nil,\n        intoTable table: String) throws {\n        return try insert(objects, on: propertyConvertibleList, intoTable: table)\n    }\n\n    public func insertOrReplace<Object: WCTTableCoding>(\n        _ objects: Object...,\n        on propertyConvertibleList: [PropertyConvertible]? = nil,\n        intoTable table: String) throws {\n        return try insertOrReplace(objects, on: propertyConvertibleList, intoTable: table)\n    }\n\n    public func insertOrIgnore<Object: WCTTableCoding>(\n        _ objects: Object...,\n        on propertyConvertibleList: [PropertyConvertible]? = nil,\n        intoTable table: String) throws {\n        return try insertOrIgnore(objects, on: propertyConvertibleList, intoTable: table)\n    }\n}\n\n#endif\n"
  },
  {
    "path": "src/swift/core/interface/InsertInterface.swift",
    "content": "//\n// Created by qiuwenchen on 2022/9/12.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport Foundation\n#if SWIFT_PACKAGE\nimport WCDB_Private\n#elseif WCDB_SWIFT_TARGET\nimport WCDBSwift.Private\n#else\nimport WCDB.Private\n#endif\n\n/// Convenient interface for inserting\npublic protocol InsertInterface: AnyObject {\n\n    /// Execute inserting with `TableEncodable` object on specific(or all) properties\n    ///\n    /// Note that it will run embedded transaction while objects.count>1.\n    /// The embedded transaction means that it will run a transaction if it's not in other transaction,\n    /// otherwise it will be executed within the existing transaction.\n    ///\n    /// - Parameters:\n    ///   - objects: Table encodable object\n    ///   - propertyConvertibleList: `Property` or `CodingTableKey` list\n    ///   - table: Table name\n    /// - Throws: `Error`\n    func insert<Object: TableEncodable>(\n        _ objects: Object...,\n        on propertyConvertibleList: [PropertyConvertible]?,\n        intoTable table: String) throws\n\n    /// Execute inserting with `TableEncodable` object on specific(or all) properties\n    ///\n    /// Note that it will run embedded transaction while objects.count>1.\n    /// The embedded transaction means that it will run a transaction if it's not in other transaction,\n    /// otherwise it will be executed within the existing transaction.\n    ///\n    /// - Parameters:\n    ///   - objects: Table encodable object\n    ///   - propertyConvertibleList: `Property` or `CodingTableKey` list\n    ///   - table: Table name\n    /// - Throws: `Error`\n    func insert<Object: TableEncodable>(\n        _ objects: [Object],\n        on propertyConvertibleList: [PropertyConvertible]?,\n        intoTable table: String) throws\n\n    /// Execute inserting or replacing with `TableEncodable` object on specific(or all) properties.\n    /// It will replace the original row while they have same primary key or row id.\n    ///\n    /// Note that it will run embedded transaction while objects.count>1.\n    /// The embedded transaction means that it will run a transaction if it's not in other transaction,\n    /// otherwise it will be executed within the existing transaction.\n    ///\n    /// - Parameters:\n    ///   - objects: Table encodable object\n    ///   - propertyConvertibleList: `Property` or `CodingTableKey` list\n    ///   - table: Table name\n    /// - Throws: `Error`\n    func insertOrReplace<Object: TableEncodable>(\n        _ objects: Object...,\n        on propertyConvertibleList: [PropertyConvertible]?,\n        intoTable table: String) throws\n\n    /// Execute inserting or replacing with `TableEncodable` object on specific(or all) properties.\n    /// It will replace the original row while they have same primary key or row id.\n    ///\n    /// Note that it will run embedded transaction while objects.count>1.\n    /// The embedded transaction means that it will run a transaction if it's not in other transaction,\n    /// otherwise it will be executed within the existing transaction.\n    ///\n    /// - Parameters:\n    ///   - objects: Table encodable object\n    ///   - propertyConvertibleList: `Property` or `CodingTableKey` list\n    ///   - table: Table name\n    /// - Throws: `Error`\n    func insertOrReplace<Object: TableEncodable>(\n        _ objects: [Object],\n        on propertyConvertibleList: [PropertyConvertible]?,\n        intoTable table: String) throws\n\n    /// Execute inserting or ignoring with `TableEncodable` object on specific(or all) properties.\n    /// It will ignore the object while there already exists the same primary key or row id in current table.\n    ///\n    /// Note that it will run embedded transaction while objects.count>1.\n    /// The embedded transaction means that it will run a transaction if it's not in other transaction,\n    /// otherwise it will be executed within the existing transaction.\n    ///\n    /// - Parameters:\n    ///   - objects: Table encodable object\n    ///   - propertyConvertibleList: `Property` or `CodingTableKey` list\n    ///   - table: Table name\n    /// - Throws: `Error`\n    func insertOrIgnore<Object: TableEncodable>(\n        _ objects: Object...,\n        on propertyConvertibleList: [PropertyConvertible]?,\n        intoTable table: String) throws\n\n    /// Execute inserting or ignoring with `TableEncodable` object on specific(or all) properties.\n    /// It will ignore the object while there already exists the same primary key or row id in current table.\n    ///\n    /// Note that it will run embedded transaction while objects.count>1.\n    /// The embedded transaction means that it will run a transaction if it's not in other transaction,\n    /// otherwise it will be executed within the existing transaction.\n    ///\n    /// - Parameters:\n    ///   - objects: Table encodable object\n    ///   - propertyConvertibleList: `Property` or `CodingTableKey` list\n    ///   - table: Table name\n    /// - Throws: `Error`\n    func insertOrIgnore<Object: TableEncodable>(\n        _ objects: [Object],\n        on propertyConvertibleList: [PropertyConvertible]?,\n        intoTable table: String) throws\n}\n\nextension InsertInterface where Self: HandleRepresentable {\n    public func insert<Object: TableEncodable>(\n        _ objects: [Object],\n        on propertyConvertibleList: [PropertyConvertible]? = nil,\n        intoTable table: String) throws {\n        let insert = Insert(with: try getHandle(writeHint: true), named: table, on: propertyConvertibleList)\n        return try insert.execute(with: objects)\n    }\n\n    public func insertOrReplace<Object: TableEncodable>(\n        _ objects: [Object],\n        on propertyConvertibleList: [PropertyConvertible]? = nil,\n        intoTable table: String) throws {\n            let insert = Insert(with: try getHandle(writeHint: true), named: table, on: propertyConvertibleList, onConflict: .Replace)\n        return try insert.execute(with: objects)\n    }\n\n    public func insertOrIgnore<Object: TableEncodable>(\n        _ objects: [Object],\n        on propertyConvertibleList: [PropertyConvertible]? = nil,\n        intoTable table: String) throws {\n            let insert = Insert(with: try getHandle(writeHint: true), named: table, on: propertyConvertibleList, onConflict: .Ignore)\n        return try insert.execute(with: objects)\n    }\n\n    public func insert<Object: TableEncodable>(\n        _ objects: Object...,\n        on propertyConvertibleList: [PropertyConvertible]? = nil,\n        intoTable table: String) throws {\n        return try insert(objects, on: propertyConvertibleList, intoTable: table)\n    }\n\n    public func insertOrReplace<Object: TableEncodable>(\n        _ objects: Object...,\n        on propertyConvertibleList: [PropertyConvertible]? = nil,\n        intoTable table: String) throws {\n        return try insertOrReplace(objects, on: propertyConvertibleList, intoTable: table)\n    }\n\n    public func insertOrIgnore<Object: TableEncodable>(\n        _ objects: Object...,\n        on propertyConvertibleList: [PropertyConvertible]? = nil,\n        intoTable table: String) throws {\n        return try insertOrIgnore(objects, on: propertyConvertibleList, intoTable: table)\n    }\n}\n"
  },
  {
    "path": "src/swift/core/interface/SelectInterface+WCTTableCoding.swift",
    "content": "//\n// Created by qiuwenchen on 2022/11/13.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#if WCDB_SWIFT_BRIDGE_OBJC\n\nimport Foundation\n#if SWIFT_PACKAGE\nimport WCDB_Private\n#elseif WCDB_SWIFT_TARGET\nimport WCDBSwift.Private\n#else\nimport WCDB.Private\n#endif\n\n/// Convenient interface for selecting\npublic protocol SelectInterfaceForObjc: AnyObject {\n    // TODO: Add generic property convertible to fit the type\n\n    /// Get objects on specific(or all) properties\n    ///\n    /// - Parameters:\n    ///   - propertyConvertibleList: `Property` or `CodingTableKey` list\n    ///   - table: Table name\n    ///   - condition: Expression convertible\n    ///   - orderList: Order convertible list\n    ///   - limit: Expression convertible\n    ///   - offset: Expression convertible\n    /// - Returns: Table decodable objects\n    /// - Throws: `Error`\n    func getObjects<Object: WCTTableCoding>(\n        on propertyConvertibleList: [PropertyConvertible],\n        fromTable table: String,\n        where condition: Condition?,\n        orderBy orderList: [OrderBy]?,\n        limit: Limit?,\n        offset: Offset?) throws -> [Object]\n\n    /// Get objects on specific(or all) properties\n    ///\n    /// - Parameters:\n    ///   - propertyConvertibleList: `Property` or `CodingTableKey` list\n    ///   - table: Table name\n    ///   - condition: Expression convertible\n    ///   - orderList: Order convertible list\n    ///   - limit: Expression convertible\n    ///   - offset: Expression convertible\n    /// - Returns: Table decodable objects\n    /// - Throws: `Error`\n    func getObjects<Object: WCTTableCoding>(\n        on propertyConvertibleList: PropertyConvertible...,\n        fromTable table: String,\n        where condition: Condition?,\n        orderBy orderList: [OrderBy]?,\n        limit: Limit?,\n        offset: Offset?) throws -> [Object]\n\n    /// Get object on specific(or all) properties\n    ///\n    /// - Parameters:\n    ///   - propertyConvertibleList: `Property` or `CodingTableKey` list\n    ///   - table: Table name\n    ///   - condition: Expression convertible\n    ///   - orderList: Order convertible list\n    ///   - offset: Expression convertible\n    /// - Returns: Table decodable objects\n    /// - Throws: `Error`\n    func getObject<Object: WCTTableCoding>(\n        on propertyConvertibleList: [PropertyConvertible],\n        fromTable table: String,\n        where condition: Condition?,\n        orderBy orderList: [OrderBy]?,\n        offset: Offset?) throws -> Object?\n\n    /// Get object on specific(or all) properties\n    ///\n    /// - Parameters:\n    ///   - propertyConvertibleList: `Property` or `CodingTableKey` list\n    ///   - table: Table name\n    ///   - condition: Expression convertible\n    ///   - orderList: Order convertible list\n    ///   - condition: Expression convertible\n    /// - Returns: Table decodable objects\n    /// - Throws: `Error`\n    func getObject<Object: WCTTableCoding>(\n        on propertyConvertibleList: PropertyConvertible...,\n        fromTable table: String,\n        where condition: Condition?,\n        orderBy orderList: [OrderBy]?,\n        offset: Offset?) throws -> Object?\n}\n\nextension SelectInterfaceForObjc where Self: HandleRepresentable {\n    public func getObjects<Object: WCTTableCoding>(\n        on propertyConvertibleList: [PropertyConvertible],\n        fromTable table: String,\n        where condition: Condition? = nil,\n        orderBy orderList: [OrderBy]? = nil,\n        limit: Limit? = nil,\n        offset: Offset? = nil) throws -> [Object] {\n        let select = Select(with: try getHandle(writeHint: false), on: propertyConvertibleList, table: table, isDistinct: false)\n        if condition != nil {\n            select.where(condition!)\n        }\n        if orderList != nil {\n            select.order(by: orderList!)\n        }\n        if limit != nil {\n            if offset != nil {\n                select.limit(limit!, offset: offset!)\n            } else {\n                select.limit(limit!)\n            }\n        }\n        return try select.allObjects()\n    }\n\n    public func getObjects<Object: WCTTableCoding>(\n        on propertyConvertibleList: PropertyConvertible...,\n        fromTable table: String,\n        where condition: Condition? = nil,\n        orderBy orderList: [OrderBy]? = nil,\n        limit: Limit? = nil,\n        offset: Offset? = nil) throws -> [Object] {\n        return try getObjects(on: propertyConvertibleList.isEmpty ? Object.allProperties() : propertyConvertibleList,\n                              fromTable: table,\n                              where: condition,\n                              orderBy: orderList,\n                              limit: limit,\n                              offset: offset)\n    }\n\n    public func getObject<Object: WCTTableCoding>(\n        on propertyConvertibleList: [PropertyConvertible],\n        fromTable table: String,\n        where condition: Condition? = nil,\n        orderBy orderList: [OrderBy]? = nil,\n        offset: Offset? = nil) throws -> Object? {\n            let objects: [Object] = try getObjects(on: propertyConvertibleList,\n                                                   fromTable: table,\n                                                   where: condition,\n                                                   orderBy: orderList,\n                                                   limit: 1,\n                                                   offset: offset)\n            return objects.first\n    }\n\n    public func getObject<Object: WCTTableCoding>(\n        on propertyConvertibleList: PropertyConvertible...,\n        fromTable table: String,\n        where condition: Condition? = nil,\n        orderBy orderList: [OrderBy]? = nil,\n        offset: Offset? = nil) throws -> Object? {\n        return try getObject(on: propertyConvertibleList.isEmpty ? Object.allProperties() : propertyConvertibleList,\n                             fromTable: table,\n                             where: condition,\n                             orderBy: orderList,\n                             offset: offset)\n    }\n}\n\n#endif\n"
  },
  {
    "path": "src/swift/core/interface/SelectInterface.swift",
    "content": "//\n// Created by qiuwenchen on 2022/9/13.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport Foundation\n#if SWIFT_PACKAGE\nimport WCDB_Private\n#elseif WCDB_SWIFT_TARGET\nimport WCDBSwift.Private\n#else\nimport WCDB.Private\n#endif\n\n/// Convenient interface for row selecting\npublic protocol RowSelectInterface: AnyObject {\n\n    /// Get rows by specific selecting\n    ///\n    /// - Parameters:\n    ///   - resultColumnConvertibleList: WINQ column result list\n    ///   - table: Table name\n    ///   - condition: Expression convertible\n    ///   - orderList: Order convertible list\n    ///   - limit: Expression convertible\n    ///   - offset: Expression convertible\n    /// - Returns: `MultiRowsValue`\n    /// - Throws: `Error`\n    func getRows(on resultColumnConvertibleList: [ResultColumnConvertible],\n                 fromTable table: String,\n                 where condition: Condition?,\n                 orderBy orderList: [OrderBy]?,\n                 limit: Limit?,\n                 offset: Offset?) throws -> MultiRowsValue\n\n    /// Get rows by specific selecting\n    ///\n    /// - Parameters:\n    ///   - resultColumnConvertibleList: WINQ column result list\n    ///   - table: Table name\n    ///   - condition: Expression convertible\n    ///   - orderList: Order convertible list\n    ///   - limit: Expression convertible\n    ///   - offset: Expression convertible\n    /// - Returns: `MultiRowsValue`\n    /// - Throws: `Error`\n    func getRows(on resultColumnConvertibleList: ResultColumnConvertible...,\n                 fromTable table: String,\n                 where condition: Condition?,\n                 orderBy orderList: [OrderBy]?,\n                 limit: Limit?,\n                 offset: Offset?) throws -> MultiRowsValue\n\n    /// Get row by specific selecting\n    ///\n    /// - Parameters:\n    ///   - resultColumnConvertibleList: WINQ column result list\n    ///   - table: Table name\n    ///   - condition: Expression convertible\n    ///   - orderList: Order convertible list\n    ///   - offset: Expression convertible\n    /// - Returns: `OneRowValue`\n    /// - Throws: `Error`\n    func getRow(on resultColumnConvertibleList: ResultColumnConvertible...,\n                fromTable table: String,\n                where condition: Condition?,\n                orderBy orderList: [OrderBy]?,\n                offset: Offset?) throws -> OneRowValue\n\n    /// Get row by specific selecting\n    ///\n    /// - Parameters:\n    ///   - resultColumnConvertibleList: WINQ column result list\n    ///   - table: Table name\n    ///   - condition: Expression convertible\n    ///   - orderList: Order convertible list\n    ///   - offset: Expression convertible\n    /// - Returns: `OneRowValue`\n    /// - Throws: `Error`\n    func getRow(on resultColumnConvertibleList: [ResultColumnConvertible],\n                fromTable table: String,\n                where condition: Condition?,\n                orderBy orderList: [OrderBy]?,\n                offset: Offset?) throws -> OneRowValue\n\n    /// Get column by specific selecting\n    ///\n    /// - Parameters:\n    ///   - resultColumnConvertible: WINQ column result\n    ///   - table: Table name\n    ///   - condition: Expression convertible\n    ///   - orderList: Order convertible list\n    ///   - limit: Expression convertible\n    ///   - offset: Expression convertible\n    /// - Returns: `OneColumnValue`\n    /// - Throws: `Error`\n    func getColumn(on resultColumnConvertible: ResultColumnConvertible,\n                   fromTable table: String,\n                   where condition: Condition?,\n                   orderBy orderList: [OrderBy]?,\n                   limit: Limit?,\n                   offset: Offset?) throws -> OneColumnValue\n\n    /// Get distinct column by specific selecting\n    ///\n    /// - Parameters:\n    ///   - resultColumnConvertible: WINQ column result\n    ///   - table: Table name\n    ///   - condition: Expression convertible\n    ///   - orderList: Order convertible list\n    ///   - limit: Expression convertible\n    ///   - offset: Expression convertible\n    /// - Returns: `OneColumnValue`\n    /// - Throws: `Error`\n    func getDistinctColumn(on resultColumnConvertible: ResultColumnConvertible,\n                           fromTable table: String,\n                           where condition: Condition?,\n                           orderBy orderList: [OrderBy]?,\n                           limit: Limit?,\n                           offset: Offset?) throws -> OneColumnValue\n\n    /// Get value by specific selecting\n    ///\n    /// - Parameters:\n    ///   - resultColumnConvertible: WINQ column result\n    ///   - table: Table name\n    ///   - condition: Expression convertible\n    ///   - orderList: Order convertible list\n    ///   - offset: Expression convertible\n    /// - Returns: `Value`\n    /// - Throws: `Error`\n    func getValue(on resultColumnConvertible: ResultColumnConvertible,\n                  fromTable table: String,\n                  where condition: Condition?,\n                  orderBy orderList: [OrderBy]?,\n                  limit: Limit?,\n                  offset: Offset?) throws -> Value\n\n    /// Get distinct value by specific selecting\n    ///\n    /// - Parameters:\n    ///   - resultColumnConvertible: WINQ column result\n    ///   - table: Table name\n    ///   - condition: Expression convertible\n    ///   - orderList: Order convertible list\n    ///   - offset: Expression convertible\n    /// - Returns: `Value`\n    /// - Throws: `Error`\n    func getDistinctValue(on result: ResultColumnConvertible,\n                          fromTable table: String,\n                          where condition: Condition?,\n                          orderBy orderList: [OrderBy]?,\n                          limit: Limit?,\n                          offset: Offset?) throws -> Value\n}\n\nextension RowSelectInterface where Self: HandleRepresentable {\n    public func getRows(on resultColumnConvertibleList: [ResultColumnConvertible],\n                        fromTable table: String,\n                        where condition: Condition? = nil,\n                        orderBy orderList: [OrderBy]? = nil,\n                        limit: Limit? = nil,\n                        offset: Offset? = nil) throws -> MultiRowsValue {\n        let rowSelect = RowSelect(with: try getHandle(writeHint: false),\n                                  results: resultColumnConvertibleList,\n                                  tables: [table],\n                                  isDistinct: false)\n        if condition != nil {\n            rowSelect.where(condition!)\n        }\n        if orderList != nil {\n            rowSelect.order(by: orderList!)\n        }\n        if limit != nil {\n            if offset != nil {\n                rowSelect.limit(limit!, offset: offset!)\n            } else {\n                rowSelect.limit(limit!)\n            }\n        }\n        return try rowSelect.allRows()\n    }\n\n    public func getRows(on resultColumnConvertibleList: ResultColumnConvertible...,\n                        fromTable table: String,\n                        where condition: Condition? = nil,\n                        orderBy orderList: [OrderBy]? = nil,\n                        limit: Limit? = nil,\n                        offset: Offset? = nil) throws -> MultiRowsValue {\n        return try getRows(\n            on: resultColumnConvertibleList.isEmpty ? [Column.all()] : resultColumnConvertibleList,\n            fromTable: table,\n            where: condition,\n            orderBy: orderList,\n            limit: limit,\n            offset: offset)\n    }\n\n    public func getRow(on resultColumnConvertibleList: ResultColumnConvertible...,\n                       fromTable table: String,\n                       where condition: Condition? = nil,\n                       orderBy orderList: [OrderBy]? = nil,\n                       offset: Offset? = nil) throws -> OneRowValue {\n        return try getRow(\n            on: resultColumnConvertibleList.isEmpty ? [Column.all()] : resultColumnConvertibleList,\n            fromTable: table,\n            where: condition,\n            orderBy: orderList,\n            offset: offset)\n    }\n\n    public func getRow(on resultColumnConvertibleList: [ResultColumnConvertible],\n                       fromTable table: String,\n                       where condition: Condition? = nil,\n                       orderBy orderList: [OrderBy]? = nil,\n                       offset: Offset? = nil) throws -> OneRowValue {\n        return try getRows(on: resultColumnConvertibleList,\n                           fromTable: table,\n                           where: condition,\n                           orderBy: orderList,\n                           limit: 1,\n                           offset: offset).first ?? []\n    }\n\n    public func getColumn(on result: ResultColumnConvertible,\n                          fromTable table: String,\n                          where condition: Condition? = nil,\n                          orderBy orderList: [OrderBy]? = nil,\n                          limit: Limit? = nil,\n                          offset: Offset? = nil) throws -> OneColumnValue {\n        let rowSelect = RowSelect(with: try getHandle(writeHint: false), results: [result], tables: [table], isDistinct: false)\n        if condition != nil {\n            rowSelect.where(condition!)\n        }\n        if orderList != nil {\n            rowSelect.order(by: orderList!)\n        }\n        if limit != nil {\n            if offset != nil {\n                rowSelect.limit(limit!, offset: offset!)\n            } else {\n                rowSelect.limit(limit!)\n            }\n        }\n        return try rowSelect.allValues()\n    }\n\n    public func getDistinctColumn(on result: ResultColumnConvertible,\n                                  fromTable table: String,\n                                  where condition: Condition? = nil,\n                                  orderBy orderList: [OrderBy]? = nil,\n                                  limit: Limit? = nil,\n                                  offset: Offset? = nil) throws -> OneColumnValue {\n        let rowSelect = RowSelect(with: try getHandle(writeHint: false), results: [result], tables: [table], isDistinct: true)\n        if condition != nil {\n            rowSelect.where(condition!)\n        }\n        if orderList != nil {\n            rowSelect.order(by: orderList!)\n        }\n        if limit != nil {\n            if offset != nil {\n                rowSelect.limit(limit!, offset: offset!)\n            } else {\n                rowSelect.limit(limit!)\n            }\n        }\n        return try rowSelect.allValues()\n    }\n\n    public func getValue(on result: ResultColumnConvertible,\n                         fromTable table: String,\n                         where condition: Condition? = nil,\n                         orderBy orderList: [OrderBy]? = nil,\n                         limit: Limit? = nil,\n                         offset: Offset? = nil) throws -> Value {\n        return (try getRows(on: result,\n                            fromTable: table,\n                            where: condition,\n                            orderBy: orderList,\n                            limit: 1,\n                            offset: offset).first?.first) ?? Value(nil)\n    }\n\n    public func getDistinctValue(on result: ResultColumnConvertible,\n                                 fromTable table: String,\n                                 where condition: Condition? = nil,\n                                 orderBy orderList: [OrderBy]? = nil,\n                                 limit: Limit? = nil,\n                                 offset: Offset? = nil) throws -> Value {\n        return (try getDistinctColumn(on: result, fromTable: table).first) ?? Value(nil)\n    }\n}\n\n/// Convenient interface for selecting\npublic protocol SelectInterface: AnyObject {\n    // TODO: Add generic property convertible to fit the type\n\n    /// Get objects on specific(or all) properties\n    ///\n    /// - Parameters:\n    ///   - propertyConvertibleList: `Property` or `CodingTableKey` list\n    ///   - table: Table name\n    ///   - condition: Expression convertible\n    ///   - orderList: Order convertible list\n    ///   - limit: Expression convertible\n    ///   - offset: Expression convertible\n    /// - Returns: Table decodable objects\n    /// - Throws: `Error`\n    func getObjects<Object: TableDecodable>(\n        on propertyConvertibleList: [PropertyConvertible],\n        fromTable table: String,\n        where condition: Condition?,\n        orderBy orderList: [OrderBy]?,\n        limit: Limit?,\n        offset: Offset?) throws -> [Object]\n\n    /// Get objects on specific(or all) properties\n    ///\n    /// - Parameters:\n    ///   - propertyConvertibleList: `Property` or `CodingTableKey` list\n    ///   - table: Table name\n    ///   - condition: Expression convertible\n    ///   - orderList: Order convertible list\n    ///   - limit: Expression convertible\n    ///   - offset: Expression convertible\n    /// - Returns: Table decodable objects\n    /// - Throws: `Error`\n    func getObjects<Object: TableDecodable>(\n        on propertyConvertibleList: PropertyConvertible...,\n        fromTable table: String,\n        where condition: Condition?,\n        orderBy orderList: [OrderBy]?,\n        limit: Limit?,\n        offset: Offset?) throws -> [Object]\n\n    /// Get object on specific(or all) properties\n    ///\n    /// - Parameters:\n    ///   - propertyConvertibleList: `Property` or `CodingTableKey` list\n    ///   - table: Table name\n    ///   - condition: Expression convertible\n    ///   - orderList: Order convertible list\n    ///   - offset: Expression convertible\n    /// - Returns: Table decodable objects\n    /// - Throws: `Error`\n    func getObject<Object: TableDecodable>(\n        on propertyConvertibleList: [PropertyConvertible],\n        fromTable table: String,\n        where condition: Condition?,\n        orderBy orderList: [OrderBy]?,\n        offset: Offset?) throws -> Object?\n\n    /// Get object on specific(or all) properties\n    ///\n    /// - Parameters:\n    ///   - propertyConvertibleList: `Property` or `CodingTableKey` list\n    ///   - table: Table name\n    ///   - condition: Expression convertible\n    ///   - orderList: Order convertible list\n    ///   - condition: Expression convertible\n    /// - Returns: Table decodable objects\n    /// - Throws: `Error`\n    func getObject<Object: TableDecodable>(\n        on propertyConvertibleList: PropertyConvertible...,\n        fromTable table: String,\n        where condition: Condition?,\n        orderBy orderList: [OrderBy]?,\n        offset: Offset?) throws -> Object?\n}\n\nextension SelectInterface where Self: HandleRepresentable {\n    public func getObjects<Object: TableDecodable>(\n        on propertyConvertibleList: [PropertyConvertible],\n        fromTable table: String,\n        where condition: Condition? = nil,\n        orderBy orderList: [OrderBy]? = nil,\n        limit: Limit? = nil,\n        offset: Offset? = nil) throws -> [Object] {\n        let select = Select(with: try getHandle(writeHint: false), on: propertyConvertibleList, table: table, isDistinct: false)\n        if condition != nil {\n            select.where(condition!)\n        }\n        if orderList != nil {\n            select.order(by: orderList!)\n        }\n        if limit != nil {\n            if offset != nil {\n                select.limit(limit!, offset: offset!)\n            } else {\n                select.limit(limit!)\n            }\n        }\n        return try select.allObjects()\n    }\n\n    public func getObjects<Object: TableDecodable>(\n        on propertyConvertibleList: PropertyConvertible...,\n        fromTable table: String,\n        where condition: Condition? = nil,\n        orderBy orderList: [OrderBy]? = nil,\n        limit: Limit? = nil,\n        offset: Offset? = nil) throws -> [Object] {\n        return try getObjects(on: propertyConvertibleList.isEmpty ? Object.Properties.all : propertyConvertibleList,\n                              fromTable: table,\n                              where: condition,\n                              orderBy: orderList,\n                              limit: limit,\n                              offset: offset)\n    }\n\n    public func getObject<Object: TableDecodable>(\n        on propertyConvertibleList: [PropertyConvertible],\n        fromTable table: String,\n        where condition: Condition? = nil,\n        orderBy orderList: [OrderBy]? = nil,\n        offset: Offset? = nil) throws -> Object? {\n            let objects: [Object] = try getObjects(on: propertyConvertibleList,\n                                                   fromTable: table,\n                                                   where: condition,\n                                                   orderBy: orderList,\n                                                   limit: 1,\n                                                   offset: offset)\n            return objects.first\n    }\n\n    public func getObject<Object: TableDecodable>(\n        on propertyConvertibleList: PropertyConvertible...,\n        fromTable table: String,\n        where condition: Condition? = nil,\n        orderBy orderList: [OrderBy]? = nil,\n        offset: Offset? = nil) throws -> Object? {\n        return try getObject(on: propertyConvertibleList.isEmpty ? Object.Properties.all : propertyConvertibleList,\n                             fromTable: table,\n                             where: condition,\n                             orderBy: orderList,\n                             offset: offset)\n    }\n}\n"
  },
  {
    "path": "src/swift/core/interface/StatementInterface+WCTTableCoding.swift",
    "content": "//\n// Created by qiuwenchen on 2022/11/13.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#if WCDB_SWIFT_BRIDGE_OBJC\n\nimport Foundation\n#if SWIFT_PACKAGE\nimport WCDB_Private\n#elseif WCDB_SWIFT_TARGET\nimport WCDBSwift.Private\n#else\nimport WCDB.Private\n#endif\n\npublic protocol StatementInterfaceForObjc {\n    /// The wrapper of `sqlite3_bind_*` for binding property of object to index.\n    ///\n    /// - Parameters:\n    ///   - propertyConvertible: `Property` or `CodingTableKey`\n    ///   - object: Table encodable object\n    ///   - index: Begin with 1\n    /// - Throws: `Error`\n    func bind<TableEncodableType: WCTTableCoding>(\n        _ propertyConvertible: PropertyConvertible,\n        of object: TableEncodableType,\n        toIndex index: Int) throws\n\n    /// The wrapper of `sqlite3_bind_*` for binding properties of object to indexes.\n    ///\n    /// - Parameters:\n    ///   - indexedPropertyConvertibleList: Indexed `Property` or `CodingTableKey` list\n    ///   - object: Table encodable object\n    /// - Throws: Begin with 1\n    func bind<TableEncodableType: WCTTableCoding>(\n        _ indexedPropertyConvertibleList: [(_: PropertyConvertible, toIndex: Int)],\n        of object: TableEncodableType) throws\n\n    /// The wrapper of `sqlite3_bind_*` for binding properties of object.\n    ///\n    /// - Parameters:\n    ///   - propertyConvertibleList: `Property` or `CodingTableKey` list\n    ///   - object: Table encodable object\n    /// - Throws: Begin with 1\n    func bind<TableEncodableType: WCTTableCoding>(\n        _ propertyConvertibleList: [PropertyConvertible],\n        of object: TableEncodableType) throws\n\n    /// The wrapper of `sqlite3_column_*` for getting  an object.\n    ///\n    /// - Parameters:\n    ///   - propertyConvertibleList: `Property` or `CodingTableKey` list\n    ///   - type: Type of table decodable object\n    /// - Returns: Table decodable object.\n    func extractObject<Object: WCTTableCoding>(on propertyConvertibleList: [PropertyConvertible]?, of type: Object.Type) -> Object\n\n    /// The wrapper of `sqlite3_column_*` for getting  all objects.\n    ///\n    /// - Parameters:\n    ///   - propertyConvertibleList: `Property` or `CodingTableKey` list\n    ///   - type: Type of table decodable object\n    /// - Returns: Table decodable objects.\n    func extractAllObjects<Object: WCTTableCoding>(on propertyConvertibleList: [PropertyConvertible]?, of type: Object.Type) throws -> [Object]\n}\n\nextension StatementInterfaceForObjc where Self: RawStatementmentRepresentable {\n    public func bind<TableEncodableType: WCTTableCoding>(\n        _ propertyConvertible: PropertyConvertible,\n        of object: TableEncodableType,\n        toIndex index: Int = 1) throws {\n        try bind([(propertyConvertible, toIndex: index)], of: object)\n    }\n\n    public func bind<TableEncodableType: WCTTableCoding>(\n        _ indexedPropertyConvertibleList: [(_: PropertyConvertible, toIndex: Int)],\n        of object: TableEncodableType) throws {\n        for args in indexedPropertyConvertibleList {\n            assert(args.0.wctProperty != nil, \"WCTProperty should not be failed. If you think it's a bug, please report an issue to us.\")\n            WCTAPIBridge.bindProperty(args.0.wctProperty!, ofObject: object, to: Int32(truncatingIfNeeded: args.toIndex), with: getRawStatement())\n        }\n    }\n\n    public func bind<TableEncodableType: WCTTableCoding>(\n        _ propertyConvertibleList: [PropertyConvertible],\n        of object: TableEncodableType) throws {\n        WCTAPIBridge.bindProperties(propertyConvertibleList.asWCTBridgeProperties(), ofObject: object, with: getRawStatement())\n    }\n\n    public func extractObject<Object: WCTTableCoding>(on propertyConvertibleList: [PropertyConvertible]? = nil, of type: Object.Type = Object.self) -> Object {\n        let properties: [WCTBridgeProperty] = propertyConvertibleList?.asWCTBridgeProperties() ?? Object.allProperties()\n        return WCTAPIBridge.extractObject(onResultColumns: properties, from: getRawStatement()) as! Object\n    }\n\n    public func extractAllObjects<Object: WCTTableCoding>(on propertyConvertibleList: [PropertyConvertible]? = nil, of type: Object.Type = Object.self) throws -> [Object] {\n        let properties: [WCTBridgeProperty] = propertyConvertibleList?.asWCTBridgeProperties() ?? Object.allProperties()\n        var objects: [Object] = []\n        let rawStatment = getRawStatement()\n        if !WCDBHandleStatementStep(rawStatment) {\n            let cppError = WCDBHandleStatementGetError(rawStatment)\n            if finalizeWhenError() {\n                WCDBHandleStatementFinalize(getRawStatement())\n            }\n            throw ErrorBridge.getErrorFrom(cppError: cppError)\n        }\n        while !WCDBHandleStatementIsDone(rawStatment) {\n            objects.append(WCTAPIBridge.extractObject(onResultColumns: properties, from: getRawStatement()) as! Object)\n            if !WCDBHandleStatementStep(rawStatment) {\n                let cppError = WCDBHandleStatementGetError(rawStatment)\n                throw ErrorBridge.getErrorFrom(cppError: cppError)\n            }\n        }\n        return objects\n    }\n}\n\n#endif\n"
  },
  {
    "path": "src/swift/core/interface/StatementInterface.swift",
    "content": "//\n// Created by qiuwenchen on 2022/9/12.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport Foundation\n#if SWIFT_PACKAGE\nimport WCDB_Private\n#elseif WCDB_SWIFT_TARGET\nimport WCDBSwift.Private\n#else\nimport WCDB.Private\n#endif\n\npublic protocol StatementInterface: AnyObject {\n    /// The wrapper of `sqlite3_finalize`\n    func finalize()\n\n    /// The wrapper of `sqlite3_step`\n    ///\n    /// - Returns: True means you can continue stepping while false means the stepping has been completed.\n    /// - Throws: `Error`\n    @discardableResult\n    func step() throws -> Bool\n\n    /// The wrapper of `sqlite3_reset`\n    func reset() throws\n\n    /// The wrapper of `sqlite3_clear_bindings`\n    func clearBindings() throws\n\n    /// The wrapper of `sqlite3_getRawStatement()_readonly`\n    var isReadOnly: Bool { get }\n\n    /// The wrapper of `sqlite3_bind_*` for binding property of object to index.\n    ///\n    /// - Parameters:\n    ///   - propertyConvertible: `Property` or `CodingTableKey`\n    ///   - object: Table encodable object\n    ///   - index: Begin with 1\n    /// - Throws: `Error`\n    func bind<TableEncodableType: TableEncodable>(\n        _ propertyConvertible: PropertyConvertible,\n        of object: TableEncodableType,\n        toIndex index: Int) throws\n\n    /// The wrapper of `sqlite3_bind_*` for binding properties of object to indexes.\n    ///\n    /// - Parameters:\n    ///   - indexedPropertyConvertibleList: Indexed `Property` or `CodingTableKey` list\n    ///   - object: Table encodable object\n    /// - Throws: Begin with 1\n    func bind<TableEncodableType: TableEncodable>(\n        _ indexedPropertyConvertibleList: [(_: PropertyConvertible, toIndex: Int)],\n        of object: TableEncodableType) throws\n\n    /// The wrapper of `sqlite3_bind_*` for binding properties of object.\n    ///\n    /// - Parameters:\n    ///   - propertyConvertibleList: `Property` or `CodingTableKey` list\n    ///   - object: Table encodable object\n    /// - Throws: Begin with 1\n    func bind<TableEncodableType: TableEncodable>(\n        _ propertyConvertibleList: [PropertyConvertible],\n        of object: TableEncodableType) throws\n\n    /// The wrapper of `sqlite3_bind_*` for binding column encodable object.\n    ///\n    /// - Parameters:\n    ///   - value: Column encodable object\n    ///   - index: Begin with 1\n    func bind(_ value: ColumnEncodable?, toIndex index: Int)\n\n    func bind(_ value: Value, toIndex index: Int)\n    func bind(_ value: Int32, toIndex index: Int)\n    func bind(_ value: Int64, toIndex index: Int)\n    func bind(_ value: Double, toIndex index: Int)\n    func bind(_ value: String, toIndex index: Int)\n    func bind(_ value: Data, toIndex index: Int)\n\n    /// The wrapper of `sqlite3_column_*` for getting column decodable value.\n    ///\n    /// - Parameters:\n    ///   - index: Begin with 0\n    ///   - type: Type of column codable object\n    /// - Returns: Same as type\n    func value(atIndex index: Int, of type: ColumnDecodable.Type) -> ColumnDecodable?\n\n    /// The wrapper of `sqlite3_column_*` for getting column decodable value.\n    ///\n    /// - Parameters:\n    ///   - name: Name of the column\n    ///   - type: Type of column codable object\n    /// - Returns: Same as type. Nil will be returned if no such a column.\n    func value<ColumnDecodableType: ColumnDecodable>(\n        byName name: String,\n        of type: ColumnDecodableType.Type) -> ColumnDecodableType?\n\n    /// The wrapper of `sqlite3_column_*` for getting value.\n    ///\n    /// - Parameter index: Begin with 0\n    /// - Returns: `Int32`, `Int64`, `Double`, `String`, `Data` or `nil` value.\n    func value(atIndex index: Int) -> Value\n\n    /// The wrapper of `sqlite3_column_*` for getting  a row of values.\n    ///\n    /// - Parameters:\n    ///   - index: Begin with 0\n    /// - Returns: OneColumnValue\n    func oneRowValue() -> OneRowValue\n\n    /// The wrapper of `sqlite3_column_*` for getting  a column of values.\n    ///\n    /// - Returns: OneRowValue\n    func oneColumnValue(atIndex index: Int) throws -> OneColumnValue\n\n    /// The wrapper of `sqlite3_column_*` for getting  multi rows of values.\n    ///\n    /// - Returns: MultiRowsValue\n    func multiRowsValue() throws -> MultiRowsValue\n\n    /// The wrapper of `sqlite3_column_*` for getting  an object.\n    ///\n    /// - Parameters:\n    ///   - propertyConvertibleList: `Property` or `CodingTableKey` list\n    ///   - type: Type of table decodable object\n    /// - Returns: Table decodable object.\n    func extractObject<Object: TableDecodable>(on propertyConvertibleList: [PropertyConvertible]?, of type: Object.Type) throws -> Object\n\n    /// The wrapper of `sqlite3_column_*` for getting  all objects.\n    ///\n    /// - Parameters:\n    ///   - propertyConvertibleList: `Property` or `CodingTableKey` list\n    ///   - type: Type of table decodable object\n    /// - Returns: Table decodable objects.\n    func extractAllObjects<Object: TableDecodable>(on propertyConvertibleList: [PropertyConvertible]?, of type: Object.Type) throws -> [Object]\n\n    /// Get index by column name.\n    ///\n    /// - Parameter name: Name of the column\n    /// - Returns: Index of given column name. Nil will be returned if no such a column.\n    func index(byName name: String) -> Int?\n\n    /// The wrapper of `sqlite3_bind_parameter_index*`.\n    ///\n    /// - Returns: index of a given bind parameter\n    func indexOf(bindParameter: String) -> Int\n\n    func columnValue(atIndex index: Int) -> Int32\n    func columnValue(atIndex index: Int, of type: Int32.Type) -> Int32\n    func columnValue(atIndex index: Int) -> Int64\n    func columnValue(atIndex index: Int, of type: Int64.Type) -> Int64\n    func columnValue(atIndex index: Int) -> Double\n    func columnValue(atIndex index: Int, of type: Double.Type) -> Double\n    func columnValue(atIndex index: Int) -> String\n    func columnValue(atIndex index: Int, of type: String.Type) -> String\n    func columnValue(atIndex index: Int) -> Data\n    func columnValue(atIndex index: Int, of type: Data.Type) -> Data\n\n    /// The wrapper of `sqlite3_column_count`.\n    ///\n    /// - Returns: Count of column result\n    func columnCount() -> Int\n\n    /// The wrapper of `sqlite3_column_name`\n    ///\n    /// - Parameter index: Begin with 0\n    /// - Returns: Name of the column\n    func columnName(atIndex index: Int) -> String\n\n    /// The wrapper of `sqlite3_column_type`\n    ///\n    /// - Parameter name: Name of the column\n    /// - Returns: Column type. For a non-exists column, `.null` will be returned.\n    func columnType(byName name: String) -> ColumnType\n\n    /// The wrapper of `sqlite3_column_type`\n    ///\n    /// - Parameter index: Begin with 0\n    /// - Returns: Type of the column\n    func columnType(atIndex index: Int) -> ColumnType\n\n    /// The wrapper of `sqlite3_column_table_name`.\n    ///\n    /// - Parameter index: Begin with 0\n    /// - Returns: Return the name of the table column from which a result column derives.\n    func originalColumnName(atIndex index: Int) -> String\n\n    /// The wrapper of `sqlite3_column_table_name`.\n    ///\n    /// - Parameter index: Begin with 0\n    /// - Returns: Return the name of the table from which a result column derives.\n    func columnTableName(atIndex index: Int) -> String\n}\n\nextension StatementInterface where Self: RawStatementmentRepresentable {\n\n    public func finalize() {\n        WCDBHandleStatementFinalize(getRawStatement())\n    }\n\n    @discardableResult\n    public func step() throws -> Bool {\n        let rawStatment = getRawStatement()\n        if !WCDBHandleStatementStep(rawStatment) {\n            let cppError = WCDBHandleStatementGetError(rawStatment)\n            if finalizeWhenError() {\n                finalize()\n            }\n            throw ErrorBridge.getErrorFrom(cppError: cppError)\n        }\n        return !WCDBHandleStatementIsDone(rawStatment)\n    }\n\n    public func reset() {\n        WCDBHandleStatementReset(getRawStatement())\n    }\n\n    public func clearBindings() {\n        WCDBHandleStatementClearBindings(getRawStatement())\n    }\n\n    public var isReadOnly: Bool {\n        return WCDBHandleStatementIsReadOnly(getRawStatement())\n    }\n\n    public func bind<TableEncodableType: TableEncodable>(\n        _ propertyConvertible: PropertyConvertible,\n        of object: TableEncodableType,\n        toIndex index: Int = 1) throws {\n        try bind([(propertyConvertible, toIndex: index)], of: object)\n    }\n\n    public func bind<TableEncodableType: TableEncodable>(\n        _ indexedPropertyConvertibleList: [(_: PropertyConvertible, toIndex: Int)],\n        of object: TableEncodableType) throws {\n        var hashedKeys: TableEncoder.HashedKey = [:]\n        for args in indexedPropertyConvertibleList {\n            hashedKeys[args.0.codingTableKey!.stringValue.hashValue] = args.toIndex\n        }\n        let encoder = TableEncoder(hashedKeys, on: self)\n        try object.encode(to: encoder)\n    }\n\n    public func bind<TableEncodableType: TableEncodable>(\n        _ propertyConvertibleList: [PropertyConvertible],\n        of object: TableEncodableType) throws {\n        var hashedKeys: TableEncoder.HashedKey = [:]\n        for (index, propertyConvertible) in propertyConvertibleList.enumerated() {\n            hashedKeys[propertyConvertible.codingTableKey!.stringValue.hashValue] = index + 1\n        }\n        let encoder = TableEncoder(hashedKeys, on: self)\n        try object.encode(to: encoder)\n    }\n\n    public func bind(_ value: ColumnEncodable?, toIndex index: Int) {\n        guard let bindingValue = value?.archivedValue() else {\n            WCDBHandleStatementBindNull(getRawStatement(), Int32(index))\n            return\n        }\n        bind(bindingValue, toIndex: index)\n    }\n\n    public func bind(_ value: Value, toIndex index: Int) {\n        switch value.type {\n        case .integer32:\n            bind(value.int32Value, toIndex: index)\n        case .integer64:\n            bind(value.int64Value, toIndex: index)\n        case .float:\n            bind(value.doubleValue, toIndex: index)\n        case .text:\n            bind(value.stringValue, toIndex: index)\n        case .BLOB:\n            bind(value.dataValue, toIndex: index)\n        case .null:\n            WCDBHandleStatementBindNull(getRawStatement(), Int32(index))\n        }\n    }\n\n    public func bind(_ value: Int32, toIndex index: Int) {\n        WCDBHandleStatementBindInteger(getRawStatement(), Int32(index), Int64(value))\n    }\n\n    public func bind(_ value: Int64, toIndex index: Int) {\n        WCDBHandleStatementBindInteger(getRawStatement(), Int32(index), value)\n    }\n\n    public func bind(_ value: Double, toIndex index: Int) {\n        WCDBHandleStatementBindDouble(getRawStatement(), Int32(index), value)\n    }\n\n    public func bind(_ value: String, toIndex index: Int) {\n        WCDBHandleStatementBindText(getRawStatement(), Int32(index), value)\n    }\n\n    public func bind(_ value: Data, toIndex index: Int) {\n        value.withUnsafeBytes {buffer in\n            WCDBHandleStatementBindBlob(getRawStatement(), Int32(index), buffer.bindMemory(to: UInt8.self).baseAddress!, UInt64(value.count))\n        }\n    }\n\n    public func value(atIndex index: Int, of type: ColumnDecodable.Type) -> ColumnDecodable? {\n        guard columnType(atIndex: index) != .null else {\n            return nil\n        }\n        return type.init(with: value(atIndex: index))\n    }\n\n    public func value<ColumnDecodableType: ColumnDecodable>(\n        atIndex index: Int,\n        of type: ColumnDecodableType.Type = ColumnDecodableType.self) -> ColumnDecodableType? {\n        guard columnType(atIndex: index) != .null else {\n            return nil\n        }\n        return type.init(with: value(atIndex: index))\n    }\n\n    public func value(atIndex index: Int) -> Value {\n        switch columnType(atIndex: index) {\n        case .integer32:\n            return Value(columnValue(atIndex: index, of: Int32.self))\n        case .integer64:\n            return Value(columnValue(atIndex: index, of: Int64.self))\n        case .float:\n            return Value(columnValue(atIndex: index, of: Double.self))\n        case .text:\n            return Value(columnValue(atIndex: index, of: String.self))\n        case .BLOB:\n            return Value(columnValue(atIndex: index, of: Data.self))\n        case .null:\n            return Value(nil)\n        }\n    }\n\n    public func value<ColumnDecodableType: ColumnDecodable>(\n        byName name: String,\n        of type: ColumnDecodableType.Type = ColumnDecodableType.self) -> ColumnDecodableType? {\n        guard let index = index(byName: name) else {\n            return nil\n        }\n        return value(atIndex: index)\n    }\n\n    public func oneRowValue() -> OneRowValue {\n        var row: OneRowValue = []\n        for index in 0..<columnCount() {\n            row.append(value(atIndex: index))\n        }\n        return row\n    }\n\n    public func oneColumnValue(atIndex index: Int) throws -> OneColumnValue {\n        var column: OneColumnValue = []\n        while try step() {\n            column.append(value(atIndex: 0))\n        }\n        return column\n    }\n\n    public func multiRowsValue() throws -> MultiRowsValue {\n        var rows: MultiRowsValue = []\n        while try step() {\n            rows.append(oneRowValue())\n        }\n        return rows\n    }\n\n    public func extractObject<Object: TableDecodable>(on propertyConvertibleList: [PropertyConvertible]? = nil, of type: Object.Type = Object.self) throws -> Object {\n        let keys: [CodingTableKeyBase] = propertyConvertibleList?.asCodingTableKeys() ?? Object.Properties.all.asCodingTableKeys()\n        let decoder = TableDecoder(keys, on: self)\n        return try Object.init(from: decoder)\n    }\n\n    public func extractAllObjects<Object: TableDecodable>(on propertyConvertibleList: [PropertyConvertible]? = nil, of type: Object.Type = Object.self) throws -> [Object] {\n        let keys: [CodingTableKeyBase] = propertyConvertibleList?.asCodingTableKeys() ?? Object.Properties.all.asCodingTableKeys()\n        let decoder = TableDecoder(keys, on: self)\n        var objects: [Object] = []\n        while try step() {\n            objects.append(try Object.init(from: decoder))\n        }\n        return objects\n    }\n\n    public func index(byName name: String) -> Int? {\n        for index in 0..<columnCount() {\n            if columnName(atIndex: index)==name {\n                return index\n            }\n        }\n        return nil\n    }\n\n    public func indexOf(bindParameter: String) -> Int {\n        return Int(WCDBHandleStatementBindParameterIndex(getRawStatement(), bindParameter.cString))\n    }\n\n    public func columnValue(atIndex index: Int) -> Int32 {\n        columnValue(atIndex: index, of: Int32.self)\n    }\n\n    public func columnValue(atIndex index: Int, of type: Int32.Type = Int32.self) -> Int32 {\n        Int32(truncatingIfNeeded: WCDBHandleStatementGetInteger(getRawStatement(), Int32(index)))\n    }\n\n    public func columnValue(atIndex index: Int) -> Int64 {\n        columnValue(atIndex: index, of: Int64.self)\n    }\n\n    public func columnValue(atIndex index: Int, of type: Int64.Type = Int64.self) -> Int64 {\n        WCDBHandleStatementGetInteger(getRawStatement(), Int32(index))\n    }\n\n    public func columnValue(atIndex index: Int) -> Double {\n        columnValue(atIndex: index, of: Double.self)\n    }\n\n    public func columnValue(atIndex index: Int, of type: Double.Type = Double.self) -> Double {\n        WCDBHandleStatementGetDouble(getRawStatement(), Int32(index))\n    }\n\n    public func columnValue(atIndex index: Int) -> String {\n        columnValue(atIndex: index, of: String.self)\n    }\n\n    public func columnValue(atIndex index: Int, of type: String.Type = String.self) -> String {\n        guard let cString = WCDBHandleStatementGetText(getRawStatement(), Int32(index)) else {\n            return \"\"\n        }\n        return String(cString: cString)\n    }\n\n    public func columnValue(atIndex index: Int) -> Data {\n        columnValue(atIndex: index, of: Data.self)\n    }\n\n    public func columnValue(atIndex index: Int, of type: Data.Type = Data.self) -> Data {\n        guard let bytes = WCDBHandleStatementGetBlob(getRawStatement(), Int32(index)) else {\n            return Data()\n        }\n        let count = Int(WCDBHandleStatementGetColumnSize(getRawStatement(), Int32(index)))\n        return Data(bytes: bytes, count: count)\n    }\n\n    public func columnCount() -> Int {\n        return Int(WCDBHandleStatementGetColumnCount(getRawStatement()))\n    }\n\n    public func columnName(atIndex index: Int) -> String {\n        guard let cString = WCDBHandleStatementGetColumnName(getRawStatement(), Int32(index)) else {\n            return \"\"\n        }\n        return String(cString: cString)\n    }\n\n    public func columnType(byName name: String) -> ColumnType {\n        guard let index = index(byName: name) else {\n            return .null\n        }\n        return columnType(atIndex: index)\n    }\n\n    public func columnType(atIndex index: Int) -> ColumnType {\n        switch WCDBHandleStatementGetColumnType(getRawStatement(), Int32(index)) {\n        case WCDBColumnValueTypeInterger:\n            return ColumnType.integer64\n        case WCDBColumnValueTypeFloat:\n            return ColumnType.float\n        case WCDBColumnValueTypeBLOB:\n            return ColumnType.BLOB\n        case WCDBColumnValueTypeString:\n            return ColumnType.text\n        default:\n            return ColumnType.null\n        }\n    }\n\n    public func originalColumnName(atIndex index: Int) -> String {\n        guard let cString = WCDBHandleStatementGetOriginalColumnName(getRawStatement(), Int32(index)) else {\n            return \"\"\n        }\n        return String(cString: cString)\n    }\n\n    public func columnTableName(atIndex index: Int) -> String {\n        guard let cString = WCDBHandleStatementGetColumnTableName(getRawStatement(), Int32(index)) else {\n            return \"\"\n        }\n        return String(cString: cString)\n    }\n}\n"
  },
  {
    "path": "src/swift/core/interface/StatementSelectInterface.swift",
    "content": "//\n// Created by qiuwenchen on 2023/3/14.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport Foundation\n#if SWIFT_PACKAGE\nimport WCDB_Private\n#elseif WCDB_SWIFT_TARGET\nimport WCDBSwift.Private\n#else\nimport WCDB.Private\n#endif\n\n/// Convenient interface for getting result with statement\npublic protocol StatementSelectInterface: AnyObject {\n\n    /// Get value by specific statement.\n    ///\n    /// - Parameters:\n    ///   - statement: Specific statement\n    /// - Returns: `Value`\n    /// - Throws: `Error`\n    func getValue(from statement: Statement) throws -> Value?\n\n    /// Get a column of values by specific statement.\n    ///\n    /// - Parameters:\n    ///   - statement: Specific statement\n    /// - Returns: `OneColumnValue`\n    /// - Throws: `Error`\n    func getColumn(from statement: Statement) throws -> OneColumnValue\n\n    /// Get a row of values by specific statement.\n    ///\n    /// - Parameters:\n    ///   - statement: Specific statement\n    /// - Returns: `OneRowValue`\n    /// - Throws: `Error`\n    func getRow(from statement: Statement) throws -> OneRowValue?\n\n    /// Get multi rows of values by specific statement.\n    ///\n    /// - Parameters:\n    ///   - statement: Specific statement\n    /// - Returns: `OneRowValue`\n    /// - Throws: `Error`\n    func getRows(from statement: Statement) throws -> MultiRowsValue\n}\n\nextension StatementSelectInterface where Self: HandleRepresentable {\n\n    public func getValue(from statement: Statement) throws -> Value? {\n        let handle = try getHandle(writeHint: false)\n        try handle.prepare(statement)\n        guard try handle.step() else {\n            handle.finalize()\n            return nil\n        }\n        let result = handle.value(atIndex: 0)\n        handle.finalize()\n        return result\n    }\n\n    public func getColumn(from statement: Statement) throws -> OneColumnValue {\n        let handle = try getHandle(writeHint: false)\n        try handle.prepare(statement)\n        let result = try handle.oneColumnValue(atIndex: 0)\n        handle.finalize()\n        return result\n    }\n\n    public func getRow(from statement: Statement) throws -> OneRowValue? {\n        let handle = try getHandle(writeHint: false)\n        try handle.prepare(statement)\n        guard try handle.step() else {\n            handle.finalize()\n            return nil\n        }\n        let result = handle.oneRowValue()\n        handle.finalize()\n        return result\n    }\n\n    public func getRows(from statement: Statement) throws -> MultiRowsValue {\n        let handle = try getHandle(writeHint: false)\n        try handle.prepare(statement)\n        let result = try handle.multiRowsValue()\n        handle.finalize()\n        return result\n    }\n}\n"
  },
  {
    "path": "src/swift/core/interface/TableCRUDInterface+WCTTableCoding.swift",
    "content": "//\n// Created by qiuwenchen on 2022/11/13.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#if WCDB_SWIFT_BRIDGE_OBJC\n\nimport Foundation\n#if SWIFT_PACKAGE\nimport WCDB_Private\n#elseif WCDB_SWIFT_TARGET\nimport WCDBSwift.Private\n#else\nimport WCDB.Private\n#endif\n\npublic protocol InsertTableInterfaceForObjc: AnyObject {\n    associatedtype Object: WCTTableCoding\n\n    func insert(_ objects: Object..., on propertyConvertibleList: [PropertyConvertible]?) throws\n    func insert(_ objects: [Object], on propertyConvertibleList: [PropertyConvertible]?) throws\n    func insertOrReplace(_ objects: Object..., on propertyConvertibleList: [PropertyConvertible]?) throws\n    func insertOrReplace(_ objects: [Object], on propertyConvertibleList: [PropertyConvertible]?) throws\n    func insertOrIgnore(_ objects: Object..., on propertyConvertibleList: [PropertyConvertible]?) throws\n    func insertOrIgnore(_ objects: [Object], on propertyConvertibleList: [PropertyConvertible]?) throws\n}\n\npublic protocol UpdateTableInterfaceForObjc: AnyObject {\n    associatedtype Object: WCTTableCoding\n\n    func update(on propertyConvertibleList: PropertyConvertible...,\n                with object: Object,\n                where condition: Condition?,\n                orderBy orderList: [OrderBy]?,\n                limit: Limit?,\n                offset: Offset?) throws\n    func update(on propertyConvertibleList: [PropertyConvertible],\n                with object: Object,\n                where condition: Condition?,\n                orderBy orderList: [OrderBy]?,\n                limit: Limit?,\n                offset: Offset?) throws\n    func update(on propertyConvertibleList: PropertyConvertible...,\n                with row: [ColumnEncodable],\n                where condition: Condition?,\n                orderBy orderList: [OrderBy]?,\n                limit: Limit?,\n                offset: Offset?) throws\n    func update(on propertyConvertibleList: [PropertyConvertible],\n                with row: [ColumnEncodable],\n                where condition: Condition?,\n                orderBy orderList: [OrderBy]?,\n                limit: Limit?,\n                offset: Offset?) throws\n}\n\npublic protocol SelectTableInterfaceForObjc: AnyObject {\n    associatedtype Object: WCTTableCoding\n\n    // TODO: Add generic property convertible to fit the type\n    func getObjects(on propertyConvertibleList: [PropertyConvertible],\n                    where condition: Condition?,\n                    orderBy orderList: [OrderBy]?,\n                    limit: Limit?,\n                    offset: Offset?) throws -> [Object]\n    func getObjects(on propertyConvertibleList: PropertyConvertible...,\n                    where condition: Condition?,\n                    orderBy orderList: [OrderBy]?,\n                    limit: Limit?,\n                    offset: Offset?) throws -> [Object]\n\n    func getObject(on propertyConvertibleList: [PropertyConvertible],\n                   where condition: Condition?,\n                   orderBy orderList: [OrderBy]?,\n                   offset: Offset?) throws -> Object?\n    func getObject(on propertyConvertibleList: PropertyConvertible...,\n                   where condition: Condition?,\n                   orderBy orderList: [OrderBy]?,\n                   offset: Offset?) throws -> Object?\n}\n\n#endif\n"
  },
  {
    "path": "src/swift/core/interface/TableCRUDInterface.swift",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport Foundation\n#if SWIFT_PACKAGE\nimport WCDB_Private\n#elseif WCDB_SWIFT_TARGET\nimport WCDBSwift.Private\n#else\nimport WCDB.Private\n#endif\n\npublic protocol InsertTableInterface: AnyObject {\n    associatedtype Object: TableEncodable\n\n    func insert(_ objects: Object..., on propertyConvertibleList: [PropertyConvertible]?) throws\n    func insert(_ objects: [Object], on propertyConvertibleList: [PropertyConvertible]?) throws\n    func insertOrReplace(_ objects: Object..., on propertyConvertibleList: [PropertyConvertible]?) throws\n    func insertOrReplace(_ objects: [Object], on propertyConvertibleList: [PropertyConvertible]?) throws\n    func insertOrIgnore(_ objects: Object..., on propertyConvertibleList: [PropertyConvertible]?) throws\n    func insertOrIgnore(_ objects: [Object], on propertyConvertibleList: [PropertyConvertible]?) throws\n}\n\npublic protocol UpdateTableInterface: AnyObject {\n    associatedtype Object: TableEncodable\n\n    func update(on propertyConvertibleList: PropertyConvertible...,\n                with object: Object,\n                where condition: Condition?,\n                orderBy orderList: [OrderBy]?,\n                limit: Limit?,\n                offset: Offset?) throws\n    func update(on propertyConvertibleList: [PropertyConvertible],\n                with object: Object,\n                where condition: Condition?,\n                orderBy orderList: [OrderBy]?,\n                limit: Limit?,\n                offset: Offset?) throws\n    func update(on propertyConvertibleList: PropertyConvertible...,\n                with row: [ColumnEncodable?],\n                where condition: Condition?,\n                orderBy orderList: [OrderBy]?,\n                limit: Limit?,\n                offset: Offset?) throws\n    func update(on propertyConvertibleList: PropertyConvertible...,\n                with row: ColumnEncodable?...,\n                where condition: Condition?,\n                orderBy orderList: [OrderBy]?,\n                limit: Limit?,\n                offset: Offset?) throws\n    func update(on propertyConvertibleList: [PropertyConvertible],\n                with row: ColumnEncodable?...,\n                where condition: Condition?,\n                orderBy orderList: [OrderBy]?,\n                limit: Limit?,\n                offset: Offset?) throws\n    func update(on propertyConvertibleList: [PropertyConvertible],\n                with row: [ColumnEncodable?],\n                where condition: Condition?,\n                orderBy orderList: [OrderBy]?,\n                limit: Limit?,\n                offset: Offset?) throws\n}\n\npublic protocol DeleteTableInterface: AnyObject {\n    func delete(where condition: Condition?, orderBy orderList: [OrderBy]?, limit: Limit?, offset: Offset?) throws\n}\n\npublic protocol RowSelectTableInterface: AnyObject {\n    func getRows(on resultColumnConvertibleList: [ResultColumnConvertible],\n                 where condition: Condition?,\n                 orderBy orderList: [OrderBy]?,\n                 limit: Limit?,\n                 offset: Offset?) throws -> MultiRowsValue\n    func getRows(on resultColumnConvertibleList: ResultColumnConvertible...,\n                 where condition: Condition?,\n                 orderBy orderList: [OrderBy]?,\n                 limit: Limit?,\n                 offset: Offset?) throws -> MultiRowsValue\n\n    func getRow(on resultColumnConvertibleList: ResultColumnConvertible...,\n                where condition: Condition?,\n                orderBy orderList: [OrderBy]?,\n                offset: Offset?) throws -> OneRowValue\n    func getRow(on resultColumnConvertibleList: [ResultColumnConvertible],\n                where condition: Condition?,\n                orderBy orderList: [OrderBy]?,\n                offset: Offset?) throws -> OneRowValue\n\n    func getColumn(on result: ResultColumnConvertible,\n                   where condition: Condition?,\n                   orderBy orderList: [OrderBy]?,\n                   limit: Limit?,\n                   offset: Offset?) throws -> OneColumnValue\n    func getDistinctColumn(on result: ResultColumnConvertible,\n                           where condition: Condition?,\n                           orderBy orderList: [OrderBy]?,\n                           limit: Limit?,\n                           offset: Offset?) throws -> OneColumnValue\n\n    func getValue(on result: ResultColumnConvertible,\n                  where condition: Condition?,\n                  orderBy orderList: [OrderBy]?,\n                  limit: Limit?,\n                  offset: Offset?) throws -> Value\n    func getDistinctValue(on result: ResultColumnConvertible,\n                          where condition: Condition?,\n                          orderBy orderList: [OrderBy]?,\n                          limit: Limit?,\n                          offset: Offset?) throws -> Value\n}\n\npublic protocol SelectTableInterface: AnyObject {\n    associatedtype Object: TableDecodable\n\n    // TODO: Add generic property convertible to fit the type\n    func getObjects(on propertyConvertibleList: [PropertyConvertible],\n                    where condition: Condition?,\n                    orderBy orderList: [OrderBy]?,\n                    limit: Limit?,\n                    offset: Offset?) throws -> [Object]\n    func getObjects(on propertyConvertibleList: PropertyConvertible...,\n                    where condition: Condition?,\n                    orderBy orderList: [OrderBy]?,\n                    limit: Limit?,\n                    offset: Offset?) throws -> [Object]\n\n    func getObject(on propertyConvertibleList: [PropertyConvertible],\n                   where condition: Condition?,\n                   orderBy orderList: [OrderBy]?,\n                   offset: Offset?) throws -> Object?\n    func getObject(on propertyConvertibleList: PropertyConvertible...,\n                   where condition: Condition?,\n                   orderBy orderList: [OrderBy]?,\n                   offset: Offset?) throws -> Object?\n}\n"
  },
  {
    "path": "src/swift/core/interface/TableInterface+WCTTableCoding.swift",
    "content": "//\n// Created by qiuwenchen on 2022/11/13.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#if WCDB_SWIFT_BRIDGE_OBJC\n\nimport Foundation\n#if SWIFT_PACKAGE\nimport WCDB_Private\n#elseif WCDB_SWIFT_TARGET\nimport WCDBSwift.Private\n#else\nimport WCDB.Private\n#endif\n\n/// Convenient interface for table related operation\npublic protocol TableInterfaceForObjc: AnyObject {\n    /// Create table, related indexes and constraints with specific type\n    ///\n    /// Note that it will create defined indexes automatically.\n    /// The name of index is `\"\\(tableName)\\(indexSuffixName)\"` while `indexSuffixName` is defined by `IndexBinding`.\n    /// BUT, it will not drop the undefined indexes. You should drop it manually.\n    ///\n    /// Note that it will add the newly defined column automatically.\n    /// AND, it will skip the undefined column. It can be very developer-friendly while upgrading your database column.\n    ///\n    /// Note that it will run embedded transaction\n    /// The embedded transaction means that it will run a transaction if it's not in other transaction,\n    /// otherwise it will be executed within the existing transaction.\n    ///\n    /// - Parameters:\n    ///   - name: Table name.\n    ///   - rootType: Type of table encodable object\n    /// - Throws: `Error`\n    func create<Root: WCTTableCoding>(table name: String, of rootType: Root.Type) throws\n\n    /// Create virtual table and constraints with specific type\n    ///\n    /// Note that it will run embedded transaction\n    /// The embedded transaction means that it will run a transaction if it's not in other transaction,\n    /// otherwise it will be executed within the existing transaction.\n    ///\n    /// - Parameters:\n    ///   - name: Table name.\n    ///   - rootType: Type of table encodable object\n    /// - Throws: `Error`\n    func create<Root: WCTTableCoding>(virtualTable name: String, of rootType: Root.Type) throws\n}\n\nextension TableInterfaceForObjc where Self: Database {\n    public func create<Root: WCTTableCoding>(\n        table name: String,\n        of rootType: Root.Type) throws {\n            let handle = try getHandle(writeHint: true)\n            try withExtendedLifetime(handle) {\n                if !WCTAPIBridge.createTable(name, withClass: rootType, with: $0.cppHandle) {\n                    throw handle.getError()\n                }\n            }\n        }\n\n    public func create<Root: WCTTableCoding>(virtualTable name: String, of rootType: Root.Type) throws {\n        let handle = try getHandle(writeHint: true)\n        if !WCTAPIBridge.createVirtualTable(name, withClass: rootType, with: handle.cppHandle) {\n            throw handle.getError()\n        }\n    }\n}\n\n#endif\n"
  },
  {
    "path": "src/swift/core/interface/TableInterface.swift",
    "content": "//\n// Created by qiuwenchen on 2022/9/13.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport Foundation\n#if SWIFT_PACKAGE\nimport WCDB_Private\n#elseif WCDB_SWIFT_TARGET\nimport WCDBSwift.Private\n#else\nimport WCDB.Private\n#endif\n\n/// Convenient interface for table related operation\npublic protocol TableInterface: AnyObject {\n    /// Create table, related indexes and constraints with specific type\n    ///\n    /// Note that it will create defined indexes automatically.\n    /// The name of index is `\"\\(tableName)\\(indexSuffixName)\"` while `indexSuffixName` is defined by `IndexBinding`.\n    /// BUT, it will not drop the undefined indexes. You should drop it manually.\n    ///\n    /// Note that it will add the newly defined column automatically.\n    /// AND, it will skip the undefined column. It can be very developer-friendly while upgrading your database column.\n    ///\n    /// Note that it will run embedded transaction\n    /// The embedded transaction means that it will run a transaction if it's not in other transaction,\n    /// otherwise it will be executed within the existing transaction.\n    ///\n    /// - Parameters:\n    ///   - name: Table name.\n    ///   - rootType: Type of table encodable object\n    /// - Throws: `Error`\n    func create<Root: TableDecodable>(table name: String, of rootType: Root.Type) throws\n\n    /// Create virtual table and constraints with specific type\n    ///\n    /// Note that it will run embedded transaction\n    /// The embedded transaction means that it will run a transaction if it's not in other transaction,\n    /// otherwise it will be executed within the existing transaction.\n    ///\n    /// - Parameters:\n    ///   - name: Table name.\n    ///   - rootType: Type of table encodable object\n    /// - Throws: `Error`\n    func create<Root: TableDecodable>(virtualTable name: String, of rootType: Root.Type) throws\n\n    /// Create table manually\n    ///\n    /// - Parameters:\n    ///   - name: Table name\n    ///   - columnDefList: WINQ column definition list\n    ///   - constraintList: WINQ constraint list.\n    /// - Throws: `Error`\n    func create(table name: String, with columnDefList: [ColumnDef], and constraintList: [TableConstraint]?) throws\n\n    /// Create table manually\n    ///\n    /// - Parameters:\n    ///   - name: Table name\n    ///   - columnDefList: WINQ column definition list\n    ///   - constraintList: WINQ constraint list.\n    /// - Throws: `Error`\n    func create(table name: String, with columnDefList: ColumnDef..., and constraintList: [TableConstraint]?) throws\n\n    /// Get a wrapper from an existing table.\n    ///\n    /// - Parameters:\n    ///   - name: The name of the table.\n    ///   - type: A class conform to TableCodable protocol.\n    /// - Returns: Table.\n    /// - Throws: `Error`\n    func getTable<Root: TableCodable>(\n        named name: String,\n        of type: Root.Type) -> Table<Root>\n\n    /// Check the existence of the table.\n    ///\n    /// - Parameter table: The name of the table.\n    /// - Returns: false for a non-existent table.\n    /// - Throws: `Error`\n    func isTableExists(_ table: String) throws -> Bool\n\n    /// Create new column\n    ///\n    /// - Parameters:\n    ///   - columnDef: WINQ column definition\n    ///   - table: Table name\n    /// - Throws: `Error`\n    func addColumn(with columnDef: ColumnDef, forTable table: String) throws\n\n    /// Drop table\n    ///\n    /// - Parameter name: Table name\n    /// - Throws: `Erro`\n    func drop(table name: String) throws\n\n    /// Create index manually\n    ///\n    /// - Parameters:\n    ///   - name: Index name\n    ///   - indexedColumnConvertibleList: WINQ column index list\n    ///   - table: Table name\n    /// - Throws: `Error`\n    func create(index name: String,\n                with indexedColumnConvertibleList: [IndexedColumnConvertible],\n                forTable table: String) throws\n\n    /// Create index manually\n    ///\n    /// - Parameters:\n    ///   - name: Index name\n    ///   - indexedColumnConvertibleList: WINQ column index list\n    ///   - table: Table name\n    /// - Throws: `Error`\n    func create(index name: String,\n                with indexedColumnConvertibleList: IndexedColumnConvertible...,\n                forTable table: String) throws\n\n    /// Drop index\n    ///\n    /// - Parameter name: Index name\n    /// - Throws: `Error`\n    func drop(index name: String) throws\n}\n\nextension TableInterface where Self: HandleRepresentable {\n    public func create<Root: TableDecodable>(\n        table name: String,\n        of rootType: Root.Type) throws {\n            let handle = try getHandle(writeHint: true)\n            let ret = WCDBBindingCreateTable(rootType.CodingKeys.objectRelationalMapping.innerBinding, name.cString, handle.cppHandle)\n            if !ret {\n                throw handle.getError()\n            }\n    }\n\n    public func create<Root: TableDecodable>(virtualTable name: String, of rootType: Root.Type) throws {\n        let handle = try getHandle(writeHint: true)\n        let ret = WCDBBindingCreateVirtualTable(rootType.CodingKeys.objectRelationalMapping.innerBinding, name.cString, handle.cppHandle)\n        if !ret {\n            throw handle.getError()\n        }\n    }\n\n    public func create(table name: String,\n                       with columnDefList: ColumnDef...,\n                       and constraintList: [TableConstraint]? = nil) throws {\n        try create(table: name, with: columnDefList, and: constraintList)\n    }\n\n    public func create(table name: String,\n                       with columnDefList: [ColumnDef],\n                       and constraintList: [TableConstraint]? = nil) throws {\n        try getHandle(writeHint: true).exec(StatementCreateTable().create(table: name).ifNotExists().with(columns: columnDefList).constraint(constraintList))\n    }\n\n    public func getTable<Root: TableCodable>(\n        named name: String,\n        of type: Root.Type = Root.self) -> Table<Root> {\n        return Table<Root>(withDatabase: getDatabase(), named: name)\n    }\n\n    public func isTableExists(_ table: String) throws -> Bool {\n        let handle = try getHandle(writeHint: false)\n        let ret = WCDBHandleExistTable(handle.cppHandle, table)\n        if !ret.hasValue {\n            let error = WCDBHandleGetError(handle.cppHandle)\n            throw ErrorBridge.getErrorFrom(cppError: error)\n        }\n        return ret.value\n    }\n\n    public func addColumn(with columnDef: ColumnDef, forTable table: String) throws {\n        try getHandle(writeHint: true).exec(StatementAlterTable().alter(table: table).addColumn(with: columnDef))\n    }\n\n    public func drop(table name: String) throws {\n        try getHandle(writeHint: true).exec(StatementDropTable().drop(table: name).ifExists())\n    }\n\n    public func create(index name: String,\n                       with indexedColumnConvertibleList: IndexedColumnConvertible...,\n                       forTable table: String) throws {\n        try create(index: name, with: indexedColumnConvertibleList, forTable: table)\n    }\n\n    public func create(index name: String,\n                       with indexedColumnConvertibleList: [IndexedColumnConvertible],\n                       forTable table: String) throws {\n        try getHandle(writeHint: true).exec(StatementCreateIndex().create(index: name).on(table: table).ifNotExists().indexesBy( indexedColumnConvertibleList))\n    }\n\n    public func drop(index name: String) throws {\n        try getHandle(writeHint: true).exec(StatementDropIndex().drop(index: name).ifExists())\n    }\n}\n"
  },
  {
    "path": "src/swift/core/interface/TransactionInterface.swift",
    "content": "//\n// Created by qiuwenchen on 2022/9/13.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport Foundation\n#if SWIFT_PACKAGE\nimport WCDB_Private\n#elseif WCDB_SWIFT_TARGET\nimport WCDBSwift.Private\n#else\nimport WCDB.Private\n#endif\n\npublic protocol TransactionInterface {\n    /// Separate interface of `run(transaction:)`\n    /// You should call `begin`, `commit`, `rollback` and all other operations in same thread.\n    /// - Throws: `Error`\n    func begin() throws\n\n    /// Separate interface of `run(transaction:)`\n    /// You should call `begin`, `commit`, `rollback` and all other operations in same thread.\n    /// - Throws: `Error`\n    func commit() throws\n\n    /// Separate interface of run(transaction:)\n    /// You should call `begin`, `commit`, `rollback` and all other operations in same thread.\n    /// Throws: `Error`\n    func rollback() throws\n\n    /// Check whether the current database has begun a transaction in the current thread.\n    var isInTransaction: Bool { get }\n\n    /// Run a transaction in closure. Transaction supports nesting.\n    ///\n    ///     try database.run(transaction: { _ in\n    ///         try database.insert(objects, intoTable: table)\n    ///     })\n    ///\n    /// - Parameter transaction: Operation inside transaction\n    /// - Throws: `Error`\n    typealias TransactionClosure = (Handle) throws -> Void\n    func run(transaction: @escaping TransactionClosure) throws\n\n    /// Run a controllable transaction in closure\n    ///\n    ///     try database.run(controllableTransaction: { _ in\n    ///         try database.insert(objects, intoTable: table)\n    ///         return true // return true to commit transaction and return false to rollback transaction.\n    ///     })\n    ///\n    /// - Parameter controllableTransaction: Operation inside transaction\n    /// - Throws: `Error`\n    typealias ControlableTransactionClosure = (Handle) throws -> Bool\n    func run(controllableTransaction: @escaping ControlableTransactionClosure) throws\n\n    typealias PausableTransactionClosure = (Handle, inout Bool, Bool) throws -> Void\n    /// Run a pausable transaction in block.\n    ///\n    /// Firstly, WCDB will begin a transaction and call the block.\n    /// After the block is finished, WCDB will check whether the main thread is suspended due to the current transaction.\n    /// If not, it will call the block again; if it is, it will temporarily commit the current transaction.\n    /// Once database operations in main thread are finished, WCDB will rebegin a new transaction in the current thread and call the block.\n    /// This process will be repeated until the second parameter of the block is specified as true, or some error occurs during the transaction.\n    ///\n    ///     try self.database.run(pausableTransaction: { (handle, stop, isNewTransaction) in\n    ///         if (isNewTransaction) {\n    ///             // Do some initialization for new transaction.\n    ///         }\n    ///\n    ///         // Perform a small amount of data processing.\n    ///\n    ///         if( All database operations are finished ) {\n    ///             stop = true;\n    ///         }\n    ///     }\n    ///\n    /// - Parameter pausableTransaction: Operation inside transaction for one loop.\n    /// - Throws: `Error`\n    func run(pausableTransaction: @escaping PausableTransactionClosure) throws\n}\n\nextension TransactionInterface where Self: HandleRepresentable {\n    public func begin() throws {\n        let handle = try getHandle(writeHint: true)\n        if !WCDBHandleBeginTransaction(handle.cppHandle) {\n            throw handle.getError()\n        }\n    }\n\n    public func commit() throws {\n        let handle = try getHandle(writeHint: true)\n        if !WCDBHandleCommitTransaction(handle.cppHandle) {\n            throw handle.getError()\n        }\n    }\n\n    public func rollback() throws {\n        let handle = try getHandle(writeHint: true)\n        WCDBHandleRollbackTransaction(handle.cppHandle)\n    }\n\n    public var isInTransaction: Bool {\n        guard let handle = try? getHandle(writeHint: true) else {\n            return false\n        }\n        return WCDBHandleIsInTransaction(handle.cppHandle)\n    }\n\n    public func run(transaction: @escaping TransactionClosure) throws {\n        let handle = try getHandle(writeHint: true)\n        if handle.isInTransaction {\n            try transaction(handle)\n            return\n        }\n        let cppTransaction: @convention(c) (UnsafeMutableRawPointer, CPPHandle) -> Bool = {\n            cppContext, cppHandle in\n            let transactionWrap: ValueWrap<(CPPHandle) -> Bool>? = ObjectBridge.extractTypedSwiftObject(cppContext)\n            guard let transactionWrap = transactionWrap else {\n                return false\n            }\n            return transactionWrap.value(cppHandle)\n        }\n        let transactionBlock: (CPPHandle) -> Bool = {\n            cppHandle in\n            let handle = Handle(withCPPHandle: cppHandle, database: getDatabase())\n            var ret = true\n            do {\n                try transaction(handle)\n            } catch {\n                ret = false\n            }\n            return ret\n        }\n        let transactionWrap = ValueWrap(transactionBlock)\n        let transactionWrapPointer = ObjectBridge.getUntypeSwiftObject(transactionWrap)\n        let ret = WCDBHandleRunTransaction(handle.cppHandle, transactionWrapPointer, cppTransaction)\n        ObjectBridge.releaseSwiftObject(transactionWrapPointer)\n        if !ret {\n            throw handle.getError()\n        }\n    }\n\n    public func run(controllableTransaction: @escaping ControlableTransactionClosure) throws {\n        var transactionRet = true\n        let transactionBlock: (CPPHandle) -> Bool = {\n            cppHandle in\n            let handle = Handle(withCPPHandle: cppHandle, database: getDatabase())\n            var ret = true\n            do {\n                transactionRet = try controllableTransaction(handle)\n            } catch {\n                ret = false\n            }\n            return ret && transactionRet\n        }\n        let transactionWrap = ValueWrap(transactionBlock)\n        let transactionWrapPointer = ObjectBridge.getUntypeSwiftObject(transactionWrap)\n\n        let cppTransaction: @convention(c) (UnsafeMutableRawPointer, CPPHandle) -> Bool = {\n            cppContext, cppHandle in\n            let transactionWrap: ValueWrap<(CPPHandle) -> Bool>? = ObjectBridge.extractTypedSwiftObject(cppContext)\n            guard let transactionWrap = transactionWrap else {\n                return false\n            }\n            return transactionWrap.value(cppHandle)\n        }\n\n        let handle = try getHandle(writeHint: true)\n        let ret = WCDBHandleRunTransaction(handle.cppHandle, transactionWrapPointer, cppTransaction)\n        ObjectBridge.releaseSwiftObject(transactionWrapPointer)\n\n        if !ret && transactionRet {\n            throw handle.getError()\n        }\n    }\n\n    public func run(pausableTransaction: @escaping PausableTransactionClosure) throws {\n        let handle = try getHandle(writeHint: true)\n        let transactionBlock: (CPPHandle, UnsafeMutablePointer<Bool>, Bool) -> Bool = {\n            _, cStop, isNewTransaction in\n            var ret = true\n            var stop = false\n            do {\n                try pausableTransaction(handle, &stop, isNewTransaction)\n                cStop.pointee = stop\n            } catch {\n                ret = false\n            }\n            return ret\n        }\n        let transactionWrap = ValueWrap(transactionBlock)\n        let transactionWrapPointer = ObjectBridge.getUntypeSwiftObject(transactionWrap)\n        let cppTransaction: @convention(c) (UnsafeMutableRawPointer, CPPHandle, UnsafeMutablePointer<Bool>, Bool) -> Bool = {\n            cppContext, cppHandle, canContinue, isNewTransaction in\n            let transactionWrap: ValueWrap<(CPPHandle, UnsafeMutablePointer<Bool>, Bool) -> Bool>? = ObjectBridge.extractTypedSwiftObject(cppContext)\n            guard let transactionWrap = transactionWrap else {\n                return false\n            }\n            return transactionWrap.value(cppHandle, canContinue, isNewTransaction)\n        }\n\n        let ret = WCDBHandleRunPausableTransaction(handle.cppHandle, transactionWrapPointer, cppTransaction)\n        ObjectBridge.objectDestructor(transactionWrapPointer)\n        if !ret {\n            throw handle.getError()\n        }\n    }\n}\n"
  },
  {
    "path": "src/swift/core/interface/UpdateInterface+WCTTableCoding.swift",
    "content": "//\n// Created by qiuwenchen on 2022/11/13.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#if WCDB_SWIFT_BRIDGE_OBJC\n\nimport Foundation\n#if SWIFT_PACKAGE\nimport WCDB_Private\n#elseif WCDB_SWIFT_TARGET\nimport WCDBSwift.Private\n#else\nimport WCDB.Private\n#endif\n\n/// Convenient interface for updating\npublic protocol UpdateInterfaceForObjc: AnyObject {\n\n    /// Execute updating with `TableEncodable` object on specific(or all) properties.\n    ///\n    /// - Parameters:\n    ///   - table: Table name\n    ///   - propertyConvertibleList: `Property` or `CodingTableKey` list\n    ///   - object: Table encodable object\n    ///   - condition: Expression convertible\n    ///   - orderList: Order convertible list\n    ///   - limit: Expression convertible\n    ///   - offset: Expression convertible\n    /// - Throws: `Error`\n    func update<Object: WCTTableCoding>(\n        table: String,\n        on propertyConvertibleList: PropertyConvertible...,\n        with object: Object,\n        where condition: Condition?,\n        orderBy orderList: [OrderBy]?,\n        limit: Limit?,\n        offset: Offset?) throws\n\n    /// Execute updating with `TableEncodable` object on specific(or all) properties.\n    ///\n    /// - Parameters:\n    ///   - table: Table name\n    ///   - propertyConvertibleList: `Property` or `CodingTableKey` list\n    ///   - object: Table encodable object\n    ///   - condition: Expression convertible\n    ///   - orderList: Order convertible list\n    ///   - limit: Expression convertible\n    ///   - offset: Expression convertible\n    /// - Throws: `Error`\n    func update<Object: WCTTableCoding>(\n        table: String,\n        on propertyConvertibleList: [PropertyConvertible],\n        with object: Object,\n        where condition: Condition?,\n        orderBy orderList: [OrderBy]?,\n        limit: Limit?,\n        offset: Offset?) throws\n}\n\nextension UpdateInterface where Self: HandleRepresentable {\n    public func update<Object: WCTTableCoding>(\n        table: String,\n        on propertyConvertibleList: [PropertyConvertible],\n        with object: Object,\n        where condition: Condition? = nil,\n        orderBy orderList: [OrderBy]? = nil,\n        limit: Limit? = nil,\n        offset: Offset? = nil) throws {\n        let update = Update(with: try getHandle(writeHint: true), on: propertyConvertibleList, andTable: table)\n        if condition != nil {\n            update.where(condition!)\n        }\n        if orderList != nil {\n            update.order(by: orderList!)\n        }\n        if limit != nil {\n            if offset != nil {\n                update.limit(limit!, offset: offset!)\n            } else {\n                update.limit(limit!)\n            }\n        }\n        return try update.execute(with: object)\n    }\n\n    public func update<Object: WCTTableCoding>(\n        table: String,\n        on propertyConvertibleList: PropertyConvertible...,\n        with object: Object,\n        where condition: Condition? = nil,\n        orderBy orderList: [OrderBy]? = nil,\n        limit: Limit? = nil,\n        offset: Offset? = nil) throws {\n        return try update(table: table,\n                          on: propertyConvertibleList,\n                          with: object,\n                          where: condition,\n                          orderBy: orderList,\n                          limit: limit,\n                          offset: offset)\n    }\n}\n\n#endif\n"
  },
  {
    "path": "src/swift/core/interface/UpdateInterface.swift",
    "content": "//\n// Created by qiuwenchen on 2022/9/12.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport Foundation\n#if SWIFT_PACKAGE\nimport WCDB_Private\n#elseif WCDB_SWIFT_TARGET\nimport WCDBSwift.Private\n#else\nimport WCDB.Private\n#endif\n\n/// Convenient interface for updating\npublic protocol UpdateInterface: AnyObject {\n\n    /// Execute updating with `TableEncodable` object on specific(or all) properties.\n    ///\n    /// - Parameters:\n    ///   - table: Table name\n    ///   - propertyConvertibleList: `Property` or `CodingTableKey` list\n    ///   - object: Table encodable object\n    ///   - condition: Expression convertible\n    ///   - orderList: Order convertible list\n    ///   - limit: Expression convertible\n    ///   - offset: Expression convertible\n    /// - Throws: `Error`\n    func update<Object: TableEncodable>(\n        table: String,\n        on propertyConvertibleList: PropertyConvertible...,\n        with object: Object,\n        where condition: Condition?,\n        orderBy orderList: [OrderBy]?,\n        limit: Limit?,\n        offset: Offset?) throws\n\n    /// Execute updating with `TableEncodable` object on specific(or all) properties.\n    ///\n    /// - Parameters:\n    ///   - table: Table name\n    ///   - propertyConvertibleList: `Property` or `CodingTableKey` list\n    ///   - object: Table encodable object\n    ///   - condition: Expression convertible\n    ///   - orderList: Order convertible list\n    ///   - limit: Expression convertible\n    ///   - offset: Expression convertible\n    /// - Throws: `Error`\n    func update<Object: TableEncodable>(\n        table: String,\n        on propertyConvertibleList: [PropertyConvertible],\n        with object: Object,\n        where condition: Condition?,\n        orderBy orderList: [OrderBy]?,\n        limit: Limit?,\n        offset: Offset?) throws\n\n    /// Execute updating with row on specific(or all) properties.\n    ///\n    /// - Parameters:\n    ///   - table: Table name\n    ///   - propertyConvertibleList: `Property` or `CodingTableKey` list\n    ///   - row: a row of ColumnEncodable value\n    ///   - condition: Expression convertible\n    ///   - orderList: Order convertible list\n    ///   - limit: Expression convertible\n    ///   - offset: Expression convertible\n    /// - Throws: `Error`\n    func update(table: String,\n                on propertyConvertibleList: PropertyConvertible...,\n                with row: [ColumnEncodable?],\n                where condition: Condition?,\n                orderBy orderList: [OrderBy]?,\n                limit: Limit?,\n                offset: Offset?) throws\n\n    /// Execute updating with row on specific(or all) properties.\n    ///\n    /// - Parameters:\n    ///   - table: Table name\n    ///   - propertyConvertibleList: `Property` or `CodingTableKey` list\n    ///   - row: a row of ColumnEncodable value\n    ///   - condition: Expression convertible\n    ///   - orderList: Order convertible list\n    ///   - limit: Expression convertible\n    ///   - offset: Expression convertible\n    /// - Throws: `Error`\n    func update(table: String,\n                on propertyConvertibleList: PropertyConvertible...,\n                with row: ColumnEncodable?...,\n                where condition: Condition?,\n                orderBy orderList: [OrderBy]?,\n                limit: Limit?,\n                offset: Offset?) throws\n\n    /// Execute updating with row on specific(or all) properties.\n    ///\n    /// - Parameters:\n    ///   - table: Table name\n    ///   - propertyConvertibleList: `Property` or `CodingTableKey` list\n    ///   - row: a row of ColumnEncodable value\n    ///   - condition: Expression convertible\n    ///   - orderList: Order convertible list\n    ///   - limit: Expression convertible\n    ///   - offset: Expression convertible\n    /// - Throws: `Error`\n    func update(table: String,\n                on propertyConvertibleList: [PropertyConvertible],\n                with row: ColumnEncodable?...,\n                where condition: Condition?,\n                orderBy orderList: [OrderBy]?,\n                limit: Limit?,\n                offset: Offset?) throws\n\n    /// Execute updating with row on specific(or all) properties.\n    ///\n    /// - Parameters:\n    ///   - table: Table name\n    ///   - propertyConvertibleList: `Property` or `CodingTableKey` list\n    ///   - row: a row of ColumnEncodable value\n    ///   - condition: Expression convertible\n    ///   - orderList: Order convertible list\n    ///   - limit: Expression convertible\n    ///   - offset: Expression convertible\n    /// - Throws: `Error`\n    func update(table: String,\n                on propertyConvertibleList: [PropertyConvertible],\n                with row: [ColumnEncodable?],\n                where condition: Condition?,\n                orderBy orderList: [OrderBy]?,\n                limit: Limit?,\n                offset: Offset?) throws\n}\n\nextension UpdateInterface where Self: HandleRepresentable {\n    public func update<Object: TableEncodable>(\n        table: String,\n        on propertyConvertibleList: [PropertyConvertible],\n        with object: Object,\n        where condition: Condition? = nil,\n        orderBy orderList: [OrderBy]? = nil,\n        limit: Limit? = nil,\n        offset: Offset? = nil) throws {\n        let update = Update(with: try getHandle(writeHint: true), on: propertyConvertibleList, andTable: table)\n        if condition != nil {\n            update.where(condition!)\n        }\n        if orderList != nil {\n            update.order(by: orderList!)\n        }\n        if limit != nil {\n            if offset != nil {\n                update.limit(limit!, offset: offset!)\n            } else {\n                update.limit(limit!)\n            }\n        }\n        return try update.execute(with: object)\n    }\n\n    public func update<Object: TableEncodable>(\n        table: String,\n        on propertyConvertibleList: PropertyConvertible...,\n        with object: Object,\n        where condition: Condition? = nil,\n        orderBy orderList: [OrderBy]? = nil,\n        limit: Limit? = nil,\n        offset: Offset? = nil) throws {\n        return try update(table: table,\n                          on: propertyConvertibleList,\n                          with: object,\n                          where: condition,\n                          orderBy: orderList,\n                          limit: limit,\n                          offset: offset)\n    }\n\n    public func update(table: String,\n                       on propertyConvertibleList: PropertyConvertible...,\n                       with row: [ColumnEncodable?],\n                       where condition: Condition? = nil,\n                       orderBy orderList: [OrderBy]? = nil,\n                       limit: Limit? = nil,\n                       offset: Offset? = nil) throws {\n        return try update(table: table,\n                          on: propertyConvertibleList,\n                          with: row,\n                          where: condition,\n                          orderBy: orderList,\n                          limit: limit,\n                          offset: offset)\n    }\n\n    public func update(table: String,\n                       on propertyConvertibleList: PropertyConvertible...,\n                       with row: ColumnEncodable?...,\n                       where condition: Condition? = nil,\n                       orderBy orderList: [OrderBy]? = nil,\n                       limit: Limit? = nil,\n                       offset: Offset? = nil) throws {\n        return try update(table: table,\n                          on: propertyConvertibleList,\n                          with: row,\n                          where: condition,\n                          orderBy: orderList,\n                          limit: limit,\n                          offset: offset)\n    }\n\n    public func update(table: String,\n                       on propertyConvertibleList: [PropertyConvertible],\n                       with row: ColumnEncodable?...,\n                       where condition: Condition? = nil,\n                       orderBy orderList: [OrderBy]? = nil,\n                       limit: Limit? = nil,\n                       offset: Offset? = nil) throws {\n        return try update(table: table,\n                          on: propertyConvertibleList,\n                          with: row,\n                          where: condition,\n                          orderBy: orderList,\n                          limit: limit,\n                          offset: offset)\n    }\n\n    public func update(table: String,\n                       on propertyConvertibleList: [PropertyConvertible],\n                       with row: [ColumnEncodable?],\n                       where condition: Condition? = nil,\n                       orderBy orderList: [OrderBy]? = nil,\n                       limit: Limit? = nil,\n                       offset: Offset? = nil) throws {\n        let update = Update(with: try getHandle(writeHint: true), on: propertyConvertibleList, andTable: table)\n        if condition != nil {\n            update.where(condition!)\n        }\n        if orderList != nil {\n            update.order(by: orderList!)\n        }\n        if limit != nil {\n            if offset != nil {\n                update.limit(limit!, offset: offset!)\n            } else {\n                update.limit(limit!)\n            }\n        }\n        return try update.execute(with: row)\n    }\n}\n"
  },
  {
    "path": "src/swift/tests/benchmark/baseline/BaselineBatchWriteBenchmark.swift",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport XCTest\n#if TEST_WCDB_SWIFT\nimport WCDBSwift\n#else\nimport WCDB\n#endif\n\nclass BaselineBatchWriteBenchmark: BaseBenchmark {\n\n    override func setUp() {\n        super.setUp()\n\n        setUpWithPreCreateObject(count: config.batchWriteCount)\n    }\n\n    func testBaselineBatchWrite() {\n        let tableName = getTableName()\n        measure(onSetUp: {\n            tearDownDatabase()\n\n            setUpWithPreCreateTable()\n\n            tearDownDatabaseCache()\n\n            setUpDatabaseCache()\n        }, for: {\n            do {\n                try database.insert(objects, intoTable: tableName)\n            } catch let error as WCDBError {\n                XCTFail(error.description)\n            } catch let error {\n                XCTFail(error.localizedDescription)\n            }\n        }, checkCorrectness: {\n            let count = try? database.getValue(on: Column.all().count(), fromTable: tableName)\n            XCTAssertEqual(Int(count?.int32Value ?? 0), config.batchWriteCount)\n        })\n    }\n}\n"
  },
  {
    "path": "src/swift/tests/benchmark/baseline/BaselineReadBenchmark.swift",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport XCTest\n\nclass BaselineReadBenchmark: BaseBenchmark {\n\n    override func setUp() {\n        super.setUp()\n\n        setUpWithPreCreateTable()\n\n        setUpWithPreInsertObjects(count: config.readCount)\n    }\n\n    func testBaselineRead() {\n        var results: [BenchmarkObject]?\n        let tableName = getTableName()\n        measure(onSetUp: {\n            results = nil\n\n            tearDownDatabaseCache()\n\n            setUpDatabaseCache()\n        }, for: {\n            results = try? database.getObjects(fromTable: tableName)\n        }, checkCorrectness: {\n            XCTAssertEqual(results?.count, config.readCount)\n        })\n    }\n}\n"
  },
  {
    "path": "src/swift/tests/benchmark/baseline/BaselineWriteBenchmark.swift",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport XCTest\n#if TEST_WCDB_SWIFT\nimport WCDBSwift\n#else\nimport WCDB\n#endif\n\nclass BaselineWriteBenchmark: BaseBenchmark {\n\n    override func setUp() {\n        super.setUp()\n\n        setUpWithPreCreateObject(count: config.writeCount)\n    }\n\n    func testBaselineWrite() {\n        let tableName = getTableName()\n        measure(onSetUp: {\n            tearDownDatabase()\n\n            setUpWithPreCreateTable()\n\n            tearDownDatabaseCache()\n\n            setUpDatabaseCache()\n        }, for: {\n            do {\n                for object in objects {\n                    try database.insert(object, intoTable: tableName)\n                }\n            } catch let error as WCDBError {\n                XCTFail(error.description)\n            } catch let error {\n                XCTFail(error.localizedDescription)\n            }\n        }, checkCorrectness: {\n            let count = try? database.getValue(on: Column.all().count(), fromTable: tableName)\n            XCTAssertEqual(Int(count?.int32Value ?? 0), config.writeCount)\n        })\n    }\n}\n"
  },
  {
    "path": "src/swift/tests/benchmark/cipher/CipherReadBenchmark.swift",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport XCTest\n\nclass CipherReadBenchmark: BaseBenchmark {\n\n    override func setUp() {\n        super.setUp()\n\n        database.setCipher(key: \"cipher\".data(using: .ascii)!)\n\n        setUpWithPreCreateTable()\n\n        setUpWithPreInsertObjects(count: config.readCount)\n    }\n\n    func testCipherRead() {\n        let tableName = getTableName()\n        var results: [BenchmarkObject]?\n        measure(onSetUp: {\n            results = nil\n\n            tearDownDatabaseCache()\n\n            setUpDatabaseCache()\n        }, for: {\n            results = try? database.getObjects(fromTable: tableName)\n        }, checkCorrectness: {\n            XCTAssertEqual(results?.count, config.readCount)\n        })\n    }\n}\n"
  },
  {
    "path": "src/swift/tests/benchmark/cipher/CipherWriteBenchmark.swift",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport XCTest\n#if TEST_WCDB_SWIFT\nimport WCDBSwift\n#else\nimport WCDB\n#endif\n\nclass CipherWriteBenchmark: BaseBenchmark {\n\n    override func setUp() {\n        super.setUp()\n\n        database.setCipher(key: \"cipher\".data(using: .ascii)!)\n\n        setUpWithPreCreateObject(count: config.writeCount)\n    }\n\n    func testCipherWrite() {\n        let tableName = getTableName()\n        measure(onSetUp: {\n            tearDownDatabase()\n\n            setUpWithPreCreateTable()\n\n            tearDownDatabaseCache()\n\n            setUpDatabaseCache()\n        }, for: {\n            do {\n                for object in objects {\n                    try database.insert(object, intoTable: tableName)\n                }\n            } catch let error as WCDBError {\n                XCTFail(error.description)\n            } catch let error {\n                XCTFail(error.localizedDescription)\n            }\n        }, checkCorrectness: {\n            let count = try? database.getValue(on: Column.all().count(), fromTable: tableName)\n            XCTAssertEqual(Int(count?.int32Value ?? 0), config.writeCount)\n        })\n    }\n}\n"
  },
  {
    "path": "src/swift/tests/benchmark/multithread/BaseMultithreadBenchmark.swift",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport XCTest\n\nclass BaseMultithreadBenchmark: BaseBenchmark {\n\n    var group: DispatchGroup!\n    var queue: DispatchQueue!\n\n    override func setUp() {\n        super.setUp()\n        group = DispatchGroup()\n        queue = DispatchQueue(label: BaseMultithreadBenchmark.name, attributes: .concurrent)\n    }\n}\n"
  },
  {
    "path": "src/swift/tests/benchmark/multithread/MultithreadReadReadBenchmark.swift",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport XCTest\n\nclass MultithreadReadReadBenchmark: BaseMultithreadBenchmark {\n\n    override func setUp() {\n        super.setUp()\n\n        setUpWithPreCreateTable()\n\n        setUpWithPreInsertObjects(count: config.readCount)\n    }\n\n    func testMultithreadReadRead() {\n        let tableName = getTableName()\n        var results1: [BenchmarkObject]?\n        var results2: [BenchmarkObject]?\n\n        measure(onSetUp: {\n            results1 = nil\n\n            results2 = nil\n\n            tearDownDatabaseCache()\n\n            setUpDatabaseCache()\n        }, for: {\n            queue.async(group: group, execute: {\n                results1 = try? self.database.getObjects(fromTable: tableName)\n            })\n            queue.async(group: group, execute: {\n                results2 = try? self.database.getObjects(fromTable: tableName)\n            })\n            group.wait()\n        }, checkCorrectness: {\n            XCTAssertEqual(results1?.count, config.readCount)\n            XCTAssertEqual(results2?.count, config.readCount)\n        })\n    }\n}\n"
  },
  {
    "path": "src/swift/tests/benchmark/multithread/MultithreadReadWriteBenchmark.swift",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport XCTest\n#if TEST_WCDB_SWIFT\nimport WCDBSwift\n#else\nimport WCDB\n#endif\n\nclass MultithreadReadWriteBenchmark: BaseMultithreadBenchmark {\n\n    override func setUp() {\n        super.setUp()\n\n        setUpWithPreCreateObject(count: config.batchWriteCount)\n    }\n\n    func testMultithreadReadWrite() {\n        let tableName = getTableName()\n        var results: [BenchmarkObject]?\n        measure(onSetUp: {\n            results = nil\n\n            tearDownDatabase()\n\n            setUpWithPreCreateTable()\n\n            setUpWithPreInsertObjects(count: config.readCount)\n\n            tearDownDatabaseCache()\n\n            setUpDatabaseCache()\n        }, for: {\n            queue.async(group: group, execute: {\n                results = try? self.database.getObjects(fromTable: tableName)\n            })\n            queue.async(group: group, execute: {\n                do {\n                    try self.database.insert(self.objects, intoTable: tableName)\n                } catch let error as WCDBError {\n                    XCTFail(error.description)\n                } catch let error {\n                    XCTFail(error.localizedDescription)\n                }\n            })\n            group.wait()\n        }, checkCorrectness: {\n            XCTAssertEqual(results?.count, config.readCount)\n            let count = try? database.getValue(on: Column.all().count(), fromTable: tableName)\n            XCTAssertEqual(Int(count?.int32Value ?? 0), config.readCount + config.batchWriteCount)\n        })\n    }\n}\n"
  },
  {
    "path": "src/swift/tests/benchmark/multithread/MultithreadWriteWriteBenchmark.swift",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport XCTest\n#if TEST_WCDB_SWIFT\nimport WCDBSwift\n#else\nimport WCDB\n#endif\n\nclass MultithreadWriteWriteBenchmark: BaseMultithreadBenchmark {\n\n    override func setUp() {\n        super.setUp()\n\n        setUpWithPreCreateObject(count: config.batchWriteCount)\n    }\n\n    func testMultithreadWriteWrite() {\n        let tableName = getTableName()\n        measure(onSetUp: {\n            tearDownDatabase()\n\n            setUpWithPreCreateTable()\n\n            tearDownDatabaseCache()\n\n            setUpDatabaseCache()\n        }, for: {\n            queue.async(group: group, execute: {\n                do {\n                    try self.database.insert(self.objects, intoTable: tableName)\n                } catch let error as WCDBError {\n                    XCTFail(error.description)\n                } catch let error {\n                    XCTFail(error.localizedDescription)\n                }\n            })\n            queue.async(group: group, execute: {\n                do {\n                    try self.database.insert(self.objects, intoTable: tableName)\n                } catch let error as WCDBError {\n                    XCTFail(error.description)\n                } catch let error {\n                    XCTFail(error.localizedDescription)\n                }\n            })\n            group.wait()\n        }, checkCorrectness: {\n            let count = try? database.getValue(on: Column.all().count(), fromTable: tableName)\n            XCTAssertEqual(Int(count?.int32Value ?? 0), config.batchWriteCount * 2)\n        })\n    }\n}\n"
  },
  {
    "path": "src/swift/tests/benchmark/other/InitializationBenchmark.swift",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport XCTest\n#if TEST_WCDB_SWIFT\nimport WCDBSwift\n#else\nimport WCDB\n#endif\n\nclass InitializationBenchmark: BaseBenchmark {\n\n    override func setUp() {\n        super.setUp()\n\n        setUpWithPreCreateTable(count: config.tableCount)\n    }\n\n    func testInitialization() {\n        measure(onSetUp: {\n            tearDownDatabaseCache()\n        }, for: {\n            XCTAssertTrue(database.canOpen)\n        }, checkCorrectness: {\n            let results = try? database.getValue(on: Column.all().count(), fromTable: Master.builtinTableName)\n            XCTAssertEqual(Int(results?.int32Value ?? 0), config.tableCount)\n        })\n    }\n}\n"
  },
  {
    "path": "src/swift/tests/benchmark/other/SyncWriteBenchmark.swift",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport XCTest\n#if TEST_WCDB_SWIFT\nimport WCDBSwift\n#else\nimport WCDB\n#endif\n\nclass SyncWriteBenchmark: BaseBenchmark {\n\n    override func setUp() {\n        super.setUp()\n\n        setUpWithPreCreateObject(count: config.syncWriteCount)\n    }\n\n    func testSyncWrite() {\n        let tableName = getTableName()\n\n        measure(onSetUp: {\n            tearDownDatabase()\n\n            setUpWithPreCreateTable()\n\n            tearDownDatabaseCache()\n\n            setUpDatabaseCache()\n        }, for: {\n            do {\n                for object in objects {\n                    try database.insert(object, intoTable: tableName)\n                }\n            } catch let error as WCDBError {\n                XCTFail(error.description)\n            } catch let error {\n                XCTFail(error.localizedDescription)\n            }\n        }, checkCorrectness: {\n            let count = try? database.getValue(on: Column.all().count(), fromTable: tableName)\n            XCTAssertEqual(Int(count?.int32Value ?? 0), config.syncWriteCount)\n        })\n    }\n}\n"
  },
  {
    "path": "src/swift/tests/benchmark/supporting/BaseBenchmark.swift",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport XCTest\n#if TEST_WCDB_SWIFT\nimport WCDBSwift\n#else\nimport WCDB\n#endif\n\nclass BaseBenchmark: DatabaseTestCase {\n\n    var config = Config.default\n    lazy var randomGenerator = RandomData(withSeed: config.randomSeed)\n\n    var objects: [BenchmarkObject] = []\n\n    func getTableName(withIndex index: Int = 0) -> String {\n        return \"\\(BenchmarkObject.name)\\(index)\"\n    }\n\n    func setUpWithPreCreateTable(count: Int = 1) {\n        XCTAssertNoThrow(try database.run(transaction: {\n            _ in\n            for i in 0..<count {\n                try self.database.create(table: self.getTableName(withIndex: i), of: BenchmarkObject.self)\n            }\n        }))\n    }\n\n    func setUpWithPreInsertObjects(count: Int, intoIndexedTable index: Int = 0) {\n        var objects = [BenchmarkObject]()\n        for i in 0..<count {\n            objects.append(BenchmarkObject(withKey: i, and: randomGenerator.data(withLength: config.valueLength)))\n        }\n        XCTAssertNoThrow(try database.insert(objects, intoTable: getTableName(withIndex: index)))\n    }\n\n    func setUpWithPreCreateObject(count: Int) {\n        for i in 0..<count {\n            objects.append(BenchmarkObject(withKey: i, and: randomGenerator.data(withLength: config.valueLength)))\n        }\n    }\n\n    func setUpDatabaseCache() {\n        XCTAssertTrue(database.canOpen)\n    }\n\n    func tearDownDatabaseCache() {\n        database.close()\n    }\n\n    func tearDownDatabase() {\n        XCTAssertNoThrow(try database.close {\n            try self.database.removeFiles()\n        })\n    }\n\n    func measure(onSetUp setUpBlock: () -> Swift.Void,\n                 for block: () -> Swift.Void,\n                 checkCorrectness correctnessBlock: () -> Swift.Void) {\n        measureMetrics(type(of: self).defaultPerformanceMetrics, automaticallyStartMeasuring: false) {\n            setUpBlock()\n\n            startMeasuring()\n\n            block()\n\n            stopMeasuring()\n\n            correctnessBlock()\n        }\n    }\n}\n"
  },
  {
    "path": "src/swift/tests/benchmark/supporting/BenchmarkObject.swift",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport Foundation\n#if TEST_WCDB_SWIFT\nimport WCDBSwift\n#else\nimport WCDB\n#endif\n\nfinal class BenchmarkObject: TableCodable, Named {\n    var key: Int = 0\n    var value: Data?\n    enum CodingKeys: String, CodingTableKey {\n        typealias Root = BenchmarkObject\n        case key\n        case value\n        nonisolated(unsafe) static let objectRelationalMapping = TableBinding(CodingKeys.self)\n    }\n    init(withKey key: Int, and data: Data) {\n        self.key = key\n        self.value = data\n    }\n}\n"
  },
  {
    "path": "src/swift/tests/benchmark/supporting/Config.swift",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport Foundation\n\nclass Config {\n    static let `default` = Config()\n\n    let valueLength: Int = 100\n    let randomSeed: Int = 0\n\n    let readCount: Int\n    let writeCount: Int\n    let batchWriteCount: Int\n\n    let tableCount: Int\n    let syncWriteCount: Int\n\n    private init() {\n        batchWriteCount = 1000000\n        readCount = 2000000\n        writeCount = 100000\n\n        tableCount = 50000\n        syncWriteCount = 500\n    }\n}\n"
  },
  {
    "path": "src/swift/tests/common/Assert.swift",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport XCTest\n#if TEST_WCDB_SWIFT\nimport WCDBSwift\ntypealias ModuleExpression = WCDBSwift.Expression\n#else\nimport WCDB\ntypealias ModuleExpression = WCDB.Expression\n#endif\n\nfunc XCTAssertEqual(_ expression1: @autoclosure () -> String,\n                    _ expression2: @autoclosure () -> String,\n                    file: StaticString = #file,\n                    line: UInt = #line) {\n    let description1 = expression1()\n    let description2 = expression2()\n    XCTAssertEqual(description1, description2, {\n        return \"different from \\\"\\(description1.commonPrefix(with: description2))\\\"\"\n    }(), file: file, line: line)\n}\n\nfunc WINQAssertEqual<DescribableObject1, DescribableObject2>(\n    _ expression1: @autoclosure () -> DescribableObject1,\n    _ expression2: @autoclosure () -> DescribableObject2,\n    file: StaticString = #file,\n    line: UInt = #line)\n    where DescribableObject1: CustomStringConvertible, DescribableObject2: CustomStringConvertible {\n    XCTAssertEqual(expression1().description, expression2().description, file: file, line: line)\n}\n\nfunc WINQExpressionAssertEqual(\n    _ expression: @autoclosure () -> ModuleExpression,\n    _ description: @autoclosure () -> String,\n    file: StaticString = #file,\n    line: UInt = #line) {\n    XCTAssertEqual(expression().description, description(), file: file, line: line)\n}\n\nfunc WCDBAssertNoThrowReturned<T>(_ expression: @autoclosure () throws -> T,\n                                  file: StaticString = #file,\n                                  line: UInt = #line,\n                                  whenFailed failedValue: @autoclosure () -> T) -> T {\n    do {\n        return try expression()\n    } catch let error as WCDBError {\n        XCTFail(error.description)\n    } catch {\n        XCTFail(error.localizedDescription)\n    }\n    return failedValue()\n}\n\nfunc WCDBAssertNoThrowReturned<T>(_ expression: @autoclosure () throws -> T,\n                                  file: StaticString = #file,\n                                  line: UInt = #line) -> T? {\n    do {\n        return try expression()\n    } catch let error as WCDBError {\n        XCTFail(error.description)\n    } catch {\n        XCTFail(error.localizedDescription)\n    }\n    return nil\n}\n\nfunc WCDBAssertNoThrowReturned<T: OptionalRepresentable>(\n    _ expression: @autoclosure () throws -> T,\n    file: StaticString = #file,\n    line: UInt = #line) -> T {\n    return WCDBAssertNoThrowReturned(try expression(), file: file, line: line, whenFailed: T.`nil`)\n}\n\nprotocol ArrayRepresentable {\n    associatedtype ElementType\n    init()\n}\n\nextension Array: ArrayRepresentable {\n    typealias ElementType = Element\n}\n\nfunc WCDBAssertNoThrowReturned<T: ArrayRepresentable>(\n    _ expression: @autoclosure () throws -> T,\n    file: StaticString = #file,\n    line: UInt = #line) -> T {\n    return WCDBAssertNoThrowReturned(try expression(), file: file, line: line, whenFailed: T())\n}\n"
  },
  {
    "path": "src/swift/tests/common/BaseTestCase.swift",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport XCTest\n#if TEST_WCDB_SWIFT\nimport WCDBSwift\n#else\nimport WCDB\n#endif\n\nclass BaseTestCase: XCTestCase, Named {\n    static let baseDirectory: URL = {\n        var url = URL(fileURLWithPath: NSTemporaryDirectory())\n        url.appendPathComponent(String(describing: BaseTestCase.self))\n        return url\n    }()\n\n    lazy var recommendedDirectory: URL = {\n        var url = BaseTestCase.baseDirectory\n        url.appendPathComponent(self.className)\n        return url\n    }()\n\n    lazy var recommendedPath: URL = {\n        var url = recommendedDirectory\n        url.appendPathComponent(String(UInt(bitPattern: self.name.hash)))\n        return url\n    }()\n\n    lazy var recommendTag: Tag = recommendedPath.hashValue\n\n    let fileManager = FileManager.default\n\n    override func setUp() {\n        super.setUp()\n        self.continueAfterFailure = false\n\n        if fileManager.fileExists(atPath: recommendedDirectory.path) {\n            XCTAssertNoThrow(try fileManager.removeItem(at: recommendedDirectory))\n        }\n        XCTAssertNoThrow(try fileManager.createDirectory(at: recommendedDirectory,\n                                                         withIntermediateDirectories: true,\n                                                         attributes: nil))\n    }\n}\n"
  },
  {
    "path": "src/swift/tests/common/Convenience.swift",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport Foundation\n#if TEST_WCDB_SWIFT\nimport WCDBSwift\n#else\nimport WCDB\n#endif\n\nprotocol Named {\n    static var name: String {get}\n    var className: String {get}\n}\n\nextension Named {\n    static var name: String {\n        return String(describing: Self.self)\n    }\n    var className: String {\n        return Self.name\n    }\n}\n\nextension URL {\n    func urlByAppendingPathComponent(_ pathComponent: String) -> URL {\n        var url = self\n        url.appendPathComponent(pathComponent)\n        return url\n    }\n}\n\nextension Database {\n    var firstMaterialPath: String {\n        return self.path + \"-first.material\"\n    }\n    var lastMaterialPath: String {\n        return self.path + \"-last.material\"\n    }\n    var factoryPath: String {\n        return self.path + \".factory\"\n    }\n    func corruptHeader() throws {\n        try self.close {\n            try self.truncateCheckpoint()\n            let fileHandle = FileHandle(forWritingAtPath: self.path)\n            let data = Data(count: 100)\n            fileHandle?.seek(toFileOffset: 0)\n            fileHandle?.write(data)\n        }\n    }\n}\n\nextension FileManager {\n    func fileSize(of path: String) -> UInt64 {\n        let attributeDic = try? self.attributesOfItem(atPath: path)\n        return attributeDic?[.size] as? UInt64 ?? UInt64(0)\n    }\n}\n"
  },
  {
    "path": "src/swift/tests/common/DatabaseTestCase.swift",
    "content": "//\n// Created by qiuwenchen on 2022/11/28.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport Foundation\n#if TEST_WCDB_SWIFT\nimport WCDBSwift\n#else\nimport WCDB\n#endif\n\nclass DatabaseTestCase: BaseTestCase {\n    var database: Database!\n    override func setUp() {\n        super.setUp()\n        database = Database(at: self.recommendedPath)\n        database.tag = recommendTag\n        Database.globalTraceError { error in\n            assert(error.level != .Fatal)\n            print(\"Time: \\(Date()),\\(error)\")\n        }\n    }\n\n    override func tearDown() {\n        Database.globalTraceError(nil)\n    }\n}\n"
  },
  {
    "path": "src/swift/tests/common/Random.swift",
    "content": "//\n// Created by qiuwenchen on 2023/8/15.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport Foundation\n\nclass Random {\n    public static func string(withLength length: Int) -> String {\n        let letters = \"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789\"\n        return String((0..<length).map { _ in letters.randomElement()! })\n    }\n\n    public static func data(withLength length: Int, andSeed seed: Int = 0) -> Data {\n        srandom(UInt32(seed))\n        var data = Data(capacity: length)\n        while data.count < length {\n            var value = arc4random()\n            withUnsafePointer(to: &value) {\n                data.append(UnsafeBufferPointer(start: $0, count: 1))\n            }\n        }\n        return data\n    }\n\n    static let wordArray: [String] = {\n        let wordFrequency: [String: Int] = [\n            \"a\": 408,\n            \"he\": 121,\n            \"but\": 86,\n            \"my\": 58,\n            \"if\": 51,\n            \"just\": 44,\n            \"people\": 33,\n            \"think\": 28,\n            \"because\": 25,\n            \"two\": 21,\n            \"very\": 19,\n            \"should\": 17,\n            \"work\": 15,\n            \"day\": 14,\n            \"oh\": 13,\n            \"use\": 11,\n            \"lot\": 10,\n            \"mr\": 10,\n            \"part\": 9,\n            \"without\": 8\n        ]\n        var wordArray: [String] = []\n        wordArray.reserveCapacity(1000)\n        for (word, frequency) in wordFrequency {\n            for _ in 0..<frequency {\n                wordArray.append(word)\n            }\n        }\n        return wordArray\n    }()\n\n    public static func englishString(withLength length: Int) -> String {\n        var ret = \"\"\n        for _ in 0..<length {\n            ret += wordArray[Int(arc4random_uniform(UInt32(1000)))]\n            ret += \" \"\n        }\n        return ret\n    }\n\n    nonisolated(unsafe) public static var useEnglishString = false\n\n    public static func testObjects(startWith id: Int, count: Int) -> [TestObject] {\n        var objects: [TestObject] = []\n        for i in 0..<count {\n            let object = TestObject()\n            object.variable1 = id + i\n            if !useEnglishString {\n                object.variable2 = string(withLength: 100)\n            } else {\n                object.variable2 = englishString(withLength: 100)\n            }\n            objects.append(object)\n        }\n        return objects\n    }\n}\n"
  },
  {
    "path": "src/swift/tests/common/RandomData.swift",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport Foundation\n\nclass RandomData {\n    private var position = 0\n    private let capacity = 1024 * 1024\n    private lazy var data: Data = {\n        var data = Data(capacity: capacity)\n        while data.count < capacity {\n            var value = arc4random()\n            withUnsafePointer(to: &value) {\n                data.append(UnsafeBufferPointer(start: $0, count: 1))\n            }\n        }\n        return data\n    }()\n\n    init(withSeed seed: Int) {\n        srandom(UInt32(seed))\n    }\n\n    func data(withLength length: Int) -> Data {\n        guard length < capacity else {\n            fatalError()\n        }\n        if position + length > data.count {\n            position = 0\n        }\n        let begin = data.startIndex.advanced(by: position)\n        let end = begin.advanced(by: length)\n        let subData = data.subdata(in: begin..<end)\n        position += length\n        return subData\n    }\n}\n"
  },
  {
    "path": "src/swift/tests/common/TestObject.swift",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport Foundation\n#if TEST_WCDB_SWIFT\nimport WCDBSwift\n#else\nimport WCDB\n#endif\n\nclass TestObjectBase: Named, Hashable, Comparable, CustomDebugStringConvertible {\n    func hash(into hasher: inout Hasher) {\n        fatalError()\n    }\n\n    var isAutoIncrement: Bool = false\n    var lastInsertedRowID: Int64 = 0\n\n    func isSame(_ other: TestObjectBase) -> Bool {\n        fatalError()\n    }\n\n    func isLessThan(_ other: TestObjectBase) -> Bool {\n        fatalError()\n    }\n\n    static func == (lhs: TestObjectBase, rhs: TestObjectBase) -> Bool {\n        return lhs.hashValue == rhs.hashValue\n    }\n\n    static func < (lhs: TestObjectBase, rhs: TestObjectBase) -> Bool {\n        return lhs.hashValue < rhs.hashValue\n    }\n\n    var debugDescription: String {\n        fatalError()\n    }\n}\n\nfinal class TestObject: TestObjectBase, TableCodable {\n    var variable1: Int? = 0\n    var variable2: String? = \"\"\n\n    init(variable1: Int? = nil, variable2: String? = nil) {\n        self.variable1 = variable1\n        self.variable2 = variable2\n    }\n\n    enum CodingKeys: String, CodingTableKey {\n        typealias Root = TestObject\n        case variable1\n        case variable2\n        nonisolated(unsafe) static let objectRelationalMapping = TableBinding(CodingKeys.self) {\n            BindColumnConstraint(variable1, isPrimary: true, orderBy: .ascending, isAutoIncrement: true)\n        }\n    }\n\n    static func == (lhs: TestObject, rhs: TestObject) -> Bool {\n        return lhs.variable1 == rhs.variable1 && lhs.variable2 == rhs.variable2\n    }\n\n    static func < (lhs: TestObject, rhs: TestObject) -> Bool {\n        if lhs.variable1 == rhs.variable1 {\n            if let lhsv2 = lhs.variable2, let rhsv2 = rhs.variable2 {\n                return lhsv2 < rhsv2\n            }\n            return lhs.variable2 == nil\n        }\n        if let lhsv1 = lhs.variable1, let rhsv1 = rhs.variable1 {\n            return lhsv1 < rhsv1\n        }\n        return lhs.variable1 == nil\n    }\n\n    override var hashValue: Int {\n        return (String(variable1 ?? 0)+(variable2 ?? \"\")).hashValue\n    }\n\n    override var debugDescription: String {\n        return \"\\(variable1 != nil ? String(variable1!) : \"nil\"), \\(variable2 ?? \"nil\")\"\n    }\n}\n"
  },
  {
    "path": "src/swift/tests/crud/AdvanceCRUDTests.swift",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport XCTest\n#if TEST_WCDB_SWIFT\nimport WCDBSwift\n#else\nimport WCDB\n#endif\n\nclass AdvanceCRUDTests: CRUDTestCase {\n\n    func testSubthreadCheckpoint() {\n        // Give\n        let fileManager = self.fileManager\n        let walFile = database.path+\"-wal\"\n        let object = TestObject()\n        object.variable2 = \"testSubthreadCheckpoint\"\n        object.isAutoIncrement = true\n        // When\n        for _ in 0..<1000 {\n            XCTAssertNoThrow(try database.insert(object, intoTable: TestObject.name))\n        }\n        var expectedSize: Int64!\n        do {\n            let walSize = WCDBAssertNoThrowReturned(try fileManager.attributesOfItem(atPath: walFile)[.size])\n            XCTAssertNotNil(walSize)\n            let typedWalSize = walSize! as? Int64\n            XCTAssertNotNil(typedWalSize)\n            XCTAssertGreaterThan(typedWalSize!, 0)\n            expectedSize = typedWalSize!\n        }\n        sleep(5)\n        // Then\n        do {\n            let walSize = WCDBAssertNoThrowReturned(try fileManager.attributesOfItem(atPath: walFile)[.size])\n            XCTAssertNotNil(walSize)\n            let typedWalSize = walSize! as? Int64\n            XCTAssertNotNil(typedWalSize)\n            XCTAssertEqual(typedWalSize!, expectedSize)\n        }\n    }\n\n    struct EncodableColumn: ColumnEncodable {\n        static var columnType: ColumnType {\n            return .integer64\n        }\n\n        func archivedValue() -> Value {\n            return Value(Int64(variable1))\n        }\n\n        var variable1: Int = 0\n    }\n\n    struct DecodableColumn: ColumnDecodable {\n        static var columnType: ColumnType {\n            return .integer64\n        }\n\n        init?(with value: Value) {\n            variable1 = Int(truncatingIfNeeded: value.int64Value)\n        }\n\n        init() {}\n\n        var variable1: Int = 0\n    }\n\n    final class EncodableObject: TableEncodable {\n        var variable1: EncodableColumn = EncodableColumn()\n        enum CodingKeys: String, CodingTableKey {\n            typealias Root = EncodableObject\n            case variable1\n            nonisolated(unsafe) static let objectRelationalMapping = TableBinding(CodingKeys.self)\n        }\n    }\n\n    final class DecodableObject: TableDecodable {\n        var variable1: DecodableColumn = DecodableColumn()\n\n        enum CodingKeys: String, CodingTableKey {\n            typealias Root = DecodableObject\n            case variable1\n            nonisolated(unsafe) static let objectRelationalMapping = TableBinding(CodingKeys.self)\n        }\n    }\n\n    func testPartialCodable() {\n        let tableName = \"testPartialCodable\"\n        XCTAssertNoThrow(try database.create(table: tableName,\n                                             of: DecodableObject.self))\n\n        let object = EncodableObject()\n        XCTAssertNoThrow(try database.insert(object,\n                                             intoTable: tableName))\n\n        let decodableObject: DecodableObject? = WCDBAssertNoThrowReturned(\n            try database.getObject(fromTable: tableName)\n        )\n        XCTAssertNotNil(decodableObject)\n        XCTAssertEqual(decodableObject!.variable1.variable1, object.variable1.variable1)\n    }\n}\n"
  },
  {
    "path": "src/swift/tests/crud/AdvanceTests.swift",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport XCTest\n#if TEST_WCDB_SWIFT\nimport WCDBSwift\n#else\nimport WCDB\n#endif\n\nclass AdvanceTests: CRUDTestCase, @unchecked Sendable {\n\n    func testHandleStatement() {\n        let statement = StatementSelect().select(Column.all()).from(Master.builtinTableName)\n        let handle = WCDBAssertNoThrowReturned(try database.getHandle())!\n\n        WCDBAssertNoThrowReturned(try handle.prepare(statement))\n        handle.finalize()\n    }\n\n    func testHandleStatementRead() {\n        // Give\n        let statement = StatementSelect().select(Column.all()).from(TestObject.name)\n        let handle = WCDBAssertNoThrowReturned(try database.getHandle())!\n        XCTAssertNoThrow(try handle.prepare(statement))\n\n        let expectedVariable1: Int32 = 1\n        let expectedVariable2 = \"object1\"\n        // When\n        XCTAssertNoThrow(try handle.step())\n        // Then\n        XCTAssertEqual(handle.columnCount(), 2)\n\n        XCTAssertEqual(handle.columnName(atIndex: 0), \"variable1\")\n        XCTAssertEqual(handle.columnName(atIndex: 1), \"variable2\")\n\n        XCTAssertEqual(handle.columnTableName(atIndex: 0), TestObject.name)\n        XCTAssertEqual(handle.columnTableName(atIndex: 1), TestObject.name)\n\n        XCTAssertEqual(handle.index(byName: \"variable1\"), 0)\n        XCTAssertEqual(handle.index(byName: \"variable2\"), 1)\n        XCTAssertNil(handle.index(byName: \"nonexistent\"))\n\n        XCTAssertEqual(handle.columnType(atIndex: 0), ColumnType.integer64)\n        XCTAssertEqual(handle.columnType(atIndex: 1), ColumnType.text)\n        XCTAssertEqual(handle.columnType(byName: \"variable1\"), ColumnType.integer64)\n        XCTAssertEqual(handle.columnType(byName: \"variable2\"), ColumnType.text)\n        XCTAssertEqual(handle.columnType(byName: \"nonexistent\"), ColumnType.null)\n\n        do {\n            let variable1: Int32? = handle.value(atIndex: 0)\n            XCTAssertNotNil(variable1)\n            XCTAssertEqual(variable1!, expectedVariable1)\n            let variable2: String? = handle.value(atIndex: 1)\n            XCTAssertNotNil(variable2)\n            XCTAssertEqual(variable2!, expectedVariable2)\n        }\n\n        do {\n            let variable1: Int32? = handle.value(byName: \"variable1\")\n            XCTAssertNotNil(variable1)\n            XCTAssertEqual(variable1!, expectedVariable1)\n            let variable2: String? = handle.value(byName: \"variable2\")\n            XCTAssertNotNil(variable2)\n            XCTAssertEqual(variable2!, expectedVariable2)\n            let nonexistent: Int32? = handle.value(byName: \"nonexistent\")\n            XCTAssertNil(nonexistent)\n        }\n\n        handle.finalize()\n    }\n\n    func testHandleStatementWrite() {\n        // Give\n        let bindParameters = BindParameter.bindParameters(2)\n        let statement = StatementInsert().insert(intoTable: TestObject.name).values(bindParameters)\n        let handle = WCDBAssertNoThrowReturned(try database.getHandle())!\n        XCTAssertNoThrow(try handle.prepare(statement))\n\n        let expectedVariable1: Int32 = 3\n        let expectedVariable2 = \"object3\"\n        // When\n        handle.bind(nil, toIndex: 1)\n        handle.bind(expectedVariable2, toIndex: 2)\n        XCTAssertNoThrow(try handle.step())\n        // Then\n        XCTAssertEqual(handle.lastInsertedRowID, 3)\n        XCTAssertEqual(handle.changes, 1)\n        // When\n        handle.reset()\n        let expectedObject = TestObject()\n        expectedObject.variable1 = 4\n        expectedObject.variable2 = \"object4\"\n        XCTAssertNoThrow(try handle.bind([TestObject.Properties.variable1], of: expectedObject))\n        XCTAssertNoThrow(try handle.bind(TestObject.Properties.variable2, of: expectedObject, toIndex: 2))\n        XCTAssertNoThrow(try handle.step())\n\n        handle.finalize()\n        // Then\n        do {\n            let condition = TestObject.Properties.variable1 == expectedVariable1\n            let result: TestObject? = WCDBAssertNoThrowReturned(\n                try database.getObject(fromTable: TestObject.name, where: condition)\n            )\n            XCTAssertNotNil(result)\n            XCTAssertEqual(result!.variable2, expectedVariable2)\n        }\n        do {\n            let condition = TestObject.Properties.variable1 == expectedObject.variable1!\n            let result: TestObject? = WCDBAssertNoThrowReturned(\n                try database.getObject(fromTable: TestObject.name, where: condition)\n            )\n            XCTAssertNotNil(result)\n            XCTAssertEqual(result!, expectedObject)\n        }\n    }\n\n    final class HandleStatementTypedObject: TableCodable, Named {\n        var int32: Int32 = 1\n        var int64: Int64 = 2\n        var double: Double = 3.0\n        var string: String = \"4\"\n        var data: Data = \"5\".data(using: .ascii)!\n        enum CodingKeys: String, CodingTableKey {\n            typealias Root = HandleStatementTypedObject\n            case int32\n            case int64\n            case double\n            case string\n            case data\n            nonisolated(unsafe) static let objectRelationalMapping = TableBinding(CodingKeys.self)\n        }\n    }\n\n    func testHandleStatementType() {\n        let tableName = HandleStatementTypedObject.name\n\n        XCTAssertNoThrow(try database.create(table: tableName, of: HandleStatementTypedObject.self))\n        XCTAssertNoThrow(try database.insert(HandleStatementTypedObject(), intoTable: tableName))\n\n        let statement = StatementSelect().select(Column.all()).from(tableName)\n        let handle = WCDBAssertNoThrowReturned(try database.getHandle())!\n        XCTAssertNoThrow(try handle.prepare(statement))\n        XCTAssertNoThrow(try handle.step())\n\n        do {\n            let v1: Int32? = handle.value(atIndex: 0)\n            XCTAssertNotNil(v1)\n            XCTAssertEqual(v1!, 1)\n\n            let v2: Int64? = handle.value(atIndex: 1)\n            XCTAssertNotNil(v2)\n            XCTAssertEqual(v2!, 2)\n\n            let v3: Double? = handle.value(atIndex: 2)\n            XCTAssertNotNil(v3)\n            XCTAssertEqual(v3!, 3.0)\n\n            let v4: String? = handle.value(atIndex: 3)\n            XCTAssertNotNil(v4)\n            XCTAssertEqual(v4!, \"4\")\n\n            let v5: Data? = handle.value(atIndex: 4)\n            XCTAssertNotNil(v5)\n            XCTAssertEqual(v5!, \"5\".data(using: .ascii)!)\n\n            let v6: Data? = handle.value(atIndex: 5)\n            XCTAssertNil(v6)\n        }\n        do {\n            let v1: Value = handle.value(atIndex: 0)\n            XCTAssertEqual(v1.int32Value, 1)\n\n            let v2: Value = handle.value(atIndex: 1)\n            XCTAssertEqual(v2.int64Value, 2)\n\n            let v3: Value = handle.value(atIndex: 2)\n            XCTAssertEqual(v3.doubleValue, 3.0)\n\n            let v4: Value = handle.value(atIndex: 3)\n            XCTAssertEqual(v4.stringValue, \"4\")\n\n            let v5: Value = handle.value(atIndex: 4)\n            XCTAssertEqual(v5.dataValue, \"5\".data(using: .ascii)!)\n\n            let v6: Value = handle.value(atIndex: 5)\n            XCTAssertEqual(v6.type, .null)\n        }\n        handle.finalize()\n    }\n\n    func testFundamentalValue() {\n        // Give\n        let int32Value: Int32 = 1\n        let int32FundamentalValue = Value(int32Value)\n        XCTAssertEqual(int32FundamentalValue.int32Value, 1)\n        XCTAssertEqual(int32FundamentalValue.int64Value, 1)\n        XCTAssertEqual(int32FundamentalValue.doubleValue, 1.0)\n        XCTAssertEqual(int32FundamentalValue.stringValue, \"1\")\n        XCTAssertEqual(int32FundamentalValue.dataValue, \"1\".data(using: .ascii)!)\n        XCTAssertEqual(int32FundamentalValue.type, .integer32)\n\n        let int64Value: Int64 = 2\n        let int64FundamentalValue = Value(int64Value)\n        XCTAssertEqual(int64FundamentalValue.int32Value, 2)\n        XCTAssertEqual(int64FundamentalValue.int64Value, 2)\n        XCTAssertEqual(int64FundamentalValue.doubleValue, 2.0)\n        XCTAssertEqual(int64FundamentalValue.stringValue, \"2\")\n        XCTAssertEqual(int64FundamentalValue.dataValue, \"2\".data(using: .ascii)!)\n        XCTAssertEqual(int64FundamentalValue.type, .integer64)\n\n        let doubleValue: Double = 3.0\n        let doubleFundamentalValue = Value(doubleValue)\n        XCTAssertEqual(doubleFundamentalValue.int32Value, 3)\n        XCTAssertEqual(doubleFundamentalValue.int64Value, 3)\n        XCTAssertEqual(doubleFundamentalValue.doubleValue, 3.0)\n        XCTAssertEqual(doubleFundamentalValue.stringValue, \"3.0\")\n        XCTAssertEqual(doubleFundamentalValue.dataValue, \"3.0\".data(using: .ascii)!)\n        XCTAssertEqual(doubleFundamentalValue.type, .float)\n\n        let stringValue: String = \"4\"\n        let stringFundamentalValue = Value(stringValue)\n        XCTAssertEqual(stringFundamentalValue.int32Value, 4)\n        XCTAssertEqual(stringFundamentalValue.int64Value, 4)\n        XCTAssertEqual(stringFundamentalValue.doubleValue, 4.0)\n        XCTAssertEqual(stringFundamentalValue.stringValue, \"4\")\n        XCTAssertEqual(stringFundamentalValue.dataValue, \"4\".data(using: .ascii)!)\n        XCTAssertEqual(stringFundamentalValue.type, .text)\n\n        let dataValue: Data = \"5\".data(using: .ascii)!\n        let dataFundamentalValue = Value(dataValue)\n        XCTAssertEqual(dataFundamentalValue.int32Value, 0)\n        XCTAssertEqual(dataFundamentalValue.int64Value, 0)\n        XCTAssertEqual(dataFundamentalValue.doubleValue, 0)\n        XCTAssertEqual(dataFundamentalValue.stringValue, \"5\")\n        XCTAssertEqual(dataFundamentalValue.dataValue, \"5\".data(using: .ascii)!)\n        XCTAssertEqual(dataFundamentalValue.type, .BLOB)\n\n        let nullFundamentalValue = Value(nil)\n        XCTAssertEqual(nullFundamentalValue.int32Value, 0)\n        XCTAssertEqual(nullFundamentalValue.int64Value, 0)\n        XCTAssertEqual(nullFundamentalValue.doubleValue, 0)\n        XCTAssertEqual(nullFundamentalValue.stringValue, \"\")\n        XCTAssertEqual(nullFundamentalValue.dataValue, \"\".data(using: .ascii)!)\n        XCTAssertEqual(nullFundamentalValue.type, .null)\n    }\n\n    func testStepFailed() {\n        // Give\n        let bindParameters = BindParameter.bindParameters(2)\n        let statement = StatementInsert().insert(intoTable: TestObject.name).values(bindParameters)\n        let handle = WCDBAssertNoThrowReturned(try database.getHandle())!\n        XCTAssertNoThrow(try handle.prepare(statement))\n\n        let expectedVariable2 = \"object3\"\n        // When\n        handle.bind(nil, toIndex: 1)\n        handle.bind(expectedVariable2, toIndex: 2)\n        XCTAssertNoThrow(try handle.step())\n        XCTAssertNoThrow(try handle.step())\n        handle.finalize()\n    }\n\n    func testExecFailed() {\n        let statement = StatementSelect().select(Column.all()).from(\"nonexistentTable\")\n        XCTAssertThrowsError(try database.exec(statement))\n    }\n\n    func testCipher() {\n        // Give\n        XCTAssertNoThrow(try database.close {\n            try self.database.removeFiles()\n        })\n        let password = \"password\".data(using: .ascii)!\n        let wrongPassword = \"wrongPassword\".data(using: .ascii)!\n        // When\n        database.setCipher(key: password)\n        XCTAssertNoThrow(try database.create(table: TestObject.name, of: TestObject.self))\n        // Then\n        database.close()\n        database.setCipher(key: wrongPassword)\n        XCTAssertThrowsError(try database.isTableExists(TestObject.name))\n\n        database.close()\n        database.setCipher(key: nil)\n        XCTAssertThrowsError(try database.isTableExists(TestObject.name))\n\n        database.close()\n        database.setCipher(key: password)\n        let exists = WCDBAssertNoThrowReturned(try database.isTableExists(TestObject.name))\n        XCTAssertNotNil(exists)\n        XCTAssertTrue(exists!)\n    }\n\n    func testCipherFailed() {\n        // Give\n        XCTAssertNoThrow(try database.close {\n            try self.database.removeFiles()\n            })\n        let emptyPassword = Data()\n        // When\n        database.setCipher(key: emptyPassword)\n        XCTAssertFalse(database.canOpen)\n    }\n\n    func testConfig() {\n        // Then\n        do {\n            let handle = WCDBAssertNoThrowReturned(try database.getHandle())!\n            XCTAssertNoThrow(try handle.prepare(StatementPragma().pragma(.secureDelete)))\n            XCTAssertNoThrow(try handle.step())\n            let isSecureDelete: Int32? = handle.value(atIndex: 0)\n            XCTAssertNotNil(isSecureDelete)\n            XCTAssertEqual(isSecureDelete!, 0)\n            handle.finalize()\n        }\n        // Give\n        database.close()\n        database.setConfig(named: \"SecureDelete\") { (handle) throws in\n            let statement = StatementPragma().pragma(.secureDelete).to(true)\n            try handle.exec(statement)\n        }\n        // When\n        XCTAssertTrue(database.canOpen)\n        // Then\n        do {\n            let handle = WCDBAssertNoThrowReturned(try database.getHandle())!\n            XCTAssertNoThrow(try handle.prepare(StatementPragma().pragma(.secureDelete)))\n            XCTAssertNoThrow(try handle.step())\n            let isSecureDelete: Int32? = handle.value(atIndex: 0)\n            XCTAssertNotNil(isSecureDelete)\n            XCTAssertEqual(isSecureDelete!, 1)\n            handle.finalize()\n        }\n    }\n\n    func testDefaultCipherConfiguration() {\n        // Give\n        XCTAssertNoThrow(try database.close {\n            try self.database.removeFiles()\n        })\n        let password = \"password\".data(using: .ascii)!\n        let pageSize = 4096\n        // When\n        database.setCipher(key: password, pageSize: pageSize, cipherVersion: .version3)\n        // Then\n        XCTAssertTrue(database.canOpen)\n\n        // When\n        database.close()\n        database.setCipher(key: password, pageSize: pageSize)\n        // Then\n        XCTAssertFalse(database.canOpen)\n\n        // When\n        Database.setDefaultCipherConfiguration(.version3)\n        // Then\n        XCTAssertTrue(database.canOpen)\n\n        XCTAssertNoThrow(try database.removeFiles())\n        database.setCipher(key: password, pageSize: pageSize, cipherVersion: .version4)\n        // Then\n        XCTAssertTrue(database.canOpen)\n\n        // When\n        database.close()\n        database.setCipher(key: password, pageSize: pageSize)\n        // Then\n        XCTAssertFalse(database.canOpen)\n        // When\n        Database.setDefaultCipherConfiguration(.version4)\n        // Then\n        XCTAssertTrue(database.canOpen)\n    }\n\n    func testOrderedConfig() {\n        // Then\n        do {\n            let handle = WCDBAssertNoThrowReturned(try database.getHandle())!\n            XCTAssertNoThrow(try handle.prepare(StatementPragma().pragma(.secureDelete)))\n            XCTAssertNoThrow(try handle.step())\n            let isSecureDelete: Int32? = handle.value(atIndex: 0)\n            XCTAssertNotNil(isSecureDelete)\n            XCTAssertEqual(isSecureDelete!, 0)\n            handle.finalize()\n        }\n        // Give\n        database.close()\n        database.setConfig(named: \"SecureDelete\", withInvocation: { (handle) throws in\n            let statement = StatementPragma().pragma(.secureDelete).to(true)\n            try handle.exec(statement)\n        }, withPriority: .high)\n        var tested = false\n        database.setConfig(named: \"test\") { (handle) throws in\n            XCTAssertNoThrow(try handle.prepare(StatementPragma().pragma(.secureDelete)))\n            XCTAssertNoThrow(try handle.step())\n            let isSecureDelete: Int32 = handle.columnValue(atIndex: 0)\n            XCTAssertEqual(isSecureDelete, 1)\n            handle.finalize()\n\n            tested = true\n        }\n        // When\n        XCTAssertTrue(database.canOpen)\n        XCTAssertTrue(tested)\n    }\n\n    func testConfigChangeOrder() {\n        // Give\n        database.close()\n        database.setConfig(named: \"SecureDelete\", withInvocation: { (_) throws in\n            XCTFail(\"should not reach\")\n        })\n        var tested = false\n        database.setConfig(named: \"test\", withInvocation: { (handle) throws in\n            // Then\n            XCTAssertNoThrow(try handle.prepare(StatementPragma().pragma(.secureDelete)))\n            XCTAssertNoThrow(try handle.step())\n            let isSecureDelete: Int32 = handle.columnValue(atIndex: 0)\n            XCTAssertEqual(isSecureDelete, 0)\n            handle.finalize()\n\n            tested = true\n        }, withPriority: .high)\n        database.setConfig(named: \"SecureDelete\", withInvocation: { (handle) throws in\n            let statement = StatementPragma().pragma(.secureDelete).to(true)\n            try handle.exec(statement)\n        }, withPriority: .high)\n        // When\n        XCTAssertTrue(database.canOpen)\n        XCTAssertTrue(tested)\n    }\n\n    func testConfigFailed() {\n        // Give\n        database.close()\n        database.setConfig(named: \"testConfigFailed\", withInvocation: { (handle) throws in\n            try handle.exec(StatementSelect().select(Column.all()).from(\"nonexistentTable\"))\n        })\n        // When\n        XCTAssertFalse(database.canOpen)\n    }\n\n    func testRedirect() {\n        let property = TestObject.Properties.any.count().as(TestObject.Properties.variable1)\n        let optionalObject: TestObject? = WCDBAssertNoThrowReturned(\n            try database.getObject(on: property, fromTable: TestObject.name)\n        )\n        XCTAssertNotNil(optionalObject)\n        XCTAssertEqual(optionalObject!.variable1, preInsertedObjects.count)\n    }\n\n    func testRedirectCodingKey() {\n        let property = TestObject.Properties.variable1.as(TestObject.Properties.variable1)\n        let optionalObject: TestObject? = WCDBAssertNoThrowReturned(\n            try database.getObject(on: property, fromTable: TestObject.name)\n        )\n        XCTAssertNotNil(optionalObject)\n        XCTAssertEqual(optionalObject!.variable1, preInsertedObjects[0].variable1)\n    }\n\n    var identifier = 0\n    var pauseTimes = -1\n    func testPausableTransaction() {\n        XCTAssertNoThrow(try database.drop(table: TestObject.name))\n        XCTAssertNoThrow(try database.create(table: TestObject.name, of: TestObject.self))\n\n        let group = DispatchGroup()\n        let queue = DispatchQueue(label: String(recommendTag), attributes: .concurrent)\n        queue.async(group: group, execute: {\n            var i = 0\n            var write1Begin = Date()\n            let transaction: TransactionInterface.PausableTransactionClosure = { handle, stop, isNewTransaction in\n                XCTAssertTrue(handle.isInTransaction)\n                if isNewTransaction {\n                    self.pauseTimes += 1\n                }\n                let beginInterval = Date().timeIntervalSince(write1Begin)\n                XCTAssertTrue(beginInterval < 1)\n\n                let handleStatement = WCDBAssertNoThrowReturned(try handle.getOrCreatePreparedStatement(with: StatementInsert().insert(intoTable: TestObject.name).columns(TestObject.Properties.all).values(BindParameter.bindParameters(TestObject.Properties.all.count))))\n                handleStatement!.reset()\n\n                self.identifier += 1\n                let obj = TestObject()\n                obj.variable1 = self.identifier\n                obj.variable2 = \"testObject\"\n                XCTAssertNoThrow(try handleStatement!.bind(TestObject.Properties.all, of: obj))\n                XCTAssertNoThrow(try handleStatement!.step())\n\n                Thread.sleep(forTimeInterval: 0.1)\n                i += 1\n                stop = i > 30\n                write1Begin = Date()\n            }\n            do {\n                return try self.database.run(pausableTransaction: transaction)\n            } catch let error as WCDBError {\n                XCTFail(error.description)\n            } catch {\n                XCTFail(error.localizedDescription)\n            }\n        })\n        Thread.sleep(forTimeInterval: 0.5)\n        var i = 0\n        var write2Begin = Date()\n        repeat {\n            write2Begin = Date()\n            XCTAssertNoThrow(try self.database.begin())\n            XCTAssertTrue(self.database.isInTransaction)\n            let beginInterval = Date().timeIntervalSince(write2Begin)\n            XCTAssertTrue(beginInterval < 1)\n            identifier += 1\n            let obj = TestObject()\n            obj.variable1 = identifier\n            obj.variable2 = \"testObject\"\n            XCTAssertNoThrow(try self.database.insert(obj, intoTable: TestObject.name))\n            Thread.sleep(forTimeInterval: 0.1)\n            XCTAssertNoThrow(try self.database.commit())\n            i += 1\n        } while(i < 10)\n        group.wait()\n        let count = WCDBAssertNoThrowReturned(try self.database.getValue(on: TestObject.Properties.any.count(), fromTable: TestObject.name))!\n        XCTAssertTrue(count.int32Value == identifier)\n        XCTAssertTrue(pauseTimes > 1)\n    }\n\n    final class FTS3Object: TestObjectBase, TableCodable {\n        var variable1: Int = 0\n        var variable2: String = \"\"\n\n        enum CodingKeys: String, CodingTableKey {\n            typealias Root = FTS3Object\n            case variable1\n            case variable2\n            nonisolated(unsafe) static let objectRelationalMapping = TableBinding(CodingKeys.self) {\n                BindVirtualTable(withModule: .FTS3, and: BuiltinTokenizer.OneOrBinary)\n            }\n        }\n\n        override var hashValue: Int {\n            return (String(variable1)+variable2).hashValue\n        }\n    }\n    func testFTS3() {\n        // Give\n        XCTAssertNoThrow(try database.close {\n            try self.database.removeFiles()\n        })\n        database.add(tokenizer: BuiltinTokenizer.OneOrBinary)\n        XCTAssertNoThrow(try database.create(virtualTable: FTS3Object.name, of: FTS3Object.self))\n\n        let preInsertedEnglishFTS3Object: FTS3Object = {\n            let object = FTS3Object()\n            object.variable1 = 1\n            object.variable2 = \"This is English test content\"\n            return object\n        }()\n        let preInsertedChineseFTS3Object: FTS3Object = {\n            let object = FTS3Object()\n            object.variable1 = 2\n            object.variable2 = \"这是中文测试内容\"\n            return object\n        }()\n        let preInsertedNumbericFTS3Object: FTS3Object = {\n            let object = FTS3Object()\n            object.variable1 = 1\n            object.variable2 = \"123456\"\n            return object\n        }()\n        let preInsertedSymbolicFTS3Object: FTS3Object = {\n            let object = FTS3Object()\n            object.variable1 = 1\n            object.variable2 = \"abc..def\"\n            return object\n        }()\n        let objects = [preInsertedEnglishFTS3Object,\n                       preInsertedChineseFTS3Object,\n                       preInsertedNumbericFTS3Object,\n                       preInsertedSymbolicFTS3Object]\n        XCTAssertNoThrow(try database.insert(objects, intoTable: FTS3Object.name))\n\n        // English\n        do {\n            // When\n            let condition = FTS3Object.Properties.variable2.match(\"Engl*\")\n            let objects = WCDBAssertNoThrowReturned(\n                try database.getObjects(fromTable: FTS3Object.name, where: condition),\n                whenFailed: [FTS3Object]()\n            )\n            // Then\n            XCTAssertEqual(objects.count, 1)\n            XCTAssertEqual(objects[0], preInsertedEnglishFTS3Object)\n        }\n        // Chinese\n        do {\n            // When\n            let condition = FTS3Object.Properties.variable2.match(\"中文*\")\n            let objects = WCDBAssertNoThrowReturned(\n                try database.getObjects(fromTable: FTS3Object.name, where: condition),\n                whenFailed: [FTS3Object]()\n            )\n            // Then\n            XCTAssertEqual(objects.count, 1)\n            XCTAssertEqual(objects[0], preInsertedChineseFTS3Object)\n        }\n        // Numberic\n        do {\n            // When\n            let condition = FTS3Object.Properties.variable2.match(\"123*\")\n            let objects = WCDBAssertNoThrowReturned(\n                try database.getObjects(fromTable: FTS3Object.name, where: condition),\n                whenFailed: [FTS3Object]()\n            )\n            // Then\n            XCTAssertEqual(objects.count, 1)\n            XCTAssertEqual(objects[0], preInsertedNumbericFTS3Object)\n        }\n        // Symbolic\n        do {\n            // When\n            let condition = FTS3Object.Properties.variable2.match(\"def\")\n            let objects = WCDBAssertNoThrowReturned(\n                try database.getObjects(fromTable: FTS3Object.name, where: condition),\n                whenFailed: [FTS3Object]()\n            )\n            // Then\n            XCTAssertEqual(objects.count, 1)\n            XCTAssertEqual(objects[0], preInsertedSymbolicFTS3Object)\n        }\n\n        // Find Chinese\n        do {\n            // When\n            let condition = FTS3Object.Properties.variable2.match(\"文测\")\n            let objects = WCDBAssertNoThrowReturned(\n                try database.getObjects(fromTable: FTS3Object.name, where: condition),\n                whenFailed: [FTS3Object]()\n            )\n            // Then\n            XCTAssertEqual(objects.count, 1)\n            XCTAssertEqual(objects[0], preInsertedChineseFTS3Object)\n        }\n    }\n\n    final class FTS5Object: TestObjectBase, TableCodable {\n        var variable1: Int = 0\n        var variable2: String = \"\"\n\n        enum CodingKeys: String, CodingTableKey {\n            typealias Root = FTS5Object\n            case variable1\n            case variable2\n            nonisolated(unsafe) static let objectRelationalMapping = TableBinding(CodingKeys.self) {\n                BindVirtualTable(withModule: .FTS5, and: BuiltinTokenizer.Verbatim)\n            }\n        }\n\n        override var hashValue: Int {\n            return (String(variable1)+variable2).hashValue\n        }\n    }\n    func testFTS5() {\n        // Give\n        XCTAssertNoThrow(try database.close {\n            try self.database.removeFiles()\n        })\n        database.add(tokenizer: BuiltinTokenizer.Verbatim)\n        XCTAssertNoThrow(try database.create(virtualTable: FTS5Object.name, of: FTS5Object.self))\n\n        let preInsertedEnglishFTS5Object: FTS5Object = {\n            let object = FTS5Object()\n            object.variable1 = 1\n            object.variable2 = \"This is English test content\"\n            return object\n        }()\n        let preInsertedChineseFTS5Object: FTS5Object = {\n            let object = FTS5Object()\n            object.variable1 = 2\n            object.variable2 = \"这是中文测试内容\"\n            return object\n        }()\n        let preInsertedNumbericFTS5Object: FTS5Object = {\n            let object = FTS5Object()\n            object.variable1 = 1\n            object.variable2 = \"123456\"\n            return object\n        }()\n        let preInsertedSymbolicFTS5Object: FTS5Object = {\n            let object = FTS5Object()\n            object.variable1 = 1\n            object.variable2 = \"abc..def\"\n            return object\n        }()\n        let objects = [preInsertedEnglishFTS5Object,\n                       preInsertedChineseFTS5Object,\n                       preInsertedNumbericFTS5Object,\n                       preInsertedSymbolicFTS5Object]\n        XCTAssertNoThrow(try database.insert(objects, intoTable: FTS5Object.name))\n\n        // English\n        do {\n            // When\n            let condition = FTS5Object.Properties.variable2.match(\"Engl*\")\n            let objects = WCDBAssertNoThrowReturned(\n                try database.getObjects(fromTable: FTS5Object.name, where: condition),\n                whenFailed: [FTS5Object]()\n            )\n            // Then\n            XCTAssertEqual(objects.count, 1)\n            XCTAssertEqual(objects[0], preInsertedEnglishFTS5Object)\n        }\n        // Chinese\n        do {\n            // When\n            let condition = FTS5Object.Properties.variable2.match(\"中文*\")\n            let objects = WCDBAssertNoThrowReturned(\n                try database.getObjects(fromTable: FTS5Object.name, where: condition),\n                whenFailed: [FTS5Object]()\n            )\n            // Then\n            XCTAssertEqual(objects.count, 1)\n            XCTAssertEqual(objects[0], preInsertedChineseFTS5Object)\n        }\n        // Numberic\n        do {\n            // When\n            let condition = FTS5Object.Properties.variable2.match(\"123*\")\n            let objects = WCDBAssertNoThrowReturned(\n                try database.getObjects(fromTable: FTS5Object.name, where: condition),\n                whenFailed: [FTS5Object]()\n            )\n            // Then\n            XCTAssertEqual(objects.count, 1)\n            XCTAssertEqual(objects[0], preInsertedNumbericFTS5Object)\n        }\n        // Symbolic\n        do {\n            // When\n            let condition = FTS5Object.Properties.variable2.match(\"def\")\n            let objects = WCDBAssertNoThrowReturned(\n                try database.getObjects(fromTable: FTS5Object.name, where: condition),\n                whenFailed: [FTS5Object]()\n            )\n            // Then\n            XCTAssertEqual(objects.count, 1)\n            XCTAssertEqual(objects[0], preInsertedSymbolicFTS5Object)\n        }\n\n        // Find Chinese\n        do {\n            // When\n            let condition = FTS5Object.Properties.variable2.match(\"文测\")\n            let objects = WCDBAssertNoThrowReturned(\n                try database.getObjects(fromTable: FTS5Object.name, where: condition),\n                whenFailed: [FTS5Object]()\n            )\n            // Then\n            XCTAssertEqual(objects.count, 1)\n            XCTAssertEqual(objects[0], preInsertedChineseFTS5Object)\n        }\n    }\n\n    final class PinyinObject: TableCodable {\n        var content: String = \"\"\n\n        enum CodingKeys: String, CodingTableKey {\n            typealias Root = PinyinObject\n            case content\n            nonisolated(unsafe) static let objectRelationalMapping = TableBinding(CodingKeys.self) {\n                BindVirtualTable(withModule: .FTS5, and: BuiltinTokenizer.Pinyin)\n            }\n        }\n    }\n\n    func testPinyin() {\n        Database.config(pinyinDict: [\n            \"单\": [ \"shan\", \"dan\", \"chan\" ],\n            \"于\": [ \"yu\" ],\n            \"骑\": [ \"qi\" ],\n            \"模\": [ \"mo\", \"mu\" ],\n            \"具\": [ \"ju\" ],\n            \"车\": [ \"che\" ]\n        ])\n        database.add(tokenizer: BuiltinTokenizer.Pinyin)\n        XCTAssertNoThrow(try database.create(virtualTable: \"pinyinTable\", of: PinyinObject.self))\n\n        let obj = PinyinObject()\n        obj.content = \"单于骑模具单车\"\n        XCTAssertNoThrow(try database.insert(obj, intoTable: \"pinyinTable\"))\n\n        let querys = [\n            \"\\\"shan yu qi mu ju dan che\\\"\",\n            \"\\\"chan yu qi mo ju shan che\\\"\",\n            \"\\\"dan yu qi mo ju chan che\\\"\",\n            \"\\\"dan yu qi mu ju ch\\\"*\",\n            \"\\\"dan yu qi mo ju d\\\"*\",\n            \"\\\"s y q m j d c\\\"\",\n            \"\\\"c y q m j s c\\\"\",\n            \"\\\"c y q m j\\\"\"\n        ]\n\n        for query in querys {\n            let objs: [PinyinObject] = WCDBAssertNoThrowReturned(try database.getObjects(fromTable: \"pinyinTable\", where: PinyinObject.Properties.content.match(query)))\n            XCTAssertEqual(objs.count, 1)\n            XCTAssertEqual(objs[0].content, obj.content)\n        }\n    }\n\n    final class TraditionalChineseObject: TableCodable {\n        var content: String = \"\"\n\n        enum CodingKeys: String, CodingTableKey {\n            typealias Root = TraditionalChineseObject\n            case content\n            nonisolated(unsafe) static let objectRelationalMapping = TableBinding(CodingKeys.self) {\n                BindVirtualTable(withModule: .FTS5, and: BuiltinTokenizer.Verbatim, BuiltinTokenizer.Parameter.SimplifyChinese)\n            }\n        }\n    }\n\n    func testTraditionalChinese() {\n        Database.config(traditionalChineseDict: [\n            \"們\": \"们\",\n            \"員\": \"员\"\n        ])\n        database.add(tokenizer: BuiltinTokenizer.Verbatim)\n        XCTAssertNoThrow(try database.create(virtualTable: \"traditionalChineseTable\", of: TraditionalChineseObject.self))\n\n        let obj = TraditionalChineseObject()\n        obj.content = \"我們是程序員\"\n        XCTAssertNoThrow(try database.insert(obj, intoTable: \"traditionalChineseTable\"))\n\n        let matchObjects1: [TraditionalChineseObject] = WCDBAssertNoThrowReturned(try database.getObjects(fromTable: \"traditionalChineseTable\", where: TraditionalChineseObject.Properties.content.match(\"我們是程序員\")))\n        XCTAssertEqual(matchObjects1.count, 1)\n        XCTAssertEqual(matchObjects1[0].content, obj.content)\n\n        let matchObjects2: [TraditionalChineseObject] = WCDBAssertNoThrowReturned(try database.getObjects(fromTable: \"traditionalChineseTable\", where: TraditionalChineseObject.Properties.content.match(\"我们是程序员\")))\n        XCTAssertEqual(matchObjects2.count, 1)\n        XCTAssertEqual(matchObjects2[0].content, obj.content)\n    }\n\n    func testMigration() {\n        let oldObject1 = TestObject()\n        oldObject1.variable1 = 1\n        oldObject1.variable2 = \"oldContent1\"\n        let oldObject2 = TestObject()\n        oldObject2.variable1 = 2\n        oldObject2.variable2 = \"oldContent2\"\n        let oldObject3 = TestObject()\n        oldObject3.variable1 = 3\n        oldObject3.variable2 = \"oldContent3\"\n\n        let sourceCipher = Random.data(withLength: 100)\n        let targetCipher = Random.data(withLength: 100, andSeed: 1)\n\n        let sourceDatabase = Database(at: recommendedDirectory.appendingPathComponent(\"sourceDB.sqlite3\"))\n        sourceDatabase.setCipher(key: sourceCipher)\n\n        let sourceTableName = \"sourceTable\"\n        XCTAssertNoThrow(try sourceDatabase.create(table: sourceTableName, of: TestObject.self))\n        let sourceTable = sourceDatabase.getTable(named: sourceTableName, of: TestObject.self)\n\n        XCTAssertNoThrow(try sourceTable.insert(oldObject1, oldObject2, oldObject3))\n\n        let targetDatabase = Database(at: recommendedDirectory.appendingPathComponent(\"targetDB.sqlite3\"))\n        targetDatabase.setCipher(key: targetCipher)\n        let targetTableName = \"targetTable\"\n\n        targetDatabase.addMigration(sourcePath: sourceDatabase.path, sourceCipher: sourceCipher) { info in\n            if info.table == targetTableName {\n                info.sourceTable = sourceTableName\n                info.filterCondition = TestObject.Properties.variable1 > 2\n            }\n        }\n\n        XCTAssertNoThrow(try targetDatabase.create(table: targetTableName, of: TestObject.self))\n        let targetTable = targetDatabase.getTable(named: targetTableName, of: TestObject.self)\n\n        XCTAssertEqual(try? targetTable.getValue(on: Column.all().count()).int64Value, 1)\n\n        XCTAssertNoThrow(try targetTable.delete(where: TestObject.Properties.variable1 == 2))\n        XCTAssertEqual(try? sourceTable.getValue(on: Column.all().count()).int64Value, 3)\n\n        XCTAssertNoThrow(try targetTable.update(on: TestObject.Properties.variable2, with: [\"newContent\"], where: TestObject.Properties.variable1 == 3))\n\n        XCTAssertEqual(try? targetTable.getValue(on: TestObject.Properties.variable2, where: TestObject.Properties.variable1 == 3).stringValue, \"newContent\")\n\n        XCTAssertNoThrow(try targetTable.delete(where: TestObject.Properties.variable1 == 3))\n        XCTAssertEqual(try? sourceTable.getValue(on: Column.all().count()).int64Value, 2)\n        XCTAssertEqual(try? targetTable.getValue(on: Column.all().count()).int64Value, 0)\n\n        let newObject = TestObject()\n        newObject.variable1 = 4\n        newObject.variable2 = \"d\"\n        XCTAssertNoThrow(try targetTable.insert(newObject))\n\n        let dbNewObject = WCDBAssertNoThrowReturned(try targetTable.getObject(on: TestObject.Properties.all, where: TestObject.Properties.variable1 == 4))\n        XCTAssertTrue(dbNewObject != nil && dbNewObject!.variable2 == \"d\")\n        XCTAssertEqual(try? sourceTable.getValue(on: Column.all().count()).int64Value, 2)\n        XCTAssertEqual(try? targetTable.getValue(on: Column.all().count()).int64Value, 1)\n\n        targetDatabase.close()\n        XCTAssertEqual(targetDatabase.isMigrated(), false)\n\n        var migratedTable: String?\n        targetDatabase.setNotificationWhenMigrated { _, info in\n            if let sourceTable = info?.sourceTable {\n                migratedTable = sourceTable\n            }\n        }\n\n        repeat {\n            XCTAssertNoThrow(try targetDatabase.stepMigration())\n        } while !targetDatabase.isMigrated()\n\n        XCTAssertEqual(targetDatabase.isMigrated(), true)\n\n        XCTAssertEqual(migratedTable ?? \"\", sourceTableName)\n    }\n\n    func testDefaultTemporaryDirectory() {\n        XCTAssertFalse(Database.setDefaultTemporaryDirectory(\"wrongDir\"))\n\n        let tempDir = NSTemporaryDirectory().appending(\"/dbTempDir\")\n        XCTAssertTrue(Database.setDefaultTemporaryDirectory(tempDir))\n\n        let getDirStatement = StatementPragma().pragma(Pragma(named: \"temp_store_directory\"))\n        var dir = WCDBAssertNoThrowReturned(try database.getValue(from: getDirStatement))\n        XCTAssertTrue(dir != nil && dir!.stringValue == tempDir)\n\n        XCTAssertTrue(Database.setDefaultTemporaryDirectory(\"\"))\n        dir = WCDBAssertNoThrowReturned(try database.getValue(from: getDirStatement))\n        XCTAssertTrue(dir != nil && dir!.stringValue == \"\")\n    }\n\n    func testNormalCompress() {\n        Random.useEnglishString = true\n        XCTAssertNoThrow(try table.delete())\n        var preInsertObjects = Random.testObjects(startWith: 1, count: 2)\n        XCTAssertNoThrow(try table.insert(preInsertObjects))\n\n        database.setCompression { info in\n            info.addZSTDNormalCompress(to: TestObject.Properties.variable2)\n        }\n        var tableCompressed = false\n        var databaseCompressed = false\n        database.setNotificationWhenCompressed { database, table in\n            XCTAssertEqual(database.tag, self.database.tag)\n            XCTAssertEqual(database.path, self.database.path)\n            if let table = table {\n                if table == self.table.name {\n                    tableCompressed = true\n                }\n            } else {\n                databaseCompressed = true\n            }\n        }\n\n        XCTAssertFalse(database.isCompressed())\n        XCTAssertNoThrow(try database.stepCompression())\n        XCTAssertNoThrow(try database.stepCompression())\n        XCTAssertTrue(database.isCompressed())\n        XCTAssertTrue(tableCompressed && databaseCompressed)\n\n        let newInsertObjects = Random.testObjects(startWith: 3, count: 2)\n        XCTAssertNoThrow(try table.insert(newInsertObjects))\n\n        let count = WCDBAssertNoThrowReturned(try database.getValue(from: StatementSelect().select(Column.all().count()).from(table.name).where(Column(named: \"WCDB_CT_variable2\") == 4)))\n        XCTAssertTrue(count != nil && count!.intValue == 4)\n\n        preInsertObjects.append(contentsOf: newInsertObjects)\n\n        let allObjects = WCDBAssertNoThrowReturned(try table.getObjects())\n        XCTAssertTrue(allObjects.elementsEqual(preInsertObjects))\n        Random.useEnglishString = false\n    }\n\n    func testDictCompress() {\n        Random.useEnglishString = true\n        XCTAssertNoThrow(try table.delete())\n        var preInsertObjects = Random.testObjects(startWith: 1, count: 2)\n        XCTAssertNoThrow(try table.insert(preInsertObjects))\n\n        var samples: [Data] = []\n        for _ in 0..<1000 {\n            samples.append(Random.englishString(withLength: 100).data(using: .utf8) ?? Data())\n        }\n        let dict = WCDBAssertNoThrowReturned(try Database.trainDict(with: samples, and: 1))\n        XCTAssertNotNil(dict)\n        XCTAssertNoThrow(try Database.register(dict: dict!, with: 1))\n\n        database.setCompression { info in\n            info.addZSTDDictCompress(to: TestObject.Properties.variable2, withDict: 1)\n        }\n\n        XCTAssertFalse(database.isCompressed())\n        XCTAssertNoThrow(try database.stepCompression())\n        XCTAssertNoThrow(try database.stepCompression())\n        XCTAssertTrue(database.isCompressed())\n\n        let newInsertObjects = Random.testObjects(startWith: 3, count: 2)\n        XCTAssertNoThrow(try table.insert(newInsertObjects))\n\n        let count = WCDBAssertNoThrowReturned(try database.getValue(from: StatementSelect().select(Column.all().count()).from(table.name).where(Column(named: \"WCDB_CT_variable2\") == 2)))\n        XCTAssertTrue(count != nil && count!.intValue == 4)\n\n        preInsertObjects.append(contentsOf: newInsertObjects)\n\n        let allObjects = WCDBAssertNoThrowReturned(try table.getObjects())\n        XCTAssertTrue(allObjects.elementsEqual(preInsertObjects))\n        Random.useEnglishString = false\n    }\n\n    func testMultiDictCompress() {\n        Random.useEnglishString = true\n        XCTAssertNoThrow(try table.delete())\n        var preInsertObjects = Random.testObjects(startWith: 1, count: 2)\n        XCTAssertNoThrow(try table.insert(preInsertObjects))\n\n        var samples: [String] = []\n        for _ in 0..<1000 {\n            samples.append(Random.englishString(withLength: 100))\n        }\n        let dict1 = WCDBAssertNoThrowReturned(try Database.trainDict(with: samples, and: 2))\n        XCTAssertNotNil(dict1)\n        XCTAssertNoThrow(try Database.register(dict: dict1!, with: 2))\n\n        samples.removeAll()\n        for _ in 0..<1000 {\n            samples.append(Random.englishString(withLength: 100))\n        }\n        let dict2 = WCDBAssertNoThrowReturned(try Database.trainDict(with: samples, and: 3))\n        XCTAssertNotNil(dict2)\n        XCTAssertNoThrow(try Database.register(dict: dict2!, with: 3))\n\n        samples.removeAll()\n        for _ in 0..<1000 {\n            samples.append(Random.englishString(withLength: 100))\n        }\n        let dict3 = WCDBAssertNoThrowReturned(try Database.trainDict(with: samples, and: 4))\n        XCTAssertNotNil(dict3)\n        XCTAssertNoThrow(try Database.register(dict: dict3!, with: 4))\n\n        database.setCompression { info in\n            info.addZSTDMultiDictCompress(to: TestObject.Properties.variable2,\n                                          withMatchProperty: TestObject.Properties.variable1,\n                                          andDicts: [\n                1: 2,\n                2: 3,\n                Database.DictDefaultMatchValue: 4\n            ])\n        }\n\n        XCTAssertFalse(database.isCompressed())\n        XCTAssertNoThrow(try database.stepCompression())\n        XCTAssertNoThrow(try database.stepCompression())\n        XCTAssertTrue(database.isCompressed())\n\n        let newInsertObjects = Random.testObjects(startWith: 3, count: 2)\n        XCTAssertNoThrow(try table.insert(newInsertObjects))\n\n        let count = WCDBAssertNoThrowReturned(try database.getValue(from: StatementSelect().select(Column.all().count()).from(table.name).where(Column(named: \"WCDB_CT_variable2\") == 2)))\n        XCTAssertTrue(count != nil && count!.intValue == 4)\n\n        preInsertObjects.append(contentsOf: newInsertObjects)\n\n        let allObjects = WCDBAssertNoThrowReturned(try table.getObjects())\n        XCTAssertTrue(allObjects.elementsEqual(preInsertObjects))\n        Random.useEnglishString = false\n    }\n}\n"
  },
  {
    "path": "src/swift/tests/crud/CRUDTestCase.swift",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport XCTest\n#if TEST_WCDB_SWIFT\nimport WCDBSwift\n#else\nimport WCDB\n#endif\n\nclass CRUDTestCase: DatabaseTestCase {\n\n    let preInsertedObjects: [TestObject] = {\n        let object1 = TestObject()\n        object1.variable1 = 1\n        object1.variable2 = \"object1\"\n        let object2 = TestObject()\n        object2.variable1 = 2\n        object2.variable2 = \"object2\"\n        return [object1, object2]\n    }()\n\n    lazy var table: Table<TestObject> = {\n        database.getTable(named: TestObject.name)\n    }()\n\n    override func setUp() {\n        super.setUp()\n\n        XCTAssertNoThrow(try database.create(table: TestObject.name, of: TestObject.self))\n\n        XCTAssertNoThrow(try database.insert(preInsertedObjects, intoTable: TestObject.name))\n    }\n}\n"
  },
  {
    "path": "src/swift/tests/crud/DatabaseTests.swift",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport XCTest\n#if TEST_WCDB_SWIFT\nimport WCDBSwift\n#else\nimport WCDB\n#endif\n\nclass DatabaseTests: BaseTestCase {\n\n    func testTag() {\n        // Give\n        let tag = self.recommendTag\n        let path: String = self.recommendedPath.path\n        var taggedDatabase: Database?\n        let database: Database = Database(at: path)\n        database.tag = tag\n        taggedDatabase = Database(at: path)\n        XCTAssertNotNil(taggedDatabase)\n        XCTAssertEqual(taggedDatabase!.tag, tag)\n        XCTAssertEqual(taggedDatabase!.path, path)\n    }\n\n    func testMultiDatabase() {\n        // Give\n        let path: String = self.recommendedPath.path\n        let database: Database = Database(at: path)\n        let database2: Database = Database(at: path)\n        database.tag = self.recommendTag\n        XCTAssertNotNil(database2.tag)\n        XCTAssertEqual(database2.tag, database.tag)\n    }\n\n    func testFailedToCreateDirectory() {\n        let blocks = self.recommendedPath\n        fileManager.createFile(atPath: blocks.path, contents: Data(), attributes: nil)\n        let path = URL(fileURLWithPath: blocks.path).appendingPathComponent(\"newPath\")\n        let database = Database(at: path)\n        XCTAssertFalse(database.canOpen)\n    }\n\n    func testFailedToOpenDatabase() {\n        let path = self.recommendedPath\n        XCTAssertNoThrow(try fileManager.createDirectory(at: path, withIntermediateDirectories: true, attributes: nil))\n        let database = Database(at: path)\n        XCTAssertFalse(database.canOpen)\n    }\n\n    func testPurgeFreeHandles() {\n        // Give\n        let database: Database = Database(at: self.recommendedPath)\n        // When\n        XCTAssertTrue(database.canOpen)\n        XCTAssertTrue(database.isOpened)\n        database.purge()\n        // Then\n        XCTAssertFalse(database.isOpened)\n\n        // When\n        XCTAssertTrue(database.canOpen)\n        XCTAssertTrue(database.isOpened)\n        Database.purge()\n        // Then\n        XCTAssertFalse(database.isOpened)\n    }\n}\n"
  },
  {
    "path": "src/swift/tests/crud/DeleteInterfaceTests.swift",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport XCTest\n#if TEST_WCDB_SWIFT\nimport WCDBSwift\n#else\nimport WCDB\n#endif\n\nclass DeleteInterfaceTests: CRUDTestCase {\n\n    func testDelete() {\n        // When\n        XCTAssertNoThrow(try database.delete(fromTable: TestObject.name))\n        // Then\n        let results: [TestObject] = WCDBAssertNoThrowReturned(try database.getObjects(fromTable: TestObject.name))\n        XCTAssertEqual(results.count, 0)\n    }\n\n    func testConditionalDelete() {\n        // When\n        XCTAssertNoThrow(try database.delete(fromTable: TestObject.name, where: TestObject.Properties.variable1 == 2))\n        // Then\n        let results: [TestObject] = WCDBAssertNoThrowReturned(try database.getObjects(fromTable: TestObject.name))\n        XCTAssertEqual(results.count, 1)\n        XCTAssertEqual(results[0], preInsertedObjects[0])\n    }\n\n    func testOrderedDelete() {\n        // Give\n        let order = [TestObject.Properties.variable1.order(.descending)]\n        // When\n        XCTAssertNoThrow(try database.delete(fromTable: TestObject.name, orderBy: order, limit: 1))\n        // Then\n        let results: [TestObject] = WCDBAssertNoThrowReturned(\n            try database.getObjects(fromTable: TestObject.name, orderBy: order)\n        )\n        XCTAssertEqual(results.count, 1)\n        XCTAssertEqual(results[0], preInsertedObjects[0])\n    }\n\n    func testLimitedDelete() {\n        // When\n        XCTAssertNoThrow(try database.delete(fromTable: TestObject.name, limit: 1))\n        // Then\n        let results: [TestObject] = WCDBAssertNoThrowReturned(try database.getObjects(fromTable: TestObject.name))\n        XCTAssertEqual(results.count, 1)\n        XCTAssertEqual(results[0], preInsertedObjects[1])\n    }\n\n    func testOffsetDelete() {\n        // When\n        XCTAssertNoThrow(try database.delete(fromTable: TestObject.name, limit: 1, offset: 1))\n        // Then\n        let results: [TestObject] = WCDBAssertNoThrowReturned(try database.getObjects(fromTable: TestObject.name))\n        XCTAssertEqual(results.count, 1)\n        XCTAssertEqual(results[0], preInsertedObjects[0])\n    }\n\n    func testTableDelete() {\n        // When\n        XCTAssertNoThrow(try table.delete())\n        // Then\n        let results: [TestObject] = WCDBAssertNoThrowReturned(try database.getObjects(fromTable: TestObject.name))\n        XCTAssertEqual(results.count, 0)\n    }\n\n    func testTableConditionalDelete() {\n        // When\n        XCTAssertNoThrow(try table.delete(where: TestObject.Properties.variable1 == 2))\n        // Then\n        let results: [TestObject] = WCDBAssertNoThrowReturned(try database.getObjects(fromTable: TestObject.name))\n        XCTAssertEqual(results.count, 1)\n        XCTAssertEqual(results[0], preInsertedObjects[0])\n    }\n\n    func testTableOrderedDelete() {\n        // Give\n        let order = [TestObject.Properties.variable1.order(.descending)]\n        // When\n        XCTAssertNoThrow(try table.delete(orderBy: order, limit: 1))\n        // Then\n        let results: [TestObject] = WCDBAssertNoThrowReturned(\n            try database.getObjects(fromTable: TestObject.name, orderBy: order)\n        )\n        XCTAssertEqual(results.count, 1)\n        XCTAssertEqual(results[0], preInsertedObjects[0])\n    }\n\n    func testTableLimitedDelete() {\n        // When\n        XCTAssertNoThrow(try table.delete(limit: 1))\n        // Then\n        let results: [TestObject] = WCDBAssertNoThrowReturned(try database.getObjects(fromTable: TestObject.name))\n        XCTAssertEqual(results.count, 1)\n        XCTAssertEqual(results[0], preInsertedObjects[1])\n    }\n\n    func testTableOffsetDelete() {\n        // When\n        XCTAssertNoThrow(try table.delete(limit: 1, offset: 1))\n        // Then\n        let results: [TestObject] = WCDBAssertNoThrowReturned(try database.getObjects(fromTable: TestObject.name))\n        XCTAssertEqual(results.count, 1)\n        XCTAssertEqual(results[0], preInsertedObjects[0])\n    }\n\n}\n"
  },
  {
    "path": "src/swift/tests/crud/DeleteTests.swift",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport XCTest\n#if TEST_WCDB_SWIFT\nimport WCDBSwift\n#else\nimport WCDB\n#endif\n\nclass DeleteTests: CRUDTestCase {\n\n    var delete: Delete!\n\n    override func setUp() {\n        super.setUp()\n\n        let optionalDelete = WCDBAssertNoThrowReturned(\n            try database.prepareDelete(fromTable: TestObject.name)\n        )\n        XCTAssertNotNil(optionalDelete)\n        delete = optionalDelete!\n    }\n\n    func testDelete() {\n        // When\n        XCTAssertNoThrow(try delete.execute())\n        // Then\n        let results: [TestObject] = WCDBAssertNoThrowReturned(try database.getObjects(fromTable: TestObject.name))\n        XCTAssertEqual(results.count, 0)\n    }\n\n    func testTableDelete() {\n        // Give\n        let optionalDelete = WCDBAssertNoThrowReturned(\n            try table.prepareDelete()\n        )\n        XCTAssertNotNil(optionalDelete)\n        delete = optionalDelete!\n        // When\n        XCTAssertNoThrow(try delete.execute())\n        // Then\n        let results: [TestObject] = WCDBAssertNoThrowReturned(try table.getObjects())\n        XCTAssertEqual(results.count, 0)\n    }\n\n    func testConditionalDelete() {\n        // When\n        XCTAssertNoThrow(try delete.where(TestObject.Properties.variable1 == 2).execute())\n        // Then\n        let results: [TestObject] = WCDBAssertNoThrowReturned(try database.getObjects(fromTable: TestObject.name))\n        XCTAssertEqual(results.count, 1)\n        XCTAssertEqual(results[0], preInsertedObjects[0])\n    }\n\n    func testOrderedDelete() {\n        // Give\n        let order = TestObject.Properties.variable1.order(.descending)\n        // When\n        XCTAssertNoThrow(try delete.order(by: order).limit(1).execute())\n        // Then\n        let results: [TestObject] = WCDBAssertNoThrowReturned(try database.getObjects(fromTable: TestObject.name))\n        XCTAssertEqual(results.count, 1)\n        XCTAssertEqual(results[0], preInsertedObjects[0])\n    }\n\n    func testLimitedDelete() {\n        // When\n        XCTAssertNoThrow(try delete.limit(1).execute())\n        // Then\n        let results: [TestObject] = WCDBAssertNoThrowReturned(try database.getObjects(fromTable: TestObject.name))\n        XCTAssertEqual(results.count, 1)\n        XCTAssertEqual(results[0], preInsertedObjects[1])\n    }\n\n    func testOffsetDelete() {\n        // When\n        XCTAssertNoThrow(try delete.limit(1, offset: 1).execute())\n        // Then\n        let results: [TestObject] = WCDBAssertNoThrowReturned(try database.getObjects(fromTable: TestObject.name))\n        XCTAssertEqual(results.count, 1)\n        XCTAssertEqual(results[0], preInsertedObjects[0])\n    }\n\n    func testLimitedFromToDelete() {\n        // When\n        XCTAssertNoThrow(try delete.limit(from: 1, to: 2).execute())\n        // Then\n        let results: [TestObject] = WCDBAssertNoThrowReturned(try database.getObjects(fromTable: TestObject.name))\n        XCTAssertEqual(results.count, 1)\n        XCTAssertEqual(results[0], preInsertedObjects[0])\n    }\n\n    func testDeleteChanges() {\n        // When\n        XCTAssertNoThrow(try delete.execute())\n        // Then\n        XCTAssertEqual(delete.changes, preInsertedObjects.count)\n    }\n}\n"
  },
  {
    "path": "src/swift/tests/crud/InsertInterfaceTests.swift",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport XCTest\n#if TEST_WCDB_SWIFT\nimport WCDBSwift\n#else\nimport WCDB\n#endif\n\nclass InsertInterfaceTests: CRUDTestCase {\n\n    func testInsert() {\n        // Give\n        let object = TestObject()\n        object.variable1 = preInsertedObjects.count + 1\n        object.variable2 = self.name\n        // When\n        XCTAssertNoThrow(try database.insert(object, intoTable: TestObject.name))\n        // Then\n        let condition = TestObject.Properties.variable1 == object.variable1!\n        let result: TestObject? = WCDBAssertNoThrowReturned(\n            try database.getObject(fromTable: TestObject.name, where: condition)\n        )\n        XCTAssertNotNil(result)\n        XCTAssertEqual(result!, object)\n    }\n\n    func testAutoIncrementInsert() {\n        // Give\n        let object = TestObject()\n        let expectedRowID = preInsertedObjects.count + 1\n        object.isAutoIncrement = true\n        object.variable2 = self.name\n        // When\n        XCTAssertNoThrow(try database.insert(object, intoTable: TestObject.name))\n        // Then\n        XCTAssertEqual(object.lastInsertedRowID, Int64(expectedRowID))\n        let condition = TestObject.Properties.variable1 == expectedRowID\n        let result: TestObject? = WCDBAssertNoThrowReturned(\n            try database.getObject(fromTable: TestObject.name, where: condition)\n        )\n        XCTAssertNotNil(result)\n        XCTAssertEqual(result!.variable1, expectedRowID)\n        XCTAssertEqual(result!.variable2, object.variable2)\n    }\n\n    func testInsertOrReplace() {\n        // Give\n        let object = TestObject()\n        let expectedReplacedRowID = 1\n        object.variable1 = expectedReplacedRowID\n        object.variable2 = self.name\n        // When\n        XCTAssertNoThrow(try database.insertOrReplace(object, intoTable: TestObject.name))\n        // Then\n        let condition = TestObject.Properties.variable1 == expectedReplacedRowID\n        let result: TestObject? = WCDBAssertNoThrowReturned(\n            try database.getObject(fromTable: TestObject.name, where: condition)\n        )\n        XCTAssertNotNil(result)\n        XCTAssertEqual(result!.variable2, self.name)\n    }\n\n    func testInsertOrIgnore() {\n        // Give\n        let object = TestObject()\n        let expectedReplacedRowID = 1\n        object.variable1 = expectedReplacedRowID\n        object.variable2 = self.name\n        // When\n        XCTAssertNoThrow(try database.insertOrIgnore(object, intoTable: TestObject.name))\n        // Then\n        let condition = TestObject.Properties.variable1 == expectedReplacedRowID\n        let result: TestObject? = WCDBAssertNoThrowReturned(\n            try database.getObject(fromTable: TestObject.name, where: condition)\n        )\n        XCTAssertNotNil(result)\n        XCTAssertNotEqual(result!.variable2, self.name)\n    }\n\n    func testPartialInsert() {\n        // Give\n        let object = TestObject()\n        object.variable1 = preInsertedObjects.count + 1\n        object.variable2 = self.name\n        // When\n        XCTAssertNoThrow(try database.insert(object,\n                                             on: [TestObject.Properties.variable1],\n                                             intoTable: TestObject.name))\n        // Then\n        let result: TestObject? = WCDBAssertNoThrowReturned(\n            try database.getObject(fromTable: TestObject.name,\n                                   where: TestObject.Properties.variable1 == object.variable1!)\n        )\n        XCTAssertNotNil(result)\n        XCTAssertNil(result!.variable2)\n    }\n\n    func testTableInsert() {\n        // Give\n        let object = TestObject()\n        object.variable1 = preInsertedObjects.count + 1\n        object.variable2 = self.name\n        // When\n        XCTAssertNoThrow(try table.insert(object))\n        // Then\n        let result = WCDBAssertNoThrowReturned(\n            try table.getObject(where: TestObject.Properties.variable1 == object.variable1!)\n        )\n        XCTAssertNotNil(result)\n        XCTAssertEqual(result!, object)\n    }\n\n    func testTableInsertOrReplace() {\n        // Give\n        let object = TestObject()\n        let expectedReplacedRowID = 1\n        object.variable1 = expectedReplacedRowID\n        object.variable2 = self.name\n        // When\n        XCTAssertNoThrow(try table.insertOrReplace(object))\n        // Then\n        let condition = TestObject.Properties.variable1 == expectedReplacedRowID\n        let result: TestObject? = WCDBAssertNoThrowReturned(\n            try table.getObject(where: condition)\n        )\n        XCTAssertNotNil(result)\n        XCTAssertEqual(result!.variable2, self.name)\n    }\n\n    func testTableInsertOrIgnore() {\n        // Give\n        let object = TestObject()\n        let expectedReplacedRowID = 1\n        object.variable1 = expectedReplacedRowID\n        object.variable2 = self.name\n        // When\n        XCTAssertNoThrow(try table.insertOrIgnore(object))\n        // Then\n        let condition = TestObject.Properties.variable1 == expectedReplacedRowID\n        let result: TestObject? = WCDBAssertNoThrowReturned(\n            try table.getObject(where: condition)\n        )\n        XCTAssertNotNil(result)\n        XCTAssertNotEqual(result!.variable2, self.name)\n    }\n\n}\n"
  },
  {
    "path": "src/swift/tests/crud/InsertTests.swift",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport XCTest\n#if TEST_WCDB_SWIFT\nimport WCDBSwift\n#else\nimport WCDB\n#endif\n\nclass InsertTests: CRUDTestCase {\n\n    var insert: Insert!\n\n    override func setUp() {\n        super.setUp()\n\n        let optionalInsert = WCDBAssertNoThrowReturned(\n            try database.prepareInsert(of: TestObject.self, intoTable: TestObject.name)\n        )\n        XCTAssertNotNil(optionalInsert)\n        insert = optionalInsert!\n    }\n\n    func testInsert() {\n        // Give\n        let object = TestObject()\n        object.variable1 = preInsertedObjects.count + 1\n        object.variable2 = self.name\n        // When\n        XCTAssertNoThrow(try insert.execute(with: object))\n        // Then\n        let condition = TestObject.Properties.variable1 == object.variable1!\n        let result: TestObject? = WCDBAssertNoThrowReturned(\n            try database.getObject(fromTable: TestObject.name, where: condition)\n        )\n        XCTAssertNotNil(result)\n        XCTAssertEqual(result!, object)\n    }\n\n    func testTableInsert() {\n        // Give\n        let optionalTableInsert = WCDBAssertNoThrowReturned(\n            try table.prepareInsert(of: TestObject.self)\n        )\n        XCTAssertNotNil(optionalTableInsert)\n        insert = optionalTableInsert!\n        let object = TestObject()\n        object.variable1 = preInsertedObjects.count + 1\n        object.variable2 = self.name\n        // When\n        XCTAssertNoThrow(try insert.execute(with: object))\n        // Then\n        let condition = TestObject.Properties.variable1 == object.variable1!\n        let result: TestObject? = WCDBAssertNoThrowReturned(\n            try table.getObject(where: condition)\n        )\n        XCTAssertNotNil(result)\n        XCTAssertEqual(result!, object)\n    }\n\n    func testAutoIncrementInsert() {\n        // Give\n        let object = TestObject()\n        let expectedRowID = preInsertedObjects.count + 1\n        object.isAutoIncrement = true\n        object.variable2 = self.name\n        // When\n        XCTAssertNoThrow(try insert.execute(with: object))\n        // Then\n        let condition = TestObject.Properties.variable1 == expectedRowID\n        XCTAssertEqual(object.lastInsertedRowID, Int64(expectedRowID))\n        let result: TestObject? = WCDBAssertNoThrowReturned(\n            try database.getObject(fromTable: TestObject.name, where: condition)\n        )\n        XCTAssertNotNil(result)\n        XCTAssertEqual(result!.variable1, expectedRowID)\n        XCTAssertEqual(result!.variable2, object.variable2)\n    }\n\n    func testInsertOrReplace() {\n        // Give\n        let object = TestObject()\n        let expectedReplacedRowID = 1\n        object.variable1 = expectedReplacedRowID\n        object.variable2 = self.name\n        let optionalInsert = WCDBAssertNoThrowReturned(\n            try database.prepareInsertOrReplace(of: TestObject.self, intoTable: TestObject.name)\n        )\n        XCTAssertNotNil(optionalInsert)\n        insert = optionalInsert!\n        // When\n        XCTAssertNoThrow(try insert.execute(with: object))\n        // Then\n        let condition = TestObject.Properties.variable1 == expectedReplacedRowID\n        let result: TestObject? = WCDBAssertNoThrowReturned(\n            try database.getObject(fromTable: TestObject.name, where: condition)\n        )\n        XCTAssertNotNil(result)\n        XCTAssertEqual(result!.variable2, self.name)\n    }\n\n    func testTableInsertOrReplace() {\n        // Give\n        let object = TestObject()\n        let expectedReplacedRowID = 1\n        object.variable1 = expectedReplacedRowID\n        object.variable2 = self.name\n        let optionalInsert = WCDBAssertNoThrowReturned(\n            try table.prepareInsertOrReplace(of: TestObject.self)\n        )\n        XCTAssertNotNil(optionalInsert)\n        insert = optionalInsert!\n        // When\n        XCTAssertNoThrow(try insert.execute(with: object))\n        // Then\n        let condition = TestObject.Properties.variable1 == expectedReplacedRowID\n        let result: TestObject? = WCDBAssertNoThrowReturned(\n            try table.getObject(where: condition)\n        )\n        XCTAssertNotNil(result)\n        XCTAssertEqual(result!.variable2, self.name)\n    }\n\n    func testInsertOrIgnore() {\n        // Give\n        let object = TestObject()\n        let expectedReplacedRowID = 1\n        object.variable1 = expectedReplacedRowID\n        object.variable2 = self.name\n        let optionalInsert = WCDBAssertNoThrowReturned(\n            try database.prepareInsertOrIgnore(of: TestObject.self, intoTable: TestObject.name)\n        )\n        XCTAssertNotNil(optionalInsert)\n        insert = optionalInsert!\n        // When\n        XCTAssertNoThrow(try insert.execute(with: object))\n        // Then\n        let condition = TestObject.Properties.variable1 == expectedReplacedRowID\n        let result: TestObject? = WCDBAssertNoThrowReturned(\n            try database.getObject(fromTable: TestObject.name, where: condition)\n        )\n        XCTAssertNotNil(result)\n        XCTAssertNotEqual(result!.variable2, self.name)\n    }\n\n    func testTableInsertOrIgnore() {\n        // Give\n        let object = TestObject()\n        let expectedReplacedRowID = 1\n        object.variable1 = expectedReplacedRowID\n        object.variable2 = self.name\n        let optionalInsert = WCDBAssertNoThrowReturned(\n            try table.prepareInsertOrIgnore(of: TestObject.self)\n        )\n        XCTAssertNotNil(optionalInsert)\n        insert = optionalInsert!\n        // When\n        XCTAssertNoThrow(try insert.execute(with: object))\n        // Then\n        let condition = TestObject.Properties.variable1 == expectedReplacedRowID\n        let result: TestObject? = WCDBAssertNoThrowReturned(\n            try table.getObject(where: condition)\n        )\n        XCTAssertNotNil(result)\n        XCTAssertNotEqual(result!.variable2, self.name)\n    }\n\n    func testPartialInsert() {\n        // Give\n        let object = TestObject()\n        object.variable1 = preInsertedObjects.count + 1\n        object.variable2 = self.name\n        let optionalInsert = WCDBAssertNoThrowReturned(\n            try database.prepareInsert(on: TestObject.Properties.variable1, intoTable: TestObject.name)\n        )\n        XCTAssertNotNil(optionalInsert)\n        let insert = optionalInsert!\n        // When\n        XCTAssertNoThrow(try insert.execute(with: object))\n        // Then\n        let condition = TestObject.Properties.variable1 == object.variable1!\n        let result: TestObject? = WCDBAssertNoThrowReturned(\n            try database.getObject(fromTable: TestObject.name, where: condition)\n        )\n        XCTAssertNotNil(result)\n        XCTAssertNil(result!.variable2)\n    }\n\n    func testTablePartialInsert() {\n        // Give\n        let object = TestObject()\n        object.variable1 = preInsertedObjects.count + 1\n        object.variable2 = self.name\n        let optionalInsert = WCDBAssertNoThrowReturned(\n            try table.prepareInsert(on: TestObject.Properties.variable1)\n        )\n        XCTAssertNotNil(optionalInsert)\n        let insert = optionalInsert!\n        // When\n        XCTAssertNoThrow(try insert.execute(with: object))\n        // Then\n        let condition = TestObject.Properties.variable1 == object.variable1!\n        let result: TestObject? = WCDBAssertNoThrowReturned(\n            try table.getObject(where: condition)\n        )\n        XCTAssertNotNil(result)\n        XCTAssertNil(result!.variable2)\n    }\n\n    func testPartialInsertOrReplace() {\n        // Give\n        let object = TestObject()\n        let expectedReplacedRowID = 1\n        object.variable1 = expectedReplacedRowID\n        object.variable2 = self.name\n        let optionalInsert = WCDBAssertNoThrowReturned(\n            try database.prepareInsertOrReplace(on:\n                TestObject.Properties.variable1,\n                TestObject.Properties.variable2,\n                                                intoTable: TestObject.name)\n        )\n        XCTAssertNotNil(optionalInsert)\n        insert = optionalInsert!\n        // When\n        XCTAssertNoThrow(try insert.execute(with: object))\n        // Then\n        let condition = TestObject.Properties.variable1 == expectedReplacedRowID\n        let result: TestObject? = WCDBAssertNoThrowReturned(\n            try database.getObject(fromTable: TestObject.name, where: condition)\n        )\n        XCTAssertNotNil(result)\n        XCTAssertEqual(result!.variable2, self.name)\n    }\n\n    func testTablePartialInsertOrReplace() {\n        // Give\n        let object = TestObject()\n        let expectedReplacedRowID = 1\n        object.variable1 = expectedReplacedRowID\n        object.variable2 = self.name\n        let optionalInsert = WCDBAssertNoThrowReturned(\n            try table.prepareInsertOrReplace(on:\n                TestObject.Properties.variable1,\n                TestObject.Properties.variable2)\n        )\n        XCTAssertNotNil(optionalInsert)\n        insert = optionalInsert!\n        // When\n        XCTAssertNoThrow(try insert.execute(with: object))\n        // Then\n        let condition = TestObject.Properties.variable1 == expectedReplacedRowID\n        let result: TestObject? = WCDBAssertNoThrowReturned(\n            try table.getObject(where: condition)\n        )\n        XCTAssertNotNil(result)\n        XCTAssertEqual(result!.variable2, self.name)\n    }\n\n    func testInsertEmpty() {\n        XCTAssertNoThrow(try insert.execute(with: [TestObject]()))\n    }\n\n    func testInsertFailed() {\n        XCTAssertNoThrow(try database.prepareInsert(of: TestObject.self, intoTable: \"\"))\n    }\n\n}\n"
  },
  {
    "path": "src/swift/tests/crud/MultiSelectTests.swift",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport XCTest\n#if TEST_WCDB_SWIFT\nimport WCDBSwift\n#else\nimport WCDB\n#endif\n\nextension Dictionary where Key==String, Value: TestObjectBase {\n    static func == (lhs: [Key: Value], rhs: [Key: Value]) -> Bool {\n        guard lhs.count == rhs.count else {\n            return false\n        }\n        for (key, value) in lhs {\n            guard rhs[key] == value else {\n                return false\n            }\n        }\n        return true\n    }\n\n    static func < (lhs: [Key: Value], rhs: [Key: Value]) -> Bool {\n        guard lhs.count == rhs.count else {\n            return lhs.count < rhs.count\n        }\n        for i in 0..<lhs.count {\n            let lhsWrap = lhs[lhs.index(lhs.startIndex, offsetBy: i)]\n            let rhsWrap = rhs[rhs.index(rhs.startIndex, offsetBy: i)]\n            guard lhsWrap.key == rhsWrap.key else {\n                return lhsWrap.key < rhsWrap.key\n            }\n            guard lhsWrap.value == rhsWrap.value else {\n                return lhsWrap.value < rhsWrap.value\n            }\n        }\n        return false\n    }\n}\n\nextension Array where Element==[String: TestObjectBase] {\n    static func == (lhs: [Element], rhs: [Element]) -> Bool {\n        guard lhs.count == rhs.count else {\n            return false\n        }\n        for i in 0..<lhs.count {\n            guard lhs[i] == rhs[i] else {\n                return false\n            }\n        }\n        return true\n    }\n\n    func sorted() -> [Element] {\n        return self.sorted { (lhs, rhs) -> Bool in\n            return lhs < rhs\n        }\n    }\n}\n\nclass MultiSelectTests: CRUDTestCase {\n\n    final class MultiSelectObject: TestObjectBase, TableCodable {\n        var variable1: Int = 0\n        var variable2: String = \"\"\n\n        enum CodingKeys: String, CodingTableKey {\n            typealias Root = MultiSelectObject\n            case variable1\n            case variable2\n            nonisolated(unsafe) static let objectRelationalMapping = TableBinding(CodingKeys.self) {\n                BindColumnConstraint(.variable1, isPrimary: true, orderBy: .ascending, isAutoIncrement: true)\n            }\n        }\n\n        override var hashValue: Int {\n            return (String(variable1)+variable2).hashValue\n        }\n\n        override var debugDescription: String {\n            return \"\\(variable1), \\(variable2)\"\n        }\n    }\n\n    var preInsertedMultiSelectObjects: [MultiSelectObject] = {\n        let object1 = MultiSelectObject()\n        object1.variable1 = 1\n        object1.variable2 = \"multiObject1\"\n        let object2 = MultiSelectObject()\n        object2.variable1 = 2\n        object2.variable2 = \"multiObject2\"\n        return [object1, object2]\n    }()\n\n    lazy var preInsertedMultiObjects: [[String: TestObjectBase]] = [\n        [\n            TestObject.name: preInsertedObjects[0],\n            MultiSelectObject.name: preInsertedMultiSelectObjects[0]\n        ],\n        [\n            TestObject.name: preInsertedObjects[1],\n            MultiSelectObject.name: preInsertedMultiSelectObjects[1]\n        ]\n    ]\n\n    var multiSelect: MultiSelect!\n\n    override func setUp() {\n        super.setUp()\n\n        XCTAssertNoThrow(try database.create(table: MultiSelectObject.name, of: MultiSelectObject.self))\n\n        XCTAssertNoThrow(try database.insert(preInsertedMultiSelectObjects, intoTable: MultiSelectObject.name))\n\n        let tables = [TestObject.name, MultiSelectObject.name]\n        let optionalMultiSelect = WCDBAssertNoThrowReturned(\n            try database.prepareMultiSelect(on:\n                TestObject.Properties.variable1.in(table: TestObject.name),\n                TestObject.Properties.variable2.in(table: TestObject.name),\n                MultiSelectObject.Properties.variable1.in(table: MultiSelectObject.name),\n                MultiSelectObject.Properties.variable2.in(table: MultiSelectObject.name),\n                                            fromTables: tables))\n        XCTAssertNotNil(optionalMultiSelect)\n        let property1 = TestObject.Properties.variable1.in(table: TestObject.name)\n        let property2 = MultiSelectObject.Properties.variable1.in(table: MultiSelectObject.name)\n        multiSelect = optionalMultiSelect!.where(property1 == property2)\n    }\n\n    func testSelect() {\n        // When\n        let results = WCDBAssertNoThrowReturned(\n            try multiSelect.allMultiObjects(),\n            whenFailed: [[String: TableDecodableBase]]()\n        )\n        let baseResults = results as? [[String: TestObjectBase]]\n        // Then\n        XCTAssertNotNil(baseResults)\n        XCTAssertTrue(baseResults! == preInsertedMultiObjects)\n    }\n\n    func testOrderedSelect() {\n        // When\n        let order = TestObject.Properties.variable1.in(table: TestObject.name).order(.descending)\n        let results = WCDBAssertNoThrowReturned(\n            try multiSelect.order(by: order).allMultiObjects(),\n            whenFailed: [[String: TableDecodableBase]]())\n        let baseResults = results as? [[String: TestObjectBase]]\n        // Then\n        XCTAssertNotNil(baseResults)\n        XCTAssertTrue(baseResults! == preInsertedMultiObjects.reversed())\n    }\n\n    func testLimitedSelect() {\n        // When\n        let results = WCDBAssertNoThrowReturned(\n            try multiSelect.limit(1).allMultiObjects(),\n            whenFailed: [[String: TableDecodableBase]]()\n        )\n        let baseResults = results as? [[String: TestObjectBase]]\n        // Then\n        XCTAssertNotNil(baseResults)\n        XCTAssertEqual(baseResults!.count, 1)\n        XCTAssertTrue(baseResults![0] == preInsertedMultiObjects[0])\n    }\n\n    func testOffsetSelect() {\n        // When\n        let results = WCDBAssertNoThrowReturned(\n            try multiSelect.limit(1, offset: 1).allMultiObjects(),\n            whenFailed: [[String: TableDecodableBase]]()\n        )\n        let baseResults = results as? [[String: TestObjectBase]]\n        // Then\n        XCTAssertNotNil(baseResults)\n        XCTAssertEqual(baseResults!.count, 1)\n        XCTAssertTrue(baseResults![0] == preInsertedMultiObjects[1])\n    }\n\n    func testSelectIteration() {\n        // When\n        var results: [[String: TestObjectBase]] = []\n        while let result = WCDBAssertNoThrowReturned(try multiSelect.nextMultiObject()) {\n            let crudObject = result as? [String: TestObjectBase]\n            XCTAssertNotNil(crudObject)\n            results.append(crudObject!)\n        }\n        // Then\n        XCTAssertTrue(results == preInsertedMultiObjects)\n    }\n}\n"
  },
  {
    "path": "src/swift/tests/crud/MultithreadTests.swift",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport XCTest\n#if TEST_WCDB_SWIFT\nimport WCDBSwift\n#else\nimport WCDB\n#endif\n\nfunc tick(_ block: () -> Void) -> TimeInterval {\n    let before: TimeInterval = ProcessInfo.processInfo.systemUptime\n    block()\n    let after: TimeInterval = ProcessInfo.processInfo.systemUptime\n    return after - before\n}\n\nclass MultithreadTests: CRUDTestCase, @unchecked Sendable {\n\n    var group: DispatchGroup!\n    var queue: DispatchQueue!\n    let tableName = TestObject.name\n\n    override func setUp() {\n        super.setUp()\n        group = DispatchGroup()\n        queue = DispatchQueue(label: String(recommendTag), attributes: .concurrent)\n\n        XCTAssertNoThrow(try database.delete(fromTable: tableName))\n        database.close()\n    }\n\n    func preInsert(withCount count: Int) {\n        let object = TestObject()\n        object.isAutoIncrement = true\n        let objects = Array(repeating: object, count: count)\n        XCTAssertNoThrow(try database.insert(objects, intoTable: tableName))\n    }\n\n    func testMultithreadReadRead() {\n        // Give\n        let expectedCount = 10000\n        preInsert(withCount: expectedCount)\n        database.close()\n\n        let singleReadCost = tick {\n            let results: [TestObject]? = try? database.getObjects(fromTable: tableName)\n            XCTAssertNotNil(results)\n            XCTAssertEqual(results!.count, expectedCount)\n        }\n        database.close()\n        // When\n        let readReadCost = tick {\n            queue.async(group: group, execute: {\n                let results: [TestObject]? = try? self.database.getObjects(fromTable: self.tableName)\n                XCTAssertNotNil(results)\n                XCTAssertEqual(results!.count, expectedCount)\n            })\n            queue.async(group: group, execute: {\n                let results: [TestObject]? = try? self.database.getObjects(fromTable: self.tableName)\n                XCTAssertNotNil(results)\n                XCTAssertEqual(results!.count, expectedCount)\n            })\n            group.wait()\n        }\n        // Then\n        XCTAssertLessThanOrEqual(readReadCost, (singleReadCost * 2) * 0.9)\n    }\n\n    func testMultithreadReadWrite() {\n        // Give\n        let expectedCount = 10000\n\n        let singleWriteCost = tick {\n            preInsert(withCount: expectedCount)\n        }\n        database.close()\n\n        // Get single read time\n        let singleReadCost = tick {\n            let results: [TestObject]? = try? database.getObjects(fromTable: tableName)\n            XCTAssertNotNil(results)\n            XCTAssertEqual(results!.count, expectedCount)\n        }\n        database.close()\n        // When\n        let readWriteCost = tick {\n            queue.async(group: group, execute: {\n                self.preInsert(withCount: expectedCount)\n            })\n            queue.async(group: group, execute: {\n                let results: [TestObject]? = try? self.database.getObjects(fromTable: self.tableName)\n                XCTAssertNotNil(results)\n                XCTAssertEqual(results!.count, expectedCount)\n            })\n            group.wait()\n        }\n\n        // Then\n        XCTAssertLessThanOrEqual(readWriteCost, (singleReadCost + singleWriteCost) * 0.9)\n    }\n\n    func testMultithreadWriteWrite() {\n        // Give\n        let expectedCount = 10000\n\n        let singleWriteCost = tick {\n            preInsert(withCount: expectedCount)\n        }\n        database.close()\n\n        // Get single read time\n        XCTAssertNoThrow(try database.delete(fromTable: tableName))\n        database.close()\n        // When\n        let writeWriteCost = tick {\n            queue.async(group: group, execute: {\n                self.preInsert(withCount: expectedCount)\n            })\n            queue.async(group: group, execute: {\n                self.preInsert(withCount: expectedCount)\n            })\n            group.wait()\n        }\n        // Then\n        XCTAssertLessThanOrEqual(writeWriteCost, (singleWriteCost * 2) * 1.1)\n        XCTAssertGreaterThanOrEqual(writeWriteCost, (singleWriteCost * 2) * 0.9)\n    }\n\n    final class ConditionLock {\n        private var mutex = pthread_mutex_t()\n        private var cond = pthread_cond_t()\n\n        init() {\n            pthread_mutex_init(&mutex, nil)\n            pthread_cond_init(&cond, nil)\n        }\n\n        deinit {\n            pthread_cond_destroy(&cond)\n            pthread_mutex_destroy(&mutex)\n        }\n\n        func lock() {\n            pthread_mutex_lock(&mutex)\n        }\n\n        func unlock() {\n            pthread_mutex_unlock(&mutex)\n        }\n\n        func wait() {\n            pthread_cond_wait(&cond, &mutex)\n        }\n\n        func wait(timeout: Int) {\n            var ts = timespec()\n            ts.tv_sec = timeout\n            pthread_cond_timedwait(&cond, &mutex, &ts)\n        }\n\n        func broadcast() {\n            pthread_cond_broadcast(&cond)\n        }\n    }\n}\n"
  },
  {
    "path": "src/swift/tests/crud/RowSelectTests.swift",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport XCTest\n#if TEST_WCDB_SWIFT\nimport WCDBSwift\n#else\nimport WCDB\n#endif\n\nclass RowSelectTests: CRUDTestCase {\n\n    var rowSelect: RowSelect!\n\n    override func setUp() {\n        super.setUp()\n\n        let optionalRowSelect = WCDBAssertNoThrowReturned(\n            try database.prepareRowSelect(fromTable: TestObject.name)\n        )\n        XCTAssertNotNil(optionalRowSelect)\n        rowSelect = optionalRowSelect!\n    }\n\n    func testRowSelect() {\n        // When\n        let results: MultiRowsValue = WCDBAssertNoThrowReturned(try rowSelect.allRows())\n        // Then\n        XCTAssertEqual(results.count, preInsertedObjects.count)\n        XCTAssertEqual(Int(results[row: 0, column: 0].int64Value), preInsertedObjects[0].variable1)\n        XCTAssertEqual(results[row: 0, column: 1].stringValue, preInsertedObjects[0].variable2)\n        XCTAssertEqual(Int(results[row: 1, column: 0].int64Value), preInsertedObjects[1].variable1)\n        XCTAssertEqual(results[row: 1, column: 1].stringValue, preInsertedObjects[1].variable2)\n    }\n\n    func testTableRowSelect() {\n        let optionalRowSelect = WCDBAssertNoThrowReturned(\n            try table.prepareRowSelect()\n        )\n        XCTAssertNotNil(optionalRowSelect)\n        rowSelect = optionalRowSelect!\n        // When\n        let results: MultiRowsValue = WCDBAssertNoThrowReturned(try rowSelect.allRows())\n        // Then\n        XCTAssertEqual(results.count, preInsertedObjects.count)\n        XCTAssertEqual(Int(results[row: 0, column: 0].int64Value), preInsertedObjects[0].variable1)\n        XCTAssertEqual(results[row: 0, column: 1].stringValue, preInsertedObjects[0].variable2)\n        XCTAssertEqual(Int(results[row: 1, column: 0].int64Value), preInsertedObjects[1].variable1)\n        XCTAssertEqual(results[row: 1, column: 1].stringValue, preInsertedObjects[1].variable2)\n    }\n\n    func testConditionalRowSelect() {\n        // When\n        let results: MultiRowsValue = WCDBAssertNoThrowReturned(\n            try rowSelect.where(TestObject.Properties.variable1 == 1).allRows()\n        )\n        // Then\n        XCTAssertEqual(results.count, 1)\n        XCTAssertEqual(Int(results[row: 0, column: 0].int64Value), preInsertedObjects[0].variable1)\n        XCTAssertEqual(results[row: 0, column: 1].stringValue, preInsertedObjects[0].variable2)\n    }\n\n    func testOrderedRowSelect() {\n        // Give\n        let order = TestObject.Properties.variable1.order(.descending)\n        // When\n        let results: MultiRowsValue = WCDBAssertNoThrowReturned(try rowSelect.order(by: order).allRows())\n        // Then\n        XCTAssertEqual(results.count, preInsertedObjects.count)\n        XCTAssertEqual(Int(results[row: 0, column: 0].int64Value), preInsertedObjects[1].variable1)\n        XCTAssertEqual(results[row: 0, column: 1].stringValue, preInsertedObjects[1].variable2)\n        XCTAssertEqual(Int(results[row: 1, column: 0].int64Value), preInsertedObjects[0].variable1)\n        XCTAssertEqual(results[row: 1, column: 1].stringValue, preInsertedObjects[0].variable2)\n    }\n\n    func testLimitedRowSelect() {\n        // When\n        let results: MultiRowsValue = WCDBAssertNoThrowReturned(try rowSelect.limit(1).allRows())\n        // Then\n        XCTAssertEqual(results.count, 1)\n        XCTAssertEqual(Int(results[row: 0, column: 0].int64Value), preInsertedObjects[0].variable1)\n        XCTAssertEqual(results[row: 0, column: 1].stringValue, preInsertedObjects[0].variable2)\n    }\n\n    func testOffsetRowSelect() {\n        // When\n        let results: MultiRowsValue = WCDBAssertNoThrowReturned(try rowSelect.limit(1, offset: 1).allRows())\n        // Then\n        XCTAssertEqual(results.count, 1)\n        XCTAssertEqual(Int(results[row: 0, column: 0].int64Value), preInsertedObjects[1].variable1)\n        XCTAssertEqual(results[row: 0, column: 1].stringValue, preInsertedObjects[1].variable2)\n    }\n\n    func testGroupByRowSelect() {\n        // Give\n        let preInsertedObjects: [TestObject] = {\n            let object1 = TestObject()\n            object1.variable1 = 3\n            object1.variable2 = \"object1\"\n            let object2 = TestObject()\n            object2.variable1 = 4\n            object2.variable2 = \"object2\"\n            return [object1, object2]\n        }()\n        XCTAssertNoThrow(try database.insert(preInsertedObjects, intoTable: TestObject.name))\n\n        let optionalRowSelect = WCDBAssertNoThrowReturned(\n            try database.prepareRowSelect(on: Column.all().count(),\n                                          fromTable: TestObject.name)\n        )\n        XCTAssertNotNil(optionalRowSelect)\n        rowSelect = optionalRowSelect!\n        rowSelect.group(by: TestObject.Properties.variable2).having(TestObject.Properties.variable1 > 0)\n        // When\n        let results: OneColumnValue = WCDBAssertNoThrowReturned(try rowSelect.allValues())\n        // Then\n        XCTAssertEqual(results.count, 2)\n        XCTAssertEqual(results[0].int32Value, 2)\n        XCTAssertEqual(results[1].int32Value, 2)\n    }\n\n    func testTableGroupByRowSelect() {\n        // Give\n        var optionalRowSelect = WCDBAssertNoThrowReturned(\n            try table.prepareRowSelect()\n        )\n        XCTAssertNotNil(optionalRowSelect)\n        rowSelect = optionalRowSelect!\n        let preInsertedObjects: [TestObject] = {\n            let object1 = TestObject()\n            object1.variable1 = 3\n            object1.variable2 = \"object1\"\n            let object2 = TestObject()\n            object2.variable1 = 4\n            object2.variable2 = \"object2\"\n            return [object1, object2]\n        }()\n        XCTAssertNoThrow(try table.insert(preInsertedObjects))\n\n        optionalRowSelect = WCDBAssertNoThrowReturned(\n            try table.prepareRowSelect(on: Column.all().count())\n        )\n        XCTAssertNotNil(optionalRowSelect)\n        rowSelect = optionalRowSelect!\n        rowSelect.group(by: TestObject.Properties.variable2).having(TestObject.Properties.variable1 > 0)\n        // When\n        let results: OneColumnValue = WCDBAssertNoThrowReturned(try rowSelect.allValues())\n        // Then\n        XCTAssertEqual(results.count, 2)\n        XCTAssertEqual(results[0].int32Value, 2)\n        XCTAssertEqual(results[1].int32Value, 2)\n    }\n\n    func testPartialRowSelect() {\n        // Give\n        let optionalRowSelect = WCDBAssertNoThrowReturned(\n            try database.prepareRowSelect(on: TestObject.Properties.variable2, fromTable: TestObject.name)\n        )\n        XCTAssertNotNil(optionalRowSelect)\n        rowSelect = optionalRowSelect!\n        // When\n        let results: MultiRowsValue = WCDBAssertNoThrowReturned(try rowSelect.allRows())\n        // Then\n        XCTAssertEqual(results.count, preInsertedObjects.count)\n        XCTAssertEqual(results[row: 0, column: 0].stringValue, preInsertedObjects[0].variable2)\n        XCTAssertEqual(results[row: 1, column: 0].stringValue, preInsertedObjects[1].variable2)\n    }\n\n    func testTablePartialRowSelect() {\n        // Give\n        let optionalRowSelect = WCDBAssertNoThrowReturned(\n            try table.prepareRowSelect(on: TestObject.Properties.variable2)\n        )\n        XCTAssertNotNil(optionalRowSelect)\n        rowSelect = optionalRowSelect!\n        // When\n        let results: MultiRowsValue = WCDBAssertNoThrowReturned(try rowSelect.allRows())\n        // Then\n        XCTAssertEqual(results.count, preInsertedObjects.count)\n        XCTAssertEqual(results[row: 0, column: 0].stringValue, preInsertedObjects[0].variable2)\n        XCTAssertEqual(results[row: 1, column: 0].stringValue, preInsertedObjects[1].variable2)\n    }\n\n    func testRowSelectIteration() {\n        // When\n        var results: MultiRowsValue = []\n        while let result = WCDBAssertNoThrowReturned(try rowSelect.nextRow()) {\n            results.append(result)\n        }\n        // Then\n        XCTAssertEqual(results.count, preInsertedObjects.count)\n        XCTAssertEqual(Int(results[row: 0, column: 0].int64Value), preInsertedObjects[0].variable1)\n        XCTAssertEqual(results[row: 0, column: 1].stringValue, preInsertedObjects[0].variable2)\n        XCTAssertEqual(Int(results[row: 1, column: 0].int64Value), preInsertedObjects[1].variable1)\n        XCTAssertEqual(results[row: 1, column: 1].stringValue, preInsertedObjects[1].variable2)\n    }\n\n    func testRowSelectValue() {\n        // When\n        let results: OneColumnValue = WCDBAssertNoThrowReturned(try rowSelect.allValues())\n        // Then\n        XCTAssertEqual(results.count, preInsertedObjects.count)\n        XCTAssertEqual(Int(results[0].int64Value), preInsertedObjects[0].variable1)\n        XCTAssertEqual(Int(results[1].int64Value), preInsertedObjects[1].variable1)\n    }\n\n    func testRowSelectValueIteraion() {\n        // When\n        var results: OneColumnValue = []\n        while let result = WCDBAssertNoThrowReturned(try rowSelect.nextValue()) {\n            results.append(result)\n        }\n        // Then\n        XCTAssertEqual(results.count, preInsertedObjects.count)\n        XCTAssertEqual(Int(results[0].int64Value), preInsertedObjects[0].variable1)\n        XCTAssertEqual(Int(results[1].int64Value), preInsertedObjects[1].variable1)\n    }\n\n    func testRowSelectMultiTables() {\n        // Give\n        let table = TestObject.name\n        let table2 = \"\\(TestObject.name)_2\"\n        XCTAssertNoThrow(try database.create(table: table2, of: TestObject.self))\n\n        let object1 = TestObject()\n        object1.variable1 = 1\n        object1.variable2 = \"object3\"\n        XCTAssertNoThrow(try database.insert(object1, intoTable: table2))\n\n        let column1Table1 = TestObject.Properties.variable1.in(table: table)\n        let column1Table2 = TestObject.Properties.variable1.in(table: table2)\n        let column2Table1 = TestObject.Properties.variable2.in(table: table)\n        let column2Table2 = TestObject.Properties.variable2.in(table: table2)\n        // When\n        let optionalRowSelect = WCDBAssertNoThrowReturned(\n            try database.prepareRowSelect(on: column2Table1, column2Table2,\n                                          fromTables: [table, table2])\n                .where(column1Table1 == column1Table2)\n        )\n        XCTAssertNotNil(optionalRowSelect)\n        let rowSelect = optionalRowSelect!\n        let rows = WCDBAssertNoThrowReturned(try rowSelect.allRows())\n        // Then\n        XCTAssertEqual(rows.count, 1)\n        XCTAssertEqual(rows[row: 0, column: 0].stringValue, \"object1\")\n        XCTAssertEqual(rows[row: 0, column: 1].stringValue, \"object3\")\n    }\n\n    func testRowSelectAllMultiTables() {\n        // Give\n        let table = TestObject.name\n        let table2 = \"\\(TestObject.name)_2\"\n        XCTAssertNoThrow(try database.create(table: table2, of: TestObject.self))\n\n        let object1 = TestObject()\n        object1.variable1 = 1\n        object1.variable2 = \"object3\"\n        XCTAssertNoThrow(try database.insert(object1, intoTable: table2))\n\n        let column1Table1 = TestObject.Properties.variable1.in(table: table)\n        let column1Table2 = TestObject.Properties.variable1.in(table: table2)\n        // When\n        let optionalRowSelect = WCDBAssertNoThrowReturned(\n            try database.prepareRowSelect(fromTables: [table, table2])\n                .where(column1Table1 == column1Table2)\n        )\n        XCTAssertNotNil(optionalRowSelect)\n        let rowSelect = optionalRowSelect!\n        let rows = WCDBAssertNoThrowReturned(try rowSelect.allRows())\n        // Then\n        XCTAssertEqual(rows.count, 1)\n        XCTAssertEqual(Int(rows[row: 0, column: 0].int32Value), 1)\n        XCTAssertEqual(rows[row: 0, column: 1].stringValue, \"object1\")\n        XCTAssertEqual(Int(rows[row: 0, column: 2].int32Value), 1)\n        XCTAssertEqual(rows[row: 0, column: 3].stringValue, \"object3\")\n    }\n\n    func testRowSelectFailed() {\n        XCTAssertNoThrow(try database.prepareRowSelect(fromTables: []))\n    }\n\n    func testRowSelectType() {\n        // Give\n        let optionalRowSelect = WCDBAssertNoThrowReturned(\n            try database.prepareRowSelect(on: 1, 2.0, \"3\", fromTable: TestObject.name)\n        )\n        XCTAssertNotNil(optionalRowSelect)\n        rowSelect = optionalRowSelect!\n\n        // When\n        let results: OneRowValue? = WCDBAssertNoThrowReturned(try rowSelect.nextRow())\n        XCTAssertNotNil(results)\n        XCTAssertEqual(results!.count, 3)\n        // Then\n        XCTAssertEqual(results![0].int32Value, 1)\n        XCTAssertEqual(results![1].doubleValue, 2.0)\n        XCTAssertEqual(results![2].stringValue, \"3\")\n    }\n\n    func testTableRowSelectType() {\n        // Give\n        let optionalRowSelect = WCDBAssertNoThrowReturned(\n            try table.prepareRowSelect(on: 1, 2.0, \"3\")\n        )\n        XCTAssertNotNil(optionalRowSelect)\n        rowSelect = optionalRowSelect!\n\n        // When\n        let results: OneRowValue? = WCDBAssertNoThrowReturned(try rowSelect.nextRow())\n        XCTAssertNotNil(results)\n        XCTAssertEqual(results!.count, 3)\n        // Then\n        XCTAssertEqual(results![0].int32Value, 1)\n        XCTAssertEqual(results![1].doubleValue, 2.0)\n        XCTAssertEqual(results![2].stringValue, \"3\")\n    }\n}\n"
  },
  {
    "path": "src/swift/tests/crud/SelectInterfaceTests.swift",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport XCTest\n#if TEST_WCDB_SWIFT\nimport WCDBSwift\n#else\nimport WCDB\n#endif\n\nclass SelectInterfaceTests: CRUDTestCase {\n\n    func testSelect() {\n        let results: [TestObject] = WCDBAssertNoThrowReturned(\n            try database.getObjects(fromTable: TestObject.name),\n            whenFailed: [TestObject]()\n        )\n        XCTAssertEqual(results.sorted(), preInsertedObjects.sorted())\n    }\n\n    func testConditionalSelect() {\n        let results: [TestObject] = WCDBAssertNoThrowReturned(\n            try database.getObjects(fromTable: TestObject.name, where: TestObject.Properties.variable1 == 2),\n            whenFailed: [TestObject]()\n        )\n        XCTAssertEqual(results.count, 1)\n        XCTAssertEqual(results[0].variable2, \"object2\")\n    }\n\n    func testOrderedSelect() {\n        let order = [TestObject.Properties.variable2.order(.descending)]\n        let results: [TestObject] = WCDBAssertNoThrowReturned(\n            try database.getObjects(fromTable: TestObject.name, orderBy: order),\n            whenFailed: [TestObject]()\n        )\n        XCTAssertEqual(results, preInsertedObjects.reversed())\n    }\n\n    func testLimitedSelect() {\n        let results: [TestObject] = WCDBAssertNoThrowReturned(\n            try database.getObjects(fromTable: TestObject.name, limit: 1),\n            whenFailed: [TestObject]()\n        )\n        XCTAssertEqual(results.count, 1)\n        XCTAssertEqual(results[0], preInsertedObjects[0])\n    }\n\n    func testOffsetSelect() {\n        let results: [TestObject] = WCDBAssertNoThrowReturned(\n            try database.getObjects(fromTable: TestObject.name, limit: 1, offset: 1),\n            whenFailed: [TestObject]()\n        )\n        XCTAssertEqual(results.count, 1)\n        XCTAssertEqual(results[0], preInsertedObjects[1])\n    }\n\n    func testPartialSelect() {\n        let results: [TestObject] = WCDBAssertNoThrowReturned(\n            try database.getObjects(on: TestObject.Properties.variable2, fromTable: TestObject.name),\n            whenFailed: [TestObject]()\n        )\n        XCTAssertEqual(results.map({ (object) in\n            XCTAssertNil(object.variable1)\n            XCTAssertNotNil(object.variable2)\n            return object.variable2!\n        }), preInsertedObjects.map { $0.variable2! })\n    }\n\n    func testTableSelect() {\n        // Give\n        let table: Table<TestObject> = database.getTable(named: TestObject.name)\n        // When\n        let results: [TestObject] = WCDBAssertNoThrowReturned(\n            try table.getObjects(), whenFailed: [TestObject]()\n        )\n        // Then\n        XCTAssertEqual(results.sorted(), preInsertedObjects.sorted())\n    }\n\n    func testRowSelect() {\n        // When\n        let results: MultiRowsValue = WCDBAssertNoThrowReturned(\n            try database.getRows(fromTable: TestObject.name)\n        )\n        // Then\n        XCTAssertEqual(results.count, preInsertedObjects.count)\n        XCTAssertEqual(Int(results[row: 0, column: 0].int64Value), preInsertedObjects[0].variable1)\n        XCTAssertEqual(results[row: 0, column: 1].stringValue, preInsertedObjects[0].variable2)\n        XCTAssertEqual(Int(results[row: 1, column: 0].int64Value), preInsertedObjects[1].variable1)\n        XCTAssertEqual(results[row: 1, column: 1].stringValue, preInsertedObjects[1].variable2)\n    }\n\n    func testConditionalRowSelect() {\n        // When\n        let results: MultiRowsValue = WCDBAssertNoThrowReturned(\n            try database.getRows(fromTable: TestObject.name, where: TestObject.Properties.variable1 == 1)\n        )\n        // Then\n        XCTAssertEqual(results.count, 1)\n        XCTAssertEqual(Int(results[row: 0, column: 0].int64Value), preInsertedObjects[0].variable1)\n        XCTAssertEqual(results[row: 0, column: 1].stringValue, preInsertedObjects[0].variable2)\n    }\n\n    func testOrderedRowSelect() {\n        // Give\n        let order = [TestObject.Properties.variable1.order(.descending)]\n        // When\n        let results: MultiRowsValue = WCDBAssertNoThrowReturned(\n            try database.getRows(fromTable: TestObject.name, orderBy: order)\n        )\n        // Then\n        XCTAssertEqual(results.count, preInsertedObjects.count)\n        XCTAssertEqual(Int(results[row: 0, column: 0].int64Value), preInsertedObjects[1].variable1)\n        XCTAssertEqual(results[row: 0, column: 1].stringValue, preInsertedObjects[1].variable2)\n        XCTAssertEqual(Int(results[row: 1, column: 0].int64Value), preInsertedObjects[0].variable1)\n        XCTAssertEqual(results[row: 1, column: 1].stringValue, preInsertedObjects[0].variable2)\n    }\n\n    func testLimitedRowSelect() {\n        // When\n        let results: MultiRowsValue = WCDBAssertNoThrowReturned(\n            try database.getRows(fromTable: TestObject.name, limit: 1)\n        )\n        // Then\n        XCTAssertEqual(results.count, 1)\n        XCTAssertEqual(Int(results[row: 0, column: 0].int64Value), preInsertedObjects[0].variable1)\n        XCTAssertEqual(results[row: 0, column: 1].stringValue, preInsertedObjects[0].variable2)\n    }\n\n    func testOffsetRowSelect() {\n        // When\n        let results: MultiRowsValue = WCDBAssertNoThrowReturned(\n            try database.getRows(fromTable: TestObject.name, limit: 1, offset: 1)\n        )\n        // Then\n        XCTAssertEqual(results.count, 1)\n        let row = results[row: 0]\n        XCTAssertEqual(Int(row[0].int64Value), preInsertedObjects[1].variable1)\n        XCTAssertEqual(row[1].stringValue, preInsertedObjects[1].variable2)\n    }\n\n    func testPartialRowSelect() {\n        // When\n        let results: MultiRowsValue = WCDBAssertNoThrowReturned(\n            try database.getRows(on: TestObject.Properties.variable2, fromTable: TestObject.name)\n        )\n        // Then\n        XCTAssertEqual(results.count, preInsertedObjects.count)\n        XCTAssertEqual(results[row: 0, column: 0].stringValue, preInsertedObjects[0].variable2)\n        XCTAssertEqual(results[row: 1, column: 0].stringValue, preInsertedObjects[1].variable2)\n    }\n\n    func testRowSelectOne() {\n        // When\n        let results: OneRowValue = WCDBAssertNoThrowReturned(\n            try database.getRow(fromTable: TestObject.name)\n        )\n        // Then\n        XCTAssertEqual(results.count, 2)\n        XCTAssertEqual(Int(results[0].int64Value), preInsertedObjects[0].variable1)\n        XCTAssertEqual(results[1].stringValue, preInsertedObjects[0].variable2)\n    }\n\n    func testRowSelectColumn() {\n        // When\n        let results: OneColumnValue = WCDBAssertNoThrowReturned(\n            try database.getColumn(on: TestObject.Properties.variable1, fromTable: TestObject.name)\n        )\n        // Then\n        XCTAssertEqual(Int(results[0].int64Value), preInsertedObjects[0].variable1)\n        XCTAssertEqual(Int(results[1].int64Value), preInsertedObjects[1].variable1)\n    }\n\n    func testConditionalRowSelectColumn() {\n        // When\n        let results: OneColumnValue = WCDBAssertNoThrowReturned(\n            try database.getColumn(on: TestObject.Properties.variable1,\n                                   fromTable: TestObject.name,\n                                   where: TestObject.Properties.variable1 == 1)\n        )\n        // Then\n        XCTAssertEqual(results.count, 1)\n        XCTAssertEqual(Int(results[0].int64Value), preInsertedObjects[0].variable1)\n    }\n\n    func testOrderedRowSelectColumn() {\n        // Give\n        let order = [TestObject.Properties.variable1.order(.descending)]\n        // When\n        let results: OneColumnValue = WCDBAssertNoThrowReturned(\n            try database.getColumn(on: TestObject.Properties.variable1, fromTable: TestObject.name, orderBy: order)\n        )\n        // Then\n        XCTAssertEqual(results.count, preInsertedObjects.count)\n        XCTAssertEqual(Int(results[0].int64Value), preInsertedObjects[1].variable1)\n        XCTAssertEqual(Int(results[1].int64Value), preInsertedObjects[0].variable1)\n    }\n\n    func testLimitedRowSelectColumn() {\n        // When\n        let results: OneColumnValue = WCDBAssertNoThrowReturned(\n            try database.getColumn(on: TestObject.Properties.variable1, fromTable: TestObject.name, limit: 1)\n        )\n        // Then\n        XCTAssertEqual(results.count, 1)\n        XCTAssertEqual(Int(results[0].int64Value), preInsertedObjects[0].variable1)\n    }\n\n    func testOffsetRowSelectColumn() {\n        // When\n        let results: OneColumnValue = WCDBAssertNoThrowReturned(\n            try database.getColumn(on: TestObject.Properties.variable1, fromTable: TestObject.name, limit: 1, offset: 1)\n        )\n        // Then\n        XCTAssertEqual(results.count, 1)\n        XCTAssertEqual(Int(results[0].int64Value), preInsertedObjects[1].variable1)\n    }\n\n    func testRowSelectDistinctColumn() {\n        // Give\n        let object1 = TestObject()\n        object1.variable1 = 3\n        object1.variable2 = \"object1\"\n        XCTAssertNoThrow(try database.insert(object1, intoTable: TestObject.name))\n        // When\n        let results: OneColumnValue = WCDBAssertNoThrowReturned(\n            try database.getDistinctColumn(on: TestObject.Properties.variable2, fromTable: TestObject.name)\n        )\n        // Then\n        XCTAssertEqual(results[0].stringValue, preInsertedObjects[0].variable2)\n        XCTAssertEqual(results[1].stringValue, preInsertedObjects[1].variable2)\n    }\n\n    func testConditionalRowSelectDistinctColumn() {\n        // Give\n        let object1 = TestObject()\n        object1.variable1 = 3\n        object1.variable2 = \"object1\"\n        XCTAssertNoThrow(try database.insert(object1, intoTable: TestObject.name))\n        // When\n        let results: OneColumnValue = WCDBAssertNoThrowReturned(\n            try database.getDistinctColumn(on: TestObject.Properties.variable2,\n                                           fromTable: TestObject.name,\n                                           where: TestObject.Properties.variable1 == 1)\n        )\n        // Then\n        XCTAssertEqual(results.count, 1)\n        XCTAssertEqual(results[0].stringValue, preInsertedObjects[0].variable2)\n    }\n\n    func testOrderedRowSelectDistinctColumn() {\n        // Give\n        let object1 = TestObject()\n        object1.variable1 = 3\n        object1.variable2 = \"object1\"\n        XCTAssertNoThrow(try database.insert(object1, intoTable: TestObject.name))\n        // Give\n        let order = [TestObject.Properties.variable2.order(.descending)]\n        // When\n        let results: OneColumnValue = WCDBAssertNoThrowReturned(\n            try database.getDistinctColumn(on: TestObject.Properties.variable2,\n                                           fromTable: TestObject.name,\n                                           orderBy: order)\n        )\n        // Then\n        XCTAssertEqual(results.count, preInsertedObjects.count)\n        XCTAssertEqual(results[0].stringValue, preInsertedObjects[1].variable2)\n        XCTAssertEqual(results[1].stringValue, preInsertedObjects[0].variable2)\n    }\n\n    func testLimitedRowSelectDistinctColumn() {\n        // Give\n        let object1 = TestObject()\n        object1.variable1 = 3\n        object1.variable2 = \"object1\"\n        XCTAssertNoThrow(try database.insert(object1, intoTable: TestObject.name))\n        // When\n        let results: OneColumnValue = WCDBAssertNoThrowReturned(\n            try database.getDistinctColumn(on: TestObject.Properties.variable2, fromTable: TestObject.name, limit: 1)\n        )\n        // Then\n        XCTAssertEqual(results.count, 1)\n        XCTAssertEqual(results[0].stringValue, preInsertedObjects[0].variable2)\n    }\n\n    func testOffsetRowSelectDistinctColumn() {\n        // Give\n        let object1 = TestObject()\n        object1.variable1 = 3\n        object1.variable2 = \"object1\"\n        XCTAssertNoThrow(try database.insert(object1, intoTable: TestObject.name))\n        // When\n        let results: OneColumnValue = WCDBAssertNoThrowReturned(\n            try database.getDistinctColumn(on: TestObject.Properties.variable2,\n                                           fromTable: TestObject.name,\n                                           limit: 1,\n                                           offset: 1)\n        )\n        // Then\n        XCTAssertEqual(results.count, 1)\n        XCTAssertEqual(results[0].stringValue, preInsertedObjects[1].variable2)\n    }\n\n    func testRowSelectValue() {\n        // When\n        let result: Value? = WCDBAssertNoThrowReturned(\n            try database.getValue(on: TestObject.Properties.variable2, fromTable: TestObject.name)\n        )\n        // Then\n        XCTAssertNotNil(result)\n        XCTAssertEqual(result!.stringValue, preInsertedObjects[0].variable2)\n    }\n\n    func testSelectOne() {\n        let result: TestObject? = WCDBAssertNoThrowReturned(\n            try database.getObject(fromTable: TestObject.name)\n        )\n        XCTAssertNotNil(result)\n        XCTAssertEqual(result!, preInsertedObjects[0])\n    }\n\n    func testTableRowSelect() {\n        // When\n        let results: MultiRowsValue = WCDBAssertNoThrowReturned(try table.getRows())\n        // Then\n        XCTAssertEqual(results.count, preInsertedObjects.count)\n        XCTAssertEqual(Int(results[row: 0, column: 0].int64Value), preInsertedObjects[0].variable1)\n        XCTAssertEqual(results[row: 0, column: 1].stringValue, preInsertedObjects[0].variable2)\n        XCTAssertEqual(Int(results[row: 1, column: 0].int64Value), preInsertedObjects[1].variable1)\n        XCTAssertEqual(results[row: 1, column: 1].stringValue, preInsertedObjects[1].variable2)\n    }\n\n    func testTableRowSelectOne() {\n        // When\n        let results: OneRowValue = WCDBAssertNoThrowReturned(\n            try table.getRow()\n        )\n        // Then\n        XCTAssertEqual(results.count, 2)\n        XCTAssertEqual(Int(results[0].int64Value), preInsertedObjects[0].variable1)\n        XCTAssertEqual(results[1].stringValue, preInsertedObjects[0].variable2)\n    }\n\n    func testTableRowSelectColumn() {\n        // When\n        let results: OneColumnValue = WCDBAssertNoThrowReturned(\n            try table.getColumn(on: TestObject.Properties.variable1)\n        )\n        // Then\n        XCTAssertEqual(Int(results[0].int64Value), preInsertedObjects[0].variable1)\n        XCTAssertEqual(Int(results[1].int64Value), preInsertedObjects[1].variable1)\n    }\n\n    func testTableConditionalRowSelectColumn() {\n        // When\n        let results: OneColumnValue = WCDBAssertNoThrowReturned(\n            try table.getColumn(on: TestObject.Properties.variable1, where: TestObject.Properties.variable1 == 1)\n        )\n        // Then\n        XCTAssertEqual(results.count, 1)\n        XCTAssertEqual(Int(results[0].int64Value), preInsertedObjects[0].variable1)\n    }\n\n    func testTableOrderedRowSelectColumn() {\n        // Give\n        let order = [TestObject.Properties.variable1.order(.descending)]\n        // When\n        let results: OneColumnValue = WCDBAssertNoThrowReturned(\n            try table.getColumn(on: TestObject.Properties.variable1, orderBy: order)\n        )\n        // Then\n        XCTAssertEqual(results.count, preInsertedObjects.count)\n        XCTAssertEqual(Int(results[0].int64Value), preInsertedObjects[1].variable1)\n        XCTAssertEqual(Int(results[1].int64Value), preInsertedObjects[0].variable1)\n    }\n\n    func testTableLimitedRowSelectColumn() {\n        // When\n        let results: OneColumnValue = WCDBAssertNoThrowReturned(\n            try table.getColumn(on: TestObject.Properties.variable1, limit: 1)\n        )\n        // Then\n        XCTAssertEqual(results.count, 1)\n        XCTAssertEqual(Int(results[0].int64Value), preInsertedObjects[0].variable1)\n    }\n\n    func testTableOffsetRowSelectColumn() {\n        // When\n        let results: OneColumnValue = WCDBAssertNoThrowReturned(\n            try table.getColumn(on: TestObject.Properties.variable1, limit: 1, offset: 1)\n        )\n        // Then\n        XCTAssertEqual(results.count, 1)\n        XCTAssertEqual(Int(results[0].int64Value), preInsertedObjects[1].variable1)\n    }\n\n    func testTableRowSelectDistinctColumn() {\n        let object1 = TestObject()\n        object1.variable1 = 3\n        object1.variable2 = \"object1\"\n        XCTAssertNoThrow(try database.insert(object1, intoTable: TestObject.name))\n        // When\n        let results: OneColumnValue = WCDBAssertNoThrowReturned(\n            try table.getDistinctColumn(on: TestObject.Properties.variable2)\n        )\n        // Then\n        XCTAssertEqual(results[0].stringValue, preInsertedObjects[0].variable2)\n        XCTAssertEqual(results[1].stringValue, preInsertedObjects[1].variable2)\n    }\n\n    func testTableConditionalRowSelectDistinctColumn() {\n        let object1 = TestObject()\n        object1.variable1 = 3\n        object1.variable2 = \"object1\"\n        XCTAssertNoThrow(try database.insert(object1, intoTable: TestObject.name))\n        // When\n        let results: OneColumnValue = WCDBAssertNoThrowReturned(\n            try table.getDistinctColumn(on: TestObject.Properties.variable2,\n                                         where: TestObject.Properties.variable1 == 1)\n        )\n        // Then\n        XCTAssertEqual(results.count, 1)\n        XCTAssertEqual(results[0].stringValue, preInsertedObjects[0].variable2)\n    }\n\n    func testTableOrderedRowSelectDistinctColumn() {\n        let object1 = TestObject()\n        object1.variable1 = 3\n        object1.variable2 = \"object1\"\n        XCTAssertNoThrow(try database.insert(object1, intoTable: TestObject.name))\n        // Give\n        let order = [TestObject.Properties.variable2.order(.descending)]\n        // When\n        let results: OneColumnValue = WCDBAssertNoThrowReturned(\n            try table.getDistinctColumn(on: TestObject.Properties.variable2, orderBy: order)\n        )\n        // Then\n        XCTAssertEqual(results.count, preInsertedObjects.count)\n        XCTAssertEqual(results[0].stringValue, preInsertedObjects[1].variable2)\n        XCTAssertEqual(results[1].stringValue, preInsertedObjects[0].variable2)\n    }\n\n    func testTableLimitedRowSelectDistinctColumn() {\n        let object1 = TestObject()\n        object1.variable1 = 3\n        object1.variable2 = \"object1\"\n        XCTAssertNoThrow(try database.insert(object1, intoTable: TestObject.name))\n        // When\n        let results: OneColumnValue = WCDBAssertNoThrowReturned(\n            try table.getDistinctColumn(on: TestObject.Properties.variable2, limit: 1)\n        )\n        // Then\n        XCTAssertEqual(results.count, 1)\n        XCTAssertEqual(results[0].stringValue, preInsertedObjects[0].variable2)\n    }\n\n    func testTableOffsetRowSelectDistinctColumn() {\n        let object1 = TestObject()\n        object1.variable1 = 3\n        object1.variable2 = \"object1\"\n        XCTAssertNoThrow(try database.insert(object1, intoTable: TestObject.name))\n        // When\n        let results: OneColumnValue = WCDBAssertNoThrowReturned(\n            try table.getDistinctColumn(on: TestObject.Properties.variable2, limit: 1, offset: 1)\n        )\n        // Then\n        XCTAssertEqual(results.count, 1)\n        XCTAssertEqual(results[0].stringValue, preInsertedObjects[1].variable2)\n    }\n\n    func testTableRowSelectValue() {\n        // When\n        let result: Value? = WCDBAssertNoThrowReturned(\n            try table.getValue(on: TestObject.Properties.variable2)\n        )\n        // Then\n        XCTAssertNotNil(result)\n        XCTAssertEqual(result!.stringValue, preInsertedObjects[0].variable2)\n    }\n\n    func testTableSelectOne() {\n        // When\n        let result: TestObject? = WCDBAssertNoThrowReturned(\n            try table.getObject()\n        )\n        // Then\n        XCTAssertNotNil(result)\n        XCTAssertEqual(result!, preInsertedObjects[0])\n    }\n\n    func testSelectEmpty() {\n        let tableName = TestObject.name\n        // Give\n        XCTAssertNoThrow(try database.delete(fromTable: tableName))\n        // Then\n        do {\n            let row = try database.getRow(on: Column.all(), fromTable: tableName)\n            XCTAssertEqual(row.count, 0)\n\n            let distinctValue = try database.getDistinctValue(on: Column.all(), fromTable: tableName)\n            XCTAssertEqual(distinctValue.type, .null)\n\n            let value = try database.getValue(on: Column.all(), fromTable: tableName)\n            XCTAssertEqual(value.type, .null)\n        } catch let error {\n            XCTFail(error.localizedDescription)\n        }\n    }\n\n    func testTableSelectEmpty() {\n        // Give\n        XCTAssertNoThrow(try database.delete(fromTable: TestObject.name))\n        let table: Table<TestObject> =  database.getTable(named: TestObject.name)\n        // Then\n        do {\n            let row = try table.getRow(on: Column.all())\n            XCTAssertEqual(row.count, 0)\n\n            let distinctValue = try table.getDistinctValue(on: Column.all())\n            XCTAssertEqual(distinctValue.type, .null)\n\n            let value = try table.getValue(on: Column.all())\n            XCTAssertEqual(value.type, .null)\n        } catch let error {\n            XCTFail(error.localizedDescription)\n        }\n    }\n\n    func testSelectValue() {\n        let value: Value? = WCDBAssertNoThrowReturned(\n            try database.getValue(from: StatementSelect().select(TestObject.Properties.variable1.max()).from(TestObject.name))\n        )\n        XCTAssertNotNil(value)\n        XCTAssertEqual(value!.int64Value, Int64(preInsertedObjects[1].variable1!))\n    }\n\n    func testSelectOneColumn() {\n        let column: OneColumnValue = WCDBAssertNoThrowReturned(\n            try database.getColumn(from: StatementSelect().select(TestObject.Properties.variable1).from(TestObject.name))\n        )\n        XCTAssertEqual(column.count, preInsertedObjects.count)\n        XCTAssertEqual(column[0].int64Value, Int64(preInsertedObjects[0].variable1!))\n        XCTAssertEqual(column[1].int64Value, Int64(preInsertedObjects[1].variable1!))\n    }\n\n    func testSelectOneRow() {\n        let row: OneRowValue? = WCDBAssertNoThrowReturned(\n            try database.getRow(from: StatementSelect().select(TestObject.Properties.all).from(TestObject.name).limit(1))\n        )\n        XCTAssertNotNil(row)\n        XCTAssertEqual(row!.count, TestObject.Properties.all.count)\n        XCTAssertEqual(row![0].int64Value, Int64(preInsertedObjects[0].variable1!))\n        XCTAssertEqual(row![1].stringValue, preInsertedObjects[0].variable2!)\n    }\n\n    func testSelectMultiRows() {\n        let rows: MultiRowsValue = WCDBAssertNoThrowReturned(\n            try database.getRows(from: StatementSelect().select(TestObject.Properties.all).from(TestObject.name))\n        )\n        XCTAssertEqual(rows.count, preInsertedObjects.count)\n        XCTAssertEqual(rows[0][0].int64Value, Int64(preInsertedObjects[0].variable1!))\n        XCTAssertEqual(rows[1][1].stringValue, preInsertedObjects[1].variable2)\n    }\n}\n"
  },
  {
    "path": "src/swift/tests/crud/SelectTests.swift",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport XCTest\n#if TEST_WCDB_SWIFT\nimport WCDBSwift\n#else\nimport WCDB\n#endif\n\nclass SelectTests: CRUDTestCase {\n\n    var select: Select!\n\n    override func setUp() {\n        super.setUp()\n\n        select = WCDBAssertNoThrowReturned(try database.prepareSelect(of: TestObject.self, fromTable: TestObject.name))\n    }\n\n    func testSelect() {\n        let results: [TestObject] = WCDBAssertNoThrowReturned(try select.allObjects(), whenFailed: [TestObject]())\n        XCTAssertEqual(results.sorted(), preInsertedObjects.sorted())\n    }\n\n    func testTableSelect() {\n        select = WCDBAssertNoThrowReturned(try table.prepareSelect(of: TestObject.self))\n        let results: [TestObject] = WCDBAssertNoThrowReturned(try select.allObjects(), whenFailed: [TestObject]())\n        XCTAssertEqual(results.sorted(), preInsertedObjects.sorted())\n    }\n\n    func testConditionalSelect() {\n        let results: [TestObject] = WCDBAssertNoThrowReturned(\n            try select.where(TestObject.Properties.variable1 == 2).allObjects(),\n            whenFailed: [TestObject]()\n        )\n        XCTAssertEqual(results.count, 1)\n        XCTAssertEqual(results[0].variable2, \"object2\")\n    }\n\n    func testOrderedSelect() {\n        let order = TestObject.Properties.variable2.order(.descending)\n        let results: [TestObject] = WCDBAssertNoThrowReturned(\n            try select.order(by: order).allObjects(),\n            whenFailed: [TestObject]()\n        )\n        XCTAssertEqual(results, preInsertedObjects.reversed())\n    }\n\n    func testLimitedSelect() {\n        let results: [TestObject] = WCDBAssertNoThrowReturned(\n            try select.limit(1).allObjects(),\n            whenFailed: [TestObject]()\n        )\n        XCTAssertEqual(results.count, 1)\n        XCTAssertEqual(results[0], preInsertedObjects[0])\n    }\n\n    func testOffsetSelect() {\n        let results: [TestObject] = WCDBAssertNoThrowReturned(\n            try select.limit(from: 1, to: 1).allObjects(),\n            whenFailed: [TestObject]()\n        )\n        XCTAssertEqual(results.count, 1)\n        XCTAssertEqual(results[0], preInsertedObjects[1])\n    }\n\n    func testPartialSelect() {\n        let select = WCDBAssertNoThrowReturned(try database.prepareSelect(on: TestObject.Properties.variable2.asProperty(), fromTable: TestObject.name))!\n        let results: [TestObject] = WCDBAssertNoThrowReturned(\n            try select.allObjects(),\n            whenFailed: [TestObject]()\n        )\n        XCTAssertEqual(results.map({ (object) -> String in\n            XCTAssertNil(object.variable1)\n            XCTAssertNotNil(object.variable2)\n            return object.variable2!\n        }), preInsertedObjects.map({\n            XCTAssertNotNil($0.variable2)\n            return $0.variable2!\n        }))\n    }\n\n    func testTablePartialSelect() {\n        let select = WCDBAssertNoThrowReturned(try table.prepareSelect(on: TestObject.Properties.variable2.asProperty()))!\n        let results: [TestObject] = WCDBAssertNoThrowReturned(\n            try select.allObjects(),\n            whenFailed: [TestObject]()\n        )\n        XCTAssertEqual(results.map({ (object) -> String in\n            XCTAssertNil(object.variable1)\n            XCTAssertNotNil(object.variable2)\n            return object.variable2!\n        }), preInsertedObjects.map({\n            XCTAssertNotNil($0.variable2)\n            return $0.variable2!\n        }))\n    }\n\n    func testSelectIteration() {\n        var results: [TestObject] = []\n        while let result: TestObject = WCDBAssertNoThrowReturned(try select.nextObject()) {\n            results.append(result)\n        }\n        XCTAssertEqual(results.sorted(), preInsertedObjects.sorted())\n    }\n\n    func testUnspecificSelect() {\n        let results = WCDBAssertNoThrowReturned(try select.allObjects(), whenFailed: [Any]())\n        let objects = results as? [TestObject]\n        XCTAssertNotNil(objects)\n        XCTAssertEqual(objects!.sorted(), preInsertedObjects.sorted())\n    }\n\n    func testUnspecificSelectIteration() {\n        var results: [TestObject] = []\n        while let result = WCDBAssertNoThrowReturned(try select.nextObject()) {\n            let crudObject = result as? TestObject\n            XCTAssertNotNil(crudObject)\n            results.append(crudObject!)\n        }\n        XCTAssertEqual(results.sorted(), preInsertedObjects.sorted())\n    }\n\n    final class WrongObject: TableCodable {\n        var variable1: Int? = 0\n        var variable2: String? = \"\"\n        enum CodingKeys: String, CodingTableKey {\n            typealias Root = WrongObject\n            case variable1\n            case variable2\n            nonisolated(unsafe) static let objectRelationalMapping = TableBinding(CodingKeys.self)\n        }\n    }\n\n    func testSelectFailed() {\n        let select = WCDBAssertNoThrowReturned(try database.prepareSelect(on: TestObject.Properties.variable2.asProperty(), fromTable: \"nonexistentTable\"))!\n        XCTAssertThrowsError(try select.nextObject())\n    }\n}\n"
  },
  {
    "path": "src/swift/tests/crud/TableTests.swift",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport XCTest\n#if TEST_WCDB_SWIFT\nimport WCDBSwift\n#else\nimport WCDB\n#endif\n\nclass TableTests: DatabaseTestCase {\n\n    final class BaselineObject: TableCodable, Named {\n        var anInt32: Int32 = -1\n        var anInt64: Int64 = 17626545782784\n        var aString: String = \"string\"\n        var aData: Data = \"data\".data(using: .ascii)!\n        var aDouble: Double = 0.001\n\n        enum CodingKeys: String, CodingTableKey {\n            typealias Root = BaselineObject\n            case anInt32\n            case anInt64\n            case aString\n            case aData\n            case aDouble\n            nonisolated(unsafe) static let objectRelationalMapping = TableBinding(CodingKeys.self) {\n                BindColumnConstraint(anInt32, isPrimary: true, orderBy: .ascending, isAutoIncrement: true)\n            }\n        }\n\n        var isAutoIncrement: Bool = false\n        var lastInsertedRowID: Int64 = 0\n    }\n    func testCreateTable() {\n        // Give\n        let tableName = BaselineObject.name\n        var expected = Master()\n        expected.sql = \"\"\"\n        CREATE TABLE \\(tableName)\\\n        (anInt32 INTEGER PRIMARY KEY ASC AUTOINCREMENT, \\\n        anInt64 INTEGER, \\\n        aString TEXT, \\\n        aData BLOB, \\\n        aDouble REAL)\n        \"\"\"\n        // When\n        XCTAssertNoThrow(try database.create(table: tableName, of: BaselineObject.self))\n        // Then\n        let optionalObject: Master? = WCDBAssertNoThrowReturned(\n            try database.getObject(fromTable: Master.builtinTableName, where: Master.Properties.name==tableName)\n        )\n        XCTAssertNotNil(optionalObject)\n        let object = optionalObject!\n        XCTAssertEqual(\n            object.sql!,\n            expected.sql\n        )\n    }\n\n    final class SkipColumnObject: TableCodable, Named {\n        var anInt32: Int32 = -1\n\n        enum CodingKeys: String, CodingTableKey {\n            typealias Root = SkipColumnObject\n            case anInt32\n            nonisolated(unsafe) static let objectRelationalMapping = TableBinding(CodingKeys.self) {\n                BindColumnConstraint(anInt32, isPrimary: true, orderBy: .ascending, isAutoIncrement: true)\n            }\n        }\n\n        var isAutoIncrement: Bool = false\n        var lastInsertedRowID: Int64 = 0\n    }\n\n    func testCreateTableSkipColumns() {\n        // Give\n        let tableName = BaselineObject.name\n        XCTAssertNoThrow(try database.create(table: tableName, of: BaselineObject.self))\n        // Then\n        XCTAssertNoThrow(try database.create(table: tableName, of: SkipColumnObject.self))\n    }\n\n    final class IndexObject: TableCodable, Named {\n        var variable: Int32 = 0\n        enum CodingKeys: String, CodingTableKey {\n            typealias Root = IndexObject\n            case variable\n            nonisolated(unsafe) static let objectRelationalMapping = TableBinding(CodingKeys.self) {\n                BindIndex(variable, namedWith: \"_index\")\n            }\n        }\n    }\n    func testCreateTableWithIndex() {\n        // Give\n        let tableName = IndexObject.name\n        let indexName = tableName+\"_index\"\n        // When\n        XCTAssertNoThrow(try database.create(table: tableName, of: IndexObject.self))\n        // Then\n        let optionalObject: Master? = WCDBAssertNoThrowReturned(\n            try database.getObject(fromTable: Master.builtinTableName, where: Master.Properties.name==indexName)\n        )\n        XCTAssertNotNil(optionalObject)\n        let object = optionalObject!\n        XCTAssertEqual(object.sql!, \"CREATE INDEX \\(indexName) ON IndexObject(variable)\")\n    }\n\n    final class ConstraintObject: TableCodable, Named {\n        var variable1: Int32 = 0\n        var variable2: Int32 = 0\n\n        enum CodingKeys: String, CodingTableKey {\n            typealias Root = ConstraintObject\n            case variable1\n            case variable2\n            nonisolated(unsafe) static let objectRelationalMapping = TableBinding(CodingKeys.self) {\n                BindMultiUnique(variable1, variable2)\n            }\n        }\n    }\n    func testCreateTableWithConstraint() {\n        // Give\n        let tableName = ConstraintObject.name\n        // When\n        XCTAssertNoThrow(try database.create(table: tableName, of: ConstraintObject.self))\n        // Then\n        let optionalObject: Master? = WCDBAssertNoThrowReturned(\n            try database.getObject(fromTable: Master.builtinTableName, where: Master.Properties.name==tableName)\n        )\n        XCTAssertNotNil(optionalObject)\n        let object = optionalObject!\n        XCTAssertEqual(\n            object.sql!,\n            \"\"\"\n            CREATE TABLE \\(tableName)\\\n            (variable1 INTEGER, variable2 INTEGER, \\\n            UNIQUE(variable1, variable2))\n            \"\"\")\n    }\n\n    final class FTS3Object: TableCodable, Named {\n        var id: Int32 = 0\n        var content: String = \"\"\n\n        enum CodingKeys: String, CodingTableKey {\n            typealias Root = FTS3Object\n            case id\n            case content\n            nonisolated(unsafe) static let objectRelationalMapping = TableBinding(CodingKeys.self) {\n                BindColumnConstraint(id, isNotIndexed: true)\n                BindVirtualTable(withModule: .FTS3, and: BuiltinTokenizer.OneOrBinary, BuiltinTokenizer.Parameter.NeedSymbol)\n            }\n        }\n    }\n    func testCreateFTS3VirtualTable() {\n        // Give\n        let tableName = FTS3Object.name\n        database.add(tokenizer: BuiltinTokenizer.OneOrBinary)\n        // When\n        XCTAssertNoThrow(try database.create(virtualTable: tableName, of: FTS3Object.self))\n        // Then\n        let optionalObject: Master? = WCDBAssertNoThrowReturned(\n            try database.getObject(fromTable: Master.builtinTableName, where: Master.Properties.name==tableName)\n        )\n        XCTAssertNotNil(optionalObject)\n        let object = optionalObject!\n        XCTAssertEqual(\n            object.sql!,\n            \"\"\"\n            CREATE VIRTUAL TABLE FTS3Object USING fts3\\\n            (tokenize = WCDB need_symbol, id INTEGER, content TEXT, notindexed=id)\n            \"\"\"\n        )\n    }\n\n    final class FTS5Object: TableCodable, Named {\n        var id: Int32 = 0\n        var content: String = \"\"\n\n        enum CodingKeys: String, CodingTableKey {\n            typealias Root = FTS5Object\n            case id\n            case content\n            nonisolated(unsafe) static let objectRelationalMapping = TableBinding(CodingKeys.self) {\n                BindColumnConstraint(id, isNotIndexed: true)\n                BindVirtualTable(withModule: .FTS5,\n                                 and: BuiltinTokenizer.Verbatim, BuiltinTokenizer.Parameter.SkipStemming,\n                                 withExternalContent: \"contentTable\")\n            }\n        }\n    }\n    func testCreateFTS5VirtualTable() {\n        // Give\n        let tableName = FTS5Object.name\n        database.add(tokenizer: BuiltinTokenizer.Verbatim)\n        // When\n        XCTAssertNoThrow(try database.create(virtualTable: tableName, of: FTS5Object.self))\n        // Then\n        let optionalObject: Master? = WCDBAssertNoThrowReturned(\n            try database.getObject(fromTable: Master.builtinTableName, where: Master.Properties.name==tableName)\n        )\n        XCTAssertNotNil(optionalObject)\n        let object = optionalObject!\n        XCTAssertEqual(\n            object.sql!,\n            \"\"\"\n            CREATE VIRTUAL TABLE FTS5Object USING fts5\\\n            (tokenize = 'wcdb_verbatim skip_stemming', content='contentTable', id UNINDEXED, content)\n            \"\"\"\n        )\n    }\n\n    final class AutoFitBaseLineObject: TableCodable, Named {\n        var anInt32: Int32 = -1\n        var anInt64: Int64 = 17626545782784\n        var aString: String = \"string\"\n        var aData: Data = \"data\".data(using: .ascii)!\n        var aDouble: Double = 0.001\n        var newColumn: Int = 0\n\n        var isAutoIncrement: Bool = false\n        var lastInsertedRowID: Int64 = 0\n        enum CodingKeys: String, CodingTableKey {\n            typealias Root = AutoFitBaseLineObject\n            case anInt32\n            case anInt64\n            case aString\n            case aData\n            case aDouble\n            case newColumn\n            nonisolated(unsafe) static let objectRelationalMapping = TableBinding(CodingKeys.self) {\n                BindColumnConstraint(anInt32, isPrimary: true, orderBy: .ascending, isAutoIncrement: true)\n            }\n        }\n    }\n    func testCreateTableAutoFitORM() {\n        // Give\n        let tableName = AutoFitBaseLineObject.name\n        XCTAssertNoThrow(try database.create(table: tableName, of: BaselineObject.self))\n        // Then\n        XCTAssertNoThrow(try database.create(table: tableName, of: AutoFitBaseLineObject.self))\n        let optionalObject: Master? = WCDBAssertNoThrowReturned(\n            try database.getObject(fromTable: Master.builtinTableName, where: Master.Properties.name==tableName)\n        )\n        XCTAssertNotNil(optionalObject)\n        let object = optionalObject!\n        XCTAssertEqual(\n            object.sql!,\n            \"\"\"\n            CREATE TABLE \\(tableName)\\\n            (anInt32 INTEGER PRIMARY KEY ASC AUTOINCREMENT, \\\n            anInt64 INTEGER, \\\n            aString TEXT, \\\n            aData BLOB, \\\n            aDouble REAL, \\\n            newColumn INTEGER)\n            \"\"\"\n        )\n    }\n\n    func testDropTable() {\n        // Give\n        let tableName = BaselineObject.name\n        // When\n        XCTAssertNoThrow(try database.create(table: tableName, of: BaselineObject.self))\n        XCTAssertNoThrow(try database.drop(table: tableName))\n        // Then\n        let optionalObject: Master? = WCDBAssertNoThrowReturned(\n            try database.getObject(fromTable: Master.builtinTableName, where: Master.Properties.name==tableName)\n        )\n        XCTAssertNil(optionalObject)\n    }\n\n    func testDropIndex() {\n        // Give\n        let tableName = IndexObject.name\n        let indexName = tableName+\"_index\"\n        // When\n        XCTAssertNoThrow(try database.create(table: tableName, of: IndexObject.self))\n        XCTAssertNoThrow(try database.drop(index: indexName))\n        // Then\n        let optionalObject: Master? = WCDBAssertNoThrowReturned(\n            try database.getObject(fromTable: Master.builtinTableName, where: Master.Properties.name==indexName)\n        )\n        XCTAssertNil(optionalObject)\n    }\n\n    func testManuallyCreateTable() {\n        // Give\n        let tableName = BaselineObject.name\n        let tableConstraint = TableConstraint(named: \"BaselineObjectConstraint\")\n        tableConstraint.check((BaselineObject.Properties.anInt32)>0)\n        let def1 = (BaselineObject.Properties.anInt32).asDef(with: .integer32)\n        let def2 = (BaselineObject.Properties.anInt64).asDef(with: .integer64)\n        // When\n        XCTAssertNoThrow(try database.create(table: tableName, with: def1, def2, and: [tableConstraint]))\n        let optionalObject: Master? = WCDBAssertNoThrowReturned(\n            try database.getObject(fromTable: Master.builtinTableName, where: Master.Properties.name==tableName)\n        )\n        XCTAssertNotNil(optionalObject)\n        let object = optionalObject!\n        XCTAssertEqual(\n            object.sql!,\n            \"\"\"\n            CREATE TABLE \\(tableName)\\\n            (anInt32 INTEGER, anInt64 INTEGER, \\\n            CONSTRAINT BaselineObjectConstraint CHECK(anInt32 > 0))\n            \"\"\"\n        )\n    }\n\n    func testManuallyAddColumn() {\n        // Give\n        let tableName = BaselineObject.name\n        let def = Column(named: \"newColumn\").asDef(with: .integer32)\n        // When\n        XCTAssertNoThrow(try database.create(table: tableName, of: BaselineObject.self))\n        XCTAssertNoThrow(try database.addColumn(with: def, forTable: tableName))\n        // Then\n        let optionalObject: Master? = WCDBAssertNoThrowReturned(\n            try database.getObject(fromTable: Master.builtinTableName, where: Master.Properties.name==tableName)\n        )\n        XCTAssertNotNil(optionalObject)\n        let object = optionalObject!\n        XCTAssertEqual(\n            object.sql!,\n            \"\"\"\n            CREATE TABLE \\(tableName)\\\n            (anInt32 INTEGER PRIMARY KEY ASC AUTOINCREMENT, \\\n            anInt64 INTEGER, \\\n            aString TEXT, \\\n            aData BLOB, \\\n            aDouble REAL, \\\n            newColumn INTEGER)\n            \"\"\"\n        )\n    }\n\n    func testManuallyCreateIndex() {\n        // Give\n        let tableName = BaselineObject.name\n        let indexName = tableName+\"_index\"\n        let index1 = (BaselineObject.Properties.aString).asIndex()\n        let index2 = (BaselineObject.Properties.aDouble).asIndex()\n        // When\n        XCTAssertNoThrow(try database.create(table: tableName, of: BaselineObject.self))\n        XCTAssertNoThrow(try database.create(index: indexName, with: index1, index2, forTable: tableName))\n        // Then\n        let optionalObject: Master? = WCDBAssertNoThrowReturned(\n            try database.getObject(fromTable: Master.builtinTableName, where: Master.Properties.name==indexName)\n        )\n        XCTAssertNotNil(optionalObject)\n        let object = optionalObject!\n        XCTAssertEqual(object.sql!, \"CREATE INDEX \\(indexName) ON \\(tableName)(aString, aDouble)\")\n    }\n}\n"
  },
  {
    "path": "src/swift/tests/crud/TypedTests.swift",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport XCTest\n#if TEST_WCDB_SWIFT\nimport WCDBSwift\n#else\nimport WCDB\n#endif\n\nclass TypedTests: CRUDTestCase {\n\n    class TypedJSONCodableObject: ColumnJSONCodable, Equatable, CustomDebugStringConvertible {\n        static func == (lhs: TypedJSONCodableObject, rhs: TypedJSONCodableObject) -> Bool {\n            return lhs.variable == rhs.variable\n        }\n\n        var variable: Int = 1\n\n        var debugDescription: String {\n            return \"\\(variable)\"\n        }\n    }\n\n    enum TypedCodableObject: Int, ColumnCodable, Equatable, CustomDebugStringConvertible {\n        case variable = 0\n\n        static var columnType: ColumnType {\n            return .integer64\n        }\n\n        func archivedValue() -> Value {\n            return Value(Int64(self.rawValue))\n        }\n\n        init?(with value: Value) {\n            guard let object = TypedCodableObject(rawValue: Int(truncatingIfNeeded: value.int64Value)) else {\n                return nil\n            }\n            self = object\n        }\n\n        var debugDescription: String {\n            return \"\\(self.rawValue)\"\n        }\n    }\n\n    final class TypedTestObject: TableCodable, Named, Equatable, CustomDebugStringConvertible {\n        var int: Int = 0\n        var int8: Int8 = 0\n        var int16: Int16 = 0\n        var int32: Int32 = 0\n        var int64: Int64 = 0\n        var uint: UInt = 0\n        var uint8: UInt8 = 0\n        var uint16: UInt16 = 0\n        var uint32: UInt32 = 0\n        var uint64: UInt64 = 0\n        var string: String = \"\"\n        var float: Float = 0\n        var double: Double = 0\n        var data: Data = Data()\n        var jsonCodable: TypedJSONCodableObject = TypedJSONCodableObject()\n        var codable: TypedCodableObject = TypedCodableObject.variable\n        var bool: Bool = false\n        var date: Date = Date()\n        var array: [Int] = []\n        var dictionary: [Int: String] = [:]\n        var set: Set<String> = []\n        enum CodingKeys: String, CodingTableKey {\n            typealias Root = TypedTestObject\n            case int\n            case int8\n            case int16\n            case int32\n            case int64\n            case uint\n            case uint8\n            case uint16\n            case uint32\n            case uint64\n            case string\n            case float\n            case double\n            case data\n            case jsonCodable\n            case codable\n            case bool\n            case date\n            case array\n            case dictionary\n            case set = \"db_set\"\n            nonisolated(unsafe) static let objectRelationalMapping = TableBinding(CodingKeys.self)\n        }\n\n        enum TestType {\n            case upperBoundary\n            case lowerBoundary\n        }\n\n        init(with testType: TestType) {\n            switch testType {\n            case .upperBoundary:\n                int = Int.max\n                int8 = Int8.max\n                int16 = Int16.max\n                int32 = Int32.max\n                int64 = Int64.max\n                uint = UInt.max\n                uint8 = UInt8.max\n                uint16 = UInt16.max\n                uint32 = UInt32.max\n                uint64 = UInt64.max\n                string = String(Array(repeating: \"0\", count: 1000))\n                float = 0.123456789123456789123456789123456789123456789\n                double = Double.pi\n                data = string.data(using: .ascii)!\n                jsonCodable = {\n                    let object = TypedJSONCodableObject()\n                    object.variable = Int.max\n                    return object\n                }()\n                codable = .variable\n                bool = true\n                date = Date.distantFuture\n                for i in 0..<10000 {\n                    array.append(i)\n                    dictionary[i] = \"\\(i)\"\n                    set.insert(\"\\(i)\")\n                }\n            case .lowerBoundary:\n                int = Int.min\n                int8 = Int8.min\n                int16 = Int16.min\n                int32 = Int32.min\n                int64 = Int64.min\n                uint = UInt.min\n                uint8 = UInt8.min\n                uint16 = UInt16.min\n                uint32 = UInt32.min\n                uint64 = UInt64.min\n                string = \"\"\n                float = 0\n                double = 0\n                data = Data()\n                jsonCodable = {\n                    let object = TypedJSONCodableObject()\n                    object.variable = Int.min\n                    return object\n                }()\n                codable = .variable\n                bool = false\n                date = Date.distantPast\n                array.removeAll()\n                dictionary.removeAll()\n                set.removeAll()\n            }\n        }\n\n        static func == (lhs: TypedTestObject, rhs: TypedTestObject) -> Bool {\n            var result = lhs.int == rhs.int\n            result = result && lhs.int8 == rhs.int8\n            result = result && lhs.int16 == rhs.int16\n            result = result && lhs.int32 == rhs.int32\n            result = result && lhs.int64 == rhs.int64\n            result = result && lhs.uint == rhs.uint\n            result = result && lhs.uint8 == rhs.uint8\n            result = result && lhs.uint16 == rhs.uint16\n            result = result && lhs.uint32 == rhs.uint32\n            result = result && lhs.uint64 == rhs.uint64\n            result = result && lhs.string == rhs.string\n            result = result && lhs.data == rhs.data\n            result = result && lhs.float == rhs.float\n            result = result && lhs.double == rhs.double\n            result = result && lhs.jsonCodable == rhs.jsonCodable\n            result = result && lhs.codable == rhs.codable\n            result = result && lhs.bool == rhs.bool\n            result = result && lhs.date == rhs.date\n            result = result && lhs.array == rhs.array\n            result = result && lhs.dictionary == rhs.dictionary\n            result = result && lhs.set == rhs.set\n            return result\n        }\n        var debugDescription: String {\n            return \"\"\"\n            int: \\(int)\n            int8: \\(int8)\n            int16: \\(int16)\n            int32: \\(int32)\n            int64: \\(int64)\n            uint: \\(uint)\n            uint8: \\(uint8)\n            uint16: \\(uint16)\n            uint32: \\(uint32)\n            uint64: \\(uint64)\n            float: \\(float)\n            double: \\(double)\n            string: \\(string)\n            data: \\(String(describing: data))\n            jsonCodable: \\(String(describing: jsonCodable))\n            codable: \\(String(describing: codable))\n            bool: \\(String(describing: bool))\n            date: \\(String(describing: date))\n            array: \\(String(describing: array))\n            dictionary: \\(String(describing: dictionary))\n            set: \\(String(describing: set))\n            \"\"\"\n        }\n    }\n\n    func testUpperBoundary() {\n        // Give\n        XCTAssertNoThrow(try database.create(table: TypedTestObject.name, of: TypedTestObject.self))\n        let object = TypedTestObject(with: .upperBoundary)\n        XCTAssertNoThrow(try database.insert(object, intoTable: TypedTestObject.name))\n        // When\n        let selected: TypedTestObject? = WCDBAssertNoThrowReturned(\n            try database.getObject(fromTable: TypedTestObject.name)\n        )\n        // Then\n        XCTAssertNotNil(selected)\n        XCTAssertEqual(selected!, object)\n    }\n\n    func testLowerBoundary() {\n        // Give\n        XCTAssertNoThrow(try database.create(table: TypedTestObject.name, of: TypedTestObject.self))\n        let object = TypedTestObject(with: .lowerBoundary)\n        XCTAssertNoThrow(try database.insert(object, intoTable: TypedTestObject.name))\n        // When\n        let selected: TypedTestObject? = WCDBAssertNoThrowReturned(\n            try database.getObject(fromTable: TypedTestObject.name)\n        )\n        // Then\n        XCTAssertNotNil(selected)\n        XCTAssertEqual(selected!, object)\n    }\n\n    final class TypedNonOverflowTestObject: TableCodable, Named, Equatable, CustomDebugStringConvertible {\n        var int: Int = 0\n        var int8: Int8 = 0\n        var int16: Int16 = 0\n        var int32: Int32 = 0\n        var int64: Int64 = 0\n        var uint: UInt = 0\n        var uint8: UInt8 = 0\n        var uint16: UInt16 = 0\n        var uint32: UInt32 = 0\n        var uint64: UInt64 = 0\n        var string: String? = \"\"\n        var float: Float = 0\n        var double: Double = 0\n        var data: Data? = Data()\n        var jsonCodable: TypedJSONCodableObject? = TypedJSONCodableObject()\n        var codable: TypedCodableObject? = TypedCodableObject.variable\n        var bool: Bool? = false\n        enum CodingKeys: String, CodingTableKey {\n            typealias Root = TypedNonOverflowTestObject\n            case int\n            case int8\n            case int16\n            case int32\n            case int64\n            case uint\n            case uint8\n            case uint16\n            case uint32\n            case uint64\n            case string\n            case float\n            case double\n            case data\n            case jsonCodable\n            case codable\n            case bool\n            nonisolated(unsafe) static let objectRelationalMapping = TableBinding(CodingKeys.self)\n        }\n\n        enum TestType {\n            case upperBoundary\n            case lowerBoundary\n        }\n\n        static func == (lhs: TypedNonOverflowTestObject, rhs: TypedNonOverflowTestObject) -> Bool {\n            var result = lhs.int == rhs.int\n            result = result && lhs.int8 == rhs.int8\n            result = result && lhs.int16 == rhs.int16\n            result = result && lhs.int32 == rhs.int32\n            result = result && lhs.int64 == rhs.int64\n            result = result && lhs.uint == rhs.uint\n            result = result && lhs.uint8 == rhs.uint8\n            result = result && lhs.uint16 == rhs.uint16\n            result = result && lhs.uint32 == rhs.uint32\n            result = result && lhs.uint64 == rhs.uint64\n            result = result && lhs.string == rhs.string\n            result = result && lhs.data == rhs.data\n            result = result && lhs.float == rhs.float\n            result = result && lhs.double == rhs.double\n            result = result && lhs.jsonCodable == rhs.jsonCodable\n            result = result && lhs.codable == rhs.codable\n            result = result && lhs.bool == rhs.bool\n            return result\n        }\n        var debugDescription: String {\n            return \"\"\"\n            int: \\(int)\n            int8: \\(int8)\n            int16: \\(int16)\n            int32: \\(int32)\n            int64: \\(int64)\n            uint: \\(uint)\n            uint8: \\(uint8)\n            uint16: \\(uint16)\n            uint32: \\(uint32)\n            uint64: \\(uint64)\n            float: \\(float)\n            double: \\(double)\n            string: \\(string ?? \"\")\n            data: \\(String(describing: data))\n            jsonCodable: \\(String(describing: jsonCodable))\n            codable: \\(String(describing: codable))\n            bool: \\(String(describing: bool))\n            \"\"\"\n        }\n    }\n\n    final class TypedOverflowTestObject: TableCodable, CustomDebugStringConvertible {\n        var int64Variable0: Int64 = Int64.max\n        var int64Variable1: Int64 = Int64.max\n        var int64Variable2: Int64 = Int64.max\n        var int64Variable3: Int64 = Int64.max\n        var int64Variable4: Int64 = Int64.max\n        var int64Variable5: Int64 = Int64.max\n        var int64Variable6: Int64 = Int64.max\n        var int64Variable7: Int64 = Int64.max\n        var int64Variable8: Int64 = Int64.max\n        var int64Variable9: Int64 = Int64.max\n        var doubleVariable0: Double = Double.pi\n        var doubleVariable1: Double = Double.pi\n        enum CodingKeys: String, CodingTableKey {\n            typealias Root = TypedOverflowTestObject\n            case int64Variable0 = \"int\"\n            case int64Variable1 = \"int8\"\n            case int64Variable2 = \"int16\"\n            case int64Variable3 = \"int32\"\n            case int64Variable4 = \"int64\"\n            case int64Variable5 = \"uint\"\n            case int64Variable6 = \"uint8\"\n            case int64Variable7 = \"uint16\"\n            case int64Variable8 = \"uint32\"\n            case int64Variable9 = \"uint64\"\n            case doubleVariable0 = \"float\"\n            case doubleVariable1 = \"double\"\n            nonisolated(unsafe) static let objectRelationalMapping = TableBinding(CodingKeys.self)\n        }\n\n        enum TestType {\n            case upperBoundary\n            case lowerBoundary\n        }\n\n        var debugDescription: String {\n            return \"\"\"\n            int64Variable0: \\(int64Variable0)\n            int64Variable1: \\(int64Variable1)\n            int64Variable2: \\(int64Variable2)\n            int64Variable3: \\(int64Variable3)\n            int64Variable4: \\(int64Variable4)\n            int64Variable5: \\(int64Variable5)\n            int64Variable6: \\(int64Variable6)\n            int64Variable7: \\(int64Variable7)\n            int64Variable8: \\(int64Variable8)\n            int64Variable9: \\(int64Variable9)\n            doubleVariable0: \\(doubleVariable0)\n            doubleVariable1: \\(doubleVariable1)\n            \"\"\"\n        }\n    }\n\n    func testOverflowed() {\n        // Give\n        XCTAssertNoThrow(try database.create(table: TypedNonOverflowTestObject.name,\n                                             of: TypedNonOverflowTestObject.self))\n        let overflow = TypedOverflowTestObject()\n        XCTAssertNoThrow(try database.insert(overflow, intoTable: TypedNonOverflowTestObject.name))\n        // When\n        let selected: TypedNonOverflowTestObject? = WCDBAssertNoThrowReturned(\n            try database.getObject(fromTable: TypedNonOverflowTestObject.name)\n        )\n        // Then\n        XCTAssertNotNil(selected)\n        let wrapped = selected!\n        XCTAssertEqual(wrapped.int, Int(truncatingIfNeeded: overflow.int64Variable0))\n        XCTAssertEqual(wrapped.int8, Int8(truncatingIfNeeded: overflow.int64Variable1))\n        XCTAssertEqual(wrapped.int16, Int16(truncatingIfNeeded: overflow.int64Variable2))\n        XCTAssertEqual(wrapped.int32, Int32(truncatingIfNeeded: overflow.int64Variable3))\n        XCTAssertEqual(wrapped.int64, overflow.int64Variable4)\n        XCTAssertEqual(wrapped.uint, UInt(truncatingIfNeeded: UInt64(bitPattern: overflow.int64Variable5)))\n        XCTAssertEqual(wrapped.uint8, UInt8(truncatingIfNeeded: UInt64(bitPattern: overflow.int64Variable6)))\n        XCTAssertEqual(wrapped.uint16, UInt16(truncatingIfNeeded: UInt64(bitPattern: overflow.int64Variable7)))\n        XCTAssertEqual(wrapped.uint32, UInt32(truncatingIfNeeded: UInt64(bitPattern: overflow.int64Variable8)))\n        XCTAssertEqual(wrapped.uint64, UInt64(bitPattern: overflow.int64Variable9))\n        XCTAssertEqual(wrapped.float, Float(overflow.doubleVariable0))\n        XCTAssertEqual(wrapped.double, overflow.doubleVariable1)\n    }\n\n    final class OptionalTypedTestObject: TableCodable, Named, Equatable, CustomDebugStringConvertible {\n        var int: Int?\n        var int8: Int8?\n        var int16: Int16?\n        var int32: Int32?\n        var int64: Int64?\n        var uint: UInt?\n        var uint8: UInt8?\n        var uint16: UInt16?\n        var uint32: UInt32?\n        var uint64: UInt64?\n        var string: String?\n        var float: Float?\n        var double: Double?\n        var data: Data?\n        var jsonCodable: TypedJSONCodableObject?\n        var codable: TypedCodableObject?\n        var bool: Bool?\n        enum CodingKeys: String, CodingTableKey {\n            typealias Root = OptionalTypedTestObject\n            case int\n            case int8\n            case int16\n            case int32\n            case int64\n            case uint\n            case uint8\n            case uint16\n            case uint32\n            case uint64\n            case string\n            case float\n            case double\n            case data\n            case jsonCodable\n            case codable\n            case bool\n            nonisolated(unsafe) static let objectRelationalMapping = TableBinding(CodingKeys.self)\n        }\n\n        enum TestType {\n            case null\n            case zero\n            case normal\n        }\n\n        init(with testType: TestType) {\n            switch testType {\n            case .null:\n                int = nil\n                int8 = nil\n                int16 = nil\n                int32 = nil\n                int64 = nil\n                uint = nil\n                uint8 = nil\n                uint16 = nil\n                uint32 = nil\n                uint64 = nil\n                string = nil\n                float = nil\n                double = nil\n                data = nil\n                jsonCodable = nil\n                codable = nil\n                bool = nil\n            case .zero:\n                int = 0\n                int8 = 0\n                int16 = 0\n                int32 = 0\n                int64 = 0\n                uint = 0\n                uint8 = 0\n                uint16 = 0\n                uint32 = 0\n                uint64 = 0\n                string = \"\"\n                float = 0\n                double = 0\n                data = Data()\n                jsonCodable = {\n                    let object = TypedJSONCodableObject()\n                    object.variable = 0\n                    return object\n                }()\n                codable = .variable\n                bool = false\n            case .normal:\n                int = 1\n                int8 = 2\n                int16 = 3\n                int32 = 4\n                int64 = 5\n                uint = 6\n                uint8 = 7\n                uint16 = 8\n                uint32 = 9\n                uint64 = 10\n                string = \"11\"\n                float = 12.13\n                double = 14.15\n                data = \"16\".data(using: .ascii)\n                jsonCodable = {\n                    let object = TypedJSONCodableObject()\n                    object.variable = 17\n                    return object\n                }()\n                codable = .variable\n                bool = true\n            }\n        }\n\n        static func == (lhs: OptionalTypedTestObject, rhs: OptionalTypedTestObject) -> Bool {\n            var result = lhs.int == rhs.int\n            result = result && lhs.int8 == rhs.int8\n            result = result && lhs.int16 == rhs.int16\n            result = result && lhs.int32 == rhs.int32\n            result = result && lhs.int64 == rhs.int64\n            result = result && lhs.uint == rhs.uint\n            result = result && lhs.uint8 == rhs.uint8\n            result = result && lhs.uint16 == rhs.uint16\n            result = result && lhs.uint32 == rhs.uint32\n            result = result && lhs.uint64 == rhs.uint64\n            result = result && lhs.string == rhs.string\n            result = result && lhs.data == rhs.data\n            result = result && lhs.float == rhs.float\n            result = result && lhs.double == rhs.double\n            result = result && lhs.jsonCodable == rhs.jsonCodable\n            result = result && lhs.codable == rhs.codable\n            result = result && lhs.bool == rhs.bool\n            return result\n        }\n        var debugDescription: String {\n            return \"\"\"\n            int: \\(String(describing: int))\n            int8: \\(String(describing: int8))\n            int16: \\(String(describing: int16))\n            int32: \\(String(describing: int32))\n            int64: \\(String(describing: int64))\n            uint: \\(String(describing: uint))\n            uint8: \\(String(describing: uint8))\n            uint16: \\(String(describing: uint16))\n            uint32: \\(String(describing: uint32))\n            uint64: \\(String(describing: uint64))\n            float: \\(String(describing: float))\n            double: \\(String(describing: double))\n            string: \\(String(describing: string))\n            data: \\(String(describing: data))\n            jsonCodable: \\(String(describing: jsonCodable))\n            codable: \\(String(describing: codable))\n            bool: \\(String(describing: bool))\n            \"\"\"\n        }\n    }\n\n    func testNull() {\n        // Give\n        XCTAssertNoThrow(try database.create(table: OptionalTypedTestObject.name, of: OptionalTypedTestObject.self))\n        let object = OptionalTypedTestObject(with: .null)\n        XCTAssertNoThrow(try database.insert(object, intoTable: OptionalTypedTestObject.name))\n        // When\n        let selected: OptionalTypedTestObject? = WCDBAssertNoThrowReturned(\n            try database.getObject(fromTable: OptionalTypedTestObject.name)\n        )\n        // Then\n        XCTAssertNotNil(selected)\n        XCTAssertEqual(selected!, object)\n    }\n\n    func testZero() {\n        // Give\n        XCTAssertNoThrow(try database.create(table: OptionalTypedTestObject.name, of: OptionalTypedTestObject.self))\n        let object = OptionalTypedTestObject(with: .zero)\n        XCTAssertNoThrow(try database.insert(object, intoTable: OptionalTypedTestObject.name))\n        // When\n        let selected: OptionalTypedTestObject? = WCDBAssertNoThrowReturned(\n            try database.getObject(fromTable: OptionalTypedTestObject.name)\n        )\n        // Then\n        XCTAssertNotNil(selected)\n        XCTAssertEqual(selected!, object)\n    }\n\n    func testPartialNil() {\n        // Give\n        XCTAssertNoThrow(try database.create(table: OptionalTypedTestObject.name, of: OptionalTypedTestObject.self))\n        let object = OptionalTypedTestObject(with: .normal)\n        XCTAssertNoThrow(try database.insert(object, intoTable: OptionalTypedTestObject.name))\n        let table = database.getTable(named: OptionalTypedTestObject.name, of: OptionalTypedTestObject.self)\n        // Then\n        do {\n            do {\n                let result = try table.getObject(on: OptionalTypedTestObject.Properties.int)\n                XCTAssertNotNil(object)\n                let wrappedResult = result!\n                XCTAssertEqual(wrappedResult.int, object.int)\n                XCTAssertNil(wrappedResult.int8)\n                XCTAssertNil(wrappedResult.int16)\n                XCTAssertNil(wrappedResult.int32)\n                XCTAssertNil(wrappedResult.int64)\n                XCTAssertNil(wrappedResult.uint)\n                XCTAssertNil(wrappedResult.uint8)\n                XCTAssertNil(wrappedResult.uint16)\n                XCTAssertNil(wrappedResult.uint32)\n                XCTAssertNil(wrappedResult.uint64)\n                XCTAssertNil(wrappedResult.string)\n                XCTAssertNil(wrappedResult.float)\n                XCTAssertNil(wrappedResult.double)\n                XCTAssertNil(wrappedResult.data)\n                XCTAssertNil(wrappedResult.jsonCodable)\n                XCTAssertNil(wrappedResult.codable)\n                XCTAssertNil(wrappedResult.bool)\n            }\n            do {\n                let result = try table.getObject(on: OptionalTypedTestObject.Properties.int8)\n                XCTAssertNotNil(object)\n                let wrappedResult = result!\n                XCTAssertEqual(wrappedResult.int8, object.int8)\n                XCTAssertNil(wrappedResult.int)\n                XCTAssertNil(wrappedResult.int16)\n                XCTAssertNil(wrappedResult.int32)\n                XCTAssertNil(wrappedResult.int64)\n                XCTAssertNil(wrappedResult.uint)\n                XCTAssertNil(wrappedResult.uint8)\n                XCTAssertNil(wrappedResult.uint16)\n                XCTAssertNil(wrappedResult.uint32)\n                XCTAssertNil(wrappedResult.uint64)\n                XCTAssertNil(wrappedResult.string)\n                XCTAssertNil(wrappedResult.float)\n                XCTAssertNil(wrappedResult.double)\n                XCTAssertNil(wrappedResult.data)\n                XCTAssertNil(wrappedResult.jsonCodable)\n                XCTAssertNil(wrappedResult.codable)\n                XCTAssertNil(wrappedResult.bool)\n            }\n        } catch let error {\n            XCTFail(error.localizedDescription)\n        }\n    }\n\n    func testPartialInsert() {\n        // Give\n        XCTAssertNoThrow(try database.create(table: TypedTestObject.name, of: TypedTestObject.self))\n        let object = TypedTestObject(with: .lowerBoundary)\n        XCTAssertNoThrow(try database.insert(object,\n                                             on: [TypedTestObject.Properties.int],\n                                             intoTable: TypedTestObject.name))\n        let table = database.getTable(named: TypedTestObject.name, of: OptionalTypedTestObject.self)\n        // Then\n        do {\n            do {\n                let result = try table.getObject()\n                XCTAssertNotNil(object)\n                let wrappedResult = result!\n                XCTAssertEqual(wrappedResult.int, object.int)\n                XCTAssertNil(wrappedResult.int8)\n                XCTAssertNil(wrappedResult.int16)\n                XCTAssertNil(wrappedResult.int32)\n                XCTAssertNil(wrappedResult.int64)\n                XCTAssertNil(wrappedResult.uint)\n                XCTAssertNil(wrappedResult.uint8)\n                XCTAssertNil(wrappedResult.uint16)\n                XCTAssertNil(wrappedResult.uint32)\n                XCTAssertNil(wrappedResult.uint64)\n                XCTAssertNil(wrappedResult.string)\n                XCTAssertNil(wrappedResult.float)\n                XCTAssertNil(wrappedResult.double)\n                XCTAssertNil(wrappedResult.data)\n                XCTAssertNil(wrappedResult.jsonCodable)\n                XCTAssertNil(wrappedResult.codable)\n                XCTAssertNil(wrappedResult.bool)\n            }\n        } catch let error {\n            XCTFail(error.localizedDescription)\n        }\n    }\n\n    func testPartialInsertOptional() {\n        // Give\n        XCTAssertNoThrow(try database.create(table: OptionalTypedTestObject.name, of: OptionalTypedTestObject.self))\n        let object = OptionalTypedTestObject(with: .normal)\n        XCTAssertNoThrow(try database.insert(object,\n                                             on: [OptionalTypedTestObject.Properties.int],\n                                             intoTable: OptionalTypedTestObject.name))\n        let table = database.getTable(named: OptionalTypedTestObject.name, of: OptionalTypedTestObject.self)\n        // Then\n        do {\n            do {\n                let result = try table.getObject()\n                XCTAssertNotNil(object)\n                let wrappedResult = result!\n                XCTAssertEqual(wrappedResult.int, object.int)\n                XCTAssertNil(wrappedResult.int8)\n                XCTAssertNil(wrappedResult.int16)\n                XCTAssertNil(wrappedResult.int32)\n                XCTAssertNil(wrappedResult.int64)\n                XCTAssertNil(wrappedResult.uint)\n                XCTAssertNil(wrappedResult.uint8)\n                XCTAssertNil(wrappedResult.uint16)\n                XCTAssertNil(wrappedResult.uint32)\n                XCTAssertNil(wrappedResult.uint64)\n                XCTAssertNil(wrappedResult.string)\n                XCTAssertNil(wrappedResult.float)\n                XCTAssertNil(wrappedResult.double)\n                XCTAssertNil(wrappedResult.data)\n                XCTAssertNil(wrappedResult.jsonCodable)\n                XCTAssertNil(wrappedResult.codable)\n                XCTAssertNil(wrappedResult.bool)\n            }\n        } catch let error {\n            XCTFail(error.localizedDescription)\n        }\n    }\n\n    class TypedNoMatchJSONCodableObject: ColumnJSONCodable {\n        var noMatchVariable: Int = 1\n    }\n\n    final class TypedMatchTable: TableCodable {\n        var variable1 = TypedJSONCodableObject()\n        enum CodingKeys: String, CodingTableKey {\n            typealias Root = TypedMatchTable\n            case variable1\n            nonisolated(unsafe) static let objectRelationalMapping = TableBinding(CodingKeys.self)\n        }\n    }\n\n    final class TypedNoMatchTable: TableCodable {\n        var variable1 = TypedNoMatchJSONCodableObject()\n        enum CodingKeys: String, CodingTableKey {\n            typealias Root = TypedNoMatchTable\n            case variable1\n            nonisolated(unsafe) static let objectRelationalMapping = TableBinding(CodingKeys.self)\n        }\n    }\n\n    func testNoMatchJSONCodableObject() {\n        // Give\n        let tableName = \"testNoMatchJSONCodableObject\"\n        XCTAssertNoThrow(try database.create(table: tableName, of: TypedMatchTable.self))\n\n        let typedMatchTable = TypedMatchTable()\n        typedMatchTable.variable1 = TypedJSONCodableObject()\n        typedMatchTable.variable1.variable = 1\n        XCTAssertNoThrow(try database.insert(typedMatchTable, intoTable: tableName))\n\n        var `catch` = false\n        do {\n            let _: TypedNoMatchTable? = try database.getObject(fromTable: tableName)\n            XCTFail(\"should not reach\")\n        } catch {\n            `catch` = true\n        }\n        XCTAssertTrue(`catch`)\n    }\n\n    func testEmptyJSONCodableObject() {\n        // Give\n        let tableName = \"testEmptyJSONCodableObject\"\n        XCTAssertNoThrow(try database.create(table: tableName, of: TypedMatchTable.self))\n\n        let statementInsert = StatementInsert().insert(intoTable: tableName).columns(TypedMatchTable.Properties.variable1)\n                                               .values(BindParameter(1))\n        let handle = try? database.getHandle()\n        XCTAssertNotNil(handle)\n        let wrappedHandle = handle!\n        XCTAssertNoThrow(try wrappedHandle.prepare(statementInsert))\n        wrappedHandle.bind(\"\", toIndex: 1)\n        XCTAssertNoThrow(try wrappedHandle.step())\n        XCTAssertNoThrow(wrappedHandle.finalize())\n\n        var `catch` = false\n        do {\n            let _: TypedMatchTable? = try database.getObject(fromTable: tableName)\n            XCTFail(\"should not reach\")\n        } catch {\n            `catch` = true\n        }\n        XCTAssertTrue(`catch`)\n    }\n}\n"
  },
  {
    "path": "src/swift/tests/crud/UpdateInterfaceTests.swift",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport XCTest\n#if TEST_WCDB_SWIFT\nimport WCDBSwift\n#else\nimport WCDB\n#endif\n\nclass UpdateInterfaceTests: CRUDTestCase {\n\n    func testUpdate() {\n        // Give\n        let object = TestObject()\n        object.variable2 = self.name\n        // When\n        XCTAssertNoThrow(try database.update(table: TestObject.name, on: TestObject.Properties.variable2, with: object))\n        // Then\n        let results: [TestObject] = WCDBAssertNoThrowReturned(\n            try database.getObjects(fromTable: TestObject.name),\n            whenFailed: [TestObject]()\n        )\n        XCTAssertEqual(Array(repeating: self.name, count: preInsertedObjects.count), results.map({\n            XCTAssertNotNil($0.variable2)\n            return $0.variable2!\n        }))\n    }\n\n    func testConditionalUpdate() {\n        // Give\n        let object = TestObject()\n        object.variable2 = self.name\n        // When\n        XCTAssertNoThrow(try database.update(table: TestObject.name,\n                                             on: TestObject.Properties.variable2,\n                                             with: object,\n                                             where: TestObject.Properties.variable1 == 1))\n        // Then\n        let result: TestObject? = WCDBAssertNoThrowReturned(\n            try database.getObject(fromTable: TestObject.name, where: TestObject.Properties.variable1 == 1)\n        )\n        XCTAssertNotNil(result)\n        XCTAssertEqual(self.name, result!.variable2)\n    }\n\n    func testOrderedUpdate() {\n        // Give\n        let object = TestObject()\n        object.variable2 = self.name\n        let order = [TestObject.Properties.variable1.order(.descending)]\n        // When\n        XCTAssertNoThrow(try database.update(table: TestObject.name,\n                                             on: TestObject.Properties.variable2,\n                                             with: object,\n                                             orderBy: order,\n                                             limit: 1))\n        // Then\n        let result: TestObject? = WCDBAssertNoThrowReturned(\n            try database.getObject(fromTable: TestObject.name, where: TestObject.Properties.variable1 == 2)\n        )\n        XCTAssertNotNil(result)\n        XCTAssertEqual(self.name, result!.variable2)\n    }\n\n    func testLimitedUpdate() {\n        // Give\n        let object = TestObject()\n        object.variable2 = self.name\n        // When\n        XCTAssertNoThrow(try database.update(table: TestObject.name,\n                                             on: TestObject.Properties.variable2,\n                                             with: object,\n                                             limit: 1))\n        // Then\n        let results: [TestObject] = WCDBAssertNoThrowReturned(try database.getObjects(fromTable: TestObject.name))\n        XCTAssertEqual(results[0].variable2, self.name)\n        XCTAssertEqual(results[1], preInsertedObjects[1])\n    }\n\n    func testOffsetUpdate() {\n        // Give\n        let object = TestObject()\n        object.variable2 = self.name\n        // When\n        XCTAssertNoThrow(try database.update(table: TestObject.name,\n                                             on: TestObject.Properties.variable2,\n                                             with: object,\n                                             limit: 1,\n                                             offset: 1))\n        // Then\n        let results: [TestObject] = WCDBAssertNoThrowReturned(try database.getObjects(fromTable: TestObject.name))\n        XCTAssertEqual(results[0], preInsertedObjects[0])\n        XCTAssertEqual(results[1].variable2, self.name)\n    }\n\n    func testUpdateWithRow() {\n        // Give\n        let object = TestObject()\n        object.variable2 = self.name\n        // When\n        XCTAssertNoThrow(\n            try database.update(table: TestObject.name, on: TestObject.Properties.variable2, with: self.name)\n        )\n        // Then\n        let results: [TestObject] = WCDBAssertNoThrowReturned(\n            try database.getObjects(fromTable: TestObject.name),\n            whenFailed: [TestObject]()\n        )\n        XCTAssertEqual(Array(repeating: self.name, count: preInsertedObjects.count), results.map({\n            XCTAssertNotNil($0.variable2)\n            return $0.variable2!\n        }))\n    }\n\n    func testConditionalUpdateWithRow() {\n        // Give\n        let object = TestObject()\n        object.variable2 = self.name\n        // When\n        XCTAssertNoThrow(try database.update(table: TestObject.name,\n                                             on: TestObject.Properties.variable2,\n                                             with: self.name,\n                                             where: TestObject.Properties.variable1 == 1))\n        // Then\n        let result: TestObject? = WCDBAssertNoThrowReturned(\n            try database.getObject(fromTable: TestObject.name, where: TestObject.Properties.variable1 == 1)\n        )\n        XCTAssertNotNil(result)\n        XCTAssertEqual(self.name, result!.variable2)\n    }\n\n    func testOrderedUpdateWithRow() {\n        // Give\n        let object = TestObject()\n        object.variable2 = self.name\n        let order = [TestObject.Properties.variable1.order(.descending)]\n        // When\n        XCTAssertNoThrow(try database.update(table: TestObject.name,\n                                             on: TestObject.Properties.variable2,\n                                             with: self.name,\n                                             orderBy: order,\n                                             limit: 1))\n        // Then\n        let result: TestObject? = WCDBAssertNoThrowReturned(\n            try database.getObject(fromTable: TestObject.name, where: TestObject.Properties.variable1 == 2)\n        )\n        XCTAssertNotNil(result)\n        XCTAssertEqual(self.name, result!.variable2)\n    }\n\n    func testLimitedUpdateWithRow() {\n        // Give\n        let object = TestObject()\n        object.variable2 = self.name\n        // When\n        XCTAssertNoThrow(try database.update(table: TestObject.name,\n                                             on: TestObject.Properties.variable2,\n                                             with: self.name,\n                                             limit: 1))\n        // Then\n        let results: [TestObject] = WCDBAssertNoThrowReturned(try database.getObjects(fromTable: TestObject.name))\n        XCTAssertEqual(results[0].variable2, self.name)\n        XCTAssertEqual(results[1], preInsertedObjects[1])\n    }\n\n    func testOffsetUpdateWithRow() {\n        // Give\n        let object = TestObject()\n        object.variable2 = self.name\n        // When\n        XCTAssertNoThrow(try database.update(table: TestObject.name,\n                                             on: TestObject.Properties.variable2,\n                                             with: self.name,\n                                             limit: 1,\n                                             offset: 1))\n        // Then\n        let results: [TestObject] = WCDBAssertNoThrowReturned(try database.getObjects(fromTable: TestObject.name))\n        XCTAssertEqual(results[0], preInsertedObjects[0])\n        XCTAssertEqual(results[1].variable2, self.name)\n    }\n\n    func testTableUpdate() {\n        // Give\n        let object = TestObject()\n        object.variable2 = self.name\n        // When\n        XCTAssertNoThrow(try table.update(on: TestObject.Properties.variable2, with: object))\n        // Then\n        let results: [TestObject] = WCDBAssertNoThrowReturned(try table.getObjects())\n        XCTAssertEqual(results.map({\n            XCTAssertNotNil($0.variable2)\n            return $0.variable2!\n        }), Array(repeating: self.name, count: preInsertedObjects.count))\n    }\n\n    func testTableConditionalUpdate() {\n        // Give\n        let object = TestObject()\n        object.variable2 = self.name\n        // When\n        XCTAssertNoThrow(try table.update(on: TestObject.Properties.variable2,\n                                             with: object,\n                                             where: TestObject.Properties.variable1 == 1))\n        // Then\n        let result: TestObject? = WCDBAssertNoThrowReturned(\n            try database.getObject(fromTable: TestObject.name, where: TestObject.Properties.variable1 == 1)\n        )\n        XCTAssertNotNil(result)\n        XCTAssertEqual(self.name, result!.variable2)\n    }\n\n    func testTableOrderedUpdate() {\n        // Give\n        let object = TestObject()\n        object.variable2 = self.name\n        let order = [TestObject.Properties.variable1.order(.descending)]\n        // When\n        XCTAssertNoThrow(try table.update(on: TestObject.Properties.variable2,\n                                             with: object,\n                                             orderBy: order,\n                                             limit: 1))\n        // Then\n        let result: TestObject? = WCDBAssertNoThrowReturned(\n            try database.getObject(fromTable: TestObject.name, where: TestObject.Properties.variable1 == 2)\n        )\n        XCTAssertNotNil(result)\n        XCTAssertEqual(self.name, result!.variable2)\n    }\n\n    func testTableLimitedUpdate() {\n        // Give\n        let object = TestObject()\n        object.variable2 = self.name\n        // When\n        XCTAssertNoThrow(try table.update(on: TestObject.Properties.variable2,\n                                             with: object,\n                                             limit: 1))\n        // Then\n        let results: [TestObject] = WCDBAssertNoThrowReturned(try database.getObjects(fromTable: TestObject.name))\n        XCTAssertEqual(results[0].variable2, self.name)\n        XCTAssertEqual(results[1], preInsertedObjects[1])\n    }\n\n    func testTableOffsetUpdate() {\n        // Give\n        let object = TestObject()\n        object.variable2 = self.name\n        // When\n        XCTAssertNoThrow(try table.update(on: TestObject.Properties.variable2,\n                                             with: object,\n                                             limit: 1,\n                                             offset: 1))\n        // Then\n        let results: [TestObject] = WCDBAssertNoThrowReturned(try database.getObjects(fromTable: TestObject.name))\n        XCTAssertEqual(results[0], preInsertedObjects[0])\n        XCTAssertEqual(results[1].variable2, self.name)\n    }\n\n    func testTableUpdateWithRow() {\n        // Give\n        let object = TestObject()\n        object.variable2 = self.name\n        // When\n        XCTAssertNoThrow(\n            try table.update(on: TestObject.Properties.variable2, with: self.name)\n        )\n        // Then\n        let results: [TestObject] = WCDBAssertNoThrowReturned(\n            try database.getObjects(fromTable: TestObject.name),\n            whenFailed: [TestObject]()\n        )\n        XCTAssertEqual(Array(repeating: self.name, count: preInsertedObjects.count), results.map({\n            XCTAssertNotNil($0.variable2)\n            return $0.variable2!\n        }))\n    }\n\n    func testTableConditionalUpdateWithRow() {\n        // Give\n        let object = TestObject()\n        object.variable2 = self.name\n        // When\n        XCTAssertNoThrow(try table.update(on: TestObject.Properties.variable2,\n                                             with: self.name,\n                                             where: TestObject.Properties.variable1 == 1))\n        // Then\n        let result: TestObject? = WCDBAssertNoThrowReturned(\n            try database.getObject(fromTable: TestObject.name, where: TestObject.Properties.variable1 == 1)\n        )\n        XCTAssertNotNil(result)\n        XCTAssertEqual(self.name, result!.variable2)\n    }\n\n    func testTableOrderedUpdateWithRow() {\n        // Give\n        let object = TestObject()\n        object.variable2 = self.name\n        let order = [TestObject.Properties.variable1.order(.descending)]\n        // When\n        XCTAssertNoThrow(try table.update(on: TestObject.Properties.variable2,\n                                             with: self.name,\n                                             orderBy: order,\n                                             limit: 1))\n        // Then\n        let result: TestObject? = WCDBAssertNoThrowReturned(\n            try database.getObject(fromTable: TestObject.name, where: TestObject.Properties.variable1 == 2)\n        )\n        XCTAssertNotNil(result)\n        XCTAssertEqual(self.name, result!.variable2)\n    }\n\n    func testTableLimitedUpdateWithRow() {\n        // Give\n        let object = TestObject()\n        object.variable2 = self.name\n        // When\n        XCTAssertNoThrow(try table.update(on: TestObject.Properties.variable2,\n                                             with: self.name,\n                                             limit: 1))\n        // Then\n        let results: [TestObject] = WCDBAssertNoThrowReturned(try database.getObjects(fromTable: TestObject.name))\n        XCTAssertEqual(results[0].variable2, self.name)\n        XCTAssertEqual(results[1], preInsertedObjects[1])\n    }\n\n    func testTableOffsetUpdateWithRow() {\n        // Give\n        let object = TestObject()\n        object.variable2 = self.name\n        // When\n        XCTAssertNoThrow(try table.update(on: TestObject.Properties.variable2,\n                                             with: self.name,\n                                             limit: 1,\n                                             offset: 1))\n        // Then\n        let results: [TestObject] = WCDBAssertNoThrowReturned(try database.getObjects(fromTable: TestObject.name))\n        XCTAssertEqual(results[0], preInsertedObjects[0])\n        XCTAssertEqual(results[1].variable2, self.name)\n    }\n\n}\n"
  },
  {
    "path": "src/swift/tests/crud/UpdateTests.swift",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport XCTest\n#if TEST_WCDB_SWIFT\nimport WCDBSwift\n#else\nimport WCDB\n#endif\n\nclass UpdateTests: CRUDTestCase {\n\n    var update: Update!\n\n    override func setUp() {\n        super.setUp()\n\n        let optionalUpdate = WCDBAssertNoThrowReturned(\n            try database.prepareUpdate(table: TestObject.name, on: TestObject.Properties.variable2)\n        )\n        XCTAssertNotNil(optionalUpdate)\n        update = optionalUpdate!\n    }\n\n    func testUpdate() {\n        // Give\n        let object = TestObject()\n        object.variable2 = self.name\n        // When\n        XCTAssertNoThrow(try update.execute(with: object))\n        // Then\n        let results: [TestObject] = WCDBAssertNoThrowReturned(\n            try database.getObjects(fromTable: TestObject.name),\n            whenFailed: [TestObject]()\n        )\n        XCTAssertEqual(Array(repeating: self.name, count: preInsertedObjects.count), results.map({\n            XCTAssertNotNil($0.variable2)\n            return $0.variable2!\n        }))\n    }\n\n    func testTableUpdate() {\n        // Give\n        let optionalUpdate = WCDBAssertNoThrowReturned(\n            try table.prepareUpdate(on: TestObject.Properties.variable2)\n        )\n        XCTAssertNotNil(optionalUpdate)\n        update = optionalUpdate!\n        let object = TestObject()\n        object.variable2 = self.name\n        // When\n        XCTAssertNoThrow(try update.execute(with: object))\n        // Then\n        let results: [TestObject] = WCDBAssertNoThrowReturned(\n            try table.getObjects(),\n            whenFailed: [TestObject]()\n        )\n        XCTAssertEqual(Array(repeating: self.name, count: preInsertedObjects.count), results.map({\n            XCTAssertNotNil($0.variable2)\n            return $0.variable2!\n        }))\n    }\n\n    func testConditionalUpdate() {\n        // Give\n        let object = TestObject()\n        object.variable2 = self.name\n        // When\n        XCTAssertNoThrow(try update.where(TestObject.Properties.variable1 == 1).execute(with: object))\n        // Then\n        let result: TestObject? = WCDBAssertNoThrowReturned(\n            try database.getObject(fromTable: TestObject.name, where: TestObject.Properties.variable1 == 1)\n        )\n        XCTAssertNotNil(result)\n        XCTAssertEqual(self.name, result!.variable2)\n    }\n\n    func testOrderedUpdate() {\n        // Give\n        let object = TestObject()\n        object.variable2 = self.name\n        let order = TestObject.Properties.variable1.order(.descending)\n        // When\n        XCTAssertNoThrow(try update.order(by: order).limit(1).execute(with: object))\n        // Then\n        let result: TestObject? = WCDBAssertNoThrowReturned(\n            try database.getObject(fromTable: TestObject.name, where: TestObject.Properties.variable1 == 2)\n        )\n        XCTAssertNotNil(result)\n        XCTAssertEqual(self.name, result!.variable2)\n    }\n\n    func testLimitedUpdate() {\n        // Give\n        let object = TestObject()\n        object.variable2 = self.name\n        // When\n        XCTAssertNoThrow(try update.limit(1).execute(with: object))\n        // Then\n        let results: [TestObject] = WCDBAssertNoThrowReturned(\n            try database.getObjects(fromTable: TestObject.name)\n        )\n        XCTAssertEqual(results[0].variable2, self.name)\n        XCTAssertEqual(results[1], preInsertedObjects[1])\n    }\n\n    func testOffsetUpdate() {\n        // Give\n        let object = TestObject()\n        object.variable2 = self.name\n        // When\n        XCTAssertNoThrow(try update.limit(1, offset: 1).execute(with: object))\n        // Then\n        let results: [TestObject] = WCDBAssertNoThrowReturned(try database.getObjects(fromTable: TestObject.name))\n        XCTAssertEqual(results[0], preInsertedObjects[0])\n        XCTAssertEqual(results[1].variable2, self.name)\n    }\n\n    func testLimitFromToUpdate() {\n        // Give\n        let object = TestObject()\n        object.variable2 = self.name\n        // When\n        XCTAssertNoThrow(try update.limit(from: 1, to: 2).execute(with: object))\n        // Then\n        let results: [TestObject] = WCDBAssertNoThrowReturned(try database.getObjects(fromTable: TestObject.name))\n        XCTAssertEqual(results[0], preInsertedObjects[0])\n        XCTAssertEqual(results[1].variable2, self.name)\n    }\n\n    func testUpdateChanges() {\n        // Give\n        let object = TestObject()\n        object.variable2 = self.name\n        // When\n        XCTAssertNoThrow(try update.execute(with: object))\n        // Then\n        XCTAssertEqual(update.changes, preInsertedObjects.count)\n    }\n}\n"
  },
  {
    "path": "src/swift/tests/orm/AutoAddColumnTests.swift",
    "content": "//\n// Created by qiuwenchen on 2022/12/6.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\": Int = 0 you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport XCTest\n#if TEST_WCDB_SWIFT\nimport WCDBSwift\n#else\nimport WCDB\n#endif\n\nclass AutoAddColumnTests: DatabaseTestCase {\n\n    final class AutoAddColumnObject: TableCodable, Named {\n        var primaryValue: Int = 0\n        var uniqueValue: Int = 0\n        var insertValue: Int = 0\n        var updateValue: Int = 0\n        var selectValue: Int = 0\n        var multiSelectValue: Int = 0\n        var deleteValue: Int = 0\n        var indexValue: Int = 0\n        enum CodingKeys: String, CodingTableKey {\n            typealias Root = AutoAddColumnObject\n            case primaryValue\n            case uniqueValue\n            case insertValue\n            case updateValue\n            case selectValue\n            case multiSelectValue\n            case deleteValue\n            nonisolated(unsafe) static let objectRelationalMapping = TableBinding(CodingKeys.self) {\n                BindColumnConstraint(.primaryValue, isPrimary: true)\n                BindColumnConstraint(.uniqueValue, isUnique: true)\n            }\n        }\n    }\n\n    func testAutoAddColumn() {\n        let fakeTable = \"fakeTable\"\n        let tableName = AutoAddColumnObject.name\n        let fakeSchema = \"notExistSchema\"\n        XCTAssertNoThrow(try self.database.create(table: fakeTable, of: AutoAddColumnObject.self))\n\n        doTestAutoAdd(column: AutoAddColumnObject.Properties.insertValue, is: true) {\n            try self.database.insert(AutoAddColumnObject(), intoTable: tableName)\n        }\n\n        doTestAutoAdd(column: AutoAddColumnObject.Properties.updateValue, is: true) {\n            try self.database.update(table: tableName, on: AutoAddColumnObject.Properties.updateValue, with: 1)\n        }\n\n        doTestAutoAdd(column: AutoAddColumnObject.Properties.deleteValue, is: true) {\n            try self.database.delete(fromTable: tableName, where: AutoAddColumnObject.Properties.deleteValue == 1)\n        }\n\n        doTestAutoAdd(column: AutoAddColumnObject.Properties.deleteValue, is: true) {\n            try self.database.delete(fromTable: tableName, where: AutoAddColumnObject.Properties.deleteValue.in(table: tableName) == 1)\n        }\n\n        doTestAutoAdd(column: AutoAddColumnObject.Properties.deleteValue, is: false) {\n            try self.database.delete(fromTable: tableName, where: AutoAddColumnObject.Properties.deleteValue.in(table: fakeTable) == 1)\n        }\n\n        doTestAutoAdd(column: AutoAddColumnObject.Properties.deleteValue, is: false) {\n            try self.database.delete(fromTable: tableName, where: AutoAddColumnObject.Properties.deleteValue.in(table: tableName).of(schema: fakeSchema) == 1)\n        }\n\n        doTestAutoAdd(column: AutoAddColumnObject.Properties.selectValue, is: true) {\n            _ = try self.database.getColumn(on: AutoAddColumnObject.Properties.selectValue, fromTable: tableName)\n        }\n\n        doTestAutoAdd(column: AutoAddColumnObject.Properties.selectValue, is: true) {\n            _ = try self.database.getColumn(on: AutoAddColumnObject.Properties.insertValue, fromTable: tableName, where: AutoAddColumnObject.Properties.selectValue == 1)\n        }\n\n        doTestAutoAdd(column: AutoAddColumnObject.Properties.selectValue, is: true) {\n            _ = try self.database.getColumn(on: AutoAddColumnObject.Properties.insertValue, fromTable: tableName, orderBy: [AutoAddColumnObject.Properties.selectValue.asOrder()])\n        }\n\n        doTestAutoAdd(column: AutoAddColumnObject.Properties.selectValue, is: true) {\n            _ = try self.database.getColumn(on: AutoAddColumnObject.Properties.insertValue, fromTable: tableName, orderBy: [AutoAddColumnObject.Properties.selectValue.in(table: tableName).asOrder()])\n        }\n\n        doTestAutoAdd(column: AutoAddColumnObject.Properties.selectValue, is: false) {\n            _ = try self.database.getColumn(on: AutoAddColumnObject.Properties.insertValue, fromTable: tableName, orderBy: [AutoAddColumnObject.Properties.selectValue.in(table: fakeTable).asOrder()])\n        }\n\n        doTestAutoAdd(column: AutoAddColumnObject.Properties.selectValue, is: false) {\n            _ = try self.database.getColumn(on: AutoAddColumnObject.Properties.insertValue, fromTable: tableName, orderBy: [AutoAddColumnObject.Properties.selectValue.in(table: tableName).of(schema: fakeSchema).asOrder()])\n        }\n\n        doTestAutoAdd(column: AutoAddColumnObject.Properties.multiSelectValue, is: true) {\n            let multiSelect = try self.database.prepareMultiSelect(on: AutoAddColumnObject.Properties.multiSelectValue.in(table: tableName), AutoAddColumnObject.Properties.multiSelectValue.in(table: fakeTable), fromTables: [fakeTable, tableName])\n            _ = try multiSelect.allMultiObjects()\n        }\n\n        doTestAutoAdd(column: AutoAddColumnObject.Properties.primaryValue, is: false) {\n            _ = try self.database.getColumn(on: AutoAddColumnObject.Properties.primaryValue, fromTable: tableName)\n        }\n\n        doTestAutoAdd(column: AutoAddColumnObject.Properties.uniqueValue, is: false) {\n            _ = try self.database.getColumn(on: AutoAddColumnObject.Properties.uniqueValue, fromTable: tableName)\n        }\n    }\n\n    func doTestAutoAdd(column codingKey: any CodingTableKey, is succeed: Bool, by execute: () throws -> Void) {\n        let tableName = AutoAddColumnObject.name\n        let propertyName = codingKey.asProperty().name\n        let createTable = StatementCreateTable().create(table: tableName)\n        let properties = AutoAddColumnObject.Properties.all.filter { element in\n            element.description != propertyName\n        }\n        let columnDefs = properties.map {\n            ColumnDef(with: $0, and: .integer64)\n        }\n        createTable.with(columns: columnDefs)\n        XCTAssertNoThrow(try self.database.exec(createTable))\n        var autoAdded = false\n        self.database.traceError { error in\n            guard error.message == \"Auto add column\" else {\n                return\n            }\n            autoAdded = true\n            XCTAssertEqual(error.extInfos[\"Table\"]?.stringValue, tableName)\n            XCTAssertEqual(error.extInfos[\"Column\"]?.stringValue, propertyName)\n        }\n        if succeed {\n            XCTAssertNoThrow(try execute())\n            XCTAssertEqual(autoAdded, true)\n        } else {\n            XCTAssertThrowsError(try execute())\n            XCTAssertEqual(autoAdded, false)\n        }\n        XCTAssertNoThrow(try self.database.drop(table: tableName))\n        self.database.traceError(nil)\n    }\n}\n"
  },
  {
    "path": "src/swift/tests/orm/ColumnConstraintBindingTests.swift",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport XCTest\n#if TEST_WCDB_SWIFT\nimport WCDBSwift\n#else\nimport WCDB\n#endif\n\nclass ColumnConstraintBindingTests: ORMTestCase {\n\n    final class BaselineTestObject: TableCodable {\n        var variable: Int = 0\n        enum CodingKeys: String, CodingTableKey {\n            typealias Root = BaselineTestObject\n            case variable\n            nonisolated(unsafe) static let objectRelationalMapping = TableBinding(CodingKeys.self)\n        }\n    }\n\n    final class PrimaryTestObject: TableCodable {\n        var variable: Int = 0\n        enum CodingKeys: String, CodingTableKey {\n            typealias Root = PrimaryTestObject\n            case variable = \"primaryVariable\"\n            nonisolated(unsafe) static let objectRelationalMapping = TableBinding(CodingKeys.self) {\n                BindColumnConstraint(variable, isPrimary: true)\n            }\n        }\n    }\n\n    final class OrderedPrimaryTestObject: TableCodable {\n        var variable: Int = 0\n        enum CodingKeys: String, CodingTableKey {\n            typealias Root = OrderedPrimaryTestObject\n            case variable = \"orderedPrimaryVariable\"\n            nonisolated(unsafe) static let objectRelationalMapping = TableBinding(CodingKeys.self) {\n                BindColumnConstraint(variable, isPrimary: true, orderBy: .ascending)\n            }\n        }\n    }\n\n    final class AutoIncrementPrimaryTestObject: TableCodable {\n        var variable: Int = 0\n        enum CodingKeys: String, CodingTableKey {\n            typealias Root = AutoIncrementPrimaryTestObject\n            case variable = \"autoIncrementPrimaryVariable\"\n            nonisolated(unsafe) static let objectRelationalMapping = TableBinding(CodingKeys.self) {\n                BindColumnConstraint(variable, isPrimary: true, isAutoIncrement: true)\n            }\n        }\n    }\n    final class ConflictPrimaryTestObject: TableCodable {\n        var variable: Int = 0\n        enum CodingKeys: String, CodingTableKey {\n            typealias Root = ConflictPrimaryTestObject\n            case variable = \"conflictPrimaryVariable\"\n            nonisolated(unsafe) static let objectRelationalMapping = TableBinding(CodingKeys.self) {\n                BindColumnConstraint(variable, isPrimary: true, onConflict: .Replace)\n            }\n        }\n    }\n\n    final class NotNullTestObject: TableCodable {\n        var variable: Int = 0\n        enum CodingKeys: String, CodingTableKey {\n            typealias Root = NotNullTestObject\n            case variable = \"notNullVariable\"\n            nonisolated(unsafe) static let objectRelationalMapping = TableBinding(CodingKeys.self) {\n                BindColumnConstraint(variable, isNotNull: true)\n            }\n        }\n    }\n\n    final class UniqueTestObject: TableCodable {\n        var variable: Int = 0\n        enum CodingKeys: String, CodingTableKey {\n            typealias Root = UniqueTestObject\n            case variable = \"uniqueVariable\"\n            nonisolated(unsafe) static let objectRelationalMapping = TableBinding(CodingKeys.self) {\n                BindColumnConstraint(variable, isUnique: true)\n            }\n        }\n    }\n\n    final class DefaultInt32ValueTestObject: TableCodable {\n        var variable: Int = 0\n        enum CodingKeys: String, CodingTableKey {\n            typealias Root = DefaultInt32ValueTestObject\n            case variable = \"defaultValueVariable\"\n            nonisolated(unsafe) static let objectRelationalMapping = TableBinding(CodingKeys.self) {\n                BindColumnConstraint(variable, defaultTo: Int32(1))\n            }\n        }\n    }\n\n    final class DefaultInt64ValueTestObject: TableCodable {\n        var variable: Int = 0\n        enum CodingKeys: String, CodingTableKey {\n            typealias Root = DefaultInt64ValueTestObject\n            case variable = \"defaultValueVariable\"\n            nonisolated(unsafe) static let objectRelationalMapping = TableBinding(CodingKeys.self) {\n                BindColumnConstraint(variable, defaultTo: Int64(1))\n            }\n        }\n    }\n\n    final class DefaultFloatValueTestObject: TableCodable {\n        var variable: Int = 0\n        enum CodingKeys: String, CodingTableKey {\n            typealias Root = DefaultFloatValueTestObject\n            case variable = \"defaultValueVariable\"\n            nonisolated(unsafe) static let objectRelationalMapping = TableBinding(CodingKeys.self) {\n                BindColumnConstraint(variable, defaultTo: Double(1.2))\n            }\n        }\n    }\n\n    final class DefaultTextValueTestObject: TableCodable {\n        var variable: Int = 0\n        enum CodingKeys: String, CodingTableKey {\n            typealias Root = DefaultTextValueTestObject\n            case variable = \"defaultValueVariable\"\n            nonisolated(unsafe) static let objectRelationalMapping = TableBinding(CodingKeys.self) {\n                BindColumnConstraint(variable, defaultTo: \"defaultString\")\n            }\n        }\n    }\n\n    final class DefaultBLOBValueTestObject: TableCodable {\n        var variable: Int = 0\n        enum CodingKeys: String, CodingTableKey {\n            typealias Root = DefaultBLOBValueTestObject\n            case variable = \"defaultValueVariable\"\n            nonisolated(unsafe) static let objectRelationalMapping = TableBinding(CodingKeys.self) {\n                BindColumnConstraint(variable, defaultTo: \"defaultData\".data(using: .ascii)!)\n            }\n        }\n    }\n\n    func testProperty() {\n        XCTAssertEqual(BaselineTestObject.Properties.variable.asProperty().codingTableKey!.stringValue,\n                       BaselineTestObject.Properties.variable.stringValue)\n\n        XCTAssertEqual(BaselineTestObject.Properties.variable.asProperty().description,\n                       BaselineTestObject.Properties.variable.asProperty().asProperty().description)\n\n        XCTAssertEqual(BaselineTestObject.Properties.variable.asProperty().codingTableKey!.stringValue,\n                       BaselineTestObject.Properties.variable.asProperty().asProperty().codingTableKey!.stringValue)\n    }\n\n    func testCantSetLastInsertedRowID() {\n        var object = BaselineTestObject()\n        // Can't set\n        object.lastInsertedRowID = Int64.max\n        XCTAssertEqual(object.lastInsertedRowID, Int64.min)\n    }\n\n    func testColumnConstraintBinding() {\n\n        ORMConstraintBindingAssertEqual(\n            BaselineTestObject.self,\n            \"CREATE TABLE IF NOT EXISTS BaselineTestObject(variable INTEGER)\"\n        )\n\n        ORMConstraintBindingAssertEqual(\n            PrimaryTestObject.self,\n            \"CREATE TABLE IF NOT EXISTS PrimaryTestObject(primaryVariable INTEGER PRIMARY KEY)\"\n        )\n\n        ORMConstraintBindingAssertEqual(\n            OrderedPrimaryTestObject.self,\n            \"CREATE TABLE IF NOT EXISTS OrderedPrimaryTestObject(orderedPrimaryVariable INTEGER PRIMARY KEY ASC)\"\n        )\n\n        ORMConstraintBindingAssertEqual(\n            AutoIncrementPrimaryTestObject.self,\n            \"\"\"\n            CREATE TABLE IF NOT EXISTS AutoIncrementPrimaryTestObject\\\n            (autoIncrementPrimaryVariable INTEGER PRIMARY KEY AUTOINCREMENT)\n            \"\"\"\n        )\n\n        ORMConstraintBindingAssertEqual(\n            ConflictPrimaryTestObject.self,\n            \"\"\"\n            CREATE TABLE IF NOT EXISTS ConflictPrimaryTestObject\\\n            (conflictPrimaryVariable INTEGER PRIMARY KEY ON CONFLICT REPLACE)\n            \"\"\"\n        )\n\n        ORMConstraintBindingAssertEqual(\n            NotNullTestObject.self,\n            \"CREATE TABLE IF NOT EXISTS NotNullTestObject(notNullVariable INTEGER NOT NULL)\"\n        )\n\n        ORMConstraintBindingAssertEqual(\n            UniqueTestObject.self,\n            \"CREATE TABLE IF NOT EXISTS UniqueTestObject(uniqueVariable INTEGER UNIQUE)\"\n        )\n\n        ORMConstraintBindingAssertEqual(\n            DefaultInt32ValueTestObject.self,\n            \"CREATE TABLE IF NOT EXISTS DefaultInt32ValueTestObject(defaultValueVariable INTEGER DEFAULT 1)\"\n        )\n\n        ORMConstraintBindingAssertEqual(\n            DefaultInt64ValueTestObject.self,\n            \"CREATE TABLE IF NOT EXISTS DefaultInt64ValueTestObject(defaultValueVariable INTEGER DEFAULT 1)\"\n        )\n\n        ORMConstraintBindingAssertEqual(\n            DefaultFloatValueTestObject.self,\n            \"CREATE TABLE IF NOT EXISTS DefaultFloatValueTestObject(defaultValueVariable INTEGER DEFAULT 1.2)\"\n        )\n\n        ORMConstraintBindingAssertEqual(\n            DefaultTextValueTestObject.self,\n            \"\"\"\n            CREATE TABLE IF NOT EXISTS DefaultTextValueTestObject\\\n            (defaultValueVariable INTEGER DEFAULT 'defaultString')\n            \"\"\"\n        )\n\n        ORMConstraintBindingAssertEqual(\n            DefaultBLOBValueTestObject.self,\n            \"CREATE TABLE IF NOT EXISTS DefaultBLOBValueTestObject(defaultValueVariable INTEGER DEFAULT 'defaultData')\"\n        )\n    }\n\n    final class EnablePrimaryAutoIncrement: TableCodable {\n        var id: Int = 0\n\n        var isAutoIncrement: Bool = false\n        var lastInsertedRowID: Int64 = 0\n        enum CodingKeys: String, CodingTableKey {\n            typealias Root = EnablePrimaryAutoIncrement\n            case id\n            nonisolated(unsafe) static let objectRelationalMapping = TableBinding(CodingKeys.self) {\n                BindColumnConstraint(id, isPrimary: true,\n                                     isAutoIncrement: true,\n                                     enableAutoIncrementForExistingTable: true)\n            }\n        }\n    }\n\n    final class PrimaryNotAutoIncrement: TableCodable {\n        var id: Int = 0\n        var lastInsertedRowID: Int64 = 0\n        enum CodingKeys: String, CodingTableKey {\n            typealias Root = PrimaryNotAutoIncrement\n            case id\n            nonisolated(unsafe) static let objectRelationalMapping = TableBinding(CodingKeys.self) {\n                BindColumnConstraint(id, isPrimary: true)\n            }\n        }\n    }\n\n    func testPrimaryEnableAutoIncrementForExistingTable() {\n        XCTAssertNoThrow(try database.create(table: \"testTable\", of: PrimaryNotAutoIncrement.self))\n        let obj1 = PrimaryNotAutoIncrement()\n        obj1.id = 1\n        XCTAssertNoThrow(try database.insert(obj1, intoTable: \"testTable\"))\n\n        XCTAssertNoThrow(try database.create(table: \"testTable\", of: EnablePrimaryAutoIncrement.self))\n\n        XCTAssertNoThrow(try database.delete(fromTable: \"testTable\"))\n\n        let obj2 = EnablePrimaryAutoIncrement()\n        obj2.isAutoIncrement = true\n        XCTAssertNoThrow(try database.insert(obj2, intoTable: \"testTable\"))\n        XCTAssertEqual(obj2.lastInsertedRowID, 2)\n    }\n}\n"
  },
  {
    "path": "src/swift/tests/orm/IndexBindingTests.swift",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport XCTest\n#if TEST_WCDB_SWIFT\nimport WCDBSwift\n#else\nimport WCDB\n#endif\n\nclass IndexBindingTests: ORMTestCase {\n\n    final class BaselineTestObject: TableCodable {\n        var variable: Int = 0\n        enum CodingKeys: String, CodingTableKey {\n            typealias Root = BaselineTestObject\n            case variable\n            nonisolated(unsafe) static let objectRelationalMapping = TableBinding(CodingKeys.self) {\n                BindIndex(variable, namedWith: \"_index\")\n            }\n        }\n    }\n\n    final class UniqueTestObject: TableCodable {\n        var variable: Int = 0\n        enum CodingKeys: String, CodingTableKey {\n            typealias Root = UniqueTestObject\n            case variable\n            nonisolated(unsafe) static let objectRelationalMapping = TableBinding(CodingKeys.self) {\n                BindIndex(variable, namedWith: \"_index\", isUnique: true)\n            }\n        }\n    }\n\n    final class MultiIndexesTestObject: TableCodable {\n        var variable1: Int = 0\n        var variable2: Int = 0\n        enum CodingKeys: String, CodingTableKey {\n            typealias Root = MultiIndexesTestObject\n            case variable1\n            case variable2\n            nonisolated(unsafe) static let objectRelationalMapping = TableBinding(CodingKeys.self) {\n                BindIndex(variable1, variable2, namedWith: \"_index\")\n            }\n        }\n    }\n\n    func testIndexBinding() {\n        ORMIndexBindingAssertEqual(\n            BaselineTestObject.self,\n            \"CREATE INDEX IF NOT EXISTS BaselineTestObject_index ON BaselineTestObject(variable)\"\n        )\n\n        ORMIndexBindingAssertEqual(\n            UniqueTestObject.self,\n            \"CREATE UNIQUE INDEX IF NOT EXISTS UniqueTestObject_index ON UniqueTestObject(variable)\"\n        )\n\n        ORMIndexBindingAssertEqual(\n            MultiIndexesTestObject.self,\n            \"\"\"\n            CREATE INDEX IF NOT EXISTS MultiIndexesTestObject_index \\\n            ON MultiIndexesTestObject(variable1, variable2)\n            \"\"\")\n    }\n}\n"
  },
  {
    "path": "src/swift/tests/orm/ORMTestCase.swift",
    "content": "//\n// Created by qiuwenchen on 2022/12/3.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport XCTest\n#if TEST_WCDB_SWIFT\nimport WCDBSwift\n#else\nimport WCDB\n#endif\n\nclass ORMTestCase: DatabaseTestCase {\n\n    func ORMConstraintBindingAssertEqual<TableCodableObject: TableCodable>(\n        _ expression1: @autoclosure () -> TableCodableObject.Type,\n        _ expression2: @autoclosure () -> String,\n        file: StaticString = #file,\n        line: UInt = #line) {\n        let type = expression1()\n        let className = String(describing: type)\n        var description1: String?\n        database.traceSQL {_, _, _, sql, _ in\n            if sql.hasPrefix(\"CREATE TABLE\") {\n                description1 = sql\n            }\n        }\n        WCDBAssertNoThrowReturned(try database.create(table: className, of: TableCodableObject.self))\n        XCTAssertNotNil(description1)\n        let description2 = expression2()\n        XCTAssertEqual(description1!, description2, file: file, line: line)\n    }\n\n    func ORMIndexBindingAssertEqual<TableCodableObject: TableCodable>(\n        _ expression1: @autoclosure () -> TableCodableObject.Type,\n        _ expression2: @autoclosure () -> String,\n        file: StaticString = #file,\n        line: UInt = #line) {\n        let type = expression1()\n        let className = String(describing: type)\n        var description1: String?\n        database.traceSQL {_, _, _, sql, _ in\n            if (sql.hasPrefix(\"CREATE INDEX\") ||\n                sql.hasPrefix(\"CREATE UNIQUE INDEX\")) &&\n                description1 == nil {\n                description1 = sql\n            }\n        }\n        WCDBAssertNoThrowReturned(try database.create(table: className, of: TableCodableObject.self))\n        XCTAssertNotNil(description1)\n        let description2 = expression2()\n        XCTAssertEqual(description1!, description2, file: file, line: line)\n    }\n\n    func ORMVirtualTableBindingAssertEqual<TableCodableObject: TableCodable>(\n        _ expression1: @autoclosure () -> TableCodableObject.Type,\n        _ expression2: @autoclosure () -> String,\n        file: StaticString = #file,\n        line: UInt = #line) {\n        let type = expression1()\n        let className = String(describing: type)\n        var description1: String?\n        database.traceSQL {_, _, _, sql, _ in\n            if sql.hasPrefix(\"CREATE VIRTUAL TABLE\") {\n                description1 = sql\n            }\n        }\n        WCDBAssertNoThrowReturned(try database.create(virtualTable: className, of: TableCodableObject.self))\n        XCTAssertNotNil(description1)\n        let description2 = expression2()\n        XCTAssertEqual(description1, description2, file: file, line: line)\n    }\n}\n"
  },
  {
    "path": "src/swift/tests/orm/TableConstraintBindingTests.swift",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport XCTest\n#if TEST_WCDB_SWIFT\nimport WCDBSwift\n#else\nimport WCDB\n#endif\n\nclass TableConstraintBindingTests: ORMTestCase {\n\n    final class BaselineMultiPrimaryTestObject: TableCodable, Named {\n        var variable1: Int = 0\n        var variable2: Int = 0\n        enum CodingKeys: String, CodingTableKey {\n            typealias Root = BaselineMultiPrimaryTestObject\n            case variable1\n            case variable2\n            nonisolated(unsafe) static let objectRelationalMapping = TableBinding(CodingKeys.self) {\n                BindMultiPrimary(variable1, variable2)\n            }\n        }\n    }\n\n    final class MultiPrimaryConflictTestObject: TableCodable, Named {\n        var variable1: Int = 0\n        var variable2: Int = 0\n        enum CodingKeys: String, CodingTableKey {\n            typealias Root = MultiPrimaryConflictTestObject\n            case variable1\n            case variable2\n            nonisolated(unsafe) static let objectRelationalMapping = TableBinding(CodingKeys.self) {\n                BindMultiPrimary(variable1, variable2, onConflict: .Replace)\n            }\n        }\n    }\n\n    func testMultiPrimaryBinding() {\n        ORMConstraintBindingAssertEqual(\n            BaselineMultiPrimaryTestObject.self,\n            \"\"\"\n            CREATE TABLE IF NOT EXISTS BaselineMultiPrimaryTestObject\\\n            (variable1 INTEGER, variable2 INTEGER, \\\n            PRIMARY KEY(variable1, variable2))\n            \"\"\"\n        )\n\n        ORMConstraintBindingAssertEqual(\n            MultiPrimaryConflictTestObject.self,\n            \"\"\"\n            CREATE TABLE IF NOT EXISTS MultiPrimaryConflictTestObject\\\n            (variable1 INTEGER, variable2 INTEGER, \\\n            PRIMARY KEY(variable1, variable2) ON CONFLICT REPLACE)\n            \"\"\"\n        )\n    }\n\n    final class BaselineMultiUniqueTestObject: TableCodable, Named {\n        var variable1: Int = 0\n        var variable2: Int = 0\n        enum CodingKeys: String, CodingTableKey {\n            typealias Root = BaselineMultiUniqueTestObject\n            case variable1\n            case variable2\n            nonisolated(unsafe) static let objectRelationalMapping = TableBinding(CodingKeys.self) {\n                BindMultiUnique(variable1, variable2)\n            }\n        }\n    }\n\n    final class MultiUniqueConflictTestObject: TableCodable, Named {\n        var variable1: Int = 0\n        var variable2: Int = 0\n        enum CodingKeys: String, CodingTableKey {\n            typealias Root = MultiUniqueConflictTestObject\n            case variable1\n            case variable2\n            nonisolated(unsafe) static let objectRelationalMapping = TableBinding(CodingKeys.self) {\n                BindMultiUnique(variable1, variable2, onConflict: .Replace)\n            }\n        }\n    }\n    func testMultiUniqueBinding() {\n        ORMConstraintBindingAssertEqual(\n            BaselineMultiUniqueTestObject.self,\n            \"\"\"\n            CREATE TABLE IF NOT EXISTS BaselineMultiUniqueTestObject\\\n            (variable1 INTEGER, \\\n            variable2 INTEGER, \\\n            UNIQUE(variable1, variable2))\n            \"\"\"\n        )\n\n        ORMConstraintBindingAssertEqual(\n            MultiUniqueConflictTestObject.self,\n            \"\"\"\n            CREATE TABLE IF NOT EXISTS MultiUniqueConflictTestObject\\\n            (variable1 INTEGER, variable2 INTEGER, \\\n            UNIQUE(variable1, variable2) ON CONFLICT REPLACE)\n            \"\"\"\n        )\n    }\n\n    final class CheckTestObject: TableCodable, Named {\n        var variable1: Int = 0\n        var variable2: Int = 0\n        static let constraintName = CheckTestObject.name + \"Constraint\"\n        enum CodingKeys: String, CodingTableKey {\n            typealias Root = CheckTestObject\n            case variable1\n            case variable2\n            nonisolated(unsafe) static let objectRelationalMapping = TableBinding(CodingKeys.self) {\n                BindChecks {\n                    variable1 > 1\n                }\n            }\n        }\n    }\n    func testCheckBinding() {\n        ORMConstraintBindingAssertEqual(\n            CheckTestObject.self,\n            \"\"\"\n            CREATE TABLE IF NOT EXISTS CheckTestObject\\\n            (variable1 INTEGER, \\\n            variable2 INTEGER, \\\n            CHECK(variable1 > 1))\n            \"\"\"\n        )\n    }\n\n    final class ForeignKeyTestObject: TableCodable, Named {\n        var variable1: Int = 0\n        var variable2: Int = 0\n        enum CodingKeys: String, CodingTableKey {\n            typealias Root = ForeignKeyTestObject\n            case variable1\n            case variable2\n            nonisolated(unsafe) static let objectRelationalMapping = TableBinding(CodingKeys.self) {\n                BindForeginKey(variable1, foreignKey: ForeignKey().references(with: ForeignKeyTestObject.name).columns(variable2))\n            }\n        }\n    }\n    func testForeignKeyBinding() {\n        ORMConstraintBindingAssertEqual(\n            ForeignKeyTestObject.self,\n            \"\"\"\n            CREATE TABLE IF NOT EXISTS ForeignKeyTestObject\\\n            (variable1 INTEGER, \\\n            variable2 INTEGER, \\\n            FOREIGN KEY(variable1) REFERENCES ForeignKeyTestObject(variable2))\n            \"\"\"\n        )\n    }\n\n}\n"
  },
  {
    "path": "src/swift/tests/orm/VirtualTableBindingTests.swift",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport XCTest\n#if TEST_WCDB_SWIFT\nimport WCDBSwift\n#else\nimport WCDB\n#endif\n\nclass VirtualTableBindingTests: ORMTestCase {\n\n    final class FTS3TestObject: TableCodable, Named {\n        var id: Int = 0\n        var content: String = \"\"\n        enum CodingKeys: String, CodingTableKey {\n            typealias Root = FTS3TestObject\n            case id\n            case content\n            nonisolated(unsafe) static let objectRelationalMapping = TableBinding(CodingKeys.self) {\n                BindVirtualTable(withModule: .FTS3, and: BuiltinTokenizer.OneOrBinary, BuiltinTokenizer.Parameter.NeedSymbol)\n                BindColumnConstraint(id, isNotIndexed: true)\n            }\n        }\n    }\n\n    func testFTS3VirtualBinding() {\n        self.database.add(tokenizer: BuiltinTokenizer.OneOrBinary)\n        ORMVirtualTableBindingAssertEqual(\n            FTS3TestObject.self,\n            \"\"\"\n            CREATE VIRTUAL TABLE IF NOT EXISTS FTS3TestObject USING fts3\\\n            (tokenize = WCDB need_symbol, id INTEGER, content TEXT, notindexed=id)\n            \"\"\"\n        )\n    }\n\n    final class FTS5TestObject: TableCodable, Named {\n        var id: Int = 0\n        var content: String = \"\"\n        enum CodingKeys: String, CodingTableKey {\n            typealias Root = FTS5TestObject\n            case id\n            case content\n            nonisolated(unsafe) static let objectRelationalMapping = TableBinding(CodingKeys.self) {\n                BindVirtualTable(withModule: .FTS5, and: BuiltinTokenizer.Verbatim, BuiltinTokenizer.Parameter.SkipStemming, BuiltinTokenizer.Parameter.SimplifyChinese)\n                BindColumnConstraint(id, isNotIndexed: true)\n            }\n        }\n    }\n\n    func testFTS5VirtualBinding() {\n        self.database.add(tokenizer: BuiltinTokenizer.Verbatim)\n        ORMVirtualTableBindingAssertEqual(\n            FTS5TestObject.self,\n            \"\"\"\n            CREATE VIRTUAL TABLE IF NOT EXISTS FTS5TestObject USING fts5\\\n            (tokenize = 'wcdb_verbatim skip_stemming chinese_traditional_to_simplified', id UNINDEXED, content)\n            \"\"\"\n        )\n    }\n}\n"
  },
  {
    "path": "src/swift/tests/other/FileTests.swift",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport XCTest\n#if TEST_WCDB_SWIFT\nimport WCDBSwift\n#else\nimport WCDB\n#endif\n\nclass FileTests: DatabaseTestCase {\n\n    func testPaths() {\n        // Give\n        let path = self.recommendedPath.path\n        let expertedPaths = [path, path+\"-wal\", path+\"-shm\", path+\"-journal\", path+\"-first.material\", path+\"-last.material\", path+\"-incremental.material\", path+\".factory\"]\n        // Then\n        XCTAssertEqual(database.paths.sorted(), expertedPaths.sorted())\n    }\n\n    func testURLs() {\n        // Give\n        let url = self.recommendedPath\n        let path = url.path\n        let expertedURLs = [url,\n                            URL(fileURLWithPath: path+\"-wal\"),\n                            URL(fileURLWithPath: path+\"-shm\"),\n                            URL(fileURLWithPath: path+\"-journal\"),\n                            URL(fileURLWithPath: path+\"-first.material\"),\n                            URL(fileURLWithPath: path+\"-last.material\"),\n                            URL(fileURLWithPath: path+\"-incremental.material\"),\n                            URL(fileURLWithPath: path+\".factory\")]\n        // Then\n        func sorter(left: URL, right: URL) -> Bool {\n            return left.path < right.path\n        }\n        XCTAssertEqual(database.urls.sorted(by: sorter), expertedURLs.sorted(by: sorter))\n    }\n\n    func testRemoveFiles() {\n        // Give\n        for path in database.paths {\n            if fileManager.fileExists(atPath: path) {\n                XCTAssertNoThrow(try fileManager.removeItem(atPath: path))\n            }\n            XCTAssertNoThrow(fileManager.createFile(atPath: path, contents: nil, attributes: nil))\n        }\n        // When\n        XCTAssertNoThrow(try database.close {\n            try self.database.removeFiles()\n        })\n        // Then\n        for path in database.paths {\n            XCTAssertFalse(fileManager.fileExists(atPath: path))\n        }\n    }\n\n    func testUnsafeRemoveFiles() {\n        // Give\n        for path in database.paths {\n            if fileManager.fileExists(atPath: path) {\n                XCTAssertNoThrow(try fileManager.removeItem(atPath: path))\n            }\n            XCTAssertNoThrow(fileManager.createFile(atPath: path, contents: nil, attributes: nil))\n        }\n        // When\n        XCTAssertNoThrow(try self.database.removeFiles())\n        // Then\n        for path in database.paths {\n            XCTAssertFalse(fileManager.fileExists(atPath: path))\n        }\n    }\n\n    func testMoveFiles() {\n        // Give\n        let paths = database.paths\n        for path in paths {\n            XCTAssertNoThrow(fileManager.createFile(atPath: path, contents: nil, attributes: nil))\n        }\n\n        let newDirectory = self.recommendedDirectory.urlByAppendingPathComponent(\"newDirectory\").path\n\n        let newPaths = paths.map { (path) -> String in\n            let fileName = URL(fileURLWithPath: path).lastPathComponent\n            return URL(fileURLWithPath: newDirectory).appendingPathComponent(fileName).path\n        }\n\n        for path in newPaths {\n            if fileManager.fileExists(atPath: path) {\n                XCTAssertNoThrow(try fileManager.removeItem(atPath: path))\n            }\n        }\n\n        // When\n        XCTAssertNoThrow(try database.moveFiles(toDirectory: newDirectory))\n        // Then\n        for path in newPaths {\n            XCTAssertTrue(fileManager.fileExists(atPath: path))\n        }\n\n        // Clear\n        XCTAssertNoThrow(try fileManager.removeItem(atPath: newDirectory))\n    }\n\n    func testGetFilesSize() {\n        // Give\n        let data = \"testGetFilesSize\".data(using: .ascii)!\n        let expectedFilesSize = data.count * database.paths.count\n        for path in database.paths {\n            if fileManager.fileExists(atPath: path) {\n                XCTAssertNoThrow(try fileManager.removeItem(atPath: path))\n            }\n            XCTAssertNoThrow(fileManager.createFile(atPath: path, contents: data, attributes: nil))\n        }\n        // Then\n        XCTAssertNoThrow(try database.close {\n            let filesSize = WCDBAssertNoThrowReturned(try self.database.getFilesSize()) ?? 0\n            XCTAssertEqual(filesSize, UInt64(expectedFilesSize))\n        })\n    }\n\n    func testUnsafeGetFilesSize() {\n        // Give\n        let data = \"testGetFilesSize\".data(using: .ascii)!\n        let expectedFilesSize = data.count * database.paths.count\n        for path in database.paths {\n            if fileManager.fileExists(atPath: path) {\n                XCTAssertNoThrow(try fileManager.removeItem(atPath: path))\n            }\n            XCTAssertNoThrow(fileManager.createFile(atPath: path, contents: data, attributes: nil))\n        }\n        // Then\n        let filesSize = WCDBAssertNoThrowReturned(try self.database.getFilesSize()) ?? 0\n        XCTAssertEqual(filesSize, UInt64(expectedFilesSize))\n    }\n}\n"
  },
  {
    "path": "src/swift/tests/other/HandleTest.swift",
    "content": "//\n// Created by 陈秋文 on 2023/8/13.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport XCTest\n#if TEST_WCDB_SWIFT\nimport WCDBSwift\n#else\nimport WCDB\n#endif\n\nclass HandleTests: DatabaseTestCase, @unchecked Sendable {\n\n    func testCancellationSignal() {\n        XCTAssertNoThrow(try database.create(table: TestObject.name, of: TestObject.self))\n        var objects: [TestObject] = []\n        for i in 0...10000 {\n            let object = TestObject()\n            object.variable1 = i\n            object.variable2 = \"\\(i)\"\n            objects.append(object)\n        }\n\n        XCTAssertNoThrow(try database.insert(objects, intoTable: TestObject.name))\n\n        var hasTestInterrupt = false\n        database.traceError { error in\n            guard error.level == .Error else {\n                return\n            }\n            XCTAssertEqual(error.code, .Interrupt)\n            hasTestInterrupt = true\n        }\n\n        let signal = Handle.CancellatiionSignal()\n        let group = DispatchGroup()\n        DispatchQueue(label: \"test\").async(group: group) {\n            let handle = try? self.database.getHandle()\n            guard let handle = handle else {\n                return\n            }\n            handle.attach(cancellationSignal: signal)\n            let objects: [TestObject]? = try? handle.getObjects(on: TestObject.Properties.all, fromTable: TestObject.name)\n            XCTAssertNil(objects)\n            handle.detachCancellationSignal()\n        }\n        usleep(10000)\n        signal.cancel()\n        group.wait()\n        XCTAssertTrue(hasTestInterrupt)\n        self.database.traceError(nil)\n    }\n\n    func testWriteWithHandleCountLimit() {\n        var maxHandleCount = 0\n        Database.globalTraceDatabaseOperation {\n            _, operation, info in\n            guard operation == .OpenHandle else {\n                return\n            }\n            maxHandleCount = max(maxHandleCount, info[Database.OperationInfoKeyHandleCount]?.intValue ?? 0)\n        }\n        XCTAssertNoThrow(try database.create(table: TestObject.name, of: TestObject.self))\n        let table = database.getTable(named: TestObject.name, of: TestObject.self)\n        let group = DispatchGroup()\n        for i in 0..<80 {\n            DispatchQueue(label: \"test\").async(group: group) {\n                do {\n                    switch i % 8 {\n                    case 0:\n                        let objects = Random.testObjects(startWith: i * 100, count: 100)\n                        try table.insert(objects)\n                    case 1:\n                        try table.update(on: TestObject.Properties.variable2, with: [\"abc\"], where: TestObject.Properties.variable1 > (i - 1) * 100 && TestObject.Properties.variable1 <= i * 100)\n                    case 2:\n                        try table.delete(where: TestObject.Properties.variable1 > ((i - 2) * 100 + 50) && TestObject.Properties.variable1 <= i * 100)\n                    case 3:\n                        try self.database.run(transaction: { _ in\n                            try table.update(on: TestObject.Properties.variable2, with: [\"abc2\"], where: TestObject.Properties.variable1 > (i - 1) * 100 && TestObject.Properties.variable1 <= i * 100)\n                        })\n                    case 4:\n                        let objects = Random.testObjects(startWith: i * 100, count: 100)\n                        try self.database.insert(objects, intoTable: TestObject.name)\n                    case 5:\n                        try self.database.update(table: TestObject.name, on: TestObject.Properties.variable2, with: [\"abc\"], where: TestObject.Properties.variable1 > (i - 1) * 100 && TestObject.Properties.variable1 <= i * 100)\n                    case 6:\n                        try self.database.delete(fromTable: TestObject.name, where: TestObject.Properties.variable1 > ((i - 2) * 100 + 50) && TestObject.Properties.variable1 <= i * 100)\n                    case 7:\n                        try self.database.run(transaction: { _ in\n                            try self.database.update(table: TestObject.name, on: TestObject.Properties.variable2, with: [\"abc2\"], where: TestObject.Properties.variable1 > (i - 1) * 100 && TestObject.Properties.variable1 <= i * 100)\n                        })\n                    default:\n                        break\n                    }\n                    usleep(100000)\n                } catch let error as WCDBError {\n                    XCTFail(error.description)\n                } catch let error {\n                    XCTFail(error.localizedDescription)\n                }\n            }\n        }\n        group.wait()\n        XCTAssertTrue(maxHandleCount <= 4)\n        Database.globalTraceDatabaseOperation(nil)\n    }\n\n    func testReadWithHandleCountLimit() {\n        var maxHandleCount = 0\n        Database.globalTraceDatabaseOperation {\n            _, operation, info in\n            guard operation == .OpenHandle else {\n                return\n            }\n            maxHandleCount = max(maxHandleCount, info[Database.OperationInfoKeyHandleCount]?.intValue ?? 0)\n        }\n        XCTAssertNoThrow(try database.create(table: TestObject.name, of: TestObject.self))\n        let table = database.getTable(named: TestObject.name, of: TestObject.self)\n        let objects = Random.testObjects(startWith: 0, count: 64000)\n        XCTAssertNoThrow(try table.insert(objects))\n        let group = DispatchGroup()\n\n        for i in 0..<640 {\n            DispatchQueue(label: \"test\").async(group: group) {\n                do {\n                    switch i % 10 {\n                    case 0:\n                        let ret = try table.getObjects(on: TestObject.Properties.all, limit: 100, offset: i * 100)\n                        XCTAssertEqual(ret.count, 100)\n                    case 1:\n                        let count = try self.database.getValue(from: StatementSelect().select(TestObject.Properties.any.count()).from(TestObject.name))\n                        XCTAssertEqual(count?.intValue, 64000)\n                    case 2:\n                        let ret = try table.getColumn(on: TestObject.Properties.variable2, limit: 100, offset: i * 100)\n                        XCTAssertEqual(ret.count, 100)\n                    case 3:\n                        let ret = try table.getRows(on: TestObject.Properties.all, limit: 100, offset: i * 100)\n                        XCTAssertEqual(ret.count, 100)\n                    case 4:\n                        let ret = try table.getRow(on: TestObject.Properties.all)\n                        XCTAssertEqual(ret.count, 2)\n                    case 5:\n                        let ret: [TestObject] = try self.database.getObjects(on: TestObject.Properties.all, fromTable: TestObject.name, limit: 100, offset: i * 100)\n                        XCTAssertEqual(ret.count, 100)\n                    case 6:\n                        let ret = try self.database.getColumn(on: TestObject.Properties.variable2, fromTable: TestObject.name, limit: 100, offset: i * 100)\n                        XCTAssertEqual(ret.count, 100)\n                    case 7:\n                        let ret = try self.database.getRows(on: TestObject.Properties.all, fromTable: TestObject.name, limit: 100, offset: i * 100)\n                        XCTAssertEqual(ret.count, 100)\n                    case 8:\n                        let ret = try self.database.getRow(on: TestObject.Properties.all, fromTable: TestObject.name)\n                        XCTAssertEqual(ret.count, 2)\n                    default:\n                        break\n                    }\n                    usleep(100000)\n                } catch let error as WCDBError {\n                    XCTFail(error.description)\n                } catch let error {\n                    XCTFail(error.localizedDescription)\n                }\n            }\n        }\n\n        group.wait()\n        XCTAssertTrue(maxHandleCount > 4 && maxHandleCount <= 32)\n        Database.globalTraceDatabaseOperation(nil)\n    }\n\n    func testReadWriteWithHandleCountLimit() {\n        var maxHandleCount = 0\n        Database.globalTraceDatabaseOperation({\n            _, operation, info in\n            guard operation == .OpenHandle else {\n                return\n            }\n            maxHandleCount = max(maxHandleCount, info[Database.OperationInfoKeyHandleCount]?.intValue ?? 0)\n        })\n        XCTAssertNoThrow(try database.create(table: TestObject.name, of: TestObject.self))\n        let table = database.getTable(named: TestObject.name, of: TestObject.self)\n        let objects = Random.testObjects(startWith: 0, count: 32000)\n        XCTAssertNoThrow(try table.insert(objects))\n        let group = DispatchGroup()\n\n        for i in 0..<320 {\n            DispatchQueue(label: \"test\").async(group: group) {\n                do {\n                    if i % 8 == 0 {\n                        let objects = Random.testObjects(startWith: i * 100 + 32000, count: 100)\n                        try table.insert(objects)\n                    } else {\n                        let ret = try table.getObjects(on: TestObject.Properties.all, limit: 100, offset: i * 100)\n                        XCTAssertEqual(ret.count, 100)\n                    }\n                    usleep(100000)\n                } catch let error as WCDBError {\n                    XCTFail(error.description)\n                } catch let error {\n                    XCTFail(error.localizedDescription)\n                }\n            }\n        }\n\n        group.wait()\n        XCTAssertTrue(maxHandleCount > 4 && maxHandleCount <= 32)\n        Database.globalTraceDatabaseOperation(nil)\n    }\n}\n"
  },
  {
    "path": "src/swift/tests/other/RepairTests.swift",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport XCTest\n#if TEST_WCDB_SWIFT\nimport WCDBSwift\n#else\nimport WCDB\n#endif\n\nclass RepairTests: DatabaseTestCase {\n    let preInsertedObjects: [TestObject] = {\n        let object1 = TestObject()\n        object1.variable1 = 1\n        object1.variable2 = \"object1\"\n        let object2 = TestObject()\n        object2.variable1 = 2\n        object2.variable2 = \"object2\"\n        return [object1, object2]\n    }()\n\n    func executeTest(_ operation: () throws -> Void) {\n        database.setCipher(key: nil)\n        XCTAssertNoThrow(try database.create(table: TestObject.name, of: TestObject.self))\n        XCTAssertNoThrow(try database.insert(preInsertedObjects, intoTable: TestObject.name))\n        XCTAssertNoThrow(try operation())\n        XCTAssertNoThrow(try database.removeFiles())\n        database.setCipher(key: Random.data(withLength: 32))\n        XCTAssertNoThrow(try database.create(table: TestObject.name, of: TestObject.self))\n        XCTAssertNoThrow(try database.insert(preInsertedObjects, intoTable: TestObject.name))\n        XCTAssertNoThrow(try operation())\n    }\n\n    func testBackup() {\n        executeTest {\n            XCTAssertFalse(self.fileManager.fileExists(atPath: self.database.firstMaterialPath))\n            XCTAssertFalse(self.fileManager.fileExists(atPath: self.database.lastMaterialPath))\n\n            XCTAssertNoThrow(try self.database.backup())\n            XCTAssertTrue(self.fileManager.fileExists(atPath: self.database.firstMaterialPath))\n            XCTAssertFalse(self.fileManager.fileExists(atPath: self.database.lastMaterialPath))\n\n            Thread.sleep(forTimeInterval: 1)\n\n            XCTAssertNoThrow(try self.database.backup())\n            XCTAssertTrue(self.fileManager.fileExists(atPath: self.database.firstMaterialPath))\n            XCTAssertTrue(self.fileManager.fileExists(atPath: self.database.lastMaterialPath))\n        }\n    }\n\n    func testBackupFilter() {\n        XCTAssertNoThrow(try database.create(table: TestObject.name, of: TestObject.self))\n        XCTAssertNoThrow(try database.insert(preInsertedObjects, intoTable: TestObject.name))\n        database.filterBackup(tableShouldBeBackedUp: nil)\n\n        XCTAssertNoThrow(try self.database.backup())\n        XCTAssertTrue(self.fileManager.fileExists(atPath: self.database.firstMaterialPath))\n        XCTAssertFalse(self.fileManager.fileExists(atPath: self.database.lastMaterialPath))\n\n        database.filterBackup { _ in\n            return false\n        }\n\n        Thread.sleep(forTimeInterval: 1)\n\n        XCTAssertNoThrow(try self.database.backup())\n        XCTAssertTrue(self.fileManager.fileExists(atPath: self.database.firstMaterialPath))\n        XCTAssertTrue(self.fileManager.fileExists(atPath: self.database.lastMaterialPath))\n\n        let firstSize = self.fileManager.fileSize(of: self.database.firstMaterialPath)\n        let lastSize = self.fileManager.fileSize(of: self.database.lastMaterialPath)\n        XCTAssertTrue(firstSize > lastSize)\n    }\n\n    func testAutoBackup() {\n        executeTest {\n            self.database.setAutoBackup(enable: true)\n            let newContent = TestObject()\n            newContent.variable1 = 3\n            newContent.variable2 = \"object3\"\n            XCTAssertFalse(self.fileManager.fileExists(atPath: self.database.firstMaterialPath))\n            XCTAssertNoThrow(try self.database.insert(newContent, intoTable: TestObject.name))\n            XCTAssertNoThrow(try self.database.passiveCheckpoint())\n#if WCDB_QUICK_TESTS\n            Thread.sleep(forTimeInterval: 12)\n#else\n            Thread.sleep(forTimeInterval: 606)\n#endif\n            XCTAssertTrue(self.fileManager.fileExists(atPath: self.database.firstMaterialPath))\n        }\n    }\n\n    func testDeposit() {\n        executeTest {\n            // 0.\n            let num0 = try? database.getValue(on: TestObject.Properties.any.count(), fromTable: TestObject.name)\n            XCTAssertTrue(num0 != nil && num0!.int32Value > 0)\n            var rowid = num0!.int32Value\n\n            // 1.\n            XCTAssertNoThrow(try database.backup())\n            XCTAssertNoThrow(try database.deposit())\n\n            let num1 = try? database.getValue(on: TestObject.Properties.any.count(), fromTable: TestObject.name)\n            XCTAssertTrue(num1 != nil && num1!.int32Value == 0)\n\n            let newObject = TestObject()\n            newObject.variable2 = \"object3\"\n            newObject.isAutoIncrement = true\n            XCTAssertNoThrow(try self.database.insert(newObject, intoTable: TestObject.name))\n            rowid += 1\n            XCTAssertTrue(newObject.lastInsertedRowID == rowid)\n\n            // 2.\n            XCTAssertNoThrow(try database.backup())\n            XCTAssertNoThrow(try database.deposit())\n            let num2 = try? database.getValue(on: TestObject.Properties.any.count(), fromTable: TestObject.name)\n            XCTAssertTrue(num2 != nil && num2!.int32Value == 0)\n\n            newObject.variable2 = \"object4\"\n            XCTAssertNoThrow(try self.database.insert(newObject, intoTable: TestObject.name))\n            rowid += 1\n            XCTAssertTrue(newObject.lastInsertedRowID == rowid)\n\n            XCTAssertTrue(self.fileManager.fileExists(atPath: self.database.factoryPath))\n            XCTAssertTrue(self.database.containDepositedFiles())\n            XCTAssertNoThrow(try self.database.removeDepositedFiles())\n            XCTAssertFalse(self.database.containDepositedFiles())\n            XCTAssertFalse(self.fileManager.fileExists(atPath: self.database.factoryPath))\n        }\n    }\n\n    func doTestRetrieve(expecting success: Bool) {\n        var lastPercentage = 0.0\n        var sanity = true\n        let score = WCDBAssertNoThrowReturned(try database.retrieve { percentage, increment in\n            if percentage - lastPercentage != increment || increment <= 0 {\n                XCTFail()\n                sanity = false\n            }\n            lastPercentage = percentage\n            return true\n        })\n        XCTAssertNotNil(score)\n        XCTAssertTrue(sanity)\n        XCTAssertTrue((success && score! == 1.0) || (!success && score! < 1.0))\n        XCTAssertTrue(lastPercentage == 1.0)\n    }\n\n    func doTestObjectsRetrieved(expecting success: Bool) {\n        let allObject: [TestObject]? = try? database.getObjects(fromTable: TestObject.name)\n        if success {\n            XCTAssertTrue(allObject != nil)\n            XCTAssertEqual(allObject!.sorted(), preInsertedObjects.sorted())\n        } else {\n            XCTAssertTrue(allObject == nil || allObject!.count == 0)\n        }\n    }\n\n    func testRetrieveWithBackupAndDeposit() {\n        executeTest {\n            XCTAssertNoThrow(try database.backup())\n            XCTAssertNoThrow(try database.deposit())\n            XCTAssertNoThrow(try database.corruptHeader())\n            doTestRetrieve(expecting: true)\n            doTestObjectsRetrieved(expecting: true)\n        }\n    }\n\n    func testRetrieveWithBackupAndWithoutDeposit() {\n        executeTest {\n            XCTAssertNoThrow(try database.backup())\n            XCTAssertNoThrow(try database.corruptHeader())\n            doTestRetrieve(expecting: true)\n            doTestObjectsRetrieved(expecting: true)\n        }\n    }\n\n    func testRetrieveWithoutBackupAndWithDeposit() {\n        executeTest {\n            XCTAssertNoThrow(try database.deposit())\n            XCTAssertNoThrow(try database.corruptHeader())\n            doTestRetrieve(expecting: true)\n            doTestObjectsRetrieved(expecting: true)\n        }\n    }\n\n    func testRetrieveWithoutBackupAndDeposit() {\n        executeTest {\n            XCTAssertNoThrow(try database.corruptHeader())\n            XCTAssertNoThrow(try database.deposit())\n            doTestRetrieve(expecting: false)\n            doTestObjectsRetrieved(expecting: false)\n        }\n    }\n\n    func testVacuum() {\n        executeTest {\n            var lastPercentage = 0.0\n            var sanity = true\n            try database.vacuum { percentage, increment in\n                if percentage - lastPercentage != increment || increment <= 0 {\n                    XCTFail()\n                    sanity = false\n                }\n                lastPercentage = percentage\n                return true\n            }\n            XCTAssertTrue(sanity)\n            XCTAssertTrue(lastPercentage == 1.0)\n            doTestObjectsRetrieved(expecting: true)\n        }\n    }\n\n    func testAutoVacuum() {\n        database.enableAutoVacuum(incremental: false)\n        var vacuumMode = try? database.getValue(from: StatementPragma().pragma(.autoVacuum))\n        XCTAssertNotNil(vacuumMode)\n        XCTAssertEqual(vacuumMode!.intValue, 1)\n\n        database.enableAutoVacuum(incremental: true)\n        vacuumMode = try? database.getValue(from: StatementPragma().pragma(.autoVacuum))\n        XCTAssertNotNil(vacuumMode)\n        XCTAssertEqual(vacuumMode!.intValue, 2)\n    }\n\n    func testIncrementalVacuum() {\n        database.enableAutoVacuum(incremental: true)\n        XCTAssertNoThrow(try database.create(table: TestObject.name, of: TestObject.self))\n        XCTAssertNoThrow(try database.insert(preInsertedObjects, intoTable: TestObject.name))\n        XCTAssertNoThrow(try database.truncateCheckpoint())\n\n        XCTAssertNoThrow(try database.drop(table: TestObject.name))\n        XCTAssertNoThrow(try database.truncateCheckpoint())\n        var freelist = try? database.getValue(from: StatementPragma().pragma(.freelistCount))\n        XCTAssertNotNil(freelist)\n        XCTAssertTrue(freelist!.intValue > 0)\n\n        XCTAssertNoThrow(try database.incrementalVacuum(pages: 0))\n        freelist = try? database.getValue(from: StatementPragma().pragma(.freelistCount))\n        XCTAssertNotNil(freelist)\n        XCTAssertTrue(freelist!.intValue == 0)\n    }\n}\n"
  },
  {
    "path": "src/swift/tests/other/TokenizerTests.swift",
    "content": "//\n// Created by qiuwenchen on 2022/11/6.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport XCTest\n#if TEST_WCDB_SWIFT\nimport WCDBSwift\n#else\nimport WCDB\n#endif\n\nclass TokenizerTests: DatabaseTestCase {\n\n    class CustomTokenizer: Tokenizer {\n\n        var hasCheckParameter: Bool = false\n        var input: UnsafePointer<Int8>?\n        var inputLength: Int = 0\n        var lastLocation: Int = 0\n        var position: Int = 0\n\n        static let fts3Name = \"fts3_custom_tokenizer\"\n        static let fts5Name = \"fts5_custom_tokenizer\"\n        static let testParameter1 = \"testParameter1\"\n        static let testParameter2 = \"testParameter2\"\n\n        required init(args: [String]) {\n            if args.contains(where: { arg in\n                return arg == CustomTokenizer.testParameter1\n            }), args.contains(where: { arg in\n                return arg == CustomTokenizer.testParameter2\n            }) {\n                hasCheckParameter = true\n            }\n        }\n\n        func load(input: UnsafePointer<Int8>?, length: Int, flags: Int) {\n            self.input = input\n            self.inputLength = length\n            self.lastLocation = 0\n            self.position = 0\n        }\n\n        func nextToken(ppToken: UnsafeMutablePointer<UnsafePointer<Int8>?>,\n                       pnBytes: UnsafeMutablePointer<Int32>,\n                       piStart: UnsafeMutablePointer<Int32>,\n                       piEnd: UnsafeMutablePointer<Int32>,\n                       pFlags: UnsafeMutablePointer<Int32>?,\n                       piPosition: UnsafeMutablePointer<Int32>?) -> TokenizerErrorCode {\n            guard hasCheckParameter, inputLength > lastLocation, let input = input else {\n                return .Done\n            }\n            var start: Int = lastLocation\n            var end: Int = lastLocation\n\n            for location in lastLocation..<inputLength {\n                if input.advanced(by: location).pointee == 32 /* space */ {\n                    if start == end {\n                        start = location + 1\n                        end = start\n                    } else {\n                        break\n                    }\n                } else {\n                    end = location + 1\n                }\n            }\n            if start == end {\n                return .Done\n            }\n            lastLocation = end\n            ppToken.pointee = input.advanced(by: start)\n            pnBytes.pointee = Int32(end - start)\n            piStart.pointee = Int32(start)\n            piEnd.pointee = Int32(end)\n            position += 1\n            if let piPosition = piPosition {\n                piPosition.pointee = Int32(position)\n            }\n            return.OK\n        }\n    }\n\n    final class FTS3Object: TableCodable, Named {\n        var content: String = \"\"\n\n        enum CodingKeys: String, CodingTableKey {\n            typealias Root = FTS3Object\n            case content\n            nonisolated(unsafe) static let objectRelationalMapping = TableBinding(CodingKeys.self) {\n                BindVirtualTable(withModule: .FTS3, and: CustomTokenizer.fts3Name, CustomTokenizer.testParameter1, CustomTokenizer.testParameter2)\n            }\n        }\n    }\n\n    func testCustomFTS3Tokenizer() {\n        // Give\n        Database.register(tokenizer: CustomTokenizer.self, of: CustomTokenizer.fts3Name, of: .FTS3)\n        self.database.add(tokenizer: CustomTokenizer.fts3Name)\n        let tableName = FTS3Object.name\n        let obj = FTS3Object()\n        obj.content = \"  test content wcdb custom tokenizer  \"\n        // When\n        XCTAssertNoThrow(try self.database.create(virtualTable: tableName, of: FTS3Object.self))\n        XCTAssertNoThrow(try self.database.insert(obj, intoTable: tableName))\n        // Then\n        let matchObj: FTS3Object? = WCDBAssertNoThrowReturned(try self.database.getObject(on: FTS3Object.Properties.all, fromTable: tableName, where: FTS3Object.Properties.content.match(\"custom content\")))\n        XCTAssertNotNil(matchObj)\n        XCTAssertEqual(matchObj!.content, obj.content)\n    }\n\n    final class FTS5Object: TableCodable, Named {\n        var content: String = \"\"\n\n        enum CodingKeys: String, CodingTableKey {\n            typealias Root = FTS5Object\n            case content\n            nonisolated(unsafe) static let objectRelationalMapping = TableBinding(CodingKeys.self) {\n                BindVirtualTable(withModule: .FTS5, and: CustomTokenizer.fts5Name, CustomTokenizer.testParameter1, CustomTokenizer.testParameter2)\n            }\n        }\n    }\n\n    func testCustomFTS5Tokenizer() {\n        // Give\n        Database.register(tokenizer: CustomTokenizer.self, of: CustomTokenizer.fts5Name, of: .FTS5)\n        self.database.add(tokenizer: CustomTokenizer.fts5Name)\n        let tableName = FTS5Object.name\n        let obj = FTS5Object()\n        obj.content = \"  test content wcdb custom tokenizer  \"\n        // When\n        XCTAssertNoThrow(try self.database.create(virtualTable: tableName, of: FTS5Object.self))\n        XCTAssertNoThrow(try self.database.insert(obj, intoTable: tableName))\n        // Then\n        let matchObj: FTS5Object? = WCDBAssertNoThrowReturned(try self.database.getObject(on: FTS5Object.Properties.all, fromTable: tableName, where: FTS5Object.Properties.content.match(\"custom content\")))\n        XCTAssertNotNil(matchObj)\n        XCTAssertEqual(matchObj!.content, obj.content)\n    }\n}\n"
  },
  {
    "path": "src/swift/tests/other/TracerTests.swift",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport XCTest\n#if TEST_WCDB_SWIFT\nimport WCDBSwift\n#else\nimport WCDB\n#endif\n\nclass TracerTests: DatabaseTestCase, @unchecked Sendable {\n\n    func reset() {\n        Database.globalTracePerformance(nil)\n        Database.globalTraceSQL(nil)\n        Database.globalTraceError(nil)\n    }\n\n    override func setUp() {\n        super.setUp()\n        reset()\n    }\n\n    override func tearDown() {\n        reset()\n        super.tearDown()\n    }\n\n    func testTraceSQL() {\n        // Give\n        let expectedSQL = \"SELECT * FROM sqlite_master\"\n\n        // Then\n        var pass = false\n        Database.globalTraceSQL { (tag, path, _, sql, _) in\n            guard path == self.database.path else {\n                return\n            }\n            XCTAssertEqual(tag, self.database.tag)\n            if sql == expectedSQL {\n                pass = true\n            }\n        }\n\n        // When\n        XCTAssertNoThrow(try database.getRows(on: Master.Properties.any, fromTable: Master.builtinTableName))\n\n        XCTAssertTrue(pass)\n    }\n\n    func testGlobalTraceError() {\n        // Give\n        let tableName = \"nonexistentTable\"\n        let expectedTag = self.database.tag\n        let expectedErrorCode = 1\n        let expectedErrorMessage = \"no such table: \\(tableName)\"\n        let expectedSQL = \"SELECT * FROM \\(tableName)\"\n        let expectedPath = self.database.path\n\n        // Then\n        var `catch` = false\n        Database.globalTraceError { (error: WCDBError) in\n            let tag = error.tag\n            XCTAssertNotNil(tag)\n            XCTAssertEqual(tag!, expectedTag)\n\n            let code = error.code\n            XCTAssertEqual(code.rawValue, expectedErrorCode)\n\n            let message = error.message\n            XCTAssertNotNil(message)\n            XCTAssertEqual(message!, expectedErrorMessage)\n\n            let sql = error.sql\n            XCTAssertNotNil(sql)\n            XCTAssertEqual(sql!, expectedSQL)\n\n            let path = error.path\n            XCTAssertNotNil(path)\n            XCTAssertEqual(path!, expectedPath)\n\n            XCTAssertNil(error.extendedCode)\n\n            let wrongStringType = error.infos[.tag]?.stringValue\n            XCTAssertNotNil(wrongStringType)\n            XCTAssertEqual(wrongStringType, String(expectedTag!))\n\n            let wrongIntType = error.infos[.path]?.intValue\n            XCTAssertNotNil(wrongIntType)\n            XCTAssertEqual(wrongIntType!, 0)\n\n            `catch` = true\n            print(error)\n        }\n\n        // When\n        XCTAssertThrowsError(\n            try database.getRows(on: Column.all(), fromTable: tableName)\n        )\n\n        XCTAssertTrue(`catch`)\n    }\n\n    func testTraceError() {\n        // Give\n        let tableName = \"nonexistentTable\"\n        let expectedTag = self.database.tag\n        let expectedErrorCode = 1\n        let expectedErrorMessage = \"no such table: \\(tableName)\"\n        let expectedSQL = \"SELECT * FROM \\(tableName)\"\n        let expectedPath = self.database.path\n\n        // Then\n        var `catch` = false\n        database.traceError { (error: WCDBError) in\n            let tag = error.tag\n            XCTAssertNotNil(tag)\n            XCTAssertEqual(tag!, expectedTag)\n\n            let code = error.code\n            XCTAssertEqual(code.rawValue, expectedErrorCode)\n\n            let message = error.message\n            XCTAssertNotNil(message)\n            XCTAssertEqual(message!, expectedErrorMessage)\n\n            let sql = error.sql\n            XCTAssertNotNil(sql)\n            XCTAssertEqual(sql!, expectedSQL)\n\n            let path = error.path\n            XCTAssertNotNil(path)\n            XCTAssertEqual(path!, expectedPath)\n\n            XCTAssertNil(error.extendedCode)\n\n            let wrongStringType = error.infos[.tag]?.stringValue\n            XCTAssertNotNil(wrongStringType)\n            XCTAssertEqual(wrongStringType, String(expectedTag!))\n\n            let wrongIntType = error.infos[.path]?.intValue\n            XCTAssertNotNil(wrongIntType)\n            XCTAssertEqual(wrongIntType!, 0)\n\n            `catch` = true\n            print(error)\n        }\n\n        // When\n        XCTAssertThrowsError(\n            try database.getRows(on: Column.all(), fromTable: tableName)\n        )\n\n        XCTAssertTrue(`catch`)\n    }\n\n    final class TracerObject: TableCodable, Named {\n        var variable = 0\n        enum CodingKeys: String, CodingTableKey {\n            typealias Root = TracerObject\n            case variable\n            nonisolated(unsafe) static let objectRelationalMapping = TableBinding(CodingKeys.self) {\n                BindColumnConstraint(variable, isPrimary: true, orderBy: .ascending, isAutoIncrement: true)\n            }\n        }\n        var isAutoIncrement: Bool = false\n    }\n\n    func testGlobalTracePerformance() {\n        // Give\n        let tableName = TracerObject.name\n        let expectedTag = self.database.tag\n        var objects: [TestObject] = []\n        for _ in (0..<1000) {\n            let object = TestObject()\n            object.isAutoIncrement = true\n            object.variable2 = Random.string(withLength: 4096)\n            objects.append(object)\n        }\n        var testCount = 0\n        var lastSQLIsInsert = false\n        // Then\n        Database.globalTracePerformance { (tag, path, _, sql, info) in\n            guard path == self.database.path else {\n                return\n            }\n            XCTAssertEqual(tag, expectedTag)\n            if sql.hasPrefix(\"COMMIT\") && lastSQLIsInsert {\n                XCTAssertTrue(info.costInNanoseconds > 0)\n                XCTAssertTrue(info.tablePageWriteCount > 0)\n                XCTAssertTrue(info.indexPageWriteCount == 0)\n                XCTAssertTrue(info.overflowPageWriteCount > 0)\n                XCTAssertTrue(info.tablePageReadCount == 0)\n                XCTAssertTrue(info.indexPageReadCount == 0)\n                XCTAssertTrue(info.overflowPageReadCount == 0)\n                testCount += 1\n            } else if sql.hasPrefix(\"CREATE INDEX\") {\n                XCTAssertTrue(info.costInNanoseconds > 0)\n                XCTAssertTrue(info.tablePageWriteCount == 1)\n                XCTAssertTrue(info.indexPageWriteCount > 0)\n                XCTAssertTrue(info.overflowPageWriteCount == objects.count)\n                XCTAssertTrue(info.tablePageReadCount > 0)\n                XCTAssertTrue(info.indexPageReadCount >= 0)\n                XCTAssertTrue(info.overflowPageReadCount == objects.count)\n                testCount += 1\n            } else if sql.hasPrefix(\"SELECT\") {\n                XCTAssertTrue(info.costInNanoseconds > 0)\n                XCTAssertTrue(info.tablePageWriteCount == 0)\n                XCTAssertTrue(info.indexPageWriteCount == 0)\n                XCTAssertTrue(info.overflowPageWriteCount == 0)\n                testCount += 1\n                if sql.hasSuffix(\"ORDER BY variable2\") {\n                    XCTAssertTrue(info.tablePageReadCount == 0)\n                    XCTAssertTrue(info.indexPageReadCount > 0)\n                    XCTAssertTrue(info.overflowPageReadCount == objects.count)\n                } else {\n                    XCTAssertTrue(info.tablePageReadCount > 0)\n                    XCTAssertTrue(info.indexPageReadCount == 0)\n                    XCTAssertTrue(info.overflowPageReadCount == objects.count)\n                }\n            }\n            lastSQLIsInsert = sql.hasPrefix(\"INSERT\")\n        }\n\n        // Give\n        let database = Database(at: self.recommendedPath)\n        XCTAssertNoThrow(try database.close {\n            try database.removeFiles()\n        })\n        database.tag = self.recommendTag\n\n        // When\n        XCTAssertNoThrow(try database.create(table: tableName, of: TestObject.self))\n        XCTAssertNoThrow(try database.insert(objects, intoTable: tableName))\n        XCTAssertNoThrow(try database.create(index: \"testIndex\", with: TestObject.Properties.variable2, forTable: tableName))\n        let result1: [TestObject] = WCDBAssertNoThrowReturned(try self.database.getObjects(fromTable: tableName))\n        XCTAssertTrue(result1.count == objects.count)\n        let result2: [TestObject] = WCDBAssertNoThrowReturned(try self.database.getObjects(fromTable: tableName, orderBy: [TestObject.Properties.variable2]))\n        XCTAssertTrue(result2.count == objects.count)\n        XCTAssertNoThrow(database.close())\n        XCTAssertTrue(testCount == 4)\n    }\n\n    func testTraceRollback() {\n        // Give\n        let tableName = TracerObject.name\n        let expectedTag = self.database.tag\n        let expectedSQL = \"INSERT INTO \\(tableName)(variable) VALUES(?1)\"\n        let expectedRollback = \"ROLLBACK\"\n\n        // Then\n        var catchInsert = false\n        var catchRollback = false\n        Database.globalTraceSQL { (tag, path, _, sql, _) in\n            guard path == self.database.path else {\n                return\n            }\n            XCTAssertEqual(tag, expectedTag)\n            if sql == expectedSQL {\n                catchInsert = true\n            } else if sql == expectedRollback {\n                catchRollback = true\n            }\n        }\n\n        // Give\n        XCTAssertNoThrow(try database.close {\n            try self.database.removeFiles()\n        })\n\n        // When\n        XCTAssertNoThrow(try database.create(table: tableName, of: TracerObject.self))\n        let template = TracerObject()\n        template.isAutoIncrement = true\n        let objects = [TracerObject](repeating: template, count: 100000)\n        XCTAssertNoThrow(try database.run(controllableTransaction: { (_) -> Bool in\n            try self.database.insert(objects, intoTable: tableName)\n            return false\n        }))\n        XCTAssertNoThrow(database.close())\n\n        XCTAssertTrue(catchInsert && catchRollback)\n    }\n\n    func testTraceDatabaseOperation() {\n        var tag = 0\n        var path = \"\"\n        var openCount = 0\n        var tableCount = 0\n        var indexCount = 0\n        Database.globalTraceDatabaseOperation {\n            (database, operation, info) in\n            switch operation {\n            case .Create:\n                path = database.path\n            case .SetTag:\n                tag = database.tag ?? 0\n            case .OpenHandle:\n                openCount += 1\n                XCTAssertEqual(info[Database.OperationInfoKeyHandleCount]?.intValue, 1)\n                XCTAssertTrue(info[Database.OperationInfoKeyHandleOpenTime]?.intValue ?? 0 > 0)\n                XCTAssertTrue(info[Database.OperationInfoKeyHandleOpenCPUTime]?.intValue ?? 0 > 0)\n                XCTAssertTrue(info[Database.OperationInfoKeySchemaUsage]?.intValue ?? 0 > 0)\n                XCTAssertEqual(info[Database.OperationInfoKeyTriggerCount]?.intValue, 0)\n                tableCount = info[Database.OperationInfoKeyTableCount]?.intValue ?? 0\n                indexCount = info[Database.OperationInfoKeyIndexCount]?.intValue ?? 0\n            }\n        }\n        let database = Database(at: \"\\(self.recommendedPath.path)_testOperation\")\n        database.tag = self.recommendTag\n        XCTAssertNoThrow(try database.create(table: TracerObject.name, of: TracerObject.self))\n        XCTAssertNoThrow(try database.exec(StatementCreateIndex().create(index: \"testIndex\").on(table: TracerObject.name).indexesBy(TracerObject.Properties.variable)))\n\n        XCTAssertTrue(tag == database.tag)\n        XCTAssertTrue(path == database.path)\n        XCTAssertTrue(openCount == 1)\n\n        database.close()\n\n        let template = TracerObject()\n        template.isAutoIncrement = true\n        let objects = [TracerObject](repeating: template, count: 10)\n        XCTAssertNoThrow(try database.insert(objects, intoTable: TracerObject.name))\n\n        XCTAssertTrue(openCount == 2)\n        XCTAssertTrue(tableCount == 4)\n        XCTAssertTrue(indexCount == 1)\n        Database.globalTracePerformance(nil)\n    }\n\n    var dispatchTid: UInt64 = 0\n    var objects: [TestObject] = []\n    func testGlobalTraceDatabaseBusy() {\n        var testTid: UInt64 = 0\n        Database.globalTraceBusy({ tag, path, tid, sql in\n            XCTAssertEqual(tag, self.database.tag)\n            XCTAssertEqual(path, self.database.path)\n            XCTAssertEqual(sql, \"INSERT INTO TestObject(variable1, variable2) VALUES(?1, ?2)\")\n            testTid = tid\n        }, timeOut: 0.1)\n\n        XCTAssertNoThrow(try database.create(table: TestObject.name, of: TestObject.self))\n        let group = DispatchGroup()\n        let queue = DispatchQueue(label: String(recommendTag), attributes: .concurrent)\n        objects = Random.testObjects(startWith: 0, count: 50000)\n        queue.async(group: group, execute: {\n            pthread_threadid_np(nil, &self.dispatchTid)\n            try! self.database.insert(self.objects, intoTable: TestObject.name)\n        })\n        usleep(10000)\n        XCTAssertNoThrow(try database.insert(TestObject(variable1: 100001, variable2: \"abdad\"),\n                                             intoTable: TestObject.name))\n\n        print(\"finish insert2\")\n        group.wait()\n        XCTAssertTrue(testTid != 0 && testTid == dispatchTid)\n        Database.globalTraceBusy(nil, timeOut: 0)\n    }\n}\n"
  },
  {
    "path": "src/swift/tests/winq/identifier/BindParameterTests.swift",
    "content": "//\n// Created by qiuwenchen on 2022/5/27.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport XCTest\n#if TEST_WCDB_SWIFT\nimport WCDBSwift\n#else\nimport WCDB\n#endif\n\nclass BindParameterTests: BaseTestCase {\n\n    func testBindParameter() {\n        WINQAssertEqual(BindParameter(1), \"?1\")\n\n        WINQAssertEqual(BindParameter(\"testName\"), \":testName\")\n\n        WINQAssertEqual(BindParameter.at(named: \"testName\"), \"@testName\")\n\n        WINQAssertEqual(BindParameter.dollar(named: \"testName\"), \"$testName\")\n\n        WINQAssertEqual(BindParameter.colon(named: \"testName\"), \":testName\")\n\n        WINQAssertEqual(BindParameter.def, \"?\")\n        WINQAssertEqual(BindParameter._1, \"?1\")\n        WINQAssertEqual(BindParameter._2, \"?2\")\n        WINQAssertEqual(BindParameter._3, \"?3\")\n        WINQAssertEqual(BindParameter._4, \"?4\")\n        WINQAssertEqual(BindParameter._5, \"?5\")\n        WINQAssertEqual(BindParameter._6, \"?6\")\n        WINQAssertEqual(BindParameter._7, \"?7\")\n        WINQAssertEqual(BindParameter._8, \"?8\")\n        WINQAssertEqual(BindParameter._9, \"?9\")\n        WINQAssertEqual(BindParameter._10, \"?10\")\n    }\n}\n"
  },
  {
    "path": "src/swift/tests/winq/identifier/ColumnConstraintTests.swift",
    "content": "//\n// Created by qiuwenchen on 2022/5/29.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport Foundation\n#if TEST_WCDB_SWIFT\nimport WCDBSwift\n#else\nimport WCDB\n#endif\n\nclass ColumnConstraintTests: BaseTestCase {\n\n    func testColumnConstraint() {\n        WINQAssertEqual(ColumnConstraint(), \"\")\n\n        let name = \"testColumnConstraint\"\n\n        WINQAssertEqual(ColumnConstraint().primaryKey(), \"PRIMARY KEY\")\n\n        WINQAssertEqual(ColumnConstraint(named: name).primaryKey(), \"CONSTRAINT \\(name) PRIMARY KEY\")\n\n        WINQAssertEqual(ColumnConstraint().primaryKey().order(.ascending), \"PRIMARY KEY ASC\")\n\n        WINQAssertEqual(ColumnConstraint().primaryKey().conflict(action: .Abort), \"PRIMARY KEY ON CONFLICT ABORT\")\n\n        WINQAssertEqual(ColumnConstraint().primaryKey().autoIncrement(), \"PRIMARY KEY AUTOINCREMENT\")\n\n        WINQAssertEqual(ColumnConstraint(named: name).notNull(), \"CONSTRAINT \\(name) NOT NULL\")\n\n        WINQAssertEqual(ColumnConstraint().notNull().conflict(action: .Abort), \"NOT NULL ON CONFLICT ABORT\")\n\n        WINQAssertEqual(ColumnConstraint(named: name).unique(), \"CONSTRAINT \\(name) UNIQUE\")\n\n        WINQAssertEqual(ColumnConstraint(named: name).unique().conflict(action: .Abort), \"CONSTRAINT \\(name) UNIQUE ON CONFLICT ABORT\")\n\n        WINQAssertEqual(ColumnConstraint(named: name).collate(with: \"BINARY\"), \"CONSTRAINT \\(name) COLLATE BINARY\")\n\n    }\n}\n"
  },
  {
    "path": "src/swift/tests/winq/identifier/ColumnDefTests.swift",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport XCTest\n#if TEST_WCDB_SWIFT\nimport WCDBSwift\n#else\nimport WCDB\n#endif\n\nclass ColumnDefTests: BaseTestCase {\n\n    func generateColumnDef() -> ColumnDef {\n        return ColumnDef(with: Column(named: \"testColumnDef\"), and: .integer32)\n    }\n\n    func testColumnDef() {\n        WINQAssertEqual(\n            ColumnDef(with: Column(named: \"testColumnDef\"), and: .float),\n            \"testColumnDef REAL\"\n        )\n\n        WINQAssertEqual(\n            ColumnDef(with: Column(named: \"testColumnDef\"), and: .text),\n            \"testColumnDef TEXT\"\n        )\n\n        WINQAssertEqual(\n            ColumnDef(with: Column(named: \"testColumnDef\"), and: .BLOB),\n            \"testColumnDef BLOB\"\n        )\n\n        WINQAssertEqual(\n            ColumnDef(with: Column(named: \"testColumnDef\"), and: .null),\n            \"testColumnDef NULL\"\n        )\n\n        WINQAssertEqual(\n            generateColumnDef().makePrimary(),\n            \"testColumnDef INTEGER PRIMARY KEY\"\n        )\n\n        WINQAssertEqual(\n            generateColumnDef().makePrimary(orderBy: .ascending),\n            \"testColumnDef INTEGER PRIMARY KEY ASC\"\n        )\n\n        WINQAssertEqual(\n            generateColumnDef().makePrimary(isAutoIncrement: true),\n            \"testColumnDef INTEGER PRIMARY KEY AUTOINCREMENT\"\n        )\n\n        WINQAssertEqual(\n            generateColumnDef().makePrimary(onConflict: .Ignore),\n            \"testColumnDef INTEGER PRIMARY KEY ON CONFLICT IGNORE\"\n        )\n\n        WINQAssertEqual(\n            generateColumnDef().makeNotNull(),\n            \"testColumnDef INTEGER NOT NULL\"\n        )\n\n        WINQAssertEqual(\n            generateColumnDef().makeUnique(),\n            \"testColumnDef INTEGER UNIQUE\"\n        )\n\n        WINQAssertEqual(\n            generateColumnDef().makeForeignKey(ForeignKey().references(with: \"testColumnDefTable\")),\n            \"testColumnDef INTEGER REFERENCES testColumnDefTable\"\n        )\n\n        WINQAssertEqual(\n            generateColumnDef().makeDefault(to: ModuleExpression(nil)),\n            \"testColumnDef INTEGER DEFAULT NULL\"\n        )\n\n        WINQAssertEqual(\n            generateColumnDef().makeDefault(to: -1),\n            \"testColumnDef INTEGER DEFAULT -1\"\n        )\n\n        WINQAssertEqual(\n            generateColumnDef().makeDefault(to: 171798691840),\n            \"testColumnDef INTEGER DEFAULT 171798691840\"\n        )\n\n        WINQAssertEqual(\n            generateColumnDef().makeDefault(to: false),\n            \"testColumnDef INTEGER DEFAULT 0\"\n        )\n\n        WINQAssertEqual(\n            generateColumnDef().makeDefault(to: \"SampleText\"),\n            \"testColumnDef INTEGER DEFAULT 'SampleText'\"\n        )\n\n        WINQAssertEqual(\n            generateColumnDef().makeDefault(to: 1.2),\n            \"testColumnDef INTEGER DEFAULT 1.2\"\n        )\n\n        WINQAssertEqual(\n            generateColumnDef().makeDefault(to: \"SampleText\".data(using: .ascii)!),\n            \"testColumnDef INTEGER DEFAULT 'SampleText'\"\n        )\n\n        WINQAssertEqual(\n            generateColumnDef().makeDefault(to: 1),\n            \"testColumnDef INTEGER DEFAULT 1\"\n        )\n\n        WINQAssertEqual(\n            generateColumnDef().makeDefault(to: LiteralValue.currentDate()),\n            \"testColumnDef INTEGER DEFAULT CURRENT_DATE\"\n        )\n\n        WINQAssertEqual(\n            generateColumnDef().makeDefault(to: LiteralValue.currentTime()),\n            \"testColumnDef INTEGER DEFAULT CURRENT_TIME\"\n        )\n\n        WINQAssertEqual(\n            generateColumnDef().makeDefault(to: LiteralValue.currentTimestamp()),\n            \"testColumnDef INTEGER DEFAULT CURRENT_TIMESTAMP\")\n    }\n}\n"
  },
  {
    "path": "src/swift/tests/winq/identifier/ColumnTests.swift",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport XCTest\n#if TEST_WCDB_SWIFT\nimport WCDBSwift\n#else\nimport WCDB\n#endif\n\nclass ColumnTests: BaseTestCase {\n\n    func testColumn() {\n        WINQAssertEqual(Column.all(), \"*\")\n\n        WINQAssertEqual(Column.rowid(), \"rowid\")\n\n        WINQAssertEqual(Column.rowid().as(\"rowidAlias\"), \"rowid AS rowidAlias\")\n\n        WINQAssertEqual(Column(named: \"testColumn\"), \"testColumn\")\n\n        WINQAssertEqual(Column(named: \"testColumn\").in(table: \"TestTable\"), \"TestTable.testColumn\")\n\n        WINQAssertEqual(Column(named: \"testColumn\").in(table: \"TestTable\").of(schema: \"TestSchema\"), \"TestSchema.TestTable.testColumn\")\n    }\n}\n"
  },
  {
    "path": "src/swift/tests/winq/identifier/ColumnTypeTests.swift",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport XCTest\n#if TEST_WCDB_SWIFT\nimport WCDBSwift\n#else\nimport WCDB\n#endif\n\nclass ColumnTypeTests: BaseTestCase {\n\n    func testColumnType() {\n\n        XCTAssertEqual(Int32.columnType, .integer32)\n\n        XCTAssertEqual(Int64.columnType, .integer64)\n\n        XCTAssertEqual(Double.columnType, .float)\n\n        XCTAssertEqual(String.columnType, .text)\n\n        XCTAssertEqual(Data.columnType, .BLOB)\n    }\n}\n"
  },
  {
    "path": "src/swift/tests/winq/identifier/CommonTableExpressionTests.swift",
    "content": "//\n// Created by qiuwenchen on 2022/5/30.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport Foundation\n#if TEST_WCDB_SWIFT\nimport WCDBSwift\n#else\nimport WCDB\n#endif\n\nclass CommonTableExpressionTests: BaseTestCase {\n\n    func testCommonTableExpression() {\n        WINQAssertEqual(CommonTableExpression(\"testTable\").as(StatementSelect().select(1)), \"testTable AS(SELECT 1)\")\n\n        WINQAssertEqual(CommonTableExpression(\"testTable\").column(Column(named: \"testColumn1\")).as(StatementSelect().select(1)), \"testTable(testColumn1) AS(SELECT 1)\")\n\n        WINQAssertEqual(CommonTableExpression(\"testTable\").column(Column(named: \"testColumn1\")).column(Column(named: \"testColumn2\")).as(StatementSelect().select(1)), \"testTable(testColumn1, testColumn2) AS(SELECT 1)\")\n    }\n}\n"
  },
  {
    "path": "src/swift/tests/winq/identifier/ExpressionTests.swift",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport XCTest\n#if TEST_WCDB_SWIFT\nimport WCDBSwift\n#else\nimport WCDB\n#endif\n\nclass ExpresssionTests: BaseTestCase {\n\n    func testExpression() {\n        let integerExpression: ModuleExpression = 1\n        WINQAssertEqual(integerExpression, \"1\")\n\n        let floatExpression: ModuleExpression = 1.1\n        WINQAssertEqual(floatExpression, \"1.1000000000000001\")\n\n        let stringExpression: ModuleExpression = \"1\"\n        WINQAssertEqual(stringExpression, \"'1'\")\n\n        let nilExpression: ModuleExpression = nil\n        WINQAssertEqual(nilExpression, \"NULL\")\n\n        let boolExpression: ModuleExpression = false\n        WINQAssertEqual(boolExpression, \"FALSE\")\n\n        let columnExpression: ModuleExpression = Column(named: \"testColumn\").asExpression()\n        WINQAssertEqual(columnExpression.asResultColumn(), \"testColumn\")\n        WINQAssertEqual(columnExpression.order(.descending), \"testColumn DESC\")\n\n        WINQAssertEqual(Expression(with: BindParameter(1)), \"?1\")\n\n        WINQAssertEqual(Expression.cast(1).as(.integer64), \"CAST(1 AS INTEGER)\")\n\n        WINQAssertEqual((Column.rowid() + 1).as(\"rowidAddOne\"), \"rowid + 1 AS rowidAddOne\")\n\n        WINQAssertEqual(Expression.windowFunction(\"testWindowFunction\").invoke().arguments(1).filter(1), \"testWindowFunction(1) FILTER(WHERE 1)\")\n        WINQAssertEqual(Expression.windowFunction(\"testWindowFunction\").invoke().arguments(1, 2).filter(1).over(\"testWindow\"), \"testWindowFunction(1, 2) FILTER(WHERE 1) OVER testWindow\")\n        WINQAssertEqual(Expression.windowFunction(\"testWindowFunction\").invoke().arguments(1, 2).filter(1).over(WindowDef().partition(1, 2)), \"testWindowFunction(1, 2) FILTER(WHERE 1) OVER(PARTITION BY 1, 2)\")\n    }\n\n    func testCaseWhenThen() {\n        WINQAssertEqual(Expression.case().when(2).then(3).else(4), \"CASE WHEN 2 THEN 3 ELSE 4 END\")\n        WINQAssertEqual(Expression.case(1).when(2).then(3).else(4), \"CASE 1 WHEN 2 THEN 3 ELSE 4 END\")\n        WINQAssertEqual(Expression.case(1).when(2).then(3).when(4).then(5).else(6), \"CASE 1 WHEN 2 THEN 3 WHEN 4 THEN 5 ELSE 6 END\")\n        WINQAssertEqual(Expression.case(1).when(2).then(3), \"CASE 1 WHEN 2 THEN 3 END\")\n    }\n\n    final class OperableObject: TableCodable {\n        var left: Int = 0\n        var right: String = \"\"\n        enum CodingKeys: String, CodingTableKey {\n            typealias Root = OperableObject\n            case left\n            case right\n            nonisolated(unsafe) static let objectRelationalMapping = TableBinding(CodingKeys.self)\n        }\n    }\n\n    func testOperable() {\n        // Give\n        let left = OperableObject.Properties.left\n        let right = OperableObject.Properties.right\n\n        // Then\n        WINQExpressionAssertEqual(!left, \"NOT left\")\n        WINQExpressionAssertEqual(+left, \"+left\")\n        WINQExpressionAssertEqual(-left, \"-left\")\n        WINQExpressionAssertEqual(~left, \"~left\")\n\n        WINQExpressionAssertEqual(left.concat(right), \"left || right\")\n\n        WINQExpressionAssertEqual(left.substr(start: 1, length: 2), \"SUBSTR(left, 1, 2)\")\n\n        WINQExpressionAssertEqual(left.like(right), \"left LIKE right\")\n\n        WINQExpressionAssertEqual(left.glob(right), \"left GLOB right\")\n\n        WINQExpressionAssertEqual(left.match(right), \"left MATCH right\")\n\n        WINQExpressionAssertEqual(left.regexp(right), \"left REGEXP right\")\n\n        WINQExpressionAssertEqual(left.notLike(right), \"left NOT LIKE right\")\n\n        WINQExpressionAssertEqual(left.notGlob(right), \"left NOT GLOB right\")\n\n        WINQExpressionAssertEqual(left.notMatch(right), \"left NOT MATCH right\")\n\n        WINQExpressionAssertEqual(left.notRegexp(right), \"left NOT REGEXP right\")\n\n        WINQExpressionAssertEqual(left.like(right).escape(2), \"left LIKE right ESCAPE 2\")\n\n        WINQExpressionAssertEqual(left.glob(right).escape(2), \"left GLOB right ESCAPE 2\")\n\n        WINQExpressionAssertEqual(left.match(right).escape(2), \"left MATCH right ESCAPE 2\")\n\n        WINQExpressionAssertEqual(left.regexp(right).escape(2), \"left REGEXP right ESCAPE 2\")\n\n        WINQExpressionAssertEqual(left.notLike(right).escape(2), \"left NOT LIKE right ESCAPE 2\")\n\n        WINQExpressionAssertEqual(left.notGlob(right).escape(2), \"left NOT GLOB right ESCAPE 2\")\n\n        WINQExpressionAssertEqual(left.notMatch(right).escape(2), \"left NOT MATCH right ESCAPE 2\")\n\n        WINQExpressionAssertEqual(left.notRegexp(right).escape(2), \"left NOT REGEXP right ESCAPE 2\")\n\n        WINQExpressionAssertEqual(left.isNull(), \"left ISNULL\")\n\n        WINQExpressionAssertEqual(left.isNotNull(), \"left NOTNULL\")\n\n        WINQExpressionAssertEqual(left.`is`(right), \"left IS right\")\n\n        WINQExpressionAssertEqual(left.isNot(right), \"left IS NOT right\")\n\n        WINQExpressionAssertEqual(left.between(2, 10), \"left BETWEEN 2 AND 10\")\n\n        WINQExpressionAssertEqual(left.notBetween(2, 10), \"left NOT BETWEEN 2 AND 10\")\n\n        let statementSelect = StatementSelect().select(left).from(\"testExpressionTable\")\n\n        WINQExpressionAssertEqual(\n            Expression.exists(statementSelect),\n            \"EXISTS(SELECT left FROM testExpressionTable)\"\n        )\n\n        WINQExpressionAssertEqual(\n            Expression.notExists(statementSelect),\n            \"NOT EXISTS(SELECT left FROM testExpressionTable)\"\n        )\n\n        WINQExpressionAssertEqual(left.`in`(statementSelect), \"left IN(SELECT left FROM testExpressionTable)\")\n\n        WINQExpressionAssertEqual(left.notIn(statementSelect), \"left NOT IN(SELECT left FROM testExpressionTable)\")\n\n        WINQExpressionAssertEqual(left.`in`(right), \"left IN(right)\")\n\n        WINQExpressionAssertEqual(left.notIn(right), \"left NOT IN(right)\")\n\n        WINQExpressionAssertEqual(left.in(function: \"testFunction\").schema(\"testSchema\").invoke().arguments(1, 2), \"left IN testSchema.testFunction(1, 2)\")\n\n        WINQExpressionAssertEqual(left.notIn(function: \"testFunction\").invoke().arguments(1, 2), \"left NOT IN testFunction(1, 2)\")\n\n        WINQExpressionAssertEqual(left.notIn(function: \"testFunction\"), \"left NOT IN testFunction()\")\n\n        WINQExpressionAssertEqual(left.inTable(\"testTable\").schema(\"testSchema\"), \"left IN testSchema.testTable\")\n\n        WINQExpressionAssertEqual(left.notInTable(\"testTable\"), \"left NOT IN testTable\")\n\n        WINQExpressionAssertEqual(left.avg(), \"AVG(left)\")\n\n        WINQExpressionAssertEqual(left.count(isDistinct: true), \"COUNT(DISTINCT left)\")\n\n        WINQExpressionAssertEqual(left.groupConcat(), \"GROUP_CONCAT(left)\")\n\n        WINQExpressionAssertEqual(\n            left.groupConcat(isDistinct: true, separateBy: \"-\"),\n            \"GROUP_CONCAT(DISTINCT left, '-')\"\n        )\n\n        WINQExpressionAssertEqual(left.max(), \"MAX(left)\")\n\n        WINQExpressionAssertEqual(left.min(), \"MIN(left)\")\n\n        WINQExpressionAssertEqual(left.sum(), \"SUM(left)\")\n\n        WINQExpressionAssertEqual(left.total(), \"TOTAL(left)\")\n\n        WINQExpressionAssertEqual(left.abs(), \"ABS(left)\")\n\n        WINQExpressionAssertEqual(left.hex(), \"HEX(left)\")\n\n        WINQExpressionAssertEqual(left.length(), \"LENGTH(left)\")\n\n        WINQExpressionAssertEqual(left.lower(), \"LOWER(left)\")\n\n        WINQExpressionAssertEqual(left.upper(), \"UPPER(left)\")\n\n        WINQExpressionAssertEqual(left.round(), \"ROUND(left)\")\n\n        WINQExpressionAssertEqual(\n            Expression.`case`(left, (when: 1, then: 2), else: 3),\n            \"CASE left WHEN 1 THEN 2 ELSE 3 END\"\n        )\n\n        WINQExpressionAssertEqual(left.matchinfo(), \"matchinfo(left)\")\n\n        WINQExpressionAssertEqual(left.offsets(), \"offsets(left)\")\n\n        WINQExpressionAssertEqual(left.snippet(), \"snippet(left)\")\n\n        WINQExpressionAssertEqual(left.bm25(), \"bm25(left)\")\n\n        WINQExpressionAssertEqual(left.highlight(), \"highlight(left)\")\n\n        WINQExpressionAssertEqual(left.substringMatchInfo(), \"\\(BuiltinAuxiliaryFunction.SubstringMatchInfo)(left)\")\n\n        WINQExpressionAssertEqual(left.collate(\"BINARY\"), \"left COLLATE BINARY\")\n    }\n\n    func testOperableXOperable() {\n        // Give\n        let left = OperableObject.Properties.left\n        let right = OperableObject.Properties.right\n\n        // Then\n        WINQExpressionAssertEqual((left || right), \"left OR right\")\n\n        WINQExpressionAssertEqual((left && right), \"left AND right\")\n\n        WINQExpressionAssertEqual((left * right), \"left * right\")\n\n        WINQExpressionAssertEqual((left / right), \"left / right\")\n\n        WINQExpressionAssertEqual((left % right), \"left % right\")\n\n        WINQExpressionAssertEqual((left + right), \"left + right\")\n\n        WINQExpressionAssertEqual((left - right), \"left - right\")\n\n        WINQExpressionAssertEqual((left << right), \"left << right\")\n\n        WINQExpressionAssertEqual((left >> right), \"left >> right\")\n\n        WINQExpressionAssertEqual((left & right), \"left & right\")\n\n        WINQExpressionAssertEqual((left | right), \"left | right\")\n\n        WINQExpressionAssertEqual((left < right), \"left < right\")\n\n        WINQExpressionAssertEqual((left <= right), \"left <= right\")\n\n        WINQExpressionAssertEqual((left > right), \"left > right\")\n\n        WINQExpressionAssertEqual((left >= right), \"left >= right\")\n\n        WINQExpressionAssertEqual((left == right), \"left == right\")\n\n        WINQExpressionAssertEqual((left != right), \"left != right\")\n    }\n\n    func testOperableXCanBeOperated() {\n        // Give\n        let left = OperableObject.Properties.left\n        let right = 1\n\n        // Then\n        WINQExpressionAssertEqual((left || right), \"left OR 1\")\n\n        WINQExpressionAssertEqual((left && right), \"left AND 1\")\n\n        WINQExpressionAssertEqual((left * right), \"left * 1\")\n\n        WINQExpressionAssertEqual((left / right), \"left / 1\")\n\n        WINQExpressionAssertEqual((left % right), \"left % 1\")\n\n        WINQExpressionAssertEqual((left + right), \"left + 1\")\n\n        WINQExpressionAssertEqual((left - right), \"left - 1\")\n\n        WINQExpressionAssertEqual((left << right), \"left << 1\")\n\n        WINQExpressionAssertEqual((left >> right), \"left >> 1\")\n\n        WINQExpressionAssertEqual((left & right), \"left & 1\")\n\n        WINQExpressionAssertEqual((left | right), \"left | 1\")\n\n        WINQExpressionAssertEqual((left < right), \"left < 1\")\n\n        WINQExpressionAssertEqual((left <= right), \"left <= 1\")\n\n        WINQExpressionAssertEqual((left > right), \"left > 1\")\n\n        WINQExpressionAssertEqual((left >= right), \"left >= 1\")\n\n        WINQExpressionAssertEqual((left == right), \"left == 1\")\n\n        WINQExpressionAssertEqual((left != right), \"left != 1\")\n    }\n}\n"
  },
  {
    "path": "src/swift/tests/winq/identifier/ForeignKeyTests.swift",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport XCTest\n#if TEST_WCDB_SWIFT\nimport WCDBSwift\n#else\nimport WCDB\n#endif\n\nclass ForeignKeyTests: BaseTestCase {\n\n    func generateForeignKey() -> ForeignKey {\n        let column1 = Column(named: \"column1\")\n        let column2 = Column(named: \"column2\")\n\n        return ForeignKey().references(with: \"testForeignKeyTable\").columns(column1, column2)\n    }\n\n    func testForeignKey() {\n        WINQAssertEqual(\n            generateForeignKey().onDelete(.setNull),\n            \"REFERENCES testForeignKeyTable(column1, column2) ON DELETE SET NULL\"\n        )\n\n        WINQAssertEqual(\n            generateForeignKey().onUpdate(.setDefault),\n            \"REFERENCES testForeignKeyTable(column1, column2) ON UPDATE SET DEFAULT\"\n        )\n\n        WINQAssertEqual(\n            generateForeignKey().onDelete(.cascade),\n            \"REFERENCES testForeignKeyTable(column1, column2) ON DELETE CASCADE\"\n        )\n\n        WINQAssertEqual(\n            generateForeignKey().onUpdate(.restrict),\n            \"REFERENCES testForeignKeyTable(column1, column2) ON UPDATE RESTRICT\"\n        )\n\n        WINQAssertEqual(\n            generateForeignKey().onDelete(.noAction),\n            \"REFERENCES testForeignKeyTable(column1, column2) ON DELETE NO ACTION\"\n        )\n\n        WINQAssertEqual(\n            generateForeignKey().deferrable(.deferred),\n            \"REFERENCES testForeignKeyTable(column1, column2) DEFERRABLE INITIALLY DEFERRED\"\n        )\n\n        WINQAssertEqual(\n            generateForeignKey().notDeferrable(.immediate),\n            \"REFERENCES testForeignKeyTable(column1, column2) NOT DEFERRABLE INITIALLY IMMEDIATE\"\n        )\n\n        WINQAssertEqual(\n            generateForeignKey().match(with: .Simple),\n            \"REFERENCES testForeignKeyTable(column1, column2) MATCH SIMPLE\"\n        )\n    }\n}\n"
  },
  {
    "path": "src/swift/tests/winq/identifier/FrameSpecTests.swift",
    "content": "//\n// Created by qiuwenchen on 2022/6/9.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport Foundation\n#if TEST_WCDB_SWIFT\nimport WCDBSwift\n#else\nimport WCDB\n#endif\n\nclass FrameSpecTests: BaseTestCase {\n\n    func testFrameSpec() {\n        WINQAssertEqual(FrameSpec().range().unboundedPreceding(), \"RANGE UNBOUNDED PRECEDING\")\n\n        WINQAssertEqual(FrameSpec().rows().unboundedPreceding(), \"ROWS UNBOUNDED PRECEDING\")\n\n        WINQAssertEqual(FrameSpec().range().preceding(1), \"RANGE 1 PRECEDING\")\n\n        WINQAssertEqual(FrameSpec().range().currentRow(), \"RANGE CURRENT ROW\")\n\n        WINQAssertEqual(FrameSpec().range().betweenUnboundedPreceding().andPreceding(2), \"RANGE BETWEEN UNBOUNDED PRECEDING AND 2 PRECEDING\")\n\n        WINQAssertEqual(FrameSpec().range().betweenPreceding(1).andPreceding(2), \"RANGE BETWEEN 1 PRECEDING AND 2 PRECEDING\")\n\n        WINQAssertEqual(FrameSpec().range().betweenCurrentRow().andPreceding(2), \"RANGE BETWEEN CURRENT ROW AND 2 PRECEDING\")\n\n        WINQAssertEqual(FrameSpec().range().betweenFollowing(1).andPreceding(2), \"RANGE BETWEEN 1 FOLLOWING AND 2 PRECEDING\")\n\n        WINQAssertEqual(FrameSpec().range().betweenUnboundedPreceding().andCurrentRow(), \"RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW\")\n\n        WINQAssertEqual(FrameSpec().range().betweenUnboundedPreceding().andFollowing(2), \"RANGE BETWEEN UNBOUNDED PRECEDING AND 2 FOLLOWING\")\n\n        WINQAssertEqual(FrameSpec().range().betweenUnboundedPreceding().andUnboundedFollowing(), \"RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING\")\n    }\n}\n"
  },
  {
    "path": "src/swift/tests/winq/identifier/IndexedColumnTests.swift",
    "content": "//\n// Created by qiuwenchen on 2022/5/27.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport XCTest\n#if TEST_WCDB_SWIFT\nimport WCDBSwift\n#else\nimport WCDB\n#endif\n\nclass IndexedColumnTests: BaseTestCase {\n\n    func testIndexedColumn() {\n        // Give\n        let column1 = Column(named: \"column1\")\n        let expression1 = column1.abs()\n\n        // Then\n        WINQAssertEqual(IndexedColumn(with: column1), \"column1\")\n\n        WINQAssertEqual(IndexedColumn(with: column1).order(.ascending), \"column1 ASC\")\n\n        WINQAssertEqual(IndexedColumn(with: expression1), \"ABS(column1)\")\n\n        WINQAssertEqual(IndexedColumn(with: expression1).order(.ascending), \"ABS(column1) ASC\")\n\n        WINQAssertEqual(IndexedColumn(with: expression1).collate(\"BINARY\"), \"ABS(column1) COLLATE BINARY\")\n    }\n}\n"
  },
  {
    "path": "src/swift/tests/winq/identifier/JoinTests.swift",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport XCTest\n#if TEST_WCDB_SWIFT\nimport WCDBSwift\n#else\nimport WCDB\n#endif\n\nclass JoinTests: BaseTestCase {\n\n    func testJoin() {\n        WINQAssertEqual(\n            Join(with: \"testTable\").join(\"testTable1\"),\n            \"testTable JOIN testTable1\"\n        )\n\n        WINQAssertEqual(\n            Join(with: \"testTable\").with(\"testTable1\"),\n            \"testTable, testTable1\"\n        )\n\n        WINQAssertEqual(\n            Join(with: \"testTable\").leftJoin(\"testTable1\"),\n            \"testTable LEFT JOIN testTable1\"\n        )\n\n        WINQAssertEqual(\n            Join(with: \"testTable\").leftOuterJoin(\"testTable1\"),\n            \"testTable LEFT OUTER JOIN testTable1\"\n        )\n\n        WINQAssertEqual(\n            Join(with: \"testTable\").innerJoin(\"testTable1\"),\n            \"testTable INNER JOIN testTable1\"\n        )\n\n        WINQAssertEqual(\n            Join(with: \"testTable\").crossJoin(\"testTable1\"),\n            \"testTable CROSS JOIN testTable1\"\n        )\n\n        WINQAssertEqual(\n            Join(with: \"testTable\").naturalJoin(\"testTable1\"),\n            \"testTable NATURAL JOIN testTable1\"\n        )\n\n        WINQAssertEqual(\n            Join(with: \"testTable\").naturalLeftJoin(\"testTable1\"),\n            \"testTable NATURAL LEFT JOIN testTable1\"\n        )\n\n        WINQAssertEqual(\n            Join(with: \"testTable\").naturalLeftOuterJoin(\"testTable1\"),\n            \"testTable NATURAL LEFT OUTER JOIN testTable1\"\n        )\n\n        WINQAssertEqual(\n            Join(with: \"testTable\").naturalInnerJoin(\"testTable1\"),\n            \"testTable NATURAL INNER JOIN testTable1\"\n        )\n\n        WINQAssertEqual(\n            Join(with: \"testTable\").naturalCrossJoin(\"testTable1\"),\n            \"testTable NATURAL CROSS JOIN testTable1\"\n        )\n\n        WINQAssertEqual(\n            Join(with: \"testTable\").join(\"testTable1\").on(1),\n            \"testTable JOIN testTable1 ON 1\"\n        )\n\n        WINQAssertEqual(\n            Join(with: \"testTable\").join(\"testTable1\").using(Column(named: \"testColumn1\"), Column(named: \"testColumn2\")),\n            \"testTable JOIN testTable1 USING(testColumn1, testColumn2)\"\n        )\n\n        WINQAssertEqual(\n            Join(with: \"testTable\").join(\"testTable1\").on(1).leftOuterJoin(\"testTable2\").on(2),\n            \"testTable JOIN testTable1 ON 1 LEFT OUTER JOIN testTable2 ON 2\"\n        )\n    }\n}\n"
  },
  {
    "path": "src/swift/tests/winq/identifier/LiteralValueTests.swift",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport XCTest\n#if TEST_WCDB_SWIFT\nimport WCDBSwift\n#else\nimport WCDB\n#endif\n\nclass LiteralValueTests: BaseTestCase {\n\n    struct Int32LiteralValue: ColumnCodable {\n        static var columnType: ColumnType {\n            return .integer32\n        }\n        func archivedValue() -> Value {\n            return Value(int32)\n        }\n        init?(with value: Value) {\n            self.init(value.int32Value)\n        }\n        init(_ value: Int32) {\n            int32 = value\n        }\n        var int32: Int32\n    }\n\n    struct Int64LiteralValue: ColumnCodable {\n        static var columnType: ColumnType {\n            return .integer64\n        }\n        func archivedValue() -> Value {\n            return Value(int64)\n        }\n        init?(with value: Value) {\n            self.init(value.int64Value)\n        }\n        init(_ value: Int64) {\n            int64 = value\n        }\n        var int64: Int64\n    }\n\n    struct FloatLiteralValue: ColumnCodable {\n        static var columnType: ColumnType {\n            return .float\n        }\n        func archivedValue() -> Value {\n            return Value(double)\n        }\n        init?(with value: Value) {\n            self.init(value.doubleValue)\n        }\n        init(_ value: Double) {\n            double = value\n        }\n        var double: Double\n    }\n\n    struct StringLiteralValue: ColumnCodable {\n        static var columnType: ColumnType {\n            return .float\n        }\n        func archivedValue() -> Value {\n            return Value(string)\n        }\n        init?(with value: Value) {\n            self.init(value.stringValue)\n        }\n        init(_ value: String) {\n            string = value\n        }\n        var string: String\n    }\n\n    struct DataLiteralValue: ColumnCodable {\n        static var columnType: ColumnType {\n            return .BLOB\n        }\n        func archivedValue() -> Value {\n            return Value(data)\n        }\n        init?(with value: Value) {\n            self.init(value.dataValue)\n        }\n        init(_ value: Data) {\n            data = value\n        }\n        var data: Data\n    }\n\n    func testLiteralValue() {\n\n        let boolLiteralValue: LiteralValue = false\n        WINQAssertEqual(boolLiteralValue, \"FALSE\")\n\n        let intLiteralValue: LiteralValue = 1\n        WINQAssertEqual(intLiteralValue, \"1\")\n\n        let floatLiteralValue: LiteralValue = 0.1\n        WINQAssertEqual(floatLiteralValue, \"0.10000000000000001\")\n\n        let stringLiteralValue: LiteralValue = \"test\"\n        WINQAssertEqual(stringLiteralValue, \"'test'\")\n\n        let nullLiteralValue: LiteralValue = nil\n        WINQAssertEqual(nullLiteralValue, \"NULL\")\n\n        WINQAssertEqual(LiteralValue(true), \"TRUE\")\n\n        WINQAssertEqual(LiteralValue(1), \"1\")\n\n        WINQAssertEqual(LiteralValue(17626545782784), \"17626545782784\")\n\n        WINQAssertEqual(LiteralValue(0.1), \"0.10000000000000001\")\n\n        WINQAssertEqual(LiteralValue(\"test\"), \"'test'\")\n\n        WINQAssertEqual(LiteralValue(\"test\".data(using: .ascii)!), \"'test'\")\n\n        WINQAssertEqual(LiteralValue(Date.init(timeIntervalSince1970: 10000)), \"10000\")\n\n        WINQAssertEqual(LiteralValue(nil), \"NULL\")\n\n        WINQAssertEqual(LiteralValue(Int32LiteralValue(1)), \"1\")\n\n        WINQAssertEqual(LiteralValue(Int64LiteralValue(17626545782784)), \"17626545782784\")\n\n        WINQAssertEqual(LiteralValue(FloatLiteralValue(0.1)), \"0.10000000000000001\")\n\n        WINQAssertEqual(LiteralValue(StringLiteralValue(\"test\")), \"'test'\")\n\n        WINQAssertEqual(LiteralValue(DataLiteralValue(\"test\".data(using: .ascii)!)), \"'test'\")\n\n        WINQAssertEqual(LiteralValue.currentTime(), \"CURRENT_TIME\")\n        WINQAssertEqual(LiteralValue.currentDate(), \"CURRENT_DATE\")\n        WINQAssertEqual(LiteralValue.currentTimestamp(), \"CURRENT_TIMESTAMP\")\n    }\n}\n"
  },
  {
    "path": "src/swift/tests/winq/identifier/OrderingTermTests.swift",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport XCTest\n#if TEST_WCDB_SWIFT\nimport WCDBSwift\n#else\nimport WCDB\n#endif\n\nclass OrderingTermTests: BaseTestCase {\n\n    func testOrderTerm() {\n        let column = Column(named: \"testColumn\")\n        WINQAssertEqual(OrderingTerm(with: column), \"testColumn\")\n\n        WINQAssertEqual(OrderingTerm(with: column).collate(\"BINARY\"), \"testColumn COLLATE BINARY\")\n\n        WINQAssertEqual(column.collate(\"BINARY\"), \"testColumn COLLATE BINARY\")\n\n        WINQAssertEqual(OrderingTerm(with: column).order(.ascending), \"testColumn ASC\")\n\n        WINQAssertEqual(column.order(.ascending), \"testColumn ASC\")\n    }\n}\n"
  },
  {
    "path": "src/swift/tests/winq/identifier/QualifiedTableTests.swift",
    "content": "//\n// Created by qiuwenchen on 2022/6/11.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport Foundation\n#if TEST_WCDB_SWIFT\nimport WCDBSwift\n#else\nimport WCDB\n#endif\n\nclass QualifiedTableTests: BaseTestCase {\n\n    func testQualifiedTable() {\n\n        WINQAssertEqual(QualifiedTable(with: \"testTable\"), \"testTable\")\n\n        WINQAssertEqual(QualifiedTable(with: \"testTable\").of(schema: \"testSchema\"), \"testSchema.testTable\")\n\n        WINQAssertEqual(QualifiedTable(with: \"testTable\").of(schema: \"testSchema\").as(\"testAlias\"), \"testSchema.testTable AS testAlias\")\n\n        WINQAssertEqual(QualifiedTable(with: \"testTable\").of(schema: \"testSchema\").indexed(by: \"testIndex\"), \"testSchema.testTable INDEXED BY testIndex\")\n\n        WINQAssertEqual(QualifiedTable(with: \"testTable\").of(schema: \"testSchema\").notIndexed(), \"testSchema.testTable NOT INDEXED\")\n    }\n}\n"
  },
  {
    "path": "src/swift/tests/winq/identifier/RaiseFunctionTests.swift",
    "content": "//\n// Created by qiuwenchen on 2022/6/9.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport Foundation\n#if TEST_WCDB_SWIFT\nimport WCDBSwift\n#else\nimport WCDB\n#endif\n\nclass RaiseFunctionTests: BaseTestCase {\n\n    func testRaiseFunction() {\n        WINQAssertEqual(RaiseFunction().ignore(), \"RAISE(IGNORE)\")\n        WINQAssertEqual(RaiseFunction().rollback(with: \"testErrorMessage\"), \"RAISE(ROLLBACK, testErrorMessage)\")\n        WINQAssertEqual(RaiseFunction().abort(with: \"testErrorMessage\"), \"RAISE(ABORT, testErrorMessage)\")\n        WINQAssertEqual(RaiseFunction().fail(with: \"testErrorMessage\"), \"RAISE(FAIL, testErrorMessage)\")\n        WINQAssertEqual(RaiseFunction().fail(with: \"testErrorMessage\"), \"RAISE(FAIL, testErrorMessage)\")\n        WINQAssertEqual(StatementSelect().select(RaiseFunction().ignore()), \"SELECT RAISE(IGNORE)\")\n\n    }\n}\n"
  },
  {
    "path": "src/swift/tests/winq/identifier/ResultColumnTests.swift",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport XCTest\n#if TEST_WCDB_SWIFT\nimport WCDBSwift\n#else\nimport WCDB\n#endif\n\nclass ResultColumnTests: BaseTestCase {\n\n    func generateResultColumn() -> ResultColumn {\n        let column = Column(named: \"testColumn\")\n        return ResultColumn(with: column)\n    }\n\n    func testResultColumn() {\n\n        WINQAssertEqual(generateResultColumn().`as`(\"testResultColumn\"), \"testColumn AS testResultColumn\")\n\n        WINQAssertEqual(generateResultColumn().asResultColumn(), \"testColumn\")\n    }\n}\n"
  },
  {
    "path": "src/swift/tests/winq/identifier/SchemaTests.swift",
    "content": "//\n// Created by qiuwenchen on 2022/5/27.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport XCTest\n#if TEST_WCDB_SWIFT\nimport WCDBSwift\n#else\nimport WCDB\n#endif\n\nclass SchemaTests: BaseTestCase {\n\n    func testSchema() {\n        WINQAssertEqual(Schema.main, \"main\")\n\n        WINQAssertEqual(Schema.temp, \"temp\")\n\n        WINQAssertEqual(Schema(with: \"testSchema\"), \"testSchema\")\n    }\n}\n"
  },
  {
    "path": "src/swift/tests/winq/identifier/TableConstraintTests.swift",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport XCTest\n#if TEST_WCDB_SWIFT\nimport WCDBSwift\n#else\nimport WCDB\n#endif\n\nclass TableConstraintTests: BaseTestCase {\n\n    func testTableConstraint() {\n        // Give\n        let column1 = Column(named: \"column1\")\n        let column2 = Column(named: \"column2\")\n        let index1 = column1.asIndex()\n        let index2 = Column(named: \"column2\").asIndex()\n        let foreignKey1 = ForeignKey().references(with: \"testTable\").columns(column1)\n        let foreignKey2 = ForeignKey().references(with: \"testTable\").columns(column1, column2)\n\n        WINQAssertEqual(\n            TableConstraint().primaryKey().indexed(by: index1, index2),\n            \"PRIMARY KEY(column1, column2)\"\n        )\n\n        WINQAssertEqual(\n            TableConstraint(named: \"testConstraint\").primaryKey().indexed(by: index1, index2),\n            \"CONSTRAINT testConstraint PRIMARY KEY(column1, column2)\"\n        )\n\n        WINQAssertEqual(\n            TableConstraint().unique().indexed(by: index1, index2),\n            \"UNIQUE(column1, column2)\"\n        )\n\n        WINQAssertEqual(\n            TableConstraint().unique().indexed(by: index1, index2).onConflict(.Fail),\n            \"UNIQUE(column1, column2) ON CONFLICT FAIL\"\n        )\n\n        WINQAssertEqual(\n            TableConstraint().check(column1 > 1),\n            \"CHECK(column1 > 1)\"\n        )\n\n        WINQAssertEqual(\n            TableConstraint().foreignKey(column1, foreignKey: foreignKey1),\n            \"FOREIGN KEY(column1) REFERENCES testTable(column1)\"\n        )\n\n        WINQAssertEqual(\n            TableConstraint().foreignKey(column1, column2, foreignKey: foreignKey2),\n            \"FOREIGN KEY(column1, column2) REFERENCES testTable(column1, column2)\"\n        )\n    }\n}\n"
  },
  {
    "path": "src/swift/tests/winq/identifier/TableOrSubqueryTests.swift",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport XCTest\n#if TEST_WCDB_SWIFT\nimport WCDBSwift\n#else\nimport WCDB\n#endif\n\nclass TableOrSubqueryTests: BaseTestCase {\n\n    func testSubquery() {\n        WINQAssertEqual(TableOrSubquery(withTable: \"testTable\"), \"testTable\")\n\n        WINQAssertEqual(TableOrSubquery(withTable: \"testTable\").of(schema: \"testSchema\"), \"testSchema.testTable\")\n\n        WINQAssertEqual(TableOrSubquery(withTable: \"testTable\").indexed(by: \"testIndex\"), \"testTable INDEXED BY testIndex\")\n\n        WINQAssertEqual(TableOrSubquery(withTable: \"testTable\").notIndexed(), \"testTable NOT INDEXED\")\n\n        WINQAssertEqual(TableOrSubquery(withTable: \"testTable\").as(alias: \"testAliasTable\"), \"testTable AS testAliasTable\")\n\n        WINQAssertEqual(TableOrSubquery.function(\"testFunction\").of(schema: \"testSchema\"), \"testSchema.testFunction()\")\n\n        WINQAssertEqual(TableOrSubquery.function(\"testFunction\").arguments(1, 2), \"testFunction(1, 2)\")\n\n        WINQAssertEqual(TableOrSubquery.function(\"testFunction\").as(alias: \"testAliasTable\"), \"testFunction() AS testAliasTable\")\n\n        WINQAssertEqual(TableOrSubquery(with: \"testTable1\", \"testTable2\"), \"(testTable1, testTable2)\")\n\n        WINQAssertEqual(TableOrSubquery.master(), \"sqlite_master\")\n\n        // Give\n        let joinClause = Join(with: \"testTable\")\n        let statementSelect = StatementSelect().select(1).from(\"testTable\")\n\n        // Then\n        WINQAssertEqual(TableOrSubquery(with: joinClause).asTableOrSubquery(), \"(testTable)\")\n\n        WINQAssertEqual(TableOrSubquery(with: joinClause), \"(testTable)\")\n\n        WINQAssertEqual(TableOrSubquery(with: statementSelect), \"(SELECT 1 FROM testTable)\")\n\n        WINQAssertEqual(TableOrSubquery(with: statementSelect).as(alias: \"testAliasTable\"), \"(SELECT 1 FROM testTable) AS testAliasTable\")\n    }\n}\n"
  },
  {
    "path": "src/swift/tests/winq/identifier/UpsertTests.swift",
    "content": "//\n// Created by qiuwenchen on 2022/6/12.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport Foundation\n#if TEST_WCDB_SWIFT\nimport WCDBSwift\n#else\nimport WCDB\n#endif\n\nclass UpsertTests: BaseTestCase {\n\n    func testUpsert() {\n        let column = Column(named: \"testColumn1\")\n        let columns = [\n            Column(named: \"testColumn2\"),\n            Column(named: \"testColumn3\")\n        ]\n        let indexedColumn1 = Column(named: \"testColumn1\")\n        let indexedColumn2 = Column(named: \"testColumn2\")\n        let condition = 1\n        let value1 = 2\n        let value2 = 3\n        let updateCondition = 4\n\n        WINQAssertEqual(Upsert().onConflict().doNothing(), \"ON CONFLICT DO NOTHING\")\n\n        WINQAssertEqual(Upsert().onConflict().indexed(by: indexedColumn1).doNothing(), \"ON CONFLICT(testColumn1) DO NOTHING\")\n\n        WINQAssertEqual(Upsert().onConflict().indexed(by: indexedColumn1, indexedColumn2).doNothing(), \"ON CONFLICT(testColumn1, testColumn2) DO NOTHING\")\n\n        WINQAssertEqual(Upsert().onConflict().indexed(by: indexedColumn1).where(condition).doNothing(), \"ON CONFLICT(testColumn1) WHERE 1 DO NOTHING\")\n\n        WINQAssertEqual(Upsert().onConflict().doUpdate().set(column).to(value1), \"ON CONFLICT DO UPDATE SET testColumn1 = 2\")\n\n        WINQAssertEqual(Upsert().onConflict().doUpdate().set(column).to(value1).set(columns).to(value2), \"ON CONFLICT DO UPDATE SET testColumn1 = 2, (testColumn2, testColumn3) = 3\")\n\n        WINQAssertEqual(Upsert().onConflict().doUpdate().set(column).to(value1).where(updateCondition), \"ON CONFLICT DO UPDATE SET testColumn1 = 2 WHERE 4\")\n    }\n}\n"
  },
  {
    "path": "src/swift/tests/winq/identifier/WindowDefTests.swift",
    "content": "//\n// Created by qiuwenchen on 2022/6/10.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport Foundation\n#if TEST_WCDB_SWIFT\nimport WCDBSwift\n#else\nimport WCDB\n#endif\n\nclass WindowDefTests: BaseTestCase {\n\n    func testWindowDef() {\n\n        WINQAssertEqual(WindowDef(), \"\")\n\n        WINQAssertEqual(WindowDef().partition(1, 2), \"(PARTITION BY 1, 2)\")\n\n        WINQAssertEqual(WindowDef().order(1, 2), \"(ORDER BY 1, 2)\")\n\n        WINQAssertEqual(WindowDef().frameSpec(FrameSpec().range().unboundedPreceding()), \"(RANGE UNBOUNDED PRECEDING)\")\n\n        WINQAssertEqual(WindowDef().partition(1, 2).order(1, 2).frameSpec(FrameSpec().range().unboundedPreceding()), \"(PARTITION BY 1, 2 ORDER BY 1, 2 RANGE UNBOUNDED PRECEDING)\")\n\n    }\n}\n"
  },
  {
    "path": "src/swift/tests/winq/statement/StatementAlterTableTests.swift",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport XCTest\n#if TEST_WCDB_SWIFT\nimport WCDBSwift\n#else\nimport WCDB\n#endif\n\nclass StatementAlterTableTests: BaseTestCase {\n\n    func testStatementAlterTable() {\n\n        WINQAssertEqual(\n            StatementAlterTable().alter(table: \"table1\").rename(to: \"table2\"),\n            \"ALTER TABLE table1 RENAME TO table2\"\n        )\n\n        WINQAssertEqual(\n            StatementAlterTable().alter(table: \"table1\").schema(\"testSchema\").rename(to: \"table2\"),\n            \"ALTER TABLE testSchema.table1 RENAME TO table2\"\n        )\n\n        let column = Column(named: \"column1\")\n        WINQAssertEqual(\n            StatementAlterTable().alter(table: \"table1\").addColumn(with: column.asDef(with: .float)),\n            \"ALTER TABLE table1 ADD COLUMN column1 REAL\"\n        )\n\n        let newColumn = Column(named: \"column2\")\n        WINQAssertEqual(\n            StatementAlterTable().alter(table: \"table1\").rename(column: column, to: newColumn),\n            \"ALTER TABLE table1 RENAME COLUMN column1 TO column2\"\n        )\n    }\n}\n"
  },
  {
    "path": "src/swift/tests/winq/statement/StatementAnalyzeTests.swift",
    "content": "//\n// Created by qiuwenchen on 2022/6/29.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport XCTest\n#if TEST_WCDB_SWIFT\nimport WCDBSwift\n#else\nimport WCDB\n#endif\n\nclass StatementAnalyzeTests: BaseTestCase {\n\n    func testStatementAnalyze() {\n\n        WINQAssertEqual(\n            StatementAnalyze().analyze(),\n            \"ANALYZE\"\n        )\n\n        WINQAssertEqual(\n            StatementAnalyze().analyze().schema(\"testSchema\"),\n            \"ANALYZE testSchema\"\n        )\n\n        WINQAssertEqual(\n            StatementAnalyze().analyze().schema(\"testSchema\").table(\"testTable\"),\n            \"ANALYZE testSchema.testTable\"\n        )\n\n        WINQAssertEqual(\n            StatementAnalyze().analyze().table(\"testTable\"),\n            \"ANALYZE testTable\"\n        )\n\n        WINQAssertEqual(\n            StatementAnalyze().analyze().schema(\"testSchema\").index(\"testIndex\"),\n            \"ANALYZE testSchema.testIndex\"\n        )\n    }\n}\n"
  },
  {
    "path": "src/swift/tests/winq/statement/StatementAttachTests.swift",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport XCTest\n#if TEST_WCDB_SWIFT\nimport WCDBSwift\n#else\nimport WCDB\n#endif\n\nclass StatementAttachTests: BaseTestCase {\n\n    func testStatementAttach() {\n        WINQAssertEqual(StatementAttach().attach(\"attach1\").as(\"schema1\"), \"ATTACH 'attach1' AS schema1\")\n        WINQAssertEqual(StatementAttach().attach(\"attach1\").as(\"schema1\").key(\"abc\"), \"ATTACH 'attach1' AS schema1 KEY 'abc'\")\n    }\n}\n"
  },
  {
    "path": "src/swift/tests/winq/statement/StatementBeginTests.swift",
    "content": "//\n// Created by qiuwenchen on 2022/7/17.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport XCTest\n#if TEST_WCDB_SWIFT\nimport WCDBSwift\n#else\nimport WCDB\n#endif\n\nclass StatementBeginTests: BaseTestCase {\n\n    func testStatementBegin() {\n        WINQAssertEqual(StatementBegin(), \"BEGIN DEFERRED\")\n        WINQAssertEqual(StatementBegin().begin(.deferred), \"BEGIN DEFERRED\")\n        WINQAssertEqual(StatementBegin().begin(.immediate), \"BEGIN IMMEDIATE\")\n        WINQAssertEqual(StatementBegin().begin(.exclusive), \"BEGIN EXCLUSIVE\")\n    }\n}\n"
  },
  {
    "path": "src/swift/tests/winq/statement/StatementCommitTests.swift",
    "content": "//\n// Created by qiuwenchen on 2022/7/17.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport XCTest\n#if TEST_WCDB_SWIFT\nimport WCDBSwift\n#else\nimport WCDB\n#endif\n\nclass StatementCommitTests: BaseTestCase {\n\n    func testStatementCommit() {\n        WINQAssertEqual(StatementCommit(), \"COMMIT\")\n    }\n}\n"
  },
  {
    "path": "src/swift/tests/winq/statement/StatementCreateIndexTests.swift",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport XCTest\n#if TEST_WCDB_SWIFT\nimport WCDBSwift\n#else\nimport WCDB\n#endif\n\nclass StatementCreateIndexTests: BaseTestCase {\n\n    func testCreateIndex() {\n        // Give\n        let column1 = Column(named: \"column1\")\n\n        let index1 = IndexedColumn(with: column1)\n        let index2 = IndexedColumn(with: Column(named: \"column2\")).order(.ascending)\n\n        let indexName1 = \"index1\"\n        let table1 = \"table1\"\n\n        WINQAssertEqual(\n            StatementCreateIndex().create(index: indexName1).on(table: table1).indexesBy(index1, index2),\n            \"CREATE INDEX index1 ON table1(column1, column2 ASC)\"\n        )\n\n        WINQAssertEqual(\n            StatementCreateIndex().create(index: indexName1).of(schema: \"testSchema\").on(table: table1).indexesBy(index1, index2),\n            \"CREATE INDEX testSchema.index1 ON table1(column1, column2 ASC)\"\n        )\n\n        WINQAssertEqual(\n            StatementCreateIndex()\n                .create(index: indexName1, isUnique: true)\n                .on(table: table1).indexesBy(index1, index2),\n            \"CREATE UNIQUE INDEX index1 ON table1(column1, column2 ASC)\"\n        )\n\n        WINQAssertEqual(\n            StatementCreateIndex()\n                .create(index: indexName1).ifNotExists()\n                .on(table: table1).indexesBy(index1, index2),\n            \"CREATE INDEX IF NOT EXISTS index1 ON table1(column1, column2 ASC)\"\n        )\n\n        WINQAssertEqual(\n            StatementCreateIndex()\n                .create(index: indexName1)\n                .on(table: table1).indexesBy(index1, index2).`where`(column1 >= 1),\n            \"CREATE INDEX index1 ON table1(column1, column2 ASC) WHERE column1 >= 1\"\n        )\n    }\n}\n"
  },
  {
    "path": "src/swift/tests/winq/statement/StatementCreateTableTests.swift",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport XCTest\n#if TEST_WCDB_SWIFT\nimport WCDBSwift\n#else\nimport WCDB\n#endif\n\nclass StatementCreateTableTests: BaseTestCase {\n\n    func testCreateTable() {\n        // Give\n        let column1 = Column(named: \"column1\")\n        let column2 = Column(named: \"column2\")\n\n        let def1 = column1.asDef(with: .integer32)\n        let def2 = column2.asDef(with: .text)\n\n        let constraint1 = TableConstraint(named: \"constraint1\").primaryKey().indexed(by: column1.asIndex())\n        let constraint2 = TableConstraint(named: \"constraint2\").unique().indexed(by: column2.asIndex())\n\n        let table1 = \"table1\"\n        let table2 = \"table2\"\n\n        let statementSelect = StatementSelect().select(column1).from(table1)\n\n        WINQAssertEqual(\n            StatementCreateTable().create(table: table1).with(columns: def1, def2),\n            \"CREATE TABLE table1(column1 INTEGER, column2 TEXT)\"\n        )\n\n        WINQAssertEqual(\n            StatementCreateTable().create(table: table1, isTemp: true).with(columns: def1, def2),\n            \"CREATE TEMP TABLE table1(column1 INTEGER, column2 TEXT)\"\n        )\n\n        WINQAssertEqual(\n            StatementCreateTable().create(table: table1).with(columns: def1, def2).withoutRowid(),\n            \"CREATE TABLE table1(column1 INTEGER, column2 TEXT) WITHOUT ROWID\"\n        )\n\n        WINQAssertEqual(\n            StatementCreateTable().create(table: table1).of(schema: \"testSchema\").with(columns: def1, def2),\n            \"CREATE TABLE testSchema.table1(column1 INTEGER, column2 TEXT)\"\n        )\n\n        WINQAssertEqual(\n            StatementCreateTable().create(table: table1).ifNotExists().with(columns: def1, def2),\n            \"CREATE TABLE IF NOT EXISTS table1(column1 INTEGER, column2 TEXT)\"\n        )\n\n        WINQAssertEqual(\n            StatementCreateTable().create(table: table1).with(columns: def1, def2).constraint(constraint1, constraint2),\n            \"\"\"\n            CREATE TABLE table1\\\n            (column1 INTEGER, column2 TEXT, \\\n            CONSTRAINT constraint1 PRIMARY KEY(column1), \\\n            CONSTRAINT constraint2 UNIQUE(column2))\n            \"\"\"\n        )\n\n        WINQAssertEqual(\n            StatementCreateTable().create(table: table2).as(statementSelect),\n            \"CREATE TABLE table2 AS SELECT column1 FROM table1\"\n        )\n\n        WINQAssertEqual(\n            StatementCreateTable().create(table: table2).ifNotExists().as(statementSelect),\n            \"CREATE TABLE IF NOT EXISTS table2 AS SELECT column1 FROM table1\"\n        )\n    }\n}\n"
  },
  {
    "path": "src/swift/tests/winq/statement/StatementCreateTriggerTests.swift",
    "content": "//\n// Created by qiuwenchen on 2022/7/15.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport XCTest\n#if TEST_WCDB_SWIFT\nimport WCDBSwift\n#else\nimport WCDB\n#endif\n\nclass StatementCreateTriggerTests: BaseTestCase {\n\n    func testCreateTrigger() {\n        // Give\n        let schema = \"testSchema\"\n        let name = \"testTrigger\"\n        let column1 = Column(named: \"testColumn1\")\n        let column2 = Column(named: \"testColumn2\")\n        let table = \"testTable\"\n        let condition = 1\n        let update = StatementUpdate().update(table: table).set(Column(named: \"testColumn\")).to(1)\n        let select = StatementSelect().select(1)\n        let insert = StatementInsert().insert(intoTable: table).values(1)\n        let delete_ = StatementDelete().delete(from: table)\n\n        WINQAssertEqual(\n            StatementCreateTrigger().create(trigger: name).of(schema: schema).before().delete().on(table: table).forEachRow().when(condition).execute(update),\n            \"CREATE TRIGGER testSchema.testTrigger BEFORE DELETE ON testTable FOR EACH ROW WHEN 1 BEGIN UPDATE testTable SET testColumn = 1; END\"\n        )\n\n        WINQAssertEqual(\n            StatementCreateTrigger().create(trigger: name, isTemp: true).before().delete().on(table: table).forEachRow().when(condition).execute(update),\n            \"CREATE TEMP TRIGGER testTrigger BEFORE DELETE ON testTable FOR EACH ROW WHEN 1 BEGIN UPDATE testTable SET testColumn = 1; END\"\n        )\n\n        WINQAssertEqual(\n            StatementCreateTrigger().create(trigger: name).of(schema: schema).ifNotExists().before().delete().on(table: table).forEachRow().when(condition).execute(update),\n            \"CREATE TRIGGER IF NOT EXISTS testSchema.testTrigger BEFORE DELETE ON testTable FOR EACH ROW WHEN 1 BEGIN UPDATE testTable SET testColumn = 1; END\"\n        )\n\n        WINQAssertEqual(\n            StatementCreateTrigger().create(trigger: name).before().delete().on(table: table).forEachRow().when(condition).execute(update),\n            \"CREATE TRIGGER testTrigger BEFORE DELETE ON testTable FOR EACH ROW WHEN 1 BEGIN UPDATE testTable SET testColumn = 1; END\"\n        )\n\n        WINQAssertEqual(\n            StatementCreateTrigger().create(trigger: name).of(schema: schema).after().delete().on(table: table).forEachRow().when(condition).execute(update),\n            \"CREATE TRIGGER testSchema.testTrigger AFTER DELETE ON testTable FOR EACH ROW WHEN 1 BEGIN UPDATE testTable SET testColumn = 1; END\"\n        )\n\n        WINQAssertEqual(\n            StatementCreateTrigger().create(trigger: name).of(schema: schema).insteadOf().delete().on(table: table).forEachRow().when(condition).execute(update),\n            \"CREATE TRIGGER testSchema.testTrigger INSTEAD OF DELETE ON testTable FOR EACH ROW WHEN 1 BEGIN UPDATE testTable SET testColumn = 1; END\"\n        )\n\n        WINQAssertEqual(\n            StatementCreateTrigger().create(trigger: name).of(schema: schema).ifNotExists().before().insert().on(table: table).forEachRow().when(condition).execute(update),\n            \"CREATE TRIGGER IF NOT EXISTS testSchema.testTrigger BEFORE INSERT ON testTable FOR EACH ROW WHEN 1 BEGIN UPDATE testTable SET testColumn = 1; END\"\n        )\n\n        WINQAssertEqual(\n            StatementCreateTrigger().create(trigger: name).of(schema: schema).before().update().of(columns: column1, column2).on(table: table).forEachRow().when(condition).execute(update),\n            \"CREATE TRIGGER testSchema.testTrigger BEFORE UPDATE OF testColumn1, testColumn2 ON testTable FOR EACH ROW WHEN 1 BEGIN UPDATE testTable SET testColumn = 1; END\"\n        )\n\n        WINQAssertEqual(\n            StatementCreateTrigger().create(trigger: name).of(schema: schema).before().update().of(columns: column1, column2).on(table: table).when(condition).execute(update),\n            \"CREATE TRIGGER testSchema.testTrigger BEFORE UPDATE OF testColumn1, testColumn2 ON testTable WHEN 1 BEGIN UPDATE testTable SET testColumn = 1; END\"\n        )\n\n        WINQAssertEqual(\n            StatementCreateTrigger().create(trigger: name).of(schema: schema).before().update().of(columns: column1, column2).on(table: table).execute(update),\n            \"CREATE TRIGGER testSchema.testTrigger BEFORE UPDATE OF testColumn1, testColumn2 ON testTable BEGIN UPDATE testTable SET testColumn = 1; END\"\n        )\n\n        WINQAssertEqual(\n            StatementCreateTrigger().create(trigger: name).of(schema: schema).before().delete().on(table: table).forEachRow().when(condition).execute(insert),\n            \"CREATE TRIGGER testSchema.testTrigger BEFORE DELETE ON testTable FOR EACH ROW WHEN 1 BEGIN INSERT INTO testTable VALUES(1); END\"\n        )\n\n        WINQAssertEqual(\n            StatementCreateTrigger().create(trigger: name).of(schema: schema).before().delete().on(table: table).forEachRow().when(condition).execute(delete_),\n            \"CREATE TRIGGER testSchema.testTrigger BEFORE DELETE ON testTable FOR EACH ROW WHEN 1 BEGIN DELETE FROM testTable; END\"\n        )\n\n        WINQAssertEqual(\n            StatementCreateTrigger().create(trigger: name).of(schema: schema).before().delete().on(table: table).forEachRow().when(condition).execute(select),\n            \"CREATE TRIGGER testSchema.testTrigger BEFORE DELETE ON testTable FOR EACH ROW WHEN 1 BEGIN SELECT 1; END\"\n        )\n\n        WINQAssertEqual(\n            StatementCreateTrigger().create(trigger: name).of(schema: schema).before().delete().on(table: table).forEachRow().when(condition).execute(update).execute(insert).execute(delete_).execute(select),\n            \"CREATE TRIGGER testSchema.testTrigger BEFORE DELETE ON testTable FOR EACH ROW WHEN 1 BEGIN UPDATE testTable SET testColumn = 1; INSERT INTO testTable VALUES(1); DELETE FROM testTable; SELECT 1; END\"\n        )\n    }\n}\n"
  },
  {
    "path": "src/swift/tests/winq/statement/StatementCreateViewTests.swift",
    "content": "//\n// Created by qiuwenchen on 2022/7/13.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport XCTest\n#if TEST_WCDB_SWIFT\nimport WCDBSwift\n#else\nimport WCDB\n#endif\n\nclass StatementCreateViewTests: BaseTestCase {\n\n    func testCreateView() {\n        // Give\n        let column1 = Column(named: \"column1\")\n        let column2 = Column(named: \"column2\")\n\n        let statementSelect = StatementSelect().select(column1).from(\"testTable\")\n\n        WINQAssertEqual(\n            StatementCreateView().create(view: \"testView\").with(columns: column1, column2).as(statementSelect),\n            \"CREATE VIEW testView(column1, column2) AS SELECT column1 FROM testTable\"\n        )\n\n        WINQAssertEqual(\n            StatementCreateView().create(view: \"testView\", isTemp: true).with(columns: column1, column2).as(statementSelect),\n            \"CREATE TEMP VIEW testView(column1, column2) AS SELECT column1 FROM testTable\"\n        )\n\n        WINQAssertEqual(\n            StatementCreateView().create(view: \"testView\").of(schema: \"testSchema\").with(columns: column1, column2).as(statementSelect),\n            \"CREATE VIEW testSchema.testView(column1, column2) AS SELECT column1 FROM testTable\"\n        )\n\n        WINQAssertEqual(\n            StatementCreateView().create(view: \"testView\").ifNotExists().with(columns: column1, column2).as(statementSelect),\n            \"CREATE VIEW IF NOT EXISTS testView(column1, column2) AS SELECT column1 FROM testTable\"\n        )\n    }\n}\n"
  },
  {
    "path": "src/swift/tests/winq/statement/StatementCreateVirtualTableTests.swift",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport XCTest\n#if TEST_WCDB_SWIFT\nimport WCDBSwift\n#else\nimport WCDB\n#endif\n\nclass StatementCreateVirtualTableTests: BaseTestCase {\n\n    func testStatementCreateVirtualTable() {\n        // Give\n        let virtualTable1 = \"virtualTable1\"\n        let tokenizer = \"tokenize=\\(BuiltinTokenizer.OneOrBinary)\"\n        let virtualTable2 = \"virtualTable2\"\n        let module = \"testModule\"\n        let argument = \"left=right\"\n\n        // Then\n\n        WINQAssertEqual(\n            StatementCreateVirtualTable()\n                .create(virtualTable: virtualTable1).ifNotExists().using(module: .FTS3).arguments(tokenizer),\n            \"CREATE VIRTUAL TABLE IF NOT EXISTS virtualTable1 USING fts3(tokenize=WCDB)\"\n        )\n\n        WINQAssertEqual(\n            StatementCreateVirtualTable().create(virtualTable: virtualTable2).using(module: module).arguments(argument),\n            \"CREATE VIRTUAL TABLE virtualTable2 USING testModule(left=right)\"\n        )\n    }\n}\n"
  },
  {
    "path": "src/swift/tests/winq/statement/StatementDeleteTests.swift",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport XCTest\n#if TEST_WCDB_SWIFT\nimport WCDBSwift\n#else\nimport WCDB\n#endif\n\nclass StatementDeleteTests: BaseTestCase {\n\n    func generateStatementDelete() -> StatementDelete {\n        let testTable = \"testTable\"\n        return StatementDelete().delete(from: testTable)\n    }\n\n    func testStatementDelete() {\n        // Give\n        let column1 = Column(named: \"column1\")\n        let column2 = Column(named: \"column2\")\n\n        WINQAssertEqual(generateStatementDelete().`where`(column1 > 1), \"DELETE FROM testTable WHERE column1 > 1\")\n\n        WINQAssertEqual(StatementDelete().delete(from: \"testTable\".asQualifiedTable().of(schema: \"testSchema\")).`where`(column1 > 1), \"DELETE FROM testSchema.testTable WHERE column1 > 1\")\n\n        WINQAssertEqual(\n            generateStatementDelete().order(by: column1.asOrder(), column2.asOrder()),\n            \"DELETE FROM testTable ORDER BY column1, column2\")\n\n        WINQAssertEqual(generateStatementDelete().limit(1), \"DELETE FROM testTable LIMIT 1\")\n\n        WINQAssertEqual(generateStatementDelete().limit(from: 1, to: 2), \"DELETE FROM testTable LIMIT 1, 2\")\n\n        WINQAssertEqual(generateStatementDelete().limit(1).offset(3), \"DELETE FROM testTable LIMIT 1 OFFSET 3\")\n\n        WINQAssertEqual(\n            generateStatementDelete()\n                .`where`(column1 > 1)\n                .order(by: column1.asOrder(), column2.asOrder())\n                .limit(1).offset(2),\n            \"DELETE FROM testTable WHERE column1 > 1 ORDER BY column1, column2 LIMIT 1 OFFSET 2\"\n        )\n\n        WINQAssertEqual(\n            generateStatementDelete()\n                .with(CommonTableExpression(\"testTable\").as(StatementSelect().select(1)))\n                .delete(from: \"testTable\")\n                .`where`(column1 > 1),\n            \"WITH testTable AS(SELECT 1) DELETE FROM testTable WHERE column1 > 1\"\n        )\n    }\n}\n"
  },
  {
    "path": "src/swift/tests/winq/statement/StatementDetachTests.swift",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport XCTest\n#if TEST_WCDB_SWIFT\nimport WCDBSwift\n#else\nimport WCDB\n#endif\n\nclass StatementDetachTests: BaseTestCase {\n\n    func testStatementDetach() {\n        WINQAssertEqual(StatementDetach().detach(schema: \"testSchema\"), \"DETACH testSchema\")\n    }\n}\n"
  },
  {
    "path": "src/swift/tests/winq/statement/StatementDropIndexTests.swift",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport XCTest\n#if TEST_WCDB_SWIFT\nimport WCDBSwift\n#else\nimport WCDB\n#endif\n\nclass StatementDropIndexTests: BaseTestCase {\n\n    func testStatementDropIndex() {\n\n        WINQAssertEqual(StatementDropIndex().drop(index: \"testIndex\"), \"DROP INDEX testIndex\")\n\n        WINQAssertEqual(StatementDropIndex().drop(index: \"testIndex\").ifExists(), \"DROP INDEX IF EXISTS testIndex\")\n\n        WINQAssertEqual(StatementDropIndex().drop(index: \"testIndex\").of(schema: \"testSchema\"), \"DROP INDEX testSchema.testIndex\")\n\n    }\n}\n"
  },
  {
    "path": "src/swift/tests/winq/statement/StatementDropTableTests.swift",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport XCTest\n#if TEST_WCDB_SWIFT\nimport WCDBSwift\n#else\nimport WCDB\n#endif\n\nclass StatementDropTableTests: BaseTestCase {\n\n    func testStatementDropTable() {\n\n        WINQAssertEqual(StatementDropTable().drop(table: \"testTable\"), \"DROP TABLE testTable\")\n\n        WINQAssertEqual(StatementDropTable().drop(table: \"testTable\").ifExists(), \"DROP TABLE IF EXISTS testTable\")\n\n        WINQAssertEqual(StatementDropTable().drop(table: \"testTable\").of(schema: \"testSchema\"), \"DROP TABLE testSchema.testTable\")\n\n    }\n}\n"
  },
  {
    "path": "src/swift/tests/winq/statement/StatementDropTriggerTests.swift",
    "content": "//\n// Created by qiuwenchen on 2022/7/13.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport XCTest\n#if TEST_WCDB_SWIFT\nimport WCDBSwift\n#else\nimport WCDB\n#endif\n\nclass StatementDropTriggerTests: BaseTestCase {\n\n    func testStatementDropTrigger() {\n\n        WINQAssertEqual(StatementDropTrigger().drop(trigger: \"testTrigger\"), \"DROP TRIGGER testTrigger\")\n\n        WINQAssertEqual(StatementDropTrigger().drop(trigger: \"testTrigger\").ifExists(), \"DROP TRIGGER IF EXISTS testTrigger\")\n\n        WINQAssertEqual(StatementDropTrigger().drop(trigger: \"testTrigger\").of(schema: \"testSchema\"), \"DROP TRIGGER testSchema.testTrigger\")\n\n    }\n}\n"
  },
  {
    "path": "src/swift/tests/winq/statement/StatementDropViewTests.swift",
    "content": "//\n// Created by qiuwenchen on 2022/7/13.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport XCTest\n#if TEST_WCDB_SWIFT\nimport WCDBSwift\n#else\nimport WCDB\n#endif\n\nclass StatementDropViewTests: BaseTestCase {\n\n    func testStatementDropView() {\n\n        WINQAssertEqual(StatementDropView().drop(view: \"testView\"), \"DROP VIEW testView\")\n\n        WINQAssertEqual(StatementDropView().drop(view: \"testView\").ifExists(), \"DROP VIEW IF EXISTS testView\")\n\n        WINQAssertEqual(StatementDropView().drop(view: \"testView\").of(schema: \"testSchema\"), \"DROP VIEW testSchema.testView\")\n\n    }\n}\n"
  },
  {
    "path": "src/swift/tests/winq/statement/StatementExplainTests.swift",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport XCTest\n#if TEST_WCDB_SWIFT\nimport WCDBSwift\n#else\nimport WCDB\n#endif\n\nclass StatementExplainTests: BaseTestCase {\n\n    func testStatementExplain() {\n        let statement = StatementSelect().select(1).from(\"testTable\")\n\n        WINQAssertEqual(StatementExplain().explain(statement), \"EXPLAIN SELECT 1 FROM testTable\")\n\n        WINQAssertEqual(StatementExplain().explainQueryPlan(statement), \"EXPLAIN QUERY PLAN SELECT 1 FROM testTable\")\n    }\n}\n"
  },
  {
    "path": "src/swift/tests/winq/statement/StatementInsertTests.swift",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport XCTest\n#if TEST_WCDB_SWIFT\nimport WCDBSwift\n#else\nimport WCDB\n#endif\n\nclass StatementInsertTests: BaseTestCase {\n\n    func testStatementInsert() {\n        // Give\n        let column1 = Column(named: \"column1\")\n        let column2 = Column(named: \"column2\")\n\n        // Then\n\n        WINQAssertEqual(\n            StatementInsert().insert(intoTable: \"testTable\").values(1, \"value\"),\n            \"INSERT INTO testTable VALUES(1, 'value')\"\n        )\n\n        WINQAssertEqual(\n            StatementInsert().insert(intoTable: \"testTable\").of(schema: \"testSchema\").values(1, \"value\"),\n            \"INSERT INTO testSchema.testTable VALUES(1, 'value')\"\n        )\n\n        WINQAssertEqual(\n            StatementInsert().insert(intoTable: \"testTable\").of(schema: \"testSchema\").as(\"newTable\").values(1, \"value\"),\n            \"INSERT INTO testSchema.testTable AS newTable VALUES(1, 'value')\"\n        )\n\n        WINQAssertEqual(\n            StatementInsert().insert(intoTable: \"testTable\").columns(column1, column2).values(1, \"value\"),\n            \"INSERT INTO testTable(column1, column2) VALUES(1, 'value')\"\n        )\n\n        WINQAssertEqual(\n            StatementInsert().insert(intoTable: \"testTable\").onConflict(.Replace).values(1, \"value\"),\n            \"INSERT OR REPLACE INTO testTable VALUES(1, 'value')\"\n        )\n\n        WINQAssertEqual(\n            StatementInsert().insert(intoTable: \"testTable\").defaultValues(),\n            \"INSERT INTO testTable DEFAULT VALUES\"\n        )\n\n        WINQAssertEqual(\n            StatementInsert().insert(intoTable: \"testTable\").columns(column1, column2).values(1, \"value\").upsert(Upsert().doNothing()),\n            \"INSERT INTO testTable(column1, column2) VALUES(1, 'value') ON CONFLICT DO NOTHING\"\n        )\n    }\n}\n"
  },
  {
    "path": "src/swift/tests/winq/statement/StatementPragmaTests.swift",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport XCTest\n#if TEST_WCDB_SWIFT\nimport WCDBSwift\n#else\nimport WCDB\n#endif\n\nclass StatementPragmaTests: BaseTestCase {\n\n    func testStatementPragma() {\n\n        WINQAssertEqual(StatementPragma().pragma(.pageSize), \"PRAGMA page_size\")\n\n        WINQAssertEqual(StatementPragma().pragma(.secureDelete).to(true), \"PRAGMA secure_delete = 1\")\n\n        WINQAssertEqual(StatementPragma().schema(\"testSchema\").pragma(.secureDelete).to(true), \"PRAGMA testSchema.secure_delete = 1\")\n\n        WINQAssertEqual(StatementPragma().schema(\"testSchema\").pragma(.tableInfo).with(\"testTable\"), \"PRAGMA testSchema.table_info('testTable')\")\n    }\n}\n"
  },
  {
    "path": "src/swift/tests/winq/statement/StatementReindexTests.swift",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport XCTest\n#if TEST_WCDB_SWIFT\nimport WCDBSwift\n#else\nimport WCDB\n#endif\n\nclass StatementReindexTests: BaseTestCase {\n\n    func testStatementReindex() {\n\n        WINQAssertEqual(StatementReindex().reindex(table: \"testTable\"), \"REINDEX testTable\")\n        WINQAssertEqual(StatementReindex().reindex(table: \"testTable\").of(schema: \"testSchema\"), \"REINDEX testSchema.testTable\")\n\n        WINQAssertEqual(StatementReindex().reindex(index: \"testIndex\"), \"REINDEX testIndex\")\n        WINQAssertEqual(StatementReindex().reindex(index: \"testIndex\").of(schema: \"testSchema\"), \"REINDEX testSchema.testIndex\")\n\n        WINQAssertEqual(StatementReindex().reindex(collation: \"testCollation\"), \"REINDEX testCollation\")\n    }\n}\n"
  },
  {
    "path": "src/swift/tests/winq/statement/StatementReleaseTests.swift",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport XCTest\n#if TEST_WCDB_SWIFT\nimport WCDBSwift\n#else\nimport WCDB\n#endif\n\nclass StatementReleaseTests: BaseTestCase {\n\n    func testStatementRelease() {\n\n        WINQAssertEqual(StatementRelease().release(savepoint: \"savepoint1\"), \"RELEASE savepoint1\")\n    }\n}\n"
  },
  {
    "path": "src/swift/tests/winq/statement/StatementRollbackTests.swift",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport XCTest\n#if TEST_WCDB_SWIFT\nimport WCDBSwift\n#else\nimport WCDB\n#endif\n\nclass StatementRollbackTests: BaseTestCase {\n\n    func testStatementRollback() {\n\n        WINQAssertEqual(StatementRollback(), \"ROLLBACK\")\n\n        WINQAssertEqual(StatementRollback().rollback(toSavepoint: \"savepoint1\"), \"ROLLBACK TO savepoint1\")\n    }\n}\n"
  },
  {
    "path": "src/swift/tests/winq/statement/StatementSavepointTests.swift",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport XCTest\n#if TEST_WCDB_SWIFT\nimport WCDBSwift\n#else\nimport WCDB\n#endif\n\nclass StatementSavepointTests: BaseTestCase {\n\n    func testStatementSavepoint() {\n        WINQAssertEqual(StatementSavepoint().savepoint(\"savepoint1\"), \"SAVEPOINT savepoint1\")\n    }\n}\n"
  },
  {
    "path": "src/swift/tests/winq/statement/StatementSelectTests.swift",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport XCTest\n#if TEST_WCDB_SWIFT\nimport WCDBSwift\n#else\nimport WCDB\n#endif\n\nclass StatementSelectTests: BaseTestCase {\n\n    func testStatementSelect() {\n        // Give\n        let column1 = Column(named: \"column1\")\n        let column2 = Column(named: \"column2\")\n\n        let table1 = \"table1\"\n        let table2 = \"table2\"\n\n        WINQAssertEqual(StatementSelect().select(column1).from(table1), \"SELECT column1 FROM table1\")\n\n        WINQAssertEqual(\n            StatementSelect().select(column1, column2).from(table1),\n            \"SELECT column1, column2 FROM table1\"\n        )\n\n        WINQAssertEqual(\n            StatementSelect().select(distinct: true, column1, column2).from(table1),\n            \"SELECT DISTINCT column1, column2 FROM table1\"\n        )\n\n        WINQAssertEqual(\n            StatementSelect().select(column1).from(table1, table2),\n            \"SELECT column1 FROM table1, table2\"\n        )\n\n        WINQAssertEqual(\n            StatementSelect().select(column1).from(table1).`where`(column1 > 1),\n            \"SELECT column1 FROM table1 WHERE column1 > 1\"\n        )\n\n        WINQAssertEqual(\n            StatementSelect().select(column1).from(table1).order(by: column1.asOrder(), column2.asOrder()),\n            \"SELECT column1 FROM table1 ORDER BY column1, column2\"\n        )\n\n        WINQAssertEqual(\n            StatementSelect().select(column1).from(table1).limit(1),\n            \"SELECT column1 FROM table1 LIMIT 1\"\n        )\n\n        WINQAssertEqual(\n            StatementSelect().select(column1).from(table1).limit(from: 1, to: 2),\n            \"SELECT column1 FROM table1 LIMIT 1, 2\"\n        )\n\n        WINQAssertEqual(\n            StatementSelect().select(column1).from(table1).limit(1).offset(3),\n            \"SELECT column1 FROM table1 LIMIT 1 OFFSET 3\"\n        )\n\n        WINQAssertEqual(\n            StatementSelect().select(column1).from(table1).group(by: column1),\n            \"SELECT column1 FROM table1 GROUP BY column1\"\n        )\n\n        WINQAssertEqual(\n            StatementSelect().select(column1).from(table1).group(by: column1, column2).having(column1>1),\n            \"SELECT column1 FROM table1 GROUP BY column1, column2 HAVING column1 > 1\"\n        )\n\n        WINQAssertEqual(\n            StatementSelect().select(column1).from(table1).asTableOrSubquery(),\n            \"(SELECT column1 FROM table1)\"\n        )\n\n        WINQAssertEqual(\n            StatementSelect().with(CommonTableExpression(table1).column(column1).as(StatementSelect().select(1)), CommonTableExpression(table2).column(column2).as(StatementSelect().select(2))).select(1, 2),\n            \"WITH table1(column1) AS(SELECT 1), table2(column2) AS(SELECT 2) SELECT 1, 2\"\n        )\n\n        WINQAssertEqual(\n            StatementSelect().with(recursive: true, CommonTableExpression(table1).column(column1).as(StatementSelect().select(1)), CommonTableExpression(table2).column(column2).as(StatementSelect().select(2))).select(1, 2),\n            \"WITH RECURSIVE table1(column1) AS(SELECT 1), table2(column2) AS(SELECT 2) SELECT 1, 2\"\n        )\n\n        WINQAssertEqual(\n            StatementSelect().select(1, 2).window(\"window1\").as(WindowDef().order(1)).window(\"window2\").as(WindowDef().order(2)),\n            \"SELECT 1, 2 WINDOW window1 AS (ORDER BY 1), window2 AS (ORDER BY 2)\"\n        )\n\n        WINQAssertEqual(\n            StatementSelect().value(1, 2),\n            \"VALUES(1, 2)\"\n        )\n        WINQAssertEqual(\n            StatementSelect().value(1, 2).value(1, 2),\n            \"VALUES(1, 2), (1, 2)\"\n        )\n\n        WINQAssertEqual(\n            StatementSelect().select(1, 2).group(by: 1, 2).union().select(1, 2).where(1),\n            \"SELECT 1, 2 GROUP BY 1, 2 UNION SELECT 1, 2 WHERE 1\"\n        )\n\n        WINQAssertEqual(\n            StatementSelect().select(1, 2).unionAll().value(1, 2),\n            \"SELECT 1, 2 UNION ALL VALUES(1, 2)\"\n        )\n\n        WINQAssertEqual(\n            StatementSelect().select(1, 2).intersect().value(1, 2),\n            \"SELECT 1, 2 INTERSECT VALUES(1, 2)\"\n        )\n\n        WINQAssertEqual(\n            StatementSelect().select(1, 2).except().value(1, 2),\n            \"SELECT 1, 2 EXCEPT VALUES(1, 2)\"\n        )\n    }\n}\n"
  },
  {
    "path": "src/swift/tests/winq/statement/StatementUpdateTests.swift",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport XCTest\n#if TEST_WCDB_SWIFT\nimport WCDBSwift\n#else\nimport WCDB\n#endif\n\nclass StatementUpdateTests: BaseTestCase {\n\n    func testStatementUpdate() {\n        // Give\n        let column1 = Column(named: \"column1\")\n        let column2 = Column(named: \"column2\")\n\n        WINQAssertEqual(\n            StatementUpdate().update(table: \"testTable\").set(column1).to(1),\n            \"UPDATE testTable SET column1 = 1\"\n        )\n\n        WINQAssertEqual(\n            StatementUpdate().update(table: \"testTable\").onConflict( .Replace).set(column1).to(1).set(column2).to(\"test\"),\n            \"UPDATE OR REPLACE testTable SET column1 = 1, column2 = 'test'\"\n        )\n\n        WINQAssertEqual(\n            StatementUpdate().update(table: \"testTable\").set(column1).to(1).set(column2).to(\"test\"),\n            \"UPDATE testTable SET column1 = 1, column2 = 'test'\"\n        )\n\n        WINQAssertEqual(\n            StatementUpdate().update(table: \"testTable\").set(column1).to(1).`where`(column1 > 1),\n            \"UPDATE testTable SET column1 = 1 WHERE column1 > 1\"\n        )\n\n        WINQAssertEqual(\n            StatementUpdate()\n                .update(table: \"testTable\")\n                .set(column1).to(1)\n                .order(by: column1.asOrder(), column2.asOrder()),\n            \"UPDATE testTable SET column1 = 1 ORDER BY column1, column2\"\n        )\n\n        WINQAssertEqual(\n            StatementUpdate().update(table: \"testTable\").set(column1).to(1).limit(1),\n            \"UPDATE testTable SET column1 = 1 LIMIT 1\"\n        )\n\n        WINQAssertEqual(\n            StatementUpdate().update(table: \"testTable\").set(column1).to(1).limit(from: 1, to: 2),\n            \"UPDATE testTable SET column1 = 1 LIMIT 1, 2\"\n        )\n\n        WINQAssertEqual(\n            StatementUpdate().update(table: \"testTable\").set(column1).to(1).limit(1).offset(3),\n            \"UPDATE testTable SET column1 = 1 LIMIT 1 OFFSET 3\"\n        )\n\n        WINQAssertEqual(\n            StatementUpdate().with(CommonTableExpression(\"testTable\").column(column1).as(StatementSelect().select(1))).update(table: \"testTable\").set(column1).to(1),\n            \"WITH testTable(column1) AS(SELECT 1) UPDATE testTable SET column1 = 1\"\n        )\n\n        WINQAssertEqual(\n            StatementUpdate().with(recursive: true, CommonTableExpression(\"table1\").column(column1).as(StatementSelect().select(1)), CommonTableExpression(\"table2\").column(column2).as(StatementSelect().select(2))).update(table: \"testTable\").set(column1).to(1),\n            \"WITH RECURSIVE table1(column1) AS(SELECT 1), table2(column2) AS(SELECT 2) UPDATE testTable SET column1 = 1\"\n        )\n    }\n}\n"
  },
  {
    "path": "src/swift/tests/winq/statement/StatementVacuumTests.swift",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport XCTest\n#if TEST_WCDB_SWIFT\nimport WCDBSwift\n#else\nimport WCDB\n#endif\n\nclass StatementVacuumTests: BaseTestCase {\n\n    func testStatementVacuum() {\n        WINQAssertEqual(StatementVacuum().vacuum(), \"VACUUM\")\n        WINQAssertEqual(StatementVacuum().vacuum(schema: \"testSchema\"), \"VACUUM testSchema\")\n    }\n}\n"
  },
  {
    "path": "src/swift/util/Convenience.swift",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport Foundation\n#if SWIFT_PACKAGE\nimport WCDB_Private\n#elseif WCDB_SWIFT_TARGET\nimport WCDBSwift.Private\n#else\nimport WCDB.Private\n#endif\n\ninternal extension Array {\n    func joined(_ map: (Element) -> String, separateBy separator: String = \", \") -> String {\n        var flag = false\n        return reduce(into: \"\") { (output, element) in\n            if flag {\n                output.append(separator)\n            } else {\n                flag = true\n            }\n            output.append(map(element))\n        }\n    }\n}\n\ninternal extension Array where Element: StringProtocol {\n    func joined(separateBy separator: String = \", \") -> String {\n        var flag = false\n        return reduce(into: \"\") { (output, element) in\n            if flag {\n                output.append(separator)\n            } else {\n                flag = true\n            }\n            output.append(String(element))\n        }\n    }\n}\n\ninternal extension Array where Element: Describable {\n    func joined(separateBy separator: String = \", \") -> String {\n        return joined({ $0.description }, separateBy: separator)\n    }\n}\n\ninternal extension Array where Element==PropertyConvertible {\n    func asCodingTableKeys() -> [CodingTableKeyBase] {\n        return reduce(into: [CodingTableKeyBase]()) { (result, element) in\n            assert(element.codingTableKey != nil, \"CodingTableKey should not be failed. If you think it's a bug, please report an issue to us.\")\n            result.append(element.codingTableKey!)\n        }\n    }\n#if WCDB_SWIFT_BRIDGE_OBJC\n    func asWCTBridgeProperties() -> [WCTBridgeProperty] {\n        return reduce(into: [WCTBridgeProperty]()) { (result, element) in\n            assert(element.wctProperty != nil, \"WCTProperty should not be failed. If you think it's a bug, please report an issue to us.\")\n            result.append(element.wctProperty!)\n        }\n    }\n#endif\n}\n\ninternal extension Array where Element: PropertyConvertible {\n    func asCodingTableKeys() -> [CodingTableKeyBase] {\n        return reduce(into: [CodingTableKeyBase]()) { (result, element) in\n            assert(element.codingTableKey != nil, \"CodingTableKey should not be failed. If you think it's a bug, please report an issue to us.\")\n            result.append(element.codingTableKey!)\n        }\n    }\n#if WCDB_SWIFT_BRIDGE_OBJC\n    func asWCTBridgeProperties() -> [WCTBridgeProperty] {\n        return reduce(into: [WCTBridgeProperty]()) { (result, element) in\n            assert(element.wctProperty != nil, \"WCTProperty should not be failed. If you think it's a bug, please report an issue to us.\")\n            result.append(element.wctProperty!)\n        }\n    }\n#endif\n}\n\ninternal extension Array {\n    mutating func expand(toNewSize newSize: Int, fillWith value: Iterator.Element) {\n        if count < newSize {\n            append(contentsOf: repeatElement(value, count: count.distance(to: newSize)))\n        }\n    }\n}\n\ninternal extension Array where Iterator.Element: FixedWidthInteger {\n    mutating func expand(toNewSize newSize: Int) {\n        expand(toNewSize: newSize, fillWith: 0)\n    }\n}\n\ninternal extension Dictionary {\n    func joined(_ map: (Key, Value) -> String, separateBy separator: String = \",\" ) -> String {\n        var flag = false\n        return reduce(into: \"\", { (output, arg) in\n            if flag {\n                output.append(separator)\n            } else {\n                flag = true\n            }\n            output.append(map(arg.key, arg.value))\n        })\n    }\n}\n\ninternal extension String {\n    var lastPathComponent: String {\n        return URL(fileURLWithPath: self).lastPathComponent\n    }\n\n    func stringByAppending(pathComponent: String) -> String {\n        return URL(fileURLWithPath: self).appendingPathComponent(pathComponent).path\n    }\n\n    var cString: UnsafePointer<Int8>? {\n        return UnsafePointer<Int8>((self as NSString).utf8String)\n    }\n\n    init?(bytes: UnsafeRawPointer, count: Int, encoding: String.Encoding) {\n        self.init(data: Data(bytes: bytes, count: count), encoding: encoding)\n    }\n\n    func range(from begin: Int, to end: Int) -> Range<String.Index> {\n        return index(startIndex, offsetBy: begin)..<index(startIndex, offsetBy: end)\n    }\n\n    func range(location: Int, length: Int) -> Range<String.Index> {\n        return range(from: location, to: location + length)\n    }\n}\n\ninternal extension Bool {\n    @inline(__always) func toInt32() -> Int32 {\n        return self ? 1 : 0\n    }\n}\n\ninternal extension Int {\n    @inline(__always) func toInt64() -> Int64 {\n        return Int64(self)\n    }\n}\n\ninternal extension Int8 {\n    @inline(__always) func toInt32() -> Int32 {\n        return Int32(self)\n    }\n}\n\ninternal extension Int16 {\n    @inline(__always) func toInt32() -> Int32 {\n        return Int32(self)\n    }\n}\n\ninternal extension Int32 {\n    @inline(__always) func toBool() -> Bool {\n        return self != 0\n    }\n    @inline(__always) func toInt8() -> Int8 {\n        return Int8(truncatingIfNeeded: self)\n    }\n    @inline(__always) func toInt16() -> Int16 {\n        return Int16(truncatingIfNeeded: self)\n    }\n    @inline(__always) func toUInt8() -> UInt8 {\n        return UInt8(bitPattern: Int8(truncatingIfNeeded: self))\n    }\n    @inline(__always) func toUInt16() -> UInt16 {\n        return UInt16(bitPattern: Int16(truncatingIfNeeded: self))\n    }\n    @inline(__always) func toUInt32() -> UInt32 {\n        return UInt32(bitPattern: self)\n    }\n}\n\ninternal extension Int64 {\n    @inline(__always) func toInt() -> Int {\n        return Int(truncatingIfNeeded: self)\n    }\n    @inline(__always) func toUInt() -> UInt {\n        return UInt(bitPattern: Int(truncatingIfNeeded: self))\n    }\n    @inline(__always) func toUInt64() -> UInt64 {\n        return UInt64(bitPattern: self)\n    }\n}\n\ninternal extension UInt {\n    @inline(__always) func toInt64() -> Int64 {\n        return Int64(bitPattern: UInt64(self))\n    }\n}\n\ninternal extension UInt8 {\n    @inline(__always) func toInt32() -> Int32 {\n        return Int32(bitPattern: UInt32(self))\n    }\n}\n\ninternal extension UInt16 {\n    @inline(__always) func toInt32() -> Int32 {\n        return Int32(bitPattern: UInt32(self))\n    }\n}\n\ninternal extension UInt32 {\n    @inline(__always) func toInt32() -> Int32 {\n        return Int32(bitPattern: self)\n    }\n}\n\ninternal extension UInt64 {\n    @inline(__always) func toInt64() -> Int64 {\n        return Int64(bitPattern: self)\n    }\n}\n\ninternal extension Float {\n    @inline(__always) func toDouble() -> Double {\n        return Double(self)\n    }\n}\n\ninternal extension Double {\n    @inline(__always) func toFloat() -> Float {\n        return Float(self)\n    }\n}\n"
  },
  {
    "path": "src/swift/util/Lock.swift",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport Foundation\n#if SWIFT_PACKAGE\nimport WCDB_Private\n#elseif WCDB_SWIFT_TARGET\nimport WCDBSwift.Private\n#else\nimport WCDB.Private\n#endif\n\ninternal protocol Lockable: AnyObject {\n    func lock()\n    func unlock()\n}\n\n@available(iOS 10.0, OSX 10.12, watchOS 3.0, tvOS 10.0, *)\ninternal final class UnfairLock: Lockable {\n    private var unfairLock = os_unfair_lock_s()\n\n    internal func lock() {\n        os_unfair_lock_lock(&unfairLock)\n    }\n\n    internal func unlock() {\n        os_unfair_lock_unlock(&unfairLock)\n    }\n}\n\ninternal final class Mutex: Lockable {\n    private var mutex = pthread_mutex_t()\n\n    internal init() {\n        pthread_mutex_init(&mutex, nil)\n    }\n\n    deinit {\n        pthread_mutex_destroy(&mutex)\n    }\n\n    internal func lock() {\n        pthread_mutex_lock(&mutex)\n    }\n\n    internal func unlock() {\n        pthread_mutex_unlock(&mutex)\n    }\n}\n\n// internal final class RecursiveMutex: Lockable {\n//    private var mutex = pthread_mutex_t()\n//\n//    internal init() {\n//        // No idea why this line can cause compile failure in SwiftPM.\n//        var attr = pthread_mutexattr_t()\n//        pthread_mutexattr_init(&attr)\n//        pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE)\n//        pthread_mutex_init(&mutex, &attr)\n//    }\n//\n//    deinit {\n//        pthread_mutex_destroy(&mutex)\n//    }\n//\n//    internal func lock() {\n//        pthread_mutex_lock(&mutex)\n//    }\n//\n//    internal func unlock() {\n//        pthread_mutex_unlock(&mutex)\n//    }\n// }\n\ninternal final class Spin: Lockable {\n    private let locker: Lockable\n\n    internal init() {\n        if #available(iOS 10.0, macOS 10.12, watchOS 3.0, tvOS 10.0, *) {\n            locker = UnfairLock()\n        } else {\n            locker = Mutex()\n        }\n    }\n\n    internal func lock() {\n        locker.lock()\n    }\n\n    internal func unlock() {\n        locker.unlock()\n    }\n}\n\ninternal final class ConditionLock: Lockable {\n    private var mutex = pthread_mutex_t()\n    private var cond = pthread_cond_t()\n\n    internal init() {\n        pthread_mutex_init(&mutex, nil)\n        pthread_cond_init(&cond, nil)\n    }\n\n    deinit {\n        pthread_cond_destroy(&cond)\n        pthread_mutex_destroy(&mutex)\n    }\n\n    internal func lock() {\n        pthread_mutex_lock(&mutex)\n    }\n\n    internal func unlock() {\n        pthread_mutex_unlock(&mutex)\n    }\n\n    internal func wait() {\n        pthread_cond_wait(&cond, &mutex)\n    }\n\n    internal func wait(timeout: TimeInterval) {\n        let integerPart = Int(timeout.nextDown)\n        let fractionalPart = timeout - Double(integerPart)\n        var ts = timespec(tv_sec: integerPart, tv_nsec: Int(fractionalPart * 1000000000))\n\n        pthread_cond_timedwait_relative_np(&cond, &mutex, &ts)\n    }\n\n    internal func signal() {\n        pthread_cond_signal(&cond)\n    }\n}\n\ninternal extension DispatchQueue {\n    nonisolated(unsafe) private static let spin = Spin()\n    nonisolated(unsafe) private static var tracker: Set<String> = []\n\n    static func once(name: String, _ block: () -> Void) {\n        spin.lock(); defer { spin.unlock() }\n        guard !tracker.contains(name) else {\n            return\n        }\n        block()\n        tracker.insert(name)\n    }\n}\n"
  },
  {
    "path": "src/swift/util/Optional.swift",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport Foundation\n#if SWIFT_PACKAGE\nimport WCDB_Private\n#elseif WCDB_SWIFT_TARGET\nimport WCDBSwift.Private\n#else\nimport WCDB.Private\n#endif\n\npublic protocol OptionalRepresentable {\n    associatedtype WrappedType\n\n    static var `nil`: Self {get}\n}\n\nextension Optional: OptionalRepresentable {\n    public static var `nil`: Wrapped? {\n        return nil\n    }\n\n    public typealias WrappedType = Wrapped\n}\n"
  },
  {
    "path": "src/swift/util/Recyclable.swift",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport Foundation\n#if SWIFT_PACKAGE\nimport WCDB_Private\n#elseif WCDB_SWIFT_TARGET\nimport WCDBSwift.Private\n#else\nimport WCDB.Private\n#endif\n\n// TODO: Refactor\ninternal class Recyclable<Value> {\n    internal typealias OnRecycled = () -> Void\n    internal let onRecycled: OnRecycled?\n\n    internal final let raw: Value\n\n    internal init(_ raw: Value, onRecycled: @escaping OnRecycled) {\n        self.raw = raw\n        self.onRecycled = onRecycled\n    }\n\n    internal init(_ raw: Value) {\n        self.raw = raw\n        self.onRecycled = nil\n    }\n\n    deinit {\n        if onRecycled != nil {\n            onRecycled!()\n        }\n    }\n}\n"
  },
  {
    "path": "src/swift/util/WCDBError.swift",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport Foundation\n#if SWIFT_PACKAGE\nimport WCDB_Private\n#elseif WCDB_SWIFT_TARGET\nimport WCDBSwift.Private\n#else\nimport WCDB.Private\n#endif\n\npublic final class WCDBError: Swift.Error, CustomStringConvertible {\n    public enum Code: Int, Sendable {\n        case OK = 0\n        case Error = 1\n        case Internal = 2\n        case Permission = 3\n        case Abort = 4\n        case Busy = 5\n        case Locked = 6\n        case NoMemory = 7\n        case Readonly = 8\n        case Interrupt = 9\n        case IOError = 10\n        case Corrupt = 11\n        case NotFound = 12\n        case Full = 13\n        case CantOpen = 14\n        case `Protocol` = 15\n        case Empty = 16\n        case Schema = 17\n        case Exceed = 18\n        case Constraint = 19\n        case Mismatch = 20\n        case Misuse = 21\n        case NoLargeFileSupport = 22\n        case Authorization = 23\n        case Format = 24\n        case Range = 25\n        case NotADatabase = 26\n        case Notice = 27\n        case Warning = 28\n        case Row = 100\n        case Done = 101\n    }\n\n    public enum ExtendCode: Int {\n        case ErrorMissingCollseq = 257       // Code.Error | (1 << 8)\n        case ErrorRetry = 513                // Code.Error | (2 << 8)\n        case ErrorSnapshot = 769             // Code.Error | (3 << 8)\n        case IOErrorRead = 266               // Code.IOError | (1 << 8)\n        case IOErrorShortRead = 522          // Code.IOError | (2 << 8)\n        case IOErrorWrite = 778              // Code.IOError | (3 << 8)\n        case IOErrorFsync = 1034             // Code.IOError | (4 << 8)\n        case IOErrorDirFsync = 1290          // Code.IOError | (5 << 8)\n        case IOErrorTruncate = 1546          // Code.IOError | (6 << 8)\n        case IOErrorFstat = 1802             // Code.IOError | (7 << 8)\n        case IOErrorUnlock = 2058            // Code.IOError | (8 << 8)\n        case IOErrorRdlock = 2314            // Code.IOError | (9 << 8)\n        case IOErrorDelete = 2570            // Code.IOError | (10 << 8)\n        case IOErrorBlocked = 2826           // Code.IOError | (11 << 8)\n        case IOErrorNoMemory = 3082          // Code.IOError | (12 << 8)\n        case IOErrorAccess = 3338            // Code.IOError | (13 << 8)\n        case IOErrorCheckReservedLock = 3594 // Code.IOError | (14 << 8)\n        case IOErrorLock = 3850              // Code.IOError | (15 << 8)\n        case IOErrorClose = 4106             // Code.IOError | (16 << 8)\n        case IOErrorDirClose = 4362          // Code.IOError | (17 << 8)\n        case IOErrorShmOpen = 4618           // Code.IOError | (18 << 8)\n        case IOErrorShmSize = 4874           // Code.IOError | (19 << 8)\n        case IOErrorShmLock = 5130           // Code.IOError | (20 << 8)\n        case IOErrorShmMap = 5386            // Code.IOError | (21 << 8)\n        case IOErrorSeek = 5642              // Code.IOError | (22 << 8)\n        case IOErrorDeleteNoEntry = 5898     // Code.IOError | (23 << 8)\n        case IOErrorMmap = 6154              // Code.IOError | (24 << 8)\n        case IOErrorGetTempPath = 6410       // Code.IOError | (25 << 8)\n        case IOErrorConvPath = 6666          // Code.IOError | (26 << 8)\n        case IOErrorVnode = 6922             // Code.IOError | (27 << 8)\n        case IOErrorAuthorization = 7178     // Code.IOError | (28 << 8)\n        case IOErrorBeginAtomic = 7434       // Code.IOError | (29 << 8)\n        case IOErrorCommitAtomic = 7690      // Code.IOError | (30 << 8)\n        case IOErrorRollbackAtomic = 7946    // Code.IOError | (31 << 8)\n        case LockedSharedCache = 262         // Code.Locked | (1 << 8)\n        case LockedVirtualTable = 518        // Code.Locked | (2 << 8)\n        case BusyRecovery = 261              // Code.Busy | (1 << 8)\n        case BusySnapshot = 517              // Code.Busy | (2 << 8)\n        case CantOpenNoTempDir = 270         // Code.CantOpen | (1 << 8)\n        case CantOpenIsDir = 526             // Code.CantOpen | (2 << 8)\n        case CantOpenFullPath = 782          // Code.CantOpen | (3 << 8)\n        case CantOpenConvPath = 1038         // Code.CantOpen | (4 << 8)\n        case CantOpenDirtyWal = 1294         // Code.CantOpen | (5 << 8)\n        case CorruptVirtualTable = 267       // Code.Corrupt | (1 << 8)\n        case CorruptSequence = 523           // Code.Corrupt | (2 << 8)\n        case ReadonlyRecovery = 264          // Code.Readonly | (1 << 8)\n        case ReadonlyCantLock = 520          // Code.Readonly | (2 << 8)\n        case ReadonlyRollback = 776          // Code.Readonly | (3 << 8)\n        case ReadonlyDatabaseMoved = 1032    // Code.Readonly | (4 << 8)\n        case ReadonlyCantInit = 1288         // Code.Readonly | (5 << 8)\n        case ReadonlyDirectory = 1544        // Code.Readonly | (6 << 8)\n        case AbortRollback = 516             // Code.Abort | (2 << 8)\n        case ConstraintCheck = 275           // Code.Constraint | (1 << 8)\n        case ConstraintCommitHook = 531      // Code.Constraint | (2 << 8)\n        case ConstraintForeignKey = 787      // Code.Constraint | (3 << 8)\n        case ConstraintFunction = 1043       // Code.Constraint | (4 << 8)\n        case ConstraintNotNull = 1299        // Code.Constraint | (5 << 8)\n        case ConstraintPrimaryKey = 1555     // Code.Constraint | (6 << 8)\n        case ConstraintTrigger = 1811        // Code.Constraint | (7 << 8)\n        case ConstraintUnique = 2067         // Code.Constraint | (8 << 8)\n        case ConstraintVirtualTable = 2323   // Code.Constraint | (9 << 8)\n        case ConstraintRowID = 2579          // Code.Constraint | (10 << 8)\n        case NoticeRecoverWal = 283          // Code.Notice | (1 << 8)\n        case NoticeRecoverRollback = 539     // Code.Notice | (2 << 8)\n        case WarningAutoIndex = 284          // Code.Warning | (1 << 8)\n        case AuthorizationUser = 279         // Code.Authorization | (1 << 8)\n        case OKLoadPermanently = 256         // Code.OK | (1 << 8)\n    }\n\n    public enum Level: Int, CustomStringConvertible, Sendable {\n        case Ignore = 1\n        case Debug = 2\n        case Notice = 3\n        case Warning = 4\n        case Error = 5 // Only for the errors that will cause api to return false.\n        case Fatal = 6 // Application should abort.\n        public var description: String {\n            switch self {\n            case .Ignore:\n                return \"IGNORE\"\n            case .Debug:\n                return \"DEBUG\"\n            case .Notice:\n                return \"NOTICE\"\n            case .Warning:\n                return \"WARNING\"\n            case .Error:\n                return \"ERROR\"\n            case .Fatal:\n                return \"FATAL\"\n            }\n        }\n    }\n\n    public enum Key: Int, CustomStringConvertible, Sendable {\n        case tag = 1\n        case path = 2\n        case type = 3\n        case source = 4\n        case SQL = 5\n        case extendedCode = 6\n        case message = 7\n        case invalidKey = 8\n\n        init(stringKey: String) {\n            switch stringKey {\n            case \"Tag\":\n                self = .tag\n            case \"Path\":\n                self = .path\n            case \"Type\":\n                self = .type\n            case \"Source\":\n                self = .source\n            case \"ExtCode\":\n                self = .extendedCode\n            case \"SQL\":\n                self = .SQL\n            case \"Message\":\n                self = .message\n            default:\n                self = .invalidKey\n            }\n        }\n        public var description: String {\n            switch self {\n            case .tag:\n                return \"Tag\"\n            case .path:\n                return \"Path\"\n            case .type:\n                return \"Type\"\n            case .source:\n                return \"Source\"\n            case .extendedCode:\n                return \"ExtCode\"\n            case .message:\n                return \"Message\"\n            case .SQL:\n                return \"SQL\"\n            case .invalidKey:\n                return \"InvalidKey\"\n            }\n        }\n    }\n\n    public let level: WCDBError.Level\n    public let code: WCDBError.Code\n\n    public typealias Infos = [WCDBError.Key: Value]\n    public let infos: Infos\n\n    public typealias ExtInfos = [String: Value]\n    public let extInfos: ExtInfos\n\n    internal convenience init(level: WCDBError.Level, code: WCDBError.Code, infos: Infos) {\n        self.init(level: level, code: code, infos: infos, extInfos: ExtInfos())\n    }\n\n    internal init(level: WCDBError.Level, code: WCDBError.Code, infos: Infos, extInfos: ExtInfos) {\n        self.infos = infos\n        self.level = level\n        self.code = code\n        self.extInfos = extInfos\n    }\n\n    public var tag: Tag? {\n        return Tag(infos[.tag]?.intValue ?? 0)\n    }\n\n    public var extendedCode: WCDBError.ExtendCode? {\n        if let code = infos[Key.extendedCode]?.intValue {\n            return ExtendCode(rawValue: Int(code))\n        }\n        return nil\n    }\n\n    public var message: String? {\n        return infos[.message]?.stringValue\n    }\n\n    public var sql: String? {\n        return infos[.SQL]?.stringValue\n    }\n\n    public var path: String? {\n        return infos[.path]?.stringValue\n    }\n\n    public var description: String {\n        return \"[\\(level)] Code:\\(code) \\(infos.joined({ \"\\($0.description):\\($1.stringValue)\" })) \\(extInfos.joined({ \"\\($0):\\($1.stringValue)\" }))\"\n    }\n}\n"
  },
  {
    "path": "src/swift/winq/Convertible.swift",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport Foundation\n#if SWIFT_PACKAGE\nimport WCDB_Private\n#elseif WCDB_SWIFT_TARGET\nimport WCDBSwift.Private\n#else\nimport WCDB.Private\n#endif\n\npublic protocol OrderingTermConvertible {\n    func asOrder() -> OrderingTerm\n    func order(_ order: Order?) -> OrderingTerm\n    func collate(_ collation: String) -> OrderingTerm\n}\n\npublic protocol SpecificColumnDefConvertible {\n    func asDef(with columnType: ColumnType?) -> ColumnDef\n}\n\npublic protocol IndexedColumnConvertible {\n    func asIndex() -> IndexedColumn\n}\n\npublic protocol SpecificColumnIndexConvertible: IndexedColumnConvertible {\n    func asIndex(orderBy term: Order?) -> IndexedColumn\n}\n\nextension SpecificColumnIndexConvertible {\n    public func asIndex() -> IndexedColumn {\n        return asIndex(orderBy: nil)\n    }\n}\n\npublic protocol ResultColumnConvertible {\n    func asResultColumn() -> ResultColumn\n}\n\npublic protocol SchemaConvertible {\n    func asSchema() -> Schema\n}\n\npublic protocol QualifiedTableConvertible {\n    func asQualifiedTable() -> QualifiedTable\n}\n\npublic protocol TableOrSubqueryConvertible {\n    func asTableOrSubquery() -> TableOrSubquery\n}\n\npublic protocol ExpressionConvertible: ResultColumnConvertible, OrderingTermConvertible {\n    func asExpression() -> Expression\n}\n\nextension ExpressionConvertible {\n    public func asResultColumn() -> ResultColumn {\n        return ResultColumn(with: asExpression())\n    }\n    public func asOrder() -> OrderingTerm {\n        return OrderingTerm(with: self)\n    }\n    public func order(_ order: Order?) -> OrderingTerm {\n        return asOrder().order(order)\n    }\n\n    public func collate(_ collation: String) -> OrderingTerm {\n        return asOrder().collate(collation)\n    }\n}\n\npublic protocol ColumnConvertible: ExpressionConvertible, SpecificColumnIndexConvertible, SpecificColumnDefConvertible {\n    func asColumn() -> Column\n    func `in`(table: String) -> Column\n    func of(schema schemaConvertible: SchemaConvertible) -> Column\n}\n\nextension ColumnConvertible {\n    public func asExpression() -> Expression {\n        return Expression(with: self)\n    }\n\n    public func asIndex(orderBy term: Order?) -> IndexedColumn {\n        let indexedColumn = IndexedColumn(with: self)\n        if let term = term {\n            indexedColumn.order(term)\n        }\n        return indexedColumn\n    }\n\n    public func asDef(with columnType: ColumnType? = nil) -> ColumnDef {\n        return ColumnDef(with: self, and: columnType)\n    }\n\n    public func `in`(table: String) -> Column {\n        return asColumn().in(table: table)\n    }\n    public func of(schema schemaConvertible: SchemaConvertible) -> Column {\n        return asColumn().of(schema: schemaConvertible)\n    }\n}\n\npublic protocol LiteralValueConvertible: ExpressionConvertible {\n    func asLiteralValue() -> LiteralValue\n}\n\nextension LiteralValueConvertible {\n    public func asExpression() -> Expression {\n        return Expression(with: self)\n    }\n}\n"
  },
  {
    "path": "src/swift/winq/Identifier.swift",
    "content": "//\n// Created by qiuwenchen on 2022/5/26.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport Foundation\n#if SWIFT_PACKAGE\nimport WCDB_Private\n#elseif WCDB_SWIFT_TARGET\nimport WCDBSwift.Private\n#else\nimport WCDB.Private\n#endif\n\npublic typealias Describable = CustomStringConvertible\n\npublic class Identifier<CPPType>: Describable, RawCPPObjectRepresentable {\n    internal final let cppObj: CPPType\n    public var rawCPPObj: UnsafeMutablePointer<CPPObject> {\n        unsafeBitCast(cppObj, to: UnsafeMutablePointer<CPPObject>.self)\n    }\n\n    public final var description: String {\n        return String(cString: WCDBWinqGetDescription(rawCPPObj))\n    }\n\n    internal init(with cppObj: CPPType) {\n        self.cppObj = cppObj\n    }\n\n    deinit {\n        let innerValue = unsafeBitCast(cppObj, to: UnsafeMutablePointer<CPPObject>.self)\n        WCDBReleaseCPPObject(innerValue)\n    }\n}\n\npublic protocol RawCPPObjectRepresentable {\n    var rawCPPObj: UnsafeMutablePointer<CPPObject> { get }\n}\n"
  },
  {
    "path": "src/swift/winq/Statement.swift",
    "content": "//\n// Created by qiuwenchen on 2022/11/10.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport Foundation\n#if SWIFT_PACKAGE\nimport WCDB_Private\n#elseif WCDB_SWIFT_TARGET\nimport WCDBSwift.Private\n#else\nimport WCDB.Private\n#endif\n\npublic protocol Statement: AnyObject, CustomStringConvertible {\n    var rawCPPObj: UnsafeMutablePointer<CPPObject> { get }\n}\n"
  },
  {
    "path": "src/swift/winq/SyntaxConst.swift",
    "content": "//\n// Created by qiuwenchen on 2022/5/29.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport Foundation\n#if SWIFT_PACKAGE\nimport WCDB_Private\n#elseif WCDB_SWIFT_TARGET\nimport WCDBSwift.Private\n#else\nimport WCDB.Private\n#endif\n\npublic enum Order {\n    case ascending\n    case descending\n    internal var cValue: WCDBSyntaxOrder {\n        switch self {\n        case .ascending:\n            return WCDBSyntaxOrder_Asc\n        case .descending:\n            return WCDBSyntaxOrder_Desc\n        }\n    }\n}\n\npublic enum ConflictAction {\n    case Replace\n    case Rollback\n    case Abort\n    case Fail\n    case Ignore\n    internal var cValue: WCDBSyntaxConflictAction {\n        switch self {\n        case .Replace:\n            return WCDBSyntaxConflictAction_Replace\n        case .Rollback:\n            return WCDBSyntaxConflictAction_Rollback\n        case .Abort:\n            return WCDBSyntaxConflictAction_Abort\n        case .Fail:\n            return WCDBSyntaxConflictAction_Fail\n        case .Ignore:\n            return WCDBSyntaxConflictAction_Ignore\n        }\n    }\n}\n\npublic enum ColumnType {\n    case integer32\n    case integer64\n    case text\n    case float\n    case BLOB\n    case null\n    internal var cValue: WCDBSyntaxColumnType {\n        switch self {\n        case .integer32:\n            fallthrough\n        case .integer64:\n            return WCDBSyntaxColumnType_Integer\n        case .text:\n            return WCDBSyntaxColumnType_Text\n        case .float:\n            return WCDBSyntaxColumnType_Float\n        case .BLOB:\n            return WCDBSyntaxColumnType_BLOB\n        case .null:\n            return WCDBSyntaxColumnType_Null\n        }\n    }\n}\n\npublic enum TransactionType {\n    case deferred\n    case immediate\n    case exclusive\n    internal var cValue: WCDBSyntaxTransactionType {\n        switch self {\n        case .deferred:\n            return WCDBSyntaxTransactionType_Deferred\n        case .immediate:\n            return WCDBSyntaxTransactionType_Immediate\n        case .exclusive:\n            return WCDBSyntaxTransactionType_Exclusive\n        }\n    }\n}\n\npublic enum FTSVersion: Describable {\n    case FTS3\n    case FTS4\n    case FTS5\n    internal var cValue: WCDBFTSVersion {\n        switch self {\n        case .FTS3:\n            return WCDBFTSVersion3\n        case .FTS4:\n            return WCDBFTSVersion4\n        case .FTS5:\n            return WCDBFTSVersion5\n        }\n    }\n    public var description: String {\n        switch self {\n        case .FTS3:\n            return \"fts3\"\n        case .FTS4:\n            return \"fts4\"\n        case .FTS5:\n            return \"fts5\"\n        }\n    }\n}\n"
  },
  {
    "path": "src/swift/winq/Value.swift",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport Foundation\n#if SWIFT_PACKAGE\nimport WCDB_Private\n#elseif WCDB_SWIFT_TARGET\nimport WCDBSwift.Private\n#else\nimport WCDB.Private\n#endif\n\n// nullable, Int32, Int64, Double, String, Data\npublic struct Value: @unchecked Sendable {\n    private let base: Any?\n    public let type: ColumnType\n\n    public init(_ _: Void? = nil) {\n        base = nil\n        type = .null\n    }\n\n    public init(_ value: Int32) {\n        base = value\n        type = .integer32\n    }\n\n    public init(_ value: Int64) {\n        base = value\n        type = .integer64\n    }\n\n    public init(_ value: Double) {\n        base = value\n        type = .float\n    }\n\n    public init(_ value: String) {\n        base = value\n        type = .text\n    }\n\n    public init(_ value: Data) {\n        base = value\n        type = .BLOB\n    }\n\n    public init<T: ColumnEncodable>(_ encodedValue: T) {\n        self = encodedValue.archivedValue()\n    }\n\n    public var intValue: Int {\n        switch type {\n        case .integer32:\n            return Int(base as! Int32)\n        case .integer64:\n            return Int(truncatingIfNeeded: base as! Int64)\n        case .float:\n            return Int(base as! Double)\n        case .text:\n            return Int(base as! String) ?? 0\n        default:\n            return 0\n        }\n    }\n\n    public var int32Value: Int32 {\n        switch type {\n        case .integer32:\n            return base as! Int32\n        case .integer64:\n            return Int32(truncatingIfNeeded: base as! Int64)\n        case .float:\n            return Int32(base as! Double)\n        case .text:\n            return Int32(base as! String) ?? 0\n        default:\n            return 0\n        }\n    }\n\n    public var int64Value: Int64 {\n        switch type {\n        case .integer32:\n            return Int64(base as! Int32)\n        case .integer64:\n            return base as! Int64\n        case .float:\n            return Int64(base as! Double)\n        case .text:\n            return Int64(base as! String) ?? 0\n        default:\n            return 0\n        }\n    }\n\n    public var stringValue: String {\n        switch type {\n        case .integer32:\n            return \"\\(base as! Int32)\"\n        case .integer64:\n            return \"\\(base as! Int64)\"\n        case .float:\n            return \"\\(base as! Double)\"\n        case .text:\n            return base as! String\n        case .BLOB:\n            return String(data: base as! Data, encoding: .utf8) ?? \"\"\n        default:\n            return \"\"\n        }\n    }\n\n    public var doubleValue: Double {\n        switch type {\n        case .integer32:\n            return Double(base as! Int32)\n        case .integer64:\n            return Double(base as! Int64)\n        case .float:\n            return base as! Double\n        case .text:\n            return Double(base as! String) ?? 0\n        default:\n            return 0\n        }\n    }\n\n    public var dataValue: Data {\n        switch type {\n        case .integer32:\n            fallthrough\n        case .integer64:\n            fallthrough\n        case .float:\n            fallthrough\n        case .text:\n            return stringValue.data(using: .utf8) ?? Data()\n        case .BLOB:\n            return (base as? Data) ?? Data()\n        default:\n            return Data()\n        }\n    }\n}\n\npublic typealias OneColumnValue = [Value]\npublic typealias OneRowValue = [Value]\n\npublic typealias MultiRowsValue = [OneRowValue]\n\nextension Array where Element==[Value] {\n    public subscript(row row: Array.Index, column column: Array<Value>.Index) -> Value {\n        return self[row][column]\n    }\n\n    public subscript(row row: Array.Index) -> OneColumnValue {\n        return self[row]\n    }\n}\n"
  },
  {
    "path": "src/swift/winq/identifier/BindParameter.swift",
    "content": "//\n// Created by qiuwenchen on 2022/5/27.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport Foundation\n#if SWIFT_PACKAGE\nimport WCDB_Private\n#elseif WCDB_SWIFT_TARGET\nimport WCDBSwift.Private\n#else\nimport WCDB.Private\n#endif\n\npublic final class BindParameter: Identifier<CPPBindParameter> {\n\n    public convenience init(_ num: Int32) {\n        self.init(with: WCDBBindparameterCreateQuestionSignType(num))\n    }\n\n    public convenience init(_ name: String) {\n        self.init(with: WCDBBindparameterCreateColonSignType(name.cString))\n    }\n\n    public static func at(named name: String) -> BindParameter {\n        BindParameter(with: WCDBBindparameterCreateAtSignType(name.cString))\n    }\n\n    public static func colon(named name: String) -> BindParameter {\n        BindParameter(with: WCDBBindparameterCreateColonSignType(name.cString))\n    }\n\n    public static func dollar(named name: String) -> BindParameter {\n        BindParameter(with: WCDBBindparameterCreateDollarSignType(name.cString))\n    }\n\n    public static func bindParameters(_ num: Int) -> [BindParameter] {\n        var bindParameters: [BindParameter] = []\n        for i in 1...num {\n            bindParameters.append(BindParameter(Int32(i)))\n        }\n        return bindParameters\n    }\n\n    nonisolated(unsafe) public static let def: BindParameter = BindParameter(0) // ?\n    nonisolated(unsafe) public static let _1: BindParameter = BindParameter(1)  // ?1\n    nonisolated(unsafe) public static let _2: BindParameter = BindParameter(2)  // ?2\n    nonisolated(unsafe) public static let _3: BindParameter = BindParameter(3)  // ?3\n    nonisolated(unsafe) public static let _4: BindParameter = BindParameter(4)  // ?4\n    nonisolated(unsafe) public static let _5: BindParameter = BindParameter(5)  // ?5\n    nonisolated(unsafe) public static let _6: BindParameter = BindParameter(6)  // ?6\n    nonisolated(unsafe) public static let _7: BindParameter = BindParameter(7)  // ?7\n    nonisolated(unsafe) public static let _8: BindParameter = BindParameter(8)  // ?8\n    nonisolated(unsafe) public static let _9: BindParameter = BindParameter(9)  // ?9\n    nonisolated(unsafe) public static let _10: BindParameter = BindParameter(10)// ?10\n}\n\nextension BindParameter: ExpressionConvertible {\n    public func asExpression() -> Expression {\n        Expression(with: self)\n    }\n}\n"
  },
  {
    "path": "src/swift/winq/identifier/Column.swift",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport Foundation\n#if SWIFT_PACKAGE\nimport WCDB_Private\n#elseif WCDB_SWIFT_TARGET\nimport WCDBSwift.Private\n#else\nimport WCDB.Private\n#endif\n\npublic final class Column: Identifier<CPPColumn> {\n\n    public static func all() -> Column {\n        Column(with: WCDBColumnCreateAll())\n    }\n\n    public static func rowid() -> Column {\n        Column(with: WCDBColumnCreateRowId())\n    }\n\n    public convenience init(named name: String) {\n        self.init(named: name, binded: nil)\n    }\n\n    internal convenience init(named name: String, binded tableBinding: UnsafeRawPointer?) {\n        self.init(with: WCDBColumnCreateWithName(name.cString, tableBinding))\n    }\n\n    internal override init(with cppObj: CPPColumn) {\n        super.init(with: cppObj)\n    }\n\n    @discardableResult\n    public func `in`(table: String) -> Column {\n        WCDBColumnInTable(cppObj, table.cString)\n        return self\n    }\n\n    public func `as`(_ alias: String) -> ResultColumn {\n        return ResultColumn(with: WCDBColumnConfigAlias(cppObj, alias.cString))\n    }\n\n    @discardableResult\n    public func of(schema schemaConvertible: SchemaConvertible) -> Column {\n        let schema = schemaConvertible.asSchema()\n        withExtendedLifetime(schema) {\n            WCDBColumnOfSchema(cppObj, schema.cppObj)\n        }\n        return self\n    }\n}\n\nextension Column: ColumnConvertible, ExpressionOperable {\n    public func asColumn() -> Column {\n        return self\n    }\n}\n"
  },
  {
    "path": "src/swift/winq/identifier/ColumnConstraint.swift",
    "content": "//\n// Created by qiuwenchen on 2022/5/29.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport Foundation\n#if SWIFT_PACKAGE\nimport WCDB_Private\n#elseif WCDB_SWIFT_TARGET\nimport WCDBSwift.Private\n#else\nimport WCDB.Private\n#endif\n\npublic final class ColumnConstraint: Identifier<CPPColumnConstraint> {\n\n    public convenience init(named name: String? = nil) {\n        self.init(with: WCDBColumnConstraintCreate(name?.cString))\n    }\n\n    @discardableResult\n    public func primaryKey() -> ColumnConstraint {\n        WCDBColumnConstraintConfigPrimaryKey(cppObj)\n        return self\n    }\n\n    @discardableResult\n    public func order(_ order: Order) -> ColumnConstraint {\n        WCDBColumnConstraintConfigOrder(cppObj, order.cValue)\n        return self\n    }\n\n    @discardableResult\n    public func conflict(action: ConflictAction) -> ColumnConstraint {\n        WCDBColumnConstraintConfigCoflictAction(cppObj, action.cValue)\n        return self\n    }\n\n    @discardableResult\n    public func autoIncrement() -> ColumnConstraint {\n        WCDBColumnConstraintConfigAutoIncrement(cppObj)\n        return self\n    }\n\n    @discardableResult\n    public func notNull() -> ColumnConstraint {\n        WCDBColumnConstraintConfigNotNull(cppObj)\n        return self\n    }\n\n    @discardableResult\n    public func unique() -> ColumnConstraint {\n        WCDBColumnConstraintConfigUnique(cppObj)\n        return self\n    }\n\n    @discardableResult\n    public func check(with expression: Expression) -> ColumnConstraint {\n        withExtendedLifetime(expression) {\n            WCDBColumnConstraintConfigCheck(cppObj, expression.cppObj)\n        }\n        return self\n    }\n\n    @discardableResult\n    public func `default`(with expressionConvertible: ExpressionConvertible) -> ColumnConstraint {\n        let expression = expressionConvertible.asExpression()\n        withExtendedLifetime(expression) {\n            WCDBColumnConstraintConfigDefaultValue(cppObj, expression.cppObj)\n        }\n        return self\n    }\n\n    @discardableResult\n    public func collate(with collation: String) -> ColumnConstraint {\n        WCDBColumnConstraintConfigCollation(cppObj, collation.cString)\n        return self\n    }\n\n    @discardableResult\n    public func foreignKey(with key: ForeignKey) -> ColumnConstraint {\n        withExtendedLifetime(key) {\n            WCDBColumnConstraintConfigForeignKey(cppObj, key.cppObj)\n        }\n        return self\n    }\n\n    @discardableResult\n    public func unIndexed() -> ColumnConstraint {\n        WCDBColumnConstraintConfigUnIndexed(cppObj)\n        return self\n    }\n}\n"
  },
  {
    "path": "src/swift/winq/identifier/ColumnDef.swift",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport Foundation\n#if SWIFT_PACKAGE\nimport WCDB_Private\n#elseif WCDB_SWIFT_TARGET\nimport WCDBSwift.Private\n#else\nimport WCDB.Private\n#endif\n\npublic final class ColumnDef: Identifier<CPPColumnDef> {\n\n    convenience public init(with columnConvertible: ColumnConvertible, and optionalType: ColumnType? = nil) {\n        let column = columnConvertible.asColumn()\n        if let type = optionalType {\n            let cppColumnDef = withExtendedLifetime(column) {\n                WCDBColumnDefCreateWithType(column.cppObj, type.cValue)\n            }\n            self.init(with: cppColumnDef)\n        } else {\n            let cppColumnDef = withExtendedLifetime(column) {\n                WCDBColumnDefCreateWithoutType(column.cppObj)\n            }\n            self.init(with: cppColumnDef)\n        }\n    }\n\n    convenience internal init(named name: String, and optionalType: ColumnType? = nil) {\n        let column = Column(named: name)\n        self.init(with: column, and: optionalType)\n    }\n\n    public func addConstraint(_ constraint: ColumnConstraint) {\n        withExtendedLifetime(constraint) {\n            WCDBColumnDefConfigConstraint(cppObj, constraint.cppObj)\n        }\n    }\n\n    @discardableResult\n    public func makePrimary(orderBy order: Order? = nil,\n                            isAutoIncrement: Bool? = false,\n                            onConflict conflict: ConflictAction? = nil) -> ColumnDef {\n        let constrant = ColumnConstraint()\n        constrant.primaryKey()\n        if let order = order {\n            constrant.order(order)\n        }\n        if isAutoIncrement != nil && isAutoIncrement! {\n            constrant.autoIncrement()\n        }\n        if let conflict = conflict {\n            constrant.conflict(action: conflict)\n        }\n        self.addConstraint(constrant)\n        return self\n    }\n\n    @discardableResult\n    public func makeDefault(to defaultValue: ExpressionConvertible) -> ColumnDef {\n        self.addConstraint(ColumnConstraint().default(with: defaultValue.asExpression()))\n        return self\n    }\n\n    @discardableResult\n    public func makeNotNull() -> ColumnDef {\n        self.addConstraint(ColumnConstraint().notNull())\n        return self\n    }\n\n    @discardableResult\n    public func makeUnique() -> ColumnDef {\n        self.addConstraint(ColumnConstraint().unique())\n        return self\n    }\n\n    @discardableResult\n    public func makeForeignKey(_ foreignKey: ForeignKey) -> ColumnDef {\n        self.addConstraint(ColumnConstraint().foreignKey(with: foreignKey))\n        return self\n    }\n\n    @discardableResult\n    public func makeNotIndexed() -> ColumnDef {\n        self.addConstraint(ColumnConstraint().unIndexed())\n        return self\n    }\n}\n"
  },
  {
    "path": "src/swift/winq/identifier/CommonTableExpression.swift",
    "content": "//\n// Created by qiuwenchen on 2022/5/30.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport Foundation\n#if SWIFT_PACKAGE\nimport WCDB_Private\n#elseif WCDB_SWIFT_TARGET\nimport WCDBSwift.Private\n#else\nimport WCDB.Private\n#endif\n\npublic final class CommonTableExpression: Identifier<CPPCommonTableExpression> {\n\n    public init(_ table: String) {\n        super.init(with: WCDBCommonTableExpressionCreate(table.cString))\n    }\n\n    @discardableResult\n    public func column(_ columnConvertible: ColumnConvertible) -> CommonTableExpression {\n        let column = columnConvertible.asColumn()\n        withExtendedLifetime(column) {\n            WCDBCommonTableExpressionAddColumn(cppObj, column.cppObj)\n        }\n        return self\n    }\n\n    @discardableResult\n    public func `as`(_ select: StatementSelect) -> CommonTableExpression {\n        withExtendedLifetime(select) {\n            WCDBCommonTableExpressionAsSelection(cppObj, select.cppObj)\n        }\n        return self\n    }\n}\n"
  },
  {
    "path": "src/swift/winq/identifier/Expression.swift",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport Foundation\n#if SWIFT_PACKAGE\nimport WCDB_Private\n#elseif WCDB_SWIFT_TARGET\nimport WCDBSwift.Private\n#else\nimport WCDB.Private\n#endif\n\npublic final class Expression: Identifier<CPPExpression> {\n\n    public convenience init(with literalValueConvertible: LiteralValueConvertible) {\n        let literalValue = literalValueConvertible.asLiteralValue()\n        let cppExpression = withExtendedLifetime(literalValue) {\n            WCDBExpressionCreateWithLiteralValue($0.cppObj)\n        }\n        self.init(with: cppExpression)\n    }\n\n    public convenience init(with bindParameter: BindParameter) {\n        let cppExpression = withExtendedLifetime(bindParameter) {\n            WCDBExpressionCreateWithBindParameter($0.cppObj)\n        }\n        self.init(with: cppExpression)\n    }\n\n    public convenience init(with columnConvertible: ColumnConvertible) {\n        let column = columnConvertible.asColumn()\n        let cppExpression = withExtendedLifetime(column) {\n            WCDBExpressionCreateWithColumn($0.cppObj)\n        }\n        self.init(with: cppExpression)\n    }\n\n    public convenience init(with statementSelect: StatementSelect) {\n        let cppExpression = withExtendedLifetime(statementSelect) {\n            WCDBExpressionCreateWithSelection($0.cppObj)\n        }\n        self.init(with: cppExpression)\n    }\n\n    public convenience init(with raiseFunc: RaiseFunction) {\n        let cppExpression = withExtendedLifetime(raiseFunc) {\n            WCDBExpressionCreateWithRaiseFunction($0.cppObj)\n        }\n        self.init(with: cppExpression)\n    }\n\n    public static func function(_ name: String) -> Expression {\n        Expression(with: WCDBExpressionCreateWithFunction(name.cString))\n    }\n\n    @discardableResult\n    public func schema(_ schemaConvertible: SchemaConvertible) -> Expression {\n        let schema = schemaConvertible.asSchema()\n        withExtendedLifetime(schema) {\n            WCDBExpressionSetWithSchema(cppObj, schema.cppObj)\n        }\n        return self\n    }\n\n    @discardableResult\n    public func distinct() -> Expression {\n        WCDBExpressionDistinct(cppObj)\n        return self\n    }\n\n    @discardableResult\n    public func arguments(_ expressionConvertibleList: [ExpressionConvertible]) -> Expression {\n        let expressions = expressionConvertibleList.map { $0.asExpression() }\n        withExtendedLifetime(expressions) {\n            let arguments = $0.map { $0.cppObj }\n            arguments.withUnsafeBufferPointer { cppArgs in\n                WCDBExpressionSetArguments(cppObj, cppArgs.baseAddress, Int32(cppArgs.count))\n            }\n        }\n        return self\n    }\n\n    @discardableResult\n    public func arguments(_ expressionConvertibleList: ExpressionConvertible...) -> Expression {\n        return self.arguments(expressionConvertibleList)\n    }\n\n    @discardableResult\n    public func invoke() -> Expression {\n        WCDBExpressionInvoke(cppObj)\n        return self\n    }\n\n    @discardableResult\n    public func invokeAll() -> Expression {\n        WCDBExpressionInvokeAll(cppObj)\n        return self\n    }\n\n    public static func cast(_ expressionConvertible: ExpressionConvertible) -> Expression {\n        let expression = expressionConvertible.asExpression()\n        let cppExpression = withExtendedLifetime(expression) {\n            WCDBExpressionCast($0.cppObj)\n        }\n        return Expression(with: cppExpression)\n    }\n\n    @discardableResult\n    public func `as`(_ type: ColumnType) -> Expression {\n        WCDBExpressionAs(cppObj, type.cValue)\n        return self\n    }\n\n    public func `as`(_ alias: String) -> ResultColumn {\n        return ResultColumn(with: WCDBExpressionConfigAlias(cppObj, alias.cString))\n    }\n\n    public static func `case`(_ expressionConvertible: ExpressionConvertible? = nil) -> Expression {\n        if let expressionConvertible = expressionConvertible {\n            let expression = expressionConvertible.asExpression()\n            let cppExpression = withExtendedLifetime(expression) {\n                WCDBExpressionCaseWithExp($0.cppObj)\n            }\n            return Expression(with: cppExpression)\n        } else {\n            return Expression(with: WCDBExpressionCase())\n        }\n    }\n\n    @discardableResult\n    public func when(_ expressionConvertible: ExpressionConvertible) -> Expression {\n        let expression = expressionConvertible.asExpression()\n        withExtendedLifetime(expression) {\n            WCDBExpressionSetWithWhenExp(cppObj, $0.cppObj)\n        }\n        return self\n    }\n\n    @discardableResult\n    public func then(_ expressionConvertible: ExpressionConvertible) -> Expression {\n        let expression = expressionConvertible.asExpression()\n        withExtendedLifetime(expression) {\n            WCDBExpressionSetWithThenExp(cppObj, $0.cppObj)\n        }\n        return self\n    }\n\n    @discardableResult\n    public func `else`(_ expressionConvertible: ExpressionConvertible) -> Expression {\n        let expression = expressionConvertible.asExpression()\n        withExtendedLifetime(expression) {\n            WCDBExpressionSetWithElseExp(cppObj, $0.cppObj)\n        }\n        return self\n    }\n\n    @discardableResult\n    public func escape(_ expressionConvertible: ExpressionConvertible) -> Expression {\n        let expression = expressionConvertible.asExpression()\n        withExtendedLifetime(expression) {\n            WCDBExpressionEscapeWith(cppObj, $0.cppObj)\n        }\n        return self\n    }\n\n    public static func windowFunction(_ funcName: String) -> Expression {\n        return Expression(with: WCDBExpressionCreateWithWindowFunction(funcName.cString))\n    }\n\n    @discardableResult\n    public func filter(_ expressionConvertible: ExpressionConvertible) -> Expression {\n        let expression = expressionConvertible.asExpression()\n        withExtendedLifetime(expression) {\n            WCDBExpressionFilter(cppObj, $0.cppObj)\n        }\n        return self\n    }\n\n    @discardableResult\n    public func over(_ window: WindowDef) -> Expression {\n        withExtendedLifetime(window) {\n            WCDBExpressionOverWindowDef(cppObj, $0.cppObj)\n        }\n        return self\n    }\n\n    @discardableResult\n    public func over(_ window: String) -> Expression {\n        WCDBExpressionOverWindow(cppObj, window.cString)\n        return self\n    }\n}\n\nextension Expression: ExpressibleByNilLiteral {\n    public convenience init(nilLiteral value: ()) {\n        self.init(with: LiteralValue(value))\n    }\n}\nextension Expression: ExpressibleByBooleanLiteral {\n    public convenience init(booleanLiteral value: Bool) {\n        self.init(with: LiteralValue(value))\n    }\n}\nextension Expression: ExpressibleByIntegerLiteral {\n    public convenience init(integerLiteral value: Int) {\n        self.init(with: LiteralValue(value))\n    }\n}\nextension Expression: ExpressibleByFloatLiteral {\n    public convenience init(floatLiteral value: Double) {\n        self.init(with: LiteralValue(value))\n    }\n}\nextension Expression: ExpressibleByStringLiteral {\n    public convenience init(stringLiteral value: String) {\n        self.init(with: LiteralValue(value))\n    }\n}\n\nextension Expression: ExpressionOperable {\n\n    public static func exists(_ select: StatementSelect) -> Expression {\n        let cppExpression = withExtendedLifetime(select) {\n            WCDBExpressionCreateWithExistStatement($0.cppObj)\n        }\n        return Expression(with: cppExpression)\n    }\n\n    public static func notExists(_ select: StatementSelect) -> Expression {\n        let cppExpression = withExtendedLifetime(select) {\n            WCDBExpressionCreateWithNotExistStatement($0.cppObj)\n        }\n        return Expression(with: cppExpression)\n    }\n\n    // Function\n    static func function(named name: String,\n                         _ arguments: ExpressionConvertible...,\n                         isDistinct: Bool = false) -> Expression {\n        return function(named: name, arguments, isDistinct: isDistinct)\n    }\n    static func function(named name: String,\n                         _ arguments: [ExpressionConvertible],\n                         isDistinct: Bool = false) -> Expression {\n        let expression = Expression.function(name)\n        expression.invoke()\n        if isDistinct {\n            expression.distinct()\n        }\n        if arguments.count > 0 {\n            expression.arguments(arguments)\n        }\n        return expression\n    }\n\n    public static func `case`(_ expressionConvertible: ExpressionConvertible,\n                              _ flows: (when: ExpressionConvertible, then: ExpressionConvertible)...,\n                              `else`: ExpressionConvertible) -> Expression {\n        return `case`(expressionConvertible, flows, else: `else`)\n    }\n    public static func `case`(_ `case`: ExpressionConvertible,\n                              _ flows: [(when: ExpressionConvertible, then: ExpressionConvertible)],\n                              `else`: ExpressionConvertible) -> Expression {\n        let expression = Expression.case(`case`)\n        for flow in flows {\n            expression.when(flow.when).then(flow.then)\n        }\n        expression.else(`else`)\n        return expression\n    }\n\n    public func asExpression() -> Expression {\n        return self\n    }\n}\n"
  },
  {
    "path": "src/swift/winq/identifier/ForeignKey.swift",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport Foundation\n#if SWIFT_PACKAGE\nimport WCDB_Private\n#elseif WCDB_SWIFT_TARGET\nimport WCDBSwift.Private\n#else\nimport WCDB.Private\n#endif\n\npublic final class ForeignKey: Identifier<CPPForeignKey> {\n\n    public init() {\n        super.init(with: WCDBForeignKeyCreate())\n    }\n\n    @discardableResult\n    public func references(with table: String) -> ForeignKey {\n        WCDBForeignKeyConfigReferencesTable(cppObj, table.cString)\n        return self\n    }\n\n    @discardableResult\n    public func columns(_ columnConvertibleList: [ColumnConvertible]) -> ForeignKey {\n        for columnConvertible in columnConvertibleList {\n            let column = columnConvertible .asColumn()\n            withExtendedLifetime(column) {\n                WCDBForeignKeyAddColumn(cppObj, column.cppObj)\n            }\n        }\n        return self\n    }\n\n    @discardableResult\n    public func columns(_ columnConvertibleList: ColumnConvertible...) -> ForeignKey {\n        return self.columns(columnConvertibleList)\n    }\n\n    public enum Action {\n        case setNull\n        case setDefault\n        case cascade\n        case restrict\n        case noAction\n    }\n\n    @discardableResult\n    public func onDelete(_ action: Action) -> ForeignKey {\n        switch action {\n        case .setNull:\n            WCDBForeignKeyConfigOnDeleteSetNull(cppObj)\n        case .setDefault:\n            WCDBForeignKeyConfigOnDeleteSetDefault(cppObj)\n        case .cascade:\n            WCDBForeignKeyConfigOnDeleteCascade(cppObj)\n        case .restrict:\n            WCDBForeignKeyConfigOnDeleteRestrict(cppObj)\n        case .noAction:\n            WCDBForeignKeyConfigOnDeleteNoAction(cppObj)\n        }\n        return self\n    }\n\n    @discardableResult\n    public func onUpdate(_ action: Action) -> ForeignKey {\n        switch action {\n        case .setNull:\n            WCDBForeignKeyConfigOnUpdateSetNull(cppObj)\n        case .setDefault:\n            WCDBForeignKeyConfigOnUpdateSetDefault(cppObj)\n        case .cascade:\n            WCDBForeignKeyConfigOnUpdateCascade(cppObj)\n        case .restrict:\n            WCDBForeignKeyConfigOnUpdateRestrict(cppObj)\n        case .noAction:\n            WCDBForeignKeyConfigOnUpdateNoAction(cppObj)\n        }\n        return self\n    }\n\n    public enum MatchType {\n        case Simple\n        case Full\n        case Partial\n    }\n\n    @discardableResult\n    public func match(with type: MatchType) -> ForeignKey {\n        switch type {\n        case .Simple:\n            WCDBForeignKeyConfigMatch(cppObj, WCDBSyntaxMatchType_Simple)\n        case .Full:\n            WCDBForeignKeyConfigMatch(cppObj, WCDBSyntaxMatchType_Full)\n        case .Partial:\n            WCDBForeignKeyConfigMatch(cppObj, WCDBSyntaxMatchType_Partial)\n        }\n        return self\n    }\n\n    public enum Deferrable {\n        case deferred\n        case immediate\n    }\n\n    @discardableResult\n    public func deferrable(_ deferrable: Deferrable? = nil) -> ForeignKey {\n        if let deferrable = deferrable {\n            switch deferrable {\n            case .deferred:\n                WCDBForeignKeyConfigDeferrableInitiallyDeferred(cppObj)\n            case .immediate:\n                WCDBForeignKeyConfigDeferrableInitiallyImmediate(cppObj)\n            }\n        } else {\n            WCDBForeignKeyConfigDeferrable(cppObj)\n        }\n        return self\n    }\n\n    @discardableResult\n    public func notDeferrable(_ deferrable: Deferrable? = nil) -> ForeignKey {\n        if let deferrable = deferrable {\n            switch deferrable {\n            case .deferred:\n                WCDBForeignKeyConfigNotDeferrableInitiallyDeferred(cppObj)\n            case .immediate:\n                WCDBForeignKeyConfigNotDeferrableInitiallyImmediate(cppObj)\n            }\n        } else {\n            WCDBForeignKeyConfigNotDeferrable(cppObj)\n        }\n        return self\n    }\n}\n"
  },
  {
    "path": "src/swift/winq/identifier/FrameSpec.swift",
    "content": "//\n// Created by qiuwenchen on 2022/6/9.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport Foundation\n#if SWIFT_PACKAGE\nimport WCDB_Private\n#elseif WCDB_SWIFT_TARGET\nimport WCDBSwift.Private\n#else\nimport WCDB.Private\n#endif\n\npublic final class FrameSpec: Identifier<CPPFrameSpec> {\n\n    public init() {\n        super.init(with: WCDBFrameSpecCreate())\n    }\n\n    @discardableResult\n    public func range() -> FrameSpec {\n        WCDBFrameSpecConfigRange(cppObj)\n        return self\n    }\n\n    @discardableResult\n    public func rows() -> FrameSpec {\n        WCDBFrameSpecConfigRows(cppObj)\n        return self\n    }\n\n    @discardableResult\n    public func unboundedPreceding() -> FrameSpec {\n        WCDBFrameSpecConfigUnboundedPreceding(cppObj)\n        return self\n    }\n\n    @discardableResult\n    public func preceding(_ expressionConverable: ExpressionConvertible) -> FrameSpec {\n        let expression = expressionConverable.asExpression()\n        withExtendedLifetime(expression) {\n            WCDBFrameSpecConfigPreceding(cppObj, $0.cppObj)\n        }\n        return self\n    }\n\n    @discardableResult\n    public func currentRow() -> FrameSpec {\n        WCDBFrameSpecConfigCurrentRow(cppObj)\n        return self\n    }\n\n    @discardableResult\n    public func betweenUnboundedPreceding() -> FrameSpec {\n        WCDBFrameSpecConfigBetweenUnboundedPreceding(cppObj)\n        return self\n    }\n\n    @discardableResult\n    public func betweenPreceding(_ expressionConverable: ExpressionConvertible) -> FrameSpec {\n        let expression = expressionConverable.asExpression()\n        withExtendedLifetime(expression) {\n            WCDBFrameSpecConfigBetweenPreceding(cppObj, $0.cppObj)\n        }\n        return self\n    }\n\n    @discardableResult\n    public func betweenCurrentRow() -> FrameSpec {\n        WCDBFrameSpecConfigBetweenCurrentRow(cppObj)\n        return self\n    }\n\n    @discardableResult\n    public func betweenFollowing(_ expressionConverable: ExpressionConvertible) -> FrameSpec {\n        let expression = expressionConverable.asExpression()\n        withExtendedLifetime(expression) {\n            WCDBFrameSpecConfigBetweenFollowing(cppObj, $0.cppObj)\n        }\n        return self\n    }\n\n    @discardableResult\n    public func andCurrentRow() -> FrameSpec {\n        WCDBFrameSpecConfigAndCurrentRow(cppObj)\n        return self\n    }\n\n    @discardableResult\n    public func andPreceding(_ expressionConverable: ExpressionConvertible) -> FrameSpec {\n        let expression = expressionConverable.asExpression()\n        withExtendedLifetime(expression) {\n            WCDBFrameSpecConfigAndPreceding(cppObj, $0.cppObj)\n        }\n        return self\n    }\n\n    @discardableResult\n    public func andUnboundedFollowing() -> FrameSpec {\n        WCDBFrameSpecConfigAndUnboundedFollowing(cppObj)\n        return self\n    }\n\n    @discardableResult\n    public func andFollowing(_ expressionConverable: ExpressionConvertible) -> FrameSpec {\n        let expression = expressionConverable.asExpression()\n        withExtendedLifetime(expression) {\n            WCDBFrameSpecConfigAndFollowing(cppObj, $0.cppObj)\n        }\n        return self\n    }\n}\n"
  },
  {
    "path": "src/swift/winq/identifier/IndexedColumn.swift",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport Foundation\n#if SWIFT_PACKAGE\nimport WCDB_Private\n#elseif WCDB_SWIFT_TARGET\nimport WCDBSwift.Private\n#else\nimport WCDB.Private\n#endif\n\npublic final class IndexedColumn: Identifier<CPPIndexedColumn> {\n\n    public init(with columnConvertible: ColumnConvertible) {\n        let column = columnConvertible.asColumn()\n        let cppIndexedColumn = withExtendedLifetime(column) {\n            WCDBIndexedColumnCreateWithColumn($0.cppObj)\n        }\n        super.init(with: cppIndexedColumn)\n    }\n\n    public init(with expressionConvertible: ExpressionConvertible) {\n        let expression = expressionConvertible.asExpression()\n        let cppIndexedColumn = withExtendedLifetime(expression) {\n            WCDBIndexedColumnCreateWithExpression($0.cppObj)\n        }\n        super.init(with: cppIndexedColumn)\n    }\n\n    @discardableResult\n    public func order(_ order: Order) -> IndexedColumn {\n        WCDBIndexedColumnConfigOrder(cppObj, order.cValue)\n        return self\n    }\n\n    @discardableResult\n    public func collate(_ collation: String) -> IndexedColumn {\n        WCDBIndexedColumnConfigCollation(cppObj, collation.cString)\n        return self\n    }\n}\n\nextension IndexedColumn: IndexedColumnConvertible {\n    public func asIndex() -> IndexedColumn {\n        return self\n    }\n}\n"
  },
  {
    "path": "src/swift/winq/identifier/Join.swift",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport Foundation\n#if SWIFT_PACKAGE\nimport WCDB_Private\n#elseif WCDB_SWIFT_TARGET\nimport WCDBSwift.Private\n#else\nimport WCDB.Private\n#endif\npublic final class Join: Identifier<CPPJoin> {\n\n    public init(with subqueryConvertible: TableOrSubqueryConvertible) {\n        let subquery = subqueryConvertible.asTableOrSubquery()\n        let cppJoin = withExtendedLifetime(subquery) {\n            WCDBJoinCreateWithTableOrSubquery($0.cppObj)\n        }\n        super.init(with: cppJoin)\n    }\n\n    @discardableResult\n    public func join(_ subqueryConvertible: TableOrSubqueryConvertible) -> Join {\n        let subquery = subqueryConvertible.asTableOrSubquery()\n        withExtendedLifetime(subquery) {\n            WCDBJoinWithJoin(cppObj, $0.cppObj)\n        }\n        return self\n    }\n\n    @discardableResult\n    public func with(_ subqueryConvertible: TableOrSubqueryConvertible) -> Join {\n        let subquery = subqueryConvertible.asTableOrSubquery()\n        withExtendedLifetime(subquery) {\n            WCDBJoinWith(cppObj, $0.cppObj)\n        }\n        return self\n    }\n\n    @discardableResult\n    public func leftOuterJoin(_ subqueryConvertible: TableOrSubqueryConvertible) -> Join {\n        let subquery = subqueryConvertible.asTableOrSubquery()\n        withExtendedLifetime(subquery) {\n            WCDBJoinWithLeftOuterJoin(cppObj, $0.cppObj)\n        }\n        return self\n    }\n\n    @discardableResult\n    public func leftJoin(_ subqueryConvertible: TableOrSubqueryConvertible) -> Join {\n        let subquery = subqueryConvertible.asTableOrSubquery()\n        withExtendedLifetime(subquery) {\n            WCDBJoinWithLeftJoin(cppObj, $0.cppObj)\n        }\n        return self\n    }\n\n    @discardableResult\n    public func innerJoin(_ subqueryConvertible: TableOrSubqueryConvertible) -> Join {\n        let subquery = subqueryConvertible.asTableOrSubquery()\n        withExtendedLifetime(subquery) {\n            WCDBJoinWithInnerJoin(cppObj, $0.cppObj)\n        }\n        return self\n    }\n\n    @discardableResult\n    public func crossJoin(_ subqueryConvertible: TableOrSubqueryConvertible) -> Join {\n        let subquery = subqueryConvertible.asTableOrSubquery()\n        withExtendedLifetime(subquery) {\n            WCDBJoinWithCrossJoin(cppObj, $0.cppObj)\n        }\n        return self\n    }\n\n    @discardableResult\n    public func naturalJoin(_ subqueryConvertible: TableOrSubqueryConvertible) -> Join {\n        let subquery = subqueryConvertible.asTableOrSubquery()\n        withExtendedLifetime(subquery) {\n            WCDBJoinWithNaturalJoin(cppObj, $0.cppObj)\n        }\n        return self\n    }\n\n    @discardableResult\n    public func naturalLeftOuterJoin(_ subqueryConvertible: TableOrSubqueryConvertible) -> Join {\n        let subquery = subqueryConvertible.asTableOrSubquery()\n        withExtendedLifetime(subquery) {\n            WCDBJoinWithNaturalLeftOuterJoin(cppObj, $0.cppObj)\n        }\n        return self\n    }\n\n    @discardableResult\n    public func naturalLeftJoin(_ subqueryConvertible: TableOrSubqueryConvertible) -> Join {\n        let subquery = subqueryConvertible.asTableOrSubquery()\n        withExtendedLifetime(subquery) {\n            WCDBJoinWithNaturalLeftJoin(cppObj, $0.cppObj)\n        }\n        return self\n    }\n\n    @discardableResult\n    public func naturalInnerJoin(_ subqueryConvertible: TableOrSubqueryConvertible) -> Join {\n        let subquery = subqueryConvertible.asTableOrSubquery()\n        withExtendedLifetime(subquery) {\n            WCDBJoinWithNaturalInnerJoin(cppObj, $0.cppObj)\n        }\n        return self\n    }\n\n    @discardableResult\n    public func naturalCrossJoin(_ subqueryConvertible: TableOrSubqueryConvertible) -> Join {\n        let subquery = subqueryConvertible.asTableOrSubquery()\n        withExtendedLifetime(subquery) {\n            WCDBJoinWithNaturalCrossJoin(cppObj, $0.cppObj)\n        }\n        return self\n    }\n\n    @discardableResult\n    public func on(_ expressionConvertible: ExpressionConvertible) -> Join {\n        let expression = expressionConvertible.asExpression()\n        withExtendedLifetime(expression) {\n            WCDBJoinConfigOn(cppObj, $0.cppObj)\n        }\n        return self\n    }\n\n    @discardableResult\n    public func using(_ columnConvertibleList: ColumnConvertible...) -> Join {\n        return using(columnConvertibleList)\n    }\n\n    @discardableResult\n    public func using(_ columnConvertibleList: [ColumnConvertible]) -> Join {\n        let columns = columnConvertibleList.map { $0.asColumn() }\n        withExtendedLifetime(columns) {\n            let cppColumns = $0.map { $0.cppObj }\n            cppColumns.withUnsafeBufferPointer {\n                WCDBJoinConfigUsingColumn(cppObj, $0.baseAddress, Int32($0.count))\n            }\n        }\n        return self\n    }\n}\n\nextension Join: TableOrSubqueryConvertible {\n    public func asTableOrSubquery() -> TableOrSubquery {\n        return TableOrSubquery(with: self)\n    }\n}\n"
  },
  {
    "path": "src/swift/winq/identifier/LiteralValue.swift",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport Foundation\n#if SWIFT_PACKAGE\nimport WCDB_Private\n#elseif WCDB_SWIFT_TARGET\nimport WCDBSwift.Private\n#else\nimport WCDB.Private\n#endif\n\npublic final class LiteralValue: Identifier<CPPLiteralValue> {\n\n    public convenience init(_ value: Int32) {\n        self.init(with: WCDBLiteralValueCreateWithInt64(Int64(value)))\n    }\n\n    public convenience init(_ value: Int64) {\n        self.init(with: WCDBLiteralValueCreateWithInt64(value))\n    }\n\n    public convenience init(_ value: Bool) {\n        self.init(with: WCDBLiteralValueCreateWithBool(value))\n    }\n\n    public convenience init(_ value: Double) {\n        self.init(with: WCDBLiteralValueCreateWithDouble(value))\n    }\n\n    public convenience init(_ value: String) {\n        self.init(with: WCDBLiteralValueCreateWithString(value.cString))\n    }\n\n    public convenience init(_ value: Data) {\n        let string = String(data: value, encoding: .utf8) ?? \"\"\n        self.init(with: WCDBLiteralValueCreateWithString(string.cString))\n    }\n\n    public convenience init(_ value: Void?) {\n        self.init(with: WCDBLiteralValueCreateWithNull())\n    }\n\n    public convenience init(_ value: Value) {\n        switch value.type {\n        case .integer32:\n            self.init(value.int32Value)\n        case .integer64:\n            self.init(value.int64Value)\n        case .float:\n            self.init(value.doubleValue)\n        case .text:\n            self.init(value.stringValue)\n        case .BLOB:\n            self.init(value.dataValue)\n        case .null:\n            self.init(nil)\n        }\n    }\n\n    public convenience init<T: ColumnEncodable>(_ encodedValue: T) {\n        self.init(encodedValue.archivedValue())\n    }\n\n    public static func currentTime() -> LiteralValue {\n        LiteralValue(with: WCDBLiteralValueCreateWithCurrentTime())\n    }\n\n    public static func currentDate() -> LiteralValue {\n        LiteralValue(with: WCDBLiteralValueCreateWithCurrentDate())\n    }\n\n    public static func currentTimestamp() -> LiteralValue {\n        LiteralValue(with: WCDBLiteralValueCreateWithCurrentTimestamp())\n    }\n}\n\nextension LiteralValue: ExpressibleByNilLiteral {\n    public convenience init(nilLiteral: ()) {\n        self.init(nilLiteral)\n    }\n}\n\nextension LiteralValue: ExpressibleByIntegerLiteral {\n    public convenience init(integerLiteral value: Int) {\n        self.init(value)\n    }\n}\n\nextension LiteralValue: ExpressibleByBooleanLiteral {\n    public convenience init(booleanLiteral value: Bool) {\n        self.init(value)\n    }\n}\n\nextension LiteralValue: ExpressibleByFloatLiteral {\n    public convenience init(floatLiteral value: Double) {\n        self.init(value)\n    }\n}\n\nextension LiteralValue: ExpressibleByStringLiteral {\n    public convenience init(stringLiteral value: String) {\n        self.init(value)\n    }\n}\n\nextension LiteralValue: LiteralValueConvertible {\n    public func asLiteralValue() -> LiteralValue {\n        return self\n    }\n}\n"
  },
  {
    "path": "src/swift/winq/identifier/Operable.swift",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport Foundation\n#if SWIFT_PACKAGE\nimport WCDB_Private\n#elseif WCDB_SWIFT_TARGET\nimport WCDBSwift.Private\n#else\nimport WCDB.Private\n#endif\n\ninternal enum UnaryOperateType {\n    case negative\n    case positive\n    case tilde\n    case not\n\n    var cValue: WCDBExpressionUnaryOperateType {\n        switch self {\n        case .negative:\n            return WCDBExpressionUnaryOperateType_Negative\n        case .positive:\n            return WCDBExpressionUnaryOperateType_Positive\n        case .tilde:\n            return WCDBExpressionUnaryOperateType_Tilde\n        case .not:\n            return WCDBExpressionUnaryOperateType_Not\n        }\n    }\n}\n\npublic protocol ExpressionUnaryOperable: ExpressionConvertible {\n    prefix static func ! (operand: Self) -> Expression\n    prefix static func + (operand: Self) -> Expression\n    prefix static func - (operand: Self) -> Expression\n    prefix static func ~ (operand: Self) -> Expression\n    func isNull() -> Expression\n    func isNotNull() -> Expression\n}\n\nextension ExpressionUnaryOperable {\n    public prefix static func ! (operand: Self) -> Expression {\n        return operate(.not, operand: operand)\n    }\n    public prefix static func + (operand: Self) -> Expression {\n        return operate(.positive, operand: operand)\n    }\n    public prefix static func - (operand: Self) -> Expression {\n        return operate(.negative, operand: operand)\n    }\n    public prefix static func ~ (operand: Self) -> Expression {\n        return operate(.tilde, operand: operand)\n    }\n    public func isNull() -> Expression {\n        self.isNull(isNot: false)\n    }\n    public func isNotNull() -> Expression {\n        self.isNull(isNot: true)\n    }\n    internal func isNull(isNot: Bool) -> Expression {\n        let expression = asExpression()\n        let cppExpression = withExtendedLifetime(expression) {\n            WCDBExpressionNullOperate($0.cppObj, isNot)\n        }\n        return Expression(with: cppExpression)\n    }\n}\n\ninternal enum BinaryOperateType {\n    case Concatenate\n    case Multiply\n    case Divide\n    case Modulo\n    case Plus\n    case Minus\n    case LeftShift\n    case RightShift\n    case BitwiseAnd\n    case BitwiseOr\n    case Less\n    case LessOrEqual\n    case Greater\n    case GreaterOrEqual\n    case Equal\n    case NotEqual\n    case Is\n    case And\n    case Or\n    case Like\n    case GLOB\n    case RegExp\n    case Match\n\n    var cValue: WCDBExpressionBinaryOperatorType {\n        switch self {\n        case .Concatenate:\n            return WCDBExpressionBinaryOperatorType_Concatenate\n        case .Multiply:\n            return WCDBExpressionBinaryOperatorType_Multiply\n        case .Divide:\n            return WCDBExpressionBinaryOperatorType_Divide\n        case .Modulo:\n            return WCDBExpressionBinaryOperatorType_Modulo\n        case .Plus:\n            return WCDBExpressionBinaryOperatorType_Plus\n        case .Minus:\n            return WCDBExpressionBinaryOperatorType_Minus\n        case .LeftShift:\n            return WCDBExpressionBinaryOperatorType_LeftShift\n        case .RightShift:\n            return WCDBExpressionBinaryOperatorType_RightShift\n        case .BitwiseAnd:\n            return WCDBExpressionBinaryOperatorType_BitwiseAnd\n        case .BitwiseOr:\n            return WCDBExpressionBinaryOperatorType_BitwiseOr\n        case .Less:\n            return WCDBExpressionBinaryOperatorType_Less\n        case .LessOrEqual:\n            return WCDBExpressionBinaryOperatorType_LessOrEqual\n        case .Greater:\n            return WCDBExpressionBinaryOperatorType_Greater\n        case .GreaterOrEqual:\n            return WCDBExpressionBinaryOperatorType_GreaterOrEqual\n        case .Equal:\n            return WCDBExpressionBinaryOperatorType_Equal\n        case .NotEqual:\n            return WCDBExpressionBinaryOperatorType_NotEqual\n        case .Is:\n            return WCDBExpressionBinaryOperatorType_Is\n        case .And:\n            return WCDBExpressionBinaryOperatorType_And\n        case .Or:\n            return WCDBExpressionBinaryOperatorType_Or\n        case .Like:\n            return WCDBExpressionBinaryOperatorType_Like\n        case .GLOB:\n            return WCDBExpressionBinaryOperatorType_GLOB\n        case .RegExp:\n            return WCDBExpressionBinaryOperatorType_RegExp\n        case .Match:\n            return WCDBExpressionBinaryOperatorType_Match\n        }\n    }\n}\n\npublic protocol ExpressionBinaryOperable: ExpressionConvertible {\n    static func || <ExpressionConvertibleType: ExpressionConvertible>(\n        left: Self,\n        right: ExpressionConvertibleType) -> Expression\n\n    static func && <ExpressionConvertibleType: ExpressionConvertible>(\n        left: Self, right: ExpressionConvertibleType) -> Expression\n\n    static func * <ExpressionConvertibleType: ExpressionConvertible>\n        (left: Self, right: ExpressionConvertibleType) -> Expression\n\n    static func / <ExpressionConvertibleType: ExpressionConvertible>(\n        left: Self, right: ExpressionConvertibleType) -> Expression\n\n    static func % <ExpressionConvertibleType: ExpressionConvertible>(\n        left: Self, right: ExpressionConvertibleType) -> Expression\n\n    static func + <ExpressionConvertibleType: ExpressionConvertible>(\n        left: Self, right: ExpressionConvertibleType) -> Expression\n\n    static func - <ExpressionConvertibleType: ExpressionConvertible>(\n        left: Self, right: ExpressionConvertibleType) -> Expression\n\n    static func << <ExpressionConvertibleType: ExpressionConvertible>(\n        left: Self, right: ExpressionConvertibleType) -> Expression\n\n    static func >> <ExpressionConvertibleType: ExpressionConvertible>(\n        left: Self, right: ExpressionConvertibleType) -> Expression\n\n    static func & <ExpressionConvertibleType: ExpressionConvertible>(\n        left: Self, right: ExpressionConvertibleType) -> Expression\n\n    static func | <ExpressionConvertibleType: ExpressionConvertible>(\n        left: Self, right: ExpressionConvertibleType) -> Expression\n\n    static func < <ExpressionConvertibleType: ExpressionConvertible>(\n        left: Self, right: ExpressionConvertibleType) -> Expression\n\n    static func <= <ExpressionConvertibleType: ExpressionConvertible>(\n        left: Self, right: ExpressionConvertibleType) -> Expression\n\n    static func > <ExpressionConvertibleType: ExpressionConvertible>(\n        left: Self, right: ExpressionConvertibleType) -> Expression\n\n    static func >= <ExpressionConvertibleType: ExpressionConvertible>(\n        left: Self, right: ExpressionConvertibleType) -> Expression\n\n    static func == <ExpressionConvertibleType: ExpressionConvertible>(\n        left: Self, right: ExpressionConvertibleType) -> Expression\n\n    static func != <ExpressionConvertibleType: ExpressionConvertible>(\n        left: Self, right: ExpressionConvertibleType) -> Expression\n\n    func concat(_ operand: ExpressionConvertible) -> Expression\n}\n\nextension ExpressionBinaryOperable {\n    public static func || <ExpressionConvertibleType: ExpressionConvertible>(\n        left: Self, right: ExpressionConvertibleType) -> Expression {\n            return operate(left: left, operator: .Or, right: right)\n    }\n\n    public static func && <ExpressionConvertibleType: ExpressionConvertible>(\n        left: Self, right: ExpressionConvertibleType) -> Expression {\n            return operate(left: left, operator: .And, right: right)\n    }\n\n    public static func * <ExpressionConvertibleType: ExpressionConvertible>(\n        left: Self, right: ExpressionConvertibleType) -> Expression {\n            return operate(left: left, operator: .Multiply, right: right)\n    }\n\n    public static func / <ExpressionConvertibleType: ExpressionConvertible>(\n        left: Self, right: ExpressionConvertibleType) -> Expression {\n            return operate(left: left, operator: .Divide, right: right)\n    }\n\n    public static func % <ExpressionConvertibleType: ExpressionConvertible>(\n        left: Self, right: ExpressionConvertibleType) -> Expression {\n            return operate(left: left, operator: .Modulo, right: right)\n    }\n\n    public static func + <ExpressionConvertibleType: ExpressionConvertible>(\n        left: Self, right: ExpressionConvertibleType) -> Expression {\n            return operate(left: left, operator: .Plus, right: right)\n    }\n\n    public static func - <ExpressionConvertibleType: ExpressionConvertible>(\n        left: Self, right: ExpressionConvertibleType) -> Expression {\n            return operate(left: left, operator: .Minus, right: right)\n    }\n\n    public static func << <ExpressionConvertibleType: ExpressionConvertible>(\n        left: Self, right: ExpressionConvertibleType) -> Expression {\n            return operate(left: left, operator: .LeftShift, right: right)\n    }\n\n    public static func >> <ExpressionConvertibleType: ExpressionConvertible>(\n        left: Self, right: ExpressionConvertibleType) -> Expression {\n            return operate(left: left, operator: .RightShift, right: right)\n    }\n\n    public static func & <ExpressionConvertibleType: ExpressionConvertible>(\n        left: Self, right: ExpressionConvertibleType) -> Expression {\n            return operate(left: left, operator: .BitwiseAnd, right: right)\n    }\n\n    public static func | <ExpressionConvertibleType: ExpressionConvertible>(\n        left: Self, right: ExpressionConvertibleType) -> Expression {\n            return operate(left: left, operator: .BitwiseOr, right: right)\n    }\n\n    public static func < <ExpressionConvertibleType: ExpressionConvertible>(\n        left: Self, right: ExpressionConvertibleType) -> Expression {\n            return operate(left: left, operator: .Less, right: right)\n    }\n\n    public static func <= <ExpressionConvertibleType: ExpressionConvertible>(\n        left: Self, right: ExpressionConvertibleType) -> Expression {\n            return operate(left: left, operator: .LessOrEqual, right: right)\n    }\n\n    public static func > <ExpressionConvertibleType: ExpressionConvertible>(\n        left: Self, right: ExpressionConvertibleType) -> Expression {\n            return operate(left: left, operator: .Greater, right: right)\n    }\n\n    public static func >= <ExpressionConvertibleType: ExpressionConvertible>(\n        left: Self, right: ExpressionConvertibleType) -> Expression {\n            return operate(left: left, operator: .GreaterOrEqual, right: right)\n    }\n\n    public static func == <ExpressionConvertibleType: ExpressionConvertible>(\n        left: Self, right: ExpressionConvertibleType) -> Expression {\n            return operate(left: left, operator: .Equal, right: right)\n    }\n\n    public static func != <ExpressionConvertibleType: ExpressionConvertible>(\n        left: Self, right: ExpressionConvertibleType) -> Expression {\n            return operate(left: left, operator: .NotEqual, right: right)\n    }\n\n    public func concat(_ operand: ExpressionConvertible) -> Expression {\n        return Self.operate(left: self, operator: .Concatenate, right: operand)\n    }\n}\n\npublic protocol ExpressionBetweenOperable: ExpressionConvertible {\n    func between(_ begin: ExpressionConvertible, _ end: ExpressionConvertible) -> Expression\n    func notBetween(_ begin: ExpressionConvertible, _ end: ExpressionConvertible) -> Expression\n}\n\nextension ExpressionBetweenOperable {\n    public func between(_ begin: ExpressionConvertible, _ end: ExpressionConvertible) -> Expression {\n        self.between(begin, end, isNot: false)\n\n    }\n    public func notBetween(_ begin: ExpressionConvertible, _ end: ExpressionConvertible) -> Expression {\n        self.between(begin, end, isNot: true)\n    }\n\n    public func between(_ begin: ExpressionConvertible, _ end: ExpressionConvertible, isNot: Bool) -> Expression {\n        let selfExp = self.asExpression()\n        let beginExp = begin.asExpression()\n        let endExp = end.asExpression()\n        let cppExpression = ObjectBridge.extendLifetime(selfExp, beginExp, endExp) {\n            WCDBExpressionBetweenOperate(selfExp.cppObj,\n                                         beginExp.asExpression().cppObj,\n                                         endExp.asExpression().cppObj,\n                                         isNot)\n        }\n        return Expression(with: cppExpression)\n\n    }\n}\n\npublic protocol ExpressionInOperable: ExpressionConvertible {\n    func `in`(function: String) -> Expression\n    func notIn(function: String) -> Expression\n\n    func inTable(_ name: String) -> Expression\n    func notInTable(_ name: String) -> Expression\n\n    func `in`(_ statementSelect: StatementSelect) -> Expression\n    func notIn(_ statementSelect: StatementSelect) -> Expression\n\n    func `in`(_ expressionConvertibleList: ExpressionConvertible...) -> Expression\n    func notIn(_ expressionConvertibleList: ExpressionConvertible...) -> Expression\n\n    func `in`(_ expressionConvertibleList: [ExpressionConvertible]) -> Expression\n    func notIn(_ expressionConvertibleList: [ExpressionConvertible]) -> Expression\n}\n\nextension ExpressionInOperable {\n    public func `in`(function: String) -> Expression {\n        self.in(function: function, isNot: false)\n    }\n    public func notIn(function: String) -> Expression {\n        self.in(function: function, isNot: true)\n    }\n    internal func `in`(function: String, isNot: Bool) -> Expression {\n        let expression = asExpression()\n        let cppExpression = withExtendedLifetime(expression) {\n            WCDBExpressionInFunctionOperate(expression.cppObj, function.cString, isNot)\n        }\n        return Expression(with: cppExpression)\n    }\n\n    public func inTable(_ name: String) -> Expression {\n        self.inTable(name, isNot: false)\n    }\n    public func notInTable(_ name: String) -> Expression {\n        self.inTable(name, isNot: true)\n    }\n    internal func inTable(_ name: String, isNot: Bool) -> Expression {\n        let expression = asExpression()\n        let cppExpression = withExtendedLifetime(expression) {\n            WCDBExpressionInTableOperate(expression.cppObj, name.cString, isNot)\n        }\n        return Expression(with: cppExpression)\n    }\n\n    public func `in`(_ statementSelect: StatementSelect) -> Expression {\n        self.in(statementSelect, isNot: false)\n    }\n    public func notIn(_ statementSelect: StatementSelect) -> Expression {\n        self.in(statementSelect, isNot: true)\n    }\n    internal func `in`(_ statementSelect: StatementSelect, isNot: Bool) -> Expression {\n        let expression = asExpression()\n        let cppExpression = ObjectBridge.extendLifetime(statementSelect, expression) {\n            WCDBExpressionInSelectionOperate(expression.cppObj, statementSelect.cppObj, isNot)\n        }\n        return Expression(with: cppExpression)\n    }\n\n    public func `in`(_ expressionConvertibleList: ExpressionConvertible...) -> Expression {\n        return self.`in`(expressionConvertibleList)\n    }\n    public func notIn(_ expressionConvertibleList: ExpressionConvertible...) -> Expression {\n        return self.notIn(expressionConvertibleList)\n    }\n    public func `in`(_ expressionConvertibleList: [ExpressionConvertible]) -> Expression {\n        self.in(expressionConvertibleList, isNot: false)\n    }\n    public func notIn(_ expressionConvertibleList: [ExpressionConvertible]) -> Expression {\n        self.in(expressionConvertibleList, isNot: true)\n    }\n    internal func `in`(_ expressionConvertibleList: [ExpressionConvertible], isNot: Bool) -> Expression {\n        let expressions = expressionConvertibleList.map { $0.asExpression() }\n        let selfExp = asExpression()\n        let cppExpression = ObjectBridge.extendLifetime(selfExp, expressions) { () -> CPPExpression in\n            let cppExpressions = expressions.map { $0.cppObj }\n            return cppExpressions.withUnsafeBufferPointer { cppExps in\n                return WCDBExpressionInExpressionOperate(selfExp.cppObj, cppExps.baseAddress, Int32(cppExps.count), isNot)\n            }\n        }\n        return Expression(with: cppExpression)\n    }\n}\n\npublic protocol ExpressionCollateOperable: ExpressionConvertible {\n    func collate(_ collation: String) -> Expression\n}\n\nextension ExpressionCollateOperable {\n    public func collate(_ collation: String) -> Expression {\n        let expression = asExpression()\n        let cppExpression = withExtendedLifetime(expression) {\n            WCDBExpressionCollateOperate(expression.cppObj, collation.cString)\n        }\n        return Expression(with: cppExpression)\n    }\n}\n\npublic protocol ExpressionFunctionOperable: ExpressionConvertible {\n    func substr(start: ExpressionConvertible, length: ExpressionConvertible) -> Expression\n\n    func like(_ operand: ExpressionConvertible) -> Expression\n    func glob(_ operand: ExpressionConvertible) -> Expression\n    func match(_ operand: ExpressionConvertible) -> Expression\n    func regexp(_ operand: ExpressionConvertible) -> Expression\n\n    func notLike(_ operand: ExpressionConvertible) -> Expression\n    func notGlob(_ operand: ExpressionConvertible) -> Expression\n    func notMatch(_ operand: ExpressionConvertible) -> Expression\n    func notRegexp(_ operand: ExpressionConvertible) -> Expression\n\n    func `is`(_ operand: ExpressionConvertible) -> Expression\n    func isNot(_ operand: ExpressionConvertible) -> Expression\n\n    func collate(_ collation: String) -> Expression\n\n    // aggregate functions\n    func avg(isDistinct: Bool) -> Expression\n    func count(isDistinct: Bool) -> Expression\n    func groupConcat(isDistinct: Bool) -> Expression\n    func groupConcat(isDistinct: Bool, separateBy seperator: String) -> Expression\n    func max(isDistinct: Bool) -> Expression\n    func min(isDistinct: Bool) -> Expression\n    func sum(isDistinct: Bool) -> Expression\n    func total(isDistinct: Bool) -> Expression\n\n    // core functions\n    func abs() -> Expression\n    func hex() -> Expression\n    func length() -> Expression\n    func lower() -> Expression\n    func upper() -> Expression\n    func round() -> Expression\n\n    // FTS3/4\n    func matchinfo() -> Expression\n    func offsets() -> Expression\n    func snippet() -> Expression\n    // FTS5\n    func bm25() -> Expression\n    func highlight() -> Expression\n    func substringMatchInfo() -> Expression\n}\n\nextension ExpressionFunctionOperable {\n    public func substr(start: ExpressionConvertible, length: ExpressionConvertible) -> Expression {\n        return Expression.function(named: \"SUBSTR\", asExpression(), start, length)\n    }\n\n    public func like(_ operand: ExpressionConvertible) -> Expression {\n        return Self.operate(left: self, operator: .Like, right: operand, isNot: false)\n    }\n    public func glob(_ operand: ExpressionConvertible) -> Expression {\n        return Self.operate(left: self, operator: .GLOB, right: operand, isNot: false)\n    }\n    public func match(_ operand: ExpressionConvertible) -> Expression {\n        return Self.operate(left: self, operator: .Match, right: operand, isNot: false)\n    }\n    public func regexp(_ operand: ExpressionConvertible) -> Expression {\n        return Self.operate(left: self, operator: .RegExp, right: operand, isNot: false)\n    }\n    public func notLike(_ operand: ExpressionConvertible) -> Expression {\n        return Self.operate(left: self, operator: .Like, right: operand, isNot: true)\n    }\n    public func notGlob(_ operand: ExpressionConvertible) -> Expression {\n        return Self.operate(left: self, operator: .GLOB, right: operand, isNot: true)\n    }\n    public func notMatch(_ operand: ExpressionConvertible) -> Expression {\n        return Self.operate(left: self, operator: .Match, right: operand, isNot: true)\n    }\n    public func notRegexp(_ operand: ExpressionConvertible) -> Expression {\n        return Self.operate(left: self, operator: .RegExp, right: operand, isNot: true)\n    }\n\n    public func `is`(_ operand: ExpressionConvertible) -> Expression {\n        return Self.operate(left: self, operator: .Is, right: operand, isNot: false)\n    }\n    public func isNot(_ operand: ExpressionConvertible) -> Expression {\n        return Self.operate(left: self, operator: .Is, right: operand, isNot: true)\n    }\n\n    // aggregate functions\n    public func avg(isDistinct: Bool = false) -> Expression {\n        return Expression.function(named: \"AVG\", self, isDistinct: isDistinct)\n    }\n    public func count(isDistinct: Bool = false) -> Expression {\n        return Expression.function(named: \"COUNT\", self, isDistinct: isDistinct)\n    }\n    public func groupConcat(isDistinct: Bool = false) -> Expression {\n        return Expression.function(named: \"GROUP_CONCAT\", self, isDistinct: isDistinct)\n    }\n    public func groupConcat(isDistinct: Bool = false, separateBy seperator: String) -> Expression {\n        return Expression.function(named: \"GROUP_CONCAT\", self, seperator, isDistinct: isDistinct)\n    }\n    public func max(isDistinct: Bool = false) -> Expression {\n        return Expression.function(named: \"MAX\", self, isDistinct: isDistinct)\n    }\n    public func min(isDistinct: Bool = false) -> Expression {\n        return Expression.function(named: \"MIN\", self, isDistinct: isDistinct)\n    }\n    public func sum(isDistinct: Bool = false) -> Expression {\n        return Expression.function(named: \"SUM\", self, isDistinct: isDistinct)\n    }\n    public func total(isDistinct: Bool = false) -> Expression {\n        return Expression.function(named: \"TOTAL\", self, isDistinct: isDistinct)\n    }\n\n    // core functions\n    public func abs() -> Expression {\n        return Expression.function(named: \"ABS\", self)\n    }\n    public func hex() -> Expression {\n        return Expression.function(named: \"HEX\", self)\n    }\n    public func length() -> Expression {\n        return Expression.function(named: \"LENGTH\", self)\n    }\n    public func lower() -> Expression {\n        return Expression.function(named: \"LOWER\", self)\n    }\n    public func upper() -> Expression {\n        return Expression.function(named: \"UPPER\", self)\n    }\n    public func round() -> Expression {\n        return Expression.function(named: \"ROUND\", self)\n    }\n\n    // FTS3/4\n    public func matchinfo() -> Expression {\n        return Expression.function(named: \"matchinfo\", self)\n    }\n    public func offsets() -> Expression {\n        return Expression.function(named: \"offsets\", self)\n    }\n    public func snippet() -> Expression {\n        return Expression.function(named: \"snippet\", self)\n    }\n    // FTS5\n    public func bm25() -> Expression {\n        return Expression.function(named: \"bm25\", self)\n    }\n    public func highlight() -> Expression {\n        return Expression.function(named: \"highlight\", self)\n    }\n    public func substringMatchInfo() -> Expression {\n        return Expression.function(named: BuiltinAuxiliaryFunction.SubstringMatchInfo, self)\n    }\n}\n\nextension ExpressionConvertible {\n    static func operate(_ `operator`: UnaryOperateType, operand: ExpressionConvertible) -> Expression {\n        let expression = operand.asExpression()\n        let cppExpression = withExtendedLifetime(expression) {\n            WCDBExpressionUnaryOperate(expression.cppObj, `operator`.cValue)\n        }\n        return Expression(with: cppExpression)\n    }\n    static func operate(left: ExpressionConvertible,\n                        `operator`: BinaryOperateType,\n                        right: ExpressionConvertible, isNot: Bool? = nil) -> Expression {\n        let leftExp = left.asExpression()\n        let rightExp = right.asExpression()\n        if let isNot = isNot {\n            let cppExpression = ObjectBridge.extendLifetime(leftExp, rightExp) {\n                WCDBExpressionBinaryOperate(leftExp.cppObj, rightExp.cppObj, `operator`.cValue, isNot)\n            }\n            return Expression(with: cppExpression)\n        } else {\n            let cppExpression = ObjectBridge.extendLifetime(leftExp, rightExp) {\n                WCDBExpressionBinaryOperate(leftExp.cppObj, rightExp.cppObj, `operator`.cValue, false)\n            }\n            return Expression(with: cppExpression)\n        }\n    }\n}\n\npublic typealias ExpressionOperable = ExpressionUnaryOperable & ExpressionBinaryOperable & ExpressionBetweenOperable & ExpressionInOperable & ExpressionCollateOperable & ExpressionFunctionOperable\n"
  },
  {
    "path": "src/swift/winq/identifier/OrderingTerm.swift",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport Foundation\n#if SWIFT_PACKAGE\nimport WCDB_Private\n#elseif WCDB_SWIFT_TARGET\nimport WCDBSwift.Private\n#else\nimport WCDB.Private\n#endif\n\npublic final class OrderingTerm: Identifier<CPPOrderingTerm> {\n    public init(with expressionConvertible: ExpressionConvertible) {\n        let expression = expressionConvertible.asExpression()\n        let cppOrderingTerm = withExtendedLifetime(expression) {\n            WCDBOrderingTermCreate(expression.cppObj)\n        }\n        super.init(with: cppOrderingTerm)\n    }\n\n    @discardableResult\n    public func order(_ order: Order?) -> OrderingTerm {\n        if let order = order {\n            WCDBOrderingTermConfigOrder(cppObj, order.cValue)\n        }\n        return self\n    }\n\n    @discardableResult\n    public func collate(_ collation: String) -> OrderingTerm {\n        WCDBOrderingTermConfigCollation(cppObj, collation.cString)\n        return self\n    }\n\n    public static func ascendingRowid() -> OrderingTerm {\n        return Column.rowid().order(.ascending)\n    }\n\n    public static func descendingRowid() -> OrderingTerm {\n        return Column.rowid().order(.descending)\n    }\n}\n\nextension OrderingTerm: OrderingTermConvertible {\n    public func asOrder() -> OrderingTerm {\n        return self\n    }\n}\n"
  },
  {
    "path": "src/swift/winq/identifier/Pragma.swift",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport Foundation\n#if SWIFT_PACKAGE\nimport WCDB_Private\n#elseif WCDB_SWIFT_TARGET\nimport WCDBSwift.Private\n#else\nimport WCDB.Private\n#endif\n\npublic final class Pragma: Identifier<CPPPragma> {\n\n    public init(named name: String) {\n        super.init(with: WCDBPragmaCreateWithName(name.cString))\n    }\n\n    nonisolated(unsafe) public static let applicationId = Pragma(named: \"application_id\")\n    nonisolated(unsafe) public static let autoVacuum = Pragma(named: \"auto_vacuum\")\n    nonisolated(unsafe) public static let automaticIndex = Pragma(named: \"automatic_index\")\n    nonisolated(unsafe) public static let busyTimeout = Pragma(named: \"busy_timeout\")\n    nonisolated(unsafe) public static let cacheSize = Pragma(named: \"cache_size\")\n    nonisolated(unsafe) public static let cacheSpill = Pragma(named: \"cache_spill\")\n    nonisolated(unsafe) public static let caseSensitiveLike = Pragma(named: \"case_sensitive_like\")\n    nonisolated(unsafe) public static let cellSizeCheck = Pragma(named: \"cell_size_check\")\n    nonisolated(unsafe) public static let checkpointFullfsync = Pragma(named: \"checkpoint_fullfsync\")\n    nonisolated(unsafe) public static let cipher = Pragma(named: \"cipher\")\n    nonisolated(unsafe) public static let cipherAddRandom = Pragma(named: \"cipher_add_random\")\n    nonisolated(unsafe) public static let cipherDefaultKdfIter = Pragma(named: \"cipher_default_kdf_iter\")\n    nonisolated(unsafe) public static let cipherDefaultPageSize = Pragma(named: \"cipher_default_page_size\")\n    nonisolated(unsafe) public static let cipherDefaultUseHmac = Pragma(named: \"cipher_default_use_hmac\")\n    nonisolated(unsafe) public static let cipherMigrate = Pragma(named: \"cipher_migrate\")\n    nonisolated(unsafe) public static let cipherProfile = Pragma(named: \"cipher_profile\")\n    nonisolated(unsafe) public static let cipherProvider = Pragma(named: \"cipher_provider\")\n    nonisolated(unsafe) public static let cipherProviderVersion = Pragma(named: \"cipher_provider_version\")\n    nonisolated(unsafe) public static let cipherUseHmac = Pragma(named: \"cipher_use_hmac\")\n    nonisolated(unsafe) public static let cipherVersion = Pragma(named: \"cipher_version\")\n    nonisolated(unsafe) public static let cipherPageSize = Pragma(named: \"cipher_page_size\")\n    nonisolated(unsafe) public static let cipherSalt = Pragma(named: \"cipher_salt\")\n    nonisolated(unsafe) public static let cipherPlainTextHeaderSize = Pragma(named: \"cipher_plaintext_header_size\")\n    nonisolated(unsafe) public static let collationList = Pragma(named: \"collation_list\")\n    nonisolated(unsafe) public static let compileOptions = Pragma(named: \"compile_options\")\n    nonisolated(unsafe) public static let countChanges = Pragma(named: \"count_changes\")\n    nonisolated(unsafe) public static let dataStoreDirectory = Pragma(named: \"data_store_directory\")\n    nonisolated(unsafe) public static let dataVersion = Pragma(named: \"data_version\")\n    nonisolated(unsafe) public static let databaseList = Pragma(named: \"database_list\")\n    nonisolated(unsafe) public static let defaultCacheSize = Pragma(named: \"default_cache_size\")\n    nonisolated(unsafe) public static let deferForeignKeys = Pragma(named: \"defer_foreign_keys\")\n    nonisolated(unsafe) public static let emptyResultCallbacks = Pragma(named: \"empty_result_callbacks\")\n    nonisolated(unsafe) public static let encoding = Pragma(named: \"encoding\")\n    nonisolated(unsafe) public static let foreignKeyCheck = Pragma(named: \"foreign_key_check\")\n    nonisolated(unsafe) public static let foreignKeyList = Pragma(named: \"foreign_key_list\")\n    nonisolated(unsafe) public static let foreignKeys = Pragma(named: \"foreign_keys\")\n    nonisolated(unsafe) public static let freelistCount = Pragma(named: \"freelist_count\")\n    nonisolated(unsafe) public static let fullColumnNames = Pragma(named: \"full_column_names\")\n    nonisolated(unsafe) public static let fullfsync = Pragma(named: \"fullfsync\")\n    nonisolated(unsafe) public static let ignoreCheckConstraints = Pragma(named: \"ignore_check_constraints\")\n    nonisolated(unsafe) public static let incrementalVacuum = Pragma(named: \"incremental_vacuum\")\n    nonisolated(unsafe) public static let indexInfo = Pragma(named: \"index_info\")\n    nonisolated(unsafe) public static let indexList = Pragma(named: \"index_list\")\n    nonisolated(unsafe) public static let indexXinfo = Pragma(named: \"index_xinfo\")\n    nonisolated(unsafe) public static let integrityCheck = Pragma(named: \"integrity_check\")\n    nonisolated(unsafe) public static let journalMode = Pragma(named: \"journal_mode\")\n    nonisolated(unsafe) public static let journalSizeLimit = Pragma(named: \"journal_size_limit\")\n    nonisolated(unsafe) public static let key = Pragma(named: \"key\")\n    nonisolated(unsafe) public static let kdfIter = Pragma(named: \"kdf_iter\")\n    nonisolated(unsafe) public static let legacyFileFormat = Pragma(named: \"legacy_file_format\")\n    nonisolated(unsafe) public static let lockingMode = Pragma(named: \"locking_mode\")\n    nonisolated(unsafe) public static let maxPageCount = Pragma(named: \"max_page_count\")\n    nonisolated(unsafe) public static let mmapSize = Pragma(named: \"mmap_size\")\n    nonisolated(unsafe) public static let pageCount = Pragma(named: \"page_count\")\n    nonisolated(unsafe) public static let pageSize = Pragma(named: \"page_size\")\n    nonisolated(unsafe) public static let parserTrace = Pragma(named: \"parser_trace\")\n    nonisolated(unsafe) public static let queryOnly = Pragma(named: \"query_only\")\n    nonisolated(unsafe) public static let quickCheck = Pragma(named: \"quick_check\")\n    nonisolated(unsafe) public static let readUncommitted = Pragma(named: \"read_uncommitted\")\n    nonisolated(unsafe) public static let recursiveTriggers = Pragma(named: \"recursive_triggers\")\n    nonisolated(unsafe) public static let rekey = Pragma(named: \"rekey\")\n    nonisolated(unsafe) public static let reverseUnorderedSelects = Pragma(named: \"reverse_unordered_selects\")\n    nonisolated(unsafe) public static let schemaVersion = Pragma(named: \"schema_version\")\n    nonisolated(unsafe) public static let secureDelete = Pragma(named: \"secure_delete\")\n    nonisolated(unsafe) public static let shortColumnNames = Pragma(named: \"short_column_names\")\n    nonisolated(unsafe) public static let shrinkMemory = Pragma(named: \"shrink_memory\")\n    nonisolated(unsafe) public static let softHeapLimit = Pragma(named: \"soft_heap_limit\")\n    nonisolated(unsafe) public static let stats = Pragma(named: \"stats\")\n    nonisolated(unsafe) public static let synchronous = Pragma(named: \"synchronous\")\n    nonisolated(unsafe) public static let tableInfo = Pragma(named: \"table_info\")\n    nonisolated(unsafe) public static let tempStore = Pragma(named: \"temp_store\")\n    nonisolated(unsafe) public static let tempStoreDirectory = Pragma(named: \"temp_store_directory\")\n    nonisolated(unsafe) public static let threads = Pragma(named: \"threads\")\n    nonisolated(unsafe) public static let userVersion = Pragma(named: \"user_version\")\n    nonisolated(unsafe) public static let vdbeAddoptrace = Pragma(named: \"vdbe_addoptrace\")\n    nonisolated(unsafe) public static let vdbeDebug = Pragma(named: \"vdbe_debug\")\n    nonisolated(unsafe) public static let vdbeListing = Pragma(named: \"vdbe_listing\")\n    nonisolated(unsafe) public static let vdbeTrace = Pragma(named: \"vdbe_trace\")\n    nonisolated(unsafe) public static let walAutocheckpoint = Pragma(named: \"wal_autocheckpoint\")\n    nonisolated(unsafe) public static let walCheckpoint = Pragma(named: \"wal_checkpoint\")\n    nonisolated(unsafe) public static let writableSchema = Pragma(named: \"writable_schema\")\n}\n"
  },
  {
    "path": "src/swift/winq/identifier/QualifiedTable.swift",
    "content": "//\n// Created by qiuwenchen on 2022/6/11.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport Foundation\n#if SWIFT_PACKAGE\nimport WCDB_Private\n#elseif WCDB_SWIFT_TARGET\nimport WCDBSwift.Private\n#else\nimport WCDB.Private\n#endif\n\npublic final class QualifiedTable: Identifier<CPPQualifiedTable> {\n    public init(with name: String) {\n        super.init(with: WCDBQualifiedTableCreateWithTable(name.cString))\n    }\n\n    @discardableResult\n    public func of(schema schemaConvertible: SchemaConvertible) -> QualifiedTable {\n        let schema = schemaConvertible.asSchema()\n        withExtendedLifetime(schema) {\n            WCDBQualifiedTableConfigSchema(cppObj, $0.cppObj)\n        }\n        return self\n    }\n\n    @discardableResult\n    public func `as`(_ alias: String) -> QualifiedTable {\n        WCDBQualifiedTableConfigAliasName(cppObj, alias.cString)\n        return self\n    }\n\n    @discardableResult\n    public func indexed(by indexName: String) -> QualifiedTable {\n        WCDBQualifiedTableConfigIndexName(cppObj, indexName.cString)\n        return self\n    }\n\n    @discardableResult\n    public func notIndexed() -> QualifiedTable {\n        WCDBQualifiedTableConfigNoIndexed(cppObj)\n        return self\n    }\n}\n\nextension QualifiedTable: QualifiedTableConvertible {\n    public func asQualifiedTable() -> QualifiedTable {\n        return self\n    }\n}\n\nextension String: QualifiedTableConvertible {\n    public func asQualifiedTable() -> QualifiedTable {\n        return QualifiedTable(with: self)\n    }\n}\n"
  },
  {
    "path": "src/swift/winq/identifier/RaiseFunction.swift",
    "content": "//\n// Created by qiuwenchen on 2022/5/31.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport Foundation\n#if SWIFT_PACKAGE\nimport WCDB_Private\n#elseif WCDB_SWIFT_TARGET\nimport WCDBSwift.Private\n#else\nimport WCDB.Private\n#endif\n\npublic final class RaiseFunction: Identifier<CPPRaiseFunction> {\n\n    public init() {\n        super.init(with: WCDBRaiseFunctionCreate())\n    }\n\n    @discardableResult\n    public func ignore() -> RaiseFunction {\n        WCDBRaiseFunctionSetAction(cppObj, WCDBSyntaxRaiseAction_Ignore, nil)\n        return self\n    }\n\n    @discardableResult\n    public func rollback(with errorMessage: String) -> RaiseFunction {\n        WCDBRaiseFunctionSetAction(cppObj, WCDBSyntaxRaiseAction_Rollback, errorMessage.cString)\n        return self\n    }\n\n    @discardableResult\n    public func abort(with errorMessage: String) -> RaiseFunction {\n        WCDBRaiseFunctionSetAction(cppObj, WCDBSyntaxRaiseAction_Abort, errorMessage.cString)\n        return self\n    }\n\n    @discardableResult\n    public func fail(with errorMessage: String) -> RaiseFunction {\n        WCDBRaiseFunctionSetAction(cppObj, WCDBSyntaxRaiseAction_Fail, errorMessage.cString)\n        return self\n    }\n}\n\nextension RaiseFunction: ExpressionConvertible {\n    public func asExpression() -> Expression {\n        return Expression(with: self)\n    }\n}\n"
  },
  {
    "path": "src/swift/winq/identifier/ResultColumn.swift",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport Foundation\n#if SWIFT_PACKAGE\nimport WCDB_Private\n#elseif WCDB_SWIFT_TARGET\nimport WCDBSwift.Private\n#else\nimport WCDB.Private\n#endif\n\npublic final class ResultColumn: Identifier<CPPResultColumn> {\n\n    public convenience init(with expressionConvertible: ExpressionConvertible) {\n        let expression = expressionConvertible.asExpression()\n        let cppColumn = withExtendedLifetime(expression) {\n            WCDBResultColumnCreateWithExpression($0.cppObj)\n        }\n        self.init(with: cppColumn)\n    }\n\n    @discardableResult\n    public func `as`(_ alias: String) -> ResultColumn {\n        WCDBResultColumnConfigAlias(cppObj, alias.cString)\n        return self\n    }\n}\n\nextension ResultColumn: ResultColumnConvertible {\n    public func asResultColumn() -> ResultColumn {\n        return self\n    }\n}\n"
  },
  {
    "path": "src/swift/winq/identifier/Schema.swift",
    "content": "//\n// Created by qiuwenchen on 2022/5/26.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport Foundation\n#if SWIFT_PACKAGE\nimport WCDB_Private\n#elseif WCDB_SWIFT_TARGET\nimport WCDBSwift.Private\n#else\nimport WCDB.Private\n#endif\n\npublic final class Schema: Identifier<CPPSchema> {\n    public convenience init(with name: String) {\n        self.init(with: WCDBSchemaCreateWithName(name.cString))\n    }\n\n    nonisolated(unsafe) public static let main: Schema = Schema(with: WCDBSchemaMain())\n    nonisolated(unsafe) public static let temp: Schema = Schema(with: WCDBSchemaTemp())\n}\n\nextension Schema: SchemaConvertible {\n    public func asSchema() -> Schema {\n        return self\n    }\n}\n\nextension String: SchemaConvertible {\n    public func asSchema() -> Schema {\n        return Schema(with: self)\n    }\n}\n"
  },
  {
    "path": "src/swift/winq/identifier/TableConstraint.swift",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport Foundation\n#if SWIFT_PACKAGE\nimport WCDB_Private\n#elseif WCDB_SWIFT_TARGET\nimport WCDBSwift.Private\n#else\nimport WCDB.Private\n#endif\npublic final class TableConstraint: Identifier<CPPTableConstraint> {\n    public init(named name: String? = nil) {\n        super.init(with: WCDBTableConstraintCreate(name?.cString))\n    }\n\n    @discardableResult\n    public func primaryKey() -> TableConstraint {\n        WCDBTableConstraintConfigPrimaryKey(cppObj)\n        return self\n    }\n\n    @discardableResult\n    public func unique() -> TableConstraint {\n        WCDBTableConstraintConfigUnique(cppObj)\n        return self\n    }\n\n    @discardableResult\n    public func indexed(by indexedColumnConvertibleList: IndexedColumnConvertible...) -> TableConstraint {\n        indexed(by: indexedColumnConvertibleList)\n    }\n\n    @discardableResult\n    public func indexed(by indexedColumnConvertibleList: [IndexedColumnConvertible]) -> TableConstraint {\n        let indexedColumns = indexedColumnConvertibleList.map { $0.asIndex() }\n        withExtendedLifetime(indexedColumns) {\n            let cppIndexedColumn = indexedColumns.map { $0.cppObj }\n            cppIndexedColumn.withUnsafeBufferPointer {\n                WCDBTableConstraintConfigIndexedColumn(cppObj, $0.baseAddress, Int32($0.count))\n            }\n        }\n        return self\n    }\n\n    @discardableResult\n    public func onConflict(_ conflict: ConflictAction) -> TableConstraint {\n        WCDBTableConstraintConfigConfliction(cppObj, conflict.cValue)\n        return self\n    }\n\n    @discardableResult\n    public func check(_ expressionConvertible: ExpressionConvertible) -> TableConstraint {\n        let expression = expressionConvertible.asExpression()\n        withExtendedLifetime(expression) {\n            WCDBTableConstraintConfigCheckCondition(cppObj, $0.cppObj)\n        }\n        return self\n    }\n\n    @discardableResult\n    public func foreignKey(_ columnConvertibleList: ColumnConvertible...,\n                               foreignKey: ForeignKey) -> TableConstraint {\n        return self.foreignKey(columnConvertibleList, foreignKey: foreignKey)\n    }\n\n    @discardableResult\n    public func foreignKey(_ columnConvertibleList: [ColumnConvertible],\n                               foreignKey: ForeignKey) -> TableConstraint {\n        let columns = columnConvertibleList.map { $0.asColumn() }\n        ObjectBridge.extendLifetime(columns, foreignKey) {\n            let cppColumns = columns.map { $0.cppObj }\n            cppColumns.withUnsafeBufferPointer {\n                WCDBTableConstraintConfigForeignKey(self.cppObj, $0.baseAddress, Int32($0.count), foreignKey.cppObj)\n            }\n        }\n        return self\n    }\n}\n"
  },
  {
    "path": "src/swift/winq/identifier/TableOrSubquery.swift",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport Foundation\n#if SWIFT_PACKAGE\nimport WCDB_Private\n#elseif WCDB_SWIFT_TARGET\nimport WCDBSwift.Private\n#else\nimport WCDB.Private\n#endif\npublic final class TableOrSubquery: Identifier<CPPTableOrSubquery> {\n\n    public convenience init(withTable table: String) {\n        self.init(with: WCDBTableOrSubqueryCreateWithTable(table.cString))\n    }\n\n    public convenience init(with join: Join) {\n        let cppSubquery = withExtendedLifetime(join) {\n            WCDBTableOrSubqueryCreateWithJoin($0.cppObj)\n        }\n        self.init(with: cppSubquery)\n    }\n\n    public convenience init(with tableOrSubqueryConvertibleList: TableOrSubqueryConvertible...) {\n        self.init(with: tableOrSubqueryConvertibleList)\n    }\n\n    public convenience init(with tableOrSubqueryConvertibleList: [TableOrSubqueryConvertible]) {\n        let queries = tableOrSubqueryConvertibleList.map { $0.asTableOrSubquery() }\n        let cppTableOrSubquery: CPPTableOrSubquery = withExtendedLifetime(queries) {\n            let cppQuries = $0.map { $0.cppObj }\n            return cppQuries.withUnsafeBufferPointer {\n                return WCDBTableOrSubqueryCreateWithTableOrSubqueries($0.baseAddress, Int32($0.count))\n            }\n        }\n        self.init(with: cppTableOrSubquery)\n    }\n\n    public convenience init(with statementSelect: StatementSelect) {\n        let cppSubquery = withExtendedLifetime(statementSelect) {\n            WCDBTableOrSubqueryCreateWithSelection($0.cppObj)\n        }\n        self.init(with: cppSubquery)\n    }\n\n    @discardableResult\n    public func `as`(alias: String) -> TableOrSubquery {\n        WCDBTableOrSubqueryConfigAs(cppObj, alias.cString)\n        return self\n    }\n\n    @discardableResult\n    public func of(schema schemaConvertible: SchemaConvertible) -> TableOrSubquery {\n        let schema = schemaConvertible.asSchema()\n        withExtendedLifetime(schema) {\n            WCDBTableOrSubqueryConfigSchema(cppObj, $0.cppObj)\n        }\n        return self\n    }\n\n    @discardableResult\n    public func notIndexed() -> TableOrSubquery {\n        WCDBTableOrSubqueryConfigNotIndexed(cppObj)\n        return self\n    }\n\n    @discardableResult\n    public func indexed(by indexName: String) -> TableOrSubquery {\n        WCDBTableOrSubqueryConfigIndexName(cppObj, indexName.cString)\n        return self\n    }\n\n    public static func function(_ name: String) -> TableOrSubquery {\n        return TableOrSubquery(with: WCDBTableOrSubqueryCreateWithFunction(name.cString))\n    }\n\n    @discardableResult\n    public func arguments(_ expressionConvertibleList: [ExpressionConvertible]) -> TableOrSubquery {\n        let expressions = expressionConvertibleList.map { $0.asExpression() }\n        withExtendedLifetime(expressions) {\n            let arguments = $0.map { $0.cppObj }\n            arguments.withUnsafeBufferPointer { cppArgs in\n                WCDBTableOrSubqueryConfigArguments(cppObj, cppArgs.baseAddress, Int32(cppArgs.count))\n            }\n        }\n        return self\n    }\n\n    @discardableResult\n    public func arguments(_ expressionConvertibleList: ExpressionConvertible...) -> TableOrSubquery {\n        return self.arguments(expressionConvertibleList)\n    }\n\n    public static func master() -> TableOrSubquery {\n        return TableOrSubquery(withTable: \"sqlite_master\")\n    }\n}\n\nextension TableOrSubquery: TableOrSubqueryConvertible {\n    public func asTableOrSubquery() -> TableOrSubquery {\n        return self\n    }\n}\n\nextension String: TableOrSubqueryConvertible {\n    public func asTableOrSubquery() -> TableOrSubquery {\n        return TableOrSubquery(withTable: self)\n    }\n}\n"
  },
  {
    "path": "src/swift/winq/identifier/Upsert.swift",
    "content": "//\n// Created by qiuwenchen on 2022/6/12.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport Foundation\n#if SWIFT_PACKAGE\nimport WCDB_Private\n#elseif WCDB_SWIFT_TARGET\nimport WCDBSwift.Private\n#else\nimport WCDB.Private\n#endif\n\npublic final class Upsert: Identifier<CPPUpsert> {\n\n    public init() {\n        super.init(with: WCDBUpsertCreate())\n    }\n\n    @discardableResult\n    public func onConflict() -> Upsert {\n        return self\n    }\n\n    @discardableResult\n    public func indexed(by indexedColumnConvertibleList: IndexedColumnConvertible...) -> Upsert {\n        indexed(by: indexedColumnConvertibleList)\n    }\n\n    @discardableResult\n    public func indexed(by indexedColumnConvertibleList: [IndexedColumnConvertible]) -> Upsert {\n        let indexedColumns = indexedColumnConvertibleList.map { $0.asIndex() }\n        withExtendedLifetime(indexedColumns) {\n            let cppIndexedColumn = indexedColumns.map { $0.cppObj }\n            cppIndexedColumn.withUnsafeBufferPointer {\n                WCDBUpsertConfigIndexdColumn(cppObj, $0.baseAddress, Int32($0.count))\n            }\n        }\n        return self\n    }\n\n    @discardableResult\n    public func `where`(_ expressionConvertible: ExpressionConvertible) -> Upsert {\n        let expression = expressionConvertible.asExpression()\n        withExtendedLifetime(expression) {\n            WCDBUpsertConfigWhere(cppObj, $0.cppObj)\n        }\n        return self\n    }\n\n    @discardableResult\n    public func doNothing() -> Upsert {\n        WCDBUpsertConfigDoNothing(cppObj)\n        return self\n    }\n\n    @discardableResult\n    public func doUpdate() -> Upsert {\n        WCDBUpsertConfigDoUpdate(cppObj)\n        return self\n    }\n\n    @discardableResult\n    public func set(_ columnConvertible: ColumnConvertible...) -> Upsert {\n        set(columnConvertible)\n    }\n\n    @discardableResult\n    public func set(_ columnConvertible: [ColumnConvertible]) -> Upsert {\n        let columns = columnConvertible.map { $0.asColumn() }\n        withExtendedLifetime(columns) {\n            let cppColumns = $0.map { $0.cppObj }\n            cppColumns.withUnsafeBufferPointer {\n                WCDBUpsertConfigSetColumns(cppObj, $0.baseAddress, Int32($0.count))\n            }\n        }\n        return self\n    }\n\n    @discardableResult\n    public func to(_ expressionConvertible: ExpressionConvertible) -> Upsert {\n        let expression = expressionConvertible.asExpression()\n        withExtendedLifetime(expression) {\n            WCDBUpsertConfigToValue(cppObj, $0.cppObj)\n        }\n        return self\n    }\n}\n"
  },
  {
    "path": "src/swift/winq/identifier/WindowDef.swift",
    "content": "//\n// Created by qiuwenchen on 2022/5/31.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport Foundation\n#if SWIFT_PACKAGE\nimport WCDB_Private\n#elseif WCDB_SWIFT_TARGET\nimport WCDBSwift.Private\n#else\nimport WCDB.Private\n#endif\npublic final class WindowDef: Identifier<CPPWindowDef> {\n\n    public init() {\n        super.init(with: WCDBWindowDefCreate())\n    }\n\n    @discardableResult\n    public func partition(_ expressionConvertibleList: ExpressionConvertible...) -> WindowDef {\n        self.partition(expressionConvertibleList)\n    }\n\n    @discardableResult\n    public func partition(_ expressionConvertibleList: [ExpressionConvertible]) -> WindowDef {\n        let expressions = expressionConvertibleList.map { $0.asExpression() }\n        withExtendedLifetime(expressions) {\n            let partitions = $0.map { $0.cppObj }\n            partitions.withUnsafeBufferPointer { cppPartitions in\n                WCDBWindowDefConfigPartition(cppObj, cppPartitions.baseAddress, Int32(cppPartitions.count))\n            }\n        }\n        return self\n    }\n\n    @discardableResult\n    public func order(_ orderConvertibleList: OrderingTermConvertible...) -> WindowDef {\n        self.order(orderConvertibleList)\n    }\n\n    @discardableResult\n    public func order(_ orderConvertibleList: [OrderingTermConvertible]) -> WindowDef {\n        let orderingTerms = orderConvertibleList.map { $0.asOrder() }\n        withExtendedLifetime(orderingTerms) {\n            let cppOrderingTerms = $0.map { $0.cppObj }\n            cppOrderingTerms.withUnsafeBufferPointer {\n                WCDBWindowDefConfigOrder(cppObj, $0.baseAddress, Int32($0.count))\n            }\n        }\n        return self\n    }\n\n    @discardableResult\n    public func frameSpec(_ frameSpec: FrameSpec) -> WindowDef {\n        withExtendedLifetime(frameSpec) {\n            WCDBWindowDefConfigFrameSpec(cppObj, $0.cppObj)\n        }\n        return self\n    }\n}\n"
  },
  {
    "path": "src/swift/winq/statement/StatementAlterTable.swift",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport Foundation\n#if SWIFT_PACKAGE\nimport WCDB_Private\n#elseif WCDB_SWIFT_TARGET\nimport WCDBSwift.Private\n#else\nimport WCDB.Private\n#endif\n\npublic final class StatementAlterTable: Identifier<CPPStatementAlterTable>, Statement {\n    public init() {\n        super.init(with: WCDBStatementAlterTableCreate())\n    }\n\n    @discardableResult\n    public func alter(table: String) -> StatementAlterTable {\n        WCDBStatementAlterTableConfigTable(cppObj, table.cString)\n        return self\n    }\n\n    @discardableResult\n    public func schema(_ schemaConvertible: SchemaConvertible) -> StatementAlterTable {\n        let schema = schemaConvertible.asSchema()\n        withExtendedLifetime(schema) {\n            WCDBStatementAlterTableConfigSchema(cppObj, $0.cppObj)\n        }\n        return self\n    }\n\n    @discardableResult\n    public func rename(to newTable: String) -> StatementAlterTable {\n        WCDBStatementAlterTableConfigRenameToTable(cppObj, newTable.cString)\n        return self\n    }\n\n    public func rename(column columnConvertible: ColumnConvertible, to newColumnConvertible: ColumnConvertible) -> StatementAlterTable {\n        let oldColumn = columnConvertible.asColumn()\n        let newColumn = newColumnConvertible.asColumn()\n        ObjectBridge.extendLifetime(oldColumn, newColumn) {\n            WCDBStatementAlterTableConfigRenameColumn(self.cppObj, oldColumn.cppObj)\n            WCDBStatementAlterTableConfigRenameToColumn(self.cppObj, newColumn.cppObj)\n        }\n        return self\n    }\n\n    @discardableResult\n    public func addColumn(with columnDef: ColumnDef) -> StatementAlterTable {\n        withExtendedLifetime(columnDef) {\n            WCDBStatementAlterTableConfigAddColumn(cppObj, columnDef.cppObj)\n        }\n        return self\n    }\n}\n"
  },
  {
    "path": "src/swift/winq/statement/StatementAnalyze.swift",
    "content": "//\n// Created by qiuwenchen on 2022/6/29.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport Foundation\n#if SWIFT_PACKAGE\nimport WCDB_Private\n#elseif WCDB_SWIFT_TARGET\nimport WCDBSwift.Private\n#else\nimport WCDB.Private\n#endif\n\npublic final class StatementAnalyze: Identifier<CPPStatementAnalyze>, Statement {\n    public init() {\n        super.init(with: WCDBStatementAnalyzeCreate())\n    }\n\n    @discardableResult\n    public func analyze() -> StatementAnalyze {\n        WCDBStatementAnalyzeToAnalyze(cppObj)\n        return self\n    }\n\n    @discardableResult\n    public func schema(_ schemaConcertable: SchemaConvertible) -> StatementAnalyze {\n        let schema = schemaConcertable.asSchema()\n        withExtendedLifetime(schema) {\n            WCDBStatementAnalyzeConfigSchema(cppObj, $0.cppObj)\n        }\n        return self\n    }\n\n    @discardableResult\n    public func table(_ name: String) -> StatementAnalyze {\n        WCDBStatementAnalyzeConfigTable(cppObj, name.cString)\n        return self\n    }\n\n    @discardableResult\n    public func index(_ name: String) -> StatementAnalyze {\n        WCDBStatementAnalyzeConfigIndex(cppObj, name.cString)\n        return self\n    }\n}\n"
  },
  {
    "path": "src/swift/winq/statement/StatementAttach.swift",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport Foundation\n#if SWIFT_PACKAGE\nimport WCDB_Private\n#elseif WCDB_SWIFT_TARGET\nimport WCDBSwift.Private\n#else\nimport WCDB.Private\n#endif\npublic final class StatementAttach: Identifier<CPPStatementAttach>, Statement {\n    public init() {\n        super.init(with: WCDBStatementAttachCreate())\n    }\n\n    @discardableResult\n    public func attach(_ expressionConvertible: ExpressionConvertible) -> StatementAttach {\n        let path = expressionConvertible.asExpression()\n        withExtendedLifetime(path) {\n            WCDBStatementAttachConfigPath(cppObj, $0.cppObj)\n        }\n        return self\n    }\n\n    @discardableResult\n    public func `as`(_ schemaConvertible: SchemaConvertible) -> StatementAttach {\n        let schema = schemaConvertible.asSchema()\n        withExtendedLifetime(schema) {\n            WCDBStatementAttachConfigSchema(cppObj, $0.cppObj)\n        }\n        return self\n    }\n\n    @discardableResult\n    public func key(_ expressionConvertible: ExpressionConvertible) -> StatementAttach {\n        let path = expressionConvertible.asExpression()\n        withExtendedLifetime(path) {\n            WCDBStatementAttachConfigKey(cppObj, $0.cppObj)\n        }\n        return self\n    }\n}\n"
  },
  {
    "path": "src/swift/winq/statement/StatementBegin.swift",
    "content": "//\n// Created by qiuwenchen on 2022/7/17.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport Foundation\n#if SWIFT_PACKAGE\nimport WCDB_Private\n#elseif WCDB_SWIFT_TARGET\nimport WCDBSwift.Private\n#else\nimport WCDB.Private\n#endif\npublic final class StatementBegin: Identifier<CPPStatementBegin>, Statement {\n    public init() {\n        super.init(with: WCDBStatementBeginCreate())\n    }\n\n    @discardableResult\n    public func begin(_ transactionType: TransactionType) -> StatementBegin {\n        WCDBStatementBeginConfigType(cppObj, transactionType.cValue)\n        return self\n    }\n}\n"
  },
  {
    "path": "src/swift/winq/statement/StatementCommit.swift",
    "content": "//\n// Created by qiuwenchen on 2022/7/17.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport Foundation\n#if SWIFT_PACKAGE\nimport WCDB_Private\n#elseif WCDB_SWIFT_TARGET\nimport WCDBSwift.Private\n#else\nimport WCDB.Private\n#endif\npublic final class StatementCommit: Identifier<CPPStatementCommit>, Statement {\n    public init() {\n        super.init(with: WCDBStatementCommitCreate())\n    }\n}\n"
  },
  {
    "path": "src/swift/winq/statement/StatementCreateIndex.swift",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport Foundation\n#if SWIFT_PACKAGE\nimport WCDB_Private\n#elseif WCDB_SWIFT_TARGET\nimport WCDBSwift.Private\n#else\nimport WCDB.Private\n#endif\n\npublic final class StatementCreateIndex: Identifier<CPPStatementCreateIndex>, Statement {\n    public init() {\n        super.init(with: WCDBStatementCreateIndexCreate())\n    }\n\n    @discardableResult\n    public func create(index: String, isUnique: Bool = false) -> StatementCreateIndex {\n        WCDBStatementCreateIndexConfigIndexName(cppObj, index.cString)\n        if isUnique {\n            WCDBStatementCreateIndexConfigUniqe(cppObj)\n        }\n        return self\n    }\n\n    @discardableResult\n    public func unique() -> StatementCreateIndex {\n        WCDBStatementCreateIndexConfigUniqe(cppObj)\n        return self\n    }\n\n    @discardableResult\n    public func ifNotExists() -> StatementCreateIndex {\n        WCDBStatementCreateIndexConfigIfNotExist(cppObj)\n        return self\n    }\n\n    @discardableResult\n    public func of(schema schemaConvertible: SchemaConvertible) -> StatementCreateIndex {\n        let schema = schemaConvertible.asSchema()\n        withExtendedLifetime(schema) {\n            WCDBStatementCreateIndexConfigSchema(cppObj, $0.cppObj)\n        }\n        return self\n    }\n\n    @discardableResult\n    public func on(table: String) -> StatementCreateIndex {\n        WCDBStatementCreateIndexConfigTable(cppObj, table.cString)\n        return self\n    }\n\n    @discardableResult\n    public func indexesBy(_ indexedColumnConvertibleList: IndexedColumnConvertible...) -> StatementCreateIndex {\n        return indexesBy(indexedColumnConvertibleList)\n    }\n\n    @discardableResult\n    public func indexesBy(_ indexedColumnConvertibleList: [IndexedColumnConvertible]) -> StatementCreateIndex {\n        let indexedColumns = indexedColumnConvertibleList.map { $0.asIndex() }\n        withExtendedLifetime(indexedColumns) {\n            let cppIndexedColumns = $0.map { $0.cppObj }\n            cppIndexedColumns.withUnsafeBufferPointer {\n                WCDBStatementCreateIndexConfigIndexColumns(cppObj, $0.baseAddress, Int32($0.count))\n            }\n        }\n        return self\n    }\n\n    @discardableResult\n    public func `where`(_ expressionConvertible: ExpressionConvertible) -> StatementCreateIndex {\n        let expression = expressionConvertible.asExpression()\n        withExtendedLifetime(expression) {\n            WCDBStatementCreateIndexConfigWhere(cppObj, $0.cppObj)\n        }\n        return self\n    }\n}\n"
  },
  {
    "path": "src/swift/winq/statement/StatementCreateTable.swift",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport Foundation\n#if SWIFT_PACKAGE\nimport WCDB_Private\n#elseif WCDB_SWIFT_TARGET\nimport WCDBSwift.Private\n#else\nimport WCDB.Private\n#endif\npublic final class StatementCreateTable: Identifier<CPPStatementCreateTable>, Statement {\n    public init() {\n        super.init(with: WCDBStatementCreateTableCreate())\n    }\n\n    @discardableResult\n    public func create(table: String, isTemp: Bool = false) -> StatementCreateTable {\n        WCDBStatementCreateTableConfigTable(cppObj, table.cString)\n        if  isTemp {\n            WCDBStatementCreateTableConfigTemp(cppObj)\n        }\n        return self\n    }\n\n    @discardableResult\n    public func of(schema schemaConvertible: SchemaConvertible) -> StatementCreateTable {\n        let schema = schemaConvertible.asSchema()\n        withExtendedLifetime(schema) {\n            WCDBStatementCreateTableConfigSchema(cppObj, $0.cppObj)\n        }\n        return self\n    }\n\n    @discardableResult\n    public func ifNotExists() -> StatementCreateTable {\n        WCDBStatementCreateTableConfigIfNotExist(cppObj)\n        return self\n    }\n\n    @discardableResult\n    public func `as`(_ select: StatementSelect) -> StatementCreateTable {\n        withExtendedLifetime(select) {\n            WCDBStatementCreateTableConfigAs(cppObj, $0.cppObj)\n        }\n        return self\n    }\n\n    @discardableResult\n    public func with(columns: ColumnDef...) -> StatementCreateTable {\n        with(columns: columns)\n    }\n\n    @discardableResult\n    public func with(columns: [ColumnDef]) -> StatementCreateTable {\n        withExtendedLifetime(columns) {\n            let cppColumns = $0.map { $0.cppObj }\n            cppColumns.withUnsafeBufferPointer {\n                WCDBStatementCreateTableConfigColumns(cppObj, $0.baseAddress, Int32($0.count) )\n            }\n        }\n        return self\n    }\n\n    @discardableResult\n    public func constraint(_ constraints: TableConstraint...) -> StatementCreateTable {\n        constraint(constraints)\n    }\n\n    @discardableResult\n    public func constraint(_ constraints: [TableConstraint]? = nil) -> StatementCreateTable {\n        if let constraints = constraints {\n            withExtendedLifetime(constraints) {\n                let cppConstrain = $0.map { $0.cppObj }\n                cppConstrain.withUnsafeBufferPointer {\n                    WCDBStatementCreateTableConfigTableConstraints(cppObj, $0.baseAddress, Int32($0.count) )\n                }\n            }\n        }\n        return self\n    }\n\n    @discardableResult\n    public func withoutRowid() -> StatementCreateTable {\n        WCDBStatementCreateTableConfigWithoutRowId(cppObj)\n        return self\n    }\n\n}\n"
  },
  {
    "path": "src/swift/winq/statement/StatementCreateTrigger.swift",
    "content": "//\n// Created by qiuwenchen on 2022/7/14.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport Foundation\n#if SWIFT_PACKAGE\nimport WCDB_Private\n#elseif WCDB_SWIFT_TARGET\nimport WCDBSwift.Private\n#else\nimport WCDB.Private\n#endif\n\npublic final class StatementCreateTrigger: Identifier<CPPStatementCreateTrigger>, Statement {\n    public init() {\n        super.init(with: WCDBStatementCreateTriggerCreate())\n    }\n\n    @discardableResult\n    public func create(trigger: String, isTemp: Bool = false) -> StatementCreateTrigger {\n        WCDBStatementCreateTriggerConfigTrigger(cppObj, trigger.cString)\n        if  isTemp {\n            WCDBStatementCreateTriggerConfigTemp(cppObj)\n        }\n        return self\n    }\n\n    @discardableResult\n    public func of(schema schemaConvertible: SchemaConvertible) -> StatementCreateTrigger {\n        let schema = schemaConvertible.asSchema()\n        withExtendedLifetime(schema) {\n            WCDBStatementCreateTriggerConfigSchema(cppObj, $0.cppObj)\n        }\n        return self\n    }\n\n    @discardableResult\n    public func ifNotExists() -> StatementCreateTrigger {\n        WCDBStatementCreateTriggerConfigIfNotExist(cppObj)\n        return self\n    }\n\n    @discardableResult\n    public func before() -> StatementCreateTrigger {\n        WCDBStatementCreateTriggerConfigBefore(cppObj)\n        return self\n    }\n\n    @discardableResult\n    public func after() -> StatementCreateTrigger {\n        WCDBStatementCreateTriggerConfigAfter(cppObj)\n        return self\n    }\n\n    @discardableResult\n    public func insteadOf() -> StatementCreateTrigger {\n        WCDBStatementCreateTriggerConfigInsteadOf(cppObj)\n        return self\n    }\n\n    @discardableResult\n    public func delete() -> StatementCreateTrigger {\n        WCDBStatementCreateTriggerConfigDelete(cppObj)\n        return self\n    }\n\n    @discardableResult\n    public func insert() -> StatementCreateTrigger {\n        WCDBStatementCreateTriggerConfigInsert(cppObj)\n        return self\n    }\n\n    @discardableResult\n    public func update() -> StatementCreateTrigger {\n        WCDBStatementCreateTriggerConfigUpdate(cppObj)\n        return self\n    }\n\n    @discardableResult\n    public func of(columns columnConvertibleList: ColumnConvertible...) -> StatementCreateTrigger {\n        of(columns: columnConvertibleList)\n    }\n\n    @discardableResult\n    public func of(columns columnConvertibleList: [ColumnConvertible]) -> StatementCreateTrigger {\n        let columns = columnConvertibleList.map {$0.asColumn()}\n        withExtendedLifetime(columns) {\n            let cppColumns = columns.map {$0.cppObj}\n            cppColumns.withUnsafeBufferPointer({\n                WCDBStatementCreateTriggerConfigColumns(cppObj, $0.baseAddress, Int32($0.count))\n            })\n        }\n        return self\n    }\n\n    @discardableResult\n    public func on(table: String) -> StatementCreateTrigger {\n        WCDBStatementCreateTriggerConfigTable(cppObj, table.cString)\n        return self\n    }\n\n    @discardableResult\n    public func forEachRow() -> StatementCreateTrigger {\n        WCDBStatementCreateTriggerConfigForEachRow(cppObj)\n        return self\n    }\n\n    @discardableResult\n    public func when(_ expressionConvertible: ExpressionConvertible) -> StatementCreateTrigger {\n        let expression = expressionConvertible.asExpression()\n        withExtendedLifetime(expression) {\n            WCDBStatementCreateTriggerConfigWhen(cppObj, $0.cppObj)\n        }\n        return self\n    }\n\n    @discardableResult\n    public func execute(_ insert: StatementInsert) -> StatementCreateTrigger {\n        withExtendedLifetime(insert) {\n            WCDBStatementCreateTriggerExecuteInsert(cppObj, $0.cppObj)\n        }\n        return self\n    }\n\n    @discardableResult\n    public func execute(_ update: StatementUpdate) -> StatementCreateTrigger {\n        withExtendedLifetime(update) {\n            WCDBStatementCreateTriggerExecuteUpdate(cppObj, $0.cppObj)\n        }\n        return self\n    }\n\n    @discardableResult\n    public func execute(_ delete: StatementDelete) -> StatementCreateTrigger {\n        withExtendedLifetime(delete) {\n            WCDBStatementCreateTriggerExecuteDelete(cppObj, $0.cppObj)\n        }\n        return self\n    }\n\n    @discardableResult\n    public func execute(_ select: StatementSelect) -> StatementCreateTrigger {\n        withExtendedLifetime(select) {\n            WCDBStatementCreateTriggerExecuteSelect(cppObj, $0.cppObj)\n        }\n        return self\n    }\n\n}\n"
  },
  {
    "path": "src/swift/winq/statement/StatementCreateView.swift",
    "content": "//\n// Created by qiuwenchen on 2022/7/13.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport Foundation\n#if SWIFT_PACKAGE\nimport WCDB_Private\n#elseif WCDB_SWIFT_TARGET\nimport WCDBSwift.Private\n#else\nimport WCDB.Private\n#endif\npublic final class StatementCreateView: Identifier<CPPStatementCreateView>, Statement {\n    public init() {\n        super.init(with: WCDBStatementCreateViewCreate())\n    }\n\n    @discardableResult\n    public func create(view: String, isTemp: Bool = false) -> StatementCreateView {\n        WCDBStatementCreateViewConfigView(cppObj, view.cString)\n        if  isTemp {\n            WCDBStatementCreateViewConfigTemp(cppObj)\n        }\n        return self\n    }\n\n    @discardableResult\n    public func of(schema schemaConvertible: SchemaConvertible) -> StatementCreateView {\n        let schema = schemaConvertible.asSchema()\n        withExtendedLifetime(schema) {\n            WCDBStatementCreateViewConfigSchema(cppObj, $0.cppObj)\n        }\n        return self\n    }\n\n    @discardableResult\n    public func ifNotExists() -> StatementCreateView {\n        WCDBStatementCreateViewConfigIfNotExist(cppObj)\n        return self\n    }\n\n    @discardableResult\n    public func `as`(_ select: StatementSelect) -> StatementCreateView {\n        withExtendedLifetime(select) {\n            WCDBStatementCreateViewConfigAs(cppObj, $0.cppObj)\n        }\n        return self\n    }\n\n    public func with(columns: Column...) -> StatementCreateView {\n        with(columns: columns)\n    }\n\n    public func with(columns: [Column]) -> StatementCreateView {\n        withExtendedLifetime(columns) {\n            let cppColumns = $0.map { $0.cppObj }\n            cppColumns.withUnsafeBufferPointer {\n                WCDBStatementCreateViewConfigColumns(cppObj, $0.baseAddress, Int32($0.count) )\n            }\n        }\n        return self\n    }\n\n}\n"
  },
  {
    "path": "src/swift/winq/statement/StatementCreateVirtualTable.swift",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport Foundation\n#if SWIFT_PACKAGE\nimport WCDB_Private\n#elseif WCDB_SWIFT_TARGET\nimport WCDBSwift.Private\n#else\nimport WCDB.Private\n#endif\npublic final class StatementCreateVirtualTable: Identifier<CPPStatementCreateVirtualTable>, Statement {\n    public init() {\n        super.init(with: WCDBStatementCreateVirtualTableCreate())\n    }\n\n    @discardableResult\n    public func create(virtualTable table: String) -> StatementCreateVirtualTable {\n        WCDBStatementCreateVirtualTableConfigTable(cppObj, table.cString)\n        return self\n    }\n\n    @discardableResult\n    public func of(schema schemaConvertible: SchemaConvertible) -> StatementCreateVirtualTable {\n        let schema = schemaConvertible.asSchema()\n        withExtendedLifetime(schema) {\n            WCDBStatementCreateVirtualTableConfigSchema(cppObj, $0.cppObj)\n        }\n        return self\n    }\n\n    @discardableResult\n    public func ifNotExists() -> StatementCreateVirtualTable {\n        WCDBStatementCreateVirtualTableConfigIfNotExist(cppObj)\n        return self\n    }\n\n    @discardableResult\n    public func using(module: FTSVersion) -> StatementCreateVirtualTable {\n        WCDBStatementCreateVirtualTableConfigModule(cppObj, module.description.cString)\n        return self\n    }\n\n    @discardableResult\n    public func using(module: String) -> StatementCreateVirtualTable {\n        WCDBStatementCreateVirtualTableConfigModule(cppObj, module.cString)\n        return self\n    }\n\n    @discardableResult\n    public func arguments(_ args: [Describable]) -> StatementCreateVirtualTable {\n        var discriptions: [String]\n        if args.count == 1, let args = args[0] as? [Describable] {\n            discriptions = args.map {\n                $0.description\n            }\n        } else {\n            discriptions = args.map {\n                $0.description\n            }\n        }\n\n        withExtendedLifetime(discriptions) {\n            let cppArgs = $0.map { $0.cString }\n            cppArgs.withUnsafeBufferPointer {\n                WCDBStatementCreateVirtualTableConfigArguments(cppObj, $0.baseAddress, Int32($0.count))\n            }\n        }\n        return self\n    }\n\n    @discardableResult\n    public func arguments(_ args: Describable...) -> StatementCreateVirtualTable {\n        arguments(args)\n    }\n}\n"
  },
  {
    "path": "src/swift/winq/statement/StatementDelete.swift",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport Foundation\n#if SWIFT_PACKAGE\nimport WCDB_Private\n#elseif WCDB_SWIFT_TARGET\nimport WCDBSwift.Private\n#else\nimport WCDB.Private\n#endif\npublic final class StatementDelete: Identifier<CPPStatementDelete>, Statement {\n    public init() {\n        super.init(with: WCDBStatementDeleteCreate())\n    }\n\n    @discardableResult\n    public func with(recursive: Bool = false, _ expList: CommonTableExpression...) -> StatementDelete {\n        self.with(recursive: recursive, expList)\n    }\n\n    @discardableResult\n    public func with(recursive: Bool = false, _ expList: [CommonTableExpression]) -> StatementDelete {\n        withExtendedLifetime(expList) {\n            let cppExplist = $0.map { $0.cppObj }\n            cppExplist.withUnsafeBufferPointer {\n                WCDBStatementDeleteConfigWith(cppObj, $0.baseAddress, Int32($0.count))\n            }\n        }\n        if recursive {\n            WCDBStatementDeleteConfigRecursive(cppObj)\n        }\n        return self\n    }\n\n    @discardableResult\n    public func delete(from qualifiedTableConvertible: QualifiedTableConvertible) -> StatementDelete {\n        let table = qualifiedTableConvertible.asQualifiedTable()\n        withExtendedLifetime(table) {\n            WCDBStatementDeleteConfigDeleteFrom(cppObj, $0.cppObj)\n        }\n        return self\n    }\n\n    @discardableResult\n    public func `where`(_ expressionConvertible: ExpressionConvertible) -> StatementDelete {\n        let expression = expressionConvertible.asExpression()\n        withExtendedLifetime(expression) {\n            WCDBStatementDeleteConfigWhere(cppObj, $0.cppObj)\n        }\n        return self\n    }\n\n    @discardableResult\n    public func order(by orderConvertibleList: OrderingTermConvertible...) -> StatementDelete {\n        return order(by: orderConvertibleList)\n    }\n\n    @discardableResult\n    public func order(by orderConvertibleList: [OrderingTermConvertible]) -> StatementDelete {\n        let orders = orderConvertibleList.map { $0.asOrder() }\n        withExtendedLifetime(orders) {\n            let cppOrders = orders.map { $0.cppObj }\n            cppOrders.withUnsafeBufferPointer {\n                WCDBStatementDeleteConfigOrder(cppObj, $0.baseAddress, Int32($0.count))\n            }\n        }\n        return self\n    }\n\n    @discardableResult\n    public func limit(from expressionConvertibleFrom: ExpressionConvertible,\n                      to expressionConvertibleTo: ExpressionConvertible) -> StatementDelete {\n        let from = expressionConvertibleFrom.asExpression()\n        let to = expressionConvertibleTo.asExpression()\n        ObjectBridge.extendLifetime(from, to) {\n            WCDBStatementDeleteConfigLimitRange(self.cppObj, from.cppObj, to.cppObj)\n        }\n        return self\n    }\n\n    @discardableResult\n    public func limit(_ expressionConvertibleLimit: ExpressionConvertible) -> StatementDelete {\n        let limit = expressionConvertibleLimit.asExpression()\n        withExtendedLifetime(limit) {\n            WCDBStatementDeleteConfigLimitCount(cppObj, $0.cppObj)\n        }\n        return self\n    }\n\n    @discardableResult\n    public func offset(_ expressionConvertibleOffset: ExpressionConvertible) -> StatementDelete {\n        let offset = expressionConvertibleOffset.asExpression()\n        withExtendedLifetime(offset) {\n            WCDBStatementDeleteConfigOffset(cppObj, $0.cppObj)\n        }\n        return self\n    }\n}\n"
  },
  {
    "path": "src/swift/winq/statement/StatementDetach.swift",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport Foundation\n#if SWIFT_PACKAGE\nimport WCDB_Private\n#elseif WCDB_SWIFT_TARGET\nimport WCDBSwift.Private\n#else\nimport WCDB.Private\n#endif\npublic final class StatementDetach: Identifier<CPPStatementDetach>, Statement {\n    public init() {\n        super.init(with: WCDBStatementDetachCreate())\n    }\n\n    @discardableResult\n    public func detach(schema schemaConvertible: SchemaConvertible) -> StatementDetach {\n        let schema = schemaConvertible.asSchema()\n        withExtendedLifetime(schema) {\n            WCDBStatementDetachConfigSchema(cppObj, $0.cppObj)\n        }\n        return self\n    }\n}\n"
  },
  {
    "path": "src/swift/winq/statement/StatementDropIndex.swift",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport Foundation\n#if SWIFT_PACKAGE\nimport WCDB_Private\n#elseif WCDB_SWIFT_TARGET\nimport WCDBSwift.Private\n#else\nimport WCDB.Private\n#endif\npublic final class StatementDropIndex: Identifier<CPPStatementDropIndex>, Statement {\n    public init() {\n        super.init(with: WCDBStatementDropIndexCreate())\n    }\n\n    @discardableResult\n    public func drop(index: String) -> StatementDropIndex {\n        WCDBStatementDropIndexConfigIndex(cppObj, index.cString)\n        return self\n    }\n\n    @discardableResult\n    public func of(schema schemaConvertible: SchemaConvertible) -> StatementDropIndex {\n        let schema = schemaConvertible.asSchema()\n        withExtendedLifetime(schema) {\n            WCDBStatementDropIndexConfigSchema(cppObj, $0.cppObj)\n        }\n        return self\n    }\n\n    @discardableResult\n    public func ifExists() -> StatementDropIndex {\n        WCDBStatementDropIndexConfigIfExists(cppObj)\n        return self\n    }\n}\n"
  },
  {
    "path": "src/swift/winq/statement/StatementDropTable.swift",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport Foundation\n#if SWIFT_PACKAGE\nimport WCDB_Private\n#elseif WCDB_SWIFT_TARGET\nimport WCDBSwift.Private\n#else\nimport WCDB.Private\n#endif\npublic final class StatementDropTable: Identifier<CPPStatementDropTable>, Statement {\n    public init() {\n        super.init(with: WCDBStatementDropTableCreate())\n    }\n\n    @discardableResult\n    public func drop(table: String) -> StatementDropTable {\n        WCDBStatementDropTableConfigTable(cppObj, table.cString)\n        return self\n    }\n\n    @discardableResult\n    public func of(schema schemaConvertible: SchemaConvertible) -> StatementDropTable {\n        let schema = schemaConvertible.asSchema()\n        withExtendedLifetime(schema) {\n            WCDBStatementDropTableConfigSchema(cppObj, $0.cppObj)\n        }\n        return self\n    }\n\n    @discardableResult\n    public func ifExists() -> StatementDropTable {\n        WCDBStatementDropTableConfigIfExists(cppObj)\n        return self\n    }\n}\n"
  },
  {
    "path": "src/swift/winq/statement/StatementDropTrigger.swift",
    "content": "//\n// Created by qiuwenchen on 2022/7/13.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport Foundation\n#if SWIFT_PACKAGE\nimport WCDB_Private\n#elseif WCDB_SWIFT_TARGET\nimport WCDBSwift.Private\n#else\nimport WCDB.Private\n#endif\npublic final class StatementDropTrigger: Identifier<CPPStatementDropTrigger>, Statement {\n    public init() {\n        super.init(with: WCDBStatementDropTriggerCreate())\n    }\n\n    @discardableResult\n    public func drop(trigger: String) -> StatementDropTrigger {\n        WCDBStatementDropTriggerConfigTrigger(cppObj, trigger.cString)\n        return self\n    }\n\n    @discardableResult\n    public func of(schema schemaConvertible: SchemaConvertible) -> StatementDropTrigger {\n        let schema = schemaConvertible.asSchema()\n        withExtendedLifetime(schema) {\n            WCDBStatementDropTriggerConfigSchema(cppObj, $0.cppObj)\n        }\n        return self\n    }\n\n    @discardableResult\n    public func ifExists() -> StatementDropTrigger {\n        WCDBStatementDropTriggerConfigIfExists(cppObj)\n        return self\n    }\n}\n"
  },
  {
    "path": "src/swift/winq/statement/StatementDropView.swift",
    "content": "//\n// Created by qiuwenchen on 2022/7/13.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport Foundation\n#if SWIFT_PACKAGE\nimport WCDB_Private\n#elseif WCDB_SWIFT_TARGET\nimport WCDBSwift.Private\n#else\nimport WCDB.Private\n#endif\npublic final class StatementDropView: Identifier<CPPStatementDropView>, Statement {\n    public init() {\n        super.init(with: WCDBStatementDropViewCreate())\n    }\n\n    @discardableResult\n    public func drop(view: String) -> StatementDropView {\n        WCDBStatementDropViewConfigView(cppObj, view.cString)\n        return self\n    }\n\n    @discardableResult\n    public func of(schema schemaConvertible: SchemaConvertible) -> StatementDropView {\n        let schema = schemaConvertible.asSchema()\n        withExtendedLifetime(schema) {\n            WCDBStatementDropViewConfigSchema(cppObj, $0.cppObj)\n        }\n        return self\n    }\n\n    @discardableResult\n    public func ifExists() -> StatementDropView {\n        WCDBStatementDropViewConfigIfExists(cppObj)\n        return self\n    }\n}\n"
  },
  {
    "path": "src/swift/winq/statement/StatementExplain.swift",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport Foundation\n#if SWIFT_PACKAGE\nimport WCDB_Private\n#elseif WCDB_SWIFT_TARGET\nimport WCDBSwift.Private\n#else\nimport WCDB.Private\n#endif\npublic final class StatementExplain: Identifier<CPPStatementExplain>, Statement {\n    public init() {\n        super.init(with: WCDBStatementExplainCreate())\n    }\n\n    @discardableResult\n    public func explain(_ statement: Statement) -> StatementExplain {\n        withExtendedLifetime(statement) {\n            WCDBStatementExplain(cppObj, $0.rawCPPObj, false)\n        }\n        return self\n    }\n\n    @discardableResult\n    public func explainQueryPlan(_ statement: Statement) -> StatementExplain {\n        withExtendedLifetime(statement) {\n            WCDBStatementExplain(cppObj, $0.rawCPPObj, true)\n        }\n        return self\n    }\n}\n"
  },
  {
    "path": "src/swift/winq/statement/StatementInsert.swift",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport Foundation\n#if SWIFT_PACKAGE\nimport WCDB_Private\n#elseif WCDB_SWIFT_TARGET\nimport WCDBSwift.Private\n#else\nimport WCDB.Private\n#endif\npublic final class StatementInsert: Identifier<CPPStatementInsert>, Statement {\n    public init() {\n        super.init(with: WCDBStatementInsertCreate())\n    }\n\n    @discardableResult\n    public func with(recursive: Bool = false, _ expList: CommonTableExpression...) -> StatementInsert {\n        self.with(recursive: recursive, expList)\n    }\n\n    @discardableResult\n    public func with(recursive: Bool = false, _ expList: [CommonTableExpression]) -> StatementInsert {\n        withExtendedLifetime(expList) {\n            let cppExplist = $0.map { $0.cppObj }\n            cppExplist.withUnsafeBufferPointer {\n                WCDBStatementInsertConfigWith(cppObj, $0.baseAddress, Int32($0.count))\n            }\n        }\n        if recursive {\n            WCDBStatementInsertConfigRecursive(cppObj)\n        }\n        return self\n    }\n\n    @discardableResult\n    public func insert(intoTable table: String) -> StatementInsert {\n        WCDBStatementInsertConfigTable(cppObj, table.cString)\n        return self\n    }\n\n    @discardableResult\n    public func of(schema schemaConvertibale: SchemaConvertible) -> StatementInsert {\n        let schema = schemaConvertibale.asSchema()\n        withExtendedLifetime(schema) {\n            WCDBStatementInsertConfigSchema(cppObj, $0.cppObj)\n        }\n        return self\n    }\n\n    @discardableResult\n    public func `as`(_ alias: String) -> StatementInsert {\n        WCDBStatementInsertConfigAlias(cppObj, alias.cString)\n        return self\n    }\n\n    @discardableResult\n    public func onConflict(_ conflict: ConflictAction? = nil) -> StatementInsert {\n        if let conflict = conflict {\n            WCDBStatementInsertConfigConfiction(cppObj, conflict.cValue)\n        }\n        return self\n    }\n\n    @discardableResult\n    public func columns(_ columnConvertibleList: ColumnConvertible...) -> StatementInsert {\n        columns(columnConvertibleList)\n    }\n\n    @discardableResult\n    public func columns(_ columnConvertibleList: [ColumnConvertible]) -> StatementInsert {\n        let columns = columnConvertibleList.map {$0.asColumn()}\n        withExtendedLifetime(columns) {\n            let cppColumns = $0.map {$0.cppObj}\n            cppColumns.withUnsafeBufferPointer {\n                WCDBStatementInsertConfigColumns(cppObj, $0.baseAddress, Int32($0.count))\n            }\n        }\n        return self\n    }\n\n    @discardableResult\n    public func values(_ expressionConvertibleList: ExpressionConvertible...) -> StatementInsert {\n        values(expressionConvertibleList)\n    }\n\n    @discardableResult\n    public func values(_ expressionConvertibleList: [ExpressionConvertible]) -> StatementInsert {\n        let expressions = expressionConvertibleList.map { $0.asExpression() }\n        withExtendedLifetime(expressions) {\n            let cppExpressions = $0.map { $0.cppObj }\n            cppExpressions.withUnsafeBufferPointer {\n                WCDBStatementInsertConfigValues(cppObj, $0.baseAddress, Int32($0.count))\n            }\n        }\n        return self\n    }\n\n    @discardableResult\n    public func values(_ select: StatementSelect) -> StatementInsert {\n        withExtendedLifetime(select) {\n            WCDBStatementInsertConfigSelect(cppObj, $0.cppObj)\n        }\n        return self\n    }\n\n    public func defaultValues() -> StatementInsert {\n        WCDBStatementInsertConfigDefaultValues(cppObj)\n        return self\n    }\n\n    public func upsert(_ upsert: Upsert) -> StatementInsert {\n        withExtendedLifetime(upsert) {\n            WCDBStatementInsertConfigUpsert(cppObj, $0.cppObj)\n        }\n        return self\n    }\n}\n"
  },
  {
    "path": "src/swift/winq/statement/StatementPragma.swift",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport Foundation\n#if SWIFT_PACKAGE\nimport WCDB_Private\n#elseif WCDB_SWIFT_TARGET\nimport WCDBSwift.Private\n#else\nimport WCDB.Private\n#endif\npublic final class StatementPragma: Identifier<CPPStatementPragma>, Statement {\n    public init() {\n        super.init(with: WCDBStatementPragmaCreate())\n    }\n\n    @discardableResult\n    public func pragma(_ pragma: Pragma) -> StatementPragma {\n        withExtendedLifetime(pragma) {\n            WCDBStatementPragmaConfigPragma(cppObj, $0.cppObj)\n        }\n        return self\n    }\n\n    @discardableResult\n    public func schema(_ schemaConvertible: SchemaConvertible) -> StatementPragma {\n        let schema = schemaConvertible.asSchema()\n        withExtendedLifetime(schema) {\n            WCDBStatementPragmaConfigSchema(cppObj, $0.cppObj)\n        }\n        return self\n    }\n\n    @discardableResult\n    public func to(_ literalValueConvertible: LiteralValueConvertible) -> StatementPragma {\n        let literalValue = literalValueConvertible.asLiteralValue()\n        withExtendedLifetime(literalValue) {\n            WCDBStatementPragmaConfigToValue(cppObj, $0.cppObj)\n        }\n        return self\n    }\n\n    @discardableResult\n    public func with(_ literalValueConvertible: LiteralValueConvertible) -> StatementPragma {\n        let literalValue = literalValueConvertible.asLiteralValue()\n        withExtendedLifetime(literalValue) {\n            WCDBStatementPragmaConfigWithValue(cppObj, $0.cppObj)\n        }\n        return self\n    }\n}\n"
  },
  {
    "path": "src/swift/winq/statement/StatementReindex.swift",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport Foundation\n#if SWIFT_PACKAGE\nimport WCDB_Private\n#elseif WCDB_SWIFT_TARGET\nimport WCDBSwift.Private\n#else\nimport WCDB.Private\n#endif\npublic final class StatementReindex: Identifier<CPPStatementReIndex>, Statement {\n    public init() {\n        super.init(with: WCDBStatementReIndexCreate())\n    }\n\n    @discardableResult\n    public func reindex(collation: String) -> StatementReindex {\n        WCDBStatementReIndexConfigCollation(cppObj, collation.cString)\n        return self\n    }\n\n    @discardableResult\n    public func reindex(table: String) -> StatementReindex {\n        WCDBStatementReIndexConfigTable(cppObj, table.cString)\n        return self\n    }\n\n    @discardableResult\n    public func reindex(index: String) -> StatementReindex {\n        WCDBStatementReIndexConfigIndex(cppObj, index.cString)\n        return self\n    }\n\n    @discardableResult\n    public func of(schema schemaConvertible: SchemaConvertible) -> StatementReindex {\n        let schema = schemaConvertible.asSchema()\n        withExtendedLifetime(schema) {\n            WCDBStatementReIndexConfigSchema(cppObj, $0.cppObj)\n        }\n        return self\n    }\n}\n"
  },
  {
    "path": "src/swift/winq/statement/StatementRelease.swift",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport Foundation\n#if SWIFT_PACKAGE\nimport WCDB_Private\n#elseif WCDB_SWIFT_TARGET\nimport WCDBSwift.Private\n#else\nimport WCDB.Private\n#endif\npublic final class StatementRelease: Identifier<CPPStatementRelease>, Statement {\n    public init() {\n        super.init(with: WCDBStatementReleaseCreate())\n    }\n\n    @discardableResult\n    public func release(savepoint name: String) -> StatementRelease {\n        WCDBStatementReleaseConfigSavepoint(cppObj, name.cString)\n        return self\n    }\n}\n"
  },
  {
    "path": "src/swift/winq/statement/StatementRollback.swift",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport Foundation\n#if SWIFT_PACKAGE\nimport WCDB_Private\n#elseif WCDB_SWIFT_TARGET\nimport WCDBSwift.Private\n#else\nimport WCDB.Private\n#endif\npublic final class StatementRollback: Identifier<CPPStatementRollback>, Statement {\n    public init() {\n        super.init(with: WCDBStatementRollbackCreate())\n    }\n\n    public func rollback(toSavepoint optionalName: String) -> StatementRollback {\n        WCDBStatementRollbackConfigSavepoint(cppObj, optionalName.cString)\n        return self\n    }\n}\n"
  },
  {
    "path": "src/swift/winq/statement/StatementSavepoint.swift",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport Foundation\n#if SWIFT_PACKAGE\nimport WCDB_Private\n#elseif WCDB_SWIFT_TARGET\nimport WCDBSwift.Private\n#else\nimport WCDB.Private\n#endif\npublic final class StatementSavepoint: Identifier<CPPStatementSavepoint>, Statement {\n    public init() {\n        super.init(with: WCDBStatementSavepointCreate())\n    }\n\n    @discardableResult\n    public func savepoint(_ name: String) -> StatementSavepoint {\n        WCDBStatementSavepointConfigName(cppObj, name.cString)\n        return self\n    }\n}\n"
  },
  {
    "path": "src/swift/winq/statement/StatementSelect.swift",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport Foundation\n#if SWIFT_PACKAGE\nimport WCDB_Private\n#elseif WCDB_SWIFT_TARGET\nimport WCDBSwift.Private\n#else\nimport WCDB.Private\n#endif\npublic final class StatementSelect: Identifier<CPPStatementSelect>, Statement {\n\n    public init() {\n        super.init(with: WCDBStatementSelectCreate())\n    }\n\n    @discardableResult\n    public func with(recursive: Bool = false, _ expList: CommonTableExpression...) -> StatementSelect {\n        self.with(recursive: recursive, expList)\n    }\n\n    @discardableResult\n    public func with(recursive: Bool = false, _ expList: [CommonTableExpression]) -> StatementSelect {\n        withExtendedLifetime(expList) {\n            let cppExplist = $0.map { $0.cppObj }\n            cppExplist.withUnsafeBufferPointer {\n                WCDBStatementSelectConfigWith(cppObj, $0.baseAddress, Int32($0.count))\n            }\n        }\n        if recursive {\n            WCDBStatementSelectConfigRecursive(cppObj)\n        }\n        return self\n    }\n\n    @discardableResult\n    public func select(distinct: Bool = false,\n                       _ resultColumnConvertibleList: ResultColumnConvertible...) -> StatementSelect {\n        return select(distinct: distinct, resultColumnConvertibleList)\n    }\n\n    @discardableResult\n    public func select(distinct: Bool = false,\n                       _ resultColumnConvertibleList: [ResultColumnConvertible]) -> StatementSelect {\n        let resultColumns = resultColumnConvertibleList.map { $0.asResultColumn() }\n        withExtendedLifetime(resultColumns) {\n            let cppColumns = $0.map { $0.cppObj }\n            cppColumns.withUnsafeBufferPointer {\n                WCDBStatementSelectConfigResultColumns(cppObj, $0.baseAddress, Int32($0.count))\n            }\n        }\n        if distinct {\n            WCDBStatementSelectConfigDistinct(cppObj)\n        }\n        return self\n    }\n\n    @discardableResult\n    public func from(_ tableOrSubqueryConvertibleList: TableOrSubqueryConvertible...) -> StatementSelect {\n        return from(tableOrSubqueryConvertibleList)\n    }\n\n    @discardableResult\n    public func from(_ tableOrSubqueryConvertibleList: [TableOrSubqueryConvertible]) -> StatementSelect {\n        let tableOrSubqueries = tableOrSubqueryConvertibleList.map { $0.asTableOrSubquery() }\n        withExtendedLifetime(tableOrSubqueries) {\n            let cppQueries = $0.map { $0.cppObj }\n            cppQueries.withUnsafeBufferPointer {\n                WCDBStatementSelectConfigFromTableOrSubqueries(cppObj, $0.baseAddress, Int32($0.count))\n            }\n        }\n        return self\n    }\n\n    @discardableResult\n    public func `where`(_ expressionConvertible: ExpressionConvertible) -> StatementSelect {\n        let expression = expressionConvertible.asExpression()\n        withExtendedLifetime(expression) {\n            WCDBStatementSelectConfigWhere(cppObj, $0.cppObj)\n        }\n        return self\n    }\n\n    @discardableResult\n    public func group(by expressionConvertibleGroupList: ExpressionConvertible...) -> StatementSelect {\n        return group(by: expressionConvertibleGroupList)\n    }\n\n    @discardableResult\n    public func group(by expressionConvertibleGroupList: [ExpressionConvertible]) -> StatementSelect {\n        let expressions = expressionConvertibleGroupList.map { $0.asExpression() }\n        withExtendedLifetime(expressions) {\n            let cppExpressions = $0.map { $0.cppObj }\n            cppExpressions.withUnsafeBufferPointer {\n                WCDBStatementSelectConfigGroups(cppObj, $0.baseAddress, Int32($0.count))\n            }\n        }\n        return self\n    }\n\n    @discardableResult\n    public func having(_ expressionConvertibleHaving: ExpressionConvertible) -> StatementSelect {\n        let having = expressionConvertibleHaving.asExpression()\n        withExtendedLifetime(having) {\n            WCDBStatementSelectConfigHaving(cppObj, $0.cppObj)\n        }\n        return self\n    }\n\n    @discardableResult\n    public func order(by orderConvertibleList: OrderingTermConvertible...) -> StatementSelect {\n        return order(by: orderConvertibleList)\n    }\n\n    @discardableResult\n    public func order(by orderConvertibleList: [OrderingTermConvertible]) -> StatementSelect {\n        let orderingTerms = orderConvertibleList.map { $0.asOrder() }\n        withExtendedLifetime(orderingTerms) {\n            let cppOrderingTerms = $0.map { $0.cppObj }\n            cppOrderingTerms.withUnsafeBufferPointer {\n                WCDBStatementSelectConfigOrders(cppObj, $0.baseAddress, Int32($0.count))\n            }\n        }\n        return self\n    }\n\n    @discardableResult\n    public func limit(from expressionConvertibleFrom: ExpressionConvertible,\n                      to expressionConvertibleTo: ExpressionConvertible) -> StatementSelect {\n        let from = expressionConvertibleFrom.asExpression()\n        let to = expressionConvertibleTo.asExpression()\n        ObjectBridge.extendLifetime(from, to) {\n            WCDBStatementSelectConfigLimitRange(self.cppObj, from.cppObj, to.cppObj)\n        }\n        return self\n    }\n\n    @discardableResult\n    public func limit(_ expressionConvertibleLimit: ExpressionConvertible) -> StatementSelect {\n        let limit = expressionConvertibleLimit.asExpression()\n        withExtendedLifetime(limit) {\n            WCDBStatementSelectConfigLimitCount(cppObj, $0.cppObj)\n        }\n        return self\n    }\n\n    @discardableResult\n    public func offset(_ expressionConvertibleOffset: ExpressionConvertible) -> StatementSelect {\n        let offset = expressionConvertibleOffset.asExpression()\n        withExtendedLifetime(offset) {\n            WCDBStatementSelectConfigLimitOffset(cppObj, $0.cppObj)\n        }\n        return self\n    }\n\n    @discardableResult\n    public func union() -> StatementSelect {\n        WCDBStatementSelectConfigUnion(cppObj)\n        return self\n    }\n\n    @discardableResult\n    public func unionAll() -> StatementSelect {\n        WCDBStatementSelectConfigUnionAll(cppObj)\n        return self\n    }\n\n    @discardableResult\n    public func intersect() -> StatementSelect {\n        WCDBStatementSelectConfigIntersect(cppObj)\n        return self\n    }\n\n    @discardableResult\n    public func except() -> StatementSelect {\n        WCDBStatementSelectConfigExcept(cppObj)\n        return self\n    }\n\n    @discardableResult\n    public func window(_ name: String) -> StatementSelect {\n        WCDBStatementSelectConfigWindow(cppObj, name.cString)\n        return self\n    }\n\n    @discardableResult\n    public func `as`(_ windowDef: WindowDef) -> StatementSelect {\n        withExtendedLifetime(windowDef) {\n            WCDBStatementSelectConfigAs(cppObj, $0.cppObj)\n        }\n        return self\n    }\n\n    @discardableResult\n    public func value(_ expressionConvertibleList: ExpressionConvertible...) -> StatementSelect {\n        self.value(expressionConvertibleList)\n    }\n\n    @discardableResult\n    public func value(_ expressionConvertibleList: [ExpressionConvertible]) -> StatementSelect {\n        let expressionList = expressionConvertibleList.map { $0.asExpression() }\n        withExtendedLifetime(expressionList) {\n            let cppExpressions = $0.map { $0.cppObj }\n            cppExpressions.withUnsafeBufferPointer {\n                WCDBStatementSelectConfigValues(cppObj, $0.baseAddress, Int32( $0.count ))\n            }\n        }\n        return self\n    }\n}\n\nextension StatementSelect: ExpressionConvertible, TableOrSubqueryConvertible {\n    public func asExpression() -> Expression {\n        return Expression(with: self)\n    }\n    public func asTableOrSubquery() -> TableOrSubquery {\n        return TableOrSubquery(with: self)\n    }\n}\n"
  },
  {
    "path": "src/swift/winq/statement/StatementUpdate.swift",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport Foundation\n#if SWIFT_PACKAGE\nimport WCDB_Private\n#elseif WCDB_SWIFT_TARGET\nimport WCDBSwift.Private\n#else\nimport WCDB.Private\n#endif\npublic final class StatementUpdate: Identifier<CPPStatementUpdate>, Statement {\n\n    public init() {\n        super.init(with: WCDBStatementUpdateCreate())\n    }\n\n    @discardableResult\n    public func with(recursive: Bool = false, _ expList: CommonTableExpression...) -> StatementUpdate {\n        self.with(recursive: recursive, expList)\n    }\n\n    @discardableResult\n    public func with(recursive: Bool = false, _ expList: [CommonTableExpression]) -> StatementUpdate {\n        withExtendedLifetime(expList) {\n            let cppExplist = $0.map { $0.cppObj }\n            cppExplist.withUnsafeBufferPointer {\n                WCDBStatementUpdateConfigWith(cppObj, $0.baseAddress, Int32($0.count))\n            }\n        }\n        if recursive {\n            WCDBStatementUpdateConfigRecursive(cppObj)\n        }\n        return self\n    }\n\n    @discardableResult\n    public func update(table qualifiedTableConvertible: QualifiedTableConvertible) -> StatementUpdate {\n        let qualifiedTable = qualifiedTableConvertible.asQualifiedTable()\n        withExtendedLifetime(qualifiedTable) {\n            WCDBStatementUpdateConfigTable(cppObj, $0.cppObj)\n        }\n        return self\n    }\n\n    @discardableResult\n    public func onConflict(_ conflict: ConflictAction? = nil) -> StatementUpdate {\n        if let conflict = conflict {\n            WCDBStatementUpdateConfigConfiction(cppObj, conflict.cValue)\n        }\n        return self\n    }\n\n    @discardableResult\n    public func set(_ columnConvertibleList: ColumnConvertible...) -> StatementUpdate {\n        set(columnConvertibleList)\n    }\n\n    @discardableResult\n    public func set(_ columnConvertibleList: [ColumnConvertible]) -> StatementUpdate {\n        let columns = columnConvertibleList.map { $0.asColumn() }\n        withExtendedLifetime(columns) {\n            let cppColumns = columns.map { $0.cppObj }\n            cppColumns.withUnsafeBufferPointer {\n                WCDBStatementUpdateConfigColumns(cppObj, $0.baseAddress, Int32($0.count))\n            }\n        }\n        return self\n    }\n\n    @discardableResult\n    public func to(_ value: ExpressionConvertible) -> StatementUpdate {\n        let expression = value.asExpression()\n        withExtendedLifetime(expression) {\n            WCDBStatementUpdateConfigValue(cppObj, $0.cppObj)\n        }\n        return self\n    }\n\n    @discardableResult\n    public func `where`(_ condition: ExpressionConvertible) -> StatementUpdate {\n        let expression = condition.asExpression()\n        withExtendedLifetime(expression) {\n            WCDBStatementUpdateConfigCondition(cppObj, $0.cppObj)\n        }\n        return self\n    }\n\n    @discardableResult\n    public func order(by orderConvertibleList: OrderingTermConvertible...) -> StatementUpdate {\n        return order(by: orderConvertibleList)\n    }\n\n    @discardableResult\n    public func order(by orderConvertibleList: [OrderingTermConvertible]) -> StatementUpdate {\n        let orderingTerms = orderConvertibleList.map { $0.asOrder() }\n        withExtendedLifetime(orderingTerms) {\n            let cppOrderingTerms = $0.map { $0.cppObj }\n            cppOrderingTerms.withUnsafeBufferPointer {\n                WCDBStatementUpdateConfigOrders(cppObj, $0.baseAddress, Int32($0.count))\n            }\n        }\n        return self\n    }\n\n    @discardableResult\n    public func limit(from expressionConvertibleFrom: ExpressionConvertible,\n                      to expressionConvertibleTo: ExpressionConvertible) -> StatementUpdate {\n        let from = expressionConvertibleFrom.asExpression()\n        let to = expressionConvertibleTo.asExpression()\n        ObjectBridge.extendLifetime(from, to) {\n            WCDBStatementUpdateConfigLimitRange(self.cppObj, from.cppObj, to.cppObj)\n        }\n        return self\n    }\n\n    @discardableResult\n    public func limit(_ expressionConvertibleLimit: ExpressionConvertible) -> StatementUpdate {\n        let limit = expressionConvertibleLimit.asExpression()\n        withExtendedLifetime(limit) {\n            WCDBStatementUpdateConfigLimitCount(cppObj, $0.cppObj)\n        }\n        return self\n    }\n\n    @discardableResult\n    public func offset(_ expressionConvertibleOffset: ExpressionConvertible) -> StatementUpdate {\n        let offset = expressionConvertibleOffset.asExpression()\n        withExtendedLifetime(offset) {\n            WCDBStatementUpdateConfigLimitOffset(cppObj, $0.cppObj)\n        }\n        return self\n    }\n\n}\n"
  },
  {
    "path": "src/swift/winq/statement/StatementVacuum.swift",
    "content": "//\n// Created by qiuwenchen on 2022/5/31.\n//\n\n/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport Foundation\n#if SWIFT_PACKAGE\nimport WCDB_Private\n#elseif WCDB_SWIFT_TARGET\nimport WCDBSwift.Private\n#else\nimport WCDB.Private\n#endif\npublic final class StatementVacuum: Identifier<CPPStatementVacuum>, Statement {\n    public init() {\n        super.init(with: WCDBStatementVacuumCreate())\n    }\n\n    @discardableResult\n    public func vacuum(schema schemaConvertible: SchemaConvertible? = nil) -> StatementVacuum {\n        if let schemaConvertible = schemaConvertible {\n            let schema = schemaConvertible.asSchema()\n            withExtendedLifetime(schema) {\n                WCDBStatementVacuumConfigSchema(cppObj, $0.cppObj)\n            }\n        } else {\n            WCDBStatementVacuumConfigAll(cppObj)\n        }\n        return self\n    }\n}\n"
  },
  {
    "path": "src/utility.cmake",
    "content": "macro(recursive_subdirs result basedir)\n    file(GLOB_RECURSE children LIST_DIRECTORIES true ${basedir}/*)\n    set(dirlist ${basedir})\n    foreach(child ${children})\n        if (IS_DIRECTORY ${child})\n            list(APPEND dirlist ${child})\n        endif()\n    endforeach()\n    set(${result} ${dirlist})\nendmacro()\n"
  },
  {
    "path": "src/zstd.cmake",
    "content": "set(ZSTD_ROOT ${CMAKE_CURRENT_LIST_DIR}/../zstd)\nset(ZSTD_INSTALL_HEADER_DIR ${CMAKE_CURRENT_BINARY_DIR}/include)\nmessage(STATUS ${ZSTD_ROOT})\nif (WIN32)\n    enable_language(ASM_MASM)\nelse ()\n    enable_language(ASM)\nendif ()\nset(CMAKE_ASM_FLAGS \"${CFLAGS} -x assembler-with-cpp\")\n\nset(ZSTD_SRC\n    ${ZSTD_ROOT}/lib/common/entropy_common.c\n    ${ZSTD_ROOT}/lib/common/fse_decompress.c\n    ${ZSTD_ROOT}/lib/common/debug.c\n    ${ZSTD_ROOT}/lib/common/xxhash.c\n    ${ZSTD_ROOT}/lib/common/pool.c\n    ${ZSTD_ROOT}/lib/common/threading.c\n    ${ZSTD_ROOT}/lib/common/zstd_common.c\n    ${ZSTD_ROOT}/lib/common/error_private.c\n    ${ZSTD_ROOT}/lib/compress/zstd_compress_superblock.c\n    ${ZSTD_ROOT}/lib/compress/zstdmt_compress.c\n    ${ZSTD_ROOT}/lib/compress/zstd_double_fast.c\n    ${ZSTD_ROOT}/lib/compress/zstd_fast.c\n    ${ZSTD_ROOT}/lib/compress/zstd_compress_sequences.c\n    ${ZSTD_ROOT}/lib/compress/zstd_ldm.c\n    ${ZSTD_ROOT}/lib/compress/hist.c\n    ${ZSTD_ROOT}/lib/compress/zstd_compress.c\n    ${ZSTD_ROOT}/lib/compress/zstd_lazy.c\n    ${ZSTD_ROOT}/lib/compress/zstd_compress_literals.c\n    ${ZSTD_ROOT}/lib/compress/huf_compress.c\n    ${ZSTD_ROOT}/lib/compress/zstd_opt.c\n    ${ZSTD_ROOT}/lib/compress/fse_compress.c\n    ${ZSTD_ROOT}/lib/decompress/zstd_ddict.c\n    ${ZSTD_ROOT}/lib/decompress/huf_decompress.c\n    ${ZSTD_ROOT}/lib/decompress/zstd_decompress.c\n    ${ZSTD_ROOT}/lib/decompress/huf_decompress_amd64.S\n    ${ZSTD_ROOT}/lib/decompress/zstd_decompress_block.c\n    ${ZSTD_ROOT}/lib/dictBuilder/cover.c\n    ${ZSTD_ROOT}/lib/dictBuilder/divsufsort.c\n    ${ZSTD_ROOT}/lib/dictBuilder/fastcover.c\n    ${ZSTD_ROOT}/lib/dictBuilder/zdict.c\n)\n\n# Copy header files to export directory\nset(ZSTD_INSTALL_HEADERS \n    ${ZSTD_ROOT}/lib/zstd.h\n    ${ZSTD_ROOT}/lib/zdict.h\n    ${ZSTD_ROOT}/lib/zstd_errors.h\n)\nfile(COPY ${ZSTD_INSTALL_HEADERS} DESTINATION ${ZSTD_INSTALL_HEADER_DIR}/zstd)\n\nadd_library(zstd STATIC\n    ${ZSTD_SRC}\n)\ntarget_include_directories(zstd INTERFACE ${ZSTD_INSTALL_HEADER_DIR})\ntarget_include_directories(zstd PUBLIC\n    ${ZSTD_ROOT}/lib/common\n    ${ZSTD_ROOT}/lib/compress\n    ${ZSTD_ROOT}/lib/decompress\n    ${ZSTD_ROOT}/lib/dictBuilder\n)\n\nif(WIN32)\n    target_compile_options(zstd PRIVATE /W4)\nelse()\n    target_compile_options(zstd PRIVATE -Wall -Wno-unused -fvisibility=hidden)\nendif()\n"
  },
  {
    "path": "src/zstd.xcodeproj/project.pbxproj",
    "content": "// !$*UTF8*$!\n{\n\tarchiveVersion = 1;\n\tclasses = {\n\t};\n\tobjectVersion = 56;\n\tobjects = {\n\n/* Begin PBXBuildFile section */\n\t\t75EAB82F2ADA39C300AAD3C9 /* zstd_errors.h in Headers */ = {isa = PBXBuildFile; fileRef = 75EAB7EC2ADA39C300AAD3C9 /* zstd_errors.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t75EAB8492ADA39C300AAD3C9 /* zdict.h in Headers */ = {isa = PBXBuildFile; fileRef = 75EAB8072ADA39C300AAD3C9 /* zdict.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t75EAB86E2ADA3FC300AAD3C9 /* zstd.h in Headers */ = {isa = PBXBuildFile; fileRef = 75EAB82E2ADA39C300AAD3C9 /* zstd.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t75EAB8BA2ADA41CD00AAD3C9 /* cover.c in Sources */ = {isa = PBXBuildFile; fileRef = 75EAB8702ADA41CC00AAD3C9 /* cover.c */; };\n\t\t75EAB8BB2ADA41CD00AAD3C9 /* divsufsort.c in Sources */ = {isa = PBXBuildFile; fileRef = 75EAB8712ADA41CC00AAD3C9 /* divsufsort.c */; };\n\t\t75EAB8BC2ADA41CD00AAD3C9 /* fastcover.c in Sources */ = {isa = PBXBuildFile; fileRef = 75EAB8722ADA41CC00AAD3C9 /* fastcover.c */; };\n\t\t75EAB8BD2ADA41CD00AAD3C9 /* zdict.c in Sources */ = {isa = PBXBuildFile; fileRef = 75EAB8732ADA41CC00AAD3C9 /* zdict.c */; };\n\t\t75EAB8BE2ADA41CD00AAD3C9 /* cover.h in Headers */ = {isa = PBXBuildFile; fileRef = 75EAB8742ADA41CC00AAD3C9 /* cover.h */; };\n\t\t75EAB8BF2ADA41CD00AAD3C9 /* divsufsort.h in Headers */ = {isa = PBXBuildFile; fileRef = 75EAB8752ADA41CC00AAD3C9 /* divsufsort.h */; };\n\t\t75EAB8C02ADA41CD00AAD3C9 /* zstd_compress_internal.h in Headers */ = {isa = PBXBuildFile; fileRef = 75EAB8772ADA41CC00AAD3C9 /* zstd_compress_internal.h */; };\n\t\t75EAB8C12ADA41CD00AAD3C9 /* hist.h in Headers */ = {isa = PBXBuildFile; fileRef = 75EAB8782ADA41CC00AAD3C9 /* hist.h */; };\n\t\t75EAB8C22ADA41CD00AAD3C9 /* zstd_ldm.h in Headers */ = {isa = PBXBuildFile; fileRef = 75EAB8792ADA41CC00AAD3C9 /* zstd_ldm.h */; };\n\t\t75EAB8C32ADA41CD00AAD3C9 /* zstd_ldm_geartab.h in Headers */ = {isa = PBXBuildFile; fileRef = 75EAB87A2ADA41CC00AAD3C9 /* zstd_ldm_geartab.h */; };\n\t\t75EAB8C42ADA41CD00AAD3C9 /* zstd_compress_superblock.c in Sources */ = {isa = PBXBuildFile; fileRef = 75EAB87B2ADA41CC00AAD3C9 /* zstd_compress_superblock.c */; };\n\t\t75EAB8C52ADA41CD00AAD3C9 /* zstd_lazy.h in Headers */ = {isa = PBXBuildFile; fileRef = 75EAB87C2ADA41CC00AAD3C9 /* zstd_lazy.h */; };\n\t\t75EAB8C62ADA41CD00AAD3C9 /* zstdmt_compress.c in Sources */ = {isa = PBXBuildFile; fileRef = 75EAB87D2ADA41CC00AAD3C9 /* zstdmt_compress.c */; };\n\t\t75EAB8C72ADA41CD00AAD3C9 /* zstd_double_fast.c in Sources */ = {isa = PBXBuildFile; fileRef = 75EAB87E2ADA41CC00AAD3C9 /* zstd_double_fast.c */; };\n\t\t75EAB8C82ADA41CD00AAD3C9 /* zstd_fast.c in Sources */ = {isa = PBXBuildFile; fileRef = 75EAB87F2ADA41CC00AAD3C9 /* zstd_fast.c */; };\n\t\t75EAB8C92ADA41CD00AAD3C9 /* zstd_opt.h in Headers */ = {isa = PBXBuildFile; fileRef = 75EAB8802ADA41CC00AAD3C9 /* zstd_opt.h */; };\n\t\t75EAB8CA2ADA41CD00AAD3C9 /* zstd_cwksp.h in Headers */ = {isa = PBXBuildFile; fileRef = 75EAB8812ADA41CC00AAD3C9 /* zstd_cwksp.h */; };\n\t\t75EAB8CB2ADA41CD00AAD3C9 /* zstd_compress_sequences.c in Sources */ = {isa = PBXBuildFile; fileRef = 75EAB8822ADA41CC00AAD3C9 /* zstd_compress_sequences.c */; };\n\t\t75EAB8CC2ADA41CD00AAD3C9 /* clevels.h in Headers */ = {isa = PBXBuildFile; fileRef = 75EAB8832ADA41CC00AAD3C9 /* clevels.h */; };\n\t\t75EAB8CD2ADA41CD00AAD3C9 /* zstd_compress_literals.h in Headers */ = {isa = PBXBuildFile; fileRef = 75EAB8842ADA41CC00AAD3C9 /* zstd_compress_literals.h */; };\n\t\t75EAB8CE2ADA41CD00AAD3C9 /* zstd_ldm.c in Sources */ = {isa = PBXBuildFile; fileRef = 75EAB8852ADA41CC00AAD3C9 /* zstd_ldm.c */; };\n\t\t75EAB8CF2ADA41CD00AAD3C9 /* hist.c in Sources */ = {isa = PBXBuildFile; fileRef = 75EAB8862ADA41CC00AAD3C9 /* hist.c */; };\n\t\t75EAB8D02ADA41CD00AAD3C9 /* zstd_compress.c in Sources */ = {isa = PBXBuildFile; fileRef = 75EAB8872ADA41CC00AAD3C9 /* zstd_compress.c */; };\n\t\t75EAB8D12ADA41CD00AAD3C9 /* zstd_double_fast.h in Headers */ = {isa = PBXBuildFile; fileRef = 75EAB8882ADA41CC00AAD3C9 /* zstd_double_fast.h */; };\n\t\t75EAB8D22ADA41CD00AAD3C9 /* zstd_lazy.c in Sources */ = {isa = PBXBuildFile; fileRef = 75EAB8892ADA41CC00AAD3C9 /* zstd_lazy.c */; };\n\t\t75EAB8D32ADA41CD00AAD3C9 /* zstdmt_compress.h in Headers */ = {isa = PBXBuildFile; fileRef = 75EAB88A2ADA41CC00AAD3C9 /* zstdmt_compress.h */; };\n\t\t75EAB8D42ADA41CD00AAD3C9 /* zstd_compress_superblock.h in Headers */ = {isa = PBXBuildFile; fileRef = 75EAB88B2ADA41CC00AAD3C9 /* zstd_compress_superblock.h */; };\n\t\t75EAB8D52ADA41CD00AAD3C9 /* zstd_compress_literals.c in Sources */ = {isa = PBXBuildFile; fileRef = 75EAB88C2ADA41CC00AAD3C9 /* zstd_compress_literals.c */; };\n\t\t75EAB8D62ADA41CD00AAD3C9 /* huf_compress.c in Sources */ = {isa = PBXBuildFile; fileRef = 75EAB88D2ADA41CC00AAD3C9 /* huf_compress.c */; };\n\t\t75EAB8D72ADA41CD00AAD3C9 /* zstd_opt.c in Sources */ = {isa = PBXBuildFile; fileRef = 75EAB88E2ADA41CC00AAD3C9 /* zstd_opt.c */; };\n\t\t75EAB8D82ADA41CD00AAD3C9 /* zstd_compress_sequences.h in Headers */ = {isa = PBXBuildFile; fileRef = 75EAB88F2ADA41CC00AAD3C9 /* zstd_compress_sequences.h */; };\n\t\t75EAB8D92ADA41CD00AAD3C9 /* fse_compress.c in Sources */ = {isa = PBXBuildFile; fileRef = 75EAB8902ADA41CC00AAD3C9 /* fse_compress.c */; };\n\t\t75EAB8DA2ADA41CD00AAD3C9 /* zstd_fast.h in Headers */ = {isa = PBXBuildFile; fileRef = 75EAB8912ADA41CC00AAD3C9 /* zstd_fast.h */; };\n\t\t75EAB8DB2ADA41CD00AAD3C9 /* zstd_ddict.c in Sources */ = {isa = PBXBuildFile; fileRef = 75EAB8932ADA41CD00AAD3C9 /* zstd_ddict.c */; };\n\t\t75EAB8DC2ADA41CD00AAD3C9 /* huf_decompress.c in Sources */ = {isa = PBXBuildFile; fileRef = 75EAB8942ADA41CD00AAD3C9 /* huf_decompress.c */; };\n\t\t75EAB8DD2ADA41CD00AAD3C9 /* zstd_decompress_block.h in Headers */ = {isa = PBXBuildFile; fileRef = 75EAB8952ADA41CD00AAD3C9 /* zstd_decompress_block.h */; };\n\t\t75EAB8DE2ADA41CD00AAD3C9 /* zstd_decompress_internal.h in Headers */ = {isa = PBXBuildFile; fileRef = 75EAB8962ADA41CD00AAD3C9 /* zstd_decompress_internal.h */; };\n\t\t75EAB8DF2ADA41CD00AAD3C9 /* zstd_decompress.c in Sources */ = {isa = PBXBuildFile; fileRef = 75EAB8972ADA41CD00AAD3C9 /* zstd_decompress.c */; };\n\t\t75EAB8E02ADA41CD00AAD3C9 /* zstd_ddict.h in Headers */ = {isa = PBXBuildFile; fileRef = 75EAB8982ADA41CD00AAD3C9 /* zstd_ddict.h */; };\n\t\t75EAB8E12ADA41CD00AAD3C9 /* huf_decompress_amd64.S in Sources */ = {isa = PBXBuildFile; fileRef = 75EAB8992ADA41CD00AAD3C9 /* huf_decompress_amd64.S */; };\n\t\t75EAB8E22ADA41CD00AAD3C9 /* zstd_decompress_block.c in Sources */ = {isa = PBXBuildFile; fileRef = 75EAB89A2ADA41CD00AAD3C9 /* zstd_decompress_block.c */; };\n\t\t75EAB8E32ADA41CD00AAD3C9 /* zstd_trace.h in Headers */ = {isa = PBXBuildFile; fileRef = 75EAB89C2ADA41CD00AAD3C9 /* zstd_trace.h */; };\n\t\t75EAB8E42ADA41CD00AAD3C9 /* xxhash.h in Headers */ = {isa = PBXBuildFile; fileRef = 75EAB89D2ADA41CD00AAD3C9 /* xxhash.h */; };\n\t\t75EAB8E52ADA41CD00AAD3C9 /* debug.h in Headers */ = {isa = PBXBuildFile; fileRef = 75EAB89E2ADA41CD00AAD3C9 /* debug.h */; };\n\t\t75EAB8E62ADA41CD00AAD3C9 /* pool.h in Headers */ = {isa = PBXBuildFile; fileRef = 75EAB89F2ADA41CD00AAD3C9 /* pool.h */; };\n\t\t75EAB8E72ADA41CD00AAD3C9 /* compiler.h in Headers */ = {isa = PBXBuildFile; fileRef = 75EAB8A02ADA41CD00AAD3C9 /* compiler.h */; };\n\t\t75EAB8E82ADA41CD00AAD3C9 /* portability_macros.h in Headers */ = {isa = PBXBuildFile; fileRef = 75EAB8A12ADA41CD00AAD3C9 /* portability_macros.h */; };\n\t\t75EAB8E92ADA41CD00AAD3C9 /* entropy_common.c in Sources */ = {isa = PBXBuildFile; fileRef = 75EAB8A22ADA41CD00AAD3C9 /* entropy_common.c */; };\n\t\t75EAB8EA2ADA41CD00AAD3C9 /* threading.h in Headers */ = {isa = PBXBuildFile; fileRef = 75EAB8A32ADA41CD00AAD3C9 /* threading.h */; };\n\t\t75EAB8EB2ADA41CD00AAD3C9 /* error_private.h in Headers */ = {isa = PBXBuildFile; fileRef = 75EAB8A42ADA41CD00AAD3C9 /* error_private.h */; };\n\t\t75EAB8EC2ADA41CD00AAD3C9 /* fse_decompress.c in Sources */ = {isa = PBXBuildFile; fileRef = 75EAB8A52ADA41CD00AAD3C9 /* fse_decompress.c */; };\n\t\t75EAB8ED2ADA41CD00AAD3C9 /* debug.c in Sources */ = {isa = PBXBuildFile; fileRef = 75EAB8A62ADA41CD00AAD3C9 /* debug.c */; };\n\t\t75EAB8EE2ADA41CD00AAD3C9 /* xxhash.c in Sources */ = {isa = PBXBuildFile; fileRef = 75EAB8A72ADA41CD00AAD3C9 /* xxhash.c */; };\n\t\t75EAB8EF2ADA41CD00AAD3C9 /* bitstream.h in Headers */ = {isa = PBXBuildFile; fileRef = 75EAB8A82ADA41CD00AAD3C9 /* bitstream.h */; };\n\t\t75EAB8F02ADA41CD00AAD3C9 /* cpu.h in Headers */ = {isa = PBXBuildFile; fileRef = 75EAB8A92ADA41CD00AAD3C9 /* cpu.h */; };\n\t\t75EAB8F12ADA41CD00AAD3C9 /* pool.c in Sources */ = {isa = PBXBuildFile; fileRef = 75EAB8AA2ADA41CD00AAD3C9 /* pool.c */; };\n\t\t75EAB8F22ADA41CD00AAD3C9 /* huf.h in Headers */ = {isa = PBXBuildFile; fileRef = 75EAB8AB2ADA41CD00AAD3C9 /* huf.h */; };\n\t\t75EAB8F32ADA41CD00AAD3C9 /* zstd_deps.h in Headers */ = {isa = PBXBuildFile; fileRef = 75EAB8AC2ADA41CD00AAD3C9 /* zstd_deps.h */; };\n\t\t75EAB8F42ADA41CD00AAD3C9 /* mem.h in Headers */ = {isa = PBXBuildFile; fileRef = 75EAB8AD2ADA41CD00AAD3C9 /* mem.h */; };\n\t\t75EAB8F52ADA41CD00AAD3C9 /* threading.c in Sources */ = {isa = PBXBuildFile; fileRef = 75EAB8AE2ADA41CD00AAD3C9 /* threading.c */; };\n\t\t75EAB8F62ADA41CD00AAD3C9 /* zstd_common.c in Sources */ = {isa = PBXBuildFile; fileRef = 75EAB8AF2ADA41CD00AAD3C9 /* zstd_common.c */; };\n\t\t75EAB8F72ADA41CD00AAD3C9 /* fse.h in Headers */ = {isa = PBXBuildFile; fileRef = 75EAB8B02ADA41CD00AAD3C9 /* fse.h */; };\n\t\t75EAB8F82ADA41CD00AAD3C9 /* zstd_internal.h in Headers */ = {isa = PBXBuildFile; fileRef = 75EAB8B12ADA41CD00AAD3C9 /* zstd_internal.h */; };\n\t\t75EAB8F92ADA41CD00AAD3C9 /* bits.h in Headers */ = {isa = PBXBuildFile; fileRef = 75EAB8B22ADA41CD00AAD3C9 /* bits.h */; };\n\t\t75EAB8FA2ADA41CD00AAD3C9 /* allocations.h in Headers */ = {isa = PBXBuildFile; fileRef = 75EAB8B32ADA41CD00AAD3C9 /* allocations.h */; };\n\t\t75EAB8FB2ADA41CD00AAD3C9 /* error_private.c in Sources */ = {isa = PBXBuildFile; fileRef = 75EAB8B42ADA41CD00AAD3C9 /* error_private.c */; };\n/* End PBXBuildFile section */\n\n/* Begin PBXFileReference section */\n\t\t0DACF8CA2B2B06FA00CB0710 /* ZstdBase.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = ZstdBase.xcconfig; path = support/ZstdBase.xcconfig; sourceTree = \"<group>\"; };\n\t\t0DACF8CB2B2B06FA00CB0710 /* ZstdDebug.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = ZstdDebug.xcconfig; path = support/ZstdDebug.xcconfig; sourceTree = \"<group>\"; };\n\t\t0DACF8CC2B2B06FA00CB0710 /* ZstdRelease.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = ZstdRelease.xcconfig; path = support/ZstdRelease.xcconfig; sourceTree = \"<group>\"; };\n\t\t75EAB79C2ADA376000AAD3C9 /* zstd.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = zstd.framework; sourceTree = BUILT_PRODUCTS_DIR; };\n\t\t75EAB7EC2ADA39C300AAD3C9 /* zstd_errors.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = zstd_errors.h; path = ../zstd/lib/zstd_errors.h; sourceTree = \"<group>\"; };\n\t\t75EAB8072ADA39C300AAD3C9 /* zdict.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = zdict.h; path = ../zstd/lib/zdict.h; sourceTree = \"<group>\"; };\n\t\t75EAB82E2ADA39C300AAD3C9 /* zstd.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = zstd.h; path = ../zstd/lib/zstd.h; sourceTree = \"<group>\"; };\n\t\t75EAB8702ADA41CC00AAD3C9 /* cover.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = cover.c; sourceTree = \"<group>\"; };\n\t\t75EAB8712ADA41CC00AAD3C9 /* divsufsort.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = divsufsort.c; sourceTree = \"<group>\"; };\n\t\t75EAB8722ADA41CC00AAD3C9 /* fastcover.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = fastcover.c; sourceTree = \"<group>\"; };\n\t\t75EAB8732ADA41CC00AAD3C9 /* zdict.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = zdict.c; sourceTree = \"<group>\"; };\n\t\t75EAB8742ADA41CC00AAD3C9 /* cover.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = cover.h; sourceTree = \"<group>\"; };\n\t\t75EAB8752ADA41CC00AAD3C9 /* divsufsort.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = divsufsort.h; sourceTree = \"<group>\"; };\n\t\t75EAB8772ADA41CC00AAD3C9 /* zstd_compress_internal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = zstd_compress_internal.h; sourceTree = \"<group>\"; };\n\t\t75EAB8782ADA41CC00AAD3C9 /* hist.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = hist.h; sourceTree = \"<group>\"; };\n\t\t75EAB8792ADA41CC00AAD3C9 /* zstd_ldm.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = zstd_ldm.h; sourceTree = \"<group>\"; };\n\t\t75EAB87A2ADA41CC00AAD3C9 /* zstd_ldm_geartab.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = zstd_ldm_geartab.h; sourceTree = \"<group>\"; };\n\t\t75EAB87B2ADA41CC00AAD3C9 /* zstd_compress_superblock.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = zstd_compress_superblock.c; sourceTree = \"<group>\"; };\n\t\t75EAB87C2ADA41CC00AAD3C9 /* zstd_lazy.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = zstd_lazy.h; sourceTree = \"<group>\"; };\n\t\t75EAB87D2ADA41CC00AAD3C9 /* zstdmt_compress.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = zstdmt_compress.c; sourceTree = \"<group>\"; };\n\t\t75EAB87E2ADA41CC00AAD3C9 /* zstd_double_fast.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = zstd_double_fast.c; sourceTree = \"<group>\"; };\n\t\t75EAB87F2ADA41CC00AAD3C9 /* zstd_fast.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = zstd_fast.c; sourceTree = \"<group>\"; };\n\t\t75EAB8802ADA41CC00AAD3C9 /* zstd_opt.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = zstd_opt.h; sourceTree = \"<group>\"; };\n\t\t75EAB8812ADA41CC00AAD3C9 /* zstd_cwksp.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = zstd_cwksp.h; sourceTree = \"<group>\"; };\n\t\t75EAB8822ADA41CC00AAD3C9 /* zstd_compress_sequences.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = zstd_compress_sequences.c; sourceTree = \"<group>\"; };\n\t\t75EAB8832ADA41CC00AAD3C9 /* clevels.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = clevels.h; sourceTree = \"<group>\"; };\n\t\t75EAB8842ADA41CC00AAD3C9 /* zstd_compress_literals.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = zstd_compress_literals.h; sourceTree = \"<group>\"; };\n\t\t75EAB8852ADA41CC00AAD3C9 /* zstd_ldm.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = zstd_ldm.c; sourceTree = \"<group>\"; };\n\t\t75EAB8862ADA41CC00AAD3C9 /* hist.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = hist.c; sourceTree = \"<group>\"; };\n\t\t75EAB8872ADA41CC00AAD3C9 /* zstd_compress.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = zstd_compress.c; sourceTree = \"<group>\"; };\n\t\t75EAB8882ADA41CC00AAD3C9 /* zstd_double_fast.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = zstd_double_fast.h; sourceTree = \"<group>\"; };\n\t\t75EAB8892ADA41CC00AAD3C9 /* zstd_lazy.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = zstd_lazy.c; sourceTree = \"<group>\"; };\n\t\t75EAB88A2ADA41CC00AAD3C9 /* zstdmt_compress.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = zstdmt_compress.h; sourceTree = \"<group>\"; };\n\t\t75EAB88B2ADA41CC00AAD3C9 /* zstd_compress_superblock.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = zstd_compress_superblock.h; sourceTree = \"<group>\"; };\n\t\t75EAB88C2ADA41CC00AAD3C9 /* zstd_compress_literals.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = zstd_compress_literals.c; sourceTree = \"<group>\"; };\n\t\t75EAB88D2ADA41CC00AAD3C9 /* huf_compress.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = huf_compress.c; sourceTree = \"<group>\"; };\n\t\t75EAB88E2ADA41CC00AAD3C9 /* zstd_opt.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = zstd_opt.c; sourceTree = \"<group>\"; };\n\t\t75EAB88F2ADA41CC00AAD3C9 /* zstd_compress_sequences.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = zstd_compress_sequences.h; sourceTree = \"<group>\"; };\n\t\t75EAB8902ADA41CC00AAD3C9 /* fse_compress.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = fse_compress.c; sourceTree = \"<group>\"; };\n\t\t75EAB8912ADA41CC00AAD3C9 /* zstd_fast.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = zstd_fast.h; sourceTree = \"<group>\"; };\n\t\t75EAB8932ADA41CD00AAD3C9 /* zstd_ddict.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = zstd_ddict.c; sourceTree = \"<group>\"; };\n\t\t75EAB8942ADA41CD00AAD3C9 /* huf_decompress.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = huf_decompress.c; sourceTree = \"<group>\"; };\n\t\t75EAB8952ADA41CD00AAD3C9 /* zstd_decompress_block.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = zstd_decompress_block.h; sourceTree = \"<group>\"; };\n\t\t75EAB8962ADA41CD00AAD3C9 /* zstd_decompress_internal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = zstd_decompress_internal.h; sourceTree = \"<group>\"; };\n\t\t75EAB8972ADA41CD00AAD3C9 /* zstd_decompress.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = zstd_decompress.c; sourceTree = \"<group>\"; };\n\t\t75EAB8982ADA41CD00AAD3C9 /* zstd_ddict.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = zstd_ddict.h; sourceTree = \"<group>\"; };\n\t\t75EAB8992ADA41CD00AAD3C9 /* huf_decompress_amd64.S */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.asm; path = huf_decompress_amd64.S; sourceTree = \"<group>\"; };\n\t\t75EAB89A2ADA41CD00AAD3C9 /* zstd_decompress_block.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = zstd_decompress_block.c; sourceTree = \"<group>\"; };\n\t\t75EAB89C2ADA41CD00AAD3C9 /* zstd_trace.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = zstd_trace.h; sourceTree = \"<group>\"; };\n\t\t75EAB89D2ADA41CD00AAD3C9 /* xxhash.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = xxhash.h; sourceTree = \"<group>\"; };\n\t\t75EAB89E2ADA41CD00AAD3C9 /* debug.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = debug.h; sourceTree = \"<group>\"; };\n\t\t75EAB89F2ADA41CD00AAD3C9 /* pool.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = pool.h; sourceTree = \"<group>\"; };\n\t\t75EAB8A02ADA41CD00AAD3C9 /* compiler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = compiler.h; sourceTree = \"<group>\"; };\n\t\t75EAB8A12ADA41CD00AAD3C9 /* portability_macros.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = portability_macros.h; sourceTree = \"<group>\"; };\n\t\t75EAB8A22ADA41CD00AAD3C9 /* entropy_common.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = entropy_common.c; sourceTree = \"<group>\"; };\n\t\t75EAB8A32ADA41CD00AAD3C9 /* threading.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = threading.h; sourceTree = \"<group>\"; };\n\t\t75EAB8A42ADA41CD00AAD3C9 /* error_private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = error_private.h; sourceTree = \"<group>\"; };\n\t\t75EAB8A52ADA41CD00AAD3C9 /* fse_decompress.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = fse_decompress.c; sourceTree = \"<group>\"; };\n\t\t75EAB8A62ADA41CD00AAD3C9 /* debug.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = debug.c; sourceTree = \"<group>\"; };\n\t\t75EAB8A72ADA41CD00AAD3C9 /* xxhash.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = xxhash.c; sourceTree = \"<group>\"; };\n\t\t75EAB8A82ADA41CD00AAD3C9 /* bitstream.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = bitstream.h; sourceTree = \"<group>\"; };\n\t\t75EAB8A92ADA41CD00AAD3C9 /* cpu.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = cpu.h; sourceTree = \"<group>\"; };\n\t\t75EAB8AA2ADA41CD00AAD3C9 /* pool.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = pool.c; sourceTree = \"<group>\"; };\n\t\t75EAB8AB2ADA41CD00AAD3C9 /* huf.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = huf.h; sourceTree = \"<group>\"; };\n\t\t75EAB8AC2ADA41CD00AAD3C9 /* zstd_deps.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = zstd_deps.h; sourceTree = \"<group>\"; };\n\t\t75EAB8AD2ADA41CD00AAD3C9 /* mem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = mem.h; sourceTree = \"<group>\"; };\n\t\t75EAB8AE2ADA41CD00AAD3C9 /* threading.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = threading.c; sourceTree = \"<group>\"; };\n\t\t75EAB8AF2ADA41CD00AAD3C9 /* zstd_common.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = zstd_common.c; sourceTree = \"<group>\"; };\n\t\t75EAB8B02ADA41CD00AAD3C9 /* fse.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = fse.h; sourceTree = \"<group>\"; };\n\t\t75EAB8B12ADA41CD00AAD3C9 /* zstd_internal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = zstd_internal.h; sourceTree = \"<group>\"; };\n\t\t75EAB8B22ADA41CD00AAD3C9 /* bits.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = bits.h; sourceTree = \"<group>\"; };\n\t\t75EAB8B32ADA41CD00AAD3C9 /* allocations.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = allocations.h; sourceTree = \"<group>\"; };\n\t\t75EAB8B42ADA41CD00AAD3C9 /* error_private.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = error_private.c; sourceTree = \"<group>\"; };\n\t\t75EAB8B62ADA41CD00AAD3C9 /* zbuff_common.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = zbuff_common.c; sourceTree = \"<group>\"; };\n\t\t75EAB8B72ADA41CD00AAD3C9 /* zbuff_decompress.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = zbuff_decompress.c; sourceTree = \"<group>\"; };\n\t\t75EAB8B82ADA41CD00AAD3C9 /* zbuff.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = zbuff.h; sourceTree = \"<group>\"; };\n\t\t75EAB8B92ADA41CD00AAD3C9 /* zbuff_compress.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = zbuff_compress.c; sourceTree = \"<group>\"; };\n/* End PBXFileReference section */\n\n/* Begin PBXFrameworksBuildPhase section */\n\t\t75EAB7992ADA376000AAD3C9 /* Frameworks */ = {\n\t\t\tisa = PBXFrameworksBuildPhase;\n\t\t\tbuildActionMask = 2147483647;\n\t\t\tfiles = (\n\t\t\t);\n\t\t\trunOnlyForDeploymentPostprocessing = 0;\n\t\t};\n/* End PBXFrameworksBuildPhase section */\n\n/* Begin PBXGroup section */\n\t\t75EAB7922ADA376000AAD3C9 = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t0DACF8CA2B2B06FA00CB0710 /* ZstdBase.xcconfig */,\n\t\t\t\t0DACF8CB2B2B06FA00CB0710 /* ZstdDebug.xcconfig */,\n\t\t\t\t0DACF8CC2B2B06FA00CB0710 /* ZstdRelease.xcconfig */,\n\t\t\t\t75EAB89B2ADA41CD00AAD3C9 /* common */,\n\t\t\t\t75EAB8762ADA41CC00AAD3C9 /* compress */,\n\t\t\t\t75EAB8922ADA41CD00AAD3C9 /* decompress */,\n\t\t\t\t75EAB8B52ADA41CD00AAD3C9 /* deprecated */,\n\t\t\t\t75EAB86F2ADA41CC00AAD3C9 /* dictBuilder */,\n\t\t\t\t75EAB8072ADA39C300AAD3C9 /* zdict.h */,\n\t\t\t\t75EAB7EC2ADA39C300AAD3C9 /* zstd_errors.h */,\n\t\t\t\t75EAB82E2ADA39C300AAD3C9 /* zstd.h */,\n\t\t\t\t75EAB79D2ADA376000AAD3C9 /* Products */,\n\t\t\t);\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t75EAB79D2ADA376000AAD3C9 /* Products */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t75EAB79C2ADA376000AAD3C9 /* zstd.framework */,\n\t\t\t);\n\t\t\tname = Products;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t75EAB86F2ADA41CC00AAD3C9 /* dictBuilder */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t75EAB8702ADA41CC00AAD3C9 /* cover.c */,\n\t\t\t\t75EAB8712ADA41CC00AAD3C9 /* divsufsort.c */,\n\t\t\t\t75EAB8722ADA41CC00AAD3C9 /* fastcover.c */,\n\t\t\t\t75EAB8732ADA41CC00AAD3C9 /* zdict.c */,\n\t\t\t\t75EAB8742ADA41CC00AAD3C9 /* cover.h */,\n\t\t\t\t75EAB8752ADA41CC00AAD3C9 /* divsufsort.h */,\n\t\t\t);\n\t\t\tname = dictBuilder;\n\t\t\tpath = ../zstd/lib/dictBuilder;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t75EAB8762ADA41CC00AAD3C9 /* compress */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t75EAB8772ADA41CC00AAD3C9 /* zstd_compress_internal.h */,\n\t\t\t\t75EAB8782ADA41CC00AAD3C9 /* hist.h */,\n\t\t\t\t75EAB8792ADA41CC00AAD3C9 /* zstd_ldm.h */,\n\t\t\t\t75EAB87A2ADA41CC00AAD3C9 /* zstd_ldm_geartab.h */,\n\t\t\t\t75EAB87B2ADA41CC00AAD3C9 /* zstd_compress_superblock.c */,\n\t\t\t\t75EAB87C2ADA41CC00AAD3C9 /* zstd_lazy.h */,\n\t\t\t\t75EAB87D2ADA41CC00AAD3C9 /* zstdmt_compress.c */,\n\t\t\t\t75EAB87E2ADA41CC00AAD3C9 /* zstd_double_fast.c */,\n\t\t\t\t75EAB87F2ADA41CC00AAD3C9 /* zstd_fast.c */,\n\t\t\t\t75EAB8802ADA41CC00AAD3C9 /* zstd_opt.h */,\n\t\t\t\t75EAB8812ADA41CC00AAD3C9 /* zstd_cwksp.h */,\n\t\t\t\t75EAB8822ADA41CC00AAD3C9 /* zstd_compress_sequences.c */,\n\t\t\t\t75EAB8832ADA41CC00AAD3C9 /* clevels.h */,\n\t\t\t\t75EAB8842ADA41CC00AAD3C9 /* zstd_compress_literals.h */,\n\t\t\t\t75EAB8852ADA41CC00AAD3C9 /* zstd_ldm.c */,\n\t\t\t\t75EAB8862ADA41CC00AAD3C9 /* hist.c */,\n\t\t\t\t75EAB8872ADA41CC00AAD3C9 /* zstd_compress.c */,\n\t\t\t\t75EAB8882ADA41CC00AAD3C9 /* zstd_double_fast.h */,\n\t\t\t\t75EAB8892ADA41CC00AAD3C9 /* zstd_lazy.c */,\n\t\t\t\t75EAB88A2ADA41CC00AAD3C9 /* zstdmt_compress.h */,\n\t\t\t\t75EAB88B2ADA41CC00AAD3C9 /* zstd_compress_superblock.h */,\n\t\t\t\t75EAB88C2ADA41CC00AAD3C9 /* zstd_compress_literals.c */,\n\t\t\t\t75EAB88D2ADA41CC00AAD3C9 /* huf_compress.c */,\n\t\t\t\t75EAB88E2ADA41CC00AAD3C9 /* zstd_opt.c */,\n\t\t\t\t75EAB88F2ADA41CC00AAD3C9 /* zstd_compress_sequences.h */,\n\t\t\t\t75EAB8902ADA41CC00AAD3C9 /* fse_compress.c */,\n\t\t\t\t75EAB8912ADA41CC00AAD3C9 /* zstd_fast.h */,\n\t\t\t);\n\t\t\tname = compress;\n\t\t\tpath = ../zstd/lib/compress;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t75EAB8922ADA41CD00AAD3C9 /* decompress */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t75EAB8932ADA41CD00AAD3C9 /* zstd_ddict.c */,\n\t\t\t\t75EAB8942ADA41CD00AAD3C9 /* huf_decompress.c */,\n\t\t\t\t75EAB8952ADA41CD00AAD3C9 /* zstd_decompress_block.h */,\n\t\t\t\t75EAB8962ADA41CD00AAD3C9 /* zstd_decompress_internal.h */,\n\t\t\t\t75EAB8972ADA41CD00AAD3C9 /* zstd_decompress.c */,\n\t\t\t\t75EAB8982ADA41CD00AAD3C9 /* zstd_ddict.h */,\n\t\t\t\t75EAB8992ADA41CD00AAD3C9 /* huf_decompress_amd64.S */,\n\t\t\t\t75EAB89A2ADA41CD00AAD3C9 /* zstd_decompress_block.c */,\n\t\t\t);\n\t\t\tname = decompress;\n\t\t\tpath = ../zstd/lib/decompress;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t75EAB89B2ADA41CD00AAD3C9 /* common */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t75EAB89C2ADA41CD00AAD3C9 /* zstd_trace.h */,\n\t\t\t\t75EAB89D2ADA41CD00AAD3C9 /* xxhash.h */,\n\t\t\t\t75EAB89E2ADA41CD00AAD3C9 /* debug.h */,\n\t\t\t\t75EAB89F2ADA41CD00AAD3C9 /* pool.h */,\n\t\t\t\t75EAB8A02ADA41CD00AAD3C9 /* compiler.h */,\n\t\t\t\t75EAB8A12ADA41CD00AAD3C9 /* portability_macros.h */,\n\t\t\t\t75EAB8A22ADA41CD00AAD3C9 /* entropy_common.c */,\n\t\t\t\t75EAB8A32ADA41CD00AAD3C9 /* threading.h */,\n\t\t\t\t75EAB8A42ADA41CD00AAD3C9 /* error_private.h */,\n\t\t\t\t75EAB8A52ADA41CD00AAD3C9 /* fse_decompress.c */,\n\t\t\t\t75EAB8A62ADA41CD00AAD3C9 /* debug.c */,\n\t\t\t\t75EAB8A72ADA41CD00AAD3C9 /* xxhash.c */,\n\t\t\t\t75EAB8A82ADA41CD00AAD3C9 /* bitstream.h */,\n\t\t\t\t75EAB8A92ADA41CD00AAD3C9 /* cpu.h */,\n\t\t\t\t75EAB8AA2ADA41CD00AAD3C9 /* pool.c */,\n\t\t\t\t75EAB8AB2ADA41CD00AAD3C9 /* huf.h */,\n\t\t\t\t75EAB8AC2ADA41CD00AAD3C9 /* zstd_deps.h */,\n\t\t\t\t75EAB8AD2ADA41CD00AAD3C9 /* mem.h */,\n\t\t\t\t75EAB8AE2ADA41CD00AAD3C9 /* threading.c */,\n\t\t\t\t75EAB8AF2ADA41CD00AAD3C9 /* zstd_common.c */,\n\t\t\t\t75EAB8B02ADA41CD00AAD3C9 /* fse.h */,\n\t\t\t\t75EAB8B12ADA41CD00AAD3C9 /* zstd_internal.h */,\n\t\t\t\t75EAB8B22ADA41CD00AAD3C9 /* bits.h */,\n\t\t\t\t75EAB8B32ADA41CD00AAD3C9 /* allocations.h */,\n\t\t\t\t75EAB8B42ADA41CD00AAD3C9 /* error_private.c */,\n\t\t\t);\n\t\t\tname = common;\n\t\t\tpath = ../zstd/lib/common;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t75EAB8B52ADA41CD00AAD3C9 /* deprecated */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t75EAB8B62ADA41CD00AAD3C9 /* zbuff_common.c */,\n\t\t\t\t75EAB8B72ADA41CD00AAD3C9 /* zbuff_decompress.c */,\n\t\t\t\t75EAB8B82ADA41CD00AAD3C9 /* zbuff.h */,\n\t\t\t\t75EAB8B92ADA41CD00AAD3C9 /* zbuff_compress.c */,\n\t\t\t);\n\t\t\tname = deprecated;\n\t\t\tpath = ../zstd/lib/deprecated;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n/* End PBXGroup section */\n\n/* Begin PBXHeadersBuildPhase section */\n\t\t75EAB7972ADA376000AAD3C9 /* Headers */ = {\n\t\t\tisa = PBXHeadersBuildPhase;\n\t\t\tbuildActionMask = 2147483647;\n\t\t\tfiles = (\n\t\t\t\t75EAB8FA2ADA41CD00AAD3C9 /* allocations.h in Headers */,\n\t\t\t\t75EAB8F22ADA41CD00AAD3C9 /* huf.h in Headers */,\n\t\t\t\t75EAB8E62ADA41CD00AAD3C9 /* pool.h in Headers */,\n\t\t\t\t75EAB8BE2ADA41CD00AAD3C9 /* cover.h in Headers */,\n\t\t\t\t75EAB8EF2ADA41CD00AAD3C9 /* bitstream.h in Headers */,\n\t\t\t\t75EAB8F02ADA41CD00AAD3C9 /* cpu.h in Headers */,\n\t\t\t\t75EAB8EA2ADA41CD00AAD3C9 /* threading.h in Headers */,\n\t\t\t\t75EAB8C52ADA41CD00AAD3C9 /* zstd_lazy.h in Headers */,\n\t\t\t\t75EAB8E42ADA41CD00AAD3C9 /* xxhash.h in Headers */,\n\t\t\t\t75EAB8DA2ADA41CD00AAD3C9 /* zstd_fast.h in Headers */,\n\t\t\t\t75EAB8F82ADA41CD00AAD3C9 /* zstd_internal.h in Headers */,\n\t\t\t\t75EAB8E82ADA41CD00AAD3C9 /* portability_macros.h in Headers */,\n\t\t\t\t75EAB8C22ADA41CD00AAD3C9 /* zstd_ldm.h in Headers */,\n\t\t\t\t75EAB8CD2ADA41CD00AAD3C9 /* zstd_compress_literals.h in Headers */,\n\t\t\t\t75EAB8E52ADA41CD00AAD3C9 /* debug.h in Headers */,\n\t\t\t\t75EAB8F92ADA41CD00AAD3C9 /* bits.h in Headers */,\n\t\t\t\t75EAB8C92ADA41CD00AAD3C9 /* zstd_opt.h in Headers */,\n\t\t\t\t75EAB8E02ADA41CD00AAD3C9 /* zstd_ddict.h in Headers */,\n\t\t\t\t75EAB8BF2ADA41CD00AAD3C9 /* divsufsort.h in Headers */,\n\t\t\t\t75EAB8C02ADA41CD00AAD3C9 /* zstd_compress_internal.h in Headers */,\n\t\t\t\t75EAB86E2ADA3FC300AAD3C9 /* zstd.h in Headers */,\n\t\t\t\t75EAB8D82ADA41CD00AAD3C9 /* zstd_compress_sequences.h in Headers */,\n\t\t\t\t75EAB8F32ADA41CD00AAD3C9 /* zstd_deps.h in Headers */,\n\t\t\t\t75EAB8D32ADA41CD00AAD3C9 /* zstdmt_compress.h in Headers */,\n\t\t\t\t75EAB8F72ADA41CD00AAD3C9 /* fse.h in Headers */,\n\t\t\t\t75EAB8E72ADA41CD00AAD3C9 /* compiler.h in Headers */,\n\t\t\t\t75EAB8C12ADA41CD00AAD3C9 /* hist.h in Headers */,\n\t\t\t\t75EAB8EB2ADA41CD00AAD3C9 /* error_private.h in Headers */,\n\t\t\t\t75EAB8CC2ADA41CD00AAD3C9 /* clevels.h in Headers */,\n\t\t\t\t75EAB8DE2ADA41CD00AAD3C9 /* zstd_decompress_internal.h in Headers */,\n\t\t\t\t75EAB8D42ADA41CD00AAD3C9 /* zstd_compress_superblock.h in Headers */,\n\t\t\t\t75EAB8F42ADA41CD00AAD3C9 /* mem.h in Headers */,\n\t\t\t\t75EAB8D12ADA41CD00AAD3C9 /* zstd_double_fast.h in Headers */,\n\t\t\t\t75EAB8492ADA39C300AAD3C9 /* zdict.h in Headers */,\n\t\t\t\t75EAB8DD2ADA41CD00AAD3C9 /* zstd_decompress_block.h in Headers */,\n\t\t\t\t75EAB8E32ADA41CD00AAD3C9 /* zstd_trace.h in Headers */,\n\t\t\t\t75EAB8C32ADA41CD00AAD3C9 /* zstd_ldm_geartab.h in Headers */,\n\t\t\t\t75EAB8CA2ADA41CD00AAD3C9 /* zstd_cwksp.h in Headers */,\n\t\t\t\t75EAB82F2ADA39C300AAD3C9 /* zstd_errors.h in Headers */,\n\t\t\t);\n\t\t\trunOnlyForDeploymentPostprocessing = 0;\n\t\t};\n/* End PBXHeadersBuildPhase section */\n\n/* Begin PBXNativeTarget section */\n\t\t75EAB79B2ADA376000AAD3C9 /* zstd */ = {\n\t\t\tisa = PBXNativeTarget;\n\t\t\tbuildConfigurationList = 75EAB7A32ADA376000AAD3C9 /* Build configuration list for PBXNativeTarget \"zstd\" */;\n\t\t\tbuildPhases = (\n\t\t\t\t75EAB7972ADA376000AAD3C9 /* Headers */,\n\t\t\t\t75EAB7982ADA376000AAD3C9 /* Sources */,\n\t\t\t\t75EAB7992ADA376000AAD3C9 /* Frameworks */,\n\t\t\t\t75EAB79A2ADA376000AAD3C9 /* Resources */,\n\t\t\t);\n\t\t\tbuildRules = (\n\t\t\t);\n\t\t\tdependencies = (\n\t\t\t);\n\t\t\tname = zstd;\n\t\t\tproductName = zstd;\n\t\t\tproductReference = 75EAB79C2ADA376000AAD3C9 /* zstd.framework */;\n\t\t\tproductType = \"com.apple.product-type.framework\";\n\t\t};\n/* End PBXNativeTarget section */\n\n/* Begin PBXProject section */\n\t\t75EAB7932ADA376000AAD3C9 /* Project object */ = {\n\t\t\tisa = PBXProject;\n\t\t\tattributes = {\n\t\t\t\tBuildIndependentTargetsInParallel = 1;\n\t\t\t\tLastUpgradeCheck = 1410;\n\t\t\t\tTargetAttributes = {\n\t\t\t\t\t75EAB79B2ADA376000AAD3C9 = {\n\t\t\t\t\t\tCreatedOnToolsVersion = 14.1;\n\t\t\t\t\t};\n\t\t\t\t};\n\t\t\t};\n\t\t\tbuildConfigurationList = 75EAB7962ADA376000AAD3C9 /* Build configuration list for PBXProject \"zstd\" */;\n\t\t\tcompatibilityVersion = \"Xcode 14.0\";\n\t\t\tdevelopmentRegion = en;\n\t\t\thasScannedForEncodings = 0;\n\t\t\tknownRegions = (\n\t\t\t\ten,\n\t\t\t\tBase,\n\t\t\t);\n\t\t\tmainGroup = 75EAB7922ADA376000AAD3C9;\n\t\t\tproductRefGroup = 75EAB79D2ADA376000AAD3C9 /* Products */;\n\t\t\tprojectDirPath = \"\";\n\t\t\tprojectRoot = \"\";\n\t\t\ttargets = (\n\t\t\t\t75EAB79B2ADA376000AAD3C9 /* zstd */,\n\t\t\t);\n\t\t};\n/* End PBXProject section */\n\n/* Begin PBXResourcesBuildPhase section */\n\t\t75EAB79A2ADA376000AAD3C9 /* Resources */ = {\n\t\t\tisa = PBXResourcesBuildPhase;\n\t\t\tbuildActionMask = 2147483647;\n\t\t\tfiles = (\n\t\t\t);\n\t\t\trunOnlyForDeploymentPostprocessing = 0;\n\t\t};\n/* End PBXResourcesBuildPhase section */\n\n/* Begin PBXSourcesBuildPhase section */\n\t\t75EAB7982ADA376000AAD3C9 /* Sources */ = {\n\t\t\tisa = PBXSourcesBuildPhase;\n\t\t\tbuildActionMask = 2147483647;\n\t\t\tfiles = (\n\t\t\t\t75EAB8D52ADA41CD00AAD3C9 /* zstd_compress_literals.c in Sources */,\n\t\t\t\t75EAB8C72ADA41CD00AAD3C9 /* zstd_double_fast.c in Sources */,\n\t\t\t\t75EAB8DC2ADA41CD00AAD3C9 /* huf_decompress.c in Sources */,\n\t\t\t\t75EAB8EC2ADA41CD00AAD3C9 /* fse_decompress.c in Sources */,\n\t\t\t\t75EAB8FB2ADA41CD00AAD3C9 /* error_private.c in Sources */,\n\t\t\t\t75EAB8DF2ADA41CD00AAD3C9 /* zstd_decompress.c in Sources */,\n\t\t\t\t75EAB8D72ADA41CD00AAD3C9 /* zstd_opt.c in Sources */,\n\t\t\t\t75EAB8F62ADA41CD00AAD3C9 /* zstd_common.c in Sources */,\n\t\t\t\t75EAB8CF2ADA41CD00AAD3C9 /* hist.c in Sources */,\n\t\t\t\t75EAB8BC2ADA41CD00AAD3C9 /* fastcover.c in Sources */,\n\t\t\t\t75EAB8F12ADA41CD00AAD3C9 /* pool.c in Sources */,\n\t\t\t\t75EAB8CE2ADA41CD00AAD3C9 /* zstd_ldm.c in Sources */,\n\t\t\t\t75EAB8D02ADA41CD00AAD3C9 /* zstd_compress.c in Sources */,\n\t\t\t\t75EAB8D62ADA41CD00AAD3C9 /* huf_compress.c in Sources */,\n\t\t\t\t75EAB8ED2ADA41CD00AAD3C9 /* debug.c in Sources */,\n\t\t\t\t75EAB8CB2ADA41CD00AAD3C9 /* zstd_compress_sequences.c in Sources */,\n\t\t\t\t75EAB8F52ADA41CD00AAD3C9 /* threading.c in Sources */,\n\t\t\t\t75EAB8BB2ADA41CD00AAD3C9 /* divsufsort.c in Sources */,\n\t\t\t\t75EAB8D92ADA41CD00AAD3C9 /* fse_compress.c in Sources */,\n\t\t\t\t75EAB8EE2ADA41CD00AAD3C9 /* xxhash.c in Sources */,\n\t\t\t\t75EAB8E22ADA41CD00AAD3C9 /* zstd_decompress_block.c in Sources */,\n\t\t\t\t75EAB8BD2ADA41CD00AAD3C9 /* zdict.c in Sources */,\n\t\t\t\t75EAB8E92ADA41CD00AAD3C9 /* entropy_common.c in Sources */,\n\t\t\t\t75EAB8C62ADA41CD00AAD3C9 /* zstdmt_compress.c in Sources */,\n\t\t\t\t75EAB8DB2ADA41CD00AAD3C9 /* zstd_ddict.c in Sources */,\n\t\t\t\t75EAB8D22ADA41CD00AAD3C9 /* zstd_lazy.c in Sources */,\n\t\t\t\t75EAB8E12ADA41CD00AAD3C9 /* huf_decompress_amd64.S in Sources */,\n\t\t\t\t75EAB8C42ADA41CD00AAD3C9 /* zstd_compress_superblock.c in Sources */,\n\t\t\t\t75EAB8C82ADA41CD00AAD3C9 /* zstd_fast.c in Sources */,\n\t\t\t\t75EAB8BA2ADA41CD00AAD3C9 /* cover.c in Sources */,\n\t\t\t);\n\t\t\trunOnlyForDeploymentPostprocessing = 0;\n\t\t};\n/* End PBXSourcesBuildPhase section */\n\n/* Begin XCBuildConfiguration section */\n\t\t75EAB7A12ADA376000AAD3C9 /* Debug */ = {\n\t\t\tisa = XCBuildConfiguration;\n\t\t\tbaseConfigurationReference = 0DACF8CB2B2B06FA00CB0710 /* ZstdDebug.xcconfig */;\n\t\t\tbuildSettings = {\n\t\t\t\tMACH_O_TYPE = staticlib;\n\t\t\t};\n\t\t\tname = Debug;\n\t\t};\n\t\t75EAB7A22ADA376000AAD3C9 /* Release */ = {\n\t\t\tisa = XCBuildConfiguration;\n\t\t\tbaseConfigurationReference = 0DACF8CC2B2B06FA00CB0710 /* ZstdRelease.xcconfig */;\n\t\t\tbuildSettings = {\n\t\t\t\tMACH_O_TYPE = staticlib;\n\t\t\t\tONLY_ACTIVE_ARCH = NO;\n\t\t\t};\n\t\t\tname = Release;\n\t\t};\n\t\t75EAB7A42ADA376000AAD3C9 /* Debug */ = {\n\t\t\tisa = XCBuildConfiguration;\n\t\t\tbaseConfigurationReference = 0DACF8CA2B2B06FA00CB0710 /* ZstdBase.xcconfig */;\n\t\t\tbuildSettings = {\n\t\t\t\tCLANG_ENABLE_MODULES = NO;\n\t\t\t\t\"CODE_SIGN_IDENTITY[sdk=macosx*]\" = \"-\";\n\t\t\t\tCODE_SIGN_STYLE = Manual;\n\t\t\t\tDEVELOPMENT_TEAM = \"\";\n\t\t\t\tDYLIB_COMPATIBILITY_VERSION = 1;\n\t\t\t\tDYLIB_CURRENT_VERSION = 1;\n\t\t\t\tDYLIB_INSTALL_NAME_BASE = \"@rpath\";\n\t\t\t\tINSTALL_PATH = \"$(LOCAL_LIBRARY_DIR)/Frameworks\";\n\t\t\t\tLD_RUNPATH_SEARCH_PATHS = (\n\t\t\t\t\t\"$(inherited)\",\n\t\t\t\t\t\"@executable_path/Frameworks\",\n\t\t\t\t\t\"@loader_path/Frameworks\",\n\t\t\t\t);\n\t\t\t\tPROVISIONING_PROFILE_SPECIFIER = \"\";\n\t\t\t\tSKIP_INSTALL = YES;\n\t\t\t\tSUPPORTED_PLATFORMS = \"appletvos appletvsimulator iphoneos iphonesimulator macosx watchos watchsimulator\";\n\t\t\t\tSUPPORTS_MACCATALYST = YES;\n\t\t\t\tSUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = NO;\n\t\t\t\tSWIFT_EMIT_LOC_STRINGS = YES;\n\t\t\t\tTARGETED_DEVICE_FAMILY = \"1,2,3,4\";\n\t\t\t};\n\t\t\tname = Debug;\n\t\t};\n\t\t75EAB7A52ADA376000AAD3C9 /* Release */ = {\n\t\t\tisa = XCBuildConfiguration;\n\t\t\tbaseConfigurationReference = 0DACF8CA2B2B06FA00CB0710 /* ZstdBase.xcconfig */;\n\t\t\tbuildSettings = {\n\t\t\t\tCLANG_ENABLE_MODULES = NO;\n\t\t\t\t\"CODE_SIGN_IDENTITY[sdk=macosx*]\" = \"-\";\n\t\t\t\tCODE_SIGN_STYLE = Manual;\n\t\t\t\tDEVELOPMENT_TEAM = \"\";\n\t\t\t\tDYLIB_COMPATIBILITY_VERSION = 1;\n\t\t\t\tDYLIB_CURRENT_VERSION = 1;\n\t\t\t\tDYLIB_INSTALL_NAME_BASE = \"@rpath\";\n\t\t\t\tGCC_PREPROCESSOR_DEFINITIONS = \"\";\n\t\t\t\tINSTALL_PATH = \"$(LOCAL_LIBRARY_DIR)/Frameworks\";\n\t\t\t\tLD_RUNPATH_SEARCH_PATHS = (\n\t\t\t\t\t\"$(inherited)\",\n\t\t\t\t\t\"@executable_path/Frameworks\",\n\t\t\t\t\t\"@loader_path/Frameworks\",\n\t\t\t\t);\n\t\t\t\tPROVISIONING_PROFILE_SPECIFIER = \"\";\n\t\t\t\tSKIP_INSTALL = YES;\n\t\t\t\tSUPPORTED_PLATFORMS = \"appletvos appletvsimulator iphoneos iphonesimulator macosx watchos watchsimulator\";\n\t\t\t\tSUPPORTS_MACCATALYST = YES;\n\t\t\t\tSUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = NO;\n\t\t\t\tSWIFT_EMIT_LOC_STRINGS = YES;\n\t\t\t\tTARGETED_DEVICE_FAMILY = \"1,2,3,4\";\n\t\t\t};\n\t\t\tname = Release;\n\t\t};\n/* End XCBuildConfiguration section */\n\n/* Begin XCConfigurationList section */\n\t\t75EAB7962ADA376000AAD3C9 /* Build configuration list for PBXProject \"zstd\" */ = {\n\t\t\tisa = XCConfigurationList;\n\t\t\tbuildConfigurations = (\n\t\t\t\t75EAB7A12ADA376000AAD3C9 /* Debug */,\n\t\t\t\t75EAB7A22ADA376000AAD3C9 /* Release */,\n\t\t\t);\n\t\t\tdefaultConfigurationIsVisible = 0;\n\t\t\tdefaultConfigurationName = Release;\n\t\t};\n\t\t75EAB7A32ADA376000AAD3C9 /* Build configuration list for PBXNativeTarget \"zstd\" */ = {\n\t\t\tisa = XCConfigurationList;\n\t\t\tbuildConfigurations = (\n\t\t\t\t75EAB7A42ADA376000AAD3C9 /* Debug */,\n\t\t\t\t75EAB7A52ADA376000AAD3C9 /* Release */,\n\t\t\t);\n\t\t\tdefaultConfigurationIsVisible = 0;\n\t\t\tdefaultConfigurationName = Release;\n\t\t};\n/* End XCConfigurationList section */\n\t};\n\trootObject = 75EAB7932ADA376000AAD3C9 /* Project object */;\n}\n"
  },
  {
    "path": "tools/GetHeaderSearchPath.py",
    "content": "import os\nimport sys\n\ndef has_header_files(path):\n    for entry in os.scandir(path):\n        if entry.is_file() and (entry.name.endswith('.h') or entry.name.endswith('.hpp')):\n            return True\n    return False\n\nif len(sys.argv) != 2:\n    print(\"用法: python script.py <目录路径>\")\n    sys.exit(1)\n\ndirectory_path = sys.argv[1]\n\nfor root, dirs, files in os.walk(directory_path):\n    dirs[:] = [dir for dir in dirs if 'test' not in dir.lower() and 'support' not in dir.lower() and 'java' not in dir.lower() and 'swift' not in dir.lower() and 'xcodeproj' not in dir.lower()]\n    for dir in dirs:\n        dir_path = os.path.join(root, dir)\n        if has_header_files(dir_path):\n            print(os.path.relpath(dir_path, directory_path))"
  },
  {
    "path": "tools/build-depends-android.sh",
    "content": "#!/bin/bash\n\n# Used configurations\nOPENSSL_CONFIG=\"no-rc2 no-cast \\\n  no-md2 no-md4 no-md5 no-ripemd no-mdc2 \\\n  no-rsa no-dsa no-dh no-ec no-ecdsa no-ecdh \\\n  no-sock no-ssl no-tls no-krb5 \\\n  no-shared no-comp no-hw no-engine no-zlib no-fips \\\n  -ffunction-sections -fdata-sections -fvisibility=hidden -Wl,--gc-sections\"\n\nSQLCIPHER_CFLAGS=\"-DSQLITE_DEFAULT_WORKER_THREADS=2 \\\n  -DSQLITE_DEFAULT_JOURNAL_SIZE_LIMIT=1048576 \\\n  -DUSE_PREAD64=1 \\\n  -DSQLITE_ENABLE_FTS3_PARENTHESIS \\\n  -DSQLITE_ENABLE_FTS3_TOKENIZER \\\n  -DSQLITE_ENABLE_STAT4 \\\n  -DSQLITE_ENABLE_EXPLAIN_COMMENTS \\\n  -DSQLITE_ENABLE_DBSTAT_VTAB \\\n  -DSQLITE_HAS_CODEC -DOMIT_MEMLOCK -DOMIT_MEM_SECURITY\"\n\nSQLCIPHER_CONFIG=\"--disable-shared --enable-static \\\n  --enable-fts3 --enable-fts4 --enable-fts5 --enable-json1 --enable-session \\\n  --enable-tempstore=always --enable-threadsafe=multi --disable-tcl\"\n\nUSE_CLANG=1\nBUILD_ARCHS=\"arm,arm64,x86,x86_64\"\nBUILD_API=16\nBUILD_PIE=1\nBUILD_CRYPTO=1\nBUILD_SQLCIPHER=0\n\n###############################\n# Help message\n###############################\nshow_help()\n{\n  cat <<_EOF\nUsage: build-depends-android.sh [OPTIONS]\n\nOPTIONS:\n    -h            Show this help message.\n    -n <path>     Specify Android NDK installation path.\n                  If this option is omitted, use ANDROID_NDK_ROOT environment variable.\n    -a <archs>    Comma separated architectures to build. Default to \"arm,arm64,x86,x86_64\"\n    -i <number>   API level to build. Default to 14.\n    -e            Do not build position-independent executables.\n    -g            Uses GCC toolchains.\n    -G            Uses clang toolchains. This is the default.\n    -c            Do not build libcrypto.\n    -s            Build SQLCipher library and executables.\n\n_EOF\n}\n\n# Parse arguments.\n#argv=`getopt -o 'h' -l 'help,ndk:,arch:,api:,clang,gcc,no-pie,no-crypto,build-sqlcipher' -- \"$@\"`\n#[ $? != 0 ] && exit 1\n\n#eval set -- \"$argv\"\n\nwhile getopts ':hn:a:i:egGcs' arg; do\n  case \"$arg\" in\n    h) show_help; exit 1 ;;\n    n) ANDROID_NDK_ROOT=\"$OPTARG\";;\n    a) BUILD_ARCHS=\"$OPTARG\";;\n    i) BUILD_API=\"$OPTARG\";;\n    G) USE_CLANG=1;;\n    g) USE_CLANG=0;;\n    e) BUILD_PIE=0;;\n    c) BUILD_CRYPTO=0;;\n    s) BUILD_SQLCIPHER=1;;\n    *) echo \"Unreconized option: $arg\"; exit 1 ;;\n  esac\ndone\n\n\n# Locate Android NDK\nif [ -z \"$ANDROID_NDK_ROOT\" ] || [ ! -d \"$ANDROID_NDK_ROOT\" ]; then\n  echo \"Error: ANDROID_NDK_ROOT is not a valid path.\"\n  echo 'Set Android NDK location using `export ANDROID_NDK_ROOT=/path/to/ndk`'\n  exit 1\nfi\necho \" * Android NDK location: $ANDROID_NDK_ROOT\"\n\n# NDK must have GCC 4.9 toolchains for arm, arm64 and x86 platform.\nif [ ! -d \"$ANDROID_NDK_ROOT/toolchains/arm-linux-androideabi-4.9\" ] || \\\n    [ ! -d \"$ANDROID_NDK_ROOT/toolchains/aarch64-linux-android-4.9\" ] || \\\n    [ ! -d \"$ANDROID_NDK_ROOT/toolchains/x86-4.9\" ]; then\n  echo \"NDK must have GCC 4.9 toolchains for arm, arm64 and x86 platform.\"\n  echo \"Google and download the latest one.\"\n  exit 1\nfi\n\n# Detect NDK host\nndk_host=\"\"\nfor host in \"windows-x86_64\" \"windows-x86\" \"linux-x86_64\" \"linux-x86\" \"darwin-x86_64\"\ndo\n  if [ -d \"$ANDROID_NDK_ROOT/toolchains/arm-linux-androideabi-4.9/prebuilt/$host/bin\" ]; then\n    ndk_host=$host\n    break\n  fi\ndone\n\n# Fix API level and architectures\ncase \"$BUILD_API\" in\n  [0-9]|1[0-5]) BUILD_API=16 ;;\n  20) BUILD_API=19 ;;\n  22) BUILD_API=21 ;;\n  25) BUILD_API=24 ;;\n  [0-9][0-9]) ;;\n  *) BUILD_API=16 ;;\nesac\n[ \"$BUILD_API\" -gt 28 ] && BUILD_API=28\nBUILD_ARCHS=${BUILD_ARCHS//,/ }\n\n# Check dependency sources\nsource_root=$(dirname \"${BASH_SOURCE[0]}\")\nif [ ! -d \"$source_root/openssl\" ] || [ ! -d \"$source_root/sqlcipher\" ]; then\n  echo \"Error: Submodule directories don't exist. Try git submodule update --init\"\n  exit 1\nfi\n\n# Print build options\ncat <<_EOF\nNDK root: ${ANDROID_NDK_ROOT}\nBuild architectures: ${BUILD_ARCHS}\nBuild API level: ${BUILD_API}\nBuild PIE: $([ \"$BUILD_PIE\" == 1 ] && echo 'yes' || echo 'no')\nToolchain: $([ \"$USE_CLANG\" == 1 ] && echo 'clang' || echo 'GCC')\n\n_EOF\n\n# Save current directory\npushd \"$source_root\" >/dev/null 2>&1\n\n# Determine position-independent executable flags\n[ \"$BUILD_PIE\" == 1 ] && android_pie='-fPIE -pie' || android_pie=\n\n# Patch OpenSSL\ncat patch/openssl/*.patch | patch -p1 -R -dopenssl --dry-run > /dev/null\nif [ $? != 0 ]; then \n  cat patch/openssl/*.patch | patch -p1 -N -dopenssl || exit 1\nfi\n\nsqlite3_headers_generated=0\n\nfor android_arch in $BUILD_ARCHS; do\n  echo \"###########################################\"\n  echo \"# Building for architecture: $android_arch \"\n  echo \"###########################################\"\n\n  # Setup current architecture\n  case \"$android_arch\" in\n    arm)\n      android_eabi=arm-linux-androideabi\n      gcc_prefix=arm-linux-androideabi\n      clang_target=arm-none-linux-androideabi\n      android_api=16\n      android_cflags=\"-Os -fpic -mthumb -march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3-d16\"\n      openssl_conf=\"linux-armv4\"\n      ;;\n    arm64)\n      android_eabi=aarch64-linux-android\n      gcc_prefix=aarch64-linux-android\n      clang_target=aarch64-none-linux-android\n      android_api=21\n      android_cflags=\"-O2 -fpic\"\n      openssl_conf=\"linux-aarch64\"\n      ;;\n    x86)\n      android_eabi=x86\n      gcc_prefix=i686-linux-android\n      clang_target=i686-none-linux-android\n      android_api=16\n      android_cflags=\"-O2 -fPIC\"\n      openssl_conf=\"linux-elf\"\n      ;;\n    x86_64)\n      android_eabi=x86_64\n      gcc_prefix=x86_64-linux-android\n      clang_target=x86_64-none-linux-android\n      android_api=21\n      android_cflags=\"-O2 -fPIC\"\n      openssl_conf=\"linux-x86_64\"\n      ;;\n    *)\n      echo \"Unsupported architecture: $android_arch\"\n      exit 1\n      ;;\n  esac\n\n  [ \"$BUILD_API\" -gt \"$android_api\" ] && android_api=\"$BUILD_API\"\n  android_sysroot=\"$ANDROID_NDK_ROOT/platforms/android-$android_api/arch-$android_arch\"\n  # If deprecated headers don't exist, uses unified headers\n  if [ ! -d \"$android_sysroot/usr/include\" ]; then\n    android_sysroot=\"$android_sysroot -isystem $ANDROID_NDK_ROOT/sysroot/usr/include\"\n    android_sysroot=\"$android_sysroot -isystem $ANDROID_NDK_ROOT/sysroot/usr/include/$gcc_prefix\"\n  fi\n\n  android_cc=\"$gcc_prefix-gcc --sysroot=$android_sysroot\"\n  android_cflags=\"$android_cflags -g -Wall -funwind-tables -fstack-protector -fomit-frame-pointer -DNDEBUG -DANDROID -D__ANDROID_API__=$android_api\"\n  android_path=\"$ANDROID_NDK_ROOT/toolchains/$android_eabi-4.9/prebuilt/$ndk_host/bin:$ANDROID_NDK_ROOT/prebuilt/$ndk_host/bin\"\n  android_prefix=\"$(pwd)/prebuilt/android/$android_arch\"\n  \n  if [ \"$USE_CLANG\" == 1 ]; then\n    android_cc=\"clang -target $clang_target -gcc-toolchain $ANDROID_NDK_ROOT/toolchains/$android_eabi-4.9/prebuilt/$ndk_host --sysroot=$android_sysroot\"\n    android_cflags=\"-fno-integrated-as $android_cflags\"\n    android_path=\"$ANDROID_NDK_ROOT/toolchains/llvm/prebuilt/$ndk_host/bin:$android_path\"\n  fi\n\n  # Export Android toolchain to PATH\n  original_path=\"$PATH\"\n  export PATH=\"$android_path\":\"$PATH\"\n\n  # Build and install libcrypto\n  if [ \"$BUILD_CRYPTO\" == 1 ]; then\n    cd openssl\n    [ -f 'Makefile' ] && make clean\n    CC=\"$android_cc\" \\\n    AR=\"$gcc_prefix-ar\" \\\n    RANLIB=\"$gcc_prefix-ranlib\" \\\n    ./Configure $openssl_conf $android_cflags $OPENSSL_CONFIG \\\n      --openssldir=\"$android_prefix\" || exit 1\n    # Edit generated Makefile\n    sed -i -e \\\n      '/^CFLAG=/ s/ \\+-O[0-3s] \\+/ /2; /^MAKEDEPPROG=/ s/^MAKEDEPPROG=.*$/MAKEDEPPROG=$(CC)/; /^DIRS=/ s/^DIRS=.*$/DIRS= crypto/' \\\n      Makefile\n    make depend -j4 || exit 1\n    make build_crypto libcrypto.pc libssl.pc openssl.pc -j4 || exit 1\n    make install_sw || exit 1\n    make clean dclean || exit 1\n    cd ..\n  fi\n\n  # Build and install sqlcipher\n  if [ \"$BUILD_SQLCIPHER\" == 1 -o \"$sqlite3_headers_generated\" == 0 ]; then\n    cd sqlcipher\n    [ -f 'Makefile' ] && make distclean\n    CC=\"$android_cc\" \\\n    CFLAGS=\"-I$android_prefix/include $android_cflags $SQLCIPHER_CFLAGS\" \\\n    LDFLAGS=\"-L$android_prefix/lib $SQLCIPHER_LDFLAGS $android_pie\" \\\n    ./configure --host=\"$gcc_prefix\" --prefix=\"$android_prefix\" $SQLCIPHER_CONFIG || exit 1\n    \n    # Generate sqlite3.c/.h\n    if [ \"$sqlite3_headers_generated\" == 0 ]; then\n      make sqlite3.h sqlite3.c || exit 1\n      cp sqlite3.h sqlite3.c sqlite3ext.h sqlite3session.h src/sqlcipher.h ../android/sqlcipher/ || exit 1\n      sqlite3_headers_generated=1\n    fi\n\n    if [ \"$BUILD_SQLCIPHER\" == 1 ]; then\n      make all install || exit 1\n    fi\n\n    make distclean || exit 1\n    cd ..\n  fi\n\n  # Recover original PATH\n  export PATH=\"$original_path\"\n  \ndone\n\n# Recover saved directory\npopd >/dev/null 2>&1\nexit 0\n"
  },
  {
    "path": "tools/createHeaderLink.sh",
    "content": "#!/bin/bash\n\n# 检查是否提供了足够的命令行参数\nif [ $# -lt 3 ]; then\n    echo \"Usage: $0 target_directory base_directory patterns_file\"\n    exit 1\nfi\n\n# 使用符号链接的目标目录\ntarget_dir=\"$1\"\n\n# 基础路径\nbase_directory=\"$2\"\n\n# 从文件中读取路径模式\npatterns_file=\"$3\"\npath_patterns=()\nwhile IFS= read -r line || [[ -n \"$line\" ]]; do\n    # 使用正则表达式匹配引号中的内容，如果没有引号则匹配整行内容\n    if [[ $line =~ \\\"([^\\\"]*)\\\" ]]; then\n        pattern=\"${BASH_REMATCH[1]}\"\n    else\n        pattern=\"$line\"\n    fi\n    path_patterns+=(\"$pattern\")\ndone < \"$patterns_file\"\n\n# 初始化头文件数组\nheader_files=()\n\n# 使用 find 命令查找匹配的路径模式，并将它们添加到数组中\nfor pattern in \"${path_patterns[@]}\"; do\n    files=()\n    if [[ $pattern == *\"*\"* ]]; then\n        # 如果路径模式包含通配符，处理 {h,hpp} 部分\n        if [[ $pattern == *\\{*\\}* ]]; then\n            prefix=\"${pattern%%\\{*\\}}\"\n            suffixes=\"${pattern#*\\{}\"\n            suffixes=\"${suffixes%%\\}*}\"\n            suffixes=(${suffixes//,/ })\n            postfix=\"${pattern#*\\}}\"\n            for suffix in \"${suffixes[@]}\"; do\n                new_pattern=\"${prefix}${suffix}${postfix}\"\n                while IFS= read -r -d '' file; do\n                    # 跳过在 target_dir 中的文件\n                    if [[ ! $file =~ ^$target_dir ]]; then\n                        files+=(\"$file\")\n                    fi\n                done < <(find -L \"$base_directory\" -type f -path \"${base_directory}/${new_pattern}\" -print0)\n            done\n        else\n            while IFS= read -r -d '' file; do\n                # 跳过在 target_dir 中的文件\n                if [[ ! $file =~ ^$target_dir ]]; then\n                    files+=(\"$file\")\n                fi\n            done < <(find -L \"$base_directory\" -type f -path \"${base_directory}/${pattern}\" -print0)\n        fi\n    else\n        # 如果路径模式不包含通配符，直接查找文件\n        file=\"$base_directory/$pattern\"\n        if [[ -f $file && ! $file =~ ^$target_dir ]]; then\n            files+=(\"$file\")\n        fi\n    fi\n    if [ ${#files[@]} -eq 0 ]; then\n        echo \"No files found for pattern: $pattern\"\n    else\n        header_files+=(\"${files[@]}\")\n    fi\ndone\n\n# 清空 target_dir 中的文件\nrm -rf \"$target_dir\"/*\nmkdir -p \"$target_dir\"\n\n# 为数组中的每个头文件创建符号链接\nfor file in \"${header_files[@]}\"; do\n    # 获取文件的基本名（不包含路径）\n    base=$(basename \"$file\")\n    # 使用 Python3 计算相对路径\n    relative_path=$(python3 -c \"import os.path; print(os.path.relpath('$file', '$target_dir'))\")\n    # 创建符号链接\n    ln -s \"$relative_path\" \"$target_dir/$base\"\ndone"
  },
  {
    "path": "tools/dbbackup.c",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n \n#include <sqlite3.h>\n#include \"../mm_backup.h\"\n#include <stdio.h>\n#include <string.h>\n#include <stdlib.h>\n#include <getopt.h>\n\n\n#define DBBAK_OP_BACKUP\t\t1\n#define DBBAK_OP_RECOVER\t2\n\nstatic int g_verbose = 0;\nstatic int g_operation = 0;\nstatic uint32_t g_flags = 0;\nstatic const char *g_db_path = NULL;\nstatic const char *g_dump_path = NULL;\nstatic const uint8_t *g_key = NULL;\nstatic const uint8_t *g_dbkey = NULL;\nstatic const char *g_tabdesc_path = NULL;\nstatic char *g_tabdesc_buffer = NULL;\nstatic mm_backup_tabdesc *g_tabdesc = NULL;\nstatic int g_num_tabdesc = 0;\n\n\nextern void sqlcipher_set_default_kdf_iter(int iter);\nextern void sqlcipher_set_default_use_hmac(int use);\nextern void sqlcipher_set_default_pagesize(int page_size);\n\n\nstatic const struct option g_options[] =\n{\n\t{\"verbose\",\t\t\tno_argument,\t\tNULL, 'v'},\n\t{\"compress\",\t\tno_argument,\t\tNULL, 'z'},\n\t{\"no-compress\",\t\tno_argument,\t\tNULL, 'Z'},\n\t{\"fix\",\t\t\t\tno_argument, \t\tNULL, 'f'},\n\t{\"no-fix\",\t\t\tno_argument,\t\tNULL, 'F'},\n\t{\"create-table\",\t    no_argument, \t\tNULL, 't'},\n\t{\"no-create-table\",\tno_argument, \t\tNULL, 'T'},\n\t{\"incremental\",\t\tno_argument, \t\tNULL, 'i'},\n\t{\"output\",\t\t\trequired_argument, \tNULL, 'o'},\n\t{\"tabdesc\",\t\t\trequired_argument,\tNULL, 'd'},\n\t{\"dbkey\",\t\t\trequired_argument,\tNULL, 'K'},\n\t{\"key\",\t\t\t\trequired_argument,\tNULL, 'k'},\n\t{\"version\",\t\t\trequired_argument,\tNULL, 0x100},\n\t{\"page-size\",\t\trequired_argument,\tNULL, 0x101},\n};\n\n\nstatic void usage(const char *argv0)\n{\n\tprintf(\"USAGE: %s <backup|recover> <db_path> <dump_path> <passwd> [encrypt]\\n\",\n\t\t\targv0);\n\texit(1);\n}\n\nstatic void print_log(int prio, const char *msg)\n{\n\tfputs(msg, stderr);\n\tfputc('\\n', stderr);\n}\n\nstatic void parse_options(int argc, char *argv[])\n{\n\tint opt;\n\tint value;\n\t\n\t// parse operation\n\tif (argc < 2) usage(argv[0]);\n\t\n\tconst char *opstr = argv[1];\n\tif (!strcmp(opstr, \"backup\"))\n\t\tg_operation = DBBAK_OP_BACKUP;\n\telse if (!strcmp(opstr, \"recover\"))\n\t\tg_operation = DBBAK_OP_RECOVER;\n\telse usage(argv[0]);\n\n\t// default to SQLCipher version 1, thanks to kkdb.\n\tsqlcipher_set_default_kdf_iter(4000);\n\tsqlcipher_set_default_use_hmac(0);\n\t\n\t// parse options\n\toptind = 2;\n\twhile ((opt = getopt_long(argc, argv, \"vzZfFtTio:d:K:k:\", g_options, NULL)) != -1)\n\t{\n\t\tswitch (opt)\n\t\t{\n\t\tcase 'v':\t// verbose\n\t\t\tg_verbose = 1;\n\t\t\tbreak;\n\t\tcase 'z':\t// compress\n\t\t\tg_flags &= (~MMBAK_FLAG_NO_COMPRESS);\n\t\t\tbreak;\n\t\tcase 'Z':\t// no-compress\n\t\t\tg_flags |= MMBAK_FLAG_NO_COMPRESS;\n\t\t\tbreak;\n\t\tcase 'f':\t// fix\n\t\t\tg_flags |= MMBAK_FLAG_FIX_CORRUPTION;\n\t\t\tbreak;\n\t\tcase 'F':\t// no-fix\n\t\t\tg_flags &= (~MMBAK_FLAG_FIX_CORRUPTION);\n\t\t\tbreak;\n\t\tcase 't':\t// create-table\n\t\t\tg_flags &= (~MMBAK_FLAG_NO_CREATE_TABLE);\n\t\t\tbreak;\n\t\tcase 'T':\t// no-create-table\n\t\t\tg_flags |= MMBAK_FLAG_NO_CREATE_TABLE;\n\t\t\tbreak;\n\t\tcase 'i':\t// incremental\n\t\t\tg_flags |= MMBAK_FLAG_INCREMENTAL;\n\t\t\tbreak;\n\t\tcase 'o':\t// output\n\t\t\tg_dump_path = optarg;\n\t\t\tbreak;\n\t\tcase 'd':\t// tabdesc\n\t\t\tg_tabdesc_path = optarg;\n\t\t\tbreak;\n\t\tcase 'K':\t// dbkey\n\t\t\tg_dbkey = optarg;\n\t\t\tbreak;\n\t\tcase 'k':\t// key\n\t\t\tg_key = optarg;\n\t\t\tbreak;\n\t\tcase 0x100:\t// version\n\t\t\tvalue = atoi(optarg);\n\t\t\tif (value == 1)\n\t\t\t{\n\t\t\t\tsqlcipher_set_default_kdf_iter(4000);\n\t\t\t\tsqlcipher_set_default_use_hmac(0);\n\t\t\t}\n\t\t\telse if (value == 2)\n\t\t\t{\n\t\t\t\tsqlcipher_set_default_kdf_iter(4000);\n\t\t\t\tsqlcipher_set_default_use_hmac(1);\n\t\t\t}\n\t\t\telse if (value == 3)\n\t\t\t{\n\t\t\t\tsqlcipher_set_default_kdf_iter(64000);\n\t\t\t\tsqlcipher_set_default_use_hmac(1);\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tprint_log(MMBAK_LOG_ERROR, \"Version must be 1, 2 or 3\");\n\t\t\t\texit(-1);\n\t\t\t}\n\t\t\tbreak;\n\t\tcase 0x101:\t// page-size\n\t\t\tvalue = atoi(optarg);\n\t\t\tif (value != 512 && value != 1024 && value != 2048 && value != 4096 &&\n\t\t\t\t\tvalue != 8192 && value != 16384 && value != 32768 && value != 65536)\n\t\t\t{\n\t\t\t\tprint_log(MMBAK_LOG_ERROR, \"Page size must be 512, 1024, 2048, ..., 65536\");\n\t\t\t\texit(-1);\n\t\t\t}\n\t\t\tsqlcipher_set_default_pagesize(value);\n\t\t\tbreak;\n\t\tdefault:\t// ?\n\t\t\tusage(argv[0]);\n\t\t}\n\t}\n\t\n\tif (optind != argc - 1) \t// no database path\n\t\tusage(argv[0]);\n\tg_db_path = argv[optind++];\n\t\n\tif (!g_dump_path)\n\t{\n\t\tprint_log(MMBAK_LOG_ERROR, \"Output path must be specified.\");\n\t\tusage(argv[0]);\n\t}\n\t\n\tif (g_key == NULL)\n\t\tg_flags |= MMBAK_FLAG_NO_CIPHER;\n}\n\nstatic void parse_tabdesc(const char *path)\n{\n\tFILE *fp = fopen(path, \"r\");\n\tif (!fp) goto bail;\n\t\n\t// get file length\n\tfseek(fp, 0, SEEK_END);\n\tlong file_len = ftell(fp) + 1;\n\tfseek(fp, 0, SEEK_SET);\n\t\n\t// read whole file into buffer\n\tg_tabdesc_buffer = (char *) malloc(file_len);\n\tif (!g_tabdesc_buffer) goto bail;\n\tchar *p = g_tabdesc_buffer;\n\tint count = 0;\n\twhile (!feof(fp) && !ferror(fp) && p - g_tabdesc_buffer < file_len)\n\t{\n\t\tchar *ret = fgets(p, g_tabdesc_buffer + file_len - p, fp);\n\t\tif (ret)\n\t\t{\n\t\t\tcount++;\n\t\t\tchar c;\n\t\t\twhile (c = *p++)\n\t\t\t{\n\t\t\t\tif (c == '\\n')\n\t\t\t\t{\n\t\t\t\t\t*(p - 1) = '\\0';\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tfclose(fp);\n\tfp = NULL;\n\t\n\t// translate strings to tabdesc\n\tg_tabdesc = (mm_backup_tabdesc *) calloc(count, sizeof(mm_backup_tabdesc));\n\tif (!g_tabdesc) goto bail;\n\t\n\tp = g_tabdesc_buffer;\n\t\n\tint i;\n\tfor (i = 0; i < count; i++)\n\t{\n\t\tg_tabdesc[i].table = p;\n\t\tchar c;\n\t\twhile (c = *p++)\n\t\t{\n\t\t\tif (c == '|')\n\t\t\t{\n\t\t\t\t*(p - 1) = '\\0';\n\t\t\t\tg_tabdesc[i].condition = p;\n\t\t\t}\n\t\t}\n\t}\n\tg_num_tabdesc = count;\n\treturn;\n\t\t\nbail:\n\tprint_log(MMBAK_LOG_ERROR, \"Cannot parse table descriptor.\");\n\tif (fp) fclose(fp);\n\texit(1);\n}\n\nint main(int argc, char *argv[])\n{\n\tint ret;\n\tsqlite3 *db;\n\t\n\tparse_options(argc, argv);\n\tif (g_tabdesc_path) parse_tabdesc(g_tabdesc_path);\n\t\n\tint key_len = g_key ? strlen(g_key) : 0;\n\t\n\tret = sqlite3_open(g_db_path, &db);\n\tif (ret != SQLITE_OK) return -3;\n\t\n\tif (g_dbkey)\n\t\tsqlite3_key(db, g_dbkey, strlen(g_dbkey));\n\t\n\tif (g_operation == DBBAK_OP_BACKUP)\n\t{\n\t\tmm_backup_ctx *ctx = mm_backup_init((const uint8_t *) g_key, key_len, g_dump_path,\n\t\t\t\tg_flags, print_log);\n\t\tif (!ctx) return -2;\n\t\t\n\t\tret = mm_backup_run(ctx, db, g_tabdesc, g_num_tabdesc);\n\t\tif (ret != 0) return -4;\n\t\t\n\t\tmm_backup_finish(ctx);\n\t}\n\telse if (g_operation == DBBAK_OP_RECOVER)\n\t{\n\t\tmm_recover_ctx *ctx = mm_recover_init(g_dump_path, (const uint8_t *) g_key, key_len, print_log);\n\t\tif (!ctx) return -2;\n\t\t\n\t\tret = mm_recover_run(ctx, db, 1);\n\t\tif (ret != 0) return -4;\n\t\t\n\t\tmm_recover_finish(ctx);\n\t}\n\telse usage(argv[0]);\n\t\n\tfree(g_tabdesc_buffer);\n\tfree(g_tabdesc);\n\t\n\tsqlite3_close(db);\n\treturn 0;\n}\n"
  },
  {
    "path": "tools/dbrepair.c",
    "content": "/*\n * Tencent is pleased to support the open source community by making\n * WCDB available.\n *\n * Copyright (C) 2017 THL A29 Limited, a Tencent company.\n * All rights reserved.\n *\n * Licensed under the BSD 3-Clause License (the \"License\"); you may not use\n * this file except in compliance with the License. You may obtain a copy of\n * the License at\n *\n *       https://opensource.org/licenses/BSD-3-Clause\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n#include <SQLiteRepairKit.h>\n#include <sqlite3.h>\n#include <stdio.h>\n#include <string.h>\n#include <getopt.h>\n\nstatic char g_verbose = 0;\nstatic const char *g_in_path = NULL;\nstatic const char *g_out_path = NULL;\nstatic const char *g_out_key = NULL;\nstatic const char *g_save_master = NULL;\nstatic const char *g_load_master = NULL;\nstatic sqliterk_cipher_conf g_cipher_conf = {0};\nstatic const char **g_filter = NULL;\nstatic size_t g_num_filter = 0;\nstatic size_t g_filter_capacity = 0;\n\n\nextern void sqlcipher_set_default_kdf_iter(int iter);\nextern void sqlcipher_set_default_use_hmac(int use);\nextern void sqlcipher_set_default_pagesize(int page_size);\nextern int sqlcipher_set_default_hmac_algorithm(int algorithm);\nextern int sqlcipher_set_default_kdf_algorithm(int algorithm);\n\n\nstatic const struct option g_options[] =\n{\n    {\"help\",            no_argument,        NULL, 'h'},\n\t{\"verbose\",\t\t\tno_argument,\t\tNULL, 'v'},\n\t{\"output\",\t\t\trequired_argument, \tNULL, 'o'},\n\t{\"out-key\",\t\t\trequired_argument,\tNULL, 'K'},\n\t{\"in-key\",\t\t\trequired_argument,\tNULL, 'k'},\n\t{\"version\",\t\t\trequired_argument,\tNULL, 0x100},\n\t{\"page-size\",\t\trequired_argument,\tNULL, 0x101},\n\t{\"save-master\",\t\trequired_argument,\tNULL, 'M'},\n\t{\"load-master\",\t\trequired_argument,\tNULL, 'm'},\n\t{\"filter\",\t\t\trequired_argument,\tNULL, 'f'},\n};\n\n\nstatic void usage(const char *argv0)\n{\n\tprintf(\"USAGE:\\n\"\n\t\t\"  %1$s --output=<output_path> [OPTIONS] <db_path>\\n\"\n\t\t\"  %1$s --save-master=<master_path> [OPTIONS] <db_path>\\n\",\n\t\targv0);\n\tputs(\"\\n\"\n\t\"OUTPUT OPTIONS:\\n\"\n\t\"  -o, --output=<path>        Output recovered data to new SQLite database.\\n\"\n\t\"  -m, --load-master=<path>   Load previously saved master info from <path>.\\n\"\n\t\"  -M, --save-master=<path>   Save master info and do no recover.\\n\"\n\t\"                             <db_path> should be database that's not corrupted.\\n\"\n\t\"  -f, --filter=<table>       Add <table> to the filter. If one or more table is in the\\n\"\n\t\"                             filter, only filtered tables is read and recovered.\\n\"\n\t\"\\n\"\n\t\"CIPHER OPTIONS:\\n\"\n\t\"  -k, --in-key=<key>         Specify the input key used to read database in <db_path>.\\n\"\n\t\"  -K, --out-key=<key>        Specify the output key used to write '--output' database.\\n\"\n\t\"      --page-size=<size>     Specify page size of the encrypted input database.\\n\"\n\t\"      --version=<1|2|3>      Use SQLCipher format version 1.x, 2.x or 3.x.\\n\"\n\t\"\\n\"\n    \"MISCELLANEOUS OPTIONS:\\n\"\n    \"  -h, --help                 Show this help message and exit.\\n\"\n    \"\\n\");\n\texit(1);\n}\n\nstatic void print_log(sqliterk_loglevel level, int result, const char* msg)\n{\n\tfputs(msg, stderr);\n\tfputc('\\n', stderr);\n}\n\nstatic void inline LOGI(const char *msg)\n{\n\tprint_log(sqliterk_loglevel_info, SQLITERK_OK, msg);\n}\n\nstatic void parse_options(int argc, char *argv[])\n{\n\tint opt;\n\tint value;\n\t\n\tif (argc < 2) usage(argv[0]);\n\n\t// default to SQLCipher version 1, for compatibility to KKDB.\n\tsqlcipher_set_default_kdf_iter(4000);\n\tsqlcipher_set_default_use_hmac(0);\n\tsqlcipher_set_default_hmac_algorithm(0);\n\tsqlcipher_set_default_kdf_algorithm(0);\n\t\n\tg_cipher_conf.use_hmac = -1;\n\n\t// parse options\n\toptind = 1;\n\twhile ((opt = getopt_long(argc, argv, \"hvo:K:k:M:m:\", g_options, NULL)) != -1)\n\t{\n\t\tswitch (opt)\n\t\t{\n        case 'h':   // help\n            usage(argv[0]);\n            break;\n\t\tcase 'v':\t// verbose\n\t\t\tg_verbose = 1;\n\t\t\tbreak;\n\t\tcase 'o':\t// output\n\t\t\tg_out_path = optarg;\n\t\t\tbreak;\n\t\tcase 'K':\t// out-key\n\t\t\tg_out_key = optarg;\n\t\t\tbreak;\n\t\tcase 'k':\t// in-key\n\t\t\tg_cipher_conf.key = optarg;\n\t\t\tg_cipher_conf.key_len = strlen(optarg);\n\t\t\tbreak;\n\t\tcase 'f':\t// filter\n\t\t\tif (g_num_filter == g_filter_capacity)\n\t\t\t{\n\t\t\t\tsize_t sz = g_filter_capacity ? g_filter_capacity * 2 : 64;\n\t\t\t\tvoid *ptr = realloc(g_filter, sz * sizeof(const char *));\n\t\t\t\tif (!ptr) exit(-5);\n\t\t\t\tg_filter = (const char **) ptr;\n\t\t\t\tg_filter_capacity = sz;\n\t\t\t}\n\t\t\tg_filter[g_num_filter++] = optarg;\n\t\t\tbreak;\n\t\tcase 'M':\t// save-master\n\t\t\tg_save_master = optarg;\n\t\t\tbreak;\n\t\tcase 'm':\t// load-master\n\t\t\tg_load_master = optarg;\n\t\t\tbreak;\n\t\tcase 0x100:\t// version\n\t\t\tvalue = atoi(optarg);\n\t\t\tif (value == 1)\n\t\t\t{\n\t\t\t\tsqlcipher_set_default_kdf_iter(4000);\n\t\t\t\tsqlcipher_set_default_use_hmac(0);\n\t\t\t}\n\t\t\telse if (value == 2)\n\t\t\t{\n\t\t\t\tsqlcipher_set_default_kdf_iter(4000);\n\t\t\t\tsqlcipher_set_default_use_hmac(1);\n\t\t\t}\n\t\t\telse if (value == 3)\n\t\t\t{\n\t\t\t\tsqlcipher_set_default_kdf_iter(64000);\n\t\t\t\tsqlcipher_set_default_use_hmac(1);\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tLOGI(\"Version must be 1, 2 or 3\");\n\t\t\t\texit(-1);\n\t\t\t}\n\t\t\tbreak;\n\t\tcase 0x101:\t// page-size\n\t\t\tvalue = atoi(optarg);\n\t\t\tif (value != 512 && value != 1024 && value != 2048 && value != 4096 &&\n\t\t\t\t\tvalue != 8192 && value != 16384 && value != 32768 && value != 65536)\n\t\t\t{\n\t\t\t\tLOGI(\"Page size must be 512, 1024, 2048, ..., or 65536\");\n\t\t\t\texit(-1);\n\t\t\t}\n            sqlcipher_set_default_pagesize(value);\n\t\t\tbreak;\n        default:    // ?\n            usage(argv[0]);\n\t\t}\n\t}\n\t\n\tif (optind != argc - 1) \t// no database path\n\t\tusage(argv[0]);\n\tg_in_path = argv[optind++];\n\t\n\tif (g_save_master && (g_load_master || g_out_path))\n\t{\n\t\tLOGI(\"--save-master must be used without --load-master or --output.\");\n\t\tusage(argv[0]);\n\t}\n\n\tif (!g_out_path && !g_save_master)\n\t{\n\t\tLOGI(\"Output path must be specified.\");\n\t\tusage(argv[0]);\n\t}\n}\n\nstatic uint8_t MASTER_KEY[] = { 0xdc, 0x1c, 0xbb, 0x92, 0xa1, 0xb1, 0xcb, 0x5b, \n\t0x06, 0x5b, 0xf0, 0x5e, 0x05, 0x0e, 0xd9, 0x36 };\n\nint main(int argc, char *argv[])\n{\n\tint ret;\n\tsqlite3 *db;\n\tsqliterk *rk;\n\t\n    sqliterk_os reg = { print_log };\n    sqliterk_register(reg);\n\n\tparse_options(argc, argv);\n\t\n\tif (g_save_master)\n\t{\n\t\tret = sqlite3_open(g_in_path, &db);\n\t\tif (ret != SQLITE_OK) return -3;\n\t\tif (g_cipher_conf.key)\n\t\t\tsqlite3_key(db, g_cipher_conf.key, g_cipher_conf.key_len);\n\n\t\tint out_key_len = g_out_key ? strlen(g_out_key) : 0;\n\t\tret = sqliterk_save_master(db, g_save_master, NULL, 0);\n\t\t\n\t\tsqlite3_close(db);\n\t\treturn (ret == SQLITERK_OK) ? 0 : -4;\n\t}\n\telse\n\t{\n\t\tsqliterk_master_info *master = NULL;\n\t\tunsigned char salt[16];\n\t\tif (g_load_master)\n\t\t{\n\t\t\tret = sqliterk_load_master(g_load_master, MASTER_KEY, sizeof(MASTER_KEY), g_filter, g_num_filter,\n\t\t\t\t&master, salt);\n\t\t\tg_cipher_conf.kdf_salt = salt;\n\t\t}\n\t\telse\n\t\t\tret = sqliterk_make_master(g_filter, g_num_filter, &master);\n\t\tif (ret != SQLITERK_OK) return -6;\n\n\t\tret = sqliterk_open(g_in_path, g_cipher_conf.key ? &g_cipher_conf : NULL, &rk);\n\t\tif (ret != SQLITERK_OK) return -3;\n\n\t\tret = sqlite3_open(g_out_path, &db);\n\t\tif (ret != SQLITE_OK) return -3;\n\t\tif (g_out_key)\n\t\t\tsqlite3_key(db, g_out_key, strlen(g_out_key));\n\n\t\tret = sqliterk_output(rk, db, master, 0);\n\n\t\tsqliterk_free_master(master);\n\t\tsqlite3_close(db);\n\t\tsqliterk_close(rk);\n\t\tfree(g_filter);\n\n\t\treturn (ret == SQLITERK_OK) ? 0 : -4;\n\t}\n}\n"
  },
  {
    "path": "tools/docs/docs.sh",
    "content": "#!/bin/bash\n\nappledoc objc/settings.plist ../../objc/WCDB\n#jazzy \\\n#    --objc \\\n#    --clean \\\n#    --author sanhuazhang \\\n#    --author_url sanhuazhang@tencent.com \\\n#    --github_url https://github.com/Tencent/wcdb \\\n#    --xcodebuild-arguments --objc,WCDB/WCDB.h,--,-x,objective-c++,-isysroot,`xcrun --show-sdk-path --sdk iphoneos` \\\n#    --root-url https://github.com/Tencent/wcdb \\\n#    --source-directory ../../objc/ \\\n#    --skip-undocumented \\\n#    --copyright \"Copyright © 2017 Tencent. All rights reserved.\" \\\n#    --output objc/\n    \njazzy \\\n    --no-objc \\\n    --clean \\\n    --author sanhuazhang \\\n    --author_url sanhuazhang@tencent.com \\\n    --github_url https://github.com/Tencent/wcdb \\\n    --xcodebuild-arguments -scheme,WCDB \\\n    --module WCDBSwift \\\n    --root-url https://github.com/Tencent/wcdb \\\n    --source-directory ../../swift/ \\\n    --skip-undocumented \\\n    --copyright \"Copyright © 2017 Tencent. All rights reserved.\" \\\n    --output swift/\n"
  },
  {
    "path": "tools/docs/objc/settings.plist",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">\n<plist version=\"1.0\">\n<dict>\n\t<key>--ignore</key>\n\t<array>\n\t\t<string>WCTBaseAccessor.h</string>\n\t\t<string>WCTConstraintBinding.h</string>\n\t\t<string>WCTDeclare.h</string>\n\t\t<string>.cpp</string>\n\t\t<string>.hpp</string>\n\t\t<string>.mm</string>\n\t</array>\n\t<key>--output</key>\n\t<string>objc/</string>\n\t<key>--create-docset</key>\n\t<false/>\n\t<key>--company-id</key>\n\t<string>com.Tencent</string>\n\t<key>--project-company</key>\n\t<string>Tencent</string>\n\t<key>--create-html</key>\n\t<true/>\n\t<key>--project-name</key>\n\t<string>WCDB</string>\n</dict>\n</plist>\n"
  },
  {
    "path": "tools/format/code.sh",
    "content": "#!/bin/bash\n\nusage() {    \n    echo \"Usage: bash $0 -p/--path path\"\n}\n\npath=\"\"\n\nwhile [[ $# -gt 0 ]]\ndo\nkey=\"$1\"\ncase \"$key\" in\n    -p|--path)\n    path=\"$2\"\n    shift\n    shift\n    ;;\n    *)\n    usage\n    exit 1\n    ;;\nesac\ndone\n\n# check parameters\nif [[ ! -a \"$path\" ]]; then\n    usage\n    exit 1    \nfi\n\n# check toolchains\nif ! type clang-format > /dev/null; then\n    echo \"Error: clang-format not found. Install it by running 'brew install clang-format'.\"\n    exit 1\nfi\nif ! type swiftlint > /dev/null; then\n    echo \"Error: swiftLint not found. Install it by running 'brew install swiftlint'.\"\n    exit 1\nfi\n\n# formatting\nextension=${path##*.}\n\nif [ $extension = \"h\" ] || [ $extension = \"hpp\" ] || [ $extension = \"c\" ] || [ $extension = \"cpp\" ] || [ $extension = \"m\" ] || [ $extension = \"mm\" ]; then\n    # clang-format\n    echo \"Formatting by clang-format for $path ...\"\n    clang-format -i \"$path\"\nelif [ $extension = \"swift\" ]; then\n    # swiftlint\n    echo \"Formatting by swiftlint for $path ...\"\n    swiftlint --autocorrect --quiet --config ../templates/.swiftlint.yml \"$path\"\nelse\n    echo \"Skip Formatting for ${path}\"\nfi\n"
  },
  {
    "path": "tools/format/main.sh",
    "content": "#!/bin/bash\n\nroot=`git rev-parse --show-toplevel`\n\npaths=(src common repair tools/templates)\nformat=$root/tools/format/code.sh\n\nfor path in ${paths[@]}; do\n    fullpath=$root/$path\n    for file in `find $fullpath \\( -name \"*.h\" -or -name \"*.hpp\" -or -name \"*.c\" -or -name \"*.cpp\" -or -name \"*.m\" -or -name \"*.mm\" -or -name \"*.swift\" \\)`; do\n        if ! (bash \"$format\" --path $file); then\n            exit 1\n        fi\n    done\ndone\n"
  },
  {
    "path": "tools/git/hook.sh",
    "content": "#!/bin/bash\n\nusage() {\n    echo \"Usage: bash $0 [--uninstall]\"\n}\n\nif ! git rev-parse --is-inside-work-tree | true; then\n    # skip\n    exit 0\nfi\n\nuninstall=false\nwhile [[ $# -gt 0 ]]\ndo\nkey=\"$1\"\ncase \"$key\" in\n    --uninstall)\n    uninstall=true\n    shift\n    ;;\n    *)\n    usage\n    exit 1\n    ;;\nesac\ndone\n\nroot=`git rev-parse --show-toplevel`\nsource=\"$root\"/tools/git\ndestination=\"$root\"/.git/hooks\n\nhooks=(pre-commit prepare-commit-msg)\nfor hook in \"${hooks[@]}\"; do\n    target=\"$destination/$hook\"\n    rm -f \"$target\"\n    echo \"$target is uninstalled.\"\n    if ! $uninstall; then\n        ln \"$source/$hook\" \"$target\"\n        chmod +x \"$target\"\n        echo \"$target is installed.\"\n    fi\ndone\n"
  },
  {
    "path": "tools/git/pre-commit",
    "content": "#!/bin/bash  \n  \nroot=`git rev-parse --show-toplevel`\n\nformat=$root/tools/format\n\ndiffs=`git diff-index --cached --diff-filter=ACMRT --name-only HEAD`\nwhile read -r file; do\n    fullpath=\"$root/$file\"\n    if ! sh \"$format/code.sh\" --path \"$fullpath\"; then\n        exit 1\n    fi\n    git add \"$fullpath\"\ndone <<< \"$diffs\"\n"
  },
  {
    "path": "tools/git/prepare-commit-msg",
    "content": "#!/bin/sh\n\nmessage=`cat $1`\n\nif [ ${#message} == 0 ]; then\n    echo \"Error: Empty commit message is not allowed.\"\n    exit 1\nfi\n\nif [[ ${message:0:1} != [A-Z] ]]; then\n    echo \"Error: The first letter of the message must be capitalized.\"\n    exit 1\nfi\n"
  },
  {
    "path": "tools/patch/openssl/0001-Workaround-CPU-detection-on-x86-machines-using-libho.patch",
    "content": "From d6717d986bce52d421321b6badbd464038501a83 Mon Sep 17 00:00:00 2001\nFrom: johnwhe <johnwhe@tencent.com>\nDate: Mon, 15 Aug 2016 16:37:37 +0800\nSubject: [PATCH 1/3] Workaround CPU detection on x86 machines using libhoudini\n causes SIGILL and sigsetjmp doesn't work properly.\n\n---\n crypto/armcap.c | 29 +++++++++++++++++++++++++++++\n 1 file changed, 29 insertions(+)\n\ndiff --git a/crypto/armcap.c b/crypto/armcap.c\nindex 356fa15..9a2489f 100644\n--- a/crypto/armcap.c\n+++ b/crypto/armcap.c\n@@ -84,6 +84,16 @@ static unsigned long (*getauxval) (unsigned long) = NULL;\n #  define HWCAP_CE_SHA256        (1 << 6)\n # endif\n \n+#ifdef __ANDROID__\n+#include <sys/system_properties.h>\n+\n+// Works around a bug where Android versions up to and including L don't\n+// properly restore the signal mask when asked.\n+#define sigsetjmp(env,savesigs) \\\n+\t(sigprocmask(SIG_SETMASK,&ill_act.sa_mask,NULL), \\\n+\t sigsetjmp(env,savesigs))\n+#endif\n+\n void OPENSSL_cpuid_setup(void)\n {\n     char *e;\n@@ -100,6 +110,25 @@ void OPENSSL_cpuid_setup(void)\n         return;\n     }\n \n+#ifdef __ANDROID__\n+\t/*\n+\t * Workaround CPU detection on x86 machines using libhoudini causes SIGILL\n+\t * and sigsetjmp doesn't work properly.\n+\t */\n+\tchar cpuabi[PROP_VALUE_MAX];\n+\n+\t__system_property_get(\"ro.product.cpu.abi\", cpuabi);\n+\tcpuabi[PROP_VALUE_MAX - 1] = 0;\n+\tif (!strcmp(cpuabi, \"x86\") || !strcmp(cpuabi, \"x86_64\"))\n+\t{\n+\t\tOPENSSL_armcap_P = ARMV7_NEON;\n+\t\t/* or maybe\n+\t\tOPENSSL_armcap_P = 0\n+\t\t:) */\n+\t\treturn;\n+\t}\n+#endif\n+\n     sigfillset(&all_masked);\n     sigdelset(&all_masked, SIGILL);\n     sigdelset(&all_masked, SIGTRAP);\n-- \n2.9.3.windows.3\n\n"
  },
  {
    "path": "tools/patch/openssl/0002-Clean-generated-asm-sources-on-clean-targets.patch",
    "content": "From c6dcab8066d72e9355cfab22ff918be45b0ba8b5 Mon Sep 17 00:00:00 2001\nFrom: John_He <johnhe928@gmail.com>\nDate: Fri, 7 Oct 2016 02:57:47 +0800\nSubject: [PATCH 2/3] Clean generated asm sources on clean targets.\n\n---\n crypto/aes/Makefile      | 2 +-\n crypto/bf/Makefile       | 2 +-\n crypto/bn/Makefile       | 2 +-\n crypto/camellia/Makefile | 2 +-\n crypto/cast/Makefile     | 2 +-\n crypto/des/Makefile      | 2 +-\n crypto/ec/Makefile       | 2 +-\n crypto/md5/Makefile      | 2 +-\n crypto/modes/Makefile    | 2 +-\n crypto/rc4/Makefile      | 2 +-\n crypto/rc5/Makefile      | 2 +-\n crypto/ripemd/Makefile   | 2 +-\n crypto/sha/Makefile      | 2 +-\n crypto/whrlpool/Makefile | 2 +-\n 14 files changed, 14 insertions(+), 14 deletions(-)\n\ndiff --git a/crypto/aes/Makefile b/crypto/aes/Makefile\nindex e825c14..7cf2ab2 100644\n--- a/crypto/aes/Makefile\n+++ b/crypto/aes/Makefile\n@@ -133,7 +133,7 @@ dclean:\n \tmv -f Makefile.new $(MAKEFILE)\n \n clean:\n-\trm -f *.s *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff\n+\trm -f *.S *.s *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff\n \n # DO NOT DELETE THIS LINE -- make depend depends on it.\n \ndiff --git a/crypto/bf/Makefile b/crypto/bf/Makefile\nindex 6dd2015..c2d37b8 100644\n--- a/crypto/bf/Makefile\n+++ b/crypto/bf/Makefile\n@@ -83,7 +83,7 @@ dclean:\n \tmv -f Makefile.new $(MAKEFILE)\n \n clean:\n-\trm -f *.s *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff\n+\trm -f *.S *.s *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff\n \n # DO NOT DELETE THIS LINE -- make depend depends on it.\n \ndiff --git a/crypto/bn/Makefile b/crypto/bn/Makefile\nindex c4c6409..d9f8341 100644\n--- a/crypto/bn/Makefile\n+++ b/crypto/bn/Makefile\n@@ -187,7 +187,7 @@ dclean:\n \tmv -f Makefile.new $(MAKEFILE)\n \n clean:\n-\trm -f *.s *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff\n+\trm -f *.S *.s *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff\n \n # DO NOT DELETE THIS LINE -- make depend depends on it.\n \ndiff --git a/crypto/camellia/Makefile b/crypto/camellia/Makefile\nindex ab1225e..04df343 100644\n--- a/crypto/camellia/Makefile\n+++ b/crypto/camellia/Makefile\n@@ -86,7 +86,7 @@ dclean:\n \tmv -f Makefile.new $(MAKEFILE)\n \n clean:\n-\trm -f *.s *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff\n+\trm -f *.S *.s *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff\n \n # DO NOT DELETE THIS LINE -- make depend depends on it.\n \ndiff --git a/crypto/cast/Makefile b/crypto/cast/Makefile\nindex 4c4b5e9..0d49bf5 100644\n--- a/crypto/cast/Makefile\n+++ b/crypto/cast/Makefile\n@@ -80,7 +80,7 @@ dclean:\n \tmv -f Makefile.new $(MAKEFILE)\n \n clean:\n-\trm -f *.s *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff\n+\trm -f *.S *.s *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff\n \n # DO NOT DELETE THIS LINE -- make depend depends on it.\n \ndiff --git a/crypto/des/Makefile b/crypto/des/Makefile\nindex 8b5166c..18ff690 100644\n--- a/crypto/des/Makefile\n+++ b/crypto/des/Makefile\n@@ -107,7 +107,7 @@ dclean:\n \tmv -f Makefile.new $(MAKEFILE)\n \n clean:\n-\trm -f *.s *.o *.obj des lib tags core .pure .nfs* *.old *.bak fluff\n+\trm -f *.S *.s *.o *.obj des lib tags core .pure .nfs* *.old *.bak fluff\n \n # DO NOT DELETE THIS LINE -- make depend depends on it.\n \ndiff --git a/crypto/ec/Makefile b/crypto/ec/Makefile\nindex 6628390..0f6595c 100644\n--- a/crypto/ec/Makefile\n+++ b/crypto/ec/Makefile\n@@ -89,7 +89,7 @@ dclean:\n \tmv -f Makefile.new $(MAKEFILE)\n \n clean:\n-\trm -f *.s *.o */*.o *.obj lib tags core .pure .nfs* *.old *.bak fluff\n+\trm -f *.S *.s *.o */*.o *.obj lib tags core .pure .nfs* *.old *.bak fluff\n \n # DO NOT DELETE THIS LINE -- make depend depends on it.\n \ndiff --git a/crypto/md5/Makefile b/crypto/md5/Makefile\nindex f5240da..6ca208f 100644\n--- a/crypto/md5/Makefile\n+++ b/crypto/md5/Makefile\n@@ -90,7 +90,7 @@ dclean:\n \tmv -f Makefile.new $(MAKEFILE)\n \n clean:\n-\trm -f *.s *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff\n+\trm -f *.S *.s *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff\n \n # DO NOT DELETE THIS LINE -- make depend depends on it.\n \ndiff --git a/crypto/modes/Makefile b/crypto/modes/Makefile\nindex a7863d9..8e8cf7d 100644\n--- a/crypto/modes/Makefile\n+++ b/crypto/modes/Makefile\n@@ -106,7 +106,7 @@ dclean:\n \tmv -f Makefile.new $(MAKEFILE)\n \n clean:\n-\trm -f *.s *.o */*.o *.obj lib tags core .pure .nfs* *.old *.bak fluff\n+\trm -f *.S *.s *.o */*.o *.obj lib tags core .pure .nfs* *.old *.bak fluff\n \n # DO NOT DELETE THIS LINE -- make depend depends on it.\n \ndiff --git a/crypto/rc4/Makefile b/crypto/rc4/Makefile\nindex 7434ff7..6167b14 100644\n--- a/crypto/rc4/Makefile\n+++ b/crypto/rc4/Makefile\n@@ -100,7 +100,7 @@ dclean:\n \tmv -f Makefile.new $(MAKEFILE)\n \n clean:\n-\trm -f *.s *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff\n+\trm -f *.S *.s *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff\n \n # DO NOT DELETE THIS LINE -- make depend depends on it.\n \ndiff --git a/crypto/rc5/Makefile b/crypto/rc5/Makefile\nindex 6ca0037..d245c9a 100644\n--- a/crypto/rc5/Makefile\n+++ b/crypto/rc5/Makefile\n@@ -80,7 +80,7 @@ dclean:\n \tmv -f Makefile.new $(MAKEFILE)\n \n clean:\n-\trm -f *.s *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff\n+\trm -f *.S *.s *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff\n \n # DO NOT DELETE THIS LINE -- make depend depends on it.\n \ndiff --git a/crypto/ripemd/Makefile b/crypto/ripemd/Makefile\nindex 1c3f094..a15893a 100644\n--- a/crypto/ripemd/Makefile\n+++ b/crypto/ripemd/Makefile\n@@ -80,7 +80,7 @@ dclean:\n \tmv -f Makefile.new $(MAKEFILE)\n \n clean:\n-\trm -f *.s *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff\n+\trm -f *.S *.s *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff\n \n # DO NOT DELETE THIS LINE -- make depend depends on it.\n \ndiff --git a/crypto/sha/Makefile b/crypto/sha/Makefile\nindex de6cdde..dbee8e0 100644\n--- a/crypto/sha/Makefile\n+++ b/crypto/sha/Makefile\n@@ -135,7 +135,7 @@ dclean:\n \tmv -f Makefile.new $(MAKEFILE)\n \n clean:\n-\trm -f *.s *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff\n+\trm -f *.S *.s *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff\n \n # DO NOT DELETE THIS LINE -- make depend depends on it.\n \ndiff --git a/crypto/whrlpool/Makefile b/crypto/whrlpool/Makefile\nindex befd6d6..394628b 100644\n--- a/crypto/whrlpool/Makefile\n+++ b/crypto/whrlpool/Makefile\n@@ -85,7 +85,7 @@ dclean:\n \tmv -f Makefile.new $(MAKEFILE)\n \n clean:\n-\trm -f *.s *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff\n+\trm -f *.S *.s *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff\n \n # DO NOT DELETE THIS LINE -- make depend depends on it.\n \n-- \n2.9.3.windows.3\n\n"
  },
  {
    "path": "tools/patch/openssl/0003-Fix-armv4-clang-build.patch",
    "content": "From 30e13db032cb9efeaf0c6d71aa48fd12536366c2 Mon Sep 17 00:00:00 2001\nFrom: johnwhe <johnwhe@tencent.com>\nDate: Sun, 20 Nov 2016 20:17:29 +0800\nSubject: [PATCH 3/3] Fix armv4 clang build.\n\n---\n crypto/modes/asm/ghash-armv4.pl | 5 -----\n 1 file changed, 5 deletions(-)\n\ndiff --git a/crypto/modes/asm/ghash-armv4.pl b/crypto/modes/asm/ghash-armv4.pl\nindex 8ccc963..21f877a 100644\n--- a/crypto/modes/asm/ghash-armv4.pl\n+++ b/crypto/modes/asm/ghash-armv4.pl\n@@ -126,11 +126,6 @@ $code=<<___;\n .text\n .code\t32\n \n-#ifdef __clang__\n-#define ldrplb\tldrbpl\n-#define ldrneb\tldrbne\n-#endif\n-\n .type\trem_4bit,%object\n .align\t5\n rem_4bit:\n-- \n2.9.3.windows.3\n\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/arm/include/openssl/aes.h",
    "content": "/* crypto/aes/aes.h */\n/* ====================================================================\n * Copyright (c) 1998-2002 The OpenSSL Project.  All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n *\n * 1. Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n *\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in\n *    the documentation and/or other materials provided with the\n *    distribution.\n *\n * 3. All advertising materials mentioning features or use of this\n *    software must display the following acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit. (http://www.openssl.org/)\"\n *\n * 4. The names \"OpenSSL Toolkit\" and \"OpenSSL Project\" must not be used to\n *    endorse or promote products derived from this software without\n *    prior written permission. For written permission, please contact\n *    openssl-core@openssl.org.\n *\n * 5. Products derived from this software may not be called \"OpenSSL\"\n *    nor may \"OpenSSL\" appear in their names without prior written\n *    permission of the OpenSSL Project.\n *\n * 6. Redistributions of any form whatsoever must retain the following\n *    acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit (http://www.openssl.org/)\"\n *\n * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY\n * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\n * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR\n * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\n * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,\n * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED\n * OF THE POSSIBILITY OF SUCH DAMAGE.\n * ====================================================================\n *\n */\n\n#ifndef HEADER_AES_H\n# define HEADER_AES_H\n\n# include <openssl/opensslconf.h>\n\n# ifdef OPENSSL_NO_AES\n#  error AES is disabled.\n# endif\n\n# include <stddef.h>\n\n# define AES_ENCRYPT     1\n# define AES_DECRYPT     0\n\n/*\n * Because array size can't be a const in C, the following two are macros.\n * Both sizes are in bytes.\n */\n# define AES_MAXNR 14\n# define AES_BLOCK_SIZE 16\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n/* This should be a hidden type, but EVP requires that the size be known */\nstruct aes_key_st {\n# ifdef AES_LONG\n    unsigned long rd_key[4 * (AES_MAXNR + 1)];\n# else\n    unsigned int rd_key[4 * (AES_MAXNR + 1)];\n# endif\n    int rounds;\n};\ntypedef struct aes_key_st AES_KEY;\n\nconst char *AES_options(void);\n\nint AES_set_encrypt_key(const unsigned char *userKey, const int bits,\n                        AES_KEY *key);\nint AES_set_decrypt_key(const unsigned char *userKey, const int bits,\n                        AES_KEY *key);\n\nint private_AES_set_encrypt_key(const unsigned char *userKey, const int bits,\n                                AES_KEY *key);\nint private_AES_set_decrypt_key(const unsigned char *userKey, const int bits,\n                                AES_KEY *key);\n\nvoid AES_encrypt(const unsigned char *in, unsigned char *out,\n                 const AES_KEY *key);\nvoid AES_decrypt(const unsigned char *in, unsigned char *out,\n                 const AES_KEY *key);\n\nvoid AES_ecb_encrypt(const unsigned char *in, unsigned char *out,\n                     const AES_KEY *key, const int enc);\nvoid AES_cbc_encrypt(const unsigned char *in, unsigned char *out,\n                     size_t length, const AES_KEY *key,\n                     unsigned char *ivec, const int enc);\nvoid AES_cfb128_encrypt(const unsigned char *in, unsigned char *out,\n                        size_t length, const AES_KEY *key,\n                        unsigned char *ivec, int *num, const int enc);\nvoid AES_cfb1_encrypt(const unsigned char *in, unsigned char *out,\n                      size_t length, const AES_KEY *key,\n                      unsigned char *ivec, int *num, const int enc);\nvoid AES_cfb8_encrypt(const unsigned char *in, unsigned char *out,\n                      size_t length, const AES_KEY *key,\n                      unsigned char *ivec, int *num, const int enc);\nvoid AES_ofb128_encrypt(const unsigned char *in, unsigned char *out,\n                        size_t length, const AES_KEY *key,\n                        unsigned char *ivec, int *num);\nvoid AES_ctr128_encrypt(const unsigned char *in, unsigned char *out,\n                        size_t length, const AES_KEY *key,\n                        unsigned char ivec[AES_BLOCK_SIZE],\n                        unsigned char ecount_buf[AES_BLOCK_SIZE],\n                        unsigned int *num);\n/* NB: the IV is _two_ blocks long */\nvoid AES_ige_encrypt(const unsigned char *in, unsigned char *out,\n                     size_t length, const AES_KEY *key,\n                     unsigned char *ivec, const int enc);\n/* NB: the IV is _four_ blocks long */\nvoid AES_bi_ige_encrypt(const unsigned char *in, unsigned char *out,\n                        size_t length, const AES_KEY *key,\n                        const AES_KEY *key2, const unsigned char *ivec,\n                        const int enc);\n\nint AES_wrap_key(AES_KEY *key, const unsigned char *iv,\n                 unsigned char *out,\n                 const unsigned char *in, unsigned int inlen);\nint AES_unwrap_key(AES_KEY *key, const unsigned char *iv,\n                   unsigned char *out,\n                   const unsigned char *in, unsigned int inlen);\n\n\n#ifdef  __cplusplus\n}\n#endif\n\n#endif                          /* !HEADER_AES_H */\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/arm/include/openssl/asn1.h",
    "content": "/* crypto/asn1/asn1.h */\n/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)\n * All rights reserved.\n *\n * This package is an SSL implementation written\n * by Eric Young (eay@cryptsoft.com).\n * The implementation was written so as to conform with Netscapes SSL.\n *\n * This library is free for commercial and non-commercial use as long as\n * the following conditions are aheared to.  The following conditions\n * apply to all code found in this distribution, be it the RC4, RSA,\n * lhash, DES, etc., code; not just the SSL code.  The SSL documentation\n * included with this distribution is covered by the same copyright terms\n * except that the holder is Tim Hudson (tjh@cryptsoft.com).\n *\n * Copyright remains Eric Young's, and as such any Copyright notices in\n * the code are not to be removed.\n * If this package is used in a product, Eric Young should be given attribution\n * as the author of the parts of the library used.\n * This can be in the form of a textual message at program startup or\n * in documentation (online or textual) provided with the package.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the copyright\n *    notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in the\n *    documentation and/or other materials provided with the distribution.\n * 3. All advertising materials mentioning features or use of this software\n *    must display the following acknowledgement:\n *    \"This product includes cryptographic software written by\n *     Eric Young (eay@cryptsoft.com)\"\n *    The word 'cryptographic' can be left out if the rouines from the library\n *    being used are not cryptographic related :-).\n * 4. If you include any Windows specific code (or a derivative thereof) from\n *    the apps directory (application code) you must include an acknowledgement:\n *    \"This product includes software written by Tim Hudson (tjh@cryptsoft.com)\"\n *\n * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n * SUCH DAMAGE.\n *\n * The licence and distribution terms for any publically available version or\n * derivative of this code cannot be changed.  i.e. this code cannot simply be\n * copied and put under another distribution licence\n * [including the GNU Public Licence.]\n */\n\n#ifndef HEADER_ASN1_H\n# define HEADER_ASN1_H\n\n# include <time.h>\n# include <openssl/e_os2.h>\n# ifndef OPENSSL_NO_BIO\n#  include <openssl/bio.h>\n# endif\n# include <openssl/stack.h>\n# include <openssl/safestack.h>\n\n# include <openssl/symhacks.h>\n\n# include <openssl/ossl_typ.h>\n# ifndef OPENSSL_NO_DEPRECATED\n#  include <openssl/bn.h>\n# endif\n\n# ifdef OPENSSL_BUILD_SHLIBCRYPTO\n#  undef OPENSSL_EXTERN\n#  define OPENSSL_EXTERN OPENSSL_EXPORT\n# endif\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n# define V_ASN1_UNIVERSAL                0x00\n# define V_ASN1_APPLICATION              0x40\n# define V_ASN1_CONTEXT_SPECIFIC         0x80\n# define V_ASN1_PRIVATE                  0xc0\n\n# define V_ASN1_CONSTRUCTED              0x20\n# define V_ASN1_PRIMITIVE_TAG            0x1f\n# define V_ASN1_PRIMATIVE_TAG            0x1f\n\n# define V_ASN1_APP_CHOOSE               -2/* let the recipient choose */\n# define V_ASN1_OTHER                    -3/* used in ASN1_TYPE */\n# define V_ASN1_ANY                      -4/* used in ASN1 template code */\n\n# define V_ASN1_NEG                      0x100/* negative flag */\n\n# define V_ASN1_UNDEF                    -1\n# define V_ASN1_EOC                      0\n# define V_ASN1_BOOLEAN                  1 /**/\n# define V_ASN1_INTEGER                  2\n# define V_ASN1_NEG_INTEGER              (2 | V_ASN1_NEG)\n# define V_ASN1_BIT_STRING               3\n# define V_ASN1_OCTET_STRING             4\n# define V_ASN1_NULL                     5\n# define V_ASN1_OBJECT                   6\n# define V_ASN1_OBJECT_DESCRIPTOR        7\n# define V_ASN1_EXTERNAL                 8\n# define V_ASN1_REAL                     9\n# define V_ASN1_ENUMERATED               10\n# define V_ASN1_NEG_ENUMERATED           (10 | V_ASN1_NEG)\n# define V_ASN1_UTF8STRING               12\n# define V_ASN1_SEQUENCE                 16\n# define V_ASN1_SET                      17\n# define V_ASN1_NUMERICSTRING            18 /**/\n# define V_ASN1_PRINTABLESTRING          19\n# define V_ASN1_T61STRING                20\n# define V_ASN1_TELETEXSTRING            20/* alias */\n# define V_ASN1_VIDEOTEXSTRING           21 /**/\n# define V_ASN1_IA5STRING                22\n# define V_ASN1_UTCTIME                  23\n# define V_ASN1_GENERALIZEDTIME          24 /**/\n# define V_ASN1_GRAPHICSTRING            25 /**/\n# define V_ASN1_ISO64STRING              26 /**/\n# define V_ASN1_VISIBLESTRING            26/* alias */\n# define V_ASN1_GENERALSTRING            27 /**/\n# define V_ASN1_UNIVERSALSTRING          28 /**/\n# define V_ASN1_BMPSTRING                30\n/* For use with d2i_ASN1_type_bytes() */\n# define B_ASN1_NUMERICSTRING    0x0001\n# define B_ASN1_PRINTABLESTRING  0x0002\n# define B_ASN1_T61STRING        0x0004\n# define B_ASN1_TELETEXSTRING    0x0004\n# define B_ASN1_VIDEOTEXSTRING   0x0008\n# define B_ASN1_IA5STRING        0x0010\n# define B_ASN1_GRAPHICSTRING    0x0020\n# define B_ASN1_ISO64STRING      0x0040\n# define B_ASN1_VISIBLESTRING    0x0040\n# define B_ASN1_GENERALSTRING    0x0080\n# define B_ASN1_UNIVERSALSTRING  0x0100\n# define B_ASN1_OCTET_STRING     0x0200\n# define B_ASN1_BIT_STRING       0x0400\n# define B_ASN1_BMPSTRING        0x0800\n# define B_ASN1_UNKNOWN          0x1000\n# define B_ASN1_UTF8STRING       0x2000\n# define B_ASN1_UTCTIME          0x4000\n# define B_ASN1_GENERALIZEDTIME  0x8000\n# define B_ASN1_SEQUENCE         0x10000\n/* For use with ASN1_mbstring_copy() */\n# define MBSTRING_FLAG           0x1000\n# define MBSTRING_UTF8           (MBSTRING_FLAG)\n# define MBSTRING_ASC            (MBSTRING_FLAG|1)\n# define MBSTRING_BMP            (MBSTRING_FLAG|2)\n# define MBSTRING_UNIV           (MBSTRING_FLAG|4)\n# define SMIME_OLDMIME           0x400\n# define SMIME_CRLFEOL           0x800\n# define SMIME_STREAM            0x1000\n    struct X509_algor_st;\nDECLARE_STACK_OF(X509_ALGOR)\n\n# define DECLARE_ASN1_SET_OF(type)/* filled in by mkstack.pl */\n# define IMPLEMENT_ASN1_SET_OF(type)/* nothing, no longer needed */\n\n/*\n * We MUST make sure that, except for constness, asn1_ctx_st and\n * asn1_const_ctx are exactly the same.  Fortunately, as soon as the old ASN1\n * parsing macros are gone, we can throw this away as well...\n */\ntypedef struct asn1_ctx_st {\n    unsigned char *p;           /* work char pointer */\n    int eos;                    /* end of sequence read for indefinite\n                                 * encoding */\n    int error;                  /* error code to use when returning an error */\n    int inf;                    /* constructed if 0x20, indefinite is 0x21 */\n    int tag;                    /* tag from last 'get object' */\n    int xclass;                 /* class from last 'get object' */\n    long slen;                  /* length of last 'get object' */\n    unsigned char *max;         /* largest value of p allowed */\n    unsigned char *q;           /* temporary variable */\n    unsigned char **pp;         /* variable */\n    int line;                   /* used in error processing */\n} ASN1_CTX;\n\ntypedef struct asn1_const_ctx_st {\n    const unsigned char *p;     /* work char pointer */\n    int eos;                    /* end of sequence read for indefinite\n                                 * encoding */\n    int error;                  /* error code to use when returning an error */\n    int inf;                    /* constructed if 0x20, indefinite is 0x21 */\n    int tag;                    /* tag from last 'get object' */\n    int xclass;                 /* class from last 'get object' */\n    long slen;                  /* length of last 'get object' */\n    const unsigned char *max;   /* largest value of p allowed */\n    const unsigned char *q;     /* temporary variable */\n    const unsigned char **pp;   /* variable */\n    int line;                   /* used in error processing */\n} ASN1_const_CTX;\n\n/*\n * These are used internally in the ASN1_OBJECT to keep track of whether the\n * names and data need to be free()ed\n */\n# define ASN1_OBJECT_FLAG_DYNAMIC         0x01/* internal use */\n# define ASN1_OBJECT_FLAG_CRITICAL        0x02/* critical x509v3 object id */\n# define ASN1_OBJECT_FLAG_DYNAMIC_STRINGS 0x04/* internal use */\n# define ASN1_OBJECT_FLAG_DYNAMIC_DATA    0x08/* internal use */\nstruct asn1_object_st {\n    const char *sn, *ln;\n    int nid;\n    int length;\n    const unsigned char *data;  /* data remains const after init */\n    int flags;                  /* Should we free this one */\n};\n\n# define ASN1_STRING_FLAG_BITS_LEFT 0x08/* Set if 0x07 has bits left value */\n/*\n * This indicates that the ASN1_STRING is not a real value but just a place\n * holder for the location where indefinite length constructed data should be\n * inserted in the memory buffer\n */\n# define ASN1_STRING_FLAG_NDEF 0x010\n\n/*\n * This flag is used by the CMS code to indicate that a string is not\n * complete and is a place holder for content when it had all been accessed.\n * The flag will be reset when content has been written to it.\n */\n\n# define ASN1_STRING_FLAG_CONT 0x020\n/*\n * This flag is used by ASN1 code to indicate an ASN1_STRING is an MSTRING\n * type.\n */\n# define ASN1_STRING_FLAG_MSTRING 0x040\n/* This is the base type that holds just about everything :-) */\nstruct asn1_string_st {\n    int length;\n    int type;\n    unsigned char *data;\n    /*\n     * The value of the following field depends on the type being held.  It\n     * is mostly being used for BIT_STRING so if the input data has a\n     * non-zero 'unused bits' value, it will be handled correctly\n     */\n    long flags;\n};\n\n/*\n * ASN1_ENCODING structure: this is used to save the received encoding of an\n * ASN1 type. This is useful to get round problems with invalid encodings\n * which can break signatures.\n */\n\ntypedef struct ASN1_ENCODING_st {\n    unsigned char *enc;         /* DER encoding */\n    long len;                   /* Length of encoding */\n    int modified;               /* set to 1 if 'enc' is invalid */\n} ASN1_ENCODING;\n\n/* Used with ASN1 LONG type: if a long is set to this it is omitted */\n# define ASN1_LONG_UNDEF 0x7fffffffL\n\n# define STABLE_FLAGS_MALLOC     0x01\n# define STABLE_NO_MASK          0x02\n# define DIRSTRING_TYPE  \\\n (B_ASN1_PRINTABLESTRING|B_ASN1_T61STRING|B_ASN1_BMPSTRING|B_ASN1_UTF8STRING)\n# define PKCS9STRING_TYPE (DIRSTRING_TYPE|B_ASN1_IA5STRING)\n\ntypedef struct asn1_string_table_st {\n    int nid;\n    long minsize;\n    long maxsize;\n    unsigned long mask;\n    unsigned long flags;\n} ASN1_STRING_TABLE;\n\nDECLARE_STACK_OF(ASN1_STRING_TABLE)\n\n/* size limits: this stuff is taken straight from RFC2459 */\n\n# define ub_name                         32768\n# define ub_common_name                  64\n# define ub_locality_name                128\n# define ub_state_name                   128\n# define ub_organization_name            64\n# define ub_organization_unit_name       64\n# define ub_title                        64\n# define ub_email_address                128\n\n/*\n * Declarations for template structures: for full definitions see asn1t.h\n */\ntypedef struct ASN1_TEMPLATE_st ASN1_TEMPLATE;\ntypedef struct ASN1_TLC_st ASN1_TLC;\n/* This is just an opaque pointer */\ntypedef struct ASN1_VALUE_st ASN1_VALUE;\n\n/* Declare ASN1 functions: the implement macro in in asn1t.h */\n\n# define DECLARE_ASN1_FUNCTIONS(type) DECLARE_ASN1_FUNCTIONS_name(type, type)\n\n# define DECLARE_ASN1_ALLOC_FUNCTIONS(type) \\\n        DECLARE_ASN1_ALLOC_FUNCTIONS_name(type, type)\n\n# define DECLARE_ASN1_FUNCTIONS_name(type, name) \\\n        DECLARE_ASN1_ALLOC_FUNCTIONS_name(type, name) \\\n        DECLARE_ASN1_ENCODE_FUNCTIONS(type, name, name)\n\n# define DECLARE_ASN1_FUNCTIONS_fname(type, itname, name) \\\n        DECLARE_ASN1_ALLOC_FUNCTIONS_name(type, name) \\\n        DECLARE_ASN1_ENCODE_FUNCTIONS(type, itname, name)\n\n# define DECLARE_ASN1_ENCODE_FUNCTIONS(type, itname, name) \\\n        type *d2i_##name(type **a, const unsigned char **in, long len); \\\n        int i2d_##name(type *a, unsigned char **out); \\\n        DECLARE_ASN1_ITEM(itname)\n\n# define DECLARE_ASN1_ENCODE_FUNCTIONS_const(type, name) \\\n        type *d2i_##name(type **a, const unsigned char **in, long len); \\\n        int i2d_##name(const type *a, unsigned char **out); \\\n        DECLARE_ASN1_ITEM(name)\n\n# define DECLARE_ASN1_NDEF_FUNCTION(name) \\\n        int i2d_##name##_NDEF(name *a, unsigned char **out);\n\n# define DECLARE_ASN1_FUNCTIONS_const(name) \\\n        DECLARE_ASN1_ALLOC_FUNCTIONS(name) \\\n        DECLARE_ASN1_ENCODE_FUNCTIONS_const(name, name)\n\n# define DECLARE_ASN1_ALLOC_FUNCTIONS_name(type, name) \\\n        type *name##_new(void); \\\n        void name##_free(type *a);\n\n# define DECLARE_ASN1_PRINT_FUNCTION(stname) \\\n        DECLARE_ASN1_PRINT_FUNCTION_fname(stname, stname)\n\n# define DECLARE_ASN1_PRINT_FUNCTION_fname(stname, fname) \\\n        int fname##_print_ctx(BIO *out, stname *x, int indent, \\\n                                         const ASN1_PCTX *pctx);\n\n# define D2I_OF(type) type *(*)(type **,const unsigned char **,long)\n# define I2D_OF(type) int (*)(type *,unsigned char **)\n# define I2D_OF_const(type) int (*)(const type *,unsigned char **)\n\n# define CHECKED_D2I_OF(type, d2i) \\\n    ((d2i_of_void*) (1 ? d2i : ((D2I_OF(type))0)))\n# define CHECKED_I2D_OF(type, i2d) \\\n    ((i2d_of_void*) (1 ? i2d : ((I2D_OF(type))0)))\n# define CHECKED_NEW_OF(type, xnew) \\\n    ((void *(*)(void)) (1 ? xnew : ((type *(*)(void))0)))\n# define CHECKED_PTR_OF(type, p) \\\n    ((void*) (1 ? p : (type*)0))\n# define CHECKED_PPTR_OF(type, p) \\\n    ((void**) (1 ? p : (type**)0))\n\n# define TYPEDEF_D2I_OF(type) typedef type *d2i_of_##type(type **,const unsigned char **,long)\n# define TYPEDEF_I2D_OF(type) typedef int i2d_of_##type(type *,unsigned char **)\n# define TYPEDEF_D2I2D_OF(type) TYPEDEF_D2I_OF(type); TYPEDEF_I2D_OF(type)\n\nTYPEDEF_D2I2D_OF(void);\n\n/*-\n * The following macros and typedefs allow an ASN1_ITEM\n * to be embedded in a structure and referenced. Since\n * the ASN1_ITEM pointers need to be globally accessible\n * (possibly from shared libraries) they may exist in\n * different forms. On platforms that support it the\n * ASN1_ITEM structure itself will be globally exported.\n * Other platforms will export a function that returns\n * an ASN1_ITEM pointer.\n *\n * To handle both cases transparently the macros below\n * should be used instead of hard coding an ASN1_ITEM\n * pointer in a structure.\n *\n * The structure will look like this:\n *\n * typedef struct SOMETHING_st {\n *      ...\n *      ASN1_ITEM_EXP *iptr;\n *      ...\n * } SOMETHING;\n *\n * It would be initialised as e.g.:\n *\n * SOMETHING somevar = {...,ASN1_ITEM_ref(X509),...};\n *\n * and the actual pointer extracted with:\n *\n * const ASN1_ITEM *it = ASN1_ITEM_ptr(somevar.iptr);\n *\n * Finally an ASN1_ITEM pointer can be extracted from an\n * appropriate reference with: ASN1_ITEM_rptr(X509). This\n * would be used when a function takes an ASN1_ITEM * argument.\n *\n */\n\n# ifndef OPENSSL_EXPORT_VAR_AS_FUNCTION\n\n/* ASN1_ITEM pointer exported type */\ntypedef const ASN1_ITEM ASN1_ITEM_EXP;\n\n/* Macro to obtain ASN1_ITEM pointer from exported type */\n#  define ASN1_ITEM_ptr(iptr) (iptr)\n\n/* Macro to include ASN1_ITEM pointer from base type */\n#  define ASN1_ITEM_ref(iptr) (&(iptr##_it))\n\n#  define ASN1_ITEM_rptr(ref) (&(ref##_it))\n\n#  define DECLARE_ASN1_ITEM(name) \\\n        OPENSSL_EXTERN const ASN1_ITEM name##_it;\n\n# else\n\n/*\n * Platforms that can't easily handle shared global variables are declared as\n * functions returning ASN1_ITEM pointers.\n */\n\n/* ASN1_ITEM pointer exported type */\ntypedef const ASN1_ITEM *ASN1_ITEM_EXP (void);\n\n/* Macro to obtain ASN1_ITEM pointer from exported type */\n#  define ASN1_ITEM_ptr(iptr) (iptr())\n\n/* Macro to include ASN1_ITEM pointer from base type */\n#  define ASN1_ITEM_ref(iptr) (iptr##_it)\n\n#  define ASN1_ITEM_rptr(ref) (ref##_it())\n\n#  define DECLARE_ASN1_ITEM(name) \\\n        const ASN1_ITEM * name##_it(void);\n\n# endif\n\n/* Parameters used by ASN1_STRING_print_ex() */\n\n/*\n * These determine which characters to escape: RFC2253 special characters,\n * control characters and MSB set characters\n */\n\n# define ASN1_STRFLGS_ESC_2253           1\n# define ASN1_STRFLGS_ESC_CTRL           2\n# define ASN1_STRFLGS_ESC_MSB            4\n\n/*\n * This flag determines how we do escaping: normally RC2253 backslash only,\n * set this to use backslash and quote.\n */\n\n# define ASN1_STRFLGS_ESC_QUOTE          8\n\n/* These three flags are internal use only. */\n\n/* Character is a valid PrintableString character */\n# define CHARTYPE_PRINTABLESTRING        0x10\n/* Character needs escaping if it is the first character */\n# define CHARTYPE_FIRST_ESC_2253         0x20\n/* Character needs escaping if it is the last character */\n# define CHARTYPE_LAST_ESC_2253          0x40\n\n/*\n * NB the internal flags are safely reused below by flags handled at the top\n * level.\n */\n\n/*\n * If this is set we convert all character strings to UTF8 first\n */\n\n# define ASN1_STRFLGS_UTF8_CONVERT       0x10\n\n/*\n * If this is set we don't attempt to interpret content: just assume all\n * strings are 1 byte per character. This will produce some pretty odd\n * looking output!\n */\n\n# define ASN1_STRFLGS_IGNORE_TYPE        0x20\n\n/* If this is set we include the string type in the output */\n# define ASN1_STRFLGS_SHOW_TYPE          0x40\n\n/*\n * This determines which strings to display and which to 'dump' (hex dump of\n * content octets or DER encoding). We can only dump non character strings or\n * everything. If we don't dump 'unknown' they are interpreted as character\n * strings with 1 octet per character and are subject to the usual escaping\n * options.\n */\n\n# define ASN1_STRFLGS_DUMP_ALL           0x80\n# define ASN1_STRFLGS_DUMP_UNKNOWN       0x100\n\n/*\n * These determine what 'dumping' does, we can dump the content octets or the\n * DER encoding: both use the RFC2253 #XXXXX notation.\n */\n\n# define ASN1_STRFLGS_DUMP_DER           0x200\n\n/*\n * All the string flags consistent with RFC2253, escaping control characters\n * isn't essential in RFC2253 but it is advisable anyway.\n */\n\n# define ASN1_STRFLGS_RFC2253    (ASN1_STRFLGS_ESC_2253 | \\\n                                ASN1_STRFLGS_ESC_CTRL | \\\n                                ASN1_STRFLGS_ESC_MSB | \\\n                                ASN1_STRFLGS_UTF8_CONVERT | \\\n                                ASN1_STRFLGS_DUMP_UNKNOWN | \\\n                                ASN1_STRFLGS_DUMP_DER)\n\nDECLARE_STACK_OF(ASN1_INTEGER)\nDECLARE_ASN1_SET_OF(ASN1_INTEGER)\n\nDECLARE_STACK_OF(ASN1_GENERALSTRING)\n\ntypedef struct asn1_type_st {\n    int type;\n    union {\n        char *ptr;\n        ASN1_BOOLEAN boolean;\n        ASN1_STRING *asn1_string;\n        ASN1_OBJECT *object;\n        ASN1_INTEGER *integer;\n        ASN1_ENUMERATED *enumerated;\n        ASN1_BIT_STRING *bit_string;\n        ASN1_OCTET_STRING *octet_string;\n        ASN1_PRINTABLESTRING *printablestring;\n        ASN1_T61STRING *t61string;\n        ASN1_IA5STRING *ia5string;\n        ASN1_GENERALSTRING *generalstring;\n        ASN1_BMPSTRING *bmpstring;\n        ASN1_UNIVERSALSTRING *universalstring;\n        ASN1_UTCTIME *utctime;\n        ASN1_GENERALIZEDTIME *generalizedtime;\n        ASN1_VISIBLESTRING *visiblestring;\n        ASN1_UTF8STRING *utf8string;\n        /*\n         * set and sequence are left complete and still contain the set or\n         * sequence bytes\n         */\n        ASN1_STRING *set;\n        ASN1_STRING *sequence;\n        ASN1_VALUE *asn1_value;\n    } value;\n} ASN1_TYPE;\n\nDECLARE_STACK_OF(ASN1_TYPE)\nDECLARE_ASN1_SET_OF(ASN1_TYPE)\n\ntypedef STACK_OF(ASN1_TYPE) ASN1_SEQUENCE_ANY;\n\nDECLARE_ASN1_ENCODE_FUNCTIONS_const(ASN1_SEQUENCE_ANY, ASN1_SEQUENCE_ANY)\nDECLARE_ASN1_ENCODE_FUNCTIONS_const(ASN1_SEQUENCE_ANY, ASN1_SET_ANY)\n\ntypedef struct NETSCAPE_X509_st {\n    ASN1_OCTET_STRING *header;\n    X509 *cert;\n} NETSCAPE_X509;\n\n/* This is used to contain a list of bit names */\ntypedef struct BIT_STRING_BITNAME_st {\n    int bitnum;\n    const char *lname;\n    const char *sname;\n} BIT_STRING_BITNAME;\n\n# define M_ASN1_STRING_length(x) ((x)->length)\n# define M_ASN1_STRING_length_set(x, n)  ((x)->length = (n))\n# define M_ASN1_STRING_type(x)   ((x)->type)\n# define M_ASN1_STRING_data(x)   ((x)->data)\n\n/* Macros for string operations */\n# define M_ASN1_BIT_STRING_new() (ASN1_BIT_STRING *)\\\n                ASN1_STRING_type_new(V_ASN1_BIT_STRING)\n# define M_ASN1_BIT_STRING_free(a)       ASN1_STRING_free((ASN1_STRING *)a)\n# define M_ASN1_BIT_STRING_dup(a) (ASN1_BIT_STRING *)\\\n                ASN1_STRING_dup((const ASN1_STRING *)a)\n# define M_ASN1_BIT_STRING_cmp(a,b) ASN1_STRING_cmp(\\\n                (const ASN1_STRING *)a,(const ASN1_STRING *)b)\n# define M_ASN1_BIT_STRING_set(a,b,c) ASN1_STRING_set((ASN1_STRING *)a,b,c)\n\n# define M_ASN1_INTEGER_new()    (ASN1_INTEGER *)\\\n                ASN1_STRING_type_new(V_ASN1_INTEGER)\n# define M_ASN1_INTEGER_free(a)          ASN1_STRING_free((ASN1_STRING *)a)\n# define M_ASN1_INTEGER_dup(a) (ASN1_INTEGER *)\\\n                ASN1_STRING_dup((const ASN1_STRING *)a)\n# define M_ASN1_INTEGER_cmp(a,b) ASN1_STRING_cmp(\\\n                (const ASN1_STRING *)a,(const ASN1_STRING *)b)\n\n# define M_ASN1_ENUMERATED_new() (ASN1_ENUMERATED *)\\\n                ASN1_STRING_type_new(V_ASN1_ENUMERATED)\n# define M_ASN1_ENUMERATED_free(a)       ASN1_STRING_free((ASN1_STRING *)a)\n# define M_ASN1_ENUMERATED_dup(a) (ASN1_ENUMERATED *)\\\n                ASN1_STRING_dup((const ASN1_STRING *)a)\n# define M_ASN1_ENUMERATED_cmp(a,b)      ASN1_STRING_cmp(\\\n                (const ASN1_STRING *)a,(const ASN1_STRING *)b)\n\n# define M_ASN1_OCTET_STRING_new()       (ASN1_OCTET_STRING *)\\\n                ASN1_STRING_type_new(V_ASN1_OCTET_STRING)\n# define M_ASN1_OCTET_STRING_free(a)     ASN1_STRING_free((ASN1_STRING *)a)\n# define M_ASN1_OCTET_STRING_dup(a) (ASN1_OCTET_STRING *)\\\n                ASN1_STRING_dup((const ASN1_STRING *)a)\n# define M_ASN1_OCTET_STRING_cmp(a,b) ASN1_STRING_cmp(\\\n                (const ASN1_STRING *)a,(const ASN1_STRING *)b)\n# define M_ASN1_OCTET_STRING_set(a,b,c)  ASN1_STRING_set((ASN1_STRING *)a,b,c)\n# define M_ASN1_OCTET_STRING_print(a,b)  ASN1_STRING_print(a,(ASN1_STRING *)b)\n# define M_i2d_ASN1_OCTET_STRING(a,pp) \\\n                i2d_ASN1_bytes((ASN1_STRING *)a,pp,V_ASN1_OCTET_STRING,\\\n                V_ASN1_UNIVERSAL)\n\n# define B_ASN1_TIME \\\n                        B_ASN1_UTCTIME | \\\n                        B_ASN1_GENERALIZEDTIME\n\n# define B_ASN1_PRINTABLE \\\n                        B_ASN1_NUMERICSTRING| \\\n                        B_ASN1_PRINTABLESTRING| \\\n                        B_ASN1_T61STRING| \\\n                        B_ASN1_IA5STRING| \\\n                        B_ASN1_BIT_STRING| \\\n                        B_ASN1_UNIVERSALSTRING|\\\n                        B_ASN1_BMPSTRING|\\\n                        B_ASN1_UTF8STRING|\\\n                        B_ASN1_SEQUENCE|\\\n                        B_ASN1_UNKNOWN\n\n# define B_ASN1_DIRECTORYSTRING \\\n                        B_ASN1_PRINTABLESTRING| \\\n                        B_ASN1_TELETEXSTRING|\\\n                        B_ASN1_BMPSTRING|\\\n                        B_ASN1_UNIVERSALSTRING|\\\n                        B_ASN1_UTF8STRING\n\n# define B_ASN1_DISPLAYTEXT \\\n                        B_ASN1_IA5STRING| \\\n                        B_ASN1_VISIBLESTRING| \\\n                        B_ASN1_BMPSTRING|\\\n                        B_ASN1_UTF8STRING\n\n# define M_ASN1_PRINTABLE_new()  ASN1_STRING_type_new(V_ASN1_T61STRING)\n# define M_ASN1_PRINTABLE_free(a)        ASN1_STRING_free((ASN1_STRING *)a)\n# define M_i2d_ASN1_PRINTABLE(a,pp) i2d_ASN1_bytes((ASN1_STRING *)a,\\\n                pp,a->type,V_ASN1_UNIVERSAL)\n# define M_d2i_ASN1_PRINTABLE(a,pp,l) \\\n                d2i_ASN1_type_bytes((ASN1_STRING **)a,pp,l, \\\n                        B_ASN1_PRINTABLE)\n\n# define M_DIRECTORYSTRING_new() ASN1_STRING_type_new(V_ASN1_PRINTABLESTRING)\n# define M_DIRECTORYSTRING_free(a)       ASN1_STRING_free((ASN1_STRING *)a)\n# define M_i2d_DIRECTORYSTRING(a,pp) i2d_ASN1_bytes((ASN1_STRING *)a,\\\n                                                pp,a->type,V_ASN1_UNIVERSAL)\n# define M_d2i_DIRECTORYSTRING(a,pp,l) \\\n                d2i_ASN1_type_bytes((ASN1_STRING **)a,pp,l, \\\n                        B_ASN1_DIRECTORYSTRING)\n\n# define M_DISPLAYTEXT_new() ASN1_STRING_type_new(V_ASN1_VISIBLESTRING)\n# define M_DISPLAYTEXT_free(a) ASN1_STRING_free((ASN1_STRING *)a)\n# define M_i2d_DISPLAYTEXT(a,pp) i2d_ASN1_bytes((ASN1_STRING *)a,\\\n                                                pp,a->type,V_ASN1_UNIVERSAL)\n# define M_d2i_DISPLAYTEXT(a,pp,l) \\\n                d2i_ASN1_type_bytes((ASN1_STRING **)a,pp,l, \\\n                        B_ASN1_DISPLAYTEXT)\n\n# define M_ASN1_PRINTABLESTRING_new() (ASN1_PRINTABLESTRING *)\\\n                ASN1_STRING_type_new(V_ASN1_PRINTABLESTRING)\n# define M_ASN1_PRINTABLESTRING_free(a)  ASN1_STRING_free((ASN1_STRING *)a)\n# define M_i2d_ASN1_PRINTABLESTRING(a,pp) \\\n                i2d_ASN1_bytes((ASN1_STRING *)a,pp,V_ASN1_PRINTABLESTRING,\\\n                V_ASN1_UNIVERSAL)\n# define M_d2i_ASN1_PRINTABLESTRING(a,pp,l) \\\n                (ASN1_PRINTABLESTRING *)d2i_ASN1_type_bytes\\\n                ((ASN1_STRING **)a,pp,l,B_ASN1_PRINTABLESTRING)\n\n# define M_ASN1_T61STRING_new()  (ASN1_T61STRING *)\\\n                ASN1_STRING_type_new(V_ASN1_T61STRING)\n# define M_ASN1_T61STRING_free(a)        ASN1_STRING_free((ASN1_STRING *)a)\n# define M_i2d_ASN1_T61STRING(a,pp) \\\n                i2d_ASN1_bytes((ASN1_STRING *)a,pp,V_ASN1_T61STRING,\\\n                V_ASN1_UNIVERSAL)\n# define M_d2i_ASN1_T61STRING(a,pp,l) \\\n                (ASN1_T61STRING *)d2i_ASN1_type_bytes\\\n                ((ASN1_STRING **)a,pp,l,B_ASN1_T61STRING)\n\n# define M_ASN1_IA5STRING_new()  (ASN1_IA5STRING *)\\\n                ASN1_STRING_type_new(V_ASN1_IA5STRING)\n# define M_ASN1_IA5STRING_free(a)        ASN1_STRING_free((ASN1_STRING *)a)\n# define M_ASN1_IA5STRING_dup(a) \\\n                (ASN1_IA5STRING *)ASN1_STRING_dup((const ASN1_STRING *)a)\n# define M_i2d_ASN1_IA5STRING(a,pp) \\\n                i2d_ASN1_bytes((ASN1_STRING *)a,pp,V_ASN1_IA5STRING,\\\n                        V_ASN1_UNIVERSAL)\n# define M_d2i_ASN1_IA5STRING(a,pp,l) \\\n                (ASN1_IA5STRING *)d2i_ASN1_type_bytes((ASN1_STRING **)a,pp,l,\\\n                        B_ASN1_IA5STRING)\n\n# define M_ASN1_UTCTIME_new()    (ASN1_UTCTIME *)\\\n                ASN1_STRING_type_new(V_ASN1_UTCTIME)\n# define M_ASN1_UTCTIME_free(a)  ASN1_STRING_free((ASN1_STRING *)a)\n# define M_ASN1_UTCTIME_dup(a) (ASN1_UTCTIME *)\\\n                ASN1_STRING_dup((const ASN1_STRING *)a)\n\n# define M_ASN1_GENERALIZEDTIME_new()    (ASN1_GENERALIZEDTIME *)\\\n                ASN1_STRING_type_new(V_ASN1_GENERALIZEDTIME)\n# define M_ASN1_GENERALIZEDTIME_free(a)  ASN1_STRING_free((ASN1_STRING *)a)\n# define M_ASN1_GENERALIZEDTIME_dup(a) (ASN1_GENERALIZEDTIME *)ASN1_STRING_dup(\\\n        (const ASN1_STRING *)a)\n\n# define M_ASN1_TIME_new()       (ASN1_TIME *)\\\n                ASN1_STRING_type_new(V_ASN1_UTCTIME)\n# define M_ASN1_TIME_free(a)     ASN1_STRING_free((ASN1_STRING *)a)\n# define M_ASN1_TIME_dup(a) (ASN1_TIME *)\\\n        ASN1_STRING_dup((const ASN1_STRING *)a)\n\n# define M_ASN1_GENERALSTRING_new()      (ASN1_GENERALSTRING *)\\\n                ASN1_STRING_type_new(V_ASN1_GENERALSTRING)\n# define M_ASN1_GENERALSTRING_free(a)    ASN1_STRING_free((ASN1_STRING *)a)\n# define M_i2d_ASN1_GENERALSTRING(a,pp) \\\n                i2d_ASN1_bytes((ASN1_STRING *)a,pp,V_ASN1_GENERALSTRING,\\\n                        V_ASN1_UNIVERSAL)\n# define M_d2i_ASN1_GENERALSTRING(a,pp,l) \\\n                (ASN1_GENERALSTRING *)d2i_ASN1_type_bytes\\\n                ((ASN1_STRING **)a,pp,l,B_ASN1_GENERALSTRING)\n\n# define M_ASN1_UNIVERSALSTRING_new()    (ASN1_UNIVERSALSTRING *)\\\n                ASN1_STRING_type_new(V_ASN1_UNIVERSALSTRING)\n# define M_ASN1_UNIVERSALSTRING_free(a)  ASN1_STRING_free((ASN1_STRING *)a)\n# define M_i2d_ASN1_UNIVERSALSTRING(a,pp) \\\n                i2d_ASN1_bytes((ASN1_STRING *)a,pp,V_ASN1_UNIVERSALSTRING,\\\n                        V_ASN1_UNIVERSAL)\n# define M_d2i_ASN1_UNIVERSALSTRING(a,pp,l) \\\n                (ASN1_UNIVERSALSTRING *)d2i_ASN1_type_bytes\\\n                ((ASN1_STRING **)a,pp,l,B_ASN1_UNIVERSALSTRING)\n\n# define M_ASN1_BMPSTRING_new()  (ASN1_BMPSTRING *)\\\n                ASN1_STRING_type_new(V_ASN1_BMPSTRING)\n# define M_ASN1_BMPSTRING_free(a)        ASN1_STRING_free((ASN1_STRING *)a)\n# define M_i2d_ASN1_BMPSTRING(a,pp) \\\n                i2d_ASN1_bytes((ASN1_STRING *)a,pp,V_ASN1_BMPSTRING,\\\n                        V_ASN1_UNIVERSAL)\n# define M_d2i_ASN1_BMPSTRING(a,pp,l) \\\n                (ASN1_BMPSTRING *)d2i_ASN1_type_bytes\\\n                ((ASN1_STRING **)a,pp,l,B_ASN1_BMPSTRING)\n\n# define M_ASN1_VISIBLESTRING_new()      (ASN1_VISIBLESTRING *)\\\n                ASN1_STRING_type_new(V_ASN1_VISIBLESTRING)\n# define M_ASN1_VISIBLESTRING_free(a)    ASN1_STRING_free((ASN1_STRING *)a)\n# define M_i2d_ASN1_VISIBLESTRING(a,pp) \\\n                i2d_ASN1_bytes((ASN1_STRING *)a,pp,V_ASN1_VISIBLESTRING,\\\n                        V_ASN1_UNIVERSAL)\n# define M_d2i_ASN1_VISIBLESTRING(a,pp,l) \\\n                (ASN1_VISIBLESTRING *)d2i_ASN1_type_bytes\\\n                ((ASN1_STRING **)a,pp,l,B_ASN1_VISIBLESTRING)\n\n# define M_ASN1_UTF8STRING_new() (ASN1_UTF8STRING *)\\\n                ASN1_STRING_type_new(V_ASN1_UTF8STRING)\n# define M_ASN1_UTF8STRING_free(a)       ASN1_STRING_free((ASN1_STRING *)a)\n# define M_i2d_ASN1_UTF8STRING(a,pp) \\\n                i2d_ASN1_bytes((ASN1_STRING *)a,pp,V_ASN1_UTF8STRING,\\\n                        V_ASN1_UNIVERSAL)\n# define M_d2i_ASN1_UTF8STRING(a,pp,l) \\\n                (ASN1_UTF8STRING *)d2i_ASN1_type_bytes\\\n                ((ASN1_STRING **)a,pp,l,B_ASN1_UTF8STRING)\n\n  /* for the is_set parameter to i2d_ASN1_SET */\n# define IS_SEQUENCE     0\n# define IS_SET          1\n\nDECLARE_ASN1_FUNCTIONS_fname(ASN1_TYPE, ASN1_ANY, ASN1_TYPE)\n\nint ASN1_TYPE_get(ASN1_TYPE *a);\nvoid ASN1_TYPE_set(ASN1_TYPE *a, int type, void *value);\nint ASN1_TYPE_set1(ASN1_TYPE *a, int type, const void *value);\nint ASN1_TYPE_cmp(const ASN1_TYPE *a, const ASN1_TYPE *b);\n\nASN1_OBJECT *ASN1_OBJECT_new(void);\nvoid ASN1_OBJECT_free(ASN1_OBJECT *a);\nint i2d_ASN1_OBJECT(ASN1_OBJECT *a, unsigned char **pp);\nASN1_OBJECT *c2i_ASN1_OBJECT(ASN1_OBJECT **a, const unsigned char **pp,\n                             long length);\nASN1_OBJECT *d2i_ASN1_OBJECT(ASN1_OBJECT **a, const unsigned char **pp,\n                             long length);\n\nDECLARE_ASN1_ITEM(ASN1_OBJECT)\n\nDECLARE_STACK_OF(ASN1_OBJECT)\nDECLARE_ASN1_SET_OF(ASN1_OBJECT)\n\nASN1_STRING *ASN1_STRING_new(void);\nvoid ASN1_STRING_free(ASN1_STRING *a);\nvoid ASN1_STRING_clear_free(ASN1_STRING *a);\nint ASN1_STRING_copy(ASN1_STRING *dst, const ASN1_STRING *str);\nASN1_STRING *ASN1_STRING_dup(const ASN1_STRING *a);\nASN1_STRING *ASN1_STRING_type_new(int type);\nint ASN1_STRING_cmp(const ASN1_STRING *a, const ASN1_STRING *b);\n  /*\n   * Since this is used to store all sorts of things, via macros, for now,\n   * make its data void *\n   */\nint ASN1_STRING_set(ASN1_STRING *str, const void *data, int len);\nvoid ASN1_STRING_set0(ASN1_STRING *str, void *data, int len);\nint ASN1_STRING_length(const ASN1_STRING *x);\nvoid ASN1_STRING_length_set(ASN1_STRING *x, int n);\nint ASN1_STRING_type(ASN1_STRING *x);\nunsigned char *ASN1_STRING_data(ASN1_STRING *x);\n\nDECLARE_ASN1_FUNCTIONS(ASN1_BIT_STRING)\nint i2c_ASN1_BIT_STRING(ASN1_BIT_STRING *a, unsigned char **pp);\nASN1_BIT_STRING *c2i_ASN1_BIT_STRING(ASN1_BIT_STRING **a,\n                                     const unsigned char **pp, long length);\nint ASN1_BIT_STRING_set(ASN1_BIT_STRING *a, unsigned char *d, int length);\nint ASN1_BIT_STRING_set_bit(ASN1_BIT_STRING *a, int n, int value);\nint ASN1_BIT_STRING_get_bit(ASN1_BIT_STRING *a, int n);\nint ASN1_BIT_STRING_check(ASN1_BIT_STRING *a,\n                          unsigned char *flags, int flags_len);\n\n# ifndef OPENSSL_NO_BIO\nint ASN1_BIT_STRING_name_print(BIO *out, ASN1_BIT_STRING *bs,\n                               BIT_STRING_BITNAME *tbl, int indent);\n# endif\nint ASN1_BIT_STRING_num_asc(char *name, BIT_STRING_BITNAME *tbl);\nint ASN1_BIT_STRING_set_asc(ASN1_BIT_STRING *bs, char *name, int value,\n                            BIT_STRING_BITNAME *tbl);\n\nint i2d_ASN1_BOOLEAN(int a, unsigned char **pp);\nint d2i_ASN1_BOOLEAN(int *a, const unsigned char **pp, long length);\n\nDECLARE_ASN1_FUNCTIONS(ASN1_INTEGER)\nint i2c_ASN1_INTEGER(ASN1_INTEGER *a, unsigned char **pp);\nASN1_INTEGER *c2i_ASN1_INTEGER(ASN1_INTEGER **a, const unsigned char **pp,\n                               long length);\nASN1_INTEGER *d2i_ASN1_UINTEGER(ASN1_INTEGER **a, const unsigned char **pp,\n                                long length);\nASN1_INTEGER *ASN1_INTEGER_dup(const ASN1_INTEGER *x);\nint ASN1_INTEGER_cmp(const ASN1_INTEGER *x, const ASN1_INTEGER *y);\n\nDECLARE_ASN1_FUNCTIONS(ASN1_ENUMERATED)\n\nint ASN1_UTCTIME_check(const ASN1_UTCTIME *a);\nASN1_UTCTIME *ASN1_UTCTIME_set(ASN1_UTCTIME *s, time_t t);\nASN1_UTCTIME *ASN1_UTCTIME_adj(ASN1_UTCTIME *s, time_t t,\n                               int offset_day, long offset_sec);\nint ASN1_UTCTIME_set_string(ASN1_UTCTIME *s, const char *str);\nint ASN1_UTCTIME_cmp_time_t(const ASN1_UTCTIME *s, time_t t);\n# if 0\ntime_t ASN1_UTCTIME_get(const ASN1_UTCTIME *s);\n# endif\n\nint ASN1_GENERALIZEDTIME_check(const ASN1_GENERALIZEDTIME *a);\nASN1_GENERALIZEDTIME *ASN1_GENERALIZEDTIME_set(ASN1_GENERALIZEDTIME *s,\n                                               time_t t);\nASN1_GENERALIZEDTIME *ASN1_GENERALIZEDTIME_adj(ASN1_GENERALIZEDTIME *s,\n                                               time_t t, int offset_day,\n                                               long offset_sec);\nint ASN1_GENERALIZEDTIME_set_string(ASN1_GENERALIZEDTIME *s, const char *str);\nint ASN1_TIME_diff(int *pday, int *psec,\n                   const ASN1_TIME *from, const ASN1_TIME *to);\n\nDECLARE_ASN1_FUNCTIONS(ASN1_OCTET_STRING)\nASN1_OCTET_STRING *ASN1_OCTET_STRING_dup(const ASN1_OCTET_STRING *a);\nint ASN1_OCTET_STRING_cmp(const ASN1_OCTET_STRING *a,\n                          const ASN1_OCTET_STRING *b);\nint ASN1_OCTET_STRING_set(ASN1_OCTET_STRING *str, const unsigned char *data,\n                          int len);\n\nDECLARE_ASN1_FUNCTIONS(ASN1_VISIBLESTRING)\nDECLARE_ASN1_FUNCTIONS(ASN1_UNIVERSALSTRING)\nDECLARE_ASN1_FUNCTIONS(ASN1_UTF8STRING)\nDECLARE_ASN1_FUNCTIONS(ASN1_NULL)\nDECLARE_ASN1_FUNCTIONS(ASN1_BMPSTRING)\n\nint UTF8_getc(const unsigned char *str, int len, unsigned long *val);\nint UTF8_putc(unsigned char *str, int len, unsigned long value);\n\nDECLARE_ASN1_FUNCTIONS_name(ASN1_STRING, ASN1_PRINTABLE)\n\nDECLARE_ASN1_FUNCTIONS_name(ASN1_STRING, DIRECTORYSTRING)\nDECLARE_ASN1_FUNCTIONS_name(ASN1_STRING, DISPLAYTEXT)\nDECLARE_ASN1_FUNCTIONS(ASN1_PRINTABLESTRING)\nDECLARE_ASN1_FUNCTIONS(ASN1_T61STRING)\nDECLARE_ASN1_FUNCTIONS(ASN1_IA5STRING)\nDECLARE_ASN1_FUNCTIONS(ASN1_GENERALSTRING)\nDECLARE_ASN1_FUNCTIONS(ASN1_UTCTIME)\nDECLARE_ASN1_FUNCTIONS(ASN1_GENERALIZEDTIME)\nDECLARE_ASN1_FUNCTIONS(ASN1_TIME)\n\nDECLARE_ASN1_ITEM(ASN1_OCTET_STRING_NDEF)\n\nASN1_TIME *ASN1_TIME_set(ASN1_TIME *s, time_t t);\nASN1_TIME *ASN1_TIME_adj(ASN1_TIME *s, time_t t,\n                         int offset_day, long offset_sec);\nint ASN1_TIME_check(ASN1_TIME *t);\nASN1_GENERALIZEDTIME *ASN1_TIME_to_generalizedtime(ASN1_TIME *t, ASN1_GENERALIZEDTIME\n                                                   **out);\nint ASN1_TIME_set_string(ASN1_TIME *s, const char *str);\n\nint i2d_ASN1_SET(STACK_OF(OPENSSL_BLOCK) *a, unsigned char **pp,\n                 i2d_of_void *i2d, int ex_tag, int ex_class, int is_set);\nSTACK_OF(OPENSSL_BLOCK) *d2i_ASN1_SET(STACK_OF(OPENSSL_BLOCK) **a,\n                                      const unsigned char **pp,\n                                      long length, d2i_of_void *d2i,\n                                      void (*free_func) (OPENSSL_BLOCK),\n                                      int ex_tag, int ex_class);\n\n# ifndef OPENSSL_NO_BIO\nint i2a_ASN1_INTEGER(BIO *bp, ASN1_INTEGER *a);\nint a2i_ASN1_INTEGER(BIO *bp, ASN1_INTEGER *bs, char *buf, int size);\nint i2a_ASN1_ENUMERATED(BIO *bp, ASN1_ENUMERATED *a);\nint a2i_ASN1_ENUMERATED(BIO *bp, ASN1_ENUMERATED *bs, char *buf, int size);\nint i2a_ASN1_OBJECT(BIO *bp, ASN1_OBJECT *a);\nint a2i_ASN1_STRING(BIO *bp, ASN1_STRING *bs, char *buf, int size);\nint i2a_ASN1_STRING(BIO *bp, ASN1_STRING *a, int type);\n# endif\nint i2t_ASN1_OBJECT(char *buf, int buf_len, ASN1_OBJECT *a);\n\nint a2d_ASN1_OBJECT(unsigned char *out, int olen, const char *buf, int num);\nASN1_OBJECT *ASN1_OBJECT_create(int nid, unsigned char *data, int len,\n                                const char *sn, const char *ln);\n\nint ASN1_INTEGER_set(ASN1_INTEGER *a, long v);\nlong ASN1_INTEGER_get(const ASN1_INTEGER *a);\nASN1_INTEGER *BN_to_ASN1_INTEGER(const BIGNUM *bn, ASN1_INTEGER *ai);\nBIGNUM *ASN1_INTEGER_to_BN(const ASN1_INTEGER *ai, BIGNUM *bn);\n\nint ASN1_ENUMERATED_set(ASN1_ENUMERATED *a, long v);\nlong ASN1_ENUMERATED_get(ASN1_ENUMERATED *a);\nASN1_ENUMERATED *BN_to_ASN1_ENUMERATED(BIGNUM *bn, ASN1_ENUMERATED *ai);\nBIGNUM *ASN1_ENUMERATED_to_BN(ASN1_ENUMERATED *ai, BIGNUM *bn);\n\n/* General */\n/* given a string, return the correct type, max is the maximum length */\nint ASN1_PRINTABLE_type(const unsigned char *s, int max);\n\nint i2d_ASN1_bytes(ASN1_STRING *a, unsigned char **pp, int tag, int xclass);\nASN1_STRING *d2i_ASN1_bytes(ASN1_STRING **a, const unsigned char **pp,\n                            long length, int Ptag, int Pclass);\nunsigned long ASN1_tag2bit(int tag);\n/* type is one or more of the B_ASN1_ values. */\nASN1_STRING *d2i_ASN1_type_bytes(ASN1_STRING **a, const unsigned char **pp,\n                                 long length, int type);\n\n/* PARSING */\nint asn1_Finish(ASN1_CTX *c);\nint asn1_const_Finish(ASN1_const_CTX *c);\n\n/* SPECIALS */\nint ASN1_get_object(const unsigned char **pp, long *plength, int *ptag,\n                    int *pclass, long omax);\nint ASN1_check_infinite_end(unsigned char **p, long len);\nint ASN1_const_check_infinite_end(const unsigned char **p, long len);\nvoid ASN1_put_object(unsigned char **pp, int constructed, int length,\n                     int tag, int xclass);\nint ASN1_put_eoc(unsigned char **pp);\nint ASN1_object_size(int constructed, int length, int tag);\n\n/* Used to implement other functions */\nvoid *ASN1_dup(i2d_of_void *i2d, d2i_of_void *d2i, void *x);\n\n# define ASN1_dup_of(type,i2d,d2i,x) \\\n    ((type*)ASN1_dup(CHECKED_I2D_OF(type, i2d), \\\n                     CHECKED_D2I_OF(type, d2i), \\\n                     CHECKED_PTR_OF(type, x)))\n\n# define ASN1_dup_of_const(type,i2d,d2i,x) \\\n    ((type*)ASN1_dup(CHECKED_I2D_OF(const type, i2d), \\\n                     CHECKED_D2I_OF(type, d2i), \\\n                     CHECKED_PTR_OF(const type, x)))\n\nvoid *ASN1_item_dup(const ASN1_ITEM *it, void *x);\n\n/* ASN1 alloc/free macros for when a type is only used internally */\n\n# define M_ASN1_new_of(type) (type *)ASN1_item_new(ASN1_ITEM_rptr(type))\n# define M_ASN1_free_of(x, type) \\\n                ASN1_item_free(CHECKED_PTR_OF(type, x), ASN1_ITEM_rptr(type))\n\n# ifndef OPENSSL_NO_FP_API\nvoid *ASN1_d2i_fp(void *(*xnew) (void), d2i_of_void *d2i, FILE *in, void **x);\n\n#  define ASN1_d2i_fp_of(type,xnew,d2i,in,x) \\\n    ((type*)ASN1_d2i_fp(CHECKED_NEW_OF(type, xnew), \\\n                        CHECKED_D2I_OF(type, d2i), \\\n                        in, \\\n                        CHECKED_PPTR_OF(type, x)))\n\nvoid *ASN1_item_d2i_fp(const ASN1_ITEM *it, FILE *in, void *x);\nint ASN1_i2d_fp(i2d_of_void *i2d, FILE *out, void *x);\n\n#  define ASN1_i2d_fp_of(type,i2d,out,x) \\\n    (ASN1_i2d_fp(CHECKED_I2D_OF(type, i2d), \\\n                 out, \\\n                 CHECKED_PTR_OF(type, x)))\n\n#  define ASN1_i2d_fp_of_const(type,i2d,out,x) \\\n    (ASN1_i2d_fp(CHECKED_I2D_OF(const type, i2d), \\\n                 out, \\\n                 CHECKED_PTR_OF(const type, x)))\n\nint ASN1_item_i2d_fp(const ASN1_ITEM *it, FILE *out, void *x);\nint ASN1_STRING_print_ex_fp(FILE *fp, ASN1_STRING *str, unsigned long flags);\n# endif\n\nint ASN1_STRING_to_UTF8(unsigned char **out, ASN1_STRING *in);\n\n# ifndef OPENSSL_NO_BIO\nvoid *ASN1_d2i_bio(void *(*xnew) (void), d2i_of_void *d2i, BIO *in, void **x);\n\n#  define ASN1_d2i_bio_of(type,xnew,d2i,in,x) \\\n    ((type*)ASN1_d2i_bio( CHECKED_NEW_OF(type, xnew), \\\n                          CHECKED_D2I_OF(type, d2i), \\\n                          in, \\\n                          CHECKED_PPTR_OF(type, x)))\n\nvoid *ASN1_item_d2i_bio(const ASN1_ITEM *it, BIO *in, void *x);\nint ASN1_i2d_bio(i2d_of_void *i2d, BIO *out, unsigned char *x);\n\n#  define ASN1_i2d_bio_of(type,i2d,out,x) \\\n    (ASN1_i2d_bio(CHECKED_I2D_OF(type, i2d), \\\n                  out, \\\n                  CHECKED_PTR_OF(type, x)))\n\n#  define ASN1_i2d_bio_of_const(type,i2d,out,x) \\\n    (ASN1_i2d_bio(CHECKED_I2D_OF(const type, i2d), \\\n                  out, \\\n                  CHECKED_PTR_OF(const type, x)))\n\nint ASN1_item_i2d_bio(const ASN1_ITEM *it, BIO *out, void *x);\nint ASN1_UTCTIME_print(BIO *fp, const ASN1_UTCTIME *a);\nint ASN1_GENERALIZEDTIME_print(BIO *fp, const ASN1_GENERALIZEDTIME *a);\nint ASN1_TIME_print(BIO *fp, const ASN1_TIME *a);\nint ASN1_STRING_print(BIO *bp, const ASN1_STRING *v);\nint ASN1_STRING_print_ex(BIO *out, ASN1_STRING *str, unsigned long flags);\nint ASN1_bn_print(BIO *bp, const char *number, const BIGNUM *num,\n                  unsigned char *buf, int off);\nint ASN1_parse(BIO *bp, const unsigned char *pp, long len, int indent);\nint ASN1_parse_dump(BIO *bp, const unsigned char *pp, long len, int indent,\n                    int dump);\n# endif\nconst char *ASN1_tag2str(int tag);\n\n/* Used to load and write netscape format cert */\n\nDECLARE_ASN1_FUNCTIONS(NETSCAPE_X509)\n\nint ASN1_UNIVERSALSTRING_to_string(ASN1_UNIVERSALSTRING *s);\n\nint ASN1_TYPE_set_octetstring(ASN1_TYPE *a, unsigned char *data, int len);\nint ASN1_TYPE_get_octetstring(ASN1_TYPE *a, unsigned char *data, int max_len);\nint ASN1_TYPE_set_int_octetstring(ASN1_TYPE *a, long num,\n                                  unsigned char *data, int len);\nint ASN1_TYPE_get_int_octetstring(ASN1_TYPE *a, long *num,\n                                  unsigned char *data, int max_len);\n\nSTACK_OF(OPENSSL_BLOCK) *ASN1_seq_unpack(const unsigned char *buf, int len,\n                                         d2i_of_void *d2i,\n                                         void (*free_func) (OPENSSL_BLOCK));\nunsigned char *ASN1_seq_pack(STACK_OF(OPENSSL_BLOCK) *safes, i2d_of_void *i2d,\n                             unsigned char **buf, int *len);\nvoid *ASN1_unpack_string(ASN1_STRING *oct, d2i_of_void *d2i);\nvoid *ASN1_item_unpack(ASN1_STRING *oct, const ASN1_ITEM *it);\nASN1_STRING *ASN1_pack_string(void *obj, i2d_of_void *i2d,\n                              ASN1_OCTET_STRING **oct);\n\n# define ASN1_pack_string_of(type,obj,i2d,oct) \\\n    (ASN1_pack_string(CHECKED_PTR_OF(type, obj), \\\n                      CHECKED_I2D_OF(type, i2d), \\\n                      oct))\n\nASN1_STRING *ASN1_item_pack(void *obj, const ASN1_ITEM *it,\n                            ASN1_OCTET_STRING **oct);\n\nvoid ASN1_STRING_set_default_mask(unsigned long mask);\nint ASN1_STRING_set_default_mask_asc(const char *p);\nunsigned long ASN1_STRING_get_default_mask(void);\nint ASN1_mbstring_copy(ASN1_STRING **out, const unsigned char *in, int len,\n                       int inform, unsigned long mask);\nint ASN1_mbstring_ncopy(ASN1_STRING **out, const unsigned char *in, int len,\n                        int inform, unsigned long mask,\n                        long minsize, long maxsize);\n\nASN1_STRING *ASN1_STRING_set_by_NID(ASN1_STRING **out,\n                                    const unsigned char *in, int inlen,\n                                    int inform, int nid);\nASN1_STRING_TABLE *ASN1_STRING_TABLE_get(int nid);\nint ASN1_STRING_TABLE_add(int, long, long, unsigned long, unsigned long);\nvoid ASN1_STRING_TABLE_cleanup(void);\n\n/* ASN1 template functions */\n\n/* Old API compatible functions */\nASN1_VALUE *ASN1_item_new(const ASN1_ITEM *it);\nvoid ASN1_item_free(ASN1_VALUE *val, const ASN1_ITEM *it);\nASN1_VALUE *ASN1_item_d2i(ASN1_VALUE **val, const unsigned char **in,\n                          long len, const ASN1_ITEM *it);\nint ASN1_item_i2d(ASN1_VALUE *val, unsigned char **out, const ASN1_ITEM *it);\nint ASN1_item_ndef_i2d(ASN1_VALUE *val, unsigned char **out,\n                       const ASN1_ITEM *it);\n\nvoid ASN1_add_oid_module(void);\n\nASN1_TYPE *ASN1_generate_nconf(char *str, CONF *nconf);\nASN1_TYPE *ASN1_generate_v3(char *str, X509V3_CTX *cnf);\n\n/* ASN1 Print flags */\n\n/* Indicate missing OPTIONAL fields */\n# define ASN1_PCTX_FLAGS_SHOW_ABSENT             0x001\n/* Mark start and end of SEQUENCE */\n# define ASN1_PCTX_FLAGS_SHOW_SEQUENCE           0x002\n/* Mark start and end of SEQUENCE/SET OF */\n# define ASN1_PCTX_FLAGS_SHOW_SSOF               0x004\n/* Show the ASN1 type of primitives */\n# define ASN1_PCTX_FLAGS_SHOW_TYPE               0x008\n/* Don't show ASN1 type of ANY */\n# define ASN1_PCTX_FLAGS_NO_ANY_TYPE             0x010\n/* Don't show ASN1 type of MSTRINGs */\n# define ASN1_PCTX_FLAGS_NO_MSTRING_TYPE         0x020\n/* Don't show field names in SEQUENCE */\n# define ASN1_PCTX_FLAGS_NO_FIELD_NAME           0x040\n/* Show structure names of each SEQUENCE field */\n# define ASN1_PCTX_FLAGS_SHOW_FIELD_STRUCT_NAME  0x080\n/* Don't show structure name even at top level */\n# define ASN1_PCTX_FLAGS_NO_STRUCT_NAME          0x100\n\nint ASN1_item_print(BIO *out, ASN1_VALUE *ifld, int indent,\n                    const ASN1_ITEM *it, const ASN1_PCTX *pctx);\nASN1_PCTX *ASN1_PCTX_new(void);\nvoid ASN1_PCTX_free(ASN1_PCTX *p);\nunsigned long ASN1_PCTX_get_flags(ASN1_PCTX *p);\nvoid ASN1_PCTX_set_flags(ASN1_PCTX *p, unsigned long flags);\nunsigned long ASN1_PCTX_get_nm_flags(ASN1_PCTX *p);\nvoid ASN1_PCTX_set_nm_flags(ASN1_PCTX *p, unsigned long flags);\nunsigned long ASN1_PCTX_get_cert_flags(ASN1_PCTX *p);\nvoid ASN1_PCTX_set_cert_flags(ASN1_PCTX *p, unsigned long flags);\nunsigned long ASN1_PCTX_get_oid_flags(ASN1_PCTX *p);\nvoid ASN1_PCTX_set_oid_flags(ASN1_PCTX *p, unsigned long flags);\nunsigned long ASN1_PCTX_get_str_flags(ASN1_PCTX *p);\nvoid ASN1_PCTX_set_str_flags(ASN1_PCTX *p, unsigned long flags);\n\nBIO_METHOD *BIO_f_asn1(void);\n\nBIO *BIO_new_NDEF(BIO *out, ASN1_VALUE *val, const ASN1_ITEM *it);\n\nint i2d_ASN1_bio_stream(BIO *out, ASN1_VALUE *val, BIO *in, int flags,\n                        const ASN1_ITEM *it);\nint PEM_write_bio_ASN1_stream(BIO *out, ASN1_VALUE *val, BIO *in, int flags,\n                              const char *hdr, const ASN1_ITEM *it);\nint SMIME_write_ASN1(BIO *bio, ASN1_VALUE *val, BIO *data, int flags,\n                     int ctype_nid, int econt_nid,\n                     STACK_OF(X509_ALGOR) *mdalgs, const ASN1_ITEM *it);\nASN1_VALUE *SMIME_read_ASN1(BIO *bio, BIO **bcont, const ASN1_ITEM *it);\nint SMIME_crlf_copy(BIO *in, BIO *out, int flags);\nint SMIME_text(BIO *in, BIO *out);\n\n/* BEGIN ERROR CODES */\n/*\n * The following lines are auto generated by the script mkerr.pl. Any changes\n * made after this point may be overwritten when the script is next run.\n */\nvoid ERR_load_ASN1_strings(void);\n\n/* Error codes for the ASN1 functions. */\n\n/* Function codes. */\n# define ASN1_F_A2D_ASN1_OBJECT                           100\n# define ASN1_F_A2I_ASN1_ENUMERATED                       101\n# define ASN1_F_A2I_ASN1_INTEGER                          102\n# define ASN1_F_A2I_ASN1_STRING                           103\n# define ASN1_F_APPEND_EXP                                176\n# define ASN1_F_ASN1_BIT_STRING_SET_BIT                   183\n# define ASN1_F_ASN1_CB                                   177\n# define ASN1_F_ASN1_CHECK_TLEN                           104\n# define ASN1_F_ASN1_COLLATE_PRIMITIVE                    105\n# define ASN1_F_ASN1_COLLECT                              106\n# define ASN1_F_ASN1_D2I_EX_PRIMITIVE                     108\n# define ASN1_F_ASN1_D2I_FP                               109\n# define ASN1_F_ASN1_D2I_READ_BIO                         107\n# define ASN1_F_ASN1_DIGEST                               184\n# define ASN1_F_ASN1_DO_ADB                               110\n# define ASN1_F_ASN1_DUP                                  111\n# define ASN1_F_ASN1_ENUMERATED_SET                       112\n# define ASN1_F_ASN1_ENUMERATED_TO_BN                     113\n# define ASN1_F_ASN1_EX_C2I                               204\n# define ASN1_F_ASN1_FIND_END                             190\n# define ASN1_F_ASN1_GENERALIZEDTIME_ADJ                  216\n# define ASN1_F_ASN1_GENERALIZEDTIME_SET                  185\n# define ASN1_F_ASN1_GENERATE_V3                          178\n# define ASN1_F_ASN1_GET_OBJECT                           114\n# define ASN1_F_ASN1_HEADER_NEW                           115\n# define ASN1_F_ASN1_I2D_BIO                              116\n# define ASN1_F_ASN1_I2D_FP                               117\n# define ASN1_F_ASN1_INTEGER_SET                          118\n# define ASN1_F_ASN1_INTEGER_TO_BN                        119\n# define ASN1_F_ASN1_ITEM_D2I_FP                          206\n# define ASN1_F_ASN1_ITEM_DUP                             191\n# define ASN1_F_ASN1_ITEM_EX_COMBINE_NEW                  121\n# define ASN1_F_ASN1_ITEM_EX_D2I                          120\n# define ASN1_F_ASN1_ITEM_I2D_BIO                         192\n# define ASN1_F_ASN1_ITEM_I2D_FP                          193\n# define ASN1_F_ASN1_ITEM_PACK                            198\n# define ASN1_F_ASN1_ITEM_SIGN                            195\n# define ASN1_F_ASN1_ITEM_SIGN_CTX                        220\n# define ASN1_F_ASN1_ITEM_UNPACK                          199\n# define ASN1_F_ASN1_ITEM_VERIFY                          197\n# define ASN1_F_ASN1_MBSTRING_NCOPY                       122\n# define ASN1_F_ASN1_OBJECT_NEW                           123\n# define ASN1_F_ASN1_OUTPUT_DATA                          214\n# define ASN1_F_ASN1_PACK_STRING                          124\n# define ASN1_F_ASN1_PCTX_NEW                             205\n# define ASN1_F_ASN1_PKCS5_PBE_SET                        125\n# define ASN1_F_ASN1_SEQ_PACK                             126\n# define ASN1_F_ASN1_SEQ_UNPACK                           127\n# define ASN1_F_ASN1_SIGN                                 128\n# define ASN1_F_ASN1_STR2TYPE                             179\n# define ASN1_F_ASN1_STRING_SET                           186\n# define ASN1_F_ASN1_STRING_TABLE_ADD                     129\n# define ASN1_F_ASN1_STRING_TYPE_NEW                      130\n# define ASN1_F_ASN1_TEMPLATE_EX_D2I                      132\n# define ASN1_F_ASN1_TEMPLATE_NEW                         133\n# define ASN1_F_ASN1_TEMPLATE_NOEXP_D2I                   131\n# define ASN1_F_ASN1_TIME_ADJ                             217\n# define ASN1_F_ASN1_TIME_SET                             175\n# define ASN1_F_ASN1_TYPE_GET_INT_OCTETSTRING             134\n# define ASN1_F_ASN1_TYPE_GET_OCTETSTRING                 135\n# define ASN1_F_ASN1_UNPACK_STRING                        136\n# define ASN1_F_ASN1_UTCTIME_ADJ                          218\n# define ASN1_F_ASN1_UTCTIME_SET                          187\n# define ASN1_F_ASN1_VERIFY                               137\n# define ASN1_F_B64_READ_ASN1                             209\n# define ASN1_F_B64_WRITE_ASN1                            210\n# define ASN1_F_BIO_NEW_NDEF                              208\n# define ASN1_F_BITSTR_CB                                 180\n# define ASN1_F_BN_TO_ASN1_ENUMERATED                     138\n# define ASN1_F_BN_TO_ASN1_INTEGER                        139\n# define ASN1_F_C2I_ASN1_BIT_STRING                       189\n# define ASN1_F_C2I_ASN1_INTEGER                          194\n# define ASN1_F_C2I_ASN1_OBJECT                           196\n# define ASN1_F_COLLECT_DATA                              140\n# define ASN1_F_D2I_ASN1_BIT_STRING                       141\n# define ASN1_F_D2I_ASN1_BOOLEAN                          142\n# define ASN1_F_D2I_ASN1_BYTES                            143\n# define ASN1_F_D2I_ASN1_GENERALIZEDTIME                  144\n# define ASN1_F_D2I_ASN1_HEADER                           145\n# define ASN1_F_D2I_ASN1_INTEGER                          146\n# define ASN1_F_D2I_ASN1_OBJECT                           147\n# define ASN1_F_D2I_ASN1_SET                              148\n# define ASN1_F_D2I_ASN1_TYPE_BYTES                       149\n# define ASN1_F_D2I_ASN1_UINTEGER                         150\n# define ASN1_F_D2I_ASN1_UTCTIME                          151\n# define ASN1_F_D2I_AUTOPRIVATEKEY                        207\n# define ASN1_F_D2I_NETSCAPE_RSA                          152\n# define ASN1_F_D2I_NETSCAPE_RSA_2                        153\n# define ASN1_F_D2I_PRIVATEKEY                            154\n# define ASN1_F_D2I_PUBLICKEY                             155\n# define ASN1_F_D2I_RSA_NET                               200\n# define ASN1_F_D2I_RSA_NET_2                             201\n# define ASN1_F_D2I_X509                                  156\n# define ASN1_F_D2I_X509_CINF                             157\n# define ASN1_F_D2I_X509_PKEY                             159\n# define ASN1_F_I2D_ASN1_BIO_STREAM                       211\n# define ASN1_F_I2D_ASN1_SET                              188\n# define ASN1_F_I2D_ASN1_TIME                             160\n# define ASN1_F_I2D_DSA_PUBKEY                            161\n# define ASN1_F_I2D_EC_PUBKEY                             181\n# define ASN1_F_I2D_PRIVATEKEY                            163\n# define ASN1_F_I2D_PUBLICKEY                             164\n# define ASN1_F_I2D_RSA_NET                               162\n# define ASN1_F_I2D_RSA_PUBKEY                            165\n# define ASN1_F_LONG_C2I                                  166\n# define ASN1_F_OID_MODULE_INIT                           174\n# define ASN1_F_PARSE_TAGGING                             182\n# define ASN1_F_PKCS5_PBE2_SET_IV                         167\n# define ASN1_F_PKCS5_PBE_SET                             202\n# define ASN1_F_PKCS5_PBE_SET0_ALGOR                      215\n# define ASN1_F_PKCS5_PBKDF2_SET                          219\n# define ASN1_F_SMIME_READ_ASN1                           212\n# define ASN1_F_SMIME_TEXT                                213\n# define ASN1_F_X509_CINF_NEW                             168\n# define ASN1_F_X509_CRL_ADD0_REVOKED                     169\n# define ASN1_F_X509_INFO_NEW                             170\n# define ASN1_F_X509_NAME_ENCODE                          203\n# define ASN1_F_X509_NAME_EX_D2I                          158\n# define ASN1_F_X509_NAME_EX_NEW                          171\n# define ASN1_F_X509_NEW                                  172\n# define ASN1_F_X509_PKEY_NEW                             173\n\n/* Reason codes. */\n# define ASN1_R_ADDING_OBJECT                             171\n# define ASN1_R_ASN1_PARSE_ERROR                          203\n# define ASN1_R_ASN1_SIG_PARSE_ERROR                      204\n# define ASN1_R_AUX_ERROR                                 100\n# define ASN1_R_BAD_CLASS                                 101\n# define ASN1_R_BAD_OBJECT_HEADER                         102\n# define ASN1_R_BAD_PASSWORD_READ                         103\n# define ASN1_R_BAD_TAG                                   104\n# define ASN1_R_BMPSTRING_IS_WRONG_LENGTH                 214\n# define ASN1_R_BN_LIB                                    105\n# define ASN1_R_BOOLEAN_IS_WRONG_LENGTH                   106\n# define ASN1_R_BUFFER_TOO_SMALL                          107\n# define ASN1_R_CIPHER_HAS_NO_OBJECT_IDENTIFIER           108\n# define ASN1_R_CONTEXT_NOT_INITIALISED                   217\n# define ASN1_R_DATA_IS_WRONG                             109\n# define ASN1_R_DECODE_ERROR                              110\n# define ASN1_R_DECODING_ERROR                            111\n# define ASN1_R_DEPTH_EXCEEDED                            174\n# define ASN1_R_DIGEST_AND_KEY_TYPE_NOT_SUPPORTED         198\n# define ASN1_R_ENCODE_ERROR                              112\n# define ASN1_R_ERROR_GETTING_TIME                        173\n# define ASN1_R_ERROR_LOADING_SECTION                     172\n# define ASN1_R_ERROR_PARSING_SET_ELEMENT                 113\n# define ASN1_R_ERROR_SETTING_CIPHER_PARAMS               114\n# define ASN1_R_EXPECTING_AN_INTEGER                      115\n# define ASN1_R_EXPECTING_AN_OBJECT                       116\n# define ASN1_R_EXPECTING_A_BOOLEAN                       117\n# define ASN1_R_EXPECTING_A_TIME                          118\n# define ASN1_R_EXPLICIT_LENGTH_MISMATCH                  119\n# define ASN1_R_EXPLICIT_TAG_NOT_CONSTRUCTED              120\n# define ASN1_R_FIELD_MISSING                             121\n# define ASN1_R_FIRST_NUM_TOO_LARGE                       122\n# define ASN1_R_HEADER_TOO_LONG                           123\n# define ASN1_R_ILLEGAL_BITSTRING_FORMAT                  175\n# define ASN1_R_ILLEGAL_BOOLEAN                           176\n# define ASN1_R_ILLEGAL_CHARACTERS                        124\n# define ASN1_R_ILLEGAL_FORMAT                            177\n# define ASN1_R_ILLEGAL_HEX                               178\n# define ASN1_R_ILLEGAL_IMPLICIT_TAG                      179\n# define ASN1_R_ILLEGAL_INTEGER                           180\n# define ASN1_R_ILLEGAL_NESTED_TAGGING                    181\n# define ASN1_R_ILLEGAL_NULL                              125\n# define ASN1_R_ILLEGAL_NULL_VALUE                        182\n# define ASN1_R_ILLEGAL_OBJECT                            183\n# define ASN1_R_ILLEGAL_OPTIONAL_ANY                      126\n# define ASN1_R_ILLEGAL_OPTIONS_ON_ITEM_TEMPLATE          170\n# define ASN1_R_ILLEGAL_TAGGED_ANY                        127\n# define ASN1_R_ILLEGAL_TIME_VALUE                        184\n# define ASN1_R_INTEGER_NOT_ASCII_FORMAT                  185\n# define ASN1_R_INTEGER_TOO_LARGE_FOR_LONG                128\n# define ASN1_R_INVALID_BIT_STRING_BITS_LEFT              220\n# define ASN1_R_INVALID_BMPSTRING_LENGTH                  129\n# define ASN1_R_INVALID_DIGIT                             130\n# define ASN1_R_INVALID_MIME_TYPE                         205\n# define ASN1_R_INVALID_MODIFIER                          186\n# define ASN1_R_INVALID_NUMBER                            187\n# define ASN1_R_INVALID_OBJECT_ENCODING                   216\n# define ASN1_R_INVALID_SEPARATOR                         131\n# define ASN1_R_INVALID_TIME_FORMAT                       132\n# define ASN1_R_INVALID_UNIVERSALSTRING_LENGTH            133\n# define ASN1_R_INVALID_UTF8STRING                        134\n# define ASN1_R_IV_TOO_LARGE                              135\n# define ASN1_R_LENGTH_ERROR                              136\n# define ASN1_R_LIST_ERROR                                188\n# define ASN1_R_MIME_NO_CONTENT_TYPE                      206\n# define ASN1_R_MIME_PARSE_ERROR                          207\n# define ASN1_R_MIME_SIG_PARSE_ERROR                      208\n# define ASN1_R_MISSING_EOC                               137\n# define ASN1_R_MISSING_SECOND_NUMBER                     138\n# define ASN1_R_MISSING_VALUE                             189\n# define ASN1_R_MSTRING_NOT_UNIVERSAL                     139\n# define ASN1_R_MSTRING_WRONG_TAG                         140\n# define ASN1_R_NESTED_ASN1_STRING                        197\n# define ASN1_R_NON_HEX_CHARACTERS                        141\n# define ASN1_R_NOT_ASCII_FORMAT                          190\n# define ASN1_R_NOT_ENOUGH_DATA                           142\n# define ASN1_R_NO_CONTENT_TYPE                           209\n# define ASN1_R_NO_DEFAULT_DIGEST                         201\n# define ASN1_R_NO_MATCHING_CHOICE_TYPE                   143\n# define ASN1_R_NO_MULTIPART_BODY_FAILURE                 210\n# define ASN1_R_NO_MULTIPART_BOUNDARY                     211\n# define ASN1_R_NO_SIG_CONTENT_TYPE                       212\n# define ASN1_R_NULL_IS_WRONG_LENGTH                      144\n# define ASN1_R_OBJECT_NOT_ASCII_FORMAT                   191\n# define ASN1_R_ODD_NUMBER_OF_CHARS                       145\n# define ASN1_R_PRIVATE_KEY_HEADER_MISSING                146\n# define ASN1_R_SECOND_NUMBER_TOO_LARGE                   147\n# define ASN1_R_SEQUENCE_LENGTH_MISMATCH                  148\n# define ASN1_R_SEQUENCE_NOT_CONSTRUCTED                  149\n# define ASN1_R_SEQUENCE_OR_SET_NEEDS_CONFIG              192\n# define ASN1_R_SHORT_LINE                                150\n# define ASN1_R_SIG_INVALID_MIME_TYPE                     213\n# define ASN1_R_STREAMING_NOT_SUPPORTED                   202\n# define ASN1_R_STRING_TOO_LONG                           151\n# define ASN1_R_STRING_TOO_SHORT                          152\n# define ASN1_R_TAG_VALUE_TOO_HIGH                        153\n# define ASN1_R_THE_ASN1_OBJECT_IDENTIFIER_IS_NOT_KNOWN_FOR_THIS_MD 154\n# define ASN1_R_TIME_NOT_ASCII_FORMAT                     193\n# define ASN1_R_TOO_LONG                                  155\n# define ASN1_R_TYPE_NOT_CONSTRUCTED                      156\n# define ASN1_R_TYPE_NOT_PRIMITIVE                        218\n# define ASN1_R_UNABLE_TO_DECODE_RSA_KEY                  157\n# define ASN1_R_UNABLE_TO_DECODE_RSA_PRIVATE_KEY          158\n# define ASN1_R_UNEXPECTED_EOC                            159\n# define ASN1_R_UNIVERSALSTRING_IS_WRONG_LENGTH           215\n# define ASN1_R_UNKNOWN_FORMAT                            160\n# define ASN1_R_UNKNOWN_MESSAGE_DIGEST_ALGORITHM          161\n# define ASN1_R_UNKNOWN_OBJECT_TYPE                       162\n# define ASN1_R_UNKNOWN_PUBLIC_KEY_TYPE                   163\n# define ASN1_R_UNKNOWN_SIGNATURE_ALGORITHM               199\n# define ASN1_R_UNKNOWN_TAG                               194\n# define ASN1_R_UNKOWN_FORMAT                             195\n# define ASN1_R_UNSUPPORTED_ANY_DEFINED_BY_TYPE           164\n# define ASN1_R_UNSUPPORTED_CIPHER                        165\n# define ASN1_R_UNSUPPORTED_ENCRYPTION_ALGORITHM          166\n# define ASN1_R_UNSUPPORTED_PUBLIC_KEY_TYPE               167\n# define ASN1_R_UNSUPPORTED_TYPE                          196\n# define ASN1_R_WRONG_PUBLIC_KEY_TYPE                     200\n# define ASN1_R_WRONG_TAG                                 168\n# define ASN1_R_WRONG_TYPE                                169\n\n#ifdef  __cplusplus\n}\n#endif\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/arm/include/openssl/asn1_mac.h",
    "content": "/* crypto/asn1/asn1_mac.h */\n/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)\n * All rights reserved.\n *\n * This package is an SSL implementation written\n * by Eric Young (eay@cryptsoft.com).\n * The implementation was written so as to conform with Netscapes SSL.\n *\n * This library is free for commercial and non-commercial use as long as\n * the following conditions are aheared to.  The following conditions\n * apply to all code found in this distribution, be it the RC4, RSA,\n * lhash, DES, etc., code; not just the SSL code.  The SSL documentation\n * included with this distribution is covered by the same copyright terms\n * except that the holder is Tim Hudson (tjh@cryptsoft.com).\n *\n * Copyright remains Eric Young's, and as such any Copyright notices in\n * the code are not to be removed.\n * If this package is used in a product, Eric Young should be given attribution\n * as the author of the parts of the library used.\n * This can be in the form of a textual message at program startup or\n * in documentation (online or textual) provided with the package.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the copyright\n *    notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in the\n *    documentation and/or other materials provided with the distribution.\n * 3. All advertising materials mentioning features or use of this software\n *    must display the following acknowledgement:\n *    \"This product includes cryptographic software written by\n *     Eric Young (eay@cryptsoft.com)\"\n *    The word 'cryptographic' can be left out if the rouines from the library\n *    being used are not cryptographic related :-).\n * 4. If you include any Windows specific code (or a derivative thereof) from\n *    the apps directory (application code) you must include an acknowledgement:\n *    \"This product includes software written by Tim Hudson (tjh@cryptsoft.com)\"\n *\n * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n * SUCH DAMAGE.\n *\n * The licence and distribution terms for any publically available version or\n * derivative of this code cannot be changed.  i.e. this code cannot simply be\n * copied and put under another distribution licence\n * [including the GNU Public Licence.]\n */\n\n#ifndef HEADER_ASN1_MAC_H\n# define HEADER_ASN1_MAC_H\n\n# include <openssl/asn1.h>\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n# ifndef ASN1_MAC_ERR_LIB\n#  define ASN1_MAC_ERR_LIB        ERR_LIB_ASN1\n# endif\n\n# define ASN1_MAC_H_err(f,r,line) \\\n        ERR_PUT_error(ASN1_MAC_ERR_LIB,(f),(r),__FILE__,(line))\n\n# define M_ASN1_D2I_vars(a,type,func) \\\n        ASN1_const_CTX c; \\\n        type ret=NULL; \\\n        \\\n        c.pp=(const unsigned char **)pp; \\\n        c.q= *(const unsigned char **)pp; \\\n        c.error=ERR_R_NESTED_ASN1_ERROR; \\\n        if ((a == NULL) || ((*a) == NULL)) \\\n                { if ((ret=(type)func()) == NULL) \\\n                        { c.line=__LINE__; goto err; } } \\\n        else    ret=(*a);\n\n# define M_ASN1_D2I_Init() \\\n        c.p= *(const unsigned char **)pp; \\\n        c.max=(length == 0)?0:(c.p+length);\n\n# define M_ASN1_D2I_Finish_2(a) \\\n        if (!asn1_const_Finish(&c)) \\\n                { c.line=__LINE__; goto err; } \\\n        *(const unsigned char **)pp=c.p; \\\n        if (a != NULL) (*a)=ret; \\\n        return(ret);\n\n# define M_ASN1_D2I_Finish(a,func,e) \\\n        M_ASN1_D2I_Finish_2(a); \\\nerr:\\\n        ASN1_MAC_H_err((e),c.error,c.line); \\\n        asn1_add_error(*(const unsigned char **)pp,(int)(c.q- *pp)); \\\n        if ((ret != NULL) && ((a == NULL) || (*a != ret))) func(ret); \\\n        return(NULL)\n\n# define M_ASN1_D2I_start_sequence() \\\n        if (!asn1_GetSequence(&c,&length)) \\\n                { c.line=__LINE__; goto err; }\n/* Begin reading ASN1 without a surrounding sequence */\n# define M_ASN1_D2I_begin() \\\n        c.slen = length;\n\n/* End reading ASN1 with no check on length */\n# define M_ASN1_D2I_Finish_nolen(a, func, e) \\\n        *pp=c.p; \\\n        if (a != NULL) (*a)=ret; \\\n        return(ret); \\\nerr:\\\n        ASN1_MAC_H_err((e),c.error,c.line); \\\n        asn1_add_error(*pp,(int)(c.q- *pp)); \\\n        if ((ret != NULL) && ((a == NULL) || (*a != ret))) func(ret); \\\n        return(NULL)\n\n# define M_ASN1_D2I_end_sequence() \\\n        (((c.inf&1) == 0)?(c.slen <= 0): \\\n                (c.eos=ASN1_const_check_infinite_end(&c.p,c.slen)))\n\n/* Don't use this with d2i_ASN1_BOOLEAN() */\n# define M_ASN1_D2I_get(b, func) \\\n        c.q=c.p; \\\n        if (func(&(b),&c.p,c.slen) == NULL) \\\n                {c.line=__LINE__; goto err; } \\\n        c.slen-=(c.p-c.q);\n\n/* Don't use this with d2i_ASN1_BOOLEAN() */\n# define M_ASN1_D2I_get_x(type,b,func) \\\n        c.q=c.p; \\\n        if (((D2I_OF(type))func)(&(b),&c.p,c.slen) == NULL) \\\n                {c.line=__LINE__; goto err; } \\\n        c.slen-=(c.p-c.q);\n\n/* use this instead () */\n# define M_ASN1_D2I_get_int(b,func) \\\n        c.q=c.p; \\\n        if (func(&(b),&c.p,c.slen) < 0) \\\n                {c.line=__LINE__; goto err; } \\\n        c.slen-=(c.p-c.q);\n\n# define M_ASN1_D2I_get_opt(b,func,type) \\\n        if ((c.slen != 0) && ((M_ASN1_next & (~V_ASN1_CONSTRUCTED)) \\\n                == (V_ASN1_UNIVERSAL|(type)))) \\\n                { \\\n                M_ASN1_D2I_get(b,func); \\\n                }\n\n# define M_ASN1_D2I_get_int_opt(b,func,type) \\\n        if ((c.slen != 0) && ((M_ASN1_next & (~V_ASN1_CONSTRUCTED)) \\\n                == (V_ASN1_UNIVERSAL|(type)))) \\\n                { \\\n                M_ASN1_D2I_get_int(b,func); \\\n                }\n\n# define M_ASN1_D2I_get_imp(b,func, type) \\\n        M_ASN1_next=(_tmp& V_ASN1_CONSTRUCTED)|type; \\\n        c.q=c.p; \\\n        if (func(&(b),&c.p,c.slen) == NULL) \\\n                {c.line=__LINE__; M_ASN1_next_prev = _tmp; goto err; } \\\n        c.slen-=(c.p-c.q);\\\n        M_ASN1_next_prev=_tmp;\n\n# define M_ASN1_D2I_get_IMP_opt(b,func,tag,type) \\\n        if ((c.slen != 0) && ((M_ASN1_next & (~V_ASN1_CONSTRUCTED)) == \\\n                (V_ASN1_CONTEXT_SPECIFIC|(tag)))) \\\n                { \\\n                unsigned char _tmp = M_ASN1_next; \\\n                M_ASN1_D2I_get_imp(b,func, type);\\\n                }\n\n# define M_ASN1_D2I_get_set(r,func,free_func) \\\n                M_ASN1_D2I_get_imp_set(r,func,free_func, \\\n                        V_ASN1_SET,V_ASN1_UNIVERSAL);\n\n# define M_ASN1_D2I_get_set_type(type,r,func,free_func) \\\n                M_ASN1_D2I_get_imp_set_type(type,r,func,free_func, \\\n                        V_ASN1_SET,V_ASN1_UNIVERSAL);\n\n# define M_ASN1_D2I_get_set_opt(r,func,free_func) \\\n        if ((c.slen != 0) && (M_ASN1_next == (V_ASN1_UNIVERSAL| \\\n                V_ASN1_CONSTRUCTED|V_ASN1_SET)))\\\n                { M_ASN1_D2I_get_set(r,func,free_func); }\n\n# define M_ASN1_D2I_get_set_opt_type(type,r,func,free_func) \\\n        if ((c.slen != 0) && (M_ASN1_next == (V_ASN1_UNIVERSAL| \\\n                V_ASN1_CONSTRUCTED|V_ASN1_SET)))\\\n                { M_ASN1_D2I_get_set_type(type,r,func,free_func); }\n\n# define M_ASN1_I2D_len_SET_opt(a,f) \\\n        if ((a != NULL) && (sk_num(a) != 0)) \\\n                M_ASN1_I2D_len_SET(a,f);\n\n# define M_ASN1_I2D_put_SET_opt(a,f) \\\n        if ((a != NULL) && (sk_num(a) != 0)) \\\n                M_ASN1_I2D_put_SET(a,f);\n\n# define M_ASN1_I2D_put_SEQUENCE_opt(a,f) \\\n        if ((a != NULL) && (sk_num(a) != 0)) \\\n                M_ASN1_I2D_put_SEQUENCE(a,f);\n\n# define M_ASN1_I2D_put_SEQUENCE_opt_type(type,a,f) \\\n        if ((a != NULL) && (sk_##type##_num(a) != 0)) \\\n                M_ASN1_I2D_put_SEQUENCE_type(type,a,f);\n\n# define M_ASN1_D2I_get_IMP_set_opt(b,func,free_func,tag) \\\n        if ((c.slen != 0) && \\\n                (M_ASN1_next == \\\n                (V_ASN1_CONTEXT_SPECIFIC|V_ASN1_CONSTRUCTED|(tag))))\\\n                { \\\n                M_ASN1_D2I_get_imp_set(b,func,free_func,\\\n                        tag,V_ASN1_CONTEXT_SPECIFIC); \\\n                }\n\n# define M_ASN1_D2I_get_IMP_set_opt_type(type,b,func,free_func,tag) \\\n        if ((c.slen != 0) && \\\n                (M_ASN1_next == \\\n                (V_ASN1_CONTEXT_SPECIFIC|V_ASN1_CONSTRUCTED|(tag))))\\\n                { \\\n                M_ASN1_D2I_get_imp_set_type(type,b,func,free_func,\\\n                        tag,V_ASN1_CONTEXT_SPECIFIC); \\\n                }\n\n# define M_ASN1_D2I_get_seq(r,func,free_func) \\\n                M_ASN1_D2I_get_imp_set(r,func,free_func,\\\n                        V_ASN1_SEQUENCE,V_ASN1_UNIVERSAL);\n\n# define M_ASN1_D2I_get_seq_type(type,r,func,free_func) \\\n                M_ASN1_D2I_get_imp_set_type(type,r,func,free_func,\\\n                                            V_ASN1_SEQUENCE,V_ASN1_UNIVERSAL)\n\n# define M_ASN1_D2I_get_seq_opt(r,func,free_func) \\\n        if ((c.slen != 0) && (M_ASN1_next == (V_ASN1_UNIVERSAL| \\\n                V_ASN1_CONSTRUCTED|V_ASN1_SEQUENCE)))\\\n                { M_ASN1_D2I_get_seq(r,func,free_func); }\n\n# define M_ASN1_D2I_get_seq_opt_type(type,r,func,free_func) \\\n        if ((c.slen != 0) && (M_ASN1_next == (V_ASN1_UNIVERSAL| \\\n                V_ASN1_CONSTRUCTED|V_ASN1_SEQUENCE)))\\\n                { M_ASN1_D2I_get_seq_type(type,r,func,free_func); }\n\n# define M_ASN1_D2I_get_IMP_set(r,func,free_func,x) \\\n                M_ASN1_D2I_get_imp_set(r,func,free_func,\\\n                        x,V_ASN1_CONTEXT_SPECIFIC);\n\n# define M_ASN1_D2I_get_IMP_set_type(type,r,func,free_func,x) \\\n                M_ASN1_D2I_get_imp_set_type(type,r,func,free_func,\\\n                        x,V_ASN1_CONTEXT_SPECIFIC);\n\n# define M_ASN1_D2I_get_imp_set(r,func,free_func,a,b) \\\n        c.q=c.p; \\\n        if (d2i_ASN1_SET(&(r),&c.p,c.slen,(char *(*)())func,\\\n                (void (*)())free_func,a,b) == NULL) \\\n                { c.line=__LINE__; goto err; } \\\n        c.slen-=(c.p-c.q);\n\n# define M_ASN1_D2I_get_imp_set_type(type,r,func,free_func,a,b) \\\n        c.q=c.p; \\\n        if (d2i_ASN1_SET_OF_##type(&(r),&c.p,c.slen,func,\\\n                                   free_func,a,b) == NULL) \\\n                { c.line=__LINE__; goto err; } \\\n        c.slen-=(c.p-c.q);\n\n# define M_ASN1_D2I_get_set_strings(r,func,a,b) \\\n        c.q=c.p; \\\n        if (d2i_ASN1_STRING_SET(&(r),&c.p,c.slen,a,b) == NULL) \\\n                { c.line=__LINE__; goto err; } \\\n        c.slen-=(c.p-c.q);\n\n# define M_ASN1_D2I_get_EXP_opt(r,func,tag) \\\n        if ((c.slen != 0L) && (M_ASN1_next == \\\n                (V_ASN1_CONSTRUCTED|V_ASN1_CONTEXT_SPECIFIC|tag))) \\\n                { \\\n                int Tinf,Ttag,Tclass; \\\n                long Tlen; \\\n                \\\n                c.q=c.p; \\\n                Tinf=ASN1_get_object(&c.p,&Tlen,&Ttag,&Tclass,c.slen); \\\n                if (Tinf & 0x80) \\\n                        { c.error=ERR_R_BAD_ASN1_OBJECT_HEADER; \\\n                        c.line=__LINE__; goto err; } \\\n                if (Tinf == (V_ASN1_CONSTRUCTED+1)) \\\n                                        Tlen = c.slen - (c.p - c.q) - 2; \\\n                if (func(&(r),&c.p,Tlen) == NULL) \\\n                        { c.line=__LINE__; goto err; } \\\n                if (Tinf == (V_ASN1_CONSTRUCTED+1)) { \\\n                        Tlen = c.slen - (c.p - c.q); \\\n                        if(!ASN1_const_check_infinite_end(&c.p, Tlen)) \\\n                                { c.error=ERR_R_MISSING_ASN1_EOS; \\\n                                c.line=__LINE__; goto err; } \\\n                }\\\n                c.slen-=(c.p-c.q); \\\n                }\n\n# define M_ASN1_D2I_get_EXP_set_opt(r,func,free_func,tag,b) \\\n        if ((c.slen != 0) && (M_ASN1_next == \\\n                (V_ASN1_CONSTRUCTED|V_ASN1_CONTEXT_SPECIFIC|tag))) \\\n                { \\\n                int Tinf,Ttag,Tclass; \\\n                long Tlen; \\\n                \\\n                c.q=c.p; \\\n                Tinf=ASN1_get_object(&c.p,&Tlen,&Ttag,&Tclass,c.slen); \\\n                if (Tinf & 0x80) \\\n                        { c.error=ERR_R_BAD_ASN1_OBJECT_HEADER; \\\n                        c.line=__LINE__; goto err; } \\\n                if (Tinf == (V_ASN1_CONSTRUCTED+1)) \\\n                                        Tlen = c.slen - (c.p - c.q) - 2; \\\n                if (d2i_ASN1_SET(&(r),&c.p,Tlen,(char *(*)())func, \\\n                        (void (*)())free_func, \\\n                        b,V_ASN1_UNIVERSAL) == NULL) \\\n                        { c.line=__LINE__; goto err; } \\\n                if (Tinf == (V_ASN1_CONSTRUCTED+1)) { \\\n                        Tlen = c.slen - (c.p - c.q); \\\n                        if(!ASN1_check_infinite_end(&c.p, Tlen)) \\\n                                { c.error=ERR_R_MISSING_ASN1_EOS; \\\n                                c.line=__LINE__; goto err; } \\\n                }\\\n                c.slen-=(c.p-c.q); \\\n                }\n\n# define M_ASN1_D2I_get_EXP_set_opt_type(type,r,func,free_func,tag,b) \\\n        if ((c.slen != 0) && (M_ASN1_next == \\\n                (V_ASN1_CONSTRUCTED|V_ASN1_CONTEXT_SPECIFIC|tag))) \\\n                { \\\n                int Tinf,Ttag,Tclass; \\\n                long Tlen; \\\n                \\\n                c.q=c.p; \\\n                Tinf=ASN1_get_object(&c.p,&Tlen,&Ttag,&Tclass,c.slen); \\\n                if (Tinf & 0x80) \\\n                        { c.error=ERR_R_BAD_ASN1_OBJECT_HEADER; \\\n                        c.line=__LINE__; goto err; } \\\n                if (Tinf == (V_ASN1_CONSTRUCTED+1)) \\\n                                        Tlen = c.slen - (c.p - c.q) - 2; \\\n                if (d2i_ASN1_SET_OF_##type(&(r),&c.p,Tlen,func, \\\n                        free_func,b,V_ASN1_UNIVERSAL) == NULL) \\\n                        { c.line=__LINE__; goto err; } \\\n                if (Tinf == (V_ASN1_CONSTRUCTED+1)) { \\\n                        Tlen = c.slen - (c.p - c.q); \\\n                        if(!ASN1_check_infinite_end(&c.p, Tlen)) \\\n                                { c.error=ERR_R_MISSING_ASN1_EOS; \\\n                                c.line=__LINE__; goto err; } \\\n                }\\\n                c.slen-=(c.p-c.q); \\\n                }\n\n/* New macros */\n# define M_ASN1_New_Malloc(ret,type) \\\n        if ((ret=(type *)OPENSSL_malloc(sizeof(type))) == NULL) \\\n                { c.line=__LINE__; goto err2; }\n\n# define M_ASN1_New(arg,func) \\\n        if (((arg)=func()) == NULL) return(NULL)\n\n# define M_ASN1_New_Error(a) \\\n/*-     err:    ASN1_MAC_H_err((a),ERR_R_NESTED_ASN1_ERROR,c.line); \\\n                return(NULL);*/ \\\n        err2:   ASN1_MAC_H_err((a),ERR_R_MALLOC_FAILURE,c.line); \\\n                return(NULL)\n\n/*\n * BIG UGLY WARNING! This is so damn ugly I wanna puke.  Unfortunately, some\n * macros that use ASN1_const_CTX still insist on writing in the input\n * stream.  ARGH! ARGH! ARGH! Let's get rid of this macro package. Please? --\n * Richard Levitte\n */\n# define M_ASN1_next             (*((unsigned char *)(c.p)))\n# define M_ASN1_next_prev        (*((unsigned char *)(c.q)))\n\n/*************************************************/\n\n# define M_ASN1_I2D_vars(a)      int r=0,ret=0; \\\n                                unsigned char *p; \\\n                                if (a == NULL) return(0)\n\n/* Length Macros */\n# define M_ASN1_I2D_len(a,f)     ret+=f(a,NULL)\n# define M_ASN1_I2D_len_IMP_opt(a,f)     if (a != NULL) M_ASN1_I2D_len(a,f)\n\n# define M_ASN1_I2D_len_SET(a,f) \\\n                ret+=i2d_ASN1_SET(a,NULL,f,V_ASN1_SET,V_ASN1_UNIVERSAL,IS_SET);\n\n# define M_ASN1_I2D_len_SET_type(type,a,f) \\\n                ret+=i2d_ASN1_SET_OF_##type(a,NULL,f,V_ASN1_SET, \\\n                                            V_ASN1_UNIVERSAL,IS_SET);\n\n# define M_ASN1_I2D_len_SEQUENCE(a,f) \\\n                ret+=i2d_ASN1_SET(a,NULL,f,V_ASN1_SEQUENCE,V_ASN1_UNIVERSAL, \\\n                                  IS_SEQUENCE);\n\n# define M_ASN1_I2D_len_SEQUENCE_type(type,a,f) \\\n                ret+=i2d_ASN1_SET_OF_##type(a,NULL,f,V_ASN1_SEQUENCE, \\\n                                            V_ASN1_UNIVERSAL,IS_SEQUENCE)\n\n# define M_ASN1_I2D_len_SEQUENCE_opt(a,f) \\\n                if ((a != NULL) && (sk_num(a) != 0)) \\\n                        M_ASN1_I2D_len_SEQUENCE(a,f);\n\n# define M_ASN1_I2D_len_SEQUENCE_opt_type(type,a,f) \\\n                if ((a != NULL) && (sk_##type##_num(a) != 0)) \\\n                        M_ASN1_I2D_len_SEQUENCE_type(type,a,f);\n\n# define M_ASN1_I2D_len_IMP_SET(a,f,x) \\\n                ret+=i2d_ASN1_SET(a,NULL,f,x,V_ASN1_CONTEXT_SPECIFIC,IS_SET);\n\n# define M_ASN1_I2D_len_IMP_SET_type(type,a,f,x) \\\n                ret+=i2d_ASN1_SET_OF_##type(a,NULL,f,x, \\\n                                            V_ASN1_CONTEXT_SPECIFIC,IS_SET);\n\n# define M_ASN1_I2D_len_IMP_SET_opt(a,f,x) \\\n                if ((a != NULL) && (sk_num(a) != 0)) \\\n                        ret+=i2d_ASN1_SET(a,NULL,f,x,V_ASN1_CONTEXT_SPECIFIC, \\\n                                          IS_SET);\n\n# define M_ASN1_I2D_len_IMP_SET_opt_type(type,a,f,x) \\\n                if ((a != NULL) && (sk_##type##_num(a) != 0)) \\\n                        ret+=i2d_ASN1_SET_OF_##type(a,NULL,f,x, \\\n                                               V_ASN1_CONTEXT_SPECIFIC,IS_SET);\n\n# define M_ASN1_I2D_len_IMP_SEQUENCE(a,f,x) \\\n                ret+=i2d_ASN1_SET(a,NULL,f,x,V_ASN1_CONTEXT_SPECIFIC, \\\n                                  IS_SEQUENCE);\n\n# define M_ASN1_I2D_len_IMP_SEQUENCE_opt(a,f,x) \\\n                if ((a != NULL) && (sk_num(a) != 0)) \\\n                        ret+=i2d_ASN1_SET(a,NULL,f,x,V_ASN1_CONTEXT_SPECIFIC, \\\n                                          IS_SEQUENCE);\n\n# define M_ASN1_I2D_len_IMP_SEQUENCE_opt_type(type,a,f,x) \\\n                if ((a != NULL) && (sk_##type##_num(a) != 0)) \\\n                        ret+=i2d_ASN1_SET_OF_##type(a,NULL,f,x, \\\n                                                    V_ASN1_CONTEXT_SPECIFIC, \\\n                                                    IS_SEQUENCE);\n\n# define M_ASN1_I2D_len_EXP_opt(a,f,mtag,v) \\\n                if (a != NULL)\\\n                        { \\\n                        v=f(a,NULL); \\\n                        ret+=ASN1_object_size(1,v,mtag); \\\n                        }\n\n# define M_ASN1_I2D_len_EXP_SET_opt(a,f,mtag,tag,v) \\\n                if ((a != NULL) && (sk_num(a) != 0))\\\n                        { \\\n                        v=i2d_ASN1_SET(a,NULL,f,tag,V_ASN1_UNIVERSAL,IS_SET); \\\n                        ret+=ASN1_object_size(1,v,mtag); \\\n                        }\n\n# define M_ASN1_I2D_len_EXP_SEQUENCE_opt(a,f,mtag,tag,v) \\\n                if ((a != NULL) && (sk_num(a) != 0))\\\n                        { \\\n                        v=i2d_ASN1_SET(a,NULL,f,tag,V_ASN1_UNIVERSAL, \\\n                                       IS_SEQUENCE); \\\n                        ret+=ASN1_object_size(1,v,mtag); \\\n                        }\n\n# define M_ASN1_I2D_len_EXP_SEQUENCE_opt_type(type,a,f,mtag,tag,v) \\\n                if ((a != NULL) && (sk_##type##_num(a) != 0))\\\n                        { \\\n                        v=i2d_ASN1_SET_OF_##type(a,NULL,f,tag, \\\n                                                 V_ASN1_UNIVERSAL, \\\n                                                 IS_SEQUENCE); \\\n                        ret+=ASN1_object_size(1,v,mtag); \\\n                        }\n\n/* Put Macros */\n# define M_ASN1_I2D_put(a,f)     f(a,&p)\n\n# define M_ASN1_I2D_put_IMP_opt(a,f,t)   \\\n                if (a != NULL) \\\n                        { \\\n                        unsigned char *q=p; \\\n                        f(a,&p); \\\n                        *q=(V_ASN1_CONTEXT_SPECIFIC|t|(*q&V_ASN1_CONSTRUCTED));\\\n                        }\n\n# define M_ASN1_I2D_put_SET(a,f) i2d_ASN1_SET(a,&p,f,V_ASN1_SET,\\\n                        V_ASN1_UNIVERSAL,IS_SET)\n# define M_ASN1_I2D_put_SET_type(type,a,f) \\\n     i2d_ASN1_SET_OF_##type(a,&p,f,V_ASN1_SET,V_ASN1_UNIVERSAL,IS_SET)\n# define M_ASN1_I2D_put_IMP_SET(a,f,x) i2d_ASN1_SET(a,&p,f,x,\\\n                        V_ASN1_CONTEXT_SPECIFIC,IS_SET)\n# define M_ASN1_I2D_put_IMP_SET_type(type,a,f,x) \\\n     i2d_ASN1_SET_OF_##type(a,&p,f,x,V_ASN1_CONTEXT_SPECIFIC,IS_SET)\n# define M_ASN1_I2D_put_IMP_SEQUENCE(a,f,x) i2d_ASN1_SET(a,&p,f,x,\\\n                        V_ASN1_CONTEXT_SPECIFIC,IS_SEQUENCE)\n\n# define M_ASN1_I2D_put_SEQUENCE(a,f) i2d_ASN1_SET(a,&p,f,V_ASN1_SEQUENCE,\\\n                                             V_ASN1_UNIVERSAL,IS_SEQUENCE)\n\n# define M_ASN1_I2D_put_SEQUENCE_type(type,a,f) \\\n     i2d_ASN1_SET_OF_##type(a,&p,f,V_ASN1_SEQUENCE,V_ASN1_UNIVERSAL, \\\n                            IS_SEQUENCE)\n\n# define M_ASN1_I2D_put_SEQUENCE_opt(a,f) \\\n                if ((a != NULL) && (sk_num(a) != 0)) \\\n                        M_ASN1_I2D_put_SEQUENCE(a,f);\n\n# define M_ASN1_I2D_put_IMP_SET_opt(a,f,x) \\\n                if ((a != NULL) && (sk_num(a) != 0)) \\\n                        { i2d_ASN1_SET(a,&p,f,x,V_ASN1_CONTEXT_SPECIFIC, \\\n                                       IS_SET); }\n\n# define M_ASN1_I2D_put_IMP_SET_opt_type(type,a,f,x) \\\n                if ((a != NULL) && (sk_##type##_num(a) != 0)) \\\n                        { i2d_ASN1_SET_OF_##type(a,&p,f,x, \\\n                                                 V_ASN1_CONTEXT_SPECIFIC, \\\n                                                 IS_SET); }\n\n# define M_ASN1_I2D_put_IMP_SEQUENCE_opt(a,f,x) \\\n                if ((a != NULL) && (sk_num(a) != 0)) \\\n                        { i2d_ASN1_SET(a,&p,f,x,V_ASN1_CONTEXT_SPECIFIC, \\\n                                       IS_SEQUENCE); }\n\n# define M_ASN1_I2D_put_IMP_SEQUENCE_opt_type(type,a,f,x) \\\n                if ((a != NULL) && (sk_##type##_num(a) != 0)) \\\n                        { i2d_ASN1_SET_OF_##type(a,&p,f,x, \\\n                                                 V_ASN1_CONTEXT_SPECIFIC, \\\n                                                 IS_SEQUENCE); }\n\n# define M_ASN1_I2D_put_EXP_opt(a,f,tag,v) \\\n                if (a != NULL) \\\n                        { \\\n                        ASN1_put_object(&p,1,v,tag,V_ASN1_CONTEXT_SPECIFIC); \\\n                        f(a,&p); \\\n                        }\n\n# define M_ASN1_I2D_put_EXP_SET_opt(a,f,mtag,tag,v) \\\n                if ((a != NULL) && (sk_num(a) != 0)) \\\n                        { \\\n                        ASN1_put_object(&p,1,v,mtag,V_ASN1_CONTEXT_SPECIFIC); \\\n                        i2d_ASN1_SET(a,&p,f,tag,V_ASN1_UNIVERSAL,IS_SET); \\\n                        }\n\n# define M_ASN1_I2D_put_EXP_SEQUENCE_opt(a,f,mtag,tag,v) \\\n                if ((a != NULL) && (sk_num(a) != 0)) \\\n                        { \\\n                        ASN1_put_object(&p,1,v,mtag,V_ASN1_CONTEXT_SPECIFIC); \\\n                        i2d_ASN1_SET(a,&p,f,tag,V_ASN1_UNIVERSAL,IS_SEQUENCE); \\\n                        }\n\n# define M_ASN1_I2D_put_EXP_SEQUENCE_opt_type(type,a,f,mtag,tag,v) \\\n                if ((a != NULL) && (sk_##type##_num(a) != 0)) \\\n                        { \\\n                        ASN1_put_object(&p,1,v,mtag,V_ASN1_CONTEXT_SPECIFIC); \\\n                        i2d_ASN1_SET_OF_##type(a,&p,f,tag,V_ASN1_UNIVERSAL, \\\n                                               IS_SEQUENCE); \\\n                        }\n\n# define M_ASN1_I2D_seq_total() \\\n                r=ASN1_object_size(1,ret,V_ASN1_SEQUENCE); \\\n                if (pp == NULL) return(r); \\\n                p= *pp; \\\n                ASN1_put_object(&p,1,ret,V_ASN1_SEQUENCE,V_ASN1_UNIVERSAL)\n\n# define M_ASN1_I2D_INF_seq_start(tag,ctx) \\\n                *(p++)=(V_ASN1_CONSTRUCTED|(tag)|(ctx)); \\\n                *(p++)=0x80\n\n# define M_ASN1_I2D_INF_seq_end() *(p++)=0x00; *(p++)=0x00\n\n# define M_ASN1_I2D_finish()     *pp=p; \\\n                                return(r);\n\nint asn1_GetSequence(ASN1_const_CTX *c, long *length);\nvoid asn1_add_error(const unsigned char *address, int offset);\n#ifdef  __cplusplus\n}\n#endif\n\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/arm/include/openssl/asn1t.h",
    "content": "/* asn1t.h */\n/*\n * Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL project\n * 2000.\n */\n/* ====================================================================\n * Copyright (c) 2000-2005 The OpenSSL Project.  All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n *\n * 1. Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n *\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in\n *    the documentation and/or other materials provided with the\n *    distribution.\n *\n * 3. All advertising materials mentioning features or use of this\n *    software must display the following acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)\"\n *\n * 4. The names \"OpenSSL Toolkit\" and \"OpenSSL Project\" must not be used to\n *    endorse or promote products derived from this software without\n *    prior written permission. For written permission, please contact\n *    licensing@OpenSSL.org.\n *\n * 5. Products derived from this software may not be called \"OpenSSL\"\n *    nor may \"OpenSSL\" appear in their names without prior written\n *    permission of the OpenSSL Project.\n *\n * 6. Redistributions of any form whatsoever must retain the following\n *    acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)\"\n *\n * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY\n * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\n * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR\n * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\n * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,\n * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED\n * OF THE POSSIBILITY OF SUCH DAMAGE.\n * ====================================================================\n *\n * This product includes cryptographic software written by Eric Young\n * (eay@cryptsoft.com).  This product includes software written by Tim\n * Hudson (tjh@cryptsoft.com).\n *\n */\n#ifndef HEADER_ASN1T_H\n# define HEADER_ASN1T_H\n\n# include <stddef.h>\n# include <openssl/e_os2.h>\n# include <openssl/asn1.h>\n\n# ifdef OPENSSL_BUILD_SHLIBCRYPTO\n#  undef OPENSSL_EXTERN\n#  define OPENSSL_EXTERN OPENSSL_EXPORT\n# endif\n\n/* ASN1 template defines, structures and functions */\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n# ifndef OPENSSL_EXPORT_VAR_AS_FUNCTION\n\n/* Macro to obtain ASN1_ADB pointer from a type (only used internally) */\n#  define ASN1_ADB_ptr(iptr) ((const ASN1_ADB *)(iptr))\n\n/* Macros for start and end of ASN1_ITEM definition */\n\n#  define ASN1_ITEM_start(itname) \\\n        OPENSSL_GLOBAL const ASN1_ITEM itname##_it = {\n\n#  define ASN1_ITEM_end(itname) \\\n                };\n\n# else\n\n/* Macro to obtain ASN1_ADB pointer from a type (only used internally) */\n#  define ASN1_ADB_ptr(iptr) ((const ASN1_ADB *)(iptr()))\n\n/* Macros for start and end of ASN1_ITEM definition */\n\n#  define ASN1_ITEM_start(itname) \\\n        const ASN1_ITEM * itname##_it(void) \\\n        { \\\n                static const ASN1_ITEM local_it = {\n\n#  define ASN1_ITEM_end(itname) \\\n                }; \\\n        return &local_it; \\\n        }\n\n# endif\n\n/* Macros to aid ASN1 template writing */\n\n# define ASN1_ITEM_TEMPLATE(tname) \\\n        static const ASN1_TEMPLATE tname##_item_tt\n\n# define ASN1_ITEM_TEMPLATE_END(tname) \\\n        ;\\\n        ASN1_ITEM_start(tname) \\\n                ASN1_ITYPE_PRIMITIVE,\\\n                -1,\\\n                &tname##_item_tt,\\\n                0,\\\n                NULL,\\\n                0,\\\n                #tname \\\n        ASN1_ITEM_end(tname)\n\n/* This is a ASN1 type which just embeds a template */\n\n/*-\n * This pair helps declare a SEQUENCE. We can do:\n *\n *      ASN1_SEQUENCE(stname) = {\n *              ... SEQUENCE components ...\n *      } ASN1_SEQUENCE_END(stname)\n *\n *      This will produce an ASN1_ITEM called stname_it\n *      for a structure called stname.\n *\n *      If you want the same structure but a different\n *      name then use:\n *\n *      ASN1_SEQUENCE(itname) = {\n *              ... SEQUENCE components ...\n *      } ASN1_SEQUENCE_END_name(stname, itname)\n *\n *      This will create an item called itname_it using\n *      a structure called stname.\n */\n\n# define ASN1_SEQUENCE(tname) \\\n        static const ASN1_TEMPLATE tname##_seq_tt[]\n\n# define ASN1_SEQUENCE_END(stname) ASN1_SEQUENCE_END_name(stname, stname)\n\n# define ASN1_SEQUENCE_END_name(stname, tname) \\\n        ;\\\n        ASN1_ITEM_start(tname) \\\n                ASN1_ITYPE_SEQUENCE,\\\n                V_ASN1_SEQUENCE,\\\n                tname##_seq_tt,\\\n                sizeof(tname##_seq_tt) / sizeof(ASN1_TEMPLATE),\\\n                NULL,\\\n                sizeof(stname),\\\n                #stname \\\n        ASN1_ITEM_end(tname)\n\n# define ASN1_NDEF_SEQUENCE(tname) \\\n        ASN1_SEQUENCE(tname)\n\n# define ASN1_NDEF_SEQUENCE_cb(tname, cb) \\\n        ASN1_SEQUENCE_cb(tname, cb)\n\n# define ASN1_SEQUENCE_cb(tname, cb) \\\n        static const ASN1_AUX tname##_aux = {NULL, 0, 0, 0, cb, 0}; \\\n        ASN1_SEQUENCE(tname)\n\n# define ASN1_BROKEN_SEQUENCE(tname) \\\n        static const ASN1_AUX tname##_aux = {NULL, ASN1_AFLG_BROKEN, 0, 0, 0, 0}; \\\n        ASN1_SEQUENCE(tname)\n\n# define ASN1_SEQUENCE_ref(tname, cb, lck) \\\n        static const ASN1_AUX tname##_aux = {NULL, ASN1_AFLG_REFCOUNT, offsetof(tname, references), lck, cb, 0}; \\\n        ASN1_SEQUENCE(tname)\n\n# define ASN1_SEQUENCE_enc(tname, enc, cb) \\\n        static const ASN1_AUX tname##_aux = {NULL, ASN1_AFLG_ENCODING, 0, 0, cb, offsetof(tname, enc)}; \\\n        ASN1_SEQUENCE(tname)\n\n# define ASN1_NDEF_SEQUENCE_END(tname) \\\n        ;\\\n        ASN1_ITEM_start(tname) \\\n                ASN1_ITYPE_NDEF_SEQUENCE,\\\n                V_ASN1_SEQUENCE,\\\n                tname##_seq_tt,\\\n                sizeof(tname##_seq_tt) / sizeof(ASN1_TEMPLATE),\\\n                NULL,\\\n                sizeof(tname),\\\n                #tname \\\n        ASN1_ITEM_end(tname)\n\n# define ASN1_BROKEN_SEQUENCE_END(stname) ASN1_SEQUENCE_END_ref(stname, stname)\n\n# define ASN1_SEQUENCE_END_enc(stname, tname) ASN1_SEQUENCE_END_ref(stname, tname)\n\n# define ASN1_SEQUENCE_END_cb(stname, tname) ASN1_SEQUENCE_END_ref(stname, tname)\n\n# define ASN1_SEQUENCE_END_ref(stname, tname) \\\n        ;\\\n        ASN1_ITEM_start(tname) \\\n                ASN1_ITYPE_SEQUENCE,\\\n                V_ASN1_SEQUENCE,\\\n                tname##_seq_tt,\\\n                sizeof(tname##_seq_tt) / sizeof(ASN1_TEMPLATE),\\\n                &tname##_aux,\\\n                sizeof(stname),\\\n                #stname \\\n        ASN1_ITEM_end(tname)\n\n# define ASN1_NDEF_SEQUENCE_END_cb(stname, tname) \\\n        ;\\\n        ASN1_ITEM_start(tname) \\\n                ASN1_ITYPE_NDEF_SEQUENCE,\\\n                V_ASN1_SEQUENCE,\\\n                tname##_seq_tt,\\\n                sizeof(tname##_seq_tt) / sizeof(ASN1_TEMPLATE),\\\n                &tname##_aux,\\\n                sizeof(stname),\\\n                #stname \\\n        ASN1_ITEM_end(tname)\n\n/*-\n * This pair helps declare a CHOICE type. We can do:\n *\n *      ASN1_CHOICE(chname) = {\n *              ... CHOICE options ...\n *      ASN1_CHOICE_END(chname)\n *\n *      This will produce an ASN1_ITEM called chname_it\n *      for a structure called chname. The structure\n *      definition must look like this:\n *      typedef struct {\n *              int type;\n *              union {\n *                      ASN1_SOMETHING *opt1;\n *                      ASN1_SOMEOTHER *opt2;\n *              } value;\n *      } chname;\n *\n *      the name of the selector must be 'type'.\n *      to use an alternative selector name use the\n *      ASN1_CHOICE_END_selector() version.\n */\n\n# define ASN1_CHOICE(tname) \\\n        static const ASN1_TEMPLATE tname##_ch_tt[]\n\n# define ASN1_CHOICE_cb(tname, cb) \\\n        static const ASN1_AUX tname##_aux = {NULL, 0, 0, 0, cb, 0}; \\\n        ASN1_CHOICE(tname)\n\n# define ASN1_CHOICE_END(stname) ASN1_CHOICE_END_name(stname, stname)\n\n# define ASN1_CHOICE_END_name(stname, tname) ASN1_CHOICE_END_selector(stname, tname, type)\n\n# define ASN1_CHOICE_END_selector(stname, tname, selname) \\\n        ;\\\n        ASN1_ITEM_start(tname) \\\n                ASN1_ITYPE_CHOICE,\\\n                offsetof(stname,selname) ,\\\n                tname##_ch_tt,\\\n                sizeof(tname##_ch_tt) / sizeof(ASN1_TEMPLATE),\\\n                NULL,\\\n                sizeof(stname),\\\n                #stname \\\n        ASN1_ITEM_end(tname)\n\n# define ASN1_CHOICE_END_cb(stname, tname, selname) \\\n        ;\\\n        ASN1_ITEM_start(tname) \\\n                ASN1_ITYPE_CHOICE,\\\n                offsetof(stname,selname) ,\\\n                tname##_ch_tt,\\\n                sizeof(tname##_ch_tt) / sizeof(ASN1_TEMPLATE),\\\n                &tname##_aux,\\\n                sizeof(stname),\\\n                #stname \\\n        ASN1_ITEM_end(tname)\n\n/* This helps with the template wrapper form of ASN1_ITEM */\n\n# define ASN1_EX_TEMPLATE_TYPE(flags, tag, name, type) { \\\n        (flags), (tag), 0,\\\n        #name, ASN1_ITEM_ref(type) }\n\n/* These help with SEQUENCE or CHOICE components */\n\n/* used to declare other types */\n\n# define ASN1_EX_TYPE(flags, tag, stname, field, type) { \\\n        (flags), (tag), offsetof(stname, field),\\\n        #field, ASN1_ITEM_ref(type) }\n\n/* used when the structure is combined with the parent */\n\n# define ASN1_EX_COMBINE(flags, tag, type) { \\\n        (flags)|ASN1_TFLG_COMBINE, (tag), 0, NULL, ASN1_ITEM_ref(type) }\n\n/* implicit and explicit helper macros */\n\n# define ASN1_IMP_EX(stname, field, type, tag, ex) \\\n                ASN1_EX_TYPE(ASN1_TFLG_IMPLICIT | ex, tag, stname, field, type)\n\n# define ASN1_EXP_EX(stname, field, type, tag, ex) \\\n                ASN1_EX_TYPE(ASN1_TFLG_EXPLICIT | ex, tag, stname, field, type)\n\n/* Any defined by macros: the field used is in the table itself */\n\n# ifndef OPENSSL_EXPORT_VAR_AS_FUNCTION\n#  define ASN1_ADB_OBJECT(tblname) { ASN1_TFLG_ADB_OID, -1, 0, #tblname, (const ASN1_ITEM *)&(tblname##_adb) }\n#  define ASN1_ADB_INTEGER(tblname) { ASN1_TFLG_ADB_INT, -1, 0, #tblname, (const ASN1_ITEM *)&(tblname##_adb) }\n# else\n#  define ASN1_ADB_OBJECT(tblname) { ASN1_TFLG_ADB_OID, -1, 0, #tblname, tblname##_adb }\n#  define ASN1_ADB_INTEGER(tblname) { ASN1_TFLG_ADB_INT, -1, 0, #tblname, tblname##_adb }\n# endif\n/* Plain simple type */\n# define ASN1_SIMPLE(stname, field, type) ASN1_EX_TYPE(0,0, stname, field, type)\n\n/* OPTIONAL simple type */\n# define ASN1_OPT(stname, field, type) ASN1_EX_TYPE(ASN1_TFLG_OPTIONAL, 0, stname, field, type)\n\n/* IMPLICIT tagged simple type */\n# define ASN1_IMP(stname, field, type, tag) ASN1_IMP_EX(stname, field, type, tag, 0)\n\n/* IMPLICIT tagged OPTIONAL simple type */\n# define ASN1_IMP_OPT(stname, field, type, tag) ASN1_IMP_EX(stname, field, type, tag, ASN1_TFLG_OPTIONAL)\n\n/* Same as above but EXPLICIT */\n\n# define ASN1_EXP(stname, field, type, tag) ASN1_EXP_EX(stname, field, type, tag, 0)\n# define ASN1_EXP_OPT(stname, field, type, tag) ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_OPTIONAL)\n\n/* SEQUENCE OF type */\n# define ASN1_SEQUENCE_OF(stname, field, type) \\\n                ASN1_EX_TYPE(ASN1_TFLG_SEQUENCE_OF, 0, stname, field, type)\n\n/* OPTIONAL SEQUENCE OF */\n# define ASN1_SEQUENCE_OF_OPT(stname, field, type) \\\n                ASN1_EX_TYPE(ASN1_TFLG_SEQUENCE_OF|ASN1_TFLG_OPTIONAL, 0, stname, field, type)\n\n/* Same as above but for SET OF */\n\n# define ASN1_SET_OF(stname, field, type) \\\n                ASN1_EX_TYPE(ASN1_TFLG_SET_OF, 0, stname, field, type)\n\n# define ASN1_SET_OF_OPT(stname, field, type) \\\n                ASN1_EX_TYPE(ASN1_TFLG_SET_OF|ASN1_TFLG_OPTIONAL, 0, stname, field, type)\n\n/* Finally compound types of SEQUENCE, SET, IMPLICIT, EXPLICIT and OPTIONAL */\n\n# define ASN1_IMP_SET_OF(stname, field, type, tag) \\\n                        ASN1_IMP_EX(stname, field, type, tag, ASN1_TFLG_SET_OF)\n\n# define ASN1_EXP_SET_OF(stname, field, type, tag) \\\n                        ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_SET_OF)\n\n# define ASN1_IMP_SET_OF_OPT(stname, field, type, tag) \\\n                        ASN1_IMP_EX(stname, field, type, tag, ASN1_TFLG_SET_OF|ASN1_TFLG_OPTIONAL)\n\n# define ASN1_EXP_SET_OF_OPT(stname, field, type, tag) \\\n                        ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_SET_OF|ASN1_TFLG_OPTIONAL)\n\n# define ASN1_IMP_SEQUENCE_OF(stname, field, type, tag) \\\n                        ASN1_IMP_EX(stname, field, type, tag, ASN1_TFLG_SEQUENCE_OF)\n\n# define ASN1_IMP_SEQUENCE_OF_OPT(stname, field, type, tag) \\\n                        ASN1_IMP_EX(stname, field, type, tag, ASN1_TFLG_SEQUENCE_OF|ASN1_TFLG_OPTIONAL)\n\n# define ASN1_EXP_SEQUENCE_OF(stname, field, type, tag) \\\n                        ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_SEQUENCE_OF)\n\n# define ASN1_EXP_SEQUENCE_OF_OPT(stname, field, type, tag) \\\n                        ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_SEQUENCE_OF|ASN1_TFLG_OPTIONAL)\n\n/* EXPLICIT using indefinite length constructed form */\n# define ASN1_NDEF_EXP(stname, field, type, tag) \\\n                        ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_NDEF)\n\n/* EXPLICIT OPTIONAL using indefinite length constructed form */\n# define ASN1_NDEF_EXP_OPT(stname, field, type, tag) \\\n                        ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_OPTIONAL|ASN1_TFLG_NDEF)\n\n/* Macros for the ASN1_ADB structure */\n\n# define ASN1_ADB(name) \\\n        static const ASN1_ADB_TABLE name##_adbtbl[]\n\n# ifndef OPENSSL_EXPORT_VAR_AS_FUNCTION\n\n#  define ASN1_ADB_END(name, flags, field, app_table, def, none) \\\n        ;\\\n        static const ASN1_ADB name##_adb = {\\\n                flags,\\\n                offsetof(name, field),\\\n                app_table,\\\n                name##_adbtbl,\\\n                sizeof(name##_adbtbl) / sizeof(ASN1_ADB_TABLE),\\\n                def,\\\n                none\\\n        }\n\n# else\n\n#  define ASN1_ADB_END(name, flags, field, app_table, def, none) \\\n        ;\\\n        static const ASN1_ITEM *name##_adb(void) \\\n        { \\\n        static const ASN1_ADB internal_adb = \\\n                {\\\n                flags,\\\n                offsetof(name, field),\\\n                app_table,\\\n                name##_adbtbl,\\\n                sizeof(name##_adbtbl) / sizeof(ASN1_ADB_TABLE),\\\n                def,\\\n                none\\\n                }; \\\n                return (const ASN1_ITEM *) &internal_adb; \\\n        } \\\n        void dummy_function(void)\n\n# endif\n\n# define ADB_ENTRY(val, template) {val, template}\n\n# define ASN1_ADB_TEMPLATE(name) \\\n        static const ASN1_TEMPLATE name##_tt\n\n/*\n * This is the ASN1 template structure that defines a wrapper round the\n * actual type. It determines the actual position of the field in the value\n * structure, various flags such as OPTIONAL and the field name.\n */\n\nstruct ASN1_TEMPLATE_st {\n    unsigned long flags;        /* Various flags */\n    long tag;                   /* tag, not used if no tagging */\n    unsigned long offset;       /* Offset of this field in structure */\n# ifndef NO_ASN1_FIELD_NAMES\n    const char *field_name;     /* Field name */\n# endif\n    ASN1_ITEM_EXP *item;        /* Relevant ASN1_ITEM or ASN1_ADB */\n};\n\n/* Macro to extract ASN1_ITEM and ASN1_ADB pointer from ASN1_TEMPLATE */\n\n# define ASN1_TEMPLATE_item(t) (t->item_ptr)\n# define ASN1_TEMPLATE_adb(t) (t->item_ptr)\n\ntypedef struct ASN1_ADB_TABLE_st ASN1_ADB_TABLE;\ntypedef struct ASN1_ADB_st ASN1_ADB;\n\nstruct ASN1_ADB_st {\n    unsigned long flags;        /* Various flags */\n    unsigned long offset;       /* Offset of selector field */\n    STACK_OF(ASN1_ADB_TABLE) **app_items; /* Application defined items */\n    const ASN1_ADB_TABLE *tbl;  /* Table of possible types */\n    long tblcount;              /* Number of entries in tbl */\n    const ASN1_TEMPLATE *default_tt; /* Type to use if no match */\n    const ASN1_TEMPLATE *null_tt; /* Type to use if selector is NULL */\n};\n\nstruct ASN1_ADB_TABLE_st {\n    long value;                 /* NID for an object or value for an int */\n    const ASN1_TEMPLATE tt;     /* item for this value */\n};\n\n/* template flags */\n\n/* Field is optional */\n# define ASN1_TFLG_OPTIONAL      (0x1)\n\n/* Field is a SET OF */\n# define ASN1_TFLG_SET_OF        (0x1 << 1)\n\n/* Field is a SEQUENCE OF */\n# define ASN1_TFLG_SEQUENCE_OF   (0x2 << 1)\n\n/*\n * Special case: this refers to a SET OF that will be sorted into DER order\n * when encoded *and* the corresponding STACK will be modified to match the\n * new order.\n */\n# define ASN1_TFLG_SET_ORDER     (0x3 << 1)\n\n/* Mask for SET OF or SEQUENCE OF */\n# define ASN1_TFLG_SK_MASK       (0x3 << 1)\n\n/*\n * These flags mean the tag should be taken from the tag field. If EXPLICIT\n * then the underlying type is used for the inner tag.\n */\n\n/* IMPLICIT tagging */\n# define ASN1_TFLG_IMPTAG        (0x1 << 3)\n\n/* EXPLICIT tagging, inner tag from underlying type */\n# define ASN1_TFLG_EXPTAG        (0x2 << 3)\n\n# define ASN1_TFLG_TAG_MASK      (0x3 << 3)\n\n/* context specific IMPLICIT */\n# define ASN1_TFLG_IMPLICIT      ASN1_TFLG_IMPTAG|ASN1_TFLG_CONTEXT\n\n/* context specific EXPLICIT */\n# define ASN1_TFLG_EXPLICIT      ASN1_TFLG_EXPTAG|ASN1_TFLG_CONTEXT\n\n/*\n * If tagging is in force these determine the type of tag to use. Otherwise\n * the tag is determined by the underlying type. These values reflect the\n * actual octet format.\n */\n\n/* Universal tag */\n# define ASN1_TFLG_UNIVERSAL     (0x0<<6)\n/* Application tag */\n# define ASN1_TFLG_APPLICATION   (0x1<<6)\n/* Context specific tag */\n# define ASN1_TFLG_CONTEXT       (0x2<<6)\n/* Private tag */\n# define ASN1_TFLG_PRIVATE       (0x3<<6)\n\n# define ASN1_TFLG_TAG_CLASS     (0x3<<6)\n\n/*\n * These are for ANY DEFINED BY type. In this case the 'item' field points to\n * an ASN1_ADB structure which contains a table of values to decode the\n * relevant type\n */\n\n# define ASN1_TFLG_ADB_MASK      (0x3<<8)\n\n# define ASN1_TFLG_ADB_OID       (0x1<<8)\n\n# define ASN1_TFLG_ADB_INT       (0x1<<9)\n\n/*\n * This flag means a parent structure is passed instead of the field: this is\n * useful is a SEQUENCE is being combined with a CHOICE for example. Since\n * this means the structure and item name will differ we need to use the\n * ASN1_CHOICE_END_name() macro for example.\n */\n\n# define ASN1_TFLG_COMBINE       (0x1<<10)\n\n/*\n * This flag when present in a SEQUENCE OF, SET OF or EXPLICIT causes\n * indefinite length constructed encoding to be used if required.\n */\n\n# define ASN1_TFLG_NDEF          (0x1<<11)\n\n/* This is the actual ASN1 item itself */\n\nstruct ASN1_ITEM_st {\n    char itype;                 /* The item type, primitive, SEQUENCE, CHOICE\n                                 * or extern */\n    long utype;                 /* underlying type */\n    const ASN1_TEMPLATE *templates; /* If SEQUENCE or CHOICE this contains\n                                     * the contents */\n    long tcount;                /* Number of templates if SEQUENCE or CHOICE */\n    const void *funcs;          /* functions that handle this type */\n    long size;                  /* Structure size (usually) */\n# ifndef NO_ASN1_FIELD_NAMES\n    const char *sname;          /* Structure name */\n# endif\n};\n\n/*-\n * These are values for the itype field and\n * determine how the type is interpreted.\n *\n * For PRIMITIVE types the underlying type\n * determines the behaviour if items is NULL.\n *\n * Otherwise templates must contain a single\n * template and the type is treated in the\n * same way as the type specified in the template.\n *\n * For SEQUENCE types the templates field points\n * to the members, the size field is the\n * structure size.\n *\n * For CHOICE types the templates field points\n * to each possible member (typically a union)\n * and the 'size' field is the offset of the\n * selector.\n *\n * The 'funcs' field is used for application\n * specific functions.\n *\n * For COMPAT types the funcs field gives a\n * set of functions that handle this type, this\n * supports the old d2i, i2d convention.\n *\n * The EXTERN type uses a new style d2i/i2d.\n * The new style should be used where possible\n * because it avoids things like the d2i IMPLICIT\n * hack.\n *\n * MSTRING is a multiple string type, it is used\n * for a CHOICE of character strings where the\n * actual strings all occupy an ASN1_STRING\n * structure. In this case the 'utype' field\n * has a special meaning, it is used as a mask\n * of acceptable types using the B_ASN1 constants.\n *\n * NDEF_SEQUENCE is the same as SEQUENCE except\n * that it will use indefinite length constructed\n * encoding if requested.\n *\n */\n\n# define ASN1_ITYPE_PRIMITIVE            0x0\n\n# define ASN1_ITYPE_SEQUENCE             0x1\n\n# define ASN1_ITYPE_CHOICE               0x2\n\n# define ASN1_ITYPE_COMPAT               0x3\n\n# define ASN1_ITYPE_EXTERN               0x4\n\n# define ASN1_ITYPE_MSTRING              0x5\n\n# define ASN1_ITYPE_NDEF_SEQUENCE        0x6\n\n/*\n * Cache for ASN1 tag and length, so we don't keep re-reading it for things\n * like CHOICE\n */\n\nstruct ASN1_TLC_st {\n    char valid;                 /* Values below are valid */\n    int ret;                    /* return value */\n    long plen;                  /* length */\n    int ptag;                   /* class value */\n    int pclass;                 /* class value */\n    int hdrlen;                 /* header length */\n};\n\n/* Typedefs for ASN1 function pointers */\n\ntypedef ASN1_VALUE *ASN1_new_func(void);\ntypedef void ASN1_free_func(ASN1_VALUE *a);\ntypedef ASN1_VALUE *ASN1_d2i_func(ASN1_VALUE **a, const unsigned char **in,\n                                  long length);\ntypedef int ASN1_i2d_func(ASN1_VALUE *a, unsigned char **in);\n\ntypedef int ASN1_ex_d2i(ASN1_VALUE **pval, const unsigned char **in, long len,\n                        const ASN1_ITEM *it, int tag, int aclass, char opt,\n                        ASN1_TLC *ctx);\n\ntypedef int ASN1_ex_i2d(ASN1_VALUE **pval, unsigned char **out,\n                        const ASN1_ITEM *it, int tag, int aclass);\ntypedef int ASN1_ex_new_func(ASN1_VALUE **pval, const ASN1_ITEM *it);\ntypedef void ASN1_ex_free_func(ASN1_VALUE **pval, const ASN1_ITEM *it);\n\ntypedef int ASN1_ex_print_func(BIO *out, ASN1_VALUE **pval,\n                               int indent, const char *fname,\n                               const ASN1_PCTX *pctx);\n\ntypedef int ASN1_primitive_i2c(ASN1_VALUE **pval, unsigned char *cont,\n                               int *putype, const ASN1_ITEM *it);\ntypedef int ASN1_primitive_c2i(ASN1_VALUE **pval, const unsigned char *cont,\n                               int len, int utype, char *free_cont,\n                               const ASN1_ITEM *it);\ntypedef int ASN1_primitive_print(BIO *out, ASN1_VALUE **pval,\n                                 const ASN1_ITEM *it, int indent,\n                                 const ASN1_PCTX *pctx);\n\ntypedef struct ASN1_COMPAT_FUNCS_st {\n    ASN1_new_func *asn1_new;\n    ASN1_free_func *asn1_free;\n    ASN1_d2i_func *asn1_d2i;\n    ASN1_i2d_func *asn1_i2d;\n} ASN1_COMPAT_FUNCS;\n\ntypedef struct ASN1_EXTERN_FUNCS_st {\n    void *app_data;\n    ASN1_ex_new_func *asn1_ex_new;\n    ASN1_ex_free_func *asn1_ex_free;\n    ASN1_ex_free_func *asn1_ex_clear;\n    ASN1_ex_d2i *asn1_ex_d2i;\n    ASN1_ex_i2d *asn1_ex_i2d;\n    ASN1_ex_print_func *asn1_ex_print;\n} ASN1_EXTERN_FUNCS;\n\ntypedef struct ASN1_PRIMITIVE_FUNCS_st {\n    void *app_data;\n    unsigned long flags;\n    ASN1_ex_new_func *prim_new;\n    ASN1_ex_free_func *prim_free;\n    ASN1_ex_free_func *prim_clear;\n    ASN1_primitive_c2i *prim_c2i;\n    ASN1_primitive_i2c *prim_i2c;\n    ASN1_primitive_print *prim_print;\n} ASN1_PRIMITIVE_FUNCS;\n\n/*\n * This is the ASN1_AUX structure: it handles various miscellaneous\n * requirements. For example the use of reference counts and an informational\n * callback. The \"informational callback\" is called at various points during\n * the ASN1 encoding and decoding. It can be used to provide minor\n * customisation of the structures used. This is most useful where the\n * supplied routines *almost* do the right thing but need some extra help at\n * a few points. If the callback returns zero then it is assumed a fatal\n * error has occurred and the main operation should be abandoned. If major\n * changes in the default behaviour are required then an external type is\n * more appropriate.\n */\n\ntypedef int ASN1_aux_cb(int operation, ASN1_VALUE **in, const ASN1_ITEM *it,\n                        void *exarg);\n\ntypedef struct ASN1_AUX_st {\n    void *app_data;\n    int flags;\n    int ref_offset;             /* Offset of reference value */\n    int ref_lock;               /* Lock type to use */\n    ASN1_aux_cb *asn1_cb;\n    int enc_offset;             /* Offset of ASN1_ENCODING structure */\n} ASN1_AUX;\n\n/* For print related callbacks exarg points to this structure */\ntypedef struct ASN1_PRINT_ARG_st {\n    BIO *out;\n    int indent;\n    const ASN1_PCTX *pctx;\n} ASN1_PRINT_ARG;\n\n/* For streaming related callbacks exarg points to this structure */\ntypedef struct ASN1_STREAM_ARG_st {\n    /* BIO to stream through */\n    BIO *out;\n    /* BIO with filters appended */\n    BIO *ndef_bio;\n    /* Streaming I/O boundary */\n    unsigned char **boundary;\n} ASN1_STREAM_ARG;\n\n/* Flags in ASN1_AUX */\n\n/* Use a reference count */\n# define ASN1_AFLG_REFCOUNT      1\n/* Save the encoding of structure (useful for signatures) */\n# define ASN1_AFLG_ENCODING      2\n/* The Sequence length is invalid */\n# define ASN1_AFLG_BROKEN        4\n\n/* operation values for asn1_cb */\n\n# define ASN1_OP_NEW_PRE         0\n# define ASN1_OP_NEW_POST        1\n# define ASN1_OP_FREE_PRE        2\n# define ASN1_OP_FREE_POST       3\n# define ASN1_OP_D2I_PRE         4\n# define ASN1_OP_D2I_POST        5\n# define ASN1_OP_I2D_PRE         6\n# define ASN1_OP_I2D_POST        7\n# define ASN1_OP_PRINT_PRE       8\n# define ASN1_OP_PRINT_POST      9\n# define ASN1_OP_STREAM_PRE      10\n# define ASN1_OP_STREAM_POST     11\n# define ASN1_OP_DETACHED_PRE    12\n# define ASN1_OP_DETACHED_POST   13\n\n/* Macro to implement a primitive type */\n# define IMPLEMENT_ASN1_TYPE(stname) IMPLEMENT_ASN1_TYPE_ex(stname, stname, 0)\n# define IMPLEMENT_ASN1_TYPE_ex(itname, vname, ex) \\\n                                ASN1_ITEM_start(itname) \\\n                                        ASN1_ITYPE_PRIMITIVE, V_##vname, NULL, 0, NULL, ex, #itname \\\n                                ASN1_ITEM_end(itname)\n\n/* Macro to implement a multi string type */\n# define IMPLEMENT_ASN1_MSTRING(itname, mask) \\\n                                ASN1_ITEM_start(itname) \\\n                                        ASN1_ITYPE_MSTRING, mask, NULL, 0, NULL, sizeof(ASN1_STRING), #itname \\\n                                ASN1_ITEM_end(itname)\n\n/* Macro to implement an ASN1_ITEM in terms of old style funcs */\n\n# define IMPLEMENT_COMPAT_ASN1(sname) IMPLEMENT_COMPAT_ASN1_type(sname, V_ASN1_SEQUENCE)\n\n# define IMPLEMENT_COMPAT_ASN1_type(sname, tag) \\\n        static const ASN1_COMPAT_FUNCS sname##_ff = { \\\n                (ASN1_new_func *)sname##_new, \\\n                (ASN1_free_func *)sname##_free, \\\n                (ASN1_d2i_func *)d2i_##sname, \\\n                (ASN1_i2d_func *)i2d_##sname, \\\n        }; \\\n        ASN1_ITEM_start(sname) \\\n                ASN1_ITYPE_COMPAT, \\\n                tag, \\\n                NULL, \\\n                0, \\\n                &sname##_ff, \\\n                0, \\\n                #sname \\\n        ASN1_ITEM_end(sname)\n\n# define IMPLEMENT_EXTERN_ASN1(sname, tag, fptrs) \\\n        ASN1_ITEM_start(sname) \\\n                ASN1_ITYPE_EXTERN, \\\n                tag, \\\n                NULL, \\\n                0, \\\n                &fptrs, \\\n                0, \\\n                #sname \\\n        ASN1_ITEM_end(sname)\n\n/* Macro to implement standard functions in terms of ASN1_ITEM structures */\n\n# define IMPLEMENT_ASN1_FUNCTIONS(stname) IMPLEMENT_ASN1_FUNCTIONS_fname(stname, stname, stname)\n\n# define IMPLEMENT_ASN1_FUNCTIONS_name(stname, itname) IMPLEMENT_ASN1_FUNCTIONS_fname(stname, itname, itname)\n\n# define IMPLEMENT_ASN1_FUNCTIONS_ENCODE_name(stname, itname) \\\n                        IMPLEMENT_ASN1_FUNCTIONS_ENCODE_fname(stname, itname, itname)\n\n# define IMPLEMENT_STATIC_ASN1_ALLOC_FUNCTIONS(stname) \\\n                IMPLEMENT_ASN1_ALLOC_FUNCTIONS_pfname(static, stname, stname, stname)\n\n# define IMPLEMENT_ASN1_ALLOC_FUNCTIONS(stname) \\\n                IMPLEMENT_ASN1_ALLOC_FUNCTIONS_fname(stname, stname, stname)\n\n# define IMPLEMENT_ASN1_ALLOC_FUNCTIONS_pfname(pre, stname, itname, fname) \\\n        pre stname *fname##_new(void) \\\n        { \\\n                return (stname *)ASN1_item_new(ASN1_ITEM_rptr(itname)); \\\n        } \\\n        pre void fname##_free(stname *a) \\\n        { \\\n                ASN1_item_free((ASN1_VALUE *)a, ASN1_ITEM_rptr(itname)); \\\n        }\n\n# define IMPLEMENT_ASN1_ALLOC_FUNCTIONS_fname(stname, itname, fname) \\\n        stname *fname##_new(void) \\\n        { \\\n                return (stname *)ASN1_item_new(ASN1_ITEM_rptr(itname)); \\\n        } \\\n        void fname##_free(stname *a) \\\n        { \\\n                ASN1_item_free((ASN1_VALUE *)a, ASN1_ITEM_rptr(itname)); \\\n        }\n\n# define IMPLEMENT_ASN1_FUNCTIONS_fname(stname, itname, fname) \\\n        IMPLEMENT_ASN1_ENCODE_FUNCTIONS_fname(stname, itname, fname) \\\n        IMPLEMENT_ASN1_ALLOC_FUNCTIONS_fname(stname, itname, fname)\n\n# define IMPLEMENT_ASN1_ENCODE_FUNCTIONS_fname(stname, itname, fname) \\\n        stname *d2i_##fname(stname **a, const unsigned char **in, long len) \\\n        { \\\n                return (stname *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, ASN1_ITEM_rptr(itname));\\\n        } \\\n        int i2d_##fname(stname *a, unsigned char **out) \\\n        { \\\n                return ASN1_item_i2d((ASN1_VALUE *)a, out, ASN1_ITEM_rptr(itname));\\\n        }\n\n# define IMPLEMENT_ASN1_NDEF_FUNCTION(stname) \\\n        int i2d_##stname##_NDEF(stname *a, unsigned char **out) \\\n        { \\\n                return ASN1_item_ndef_i2d((ASN1_VALUE *)a, out, ASN1_ITEM_rptr(stname));\\\n        }\n\n/*\n * This includes evil casts to remove const: they will go away when full ASN1\n * constification is done.\n */\n# define IMPLEMENT_ASN1_ENCODE_FUNCTIONS_const_fname(stname, itname, fname) \\\n        stname *d2i_##fname(stname **a, const unsigned char **in, long len) \\\n        { \\\n                return (stname *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, ASN1_ITEM_rptr(itname));\\\n        } \\\n        int i2d_##fname(const stname *a, unsigned char **out) \\\n        { \\\n                return ASN1_item_i2d((ASN1_VALUE *)a, out, ASN1_ITEM_rptr(itname));\\\n        }\n\n# define IMPLEMENT_ASN1_DUP_FUNCTION(stname) \\\n        stname * stname##_dup(stname *x) \\\n        { \\\n        return ASN1_item_dup(ASN1_ITEM_rptr(stname), x); \\\n        }\n\n# define IMPLEMENT_ASN1_PRINT_FUNCTION(stname) \\\n        IMPLEMENT_ASN1_PRINT_FUNCTION_fname(stname, stname, stname)\n\n# define IMPLEMENT_ASN1_PRINT_FUNCTION_fname(stname, itname, fname) \\\n        int fname##_print_ctx(BIO *out, stname *x, int indent, \\\n                                                const ASN1_PCTX *pctx) \\\n        { \\\n                return ASN1_item_print(out, (ASN1_VALUE *)x, indent, \\\n                        ASN1_ITEM_rptr(itname), pctx); \\\n        }\n\n# define IMPLEMENT_ASN1_FUNCTIONS_const(name) \\\n                IMPLEMENT_ASN1_FUNCTIONS_const_fname(name, name, name)\n\n# define IMPLEMENT_ASN1_FUNCTIONS_const_fname(stname, itname, fname) \\\n        IMPLEMENT_ASN1_ENCODE_FUNCTIONS_const_fname(stname, itname, fname) \\\n        IMPLEMENT_ASN1_ALLOC_FUNCTIONS_fname(stname, itname, fname)\n\n/* external definitions for primitive types */\n\nDECLARE_ASN1_ITEM(ASN1_BOOLEAN)\nDECLARE_ASN1_ITEM(ASN1_TBOOLEAN)\nDECLARE_ASN1_ITEM(ASN1_FBOOLEAN)\nDECLARE_ASN1_ITEM(ASN1_SEQUENCE)\nDECLARE_ASN1_ITEM(CBIGNUM)\nDECLARE_ASN1_ITEM(BIGNUM)\nDECLARE_ASN1_ITEM(LONG)\nDECLARE_ASN1_ITEM(ZLONG)\n\nDECLARE_STACK_OF(ASN1_VALUE)\n\n/* Functions used internally by the ASN1 code */\n\nint ASN1_item_ex_new(ASN1_VALUE **pval, const ASN1_ITEM *it);\nvoid ASN1_item_ex_free(ASN1_VALUE **pval, const ASN1_ITEM *it);\nint ASN1_template_new(ASN1_VALUE **pval, const ASN1_TEMPLATE *tt);\nint ASN1_primitive_new(ASN1_VALUE **pval, const ASN1_ITEM *it);\n\nvoid ASN1_template_free(ASN1_VALUE **pval, const ASN1_TEMPLATE *tt);\nint ASN1_template_d2i(ASN1_VALUE **pval, const unsigned char **in, long len,\n                      const ASN1_TEMPLATE *tt);\nint ASN1_item_ex_d2i(ASN1_VALUE **pval, const unsigned char **in, long len,\n                     const ASN1_ITEM *it, int tag, int aclass, char opt,\n                     ASN1_TLC *ctx);\n\nint ASN1_item_ex_i2d(ASN1_VALUE **pval, unsigned char **out,\n                     const ASN1_ITEM *it, int tag, int aclass);\nint ASN1_template_i2d(ASN1_VALUE **pval, unsigned char **out,\n                      const ASN1_TEMPLATE *tt);\nvoid ASN1_primitive_free(ASN1_VALUE **pval, const ASN1_ITEM *it);\n\nint asn1_ex_i2c(ASN1_VALUE **pval, unsigned char *cont, int *putype,\n                const ASN1_ITEM *it);\nint asn1_ex_c2i(ASN1_VALUE **pval, const unsigned char *cont, int len,\n                int utype, char *free_cont, const ASN1_ITEM *it);\n\nint asn1_get_choice_selector(ASN1_VALUE **pval, const ASN1_ITEM *it);\nint asn1_set_choice_selector(ASN1_VALUE **pval, int value,\n                             const ASN1_ITEM *it);\n\nASN1_VALUE **asn1_get_field_ptr(ASN1_VALUE **pval, const ASN1_TEMPLATE *tt);\n\nconst ASN1_TEMPLATE *asn1_do_adb(ASN1_VALUE **pval, const ASN1_TEMPLATE *tt,\n                                 int nullerr);\n\nint asn1_do_lock(ASN1_VALUE **pval, int op, const ASN1_ITEM *it);\n\nvoid asn1_enc_init(ASN1_VALUE **pval, const ASN1_ITEM *it);\nvoid asn1_enc_free(ASN1_VALUE **pval, const ASN1_ITEM *it);\nint asn1_enc_restore(int *len, unsigned char **out, ASN1_VALUE **pval,\n                     const ASN1_ITEM *it);\nint asn1_enc_save(ASN1_VALUE **pval, const unsigned char *in, int inlen,\n                  const ASN1_ITEM *it);\n\n#ifdef  __cplusplus\n}\n#endif\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/arm/include/openssl/bio.h",
    "content": "/* crypto/bio/bio.h */\n/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)\n * All rights reserved.\n *\n * This package is an SSL implementation written\n * by Eric Young (eay@cryptsoft.com).\n * The implementation was written so as to conform with Netscapes SSL.\n *\n * This library is free for commercial and non-commercial use as long as\n * the following conditions are aheared to.  The following conditions\n * apply to all code found in this distribution, be it the RC4, RSA,\n * lhash, DES, etc., code; not just the SSL code.  The SSL documentation\n * included with this distribution is covered by the same copyright terms\n * except that the holder is Tim Hudson (tjh@cryptsoft.com).\n *\n * Copyright remains Eric Young's, and as such any Copyright notices in\n * the code are not to be removed.\n * If this package is used in a product, Eric Young should be given attribution\n * as the author of the parts of the library used.\n * This can be in the form of a textual message at program startup or\n * in documentation (online or textual) provided with the package.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the copyright\n *    notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in the\n *    documentation and/or other materials provided with the distribution.\n * 3. All advertising materials mentioning features or use of this software\n *    must display the following acknowledgement:\n *    \"This product includes cryptographic software written by\n *     Eric Young (eay@cryptsoft.com)\"\n *    The word 'cryptographic' can be left out if the rouines from the library\n *    being used are not cryptographic related :-).\n * 4. If you include any Windows specific code (or a derivative thereof) from\n *    the apps directory (application code) you must include an acknowledgement:\n *    \"This product includes software written by Tim Hudson (tjh@cryptsoft.com)\"\n *\n * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n * SUCH DAMAGE.\n *\n * The licence and distribution terms for any publically available version or\n * derivative of this code cannot be changed.  i.e. this code cannot simply be\n * copied and put under another distribution licence\n * [including the GNU Public Licence.]\n */\n\n#ifndef HEADER_BIO_H\n# define HEADER_BIO_H\n\n# include <openssl/e_os2.h>\n\n# ifndef OPENSSL_NO_FP_API\n#  include <stdio.h>\n# endif\n# include <stdarg.h>\n\n# include <openssl/crypto.h>\n\n# ifndef OPENSSL_NO_SCTP\n#  ifndef OPENSSL_SYS_VMS\n#   include <stdint.h>\n#  else\n#   include <inttypes.h>\n#  endif\n# endif\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n/* These are the 'types' of BIOs */\n# define BIO_TYPE_NONE           0\n# define BIO_TYPE_MEM            (1|0x0400)\n# define BIO_TYPE_FILE           (2|0x0400)\n\n# define BIO_TYPE_FD             (4|0x0400|0x0100)\n# define BIO_TYPE_SOCKET         (5|0x0400|0x0100)\n# define BIO_TYPE_NULL           (6|0x0400)\n# define BIO_TYPE_SSL            (7|0x0200)\n# define BIO_TYPE_MD             (8|0x0200)/* passive filter */\n# define BIO_TYPE_BUFFER         (9|0x0200)/* filter */\n# define BIO_TYPE_CIPHER         (10|0x0200)/* filter */\n# define BIO_TYPE_BASE64         (11|0x0200)/* filter */\n# define BIO_TYPE_CONNECT        (12|0x0400|0x0100)/* socket - connect */\n# define BIO_TYPE_ACCEPT         (13|0x0400|0x0100)/* socket for accept */\n# define BIO_TYPE_PROXY_CLIENT   (14|0x0200)/* client proxy BIO */\n# define BIO_TYPE_PROXY_SERVER   (15|0x0200)/* server proxy BIO */\n# define BIO_TYPE_NBIO_TEST      (16|0x0200)/* server proxy BIO */\n# define BIO_TYPE_NULL_FILTER    (17|0x0200)\n# define BIO_TYPE_BER            (18|0x0200)/* BER -> bin filter */\n# define BIO_TYPE_BIO            (19|0x0400)/* (half a) BIO pair */\n# define BIO_TYPE_LINEBUFFER     (20|0x0200)/* filter */\n# define BIO_TYPE_DGRAM          (21|0x0400|0x0100)\n# ifndef OPENSSL_NO_SCTP\n#  define BIO_TYPE_DGRAM_SCTP     (24|0x0400|0x0100)\n# endif\n# define BIO_TYPE_ASN1           (22|0x0200)/* filter */\n# define BIO_TYPE_COMP           (23|0x0200)/* filter */\n\n# define BIO_TYPE_DESCRIPTOR     0x0100/* socket, fd, connect or accept */\n# define BIO_TYPE_FILTER         0x0200\n# define BIO_TYPE_SOURCE_SINK    0x0400\n\n/*\n * BIO_FILENAME_READ|BIO_CLOSE to open or close on free.\n * BIO_set_fp(in,stdin,BIO_NOCLOSE);\n */\n# define BIO_NOCLOSE             0x00\n# define BIO_CLOSE               0x01\n\n/*\n * These are used in the following macros and are passed to BIO_ctrl()\n */\n# define BIO_CTRL_RESET          1/* opt - rewind/zero etc */\n# define BIO_CTRL_EOF            2/* opt - are we at the eof */\n# define BIO_CTRL_INFO           3/* opt - extra tit-bits */\n# define BIO_CTRL_SET            4/* man - set the 'IO' type */\n# define BIO_CTRL_GET            5/* man - get the 'IO' type */\n# define BIO_CTRL_PUSH           6/* opt - internal, used to signify change */\n# define BIO_CTRL_POP            7/* opt - internal, used to signify change */\n# define BIO_CTRL_GET_CLOSE      8/* man - set the 'close' on free */\n# define BIO_CTRL_SET_CLOSE      9/* man - set the 'close' on free */\n# define BIO_CTRL_PENDING        10/* opt - is their more data buffered */\n# define BIO_CTRL_FLUSH          11/* opt - 'flush' buffered output */\n# define BIO_CTRL_DUP            12/* man - extra stuff for 'duped' BIO */\n# define BIO_CTRL_WPENDING       13/* opt - number of bytes still to write */\n/* callback is int cb(BIO *bio,state,ret); */\n# define BIO_CTRL_SET_CALLBACK   14/* opt - set callback function */\n# define BIO_CTRL_GET_CALLBACK   15/* opt - set callback function */\n\n# define BIO_CTRL_SET_FILENAME   30/* BIO_s_file special */\n\n/* dgram BIO stuff */\n# define BIO_CTRL_DGRAM_CONNECT       31/* BIO dgram special */\n# define BIO_CTRL_DGRAM_SET_CONNECTED 32/* allow for an externally connected\n                                         * socket to be passed in */\n# define BIO_CTRL_DGRAM_SET_RECV_TIMEOUT 33/* setsockopt, essentially */\n# define BIO_CTRL_DGRAM_GET_RECV_TIMEOUT 34/* getsockopt, essentially */\n# define BIO_CTRL_DGRAM_SET_SEND_TIMEOUT 35/* setsockopt, essentially */\n# define BIO_CTRL_DGRAM_GET_SEND_TIMEOUT 36/* getsockopt, essentially */\n\n# define BIO_CTRL_DGRAM_GET_RECV_TIMER_EXP 37/* flag whether the last */\n# define BIO_CTRL_DGRAM_GET_SEND_TIMER_EXP 38/* I/O operation tiemd out */\n\n/* #ifdef IP_MTU_DISCOVER */\n# define BIO_CTRL_DGRAM_MTU_DISCOVER       39/* set DF bit on egress packets */\n/* #endif */\n\n# define BIO_CTRL_DGRAM_QUERY_MTU          40/* as kernel for current MTU */\n# define BIO_CTRL_DGRAM_GET_FALLBACK_MTU   47\n# define BIO_CTRL_DGRAM_GET_MTU            41/* get cached value for MTU */\n# define BIO_CTRL_DGRAM_SET_MTU            42/* set cached value for MTU.\n                                              * want to use this if asking\n                                              * the kernel fails */\n\n# define BIO_CTRL_DGRAM_MTU_EXCEEDED       43/* check whether the MTU was\n                                              * exceed in the previous write\n                                              * operation */\n\n# define BIO_CTRL_DGRAM_GET_PEER           46\n# define BIO_CTRL_DGRAM_SET_PEER           44/* Destination for the data */\n\n# define BIO_CTRL_DGRAM_SET_NEXT_TIMEOUT   45/* Next DTLS handshake timeout\n                                              * to adjust socket timeouts */\n# define BIO_CTRL_DGRAM_SET_DONT_FRAG      48\n\n# define BIO_CTRL_DGRAM_GET_MTU_OVERHEAD   49\n\n# ifndef OPENSSL_NO_SCTP\n/* SCTP stuff */\n#  define BIO_CTRL_DGRAM_SCTP_SET_IN_HANDSHAKE    50\n#  define BIO_CTRL_DGRAM_SCTP_ADD_AUTH_KEY                51\n#  define BIO_CTRL_DGRAM_SCTP_NEXT_AUTH_KEY               52\n#  define BIO_CTRL_DGRAM_SCTP_AUTH_CCS_RCVD               53\n#  define BIO_CTRL_DGRAM_SCTP_GET_SNDINFO         60\n#  define BIO_CTRL_DGRAM_SCTP_SET_SNDINFO         61\n#  define BIO_CTRL_DGRAM_SCTP_GET_RCVINFO         62\n#  define BIO_CTRL_DGRAM_SCTP_SET_RCVINFO         63\n#  define BIO_CTRL_DGRAM_SCTP_GET_PRINFO                  64\n#  define BIO_CTRL_DGRAM_SCTP_SET_PRINFO                  65\n#  define BIO_CTRL_DGRAM_SCTP_SAVE_SHUTDOWN               70\n# endif\n\n/* modifiers */\n# define BIO_FP_READ             0x02\n# define BIO_FP_WRITE            0x04\n# define BIO_FP_APPEND           0x08\n# define BIO_FP_TEXT             0x10\n\n# define BIO_FLAGS_READ          0x01\n# define BIO_FLAGS_WRITE         0x02\n# define BIO_FLAGS_IO_SPECIAL    0x04\n# define BIO_FLAGS_RWS (BIO_FLAGS_READ|BIO_FLAGS_WRITE|BIO_FLAGS_IO_SPECIAL)\n# define BIO_FLAGS_SHOULD_RETRY  0x08\n# ifndef BIO_FLAGS_UPLINK\n/*\n * \"UPLINK\" flag denotes file descriptors provided by application. It\n * defaults to 0, as most platforms don't require UPLINK interface.\n */\n#  define BIO_FLAGS_UPLINK        0\n# endif\n\n/* Used in BIO_gethostbyname() */\n# define BIO_GHBN_CTRL_HITS              1\n# define BIO_GHBN_CTRL_MISSES            2\n# define BIO_GHBN_CTRL_CACHE_SIZE        3\n# define BIO_GHBN_CTRL_GET_ENTRY         4\n# define BIO_GHBN_CTRL_FLUSH             5\n\n/* Mostly used in the SSL BIO */\n/*-\n * Not used anymore\n * #define BIO_FLAGS_PROTOCOL_DELAYED_READ 0x10\n * #define BIO_FLAGS_PROTOCOL_DELAYED_WRITE 0x20\n * #define BIO_FLAGS_PROTOCOL_STARTUP   0x40\n */\n\n# define BIO_FLAGS_BASE64_NO_NL  0x100\n\n/*\n * This is used with memory BIOs: it means we shouldn't free up or change the\n * data in any way.\n */\n# define BIO_FLAGS_MEM_RDONLY    0x200\n\ntypedef struct bio_st BIO;\n\nvoid BIO_set_flags(BIO *b, int flags);\nint BIO_test_flags(const BIO *b, int flags);\nvoid BIO_clear_flags(BIO *b, int flags);\n\n# define BIO_get_flags(b) BIO_test_flags(b, ~(0x0))\n# define BIO_set_retry_special(b) \\\n                BIO_set_flags(b, (BIO_FLAGS_IO_SPECIAL|BIO_FLAGS_SHOULD_RETRY))\n# define BIO_set_retry_read(b) \\\n                BIO_set_flags(b, (BIO_FLAGS_READ|BIO_FLAGS_SHOULD_RETRY))\n# define BIO_set_retry_write(b) \\\n                BIO_set_flags(b, (BIO_FLAGS_WRITE|BIO_FLAGS_SHOULD_RETRY))\n\n/* These are normally used internally in BIOs */\n# define BIO_clear_retry_flags(b) \\\n                BIO_clear_flags(b, (BIO_FLAGS_RWS|BIO_FLAGS_SHOULD_RETRY))\n# define BIO_get_retry_flags(b) \\\n                BIO_test_flags(b, (BIO_FLAGS_RWS|BIO_FLAGS_SHOULD_RETRY))\n\n/* These should be used by the application to tell why we should retry */\n# define BIO_should_read(a)              BIO_test_flags(a, BIO_FLAGS_READ)\n# define BIO_should_write(a)             BIO_test_flags(a, BIO_FLAGS_WRITE)\n# define BIO_should_io_special(a)        BIO_test_flags(a, BIO_FLAGS_IO_SPECIAL)\n# define BIO_retry_type(a)               BIO_test_flags(a, BIO_FLAGS_RWS)\n# define BIO_should_retry(a)             BIO_test_flags(a, BIO_FLAGS_SHOULD_RETRY)\n\n/*\n * The next three are used in conjunction with the BIO_should_io_special()\n * condition.  After this returns true, BIO *BIO_get_retry_BIO(BIO *bio, int\n * *reason); will walk the BIO stack and return the 'reason' for the special\n * and the offending BIO. Given a BIO, BIO_get_retry_reason(bio) will return\n * the code.\n */\n/*\n * Returned from the SSL bio when the certificate retrieval code had an error\n */\n# define BIO_RR_SSL_X509_LOOKUP          0x01\n/* Returned from the connect BIO when a connect would have blocked */\n# define BIO_RR_CONNECT                  0x02\n/* Returned from the accept BIO when an accept would have blocked */\n# define BIO_RR_ACCEPT                   0x03\n\n/* These are passed by the BIO callback */\n# define BIO_CB_FREE     0x01\n# define BIO_CB_READ     0x02\n# define BIO_CB_WRITE    0x03\n# define BIO_CB_PUTS     0x04\n# define BIO_CB_GETS     0x05\n# define BIO_CB_CTRL     0x06\n\n/*\n * The callback is called before and after the underling operation, The\n * BIO_CB_RETURN flag indicates if it is after the call\n */\n# define BIO_CB_RETURN   0x80\n# define BIO_CB_return(a) ((a)|BIO_CB_RETURN)\n# define BIO_cb_pre(a)   (!((a)&BIO_CB_RETURN))\n# define BIO_cb_post(a)  ((a)&BIO_CB_RETURN)\n\nlong (*BIO_get_callback(const BIO *b)) (struct bio_st *, int, const char *,\n                                        int, long, long);\nvoid BIO_set_callback(BIO *b,\n                      long (*callback) (struct bio_st *, int, const char *,\n                                        int, long, long));\nchar *BIO_get_callback_arg(const BIO *b);\nvoid BIO_set_callback_arg(BIO *b, char *arg);\n\nconst char *BIO_method_name(const BIO *b);\nint BIO_method_type(const BIO *b);\n\ntypedef void bio_info_cb (struct bio_st *, int, const char *, int, long,\n                          long);\n\ntypedef struct bio_method_st {\n    int type;\n    const char *name;\n    int (*bwrite) (BIO *, const char *, int);\n    int (*bread) (BIO *, char *, int);\n    int (*bputs) (BIO *, const char *);\n    int (*bgets) (BIO *, char *, int);\n    long (*ctrl) (BIO *, int, long, void *);\n    int (*create) (BIO *);\n    int (*destroy) (BIO *);\n    long (*callback_ctrl) (BIO *, int, bio_info_cb *);\n} BIO_METHOD;\n\nstruct bio_st {\n    BIO_METHOD *method;\n    /* bio, mode, argp, argi, argl, ret */\n    long (*callback) (struct bio_st *, int, const char *, int, long, long);\n    char *cb_arg;               /* first argument for the callback */\n    int init;\n    int shutdown;\n    int flags;                  /* extra storage */\n    int retry_reason;\n    int num;\n    void *ptr;\n    struct bio_st *next_bio;    /* used by filter BIOs */\n    struct bio_st *prev_bio;    /* used by filter BIOs */\n    int references;\n    unsigned long num_read;\n    unsigned long num_write;\n    CRYPTO_EX_DATA ex_data;\n};\n\nDECLARE_STACK_OF(BIO)\n\ntypedef struct bio_f_buffer_ctx_struct {\n    /*-\n     * Buffers are setup like this:\n     *\n     * <---------------------- size ----------------------->\n     * +---------------------------------------------------+\n     * | consumed | remaining          | free space        |\n     * +---------------------------------------------------+\n     * <-- off --><------- len ------->\n     */\n    /*- BIO *bio; *//*\n     * this is now in the BIO struct\n     */\n    int ibuf_size;              /* how big is the input buffer */\n    int obuf_size;              /* how big is the output buffer */\n    char *ibuf;                 /* the char array */\n    int ibuf_len;               /* how many bytes are in it */\n    int ibuf_off;               /* write/read offset */\n    char *obuf;                 /* the char array */\n    int obuf_len;               /* how many bytes are in it */\n    int obuf_off;               /* write/read offset */\n} BIO_F_BUFFER_CTX;\n\n/* Prefix and suffix callback in ASN1 BIO */\ntypedef int asn1_ps_func (BIO *b, unsigned char **pbuf, int *plen,\n                          void *parg);\n\n# ifndef OPENSSL_NO_SCTP\n/* SCTP parameter structs */\nstruct bio_dgram_sctp_sndinfo {\n    uint16_t snd_sid;\n    uint16_t snd_flags;\n    uint32_t snd_ppid;\n    uint32_t snd_context;\n};\n\nstruct bio_dgram_sctp_rcvinfo {\n    uint16_t rcv_sid;\n    uint16_t rcv_ssn;\n    uint16_t rcv_flags;\n    uint32_t rcv_ppid;\n    uint32_t rcv_tsn;\n    uint32_t rcv_cumtsn;\n    uint32_t rcv_context;\n};\n\nstruct bio_dgram_sctp_prinfo {\n    uint16_t pr_policy;\n    uint32_t pr_value;\n};\n# endif\n\n/* connect BIO stuff */\n# define BIO_CONN_S_BEFORE               1\n# define BIO_CONN_S_GET_IP               2\n# define BIO_CONN_S_GET_PORT             3\n# define BIO_CONN_S_CREATE_SOCKET        4\n# define BIO_CONN_S_CONNECT              5\n# define BIO_CONN_S_OK                   6\n# define BIO_CONN_S_BLOCKED_CONNECT      7\n# define BIO_CONN_S_NBIO                 8\n/*\n * #define BIO_CONN_get_param_hostname BIO_ctrl\n */\n\n# define BIO_C_SET_CONNECT                       100\n# define BIO_C_DO_STATE_MACHINE                  101\n# define BIO_C_SET_NBIO                          102\n# define BIO_C_SET_PROXY_PARAM                   103\n# define BIO_C_SET_FD                            104\n# define BIO_C_GET_FD                            105\n# define BIO_C_SET_FILE_PTR                      106\n# define BIO_C_GET_FILE_PTR                      107\n# define BIO_C_SET_FILENAME                      108\n# define BIO_C_SET_SSL                           109\n# define BIO_C_GET_SSL                           110\n# define BIO_C_SET_MD                            111\n# define BIO_C_GET_MD                            112\n# define BIO_C_GET_CIPHER_STATUS                 113\n# define BIO_C_SET_BUF_MEM                       114\n# define BIO_C_GET_BUF_MEM_PTR                   115\n# define BIO_C_GET_BUFF_NUM_LINES                116\n# define BIO_C_SET_BUFF_SIZE                     117\n# define BIO_C_SET_ACCEPT                        118\n# define BIO_C_SSL_MODE                          119\n# define BIO_C_GET_MD_CTX                        120\n# define BIO_C_GET_PROXY_PARAM                   121\n# define BIO_C_SET_BUFF_READ_DATA                122/* data to read first */\n# define BIO_C_GET_CONNECT                       123\n# define BIO_C_GET_ACCEPT                        124\n# define BIO_C_SET_SSL_RENEGOTIATE_BYTES         125\n# define BIO_C_GET_SSL_NUM_RENEGOTIATES          126\n# define BIO_C_SET_SSL_RENEGOTIATE_TIMEOUT       127\n# define BIO_C_FILE_SEEK                         128\n# define BIO_C_GET_CIPHER_CTX                    129\n# define BIO_C_SET_BUF_MEM_EOF_RETURN            130/* return end of input\n                                                     * value */\n# define BIO_C_SET_BIND_MODE                     131\n# define BIO_C_GET_BIND_MODE                     132\n# define BIO_C_FILE_TELL                         133\n# define BIO_C_GET_SOCKS                         134\n# define BIO_C_SET_SOCKS                         135\n\n# define BIO_C_SET_WRITE_BUF_SIZE                136/* for BIO_s_bio */\n# define BIO_C_GET_WRITE_BUF_SIZE                137\n# define BIO_C_MAKE_BIO_PAIR                     138\n# define BIO_C_DESTROY_BIO_PAIR                  139\n# define BIO_C_GET_WRITE_GUARANTEE               140\n# define BIO_C_GET_READ_REQUEST                  141\n# define BIO_C_SHUTDOWN_WR                       142\n# define BIO_C_NREAD0                            143\n# define BIO_C_NREAD                             144\n# define BIO_C_NWRITE0                           145\n# define BIO_C_NWRITE                            146\n# define BIO_C_RESET_READ_REQUEST                147\n# define BIO_C_SET_MD_CTX                        148\n\n# define BIO_C_SET_PREFIX                        149\n# define BIO_C_GET_PREFIX                        150\n# define BIO_C_SET_SUFFIX                        151\n# define BIO_C_GET_SUFFIX                        152\n\n# define BIO_C_SET_EX_ARG                        153\n# define BIO_C_GET_EX_ARG                        154\n\n# define BIO_set_app_data(s,arg)         BIO_set_ex_data(s,0,arg)\n# define BIO_get_app_data(s)             BIO_get_ex_data(s,0)\n\n/* BIO_s_connect() and BIO_s_socks4a_connect() */\n# define BIO_set_conn_hostname(b,name) BIO_ctrl(b,BIO_C_SET_CONNECT,0,(char *)name)\n# define BIO_set_conn_port(b,port) BIO_ctrl(b,BIO_C_SET_CONNECT,1,(char *)port)\n# define BIO_set_conn_ip(b,ip)     BIO_ctrl(b,BIO_C_SET_CONNECT,2,(char *)ip)\n# define BIO_set_conn_int_port(b,port) BIO_ctrl(b,BIO_C_SET_CONNECT,3,(char *)port)\n# define BIO_get_conn_hostname(b)  BIO_ptr_ctrl(b,BIO_C_GET_CONNECT,0)\n# define BIO_get_conn_port(b)      BIO_ptr_ctrl(b,BIO_C_GET_CONNECT,1)\n# define BIO_get_conn_ip(b)               BIO_ptr_ctrl(b,BIO_C_GET_CONNECT,2)\n# define BIO_get_conn_int_port(b) BIO_ctrl(b,BIO_C_GET_CONNECT,3,NULL)\n\n# define BIO_set_nbio(b,n)       BIO_ctrl(b,BIO_C_SET_NBIO,(n),NULL)\n\n/* BIO_s_accept() */\n# define BIO_set_accept_port(b,name) BIO_ctrl(b,BIO_C_SET_ACCEPT,0,(char *)name)\n# define BIO_get_accept_port(b)  BIO_ptr_ctrl(b,BIO_C_GET_ACCEPT,0)\n/* #define BIO_set_nbio(b,n)    BIO_ctrl(b,BIO_C_SET_NBIO,(n),NULL) */\n# define BIO_set_nbio_accept(b,n) BIO_ctrl(b,BIO_C_SET_ACCEPT,1,(n)?(void *)\"a\":NULL)\n# define BIO_set_accept_bios(b,bio) BIO_ctrl(b,BIO_C_SET_ACCEPT,2,(char *)bio)\n\n# define BIO_BIND_NORMAL                 0\n# define BIO_BIND_REUSEADDR_IF_UNUSED    1\n# define BIO_BIND_REUSEADDR              2\n# define BIO_set_bind_mode(b,mode) BIO_ctrl(b,BIO_C_SET_BIND_MODE,mode,NULL)\n# define BIO_get_bind_mode(b,mode) BIO_ctrl(b,BIO_C_GET_BIND_MODE,0,NULL)\n\n/* BIO_s_accept() and BIO_s_connect() */\n# define BIO_do_connect(b)       BIO_do_handshake(b)\n# define BIO_do_accept(b)        BIO_do_handshake(b)\n# define BIO_do_handshake(b)     BIO_ctrl(b,BIO_C_DO_STATE_MACHINE,0,NULL)\n\n/* BIO_s_proxy_client() */\n# define BIO_set_url(b,url)      BIO_ctrl(b,BIO_C_SET_PROXY_PARAM,0,(char *)(url))\n# define BIO_set_proxies(b,p)    BIO_ctrl(b,BIO_C_SET_PROXY_PARAM,1,(char *)(p))\n/* BIO_set_nbio(b,n) */\n# define BIO_set_filter_bio(b,s) BIO_ctrl(b,BIO_C_SET_PROXY_PARAM,2,(char *)(s))\n/* BIO *BIO_get_filter_bio(BIO *bio); */\n# define BIO_set_proxy_cb(b,cb) BIO_callback_ctrl(b,BIO_C_SET_PROXY_PARAM,3,(void *(*cb)()))\n# define BIO_set_proxy_header(b,sk) BIO_ctrl(b,BIO_C_SET_PROXY_PARAM,4,(char *)sk)\n# define BIO_set_no_connect_return(b,bool) BIO_int_ctrl(b,BIO_C_SET_PROXY_PARAM,5,bool)\n\n# define BIO_get_proxy_header(b,skp) BIO_ctrl(b,BIO_C_GET_PROXY_PARAM,0,(char *)skp)\n# define BIO_get_proxies(b,pxy_p) BIO_ctrl(b,BIO_C_GET_PROXY_PARAM,1,(char *)(pxy_p))\n# define BIO_get_url(b,url)      BIO_ctrl(b,BIO_C_GET_PROXY_PARAM,2,(char *)(url))\n# define BIO_get_no_connect_return(b)    BIO_ctrl(b,BIO_C_GET_PROXY_PARAM,5,NULL)\n\n/* BIO_s_datagram(), BIO_s_fd(), BIO_s_socket(), BIO_s_accept() and BIO_s_connect() */\n# define BIO_set_fd(b,fd,c)      BIO_int_ctrl(b,BIO_C_SET_FD,c,fd)\n# define BIO_get_fd(b,c)         BIO_ctrl(b,BIO_C_GET_FD,0,(char *)c)\n\n/* BIO_s_file() */\n# define BIO_set_fp(b,fp,c)      BIO_ctrl(b,BIO_C_SET_FILE_PTR,c,(char *)fp)\n# define BIO_get_fp(b,fpp)       BIO_ctrl(b,BIO_C_GET_FILE_PTR,0,(char *)fpp)\n\n/* BIO_s_fd() and BIO_s_file() */\n# define BIO_seek(b,ofs) (int)BIO_ctrl(b,BIO_C_FILE_SEEK,ofs,NULL)\n# define BIO_tell(b)     (int)BIO_ctrl(b,BIO_C_FILE_TELL,0,NULL)\n\n/*\n * name is cast to lose const, but might be better to route through a\n * function so we can do it safely\n */\n# ifdef CONST_STRICT\n/*\n * If you are wondering why this isn't defined, its because CONST_STRICT is\n * purely a compile-time kludge to allow const to be checked.\n */\nint BIO_read_filename(BIO *b, const char *name);\n# else\n#  define BIO_read_filename(b,name) BIO_ctrl(b,BIO_C_SET_FILENAME, \\\n                BIO_CLOSE|BIO_FP_READ,(char *)name)\n# endif\n# define BIO_write_filename(b,name) BIO_ctrl(b,BIO_C_SET_FILENAME, \\\n                BIO_CLOSE|BIO_FP_WRITE,name)\n# define BIO_append_filename(b,name) BIO_ctrl(b,BIO_C_SET_FILENAME, \\\n                BIO_CLOSE|BIO_FP_APPEND,name)\n# define BIO_rw_filename(b,name) BIO_ctrl(b,BIO_C_SET_FILENAME, \\\n                BIO_CLOSE|BIO_FP_READ|BIO_FP_WRITE,name)\n\n/*\n * WARNING WARNING, this ups the reference count on the read bio of the SSL\n * structure.  This is because the ssl read BIO is now pointed to by the\n * next_bio field in the bio.  So when you free the BIO, make sure you are\n * doing a BIO_free_all() to catch the underlying BIO.\n */\n# define BIO_set_ssl(b,ssl,c)    BIO_ctrl(b,BIO_C_SET_SSL,c,(char *)ssl)\n# define BIO_get_ssl(b,sslp)     BIO_ctrl(b,BIO_C_GET_SSL,0,(char *)sslp)\n# define BIO_set_ssl_mode(b,client)      BIO_ctrl(b,BIO_C_SSL_MODE,client,NULL)\n# define BIO_set_ssl_renegotiate_bytes(b,num) \\\n        BIO_ctrl(b,BIO_C_SET_SSL_RENEGOTIATE_BYTES,num,NULL)\n# define BIO_get_num_renegotiates(b) \\\n        BIO_ctrl(b,BIO_C_GET_SSL_NUM_RENEGOTIATES,0,NULL)\n# define BIO_set_ssl_renegotiate_timeout(b,seconds) \\\n        BIO_ctrl(b,BIO_C_SET_SSL_RENEGOTIATE_TIMEOUT,seconds,NULL)\n\n/* defined in evp.h */\n/* #define BIO_set_md(b,md)     BIO_ctrl(b,BIO_C_SET_MD,1,(char *)md) */\n\n# define BIO_get_mem_data(b,pp)  BIO_ctrl(b,BIO_CTRL_INFO,0,(char *)pp)\n# define BIO_set_mem_buf(b,bm,c) BIO_ctrl(b,BIO_C_SET_BUF_MEM,c,(char *)bm)\n# define BIO_get_mem_ptr(b,pp)   BIO_ctrl(b,BIO_C_GET_BUF_MEM_PTR,0,(char *)pp)\n# define BIO_set_mem_eof_return(b,v) \\\n                                BIO_ctrl(b,BIO_C_SET_BUF_MEM_EOF_RETURN,v,NULL)\n\n/* For the BIO_f_buffer() type */\n# define BIO_get_buffer_num_lines(b)     BIO_ctrl(b,BIO_C_GET_BUFF_NUM_LINES,0,NULL)\n# define BIO_set_buffer_size(b,size)     BIO_ctrl(b,BIO_C_SET_BUFF_SIZE,size,NULL)\n# define BIO_set_read_buffer_size(b,size) BIO_int_ctrl(b,BIO_C_SET_BUFF_SIZE,size,0)\n# define BIO_set_write_buffer_size(b,size) BIO_int_ctrl(b,BIO_C_SET_BUFF_SIZE,size,1)\n# define BIO_set_buffer_read_data(b,buf,num) BIO_ctrl(b,BIO_C_SET_BUFF_READ_DATA,num,buf)\n\n/* Don't use the next one unless you know what you are doing :-) */\n# define BIO_dup_state(b,ret)    BIO_ctrl(b,BIO_CTRL_DUP,0,(char *)(ret))\n\n# define BIO_reset(b)            (int)BIO_ctrl(b,BIO_CTRL_RESET,0,NULL)\n# define BIO_eof(b)              (int)BIO_ctrl(b,BIO_CTRL_EOF,0,NULL)\n# define BIO_set_close(b,c)      (int)BIO_ctrl(b,BIO_CTRL_SET_CLOSE,(c),NULL)\n# define BIO_get_close(b)        (int)BIO_ctrl(b,BIO_CTRL_GET_CLOSE,0,NULL)\n# define BIO_pending(b)          (int)BIO_ctrl(b,BIO_CTRL_PENDING,0,NULL)\n# define BIO_wpending(b)         (int)BIO_ctrl(b,BIO_CTRL_WPENDING,0,NULL)\n/* ...pending macros have inappropriate return type */\nsize_t BIO_ctrl_pending(BIO *b);\nsize_t BIO_ctrl_wpending(BIO *b);\n# define BIO_flush(b)            (int)BIO_ctrl(b,BIO_CTRL_FLUSH,0,NULL)\n# define BIO_get_info_callback(b,cbp) (int)BIO_ctrl(b,BIO_CTRL_GET_CALLBACK,0, \\\n                                                   cbp)\n# define BIO_set_info_callback(b,cb) (int)BIO_callback_ctrl(b,BIO_CTRL_SET_CALLBACK,cb)\n\n/* For the BIO_f_buffer() type */\n# define BIO_buffer_get_num_lines(b) BIO_ctrl(b,BIO_CTRL_GET,0,NULL)\n\n/* For BIO_s_bio() */\n# define BIO_set_write_buf_size(b,size) (int)BIO_ctrl(b,BIO_C_SET_WRITE_BUF_SIZE,size,NULL)\n# define BIO_get_write_buf_size(b,size) (size_t)BIO_ctrl(b,BIO_C_GET_WRITE_BUF_SIZE,size,NULL)\n# define BIO_make_bio_pair(b1,b2)   (int)BIO_ctrl(b1,BIO_C_MAKE_BIO_PAIR,0,b2)\n# define BIO_destroy_bio_pair(b)    (int)BIO_ctrl(b,BIO_C_DESTROY_BIO_PAIR,0,NULL)\n# define BIO_shutdown_wr(b) (int)BIO_ctrl(b, BIO_C_SHUTDOWN_WR, 0, NULL)\n/* macros with inappropriate type -- but ...pending macros use int too: */\n# define BIO_get_write_guarantee(b) (int)BIO_ctrl(b,BIO_C_GET_WRITE_GUARANTEE,0,NULL)\n# define BIO_get_read_request(b)    (int)BIO_ctrl(b,BIO_C_GET_READ_REQUEST,0,NULL)\nsize_t BIO_ctrl_get_write_guarantee(BIO *b);\nsize_t BIO_ctrl_get_read_request(BIO *b);\nint BIO_ctrl_reset_read_request(BIO *b);\n\n/* ctrl macros for dgram */\n# define BIO_ctrl_dgram_connect(b,peer)  \\\n                     (int)BIO_ctrl(b,BIO_CTRL_DGRAM_CONNECT,0, (char *)peer)\n# define BIO_ctrl_set_connected(b, state, peer) \\\n         (int)BIO_ctrl(b, BIO_CTRL_DGRAM_SET_CONNECTED, state, (char *)peer)\n# define BIO_dgram_recv_timedout(b) \\\n         (int)BIO_ctrl(b, BIO_CTRL_DGRAM_GET_RECV_TIMER_EXP, 0, NULL)\n# define BIO_dgram_send_timedout(b) \\\n         (int)BIO_ctrl(b, BIO_CTRL_DGRAM_GET_SEND_TIMER_EXP, 0, NULL)\n# define BIO_dgram_get_peer(b,peer) \\\n         (int)BIO_ctrl(b, BIO_CTRL_DGRAM_GET_PEER, 0, (char *)peer)\n# define BIO_dgram_set_peer(b,peer) \\\n         (int)BIO_ctrl(b, BIO_CTRL_DGRAM_SET_PEER, 0, (char *)peer)\n# define BIO_dgram_get_mtu_overhead(b) \\\n         (unsigned int)BIO_ctrl((b), BIO_CTRL_DGRAM_GET_MTU_OVERHEAD, 0, NULL)\n\n/* These two aren't currently implemented */\n/* int BIO_get_ex_num(BIO *bio); */\n/* void BIO_set_ex_free_func(BIO *bio,int idx,void (*cb)()); */\nint BIO_set_ex_data(BIO *bio, int idx, void *data);\nvoid *BIO_get_ex_data(BIO *bio, int idx);\nint BIO_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func,\n                         CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func);\nunsigned long BIO_number_read(BIO *bio);\nunsigned long BIO_number_written(BIO *bio);\n\n/* For BIO_f_asn1() */\nint BIO_asn1_set_prefix(BIO *b, asn1_ps_func *prefix,\n                        asn1_ps_func *prefix_free);\nint BIO_asn1_get_prefix(BIO *b, asn1_ps_func **pprefix,\n                        asn1_ps_func **pprefix_free);\nint BIO_asn1_set_suffix(BIO *b, asn1_ps_func *suffix,\n                        asn1_ps_func *suffix_free);\nint BIO_asn1_get_suffix(BIO *b, asn1_ps_func **psuffix,\n                        asn1_ps_func **psuffix_free);\n\n# ifndef OPENSSL_NO_FP_API\nBIO_METHOD *BIO_s_file(void);\nBIO *BIO_new_file(const char *filename, const char *mode);\nBIO *BIO_new_fp(FILE *stream, int close_flag);\n#  define BIO_s_file_internal    BIO_s_file\n# endif\nBIO *BIO_new(BIO_METHOD *type);\nint BIO_set(BIO *a, BIO_METHOD *type);\nint BIO_free(BIO *a);\nvoid BIO_vfree(BIO *a);\nint BIO_read(BIO *b, void *data, int len);\nint BIO_gets(BIO *bp, char *buf, int size);\nint BIO_write(BIO *b, const void *data, int len);\nint BIO_puts(BIO *bp, const char *buf);\nint BIO_indent(BIO *b, int indent, int max);\nlong BIO_ctrl(BIO *bp, int cmd, long larg, void *parg);\nlong BIO_callback_ctrl(BIO *b, int cmd,\n                       void (*fp) (struct bio_st *, int, const char *, int,\n                                   long, long));\nchar *BIO_ptr_ctrl(BIO *bp, int cmd, long larg);\nlong BIO_int_ctrl(BIO *bp, int cmd, long larg, int iarg);\nBIO *BIO_push(BIO *b, BIO *append);\nBIO *BIO_pop(BIO *b);\nvoid BIO_free_all(BIO *a);\nBIO *BIO_find_type(BIO *b, int bio_type);\nBIO *BIO_next(BIO *b);\nBIO *BIO_get_retry_BIO(BIO *bio, int *reason);\nint BIO_get_retry_reason(BIO *bio);\nBIO *BIO_dup_chain(BIO *in);\n\nint BIO_nread0(BIO *bio, char **buf);\nint BIO_nread(BIO *bio, char **buf, int num);\nint BIO_nwrite0(BIO *bio, char **buf);\nint BIO_nwrite(BIO *bio, char **buf, int num);\n\nlong BIO_debug_callback(BIO *bio, int cmd, const char *argp, int argi,\n                        long argl, long ret);\n\nBIO_METHOD *BIO_s_mem(void);\nBIO *BIO_new_mem_buf(const void *buf, int len);\nBIO_METHOD *BIO_s_socket(void);\nBIO_METHOD *BIO_s_connect(void);\nBIO_METHOD *BIO_s_accept(void);\nBIO_METHOD *BIO_s_fd(void);\n# ifndef OPENSSL_SYS_OS2\nBIO_METHOD *BIO_s_log(void);\n# endif\nBIO_METHOD *BIO_s_bio(void);\nBIO_METHOD *BIO_s_null(void);\nBIO_METHOD *BIO_f_null(void);\nBIO_METHOD *BIO_f_buffer(void);\n# ifdef OPENSSL_SYS_VMS\nBIO_METHOD *BIO_f_linebuffer(void);\n# endif\nBIO_METHOD *BIO_f_nbio_test(void);\n# ifndef OPENSSL_NO_DGRAM\nBIO_METHOD *BIO_s_datagram(void);\n#  ifndef OPENSSL_NO_SCTP\nBIO_METHOD *BIO_s_datagram_sctp(void);\n#  endif\n# endif\n\n/* BIO_METHOD *BIO_f_ber(void); */\n\nint BIO_sock_should_retry(int i);\nint BIO_sock_non_fatal_error(int error);\nint BIO_dgram_non_fatal_error(int error);\n\nint BIO_fd_should_retry(int i);\nint BIO_fd_non_fatal_error(int error);\nint BIO_dump_cb(int (*cb) (const void *data, size_t len, void *u),\n                void *u, const char *s, int len);\nint BIO_dump_indent_cb(int (*cb) (const void *data, size_t len, void *u),\n                       void *u, const char *s, int len, int indent);\nint BIO_dump(BIO *b, const char *bytes, int len);\nint BIO_dump_indent(BIO *b, const char *bytes, int len, int indent);\n# ifndef OPENSSL_NO_FP_API\nint BIO_dump_fp(FILE *fp, const char *s, int len);\nint BIO_dump_indent_fp(FILE *fp, const char *s, int len, int indent);\n# endif\nint BIO_hex_string(BIO *out, int indent, int width, unsigned char *data,\n                   int datalen);\n\nstruct hostent *BIO_gethostbyname(const char *name);\n/*-\n * We might want a thread-safe interface too:\n * struct hostent *BIO_gethostbyname_r(const char *name,\n *     struct hostent *result, void *buffer, size_t buflen);\n * or something similar (caller allocates a struct hostent,\n * pointed to by \"result\", and additional buffer space for the various\n * substructures; if the buffer does not suffice, NULL is returned\n * and an appropriate error code is set).\n */\nint BIO_sock_error(int sock);\nint BIO_socket_ioctl(int fd, long type, void *arg);\nint BIO_socket_nbio(int fd, int mode);\nint BIO_get_port(const char *str, unsigned short *port_ptr);\nint BIO_get_host_ip(const char *str, unsigned char *ip);\nint BIO_get_accept_socket(char *host_port, int mode);\nint BIO_accept(int sock, char **ip_port);\nint BIO_sock_init(void);\nvoid BIO_sock_cleanup(void);\nint BIO_set_tcp_ndelay(int sock, int turn_on);\n\nBIO *BIO_new_socket(int sock, int close_flag);\nBIO *BIO_new_dgram(int fd, int close_flag);\n# ifndef OPENSSL_NO_SCTP\nBIO *BIO_new_dgram_sctp(int fd, int close_flag);\nint BIO_dgram_is_sctp(BIO *bio);\nint BIO_dgram_sctp_notification_cb(BIO *b,\n                                   void (*handle_notifications) (BIO *bio,\n                                                                 void\n                                                                 *context,\n                                                                 void *buf),\n                                   void *context);\nint BIO_dgram_sctp_wait_for_dry(BIO *b);\nint BIO_dgram_sctp_msg_waiting(BIO *b);\n# endif\nBIO *BIO_new_fd(int fd, int close_flag);\nBIO *BIO_new_connect(const char *host_port);\nBIO *BIO_new_accept(const char *host_port);\n\nint BIO_new_bio_pair(BIO **bio1, size_t writebuf1,\n                     BIO **bio2, size_t writebuf2);\n/*\n * If successful, returns 1 and in *bio1, *bio2 two BIO pair endpoints.\n * Otherwise returns 0 and sets *bio1 and *bio2 to NULL. Size 0 uses default\n * value.\n */\n\nvoid BIO_copy_next_retry(BIO *b);\n\n/*\n * long BIO_ghbn_ctrl(int cmd,int iarg,char *parg);\n */\n\n# ifdef __GNUC__\n#  define __bio_h__attr__ __attribute__\n# else\n#  define __bio_h__attr__(x)\n# endif\nint BIO_printf(BIO *bio, const char *format, ...)\n__bio_h__attr__((__format__(__printf__, 2, 3)));\nint BIO_vprintf(BIO *bio, const char *format, va_list args)\n__bio_h__attr__((__format__(__printf__, 2, 0)));\nint BIO_snprintf(char *buf, size_t n, const char *format, ...)\n__bio_h__attr__((__format__(__printf__, 3, 4)));\nint BIO_vsnprintf(char *buf, size_t n, const char *format, va_list args)\n__bio_h__attr__((__format__(__printf__, 3, 0)));\n# undef __bio_h__attr__\n\n/* BEGIN ERROR CODES */\n/*\n * The following lines are auto generated by the script mkerr.pl. Any changes\n * made after this point may be overwritten when the script is next run.\n */\nvoid ERR_load_BIO_strings(void);\n\n/* Error codes for the BIO functions. */\n\n/* Function codes. */\n# define BIO_F_ACPT_STATE                                 100\n# define BIO_F_BIO_ACCEPT                                 101\n# define BIO_F_BIO_BER_GET_HEADER                         102\n# define BIO_F_BIO_CALLBACK_CTRL                          131\n# define BIO_F_BIO_CTRL                                   103\n# define BIO_F_BIO_GETHOSTBYNAME                          120\n# define BIO_F_BIO_GETS                                   104\n# define BIO_F_BIO_GET_ACCEPT_SOCKET                      105\n# define BIO_F_BIO_GET_HOST_IP                            106\n# define BIO_F_BIO_GET_PORT                               107\n# define BIO_F_BIO_MAKE_PAIR                              121\n# define BIO_F_BIO_NEW                                    108\n# define BIO_F_BIO_NEW_FILE                               109\n# define BIO_F_BIO_NEW_MEM_BUF                            126\n# define BIO_F_BIO_NREAD                                  123\n# define BIO_F_BIO_NREAD0                                 124\n# define BIO_F_BIO_NWRITE                                 125\n# define BIO_F_BIO_NWRITE0                                122\n# define BIO_F_BIO_PUTS                                   110\n# define BIO_F_BIO_READ                                   111\n# define BIO_F_BIO_SOCK_INIT                              112\n# define BIO_F_BIO_WRITE                                  113\n# define BIO_F_BUFFER_CTRL                                114\n# define BIO_F_CONN_CTRL                                  127\n# define BIO_F_CONN_STATE                                 115\n# define BIO_F_DGRAM_SCTP_READ                            132\n# define BIO_F_DGRAM_SCTP_WRITE                           133\n# define BIO_F_FILE_CTRL                                  116\n# define BIO_F_FILE_READ                                  130\n# define BIO_F_LINEBUFFER_CTRL                            129\n# define BIO_F_MEM_READ                                   128\n# define BIO_F_MEM_WRITE                                  117\n# define BIO_F_SSL_NEW                                    118\n# define BIO_F_WSASTARTUP                                 119\n\n/* Reason codes. */\n# define BIO_R_ACCEPT_ERROR                               100\n# define BIO_R_BAD_FOPEN_MODE                             101\n# define BIO_R_BAD_HOSTNAME_LOOKUP                        102\n# define BIO_R_BROKEN_PIPE                                124\n# define BIO_R_CONNECT_ERROR                              103\n# define BIO_R_EOF_ON_MEMORY_BIO                          127\n# define BIO_R_ERROR_SETTING_NBIO                         104\n# define BIO_R_ERROR_SETTING_NBIO_ON_ACCEPTED_SOCKET      105\n# define BIO_R_ERROR_SETTING_NBIO_ON_ACCEPT_SOCKET        106\n# define BIO_R_GETHOSTBYNAME_ADDR_IS_NOT_AF_INET          107\n# define BIO_R_INVALID_ARGUMENT                           125\n# define BIO_R_INVALID_IP_ADDRESS                         108\n# define BIO_R_IN_USE                                     123\n# define BIO_R_KEEPALIVE                                  109\n# define BIO_R_NBIO_CONNECT_ERROR                         110\n# define BIO_R_NO_ACCEPT_PORT_SPECIFIED                   111\n# define BIO_R_NO_HOSTNAME_SPECIFIED                      112\n# define BIO_R_NO_PORT_DEFINED                            113\n# define BIO_R_NO_PORT_SPECIFIED                          114\n# define BIO_R_NO_SUCH_FILE                               128\n# define BIO_R_NULL_PARAMETER                             115\n# define BIO_R_TAG_MISMATCH                               116\n# define BIO_R_UNABLE_TO_BIND_SOCKET                      117\n# define BIO_R_UNABLE_TO_CREATE_SOCKET                    118\n# define BIO_R_UNABLE_TO_LISTEN_SOCKET                    119\n# define BIO_R_UNINITIALIZED                              120\n# define BIO_R_UNSUPPORTED_METHOD                         121\n# define BIO_R_WRITE_TO_READ_ONLY_BIO                     126\n# define BIO_R_WSASTARTUP                                 122\n\n#ifdef  __cplusplus\n}\n#endif\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/arm/include/openssl/blowfish.h",
    "content": "/* crypto/bf/blowfish.h */\n/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)\n * All rights reserved.\n *\n * This package is an SSL implementation written\n * by Eric Young (eay@cryptsoft.com).\n * The implementation was written so as to conform with Netscapes SSL.\n *\n * This library is free for commercial and non-commercial use as long as\n * the following conditions are aheared to.  The following conditions\n * apply to all code found in this distribution, be it the RC4, RSA,\n * lhash, DES, etc., code; not just the SSL code.  The SSL documentation\n * included with this distribution is covered by the same copyright terms\n * except that the holder is Tim Hudson (tjh@cryptsoft.com).\n *\n * Copyright remains Eric Young's, and as such any Copyright notices in\n * the code are not to be removed.\n * If this package is used in a product, Eric Young should be given attribution\n * as the author of the parts of the library used.\n * This can be in the form of a textual message at program startup or\n * in documentation (online or textual) provided with the package.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the copyright\n *    notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in the\n *    documentation and/or other materials provided with the distribution.\n * 3. All advertising materials mentioning features or use of this software\n *    must display the following acknowledgement:\n *    \"This product includes cryptographic software written by\n *     Eric Young (eay@cryptsoft.com)\"\n *    The word 'cryptographic' can be left out if the rouines from the library\n *    being used are not cryptographic related :-).\n * 4. If you include any Windows specific code (or a derivative thereof) from\n *    the apps directory (application code) you must include an acknowledgement:\n *    \"This product includes software written by Tim Hudson (tjh@cryptsoft.com)\"\n *\n * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n * SUCH DAMAGE.\n *\n * The licence and distribution terms for any publically available version or\n * derivative of this code cannot be changed.  i.e. this code cannot simply be\n * copied and put under another distribution licence\n * [including the GNU Public Licence.]\n */\n\n#ifndef HEADER_BLOWFISH_H\n# define HEADER_BLOWFISH_H\n\n# include <openssl/e_os2.h>\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n# ifdef OPENSSL_NO_BF\n#  error BF is disabled.\n# endif\n\n# define BF_ENCRYPT      1\n# define BF_DECRYPT      0\n\n/*-\n * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n * ! BF_LONG has to be at least 32 bits wide. If it's wider, then !\n * ! BF_LONG_LOG2 has to be defined along.                        !\n * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n */\n\n# if defined(__LP32__)\n#  define BF_LONG unsigned long\n# elif defined(OPENSSL_SYS_CRAY) || defined(__ILP64__)\n#  define BF_LONG unsigned long\n#  define BF_LONG_LOG2 3\n/*\n * _CRAY note. I could declare short, but I have no idea what impact\n * does it have on performance on none-T3E machines. I could declare\n * int, but at least on C90 sizeof(int) can be chosen at compile time.\n * So I've chosen long...\n *                                      <appro@fy.chalmers.se>\n */\n# else\n#  define BF_LONG unsigned int\n# endif\n\n# define BF_ROUNDS       16\n# define BF_BLOCK        8\n\ntypedef struct bf_key_st {\n    BF_LONG P[BF_ROUNDS + 2];\n    BF_LONG S[4 * 256];\n} BF_KEY;\n\n# ifdef OPENSSL_FIPS\nvoid private_BF_set_key(BF_KEY *key, int len, const unsigned char *data);\n# endif\nvoid BF_set_key(BF_KEY *key, int len, const unsigned char *data);\n\nvoid BF_encrypt(BF_LONG *data, const BF_KEY *key);\nvoid BF_decrypt(BF_LONG *data, const BF_KEY *key);\n\nvoid BF_ecb_encrypt(const unsigned char *in, unsigned char *out,\n                    const BF_KEY *key, int enc);\nvoid BF_cbc_encrypt(const unsigned char *in, unsigned char *out, long length,\n                    const BF_KEY *schedule, unsigned char *ivec, int enc);\nvoid BF_cfb64_encrypt(const unsigned char *in, unsigned char *out,\n                      long length, const BF_KEY *schedule,\n                      unsigned char *ivec, int *num, int enc);\nvoid BF_ofb64_encrypt(const unsigned char *in, unsigned char *out,\n                      long length, const BF_KEY *schedule,\n                      unsigned char *ivec, int *num);\nconst char *BF_options(void);\n\n#ifdef  __cplusplus\n}\n#endif\n\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/arm/include/openssl/bn.h",
    "content": "/* crypto/bn/bn.h */\n/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)\n * All rights reserved.\n *\n * This package is an SSL implementation written\n * by Eric Young (eay@cryptsoft.com).\n * The implementation was written so as to conform with Netscapes SSL.\n *\n * This library is free for commercial and non-commercial use as long as\n * the following conditions are aheared to.  The following conditions\n * apply to all code found in this distribution, be it the RC4, RSA,\n * lhash, DES, etc., code; not just the SSL code.  The SSL documentation\n * included with this distribution is covered by the same copyright terms\n * except that the holder is Tim Hudson (tjh@cryptsoft.com).\n *\n * Copyright remains Eric Young's, and as such any Copyright notices in\n * the code are not to be removed.\n * If this package is used in a product, Eric Young should be given attribution\n * as the author of the parts of the library used.\n * This can be in the form of a textual message at program startup or\n * in documentation (online or textual) provided with the package.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the copyright\n *    notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in the\n *    documentation and/or other materials provided with the distribution.\n * 3. All advertising materials mentioning features or use of this software\n *    must display the following acknowledgement:\n *    \"This product includes cryptographic software written by\n *     Eric Young (eay@cryptsoft.com)\"\n *    The word 'cryptographic' can be left out if the rouines from the library\n *    being used are not cryptographic related :-).\n * 4. If you include any Windows specific code (or a derivative thereof) from\n *    the apps directory (application code) you must include an acknowledgement:\n *    \"This product includes software written by Tim Hudson (tjh@cryptsoft.com)\"\n *\n * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n * SUCH DAMAGE.\n *\n * The licence and distribution terms for any publically available version or\n * derivative of this code cannot be changed.  i.e. this code cannot simply be\n * copied and put under another distribution licence\n * [including the GNU Public Licence.]\n */\n/* ====================================================================\n * Copyright (c) 1998-2006 The OpenSSL Project.  All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n *\n * 1. Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n *\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in\n *    the documentation and/or other materials provided with the\n *    distribution.\n *\n * 3. All advertising materials mentioning features or use of this\n *    software must display the following acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit. (http://www.openssl.org/)\"\n *\n * 4. The names \"OpenSSL Toolkit\" and \"OpenSSL Project\" must not be used to\n *    endorse or promote products derived from this software without\n *    prior written permission. For written permission, please contact\n *    openssl-core@openssl.org.\n *\n * 5. Products derived from this software may not be called \"OpenSSL\"\n *    nor may \"OpenSSL\" appear in their names without prior written\n *    permission of the OpenSSL Project.\n *\n * 6. Redistributions of any form whatsoever must retain the following\n *    acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit (http://www.openssl.org/)\"\n *\n * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY\n * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\n * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR\n * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\n * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,\n * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED\n * OF THE POSSIBILITY OF SUCH DAMAGE.\n * ====================================================================\n *\n * This product includes cryptographic software written by Eric Young\n * (eay@cryptsoft.com).  This product includes software written by Tim\n * Hudson (tjh@cryptsoft.com).\n *\n */\n/* ====================================================================\n * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED.\n *\n * Portions of the attached software (\"Contribution\") are developed by\n * SUN MICROSYSTEMS, INC., and are contributed to the OpenSSL project.\n *\n * The Contribution is licensed pursuant to the Eric Young open source\n * license provided above.\n *\n * The binary polynomial arithmetic software is originally written by\n * Sheueling Chang Shantz and Douglas Stebila of Sun Microsystems Laboratories.\n *\n */\n\n#ifndef HEADER_BN_H\n# define HEADER_BN_H\n\n# include <limits.h>\n# include <openssl/e_os2.h>\n# ifndef OPENSSL_NO_FP_API\n#  include <stdio.h>            /* FILE */\n# endif\n# include <openssl/ossl_typ.h>\n# include <openssl/crypto.h>\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n/*\n * These preprocessor symbols control various aspects of the bignum headers\n * and library code. They're not defined by any \"normal\" configuration, as\n * they are intended for development and testing purposes. NB: defining all\n * three can be useful for debugging application code as well as openssl\n * itself. BN_DEBUG - turn on various debugging alterations to the bignum\n * code BN_DEBUG_RAND - uses random poisoning of unused words to trip up\n * mismanagement of bignum internals. You must also define BN_DEBUG.\n */\n/* #define BN_DEBUG */\n/* #define BN_DEBUG_RAND */\n\n# ifndef OPENSSL_SMALL_FOOTPRINT\n#  define BN_MUL_COMBA\n#  define BN_SQR_COMBA\n#  define BN_RECURSION\n# endif\n\n/*\n * This next option uses the C libraries (2 word)/(1 word) function. If it is\n * not defined, I use my C version (which is slower). The reason for this\n * flag is that when the particular C compiler library routine is used, and\n * the library is linked with a different compiler, the library is missing.\n * This mostly happens when the library is built with gcc and then linked\n * using normal cc.  This would be a common occurrence because gcc normally\n * produces code that is 2 times faster than system compilers for the big\n * number stuff. For machines with only one compiler (or shared libraries),\n * this should be on.  Again this in only really a problem on machines using\n * \"long long's\", are 32bit, and are not using my assembler code.\n */\n# if defined(OPENSSL_SYS_MSDOS) || defined(OPENSSL_SYS_WINDOWS) || \\\n    defined(OPENSSL_SYS_WIN32) || defined(linux)\n#  ifndef BN_DIV2W\n#   define BN_DIV2W\n#  endif\n# endif\n\n/*\n * assuming long is 64bit - this is the DEC Alpha unsigned long long is only\n * 64 bits :-(, don't define BN_LLONG for the DEC Alpha\n */\n# ifdef SIXTY_FOUR_BIT_LONG\n#  define BN_ULLONG       unsigned long long\n#  define BN_ULONG        unsigned long\n#  define BN_LONG         long\n#  define BN_BITS         128\n#  define BN_BYTES        8\n#  define BN_BITS2        64\n#  define BN_BITS4        32\n#  define BN_MASK         (0xffffffffffffffffffffffffffffffffLL)\n#  define BN_MASK2        (0xffffffffffffffffL)\n#  define BN_MASK2l       (0xffffffffL)\n#  define BN_MASK2h       (0xffffffff00000000L)\n#  define BN_MASK2h1      (0xffffffff80000000L)\n#  define BN_TBIT         (0x8000000000000000L)\n#  define BN_DEC_CONV     (10000000000000000000UL)\n#  define BN_DEC_FMT1     \"%lu\"\n#  define BN_DEC_FMT2     \"%019lu\"\n#  define BN_DEC_NUM      19\n#  define BN_HEX_FMT1     \"%lX\"\n#  define BN_HEX_FMT2     \"%016lX\"\n# endif\n\n/*\n * This is where the long long data type is 64 bits, but long is 32. For\n * machines where there are 64bit registers, this is the mode to use. IRIX,\n * on R4000 and above should use this mode, along with the relevant assembler\n * code :-).  Do NOT define BN_LLONG.\n */\n# ifdef SIXTY_FOUR_BIT\n#  undef BN_LLONG\n#  undef BN_ULLONG\n#  define BN_ULONG        unsigned long long\n#  define BN_LONG         long long\n#  define BN_BITS         128\n#  define BN_BYTES        8\n#  define BN_BITS2        64\n#  define BN_BITS4        32\n#  define BN_MASK2        (0xffffffffffffffffLL)\n#  define BN_MASK2l       (0xffffffffL)\n#  define BN_MASK2h       (0xffffffff00000000LL)\n#  define BN_MASK2h1      (0xffffffff80000000LL)\n#  define BN_TBIT         (0x8000000000000000LL)\n#  define BN_DEC_CONV     (10000000000000000000ULL)\n#  define BN_DEC_FMT1     \"%llu\"\n#  define BN_DEC_FMT2     \"%019llu\"\n#  define BN_DEC_NUM      19\n#  define BN_HEX_FMT1     \"%llX\"\n#  define BN_HEX_FMT2     \"%016llX\"\n# endif\n\n# ifdef THIRTY_TWO_BIT\n#  ifdef BN_LLONG\n#   if defined(_WIN32) && !defined(__GNUC__)\n#    define BN_ULLONG     unsigned __int64\n#    define BN_MASK       (0xffffffffffffffffI64)\n#   else\n#    define BN_ULLONG     unsigned long long\n#    define BN_MASK       (0xffffffffffffffffLL)\n#   endif\n#  endif\n#  define BN_ULONG        unsigned int\n#  define BN_LONG         int\n#  define BN_BITS         64\n#  define BN_BYTES        4\n#  define BN_BITS2        32\n#  define BN_BITS4        16\n#  define BN_MASK2        (0xffffffffL)\n#  define BN_MASK2l       (0xffff)\n#  define BN_MASK2h1      (0xffff8000L)\n#  define BN_MASK2h       (0xffff0000L)\n#  define BN_TBIT         (0x80000000L)\n#  define BN_DEC_CONV     (1000000000L)\n#  define BN_DEC_FMT1     \"%u\"\n#  define BN_DEC_FMT2     \"%09u\"\n#  define BN_DEC_NUM      9\n#  define BN_HEX_FMT1     \"%X\"\n#  define BN_HEX_FMT2     \"%08X\"\n# endif\n\n# define BN_DEFAULT_BITS 1280\n\n# define BN_FLG_MALLOCED         0x01\n# define BN_FLG_STATIC_DATA      0x02\n\n/*\n * avoid leaking exponent information through timing,\n * BN_mod_exp_mont() will call BN_mod_exp_mont_consttime,\n * BN_div() will call BN_div_no_branch,\n * BN_mod_inverse() will call BN_mod_inverse_no_branch.\n */\n# define BN_FLG_CONSTTIME        0x04\n\n# ifdef OPENSSL_NO_DEPRECATED\n/* deprecated name for the flag */\n#  define BN_FLG_EXP_CONSTTIME BN_FLG_CONSTTIME\n/*\n * avoid leaking exponent information through timings\n * (BN_mod_exp_mont() will call BN_mod_exp_mont_consttime)\n */\n# endif\n\n# ifndef OPENSSL_NO_DEPRECATED\n#  define BN_FLG_FREE             0x8000\n                                       /* used for debuging */\n# endif\n# define BN_set_flags(b,n)       ((b)->flags|=(n))\n# define BN_get_flags(b,n)       ((b)->flags&(n))\n\n/*\n * get a clone of a BIGNUM with changed flags, for *temporary* use only (the\n * two BIGNUMs cannot not be used in parallel!)\n */\n# define BN_with_flags(dest,b,n)  ((dest)->d=(b)->d, \\\n                                  (dest)->top=(b)->top, \\\n                                  (dest)->dmax=(b)->dmax, \\\n                                  (dest)->neg=(b)->neg, \\\n                                  (dest)->flags=(((dest)->flags & BN_FLG_MALLOCED) \\\n                                                 |  ((b)->flags & ~BN_FLG_MALLOCED) \\\n                                                 |  BN_FLG_STATIC_DATA \\\n                                                 |  (n)))\n\n/* Already declared in ossl_typ.h */\n# if 0\ntypedef struct bignum_st BIGNUM;\n/* Used for temp variables (declaration hidden in bn_lcl.h) */\ntypedef struct bignum_ctx BN_CTX;\ntypedef struct bn_blinding_st BN_BLINDING;\ntypedef struct bn_mont_ctx_st BN_MONT_CTX;\ntypedef struct bn_recp_ctx_st BN_RECP_CTX;\ntypedef struct bn_gencb_st BN_GENCB;\n# endif\n\nstruct bignum_st {\n    BN_ULONG *d;                /* Pointer to an array of 'BN_BITS2' bit\n                                 * chunks. */\n    int top;                    /* Index of last used d +1. */\n    /* The next are internal book keeping for bn_expand. */\n    int dmax;                   /* Size of the d array. */\n    int neg;                    /* one if the number is negative */\n    int flags;\n};\n\n/* Used for montgomery multiplication */\nstruct bn_mont_ctx_st {\n    int ri;                     /* number of bits in R */\n    BIGNUM RR;                  /* used to convert to montgomery form */\n    BIGNUM N;                   /* The modulus */\n    BIGNUM Ni;                  /* R*(1/R mod N) - N*Ni = 1 (Ni is only\n                                 * stored for bignum algorithm) */\n    BN_ULONG n0[2];             /* least significant word(s) of Ni; (type\n                                 * changed with 0.9.9, was \"BN_ULONG n0;\"\n                                 * before) */\n    int flags;\n};\n\n/*\n * Used for reciprocal division/mod functions It cannot be shared between\n * threads\n */\nstruct bn_recp_ctx_st {\n    BIGNUM N;                   /* the divisor */\n    BIGNUM Nr;                  /* the reciprocal */\n    int num_bits;\n    int shift;\n    int flags;\n};\n\n/* Used for slow \"generation\" functions. */\nstruct bn_gencb_st {\n    unsigned int ver;           /* To handle binary (in)compatibility */\n    void *arg;                  /* callback-specific data */\n    union {\n        /* if(ver==1) - handles old style callbacks */\n        void (*cb_1) (int, int, void *);\n        /* if(ver==2) - new callback style */\n        int (*cb_2) (int, int, BN_GENCB *);\n    } cb;\n};\n/* Wrapper function to make using BN_GENCB easier,  */\nint BN_GENCB_call(BN_GENCB *cb, int a, int b);\n/* Macro to populate a BN_GENCB structure with an \"old\"-style callback */\n# define BN_GENCB_set_old(gencb, callback, cb_arg) { \\\n                BN_GENCB *tmp_gencb = (gencb); \\\n                tmp_gencb->ver = 1; \\\n                tmp_gencb->arg = (cb_arg); \\\n                tmp_gencb->cb.cb_1 = (callback); }\n/* Macro to populate a BN_GENCB structure with a \"new\"-style callback */\n# define BN_GENCB_set(gencb, callback, cb_arg) { \\\n                BN_GENCB *tmp_gencb = (gencb); \\\n                tmp_gencb->ver = 2; \\\n                tmp_gencb->arg = (cb_arg); \\\n                tmp_gencb->cb.cb_2 = (callback); }\n\n# define BN_prime_checks 0      /* default: select number of iterations based\n                                 * on the size of the number */\n\n/*\n * number of Miller-Rabin iterations for an error rate of less than 2^-80 for\n * random 'b'-bit input, b >= 100 (taken from table 4.4 in the Handbook of\n * Applied Cryptography [Menezes, van Oorschot, Vanstone; CRC Press 1996];\n * original paper: Damgaard, Landrock, Pomerance: Average case error\n * estimates for the strong probable prime test. -- Math. Comp. 61 (1993)\n * 177-194)\n */\n# define BN_prime_checks_for_size(b) ((b) >= 1300 ?  2 : \\\n                                (b) >=  850 ?  3 : \\\n                                (b) >=  650 ?  4 : \\\n                                (b) >=  550 ?  5 : \\\n                                (b) >=  450 ?  6 : \\\n                                (b) >=  400 ?  7 : \\\n                                (b) >=  350 ?  8 : \\\n                                (b) >=  300 ?  9 : \\\n                                (b) >=  250 ? 12 : \\\n                                (b) >=  200 ? 15 : \\\n                                (b) >=  150 ? 18 : \\\n                                /* b >= 100 */ 27)\n\n# define BN_num_bytes(a) ((BN_num_bits(a)+7)/8)\n\n/* Note that BN_abs_is_word didn't work reliably for w == 0 until 0.9.8 */\n# define BN_abs_is_word(a,w) ((((a)->top == 1) && ((a)->d[0] == (BN_ULONG)(w))) || \\\n                                (((w) == 0) && ((a)->top == 0)))\n# define BN_is_zero(a)       ((a)->top == 0)\n# define BN_is_one(a)        (BN_abs_is_word((a),1) && !(a)->neg)\n# define BN_is_word(a,w)     (BN_abs_is_word((a),(w)) && (!(w) || !(a)->neg))\n# define BN_is_odd(a)        (((a)->top > 0) && ((a)->d[0] & 1))\n\n# define BN_one(a)       (BN_set_word((a),1))\n# define BN_zero_ex(a) \\\n        do { \\\n                BIGNUM *_tmp_bn = (a); \\\n                _tmp_bn->top = 0; \\\n                _tmp_bn->neg = 0; \\\n        } while(0)\n# ifdef OPENSSL_NO_DEPRECATED\n#  define BN_zero(a)      BN_zero_ex(a)\n# else\n#  define BN_zero(a)      (BN_set_word((a),0))\n# endif\n\nconst BIGNUM *BN_value_one(void);\nchar *BN_options(void);\nBN_CTX *BN_CTX_new(void);\n# ifndef OPENSSL_NO_DEPRECATED\nvoid BN_CTX_init(BN_CTX *c);\n# endif\nvoid BN_CTX_free(BN_CTX *c);\nvoid BN_CTX_start(BN_CTX *ctx);\nBIGNUM *BN_CTX_get(BN_CTX *ctx);\nvoid BN_CTX_end(BN_CTX *ctx);\nint BN_rand(BIGNUM *rnd, int bits, int top, int bottom);\nint BN_pseudo_rand(BIGNUM *rnd, int bits, int top, int bottom);\nint BN_rand_range(BIGNUM *rnd, const BIGNUM *range);\nint BN_pseudo_rand_range(BIGNUM *rnd, const BIGNUM *range);\nint BN_num_bits(const BIGNUM *a);\nint BN_num_bits_word(BN_ULONG);\nBIGNUM *BN_new(void);\nvoid BN_init(BIGNUM *);\nvoid BN_clear_free(BIGNUM *a);\nBIGNUM *BN_copy(BIGNUM *a, const BIGNUM *b);\nvoid BN_swap(BIGNUM *a, BIGNUM *b);\nBIGNUM *BN_bin2bn(const unsigned char *s, int len, BIGNUM *ret);\nint BN_bn2bin(const BIGNUM *a, unsigned char *to);\nBIGNUM *BN_mpi2bn(const unsigned char *s, int len, BIGNUM *ret);\nint BN_bn2mpi(const BIGNUM *a, unsigned char *to);\nint BN_sub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b);\nint BN_usub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b);\nint BN_uadd(BIGNUM *r, const BIGNUM *a, const BIGNUM *b);\nint BN_add(BIGNUM *r, const BIGNUM *a, const BIGNUM *b);\nint BN_mul(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx);\nint BN_sqr(BIGNUM *r, const BIGNUM *a, BN_CTX *ctx);\n/** BN_set_negative sets sign of a BIGNUM\n * \\param  b  pointer to the BIGNUM object\n * \\param  n  0 if the BIGNUM b should be positive and a value != 0 otherwise\n */\nvoid BN_set_negative(BIGNUM *b, int n);\n/** BN_is_negative returns 1 if the BIGNUM is negative\n * \\param  a  pointer to the BIGNUM object\n * \\return 1 if a < 0 and 0 otherwise\n */\n# define BN_is_negative(a) ((a)->neg != 0)\n\nint BN_div(BIGNUM *dv, BIGNUM *rem, const BIGNUM *m, const BIGNUM *d,\n           BN_CTX *ctx);\n# define BN_mod(rem,m,d,ctx) BN_div(NULL,(rem),(m),(d),(ctx))\nint BN_nnmod(BIGNUM *r, const BIGNUM *m, const BIGNUM *d, BN_CTX *ctx);\nint BN_mod_add(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *m,\n               BN_CTX *ctx);\nint BN_mod_add_quick(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,\n                     const BIGNUM *m);\nint BN_mod_sub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *m,\n               BN_CTX *ctx);\nint BN_mod_sub_quick(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,\n                     const BIGNUM *m);\nint BN_mod_mul(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *m,\n               BN_CTX *ctx);\nint BN_mod_sqr(BIGNUM *r, const BIGNUM *a, const BIGNUM *m, BN_CTX *ctx);\nint BN_mod_lshift1(BIGNUM *r, const BIGNUM *a, const BIGNUM *m, BN_CTX *ctx);\nint BN_mod_lshift1_quick(BIGNUM *r, const BIGNUM *a, const BIGNUM *m);\nint BN_mod_lshift(BIGNUM *r, const BIGNUM *a, int n, const BIGNUM *m,\n                  BN_CTX *ctx);\nint BN_mod_lshift_quick(BIGNUM *r, const BIGNUM *a, int n, const BIGNUM *m);\n\nBN_ULONG BN_mod_word(const BIGNUM *a, BN_ULONG w);\nBN_ULONG BN_div_word(BIGNUM *a, BN_ULONG w);\nint BN_mul_word(BIGNUM *a, BN_ULONG w);\nint BN_add_word(BIGNUM *a, BN_ULONG w);\nint BN_sub_word(BIGNUM *a, BN_ULONG w);\nint BN_set_word(BIGNUM *a, BN_ULONG w);\nBN_ULONG BN_get_word(const BIGNUM *a);\n\nint BN_cmp(const BIGNUM *a, const BIGNUM *b);\nvoid BN_free(BIGNUM *a);\nint BN_is_bit_set(const BIGNUM *a, int n);\nint BN_lshift(BIGNUM *r, const BIGNUM *a, int n);\nint BN_lshift1(BIGNUM *r, const BIGNUM *a);\nint BN_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx);\n\nint BN_mod_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,\n               const BIGNUM *m, BN_CTX *ctx);\nint BN_mod_exp_mont(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,\n                    const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx);\nint BN_mod_exp_mont_consttime(BIGNUM *rr, const BIGNUM *a, const BIGNUM *p,\n                              const BIGNUM *m, BN_CTX *ctx,\n                              BN_MONT_CTX *in_mont);\nint BN_mod_exp_mont_word(BIGNUM *r, BN_ULONG a, const BIGNUM *p,\n                         const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx);\nint BN_mod_exp2_mont(BIGNUM *r, const BIGNUM *a1, const BIGNUM *p1,\n                     const BIGNUM *a2, const BIGNUM *p2, const BIGNUM *m,\n                     BN_CTX *ctx, BN_MONT_CTX *m_ctx);\nint BN_mod_exp_simple(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,\n                      const BIGNUM *m, BN_CTX *ctx);\n\nint BN_mask_bits(BIGNUM *a, int n);\n# ifndef OPENSSL_NO_FP_API\nint BN_print_fp(FILE *fp, const BIGNUM *a);\n# endif\n# ifdef HEADER_BIO_H\nint BN_print(BIO *fp, const BIGNUM *a);\n# else\nint BN_print(void *fp, const BIGNUM *a);\n# endif\nint BN_reciprocal(BIGNUM *r, const BIGNUM *m, int len, BN_CTX *ctx);\nint BN_rshift(BIGNUM *r, const BIGNUM *a, int n);\nint BN_rshift1(BIGNUM *r, const BIGNUM *a);\nvoid BN_clear(BIGNUM *a);\nBIGNUM *BN_dup(const BIGNUM *a);\nint BN_ucmp(const BIGNUM *a, const BIGNUM *b);\nint BN_set_bit(BIGNUM *a, int n);\nint BN_clear_bit(BIGNUM *a, int n);\nchar *BN_bn2hex(const BIGNUM *a);\nchar *BN_bn2dec(const BIGNUM *a);\nint BN_hex2bn(BIGNUM **a, const char *str);\nint BN_dec2bn(BIGNUM **a, const char *str);\nint BN_asc2bn(BIGNUM **a, const char *str);\nint BN_gcd(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx);\nint BN_kronecker(const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx); /* returns\n                                                                  * -2 for\n                                                                  * error */\nBIGNUM *BN_mod_inverse(BIGNUM *ret,\n                       const BIGNUM *a, const BIGNUM *n, BN_CTX *ctx);\nBIGNUM *BN_mod_sqrt(BIGNUM *ret,\n                    const BIGNUM *a, const BIGNUM *n, BN_CTX *ctx);\n\nvoid BN_consttime_swap(BN_ULONG swap, BIGNUM *a, BIGNUM *b, int nwords);\n\n/* Deprecated versions */\n# ifndef OPENSSL_NO_DEPRECATED\nBIGNUM *BN_generate_prime(BIGNUM *ret, int bits, int safe,\n                          const BIGNUM *add, const BIGNUM *rem,\n                          void (*callback) (int, int, void *), void *cb_arg);\nint BN_is_prime(const BIGNUM *p, int nchecks,\n                void (*callback) (int, int, void *),\n                BN_CTX *ctx, void *cb_arg);\nint BN_is_prime_fasttest(const BIGNUM *p, int nchecks,\n                         void (*callback) (int, int, void *), BN_CTX *ctx,\n                         void *cb_arg, int do_trial_division);\n# endif                         /* !defined(OPENSSL_NO_DEPRECATED) */\n\n/* Newer versions */\nint BN_generate_prime_ex(BIGNUM *ret, int bits, int safe, const BIGNUM *add,\n                         const BIGNUM *rem, BN_GENCB *cb);\nint BN_is_prime_ex(const BIGNUM *p, int nchecks, BN_CTX *ctx, BN_GENCB *cb);\nint BN_is_prime_fasttest_ex(const BIGNUM *p, int nchecks, BN_CTX *ctx,\n                            int do_trial_division, BN_GENCB *cb);\n\nint BN_X931_generate_Xpq(BIGNUM *Xp, BIGNUM *Xq, int nbits, BN_CTX *ctx);\n\nint BN_X931_derive_prime_ex(BIGNUM *p, BIGNUM *p1, BIGNUM *p2,\n                            const BIGNUM *Xp, const BIGNUM *Xp1,\n                            const BIGNUM *Xp2, const BIGNUM *e, BN_CTX *ctx,\n                            BN_GENCB *cb);\nint BN_X931_generate_prime_ex(BIGNUM *p, BIGNUM *p1, BIGNUM *p2, BIGNUM *Xp1,\n                              BIGNUM *Xp2, const BIGNUM *Xp, const BIGNUM *e,\n                              BN_CTX *ctx, BN_GENCB *cb);\n\nBN_MONT_CTX *BN_MONT_CTX_new(void);\nvoid BN_MONT_CTX_init(BN_MONT_CTX *ctx);\nint BN_mod_mul_montgomery(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,\n                          BN_MONT_CTX *mont, BN_CTX *ctx);\n# define BN_to_montgomery(r,a,mont,ctx)  BN_mod_mul_montgomery(\\\n        (r),(a),&((mont)->RR),(mont),(ctx))\nint BN_from_montgomery(BIGNUM *r, const BIGNUM *a,\n                       BN_MONT_CTX *mont, BN_CTX *ctx);\nvoid BN_MONT_CTX_free(BN_MONT_CTX *mont);\nint BN_MONT_CTX_set(BN_MONT_CTX *mont, const BIGNUM *mod, BN_CTX *ctx);\nBN_MONT_CTX *BN_MONT_CTX_copy(BN_MONT_CTX *to, BN_MONT_CTX *from);\nBN_MONT_CTX *BN_MONT_CTX_set_locked(BN_MONT_CTX **pmont, int lock,\n                                    const BIGNUM *mod, BN_CTX *ctx);\n\n/* BN_BLINDING flags */\n# define BN_BLINDING_NO_UPDATE   0x00000001\n# define BN_BLINDING_NO_RECREATE 0x00000002\n\nBN_BLINDING *BN_BLINDING_new(const BIGNUM *A, const BIGNUM *Ai, BIGNUM *mod);\nvoid BN_BLINDING_free(BN_BLINDING *b);\nint BN_BLINDING_update(BN_BLINDING *b, BN_CTX *ctx);\nint BN_BLINDING_convert(BIGNUM *n, BN_BLINDING *b, BN_CTX *ctx);\nint BN_BLINDING_invert(BIGNUM *n, BN_BLINDING *b, BN_CTX *ctx);\nint BN_BLINDING_convert_ex(BIGNUM *n, BIGNUM *r, BN_BLINDING *b, BN_CTX *);\nint BN_BLINDING_invert_ex(BIGNUM *n, const BIGNUM *r, BN_BLINDING *b,\n                          BN_CTX *);\n# ifndef OPENSSL_NO_DEPRECATED\nunsigned long BN_BLINDING_get_thread_id(const BN_BLINDING *);\nvoid BN_BLINDING_set_thread_id(BN_BLINDING *, unsigned long);\n# endif\nCRYPTO_THREADID *BN_BLINDING_thread_id(BN_BLINDING *);\nunsigned long BN_BLINDING_get_flags(const BN_BLINDING *);\nvoid BN_BLINDING_set_flags(BN_BLINDING *, unsigned long);\nBN_BLINDING *BN_BLINDING_create_param(BN_BLINDING *b,\n                                      const BIGNUM *e, BIGNUM *m, BN_CTX *ctx,\n                                      int (*bn_mod_exp) (BIGNUM *r,\n                                                         const BIGNUM *a,\n                                                         const BIGNUM *p,\n                                                         const BIGNUM *m,\n                                                         BN_CTX *ctx,\n                                                         BN_MONT_CTX *m_ctx),\n                                      BN_MONT_CTX *m_ctx);\n\n# ifndef OPENSSL_NO_DEPRECATED\nvoid BN_set_params(int mul, int high, int low, int mont);\nint BN_get_params(int which);   /* 0, mul, 1 high, 2 low, 3 mont */\n# endif\n\nvoid BN_RECP_CTX_init(BN_RECP_CTX *recp);\nBN_RECP_CTX *BN_RECP_CTX_new(void);\nvoid BN_RECP_CTX_free(BN_RECP_CTX *recp);\nint BN_RECP_CTX_set(BN_RECP_CTX *recp, const BIGNUM *rdiv, BN_CTX *ctx);\nint BN_mod_mul_reciprocal(BIGNUM *r, const BIGNUM *x, const BIGNUM *y,\n                          BN_RECP_CTX *recp, BN_CTX *ctx);\nint BN_mod_exp_recp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,\n                    const BIGNUM *m, BN_CTX *ctx);\nint BN_div_recp(BIGNUM *dv, BIGNUM *rem, const BIGNUM *m,\n                BN_RECP_CTX *recp, BN_CTX *ctx);\n\n# ifndef OPENSSL_NO_EC2M\n\n/*\n * Functions for arithmetic over binary polynomials represented by BIGNUMs.\n * The BIGNUM::neg property of BIGNUMs representing binary polynomials is\n * ignored. Note that input arguments are not const so that their bit arrays\n * can be expanded to the appropriate size if needed.\n */\n\n/*\n * r = a + b\n */\nint BN_GF2m_add(BIGNUM *r, const BIGNUM *a, const BIGNUM *b);\n#  define BN_GF2m_sub(r, a, b) BN_GF2m_add(r, a, b)\n/*\n * r=a mod p\n */\nint BN_GF2m_mod(BIGNUM *r, const BIGNUM *a, const BIGNUM *p);\n/* r = (a * b) mod p */\nint BN_GF2m_mod_mul(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,\n                    const BIGNUM *p, BN_CTX *ctx);\n/* r = (a * a) mod p */\nint BN_GF2m_mod_sqr(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx);\n/* r = (1 / b) mod p */\nint BN_GF2m_mod_inv(BIGNUM *r, const BIGNUM *b, const BIGNUM *p, BN_CTX *ctx);\n/* r = (a / b) mod p */\nint BN_GF2m_mod_div(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,\n                    const BIGNUM *p, BN_CTX *ctx);\n/* r = (a ^ b) mod p */\nint BN_GF2m_mod_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,\n                    const BIGNUM *p, BN_CTX *ctx);\n/* r = sqrt(a) mod p */\nint BN_GF2m_mod_sqrt(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,\n                     BN_CTX *ctx);\n/* r^2 + r = a mod p */\nint BN_GF2m_mod_solve_quad(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,\n                           BN_CTX *ctx);\n#  define BN_GF2m_cmp(a, b) BN_ucmp((a), (b))\n/*-\n * Some functions allow for representation of the irreducible polynomials\n * as an unsigned int[], say p.  The irreducible f(t) is then of the form:\n *     t^p[0] + t^p[1] + ... + t^p[k]\n * where m = p[0] > p[1] > ... > p[k] = 0.\n */\n/* r = a mod p */\nint BN_GF2m_mod_arr(BIGNUM *r, const BIGNUM *a, const int p[]);\n/* r = (a * b) mod p */\nint BN_GF2m_mod_mul_arr(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,\n                        const int p[], BN_CTX *ctx);\n/* r = (a * a) mod p */\nint BN_GF2m_mod_sqr_arr(BIGNUM *r, const BIGNUM *a, const int p[],\n                        BN_CTX *ctx);\n/* r = (1 / b) mod p */\nint BN_GF2m_mod_inv_arr(BIGNUM *r, const BIGNUM *b, const int p[],\n                        BN_CTX *ctx);\n/* r = (a / b) mod p */\nint BN_GF2m_mod_div_arr(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,\n                        const int p[], BN_CTX *ctx);\n/* r = (a ^ b) mod p */\nint BN_GF2m_mod_exp_arr(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,\n                        const int p[], BN_CTX *ctx);\n/* r = sqrt(a) mod p */\nint BN_GF2m_mod_sqrt_arr(BIGNUM *r, const BIGNUM *a,\n                         const int p[], BN_CTX *ctx);\n/* r^2 + r = a mod p */\nint BN_GF2m_mod_solve_quad_arr(BIGNUM *r, const BIGNUM *a,\n                               const int p[], BN_CTX *ctx);\nint BN_GF2m_poly2arr(const BIGNUM *a, int p[], int max);\nint BN_GF2m_arr2poly(const int p[], BIGNUM *a);\n\n# endif\n\n/*\n * faster mod functions for the 'NIST primes' 0 <= a < p^2\n */\nint BN_nist_mod_192(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx);\nint BN_nist_mod_224(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx);\nint BN_nist_mod_256(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx);\nint BN_nist_mod_384(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx);\nint BN_nist_mod_521(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx);\n\nconst BIGNUM *BN_get0_nist_prime_192(void);\nconst BIGNUM *BN_get0_nist_prime_224(void);\nconst BIGNUM *BN_get0_nist_prime_256(void);\nconst BIGNUM *BN_get0_nist_prime_384(void);\nconst BIGNUM *BN_get0_nist_prime_521(void);\n\n/* library internal functions */\n\n# define bn_expand(a,bits) \\\n    ( \\\n        bits > (INT_MAX - BN_BITS2 + 1) ? \\\n            NULL \\\n        : \\\n            (((bits+BN_BITS2-1)/BN_BITS2) <= (a)->dmax) ? \\\n                (a) \\\n            : \\\n                bn_expand2((a),(bits+BN_BITS2-1)/BN_BITS2) \\\n    )\n\n# define bn_wexpand(a,words) (((words) <= (a)->dmax)?(a):bn_expand2((a),(words)))\nBIGNUM *bn_expand2(BIGNUM *a, int words);\n# ifndef OPENSSL_NO_DEPRECATED\nBIGNUM *bn_dup_expand(const BIGNUM *a, int words); /* unused */\n# endif\n\n/*-\n * Bignum consistency macros\n * There is one \"API\" macro, bn_fix_top(), for stripping leading zeroes from\n * bignum data after direct manipulations on the data. There is also an\n * \"internal\" macro, bn_check_top(), for verifying that there are no leading\n * zeroes. Unfortunately, some auditing is required due to the fact that\n * bn_fix_top() has become an overabused duct-tape because bignum data is\n * occasionally passed around in an inconsistent state. So the following\n * changes have been made to sort this out;\n * - bn_fix_top()s implementation has been moved to bn_correct_top()\n * - if BN_DEBUG isn't defined, bn_fix_top() maps to bn_correct_top(), and\n *   bn_check_top() is as before.\n * - if BN_DEBUG *is* defined;\n *   - bn_check_top() tries to pollute unused words even if the bignum 'top' is\n *     consistent. (ed: only if BN_DEBUG_RAND is defined)\n *   - bn_fix_top() maps to bn_check_top() rather than \"fixing\" anything.\n * The idea is to have debug builds flag up inconsistent bignums when they\n * occur. If that occurs in a bn_fix_top(), we examine the code in question; if\n * the use of bn_fix_top() was appropriate (ie. it follows directly after code\n * that manipulates the bignum) it is converted to bn_correct_top(), and if it\n * was not appropriate, we convert it permanently to bn_check_top() and track\n * down the cause of the bug. Eventually, no internal code should be using the\n * bn_fix_top() macro. External applications and libraries should try this with\n * their own code too, both in terms of building against the openssl headers\n * with BN_DEBUG defined *and* linking with a version of OpenSSL built with it\n * defined. This not only improves external code, it provides more test\n * coverage for openssl's own code.\n */\n\n# ifdef BN_DEBUG\n\n/* We only need assert() when debugging */\n#  include <assert.h>\n\n#  ifdef BN_DEBUG_RAND\n/* To avoid \"make update\" cvs wars due to BN_DEBUG, use some tricks */\n#   ifndef RAND_pseudo_bytes\nint RAND_pseudo_bytes(unsigned char *buf, int num);\n#    define BN_DEBUG_TRIX\n#   endif\n#   define bn_pollute(a) \\\n        do { \\\n                const BIGNUM *_bnum1 = (a); \\\n                if(_bnum1->top < _bnum1->dmax) { \\\n                        unsigned char _tmp_char; \\\n                        /* We cast away const without the compiler knowing, any \\\n                         * *genuinely* constant variables that aren't mutable \\\n                         * wouldn't be constructed with top!=dmax. */ \\\n                        BN_ULONG *_not_const; \\\n                        memcpy(&_not_const, &_bnum1->d, sizeof(BN_ULONG*)); \\\n                        /* Debug only - safe to ignore error return */ \\\n                        RAND_pseudo_bytes(&_tmp_char, 1); \\\n                        memset((unsigned char *)(_not_const + _bnum1->top), _tmp_char, \\\n                                (_bnum1->dmax - _bnum1->top) * sizeof(BN_ULONG)); \\\n                } \\\n        } while(0)\n#   ifdef BN_DEBUG_TRIX\n#    undef RAND_pseudo_bytes\n#   endif\n#  else\n#   define bn_pollute(a)\n#  endif\n#  define bn_check_top(a) \\\n        do { \\\n                const BIGNUM *_bnum2 = (a); \\\n                if (_bnum2 != NULL) { \\\n                        assert((_bnum2->top == 0) || \\\n                                (_bnum2->d[_bnum2->top - 1] != 0)); \\\n                        bn_pollute(_bnum2); \\\n                } \\\n        } while(0)\n\n#  define bn_fix_top(a)           bn_check_top(a)\n\n#  define bn_check_size(bn, bits) bn_wcheck_size(bn, ((bits+BN_BITS2-1))/BN_BITS2)\n#  define bn_wcheck_size(bn, words) \\\n        do { \\\n                const BIGNUM *_bnum2 = (bn); \\\n                assert((words) <= (_bnum2)->dmax && (words) >= (_bnum2)->top); \\\n                /* avoid unused variable warning with NDEBUG */ \\\n                (void)(_bnum2); \\\n        } while(0)\n\n# else                          /* !BN_DEBUG */\n\n#  define bn_pollute(a)\n#  define bn_check_top(a)\n#  define bn_fix_top(a)           bn_correct_top(a)\n#  define bn_check_size(bn, bits)\n#  define bn_wcheck_size(bn, words)\n\n# endif\n\n# define bn_correct_top(a) \\\n        { \\\n        BN_ULONG *ftl; \\\n        int tmp_top = (a)->top; \\\n        if (tmp_top > 0) \\\n                { \\\n                for (ftl= &((a)->d[tmp_top-1]); tmp_top > 0; tmp_top--) \\\n                        if (*(ftl--)) break; \\\n                (a)->top = tmp_top; \\\n                } \\\n        if ((a)->top == 0) \\\n            (a)->neg = 0; \\\n        bn_pollute(a); \\\n        }\n\nBN_ULONG bn_mul_add_words(BN_ULONG *rp, const BN_ULONG *ap, int num,\n                          BN_ULONG w);\nBN_ULONG bn_mul_words(BN_ULONG *rp, const BN_ULONG *ap, int num, BN_ULONG w);\nvoid bn_sqr_words(BN_ULONG *rp, const BN_ULONG *ap, int num);\nBN_ULONG bn_div_words(BN_ULONG h, BN_ULONG l, BN_ULONG d);\nBN_ULONG bn_add_words(BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp,\n                      int num);\nBN_ULONG bn_sub_words(BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp,\n                      int num);\n\n/* Primes from RFC 2409 */\nBIGNUM *get_rfc2409_prime_768(BIGNUM *bn);\nBIGNUM *get_rfc2409_prime_1024(BIGNUM *bn);\n\n/* Primes from RFC 3526 */\nBIGNUM *get_rfc3526_prime_1536(BIGNUM *bn);\nBIGNUM *get_rfc3526_prime_2048(BIGNUM *bn);\nBIGNUM *get_rfc3526_prime_3072(BIGNUM *bn);\nBIGNUM *get_rfc3526_prime_4096(BIGNUM *bn);\nBIGNUM *get_rfc3526_prime_6144(BIGNUM *bn);\nBIGNUM *get_rfc3526_prime_8192(BIGNUM *bn);\n\nint BN_bntest_rand(BIGNUM *rnd, int bits, int top, int bottom);\n\n/* BEGIN ERROR CODES */\n/*\n * The following lines are auto generated by the script mkerr.pl. Any changes\n * made after this point may be overwritten when the script is next run.\n */\nvoid ERR_load_BN_strings(void);\n\n/* Error codes for the BN functions. */\n\n/* Function codes. */\n# define BN_F_BNRAND                                      127\n# define BN_F_BN_BLINDING_CONVERT_EX                      100\n# define BN_F_BN_BLINDING_CREATE_PARAM                    128\n# define BN_F_BN_BLINDING_INVERT_EX                       101\n# define BN_F_BN_BLINDING_NEW                             102\n# define BN_F_BN_BLINDING_UPDATE                          103\n# define BN_F_BN_BN2DEC                                   104\n# define BN_F_BN_BN2HEX                                   105\n# define BN_F_BN_CTX_GET                                  116\n# define BN_F_BN_CTX_NEW                                  106\n# define BN_F_BN_CTX_START                                129\n# define BN_F_BN_DIV                                      107\n# define BN_F_BN_DIV_NO_BRANCH                            138\n# define BN_F_BN_DIV_RECP                                 130\n# define BN_F_BN_EXP                                      123\n# define BN_F_BN_EXPAND2                                  108\n# define BN_F_BN_EXPAND_INTERNAL                          120\n# define BN_F_BN_GF2M_MOD                                 131\n# define BN_F_BN_GF2M_MOD_EXP                             132\n# define BN_F_BN_GF2M_MOD_MUL                             133\n# define BN_F_BN_GF2M_MOD_SOLVE_QUAD                      134\n# define BN_F_BN_GF2M_MOD_SOLVE_QUAD_ARR                  135\n# define BN_F_BN_GF2M_MOD_SQR                             136\n# define BN_F_BN_GF2M_MOD_SQRT                            137\n# define BN_F_BN_LSHIFT                                   145\n# define BN_F_BN_MOD_EXP2_MONT                            118\n# define BN_F_BN_MOD_EXP_MONT                             109\n# define BN_F_BN_MOD_EXP_MONT_CONSTTIME                   124\n# define BN_F_BN_MOD_EXP_MONT_WORD                        117\n# define BN_F_BN_MOD_EXP_RECP                             125\n# define BN_F_BN_MOD_EXP_SIMPLE                           126\n# define BN_F_BN_MOD_INVERSE                              110\n# define BN_F_BN_MOD_INVERSE_NO_BRANCH                    139\n# define BN_F_BN_MOD_LSHIFT_QUICK                         119\n# define BN_F_BN_MOD_MUL_RECIPROCAL                       111\n# define BN_F_BN_MOD_SQRT                                 121\n# define BN_F_BN_MPI2BN                                   112\n# define BN_F_BN_NEW                                      113\n# define BN_F_BN_RAND                                     114\n# define BN_F_BN_RAND_RANGE                               122\n# define BN_F_BN_RSHIFT                                   146\n# define BN_F_BN_USUB                                     115\n\n/* Reason codes. */\n# define BN_R_ARG2_LT_ARG3                                100\n# define BN_R_BAD_RECIPROCAL                              101\n# define BN_R_BIGNUM_TOO_LONG                             114\n# define BN_R_BITS_TOO_SMALL                              118\n# define BN_R_CALLED_WITH_EVEN_MODULUS                    102\n# define BN_R_DIV_BY_ZERO                                 103\n# define BN_R_ENCODING_ERROR                              104\n# define BN_R_EXPAND_ON_STATIC_BIGNUM_DATA                105\n# define BN_R_INPUT_NOT_REDUCED                           110\n# define BN_R_INVALID_LENGTH                              106\n# define BN_R_INVALID_RANGE                               115\n# define BN_R_INVALID_SHIFT                               119\n# define BN_R_NOT_A_SQUARE                                111\n# define BN_R_NOT_INITIALIZED                             107\n# define BN_R_NO_INVERSE                                  108\n# define BN_R_NO_SOLUTION                                 116\n# define BN_R_P_IS_NOT_PRIME                              112\n# define BN_R_TOO_MANY_ITERATIONS                         113\n# define BN_R_TOO_MANY_TEMPORARY_VARIABLES                109\n\n#ifdef  __cplusplus\n}\n#endif\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/arm/include/openssl/buffer.h",
    "content": "/* crypto/buffer/buffer.h */\n/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)\n * All rights reserved.\n *\n * This package is an SSL implementation written\n * by Eric Young (eay@cryptsoft.com).\n * The implementation was written so as to conform with Netscapes SSL.\n *\n * This library is free for commercial and non-commercial use as long as\n * the following conditions are aheared to.  The following conditions\n * apply to all code found in this distribution, be it the RC4, RSA,\n * lhash, DES, etc., code; not just the SSL code.  The SSL documentation\n * included with this distribution is covered by the same copyright terms\n * except that the holder is Tim Hudson (tjh@cryptsoft.com).\n *\n * Copyright remains Eric Young's, and as such any Copyright notices in\n * the code are not to be removed.\n * If this package is used in a product, Eric Young should be given attribution\n * as the author of the parts of the library used.\n * This can be in the form of a textual message at program startup or\n * in documentation (online or textual) provided with the package.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the copyright\n *    notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in the\n *    documentation and/or other materials provided with the distribution.\n * 3. All advertising materials mentioning features or use of this software\n *    must display the following acknowledgement:\n *    \"This product includes cryptographic software written by\n *     Eric Young (eay@cryptsoft.com)\"\n *    The word 'cryptographic' can be left out if the rouines from the library\n *    being used are not cryptographic related :-).\n * 4. If you include any Windows specific code (or a derivative thereof) from\n *    the apps directory (application code) you must include an acknowledgement:\n *    \"This product includes software written by Tim Hudson (tjh@cryptsoft.com)\"\n *\n * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n * SUCH DAMAGE.\n *\n * The licence and distribution terms for any publically available version or\n * derivative of this code cannot be changed.  i.e. this code cannot simply be\n * copied and put under another distribution licence\n * [including the GNU Public Licence.]\n */\n\n#ifndef HEADER_BUFFER_H\n# define HEADER_BUFFER_H\n\n# include <openssl/ossl_typ.h>\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n# include <stddef.h>\n\n# if !defined(NO_SYS_TYPES_H)\n#  include <sys/types.h>\n# endif\n\n/* Already declared in ossl_typ.h */\n/* typedef struct buf_mem_st BUF_MEM; */\n\nstruct buf_mem_st {\n    size_t length;              /* current number of bytes */\n    char *data;\n    size_t max;                 /* size of buffer */\n};\n\nBUF_MEM *BUF_MEM_new(void);\nvoid BUF_MEM_free(BUF_MEM *a);\nint BUF_MEM_grow(BUF_MEM *str, size_t len);\nint BUF_MEM_grow_clean(BUF_MEM *str, size_t len);\nsize_t BUF_strnlen(const char *str, size_t maxlen);\nchar *BUF_strdup(const char *str);\n\n/*\n * Like strndup, but in addition, explicitly guarantees to never read past the\n * first |siz| bytes of |str|.\n */\nchar *BUF_strndup(const char *str, size_t siz);\n\nvoid *BUF_memdup(const void *data, size_t siz);\nvoid BUF_reverse(unsigned char *out, const unsigned char *in, size_t siz);\n\n/* safe string functions */\nsize_t BUF_strlcpy(char *dst, const char *src, size_t siz);\nsize_t BUF_strlcat(char *dst, const char *src, size_t siz);\n\n/* BEGIN ERROR CODES */\n/*\n * The following lines are auto generated by the script mkerr.pl. Any changes\n * made after this point may be overwritten when the script is next run.\n */\nvoid ERR_load_BUF_strings(void);\n\n/* Error codes for the BUF functions. */\n\n/* Function codes. */\n# define BUF_F_BUF_MEMDUP                                 103\n# define BUF_F_BUF_MEM_GROW                               100\n# define BUF_F_BUF_MEM_GROW_CLEAN                         105\n# define BUF_F_BUF_MEM_NEW                                101\n# define BUF_F_BUF_STRDUP                                 102\n# define BUF_F_BUF_STRNDUP                                104\n\n/* Reason codes. */\n\n#ifdef  __cplusplus\n}\n#endif\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/arm/include/openssl/camellia.h",
    "content": "/* crypto/camellia/camellia.h */\n/* ====================================================================\n * Copyright (c) 2006 The OpenSSL Project.  All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n *\n * 1. Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n *\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in\n *    the documentation and/or other materials provided with the\n *    distribution.\n *\n * 3. All advertising materials mentioning features or use of this\n *    software must display the following acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit. (http://www.openssl.org/)\"\n *\n * 4. The names \"OpenSSL Toolkit\" and \"OpenSSL Project\" must not be used to\n *    endorse or promote products derived from this software without\n *    prior written permission. For written permission, please contact\n *    openssl-core@openssl.org.\n *\n * 5. Products derived from this software may not be called \"OpenSSL\"\n *    nor may \"OpenSSL\" appear in their names without prior written\n *    permission of the OpenSSL Project.\n *\n * 6. Redistributions of any form whatsoever must retain the following\n *    acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit (http://www.openssl.org/)\"\n *\n * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY\n * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\n * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR\n * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\n * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,\n * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED\n * OF THE POSSIBILITY OF SUCH DAMAGE.\n * ====================================================================\n *\n */\n\n#ifndef HEADER_CAMELLIA_H\n# define HEADER_CAMELLIA_H\n\n# include <openssl/opensslconf.h>\n\n# ifdef OPENSSL_NO_CAMELLIA\n#  error CAMELLIA is disabled.\n# endif\n\n# include <stddef.h>\n\n# define CAMELLIA_ENCRYPT        1\n# define CAMELLIA_DECRYPT        0\n\n/*\n * Because array size can't be a const in C, the following two are macros.\n * Both sizes are in bytes.\n */\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n/* This should be a hidden type, but EVP requires that the size be known */\n\n# define CAMELLIA_BLOCK_SIZE 16\n# define CAMELLIA_TABLE_BYTE_LEN 272\n# define CAMELLIA_TABLE_WORD_LEN (CAMELLIA_TABLE_BYTE_LEN / 4)\n\ntypedef unsigned int KEY_TABLE_TYPE[CAMELLIA_TABLE_WORD_LEN]; /* to match\n                                                               * with WORD */\n\nstruct camellia_key_st {\n    union {\n        double d;               /* ensures 64-bit align */\n        KEY_TABLE_TYPE rd_key;\n    } u;\n    int grand_rounds;\n};\ntypedef struct camellia_key_st CAMELLIA_KEY;\n\n# ifdef OPENSSL_FIPS\nint private_Camellia_set_key(const unsigned char *userKey, const int bits,\n                             CAMELLIA_KEY *key);\n# endif\nint Camellia_set_key(const unsigned char *userKey, const int bits,\n                     CAMELLIA_KEY *key);\n\nvoid Camellia_encrypt(const unsigned char *in, unsigned char *out,\n                      const CAMELLIA_KEY *key);\nvoid Camellia_decrypt(const unsigned char *in, unsigned char *out,\n                      const CAMELLIA_KEY *key);\n\nvoid Camellia_ecb_encrypt(const unsigned char *in, unsigned char *out,\n                          const CAMELLIA_KEY *key, const int enc);\nvoid Camellia_cbc_encrypt(const unsigned char *in, unsigned char *out,\n                          size_t length, const CAMELLIA_KEY *key,\n                          unsigned char *ivec, const int enc);\nvoid Camellia_cfb128_encrypt(const unsigned char *in, unsigned char *out,\n                             size_t length, const CAMELLIA_KEY *key,\n                             unsigned char *ivec, int *num, const int enc);\nvoid Camellia_cfb1_encrypt(const unsigned char *in, unsigned char *out,\n                           size_t length, const CAMELLIA_KEY *key,\n                           unsigned char *ivec, int *num, const int enc);\nvoid Camellia_cfb8_encrypt(const unsigned char *in, unsigned char *out,\n                           size_t length, const CAMELLIA_KEY *key,\n                           unsigned char *ivec, int *num, const int enc);\nvoid Camellia_ofb128_encrypt(const unsigned char *in, unsigned char *out,\n                             size_t length, const CAMELLIA_KEY *key,\n                             unsigned char *ivec, int *num);\nvoid Camellia_ctr128_encrypt(const unsigned char *in, unsigned char *out,\n                             size_t length, const CAMELLIA_KEY *key,\n                             unsigned char ivec[CAMELLIA_BLOCK_SIZE],\n                             unsigned char ecount_buf[CAMELLIA_BLOCK_SIZE],\n                             unsigned int *num);\n\n#ifdef  __cplusplus\n}\n#endif\n\n#endif                          /* !HEADER_Camellia_H */\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/arm/include/openssl/cast.h",
    "content": "/* crypto/cast/cast.h */\n/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)\n * All rights reserved.\n *\n * This package is an SSL implementation written\n * by Eric Young (eay@cryptsoft.com).\n * The implementation was written so as to conform with Netscapes SSL.\n *\n * This library is free for commercial and non-commercial use as long as\n * the following conditions are aheared to.  The following conditions\n * apply to all code found in this distribution, be it the RC4, RSA,\n * lhash, DES, etc., code; not just the SSL code.  The SSL documentation\n * included with this distribution is covered by the same copyright terms\n * except that the holder is Tim Hudson (tjh@cryptsoft.com).\n *\n * Copyright remains Eric Young's, and as such any Copyright notices in\n * the code are not to be removed.\n * If this package is used in a product, Eric Young should be given attribution\n * as the author of the parts of the library used.\n * This can be in the form of a textual message at program startup or\n * in documentation (online or textual) provided with the package.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the copyright\n *    notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in the\n *    documentation and/or other materials provided with the distribution.\n * 3. All advertising materials mentioning features or use of this software\n *    must display the following acknowledgement:\n *    \"This product includes cryptographic software written by\n *     Eric Young (eay@cryptsoft.com)\"\n *    The word 'cryptographic' can be left out if the rouines from the library\n *    being used are not cryptographic related :-).\n * 4. If you include any Windows specific code (or a derivative thereof) from\n *    the apps directory (application code) you must include an acknowledgement:\n *    \"This product includes software written by Tim Hudson (tjh@cryptsoft.com)\"\n *\n * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n * SUCH DAMAGE.\n *\n * The licence and distribution terms for any publically available version or\n * derivative of this code cannot be changed.  i.e. this code cannot simply be\n * copied and put under another distribution licence\n * [including the GNU Public Licence.]\n */\n\n#ifndef HEADER_CAST_H\n# define HEADER_CAST_H\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n# include <openssl/opensslconf.h>\n\n# ifdef OPENSSL_NO_CAST\n#  error CAST is disabled.\n# endif\n\n# define CAST_ENCRYPT    1\n# define CAST_DECRYPT    0\n\n# define CAST_LONG unsigned int\n\n# define CAST_BLOCK      8\n# define CAST_KEY_LENGTH 16\n\ntypedef struct cast_key_st {\n    CAST_LONG data[32];\n    int short_key;              /* Use reduced rounds for short key */\n} CAST_KEY;\n\n# ifdef OPENSSL_FIPS\nvoid private_CAST_set_key(CAST_KEY *key, int len, const unsigned char *data);\n# endif\nvoid CAST_set_key(CAST_KEY *key, int len, const unsigned char *data);\nvoid CAST_ecb_encrypt(const unsigned char *in, unsigned char *out,\n                      const CAST_KEY *key, int enc);\nvoid CAST_encrypt(CAST_LONG *data, const CAST_KEY *key);\nvoid CAST_decrypt(CAST_LONG *data, const CAST_KEY *key);\nvoid CAST_cbc_encrypt(const unsigned char *in, unsigned char *out,\n                      long length, const CAST_KEY *ks, unsigned char *iv,\n                      int enc);\nvoid CAST_cfb64_encrypt(const unsigned char *in, unsigned char *out,\n                        long length, const CAST_KEY *schedule,\n                        unsigned char *ivec, int *num, int enc);\nvoid CAST_ofb64_encrypt(const unsigned char *in, unsigned char *out,\n                        long length, const CAST_KEY *schedule,\n                        unsigned char *ivec, int *num);\n\n#ifdef  __cplusplus\n}\n#endif\n\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/arm/include/openssl/cmac.h",
    "content": "/* crypto/cmac/cmac.h */\n/*\n * Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL\n * project.\n */\n/* ====================================================================\n * Copyright (c) 2010 The OpenSSL Project.  All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n *\n * 1. Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n *\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in\n *    the documentation and/or other materials provided with the\n *    distribution.\n *\n * 3. All advertising materials mentioning features or use of this\n *    software must display the following acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)\"\n *\n * 4. The names \"OpenSSL Toolkit\" and \"OpenSSL Project\" must not be used to\n *    endorse or promote products derived from this software without\n *    prior written permission. For written permission, please contact\n *    licensing@OpenSSL.org.\n *\n * 5. Products derived from this software may not be called \"OpenSSL\"\n *    nor may \"OpenSSL\" appear in their names without prior written\n *    permission of the OpenSSL Project.\n *\n * 6. Redistributions of any form whatsoever must retain the following\n *    acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)\"\n *\n * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY\n * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\n * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR\n * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\n * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,\n * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED\n * OF THE POSSIBILITY OF SUCH DAMAGE.\n * ====================================================================\n */\n\n#ifndef HEADER_CMAC_H\n# define HEADER_CMAC_H\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n# include <openssl/evp.h>\n\n/* Opaque */\ntypedef struct CMAC_CTX_st CMAC_CTX;\n\nCMAC_CTX *CMAC_CTX_new(void);\nvoid CMAC_CTX_cleanup(CMAC_CTX *ctx);\nvoid CMAC_CTX_free(CMAC_CTX *ctx);\nEVP_CIPHER_CTX *CMAC_CTX_get0_cipher_ctx(CMAC_CTX *ctx);\nint CMAC_CTX_copy(CMAC_CTX *out, const CMAC_CTX *in);\n\nint CMAC_Init(CMAC_CTX *ctx, const void *key, size_t keylen,\n              const EVP_CIPHER *cipher, ENGINE *impl);\nint CMAC_Update(CMAC_CTX *ctx, const void *data, size_t dlen);\nint CMAC_Final(CMAC_CTX *ctx, unsigned char *out, size_t *poutlen);\nint CMAC_resume(CMAC_CTX *ctx);\n\n#ifdef  __cplusplus\n}\n#endif\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/arm/include/openssl/cms.h",
    "content": "/* crypto/cms/cms.h */\n/*\n * Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL\n * project.\n */\n/* ====================================================================\n * Copyright (c) 2008 The OpenSSL Project.  All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n *\n * 1. Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n *\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in\n *    the documentation and/or other materials provided with the\n *    distribution.\n *\n * 3. All advertising materials mentioning features or use of this\n *    software must display the following acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)\"\n *\n * 4. The names \"OpenSSL Toolkit\" and \"OpenSSL Project\" must not be used to\n *    endorse or promote products derived from this software without\n *    prior written permission. For written permission, please contact\n *    licensing@OpenSSL.org.\n *\n * 5. Products derived from this software may not be called \"OpenSSL\"\n *    nor may \"OpenSSL\" appear in their names without prior written\n *    permission of the OpenSSL Project.\n *\n * 6. Redistributions of any form whatsoever must retain the following\n *    acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)\"\n *\n * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY\n * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\n * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR\n * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\n * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,\n * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED\n * OF THE POSSIBILITY OF SUCH DAMAGE.\n * ====================================================================\n */\n\n#ifndef HEADER_CMS_H\n# define HEADER_CMS_H\n\n# include <openssl/x509.h>\n\n# ifdef OPENSSL_NO_CMS\n#  error CMS is disabled.\n# endif\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\ntypedef struct CMS_ContentInfo_st CMS_ContentInfo;\ntypedef struct CMS_SignerInfo_st CMS_SignerInfo;\ntypedef struct CMS_CertificateChoices CMS_CertificateChoices;\ntypedef struct CMS_RevocationInfoChoice_st CMS_RevocationInfoChoice;\ntypedef struct CMS_RecipientInfo_st CMS_RecipientInfo;\ntypedef struct CMS_ReceiptRequest_st CMS_ReceiptRequest;\ntypedef struct CMS_Receipt_st CMS_Receipt;\ntypedef struct CMS_RecipientEncryptedKey_st CMS_RecipientEncryptedKey;\ntypedef struct CMS_OtherKeyAttribute_st CMS_OtherKeyAttribute;\n\nDECLARE_STACK_OF(CMS_SignerInfo)\nDECLARE_STACK_OF(GENERAL_NAMES)\nDECLARE_STACK_OF(CMS_RecipientEncryptedKey)\nDECLARE_ASN1_FUNCTIONS(CMS_ContentInfo)\nDECLARE_ASN1_FUNCTIONS(CMS_ReceiptRequest)\nDECLARE_ASN1_PRINT_FUNCTION(CMS_ContentInfo)\n\n# define CMS_SIGNERINFO_ISSUER_SERIAL    0\n# define CMS_SIGNERINFO_KEYIDENTIFIER    1\n\n# define CMS_RECIPINFO_NONE              -1\n# define CMS_RECIPINFO_TRANS             0\n# define CMS_RECIPINFO_AGREE             1\n# define CMS_RECIPINFO_KEK               2\n# define CMS_RECIPINFO_PASS              3\n# define CMS_RECIPINFO_OTHER             4\n\n/* S/MIME related flags */\n\n# define CMS_TEXT                        0x1\n# define CMS_NOCERTS                     0x2\n# define CMS_NO_CONTENT_VERIFY           0x4\n# define CMS_NO_ATTR_VERIFY              0x8\n# define CMS_NOSIGS                      \\\n                        (CMS_NO_CONTENT_VERIFY|CMS_NO_ATTR_VERIFY)\n# define CMS_NOINTERN                    0x10\n# define CMS_NO_SIGNER_CERT_VERIFY       0x20\n# define CMS_NOVERIFY                    0x20\n# define CMS_DETACHED                    0x40\n# define CMS_BINARY                      0x80\n# define CMS_NOATTR                      0x100\n# define CMS_NOSMIMECAP                  0x200\n# define CMS_NOOLDMIMETYPE               0x400\n# define CMS_CRLFEOL                     0x800\n# define CMS_STREAM                      0x1000\n# define CMS_NOCRL                       0x2000\n# define CMS_PARTIAL                     0x4000\n# define CMS_REUSE_DIGEST                0x8000\n# define CMS_USE_KEYID                   0x10000\n# define CMS_DEBUG_DECRYPT               0x20000\n# define CMS_KEY_PARAM                   0x40000\n\nconst ASN1_OBJECT *CMS_get0_type(CMS_ContentInfo *cms);\n\nBIO *CMS_dataInit(CMS_ContentInfo *cms, BIO *icont);\nint CMS_dataFinal(CMS_ContentInfo *cms, BIO *bio);\n\nASN1_OCTET_STRING **CMS_get0_content(CMS_ContentInfo *cms);\nint CMS_is_detached(CMS_ContentInfo *cms);\nint CMS_set_detached(CMS_ContentInfo *cms, int detached);\n\n# ifdef HEADER_PEM_H\nDECLARE_PEM_rw_const(CMS, CMS_ContentInfo)\n# endif\nint CMS_stream(unsigned char ***boundary, CMS_ContentInfo *cms);\nCMS_ContentInfo *d2i_CMS_bio(BIO *bp, CMS_ContentInfo **cms);\nint i2d_CMS_bio(BIO *bp, CMS_ContentInfo *cms);\n\nBIO *BIO_new_CMS(BIO *out, CMS_ContentInfo *cms);\nint i2d_CMS_bio_stream(BIO *out, CMS_ContentInfo *cms, BIO *in, int flags);\nint PEM_write_bio_CMS_stream(BIO *out, CMS_ContentInfo *cms, BIO *in,\n                             int flags);\nCMS_ContentInfo *SMIME_read_CMS(BIO *bio, BIO **bcont);\nint SMIME_write_CMS(BIO *bio, CMS_ContentInfo *cms, BIO *data, int flags);\n\nint CMS_final(CMS_ContentInfo *cms, BIO *data, BIO *dcont,\n              unsigned int flags);\n\nCMS_ContentInfo *CMS_sign(X509 *signcert, EVP_PKEY *pkey,\n                          STACK_OF(X509) *certs, BIO *data,\n                          unsigned int flags);\n\nCMS_ContentInfo *CMS_sign_receipt(CMS_SignerInfo *si,\n                                  X509 *signcert, EVP_PKEY *pkey,\n                                  STACK_OF(X509) *certs, unsigned int flags);\n\nint CMS_data(CMS_ContentInfo *cms, BIO *out, unsigned int flags);\nCMS_ContentInfo *CMS_data_create(BIO *in, unsigned int flags);\n\nint CMS_digest_verify(CMS_ContentInfo *cms, BIO *dcont, BIO *out,\n                      unsigned int flags);\nCMS_ContentInfo *CMS_digest_create(BIO *in, const EVP_MD *md,\n                                   unsigned int flags);\n\nint CMS_EncryptedData_decrypt(CMS_ContentInfo *cms,\n                              const unsigned char *key, size_t keylen,\n                              BIO *dcont, BIO *out, unsigned int flags);\n\nCMS_ContentInfo *CMS_EncryptedData_encrypt(BIO *in, const EVP_CIPHER *cipher,\n                                           const unsigned char *key,\n                                           size_t keylen, unsigned int flags);\n\nint CMS_EncryptedData_set1_key(CMS_ContentInfo *cms, const EVP_CIPHER *ciph,\n                               const unsigned char *key, size_t keylen);\n\nint CMS_verify(CMS_ContentInfo *cms, STACK_OF(X509) *certs,\n               X509_STORE *store, BIO *dcont, BIO *out, unsigned int flags);\n\nint CMS_verify_receipt(CMS_ContentInfo *rcms, CMS_ContentInfo *ocms,\n                       STACK_OF(X509) *certs,\n                       X509_STORE *store, unsigned int flags);\n\nSTACK_OF(X509) *CMS_get0_signers(CMS_ContentInfo *cms);\n\nCMS_ContentInfo *CMS_encrypt(STACK_OF(X509) *certs, BIO *in,\n                             const EVP_CIPHER *cipher, unsigned int flags);\n\nint CMS_decrypt(CMS_ContentInfo *cms, EVP_PKEY *pkey, X509 *cert,\n                BIO *dcont, BIO *out, unsigned int flags);\n\nint CMS_decrypt_set1_pkey(CMS_ContentInfo *cms, EVP_PKEY *pk, X509 *cert);\nint CMS_decrypt_set1_key(CMS_ContentInfo *cms,\n                         unsigned char *key, size_t keylen,\n                         unsigned char *id, size_t idlen);\nint CMS_decrypt_set1_password(CMS_ContentInfo *cms,\n                              unsigned char *pass, ossl_ssize_t passlen);\n\nSTACK_OF(CMS_RecipientInfo) *CMS_get0_RecipientInfos(CMS_ContentInfo *cms);\nint CMS_RecipientInfo_type(CMS_RecipientInfo *ri);\nEVP_PKEY_CTX *CMS_RecipientInfo_get0_pkey_ctx(CMS_RecipientInfo *ri);\nCMS_ContentInfo *CMS_EnvelopedData_create(const EVP_CIPHER *cipher);\nCMS_RecipientInfo *CMS_add1_recipient_cert(CMS_ContentInfo *cms,\n                                           X509 *recip, unsigned int flags);\nint CMS_RecipientInfo_set0_pkey(CMS_RecipientInfo *ri, EVP_PKEY *pkey);\nint CMS_RecipientInfo_ktri_cert_cmp(CMS_RecipientInfo *ri, X509 *cert);\nint CMS_RecipientInfo_ktri_get0_algs(CMS_RecipientInfo *ri,\n                                     EVP_PKEY **pk, X509 **recip,\n                                     X509_ALGOR **palg);\nint CMS_RecipientInfo_ktri_get0_signer_id(CMS_RecipientInfo *ri,\n                                          ASN1_OCTET_STRING **keyid,\n                                          X509_NAME **issuer,\n                                          ASN1_INTEGER **sno);\n\nCMS_RecipientInfo *CMS_add0_recipient_key(CMS_ContentInfo *cms, int nid,\n                                          unsigned char *key, size_t keylen,\n                                          unsigned char *id, size_t idlen,\n                                          ASN1_GENERALIZEDTIME *date,\n                                          ASN1_OBJECT *otherTypeId,\n                                          ASN1_TYPE *otherType);\n\nint CMS_RecipientInfo_kekri_get0_id(CMS_RecipientInfo *ri,\n                                    X509_ALGOR **palg,\n                                    ASN1_OCTET_STRING **pid,\n                                    ASN1_GENERALIZEDTIME **pdate,\n                                    ASN1_OBJECT **potherid,\n                                    ASN1_TYPE **pothertype);\n\nint CMS_RecipientInfo_set0_key(CMS_RecipientInfo *ri,\n                               unsigned char *key, size_t keylen);\n\nint CMS_RecipientInfo_kekri_id_cmp(CMS_RecipientInfo *ri,\n                                   const unsigned char *id, size_t idlen);\n\nint CMS_RecipientInfo_set0_password(CMS_RecipientInfo *ri,\n                                    unsigned char *pass,\n                                    ossl_ssize_t passlen);\n\nCMS_RecipientInfo *CMS_add0_recipient_password(CMS_ContentInfo *cms,\n                                               int iter, int wrap_nid,\n                                               int pbe_nid,\n                                               unsigned char *pass,\n                                               ossl_ssize_t passlen,\n                                               const EVP_CIPHER *kekciph);\n\nint CMS_RecipientInfo_decrypt(CMS_ContentInfo *cms, CMS_RecipientInfo *ri);\nint CMS_RecipientInfo_encrypt(CMS_ContentInfo *cms, CMS_RecipientInfo *ri);\n\nint CMS_uncompress(CMS_ContentInfo *cms, BIO *dcont, BIO *out,\n                   unsigned int flags);\nCMS_ContentInfo *CMS_compress(BIO *in, int comp_nid, unsigned int flags);\n\nint CMS_set1_eContentType(CMS_ContentInfo *cms, const ASN1_OBJECT *oid);\nconst ASN1_OBJECT *CMS_get0_eContentType(CMS_ContentInfo *cms);\n\nCMS_CertificateChoices *CMS_add0_CertificateChoices(CMS_ContentInfo *cms);\nint CMS_add0_cert(CMS_ContentInfo *cms, X509 *cert);\nint CMS_add1_cert(CMS_ContentInfo *cms, X509 *cert);\nSTACK_OF(X509) *CMS_get1_certs(CMS_ContentInfo *cms);\n\nCMS_RevocationInfoChoice *CMS_add0_RevocationInfoChoice(CMS_ContentInfo *cms);\nint CMS_add0_crl(CMS_ContentInfo *cms, X509_CRL *crl);\nint CMS_add1_crl(CMS_ContentInfo *cms, X509_CRL *crl);\nSTACK_OF(X509_CRL) *CMS_get1_crls(CMS_ContentInfo *cms);\n\nint CMS_SignedData_init(CMS_ContentInfo *cms);\nCMS_SignerInfo *CMS_add1_signer(CMS_ContentInfo *cms,\n                                X509 *signer, EVP_PKEY *pk, const EVP_MD *md,\n                                unsigned int flags);\nEVP_PKEY_CTX *CMS_SignerInfo_get0_pkey_ctx(CMS_SignerInfo *si);\nEVP_MD_CTX *CMS_SignerInfo_get0_md_ctx(CMS_SignerInfo *si);\nSTACK_OF(CMS_SignerInfo) *CMS_get0_SignerInfos(CMS_ContentInfo *cms);\n\nvoid CMS_SignerInfo_set1_signer_cert(CMS_SignerInfo *si, X509 *signer);\nint CMS_SignerInfo_get0_signer_id(CMS_SignerInfo *si,\n                                  ASN1_OCTET_STRING **keyid,\n                                  X509_NAME **issuer, ASN1_INTEGER **sno);\nint CMS_SignerInfo_cert_cmp(CMS_SignerInfo *si, X509 *cert);\nint CMS_set1_signers_certs(CMS_ContentInfo *cms, STACK_OF(X509) *certs,\n                           unsigned int flags);\nvoid CMS_SignerInfo_get0_algs(CMS_SignerInfo *si, EVP_PKEY **pk,\n                              X509 **signer, X509_ALGOR **pdig,\n                              X509_ALGOR **psig);\nASN1_OCTET_STRING *CMS_SignerInfo_get0_signature(CMS_SignerInfo *si);\nint CMS_SignerInfo_sign(CMS_SignerInfo *si);\nint CMS_SignerInfo_verify(CMS_SignerInfo *si);\nint CMS_SignerInfo_verify_content(CMS_SignerInfo *si, BIO *chain);\n\nint CMS_add_smimecap(CMS_SignerInfo *si, STACK_OF(X509_ALGOR) *algs);\nint CMS_add_simple_smimecap(STACK_OF(X509_ALGOR) **algs,\n                            int algnid, int keysize);\nint CMS_add_standard_smimecap(STACK_OF(X509_ALGOR) **smcap);\n\nint CMS_signed_get_attr_count(const CMS_SignerInfo *si);\nint CMS_signed_get_attr_by_NID(const CMS_SignerInfo *si, int nid,\n                               int lastpos);\nint CMS_signed_get_attr_by_OBJ(const CMS_SignerInfo *si, ASN1_OBJECT *obj,\n                               int lastpos);\nX509_ATTRIBUTE *CMS_signed_get_attr(const CMS_SignerInfo *si, int loc);\nX509_ATTRIBUTE *CMS_signed_delete_attr(CMS_SignerInfo *si, int loc);\nint CMS_signed_add1_attr(CMS_SignerInfo *si, X509_ATTRIBUTE *attr);\nint CMS_signed_add1_attr_by_OBJ(CMS_SignerInfo *si,\n                                const ASN1_OBJECT *obj, int type,\n                                const void *bytes, int len);\nint CMS_signed_add1_attr_by_NID(CMS_SignerInfo *si,\n                                int nid, int type,\n                                const void *bytes, int len);\nint CMS_signed_add1_attr_by_txt(CMS_SignerInfo *si,\n                                const char *attrname, int type,\n                                const void *bytes, int len);\nvoid *CMS_signed_get0_data_by_OBJ(CMS_SignerInfo *si, ASN1_OBJECT *oid,\n                                  int lastpos, int type);\n\nint CMS_unsigned_get_attr_count(const CMS_SignerInfo *si);\nint CMS_unsigned_get_attr_by_NID(const CMS_SignerInfo *si, int nid,\n                                 int lastpos);\nint CMS_unsigned_get_attr_by_OBJ(const CMS_SignerInfo *si, ASN1_OBJECT *obj,\n                                 int lastpos);\nX509_ATTRIBUTE *CMS_unsigned_get_attr(const CMS_SignerInfo *si, int loc);\nX509_ATTRIBUTE *CMS_unsigned_delete_attr(CMS_SignerInfo *si, int loc);\nint CMS_unsigned_add1_attr(CMS_SignerInfo *si, X509_ATTRIBUTE *attr);\nint CMS_unsigned_add1_attr_by_OBJ(CMS_SignerInfo *si,\n                                  const ASN1_OBJECT *obj, int type,\n                                  const void *bytes, int len);\nint CMS_unsigned_add1_attr_by_NID(CMS_SignerInfo *si,\n                                  int nid, int type,\n                                  const void *bytes, int len);\nint CMS_unsigned_add1_attr_by_txt(CMS_SignerInfo *si,\n                                  const char *attrname, int type,\n                                  const void *bytes, int len);\nvoid *CMS_unsigned_get0_data_by_OBJ(CMS_SignerInfo *si, ASN1_OBJECT *oid,\n                                    int lastpos, int type);\n\n# ifdef HEADER_X509V3_H\n\nint CMS_get1_ReceiptRequest(CMS_SignerInfo *si, CMS_ReceiptRequest **prr);\nCMS_ReceiptRequest *CMS_ReceiptRequest_create0(unsigned char *id, int idlen,\n                                               int allorfirst,\n                                               STACK_OF(GENERAL_NAMES)\n                                               *receiptList, STACK_OF(GENERAL_NAMES)\n                                               *receiptsTo);\nint CMS_add1_ReceiptRequest(CMS_SignerInfo *si, CMS_ReceiptRequest *rr);\nvoid CMS_ReceiptRequest_get0_values(CMS_ReceiptRequest *rr,\n                                    ASN1_STRING **pcid,\n                                    int *pallorfirst,\n                                    STACK_OF(GENERAL_NAMES) **plist,\n                                    STACK_OF(GENERAL_NAMES) **prto);\n# endif\nint CMS_RecipientInfo_kari_get0_alg(CMS_RecipientInfo *ri,\n                                    X509_ALGOR **palg,\n                                    ASN1_OCTET_STRING **pukm);\nSTACK_OF(CMS_RecipientEncryptedKey)\n*CMS_RecipientInfo_kari_get0_reks(CMS_RecipientInfo *ri);\n\nint CMS_RecipientInfo_kari_get0_orig_id(CMS_RecipientInfo *ri,\n                                        X509_ALGOR **pubalg,\n                                        ASN1_BIT_STRING **pubkey,\n                                        ASN1_OCTET_STRING **keyid,\n                                        X509_NAME **issuer,\n                                        ASN1_INTEGER **sno);\n\nint CMS_RecipientInfo_kari_orig_id_cmp(CMS_RecipientInfo *ri, X509 *cert);\n\nint CMS_RecipientEncryptedKey_get0_id(CMS_RecipientEncryptedKey *rek,\n                                      ASN1_OCTET_STRING **keyid,\n                                      ASN1_GENERALIZEDTIME **tm,\n                                      CMS_OtherKeyAttribute **other,\n                                      X509_NAME **issuer, ASN1_INTEGER **sno);\nint CMS_RecipientEncryptedKey_cert_cmp(CMS_RecipientEncryptedKey *rek,\n                                       X509 *cert);\nint CMS_RecipientInfo_kari_set0_pkey(CMS_RecipientInfo *ri, EVP_PKEY *pk);\nEVP_CIPHER_CTX *CMS_RecipientInfo_kari_get0_ctx(CMS_RecipientInfo *ri);\nint CMS_RecipientInfo_kari_decrypt(CMS_ContentInfo *cms,\n                                   CMS_RecipientInfo *ri,\n                                   CMS_RecipientEncryptedKey *rek);\n\nint CMS_SharedInfo_encode(unsigned char **pder, X509_ALGOR *kekalg,\n                          ASN1_OCTET_STRING *ukm, int keylen);\n\n/* BEGIN ERROR CODES */\n/*\n * The following lines are auto generated by the script mkerr.pl. Any changes\n * made after this point may be overwritten when the script is next run.\n */\nvoid ERR_load_CMS_strings(void);\n\n/* Error codes for the CMS functions. */\n\n/* Function codes. */\n# define CMS_F_CHECK_CONTENT                              99\n# define CMS_F_CMS_ADD0_CERT                              164\n# define CMS_F_CMS_ADD0_RECIPIENT_KEY                     100\n# define CMS_F_CMS_ADD0_RECIPIENT_PASSWORD                165\n# define CMS_F_CMS_ADD1_RECEIPTREQUEST                    158\n# define CMS_F_CMS_ADD1_RECIPIENT_CERT                    101\n# define CMS_F_CMS_ADD1_SIGNER                            102\n# define CMS_F_CMS_ADD1_SIGNINGTIME                       103\n# define CMS_F_CMS_COMPRESS                               104\n# define CMS_F_CMS_COMPRESSEDDATA_CREATE                  105\n# define CMS_F_CMS_COMPRESSEDDATA_INIT_BIO                106\n# define CMS_F_CMS_COPY_CONTENT                           107\n# define CMS_F_CMS_COPY_MESSAGEDIGEST                     108\n# define CMS_F_CMS_DATA                                   109\n# define CMS_F_CMS_DATAFINAL                              110\n# define CMS_F_CMS_DATAINIT                               111\n# define CMS_F_CMS_DECRYPT                                112\n# define CMS_F_CMS_DECRYPT_SET1_KEY                       113\n# define CMS_F_CMS_DECRYPT_SET1_PASSWORD                  166\n# define CMS_F_CMS_DECRYPT_SET1_PKEY                      114\n# define CMS_F_CMS_DIGESTALGORITHM_FIND_CTX               115\n# define CMS_F_CMS_DIGESTALGORITHM_INIT_BIO               116\n# define CMS_F_CMS_DIGESTEDDATA_DO_FINAL                  117\n# define CMS_F_CMS_DIGEST_VERIFY                          118\n# define CMS_F_CMS_ENCODE_RECEIPT                         161\n# define CMS_F_CMS_ENCRYPT                                119\n# define CMS_F_CMS_ENCRYPTEDCONTENT_INIT_BIO              120\n# define CMS_F_CMS_ENCRYPTEDDATA_DECRYPT                  121\n# define CMS_F_CMS_ENCRYPTEDDATA_ENCRYPT                  122\n# define CMS_F_CMS_ENCRYPTEDDATA_SET1_KEY                 123\n# define CMS_F_CMS_ENVELOPEDDATA_CREATE                   124\n# define CMS_F_CMS_ENVELOPEDDATA_INIT_BIO                 125\n# define CMS_F_CMS_ENVELOPED_DATA_INIT                    126\n# define CMS_F_CMS_ENV_ASN1_CTRL                          171\n# define CMS_F_CMS_FINAL                                  127\n# define CMS_F_CMS_GET0_CERTIFICATE_CHOICES               128\n# define CMS_F_CMS_GET0_CONTENT                           129\n# define CMS_F_CMS_GET0_ECONTENT_TYPE                     130\n# define CMS_F_CMS_GET0_ENVELOPED                         131\n# define CMS_F_CMS_GET0_REVOCATION_CHOICES                132\n# define CMS_F_CMS_GET0_SIGNED                            133\n# define CMS_F_CMS_MSGSIGDIGEST_ADD1                      162\n# define CMS_F_CMS_RECEIPTREQUEST_CREATE0                 159\n# define CMS_F_CMS_RECEIPT_VERIFY                         160\n# define CMS_F_CMS_RECIPIENTINFO_DECRYPT                  134\n# define CMS_F_CMS_RECIPIENTINFO_ENCRYPT                  169\n# define CMS_F_CMS_RECIPIENTINFO_KARI_ENCRYPT             178\n# define CMS_F_CMS_RECIPIENTINFO_KARI_GET0_ALG            175\n# define CMS_F_CMS_RECIPIENTINFO_KARI_GET0_ORIG_ID        173\n# define CMS_F_CMS_RECIPIENTINFO_KARI_GET0_REKS           172\n# define CMS_F_CMS_RECIPIENTINFO_KARI_ORIG_ID_CMP         174\n# define CMS_F_CMS_RECIPIENTINFO_KEKRI_DECRYPT            135\n# define CMS_F_CMS_RECIPIENTINFO_KEKRI_ENCRYPT            136\n# define CMS_F_CMS_RECIPIENTINFO_KEKRI_GET0_ID            137\n# define CMS_F_CMS_RECIPIENTINFO_KEKRI_ID_CMP             138\n# define CMS_F_CMS_RECIPIENTINFO_KTRI_CERT_CMP            139\n# define CMS_F_CMS_RECIPIENTINFO_KTRI_DECRYPT             140\n# define CMS_F_CMS_RECIPIENTINFO_KTRI_ENCRYPT             141\n# define CMS_F_CMS_RECIPIENTINFO_KTRI_GET0_ALGS           142\n# define CMS_F_CMS_RECIPIENTINFO_KTRI_GET0_SIGNER_ID      143\n# define CMS_F_CMS_RECIPIENTINFO_PWRI_CRYPT               167\n# define CMS_F_CMS_RECIPIENTINFO_SET0_KEY                 144\n# define CMS_F_CMS_RECIPIENTINFO_SET0_PASSWORD            168\n# define CMS_F_CMS_RECIPIENTINFO_SET0_PKEY                145\n# define CMS_F_CMS_SD_ASN1_CTRL                           170\n# define CMS_F_CMS_SET1_IAS                               176\n# define CMS_F_CMS_SET1_KEYID                             177\n# define CMS_F_CMS_SET1_SIGNERIDENTIFIER                  146\n# define CMS_F_CMS_SET_DETACHED                           147\n# define CMS_F_CMS_SIGN                                   148\n# define CMS_F_CMS_SIGNED_DATA_INIT                       149\n# define CMS_F_CMS_SIGNERINFO_CONTENT_SIGN                150\n# define CMS_F_CMS_SIGNERINFO_SIGN                        151\n# define CMS_F_CMS_SIGNERINFO_VERIFY                      152\n# define CMS_F_CMS_SIGNERINFO_VERIFY_CERT                 153\n# define CMS_F_CMS_SIGNERINFO_VERIFY_CONTENT              154\n# define CMS_F_CMS_SIGN_RECEIPT                           163\n# define CMS_F_CMS_STREAM                                 155\n# define CMS_F_CMS_UNCOMPRESS                             156\n# define CMS_F_CMS_VERIFY                                 157\n\n/* Reason codes. */\n# define CMS_R_ADD_SIGNER_ERROR                           99\n# define CMS_R_CERTIFICATE_ALREADY_PRESENT                175\n# define CMS_R_CERTIFICATE_HAS_NO_KEYID                   160\n# define CMS_R_CERTIFICATE_VERIFY_ERROR                   100\n# define CMS_R_CIPHER_INITIALISATION_ERROR                101\n# define CMS_R_CIPHER_PARAMETER_INITIALISATION_ERROR      102\n# define CMS_R_CMS_DATAFINAL_ERROR                        103\n# define CMS_R_CMS_LIB                                    104\n# define CMS_R_CONTENTIDENTIFIER_MISMATCH                 170\n# define CMS_R_CONTENT_NOT_FOUND                          105\n# define CMS_R_CONTENT_TYPE_MISMATCH                      171\n# define CMS_R_CONTENT_TYPE_NOT_COMPRESSED_DATA           106\n# define CMS_R_CONTENT_TYPE_NOT_ENVELOPED_DATA            107\n# define CMS_R_CONTENT_TYPE_NOT_SIGNED_DATA               108\n# define CMS_R_CONTENT_VERIFY_ERROR                       109\n# define CMS_R_CTRL_ERROR                                 110\n# define CMS_R_CTRL_FAILURE                               111\n# define CMS_R_DECRYPT_ERROR                              112\n# define CMS_R_DIGEST_ERROR                               161\n# define CMS_R_ERROR_GETTING_PUBLIC_KEY                   113\n# define CMS_R_ERROR_READING_MESSAGEDIGEST_ATTRIBUTE      114\n# define CMS_R_ERROR_SETTING_KEY                          115\n# define CMS_R_ERROR_SETTING_RECIPIENTINFO                116\n# define CMS_R_INVALID_ENCRYPTED_KEY_LENGTH               117\n# define CMS_R_INVALID_KEY_ENCRYPTION_PARAMETER           176\n# define CMS_R_INVALID_KEY_LENGTH                         118\n# define CMS_R_MD_BIO_INIT_ERROR                          119\n# define CMS_R_MESSAGEDIGEST_ATTRIBUTE_WRONG_LENGTH       120\n# define CMS_R_MESSAGEDIGEST_WRONG_LENGTH                 121\n# define CMS_R_MSGSIGDIGEST_ERROR                         172\n# define CMS_R_MSGSIGDIGEST_VERIFICATION_FAILURE          162\n# define CMS_R_MSGSIGDIGEST_WRONG_LENGTH                  163\n# define CMS_R_NEED_ONE_SIGNER                            164\n# define CMS_R_NOT_A_SIGNED_RECEIPT                       165\n# define CMS_R_NOT_ENCRYPTED_DATA                         122\n# define CMS_R_NOT_KEK                                    123\n# define CMS_R_NOT_KEY_AGREEMENT                          181\n# define CMS_R_NOT_KEY_TRANSPORT                          124\n# define CMS_R_NOT_PWRI                                   177\n# define CMS_R_NOT_SUPPORTED_FOR_THIS_KEY_TYPE            125\n# define CMS_R_NO_CIPHER                                  126\n# define CMS_R_NO_CONTENT                                 127\n# define CMS_R_NO_CONTENT_TYPE                            173\n# define CMS_R_NO_DEFAULT_DIGEST                          128\n# define CMS_R_NO_DIGEST_SET                              129\n# define CMS_R_NO_KEY                                     130\n# define CMS_R_NO_KEY_OR_CERT                             174\n# define CMS_R_NO_MATCHING_DIGEST                         131\n# define CMS_R_NO_MATCHING_RECIPIENT                      132\n# define CMS_R_NO_MATCHING_SIGNATURE                      166\n# define CMS_R_NO_MSGSIGDIGEST                            167\n# define CMS_R_NO_PASSWORD                                178\n# define CMS_R_NO_PRIVATE_KEY                             133\n# define CMS_R_NO_PUBLIC_KEY                              134\n# define CMS_R_NO_RECEIPT_REQUEST                         168\n# define CMS_R_NO_SIGNERS                                 135\n# define CMS_R_PRIVATE_KEY_DOES_NOT_MATCH_CERTIFICATE     136\n# define CMS_R_RECEIPT_DECODE_ERROR                       169\n# define CMS_R_RECIPIENT_ERROR                            137\n# define CMS_R_SIGNER_CERTIFICATE_NOT_FOUND               138\n# define CMS_R_SIGNFINAL_ERROR                            139\n# define CMS_R_SMIME_TEXT_ERROR                           140\n# define CMS_R_STORE_INIT_ERROR                           141\n# define CMS_R_TYPE_NOT_COMPRESSED_DATA                   142\n# define CMS_R_TYPE_NOT_DATA                              143\n# define CMS_R_TYPE_NOT_DIGESTED_DATA                     144\n# define CMS_R_TYPE_NOT_ENCRYPTED_DATA                    145\n# define CMS_R_TYPE_NOT_ENVELOPED_DATA                    146\n# define CMS_R_UNABLE_TO_FINALIZE_CONTEXT                 147\n# define CMS_R_UNKNOWN_CIPHER                             148\n# define CMS_R_UNKNOWN_DIGEST_ALGORIHM                    149\n# define CMS_R_UNKNOWN_ID                                 150\n# define CMS_R_UNSUPPORTED_COMPRESSION_ALGORITHM          151\n# define CMS_R_UNSUPPORTED_CONTENT_TYPE                   152\n# define CMS_R_UNSUPPORTED_KEK_ALGORITHM                  153\n# define CMS_R_UNSUPPORTED_KEY_ENCRYPTION_ALGORITHM       179\n# define CMS_R_UNSUPPORTED_RECIPIENT_TYPE                 154\n# define CMS_R_UNSUPPORTED_RECPIENTINFO_TYPE              155\n# define CMS_R_UNSUPPORTED_TYPE                           156\n# define CMS_R_UNWRAP_ERROR                               157\n# define CMS_R_UNWRAP_FAILURE                             180\n# define CMS_R_VERIFICATION_FAILURE                       158\n# define CMS_R_WRAP_ERROR                                 159\n\n#ifdef  __cplusplus\n}\n#endif\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/arm/include/openssl/conf.h",
    "content": "/* crypto/conf/conf.h */\n/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)\n * All rights reserved.\n *\n * This package is an SSL implementation written\n * by Eric Young (eay@cryptsoft.com).\n * The implementation was written so as to conform with Netscapes SSL.\n *\n * This library is free for commercial and non-commercial use as long as\n * the following conditions are aheared to.  The following conditions\n * apply to all code found in this distribution, be it the RC4, RSA,\n * lhash, DES, etc., code; not just the SSL code.  The SSL documentation\n * included with this distribution is covered by the same copyright terms\n * except that the holder is Tim Hudson (tjh@cryptsoft.com).\n *\n * Copyright remains Eric Young's, and as such any Copyright notices in\n * the code are not to be removed.\n * If this package is used in a product, Eric Young should be given attribution\n * as the author of the parts of the library used.\n * This can be in the form of a textual message at program startup or\n * in documentation (online or textual) provided with the package.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the copyright\n *    notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in the\n *    documentation and/or other materials provided with the distribution.\n * 3. All advertising materials mentioning features or use of this software\n *    must display the following acknowledgement:\n *    \"This product includes cryptographic software written by\n *     Eric Young (eay@cryptsoft.com)\"\n *    The word 'cryptographic' can be left out if the rouines from the library\n *    being used are not cryptographic related :-).\n * 4. If you include any Windows specific code (or a derivative thereof) from\n *    the apps directory (application code) you must include an acknowledgement:\n *    \"This product includes software written by Tim Hudson (tjh@cryptsoft.com)\"\n *\n * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n * SUCH DAMAGE.\n *\n * The licence and distribution terms for any publically available version or\n * derivative of this code cannot be changed.  i.e. this code cannot simply be\n * copied and put under another distribution licence\n * [including the GNU Public Licence.]\n */\n\n#ifndef  HEADER_CONF_H\n# define HEADER_CONF_H\n\n# include <openssl/bio.h>\n# include <openssl/lhash.h>\n# include <openssl/stack.h>\n# include <openssl/safestack.h>\n# include <openssl/e_os2.h>\n\n# include <openssl/ossl_typ.h>\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\ntypedef struct {\n    char *section;\n    char *name;\n    char *value;\n} CONF_VALUE;\n\nDECLARE_STACK_OF(CONF_VALUE)\nDECLARE_LHASH_OF(CONF_VALUE);\n\nstruct conf_st;\nstruct conf_method_st;\ntypedef struct conf_method_st CONF_METHOD;\n\nstruct conf_method_st {\n    const char *name;\n    CONF *(*create) (CONF_METHOD *meth);\n    int (*init) (CONF *conf);\n    int (*destroy) (CONF *conf);\n    int (*destroy_data) (CONF *conf);\n    int (*load_bio) (CONF *conf, BIO *bp, long *eline);\n    int (*dump) (const CONF *conf, BIO *bp);\n    int (*is_number) (const CONF *conf, char c);\n    int (*to_int) (const CONF *conf, char c);\n    int (*load) (CONF *conf, const char *name, long *eline);\n};\n\n/* Module definitions */\n\ntypedef struct conf_imodule_st CONF_IMODULE;\ntypedef struct conf_module_st CONF_MODULE;\n\nDECLARE_STACK_OF(CONF_MODULE)\nDECLARE_STACK_OF(CONF_IMODULE)\n\n/* DSO module function typedefs */\ntypedef int conf_init_func (CONF_IMODULE *md, const CONF *cnf);\ntypedef void conf_finish_func (CONF_IMODULE *md);\n\n# define CONF_MFLAGS_IGNORE_ERRORS       0x1\n# define CONF_MFLAGS_IGNORE_RETURN_CODES 0x2\n# define CONF_MFLAGS_SILENT              0x4\n# define CONF_MFLAGS_NO_DSO              0x8\n# define CONF_MFLAGS_IGNORE_MISSING_FILE 0x10\n# define CONF_MFLAGS_DEFAULT_SECTION     0x20\n\nint CONF_set_default_method(CONF_METHOD *meth);\nvoid CONF_set_nconf(CONF *conf, LHASH_OF(CONF_VALUE) *hash);\nLHASH_OF(CONF_VALUE) *CONF_load(LHASH_OF(CONF_VALUE) *conf, const char *file,\n                                long *eline);\n# ifndef OPENSSL_NO_FP_API\nLHASH_OF(CONF_VALUE) *CONF_load_fp(LHASH_OF(CONF_VALUE) *conf, FILE *fp,\n                                   long *eline);\n# endif\nLHASH_OF(CONF_VALUE) *CONF_load_bio(LHASH_OF(CONF_VALUE) *conf, BIO *bp,\n                                    long *eline);\nSTACK_OF(CONF_VALUE) *CONF_get_section(LHASH_OF(CONF_VALUE) *conf,\n                                       const char *section);\nchar *CONF_get_string(LHASH_OF(CONF_VALUE) *conf, const char *group,\n                      const char *name);\nlong CONF_get_number(LHASH_OF(CONF_VALUE) *conf, const char *group,\n                     const char *name);\nvoid CONF_free(LHASH_OF(CONF_VALUE) *conf);\nint CONF_dump_fp(LHASH_OF(CONF_VALUE) *conf, FILE *out);\nint CONF_dump_bio(LHASH_OF(CONF_VALUE) *conf, BIO *out);\n\nvoid OPENSSL_config(const char *config_name);\nvoid OPENSSL_no_config(void);\n\n/*\n * New conf code.  The semantics are different from the functions above. If\n * that wasn't the case, the above functions would have been replaced\n */\n\nstruct conf_st {\n    CONF_METHOD *meth;\n    void *meth_data;\n    LHASH_OF(CONF_VALUE) *data;\n};\n\nCONF *NCONF_new(CONF_METHOD *meth);\nCONF_METHOD *NCONF_default(void);\nCONF_METHOD *NCONF_WIN32(void);\n# if 0                          /* Just to give you an idea of what I have in\n                                 * mind */\nCONF_METHOD *NCONF_XML(void);\n# endif\nvoid NCONF_free(CONF *conf);\nvoid NCONF_free_data(CONF *conf);\n\nint NCONF_load(CONF *conf, const char *file, long *eline);\n# ifndef OPENSSL_NO_FP_API\nint NCONF_load_fp(CONF *conf, FILE *fp, long *eline);\n# endif\nint NCONF_load_bio(CONF *conf, BIO *bp, long *eline);\nSTACK_OF(CONF_VALUE) *NCONF_get_section(const CONF *conf,\n                                        const char *section);\nchar *NCONF_get_string(const CONF *conf, const char *group, const char *name);\nint NCONF_get_number_e(const CONF *conf, const char *group, const char *name,\n                       long *result);\nint NCONF_dump_fp(const CONF *conf, FILE *out);\nint NCONF_dump_bio(const CONF *conf, BIO *out);\n\n# if 0                          /* The following function has no error\n                                 * checking, and should therefore be avoided */\nlong NCONF_get_number(CONF *conf, char *group, char *name);\n# else\n#  define NCONF_get_number(c,g,n,r) NCONF_get_number_e(c,g,n,r)\n# endif\n\n/* Module functions */\n\nint CONF_modules_load(const CONF *cnf, const char *appname,\n                      unsigned long flags);\nint CONF_modules_load_file(const char *filename, const char *appname,\n                           unsigned long flags);\nvoid CONF_modules_unload(int all);\nvoid CONF_modules_finish(void);\nvoid CONF_modules_free(void);\nint CONF_module_add(const char *name, conf_init_func *ifunc,\n                    conf_finish_func *ffunc);\n\nconst char *CONF_imodule_get_name(const CONF_IMODULE *md);\nconst char *CONF_imodule_get_value(const CONF_IMODULE *md);\nvoid *CONF_imodule_get_usr_data(const CONF_IMODULE *md);\nvoid CONF_imodule_set_usr_data(CONF_IMODULE *md, void *usr_data);\nCONF_MODULE *CONF_imodule_get_module(const CONF_IMODULE *md);\nunsigned long CONF_imodule_get_flags(const CONF_IMODULE *md);\nvoid CONF_imodule_set_flags(CONF_IMODULE *md, unsigned long flags);\nvoid *CONF_module_get_usr_data(CONF_MODULE *pmod);\nvoid CONF_module_set_usr_data(CONF_MODULE *pmod, void *usr_data);\n\nchar *CONF_get1_default_config_file(void);\n\nint CONF_parse_list(const char *list, int sep, int nospc,\n                    int (*list_cb) (const char *elem, int len, void *usr),\n                    void *arg);\n\nvoid OPENSSL_load_builtin_modules(void);\n\n/* BEGIN ERROR CODES */\n/*\n * The following lines are auto generated by the script mkerr.pl. Any changes\n * made after this point may be overwritten when the script is next run.\n */\nvoid ERR_load_CONF_strings(void);\n\n/* Error codes for the CONF functions. */\n\n/* Function codes. */\n# define CONF_F_CONF_DUMP_FP                              104\n# define CONF_F_CONF_LOAD                                 100\n# define CONF_F_CONF_LOAD_BIO                             102\n# define CONF_F_CONF_LOAD_FP                              103\n# define CONF_F_CONF_MODULES_LOAD                         116\n# define CONF_F_CONF_PARSE_LIST                           119\n# define CONF_F_DEF_LOAD                                  120\n# define CONF_F_DEF_LOAD_BIO                              121\n# define CONF_F_MODULE_INIT                               115\n# define CONF_F_MODULE_LOAD_DSO                           117\n# define CONF_F_MODULE_RUN                                118\n# define CONF_F_NCONF_DUMP_BIO                            105\n# define CONF_F_NCONF_DUMP_FP                             106\n# define CONF_F_NCONF_GET_NUMBER                          107\n# define CONF_F_NCONF_GET_NUMBER_E                        112\n# define CONF_F_NCONF_GET_SECTION                         108\n# define CONF_F_NCONF_GET_STRING                          109\n# define CONF_F_NCONF_LOAD                                113\n# define CONF_F_NCONF_LOAD_BIO                            110\n# define CONF_F_NCONF_LOAD_FP                             114\n# define CONF_F_NCONF_NEW                                 111\n# define CONF_F_STR_COPY                                  101\n\n/* Reason codes. */\n# define CONF_R_ERROR_LOADING_DSO                         110\n# define CONF_R_LIST_CANNOT_BE_NULL                       115\n# define CONF_R_MISSING_CLOSE_SQUARE_BRACKET              100\n# define CONF_R_MISSING_EQUAL_SIGN                        101\n# define CONF_R_MISSING_FINISH_FUNCTION                   111\n# define CONF_R_MISSING_INIT_FUNCTION                     112\n# define CONF_R_MODULE_INITIALIZATION_ERROR               109\n# define CONF_R_NO_CLOSE_BRACE                            102\n# define CONF_R_NO_CONF                                   105\n# define CONF_R_NO_CONF_OR_ENVIRONMENT_VARIABLE           106\n# define CONF_R_NO_SECTION                                107\n# define CONF_R_NO_SUCH_FILE                              114\n# define CONF_R_NO_VALUE                                  108\n# define CONF_R_UNABLE_TO_CREATE_NEW_SECTION              103\n# define CONF_R_UNKNOWN_MODULE_NAME                       113\n# define CONF_R_VARIABLE_HAS_NO_VALUE                     104\n\n#ifdef  __cplusplus\n}\n#endif\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/arm/include/openssl/conf_api.h",
    "content": "/* conf_api.h */\n/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)\n * All rights reserved.\n *\n * This package is an SSL implementation written\n * by Eric Young (eay@cryptsoft.com).\n * The implementation was written so as to conform with Netscapes SSL.\n *\n * This library is free for commercial and non-commercial use as long as\n * the following conditions are aheared to.  The following conditions\n * apply to all code found in this distribution, be it the RC4, RSA,\n * lhash, DES, etc., code; not just the SSL code.  The SSL documentation\n * included with this distribution is covered by the same copyright terms\n * except that the holder is Tim Hudson (tjh@cryptsoft.com).\n *\n * Copyright remains Eric Young's, and as such any Copyright notices in\n * the code are not to be removed.\n * If this package is used in a product, Eric Young should be given attribution\n * as the author of the parts of the library used.\n * This can be in the form of a textual message at program startup or\n * in documentation (online or textual) provided with the package.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the copyright\n *    notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in the\n *    documentation and/or other materials provided with the distribution.\n * 3. All advertising materials mentioning features or use of this software\n *    must display the following acknowledgement:\n *    \"This product includes cryptographic software written by\n *     Eric Young (eay@cryptsoft.com)\"\n *    The word 'cryptographic' can be left out if the rouines from the library\n *    being used are not cryptographic related :-).\n * 4. If you include any Windows specific code (or a derivative thereof) from\n *    the apps directory (application code) you must include an acknowledgement:\n *    \"This product includes software written by Tim Hudson (tjh@cryptsoft.com)\"\n *\n * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n * SUCH DAMAGE.\n *\n * The licence and distribution terms for any publically available version or\n * derivative of this code cannot be changed.  i.e. this code cannot simply be\n * copied and put under another distribution licence\n * [including the GNU Public Licence.]\n */\n\n#ifndef  HEADER_CONF_API_H\n# define HEADER_CONF_API_H\n\n# include <openssl/lhash.h>\n# include <openssl/conf.h>\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n/* Up until OpenSSL 0.9.5a, this was new_section */\nCONF_VALUE *_CONF_new_section(CONF *conf, const char *section);\n/* Up until OpenSSL 0.9.5a, this was get_section */\nCONF_VALUE *_CONF_get_section(const CONF *conf, const char *section);\n/* Up until OpenSSL 0.9.5a, this was CONF_get_section */\nSTACK_OF(CONF_VALUE) *_CONF_get_section_values(const CONF *conf,\n                                               const char *section);\n\nint _CONF_add_string(CONF *conf, CONF_VALUE *section, CONF_VALUE *value);\nchar *_CONF_get_string(const CONF *conf, const char *section,\n                       const char *name);\nlong _CONF_get_number(const CONF *conf, const char *section,\n                      const char *name);\n\nint _CONF_new_data(CONF *conf);\nvoid _CONF_free_data(CONF *conf);\n\n#ifdef  __cplusplus\n}\n#endif\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/arm/include/openssl/crypto.h",
    "content": "/* crypto/crypto.h */\n/* ====================================================================\n * Copyright (c) 1998-2006 The OpenSSL Project.  All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n *\n * 1. Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n *\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in\n *    the documentation and/or other materials provided with the\n *    distribution.\n *\n * 3. All advertising materials mentioning features or use of this\n *    software must display the following acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit. (http://www.openssl.org/)\"\n *\n * 4. The names \"OpenSSL Toolkit\" and \"OpenSSL Project\" must not be used to\n *    endorse or promote products derived from this software without\n *    prior written permission. For written permission, please contact\n *    openssl-core@openssl.org.\n *\n * 5. Products derived from this software may not be called \"OpenSSL\"\n *    nor may \"OpenSSL\" appear in their names without prior written\n *    permission of the OpenSSL Project.\n *\n * 6. Redistributions of any form whatsoever must retain the following\n *    acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit (http://www.openssl.org/)\"\n *\n * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY\n * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\n * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR\n * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\n * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,\n * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED\n * OF THE POSSIBILITY OF SUCH DAMAGE.\n * ====================================================================\n *\n * This product includes cryptographic software written by Eric Young\n * (eay@cryptsoft.com).  This product includes software written by Tim\n * Hudson (tjh@cryptsoft.com).\n *\n */\n/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)\n * All rights reserved.\n *\n * This package is an SSL implementation written\n * by Eric Young (eay@cryptsoft.com).\n * The implementation was written so as to conform with Netscapes SSL.\n *\n * This library is free for commercial and non-commercial use as long as\n * the following conditions are aheared to.  The following conditions\n * apply to all code found in this distribution, be it the RC4, RSA,\n * lhash, DES, etc., code; not just the SSL code.  The SSL documentation\n * included with this distribution is covered by the same copyright terms\n * except that the holder is Tim Hudson (tjh@cryptsoft.com).\n *\n * Copyright remains Eric Young's, and as such any Copyright notices in\n * the code are not to be removed.\n * If this package is used in a product, Eric Young should be given attribution\n * as the author of the parts of the library used.\n * This can be in the form of a textual message at program startup or\n * in documentation (online or textual) provided with the package.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the copyright\n *    notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in the\n *    documentation and/or other materials provided with the distribution.\n * 3. All advertising materials mentioning features or use of this software\n *    must display the following acknowledgement:\n *    \"This product includes cryptographic software written by\n *     Eric Young (eay@cryptsoft.com)\"\n *    The word 'cryptographic' can be left out if the rouines from the library\n *    being used are not cryptographic related :-).\n * 4. If you include any Windows specific code (or a derivative thereof) from\n *    the apps directory (application code) you must include an acknowledgement:\n *    \"This product includes software written by Tim Hudson (tjh@cryptsoft.com)\"\n *\n * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n * SUCH DAMAGE.\n *\n * The licence and distribution terms for any publically available version or\n * derivative of this code cannot be changed.  i.e. this code cannot simply be\n * copied and put under another distribution licence\n * [including the GNU Public Licence.]\n */\n/* ====================================================================\n * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED.\n * ECDH support in OpenSSL originally developed by\n * SUN MICROSYSTEMS, INC., and contributed to the OpenSSL project.\n */\n\n#ifndef HEADER_CRYPTO_H\n# define HEADER_CRYPTO_H\n\n# include <stdlib.h>\n\n# include <openssl/e_os2.h>\n\n# ifndef OPENSSL_NO_FP_API\n#  include <stdio.h>\n# endif\n\n# include <openssl/stack.h>\n# include <openssl/safestack.h>\n# include <openssl/opensslv.h>\n# include <openssl/ossl_typ.h>\n\n# ifdef CHARSET_EBCDIC\n#  include <openssl/ebcdic.h>\n# endif\n\n/*\n * Resolve problems on some operating systems with symbol names that clash\n * one way or another\n */\n# include <openssl/symhacks.h>\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n/* Backward compatibility to SSLeay */\n/*\n * This is more to be used to check the correct DLL is being used in the MS\n * world.\n */\n# define SSLEAY_VERSION_NUMBER   OPENSSL_VERSION_NUMBER\n# define SSLEAY_VERSION          0\n/* #define SSLEAY_OPTIONS       1 no longer supported */\n# define SSLEAY_CFLAGS           2\n# define SSLEAY_BUILT_ON         3\n# define SSLEAY_PLATFORM         4\n# define SSLEAY_DIR              5\n\n/* Already declared in ossl_typ.h */\n# if 0\ntypedef struct crypto_ex_data_st CRYPTO_EX_DATA;\n/* Called when a new object is created */\ntypedef int CRYPTO_EX_new (void *parent, void *ptr, CRYPTO_EX_DATA *ad,\n                           int idx, long argl, void *argp);\n/* Called when an object is free()ed */\ntypedef void CRYPTO_EX_free (void *parent, void *ptr, CRYPTO_EX_DATA *ad,\n                             int idx, long argl, void *argp);\n/* Called when we need to dup an object */\ntypedef int CRYPTO_EX_dup (CRYPTO_EX_DATA *to, CRYPTO_EX_DATA *from,\n                           void *from_d, int idx, long argl, void *argp);\n# endif\n\n/* A generic structure to pass assorted data in a expandable way */\ntypedef struct openssl_item_st {\n    int code;\n    void *value;                /* Not used for flag attributes */\n    size_t value_size;          /* Max size of value for output, length for\n                                 * input */\n    size_t *value_length;       /* Returned length of value for output */\n} OPENSSL_ITEM;\n\n/*\n * When changing the CRYPTO_LOCK_* list, be sure to maintin the text lock\n * names in cryptlib.c\n */\n\n# define CRYPTO_LOCK_ERR                 1\n# define CRYPTO_LOCK_EX_DATA             2\n# define CRYPTO_LOCK_X509                3\n# define CRYPTO_LOCK_X509_INFO           4\n# define CRYPTO_LOCK_X509_PKEY           5\n# define CRYPTO_LOCK_X509_CRL            6\n# define CRYPTO_LOCK_X509_REQ            7\n# define CRYPTO_LOCK_DSA                 8\n# define CRYPTO_LOCK_RSA                 9\n# define CRYPTO_LOCK_EVP_PKEY            10\n# define CRYPTO_LOCK_X509_STORE          11\n# define CRYPTO_LOCK_SSL_CTX             12\n# define CRYPTO_LOCK_SSL_CERT            13\n# define CRYPTO_LOCK_SSL_SESSION         14\n# define CRYPTO_LOCK_SSL_SESS_CERT       15\n# define CRYPTO_LOCK_SSL                 16\n# define CRYPTO_LOCK_SSL_METHOD          17\n# define CRYPTO_LOCK_RAND                18\n# define CRYPTO_LOCK_RAND2               19\n# define CRYPTO_LOCK_MALLOC              20\n# define CRYPTO_LOCK_BIO                 21\n# define CRYPTO_LOCK_GETHOSTBYNAME       22\n# define CRYPTO_LOCK_GETSERVBYNAME       23\n# define CRYPTO_LOCK_READDIR             24\n# define CRYPTO_LOCK_RSA_BLINDING        25\n# define CRYPTO_LOCK_DH                  26\n# define CRYPTO_LOCK_MALLOC2             27\n# define CRYPTO_LOCK_DSO                 28\n# define CRYPTO_LOCK_DYNLOCK             29\n# define CRYPTO_LOCK_ENGINE              30\n# define CRYPTO_LOCK_UI                  31\n# define CRYPTO_LOCK_ECDSA               32\n# define CRYPTO_LOCK_EC                  33\n# define CRYPTO_LOCK_ECDH                34\n# define CRYPTO_LOCK_BN                  35\n# define CRYPTO_LOCK_EC_PRE_COMP         36\n# define CRYPTO_LOCK_STORE               37\n# define CRYPTO_LOCK_COMP                38\n# define CRYPTO_LOCK_FIPS                39\n# define CRYPTO_LOCK_FIPS2               40\n# define CRYPTO_NUM_LOCKS                41\n\n# define CRYPTO_LOCK             1\n# define CRYPTO_UNLOCK           2\n# define CRYPTO_READ             4\n# define CRYPTO_WRITE            8\n\n# ifndef OPENSSL_NO_LOCKING\n#  ifndef CRYPTO_w_lock\n#   define CRYPTO_w_lock(type)     \\\n        CRYPTO_lock(CRYPTO_LOCK|CRYPTO_WRITE,type,__FILE__,__LINE__)\n#   define CRYPTO_w_unlock(type)   \\\n        CRYPTO_lock(CRYPTO_UNLOCK|CRYPTO_WRITE,type,__FILE__,__LINE__)\n#   define CRYPTO_r_lock(type)     \\\n        CRYPTO_lock(CRYPTO_LOCK|CRYPTO_READ,type,__FILE__,__LINE__)\n#   define CRYPTO_r_unlock(type)   \\\n        CRYPTO_lock(CRYPTO_UNLOCK|CRYPTO_READ,type,__FILE__,__LINE__)\n#   define CRYPTO_add(addr,amount,type)    \\\n        CRYPTO_add_lock(addr,amount,type,__FILE__,__LINE__)\n#  endif\n# else\n#  define CRYPTO_w_lock(a)\n#  define CRYPTO_w_unlock(a)\n#  define CRYPTO_r_lock(a)\n#  define CRYPTO_r_unlock(a)\n#  define CRYPTO_add(a,b,c)       ((*(a))+=(b))\n# endif\n\n/*\n * Some applications as well as some parts of OpenSSL need to allocate and\n * deallocate locks in a dynamic fashion.  The following typedef makes this\n * possible in a type-safe manner.\n */\n/* struct CRYPTO_dynlock_value has to be defined by the application. */\ntypedef struct {\n    int references;\n    struct CRYPTO_dynlock_value *data;\n} CRYPTO_dynlock;\n\n/*\n * The following can be used to detect memory leaks in the SSLeay library. It\n * used, it turns on malloc checking\n */\n\n# define CRYPTO_MEM_CHECK_OFF    0x0/* an enume */\n# define CRYPTO_MEM_CHECK_ON     0x1/* a bit */\n# define CRYPTO_MEM_CHECK_ENABLE 0x2/* a bit */\n# define CRYPTO_MEM_CHECK_DISABLE 0x3/* an enume */\n\n/*\n * The following are bit values to turn on or off options connected to the\n * malloc checking functionality\n */\n\n/* Adds time to the memory checking information */\n# define V_CRYPTO_MDEBUG_TIME    0x1/* a bit */\n/* Adds thread number to the memory checking information */\n# define V_CRYPTO_MDEBUG_THREAD  0x2/* a bit */\n\n# define V_CRYPTO_MDEBUG_ALL (V_CRYPTO_MDEBUG_TIME | V_CRYPTO_MDEBUG_THREAD)\n\n/* predec of the BIO type */\ntypedef struct bio_st BIO_dummy;\n\nstruct crypto_ex_data_st {\n    STACK_OF(void) *sk;\n    /* gcc is screwing up this data structure :-( */\n    int dummy;\n};\nDECLARE_STACK_OF(void)\n\n/*\n * This stuff is basically class callback functions The current classes are\n * SSL_CTX, SSL, SSL_SESSION, and a few more\n */\n\ntypedef struct crypto_ex_data_func_st {\n    long argl;                  /* Arbitary long */\n    void *argp;                 /* Arbitary void * */\n    CRYPTO_EX_new *new_func;\n    CRYPTO_EX_free *free_func;\n    CRYPTO_EX_dup *dup_func;\n} CRYPTO_EX_DATA_FUNCS;\n\nDECLARE_STACK_OF(CRYPTO_EX_DATA_FUNCS)\n\n/*\n * Per class, we have a STACK of CRYPTO_EX_DATA_FUNCS for each CRYPTO_EX_DATA\n * entry.\n */\n\n# define CRYPTO_EX_INDEX_BIO             0\n# define CRYPTO_EX_INDEX_SSL             1\n# define CRYPTO_EX_INDEX_SSL_CTX         2\n# define CRYPTO_EX_INDEX_SSL_SESSION     3\n# define CRYPTO_EX_INDEX_X509_STORE      4\n# define CRYPTO_EX_INDEX_X509_STORE_CTX  5\n# define CRYPTO_EX_INDEX_RSA             6\n# define CRYPTO_EX_INDEX_DSA             7\n# define CRYPTO_EX_INDEX_DH              8\n# define CRYPTO_EX_INDEX_ENGINE          9\n# define CRYPTO_EX_INDEX_X509            10\n# define CRYPTO_EX_INDEX_UI              11\n# define CRYPTO_EX_INDEX_ECDSA           12\n# define CRYPTO_EX_INDEX_ECDH            13\n# define CRYPTO_EX_INDEX_COMP            14\n# define CRYPTO_EX_INDEX_STORE           15\n\n/*\n * Dynamically assigned indexes start from this value (don't use directly,\n * use via CRYPTO_ex_data_new_class).\n */\n# define CRYPTO_EX_INDEX_USER            100\n\n/*\n * This is the default callbacks, but we can have others as well: this is\n * needed in Win32 where the application malloc and the library malloc may\n * not be the same.\n */\n# define CRYPTO_malloc_init()    CRYPTO_set_mem_functions(\\\n        malloc, realloc, free)\n\n# if defined CRYPTO_MDEBUG_ALL || defined CRYPTO_MDEBUG_TIME || defined CRYPTO_MDEBUG_THREAD\n#  ifndef CRYPTO_MDEBUG         /* avoid duplicate #define */\n#   define CRYPTO_MDEBUG\n#  endif\n# endif\n\n/*\n * Set standard debugging functions (not done by default unless CRYPTO_MDEBUG\n * is defined)\n */\n# define CRYPTO_malloc_debug_init()      do {\\\n        CRYPTO_set_mem_debug_functions(\\\n                CRYPTO_dbg_malloc,\\\n                CRYPTO_dbg_realloc,\\\n                CRYPTO_dbg_free,\\\n                CRYPTO_dbg_set_options,\\\n                CRYPTO_dbg_get_options);\\\n        } while(0)\n\nint CRYPTO_mem_ctrl(int mode);\nint CRYPTO_is_mem_check_on(void);\n\n/* for applications */\n# define MemCheck_start() CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON)\n# define MemCheck_stop() CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_OFF)\n\n/* for library-internal use */\n# define MemCheck_on()   CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ENABLE)\n# define MemCheck_off()  CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_DISABLE)\n# define is_MemCheck_on() CRYPTO_is_mem_check_on()\n\n# define OPENSSL_malloc(num)     CRYPTO_malloc((int)num,__FILE__,__LINE__)\n# define OPENSSL_strdup(str)     CRYPTO_strdup((str),__FILE__,__LINE__)\n# define OPENSSL_realloc(addr,num) \\\n        CRYPTO_realloc((char *)addr,(int)num,__FILE__,__LINE__)\n# define OPENSSL_realloc_clean(addr,old_num,num) \\\n        CRYPTO_realloc_clean(addr,old_num,num,__FILE__,__LINE__)\n# define OPENSSL_remalloc(addr,num) \\\n        CRYPTO_remalloc((char **)addr,(int)num,__FILE__,__LINE__)\n# define OPENSSL_freeFunc        CRYPTO_free\n# define OPENSSL_free(addr)      CRYPTO_free(addr)\n\n# define OPENSSL_malloc_locked(num) \\\n        CRYPTO_malloc_locked((int)num,__FILE__,__LINE__)\n# define OPENSSL_free_locked(addr) CRYPTO_free_locked(addr)\n\nconst char *SSLeay_version(int type);\nunsigned long SSLeay(void);\n\nint OPENSSL_issetugid(void);\n\n/* An opaque type representing an implementation of \"ex_data\" support */\ntypedef struct st_CRYPTO_EX_DATA_IMPL CRYPTO_EX_DATA_IMPL;\n/* Return an opaque pointer to the current \"ex_data\" implementation */\nconst CRYPTO_EX_DATA_IMPL *CRYPTO_get_ex_data_implementation(void);\n/* Sets the \"ex_data\" implementation to be used (if it's not too late) */\nint CRYPTO_set_ex_data_implementation(const CRYPTO_EX_DATA_IMPL *i);\n/* Get a new \"ex_data\" class, and return the corresponding \"class_index\" */\nint CRYPTO_ex_data_new_class(void);\n/* Within a given class, get/register a new index */\nint CRYPTO_get_ex_new_index(int class_index, long argl, void *argp,\n                            CRYPTO_EX_new *new_func, CRYPTO_EX_dup *dup_func,\n                            CRYPTO_EX_free *free_func);\n/*\n * Initialise/duplicate/free CRYPTO_EX_DATA variables corresponding to a\n * given class (invokes whatever per-class callbacks are applicable)\n */\nint CRYPTO_new_ex_data(int class_index, void *obj, CRYPTO_EX_DATA *ad);\nint CRYPTO_dup_ex_data(int class_index, CRYPTO_EX_DATA *to,\n                       CRYPTO_EX_DATA *from);\nvoid CRYPTO_free_ex_data(int class_index, void *obj, CRYPTO_EX_DATA *ad);\n/*\n * Get/set data in a CRYPTO_EX_DATA variable corresponding to a particular\n * index (relative to the class type involved)\n */\nint CRYPTO_set_ex_data(CRYPTO_EX_DATA *ad, int idx, void *val);\nvoid *CRYPTO_get_ex_data(const CRYPTO_EX_DATA *ad, int idx);\n/*\n * This function cleans up all \"ex_data\" state. It mustn't be called under\n * potential race-conditions.\n */\nvoid CRYPTO_cleanup_all_ex_data(void);\n\nint CRYPTO_get_new_lockid(char *name);\n\nint CRYPTO_num_locks(void);     /* return CRYPTO_NUM_LOCKS (shared libs!) */\nvoid CRYPTO_lock(int mode, int type, const char *file, int line);\nvoid CRYPTO_set_locking_callback(void (*func) (int mode, int type,\n                                               const char *file, int line));\nvoid (*CRYPTO_get_locking_callback(void)) (int mode, int type,\n                                           const char *file, int line);\nvoid CRYPTO_set_add_lock_callback(int (*func)\n                                   (int *num, int mount, int type,\n                                    const char *file, int line));\nint (*CRYPTO_get_add_lock_callback(void)) (int *num, int mount, int type,\n                                           const char *file, int line);\n\n/* Don't use this structure directly. */\ntypedef struct crypto_threadid_st {\n    void *ptr;\n    unsigned long val;\n} CRYPTO_THREADID;\n/* Only use CRYPTO_THREADID_set_[numeric|pointer]() within callbacks */\nvoid CRYPTO_THREADID_set_numeric(CRYPTO_THREADID *id, unsigned long val);\nvoid CRYPTO_THREADID_set_pointer(CRYPTO_THREADID *id, void *ptr);\nint CRYPTO_THREADID_set_callback(void (*threadid_func) (CRYPTO_THREADID *));\nvoid (*CRYPTO_THREADID_get_callback(void)) (CRYPTO_THREADID *);\nvoid CRYPTO_THREADID_current(CRYPTO_THREADID *id);\nint CRYPTO_THREADID_cmp(const CRYPTO_THREADID *a, const CRYPTO_THREADID *b);\nvoid CRYPTO_THREADID_cpy(CRYPTO_THREADID *dest, const CRYPTO_THREADID *src);\nunsigned long CRYPTO_THREADID_hash(const CRYPTO_THREADID *id);\n# ifndef OPENSSL_NO_DEPRECATED\nvoid CRYPTO_set_id_callback(unsigned long (*func) (void));\nunsigned long (*CRYPTO_get_id_callback(void)) (void);\nunsigned long CRYPTO_thread_id(void);\n# endif\n\nconst char *CRYPTO_get_lock_name(int type);\nint CRYPTO_add_lock(int *pointer, int amount, int type, const char *file,\n                    int line);\n\nint CRYPTO_get_new_dynlockid(void);\nvoid CRYPTO_destroy_dynlockid(int i);\nstruct CRYPTO_dynlock_value *CRYPTO_get_dynlock_value(int i);\nvoid CRYPTO_set_dynlock_create_callback(struct CRYPTO_dynlock_value\n                                        *(*dyn_create_function) (const char\n                                                                 *file,\n                                                                 int line));\nvoid CRYPTO_set_dynlock_lock_callback(void (*dyn_lock_function)\n                                       (int mode,\n                                        struct CRYPTO_dynlock_value *l,\n                                        const char *file, int line));\nvoid CRYPTO_set_dynlock_destroy_callback(void (*dyn_destroy_function)\n                                          (struct CRYPTO_dynlock_value *l,\n                                           const char *file, int line));\nstruct CRYPTO_dynlock_value\n*(*CRYPTO_get_dynlock_create_callback(void)) (const char *file, int line);\nvoid (*CRYPTO_get_dynlock_lock_callback(void)) (int mode,\n                                                struct CRYPTO_dynlock_value\n                                                *l, const char *file,\n                                                int line);\nvoid (*CRYPTO_get_dynlock_destroy_callback(void)) (struct CRYPTO_dynlock_value\n                                                   *l, const char *file,\n                                                   int line);\n\n/*\n * CRYPTO_set_mem_functions includes CRYPTO_set_locked_mem_functions -- call\n * the latter last if you need different functions\n */\nint CRYPTO_set_mem_functions(void *(*m) (size_t), void *(*r) (void *, size_t),\n                             void (*f) (void *));\nint CRYPTO_set_locked_mem_functions(void *(*m) (size_t),\n                                    void (*free_func) (void *));\nint CRYPTO_set_mem_ex_functions(void *(*m) (size_t, const char *, int),\n                                void *(*r) (void *, size_t, const char *,\n                                            int), void (*f) (void *));\nint CRYPTO_set_locked_mem_ex_functions(void *(*m) (size_t, const char *, int),\n                                       void (*free_func) (void *));\nint CRYPTO_set_mem_debug_functions(void (*m)\n                                    (void *, int, const char *, int, int),\n                                   void (*r) (void *, void *, int,\n                                              const char *, int, int),\n                                   void (*f) (void *, int), void (*so) (long),\n                                   long (*go) (void));\nvoid CRYPTO_get_mem_functions(void *(**m) (size_t),\n                              void *(**r) (void *, size_t),\n                              void (**f) (void *));\nvoid CRYPTO_get_locked_mem_functions(void *(**m) (size_t),\n                                     void (**f) (void *));\nvoid CRYPTO_get_mem_ex_functions(void *(**m) (size_t, const char *, int),\n                                 void *(**r) (void *, size_t, const char *,\n                                              int), void (**f) (void *));\nvoid CRYPTO_get_locked_mem_ex_functions(void\n                                        *(**m) (size_t, const char *, int),\n                                        void (**f) (void *));\nvoid CRYPTO_get_mem_debug_functions(void (**m)\n                                     (void *, int, const char *, int, int),\n                                    void (**r) (void *, void *, int,\n                                                const char *, int, int),\n                                    void (**f) (void *, int),\n                                    void (**so) (long), long (**go) (void));\n\nvoid *CRYPTO_malloc_locked(int num, const char *file, int line);\nvoid CRYPTO_free_locked(void *ptr);\nvoid *CRYPTO_malloc(int num, const char *file, int line);\nchar *CRYPTO_strdup(const char *str, const char *file, int line);\nvoid CRYPTO_free(void *ptr);\nvoid *CRYPTO_realloc(void *addr, int num, const char *file, int line);\nvoid *CRYPTO_realloc_clean(void *addr, int old_num, int num, const char *file,\n                           int line);\nvoid *CRYPTO_remalloc(void *addr, int num, const char *file, int line);\n\nvoid OPENSSL_cleanse(void *ptr, size_t len);\n\nvoid CRYPTO_set_mem_debug_options(long bits);\nlong CRYPTO_get_mem_debug_options(void);\n\n# define CRYPTO_push_info(info) \\\n        CRYPTO_push_info_(info, __FILE__, __LINE__);\nint CRYPTO_push_info_(const char *info, const char *file, int line);\nint CRYPTO_pop_info(void);\nint CRYPTO_remove_all_info(void);\n\n/*\n * Default debugging functions (enabled by CRYPTO_malloc_debug_init() macro;\n * used as default in CRYPTO_MDEBUG compilations):\n */\n/*-\n * The last argument has the following significance:\n *\n * 0:   called before the actual memory allocation has taken place\n * 1:   called after the actual memory allocation has taken place\n */\nvoid CRYPTO_dbg_malloc(void *addr, int num, const char *file, int line,\n                       int before_p);\nvoid CRYPTO_dbg_realloc(void *addr1, void *addr2, int num, const char *file,\n                        int line, int before_p);\nvoid CRYPTO_dbg_free(void *addr, int before_p);\n/*-\n * Tell the debugging code about options.  By default, the following values\n * apply:\n *\n * 0:                           Clear all options.\n * V_CRYPTO_MDEBUG_TIME (1):    Set the \"Show Time\" option.\n * V_CRYPTO_MDEBUG_THREAD (2):  Set the \"Show Thread Number\" option.\n * V_CRYPTO_MDEBUG_ALL (3):     1 + 2\n */\nvoid CRYPTO_dbg_set_options(long bits);\nlong CRYPTO_dbg_get_options(void);\n\n# ifndef OPENSSL_NO_FP_API\nvoid CRYPTO_mem_leaks_fp(FILE *);\n# endif\nvoid CRYPTO_mem_leaks(struct bio_st *bio);\n/* unsigned long order, char *file, int line, int num_bytes, char *addr */\ntypedef void *CRYPTO_MEM_LEAK_CB (unsigned long, const char *, int, int,\n                                  void *);\nvoid CRYPTO_mem_leaks_cb(CRYPTO_MEM_LEAK_CB *cb);\n\n/* die if we have to */\nvoid OpenSSLDie(const char *file, int line, const char *assertion);\n# define OPENSSL_assert(e)       (void)((e) ? 0 : (OpenSSLDie(__FILE__, __LINE__, #e),1))\n\nunsigned long *OPENSSL_ia32cap_loc(void);\n# define OPENSSL_ia32cap (*(OPENSSL_ia32cap_loc()))\nint OPENSSL_isservice(void);\n\nint FIPS_mode(void);\nint FIPS_mode_set(int r);\n\nvoid OPENSSL_init(void);\n\n# define fips_md_init(alg) fips_md_init_ctx(alg, alg)\n\n# ifdef OPENSSL_FIPS\n#  define fips_md_init_ctx(alg, cx) \\\n        int alg##_Init(cx##_CTX *c) \\\n        { \\\n        if (FIPS_mode()) OpenSSLDie(__FILE__, __LINE__, \\\n                \"Low level API call to digest \" #alg \" forbidden in FIPS mode!\"); \\\n        return private_##alg##_Init(c); \\\n        } \\\n        int private_##alg##_Init(cx##_CTX *c)\n\n#  define fips_cipher_abort(alg) \\\n        if (FIPS_mode()) OpenSSLDie(__FILE__, __LINE__, \\\n                \"Low level API call to cipher \" #alg \" forbidden in FIPS mode!\")\n\n# else\n#  define fips_md_init_ctx(alg, cx) \\\n        int alg##_Init(cx##_CTX *c)\n#  define fips_cipher_abort(alg) while(0)\n# endif\n\n/*\n * CRYPTO_memcmp returns zero iff the |len| bytes at |a| and |b| are equal.\n * It takes an amount of time dependent on |len|, but independent of the\n * contents of |a| and |b|. Unlike memcmp, it cannot be used to put elements\n * into a defined order as the return value when a != b is undefined, other\n * than to be non-zero.\n */\nint CRYPTO_memcmp(const volatile void *a, const volatile void *b, size_t len);\n\n/* BEGIN ERROR CODES */\n/*\n * The following lines are auto generated by the script mkerr.pl. Any changes\n * made after this point may be overwritten when the script is next run.\n */\nvoid ERR_load_CRYPTO_strings(void);\n\n/* Error codes for the CRYPTO functions. */\n\n/* Function codes. */\n# define CRYPTO_F_CRYPTO_GET_EX_NEW_INDEX                 100\n# define CRYPTO_F_CRYPTO_GET_NEW_DYNLOCKID                103\n# define CRYPTO_F_CRYPTO_GET_NEW_LOCKID                   101\n# define CRYPTO_F_CRYPTO_SET_EX_DATA                      102\n# define CRYPTO_F_DEF_ADD_INDEX                           104\n# define CRYPTO_F_DEF_GET_CLASS                           105\n# define CRYPTO_F_FIPS_MODE_SET                           109\n# define CRYPTO_F_INT_DUP_EX_DATA                         106\n# define CRYPTO_F_INT_FREE_EX_DATA                        107\n# define CRYPTO_F_INT_NEW_EX_DATA                         108\n\n/* Reason codes. */\n# define CRYPTO_R_FIPS_MODE_NOT_SUPPORTED                 101\n# define CRYPTO_R_NO_DYNLOCK_CREATE_CALLBACK              100\n\n#ifdef  __cplusplus\n}\n#endif\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/arm/include/openssl/des.h",
    "content": "/* crypto/des/des.h */\n/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)\n * All rights reserved.\n *\n * This package is an SSL implementation written\n * by Eric Young (eay@cryptsoft.com).\n * The implementation was written so as to conform with Netscapes SSL.\n *\n * This library is free for commercial and non-commercial use as long as\n * the following conditions are aheared to.  The following conditions\n * apply to all code found in this distribution, be it the RC4, RSA,\n * lhash, DES, etc., code; not just the SSL code.  The SSL documentation\n * included with this distribution is covered by the same copyright terms\n * except that the holder is Tim Hudson (tjh@cryptsoft.com).\n *\n * Copyright remains Eric Young's, and as such any Copyright notices in\n * the code are not to be removed.\n * If this package is used in a product, Eric Young should be given attribution\n * as the author of the parts of the library used.\n * This can be in the form of a textual message at program startup or\n * in documentation (online or textual) provided with the package.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the copyright\n *    notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in the\n *    documentation and/or other materials provided with the distribution.\n * 3. All advertising materials mentioning features or use of this software\n *    must display the following acknowledgement:\n *    \"This product includes cryptographic software written by\n *     Eric Young (eay@cryptsoft.com)\"\n *    The word 'cryptographic' can be left out if the rouines from the library\n *    being used are not cryptographic related :-).\n * 4. If you include any Windows specific code (or a derivative thereof) from\n *    the apps directory (application code) you must include an acknowledgement:\n *    \"This product includes software written by Tim Hudson (tjh@cryptsoft.com)\"\n *\n * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n * SUCH DAMAGE.\n *\n * The licence and distribution terms for any publically available version or\n * derivative of this code cannot be changed.  i.e. this code cannot simply be\n * copied and put under another distribution licence\n * [including the GNU Public Licence.]\n */\n\n#ifndef HEADER_NEW_DES_H\n# define HEADER_NEW_DES_H\n\n# include <openssl/e_os2.h>     /* OPENSSL_EXTERN, OPENSSL_NO_DES, DES_LONG\n                                 * (via openssl/opensslconf.h */\n\n# ifdef OPENSSL_NO_DES\n#  error DES is disabled.\n# endif\n\n# ifdef OPENSSL_BUILD_SHLIBCRYPTO\n#  undef OPENSSL_EXTERN\n#  define OPENSSL_EXTERN OPENSSL_EXPORT\n# endif\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\ntypedef unsigned char DES_cblock[8];\ntypedef /* const */ unsigned char const_DES_cblock[8];\n/*\n * With \"const\", gcc 2.8.1 on Solaris thinks that DES_cblock * and\n * const_DES_cblock * are incompatible pointer types.\n */\n\ntypedef struct DES_ks {\n    union {\n        DES_cblock cblock;\n        /*\n         * make sure things are correct size on machines with 8 byte longs\n         */\n        DES_LONG deslong[2];\n    } ks[16];\n} DES_key_schedule;\n\n# ifndef OPENSSL_DISABLE_OLD_DES_SUPPORT\n#  ifndef OPENSSL_ENABLE_OLD_DES_SUPPORT\n#   define OPENSSL_ENABLE_OLD_DES_SUPPORT\n#  endif\n# endif\n\n# ifdef OPENSSL_ENABLE_OLD_DES_SUPPORT\n#  include <openssl/des_old.h>\n# endif\n\n# define DES_KEY_SZ      (sizeof(DES_cblock))\n# define DES_SCHEDULE_SZ (sizeof(DES_key_schedule))\n\n# define DES_ENCRYPT     1\n# define DES_DECRYPT     0\n\n# define DES_CBC_MODE    0\n# define DES_PCBC_MODE   1\n\n# define DES_ecb2_encrypt(i,o,k1,k2,e) \\\n        DES_ecb3_encrypt((i),(o),(k1),(k2),(k1),(e))\n\n# define DES_ede2_cbc_encrypt(i,o,l,k1,k2,iv,e) \\\n        DES_ede3_cbc_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(e))\n\n# define DES_ede2_cfb64_encrypt(i,o,l,k1,k2,iv,n,e) \\\n        DES_ede3_cfb64_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(n),(e))\n\n# define DES_ede2_ofb64_encrypt(i,o,l,k1,k2,iv,n) \\\n        DES_ede3_ofb64_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(n))\n\nOPENSSL_DECLARE_GLOBAL(int, DES_check_key); /* defaults to false */\n# define DES_check_key OPENSSL_GLOBAL_REF(DES_check_key)\nOPENSSL_DECLARE_GLOBAL(int, DES_rw_mode); /* defaults to DES_PCBC_MODE */\n# define DES_rw_mode OPENSSL_GLOBAL_REF(DES_rw_mode)\n\nconst char *DES_options(void);\nvoid DES_ecb3_encrypt(const_DES_cblock *input, DES_cblock *output,\n                      DES_key_schedule *ks1, DES_key_schedule *ks2,\n                      DES_key_schedule *ks3, int enc);\nDES_LONG DES_cbc_cksum(const unsigned char *input, DES_cblock *output,\n                       long length, DES_key_schedule *schedule,\n                       const_DES_cblock *ivec);\n/* DES_cbc_encrypt does not update the IV!  Use DES_ncbc_encrypt instead. */\nvoid DES_cbc_encrypt(const unsigned char *input, unsigned char *output,\n                     long length, DES_key_schedule *schedule,\n                     DES_cblock *ivec, int enc);\nvoid DES_ncbc_encrypt(const unsigned char *input, unsigned char *output,\n                      long length, DES_key_schedule *schedule,\n                      DES_cblock *ivec, int enc);\nvoid DES_xcbc_encrypt(const unsigned char *input, unsigned char *output,\n                      long length, DES_key_schedule *schedule,\n                      DES_cblock *ivec, const_DES_cblock *inw,\n                      const_DES_cblock *outw, int enc);\nvoid DES_cfb_encrypt(const unsigned char *in, unsigned char *out, int numbits,\n                     long length, DES_key_schedule *schedule,\n                     DES_cblock *ivec, int enc);\nvoid DES_ecb_encrypt(const_DES_cblock *input, DES_cblock *output,\n                     DES_key_schedule *ks, int enc);\n\n/*\n * This is the DES encryption function that gets called by just about every\n * other DES routine in the library.  You should not use this function except\n * to implement 'modes' of DES.  I say this because the functions that call\n * this routine do the conversion from 'char *' to long, and this needs to be\n * done to make sure 'non-aligned' memory access do not occur.  The\n * characters are loaded 'little endian'. Data is a pointer to 2 unsigned\n * long's and ks is the DES_key_schedule to use.  enc, is non zero specifies\n * encryption, zero if decryption.\n */\nvoid DES_encrypt1(DES_LONG *data, DES_key_schedule *ks, int enc);\n\n/*\n * This functions is the same as DES_encrypt1() except that the DES initial\n * permutation (IP) and final permutation (FP) have been left out.  As for\n * DES_encrypt1(), you should not use this function. It is used by the\n * routines in the library that implement triple DES. IP() DES_encrypt2()\n * DES_encrypt2() DES_encrypt2() FP() is the same as DES_encrypt1()\n * DES_encrypt1() DES_encrypt1() except faster :-).\n */\nvoid DES_encrypt2(DES_LONG *data, DES_key_schedule *ks, int enc);\n\nvoid DES_encrypt3(DES_LONG *data, DES_key_schedule *ks1,\n                  DES_key_schedule *ks2, DES_key_schedule *ks3);\nvoid DES_decrypt3(DES_LONG *data, DES_key_schedule *ks1,\n                  DES_key_schedule *ks2, DES_key_schedule *ks3);\nvoid DES_ede3_cbc_encrypt(const unsigned char *input, unsigned char *output,\n                          long length,\n                          DES_key_schedule *ks1, DES_key_schedule *ks2,\n                          DES_key_schedule *ks3, DES_cblock *ivec, int enc);\nvoid DES_ede3_cbcm_encrypt(const unsigned char *in, unsigned char *out,\n                           long length,\n                           DES_key_schedule *ks1, DES_key_schedule *ks2,\n                           DES_key_schedule *ks3,\n                           DES_cblock *ivec1, DES_cblock *ivec2, int enc);\nvoid DES_ede3_cfb64_encrypt(const unsigned char *in, unsigned char *out,\n                            long length, DES_key_schedule *ks1,\n                            DES_key_schedule *ks2, DES_key_schedule *ks3,\n                            DES_cblock *ivec, int *num, int enc);\nvoid DES_ede3_cfb_encrypt(const unsigned char *in, unsigned char *out,\n                          int numbits, long length, DES_key_schedule *ks1,\n                          DES_key_schedule *ks2, DES_key_schedule *ks3,\n                          DES_cblock *ivec, int enc);\nvoid DES_ede3_ofb64_encrypt(const unsigned char *in, unsigned char *out,\n                            long length, DES_key_schedule *ks1,\n                            DES_key_schedule *ks2, DES_key_schedule *ks3,\n                            DES_cblock *ivec, int *num);\n# if 0\nvoid DES_xwhite_in2out(const_DES_cblock *DES_key, const_DES_cblock *in_white,\n                       DES_cblock *out_white);\n# endif\n\nint DES_enc_read(int fd, void *buf, int len, DES_key_schedule *sched,\n                 DES_cblock *iv);\nint DES_enc_write(int fd, const void *buf, int len, DES_key_schedule *sched,\n                  DES_cblock *iv);\nchar *DES_fcrypt(const char *buf, const char *salt, char *ret);\nchar *DES_crypt(const char *buf, const char *salt);\nvoid DES_ofb_encrypt(const unsigned char *in, unsigned char *out, int numbits,\n                     long length, DES_key_schedule *schedule,\n                     DES_cblock *ivec);\nvoid DES_pcbc_encrypt(const unsigned char *input, unsigned char *output,\n                      long length, DES_key_schedule *schedule,\n                      DES_cblock *ivec, int enc);\nDES_LONG DES_quad_cksum(const unsigned char *input, DES_cblock output[],\n                        long length, int out_count, DES_cblock *seed);\nint DES_random_key(DES_cblock *ret);\nvoid DES_set_odd_parity(DES_cblock *key);\nint DES_check_key_parity(const_DES_cblock *key);\nint DES_is_weak_key(const_DES_cblock *key);\n/*\n * DES_set_key (= set_key = DES_key_sched = key_sched) calls\n * DES_set_key_checked if global variable DES_check_key is set,\n * DES_set_key_unchecked otherwise.\n */\nint DES_set_key(const_DES_cblock *key, DES_key_schedule *schedule);\nint DES_key_sched(const_DES_cblock *key, DES_key_schedule *schedule);\nint DES_set_key_checked(const_DES_cblock *key, DES_key_schedule *schedule);\nvoid DES_set_key_unchecked(const_DES_cblock *key, DES_key_schedule *schedule);\n# ifdef OPENSSL_FIPS\nvoid private_DES_set_key_unchecked(const_DES_cblock *key,\n                                   DES_key_schedule *schedule);\n# endif\nvoid DES_string_to_key(const char *str, DES_cblock *key);\nvoid DES_string_to_2keys(const char *str, DES_cblock *key1, DES_cblock *key2);\nvoid DES_cfb64_encrypt(const unsigned char *in, unsigned char *out,\n                       long length, DES_key_schedule *schedule,\n                       DES_cblock *ivec, int *num, int enc);\nvoid DES_ofb64_encrypt(const unsigned char *in, unsigned char *out,\n                       long length, DES_key_schedule *schedule,\n                       DES_cblock *ivec, int *num);\n\nint DES_read_password(DES_cblock *key, const char *prompt, int verify);\nint DES_read_2passwords(DES_cblock *key1, DES_cblock *key2,\n                        const char *prompt, int verify);\n\n# define DES_fixup_key_parity DES_set_odd_parity\n\n#ifdef  __cplusplus\n}\n#endif\n\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/arm/include/openssl/des_old.h",
    "content": "/* crypto/des/des_old.h */\n\n/*-\n * WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING\n *\n * The function names in here are deprecated and are only present to\n * provide an interface compatible with openssl 0.9.6 and older as\n * well as libdes.  OpenSSL now provides functions where \"des_\" has\n * been replaced with \"DES_\" in the names, to make it possible to\n * make incompatible changes that are needed for C type security and\n * other stuff.\n *\n * This include files has two compatibility modes:\n *\n *   - If OPENSSL_DES_LIBDES_COMPATIBILITY is defined, you get an API\n *     that is compatible with libdes and SSLeay.\n *   - If OPENSSL_DES_LIBDES_COMPATIBILITY isn't defined, you get an\n *     API that is compatible with OpenSSL 0.9.5x to 0.9.6x.\n *\n * Note that these modes break earlier snapshots of OpenSSL, where\n * libdes compatibility was the only available mode or (later on) the\n * prefered compatibility mode.  However, after much consideration\n * (and more or less violent discussions with external parties), it\n * was concluded that OpenSSL should be compatible with earlier versions\n * of itself before anything else.  Also, in all honesty, libdes is\n * an old beast that shouldn't really be used any more.\n *\n * Please consider starting to use the DES_ functions rather than the\n * des_ ones.  The des_ functions will disappear completely before\n * OpenSSL 1.0!\n *\n * WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING\n */\n\n/*\n * Written by Richard Levitte (richard@levitte.org) for the OpenSSL project\n * 2001.\n */\n/* ====================================================================\n * Copyright (c) 1998-2002 The OpenSSL Project.  All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n *\n * 1. Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n *\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in\n *    the documentation and/or other materials provided with the\n *    distribution.\n *\n * 3. All advertising materials mentioning features or use of this\n *    software must display the following acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit. (http://www.openssl.org/)\"\n *\n * 4. The names \"OpenSSL Toolkit\" and \"OpenSSL Project\" must not be used to\n *    endorse or promote products derived from this software without\n *    prior written permission. For written permission, please contact\n *    openssl-core@openssl.org.\n *\n * 5. Products derived from this software may not be called \"OpenSSL\"\n *    nor may \"OpenSSL\" appear in their names without prior written\n *    permission of the OpenSSL Project.\n *\n * 6. Redistributions of any form whatsoever must retain the following\n *    acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit (http://www.openssl.org/)\"\n *\n * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY\n * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\n * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR\n * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\n * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,\n * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED\n * OF THE POSSIBILITY OF SUCH DAMAGE.\n * ====================================================================\n *\n * This product includes cryptographic software written by Eric Young\n * (eay@cryptsoft.com).  This product includes software written by Tim\n * Hudson (tjh@cryptsoft.com).\n *\n */\n\n#ifndef HEADER_DES_H\n# define HEADER_DES_H\n\n# include <openssl/e_os2.h>     /* OPENSSL_EXTERN, OPENSSL_NO_DES, DES_LONG */\n\n# ifdef OPENSSL_NO_DES\n#  error DES is disabled.\n# endif\n\n# ifndef HEADER_NEW_DES_H\n#  error You must include des.h, not des_old.h directly.\n# endif\n\n# ifdef _KERBEROS_DES_H\n#  error <openssl/des_old.h> replaces <kerberos/des.h>.\n# endif\n\n# include <openssl/symhacks.h>\n\n# ifdef OPENSSL_BUILD_SHLIBCRYPTO\n#  undef OPENSSL_EXTERN\n#  define OPENSSL_EXTERN OPENSSL_EXPORT\n# endif\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n# ifdef _\n#  undef _\n# endif\n\ntypedef unsigned char _ossl_old_des_cblock[8];\ntypedef struct _ossl_old_des_ks_struct {\n    union {\n        _ossl_old_des_cblock _;\n        /*\n         * make sure things are correct size on machines with 8 byte longs\n         */\n        DES_LONG pad[2];\n    } ks;\n} _ossl_old_des_key_schedule[16];\n\n# ifndef OPENSSL_DES_LIBDES_COMPATIBILITY\n#  define des_cblock DES_cblock\n#  define const_des_cblock const_DES_cblock\n#  define des_key_schedule DES_key_schedule\n#  define des_ecb3_encrypt(i,o,k1,k2,k3,e)\\\n        DES_ecb3_encrypt((i),(o),&(k1),&(k2),&(k3),(e))\n#  define des_ede3_cbc_encrypt(i,o,l,k1,k2,k3,iv,e)\\\n        DES_ede3_cbc_encrypt((i),(o),(l),&(k1),&(k2),&(k3),(iv),(e))\n#  define des_ede3_cbcm_encrypt(i,o,l,k1,k2,k3,iv1,iv2,e)\\\n        DES_ede3_cbcm_encrypt((i),(o),(l),&(k1),&(k2),&(k3),(iv1),(iv2),(e))\n#  define des_ede3_cfb64_encrypt(i,o,l,k1,k2,k3,iv,n,e)\\\n        DES_ede3_cfb64_encrypt((i),(o),(l),&(k1),&(k2),&(k3),(iv),(n),(e))\n#  define des_ede3_ofb64_encrypt(i,o,l,k1,k2,k3,iv,n)\\\n        DES_ede3_ofb64_encrypt((i),(o),(l),&(k1),&(k2),&(k3),(iv),(n))\n#  define des_options()\\\n        DES_options()\n#  define des_cbc_cksum(i,o,l,k,iv)\\\n        DES_cbc_cksum((i),(o),(l),&(k),(iv))\n#  define des_cbc_encrypt(i,o,l,k,iv,e)\\\n        DES_cbc_encrypt((i),(o),(l),&(k),(iv),(e))\n#  define des_ncbc_encrypt(i,o,l,k,iv,e)\\\n        DES_ncbc_encrypt((i),(o),(l),&(k),(iv),(e))\n#  define des_xcbc_encrypt(i,o,l,k,iv,inw,outw,e)\\\n        DES_xcbc_encrypt((i),(o),(l),&(k),(iv),(inw),(outw),(e))\n#  define des_cfb_encrypt(i,o,n,l,k,iv,e)\\\n        DES_cfb_encrypt((i),(o),(n),(l),&(k),(iv),(e))\n#  define des_ecb_encrypt(i,o,k,e)\\\n        DES_ecb_encrypt((i),(o),&(k),(e))\n#  define des_encrypt1(d,k,e)\\\n        DES_encrypt1((d),&(k),(e))\n#  define des_encrypt2(d,k,e)\\\n        DES_encrypt2((d),&(k),(e))\n#  define des_encrypt3(d,k1,k2,k3)\\\n        DES_encrypt3((d),&(k1),&(k2),&(k3))\n#  define des_decrypt3(d,k1,k2,k3)\\\n        DES_decrypt3((d),&(k1),&(k2),&(k3))\n#  define des_xwhite_in2out(k,i,o)\\\n        DES_xwhite_in2out((k),(i),(o))\n#  define des_enc_read(f,b,l,k,iv)\\\n        DES_enc_read((f),(b),(l),&(k),(iv))\n#  define des_enc_write(f,b,l,k,iv)\\\n        DES_enc_write((f),(b),(l),&(k),(iv))\n#  define des_fcrypt(b,s,r)\\\n        DES_fcrypt((b),(s),(r))\n#  if 0\n#   define des_crypt(b,s)\\\n        DES_crypt((b),(s))\n#   if !defined(PERL5) && !defined(__FreeBSD__) && !defined(NeXT) && !defined(__OpenBSD__)\n#    define crypt(b,s)\\\n        DES_crypt((b),(s))\n#   endif\n#  endif\n#  define des_ofb_encrypt(i,o,n,l,k,iv)\\\n        DES_ofb_encrypt((i),(o),(n),(l),&(k),(iv))\n#  define des_pcbc_encrypt(i,o,l,k,iv,e)\\\n        DES_pcbc_encrypt((i),(o),(l),&(k),(iv),(e))\n#  define des_quad_cksum(i,o,l,c,s)\\\n        DES_quad_cksum((i),(o),(l),(c),(s))\n#  define des_random_seed(k)\\\n        _ossl_096_des_random_seed((k))\n#  define des_random_key(r)\\\n        DES_random_key((r))\n#  define des_read_password(k,p,v) \\\n        DES_read_password((k),(p),(v))\n#  define des_read_2passwords(k1,k2,p,v) \\\n        DES_read_2passwords((k1),(k2),(p),(v))\n#  define des_set_odd_parity(k)\\\n        DES_set_odd_parity((k))\n#  define des_check_key_parity(k)\\\n        DES_check_key_parity((k))\n#  define des_is_weak_key(k)\\\n        DES_is_weak_key((k))\n#  define des_set_key(k,ks)\\\n        DES_set_key((k),&(ks))\n#  define des_key_sched(k,ks)\\\n        DES_key_sched((k),&(ks))\n#  define des_set_key_checked(k,ks)\\\n        DES_set_key_checked((k),&(ks))\n#  define des_set_key_unchecked(k,ks)\\\n        DES_set_key_unchecked((k),&(ks))\n#  define des_string_to_key(s,k)\\\n        DES_string_to_key((s),(k))\n#  define des_string_to_2keys(s,k1,k2)\\\n        DES_string_to_2keys((s),(k1),(k2))\n#  define des_cfb64_encrypt(i,o,l,ks,iv,n,e)\\\n        DES_cfb64_encrypt((i),(o),(l),&(ks),(iv),(n),(e))\n#  define des_ofb64_encrypt(i,o,l,ks,iv,n)\\\n        DES_ofb64_encrypt((i),(o),(l),&(ks),(iv),(n))\n\n#  define des_ecb2_encrypt(i,o,k1,k2,e) \\\n        des_ecb3_encrypt((i),(o),(k1),(k2),(k1),(e))\n\n#  define des_ede2_cbc_encrypt(i,o,l,k1,k2,iv,e) \\\n        des_ede3_cbc_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(e))\n\n#  define des_ede2_cfb64_encrypt(i,o,l,k1,k2,iv,n,e) \\\n        des_ede3_cfb64_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(n),(e))\n\n#  define des_ede2_ofb64_encrypt(i,o,l,k1,k2,iv,n) \\\n        des_ede3_ofb64_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(n))\n\n#  define des_check_key DES_check_key\n#  define des_rw_mode DES_rw_mode\n# else                          /* libdes compatibility */\n/*\n * Map all symbol names to _ossl_old_des_* form, so we avoid all clashes with\n * libdes\n */\n#  define des_cblock _ossl_old_des_cblock\n#  define des_key_schedule _ossl_old_des_key_schedule\n#  define des_ecb3_encrypt(i,o,k1,k2,k3,e)\\\n        _ossl_old_des_ecb3_encrypt((i),(o),(k1),(k2),(k3),(e))\n#  define des_ede3_cbc_encrypt(i,o,l,k1,k2,k3,iv,e)\\\n        _ossl_old_des_ede3_cbc_encrypt((i),(o),(l),(k1),(k2),(k3),(iv),(e))\n#  define des_ede3_cfb64_encrypt(i,o,l,k1,k2,k3,iv,n,e)\\\n        _ossl_old_des_ede3_cfb64_encrypt((i),(o),(l),(k1),(k2),(k3),(iv),(n),(e))\n#  define des_ede3_ofb64_encrypt(i,o,l,k1,k2,k3,iv,n)\\\n        _ossl_old_des_ede3_ofb64_encrypt((i),(o),(l),(k1),(k2),(k3),(iv),(n))\n#  define des_options()\\\n        _ossl_old_des_options()\n#  define des_cbc_cksum(i,o,l,k,iv)\\\n        _ossl_old_des_cbc_cksum((i),(o),(l),(k),(iv))\n#  define des_cbc_encrypt(i,o,l,k,iv,e)\\\n        _ossl_old_des_cbc_encrypt((i),(o),(l),(k),(iv),(e))\n#  define des_ncbc_encrypt(i,o,l,k,iv,e)\\\n        _ossl_old_des_ncbc_encrypt((i),(o),(l),(k),(iv),(e))\n#  define des_xcbc_encrypt(i,o,l,k,iv,inw,outw,e)\\\n        _ossl_old_des_xcbc_encrypt((i),(o),(l),(k),(iv),(inw),(outw),(e))\n#  define des_cfb_encrypt(i,o,n,l,k,iv,e)\\\n        _ossl_old_des_cfb_encrypt((i),(o),(n),(l),(k),(iv),(e))\n#  define des_ecb_encrypt(i,o,k,e)\\\n        _ossl_old_des_ecb_encrypt((i),(o),(k),(e))\n#  define des_encrypt(d,k,e)\\\n        _ossl_old_des_encrypt((d),(k),(e))\n#  define des_encrypt2(d,k,e)\\\n        _ossl_old_des_encrypt2((d),(k),(e))\n#  define des_encrypt3(d,k1,k2,k3)\\\n        _ossl_old_des_encrypt3((d),(k1),(k2),(k3))\n#  define des_decrypt3(d,k1,k2,k3)\\\n        _ossl_old_des_decrypt3((d),(k1),(k2),(k3))\n#  define des_xwhite_in2out(k,i,o)\\\n        _ossl_old_des_xwhite_in2out((k),(i),(o))\n#  define des_enc_read(f,b,l,k,iv)\\\n        _ossl_old_des_enc_read((f),(b),(l),(k),(iv))\n#  define des_enc_write(f,b,l,k,iv)\\\n        _ossl_old_des_enc_write((f),(b),(l),(k),(iv))\n#  define des_fcrypt(b,s,r)\\\n        _ossl_old_des_fcrypt((b),(s),(r))\n#  define des_crypt(b,s)\\\n        _ossl_old_des_crypt((b),(s))\n#  if 0\n#   define crypt(b,s)\\\n        _ossl_old_crypt((b),(s))\n#  endif\n#  define des_ofb_encrypt(i,o,n,l,k,iv)\\\n        _ossl_old_des_ofb_encrypt((i),(o),(n),(l),(k),(iv))\n#  define des_pcbc_encrypt(i,o,l,k,iv,e)\\\n        _ossl_old_des_pcbc_encrypt((i),(o),(l),(k),(iv),(e))\n#  define des_quad_cksum(i,o,l,c,s)\\\n        _ossl_old_des_quad_cksum((i),(o),(l),(c),(s))\n#  define des_random_seed(k)\\\n        _ossl_old_des_random_seed((k))\n#  define des_random_key(r)\\\n        _ossl_old_des_random_key((r))\n#  define des_read_password(k,p,v) \\\n        _ossl_old_des_read_password((k),(p),(v))\n#  define des_read_2passwords(k1,k2,p,v) \\\n        _ossl_old_des_read_2passwords((k1),(k2),(p),(v))\n#  define des_set_odd_parity(k)\\\n        _ossl_old_des_set_odd_parity((k))\n#  define des_is_weak_key(k)\\\n        _ossl_old_des_is_weak_key((k))\n#  define des_set_key(k,ks)\\\n        _ossl_old_des_set_key((k),(ks))\n#  define des_key_sched(k,ks)\\\n        _ossl_old_des_key_sched((k),(ks))\n#  define des_string_to_key(s,k)\\\n        _ossl_old_des_string_to_key((s),(k))\n#  define des_string_to_2keys(s,k1,k2)\\\n        _ossl_old_des_string_to_2keys((s),(k1),(k2))\n#  define des_cfb64_encrypt(i,o,l,ks,iv,n,e)\\\n        _ossl_old_des_cfb64_encrypt((i),(o),(l),(ks),(iv),(n),(e))\n#  define des_ofb64_encrypt(i,o,l,ks,iv,n)\\\n        _ossl_old_des_ofb64_encrypt((i),(o),(l),(ks),(iv),(n))\n\n#  define des_ecb2_encrypt(i,o,k1,k2,e) \\\n        des_ecb3_encrypt((i),(o),(k1),(k2),(k1),(e))\n\n#  define des_ede2_cbc_encrypt(i,o,l,k1,k2,iv,e) \\\n        des_ede3_cbc_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(e))\n\n#  define des_ede2_cfb64_encrypt(i,o,l,k1,k2,iv,n,e) \\\n        des_ede3_cfb64_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(n),(e))\n\n#  define des_ede2_ofb64_encrypt(i,o,l,k1,k2,iv,n) \\\n        des_ede3_ofb64_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(n))\n\n#  define des_check_key DES_check_key\n#  define des_rw_mode DES_rw_mode\n# endif\n\nconst char *_ossl_old_des_options(void);\nvoid _ossl_old_des_ecb3_encrypt(_ossl_old_des_cblock *input,\n                                _ossl_old_des_cblock *output,\n                                _ossl_old_des_key_schedule ks1,\n                                _ossl_old_des_key_schedule ks2,\n                                _ossl_old_des_key_schedule ks3, int enc);\nDES_LONG _ossl_old_des_cbc_cksum(_ossl_old_des_cblock *input,\n                                 _ossl_old_des_cblock *output, long length,\n                                 _ossl_old_des_key_schedule schedule,\n                                 _ossl_old_des_cblock *ivec);\nvoid _ossl_old_des_cbc_encrypt(_ossl_old_des_cblock *input,\n                               _ossl_old_des_cblock *output, long length,\n                               _ossl_old_des_key_schedule schedule,\n                               _ossl_old_des_cblock *ivec, int enc);\nvoid _ossl_old_des_ncbc_encrypt(_ossl_old_des_cblock *input,\n                                _ossl_old_des_cblock *output, long length,\n                                _ossl_old_des_key_schedule schedule,\n                                _ossl_old_des_cblock *ivec, int enc);\nvoid _ossl_old_des_xcbc_encrypt(_ossl_old_des_cblock *input,\n                                _ossl_old_des_cblock *output, long length,\n                                _ossl_old_des_key_schedule schedule,\n                                _ossl_old_des_cblock *ivec,\n                                _ossl_old_des_cblock *inw,\n                                _ossl_old_des_cblock *outw, int enc);\nvoid _ossl_old_des_cfb_encrypt(unsigned char *in, unsigned char *out,\n                               int numbits, long length,\n                               _ossl_old_des_key_schedule schedule,\n                               _ossl_old_des_cblock *ivec, int enc);\nvoid _ossl_old_des_ecb_encrypt(_ossl_old_des_cblock *input,\n                               _ossl_old_des_cblock *output,\n                               _ossl_old_des_key_schedule ks, int enc);\nvoid _ossl_old_des_encrypt(DES_LONG *data, _ossl_old_des_key_schedule ks,\n                           int enc);\nvoid _ossl_old_des_encrypt2(DES_LONG *data, _ossl_old_des_key_schedule ks,\n                            int enc);\nvoid _ossl_old_des_encrypt3(DES_LONG *data, _ossl_old_des_key_schedule ks1,\n                            _ossl_old_des_key_schedule ks2,\n                            _ossl_old_des_key_schedule ks3);\nvoid _ossl_old_des_decrypt3(DES_LONG *data, _ossl_old_des_key_schedule ks1,\n                            _ossl_old_des_key_schedule ks2,\n                            _ossl_old_des_key_schedule ks3);\nvoid _ossl_old_des_ede3_cbc_encrypt(_ossl_old_des_cblock *input,\n                                    _ossl_old_des_cblock *output, long length,\n                                    _ossl_old_des_key_schedule ks1,\n                                    _ossl_old_des_key_schedule ks2,\n                                    _ossl_old_des_key_schedule ks3,\n                                    _ossl_old_des_cblock *ivec, int enc);\nvoid _ossl_old_des_ede3_cfb64_encrypt(unsigned char *in, unsigned char *out,\n                                      long length,\n                                      _ossl_old_des_key_schedule ks1,\n                                      _ossl_old_des_key_schedule ks2,\n                                      _ossl_old_des_key_schedule ks3,\n                                      _ossl_old_des_cblock *ivec, int *num,\n                                      int enc);\nvoid _ossl_old_des_ede3_ofb64_encrypt(unsigned char *in, unsigned char *out,\n                                      long length,\n                                      _ossl_old_des_key_schedule ks1,\n                                      _ossl_old_des_key_schedule ks2,\n                                      _ossl_old_des_key_schedule ks3,\n                                      _ossl_old_des_cblock *ivec, int *num);\n# if 0\nvoid _ossl_old_des_xwhite_in2out(_ossl_old_des_cblock (*des_key),\n                                 _ossl_old_des_cblock (*in_white),\n                                 _ossl_old_des_cblock (*out_white));\n# endif\n\nint _ossl_old_des_enc_read(int fd, char *buf, int len,\n                           _ossl_old_des_key_schedule sched,\n                           _ossl_old_des_cblock *iv);\nint _ossl_old_des_enc_write(int fd, char *buf, int len,\n                            _ossl_old_des_key_schedule sched,\n                            _ossl_old_des_cblock *iv);\nchar *_ossl_old_des_fcrypt(const char *buf, const char *salt, char *ret);\nchar *_ossl_old_des_crypt(const char *buf, const char *salt);\n# if !defined(PERL5) && !defined(NeXT)\nchar *_ossl_old_crypt(const char *buf, const char *salt);\n# endif\nvoid _ossl_old_des_ofb_encrypt(unsigned char *in, unsigned char *out,\n                               int numbits, long length,\n                               _ossl_old_des_key_schedule schedule,\n                               _ossl_old_des_cblock *ivec);\nvoid _ossl_old_des_pcbc_encrypt(_ossl_old_des_cblock *input,\n                                _ossl_old_des_cblock *output, long length,\n                                _ossl_old_des_key_schedule schedule,\n                                _ossl_old_des_cblock *ivec, int enc);\nDES_LONG _ossl_old_des_quad_cksum(_ossl_old_des_cblock *input,\n                                  _ossl_old_des_cblock *output, long length,\n                                  int out_count, _ossl_old_des_cblock *seed);\nvoid _ossl_old_des_random_seed(_ossl_old_des_cblock key);\nvoid _ossl_old_des_random_key(_ossl_old_des_cblock ret);\nint _ossl_old_des_read_password(_ossl_old_des_cblock *key, const char *prompt,\n                                int verify);\nint _ossl_old_des_read_2passwords(_ossl_old_des_cblock *key1,\n                                  _ossl_old_des_cblock *key2,\n                                  const char *prompt, int verify);\nvoid _ossl_old_des_set_odd_parity(_ossl_old_des_cblock *key);\nint _ossl_old_des_is_weak_key(_ossl_old_des_cblock *key);\nint _ossl_old_des_set_key(_ossl_old_des_cblock *key,\n                          _ossl_old_des_key_schedule schedule);\nint _ossl_old_des_key_sched(_ossl_old_des_cblock *key,\n                            _ossl_old_des_key_schedule schedule);\nvoid _ossl_old_des_string_to_key(char *str, _ossl_old_des_cblock *key);\nvoid _ossl_old_des_string_to_2keys(char *str, _ossl_old_des_cblock *key1,\n                                   _ossl_old_des_cblock *key2);\nvoid _ossl_old_des_cfb64_encrypt(unsigned char *in, unsigned char *out,\n                                 long length,\n                                 _ossl_old_des_key_schedule schedule,\n                                 _ossl_old_des_cblock *ivec, int *num,\n                                 int enc);\nvoid _ossl_old_des_ofb64_encrypt(unsigned char *in, unsigned char *out,\n                                 long length,\n                                 _ossl_old_des_key_schedule schedule,\n                                 _ossl_old_des_cblock *ivec, int *num);\n\nvoid _ossl_096_des_random_seed(des_cblock *key);\n\n/*\n * The following definitions provide compatibility with the MIT Kerberos\n * library. The _ossl_old_des_key_schedule structure is not binary\n * compatible.\n */\n\n# define _KERBEROS_DES_H\n\n# define KRBDES_ENCRYPT DES_ENCRYPT\n# define KRBDES_DECRYPT DES_DECRYPT\n\n# ifdef KERBEROS\n#  define ENCRYPT DES_ENCRYPT\n#  define DECRYPT DES_DECRYPT\n# endif\n\n# ifndef NCOMPAT\n#  define C_Block des_cblock\n#  define Key_schedule des_key_schedule\n#  define KEY_SZ DES_KEY_SZ\n#  define string_to_key des_string_to_key\n#  define read_pw_string des_read_pw_string\n#  define random_key des_random_key\n#  define pcbc_encrypt des_pcbc_encrypt\n#  define set_key des_set_key\n#  define key_sched des_key_sched\n#  define ecb_encrypt des_ecb_encrypt\n#  define cbc_encrypt des_cbc_encrypt\n#  define ncbc_encrypt des_ncbc_encrypt\n#  define xcbc_encrypt des_xcbc_encrypt\n#  define cbc_cksum des_cbc_cksum\n#  define quad_cksum des_quad_cksum\n#  define check_parity des_check_key_parity\n# endif\n\n# define des_fixup_key_parity DES_fixup_key_parity\n\n#ifdef  __cplusplus\n}\n#endif\n\n/* for DES_read_pw_string et al */\n# include <openssl/ui_compat.h>\n\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/arm/include/openssl/dh.h",
    "content": "/* crypto/dh/dh.h */\n/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)\n * All rights reserved.\n *\n * This package is an SSL implementation written\n * by Eric Young (eay@cryptsoft.com).\n * The implementation was written so as to conform with Netscapes SSL.\n *\n * This library is free for commercial and non-commercial use as long as\n * the following conditions are aheared to.  The following conditions\n * apply to all code found in this distribution, be it the RC4, RSA,\n * lhash, DES, etc., code; not just the SSL code.  The SSL documentation\n * included with this distribution is covered by the same copyright terms\n * except that the holder is Tim Hudson (tjh@cryptsoft.com).\n *\n * Copyright remains Eric Young's, and as such any Copyright notices in\n * the code are not to be removed.\n * If this package is used in a product, Eric Young should be given attribution\n * as the author of the parts of the library used.\n * This can be in the form of a textual message at program startup or\n * in documentation (online or textual) provided with the package.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the copyright\n *    notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in the\n *    documentation and/or other materials provided with the distribution.\n * 3. All advertising materials mentioning features or use of this software\n *    must display the following acknowledgement:\n *    \"This product includes cryptographic software written by\n *     Eric Young (eay@cryptsoft.com)\"\n *    The word 'cryptographic' can be left out if the rouines from the library\n *    being used are not cryptographic related :-).\n * 4. If you include any Windows specific code (or a derivative thereof) from\n *    the apps directory (application code) you must include an acknowledgement:\n *    \"This product includes software written by Tim Hudson (tjh@cryptsoft.com)\"\n *\n * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n * SUCH DAMAGE.\n *\n * The licence and distribution terms for any publically available version or\n * derivative of this code cannot be changed.  i.e. this code cannot simply be\n * copied and put under another distribution licence\n * [including the GNU Public Licence.]\n */\n\n#ifndef HEADER_DH_H\n# define HEADER_DH_H\n\n# include <openssl/e_os2.h>\n\n# ifdef OPENSSL_NO_DH\n#  error DH is disabled.\n# endif\n\n# ifndef OPENSSL_NO_BIO\n#  include <openssl/bio.h>\n# endif\n# include <openssl/ossl_typ.h>\n# ifndef OPENSSL_NO_DEPRECATED\n#  include <openssl/bn.h>\n# endif\n\n# ifndef OPENSSL_DH_MAX_MODULUS_BITS\n#  define OPENSSL_DH_MAX_MODULUS_BITS    10000\n# endif\n\n# define DH_FLAG_CACHE_MONT_P     0x01\n\n/*\n * new with 0.9.7h; the built-in DH\n * implementation now uses constant time\n * modular exponentiation for secret exponents\n * by default. This flag causes the\n * faster variable sliding window method to\n * be used for all exponents.\n */\n# define DH_FLAG_NO_EXP_CONSTTIME 0x02\n\n/*\n * If this flag is set the DH method is FIPS compliant and can be used in\n * FIPS mode. This is set in the validated module method. If an application\n * sets this flag in its own methods it is its reposibility to ensure the\n * result is compliant.\n */\n\n# define DH_FLAG_FIPS_METHOD                     0x0400\n\n/*\n * If this flag is set the operations normally disabled in FIPS mode are\n * permitted it is then the applications responsibility to ensure that the\n * usage is compliant.\n */\n\n# define DH_FLAG_NON_FIPS_ALLOW                  0x0400\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n/* Already defined in ossl_typ.h */\n/* typedef struct dh_st DH; */\n/* typedef struct dh_method DH_METHOD; */\n\nstruct dh_method {\n    const char *name;\n    /* Methods here */\n    int (*generate_key) (DH *dh);\n    int (*compute_key) (unsigned char *key, const BIGNUM *pub_key, DH *dh);\n    /* Can be null */\n    int (*bn_mod_exp) (const DH *dh, BIGNUM *r, const BIGNUM *a,\n                       const BIGNUM *p, const BIGNUM *m, BN_CTX *ctx,\n                       BN_MONT_CTX *m_ctx);\n    int (*init) (DH *dh);\n    int (*finish) (DH *dh);\n    int flags;\n    char *app_data;\n    /* If this is non-NULL, it will be used to generate parameters */\n    int (*generate_params) (DH *dh, int prime_len, int generator,\n                            BN_GENCB *cb);\n};\n\nstruct dh_st {\n    /*\n     * This first argument is used to pick up errors when a DH is passed\n     * instead of a EVP_PKEY\n     */\n    int pad;\n    int version;\n    BIGNUM *p;\n    BIGNUM *g;\n    long length;                /* optional */\n    BIGNUM *pub_key;            /* g^x % p */\n    BIGNUM *priv_key;           /* x */\n    int flags;\n    BN_MONT_CTX *method_mont_p;\n    /* Place holders if we want to do X9.42 DH */\n    BIGNUM *q;\n    BIGNUM *j;\n    unsigned char *seed;\n    int seedlen;\n    BIGNUM *counter;\n    int references;\n    CRYPTO_EX_DATA ex_data;\n    const DH_METHOD *meth;\n    ENGINE *engine;\n};\n\n# define DH_GENERATOR_2          2\n/* #define DH_GENERATOR_3       3 */\n# define DH_GENERATOR_5          5\n\n/* DH_check error codes */\n# define DH_CHECK_P_NOT_PRIME            0x01\n# define DH_CHECK_P_NOT_SAFE_PRIME       0x02\n# define DH_UNABLE_TO_CHECK_GENERATOR    0x04\n# define DH_NOT_SUITABLE_GENERATOR       0x08\n# define DH_CHECK_Q_NOT_PRIME            0x10\n# define DH_CHECK_INVALID_Q_VALUE        0x20\n# define DH_CHECK_INVALID_J_VALUE        0x40\n\n/* DH_check_pub_key error codes */\n# define DH_CHECK_PUBKEY_TOO_SMALL       0x01\n# define DH_CHECK_PUBKEY_TOO_LARGE       0x02\n# define DH_CHECK_PUBKEY_INVALID         0x04\n\n/*\n * primes p where (p-1)/2 is prime too are called \"safe\"; we define this for\n * backward compatibility:\n */\n# define DH_CHECK_P_NOT_STRONG_PRIME     DH_CHECK_P_NOT_SAFE_PRIME\n\n# define d2i_DHparams_fp(fp,x) (DH *)ASN1_d2i_fp((char *(*)())DH_new, \\\n                (char *(*)())d2i_DHparams,(fp),(unsigned char **)(x))\n# define i2d_DHparams_fp(fp,x) ASN1_i2d_fp(i2d_DHparams,(fp), \\\n                (unsigned char *)(x))\n# define d2i_DHparams_bio(bp,x) ASN1_d2i_bio_of(DH,DH_new,d2i_DHparams,bp,x)\n# define i2d_DHparams_bio(bp,x) ASN1_i2d_bio_of_const(DH,i2d_DHparams,bp,x)\n\nDH *DHparams_dup(DH *);\n\nconst DH_METHOD *DH_OpenSSL(void);\n\nvoid DH_set_default_method(const DH_METHOD *meth);\nconst DH_METHOD *DH_get_default_method(void);\nint DH_set_method(DH *dh, const DH_METHOD *meth);\nDH *DH_new_method(ENGINE *engine);\n\nDH *DH_new(void);\nvoid DH_free(DH *dh);\nint DH_up_ref(DH *dh);\nint DH_size(const DH *dh);\nint DH_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func,\n                        CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func);\nint DH_set_ex_data(DH *d, int idx, void *arg);\nvoid *DH_get_ex_data(DH *d, int idx);\n\n/* Deprecated version */\n# ifndef OPENSSL_NO_DEPRECATED\nDH *DH_generate_parameters(int prime_len, int generator,\n                           void (*callback) (int, int, void *), void *cb_arg);\n# endif                         /* !defined(OPENSSL_NO_DEPRECATED) */\n\n/* New version */\nint DH_generate_parameters_ex(DH *dh, int prime_len, int generator,\n                              BN_GENCB *cb);\n\nint DH_check(const DH *dh, int *codes);\nint DH_check_pub_key(const DH *dh, const BIGNUM *pub_key, int *codes);\nint DH_generate_key(DH *dh);\nint DH_compute_key(unsigned char *key, const BIGNUM *pub_key, DH *dh);\nint DH_compute_key_padded(unsigned char *key, const BIGNUM *pub_key, DH *dh);\nDH *d2i_DHparams(DH **a, const unsigned char **pp, long length);\nint i2d_DHparams(const DH *a, unsigned char **pp);\nDH *d2i_DHxparams(DH **a, const unsigned char **pp, long length);\nint i2d_DHxparams(const DH *a, unsigned char **pp);\n# ifndef OPENSSL_NO_FP_API\nint DHparams_print_fp(FILE *fp, const DH *x);\n# endif\n# ifndef OPENSSL_NO_BIO\nint DHparams_print(BIO *bp, const DH *x);\n# else\nint DHparams_print(char *bp, const DH *x);\n# endif\n\n/* RFC 5114 parameters */\nDH *DH_get_1024_160(void);\nDH *DH_get_2048_224(void);\nDH *DH_get_2048_256(void);\n\n/* RFC2631 KDF */\nint DH_KDF_X9_42(unsigned char *out, size_t outlen,\n                 const unsigned char *Z, size_t Zlen,\n                 ASN1_OBJECT *key_oid,\n                 const unsigned char *ukm, size_t ukmlen, const EVP_MD *md);\n\n# define EVP_PKEY_CTX_set_dh_paramgen_prime_len(ctx, len) \\\n        EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DH, EVP_PKEY_OP_PARAMGEN, \\\n                        EVP_PKEY_CTRL_DH_PARAMGEN_PRIME_LEN, len, NULL)\n\n# define EVP_PKEY_CTX_set_dh_paramgen_subprime_len(ctx, len) \\\n        EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DH, EVP_PKEY_OP_PARAMGEN, \\\n                        EVP_PKEY_CTRL_DH_PARAMGEN_SUBPRIME_LEN, len, NULL)\n\n# define EVP_PKEY_CTX_set_dh_paramgen_type(ctx, typ) \\\n        EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DH, EVP_PKEY_OP_PARAMGEN, \\\n                        EVP_PKEY_CTRL_DH_PARAMGEN_TYPE, typ, NULL)\n\n# define EVP_PKEY_CTX_set_dh_paramgen_generator(ctx, gen) \\\n        EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DH, EVP_PKEY_OP_PARAMGEN, \\\n                        EVP_PKEY_CTRL_DH_PARAMGEN_GENERATOR, gen, NULL)\n\n# define EVP_PKEY_CTX_set_dh_rfc5114(ctx, gen) \\\n        EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DHX, EVP_PKEY_OP_PARAMGEN, \\\n                        EVP_PKEY_CTRL_DH_RFC5114, gen, NULL)\n\n# define EVP_PKEY_CTX_set_dhx_rfc5114(ctx, gen) \\\n        EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DHX, EVP_PKEY_OP_PARAMGEN, \\\n                        EVP_PKEY_CTRL_DH_RFC5114, gen, NULL)\n\n# define EVP_PKEY_CTX_set_dh_kdf_type(ctx, kdf) \\\n        EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DHX, \\\n                                EVP_PKEY_OP_DERIVE, \\\n                                EVP_PKEY_CTRL_DH_KDF_TYPE, kdf, NULL)\n\n# define EVP_PKEY_CTX_get_dh_kdf_type(ctx) \\\n        EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DHX, \\\n                                EVP_PKEY_OP_DERIVE, \\\n                                EVP_PKEY_CTRL_DH_KDF_TYPE, -2, NULL)\n\n# define EVP_PKEY_CTX_set0_dh_kdf_oid(ctx, oid) \\\n        EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DHX, \\\n                                EVP_PKEY_OP_DERIVE, \\\n                                EVP_PKEY_CTRL_DH_KDF_OID, 0, (void *)oid)\n\n# define EVP_PKEY_CTX_get0_dh_kdf_oid(ctx, poid) \\\n        EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DHX, \\\n                                EVP_PKEY_OP_DERIVE, \\\n                                EVP_PKEY_CTRL_GET_DH_KDF_OID, 0, (void *)poid)\n\n# define EVP_PKEY_CTX_set_dh_kdf_md(ctx, md) \\\n        EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DHX, \\\n                                EVP_PKEY_OP_DERIVE, \\\n                                EVP_PKEY_CTRL_DH_KDF_MD, 0, (void *)md)\n\n# define EVP_PKEY_CTX_get_dh_kdf_md(ctx, pmd) \\\n        EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DHX, \\\n                                EVP_PKEY_OP_DERIVE, \\\n                                EVP_PKEY_CTRL_GET_DH_KDF_MD, 0, (void *)pmd)\n\n# define EVP_PKEY_CTX_set_dh_kdf_outlen(ctx, len) \\\n        EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DHX, \\\n                                EVP_PKEY_OP_DERIVE, \\\n                                EVP_PKEY_CTRL_DH_KDF_OUTLEN, len, NULL)\n\n# define EVP_PKEY_CTX_get_dh_kdf_outlen(ctx, plen) \\\n        EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DHX, \\\n                                EVP_PKEY_OP_DERIVE, \\\n                        EVP_PKEY_CTRL_GET_DH_KDF_OUTLEN, 0, (void *)plen)\n\n# define EVP_PKEY_CTX_set0_dh_kdf_ukm(ctx, p, plen) \\\n        EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DHX, \\\n                                EVP_PKEY_OP_DERIVE, \\\n                                EVP_PKEY_CTRL_DH_KDF_UKM, plen, (void *)p)\n\n# define EVP_PKEY_CTX_get0_dh_kdf_ukm(ctx, p) \\\n        EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DHX, \\\n                                EVP_PKEY_OP_DERIVE, \\\n                                EVP_PKEY_CTRL_GET_DH_KDF_UKM, 0, (void *)p)\n\n# define EVP_PKEY_CTRL_DH_PARAMGEN_PRIME_LEN     (EVP_PKEY_ALG_CTRL + 1)\n# define EVP_PKEY_CTRL_DH_PARAMGEN_GENERATOR     (EVP_PKEY_ALG_CTRL + 2)\n# define EVP_PKEY_CTRL_DH_RFC5114                (EVP_PKEY_ALG_CTRL + 3)\n# define EVP_PKEY_CTRL_DH_PARAMGEN_SUBPRIME_LEN  (EVP_PKEY_ALG_CTRL + 4)\n# define EVP_PKEY_CTRL_DH_PARAMGEN_TYPE          (EVP_PKEY_ALG_CTRL + 5)\n# define EVP_PKEY_CTRL_DH_KDF_TYPE               (EVP_PKEY_ALG_CTRL + 6)\n# define EVP_PKEY_CTRL_DH_KDF_MD                 (EVP_PKEY_ALG_CTRL + 7)\n# define EVP_PKEY_CTRL_GET_DH_KDF_MD             (EVP_PKEY_ALG_CTRL + 8)\n# define EVP_PKEY_CTRL_DH_KDF_OUTLEN             (EVP_PKEY_ALG_CTRL + 9)\n# define EVP_PKEY_CTRL_GET_DH_KDF_OUTLEN         (EVP_PKEY_ALG_CTRL + 10)\n# define EVP_PKEY_CTRL_DH_KDF_UKM                (EVP_PKEY_ALG_CTRL + 11)\n# define EVP_PKEY_CTRL_GET_DH_KDF_UKM            (EVP_PKEY_ALG_CTRL + 12)\n# define EVP_PKEY_CTRL_DH_KDF_OID                (EVP_PKEY_ALG_CTRL + 13)\n# define EVP_PKEY_CTRL_GET_DH_KDF_OID            (EVP_PKEY_ALG_CTRL + 14)\n\n/* KDF types */\n# define EVP_PKEY_DH_KDF_NONE                            1\n# define EVP_PKEY_DH_KDF_X9_42                           2\n\n/* BEGIN ERROR CODES */\n/*\n * The following lines are auto generated by the script mkerr.pl. Any changes\n * made after this point may be overwritten when the script is next run.\n */\nvoid ERR_load_DH_strings(void);\n\n/* Error codes for the DH functions. */\n\n/* Function codes. */\n# define DH_F_COMPUTE_KEY                                 102\n# define DH_F_DHPARAMS_PRINT_FP                           101\n# define DH_F_DH_BUILTIN_GENPARAMS                        106\n# define DH_F_DH_CMS_DECRYPT                              117\n# define DH_F_DH_CMS_SET_PEERKEY                          118\n# define DH_F_DH_CMS_SET_SHARED_INFO                      119\n# define DH_F_DH_COMPUTE_KEY                              114\n# define DH_F_DH_GENERATE_KEY                             115\n# define DH_F_DH_GENERATE_PARAMETERS_EX                   116\n# define DH_F_DH_NEW_METHOD                               105\n# define DH_F_DH_PARAM_DECODE                             107\n# define DH_F_DH_PRIV_DECODE                              110\n# define DH_F_DH_PRIV_ENCODE                              111\n# define DH_F_DH_PUB_DECODE                               108\n# define DH_F_DH_PUB_ENCODE                               109\n# define DH_F_DO_DH_PRINT                                 100\n# define DH_F_GENERATE_KEY                                103\n# define DH_F_GENERATE_PARAMETERS                         104\n# define DH_F_PKEY_DH_DERIVE                              112\n# define DH_F_PKEY_DH_KEYGEN                              113\n\n/* Reason codes. */\n# define DH_R_BAD_GENERATOR                               101\n# define DH_R_BN_DECODE_ERROR                             109\n# define DH_R_BN_ERROR                                    106\n# define DH_R_DECODE_ERROR                                104\n# define DH_R_INVALID_PUBKEY                              102\n# define DH_R_KDF_PARAMETER_ERROR                         112\n# define DH_R_KEYS_NOT_SET                                108\n# define DH_R_KEY_SIZE_TOO_SMALL                          110\n# define DH_R_MODULUS_TOO_LARGE                           103\n# define DH_R_NON_FIPS_METHOD                             111\n# define DH_R_NO_PARAMETERS_SET                           107\n# define DH_R_NO_PRIVATE_VALUE                            100\n# define DH_R_PARAMETER_ENCODING_ERROR                    105\n# define DH_R_PEER_KEY_ERROR                              113\n# define DH_R_SHARED_INFO_ERROR                           114\n\n#ifdef  __cplusplus\n}\n#endif\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/arm/include/openssl/dsa.h",
    "content": "/* crypto/dsa/dsa.h */\n/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)\n * All rights reserved.\n *\n * This package is an SSL implementation written\n * by Eric Young (eay@cryptsoft.com).\n * The implementation was written so as to conform with Netscapes SSL.\n *\n * This library is free for commercial and non-commercial use as long as\n * the following conditions are aheared to.  The following conditions\n * apply to all code found in this distribution, be it the RC4, RSA,\n * lhash, DES, etc., code; not just the SSL code.  The SSL documentation\n * included with this distribution is covered by the same copyright terms\n * except that the holder is Tim Hudson (tjh@cryptsoft.com).\n *\n * Copyright remains Eric Young's, and as such any Copyright notices in\n * the code are not to be removed.\n * If this package is used in a product, Eric Young should be given attribution\n * as the author of the parts of the library used.\n * This can be in the form of a textual message at program startup or\n * in documentation (online or textual) provided with the package.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the copyright\n *    notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in the\n *    documentation and/or other materials provided with the distribution.\n * 3. All advertising materials mentioning features or use of this software\n *    must display the following acknowledgement:\n *    \"This product includes cryptographic software written by\n *     Eric Young (eay@cryptsoft.com)\"\n *    The word 'cryptographic' can be left out if the rouines from the library\n *    being used are not cryptographic related :-).\n * 4. If you include any Windows specific code (or a derivative thereof) from\n *    the apps directory (application code) you must include an acknowledgement:\n *    \"This product includes software written by Tim Hudson (tjh@cryptsoft.com)\"\n *\n * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n * SUCH DAMAGE.\n *\n * The licence and distribution terms for any publically available version or\n * derivative of this code cannot be changed.  i.e. this code cannot simply be\n * copied and put under another distribution licence\n * [including the GNU Public Licence.]\n */\n\n/*\n * The DSS routines are based on patches supplied by\n * Steven Schoch <schoch@sheba.arc.nasa.gov>.  He basically did the\n * work and I have just tweaked them a little to fit into my\n * stylistic vision for SSLeay :-) */\n\n#ifndef HEADER_DSA_H\n# define HEADER_DSA_H\n\n# include <openssl/e_os2.h>\n\n# ifdef OPENSSL_NO_DSA\n#  error DSA is disabled.\n# endif\n\n# ifndef OPENSSL_NO_BIO\n#  include <openssl/bio.h>\n# endif\n# include <openssl/crypto.h>\n# include <openssl/ossl_typ.h>\n\n# ifndef OPENSSL_NO_DEPRECATED\n#  include <openssl/bn.h>\n#  ifndef OPENSSL_NO_DH\n#   include <openssl/dh.h>\n#  endif\n# endif\n\n# ifndef OPENSSL_DSA_MAX_MODULUS_BITS\n#  define OPENSSL_DSA_MAX_MODULUS_BITS   10000\n# endif\n\n# define DSA_FLAG_CACHE_MONT_P   0x01\n/*\n * new with 0.9.7h; the built-in DSA implementation now uses constant time\n * modular exponentiation for secret exponents by default. This flag causes\n * the faster variable sliding window method to be used for all exponents.\n */\n# define DSA_FLAG_NO_EXP_CONSTTIME       0x02\n\n/*\n * If this flag is set the DSA method is FIPS compliant and can be used in\n * FIPS mode. This is set in the validated module method. If an application\n * sets this flag in its own methods it is its reposibility to ensure the\n * result is compliant.\n */\n\n# define DSA_FLAG_FIPS_METHOD                    0x0400\n\n/*\n * If this flag is set the operations normally disabled in FIPS mode are\n * permitted it is then the applications responsibility to ensure that the\n * usage is compliant.\n */\n\n# define DSA_FLAG_NON_FIPS_ALLOW                 0x0400\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n/* Already defined in ossl_typ.h */\n/* typedef struct dsa_st DSA; */\n/* typedef struct dsa_method DSA_METHOD; */\n\ntypedef struct DSA_SIG_st {\n    BIGNUM *r;\n    BIGNUM *s;\n} DSA_SIG;\n\nstruct dsa_method {\n    const char *name;\n    DSA_SIG *(*dsa_do_sign) (const unsigned char *dgst, int dlen, DSA *dsa);\n    int (*dsa_sign_setup) (DSA *dsa, BN_CTX *ctx_in, BIGNUM **kinvp,\n                           BIGNUM **rp);\n    int (*dsa_do_verify) (const unsigned char *dgst, int dgst_len,\n                          DSA_SIG *sig, DSA *dsa);\n    int (*dsa_mod_exp) (DSA *dsa, BIGNUM *rr, BIGNUM *a1, BIGNUM *p1,\n                        BIGNUM *a2, BIGNUM *p2, BIGNUM *m, BN_CTX *ctx,\n                        BN_MONT_CTX *in_mont);\n    /* Can be null */\n    int (*bn_mod_exp) (DSA *dsa, BIGNUM *r, BIGNUM *a, const BIGNUM *p,\n                       const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx);\n    int (*init) (DSA *dsa);\n    int (*finish) (DSA *dsa);\n    int flags;\n    char *app_data;\n    /* If this is non-NULL, it is used to generate DSA parameters */\n    int (*dsa_paramgen) (DSA *dsa, int bits,\n                         const unsigned char *seed, int seed_len,\n                         int *counter_ret, unsigned long *h_ret,\n                         BN_GENCB *cb);\n    /* If this is non-NULL, it is used to generate DSA keys */\n    int (*dsa_keygen) (DSA *dsa);\n};\n\nstruct dsa_st {\n    /*\n     * This first variable is used to pick up errors where a DSA is passed\n     * instead of of a EVP_PKEY\n     */\n    int pad;\n    long version;\n    int write_params;\n    BIGNUM *p;\n    BIGNUM *q;                  /* == 20 */\n    BIGNUM *g;\n    BIGNUM *pub_key;            /* y public key */\n    BIGNUM *priv_key;           /* x private key */\n    BIGNUM *kinv;               /* Signing pre-calc */\n    BIGNUM *r;                  /* Signing pre-calc */\n    int flags;\n    /* Normally used to cache montgomery values */\n    BN_MONT_CTX *method_mont_p;\n    int references;\n    CRYPTO_EX_DATA ex_data;\n    const DSA_METHOD *meth;\n    /* functional reference if 'meth' is ENGINE-provided */\n    ENGINE *engine;\n};\n\n# define d2i_DSAparams_fp(fp,x) (DSA *)ASN1_d2i_fp((char *(*)())DSA_new, \\\n                (char *(*)())d2i_DSAparams,(fp),(unsigned char **)(x))\n# define i2d_DSAparams_fp(fp,x) ASN1_i2d_fp(i2d_DSAparams,(fp), \\\n                (unsigned char *)(x))\n# define d2i_DSAparams_bio(bp,x) ASN1_d2i_bio_of(DSA,DSA_new,d2i_DSAparams,bp,x)\n# define i2d_DSAparams_bio(bp,x) ASN1_i2d_bio_of_const(DSA,i2d_DSAparams,bp,x)\n\nDSA *DSAparams_dup(DSA *x);\nDSA_SIG *DSA_SIG_new(void);\nvoid DSA_SIG_free(DSA_SIG *a);\nint i2d_DSA_SIG(const DSA_SIG *a, unsigned char **pp);\nDSA_SIG *d2i_DSA_SIG(DSA_SIG **v, const unsigned char **pp, long length);\n\nDSA_SIG *DSA_do_sign(const unsigned char *dgst, int dlen, DSA *dsa);\nint DSA_do_verify(const unsigned char *dgst, int dgst_len,\n                  DSA_SIG *sig, DSA *dsa);\n\nconst DSA_METHOD *DSA_OpenSSL(void);\n\nvoid DSA_set_default_method(const DSA_METHOD *);\nconst DSA_METHOD *DSA_get_default_method(void);\nint DSA_set_method(DSA *dsa, const DSA_METHOD *);\n\nDSA *DSA_new(void);\nDSA *DSA_new_method(ENGINE *engine);\nvoid DSA_free(DSA *r);\n/* \"up\" the DSA object's reference count */\nint DSA_up_ref(DSA *r);\nint DSA_size(const DSA *);\n        /* next 4 return -1 on error */\nint DSA_sign_setup(DSA *dsa, BN_CTX *ctx_in, BIGNUM **kinvp, BIGNUM **rp);\nint DSA_sign(int type, const unsigned char *dgst, int dlen,\n             unsigned char *sig, unsigned int *siglen, DSA *dsa);\nint DSA_verify(int type, const unsigned char *dgst, int dgst_len,\n               const unsigned char *sigbuf, int siglen, DSA *dsa);\nint DSA_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func,\n                         CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func);\nint DSA_set_ex_data(DSA *d, int idx, void *arg);\nvoid *DSA_get_ex_data(DSA *d, int idx);\n\nDSA *d2i_DSAPublicKey(DSA **a, const unsigned char **pp, long length);\nDSA *d2i_DSAPrivateKey(DSA **a, const unsigned char **pp, long length);\nDSA *d2i_DSAparams(DSA **a, const unsigned char **pp, long length);\n\n/* Deprecated version */\n# ifndef OPENSSL_NO_DEPRECATED\nDSA *DSA_generate_parameters(int bits,\n                             unsigned char *seed, int seed_len,\n                             int *counter_ret, unsigned long *h_ret, void\n                              (*callback) (int, int, void *), void *cb_arg);\n# endif                         /* !defined(OPENSSL_NO_DEPRECATED) */\n\n/* New version */\nint DSA_generate_parameters_ex(DSA *dsa, int bits,\n                               const unsigned char *seed, int seed_len,\n                               int *counter_ret, unsigned long *h_ret,\n                               BN_GENCB *cb);\n\nint DSA_generate_key(DSA *a);\nint i2d_DSAPublicKey(const DSA *a, unsigned char **pp);\nint i2d_DSAPrivateKey(const DSA *a, unsigned char **pp);\nint i2d_DSAparams(const DSA *a, unsigned char **pp);\n\n# ifndef OPENSSL_NO_BIO\nint DSAparams_print(BIO *bp, const DSA *x);\nint DSA_print(BIO *bp, const DSA *x, int off);\n# endif\n# ifndef OPENSSL_NO_FP_API\nint DSAparams_print_fp(FILE *fp, const DSA *x);\nint DSA_print_fp(FILE *bp, const DSA *x, int off);\n# endif\n\n# define DSS_prime_checks 50\n/*\n * Primality test according to FIPS PUB 186[-1], Appendix 2.1: 50 rounds of\n * Rabin-Miller\n */\n# define DSA_is_prime(n, callback, cb_arg) \\\n        BN_is_prime(n, DSS_prime_checks, callback, NULL, cb_arg)\n\n# ifndef OPENSSL_NO_DH\n/*\n * Convert DSA structure (key or just parameters) into DH structure (be\n * careful to avoid small subgroup attacks when using this!)\n */\nDH *DSA_dup_DH(const DSA *r);\n# endif\n\n# define EVP_PKEY_CTX_set_dsa_paramgen_bits(ctx, nbits) \\\n        EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DSA, EVP_PKEY_OP_PARAMGEN, \\\n                                EVP_PKEY_CTRL_DSA_PARAMGEN_BITS, nbits, NULL)\n\n# define EVP_PKEY_CTRL_DSA_PARAMGEN_BITS         (EVP_PKEY_ALG_CTRL + 1)\n# define EVP_PKEY_CTRL_DSA_PARAMGEN_Q_BITS       (EVP_PKEY_ALG_CTRL + 2)\n# define EVP_PKEY_CTRL_DSA_PARAMGEN_MD           (EVP_PKEY_ALG_CTRL + 3)\n\n/* BEGIN ERROR CODES */\n/*\n * The following lines are auto generated by the script mkerr.pl. Any changes\n * made after this point may be overwritten when the script is next run.\n */\nvoid ERR_load_DSA_strings(void);\n\n/* Error codes for the DSA functions. */\n\n/* Function codes. */\n# define DSA_F_D2I_DSA_SIG                                110\n# define DSA_F_DO_DSA_PRINT                               104\n# define DSA_F_DSAPARAMS_PRINT                            100\n# define DSA_F_DSAPARAMS_PRINT_FP                         101\n# define DSA_F_DSA_BUILTIN_PARAMGEN2                      126\n# define DSA_F_DSA_DO_SIGN                                112\n# define DSA_F_DSA_DO_VERIFY                              113\n# define DSA_F_DSA_GENERATE_KEY                           124\n# define DSA_F_DSA_GENERATE_PARAMETERS_EX                 123\n# define DSA_F_DSA_NEW_METHOD                             103\n# define DSA_F_DSA_PARAM_DECODE                           119\n# define DSA_F_DSA_PRINT_FP                               105\n# define DSA_F_DSA_PRIV_DECODE                            115\n# define DSA_F_DSA_PRIV_ENCODE                            116\n# define DSA_F_DSA_PUB_DECODE                             117\n# define DSA_F_DSA_PUB_ENCODE                             118\n# define DSA_F_DSA_SIGN                                   106\n# define DSA_F_DSA_SIGN_SETUP                             107\n# define DSA_F_DSA_SIG_NEW                                109\n# define DSA_F_DSA_SIG_PRINT                              125\n# define DSA_F_DSA_VERIFY                                 108\n# define DSA_F_I2D_DSA_SIG                                111\n# define DSA_F_OLD_DSA_PRIV_DECODE                        122\n# define DSA_F_PKEY_DSA_CTRL                              120\n# define DSA_F_PKEY_DSA_KEYGEN                            121\n# define DSA_F_SIG_CB                                     114\n\n/* Reason codes. */\n# define DSA_R_BAD_Q_VALUE                                102\n# define DSA_R_BN_DECODE_ERROR                            108\n# define DSA_R_BN_ERROR                                   109\n# define DSA_R_DATA_TOO_LARGE_FOR_KEY_SIZE                100\n# define DSA_R_DECODE_ERROR                               104\n# define DSA_R_INVALID_DIGEST_TYPE                        106\n# define DSA_R_INVALID_PARAMETERS                         112\n# define DSA_R_MISSING_PARAMETERS                         101\n# define DSA_R_MODULUS_TOO_LARGE                          103\n# define DSA_R_NEED_NEW_SETUP_VALUES                      110\n# define DSA_R_NON_FIPS_DSA_METHOD                        111\n# define DSA_R_NO_PARAMETERS_SET                          107\n# define DSA_R_PARAMETER_ENCODING_ERROR                   105\n# define DSA_R_Q_NOT_PRIME                                113\n\n#ifdef  __cplusplus\n}\n#endif\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/arm/include/openssl/dso.h",
    "content": "/* dso.h */\n/*\n * Written by Geoff Thorpe (geoff@geoffthorpe.net) for the OpenSSL project\n * 2000.\n */\n/* ====================================================================\n * Copyright (c) 2000 The OpenSSL Project.  All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n *\n * 1. Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n *\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in\n *    the documentation and/or other materials provided with the\n *    distribution.\n *\n * 3. All advertising materials mentioning features or use of this\n *    software must display the following acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)\"\n *\n * 4. The names \"OpenSSL Toolkit\" and \"OpenSSL Project\" must not be used to\n *    endorse or promote products derived from this software without\n *    prior written permission. For written permission, please contact\n *    licensing@OpenSSL.org.\n *\n * 5. Products derived from this software may not be called \"OpenSSL\"\n *    nor may \"OpenSSL\" appear in their names without prior written\n *    permission of the OpenSSL Project.\n *\n * 6. Redistributions of any form whatsoever must retain the following\n *    acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)\"\n *\n * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY\n * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\n * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR\n * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\n * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,\n * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED\n * OF THE POSSIBILITY OF SUCH DAMAGE.\n * ====================================================================\n *\n * This product includes cryptographic software written by Eric Young\n * (eay@cryptsoft.com).  This product includes software written by Tim\n * Hudson (tjh@cryptsoft.com).\n *\n */\n\n#ifndef HEADER_DSO_H\n# define HEADER_DSO_H\n\n# include <openssl/crypto.h>\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/* These values are used as commands to DSO_ctrl() */\n# define DSO_CTRL_GET_FLAGS      1\n# define DSO_CTRL_SET_FLAGS      2\n# define DSO_CTRL_OR_FLAGS       3\n\n/*\n * By default, DSO_load() will translate the provided filename into a form\n * typical for the platform (more specifically the DSO_METHOD) using the\n * dso_name_converter function of the method. Eg. win32 will transform \"blah\"\n * into \"blah.dll\", and dlfcn will transform it into \"libblah.so\". The\n * behaviour can be overriden by setting the name_converter callback in the\n * DSO object (using DSO_set_name_converter()). This callback could even\n * utilise the DSO_METHOD's converter too if it only wants to override\n * behaviour for one or two possible DSO methods. However, the following flag\n * can be set in a DSO to prevent *any* native name-translation at all - eg.\n * if the caller has prompted the user for a path to a driver library so the\n * filename should be interpreted as-is.\n */\n# define DSO_FLAG_NO_NAME_TRANSLATION            0x01\n/*\n * An extra flag to give if only the extension should be added as\n * translation.  This is obviously only of importance on Unix and other\n * operating systems where the translation also may prefix the name with\n * something, like 'lib', and ignored everywhere else. This flag is also\n * ignored if DSO_FLAG_NO_NAME_TRANSLATION is used at the same time.\n */\n# define DSO_FLAG_NAME_TRANSLATION_EXT_ONLY      0x02\n\n/*\n * The following flag controls the translation of symbol names to upper case.\n * This is currently only being implemented for OpenVMS.\n */\n# define DSO_FLAG_UPCASE_SYMBOL                  0x10\n\n/*\n * This flag loads the library with public symbols. Meaning: The exported\n * symbols of this library are public to all libraries loaded after this\n * library. At the moment only implemented in unix.\n */\n# define DSO_FLAG_GLOBAL_SYMBOLS                 0x20\n\ntypedef void (*DSO_FUNC_TYPE) (void);\n\ntypedef struct dso_st DSO;\n\n/*\n * The function prototype used for method functions (or caller-provided\n * callbacks) that transform filenames. They are passed a DSO structure\n * pointer (or NULL if they are to be used independantly of a DSO object) and\n * a filename to transform. They should either return NULL (if there is an\n * error condition) or a newly allocated string containing the transformed\n * form that the caller will need to free with OPENSSL_free() when done.\n */\ntypedef char *(*DSO_NAME_CONVERTER_FUNC)(DSO *, const char *);\n/*\n * The function prototype used for method functions (or caller-provided\n * callbacks) that merge two file specifications. They are passed a DSO\n * structure pointer (or NULL if they are to be used independantly of a DSO\n * object) and two file specifications to merge. They should either return\n * NULL (if there is an error condition) or a newly allocated string\n * containing the result of merging that the caller will need to free with\n * OPENSSL_free() when done. Here, merging means that bits and pieces are\n * taken from each of the file specifications and added together in whatever\n * fashion that is sensible for the DSO method in question.  The only rule\n * that really applies is that if the two specification contain pieces of the\n * same type, the copy from the first string takes priority.  One could see\n * it as the first specification is the one given by the user and the second\n * being a bunch of defaults to add on if they're missing in the first.\n */\ntypedef char *(*DSO_MERGER_FUNC)(DSO *, const char *, const char *);\n\ntypedef struct dso_meth_st {\n    const char *name;\n    /*\n     * Loads a shared library, NB: new DSO_METHODs must ensure that a\n     * successful load populates the loaded_filename field, and likewise a\n     * successful unload OPENSSL_frees and NULLs it out.\n     */\n    int (*dso_load) (DSO *dso);\n    /* Unloads a shared library */\n    int (*dso_unload) (DSO *dso);\n    /* Binds a variable */\n    void *(*dso_bind_var) (DSO *dso, const char *symname);\n    /*\n     * Binds a function - assumes a return type of DSO_FUNC_TYPE. This should\n     * be cast to the real function prototype by the caller. Platforms that\n     * don't have compatible representations for different prototypes (this\n     * is possible within ANSI C) are highly unlikely to have shared\n     * libraries at all, let alone a DSO_METHOD implemented for them.\n     */\n    DSO_FUNC_TYPE (*dso_bind_func) (DSO *dso, const char *symname);\n/* I don't think this would actually be used in any circumstances. */\n# if 0\n    /* Unbinds a variable */\n    int (*dso_unbind_var) (DSO *dso, char *symname, void *symptr);\n    /* Unbinds a function */\n    int (*dso_unbind_func) (DSO *dso, char *symname, DSO_FUNC_TYPE symptr);\n# endif\n    /*\n     * The generic (yuck) \"ctrl()\" function. NB: Negative return values\n     * (rather than zero) indicate errors.\n     */\n    long (*dso_ctrl) (DSO *dso, int cmd, long larg, void *parg);\n    /*\n     * The default DSO_METHOD-specific function for converting filenames to a\n     * canonical native form.\n     */\n    DSO_NAME_CONVERTER_FUNC dso_name_converter;\n    /*\n     * The default DSO_METHOD-specific function for converting filenames to a\n     * canonical native form.\n     */\n    DSO_MERGER_FUNC dso_merger;\n    /* [De]Initialisation handlers. */\n    int (*init) (DSO *dso);\n    int (*finish) (DSO *dso);\n    /* Return pathname of the module containing location */\n    int (*pathbyaddr) (void *addr, char *path, int sz);\n    /* Perform global symbol lookup, i.e. among *all* modules */\n    void *(*globallookup) (const char *symname);\n} DSO_METHOD;\n\n/**********************************************************************/\n/* The low-level handle type used to refer to a loaded shared library */\n\nstruct dso_st {\n    DSO_METHOD *meth;\n    /*\n     * Standard dlopen uses a (void *). Win32 uses a HANDLE. VMS doesn't use\n     * anything but will need to cache the filename for use in the dso_bind\n     * handler. All in all, let each method control its own destiny.\n     * \"Handles\" and such go in a STACK.\n     */\n    STACK_OF(void) *meth_data;\n    int references;\n    int flags;\n    /*\n     * For use by applications etc ... use this for your bits'n'pieces, don't\n     * touch meth_data!\n     */\n    CRYPTO_EX_DATA ex_data;\n    /*\n     * If this callback function pointer is set to non-NULL, then it will be\n     * used in DSO_load() in place of meth->dso_name_converter. NB: This\n     * should normally set using DSO_set_name_converter().\n     */\n    DSO_NAME_CONVERTER_FUNC name_converter;\n    /*\n     * If this callback function pointer is set to non-NULL, then it will be\n     * used in DSO_load() in place of meth->dso_merger. NB: This should\n     * normally set using DSO_set_merger().\n     */\n    DSO_MERGER_FUNC merger;\n    /*\n     * This is populated with (a copy of) the platform-independant filename\n     * used for this DSO.\n     */\n    char *filename;\n    /*\n     * This is populated with (a copy of) the translated filename by which\n     * the DSO was actually loaded. It is NULL iff the DSO is not currently\n     * loaded. NB: This is here because the filename translation process may\n     * involve a callback being invoked more than once not only to convert to\n     * a platform-specific form, but also to try different filenames in the\n     * process of trying to perform a load. As such, this variable can be\n     * used to indicate (a) whether this DSO structure corresponds to a\n     * loaded library or not, and (b) the filename with which it was actually\n     * loaded.\n     */\n    char *loaded_filename;\n};\n\nDSO *DSO_new(void);\nDSO *DSO_new_method(DSO_METHOD *method);\nint DSO_free(DSO *dso);\nint DSO_flags(DSO *dso);\nint DSO_up_ref(DSO *dso);\nlong DSO_ctrl(DSO *dso, int cmd, long larg, void *parg);\n\n/*\n * This function sets the DSO's name_converter callback. If it is non-NULL,\n * then it will be used instead of the associated DSO_METHOD's function. If\n * oldcb is non-NULL then it is set to the function pointer value being\n * replaced. Return value is non-zero for success.\n */\nint DSO_set_name_converter(DSO *dso, DSO_NAME_CONVERTER_FUNC cb,\n                           DSO_NAME_CONVERTER_FUNC *oldcb);\n/*\n * These functions can be used to get/set the platform-independant filename\n * used for a DSO. NB: set will fail if the DSO is already loaded.\n */\nconst char *DSO_get_filename(DSO *dso);\nint DSO_set_filename(DSO *dso, const char *filename);\n/*\n * This function will invoke the DSO's name_converter callback to translate a\n * filename, or if the callback isn't set it will instead use the DSO_METHOD's\n * converter. If \"filename\" is NULL, the \"filename\" in the DSO itself will be\n * used. If the DSO_FLAG_NO_NAME_TRANSLATION flag is set, then the filename is\n * simply duplicated. NB: This function is usually called from within a\n * DSO_METHOD during the processing of a DSO_load() call, and is exposed so\n * that caller-created DSO_METHODs can do the same thing. A non-NULL return\n * value will need to be OPENSSL_free()'d.\n */\nchar *DSO_convert_filename(DSO *dso, const char *filename);\n/*\n * This function will invoke the DSO's merger callback to merge two file\n * specifications, or if the callback isn't set it will instead use the\n * DSO_METHOD's merger.  A non-NULL return value will need to be\n * OPENSSL_free()'d.\n */\nchar *DSO_merge(DSO *dso, const char *filespec1, const char *filespec2);\n/*\n * If the DSO is currently loaded, this returns the filename that it was\n * loaded under, otherwise it returns NULL. So it is also useful as a test as\n * to whether the DSO is currently loaded. NB: This will not necessarily\n * return the same value as DSO_convert_filename(dso, dso->filename), because\n * the DSO_METHOD's load function may have tried a variety of filenames (with\n * and/or without the aid of the converters) before settling on the one it\n * actually loaded.\n */\nconst char *DSO_get_loaded_filename(DSO *dso);\n\nvoid DSO_set_default_method(DSO_METHOD *meth);\nDSO_METHOD *DSO_get_default_method(void);\nDSO_METHOD *DSO_get_method(DSO *dso);\nDSO_METHOD *DSO_set_method(DSO *dso, DSO_METHOD *meth);\n\n/*\n * The all-singing all-dancing load function, you normally pass NULL for the\n * first and third parameters. Use DSO_up and DSO_free for subsequent\n * reference count handling. Any flags passed in will be set in the\n * constructed DSO after its init() function but before the load operation.\n * If 'dso' is non-NULL, 'flags' is ignored.\n */\nDSO *DSO_load(DSO *dso, const char *filename, DSO_METHOD *meth, int flags);\n\n/* This function binds to a variable inside a shared library. */\nvoid *DSO_bind_var(DSO *dso, const char *symname);\n\n/* This function binds to a function inside a shared library. */\nDSO_FUNC_TYPE DSO_bind_func(DSO *dso, const char *symname);\n\n/*\n * This method is the default, but will beg, borrow, or steal whatever method\n * should be the default on any particular platform (including\n * DSO_METH_null() if necessary).\n */\nDSO_METHOD *DSO_METHOD_openssl(void);\n\n/*\n * This method is defined for all platforms - if a platform has no DSO\n * support then this will be the only method!\n */\nDSO_METHOD *DSO_METHOD_null(void);\n\n/*\n * If DSO_DLFCN is defined, the standard dlfcn.h-style functions (dlopen,\n * dlclose, dlsym, etc) will be used and incorporated into this method. If\n * not, this method will return NULL.\n */\nDSO_METHOD *DSO_METHOD_dlfcn(void);\n\n/*\n * If DSO_DL is defined, the standard dl.h-style functions (shl_load,\n * shl_unload, shl_findsym, etc) will be used and incorporated into this\n * method. If not, this method will return NULL.\n */\nDSO_METHOD *DSO_METHOD_dl(void);\n\n/* If WIN32 is defined, use DLLs. If not, return NULL. */\nDSO_METHOD *DSO_METHOD_win32(void);\n\n/* If VMS is defined, use shared images. If not, return NULL. */\nDSO_METHOD *DSO_METHOD_vms(void);\n\n/*\n * This function writes null-terminated pathname of DSO module containing\n * 'addr' into 'sz' large caller-provided 'path' and returns the number of\n * characters [including trailing zero] written to it. If 'sz' is 0 or\n * negative, 'path' is ignored and required amount of charachers [including\n * trailing zero] to accomodate pathname is returned. If 'addr' is NULL, then\n * pathname of cryptolib itself is returned. Negative or zero return value\n * denotes error.\n */\nint DSO_pathbyaddr(void *addr, char *path, int sz);\n\n/*\n * This function should be used with caution! It looks up symbols in *all*\n * loaded modules and if module gets unloaded by somebody else attempt to\n * dereference the pointer is doomed to have fatal consequences. Primary\n * usage for this function is to probe *core* system functionality, e.g.\n * check if getnameinfo(3) is available at run-time without bothering about\n * OS-specific details such as libc.so.versioning or where does it actually\n * reside: in libc itself or libsocket.\n */\nvoid *DSO_global_lookup(const char *name);\n\n/* If BeOS is defined, use shared images. If not, return NULL. */\nDSO_METHOD *DSO_METHOD_beos(void);\n\n/* BEGIN ERROR CODES */\n/*\n * The following lines are auto generated by the script mkerr.pl. Any changes\n * made after this point may be overwritten when the script is next run.\n */\nvoid ERR_load_DSO_strings(void);\n\n/* Error codes for the DSO functions. */\n\n/* Function codes. */\n# define DSO_F_BEOS_BIND_FUNC                             144\n# define DSO_F_BEOS_BIND_VAR                              145\n# define DSO_F_BEOS_LOAD                                  146\n# define DSO_F_BEOS_NAME_CONVERTER                        147\n# define DSO_F_BEOS_UNLOAD                                148\n# define DSO_F_DLFCN_BIND_FUNC                            100\n# define DSO_F_DLFCN_BIND_VAR                             101\n# define DSO_F_DLFCN_LOAD                                 102\n# define DSO_F_DLFCN_MERGER                               130\n# define DSO_F_DLFCN_NAME_CONVERTER                       123\n# define DSO_F_DLFCN_UNLOAD                               103\n# define DSO_F_DL_BIND_FUNC                               104\n# define DSO_F_DL_BIND_VAR                                105\n# define DSO_F_DL_LOAD                                    106\n# define DSO_F_DL_MERGER                                  131\n# define DSO_F_DL_NAME_CONVERTER                          124\n# define DSO_F_DL_UNLOAD                                  107\n# define DSO_F_DSO_BIND_FUNC                              108\n# define DSO_F_DSO_BIND_VAR                               109\n# define DSO_F_DSO_CONVERT_FILENAME                       126\n# define DSO_F_DSO_CTRL                                   110\n# define DSO_F_DSO_FREE                                   111\n# define DSO_F_DSO_GET_FILENAME                           127\n# define DSO_F_DSO_GET_LOADED_FILENAME                    128\n# define DSO_F_DSO_GLOBAL_LOOKUP                          139\n# define DSO_F_DSO_LOAD                                   112\n# define DSO_F_DSO_MERGE                                  132\n# define DSO_F_DSO_NEW_METHOD                             113\n# define DSO_F_DSO_PATHBYADDR                             140\n# define DSO_F_DSO_SET_FILENAME                           129\n# define DSO_F_DSO_SET_NAME_CONVERTER                     122\n# define DSO_F_DSO_UP_REF                                 114\n# define DSO_F_GLOBAL_LOOKUP_FUNC                         138\n# define DSO_F_PATHBYADDR                                 137\n# define DSO_F_VMS_BIND_SYM                               115\n# define DSO_F_VMS_LOAD                                   116\n# define DSO_F_VMS_MERGER                                 133\n# define DSO_F_VMS_UNLOAD                                 117\n# define DSO_F_WIN32_BIND_FUNC                            118\n# define DSO_F_WIN32_BIND_VAR                             119\n# define DSO_F_WIN32_GLOBALLOOKUP                         142\n# define DSO_F_WIN32_GLOBALLOOKUP_FUNC                    143\n# define DSO_F_WIN32_JOINER                               135\n# define DSO_F_WIN32_LOAD                                 120\n# define DSO_F_WIN32_MERGER                               134\n# define DSO_F_WIN32_NAME_CONVERTER                       125\n# define DSO_F_WIN32_PATHBYADDR                           141\n# define DSO_F_WIN32_SPLITTER                             136\n# define DSO_F_WIN32_UNLOAD                               121\n\n/* Reason codes. */\n# define DSO_R_CTRL_FAILED                                100\n# define DSO_R_DSO_ALREADY_LOADED                         110\n# define DSO_R_EMPTY_FILE_STRUCTURE                       113\n# define DSO_R_FAILURE                                    114\n# define DSO_R_FILENAME_TOO_BIG                           101\n# define DSO_R_FINISH_FAILED                              102\n# define DSO_R_INCORRECT_FILE_SYNTAX                      115\n# define DSO_R_LOAD_FAILED                                103\n# define DSO_R_NAME_TRANSLATION_FAILED                    109\n# define DSO_R_NO_FILENAME                                111\n# define DSO_R_NO_FILE_SPECIFICATION                      116\n# define DSO_R_NULL_HANDLE                                104\n# define DSO_R_SET_FILENAME_FAILED                        112\n# define DSO_R_STACK_ERROR                                105\n# define DSO_R_SYM_FAILURE                                106\n# define DSO_R_UNLOAD_FAILED                              107\n# define DSO_R_UNSUPPORTED                                108\n\n#ifdef  __cplusplus\n}\n#endif\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/arm/include/openssl/dtls1.h",
    "content": "/* ssl/dtls1.h */\n/*\n * DTLS implementation written by Nagendra Modadugu\n * (nagendra@cs.stanford.edu) for the OpenSSL project 2005.\n */\n/* ====================================================================\n * Copyright (c) 1999-2005 The OpenSSL Project.  All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n *\n * 1. Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n *\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in\n *    the documentation and/or other materials provided with the\n *    distribution.\n *\n * 3. All advertising materials mentioning features or use of this\n *    software must display the following acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)\"\n *\n * 4. The names \"OpenSSL Toolkit\" and \"OpenSSL Project\" must not be used to\n *    endorse or promote products derived from this software without\n *    prior written permission. For written permission, please contact\n *    openssl-core@OpenSSL.org.\n *\n * 5. Products derived from this software may not be called \"OpenSSL\"\n *    nor may \"OpenSSL\" appear in their names without prior written\n *    permission of the OpenSSL Project.\n *\n * 6. Redistributions of any form whatsoever must retain the following\n *    acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)\"\n *\n * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY\n * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\n * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR\n * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\n * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,\n * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED\n * OF THE POSSIBILITY OF SUCH DAMAGE.\n * ====================================================================\n *\n * This product includes cryptographic software written by Eric Young\n * (eay@cryptsoft.com).  This product includes software written by Tim\n * Hudson (tjh@cryptsoft.com).\n *\n */\n\n#ifndef HEADER_DTLS1_H\n# define HEADER_DTLS1_H\n\n# include <openssl/buffer.h>\n# include <openssl/pqueue.h>\n# ifdef OPENSSL_SYS_VMS\n#  include <resource.h>\n#  include <sys/timeb.h>\n# endif\n# ifdef OPENSSL_SYS_WIN32\n/* Needed for struct timeval */\n#  include <winsock.h>\n# elif defined(OPENSSL_SYS_NETWARE) && !defined(_WINSOCK2API_)\n#  include <sys/timeval.h>\n# else\n#  if defined(OPENSSL_SYS_VXWORKS)\n#   include <sys/times.h>\n#  else\n#   include <sys/time.h>\n#  endif\n# endif\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n# define DTLS1_VERSION                   0xFEFF\n# define DTLS1_2_VERSION                 0xFEFD\n# define DTLS_MAX_VERSION                DTLS1_2_VERSION\n# define DTLS1_VERSION_MAJOR             0xFE\n\n# define DTLS1_BAD_VER                   0x0100\n\n/* Special value for method supporting multiple versions */\n# define DTLS_ANY_VERSION                0x1FFFF\n\n# if 0\n/* this alert description is not specified anywhere... */\n#  define DTLS1_AD_MISSING_HANDSHAKE_MESSAGE    110\n# endif\n\n/* lengths of messages */\n# define DTLS1_COOKIE_LENGTH                     256\n\n# define DTLS1_RT_HEADER_LENGTH                  13\n\n# define DTLS1_HM_HEADER_LENGTH                  12\n\n# define DTLS1_HM_BAD_FRAGMENT                   -2\n# define DTLS1_HM_FRAGMENT_RETRY                 -3\n\n# define DTLS1_CCS_HEADER_LENGTH                  1\n\n# ifdef DTLS1_AD_MISSING_HANDSHAKE_MESSAGE\n#  define DTLS1_AL_HEADER_LENGTH                   7\n# else\n#  define DTLS1_AL_HEADER_LENGTH                   2\n# endif\n\n# ifndef OPENSSL_NO_SSL_INTERN\n\n#  ifndef OPENSSL_NO_SCTP\n#   define DTLS1_SCTP_AUTH_LABEL   \"EXPORTER_DTLS_OVER_SCTP\"\n#  endif\n\n/* Max MTU overhead we know about so far is 40 for IPv6 + 8 for UDP */\n#  define DTLS1_MAX_MTU_OVERHEAD                   48\n\ntypedef struct dtls1_bitmap_st {\n    unsigned long map;          /* track 32 packets on 32-bit systems and 64\n                                 * - on 64-bit systems */\n    unsigned char max_seq_num[8]; /* max record number seen so far, 64-bit\n                                   * value in big-endian encoding */\n} DTLS1_BITMAP;\n\nstruct dtls1_retransmit_state {\n    EVP_CIPHER_CTX *enc_write_ctx; /* cryptographic state */\n    EVP_MD_CTX *write_hash;     /* used for mac generation */\n#  ifndef OPENSSL_NO_COMP\n    COMP_CTX *compress;         /* compression */\n#  else\n    char *compress;\n#  endif\n    SSL_SESSION *session;\n    unsigned short epoch;\n};\n\nstruct hm_header_st {\n    unsigned char type;\n    unsigned long msg_len;\n    unsigned short seq;\n    unsigned long frag_off;\n    unsigned long frag_len;\n    unsigned int is_ccs;\n    struct dtls1_retransmit_state saved_retransmit_state;\n};\n\nstruct ccs_header_st {\n    unsigned char type;\n    unsigned short seq;\n};\n\nstruct dtls1_timeout_st {\n    /* Number of read timeouts so far */\n    unsigned int read_timeouts;\n    /* Number of write timeouts so far */\n    unsigned int write_timeouts;\n    /* Number of alerts received so far */\n    unsigned int num_alerts;\n};\n\ntypedef struct record_pqueue_st {\n    unsigned short epoch;\n    pqueue q;\n} record_pqueue;\n\ntypedef struct hm_fragment_st {\n    struct hm_header_st msg_header;\n    unsigned char *fragment;\n    unsigned char *reassembly;\n} hm_fragment;\n\ntypedef struct dtls1_state_st {\n    unsigned int send_cookie;\n    unsigned char cookie[DTLS1_COOKIE_LENGTH];\n    unsigned char rcvd_cookie[DTLS1_COOKIE_LENGTH];\n    unsigned int cookie_len;\n    /*\n     * The current data and handshake epoch.  This is initially\n     * undefined, and starts at zero once the initial handshake is\n     * completed\n     */\n    unsigned short r_epoch;\n    unsigned short w_epoch;\n    /* records being received in the current epoch */\n    DTLS1_BITMAP bitmap;\n    /* renegotiation starts a new set of sequence numbers */\n    DTLS1_BITMAP next_bitmap;\n    /* handshake message numbers */\n    unsigned short handshake_write_seq;\n    unsigned short next_handshake_write_seq;\n    unsigned short handshake_read_seq;\n    /* save last sequence number for retransmissions */\n    unsigned char last_write_sequence[8];\n    /* Received handshake records (processed and unprocessed) */\n    record_pqueue unprocessed_rcds;\n    record_pqueue processed_rcds;\n    /* Buffered handshake messages */\n    pqueue buffered_messages;\n    /* Buffered (sent) handshake records */\n    pqueue sent_messages;\n    /*\n     * Buffered application records. Only for records between CCS and\n     * Finished to prevent either protocol violation or unnecessary message\n     * loss.\n     */\n    record_pqueue buffered_app_data;\n    /* Is set when listening for new connections with dtls1_listen() */\n    unsigned int listen;\n    unsigned int link_mtu;      /* max on-the-wire DTLS packet size */\n    unsigned int mtu;           /* max DTLS packet size */\n    struct hm_header_st w_msg_hdr;\n    struct hm_header_st r_msg_hdr;\n    struct dtls1_timeout_st timeout;\n    /*\n     * Indicates when the last handshake msg or heartbeat sent will timeout\n     */\n    struct timeval next_timeout;\n    /* Timeout duration */\n    unsigned short timeout_duration;\n    /*\n     * storage for Alert/Handshake protocol data received but not yet\n     * processed by ssl3_read_bytes:\n     */\n    unsigned char alert_fragment[DTLS1_AL_HEADER_LENGTH];\n    unsigned int alert_fragment_len;\n    unsigned char handshake_fragment[DTLS1_HM_HEADER_LENGTH];\n    unsigned int handshake_fragment_len;\n    unsigned int retransmitting;\n    /*\n     * Set when the handshake is ready to process peer's ChangeCipherSpec message.\n     * Cleared after the message has been processed.\n     */\n    unsigned int change_cipher_spec_ok;\n#  ifndef OPENSSL_NO_SCTP\n    /* used when SSL_ST_XX_FLUSH is entered */\n    int next_state;\n    int shutdown_received;\n#  endif\n} DTLS1_STATE;\n\ntypedef struct dtls1_record_data_st {\n    unsigned char *packet;\n    unsigned int packet_length;\n    SSL3_BUFFER rbuf;\n    SSL3_RECORD rrec;\n#  ifndef OPENSSL_NO_SCTP\n    struct bio_dgram_sctp_rcvinfo recordinfo;\n#  endif\n} DTLS1_RECORD_DATA;\n\n# endif\n\n/* Timeout multipliers (timeout slice is defined in apps/timeouts.h */\n# define DTLS1_TMO_READ_COUNT                      2\n# define DTLS1_TMO_WRITE_COUNT                     2\n\n# define DTLS1_TMO_ALERT_COUNT                     12\n\n#ifdef  __cplusplus\n}\n#endif\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/arm/include/openssl/e_os2.h",
    "content": "/* e_os2.h */\n/* ====================================================================\n * Copyright (c) 1998-2000 The OpenSSL Project.  All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n *\n * 1. Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n *\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in\n *    the documentation and/or other materials provided with the\n *    distribution.\n *\n * 3. All advertising materials mentioning features or use of this\n *    software must display the following acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit. (http://www.openssl.org/)\"\n *\n * 4. The names \"OpenSSL Toolkit\" and \"OpenSSL Project\" must not be used to\n *    endorse or promote products derived from this software without\n *    prior written permission. For written permission, please contact\n *    openssl-core@openssl.org.\n *\n * 5. Products derived from this software may not be called \"OpenSSL\"\n *    nor may \"OpenSSL\" appear in their names without prior written\n *    permission of the OpenSSL Project.\n *\n * 6. Redistributions of any form whatsoever must retain the following\n *    acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit (http://www.openssl.org/)\"\n *\n * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY\n * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\n * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR\n * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\n * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,\n * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED\n * OF THE POSSIBILITY OF SUCH DAMAGE.\n * ====================================================================\n *\n * This product includes cryptographic software written by Eric Young\n * (eay@cryptsoft.com).  This product includes software written by Tim\n * Hudson (tjh@cryptsoft.com).\n *\n */\n\n#include <openssl/opensslconf.h>\n\n#ifndef HEADER_E_OS2_H\n# define HEADER_E_OS2_H\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n/******************************************************************************\n * Detect operating systems.  This probably needs completing.\n * The result is that at least one OPENSSL_SYS_os macro should be defined.\n * However, if none is defined, Unix is assumed.\n **/\n\n# define OPENSSL_SYS_UNIX\n\n/* ---------------------- Macintosh, before MacOS X ----------------------- */\n# if defined(__MWERKS__) && defined(macintosh) || defined(OPENSSL_SYSNAME_MAC)\n#  undef OPENSSL_SYS_UNIX\n#  define OPENSSL_SYS_MACINTOSH_CLASSIC\n# endif\n\n/* ---------------------- NetWare ----------------------------------------- */\n# if defined(NETWARE) || defined(OPENSSL_SYSNAME_NETWARE)\n#  undef OPENSSL_SYS_UNIX\n#  define OPENSSL_SYS_NETWARE\n# endif\n\n/* --------------------- Microsoft operating systems ---------------------- */\n\n/*\n * Note that MSDOS actually denotes 32-bit environments running on top of\n * MS-DOS, such as DJGPP one.\n */\n# if defined(OPENSSL_SYSNAME_MSDOS)\n#  undef OPENSSL_SYS_UNIX\n#  define OPENSSL_SYS_MSDOS\n# endif\n\n/*\n * For 32 bit environment, there seems to be the CygWin environment and then\n * all the others that try to do the same thing Microsoft does...\n */\n# if defined(OPENSSL_SYSNAME_UWIN)\n#  undef OPENSSL_SYS_UNIX\n#  define OPENSSL_SYS_WIN32_UWIN\n# else\n#  if defined(__CYGWIN__) || defined(OPENSSL_SYSNAME_CYGWIN)\n#   undef OPENSSL_SYS_UNIX\n#   define OPENSSL_SYS_WIN32_CYGWIN\n#  else\n#   if defined(_WIN32) || defined(OPENSSL_SYSNAME_WIN32)\n#    undef OPENSSL_SYS_UNIX\n#    define OPENSSL_SYS_WIN32\n#   endif\n#   if defined(_WIN64) || defined(OPENSSL_SYSNAME_WIN64)\n#    undef OPENSSL_SYS_UNIX\n#    if !defined(OPENSSL_SYS_WIN64)\n#     define OPENSSL_SYS_WIN64\n#    endif\n#   endif\n#   if defined(OPENSSL_SYSNAME_WINNT)\n#    undef OPENSSL_SYS_UNIX\n#    define OPENSSL_SYS_WINNT\n#   endif\n#   if defined(OPENSSL_SYSNAME_WINCE)\n#    undef OPENSSL_SYS_UNIX\n#    define OPENSSL_SYS_WINCE\n#   endif\n#  endif\n# endif\n\n/* Anything that tries to look like Microsoft is \"Windows\" */\n# if defined(OPENSSL_SYS_WIN32) || defined(OPENSSL_SYS_WIN64) || defined(OPENSSL_SYS_WINNT) || defined(OPENSSL_SYS_WINCE)\n#  undef OPENSSL_SYS_UNIX\n#  define OPENSSL_SYS_WINDOWS\n#  ifndef OPENSSL_SYS_MSDOS\n#   define OPENSSL_SYS_MSDOS\n#  endif\n# endif\n\n/*\n * DLL settings.  This part is a bit tough, because it's up to the\n * application implementor how he or she will link the application, so it\n * requires some macro to be used.\n */\n# ifdef OPENSSL_SYS_WINDOWS\n#  ifndef OPENSSL_OPT_WINDLL\n#   if defined(_WINDLL)         /* This is used when building OpenSSL to\n                                 * indicate that DLL linkage should be used */\n#    define OPENSSL_OPT_WINDLL\n#   endif\n#  endif\n# endif\n\n/* ------------------------------- OpenVMS -------------------------------- */\n# if defined(__VMS) || defined(VMS) || defined(OPENSSL_SYSNAME_VMS)\n#  undef OPENSSL_SYS_UNIX\n#  define OPENSSL_SYS_VMS\n#  if defined(__DECC)\n#   define OPENSSL_SYS_VMS_DECC\n#  elif defined(__DECCXX)\n#   define OPENSSL_SYS_VMS_DECC\n#   define OPENSSL_SYS_VMS_DECCXX\n#  else\n#   define OPENSSL_SYS_VMS_NODECC\n#  endif\n# endif\n\n/* -------------------------------- OS/2 ---------------------------------- */\n# if defined(__EMX__) || defined(__OS2__)\n#  undef OPENSSL_SYS_UNIX\n#  define OPENSSL_SYS_OS2\n# endif\n\n/* -------------------------------- Unix ---------------------------------- */\n# ifdef OPENSSL_SYS_UNIX\n#  if defined(linux) || defined(__linux__) || defined(OPENSSL_SYSNAME_LINUX)\n#   define OPENSSL_SYS_LINUX\n#  endif\n#  ifdef OPENSSL_SYSNAME_MPE\n#   define OPENSSL_SYS_MPE\n#  endif\n#  ifdef OPENSSL_SYSNAME_SNI\n#   define OPENSSL_SYS_SNI\n#  endif\n#  ifdef OPENSSL_SYSNAME_ULTRASPARC\n#   define OPENSSL_SYS_ULTRASPARC\n#  endif\n#  ifdef OPENSSL_SYSNAME_NEWS4\n#   define OPENSSL_SYS_NEWS4\n#  endif\n#  ifdef OPENSSL_SYSNAME_MACOSX\n#   define OPENSSL_SYS_MACOSX\n#  endif\n#  ifdef OPENSSL_SYSNAME_MACOSX_RHAPSODY\n#   define OPENSSL_SYS_MACOSX_RHAPSODY\n#   define OPENSSL_SYS_MACOSX\n#  endif\n#  ifdef OPENSSL_SYSNAME_SUNOS\n#   define OPENSSL_SYS_SUNOS\n#  endif\n#  if defined(_CRAY) || defined(OPENSSL_SYSNAME_CRAY)\n#   define OPENSSL_SYS_CRAY\n#  endif\n#  if defined(_AIX) || defined(OPENSSL_SYSNAME_AIX)\n#   define OPENSSL_SYS_AIX\n#  endif\n# endif\n\n/* -------------------------------- VOS ----------------------------------- */\n# if defined(__VOS__) || defined(OPENSSL_SYSNAME_VOS)\n#  define OPENSSL_SYS_VOS\n#  ifdef __HPPA__\n#   define OPENSSL_SYS_VOS_HPPA\n#  endif\n#  ifdef __IA32__\n#   define OPENSSL_SYS_VOS_IA32\n#  endif\n# endif\n\n/* ------------------------------ VxWorks --------------------------------- */\n# ifdef OPENSSL_SYSNAME_VXWORKS\n#  define OPENSSL_SYS_VXWORKS\n# endif\n\n/* -------------------------------- BeOS ---------------------------------- */\n# if defined(__BEOS__)\n#  define OPENSSL_SYS_BEOS\n#  include <sys/socket.h>\n#  if defined(BONE_VERSION)\n#   define OPENSSL_SYS_BEOS_BONE\n#  else\n#   define OPENSSL_SYS_BEOS_R5\n#  endif\n# endif\n\n/**\n * That's it for OS-specific stuff\n *****************************************************************************/\n\n/* Specials for I/O an exit */\n# ifdef OPENSSL_SYS_MSDOS\n#  define OPENSSL_UNISTD_IO <io.h>\n#  define OPENSSL_DECLARE_EXIT extern void exit(int);\n# else\n#  define OPENSSL_UNISTD_IO OPENSSL_UNISTD\n#  define OPENSSL_DECLARE_EXIT  /* declared in unistd.h */\n# endif\n\n/*-\n * Definitions of OPENSSL_GLOBAL and OPENSSL_EXTERN, to define and declare\n * certain global symbols that, with some compilers under VMS, have to be\n * defined and declared explicitely with globaldef and globalref.\n * Definitions of OPENSSL_EXPORT and OPENSSL_IMPORT, to define and declare\n * DLL exports and imports for compilers under Win32.  These are a little\n * more complicated to use.  Basically, for any library that exports some\n * global variables, the following code must be present in the header file\n * that declares them, before OPENSSL_EXTERN is used:\n *\n * #ifdef SOME_BUILD_FLAG_MACRO\n * # undef OPENSSL_EXTERN\n * # define OPENSSL_EXTERN OPENSSL_EXPORT\n * #endif\n *\n * The default is to have OPENSSL_EXPORT, OPENSSL_IMPORT and OPENSSL_GLOBAL\n * have some generally sensible values, and for OPENSSL_EXTERN to have the\n * value OPENSSL_IMPORT.\n */\n\n# if defined(OPENSSL_SYS_VMS_NODECC)\n#  define OPENSSL_EXPORT globalref\n#  define OPENSSL_IMPORT globalref\n#  define OPENSSL_GLOBAL globaldef\n# elif defined(OPENSSL_SYS_WINDOWS) && defined(OPENSSL_OPT_WINDLL)\n#  define OPENSSL_EXPORT extern __declspec(dllexport)\n#  define OPENSSL_IMPORT extern __declspec(dllimport)\n#  define OPENSSL_GLOBAL\n# else\n#  define OPENSSL_EXPORT extern\n#  define OPENSSL_IMPORT extern\n#  define OPENSSL_GLOBAL\n# endif\n# define OPENSSL_EXTERN OPENSSL_IMPORT\n\n/*-\n * Macros to allow global variables to be reached through function calls when\n * required (if a shared library version requires it, for example.\n * The way it's done allows definitions like this:\n *\n *      // in foobar.c\n *      OPENSSL_IMPLEMENT_GLOBAL(int,foobar,0)\n *      // in foobar.h\n *      OPENSSL_DECLARE_GLOBAL(int,foobar);\n *      #define foobar OPENSSL_GLOBAL_REF(foobar)\n */\n# ifdef OPENSSL_EXPORT_VAR_AS_FUNCTION\n#  define OPENSSL_IMPLEMENT_GLOBAL(type,name,value)                      \\\n        type *_shadow_##name(void)                                      \\\n        { static type _hide_##name=value; return &_hide_##name; }\n#  define OPENSSL_DECLARE_GLOBAL(type,name) type *_shadow_##name(void)\n#  define OPENSSL_GLOBAL_REF(name) (*(_shadow_##name()))\n# else\n#  define OPENSSL_IMPLEMENT_GLOBAL(type,name,value) OPENSSL_GLOBAL type _shadow_##name=value;\n#  define OPENSSL_DECLARE_GLOBAL(type,name) OPENSSL_EXPORT type _shadow_##name\n#  define OPENSSL_GLOBAL_REF(name) _shadow_##name\n# endif\n\n# if defined(OPENSSL_SYS_MACINTOSH_CLASSIC) && macintosh==1 && !defined(MAC_OS_GUSI_SOURCE)\n#  define ossl_ssize_t long\n# endif\n\n# ifdef OPENSSL_SYS_MSDOS\n#  define ossl_ssize_t long\n# endif\n\n# if defined(NeXT) || defined(OPENSSL_SYS_NEWS4) || defined(OPENSSL_SYS_SUNOS)\n#  define ssize_t int\n# endif\n\n# if defined(__ultrix) && !defined(ssize_t)\n#  define ossl_ssize_t int\n# endif\n\n# ifndef ossl_ssize_t\n#  define ossl_ssize_t ssize_t\n# endif\n\n#ifdef  __cplusplus\n}\n#endif\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/arm/include/openssl/ebcdic.h",
    "content": "/* crypto/ebcdic.h */\n\n#ifndef HEADER_EBCDIC_H\n# define HEADER_EBCDIC_H\n\n# include <sys/types.h>\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n/* Avoid name clashes with other applications */\n# define os_toascii   _openssl_os_toascii\n# define os_toebcdic  _openssl_os_toebcdic\n# define ebcdic2ascii _openssl_ebcdic2ascii\n# define ascii2ebcdic _openssl_ascii2ebcdic\n\nextern const unsigned char os_toascii[256];\nextern const unsigned char os_toebcdic[256];\nvoid *ebcdic2ascii(void *dest, const void *srce, size_t count);\nvoid *ascii2ebcdic(void *dest, const void *srce, size_t count);\n\n#ifdef  __cplusplus\n}\n#endif\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/arm/include/openssl/ec.h",
    "content": "/* crypto/ec/ec.h */\n/*\n * Originally written by Bodo Moeller for the OpenSSL project.\n */\n/**\n * \\file crypto/ec/ec.h Include file for the OpenSSL EC functions\n * \\author Originally written by Bodo Moeller for the OpenSSL project\n */\n/* ====================================================================\n * Copyright (c) 1998-2005 The OpenSSL Project.  All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n *\n * 1. Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n *\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in\n *    the documentation and/or other materials provided with the\n *    distribution.\n *\n * 3. All advertising materials mentioning features or use of this\n *    software must display the following acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit. (http://www.openssl.org/)\"\n *\n * 4. The names \"OpenSSL Toolkit\" and \"OpenSSL Project\" must not be used to\n *    endorse or promote products derived from this software without\n *    prior written permission. For written permission, please contact\n *    openssl-core@openssl.org.\n *\n * 5. Products derived from this software may not be called \"OpenSSL\"\n *    nor may \"OpenSSL\" appear in their names without prior written\n *    permission of the OpenSSL Project.\n *\n * 6. Redistributions of any form whatsoever must retain the following\n *    acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit (http://www.openssl.org/)\"\n *\n * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY\n * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\n * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR\n * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\n * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,\n * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED\n * OF THE POSSIBILITY OF SUCH DAMAGE.\n * ====================================================================\n *\n * This product includes cryptographic software written by Eric Young\n * (eay@cryptsoft.com).  This product includes software written by Tim\n * Hudson (tjh@cryptsoft.com).\n *\n */\n/* ====================================================================\n * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED.\n *\n * Portions of the attached software (\"Contribution\") are developed by\n * SUN MICROSYSTEMS, INC., and are contributed to the OpenSSL project.\n *\n * The Contribution is licensed pursuant to the OpenSSL open source\n * license provided above.\n *\n * The elliptic curve binary polynomial software is originally written by\n * Sheueling Chang Shantz and Douglas Stebila of Sun Microsystems Laboratories.\n *\n */\n\n#ifndef HEADER_EC_H\n# define HEADER_EC_H\n\n# include <openssl/opensslconf.h>\n\n# ifdef OPENSSL_NO_EC\n#  error EC is disabled.\n# endif\n\n# include <openssl/asn1.h>\n# include <openssl/symhacks.h>\n# ifndef OPENSSL_NO_DEPRECATED\n#  include <openssl/bn.h>\n# endif\n\n# ifdef  __cplusplus\nextern \"C\" {\n# elif defined(__SUNPRO_C)\n#  if __SUNPRO_C >= 0x520\n#   pragma error_messages (off,E_ARRAY_OF_INCOMPLETE_NONAME,E_ARRAY_OF_INCOMPLETE)\n#  endif\n# endif\n\n# ifndef OPENSSL_ECC_MAX_FIELD_BITS\n#  define OPENSSL_ECC_MAX_FIELD_BITS 661\n# endif\n\n/** Enum for the point conversion form as defined in X9.62 (ECDSA)\n *  for the encoding of a elliptic curve point (x,y) */\ntypedef enum {\n        /** the point is encoded as z||x, where the octet z specifies\n         *  which solution of the quadratic equation y is  */\n    POINT_CONVERSION_COMPRESSED = 2,\n        /** the point is encoded as z||x||y, where z is the octet 0x04  */\n    POINT_CONVERSION_UNCOMPRESSED = 4,\n        /** the point is encoded as z||x||y, where the octet z specifies\n         *  which solution of the quadratic equation y is  */\n    POINT_CONVERSION_HYBRID = 6\n} point_conversion_form_t;\n\ntypedef struct ec_method_st EC_METHOD;\n\ntypedef struct ec_group_st\n    /*-\n     EC_METHOD *meth;\n     -- field definition\n     -- curve coefficients\n     -- optional generator with associated information (order, cofactor)\n     -- optional extra data (precomputed table for fast computation of multiples of generator)\n     -- ASN1 stuff\n    */\n    EC_GROUP;\n\ntypedef struct ec_point_st EC_POINT;\n\n/********************************************************************/\n/*               EC_METHODs for curves over GF(p)                   */\n/********************************************************************/\n\n/** Returns the basic GFp ec methods which provides the basis for the\n *  optimized methods.\n *  \\return  EC_METHOD object\n */\nconst EC_METHOD *EC_GFp_simple_method(void);\n\n/** Returns GFp methods using montgomery multiplication.\n *  \\return  EC_METHOD object\n */\nconst EC_METHOD *EC_GFp_mont_method(void);\n\n/** Returns GFp methods using optimized methods for NIST recommended curves\n *  \\return  EC_METHOD object\n */\nconst EC_METHOD *EC_GFp_nist_method(void);\n\n# ifndef OPENSSL_NO_EC_NISTP_64_GCC_128\n/** Returns 64-bit optimized methods for nistp224\n *  \\return  EC_METHOD object\n */\nconst EC_METHOD *EC_GFp_nistp224_method(void);\n\n/** Returns 64-bit optimized methods for nistp256\n *  \\return  EC_METHOD object\n */\nconst EC_METHOD *EC_GFp_nistp256_method(void);\n\n/** Returns 64-bit optimized methods for nistp521\n *  \\return  EC_METHOD object\n */\nconst EC_METHOD *EC_GFp_nistp521_method(void);\n# endif\n\n# ifndef OPENSSL_NO_EC2M\n/********************************************************************/\n/*           EC_METHOD for curves over GF(2^m)                      */\n/********************************************************************/\n\n/** Returns the basic GF2m ec method\n *  \\return  EC_METHOD object\n */\nconst EC_METHOD *EC_GF2m_simple_method(void);\n\n# endif\n\n/********************************************************************/\n/*                   EC_GROUP functions                             */\n/********************************************************************/\n\n/** Creates a new EC_GROUP object\n *  \\param   meth  EC_METHOD to use\n *  \\return  newly created EC_GROUP object or NULL in case of an error.\n */\nEC_GROUP *EC_GROUP_new(const EC_METHOD *meth);\n\n/** Frees a EC_GROUP object\n *  \\param  group  EC_GROUP object to be freed.\n */\nvoid EC_GROUP_free(EC_GROUP *group);\n\n/** Clears and frees a EC_GROUP object\n *  \\param  group  EC_GROUP object to be cleared and freed.\n */\nvoid EC_GROUP_clear_free(EC_GROUP *group);\n\n/** Copies EC_GROUP objects. Note: both EC_GROUPs must use the same EC_METHOD.\n *  \\param  dst  destination EC_GROUP object\n *  \\param  src  source EC_GROUP object\n *  \\return 1 on success and 0 if an error occurred.\n */\nint EC_GROUP_copy(EC_GROUP *dst, const EC_GROUP *src);\n\n/** Creates a new EC_GROUP object and copies the copies the content\n *  form src to the newly created EC_KEY object\n *  \\param  src  source EC_GROUP object\n *  \\return newly created EC_GROUP object or NULL in case of an error.\n */\nEC_GROUP *EC_GROUP_dup(const EC_GROUP *src);\n\n/** Returns the EC_METHOD of the EC_GROUP object.\n *  \\param  group  EC_GROUP object\n *  \\return EC_METHOD used in this EC_GROUP object.\n */\nconst EC_METHOD *EC_GROUP_method_of(const EC_GROUP *group);\n\n/** Returns the field type of the EC_METHOD.\n *  \\param  meth  EC_METHOD object\n *  \\return NID of the underlying field type OID.\n */\nint EC_METHOD_get_field_type(const EC_METHOD *meth);\n\n/** Sets the generator and it's order/cofactor of a EC_GROUP object.\n *  \\param  group      EC_GROUP object\n *  \\param  generator  EC_POINT object with the generator.\n *  \\param  order      the order of the group generated by the generator.\n *  \\param  cofactor   the index of the sub-group generated by the generator\n *                     in the group of all points on the elliptic curve.\n *  \\return 1 on success and 0 if an error occured\n */\nint EC_GROUP_set_generator(EC_GROUP *group, const EC_POINT *generator,\n                           const BIGNUM *order, const BIGNUM *cofactor);\n\n/** Returns the generator of a EC_GROUP object.\n *  \\param  group  EC_GROUP object\n *  \\return the currently used generator (possibly NULL).\n */\nconst EC_POINT *EC_GROUP_get0_generator(const EC_GROUP *group);\n\n/** Returns the montgomery data for order(Generator)\n *  \\param  group  EC_GROUP object\n *  \\return the currently used generator (possibly NULL).\n*/\nBN_MONT_CTX *EC_GROUP_get_mont_data(const EC_GROUP *group);\n\n/** Gets the order of a EC_GROUP\n *  \\param  group  EC_GROUP object\n *  \\param  order  BIGNUM to which the order is copied\n *  \\param  ctx    BN_CTX object (optional)\n *  \\return 1 on success and 0 if an error occured\n */\nint EC_GROUP_get_order(const EC_GROUP *group, BIGNUM *order, BN_CTX *ctx);\n\n/** Gets the cofactor of a EC_GROUP\n *  \\param  group     EC_GROUP object\n *  \\param  cofactor  BIGNUM to which the cofactor is copied\n *  \\param  ctx       BN_CTX object (optional)\n *  \\return 1 on success and 0 if an error occured\n */\nint EC_GROUP_get_cofactor(const EC_GROUP *group, BIGNUM *cofactor,\n                          BN_CTX *ctx);\n\n/** Sets the name of a EC_GROUP object\n *  \\param  group  EC_GROUP object\n *  \\param  nid    NID of the curve name OID\n */\nvoid EC_GROUP_set_curve_name(EC_GROUP *group, int nid);\n\n/** Returns the curve name of a EC_GROUP object\n *  \\param  group  EC_GROUP object\n *  \\return NID of the curve name OID or 0 if not set.\n */\nint EC_GROUP_get_curve_name(const EC_GROUP *group);\n\nvoid EC_GROUP_set_asn1_flag(EC_GROUP *group, int flag);\nint EC_GROUP_get_asn1_flag(const EC_GROUP *group);\n\nvoid EC_GROUP_set_point_conversion_form(EC_GROUP *group,\n                                        point_conversion_form_t form);\npoint_conversion_form_t EC_GROUP_get_point_conversion_form(const EC_GROUP *);\n\nunsigned char *EC_GROUP_get0_seed(const EC_GROUP *x);\nsize_t EC_GROUP_get_seed_len(const EC_GROUP *);\nsize_t EC_GROUP_set_seed(EC_GROUP *, const unsigned char *, size_t len);\n\n/** Sets the parameter of a ec over GFp defined by y^2 = x^3 + a*x + b\n *  \\param  group  EC_GROUP object\n *  \\param  p      BIGNUM with the prime number\n *  \\param  a      BIGNUM with parameter a of the equation\n *  \\param  b      BIGNUM with parameter b of the equation\n *  \\param  ctx    BN_CTX object (optional)\n *  \\return 1 on success and 0 if an error occured\n */\nint EC_GROUP_set_curve_GFp(EC_GROUP *group, const BIGNUM *p, const BIGNUM *a,\n                           const BIGNUM *b, BN_CTX *ctx);\n\n/** Gets the parameter of the ec over GFp defined by y^2 = x^3 + a*x + b\n *  \\param  group  EC_GROUP object\n *  \\param  p      BIGNUM for the prime number\n *  \\param  a      BIGNUM for parameter a of the equation\n *  \\param  b      BIGNUM for parameter b of the equation\n *  \\param  ctx    BN_CTX object (optional)\n *  \\return 1 on success and 0 if an error occured\n */\nint EC_GROUP_get_curve_GFp(const EC_GROUP *group, BIGNUM *p, BIGNUM *a,\n                           BIGNUM *b, BN_CTX *ctx);\n\n# ifndef OPENSSL_NO_EC2M\n/** Sets the parameter of a ec over GF2m defined by y^2 + x*y = x^3 + a*x^2 + b\n *  \\param  group  EC_GROUP object\n *  \\param  p      BIGNUM with the polynomial defining the underlying field\n *  \\param  a      BIGNUM with parameter a of the equation\n *  \\param  b      BIGNUM with parameter b of the equation\n *  \\param  ctx    BN_CTX object (optional)\n *  \\return 1 on success and 0 if an error occured\n */\nint EC_GROUP_set_curve_GF2m(EC_GROUP *group, const BIGNUM *p, const BIGNUM *a,\n                            const BIGNUM *b, BN_CTX *ctx);\n\n/** Gets the parameter of the ec over GF2m defined by y^2 + x*y = x^3 + a*x^2 + b\n *  \\param  group  EC_GROUP object\n *  \\param  p      BIGNUM for the polynomial defining the underlying field\n *  \\param  a      BIGNUM for parameter a of the equation\n *  \\param  b      BIGNUM for parameter b of the equation\n *  \\param  ctx    BN_CTX object (optional)\n *  \\return 1 on success and 0 if an error occured\n */\nint EC_GROUP_get_curve_GF2m(const EC_GROUP *group, BIGNUM *p, BIGNUM *a,\n                            BIGNUM *b, BN_CTX *ctx);\n# endif\n/** Returns the number of bits needed to represent a field element\n *  \\param  group  EC_GROUP object\n *  \\return number of bits needed to represent a field element\n */\nint EC_GROUP_get_degree(const EC_GROUP *group);\n\n/** Checks whether the parameter in the EC_GROUP define a valid ec group\n *  \\param  group  EC_GROUP object\n *  \\param  ctx    BN_CTX object (optional)\n *  \\return 1 if group is a valid ec group and 0 otherwise\n */\nint EC_GROUP_check(const EC_GROUP *group, BN_CTX *ctx);\n\n/** Checks whether the discriminant of the elliptic curve is zero or not\n *  \\param  group  EC_GROUP object\n *  \\param  ctx    BN_CTX object (optional)\n *  \\return 1 if the discriminant is not zero and 0 otherwise\n */\nint EC_GROUP_check_discriminant(const EC_GROUP *group, BN_CTX *ctx);\n\n/** Compares two EC_GROUP objects\n *  \\param  a    first EC_GROUP object\n *  \\param  b    second EC_GROUP object\n *  \\param  ctx  BN_CTX object (optional)\n *  \\return 0 if both groups are equal and 1 otherwise\n */\nint EC_GROUP_cmp(const EC_GROUP *a, const EC_GROUP *b, BN_CTX *ctx);\n\n/*\n * EC_GROUP_new_GF*() calls EC_GROUP_new() and EC_GROUP_set_GF*() after\n * choosing an appropriate EC_METHOD\n */\n\n/** Creates a new EC_GROUP object with the specified parameters defined\n *  over GFp (defined by the equation y^2 = x^3 + a*x + b)\n *  \\param  p    BIGNUM with the prime number\n *  \\param  a    BIGNUM with the parameter a of the equation\n *  \\param  b    BIGNUM with the parameter b of the equation\n *  \\param  ctx  BN_CTX object (optional)\n *  \\return newly created EC_GROUP object with the specified parameters\n */\nEC_GROUP *EC_GROUP_new_curve_GFp(const BIGNUM *p, const BIGNUM *a,\n                                 const BIGNUM *b, BN_CTX *ctx);\n# ifndef OPENSSL_NO_EC2M\n/** Creates a new EC_GROUP object with the specified parameters defined\n *  over GF2m (defined by the equation y^2 + x*y = x^3 + a*x^2 + b)\n *  \\param  p    BIGNUM with the polynomial defining the underlying field\n *  \\param  a    BIGNUM with the parameter a of the equation\n *  \\param  b    BIGNUM with the parameter b of the equation\n *  \\param  ctx  BN_CTX object (optional)\n *  \\return newly created EC_GROUP object with the specified parameters\n */\nEC_GROUP *EC_GROUP_new_curve_GF2m(const BIGNUM *p, const BIGNUM *a,\n                                  const BIGNUM *b, BN_CTX *ctx);\n# endif\n/** Creates a EC_GROUP object with a curve specified by a NID\n *  \\param  nid  NID of the OID of the curve name\n *  \\return newly created EC_GROUP object with specified curve or NULL\n *          if an error occurred\n */\nEC_GROUP *EC_GROUP_new_by_curve_name(int nid);\n\n/********************************************************************/\n/*               handling of internal curves                        */\n/********************************************************************/\n\ntypedef struct {\n    int nid;\n    const char *comment;\n} EC_builtin_curve;\n\n/*\n * EC_builtin_curves(EC_builtin_curve *r, size_t size) returns number of all\n * available curves or zero if a error occurred. In case r ist not zero\n * nitems EC_builtin_curve structures are filled with the data of the first\n * nitems internal groups\n */\nsize_t EC_get_builtin_curves(EC_builtin_curve *r, size_t nitems);\n\nconst char *EC_curve_nid2nist(int nid);\nint EC_curve_nist2nid(const char *name);\n\n/********************************************************************/\n/*                    EC_POINT functions                            */\n/********************************************************************/\n\n/** Creates a new EC_POINT object for the specified EC_GROUP\n *  \\param  group  EC_GROUP the underlying EC_GROUP object\n *  \\return newly created EC_POINT object or NULL if an error occurred\n */\nEC_POINT *EC_POINT_new(const EC_GROUP *group);\n\n/** Frees a EC_POINT object\n *  \\param  point  EC_POINT object to be freed\n */\nvoid EC_POINT_free(EC_POINT *point);\n\n/** Clears and frees a EC_POINT object\n *  \\param  point  EC_POINT object to be cleared and freed\n */\nvoid EC_POINT_clear_free(EC_POINT *point);\n\n/** Copies EC_POINT object\n *  \\param  dst  destination EC_POINT object\n *  \\param  src  source EC_POINT object\n *  \\return 1 on success and 0 if an error occured\n */\nint EC_POINT_copy(EC_POINT *dst, const EC_POINT *src);\n\n/** Creates a new EC_POINT object and copies the content of the supplied\n *  EC_POINT\n *  \\param  src    source EC_POINT object\n *  \\param  group  underlying the EC_GROUP object\n *  \\return newly created EC_POINT object or NULL if an error occurred\n */\nEC_POINT *EC_POINT_dup(const EC_POINT *src, const EC_GROUP *group);\n\n/** Returns the EC_METHOD used in EC_POINT object\n *  \\param  point  EC_POINT object\n *  \\return the EC_METHOD used\n */\nconst EC_METHOD *EC_POINT_method_of(const EC_POINT *point);\n\n/** Sets a point to infinity (neutral element)\n *  \\param  group  underlying EC_GROUP object\n *  \\param  point  EC_POINT to set to infinity\n *  \\return 1 on success and 0 if an error occured\n */\nint EC_POINT_set_to_infinity(const EC_GROUP *group, EC_POINT *point);\n\n/** Sets the jacobian projective coordinates of a EC_POINT over GFp\n *  \\param  group  underlying EC_GROUP object\n *  \\param  p      EC_POINT object\n *  \\param  x      BIGNUM with the x-coordinate\n *  \\param  y      BIGNUM with the y-coordinate\n *  \\param  z      BIGNUM with the z-coordinate\n *  \\param  ctx    BN_CTX object (optional)\n *  \\return 1 on success and 0 if an error occured\n */\nint EC_POINT_set_Jprojective_coordinates_GFp(const EC_GROUP *group,\n                                             EC_POINT *p, const BIGNUM *x,\n                                             const BIGNUM *y, const BIGNUM *z,\n                                             BN_CTX *ctx);\n\n/** Gets the jacobian projective coordinates of a EC_POINT over GFp\n *  \\param  group  underlying EC_GROUP object\n *  \\param  p      EC_POINT object\n *  \\param  x      BIGNUM for the x-coordinate\n *  \\param  y      BIGNUM for the y-coordinate\n *  \\param  z      BIGNUM for the z-coordinate\n *  \\param  ctx    BN_CTX object (optional)\n *  \\return 1 on success and 0 if an error occured\n */\nint EC_POINT_get_Jprojective_coordinates_GFp(const EC_GROUP *group,\n                                             const EC_POINT *p, BIGNUM *x,\n                                             BIGNUM *y, BIGNUM *z,\n                                             BN_CTX *ctx);\n\n/** Sets the affine coordinates of a EC_POINT over GFp\n *  \\param  group  underlying EC_GROUP object\n *  \\param  p      EC_POINT object\n *  \\param  x      BIGNUM with the x-coordinate\n *  \\param  y      BIGNUM with the y-coordinate\n *  \\param  ctx    BN_CTX object (optional)\n *  \\return 1 on success and 0 if an error occured\n */\nint EC_POINT_set_affine_coordinates_GFp(const EC_GROUP *group, EC_POINT *p,\n                                        const BIGNUM *x, const BIGNUM *y,\n                                        BN_CTX *ctx);\n\n/** Gets the affine coordinates of a EC_POINT over GFp\n *  \\param  group  underlying EC_GROUP object\n *  \\param  p      EC_POINT object\n *  \\param  x      BIGNUM for the x-coordinate\n *  \\param  y      BIGNUM for the y-coordinate\n *  \\param  ctx    BN_CTX object (optional)\n *  \\return 1 on success and 0 if an error occured\n */\nint EC_POINT_get_affine_coordinates_GFp(const EC_GROUP *group,\n                                        const EC_POINT *p, BIGNUM *x,\n                                        BIGNUM *y, BN_CTX *ctx);\n\n/** Sets the x9.62 compressed coordinates of a EC_POINT over GFp\n *  \\param  group  underlying EC_GROUP object\n *  \\param  p      EC_POINT object\n *  \\param  x      BIGNUM with x-coordinate\n *  \\param  y_bit  integer with the y-Bit (either 0 or 1)\n *  \\param  ctx    BN_CTX object (optional)\n *  \\return 1 on success and 0 if an error occured\n */\nint EC_POINT_set_compressed_coordinates_GFp(const EC_GROUP *group,\n                                            EC_POINT *p, const BIGNUM *x,\n                                            int y_bit, BN_CTX *ctx);\n# ifndef OPENSSL_NO_EC2M\n/** Sets the affine coordinates of a EC_POINT over GF2m\n *  \\param  group  underlying EC_GROUP object\n *  \\param  p      EC_POINT object\n *  \\param  x      BIGNUM with the x-coordinate\n *  \\param  y      BIGNUM with the y-coordinate\n *  \\param  ctx    BN_CTX object (optional)\n *  \\return 1 on success and 0 if an error occured\n */\nint EC_POINT_set_affine_coordinates_GF2m(const EC_GROUP *group, EC_POINT *p,\n                                         const BIGNUM *x, const BIGNUM *y,\n                                         BN_CTX *ctx);\n\n/** Gets the affine coordinates of a EC_POINT over GF2m\n *  \\param  group  underlying EC_GROUP object\n *  \\param  p      EC_POINT object\n *  \\param  x      BIGNUM for the x-coordinate\n *  \\param  y      BIGNUM for the y-coordinate\n *  \\param  ctx    BN_CTX object (optional)\n *  \\return 1 on success and 0 if an error occured\n */\nint EC_POINT_get_affine_coordinates_GF2m(const EC_GROUP *group,\n                                         const EC_POINT *p, BIGNUM *x,\n                                         BIGNUM *y, BN_CTX *ctx);\n\n/** Sets the x9.62 compressed coordinates of a EC_POINT over GF2m\n *  \\param  group  underlying EC_GROUP object\n *  \\param  p      EC_POINT object\n *  \\param  x      BIGNUM with x-coordinate\n *  \\param  y_bit  integer with the y-Bit (either 0 or 1)\n *  \\param  ctx    BN_CTX object (optional)\n *  \\return 1 on success and 0 if an error occured\n */\nint EC_POINT_set_compressed_coordinates_GF2m(const EC_GROUP *group,\n                                             EC_POINT *p, const BIGNUM *x,\n                                             int y_bit, BN_CTX *ctx);\n# endif\n/** Encodes a EC_POINT object to a octet string\n *  \\param  group  underlying EC_GROUP object\n *  \\param  p      EC_POINT object\n *  \\param  form   point conversion form\n *  \\param  buf    memory buffer for the result. If NULL the function returns\n *                 required buffer size.\n *  \\param  len    length of the memory buffer\n *  \\param  ctx    BN_CTX object (optional)\n *  \\return the length of the encoded octet string or 0 if an error occurred\n */\nsize_t EC_POINT_point2oct(const EC_GROUP *group, const EC_POINT *p,\n                          point_conversion_form_t form,\n                          unsigned char *buf, size_t len, BN_CTX *ctx);\n\n/** Decodes a EC_POINT from a octet string\n *  \\param  group  underlying EC_GROUP object\n *  \\param  p      EC_POINT object\n *  \\param  buf    memory buffer with the encoded ec point\n *  \\param  len    length of the encoded ec point\n *  \\param  ctx    BN_CTX object (optional)\n *  \\return 1 on success and 0 if an error occured\n */\nint EC_POINT_oct2point(const EC_GROUP *group, EC_POINT *p,\n                       const unsigned char *buf, size_t len, BN_CTX *ctx);\n\n/* other interfaces to point2oct/oct2point: */\nBIGNUM *EC_POINT_point2bn(const EC_GROUP *, const EC_POINT *,\n                          point_conversion_form_t form, BIGNUM *, BN_CTX *);\nEC_POINT *EC_POINT_bn2point(const EC_GROUP *, const BIGNUM *,\n                            EC_POINT *, BN_CTX *);\nchar *EC_POINT_point2hex(const EC_GROUP *, const EC_POINT *,\n                         point_conversion_form_t form, BN_CTX *);\nEC_POINT *EC_POINT_hex2point(const EC_GROUP *, const char *,\n                             EC_POINT *, BN_CTX *);\n\n/********************************************************************/\n/*         functions for doing EC_POINT arithmetic                  */\n/********************************************************************/\n\n/** Computes the sum of two EC_POINT\n *  \\param  group  underlying EC_GROUP object\n *  \\param  r      EC_POINT object for the result (r = a + b)\n *  \\param  a      EC_POINT object with the first summand\n *  \\param  b      EC_POINT object with the second summand\n *  \\param  ctx    BN_CTX object (optional)\n *  \\return 1 on success and 0 if an error occured\n */\nint EC_POINT_add(const EC_GROUP *group, EC_POINT *r, const EC_POINT *a,\n                 const EC_POINT *b, BN_CTX *ctx);\n\n/** Computes the double of a EC_POINT\n *  \\param  group  underlying EC_GROUP object\n *  \\param  r      EC_POINT object for the result (r = 2 * a)\n *  \\param  a      EC_POINT object\n *  \\param  ctx    BN_CTX object (optional)\n *  \\return 1 on success and 0 if an error occured\n */\nint EC_POINT_dbl(const EC_GROUP *group, EC_POINT *r, const EC_POINT *a,\n                 BN_CTX *ctx);\n\n/** Computes the inverse of a EC_POINT\n *  \\param  group  underlying EC_GROUP object\n *  \\param  a      EC_POINT object to be inverted (it's used for the result as well)\n *  \\param  ctx    BN_CTX object (optional)\n *  \\return 1 on success and 0 if an error occured\n */\nint EC_POINT_invert(const EC_GROUP *group, EC_POINT *a, BN_CTX *ctx);\n\n/** Checks whether the point is the neutral element of the group\n *  \\param  group  the underlying EC_GROUP object\n *  \\param  p      EC_POINT object\n *  \\return 1 if the point is the neutral element and 0 otherwise\n */\nint EC_POINT_is_at_infinity(const EC_GROUP *group, const EC_POINT *p);\n\n/** Checks whether the point is on the curve\n *  \\param  group  underlying EC_GROUP object\n *  \\param  point  EC_POINT object to check\n *  \\param  ctx    BN_CTX object (optional)\n *  \\return 1 if point if on the curve and 0 otherwise\n */\nint EC_POINT_is_on_curve(const EC_GROUP *group, const EC_POINT *point,\n                         BN_CTX *ctx);\n\n/** Compares two EC_POINTs\n *  \\param  group  underlying EC_GROUP object\n *  \\param  a      first EC_POINT object\n *  \\param  b      second EC_POINT object\n *  \\param  ctx    BN_CTX object (optional)\n *  \\return 0 if both points are equal and a value != 0 otherwise\n */\nint EC_POINT_cmp(const EC_GROUP *group, const EC_POINT *a, const EC_POINT *b,\n                 BN_CTX *ctx);\n\nint EC_POINT_make_affine(const EC_GROUP *group, EC_POINT *point, BN_CTX *ctx);\nint EC_POINTs_make_affine(const EC_GROUP *group, size_t num,\n                          EC_POINT *points[], BN_CTX *ctx);\n\n/** Computes r = generator * n sum_{i=0}^{num-1} p[i] * m[i]\n *  \\param  group  underlying EC_GROUP object\n *  \\param  r      EC_POINT object for the result\n *  \\param  n      BIGNUM with the multiplier for the group generator (optional)\n *  \\param  num    number futher summands\n *  \\param  p      array of size num of EC_POINT objects\n *  \\param  m      array of size num of BIGNUM objects\n *  \\param  ctx    BN_CTX object (optional)\n *  \\return 1 on success and 0 if an error occured\n */\nint EC_POINTs_mul(const EC_GROUP *group, EC_POINT *r, const BIGNUM *n,\n                  size_t num, const EC_POINT *p[], const BIGNUM *m[],\n                  BN_CTX *ctx);\n\n/** Computes r = generator * n + q * m\n *  \\param  group  underlying EC_GROUP object\n *  \\param  r      EC_POINT object for the result\n *  \\param  n      BIGNUM with the multiplier for the group generator (optional)\n *  \\param  q      EC_POINT object with the first factor of the second summand\n *  \\param  m      BIGNUM with the second factor of the second summand\n *  \\param  ctx    BN_CTX object (optional)\n *  \\return 1 on success and 0 if an error occured\n */\nint EC_POINT_mul(const EC_GROUP *group, EC_POINT *r, const BIGNUM *n,\n                 const EC_POINT *q, const BIGNUM *m, BN_CTX *ctx);\n\n/** Stores multiples of generator for faster point multiplication\n *  \\param  group  EC_GROUP object\n *  \\param  ctx    BN_CTX object (optional)\n *  \\return 1 on success and 0 if an error occured\n */\nint EC_GROUP_precompute_mult(EC_GROUP *group, BN_CTX *ctx);\n\n/** Reports whether a precomputation has been done\n *  \\param  group  EC_GROUP object\n *  \\return 1 if a pre-computation has been done and 0 otherwise\n */\nint EC_GROUP_have_precompute_mult(const EC_GROUP *group);\n\n/********************************************************************/\n/*                       ASN1 stuff                                 */\n/********************************************************************/\n\n/*\n * EC_GROUP_get_basis_type() returns the NID of the basis type used to\n * represent the field elements\n */\nint EC_GROUP_get_basis_type(const EC_GROUP *);\n# ifndef OPENSSL_NO_EC2M\nint EC_GROUP_get_trinomial_basis(const EC_GROUP *, unsigned int *k);\nint EC_GROUP_get_pentanomial_basis(const EC_GROUP *, unsigned int *k1,\n                                   unsigned int *k2, unsigned int *k3);\n# endif\n\n# define OPENSSL_EC_NAMED_CURVE  0x001\n\ntypedef struct ecpk_parameters_st ECPKPARAMETERS;\n\nEC_GROUP *d2i_ECPKParameters(EC_GROUP **, const unsigned char **in, long len);\nint i2d_ECPKParameters(const EC_GROUP *, unsigned char **out);\n\n# define d2i_ECPKParameters_bio(bp,x) ASN1_d2i_bio_of(EC_GROUP,NULL,d2i_ECPKParameters,bp,x)\n# define i2d_ECPKParameters_bio(bp,x) ASN1_i2d_bio_of_const(EC_GROUP,i2d_ECPKParameters,bp,x)\n# define d2i_ECPKParameters_fp(fp,x) (EC_GROUP *)ASN1_d2i_fp(NULL, \\\n                (char *(*)())d2i_ECPKParameters,(fp),(unsigned char **)(x))\n# define i2d_ECPKParameters_fp(fp,x) ASN1_i2d_fp(i2d_ECPKParameters,(fp), \\\n                (unsigned char *)(x))\n\n# ifndef OPENSSL_NO_BIO\nint ECPKParameters_print(BIO *bp, const EC_GROUP *x, int off);\n# endif\n# ifndef OPENSSL_NO_FP_API\nint ECPKParameters_print_fp(FILE *fp, const EC_GROUP *x, int off);\n# endif\n\n/********************************************************************/\n/*                      EC_KEY functions                            */\n/********************************************************************/\n\ntypedef struct ec_key_st EC_KEY;\n\n/* some values for the encoding_flag */\n# define EC_PKEY_NO_PARAMETERS   0x001\n# define EC_PKEY_NO_PUBKEY       0x002\n\n/* some values for the flags field */\n# define EC_FLAG_NON_FIPS_ALLOW  0x1\n# define EC_FLAG_FIPS_CHECKED    0x2\n\n/** Creates a new EC_KEY object.\n *  \\return EC_KEY object or NULL if an error occurred.\n */\nEC_KEY *EC_KEY_new(void);\n\nint EC_KEY_get_flags(const EC_KEY *key);\n\nvoid EC_KEY_set_flags(EC_KEY *key, int flags);\n\nvoid EC_KEY_clear_flags(EC_KEY *key, int flags);\n\n/** Creates a new EC_KEY object using a named curve as underlying\n *  EC_GROUP object.\n *  \\param  nid  NID of the named curve.\n *  \\return EC_KEY object or NULL if an error occurred.\n */\nEC_KEY *EC_KEY_new_by_curve_name(int nid);\n\n/** Frees a EC_KEY object.\n *  \\param  key  EC_KEY object to be freed.\n */\nvoid EC_KEY_free(EC_KEY *key);\n\n/** Copies a EC_KEY object.\n *  \\param  dst  destination EC_KEY object\n *  \\param  src  src EC_KEY object\n *  \\return dst or NULL if an error occurred.\n */\nEC_KEY *EC_KEY_copy(EC_KEY *dst, const EC_KEY *src);\n\n/** Creates a new EC_KEY object and copies the content from src to it.\n *  \\param  src  the source EC_KEY object\n *  \\return newly created EC_KEY object or NULL if an error occurred.\n */\nEC_KEY *EC_KEY_dup(const EC_KEY *src);\n\n/** Increases the internal reference count of a EC_KEY object.\n *  \\param  key  EC_KEY object\n *  \\return 1 on success and 0 if an error occurred.\n */\nint EC_KEY_up_ref(EC_KEY *key);\n\n/** Returns the EC_GROUP object of a EC_KEY object\n *  \\param  key  EC_KEY object\n *  \\return the EC_GROUP object (possibly NULL).\n */\nconst EC_GROUP *EC_KEY_get0_group(const EC_KEY *key);\n\n/** Sets the EC_GROUP of a EC_KEY object.\n *  \\param  key    EC_KEY object\n *  \\param  group  EC_GROUP to use in the EC_KEY object (note: the EC_KEY\n *                 object will use an own copy of the EC_GROUP).\n *  \\return 1 on success and 0 if an error occurred.\n */\nint EC_KEY_set_group(EC_KEY *key, const EC_GROUP *group);\n\n/** Returns the private key of a EC_KEY object.\n *  \\param  key  EC_KEY object\n *  \\return a BIGNUM with the private key (possibly NULL).\n */\nconst BIGNUM *EC_KEY_get0_private_key(const EC_KEY *key);\n\n/** Sets the private key of a EC_KEY object.\n *  \\param  key  EC_KEY object\n *  \\param  prv  BIGNUM with the private key (note: the EC_KEY object\n *               will use an own copy of the BIGNUM).\n *  \\return 1 on success and 0 if an error occurred.\n */\nint EC_KEY_set_private_key(EC_KEY *key, const BIGNUM *prv);\n\n/** Returns the public key of a EC_KEY object.\n *  \\param  key  the EC_KEY object\n *  \\return a EC_POINT object with the public key (possibly NULL)\n */\nconst EC_POINT *EC_KEY_get0_public_key(const EC_KEY *key);\n\n/** Sets the public key of a EC_KEY object.\n *  \\param  key  EC_KEY object\n *  \\param  pub  EC_POINT object with the public key (note: the EC_KEY object\n *               will use an own copy of the EC_POINT object).\n *  \\return 1 on success and 0 if an error occurred.\n */\nint EC_KEY_set_public_key(EC_KEY *key, const EC_POINT *pub);\n\nunsigned EC_KEY_get_enc_flags(const EC_KEY *key);\nvoid EC_KEY_set_enc_flags(EC_KEY *eckey, unsigned int flags);\npoint_conversion_form_t EC_KEY_get_conv_form(const EC_KEY *key);\nvoid EC_KEY_set_conv_form(EC_KEY *eckey, point_conversion_form_t cform);\n/* functions to set/get method specific data  */\nvoid *EC_KEY_get_key_method_data(EC_KEY *key,\n                                 void *(*dup_func) (void *),\n                                 void (*free_func) (void *),\n                                 void (*clear_free_func) (void *));\n/** Sets the key method data of an EC_KEY object, if none has yet been set.\n *  \\param  key              EC_KEY object\n *  \\param  data             opaque data to install.\n *  \\param  dup_func         a function that duplicates |data|.\n *  \\param  free_func        a function that frees |data|.\n *  \\param  clear_free_func  a function that wipes and frees |data|.\n *  \\return the previously set data pointer, or NULL if |data| was inserted.\n */\nvoid *EC_KEY_insert_key_method_data(EC_KEY *key, void *data,\n                                    void *(*dup_func) (void *),\n                                    void (*free_func) (void *),\n                                    void (*clear_free_func) (void *));\n/* wrapper functions for the underlying EC_GROUP object */\nvoid EC_KEY_set_asn1_flag(EC_KEY *eckey, int asn1_flag);\n\n/** Creates a table of pre-computed multiples of the generator to\n *  accelerate further EC_KEY operations.\n *  \\param  key  EC_KEY object\n *  \\param  ctx  BN_CTX object (optional)\n *  \\return 1 on success and 0 if an error occurred.\n */\nint EC_KEY_precompute_mult(EC_KEY *key, BN_CTX *ctx);\n\n/** Creates a new ec private (and optional a new public) key.\n *  \\param  key  EC_KEY object\n *  \\return 1 on success and 0 if an error occurred.\n */\nint EC_KEY_generate_key(EC_KEY *key);\n\n/** Verifies that a private and/or public key is valid.\n *  \\param  key  the EC_KEY object\n *  \\return 1 on success and 0 otherwise.\n */\nint EC_KEY_check_key(const EC_KEY *key);\n\n/** Sets a public key from affine coordindates performing\n *  neccessary NIST PKV tests.\n *  \\param  key  the EC_KEY object\n *  \\param  x    public key x coordinate\n *  \\param  y    public key y coordinate\n *  \\return 1 on success and 0 otherwise.\n */\nint EC_KEY_set_public_key_affine_coordinates(EC_KEY *key, BIGNUM *x,\n                                             BIGNUM *y);\n\n/********************************************************************/\n/*        de- and encoding functions for SEC1 ECPrivateKey          */\n/********************************************************************/\n\n/** Decodes a private key from a memory buffer.\n *  \\param  key  a pointer to a EC_KEY object which should be used (or NULL)\n *  \\param  in   pointer to memory with the DER encoded private key\n *  \\param  len  length of the DER encoded private key\n *  \\return the decoded private key or NULL if an error occurred.\n */\nEC_KEY *d2i_ECPrivateKey(EC_KEY **key, const unsigned char **in, long len);\n\n/** Encodes a private key object and stores the result in a buffer.\n *  \\param  key  the EC_KEY object to encode\n *  \\param  out  the buffer for the result (if NULL the function returns number\n *               of bytes needed).\n *  \\return 1 on success and 0 if an error occurred.\n */\nint i2d_ECPrivateKey(EC_KEY *key, unsigned char **out);\n\n/********************************************************************/\n/*        de- and encoding functions for EC parameters              */\n/********************************************************************/\n\n/** Decodes ec parameter from a memory buffer.\n *  \\param  key  a pointer to a EC_KEY object which should be used (or NULL)\n *  \\param  in   pointer to memory with the DER encoded ec parameters\n *  \\param  len  length of the DER encoded ec parameters\n *  \\return a EC_KEY object with the decoded parameters or NULL if an error\n *          occurred.\n */\nEC_KEY *d2i_ECParameters(EC_KEY **key, const unsigned char **in, long len);\n\n/** Encodes ec parameter and stores the result in a buffer.\n *  \\param  key  the EC_KEY object with ec paramters to encode\n *  \\param  out  the buffer for the result (if NULL the function returns number\n *               of bytes needed).\n *  \\return 1 on success and 0 if an error occurred.\n */\nint i2d_ECParameters(EC_KEY *key, unsigned char **out);\n\n/********************************************************************/\n/*         de- and encoding functions for EC public key             */\n/*         (octet string, not DER -- hence 'o2i' and 'i2o')         */\n/********************************************************************/\n\n/** Decodes a ec public key from a octet string.\n *  \\param  key  a pointer to a EC_KEY object which should be used\n *  \\param  in   memory buffer with the encoded public key\n *  \\param  len  length of the encoded public key\n *  \\return EC_KEY object with decoded public key or NULL if an error\n *          occurred.\n */\nEC_KEY *o2i_ECPublicKey(EC_KEY **key, const unsigned char **in, long len);\n\n/** Encodes a ec public key in an octet string.\n *  \\param  key  the EC_KEY object with the public key\n *  \\param  out  the buffer for the result (if NULL the function returns number\n *               of bytes needed).\n *  \\return 1 on success and 0 if an error occurred\n */\nint i2o_ECPublicKey(EC_KEY *key, unsigned char **out);\n\n# ifndef OPENSSL_NO_BIO\n/** Prints out the ec parameters on human readable form.\n *  \\param  bp   BIO object to which the information is printed\n *  \\param  key  EC_KEY object\n *  \\return 1 on success and 0 if an error occurred\n */\nint ECParameters_print(BIO *bp, const EC_KEY *key);\n\n/** Prints out the contents of a EC_KEY object\n *  \\param  bp   BIO object to which the information is printed\n *  \\param  key  EC_KEY object\n *  \\param  off  line offset\n *  \\return 1 on success and 0 if an error occurred\n */\nint EC_KEY_print(BIO *bp, const EC_KEY *key, int off);\n\n# endif\n# ifndef OPENSSL_NO_FP_API\n/** Prints out the ec parameters on human readable form.\n *  \\param  fp   file descriptor to which the information is printed\n *  \\param  key  EC_KEY object\n *  \\return 1 on success and 0 if an error occurred\n */\nint ECParameters_print_fp(FILE *fp, const EC_KEY *key);\n\n/** Prints out the contents of a EC_KEY object\n *  \\param  fp   file descriptor to which the information is printed\n *  \\param  key  EC_KEY object\n *  \\param  off  line offset\n *  \\return 1 on success and 0 if an error occurred\n */\nint EC_KEY_print_fp(FILE *fp, const EC_KEY *key, int off);\n\n# endif\n\n# define ECParameters_dup(x) ASN1_dup_of(EC_KEY,i2d_ECParameters,d2i_ECParameters,x)\n\n# ifndef __cplusplus\n#  if defined(__SUNPRO_C)\n#   if __SUNPRO_C >= 0x520\n#    pragma error_messages (default,E_ARRAY_OF_INCOMPLETE_NONAME,E_ARRAY_OF_INCOMPLETE)\n#   endif\n#  endif\n# endif\n\n# define EVP_PKEY_CTX_set_ec_paramgen_curve_nid(ctx, nid) \\\n        EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_EC, \\\n                                EVP_PKEY_OP_PARAMGEN|EVP_PKEY_OP_KEYGEN, \\\n                                EVP_PKEY_CTRL_EC_PARAMGEN_CURVE_NID, nid, NULL)\n\n# define EVP_PKEY_CTX_set_ec_param_enc(ctx, flag) \\\n        EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_EC, \\\n                                EVP_PKEY_OP_PARAMGEN|EVP_PKEY_OP_KEYGEN, \\\n                                EVP_PKEY_CTRL_EC_PARAM_ENC, flag, NULL)\n\n# define EVP_PKEY_CTX_set_ecdh_cofactor_mode(ctx, flag) \\\n        EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_EC, \\\n                                EVP_PKEY_OP_DERIVE, \\\n                                EVP_PKEY_CTRL_EC_ECDH_COFACTOR, flag, NULL)\n\n# define EVP_PKEY_CTX_get_ecdh_cofactor_mode(ctx) \\\n        EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_EC, \\\n                                EVP_PKEY_OP_DERIVE, \\\n                                EVP_PKEY_CTRL_EC_ECDH_COFACTOR, -2, NULL)\n\n# define EVP_PKEY_CTX_set_ecdh_kdf_type(ctx, kdf) \\\n        EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_EC, \\\n                                EVP_PKEY_OP_DERIVE, \\\n                                EVP_PKEY_CTRL_EC_KDF_TYPE, kdf, NULL)\n\n# define EVP_PKEY_CTX_get_ecdh_kdf_type(ctx) \\\n        EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_EC, \\\n                                EVP_PKEY_OP_DERIVE, \\\n                                EVP_PKEY_CTRL_EC_KDF_TYPE, -2, NULL)\n\n# define EVP_PKEY_CTX_set_ecdh_kdf_md(ctx, md) \\\n        EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_EC, \\\n                                EVP_PKEY_OP_DERIVE, \\\n                                EVP_PKEY_CTRL_EC_KDF_MD, 0, (void *)md)\n\n# define EVP_PKEY_CTX_get_ecdh_kdf_md(ctx, pmd) \\\n        EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_EC, \\\n                                EVP_PKEY_OP_DERIVE, \\\n                                EVP_PKEY_CTRL_GET_EC_KDF_MD, 0, (void *)pmd)\n\n# define EVP_PKEY_CTX_set_ecdh_kdf_outlen(ctx, len) \\\n        EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_EC, \\\n                                EVP_PKEY_OP_DERIVE, \\\n                                EVP_PKEY_CTRL_EC_KDF_OUTLEN, len, NULL)\n\n# define EVP_PKEY_CTX_get_ecdh_kdf_outlen(ctx, plen) \\\n        EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_EC, \\\n                                EVP_PKEY_OP_DERIVE, \\\n                        EVP_PKEY_CTRL_GET_EC_KDF_OUTLEN, 0, (void *)plen)\n\n# define EVP_PKEY_CTX_set0_ecdh_kdf_ukm(ctx, p, plen) \\\n        EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_EC, \\\n                                EVP_PKEY_OP_DERIVE, \\\n                                EVP_PKEY_CTRL_EC_KDF_UKM, plen, (void *)p)\n\n# define EVP_PKEY_CTX_get0_ecdh_kdf_ukm(ctx, p) \\\n        EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_EC, \\\n                                EVP_PKEY_OP_DERIVE, \\\n                                EVP_PKEY_CTRL_GET_EC_KDF_UKM, 0, (void *)p)\n\n# define EVP_PKEY_CTRL_EC_PARAMGEN_CURVE_NID             (EVP_PKEY_ALG_CTRL + 1)\n# define EVP_PKEY_CTRL_EC_PARAM_ENC                      (EVP_PKEY_ALG_CTRL + 2)\n# define EVP_PKEY_CTRL_EC_ECDH_COFACTOR                  (EVP_PKEY_ALG_CTRL + 3)\n# define EVP_PKEY_CTRL_EC_KDF_TYPE                       (EVP_PKEY_ALG_CTRL + 4)\n# define EVP_PKEY_CTRL_EC_KDF_MD                         (EVP_PKEY_ALG_CTRL + 5)\n# define EVP_PKEY_CTRL_GET_EC_KDF_MD                     (EVP_PKEY_ALG_CTRL + 6)\n# define EVP_PKEY_CTRL_EC_KDF_OUTLEN                     (EVP_PKEY_ALG_CTRL + 7)\n# define EVP_PKEY_CTRL_GET_EC_KDF_OUTLEN                 (EVP_PKEY_ALG_CTRL + 8)\n# define EVP_PKEY_CTRL_EC_KDF_UKM                        (EVP_PKEY_ALG_CTRL + 9)\n# define EVP_PKEY_CTRL_GET_EC_KDF_UKM                    (EVP_PKEY_ALG_CTRL + 10)\n/* KDF types */\n# define EVP_PKEY_ECDH_KDF_NONE                          1\n# define EVP_PKEY_ECDH_KDF_X9_62                         2\n\n/* BEGIN ERROR CODES */\n/*\n * The following lines are auto generated by the script mkerr.pl. Any changes\n * made after this point may be overwritten when the script is next run.\n */\nvoid ERR_load_EC_strings(void);\n\n/* Error codes for the EC functions. */\n\n/* Function codes. */\n# define EC_F_BN_TO_FELEM                                 224\n# define EC_F_COMPUTE_WNAF                                143\n# define EC_F_D2I_ECPARAMETERS                            144\n# define EC_F_D2I_ECPKPARAMETERS                          145\n# define EC_F_D2I_ECPRIVATEKEY                            146\n# define EC_F_DO_EC_KEY_PRINT                             221\n# define EC_F_ECDH_CMS_DECRYPT                            238\n# define EC_F_ECDH_CMS_SET_SHARED_INFO                    239\n# define EC_F_ECKEY_PARAM2TYPE                            223\n# define EC_F_ECKEY_PARAM_DECODE                          212\n# define EC_F_ECKEY_PRIV_DECODE                           213\n# define EC_F_ECKEY_PRIV_ENCODE                           214\n# define EC_F_ECKEY_PUB_DECODE                            215\n# define EC_F_ECKEY_PUB_ENCODE                            216\n# define EC_F_ECKEY_TYPE2PARAM                            220\n# define EC_F_ECPARAMETERS_PRINT                          147\n# define EC_F_ECPARAMETERS_PRINT_FP                       148\n# define EC_F_ECPKPARAMETERS_PRINT                        149\n# define EC_F_ECPKPARAMETERS_PRINT_FP                     150\n# define EC_F_ECP_NISTZ256_GET_AFFINE                     240\n# define EC_F_ECP_NISTZ256_MULT_PRECOMPUTE                243\n# define EC_F_ECP_NISTZ256_POINTS_MUL                     241\n# define EC_F_ECP_NISTZ256_PRE_COMP_NEW                   244\n# define EC_F_ECP_NISTZ256_SET_WORDS                      245\n# define EC_F_ECP_NISTZ256_WINDOWED_MUL                   242\n# define EC_F_ECP_NIST_MOD_192                            203\n# define EC_F_ECP_NIST_MOD_224                            204\n# define EC_F_ECP_NIST_MOD_256                            205\n# define EC_F_ECP_NIST_MOD_521                            206\n# define EC_F_EC_ASN1_GROUP2CURVE                         153\n# define EC_F_EC_ASN1_GROUP2FIELDID                       154\n# define EC_F_EC_ASN1_GROUP2PARAMETERS                    155\n# define EC_F_EC_ASN1_GROUP2PKPARAMETERS                  156\n# define EC_F_EC_ASN1_PARAMETERS2GROUP                    157\n# define EC_F_EC_ASN1_PKPARAMETERS2GROUP                  158\n# define EC_F_EC_EX_DATA_SET_DATA                         211\n# define EC_F_EC_GF2M_MONTGOMERY_POINT_MULTIPLY           208\n# define EC_F_EC_GF2M_SIMPLE_GROUP_CHECK_DISCRIMINANT     159\n# define EC_F_EC_GF2M_SIMPLE_GROUP_SET_CURVE              195\n# define EC_F_EC_GF2M_SIMPLE_OCT2POINT                    160\n# define EC_F_EC_GF2M_SIMPLE_POINT2OCT                    161\n# define EC_F_EC_GF2M_SIMPLE_POINT_GET_AFFINE_COORDINATES 162\n# define EC_F_EC_GF2M_SIMPLE_POINT_SET_AFFINE_COORDINATES 163\n# define EC_F_EC_GF2M_SIMPLE_SET_COMPRESSED_COORDINATES   164\n# define EC_F_EC_GFP_MONT_FIELD_DECODE                    133\n# define EC_F_EC_GFP_MONT_FIELD_ENCODE                    134\n# define EC_F_EC_GFP_MONT_FIELD_MUL                       131\n# define EC_F_EC_GFP_MONT_FIELD_SET_TO_ONE                209\n# define EC_F_EC_GFP_MONT_FIELD_SQR                       132\n# define EC_F_EC_GFP_MONT_GROUP_SET_CURVE                 189\n# define EC_F_EC_GFP_MONT_GROUP_SET_CURVE_GFP             135\n# define EC_F_EC_GFP_NISTP224_GROUP_SET_CURVE             225\n# define EC_F_EC_GFP_NISTP224_POINTS_MUL                  228\n# define EC_F_EC_GFP_NISTP224_POINT_GET_AFFINE_COORDINATES 226\n# define EC_F_EC_GFP_NISTP256_GROUP_SET_CURVE             230\n# define EC_F_EC_GFP_NISTP256_POINTS_MUL                  231\n# define EC_F_EC_GFP_NISTP256_POINT_GET_AFFINE_COORDINATES 232\n# define EC_F_EC_GFP_NISTP521_GROUP_SET_CURVE             233\n# define EC_F_EC_GFP_NISTP521_POINTS_MUL                  234\n# define EC_F_EC_GFP_NISTP521_POINT_GET_AFFINE_COORDINATES 235\n# define EC_F_EC_GFP_NIST_FIELD_MUL                       200\n# define EC_F_EC_GFP_NIST_FIELD_SQR                       201\n# define EC_F_EC_GFP_NIST_GROUP_SET_CURVE                 202\n# define EC_F_EC_GFP_SIMPLE_GROUP_CHECK_DISCRIMINANT      165\n# define EC_F_EC_GFP_SIMPLE_GROUP_SET_CURVE               166\n# define EC_F_EC_GFP_SIMPLE_GROUP_SET_CURVE_GFP           100\n# define EC_F_EC_GFP_SIMPLE_GROUP_SET_GENERATOR           101\n# define EC_F_EC_GFP_SIMPLE_MAKE_AFFINE                   102\n# define EC_F_EC_GFP_SIMPLE_OCT2POINT                     103\n# define EC_F_EC_GFP_SIMPLE_POINT2OCT                     104\n# define EC_F_EC_GFP_SIMPLE_POINTS_MAKE_AFFINE            137\n# define EC_F_EC_GFP_SIMPLE_POINT_GET_AFFINE_COORDINATES  167\n# define EC_F_EC_GFP_SIMPLE_POINT_GET_AFFINE_COORDINATES_GFP 105\n# define EC_F_EC_GFP_SIMPLE_POINT_SET_AFFINE_COORDINATES  168\n# define EC_F_EC_GFP_SIMPLE_POINT_SET_AFFINE_COORDINATES_GFP 128\n# define EC_F_EC_GFP_SIMPLE_SET_COMPRESSED_COORDINATES    169\n# define EC_F_EC_GFP_SIMPLE_SET_COMPRESSED_COORDINATES_GFP 129\n# define EC_F_EC_GROUP_CHECK                              170\n# define EC_F_EC_GROUP_CHECK_DISCRIMINANT                 171\n# define EC_F_EC_GROUP_COPY                               106\n# define EC_F_EC_GROUP_GET0_GENERATOR                     139\n# define EC_F_EC_GROUP_GET_COFACTOR                       140\n# define EC_F_EC_GROUP_GET_CURVE_GF2M                     172\n# define EC_F_EC_GROUP_GET_CURVE_GFP                      130\n# define EC_F_EC_GROUP_GET_DEGREE                         173\n# define EC_F_EC_GROUP_GET_ORDER                          141\n# define EC_F_EC_GROUP_GET_PENTANOMIAL_BASIS              193\n# define EC_F_EC_GROUP_GET_TRINOMIAL_BASIS                194\n# define EC_F_EC_GROUP_NEW                                108\n# define EC_F_EC_GROUP_NEW_BY_CURVE_NAME                  174\n# define EC_F_EC_GROUP_NEW_FROM_DATA                      175\n# define EC_F_EC_GROUP_PRECOMPUTE_MULT                    142\n# define EC_F_EC_GROUP_SET_CURVE_GF2M                     176\n# define EC_F_EC_GROUP_SET_CURVE_GFP                      109\n# define EC_F_EC_GROUP_SET_EXTRA_DATA                     110\n# define EC_F_EC_GROUP_SET_GENERATOR                      111\n# define EC_F_EC_KEY_CHECK_KEY                            177\n# define EC_F_EC_KEY_COPY                                 178\n# define EC_F_EC_KEY_GENERATE_KEY                         179\n# define EC_F_EC_KEY_NEW                                  182\n# define EC_F_EC_KEY_PRINT                                180\n# define EC_F_EC_KEY_PRINT_FP                             181\n# define EC_F_EC_KEY_SET_PUBLIC_KEY_AFFINE_COORDINATES    229\n# define EC_F_EC_POINTS_MAKE_AFFINE                       136\n# define EC_F_EC_POINT_ADD                                112\n# define EC_F_EC_POINT_CMP                                113\n# define EC_F_EC_POINT_COPY                               114\n# define EC_F_EC_POINT_DBL                                115\n# define EC_F_EC_POINT_GET_AFFINE_COORDINATES_GF2M        183\n# define EC_F_EC_POINT_GET_AFFINE_COORDINATES_GFP         116\n# define EC_F_EC_POINT_GET_JPROJECTIVE_COORDINATES_GFP    117\n# define EC_F_EC_POINT_INVERT                             210\n# define EC_F_EC_POINT_IS_AT_INFINITY                     118\n# define EC_F_EC_POINT_IS_ON_CURVE                        119\n# define EC_F_EC_POINT_MAKE_AFFINE                        120\n# define EC_F_EC_POINT_MUL                                184\n# define EC_F_EC_POINT_NEW                                121\n# define EC_F_EC_POINT_OCT2POINT                          122\n# define EC_F_EC_POINT_POINT2OCT                          123\n# define EC_F_EC_POINT_SET_AFFINE_COORDINATES_GF2M        185\n# define EC_F_EC_POINT_SET_AFFINE_COORDINATES_GFP         124\n# define EC_F_EC_POINT_SET_COMPRESSED_COORDINATES_GF2M    186\n# define EC_F_EC_POINT_SET_COMPRESSED_COORDINATES_GFP     125\n# define EC_F_EC_POINT_SET_JPROJECTIVE_COORDINATES_GFP    126\n# define EC_F_EC_POINT_SET_TO_INFINITY                    127\n# define EC_F_EC_PRE_COMP_DUP                             207\n# define EC_F_EC_PRE_COMP_NEW                             196\n# define EC_F_EC_WNAF_MUL                                 187\n# define EC_F_EC_WNAF_PRECOMPUTE_MULT                     188\n# define EC_F_I2D_ECPARAMETERS                            190\n# define EC_F_I2D_ECPKPARAMETERS                          191\n# define EC_F_I2D_ECPRIVATEKEY                            192\n# define EC_F_I2O_ECPUBLICKEY                             151\n# define EC_F_NISTP224_PRE_COMP_NEW                       227\n# define EC_F_NISTP256_PRE_COMP_NEW                       236\n# define EC_F_NISTP521_PRE_COMP_NEW                       237\n# define EC_F_O2I_ECPUBLICKEY                             152\n# define EC_F_OLD_EC_PRIV_DECODE                          222\n# define EC_F_PKEY_EC_CTRL                                197\n# define EC_F_PKEY_EC_CTRL_STR                            198\n# define EC_F_PKEY_EC_DERIVE                              217\n# define EC_F_PKEY_EC_KEYGEN                              199\n# define EC_F_PKEY_EC_PARAMGEN                            219\n# define EC_F_PKEY_EC_SIGN                                218\n\n/* Reason codes. */\n# define EC_R_ASN1_ERROR                                  115\n# define EC_R_ASN1_UNKNOWN_FIELD                          116\n# define EC_R_BIGNUM_OUT_OF_RANGE                         144\n# define EC_R_BUFFER_TOO_SMALL                            100\n# define EC_R_COORDINATES_OUT_OF_RANGE                    146\n# define EC_R_D2I_ECPKPARAMETERS_FAILURE                  117\n# define EC_R_DECODE_ERROR                                142\n# define EC_R_DISCRIMINANT_IS_ZERO                        118\n# define EC_R_EC_GROUP_NEW_BY_NAME_FAILURE                119\n# define EC_R_FIELD_TOO_LARGE                             143\n# define EC_R_GF2M_NOT_SUPPORTED                          147\n# define EC_R_GROUP2PKPARAMETERS_FAILURE                  120\n# define EC_R_I2D_ECPKPARAMETERS_FAILURE                  121\n# define EC_R_INCOMPATIBLE_OBJECTS                        101\n# define EC_R_INVALID_ARGUMENT                            112\n# define EC_R_INVALID_COMPRESSED_POINT                    110\n# define EC_R_INVALID_COMPRESSION_BIT                     109\n# define EC_R_INVALID_CURVE                               141\n# define EC_R_INVALID_DIGEST                              151\n# define EC_R_INVALID_DIGEST_TYPE                         138\n# define EC_R_INVALID_ENCODING                            102\n# define EC_R_INVALID_FIELD                               103\n# define EC_R_INVALID_FORM                                104\n# define EC_R_INVALID_GROUP_ORDER                         122\n# define EC_R_INVALID_PENTANOMIAL_BASIS                   132\n# define EC_R_INVALID_PRIVATE_KEY                         123\n# define EC_R_INVALID_TRINOMIAL_BASIS                     137\n# define EC_R_KDF_PARAMETER_ERROR                         148\n# define EC_R_KEYS_NOT_SET                                140\n# define EC_R_MISSING_PARAMETERS                          124\n# define EC_R_MISSING_PRIVATE_KEY                         125\n# define EC_R_NOT_A_NIST_PRIME                            135\n# define EC_R_NOT_A_SUPPORTED_NIST_PRIME                  136\n# define EC_R_NOT_IMPLEMENTED                             126\n# define EC_R_NOT_INITIALIZED                             111\n# define EC_R_NO_FIELD_MOD                                133\n# define EC_R_NO_PARAMETERS_SET                           139\n# define EC_R_PASSED_NULL_PARAMETER                       134\n# define EC_R_PEER_KEY_ERROR                              149\n# define EC_R_PKPARAMETERS2GROUP_FAILURE                  127\n# define EC_R_POINT_AT_INFINITY                           106\n# define EC_R_POINT_IS_NOT_ON_CURVE                       107\n# define EC_R_SHARED_INFO_ERROR                           150\n# define EC_R_SLOT_FULL                                   108\n# define EC_R_UNDEFINED_GENERATOR                         113\n# define EC_R_UNDEFINED_ORDER                             128\n# define EC_R_UNKNOWN_GROUP                               129\n# define EC_R_UNKNOWN_ORDER                               114\n# define EC_R_UNSUPPORTED_FIELD                           131\n# define EC_R_WRONG_CURVE_PARAMETERS                      145\n# define EC_R_WRONG_ORDER                                 130\n\n#ifdef  __cplusplus\n}\n#endif\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/arm/include/openssl/ecdh.h",
    "content": "/* crypto/ecdh/ecdh.h */\n/* ====================================================================\n * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED.\n *\n * The Elliptic Curve Public-Key Crypto Library (ECC Code) included\n * herein is developed by SUN MICROSYSTEMS, INC., and is contributed\n * to the OpenSSL project.\n *\n * The ECC Code is licensed pursuant to the OpenSSL open source\n * license provided below.\n *\n * The ECDH software is originally written by Douglas Stebila of\n * Sun Microsystems Laboratories.\n *\n */\n/* ====================================================================\n * Copyright (c) 2000-2002 The OpenSSL Project.  All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n *\n * 1. Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n *\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in\n *    the documentation and/or other materials provided with the\n *    distribution.\n *\n * 3. All advertising materials mentioning features or use of this\n *    software must display the following acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)\"\n *\n * 4. The names \"OpenSSL Toolkit\" and \"OpenSSL Project\" must not be used to\n *    endorse or promote products derived from this software without\n *    prior written permission. For written permission, please contact\n *    licensing@OpenSSL.org.\n *\n * 5. Products derived from this software may not be called \"OpenSSL\"\n *    nor may \"OpenSSL\" appear in their names without prior written\n *    permission of the OpenSSL Project.\n *\n * 6. Redistributions of any form whatsoever must retain the following\n *    acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)\"\n *\n * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY\n * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\n * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR\n * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\n * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,\n * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED\n * OF THE POSSIBILITY OF SUCH DAMAGE.\n * ====================================================================\n *\n * This product includes cryptographic software written by Eric Young\n * (eay@cryptsoft.com).  This product includes software written by Tim\n * Hudson (tjh@cryptsoft.com).\n *\n */\n#ifndef HEADER_ECDH_H\n# define HEADER_ECDH_H\n\n# include <openssl/opensslconf.h>\n\n# ifdef OPENSSL_NO_ECDH\n#  error ECDH is disabled.\n# endif\n\n# include <openssl/ec.h>\n# include <openssl/ossl_typ.h>\n# ifndef OPENSSL_NO_DEPRECATED\n#  include <openssl/bn.h>\n# endif\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n# define EC_FLAG_COFACTOR_ECDH   0x1000\n\nconst ECDH_METHOD *ECDH_OpenSSL(void);\n\nvoid ECDH_set_default_method(const ECDH_METHOD *);\nconst ECDH_METHOD *ECDH_get_default_method(void);\nint ECDH_set_method(EC_KEY *, const ECDH_METHOD *);\n\nint ECDH_compute_key(void *out, size_t outlen, const EC_POINT *pub_key,\n                     EC_KEY *ecdh, void *(*KDF) (const void *in, size_t inlen,\n                                                 void *out, size_t *outlen));\n\nint ECDH_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new\n                          *new_func, CRYPTO_EX_dup *dup_func,\n                          CRYPTO_EX_free *free_func);\nint ECDH_set_ex_data(EC_KEY *d, int idx, void *arg);\nvoid *ECDH_get_ex_data(EC_KEY *d, int idx);\n\nint ECDH_KDF_X9_62(unsigned char *out, size_t outlen,\n                   const unsigned char *Z, size_t Zlen,\n                   const unsigned char *sinfo, size_t sinfolen,\n                   const EVP_MD *md);\n\n/* BEGIN ERROR CODES */\n/*\n * The following lines are auto generated by the script mkerr.pl. Any changes\n * made after this point may be overwritten when the script is next run.\n */\nvoid ERR_load_ECDH_strings(void);\n\n/* Error codes for the ECDH functions. */\n\n/* Function codes. */\n# define ECDH_F_ECDH_CHECK                                102\n# define ECDH_F_ECDH_COMPUTE_KEY                          100\n# define ECDH_F_ECDH_DATA_NEW_METHOD                      101\n\n/* Reason codes. */\n# define ECDH_R_KDF_FAILED                                102\n# define ECDH_R_NON_FIPS_METHOD                           103\n# define ECDH_R_NO_PRIVATE_VALUE                          100\n# define ECDH_R_POINT_ARITHMETIC_FAILURE                  101\n\n#ifdef  __cplusplus\n}\n#endif\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/arm/include/openssl/ecdsa.h",
    "content": "/* crypto/ecdsa/ecdsa.h */\n/**\n * \\file   crypto/ecdsa/ecdsa.h Include file for the OpenSSL ECDSA functions\n * \\author Written by Nils Larsch for the OpenSSL project\n */\n/* ====================================================================\n * Copyright (c) 2000-2005 The OpenSSL Project.  All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n *\n * 1. Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n *\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in\n *    the documentation and/or other materials provided with the\n *    distribution.\n *\n * 3. All advertising materials mentioning features or use of this\n *    software must display the following acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)\"\n *\n * 4. The names \"OpenSSL Toolkit\" and \"OpenSSL Project\" must not be used to\n *    endorse or promote products derived from this software without\n *    prior written permission. For written permission, please contact\n *    licensing@OpenSSL.org.\n *\n * 5. Products derived from this software may not be called \"OpenSSL\"\n *    nor may \"OpenSSL\" appear in their names without prior written\n *    permission of the OpenSSL Project.\n *\n * 6. Redistributions of any form whatsoever must retain the following\n *    acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)\"\n *\n * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY\n * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\n * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR\n * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\n * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,\n * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED\n * OF THE POSSIBILITY OF SUCH DAMAGE.\n * ====================================================================\n *\n * This product includes cryptographic software written by Eric Young\n * (eay@cryptsoft.com).  This product includes software written by Tim\n * Hudson (tjh@cryptsoft.com).\n *\n */\n#ifndef HEADER_ECDSA_H\n# define HEADER_ECDSA_H\n\n# include <openssl/opensslconf.h>\n\n# ifdef OPENSSL_NO_ECDSA\n#  error ECDSA is disabled.\n# endif\n\n# include <openssl/ec.h>\n# include <openssl/ossl_typ.h>\n# ifndef OPENSSL_NO_DEPRECATED\n#  include <openssl/bn.h>\n# endif\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\ntypedef struct ECDSA_SIG_st {\n    BIGNUM *r;\n    BIGNUM *s;\n} ECDSA_SIG;\n\n/** Allocates and initialize a ECDSA_SIG structure\n *  \\return pointer to a ECDSA_SIG structure or NULL if an error occurred\n */\nECDSA_SIG *ECDSA_SIG_new(void);\n\n/** frees a ECDSA_SIG structure\n *  \\param  sig  pointer to the ECDSA_SIG structure\n */\nvoid ECDSA_SIG_free(ECDSA_SIG *sig);\n\n/** DER encode content of ECDSA_SIG object (note: this function modifies *pp\n *  (*pp += length of the DER encoded signature)).\n *  \\param  sig  pointer to the ECDSA_SIG object\n *  \\param  pp   pointer to a unsigned char pointer for the output or NULL\n *  \\return the length of the DER encoded ECDSA_SIG object or 0\n */\nint i2d_ECDSA_SIG(const ECDSA_SIG *sig, unsigned char **pp);\n\n/** Decodes a DER encoded ECDSA signature (note: this function changes *pp\n *  (*pp += len)).\n *  \\param  sig  pointer to ECDSA_SIG pointer (may be NULL)\n *  \\param  pp   memory buffer with the DER encoded signature\n *  \\param  len  length of the buffer\n *  \\return pointer to the decoded ECDSA_SIG structure (or NULL)\n */\nECDSA_SIG *d2i_ECDSA_SIG(ECDSA_SIG **sig, const unsigned char **pp, long len);\n\n/** Computes the ECDSA signature of the given hash value using\n *  the supplied private key and returns the created signature.\n *  \\param  dgst      pointer to the hash value\n *  \\param  dgst_len  length of the hash value\n *  \\param  eckey     EC_KEY object containing a private EC key\n *  \\return pointer to a ECDSA_SIG structure or NULL if an error occurred\n */\nECDSA_SIG *ECDSA_do_sign(const unsigned char *dgst, int dgst_len,\n                         EC_KEY *eckey);\n\n/** Computes ECDSA signature of a given hash value using the supplied\n *  private key (note: sig must point to ECDSA_size(eckey) bytes of memory).\n *  \\param  dgst     pointer to the hash value to sign\n *  \\param  dgstlen  length of the hash value\n *  \\param  kinv     BIGNUM with a pre-computed inverse k (optional)\n *  \\param  rp       BIGNUM with a pre-computed rp value (optioanl),\n *                   see ECDSA_sign_setup\n *  \\param  eckey    EC_KEY object containing a private EC key\n *  \\return pointer to a ECDSA_SIG structure or NULL if an error occurred\n */\nECDSA_SIG *ECDSA_do_sign_ex(const unsigned char *dgst, int dgstlen,\n                            const BIGNUM *kinv, const BIGNUM *rp,\n                            EC_KEY *eckey);\n\n/** Verifies that the supplied signature is a valid ECDSA\n *  signature of the supplied hash value using the supplied public key.\n *  \\param  dgst      pointer to the hash value\n *  \\param  dgst_len  length of the hash value\n *  \\param  sig       ECDSA_SIG structure\n *  \\param  eckey     EC_KEY object containing a public EC key\n *  \\return 1 if the signature is valid, 0 if the signature is invalid\n *          and -1 on error\n */\nint ECDSA_do_verify(const unsigned char *dgst, int dgst_len,\n                    const ECDSA_SIG *sig, EC_KEY *eckey);\n\nconst ECDSA_METHOD *ECDSA_OpenSSL(void);\n\n/** Sets the default ECDSA method\n *  \\param  meth  new default ECDSA_METHOD\n */\nvoid ECDSA_set_default_method(const ECDSA_METHOD *meth);\n\n/** Returns the default ECDSA method\n *  \\return pointer to ECDSA_METHOD structure containing the default method\n */\nconst ECDSA_METHOD *ECDSA_get_default_method(void);\n\n/** Sets method to be used for the ECDSA operations\n *  \\param  eckey  EC_KEY object\n *  \\param  meth   new method\n *  \\return 1 on success and 0 otherwise\n */\nint ECDSA_set_method(EC_KEY *eckey, const ECDSA_METHOD *meth);\n\n/** Returns the maximum length of the DER encoded signature\n *  \\param  eckey  EC_KEY object\n *  \\return numbers of bytes required for the DER encoded signature\n */\nint ECDSA_size(const EC_KEY *eckey);\n\n/** Precompute parts of the signing operation\n *  \\param  eckey  EC_KEY object containing a private EC key\n *  \\param  ctx    BN_CTX object (optional)\n *  \\param  kinv   BIGNUM pointer for the inverse of k\n *  \\param  rp     BIGNUM pointer for x coordinate of k * generator\n *  \\return 1 on success and 0 otherwise\n */\nint ECDSA_sign_setup(EC_KEY *eckey, BN_CTX *ctx, BIGNUM **kinv, BIGNUM **rp);\n\n/** Computes ECDSA signature of a given hash value using the supplied\n *  private key (note: sig must point to ECDSA_size(eckey) bytes of memory).\n *  \\param  type     this parameter is ignored\n *  \\param  dgst     pointer to the hash value to sign\n *  \\param  dgstlen  length of the hash value\n *  \\param  sig      memory for the DER encoded created signature\n *  \\param  siglen   pointer to the length of the returned signature\n *  \\param  eckey    EC_KEY object containing a private EC key\n *  \\return 1 on success and 0 otherwise\n */\nint ECDSA_sign(int type, const unsigned char *dgst, int dgstlen,\n               unsigned char *sig, unsigned int *siglen, EC_KEY *eckey);\n\n/** Computes ECDSA signature of a given hash value using the supplied\n *  private key (note: sig must point to ECDSA_size(eckey) bytes of memory).\n *  \\param  type     this parameter is ignored\n *  \\param  dgst     pointer to the hash value to sign\n *  \\param  dgstlen  length of the hash value\n *  \\param  sig      buffer to hold the DER encoded signature\n *  \\param  siglen   pointer to the length of the returned signature\n *  \\param  kinv     BIGNUM with a pre-computed inverse k (optional)\n *  \\param  rp       BIGNUM with a pre-computed rp value (optioanl),\n *                   see ECDSA_sign_setup\n *  \\param  eckey    EC_KEY object containing a private EC key\n *  \\return 1 on success and 0 otherwise\n */\nint ECDSA_sign_ex(int type, const unsigned char *dgst, int dgstlen,\n                  unsigned char *sig, unsigned int *siglen,\n                  const BIGNUM *kinv, const BIGNUM *rp, EC_KEY *eckey);\n\n/** Verifies that the given signature is valid ECDSA signature\n *  of the supplied hash value using the specified public key.\n *  \\param  type     this parameter is ignored\n *  \\param  dgst     pointer to the hash value\n *  \\param  dgstlen  length of the hash value\n *  \\param  sig      pointer to the DER encoded signature\n *  \\param  siglen   length of the DER encoded signature\n *  \\param  eckey    EC_KEY object containing a public EC key\n *  \\return 1 if the signature is valid, 0 if the signature is invalid\n *          and -1 on error\n */\nint ECDSA_verify(int type, const unsigned char *dgst, int dgstlen,\n                 const unsigned char *sig, int siglen, EC_KEY *eckey);\n\n/* the standard ex_data functions */\nint ECDSA_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new\n                           *new_func, CRYPTO_EX_dup *dup_func,\n                           CRYPTO_EX_free *free_func);\nint ECDSA_set_ex_data(EC_KEY *d, int idx, void *arg);\nvoid *ECDSA_get_ex_data(EC_KEY *d, int idx);\n\n/** Allocates and initialize a ECDSA_METHOD structure\n *  \\param ecdsa_method pointer to ECDSA_METHOD to copy.  (May be NULL)\n *  \\return pointer to a ECDSA_METHOD structure or NULL if an error occurred\n */\n\nECDSA_METHOD *ECDSA_METHOD_new(const ECDSA_METHOD *ecdsa_method);\n\n/** frees a ECDSA_METHOD structure\n *  \\param  ecdsa_method  pointer to the ECDSA_METHOD structure\n */\nvoid ECDSA_METHOD_free(ECDSA_METHOD *ecdsa_method);\n\n/**  Sets application specific data in the ECDSA_METHOD\n *   \\param  ecdsa_method pointer to existing ECDSA_METHOD\n *   \\param  app application specific data to set\n */\n\nvoid ECDSA_METHOD_set_app_data(ECDSA_METHOD *ecdsa_method, void *app);\n\n/** Returns application specific data from a ECDSA_METHOD structure\n *  \\param ecdsa_method pointer to ECDSA_METHOD structure\n *  \\return pointer to application specific data.\n */\n\nvoid *ECDSA_METHOD_get_app_data(ECDSA_METHOD *ecdsa_method);\n\n/**  Set the ECDSA_do_sign function in the ECDSA_METHOD\n *   \\param  ecdsa_method  pointer to existing ECDSA_METHOD\n *   \\param  ecdsa_do_sign a funtion of type ECDSA_do_sign\n */\n\nvoid ECDSA_METHOD_set_sign(ECDSA_METHOD *ecdsa_method,\n                           ECDSA_SIG *(*ecdsa_do_sign) (const unsigned char\n                                                        *dgst, int dgst_len,\n                                                        const BIGNUM *inv,\n                                                        const BIGNUM *rp,\n                                                        EC_KEY *eckey));\n\n/**  Set the  ECDSA_sign_setup function in the ECDSA_METHOD\n *   \\param  ecdsa_method  pointer to existing ECDSA_METHOD\n *   \\param  ecdsa_sign_setup a funtion of type ECDSA_sign_setup\n */\n\nvoid ECDSA_METHOD_set_sign_setup(ECDSA_METHOD *ecdsa_method,\n                                 int (*ecdsa_sign_setup) (EC_KEY *eckey,\n                                                          BN_CTX *ctx,\n                                                          BIGNUM **kinv,\n                                                          BIGNUM **r));\n\n/**  Set the ECDSA_do_verify function in the ECDSA_METHOD\n *   \\param  ecdsa_method  pointer to existing ECDSA_METHOD\n *   \\param  ecdsa_do_verify a funtion of type ECDSA_do_verify\n */\n\nvoid ECDSA_METHOD_set_verify(ECDSA_METHOD *ecdsa_method,\n                             int (*ecdsa_do_verify) (const unsigned char\n                                                     *dgst, int dgst_len,\n                                                     const ECDSA_SIG *sig,\n                                                     EC_KEY *eckey));\n\nvoid ECDSA_METHOD_set_flags(ECDSA_METHOD *ecdsa_method, int flags);\n\n/**  Set the flags field in the ECDSA_METHOD\n *   \\param  ecdsa_method  pointer to existing ECDSA_METHOD\n *   \\param  flags flags value to set\n */\n\nvoid ECDSA_METHOD_set_name(ECDSA_METHOD *ecdsa_method, char *name);\n\n/**  Set the name field in the ECDSA_METHOD\n *   \\param  ecdsa_method  pointer to existing ECDSA_METHOD\n *   \\param  name name to set\n */\n\n/* BEGIN ERROR CODES */\n/*\n * The following lines are auto generated by the script mkerr.pl. Any changes\n * made after this point may be overwritten when the script is next run.\n */\nvoid ERR_load_ECDSA_strings(void);\n\n/* Error codes for the ECDSA functions. */\n\n/* Function codes. */\n# define ECDSA_F_ECDSA_CHECK                              104\n# define ECDSA_F_ECDSA_DATA_NEW_METHOD                    100\n# define ECDSA_F_ECDSA_DO_SIGN                            101\n# define ECDSA_F_ECDSA_DO_VERIFY                          102\n# define ECDSA_F_ECDSA_METHOD_NEW                         105\n# define ECDSA_F_ECDSA_SIGN_SETUP                         103\n\n/* Reason codes. */\n# define ECDSA_R_BAD_SIGNATURE                            100\n# define ECDSA_R_DATA_TOO_LARGE_FOR_KEY_SIZE              101\n# define ECDSA_R_ERR_EC_LIB                               102\n# define ECDSA_R_MISSING_PARAMETERS                       103\n# define ECDSA_R_NEED_NEW_SETUP_VALUES                    106\n# define ECDSA_R_NON_FIPS_METHOD                          107\n# define ECDSA_R_RANDOM_NUMBER_GENERATION_FAILED          104\n# define ECDSA_R_SIGNATURE_MALLOC_FAILED                  105\n\n#ifdef  __cplusplus\n}\n#endif\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/arm/include/openssl/err.h",
    "content": "/* crypto/err/err.h */\n/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)\n * All rights reserved.\n *\n * This package is an SSL implementation written\n * by Eric Young (eay@cryptsoft.com).\n * The implementation was written so as to conform with Netscapes SSL.\n *\n * This library is free for commercial and non-commercial use as long as\n * the following conditions are aheared to.  The following conditions\n * apply to all code found in this distribution, be it the RC4, RSA,\n * lhash, DES, etc., code; not just the SSL code.  The SSL documentation\n * included with this distribution is covered by the same copyright terms\n * except that the holder is Tim Hudson (tjh@cryptsoft.com).\n *\n * Copyright remains Eric Young's, and as such any Copyright notices in\n * the code are not to be removed.\n * If this package is used in a product, Eric Young should be given attribution\n * as the author of the parts of the library used.\n * This can be in the form of a textual message at program startup or\n * in documentation (online or textual) provided with the package.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the copyright\n *    notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in the\n *    documentation and/or other materials provided with the distribution.\n * 3. All advertising materials mentioning features or use of this software\n *    must display the following acknowledgement:\n *    \"This product includes cryptographic software written by\n *     Eric Young (eay@cryptsoft.com)\"\n *    The word 'cryptographic' can be left out if the rouines from the library\n *    being used are not cryptographic related :-).\n * 4. If you include any Windows specific code (or a derivative thereof) from\n *    the apps directory (application code) you must include an acknowledgement:\n *    \"This product includes software written by Tim Hudson (tjh@cryptsoft.com)\"\n *\n * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n * SUCH DAMAGE.\n *\n * The licence and distribution terms for any publically available version or\n * derivative of this code cannot be changed.  i.e. this code cannot simply be\n * copied and put under another distribution licence\n * [including the GNU Public Licence.]\n */\n/* ====================================================================\n * Copyright (c) 1998-2006 The OpenSSL Project.  All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n *\n * 1. Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n *\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in\n *    the documentation and/or other materials provided with the\n *    distribution.\n *\n * 3. All advertising materials mentioning features or use of this\n *    software must display the following acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit. (http://www.openssl.org/)\"\n *\n * 4. The names \"OpenSSL Toolkit\" and \"OpenSSL Project\" must not be used to\n *    endorse or promote products derived from this software without\n *    prior written permission. For written permission, please contact\n *    openssl-core@openssl.org.\n *\n * 5. Products derived from this software may not be called \"OpenSSL\"\n *    nor may \"OpenSSL\" appear in their names without prior written\n *    permission of the OpenSSL Project.\n *\n * 6. Redistributions of any form whatsoever must retain the following\n *    acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit (http://www.openssl.org/)\"\n *\n * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY\n * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\n * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR\n * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\n * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,\n * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED\n * OF THE POSSIBILITY OF SUCH DAMAGE.\n * ====================================================================\n *\n * This product includes cryptographic software written by Eric Young\n * (eay@cryptsoft.com).  This product includes software written by Tim\n * Hudson (tjh@cryptsoft.com).\n *\n */\n\n#ifndef HEADER_ERR_H\n# define HEADER_ERR_H\n\n# include <openssl/e_os2.h>\n\n# ifndef OPENSSL_NO_FP_API\n#  include <stdio.h>\n#  include <stdlib.h>\n# endif\n\n# include <openssl/ossl_typ.h>\n# ifndef OPENSSL_NO_BIO\n#  include <openssl/bio.h>\n# endif\n# ifndef OPENSSL_NO_LHASH\n#  include <openssl/lhash.h>\n# endif\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n# ifndef OPENSSL_NO_ERR\n#  define ERR_PUT_error(a,b,c,d,e)        ERR_put_error(a,b,c,d,e)\n# else\n#  define ERR_PUT_error(a,b,c,d,e)        ERR_put_error(a,b,c,NULL,0)\n# endif\n\n# include <errno.h>\n\n# define ERR_TXT_MALLOCED        0x01\n# define ERR_TXT_STRING          0x02\n\n# define ERR_FLAG_MARK           0x01\n\n# define ERR_NUM_ERRORS  16\ntypedef struct err_state_st {\n    CRYPTO_THREADID tid;\n    int err_flags[ERR_NUM_ERRORS];\n    unsigned long err_buffer[ERR_NUM_ERRORS];\n    char *err_data[ERR_NUM_ERRORS];\n    int err_data_flags[ERR_NUM_ERRORS];\n    const char *err_file[ERR_NUM_ERRORS];\n    int err_line[ERR_NUM_ERRORS];\n    int top, bottom;\n} ERR_STATE;\n\n/* library */\n# define ERR_LIB_NONE            1\n# define ERR_LIB_SYS             2\n# define ERR_LIB_BN              3\n# define ERR_LIB_RSA             4\n# define ERR_LIB_DH              5\n# define ERR_LIB_EVP             6\n# define ERR_LIB_BUF             7\n# define ERR_LIB_OBJ             8\n# define ERR_LIB_PEM             9\n# define ERR_LIB_DSA             10\n# define ERR_LIB_X509            11\n/* #define ERR_LIB_METH         12 */\n# define ERR_LIB_ASN1            13\n# define ERR_LIB_CONF            14\n# define ERR_LIB_CRYPTO          15\n# define ERR_LIB_EC              16\n# define ERR_LIB_SSL             20\n/* #define ERR_LIB_SSL23        21 */\n/* #define ERR_LIB_SSL2         22 */\n/* #define ERR_LIB_SSL3         23 */\n/* #define ERR_LIB_RSAREF       30 */\n/* #define ERR_LIB_PROXY        31 */\n# define ERR_LIB_BIO             32\n# define ERR_LIB_PKCS7           33\n# define ERR_LIB_X509V3          34\n# define ERR_LIB_PKCS12          35\n# define ERR_LIB_RAND            36\n# define ERR_LIB_DSO             37\n# define ERR_LIB_ENGINE          38\n# define ERR_LIB_OCSP            39\n# define ERR_LIB_UI              40\n# define ERR_LIB_COMP            41\n# define ERR_LIB_ECDSA           42\n# define ERR_LIB_ECDH            43\n# define ERR_LIB_STORE           44\n# define ERR_LIB_FIPS            45\n# define ERR_LIB_CMS             46\n# define ERR_LIB_TS              47\n# define ERR_LIB_HMAC            48\n# define ERR_LIB_JPAKE           49\n\n# define ERR_LIB_USER            128\n\n# define SYSerr(f,r)  ERR_PUT_error(ERR_LIB_SYS,(f),(r),__FILE__,__LINE__)\n# define BNerr(f,r)   ERR_PUT_error(ERR_LIB_BN,(f),(r),__FILE__,__LINE__)\n# define RSAerr(f,r)  ERR_PUT_error(ERR_LIB_RSA,(f),(r),__FILE__,__LINE__)\n# define DHerr(f,r)   ERR_PUT_error(ERR_LIB_DH,(f),(r),__FILE__,__LINE__)\n# define EVPerr(f,r)  ERR_PUT_error(ERR_LIB_EVP,(f),(r),__FILE__,__LINE__)\n# define BUFerr(f,r)  ERR_PUT_error(ERR_LIB_BUF,(f),(r),__FILE__,__LINE__)\n# define OBJerr(f,r)  ERR_PUT_error(ERR_LIB_OBJ,(f),(r),__FILE__,__LINE__)\n# define PEMerr(f,r)  ERR_PUT_error(ERR_LIB_PEM,(f),(r),__FILE__,__LINE__)\n# define DSAerr(f,r)  ERR_PUT_error(ERR_LIB_DSA,(f),(r),__FILE__,__LINE__)\n# define X509err(f,r) ERR_PUT_error(ERR_LIB_X509,(f),(r),__FILE__,__LINE__)\n# define ASN1err(f,r) ERR_PUT_error(ERR_LIB_ASN1,(f),(r),__FILE__,__LINE__)\n# define CONFerr(f,r) ERR_PUT_error(ERR_LIB_CONF,(f),(r),__FILE__,__LINE__)\n# define CRYPTOerr(f,r) ERR_PUT_error(ERR_LIB_CRYPTO,(f),(r),__FILE__,__LINE__)\n# define ECerr(f,r)   ERR_PUT_error(ERR_LIB_EC,(f),(r),__FILE__,__LINE__)\n# define SSLerr(f,r)  ERR_PUT_error(ERR_LIB_SSL,(f),(r),__FILE__,__LINE__)\n# define BIOerr(f,r)  ERR_PUT_error(ERR_LIB_BIO,(f),(r),__FILE__,__LINE__)\n# define PKCS7err(f,r) ERR_PUT_error(ERR_LIB_PKCS7,(f),(r),__FILE__,__LINE__)\n# define X509V3err(f,r) ERR_PUT_error(ERR_LIB_X509V3,(f),(r),__FILE__,__LINE__)\n# define PKCS12err(f,r) ERR_PUT_error(ERR_LIB_PKCS12,(f),(r),__FILE__,__LINE__)\n# define RANDerr(f,r) ERR_PUT_error(ERR_LIB_RAND,(f),(r),__FILE__,__LINE__)\n# define DSOerr(f,r) ERR_PUT_error(ERR_LIB_DSO,(f),(r),__FILE__,__LINE__)\n# define ENGINEerr(f,r) ERR_PUT_error(ERR_LIB_ENGINE,(f),(r),__FILE__,__LINE__)\n# define OCSPerr(f,r) ERR_PUT_error(ERR_LIB_OCSP,(f),(r),__FILE__,__LINE__)\n# define UIerr(f,r) ERR_PUT_error(ERR_LIB_UI,(f),(r),__FILE__,__LINE__)\n# define COMPerr(f,r) ERR_PUT_error(ERR_LIB_COMP,(f),(r),__FILE__,__LINE__)\n# define ECDSAerr(f,r)  ERR_PUT_error(ERR_LIB_ECDSA,(f),(r),__FILE__,__LINE__)\n# define ECDHerr(f,r)  ERR_PUT_error(ERR_LIB_ECDH,(f),(r),__FILE__,__LINE__)\n# define STOREerr(f,r) ERR_PUT_error(ERR_LIB_STORE,(f),(r),__FILE__,__LINE__)\n# define FIPSerr(f,r) ERR_PUT_error(ERR_LIB_FIPS,(f),(r),__FILE__,__LINE__)\n# define CMSerr(f,r) ERR_PUT_error(ERR_LIB_CMS,(f),(r),__FILE__,__LINE__)\n# define TSerr(f,r) ERR_PUT_error(ERR_LIB_TS,(f),(r),__FILE__,__LINE__)\n# define HMACerr(f,r) ERR_PUT_error(ERR_LIB_HMAC,(f),(r),__FILE__,__LINE__)\n# define JPAKEerr(f,r) ERR_PUT_error(ERR_LIB_JPAKE,(f),(r),__FILE__,__LINE__)\n\n/*\n * Borland C seems too stupid to be able to shift and do longs in the\n * pre-processor :-(\n */\n# define ERR_PACK(l,f,r)         (((((unsigned long)l)&0xffL)*0x1000000)| \\\n                                ((((unsigned long)f)&0xfffL)*0x1000)| \\\n                                ((((unsigned long)r)&0xfffL)))\n# define ERR_GET_LIB(l)          (int)((((unsigned long)l)>>24L)&0xffL)\n# define ERR_GET_FUNC(l)         (int)((((unsigned long)l)>>12L)&0xfffL)\n# define ERR_GET_REASON(l)       (int)((l)&0xfffL)\n# define ERR_FATAL_ERROR(l)      (int)((l)&ERR_R_FATAL)\n\n/* OS functions */\n# define SYS_F_FOPEN             1\n# define SYS_F_CONNECT           2\n# define SYS_F_GETSERVBYNAME     3\n# define SYS_F_SOCKET            4\n# define SYS_F_IOCTLSOCKET       5\n# define SYS_F_BIND              6\n# define SYS_F_LISTEN            7\n# define SYS_F_ACCEPT            8\n# define SYS_F_WSASTARTUP        9/* Winsock stuff */\n# define SYS_F_OPENDIR           10\n# define SYS_F_FREAD             11\n\n/* reasons */\n# define ERR_R_SYS_LIB   ERR_LIB_SYS/* 2 */\n# define ERR_R_BN_LIB    ERR_LIB_BN/* 3 */\n# define ERR_R_RSA_LIB   ERR_LIB_RSA/* 4 */\n# define ERR_R_DH_LIB    ERR_LIB_DH/* 5 */\n# define ERR_R_EVP_LIB   ERR_LIB_EVP/* 6 */\n# define ERR_R_BUF_LIB   ERR_LIB_BUF/* 7 */\n# define ERR_R_OBJ_LIB   ERR_LIB_OBJ/* 8 */\n# define ERR_R_PEM_LIB   ERR_LIB_PEM/* 9 */\n# define ERR_R_DSA_LIB   ERR_LIB_DSA/* 10 */\n# define ERR_R_X509_LIB  ERR_LIB_X509/* 11 */\n# define ERR_R_ASN1_LIB  ERR_LIB_ASN1/* 13 */\n# define ERR_R_CONF_LIB  ERR_LIB_CONF/* 14 */\n# define ERR_R_CRYPTO_LIB ERR_LIB_CRYPTO/* 15 */\n# define ERR_R_EC_LIB    ERR_LIB_EC/* 16 */\n# define ERR_R_SSL_LIB   ERR_LIB_SSL/* 20 */\n# define ERR_R_BIO_LIB   ERR_LIB_BIO/* 32 */\n# define ERR_R_PKCS7_LIB ERR_LIB_PKCS7/* 33 */\n# define ERR_R_X509V3_LIB ERR_LIB_X509V3/* 34 */\n# define ERR_R_PKCS12_LIB ERR_LIB_PKCS12/* 35 */\n# define ERR_R_RAND_LIB  ERR_LIB_RAND/* 36 */\n# define ERR_R_DSO_LIB   ERR_LIB_DSO/* 37 */\n# define ERR_R_ENGINE_LIB ERR_LIB_ENGINE/* 38 */\n# define ERR_R_OCSP_LIB  ERR_LIB_OCSP/* 39 */\n# define ERR_R_UI_LIB    ERR_LIB_UI/* 40 */\n# define ERR_R_COMP_LIB  ERR_LIB_COMP/* 41 */\n# define ERR_R_ECDSA_LIB ERR_LIB_ECDSA/* 42 */\n# define ERR_R_ECDH_LIB  ERR_LIB_ECDH/* 43 */\n# define ERR_R_STORE_LIB ERR_LIB_STORE/* 44 */\n# define ERR_R_TS_LIB    ERR_LIB_TS/* 45 */\n\n# define ERR_R_NESTED_ASN1_ERROR                 58\n# define ERR_R_BAD_ASN1_OBJECT_HEADER            59\n# define ERR_R_BAD_GET_ASN1_OBJECT_CALL          60\n# define ERR_R_EXPECTING_AN_ASN1_SEQUENCE        61\n# define ERR_R_ASN1_LENGTH_MISMATCH              62\n# define ERR_R_MISSING_ASN1_EOS                  63\n\n/* fatal error */\n# define ERR_R_FATAL                             64\n# define ERR_R_MALLOC_FAILURE                    (1|ERR_R_FATAL)\n# define ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED       (2|ERR_R_FATAL)\n# define ERR_R_PASSED_NULL_PARAMETER             (3|ERR_R_FATAL)\n# define ERR_R_INTERNAL_ERROR                    (4|ERR_R_FATAL)\n# define ERR_R_DISABLED                          (5|ERR_R_FATAL)\n\n/*\n * 99 is the maximum possible ERR_R_... code, higher values are reserved for\n * the individual libraries\n */\n\ntypedef struct ERR_string_data_st {\n    unsigned long error;\n    const char *string;\n} ERR_STRING_DATA;\n\nvoid ERR_put_error(int lib, int func, int reason, const char *file, int line);\nvoid ERR_set_error_data(char *data, int flags);\n\nunsigned long ERR_get_error(void);\nunsigned long ERR_get_error_line(const char **file, int *line);\nunsigned long ERR_get_error_line_data(const char **file, int *line,\n                                      const char **data, int *flags);\nunsigned long ERR_peek_error(void);\nunsigned long ERR_peek_error_line(const char **file, int *line);\nunsigned long ERR_peek_error_line_data(const char **file, int *line,\n                                       const char **data, int *flags);\nunsigned long ERR_peek_last_error(void);\nunsigned long ERR_peek_last_error_line(const char **file, int *line);\nunsigned long ERR_peek_last_error_line_data(const char **file, int *line,\n                                            const char **data, int *flags);\nvoid ERR_clear_error(void);\nchar *ERR_error_string(unsigned long e, char *buf);\nvoid ERR_error_string_n(unsigned long e, char *buf, size_t len);\nconst char *ERR_lib_error_string(unsigned long e);\nconst char *ERR_func_error_string(unsigned long e);\nconst char *ERR_reason_error_string(unsigned long e);\nvoid ERR_print_errors_cb(int (*cb) (const char *str, size_t len, void *u),\n                         void *u);\n# ifndef OPENSSL_NO_FP_API\nvoid ERR_print_errors_fp(FILE *fp);\n# endif\n# ifndef OPENSSL_NO_BIO\nvoid ERR_print_errors(BIO *bp);\n# endif\nvoid ERR_add_error_data(int num, ...);\nvoid ERR_add_error_vdata(int num, va_list args);\nvoid ERR_load_strings(int lib, ERR_STRING_DATA str[]);\nvoid ERR_unload_strings(int lib, ERR_STRING_DATA str[]);\nvoid ERR_load_ERR_strings(void);\nvoid ERR_load_crypto_strings(void);\nvoid ERR_free_strings(void);\n\nvoid ERR_remove_thread_state(const CRYPTO_THREADID *tid);\n# ifndef OPENSSL_NO_DEPRECATED\nvoid ERR_remove_state(unsigned long pid); /* if zero we look it up */\n# endif\nERR_STATE *ERR_get_state(void);\n\n# ifndef OPENSSL_NO_LHASH\nLHASH_OF(ERR_STRING_DATA) *ERR_get_string_table(void);\nLHASH_OF(ERR_STATE) *ERR_get_err_state_table(void);\nvoid ERR_release_err_state_table(LHASH_OF(ERR_STATE) **hash);\n# endif\n\nint ERR_get_next_error_library(void);\n\nint ERR_set_mark(void);\nint ERR_pop_to_mark(void);\n\n/* Already defined in ossl_typ.h */\n/* typedef struct st_ERR_FNS ERR_FNS; */\n/*\n * An application can use this function and provide the return value to\n * loaded modules that should use the application's ERR state/functionality\n */\nconst ERR_FNS *ERR_get_implementation(void);\n/*\n * A loaded module should call this function prior to any ERR operations\n * using the application's \"ERR_FNS\".\n */\nint ERR_set_implementation(const ERR_FNS *fns);\n\n#ifdef  __cplusplus\n}\n#endif\n\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/arm/include/openssl/evp.h",
    "content": "/* crypto/evp/evp.h */\n/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)\n * All rights reserved.\n *\n * This package is an SSL implementation written\n * by Eric Young (eay@cryptsoft.com).\n * The implementation was written so as to conform with Netscapes SSL.\n *\n * This library is free for commercial and non-commercial use as long as\n * the following conditions are aheared to.  The following conditions\n * apply to all code found in this distribution, be it the RC4, RSA,\n * lhash, DES, etc., code; not just the SSL code.  The SSL documentation\n * included with this distribution is covered by the same copyright terms\n * except that the holder is Tim Hudson (tjh@cryptsoft.com).\n *\n * Copyright remains Eric Young's, and as such any Copyright notices in\n * the code are not to be removed.\n * If this package is used in a product, Eric Young should be given attribution\n * as the author of the parts of the library used.\n * This can be in the form of a textual message at program startup or\n * in documentation (online or textual) provided with the package.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the copyright\n *    notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in the\n *    documentation and/or other materials provided with the distribution.\n * 3. All advertising materials mentioning features or use of this software\n *    must display the following acknowledgement:\n *    \"This product includes cryptographic software written by\n *     Eric Young (eay@cryptsoft.com)\"\n *    The word 'cryptographic' can be left out if the rouines from the library\n *    being used are not cryptographic related :-).\n * 4. If you include any Windows specific code (or a derivative thereof) from\n *    the apps directory (application code) you must include an acknowledgement:\n *    \"This product includes software written by Tim Hudson (tjh@cryptsoft.com)\"\n *\n * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n * SUCH DAMAGE.\n *\n * The licence and distribution terms for any publically available version or\n * derivative of this code cannot be changed.  i.e. this code cannot simply be\n * copied and put under another distribution licence\n * [including the GNU Public Licence.]\n */\n\n#ifndef HEADER_ENVELOPE_H\n# define HEADER_ENVELOPE_H\n\n# ifdef OPENSSL_ALGORITHM_DEFINES\n#  include <openssl/opensslconf.h>\n# else\n#  define OPENSSL_ALGORITHM_DEFINES\n#  include <openssl/opensslconf.h>\n#  undef OPENSSL_ALGORITHM_DEFINES\n# endif\n\n# include <openssl/ossl_typ.h>\n\n# include <openssl/symhacks.h>\n\n# ifndef OPENSSL_NO_BIO\n#  include <openssl/bio.h>\n# endif\n\n/*-\n#define EVP_RC2_KEY_SIZE                16\n#define EVP_RC4_KEY_SIZE                16\n#define EVP_BLOWFISH_KEY_SIZE           16\n#define EVP_CAST5_KEY_SIZE              16\n#define EVP_RC5_32_12_16_KEY_SIZE       16\n*/\n# define EVP_MAX_MD_SIZE                 64/* longest known is SHA512 */\n# define EVP_MAX_KEY_LENGTH              64\n# define EVP_MAX_IV_LENGTH               16\n# define EVP_MAX_BLOCK_LENGTH            32\n\n# define PKCS5_SALT_LEN                  8\n/* Default PKCS#5 iteration count */\n# define PKCS5_DEFAULT_ITER              2048\n\n# include <openssl/objects.h>\n\n# define EVP_PK_RSA      0x0001\n# define EVP_PK_DSA      0x0002\n# define EVP_PK_DH       0x0004\n# define EVP_PK_EC       0x0008\n# define EVP_PKT_SIGN    0x0010\n# define EVP_PKT_ENC     0x0020\n# define EVP_PKT_EXCH    0x0040\n# define EVP_PKS_RSA     0x0100\n# define EVP_PKS_DSA     0x0200\n# define EVP_PKS_EC      0x0400\n\n# define EVP_PKEY_NONE   NID_undef\n# define EVP_PKEY_RSA    NID_rsaEncryption\n# define EVP_PKEY_RSA2   NID_rsa\n# define EVP_PKEY_DSA    NID_dsa\n# define EVP_PKEY_DSA1   NID_dsa_2\n# define EVP_PKEY_DSA2   NID_dsaWithSHA\n# define EVP_PKEY_DSA3   NID_dsaWithSHA1\n# define EVP_PKEY_DSA4   NID_dsaWithSHA1_2\n# define EVP_PKEY_DH     NID_dhKeyAgreement\n# define EVP_PKEY_DHX    NID_dhpublicnumber\n# define EVP_PKEY_EC     NID_X9_62_id_ecPublicKey\n# define EVP_PKEY_HMAC   NID_hmac\n# define EVP_PKEY_CMAC   NID_cmac\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n/*\n * Type needs to be a bit field Sub-type needs to be for variations on the\n * method, as in, can it do arbitrary encryption....\n */\nstruct evp_pkey_st {\n    int type;\n    int save_type;\n    int references;\n    const EVP_PKEY_ASN1_METHOD *ameth;\n    ENGINE *engine;\n    union {\n        char *ptr;\n# ifndef OPENSSL_NO_RSA\n        struct rsa_st *rsa;     /* RSA */\n# endif\n# ifndef OPENSSL_NO_DSA\n        struct dsa_st *dsa;     /* DSA */\n# endif\n# ifndef OPENSSL_NO_DH\n        struct dh_st *dh;       /* DH */\n# endif\n# ifndef OPENSSL_NO_EC\n        struct ec_key_st *ec;   /* ECC */\n# endif\n    } pkey;\n    int save_parameters;\n    STACK_OF(X509_ATTRIBUTE) *attributes; /* [ 0 ] */\n} /* EVP_PKEY */ ;\n\n# define EVP_PKEY_MO_SIGN        0x0001\n# define EVP_PKEY_MO_VERIFY      0x0002\n# define EVP_PKEY_MO_ENCRYPT     0x0004\n# define EVP_PKEY_MO_DECRYPT     0x0008\n\n# ifndef EVP_MD\nstruct env_md_st {\n    int type;\n    int pkey_type;\n    int md_size;\n    unsigned long flags;\n    int (*init) (EVP_MD_CTX *ctx);\n    int (*update) (EVP_MD_CTX *ctx, const void *data, size_t count);\n    int (*final) (EVP_MD_CTX *ctx, unsigned char *md);\n    int (*copy) (EVP_MD_CTX *to, const EVP_MD_CTX *from);\n    int (*cleanup) (EVP_MD_CTX *ctx);\n    /* FIXME: prototype these some day */\n    int (*sign) (int type, const unsigned char *m, unsigned int m_length,\n                 unsigned char *sigret, unsigned int *siglen, void *key);\n    int (*verify) (int type, const unsigned char *m, unsigned int m_length,\n                   const unsigned char *sigbuf, unsigned int siglen,\n                   void *key);\n    int required_pkey_type[5];  /* EVP_PKEY_xxx */\n    int block_size;\n    int ctx_size;               /* how big does the ctx->md_data need to be */\n    /* control function */\n    int (*md_ctrl) (EVP_MD_CTX *ctx, int cmd, int p1, void *p2);\n} /* EVP_MD */ ;\n\ntypedef int evp_sign_method(int type, const unsigned char *m,\n                            unsigned int m_length, unsigned char *sigret,\n                            unsigned int *siglen, void *key);\ntypedef int evp_verify_method(int type, const unsigned char *m,\n                              unsigned int m_length,\n                              const unsigned char *sigbuf,\n                              unsigned int siglen, void *key);\n\n/* digest can only handle a single block */\n#  define EVP_MD_FLAG_ONESHOT     0x0001\n\n/*\n * digest is a \"clone\" digest used\n * which is a copy of an existing\n * one for a specific public key type.\n * EVP_dss1() etc\n */\n#  define EVP_MD_FLAG_PKEY_DIGEST 0x0002\n\n/* Digest uses EVP_PKEY_METHOD for signing instead of MD specific signing */\n\n#  define EVP_MD_FLAG_PKEY_METHOD_SIGNATURE       0x0004\n\n/* DigestAlgorithmIdentifier flags... */\n\n#  define EVP_MD_FLAG_DIGALGID_MASK               0x0018\n\n/* NULL or absent parameter accepted. Use NULL */\n\n#  define EVP_MD_FLAG_DIGALGID_NULL               0x0000\n\n/* NULL or absent parameter accepted. Use NULL for PKCS#1 otherwise absent */\n\n#  define EVP_MD_FLAG_DIGALGID_ABSENT             0x0008\n\n/* Custom handling via ctrl */\n\n#  define EVP_MD_FLAG_DIGALGID_CUSTOM             0x0018\n\n/* Note if suitable for use in FIPS mode */\n#  define EVP_MD_FLAG_FIPS        0x0400\n\n/* Digest ctrls */\n\n#  define EVP_MD_CTRL_DIGALGID                    0x1\n#  define EVP_MD_CTRL_MICALG                      0x2\n\n/* Minimum Algorithm specific ctrl value */\n\n#  define EVP_MD_CTRL_ALG_CTRL                    0x1000\n\n#  define EVP_PKEY_NULL_method    NULL,NULL,{0,0,0,0}\n\n#  ifndef OPENSSL_NO_DSA\n#   define EVP_PKEY_DSA_method     (evp_sign_method *)DSA_sign, \\\n                                (evp_verify_method *)DSA_verify, \\\n                                {EVP_PKEY_DSA,EVP_PKEY_DSA2,EVP_PKEY_DSA3, \\\n                                        EVP_PKEY_DSA4,0}\n#  else\n#   define EVP_PKEY_DSA_method     EVP_PKEY_NULL_method\n#  endif\n\n#  ifndef OPENSSL_NO_ECDSA\n#   define EVP_PKEY_ECDSA_method   (evp_sign_method *)ECDSA_sign, \\\n                                (evp_verify_method *)ECDSA_verify, \\\n                                 {EVP_PKEY_EC,0,0,0}\n#  else\n#   define EVP_PKEY_ECDSA_method   EVP_PKEY_NULL_method\n#  endif\n\n#  ifndef OPENSSL_NO_RSA\n#   define EVP_PKEY_RSA_method     (evp_sign_method *)RSA_sign, \\\n                                (evp_verify_method *)RSA_verify, \\\n                                {EVP_PKEY_RSA,EVP_PKEY_RSA2,0,0}\n#   define EVP_PKEY_RSA_ASN1_OCTET_STRING_method \\\n                                (evp_sign_method *)RSA_sign_ASN1_OCTET_STRING, \\\n                                (evp_verify_method *)RSA_verify_ASN1_OCTET_STRING, \\\n                                {EVP_PKEY_RSA,EVP_PKEY_RSA2,0,0}\n#  else\n#   define EVP_PKEY_RSA_method     EVP_PKEY_NULL_method\n#   define EVP_PKEY_RSA_ASN1_OCTET_STRING_method EVP_PKEY_NULL_method\n#  endif\n\n# endif                         /* !EVP_MD */\n\nstruct env_md_ctx_st {\n    const EVP_MD *digest;\n    ENGINE *engine;             /* functional reference if 'digest' is\n                                 * ENGINE-provided */\n    unsigned long flags;\n    void *md_data;\n    /* Public key context for sign/verify */\n    EVP_PKEY_CTX *pctx;\n    /* Update function: usually copied from EVP_MD */\n    int (*update) (EVP_MD_CTX *ctx, const void *data, size_t count);\n} /* EVP_MD_CTX */ ;\n\n/* values for EVP_MD_CTX flags */\n\n# define EVP_MD_CTX_FLAG_ONESHOT         0x0001/* digest update will be\n                                                * called once only */\n# define EVP_MD_CTX_FLAG_CLEANED         0x0002/* context has already been\n                                                * cleaned */\n# define EVP_MD_CTX_FLAG_REUSE           0x0004/* Don't free up ctx->md_data\n                                                * in EVP_MD_CTX_cleanup */\n/*\n * FIPS and pad options are ignored in 1.0.0, definitions are here so we\n * don't accidentally reuse the values for other purposes.\n */\n\n# define EVP_MD_CTX_FLAG_NON_FIPS_ALLOW  0x0008/* Allow use of non FIPS\n                                                * digest in FIPS mode */\n\n/*\n * The following PAD options are also currently ignored in 1.0.0, digest\n * parameters are handled through EVP_DigestSign*() and EVP_DigestVerify*()\n * instead.\n */\n# define EVP_MD_CTX_FLAG_PAD_MASK        0xF0/* RSA mode to use */\n# define EVP_MD_CTX_FLAG_PAD_PKCS1       0x00/* PKCS#1 v1.5 mode */\n# define EVP_MD_CTX_FLAG_PAD_X931        0x10/* X9.31 mode */\n# define EVP_MD_CTX_FLAG_PAD_PSS         0x20/* PSS mode */\n\n# define EVP_MD_CTX_FLAG_NO_INIT         0x0100/* Don't initialize md_data */\n\nstruct evp_cipher_st {\n    int nid;\n    int block_size;\n    /* Default value for variable length ciphers */\n    int key_len;\n    int iv_len;\n    /* Various flags */\n    unsigned long flags;\n    /* init key */\n    int (*init) (EVP_CIPHER_CTX *ctx, const unsigned char *key,\n                 const unsigned char *iv, int enc);\n    /* encrypt/decrypt data */\n    int (*do_cipher) (EVP_CIPHER_CTX *ctx, unsigned char *out,\n                      const unsigned char *in, size_t inl);\n    /* cleanup ctx */\n    int (*cleanup) (EVP_CIPHER_CTX *);\n    /* how big ctx->cipher_data needs to be */\n    int ctx_size;\n    /* Populate a ASN1_TYPE with parameters */\n    int (*set_asn1_parameters) (EVP_CIPHER_CTX *, ASN1_TYPE *);\n    /* Get parameters from a ASN1_TYPE */\n    int (*get_asn1_parameters) (EVP_CIPHER_CTX *, ASN1_TYPE *);\n    /* Miscellaneous operations */\n    int (*ctrl) (EVP_CIPHER_CTX *, int type, int arg, void *ptr);\n    /* Application data */\n    void *app_data;\n} /* EVP_CIPHER */ ;\n\n/* Values for cipher flags */\n\n/* Modes for ciphers */\n\n# define         EVP_CIPH_STREAM_CIPHER          0x0\n# define         EVP_CIPH_ECB_MODE               0x1\n# define         EVP_CIPH_CBC_MODE               0x2\n# define         EVP_CIPH_CFB_MODE               0x3\n# define         EVP_CIPH_OFB_MODE               0x4\n# define         EVP_CIPH_CTR_MODE               0x5\n# define         EVP_CIPH_GCM_MODE               0x6\n# define         EVP_CIPH_CCM_MODE               0x7\n# define         EVP_CIPH_XTS_MODE               0x10001\n# define         EVP_CIPH_WRAP_MODE              0x10002\n# define         EVP_CIPH_MODE                   0xF0007\n/* Set if variable length cipher */\n# define         EVP_CIPH_VARIABLE_LENGTH        0x8\n/* Set if the iv handling should be done by the cipher itself */\n# define         EVP_CIPH_CUSTOM_IV              0x10\n/* Set if the cipher's init() function should be called if key is NULL */\n# define         EVP_CIPH_ALWAYS_CALL_INIT       0x20\n/* Call ctrl() to init cipher parameters */\n# define         EVP_CIPH_CTRL_INIT              0x40\n/* Don't use standard key length function */\n# define         EVP_CIPH_CUSTOM_KEY_LENGTH      0x80\n/* Don't use standard block padding */\n# define         EVP_CIPH_NO_PADDING             0x100\n/* cipher handles random key generation */\n# define         EVP_CIPH_RAND_KEY               0x200\n/* cipher has its own additional copying logic */\n# define         EVP_CIPH_CUSTOM_COPY            0x400\n/* Allow use default ASN1 get/set iv */\n# define         EVP_CIPH_FLAG_DEFAULT_ASN1      0x1000\n/* Buffer length in bits not bytes: CFB1 mode only */\n# define         EVP_CIPH_FLAG_LENGTH_BITS       0x2000\n/* Note if suitable for use in FIPS mode */\n# define         EVP_CIPH_FLAG_FIPS              0x4000\n/* Allow non FIPS cipher in FIPS mode */\n# define         EVP_CIPH_FLAG_NON_FIPS_ALLOW    0x8000\n/*\n * Cipher handles any and all padding logic as well as finalisation.\n */\n# define         EVP_CIPH_FLAG_CUSTOM_CIPHER     0x100000\n# define         EVP_CIPH_FLAG_AEAD_CIPHER       0x200000\n# define         EVP_CIPH_FLAG_TLS1_1_MULTIBLOCK 0x400000\n\n/*\n * Cipher context flag to indicate we can handle wrap mode: if allowed in\n * older applications it could overflow buffers.\n */\n\n# define         EVP_CIPHER_CTX_FLAG_WRAP_ALLOW  0x1\n\n/* ctrl() values */\n\n# define         EVP_CTRL_INIT                   0x0\n# define         EVP_CTRL_SET_KEY_LENGTH         0x1\n# define         EVP_CTRL_GET_RC2_KEY_BITS       0x2\n# define         EVP_CTRL_SET_RC2_KEY_BITS       0x3\n# define         EVP_CTRL_GET_RC5_ROUNDS         0x4\n# define         EVP_CTRL_SET_RC5_ROUNDS         0x5\n# define         EVP_CTRL_RAND_KEY               0x6\n# define         EVP_CTRL_PBE_PRF_NID            0x7\n# define         EVP_CTRL_COPY                   0x8\n# define         EVP_CTRL_GCM_SET_IVLEN          0x9\n# define         EVP_CTRL_GCM_GET_TAG            0x10\n# define         EVP_CTRL_GCM_SET_TAG            0x11\n# define         EVP_CTRL_GCM_SET_IV_FIXED       0x12\n# define         EVP_CTRL_GCM_IV_GEN             0x13\n# define         EVP_CTRL_CCM_SET_IVLEN          EVP_CTRL_GCM_SET_IVLEN\n# define         EVP_CTRL_CCM_GET_TAG            EVP_CTRL_GCM_GET_TAG\n# define         EVP_CTRL_CCM_SET_TAG            EVP_CTRL_GCM_SET_TAG\n# define         EVP_CTRL_CCM_SET_L              0x14\n# define         EVP_CTRL_CCM_SET_MSGLEN         0x15\n/*\n * AEAD cipher deduces payload length and returns number of bytes required to\n * store MAC and eventual padding. Subsequent call to EVP_Cipher even\n * appends/verifies MAC.\n */\n# define         EVP_CTRL_AEAD_TLS1_AAD          0x16\n/* Used by composite AEAD ciphers, no-op in GCM, CCM... */\n# define         EVP_CTRL_AEAD_SET_MAC_KEY       0x17\n/* Set the GCM invocation field, decrypt only */\n# define         EVP_CTRL_GCM_SET_IV_INV         0x18\n\n# define         EVP_CTRL_TLS1_1_MULTIBLOCK_AAD  0x19\n# define         EVP_CTRL_TLS1_1_MULTIBLOCK_ENCRYPT      0x1a\n# define         EVP_CTRL_TLS1_1_MULTIBLOCK_DECRYPT      0x1b\n# define         EVP_CTRL_TLS1_1_MULTIBLOCK_MAX_BUFSIZE  0x1c\n\n/* RFC 5246 defines additional data to be 13 bytes in length */\n# define         EVP_AEAD_TLS1_AAD_LEN           13\n\ntypedef struct {\n    unsigned char *out;\n    const unsigned char *inp;\n    size_t len;\n    unsigned int interleave;\n} EVP_CTRL_TLS1_1_MULTIBLOCK_PARAM;\n\n/* GCM TLS constants */\n/* Length of fixed part of IV derived from PRF */\n# define EVP_GCM_TLS_FIXED_IV_LEN                        4\n/* Length of explicit part of IV part of TLS records */\n# define EVP_GCM_TLS_EXPLICIT_IV_LEN                     8\n/* Length of tag for TLS */\n# define EVP_GCM_TLS_TAG_LEN                             16\n\ntypedef struct evp_cipher_info_st {\n    const EVP_CIPHER *cipher;\n    unsigned char iv[EVP_MAX_IV_LENGTH];\n} EVP_CIPHER_INFO;\n\nstruct evp_cipher_ctx_st {\n    const EVP_CIPHER *cipher;\n    ENGINE *engine;             /* functional reference if 'cipher' is\n                                 * ENGINE-provided */\n    int encrypt;                /* encrypt or decrypt */\n    int buf_len;                /* number we have left */\n    unsigned char oiv[EVP_MAX_IV_LENGTH]; /* original iv */\n    unsigned char iv[EVP_MAX_IV_LENGTH]; /* working iv */\n    unsigned char buf[EVP_MAX_BLOCK_LENGTH]; /* saved partial block */\n    int num;                    /* used by cfb/ofb/ctr mode */\n    void *app_data;             /* application stuff */\n    int key_len;                /* May change for variable length cipher */\n    unsigned long flags;        /* Various flags */\n    void *cipher_data;          /* per EVP data */\n    int final_used;\n    int block_mask;\n    unsigned char final[EVP_MAX_BLOCK_LENGTH]; /* possible final block */\n} /* EVP_CIPHER_CTX */ ;\n\ntypedef struct evp_Encode_Ctx_st {\n    /* number saved in a partial encode/decode */\n    int num;\n    /*\n     * The length is either the output line length (in input bytes) or the\n     * shortest input line length that is ok.  Once decoding begins, the\n     * length is adjusted up each time a longer line is decoded\n     */\n    int length;\n    /* data to encode */\n    unsigned char enc_data[80];\n    /* number read on current line */\n    int line_num;\n    int expect_nl;\n} EVP_ENCODE_CTX;\n\n/* Password based encryption function */\ntypedef int (EVP_PBE_KEYGEN) (EVP_CIPHER_CTX *ctx, const char *pass,\n                              int passlen, ASN1_TYPE *param,\n                              const EVP_CIPHER *cipher, const EVP_MD *md,\n                              int en_de);\n\n# ifndef OPENSSL_NO_RSA\n#  define EVP_PKEY_assign_RSA(pkey,rsa) EVP_PKEY_assign((pkey),EVP_PKEY_RSA,\\\n                                        (char *)(rsa))\n# endif\n\n# ifndef OPENSSL_NO_DSA\n#  define EVP_PKEY_assign_DSA(pkey,dsa) EVP_PKEY_assign((pkey),EVP_PKEY_DSA,\\\n                                        (char *)(dsa))\n# endif\n\n# ifndef OPENSSL_NO_DH\n#  define EVP_PKEY_assign_DH(pkey,dh) EVP_PKEY_assign((pkey),EVP_PKEY_DH,\\\n                                        (char *)(dh))\n# endif\n\n# ifndef OPENSSL_NO_EC\n#  define EVP_PKEY_assign_EC_KEY(pkey,eckey) EVP_PKEY_assign((pkey),EVP_PKEY_EC,\\\n                                        (char *)(eckey))\n# endif\n\n/* Add some extra combinations */\n# define EVP_get_digestbynid(a) EVP_get_digestbyname(OBJ_nid2sn(a))\n# define EVP_get_digestbyobj(a) EVP_get_digestbynid(OBJ_obj2nid(a))\n# define EVP_get_cipherbynid(a) EVP_get_cipherbyname(OBJ_nid2sn(a))\n# define EVP_get_cipherbyobj(a) EVP_get_cipherbynid(OBJ_obj2nid(a))\n\nint EVP_MD_type(const EVP_MD *md);\n# define EVP_MD_nid(e)                   EVP_MD_type(e)\n# define EVP_MD_name(e)                  OBJ_nid2sn(EVP_MD_nid(e))\nint EVP_MD_pkey_type(const EVP_MD *md);\nint EVP_MD_size(const EVP_MD *md);\nint EVP_MD_block_size(const EVP_MD *md);\nunsigned long EVP_MD_flags(const EVP_MD *md);\n\nconst EVP_MD *EVP_MD_CTX_md(const EVP_MD_CTX *ctx);\n# define EVP_MD_CTX_size(e)              EVP_MD_size(EVP_MD_CTX_md(e))\n# define EVP_MD_CTX_block_size(e)        EVP_MD_block_size(EVP_MD_CTX_md(e))\n# define EVP_MD_CTX_type(e)              EVP_MD_type(EVP_MD_CTX_md(e))\n\nint EVP_CIPHER_nid(const EVP_CIPHER *cipher);\n# define EVP_CIPHER_name(e)              OBJ_nid2sn(EVP_CIPHER_nid(e))\nint EVP_CIPHER_block_size(const EVP_CIPHER *cipher);\nint EVP_CIPHER_key_length(const EVP_CIPHER *cipher);\nint EVP_CIPHER_iv_length(const EVP_CIPHER *cipher);\nunsigned long EVP_CIPHER_flags(const EVP_CIPHER *cipher);\n# define EVP_CIPHER_mode(e)              (EVP_CIPHER_flags(e) & EVP_CIPH_MODE)\n\nconst EVP_CIPHER *EVP_CIPHER_CTX_cipher(const EVP_CIPHER_CTX *ctx);\nint EVP_CIPHER_CTX_nid(const EVP_CIPHER_CTX *ctx);\nint EVP_CIPHER_CTX_block_size(const EVP_CIPHER_CTX *ctx);\nint EVP_CIPHER_CTX_key_length(const EVP_CIPHER_CTX *ctx);\nint EVP_CIPHER_CTX_iv_length(const EVP_CIPHER_CTX *ctx);\nint EVP_CIPHER_CTX_copy(EVP_CIPHER_CTX *out, const EVP_CIPHER_CTX *in);\nvoid *EVP_CIPHER_CTX_get_app_data(const EVP_CIPHER_CTX *ctx);\nvoid EVP_CIPHER_CTX_set_app_data(EVP_CIPHER_CTX *ctx, void *data);\n# define EVP_CIPHER_CTX_type(c)         EVP_CIPHER_type(EVP_CIPHER_CTX_cipher(c))\nunsigned long EVP_CIPHER_CTX_flags(const EVP_CIPHER_CTX *ctx);\n# define EVP_CIPHER_CTX_mode(e)          (EVP_CIPHER_CTX_flags(e) & EVP_CIPH_MODE)\n\n# define EVP_ENCODE_LENGTH(l)    (((l+2)/3*4)+(l/48+1)*2+80)\n# define EVP_DECODE_LENGTH(l)    ((l+3)/4*3+80)\n\n# define EVP_SignInit_ex(a,b,c)          EVP_DigestInit_ex(a,b,c)\n# define EVP_SignInit(a,b)               EVP_DigestInit(a,b)\n# define EVP_SignUpdate(a,b,c)           EVP_DigestUpdate(a,b,c)\n# define EVP_VerifyInit_ex(a,b,c)        EVP_DigestInit_ex(a,b,c)\n# define EVP_VerifyInit(a,b)             EVP_DigestInit(a,b)\n# define EVP_VerifyUpdate(a,b,c)         EVP_DigestUpdate(a,b,c)\n# define EVP_OpenUpdate(a,b,c,d,e)       EVP_DecryptUpdate(a,b,c,d,e)\n# define EVP_SealUpdate(a,b,c,d,e)       EVP_EncryptUpdate(a,b,c,d,e)\n# define EVP_DigestSignUpdate(a,b,c)     EVP_DigestUpdate(a,b,c)\n# define EVP_DigestVerifyUpdate(a,b,c)   EVP_DigestUpdate(a,b,c)\n\n# ifdef CONST_STRICT\nvoid BIO_set_md(BIO *, const EVP_MD *md);\n# else\n#  define BIO_set_md(b,md)               BIO_ctrl(b,BIO_C_SET_MD,0,(char *)md)\n# endif\n# define BIO_get_md(b,mdp)               BIO_ctrl(b,BIO_C_GET_MD,0,(char *)mdp)\n# define BIO_get_md_ctx(b,mdcp)     BIO_ctrl(b,BIO_C_GET_MD_CTX,0,(char *)mdcp)\n# define BIO_set_md_ctx(b,mdcp)     BIO_ctrl(b,BIO_C_SET_MD_CTX,0,(char *)mdcp)\n# define BIO_get_cipher_status(b)        BIO_ctrl(b,BIO_C_GET_CIPHER_STATUS,0,NULL)\n# define BIO_get_cipher_ctx(b,c_pp)      BIO_ctrl(b,BIO_C_GET_CIPHER_CTX,0,(char *)c_pp)\n\nint EVP_Cipher(EVP_CIPHER_CTX *c,\n               unsigned char *out, const unsigned char *in, unsigned int inl);\n\n# define EVP_add_cipher_alias(n,alias) \\\n        OBJ_NAME_add((alias),OBJ_NAME_TYPE_CIPHER_METH|OBJ_NAME_ALIAS,(n))\n# define EVP_add_digest_alias(n,alias) \\\n        OBJ_NAME_add((alias),OBJ_NAME_TYPE_MD_METH|OBJ_NAME_ALIAS,(n))\n# define EVP_delete_cipher_alias(alias) \\\n        OBJ_NAME_remove(alias,OBJ_NAME_TYPE_CIPHER_METH|OBJ_NAME_ALIAS);\n# define EVP_delete_digest_alias(alias) \\\n        OBJ_NAME_remove(alias,OBJ_NAME_TYPE_MD_METH|OBJ_NAME_ALIAS);\n\nvoid EVP_MD_CTX_init(EVP_MD_CTX *ctx);\nint EVP_MD_CTX_cleanup(EVP_MD_CTX *ctx);\nEVP_MD_CTX *EVP_MD_CTX_create(void);\nvoid EVP_MD_CTX_destroy(EVP_MD_CTX *ctx);\nint EVP_MD_CTX_copy_ex(EVP_MD_CTX *out, const EVP_MD_CTX *in);\nvoid EVP_MD_CTX_set_flags(EVP_MD_CTX *ctx, int flags);\nvoid EVP_MD_CTX_clear_flags(EVP_MD_CTX *ctx, int flags);\nint EVP_MD_CTX_test_flags(const EVP_MD_CTX *ctx, int flags);\nint EVP_DigestInit_ex(EVP_MD_CTX *ctx, const EVP_MD *type, ENGINE *impl);\nint EVP_DigestUpdate(EVP_MD_CTX *ctx, const void *d, size_t cnt);\nint EVP_DigestFinal_ex(EVP_MD_CTX *ctx, unsigned char *md, unsigned int *s);\nint EVP_Digest(const void *data, size_t count,\n               unsigned char *md, unsigned int *size, const EVP_MD *type,\n               ENGINE *impl);\n\nint EVP_MD_CTX_copy(EVP_MD_CTX *out, const EVP_MD_CTX *in);\nint EVP_DigestInit(EVP_MD_CTX *ctx, const EVP_MD *type);\nint EVP_DigestFinal(EVP_MD_CTX *ctx, unsigned char *md, unsigned int *s);\n\nint EVP_read_pw_string(char *buf, int length, const char *prompt, int verify);\nint EVP_read_pw_string_min(char *buf, int minlen, int maxlen,\n                           const char *prompt, int verify);\nvoid EVP_set_pw_prompt(const char *prompt);\nchar *EVP_get_pw_prompt(void);\n\nint EVP_BytesToKey(const EVP_CIPHER *type, const EVP_MD *md,\n                   const unsigned char *salt, const unsigned char *data,\n                   int datal, int count, unsigned char *key,\n                   unsigned char *iv);\n\nvoid EVP_CIPHER_CTX_set_flags(EVP_CIPHER_CTX *ctx, int flags);\nvoid EVP_CIPHER_CTX_clear_flags(EVP_CIPHER_CTX *ctx, int flags);\nint EVP_CIPHER_CTX_test_flags(const EVP_CIPHER_CTX *ctx, int flags);\n\nint EVP_EncryptInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher,\n                    const unsigned char *key, const unsigned char *iv);\nint EVP_EncryptInit_ex(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher,\n                       ENGINE *impl, const unsigned char *key,\n                       const unsigned char *iv);\nint EVP_EncryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl,\n                      const unsigned char *in, int inl);\nint EVP_EncryptFinal_ex(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl);\nint EVP_EncryptFinal(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl);\n\nint EVP_DecryptInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher,\n                    const unsigned char *key, const unsigned char *iv);\nint EVP_DecryptInit_ex(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher,\n                       ENGINE *impl, const unsigned char *key,\n                       const unsigned char *iv);\nint EVP_DecryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl,\n                      const unsigned char *in, int inl);\nint EVP_DecryptFinal(EVP_CIPHER_CTX *ctx, unsigned char *outm, int *outl);\nint EVP_DecryptFinal_ex(EVP_CIPHER_CTX *ctx, unsigned char *outm, int *outl);\n\nint EVP_CipherInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher,\n                   const unsigned char *key, const unsigned char *iv,\n                   int enc);\nint EVP_CipherInit_ex(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher,\n                      ENGINE *impl, const unsigned char *key,\n                      const unsigned char *iv, int enc);\nint EVP_CipherUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl,\n                     const unsigned char *in, int inl);\nint EVP_CipherFinal(EVP_CIPHER_CTX *ctx, unsigned char *outm, int *outl);\nint EVP_CipherFinal_ex(EVP_CIPHER_CTX *ctx, unsigned char *outm, int *outl);\n\nint EVP_SignFinal(EVP_MD_CTX *ctx, unsigned char *md, unsigned int *s,\n                  EVP_PKEY *pkey);\n\nint EVP_VerifyFinal(EVP_MD_CTX *ctx, const unsigned char *sigbuf,\n                    unsigned int siglen, EVP_PKEY *pkey);\n\nint EVP_DigestSignInit(EVP_MD_CTX *ctx, EVP_PKEY_CTX **pctx,\n                       const EVP_MD *type, ENGINE *e, EVP_PKEY *pkey);\nint EVP_DigestSignFinal(EVP_MD_CTX *ctx,\n                        unsigned char *sigret, size_t *siglen);\n\nint EVP_DigestVerifyInit(EVP_MD_CTX *ctx, EVP_PKEY_CTX **pctx,\n                         const EVP_MD *type, ENGINE *e, EVP_PKEY *pkey);\nint EVP_DigestVerifyFinal(EVP_MD_CTX *ctx,\n                          const unsigned char *sig, size_t siglen);\n\nint EVP_OpenInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *type,\n                 const unsigned char *ek, int ekl, const unsigned char *iv,\n                 EVP_PKEY *priv);\nint EVP_OpenFinal(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl);\n\nint EVP_SealInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *type,\n                 unsigned char **ek, int *ekl, unsigned char *iv,\n                 EVP_PKEY **pubk, int npubk);\nint EVP_SealFinal(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl);\n\nvoid EVP_EncodeInit(EVP_ENCODE_CTX *ctx);\nvoid EVP_EncodeUpdate(EVP_ENCODE_CTX *ctx, unsigned char *out, int *outl,\n                      const unsigned char *in, int inl);\nvoid EVP_EncodeFinal(EVP_ENCODE_CTX *ctx, unsigned char *out, int *outl);\nint EVP_EncodeBlock(unsigned char *t, const unsigned char *f, int n);\n\nvoid EVP_DecodeInit(EVP_ENCODE_CTX *ctx);\nint EVP_DecodeUpdate(EVP_ENCODE_CTX *ctx, unsigned char *out, int *outl,\n                     const unsigned char *in, int inl);\nint EVP_DecodeFinal(EVP_ENCODE_CTX *ctx, unsigned\n                    char *out, int *outl);\nint EVP_DecodeBlock(unsigned char *t, const unsigned char *f, int n);\n\nvoid EVP_CIPHER_CTX_init(EVP_CIPHER_CTX *a);\nint EVP_CIPHER_CTX_cleanup(EVP_CIPHER_CTX *a);\nEVP_CIPHER_CTX *EVP_CIPHER_CTX_new(void);\nvoid EVP_CIPHER_CTX_free(EVP_CIPHER_CTX *a);\nint EVP_CIPHER_CTX_set_key_length(EVP_CIPHER_CTX *x, int keylen);\nint EVP_CIPHER_CTX_set_padding(EVP_CIPHER_CTX *c, int pad);\nint EVP_CIPHER_CTX_ctrl(EVP_CIPHER_CTX *ctx, int type, int arg, void *ptr);\nint EVP_CIPHER_CTX_rand_key(EVP_CIPHER_CTX *ctx, unsigned char *key);\n\n# ifndef OPENSSL_NO_BIO\nBIO_METHOD *BIO_f_md(void);\nBIO_METHOD *BIO_f_base64(void);\nBIO_METHOD *BIO_f_cipher(void);\nBIO_METHOD *BIO_f_reliable(void);\nvoid BIO_set_cipher(BIO *b, const EVP_CIPHER *c, const unsigned char *k,\n                    const unsigned char *i, int enc);\n# endif\n\nconst EVP_MD *EVP_md_null(void);\n# ifndef OPENSSL_NO_MD2\nconst EVP_MD *EVP_md2(void);\n# endif\n# ifndef OPENSSL_NO_MD4\nconst EVP_MD *EVP_md4(void);\n# endif\n# ifndef OPENSSL_NO_MD5\nconst EVP_MD *EVP_md5(void);\n# endif\n# ifndef OPENSSL_NO_SHA\nconst EVP_MD *EVP_sha(void);\nconst EVP_MD *EVP_sha1(void);\nconst EVP_MD *EVP_dss(void);\nconst EVP_MD *EVP_dss1(void);\nconst EVP_MD *EVP_ecdsa(void);\n# endif\n# ifndef OPENSSL_NO_SHA256\nconst EVP_MD *EVP_sha224(void);\nconst EVP_MD *EVP_sha256(void);\n# endif\n# ifndef OPENSSL_NO_SHA512\nconst EVP_MD *EVP_sha384(void);\nconst EVP_MD *EVP_sha512(void);\n# endif\n# ifndef OPENSSL_NO_MDC2\nconst EVP_MD *EVP_mdc2(void);\n# endif\n# ifndef OPENSSL_NO_RIPEMD\nconst EVP_MD *EVP_ripemd160(void);\n# endif\n# ifndef OPENSSL_NO_WHIRLPOOL\nconst EVP_MD *EVP_whirlpool(void);\n# endif\nconst EVP_CIPHER *EVP_enc_null(void); /* does nothing :-) */\n# ifndef OPENSSL_NO_DES\nconst EVP_CIPHER *EVP_des_ecb(void);\nconst EVP_CIPHER *EVP_des_ede(void);\nconst EVP_CIPHER *EVP_des_ede3(void);\nconst EVP_CIPHER *EVP_des_ede_ecb(void);\nconst EVP_CIPHER *EVP_des_ede3_ecb(void);\nconst EVP_CIPHER *EVP_des_cfb64(void);\n#  define EVP_des_cfb EVP_des_cfb64\nconst EVP_CIPHER *EVP_des_cfb1(void);\nconst EVP_CIPHER *EVP_des_cfb8(void);\nconst EVP_CIPHER *EVP_des_ede_cfb64(void);\n#  define EVP_des_ede_cfb EVP_des_ede_cfb64\n#  if 0\nconst EVP_CIPHER *EVP_des_ede_cfb1(void);\nconst EVP_CIPHER *EVP_des_ede_cfb8(void);\n#  endif\nconst EVP_CIPHER *EVP_des_ede3_cfb64(void);\n#  define EVP_des_ede3_cfb EVP_des_ede3_cfb64\nconst EVP_CIPHER *EVP_des_ede3_cfb1(void);\nconst EVP_CIPHER *EVP_des_ede3_cfb8(void);\nconst EVP_CIPHER *EVP_des_ofb(void);\nconst EVP_CIPHER *EVP_des_ede_ofb(void);\nconst EVP_CIPHER *EVP_des_ede3_ofb(void);\nconst EVP_CIPHER *EVP_des_cbc(void);\nconst EVP_CIPHER *EVP_des_ede_cbc(void);\nconst EVP_CIPHER *EVP_des_ede3_cbc(void);\nconst EVP_CIPHER *EVP_desx_cbc(void);\nconst EVP_CIPHER *EVP_des_ede3_wrap(void);\n/*\n * This should now be supported through the dev_crypto ENGINE. But also, why\n * are rc4 and md5 declarations made here inside a \"NO_DES\" precompiler\n * branch?\n */\n#  if 0\n#   ifdef OPENSSL_OPENBSD_DEV_CRYPTO\nconst EVP_CIPHER *EVP_dev_crypto_des_ede3_cbc(void);\nconst EVP_CIPHER *EVP_dev_crypto_rc4(void);\nconst EVP_MD *EVP_dev_crypto_md5(void);\n#   endif\n#  endif\n# endif\n# ifndef OPENSSL_NO_RC4\nconst EVP_CIPHER *EVP_rc4(void);\nconst EVP_CIPHER *EVP_rc4_40(void);\n#  ifndef OPENSSL_NO_MD5\nconst EVP_CIPHER *EVP_rc4_hmac_md5(void);\n#  endif\n# endif\n# ifndef OPENSSL_NO_IDEA\nconst EVP_CIPHER *EVP_idea_ecb(void);\nconst EVP_CIPHER *EVP_idea_cfb64(void);\n#  define EVP_idea_cfb EVP_idea_cfb64\nconst EVP_CIPHER *EVP_idea_ofb(void);\nconst EVP_CIPHER *EVP_idea_cbc(void);\n# endif\n# ifndef OPENSSL_NO_RC2\nconst EVP_CIPHER *EVP_rc2_ecb(void);\nconst EVP_CIPHER *EVP_rc2_cbc(void);\nconst EVP_CIPHER *EVP_rc2_40_cbc(void);\nconst EVP_CIPHER *EVP_rc2_64_cbc(void);\nconst EVP_CIPHER *EVP_rc2_cfb64(void);\n#  define EVP_rc2_cfb EVP_rc2_cfb64\nconst EVP_CIPHER *EVP_rc2_ofb(void);\n# endif\n# ifndef OPENSSL_NO_BF\nconst EVP_CIPHER *EVP_bf_ecb(void);\nconst EVP_CIPHER *EVP_bf_cbc(void);\nconst EVP_CIPHER *EVP_bf_cfb64(void);\n#  define EVP_bf_cfb EVP_bf_cfb64\nconst EVP_CIPHER *EVP_bf_ofb(void);\n# endif\n# ifndef OPENSSL_NO_CAST\nconst EVP_CIPHER *EVP_cast5_ecb(void);\nconst EVP_CIPHER *EVP_cast5_cbc(void);\nconst EVP_CIPHER *EVP_cast5_cfb64(void);\n#  define EVP_cast5_cfb EVP_cast5_cfb64\nconst EVP_CIPHER *EVP_cast5_ofb(void);\n# endif\n# ifndef OPENSSL_NO_RC5\nconst EVP_CIPHER *EVP_rc5_32_12_16_cbc(void);\nconst EVP_CIPHER *EVP_rc5_32_12_16_ecb(void);\nconst EVP_CIPHER *EVP_rc5_32_12_16_cfb64(void);\n#  define EVP_rc5_32_12_16_cfb EVP_rc5_32_12_16_cfb64\nconst EVP_CIPHER *EVP_rc5_32_12_16_ofb(void);\n# endif\n# ifndef OPENSSL_NO_AES\nconst EVP_CIPHER *EVP_aes_128_ecb(void);\nconst EVP_CIPHER *EVP_aes_128_cbc(void);\nconst EVP_CIPHER *EVP_aes_128_cfb1(void);\nconst EVP_CIPHER *EVP_aes_128_cfb8(void);\nconst EVP_CIPHER *EVP_aes_128_cfb128(void);\n#  define EVP_aes_128_cfb EVP_aes_128_cfb128\nconst EVP_CIPHER *EVP_aes_128_ofb(void);\nconst EVP_CIPHER *EVP_aes_128_ctr(void);\nconst EVP_CIPHER *EVP_aes_128_ccm(void);\nconst EVP_CIPHER *EVP_aes_128_gcm(void);\nconst EVP_CIPHER *EVP_aes_128_xts(void);\nconst EVP_CIPHER *EVP_aes_128_wrap(void);\nconst EVP_CIPHER *EVP_aes_192_ecb(void);\nconst EVP_CIPHER *EVP_aes_192_cbc(void);\nconst EVP_CIPHER *EVP_aes_192_cfb1(void);\nconst EVP_CIPHER *EVP_aes_192_cfb8(void);\nconst EVP_CIPHER *EVP_aes_192_cfb128(void);\n#  define EVP_aes_192_cfb EVP_aes_192_cfb128\nconst EVP_CIPHER *EVP_aes_192_ofb(void);\nconst EVP_CIPHER *EVP_aes_192_ctr(void);\nconst EVP_CIPHER *EVP_aes_192_ccm(void);\nconst EVP_CIPHER *EVP_aes_192_gcm(void);\nconst EVP_CIPHER *EVP_aes_192_wrap(void);\nconst EVP_CIPHER *EVP_aes_256_ecb(void);\nconst EVP_CIPHER *EVP_aes_256_cbc(void);\nconst EVP_CIPHER *EVP_aes_256_cfb1(void);\nconst EVP_CIPHER *EVP_aes_256_cfb8(void);\nconst EVP_CIPHER *EVP_aes_256_cfb128(void);\n#  define EVP_aes_256_cfb EVP_aes_256_cfb128\nconst EVP_CIPHER *EVP_aes_256_ofb(void);\nconst EVP_CIPHER *EVP_aes_256_ctr(void);\nconst EVP_CIPHER *EVP_aes_256_ccm(void);\nconst EVP_CIPHER *EVP_aes_256_gcm(void);\nconst EVP_CIPHER *EVP_aes_256_xts(void);\nconst EVP_CIPHER *EVP_aes_256_wrap(void);\n#  if !defined(OPENSSL_NO_SHA) && !defined(OPENSSL_NO_SHA1)\nconst EVP_CIPHER *EVP_aes_128_cbc_hmac_sha1(void);\nconst EVP_CIPHER *EVP_aes_256_cbc_hmac_sha1(void);\n#  endif\n#  ifndef OPENSSL_NO_SHA256\nconst EVP_CIPHER *EVP_aes_128_cbc_hmac_sha256(void);\nconst EVP_CIPHER *EVP_aes_256_cbc_hmac_sha256(void);\n#  endif\n# endif\n# ifndef OPENSSL_NO_CAMELLIA\nconst EVP_CIPHER *EVP_camellia_128_ecb(void);\nconst EVP_CIPHER *EVP_camellia_128_cbc(void);\nconst EVP_CIPHER *EVP_camellia_128_cfb1(void);\nconst EVP_CIPHER *EVP_camellia_128_cfb8(void);\nconst EVP_CIPHER *EVP_camellia_128_cfb128(void);\n#  define EVP_camellia_128_cfb EVP_camellia_128_cfb128\nconst EVP_CIPHER *EVP_camellia_128_ofb(void);\nconst EVP_CIPHER *EVP_camellia_192_ecb(void);\nconst EVP_CIPHER *EVP_camellia_192_cbc(void);\nconst EVP_CIPHER *EVP_camellia_192_cfb1(void);\nconst EVP_CIPHER *EVP_camellia_192_cfb8(void);\nconst EVP_CIPHER *EVP_camellia_192_cfb128(void);\n#  define EVP_camellia_192_cfb EVP_camellia_192_cfb128\nconst EVP_CIPHER *EVP_camellia_192_ofb(void);\nconst EVP_CIPHER *EVP_camellia_256_ecb(void);\nconst EVP_CIPHER *EVP_camellia_256_cbc(void);\nconst EVP_CIPHER *EVP_camellia_256_cfb1(void);\nconst EVP_CIPHER *EVP_camellia_256_cfb8(void);\nconst EVP_CIPHER *EVP_camellia_256_cfb128(void);\n#  define EVP_camellia_256_cfb EVP_camellia_256_cfb128\nconst EVP_CIPHER *EVP_camellia_256_ofb(void);\n# endif\n\n# ifndef OPENSSL_NO_SEED\nconst EVP_CIPHER *EVP_seed_ecb(void);\nconst EVP_CIPHER *EVP_seed_cbc(void);\nconst EVP_CIPHER *EVP_seed_cfb128(void);\n#  define EVP_seed_cfb EVP_seed_cfb128\nconst EVP_CIPHER *EVP_seed_ofb(void);\n# endif\n\nvoid OPENSSL_add_all_algorithms_noconf(void);\nvoid OPENSSL_add_all_algorithms_conf(void);\n\n# ifdef OPENSSL_LOAD_CONF\n#  define OpenSSL_add_all_algorithms() \\\n                OPENSSL_add_all_algorithms_conf()\n# else\n#  define OpenSSL_add_all_algorithms() \\\n                OPENSSL_add_all_algorithms_noconf()\n# endif\n\nvoid OpenSSL_add_all_ciphers(void);\nvoid OpenSSL_add_all_digests(void);\n# define SSLeay_add_all_algorithms() OpenSSL_add_all_algorithms()\n# define SSLeay_add_all_ciphers() OpenSSL_add_all_ciphers()\n# define SSLeay_add_all_digests() OpenSSL_add_all_digests()\n\nint EVP_add_cipher(const EVP_CIPHER *cipher);\nint EVP_add_digest(const EVP_MD *digest);\n\nconst EVP_CIPHER *EVP_get_cipherbyname(const char *name);\nconst EVP_MD *EVP_get_digestbyname(const char *name);\nvoid EVP_cleanup(void);\n\nvoid EVP_CIPHER_do_all(void (*fn) (const EVP_CIPHER *ciph,\n                                   const char *from, const char *to, void *x),\n                       void *arg);\nvoid EVP_CIPHER_do_all_sorted(void (*fn)\n                               (const EVP_CIPHER *ciph, const char *from,\n                                const char *to, void *x), void *arg);\n\nvoid EVP_MD_do_all(void (*fn) (const EVP_MD *ciph,\n                               const char *from, const char *to, void *x),\n                   void *arg);\nvoid EVP_MD_do_all_sorted(void (*fn)\n                           (const EVP_MD *ciph, const char *from,\n                            const char *to, void *x), void *arg);\n\nint EVP_PKEY_decrypt_old(unsigned char *dec_key,\n                         const unsigned char *enc_key, int enc_key_len,\n                         EVP_PKEY *private_key);\nint EVP_PKEY_encrypt_old(unsigned char *enc_key,\n                         const unsigned char *key, int key_len,\n                         EVP_PKEY *pub_key);\nint EVP_PKEY_type(int type);\nint EVP_PKEY_id(const EVP_PKEY *pkey);\nint EVP_PKEY_base_id(const EVP_PKEY *pkey);\nint EVP_PKEY_bits(EVP_PKEY *pkey);\nint EVP_PKEY_size(EVP_PKEY *pkey);\nint EVP_PKEY_set_type(EVP_PKEY *pkey, int type);\nint EVP_PKEY_set_type_str(EVP_PKEY *pkey, const char *str, int len);\nint EVP_PKEY_assign(EVP_PKEY *pkey, int type, void *key);\nvoid *EVP_PKEY_get0(EVP_PKEY *pkey);\n\n# ifndef OPENSSL_NO_RSA\nstruct rsa_st;\nint EVP_PKEY_set1_RSA(EVP_PKEY *pkey, struct rsa_st *key);\nstruct rsa_st *EVP_PKEY_get1_RSA(EVP_PKEY *pkey);\n# endif\n# ifndef OPENSSL_NO_DSA\nstruct dsa_st;\nint EVP_PKEY_set1_DSA(EVP_PKEY *pkey, struct dsa_st *key);\nstruct dsa_st *EVP_PKEY_get1_DSA(EVP_PKEY *pkey);\n# endif\n# ifndef OPENSSL_NO_DH\nstruct dh_st;\nint EVP_PKEY_set1_DH(EVP_PKEY *pkey, struct dh_st *key);\nstruct dh_st *EVP_PKEY_get1_DH(EVP_PKEY *pkey);\n# endif\n# ifndef OPENSSL_NO_EC\nstruct ec_key_st;\nint EVP_PKEY_set1_EC_KEY(EVP_PKEY *pkey, struct ec_key_st *key);\nstruct ec_key_st *EVP_PKEY_get1_EC_KEY(EVP_PKEY *pkey);\n# endif\n\nEVP_PKEY *EVP_PKEY_new(void);\nvoid EVP_PKEY_free(EVP_PKEY *pkey);\n\nEVP_PKEY *d2i_PublicKey(int type, EVP_PKEY **a, const unsigned char **pp,\n                        long length);\nint i2d_PublicKey(EVP_PKEY *a, unsigned char **pp);\n\nEVP_PKEY *d2i_PrivateKey(int type, EVP_PKEY **a, const unsigned char **pp,\n                         long length);\nEVP_PKEY *d2i_AutoPrivateKey(EVP_PKEY **a, const unsigned char **pp,\n                             long length);\nint i2d_PrivateKey(EVP_PKEY *a, unsigned char **pp);\n\nint EVP_PKEY_copy_parameters(EVP_PKEY *to, const EVP_PKEY *from);\nint EVP_PKEY_missing_parameters(const EVP_PKEY *pkey);\nint EVP_PKEY_save_parameters(EVP_PKEY *pkey, int mode);\nint EVP_PKEY_cmp_parameters(const EVP_PKEY *a, const EVP_PKEY *b);\n\nint EVP_PKEY_cmp(const EVP_PKEY *a, const EVP_PKEY *b);\n\nint EVP_PKEY_print_public(BIO *out, const EVP_PKEY *pkey,\n                          int indent, ASN1_PCTX *pctx);\nint EVP_PKEY_print_private(BIO *out, const EVP_PKEY *pkey,\n                           int indent, ASN1_PCTX *pctx);\nint EVP_PKEY_print_params(BIO *out, const EVP_PKEY *pkey,\n                          int indent, ASN1_PCTX *pctx);\n\nint EVP_PKEY_get_default_digest_nid(EVP_PKEY *pkey, int *pnid);\n\nint EVP_CIPHER_type(const EVP_CIPHER *ctx);\n\n/* calls methods */\nint EVP_CIPHER_param_to_asn1(EVP_CIPHER_CTX *c, ASN1_TYPE *type);\nint EVP_CIPHER_asn1_to_param(EVP_CIPHER_CTX *c, ASN1_TYPE *type);\n\n/* These are used by EVP_CIPHER methods */\nint EVP_CIPHER_set_asn1_iv(EVP_CIPHER_CTX *c, ASN1_TYPE *type);\nint EVP_CIPHER_get_asn1_iv(EVP_CIPHER_CTX *c, ASN1_TYPE *type);\n\n/* PKCS5 password based encryption */\nint PKCS5_PBE_keyivgen(EVP_CIPHER_CTX *ctx, const char *pass, int passlen,\n                       ASN1_TYPE *param, const EVP_CIPHER *cipher,\n                       const EVP_MD *md, int en_de);\nint PKCS5_PBKDF2_HMAC_SHA1(const char *pass, int passlen,\n                           const unsigned char *salt, int saltlen, int iter,\n                           int keylen, unsigned char *out);\nint PKCS5_PBKDF2_HMAC(const char *pass, int passlen,\n                      const unsigned char *salt, int saltlen, int iter,\n                      const EVP_MD *digest, int keylen, unsigned char *out);\nint PKCS5_v2_PBE_keyivgen(EVP_CIPHER_CTX *ctx, const char *pass, int passlen,\n                          ASN1_TYPE *param, const EVP_CIPHER *cipher,\n                          const EVP_MD *md, int en_de);\n\nvoid PKCS5_PBE_add(void);\n\nint EVP_PBE_CipherInit(ASN1_OBJECT *pbe_obj, const char *pass, int passlen,\n                       ASN1_TYPE *param, EVP_CIPHER_CTX *ctx, int en_de);\n\n/* PBE type */\n\n/* Can appear as the outermost AlgorithmIdentifier */\n# define EVP_PBE_TYPE_OUTER      0x0\n/* Is an PRF type OID */\n# define EVP_PBE_TYPE_PRF        0x1\n\nint EVP_PBE_alg_add_type(int pbe_type, int pbe_nid, int cipher_nid,\n                         int md_nid, EVP_PBE_KEYGEN *keygen);\nint EVP_PBE_alg_add(int nid, const EVP_CIPHER *cipher, const EVP_MD *md,\n                    EVP_PBE_KEYGEN *keygen);\nint EVP_PBE_find(int type, int pbe_nid, int *pcnid, int *pmnid,\n                 EVP_PBE_KEYGEN **pkeygen);\nvoid EVP_PBE_cleanup(void);\n\n# define ASN1_PKEY_ALIAS         0x1\n# define ASN1_PKEY_DYNAMIC       0x2\n# define ASN1_PKEY_SIGPARAM_NULL 0x4\n\n# define ASN1_PKEY_CTRL_PKCS7_SIGN       0x1\n# define ASN1_PKEY_CTRL_PKCS7_ENCRYPT    0x2\n# define ASN1_PKEY_CTRL_DEFAULT_MD_NID   0x3\n# define ASN1_PKEY_CTRL_CMS_SIGN         0x5\n# define ASN1_PKEY_CTRL_CMS_ENVELOPE     0x7\n# define ASN1_PKEY_CTRL_CMS_RI_TYPE      0x8\n\nint EVP_PKEY_asn1_get_count(void);\nconst EVP_PKEY_ASN1_METHOD *EVP_PKEY_asn1_get0(int idx);\nconst EVP_PKEY_ASN1_METHOD *EVP_PKEY_asn1_find(ENGINE **pe, int type);\nconst EVP_PKEY_ASN1_METHOD *EVP_PKEY_asn1_find_str(ENGINE **pe,\n                                                   const char *str, int len);\nint EVP_PKEY_asn1_add0(const EVP_PKEY_ASN1_METHOD *ameth);\nint EVP_PKEY_asn1_add_alias(int to, int from);\nint EVP_PKEY_asn1_get0_info(int *ppkey_id, int *pkey_base_id,\n                            int *ppkey_flags, const char **pinfo,\n                            const char **ppem_str,\n                            const EVP_PKEY_ASN1_METHOD *ameth);\n\nconst EVP_PKEY_ASN1_METHOD *EVP_PKEY_get0_asn1(EVP_PKEY *pkey);\nEVP_PKEY_ASN1_METHOD *EVP_PKEY_asn1_new(int id, int flags,\n                                        const char *pem_str,\n                                        const char *info);\nvoid EVP_PKEY_asn1_copy(EVP_PKEY_ASN1_METHOD *dst,\n                        const EVP_PKEY_ASN1_METHOD *src);\nvoid EVP_PKEY_asn1_free(EVP_PKEY_ASN1_METHOD *ameth);\nvoid EVP_PKEY_asn1_set_public(EVP_PKEY_ASN1_METHOD *ameth,\n                              int (*pub_decode) (EVP_PKEY *pk,\n                                                 X509_PUBKEY *pub),\n                              int (*pub_encode) (X509_PUBKEY *pub,\n                                                 const EVP_PKEY *pk),\n                              int (*pub_cmp) (const EVP_PKEY *a,\n                                              const EVP_PKEY *b),\n                              int (*pub_print) (BIO *out,\n                                                const EVP_PKEY *pkey,\n                                                int indent, ASN1_PCTX *pctx),\n                              int (*pkey_size) (const EVP_PKEY *pk),\n                              int (*pkey_bits) (const EVP_PKEY *pk));\nvoid EVP_PKEY_asn1_set_private(EVP_PKEY_ASN1_METHOD *ameth,\n                               int (*priv_decode) (EVP_PKEY *pk,\n                                                   PKCS8_PRIV_KEY_INFO\n                                                   *p8inf),\n                               int (*priv_encode) (PKCS8_PRIV_KEY_INFO *p8,\n                                                   const EVP_PKEY *pk),\n                               int (*priv_print) (BIO *out,\n                                                  const EVP_PKEY *pkey,\n                                                  int indent,\n                                                  ASN1_PCTX *pctx));\nvoid EVP_PKEY_asn1_set_param(EVP_PKEY_ASN1_METHOD *ameth,\n                             int (*param_decode) (EVP_PKEY *pkey,\n                                                  const unsigned char **pder,\n                                                  int derlen),\n                             int (*param_encode) (const EVP_PKEY *pkey,\n                                                  unsigned char **pder),\n                             int (*param_missing) (const EVP_PKEY *pk),\n                             int (*param_copy) (EVP_PKEY *to,\n                                                const EVP_PKEY *from),\n                             int (*param_cmp) (const EVP_PKEY *a,\n                                               const EVP_PKEY *b),\n                             int (*param_print) (BIO *out,\n                                                 const EVP_PKEY *pkey,\n                                                 int indent,\n                                                 ASN1_PCTX *pctx));\n\nvoid EVP_PKEY_asn1_set_free(EVP_PKEY_ASN1_METHOD *ameth,\n                            void (*pkey_free) (EVP_PKEY *pkey));\nvoid EVP_PKEY_asn1_set_ctrl(EVP_PKEY_ASN1_METHOD *ameth,\n                            int (*pkey_ctrl) (EVP_PKEY *pkey, int op,\n                                              long arg1, void *arg2));\nvoid EVP_PKEY_asn1_set_item(EVP_PKEY_ASN1_METHOD *ameth,\n                            int (*item_verify) (EVP_MD_CTX *ctx,\n                                                const ASN1_ITEM *it,\n                                                void *asn,\n                                                X509_ALGOR *a,\n                                                ASN1_BIT_STRING *sig,\n                                                EVP_PKEY *pkey),\n                            int (*item_sign) (EVP_MD_CTX *ctx,\n                                              const ASN1_ITEM *it,\n                                              void *asn,\n                                              X509_ALGOR *alg1,\n                                              X509_ALGOR *alg2,\n                                              ASN1_BIT_STRING *sig));\n\n# define EVP_PKEY_OP_UNDEFINED           0\n# define EVP_PKEY_OP_PARAMGEN            (1<<1)\n# define EVP_PKEY_OP_KEYGEN              (1<<2)\n# define EVP_PKEY_OP_SIGN                (1<<3)\n# define EVP_PKEY_OP_VERIFY              (1<<4)\n# define EVP_PKEY_OP_VERIFYRECOVER       (1<<5)\n# define EVP_PKEY_OP_SIGNCTX             (1<<6)\n# define EVP_PKEY_OP_VERIFYCTX           (1<<7)\n# define EVP_PKEY_OP_ENCRYPT             (1<<8)\n# define EVP_PKEY_OP_DECRYPT             (1<<9)\n# define EVP_PKEY_OP_DERIVE              (1<<10)\n\n# define EVP_PKEY_OP_TYPE_SIG    \\\n        (EVP_PKEY_OP_SIGN | EVP_PKEY_OP_VERIFY | EVP_PKEY_OP_VERIFYRECOVER \\\n                | EVP_PKEY_OP_SIGNCTX | EVP_PKEY_OP_VERIFYCTX)\n\n# define EVP_PKEY_OP_TYPE_CRYPT \\\n        (EVP_PKEY_OP_ENCRYPT | EVP_PKEY_OP_DECRYPT)\n\n# define EVP_PKEY_OP_TYPE_NOGEN \\\n        (EVP_PKEY_OP_SIG | EVP_PKEY_OP_CRYPT | EVP_PKEY_OP_DERIVE)\n\n# define EVP_PKEY_OP_TYPE_GEN \\\n                (EVP_PKEY_OP_PARAMGEN | EVP_PKEY_OP_KEYGEN)\n\n# define  EVP_PKEY_CTX_set_signature_md(ctx, md) \\\n                EVP_PKEY_CTX_ctrl(ctx, -1, EVP_PKEY_OP_TYPE_SIG,  \\\n                                        EVP_PKEY_CTRL_MD, 0, (void *)md)\n\n# define  EVP_PKEY_CTX_get_signature_md(ctx, pmd)        \\\n                EVP_PKEY_CTX_ctrl(ctx, -1, EVP_PKEY_OP_TYPE_SIG,  \\\n                                        EVP_PKEY_CTRL_GET_MD, 0, (void *)pmd)\n\n# define EVP_PKEY_CTRL_MD                1\n# define EVP_PKEY_CTRL_PEER_KEY          2\n\n# define EVP_PKEY_CTRL_PKCS7_ENCRYPT     3\n# define EVP_PKEY_CTRL_PKCS7_DECRYPT     4\n\n# define EVP_PKEY_CTRL_PKCS7_SIGN        5\n\n# define EVP_PKEY_CTRL_SET_MAC_KEY       6\n\n# define EVP_PKEY_CTRL_DIGESTINIT        7\n\n/* Used by GOST key encryption in TLS */\n# define EVP_PKEY_CTRL_SET_IV            8\n\n# define EVP_PKEY_CTRL_CMS_ENCRYPT       9\n# define EVP_PKEY_CTRL_CMS_DECRYPT       10\n# define EVP_PKEY_CTRL_CMS_SIGN          11\n\n# define EVP_PKEY_CTRL_CIPHER            12\n\n# define EVP_PKEY_CTRL_GET_MD            13\n\n# define EVP_PKEY_ALG_CTRL               0x1000\n\n# define EVP_PKEY_FLAG_AUTOARGLEN        2\n/*\n * Method handles all operations: don't assume any digest related defaults.\n */\n# define EVP_PKEY_FLAG_SIGCTX_CUSTOM     4\n\nconst EVP_PKEY_METHOD *EVP_PKEY_meth_find(int type);\nEVP_PKEY_METHOD *EVP_PKEY_meth_new(int id, int flags);\nvoid EVP_PKEY_meth_get0_info(int *ppkey_id, int *pflags,\n                             const EVP_PKEY_METHOD *meth);\nvoid EVP_PKEY_meth_copy(EVP_PKEY_METHOD *dst, const EVP_PKEY_METHOD *src);\nvoid EVP_PKEY_meth_free(EVP_PKEY_METHOD *pmeth);\nint EVP_PKEY_meth_add0(const EVP_PKEY_METHOD *pmeth);\n\nEVP_PKEY_CTX *EVP_PKEY_CTX_new(EVP_PKEY *pkey, ENGINE *e);\nEVP_PKEY_CTX *EVP_PKEY_CTX_new_id(int id, ENGINE *e);\nEVP_PKEY_CTX *EVP_PKEY_CTX_dup(EVP_PKEY_CTX *ctx);\nvoid EVP_PKEY_CTX_free(EVP_PKEY_CTX *ctx);\n\nint EVP_PKEY_CTX_ctrl(EVP_PKEY_CTX *ctx, int keytype, int optype,\n                      int cmd, int p1, void *p2);\nint EVP_PKEY_CTX_ctrl_str(EVP_PKEY_CTX *ctx, const char *type,\n                          const char *value);\n\nint EVP_PKEY_CTX_get_operation(EVP_PKEY_CTX *ctx);\nvoid EVP_PKEY_CTX_set0_keygen_info(EVP_PKEY_CTX *ctx, int *dat, int datlen);\n\nEVP_PKEY *EVP_PKEY_new_mac_key(int type, ENGINE *e,\n                               const unsigned char *key, int keylen);\n\nvoid EVP_PKEY_CTX_set_data(EVP_PKEY_CTX *ctx, void *data);\nvoid *EVP_PKEY_CTX_get_data(EVP_PKEY_CTX *ctx);\nEVP_PKEY *EVP_PKEY_CTX_get0_pkey(EVP_PKEY_CTX *ctx);\n\nEVP_PKEY *EVP_PKEY_CTX_get0_peerkey(EVP_PKEY_CTX *ctx);\n\nvoid EVP_PKEY_CTX_set_app_data(EVP_PKEY_CTX *ctx, void *data);\nvoid *EVP_PKEY_CTX_get_app_data(EVP_PKEY_CTX *ctx);\n\nint EVP_PKEY_sign_init(EVP_PKEY_CTX *ctx);\nint EVP_PKEY_sign(EVP_PKEY_CTX *ctx,\n                  unsigned char *sig, size_t *siglen,\n                  const unsigned char *tbs, size_t tbslen);\nint EVP_PKEY_verify_init(EVP_PKEY_CTX *ctx);\nint EVP_PKEY_verify(EVP_PKEY_CTX *ctx,\n                    const unsigned char *sig, size_t siglen,\n                    const unsigned char *tbs, size_t tbslen);\nint EVP_PKEY_verify_recover_init(EVP_PKEY_CTX *ctx);\nint EVP_PKEY_verify_recover(EVP_PKEY_CTX *ctx,\n                            unsigned char *rout, size_t *routlen,\n                            const unsigned char *sig, size_t siglen);\nint EVP_PKEY_encrypt_init(EVP_PKEY_CTX *ctx);\nint EVP_PKEY_encrypt(EVP_PKEY_CTX *ctx,\n                     unsigned char *out, size_t *outlen,\n                     const unsigned char *in, size_t inlen);\nint EVP_PKEY_decrypt_init(EVP_PKEY_CTX *ctx);\nint EVP_PKEY_decrypt(EVP_PKEY_CTX *ctx,\n                     unsigned char *out, size_t *outlen,\n                     const unsigned char *in, size_t inlen);\n\nint EVP_PKEY_derive_init(EVP_PKEY_CTX *ctx);\nint EVP_PKEY_derive_set_peer(EVP_PKEY_CTX *ctx, EVP_PKEY *peer);\nint EVP_PKEY_derive(EVP_PKEY_CTX *ctx, unsigned char *key, size_t *keylen);\n\ntypedef int EVP_PKEY_gen_cb (EVP_PKEY_CTX *ctx);\n\nint EVP_PKEY_paramgen_init(EVP_PKEY_CTX *ctx);\nint EVP_PKEY_paramgen(EVP_PKEY_CTX *ctx, EVP_PKEY **ppkey);\nint EVP_PKEY_keygen_init(EVP_PKEY_CTX *ctx);\nint EVP_PKEY_keygen(EVP_PKEY_CTX *ctx, EVP_PKEY **ppkey);\n\nvoid EVP_PKEY_CTX_set_cb(EVP_PKEY_CTX *ctx, EVP_PKEY_gen_cb *cb);\nEVP_PKEY_gen_cb *EVP_PKEY_CTX_get_cb(EVP_PKEY_CTX *ctx);\n\nint EVP_PKEY_CTX_get_keygen_info(EVP_PKEY_CTX *ctx, int idx);\n\nvoid EVP_PKEY_meth_set_init(EVP_PKEY_METHOD *pmeth,\n                            int (*init) (EVP_PKEY_CTX *ctx));\n\nvoid EVP_PKEY_meth_set_copy(EVP_PKEY_METHOD *pmeth,\n                            int (*copy) (EVP_PKEY_CTX *dst,\n                                         EVP_PKEY_CTX *src));\n\nvoid EVP_PKEY_meth_set_cleanup(EVP_PKEY_METHOD *pmeth,\n                               void (*cleanup) (EVP_PKEY_CTX *ctx));\n\nvoid EVP_PKEY_meth_set_paramgen(EVP_PKEY_METHOD *pmeth,\n                                int (*paramgen_init) (EVP_PKEY_CTX *ctx),\n                                int (*paramgen) (EVP_PKEY_CTX *ctx,\n                                                 EVP_PKEY *pkey));\n\nvoid EVP_PKEY_meth_set_keygen(EVP_PKEY_METHOD *pmeth,\n                              int (*keygen_init) (EVP_PKEY_CTX *ctx),\n                              int (*keygen) (EVP_PKEY_CTX *ctx,\n                                             EVP_PKEY *pkey));\n\nvoid EVP_PKEY_meth_set_sign(EVP_PKEY_METHOD *pmeth,\n                            int (*sign_init) (EVP_PKEY_CTX *ctx),\n                            int (*sign) (EVP_PKEY_CTX *ctx,\n                                         unsigned char *sig, size_t *siglen,\n                                         const unsigned char *tbs,\n                                         size_t tbslen));\n\nvoid EVP_PKEY_meth_set_verify(EVP_PKEY_METHOD *pmeth,\n                              int (*verify_init) (EVP_PKEY_CTX *ctx),\n                              int (*verify) (EVP_PKEY_CTX *ctx,\n                                             const unsigned char *sig,\n                                             size_t siglen,\n                                             const unsigned char *tbs,\n                                             size_t tbslen));\n\nvoid EVP_PKEY_meth_set_verify_recover(EVP_PKEY_METHOD *pmeth,\n                                      int (*verify_recover_init) (EVP_PKEY_CTX\n                                                                  *ctx),\n                                      int (*verify_recover) (EVP_PKEY_CTX\n                                                             *ctx,\n                                                             unsigned char\n                                                             *sig,\n                                                             size_t *siglen,\n                                                             const unsigned\n                                                             char *tbs,\n                                                             size_t tbslen));\n\nvoid EVP_PKEY_meth_set_signctx(EVP_PKEY_METHOD *pmeth,\n                               int (*signctx_init) (EVP_PKEY_CTX *ctx,\n                                                    EVP_MD_CTX *mctx),\n                               int (*signctx) (EVP_PKEY_CTX *ctx,\n                                               unsigned char *sig,\n                                               size_t *siglen,\n                                               EVP_MD_CTX *mctx));\n\nvoid EVP_PKEY_meth_set_verifyctx(EVP_PKEY_METHOD *pmeth,\n                                 int (*verifyctx_init) (EVP_PKEY_CTX *ctx,\n                                                        EVP_MD_CTX *mctx),\n                                 int (*verifyctx) (EVP_PKEY_CTX *ctx,\n                                                   const unsigned char *sig,\n                                                   int siglen,\n                                                   EVP_MD_CTX *mctx));\n\nvoid EVP_PKEY_meth_set_encrypt(EVP_PKEY_METHOD *pmeth,\n                               int (*encrypt_init) (EVP_PKEY_CTX *ctx),\n                               int (*encryptfn) (EVP_PKEY_CTX *ctx,\n                                                 unsigned char *out,\n                                                 size_t *outlen,\n                                                 const unsigned char *in,\n                                                 size_t inlen));\n\nvoid EVP_PKEY_meth_set_decrypt(EVP_PKEY_METHOD *pmeth,\n                               int (*decrypt_init) (EVP_PKEY_CTX *ctx),\n                               int (*decrypt) (EVP_PKEY_CTX *ctx,\n                                               unsigned char *out,\n                                               size_t *outlen,\n                                               const unsigned char *in,\n                                               size_t inlen));\n\nvoid EVP_PKEY_meth_set_derive(EVP_PKEY_METHOD *pmeth,\n                              int (*derive_init) (EVP_PKEY_CTX *ctx),\n                              int (*derive) (EVP_PKEY_CTX *ctx,\n                                             unsigned char *key,\n                                             size_t *keylen));\n\nvoid EVP_PKEY_meth_set_ctrl(EVP_PKEY_METHOD *pmeth,\n                            int (*ctrl) (EVP_PKEY_CTX *ctx, int type, int p1,\n                                         void *p2),\n                            int (*ctrl_str) (EVP_PKEY_CTX *ctx,\n                                             const char *type,\n                                             const char *value));\n\nvoid EVP_add_alg_module(void);\n\n/* BEGIN ERROR CODES */\n/*\n * The following lines are auto generated by the script mkerr.pl. Any changes\n * made after this point may be overwritten when the script is next run.\n */\n\nvoid ERR_load_EVP_strings(void);\n\n/* Error codes for the EVP functions. */\n\n/* Function codes. */\n# define EVP_F_AESNI_INIT_KEY                             165\n# define EVP_F_AESNI_XTS_CIPHER                           176\n# define EVP_F_AES_INIT_KEY                               133\n# define EVP_F_AES_T4_INIT_KEY                            178\n# define EVP_F_AES_XTS                                    172\n# define EVP_F_AES_XTS_CIPHER                             175\n# define EVP_F_ALG_MODULE_INIT                            177\n# define EVP_F_CAMELLIA_INIT_KEY                          159\n# define EVP_F_CMAC_INIT                                  173\n# define EVP_F_CMLL_T4_INIT_KEY                           179\n# define EVP_F_D2I_PKEY                                   100\n# define EVP_F_DO_SIGVER_INIT                             161\n# define EVP_F_DSAPKEY2PKCS8                              134\n# define EVP_F_DSA_PKEY2PKCS8                             135\n# define EVP_F_ECDSA_PKEY2PKCS8                           129\n# define EVP_F_ECKEY_PKEY2PKCS8                           132\n# define EVP_F_EVP_CIPHERINIT_EX                          123\n# define EVP_F_EVP_CIPHER_CTX_COPY                        163\n# define EVP_F_EVP_CIPHER_CTX_CTRL                        124\n# define EVP_F_EVP_CIPHER_CTX_SET_KEY_LENGTH              122\n# define EVP_F_EVP_DECRYPTFINAL_EX                        101\n# define EVP_F_EVP_DIGESTINIT_EX                          128\n# define EVP_F_EVP_ENCRYPTFINAL_EX                        127\n# define EVP_F_EVP_MD_CTX_COPY_EX                         110\n# define EVP_F_EVP_MD_SIZE                                162\n# define EVP_F_EVP_OPENINIT                               102\n# define EVP_F_EVP_PBE_ALG_ADD                            115\n# define EVP_F_EVP_PBE_ALG_ADD_TYPE                       160\n# define EVP_F_EVP_PBE_CIPHERINIT                         116\n# define EVP_F_EVP_PKCS82PKEY                             111\n# define EVP_F_EVP_PKCS82PKEY_BROKEN                      136\n# define EVP_F_EVP_PKEY2PKCS8_BROKEN                      113\n# define EVP_F_EVP_PKEY_COPY_PARAMETERS                   103\n# define EVP_F_EVP_PKEY_CTX_CTRL                          137\n# define EVP_F_EVP_PKEY_CTX_CTRL_STR                      150\n# define EVP_F_EVP_PKEY_CTX_DUP                           156\n# define EVP_F_EVP_PKEY_DECRYPT                           104\n# define EVP_F_EVP_PKEY_DECRYPT_INIT                      138\n# define EVP_F_EVP_PKEY_DECRYPT_OLD                       151\n# define EVP_F_EVP_PKEY_DERIVE                            153\n# define EVP_F_EVP_PKEY_DERIVE_INIT                       154\n# define EVP_F_EVP_PKEY_DERIVE_SET_PEER                   155\n# define EVP_F_EVP_PKEY_ENCRYPT                           105\n# define EVP_F_EVP_PKEY_ENCRYPT_INIT                      139\n# define EVP_F_EVP_PKEY_ENCRYPT_OLD                       152\n# define EVP_F_EVP_PKEY_GET1_DH                           119\n# define EVP_F_EVP_PKEY_GET1_DSA                          120\n# define EVP_F_EVP_PKEY_GET1_ECDSA                        130\n# define EVP_F_EVP_PKEY_GET1_EC_KEY                       131\n# define EVP_F_EVP_PKEY_GET1_RSA                          121\n# define EVP_F_EVP_PKEY_KEYGEN                            146\n# define EVP_F_EVP_PKEY_KEYGEN_INIT                       147\n# define EVP_F_EVP_PKEY_NEW                               106\n# define EVP_F_EVP_PKEY_PARAMGEN                          148\n# define EVP_F_EVP_PKEY_PARAMGEN_INIT                     149\n# define EVP_F_EVP_PKEY_SIGN                              140\n# define EVP_F_EVP_PKEY_SIGN_INIT                         141\n# define EVP_F_EVP_PKEY_VERIFY                            142\n# define EVP_F_EVP_PKEY_VERIFY_INIT                       143\n# define EVP_F_EVP_PKEY_VERIFY_RECOVER                    144\n# define EVP_F_EVP_PKEY_VERIFY_RECOVER_INIT               145\n# define EVP_F_EVP_RIJNDAEL                               126\n# define EVP_F_EVP_SIGNFINAL                              107\n# define EVP_F_EVP_VERIFYFINAL                            108\n# define EVP_F_FIPS_CIPHERINIT                            166\n# define EVP_F_FIPS_CIPHER_CTX_COPY                       170\n# define EVP_F_FIPS_CIPHER_CTX_CTRL                       167\n# define EVP_F_FIPS_CIPHER_CTX_SET_KEY_LENGTH             171\n# define EVP_F_FIPS_DIGESTINIT                            168\n# define EVP_F_FIPS_MD_CTX_COPY                           169\n# define EVP_F_HMAC_INIT_EX                               174\n# define EVP_F_INT_CTX_NEW                                157\n# define EVP_F_PKCS5_PBE_KEYIVGEN                         117\n# define EVP_F_PKCS5_V2_PBE_KEYIVGEN                      118\n# define EVP_F_PKCS5_V2_PBKDF2_KEYIVGEN                   164\n# define EVP_F_PKCS8_SET_BROKEN                           112\n# define EVP_F_PKEY_SET_TYPE                              158\n# define EVP_F_RC2_MAGIC_TO_METH                          109\n# define EVP_F_RC5_CTRL                                   125\n\n/* Reason codes. */\n# define EVP_R_AES_IV_SETUP_FAILED                        162\n# define EVP_R_AES_KEY_SETUP_FAILED                       143\n# define EVP_R_ASN1_LIB                                   140\n# define EVP_R_BAD_BLOCK_LENGTH                           136\n# define EVP_R_BAD_DECRYPT                                100\n# define EVP_R_BAD_KEY_LENGTH                             137\n# define EVP_R_BN_DECODE_ERROR                            112\n# define EVP_R_BN_PUBKEY_ERROR                            113\n# define EVP_R_BUFFER_TOO_SMALL                           155\n# define EVP_R_CAMELLIA_KEY_SETUP_FAILED                  157\n# define EVP_R_CIPHER_PARAMETER_ERROR                     122\n# define EVP_R_COMMAND_NOT_SUPPORTED                      147\n# define EVP_R_CTRL_NOT_IMPLEMENTED                       132\n# define EVP_R_CTRL_OPERATION_NOT_IMPLEMENTED             133\n# define EVP_R_DATA_NOT_MULTIPLE_OF_BLOCK_LENGTH          138\n# define EVP_R_DECODE_ERROR                               114\n# define EVP_R_DIFFERENT_KEY_TYPES                        101\n# define EVP_R_DIFFERENT_PARAMETERS                       153\n# define EVP_R_DISABLED_FOR_FIPS                          163\n# define EVP_R_ENCODE_ERROR                               115\n# define EVP_R_ERROR_LOADING_SECTION                      165\n# define EVP_R_ERROR_SETTING_FIPS_MODE                    166\n# define EVP_R_EVP_PBE_CIPHERINIT_ERROR                   119\n# define EVP_R_EXPECTING_AN_RSA_KEY                       127\n# define EVP_R_EXPECTING_A_DH_KEY                         128\n# define EVP_R_EXPECTING_A_DSA_KEY                        129\n# define EVP_R_EXPECTING_A_ECDSA_KEY                      141\n# define EVP_R_EXPECTING_A_EC_KEY                         142\n# define EVP_R_FIPS_MODE_NOT_SUPPORTED                    167\n# define EVP_R_INITIALIZATION_ERROR                       134\n# define EVP_R_INPUT_NOT_INITIALIZED                      111\n# define EVP_R_INVALID_DIGEST                             152\n# define EVP_R_INVALID_FIPS_MODE                          168\n# define EVP_R_INVALID_KEY                                171\n# define EVP_R_INVALID_KEY_LENGTH                         130\n# define EVP_R_INVALID_OPERATION                          148\n# define EVP_R_IV_TOO_LARGE                               102\n# define EVP_R_KEYGEN_FAILURE                             120\n# define EVP_R_MESSAGE_DIGEST_IS_NULL                     159\n# define EVP_R_METHOD_NOT_SUPPORTED                       144\n# define EVP_R_MISSING_PARAMETERS                         103\n# define EVP_R_NO_CIPHER_SET                              131\n# define EVP_R_NO_DEFAULT_DIGEST                          158\n# define EVP_R_NO_DIGEST_SET                              139\n# define EVP_R_NO_DSA_PARAMETERS                          116\n# define EVP_R_NO_KEY_SET                                 154\n# define EVP_R_NO_OPERATION_SET                           149\n# define EVP_R_NO_SIGN_FUNCTION_CONFIGURED                104\n# define EVP_R_NO_VERIFY_FUNCTION_CONFIGURED              105\n# define EVP_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE   150\n# define EVP_R_OPERATON_NOT_INITIALIZED                   151\n# define EVP_R_PKCS8_UNKNOWN_BROKEN_TYPE                  117\n# define EVP_R_PRIVATE_KEY_DECODE_ERROR                   145\n# define EVP_R_PRIVATE_KEY_ENCODE_ERROR                   146\n# define EVP_R_PUBLIC_KEY_NOT_RSA                         106\n# define EVP_R_TOO_LARGE                                  164\n# define EVP_R_UNKNOWN_CIPHER                             160\n# define EVP_R_UNKNOWN_DIGEST                             161\n# define EVP_R_UNKNOWN_OPTION                             169\n# define EVP_R_UNKNOWN_PBE_ALGORITHM                      121\n# define EVP_R_UNSUPORTED_NUMBER_OF_ROUNDS                135\n# define EVP_R_UNSUPPORTED_ALGORITHM                      156\n# define EVP_R_UNSUPPORTED_CIPHER                         107\n# define EVP_R_UNSUPPORTED_KEYLENGTH                      123\n# define EVP_R_UNSUPPORTED_KEY_DERIVATION_FUNCTION        124\n# define EVP_R_UNSUPPORTED_KEY_SIZE                       108\n# define EVP_R_UNSUPPORTED_PRF                            125\n# define EVP_R_UNSUPPORTED_PRIVATE_KEY_ALGORITHM          118\n# define EVP_R_UNSUPPORTED_SALT_TYPE                      126\n# define EVP_R_WRAP_MODE_NOT_ALLOWED                      170\n# define EVP_R_WRONG_FINAL_BLOCK_LENGTH                   109\n# define EVP_R_WRONG_PUBLIC_KEY_TYPE                      110\n\n# ifdef  __cplusplus\n}\n# endif\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/arm/include/openssl/hmac.h",
    "content": "/* crypto/hmac/hmac.h */\n/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)\n * All rights reserved.\n *\n * This package is an SSL implementation written\n * by Eric Young (eay@cryptsoft.com).\n * The implementation was written so as to conform with Netscapes SSL.\n *\n * This library is free for commercial and non-commercial use as long as\n * the following conditions are aheared to.  The following conditions\n * apply to all code found in this distribution, be it the RC4, RSA,\n * lhash, DES, etc., code; not just the SSL code.  The SSL documentation\n * included with this distribution is covered by the same copyright terms\n * except that the holder is Tim Hudson (tjh@cryptsoft.com).\n *\n * Copyright remains Eric Young's, and as such any Copyright notices in\n * the code are not to be removed.\n * If this package is used in a product, Eric Young should be given attribution\n * as the author of the parts of the library used.\n * This can be in the form of a textual message at program startup or\n * in documentation (online or textual) provided with the package.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the copyright\n *    notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in the\n *    documentation and/or other materials provided with the distribution.\n * 3. All advertising materials mentioning features or use of this software\n *    must display the following acknowledgement:\n *    \"This product includes cryptographic software written by\n *     Eric Young (eay@cryptsoft.com)\"\n *    The word 'cryptographic' can be left out if the rouines from the library\n *    being used are not cryptographic related :-).\n * 4. If you include any Windows specific code (or a derivative thereof) from\n *    the apps directory (application code) you must include an acknowledgement:\n *    \"This product includes software written by Tim Hudson (tjh@cryptsoft.com)\"\n *\n * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n * SUCH DAMAGE.\n *\n * The licence and distribution terms for any publically available version or\n * derivative of this code cannot be changed.  i.e. this code cannot simply be\n * copied and put under another distribution licence\n * [including the GNU Public Licence.]\n */\n#ifndef HEADER_HMAC_H\n# define HEADER_HMAC_H\n\n# include <openssl/opensslconf.h>\n\n# ifdef OPENSSL_NO_HMAC\n#  error HMAC is disabled.\n# endif\n\n# include <openssl/evp.h>\n\n# define HMAC_MAX_MD_CBLOCK      128/* largest known is SHA512 */\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\ntypedef struct hmac_ctx_st {\n    const EVP_MD *md;\n    EVP_MD_CTX md_ctx;\n    EVP_MD_CTX i_ctx;\n    EVP_MD_CTX o_ctx;\n    unsigned int key_length;\n    unsigned char key[HMAC_MAX_MD_CBLOCK];\n} HMAC_CTX;\n\n# define HMAC_size(e)    (EVP_MD_size((e)->md))\n\nvoid HMAC_CTX_init(HMAC_CTX *ctx);\nvoid HMAC_CTX_cleanup(HMAC_CTX *ctx);\n\n/* deprecated */\n# define HMAC_cleanup(ctx) HMAC_CTX_cleanup(ctx)\n\n/* deprecated */\nint HMAC_Init(HMAC_CTX *ctx, const void *key, int len, const EVP_MD *md);\nint HMAC_Init_ex(HMAC_CTX *ctx, const void *key, int len,\n                 const EVP_MD *md, ENGINE *impl);\nint HMAC_Update(HMAC_CTX *ctx, const unsigned char *data, size_t len);\nint HMAC_Final(HMAC_CTX *ctx, unsigned char *md, unsigned int *len);\nunsigned char *HMAC(const EVP_MD *evp_md, const void *key, int key_len,\n                    const unsigned char *d, size_t n, unsigned char *md,\n                    unsigned int *md_len);\nint HMAC_CTX_copy(HMAC_CTX *dctx, HMAC_CTX *sctx);\n\nvoid HMAC_CTX_set_flags(HMAC_CTX *ctx, unsigned long flags);\n\n#ifdef  __cplusplus\n}\n#endif\n\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/arm/include/openssl/idea.h",
    "content": "/* crypto/idea/idea.h */\n/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)\n * All rights reserved.\n *\n * This package is an SSL implementation written\n * by Eric Young (eay@cryptsoft.com).\n * The implementation was written so as to conform with Netscapes SSL.\n *\n * This library is free for commercial and non-commercial use as long as\n * the following conditions are aheared to.  The following conditions\n * apply to all code found in this distribution, be it the RC4, RSA,\n * lhash, DES, etc., code; not just the SSL code.  The SSL documentation\n * included with this distribution is covered by the same copyright terms\n * except that the holder is Tim Hudson (tjh@cryptsoft.com).\n *\n * Copyright remains Eric Young's, and as such any Copyright notices in\n * the code are not to be removed.\n * If this package is used in a product, Eric Young should be given attribution\n * as the author of the parts of the library used.\n * This can be in the form of a textual message at program startup or\n * in documentation (online or textual) provided with the package.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the copyright\n *    notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in the\n *    documentation and/or other materials provided with the distribution.\n * 3. All advertising materials mentioning features or use of this software\n *    must display the following acknowledgement:\n *    \"This product includes cryptographic software written by\n *     Eric Young (eay@cryptsoft.com)\"\n *    The word 'cryptographic' can be left out if the rouines from the library\n *    being used are not cryptographic related :-).\n * 4. If you include any Windows specific code (or a derivative thereof) from\n *    the apps directory (application code) you must include an acknowledgement:\n *    \"This product includes software written by Tim Hudson (tjh@cryptsoft.com)\"\n *\n * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n * SUCH DAMAGE.\n *\n * The licence and distribution terms for any publically available version or\n * derivative of this code cannot be changed.  i.e. this code cannot simply be\n * copied and put under another distribution licence\n * [including the GNU Public Licence.]\n */\n\n#ifndef HEADER_IDEA_H\n# define HEADER_IDEA_H\n\n# include <openssl/opensslconf.h>/* IDEA_INT, OPENSSL_NO_IDEA */\n\n# ifdef OPENSSL_NO_IDEA\n#  error IDEA is disabled.\n# endif\n\n# define IDEA_ENCRYPT    1\n# define IDEA_DECRYPT    0\n\n# define IDEA_BLOCK      8\n# define IDEA_KEY_LENGTH 16\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\ntypedef struct idea_key_st {\n    IDEA_INT data[9][6];\n} IDEA_KEY_SCHEDULE;\n\nconst char *idea_options(void);\nvoid idea_ecb_encrypt(const unsigned char *in, unsigned char *out,\n                      IDEA_KEY_SCHEDULE *ks);\n# ifdef OPENSSL_FIPS\nvoid private_idea_set_encrypt_key(const unsigned char *key,\n                                  IDEA_KEY_SCHEDULE *ks);\n# endif\nvoid idea_set_encrypt_key(const unsigned char *key, IDEA_KEY_SCHEDULE *ks);\nvoid idea_set_decrypt_key(IDEA_KEY_SCHEDULE *ek, IDEA_KEY_SCHEDULE *dk);\nvoid idea_cbc_encrypt(const unsigned char *in, unsigned char *out,\n                      long length, IDEA_KEY_SCHEDULE *ks, unsigned char *iv,\n                      int enc);\nvoid idea_cfb64_encrypt(const unsigned char *in, unsigned char *out,\n                        long length, IDEA_KEY_SCHEDULE *ks, unsigned char *iv,\n                        int *num, int enc);\nvoid idea_ofb64_encrypt(const unsigned char *in, unsigned char *out,\n                        long length, IDEA_KEY_SCHEDULE *ks, unsigned char *iv,\n                        int *num);\nvoid idea_encrypt(unsigned long *in, IDEA_KEY_SCHEDULE *ks);\n#ifdef  __cplusplus\n}\n#endif\n\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/arm/include/openssl/krb5_asn.h",
    "content": "/* krb5_asn.h */\n/*\n * Written by Vern Staats <staatsvr@asc.hpc.mil> for the OpenSSL project, **\n * using ocsp/{*.h,*asn*.c} as a starting point\n */\n\n/* ====================================================================\n * Copyright (c) 1998-2000 The OpenSSL Project.  All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n *\n * 1. Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n *\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in\n *    the documentation and/or other materials provided with the\n *    distribution.\n *\n * 3. All advertising materials mentioning features or use of this\n *    software must display the following acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit. (http://www.openssl.org/)\"\n *\n * 4. The names \"OpenSSL Toolkit\" and \"OpenSSL Project\" must not be used to\n *    endorse or promote products derived from this software without\n *    prior written permission. For written permission, please contact\n *    openssl-core@openssl.org.\n *\n * 5. Products derived from this software may not be called \"OpenSSL\"\n *    nor may \"OpenSSL\" appear in their names without prior written\n *    permission of the OpenSSL Project.\n *\n * 6. Redistributions of any form whatsoever must retain the following\n *    acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit (http://www.openssl.org/)\"\n *\n * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY\n * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\n * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR\n * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\n * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,\n * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED\n * OF THE POSSIBILITY OF SUCH DAMAGE.\n * ====================================================================\n *\n * This product includes cryptographic software written by Eric Young\n * (eay@cryptsoft.com).  This product includes software written by Tim\n * Hudson (tjh@cryptsoft.com).\n *\n */\n\n#ifndef HEADER_KRB5_ASN_H\n# define HEADER_KRB5_ASN_H\n\n/*\n * #include <krb5.h>\n */\n# include <openssl/safestack.h>\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n/*\n * ASN.1 from Kerberos RFC 1510\n */\n\n/*-     EncryptedData ::=   SEQUENCE {\n *              etype[0]                      INTEGER, -- EncryptionType\n *              kvno[1]                       INTEGER OPTIONAL,\n *              cipher[2]                     OCTET STRING -- ciphertext\n *      }\n */\ntypedef struct krb5_encdata_st {\n    ASN1_INTEGER *etype;\n    ASN1_INTEGER *kvno;\n    ASN1_OCTET_STRING *cipher;\n} KRB5_ENCDATA;\n\nDECLARE_STACK_OF(KRB5_ENCDATA)\n\n/*-     PrincipalName ::=   SEQUENCE {\n *              name-type[0]                  INTEGER,\n *              name-string[1]                SEQUENCE OF GeneralString\n *      }\n */\ntypedef struct krb5_princname_st {\n    ASN1_INTEGER *nametype;\n    STACK_OF(ASN1_GENERALSTRING) *namestring;\n} KRB5_PRINCNAME;\n\nDECLARE_STACK_OF(KRB5_PRINCNAME)\n\n/*-     Ticket ::=      [APPLICATION 1] SEQUENCE {\n *              tkt-vno[0]                    INTEGER,\n *              realm[1]                      Realm,\n *              sname[2]                      PrincipalName,\n *              enc-part[3]                   EncryptedData\n *      }\n */\ntypedef struct krb5_tktbody_st {\n    ASN1_INTEGER *tktvno;\n    ASN1_GENERALSTRING *realm;\n    KRB5_PRINCNAME *sname;\n    KRB5_ENCDATA *encdata;\n} KRB5_TKTBODY;\n\ntypedef STACK_OF(KRB5_TKTBODY) KRB5_TICKET;\nDECLARE_STACK_OF(KRB5_TKTBODY)\n\n/*-     AP-REQ ::=      [APPLICATION 14] SEQUENCE {\n *              pvno[0]                       INTEGER,\n *              msg-type[1]                   INTEGER,\n *              ap-options[2]                 APOptions,\n *              ticket[3]                     Ticket,\n *              authenticator[4]              EncryptedData\n *      }\n *\n *      APOptions ::=   BIT STRING {\n *              reserved(0), use-session-key(1), mutual-required(2) }\n */\ntypedef struct krb5_ap_req_st {\n    ASN1_INTEGER *pvno;\n    ASN1_INTEGER *msgtype;\n    ASN1_BIT_STRING *apoptions;\n    KRB5_TICKET *ticket;\n    KRB5_ENCDATA *authenticator;\n} KRB5_APREQBODY;\n\ntypedef STACK_OF(KRB5_APREQBODY) KRB5_APREQ;\nDECLARE_STACK_OF(KRB5_APREQBODY)\n\n/*      Authenticator Stuff     */\n\n/*-     Checksum ::=   SEQUENCE {\n *              cksumtype[0]                  INTEGER,\n *              checksum[1]                   OCTET STRING\n *      }\n */\ntypedef struct krb5_checksum_st {\n    ASN1_INTEGER *ctype;\n    ASN1_OCTET_STRING *checksum;\n} KRB5_CHECKSUM;\n\nDECLARE_STACK_OF(KRB5_CHECKSUM)\n\n/*-     EncryptionKey ::=   SEQUENCE {\n *              keytype[0]                    INTEGER,\n *              keyvalue[1]                   OCTET STRING\n *      }\n */\ntypedef struct krb5_encryptionkey_st {\n    ASN1_INTEGER *ktype;\n    ASN1_OCTET_STRING *keyvalue;\n} KRB5_ENCKEY;\n\nDECLARE_STACK_OF(KRB5_ENCKEY)\n\n/*-     AuthorizationData ::=   SEQUENCE OF SEQUENCE {\n *              ad-type[0]                    INTEGER,\n *              ad-data[1]                    OCTET STRING\n *      }\n */\ntypedef struct krb5_authorization_st {\n    ASN1_INTEGER *adtype;\n    ASN1_OCTET_STRING *addata;\n} KRB5_AUTHDATA;\n\nDECLARE_STACK_OF(KRB5_AUTHDATA)\n\n/*-     -- Unencrypted authenticator\n *      Authenticator ::=    [APPLICATION 2] SEQUENCE    {\n *              authenticator-vno[0]          INTEGER,\n *              crealm[1]                     Realm,\n *              cname[2]                      PrincipalName,\n *              cksum[3]                      Checksum OPTIONAL,\n *              cusec[4]                      INTEGER,\n *              ctime[5]                      KerberosTime,\n *              subkey[6]                     EncryptionKey OPTIONAL,\n *              seq-number[7]                 INTEGER OPTIONAL,\n *              authorization-data[8]         AuthorizationData OPTIONAL\n *      }\n */\ntypedef struct krb5_authenticator_st {\n    ASN1_INTEGER *avno;\n    ASN1_GENERALSTRING *crealm;\n    KRB5_PRINCNAME *cname;\n    KRB5_CHECKSUM *cksum;\n    ASN1_INTEGER *cusec;\n    ASN1_GENERALIZEDTIME *ctime;\n    KRB5_ENCKEY *subkey;\n    ASN1_INTEGER *seqnum;\n    KRB5_AUTHDATA *authorization;\n} KRB5_AUTHENTBODY;\n\ntypedef STACK_OF(KRB5_AUTHENTBODY) KRB5_AUTHENT;\nDECLARE_STACK_OF(KRB5_AUTHENTBODY)\n\n/*-  DECLARE_ASN1_FUNCTIONS(type) = DECLARE_ASN1_FUNCTIONS_name(type, type) =\n *      type *name##_new(void);\n *      void name##_free(type *a);\n *      DECLARE_ASN1_ENCODE_FUNCTIONS(type, name, name) =\n *       DECLARE_ASN1_ENCODE_FUNCTIONS(type, itname, name) =\n *        type *d2i_##name(type **a, const unsigned char **in, long len);\n *        int i2d_##name(type *a, unsigned char **out);\n *        DECLARE_ASN1_ITEM(itname) = OPENSSL_EXTERN const ASN1_ITEM itname##_it\n */\n\nDECLARE_ASN1_FUNCTIONS(KRB5_ENCDATA)\nDECLARE_ASN1_FUNCTIONS(KRB5_PRINCNAME)\nDECLARE_ASN1_FUNCTIONS(KRB5_TKTBODY)\nDECLARE_ASN1_FUNCTIONS(KRB5_APREQBODY)\nDECLARE_ASN1_FUNCTIONS(KRB5_TICKET)\nDECLARE_ASN1_FUNCTIONS(KRB5_APREQ)\n\nDECLARE_ASN1_FUNCTIONS(KRB5_CHECKSUM)\nDECLARE_ASN1_FUNCTIONS(KRB5_ENCKEY)\nDECLARE_ASN1_FUNCTIONS(KRB5_AUTHDATA)\nDECLARE_ASN1_FUNCTIONS(KRB5_AUTHENTBODY)\nDECLARE_ASN1_FUNCTIONS(KRB5_AUTHENT)\n\n/* BEGIN ERROR CODES */\n/*\n * The following lines are auto generated by the script mkerr.pl. Any changes\n * made after this point may be overwritten when the script is next run.\n */\n\n#ifdef  __cplusplus\n}\n#endif\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/arm/include/openssl/kssl.h",
    "content": "/* ssl/kssl.h */\n/*\n * Written by Vern Staats <staatsvr@asc.hpc.mil> for the OpenSSL project\n * 2000. project 2000.\n */\n/* ====================================================================\n * Copyright (c) 2000 The OpenSSL Project.  All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n *\n * 1. Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n *\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in\n *    the documentation and/or other materials provided with the\n *    distribution.\n *\n * 3. All advertising materials mentioning features or use of this\n *    software must display the following acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)\"\n *\n * 4. The names \"OpenSSL Toolkit\" and \"OpenSSL Project\" must not be used to\n *    endorse or promote products derived from this software without\n *    prior written permission. For written permission, please contact\n *    licensing@OpenSSL.org.\n *\n * 5. Products derived from this software may not be called \"OpenSSL\"\n *    nor may \"OpenSSL\" appear in their names without prior written\n *    permission of the OpenSSL Project.\n *\n * 6. Redistributions of any form whatsoever must retain the following\n *    acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)\"\n *\n * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY\n * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\n * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR\n * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\n * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,\n * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED\n * OF THE POSSIBILITY OF SUCH DAMAGE.\n * ====================================================================\n *\n * This product includes cryptographic software written by Eric Young\n * (eay@cryptsoft.com).  This product includes software written by Tim\n * Hudson (tjh@cryptsoft.com).\n *\n */\n\n/*\n **      19990701        VRS     Started.\n */\n\n#ifndef KSSL_H\n# define KSSL_H\n\n# include <openssl/opensslconf.h>\n\n# ifndef OPENSSL_NO_KRB5\n\n#  include <stdio.h>\n#  include <ctype.h>\n#  include <krb5.h>\n#  ifdef OPENSSL_SYS_WIN32\n/*\n * These can sometimes get redefined indirectly by krb5 header files after\n * they get undefed in ossl_typ.h\n */\n#   undef X509_NAME\n#   undef X509_EXTENSIONS\n#   undef OCSP_REQUEST\n#   undef OCSP_RESPONSE\n#  endif\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n/*\n *      Depending on which KRB5 implementation used, some types from\n *      the other may be missing.  Resolve that here and now\n */\n#  ifdef KRB5_HEIMDAL\ntypedef unsigned char krb5_octet;\n#   define FAR\n#  else\n\n#   ifndef FAR\n#    define FAR\n#   endif\n\n#  endif\n\n/*-\n *      Uncomment this to debug kssl problems or\n *      to trace usage of the Kerberos session key\n *\n *      #define         KSSL_DEBUG\n */\n\n#  ifndef KRB5SVC\n#   define KRB5SVC \"host\"\n#  endif\n\n#  ifndef KRB5KEYTAB\n#   define KRB5KEYTAB      \"/etc/krb5.keytab\"\n#  endif\n\n#  ifndef KRB5SENDAUTH\n#   define KRB5SENDAUTH    1\n#  endif\n\n#  ifndef KRB5CHECKAUTH\n#   define KRB5CHECKAUTH   1\n#  endif\n\n#  ifndef KSSL_CLOCKSKEW\n#   define KSSL_CLOCKSKEW  300;\n#  endif\n\n#  define KSSL_ERR_MAX    255\ntypedef struct kssl_err_st {\n    int reason;\n    char text[KSSL_ERR_MAX + 1];\n} KSSL_ERR;\n\n/*-     Context for passing\n *              (1) Kerberos session key to SSL, and\n *              (2)     Config data between application and SSL lib\n */\ntypedef struct kssl_ctx_st {\n    /*      used by:    disposition:            */\n    char *service_name;         /* C,S default ok (kssl) */\n    char *service_host;         /* C input, REQUIRED */\n    char *client_princ;         /* S output from krb5 ticket */\n    char *keytab_file;          /* S NULL (/etc/krb5.keytab) */\n    char *cred_cache;           /* C NULL (default) */\n    krb5_enctype enctype;\n    int length;\n    krb5_octet FAR *key;\n} KSSL_CTX;\n\n#  define KSSL_CLIENT     1\n#  define KSSL_SERVER     2\n#  define KSSL_SERVICE    3\n#  define KSSL_KEYTAB     4\n\n#  define KSSL_CTX_OK     0\n#  define KSSL_CTX_ERR    1\n#  define KSSL_NOMEM      2\n\n/* Public (for use by applications that use OpenSSL with Kerberos 5 support */\nkrb5_error_code kssl_ctx_setstring(KSSL_CTX *kssl_ctx, int which, char *text);\nKSSL_CTX *kssl_ctx_new(void);\nKSSL_CTX *kssl_ctx_free(KSSL_CTX *kssl_ctx);\nvoid kssl_ctx_show(KSSL_CTX *kssl_ctx);\nkrb5_error_code kssl_ctx_setprinc(KSSL_CTX *kssl_ctx, int which,\n                                  krb5_data *realm, krb5_data *entity,\n                                  int nentities);\nkrb5_error_code kssl_cget_tkt(KSSL_CTX *kssl_ctx, krb5_data **enc_tktp,\n                              krb5_data *authenp, KSSL_ERR *kssl_err);\nkrb5_error_code kssl_sget_tkt(KSSL_CTX *kssl_ctx, krb5_data *indata,\n                              krb5_ticket_times *ttimes, KSSL_ERR *kssl_err);\nkrb5_error_code kssl_ctx_setkey(KSSL_CTX *kssl_ctx, krb5_keyblock *session);\nvoid kssl_err_set(KSSL_ERR *kssl_err, int reason, char *text);\nvoid kssl_krb5_free_data_contents(krb5_context context, krb5_data *data);\nkrb5_error_code kssl_build_principal_2(krb5_context context,\n                                       krb5_principal *princ, int rlen,\n                                       const char *realm, int slen,\n                                       const char *svc, int hlen,\n                                       const char *host);\nkrb5_error_code kssl_validate_times(krb5_timestamp atime,\n                                    krb5_ticket_times *ttimes);\nkrb5_error_code kssl_check_authent(KSSL_CTX *kssl_ctx, krb5_data *authentp,\n                                   krb5_timestamp *atimep,\n                                   KSSL_ERR *kssl_err);\nunsigned char *kssl_skip_confound(krb5_enctype enctype, unsigned char *authn);\n\nvoid SSL_set0_kssl_ctx(SSL *s, KSSL_CTX *kctx);\nKSSL_CTX *SSL_get0_kssl_ctx(SSL *s);\nchar *kssl_ctx_get0_client_princ(KSSL_CTX *kctx);\n\n#ifdef  __cplusplus\n}\n#endif\n# endif                         /* OPENSSL_NO_KRB5 */\n#endif                          /* KSSL_H */\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/arm/include/openssl/lhash.h",
    "content": "/* crypto/lhash/lhash.h */\n/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)\n * All rights reserved.\n *\n * This package is an SSL implementation written\n * by Eric Young (eay@cryptsoft.com).\n * The implementation was written so as to conform with Netscapes SSL.\n *\n * This library is free for commercial and non-commercial use as long as\n * the following conditions are aheared to.  The following conditions\n * apply to all code found in this distribution, be it the RC4, RSA,\n * lhash, DES, etc., code; not just the SSL code.  The SSL documentation\n * included with this distribution is covered by the same copyright terms\n * except that the holder is Tim Hudson (tjh@cryptsoft.com).\n *\n * Copyright remains Eric Young's, and as such any Copyright notices in\n * the code are not to be removed.\n * If this package is used in a product, Eric Young should be given attribution\n * as the author of the parts of the library used.\n * This can be in the form of a textual message at program startup or\n * in documentation (online or textual) provided with the package.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the copyright\n *    notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in the\n *    documentation and/or other materials provided with the distribution.\n * 3. All advertising materials mentioning features or use of this software\n *    must display the following acknowledgement:\n *    \"This product includes cryptographic software written by\n *     Eric Young (eay@cryptsoft.com)\"\n *    The word 'cryptographic' can be left out if the rouines from the library\n *    being used are not cryptographic related :-).\n * 4. If you include any Windows specific code (or a derivative thereof) from\n *    the apps directory (application code) you must include an acknowledgement:\n *    \"This product includes software written by Tim Hudson (tjh@cryptsoft.com)\"\n *\n * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n * SUCH DAMAGE.\n *\n * The licence and distribution terms for any publically available version or\n * derivative of this code cannot be changed.  i.e. this code cannot simply be\n * copied and put under another distribution licence\n * [including the GNU Public Licence.]\n */\n\n/*\n * Header for dynamic hash table routines Author - Eric Young\n */\n\n#ifndef HEADER_LHASH_H\n# define HEADER_LHASH_H\n\n# include <openssl/e_os2.h>\n# ifndef OPENSSL_NO_FP_API\n#  include <stdio.h>\n# endif\n\n# ifndef OPENSSL_NO_BIO\n#  include <openssl/bio.h>\n# endif\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\ntypedef struct lhash_node_st {\n    void *data;\n    struct lhash_node_st *next;\n# ifndef OPENSSL_NO_HASH_COMP\n    unsigned long hash;\n# endif\n} LHASH_NODE;\n\ntypedef int (*LHASH_COMP_FN_TYPE) (const void *, const void *);\ntypedef unsigned long (*LHASH_HASH_FN_TYPE) (const void *);\ntypedef void (*LHASH_DOALL_FN_TYPE) (void *);\ntypedef void (*LHASH_DOALL_ARG_FN_TYPE) (void *, void *);\n\n/*\n * Macros for declaring and implementing type-safe wrappers for LHASH\n * callbacks. This way, callbacks can be provided to LHASH structures without\n * function pointer casting and the macro-defined callbacks provide\n * per-variable casting before deferring to the underlying type-specific\n * callbacks. NB: It is possible to place a \"static\" in front of both the\n * DECLARE and IMPLEMENT macros if the functions are strictly internal.\n */\n\n/* First: \"hash\" functions */\n# define DECLARE_LHASH_HASH_FN(name, o_type) \\\n        unsigned long name##_LHASH_HASH(const void *);\n# define IMPLEMENT_LHASH_HASH_FN(name, o_type) \\\n        unsigned long name##_LHASH_HASH(const void *arg) { \\\n                const o_type *a = arg; \\\n                return name##_hash(a); }\n# define LHASH_HASH_FN(name) name##_LHASH_HASH\n\n/* Second: \"compare\" functions */\n# define DECLARE_LHASH_COMP_FN(name, o_type) \\\n        int name##_LHASH_COMP(const void *, const void *);\n# define IMPLEMENT_LHASH_COMP_FN(name, o_type) \\\n        int name##_LHASH_COMP(const void *arg1, const void *arg2) { \\\n                const o_type *a = arg1;             \\\n                const o_type *b = arg2; \\\n                return name##_cmp(a,b); }\n# define LHASH_COMP_FN(name) name##_LHASH_COMP\n\n/* Third: \"doall\" functions */\n# define DECLARE_LHASH_DOALL_FN(name, o_type) \\\n        void name##_LHASH_DOALL(void *);\n# define IMPLEMENT_LHASH_DOALL_FN(name, o_type) \\\n        void name##_LHASH_DOALL(void *arg) { \\\n                o_type *a = arg; \\\n                name##_doall(a); }\n# define LHASH_DOALL_FN(name) name##_LHASH_DOALL\n\n/* Fourth: \"doall_arg\" functions */\n# define DECLARE_LHASH_DOALL_ARG_FN(name, o_type, a_type) \\\n        void name##_LHASH_DOALL_ARG(void *, void *);\n# define IMPLEMENT_LHASH_DOALL_ARG_FN(name, o_type, a_type) \\\n        void name##_LHASH_DOALL_ARG(void *arg1, void *arg2) { \\\n                o_type *a = arg1; \\\n                a_type *b = arg2; \\\n                name##_doall_arg(a, b); }\n# define LHASH_DOALL_ARG_FN(name) name##_LHASH_DOALL_ARG\n\ntypedef struct lhash_st {\n    LHASH_NODE **b;\n    LHASH_COMP_FN_TYPE comp;\n    LHASH_HASH_FN_TYPE hash;\n    unsigned int num_nodes;\n    unsigned int num_alloc_nodes;\n    unsigned int p;\n    unsigned int pmax;\n    unsigned long up_load;      /* load times 256 */\n    unsigned long down_load;    /* load times 256 */\n    unsigned long num_items;\n    unsigned long num_expands;\n    unsigned long num_expand_reallocs;\n    unsigned long num_contracts;\n    unsigned long num_contract_reallocs;\n    unsigned long num_hash_calls;\n    unsigned long num_comp_calls;\n    unsigned long num_insert;\n    unsigned long num_replace;\n    unsigned long num_delete;\n    unsigned long num_no_delete;\n    unsigned long num_retrieve;\n    unsigned long num_retrieve_miss;\n    unsigned long num_hash_comps;\n    int error;\n} _LHASH;                       /* Do not use _LHASH directly, use LHASH_OF\n                                 * and friends */\n\n# define LH_LOAD_MULT    256\n\n/*\n * Indicates a malloc() error in the last call, this is only bad in\n * lh_insert().\n */\n# define lh_error(lh)    ((lh)->error)\n\n_LHASH *lh_new(LHASH_HASH_FN_TYPE h, LHASH_COMP_FN_TYPE c);\nvoid lh_free(_LHASH *lh);\nvoid *lh_insert(_LHASH *lh, void *data);\nvoid *lh_delete(_LHASH *lh, const void *data);\nvoid *lh_retrieve(_LHASH *lh, const void *data);\nvoid lh_doall(_LHASH *lh, LHASH_DOALL_FN_TYPE func);\nvoid lh_doall_arg(_LHASH *lh, LHASH_DOALL_ARG_FN_TYPE func, void *arg);\nunsigned long lh_strhash(const char *c);\nunsigned long lh_num_items(const _LHASH *lh);\n\n# ifndef OPENSSL_NO_FP_API\nvoid lh_stats(const _LHASH *lh, FILE *out);\nvoid lh_node_stats(const _LHASH *lh, FILE *out);\nvoid lh_node_usage_stats(const _LHASH *lh, FILE *out);\n# endif\n\n# ifndef OPENSSL_NO_BIO\nvoid lh_stats_bio(const _LHASH *lh, BIO *out);\nvoid lh_node_stats_bio(const _LHASH *lh, BIO *out);\nvoid lh_node_usage_stats_bio(const _LHASH *lh, BIO *out);\n# endif\n\n/* Type checking... */\n\n# define LHASH_OF(type) struct lhash_st_##type\n\n# define DECLARE_LHASH_OF(type) LHASH_OF(type) { int dummy; }\n\n# define CHECKED_LHASH_OF(type,lh) \\\n  ((_LHASH *)CHECKED_PTR_OF(LHASH_OF(type),lh))\n\n/* Define wrapper functions. */\n# define LHM_lh_new(type, name) \\\n  ((LHASH_OF(type) *)lh_new(LHASH_HASH_FN(name), LHASH_COMP_FN(name)))\n# define LHM_lh_error(type, lh) \\\n  lh_error(CHECKED_LHASH_OF(type,lh))\n# define LHM_lh_insert(type, lh, inst) \\\n  ((type *)lh_insert(CHECKED_LHASH_OF(type, lh), \\\n                     CHECKED_PTR_OF(type, inst)))\n# define LHM_lh_retrieve(type, lh, inst) \\\n  ((type *)lh_retrieve(CHECKED_LHASH_OF(type, lh), \\\n                       CHECKED_PTR_OF(type, inst)))\n# define LHM_lh_delete(type, lh, inst) \\\n  ((type *)lh_delete(CHECKED_LHASH_OF(type, lh),                        \\\n                     CHECKED_PTR_OF(type, inst)))\n# define LHM_lh_doall(type, lh,fn) lh_doall(CHECKED_LHASH_OF(type, lh), fn)\n# define LHM_lh_doall_arg(type, lh, fn, arg_type, arg) \\\n  lh_doall_arg(CHECKED_LHASH_OF(type, lh), fn, CHECKED_PTR_OF(arg_type, arg))\n# define LHM_lh_num_items(type, lh) lh_num_items(CHECKED_LHASH_OF(type, lh))\n# define LHM_lh_down_load(type, lh) (CHECKED_LHASH_OF(type, lh)->down_load)\n# define LHM_lh_node_stats_bio(type, lh, out) \\\n  lh_node_stats_bio(CHECKED_LHASH_OF(type, lh), out)\n# define LHM_lh_node_usage_stats_bio(type, lh, out) \\\n  lh_node_usage_stats_bio(CHECKED_LHASH_OF(type, lh), out)\n# define LHM_lh_stats_bio(type, lh, out) \\\n  lh_stats_bio(CHECKED_LHASH_OF(type, lh), out)\n# define LHM_lh_free(type, lh) lh_free(CHECKED_LHASH_OF(type, lh))\n\nDECLARE_LHASH_OF(OPENSSL_STRING);\nDECLARE_LHASH_OF(OPENSSL_CSTRING);\n\n#ifdef  __cplusplus\n}\n#endif\n\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/arm/include/openssl/md4.h",
    "content": "/* crypto/md4/md4.h */\n/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)\n * All rights reserved.\n *\n * This package is an SSL implementation written\n * by Eric Young (eay@cryptsoft.com).\n * The implementation was written so as to conform with Netscapes SSL.\n *\n * This library is free for commercial and non-commercial use as long as\n * the following conditions are aheared to.  The following conditions\n * apply to all code found in this distribution, be it the RC4, RSA,\n * lhash, DES, etc., code; not just the SSL code.  The SSL documentation\n * included with this distribution is covered by the same copyright terms\n * except that the holder is Tim Hudson (tjh@cryptsoft.com).\n *\n * Copyright remains Eric Young's, and as such any Copyright notices in\n * the code are not to be removed.\n * If this package is used in a product, Eric Young should be given attribution\n * as the author of the parts of the library used.\n * This can be in the form of a textual message at program startup or\n * in documentation (online or textual) provided with the package.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the copyright\n *    notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in the\n *    documentation and/or other materials provided with the distribution.\n * 3. All advertising materials mentioning features or use of this software\n *    must display the following acknowledgement:\n *    \"This product includes cryptographic software written by\n *     Eric Young (eay@cryptsoft.com)\"\n *    The word 'cryptographic' can be left out if the rouines from the library\n *    being used are not cryptographic related :-).\n * 4. If you include any Windows specific code (or a derivative thereof) from\n *    the apps directory (application code) you must include an acknowledgement:\n *    \"This product includes software written by Tim Hudson (tjh@cryptsoft.com)\"\n *\n * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n * SUCH DAMAGE.\n *\n * The licence and distribution terms for any publically available version or\n * derivative of this code cannot be changed.  i.e. this code cannot simply be\n * copied and put under another distribution licence\n * [including the GNU Public Licence.]\n */\n\n#ifndef HEADER_MD4_H\n# define HEADER_MD4_H\n\n# include <openssl/e_os2.h>\n# include <stddef.h>\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n# ifdef OPENSSL_NO_MD4\n#  error MD4 is disabled.\n# endif\n\n/*-\n * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n * ! MD4_LONG has to be at least 32 bits wide. If it's wider, then !\n * ! MD4_LONG_LOG2 has to be defined along.                        !\n * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n */\n\n# if defined(__LP32__)\n#  define MD4_LONG unsigned long\n# elif defined(OPENSSL_SYS_CRAY) || defined(__ILP64__)\n#  define MD4_LONG unsigned long\n#  define MD4_LONG_LOG2 3\n/*\n * _CRAY note. I could declare short, but I have no idea what impact\n * does it have on performance on none-T3E machines. I could declare\n * int, but at least on C90 sizeof(int) can be chosen at compile time.\n * So I've chosen long...\n *                                      <appro@fy.chalmers.se>\n */\n# else\n#  define MD4_LONG unsigned int\n# endif\n\n# define MD4_CBLOCK      64\n# define MD4_LBLOCK      (MD4_CBLOCK/4)\n# define MD4_DIGEST_LENGTH 16\n\ntypedef struct MD4state_st {\n    MD4_LONG A, B, C, D;\n    MD4_LONG Nl, Nh;\n    MD4_LONG data[MD4_LBLOCK];\n    unsigned int num;\n} MD4_CTX;\n\n# ifdef OPENSSL_FIPS\nint private_MD4_Init(MD4_CTX *c);\n# endif\nint MD4_Init(MD4_CTX *c);\nint MD4_Update(MD4_CTX *c, const void *data, size_t len);\nint MD4_Final(unsigned char *md, MD4_CTX *c);\nunsigned char *MD4(const unsigned char *d, size_t n, unsigned char *md);\nvoid MD4_Transform(MD4_CTX *c, const unsigned char *b);\n#ifdef  __cplusplus\n}\n#endif\n\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/arm/include/openssl/md5.h",
    "content": "/* crypto/md5/md5.h */\n/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)\n * All rights reserved.\n *\n * This package is an SSL implementation written\n * by Eric Young (eay@cryptsoft.com).\n * The implementation was written so as to conform with Netscapes SSL.\n *\n * This library is free for commercial and non-commercial use as long as\n * the following conditions are aheared to.  The following conditions\n * apply to all code found in this distribution, be it the RC4, RSA,\n * lhash, DES, etc., code; not just the SSL code.  The SSL documentation\n * included with this distribution is covered by the same copyright terms\n * except that the holder is Tim Hudson (tjh@cryptsoft.com).\n *\n * Copyright remains Eric Young's, and as such any Copyright notices in\n * the code are not to be removed.\n * If this package is used in a product, Eric Young should be given attribution\n * as the author of the parts of the library used.\n * This can be in the form of a textual message at program startup or\n * in documentation (online or textual) provided with the package.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the copyright\n *    notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in the\n *    documentation and/or other materials provided with the distribution.\n * 3. All advertising materials mentioning features or use of this software\n *    must display the following acknowledgement:\n *    \"This product includes cryptographic software written by\n *     Eric Young (eay@cryptsoft.com)\"\n *    The word 'cryptographic' can be left out if the rouines from the library\n *    being used are not cryptographic related :-).\n * 4. If you include any Windows specific code (or a derivative thereof) from\n *    the apps directory (application code) you must include an acknowledgement:\n *    \"This product includes software written by Tim Hudson (tjh@cryptsoft.com)\"\n *\n * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n * SUCH DAMAGE.\n *\n * The licence and distribution terms for any publically available version or\n * derivative of this code cannot be changed.  i.e. this code cannot simply be\n * copied and put under another distribution licence\n * [including the GNU Public Licence.]\n */\n\n#ifndef HEADER_MD5_H\n# define HEADER_MD5_H\n\n# include <openssl/e_os2.h>\n# include <stddef.h>\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n# ifdef OPENSSL_NO_MD5\n#  error MD5 is disabled.\n# endif\n\n/*\n * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n * ! MD5_LONG has to be at least 32 bits wide. If it's wider, then !\n * ! MD5_LONG_LOG2 has to be defined along.                        !\n * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n */\n\n# if defined(__LP32__)\n#  define MD5_LONG unsigned long\n# elif defined(OPENSSL_SYS_CRAY) || defined(__ILP64__)\n#  define MD5_LONG unsigned long\n#  define MD5_LONG_LOG2 3\n/*\n * _CRAY note. I could declare short, but I have no idea what impact\n * does it have on performance on none-T3E machines. I could declare\n * int, but at least on C90 sizeof(int) can be chosen at compile time.\n * So I've chosen long...\n *                                      <appro@fy.chalmers.se>\n */\n# else\n#  define MD5_LONG unsigned int\n# endif\n\n# define MD5_CBLOCK      64\n# define MD5_LBLOCK      (MD5_CBLOCK/4)\n# define MD5_DIGEST_LENGTH 16\n\ntypedef struct MD5state_st {\n    MD5_LONG A, B, C, D;\n    MD5_LONG Nl, Nh;\n    MD5_LONG data[MD5_LBLOCK];\n    unsigned int num;\n} MD5_CTX;\n\n# ifdef OPENSSL_FIPS\nint private_MD5_Init(MD5_CTX *c);\n# endif\nint MD5_Init(MD5_CTX *c);\nint MD5_Update(MD5_CTX *c, const void *data, size_t len);\nint MD5_Final(unsigned char *md, MD5_CTX *c);\nunsigned char *MD5(const unsigned char *d, size_t n, unsigned char *md);\nvoid MD5_Transform(MD5_CTX *c, const unsigned char *b);\n#ifdef  __cplusplus\n}\n#endif\n\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/arm/include/openssl/mdc2.h",
    "content": "/* crypto/mdc2/mdc2.h */\n/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)\n * All rights reserved.\n *\n * This package is an SSL implementation written\n * by Eric Young (eay@cryptsoft.com).\n * The implementation was written so as to conform with Netscapes SSL.\n *\n * This library is free for commercial and non-commercial use as long as\n * the following conditions are aheared to.  The following conditions\n * apply to all code found in this distribution, be it the RC4, RSA,\n * lhash, DES, etc., code; not just the SSL code.  The SSL documentation\n * included with this distribution is covered by the same copyright terms\n * except that the holder is Tim Hudson (tjh@cryptsoft.com).\n *\n * Copyright remains Eric Young's, and as such any Copyright notices in\n * the code are not to be removed.\n * If this package is used in a product, Eric Young should be given attribution\n * as the author of the parts of the library used.\n * This can be in the form of a textual message at program startup or\n * in documentation (online or textual) provided with the package.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the copyright\n *    notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in the\n *    documentation and/or other materials provided with the distribution.\n * 3. All advertising materials mentioning features or use of this software\n *    must display the following acknowledgement:\n *    \"This product includes cryptographic software written by\n *     Eric Young (eay@cryptsoft.com)\"\n *    The word 'cryptographic' can be left out if the rouines from the library\n *    being used are not cryptographic related :-).\n * 4. If you include any Windows specific code (or a derivative thereof) from\n *    the apps directory (application code) you must include an acknowledgement:\n *    \"This product includes software written by Tim Hudson (tjh@cryptsoft.com)\"\n *\n * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n * SUCH DAMAGE.\n *\n * The licence and distribution terms for any publically available version or\n * derivative of this code cannot be changed.  i.e. this code cannot simply be\n * copied and put under another distribution licence\n * [including the GNU Public Licence.]\n */\n\n#ifndef HEADER_MDC2_H\n# define HEADER_MDC2_H\n\n# include <openssl/des.h>\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n# ifdef OPENSSL_NO_MDC2\n#  error MDC2 is disabled.\n# endif\n\n# define MDC2_BLOCK              8\n# define MDC2_DIGEST_LENGTH      16\n\ntypedef struct mdc2_ctx_st {\n    unsigned int num;\n    unsigned char data[MDC2_BLOCK];\n    DES_cblock h, hh;\n    int pad_type;               /* either 1 or 2, default 1 */\n} MDC2_CTX;\n\n# ifdef OPENSSL_FIPS\nint private_MDC2_Init(MDC2_CTX *c);\n# endif\nint MDC2_Init(MDC2_CTX *c);\nint MDC2_Update(MDC2_CTX *c, const unsigned char *data, size_t len);\nint MDC2_Final(unsigned char *md, MDC2_CTX *c);\nunsigned char *MDC2(const unsigned char *d, size_t n, unsigned char *md);\n\n#ifdef  __cplusplus\n}\n#endif\n\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/arm/include/openssl/modes.h",
    "content": "/* ====================================================================\n * Copyright (c) 2008 The OpenSSL Project. All rights reserved.\n *\n * Rights for redistribution and usage in source and binary\n * forms are granted according to the OpenSSL license.\n */\n\n#include <stddef.h>\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\ntypedef void (*block128_f) (const unsigned char in[16],\n                            unsigned char out[16], const void *key);\n\ntypedef void (*cbc128_f) (const unsigned char *in, unsigned char *out,\n                          size_t len, const void *key,\n                          unsigned char ivec[16], int enc);\n\ntypedef void (*ctr128_f) (const unsigned char *in, unsigned char *out,\n                          size_t blocks, const void *key,\n                          const unsigned char ivec[16]);\n\ntypedef void (*ccm128_f) (const unsigned char *in, unsigned char *out,\n                          size_t blocks, const void *key,\n                          const unsigned char ivec[16],\n                          unsigned char cmac[16]);\n\nvoid CRYPTO_cbc128_encrypt(const unsigned char *in, unsigned char *out,\n                           size_t len, const void *key,\n                           unsigned char ivec[16], block128_f block);\nvoid CRYPTO_cbc128_decrypt(const unsigned char *in, unsigned char *out,\n                           size_t len, const void *key,\n                           unsigned char ivec[16], block128_f block);\n\nvoid CRYPTO_ctr128_encrypt(const unsigned char *in, unsigned char *out,\n                           size_t len, const void *key,\n                           unsigned char ivec[16],\n                           unsigned char ecount_buf[16], unsigned int *num,\n                           block128_f block);\n\nvoid CRYPTO_ctr128_encrypt_ctr32(const unsigned char *in, unsigned char *out,\n                                 size_t len, const void *key,\n                                 unsigned char ivec[16],\n                                 unsigned char ecount_buf[16],\n                                 unsigned int *num, ctr128_f ctr);\n\nvoid CRYPTO_ofb128_encrypt(const unsigned char *in, unsigned char *out,\n                           size_t len, const void *key,\n                           unsigned char ivec[16], int *num,\n                           block128_f block);\n\nvoid CRYPTO_cfb128_encrypt(const unsigned char *in, unsigned char *out,\n                           size_t len, const void *key,\n                           unsigned char ivec[16], int *num,\n                           int enc, block128_f block);\nvoid CRYPTO_cfb128_8_encrypt(const unsigned char *in, unsigned char *out,\n                             size_t length, const void *key,\n                             unsigned char ivec[16], int *num,\n                             int enc, block128_f block);\nvoid CRYPTO_cfb128_1_encrypt(const unsigned char *in, unsigned char *out,\n                             size_t bits, const void *key,\n                             unsigned char ivec[16], int *num,\n                             int enc, block128_f block);\n\nsize_t CRYPTO_cts128_encrypt_block(const unsigned char *in,\n                                   unsigned char *out, size_t len,\n                                   const void *key, unsigned char ivec[16],\n                                   block128_f block);\nsize_t CRYPTO_cts128_encrypt(const unsigned char *in, unsigned char *out,\n                             size_t len, const void *key,\n                             unsigned char ivec[16], cbc128_f cbc);\nsize_t CRYPTO_cts128_decrypt_block(const unsigned char *in,\n                                   unsigned char *out, size_t len,\n                                   const void *key, unsigned char ivec[16],\n                                   block128_f block);\nsize_t CRYPTO_cts128_decrypt(const unsigned char *in, unsigned char *out,\n                             size_t len, const void *key,\n                             unsigned char ivec[16], cbc128_f cbc);\n\nsize_t CRYPTO_nistcts128_encrypt_block(const unsigned char *in,\n                                       unsigned char *out, size_t len,\n                                       const void *key,\n                                       unsigned char ivec[16],\n                                       block128_f block);\nsize_t CRYPTO_nistcts128_encrypt(const unsigned char *in, unsigned char *out,\n                                 size_t len, const void *key,\n                                 unsigned char ivec[16], cbc128_f cbc);\nsize_t CRYPTO_nistcts128_decrypt_block(const unsigned char *in,\n                                       unsigned char *out, size_t len,\n                                       const void *key,\n                                       unsigned char ivec[16],\n                                       block128_f block);\nsize_t CRYPTO_nistcts128_decrypt(const unsigned char *in, unsigned char *out,\n                                 size_t len, const void *key,\n                                 unsigned char ivec[16], cbc128_f cbc);\n\ntypedef struct gcm128_context GCM128_CONTEXT;\n\nGCM128_CONTEXT *CRYPTO_gcm128_new(void *key, block128_f block);\nvoid CRYPTO_gcm128_init(GCM128_CONTEXT *ctx, void *key, block128_f block);\nvoid CRYPTO_gcm128_setiv(GCM128_CONTEXT *ctx, const unsigned char *iv,\n                         size_t len);\nint CRYPTO_gcm128_aad(GCM128_CONTEXT *ctx, const unsigned char *aad,\n                      size_t len);\nint CRYPTO_gcm128_encrypt(GCM128_CONTEXT *ctx,\n                          const unsigned char *in, unsigned char *out,\n                          size_t len);\nint CRYPTO_gcm128_decrypt(GCM128_CONTEXT *ctx,\n                          const unsigned char *in, unsigned char *out,\n                          size_t len);\nint CRYPTO_gcm128_encrypt_ctr32(GCM128_CONTEXT *ctx,\n                                const unsigned char *in, unsigned char *out,\n                                size_t len, ctr128_f stream);\nint CRYPTO_gcm128_decrypt_ctr32(GCM128_CONTEXT *ctx,\n                                const unsigned char *in, unsigned char *out,\n                                size_t len, ctr128_f stream);\nint CRYPTO_gcm128_finish(GCM128_CONTEXT *ctx, const unsigned char *tag,\n                         size_t len);\nvoid CRYPTO_gcm128_tag(GCM128_CONTEXT *ctx, unsigned char *tag, size_t len);\nvoid CRYPTO_gcm128_release(GCM128_CONTEXT *ctx);\n\ntypedef struct ccm128_context CCM128_CONTEXT;\n\nvoid CRYPTO_ccm128_init(CCM128_CONTEXT *ctx,\n                        unsigned int M, unsigned int L, void *key,\n                        block128_f block);\nint CRYPTO_ccm128_setiv(CCM128_CONTEXT *ctx, const unsigned char *nonce,\n                        size_t nlen, size_t mlen);\nvoid CRYPTO_ccm128_aad(CCM128_CONTEXT *ctx, const unsigned char *aad,\n                       size_t alen);\nint CRYPTO_ccm128_encrypt(CCM128_CONTEXT *ctx, const unsigned char *inp,\n                          unsigned char *out, size_t len);\nint CRYPTO_ccm128_decrypt(CCM128_CONTEXT *ctx, const unsigned char *inp,\n                          unsigned char *out, size_t len);\nint CRYPTO_ccm128_encrypt_ccm64(CCM128_CONTEXT *ctx, const unsigned char *inp,\n                                unsigned char *out, size_t len,\n                                ccm128_f stream);\nint CRYPTO_ccm128_decrypt_ccm64(CCM128_CONTEXT *ctx, const unsigned char *inp,\n                                unsigned char *out, size_t len,\n                                ccm128_f stream);\nsize_t CRYPTO_ccm128_tag(CCM128_CONTEXT *ctx, unsigned char *tag, size_t len);\n\ntypedef struct xts128_context XTS128_CONTEXT;\n\nint CRYPTO_xts128_encrypt(const XTS128_CONTEXT *ctx,\n                          const unsigned char iv[16],\n                          const unsigned char *inp, unsigned char *out,\n                          size_t len, int enc);\n\nsize_t CRYPTO_128_wrap(void *key, const unsigned char *iv,\n                       unsigned char *out,\n                       const unsigned char *in, size_t inlen,\n                       block128_f block);\n\nsize_t CRYPTO_128_unwrap(void *key, const unsigned char *iv,\n                         unsigned char *out,\n                         const unsigned char *in, size_t inlen,\n                         block128_f block);\n\n#ifdef  __cplusplus\n}\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/arm/include/openssl/obj_mac.h",
    "content": "/* crypto/objects/obj_mac.h */\n\n/*\n * THIS FILE IS GENERATED FROM objects.txt by objects.pl via the following\n * command: perl objects.pl objects.txt obj_mac.num obj_mac.h\n */\n\n/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)\n * All rights reserved.\n *\n * This package is an SSL implementation written\n * by Eric Young (eay@cryptsoft.com).\n * The implementation was written so as to conform with Netscapes SSL.\n *\n * This library is free for commercial and non-commercial use as long as\n * the following conditions are aheared to.  The following conditions\n * apply to all code found in this distribution, be it the RC4, RSA,\n * lhash, DES, etc., code; not just the SSL code.  The SSL documentation\n * included with this distribution is covered by the same copyright terms\n * except that the holder is Tim Hudson (tjh@cryptsoft.com).\n *\n * Copyright remains Eric Young's, and as such any Copyright notices in\n * the code are not to be removed.\n * If this package is used in a product, Eric Young should be given attribution\n * as the author of the parts of the library used.\n * This can be in the form of a textual message at program startup or\n * in documentation (online or textual) provided with the package.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the copyright\n *    notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in the\n *    documentation and/or other materials provided with the distribution.\n * 3. All advertising materials mentioning features or use of this software\n *    must display the following acknowledgement:\n *    \"This product includes cryptographic software written by\n *     Eric Young (eay@cryptsoft.com)\"\n *    The word 'cryptographic' can be left out if the rouines from the library\n *    being used are not cryptographic related :-).\n * 4. If you include any Windows specific code (or a derivative thereof) from\n *    the apps directory (application code) you must include an acknowledgement:\n *    \"This product includes software written by Tim Hudson (tjh@cryptsoft.com)\"\n *\n * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n * SUCH DAMAGE.\n *\n * The licence and distribution terms for any publically available version or\n * derivative of this code cannot be changed.  i.e. this code cannot simply be\n * copied and put under another distribution licence\n * [including the GNU Public Licence.]\n */\n\n#define SN_undef                        \"UNDEF\"\n#define LN_undef                        \"undefined\"\n#define NID_undef                       0\n#define OBJ_undef                       0L\n\n#define SN_itu_t                \"ITU-T\"\n#define LN_itu_t                \"itu-t\"\n#define NID_itu_t               645\n#define OBJ_itu_t               0L\n\n#define NID_ccitt               404\n#define OBJ_ccitt               OBJ_itu_t\n\n#define SN_iso          \"ISO\"\n#define LN_iso          \"iso\"\n#define NID_iso         181\n#define OBJ_iso         1L\n\n#define SN_joint_iso_itu_t              \"JOINT-ISO-ITU-T\"\n#define LN_joint_iso_itu_t              \"joint-iso-itu-t\"\n#define NID_joint_iso_itu_t             646\n#define OBJ_joint_iso_itu_t             2L\n\n#define NID_joint_iso_ccitt             393\n#define OBJ_joint_iso_ccitt             OBJ_joint_iso_itu_t\n\n#define SN_member_body          \"member-body\"\n#define LN_member_body          \"ISO Member Body\"\n#define NID_member_body         182\n#define OBJ_member_body         OBJ_iso,2L\n\n#define SN_identified_organization              \"identified-organization\"\n#define NID_identified_organization             676\n#define OBJ_identified_organization             OBJ_iso,3L\n\n#define SN_hmac_md5             \"HMAC-MD5\"\n#define LN_hmac_md5             \"hmac-md5\"\n#define NID_hmac_md5            780\n#define OBJ_hmac_md5            OBJ_identified_organization,6L,1L,5L,5L,8L,1L,1L\n\n#define SN_hmac_sha1            \"HMAC-SHA1\"\n#define LN_hmac_sha1            \"hmac-sha1\"\n#define NID_hmac_sha1           781\n#define OBJ_hmac_sha1           OBJ_identified_organization,6L,1L,5L,5L,8L,1L,2L\n\n#define SN_certicom_arc         \"certicom-arc\"\n#define NID_certicom_arc                677\n#define OBJ_certicom_arc                OBJ_identified_organization,132L\n\n#define SN_international_organizations          \"international-organizations\"\n#define LN_international_organizations          \"International Organizations\"\n#define NID_international_organizations         647\n#define OBJ_international_organizations         OBJ_joint_iso_itu_t,23L\n\n#define SN_wap          \"wap\"\n#define NID_wap         678\n#define OBJ_wap         OBJ_international_organizations,43L\n\n#define SN_wap_wsg              \"wap-wsg\"\n#define NID_wap_wsg             679\n#define OBJ_wap_wsg             OBJ_wap,1L\n\n#define SN_selected_attribute_types             \"selected-attribute-types\"\n#define LN_selected_attribute_types             \"Selected Attribute Types\"\n#define NID_selected_attribute_types            394\n#define OBJ_selected_attribute_types            OBJ_joint_iso_itu_t,5L,1L,5L\n\n#define SN_clearance            \"clearance\"\n#define NID_clearance           395\n#define OBJ_clearance           OBJ_selected_attribute_types,55L\n\n#define SN_ISO_US               \"ISO-US\"\n#define LN_ISO_US               \"ISO US Member Body\"\n#define NID_ISO_US              183\n#define OBJ_ISO_US              OBJ_member_body,840L\n\n#define SN_X9_57                \"X9-57\"\n#define LN_X9_57                \"X9.57\"\n#define NID_X9_57               184\n#define OBJ_X9_57               OBJ_ISO_US,10040L\n\n#define SN_X9cm         \"X9cm\"\n#define LN_X9cm         \"X9.57 CM ?\"\n#define NID_X9cm                185\n#define OBJ_X9cm                OBJ_X9_57,4L\n\n#define SN_dsa          \"DSA\"\n#define LN_dsa          \"dsaEncryption\"\n#define NID_dsa         116\n#define OBJ_dsa         OBJ_X9cm,1L\n\n#define SN_dsaWithSHA1          \"DSA-SHA1\"\n#define LN_dsaWithSHA1          \"dsaWithSHA1\"\n#define NID_dsaWithSHA1         113\n#define OBJ_dsaWithSHA1         OBJ_X9cm,3L\n\n#define SN_ansi_X9_62           \"ansi-X9-62\"\n#define LN_ansi_X9_62           \"ANSI X9.62\"\n#define NID_ansi_X9_62          405\n#define OBJ_ansi_X9_62          OBJ_ISO_US,10045L\n\n#define OBJ_X9_62_id_fieldType          OBJ_ansi_X9_62,1L\n\n#define SN_X9_62_prime_field            \"prime-field\"\n#define NID_X9_62_prime_field           406\n#define OBJ_X9_62_prime_field           OBJ_X9_62_id_fieldType,1L\n\n#define SN_X9_62_characteristic_two_field               \"characteristic-two-field\"\n#define NID_X9_62_characteristic_two_field              407\n#define OBJ_X9_62_characteristic_two_field              OBJ_X9_62_id_fieldType,2L\n\n#define SN_X9_62_id_characteristic_two_basis            \"id-characteristic-two-basis\"\n#define NID_X9_62_id_characteristic_two_basis           680\n#define OBJ_X9_62_id_characteristic_two_basis           OBJ_X9_62_characteristic_two_field,3L\n\n#define SN_X9_62_onBasis                \"onBasis\"\n#define NID_X9_62_onBasis               681\n#define OBJ_X9_62_onBasis               OBJ_X9_62_id_characteristic_two_basis,1L\n\n#define SN_X9_62_tpBasis                \"tpBasis\"\n#define NID_X9_62_tpBasis               682\n#define OBJ_X9_62_tpBasis               OBJ_X9_62_id_characteristic_two_basis,2L\n\n#define SN_X9_62_ppBasis                \"ppBasis\"\n#define NID_X9_62_ppBasis               683\n#define OBJ_X9_62_ppBasis               OBJ_X9_62_id_characteristic_two_basis,3L\n\n#define OBJ_X9_62_id_publicKeyType              OBJ_ansi_X9_62,2L\n\n#define SN_X9_62_id_ecPublicKey         \"id-ecPublicKey\"\n#define NID_X9_62_id_ecPublicKey                408\n#define OBJ_X9_62_id_ecPublicKey                OBJ_X9_62_id_publicKeyType,1L\n\n#define OBJ_X9_62_ellipticCurve         OBJ_ansi_X9_62,3L\n\n#define OBJ_X9_62_c_TwoCurve            OBJ_X9_62_ellipticCurve,0L\n\n#define SN_X9_62_c2pnb163v1             \"c2pnb163v1\"\n#define NID_X9_62_c2pnb163v1            684\n#define OBJ_X9_62_c2pnb163v1            OBJ_X9_62_c_TwoCurve,1L\n\n#define SN_X9_62_c2pnb163v2             \"c2pnb163v2\"\n#define NID_X9_62_c2pnb163v2            685\n#define OBJ_X9_62_c2pnb163v2            OBJ_X9_62_c_TwoCurve,2L\n\n#define SN_X9_62_c2pnb163v3             \"c2pnb163v3\"\n#define NID_X9_62_c2pnb163v3            686\n#define OBJ_X9_62_c2pnb163v3            OBJ_X9_62_c_TwoCurve,3L\n\n#define SN_X9_62_c2pnb176v1             \"c2pnb176v1\"\n#define NID_X9_62_c2pnb176v1            687\n#define OBJ_X9_62_c2pnb176v1            OBJ_X9_62_c_TwoCurve,4L\n\n#define SN_X9_62_c2tnb191v1             \"c2tnb191v1\"\n#define NID_X9_62_c2tnb191v1            688\n#define OBJ_X9_62_c2tnb191v1            OBJ_X9_62_c_TwoCurve,5L\n\n#define SN_X9_62_c2tnb191v2             \"c2tnb191v2\"\n#define NID_X9_62_c2tnb191v2            689\n#define OBJ_X9_62_c2tnb191v2            OBJ_X9_62_c_TwoCurve,6L\n\n#define SN_X9_62_c2tnb191v3             \"c2tnb191v3\"\n#define NID_X9_62_c2tnb191v3            690\n#define OBJ_X9_62_c2tnb191v3            OBJ_X9_62_c_TwoCurve,7L\n\n#define SN_X9_62_c2onb191v4             \"c2onb191v4\"\n#define NID_X9_62_c2onb191v4            691\n#define OBJ_X9_62_c2onb191v4            OBJ_X9_62_c_TwoCurve,8L\n\n#define SN_X9_62_c2onb191v5             \"c2onb191v5\"\n#define NID_X9_62_c2onb191v5            692\n#define OBJ_X9_62_c2onb191v5            OBJ_X9_62_c_TwoCurve,9L\n\n#define SN_X9_62_c2pnb208w1             \"c2pnb208w1\"\n#define NID_X9_62_c2pnb208w1            693\n#define OBJ_X9_62_c2pnb208w1            OBJ_X9_62_c_TwoCurve,10L\n\n#define SN_X9_62_c2tnb239v1             \"c2tnb239v1\"\n#define NID_X9_62_c2tnb239v1            694\n#define OBJ_X9_62_c2tnb239v1            OBJ_X9_62_c_TwoCurve,11L\n\n#define SN_X9_62_c2tnb239v2             \"c2tnb239v2\"\n#define NID_X9_62_c2tnb239v2            695\n#define OBJ_X9_62_c2tnb239v2            OBJ_X9_62_c_TwoCurve,12L\n\n#define SN_X9_62_c2tnb239v3             \"c2tnb239v3\"\n#define NID_X9_62_c2tnb239v3            696\n#define OBJ_X9_62_c2tnb239v3            OBJ_X9_62_c_TwoCurve,13L\n\n#define SN_X9_62_c2onb239v4             \"c2onb239v4\"\n#define NID_X9_62_c2onb239v4            697\n#define OBJ_X9_62_c2onb239v4            OBJ_X9_62_c_TwoCurve,14L\n\n#define SN_X9_62_c2onb239v5             \"c2onb239v5\"\n#define NID_X9_62_c2onb239v5            698\n#define OBJ_X9_62_c2onb239v5            OBJ_X9_62_c_TwoCurve,15L\n\n#define SN_X9_62_c2pnb272w1             \"c2pnb272w1\"\n#define NID_X9_62_c2pnb272w1            699\n#define OBJ_X9_62_c2pnb272w1            OBJ_X9_62_c_TwoCurve,16L\n\n#define SN_X9_62_c2pnb304w1             \"c2pnb304w1\"\n#define NID_X9_62_c2pnb304w1            700\n#define OBJ_X9_62_c2pnb304w1            OBJ_X9_62_c_TwoCurve,17L\n\n#define SN_X9_62_c2tnb359v1             \"c2tnb359v1\"\n#define NID_X9_62_c2tnb359v1            701\n#define OBJ_X9_62_c2tnb359v1            OBJ_X9_62_c_TwoCurve,18L\n\n#define SN_X9_62_c2pnb368w1             \"c2pnb368w1\"\n#define NID_X9_62_c2pnb368w1            702\n#define OBJ_X9_62_c2pnb368w1            OBJ_X9_62_c_TwoCurve,19L\n\n#define SN_X9_62_c2tnb431r1             \"c2tnb431r1\"\n#define NID_X9_62_c2tnb431r1            703\n#define OBJ_X9_62_c2tnb431r1            OBJ_X9_62_c_TwoCurve,20L\n\n#define OBJ_X9_62_primeCurve            OBJ_X9_62_ellipticCurve,1L\n\n#define SN_X9_62_prime192v1             \"prime192v1\"\n#define NID_X9_62_prime192v1            409\n#define OBJ_X9_62_prime192v1            OBJ_X9_62_primeCurve,1L\n\n#define SN_X9_62_prime192v2             \"prime192v2\"\n#define NID_X9_62_prime192v2            410\n#define OBJ_X9_62_prime192v2            OBJ_X9_62_primeCurve,2L\n\n#define SN_X9_62_prime192v3             \"prime192v3\"\n#define NID_X9_62_prime192v3            411\n#define OBJ_X9_62_prime192v3            OBJ_X9_62_primeCurve,3L\n\n#define SN_X9_62_prime239v1             \"prime239v1\"\n#define NID_X9_62_prime239v1            412\n#define OBJ_X9_62_prime239v1            OBJ_X9_62_primeCurve,4L\n\n#define SN_X9_62_prime239v2             \"prime239v2\"\n#define NID_X9_62_prime239v2            413\n#define OBJ_X9_62_prime239v2            OBJ_X9_62_primeCurve,5L\n\n#define SN_X9_62_prime239v3             \"prime239v3\"\n#define NID_X9_62_prime239v3            414\n#define OBJ_X9_62_prime239v3            OBJ_X9_62_primeCurve,6L\n\n#define SN_X9_62_prime256v1             \"prime256v1\"\n#define NID_X9_62_prime256v1            415\n#define OBJ_X9_62_prime256v1            OBJ_X9_62_primeCurve,7L\n\n#define OBJ_X9_62_id_ecSigType          OBJ_ansi_X9_62,4L\n\n#define SN_ecdsa_with_SHA1              \"ecdsa-with-SHA1\"\n#define NID_ecdsa_with_SHA1             416\n#define OBJ_ecdsa_with_SHA1             OBJ_X9_62_id_ecSigType,1L\n\n#define SN_ecdsa_with_Recommended               \"ecdsa-with-Recommended\"\n#define NID_ecdsa_with_Recommended              791\n#define OBJ_ecdsa_with_Recommended              OBJ_X9_62_id_ecSigType,2L\n\n#define SN_ecdsa_with_Specified         \"ecdsa-with-Specified\"\n#define NID_ecdsa_with_Specified                792\n#define OBJ_ecdsa_with_Specified                OBJ_X9_62_id_ecSigType,3L\n\n#define SN_ecdsa_with_SHA224            \"ecdsa-with-SHA224\"\n#define NID_ecdsa_with_SHA224           793\n#define OBJ_ecdsa_with_SHA224           OBJ_ecdsa_with_Specified,1L\n\n#define SN_ecdsa_with_SHA256            \"ecdsa-with-SHA256\"\n#define NID_ecdsa_with_SHA256           794\n#define OBJ_ecdsa_with_SHA256           OBJ_ecdsa_with_Specified,2L\n\n#define SN_ecdsa_with_SHA384            \"ecdsa-with-SHA384\"\n#define NID_ecdsa_with_SHA384           795\n#define OBJ_ecdsa_with_SHA384           OBJ_ecdsa_with_Specified,3L\n\n#define SN_ecdsa_with_SHA512            \"ecdsa-with-SHA512\"\n#define NID_ecdsa_with_SHA512           796\n#define OBJ_ecdsa_with_SHA512           OBJ_ecdsa_with_Specified,4L\n\n#define OBJ_secg_ellipticCurve          OBJ_certicom_arc,0L\n\n#define SN_secp112r1            \"secp112r1\"\n#define NID_secp112r1           704\n#define OBJ_secp112r1           OBJ_secg_ellipticCurve,6L\n\n#define SN_secp112r2            \"secp112r2\"\n#define NID_secp112r2           705\n#define OBJ_secp112r2           OBJ_secg_ellipticCurve,7L\n\n#define SN_secp128r1            \"secp128r1\"\n#define NID_secp128r1           706\n#define OBJ_secp128r1           OBJ_secg_ellipticCurve,28L\n\n#define SN_secp128r2            \"secp128r2\"\n#define NID_secp128r2           707\n#define OBJ_secp128r2           OBJ_secg_ellipticCurve,29L\n\n#define SN_secp160k1            \"secp160k1\"\n#define NID_secp160k1           708\n#define OBJ_secp160k1           OBJ_secg_ellipticCurve,9L\n\n#define SN_secp160r1            \"secp160r1\"\n#define NID_secp160r1           709\n#define OBJ_secp160r1           OBJ_secg_ellipticCurve,8L\n\n#define SN_secp160r2            \"secp160r2\"\n#define NID_secp160r2           710\n#define OBJ_secp160r2           OBJ_secg_ellipticCurve,30L\n\n#define SN_secp192k1            \"secp192k1\"\n#define NID_secp192k1           711\n#define OBJ_secp192k1           OBJ_secg_ellipticCurve,31L\n\n#define SN_secp224k1            \"secp224k1\"\n#define NID_secp224k1           712\n#define OBJ_secp224k1           OBJ_secg_ellipticCurve,32L\n\n#define SN_secp224r1            \"secp224r1\"\n#define NID_secp224r1           713\n#define OBJ_secp224r1           OBJ_secg_ellipticCurve,33L\n\n#define SN_secp256k1            \"secp256k1\"\n#define NID_secp256k1           714\n#define OBJ_secp256k1           OBJ_secg_ellipticCurve,10L\n\n#define SN_secp384r1            \"secp384r1\"\n#define NID_secp384r1           715\n#define OBJ_secp384r1           OBJ_secg_ellipticCurve,34L\n\n#define SN_secp521r1            \"secp521r1\"\n#define NID_secp521r1           716\n#define OBJ_secp521r1           OBJ_secg_ellipticCurve,35L\n\n#define SN_sect113r1            \"sect113r1\"\n#define NID_sect113r1           717\n#define OBJ_sect113r1           OBJ_secg_ellipticCurve,4L\n\n#define SN_sect113r2            \"sect113r2\"\n#define NID_sect113r2           718\n#define OBJ_sect113r2           OBJ_secg_ellipticCurve,5L\n\n#define SN_sect131r1            \"sect131r1\"\n#define NID_sect131r1           719\n#define OBJ_sect131r1           OBJ_secg_ellipticCurve,22L\n\n#define SN_sect131r2            \"sect131r2\"\n#define NID_sect131r2           720\n#define OBJ_sect131r2           OBJ_secg_ellipticCurve,23L\n\n#define SN_sect163k1            \"sect163k1\"\n#define NID_sect163k1           721\n#define OBJ_sect163k1           OBJ_secg_ellipticCurve,1L\n\n#define SN_sect163r1            \"sect163r1\"\n#define NID_sect163r1           722\n#define OBJ_sect163r1           OBJ_secg_ellipticCurve,2L\n\n#define SN_sect163r2            \"sect163r2\"\n#define NID_sect163r2           723\n#define OBJ_sect163r2           OBJ_secg_ellipticCurve,15L\n\n#define SN_sect193r1            \"sect193r1\"\n#define NID_sect193r1           724\n#define OBJ_sect193r1           OBJ_secg_ellipticCurve,24L\n\n#define SN_sect193r2            \"sect193r2\"\n#define NID_sect193r2           725\n#define OBJ_sect193r2           OBJ_secg_ellipticCurve,25L\n\n#define SN_sect233k1            \"sect233k1\"\n#define NID_sect233k1           726\n#define OBJ_sect233k1           OBJ_secg_ellipticCurve,26L\n\n#define SN_sect233r1            \"sect233r1\"\n#define NID_sect233r1           727\n#define OBJ_sect233r1           OBJ_secg_ellipticCurve,27L\n\n#define SN_sect239k1            \"sect239k1\"\n#define NID_sect239k1           728\n#define OBJ_sect239k1           OBJ_secg_ellipticCurve,3L\n\n#define SN_sect283k1            \"sect283k1\"\n#define NID_sect283k1           729\n#define OBJ_sect283k1           OBJ_secg_ellipticCurve,16L\n\n#define SN_sect283r1            \"sect283r1\"\n#define NID_sect283r1           730\n#define OBJ_sect283r1           OBJ_secg_ellipticCurve,17L\n\n#define SN_sect409k1            \"sect409k1\"\n#define NID_sect409k1           731\n#define OBJ_sect409k1           OBJ_secg_ellipticCurve,36L\n\n#define SN_sect409r1            \"sect409r1\"\n#define NID_sect409r1           732\n#define OBJ_sect409r1           OBJ_secg_ellipticCurve,37L\n\n#define SN_sect571k1            \"sect571k1\"\n#define NID_sect571k1           733\n#define OBJ_sect571k1           OBJ_secg_ellipticCurve,38L\n\n#define SN_sect571r1            \"sect571r1\"\n#define NID_sect571r1           734\n#define OBJ_sect571r1           OBJ_secg_ellipticCurve,39L\n\n#define OBJ_wap_wsg_idm_ecid            OBJ_wap_wsg,4L\n\n#define SN_wap_wsg_idm_ecid_wtls1               \"wap-wsg-idm-ecid-wtls1\"\n#define NID_wap_wsg_idm_ecid_wtls1              735\n#define OBJ_wap_wsg_idm_ecid_wtls1              OBJ_wap_wsg_idm_ecid,1L\n\n#define SN_wap_wsg_idm_ecid_wtls3               \"wap-wsg-idm-ecid-wtls3\"\n#define NID_wap_wsg_idm_ecid_wtls3              736\n#define OBJ_wap_wsg_idm_ecid_wtls3              OBJ_wap_wsg_idm_ecid,3L\n\n#define SN_wap_wsg_idm_ecid_wtls4               \"wap-wsg-idm-ecid-wtls4\"\n#define NID_wap_wsg_idm_ecid_wtls4              737\n#define OBJ_wap_wsg_idm_ecid_wtls4              OBJ_wap_wsg_idm_ecid,4L\n\n#define SN_wap_wsg_idm_ecid_wtls5               \"wap-wsg-idm-ecid-wtls5\"\n#define NID_wap_wsg_idm_ecid_wtls5              738\n#define OBJ_wap_wsg_idm_ecid_wtls5              OBJ_wap_wsg_idm_ecid,5L\n\n#define SN_wap_wsg_idm_ecid_wtls6               \"wap-wsg-idm-ecid-wtls6\"\n#define NID_wap_wsg_idm_ecid_wtls6              739\n#define OBJ_wap_wsg_idm_ecid_wtls6              OBJ_wap_wsg_idm_ecid,6L\n\n#define SN_wap_wsg_idm_ecid_wtls7               \"wap-wsg-idm-ecid-wtls7\"\n#define NID_wap_wsg_idm_ecid_wtls7              740\n#define OBJ_wap_wsg_idm_ecid_wtls7              OBJ_wap_wsg_idm_ecid,7L\n\n#define SN_wap_wsg_idm_ecid_wtls8               \"wap-wsg-idm-ecid-wtls8\"\n#define NID_wap_wsg_idm_ecid_wtls8              741\n#define OBJ_wap_wsg_idm_ecid_wtls8              OBJ_wap_wsg_idm_ecid,8L\n\n#define SN_wap_wsg_idm_ecid_wtls9               \"wap-wsg-idm-ecid-wtls9\"\n#define NID_wap_wsg_idm_ecid_wtls9              742\n#define OBJ_wap_wsg_idm_ecid_wtls9              OBJ_wap_wsg_idm_ecid,9L\n\n#define SN_wap_wsg_idm_ecid_wtls10              \"wap-wsg-idm-ecid-wtls10\"\n#define NID_wap_wsg_idm_ecid_wtls10             743\n#define OBJ_wap_wsg_idm_ecid_wtls10             OBJ_wap_wsg_idm_ecid,10L\n\n#define SN_wap_wsg_idm_ecid_wtls11              \"wap-wsg-idm-ecid-wtls11\"\n#define NID_wap_wsg_idm_ecid_wtls11             744\n#define OBJ_wap_wsg_idm_ecid_wtls11             OBJ_wap_wsg_idm_ecid,11L\n\n#define SN_wap_wsg_idm_ecid_wtls12              \"wap-wsg-idm-ecid-wtls12\"\n#define NID_wap_wsg_idm_ecid_wtls12             745\n#define OBJ_wap_wsg_idm_ecid_wtls12             OBJ_wap_wsg_idm_ecid,12L\n\n#define SN_cast5_cbc            \"CAST5-CBC\"\n#define LN_cast5_cbc            \"cast5-cbc\"\n#define NID_cast5_cbc           108\n#define OBJ_cast5_cbc           OBJ_ISO_US,113533L,7L,66L,10L\n\n#define SN_cast5_ecb            \"CAST5-ECB\"\n#define LN_cast5_ecb            \"cast5-ecb\"\n#define NID_cast5_ecb           109\n\n#define SN_cast5_cfb64          \"CAST5-CFB\"\n#define LN_cast5_cfb64          \"cast5-cfb\"\n#define NID_cast5_cfb64         110\n\n#define SN_cast5_ofb64          \"CAST5-OFB\"\n#define LN_cast5_ofb64          \"cast5-ofb\"\n#define NID_cast5_ofb64         111\n\n#define LN_pbeWithMD5AndCast5_CBC               \"pbeWithMD5AndCast5CBC\"\n#define NID_pbeWithMD5AndCast5_CBC              112\n#define OBJ_pbeWithMD5AndCast5_CBC              OBJ_ISO_US,113533L,7L,66L,12L\n\n#define SN_id_PasswordBasedMAC          \"id-PasswordBasedMAC\"\n#define LN_id_PasswordBasedMAC          \"password based MAC\"\n#define NID_id_PasswordBasedMAC         782\n#define OBJ_id_PasswordBasedMAC         OBJ_ISO_US,113533L,7L,66L,13L\n\n#define SN_id_DHBasedMac                \"id-DHBasedMac\"\n#define LN_id_DHBasedMac                \"Diffie-Hellman based MAC\"\n#define NID_id_DHBasedMac               783\n#define OBJ_id_DHBasedMac               OBJ_ISO_US,113533L,7L,66L,30L\n\n#define SN_rsadsi               \"rsadsi\"\n#define LN_rsadsi               \"RSA Data Security, Inc.\"\n#define NID_rsadsi              1\n#define OBJ_rsadsi              OBJ_ISO_US,113549L\n\n#define SN_pkcs         \"pkcs\"\n#define LN_pkcs         \"RSA Data Security, Inc. PKCS\"\n#define NID_pkcs                2\n#define OBJ_pkcs                OBJ_rsadsi,1L\n\n#define SN_pkcs1                \"pkcs1\"\n#define NID_pkcs1               186\n#define OBJ_pkcs1               OBJ_pkcs,1L\n\n#define LN_rsaEncryption                \"rsaEncryption\"\n#define NID_rsaEncryption               6\n#define OBJ_rsaEncryption               OBJ_pkcs1,1L\n\n#define SN_md2WithRSAEncryption         \"RSA-MD2\"\n#define LN_md2WithRSAEncryption         \"md2WithRSAEncryption\"\n#define NID_md2WithRSAEncryption                7\n#define OBJ_md2WithRSAEncryption                OBJ_pkcs1,2L\n\n#define SN_md4WithRSAEncryption         \"RSA-MD4\"\n#define LN_md4WithRSAEncryption         \"md4WithRSAEncryption\"\n#define NID_md4WithRSAEncryption                396\n#define OBJ_md4WithRSAEncryption                OBJ_pkcs1,3L\n\n#define SN_md5WithRSAEncryption         \"RSA-MD5\"\n#define LN_md5WithRSAEncryption         \"md5WithRSAEncryption\"\n#define NID_md5WithRSAEncryption                8\n#define OBJ_md5WithRSAEncryption                OBJ_pkcs1,4L\n\n#define SN_sha1WithRSAEncryption                \"RSA-SHA1\"\n#define LN_sha1WithRSAEncryption                \"sha1WithRSAEncryption\"\n#define NID_sha1WithRSAEncryption               65\n#define OBJ_sha1WithRSAEncryption               OBJ_pkcs1,5L\n\n#define SN_rsaesOaep            \"RSAES-OAEP\"\n#define LN_rsaesOaep            \"rsaesOaep\"\n#define NID_rsaesOaep           919\n#define OBJ_rsaesOaep           OBJ_pkcs1,7L\n\n#define SN_mgf1         \"MGF1\"\n#define LN_mgf1         \"mgf1\"\n#define NID_mgf1                911\n#define OBJ_mgf1                OBJ_pkcs1,8L\n\n#define SN_pSpecified           \"PSPECIFIED\"\n#define LN_pSpecified           \"pSpecified\"\n#define NID_pSpecified          935\n#define OBJ_pSpecified          OBJ_pkcs1,9L\n\n#define SN_rsassaPss            \"RSASSA-PSS\"\n#define LN_rsassaPss            \"rsassaPss\"\n#define NID_rsassaPss           912\n#define OBJ_rsassaPss           OBJ_pkcs1,10L\n\n#define SN_sha256WithRSAEncryption              \"RSA-SHA256\"\n#define LN_sha256WithRSAEncryption              \"sha256WithRSAEncryption\"\n#define NID_sha256WithRSAEncryption             668\n#define OBJ_sha256WithRSAEncryption             OBJ_pkcs1,11L\n\n#define SN_sha384WithRSAEncryption              \"RSA-SHA384\"\n#define LN_sha384WithRSAEncryption              \"sha384WithRSAEncryption\"\n#define NID_sha384WithRSAEncryption             669\n#define OBJ_sha384WithRSAEncryption             OBJ_pkcs1,12L\n\n#define SN_sha512WithRSAEncryption              \"RSA-SHA512\"\n#define LN_sha512WithRSAEncryption              \"sha512WithRSAEncryption\"\n#define NID_sha512WithRSAEncryption             670\n#define OBJ_sha512WithRSAEncryption             OBJ_pkcs1,13L\n\n#define SN_sha224WithRSAEncryption              \"RSA-SHA224\"\n#define LN_sha224WithRSAEncryption              \"sha224WithRSAEncryption\"\n#define NID_sha224WithRSAEncryption             671\n#define OBJ_sha224WithRSAEncryption             OBJ_pkcs1,14L\n\n#define SN_pkcs3                \"pkcs3\"\n#define NID_pkcs3               27\n#define OBJ_pkcs3               OBJ_pkcs,3L\n\n#define LN_dhKeyAgreement               \"dhKeyAgreement\"\n#define NID_dhKeyAgreement              28\n#define OBJ_dhKeyAgreement              OBJ_pkcs3,1L\n\n#define SN_pkcs5                \"pkcs5\"\n#define NID_pkcs5               187\n#define OBJ_pkcs5               OBJ_pkcs,5L\n\n#define SN_pbeWithMD2AndDES_CBC         \"PBE-MD2-DES\"\n#define LN_pbeWithMD2AndDES_CBC         \"pbeWithMD2AndDES-CBC\"\n#define NID_pbeWithMD2AndDES_CBC                9\n#define OBJ_pbeWithMD2AndDES_CBC                OBJ_pkcs5,1L\n\n#define SN_pbeWithMD5AndDES_CBC         \"PBE-MD5-DES\"\n#define LN_pbeWithMD5AndDES_CBC         \"pbeWithMD5AndDES-CBC\"\n#define NID_pbeWithMD5AndDES_CBC                10\n#define OBJ_pbeWithMD5AndDES_CBC                OBJ_pkcs5,3L\n\n#define SN_pbeWithMD2AndRC2_CBC         \"PBE-MD2-RC2-64\"\n#define LN_pbeWithMD2AndRC2_CBC         \"pbeWithMD2AndRC2-CBC\"\n#define NID_pbeWithMD2AndRC2_CBC                168\n#define OBJ_pbeWithMD2AndRC2_CBC                OBJ_pkcs5,4L\n\n#define SN_pbeWithMD5AndRC2_CBC         \"PBE-MD5-RC2-64\"\n#define LN_pbeWithMD5AndRC2_CBC         \"pbeWithMD5AndRC2-CBC\"\n#define NID_pbeWithMD5AndRC2_CBC                169\n#define OBJ_pbeWithMD5AndRC2_CBC                OBJ_pkcs5,6L\n\n#define SN_pbeWithSHA1AndDES_CBC                \"PBE-SHA1-DES\"\n#define LN_pbeWithSHA1AndDES_CBC                \"pbeWithSHA1AndDES-CBC\"\n#define NID_pbeWithSHA1AndDES_CBC               170\n#define OBJ_pbeWithSHA1AndDES_CBC               OBJ_pkcs5,10L\n\n#define SN_pbeWithSHA1AndRC2_CBC                \"PBE-SHA1-RC2-64\"\n#define LN_pbeWithSHA1AndRC2_CBC                \"pbeWithSHA1AndRC2-CBC\"\n#define NID_pbeWithSHA1AndRC2_CBC               68\n#define OBJ_pbeWithSHA1AndRC2_CBC               OBJ_pkcs5,11L\n\n#define LN_id_pbkdf2            \"PBKDF2\"\n#define NID_id_pbkdf2           69\n#define OBJ_id_pbkdf2           OBJ_pkcs5,12L\n\n#define LN_pbes2                \"PBES2\"\n#define NID_pbes2               161\n#define OBJ_pbes2               OBJ_pkcs5,13L\n\n#define LN_pbmac1               \"PBMAC1\"\n#define NID_pbmac1              162\n#define OBJ_pbmac1              OBJ_pkcs5,14L\n\n#define SN_pkcs7                \"pkcs7\"\n#define NID_pkcs7               20\n#define OBJ_pkcs7               OBJ_pkcs,7L\n\n#define LN_pkcs7_data           \"pkcs7-data\"\n#define NID_pkcs7_data          21\n#define OBJ_pkcs7_data          OBJ_pkcs7,1L\n\n#define LN_pkcs7_signed         \"pkcs7-signedData\"\n#define NID_pkcs7_signed                22\n#define OBJ_pkcs7_signed                OBJ_pkcs7,2L\n\n#define LN_pkcs7_enveloped              \"pkcs7-envelopedData\"\n#define NID_pkcs7_enveloped             23\n#define OBJ_pkcs7_enveloped             OBJ_pkcs7,3L\n\n#define LN_pkcs7_signedAndEnveloped             \"pkcs7-signedAndEnvelopedData\"\n#define NID_pkcs7_signedAndEnveloped            24\n#define OBJ_pkcs7_signedAndEnveloped            OBJ_pkcs7,4L\n\n#define LN_pkcs7_digest         \"pkcs7-digestData\"\n#define NID_pkcs7_digest                25\n#define OBJ_pkcs7_digest                OBJ_pkcs7,5L\n\n#define LN_pkcs7_encrypted              \"pkcs7-encryptedData\"\n#define NID_pkcs7_encrypted             26\n#define OBJ_pkcs7_encrypted             OBJ_pkcs7,6L\n\n#define SN_pkcs9                \"pkcs9\"\n#define NID_pkcs9               47\n#define OBJ_pkcs9               OBJ_pkcs,9L\n\n#define LN_pkcs9_emailAddress           \"emailAddress\"\n#define NID_pkcs9_emailAddress          48\n#define OBJ_pkcs9_emailAddress          OBJ_pkcs9,1L\n\n#define LN_pkcs9_unstructuredName               \"unstructuredName\"\n#define NID_pkcs9_unstructuredName              49\n#define OBJ_pkcs9_unstructuredName              OBJ_pkcs9,2L\n\n#define LN_pkcs9_contentType            \"contentType\"\n#define NID_pkcs9_contentType           50\n#define OBJ_pkcs9_contentType           OBJ_pkcs9,3L\n\n#define LN_pkcs9_messageDigest          \"messageDigest\"\n#define NID_pkcs9_messageDigest         51\n#define OBJ_pkcs9_messageDigest         OBJ_pkcs9,4L\n\n#define LN_pkcs9_signingTime            \"signingTime\"\n#define NID_pkcs9_signingTime           52\n#define OBJ_pkcs9_signingTime           OBJ_pkcs9,5L\n\n#define LN_pkcs9_countersignature               \"countersignature\"\n#define NID_pkcs9_countersignature              53\n#define OBJ_pkcs9_countersignature              OBJ_pkcs9,6L\n\n#define LN_pkcs9_challengePassword              \"challengePassword\"\n#define NID_pkcs9_challengePassword             54\n#define OBJ_pkcs9_challengePassword             OBJ_pkcs9,7L\n\n#define LN_pkcs9_unstructuredAddress            \"unstructuredAddress\"\n#define NID_pkcs9_unstructuredAddress           55\n#define OBJ_pkcs9_unstructuredAddress           OBJ_pkcs9,8L\n\n#define LN_pkcs9_extCertAttributes              \"extendedCertificateAttributes\"\n#define NID_pkcs9_extCertAttributes             56\n#define OBJ_pkcs9_extCertAttributes             OBJ_pkcs9,9L\n\n#define SN_ext_req              \"extReq\"\n#define LN_ext_req              \"Extension Request\"\n#define NID_ext_req             172\n#define OBJ_ext_req             OBJ_pkcs9,14L\n\n#define SN_SMIMECapabilities            \"SMIME-CAPS\"\n#define LN_SMIMECapabilities            \"S/MIME Capabilities\"\n#define NID_SMIMECapabilities           167\n#define OBJ_SMIMECapabilities           OBJ_pkcs9,15L\n\n#define SN_SMIME                \"SMIME\"\n#define LN_SMIME                \"S/MIME\"\n#define NID_SMIME               188\n#define OBJ_SMIME               OBJ_pkcs9,16L\n\n#define SN_id_smime_mod         \"id-smime-mod\"\n#define NID_id_smime_mod                189\n#define OBJ_id_smime_mod                OBJ_SMIME,0L\n\n#define SN_id_smime_ct          \"id-smime-ct\"\n#define NID_id_smime_ct         190\n#define OBJ_id_smime_ct         OBJ_SMIME,1L\n\n#define SN_id_smime_aa          \"id-smime-aa\"\n#define NID_id_smime_aa         191\n#define OBJ_id_smime_aa         OBJ_SMIME,2L\n\n#define SN_id_smime_alg         \"id-smime-alg\"\n#define NID_id_smime_alg                192\n#define OBJ_id_smime_alg                OBJ_SMIME,3L\n\n#define SN_id_smime_cd          \"id-smime-cd\"\n#define NID_id_smime_cd         193\n#define OBJ_id_smime_cd         OBJ_SMIME,4L\n\n#define SN_id_smime_spq         \"id-smime-spq\"\n#define NID_id_smime_spq                194\n#define OBJ_id_smime_spq                OBJ_SMIME,5L\n\n#define SN_id_smime_cti         \"id-smime-cti\"\n#define NID_id_smime_cti                195\n#define OBJ_id_smime_cti                OBJ_SMIME,6L\n\n#define SN_id_smime_mod_cms             \"id-smime-mod-cms\"\n#define NID_id_smime_mod_cms            196\n#define OBJ_id_smime_mod_cms            OBJ_id_smime_mod,1L\n\n#define SN_id_smime_mod_ess             \"id-smime-mod-ess\"\n#define NID_id_smime_mod_ess            197\n#define OBJ_id_smime_mod_ess            OBJ_id_smime_mod,2L\n\n#define SN_id_smime_mod_oid             \"id-smime-mod-oid\"\n#define NID_id_smime_mod_oid            198\n#define OBJ_id_smime_mod_oid            OBJ_id_smime_mod,3L\n\n#define SN_id_smime_mod_msg_v3          \"id-smime-mod-msg-v3\"\n#define NID_id_smime_mod_msg_v3         199\n#define OBJ_id_smime_mod_msg_v3         OBJ_id_smime_mod,4L\n\n#define SN_id_smime_mod_ets_eSignature_88               \"id-smime-mod-ets-eSignature-88\"\n#define NID_id_smime_mod_ets_eSignature_88              200\n#define OBJ_id_smime_mod_ets_eSignature_88              OBJ_id_smime_mod,5L\n\n#define SN_id_smime_mod_ets_eSignature_97               \"id-smime-mod-ets-eSignature-97\"\n#define NID_id_smime_mod_ets_eSignature_97              201\n#define OBJ_id_smime_mod_ets_eSignature_97              OBJ_id_smime_mod,6L\n\n#define SN_id_smime_mod_ets_eSigPolicy_88               \"id-smime-mod-ets-eSigPolicy-88\"\n#define NID_id_smime_mod_ets_eSigPolicy_88              202\n#define OBJ_id_smime_mod_ets_eSigPolicy_88              OBJ_id_smime_mod,7L\n\n#define SN_id_smime_mod_ets_eSigPolicy_97               \"id-smime-mod-ets-eSigPolicy-97\"\n#define NID_id_smime_mod_ets_eSigPolicy_97              203\n#define OBJ_id_smime_mod_ets_eSigPolicy_97              OBJ_id_smime_mod,8L\n\n#define SN_id_smime_ct_receipt          \"id-smime-ct-receipt\"\n#define NID_id_smime_ct_receipt         204\n#define OBJ_id_smime_ct_receipt         OBJ_id_smime_ct,1L\n\n#define SN_id_smime_ct_authData         \"id-smime-ct-authData\"\n#define NID_id_smime_ct_authData                205\n#define OBJ_id_smime_ct_authData                OBJ_id_smime_ct,2L\n\n#define SN_id_smime_ct_publishCert              \"id-smime-ct-publishCert\"\n#define NID_id_smime_ct_publishCert             206\n#define OBJ_id_smime_ct_publishCert             OBJ_id_smime_ct,3L\n\n#define SN_id_smime_ct_TSTInfo          \"id-smime-ct-TSTInfo\"\n#define NID_id_smime_ct_TSTInfo         207\n#define OBJ_id_smime_ct_TSTInfo         OBJ_id_smime_ct,4L\n\n#define SN_id_smime_ct_TDTInfo          \"id-smime-ct-TDTInfo\"\n#define NID_id_smime_ct_TDTInfo         208\n#define OBJ_id_smime_ct_TDTInfo         OBJ_id_smime_ct,5L\n\n#define SN_id_smime_ct_contentInfo              \"id-smime-ct-contentInfo\"\n#define NID_id_smime_ct_contentInfo             209\n#define OBJ_id_smime_ct_contentInfo             OBJ_id_smime_ct,6L\n\n#define SN_id_smime_ct_DVCSRequestData          \"id-smime-ct-DVCSRequestData\"\n#define NID_id_smime_ct_DVCSRequestData         210\n#define OBJ_id_smime_ct_DVCSRequestData         OBJ_id_smime_ct,7L\n\n#define SN_id_smime_ct_DVCSResponseData         \"id-smime-ct-DVCSResponseData\"\n#define NID_id_smime_ct_DVCSResponseData                211\n#define OBJ_id_smime_ct_DVCSResponseData                OBJ_id_smime_ct,8L\n\n#define SN_id_smime_ct_compressedData           \"id-smime-ct-compressedData\"\n#define NID_id_smime_ct_compressedData          786\n#define OBJ_id_smime_ct_compressedData          OBJ_id_smime_ct,9L\n\n#define SN_id_ct_asciiTextWithCRLF              \"id-ct-asciiTextWithCRLF\"\n#define NID_id_ct_asciiTextWithCRLF             787\n#define OBJ_id_ct_asciiTextWithCRLF             OBJ_id_smime_ct,27L\n\n#define SN_id_smime_aa_receiptRequest           \"id-smime-aa-receiptRequest\"\n#define NID_id_smime_aa_receiptRequest          212\n#define OBJ_id_smime_aa_receiptRequest          OBJ_id_smime_aa,1L\n\n#define SN_id_smime_aa_securityLabel            \"id-smime-aa-securityLabel\"\n#define NID_id_smime_aa_securityLabel           213\n#define OBJ_id_smime_aa_securityLabel           OBJ_id_smime_aa,2L\n\n#define SN_id_smime_aa_mlExpandHistory          \"id-smime-aa-mlExpandHistory\"\n#define NID_id_smime_aa_mlExpandHistory         214\n#define OBJ_id_smime_aa_mlExpandHistory         OBJ_id_smime_aa,3L\n\n#define SN_id_smime_aa_contentHint              \"id-smime-aa-contentHint\"\n#define NID_id_smime_aa_contentHint             215\n#define OBJ_id_smime_aa_contentHint             OBJ_id_smime_aa,4L\n\n#define SN_id_smime_aa_msgSigDigest             \"id-smime-aa-msgSigDigest\"\n#define NID_id_smime_aa_msgSigDigest            216\n#define OBJ_id_smime_aa_msgSigDigest            OBJ_id_smime_aa,5L\n\n#define SN_id_smime_aa_encapContentType         \"id-smime-aa-encapContentType\"\n#define NID_id_smime_aa_encapContentType                217\n#define OBJ_id_smime_aa_encapContentType                OBJ_id_smime_aa,6L\n\n#define SN_id_smime_aa_contentIdentifier                \"id-smime-aa-contentIdentifier\"\n#define NID_id_smime_aa_contentIdentifier               218\n#define OBJ_id_smime_aa_contentIdentifier               OBJ_id_smime_aa,7L\n\n#define SN_id_smime_aa_macValue         \"id-smime-aa-macValue\"\n#define NID_id_smime_aa_macValue                219\n#define OBJ_id_smime_aa_macValue                OBJ_id_smime_aa,8L\n\n#define SN_id_smime_aa_equivalentLabels         \"id-smime-aa-equivalentLabels\"\n#define NID_id_smime_aa_equivalentLabels                220\n#define OBJ_id_smime_aa_equivalentLabels                OBJ_id_smime_aa,9L\n\n#define SN_id_smime_aa_contentReference         \"id-smime-aa-contentReference\"\n#define NID_id_smime_aa_contentReference                221\n#define OBJ_id_smime_aa_contentReference                OBJ_id_smime_aa,10L\n\n#define SN_id_smime_aa_encrypKeyPref            \"id-smime-aa-encrypKeyPref\"\n#define NID_id_smime_aa_encrypKeyPref           222\n#define OBJ_id_smime_aa_encrypKeyPref           OBJ_id_smime_aa,11L\n\n#define SN_id_smime_aa_signingCertificate               \"id-smime-aa-signingCertificate\"\n#define NID_id_smime_aa_signingCertificate              223\n#define OBJ_id_smime_aa_signingCertificate              OBJ_id_smime_aa,12L\n\n#define SN_id_smime_aa_smimeEncryptCerts                \"id-smime-aa-smimeEncryptCerts\"\n#define NID_id_smime_aa_smimeEncryptCerts               224\n#define OBJ_id_smime_aa_smimeEncryptCerts               OBJ_id_smime_aa,13L\n\n#define SN_id_smime_aa_timeStampToken           \"id-smime-aa-timeStampToken\"\n#define NID_id_smime_aa_timeStampToken          225\n#define OBJ_id_smime_aa_timeStampToken          OBJ_id_smime_aa,14L\n\n#define SN_id_smime_aa_ets_sigPolicyId          \"id-smime-aa-ets-sigPolicyId\"\n#define NID_id_smime_aa_ets_sigPolicyId         226\n#define OBJ_id_smime_aa_ets_sigPolicyId         OBJ_id_smime_aa,15L\n\n#define SN_id_smime_aa_ets_commitmentType               \"id-smime-aa-ets-commitmentType\"\n#define NID_id_smime_aa_ets_commitmentType              227\n#define OBJ_id_smime_aa_ets_commitmentType              OBJ_id_smime_aa,16L\n\n#define SN_id_smime_aa_ets_signerLocation               \"id-smime-aa-ets-signerLocation\"\n#define NID_id_smime_aa_ets_signerLocation              228\n#define OBJ_id_smime_aa_ets_signerLocation              OBJ_id_smime_aa,17L\n\n#define SN_id_smime_aa_ets_signerAttr           \"id-smime-aa-ets-signerAttr\"\n#define NID_id_smime_aa_ets_signerAttr          229\n#define OBJ_id_smime_aa_ets_signerAttr          OBJ_id_smime_aa,18L\n\n#define SN_id_smime_aa_ets_otherSigCert         \"id-smime-aa-ets-otherSigCert\"\n#define NID_id_smime_aa_ets_otherSigCert                230\n#define OBJ_id_smime_aa_ets_otherSigCert                OBJ_id_smime_aa,19L\n\n#define SN_id_smime_aa_ets_contentTimestamp             \"id-smime-aa-ets-contentTimestamp\"\n#define NID_id_smime_aa_ets_contentTimestamp            231\n#define OBJ_id_smime_aa_ets_contentTimestamp            OBJ_id_smime_aa,20L\n\n#define SN_id_smime_aa_ets_CertificateRefs              \"id-smime-aa-ets-CertificateRefs\"\n#define NID_id_smime_aa_ets_CertificateRefs             232\n#define OBJ_id_smime_aa_ets_CertificateRefs             OBJ_id_smime_aa,21L\n\n#define SN_id_smime_aa_ets_RevocationRefs               \"id-smime-aa-ets-RevocationRefs\"\n#define NID_id_smime_aa_ets_RevocationRefs              233\n#define OBJ_id_smime_aa_ets_RevocationRefs              OBJ_id_smime_aa,22L\n\n#define SN_id_smime_aa_ets_certValues           \"id-smime-aa-ets-certValues\"\n#define NID_id_smime_aa_ets_certValues          234\n#define OBJ_id_smime_aa_ets_certValues          OBJ_id_smime_aa,23L\n\n#define SN_id_smime_aa_ets_revocationValues             \"id-smime-aa-ets-revocationValues\"\n#define NID_id_smime_aa_ets_revocationValues            235\n#define OBJ_id_smime_aa_ets_revocationValues            OBJ_id_smime_aa,24L\n\n#define SN_id_smime_aa_ets_escTimeStamp         \"id-smime-aa-ets-escTimeStamp\"\n#define NID_id_smime_aa_ets_escTimeStamp                236\n#define OBJ_id_smime_aa_ets_escTimeStamp                OBJ_id_smime_aa,25L\n\n#define SN_id_smime_aa_ets_certCRLTimestamp             \"id-smime-aa-ets-certCRLTimestamp\"\n#define NID_id_smime_aa_ets_certCRLTimestamp            237\n#define OBJ_id_smime_aa_ets_certCRLTimestamp            OBJ_id_smime_aa,26L\n\n#define SN_id_smime_aa_ets_archiveTimeStamp             \"id-smime-aa-ets-archiveTimeStamp\"\n#define NID_id_smime_aa_ets_archiveTimeStamp            238\n#define OBJ_id_smime_aa_ets_archiveTimeStamp            OBJ_id_smime_aa,27L\n\n#define SN_id_smime_aa_signatureType            \"id-smime-aa-signatureType\"\n#define NID_id_smime_aa_signatureType           239\n#define OBJ_id_smime_aa_signatureType           OBJ_id_smime_aa,28L\n\n#define SN_id_smime_aa_dvcs_dvc         \"id-smime-aa-dvcs-dvc\"\n#define NID_id_smime_aa_dvcs_dvc                240\n#define OBJ_id_smime_aa_dvcs_dvc                OBJ_id_smime_aa,29L\n\n#define SN_id_smime_alg_ESDHwith3DES            \"id-smime-alg-ESDHwith3DES\"\n#define NID_id_smime_alg_ESDHwith3DES           241\n#define OBJ_id_smime_alg_ESDHwith3DES           OBJ_id_smime_alg,1L\n\n#define SN_id_smime_alg_ESDHwithRC2             \"id-smime-alg-ESDHwithRC2\"\n#define NID_id_smime_alg_ESDHwithRC2            242\n#define OBJ_id_smime_alg_ESDHwithRC2            OBJ_id_smime_alg,2L\n\n#define SN_id_smime_alg_3DESwrap                \"id-smime-alg-3DESwrap\"\n#define NID_id_smime_alg_3DESwrap               243\n#define OBJ_id_smime_alg_3DESwrap               OBJ_id_smime_alg,3L\n\n#define SN_id_smime_alg_RC2wrap         \"id-smime-alg-RC2wrap\"\n#define NID_id_smime_alg_RC2wrap                244\n#define OBJ_id_smime_alg_RC2wrap                OBJ_id_smime_alg,4L\n\n#define SN_id_smime_alg_ESDH            \"id-smime-alg-ESDH\"\n#define NID_id_smime_alg_ESDH           245\n#define OBJ_id_smime_alg_ESDH           OBJ_id_smime_alg,5L\n\n#define SN_id_smime_alg_CMS3DESwrap             \"id-smime-alg-CMS3DESwrap\"\n#define NID_id_smime_alg_CMS3DESwrap            246\n#define OBJ_id_smime_alg_CMS3DESwrap            OBJ_id_smime_alg,6L\n\n#define SN_id_smime_alg_CMSRC2wrap              \"id-smime-alg-CMSRC2wrap\"\n#define NID_id_smime_alg_CMSRC2wrap             247\n#define OBJ_id_smime_alg_CMSRC2wrap             OBJ_id_smime_alg,7L\n\n#define SN_id_alg_PWRI_KEK              \"id-alg-PWRI-KEK\"\n#define NID_id_alg_PWRI_KEK             893\n#define OBJ_id_alg_PWRI_KEK             OBJ_id_smime_alg,9L\n\n#define SN_id_smime_cd_ldap             \"id-smime-cd-ldap\"\n#define NID_id_smime_cd_ldap            248\n#define OBJ_id_smime_cd_ldap            OBJ_id_smime_cd,1L\n\n#define SN_id_smime_spq_ets_sqt_uri             \"id-smime-spq-ets-sqt-uri\"\n#define NID_id_smime_spq_ets_sqt_uri            249\n#define OBJ_id_smime_spq_ets_sqt_uri            OBJ_id_smime_spq,1L\n\n#define SN_id_smime_spq_ets_sqt_unotice         \"id-smime-spq-ets-sqt-unotice\"\n#define NID_id_smime_spq_ets_sqt_unotice                250\n#define OBJ_id_smime_spq_ets_sqt_unotice                OBJ_id_smime_spq,2L\n\n#define SN_id_smime_cti_ets_proofOfOrigin               \"id-smime-cti-ets-proofOfOrigin\"\n#define NID_id_smime_cti_ets_proofOfOrigin              251\n#define OBJ_id_smime_cti_ets_proofOfOrigin              OBJ_id_smime_cti,1L\n\n#define SN_id_smime_cti_ets_proofOfReceipt              \"id-smime-cti-ets-proofOfReceipt\"\n#define NID_id_smime_cti_ets_proofOfReceipt             252\n#define OBJ_id_smime_cti_ets_proofOfReceipt             OBJ_id_smime_cti,2L\n\n#define SN_id_smime_cti_ets_proofOfDelivery             \"id-smime-cti-ets-proofOfDelivery\"\n#define NID_id_smime_cti_ets_proofOfDelivery            253\n#define OBJ_id_smime_cti_ets_proofOfDelivery            OBJ_id_smime_cti,3L\n\n#define SN_id_smime_cti_ets_proofOfSender               \"id-smime-cti-ets-proofOfSender\"\n#define NID_id_smime_cti_ets_proofOfSender              254\n#define OBJ_id_smime_cti_ets_proofOfSender              OBJ_id_smime_cti,4L\n\n#define SN_id_smime_cti_ets_proofOfApproval             \"id-smime-cti-ets-proofOfApproval\"\n#define NID_id_smime_cti_ets_proofOfApproval            255\n#define OBJ_id_smime_cti_ets_proofOfApproval            OBJ_id_smime_cti,5L\n\n#define SN_id_smime_cti_ets_proofOfCreation             \"id-smime-cti-ets-proofOfCreation\"\n#define NID_id_smime_cti_ets_proofOfCreation            256\n#define OBJ_id_smime_cti_ets_proofOfCreation            OBJ_id_smime_cti,6L\n\n#define LN_friendlyName         \"friendlyName\"\n#define NID_friendlyName                156\n#define OBJ_friendlyName                OBJ_pkcs9,20L\n\n#define LN_localKeyID           \"localKeyID\"\n#define NID_localKeyID          157\n#define OBJ_localKeyID          OBJ_pkcs9,21L\n\n#define SN_ms_csp_name          \"CSPName\"\n#define LN_ms_csp_name          \"Microsoft CSP Name\"\n#define NID_ms_csp_name         417\n#define OBJ_ms_csp_name         1L,3L,6L,1L,4L,1L,311L,17L,1L\n\n#define SN_LocalKeySet          \"LocalKeySet\"\n#define LN_LocalKeySet          \"Microsoft Local Key set\"\n#define NID_LocalKeySet         856\n#define OBJ_LocalKeySet         1L,3L,6L,1L,4L,1L,311L,17L,2L\n\n#define OBJ_certTypes           OBJ_pkcs9,22L\n\n#define LN_x509Certificate              \"x509Certificate\"\n#define NID_x509Certificate             158\n#define OBJ_x509Certificate             OBJ_certTypes,1L\n\n#define LN_sdsiCertificate              \"sdsiCertificate\"\n#define NID_sdsiCertificate             159\n#define OBJ_sdsiCertificate             OBJ_certTypes,2L\n\n#define OBJ_crlTypes            OBJ_pkcs9,23L\n\n#define LN_x509Crl              \"x509Crl\"\n#define NID_x509Crl             160\n#define OBJ_x509Crl             OBJ_crlTypes,1L\n\n#define OBJ_pkcs12              OBJ_pkcs,12L\n\n#define OBJ_pkcs12_pbeids               OBJ_pkcs12,1L\n\n#define SN_pbe_WithSHA1And128BitRC4             \"PBE-SHA1-RC4-128\"\n#define LN_pbe_WithSHA1And128BitRC4             \"pbeWithSHA1And128BitRC4\"\n#define NID_pbe_WithSHA1And128BitRC4            144\n#define OBJ_pbe_WithSHA1And128BitRC4            OBJ_pkcs12_pbeids,1L\n\n#define SN_pbe_WithSHA1And40BitRC4              \"PBE-SHA1-RC4-40\"\n#define LN_pbe_WithSHA1And40BitRC4              \"pbeWithSHA1And40BitRC4\"\n#define NID_pbe_WithSHA1And40BitRC4             145\n#define OBJ_pbe_WithSHA1And40BitRC4             OBJ_pkcs12_pbeids,2L\n\n#define SN_pbe_WithSHA1And3_Key_TripleDES_CBC           \"PBE-SHA1-3DES\"\n#define LN_pbe_WithSHA1And3_Key_TripleDES_CBC           \"pbeWithSHA1And3-KeyTripleDES-CBC\"\n#define NID_pbe_WithSHA1And3_Key_TripleDES_CBC          146\n#define OBJ_pbe_WithSHA1And3_Key_TripleDES_CBC          OBJ_pkcs12_pbeids,3L\n\n#define SN_pbe_WithSHA1And2_Key_TripleDES_CBC           \"PBE-SHA1-2DES\"\n#define LN_pbe_WithSHA1And2_Key_TripleDES_CBC           \"pbeWithSHA1And2-KeyTripleDES-CBC\"\n#define NID_pbe_WithSHA1And2_Key_TripleDES_CBC          147\n#define OBJ_pbe_WithSHA1And2_Key_TripleDES_CBC          OBJ_pkcs12_pbeids,4L\n\n#define SN_pbe_WithSHA1And128BitRC2_CBC         \"PBE-SHA1-RC2-128\"\n#define LN_pbe_WithSHA1And128BitRC2_CBC         \"pbeWithSHA1And128BitRC2-CBC\"\n#define NID_pbe_WithSHA1And128BitRC2_CBC                148\n#define OBJ_pbe_WithSHA1And128BitRC2_CBC                OBJ_pkcs12_pbeids,5L\n\n#define SN_pbe_WithSHA1And40BitRC2_CBC          \"PBE-SHA1-RC2-40\"\n#define LN_pbe_WithSHA1And40BitRC2_CBC          \"pbeWithSHA1And40BitRC2-CBC\"\n#define NID_pbe_WithSHA1And40BitRC2_CBC         149\n#define OBJ_pbe_WithSHA1And40BitRC2_CBC         OBJ_pkcs12_pbeids,6L\n\n#define OBJ_pkcs12_Version1             OBJ_pkcs12,10L\n\n#define OBJ_pkcs12_BagIds               OBJ_pkcs12_Version1,1L\n\n#define LN_keyBag               \"keyBag\"\n#define NID_keyBag              150\n#define OBJ_keyBag              OBJ_pkcs12_BagIds,1L\n\n#define LN_pkcs8ShroudedKeyBag          \"pkcs8ShroudedKeyBag\"\n#define NID_pkcs8ShroudedKeyBag         151\n#define OBJ_pkcs8ShroudedKeyBag         OBJ_pkcs12_BagIds,2L\n\n#define LN_certBag              \"certBag\"\n#define NID_certBag             152\n#define OBJ_certBag             OBJ_pkcs12_BagIds,3L\n\n#define LN_crlBag               \"crlBag\"\n#define NID_crlBag              153\n#define OBJ_crlBag              OBJ_pkcs12_BagIds,4L\n\n#define LN_secretBag            \"secretBag\"\n#define NID_secretBag           154\n#define OBJ_secretBag           OBJ_pkcs12_BagIds,5L\n\n#define LN_safeContentsBag              \"safeContentsBag\"\n#define NID_safeContentsBag             155\n#define OBJ_safeContentsBag             OBJ_pkcs12_BagIds,6L\n\n#define SN_md2          \"MD2\"\n#define LN_md2          \"md2\"\n#define NID_md2         3\n#define OBJ_md2         OBJ_rsadsi,2L,2L\n\n#define SN_md4          \"MD4\"\n#define LN_md4          \"md4\"\n#define NID_md4         257\n#define OBJ_md4         OBJ_rsadsi,2L,4L\n\n#define SN_md5          \"MD5\"\n#define LN_md5          \"md5\"\n#define NID_md5         4\n#define OBJ_md5         OBJ_rsadsi,2L,5L\n\n#define SN_md5_sha1             \"MD5-SHA1\"\n#define LN_md5_sha1             \"md5-sha1\"\n#define NID_md5_sha1            114\n\n#define LN_hmacWithMD5          \"hmacWithMD5\"\n#define NID_hmacWithMD5         797\n#define OBJ_hmacWithMD5         OBJ_rsadsi,2L,6L\n\n#define LN_hmacWithSHA1         \"hmacWithSHA1\"\n#define NID_hmacWithSHA1                163\n#define OBJ_hmacWithSHA1                OBJ_rsadsi,2L,7L\n\n#define LN_hmacWithSHA224               \"hmacWithSHA224\"\n#define NID_hmacWithSHA224              798\n#define OBJ_hmacWithSHA224              OBJ_rsadsi,2L,8L\n\n#define LN_hmacWithSHA256               \"hmacWithSHA256\"\n#define NID_hmacWithSHA256              799\n#define OBJ_hmacWithSHA256              OBJ_rsadsi,2L,9L\n\n#define LN_hmacWithSHA384               \"hmacWithSHA384\"\n#define NID_hmacWithSHA384              800\n#define OBJ_hmacWithSHA384              OBJ_rsadsi,2L,10L\n\n#define LN_hmacWithSHA512               \"hmacWithSHA512\"\n#define NID_hmacWithSHA512              801\n#define OBJ_hmacWithSHA512              OBJ_rsadsi,2L,11L\n\n#define SN_rc2_cbc              \"RC2-CBC\"\n#define LN_rc2_cbc              \"rc2-cbc\"\n#define NID_rc2_cbc             37\n#define OBJ_rc2_cbc             OBJ_rsadsi,3L,2L\n\n#define SN_rc2_ecb              \"RC2-ECB\"\n#define LN_rc2_ecb              \"rc2-ecb\"\n#define NID_rc2_ecb             38\n\n#define SN_rc2_cfb64            \"RC2-CFB\"\n#define LN_rc2_cfb64            \"rc2-cfb\"\n#define NID_rc2_cfb64           39\n\n#define SN_rc2_ofb64            \"RC2-OFB\"\n#define LN_rc2_ofb64            \"rc2-ofb\"\n#define NID_rc2_ofb64           40\n\n#define SN_rc2_40_cbc           \"RC2-40-CBC\"\n#define LN_rc2_40_cbc           \"rc2-40-cbc\"\n#define NID_rc2_40_cbc          98\n\n#define SN_rc2_64_cbc           \"RC2-64-CBC\"\n#define LN_rc2_64_cbc           \"rc2-64-cbc\"\n#define NID_rc2_64_cbc          166\n\n#define SN_rc4          \"RC4\"\n#define LN_rc4          \"rc4\"\n#define NID_rc4         5\n#define OBJ_rc4         OBJ_rsadsi,3L,4L\n\n#define SN_rc4_40               \"RC4-40\"\n#define LN_rc4_40               \"rc4-40\"\n#define NID_rc4_40              97\n\n#define SN_des_ede3_cbc         \"DES-EDE3-CBC\"\n#define LN_des_ede3_cbc         \"des-ede3-cbc\"\n#define NID_des_ede3_cbc                44\n#define OBJ_des_ede3_cbc                OBJ_rsadsi,3L,7L\n\n#define SN_rc5_cbc              \"RC5-CBC\"\n#define LN_rc5_cbc              \"rc5-cbc\"\n#define NID_rc5_cbc             120\n#define OBJ_rc5_cbc             OBJ_rsadsi,3L,8L\n\n#define SN_rc5_ecb              \"RC5-ECB\"\n#define LN_rc5_ecb              \"rc5-ecb\"\n#define NID_rc5_ecb             121\n\n#define SN_rc5_cfb64            \"RC5-CFB\"\n#define LN_rc5_cfb64            \"rc5-cfb\"\n#define NID_rc5_cfb64           122\n\n#define SN_rc5_ofb64            \"RC5-OFB\"\n#define LN_rc5_ofb64            \"rc5-ofb\"\n#define NID_rc5_ofb64           123\n\n#define SN_ms_ext_req           \"msExtReq\"\n#define LN_ms_ext_req           \"Microsoft Extension Request\"\n#define NID_ms_ext_req          171\n#define OBJ_ms_ext_req          1L,3L,6L,1L,4L,1L,311L,2L,1L,14L\n\n#define SN_ms_code_ind          \"msCodeInd\"\n#define LN_ms_code_ind          \"Microsoft Individual Code Signing\"\n#define NID_ms_code_ind         134\n#define OBJ_ms_code_ind         1L,3L,6L,1L,4L,1L,311L,2L,1L,21L\n\n#define SN_ms_code_com          \"msCodeCom\"\n#define LN_ms_code_com          \"Microsoft Commercial Code Signing\"\n#define NID_ms_code_com         135\n#define OBJ_ms_code_com         1L,3L,6L,1L,4L,1L,311L,2L,1L,22L\n\n#define SN_ms_ctl_sign          \"msCTLSign\"\n#define LN_ms_ctl_sign          \"Microsoft Trust List Signing\"\n#define NID_ms_ctl_sign         136\n#define OBJ_ms_ctl_sign         1L,3L,6L,1L,4L,1L,311L,10L,3L,1L\n\n#define SN_ms_sgc               \"msSGC\"\n#define LN_ms_sgc               \"Microsoft Server Gated Crypto\"\n#define NID_ms_sgc              137\n#define OBJ_ms_sgc              1L,3L,6L,1L,4L,1L,311L,10L,3L,3L\n\n#define SN_ms_efs               \"msEFS\"\n#define LN_ms_efs               \"Microsoft Encrypted File System\"\n#define NID_ms_efs              138\n#define OBJ_ms_efs              1L,3L,6L,1L,4L,1L,311L,10L,3L,4L\n\n#define SN_ms_smartcard_login           \"msSmartcardLogin\"\n#define LN_ms_smartcard_login           \"Microsoft Smartcardlogin\"\n#define NID_ms_smartcard_login          648\n#define OBJ_ms_smartcard_login          1L,3L,6L,1L,4L,1L,311L,20L,2L,2L\n\n#define SN_ms_upn               \"msUPN\"\n#define LN_ms_upn               \"Microsoft Universal Principal Name\"\n#define NID_ms_upn              649\n#define OBJ_ms_upn              1L,3L,6L,1L,4L,1L,311L,20L,2L,3L\n\n#define SN_idea_cbc             \"IDEA-CBC\"\n#define LN_idea_cbc             \"idea-cbc\"\n#define NID_idea_cbc            34\n#define OBJ_idea_cbc            1L,3L,6L,1L,4L,1L,188L,7L,1L,1L,2L\n\n#define SN_idea_ecb             \"IDEA-ECB\"\n#define LN_idea_ecb             \"idea-ecb\"\n#define NID_idea_ecb            36\n\n#define SN_idea_cfb64           \"IDEA-CFB\"\n#define LN_idea_cfb64           \"idea-cfb\"\n#define NID_idea_cfb64          35\n\n#define SN_idea_ofb64           \"IDEA-OFB\"\n#define LN_idea_ofb64           \"idea-ofb\"\n#define NID_idea_ofb64          46\n\n#define SN_bf_cbc               \"BF-CBC\"\n#define LN_bf_cbc               \"bf-cbc\"\n#define NID_bf_cbc              91\n#define OBJ_bf_cbc              1L,3L,6L,1L,4L,1L,3029L,1L,2L\n\n#define SN_bf_ecb               \"BF-ECB\"\n#define LN_bf_ecb               \"bf-ecb\"\n#define NID_bf_ecb              92\n\n#define SN_bf_cfb64             \"BF-CFB\"\n#define LN_bf_cfb64             \"bf-cfb\"\n#define NID_bf_cfb64            93\n\n#define SN_bf_ofb64             \"BF-OFB\"\n#define LN_bf_ofb64             \"bf-ofb\"\n#define NID_bf_ofb64            94\n\n#define SN_id_pkix              \"PKIX\"\n#define NID_id_pkix             127\n#define OBJ_id_pkix             1L,3L,6L,1L,5L,5L,7L\n\n#define SN_id_pkix_mod          \"id-pkix-mod\"\n#define NID_id_pkix_mod         258\n#define OBJ_id_pkix_mod         OBJ_id_pkix,0L\n\n#define SN_id_pe                \"id-pe\"\n#define NID_id_pe               175\n#define OBJ_id_pe               OBJ_id_pkix,1L\n\n#define SN_id_qt                \"id-qt\"\n#define NID_id_qt               259\n#define OBJ_id_qt               OBJ_id_pkix,2L\n\n#define SN_id_kp                \"id-kp\"\n#define NID_id_kp               128\n#define OBJ_id_kp               OBJ_id_pkix,3L\n\n#define SN_id_it                \"id-it\"\n#define NID_id_it               260\n#define OBJ_id_it               OBJ_id_pkix,4L\n\n#define SN_id_pkip              \"id-pkip\"\n#define NID_id_pkip             261\n#define OBJ_id_pkip             OBJ_id_pkix,5L\n\n#define SN_id_alg               \"id-alg\"\n#define NID_id_alg              262\n#define OBJ_id_alg              OBJ_id_pkix,6L\n\n#define SN_id_cmc               \"id-cmc\"\n#define NID_id_cmc              263\n#define OBJ_id_cmc              OBJ_id_pkix,7L\n\n#define SN_id_on                \"id-on\"\n#define NID_id_on               264\n#define OBJ_id_on               OBJ_id_pkix,8L\n\n#define SN_id_pda               \"id-pda\"\n#define NID_id_pda              265\n#define OBJ_id_pda              OBJ_id_pkix,9L\n\n#define SN_id_aca               \"id-aca\"\n#define NID_id_aca              266\n#define OBJ_id_aca              OBJ_id_pkix,10L\n\n#define SN_id_qcs               \"id-qcs\"\n#define NID_id_qcs              267\n#define OBJ_id_qcs              OBJ_id_pkix,11L\n\n#define SN_id_cct               \"id-cct\"\n#define NID_id_cct              268\n#define OBJ_id_cct              OBJ_id_pkix,12L\n\n#define SN_id_ppl               \"id-ppl\"\n#define NID_id_ppl              662\n#define OBJ_id_ppl              OBJ_id_pkix,21L\n\n#define SN_id_ad                \"id-ad\"\n#define NID_id_ad               176\n#define OBJ_id_ad               OBJ_id_pkix,48L\n\n#define SN_id_pkix1_explicit_88         \"id-pkix1-explicit-88\"\n#define NID_id_pkix1_explicit_88                269\n#define OBJ_id_pkix1_explicit_88                OBJ_id_pkix_mod,1L\n\n#define SN_id_pkix1_implicit_88         \"id-pkix1-implicit-88\"\n#define NID_id_pkix1_implicit_88                270\n#define OBJ_id_pkix1_implicit_88                OBJ_id_pkix_mod,2L\n\n#define SN_id_pkix1_explicit_93         \"id-pkix1-explicit-93\"\n#define NID_id_pkix1_explicit_93                271\n#define OBJ_id_pkix1_explicit_93                OBJ_id_pkix_mod,3L\n\n#define SN_id_pkix1_implicit_93         \"id-pkix1-implicit-93\"\n#define NID_id_pkix1_implicit_93                272\n#define OBJ_id_pkix1_implicit_93                OBJ_id_pkix_mod,4L\n\n#define SN_id_mod_crmf          \"id-mod-crmf\"\n#define NID_id_mod_crmf         273\n#define OBJ_id_mod_crmf         OBJ_id_pkix_mod,5L\n\n#define SN_id_mod_cmc           \"id-mod-cmc\"\n#define NID_id_mod_cmc          274\n#define OBJ_id_mod_cmc          OBJ_id_pkix_mod,6L\n\n#define SN_id_mod_kea_profile_88                \"id-mod-kea-profile-88\"\n#define NID_id_mod_kea_profile_88               275\n#define OBJ_id_mod_kea_profile_88               OBJ_id_pkix_mod,7L\n\n#define SN_id_mod_kea_profile_93                \"id-mod-kea-profile-93\"\n#define NID_id_mod_kea_profile_93               276\n#define OBJ_id_mod_kea_profile_93               OBJ_id_pkix_mod,8L\n\n#define SN_id_mod_cmp           \"id-mod-cmp\"\n#define NID_id_mod_cmp          277\n#define OBJ_id_mod_cmp          OBJ_id_pkix_mod,9L\n\n#define SN_id_mod_qualified_cert_88             \"id-mod-qualified-cert-88\"\n#define NID_id_mod_qualified_cert_88            278\n#define OBJ_id_mod_qualified_cert_88            OBJ_id_pkix_mod,10L\n\n#define SN_id_mod_qualified_cert_93             \"id-mod-qualified-cert-93\"\n#define NID_id_mod_qualified_cert_93            279\n#define OBJ_id_mod_qualified_cert_93            OBJ_id_pkix_mod,11L\n\n#define SN_id_mod_attribute_cert                \"id-mod-attribute-cert\"\n#define NID_id_mod_attribute_cert               280\n#define OBJ_id_mod_attribute_cert               OBJ_id_pkix_mod,12L\n\n#define SN_id_mod_timestamp_protocol            \"id-mod-timestamp-protocol\"\n#define NID_id_mod_timestamp_protocol           281\n#define OBJ_id_mod_timestamp_protocol           OBJ_id_pkix_mod,13L\n\n#define SN_id_mod_ocsp          \"id-mod-ocsp\"\n#define NID_id_mod_ocsp         282\n#define OBJ_id_mod_ocsp         OBJ_id_pkix_mod,14L\n\n#define SN_id_mod_dvcs          \"id-mod-dvcs\"\n#define NID_id_mod_dvcs         283\n#define OBJ_id_mod_dvcs         OBJ_id_pkix_mod,15L\n\n#define SN_id_mod_cmp2000               \"id-mod-cmp2000\"\n#define NID_id_mod_cmp2000              284\n#define OBJ_id_mod_cmp2000              OBJ_id_pkix_mod,16L\n\n#define SN_info_access          \"authorityInfoAccess\"\n#define LN_info_access          \"Authority Information Access\"\n#define NID_info_access         177\n#define OBJ_info_access         OBJ_id_pe,1L\n\n#define SN_biometricInfo                \"biometricInfo\"\n#define LN_biometricInfo                \"Biometric Info\"\n#define NID_biometricInfo               285\n#define OBJ_biometricInfo               OBJ_id_pe,2L\n\n#define SN_qcStatements         \"qcStatements\"\n#define NID_qcStatements                286\n#define OBJ_qcStatements                OBJ_id_pe,3L\n\n#define SN_ac_auditEntity               \"ac-auditEntity\"\n#define NID_ac_auditEntity              287\n#define OBJ_ac_auditEntity              OBJ_id_pe,4L\n\n#define SN_ac_targeting         \"ac-targeting\"\n#define NID_ac_targeting                288\n#define OBJ_ac_targeting                OBJ_id_pe,5L\n\n#define SN_aaControls           \"aaControls\"\n#define NID_aaControls          289\n#define OBJ_aaControls          OBJ_id_pe,6L\n\n#define SN_sbgp_ipAddrBlock             \"sbgp-ipAddrBlock\"\n#define NID_sbgp_ipAddrBlock            290\n#define OBJ_sbgp_ipAddrBlock            OBJ_id_pe,7L\n\n#define SN_sbgp_autonomousSysNum                \"sbgp-autonomousSysNum\"\n#define NID_sbgp_autonomousSysNum               291\n#define OBJ_sbgp_autonomousSysNum               OBJ_id_pe,8L\n\n#define SN_sbgp_routerIdentifier                \"sbgp-routerIdentifier\"\n#define NID_sbgp_routerIdentifier               292\n#define OBJ_sbgp_routerIdentifier               OBJ_id_pe,9L\n\n#define SN_ac_proxying          \"ac-proxying\"\n#define NID_ac_proxying         397\n#define OBJ_ac_proxying         OBJ_id_pe,10L\n\n#define SN_sinfo_access         \"subjectInfoAccess\"\n#define LN_sinfo_access         \"Subject Information Access\"\n#define NID_sinfo_access                398\n#define OBJ_sinfo_access                OBJ_id_pe,11L\n\n#define SN_proxyCertInfo                \"proxyCertInfo\"\n#define LN_proxyCertInfo                \"Proxy Certificate Information\"\n#define NID_proxyCertInfo               663\n#define OBJ_proxyCertInfo               OBJ_id_pe,14L\n\n#define SN_id_qt_cps            \"id-qt-cps\"\n#define LN_id_qt_cps            \"Policy Qualifier CPS\"\n#define NID_id_qt_cps           164\n#define OBJ_id_qt_cps           OBJ_id_qt,1L\n\n#define SN_id_qt_unotice                \"id-qt-unotice\"\n#define LN_id_qt_unotice                \"Policy Qualifier User Notice\"\n#define NID_id_qt_unotice               165\n#define OBJ_id_qt_unotice               OBJ_id_qt,2L\n\n#define SN_textNotice           \"textNotice\"\n#define NID_textNotice          293\n#define OBJ_textNotice          OBJ_id_qt,3L\n\n#define SN_server_auth          \"serverAuth\"\n#define LN_server_auth          \"TLS Web Server Authentication\"\n#define NID_server_auth         129\n#define OBJ_server_auth         OBJ_id_kp,1L\n\n#define SN_client_auth          \"clientAuth\"\n#define LN_client_auth          \"TLS Web Client Authentication\"\n#define NID_client_auth         130\n#define OBJ_client_auth         OBJ_id_kp,2L\n\n#define SN_code_sign            \"codeSigning\"\n#define LN_code_sign            \"Code Signing\"\n#define NID_code_sign           131\n#define OBJ_code_sign           OBJ_id_kp,3L\n\n#define SN_email_protect                \"emailProtection\"\n#define LN_email_protect                \"E-mail Protection\"\n#define NID_email_protect               132\n#define OBJ_email_protect               OBJ_id_kp,4L\n\n#define SN_ipsecEndSystem               \"ipsecEndSystem\"\n#define LN_ipsecEndSystem               \"IPSec End System\"\n#define NID_ipsecEndSystem              294\n#define OBJ_ipsecEndSystem              OBJ_id_kp,5L\n\n#define SN_ipsecTunnel          \"ipsecTunnel\"\n#define LN_ipsecTunnel          \"IPSec Tunnel\"\n#define NID_ipsecTunnel         295\n#define OBJ_ipsecTunnel         OBJ_id_kp,6L\n\n#define SN_ipsecUser            \"ipsecUser\"\n#define LN_ipsecUser            \"IPSec User\"\n#define NID_ipsecUser           296\n#define OBJ_ipsecUser           OBJ_id_kp,7L\n\n#define SN_time_stamp           \"timeStamping\"\n#define LN_time_stamp           \"Time Stamping\"\n#define NID_time_stamp          133\n#define OBJ_time_stamp          OBJ_id_kp,8L\n\n#define SN_OCSP_sign            \"OCSPSigning\"\n#define LN_OCSP_sign            \"OCSP Signing\"\n#define NID_OCSP_sign           180\n#define OBJ_OCSP_sign           OBJ_id_kp,9L\n\n#define SN_dvcs         \"DVCS\"\n#define LN_dvcs         \"dvcs\"\n#define NID_dvcs                297\n#define OBJ_dvcs                OBJ_id_kp,10L\n\n#define SN_id_it_caProtEncCert          \"id-it-caProtEncCert\"\n#define NID_id_it_caProtEncCert         298\n#define OBJ_id_it_caProtEncCert         OBJ_id_it,1L\n\n#define SN_id_it_signKeyPairTypes               \"id-it-signKeyPairTypes\"\n#define NID_id_it_signKeyPairTypes              299\n#define OBJ_id_it_signKeyPairTypes              OBJ_id_it,2L\n\n#define SN_id_it_encKeyPairTypes                \"id-it-encKeyPairTypes\"\n#define NID_id_it_encKeyPairTypes               300\n#define OBJ_id_it_encKeyPairTypes               OBJ_id_it,3L\n\n#define SN_id_it_preferredSymmAlg               \"id-it-preferredSymmAlg\"\n#define NID_id_it_preferredSymmAlg              301\n#define OBJ_id_it_preferredSymmAlg              OBJ_id_it,4L\n\n#define SN_id_it_caKeyUpdateInfo                \"id-it-caKeyUpdateInfo\"\n#define NID_id_it_caKeyUpdateInfo               302\n#define OBJ_id_it_caKeyUpdateInfo               OBJ_id_it,5L\n\n#define SN_id_it_currentCRL             \"id-it-currentCRL\"\n#define NID_id_it_currentCRL            303\n#define OBJ_id_it_currentCRL            OBJ_id_it,6L\n\n#define SN_id_it_unsupportedOIDs                \"id-it-unsupportedOIDs\"\n#define NID_id_it_unsupportedOIDs               304\n#define OBJ_id_it_unsupportedOIDs               OBJ_id_it,7L\n\n#define SN_id_it_subscriptionRequest            \"id-it-subscriptionRequest\"\n#define NID_id_it_subscriptionRequest           305\n#define OBJ_id_it_subscriptionRequest           OBJ_id_it,8L\n\n#define SN_id_it_subscriptionResponse           \"id-it-subscriptionResponse\"\n#define NID_id_it_subscriptionResponse          306\n#define OBJ_id_it_subscriptionResponse          OBJ_id_it,9L\n\n#define SN_id_it_keyPairParamReq                \"id-it-keyPairParamReq\"\n#define NID_id_it_keyPairParamReq               307\n#define OBJ_id_it_keyPairParamReq               OBJ_id_it,10L\n\n#define SN_id_it_keyPairParamRep                \"id-it-keyPairParamRep\"\n#define NID_id_it_keyPairParamRep               308\n#define OBJ_id_it_keyPairParamRep               OBJ_id_it,11L\n\n#define SN_id_it_revPassphrase          \"id-it-revPassphrase\"\n#define NID_id_it_revPassphrase         309\n#define OBJ_id_it_revPassphrase         OBJ_id_it,12L\n\n#define SN_id_it_implicitConfirm                \"id-it-implicitConfirm\"\n#define NID_id_it_implicitConfirm               310\n#define OBJ_id_it_implicitConfirm               OBJ_id_it,13L\n\n#define SN_id_it_confirmWaitTime                \"id-it-confirmWaitTime\"\n#define NID_id_it_confirmWaitTime               311\n#define OBJ_id_it_confirmWaitTime               OBJ_id_it,14L\n\n#define SN_id_it_origPKIMessage         \"id-it-origPKIMessage\"\n#define NID_id_it_origPKIMessage                312\n#define OBJ_id_it_origPKIMessage                OBJ_id_it,15L\n\n#define SN_id_it_suppLangTags           \"id-it-suppLangTags\"\n#define NID_id_it_suppLangTags          784\n#define OBJ_id_it_suppLangTags          OBJ_id_it,16L\n\n#define SN_id_regCtrl           \"id-regCtrl\"\n#define NID_id_regCtrl          313\n#define OBJ_id_regCtrl          OBJ_id_pkip,1L\n\n#define SN_id_regInfo           \"id-regInfo\"\n#define NID_id_regInfo          314\n#define OBJ_id_regInfo          OBJ_id_pkip,2L\n\n#define SN_id_regCtrl_regToken          \"id-regCtrl-regToken\"\n#define NID_id_regCtrl_regToken         315\n#define OBJ_id_regCtrl_regToken         OBJ_id_regCtrl,1L\n\n#define SN_id_regCtrl_authenticator             \"id-regCtrl-authenticator\"\n#define NID_id_regCtrl_authenticator            316\n#define OBJ_id_regCtrl_authenticator            OBJ_id_regCtrl,2L\n\n#define SN_id_regCtrl_pkiPublicationInfo                \"id-regCtrl-pkiPublicationInfo\"\n#define NID_id_regCtrl_pkiPublicationInfo               317\n#define OBJ_id_regCtrl_pkiPublicationInfo               OBJ_id_regCtrl,3L\n\n#define SN_id_regCtrl_pkiArchiveOptions         \"id-regCtrl-pkiArchiveOptions\"\n#define NID_id_regCtrl_pkiArchiveOptions                318\n#define OBJ_id_regCtrl_pkiArchiveOptions                OBJ_id_regCtrl,4L\n\n#define SN_id_regCtrl_oldCertID         \"id-regCtrl-oldCertID\"\n#define NID_id_regCtrl_oldCertID                319\n#define OBJ_id_regCtrl_oldCertID                OBJ_id_regCtrl,5L\n\n#define SN_id_regCtrl_protocolEncrKey           \"id-regCtrl-protocolEncrKey\"\n#define NID_id_regCtrl_protocolEncrKey          320\n#define OBJ_id_regCtrl_protocolEncrKey          OBJ_id_regCtrl,6L\n\n#define SN_id_regInfo_utf8Pairs         \"id-regInfo-utf8Pairs\"\n#define NID_id_regInfo_utf8Pairs                321\n#define OBJ_id_regInfo_utf8Pairs                OBJ_id_regInfo,1L\n\n#define SN_id_regInfo_certReq           \"id-regInfo-certReq\"\n#define NID_id_regInfo_certReq          322\n#define OBJ_id_regInfo_certReq          OBJ_id_regInfo,2L\n\n#define SN_id_alg_des40         \"id-alg-des40\"\n#define NID_id_alg_des40                323\n#define OBJ_id_alg_des40                OBJ_id_alg,1L\n\n#define SN_id_alg_noSignature           \"id-alg-noSignature\"\n#define NID_id_alg_noSignature          324\n#define OBJ_id_alg_noSignature          OBJ_id_alg,2L\n\n#define SN_id_alg_dh_sig_hmac_sha1              \"id-alg-dh-sig-hmac-sha1\"\n#define NID_id_alg_dh_sig_hmac_sha1             325\n#define OBJ_id_alg_dh_sig_hmac_sha1             OBJ_id_alg,3L\n\n#define SN_id_alg_dh_pop                \"id-alg-dh-pop\"\n#define NID_id_alg_dh_pop               326\n#define OBJ_id_alg_dh_pop               OBJ_id_alg,4L\n\n#define SN_id_cmc_statusInfo            \"id-cmc-statusInfo\"\n#define NID_id_cmc_statusInfo           327\n#define OBJ_id_cmc_statusInfo           OBJ_id_cmc,1L\n\n#define SN_id_cmc_identification                \"id-cmc-identification\"\n#define NID_id_cmc_identification               328\n#define OBJ_id_cmc_identification               OBJ_id_cmc,2L\n\n#define SN_id_cmc_identityProof         \"id-cmc-identityProof\"\n#define NID_id_cmc_identityProof                329\n#define OBJ_id_cmc_identityProof                OBJ_id_cmc,3L\n\n#define SN_id_cmc_dataReturn            \"id-cmc-dataReturn\"\n#define NID_id_cmc_dataReturn           330\n#define OBJ_id_cmc_dataReturn           OBJ_id_cmc,4L\n\n#define SN_id_cmc_transactionId         \"id-cmc-transactionId\"\n#define NID_id_cmc_transactionId                331\n#define OBJ_id_cmc_transactionId                OBJ_id_cmc,5L\n\n#define SN_id_cmc_senderNonce           \"id-cmc-senderNonce\"\n#define NID_id_cmc_senderNonce          332\n#define OBJ_id_cmc_senderNonce          OBJ_id_cmc,6L\n\n#define SN_id_cmc_recipientNonce                \"id-cmc-recipientNonce\"\n#define NID_id_cmc_recipientNonce               333\n#define OBJ_id_cmc_recipientNonce               OBJ_id_cmc,7L\n\n#define SN_id_cmc_addExtensions         \"id-cmc-addExtensions\"\n#define NID_id_cmc_addExtensions                334\n#define OBJ_id_cmc_addExtensions                OBJ_id_cmc,8L\n\n#define SN_id_cmc_encryptedPOP          \"id-cmc-encryptedPOP\"\n#define NID_id_cmc_encryptedPOP         335\n#define OBJ_id_cmc_encryptedPOP         OBJ_id_cmc,9L\n\n#define SN_id_cmc_decryptedPOP          \"id-cmc-decryptedPOP\"\n#define NID_id_cmc_decryptedPOP         336\n#define OBJ_id_cmc_decryptedPOP         OBJ_id_cmc,10L\n\n#define SN_id_cmc_lraPOPWitness         \"id-cmc-lraPOPWitness\"\n#define NID_id_cmc_lraPOPWitness                337\n#define OBJ_id_cmc_lraPOPWitness                OBJ_id_cmc,11L\n\n#define SN_id_cmc_getCert               \"id-cmc-getCert\"\n#define NID_id_cmc_getCert              338\n#define OBJ_id_cmc_getCert              OBJ_id_cmc,15L\n\n#define SN_id_cmc_getCRL                \"id-cmc-getCRL\"\n#define NID_id_cmc_getCRL               339\n#define OBJ_id_cmc_getCRL               OBJ_id_cmc,16L\n\n#define SN_id_cmc_revokeRequest         \"id-cmc-revokeRequest\"\n#define NID_id_cmc_revokeRequest                340\n#define OBJ_id_cmc_revokeRequest                OBJ_id_cmc,17L\n\n#define SN_id_cmc_regInfo               \"id-cmc-regInfo\"\n#define NID_id_cmc_regInfo              341\n#define OBJ_id_cmc_regInfo              OBJ_id_cmc,18L\n\n#define SN_id_cmc_responseInfo          \"id-cmc-responseInfo\"\n#define NID_id_cmc_responseInfo         342\n#define OBJ_id_cmc_responseInfo         OBJ_id_cmc,19L\n\n#define SN_id_cmc_queryPending          \"id-cmc-queryPending\"\n#define NID_id_cmc_queryPending         343\n#define OBJ_id_cmc_queryPending         OBJ_id_cmc,21L\n\n#define SN_id_cmc_popLinkRandom         \"id-cmc-popLinkRandom\"\n#define NID_id_cmc_popLinkRandom                344\n#define OBJ_id_cmc_popLinkRandom                OBJ_id_cmc,22L\n\n#define SN_id_cmc_popLinkWitness                \"id-cmc-popLinkWitness\"\n#define NID_id_cmc_popLinkWitness               345\n#define OBJ_id_cmc_popLinkWitness               OBJ_id_cmc,23L\n\n#define SN_id_cmc_confirmCertAcceptance         \"id-cmc-confirmCertAcceptance\"\n#define NID_id_cmc_confirmCertAcceptance                346\n#define OBJ_id_cmc_confirmCertAcceptance                OBJ_id_cmc,24L\n\n#define SN_id_on_personalData           \"id-on-personalData\"\n#define NID_id_on_personalData          347\n#define OBJ_id_on_personalData          OBJ_id_on,1L\n\n#define SN_id_on_permanentIdentifier            \"id-on-permanentIdentifier\"\n#define LN_id_on_permanentIdentifier            \"Permanent Identifier\"\n#define NID_id_on_permanentIdentifier           858\n#define OBJ_id_on_permanentIdentifier           OBJ_id_on,3L\n\n#define SN_id_pda_dateOfBirth           \"id-pda-dateOfBirth\"\n#define NID_id_pda_dateOfBirth          348\n#define OBJ_id_pda_dateOfBirth          OBJ_id_pda,1L\n\n#define SN_id_pda_placeOfBirth          \"id-pda-placeOfBirth\"\n#define NID_id_pda_placeOfBirth         349\n#define OBJ_id_pda_placeOfBirth         OBJ_id_pda,2L\n\n#define SN_id_pda_gender                \"id-pda-gender\"\n#define NID_id_pda_gender               351\n#define OBJ_id_pda_gender               OBJ_id_pda,3L\n\n#define SN_id_pda_countryOfCitizenship          \"id-pda-countryOfCitizenship\"\n#define NID_id_pda_countryOfCitizenship         352\n#define OBJ_id_pda_countryOfCitizenship         OBJ_id_pda,4L\n\n#define SN_id_pda_countryOfResidence            \"id-pda-countryOfResidence\"\n#define NID_id_pda_countryOfResidence           353\n#define OBJ_id_pda_countryOfResidence           OBJ_id_pda,5L\n\n#define SN_id_aca_authenticationInfo            \"id-aca-authenticationInfo\"\n#define NID_id_aca_authenticationInfo           354\n#define OBJ_id_aca_authenticationInfo           OBJ_id_aca,1L\n\n#define SN_id_aca_accessIdentity                \"id-aca-accessIdentity\"\n#define NID_id_aca_accessIdentity               355\n#define OBJ_id_aca_accessIdentity               OBJ_id_aca,2L\n\n#define SN_id_aca_chargingIdentity              \"id-aca-chargingIdentity\"\n#define NID_id_aca_chargingIdentity             356\n#define OBJ_id_aca_chargingIdentity             OBJ_id_aca,3L\n\n#define SN_id_aca_group         \"id-aca-group\"\n#define NID_id_aca_group                357\n#define OBJ_id_aca_group                OBJ_id_aca,4L\n\n#define SN_id_aca_role          \"id-aca-role\"\n#define NID_id_aca_role         358\n#define OBJ_id_aca_role         OBJ_id_aca,5L\n\n#define SN_id_aca_encAttrs              \"id-aca-encAttrs\"\n#define NID_id_aca_encAttrs             399\n#define OBJ_id_aca_encAttrs             OBJ_id_aca,6L\n\n#define SN_id_qcs_pkixQCSyntax_v1               \"id-qcs-pkixQCSyntax-v1\"\n#define NID_id_qcs_pkixQCSyntax_v1              359\n#define OBJ_id_qcs_pkixQCSyntax_v1              OBJ_id_qcs,1L\n\n#define SN_id_cct_crs           \"id-cct-crs\"\n#define NID_id_cct_crs          360\n#define OBJ_id_cct_crs          OBJ_id_cct,1L\n\n#define SN_id_cct_PKIData               \"id-cct-PKIData\"\n#define NID_id_cct_PKIData              361\n#define OBJ_id_cct_PKIData              OBJ_id_cct,2L\n\n#define SN_id_cct_PKIResponse           \"id-cct-PKIResponse\"\n#define NID_id_cct_PKIResponse          362\n#define OBJ_id_cct_PKIResponse          OBJ_id_cct,3L\n\n#define SN_id_ppl_anyLanguage           \"id-ppl-anyLanguage\"\n#define LN_id_ppl_anyLanguage           \"Any language\"\n#define NID_id_ppl_anyLanguage          664\n#define OBJ_id_ppl_anyLanguage          OBJ_id_ppl,0L\n\n#define SN_id_ppl_inheritAll            \"id-ppl-inheritAll\"\n#define LN_id_ppl_inheritAll            \"Inherit all\"\n#define NID_id_ppl_inheritAll           665\n#define OBJ_id_ppl_inheritAll           OBJ_id_ppl,1L\n\n#define SN_Independent          \"id-ppl-independent\"\n#define LN_Independent          \"Independent\"\n#define NID_Independent         667\n#define OBJ_Independent         OBJ_id_ppl,2L\n\n#define SN_ad_OCSP              \"OCSP\"\n#define LN_ad_OCSP              \"OCSP\"\n#define NID_ad_OCSP             178\n#define OBJ_ad_OCSP             OBJ_id_ad,1L\n\n#define SN_ad_ca_issuers                \"caIssuers\"\n#define LN_ad_ca_issuers                \"CA Issuers\"\n#define NID_ad_ca_issuers               179\n#define OBJ_ad_ca_issuers               OBJ_id_ad,2L\n\n#define SN_ad_timeStamping              \"ad_timestamping\"\n#define LN_ad_timeStamping              \"AD Time Stamping\"\n#define NID_ad_timeStamping             363\n#define OBJ_ad_timeStamping             OBJ_id_ad,3L\n\n#define SN_ad_dvcs              \"AD_DVCS\"\n#define LN_ad_dvcs              \"ad dvcs\"\n#define NID_ad_dvcs             364\n#define OBJ_ad_dvcs             OBJ_id_ad,4L\n\n#define SN_caRepository         \"caRepository\"\n#define LN_caRepository         \"CA Repository\"\n#define NID_caRepository                785\n#define OBJ_caRepository                OBJ_id_ad,5L\n\n#define OBJ_id_pkix_OCSP                OBJ_ad_OCSP\n\n#define SN_id_pkix_OCSP_basic           \"basicOCSPResponse\"\n#define LN_id_pkix_OCSP_basic           \"Basic OCSP Response\"\n#define NID_id_pkix_OCSP_basic          365\n#define OBJ_id_pkix_OCSP_basic          OBJ_id_pkix_OCSP,1L\n\n#define SN_id_pkix_OCSP_Nonce           \"Nonce\"\n#define LN_id_pkix_OCSP_Nonce           \"OCSP Nonce\"\n#define NID_id_pkix_OCSP_Nonce          366\n#define OBJ_id_pkix_OCSP_Nonce          OBJ_id_pkix_OCSP,2L\n\n#define SN_id_pkix_OCSP_CrlID           \"CrlID\"\n#define LN_id_pkix_OCSP_CrlID           \"OCSP CRL ID\"\n#define NID_id_pkix_OCSP_CrlID          367\n#define OBJ_id_pkix_OCSP_CrlID          OBJ_id_pkix_OCSP,3L\n\n#define SN_id_pkix_OCSP_acceptableResponses             \"acceptableResponses\"\n#define LN_id_pkix_OCSP_acceptableResponses             \"Acceptable OCSP Responses\"\n#define NID_id_pkix_OCSP_acceptableResponses            368\n#define OBJ_id_pkix_OCSP_acceptableResponses            OBJ_id_pkix_OCSP,4L\n\n#define SN_id_pkix_OCSP_noCheck         \"noCheck\"\n#define LN_id_pkix_OCSP_noCheck         \"OCSP No Check\"\n#define NID_id_pkix_OCSP_noCheck                369\n#define OBJ_id_pkix_OCSP_noCheck                OBJ_id_pkix_OCSP,5L\n\n#define SN_id_pkix_OCSP_archiveCutoff           \"archiveCutoff\"\n#define LN_id_pkix_OCSP_archiveCutoff           \"OCSP Archive Cutoff\"\n#define NID_id_pkix_OCSP_archiveCutoff          370\n#define OBJ_id_pkix_OCSP_archiveCutoff          OBJ_id_pkix_OCSP,6L\n\n#define SN_id_pkix_OCSP_serviceLocator          \"serviceLocator\"\n#define LN_id_pkix_OCSP_serviceLocator          \"OCSP Service Locator\"\n#define NID_id_pkix_OCSP_serviceLocator         371\n#define OBJ_id_pkix_OCSP_serviceLocator         OBJ_id_pkix_OCSP,7L\n\n#define SN_id_pkix_OCSP_extendedStatus          \"extendedStatus\"\n#define LN_id_pkix_OCSP_extendedStatus          \"Extended OCSP Status\"\n#define NID_id_pkix_OCSP_extendedStatus         372\n#define OBJ_id_pkix_OCSP_extendedStatus         OBJ_id_pkix_OCSP,8L\n\n#define SN_id_pkix_OCSP_valid           \"valid\"\n#define NID_id_pkix_OCSP_valid          373\n#define OBJ_id_pkix_OCSP_valid          OBJ_id_pkix_OCSP,9L\n\n#define SN_id_pkix_OCSP_path            \"path\"\n#define NID_id_pkix_OCSP_path           374\n#define OBJ_id_pkix_OCSP_path           OBJ_id_pkix_OCSP,10L\n\n#define SN_id_pkix_OCSP_trustRoot               \"trustRoot\"\n#define LN_id_pkix_OCSP_trustRoot               \"Trust Root\"\n#define NID_id_pkix_OCSP_trustRoot              375\n#define OBJ_id_pkix_OCSP_trustRoot              OBJ_id_pkix_OCSP,11L\n\n#define SN_algorithm            \"algorithm\"\n#define LN_algorithm            \"algorithm\"\n#define NID_algorithm           376\n#define OBJ_algorithm           1L,3L,14L,3L,2L\n\n#define SN_md5WithRSA           \"RSA-NP-MD5\"\n#define LN_md5WithRSA           \"md5WithRSA\"\n#define NID_md5WithRSA          104\n#define OBJ_md5WithRSA          OBJ_algorithm,3L\n\n#define SN_des_ecb              \"DES-ECB\"\n#define LN_des_ecb              \"des-ecb\"\n#define NID_des_ecb             29\n#define OBJ_des_ecb             OBJ_algorithm,6L\n\n#define SN_des_cbc              \"DES-CBC\"\n#define LN_des_cbc              \"des-cbc\"\n#define NID_des_cbc             31\n#define OBJ_des_cbc             OBJ_algorithm,7L\n\n#define SN_des_ofb64            \"DES-OFB\"\n#define LN_des_ofb64            \"des-ofb\"\n#define NID_des_ofb64           45\n#define OBJ_des_ofb64           OBJ_algorithm,8L\n\n#define SN_des_cfb64            \"DES-CFB\"\n#define LN_des_cfb64            \"des-cfb\"\n#define NID_des_cfb64           30\n#define OBJ_des_cfb64           OBJ_algorithm,9L\n\n#define SN_rsaSignature         \"rsaSignature\"\n#define NID_rsaSignature                377\n#define OBJ_rsaSignature                OBJ_algorithm,11L\n\n#define SN_dsa_2                \"DSA-old\"\n#define LN_dsa_2                \"dsaEncryption-old\"\n#define NID_dsa_2               67\n#define OBJ_dsa_2               OBJ_algorithm,12L\n\n#define SN_dsaWithSHA           \"DSA-SHA\"\n#define LN_dsaWithSHA           \"dsaWithSHA\"\n#define NID_dsaWithSHA          66\n#define OBJ_dsaWithSHA          OBJ_algorithm,13L\n\n#define SN_shaWithRSAEncryption         \"RSA-SHA\"\n#define LN_shaWithRSAEncryption         \"shaWithRSAEncryption\"\n#define NID_shaWithRSAEncryption                42\n#define OBJ_shaWithRSAEncryption                OBJ_algorithm,15L\n\n#define SN_des_ede_ecb          \"DES-EDE\"\n#define LN_des_ede_ecb          \"des-ede\"\n#define NID_des_ede_ecb         32\n#define OBJ_des_ede_ecb         OBJ_algorithm,17L\n\n#define SN_des_ede3_ecb         \"DES-EDE3\"\n#define LN_des_ede3_ecb         \"des-ede3\"\n#define NID_des_ede3_ecb                33\n\n#define SN_des_ede_cbc          \"DES-EDE-CBC\"\n#define LN_des_ede_cbc          \"des-ede-cbc\"\n#define NID_des_ede_cbc         43\n\n#define SN_des_ede_cfb64                \"DES-EDE-CFB\"\n#define LN_des_ede_cfb64                \"des-ede-cfb\"\n#define NID_des_ede_cfb64               60\n\n#define SN_des_ede3_cfb64               \"DES-EDE3-CFB\"\n#define LN_des_ede3_cfb64               \"des-ede3-cfb\"\n#define NID_des_ede3_cfb64              61\n\n#define SN_des_ede_ofb64                \"DES-EDE-OFB\"\n#define LN_des_ede_ofb64                \"des-ede-ofb\"\n#define NID_des_ede_ofb64               62\n\n#define SN_des_ede3_ofb64               \"DES-EDE3-OFB\"\n#define LN_des_ede3_ofb64               \"des-ede3-ofb\"\n#define NID_des_ede3_ofb64              63\n\n#define SN_desx_cbc             \"DESX-CBC\"\n#define LN_desx_cbc             \"desx-cbc\"\n#define NID_desx_cbc            80\n\n#define SN_sha          \"SHA\"\n#define LN_sha          \"sha\"\n#define NID_sha         41\n#define OBJ_sha         OBJ_algorithm,18L\n\n#define SN_sha1         \"SHA1\"\n#define LN_sha1         \"sha1\"\n#define NID_sha1                64\n#define OBJ_sha1                OBJ_algorithm,26L\n\n#define SN_dsaWithSHA1_2                \"DSA-SHA1-old\"\n#define LN_dsaWithSHA1_2                \"dsaWithSHA1-old\"\n#define NID_dsaWithSHA1_2               70\n#define OBJ_dsaWithSHA1_2               OBJ_algorithm,27L\n\n#define SN_sha1WithRSA          \"RSA-SHA1-2\"\n#define LN_sha1WithRSA          \"sha1WithRSA\"\n#define NID_sha1WithRSA         115\n#define OBJ_sha1WithRSA         OBJ_algorithm,29L\n\n#define SN_ripemd160            \"RIPEMD160\"\n#define LN_ripemd160            \"ripemd160\"\n#define NID_ripemd160           117\n#define OBJ_ripemd160           1L,3L,36L,3L,2L,1L\n\n#define SN_ripemd160WithRSA             \"RSA-RIPEMD160\"\n#define LN_ripemd160WithRSA             \"ripemd160WithRSA\"\n#define NID_ripemd160WithRSA            119\n#define OBJ_ripemd160WithRSA            1L,3L,36L,3L,3L,1L,2L\n\n#define SN_sxnet                \"SXNetID\"\n#define LN_sxnet                \"Strong Extranet ID\"\n#define NID_sxnet               143\n#define OBJ_sxnet               1L,3L,101L,1L,4L,1L\n\n#define SN_X500         \"X500\"\n#define LN_X500         \"directory services (X.500)\"\n#define NID_X500                11\n#define OBJ_X500                2L,5L\n\n#define SN_X509         \"X509\"\n#define NID_X509                12\n#define OBJ_X509                OBJ_X500,4L\n\n#define SN_commonName           \"CN\"\n#define LN_commonName           \"commonName\"\n#define NID_commonName          13\n#define OBJ_commonName          OBJ_X509,3L\n\n#define SN_surname              \"SN\"\n#define LN_surname              \"surname\"\n#define NID_surname             100\n#define OBJ_surname             OBJ_X509,4L\n\n#define LN_serialNumber         \"serialNumber\"\n#define NID_serialNumber                105\n#define OBJ_serialNumber                OBJ_X509,5L\n\n#define SN_countryName          \"C\"\n#define LN_countryName          \"countryName\"\n#define NID_countryName         14\n#define OBJ_countryName         OBJ_X509,6L\n\n#define SN_localityName         \"L\"\n#define LN_localityName         \"localityName\"\n#define NID_localityName                15\n#define OBJ_localityName                OBJ_X509,7L\n\n#define SN_stateOrProvinceName          \"ST\"\n#define LN_stateOrProvinceName          \"stateOrProvinceName\"\n#define NID_stateOrProvinceName         16\n#define OBJ_stateOrProvinceName         OBJ_X509,8L\n\n#define SN_streetAddress                \"street\"\n#define LN_streetAddress                \"streetAddress\"\n#define NID_streetAddress               660\n#define OBJ_streetAddress               OBJ_X509,9L\n\n#define SN_organizationName             \"O\"\n#define LN_organizationName             \"organizationName\"\n#define NID_organizationName            17\n#define OBJ_organizationName            OBJ_X509,10L\n\n#define SN_organizationalUnitName               \"OU\"\n#define LN_organizationalUnitName               \"organizationalUnitName\"\n#define NID_organizationalUnitName              18\n#define OBJ_organizationalUnitName              OBJ_X509,11L\n\n#define SN_title                \"title\"\n#define LN_title                \"title\"\n#define NID_title               106\n#define OBJ_title               OBJ_X509,12L\n\n#define LN_description          \"description\"\n#define NID_description         107\n#define OBJ_description         OBJ_X509,13L\n\n#define LN_searchGuide          \"searchGuide\"\n#define NID_searchGuide         859\n#define OBJ_searchGuide         OBJ_X509,14L\n\n#define LN_businessCategory             \"businessCategory\"\n#define NID_businessCategory            860\n#define OBJ_businessCategory            OBJ_X509,15L\n\n#define LN_postalAddress                \"postalAddress\"\n#define NID_postalAddress               861\n#define OBJ_postalAddress               OBJ_X509,16L\n\n#define LN_postalCode           \"postalCode\"\n#define NID_postalCode          661\n#define OBJ_postalCode          OBJ_X509,17L\n\n#define LN_postOfficeBox                \"postOfficeBox\"\n#define NID_postOfficeBox               862\n#define OBJ_postOfficeBox               OBJ_X509,18L\n\n#define LN_physicalDeliveryOfficeName           \"physicalDeliveryOfficeName\"\n#define NID_physicalDeliveryOfficeName          863\n#define OBJ_physicalDeliveryOfficeName          OBJ_X509,19L\n\n#define LN_telephoneNumber              \"telephoneNumber\"\n#define NID_telephoneNumber             864\n#define OBJ_telephoneNumber             OBJ_X509,20L\n\n#define LN_telexNumber          \"telexNumber\"\n#define NID_telexNumber         865\n#define OBJ_telexNumber         OBJ_X509,21L\n\n#define LN_teletexTerminalIdentifier            \"teletexTerminalIdentifier\"\n#define NID_teletexTerminalIdentifier           866\n#define OBJ_teletexTerminalIdentifier           OBJ_X509,22L\n\n#define LN_facsimileTelephoneNumber             \"facsimileTelephoneNumber\"\n#define NID_facsimileTelephoneNumber            867\n#define OBJ_facsimileTelephoneNumber            OBJ_X509,23L\n\n#define LN_x121Address          \"x121Address\"\n#define NID_x121Address         868\n#define OBJ_x121Address         OBJ_X509,24L\n\n#define LN_internationaliSDNNumber              \"internationaliSDNNumber\"\n#define NID_internationaliSDNNumber             869\n#define OBJ_internationaliSDNNumber             OBJ_X509,25L\n\n#define LN_registeredAddress            \"registeredAddress\"\n#define NID_registeredAddress           870\n#define OBJ_registeredAddress           OBJ_X509,26L\n\n#define LN_destinationIndicator         \"destinationIndicator\"\n#define NID_destinationIndicator                871\n#define OBJ_destinationIndicator                OBJ_X509,27L\n\n#define LN_preferredDeliveryMethod              \"preferredDeliveryMethod\"\n#define NID_preferredDeliveryMethod             872\n#define OBJ_preferredDeliveryMethod             OBJ_X509,28L\n\n#define LN_presentationAddress          \"presentationAddress\"\n#define NID_presentationAddress         873\n#define OBJ_presentationAddress         OBJ_X509,29L\n\n#define LN_supportedApplicationContext          \"supportedApplicationContext\"\n#define NID_supportedApplicationContext         874\n#define OBJ_supportedApplicationContext         OBJ_X509,30L\n\n#define SN_member               \"member\"\n#define NID_member              875\n#define OBJ_member              OBJ_X509,31L\n\n#define SN_owner                \"owner\"\n#define NID_owner               876\n#define OBJ_owner               OBJ_X509,32L\n\n#define LN_roleOccupant         \"roleOccupant\"\n#define NID_roleOccupant                877\n#define OBJ_roleOccupant                OBJ_X509,33L\n\n#define SN_seeAlso              \"seeAlso\"\n#define NID_seeAlso             878\n#define OBJ_seeAlso             OBJ_X509,34L\n\n#define LN_userPassword         \"userPassword\"\n#define NID_userPassword                879\n#define OBJ_userPassword                OBJ_X509,35L\n\n#define LN_userCertificate              \"userCertificate\"\n#define NID_userCertificate             880\n#define OBJ_userCertificate             OBJ_X509,36L\n\n#define LN_cACertificate                \"cACertificate\"\n#define NID_cACertificate               881\n#define OBJ_cACertificate               OBJ_X509,37L\n\n#define LN_authorityRevocationList              \"authorityRevocationList\"\n#define NID_authorityRevocationList             882\n#define OBJ_authorityRevocationList             OBJ_X509,38L\n\n#define LN_certificateRevocationList            \"certificateRevocationList\"\n#define NID_certificateRevocationList           883\n#define OBJ_certificateRevocationList           OBJ_X509,39L\n\n#define LN_crossCertificatePair         \"crossCertificatePair\"\n#define NID_crossCertificatePair                884\n#define OBJ_crossCertificatePair                OBJ_X509,40L\n\n#define SN_name         \"name\"\n#define LN_name         \"name\"\n#define NID_name                173\n#define OBJ_name                OBJ_X509,41L\n\n#define SN_givenName            \"GN\"\n#define LN_givenName            \"givenName\"\n#define NID_givenName           99\n#define OBJ_givenName           OBJ_X509,42L\n\n#define SN_initials             \"initials\"\n#define LN_initials             \"initials\"\n#define NID_initials            101\n#define OBJ_initials            OBJ_X509,43L\n\n#define LN_generationQualifier          \"generationQualifier\"\n#define NID_generationQualifier         509\n#define OBJ_generationQualifier         OBJ_X509,44L\n\n#define LN_x500UniqueIdentifier         \"x500UniqueIdentifier\"\n#define NID_x500UniqueIdentifier                503\n#define OBJ_x500UniqueIdentifier                OBJ_X509,45L\n\n#define SN_dnQualifier          \"dnQualifier\"\n#define LN_dnQualifier          \"dnQualifier\"\n#define NID_dnQualifier         174\n#define OBJ_dnQualifier         OBJ_X509,46L\n\n#define LN_enhancedSearchGuide          \"enhancedSearchGuide\"\n#define NID_enhancedSearchGuide         885\n#define OBJ_enhancedSearchGuide         OBJ_X509,47L\n\n#define LN_protocolInformation          \"protocolInformation\"\n#define NID_protocolInformation         886\n#define OBJ_protocolInformation         OBJ_X509,48L\n\n#define LN_distinguishedName            \"distinguishedName\"\n#define NID_distinguishedName           887\n#define OBJ_distinguishedName           OBJ_X509,49L\n\n#define LN_uniqueMember         \"uniqueMember\"\n#define NID_uniqueMember                888\n#define OBJ_uniqueMember                OBJ_X509,50L\n\n#define LN_houseIdentifier              \"houseIdentifier\"\n#define NID_houseIdentifier             889\n#define OBJ_houseIdentifier             OBJ_X509,51L\n\n#define LN_supportedAlgorithms          \"supportedAlgorithms\"\n#define NID_supportedAlgorithms         890\n#define OBJ_supportedAlgorithms         OBJ_X509,52L\n\n#define LN_deltaRevocationList          \"deltaRevocationList\"\n#define NID_deltaRevocationList         891\n#define OBJ_deltaRevocationList         OBJ_X509,53L\n\n#define SN_dmdName              \"dmdName\"\n#define NID_dmdName             892\n#define OBJ_dmdName             OBJ_X509,54L\n\n#define LN_pseudonym            \"pseudonym\"\n#define NID_pseudonym           510\n#define OBJ_pseudonym           OBJ_X509,65L\n\n#define SN_role         \"role\"\n#define LN_role         \"role\"\n#define NID_role                400\n#define OBJ_role                OBJ_X509,72L\n\n#define SN_X500algorithms               \"X500algorithms\"\n#define LN_X500algorithms               \"directory services - algorithms\"\n#define NID_X500algorithms              378\n#define OBJ_X500algorithms              OBJ_X500,8L\n\n#define SN_rsa          \"RSA\"\n#define LN_rsa          \"rsa\"\n#define NID_rsa         19\n#define OBJ_rsa         OBJ_X500algorithms,1L,1L\n\n#define SN_mdc2WithRSA          \"RSA-MDC2\"\n#define LN_mdc2WithRSA          \"mdc2WithRSA\"\n#define NID_mdc2WithRSA         96\n#define OBJ_mdc2WithRSA         OBJ_X500algorithms,3L,100L\n\n#define SN_mdc2         \"MDC2\"\n#define LN_mdc2         \"mdc2\"\n#define NID_mdc2                95\n#define OBJ_mdc2                OBJ_X500algorithms,3L,101L\n\n#define SN_id_ce                \"id-ce\"\n#define NID_id_ce               81\n#define OBJ_id_ce               OBJ_X500,29L\n\n#define SN_subject_directory_attributes         \"subjectDirectoryAttributes\"\n#define LN_subject_directory_attributes         \"X509v3 Subject Directory Attributes\"\n#define NID_subject_directory_attributes                769\n#define OBJ_subject_directory_attributes                OBJ_id_ce,9L\n\n#define SN_subject_key_identifier               \"subjectKeyIdentifier\"\n#define LN_subject_key_identifier               \"X509v3 Subject Key Identifier\"\n#define NID_subject_key_identifier              82\n#define OBJ_subject_key_identifier              OBJ_id_ce,14L\n\n#define SN_key_usage            \"keyUsage\"\n#define LN_key_usage            \"X509v3 Key Usage\"\n#define NID_key_usage           83\n#define OBJ_key_usage           OBJ_id_ce,15L\n\n#define SN_private_key_usage_period             \"privateKeyUsagePeriod\"\n#define LN_private_key_usage_period             \"X509v3 Private Key Usage Period\"\n#define NID_private_key_usage_period            84\n#define OBJ_private_key_usage_period            OBJ_id_ce,16L\n\n#define SN_subject_alt_name             \"subjectAltName\"\n#define LN_subject_alt_name             \"X509v3 Subject Alternative Name\"\n#define NID_subject_alt_name            85\n#define OBJ_subject_alt_name            OBJ_id_ce,17L\n\n#define SN_issuer_alt_name              \"issuerAltName\"\n#define LN_issuer_alt_name              \"X509v3 Issuer Alternative Name\"\n#define NID_issuer_alt_name             86\n#define OBJ_issuer_alt_name             OBJ_id_ce,18L\n\n#define SN_basic_constraints            \"basicConstraints\"\n#define LN_basic_constraints            \"X509v3 Basic Constraints\"\n#define NID_basic_constraints           87\n#define OBJ_basic_constraints           OBJ_id_ce,19L\n\n#define SN_crl_number           \"crlNumber\"\n#define LN_crl_number           \"X509v3 CRL Number\"\n#define NID_crl_number          88\n#define OBJ_crl_number          OBJ_id_ce,20L\n\n#define SN_crl_reason           \"CRLReason\"\n#define LN_crl_reason           \"X509v3 CRL Reason Code\"\n#define NID_crl_reason          141\n#define OBJ_crl_reason          OBJ_id_ce,21L\n\n#define SN_invalidity_date              \"invalidityDate\"\n#define LN_invalidity_date              \"Invalidity Date\"\n#define NID_invalidity_date             142\n#define OBJ_invalidity_date             OBJ_id_ce,24L\n\n#define SN_delta_crl            \"deltaCRL\"\n#define LN_delta_crl            \"X509v3 Delta CRL Indicator\"\n#define NID_delta_crl           140\n#define OBJ_delta_crl           OBJ_id_ce,27L\n\n#define SN_issuing_distribution_point           \"issuingDistributionPoint\"\n#define LN_issuing_distribution_point           \"X509v3 Issuing Distrubution Point\"\n#define NID_issuing_distribution_point          770\n#define OBJ_issuing_distribution_point          OBJ_id_ce,28L\n\n#define SN_certificate_issuer           \"certificateIssuer\"\n#define LN_certificate_issuer           \"X509v3 Certificate Issuer\"\n#define NID_certificate_issuer          771\n#define OBJ_certificate_issuer          OBJ_id_ce,29L\n\n#define SN_name_constraints             \"nameConstraints\"\n#define LN_name_constraints             \"X509v3 Name Constraints\"\n#define NID_name_constraints            666\n#define OBJ_name_constraints            OBJ_id_ce,30L\n\n#define SN_crl_distribution_points              \"crlDistributionPoints\"\n#define LN_crl_distribution_points              \"X509v3 CRL Distribution Points\"\n#define NID_crl_distribution_points             103\n#define OBJ_crl_distribution_points             OBJ_id_ce,31L\n\n#define SN_certificate_policies         \"certificatePolicies\"\n#define LN_certificate_policies         \"X509v3 Certificate Policies\"\n#define NID_certificate_policies                89\n#define OBJ_certificate_policies                OBJ_id_ce,32L\n\n#define SN_any_policy           \"anyPolicy\"\n#define LN_any_policy           \"X509v3 Any Policy\"\n#define NID_any_policy          746\n#define OBJ_any_policy          OBJ_certificate_policies,0L\n\n#define SN_policy_mappings              \"policyMappings\"\n#define LN_policy_mappings              \"X509v3 Policy Mappings\"\n#define NID_policy_mappings             747\n#define OBJ_policy_mappings             OBJ_id_ce,33L\n\n#define SN_authority_key_identifier             \"authorityKeyIdentifier\"\n#define LN_authority_key_identifier             \"X509v3 Authority Key Identifier\"\n#define NID_authority_key_identifier            90\n#define OBJ_authority_key_identifier            OBJ_id_ce,35L\n\n#define SN_policy_constraints           \"policyConstraints\"\n#define LN_policy_constraints           \"X509v3 Policy Constraints\"\n#define NID_policy_constraints          401\n#define OBJ_policy_constraints          OBJ_id_ce,36L\n\n#define SN_ext_key_usage                \"extendedKeyUsage\"\n#define LN_ext_key_usage                \"X509v3 Extended Key Usage\"\n#define NID_ext_key_usage               126\n#define OBJ_ext_key_usage               OBJ_id_ce,37L\n\n#define SN_freshest_crl         \"freshestCRL\"\n#define LN_freshest_crl         \"X509v3 Freshest CRL\"\n#define NID_freshest_crl                857\n#define OBJ_freshest_crl                OBJ_id_ce,46L\n\n#define SN_inhibit_any_policy           \"inhibitAnyPolicy\"\n#define LN_inhibit_any_policy           \"X509v3 Inhibit Any Policy\"\n#define NID_inhibit_any_policy          748\n#define OBJ_inhibit_any_policy          OBJ_id_ce,54L\n\n#define SN_target_information           \"targetInformation\"\n#define LN_target_information           \"X509v3 AC Targeting\"\n#define NID_target_information          402\n#define OBJ_target_information          OBJ_id_ce,55L\n\n#define SN_no_rev_avail         \"noRevAvail\"\n#define LN_no_rev_avail         \"X509v3 No Revocation Available\"\n#define NID_no_rev_avail                403\n#define OBJ_no_rev_avail                OBJ_id_ce,56L\n\n#define SN_anyExtendedKeyUsage          \"anyExtendedKeyUsage\"\n#define LN_anyExtendedKeyUsage          \"Any Extended Key Usage\"\n#define NID_anyExtendedKeyUsage         910\n#define OBJ_anyExtendedKeyUsage         OBJ_ext_key_usage,0L\n\n#define SN_netscape             \"Netscape\"\n#define LN_netscape             \"Netscape Communications Corp.\"\n#define NID_netscape            57\n#define OBJ_netscape            2L,16L,840L,1L,113730L\n\n#define SN_netscape_cert_extension              \"nsCertExt\"\n#define LN_netscape_cert_extension              \"Netscape Certificate Extension\"\n#define NID_netscape_cert_extension             58\n#define OBJ_netscape_cert_extension             OBJ_netscape,1L\n\n#define SN_netscape_data_type           \"nsDataType\"\n#define LN_netscape_data_type           \"Netscape Data Type\"\n#define NID_netscape_data_type          59\n#define OBJ_netscape_data_type          OBJ_netscape,2L\n\n#define SN_netscape_cert_type           \"nsCertType\"\n#define LN_netscape_cert_type           \"Netscape Cert Type\"\n#define NID_netscape_cert_type          71\n#define OBJ_netscape_cert_type          OBJ_netscape_cert_extension,1L\n\n#define SN_netscape_base_url            \"nsBaseUrl\"\n#define LN_netscape_base_url            \"Netscape Base Url\"\n#define NID_netscape_base_url           72\n#define OBJ_netscape_base_url           OBJ_netscape_cert_extension,2L\n\n#define SN_netscape_revocation_url              \"nsRevocationUrl\"\n#define LN_netscape_revocation_url              \"Netscape Revocation Url\"\n#define NID_netscape_revocation_url             73\n#define OBJ_netscape_revocation_url             OBJ_netscape_cert_extension,3L\n\n#define SN_netscape_ca_revocation_url           \"nsCaRevocationUrl\"\n#define LN_netscape_ca_revocation_url           \"Netscape CA Revocation Url\"\n#define NID_netscape_ca_revocation_url          74\n#define OBJ_netscape_ca_revocation_url          OBJ_netscape_cert_extension,4L\n\n#define SN_netscape_renewal_url         \"nsRenewalUrl\"\n#define LN_netscape_renewal_url         \"Netscape Renewal Url\"\n#define NID_netscape_renewal_url                75\n#define OBJ_netscape_renewal_url                OBJ_netscape_cert_extension,7L\n\n#define SN_netscape_ca_policy_url               \"nsCaPolicyUrl\"\n#define LN_netscape_ca_policy_url               \"Netscape CA Policy Url\"\n#define NID_netscape_ca_policy_url              76\n#define OBJ_netscape_ca_policy_url              OBJ_netscape_cert_extension,8L\n\n#define SN_netscape_ssl_server_name             \"nsSslServerName\"\n#define LN_netscape_ssl_server_name             \"Netscape SSL Server Name\"\n#define NID_netscape_ssl_server_name            77\n#define OBJ_netscape_ssl_server_name            OBJ_netscape_cert_extension,12L\n\n#define SN_netscape_comment             \"nsComment\"\n#define LN_netscape_comment             \"Netscape Comment\"\n#define NID_netscape_comment            78\n#define OBJ_netscape_comment            OBJ_netscape_cert_extension,13L\n\n#define SN_netscape_cert_sequence               \"nsCertSequence\"\n#define LN_netscape_cert_sequence               \"Netscape Certificate Sequence\"\n#define NID_netscape_cert_sequence              79\n#define OBJ_netscape_cert_sequence              OBJ_netscape_data_type,5L\n\n#define SN_ns_sgc               \"nsSGC\"\n#define LN_ns_sgc               \"Netscape Server Gated Crypto\"\n#define NID_ns_sgc              139\n#define OBJ_ns_sgc              OBJ_netscape,4L,1L\n\n#define SN_org          \"ORG\"\n#define LN_org          \"org\"\n#define NID_org         379\n#define OBJ_org         OBJ_iso,3L\n\n#define SN_dod          \"DOD\"\n#define LN_dod          \"dod\"\n#define NID_dod         380\n#define OBJ_dod         OBJ_org,6L\n\n#define SN_iana         \"IANA\"\n#define LN_iana         \"iana\"\n#define NID_iana                381\n#define OBJ_iana                OBJ_dod,1L\n\n#define OBJ_internet            OBJ_iana\n\n#define SN_Directory            \"directory\"\n#define LN_Directory            \"Directory\"\n#define NID_Directory           382\n#define OBJ_Directory           OBJ_internet,1L\n\n#define SN_Management           \"mgmt\"\n#define LN_Management           \"Management\"\n#define NID_Management          383\n#define OBJ_Management          OBJ_internet,2L\n\n#define SN_Experimental         \"experimental\"\n#define LN_Experimental         \"Experimental\"\n#define NID_Experimental                384\n#define OBJ_Experimental                OBJ_internet,3L\n\n#define SN_Private              \"private\"\n#define LN_Private              \"Private\"\n#define NID_Private             385\n#define OBJ_Private             OBJ_internet,4L\n\n#define SN_Security             \"security\"\n#define LN_Security             \"Security\"\n#define NID_Security            386\n#define OBJ_Security            OBJ_internet,5L\n\n#define SN_SNMPv2               \"snmpv2\"\n#define LN_SNMPv2               \"SNMPv2\"\n#define NID_SNMPv2              387\n#define OBJ_SNMPv2              OBJ_internet,6L\n\n#define LN_Mail         \"Mail\"\n#define NID_Mail                388\n#define OBJ_Mail                OBJ_internet,7L\n\n#define SN_Enterprises          \"enterprises\"\n#define LN_Enterprises          \"Enterprises\"\n#define NID_Enterprises         389\n#define OBJ_Enterprises         OBJ_Private,1L\n\n#define SN_dcObject             \"dcobject\"\n#define LN_dcObject             \"dcObject\"\n#define NID_dcObject            390\n#define OBJ_dcObject            OBJ_Enterprises,1466L,344L\n\n#define SN_mime_mhs             \"mime-mhs\"\n#define LN_mime_mhs             \"MIME MHS\"\n#define NID_mime_mhs            504\n#define OBJ_mime_mhs            OBJ_Mail,1L\n\n#define SN_mime_mhs_headings            \"mime-mhs-headings\"\n#define LN_mime_mhs_headings            \"mime-mhs-headings\"\n#define NID_mime_mhs_headings           505\n#define OBJ_mime_mhs_headings           OBJ_mime_mhs,1L\n\n#define SN_mime_mhs_bodies              \"mime-mhs-bodies\"\n#define LN_mime_mhs_bodies              \"mime-mhs-bodies\"\n#define NID_mime_mhs_bodies             506\n#define OBJ_mime_mhs_bodies             OBJ_mime_mhs,2L\n\n#define SN_id_hex_partial_message               \"id-hex-partial-message\"\n#define LN_id_hex_partial_message               \"id-hex-partial-message\"\n#define NID_id_hex_partial_message              507\n#define OBJ_id_hex_partial_message              OBJ_mime_mhs_headings,1L\n\n#define SN_id_hex_multipart_message             \"id-hex-multipart-message\"\n#define LN_id_hex_multipart_message             \"id-hex-multipart-message\"\n#define NID_id_hex_multipart_message            508\n#define OBJ_id_hex_multipart_message            OBJ_mime_mhs_headings,2L\n\n#define SN_rle_compression              \"RLE\"\n#define LN_rle_compression              \"run length compression\"\n#define NID_rle_compression             124\n#define OBJ_rle_compression             1L,1L,1L,1L,666L,1L\n\n#define SN_zlib_compression             \"ZLIB\"\n#define LN_zlib_compression             \"zlib compression\"\n#define NID_zlib_compression            125\n#define OBJ_zlib_compression            OBJ_id_smime_alg,8L\n\n#define OBJ_csor                2L,16L,840L,1L,101L,3L\n\n#define OBJ_nistAlgorithms              OBJ_csor,4L\n\n#define OBJ_aes         OBJ_nistAlgorithms,1L\n\n#define SN_aes_128_ecb          \"AES-128-ECB\"\n#define LN_aes_128_ecb          \"aes-128-ecb\"\n#define NID_aes_128_ecb         418\n#define OBJ_aes_128_ecb         OBJ_aes,1L\n\n#define SN_aes_128_cbc          \"AES-128-CBC\"\n#define LN_aes_128_cbc          \"aes-128-cbc\"\n#define NID_aes_128_cbc         419\n#define OBJ_aes_128_cbc         OBJ_aes,2L\n\n#define SN_aes_128_ofb128               \"AES-128-OFB\"\n#define LN_aes_128_ofb128               \"aes-128-ofb\"\n#define NID_aes_128_ofb128              420\n#define OBJ_aes_128_ofb128              OBJ_aes,3L\n\n#define SN_aes_128_cfb128               \"AES-128-CFB\"\n#define LN_aes_128_cfb128               \"aes-128-cfb\"\n#define NID_aes_128_cfb128              421\n#define OBJ_aes_128_cfb128              OBJ_aes,4L\n\n#define SN_id_aes128_wrap               \"id-aes128-wrap\"\n#define NID_id_aes128_wrap              788\n#define OBJ_id_aes128_wrap              OBJ_aes,5L\n\n#define SN_aes_128_gcm          \"id-aes128-GCM\"\n#define LN_aes_128_gcm          \"aes-128-gcm\"\n#define NID_aes_128_gcm         895\n#define OBJ_aes_128_gcm         OBJ_aes,6L\n\n#define SN_aes_128_ccm          \"id-aes128-CCM\"\n#define LN_aes_128_ccm          \"aes-128-ccm\"\n#define NID_aes_128_ccm         896\n#define OBJ_aes_128_ccm         OBJ_aes,7L\n\n#define SN_id_aes128_wrap_pad           \"id-aes128-wrap-pad\"\n#define NID_id_aes128_wrap_pad          897\n#define OBJ_id_aes128_wrap_pad          OBJ_aes,8L\n\n#define SN_aes_192_ecb          \"AES-192-ECB\"\n#define LN_aes_192_ecb          \"aes-192-ecb\"\n#define NID_aes_192_ecb         422\n#define OBJ_aes_192_ecb         OBJ_aes,21L\n\n#define SN_aes_192_cbc          \"AES-192-CBC\"\n#define LN_aes_192_cbc          \"aes-192-cbc\"\n#define NID_aes_192_cbc         423\n#define OBJ_aes_192_cbc         OBJ_aes,22L\n\n#define SN_aes_192_ofb128               \"AES-192-OFB\"\n#define LN_aes_192_ofb128               \"aes-192-ofb\"\n#define NID_aes_192_ofb128              424\n#define OBJ_aes_192_ofb128              OBJ_aes,23L\n\n#define SN_aes_192_cfb128               \"AES-192-CFB\"\n#define LN_aes_192_cfb128               \"aes-192-cfb\"\n#define NID_aes_192_cfb128              425\n#define OBJ_aes_192_cfb128              OBJ_aes,24L\n\n#define SN_id_aes192_wrap               \"id-aes192-wrap\"\n#define NID_id_aes192_wrap              789\n#define OBJ_id_aes192_wrap              OBJ_aes,25L\n\n#define SN_aes_192_gcm          \"id-aes192-GCM\"\n#define LN_aes_192_gcm          \"aes-192-gcm\"\n#define NID_aes_192_gcm         898\n#define OBJ_aes_192_gcm         OBJ_aes,26L\n\n#define SN_aes_192_ccm          \"id-aes192-CCM\"\n#define LN_aes_192_ccm          \"aes-192-ccm\"\n#define NID_aes_192_ccm         899\n#define OBJ_aes_192_ccm         OBJ_aes,27L\n\n#define SN_id_aes192_wrap_pad           \"id-aes192-wrap-pad\"\n#define NID_id_aes192_wrap_pad          900\n#define OBJ_id_aes192_wrap_pad          OBJ_aes,28L\n\n#define SN_aes_256_ecb          \"AES-256-ECB\"\n#define LN_aes_256_ecb          \"aes-256-ecb\"\n#define NID_aes_256_ecb         426\n#define OBJ_aes_256_ecb         OBJ_aes,41L\n\n#define SN_aes_256_cbc          \"AES-256-CBC\"\n#define LN_aes_256_cbc          \"aes-256-cbc\"\n#define NID_aes_256_cbc         427\n#define OBJ_aes_256_cbc         OBJ_aes,42L\n\n#define SN_aes_256_ofb128               \"AES-256-OFB\"\n#define LN_aes_256_ofb128               \"aes-256-ofb\"\n#define NID_aes_256_ofb128              428\n#define OBJ_aes_256_ofb128              OBJ_aes,43L\n\n#define SN_aes_256_cfb128               \"AES-256-CFB\"\n#define LN_aes_256_cfb128               \"aes-256-cfb\"\n#define NID_aes_256_cfb128              429\n#define OBJ_aes_256_cfb128              OBJ_aes,44L\n\n#define SN_id_aes256_wrap               \"id-aes256-wrap\"\n#define NID_id_aes256_wrap              790\n#define OBJ_id_aes256_wrap              OBJ_aes,45L\n\n#define SN_aes_256_gcm          \"id-aes256-GCM\"\n#define LN_aes_256_gcm          \"aes-256-gcm\"\n#define NID_aes_256_gcm         901\n#define OBJ_aes_256_gcm         OBJ_aes,46L\n\n#define SN_aes_256_ccm          \"id-aes256-CCM\"\n#define LN_aes_256_ccm          \"aes-256-ccm\"\n#define NID_aes_256_ccm         902\n#define OBJ_aes_256_ccm         OBJ_aes,47L\n\n#define SN_id_aes256_wrap_pad           \"id-aes256-wrap-pad\"\n#define NID_id_aes256_wrap_pad          903\n#define OBJ_id_aes256_wrap_pad          OBJ_aes,48L\n\n#define SN_aes_128_cfb1         \"AES-128-CFB1\"\n#define LN_aes_128_cfb1         \"aes-128-cfb1\"\n#define NID_aes_128_cfb1                650\n\n#define SN_aes_192_cfb1         \"AES-192-CFB1\"\n#define LN_aes_192_cfb1         \"aes-192-cfb1\"\n#define NID_aes_192_cfb1                651\n\n#define SN_aes_256_cfb1         \"AES-256-CFB1\"\n#define LN_aes_256_cfb1         \"aes-256-cfb1\"\n#define NID_aes_256_cfb1                652\n\n#define SN_aes_128_cfb8         \"AES-128-CFB8\"\n#define LN_aes_128_cfb8         \"aes-128-cfb8\"\n#define NID_aes_128_cfb8                653\n\n#define SN_aes_192_cfb8         \"AES-192-CFB8\"\n#define LN_aes_192_cfb8         \"aes-192-cfb8\"\n#define NID_aes_192_cfb8                654\n\n#define SN_aes_256_cfb8         \"AES-256-CFB8\"\n#define LN_aes_256_cfb8         \"aes-256-cfb8\"\n#define NID_aes_256_cfb8                655\n\n#define SN_aes_128_ctr          \"AES-128-CTR\"\n#define LN_aes_128_ctr          \"aes-128-ctr\"\n#define NID_aes_128_ctr         904\n\n#define SN_aes_192_ctr          \"AES-192-CTR\"\n#define LN_aes_192_ctr          \"aes-192-ctr\"\n#define NID_aes_192_ctr         905\n\n#define SN_aes_256_ctr          \"AES-256-CTR\"\n#define LN_aes_256_ctr          \"aes-256-ctr\"\n#define NID_aes_256_ctr         906\n\n#define SN_aes_128_xts          \"AES-128-XTS\"\n#define LN_aes_128_xts          \"aes-128-xts\"\n#define NID_aes_128_xts         913\n\n#define SN_aes_256_xts          \"AES-256-XTS\"\n#define LN_aes_256_xts          \"aes-256-xts\"\n#define NID_aes_256_xts         914\n\n#define SN_des_cfb1             \"DES-CFB1\"\n#define LN_des_cfb1             \"des-cfb1\"\n#define NID_des_cfb1            656\n\n#define SN_des_cfb8             \"DES-CFB8\"\n#define LN_des_cfb8             \"des-cfb8\"\n#define NID_des_cfb8            657\n\n#define SN_des_ede3_cfb1                \"DES-EDE3-CFB1\"\n#define LN_des_ede3_cfb1                \"des-ede3-cfb1\"\n#define NID_des_ede3_cfb1               658\n\n#define SN_des_ede3_cfb8                \"DES-EDE3-CFB8\"\n#define LN_des_ede3_cfb8                \"des-ede3-cfb8\"\n#define NID_des_ede3_cfb8               659\n\n#define OBJ_nist_hashalgs               OBJ_nistAlgorithms,2L\n\n#define SN_sha256               \"SHA256\"\n#define LN_sha256               \"sha256\"\n#define NID_sha256              672\n#define OBJ_sha256              OBJ_nist_hashalgs,1L\n\n#define SN_sha384               \"SHA384\"\n#define LN_sha384               \"sha384\"\n#define NID_sha384              673\n#define OBJ_sha384              OBJ_nist_hashalgs,2L\n\n#define SN_sha512               \"SHA512\"\n#define LN_sha512               \"sha512\"\n#define NID_sha512              674\n#define OBJ_sha512              OBJ_nist_hashalgs,3L\n\n#define SN_sha224               \"SHA224\"\n#define LN_sha224               \"sha224\"\n#define NID_sha224              675\n#define OBJ_sha224              OBJ_nist_hashalgs,4L\n\n#define OBJ_dsa_with_sha2               OBJ_nistAlgorithms,3L\n\n#define SN_dsa_with_SHA224              \"dsa_with_SHA224\"\n#define NID_dsa_with_SHA224             802\n#define OBJ_dsa_with_SHA224             OBJ_dsa_with_sha2,1L\n\n#define SN_dsa_with_SHA256              \"dsa_with_SHA256\"\n#define NID_dsa_with_SHA256             803\n#define OBJ_dsa_with_SHA256             OBJ_dsa_with_sha2,2L\n\n#define SN_hold_instruction_code                \"holdInstructionCode\"\n#define LN_hold_instruction_code                \"Hold Instruction Code\"\n#define NID_hold_instruction_code               430\n#define OBJ_hold_instruction_code               OBJ_id_ce,23L\n\n#define OBJ_holdInstruction             OBJ_X9_57,2L\n\n#define SN_hold_instruction_none                \"holdInstructionNone\"\n#define LN_hold_instruction_none                \"Hold Instruction None\"\n#define NID_hold_instruction_none               431\n#define OBJ_hold_instruction_none               OBJ_holdInstruction,1L\n\n#define SN_hold_instruction_call_issuer         \"holdInstructionCallIssuer\"\n#define LN_hold_instruction_call_issuer         \"Hold Instruction Call Issuer\"\n#define NID_hold_instruction_call_issuer                432\n#define OBJ_hold_instruction_call_issuer                OBJ_holdInstruction,2L\n\n#define SN_hold_instruction_reject              \"holdInstructionReject\"\n#define LN_hold_instruction_reject              \"Hold Instruction Reject\"\n#define NID_hold_instruction_reject             433\n#define OBJ_hold_instruction_reject             OBJ_holdInstruction,3L\n\n#define SN_data         \"data\"\n#define NID_data                434\n#define OBJ_data                OBJ_itu_t,9L\n\n#define SN_pss          \"pss\"\n#define NID_pss         435\n#define OBJ_pss         OBJ_data,2342L\n\n#define SN_ucl          \"ucl\"\n#define NID_ucl         436\n#define OBJ_ucl         OBJ_pss,19200300L\n\n#define SN_pilot                \"pilot\"\n#define NID_pilot               437\n#define OBJ_pilot               OBJ_ucl,100L\n\n#define LN_pilotAttributeType           \"pilotAttributeType\"\n#define NID_pilotAttributeType          438\n#define OBJ_pilotAttributeType          OBJ_pilot,1L\n\n#define LN_pilotAttributeSyntax         \"pilotAttributeSyntax\"\n#define NID_pilotAttributeSyntax                439\n#define OBJ_pilotAttributeSyntax                OBJ_pilot,3L\n\n#define LN_pilotObjectClass             \"pilotObjectClass\"\n#define NID_pilotObjectClass            440\n#define OBJ_pilotObjectClass            OBJ_pilot,4L\n\n#define LN_pilotGroups          \"pilotGroups\"\n#define NID_pilotGroups         441\n#define OBJ_pilotGroups         OBJ_pilot,10L\n\n#define LN_iA5StringSyntax              \"iA5StringSyntax\"\n#define NID_iA5StringSyntax             442\n#define OBJ_iA5StringSyntax             OBJ_pilotAttributeSyntax,4L\n\n#define LN_caseIgnoreIA5StringSyntax            \"caseIgnoreIA5StringSyntax\"\n#define NID_caseIgnoreIA5StringSyntax           443\n#define OBJ_caseIgnoreIA5StringSyntax           OBJ_pilotAttributeSyntax,5L\n\n#define LN_pilotObject          \"pilotObject\"\n#define NID_pilotObject         444\n#define OBJ_pilotObject         OBJ_pilotObjectClass,3L\n\n#define LN_pilotPerson          \"pilotPerson\"\n#define NID_pilotPerson         445\n#define OBJ_pilotPerson         OBJ_pilotObjectClass,4L\n\n#define SN_account              \"account\"\n#define NID_account             446\n#define OBJ_account             OBJ_pilotObjectClass,5L\n\n#define SN_document             \"document\"\n#define NID_document            447\n#define OBJ_document            OBJ_pilotObjectClass,6L\n\n#define SN_room         \"room\"\n#define NID_room                448\n#define OBJ_room                OBJ_pilotObjectClass,7L\n\n#define LN_documentSeries               \"documentSeries\"\n#define NID_documentSeries              449\n#define OBJ_documentSeries              OBJ_pilotObjectClass,9L\n\n#define SN_Domain               \"domain\"\n#define LN_Domain               \"Domain\"\n#define NID_Domain              392\n#define OBJ_Domain              OBJ_pilotObjectClass,13L\n\n#define LN_rFC822localPart              \"rFC822localPart\"\n#define NID_rFC822localPart             450\n#define OBJ_rFC822localPart             OBJ_pilotObjectClass,14L\n\n#define LN_dNSDomain            \"dNSDomain\"\n#define NID_dNSDomain           451\n#define OBJ_dNSDomain           OBJ_pilotObjectClass,15L\n\n#define LN_domainRelatedObject          \"domainRelatedObject\"\n#define NID_domainRelatedObject         452\n#define OBJ_domainRelatedObject         OBJ_pilotObjectClass,17L\n\n#define LN_friendlyCountry              \"friendlyCountry\"\n#define NID_friendlyCountry             453\n#define OBJ_friendlyCountry             OBJ_pilotObjectClass,18L\n\n#define LN_simpleSecurityObject         \"simpleSecurityObject\"\n#define NID_simpleSecurityObject                454\n#define OBJ_simpleSecurityObject                OBJ_pilotObjectClass,19L\n\n#define LN_pilotOrganization            \"pilotOrganization\"\n#define NID_pilotOrganization           455\n#define OBJ_pilotOrganization           OBJ_pilotObjectClass,20L\n\n#define LN_pilotDSA             \"pilotDSA\"\n#define NID_pilotDSA            456\n#define OBJ_pilotDSA            OBJ_pilotObjectClass,21L\n\n#define LN_qualityLabelledData          \"qualityLabelledData\"\n#define NID_qualityLabelledData         457\n#define OBJ_qualityLabelledData         OBJ_pilotObjectClass,22L\n\n#define SN_userId               \"UID\"\n#define LN_userId               \"userId\"\n#define NID_userId              458\n#define OBJ_userId              OBJ_pilotAttributeType,1L\n\n#define LN_textEncodedORAddress         \"textEncodedORAddress\"\n#define NID_textEncodedORAddress                459\n#define OBJ_textEncodedORAddress                OBJ_pilotAttributeType,2L\n\n#define SN_rfc822Mailbox                \"mail\"\n#define LN_rfc822Mailbox                \"rfc822Mailbox\"\n#define NID_rfc822Mailbox               460\n#define OBJ_rfc822Mailbox               OBJ_pilotAttributeType,3L\n\n#define SN_info         \"info\"\n#define NID_info                461\n#define OBJ_info                OBJ_pilotAttributeType,4L\n\n#define LN_favouriteDrink               \"favouriteDrink\"\n#define NID_favouriteDrink              462\n#define OBJ_favouriteDrink              OBJ_pilotAttributeType,5L\n\n#define LN_roomNumber           \"roomNumber\"\n#define NID_roomNumber          463\n#define OBJ_roomNumber          OBJ_pilotAttributeType,6L\n\n#define SN_photo                \"photo\"\n#define NID_photo               464\n#define OBJ_photo               OBJ_pilotAttributeType,7L\n\n#define LN_userClass            \"userClass\"\n#define NID_userClass           465\n#define OBJ_userClass           OBJ_pilotAttributeType,8L\n\n#define SN_host         \"host\"\n#define NID_host                466\n#define OBJ_host                OBJ_pilotAttributeType,9L\n\n#define SN_manager              \"manager\"\n#define NID_manager             467\n#define OBJ_manager             OBJ_pilotAttributeType,10L\n\n#define LN_documentIdentifier           \"documentIdentifier\"\n#define NID_documentIdentifier          468\n#define OBJ_documentIdentifier          OBJ_pilotAttributeType,11L\n\n#define LN_documentTitle                \"documentTitle\"\n#define NID_documentTitle               469\n#define OBJ_documentTitle               OBJ_pilotAttributeType,12L\n\n#define LN_documentVersion              \"documentVersion\"\n#define NID_documentVersion             470\n#define OBJ_documentVersion             OBJ_pilotAttributeType,13L\n\n#define LN_documentAuthor               \"documentAuthor\"\n#define NID_documentAuthor              471\n#define OBJ_documentAuthor              OBJ_pilotAttributeType,14L\n\n#define LN_documentLocation             \"documentLocation\"\n#define NID_documentLocation            472\n#define OBJ_documentLocation            OBJ_pilotAttributeType,15L\n\n#define LN_homeTelephoneNumber          \"homeTelephoneNumber\"\n#define NID_homeTelephoneNumber         473\n#define OBJ_homeTelephoneNumber         OBJ_pilotAttributeType,20L\n\n#define SN_secretary            \"secretary\"\n#define NID_secretary           474\n#define OBJ_secretary           OBJ_pilotAttributeType,21L\n\n#define LN_otherMailbox         \"otherMailbox\"\n#define NID_otherMailbox                475\n#define OBJ_otherMailbox                OBJ_pilotAttributeType,22L\n\n#define LN_lastModifiedTime             \"lastModifiedTime\"\n#define NID_lastModifiedTime            476\n#define OBJ_lastModifiedTime            OBJ_pilotAttributeType,23L\n\n#define LN_lastModifiedBy               \"lastModifiedBy\"\n#define NID_lastModifiedBy              477\n#define OBJ_lastModifiedBy              OBJ_pilotAttributeType,24L\n\n#define SN_domainComponent              \"DC\"\n#define LN_domainComponent              \"domainComponent\"\n#define NID_domainComponent             391\n#define OBJ_domainComponent             OBJ_pilotAttributeType,25L\n\n#define LN_aRecord              \"aRecord\"\n#define NID_aRecord             478\n#define OBJ_aRecord             OBJ_pilotAttributeType,26L\n\n#define LN_pilotAttributeType27         \"pilotAttributeType27\"\n#define NID_pilotAttributeType27                479\n#define OBJ_pilotAttributeType27                OBJ_pilotAttributeType,27L\n\n#define LN_mXRecord             \"mXRecord\"\n#define NID_mXRecord            480\n#define OBJ_mXRecord            OBJ_pilotAttributeType,28L\n\n#define LN_nSRecord             \"nSRecord\"\n#define NID_nSRecord            481\n#define OBJ_nSRecord            OBJ_pilotAttributeType,29L\n\n#define LN_sOARecord            \"sOARecord\"\n#define NID_sOARecord           482\n#define OBJ_sOARecord           OBJ_pilotAttributeType,30L\n\n#define LN_cNAMERecord          \"cNAMERecord\"\n#define NID_cNAMERecord         483\n#define OBJ_cNAMERecord         OBJ_pilotAttributeType,31L\n\n#define LN_associatedDomain             \"associatedDomain\"\n#define NID_associatedDomain            484\n#define OBJ_associatedDomain            OBJ_pilotAttributeType,37L\n\n#define LN_associatedName               \"associatedName\"\n#define NID_associatedName              485\n#define OBJ_associatedName              OBJ_pilotAttributeType,38L\n\n#define LN_homePostalAddress            \"homePostalAddress\"\n#define NID_homePostalAddress           486\n#define OBJ_homePostalAddress           OBJ_pilotAttributeType,39L\n\n#define LN_personalTitle                \"personalTitle\"\n#define NID_personalTitle               487\n#define OBJ_personalTitle               OBJ_pilotAttributeType,40L\n\n#define LN_mobileTelephoneNumber                \"mobileTelephoneNumber\"\n#define NID_mobileTelephoneNumber               488\n#define OBJ_mobileTelephoneNumber               OBJ_pilotAttributeType,41L\n\n#define LN_pagerTelephoneNumber         \"pagerTelephoneNumber\"\n#define NID_pagerTelephoneNumber                489\n#define OBJ_pagerTelephoneNumber                OBJ_pilotAttributeType,42L\n\n#define LN_friendlyCountryName          \"friendlyCountryName\"\n#define NID_friendlyCountryName         490\n#define OBJ_friendlyCountryName         OBJ_pilotAttributeType,43L\n\n#define LN_organizationalStatus         \"organizationalStatus\"\n#define NID_organizationalStatus                491\n#define OBJ_organizationalStatus                OBJ_pilotAttributeType,45L\n\n#define LN_janetMailbox         \"janetMailbox\"\n#define NID_janetMailbox                492\n#define OBJ_janetMailbox                OBJ_pilotAttributeType,46L\n\n#define LN_mailPreferenceOption         \"mailPreferenceOption\"\n#define NID_mailPreferenceOption                493\n#define OBJ_mailPreferenceOption                OBJ_pilotAttributeType,47L\n\n#define LN_buildingName         \"buildingName\"\n#define NID_buildingName                494\n#define OBJ_buildingName                OBJ_pilotAttributeType,48L\n\n#define LN_dSAQuality           \"dSAQuality\"\n#define NID_dSAQuality          495\n#define OBJ_dSAQuality          OBJ_pilotAttributeType,49L\n\n#define LN_singleLevelQuality           \"singleLevelQuality\"\n#define NID_singleLevelQuality          496\n#define OBJ_singleLevelQuality          OBJ_pilotAttributeType,50L\n\n#define LN_subtreeMinimumQuality                \"subtreeMinimumQuality\"\n#define NID_subtreeMinimumQuality               497\n#define OBJ_subtreeMinimumQuality               OBJ_pilotAttributeType,51L\n\n#define LN_subtreeMaximumQuality                \"subtreeMaximumQuality\"\n#define NID_subtreeMaximumQuality               498\n#define OBJ_subtreeMaximumQuality               OBJ_pilotAttributeType,52L\n\n#define LN_personalSignature            \"personalSignature\"\n#define NID_personalSignature           499\n#define OBJ_personalSignature           OBJ_pilotAttributeType,53L\n\n#define LN_dITRedirect          \"dITRedirect\"\n#define NID_dITRedirect         500\n#define OBJ_dITRedirect         OBJ_pilotAttributeType,54L\n\n#define SN_audio                \"audio\"\n#define NID_audio               501\n#define OBJ_audio               OBJ_pilotAttributeType,55L\n\n#define LN_documentPublisher            \"documentPublisher\"\n#define NID_documentPublisher           502\n#define OBJ_documentPublisher           OBJ_pilotAttributeType,56L\n\n#define SN_id_set               \"id-set\"\n#define LN_id_set               \"Secure Electronic Transactions\"\n#define NID_id_set              512\n#define OBJ_id_set              OBJ_international_organizations,42L\n\n#define SN_set_ctype            \"set-ctype\"\n#define LN_set_ctype            \"content types\"\n#define NID_set_ctype           513\n#define OBJ_set_ctype           OBJ_id_set,0L\n\n#define SN_set_msgExt           \"set-msgExt\"\n#define LN_set_msgExt           \"message extensions\"\n#define NID_set_msgExt          514\n#define OBJ_set_msgExt          OBJ_id_set,1L\n\n#define SN_set_attr             \"set-attr\"\n#define NID_set_attr            515\n#define OBJ_set_attr            OBJ_id_set,3L\n\n#define SN_set_policy           \"set-policy\"\n#define NID_set_policy          516\n#define OBJ_set_policy          OBJ_id_set,5L\n\n#define SN_set_certExt          \"set-certExt\"\n#define LN_set_certExt          \"certificate extensions\"\n#define NID_set_certExt         517\n#define OBJ_set_certExt         OBJ_id_set,7L\n\n#define SN_set_brand            \"set-brand\"\n#define NID_set_brand           518\n#define OBJ_set_brand           OBJ_id_set,8L\n\n#define SN_setct_PANData                \"setct-PANData\"\n#define NID_setct_PANData               519\n#define OBJ_setct_PANData               OBJ_set_ctype,0L\n\n#define SN_setct_PANToken               \"setct-PANToken\"\n#define NID_setct_PANToken              520\n#define OBJ_setct_PANToken              OBJ_set_ctype,1L\n\n#define SN_setct_PANOnly                \"setct-PANOnly\"\n#define NID_setct_PANOnly               521\n#define OBJ_setct_PANOnly               OBJ_set_ctype,2L\n\n#define SN_setct_OIData         \"setct-OIData\"\n#define NID_setct_OIData                522\n#define OBJ_setct_OIData                OBJ_set_ctype,3L\n\n#define SN_setct_PI             \"setct-PI\"\n#define NID_setct_PI            523\n#define OBJ_setct_PI            OBJ_set_ctype,4L\n\n#define SN_setct_PIData         \"setct-PIData\"\n#define NID_setct_PIData                524\n#define OBJ_setct_PIData                OBJ_set_ctype,5L\n\n#define SN_setct_PIDataUnsigned         \"setct-PIDataUnsigned\"\n#define NID_setct_PIDataUnsigned                525\n#define OBJ_setct_PIDataUnsigned                OBJ_set_ctype,6L\n\n#define SN_setct_HODInput               \"setct-HODInput\"\n#define NID_setct_HODInput              526\n#define OBJ_setct_HODInput              OBJ_set_ctype,7L\n\n#define SN_setct_AuthResBaggage         \"setct-AuthResBaggage\"\n#define NID_setct_AuthResBaggage                527\n#define OBJ_setct_AuthResBaggage                OBJ_set_ctype,8L\n\n#define SN_setct_AuthRevReqBaggage              \"setct-AuthRevReqBaggage\"\n#define NID_setct_AuthRevReqBaggage             528\n#define OBJ_setct_AuthRevReqBaggage             OBJ_set_ctype,9L\n\n#define SN_setct_AuthRevResBaggage              \"setct-AuthRevResBaggage\"\n#define NID_setct_AuthRevResBaggage             529\n#define OBJ_setct_AuthRevResBaggage             OBJ_set_ctype,10L\n\n#define SN_setct_CapTokenSeq            \"setct-CapTokenSeq\"\n#define NID_setct_CapTokenSeq           530\n#define OBJ_setct_CapTokenSeq           OBJ_set_ctype,11L\n\n#define SN_setct_PInitResData           \"setct-PInitResData\"\n#define NID_setct_PInitResData          531\n#define OBJ_setct_PInitResData          OBJ_set_ctype,12L\n\n#define SN_setct_PI_TBS         \"setct-PI-TBS\"\n#define NID_setct_PI_TBS                532\n#define OBJ_setct_PI_TBS                OBJ_set_ctype,13L\n\n#define SN_setct_PResData               \"setct-PResData\"\n#define NID_setct_PResData              533\n#define OBJ_setct_PResData              OBJ_set_ctype,14L\n\n#define SN_setct_AuthReqTBS             \"setct-AuthReqTBS\"\n#define NID_setct_AuthReqTBS            534\n#define OBJ_setct_AuthReqTBS            OBJ_set_ctype,16L\n\n#define SN_setct_AuthResTBS             \"setct-AuthResTBS\"\n#define NID_setct_AuthResTBS            535\n#define OBJ_setct_AuthResTBS            OBJ_set_ctype,17L\n\n#define SN_setct_AuthResTBSX            \"setct-AuthResTBSX\"\n#define NID_setct_AuthResTBSX           536\n#define OBJ_setct_AuthResTBSX           OBJ_set_ctype,18L\n\n#define SN_setct_AuthTokenTBS           \"setct-AuthTokenTBS\"\n#define NID_setct_AuthTokenTBS          537\n#define OBJ_setct_AuthTokenTBS          OBJ_set_ctype,19L\n\n#define SN_setct_CapTokenData           \"setct-CapTokenData\"\n#define NID_setct_CapTokenData          538\n#define OBJ_setct_CapTokenData          OBJ_set_ctype,20L\n\n#define SN_setct_CapTokenTBS            \"setct-CapTokenTBS\"\n#define NID_setct_CapTokenTBS           539\n#define OBJ_setct_CapTokenTBS           OBJ_set_ctype,21L\n\n#define SN_setct_AcqCardCodeMsg         \"setct-AcqCardCodeMsg\"\n#define NID_setct_AcqCardCodeMsg                540\n#define OBJ_setct_AcqCardCodeMsg                OBJ_set_ctype,22L\n\n#define SN_setct_AuthRevReqTBS          \"setct-AuthRevReqTBS\"\n#define NID_setct_AuthRevReqTBS         541\n#define OBJ_setct_AuthRevReqTBS         OBJ_set_ctype,23L\n\n#define SN_setct_AuthRevResData         \"setct-AuthRevResData\"\n#define NID_setct_AuthRevResData                542\n#define OBJ_setct_AuthRevResData                OBJ_set_ctype,24L\n\n#define SN_setct_AuthRevResTBS          \"setct-AuthRevResTBS\"\n#define NID_setct_AuthRevResTBS         543\n#define OBJ_setct_AuthRevResTBS         OBJ_set_ctype,25L\n\n#define SN_setct_CapReqTBS              \"setct-CapReqTBS\"\n#define NID_setct_CapReqTBS             544\n#define OBJ_setct_CapReqTBS             OBJ_set_ctype,26L\n\n#define SN_setct_CapReqTBSX             \"setct-CapReqTBSX\"\n#define NID_setct_CapReqTBSX            545\n#define OBJ_setct_CapReqTBSX            OBJ_set_ctype,27L\n\n#define SN_setct_CapResData             \"setct-CapResData\"\n#define NID_setct_CapResData            546\n#define OBJ_setct_CapResData            OBJ_set_ctype,28L\n\n#define SN_setct_CapRevReqTBS           \"setct-CapRevReqTBS\"\n#define NID_setct_CapRevReqTBS          547\n#define OBJ_setct_CapRevReqTBS          OBJ_set_ctype,29L\n\n#define SN_setct_CapRevReqTBSX          \"setct-CapRevReqTBSX\"\n#define NID_setct_CapRevReqTBSX         548\n#define OBJ_setct_CapRevReqTBSX         OBJ_set_ctype,30L\n\n#define SN_setct_CapRevResData          \"setct-CapRevResData\"\n#define NID_setct_CapRevResData         549\n#define OBJ_setct_CapRevResData         OBJ_set_ctype,31L\n\n#define SN_setct_CredReqTBS             \"setct-CredReqTBS\"\n#define NID_setct_CredReqTBS            550\n#define OBJ_setct_CredReqTBS            OBJ_set_ctype,32L\n\n#define SN_setct_CredReqTBSX            \"setct-CredReqTBSX\"\n#define NID_setct_CredReqTBSX           551\n#define OBJ_setct_CredReqTBSX           OBJ_set_ctype,33L\n\n#define SN_setct_CredResData            \"setct-CredResData\"\n#define NID_setct_CredResData           552\n#define OBJ_setct_CredResData           OBJ_set_ctype,34L\n\n#define SN_setct_CredRevReqTBS          \"setct-CredRevReqTBS\"\n#define NID_setct_CredRevReqTBS         553\n#define OBJ_setct_CredRevReqTBS         OBJ_set_ctype,35L\n\n#define SN_setct_CredRevReqTBSX         \"setct-CredRevReqTBSX\"\n#define NID_setct_CredRevReqTBSX                554\n#define OBJ_setct_CredRevReqTBSX                OBJ_set_ctype,36L\n\n#define SN_setct_CredRevResData         \"setct-CredRevResData\"\n#define NID_setct_CredRevResData                555\n#define OBJ_setct_CredRevResData                OBJ_set_ctype,37L\n\n#define SN_setct_PCertReqData           \"setct-PCertReqData\"\n#define NID_setct_PCertReqData          556\n#define OBJ_setct_PCertReqData          OBJ_set_ctype,38L\n\n#define SN_setct_PCertResTBS            \"setct-PCertResTBS\"\n#define NID_setct_PCertResTBS           557\n#define OBJ_setct_PCertResTBS           OBJ_set_ctype,39L\n\n#define SN_setct_BatchAdminReqData              \"setct-BatchAdminReqData\"\n#define NID_setct_BatchAdminReqData             558\n#define OBJ_setct_BatchAdminReqData             OBJ_set_ctype,40L\n\n#define SN_setct_BatchAdminResData              \"setct-BatchAdminResData\"\n#define NID_setct_BatchAdminResData             559\n#define OBJ_setct_BatchAdminResData             OBJ_set_ctype,41L\n\n#define SN_setct_CardCInitResTBS                \"setct-CardCInitResTBS\"\n#define NID_setct_CardCInitResTBS               560\n#define OBJ_setct_CardCInitResTBS               OBJ_set_ctype,42L\n\n#define SN_setct_MeAqCInitResTBS                \"setct-MeAqCInitResTBS\"\n#define NID_setct_MeAqCInitResTBS               561\n#define OBJ_setct_MeAqCInitResTBS               OBJ_set_ctype,43L\n\n#define SN_setct_RegFormResTBS          \"setct-RegFormResTBS\"\n#define NID_setct_RegFormResTBS         562\n#define OBJ_setct_RegFormResTBS         OBJ_set_ctype,44L\n\n#define SN_setct_CertReqData            \"setct-CertReqData\"\n#define NID_setct_CertReqData           563\n#define OBJ_setct_CertReqData           OBJ_set_ctype,45L\n\n#define SN_setct_CertReqTBS             \"setct-CertReqTBS\"\n#define NID_setct_CertReqTBS            564\n#define OBJ_setct_CertReqTBS            OBJ_set_ctype,46L\n\n#define SN_setct_CertResData            \"setct-CertResData\"\n#define NID_setct_CertResData           565\n#define OBJ_setct_CertResData           OBJ_set_ctype,47L\n\n#define SN_setct_CertInqReqTBS          \"setct-CertInqReqTBS\"\n#define NID_setct_CertInqReqTBS         566\n#define OBJ_setct_CertInqReqTBS         OBJ_set_ctype,48L\n\n#define SN_setct_ErrorTBS               \"setct-ErrorTBS\"\n#define NID_setct_ErrorTBS              567\n#define OBJ_setct_ErrorTBS              OBJ_set_ctype,49L\n\n#define SN_setct_PIDualSignedTBE                \"setct-PIDualSignedTBE\"\n#define NID_setct_PIDualSignedTBE               568\n#define OBJ_setct_PIDualSignedTBE               OBJ_set_ctype,50L\n\n#define SN_setct_PIUnsignedTBE          \"setct-PIUnsignedTBE\"\n#define NID_setct_PIUnsignedTBE         569\n#define OBJ_setct_PIUnsignedTBE         OBJ_set_ctype,51L\n\n#define SN_setct_AuthReqTBE             \"setct-AuthReqTBE\"\n#define NID_setct_AuthReqTBE            570\n#define OBJ_setct_AuthReqTBE            OBJ_set_ctype,52L\n\n#define SN_setct_AuthResTBE             \"setct-AuthResTBE\"\n#define NID_setct_AuthResTBE            571\n#define OBJ_setct_AuthResTBE            OBJ_set_ctype,53L\n\n#define SN_setct_AuthResTBEX            \"setct-AuthResTBEX\"\n#define NID_setct_AuthResTBEX           572\n#define OBJ_setct_AuthResTBEX           OBJ_set_ctype,54L\n\n#define SN_setct_AuthTokenTBE           \"setct-AuthTokenTBE\"\n#define NID_setct_AuthTokenTBE          573\n#define OBJ_setct_AuthTokenTBE          OBJ_set_ctype,55L\n\n#define SN_setct_CapTokenTBE            \"setct-CapTokenTBE\"\n#define NID_setct_CapTokenTBE           574\n#define OBJ_setct_CapTokenTBE           OBJ_set_ctype,56L\n\n#define SN_setct_CapTokenTBEX           \"setct-CapTokenTBEX\"\n#define NID_setct_CapTokenTBEX          575\n#define OBJ_setct_CapTokenTBEX          OBJ_set_ctype,57L\n\n#define SN_setct_AcqCardCodeMsgTBE              \"setct-AcqCardCodeMsgTBE\"\n#define NID_setct_AcqCardCodeMsgTBE             576\n#define OBJ_setct_AcqCardCodeMsgTBE             OBJ_set_ctype,58L\n\n#define SN_setct_AuthRevReqTBE          \"setct-AuthRevReqTBE\"\n#define NID_setct_AuthRevReqTBE         577\n#define OBJ_setct_AuthRevReqTBE         OBJ_set_ctype,59L\n\n#define SN_setct_AuthRevResTBE          \"setct-AuthRevResTBE\"\n#define NID_setct_AuthRevResTBE         578\n#define OBJ_setct_AuthRevResTBE         OBJ_set_ctype,60L\n\n#define SN_setct_AuthRevResTBEB         \"setct-AuthRevResTBEB\"\n#define NID_setct_AuthRevResTBEB                579\n#define OBJ_setct_AuthRevResTBEB                OBJ_set_ctype,61L\n\n#define SN_setct_CapReqTBE              \"setct-CapReqTBE\"\n#define NID_setct_CapReqTBE             580\n#define OBJ_setct_CapReqTBE             OBJ_set_ctype,62L\n\n#define SN_setct_CapReqTBEX             \"setct-CapReqTBEX\"\n#define NID_setct_CapReqTBEX            581\n#define OBJ_setct_CapReqTBEX            OBJ_set_ctype,63L\n\n#define SN_setct_CapResTBE              \"setct-CapResTBE\"\n#define NID_setct_CapResTBE             582\n#define OBJ_setct_CapResTBE             OBJ_set_ctype,64L\n\n#define SN_setct_CapRevReqTBE           \"setct-CapRevReqTBE\"\n#define NID_setct_CapRevReqTBE          583\n#define OBJ_setct_CapRevReqTBE          OBJ_set_ctype,65L\n\n#define SN_setct_CapRevReqTBEX          \"setct-CapRevReqTBEX\"\n#define NID_setct_CapRevReqTBEX         584\n#define OBJ_setct_CapRevReqTBEX         OBJ_set_ctype,66L\n\n#define SN_setct_CapRevResTBE           \"setct-CapRevResTBE\"\n#define NID_setct_CapRevResTBE          585\n#define OBJ_setct_CapRevResTBE          OBJ_set_ctype,67L\n\n#define SN_setct_CredReqTBE             \"setct-CredReqTBE\"\n#define NID_setct_CredReqTBE            586\n#define OBJ_setct_CredReqTBE            OBJ_set_ctype,68L\n\n#define SN_setct_CredReqTBEX            \"setct-CredReqTBEX\"\n#define NID_setct_CredReqTBEX           587\n#define OBJ_setct_CredReqTBEX           OBJ_set_ctype,69L\n\n#define SN_setct_CredResTBE             \"setct-CredResTBE\"\n#define NID_setct_CredResTBE            588\n#define OBJ_setct_CredResTBE            OBJ_set_ctype,70L\n\n#define SN_setct_CredRevReqTBE          \"setct-CredRevReqTBE\"\n#define NID_setct_CredRevReqTBE         589\n#define OBJ_setct_CredRevReqTBE         OBJ_set_ctype,71L\n\n#define SN_setct_CredRevReqTBEX         \"setct-CredRevReqTBEX\"\n#define NID_setct_CredRevReqTBEX                590\n#define OBJ_setct_CredRevReqTBEX                OBJ_set_ctype,72L\n\n#define SN_setct_CredRevResTBE          \"setct-CredRevResTBE\"\n#define NID_setct_CredRevResTBE         591\n#define OBJ_setct_CredRevResTBE         OBJ_set_ctype,73L\n\n#define SN_setct_BatchAdminReqTBE               \"setct-BatchAdminReqTBE\"\n#define NID_setct_BatchAdminReqTBE              592\n#define OBJ_setct_BatchAdminReqTBE              OBJ_set_ctype,74L\n\n#define SN_setct_BatchAdminResTBE               \"setct-BatchAdminResTBE\"\n#define NID_setct_BatchAdminResTBE              593\n#define OBJ_setct_BatchAdminResTBE              OBJ_set_ctype,75L\n\n#define SN_setct_RegFormReqTBE          \"setct-RegFormReqTBE\"\n#define NID_setct_RegFormReqTBE         594\n#define OBJ_setct_RegFormReqTBE         OBJ_set_ctype,76L\n\n#define SN_setct_CertReqTBE             \"setct-CertReqTBE\"\n#define NID_setct_CertReqTBE            595\n#define OBJ_setct_CertReqTBE            OBJ_set_ctype,77L\n\n#define SN_setct_CertReqTBEX            \"setct-CertReqTBEX\"\n#define NID_setct_CertReqTBEX           596\n#define OBJ_setct_CertReqTBEX           OBJ_set_ctype,78L\n\n#define SN_setct_CertResTBE             \"setct-CertResTBE\"\n#define NID_setct_CertResTBE            597\n#define OBJ_setct_CertResTBE            OBJ_set_ctype,79L\n\n#define SN_setct_CRLNotificationTBS             \"setct-CRLNotificationTBS\"\n#define NID_setct_CRLNotificationTBS            598\n#define OBJ_setct_CRLNotificationTBS            OBJ_set_ctype,80L\n\n#define SN_setct_CRLNotificationResTBS          \"setct-CRLNotificationResTBS\"\n#define NID_setct_CRLNotificationResTBS         599\n#define OBJ_setct_CRLNotificationResTBS         OBJ_set_ctype,81L\n\n#define SN_setct_BCIDistributionTBS             \"setct-BCIDistributionTBS\"\n#define NID_setct_BCIDistributionTBS            600\n#define OBJ_setct_BCIDistributionTBS            OBJ_set_ctype,82L\n\n#define SN_setext_genCrypt              \"setext-genCrypt\"\n#define LN_setext_genCrypt              \"generic cryptogram\"\n#define NID_setext_genCrypt             601\n#define OBJ_setext_genCrypt             OBJ_set_msgExt,1L\n\n#define SN_setext_miAuth                \"setext-miAuth\"\n#define LN_setext_miAuth                \"merchant initiated auth\"\n#define NID_setext_miAuth               602\n#define OBJ_setext_miAuth               OBJ_set_msgExt,3L\n\n#define SN_setext_pinSecure             \"setext-pinSecure\"\n#define NID_setext_pinSecure            603\n#define OBJ_setext_pinSecure            OBJ_set_msgExt,4L\n\n#define SN_setext_pinAny                \"setext-pinAny\"\n#define NID_setext_pinAny               604\n#define OBJ_setext_pinAny               OBJ_set_msgExt,5L\n\n#define SN_setext_track2                \"setext-track2\"\n#define NID_setext_track2               605\n#define OBJ_setext_track2               OBJ_set_msgExt,7L\n\n#define SN_setext_cv            \"setext-cv\"\n#define LN_setext_cv            \"additional verification\"\n#define NID_setext_cv           606\n#define OBJ_setext_cv           OBJ_set_msgExt,8L\n\n#define SN_set_policy_root              \"set-policy-root\"\n#define NID_set_policy_root             607\n#define OBJ_set_policy_root             OBJ_set_policy,0L\n\n#define SN_setCext_hashedRoot           \"setCext-hashedRoot\"\n#define NID_setCext_hashedRoot          608\n#define OBJ_setCext_hashedRoot          OBJ_set_certExt,0L\n\n#define SN_setCext_certType             \"setCext-certType\"\n#define NID_setCext_certType            609\n#define OBJ_setCext_certType            OBJ_set_certExt,1L\n\n#define SN_setCext_merchData            \"setCext-merchData\"\n#define NID_setCext_merchData           610\n#define OBJ_setCext_merchData           OBJ_set_certExt,2L\n\n#define SN_setCext_cCertRequired                \"setCext-cCertRequired\"\n#define NID_setCext_cCertRequired               611\n#define OBJ_setCext_cCertRequired               OBJ_set_certExt,3L\n\n#define SN_setCext_tunneling            \"setCext-tunneling\"\n#define NID_setCext_tunneling           612\n#define OBJ_setCext_tunneling           OBJ_set_certExt,4L\n\n#define SN_setCext_setExt               \"setCext-setExt\"\n#define NID_setCext_setExt              613\n#define OBJ_setCext_setExt              OBJ_set_certExt,5L\n\n#define SN_setCext_setQualf             \"setCext-setQualf\"\n#define NID_setCext_setQualf            614\n#define OBJ_setCext_setQualf            OBJ_set_certExt,6L\n\n#define SN_setCext_PGWYcapabilities             \"setCext-PGWYcapabilities\"\n#define NID_setCext_PGWYcapabilities            615\n#define OBJ_setCext_PGWYcapabilities            OBJ_set_certExt,7L\n\n#define SN_setCext_TokenIdentifier              \"setCext-TokenIdentifier\"\n#define NID_setCext_TokenIdentifier             616\n#define OBJ_setCext_TokenIdentifier             OBJ_set_certExt,8L\n\n#define SN_setCext_Track2Data           \"setCext-Track2Data\"\n#define NID_setCext_Track2Data          617\n#define OBJ_setCext_Track2Data          OBJ_set_certExt,9L\n\n#define SN_setCext_TokenType            \"setCext-TokenType\"\n#define NID_setCext_TokenType           618\n#define OBJ_setCext_TokenType           OBJ_set_certExt,10L\n\n#define SN_setCext_IssuerCapabilities           \"setCext-IssuerCapabilities\"\n#define NID_setCext_IssuerCapabilities          619\n#define OBJ_setCext_IssuerCapabilities          OBJ_set_certExt,11L\n\n#define SN_setAttr_Cert         \"setAttr-Cert\"\n#define NID_setAttr_Cert                620\n#define OBJ_setAttr_Cert                OBJ_set_attr,0L\n\n#define SN_setAttr_PGWYcap              \"setAttr-PGWYcap\"\n#define LN_setAttr_PGWYcap              \"payment gateway capabilities\"\n#define NID_setAttr_PGWYcap             621\n#define OBJ_setAttr_PGWYcap             OBJ_set_attr,1L\n\n#define SN_setAttr_TokenType            \"setAttr-TokenType\"\n#define NID_setAttr_TokenType           622\n#define OBJ_setAttr_TokenType           OBJ_set_attr,2L\n\n#define SN_setAttr_IssCap               \"setAttr-IssCap\"\n#define LN_setAttr_IssCap               \"issuer capabilities\"\n#define NID_setAttr_IssCap              623\n#define OBJ_setAttr_IssCap              OBJ_set_attr,3L\n\n#define SN_set_rootKeyThumb             \"set-rootKeyThumb\"\n#define NID_set_rootKeyThumb            624\n#define OBJ_set_rootKeyThumb            OBJ_setAttr_Cert,0L\n\n#define SN_set_addPolicy                \"set-addPolicy\"\n#define NID_set_addPolicy               625\n#define OBJ_set_addPolicy               OBJ_setAttr_Cert,1L\n\n#define SN_setAttr_Token_EMV            \"setAttr-Token-EMV\"\n#define NID_setAttr_Token_EMV           626\n#define OBJ_setAttr_Token_EMV           OBJ_setAttr_TokenType,1L\n\n#define SN_setAttr_Token_B0Prime                \"setAttr-Token-B0Prime\"\n#define NID_setAttr_Token_B0Prime               627\n#define OBJ_setAttr_Token_B0Prime               OBJ_setAttr_TokenType,2L\n\n#define SN_setAttr_IssCap_CVM           \"setAttr-IssCap-CVM\"\n#define NID_setAttr_IssCap_CVM          628\n#define OBJ_setAttr_IssCap_CVM          OBJ_setAttr_IssCap,3L\n\n#define SN_setAttr_IssCap_T2            \"setAttr-IssCap-T2\"\n#define NID_setAttr_IssCap_T2           629\n#define OBJ_setAttr_IssCap_T2           OBJ_setAttr_IssCap,4L\n\n#define SN_setAttr_IssCap_Sig           \"setAttr-IssCap-Sig\"\n#define NID_setAttr_IssCap_Sig          630\n#define OBJ_setAttr_IssCap_Sig          OBJ_setAttr_IssCap,5L\n\n#define SN_setAttr_GenCryptgrm          \"setAttr-GenCryptgrm\"\n#define LN_setAttr_GenCryptgrm          \"generate cryptogram\"\n#define NID_setAttr_GenCryptgrm         631\n#define OBJ_setAttr_GenCryptgrm         OBJ_setAttr_IssCap_CVM,1L\n\n#define SN_setAttr_T2Enc                \"setAttr-T2Enc\"\n#define LN_setAttr_T2Enc                \"encrypted track 2\"\n#define NID_setAttr_T2Enc               632\n#define OBJ_setAttr_T2Enc               OBJ_setAttr_IssCap_T2,1L\n\n#define SN_setAttr_T2cleartxt           \"setAttr-T2cleartxt\"\n#define LN_setAttr_T2cleartxt           \"cleartext track 2\"\n#define NID_setAttr_T2cleartxt          633\n#define OBJ_setAttr_T2cleartxt          OBJ_setAttr_IssCap_T2,2L\n\n#define SN_setAttr_TokICCsig            \"setAttr-TokICCsig\"\n#define LN_setAttr_TokICCsig            \"ICC or token signature\"\n#define NID_setAttr_TokICCsig           634\n#define OBJ_setAttr_TokICCsig           OBJ_setAttr_IssCap_Sig,1L\n\n#define SN_setAttr_SecDevSig            \"setAttr-SecDevSig\"\n#define LN_setAttr_SecDevSig            \"secure device signature\"\n#define NID_setAttr_SecDevSig           635\n#define OBJ_setAttr_SecDevSig           OBJ_setAttr_IssCap_Sig,2L\n\n#define SN_set_brand_IATA_ATA           \"set-brand-IATA-ATA\"\n#define NID_set_brand_IATA_ATA          636\n#define OBJ_set_brand_IATA_ATA          OBJ_set_brand,1L\n\n#define SN_set_brand_Diners             \"set-brand-Diners\"\n#define NID_set_brand_Diners            637\n#define OBJ_set_brand_Diners            OBJ_set_brand,30L\n\n#define SN_set_brand_AmericanExpress            \"set-brand-AmericanExpress\"\n#define NID_set_brand_AmericanExpress           638\n#define OBJ_set_brand_AmericanExpress           OBJ_set_brand,34L\n\n#define SN_set_brand_JCB                \"set-brand-JCB\"\n#define NID_set_brand_JCB               639\n#define OBJ_set_brand_JCB               OBJ_set_brand,35L\n\n#define SN_set_brand_Visa               \"set-brand-Visa\"\n#define NID_set_brand_Visa              640\n#define OBJ_set_brand_Visa              OBJ_set_brand,4L\n\n#define SN_set_brand_MasterCard         \"set-brand-MasterCard\"\n#define NID_set_brand_MasterCard                641\n#define OBJ_set_brand_MasterCard                OBJ_set_brand,5L\n\n#define SN_set_brand_Novus              \"set-brand-Novus\"\n#define NID_set_brand_Novus             642\n#define OBJ_set_brand_Novus             OBJ_set_brand,6011L\n\n#define SN_des_cdmf             \"DES-CDMF\"\n#define LN_des_cdmf             \"des-cdmf\"\n#define NID_des_cdmf            643\n#define OBJ_des_cdmf            OBJ_rsadsi,3L,10L\n\n#define SN_rsaOAEPEncryptionSET         \"rsaOAEPEncryptionSET\"\n#define NID_rsaOAEPEncryptionSET                644\n#define OBJ_rsaOAEPEncryptionSET                OBJ_rsadsi,1L,1L,6L\n\n#define SN_ipsec3               \"Oakley-EC2N-3\"\n#define LN_ipsec3               \"ipsec3\"\n#define NID_ipsec3              749\n\n#define SN_ipsec4               \"Oakley-EC2N-4\"\n#define LN_ipsec4               \"ipsec4\"\n#define NID_ipsec4              750\n\n#define SN_whirlpool            \"whirlpool\"\n#define NID_whirlpool           804\n#define OBJ_whirlpool           OBJ_iso,0L,10118L,3L,0L,55L\n\n#define SN_cryptopro            \"cryptopro\"\n#define NID_cryptopro           805\n#define OBJ_cryptopro           OBJ_member_body,643L,2L,2L\n\n#define SN_cryptocom            \"cryptocom\"\n#define NID_cryptocom           806\n#define OBJ_cryptocom           OBJ_member_body,643L,2L,9L\n\n#define SN_id_GostR3411_94_with_GostR3410_2001          \"id-GostR3411-94-with-GostR3410-2001\"\n#define LN_id_GostR3411_94_with_GostR3410_2001          \"GOST R 34.11-94 with GOST R 34.10-2001\"\n#define NID_id_GostR3411_94_with_GostR3410_2001         807\n#define OBJ_id_GostR3411_94_with_GostR3410_2001         OBJ_cryptopro,3L\n\n#define SN_id_GostR3411_94_with_GostR3410_94            \"id-GostR3411-94-with-GostR3410-94\"\n#define LN_id_GostR3411_94_with_GostR3410_94            \"GOST R 34.11-94 with GOST R 34.10-94\"\n#define NID_id_GostR3411_94_with_GostR3410_94           808\n#define OBJ_id_GostR3411_94_with_GostR3410_94           OBJ_cryptopro,4L\n\n#define SN_id_GostR3411_94              \"md_gost94\"\n#define LN_id_GostR3411_94              \"GOST R 34.11-94\"\n#define NID_id_GostR3411_94             809\n#define OBJ_id_GostR3411_94             OBJ_cryptopro,9L\n\n#define SN_id_HMACGostR3411_94          \"id-HMACGostR3411-94\"\n#define LN_id_HMACGostR3411_94          \"HMAC GOST 34.11-94\"\n#define NID_id_HMACGostR3411_94         810\n#define OBJ_id_HMACGostR3411_94         OBJ_cryptopro,10L\n\n#define SN_id_GostR3410_2001            \"gost2001\"\n#define LN_id_GostR3410_2001            \"GOST R 34.10-2001\"\n#define NID_id_GostR3410_2001           811\n#define OBJ_id_GostR3410_2001           OBJ_cryptopro,19L\n\n#define SN_id_GostR3410_94              \"gost94\"\n#define LN_id_GostR3410_94              \"GOST R 34.10-94\"\n#define NID_id_GostR3410_94             812\n#define OBJ_id_GostR3410_94             OBJ_cryptopro,20L\n\n#define SN_id_Gost28147_89              \"gost89\"\n#define LN_id_Gost28147_89              \"GOST 28147-89\"\n#define NID_id_Gost28147_89             813\n#define OBJ_id_Gost28147_89             OBJ_cryptopro,21L\n\n#define SN_gost89_cnt           \"gost89-cnt\"\n#define NID_gost89_cnt          814\n\n#define SN_id_Gost28147_89_MAC          \"gost-mac\"\n#define LN_id_Gost28147_89_MAC          \"GOST 28147-89 MAC\"\n#define NID_id_Gost28147_89_MAC         815\n#define OBJ_id_Gost28147_89_MAC         OBJ_cryptopro,22L\n\n#define SN_id_GostR3411_94_prf          \"prf-gostr3411-94\"\n#define LN_id_GostR3411_94_prf          \"GOST R 34.11-94 PRF\"\n#define NID_id_GostR3411_94_prf         816\n#define OBJ_id_GostR3411_94_prf         OBJ_cryptopro,23L\n\n#define SN_id_GostR3410_2001DH          \"id-GostR3410-2001DH\"\n#define LN_id_GostR3410_2001DH          \"GOST R 34.10-2001 DH\"\n#define NID_id_GostR3410_2001DH         817\n#define OBJ_id_GostR3410_2001DH         OBJ_cryptopro,98L\n\n#define SN_id_GostR3410_94DH            \"id-GostR3410-94DH\"\n#define LN_id_GostR3410_94DH            \"GOST R 34.10-94 DH\"\n#define NID_id_GostR3410_94DH           818\n#define OBJ_id_GostR3410_94DH           OBJ_cryptopro,99L\n\n#define SN_id_Gost28147_89_CryptoPro_KeyMeshing         \"id-Gost28147-89-CryptoPro-KeyMeshing\"\n#define NID_id_Gost28147_89_CryptoPro_KeyMeshing                819\n#define OBJ_id_Gost28147_89_CryptoPro_KeyMeshing                OBJ_cryptopro,14L,1L\n\n#define SN_id_Gost28147_89_None_KeyMeshing              \"id-Gost28147-89-None-KeyMeshing\"\n#define NID_id_Gost28147_89_None_KeyMeshing             820\n#define OBJ_id_Gost28147_89_None_KeyMeshing             OBJ_cryptopro,14L,0L\n\n#define SN_id_GostR3411_94_TestParamSet         \"id-GostR3411-94-TestParamSet\"\n#define NID_id_GostR3411_94_TestParamSet                821\n#define OBJ_id_GostR3411_94_TestParamSet                OBJ_cryptopro,30L,0L\n\n#define SN_id_GostR3411_94_CryptoProParamSet            \"id-GostR3411-94-CryptoProParamSet\"\n#define NID_id_GostR3411_94_CryptoProParamSet           822\n#define OBJ_id_GostR3411_94_CryptoProParamSet           OBJ_cryptopro,30L,1L\n\n#define SN_id_Gost28147_89_TestParamSet         \"id-Gost28147-89-TestParamSet\"\n#define NID_id_Gost28147_89_TestParamSet                823\n#define OBJ_id_Gost28147_89_TestParamSet                OBJ_cryptopro,31L,0L\n\n#define SN_id_Gost28147_89_CryptoPro_A_ParamSet         \"id-Gost28147-89-CryptoPro-A-ParamSet\"\n#define NID_id_Gost28147_89_CryptoPro_A_ParamSet                824\n#define OBJ_id_Gost28147_89_CryptoPro_A_ParamSet                OBJ_cryptopro,31L,1L\n\n#define SN_id_Gost28147_89_CryptoPro_B_ParamSet         \"id-Gost28147-89-CryptoPro-B-ParamSet\"\n#define NID_id_Gost28147_89_CryptoPro_B_ParamSet                825\n#define OBJ_id_Gost28147_89_CryptoPro_B_ParamSet                OBJ_cryptopro,31L,2L\n\n#define SN_id_Gost28147_89_CryptoPro_C_ParamSet         \"id-Gost28147-89-CryptoPro-C-ParamSet\"\n#define NID_id_Gost28147_89_CryptoPro_C_ParamSet                826\n#define OBJ_id_Gost28147_89_CryptoPro_C_ParamSet                OBJ_cryptopro,31L,3L\n\n#define SN_id_Gost28147_89_CryptoPro_D_ParamSet         \"id-Gost28147-89-CryptoPro-D-ParamSet\"\n#define NID_id_Gost28147_89_CryptoPro_D_ParamSet                827\n#define OBJ_id_Gost28147_89_CryptoPro_D_ParamSet                OBJ_cryptopro,31L,4L\n\n#define SN_id_Gost28147_89_CryptoPro_Oscar_1_1_ParamSet         \"id-Gost28147-89-CryptoPro-Oscar-1-1-ParamSet\"\n#define NID_id_Gost28147_89_CryptoPro_Oscar_1_1_ParamSet                828\n#define OBJ_id_Gost28147_89_CryptoPro_Oscar_1_1_ParamSet                OBJ_cryptopro,31L,5L\n\n#define SN_id_Gost28147_89_CryptoPro_Oscar_1_0_ParamSet         \"id-Gost28147-89-CryptoPro-Oscar-1-0-ParamSet\"\n#define NID_id_Gost28147_89_CryptoPro_Oscar_1_0_ParamSet                829\n#define OBJ_id_Gost28147_89_CryptoPro_Oscar_1_0_ParamSet                OBJ_cryptopro,31L,6L\n\n#define SN_id_Gost28147_89_CryptoPro_RIC_1_ParamSet             \"id-Gost28147-89-CryptoPro-RIC-1-ParamSet\"\n#define NID_id_Gost28147_89_CryptoPro_RIC_1_ParamSet            830\n#define OBJ_id_Gost28147_89_CryptoPro_RIC_1_ParamSet            OBJ_cryptopro,31L,7L\n\n#define SN_id_GostR3410_94_TestParamSet         \"id-GostR3410-94-TestParamSet\"\n#define NID_id_GostR3410_94_TestParamSet                831\n#define OBJ_id_GostR3410_94_TestParamSet                OBJ_cryptopro,32L,0L\n\n#define SN_id_GostR3410_94_CryptoPro_A_ParamSet         \"id-GostR3410-94-CryptoPro-A-ParamSet\"\n#define NID_id_GostR3410_94_CryptoPro_A_ParamSet                832\n#define OBJ_id_GostR3410_94_CryptoPro_A_ParamSet                OBJ_cryptopro,32L,2L\n\n#define SN_id_GostR3410_94_CryptoPro_B_ParamSet         \"id-GostR3410-94-CryptoPro-B-ParamSet\"\n#define NID_id_GostR3410_94_CryptoPro_B_ParamSet                833\n#define OBJ_id_GostR3410_94_CryptoPro_B_ParamSet                OBJ_cryptopro,32L,3L\n\n#define SN_id_GostR3410_94_CryptoPro_C_ParamSet         \"id-GostR3410-94-CryptoPro-C-ParamSet\"\n#define NID_id_GostR3410_94_CryptoPro_C_ParamSet                834\n#define OBJ_id_GostR3410_94_CryptoPro_C_ParamSet                OBJ_cryptopro,32L,4L\n\n#define SN_id_GostR3410_94_CryptoPro_D_ParamSet         \"id-GostR3410-94-CryptoPro-D-ParamSet\"\n#define NID_id_GostR3410_94_CryptoPro_D_ParamSet                835\n#define OBJ_id_GostR3410_94_CryptoPro_D_ParamSet                OBJ_cryptopro,32L,5L\n\n#define SN_id_GostR3410_94_CryptoPro_XchA_ParamSet              \"id-GostR3410-94-CryptoPro-XchA-ParamSet\"\n#define NID_id_GostR3410_94_CryptoPro_XchA_ParamSet             836\n#define OBJ_id_GostR3410_94_CryptoPro_XchA_ParamSet             OBJ_cryptopro,33L,1L\n\n#define SN_id_GostR3410_94_CryptoPro_XchB_ParamSet              \"id-GostR3410-94-CryptoPro-XchB-ParamSet\"\n#define NID_id_GostR3410_94_CryptoPro_XchB_ParamSet             837\n#define OBJ_id_GostR3410_94_CryptoPro_XchB_ParamSet             OBJ_cryptopro,33L,2L\n\n#define SN_id_GostR3410_94_CryptoPro_XchC_ParamSet              \"id-GostR3410-94-CryptoPro-XchC-ParamSet\"\n#define NID_id_GostR3410_94_CryptoPro_XchC_ParamSet             838\n#define OBJ_id_GostR3410_94_CryptoPro_XchC_ParamSet             OBJ_cryptopro,33L,3L\n\n#define SN_id_GostR3410_2001_TestParamSet               \"id-GostR3410-2001-TestParamSet\"\n#define NID_id_GostR3410_2001_TestParamSet              839\n#define OBJ_id_GostR3410_2001_TestParamSet              OBJ_cryptopro,35L,0L\n\n#define SN_id_GostR3410_2001_CryptoPro_A_ParamSet               \"id-GostR3410-2001-CryptoPro-A-ParamSet\"\n#define NID_id_GostR3410_2001_CryptoPro_A_ParamSet              840\n#define OBJ_id_GostR3410_2001_CryptoPro_A_ParamSet              OBJ_cryptopro,35L,1L\n\n#define SN_id_GostR3410_2001_CryptoPro_B_ParamSet               \"id-GostR3410-2001-CryptoPro-B-ParamSet\"\n#define NID_id_GostR3410_2001_CryptoPro_B_ParamSet              841\n#define OBJ_id_GostR3410_2001_CryptoPro_B_ParamSet              OBJ_cryptopro,35L,2L\n\n#define SN_id_GostR3410_2001_CryptoPro_C_ParamSet               \"id-GostR3410-2001-CryptoPro-C-ParamSet\"\n#define NID_id_GostR3410_2001_CryptoPro_C_ParamSet              842\n#define OBJ_id_GostR3410_2001_CryptoPro_C_ParamSet              OBJ_cryptopro,35L,3L\n\n#define SN_id_GostR3410_2001_CryptoPro_XchA_ParamSet            \"id-GostR3410-2001-CryptoPro-XchA-ParamSet\"\n#define NID_id_GostR3410_2001_CryptoPro_XchA_ParamSet           843\n#define OBJ_id_GostR3410_2001_CryptoPro_XchA_ParamSet           OBJ_cryptopro,36L,0L\n\n#define SN_id_GostR3410_2001_CryptoPro_XchB_ParamSet            \"id-GostR3410-2001-CryptoPro-XchB-ParamSet\"\n#define NID_id_GostR3410_2001_CryptoPro_XchB_ParamSet           844\n#define OBJ_id_GostR3410_2001_CryptoPro_XchB_ParamSet           OBJ_cryptopro,36L,1L\n\n#define SN_id_GostR3410_94_a            \"id-GostR3410-94-a\"\n#define NID_id_GostR3410_94_a           845\n#define OBJ_id_GostR3410_94_a           OBJ_id_GostR3410_94,1L\n\n#define SN_id_GostR3410_94_aBis         \"id-GostR3410-94-aBis\"\n#define NID_id_GostR3410_94_aBis                846\n#define OBJ_id_GostR3410_94_aBis                OBJ_id_GostR3410_94,2L\n\n#define SN_id_GostR3410_94_b            \"id-GostR3410-94-b\"\n#define NID_id_GostR3410_94_b           847\n#define OBJ_id_GostR3410_94_b           OBJ_id_GostR3410_94,3L\n\n#define SN_id_GostR3410_94_bBis         \"id-GostR3410-94-bBis\"\n#define NID_id_GostR3410_94_bBis                848\n#define OBJ_id_GostR3410_94_bBis                OBJ_id_GostR3410_94,4L\n\n#define SN_id_Gost28147_89_cc           \"id-Gost28147-89-cc\"\n#define LN_id_Gost28147_89_cc           \"GOST 28147-89 Cryptocom ParamSet\"\n#define NID_id_Gost28147_89_cc          849\n#define OBJ_id_Gost28147_89_cc          OBJ_cryptocom,1L,6L,1L\n\n#define SN_id_GostR3410_94_cc           \"gost94cc\"\n#define LN_id_GostR3410_94_cc           \"GOST 34.10-94 Cryptocom\"\n#define NID_id_GostR3410_94_cc          850\n#define OBJ_id_GostR3410_94_cc          OBJ_cryptocom,1L,5L,3L\n\n#define SN_id_GostR3410_2001_cc         \"gost2001cc\"\n#define LN_id_GostR3410_2001_cc         \"GOST 34.10-2001 Cryptocom\"\n#define NID_id_GostR3410_2001_cc                851\n#define OBJ_id_GostR3410_2001_cc                OBJ_cryptocom,1L,5L,4L\n\n#define SN_id_GostR3411_94_with_GostR3410_94_cc         \"id-GostR3411-94-with-GostR3410-94-cc\"\n#define LN_id_GostR3411_94_with_GostR3410_94_cc         \"GOST R 34.11-94 with GOST R 34.10-94 Cryptocom\"\n#define NID_id_GostR3411_94_with_GostR3410_94_cc                852\n#define OBJ_id_GostR3411_94_with_GostR3410_94_cc                OBJ_cryptocom,1L,3L,3L\n\n#define SN_id_GostR3411_94_with_GostR3410_2001_cc               \"id-GostR3411-94-with-GostR3410-2001-cc\"\n#define LN_id_GostR3411_94_with_GostR3410_2001_cc               \"GOST R 34.11-94 with GOST R 34.10-2001 Cryptocom\"\n#define NID_id_GostR3411_94_with_GostR3410_2001_cc              853\n#define OBJ_id_GostR3411_94_with_GostR3410_2001_cc              OBJ_cryptocom,1L,3L,4L\n\n#define SN_id_GostR3410_2001_ParamSet_cc                \"id-GostR3410-2001-ParamSet-cc\"\n#define LN_id_GostR3410_2001_ParamSet_cc                \"GOST R 3410-2001 Parameter Set Cryptocom\"\n#define NID_id_GostR3410_2001_ParamSet_cc               854\n#define OBJ_id_GostR3410_2001_ParamSet_cc               OBJ_cryptocom,1L,8L,1L\n\n#define SN_camellia_128_cbc             \"CAMELLIA-128-CBC\"\n#define LN_camellia_128_cbc             \"camellia-128-cbc\"\n#define NID_camellia_128_cbc            751\n#define OBJ_camellia_128_cbc            1L,2L,392L,200011L,61L,1L,1L,1L,2L\n\n#define SN_camellia_192_cbc             \"CAMELLIA-192-CBC\"\n#define LN_camellia_192_cbc             \"camellia-192-cbc\"\n#define NID_camellia_192_cbc            752\n#define OBJ_camellia_192_cbc            1L,2L,392L,200011L,61L,1L,1L,1L,3L\n\n#define SN_camellia_256_cbc             \"CAMELLIA-256-CBC\"\n#define LN_camellia_256_cbc             \"camellia-256-cbc\"\n#define NID_camellia_256_cbc            753\n#define OBJ_camellia_256_cbc            1L,2L,392L,200011L,61L,1L,1L,1L,4L\n\n#define SN_id_camellia128_wrap          \"id-camellia128-wrap\"\n#define NID_id_camellia128_wrap         907\n#define OBJ_id_camellia128_wrap         1L,2L,392L,200011L,61L,1L,1L,3L,2L\n\n#define SN_id_camellia192_wrap          \"id-camellia192-wrap\"\n#define NID_id_camellia192_wrap         908\n#define OBJ_id_camellia192_wrap         1L,2L,392L,200011L,61L,1L,1L,3L,3L\n\n#define SN_id_camellia256_wrap          \"id-camellia256-wrap\"\n#define NID_id_camellia256_wrap         909\n#define OBJ_id_camellia256_wrap         1L,2L,392L,200011L,61L,1L,1L,3L,4L\n\n#define OBJ_ntt_ds              0L,3L,4401L,5L\n\n#define OBJ_camellia            OBJ_ntt_ds,3L,1L,9L\n\n#define SN_camellia_128_ecb             \"CAMELLIA-128-ECB\"\n#define LN_camellia_128_ecb             \"camellia-128-ecb\"\n#define NID_camellia_128_ecb            754\n#define OBJ_camellia_128_ecb            OBJ_camellia,1L\n\n#define SN_camellia_128_ofb128          \"CAMELLIA-128-OFB\"\n#define LN_camellia_128_ofb128          \"camellia-128-ofb\"\n#define NID_camellia_128_ofb128         766\n#define OBJ_camellia_128_ofb128         OBJ_camellia,3L\n\n#define SN_camellia_128_cfb128          \"CAMELLIA-128-CFB\"\n#define LN_camellia_128_cfb128          \"camellia-128-cfb\"\n#define NID_camellia_128_cfb128         757\n#define OBJ_camellia_128_cfb128         OBJ_camellia,4L\n\n#define SN_camellia_192_ecb             \"CAMELLIA-192-ECB\"\n#define LN_camellia_192_ecb             \"camellia-192-ecb\"\n#define NID_camellia_192_ecb            755\n#define OBJ_camellia_192_ecb            OBJ_camellia,21L\n\n#define SN_camellia_192_ofb128          \"CAMELLIA-192-OFB\"\n#define LN_camellia_192_ofb128          \"camellia-192-ofb\"\n#define NID_camellia_192_ofb128         767\n#define OBJ_camellia_192_ofb128         OBJ_camellia,23L\n\n#define SN_camellia_192_cfb128          \"CAMELLIA-192-CFB\"\n#define LN_camellia_192_cfb128          \"camellia-192-cfb\"\n#define NID_camellia_192_cfb128         758\n#define OBJ_camellia_192_cfb128         OBJ_camellia,24L\n\n#define SN_camellia_256_ecb             \"CAMELLIA-256-ECB\"\n#define LN_camellia_256_ecb             \"camellia-256-ecb\"\n#define NID_camellia_256_ecb            756\n#define OBJ_camellia_256_ecb            OBJ_camellia,41L\n\n#define SN_camellia_256_ofb128          \"CAMELLIA-256-OFB\"\n#define LN_camellia_256_ofb128          \"camellia-256-ofb\"\n#define NID_camellia_256_ofb128         768\n#define OBJ_camellia_256_ofb128         OBJ_camellia,43L\n\n#define SN_camellia_256_cfb128          \"CAMELLIA-256-CFB\"\n#define LN_camellia_256_cfb128          \"camellia-256-cfb\"\n#define NID_camellia_256_cfb128         759\n#define OBJ_camellia_256_cfb128         OBJ_camellia,44L\n\n#define SN_camellia_128_cfb1            \"CAMELLIA-128-CFB1\"\n#define LN_camellia_128_cfb1            \"camellia-128-cfb1\"\n#define NID_camellia_128_cfb1           760\n\n#define SN_camellia_192_cfb1            \"CAMELLIA-192-CFB1\"\n#define LN_camellia_192_cfb1            \"camellia-192-cfb1\"\n#define NID_camellia_192_cfb1           761\n\n#define SN_camellia_256_cfb1            \"CAMELLIA-256-CFB1\"\n#define LN_camellia_256_cfb1            \"camellia-256-cfb1\"\n#define NID_camellia_256_cfb1           762\n\n#define SN_camellia_128_cfb8            \"CAMELLIA-128-CFB8\"\n#define LN_camellia_128_cfb8            \"camellia-128-cfb8\"\n#define NID_camellia_128_cfb8           763\n\n#define SN_camellia_192_cfb8            \"CAMELLIA-192-CFB8\"\n#define LN_camellia_192_cfb8            \"camellia-192-cfb8\"\n#define NID_camellia_192_cfb8           764\n\n#define SN_camellia_256_cfb8            \"CAMELLIA-256-CFB8\"\n#define LN_camellia_256_cfb8            \"camellia-256-cfb8\"\n#define NID_camellia_256_cfb8           765\n\n#define SN_kisa         \"KISA\"\n#define LN_kisa         \"kisa\"\n#define NID_kisa                773\n#define OBJ_kisa                OBJ_member_body,410L,200004L\n\n#define SN_seed_ecb             \"SEED-ECB\"\n#define LN_seed_ecb             \"seed-ecb\"\n#define NID_seed_ecb            776\n#define OBJ_seed_ecb            OBJ_kisa,1L,3L\n\n#define SN_seed_cbc             \"SEED-CBC\"\n#define LN_seed_cbc             \"seed-cbc\"\n#define NID_seed_cbc            777\n#define OBJ_seed_cbc            OBJ_kisa,1L,4L\n\n#define SN_seed_cfb128          \"SEED-CFB\"\n#define LN_seed_cfb128          \"seed-cfb\"\n#define NID_seed_cfb128         779\n#define OBJ_seed_cfb128         OBJ_kisa,1L,5L\n\n#define SN_seed_ofb128          \"SEED-OFB\"\n#define LN_seed_ofb128          \"seed-ofb\"\n#define NID_seed_ofb128         778\n#define OBJ_seed_ofb128         OBJ_kisa,1L,6L\n\n#define SN_hmac         \"HMAC\"\n#define LN_hmac         \"hmac\"\n#define NID_hmac                855\n\n#define SN_cmac         \"CMAC\"\n#define LN_cmac         \"cmac\"\n#define NID_cmac                894\n\n#define SN_rc4_hmac_md5         \"RC4-HMAC-MD5\"\n#define LN_rc4_hmac_md5         \"rc4-hmac-md5\"\n#define NID_rc4_hmac_md5                915\n\n#define SN_aes_128_cbc_hmac_sha1                \"AES-128-CBC-HMAC-SHA1\"\n#define LN_aes_128_cbc_hmac_sha1                \"aes-128-cbc-hmac-sha1\"\n#define NID_aes_128_cbc_hmac_sha1               916\n\n#define SN_aes_192_cbc_hmac_sha1                \"AES-192-CBC-HMAC-SHA1\"\n#define LN_aes_192_cbc_hmac_sha1                \"aes-192-cbc-hmac-sha1\"\n#define NID_aes_192_cbc_hmac_sha1               917\n\n#define SN_aes_256_cbc_hmac_sha1                \"AES-256-CBC-HMAC-SHA1\"\n#define LN_aes_256_cbc_hmac_sha1                \"aes-256-cbc-hmac-sha1\"\n#define NID_aes_256_cbc_hmac_sha1               918\n\n#define SN_aes_128_cbc_hmac_sha256              \"AES-128-CBC-HMAC-SHA256\"\n#define LN_aes_128_cbc_hmac_sha256              \"aes-128-cbc-hmac-sha256\"\n#define NID_aes_128_cbc_hmac_sha256             948\n\n#define SN_aes_192_cbc_hmac_sha256              \"AES-192-CBC-HMAC-SHA256\"\n#define LN_aes_192_cbc_hmac_sha256              \"aes-192-cbc-hmac-sha256\"\n#define NID_aes_192_cbc_hmac_sha256             949\n\n#define SN_aes_256_cbc_hmac_sha256              \"AES-256-CBC-HMAC-SHA256\"\n#define LN_aes_256_cbc_hmac_sha256              \"aes-256-cbc-hmac-sha256\"\n#define NID_aes_256_cbc_hmac_sha256             950\n\n#define SN_dhpublicnumber               \"dhpublicnumber\"\n#define LN_dhpublicnumber               \"X9.42 DH\"\n#define NID_dhpublicnumber              920\n#define OBJ_dhpublicnumber              OBJ_ISO_US,10046L,2L,1L\n\n#define SN_brainpoolP160r1              \"brainpoolP160r1\"\n#define NID_brainpoolP160r1             921\n#define OBJ_brainpoolP160r1             1L,3L,36L,3L,3L,2L,8L,1L,1L,1L\n\n#define SN_brainpoolP160t1              \"brainpoolP160t1\"\n#define NID_brainpoolP160t1             922\n#define OBJ_brainpoolP160t1             1L,3L,36L,3L,3L,2L,8L,1L,1L,2L\n\n#define SN_brainpoolP192r1              \"brainpoolP192r1\"\n#define NID_brainpoolP192r1             923\n#define OBJ_brainpoolP192r1             1L,3L,36L,3L,3L,2L,8L,1L,1L,3L\n\n#define SN_brainpoolP192t1              \"brainpoolP192t1\"\n#define NID_brainpoolP192t1             924\n#define OBJ_brainpoolP192t1             1L,3L,36L,3L,3L,2L,8L,1L,1L,4L\n\n#define SN_brainpoolP224r1              \"brainpoolP224r1\"\n#define NID_brainpoolP224r1             925\n#define OBJ_brainpoolP224r1             1L,3L,36L,3L,3L,2L,8L,1L,1L,5L\n\n#define SN_brainpoolP224t1              \"brainpoolP224t1\"\n#define NID_brainpoolP224t1             926\n#define OBJ_brainpoolP224t1             1L,3L,36L,3L,3L,2L,8L,1L,1L,6L\n\n#define SN_brainpoolP256r1              \"brainpoolP256r1\"\n#define NID_brainpoolP256r1             927\n#define OBJ_brainpoolP256r1             1L,3L,36L,3L,3L,2L,8L,1L,1L,7L\n\n#define SN_brainpoolP256t1              \"brainpoolP256t1\"\n#define NID_brainpoolP256t1             928\n#define OBJ_brainpoolP256t1             1L,3L,36L,3L,3L,2L,8L,1L,1L,8L\n\n#define SN_brainpoolP320r1              \"brainpoolP320r1\"\n#define NID_brainpoolP320r1             929\n#define OBJ_brainpoolP320r1             1L,3L,36L,3L,3L,2L,8L,1L,1L,9L\n\n#define SN_brainpoolP320t1              \"brainpoolP320t1\"\n#define NID_brainpoolP320t1             930\n#define OBJ_brainpoolP320t1             1L,3L,36L,3L,3L,2L,8L,1L,1L,10L\n\n#define SN_brainpoolP384r1              \"brainpoolP384r1\"\n#define NID_brainpoolP384r1             931\n#define OBJ_brainpoolP384r1             1L,3L,36L,3L,3L,2L,8L,1L,1L,11L\n\n#define SN_brainpoolP384t1              \"brainpoolP384t1\"\n#define NID_brainpoolP384t1             932\n#define OBJ_brainpoolP384t1             1L,3L,36L,3L,3L,2L,8L,1L,1L,12L\n\n#define SN_brainpoolP512r1              \"brainpoolP512r1\"\n#define NID_brainpoolP512r1             933\n#define OBJ_brainpoolP512r1             1L,3L,36L,3L,3L,2L,8L,1L,1L,13L\n\n#define SN_brainpoolP512t1              \"brainpoolP512t1\"\n#define NID_brainpoolP512t1             934\n#define OBJ_brainpoolP512t1             1L,3L,36L,3L,3L,2L,8L,1L,1L,14L\n\n#define OBJ_x9_63_scheme                1L,3L,133L,16L,840L,63L,0L\n\n#define OBJ_secg_scheme         OBJ_certicom_arc,1L\n\n#define SN_dhSinglePass_stdDH_sha1kdf_scheme            \"dhSinglePass-stdDH-sha1kdf-scheme\"\n#define NID_dhSinglePass_stdDH_sha1kdf_scheme           936\n#define OBJ_dhSinglePass_stdDH_sha1kdf_scheme           OBJ_x9_63_scheme,2L\n\n#define SN_dhSinglePass_stdDH_sha224kdf_scheme          \"dhSinglePass-stdDH-sha224kdf-scheme\"\n#define NID_dhSinglePass_stdDH_sha224kdf_scheme         937\n#define OBJ_dhSinglePass_stdDH_sha224kdf_scheme         OBJ_secg_scheme,11L,0L\n\n#define SN_dhSinglePass_stdDH_sha256kdf_scheme          \"dhSinglePass-stdDH-sha256kdf-scheme\"\n#define NID_dhSinglePass_stdDH_sha256kdf_scheme         938\n#define OBJ_dhSinglePass_stdDH_sha256kdf_scheme         OBJ_secg_scheme,11L,1L\n\n#define SN_dhSinglePass_stdDH_sha384kdf_scheme          \"dhSinglePass-stdDH-sha384kdf-scheme\"\n#define NID_dhSinglePass_stdDH_sha384kdf_scheme         939\n#define OBJ_dhSinglePass_stdDH_sha384kdf_scheme         OBJ_secg_scheme,11L,2L\n\n#define SN_dhSinglePass_stdDH_sha512kdf_scheme          \"dhSinglePass-stdDH-sha512kdf-scheme\"\n#define NID_dhSinglePass_stdDH_sha512kdf_scheme         940\n#define OBJ_dhSinglePass_stdDH_sha512kdf_scheme         OBJ_secg_scheme,11L,3L\n\n#define SN_dhSinglePass_cofactorDH_sha1kdf_scheme               \"dhSinglePass-cofactorDH-sha1kdf-scheme\"\n#define NID_dhSinglePass_cofactorDH_sha1kdf_scheme              941\n#define OBJ_dhSinglePass_cofactorDH_sha1kdf_scheme              OBJ_x9_63_scheme,3L\n\n#define SN_dhSinglePass_cofactorDH_sha224kdf_scheme             \"dhSinglePass-cofactorDH-sha224kdf-scheme\"\n#define NID_dhSinglePass_cofactorDH_sha224kdf_scheme            942\n#define OBJ_dhSinglePass_cofactorDH_sha224kdf_scheme            OBJ_secg_scheme,14L,0L\n\n#define SN_dhSinglePass_cofactorDH_sha256kdf_scheme             \"dhSinglePass-cofactorDH-sha256kdf-scheme\"\n#define NID_dhSinglePass_cofactorDH_sha256kdf_scheme            943\n#define OBJ_dhSinglePass_cofactorDH_sha256kdf_scheme            OBJ_secg_scheme,14L,1L\n\n#define SN_dhSinglePass_cofactorDH_sha384kdf_scheme             \"dhSinglePass-cofactorDH-sha384kdf-scheme\"\n#define NID_dhSinglePass_cofactorDH_sha384kdf_scheme            944\n#define OBJ_dhSinglePass_cofactorDH_sha384kdf_scheme            OBJ_secg_scheme,14L,2L\n\n#define SN_dhSinglePass_cofactorDH_sha512kdf_scheme             \"dhSinglePass-cofactorDH-sha512kdf-scheme\"\n#define NID_dhSinglePass_cofactorDH_sha512kdf_scheme            945\n#define OBJ_dhSinglePass_cofactorDH_sha512kdf_scheme            OBJ_secg_scheme,14L,3L\n\n#define SN_dh_std_kdf           \"dh-std-kdf\"\n#define NID_dh_std_kdf          946\n\n#define SN_dh_cofactor_kdf              \"dh-cofactor-kdf\"\n#define NID_dh_cofactor_kdf             947\n\n#define SN_ct_precert_scts              \"ct_precert_scts\"\n#define LN_ct_precert_scts              \"CT Precertificate SCTs\"\n#define NID_ct_precert_scts             951\n#define OBJ_ct_precert_scts             1L,3L,6L,1L,4L,1L,11129L,2L,4L,2L\n\n#define SN_ct_precert_poison            \"ct_precert_poison\"\n#define LN_ct_precert_poison            \"CT Precertificate Poison\"\n#define NID_ct_precert_poison           952\n#define OBJ_ct_precert_poison           1L,3L,6L,1L,4L,1L,11129L,2L,4L,3L\n\n#define SN_ct_precert_signer            \"ct_precert_signer\"\n#define LN_ct_precert_signer            \"CT Precertificate Signer\"\n#define NID_ct_precert_signer           953\n#define OBJ_ct_precert_signer           1L,3L,6L,1L,4L,1L,11129L,2L,4L,4L\n\n#define SN_ct_cert_scts         \"ct_cert_scts\"\n#define LN_ct_cert_scts         \"CT Certificate SCTs\"\n#define NID_ct_cert_scts                954\n#define OBJ_ct_cert_scts                1L,3L,6L,1L,4L,1L,11129L,2L,4L,5L\n\n#define SN_jurisdictionLocalityName             \"jurisdictionL\"\n#define LN_jurisdictionLocalityName             \"jurisdictionLocalityName\"\n#define NID_jurisdictionLocalityName            955\n#define OBJ_jurisdictionLocalityName            1L,3L,6L,1L,4L,1L,311L,60L,2L,1L,1L\n\n#define SN_jurisdictionStateOrProvinceName              \"jurisdictionST\"\n#define LN_jurisdictionStateOrProvinceName              \"jurisdictionStateOrProvinceName\"\n#define NID_jurisdictionStateOrProvinceName             956\n#define OBJ_jurisdictionStateOrProvinceName             1L,3L,6L,1L,4L,1L,311L,60L,2L,1L,2L\n\n#define SN_jurisdictionCountryName              \"jurisdictionC\"\n#define LN_jurisdictionCountryName              \"jurisdictionCountryName\"\n#define NID_jurisdictionCountryName             957\n#define OBJ_jurisdictionCountryName             1L,3L,6L,1L,4L,1L,311L,60L,2L,1L,3L\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/arm/include/openssl/objects.h",
    "content": "/* crypto/objects/objects.h */\n/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)\n * All rights reserved.\n *\n * This package is an SSL implementation written\n * by Eric Young (eay@cryptsoft.com).\n * The implementation was written so as to conform with Netscapes SSL.\n *\n * This library is free for commercial and non-commercial use as long as\n * the following conditions are aheared to.  The following conditions\n * apply to all code found in this distribution, be it the RC4, RSA,\n * lhash, DES, etc., code; not just the SSL code.  The SSL documentation\n * included with this distribution is covered by the same copyright terms\n * except that the holder is Tim Hudson (tjh@cryptsoft.com).\n *\n * Copyright remains Eric Young's, and as such any Copyright notices in\n * the code are not to be removed.\n * If this package is used in a product, Eric Young should be given attribution\n * as the author of the parts of the library used.\n * This can be in the form of a textual message at program startup or\n * in documentation (online or textual) provided with the package.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the copyright\n *    notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in the\n *    documentation and/or other materials provided with the distribution.\n * 3. All advertising materials mentioning features or use of this software\n *    must display the following acknowledgement:\n *    \"This product includes cryptographic software written by\n *     Eric Young (eay@cryptsoft.com)\"\n *    The word 'cryptographic' can be left out if the rouines from the library\n *    being used are not cryptographic related :-).\n * 4. If you include any Windows specific code (or a derivative thereof) from\n *    the apps directory (application code) you must include an acknowledgement:\n *    \"This product includes software written by Tim Hudson (tjh@cryptsoft.com)\"\n *\n * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n * SUCH DAMAGE.\n *\n * The licence and distribution terms for any publically available version or\n * derivative of this code cannot be changed.  i.e. this code cannot simply be\n * copied and put under another distribution licence\n * [including the GNU Public Licence.]\n */\n\n#ifndef HEADER_OBJECTS_H\n# define HEADER_OBJECTS_H\n\n# define USE_OBJ_MAC\n\n# ifdef USE_OBJ_MAC\n#  include <openssl/obj_mac.h>\n# else\n#  define SN_undef                        \"UNDEF\"\n#  define LN_undef                        \"undefined\"\n#  define NID_undef                       0\n#  define OBJ_undef                       0L\n\n#  define SN_Algorithm                    \"Algorithm\"\n#  define LN_algorithm                    \"algorithm\"\n#  define NID_algorithm                   38\n#  define OBJ_algorithm                   1L,3L,14L,3L,2L\n\n#  define LN_rsadsi                       \"rsadsi\"\n#  define NID_rsadsi                      1\n#  define OBJ_rsadsi                      1L,2L,840L,113549L\n\n#  define LN_pkcs                         \"pkcs\"\n#  define NID_pkcs                        2\n#  define OBJ_pkcs                        OBJ_rsadsi,1L\n\n#  define SN_md2                          \"MD2\"\n#  define LN_md2                          \"md2\"\n#  define NID_md2                         3\n#  define OBJ_md2                         OBJ_rsadsi,2L,2L\n\n#  define SN_md5                          \"MD5\"\n#  define LN_md5                          \"md5\"\n#  define NID_md5                         4\n#  define OBJ_md5                         OBJ_rsadsi,2L,5L\n\n#  define SN_rc4                          \"RC4\"\n#  define LN_rc4                          \"rc4\"\n#  define NID_rc4                         5\n#  define OBJ_rc4                         OBJ_rsadsi,3L,4L\n\n#  define LN_rsaEncryption                \"rsaEncryption\"\n#  define NID_rsaEncryption               6\n#  define OBJ_rsaEncryption               OBJ_pkcs,1L,1L\n\n#  define SN_md2WithRSAEncryption         \"RSA-MD2\"\n#  define LN_md2WithRSAEncryption         \"md2WithRSAEncryption\"\n#  define NID_md2WithRSAEncryption        7\n#  define OBJ_md2WithRSAEncryption        OBJ_pkcs,1L,2L\n\n#  define SN_md5WithRSAEncryption         \"RSA-MD5\"\n#  define LN_md5WithRSAEncryption         \"md5WithRSAEncryption\"\n#  define NID_md5WithRSAEncryption        8\n#  define OBJ_md5WithRSAEncryption        OBJ_pkcs,1L,4L\n\n#  define SN_pbeWithMD2AndDES_CBC         \"PBE-MD2-DES\"\n#  define LN_pbeWithMD2AndDES_CBC         \"pbeWithMD2AndDES-CBC\"\n#  define NID_pbeWithMD2AndDES_CBC        9\n#  define OBJ_pbeWithMD2AndDES_CBC        OBJ_pkcs,5L,1L\n\n#  define SN_pbeWithMD5AndDES_CBC         \"PBE-MD5-DES\"\n#  define LN_pbeWithMD5AndDES_CBC         \"pbeWithMD5AndDES-CBC\"\n#  define NID_pbeWithMD5AndDES_CBC        10\n#  define OBJ_pbeWithMD5AndDES_CBC        OBJ_pkcs,5L,3L\n\n#  define LN_X500                         \"X500\"\n#  define NID_X500                        11\n#  define OBJ_X500                        2L,5L\n\n#  define LN_X509                         \"X509\"\n#  define NID_X509                        12\n#  define OBJ_X509                        OBJ_X500,4L\n\n#  define SN_commonName                   \"CN\"\n#  define LN_commonName                   \"commonName\"\n#  define NID_commonName                  13\n#  define OBJ_commonName                  OBJ_X509,3L\n\n#  define SN_countryName                  \"C\"\n#  define LN_countryName                  \"countryName\"\n#  define NID_countryName                 14\n#  define OBJ_countryName                 OBJ_X509,6L\n\n#  define SN_localityName                 \"L\"\n#  define LN_localityName                 \"localityName\"\n#  define NID_localityName                15\n#  define OBJ_localityName                OBJ_X509,7L\n\n/* Postal Address? PA */\n\n/* should be \"ST\" (rfc1327) but MS uses 'S' */\n#  define SN_stateOrProvinceName          \"ST\"\n#  define LN_stateOrProvinceName          \"stateOrProvinceName\"\n#  define NID_stateOrProvinceName         16\n#  define OBJ_stateOrProvinceName         OBJ_X509,8L\n\n#  define SN_organizationName             \"O\"\n#  define LN_organizationName             \"organizationName\"\n#  define NID_organizationName            17\n#  define OBJ_organizationName            OBJ_X509,10L\n\n#  define SN_organizationalUnitName       \"OU\"\n#  define LN_organizationalUnitName       \"organizationalUnitName\"\n#  define NID_organizationalUnitName      18\n#  define OBJ_organizationalUnitName      OBJ_X509,11L\n\n#  define SN_rsa                          \"RSA\"\n#  define LN_rsa                          \"rsa\"\n#  define NID_rsa                         19\n#  define OBJ_rsa                         OBJ_X500,8L,1L,1L\n\n#  define LN_pkcs7                        \"pkcs7\"\n#  define NID_pkcs7                       20\n#  define OBJ_pkcs7                       OBJ_pkcs,7L\n\n#  define LN_pkcs7_data                   \"pkcs7-data\"\n#  define NID_pkcs7_data                  21\n#  define OBJ_pkcs7_data                  OBJ_pkcs7,1L\n\n#  define LN_pkcs7_signed                 \"pkcs7-signedData\"\n#  define NID_pkcs7_signed                22\n#  define OBJ_pkcs7_signed                OBJ_pkcs7,2L\n\n#  define LN_pkcs7_enveloped              \"pkcs7-envelopedData\"\n#  define NID_pkcs7_enveloped             23\n#  define OBJ_pkcs7_enveloped             OBJ_pkcs7,3L\n\n#  define LN_pkcs7_signedAndEnveloped     \"pkcs7-signedAndEnvelopedData\"\n#  define NID_pkcs7_signedAndEnveloped    24\n#  define OBJ_pkcs7_signedAndEnveloped    OBJ_pkcs7,4L\n\n#  define LN_pkcs7_digest                 \"pkcs7-digestData\"\n#  define NID_pkcs7_digest                25\n#  define OBJ_pkcs7_digest                OBJ_pkcs7,5L\n\n#  define LN_pkcs7_encrypted              \"pkcs7-encryptedData\"\n#  define NID_pkcs7_encrypted             26\n#  define OBJ_pkcs7_encrypted             OBJ_pkcs7,6L\n\n#  define LN_pkcs3                        \"pkcs3\"\n#  define NID_pkcs3                       27\n#  define OBJ_pkcs3                       OBJ_pkcs,3L\n\n#  define LN_dhKeyAgreement               \"dhKeyAgreement\"\n#  define NID_dhKeyAgreement              28\n#  define OBJ_dhKeyAgreement              OBJ_pkcs3,1L\n\n#  define SN_des_ecb                      \"DES-ECB\"\n#  define LN_des_ecb                      \"des-ecb\"\n#  define NID_des_ecb                     29\n#  define OBJ_des_ecb                     OBJ_algorithm,6L\n\n#  define SN_des_cfb64                    \"DES-CFB\"\n#  define LN_des_cfb64                    \"des-cfb\"\n#  define NID_des_cfb64                   30\n/* IV + num */\n#  define OBJ_des_cfb64                   OBJ_algorithm,9L\n\n#  define SN_des_cbc                      \"DES-CBC\"\n#  define LN_des_cbc                      \"des-cbc\"\n#  define NID_des_cbc                     31\n/* IV */\n#  define OBJ_des_cbc                     OBJ_algorithm,7L\n\n#  define SN_des_ede                      \"DES-EDE\"\n#  define LN_des_ede                      \"des-ede\"\n#  define NID_des_ede                     32\n/* ?? */\n#  define OBJ_des_ede                     OBJ_algorithm,17L\n\n#  define SN_des_ede3                     \"DES-EDE3\"\n#  define LN_des_ede3                     \"des-ede3\"\n#  define NID_des_ede3                    33\n\n#  define SN_idea_cbc                     \"IDEA-CBC\"\n#  define LN_idea_cbc                     \"idea-cbc\"\n#  define NID_idea_cbc                    34\n#  define OBJ_idea_cbc                    1L,3L,6L,1L,4L,1L,188L,7L,1L,1L,2L\n\n#  define SN_idea_cfb64                   \"IDEA-CFB\"\n#  define LN_idea_cfb64                   \"idea-cfb\"\n#  define NID_idea_cfb64                  35\n\n#  define SN_idea_ecb                     \"IDEA-ECB\"\n#  define LN_idea_ecb                     \"idea-ecb\"\n#  define NID_idea_ecb                    36\n\n#  define SN_rc2_cbc                      \"RC2-CBC\"\n#  define LN_rc2_cbc                      \"rc2-cbc\"\n#  define NID_rc2_cbc                     37\n#  define OBJ_rc2_cbc                     OBJ_rsadsi,3L,2L\n\n#  define SN_rc2_ecb                      \"RC2-ECB\"\n#  define LN_rc2_ecb                      \"rc2-ecb\"\n#  define NID_rc2_ecb                     38\n\n#  define SN_rc2_cfb64                    \"RC2-CFB\"\n#  define LN_rc2_cfb64                    \"rc2-cfb\"\n#  define NID_rc2_cfb64                   39\n\n#  define SN_rc2_ofb64                    \"RC2-OFB\"\n#  define LN_rc2_ofb64                    \"rc2-ofb\"\n#  define NID_rc2_ofb64                   40\n\n#  define SN_sha                          \"SHA\"\n#  define LN_sha                          \"sha\"\n#  define NID_sha                         41\n#  define OBJ_sha                         OBJ_algorithm,18L\n\n#  define SN_shaWithRSAEncryption         \"RSA-SHA\"\n#  define LN_shaWithRSAEncryption         \"shaWithRSAEncryption\"\n#  define NID_shaWithRSAEncryption        42\n#  define OBJ_shaWithRSAEncryption        OBJ_algorithm,15L\n\n#  define SN_des_ede_cbc                  \"DES-EDE-CBC\"\n#  define LN_des_ede_cbc                  \"des-ede-cbc\"\n#  define NID_des_ede_cbc                 43\n\n#  define SN_des_ede3_cbc                 \"DES-EDE3-CBC\"\n#  define LN_des_ede3_cbc                 \"des-ede3-cbc\"\n#  define NID_des_ede3_cbc                44\n#  define OBJ_des_ede3_cbc                OBJ_rsadsi,3L,7L\n\n#  define SN_des_ofb64                    \"DES-OFB\"\n#  define LN_des_ofb64                    \"des-ofb\"\n#  define NID_des_ofb64                   45\n#  define OBJ_des_ofb64                   OBJ_algorithm,8L\n\n#  define SN_idea_ofb64                   \"IDEA-OFB\"\n#  define LN_idea_ofb64                   \"idea-ofb\"\n#  define NID_idea_ofb64                  46\n\n#  define LN_pkcs9                        \"pkcs9\"\n#  define NID_pkcs9                       47\n#  define OBJ_pkcs9                       OBJ_pkcs,9L\n\n#  define SN_pkcs9_emailAddress           \"Email\"\n#  define LN_pkcs9_emailAddress           \"emailAddress\"\n#  define NID_pkcs9_emailAddress          48\n#  define OBJ_pkcs9_emailAddress          OBJ_pkcs9,1L\n\n#  define LN_pkcs9_unstructuredName       \"unstructuredName\"\n#  define NID_pkcs9_unstructuredName      49\n#  define OBJ_pkcs9_unstructuredName      OBJ_pkcs9,2L\n\n#  define LN_pkcs9_contentType            \"contentType\"\n#  define NID_pkcs9_contentType           50\n#  define OBJ_pkcs9_contentType           OBJ_pkcs9,3L\n\n#  define LN_pkcs9_messageDigest          \"messageDigest\"\n#  define NID_pkcs9_messageDigest         51\n#  define OBJ_pkcs9_messageDigest         OBJ_pkcs9,4L\n\n#  define LN_pkcs9_signingTime            \"signingTime\"\n#  define NID_pkcs9_signingTime           52\n#  define OBJ_pkcs9_signingTime           OBJ_pkcs9,5L\n\n#  define LN_pkcs9_countersignature       \"countersignature\"\n#  define NID_pkcs9_countersignature      53\n#  define OBJ_pkcs9_countersignature      OBJ_pkcs9,6L\n\n#  define LN_pkcs9_challengePassword      \"challengePassword\"\n#  define NID_pkcs9_challengePassword     54\n#  define OBJ_pkcs9_challengePassword     OBJ_pkcs9,7L\n\n#  define LN_pkcs9_unstructuredAddress    \"unstructuredAddress\"\n#  define NID_pkcs9_unstructuredAddress   55\n#  define OBJ_pkcs9_unstructuredAddress   OBJ_pkcs9,8L\n\n#  define LN_pkcs9_extCertAttributes      \"extendedCertificateAttributes\"\n#  define NID_pkcs9_extCertAttributes     56\n#  define OBJ_pkcs9_extCertAttributes     OBJ_pkcs9,9L\n\n#  define SN_netscape                     \"Netscape\"\n#  define LN_netscape                     \"Netscape Communications Corp.\"\n#  define NID_netscape                    57\n#  define OBJ_netscape                    2L,16L,840L,1L,113730L\n\n#  define SN_netscape_cert_extension      \"nsCertExt\"\n#  define LN_netscape_cert_extension      \"Netscape Certificate Extension\"\n#  define NID_netscape_cert_extension     58\n#  define OBJ_netscape_cert_extension     OBJ_netscape,1L\n\n#  define SN_netscape_data_type           \"nsDataType\"\n#  define LN_netscape_data_type           \"Netscape Data Type\"\n#  define NID_netscape_data_type          59\n#  define OBJ_netscape_data_type          OBJ_netscape,2L\n\n#  define SN_des_ede_cfb64                \"DES-EDE-CFB\"\n#  define LN_des_ede_cfb64                \"des-ede-cfb\"\n#  define NID_des_ede_cfb64               60\n\n#  define SN_des_ede3_cfb64               \"DES-EDE3-CFB\"\n#  define LN_des_ede3_cfb64               \"des-ede3-cfb\"\n#  define NID_des_ede3_cfb64              61\n\n#  define SN_des_ede_ofb64                \"DES-EDE-OFB\"\n#  define LN_des_ede_ofb64                \"des-ede-ofb\"\n#  define NID_des_ede_ofb64               62\n\n#  define SN_des_ede3_ofb64               \"DES-EDE3-OFB\"\n#  define LN_des_ede3_ofb64               \"des-ede3-ofb\"\n#  define NID_des_ede3_ofb64              63\n\n/* I'm not sure about the object ID */\n#  define SN_sha1                         \"SHA1\"\n#  define LN_sha1                         \"sha1\"\n#  define NID_sha1                        64\n#  define OBJ_sha1                        OBJ_algorithm,26L\n/* 28 Jun 1996 - eay */\n/* #define OBJ_sha1                     1L,3L,14L,2L,26L,05L <- wrong */\n\n#  define SN_sha1WithRSAEncryption        \"RSA-SHA1\"\n#  define LN_sha1WithRSAEncryption        \"sha1WithRSAEncryption\"\n#  define NID_sha1WithRSAEncryption       65\n#  define OBJ_sha1WithRSAEncryption       OBJ_pkcs,1L,5L\n\n#  define SN_dsaWithSHA                   \"DSA-SHA\"\n#  define LN_dsaWithSHA                   \"dsaWithSHA\"\n#  define NID_dsaWithSHA                  66\n#  define OBJ_dsaWithSHA                  OBJ_algorithm,13L\n\n#  define SN_dsa_2                        \"DSA-old\"\n#  define LN_dsa_2                        \"dsaEncryption-old\"\n#  define NID_dsa_2                       67\n#  define OBJ_dsa_2                       OBJ_algorithm,12L\n\n/* proposed by microsoft to RSA */\n#  define SN_pbeWithSHA1AndRC2_CBC        \"PBE-SHA1-RC2-64\"\n#  define LN_pbeWithSHA1AndRC2_CBC        \"pbeWithSHA1AndRC2-CBC\"\n#  define NID_pbeWithSHA1AndRC2_CBC       68\n#  define OBJ_pbeWithSHA1AndRC2_CBC       OBJ_pkcs,5L,11L\n\n/*\n * proposed by microsoft to RSA as pbeWithSHA1AndRC4: it is now defined\n * explicitly in PKCS#5 v2.0 as id-PBKDF2 which is something completely\n * different.\n */\n#  define LN_id_pbkdf2                    \"PBKDF2\"\n#  define NID_id_pbkdf2                   69\n#  define OBJ_id_pbkdf2                   OBJ_pkcs,5L,12L\n\n#  define SN_dsaWithSHA1_2                \"DSA-SHA1-old\"\n#  define LN_dsaWithSHA1_2                \"dsaWithSHA1-old\"\n#  define NID_dsaWithSHA1_2               70\n/* Got this one from 'sdn706r20.pdf' which is actually an NSA document :-) */\n#  define OBJ_dsaWithSHA1_2               OBJ_algorithm,27L\n\n#  define SN_netscape_cert_type           \"nsCertType\"\n#  define LN_netscape_cert_type           \"Netscape Cert Type\"\n#  define NID_netscape_cert_type          71\n#  define OBJ_netscape_cert_type          OBJ_netscape_cert_extension,1L\n\n#  define SN_netscape_base_url            \"nsBaseUrl\"\n#  define LN_netscape_base_url            \"Netscape Base Url\"\n#  define NID_netscape_base_url           72\n#  define OBJ_netscape_base_url           OBJ_netscape_cert_extension,2L\n\n#  define SN_netscape_revocation_url      \"nsRevocationUrl\"\n#  define LN_netscape_revocation_url      \"Netscape Revocation Url\"\n#  define NID_netscape_revocation_url     73\n#  define OBJ_netscape_revocation_url     OBJ_netscape_cert_extension,3L\n\n#  define SN_netscape_ca_revocation_url   \"nsCaRevocationUrl\"\n#  define LN_netscape_ca_revocation_url   \"Netscape CA Revocation Url\"\n#  define NID_netscape_ca_revocation_url  74\n#  define OBJ_netscape_ca_revocation_url  OBJ_netscape_cert_extension,4L\n\n#  define SN_netscape_renewal_url         \"nsRenewalUrl\"\n#  define LN_netscape_renewal_url         \"Netscape Renewal Url\"\n#  define NID_netscape_renewal_url        75\n#  define OBJ_netscape_renewal_url        OBJ_netscape_cert_extension,7L\n\n#  define SN_netscape_ca_policy_url       \"nsCaPolicyUrl\"\n#  define LN_netscape_ca_policy_url       \"Netscape CA Policy Url\"\n#  define NID_netscape_ca_policy_url      76\n#  define OBJ_netscape_ca_policy_url      OBJ_netscape_cert_extension,8L\n\n#  define SN_netscape_ssl_server_name     \"nsSslServerName\"\n#  define LN_netscape_ssl_server_name     \"Netscape SSL Server Name\"\n#  define NID_netscape_ssl_server_name    77\n#  define OBJ_netscape_ssl_server_name    OBJ_netscape_cert_extension,12L\n\n#  define SN_netscape_comment             \"nsComment\"\n#  define LN_netscape_comment             \"Netscape Comment\"\n#  define NID_netscape_comment            78\n#  define OBJ_netscape_comment            OBJ_netscape_cert_extension,13L\n\n#  define SN_netscape_cert_sequence       \"nsCertSequence\"\n#  define LN_netscape_cert_sequence       \"Netscape Certificate Sequence\"\n#  define NID_netscape_cert_sequence      79\n#  define OBJ_netscape_cert_sequence      OBJ_netscape_data_type,5L\n\n#  define SN_desx_cbc                     \"DESX-CBC\"\n#  define LN_desx_cbc                     \"desx-cbc\"\n#  define NID_desx_cbc                    80\n\n#  define SN_id_ce                        \"id-ce\"\n#  define NID_id_ce                       81\n#  define OBJ_id_ce                       2L,5L,29L\n\n#  define SN_subject_key_identifier       \"subjectKeyIdentifier\"\n#  define LN_subject_key_identifier       \"X509v3 Subject Key Identifier\"\n#  define NID_subject_key_identifier      82\n#  define OBJ_subject_key_identifier      OBJ_id_ce,14L\n\n#  define SN_key_usage                    \"keyUsage\"\n#  define LN_key_usage                    \"X509v3 Key Usage\"\n#  define NID_key_usage                   83\n#  define OBJ_key_usage                   OBJ_id_ce,15L\n\n#  define SN_private_key_usage_period     \"privateKeyUsagePeriod\"\n#  define LN_private_key_usage_period     \"X509v3 Private Key Usage Period\"\n#  define NID_private_key_usage_period    84\n#  define OBJ_private_key_usage_period    OBJ_id_ce,16L\n\n#  define SN_subject_alt_name             \"subjectAltName\"\n#  define LN_subject_alt_name             \"X509v3 Subject Alternative Name\"\n#  define NID_subject_alt_name            85\n#  define OBJ_subject_alt_name            OBJ_id_ce,17L\n\n#  define SN_issuer_alt_name              \"issuerAltName\"\n#  define LN_issuer_alt_name              \"X509v3 Issuer Alternative Name\"\n#  define NID_issuer_alt_name             86\n#  define OBJ_issuer_alt_name             OBJ_id_ce,18L\n\n#  define SN_basic_constraints            \"basicConstraints\"\n#  define LN_basic_constraints            \"X509v3 Basic Constraints\"\n#  define NID_basic_constraints           87\n#  define OBJ_basic_constraints           OBJ_id_ce,19L\n\n#  define SN_crl_number                   \"crlNumber\"\n#  define LN_crl_number                   \"X509v3 CRL Number\"\n#  define NID_crl_number                  88\n#  define OBJ_crl_number                  OBJ_id_ce,20L\n\n#  define SN_certificate_policies         \"certificatePolicies\"\n#  define LN_certificate_policies         \"X509v3 Certificate Policies\"\n#  define NID_certificate_policies        89\n#  define OBJ_certificate_policies        OBJ_id_ce,32L\n\n#  define SN_authority_key_identifier     \"authorityKeyIdentifier\"\n#  define LN_authority_key_identifier     \"X509v3 Authority Key Identifier\"\n#  define NID_authority_key_identifier    90\n#  define OBJ_authority_key_identifier    OBJ_id_ce,35L\n\n#  define SN_bf_cbc                       \"BF-CBC\"\n#  define LN_bf_cbc                       \"bf-cbc\"\n#  define NID_bf_cbc                      91\n#  define OBJ_bf_cbc                      1L,3L,6L,1L,4L,1L,3029L,1L,2L\n\n#  define SN_bf_ecb                       \"BF-ECB\"\n#  define LN_bf_ecb                       \"bf-ecb\"\n#  define NID_bf_ecb                      92\n\n#  define SN_bf_cfb64                     \"BF-CFB\"\n#  define LN_bf_cfb64                     \"bf-cfb\"\n#  define NID_bf_cfb64                    93\n\n#  define SN_bf_ofb64                     \"BF-OFB\"\n#  define LN_bf_ofb64                     \"bf-ofb\"\n#  define NID_bf_ofb64                    94\n\n#  define SN_mdc2                         \"MDC2\"\n#  define LN_mdc2                         \"mdc2\"\n#  define NID_mdc2                        95\n#  define OBJ_mdc2                        2L,5L,8L,3L,101L\n/* An alternative?                      1L,3L,14L,3L,2L,19L */\n\n#  define SN_mdc2WithRSA                  \"RSA-MDC2\"\n#  define LN_mdc2WithRSA                  \"mdc2withRSA\"\n#  define NID_mdc2WithRSA                 96\n#  define OBJ_mdc2WithRSA                 2L,5L,8L,3L,100L\n\n#  define SN_rc4_40                       \"RC4-40\"\n#  define LN_rc4_40                       \"rc4-40\"\n#  define NID_rc4_40                      97\n\n#  define SN_rc2_40_cbc                   \"RC2-40-CBC\"\n#  define LN_rc2_40_cbc                   \"rc2-40-cbc\"\n#  define NID_rc2_40_cbc                  98\n\n#  define SN_givenName                    \"G\"\n#  define LN_givenName                    \"givenName\"\n#  define NID_givenName                   99\n#  define OBJ_givenName                   OBJ_X509,42L\n\n#  define SN_surname                      \"S\"\n#  define LN_surname                      \"surname\"\n#  define NID_surname                     100\n#  define OBJ_surname                     OBJ_X509,4L\n\n#  define SN_initials                     \"I\"\n#  define LN_initials                     \"initials\"\n#  define NID_initials                    101\n#  define OBJ_initials                    OBJ_X509,43L\n\n#  define SN_uniqueIdentifier             \"UID\"\n#  define LN_uniqueIdentifier             \"uniqueIdentifier\"\n#  define NID_uniqueIdentifier            102\n#  define OBJ_uniqueIdentifier            OBJ_X509,45L\n\n#  define SN_crl_distribution_points      \"crlDistributionPoints\"\n#  define LN_crl_distribution_points      \"X509v3 CRL Distribution Points\"\n#  define NID_crl_distribution_points     103\n#  define OBJ_crl_distribution_points     OBJ_id_ce,31L\n\n#  define SN_md5WithRSA                   \"RSA-NP-MD5\"\n#  define LN_md5WithRSA                   \"md5WithRSA\"\n#  define NID_md5WithRSA                  104\n#  define OBJ_md5WithRSA                  OBJ_algorithm,3L\n\n#  define SN_serialNumber                 \"SN\"\n#  define LN_serialNumber                 \"serialNumber\"\n#  define NID_serialNumber                105\n#  define OBJ_serialNumber                OBJ_X509,5L\n\n#  define SN_title                        \"T\"\n#  define LN_title                        \"title\"\n#  define NID_title                       106\n#  define OBJ_title                       OBJ_X509,12L\n\n#  define SN_description                  \"D\"\n#  define LN_description                  \"description\"\n#  define NID_description                 107\n#  define OBJ_description                 OBJ_X509,13L\n\n/* CAST5 is CAST-128, I'm just sticking with the documentation */\n#  define SN_cast5_cbc                    \"CAST5-CBC\"\n#  define LN_cast5_cbc                    \"cast5-cbc\"\n#  define NID_cast5_cbc                   108\n#  define OBJ_cast5_cbc                   1L,2L,840L,113533L,7L,66L,10L\n\n#  define SN_cast5_ecb                    \"CAST5-ECB\"\n#  define LN_cast5_ecb                    \"cast5-ecb\"\n#  define NID_cast5_ecb                   109\n\n#  define SN_cast5_cfb64                  \"CAST5-CFB\"\n#  define LN_cast5_cfb64                  \"cast5-cfb\"\n#  define NID_cast5_cfb64                 110\n\n#  define SN_cast5_ofb64                  \"CAST5-OFB\"\n#  define LN_cast5_ofb64                  \"cast5-ofb\"\n#  define NID_cast5_ofb64                 111\n\n#  define LN_pbeWithMD5AndCast5_CBC       \"pbeWithMD5AndCast5CBC\"\n#  define NID_pbeWithMD5AndCast5_CBC      112\n#  define OBJ_pbeWithMD5AndCast5_CBC      1L,2L,840L,113533L,7L,66L,12L\n\n/*-\n * This is one sun will soon be using :-(\n * id-dsa-with-sha1 ID  ::= {\n *   iso(1) member-body(2) us(840) x9-57 (10040) x9cm(4) 3 }\n */\n#  define SN_dsaWithSHA1                  \"DSA-SHA1\"\n#  define LN_dsaWithSHA1                  \"dsaWithSHA1\"\n#  define NID_dsaWithSHA1                 113\n#  define OBJ_dsaWithSHA1                 1L,2L,840L,10040L,4L,3L\n\n#  define NID_md5_sha1                    114\n#  define SN_md5_sha1                     \"MD5-SHA1\"\n#  define LN_md5_sha1                     \"md5-sha1\"\n\n#  define SN_sha1WithRSA                  \"RSA-SHA1-2\"\n#  define LN_sha1WithRSA                  \"sha1WithRSA\"\n#  define NID_sha1WithRSA                 115\n#  define OBJ_sha1WithRSA                 OBJ_algorithm,29L\n\n#  define SN_dsa                          \"DSA\"\n#  define LN_dsa                          \"dsaEncryption\"\n#  define NID_dsa                         116\n#  define OBJ_dsa                         1L,2L,840L,10040L,4L,1L\n\n#  define SN_ripemd160                    \"RIPEMD160\"\n#  define LN_ripemd160                    \"ripemd160\"\n#  define NID_ripemd160                   117\n#  define OBJ_ripemd160                   1L,3L,36L,3L,2L,1L\n\n/*\n * The name should actually be rsaSignatureWithripemd160, but I'm going to\n * continue using the convention I'm using with the other ciphers\n */\n#  define SN_ripemd160WithRSA             \"RSA-RIPEMD160\"\n#  define LN_ripemd160WithRSA             \"ripemd160WithRSA\"\n#  define NID_ripemd160WithRSA            119\n#  define OBJ_ripemd160WithRSA            1L,3L,36L,3L,3L,1L,2L\n\n/*-\n * Taken from rfc2040\n *  RC5_CBC_Parameters ::= SEQUENCE {\n *      version           INTEGER (v1_0(16)),\n *      rounds            INTEGER (8..127),\n *      blockSizeInBits   INTEGER (64, 128),\n *      iv                OCTET STRING OPTIONAL\n *      }\n */\n#  define SN_rc5_cbc                      \"RC5-CBC\"\n#  define LN_rc5_cbc                      \"rc5-cbc\"\n#  define NID_rc5_cbc                     120\n#  define OBJ_rc5_cbc                     OBJ_rsadsi,3L,8L\n\n#  define SN_rc5_ecb                      \"RC5-ECB\"\n#  define LN_rc5_ecb                      \"rc5-ecb\"\n#  define NID_rc5_ecb                     121\n\n#  define SN_rc5_cfb64                    \"RC5-CFB\"\n#  define LN_rc5_cfb64                    \"rc5-cfb\"\n#  define NID_rc5_cfb64                   122\n\n#  define SN_rc5_ofb64                    \"RC5-OFB\"\n#  define LN_rc5_ofb64                    \"rc5-ofb\"\n#  define NID_rc5_ofb64                   123\n\n#  define SN_rle_compression              \"RLE\"\n#  define LN_rle_compression              \"run length compression\"\n#  define NID_rle_compression             124\n#  define OBJ_rle_compression             1L,1L,1L,1L,666L,1L\n\n#  define SN_zlib_compression             \"ZLIB\"\n#  define LN_zlib_compression             \"zlib compression\"\n#  define NID_zlib_compression            125\n#  define OBJ_zlib_compression            1L,1L,1L,1L,666L,2L\n\n#  define SN_ext_key_usage                \"extendedKeyUsage\"\n#  define LN_ext_key_usage                \"X509v3 Extended Key Usage\"\n#  define NID_ext_key_usage               126\n#  define OBJ_ext_key_usage               OBJ_id_ce,37\n\n#  define SN_id_pkix                      \"PKIX\"\n#  define NID_id_pkix                     127\n#  define OBJ_id_pkix                     1L,3L,6L,1L,5L,5L,7L\n\n#  define SN_id_kp                        \"id-kp\"\n#  define NID_id_kp                       128\n#  define OBJ_id_kp                       OBJ_id_pkix,3L\n\n/* PKIX extended key usage OIDs */\n\n#  define SN_server_auth                  \"serverAuth\"\n#  define LN_server_auth                  \"TLS Web Server Authentication\"\n#  define NID_server_auth                 129\n#  define OBJ_server_auth                 OBJ_id_kp,1L\n\n#  define SN_client_auth                  \"clientAuth\"\n#  define LN_client_auth                  \"TLS Web Client Authentication\"\n#  define NID_client_auth                 130\n#  define OBJ_client_auth                 OBJ_id_kp,2L\n\n#  define SN_code_sign                    \"codeSigning\"\n#  define LN_code_sign                    \"Code Signing\"\n#  define NID_code_sign                   131\n#  define OBJ_code_sign                   OBJ_id_kp,3L\n\n#  define SN_email_protect                \"emailProtection\"\n#  define LN_email_protect                \"E-mail Protection\"\n#  define NID_email_protect               132\n#  define OBJ_email_protect               OBJ_id_kp,4L\n\n#  define SN_time_stamp                   \"timeStamping\"\n#  define LN_time_stamp                   \"Time Stamping\"\n#  define NID_time_stamp                  133\n#  define OBJ_time_stamp                  OBJ_id_kp,8L\n\n/* Additional extended key usage OIDs: Microsoft */\n\n#  define SN_ms_code_ind                  \"msCodeInd\"\n#  define LN_ms_code_ind                  \"Microsoft Individual Code Signing\"\n#  define NID_ms_code_ind                 134\n#  define OBJ_ms_code_ind                 1L,3L,6L,1L,4L,1L,311L,2L,1L,21L\n\n#  define SN_ms_code_com                  \"msCodeCom\"\n#  define LN_ms_code_com                  \"Microsoft Commercial Code Signing\"\n#  define NID_ms_code_com                 135\n#  define OBJ_ms_code_com                 1L,3L,6L,1L,4L,1L,311L,2L,1L,22L\n\n#  define SN_ms_ctl_sign                  \"msCTLSign\"\n#  define LN_ms_ctl_sign                  \"Microsoft Trust List Signing\"\n#  define NID_ms_ctl_sign                 136\n#  define OBJ_ms_ctl_sign                 1L,3L,6L,1L,4L,1L,311L,10L,3L,1L\n\n#  define SN_ms_sgc                       \"msSGC\"\n#  define LN_ms_sgc                       \"Microsoft Server Gated Crypto\"\n#  define NID_ms_sgc                      137\n#  define OBJ_ms_sgc                      1L,3L,6L,1L,4L,1L,311L,10L,3L,3L\n\n#  define SN_ms_efs                       \"msEFS\"\n#  define LN_ms_efs                       \"Microsoft Encrypted File System\"\n#  define NID_ms_efs                      138\n#  define OBJ_ms_efs                      1L,3L,6L,1L,4L,1L,311L,10L,3L,4L\n\n/* Additional usage: Netscape */\n\n#  define SN_ns_sgc                       \"nsSGC\"\n#  define LN_ns_sgc                       \"Netscape Server Gated Crypto\"\n#  define NID_ns_sgc                      139\n#  define OBJ_ns_sgc                      OBJ_netscape,4L,1L\n\n#  define SN_delta_crl                    \"deltaCRL\"\n#  define LN_delta_crl                    \"X509v3 Delta CRL Indicator\"\n#  define NID_delta_crl                   140\n#  define OBJ_delta_crl                   OBJ_id_ce,27L\n\n#  define SN_crl_reason                   \"CRLReason\"\n#  define LN_crl_reason                   \"CRL Reason Code\"\n#  define NID_crl_reason                  141\n#  define OBJ_crl_reason                  OBJ_id_ce,21L\n\n#  define SN_invalidity_date              \"invalidityDate\"\n#  define LN_invalidity_date              \"Invalidity Date\"\n#  define NID_invalidity_date             142\n#  define OBJ_invalidity_date             OBJ_id_ce,24L\n\n#  define SN_sxnet                        \"SXNetID\"\n#  define LN_sxnet                        \"Strong Extranet ID\"\n#  define NID_sxnet                       143\n#  define OBJ_sxnet                       1L,3L,101L,1L,4L,1L\n\n/* PKCS12 and related OBJECT IDENTIFIERS */\n\n#  define OBJ_pkcs12                      OBJ_pkcs,12L\n#  define OBJ_pkcs12_pbeids               OBJ_pkcs12, 1\n\n#  define SN_pbe_WithSHA1And128BitRC4     \"PBE-SHA1-RC4-128\"\n#  define LN_pbe_WithSHA1And128BitRC4     \"pbeWithSHA1And128BitRC4\"\n#  define NID_pbe_WithSHA1And128BitRC4    144\n#  define OBJ_pbe_WithSHA1And128BitRC4    OBJ_pkcs12_pbeids, 1L\n\n#  define SN_pbe_WithSHA1And40BitRC4      \"PBE-SHA1-RC4-40\"\n#  define LN_pbe_WithSHA1And40BitRC4      \"pbeWithSHA1And40BitRC4\"\n#  define NID_pbe_WithSHA1And40BitRC4     145\n#  define OBJ_pbe_WithSHA1And40BitRC4     OBJ_pkcs12_pbeids, 2L\n\n#  define SN_pbe_WithSHA1And3_Key_TripleDES_CBC   \"PBE-SHA1-3DES\"\n#  define LN_pbe_WithSHA1And3_Key_TripleDES_CBC   \"pbeWithSHA1And3-KeyTripleDES-CBC\"\n#  define NID_pbe_WithSHA1And3_Key_TripleDES_CBC  146\n#  define OBJ_pbe_WithSHA1And3_Key_TripleDES_CBC  OBJ_pkcs12_pbeids, 3L\n\n#  define SN_pbe_WithSHA1And2_Key_TripleDES_CBC   \"PBE-SHA1-2DES\"\n#  define LN_pbe_WithSHA1And2_Key_TripleDES_CBC   \"pbeWithSHA1And2-KeyTripleDES-CBC\"\n#  define NID_pbe_WithSHA1And2_Key_TripleDES_CBC  147\n#  define OBJ_pbe_WithSHA1And2_Key_TripleDES_CBC  OBJ_pkcs12_pbeids, 4L\n\n#  define SN_pbe_WithSHA1And128BitRC2_CBC         \"PBE-SHA1-RC2-128\"\n#  define LN_pbe_WithSHA1And128BitRC2_CBC         \"pbeWithSHA1And128BitRC2-CBC\"\n#  define NID_pbe_WithSHA1And128BitRC2_CBC        148\n#  define OBJ_pbe_WithSHA1And128BitRC2_CBC        OBJ_pkcs12_pbeids, 5L\n\n#  define SN_pbe_WithSHA1And40BitRC2_CBC  \"PBE-SHA1-RC2-40\"\n#  define LN_pbe_WithSHA1And40BitRC2_CBC  \"pbeWithSHA1And40BitRC2-CBC\"\n#  define NID_pbe_WithSHA1And40BitRC2_CBC 149\n#  define OBJ_pbe_WithSHA1And40BitRC2_CBC OBJ_pkcs12_pbeids, 6L\n\n#  define OBJ_pkcs12_Version1     OBJ_pkcs12, 10L\n\n#  define OBJ_pkcs12_BagIds       OBJ_pkcs12_Version1, 1L\n\n#  define LN_keyBag               \"keyBag\"\n#  define NID_keyBag              150\n#  define OBJ_keyBag              OBJ_pkcs12_BagIds, 1L\n\n#  define LN_pkcs8ShroudedKeyBag  \"pkcs8ShroudedKeyBag\"\n#  define NID_pkcs8ShroudedKeyBag 151\n#  define OBJ_pkcs8ShroudedKeyBag OBJ_pkcs12_BagIds, 2L\n\n#  define LN_certBag              \"certBag\"\n#  define NID_certBag             152\n#  define OBJ_certBag             OBJ_pkcs12_BagIds, 3L\n\n#  define LN_crlBag               \"crlBag\"\n#  define NID_crlBag              153\n#  define OBJ_crlBag              OBJ_pkcs12_BagIds, 4L\n\n#  define LN_secretBag            \"secretBag\"\n#  define NID_secretBag           154\n#  define OBJ_secretBag           OBJ_pkcs12_BagIds, 5L\n\n#  define LN_safeContentsBag      \"safeContentsBag\"\n#  define NID_safeContentsBag     155\n#  define OBJ_safeContentsBag     OBJ_pkcs12_BagIds, 6L\n\n#  define LN_friendlyName         \"friendlyName\"\n#  define NID_friendlyName        156\n#  define OBJ_friendlyName        OBJ_pkcs9, 20L\n\n#  define LN_localKeyID           \"localKeyID\"\n#  define NID_localKeyID          157\n#  define OBJ_localKeyID          OBJ_pkcs9, 21L\n\n#  define OBJ_certTypes           OBJ_pkcs9, 22L\n\n#  define LN_x509Certificate      \"x509Certificate\"\n#  define NID_x509Certificate     158\n#  define OBJ_x509Certificate     OBJ_certTypes, 1L\n\n#  define LN_sdsiCertificate      \"sdsiCertificate\"\n#  define NID_sdsiCertificate     159\n#  define OBJ_sdsiCertificate     OBJ_certTypes, 2L\n\n#  define OBJ_crlTypes            OBJ_pkcs9, 23L\n\n#  define LN_x509Crl              \"x509Crl\"\n#  define NID_x509Crl             160\n#  define OBJ_x509Crl             OBJ_crlTypes, 1L\n\n/* PKCS#5 v2 OIDs */\n\n#  define LN_pbes2                \"PBES2\"\n#  define NID_pbes2               161\n#  define OBJ_pbes2               OBJ_pkcs,5L,13L\n\n#  define LN_pbmac1               \"PBMAC1\"\n#  define NID_pbmac1              162\n#  define OBJ_pbmac1              OBJ_pkcs,5L,14L\n\n#  define LN_hmacWithSHA1         \"hmacWithSHA1\"\n#  define NID_hmacWithSHA1        163\n#  define OBJ_hmacWithSHA1        OBJ_rsadsi,2L,7L\n\n/* Policy Qualifier Ids */\n\n#  define LN_id_qt_cps            \"Policy Qualifier CPS\"\n#  define SN_id_qt_cps            \"id-qt-cps\"\n#  define NID_id_qt_cps           164\n#  define OBJ_id_qt_cps           OBJ_id_pkix,2L,1L\n\n#  define LN_id_qt_unotice        \"Policy Qualifier User Notice\"\n#  define SN_id_qt_unotice        \"id-qt-unotice\"\n#  define NID_id_qt_unotice       165\n#  define OBJ_id_qt_unotice       OBJ_id_pkix,2L,2L\n\n#  define SN_rc2_64_cbc                   \"RC2-64-CBC\"\n#  define LN_rc2_64_cbc                   \"rc2-64-cbc\"\n#  define NID_rc2_64_cbc                  166\n\n#  define SN_SMIMECapabilities            \"SMIME-CAPS\"\n#  define LN_SMIMECapabilities            \"S/MIME Capabilities\"\n#  define NID_SMIMECapabilities           167\n#  define OBJ_SMIMECapabilities           OBJ_pkcs9,15L\n\n#  define SN_pbeWithMD2AndRC2_CBC         \"PBE-MD2-RC2-64\"\n#  define LN_pbeWithMD2AndRC2_CBC         \"pbeWithMD2AndRC2-CBC\"\n#  define NID_pbeWithMD2AndRC2_CBC        168\n#  define OBJ_pbeWithMD2AndRC2_CBC        OBJ_pkcs,5L,4L\n\n#  define SN_pbeWithMD5AndRC2_CBC         \"PBE-MD5-RC2-64\"\n#  define LN_pbeWithMD5AndRC2_CBC         \"pbeWithMD5AndRC2-CBC\"\n#  define NID_pbeWithMD5AndRC2_CBC        169\n#  define OBJ_pbeWithMD5AndRC2_CBC        OBJ_pkcs,5L,6L\n\n#  define SN_pbeWithSHA1AndDES_CBC        \"PBE-SHA1-DES\"\n#  define LN_pbeWithSHA1AndDES_CBC        \"pbeWithSHA1AndDES-CBC\"\n#  define NID_pbeWithSHA1AndDES_CBC       170\n#  define OBJ_pbeWithSHA1AndDES_CBC       OBJ_pkcs,5L,10L\n\n/* Extension request OIDs */\n\n#  define LN_ms_ext_req                   \"Microsoft Extension Request\"\n#  define SN_ms_ext_req                   \"msExtReq\"\n#  define NID_ms_ext_req                  171\n#  define OBJ_ms_ext_req                  1L,3L,6L,1L,4L,1L,311L,2L,1L,14L\n\n#  define LN_ext_req                      \"Extension Request\"\n#  define SN_ext_req                      \"extReq\"\n#  define NID_ext_req                     172\n#  define OBJ_ext_req                     OBJ_pkcs9,14L\n\n#  define SN_name                         \"name\"\n#  define LN_name                         \"name\"\n#  define NID_name                        173\n#  define OBJ_name                        OBJ_X509,41L\n\n#  define SN_dnQualifier                  \"dnQualifier\"\n#  define LN_dnQualifier                  \"dnQualifier\"\n#  define NID_dnQualifier                 174\n#  define OBJ_dnQualifier                 OBJ_X509,46L\n\n#  define SN_id_pe                        \"id-pe\"\n#  define NID_id_pe                       175\n#  define OBJ_id_pe                       OBJ_id_pkix,1L\n\n#  define SN_id_ad                        \"id-ad\"\n#  define NID_id_ad                       176\n#  define OBJ_id_ad                       OBJ_id_pkix,48L\n\n#  define SN_info_access                  \"authorityInfoAccess\"\n#  define LN_info_access                  \"Authority Information Access\"\n#  define NID_info_access                 177\n#  define OBJ_info_access                 OBJ_id_pe,1L\n\n#  define SN_ad_OCSP                      \"OCSP\"\n#  define LN_ad_OCSP                      \"OCSP\"\n#  define NID_ad_OCSP                     178\n#  define OBJ_ad_OCSP                     OBJ_id_ad,1L\n\n#  define SN_ad_ca_issuers                \"caIssuers\"\n#  define LN_ad_ca_issuers                \"CA Issuers\"\n#  define NID_ad_ca_issuers               179\n#  define OBJ_ad_ca_issuers               OBJ_id_ad,2L\n\n#  define SN_OCSP_sign                    \"OCSPSigning\"\n#  define LN_OCSP_sign                    \"OCSP Signing\"\n#  define NID_OCSP_sign                   180\n#  define OBJ_OCSP_sign                   OBJ_id_kp,9L\n# endif                         /* USE_OBJ_MAC */\n\n# include <openssl/bio.h>\n# include <openssl/asn1.h>\n\n# define OBJ_NAME_TYPE_UNDEF             0x00\n# define OBJ_NAME_TYPE_MD_METH           0x01\n# define OBJ_NAME_TYPE_CIPHER_METH       0x02\n# define OBJ_NAME_TYPE_PKEY_METH         0x03\n# define OBJ_NAME_TYPE_COMP_METH         0x04\n# define OBJ_NAME_TYPE_NUM               0x05\n\n# define OBJ_NAME_ALIAS                  0x8000\n\n# define OBJ_BSEARCH_VALUE_ON_NOMATCH            0x01\n# define OBJ_BSEARCH_FIRST_VALUE_ON_MATCH        0x02\n\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\ntypedef struct obj_name_st {\n    int type;\n    int alias;\n    const char *name;\n    const char *data;\n} OBJ_NAME;\n\n# define         OBJ_create_and_add_object(a,b,c) OBJ_create(a,b,c)\n\nint OBJ_NAME_init(void);\nint OBJ_NAME_new_index(unsigned long (*hash_func) (const char *),\n                       int (*cmp_func) (const char *, const char *),\n                       void (*free_func) (const char *, int, const char *));\nconst char *OBJ_NAME_get(const char *name, int type);\nint OBJ_NAME_add(const char *name, int type, const char *data);\nint OBJ_NAME_remove(const char *name, int type);\nvoid OBJ_NAME_cleanup(int type); /* -1 for everything */\nvoid OBJ_NAME_do_all(int type, void (*fn) (const OBJ_NAME *, void *arg),\n                     void *arg);\nvoid OBJ_NAME_do_all_sorted(int type,\n                            void (*fn) (const OBJ_NAME *, void *arg),\n                            void *arg);\n\nASN1_OBJECT *OBJ_dup(const ASN1_OBJECT *o);\nASN1_OBJECT *OBJ_nid2obj(int n);\nconst char *OBJ_nid2ln(int n);\nconst char *OBJ_nid2sn(int n);\nint OBJ_obj2nid(const ASN1_OBJECT *o);\nASN1_OBJECT *OBJ_txt2obj(const char *s, int no_name);\nint OBJ_obj2txt(char *buf, int buf_len, const ASN1_OBJECT *a, int no_name);\nint OBJ_txt2nid(const char *s);\nint OBJ_ln2nid(const char *s);\nint OBJ_sn2nid(const char *s);\nint OBJ_cmp(const ASN1_OBJECT *a, const ASN1_OBJECT *b);\nconst void *OBJ_bsearch_(const void *key, const void *base, int num, int size,\n                         int (*cmp) (const void *, const void *));\nconst void *OBJ_bsearch_ex_(const void *key, const void *base, int num,\n                            int size,\n                            int (*cmp) (const void *, const void *),\n                            int flags);\n\n# define _DECLARE_OBJ_BSEARCH_CMP_FN(scope, type1, type2, nm)    \\\n  static int nm##_cmp_BSEARCH_CMP_FN(const void *, const void *); \\\n  static int nm##_cmp(type1 const *, type2 const *); \\\n  scope type2 * OBJ_bsearch_##nm(type1 *key, type2 const *base, int num)\n\n# define DECLARE_OBJ_BSEARCH_CMP_FN(type1, type2, cmp)   \\\n  _DECLARE_OBJ_BSEARCH_CMP_FN(static, type1, type2, cmp)\n# define DECLARE_OBJ_BSEARCH_GLOBAL_CMP_FN(type1, type2, nm)     \\\n  type2 * OBJ_bsearch_##nm(type1 *key, type2 const *base, int num)\n\n/*-\n * Unsolved problem: if a type is actually a pointer type, like\n * nid_triple is, then its impossible to get a const where you need\n * it. Consider:\n *\n * typedef int nid_triple[3];\n * const void *a_;\n * const nid_triple const *a = a_;\n *\n * The assignement discards a const because what you really want is:\n *\n * const int const * const *a = a_;\n *\n * But if you do that, you lose the fact that a is an array of 3 ints,\n * which breaks comparison functions.\n *\n * Thus we end up having to cast, sadly, or unpack the\n * declarations. Or, as I finally did in this case, delcare nid_triple\n * to be a struct, which it should have been in the first place.\n *\n * Ben, August 2008.\n *\n * Also, strictly speaking not all types need be const, but handling\n * the non-constness means a lot of complication, and in practice\n * comparison routines do always not touch their arguments.\n */\n\n# define IMPLEMENT_OBJ_BSEARCH_CMP_FN(type1, type2, nm)  \\\n  static int nm##_cmp_BSEARCH_CMP_FN(const void *a_, const void *b_)    \\\n      { \\\n      type1 const *a = a_; \\\n      type2 const *b = b_; \\\n      return nm##_cmp(a,b); \\\n      } \\\n  static type2 *OBJ_bsearch_##nm(type1 *key, type2 const *base, int num) \\\n      { \\\n      return (type2 *)OBJ_bsearch_(key, base, num, sizeof(type2), \\\n                                        nm##_cmp_BSEARCH_CMP_FN); \\\n      } \\\n      extern void dummy_prototype(void)\n\n# define IMPLEMENT_OBJ_BSEARCH_GLOBAL_CMP_FN(type1, type2, nm)   \\\n  static int nm##_cmp_BSEARCH_CMP_FN(const void *a_, const void *b_)    \\\n      { \\\n      type1 const *a = a_; \\\n      type2 const *b = b_; \\\n      return nm##_cmp(a,b); \\\n      } \\\n  type2 *OBJ_bsearch_##nm(type1 *key, type2 const *base, int num) \\\n      { \\\n      return (type2 *)OBJ_bsearch_(key, base, num, sizeof(type2), \\\n                                        nm##_cmp_BSEARCH_CMP_FN); \\\n      } \\\n      extern void dummy_prototype(void)\n\n# define OBJ_bsearch(type1,key,type2,base,num,cmp)                              \\\n  ((type2 *)OBJ_bsearch_(CHECKED_PTR_OF(type1,key),CHECKED_PTR_OF(type2,base), \\\n                         num,sizeof(type2),                             \\\n                         ((void)CHECKED_PTR_OF(type1,cmp##_type_1),     \\\n                          (void)CHECKED_PTR_OF(type2,cmp##_type_2),     \\\n                          cmp##_BSEARCH_CMP_FN)))\n\n# define OBJ_bsearch_ex(type1,key,type2,base,num,cmp,flags)                      \\\n  ((type2 *)OBJ_bsearch_ex_(CHECKED_PTR_OF(type1,key),CHECKED_PTR_OF(type2,base), \\\n                         num,sizeof(type2),                             \\\n                         ((void)CHECKED_PTR_OF(type1,cmp##_type_1),     \\\n                          (void)type_2=CHECKED_PTR_OF(type2,cmp##_type_2), \\\n                          cmp##_BSEARCH_CMP_FN)),flags)\n\nint OBJ_new_nid(int num);\nint OBJ_add_object(const ASN1_OBJECT *obj);\nint OBJ_create(const char *oid, const char *sn, const char *ln);\nvoid OBJ_cleanup(void);\nint OBJ_create_objects(BIO *in);\n\nint OBJ_find_sigid_algs(int signid, int *pdig_nid, int *ppkey_nid);\nint OBJ_find_sigid_by_algs(int *psignid, int dig_nid, int pkey_nid);\nint OBJ_add_sigid(int signid, int dig_id, int pkey_id);\nvoid OBJ_sigid_free(void);\n\nextern int obj_cleanup_defer;\nvoid check_defer(int nid);\n\n/* BEGIN ERROR CODES */\n/*\n * The following lines are auto generated by the script mkerr.pl. Any changes\n * made after this point may be overwritten when the script is next run.\n */\nvoid ERR_load_OBJ_strings(void);\n\n/* Error codes for the OBJ functions. */\n\n/* Function codes. */\n# define OBJ_F_OBJ_ADD_OBJECT                             105\n# define OBJ_F_OBJ_CREATE                                 100\n# define OBJ_F_OBJ_DUP                                    101\n# define OBJ_F_OBJ_NAME_NEW_INDEX                         106\n# define OBJ_F_OBJ_NID2LN                                 102\n# define OBJ_F_OBJ_NID2OBJ                                103\n# define OBJ_F_OBJ_NID2SN                                 104\n\n/* Reason codes. */\n# define OBJ_R_MALLOC_FAILURE                             100\n# define OBJ_R_UNKNOWN_NID                                101\n\n#ifdef  __cplusplus\n}\n#endif\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/arm/include/openssl/ocsp.h",
    "content": "/* ocsp.h */\n/*\n * Written by Tom Titchener <Tom_Titchener@groove.net> for the OpenSSL\n * project.\n */\n\n/*\n * History: This file was transfered to Richard Levitte from CertCo by Kathy\n * Weinhold in mid-spring 2000 to be included in OpenSSL or released as a\n * patch kit.\n */\n\n/* ====================================================================\n * Copyright (c) 1998-2000 The OpenSSL Project.  All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n *\n * 1. Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n *\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in\n *    the documentation and/or other materials provided with the\n *    distribution.\n *\n * 3. All advertising materials mentioning features or use of this\n *    software must display the following acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit. (http://www.openssl.org/)\"\n *\n * 4. The names \"OpenSSL Toolkit\" and \"OpenSSL Project\" must not be used to\n *    endorse or promote products derived from this software without\n *    prior written permission. For written permission, please contact\n *    openssl-core@openssl.org.\n *\n * 5. Products derived from this software may not be called \"OpenSSL\"\n *    nor may \"OpenSSL\" appear in their names without prior written\n *    permission of the OpenSSL Project.\n *\n * 6. Redistributions of any form whatsoever must retain the following\n *    acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit (http://www.openssl.org/)\"\n *\n * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY\n * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\n * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR\n * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\n * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,\n * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED\n * OF THE POSSIBILITY OF SUCH DAMAGE.\n * ====================================================================\n *\n * This product includes cryptographic software written by Eric Young\n * (eay@cryptsoft.com).  This product includes software written by Tim\n * Hudson (tjh@cryptsoft.com).\n *\n */\n\n#ifndef HEADER_OCSP_H\n# define HEADER_OCSP_H\n\n# include <openssl/ossl_typ.h>\n# include <openssl/x509.h>\n# include <openssl/x509v3.h>\n# include <openssl/safestack.h>\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n/* Various flags and values */\n\n# define OCSP_DEFAULT_NONCE_LENGTH       16\n\n# define OCSP_NOCERTS                    0x1\n# define OCSP_NOINTERN                   0x2\n# define OCSP_NOSIGS                     0x4\n# define OCSP_NOCHAIN                    0x8\n# define OCSP_NOVERIFY                   0x10\n# define OCSP_NOEXPLICIT                 0x20\n# define OCSP_NOCASIGN                   0x40\n# define OCSP_NODELEGATED                0x80\n# define OCSP_NOCHECKS                   0x100\n# define OCSP_TRUSTOTHER                 0x200\n# define OCSP_RESPID_KEY                 0x400\n# define OCSP_NOTIME                     0x800\n\n/*-  CertID ::= SEQUENCE {\n *       hashAlgorithm            AlgorithmIdentifier,\n *       issuerNameHash     OCTET STRING, -- Hash of Issuer's DN\n *       issuerKeyHash      OCTET STRING, -- Hash of Issuers public key (excluding the tag & length fields)\n *       serialNumber       CertificateSerialNumber }\n */\ntypedef struct ocsp_cert_id_st {\n    X509_ALGOR *hashAlgorithm;\n    ASN1_OCTET_STRING *issuerNameHash;\n    ASN1_OCTET_STRING *issuerKeyHash;\n    ASN1_INTEGER *serialNumber;\n} OCSP_CERTID;\n\nDECLARE_STACK_OF(OCSP_CERTID)\n\n/*-  Request ::=     SEQUENCE {\n *       reqCert                    CertID,\n *       singleRequestExtensions    [0] EXPLICIT Extensions OPTIONAL }\n */\ntypedef struct ocsp_one_request_st {\n    OCSP_CERTID *reqCert;\n    STACK_OF(X509_EXTENSION) *singleRequestExtensions;\n} OCSP_ONEREQ;\n\nDECLARE_STACK_OF(OCSP_ONEREQ)\nDECLARE_ASN1_SET_OF(OCSP_ONEREQ)\n\n/*-  TBSRequest      ::=     SEQUENCE {\n *       version             [0] EXPLICIT Version DEFAULT v1,\n *       requestorName       [1] EXPLICIT GeneralName OPTIONAL,\n *       requestList             SEQUENCE OF Request,\n *       requestExtensions   [2] EXPLICIT Extensions OPTIONAL }\n */\ntypedef struct ocsp_req_info_st {\n    ASN1_INTEGER *version;\n    GENERAL_NAME *requestorName;\n    STACK_OF(OCSP_ONEREQ) *requestList;\n    STACK_OF(X509_EXTENSION) *requestExtensions;\n} OCSP_REQINFO;\n\n/*-  Signature       ::=     SEQUENCE {\n *       signatureAlgorithm   AlgorithmIdentifier,\n *       signature            BIT STRING,\n *       certs                [0] EXPLICIT SEQUENCE OF Certificate OPTIONAL }\n */\ntypedef struct ocsp_signature_st {\n    X509_ALGOR *signatureAlgorithm;\n    ASN1_BIT_STRING *signature;\n    STACK_OF(X509) *certs;\n} OCSP_SIGNATURE;\n\n/*-  OCSPRequest     ::=     SEQUENCE {\n *       tbsRequest                  TBSRequest,\n *       optionalSignature   [0]     EXPLICIT Signature OPTIONAL }\n */\ntypedef struct ocsp_request_st {\n    OCSP_REQINFO *tbsRequest;\n    OCSP_SIGNATURE *optionalSignature; /* OPTIONAL */\n} OCSP_REQUEST;\n\n/*-  OCSPResponseStatus ::= ENUMERATED {\n *       successful            (0),      --Response has valid confirmations\n *       malformedRequest      (1),      --Illegal confirmation request\n *       internalError         (2),      --Internal error in issuer\n *       tryLater              (3),      --Try again later\n *                                       --(4) is not used\n *       sigRequired           (5),      --Must sign the request\n *       unauthorized          (6)       --Request unauthorized\n *   }\n */\n# define OCSP_RESPONSE_STATUS_SUCCESSFUL          0\n# define OCSP_RESPONSE_STATUS_MALFORMEDREQUEST     1\n# define OCSP_RESPONSE_STATUS_INTERNALERROR        2\n# define OCSP_RESPONSE_STATUS_TRYLATER             3\n# define OCSP_RESPONSE_STATUS_SIGREQUIRED          5\n# define OCSP_RESPONSE_STATUS_UNAUTHORIZED         6\n\n/*-  ResponseBytes ::=       SEQUENCE {\n *       responseType   OBJECT IDENTIFIER,\n *       response       OCTET STRING }\n */\ntypedef struct ocsp_resp_bytes_st {\n    ASN1_OBJECT *responseType;\n    ASN1_OCTET_STRING *response;\n} OCSP_RESPBYTES;\n\n/*-  OCSPResponse ::= SEQUENCE {\n *      responseStatus         OCSPResponseStatus,\n *      responseBytes          [0] EXPLICIT ResponseBytes OPTIONAL }\n */\nstruct ocsp_response_st {\n    ASN1_ENUMERATED *responseStatus;\n    OCSP_RESPBYTES *responseBytes;\n};\n\n/*-  ResponderID ::= CHOICE {\n *      byName   [1] Name,\n *      byKey    [2] KeyHash }\n */\n# define V_OCSP_RESPID_NAME 0\n# define V_OCSP_RESPID_KEY  1\nstruct ocsp_responder_id_st {\n    int type;\n    union {\n        X509_NAME *byName;\n        ASN1_OCTET_STRING *byKey;\n    } value;\n};\n\nDECLARE_STACK_OF(OCSP_RESPID)\nDECLARE_ASN1_FUNCTIONS(OCSP_RESPID)\n\n/*-  KeyHash ::= OCTET STRING --SHA-1 hash of responder's public key\n *                            --(excluding the tag and length fields)\n */\n\n/*-  RevokedInfo ::= SEQUENCE {\n *       revocationTime              GeneralizedTime,\n *       revocationReason    [0]     EXPLICIT CRLReason OPTIONAL }\n */\ntypedef struct ocsp_revoked_info_st {\n    ASN1_GENERALIZEDTIME *revocationTime;\n    ASN1_ENUMERATED *revocationReason;\n} OCSP_REVOKEDINFO;\n\n/*-  CertStatus ::= CHOICE {\n *       good                [0]     IMPLICIT NULL,\n *       revoked             [1]     IMPLICIT RevokedInfo,\n *       unknown             [2]     IMPLICIT UnknownInfo }\n */\n# define V_OCSP_CERTSTATUS_GOOD    0\n# define V_OCSP_CERTSTATUS_REVOKED 1\n# define V_OCSP_CERTSTATUS_UNKNOWN 2\ntypedef struct ocsp_cert_status_st {\n    int type;\n    union {\n        ASN1_NULL *good;\n        OCSP_REVOKEDINFO *revoked;\n        ASN1_NULL *unknown;\n    } value;\n} OCSP_CERTSTATUS;\n\n/*-  SingleResponse ::= SEQUENCE {\n *      certID                       CertID,\n *      certStatus                   CertStatus,\n *      thisUpdate                   GeneralizedTime,\n *      nextUpdate           [0]     EXPLICIT GeneralizedTime OPTIONAL,\n *      singleExtensions     [1]     EXPLICIT Extensions OPTIONAL }\n */\ntypedef struct ocsp_single_response_st {\n    OCSP_CERTID *certId;\n    OCSP_CERTSTATUS *certStatus;\n    ASN1_GENERALIZEDTIME *thisUpdate;\n    ASN1_GENERALIZEDTIME *nextUpdate;\n    STACK_OF(X509_EXTENSION) *singleExtensions;\n} OCSP_SINGLERESP;\n\nDECLARE_STACK_OF(OCSP_SINGLERESP)\nDECLARE_ASN1_SET_OF(OCSP_SINGLERESP)\n\n/*-  ResponseData ::= SEQUENCE {\n *      version              [0] EXPLICIT Version DEFAULT v1,\n *      responderID              ResponderID,\n *      producedAt               GeneralizedTime,\n *      responses                SEQUENCE OF SingleResponse,\n *      responseExtensions   [1] EXPLICIT Extensions OPTIONAL }\n */\ntypedef struct ocsp_response_data_st {\n    ASN1_INTEGER *version;\n    OCSP_RESPID *responderId;\n    ASN1_GENERALIZEDTIME *producedAt;\n    STACK_OF(OCSP_SINGLERESP) *responses;\n    STACK_OF(X509_EXTENSION) *responseExtensions;\n} OCSP_RESPDATA;\n\n/*-  BasicOCSPResponse       ::= SEQUENCE {\n *      tbsResponseData      ResponseData,\n *      signatureAlgorithm   AlgorithmIdentifier,\n *      signature            BIT STRING,\n *      certs                [0] EXPLICIT SEQUENCE OF Certificate OPTIONAL }\n */\n  /*\n   * Note 1: The value for \"signature\" is specified in the OCSP rfc2560 as\n   * follows: \"The value for the signature SHALL be computed on the hash of\n   * the DER encoding ResponseData.\" This means that you must hash the\n   * DER-encoded tbsResponseData, and then run it through a crypto-signing\n   * function, which will (at least w/RSA) do a hash-'n'-private-encrypt\n   * operation.  This seems a bit odd, but that's the spec.  Also note that\n   * the data structures do not leave anywhere to independently specify the\n   * algorithm used for the initial hash. So, we look at the\n   * signature-specification algorithm, and try to do something intelligent.\n   * -- Kathy Weinhold, CertCo\n   */\n  /*\n   * Note 2: It seems that the mentioned passage from RFC 2560 (section\n   * 4.2.1) is open for interpretation.  I've done tests against another\n   * responder, and found that it doesn't do the double hashing that the RFC\n   * seems to say one should.  Therefore, all relevant functions take a flag\n   * saying which variant should be used.  -- Richard Levitte, OpenSSL team\n   * and CeloCom\n   */\ntypedef struct ocsp_basic_response_st {\n    OCSP_RESPDATA *tbsResponseData;\n    X509_ALGOR *signatureAlgorithm;\n    ASN1_BIT_STRING *signature;\n    STACK_OF(X509) *certs;\n} OCSP_BASICRESP;\n\n/*-\n *   CRLReason ::= ENUMERATED {\n *        unspecified             (0),\n *        keyCompromise           (1),\n *        cACompromise            (2),\n *        affiliationChanged      (3),\n *        superseded              (4),\n *        cessationOfOperation    (5),\n *        certificateHold         (6),\n *        removeFromCRL           (8) }\n */\n# define OCSP_REVOKED_STATUS_NOSTATUS               -1\n# define OCSP_REVOKED_STATUS_UNSPECIFIED             0\n# define OCSP_REVOKED_STATUS_KEYCOMPROMISE           1\n# define OCSP_REVOKED_STATUS_CACOMPROMISE            2\n# define OCSP_REVOKED_STATUS_AFFILIATIONCHANGED      3\n# define OCSP_REVOKED_STATUS_SUPERSEDED              4\n# define OCSP_REVOKED_STATUS_CESSATIONOFOPERATION    5\n# define OCSP_REVOKED_STATUS_CERTIFICATEHOLD         6\n# define OCSP_REVOKED_STATUS_REMOVEFROMCRL           8\n\n/*-\n * CrlID ::= SEQUENCE {\n *     crlUrl               [0]     EXPLICIT IA5String OPTIONAL,\n *     crlNum               [1]     EXPLICIT INTEGER OPTIONAL,\n *     crlTime              [2]     EXPLICIT GeneralizedTime OPTIONAL }\n */\ntypedef struct ocsp_crl_id_st {\n    ASN1_IA5STRING *crlUrl;\n    ASN1_INTEGER *crlNum;\n    ASN1_GENERALIZEDTIME *crlTime;\n} OCSP_CRLID;\n\n/*-\n * ServiceLocator ::= SEQUENCE {\n *      issuer    Name,\n *      locator   AuthorityInfoAccessSyntax OPTIONAL }\n */\ntypedef struct ocsp_service_locator_st {\n    X509_NAME *issuer;\n    STACK_OF(ACCESS_DESCRIPTION) *locator;\n} OCSP_SERVICELOC;\n\n# define PEM_STRING_OCSP_REQUEST \"OCSP REQUEST\"\n# define PEM_STRING_OCSP_RESPONSE \"OCSP RESPONSE\"\n\n# define d2i_OCSP_REQUEST_bio(bp,p) ASN1_d2i_bio_of(OCSP_REQUEST,OCSP_REQUEST_new,d2i_OCSP_REQUEST,bp,p)\n\n# define d2i_OCSP_RESPONSE_bio(bp,p) ASN1_d2i_bio_of(OCSP_RESPONSE,OCSP_RESPONSE_new,d2i_OCSP_RESPONSE,bp,p)\n\n# define PEM_read_bio_OCSP_REQUEST(bp,x,cb) (OCSP_REQUEST *)PEM_ASN1_read_bio( \\\n     (char *(*)())d2i_OCSP_REQUEST,PEM_STRING_OCSP_REQUEST,bp,(char **)x,cb,NULL)\n\n# define PEM_read_bio_OCSP_RESPONSE(bp,x,cb)(OCSP_RESPONSE *)PEM_ASN1_read_bio(\\\n     (char *(*)())d2i_OCSP_RESPONSE,PEM_STRING_OCSP_RESPONSE,bp,(char **)x,cb,NULL)\n\n# define PEM_write_bio_OCSP_REQUEST(bp,o) \\\n    PEM_ASN1_write_bio((int (*)())i2d_OCSP_REQUEST,PEM_STRING_OCSP_REQUEST,\\\n                        bp,(char *)o, NULL,NULL,0,NULL,NULL)\n\n# define PEM_write_bio_OCSP_RESPONSE(bp,o) \\\n    PEM_ASN1_write_bio((int (*)())i2d_OCSP_RESPONSE,PEM_STRING_OCSP_RESPONSE,\\\n                        bp,(char *)o, NULL,NULL,0,NULL,NULL)\n\n# define i2d_OCSP_RESPONSE_bio(bp,o) ASN1_i2d_bio_of(OCSP_RESPONSE,i2d_OCSP_RESPONSE,bp,o)\n\n# define i2d_OCSP_REQUEST_bio(bp,o) ASN1_i2d_bio_of(OCSP_REQUEST,i2d_OCSP_REQUEST,bp,o)\n\n# define OCSP_REQUEST_sign(o,pkey,md) \\\n        ASN1_item_sign(ASN1_ITEM_rptr(OCSP_REQINFO),\\\n                o->optionalSignature->signatureAlgorithm,NULL,\\\n                o->optionalSignature->signature,o->tbsRequest,pkey,md)\n\n# define OCSP_BASICRESP_sign(o,pkey,md,d) \\\n        ASN1_item_sign(ASN1_ITEM_rptr(OCSP_RESPDATA),o->signatureAlgorithm,NULL,\\\n                o->signature,o->tbsResponseData,pkey,md)\n\n# define OCSP_REQUEST_verify(a,r) ASN1_item_verify(ASN1_ITEM_rptr(OCSP_REQINFO),\\\n        a->optionalSignature->signatureAlgorithm,\\\n        a->optionalSignature->signature,a->tbsRequest,r)\n\n# define OCSP_BASICRESP_verify(a,r,d) ASN1_item_verify(ASN1_ITEM_rptr(OCSP_RESPDATA),\\\n        a->signatureAlgorithm,a->signature,a->tbsResponseData,r)\n\n# define ASN1_BIT_STRING_digest(data,type,md,len) \\\n        ASN1_item_digest(ASN1_ITEM_rptr(ASN1_BIT_STRING),type,data,md,len)\n\n# define OCSP_CERTSTATUS_dup(cs)\\\n                (OCSP_CERTSTATUS*)ASN1_dup((int(*)())i2d_OCSP_CERTSTATUS,\\\n                (char *(*)())d2i_OCSP_CERTSTATUS,(char *)(cs))\n\nOCSP_CERTID *OCSP_CERTID_dup(OCSP_CERTID *id);\n\nOCSP_RESPONSE *OCSP_sendreq_bio(BIO *b, const char *path, OCSP_REQUEST *req);\nOCSP_REQ_CTX *OCSP_sendreq_new(BIO *io, const char *path, OCSP_REQUEST *req,\n                               int maxline);\nint OCSP_REQ_CTX_nbio(OCSP_REQ_CTX *rctx);\nint OCSP_sendreq_nbio(OCSP_RESPONSE **presp, OCSP_REQ_CTX *rctx);\nOCSP_REQ_CTX *OCSP_REQ_CTX_new(BIO *io, int maxline);\nvoid OCSP_REQ_CTX_free(OCSP_REQ_CTX *rctx);\nvoid OCSP_set_max_response_length(OCSP_REQ_CTX *rctx, unsigned long len);\nint OCSP_REQ_CTX_i2d(OCSP_REQ_CTX *rctx, const ASN1_ITEM *it,\n                     ASN1_VALUE *val);\nint OCSP_REQ_CTX_nbio_d2i(OCSP_REQ_CTX *rctx, ASN1_VALUE **pval,\n                          const ASN1_ITEM *it);\nBIO *OCSP_REQ_CTX_get0_mem_bio(OCSP_REQ_CTX *rctx);\nint OCSP_REQ_CTX_i2d(OCSP_REQ_CTX *rctx, const ASN1_ITEM *it,\n                     ASN1_VALUE *val);\nint OCSP_REQ_CTX_http(OCSP_REQ_CTX *rctx, const char *op, const char *path);\nint OCSP_REQ_CTX_set1_req(OCSP_REQ_CTX *rctx, OCSP_REQUEST *req);\nint OCSP_REQ_CTX_add1_header(OCSP_REQ_CTX *rctx,\n                             const char *name, const char *value);\n\nOCSP_CERTID *OCSP_cert_to_id(const EVP_MD *dgst, X509 *subject, X509 *issuer);\n\nOCSP_CERTID *OCSP_cert_id_new(const EVP_MD *dgst,\n                              X509_NAME *issuerName,\n                              ASN1_BIT_STRING *issuerKey,\n                              ASN1_INTEGER *serialNumber);\n\nOCSP_ONEREQ *OCSP_request_add0_id(OCSP_REQUEST *req, OCSP_CERTID *cid);\n\nint OCSP_request_add1_nonce(OCSP_REQUEST *req, unsigned char *val, int len);\nint OCSP_basic_add1_nonce(OCSP_BASICRESP *resp, unsigned char *val, int len);\nint OCSP_check_nonce(OCSP_REQUEST *req, OCSP_BASICRESP *bs);\nint OCSP_copy_nonce(OCSP_BASICRESP *resp, OCSP_REQUEST *req);\n\nint OCSP_request_set1_name(OCSP_REQUEST *req, X509_NAME *nm);\nint OCSP_request_add1_cert(OCSP_REQUEST *req, X509 *cert);\n\nint OCSP_request_sign(OCSP_REQUEST *req,\n                      X509 *signer,\n                      EVP_PKEY *key,\n                      const EVP_MD *dgst,\n                      STACK_OF(X509) *certs, unsigned long flags);\n\nint OCSP_response_status(OCSP_RESPONSE *resp);\nOCSP_BASICRESP *OCSP_response_get1_basic(OCSP_RESPONSE *resp);\n\nint OCSP_resp_count(OCSP_BASICRESP *bs);\nOCSP_SINGLERESP *OCSP_resp_get0(OCSP_BASICRESP *bs, int idx);\nint OCSP_resp_find(OCSP_BASICRESP *bs, OCSP_CERTID *id, int last);\nint OCSP_single_get0_status(OCSP_SINGLERESP *single, int *reason,\n                            ASN1_GENERALIZEDTIME **revtime,\n                            ASN1_GENERALIZEDTIME **thisupd,\n                            ASN1_GENERALIZEDTIME **nextupd);\nint OCSP_resp_find_status(OCSP_BASICRESP *bs, OCSP_CERTID *id, int *status,\n                          int *reason,\n                          ASN1_GENERALIZEDTIME **revtime,\n                          ASN1_GENERALIZEDTIME **thisupd,\n                          ASN1_GENERALIZEDTIME **nextupd);\nint OCSP_check_validity(ASN1_GENERALIZEDTIME *thisupd,\n                        ASN1_GENERALIZEDTIME *nextupd, long sec, long maxsec);\n\nint OCSP_request_verify(OCSP_REQUEST *req, STACK_OF(X509) *certs,\n                        X509_STORE *store, unsigned long flags);\n\nint OCSP_parse_url(const char *url, char **phost, char **pport, char **ppath,\n                   int *pssl);\n\nint OCSP_id_issuer_cmp(OCSP_CERTID *a, OCSP_CERTID *b);\nint OCSP_id_cmp(OCSP_CERTID *a, OCSP_CERTID *b);\n\nint OCSP_request_onereq_count(OCSP_REQUEST *req);\nOCSP_ONEREQ *OCSP_request_onereq_get0(OCSP_REQUEST *req, int i);\nOCSP_CERTID *OCSP_onereq_get0_id(OCSP_ONEREQ *one);\nint OCSP_id_get0_info(ASN1_OCTET_STRING **piNameHash, ASN1_OBJECT **pmd,\n                      ASN1_OCTET_STRING **pikeyHash,\n                      ASN1_INTEGER **pserial, OCSP_CERTID *cid);\nint OCSP_request_is_signed(OCSP_REQUEST *req);\nOCSP_RESPONSE *OCSP_response_create(int status, OCSP_BASICRESP *bs);\nOCSP_SINGLERESP *OCSP_basic_add1_status(OCSP_BASICRESP *rsp,\n                                        OCSP_CERTID *cid,\n                                        int status, int reason,\n                                        ASN1_TIME *revtime,\n                                        ASN1_TIME *thisupd,\n                                        ASN1_TIME *nextupd);\nint OCSP_basic_add1_cert(OCSP_BASICRESP *resp, X509 *cert);\nint OCSP_basic_sign(OCSP_BASICRESP *brsp,\n                    X509 *signer, EVP_PKEY *key, const EVP_MD *dgst,\n                    STACK_OF(X509) *certs, unsigned long flags);\n\nX509_EXTENSION *OCSP_crlID_new(char *url, long *n, char *tim);\n\nX509_EXTENSION *OCSP_accept_responses_new(char **oids);\n\nX509_EXTENSION *OCSP_archive_cutoff_new(char *tim);\n\nX509_EXTENSION *OCSP_url_svcloc_new(X509_NAME *issuer, char **urls);\n\nint OCSP_REQUEST_get_ext_count(OCSP_REQUEST *x);\nint OCSP_REQUEST_get_ext_by_NID(OCSP_REQUEST *x, int nid, int lastpos);\nint OCSP_REQUEST_get_ext_by_OBJ(OCSP_REQUEST *x, ASN1_OBJECT *obj,\n                                int lastpos);\nint OCSP_REQUEST_get_ext_by_critical(OCSP_REQUEST *x, int crit, int lastpos);\nX509_EXTENSION *OCSP_REQUEST_get_ext(OCSP_REQUEST *x, int loc);\nX509_EXTENSION *OCSP_REQUEST_delete_ext(OCSP_REQUEST *x, int loc);\nvoid *OCSP_REQUEST_get1_ext_d2i(OCSP_REQUEST *x, int nid, int *crit,\n                                int *idx);\nint OCSP_REQUEST_add1_ext_i2d(OCSP_REQUEST *x, int nid, void *value, int crit,\n                              unsigned long flags);\nint OCSP_REQUEST_add_ext(OCSP_REQUEST *x, X509_EXTENSION *ex, int loc);\n\nint OCSP_ONEREQ_get_ext_count(OCSP_ONEREQ *x);\nint OCSP_ONEREQ_get_ext_by_NID(OCSP_ONEREQ *x, int nid, int lastpos);\nint OCSP_ONEREQ_get_ext_by_OBJ(OCSP_ONEREQ *x, ASN1_OBJECT *obj, int lastpos);\nint OCSP_ONEREQ_get_ext_by_critical(OCSP_ONEREQ *x, int crit, int lastpos);\nX509_EXTENSION *OCSP_ONEREQ_get_ext(OCSP_ONEREQ *x, int loc);\nX509_EXTENSION *OCSP_ONEREQ_delete_ext(OCSP_ONEREQ *x, int loc);\nvoid *OCSP_ONEREQ_get1_ext_d2i(OCSP_ONEREQ *x, int nid, int *crit, int *idx);\nint OCSP_ONEREQ_add1_ext_i2d(OCSP_ONEREQ *x, int nid, void *value, int crit,\n                             unsigned long flags);\nint OCSP_ONEREQ_add_ext(OCSP_ONEREQ *x, X509_EXTENSION *ex, int loc);\n\nint OCSP_BASICRESP_get_ext_count(OCSP_BASICRESP *x);\nint OCSP_BASICRESP_get_ext_by_NID(OCSP_BASICRESP *x, int nid, int lastpos);\nint OCSP_BASICRESP_get_ext_by_OBJ(OCSP_BASICRESP *x, ASN1_OBJECT *obj,\n                                  int lastpos);\nint OCSP_BASICRESP_get_ext_by_critical(OCSP_BASICRESP *x, int crit,\n                                       int lastpos);\nX509_EXTENSION *OCSP_BASICRESP_get_ext(OCSP_BASICRESP *x, int loc);\nX509_EXTENSION *OCSP_BASICRESP_delete_ext(OCSP_BASICRESP *x, int loc);\nvoid *OCSP_BASICRESP_get1_ext_d2i(OCSP_BASICRESP *x, int nid, int *crit,\n                                  int *idx);\nint OCSP_BASICRESP_add1_ext_i2d(OCSP_BASICRESP *x, int nid, void *value,\n                                int crit, unsigned long flags);\nint OCSP_BASICRESP_add_ext(OCSP_BASICRESP *x, X509_EXTENSION *ex, int loc);\n\nint OCSP_SINGLERESP_get_ext_count(OCSP_SINGLERESP *x);\nint OCSP_SINGLERESP_get_ext_by_NID(OCSP_SINGLERESP *x, int nid, int lastpos);\nint OCSP_SINGLERESP_get_ext_by_OBJ(OCSP_SINGLERESP *x, ASN1_OBJECT *obj,\n                                   int lastpos);\nint OCSP_SINGLERESP_get_ext_by_critical(OCSP_SINGLERESP *x, int crit,\n                                        int lastpos);\nX509_EXTENSION *OCSP_SINGLERESP_get_ext(OCSP_SINGLERESP *x, int loc);\nX509_EXTENSION *OCSP_SINGLERESP_delete_ext(OCSP_SINGLERESP *x, int loc);\nvoid *OCSP_SINGLERESP_get1_ext_d2i(OCSP_SINGLERESP *x, int nid, int *crit,\n                                   int *idx);\nint OCSP_SINGLERESP_add1_ext_i2d(OCSP_SINGLERESP *x, int nid, void *value,\n                                 int crit, unsigned long flags);\nint OCSP_SINGLERESP_add_ext(OCSP_SINGLERESP *x, X509_EXTENSION *ex, int loc);\n\nDECLARE_ASN1_FUNCTIONS(OCSP_SINGLERESP)\nDECLARE_ASN1_FUNCTIONS(OCSP_CERTSTATUS)\nDECLARE_ASN1_FUNCTIONS(OCSP_REVOKEDINFO)\nDECLARE_ASN1_FUNCTIONS(OCSP_BASICRESP)\nDECLARE_ASN1_FUNCTIONS(OCSP_RESPDATA)\nDECLARE_ASN1_FUNCTIONS(OCSP_RESPID)\nDECLARE_ASN1_FUNCTIONS(OCSP_RESPONSE)\nDECLARE_ASN1_FUNCTIONS(OCSP_RESPBYTES)\nDECLARE_ASN1_FUNCTIONS(OCSP_ONEREQ)\nDECLARE_ASN1_FUNCTIONS(OCSP_CERTID)\nDECLARE_ASN1_FUNCTIONS(OCSP_REQUEST)\nDECLARE_ASN1_FUNCTIONS(OCSP_SIGNATURE)\nDECLARE_ASN1_FUNCTIONS(OCSP_REQINFO)\nDECLARE_ASN1_FUNCTIONS(OCSP_CRLID)\nDECLARE_ASN1_FUNCTIONS(OCSP_SERVICELOC)\n\nconst char *OCSP_response_status_str(long s);\nconst char *OCSP_cert_status_str(long s);\nconst char *OCSP_crl_reason_str(long s);\n\nint OCSP_REQUEST_print(BIO *bp, OCSP_REQUEST *a, unsigned long flags);\nint OCSP_RESPONSE_print(BIO *bp, OCSP_RESPONSE *o, unsigned long flags);\n\nint OCSP_basic_verify(OCSP_BASICRESP *bs, STACK_OF(X509) *certs,\n                      X509_STORE *st, unsigned long flags);\n\n/* BEGIN ERROR CODES */\n/*\n * The following lines are auto generated by the script mkerr.pl. Any changes\n * made after this point may be overwritten when the script is next run.\n */\nvoid ERR_load_OCSP_strings(void);\n\n/* Error codes for the OCSP functions. */\n\n/* Function codes. */\n# define OCSP_F_ASN1_STRING_ENCODE                        100\n# define OCSP_F_D2I_OCSP_NONCE                            102\n# define OCSP_F_OCSP_BASIC_ADD1_STATUS                    103\n# define OCSP_F_OCSP_BASIC_SIGN                           104\n# define OCSP_F_OCSP_BASIC_VERIFY                         105\n# define OCSP_F_OCSP_CERT_ID_NEW                          101\n# define OCSP_F_OCSP_CHECK_DELEGATED                      106\n# define OCSP_F_OCSP_CHECK_IDS                            107\n# define OCSP_F_OCSP_CHECK_ISSUER                         108\n# define OCSP_F_OCSP_CHECK_VALIDITY                       115\n# define OCSP_F_OCSP_MATCH_ISSUERID                       109\n# define OCSP_F_OCSP_PARSE_URL                            114\n# define OCSP_F_OCSP_REQUEST_SIGN                         110\n# define OCSP_F_OCSP_REQUEST_VERIFY                       116\n# define OCSP_F_OCSP_RESPONSE_GET1_BASIC                  111\n# define OCSP_F_OCSP_SENDREQ_BIO                          112\n# define OCSP_F_OCSP_SENDREQ_NBIO                         117\n# define OCSP_F_PARSE_HTTP_LINE1                          118\n# define OCSP_F_REQUEST_VERIFY                            113\n\n/* Reason codes. */\n# define OCSP_R_BAD_DATA                                  100\n# define OCSP_R_CERTIFICATE_VERIFY_ERROR                  101\n# define OCSP_R_DIGEST_ERR                                102\n# define OCSP_R_ERROR_IN_NEXTUPDATE_FIELD                 122\n# define OCSP_R_ERROR_IN_THISUPDATE_FIELD                 123\n# define OCSP_R_ERROR_PARSING_URL                         121\n# define OCSP_R_MISSING_OCSPSIGNING_USAGE                 103\n# define OCSP_R_NEXTUPDATE_BEFORE_THISUPDATE              124\n# define OCSP_R_NOT_BASIC_RESPONSE                        104\n# define OCSP_R_NO_CERTIFICATES_IN_CHAIN                  105\n# define OCSP_R_NO_CONTENT                                106\n# define OCSP_R_NO_PUBLIC_KEY                             107\n# define OCSP_R_NO_RESPONSE_DATA                          108\n# define OCSP_R_NO_REVOKED_TIME                           109\n# define OCSP_R_PRIVATE_KEY_DOES_NOT_MATCH_CERTIFICATE    110\n# define OCSP_R_REQUEST_NOT_SIGNED                        128\n# define OCSP_R_RESPONSE_CONTAINS_NO_REVOCATION_DATA      111\n# define OCSP_R_ROOT_CA_NOT_TRUSTED                       112\n# define OCSP_R_SERVER_READ_ERROR                         113\n# define OCSP_R_SERVER_RESPONSE_ERROR                     114\n# define OCSP_R_SERVER_RESPONSE_PARSE_ERROR               115\n# define OCSP_R_SERVER_WRITE_ERROR                        116\n# define OCSP_R_SIGNATURE_FAILURE                         117\n# define OCSP_R_SIGNER_CERTIFICATE_NOT_FOUND              118\n# define OCSP_R_STATUS_EXPIRED                            125\n# define OCSP_R_STATUS_NOT_YET_VALID                      126\n# define OCSP_R_STATUS_TOO_OLD                            127\n# define OCSP_R_UNKNOWN_MESSAGE_DIGEST                    119\n# define OCSP_R_UNKNOWN_NID                               120\n# define OCSP_R_UNSUPPORTED_REQUESTORNAME_TYPE            129\n\n#ifdef  __cplusplus\n}\n#endif\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/arm/include/openssl/opensslconf.h",
    "content": "/* opensslconf.h */\n/* WARNING: Generated automatically from opensslconf.h.in by Configure. */\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n/* OpenSSL was configured with the following options: */\n#ifndef OPENSSL_DOING_MAKEDEPEND\n\n\n#ifndef OPENSSL_NO_CAST\n# define OPENSSL_NO_CAST\n#endif\n#ifndef OPENSSL_NO_COMP\n# define OPENSSL_NO_COMP\n#endif\n#ifndef OPENSSL_NO_DH\n# define OPENSSL_NO_DH\n#endif\n#ifndef OPENSSL_NO_DSA\n# define OPENSSL_NO_DSA\n#endif\n#ifndef OPENSSL_NO_EC\n# define OPENSSL_NO_EC\n#endif\n#ifndef OPENSSL_NO_EC_NISTP_64_GCC_128\n# define OPENSSL_NO_EC_NISTP_64_GCC_128\n#endif\n#ifndef OPENSSL_NO_ECDH\n# define OPENSSL_NO_ECDH\n#endif\n#ifndef OPENSSL_NO_ECDSA\n# define OPENSSL_NO_ECDSA\n#endif\n#ifndef OPENSSL_NO_ENGINE\n# define OPENSSL_NO_ENGINE\n#endif\n#ifndef OPENSSL_NO_FIPS\n# define OPENSSL_NO_FIPS\n#endif\n#ifndef OPENSSL_NO_GMP\n# define OPENSSL_NO_GMP\n#endif\n#ifndef OPENSSL_NO_GOST\n# define OPENSSL_NO_GOST\n#endif\n#ifndef OPENSSL_NO_JPAKE\n# define OPENSSL_NO_JPAKE\n#endif\n#ifndef OPENSSL_NO_KRB5\n# define OPENSSL_NO_KRB5\n#endif\n#ifndef OPENSSL_NO_LIBUNBOUND\n# define OPENSSL_NO_LIBUNBOUND\n#endif\n#ifndef OPENSSL_NO_MD2\n# define OPENSSL_NO_MD2\n#endif\n#ifndef OPENSSL_NO_MD4\n# define OPENSSL_NO_MD4\n#endif\n#ifndef OPENSSL_NO_MD5\n# define OPENSSL_NO_MD5\n#endif\n#ifndef OPENSSL_NO_MDC2\n# define OPENSSL_NO_MDC2\n#endif\n#ifndef OPENSSL_NO_RC2\n# define OPENSSL_NO_RC2\n#endif\n#ifndef OPENSSL_NO_RC5\n# define OPENSSL_NO_RC5\n#endif\n#ifndef OPENSSL_NO_RFC3779\n# define OPENSSL_NO_RFC3779\n#endif\n#ifndef OPENSSL_NO_RIPEMD\n# define OPENSSL_NO_RIPEMD\n#endif\n#ifndef OPENSSL_NO_RSA\n# define OPENSSL_NO_RSA\n#endif\n#ifndef OPENSSL_NO_SCTP\n# define OPENSSL_NO_SCTP\n#endif\n#ifndef OPENSSL_NO_SOCK\n# define OPENSSL_NO_SOCK\n#endif\n#ifndef OPENSSL_NO_SSL_TRACE\n# define OPENSSL_NO_SSL_TRACE\n#endif\n#ifndef OPENSSL_NO_SSL2\n# define OPENSSL_NO_SSL2\n#endif\n#ifndef OPENSSL_NO_SSL3\n# define OPENSSL_NO_SSL3\n#endif\n#ifndef OPENSSL_NO_STORE\n# define OPENSSL_NO_STORE\n#endif\n#ifndef OPENSSL_NO_TLS1\n# define OPENSSL_NO_TLS1\n#endif\n#ifndef OPENSSL_NO_UNIT_TEST\n# define OPENSSL_NO_UNIT_TEST\n#endif\n#ifndef OPENSSL_NO_WEAK_SSL_CIPHERS\n# define OPENSSL_NO_WEAK_SSL_CIPHERS\n#endif\n\n#endif /* OPENSSL_DOING_MAKEDEPEND */\n\n#ifndef OPENSSL_THREADS\n# define OPENSSL_THREADS\n#endif\n#ifndef OPENSSL_NO_HW\n# define OPENSSL_NO_HW\n#endif\n#ifndef OPENSSL_NO_DYNAMIC_ENGINE\n# define OPENSSL_NO_DYNAMIC_ENGINE\n#endif\n\n/* The OPENSSL_NO_* macros are also defined as NO_* if the application\n   asks for it.  This is a transient feature that is provided for those\n   who haven't had the time to do the appropriate changes in their\n   applications.  */\n#ifdef OPENSSL_ALGORITHM_DEFINES\n# if defined(OPENSSL_NO_CAST) && !defined(NO_CAST)\n#  define NO_CAST\n# endif\n# if defined(OPENSSL_NO_COMP) && !defined(NO_COMP)\n#  define NO_COMP\n# endif\n# if defined(OPENSSL_NO_DH) && !defined(NO_DH)\n#  define NO_DH\n# endif\n# if defined(OPENSSL_NO_DSA) && !defined(NO_DSA)\n#  define NO_DSA\n# endif\n# if defined(OPENSSL_NO_EC) && !defined(NO_EC)\n#  define NO_EC\n# endif\n# if defined(OPENSSL_NO_EC_NISTP_64_GCC_128) && !defined(NO_EC_NISTP_64_GCC_128)\n#  define NO_EC_NISTP_64_GCC_128\n# endif\n# if defined(OPENSSL_NO_ECDH) && !defined(NO_ECDH)\n#  define NO_ECDH\n# endif\n# if defined(OPENSSL_NO_ECDSA) && !defined(NO_ECDSA)\n#  define NO_ECDSA\n# endif\n# if defined(OPENSSL_NO_ENGINE) && !defined(NO_ENGINE)\n#  define NO_ENGINE\n# endif\n# if defined(OPENSSL_NO_FIPS) && !defined(NO_FIPS)\n#  define NO_FIPS\n# endif\n# if defined(OPENSSL_NO_GMP) && !defined(NO_GMP)\n#  define NO_GMP\n# endif\n# if defined(OPENSSL_NO_GOST) && !defined(NO_GOST)\n#  define NO_GOST\n# endif\n# if defined(OPENSSL_NO_JPAKE) && !defined(NO_JPAKE)\n#  define NO_JPAKE\n# endif\n# if defined(OPENSSL_NO_KRB5) && !defined(NO_KRB5)\n#  define NO_KRB5\n# endif\n# if defined(OPENSSL_NO_LIBUNBOUND) && !defined(NO_LIBUNBOUND)\n#  define NO_LIBUNBOUND\n# endif\n# if defined(OPENSSL_NO_MD2) && !defined(NO_MD2)\n#  define NO_MD2\n# endif\n# if defined(OPENSSL_NO_MD4) && !defined(NO_MD4)\n#  define NO_MD4\n# endif\n# if defined(OPENSSL_NO_MD5) && !defined(NO_MD5)\n#  define NO_MD5\n# endif\n# if defined(OPENSSL_NO_MDC2) && !defined(NO_MDC2)\n#  define NO_MDC2\n# endif\n# if defined(OPENSSL_NO_RC2) && !defined(NO_RC2)\n#  define NO_RC2\n# endif\n# if defined(OPENSSL_NO_RC5) && !defined(NO_RC5)\n#  define NO_RC5\n# endif\n# if defined(OPENSSL_NO_RFC3779) && !defined(NO_RFC3779)\n#  define NO_RFC3779\n# endif\n# if defined(OPENSSL_NO_RIPEMD) && !defined(NO_RIPEMD)\n#  define NO_RIPEMD\n# endif\n# if defined(OPENSSL_NO_RSA) && !defined(NO_RSA)\n#  define NO_RSA\n# endif\n# if defined(OPENSSL_NO_SCTP) && !defined(NO_SCTP)\n#  define NO_SCTP\n# endif\n# if defined(OPENSSL_NO_SOCK) && !defined(NO_SOCK)\n#  define NO_SOCK\n# endif\n# if defined(OPENSSL_NO_SSL_TRACE) && !defined(NO_SSL_TRACE)\n#  define NO_SSL_TRACE\n# endif\n# if defined(OPENSSL_NO_SSL2) && !defined(NO_SSL2)\n#  define NO_SSL2\n# endif\n# if defined(OPENSSL_NO_SSL3) && !defined(NO_SSL3)\n#  define NO_SSL3\n# endif\n# if defined(OPENSSL_NO_STORE) && !defined(NO_STORE)\n#  define NO_STORE\n# endif\n# if defined(OPENSSL_NO_TLS1) && !defined(NO_TLS1)\n#  define NO_TLS1\n# endif\n# if defined(OPENSSL_NO_UNIT_TEST) && !defined(NO_UNIT_TEST)\n#  define NO_UNIT_TEST\n# endif\n# if defined(OPENSSL_NO_WEAK_SSL_CIPHERS) && !defined(NO_WEAK_SSL_CIPHERS)\n#  define NO_WEAK_SSL_CIPHERS\n# endif\n#endif\n\n#define OPENSSL_CPUID_OBJ\n\n/* crypto/opensslconf.h.in */\n\n/* Generate 80386 code? */\n#undef I386_ONLY\n\n#if !(defined(VMS) || defined(__VMS)) /* VMS uses logical names instead */\n#if defined(HEADER_CRYPTLIB_H) && !defined(OPENSSLDIR)\n#define ENGINESDIR \"/c/projects/wcdb/android/prebuilt/arm/lib/engines\"\n#define OPENSSLDIR \"/c/projects/wcdb/android/prebuilt/arm\"\n#endif\n#endif\n\n#undef OPENSSL_UNISTD\n#define OPENSSL_UNISTD <unistd.h>\n\n#undef OPENSSL_EXPORT_VAR_AS_FUNCTION\n\n#if defined(HEADER_IDEA_H) && !defined(IDEA_INT)\n#define IDEA_INT unsigned int\n#endif\n\n#if defined(HEADER_MD2_H) && !defined(MD2_INT)\n#define MD2_INT unsigned int\n#endif\n\n#if defined(HEADER_RC2_H) && !defined(RC2_INT)\n/* I need to put in a mod for the alpha - eay */\n#define RC2_INT unsigned int\n#endif\n\n#if defined(HEADER_RC4_H)\n#if !defined(RC4_INT)\n/* using int types make the structure larger but make the code faster\n * on most boxes I have tested - up to %20 faster. */\n/*\n * I don't know what does \"most\" mean, but declaring \"int\" is a must on:\n * - Intel P6 because partial register stalls are very expensive;\n * - elder Alpha because it lacks byte load/store instructions;\n */\n#define RC4_INT unsigned char\n#endif\n#if !defined(RC4_CHUNK)\n/*\n * This enables code handling data aligned at natural CPU word\n * boundary. See crypto/rc4/rc4_enc.c for further details.\n */\n#define RC4_CHUNK unsigned long\n#endif\n#endif\n\n#if (defined(HEADER_NEW_DES_H) || defined(HEADER_DES_H)) && !defined(DES_LONG)\n/* If this is set to 'unsigned int' on a DEC Alpha, this gives about a\n * %20 speed up (longs are 8 bytes, int's are 4). */\n#ifndef DES_LONG\n#define DES_LONG unsigned int\n#endif\n#endif\n\n#if defined(HEADER_BN_H) && !defined(CONFIG_HEADER_BN_H)\n#define CONFIG_HEADER_BN_H\n#define BN_LLONG\n\n/* Should we define BN_DIV2W here? */\n\n/* Only one for the following should be defined */\n#undef SIXTY_FOUR_BIT_LONG\n#undef SIXTY_FOUR_BIT\n#define THIRTY_TWO_BIT\n#endif\n\n#if defined(HEADER_RC4_LOCL_H) && !defined(CONFIG_HEADER_RC4_LOCL_H)\n#define CONFIG_HEADER_RC4_LOCL_H\n/* if this is defined data[i] is used instead of *data, this is a %20\n * speedup on x86 */\n#undef RC4_INDEX\n#endif\n\n#if defined(HEADER_BF_LOCL_H) && !defined(CONFIG_HEADER_BF_LOCL_H)\n#define CONFIG_HEADER_BF_LOCL_H\n#define BF_PTR\n#endif /* HEADER_BF_LOCL_H */\n\n#if defined(HEADER_DES_LOCL_H) && !defined(CONFIG_HEADER_DES_LOCL_H)\n#define CONFIG_HEADER_DES_LOCL_H\n#ifndef DES_DEFAULT_OPTIONS\n/* the following is tweaked from a config script, that is why it is a\n * protected undef/define */\n#ifndef DES_PTR\n#undef DES_PTR\n#endif\n\n/* This helps C compiler generate the correct code for multiple functional\n * units.  It reduces register dependancies at the expense of 2 more\n * registers */\n#ifndef DES_RISC1\n#undef DES_RISC1\n#endif\n\n#ifndef DES_RISC2\n#undef DES_RISC2\n#endif\n\n#if defined(DES_RISC1) && defined(DES_RISC2)\n#error YOU SHOULD NOT HAVE BOTH DES_RISC1 AND DES_RISC2 DEFINED!!!!!\n#endif\n\n/* Unroll the inner loop, this sometimes helps, sometimes hinders.\n * Very mucy CPU dependant */\n#ifndef DES_UNROLL\n#define DES_UNROLL\n#endif\n\n/* These default values were supplied by\n * Peter Gutman <pgut001@cs.auckland.ac.nz>\n * They are only used if nothing else has been defined */\n#if !defined(DES_PTR) && !defined(DES_RISC1) && !defined(DES_RISC2) && !defined(DES_UNROLL)\n/* Special defines which change the way the code is built depending on the\n   CPU and OS.  For SGI machines you can use _MIPS_SZLONG (32 or 64) to find\n   even newer MIPS CPU's, but at the moment one size fits all for\n   optimization options.  Older Sparc's work better with only UNROLL, but\n   there's no way to tell at compile time what it is you're running on */\n \n#if defined( __sun ) || defined ( sun )\t\t/* Newer Sparc's */\n#  define DES_PTR\n#  define DES_RISC1\n#  define DES_UNROLL\n#elif defined( __ultrix )\t/* Older MIPS */\n#  define DES_PTR\n#  define DES_RISC2\n#  define DES_UNROLL\n#elif defined( __osf1__ )\t/* Alpha */\n#  define DES_PTR\n#  define DES_RISC2\n#elif defined ( _AIX )\t\t/* RS6000 */\n  /* Unknown */\n#elif defined( __hpux )\t\t/* HP-PA */\n  /* Unknown */\n#elif defined( __aux )\t\t/* 68K */\n  /* Unknown */\n#elif defined( __dgux )\t\t/* 88K (but P6 in latest boxes) */\n#  define DES_UNROLL\n#elif defined( __sgi )\t\t/* Newer MIPS */\n#  define DES_PTR\n#  define DES_RISC2\n#  define DES_UNROLL\n#elif defined(i386) || defined(__i386__)\t/* x86 boxes, should be gcc */\n#  define DES_PTR\n#  define DES_RISC1\n#  define DES_UNROLL\n#endif /* Systems-specific speed defines */\n#endif\n\n#endif /* DES_DEFAULT_OPTIONS */\n#endif /* HEADER_DES_LOCL_H */\n#ifdef  __cplusplus\n}\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/arm/include/openssl/opensslv.h",
    "content": "#ifndef HEADER_OPENSSLV_H\n# define HEADER_OPENSSLV_H\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n/*-\n * Numeric release version identifier:\n * MNNFFPPS: major minor fix patch status\n * The status nibble has one of the values 0 for development, 1 to e for betas\n * 1 to 14, and f for release.  The patch level is exactly that.\n * For example:\n * 0.9.3-dev      0x00903000\n * 0.9.3-beta1    0x00903001\n * 0.9.3-beta2-dev 0x00903002\n * 0.9.3-beta2    0x00903002 (same as ...beta2-dev)\n * 0.9.3          0x0090300f\n * 0.9.3a         0x0090301f\n * 0.9.4          0x0090400f\n * 1.2.3z         0x102031af\n *\n * For continuity reasons (because 0.9.5 is already out, and is coded\n * 0x00905100), between 0.9.5 and 0.9.6 the coding of the patch level\n * part is slightly different, by setting the highest bit.  This means\n * that 0.9.5a looks like this: 0x0090581f.  At 0.9.6, we can start\n * with 0x0090600S...\n *\n * (Prior to 0.9.3-dev a different scheme was used: 0.9.2b is 0x0922.)\n * (Prior to 0.9.5a beta1, a different scheme was used: MMNNFFRBB for\n *  major minor fix final patch/beta)\n */\n# define OPENSSL_VERSION_NUMBER  0x100020bfL\n# ifdef OPENSSL_FIPS\n#  define OPENSSL_VERSION_TEXT    \"OpenSSL 1.0.2k-fips  26 Jan 2017\"\n# else\n#  define OPENSSL_VERSION_TEXT    \"OpenSSL 1.0.2k  26 Jan 2017\"\n# endif\n# define OPENSSL_VERSION_PTEXT   \" part of \" OPENSSL_VERSION_TEXT\n\n/*-\n * The macros below are to be used for shared library (.so, .dll, ...)\n * versioning.  That kind of versioning works a bit differently between\n * operating systems.  The most usual scheme is to set a major and a minor\n * number, and have the runtime loader check that the major number is equal\n * to what it was at application link time, while the minor number has to\n * be greater or equal to what it was at application link time.  With this\n * scheme, the version number is usually part of the file name, like this:\n *\n *      libcrypto.so.0.9\n *\n * Some unixen also make a softlink with the major verson number only:\n *\n *      libcrypto.so.0\n *\n * On Tru64 and IRIX 6.x it works a little bit differently.  There, the\n * shared library version is stored in the file, and is actually a series\n * of versions, separated by colons.  The rightmost version present in the\n * library when linking an application is stored in the application to be\n * matched at run time.  When the application is run, a check is done to\n * see if the library version stored in the application matches any of the\n * versions in the version string of the library itself.\n * This version string can be constructed in any way, depending on what\n * kind of matching is desired.  However, to implement the same scheme as\n * the one used in the other unixen, all compatible versions, from lowest\n * to highest, should be part of the string.  Consecutive builds would\n * give the following versions strings:\n *\n *      3.0\n *      3.0:3.1\n *      3.0:3.1:3.2\n *      4.0\n *      4.0:4.1\n *\n * Notice how version 4 is completely incompatible with version, and\n * therefore give the breach you can see.\n *\n * There may be other schemes as well that I haven't yet discovered.\n *\n * So, here's the way it works here: first of all, the library version\n * number doesn't need at all to match the overall OpenSSL version.\n * However, it's nice and more understandable if it actually does.\n * The current library version is stored in the macro SHLIB_VERSION_NUMBER,\n * which is just a piece of text in the format \"M.m.e\" (Major, minor, edit).\n * For the sake of Tru64, IRIX, and any other OS that behaves in similar ways,\n * we need to keep a history of version numbers, which is done in the\n * macro SHLIB_VERSION_HISTORY.  The numbers are separated by colons and\n * should only keep the versions that are binary compatible with the current.\n */\n# define SHLIB_VERSION_HISTORY \"\"\n# define SHLIB_VERSION_NUMBER \"1.0.0\"\n\n\n#ifdef  __cplusplus\n}\n#endif\n#endif                          /* HEADER_OPENSSLV_H */\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/arm/include/openssl/ossl_typ.h",
    "content": "/* ====================================================================\n * Copyright (c) 1998-2001 The OpenSSL Project.  All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n *\n * 1. Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n *\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in\n *    the documentation and/or other materials provided with the\n *    distribution.\n *\n * 3. All advertising materials mentioning features or use of this\n *    software must display the following acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit. (http://www.openssl.org/)\"\n *\n * 4. The names \"OpenSSL Toolkit\" and \"OpenSSL Project\" must not be used to\n *    endorse or promote products derived from this software without\n *    prior written permission. For written permission, please contact\n *    openssl-core@openssl.org.\n *\n * 5. Products derived from this software may not be called \"OpenSSL\"\n *    nor may \"OpenSSL\" appear in their names without prior written\n *    permission of the OpenSSL Project.\n *\n * 6. Redistributions of any form whatsoever must retain the following\n *    acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit (http://www.openssl.org/)\"\n *\n * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY\n * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\n * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR\n * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\n * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,\n * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED\n * OF THE POSSIBILITY OF SUCH DAMAGE.\n * ====================================================================\n *\n * This product includes cryptographic software written by Eric Young\n * (eay@cryptsoft.com).  This product includes software written by Tim\n * Hudson (tjh@cryptsoft.com).\n *\n */\n\n#ifndef HEADER_OPENSSL_TYPES_H\n# define HEADER_OPENSSL_TYPES_H\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n# include <openssl/e_os2.h>\n\n# ifdef NO_ASN1_TYPEDEFS\n#  define ASN1_INTEGER            ASN1_STRING\n#  define ASN1_ENUMERATED         ASN1_STRING\n#  define ASN1_BIT_STRING         ASN1_STRING\n#  define ASN1_OCTET_STRING       ASN1_STRING\n#  define ASN1_PRINTABLESTRING    ASN1_STRING\n#  define ASN1_T61STRING          ASN1_STRING\n#  define ASN1_IA5STRING          ASN1_STRING\n#  define ASN1_UTCTIME            ASN1_STRING\n#  define ASN1_GENERALIZEDTIME    ASN1_STRING\n#  define ASN1_TIME               ASN1_STRING\n#  define ASN1_GENERALSTRING      ASN1_STRING\n#  define ASN1_UNIVERSALSTRING    ASN1_STRING\n#  define ASN1_BMPSTRING          ASN1_STRING\n#  define ASN1_VISIBLESTRING      ASN1_STRING\n#  define ASN1_UTF8STRING         ASN1_STRING\n#  define ASN1_BOOLEAN            int\n#  define ASN1_NULL               int\n# else\ntypedef struct asn1_string_st ASN1_INTEGER;\ntypedef struct asn1_string_st ASN1_ENUMERATED;\ntypedef struct asn1_string_st ASN1_BIT_STRING;\ntypedef struct asn1_string_st ASN1_OCTET_STRING;\ntypedef struct asn1_string_st ASN1_PRINTABLESTRING;\ntypedef struct asn1_string_st ASN1_T61STRING;\ntypedef struct asn1_string_st ASN1_IA5STRING;\ntypedef struct asn1_string_st ASN1_GENERALSTRING;\ntypedef struct asn1_string_st ASN1_UNIVERSALSTRING;\ntypedef struct asn1_string_st ASN1_BMPSTRING;\ntypedef struct asn1_string_st ASN1_UTCTIME;\ntypedef struct asn1_string_st ASN1_TIME;\ntypedef struct asn1_string_st ASN1_GENERALIZEDTIME;\ntypedef struct asn1_string_st ASN1_VISIBLESTRING;\ntypedef struct asn1_string_st ASN1_UTF8STRING;\ntypedef struct asn1_string_st ASN1_STRING;\ntypedef int ASN1_BOOLEAN;\ntypedef int ASN1_NULL;\n# endif\n\ntypedef struct asn1_object_st ASN1_OBJECT;\n\ntypedef struct ASN1_ITEM_st ASN1_ITEM;\ntypedef struct asn1_pctx_st ASN1_PCTX;\n\n# ifdef OPENSSL_SYS_WIN32\n#  undef X509_NAME\n#  undef X509_EXTENSIONS\n#  undef X509_CERT_PAIR\n#  undef PKCS7_ISSUER_AND_SERIAL\n#  undef OCSP_REQUEST\n#  undef OCSP_RESPONSE\n# endif\n\n# ifdef BIGNUM\n#  undef BIGNUM\n# endif\ntypedef struct bignum_st BIGNUM;\ntypedef struct bignum_ctx BN_CTX;\ntypedef struct bn_blinding_st BN_BLINDING;\ntypedef struct bn_mont_ctx_st BN_MONT_CTX;\ntypedef struct bn_recp_ctx_st BN_RECP_CTX;\ntypedef struct bn_gencb_st BN_GENCB;\n\ntypedef struct buf_mem_st BUF_MEM;\n\ntypedef struct evp_cipher_st EVP_CIPHER;\ntypedef struct evp_cipher_ctx_st EVP_CIPHER_CTX;\ntypedef struct env_md_st EVP_MD;\ntypedef struct env_md_ctx_st EVP_MD_CTX;\ntypedef struct evp_pkey_st EVP_PKEY;\n\ntypedef struct evp_pkey_asn1_method_st EVP_PKEY_ASN1_METHOD;\n\ntypedef struct evp_pkey_method_st EVP_PKEY_METHOD;\ntypedef struct evp_pkey_ctx_st EVP_PKEY_CTX;\n\ntypedef struct dh_st DH;\ntypedef struct dh_method DH_METHOD;\n\ntypedef struct dsa_st DSA;\ntypedef struct dsa_method DSA_METHOD;\n\ntypedef struct rsa_st RSA;\ntypedef struct rsa_meth_st RSA_METHOD;\n\ntypedef struct rand_meth_st RAND_METHOD;\n\ntypedef struct ecdh_method ECDH_METHOD;\ntypedef struct ecdsa_method ECDSA_METHOD;\n\ntypedef struct x509_st X509;\ntypedef struct X509_algor_st X509_ALGOR;\ntypedef struct X509_crl_st X509_CRL;\ntypedef struct x509_crl_method_st X509_CRL_METHOD;\ntypedef struct x509_revoked_st X509_REVOKED;\ntypedef struct X509_name_st X509_NAME;\ntypedef struct X509_pubkey_st X509_PUBKEY;\ntypedef struct x509_store_st X509_STORE;\ntypedef struct x509_store_ctx_st X509_STORE_CTX;\n\ntypedef struct pkcs8_priv_key_info_st PKCS8_PRIV_KEY_INFO;\n\ntypedef struct v3_ext_ctx X509V3_CTX;\ntypedef struct conf_st CONF;\n\ntypedef struct store_st STORE;\ntypedef struct store_method_st STORE_METHOD;\n\ntypedef struct ui_st UI;\ntypedef struct ui_method_st UI_METHOD;\n\ntypedef struct st_ERR_FNS ERR_FNS;\n\ntypedef struct engine_st ENGINE;\ntypedef struct ssl_st SSL;\ntypedef struct ssl_ctx_st SSL_CTX;\n\ntypedef struct comp_method_st COMP_METHOD;\n\ntypedef struct X509_POLICY_NODE_st X509_POLICY_NODE;\ntypedef struct X509_POLICY_LEVEL_st X509_POLICY_LEVEL;\ntypedef struct X509_POLICY_TREE_st X509_POLICY_TREE;\ntypedef struct X509_POLICY_CACHE_st X509_POLICY_CACHE;\n\ntypedef struct AUTHORITY_KEYID_st AUTHORITY_KEYID;\ntypedef struct DIST_POINT_st DIST_POINT;\ntypedef struct ISSUING_DIST_POINT_st ISSUING_DIST_POINT;\ntypedef struct NAME_CONSTRAINTS_st NAME_CONSTRAINTS;\n\n  /* If placed in pkcs12.h, we end up with a circular depency with pkcs7.h */\n# define DECLARE_PKCS12_STACK_OF(type)/* Nothing */\n# define IMPLEMENT_PKCS12_STACK_OF(type)/* Nothing */\n\ntypedef struct crypto_ex_data_st CRYPTO_EX_DATA;\n/* Callback types for crypto.h */\ntypedef int CRYPTO_EX_new (void *parent, void *ptr, CRYPTO_EX_DATA *ad,\n                           int idx, long argl, void *argp);\ntypedef void CRYPTO_EX_free (void *parent, void *ptr, CRYPTO_EX_DATA *ad,\n                             int idx, long argl, void *argp);\ntypedef int CRYPTO_EX_dup (CRYPTO_EX_DATA *to, CRYPTO_EX_DATA *from,\n                           void *from_d, int idx, long argl, void *argp);\n\ntypedef struct ocsp_req_ctx_st OCSP_REQ_CTX;\ntypedef struct ocsp_response_st OCSP_RESPONSE;\ntypedef struct ocsp_responder_id_st OCSP_RESPID;\n\n#ifdef  __cplusplus\n}\n#endif\n#endif                          /* def HEADER_OPENSSL_TYPES_H */\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/arm/include/openssl/pem.h",
    "content": "/* crypto/pem/pem.h */\n/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)\n * All rights reserved.\n *\n * This package is an SSL implementation written\n * by Eric Young (eay@cryptsoft.com).\n * The implementation was written so as to conform with Netscapes SSL.\n *\n * This library is free for commercial and non-commercial use as long as\n * the following conditions are aheared to.  The following conditions\n * apply to all code found in this distribution, be it the RC4, RSA,\n * lhash, DES, etc., code; not just the SSL code.  The SSL documentation\n * included with this distribution is covered by the same copyright terms\n * except that the holder is Tim Hudson (tjh@cryptsoft.com).\n *\n * Copyright remains Eric Young's, and as such any Copyright notices in\n * the code are not to be removed.\n * If this package is used in a product, Eric Young should be given attribution\n * as the author of the parts of the library used.\n * This can be in the form of a textual message at program startup or\n * in documentation (online or textual) provided with the package.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the copyright\n *    notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in the\n *    documentation and/or other materials provided with the distribution.\n * 3. All advertising materials mentioning features or use of this software\n *    must display the following acknowledgement:\n *    \"This product includes cryptographic software written by\n *     Eric Young (eay@cryptsoft.com)\"\n *    The word 'cryptographic' can be left out if the rouines from the library\n *    being used are not cryptographic related :-).\n * 4. If you include any Windows specific code (or a derivative thereof) from\n *    the apps directory (application code) you must include an acknowledgement:\n *    \"This product includes software written by Tim Hudson (tjh@cryptsoft.com)\"\n *\n * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n * SUCH DAMAGE.\n *\n * The licence and distribution terms for any publically available version or\n * derivative of this code cannot be changed.  i.e. this code cannot simply be\n * copied and put under another distribution licence\n * [including the GNU Public Licence.]\n */\n\n#ifndef HEADER_PEM_H\n# define HEADER_PEM_H\n\n# include <openssl/e_os2.h>\n# ifndef OPENSSL_NO_BIO\n#  include <openssl/bio.h>\n# endif\n# ifndef OPENSSL_NO_STACK\n#  include <openssl/stack.h>\n# endif\n# include <openssl/evp.h>\n# include <openssl/x509.h>\n# include <openssl/pem2.h>\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n# define PEM_BUFSIZE             1024\n\n# define PEM_OBJ_UNDEF           0\n# define PEM_OBJ_X509            1\n# define PEM_OBJ_X509_REQ        2\n# define PEM_OBJ_CRL             3\n# define PEM_OBJ_SSL_SESSION     4\n# define PEM_OBJ_PRIV_KEY        10\n# define PEM_OBJ_PRIV_RSA        11\n# define PEM_OBJ_PRIV_DSA        12\n# define PEM_OBJ_PRIV_DH         13\n# define PEM_OBJ_PUB_RSA         14\n# define PEM_OBJ_PUB_DSA         15\n# define PEM_OBJ_PUB_DH          16\n# define PEM_OBJ_DHPARAMS        17\n# define PEM_OBJ_DSAPARAMS       18\n# define PEM_OBJ_PRIV_RSA_PUBLIC 19\n# define PEM_OBJ_PRIV_ECDSA      20\n# define PEM_OBJ_PUB_ECDSA       21\n# define PEM_OBJ_ECPARAMETERS    22\n\n# define PEM_ERROR               30\n# define PEM_DEK_DES_CBC         40\n# define PEM_DEK_IDEA_CBC        45\n# define PEM_DEK_DES_EDE         50\n# define PEM_DEK_DES_ECB         60\n# define PEM_DEK_RSA             70\n# define PEM_DEK_RSA_MD2         80\n# define PEM_DEK_RSA_MD5         90\n\n# define PEM_MD_MD2              NID_md2\n# define PEM_MD_MD5              NID_md5\n# define PEM_MD_SHA              NID_sha\n# define PEM_MD_MD2_RSA          NID_md2WithRSAEncryption\n# define PEM_MD_MD5_RSA          NID_md5WithRSAEncryption\n# define PEM_MD_SHA_RSA          NID_sha1WithRSAEncryption\n\n# define PEM_STRING_X509_OLD     \"X509 CERTIFICATE\"\n# define PEM_STRING_X509         \"CERTIFICATE\"\n# define PEM_STRING_X509_PAIR    \"CERTIFICATE PAIR\"\n# define PEM_STRING_X509_TRUSTED \"TRUSTED CERTIFICATE\"\n# define PEM_STRING_X509_REQ_OLD \"NEW CERTIFICATE REQUEST\"\n# define PEM_STRING_X509_REQ     \"CERTIFICATE REQUEST\"\n# define PEM_STRING_X509_CRL     \"X509 CRL\"\n# define PEM_STRING_EVP_PKEY     \"ANY PRIVATE KEY\"\n# define PEM_STRING_PUBLIC       \"PUBLIC KEY\"\n# define PEM_STRING_RSA          \"RSA PRIVATE KEY\"\n# define PEM_STRING_RSA_PUBLIC   \"RSA PUBLIC KEY\"\n# define PEM_STRING_DSA          \"DSA PRIVATE KEY\"\n# define PEM_STRING_DSA_PUBLIC   \"DSA PUBLIC KEY\"\n# define PEM_STRING_PKCS7        \"PKCS7\"\n# define PEM_STRING_PKCS7_SIGNED \"PKCS #7 SIGNED DATA\"\n# define PEM_STRING_PKCS8        \"ENCRYPTED PRIVATE KEY\"\n# define PEM_STRING_PKCS8INF     \"PRIVATE KEY\"\n# define PEM_STRING_DHPARAMS     \"DH PARAMETERS\"\n# define PEM_STRING_DHXPARAMS    \"X9.42 DH PARAMETERS\"\n# define PEM_STRING_SSL_SESSION  \"SSL SESSION PARAMETERS\"\n# define PEM_STRING_DSAPARAMS    \"DSA PARAMETERS\"\n# define PEM_STRING_ECDSA_PUBLIC \"ECDSA PUBLIC KEY\"\n# define PEM_STRING_ECPARAMETERS \"EC PARAMETERS\"\n# define PEM_STRING_ECPRIVATEKEY \"EC PRIVATE KEY\"\n# define PEM_STRING_PARAMETERS   \"PARAMETERS\"\n# define PEM_STRING_CMS          \"CMS\"\n\n  /*\n   * Note that this structure is initialised by PEM_SealInit and cleaned up\n   * by PEM_SealFinal (at least for now)\n   */\ntypedef struct PEM_Encode_Seal_st {\n    EVP_ENCODE_CTX encode;\n    EVP_MD_CTX md;\n    EVP_CIPHER_CTX cipher;\n} PEM_ENCODE_SEAL_CTX;\n\n/* enc_type is one off */\n# define PEM_TYPE_ENCRYPTED      10\n# define PEM_TYPE_MIC_ONLY       20\n# define PEM_TYPE_MIC_CLEAR      30\n# define PEM_TYPE_CLEAR          40\n\ntypedef struct pem_recip_st {\n    char *name;\n    X509_NAME *dn;\n    int cipher;\n    int key_enc;\n    /*      char iv[8]; unused and wrong size */\n} PEM_USER;\n\ntypedef struct pem_ctx_st {\n    int type;                   /* what type of object */\n    struct {\n        int version;\n        int mode;\n    } proc_type;\n\n    char *domain;\n\n    struct {\n        int cipher;\n        /*-\n        unused, and wrong size\n        unsigned char iv[8]; */\n    } DEK_info;\n\n    PEM_USER *originator;\n\n    int num_recipient;\n    PEM_USER **recipient;\n/*-\n    XXX(ben): don#t think this is used!\n        STACK *x509_chain;      / * certificate chain */\n    EVP_MD *md;                 /* signature type */\n\n    int md_enc;                 /* is the md encrypted or not? */\n    int md_len;                 /* length of md_data */\n    char *md_data;              /* message digest, could be pkey encrypted */\n\n    EVP_CIPHER *dec;            /* date encryption cipher */\n    int key_len;                /* key length */\n    unsigned char *key;         /* key */\n  /*-\n    unused, and wrong size\n    unsigned char iv[8]; */\n\n    int data_enc;               /* is the data encrypted */\n    int data_len;\n    unsigned char *data;\n} PEM_CTX;\n\n/*\n * These macros make the PEM_read/PEM_write functions easier to maintain and\n * write. Now they are all implemented with either: IMPLEMENT_PEM_rw(...) or\n * IMPLEMENT_PEM_rw_cb(...)\n */\n\n# ifdef OPENSSL_NO_FP_API\n\n#  define IMPLEMENT_PEM_read_fp(name, type, str, asn1) /**/\n#  define IMPLEMENT_PEM_write_fp(name, type, str, asn1) /**/\n#  define IMPLEMENT_PEM_write_fp_const(name, type, str, asn1) /**/\n#  define IMPLEMENT_PEM_write_cb_fp(name, type, str, asn1) /**/\n#  define IMPLEMENT_PEM_write_cb_fp_const(name, type, str, asn1) /**/\n# else\n\n#  define IMPLEMENT_PEM_read_fp(name, type, str, asn1) \\\ntype *PEM_read_##name(FILE *fp, type **x, pem_password_cb *cb, void *u)\\\n{ \\\nreturn PEM_ASN1_read((d2i_of_void *)d2i_##asn1, str,fp,(void **)x,cb,u); \\\n}\n\n#  define IMPLEMENT_PEM_write_fp(name, type, str, asn1) \\\nint PEM_write_##name(FILE *fp, type *x) \\\n{ \\\nreturn PEM_ASN1_write((i2d_of_void *)i2d_##asn1,str,fp,x,NULL,NULL,0,NULL,NULL); \\\n}\n\n#  define IMPLEMENT_PEM_write_fp_const(name, type, str, asn1) \\\nint PEM_write_##name(FILE *fp, const type *x) \\\n{ \\\nreturn PEM_ASN1_write((i2d_of_void *)i2d_##asn1,str,fp,(void *)x,NULL,NULL,0,NULL,NULL); \\\n}\n\n#  define IMPLEMENT_PEM_write_cb_fp(name, type, str, asn1) \\\nint PEM_write_##name(FILE *fp, type *x, const EVP_CIPHER *enc, \\\n             unsigned char *kstr, int klen, pem_password_cb *cb, \\\n                  void *u) \\\n        { \\\n        return PEM_ASN1_write((i2d_of_void *)i2d_##asn1,str,fp,x,enc,kstr,klen,cb,u); \\\n        }\n\n#  define IMPLEMENT_PEM_write_cb_fp_const(name, type, str, asn1) \\\nint PEM_write_##name(FILE *fp, type *x, const EVP_CIPHER *enc, \\\n             unsigned char *kstr, int klen, pem_password_cb *cb, \\\n                  void *u) \\\n        { \\\n        return PEM_ASN1_write((i2d_of_void *)i2d_##asn1,str,fp,x,enc,kstr,klen,cb,u); \\\n        }\n\n# endif\n\n# define IMPLEMENT_PEM_read_bio(name, type, str, asn1) \\\ntype *PEM_read_bio_##name(BIO *bp, type **x, pem_password_cb *cb, void *u)\\\n{ \\\nreturn PEM_ASN1_read_bio((d2i_of_void *)d2i_##asn1, str,bp,(void **)x,cb,u); \\\n}\n\n# define IMPLEMENT_PEM_write_bio(name, type, str, asn1) \\\nint PEM_write_bio_##name(BIO *bp, type *x) \\\n{ \\\nreturn PEM_ASN1_write_bio((i2d_of_void *)i2d_##asn1,str,bp,x,NULL,NULL,0,NULL,NULL); \\\n}\n\n# define IMPLEMENT_PEM_write_bio_const(name, type, str, asn1) \\\nint PEM_write_bio_##name(BIO *bp, const type *x) \\\n{ \\\nreturn PEM_ASN1_write_bio((i2d_of_void *)i2d_##asn1,str,bp,(void *)x,NULL,NULL,0,NULL,NULL); \\\n}\n\n# define IMPLEMENT_PEM_write_cb_bio(name, type, str, asn1) \\\nint PEM_write_bio_##name(BIO *bp, type *x, const EVP_CIPHER *enc, \\\n             unsigned char *kstr, int klen, pem_password_cb *cb, void *u) \\\n        { \\\n        return PEM_ASN1_write_bio((i2d_of_void *)i2d_##asn1,str,bp,x,enc,kstr,klen,cb,u); \\\n        }\n\n# define IMPLEMENT_PEM_write_cb_bio_const(name, type, str, asn1) \\\nint PEM_write_bio_##name(BIO *bp, type *x, const EVP_CIPHER *enc, \\\n             unsigned char *kstr, int klen, pem_password_cb *cb, void *u) \\\n        { \\\n        return PEM_ASN1_write_bio((i2d_of_void *)i2d_##asn1,str,bp,(void *)x,enc,kstr,klen,cb,u); \\\n        }\n\n# define IMPLEMENT_PEM_write(name, type, str, asn1) \\\n        IMPLEMENT_PEM_write_bio(name, type, str, asn1) \\\n        IMPLEMENT_PEM_write_fp(name, type, str, asn1)\n\n# define IMPLEMENT_PEM_write_const(name, type, str, asn1) \\\n        IMPLEMENT_PEM_write_bio_const(name, type, str, asn1) \\\n        IMPLEMENT_PEM_write_fp_const(name, type, str, asn1)\n\n# define IMPLEMENT_PEM_write_cb(name, type, str, asn1) \\\n        IMPLEMENT_PEM_write_cb_bio(name, type, str, asn1) \\\n        IMPLEMENT_PEM_write_cb_fp(name, type, str, asn1)\n\n# define IMPLEMENT_PEM_write_cb_const(name, type, str, asn1) \\\n        IMPLEMENT_PEM_write_cb_bio_const(name, type, str, asn1) \\\n        IMPLEMENT_PEM_write_cb_fp_const(name, type, str, asn1)\n\n# define IMPLEMENT_PEM_read(name, type, str, asn1) \\\n        IMPLEMENT_PEM_read_bio(name, type, str, asn1) \\\n        IMPLEMENT_PEM_read_fp(name, type, str, asn1)\n\n# define IMPLEMENT_PEM_rw(name, type, str, asn1) \\\n        IMPLEMENT_PEM_read(name, type, str, asn1) \\\n        IMPLEMENT_PEM_write(name, type, str, asn1)\n\n# define IMPLEMENT_PEM_rw_const(name, type, str, asn1) \\\n        IMPLEMENT_PEM_read(name, type, str, asn1) \\\n        IMPLEMENT_PEM_write_const(name, type, str, asn1)\n\n# define IMPLEMENT_PEM_rw_cb(name, type, str, asn1) \\\n        IMPLEMENT_PEM_read(name, type, str, asn1) \\\n        IMPLEMENT_PEM_write_cb(name, type, str, asn1)\n\n/* These are the same except they are for the declarations */\n\n# if defined(OPENSSL_NO_FP_API)\n\n#  define DECLARE_PEM_read_fp(name, type) /**/\n#  define DECLARE_PEM_write_fp(name, type) /**/\n#  define DECLARE_PEM_write_cb_fp(name, type) /**/\n# else\n\n#  define DECLARE_PEM_read_fp(name, type) \\\n        type *PEM_read_##name(FILE *fp, type **x, pem_password_cb *cb, void *u);\n\n#  define DECLARE_PEM_write_fp(name, type) \\\n        int PEM_write_##name(FILE *fp, type *x);\n\n#  define DECLARE_PEM_write_fp_const(name, type) \\\n        int PEM_write_##name(FILE *fp, const type *x);\n\n#  define DECLARE_PEM_write_cb_fp(name, type) \\\n        int PEM_write_##name(FILE *fp, type *x, const EVP_CIPHER *enc, \\\n             unsigned char *kstr, int klen, pem_password_cb *cb, void *u);\n\n# endif\n\n# ifndef OPENSSL_NO_BIO\n#  define DECLARE_PEM_read_bio(name, type) \\\n        type *PEM_read_bio_##name(BIO *bp, type **x, pem_password_cb *cb, void *u);\n\n#  define DECLARE_PEM_write_bio(name, type) \\\n        int PEM_write_bio_##name(BIO *bp, type *x);\n\n#  define DECLARE_PEM_write_bio_const(name, type) \\\n        int PEM_write_bio_##name(BIO *bp, const type *x);\n\n#  define DECLARE_PEM_write_cb_bio(name, type) \\\n        int PEM_write_bio_##name(BIO *bp, type *x, const EVP_CIPHER *enc, \\\n             unsigned char *kstr, int klen, pem_password_cb *cb, void *u);\n\n# else\n\n#  define DECLARE_PEM_read_bio(name, type) /**/\n#  define DECLARE_PEM_write_bio(name, type) /**/\n#  define DECLARE_PEM_write_bio_const(name, type) /**/\n#  define DECLARE_PEM_write_cb_bio(name, type) /**/\n# endif\n# define DECLARE_PEM_write(name, type) \\\n        DECLARE_PEM_write_bio(name, type) \\\n        DECLARE_PEM_write_fp(name, type)\n# define DECLARE_PEM_write_const(name, type) \\\n        DECLARE_PEM_write_bio_const(name, type) \\\n        DECLARE_PEM_write_fp_const(name, type)\n# define DECLARE_PEM_write_cb(name, type) \\\n        DECLARE_PEM_write_cb_bio(name, type) \\\n        DECLARE_PEM_write_cb_fp(name, type)\n# define DECLARE_PEM_read(name, type) \\\n        DECLARE_PEM_read_bio(name, type) \\\n        DECLARE_PEM_read_fp(name, type)\n# define DECLARE_PEM_rw(name, type) \\\n        DECLARE_PEM_read(name, type) \\\n        DECLARE_PEM_write(name, type)\n# define DECLARE_PEM_rw_const(name, type) \\\n        DECLARE_PEM_read(name, type) \\\n        DECLARE_PEM_write_const(name, type)\n# define DECLARE_PEM_rw_cb(name, type) \\\n        DECLARE_PEM_read(name, type) \\\n        DECLARE_PEM_write_cb(name, type)\n# if 1\n/* \"userdata\": new with OpenSSL 0.9.4 */\ntypedef int pem_password_cb (char *buf, int size, int rwflag, void *userdata);\n# else\n/* OpenSSL 0.9.3, 0.9.3a */\ntypedef int pem_password_cb (char *buf, int size, int rwflag);\n# endif\n\nint PEM_get_EVP_CIPHER_INFO(char *header, EVP_CIPHER_INFO *cipher);\nint PEM_do_header(EVP_CIPHER_INFO *cipher, unsigned char *data, long *len,\n                  pem_password_cb *callback, void *u);\n\n# ifndef OPENSSL_NO_BIO\nint PEM_read_bio(BIO *bp, char **name, char **header,\n                 unsigned char **data, long *len);\nint PEM_write_bio(BIO *bp, const char *name, const char *hdr,\n                  const unsigned char *data, long len);\nint PEM_bytes_read_bio(unsigned char **pdata, long *plen, char **pnm,\n                       const char *name, BIO *bp, pem_password_cb *cb,\n                       void *u);\nvoid *PEM_ASN1_read_bio(d2i_of_void *d2i, const char *name, BIO *bp, void **x,\n                        pem_password_cb *cb, void *u);\nint PEM_ASN1_write_bio(i2d_of_void *i2d, const char *name, BIO *bp, void *x,\n                       const EVP_CIPHER *enc, unsigned char *kstr, int klen,\n                       pem_password_cb *cb, void *u);\n\nSTACK_OF(X509_INFO) *PEM_X509_INFO_read_bio(BIO *bp, STACK_OF(X509_INFO) *sk,\n                                            pem_password_cb *cb, void *u);\nint PEM_X509_INFO_write_bio(BIO *bp, X509_INFO *xi, EVP_CIPHER *enc,\n                            unsigned char *kstr, int klen,\n                            pem_password_cb *cd, void *u);\n# endif\n\nint PEM_read(FILE *fp, char **name, char **header,\n             unsigned char **data, long *len);\nint PEM_write(FILE *fp, const char *name, const char *hdr,\n              const unsigned char *data, long len);\nvoid *PEM_ASN1_read(d2i_of_void *d2i, const char *name, FILE *fp, void **x,\n                    pem_password_cb *cb, void *u);\nint PEM_ASN1_write(i2d_of_void *i2d, const char *name, FILE *fp,\n                   void *x, const EVP_CIPHER *enc, unsigned char *kstr,\n                   int klen, pem_password_cb *callback, void *u);\nSTACK_OF(X509_INFO) *PEM_X509_INFO_read(FILE *fp, STACK_OF(X509_INFO) *sk,\n                                        pem_password_cb *cb, void *u);\n\nint PEM_SealInit(PEM_ENCODE_SEAL_CTX *ctx, EVP_CIPHER *type,\n                 EVP_MD *md_type, unsigned char **ek, int *ekl,\n                 unsigned char *iv, EVP_PKEY **pubk, int npubk);\nvoid PEM_SealUpdate(PEM_ENCODE_SEAL_CTX *ctx, unsigned char *out, int *outl,\n                    unsigned char *in, int inl);\nint PEM_SealFinal(PEM_ENCODE_SEAL_CTX *ctx, unsigned char *sig, int *sigl,\n                  unsigned char *out, int *outl, EVP_PKEY *priv);\n\nvoid PEM_SignInit(EVP_MD_CTX *ctx, EVP_MD *type);\nvoid PEM_SignUpdate(EVP_MD_CTX *ctx, unsigned char *d, unsigned int cnt);\nint PEM_SignFinal(EVP_MD_CTX *ctx, unsigned char *sigret,\n                  unsigned int *siglen, EVP_PKEY *pkey);\n\nint PEM_def_callback(char *buf, int num, int w, void *key);\nvoid PEM_proc_type(char *buf, int type);\nvoid PEM_dek_info(char *buf, const char *type, int len, char *str);\n\n# include <openssl/symhacks.h>\n\nDECLARE_PEM_rw(X509, X509)\nDECLARE_PEM_rw(X509_AUX, X509)\nDECLARE_PEM_rw(X509_CERT_PAIR, X509_CERT_PAIR)\nDECLARE_PEM_rw(X509_REQ, X509_REQ)\nDECLARE_PEM_write(X509_REQ_NEW, X509_REQ)\nDECLARE_PEM_rw(X509_CRL, X509_CRL)\nDECLARE_PEM_rw(PKCS7, PKCS7)\nDECLARE_PEM_rw(NETSCAPE_CERT_SEQUENCE, NETSCAPE_CERT_SEQUENCE)\nDECLARE_PEM_rw(PKCS8, X509_SIG)\nDECLARE_PEM_rw(PKCS8_PRIV_KEY_INFO, PKCS8_PRIV_KEY_INFO)\n# ifndef OPENSSL_NO_RSA\nDECLARE_PEM_rw_cb(RSAPrivateKey, RSA)\nDECLARE_PEM_rw_const(RSAPublicKey, RSA)\nDECLARE_PEM_rw(RSA_PUBKEY, RSA)\n# endif\n# ifndef OPENSSL_NO_DSA\nDECLARE_PEM_rw_cb(DSAPrivateKey, DSA)\nDECLARE_PEM_rw(DSA_PUBKEY, DSA)\nDECLARE_PEM_rw_const(DSAparams, DSA)\n# endif\n# ifndef OPENSSL_NO_EC\nDECLARE_PEM_rw_const(ECPKParameters, EC_GROUP)\nDECLARE_PEM_rw_cb(ECPrivateKey, EC_KEY)\nDECLARE_PEM_rw(EC_PUBKEY, EC_KEY)\n# endif\n# ifndef OPENSSL_NO_DH\nDECLARE_PEM_rw_const(DHparams, DH)\nDECLARE_PEM_write_const(DHxparams, DH)\n# endif\nDECLARE_PEM_rw_cb(PrivateKey, EVP_PKEY)\nDECLARE_PEM_rw(PUBKEY, EVP_PKEY)\n\nint PEM_write_bio_PKCS8PrivateKey_nid(BIO *bp, EVP_PKEY *x, int nid,\n                                      char *kstr, int klen,\n                                      pem_password_cb *cb, void *u);\nint PEM_write_bio_PKCS8PrivateKey(BIO *, EVP_PKEY *, const EVP_CIPHER *,\n                                  char *, int, pem_password_cb *, void *);\nint i2d_PKCS8PrivateKey_bio(BIO *bp, EVP_PKEY *x, const EVP_CIPHER *enc,\n                            char *kstr, int klen,\n                            pem_password_cb *cb, void *u);\nint i2d_PKCS8PrivateKey_nid_bio(BIO *bp, EVP_PKEY *x, int nid,\n                                char *kstr, int klen,\n                                pem_password_cb *cb, void *u);\nEVP_PKEY *d2i_PKCS8PrivateKey_bio(BIO *bp, EVP_PKEY **x, pem_password_cb *cb,\n                                  void *u);\n\nint i2d_PKCS8PrivateKey_fp(FILE *fp, EVP_PKEY *x, const EVP_CIPHER *enc,\n                           char *kstr, int klen,\n                           pem_password_cb *cb, void *u);\nint i2d_PKCS8PrivateKey_nid_fp(FILE *fp, EVP_PKEY *x, int nid,\n                               char *kstr, int klen,\n                               pem_password_cb *cb, void *u);\nint PEM_write_PKCS8PrivateKey_nid(FILE *fp, EVP_PKEY *x, int nid,\n                                  char *kstr, int klen,\n                                  pem_password_cb *cb, void *u);\n\nEVP_PKEY *d2i_PKCS8PrivateKey_fp(FILE *fp, EVP_PKEY **x, pem_password_cb *cb,\n                                 void *u);\n\nint PEM_write_PKCS8PrivateKey(FILE *fp, EVP_PKEY *x, const EVP_CIPHER *enc,\n                              char *kstr, int klen, pem_password_cb *cd,\n                              void *u);\n\nEVP_PKEY *PEM_read_bio_Parameters(BIO *bp, EVP_PKEY **x);\nint PEM_write_bio_Parameters(BIO *bp, EVP_PKEY *x);\n\nEVP_PKEY *b2i_PrivateKey(const unsigned char **in, long length);\nEVP_PKEY *b2i_PublicKey(const unsigned char **in, long length);\nEVP_PKEY *b2i_PrivateKey_bio(BIO *in);\nEVP_PKEY *b2i_PublicKey_bio(BIO *in);\nint i2b_PrivateKey_bio(BIO *out, EVP_PKEY *pk);\nint i2b_PublicKey_bio(BIO *out, EVP_PKEY *pk);\n# ifndef OPENSSL_NO_RC4\nEVP_PKEY *b2i_PVK_bio(BIO *in, pem_password_cb *cb, void *u);\nint i2b_PVK_bio(BIO *out, EVP_PKEY *pk, int enclevel,\n                pem_password_cb *cb, void *u);\n# endif\n\n/* BEGIN ERROR CODES */\n/*\n * The following lines are auto generated by the script mkerr.pl. Any changes\n * made after this point may be overwritten when the script is next run.\n */\n\nvoid ERR_load_PEM_strings(void);\n\n/* Error codes for the PEM functions. */\n\n/* Function codes. */\n# define PEM_F_B2I_DSS                                    127\n# define PEM_F_B2I_PVK_BIO                                128\n# define PEM_F_B2I_RSA                                    129\n# define PEM_F_CHECK_BITLEN_DSA                           130\n# define PEM_F_CHECK_BITLEN_RSA                           131\n# define PEM_F_D2I_PKCS8PRIVATEKEY_BIO                    120\n# define PEM_F_D2I_PKCS8PRIVATEKEY_FP                     121\n# define PEM_F_DO_B2I                                     132\n# define PEM_F_DO_B2I_BIO                                 133\n# define PEM_F_DO_BLOB_HEADER                             134\n# define PEM_F_DO_PK8PKEY                                 126\n# define PEM_F_DO_PK8PKEY_FP                              125\n# define PEM_F_DO_PVK_BODY                                135\n# define PEM_F_DO_PVK_HEADER                              136\n# define PEM_F_I2B_PVK                                    137\n# define PEM_F_I2B_PVK_BIO                                138\n# define PEM_F_LOAD_IV                                    101\n# define PEM_F_PEM_ASN1_READ                              102\n# define PEM_F_PEM_ASN1_READ_BIO                          103\n# define PEM_F_PEM_ASN1_WRITE                             104\n# define PEM_F_PEM_ASN1_WRITE_BIO                         105\n# define PEM_F_PEM_DEF_CALLBACK                           100\n# define PEM_F_PEM_DO_HEADER                              106\n# define PEM_F_PEM_F_PEM_WRITE_PKCS8PRIVATEKEY            118\n# define PEM_F_PEM_GET_EVP_CIPHER_INFO                    107\n# define PEM_F_PEM_PK8PKEY                                119\n# define PEM_F_PEM_READ                                   108\n# define PEM_F_PEM_READ_BIO                               109\n# define PEM_F_PEM_READ_BIO_DHPARAMS                      141\n# define PEM_F_PEM_READ_BIO_PARAMETERS                    140\n# define PEM_F_PEM_READ_BIO_PRIVATEKEY                    123\n# define PEM_F_PEM_READ_DHPARAMS                          142\n# define PEM_F_PEM_READ_PRIVATEKEY                        124\n# define PEM_F_PEM_SEALFINAL                              110\n# define PEM_F_PEM_SEALINIT                               111\n# define PEM_F_PEM_SIGNFINAL                              112\n# define PEM_F_PEM_WRITE                                  113\n# define PEM_F_PEM_WRITE_BIO                              114\n# define PEM_F_PEM_WRITE_PRIVATEKEY                       139\n# define PEM_F_PEM_X509_INFO_READ                         115\n# define PEM_F_PEM_X509_INFO_READ_BIO                     116\n# define PEM_F_PEM_X509_INFO_WRITE_BIO                    117\n\n/* Reason codes. */\n# define PEM_R_BAD_BASE64_DECODE                          100\n# define PEM_R_BAD_DECRYPT                                101\n# define PEM_R_BAD_END_LINE                               102\n# define PEM_R_BAD_IV_CHARS                               103\n# define PEM_R_BAD_MAGIC_NUMBER                           116\n# define PEM_R_BAD_PASSWORD_READ                          104\n# define PEM_R_BAD_VERSION_NUMBER                         117\n# define PEM_R_BIO_WRITE_FAILURE                          118\n# define PEM_R_CIPHER_IS_NULL                             127\n# define PEM_R_ERROR_CONVERTING_PRIVATE_KEY               115\n# define PEM_R_EXPECTING_PRIVATE_KEY_BLOB                 119\n# define PEM_R_EXPECTING_PUBLIC_KEY_BLOB                  120\n# define PEM_R_HEADER_TOO_LONG                            128\n# define PEM_R_INCONSISTENT_HEADER                        121\n# define PEM_R_KEYBLOB_HEADER_PARSE_ERROR                 122\n# define PEM_R_KEYBLOB_TOO_SHORT                          123\n# define PEM_R_NOT_DEK_INFO                               105\n# define PEM_R_NOT_ENCRYPTED                              106\n# define PEM_R_NOT_PROC_TYPE                              107\n# define PEM_R_NO_START_LINE                              108\n# define PEM_R_PROBLEMS_GETTING_PASSWORD                  109\n# define PEM_R_PUBLIC_KEY_NO_RSA                          110\n# define PEM_R_PVK_DATA_TOO_SHORT                         124\n# define PEM_R_PVK_TOO_SHORT                              125\n# define PEM_R_READ_KEY                                   111\n# define PEM_R_SHORT_HEADER                               112\n# define PEM_R_UNSUPPORTED_CIPHER                         113\n# define PEM_R_UNSUPPORTED_ENCRYPTION                     114\n# define PEM_R_UNSUPPORTED_KEY_COMPONENTS                 126\n\n# ifdef  __cplusplus\n}\n# endif\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/arm/include/openssl/pem2.h",
    "content": "/* ====================================================================\n * Copyright (c) 1999 The OpenSSL Project.  All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n *\n * 1. Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n *\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in\n *    the documentation and/or other materials provided with the\n *    distribution.\n *\n * 3. All advertising materials mentioning features or use of this\n *    software must display the following acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)\"\n *\n * 4. The names \"OpenSSL Toolkit\" and \"OpenSSL Project\" must not be used to\n *    endorse or promote products derived from this software without\n *    prior written permission. For written permission, please contact\n *    licensing@OpenSSL.org.\n *\n * 5. Products derived from this software may not be called \"OpenSSL\"\n *    nor may \"OpenSSL\" appear in their names without prior written\n *    permission of the OpenSSL Project.\n *\n * 6. Redistributions of any form whatsoever must retain the following\n *    acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)\"\n *\n * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY\n * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\n * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR\n * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\n * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,\n * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED\n * OF THE POSSIBILITY OF SUCH DAMAGE.\n * ====================================================================\n *\n * This product includes cryptographic software written by Eric Young\n * (eay@cryptsoft.com).  This product includes software written by Tim\n * Hudson (tjh@cryptsoft.com).\n *\n */\n\n/*\n * This header only exists to break a circular dependency between pem and err\n * Ben 30 Jan 1999.\n */\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n#ifndef HEADER_PEM_H\nvoid ERR_load_PEM_strings(void);\n#endif\n\n#ifdef __cplusplus\n}\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/arm/include/openssl/pkcs12.h",
    "content": "/* pkcs12.h */\n/*\n * Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL project\n * 1999.\n */\n/* ====================================================================\n * Copyright (c) 1999 The OpenSSL Project.  All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n *\n * 1. Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n *\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in\n *    the documentation and/or other materials provided with the\n *    distribution.\n *\n * 3. All advertising materials mentioning features or use of this\n *    software must display the following acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)\"\n *\n * 4. The names \"OpenSSL Toolkit\" and \"OpenSSL Project\" must not be used to\n *    endorse or promote products derived from this software without\n *    prior written permission. For written permission, please contact\n *    licensing@OpenSSL.org.\n *\n * 5. Products derived from this software may not be called \"OpenSSL\"\n *    nor may \"OpenSSL\" appear in their names without prior written\n *    permission of the OpenSSL Project.\n *\n * 6. Redistributions of any form whatsoever must retain the following\n *    acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)\"\n *\n * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY\n * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\n * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR\n * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\n * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,\n * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED\n * OF THE POSSIBILITY OF SUCH DAMAGE.\n * ====================================================================\n *\n * This product includes cryptographic software written by Eric Young\n * (eay@cryptsoft.com).  This product includes software written by Tim\n * Hudson (tjh@cryptsoft.com).\n *\n */\n\n#ifndef HEADER_PKCS12_H\n# define HEADER_PKCS12_H\n\n# include <openssl/bio.h>\n# include <openssl/x509.h>\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n# define PKCS12_KEY_ID   1\n# define PKCS12_IV_ID    2\n# define PKCS12_MAC_ID   3\n\n/* Default iteration count */\n# ifndef PKCS12_DEFAULT_ITER\n#  define PKCS12_DEFAULT_ITER     PKCS5_DEFAULT_ITER\n# endif\n\n# define PKCS12_MAC_KEY_LENGTH 20\n\n# define PKCS12_SALT_LEN 8\n\n/* Uncomment out next line for unicode password and names, otherwise ASCII */\n\n/*\n * #define PBE_UNICODE\n */\n\n# ifdef PBE_UNICODE\n#  define PKCS12_key_gen PKCS12_key_gen_uni\n#  define PKCS12_add_friendlyname PKCS12_add_friendlyname_uni\n# else\n#  define PKCS12_key_gen PKCS12_key_gen_asc\n#  define PKCS12_add_friendlyname PKCS12_add_friendlyname_asc\n# endif\n\n/* MS key usage constants */\n\n# define KEY_EX  0x10\n# define KEY_SIG 0x80\n\ntypedef struct {\n    X509_SIG *dinfo;\n    ASN1_OCTET_STRING *salt;\n    ASN1_INTEGER *iter;         /* defaults to 1 */\n} PKCS12_MAC_DATA;\n\ntypedef struct {\n    ASN1_INTEGER *version;\n    PKCS12_MAC_DATA *mac;\n    PKCS7 *authsafes;\n} PKCS12;\n\ntypedef struct {\n    ASN1_OBJECT *type;\n    union {\n        struct pkcs12_bag_st *bag; /* secret, crl and certbag */\n        struct pkcs8_priv_key_info_st *keybag; /* keybag */\n        X509_SIG *shkeybag;     /* shrouded key bag */\n        STACK_OF(PKCS12_SAFEBAG) *safes;\n        ASN1_TYPE *other;\n    } value;\n    STACK_OF(X509_ATTRIBUTE) *attrib;\n} PKCS12_SAFEBAG;\n\nDECLARE_STACK_OF(PKCS12_SAFEBAG)\nDECLARE_ASN1_SET_OF(PKCS12_SAFEBAG)\nDECLARE_PKCS12_STACK_OF(PKCS12_SAFEBAG)\n\ntypedef struct pkcs12_bag_st {\n    ASN1_OBJECT *type;\n    union {\n        ASN1_OCTET_STRING *x509cert;\n        ASN1_OCTET_STRING *x509crl;\n        ASN1_OCTET_STRING *octet;\n        ASN1_IA5STRING *sdsicert;\n        ASN1_TYPE *other;       /* Secret or other bag */\n    } value;\n} PKCS12_BAGS;\n\n# define PKCS12_ERROR    0\n# define PKCS12_OK       1\n\n/* Compatibility macros */\n\n# define M_PKCS12_x5092certbag PKCS12_x5092certbag\n# define M_PKCS12_x509crl2certbag PKCS12_x509crl2certbag\n\n# define M_PKCS12_certbag2x509 PKCS12_certbag2x509\n# define M_PKCS12_certbag2x509crl PKCS12_certbag2x509crl\n\n# define M_PKCS12_unpack_p7data PKCS12_unpack_p7data\n# define M_PKCS12_pack_authsafes PKCS12_pack_authsafes\n# define M_PKCS12_unpack_authsafes PKCS12_unpack_authsafes\n# define M_PKCS12_unpack_p7encdata PKCS12_unpack_p7encdata\n\n# define M_PKCS12_decrypt_skey PKCS12_decrypt_skey\n# define M_PKCS8_decrypt PKCS8_decrypt\n\n# define M_PKCS12_bag_type(bg) OBJ_obj2nid((bg)->type)\n# define M_PKCS12_cert_bag_type(bg) OBJ_obj2nid((bg)->value.bag->type)\n# define M_PKCS12_crl_bag_type M_PKCS12_cert_bag_type\n\n# define PKCS12_get_attr(bag, attr_nid) \\\n                         PKCS12_get_attr_gen(bag->attrib, attr_nid)\n\n# define PKCS8_get_attr(p8, attr_nid) \\\n                PKCS12_get_attr_gen(p8->attributes, attr_nid)\n\n# define PKCS12_mac_present(p12) ((p12)->mac ? 1 : 0)\n\nPKCS12_SAFEBAG *PKCS12_x5092certbag(X509 *x509);\nPKCS12_SAFEBAG *PKCS12_x509crl2certbag(X509_CRL *crl);\nX509 *PKCS12_certbag2x509(PKCS12_SAFEBAG *bag);\nX509_CRL *PKCS12_certbag2x509crl(PKCS12_SAFEBAG *bag);\n\nPKCS12_SAFEBAG *PKCS12_item_pack_safebag(void *obj, const ASN1_ITEM *it,\n                                         int nid1, int nid2);\nPKCS12_SAFEBAG *PKCS12_MAKE_KEYBAG(PKCS8_PRIV_KEY_INFO *p8);\nPKCS8_PRIV_KEY_INFO *PKCS8_decrypt(X509_SIG *p8, const char *pass,\n                                   int passlen);\nPKCS8_PRIV_KEY_INFO *PKCS12_decrypt_skey(PKCS12_SAFEBAG *bag,\n                                         const char *pass, int passlen);\nX509_SIG *PKCS8_encrypt(int pbe_nid, const EVP_CIPHER *cipher,\n                        const char *pass, int passlen, unsigned char *salt,\n                        int saltlen, int iter, PKCS8_PRIV_KEY_INFO *p8);\nPKCS12_SAFEBAG *PKCS12_MAKE_SHKEYBAG(int pbe_nid, const char *pass,\n                                     int passlen, unsigned char *salt,\n                                     int saltlen, int iter,\n                                     PKCS8_PRIV_KEY_INFO *p8);\nPKCS7 *PKCS12_pack_p7data(STACK_OF(PKCS12_SAFEBAG) *sk);\nSTACK_OF(PKCS12_SAFEBAG) *PKCS12_unpack_p7data(PKCS7 *p7);\nPKCS7 *PKCS12_pack_p7encdata(int pbe_nid, const char *pass, int passlen,\n                             unsigned char *salt, int saltlen, int iter,\n                             STACK_OF(PKCS12_SAFEBAG) *bags);\nSTACK_OF(PKCS12_SAFEBAG) *PKCS12_unpack_p7encdata(PKCS7 *p7, const char *pass,\n                                                  int passlen);\n\nint PKCS12_pack_authsafes(PKCS12 *p12, STACK_OF(PKCS7) *safes);\nSTACK_OF(PKCS7) *PKCS12_unpack_authsafes(PKCS12 *p12);\n\nint PKCS12_add_localkeyid(PKCS12_SAFEBAG *bag, unsigned char *name,\n                          int namelen);\nint PKCS12_add_friendlyname_asc(PKCS12_SAFEBAG *bag, const char *name,\n                                int namelen);\nint PKCS12_add_CSPName_asc(PKCS12_SAFEBAG *bag, const char *name,\n                           int namelen);\nint PKCS12_add_friendlyname_uni(PKCS12_SAFEBAG *bag,\n                                const unsigned char *name, int namelen);\nint PKCS8_add_keyusage(PKCS8_PRIV_KEY_INFO *p8, int usage);\nASN1_TYPE *PKCS12_get_attr_gen(STACK_OF(X509_ATTRIBUTE) *attrs, int attr_nid);\nchar *PKCS12_get_friendlyname(PKCS12_SAFEBAG *bag);\nunsigned char *PKCS12_pbe_crypt(X509_ALGOR *algor, const char *pass,\n                                int passlen, unsigned char *in, int inlen,\n                                unsigned char **data, int *datalen,\n                                int en_de);\nvoid *PKCS12_item_decrypt_d2i(X509_ALGOR *algor, const ASN1_ITEM *it,\n                              const char *pass, int passlen,\n                              ASN1_OCTET_STRING *oct, int zbuf);\nASN1_OCTET_STRING *PKCS12_item_i2d_encrypt(X509_ALGOR *algor,\n                                           const ASN1_ITEM *it,\n                                           const char *pass, int passlen,\n                                           void *obj, int zbuf);\nPKCS12 *PKCS12_init(int mode);\nint PKCS12_key_gen_asc(const char *pass, int passlen, unsigned char *salt,\n                       int saltlen, int id, int iter, int n,\n                       unsigned char *out, const EVP_MD *md_type);\nint PKCS12_key_gen_uni(unsigned char *pass, int passlen, unsigned char *salt,\n                       int saltlen, int id, int iter, int n,\n                       unsigned char *out, const EVP_MD *md_type);\nint PKCS12_PBE_keyivgen(EVP_CIPHER_CTX *ctx, const char *pass, int passlen,\n                        ASN1_TYPE *param, const EVP_CIPHER *cipher,\n                        const EVP_MD *md_type, int en_de);\nint PKCS12_gen_mac(PKCS12 *p12, const char *pass, int passlen,\n                   unsigned char *mac, unsigned int *maclen);\nint PKCS12_verify_mac(PKCS12 *p12, const char *pass, int passlen);\nint PKCS12_set_mac(PKCS12 *p12, const char *pass, int passlen,\n                   unsigned char *salt, int saltlen, int iter,\n                   const EVP_MD *md_type);\nint PKCS12_setup_mac(PKCS12 *p12, int iter, unsigned char *salt,\n                     int saltlen, const EVP_MD *md_type);\nunsigned char *OPENSSL_asc2uni(const char *asc, int asclen,\n                               unsigned char **uni, int *unilen);\nchar *OPENSSL_uni2asc(unsigned char *uni, int unilen);\n\nDECLARE_ASN1_FUNCTIONS(PKCS12)\nDECLARE_ASN1_FUNCTIONS(PKCS12_MAC_DATA)\nDECLARE_ASN1_FUNCTIONS(PKCS12_SAFEBAG)\nDECLARE_ASN1_FUNCTIONS(PKCS12_BAGS)\n\nDECLARE_ASN1_ITEM(PKCS12_SAFEBAGS)\nDECLARE_ASN1_ITEM(PKCS12_AUTHSAFES)\n\nvoid PKCS12_PBE_add(void);\nint PKCS12_parse(PKCS12 *p12, const char *pass, EVP_PKEY **pkey, X509 **cert,\n                 STACK_OF(X509) **ca);\nPKCS12 *PKCS12_create(char *pass, char *name, EVP_PKEY *pkey, X509 *cert,\n                      STACK_OF(X509) *ca, int nid_key, int nid_cert, int iter,\n                      int mac_iter, int keytype);\n\nPKCS12_SAFEBAG *PKCS12_add_cert(STACK_OF(PKCS12_SAFEBAG) **pbags, X509 *cert);\nPKCS12_SAFEBAG *PKCS12_add_key(STACK_OF(PKCS12_SAFEBAG) **pbags,\n                               EVP_PKEY *key, int key_usage, int iter,\n                               int key_nid, char *pass);\nint PKCS12_add_safe(STACK_OF(PKCS7) **psafes, STACK_OF(PKCS12_SAFEBAG) *bags,\n                    int safe_nid, int iter, char *pass);\nPKCS12 *PKCS12_add_safes(STACK_OF(PKCS7) *safes, int p7_nid);\n\nint i2d_PKCS12_bio(BIO *bp, PKCS12 *p12);\nint i2d_PKCS12_fp(FILE *fp, PKCS12 *p12);\nPKCS12 *d2i_PKCS12_bio(BIO *bp, PKCS12 **p12);\nPKCS12 *d2i_PKCS12_fp(FILE *fp, PKCS12 **p12);\nint PKCS12_newpass(PKCS12 *p12, const char *oldpass, const char *newpass);\n\n/* BEGIN ERROR CODES */\n/*\n * The following lines are auto generated by the script mkerr.pl. Any changes\n * made after this point may be overwritten when the script is next run.\n */\nvoid ERR_load_PKCS12_strings(void);\n\n/* Error codes for the PKCS12 functions. */\n\n/* Function codes. */\n# define PKCS12_F_PARSE_BAG                               129\n# define PKCS12_F_PARSE_BAGS                              103\n# define PKCS12_F_PKCS12_ADD_FRIENDLYNAME                 100\n# define PKCS12_F_PKCS12_ADD_FRIENDLYNAME_ASC             127\n# define PKCS12_F_PKCS12_ADD_FRIENDLYNAME_UNI             102\n# define PKCS12_F_PKCS12_ADD_LOCALKEYID                   104\n# define PKCS12_F_PKCS12_CREATE                           105\n# define PKCS12_F_PKCS12_GEN_MAC                          107\n# define PKCS12_F_PKCS12_INIT                             109\n# define PKCS12_F_PKCS12_ITEM_DECRYPT_D2I                 106\n# define PKCS12_F_PKCS12_ITEM_I2D_ENCRYPT                 108\n# define PKCS12_F_PKCS12_ITEM_PACK_SAFEBAG                117\n# define PKCS12_F_PKCS12_KEY_GEN_ASC                      110\n# define PKCS12_F_PKCS12_KEY_GEN_UNI                      111\n# define PKCS12_F_PKCS12_MAKE_KEYBAG                      112\n# define PKCS12_F_PKCS12_MAKE_SHKEYBAG                    113\n# define PKCS12_F_PKCS12_NEWPASS                          128\n# define PKCS12_F_PKCS12_PACK_P7DATA                      114\n# define PKCS12_F_PKCS12_PACK_P7ENCDATA                   115\n# define PKCS12_F_PKCS12_PARSE                            118\n# define PKCS12_F_PKCS12_PBE_CRYPT                        119\n# define PKCS12_F_PKCS12_PBE_KEYIVGEN                     120\n# define PKCS12_F_PKCS12_SETUP_MAC                        122\n# define PKCS12_F_PKCS12_SET_MAC                          123\n# define PKCS12_F_PKCS12_UNPACK_AUTHSAFES                 130\n# define PKCS12_F_PKCS12_UNPACK_P7DATA                    131\n# define PKCS12_F_PKCS12_VERIFY_MAC                       126\n# define PKCS12_F_PKCS8_ADD_KEYUSAGE                      124\n# define PKCS12_F_PKCS8_ENCRYPT                           125\n\n/* Reason codes. */\n# define PKCS12_R_CANT_PACK_STRUCTURE                     100\n# define PKCS12_R_CONTENT_TYPE_NOT_DATA                   121\n# define PKCS12_R_DECODE_ERROR                            101\n# define PKCS12_R_ENCODE_ERROR                            102\n# define PKCS12_R_ENCRYPT_ERROR                           103\n# define PKCS12_R_ERROR_SETTING_ENCRYPTED_DATA_TYPE       120\n# define PKCS12_R_INVALID_NULL_ARGUMENT                   104\n# define PKCS12_R_INVALID_NULL_PKCS12_POINTER             105\n# define PKCS12_R_IV_GEN_ERROR                            106\n# define PKCS12_R_KEY_GEN_ERROR                           107\n# define PKCS12_R_MAC_ABSENT                              108\n# define PKCS12_R_MAC_GENERATION_ERROR                    109\n# define PKCS12_R_MAC_SETUP_ERROR                         110\n# define PKCS12_R_MAC_STRING_SET_ERROR                    111\n# define PKCS12_R_MAC_VERIFY_ERROR                        112\n# define PKCS12_R_MAC_VERIFY_FAILURE                      113\n# define PKCS12_R_PARSE_ERROR                             114\n# define PKCS12_R_PKCS12_ALGOR_CIPHERINIT_ERROR           115\n# define PKCS12_R_PKCS12_CIPHERFINAL_ERROR                116\n# define PKCS12_R_PKCS12_PBE_CRYPT_ERROR                  117\n# define PKCS12_R_UNKNOWN_DIGEST_ALGORITHM                118\n# define PKCS12_R_UNSUPPORTED_PKCS12_MODE                 119\n\n#ifdef  __cplusplus\n}\n#endif\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/arm/include/openssl/pkcs7.h",
    "content": "/* crypto/pkcs7/pkcs7.h */\n/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)\n * All rights reserved.\n *\n * This package is an SSL implementation written\n * by Eric Young (eay@cryptsoft.com).\n * The implementation was written so as to conform with Netscapes SSL.\n *\n * This library is free for commercial and non-commercial use as long as\n * the following conditions are aheared to.  The following conditions\n * apply to all code found in this distribution, be it the RC4, RSA,\n * lhash, DES, etc., code; not just the SSL code.  The SSL documentation\n * included with this distribution is covered by the same copyright terms\n * except that the holder is Tim Hudson (tjh@cryptsoft.com).\n *\n * Copyright remains Eric Young's, and as such any Copyright notices in\n * the code are not to be removed.\n * If this package is used in a product, Eric Young should be given attribution\n * as the author of the parts of the library used.\n * This can be in the form of a textual message at program startup or\n * in documentation (online or textual) provided with the package.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the copyright\n *    notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in the\n *    documentation and/or other materials provided with the distribution.\n * 3. All advertising materials mentioning features or use of this software\n *    must display the following acknowledgement:\n *    \"This product includes cryptographic software written by\n *     Eric Young (eay@cryptsoft.com)\"\n *    The word 'cryptographic' can be left out if the rouines from the library\n *    being used are not cryptographic related :-).\n * 4. If you include any Windows specific code (or a derivative thereof) from\n *    the apps directory (application code) you must include an acknowledgement:\n *    \"This product includes software written by Tim Hudson (tjh@cryptsoft.com)\"\n *\n * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n * SUCH DAMAGE.\n *\n * The licence and distribution terms for any publically available version or\n * derivative of this code cannot be changed.  i.e. this code cannot simply be\n * copied and put under another distribution licence\n * [including the GNU Public Licence.]\n */\n\n#ifndef HEADER_PKCS7_H\n# define HEADER_PKCS7_H\n\n# include <openssl/asn1.h>\n# include <openssl/bio.h>\n# include <openssl/e_os2.h>\n\n# include <openssl/symhacks.h>\n# include <openssl/ossl_typ.h>\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n# ifdef OPENSSL_SYS_WIN32\n/* Under Win32 thes are defined in wincrypt.h */\n#  undef PKCS7_ISSUER_AND_SERIAL\n#  undef PKCS7_SIGNER_INFO\n# endif\n\n/*-\nEncryption_ID           DES-CBC\nDigest_ID               MD5\nDigest_Encryption_ID    rsaEncryption\nKey_Encryption_ID       rsaEncryption\n*/\n\ntypedef struct pkcs7_issuer_and_serial_st {\n    X509_NAME *issuer;\n    ASN1_INTEGER *serial;\n} PKCS7_ISSUER_AND_SERIAL;\n\ntypedef struct pkcs7_signer_info_st {\n    ASN1_INTEGER *version;      /* version 1 */\n    PKCS7_ISSUER_AND_SERIAL *issuer_and_serial;\n    X509_ALGOR *digest_alg;\n    STACK_OF(X509_ATTRIBUTE) *auth_attr; /* [ 0 ] */\n    X509_ALGOR *digest_enc_alg;\n    ASN1_OCTET_STRING *enc_digest;\n    STACK_OF(X509_ATTRIBUTE) *unauth_attr; /* [ 1 ] */\n    /* The private key to sign with */\n    EVP_PKEY *pkey;\n} PKCS7_SIGNER_INFO;\n\nDECLARE_STACK_OF(PKCS7_SIGNER_INFO)\nDECLARE_ASN1_SET_OF(PKCS7_SIGNER_INFO)\n\ntypedef struct pkcs7_recip_info_st {\n    ASN1_INTEGER *version;      /* version 0 */\n    PKCS7_ISSUER_AND_SERIAL *issuer_and_serial;\n    X509_ALGOR *key_enc_algor;\n    ASN1_OCTET_STRING *enc_key;\n    X509 *cert;                 /* get the pub-key from this */\n} PKCS7_RECIP_INFO;\n\nDECLARE_STACK_OF(PKCS7_RECIP_INFO)\nDECLARE_ASN1_SET_OF(PKCS7_RECIP_INFO)\n\ntypedef struct pkcs7_signed_st {\n    ASN1_INTEGER *version;      /* version 1 */\n    STACK_OF(X509_ALGOR) *md_algs; /* md used */\n    STACK_OF(X509) *cert;       /* [ 0 ] */\n    STACK_OF(X509_CRL) *crl;    /* [ 1 ] */\n    STACK_OF(PKCS7_SIGNER_INFO) *signer_info;\n    struct pkcs7_st *contents;\n} PKCS7_SIGNED;\n/*\n * The above structure is very very similar to PKCS7_SIGN_ENVELOPE. How about\n * merging the two\n */\n\ntypedef struct pkcs7_enc_content_st {\n    ASN1_OBJECT *content_type;\n    X509_ALGOR *algorithm;\n    ASN1_OCTET_STRING *enc_data; /* [ 0 ] */\n    const EVP_CIPHER *cipher;\n} PKCS7_ENC_CONTENT;\n\ntypedef struct pkcs7_enveloped_st {\n    ASN1_INTEGER *version;      /* version 0 */\n    STACK_OF(PKCS7_RECIP_INFO) *recipientinfo;\n    PKCS7_ENC_CONTENT *enc_data;\n} PKCS7_ENVELOPE;\n\ntypedef struct pkcs7_signedandenveloped_st {\n    ASN1_INTEGER *version;      /* version 1 */\n    STACK_OF(X509_ALGOR) *md_algs; /* md used */\n    STACK_OF(X509) *cert;       /* [ 0 ] */\n    STACK_OF(X509_CRL) *crl;    /* [ 1 ] */\n    STACK_OF(PKCS7_SIGNER_INFO) *signer_info;\n    PKCS7_ENC_CONTENT *enc_data;\n    STACK_OF(PKCS7_RECIP_INFO) *recipientinfo;\n} PKCS7_SIGN_ENVELOPE;\n\ntypedef struct pkcs7_digest_st {\n    ASN1_INTEGER *version;      /* version 0 */\n    X509_ALGOR *md;             /* md used */\n    struct pkcs7_st *contents;\n    ASN1_OCTET_STRING *digest;\n} PKCS7_DIGEST;\n\ntypedef struct pkcs7_encrypted_st {\n    ASN1_INTEGER *version;      /* version 0 */\n    PKCS7_ENC_CONTENT *enc_data;\n} PKCS7_ENCRYPT;\n\ntypedef struct pkcs7_st {\n    /*\n     * The following is non NULL if it contains ASN1 encoding of this\n     * structure\n     */\n    unsigned char *asn1;\n    long length;\n# define PKCS7_S_HEADER  0\n# define PKCS7_S_BODY    1\n# define PKCS7_S_TAIL    2\n    int state;                  /* used during processing */\n    int detached;\n    ASN1_OBJECT *type;\n    /* content as defined by the type */\n    /*\n     * all encryption/message digests are applied to the 'contents', leaving\n     * out the 'type' field.\n     */\n    union {\n        char *ptr;\n        /* NID_pkcs7_data */\n        ASN1_OCTET_STRING *data;\n        /* NID_pkcs7_signed */\n        PKCS7_SIGNED *sign;\n        /* NID_pkcs7_enveloped */\n        PKCS7_ENVELOPE *enveloped;\n        /* NID_pkcs7_signedAndEnveloped */\n        PKCS7_SIGN_ENVELOPE *signed_and_enveloped;\n        /* NID_pkcs7_digest */\n        PKCS7_DIGEST *digest;\n        /* NID_pkcs7_encrypted */\n        PKCS7_ENCRYPT *encrypted;\n        /* Anything else */\n        ASN1_TYPE *other;\n    } d;\n} PKCS7;\n\nDECLARE_STACK_OF(PKCS7)\nDECLARE_ASN1_SET_OF(PKCS7)\nDECLARE_PKCS12_STACK_OF(PKCS7)\n\n# define PKCS7_OP_SET_DETACHED_SIGNATURE 1\n# define PKCS7_OP_GET_DETACHED_SIGNATURE 2\n\n# define PKCS7_get_signed_attributes(si) ((si)->auth_attr)\n# define PKCS7_get_attributes(si)        ((si)->unauth_attr)\n\n# define PKCS7_type_is_signed(a) (OBJ_obj2nid((a)->type) == NID_pkcs7_signed)\n# define PKCS7_type_is_encrypted(a) (OBJ_obj2nid((a)->type) == NID_pkcs7_encrypted)\n# define PKCS7_type_is_enveloped(a) (OBJ_obj2nid((a)->type) == NID_pkcs7_enveloped)\n# define PKCS7_type_is_signedAndEnveloped(a) \\\n                (OBJ_obj2nid((a)->type) == NID_pkcs7_signedAndEnveloped)\n# define PKCS7_type_is_data(a)   (OBJ_obj2nid((a)->type) == NID_pkcs7_data)\n# define PKCS7_type_is_digest(a)   (OBJ_obj2nid((a)->type) == NID_pkcs7_digest)\n\n# define PKCS7_set_detached(p,v) \\\n                PKCS7_ctrl(p,PKCS7_OP_SET_DETACHED_SIGNATURE,v,NULL)\n# define PKCS7_get_detached(p) \\\n                PKCS7_ctrl(p,PKCS7_OP_GET_DETACHED_SIGNATURE,0,NULL)\n\n# define PKCS7_is_detached(p7) (PKCS7_type_is_signed(p7) && PKCS7_get_detached(p7))\n\n/* S/MIME related flags */\n\n# define PKCS7_TEXT              0x1\n# define PKCS7_NOCERTS           0x2\n# define PKCS7_NOSIGS            0x4\n# define PKCS7_NOCHAIN           0x8\n# define PKCS7_NOINTERN          0x10\n# define PKCS7_NOVERIFY          0x20\n# define PKCS7_DETACHED          0x40\n# define PKCS7_BINARY            0x80\n# define PKCS7_NOATTR            0x100\n# define PKCS7_NOSMIMECAP        0x200\n# define PKCS7_NOOLDMIMETYPE     0x400\n# define PKCS7_CRLFEOL           0x800\n# define PKCS7_STREAM            0x1000\n# define PKCS7_NOCRL             0x2000\n# define PKCS7_PARTIAL           0x4000\n# define PKCS7_REUSE_DIGEST      0x8000\n\n/* Flags: for compatibility with older code */\n\n# define SMIME_TEXT      PKCS7_TEXT\n# define SMIME_NOCERTS   PKCS7_NOCERTS\n# define SMIME_NOSIGS    PKCS7_NOSIGS\n# define SMIME_NOCHAIN   PKCS7_NOCHAIN\n# define SMIME_NOINTERN  PKCS7_NOINTERN\n# define SMIME_NOVERIFY  PKCS7_NOVERIFY\n# define SMIME_DETACHED  PKCS7_DETACHED\n# define SMIME_BINARY    PKCS7_BINARY\n# define SMIME_NOATTR    PKCS7_NOATTR\n\nDECLARE_ASN1_FUNCTIONS(PKCS7_ISSUER_AND_SERIAL)\n\nint PKCS7_ISSUER_AND_SERIAL_digest(PKCS7_ISSUER_AND_SERIAL *data,\n                                   const EVP_MD *type, unsigned char *md,\n                                   unsigned int *len);\n# ifndef OPENSSL_NO_FP_API\nPKCS7 *d2i_PKCS7_fp(FILE *fp, PKCS7 **p7);\nint i2d_PKCS7_fp(FILE *fp, PKCS7 *p7);\n# endif\nPKCS7 *PKCS7_dup(PKCS7 *p7);\nPKCS7 *d2i_PKCS7_bio(BIO *bp, PKCS7 **p7);\nint i2d_PKCS7_bio(BIO *bp, PKCS7 *p7);\nint i2d_PKCS7_bio_stream(BIO *out, PKCS7 *p7, BIO *in, int flags);\nint PEM_write_bio_PKCS7_stream(BIO *out, PKCS7 *p7, BIO *in, int flags);\n\nDECLARE_ASN1_FUNCTIONS(PKCS7_SIGNER_INFO)\nDECLARE_ASN1_FUNCTIONS(PKCS7_RECIP_INFO)\nDECLARE_ASN1_FUNCTIONS(PKCS7_SIGNED)\nDECLARE_ASN1_FUNCTIONS(PKCS7_ENC_CONTENT)\nDECLARE_ASN1_FUNCTIONS(PKCS7_ENVELOPE)\nDECLARE_ASN1_FUNCTIONS(PKCS7_SIGN_ENVELOPE)\nDECLARE_ASN1_FUNCTIONS(PKCS7_DIGEST)\nDECLARE_ASN1_FUNCTIONS(PKCS7_ENCRYPT)\nDECLARE_ASN1_FUNCTIONS(PKCS7)\n\nDECLARE_ASN1_ITEM(PKCS7_ATTR_SIGN)\nDECLARE_ASN1_ITEM(PKCS7_ATTR_VERIFY)\n\nDECLARE_ASN1_NDEF_FUNCTION(PKCS7)\nDECLARE_ASN1_PRINT_FUNCTION(PKCS7)\n\nlong PKCS7_ctrl(PKCS7 *p7, int cmd, long larg, char *parg);\n\nint PKCS7_set_type(PKCS7 *p7, int type);\nint PKCS7_set0_type_other(PKCS7 *p7, int type, ASN1_TYPE *other);\nint PKCS7_set_content(PKCS7 *p7, PKCS7 *p7_data);\nint PKCS7_SIGNER_INFO_set(PKCS7_SIGNER_INFO *p7i, X509 *x509, EVP_PKEY *pkey,\n                          const EVP_MD *dgst);\nint PKCS7_SIGNER_INFO_sign(PKCS7_SIGNER_INFO *si);\nint PKCS7_add_signer(PKCS7 *p7, PKCS7_SIGNER_INFO *p7i);\nint PKCS7_add_certificate(PKCS7 *p7, X509 *x509);\nint PKCS7_add_crl(PKCS7 *p7, X509_CRL *x509);\nint PKCS7_content_new(PKCS7 *p7, int nid);\nint PKCS7_dataVerify(X509_STORE *cert_store, X509_STORE_CTX *ctx,\n                     BIO *bio, PKCS7 *p7, PKCS7_SIGNER_INFO *si);\nint PKCS7_signatureVerify(BIO *bio, PKCS7 *p7, PKCS7_SIGNER_INFO *si,\n                          X509 *x509);\n\nBIO *PKCS7_dataInit(PKCS7 *p7, BIO *bio);\nint PKCS7_dataFinal(PKCS7 *p7, BIO *bio);\nBIO *PKCS7_dataDecode(PKCS7 *p7, EVP_PKEY *pkey, BIO *in_bio, X509 *pcert);\n\nPKCS7_SIGNER_INFO *PKCS7_add_signature(PKCS7 *p7, X509 *x509,\n                                       EVP_PKEY *pkey, const EVP_MD *dgst);\nX509 *PKCS7_cert_from_signer_info(PKCS7 *p7, PKCS7_SIGNER_INFO *si);\nint PKCS7_set_digest(PKCS7 *p7, const EVP_MD *md);\nSTACK_OF(PKCS7_SIGNER_INFO) *PKCS7_get_signer_info(PKCS7 *p7);\n\nPKCS7_RECIP_INFO *PKCS7_add_recipient(PKCS7 *p7, X509 *x509);\nvoid PKCS7_SIGNER_INFO_get0_algs(PKCS7_SIGNER_INFO *si, EVP_PKEY **pk,\n                                 X509_ALGOR **pdig, X509_ALGOR **psig);\nvoid PKCS7_RECIP_INFO_get0_alg(PKCS7_RECIP_INFO *ri, X509_ALGOR **penc);\nint PKCS7_add_recipient_info(PKCS7 *p7, PKCS7_RECIP_INFO *ri);\nint PKCS7_RECIP_INFO_set(PKCS7_RECIP_INFO *p7i, X509 *x509);\nint PKCS7_set_cipher(PKCS7 *p7, const EVP_CIPHER *cipher);\nint PKCS7_stream(unsigned char ***boundary, PKCS7 *p7);\n\nPKCS7_ISSUER_AND_SERIAL *PKCS7_get_issuer_and_serial(PKCS7 *p7, int idx);\nASN1_OCTET_STRING *PKCS7_digest_from_attributes(STACK_OF(X509_ATTRIBUTE) *sk);\nint PKCS7_add_signed_attribute(PKCS7_SIGNER_INFO *p7si, int nid, int type,\n                               void *data);\nint PKCS7_add_attribute(PKCS7_SIGNER_INFO *p7si, int nid, int atrtype,\n                        void *value);\nASN1_TYPE *PKCS7_get_attribute(PKCS7_SIGNER_INFO *si, int nid);\nASN1_TYPE *PKCS7_get_signed_attribute(PKCS7_SIGNER_INFO *si, int nid);\nint PKCS7_set_signed_attributes(PKCS7_SIGNER_INFO *p7si,\n                                STACK_OF(X509_ATTRIBUTE) *sk);\nint PKCS7_set_attributes(PKCS7_SIGNER_INFO *p7si,\n                         STACK_OF(X509_ATTRIBUTE) *sk);\n\nPKCS7 *PKCS7_sign(X509 *signcert, EVP_PKEY *pkey, STACK_OF(X509) *certs,\n                  BIO *data, int flags);\n\nPKCS7_SIGNER_INFO *PKCS7_sign_add_signer(PKCS7 *p7,\n                                         X509 *signcert, EVP_PKEY *pkey,\n                                         const EVP_MD *md, int flags);\n\nint PKCS7_final(PKCS7 *p7, BIO *data, int flags);\nint PKCS7_verify(PKCS7 *p7, STACK_OF(X509) *certs, X509_STORE *store,\n                 BIO *indata, BIO *out, int flags);\nSTACK_OF(X509) *PKCS7_get0_signers(PKCS7 *p7, STACK_OF(X509) *certs,\n                                   int flags);\nPKCS7 *PKCS7_encrypt(STACK_OF(X509) *certs, BIO *in, const EVP_CIPHER *cipher,\n                     int flags);\nint PKCS7_decrypt(PKCS7 *p7, EVP_PKEY *pkey, X509 *cert, BIO *data,\n                  int flags);\n\nint PKCS7_add_attrib_smimecap(PKCS7_SIGNER_INFO *si,\n                              STACK_OF(X509_ALGOR) *cap);\nSTACK_OF(X509_ALGOR) *PKCS7_get_smimecap(PKCS7_SIGNER_INFO *si);\nint PKCS7_simple_smimecap(STACK_OF(X509_ALGOR) *sk, int nid, int arg);\n\nint PKCS7_add_attrib_content_type(PKCS7_SIGNER_INFO *si, ASN1_OBJECT *coid);\nint PKCS7_add0_attrib_signing_time(PKCS7_SIGNER_INFO *si, ASN1_TIME *t);\nint PKCS7_add1_attrib_digest(PKCS7_SIGNER_INFO *si,\n                             const unsigned char *md, int mdlen);\n\nint SMIME_write_PKCS7(BIO *bio, PKCS7 *p7, BIO *data, int flags);\nPKCS7 *SMIME_read_PKCS7(BIO *bio, BIO **bcont);\n\nBIO *BIO_new_PKCS7(BIO *out, PKCS7 *p7);\n\n/* BEGIN ERROR CODES */\n/*\n * The following lines are auto generated by the script mkerr.pl. Any changes\n * made after this point may be overwritten when the script is next run.\n */\nvoid ERR_load_PKCS7_strings(void);\n\n/* Error codes for the PKCS7 functions. */\n\n/* Function codes. */\n# define PKCS7_F_B64_READ_PKCS7                           120\n# define PKCS7_F_B64_WRITE_PKCS7                          121\n# define PKCS7_F_DO_PKCS7_SIGNED_ATTRIB                   136\n# define PKCS7_F_I2D_PKCS7_BIO_STREAM                     140\n# define PKCS7_F_PKCS7_ADD0_ATTRIB_SIGNING_TIME           135\n# define PKCS7_F_PKCS7_ADD_ATTRIB_SMIMECAP                118\n# define PKCS7_F_PKCS7_ADD_CERTIFICATE                    100\n# define PKCS7_F_PKCS7_ADD_CRL                            101\n# define PKCS7_F_PKCS7_ADD_RECIPIENT_INFO                 102\n# define PKCS7_F_PKCS7_ADD_SIGNATURE                      131\n# define PKCS7_F_PKCS7_ADD_SIGNER                         103\n# define PKCS7_F_PKCS7_BIO_ADD_DIGEST                     125\n# define PKCS7_F_PKCS7_COPY_EXISTING_DIGEST               138\n# define PKCS7_F_PKCS7_CTRL                               104\n# define PKCS7_F_PKCS7_DATADECODE                         112\n# define PKCS7_F_PKCS7_DATAFINAL                          128\n# define PKCS7_F_PKCS7_DATAINIT                           105\n# define PKCS7_F_PKCS7_DATASIGN                           106\n# define PKCS7_F_PKCS7_DATAVERIFY                         107\n# define PKCS7_F_PKCS7_DECRYPT                            114\n# define PKCS7_F_PKCS7_DECRYPT_RINFO                      133\n# define PKCS7_F_PKCS7_ENCODE_RINFO                       132\n# define PKCS7_F_PKCS7_ENCRYPT                            115\n# define PKCS7_F_PKCS7_FINAL                              134\n# define PKCS7_F_PKCS7_FIND_DIGEST                        127\n# define PKCS7_F_PKCS7_GET0_SIGNERS                       124\n# define PKCS7_F_PKCS7_RECIP_INFO_SET                     130\n# define PKCS7_F_PKCS7_SET_CIPHER                         108\n# define PKCS7_F_PKCS7_SET_CONTENT                        109\n# define PKCS7_F_PKCS7_SET_DIGEST                         126\n# define PKCS7_F_PKCS7_SET_TYPE                           110\n# define PKCS7_F_PKCS7_SIGN                               116\n# define PKCS7_F_PKCS7_SIGNATUREVERIFY                    113\n# define PKCS7_F_PKCS7_SIGNER_INFO_SET                    129\n# define PKCS7_F_PKCS7_SIGNER_INFO_SIGN                   139\n# define PKCS7_F_PKCS7_SIGN_ADD_SIGNER                    137\n# define PKCS7_F_PKCS7_SIMPLE_SMIMECAP                    119\n# define PKCS7_F_PKCS7_VERIFY                             117\n# define PKCS7_F_SMIME_READ_PKCS7                         122\n# define PKCS7_F_SMIME_TEXT                               123\n\n/* Reason codes. */\n# define PKCS7_R_CERTIFICATE_VERIFY_ERROR                 117\n# define PKCS7_R_CIPHER_HAS_NO_OBJECT_IDENTIFIER          144\n# define PKCS7_R_CIPHER_NOT_INITIALIZED                   116\n# define PKCS7_R_CONTENT_AND_DATA_PRESENT                 118\n# define PKCS7_R_CTRL_ERROR                               152\n# define PKCS7_R_DECODE_ERROR                             130\n# define PKCS7_R_DECRYPTED_KEY_IS_WRONG_LENGTH            100\n# define PKCS7_R_DECRYPT_ERROR                            119\n# define PKCS7_R_DIGEST_FAILURE                           101\n# define PKCS7_R_ENCRYPTION_CTRL_FAILURE                  149\n# define PKCS7_R_ENCRYPTION_NOT_SUPPORTED_FOR_THIS_KEY_TYPE 150\n# define PKCS7_R_ERROR_ADDING_RECIPIENT                   120\n# define PKCS7_R_ERROR_SETTING_CIPHER                     121\n# define PKCS7_R_INVALID_MIME_TYPE                        131\n# define PKCS7_R_INVALID_NULL_POINTER                     143\n# define PKCS7_R_INVALID_SIGNED_DATA_TYPE                 155\n# define PKCS7_R_MIME_NO_CONTENT_TYPE                     132\n# define PKCS7_R_MIME_PARSE_ERROR                         133\n# define PKCS7_R_MIME_SIG_PARSE_ERROR                     134\n# define PKCS7_R_MISSING_CERIPEND_INFO                    103\n# define PKCS7_R_NO_CONTENT                               122\n# define PKCS7_R_NO_CONTENT_TYPE                          135\n# define PKCS7_R_NO_DEFAULT_DIGEST                        151\n# define PKCS7_R_NO_MATCHING_DIGEST_TYPE_FOUND            154\n# define PKCS7_R_NO_MULTIPART_BODY_FAILURE                136\n# define PKCS7_R_NO_MULTIPART_BOUNDARY                    137\n# define PKCS7_R_NO_RECIPIENT_MATCHES_CERTIFICATE         115\n# define PKCS7_R_NO_RECIPIENT_MATCHES_KEY                 146\n# define PKCS7_R_NO_SIGNATURES_ON_DATA                    123\n# define PKCS7_R_NO_SIGNERS                               142\n# define PKCS7_R_NO_SIG_CONTENT_TYPE                      138\n# define PKCS7_R_OPERATION_NOT_SUPPORTED_ON_THIS_TYPE     104\n# define PKCS7_R_PKCS7_ADD_SIGNATURE_ERROR                124\n# define PKCS7_R_PKCS7_ADD_SIGNER_ERROR                   153\n# define PKCS7_R_PKCS7_DATAFINAL                          126\n# define PKCS7_R_PKCS7_DATAFINAL_ERROR                    125\n# define PKCS7_R_PKCS7_DATASIGN                           145\n# define PKCS7_R_PKCS7_PARSE_ERROR                        139\n# define PKCS7_R_PKCS7_SIG_PARSE_ERROR                    140\n# define PKCS7_R_PRIVATE_KEY_DOES_NOT_MATCH_CERTIFICATE   127\n# define PKCS7_R_SIGNATURE_FAILURE                        105\n# define PKCS7_R_SIGNER_CERTIFICATE_NOT_FOUND             128\n# define PKCS7_R_SIGNING_CTRL_FAILURE                     147\n# define PKCS7_R_SIGNING_NOT_SUPPORTED_FOR_THIS_KEY_TYPE  148\n# define PKCS7_R_SIG_INVALID_MIME_TYPE                    141\n# define PKCS7_R_SMIME_TEXT_ERROR                         129\n# define PKCS7_R_UNABLE_TO_FIND_CERTIFICATE               106\n# define PKCS7_R_UNABLE_TO_FIND_MEM_BIO                   107\n# define PKCS7_R_UNABLE_TO_FIND_MESSAGE_DIGEST            108\n# define PKCS7_R_UNKNOWN_DIGEST_TYPE                      109\n# define PKCS7_R_UNKNOWN_OPERATION                        110\n# define PKCS7_R_UNSUPPORTED_CIPHER_TYPE                  111\n# define PKCS7_R_UNSUPPORTED_CONTENT_TYPE                 112\n# define PKCS7_R_WRONG_CONTENT_TYPE                       113\n# define PKCS7_R_WRONG_PKCS7_TYPE                         114\n\n#ifdef  __cplusplus\n}\n#endif\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/arm/include/openssl/pqueue.h",
    "content": "/* crypto/pqueue/pqueue.h */\n/*\n * DTLS implementation written by Nagendra Modadugu\n * (nagendra@cs.stanford.edu) for the OpenSSL project 2005.\n */\n/* ====================================================================\n * Copyright (c) 1999-2005 The OpenSSL Project.  All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n *\n * 1. Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n *\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in\n *    the documentation and/or other materials provided with the\n *    distribution.\n *\n * 3. All advertising materials mentioning features or use of this\n *    software must display the following acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)\"\n *\n * 4. The names \"OpenSSL Toolkit\" and \"OpenSSL Project\" must not be used to\n *    endorse or promote products derived from this software without\n *    prior written permission. For written permission, please contact\n *    openssl-core@OpenSSL.org.\n *\n * 5. Products derived from this software may not be called \"OpenSSL\"\n *    nor may \"OpenSSL\" appear in their names without prior written\n *    permission of the OpenSSL Project.\n *\n * 6. Redistributions of any form whatsoever must retain the following\n *    acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)\"\n *\n * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY\n * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\n * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR\n * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\n * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,\n * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED\n * OF THE POSSIBILITY OF SUCH DAMAGE.\n * ====================================================================\n *\n * This product includes cryptographic software written by Eric Young\n * (eay@cryptsoft.com).  This product includes software written by Tim\n * Hudson (tjh@cryptsoft.com).\n *\n */\n\n#ifndef HEADER_PQUEUE_H\n# define HEADER_PQUEUE_H\n\n# include <stdio.h>\n# include <stdlib.h>\n# include <string.h>\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\ntypedef struct _pqueue *pqueue;\n\ntypedef struct _pitem {\n    unsigned char priority[8];  /* 64-bit value in big-endian encoding */\n    void *data;\n    struct _pitem *next;\n} pitem;\n\ntypedef struct _pitem *piterator;\n\npitem *pitem_new(unsigned char *prio64be, void *data);\nvoid pitem_free(pitem *item);\n\npqueue pqueue_new(void);\nvoid pqueue_free(pqueue pq);\n\npitem *pqueue_insert(pqueue pq, pitem *item);\npitem *pqueue_peek(pqueue pq);\npitem *pqueue_pop(pqueue pq);\npitem *pqueue_find(pqueue pq, unsigned char *prio64be);\npitem *pqueue_iterator(pqueue pq);\npitem *pqueue_next(piterator *iter);\n\nvoid pqueue_print(pqueue pq);\nint pqueue_size(pqueue pq);\n\n#ifdef  __cplusplus\n}\n#endif\n#endif                          /* ! HEADER_PQUEUE_H */\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/arm/include/openssl/rand.h",
    "content": "/* crypto/rand/rand.h */\n/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)\n * All rights reserved.\n *\n * This package is an SSL implementation written\n * by Eric Young (eay@cryptsoft.com).\n * The implementation was written so as to conform with Netscapes SSL.\n *\n * This library is free for commercial and non-commercial use as long as\n * the following conditions are aheared to.  The following conditions\n * apply to all code found in this distribution, be it the RC4, RSA,\n * lhash, DES, etc., code; not just the SSL code.  The SSL documentation\n * included with this distribution is covered by the same copyright terms\n * except that the holder is Tim Hudson (tjh@cryptsoft.com).\n *\n * Copyright remains Eric Young's, and as such any Copyright notices in\n * the code are not to be removed.\n * If this package is used in a product, Eric Young should be given attribution\n * as the author of the parts of the library used.\n * This can be in the form of a textual message at program startup or\n * in documentation (online or textual) provided with the package.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the copyright\n *    notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in the\n *    documentation and/or other materials provided with the distribution.\n * 3. All advertising materials mentioning features or use of this software\n *    must display the following acknowledgement:\n *    \"This product includes cryptographic software written by\n *     Eric Young (eay@cryptsoft.com)\"\n *    The word 'cryptographic' can be left out if the rouines from the library\n *    being used are not cryptographic related :-).\n * 4. If you include any Windows specific code (or a derivative thereof) from\n *    the apps directory (application code) you must include an acknowledgement:\n *    \"This product includes software written by Tim Hudson (tjh@cryptsoft.com)\"\n *\n * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n * SUCH DAMAGE.\n *\n * The licence and distribution terms for any publically available version or\n * derivative of this code cannot be changed.  i.e. this code cannot simply be\n * copied and put under another distribution licence\n * [including the GNU Public Licence.]\n */\n\n#ifndef HEADER_RAND_H\n# define HEADER_RAND_H\n\n# include <stdlib.h>\n# include <openssl/ossl_typ.h>\n# include <openssl/e_os2.h>\n\n# if defined(OPENSSL_SYS_WINDOWS)\n#  include <windows.h>\n# endif\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n# if defined(OPENSSL_FIPS)\n#  define FIPS_RAND_SIZE_T size_t\n# endif\n\n/* Already defined in ossl_typ.h */\n/* typedef struct rand_meth_st RAND_METHOD; */\n\nstruct rand_meth_st {\n    void (*seed) (const void *buf, int num);\n    int (*bytes) (unsigned char *buf, int num);\n    void (*cleanup) (void);\n    void (*add) (const void *buf, int num, double entropy);\n    int (*pseudorand) (unsigned char *buf, int num);\n    int (*status) (void);\n};\n\n# ifdef BN_DEBUG\nextern int rand_predictable;\n# endif\n\nint RAND_set_rand_method(const RAND_METHOD *meth);\nconst RAND_METHOD *RAND_get_rand_method(void);\n# ifndef OPENSSL_NO_ENGINE\nint RAND_set_rand_engine(ENGINE *engine);\n# endif\nRAND_METHOD *RAND_SSLeay(void);\nvoid RAND_cleanup(void);\nint RAND_bytes(unsigned char *buf, int num);\nint RAND_pseudo_bytes(unsigned char *buf, int num);\nvoid RAND_seed(const void *buf, int num);\nvoid RAND_add(const void *buf, int num, double entropy);\nint RAND_load_file(const char *file, long max_bytes);\nint RAND_write_file(const char *file);\nconst char *RAND_file_name(char *file, size_t num);\nint RAND_status(void);\nint RAND_query_egd_bytes(const char *path, unsigned char *buf, int bytes);\nint RAND_egd(const char *path);\nint RAND_egd_bytes(const char *path, int bytes);\nint RAND_poll(void);\n\n# if defined(OPENSSL_SYS_WINDOWS) || defined(OPENSSL_SYS_WIN32)\n\nvoid RAND_screen(void);\nint RAND_event(UINT, WPARAM, LPARAM);\n\n# endif\n\n# ifdef OPENSSL_FIPS\nvoid RAND_set_fips_drbg_type(int type, int flags);\nint RAND_init_fips(void);\n# endif\n\n/* BEGIN ERROR CODES */\n/*\n * The following lines are auto generated by the script mkerr.pl. Any changes\n * made after this point may be overwritten when the script is next run.\n */\nvoid ERR_load_RAND_strings(void);\n\n/* Error codes for the RAND functions. */\n\n/* Function codes. */\n# define RAND_F_RAND_GET_RAND_METHOD                      101\n# define RAND_F_RAND_INIT_FIPS                            102\n# define RAND_F_SSLEAY_RAND_BYTES                         100\n\n/* Reason codes. */\n# define RAND_R_DUAL_EC_DRBG_DISABLED                     104\n# define RAND_R_ERROR_INITIALISING_DRBG                   102\n# define RAND_R_ERROR_INSTANTIATING_DRBG                  103\n# define RAND_R_NO_FIPS_RANDOM_METHOD_SET                 101\n# define RAND_R_PRNG_NOT_SEEDED                           100\n\n#ifdef  __cplusplus\n}\n#endif\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/arm/include/openssl/rc2.h",
    "content": "/* crypto/rc2/rc2.h */\n/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)\n * All rights reserved.\n *\n * This package is an SSL implementation written\n * by Eric Young (eay@cryptsoft.com).\n * The implementation was written so as to conform with Netscapes SSL.\n *\n * This library is free for commercial and non-commercial use as long as\n * the following conditions are aheared to.  The following conditions\n * apply to all code found in this distribution, be it the RC4, RSA,\n * lhash, DES, etc., code; not just the SSL code.  The SSL documentation\n * included with this distribution is covered by the same copyright terms\n * except that the holder is Tim Hudson (tjh@cryptsoft.com).\n *\n * Copyright remains Eric Young's, and as such any Copyright notices in\n * the code are not to be removed.\n * If this package is used in a product, Eric Young should be given attribution\n * as the author of the parts of the library used.\n * This can be in the form of a textual message at program startup or\n * in documentation (online or textual) provided with the package.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the copyright\n *    notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in the\n *    documentation and/or other materials provided with the distribution.\n * 3. All advertising materials mentioning features or use of this software\n *    must display the following acknowledgement:\n *    \"This product includes cryptographic software written by\n *     Eric Young (eay@cryptsoft.com)\"\n *    The word 'cryptographic' can be left out if the rouines from the library\n *    being used are not cryptographic related :-).\n * 4. If you include any Windows specific code (or a derivative thereof) from\n *    the apps directory (application code) you must include an acknowledgement:\n *    \"This product includes software written by Tim Hudson (tjh@cryptsoft.com)\"\n *\n * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n * SUCH DAMAGE.\n *\n * The licence and distribution terms for any publically available version or\n * derivative of this code cannot be changed.  i.e. this code cannot simply be\n * copied and put under another distribution licence\n * [including the GNU Public Licence.]\n */\n\n#ifndef HEADER_RC2_H\n# define HEADER_RC2_H\n\n# include <openssl/opensslconf.h>/* OPENSSL_NO_RC2, RC2_INT */\n# ifdef OPENSSL_NO_RC2\n#  error RC2 is disabled.\n# endif\n\n# define RC2_ENCRYPT     1\n# define RC2_DECRYPT     0\n\n# define RC2_BLOCK       8\n# define RC2_KEY_LENGTH  16\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\ntypedef struct rc2_key_st {\n    RC2_INT data[64];\n} RC2_KEY;\n\n# ifdef OPENSSL_FIPS\nvoid private_RC2_set_key(RC2_KEY *key, int len, const unsigned char *data,\n                         int bits);\n# endif\nvoid RC2_set_key(RC2_KEY *key, int len, const unsigned char *data, int bits);\nvoid RC2_ecb_encrypt(const unsigned char *in, unsigned char *out,\n                     RC2_KEY *key, int enc);\nvoid RC2_encrypt(unsigned long *data, RC2_KEY *key);\nvoid RC2_decrypt(unsigned long *data, RC2_KEY *key);\nvoid RC2_cbc_encrypt(const unsigned char *in, unsigned char *out, long length,\n                     RC2_KEY *ks, unsigned char *iv, int enc);\nvoid RC2_cfb64_encrypt(const unsigned char *in, unsigned char *out,\n                       long length, RC2_KEY *schedule, unsigned char *ivec,\n                       int *num, int enc);\nvoid RC2_ofb64_encrypt(const unsigned char *in, unsigned char *out,\n                       long length, RC2_KEY *schedule, unsigned char *ivec,\n                       int *num);\n\n#ifdef  __cplusplus\n}\n#endif\n\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/arm/include/openssl/rc4.h",
    "content": "/* crypto/rc4/rc4.h */\n/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)\n * All rights reserved.\n *\n * This package is an SSL implementation written\n * by Eric Young (eay@cryptsoft.com).\n * The implementation was written so as to conform with Netscapes SSL.\n *\n * This library is free for commercial and non-commercial use as long as\n * the following conditions are aheared to.  The following conditions\n * apply to all code found in this distribution, be it the RC4, RSA,\n * lhash, DES, etc., code; not just the SSL code.  The SSL documentation\n * included with this distribution is covered by the same copyright terms\n * except that the holder is Tim Hudson (tjh@cryptsoft.com).\n *\n * Copyright remains Eric Young's, and as such any Copyright notices in\n * the code are not to be removed.\n * If this package is used in a product, Eric Young should be given attribution\n * as the author of the parts of the library used.\n * This can be in the form of a textual message at program startup or\n * in documentation (online or textual) provided with the package.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the copyright\n *    notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in the\n *    documentation and/or other materials provided with the distribution.\n * 3. All advertising materials mentioning features or use of this software\n *    must display the following acknowledgement:\n *    \"This product includes cryptographic software written by\n *     Eric Young (eay@cryptsoft.com)\"\n *    The word 'cryptographic' can be left out if the rouines from the library\n *    being used are not cryptographic related :-).\n * 4. If you include any Windows specific code (or a derivative thereof) from\n *    the apps directory (application code) you must include an acknowledgement:\n *    \"This product includes software written by Tim Hudson (tjh@cryptsoft.com)\"\n *\n * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n * SUCH DAMAGE.\n *\n * The licence and distribution terms for any publically available version or\n * derivative of this code cannot be changed.  i.e. this code cannot simply be\n * copied and put under another distribution licence\n * [including the GNU Public Licence.]\n */\n\n#ifndef HEADER_RC4_H\n# define HEADER_RC4_H\n\n# include <openssl/opensslconf.h>/* OPENSSL_NO_RC4, RC4_INT */\n# ifdef OPENSSL_NO_RC4\n#  error RC4 is disabled.\n# endif\n\n# include <stddef.h>\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\ntypedef struct rc4_key_st {\n    RC4_INT x, y;\n    RC4_INT data[256];\n} RC4_KEY;\n\nconst char *RC4_options(void);\nvoid RC4_set_key(RC4_KEY *key, int len, const unsigned char *data);\nvoid private_RC4_set_key(RC4_KEY *key, int len, const unsigned char *data);\nvoid RC4(RC4_KEY *key, size_t len, const unsigned char *indata,\n         unsigned char *outdata);\n\n#ifdef  __cplusplus\n}\n#endif\n\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/arm/include/openssl/ripemd.h",
    "content": "/* crypto/ripemd/ripemd.h */\n/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)\n * All rights reserved.\n *\n * This package is an SSL implementation written\n * by Eric Young (eay@cryptsoft.com).\n * The implementation was written so as to conform with Netscapes SSL.\n *\n * This library is free for commercial and non-commercial use as long as\n * the following conditions are aheared to.  The following conditions\n * apply to all code found in this distribution, be it the RC4, RSA,\n * lhash, DES, etc., code; not just the SSL code.  The SSL documentation\n * included with this distribution is covered by the same copyright terms\n * except that the holder is Tim Hudson (tjh@cryptsoft.com).\n *\n * Copyright remains Eric Young's, and as such any Copyright notices in\n * the code are not to be removed.\n * If this package is used in a product, Eric Young should be given attribution\n * as the author of the parts of the library used.\n * This can be in the form of a textual message at program startup or\n * in documentation (online or textual) provided with the package.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the copyright\n *    notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in the\n *    documentation and/or other materials provided with the distribution.\n * 3. All advertising materials mentioning features or use of this software\n *    must display the following acknowledgement:\n *    \"This product includes cryptographic software written by\n *     Eric Young (eay@cryptsoft.com)\"\n *    The word 'cryptographic' can be left out if the rouines from the library\n *    being used are not cryptographic related :-).\n * 4. If you include any Windows specific code (or a derivative thereof) from\n *    the apps directory (application code) you must include an acknowledgement:\n *    \"This product includes software written by Tim Hudson (tjh@cryptsoft.com)\"\n *\n * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n * SUCH DAMAGE.\n *\n * The licence and distribution terms for any publically available version or\n * derivative of this code cannot be changed.  i.e. this code cannot simply be\n * copied and put under another distribution licence\n * [including the GNU Public Licence.]\n */\n\n#ifndef HEADER_RIPEMD_H\n# define HEADER_RIPEMD_H\n\n# include <openssl/e_os2.h>\n# include <stddef.h>\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n# ifdef OPENSSL_NO_RIPEMD\n#  error RIPEMD is disabled.\n# endif\n\n# if defined(__LP32__)\n#  define RIPEMD160_LONG unsigned long\n# elif defined(OPENSSL_SYS_CRAY) || defined(__ILP64__)\n#  define RIPEMD160_LONG unsigned long\n#  define RIPEMD160_LONG_LOG2 3\n# else\n#  define RIPEMD160_LONG unsigned int\n# endif\n\n# define RIPEMD160_CBLOCK        64\n# define RIPEMD160_LBLOCK        (RIPEMD160_CBLOCK/4)\n# define RIPEMD160_DIGEST_LENGTH 20\n\ntypedef struct RIPEMD160state_st {\n    RIPEMD160_LONG A, B, C, D, E;\n    RIPEMD160_LONG Nl, Nh;\n    RIPEMD160_LONG data[RIPEMD160_LBLOCK];\n    unsigned int num;\n} RIPEMD160_CTX;\n\n# ifdef OPENSSL_FIPS\nint private_RIPEMD160_Init(RIPEMD160_CTX *c);\n# endif\nint RIPEMD160_Init(RIPEMD160_CTX *c);\nint RIPEMD160_Update(RIPEMD160_CTX *c, const void *data, size_t len);\nint RIPEMD160_Final(unsigned char *md, RIPEMD160_CTX *c);\nunsigned char *RIPEMD160(const unsigned char *d, size_t n, unsigned char *md);\nvoid RIPEMD160_Transform(RIPEMD160_CTX *c, const unsigned char *b);\n#ifdef  __cplusplus\n}\n#endif\n\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/arm/include/openssl/rsa.h",
    "content": "/* crypto/rsa/rsa.h */\n/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)\n * All rights reserved.\n *\n * This package is an SSL implementation written\n * by Eric Young (eay@cryptsoft.com).\n * The implementation was written so as to conform with Netscapes SSL.\n *\n * This library is free for commercial and non-commercial use as long as\n * the following conditions are aheared to.  The following conditions\n * apply to all code found in this distribution, be it the RC4, RSA,\n * lhash, DES, etc., code; not just the SSL code.  The SSL documentation\n * included with this distribution is covered by the same copyright terms\n * except that the holder is Tim Hudson (tjh@cryptsoft.com).\n *\n * Copyright remains Eric Young's, and as such any Copyright notices in\n * the code are not to be removed.\n * If this package is used in a product, Eric Young should be given attribution\n * as the author of the parts of the library used.\n * This can be in the form of a textual message at program startup or\n * in documentation (online or textual) provided with the package.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the copyright\n *    notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in the\n *    documentation and/or other materials provided with the distribution.\n * 3. All advertising materials mentioning features or use of this software\n *    must display the following acknowledgement:\n *    \"This product includes cryptographic software written by\n *     Eric Young (eay@cryptsoft.com)\"\n *    The word 'cryptographic' can be left out if the rouines from the library\n *    being used are not cryptographic related :-).\n * 4. If you include any Windows specific code (or a derivative thereof) from\n *    the apps directory (application code) you must include an acknowledgement:\n *    \"This product includes software written by Tim Hudson (tjh@cryptsoft.com)\"\n *\n * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n * SUCH DAMAGE.\n *\n * The licence and distribution terms for any publically available version or\n * derivative of this code cannot be changed.  i.e. this code cannot simply be\n * copied and put under another distribution licence\n * [including the GNU Public Licence.]\n */\n\n#ifndef HEADER_RSA_H\n# define HEADER_RSA_H\n\n# include <openssl/asn1.h>\n\n# ifndef OPENSSL_NO_BIO\n#  include <openssl/bio.h>\n# endif\n# include <openssl/crypto.h>\n# include <openssl/ossl_typ.h>\n# ifndef OPENSSL_NO_DEPRECATED\n#  include <openssl/bn.h>\n# endif\n\n# ifdef OPENSSL_NO_RSA\n#  error RSA is disabled.\n# endif\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n/* Declared already in ossl_typ.h */\n/* typedef struct rsa_st RSA; */\n/* typedef struct rsa_meth_st RSA_METHOD; */\n\nstruct rsa_meth_st {\n    const char *name;\n    int (*rsa_pub_enc) (int flen, const unsigned char *from,\n                        unsigned char *to, RSA *rsa, int padding);\n    int (*rsa_pub_dec) (int flen, const unsigned char *from,\n                        unsigned char *to, RSA *rsa, int padding);\n    int (*rsa_priv_enc) (int flen, const unsigned char *from,\n                         unsigned char *to, RSA *rsa, int padding);\n    int (*rsa_priv_dec) (int flen, const unsigned char *from,\n                         unsigned char *to, RSA *rsa, int padding);\n    /* Can be null */\n    int (*rsa_mod_exp) (BIGNUM *r0, const BIGNUM *I, RSA *rsa, BN_CTX *ctx);\n    /* Can be null */\n    int (*bn_mod_exp) (BIGNUM *r, const BIGNUM *a, const BIGNUM *p,\n                       const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx);\n    /* called at new */\n    int (*init) (RSA *rsa);\n    /* called at free */\n    int (*finish) (RSA *rsa);\n    /* RSA_METHOD_FLAG_* things */\n    int flags;\n    /* may be needed! */\n    char *app_data;\n    /*\n     * New sign and verify functions: some libraries don't allow arbitrary\n     * data to be signed/verified: this allows them to be used. Note: for\n     * this to work the RSA_public_decrypt() and RSA_private_encrypt() should\n     * *NOT* be used RSA_sign(), RSA_verify() should be used instead. Note:\n     * for backwards compatibility this functionality is only enabled if the\n     * RSA_FLAG_SIGN_VER option is set in 'flags'.\n     */\n    int (*rsa_sign) (int type,\n                     const unsigned char *m, unsigned int m_length,\n                     unsigned char *sigret, unsigned int *siglen,\n                     const RSA *rsa);\n    int (*rsa_verify) (int dtype, const unsigned char *m,\n                       unsigned int m_length, const unsigned char *sigbuf,\n                       unsigned int siglen, const RSA *rsa);\n    /*\n     * If this callback is NULL, the builtin software RSA key-gen will be\n     * used. This is for behavioural compatibility whilst the code gets\n     * rewired, but one day it would be nice to assume there are no such\n     * things as \"builtin software\" implementations.\n     */\n    int (*rsa_keygen) (RSA *rsa, int bits, BIGNUM *e, BN_GENCB *cb);\n};\n\nstruct rsa_st {\n    /*\n     * The first parameter is used to pickup errors where this is passed\n     * instead of aEVP_PKEY, it is set to 0\n     */\n    int pad;\n    long version;\n    const RSA_METHOD *meth;\n    /* functional reference if 'meth' is ENGINE-provided */\n    ENGINE *engine;\n    BIGNUM *n;\n    BIGNUM *e;\n    BIGNUM *d;\n    BIGNUM *p;\n    BIGNUM *q;\n    BIGNUM *dmp1;\n    BIGNUM *dmq1;\n    BIGNUM *iqmp;\n    /* be careful using this if the RSA structure is shared */\n    CRYPTO_EX_DATA ex_data;\n    int references;\n    int flags;\n    /* Used to cache montgomery values */\n    BN_MONT_CTX *_method_mod_n;\n    BN_MONT_CTX *_method_mod_p;\n    BN_MONT_CTX *_method_mod_q;\n    /*\n     * all BIGNUM values are actually in the following data, if it is not\n     * NULL\n     */\n    char *bignum_data;\n    BN_BLINDING *blinding;\n    BN_BLINDING *mt_blinding;\n};\n\n# ifndef OPENSSL_RSA_MAX_MODULUS_BITS\n#  define OPENSSL_RSA_MAX_MODULUS_BITS   16384\n# endif\n\n# ifndef OPENSSL_RSA_SMALL_MODULUS_BITS\n#  define OPENSSL_RSA_SMALL_MODULUS_BITS 3072\n# endif\n# ifndef OPENSSL_RSA_MAX_PUBEXP_BITS\n\n/* exponent limit enforced for \"large\" modulus only */\n#  define OPENSSL_RSA_MAX_PUBEXP_BITS    64\n# endif\n\n# define RSA_3   0x3L\n# define RSA_F4  0x10001L\n\n# define RSA_METHOD_FLAG_NO_CHECK        0x0001/* don't check pub/private\n                                                * match */\n\n# define RSA_FLAG_CACHE_PUBLIC           0x0002\n# define RSA_FLAG_CACHE_PRIVATE          0x0004\n# define RSA_FLAG_BLINDING               0x0008\n# define RSA_FLAG_THREAD_SAFE            0x0010\n/*\n * This flag means the private key operations will be handled by rsa_mod_exp\n * and that they do not depend on the private key components being present:\n * for example a key stored in external hardware. Without this flag\n * bn_mod_exp gets called when private key components are absent.\n */\n# define RSA_FLAG_EXT_PKEY               0x0020\n\n/*\n * This flag in the RSA_METHOD enables the new rsa_sign, rsa_verify\n * functions.\n */\n# define RSA_FLAG_SIGN_VER               0x0040\n\n/*\n * new with 0.9.6j and 0.9.7b; the built-in\n * RSA implementation now uses blinding by\n * default (ignoring RSA_FLAG_BLINDING),\n * but other engines might not need it\n */\n# define RSA_FLAG_NO_BLINDING            0x0080\n/*\n * new with 0.9.8f; the built-in RSA\n * implementation now uses constant time\n * operations by default in private key operations,\n * e.g., constant time modular exponentiation,\n * modular inverse without leaking branches,\n * division without leaking branches. This\n * flag disables these constant time\n * operations and results in faster RSA\n * private key operations.\n */\n# define RSA_FLAG_NO_CONSTTIME           0x0100\n# ifdef OPENSSL_USE_DEPRECATED\n/* deprecated name for the flag*/\n/*\n * new with 0.9.7h; the built-in RSA\n * implementation now uses constant time\n * modular exponentiation for secret exponents\n * by default. This flag causes the\n * faster variable sliding window method to\n * be used for all exponents.\n */\n#  define RSA_FLAG_NO_EXP_CONSTTIME RSA_FLAG_NO_CONSTTIME\n# endif\n\n# define EVP_PKEY_CTX_set_rsa_padding(ctx, pad) \\\n        EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_RSA, -1, EVP_PKEY_CTRL_RSA_PADDING, \\\n                                pad, NULL)\n\n# define EVP_PKEY_CTX_get_rsa_padding(ctx, ppad) \\\n        EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_RSA, -1, \\\n                                EVP_PKEY_CTRL_GET_RSA_PADDING, 0, ppad)\n\n# define EVP_PKEY_CTX_set_rsa_pss_saltlen(ctx, len) \\\n        EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_RSA, \\\n                                (EVP_PKEY_OP_SIGN|EVP_PKEY_OP_VERIFY), \\\n                                EVP_PKEY_CTRL_RSA_PSS_SALTLEN, \\\n                                len, NULL)\n\n# define EVP_PKEY_CTX_get_rsa_pss_saltlen(ctx, plen) \\\n        EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_RSA, \\\n                                (EVP_PKEY_OP_SIGN|EVP_PKEY_OP_VERIFY), \\\n                                EVP_PKEY_CTRL_GET_RSA_PSS_SALTLEN, \\\n                                0, plen)\n\n# define EVP_PKEY_CTX_set_rsa_keygen_bits(ctx, bits) \\\n        EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_RSA, EVP_PKEY_OP_KEYGEN, \\\n                                EVP_PKEY_CTRL_RSA_KEYGEN_BITS, bits, NULL)\n\n# define EVP_PKEY_CTX_set_rsa_keygen_pubexp(ctx, pubexp) \\\n        EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_RSA, EVP_PKEY_OP_KEYGEN, \\\n                                EVP_PKEY_CTRL_RSA_KEYGEN_PUBEXP, 0, pubexp)\n\n# define  EVP_PKEY_CTX_set_rsa_mgf1_md(ctx, md)  \\\n                EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_RSA, \\\n                        EVP_PKEY_OP_TYPE_SIG | EVP_PKEY_OP_TYPE_CRYPT, \\\n                                EVP_PKEY_CTRL_RSA_MGF1_MD, 0, (void *)md)\n\n# define  EVP_PKEY_CTX_set_rsa_oaep_md(ctx, md)  \\\n                EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_RSA, EVP_PKEY_OP_TYPE_CRYPT,  \\\n                                EVP_PKEY_CTRL_RSA_OAEP_MD, 0, (void *)md)\n\n# define  EVP_PKEY_CTX_get_rsa_mgf1_md(ctx, pmd) \\\n                EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_RSA, \\\n                        EVP_PKEY_OP_TYPE_SIG | EVP_PKEY_OP_TYPE_CRYPT, \\\n                                EVP_PKEY_CTRL_GET_RSA_MGF1_MD, 0, (void *)pmd)\n\n# define  EVP_PKEY_CTX_get_rsa_oaep_md(ctx, pmd) \\\n                EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_RSA, EVP_PKEY_OP_TYPE_CRYPT,  \\\n                                EVP_PKEY_CTRL_GET_RSA_OAEP_MD, 0, (void *)pmd)\n\n# define  EVP_PKEY_CTX_set0_rsa_oaep_label(ctx, l, llen) \\\n                EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_RSA, EVP_PKEY_OP_TYPE_CRYPT,  \\\n                                EVP_PKEY_CTRL_RSA_OAEP_LABEL, llen, (void *)l)\n\n# define  EVP_PKEY_CTX_get0_rsa_oaep_label(ctx, l)       \\\n                EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_RSA, EVP_PKEY_OP_TYPE_CRYPT,  \\\n                                EVP_PKEY_CTRL_GET_RSA_OAEP_LABEL, 0, (void *)l)\n\n# define EVP_PKEY_CTRL_RSA_PADDING       (EVP_PKEY_ALG_CTRL + 1)\n# define EVP_PKEY_CTRL_RSA_PSS_SALTLEN   (EVP_PKEY_ALG_CTRL + 2)\n\n# define EVP_PKEY_CTRL_RSA_KEYGEN_BITS   (EVP_PKEY_ALG_CTRL + 3)\n# define EVP_PKEY_CTRL_RSA_KEYGEN_PUBEXP (EVP_PKEY_ALG_CTRL + 4)\n# define EVP_PKEY_CTRL_RSA_MGF1_MD       (EVP_PKEY_ALG_CTRL + 5)\n\n# define EVP_PKEY_CTRL_GET_RSA_PADDING           (EVP_PKEY_ALG_CTRL + 6)\n# define EVP_PKEY_CTRL_GET_RSA_PSS_SALTLEN       (EVP_PKEY_ALG_CTRL + 7)\n# define EVP_PKEY_CTRL_GET_RSA_MGF1_MD           (EVP_PKEY_ALG_CTRL + 8)\n\n# define EVP_PKEY_CTRL_RSA_OAEP_MD       (EVP_PKEY_ALG_CTRL + 9)\n# define EVP_PKEY_CTRL_RSA_OAEP_LABEL    (EVP_PKEY_ALG_CTRL + 10)\n\n# define EVP_PKEY_CTRL_GET_RSA_OAEP_MD   (EVP_PKEY_ALG_CTRL + 11)\n# define EVP_PKEY_CTRL_GET_RSA_OAEP_LABEL (EVP_PKEY_ALG_CTRL + 12)\n\n# define RSA_PKCS1_PADDING       1\n# define RSA_SSLV23_PADDING      2\n# define RSA_NO_PADDING          3\n# define RSA_PKCS1_OAEP_PADDING  4\n# define RSA_X931_PADDING        5\n/* EVP_PKEY_ only */\n# define RSA_PKCS1_PSS_PADDING   6\n\n# define RSA_PKCS1_PADDING_SIZE  11\n\n# define RSA_set_app_data(s,arg)         RSA_set_ex_data(s,0,arg)\n# define RSA_get_app_data(s)             RSA_get_ex_data(s,0)\n\nRSA *RSA_new(void);\nRSA *RSA_new_method(ENGINE *engine);\nint RSA_size(const RSA *rsa);\n\n/* Deprecated version */\n# ifndef OPENSSL_NO_DEPRECATED\nRSA *RSA_generate_key(int bits, unsigned long e, void\n                       (*callback) (int, int, void *), void *cb_arg);\n# endif                         /* !defined(OPENSSL_NO_DEPRECATED) */\n\n/* New version */\nint RSA_generate_key_ex(RSA *rsa, int bits, BIGNUM *e, BN_GENCB *cb);\n\nint RSA_check_key(const RSA *);\n        /* next 4 return -1 on error */\nint RSA_public_encrypt(int flen, const unsigned char *from,\n                       unsigned char *to, RSA *rsa, int padding);\nint RSA_private_encrypt(int flen, const unsigned char *from,\n                        unsigned char *to, RSA *rsa, int padding);\nint RSA_public_decrypt(int flen, const unsigned char *from,\n                       unsigned char *to, RSA *rsa, int padding);\nint RSA_private_decrypt(int flen, const unsigned char *from,\n                        unsigned char *to, RSA *rsa, int padding);\nvoid RSA_free(RSA *r);\n/* \"up\" the RSA object's reference count */\nint RSA_up_ref(RSA *r);\n\nint RSA_flags(const RSA *r);\n\nvoid RSA_set_default_method(const RSA_METHOD *meth);\nconst RSA_METHOD *RSA_get_default_method(void);\nconst RSA_METHOD *RSA_get_method(const RSA *rsa);\nint RSA_set_method(RSA *rsa, const RSA_METHOD *meth);\n\n/* This function needs the memory locking malloc callbacks to be installed */\nint RSA_memory_lock(RSA *r);\n\n/* these are the actual SSLeay RSA functions */\nconst RSA_METHOD *RSA_PKCS1_SSLeay(void);\n\nconst RSA_METHOD *RSA_null_method(void);\n\nDECLARE_ASN1_ENCODE_FUNCTIONS_const(RSA, RSAPublicKey)\nDECLARE_ASN1_ENCODE_FUNCTIONS_const(RSA, RSAPrivateKey)\n\ntypedef struct rsa_pss_params_st {\n    X509_ALGOR *hashAlgorithm;\n    X509_ALGOR *maskGenAlgorithm;\n    ASN1_INTEGER *saltLength;\n    ASN1_INTEGER *trailerField;\n} RSA_PSS_PARAMS;\n\nDECLARE_ASN1_FUNCTIONS(RSA_PSS_PARAMS)\n\ntypedef struct rsa_oaep_params_st {\n    X509_ALGOR *hashFunc;\n    X509_ALGOR *maskGenFunc;\n    X509_ALGOR *pSourceFunc;\n} RSA_OAEP_PARAMS;\n\nDECLARE_ASN1_FUNCTIONS(RSA_OAEP_PARAMS)\n\n# ifndef OPENSSL_NO_FP_API\nint RSA_print_fp(FILE *fp, const RSA *r, int offset);\n# endif\n\n# ifndef OPENSSL_NO_BIO\nint RSA_print(BIO *bp, const RSA *r, int offset);\n# endif\n\n# ifndef OPENSSL_NO_RC4\nint i2d_RSA_NET(const RSA *a, unsigned char **pp,\n                int (*cb) (char *buf, int len, const char *prompt,\n                           int verify), int sgckey);\nRSA *d2i_RSA_NET(RSA **a, const unsigned char **pp, long length,\n                 int (*cb) (char *buf, int len, const char *prompt,\n                            int verify), int sgckey);\n\nint i2d_Netscape_RSA(const RSA *a, unsigned char **pp,\n                     int (*cb) (char *buf, int len, const char *prompt,\n                                int verify));\nRSA *d2i_Netscape_RSA(RSA **a, const unsigned char **pp, long length,\n                      int (*cb) (char *buf, int len, const char *prompt,\n                                 int verify));\n# endif\n\n/*\n * The following 2 functions sign and verify a X509_SIG ASN1 object inside\n * PKCS#1 padded RSA encryption\n */\nint RSA_sign(int type, const unsigned char *m, unsigned int m_length,\n             unsigned char *sigret, unsigned int *siglen, RSA *rsa);\nint RSA_verify(int type, const unsigned char *m, unsigned int m_length,\n               const unsigned char *sigbuf, unsigned int siglen, RSA *rsa);\n\n/*\n * The following 2 function sign and verify a ASN1_OCTET_STRING object inside\n * PKCS#1 padded RSA encryption\n */\nint RSA_sign_ASN1_OCTET_STRING(int type,\n                               const unsigned char *m, unsigned int m_length,\n                               unsigned char *sigret, unsigned int *siglen,\n                               RSA *rsa);\nint RSA_verify_ASN1_OCTET_STRING(int type, const unsigned char *m,\n                                 unsigned int m_length, unsigned char *sigbuf,\n                                 unsigned int siglen, RSA *rsa);\n\nint RSA_blinding_on(RSA *rsa, BN_CTX *ctx);\nvoid RSA_blinding_off(RSA *rsa);\nBN_BLINDING *RSA_setup_blinding(RSA *rsa, BN_CTX *ctx);\n\nint RSA_padding_add_PKCS1_type_1(unsigned char *to, int tlen,\n                                 const unsigned char *f, int fl);\nint RSA_padding_check_PKCS1_type_1(unsigned char *to, int tlen,\n                                   const unsigned char *f, int fl,\n                                   int rsa_len);\nint RSA_padding_add_PKCS1_type_2(unsigned char *to, int tlen,\n                                 const unsigned char *f, int fl);\nint RSA_padding_check_PKCS1_type_2(unsigned char *to, int tlen,\n                                   const unsigned char *f, int fl,\n                                   int rsa_len);\nint PKCS1_MGF1(unsigned char *mask, long len, const unsigned char *seed,\n               long seedlen, const EVP_MD *dgst);\nint RSA_padding_add_PKCS1_OAEP(unsigned char *to, int tlen,\n                               const unsigned char *f, int fl,\n                               const unsigned char *p, int pl);\nint RSA_padding_check_PKCS1_OAEP(unsigned char *to, int tlen,\n                                 const unsigned char *f, int fl, int rsa_len,\n                                 const unsigned char *p, int pl);\nint RSA_padding_add_PKCS1_OAEP_mgf1(unsigned char *to, int tlen,\n                                    const unsigned char *from, int flen,\n                                    const unsigned char *param, int plen,\n                                    const EVP_MD *md, const EVP_MD *mgf1md);\nint RSA_padding_check_PKCS1_OAEP_mgf1(unsigned char *to, int tlen,\n                                      const unsigned char *from, int flen,\n                                      int num, const unsigned char *param,\n                                      int plen, const EVP_MD *md,\n                                      const EVP_MD *mgf1md);\nint RSA_padding_add_SSLv23(unsigned char *to, int tlen,\n                           const unsigned char *f, int fl);\nint RSA_padding_check_SSLv23(unsigned char *to, int tlen,\n                             const unsigned char *f, int fl, int rsa_len);\nint RSA_padding_add_none(unsigned char *to, int tlen, const unsigned char *f,\n                         int fl);\nint RSA_padding_check_none(unsigned char *to, int tlen,\n                           const unsigned char *f, int fl, int rsa_len);\nint RSA_padding_add_X931(unsigned char *to, int tlen, const unsigned char *f,\n                         int fl);\nint RSA_padding_check_X931(unsigned char *to, int tlen,\n                           const unsigned char *f, int fl, int rsa_len);\nint RSA_X931_hash_id(int nid);\n\nint RSA_verify_PKCS1_PSS(RSA *rsa, const unsigned char *mHash,\n                         const EVP_MD *Hash, const unsigned char *EM,\n                         int sLen);\nint RSA_padding_add_PKCS1_PSS(RSA *rsa, unsigned char *EM,\n                              const unsigned char *mHash, const EVP_MD *Hash,\n                              int sLen);\n\nint RSA_verify_PKCS1_PSS_mgf1(RSA *rsa, const unsigned char *mHash,\n                              const EVP_MD *Hash, const EVP_MD *mgf1Hash,\n                              const unsigned char *EM, int sLen);\n\nint RSA_padding_add_PKCS1_PSS_mgf1(RSA *rsa, unsigned char *EM,\n                                   const unsigned char *mHash,\n                                   const EVP_MD *Hash, const EVP_MD *mgf1Hash,\n                                   int sLen);\n\nint RSA_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func,\n                         CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func);\nint RSA_set_ex_data(RSA *r, int idx, void *arg);\nvoid *RSA_get_ex_data(const RSA *r, int idx);\n\nRSA *RSAPublicKey_dup(RSA *rsa);\nRSA *RSAPrivateKey_dup(RSA *rsa);\n\n/*\n * If this flag is set the RSA method is FIPS compliant and can be used in\n * FIPS mode. This is set in the validated module method. If an application\n * sets this flag in its own methods it is its responsibility to ensure the\n * result is compliant.\n */\n\n# define RSA_FLAG_FIPS_METHOD                    0x0400\n\n/*\n * If this flag is set the operations normally disabled in FIPS mode are\n * permitted it is then the applications responsibility to ensure that the\n * usage is compliant.\n */\n\n# define RSA_FLAG_NON_FIPS_ALLOW                 0x0400\n/*\n * Application has decided PRNG is good enough to generate a key: don't\n * check.\n */\n# define RSA_FLAG_CHECKED                        0x0800\n\n/* BEGIN ERROR CODES */\n/*\n * The following lines are auto generated by the script mkerr.pl. Any changes\n * made after this point may be overwritten when the script is next run.\n */\nvoid ERR_load_RSA_strings(void);\n\n/* Error codes for the RSA functions. */\n\n/* Function codes. */\n# define RSA_F_CHECK_PADDING_MD                           140\n# define RSA_F_DO_RSA_PRINT                               146\n# define RSA_F_INT_RSA_VERIFY                             145\n# define RSA_F_MEMORY_LOCK                                100\n# define RSA_F_OLD_RSA_PRIV_DECODE                        147\n# define RSA_F_PKEY_RSA_CTRL                              143\n# define RSA_F_PKEY_RSA_CTRL_STR                          144\n# define RSA_F_PKEY_RSA_SIGN                              142\n# define RSA_F_PKEY_RSA_VERIFY                            154\n# define RSA_F_PKEY_RSA_VERIFYRECOVER                     141\n# define RSA_F_RSA_ALGOR_TO_MD                            157\n# define RSA_F_RSA_BUILTIN_KEYGEN                         129\n# define RSA_F_RSA_CHECK_KEY                              123\n# define RSA_F_RSA_CMS_DECRYPT                            158\n# define RSA_F_RSA_EAY_PRIVATE_DECRYPT                    101\n# define RSA_F_RSA_EAY_PRIVATE_ENCRYPT                    102\n# define RSA_F_RSA_EAY_PUBLIC_DECRYPT                     103\n# define RSA_F_RSA_EAY_PUBLIC_ENCRYPT                     104\n# define RSA_F_RSA_GENERATE_KEY                           105\n# define RSA_F_RSA_GENERATE_KEY_EX                        155\n# define RSA_F_RSA_ITEM_VERIFY                            156\n# define RSA_F_RSA_MEMORY_LOCK                            130\n# define RSA_F_RSA_MGF1_TO_MD                             159\n# define RSA_F_RSA_NEW_METHOD                             106\n# define RSA_F_RSA_NULL                                   124\n# define RSA_F_RSA_NULL_MOD_EXP                           131\n# define RSA_F_RSA_NULL_PRIVATE_DECRYPT                   132\n# define RSA_F_RSA_NULL_PRIVATE_ENCRYPT                   133\n# define RSA_F_RSA_NULL_PUBLIC_DECRYPT                    134\n# define RSA_F_RSA_NULL_PUBLIC_ENCRYPT                    135\n# define RSA_F_RSA_PADDING_ADD_NONE                       107\n# define RSA_F_RSA_PADDING_ADD_PKCS1_OAEP                 121\n# define RSA_F_RSA_PADDING_ADD_PKCS1_OAEP_MGF1            160\n# define RSA_F_RSA_PADDING_ADD_PKCS1_PSS                  125\n# define RSA_F_RSA_PADDING_ADD_PKCS1_PSS_MGF1             148\n# define RSA_F_RSA_PADDING_ADD_PKCS1_TYPE_1               108\n# define RSA_F_RSA_PADDING_ADD_PKCS1_TYPE_2               109\n# define RSA_F_RSA_PADDING_ADD_SSLV23                     110\n# define RSA_F_RSA_PADDING_ADD_X931                       127\n# define RSA_F_RSA_PADDING_CHECK_NONE                     111\n# define RSA_F_RSA_PADDING_CHECK_PKCS1_OAEP               122\n# define RSA_F_RSA_PADDING_CHECK_PKCS1_OAEP_MGF1          161\n# define RSA_F_RSA_PADDING_CHECK_PKCS1_TYPE_1             112\n# define RSA_F_RSA_PADDING_CHECK_PKCS1_TYPE_2             113\n# define RSA_F_RSA_PADDING_CHECK_SSLV23                   114\n# define RSA_F_RSA_PADDING_CHECK_X931                     128\n# define RSA_F_RSA_PRINT                                  115\n# define RSA_F_RSA_PRINT_FP                               116\n# define RSA_F_RSA_PRIVATE_DECRYPT                        150\n# define RSA_F_RSA_PRIVATE_ENCRYPT                        151\n# define RSA_F_RSA_PRIV_DECODE                            137\n# define RSA_F_RSA_PRIV_ENCODE                            138\n# define RSA_F_RSA_PSS_TO_CTX                             162\n# define RSA_F_RSA_PUBLIC_DECRYPT                         152\n# define RSA_F_RSA_PUBLIC_ENCRYPT                         153\n# define RSA_F_RSA_PUB_DECODE                             139\n# define RSA_F_RSA_SETUP_BLINDING                         136\n# define RSA_F_RSA_SIGN                                   117\n# define RSA_F_RSA_SIGN_ASN1_OCTET_STRING                 118\n# define RSA_F_RSA_VERIFY                                 119\n# define RSA_F_RSA_VERIFY_ASN1_OCTET_STRING               120\n# define RSA_F_RSA_VERIFY_PKCS1_PSS                       126\n# define RSA_F_RSA_VERIFY_PKCS1_PSS_MGF1                  149\n\n/* Reason codes. */\n# define RSA_R_ALGORITHM_MISMATCH                         100\n# define RSA_R_BAD_E_VALUE                                101\n# define RSA_R_BAD_FIXED_HEADER_DECRYPT                   102\n# define RSA_R_BAD_PAD_BYTE_COUNT                         103\n# define RSA_R_BAD_SIGNATURE                              104\n# define RSA_R_BLOCK_TYPE_IS_NOT_01                       106\n# define RSA_R_BLOCK_TYPE_IS_NOT_02                       107\n# define RSA_R_DATA_GREATER_THAN_MOD_LEN                  108\n# define RSA_R_DATA_TOO_LARGE                             109\n# define RSA_R_DATA_TOO_LARGE_FOR_KEY_SIZE                110\n# define RSA_R_DATA_TOO_LARGE_FOR_MODULUS                 132\n# define RSA_R_DATA_TOO_SMALL                             111\n# define RSA_R_DATA_TOO_SMALL_FOR_KEY_SIZE                122\n# define RSA_R_DIGEST_DOES_NOT_MATCH                      166\n# define RSA_R_DIGEST_TOO_BIG_FOR_RSA_KEY                 112\n# define RSA_R_DMP1_NOT_CONGRUENT_TO_D                    124\n# define RSA_R_DMQ1_NOT_CONGRUENT_TO_D                    125\n# define RSA_R_D_E_NOT_CONGRUENT_TO_1                     123\n# define RSA_R_FIRST_OCTET_INVALID                        133\n# define RSA_R_ILLEGAL_OR_UNSUPPORTED_PADDING_MODE        144\n# define RSA_R_INVALID_DIGEST                             160\n# define RSA_R_INVALID_DIGEST_LENGTH                      143\n# define RSA_R_INVALID_HEADER                             137\n# define RSA_R_INVALID_KEYBITS                            145\n# define RSA_R_INVALID_LABEL                              161\n# define RSA_R_INVALID_MESSAGE_LENGTH                     131\n# define RSA_R_INVALID_MGF1_MD                            156\n# define RSA_R_INVALID_OAEP_PARAMETERS                    162\n# define RSA_R_INVALID_PADDING                            138\n# define RSA_R_INVALID_PADDING_MODE                       141\n# define RSA_R_INVALID_PSS_PARAMETERS                     149\n# define RSA_R_INVALID_PSS_SALTLEN                        146\n# define RSA_R_INVALID_SALT_LENGTH                        150\n# define RSA_R_INVALID_TRAILER                            139\n# define RSA_R_INVALID_X931_DIGEST                        142\n# define RSA_R_IQMP_NOT_INVERSE_OF_Q                      126\n# define RSA_R_KEY_SIZE_TOO_SMALL                         120\n# define RSA_R_LAST_OCTET_INVALID                         134\n# define RSA_R_MODULUS_TOO_LARGE                          105\n# define RSA_R_NON_FIPS_RSA_METHOD                        157\n# define RSA_R_NO_PUBLIC_EXPONENT                         140\n# define RSA_R_NULL_BEFORE_BLOCK_MISSING                  113\n# define RSA_R_N_DOES_NOT_EQUAL_P_Q                       127\n# define RSA_R_OAEP_DECODING_ERROR                        121\n# define RSA_R_OPERATION_NOT_ALLOWED_IN_FIPS_MODE         158\n# define RSA_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE   148\n# define RSA_R_PADDING_CHECK_FAILED                       114\n# define RSA_R_PKCS_DECODING_ERROR                        159\n# define RSA_R_P_NOT_PRIME                                128\n# define RSA_R_Q_NOT_PRIME                                129\n# define RSA_R_RSA_OPERATIONS_NOT_SUPPORTED               130\n# define RSA_R_SLEN_CHECK_FAILED                          136\n# define RSA_R_SLEN_RECOVERY_FAILED                       135\n# define RSA_R_SSLV3_ROLLBACK_ATTACK                      115\n# define RSA_R_THE_ASN1_OBJECT_IDENTIFIER_IS_NOT_KNOWN_FOR_THIS_MD 116\n# define RSA_R_UNKNOWN_ALGORITHM_TYPE                     117\n# define RSA_R_UNKNOWN_DIGEST                             163\n# define RSA_R_UNKNOWN_MASK_DIGEST                        151\n# define RSA_R_UNKNOWN_PADDING_TYPE                       118\n# define RSA_R_UNKNOWN_PSS_DIGEST                         152\n# define RSA_R_UNSUPPORTED_ENCRYPTION_TYPE                164\n# define RSA_R_UNSUPPORTED_LABEL_SOURCE                   165\n# define RSA_R_UNSUPPORTED_MASK_ALGORITHM                 153\n# define RSA_R_UNSUPPORTED_MASK_PARAMETER                 154\n# define RSA_R_UNSUPPORTED_SIGNATURE_TYPE                 155\n# define RSA_R_VALUE_MISSING                              147\n# define RSA_R_WRONG_SIGNATURE_LENGTH                     119\n\n#ifdef  __cplusplus\n}\n#endif\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/arm/include/openssl/safestack.h",
    "content": "/* ====================================================================\n * Copyright (c) 1999 The OpenSSL Project.  All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n *\n * 1. Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n *\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in\n *    the documentation and/or other materials provided with the\n *    distribution.\n *\n * 3. All advertising materials mentioning features or use of this\n *    software must display the following acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit. (http://www.openssl.org/)\"\n *\n * 4. The names \"OpenSSL Toolkit\" and \"OpenSSL Project\" must not be used to\n *    endorse or promote products derived from this software without\n *    prior written permission. For written permission, please contact\n *    openssl-core@openssl.org.\n *\n * 5. Products derived from this software may not be called \"OpenSSL\"\n *    nor may \"OpenSSL\" appear in their names without prior written\n *    permission of the OpenSSL Project.\n *\n * 6. Redistributions of any form whatsoever must retain the following\n *    acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit (http://www.openssl.org/)\"\n *\n * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY\n * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\n * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR\n * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\n * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,\n * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED\n * OF THE POSSIBILITY OF SUCH DAMAGE.\n * ====================================================================\n *\n * This product includes cryptographic software written by Eric Young\n * (eay@cryptsoft.com).  This product includes software written by Tim\n * Hudson (tjh@cryptsoft.com).\n *\n */\n\n#ifndef HEADER_SAFESTACK_H\n# define HEADER_SAFESTACK_H\n\n# include <openssl/stack.h>\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n# ifndef CHECKED_PTR_OF\n#  define CHECKED_PTR_OF(type, p) \\\n    ((void*) (1 ? p : (type*)0))\n# endif\n\n/*\n * In C++ we get problems because an explicit cast is needed from (void *) we\n * use CHECKED_STACK_OF to ensure the correct type is passed in the macros\n * below.\n */\n\n# define CHECKED_STACK_OF(type, p) \\\n    ((_STACK*) (1 ? p : (STACK_OF(type)*)0))\n\n# define CHECKED_SK_COPY_FUNC(type, p) \\\n    ((void *(*)(void *)) ((1 ? p : (type *(*)(const type *))0)))\n\n# define CHECKED_SK_FREE_FUNC(type, p) \\\n    ((void (*)(void *)) ((1 ? p : (void (*)(type *))0)))\n\n# define CHECKED_SK_CMP_FUNC(type, p) \\\n    ((int (*)(const void *, const void *)) \\\n        ((1 ? p : (int (*)(const type * const *, const type * const *))0)))\n\n# define STACK_OF(type) struct stack_st_##type\n# define PREDECLARE_STACK_OF(type) STACK_OF(type);\n\n# define DECLARE_STACK_OF(type) \\\nSTACK_OF(type) \\\n    { \\\n    _STACK stack; \\\n    };\n# define DECLARE_SPECIAL_STACK_OF(type, type2) \\\nSTACK_OF(type) \\\n    { \\\n    _STACK stack; \\\n    };\n\n/* nada (obsolete in new safestack approach)*/\n# define IMPLEMENT_STACK_OF(type)\n\n/*-\n * Strings are special: normally an lhash entry will point to a single\n * (somewhat) mutable object. In the case of strings:\n *\n * a) Instead of a single char, there is an array of chars, NUL-terminated.\n * b) The string may have be immutable.\n *\n * So, they need their own declarations. Especially important for\n * type-checking tools, such as Deputy.\n *\n * In practice, however, it appears to be hard to have a const\n * string. For now, I'm settling for dealing with the fact it is a\n * string at all.\n */\ntypedef char *OPENSSL_STRING;\n\ntypedef const char *OPENSSL_CSTRING;\n\n/*\n * Confusingly, LHASH_OF(STRING) deals with char ** throughout, but\n * STACK_OF(STRING) is really more like STACK_OF(char), only, as mentioned\n * above, instead of a single char each entry is a NUL-terminated array of\n * chars. So, we have to implement STRING specially for STACK_OF. This is\n * dealt with in the autogenerated macros below.\n */\n\nDECLARE_SPECIAL_STACK_OF(OPENSSL_STRING, char)\n\n/*\n * Similarly, we sometimes use a block of characters, NOT nul-terminated.\n * These should also be distinguished from \"normal\" stacks.\n */\ntypedef void *OPENSSL_BLOCK;\nDECLARE_SPECIAL_STACK_OF(OPENSSL_BLOCK, void)\n\n/*\n * SKM_sk_... stack macros are internal to safestack.h: never use them\n * directly, use sk_<type>_... instead\n */\n# define SKM_sk_new(type, cmp) \\\n        ((STACK_OF(type) *)sk_new(CHECKED_SK_CMP_FUNC(type, cmp)))\n# define SKM_sk_new_null(type) \\\n        ((STACK_OF(type) *)sk_new_null())\n# define SKM_sk_free(type, st) \\\n        sk_free(CHECKED_STACK_OF(type, st))\n# define SKM_sk_num(type, st) \\\n        sk_num(CHECKED_STACK_OF(type, st))\n# define SKM_sk_value(type, st,i) \\\n        ((type *)sk_value(CHECKED_STACK_OF(type, st), i))\n# define SKM_sk_set(type, st,i,val) \\\n        sk_set(CHECKED_STACK_OF(type, st), i, CHECKED_PTR_OF(type, val))\n# define SKM_sk_zero(type, st) \\\n        sk_zero(CHECKED_STACK_OF(type, st))\n# define SKM_sk_push(type, st, val) \\\n        sk_push(CHECKED_STACK_OF(type, st), CHECKED_PTR_OF(type, val))\n# define SKM_sk_unshift(type, st, val) \\\n        sk_unshift(CHECKED_STACK_OF(type, st), CHECKED_PTR_OF(type, val))\n# define SKM_sk_find(type, st, val) \\\n        sk_find(CHECKED_STACK_OF(type, st), CHECKED_PTR_OF(type, val))\n# define SKM_sk_find_ex(type, st, val) \\\n        sk_find_ex(CHECKED_STACK_OF(type, st), \\\n                   CHECKED_PTR_OF(type, val))\n# define SKM_sk_delete(type, st, i) \\\n        (type *)sk_delete(CHECKED_STACK_OF(type, st), i)\n# define SKM_sk_delete_ptr(type, st, ptr) \\\n        (type *)sk_delete_ptr(CHECKED_STACK_OF(type, st), CHECKED_PTR_OF(type, ptr))\n# define SKM_sk_insert(type, st,val, i) \\\n        sk_insert(CHECKED_STACK_OF(type, st), CHECKED_PTR_OF(type, val), i)\n# define SKM_sk_set_cmp_func(type, st, cmp) \\\n        ((int (*)(const type * const *,const type * const *)) \\\n        sk_set_cmp_func(CHECKED_STACK_OF(type, st), CHECKED_SK_CMP_FUNC(type, cmp)))\n# define SKM_sk_dup(type, st) \\\n        (STACK_OF(type) *)sk_dup(CHECKED_STACK_OF(type, st))\n# define SKM_sk_pop_free(type, st, free_func) \\\n        sk_pop_free(CHECKED_STACK_OF(type, st), CHECKED_SK_FREE_FUNC(type, free_func))\n# define SKM_sk_deep_copy(type, st, copy_func, free_func) \\\n        (STACK_OF(type) *)sk_deep_copy(CHECKED_STACK_OF(type, st), CHECKED_SK_COPY_FUNC(type, copy_func), CHECKED_SK_FREE_FUNC(type, free_func))\n# define SKM_sk_shift(type, st) \\\n        (type *)sk_shift(CHECKED_STACK_OF(type, st))\n# define SKM_sk_pop(type, st) \\\n        (type *)sk_pop(CHECKED_STACK_OF(type, st))\n# define SKM_sk_sort(type, st) \\\n        sk_sort(CHECKED_STACK_OF(type, st))\n# define SKM_sk_is_sorted(type, st) \\\n        sk_is_sorted(CHECKED_STACK_OF(type, st))\n# define SKM_ASN1_SET_OF_d2i(type, st, pp, length, d2i_func, free_func, ex_tag, ex_class) \\\n  (STACK_OF(type) *)d2i_ASN1_SET( \\\n                                (STACK_OF(OPENSSL_BLOCK) **)CHECKED_PTR_OF(STACK_OF(type)*, st), \\\n                                pp, length, \\\n                                CHECKED_D2I_OF(type, d2i_func), \\\n                                CHECKED_SK_FREE_FUNC(type, free_func), \\\n                                ex_tag, ex_class)\n# define SKM_ASN1_SET_OF_i2d(type, st, pp, i2d_func, ex_tag, ex_class, is_set) \\\n  i2d_ASN1_SET((STACK_OF(OPENSSL_BLOCK) *)CHECKED_STACK_OF(type, st), pp, \\\n                                CHECKED_I2D_OF(type, i2d_func), \\\n                                ex_tag, ex_class, is_set)\n# define SKM_ASN1_seq_pack(type, st, i2d_func, buf, len) \\\n        ASN1_seq_pack(CHECKED_PTR_OF(STACK_OF(type), st), \\\n                        CHECKED_I2D_OF(type, i2d_func), buf, len)\n# define SKM_ASN1_seq_unpack(type, buf, len, d2i_func, free_func) \\\n        (STACK_OF(type) *)ASN1_seq_unpack(buf, len, CHECKED_D2I_OF(type, d2i_func), CHECKED_SK_FREE_FUNC(type, free_func))\n# define SKM_PKCS12_decrypt_d2i(type, algor, d2i_func, free_func, pass, passlen, oct, seq) \\\n        (STACK_OF(type) *)PKCS12_decrypt_d2i(algor, \\\n                                CHECKED_D2I_OF(type, d2i_func), \\\n                                CHECKED_SK_FREE_FUNC(type, free_func), \\\n                                pass, passlen, oct, seq)\n/*\n * This block of defines is updated by util/mkstack.pl, please do not touch!\n */\n# define sk_ACCESS_DESCRIPTION_new(cmp) SKM_sk_new(ACCESS_DESCRIPTION, (cmp))\n# define sk_ACCESS_DESCRIPTION_new_null() SKM_sk_new_null(ACCESS_DESCRIPTION)\n# define sk_ACCESS_DESCRIPTION_free(st) SKM_sk_free(ACCESS_DESCRIPTION, (st))\n# define sk_ACCESS_DESCRIPTION_num(st) SKM_sk_num(ACCESS_DESCRIPTION, (st))\n# define sk_ACCESS_DESCRIPTION_value(st, i) SKM_sk_value(ACCESS_DESCRIPTION, (st), (i))\n# define sk_ACCESS_DESCRIPTION_set(st, i, val) SKM_sk_set(ACCESS_DESCRIPTION, (st), (i), (val))\n# define sk_ACCESS_DESCRIPTION_zero(st) SKM_sk_zero(ACCESS_DESCRIPTION, (st))\n# define sk_ACCESS_DESCRIPTION_push(st, val) SKM_sk_push(ACCESS_DESCRIPTION, (st), (val))\n# define sk_ACCESS_DESCRIPTION_unshift(st, val) SKM_sk_unshift(ACCESS_DESCRIPTION, (st), (val))\n# define sk_ACCESS_DESCRIPTION_find(st, val) SKM_sk_find(ACCESS_DESCRIPTION, (st), (val))\n# define sk_ACCESS_DESCRIPTION_find_ex(st, val) SKM_sk_find_ex(ACCESS_DESCRIPTION, (st), (val))\n# define sk_ACCESS_DESCRIPTION_delete(st, i) SKM_sk_delete(ACCESS_DESCRIPTION, (st), (i))\n# define sk_ACCESS_DESCRIPTION_delete_ptr(st, ptr) SKM_sk_delete_ptr(ACCESS_DESCRIPTION, (st), (ptr))\n# define sk_ACCESS_DESCRIPTION_insert(st, val, i) SKM_sk_insert(ACCESS_DESCRIPTION, (st), (val), (i))\n# define sk_ACCESS_DESCRIPTION_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(ACCESS_DESCRIPTION, (st), (cmp))\n# define sk_ACCESS_DESCRIPTION_dup(st) SKM_sk_dup(ACCESS_DESCRIPTION, st)\n# define sk_ACCESS_DESCRIPTION_pop_free(st, free_func) SKM_sk_pop_free(ACCESS_DESCRIPTION, (st), (free_func))\n# define sk_ACCESS_DESCRIPTION_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(ACCESS_DESCRIPTION, (st), (copy_func), (free_func))\n# define sk_ACCESS_DESCRIPTION_shift(st) SKM_sk_shift(ACCESS_DESCRIPTION, (st))\n# define sk_ACCESS_DESCRIPTION_pop(st) SKM_sk_pop(ACCESS_DESCRIPTION, (st))\n# define sk_ACCESS_DESCRIPTION_sort(st) SKM_sk_sort(ACCESS_DESCRIPTION, (st))\n# define sk_ACCESS_DESCRIPTION_is_sorted(st) SKM_sk_is_sorted(ACCESS_DESCRIPTION, (st))\n# define sk_ASIdOrRange_new(cmp) SKM_sk_new(ASIdOrRange, (cmp))\n# define sk_ASIdOrRange_new_null() SKM_sk_new_null(ASIdOrRange)\n# define sk_ASIdOrRange_free(st) SKM_sk_free(ASIdOrRange, (st))\n# define sk_ASIdOrRange_num(st) SKM_sk_num(ASIdOrRange, (st))\n# define sk_ASIdOrRange_value(st, i) SKM_sk_value(ASIdOrRange, (st), (i))\n# define sk_ASIdOrRange_set(st, i, val) SKM_sk_set(ASIdOrRange, (st), (i), (val))\n# define sk_ASIdOrRange_zero(st) SKM_sk_zero(ASIdOrRange, (st))\n# define sk_ASIdOrRange_push(st, val) SKM_sk_push(ASIdOrRange, (st), (val))\n# define sk_ASIdOrRange_unshift(st, val) SKM_sk_unshift(ASIdOrRange, (st), (val))\n# define sk_ASIdOrRange_find(st, val) SKM_sk_find(ASIdOrRange, (st), (val))\n# define sk_ASIdOrRange_find_ex(st, val) SKM_sk_find_ex(ASIdOrRange, (st), (val))\n# define sk_ASIdOrRange_delete(st, i) SKM_sk_delete(ASIdOrRange, (st), (i))\n# define sk_ASIdOrRange_delete_ptr(st, ptr) SKM_sk_delete_ptr(ASIdOrRange, (st), (ptr))\n# define sk_ASIdOrRange_insert(st, val, i) SKM_sk_insert(ASIdOrRange, (st), (val), (i))\n# define sk_ASIdOrRange_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(ASIdOrRange, (st), (cmp))\n# define sk_ASIdOrRange_dup(st) SKM_sk_dup(ASIdOrRange, st)\n# define sk_ASIdOrRange_pop_free(st, free_func) SKM_sk_pop_free(ASIdOrRange, (st), (free_func))\n# define sk_ASIdOrRange_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(ASIdOrRange, (st), (copy_func), (free_func))\n# define sk_ASIdOrRange_shift(st) SKM_sk_shift(ASIdOrRange, (st))\n# define sk_ASIdOrRange_pop(st) SKM_sk_pop(ASIdOrRange, (st))\n# define sk_ASIdOrRange_sort(st) SKM_sk_sort(ASIdOrRange, (st))\n# define sk_ASIdOrRange_is_sorted(st) SKM_sk_is_sorted(ASIdOrRange, (st))\n# define sk_ASN1_GENERALSTRING_new(cmp) SKM_sk_new(ASN1_GENERALSTRING, (cmp))\n# define sk_ASN1_GENERALSTRING_new_null() SKM_sk_new_null(ASN1_GENERALSTRING)\n# define sk_ASN1_GENERALSTRING_free(st) SKM_sk_free(ASN1_GENERALSTRING, (st))\n# define sk_ASN1_GENERALSTRING_num(st) SKM_sk_num(ASN1_GENERALSTRING, (st))\n# define sk_ASN1_GENERALSTRING_value(st, i) SKM_sk_value(ASN1_GENERALSTRING, (st), (i))\n# define sk_ASN1_GENERALSTRING_set(st, i, val) SKM_sk_set(ASN1_GENERALSTRING, (st), (i), (val))\n# define sk_ASN1_GENERALSTRING_zero(st) SKM_sk_zero(ASN1_GENERALSTRING, (st))\n# define sk_ASN1_GENERALSTRING_push(st, val) SKM_sk_push(ASN1_GENERALSTRING, (st), (val))\n# define sk_ASN1_GENERALSTRING_unshift(st, val) SKM_sk_unshift(ASN1_GENERALSTRING, (st), (val))\n# define sk_ASN1_GENERALSTRING_find(st, val) SKM_sk_find(ASN1_GENERALSTRING, (st), (val))\n# define sk_ASN1_GENERALSTRING_find_ex(st, val) SKM_sk_find_ex(ASN1_GENERALSTRING, (st), (val))\n# define sk_ASN1_GENERALSTRING_delete(st, i) SKM_sk_delete(ASN1_GENERALSTRING, (st), (i))\n# define sk_ASN1_GENERALSTRING_delete_ptr(st, ptr) SKM_sk_delete_ptr(ASN1_GENERALSTRING, (st), (ptr))\n# define sk_ASN1_GENERALSTRING_insert(st, val, i) SKM_sk_insert(ASN1_GENERALSTRING, (st), (val), (i))\n# define sk_ASN1_GENERALSTRING_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(ASN1_GENERALSTRING, (st), (cmp))\n# define sk_ASN1_GENERALSTRING_dup(st) SKM_sk_dup(ASN1_GENERALSTRING, st)\n# define sk_ASN1_GENERALSTRING_pop_free(st, free_func) SKM_sk_pop_free(ASN1_GENERALSTRING, (st), (free_func))\n# define sk_ASN1_GENERALSTRING_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(ASN1_GENERALSTRING, (st), (copy_func), (free_func))\n# define sk_ASN1_GENERALSTRING_shift(st) SKM_sk_shift(ASN1_GENERALSTRING, (st))\n# define sk_ASN1_GENERALSTRING_pop(st) SKM_sk_pop(ASN1_GENERALSTRING, (st))\n# define sk_ASN1_GENERALSTRING_sort(st) SKM_sk_sort(ASN1_GENERALSTRING, (st))\n# define sk_ASN1_GENERALSTRING_is_sorted(st) SKM_sk_is_sorted(ASN1_GENERALSTRING, (st))\n# define sk_ASN1_INTEGER_new(cmp) SKM_sk_new(ASN1_INTEGER, (cmp))\n# define sk_ASN1_INTEGER_new_null() SKM_sk_new_null(ASN1_INTEGER)\n# define sk_ASN1_INTEGER_free(st) SKM_sk_free(ASN1_INTEGER, (st))\n# define sk_ASN1_INTEGER_num(st) SKM_sk_num(ASN1_INTEGER, (st))\n# define sk_ASN1_INTEGER_value(st, i) SKM_sk_value(ASN1_INTEGER, (st), (i))\n# define sk_ASN1_INTEGER_set(st, i, val) SKM_sk_set(ASN1_INTEGER, (st), (i), (val))\n# define sk_ASN1_INTEGER_zero(st) SKM_sk_zero(ASN1_INTEGER, (st))\n# define sk_ASN1_INTEGER_push(st, val) SKM_sk_push(ASN1_INTEGER, (st), (val))\n# define sk_ASN1_INTEGER_unshift(st, val) SKM_sk_unshift(ASN1_INTEGER, (st), (val))\n# define sk_ASN1_INTEGER_find(st, val) SKM_sk_find(ASN1_INTEGER, (st), (val))\n# define sk_ASN1_INTEGER_find_ex(st, val) SKM_sk_find_ex(ASN1_INTEGER, (st), (val))\n# define sk_ASN1_INTEGER_delete(st, i) SKM_sk_delete(ASN1_INTEGER, (st), (i))\n# define sk_ASN1_INTEGER_delete_ptr(st, ptr) SKM_sk_delete_ptr(ASN1_INTEGER, (st), (ptr))\n# define sk_ASN1_INTEGER_insert(st, val, i) SKM_sk_insert(ASN1_INTEGER, (st), (val), (i))\n# define sk_ASN1_INTEGER_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(ASN1_INTEGER, (st), (cmp))\n# define sk_ASN1_INTEGER_dup(st) SKM_sk_dup(ASN1_INTEGER, st)\n# define sk_ASN1_INTEGER_pop_free(st, free_func) SKM_sk_pop_free(ASN1_INTEGER, (st), (free_func))\n# define sk_ASN1_INTEGER_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(ASN1_INTEGER, (st), (copy_func), (free_func))\n# define sk_ASN1_INTEGER_shift(st) SKM_sk_shift(ASN1_INTEGER, (st))\n# define sk_ASN1_INTEGER_pop(st) SKM_sk_pop(ASN1_INTEGER, (st))\n# define sk_ASN1_INTEGER_sort(st) SKM_sk_sort(ASN1_INTEGER, (st))\n# define sk_ASN1_INTEGER_is_sorted(st) SKM_sk_is_sorted(ASN1_INTEGER, (st))\n# define sk_ASN1_OBJECT_new(cmp) SKM_sk_new(ASN1_OBJECT, (cmp))\n# define sk_ASN1_OBJECT_new_null() SKM_sk_new_null(ASN1_OBJECT)\n# define sk_ASN1_OBJECT_free(st) SKM_sk_free(ASN1_OBJECT, (st))\n# define sk_ASN1_OBJECT_num(st) SKM_sk_num(ASN1_OBJECT, (st))\n# define sk_ASN1_OBJECT_value(st, i) SKM_sk_value(ASN1_OBJECT, (st), (i))\n# define sk_ASN1_OBJECT_set(st, i, val) SKM_sk_set(ASN1_OBJECT, (st), (i), (val))\n# define sk_ASN1_OBJECT_zero(st) SKM_sk_zero(ASN1_OBJECT, (st))\n# define sk_ASN1_OBJECT_push(st, val) SKM_sk_push(ASN1_OBJECT, (st), (val))\n# define sk_ASN1_OBJECT_unshift(st, val) SKM_sk_unshift(ASN1_OBJECT, (st), (val))\n# define sk_ASN1_OBJECT_find(st, val) SKM_sk_find(ASN1_OBJECT, (st), (val))\n# define sk_ASN1_OBJECT_find_ex(st, val) SKM_sk_find_ex(ASN1_OBJECT, (st), (val))\n# define sk_ASN1_OBJECT_delete(st, i) SKM_sk_delete(ASN1_OBJECT, (st), (i))\n# define sk_ASN1_OBJECT_delete_ptr(st, ptr) SKM_sk_delete_ptr(ASN1_OBJECT, (st), (ptr))\n# define sk_ASN1_OBJECT_insert(st, val, i) SKM_sk_insert(ASN1_OBJECT, (st), (val), (i))\n# define sk_ASN1_OBJECT_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(ASN1_OBJECT, (st), (cmp))\n# define sk_ASN1_OBJECT_dup(st) SKM_sk_dup(ASN1_OBJECT, st)\n# define sk_ASN1_OBJECT_pop_free(st, free_func) SKM_sk_pop_free(ASN1_OBJECT, (st), (free_func))\n# define sk_ASN1_OBJECT_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(ASN1_OBJECT, (st), (copy_func), (free_func))\n# define sk_ASN1_OBJECT_shift(st) SKM_sk_shift(ASN1_OBJECT, (st))\n# define sk_ASN1_OBJECT_pop(st) SKM_sk_pop(ASN1_OBJECT, (st))\n# define sk_ASN1_OBJECT_sort(st) SKM_sk_sort(ASN1_OBJECT, (st))\n# define sk_ASN1_OBJECT_is_sorted(st) SKM_sk_is_sorted(ASN1_OBJECT, (st))\n# define sk_ASN1_STRING_TABLE_new(cmp) SKM_sk_new(ASN1_STRING_TABLE, (cmp))\n# define sk_ASN1_STRING_TABLE_new_null() SKM_sk_new_null(ASN1_STRING_TABLE)\n# define sk_ASN1_STRING_TABLE_free(st) SKM_sk_free(ASN1_STRING_TABLE, (st))\n# define sk_ASN1_STRING_TABLE_num(st) SKM_sk_num(ASN1_STRING_TABLE, (st))\n# define sk_ASN1_STRING_TABLE_value(st, i) SKM_sk_value(ASN1_STRING_TABLE, (st), (i))\n# define sk_ASN1_STRING_TABLE_set(st, i, val) SKM_sk_set(ASN1_STRING_TABLE, (st), (i), (val))\n# define sk_ASN1_STRING_TABLE_zero(st) SKM_sk_zero(ASN1_STRING_TABLE, (st))\n# define sk_ASN1_STRING_TABLE_push(st, val) SKM_sk_push(ASN1_STRING_TABLE, (st), (val))\n# define sk_ASN1_STRING_TABLE_unshift(st, val) SKM_sk_unshift(ASN1_STRING_TABLE, (st), (val))\n# define sk_ASN1_STRING_TABLE_find(st, val) SKM_sk_find(ASN1_STRING_TABLE, (st), (val))\n# define sk_ASN1_STRING_TABLE_find_ex(st, val) SKM_sk_find_ex(ASN1_STRING_TABLE, (st), (val))\n# define sk_ASN1_STRING_TABLE_delete(st, i) SKM_sk_delete(ASN1_STRING_TABLE, (st), (i))\n# define sk_ASN1_STRING_TABLE_delete_ptr(st, ptr) SKM_sk_delete_ptr(ASN1_STRING_TABLE, (st), (ptr))\n# define sk_ASN1_STRING_TABLE_insert(st, val, i) SKM_sk_insert(ASN1_STRING_TABLE, (st), (val), (i))\n# define sk_ASN1_STRING_TABLE_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(ASN1_STRING_TABLE, (st), (cmp))\n# define sk_ASN1_STRING_TABLE_dup(st) SKM_sk_dup(ASN1_STRING_TABLE, st)\n# define sk_ASN1_STRING_TABLE_pop_free(st, free_func) SKM_sk_pop_free(ASN1_STRING_TABLE, (st), (free_func))\n# define sk_ASN1_STRING_TABLE_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(ASN1_STRING_TABLE, (st), (copy_func), (free_func))\n# define sk_ASN1_STRING_TABLE_shift(st) SKM_sk_shift(ASN1_STRING_TABLE, (st))\n# define sk_ASN1_STRING_TABLE_pop(st) SKM_sk_pop(ASN1_STRING_TABLE, (st))\n# define sk_ASN1_STRING_TABLE_sort(st) SKM_sk_sort(ASN1_STRING_TABLE, (st))\n# define sk_ASN1_STRING_TABLE_is_sorted(st) SKM_sk_is_sorted(ASN1_STRING_TABLE, (st))\n# define sk_ASN1_TYPE_new(cmp) SKM_sk_new(ASN1_TYPE, (cmp))\n# define sk_ASN1_TYPE_new_null() SKM_sk_new_null(ASN1_TYPE)\n# define sk_ASN1_TYPE_free(st) SKM_sk_free(ASN1_TYPE, (st))\n# define sk_ASN1_TYPE_num(st) SKM_sk_num(ASN1_TYPE, (st))\n# define sk_ASN1_TYPE_value(st, i) SKM_sk_value(ASN1_TYPE, (st), (i))\n# define sk_ASN1_TYPE_set(st, i, val) SKM_sk_set(ASN1_TYPE, (st), (i), (val))\n# define sk_ASN1_TYPE_zero(st) SKM_sk_zero(ASN1_TYPE, (st))\n# define sk_ASN1_TYPE_push(st, val) SKM_sk_push(ASN1_TYPE, (st), (val))\n# define sk_ASN1_TYPE_unshift(st, val) SKM_sk_unshift(ASN1_TYPE, (st), (val))\n# define sk_ASN1_TYPE_find(st, val) SKM_sk_find(ASN1_TYPE, (st), (val))\n# define sk_ASN1_TYPE_find_ex(st, val) SKM_sk_find_ex(ASN1_TYPE, (st), (val))\n# define sk_ASN1_TYPE_delete(st, i) SKM_sk_delete(ASN1_TYPE, (st), (i))\n# define sk_ASN1_TYPE_delete_ptr(st, ptr) SKM_sk_delete_ptr(ASN1_TYPE, (st), (ptr))\n# define sk_ASN1_TYPE_insert(st, val, i) SKM_sk_insert(ASN1_TYPE, (st), (val), (i))\n# define sk_ASN1_TYPE_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(ASN1_TYPE, (st), (cmp))\n# define sk_ASN1_TYPE_dup(st) SKM_sk_dup(ASN1_TYPE, st)\n# define sk_ASN1_TYPE_pop_free(st, free_func) SKM_sk_pop_free(ASN1_TYPE, (st), (free_func))\n# define sk_ASN1_TYPE_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(ASN1_TYPE, (st), (copy_func), (free_func))\n# define sk_ASN1_TYPE_shift(st) SKM_sk_shift(ASN1_TYPE, (st))\n# define sk_ASN1_TYPE_pop(st) SKM_sk_pop(ASN1_TYPE, (st))\n# define sk_ASN1_TYPE_sort(st) SKM_sk_sort(ASN1_TYPE, (st))\n# define sk_ASN1_TYPE_is_sorted(st) SKM_sk_is_sorted(ASN1_TYPE, (st))\n# define sk_ASN1_UTF8STRING_new(cmp) SKM_sk_new(ASN1_UTF8STRING, (cmp))\n# define sk_ASN1_UTF8STRING_new_null() SKM_sk_new_null(ASN1_UTF8STRING)\n# define sk_ASN1_UTF8STRING_free(st) SKM_sk_free(ASN1_UTF8STRING, (st))\n# define sk_ASN1_UTF8STRING_num(st) SKM_sk_num(ASN1_UTF8STRING, (st))\n# define sk_ASN1_UTF8STRING_value(st, i) SKM_sk_value(ASN1_UTF8STRING, (st), (i))\n# define sk_ASN1_UTF8STRING_set(st, i, val) SKM_sk_set(ASN1_UTF8STRING, (st), (i), (val))\n# define sk_ASN1_UTF8STRING_zero(st) SKM_sk_zero(ASN1_UTF8STRING, (st))\n# define sk_ASN1_UTF8STRING_push(st, val) SKM_sk_push(ASN1_UTF8STRING, (st), (val))\n# define sk_ASN1_UTF8STRING_unshift(st, val) SKM_sk_unshift(ASN1_UTF8STRING, (st), (val))\n# define sk_ASN1_UTF8STRING_find(st, val) SKM_sk_find(ASN1_UTF8STRING, (st), (val))\n# define sk_ASN1_UTF8STRING_find_ex(st, val) SKM_sk_find_ex(ASN1_UTF8STRING, (st), (val))\n# define sk_ASN1_UTF8STRING_delete(st, i) SKM_sk_delete(ASN1_UTF8STRING, (st), (i))\n# define sk_ASN1_UTF8STRING_delete_ptr(st, ptr) SKM_sk_delete_ptr(ASN1_UTF8STRING, (st), (ptr))\n# define sk_ASN1_UTF8STRING_insert(st, val, i) SKM_sk_insert(ASN1_UTF8STRING, (st), (val), (i))\n# define sk_ASN1_UTF8STRING_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(ASN1_UTF8STRING, (st), (cmp))\n# define sk_ASN1_UTF8STRING_dup(st) SKM_sk_dup(ASN1_UTF8STRING, st)\n# define sk_ASN1_UTF8STRING_pop_free(st, free_func) SKM_sk_pop_free(ASN1_UTF8STRING, (st), (free_func))\n# define sk_ASN1_UTF8STRING_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(ASN1_UTF8STRING, (st), (copy_func), (free_func))\n# define sk_ASN1_UTF8STRING_shift(st) SKM_sk_shift(ASN1_UTF8STRING, (st))\n# define sk_ASN1_UTF8STRING_pop(st) SKM_sk_pop(ASN1_UTF8STRING, (st))\n# define sk_ASN1_UTF8STRING_sort(st) SKM_sk_sort(ASN1_UTF8STRING, (st))\n# define sk_ASN1_UTF8STRING_is_sorted(st) SKM_sk_is_sorted(ASN1_UTF8STRING, (st))\n# define sk_ASN1_VALUE_new(cmp) SKM_sk_new(ASN1_VALUE, (cmp))\n# define sk_ASN1_VALUE_new_null() SKM_sk_new_null(ASN1_VALUE)\n# define sk_ASN1_VALUE_free(st) SKM_sk_free(ASN1_VALUE, (st))\n# define sk_ASN1_VALUE_num(st) SKM_sk_num(ASN1_VALUE, (st))\n# define sk_ASN1_VALUE_value(st, i) SKM_sk_value(ASN1_VALUE, (st), (i))\n# define sk_ASN1_VALUE_set(st, i, val) SKM_sk_set(ASN1_VALUE, (st), (i), (val))\n# define sk_ASN1_VALUE_zero(st) SKM_sk_zero(ASN1_VALUE, (st))\n# define sk_ASN1_VALUE_push(st, val) SKM_sk_push(ASN1_VALUE, (st), (val))\n# define sk_ASN1_VALUE_unshift(st, val) SKM_sk_unshift(ASN1_VALUE, (st), (val))\n# define sk_ASN1_VALUE_find(st, val) SKM_sk_find(ASN1_VALUE, (st), (val))\n# define sk_ASN1_VALUE_find_ex(st, val) SKM_sk_find_ex(ASN1_VALUE, (st), (val))\n# define sk_ASN1_VALUE_delete(st, i) SKM_sk_delete(ASN1_VALUE, (st), (i))\n# define sk_ASN1_VALUE_delete_ptr(st, ptr) SKM_sk_delete_ptr(ASN1_VALUE, (st), (ptr))\n# define sk_ASN1_VALUE_insert(st, val, i) SKM_sk_insert(ASN1_VALUE, (st), (val), (i))\n# define sk_ASN1_VALUE_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(ASN1_VALUE, (st), (cmp))\n# define sk_ASN1_VALUE_dup(st) SKM_sk_dup(ASN1_VALUE, st)\n# define sk_ASN1_VALUE_pop_free(st, free_func) SKM_sk_pop_free(ASN1_VALUE, (st), (free_func))\n# define sk_ASN1_VALUE_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(ASN1_VALUE, (st), (copy_func), (free_func))\n# define sk_ASN1_VALUE_shift(st) SKM_sk_shift(ASN1_VALUE, (st))\n# define sk_ASN1_VALUE_pop(st) SKM_sk_pop(ASN1_VALUE, (st))\n# define sk_ASN1_VALUE_sort(st) SKM_sk_sort(ASN1_VALUE, (st))\n# define sk_ASN1_VALUE_is_sorted(st) SKM_sk_is_sorted(ASN1_VALUE, (st))\n# define sk_BIO_new(cmp) SKM_sk_new(BIO, (cmp))\n# define sk_BIO_new_null() SKM_sk_new_null(BIO)\n# define sk_BIO_free(st) SKM_sk_free(BIO, (st))\n# define sk_BIO_num(st) SKM_sk_num(BIO, (st))\n# define sk_BIO_value(st, i) SKM_sk_value(BIO, (st), (i))\n# define sk_BIO_set(st, i, val) SKM_sk_set(BIO, (st), (i), (val))\n# define sk_BIO_zero(st) SKM_sk_zero(BIO, (st))\n# define sk_BIO_push(st, val) SKM_sk_push(BIO, (st), (val))\n# define sk_BIO_unshift(st, val) SKM_sk_unshift(BIO, (st), (val))\n# define sk_BIO_find(st, val) SKM_sk_find(BIO, (st), (val))\n# define sk_BIO_find_ex(st, val) SKM_sk_find_ex(BIO, (st), (val))\n# define sk_BIO_delete(st, i) SKM_sk_delete(BIO, (st), (i))\n# define sk_BIO_delete_ptr(st, ptr) SKM_sk_delete_ptr(BIO, (st), (ptr))\n# define sk_BIO_insert(st, val, i) SKM_sk_insert(BIO, (st), (val), (i))\n# define sk_BIO_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(BIO, (st), (cmp))\n# define sk_BIO_dup(st) SKM_sk_dup(BIO, st)\n# define sk_BIO_pop_free(st, free_func) SKM_sk_pop_free(BIO, (st), (free_func))\n# define sk_BIO_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(BIO, (st), (copy_func), (free_func))\n# define sk_BIO_shift(st) SKM_sk_shift(BIO, (st))\n# define sk_BIO_pop(st) SKM_sk_pop(BIO, (st))\n# define sk_BIO_sort(st) SKM_sk_sort(BIO, (st))\n# define sk_BIO_is_sorted(st) SKM_sk_is_sorted(BIO, (st))\n# define sk_BY_DIR_ENTRY_new(cmp) SKM_sk_new(BY_DIR_ENTRY, (cmp))\n# define sk_BY_DIR_ENTRY_new_null() SKM_sk_new_null(BY_DIR_ENTRY)\n# define sk_BY_DIR_ENTRY_free(st) SKM_sk_free(BY_DIR_ENTRY, (st))\n# define sk_BY_DIR_ENTRY_num(st) SKM_sk_num(BY_DIR_ENTRY, (st))\n# define sk_BY_DIR_ENTRY_value(st, i) SKM_sk_value(BY_DIR_ENTRY, (st), (i))\n# define sk_BY_DIR_ENTRY_set(st, i, val) SKM_sk_set(BY_DIR_ENTRY, (st), (i), (val))\n# define sk_BY_DIR_ENTRY_zero(st) SKM_sk_zero(BY_DIR_ENTRY, (st))\n# define sk_BY_DIR_ENTRY_push(st, val) SKM_sk_push(BY_DIR_ENTRY, (st), (val))\n# define sk_BY_DIR_ENTRY_unshift(st, val) SKM_sk_unshift(BY_DIR_ENTRY, (st), (val))\n# define sk_BY_DIR_ENTRY_find(st, val) SKM_sk_find(BY_DIR_ENTRY, (st), (val))\n# define sk_BY_DIR_ENTRY_find_ex(st, val) SKM_sk_find_ex(BY_DIR_ENTRY, (st), (val))\n# define sk_BY_DIR_ENTRY_delete(st, i) SKM_sk_delete(BY_DIR_ENTRY, (st), (i))\n# define sk_BY_DIR_ENTRY_delete_ptr(st, ptr) SKM_sk_delete_ptr(BY_DIR_ENTRY, (st), (ptr))\n# define sk_BY_DIR_ENTRY_insert(st, val, i) SKM_sk_insert(BY_DIR_ENTRY, (st), (val), (i))\n# define sk_BY_DIR_ENTRY_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(BY_DIR_ENTRY, (st), (cmp))\n# define sk_BY_DIR_ENTRY_dup(st) SKM_sk_dup(BY_DIR_ENTRY, st)\n# define sk_BY_DIR_ENTRY_pop_free(st, free_func) SKM_sk_pop_free(BY_DIR_ENTRY, (st), (free_func))\n# define sk_BY_DIR_ENTRY_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(BY_DIR_ENTRY, (st), (copy_func), (free_func))\n# define sk_BY_DIR_ENTRY_shift(st) SKM_sk_shift(BY_DIR_ENTRY, (st))\n# define sk_BY_DIR_ENTRY_pop(st) SKM_sk_pop(BY_DIR_ENTRY, (st))\n# define sk_BY_DIR_ENTRY_sort(st) SKM_sk_sort(BY_DIR_ENTRY, (st))\n# define sk_BY_DIR_ENTRY_is_sorted(st) SKM_sk_is_sorted(BY_DIR_ENTRY, (st))\n# define sk_BY_DIR_HASH_new(cmp) SKM_sk_new(BY_DIR_HASH, (cmp))\n# define sk_BY_DIR_HASH_new_null() SKM_sk_new_null(BY_DIR_HASH)\n# define sk_BY_DIR_HASH_free(st) SKM_sk_free(BY_DIR_HASH, (st))\n# define sk_BY_DIR_HASH_num(st) SKM_sk_num(BY_DIR_HASH, (st))\n# define sk_BY_DIR_HASH_value(st, i) SKM_sk_value(BY_DIR_HASH, (st), (i))\n# define sk_BY_DIR_HASH_set(st, i, val) SKM_sk_set(BY_DIR_HASH, (st), (i), (val))\n# define sk_BY_DIR_HASH_zero(st) SKM_sk_zero(BY_DIR_HASH, (st))\n# define sk_BY_DIR_HASH_push(st, val) SKM_sk_push(BY_DIR_HASH, (st), (val))\n# define sk_BY_DIR_HASH_unshift(st, val) SKM_sk_unshift(BY_DIR_HASH, (st), (val))\n# define sk_BY_DIR_HASH_find(st, val) SKM_sk_find(BY_DIR_HASH, (st), (val))\n# define sk_BY_DIR_HASH_find_ex(st, val) SKM_sk_find_ex(BY_DIR_HASH, (st), (val))\n# define sk_BY_DIR_HASH_delete(st, i) SKM_sk_delete(BY_DIR_HASH, (st), (i))\n# define sk_BY_DIR_HASH_delete_ptr(st, ptr) SKM_sk_delete_ptr(BY_DIR_HASH, (st), (ptr))\n# define sk_BY_DIR_HASH_insert(st, val, i) SKM_sk_insert(BY_DIR_HASH, (st), (val), (i))\n# define sk_BY_DIR_HASH_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(BY_DIR_HASH, (st), (cmp))\n# define sk_BY_DIR_HASH_dup(st) SKM_sk_dup(BY_DIR_HASH, st)\n# define sk_BY_DIR_HASH_pop_free(st, free_func) SKM_sk_pop_free(BY_DIR_HASH, (st), (free_func))\n# define sk_BY_DIR_HASH_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(BY_DIR_HASH, (st), (copy_func), (free_func))\n# define sk_BY_DIR_HASH_shift(st) SKM_sk_shift(BY_DIR_HASH, (st))\n# define sk_BY_DIR_HASH_pop(st) SKM_sk_pop(BY_DIR_HASH, (st))\n# define sk_BY_DIR_HASH_sort(st) SKM_sk_sort(BY_DIR_HASH, (st))\n# define sk_BY_DIR_HASH_is_sorted(st) SKM_sk_is_sorted(BY_DIR_HASH, (st))\n# define sk_CMS_CertificateChoices_new(cmp) SKM_sk_new(CMS_CertificateChoices, (cmp))\n# define sk_CMS_CertificateChoices_new_null() SKM_sk_new_null(CMS_CertificateChoices)\n# define sk_CMS_CertificateChoices_free(st) SKM_sk_free(CMS_CertificateChoices, (st))\n# define sk_CMS_CertificateChoices_num(st) SKM_sk_num(CMS_CertificateChoices, (st))\n# define sk_CMS_CertificateChoices_value(st, i) SKM_sk_value(CMS_CertificateChoices, (st), (i))\n# define sk_CMS_CertificateChoices_set(st, i, val) SKM_sk_set(CMS_CertificateChoices, (st), (i), (val))\n# define sk_CMS_CertificateChoices_zero(st) SKM_sk_zero(CMS_CertificateChoices, (st))\n# define sk_CMS_CertificateChoices_push(st, val) SKM_sk_push(CMS_CertificateChoices, (st), (val))\n# define sk_CMS_CertificateChoices_unshift(st, val) SKM_sk_unshift(CMS_CertificateChoices, (st), (val))\n# define sk_CMS_CertificateChoices_find(st, val) SKM_sk_find(CMS_CertificateChoices, (st), (val))\n# define sk_CMS_CertificateChoices_find_ex(st, val) SKM_sk_find_ex(CMS_CertificateChoices, (st), (val))\n# define sk_CMS_CertificateChoices_delete(st, i) SKM_sk_delete(CMS_CertificateChoices, (st), (i))\n# define sk_CMS_CertificateChoices_delete_ptr(st, ptr) SKM_sk_delete_ptr(CMS_CertificateChoices, (st), (ptr))\n# define sk_CMS_CertificateChoices_insert(st, val, i) SKM_sk_insert(CMS_CertificateChoices, (st), (val), (i))\n# define sk_CMS_CertificateChoices_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(CMS_CertificateChoices, (st), (cmp))\n# define sk_CMS_CertificateChoices_dup(st) SKM_sk_dup(CMS_CertificateChoices, st)\n# define sk_CMS_CertificateChoices_pop_free(st, free_func) SKM_sk_pop_free(CMS_CertificateChoices, (st), (free_func))\n# define sk_CMS_CertificateChoices_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(CMS_CertificateChoices, (st), (copy_func), (free_func))\n# define sk_CMS_CertificateChoices_shift(st) SKM_sk_shift(CMS_CertificateChoices, (st))\n# define sk_CMS_CertificateChoices_pop(st) SKM_sk_pop(CMS_CertificateChoices, (st))\n# define sk_CMS_CertificateChoices_sort(st) SKM_sk_sort(CMS_CertificateChoices, (st))\n# define sk_CMS_CertificateChoices_is_sorted(st) SKM_sk_is_sorted(CMS_CertificateChoices, (st))\n# define sk_CMS_RecipientEncryptedKey_new(cmp) SKM_sk_new(CMS_RecipientEncryptedKey, (cmp))\n# define sk_CMS_RecipientEncryptedKey_new_null() SKM_sk_new_null(CMS_RecipientEncryptedKey)\n# define sk_CMS_RecipientEncryptedKey_free(st) SKM_sk_free(CMS_RecipientEncryptedKey, (st))\n# define sk_CMS_RecipientEncryptedKey_num(st) SKM_sk_num(CMS_RecipientEncryptedKey, (st))\n# define sk_CMS_RecipientEncryptedKey_value(st, i) SKM_sk_value(CMS_RecipientEncryptedKey, (st), (i))\n# define sk_CMS_RecipientEncryptedKey_set(st, i, val) SKM_sk_set(CMS_RecipientEncryptedKey, (st), (i), (val))\n# define sk_CMS_RecipientEncryptedKey_zero(st) SKM_sk_zero(CMS_RecipientEncryptedKey, (st))\n# define sk_CMS_RecipientEncryptedKey_push(st, val) SKM_sk_push(CMS_RecipientEncryptedKey, (st), (val))\n# define sk_CMS_RecipientEncryptedKey_unshift(st, val) SKM_sk_unshift(CMS_RecipientEncryptedKey, (st), (val))\n# define sk_CMS_RecipientEncryptedKey_find(st, val) SKM_sk_find(CMS_RecipientEncryptedKey, (st), (val))\n# define sk_CMS_RecipientEncryptedKey_find_ex(st, val) SKM_sk_find_ex(CMS_RecipientEncryptedKey, (st), (val))\n# define sk_CMS_RecipientEncryptedKey_delete(st, i) SKM_sk_delete(CMS_RecipientEncryptedKey, (st), (i))\n# define sk_CMS_RecipientEncryptedKey_delete_ptr(st, ptr) SKM_sk_delete_ptr(CMS_RecipientEncryptedKey, (st), (ptr))\n# define sk_CMS_RecipientEncryptedKey_insert(st, val, i) SKM_sk_insert(CMS_RecipientEncryptedKey, (st), (val), (i))\n# define sk_CMS_RecipientEncryptedKey_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(CMS_RecipientEncryptedKey, (st), (cmp))\n# define sk_CMS_RecipientEncryptedKey_dup(st) SKM_sk_dup(CMS_RecipientEncryptedKey, st)\n# define sk_CMS_RecipientEncryptedKey_pop_free(st, free_func) SKM_sk_pop_free(CMS_RecipientEncryptedKey, (st), (free_func))\n# define sk_CMS_RecipientEncryptedKey_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(CMS_RecipientEncryptedKey, (st), (copy_func), (free_func))\n# define sk_CMS_RecipientEncryptedKey_shift(st) SKM_sk_shift(CMS_RecipientEncryptedKey, (st))\n# define sk_CMS_RecipientEncryptedKey_pop(st) SKM_sk_pop(CMS_RecipientEncryptedKey, (st))\n# define sk_CMS_RecipientEncryptedKey_sort(st) SKM_sk_sort(CMS_RecipientEncryptedKey, (st))\n# define sk_CMS_RecipientEncryptedKey_is_sorted(st) SKM_sk_is_sorted(CMS_RecipientEncryptedKey, (st))\n# define sk_CMS_RecipientInfo_new(cmp) SKM_sk_new(CMS_RecipientInfo, (cmp))\n# define sk_CMS_RecipientInfo_new_null() SKM_sk_new_null(CMS_RecipientInfo)\n# define sk_CMS_RecipientInfo_free(st) SKM_sk_free(CMS_RecipientInfo, (st))\n# define sk_CMS_RecipientInfo_num(st) SKM_sk_num(CMS_RecipientInfo, (st))\n# define sk_CMS_RecipientInfo_value(st, i) SKM_sk_value(CMS_RecipientInfo, (st), (i))\n# define sk_CMS_RecipientInfo_set(st, i, val) SKM_sk_set(CMS_RecipientInfo, (st), (i), (val))\n# define sk_CMS_RecipientInfo_zero(st) SKM_sk_zero(CMS_RecipientInfo, (st))\n# define sk_CMS_RecipientInfo_push(st, val) SKM_sk_push(CMS_RecipientInfo, (st), (val))\n# define sk_CMS_RecipientInfo_unshift(st, val) SKM_sk_unshift(CMS_RecipientInfo, (st), (val))\n# define sk_CMS_RecipientInfo_find(st, val) SKM_sk_find(CMS_RecipientInfo, (st), (val))\n# define sk_CMS_RecipientInfo_find_ex(st, val) SKM_sk_find_ex(CMS_RecipientInfo, (st), (val))\n# define sk_CMS_RecipientInfo_delete(st, i) SKM_sk_delete(CMS_RecipientInfo, (st), (i))\n# define sk_CMS_RecipientInfo_delete_ptr(st, ptr) SKM_sk_delete_ptr(CMS_RecipientInfo, (st), (ptr))\n# define sk_CMS_RecipientInfo_insert(st, val, i) SKM_sk_insert(CMS_RecipientInfo, (st), (val), (i))\n# define sk_CMS_RecipientInfo_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(CMS_RecipientInfo, (st), (cmp))\n# define sk_CMS_RecipientInfo_dup(st) SKM_sk_dup(CMS_RecipientInfo, st)\n# define sk_CMS_RecipientInfo_pop_free(st, free_func) SKM_sk_pop_free(CMS_RecipientInfo, (st), (free_func))\n# define sk_CMS_RecipientInfo_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(CMS_RecipientInfo, (st), (copy_func), (free_func))\n# define sk_CMS_RecipientInfo_shift(st) SKM_sk_shift(CMS_RecipientInfo, (st))\n# define sk_CMS_RecipientInfo_pop(st) SKM_sk_pop(CMS_RecipientInfo, (st))\n# define sk_CMS_RecipientInfo_sort(st) SKM_sk_sort(CMS_RecipientInfo, (st))\n# define sk_CMS_RecipientInfo_is_sorted(st) SKM_sk_is_sorted(CMS_RecipientInfo, (st))\n# define sk_CMS_RevocationInfoChoice_new(cmp) SKM_sk_new(CMS_RevocationInfoChoice, (cmp))\n# define sk_CMS_RevocationInfoChoice_new_null() SKM_sk_new_null(CMS_RevocationInfoChoice)\n# define sk_CMS_RevocationInfoChoice_free(st) SKM_sk_free(CMS_RevocationInfoChoice, (st))\n# define sk_CMS_RevocationInfoChoice_num(st) SKM_sk_num(CMS_RevocationInfoChoice, (st))\n# define sk_CMS_RevocationInfoChoice_value(st, i) SKM_sk_value(CMS_RevocationInfoChoice, (st), (i))\n# define sk_CMS_RevocationInfoChoice_set(st, i, val) SKM_sk_set(CMS_RevocationInfoChoice, (st), (i), (val))\n# define sk_CMS_RevocationInfoChoice_zero(st) SKM_sk_zero(CMS_RevocationInfoChoice, (st))\n# define sk_CMS_RevocationInfoChoice_push(st, val) SKM_sk_push(CMS_RevocationInfoChoice, (st), (val))\n# define sk_CMS_RevocationInfoChoice_unshift(st, val) SKM_sk_unshift(CMS_RevocationInfoChoice, (st), (val))\n# define sk_CMS_RevocationInfoChoice_find(st, val) SKM_sk_find(CMS_RevocationInfoChoice, (st), (val))\n# define sk_CMS_RevocationInfoChoice_find_ex(st, val) SKM_sk_find_ex(CMS_RevocationInfoChoice, (st), (val))\n# define sk_CMS_RevocationInfoChoice_delete(st, i) SKM_sk_delete(CMS_RevocationInfoChoice, (st), (i))\n# define sk_CMS_RevocationInfoChoice_delete_ptr(st, ptr) SKM_sk_delete_ptr(CMS_RevocationInfoChoice, (st), (ptr))\n# define sk_CMS_RevocationInfoChoice_insert(st, val, i) SKM_sk_insert(CMS_RevocationInfoChoice, (st), (val), (i))\n# define sk_CMS_RevocationInfoChoice_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(CMS_RevocationInfoChoice, (st), (cmp))\n# define sk_CMS_RevocationInfoChoice_dup(st) SKM_sk_dup(CMS_RevocationInfoChoice, st)\n# define sk_CMS_RevocationInfoChoice_pop_free(st, free_func) SKM_sk_pop_free(CMS_RevocationInfoChoice, (st), (free_func))\n# define sk_CMS_RevocationInfoChoice_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(CMS_RevocationInfoChoice, (st), (copy_func), (free_func))\n# define sk_CMS_RevocationInfoChoice_shift(st) SKM_sk_shift(CMS_RevocationInfoChoice, (st))\n# define sk_CMS_RevocationInfoChoice_pop(st) SKM_sk_pop(CMS_RevocationInfoChoice, (st))\n# define sk_CMS_RevocationInfoChoice_sort(st) SKM_sk_sort(CMS_RevocationInfoChoice, (st))\n# define sk_CMS_RevocationInfoChoice_is_sorted(st) SKM_sk_is_sorted(CMS_RevocationInfoChoice, (st))\n# define sk_CMS_SignerInfo_new(cmp) SKM_sk_new(CMS_SignerInfo, (cmp))\n# define sk_CMS_SignerInfo_new_null() SKM_sk_new_null(CMS_SignerInfo)\n# define sk_CMS_SignerInfo_free(st) SKM_sk_free(CMS_SignerInfo, (st))\n# define sk_CMS_SignerInfo_num(st) SKM_sk_num(CMS_SignerInfo, (st))\n# define sk_CMS_SignerInfo_value(st, i) SKM_sk_value(CMS_SignerInfo, (st), (i))\n# define sk_CMS_SignerInfo_set(st, i, val) SKM_sk_set(CMS_SignerInfo, (st), (i), (val))\n# define sk_CMS_SignerInfo_zero(st) SKM_sk_zero(CMS_SignerInfo, (st))\n# define sk_CMS_SignerInfo_push(st, val) SKM_sk_push(CMS_SignerInfo, (st), (val))\n# define sk_CMS_SignerInfo_unshift(st, val) SKM_sk_unshift(CMS_SignerInfo, (st), (val))\n# define sk_CMS_SignerInfo_find(st, val) SKM_sk_find(CMS_SignerInfo, (st), (val))\n# define sk_CMS_SignerInfo_find_ex(st, val) SKM_sk_find_ex(CMS_SignerInfo, (st), (val))\n# define sk_CMS_SignerInfo_delete(st, i) SKM_sk_delete(CMS_SignerInfo, (st), (i))\n# define sk_CMS_SignerInfo_delete_ptr(st, ptr) SKM_sk_delete_ptr(CMS_SignerInfo, (st), (ptr))\n# define sk_CMS_SignerInfo_insert(st, val, i) SKM_sk_insert(CMS_SignerInfo, (st), (val), (i))\n# define sk_CMS_SignerInfo_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(CMS_SignerInfo, (st), (cmp))\n# define sk_CMS_SignerInfo_dup(st) SKM_sk_dup(CMS_SignerInfo, st)\n# define sk_CMS_SignerInfo_pop_free(st, free_func) SKM_sk_pop_free(CMS_SignerInfo, (st), (free_func))\n# define sk_CMS_SignerInfo_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(CMS_SignerInfo, (st), (copy_func), (free_func))\n# define sk_CMS_SignerInfo_shift(st) SKM_sk_shift(CMS_SignerInfo, (st))\n# define sk_CMS_SignerInfo_pop(st) SKM_sk_pop(CMS_SignerInfo, (st))\n# define sk_CMS_SignerInfo_sort(st) SKM_sk_sort(CMS_SignerInfo, (st))\n# define sk_CMS_SignerInfo_is_sorted(st) SKM_sk_is_sorted(CMS_SignerInfo, (st))\n# define sk_CONF_IMODULE_new(cmp) SKM_sk_new(CONF_IMODULE, (cmp))\n# define sk_CONF_IMODULE_new_null() SKM_sk_new_null(CONF_IMODULE)\n# define sk_CONF_IMODULE_free(st) SKM_sk_free(CONF_IMODULE, (st))\n# define sk_CONF_IMODULE_num(st) SKM_sk_num(CONF_IMODULE, (st))\n# define sk_CONF_IMODULE_value(st, i) SKM_sk_value(CONF_IMODULE, (st), (i))\n# define sk_CONF_IMODULE_set(st, i, val) SKM_sk_set(CONF_IMODULE, (st), (i), (val))\n# define sk_CONF_IMODULE_zero(st) SKM_sk_zero(CONF_IMODULE, (st))\n# define sk_CONF_IMODULE_push(st, val) SKM_sk_push(CONF_IMODULE, (st), (val))\n# define sk_CONF_IMODULE_unshift(st, val) SKM_sk_unshift(CONF_IMODULE, (st), (val))\n# define sk_CONF_IMODULE_find(st, val) SKM_sk_find(CONF_IMODULE, (st), (val))\n# define sk_CONF_IMODULE_find_ex(st, val) SKM_sk_find_ex(CONF_IMODULE, (st), (val))\n# define sk_CONF_IMODULE_delete(st, i) SKM_sk_delete(CONF_IMODULE, (st), (i))\n# define sk_CONF_IMODULE_delete_ptr(st, ptr) SKM_sk_delete_ptr(CONF_IMODULE, (st), (ptr))\n# define sk_CONF_IMODULE_insert(st, val, i) SKM_sk_insert(CONF_IMODULE, (st), (val), (i))\n# define sk_CONF_IMODULE_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(CONF_IMODULE, (st), (cmp))\n# define sk_CONF_IMODULE_dup(st) SKM_sk_dup(CONF_IMODULE, st)\n# define sk_CONF_IMODULE_pop_free(st, free_func) SKM_sk_pop_free(CONF_IMODULE, (st), (free_func))\n# define sk_CONF_IMODULE_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(CONF_IMODULE, (st), (copy_func), (free_func))\n# define sk_CONF_IMODULE_shift(st) SKM_sk_shift(CONF_IMODULE, (st))\n# define sk_CONF_IMODULE_pop(st) SKM_sk_pop(CONF_IMODULE, (st))\n# define sk_CONF_IMODULE_sort(st) SKM_sk_sort(CONF_IMODULE, (st))\n# define sk_CONF_IMODULE_is_sorted(st) SKM_sk_is_sorted(CONF_IMODULE, (st))\n# define sk_CONF_MODULE_new(cmp) SKM_sk_new(CONF_MODULE, (cmp))\n# define sk_CONF_MODULE_new_null() SKM_sk_new_null(CONF_MODULE)\n# define sk_CONF_MODULE_free(st) SKM_sk_free(CONF_MODULE, (st))\n# define sk_CONF_MODULE_num(st) SKM_sk_num(CONF_MODULE, (st))\n# define sk_CONF_MODULE_value(st, i) SKM_sk_value(CONF_MODULE, (st), (i))\n# define sk_CONF_MODULE_set(st, i, val) SKM_sk_set(CONF_MODULE, (st), (i), (val))\n# define sk_CONF_MODULE_zero(st) SKM_sk_zero(CONF_MODULE, (st))\n# define sk_CONF_MODULE_push(st, val) SKM_sk_push(CONF_MODULE, (st), (val))\n# define sk_CONF_MODULE_unshift(st, val) SKM_sk_unshift(CONF_MODULE, (st), (val))\n# define sk_CONF_MODULE_find(st, val) SKM_sk_find(CONF_MODULE, (st), (val))\n# define sk_CONF_MODULE_find_ex(st, val) SKM_sk_find_ex(CONF_MODULE, (st), (val))\n# define sk_CONF_MODULE_delete(st, i) SKM_sk_delete(CONF_MODULE, (st), (i))\n# define sk_CONF_MODULE_delete_ptr(st, ptr) SKM_sk_delete_ptr(CONF_MODULE, (st), (ptr))\n# define sk_CONF_MODULE_insert(st, val, i) SKM_sk_insert(CONF_MODULE, (st), (val), (i))\n# define sk_CONF_MODULE_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(CONF_MODULE, (st), (cmp))\n# define sk_CONF_MODULE_dup(st) SKM_sk_dup(CONF_MODULE, st)\n# define sk_CONF_MODULE_pop_free(st, free_func) SKM_sk_pop_free(CONF_MODULE, (st), (free_func))\n# define sk_CONF_MODULE_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(CONF_MODULE, (st), (copy_func), (free_func))\n# define sk_CONF_MODULE_shift(st) SKM_sk_shift(CONF_MODULE, (st))\n# define sk_CONF_MODULE_pop(st) SKM_sk_pop(CONF_MODULE, (st))\n# define sk_CONF_MODULE_sort(st) SKM_sk_sort(CONF_MODULE, (st))\n# define sk_CONF_MODULE_is_sorted(st) SKM_sk_is_sorted(CONF_MODULE, (st))\n# define sk_CONF_VALUE_new(cmp) SKM_sk_new(CONF_VALUE, (cmp))\n# define sk_CONF_VALUE_new_null() SKM_sk_new_null(CONF_VALUE)\n# define sk_CONF_VALUE_free(st) SKM_sk_free(CONF_VALUE, (st))\n# define sk_CONF_VALUE_num(st) SKM_sk_num(CONF_VALUE, (st))\n# define sk_CONF_VALUE_value(st, i) SKM_sk_value(CONF_VALUE, (st), (i))\n# define sk_CONF_VALUE_set(st, i, val) SKM_sk_set(CONF_VALUE, (st), (i), (val))\n# define sk_CONF_VALUE_zero(st) SKM_sk_zero(CONF_VALUE, (st))\n# define sk_CONF_VALUE_push(st, val) SKM_sk_push(CONF_VALUE, (st), (val))\n# define sk_CONF_VALUE_unshift(st, val) SKM_sk_unshift(CONF_VALUE, (st), (val))\n# define sk_CONF_VALUE_find(st, val) SKM_sk_find(CONF_VALUE, (st), (val))\n# define sk_CONF_VALUE_find_ex(st, val) SKM_sk_find_ex(CONF_VALUE, (st), (val))\n# define sk_CONF_VALUE_delete(st, i) SKM_sk_delete(CONF_VALUE, (st), (i))\n# define sk_CONF_VALUE_delete_ptr(st, ptr) SKM_sk_delete_ptr(CONF_VALUE, (st), (ptr))\n# define sk_CONF_VALUE_insert(st, val, i) SKM_sk_insert(CONF_VALUE, (st), (val), (i))\n# define sk_CONF_VALUE_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(CONF_VALUE, (st), (cmp))\n# define sk_CONF_VALUE_dup(st) SKM_sk_dup(CONF_VALUE, st)\n# define sk_CONF_VALUE_pop_free(st, free_func) SKM_sk_pop_free(CONF_VALUE, (st), (free_func))\n# define sk_CONF_VALUE_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(CONF_VALUE, (st), (copy_func), (free_func))\n# define sk_CONF_VALUE_shift(st) SKM_sk_shift(CONF_VALUE, (st))\n# define sk_CONF_VALUE_pop(st) SKM_sk_pop(CONF_VALUE, (st))\n# define sk_CONF_VALUE_sort(st) SKM_sk_sort(CONF_VALUE, (st))\n# define sk_CONF_VALUE_is_sorted(st) SKM_sk_is_sorted(CONF_VALUE, (st))\n# define sk_CRYPTO_EX_DATA_FUNCS_new(cmp) SKM_sk_new(CRYPTO_EX_DATA_FUNCS, (cmp))\n# define sk_CRYPTO_EX_DATA_FUNCS_new_null() SKM_sk_new_null(CRYPTO_EX_DATA_FUNCS)\n# define sk_CRYPTO_EX_DATA_FUNCS_free(st) SKM_sk_free(CRYPTO_EX_DATA_FUNCS, (st))\n# define sk_CRYPTO_EX_DATA_FUNCS_num(st) SKM_sk_num(CRYPTO_EX_DATA_FUNCS, (st))\n# define sk_CRYPTO_EX_DATA_FUNCS_value(st, i) SKM_sk_value(CRYPTO_EX_DATA_FUNCS, (st), (i))\n# define sk_CRYPTO_EX_DATA_FUNCS_set(st, i, val) SKM_sk_set(CRYPTO_EX_DATA_FUNCS, (st), (i), (val))\n# define sk_CRYPTO_EX_DATA_FUNCS_zero(st) SKM_sk_zero(CRYPTO_EX_DATA_FUNCS, (st))\n# define sk_CRYPTO_EX_DATA_FUNCS_push(st, val) SKM_sk_push(CRYPTO_EX_DATA_FUNCS, (st), (val))\n# define sk_CRYPTO_EX_DATA_FUNCS_unshift(st, val) SKM_sk_unshift(CRYPTO_EX_DATA_FUNCS, (st), (val))\n# define sk_CRYPTO_EX_DATA_FUNCS_find(st, val) SKM_sk_find(CRYPTO_EX_DATA_FUNCS, (st), (val))\n# define sk_CRYPTO_EX_DATA_FUNCS_find_ex(st, val) SKM_sk_find_ex(CRYPTO_EX_DATA_FUNCS, (st), (val))\n# define sk_CRYPTO_EX_DATA_FUNCS_delete(st, i) SKM_sk_delete(CRYPTO_EX_DATA_FUNCS, (st), (i))\n# define sk_CRYPTO_EX_DATA_FUNCS_delete_ptr(st, ptr) SKM_sk_delete_ptr(CRYPTO_EX_DATA_FUNCS, (st), (ptr))\n# define sk_CRYPTO_EX_DATA_FUNCS_insert(st, val, i) SKM_sk_insert(CRYPTO_EX_DATA_FUNCS, (st), (val), (i))\n# define sk_CRYPTO_EX_DATA_FUNCS_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(CRYPTO_EX_DATA_FUNCS, (st), (cmp))\n# define sk_CRYPTO_EX_DATA_FUNCS_dup(st) SKM_sk_dup(CRYPTO_EX_DATA_FUNCS, st)\n# define sk_CRYPTO_EX_DATA_FUNCS_pop_free(st, free_func) SKM_sk_pop_free(CRYPTO_EX_DATA_FUNCS, (st), (free_func))\n# define sk_CRYPTO_EX_DATA_FUNCS_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(CRYPTO_EX_DATA_FUNCS, (st), (copy_func), (free_func))\n# define sk_CRYPTO_EX_DATA_FUNCS_shift(st) SKM_sk_shift(CRYPTO_EX_DATA_FUNCS, (st))\n# define sk_CRYPTO_EX_DATA_FUNCS_pop(st) SKM_sk_pop(CRYPTO_EX_DATA_FUNCS, (st))\n# define sk_CRYPTO_EX_DATA_FUNCS_sort(st) SKM_sk_sort(CRYPTO_EX_DATA_FUNCS, (st))\n# define sk_CRYPTO_EX_DATA_FUNCS_is_sorted(st) SKM_sk_is_sorted(CRYPTO_EX_DATA_FUNCS, (st))\n# define sk_CRYPTO_dynlock_new(cmp) SKM_sk_new(CRYPTO_dynlock, (cmp))\n# define sk_CRYPTO_dynlock_new_null() SKM_sk_new_null(CRYPTO_dynlock)\n# define sk_CRYPTO_dynlock_free(st) SKM_sk_free(CRYPTO_dynlock, (st))\n# define sk_CRYPTO_dynlock_num(st) SKM_sk_num(CRYPTO_dynlock, (st))\n# define sk_CRYPTO_dynlock_value(st, i) SKM_sk_value(CRYPTO_dynlock, (st), (i))\n# define sk_CRYPTO_dynlock_set(st, i, val) SKM_sk_set(CRYPTO_dynlock, (st), (i), (val))\n# define sk_CRYPTO_dynlock_zero(st) SKM_sk_zero(CRYPTO_dynlock, (st))\n# define sk_CRYPTO_dynlock_push(st, val) SKM_sk_push(CRYPTO_dynlock, (st), (val))\n# define sk_CRYPTO_dynlock_unshift(st, val) SKM_sk_unshift(CRYPTO_dynlock, (st), (val))\n# define sk_CRYPTO_dynlock_find(st, val) SKM_sk_find(CRYPTO_dynlock, (st), (val))\n# define sk_CRYPTO_dynlock_find_ex(st, val) SKM_sk_find_ex(CRYPTO_dynlock, (st), (val))\n# define sk_CRYPTO_dynlock_delete(st, i) SKM_sk_delete(CRYPTO_dynlock, (st), (i))\n# define sk_CRYPTO_dynlock_delete_ptr(st, ptr) SKM_sk_delete_ptr(CRYPTO_dynlock, (st), (ptr))\n# define sk_CRYPTO_dynlock_insert(st, val, i) SKM_sk_insert(CRYPTO_dynlock, (st), (val), (i))\n# define sk_CRYPTO_dynlock_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(CRYPTO_dynlock, (st), (cmp))\n# define sk_CRYPTO_dynlock_dup(st) SKM_sk_dup(CRYPTO_dynlock, st)\n# define sk_CRYPTO_dynlock_pop_free(st, free_func) SKM_sk_pop_free(CRYPTO_dynlock, (st), (free_func))\n# define sk_CRYPTO_dynlock_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(CRYPTO_dynlock, (st), (copy_func), (free_func))\n# define sk_CRYPTO_dynlock_shift(st) SKM_sk_shift(CRYPTO_dynlock, (st))\n# define sk_CRYPTO_dynlock_pop(st) SKM_sk_pop(CRYPTO_dynlock, (st))\n# define sk_CRYPTO_dynlock_sort(st) SKM_sk_sort(CRYPTO_dynlock, (st))\n# define sk_CRYPTO_dynlock_is_sorted(st) SKM_sk_is_sorted(CRYPTO_dynlock, (st))\n# define sk_DIST_POINT_new(cmp) SKM_sk_new(DIST_POINT, (cmp))\n# define sk_DIST_POINT_new_null() SKM_sk_new_null(DIST_POINT)\n# define sk_DIST_POINT_free(st) SKM_sk_free(DIST_POINT, (st))\n# define sk_DIST_POINT_num(st) SKM_sk_num(DIST_POINT, (st))\n# define sk_DIST_POINT_value(st, i) SKM_sk_value(DIST_POINT, (st), (i))\n# define sk_DIST_POINT_set(st, i, val) SKM_sk_set(DIST_POINT, (st), (i), (val))\n# define sk_DIST_POINT_zero(st) SKM_sk_zero(DIST_POINT, (st))\n# define sk_DIST_POINT_push(st, val) SKM_sk_push(DIST_POINT, (st), (val))\n# define sk_DIST_POINT_unshift(st, val) SKM_sk_unshift(DIST_POINT, (st), (val))\n# define sk_DIST_POINT_find(st, val) SKM_sk_find(DIST_POINT, (st), (val))\n# define sk_DIST_POINT_find_ex(st, val) SKM_sk_find_ex(DIST_POINT, (st), (val))\n# define sk_DIST_POINT_delete(st, i) SKM_sk_delete(DIST_POINT, (st), (i))\n# define sk_DIST_POINT_delete_ptr(st, ptr) SKM_sk_delete_ptr(DIST_POINT, (st), (ptr))\n# define sk_DIST_POINT_insert(st, val, i) SKM_sk_insert(DIST_POINT, (st), (val), (i))\n# define sk_DIST_POINT_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(DIST_POINT, (st), (cmp))\n# define sk_DIST_POINT_dup(st) SKM_sk_dup(DIST_POINT, st)\n# define sk_DIST_POINT_pop_free(st, free_func) SKM_sk_pop_free(DIST_POINT, (st), (free_func))\n# define sk_DIST_POINT_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(DIST_POINT, (st), (copy_func), (free_func))\n# define sk_DIST_POINT_shift(st) SKM_sk_shift(DIST_POINT, (st))\n# define sk_DIST_POINT_pop(st) SKM_sk_pop(DIST_POINT, (st))\n# define sk_DIST_POINT_sort(st) SKM_sk_sort(DIST_POINT, (st))\n# define sk_DIST_POINT_is_sorted(st) SKM_sk_is_sorted(DIST_POINT, (st))\n# define sk_ENGINE_new(cmp) SKM_sk_new(ENGINE, (cmp))\n# define sk_ENGINE_new_null() SKM_sk_new_null(ENGINE)\n# define sk_ENGINE_free(st) SKM_sk_free(ENGINE, (st))\n# define sk_ENGINE_num(st) SKM_sk_num(ENGINE, (st))\n# define sk_ENGINE_value(st, i) SKM_sk_value(ENGINE, (st), (i))\n# define sk_ENGINE_set(st, i, val) SKM_sk_set(ENGINE, (st), (i), (val))\n# define sk_ENGINE_zero(st) SKM_sk_zero(ENGINE, (st))\n# define sk_ENGINE_push(st, val) SKM_sk_push(ENGINE, (st), (val))\n# define sk_ENGINE_unshift(st, val) SKM_sk_unshift(ENGINE, (st), (val))\n# define sk_ENGINE_find(st, val) SKM_sk_find(ENGINE, (st), (val))\n# define sk_ENGINE_find_ex(st, val) SKM_sk_find_ex(ENGINE, (st), (val))\n# define sk_ENGINE_delete(st, i) SKM_sk_delete(ENGINE, (st), (i))\n# define sk_ENGINE_delete_ptr(st, ptr) SKM_sk_delete_ptr(ENGINE, (st), (ptr))\n# define sk_ENGINE_insert(st, val, i) SKM_sk_insert(ENGINE, (st), (val), (i))\n# define sk_ENGINE_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(ENGINE, (st), (cmp))\n# define sk_ENGINE_dup(st) SKM_sk_dup(ENGINE, st)\n# define sk_ENGINE_pop_free(st, free_func) SKM_sk_pop_free(ENGINE, (st), (free_func))\n# define sk_ENGINE_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(ENGINE, (st), (copy_func), (free_func))\n# define sk_ENGINE_shift(st) SKM_sk_shift(ENGINE, (st))\n# define sk_ENGINE_pop(st) SKM_sk_pop(ENGINE, (st))\n# define sk_ENGINE_sort(st) SKM_sk_sort(ENGINE, (st))\n# define sk_ENGINE_is_sorted(st) SKM_sk_is_sorted(ENGINE, (st))\n# define sk_ENGINE_CLEANUP_ITEM_new(cmp) SKM_sk_new(ENGINE_CLEANUP_ITEM, (cmp))\n# define sk_ENGINE_CLEANUP_ITEM_new_null() SKM_sk_new_null(ENGINE_CLEANUP_ITEM)\n# define sk_ENGINE_CLEANUP_ITEM_free(st) SKM_sk_free(ENGINE_CLEANUP_ITEM, (st))\n# define sk_ENGINE_CLEANUP_ITEM_num(st) SKM_sk_num(ENGINE_CLEANUP_ITEM, (st))\n# define sk_ENGINE_CLEANUP_ITEM_value(st, i) SKM_sk_value(ENGINE_CLEANUP_ITEM, (st), (i))\n# define sk_ENGINE_CLEANUP_ITEM_set(st, i, val) SKM_sk_set(ENGINE_CLEANUP_ITEM, (st), (i), (val))\n# define sk_ENGINE_CLEANUP_ITEM_zero(st) SKM_sk_zero(ENGINE_CLEANUP_ITEM, (st))\n# define sk_ENGINE_CLEANUP_ITEM_push(st, val) SKM_sk_push(ENGINE_CLEANUP_ITEM, (st), (val))\n# define sk_ENGINE_CLEANUP_ITEM_unshift(st, val) SKM_sk_unshift(ENGINE_CLEANUP_ITEM, (st), (val))\n# define sk_ENGINE_CLEANUP_ITEM_find(st, val) SKM_sk_find(ENGINE_CLEANUP_ITEM, (st), (val))\n# define sk_ENGINE_CLEANUP_ITEM_find_ex(st, val) SKM_sk_find_ex(ENGINE_CLEANUP_ITEM, (st), (val))\n# define sk_ENGINE_CLEANUP_ITEM_delete(st, i) SKM_sk_delete(ENGINE_CLEANUP_ITEM, (st), (i))\n# define sk_ENGINE_CLEANUP_ITEM_delete_ptr(st, ptr) SKM_sk_delete_ptr(ENGINE_CLEANUP_ITEM, (st), (ptr))\n# define sk_ENGINE_CLEANUP_ITEM_insert(st, val, i) SKM_sk_insert(ENGINE_CLEANUP_ITEM, (st), (val), (i))\n# define sk_ENGINE_CLEANUP_ITEM_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(ENGINE_CLEANUP_ITEM, (st), (cmp))\n# define sk_ENGINE_CLEANUP_ITEM_dup(st) SKM_sk_dup(ENGINE_CLEANUP_ITEM, st)\n# define sk_ENGINE_CLEANUP_ITEM_pop_free(st, free_func) SKM_sk_pop_free(ENGINE_CLEANUP_ITEM, (st), (free_func))\n# define sk_ENGINE_CLEANUP_ITEM_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(ENGINE_CLEANUP_ITEM, (st), (copy_func), (free_func))\n# define sk_ENGINE_CLEANUP_ITEM_shift(st) SKM_sk_shift(ENGINE_CLEANUP_ITEM, (st))\n# define sk_ENGINE_CLEANUP_ITEM_pop(st) SKM_sk_pop(ENGINE_CLEANUP_ITEM, (st))\n# define sk_ENGINE_CLEANUP_ITEM_sort(st) SKM_sk_sort(ENGINE_CLEANUP_ITEM, (st))\n# define sk_ENGINE_CLEANUP_ITEM_is_sorted(st) SKM_sk_is_sorted(ENGINE_CLEANUP_ITEM, (st))\n# define sk_ESS_CERT_ID_new(cmp) SKM_sk_new(ESS_CERT_ID, (cmp))\n# define sk_ESS_CERT_ID_new_null() SKM_sk_new_null(ESS_CERT_ID)\n# define sk_ESS_CERT_ID_free(st) SKM_sk_free(ESS_CERT_ID, (st))\n# define sk_ESS_CERT_ID_num(st) SKM_sk_num(ESS_CERT_ID, (st))\n# define sk_ESS_CERT_ID_value(st, i) SKM_sk_value(ESS_CERT_ID, (st), (i))\n# define sk_ESS_CERT_ID_set(st, i, val) SKM_sk_set(ESS_CERT_ID, (st), (i), (val))\n# define sk_ESS_CERT_ID_zero(st) SKM_sk_zero(ESS_CERT_ID, (st))\n# define sk_ESS_CERT_ID_push(st, val) SKM_sk_push(ESS_CERT_ID, (st), (val))\n# define sk_ESS_CERT_ID_unshift(st, val) SKM_sk_unshift(ESS_CERT_ID, (st), (val))\n# define sk_ESS_CERT_ID_find(st, val) SKM_sk_find(ESS_CERT_ID, (st), (val))\n# define sk_ESS_CERT_ID_find_ex(st, val) SKM_sk_find_ex(ESS_CERT_ID, (st), (val))\n# define sk_ESS_CERT_ID_delete(st, i) SKM_sk_delete(ESS_CERT_ID, (st), (i))\n# define sk_ESS_CERT_ID_delete_ptr(st, ptr) SKM_sk_delete_ptr(ESS_CERT_ID, (st), (ptr))\n# define sk_ESS_CERT_ID_insert(st, val, i) SKM_sk_insert(ESS_CERT_ID, (st), (val), (i))\n# define sk_ESS_CERT_ID_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(ESS_CERT_ID, (st), (cmp))\n# define sk_ESS_CERT_ID_dup(st) SKM_sk_dup(ESS_CERT_ID, st)\n# define sk_ESS_CERT_ID_pop_free(st, free_func) SKM_sk_pop_free(ESS_CERT_ID, (st), (free_func))\n# define sk_ESS_CERT_ID_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(ESS_CERT_ID, (st), (copy_func), (free_func))\n# define sk_ESS_CERT_ID_shift(st) SKM_sk_shift(ESS_CERT_ID, (st))\n# define sk_ESS_CERT_ID_pop(st) SKM_sk_pop(ESS_CERT_ID, (st))\n# define sk_ESS_CERT_ID_sort(st) SKM_sk_sort(ESS_CERT_ID, (st))\n# define sk_ESS_CERT_ID_is_sorted(st) SKM_sk_is_sorted(ESS_CERT_ID, (st))\n# define sk_EVP_MD_new(cmp) SKM_sk_new(EVP_MD, (cmp))\n# define sk_EVP_MD_new_null() SKM_sk_new_null(EVP_MD)\n# define sk_EVP_MD_free(st) SKM_sk_free(EVP_MD, (st))\n# define sk_EVP_MD_num(st) SKM_sk_num(EVP_MD, (st))\n# define sk_EVP_MD_value(st, i) SKM_sk_value(EVP_MD, (st), (i))\n# define sk_EVP_MD_set(st, i, val) SKM_sk_set(EVP_MD, (st), (i), (val))\n# define sk_EVP_MD_zero(st) SKM_sk_zero(EVP_MD, (st))\n# define sk_EVP_MD_push(st, val) SKM_sk_push(EVP_MD, (st), (val))\n# define sk_EVP_MD_unshift(st, val) SKM_sk_unshift(EVP_MD, (st), (val))\n# define sk_EVP_MD_find(st, val) SKM_sk_find(EVP_MD, (st), (val))\n# define sk_EVP_MD_find_ex(st, val) SKM_sk_find_ex(EVP_MD, (st), (val))\n# define sk_EVP_MD_delete(st, i) SKM_sk_delete(EVP_MD, (st), (i))\n# define sk_EVP_MD_delete_ptr(st, ptr) SKM_sk_delete_ptr(EVP_MD, (st), (ptr))\n# define sk_EVP_MD_insert(st, val, i) SKM_sk_insert(EVP_MD, (st), (val), (i))\n# define sk_EVP_MD_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(EVP_MD, (st), (cmp))\n# define sk_EVP_MD_dup(st) SKM_sk_dup(EVP_MD, st)\n# define sk_EVP_MD_pop_free(st, free_func) SKM_sk_pop_free(EVP_MD, (st), (free_func))\n# define sk_EVP_MD_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(EVP_MD, (st), (copy_func), (free_func))\n# define sk_EVP_MD_shift(st) SKM_sk_shift(EVP_MD, (st))\n# define sk_EVP_MD_pop(st) SKM_sk_pop(EVP_MD, (st))\n# define sk_EVP_MD_sort(st) SKM_sk_sort(EVP_MD, (st))\n# define sk_EVP_MD_is_sorted(st) SKM_sk_is_sorted(EVP_MD, (st))\n# define sk_EVP_PBE_CTL_new(cmp) SKM_sk_new(EVP_PBE_CTL, (cmp))\n# define sk_EVP_PBE_CTL_new_null() SKM_sk_new_null(EVP_PBE_CTL)\n# define sk_EVP_PBE_CTL_free(st) SKM_sk_free(EVP_PBE_CTL, (st))\n# define sk_EVP_PBE_CTL_num(st) SKM_sk_num(EVP_PBE_CTL, (st))\n# define sk_EVP_PBE_CTL_value(st, i) SKM_sk_value(EVP_PBE_CTL, (st), (i))\n# define sk_EVP_PBE_CTL_set(st, i, val) SKM_sk_set(EVP_PBE_CTL, (st), (i), (val))\n# define sk_EVP_PBE_CTL_zero(st) SKM_sk_zero(EVP_PBE_CTL, (st))\n# define sk_EVP_PBE_CTL_push(st, val) SKM_sk_push(EVP_PBE_CTL, (st), (val))\n# define sk_EVP_PBE_CTL_unshift(st, val) SKM_sk_unshift(EVP_PBE_CTL, (st), (val))\n# define sk_EVP_PBE_CTL_find(st, val) SKM_sk_find(EVP_PBE_CTL, (st), (val))\n# define sk_EVP_PBE_CTL_find_ex(st, val) SKM_sk_find_ex(EVP_PBE_CTL, (st), (val))\n# define sk_EVP_PBE_CTL_delete(st, i) SKM_sk_delete(EVP_PBE_CTL, (st), (i))\n# define sk_EVP_PBE_CTL_delete_ptr(st, ptr) SKM_sk_delete_ptr(EVP_PBE_CTL, (st), (ptr))\n# define sk_EVP_PBE_CTL_insert(st, val, i) SKM_sk_insert(EVP_PBE_CTL, (st), (val), (i))\n# define sk_EVP_PBE_CTL_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(EVP_PBE_CTL, (st), (cmp))\n# define sk_EVP_PBE_CTL_dup(st) SKM_sk_dup(EVP_PBE_CTL, st)\n# define sk_EVP_PBE_CTL_pop_free(st, free_func) SKM_sk_pop_free(EVP_PBE_CTL, (st), (free_func))\n# define sk_EVP_PBE_CTL_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(EVP_PBE_CTL, (st), (copy_func), (free_func))\n# define sk_EVP_PBE_CTL_shift(st) SKM_sk_shift(EVP_PBE_CTL, (st))\n# define sk_EVP_PBE_CTL_pop(st) SKM_sk_pop(EVP_PBE_CTL, (st))\n# define sk_EVP_PBE_CTL_sort(st) SKM_sk_sort(EVP_PBE_CTL, (st))\n# define sk_EVP_PBE_CTL_is_sorted(st) SKM_sk_is_sorted(EVP_PBE_CTL, (st))\n# define sk_EVP_PKEY_ASN1_METHOD_new(cmp) SKM_sk_new(EVP_PKEY_ASN1_METHOD, (cmp))\n# define sk_EVP_PKEY_ASN1_METHOD_new_null() SKM_sk_new_null(EVP_PKEY_ASN1_METHOD)\n# define sk_EVP_PKEY_ASN1_METHOD_free(st) SKM_sk_free(EVP_PKEY_ASN1_METHOD, (st))\n# define sk_EVP_PKEY_ASN1_METHOD_num(st) SKM_sk_num(EVP_PKEY_ASN1_METHOD, (st))\n# define sk_EVP_PKEY_ASN1_METHOD_value(st, i) SKM_sk_value(EVP_PKEY_ASN1_METHOD, (st), (i))\n# define sk_EVP_PKEY_ASN1_METHOD_set(st, i, val) SKM_sk_set(EVP_PKEY_ASN1_METHOD, (st), (i), (val))\n# define sk_EVP_PKEY_ASN1_METHOD_zero(st) SKM_sk_zero(EVP_PKEY_ASN1_METHOD, (st))\n# define sk_EVP_PKEY_ASN1_METHOD_push(st, val) SKM_sk_push(EVP_PKEY_ASN1_METHOD, (st), (val))\n# define sk_EVP_PKEY_ASN1_METHOD_unshift(st, val) SKM_sk_unshift(EVP_PKEY_ASN1_METHOD, (st), (val))\n# define sk_EVP_PKEY_ASN1_METHOD_find(st, val) SKM_sk_find(EVP_PKEY_ASN1_METHOD, (st), (val))\n# define sk_EVP_PKEY_ASN1_METHOD_find_ex(st, val) SKM_sk_find_ex(EVP_PKEY_ASN1_METHOD, (st), (val))\n# define sk_EVP_PKEY_ASN1_METHOD_delete(st, i) SKM_sk_delete(EVP_PKEY_ASN1_METHOD, (st), (i))\n# define sk_EVP_PKEY_ASN1_METHOD_delete_ptr(st, ptr) SKM_sk_delete_ptr(EVP_PKEY_ASN1_METHOD, (st), (ptr))\n# define sk_EVP_PKEY_ASN1_METHOD_insert(st, val, i) SKM_sk_insert(EVP_PKEY_ASN1_METHOD, (st), (val), (i))\n# define sk_EVP_PKEY_ASN1_METHOD_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(EVP_PKEY_ASN1_METHOD, (st), (cmp))\n# define sk_EVP_PKEY_ASN1_METHOD_dup(st) SKM_sk_dup(EVP_PKEY_ASN1_METHOD, st)\n# define sk_EVP_PKEY_ASN1_METHOD_pop_free(st, free_func) SKM_sk_pop_free(EVP_PKEY_ASN1_METHOD, (st), (free_func))\n# define sk_EVP_PKEY_ASN1_METHOD_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(EVP_PKEY_ASN1_METHOD, (st), (copy_func), (free_func))\n# define sk_EVP_PKEY_ASN1_METHOD_shift(st) SKM_sk_shift(EVP_PKEY_ASN1_METHOD, (st))\n# define sk_EVP_PKEY_ASN1_METHOD_pop(st) SKM_sk_pop(EVP_PKEY_ASN1_METHOD, (st))\n# define sk_EVP_PKEY_ASN1_METHOD_sort(st) SKM_sk_sort(EVP_PKEY_ASN1_METHOD, (st))\n# define sk_EVP_PKEY_ASN1_METHOD_is_sorted(st) SKM_sk_is_sorted(EVP_PKEY_ASN1_METHOD, (st))\n# define sk_EVP_PKEY_METHOD_new(cmp) SKM_sk_new(EVP_PKEY_METHOD, (cmp))\n# define sk_EVP_PKEY_METHOD_new_null() SKM_sk_new_null(EVP_PKEY_METHOD)\n# define sk_EVP_PKEY_METHOD_free(st) SKM_sk_free(EVP_PKEY_METHOD, (st))\n# define sk_EVP_PKEY_METHOD_num(st) SKM_sk_num(EVP_PKEY_METHOD, (st))\n# define sk_EVP_PKEY_METHOD_value(st, i) SKM_sk_value(EVP_PKEY_METHOD, (st), (i))\n# define sk_EVP_PKEY_METHOD_set(st, i, val) SKM_sk_set(EVP_PKEY_METHOD, (st), (i), (val))\n# define sk_EVP_PKEY_METHOD_zero(st) SKM_sk_zero(EVP_PKEY_METHOD, (st))\n# define sk_EVP_PKEY_METHOD_push(st, val) SKM_sk_push(EVP_PKEY_METHOD, (st), (val))\n# define sk_EVP_PKEY_METHOD_unshift(st, val) SKM_sk_unshift(EVP_PKEY_METHOD, (st), (val))\n# define sk_EVP_PKEY_METHOD_find(st, val) SKM_sk_find(EVP_PKEY_METHOD, (st), (val))\n# define sk_EVP_PKEY_METHOD_find_ex(st, val) SKM_sk_find_ex(EVP_PKEY_METHOD, (st), (val))\n# define sk_EVP_PKEY_METHOD_delete(st, i) SKM_sk_delete(EVP_PKEY_METHOD, (st), (i))\n# define sk_EVP_PKEY_METHOD_delete_ptr(st, ptr) SKM_sk_delete_ptr(EVP_PKEY_METHOD, (st), (ptr))\n# define sk_EVP_PKEY_METHOD_insert(st, val, i) SKM_sk_insert(EVP_PKEY_METHOD, (st), (val), (i))\n# define sk_EVP_PKEY_METHOD_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(EVP_PKEY_METHOD, (st), (cmp))\n# define sk_EVP_PKEY_METHOD_dup(st) SKM_sk_dup(EVP_PKEY_METHOD, st)\n# define sk_EVP_PKEY_METHOD_pop_free(st, free_func) SKM_sk_pop_free(EVP_PKEY_METHOD, (st), (free_func))\n# define sk_EVP_PKEY_METHOD_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(EVP_PKEY_METHOD, (st), (copy_func), (free_func))\n# define sk_EVP_PKEY_METHOD_shift(st) SKM_sk_shift(EVP_PKEY_METHOD, (st))\n# define sk_EVP_PKEY_METHOD_pop(st) SKM_sk_pop(EVP_PKEY_METHOD, (st))\n# define sk_EVP_PKEY_METHOD_sort(st) SKM_sk_sort(EVP_PKEY_METHOD, (st))\n# define sk_EVP_PKEY_METHOD_is_sorted(st) SKM_sk_is_sorted(EVP_PKEY_METHOD, (st))\n# define sk_GENERAL_NAME_new(cmp) SKM_sk_new(GENERAL_NAME, (cmp))\n# define sk_GENERAL_NAME_new_null() SKM_sk_new_null(GENERAL_NAME)\n# define sk_GENERAL_NAME_free(st) SKM_sk_free(GENERAL_NAME, (st))\n# define sk_GENERAL_NAME_num(st) SKM_sk_num(GENERAL_NAME, (st))\n# define sk_GENERAL_NAME_value(st, i) SKM_sk_value(GENERAL_NAME, (st), (i))\n# define sk_GENERAL_NAME_set(st, i, val) SKM_sk_set(GENERAL_NAME, (st), (i), (val))\n# define sk_GENERAL_NAME_zero(st) SKM_sk_zero(GENERAL_NAME, (st))\n# define sk_GENERAL_NAME_push(st, val) SKM_sk_push(GENERAL_NAME, (st), (val))\n# define sk_GENERAL_NAME_unshift(st, val) SKM_sk_unshift(GENERAL_NAME, (st), (val))\n# define sk_GENERAL_NAME_find(st, val) SKM_sk_find(GENERAL_NAME, (st), (val))\n# define sk_GENERAL_NAME_find_ex(st, val) SKM_sk_find_ex(GENERAL_NAME, (st), (val))\n# define sk_GENERAL_NAME_delete(st, i) SKM_sk_delete(GENERAL_NAME, (st), (i))\n# define sk_GENERAL_NAME_delete_ptr(st, ptr) SKM_sk_delete_ptr(GENERAL_NAME, (st), (ptr))\n# define sk_GENERAL_NAME_insert(st, val, i) SKM_sk_insert(GENERAL_NAME, (st), (val), (i))\n# define sk_GENERAL_NAME_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(GENERAL_NAME, (st), (cmp))\n# define sk_GENERAL_NAME_dup(st) SKM_sk_dup(GENERAL_NAME, st)\n# define sk_GENERAL_NAME_pop_free(st, free_func) SKM_sk_pop_free(GENERAL_NAME, (st), (free_func))\n# define sk_GENERAL_NAME_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(GENERAL_NAME, (st), (copy_func), (free_func))\n# define sk_GENERAL_NAME_shift(st) SKM_sk_shift(GENERAL_NAME, (st))\n# define sk_GENERAL_NAME_pop(st) SKM_sk_pop(GENERAL_NAME, (st))\n# define sk_GENERAL_NAME_sort(st) SKM_sk_sort(GENERAL_NAME, (st))\n# define sk_GENERAL_NAME_is_sorted(st) SKM_sk_is_sorted(GENERAL_NAME, (st))\n# define sk_GENERAL_NAMES_new(cmp) SKM_sk_new(GENERAL_NAMES, (cmp))\n# define sk_GENERAL_NAMES_new_null() SKM_sk_new_null(GENERAL_NAMES)\n# define sk_GENERAL_NAMES_free(st) SKM_sk_free(GENERAL_NAMES, (st))\n# define sk_GENERAL_NAMES_num(st) SKM_sk_num(GENERAL_NAMES, (st))\n# define sk_GENERAL_NAMES_value(st, i) SKM_sk_value(GENERAL_NAMES, (st), (i))\n# define sk_GENERAL_NAMES_set(st, i, val) SKM_sk_set(GENERAL_NAMES, (st), (i), (val))\n# define sk_GENERAL_NAMES_zero(st) SKM_sk_zero(GENERAL_NAMES, (st))\n# define sk_GENERAL_NAMES_push(st, val) SKM_sk_push(GENERAL_NAMES, (st), (val))\n# define sk_GENERAL_NAMES_unshift(st, val) SKM_sk_unshift(GENERAL_NAMES, (st), (val))\n# define sk_GENERAL_NAMES_find(st, val) SKM_sk_find(GENERAL_NAMES, (st), (val))\n# define sk_GENERAL_NAMES_find_ex(st, val) SKM_sk_find_ex(GENERAL_NAMES, (st), (val))\n# define sk_GENERAL_NAMES_delete(st, i) SKM_sk_delete(GENERAL_NAMES, (st), (i))\n# define sk_GENERAL_NAMES_delete_ptr(st, ptr) SKM_sk_delete_ptr(GENERAL_NAMES, (st), (ptr))\n# define sk_GENERAL_NAMES_insert(st, val, i) SKM_sk_insert(GENERAL_NAMES, (st), (val), (i))\n# define sk_GENERAL_NAMES_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(GENERAL_NAMES, (st), (cmp))\n# define sk_GENERAL_NAMES_dup(st) SKM_sk_dup(GENERAL_NAMES, st)\n# define sk_GENERAL_NAMES_pop_free(st, free_func) SKM_sk_pop_free(GENERAL_NAMES, (st), (free_func))\n# define sk_GENERAL_NAMES_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(GENERAL_NAMES, (st), (copy_func), (free_func))\n# define sk_GENERAL_NAMES_shift(st) SKM_sk_shift(GENERAL_NAMES, (st))\n# define sk_GENERAL_NAMES_pop(st) SKM_sk_pop(GENERAL_NAMES, (st))\n# define sk_GENERAL_NAMES_sort(st) SKM_sk_sort(GENERAL_NAMES, (st))\n# define sk_GENERAL_NAMES_is_sorted(st) SKM_sk_is_sorted(GENERAL_NAMES, (st))\n# define sk_GENERAL_SUBTREE_new(cmp) SKM_sk_new(GENERAL_SUBTREE, (cmp))\n# define sk_GENERAL_SUBTREE_new_null() SKM_sk_new_null(GENERAL_SUBTREE)\n# define sk_GENERAL_SUBTREE_free(st) SKM_sk_free(GENERAL_SUBTREE, (st))\n# define sk_GENERAL_SUBTREE_num(st) SKM_sk_num(GENERAL_SUBTREE, (st))\n# define sk_GENERAL_SUBTREE_value(st, i) SKM_sk_value(GENERAL_SUBTREE, (st), (i))\n# define sk_GENERAL_SUBTREE_set(st, i, val) SKM_sk_set(GENERAL_SUBTREE, (st), (i), (val))\n# define sk_GENERAL_SUBTREE_zero(st) SKM_sk_zero(GENERAL_SUBTREE, (st))\n# define sk_GENERAL_SUBTREE_push(st, val) SKM_sk_push(GENERAL_SUBTREE, (st), (val))\n# define sk_GENERAL_SUBTREE_unshift(st, val) SKM_sk_unshift(GENERAL_SUBTREE, (st), (val))\n# define sk_GENERAL_SUBTREE_find(st, val) SKM_sk_find(GENERAL_SUBTREE, (st), (val))\n# define sk_GENERAL_SUBTREE_find_ex(st, val) SKM_sk_find_ex(GENERAL_SUBTREE, (st), (val))\n# define sk_GENERAL_SUBTREE_delete(st, i) SKM_sk_delete(GENERAL_SUBTREE, (st), (i))\n# define sk_GENERAL_SUBTREE_delete_ptr(st, ptr) SKM_sk_delete_ptr(GENERAL_SUBTREE, (st), (ptr))\n# define sk_GENERAL_SUBTREE_insert(st, val, i) SKM_sk_insert(GENERAL_SUBTREE, (st), (val), (i))\n# define sk_GENERAL_SUBTREE_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(GENERAL_SUBTREE, (st), (cmp))\n# define sk_GENERAL_SUBTREE_dup(st) SKM_sk_dup(GENERAL_SUBTREE, st)\n# define sk_GENERAL_SUBTREE_pop_free(st, free_func) SKM_sk_pop_free(GENERAL_SUBTREE, (st), (free_func))\n# define sk_GENERAL_SUBTREE_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(GENERAL_SUBTREE, (st), (copy_func), (free_func))\n# define sk_GENERAL_SUBTREE_shift(st) SKM_sk_shift(GENERAL_SUBTREE, (st))\n# define sk_GENERAL_SUBTREE_pop(st) SKM_sk_pop(GENERAL_SUBTREE, (st))\n# define sk_GENERAL_SUBTREE_sort(st) SKM_sk_sort(GENERAL_SUBTREE, (st))\n# define sk_GENERAL_SUBTREE_is_sorted(st) SKM_sk_is_sorted(GENERAL_SUBTREE, (st))\n# define sk_IPAddressFamily_new(cmp) SKM_sk_new(IPAddressFamily, (cmp))\n# define sk_IPAddressFamily_new_null() SKM_sk_new_null(IPAddressFamily)\n# define sk_IPAddressFamily_free(st) SKM_sk_free(IPAddressFamily, (st))\n# define sk_IPAddressFamily_num(st) SKM_sk_num(IPAddressFamily, (st))\n# define sk_IPAddressFamily_value(st, i) SKM_sk_value(IPAddressFamily, (st), (i))\n# define sk_IPAddressFamily_set(st, i, val) SKM_sk_set(IPAddressFamily, (st), (i), (val))\n# define sk_IPAddressFamily_zero(st) SKM_sk_zero(IPAddressFamily, (st))\n# define sk_IPAddressFamily_push(st, val) SKM_sk_push(IPAddressFamily, (st), (val))\n# define sk_IPAddressFamily_unshift(st, val) SKM_sk_unshift(IPAddressFamily, (st), (val))\n# define sk_IPAddressFamily_find(st, val) SKM_sk_find(IPAddressFamily, (st), (val))\n# define sk_IPAddressFamily_find_ex(st, val) SKM_sk_find_ex(IPAddressFamily, (st), (val))\n# define sk_IPAddressFamily_delete(st, i) SKM_sk_delete(IPAddressFamily, (st), (i))\n# define sk_IPAddressFamily_delete_ptr(st, ptr) SKM_sk_delete_ptr(IPAddressFamily, (st), (ptr))\n# define sk_IPAddressFamily_insert(st, val, i) SKM_sk_insert(IPAddressFamily, (st), (val), (i))\n# define sk_IPAddressFamily_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(IPAddressFamily, (st), (cmp))\n# define sk_IPAddressFamily_dup(st) SKM_sk_dup(IPAddressFamily, st)\n# define sk_IPAddressFamily_pop_free(st, free_func) SKM_sk_pop_free(IPAddressFamily, (st), (free_func))\n# define sk_IPAddressFamily_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(IPAddressFamily, (st), (copy_func), (free_func))\n# define sk_IPAddressFamily_shift(st) SKM_sk_shift(IPAddressFamily, (st))\n# define sk_IPAddressFamily_pop(st) SKM_sk_pop(IPAddressFamily, (st))\n# define sk_IPAddressFamily_sort(st) SKM_sk_sort(IPAddressFamily, (st))\n# define sk_IPAddressFamily_is_sorted(st) SKM_sk_is_sorted(IPAddressFamily, (st))\n# define sk_IPAddressOrRange_new(cmp) SKM_sk_new(IPAddressOrRange, (cmp))\n# define sk_IPAddressOrRange_new_null() SKM_sk_new_null(IPAddressOrRange)\n# define sk_IPAddressOrRange_free(st) SKM_sk_free(IPAddressOrRange, (st))\n# define sk_IPAddressOrRange_num(st) SKM_sk_num(IPAddressOrRange, (st))\n# define sk_IPAddressOrRange_value(st, i) SKM_sk_value(IPAddressOrRange, (st), (i))\n# define sk_IPAddressOrRange_set(st, i, val) SKM_sk_set(IPAddressOrRange, (st), (i), (val))\n# define sk_IPAddressOrRange_zero(st) SKM_sk_zero(IPAddressOrRange, (st))\n# define sk_IPAddressOrRange_push(st, val) SKM_sk_push(IPAddressOrRange, (st), (val))\n# define sk_IPAddressOrRange_unshift(st, val) SKM_sk_unshift(IPAddressOrRange, (st), (val))\n# define sk_IPAddressOrRange_find(st, val) SKM_sk_find(IPAddressOrRange, (st), (val))\n# define sk_IPAddressOrRange_find_ex(st, val) SKM_sk_find_ex(IPAddressOrRange, (st), (val))\n# define sk_IPAddressOrRange_delete(st, i) SKM_sk_delete(IPAddressOrRange, (st), (i))\n# define sk_IPAddressOrRange_delete_ptr(st, ptr) SKM_sk_delete_ptr(IPAddressOrRange, (st), (ptr))\n# define sk_IPAddressOrRange_insert(st, val, i) SKM_sk_insert(IPAddressOrRange, (st), (val), (i))\n# define sk_IPAddressOrRange_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(IPAddressOrRange, (st), (cmp))\n# define sk_IPAddressOrRange_dup(st) SKM_sk_dup(IPAddressOrRange, st)\n# define sk_IPAddressOrRange_pop_free(st, free_func) SKM_sk_pop_free(IPAddressOrRange, (st), (free_func))\n# define sk_IPAddressOrRange_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(IPAddressOrRange, (st), (copy_func), (free_func))\n# define sk_IPAddressOrRange_shift(st) SKM_sk_shift(IPAddressOrRange, (st))\n# define sk_IPAddressOrRange_pop(st) SKM_sk_pop(IPAddressOrRange, (st))\n# define sk_IPAddressOrRange_sort(st) SKM_sk_sort(IPAddressOrRange, (st))\n# define sk_IPAddressOrRange_is_sorted(st) SKM_sk_is_sorted(IPAddressOrRange, (st))\n# define sk_KRB5_APREQBODY_new(cmp) SKM_sk_new(KRB5_APREQBODY, (cmp))\n# define sk_KRB5_APREQBODY_new_null() SKM_sk_new_null(KRB5_APREQBODY)\n# define sk_KRB5_APREQBODY_free(st) SKM_sk_free(KRB5_APREQBODY, (st))\n# define sk_KRB5_APREQBODY_num(st) SKM_sk_num(KRB5_APREQBODY, (st))\n# define sk_KRB5_APREQBODY_value(st, i) SKM_sk_value(KRB5_APREQBODY, (st), (i))\n# define sk_KRB5_APREQBODY_set(st, i, val) SKM_sk_set(KRB5_APREQBODY, (st), (i), (val))\n# define sk_KRB5_APREQBODY_zero(st) SKM_sk_zero(KRB5_APREQBODY, (st))\n# define sk_KRB5_APREQBODY_push(st, val) SKM_sk_push(KRB5_APREQBODY, (st), (val))\n# define sk_KRB5_APREQBODY_unshift(st, val) SKM_sk_unshift(KRB5_APREQBODY, (st), (val))\n# define sk_KRB5_APREQBODY_find(st, val) SKM_sk_find(KRB5_APREQBODY, (st), (val))\n# define sk_KRB5_APREQBODY_find_ex(st, val) SKM_sk_find_ex(KRB5_APREQBODY, (st), (val))\n# define sk_KRB5_APREQBODY_delete(st, i) SKM_sk_delete(KRB5_APREQBODY, (st), (i))\n# define sk_KRB5_APREQBODY_delete_ptr(st, ptr) SKM_sk_delete_ptr(KRB5_APREQBODY, (st), (ptr))\n# define sk_KRB5_APREQBODY_insert(st, val, i) SKM_sk_insert(KRB5_APREQBODY, (st), (val), (i))\n# define sk_KRB5_APREQBODY_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(KRB5_APREQBODY, (st), (cmp))\n# define sk_KRB5_APREQBODY_dup(st) SKM_sk_dup(KRB5_APREQBODY, st)\n# define sk_KRB5_APREQBODY_pop_free(st, free_func) SKM_sk_pop_free(KRB5_APREQBODY, (st), (free_func))\n# define sk_KRB5_APREQBODY_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(KRB5_APREQBODY, (st), (copy_func), (free_func))\n# define sk_KRB5_APREQBODY_shift(st) SKM_sk_shift(KRB5_APREQBODY, (st))\n# define sk_KRB5_APREQBODY_pop(st) SKM_sk_pop(KRB5_APREQBODY, (st))\n# define sk_KRB5_APREQBODY_sort(st) SKM_sk_sort(KRB5_APREQBODY, (st))\n# define sk_KRB5_APREQBODY_is_sorted(st) SKM_sk_is_sorted(KRB5_APREQBODY, (st))\n# define sk_KRB5_AUTHDATA_new(cmp) SKM_sk_new(KRB5_AUTHDATA, (cmp))\n# define sk_KRB5_AUTHDATA_new_null() SKM_sk_new_null(KRB5_AUTHDATA)\n# define sk_KRB5_AUTHDATA_free(st) SKM_sk_free(KRB5_AUTHDATA, (st))\n# define sk_KRB5_AUTHDATA_num(st) SKM_sk_num(KRB5_AUTHDATA, (st))\n# define sk_KRB5_AUTHDATA_value(st, i) SKM_sk_value(KRB5_AUTHDATA, (st), (i))\n# define sk_KRB5_AUTHDATA_set(st, i, val) SKM_sk_set(KRB5_AUTHDATA, (st), (i), (val))\n# define sk_KRB5_AUTHDATA_zero(st) SKM_sk_zero(KRB5_AUTHDATA, (st))\n# define sk_KRB5_AUTHDATA_push(st, val) SKM_sk_push(KRB5_AUTHDATA, (st), (val))\n# define sk_KRB5_AUTHDATA_unshift(st, val) SKM_sk_unshift(KRB5_AUTHDATA, (st), (val))\n# define sk_KRB5_AUTHDATA_find(st, val) SKM_sk_find(KRB5_AUTHDATA, (st), (val))\n# define sk_KRB5_AUTHDATA_find_ex(st, val) SKM_sk_find_ex(KRB5_AUTHDATA, (st), (val))\n# define sk_KRB5_AUTHDATA_delete(st, i) SKM_sk_delete(KRB5_AUTHDATA, (st), (i))\n# define sk_KRB5_AUTHDATA_delete_ptr(st, ptr) SKM_sk_delete_ptr(KRB5_AUTHDATA, (st), (ptr))\n# define sk_KRB5_AUTHDATA_insert(st, val, i) SKM_sk_insert(KRB5_AUTHDATA, (st), (val), (i))\n# define sk_KRB5_AUTHDATA_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(KRB5_AUTHDATA, (st), (cmp))\n# define sk_KRB5_AUTHDATA_dup(st) SKM_sk_dup(KRB5_AUTHDATA, st)\n# define sk_KRB5_AUTHDATA_pop_free(st, free_func) SKM_sk_pop_free(KRB5_AUTHDATA, (st), (free_func))\n# define sk_KRB5_AUTHDATA_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(KRB5_AUTHDATA, (st), (copy_func), (free_func))\n# define sk_KRB5_AUTHDATA_shift(st) SKM_sk_shift(KRB5_AUTHDATA, (st))\n# define sk_KRB5_AUTHDATA_pop(st) SKM_sk_pop(KRB5_AUTHDATA, (st))\n# define sk_KRB5_AUTHDATA_sort(st) SKM_sk_sort(KRB5_AUTHDATA, (st))\n# define sk_KRB5_AUTHDATA_is_sorted(st) SKM_sk_is_sorted(KRB5_AUTHDATA, (st))\n# define sk_KRB5_AUTHENTBODY_new(cmp) SKM_sk_new(KRB5_AUTHENTBODY, (cmp))\n# define sk_KRB5_AUTHENTBODY_new_null() SKM_sk_new_null(KRB5_AUTHENTBODY)\n# define sk_KRB5_AUTHENTBODY_free(st) SKM_sk_free(KRB5_AUTHENTBODY, (st))\n# define sk_KRB5_AUTHENTBODY_num(st) SKM_sk_num(KRB5_AUTHENTBODY, (st))\n# define sk_KRB5_AUTHENTBODY_value(st, i) SKM_sk_value(KRB5_AUTHENTBODY, (st), (i))\n# define sk_KRB5_AUTHENTBODY_set(st, i, val) SKM_sk_set(KRB5_AUTHENTBODY, (st), (i), (val))\n# define sk_KRB5_AUTHENTBODY_zero(st) SKM_sk_zero(KRB5_AUTHENTBODY, (st))\n# define sk_KRB5_AUTHENTBODY_push(st, val) SKM_sk_push(KRB5_AUTHENTBODY, (st), (val))\n# define sk_KRB5_AUTHENTBODY_unshift(st, val) SKM_sk_unshift(KRB5_AUTHENTBODY, (st), (val))\n# define sk_KRB5_AUTHENTBODY_find(st, val) SKM_sk_find(KRB5_AUTHENTBODY, (st), (val))\n# define sk_KRB5_AUTHENTBODY_find_ex(st, val) SKM_sk_find_ex(KRB5_AUTHENTBODY, (st), (val))\n# define sk_KRB5_AUTHENTBODY_delete(st, i) SKM_sk_delete(KRB5_AUTHENTBODY, (st), (i))\n# define sk_KRB5_AUTHENTBODY_delete_ptr(st, ptr) SKM_sk_delete_ptr(KRB5_AUTHENTBODY, (st), (ptr))\n# define sk_KRB5_AUTHENTBODY_insert(st, val, i) SKM_sk_insert(KRB5_AUTHENTBODY, (st), (val), (i))\n# define sk_KRB5_AUTHENTBODY_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(KRB5_AUTHENTBODY, (st), (cmp))\n# define sk_KRB5_AUTHENTBODY_dup(st) SKM_sk_dup(KRB5_AUTHENTBODY, st)\n# define sk_KRB5_AUTHENTBODY_pop_free(st, free_func) SKM_sk_pop_free(KRB5_AUTHENTBODY, (st), (free_func))\n# define sk_KRB5_AUTHENTBODY_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(KRB5_AUTHENTBODY, (st), (copy_func), (free_func))\n# define sk_KRB5_AUTHENTBODY_shift(st) SKM_sk_shift(KRB5_AUTHENTBODY, (st))\n# define sk_KRB5_AUTHENTBODY_pop(st) SKM_sk_pop(KRB5_AUTHENTBODY, (st))\n# define sk_KRB5_AUTHENTBODY_sort(st) SKM_sk_sort(KRB5_AUTHENTBODY, (st))\n# define sk_KRB5_AUTHENTBODY_is_sorted(st) SKM_sk_is_sorted(KRB5_AUTHENTBODY, (st))\n# define sk_KRB5_CHECKSUM_new(cmp) SKM_sk_new(KRB5_CHECKSUM, (cmp))\n# define sk_KRB5_CHECKSUM_new_null() SKM_sk_new_null(KRB5_CHECKSUM)\n# define sk_KRB5_CHECKSUM_free(st) SKM_sk_free(KRB5_CHECKSUM, (st))\n# define sk_KRB5_CHECKSUM_num(st) SKM_sk_num(KRB5_CHECKSUM, (st))\n# define sk_KRB5_CHECKSUM_value(st, i) SKM_sk_value(KRB5_CHECKSUM, (st), (i))\n# define sk_KRB5_CHECKSUM_set(st, i, val) SKM_sk_set(KRB5_CHECKSUM, (st), (i), (val))\n# define sk_KRB5_CHECKSUM_zero(st) SKM_sk_zero(KRB5_CHECKSUM, (st))\n# define sk_KRB5_CHECKSUM_push(st, val) SKM_sk_push(KRB5_CHECKSUM, (st), (val))\n# define sk_KRB5_CHECKSUM_unshift(st, val) SKM_sk_unshift(KRB5_CHECKSUM, (st), (val))\n# define sk_KRB5_CHECKSUM_find(st, val) SKM_sk_find(KRB5_CHECKSUM, (st), (val))\n# define sk_KRB5_CHECKSUM_find_ex(st, val) SKM_sk_find_ex(KRB5_CHECKSUM, (st), (val))\n# define sk_KRB5_CHECKSUM_delete(st, i) SKM_sk_delete(KRB5_CHECKSUM, (st), (i))\n# define sk_KRB5_CHECKSUM_delete_ptr(st, ptr) SKM_sk_delete_ptr(KRB5_CHECKSUM, (st), (ptr))\n# define sk_KRB5_CHECKSUM_insert(st, val, i) SKM_sk_insert(KRB5_CHECKSUM, (st), (val), (i))\n# define sk_KRB5_CHECKSUM_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(KRB5_CHECKSUM, (st), (cmp))\n# define sk_KRB5_CHECKSUM_dup(st) SKM_sk_dup(KRB5_CHECKSUM, st)\n# define sk_KRB5_CHECKSUM_pop_free(st, free_func) SKM_sk_pop_free(KRB5_CHECKSUM, (st), (free_func))\n# define sk_KRB5_CHECKSUM_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(KRB5_CHECKSUM, (st), (copy_func), (free_func))\n# define sk_KRB5_CHECKSUM_shift(st) SKM_sk_shift(KRB5_CHECKSUM, (st))\n# define sk_KRB5_CHECKSUM_pop(st) SKM_sk_pop(KRB5_CHECKSUM, (st))\n# define sk_KRB5_CHECKSUM_sort(st) SKM_sk_sort(KRB5_CHECKSUM, (st))\n# define sk_KRB5_CHECKSUM_is_sorted(st) SKM_sk_is_sorted(KRB5_CHECKSUM, (st))\n# define sk_KRB5_ENCDATA_new(cmp) SKM_sk_new(KRB5_ENCDATA, (cmp))\n# define sk_KRB5_ENCDATA_new_null() SKM_sk_new_null(KRB5_ENCDATA)\n# define sk_KRB5_ENCDATA_free(st) SKM_sk_free(KRB5_ENCDATA, (st))\n# define sk_KRB5_ENCDATA_num(st) SKM_sk_num(KRB5_ENCDATA, (st))\n# define sk_KRB5_ENCDATA_value(st, i) SKM_sk_value(KRB5_ENCDATA, (st), (i))\n# define sk_KRB5_ENCDATA_set(st, i, val) SKM_sk_set(KRB5_ENCDATA, (st), (i), (val))\n# define sk_KRB5_ENCDATA_zero(st) SKM_sk_zero(KRB5_ENCDATA, (st))\n# define sk_KRB5_ENCDATA_push(st, val) SKM_sk_push(KRB5_ENCDATA, (st), (val))\n# define sk_KRB5_ENCDATA_unshift(st, val) SKM_sk_unshift(KRB5_ENCDATA, (st), (val))\n# define sk_KRB5_ENCDATA_find(st, val) SKM_sk_find(KRB5_ENCDATA, (st), (val))\n# define sk_KRB5_ENCDATA_find_ex(st, val) SKM_sk_find_ex(KRB5_ENCDATA, (st), (val))\n# define sk_KRB5_ENCDATA_delete(st, i) SKM_sk_delete(KRB5_ENCDATA, (st), (i))\n# define sk_KRB5_ENCDATA_delete_ptr(st, ptr) SKM_sk_delete_ptr(KRB5_ENCDATA, (st), (ptr))\n# define sk_KRB5_ENCDATA_insert(st, val, i) SKM_sk_insert(KRB5_ENCDATA, (st), (val), (i))\n# define sk_KRB5_ENCDATA_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(KRB5_ENCDATA, (st), (cmp))\n# define sk_KRB5_ENCDATA_dup(st) SKM_sk_dup(KRB5_ENCDATA, st)\n# define sk_KRB5_ENCDATA_pop_free(st, free_func) SKM_sk_pop_free(KRB5_ENCDATA, (st), (free_func))\n# define sk_KRB5_ENCDATA_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(KRB5_ENCDATA, (st), (copy_func), (free_func))\n# define sk_KRB5_ENCDATA_shift(st) SKM_sk_shift(KRB5_ENCDATA, (st))\n# define sk_KRB5_ENCDATA_pop(st) SKM_sk_pop(KRB5_ENCDATA, (st))\n# define sk_KRB5_ENCDATA_sort(st) SKM_sk_sort(KRB5_ENCDATA, (st))\n# define sk_KRB5_ENCDATA_is_sorted(st) SKM_sk_is_sorted(KRB5_ENCDATA, (st))\n# define sk_KRB5_ENCKEY_new(cmp) SKM_sk_new(KRB5_ENCKEY, (cmp))\n# define sk_KRB5_ENCKEY_new_null() SKM_sk_new_null(KRB5_ENCKEY)\n# define sk_KRB5_ENCKEY_free(st) SKM_sk_free(KRB5_ENCKEY, (st))\n# define sk_KRB5_ENCKEY_num(st) SKM_sk_num(KRB5_ENCKEY, (st))\n# define sk_KRB5_ENCKEY_value(st, i) SKM_sk_value(KRB5_ENCKEY, (st), (i))\n# define sk_KRB5_ENCKEY_set(st, i, val) SKM_sk_set(KRB5_ENCKEY, (st), (i), (val))\n# define sk_KRB5_ENCKEY_zero(st) SKM_sk_zero(KRB5_ENCKEY, (st))\n# define sk_KRB5_ENCKEY_push(st, val) SKM_sk_push(KRB5_ENCKEY, (st), (val))\n# define sk_KRB5_ENCKEY_unshift(st, val) SKM_sk_unshift(KRB5_ENCKEY, (st), (val))\n# define sk_KRB5_ENCKEY_find(st, val) SKM_sk_find(KRB5_ENCKEY, (st), (val))\n# define sk_KRB5_ENCKEY_find_ex(st, val) SKM_sk_find_ex(KRB5_ENCKEY, (st), (val))\n# define sk_KRB5_ENCKEY_delete(st, i) SKM_sk_delete(KRB5_ENCKEY, (st), (i))\n# define sk_KRB5_ENCKEY_delete_ptr(st, ptr) SKM_sk_delete_ptr(KRB5_ENCKEY, (st), (ptr))\n# define sk_KRB5_ENCKEY_insert(st, val, i) SKM_sk_insert(KRB5_ENCKEY, (st), (val), (i))\n# define sk_KRB5_ENCKEY_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(KRB5_ENCKEY, (st), (cmp))\n# define sk_KRB5_ENCKEY_dup(st) SKM_sk_dup(KRB5_ENCKEY, st)\n# define sk_KRB5_ENCKEY_pop_free(st, free_func) SKM_sk_pop_free(KRB5_ENCKEY, (st), (free_func))\n# define sk_KRB5_ENCKEY_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(KRB5_ENCKEY, (st), (copy_func), (free_func))\n# define sk_KRB5_ENCKEY_shift(st) SKM_sk_shift(KRB5_ENCKEY, (st))\n# define sk_KRB5_ENCKEY_pop(st) SKM_sk_pop(KRB5_ENCKEY, (st))\n# define sk_KRB5_ENCKEY_sort(st) SKM_sk_sort(KRB5_ENCKEY, (st))\n# define sk_KRB5_ENCKEY_is_sorted(st) SKM_sk_is_sorted(KRB5_ENCKEY, (st))\n# define sk_KRB5_PRINCNAME_new(cmp) SKM_sk_new(KRB5_PRINCNAME, (cmp))\n# define sk_KRB5_PRINCNAME_new_null() SKM_sk_new_null(KRB5_PRINCNAME)\n# define sk_KRB5_PRINCNAME_free(st) SKM_sk_free(KRB5_PRINCNAME, (st))\n# define sk_KRB5_PRINCNAME_num(st) SKM_sk_num(KRB5_PRINCNAME, (st))\n# define sk_KRB5_PRINCNAME_value(st, i) SKM_sk_value(KRB5_PRINCNAME, (st), (i))\n# define sk_KRB5_PRINCNAME_set(st, i, val) SKM_sk_set(KRB5_PRINCNAME, (st), (i), (val))\n# define sk_KRB5_PRINCNAME_zero(st) SKM_sk_zero(KRB5_PRINCNAME, (st))\n# define sk_KRB5_PRINCNAME_push(st, val) SKM_sk_push(KRB5_PRINCNAME, (st), (val))\n# define sk_KRB5_PRINCNAME_unshift(st, val) SKM_sk_unshift(KRB5_PRINCNAME, (st), (val))\n# define sk_KRB5_PRINCNAME_find(st, val) SKM_sk_find(KRB5_PRINCNAME, (st), (val))\n# define sk_KRB5_PRINCNAME_find_ex(st, val) SKM_sk_find_ex(KRB5_PRINCNAME, (st), (val))\n# define sk_KRB5_PRINCNAME_delete(st, i) SKM_sk_delete(KRB5_PRINCNAME, (st), (i))\n# define sk_KRB5_PRINCNAME_delete_ptr(st, ptr) SKM_sk_delete_ptr(KRB5_PRINCNAME, (st), (ptr))\n# define sk_KRB5_PRINCNAME_insert(st, val, i) SKM_sk_insert(KRB5_PRINCNAME, (st), (val), (i))\n# define sk_KRB5_PRINCNAME_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(KRB5_PRINCNAME, (st), (cmp))\n# define sk_KRB5_PRINCNAME_dup(st) SKM_sk_dup(KRB5_PRINCNAME, st)\n# define sk_KRB5_PRINCNAME_pop_free(st, free_func) SKM_sk_pop_free(KRB5_PRINCNAME, (st), (free_func))\n# define sk_KRB5_PRINCNAME_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(KRB5_PRINCNAME, (st), (copy_func), (free_func))\n# define sk_KRB5_PRINCNAME_shift(st) SKM_sk_shift(KRB5_PRINCNAME, (st))\n# define sk_KRB5_PRINCNAME_pop(st) SKM_sk_pop(KRB5_PRINCNAME, (st))\n# define sk_KRB5_PRINCNAME_sort(st) SKM_sk_sort(KRB5_PRINCNAME, (st))\n# define sk_KRB5_PRINCNAME_is_sorted(st) SKM_sk_is_sorted(KRB5_PRINCNAME, (st))\n# define sk_KRB5_TKTBODY_new(cmp) SKM_sk_new(KRB5_TKTBODY, (cmp))\n# define sk_KRB5_TKTBODY_new_null() SKM_sk_new_null(KRB5_TKTBODY)\n# define sk_KRB5_TKTBODY_free(st) SKM_sk_free(KRB5_TKTBODY, (st))\n# define sk_KRB5_TKTBODY_num(st) SKM_sk_num(KRB5_TKTBODY, (st))\n# define sk_KRB5_TKTBODY_value(st, i) SKM_sk_value(KRB5_TKTBODY, (st), (i))\n# define sk_KRB5_TKTBODY_set(st, i, val) SKM_sk_set(KRB5_TKTBODY, (st), (i), (val))\n# define sk_KRB5_TKTBODY_zero(st) SKM_sk_zero(KRB5_TKTBODY, (st))\n# define sk_KRB5_TKTBODY_push(st, val) SKM_sk_push(KRB5_TKTBODY, (st), (val))\n# define sk_KRB5_TKTBODY_unshift(st, val) SKM_sk_unshift(KRB5_TKTBODY, (st), (val))\n# define sk_KRB5_TKTBODY_find(st, val) SKM_sk_find(KRB5_TKTBODY, (st), (val))\n# define sk_KRB5_TKTBODY_find_ex(st, val) SKM_sk_find_ex(KRB5_TKTBODY, (st), (val))\n# define sk_KRB5_TKTBODY_delete(st, i) SKM_sk_delete(KRB5_TKTBODY, (st), (i))\n# define sk_KRB5_TKTBODY_delete_ptr(st, ptr) SKM_sk_delete_ptr(KRB5_TKTBODY, (st), (ptr))\n# define sk_KRB5_TKTBODY_insert(st, val, i) SKM_sk_insert(KRB5_TKTBODY, (st), (val), (i))\n# define sk_KRB5_TKTBODY_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(KRB5_TKTBODY, (st), (cmp))\n# define sk_KRB5_TKTBODY_dup(st) SKM_sk_dup(KRB5_TKTBODY, st)\n# define sk_KRB5_TKTBODY_pop_free(st, free_func) SKM_sk_pop_free(KRB5_TKTBODY, (st), (free_func))\n# define sk_KRB5_TKTBODY_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(KRB5_TKTBODY, (st), (copy_func), (free_func))\n# define sk_KRB5_TKTBODY_shift(st) SKM_sk_shift(KRB5_TKTBODY, (st))\n# define sk_KRB5_TKTBODY_pop(st) SKM_sk_pop(KRB5_TKTBODY, (st))\n# define sk_KRB5_TKTBODY_sort(st) SKM_sk_sort(KRB5_TKTBODY, (st))\n# define sk_KRB5_TKTBODY_is_sorted(st) SKM_sk_is_sorted(KRB5_TKTBODY, (st))\n# define sk_MEM_OBJECT_DATA_new(cmp) SKM_sk_new(MEM_OBJECT_DATA, (cmp))\n# define sk_MEM_OBJECT_DATA_new_null() SKM_sk_new_null(MEM_OBJECT_DATA)\n# define sk_MEM_OBJECT_DATA_free(st) SKM_sk_free(MEM_OBJECT_DATA, (st))\n# define sk_MEM_OBJECT_DATA_num(st) SKM_sk_num(MEM_OBJECT_DATA, (st))\n# define sk_MEM_OBJECT_DATA_value(st, i) SKM_sk_value(MEM_OBJECT_DATA, (st), (i))\n# define sk_MEM_OBJECT_DATA_set(st, i, val) SKM_sk_set(MEM_OBJECT_DATA, (st), (i), (val))\n# define sk_MEM_OBJECT_DATA_zero(st) SKM_sk_zero(MEM_OBJECT_DATA, (st))\n# define sk_MEM_OBJECT_DATA_push(st, val) SKM_sk_push(MEM_OBJECT_DATA, (st), (val))\n# define sk_MEM_OBJECT_DATA_unshift(st, val) SKM_sk_unshift(MEM_OBJECT_DATA, (st), (val))\n# define sk_MEM_OBJECT_DATA_find(st, val) SKM_sk_find(MEM_OBJECT_DATA, (st), (val))\n# define sk_MEM_OBJECT_DATA_find_ex(st, val) SKM_sk_find_ex(MEM_OBJECT_DATA, (st), (val))\n# define sk_MEM_OBJECT_DATA_delete(st, i) SKM_sk_delete(MEM_OBJECT_DATA, (st), (i))\n# define sk_MEM_OBJECT_DATA_delete_ptr(st, ptr) SKM_sk_delete_ptr(MEM_OBJECT_DATA, (st), (ptr))\n# define sk_MEM_OBJECT_DATA_insert(st, val, i) SKM_sk_insert(MEM_OBJECT_DATA, (st), (val), (i))\n# define sk_MEM_OBJECT_DATA_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(MEM_OBJECT_DATA, (st), (cmp))\n# define sk_MEM_OBJECT_DATA_dup(st) SKM_sk_dup(MEM_OBJECT_DATA, st)\n# define sk_MEM_OBJECT_DATA_pop_free(st, free_func) SKM_sk_pop_free(MEM_OBJECT_DATA, (st), (free_func))\n# define sk_MEM_OBJECT_DATA_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(MEM_OBJECT_DATA, (st), (copy_func), (free_func))\n# define sk_MEM_OBJECT_DATA_shift(st) SKM_sk_shift(MEM_OBJECT_DATA, (st))\n# define sk_MEM_OBJECT_DATA_pop(st) SKM_sk_pop(MEM_OBJECT_DATA, (st))\n# define sk_MEM_OBJECT_DATA_sort(st) SKM_sk_sort(MEM_OBJECT_DATA, (st))\n# define sk_MEM_OBJECT_DATA_is_sorted(st) SKM_sk_is_sorted(MEM_OBJECT_DATA, (st))\n# define sk_MIME_HEADER_new(cmp) SKM_sk_new(MIME_HEADER, (cmp))\n# define sk_MIME_HEADER_new_null() SKM_sk_new_null(MIME_HEADER)\n# define sk_MIME_HEADER_free(st) SKM_sk_free(MIME_HEADER, (st))\n# define sk_MIME_HEADER_num(st) SKM_sk_num(MIME_HEADER, (st))\n# define sk_MIME_HEADER_value(st, i) SKM_sk_value(MIME_HEADER, (st), (i))\n# define sk_MIME_HEADER_set(st, i, val) SKM_sk_set(MIME_HEADER, (st), (i), (val))\n# define sk_MIME_HEADER_zero(st) SKM_sk_zero(MIME_HEADER, (st))\n# define sk_MIME_HEADER_push(st, val) SKM_sk_push(MIME_HEADER, (st), (val))\n# define sk_MIME_HEADER_unshift(st, val) SKM_sk_unshift(MIME_HEADER, (st), (val))\n# define sk_MIME_HEADER_find(st, val) SKM_sk_find(MIME_HEADER, (st), (val))\n# define sk_MIME_HEADER_find_ex(st, val) SKM_sk_find_ex(MIME_HEADER, (st), (val))\n# define sk_MIME_HEADER_delete(st, i) SKM_sk_delete(MIME_HEADER, (st), (i))\n# define sk_MIME_HEADER_delete_ptr(st, ptr) SKM_sk_delete_ptr(MIME_HEADER, (st), (ptr))\n# define sk_MIME_HEADER_insert(st, val, i) SKM_sk_insert(MIME_HEADER, (st), (val), (i))\n# define sk_MIME_HEADER_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(MIME_HEADER, (st), (cmp))\n# define sk_MIME_HEADER_dup(st) SKM_sk_dup(MIME_HEADER, st)\n# define sk_MIME_HEADER_pop_free(st, free_func) SKM_sk_pop_free(MIME_HEADER, (st), (free_func))\n# define sk_MIME_HEADER_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(MIME_HEADER, (st), (copy_func), (free_func))\n# define sk_MIME_HEADER_shift(st) SKM_sk_shift(MIME_HEADER, (st))\n# define sk_MIME_HEADER_pop(st) SKM_sk_pop(MIME_HEADER, (st))\n# define sk_MIME_HEADER_sort(st) SKM_sk_sort(MIME_HEADER, (st))\n# define sk_MIME_HEADER_is_sorted(st) SKM_sk_is_sorted(MIME_HEADER, (st))\n# define sk_MIME_PARAM_new(cmp) SKM_sk_new(MIME_PARAM, (cmp))\n# define sk_MIME_PARAM_new_null() SKM_sk_new_null(MIME_PARAM)\n# define sk_MIME_PARAM_free(st) SKM_sk_free(MIME_PARAM, (st))\n# define sk_MIME_PARAM_num(st) SKM_sk_num(MIME_PARAM, (st))\n# define sk_MIME_PARAM_value(st, i) SKM_sk_value(MIME_PARAM, (st), (i))\n# define sk_MIME_PARAM_set(st, i, val) SKM_sk_set(MIME_PARAM, (st), (i), (val))\n# define sk_MIME_PARAM_zero(st) SKM_sk_zero(MIME_PARAM, (st))\n# define sk_MIME_PARAM_push(st, val) SKM_sk_push(MIME_PARAM, (st), (val))\n# define sk_MIME_PARAM_unshift(st, val) SKM_sk_unshift(MIME_PARAM, (st), (val))\n# define sk_MIME_PARAM_find(st, val) SKM_sk_find(MIME_PARAM, (st), (val))\n# define sk_MIME_PARAM_find_ex(st, val) SKM_sk_find_ex(MIME_PARAM, (st), (val))\n# define sk_MIME_PARAM_delete(st, i) SKM_sk_delete(MIME_PARAM, (st), (i))\n# define sk_MIME_PARAM_delete_ptr(st, ptr) SKM_sk_delete_ptr(MIME_PARAM, (st), (ptr))\n# define sk_MIME_PARAM_insert(st, val, i) SKM_sk_insert(MIME_PARAM, (st), (val), (i))\n# define sk_MIME_PARAM_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(MIME_PARAM, (st), (cmp))\n# define sk_MIME_PARAM_dup(st) SKM_sk_dup(MIME_PARAM, st)\n# define sk_MIME_PARAM_pop_free(st, free_func) SKM_sk_pop_free(MIME_PARAM, (st), (free_func))\n# define sk_MIME_PARAM_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(MIME_PARAM, (st), (copy_func), (free_func))\n# define sk_MIME_PARAM_shift(st) SKM_sk_shift(MIME_PARAM, (st))\n# define sk_MIME_PARAM_pop(st) SKM_sk_pop(MIME_PARAM, (st))\n# define sk_MIME_PARAM_sort(st) SKM_sk_sort(MIME_PARAM, (st))\n# define sk_MIME_PARAM_is_sorted(st) SKM_sk_is_sorted(MIME_PARAM, (st))\n# define sk_NAME_FUNCS_new(cmp) SKM_sk_new(NAME_FUNCS, (cmp))\n# define sk_NAME_FUNCS_new_null() SKM_sk_new_null(NAME_FUNCS)\n# define sk_NAME_FUNCS_free(st) SKM_sk_free(NAME_FUNCS, (st))\n# define sk_NAME_FUNCS_num(st) SKM_sk_num(NAME_FUNCS, (st))\n# define sk_NAME_FUNCS_value(st, i) SKM_sk_value(NAME_FUNCS, (st), (i))\n# define sk_NAME_FUNCS_set(st, i, val) SKM_sk_set(NAME_FUNCS, (st), (i), (val))\n# define sk_NAME_FUNCS_zero(st) SKM_sk_zero(NAME_FUNCS, (st))\n# define sk_NAME_FUNCS_push(st, val) SKM_sk_push(NAME_FUNCS, (st), (val))\n# define sk_NAME_FUNCS_unshift(st, val) SKM_sk_unshift(NAME_FUNCS, (st), (val))\n# define sk_NAME_FUNCS_find(st, val) SKM_sk_find(NAME_FUNCS, (st), (val))\n# define sk_NAME_FUNCS_find_ex(st, val) SKM_sk_find_ex(NAME_FUNCS, (st), (val))\n# define sk_NAME_FUNCS_delete(st, i) SKM_sk_delete(NAME_FUNCS, (st), (i))\n# define sk_NAME_FUNCS_delete_ptr(st, ptr) SKM_sk_delete_ptr(NAME_FUNCS, (st), (ptr))\n# define sk_NAME_FUNCS_insert(st, val, i) SKM_sk_insert(NAME_FUNCS, (st), (val), (i))\n# define sk_NAME_FUNCS_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(NAME_FUNCS, (st), (cmp))\n# define sk_NAME_FUNCS_dup(st) SKM_sk_dup(NAME_FUNCS, st)\n# define sk_NAME_FUNCS_pop_free(st, free_func) SKM_sk_pop_free(NAME_FUNCS, (st), (free_func))\n# define sk_NAME_FUNCS_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(NAME_FUNCS, (st), (copy_func), (free_func))\n# define sk_NAME_FUNCS_shift(st) SKM_sk_shift(NAME_FUNCS, (st))\n# define sk_NAME_FUNCS_pop(st) SKM_sk_pop(NAME_FUNCS, (st))\n# define sk_NAME_FUNCS_sort(st) SKM_sk_sort(NAME_FUNCS, (st))\n# define sk_NAME_FUNCS_is_sorted(st) SKM_sk_is_sorted(NAME_FUNCS, (st))\n# define sk_OCSP_CERTID_new(cmp) SKM_sk_new(OCSP_CERTID, (cmp))\n# define sk_OCSP_CERTID_new_null() SKM_sk_new_null(OCSP_CERTID)\n# define sk_OCSP_CERTID_free(st) SKM_sk_free(OCSP_CERTID, (st))\n# define sk_OCSP_CERTID_num(st) SKM_sk_num(OCSP_CERTID, (st))\n# define sk_OCSP_CERTID_value(st, i) SKM_sk_value(OCSP_CERTID, (st), (i))\n# define sk_OCSP_CERTID_set(st, i, val) SKM_sk_set(OCSP_CERTID, (st), (i), (val))\n# define sk_OCSP_CERTID_zero(st) SKM_sk_zero(OCSP_CERTID, (st))\n# define sk_OCSP_CERTID_push(st, val) SKM_sk_push(OCSP_CERTID, (st), (val))\n# define sk_OCSP_CERTID_unshift(st, val) SKM_sk_unshift(OCSP_CERTID, (st), (val))\n# define sk_OCSP_CERTID_find(st, val) SKM_sk_find(OCSP_CERTID, (st), (val))\n# define sk_OCSP_CERTID_find_ex(st, val) SKM_sk_find_ex(OCSP_CERTID, (st), (val))\n# define sk_OCSP_CERTID_delete(st, i) SKM_sk_delete(OCSP_CERTID, (st), (i))\n# define sk_OCSP_CERTID_delete_ptr(st, ptr) SKM_sk_delete_ptr(OCSP_CERTID, (st), (ptr))\n# define sk_OCSP_CERTID_insert(st, val, i) SKM_sk_insert(OCSP_CERTID, (st), (val), (i))\n# define sk_OCSP_CERTID_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(OCSP_CERTID, (st), (cmp))\n# define sk_OCSP_CERTID_dup(st) SKM_sk_dup(OCSP_CERTID, st)\n# define sk_OCSP_CERTID_pop_free(st, free_func) SKM_sk_pop_free(OCSP_CERTID, (st), (free_func))\n# define sk_OCSP_CERTID_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(OCSP_CERTID, (st), (copy_func), (free_func))\n# define sk_OCSP_CERTID_shift(st) SKM_sk_shift(OCSP_CERTID, (st))\n# define sk_OCSP_CERTID_pop(st) SKM_sk_pop(OCSP_CERTID, (st))\n# define sk_OCSP_CERTID_sort(st) SKM_sk_sort(OCSP_CERTID, (st))\n# define sk_OCSP_CERTID_is_sorted(st) SKM_sk_is_sorted(OCSP_CERTID, (st))\n# define sk_OCSP_ONEREQ_new(cmp) SKM_sk_new(OCSP_ONEREQ, (cmp))\n# define sk_OCSP_ONEREQ_new_null() SKM_sk_new_null(OCSP_ONEREQ)\n# define sk_OCSP_ONEREQ_free(st) SKM_sk_free(OCSP_ONEREQ, (st))\n# define sk_OCSP_ONEREQ_num(st) SKM_sk_num(OCSP_ONEREQ, (st))\n# define sk_OCSP_ONEREQ_value(st, i) SKM_sk_value(OCSP_ONEREQ, (st), (i))\n# define sk_OCSP_ONEREQ_set(st, i, val) SKM_sk_set(OCSP_ONEREQ, (st), (i), (val))\n# define sk_OCSP_ONEREQ_zero(st) SKM_sk_zero(OCSP_ONEREQ, (st))\n# define sk_OCSP_ONEREQ_push(st, val) SKM_sk_push(OCSP_ONEREQ, (st), (val))\n# define sk_OCSP_ONEREQ_unshift(st, val) SKM_sk_unshift(OCSP_ONEREQ, (st), (val))\n# define sk_OCSP_ONEREQ_find(st, val) SKM_sk_find(OCSP_ONEREQ, (st), (val))\n# define sk_OCSP_ONEREQ_find_ex(st, val) SKM_sk_find_ex(OCSP_ONEREQ, (st), (val))\n# define sk_OCSP_ONEREQ_delete(st, i) SKM_sk_delete(OCSP_ONEREQ, (st), (i))\n# define sk_OCSP_ONEREQ_delete_ptr(st, ptr) SKM_sk_delete_ptr(OCSP_ONEREQ, (st), (ptr))\n# define sk_OCSP_ONEREQ_insert(st, val, i) SKM_sk_insert(OCSP_ONEREQ, (st), (val), (i))\n# define sk_OCSP_ONEREQ_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(OCSP_ONEREQ, (st), (cmp))\n# define sk_OCSP_ONEREQ_dup(st) SKM_sk_dup(OCSP_ONEREQ, st)\n# define sk_OCSP_ONEREQ_pop_free(st, free_func) SKM_sk_pop_free(OCSP_ONEREQ, (st), (free_func))\n# define sk_OCSP_ONEREQ_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(OCSP_ONEREQ, (st), (copy_func), (free_func))\n# define sk_OCSP_ONEREQ_shift(st) SKM_sk_shift(OCSP_ONEREQ, (st))\n# define sk_OCSP_ONEREQ_pop(st) SKM_sk_pop(OCSP_ONEREQ, (st))\n# define sk_OCSP_ONEREQ_sort(st) SKM_sk_sort(OCSP_ONEREQ, (st))\n# define sk_OCSP_ONEREQ_is_sorted(st) SKM_sk_is_sorted(OCSP_ONEREQ, (st))\n# define sk_OCSP_RESPID_new(cmp) SKM_sk_new(OCSP_RESPID, (cmp))\n# define sk_OCSP_RESPID_new_null() SKM_sk_new_null(OCSP_RESPID)\n# define sk_OCSP_RESPID_free(st) SKM_sk_free(OCSP_RESPID, (st))\n# define sk_OCSP_RESPID_num(st) SKM_sk_num(OCSP_RESPID, (st))\n# define sk_OCSP_RESPID_value(st, i) SKM_sk_value(OCSP_RESPID, (st), (i))\n# define sk_OCSP_RESPID_set(st, i, val) SKM_sk_set(OCSP_RESPID, (st), (i), (val))\n# define sk_OCSP_RESPID_zero(st) SKM_sk_zero(OCSP_RESPID, (st))\n# define sk_OCSP_RESPID_push(st, val) SKM_sk_push(OCSP_RESPID, (st), (val))\n# define sk_OCSP_RESPID_unshift(st, val) SKM_sk_unshift(OCSP_RESPID, (st), (val))\n# define sk_OCSP_RESPID_find(st, val) SKM_sk_find(OCSP_RESPID, (st), (val))\n# define sk_OCSP_RESPID_find_ex(st, val) SKM_sk_find_ex(OCSP_RESPID, (st), (val))\n# define sk_OCSP_RESPID_delete(st, i) SKM_sk_delete(OCSP_RESPID, (st), (i))\n# define sk_OCSP_RESPID_delete_ptr(st, ptr) SKM_sk_delete_ptr(OCSP_RESPID, (st), (ptr))\n# define sk_OCSP_RESPID_insert(st, val, i) SKM_sk_insert(OCSP_RESPID, (st), (val), (i))\n# define sk_OCSP_RESPID_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(OCSP_RESPID, (st), (cmp))\n# define sk_OCSP_RESPID_dup(st) SKM_sk_dup(OCSP_RESPID, st)\n# define sk_OCSP_RESPID_pop_free(st, free_func) SKM_sk_pop_free(OCSP_RESPID, (st), (free_func))\n# define sk_OCSP_RESPID_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(OCSP_RESPID, (st), (copy_func), (free_func))\n# define sk_OCSP_RESPID_shift(st) SKM_sk_shift(OCSP_RESPID, (st))\n# define sk_OCSP_RESPID_pop(st) SKM_sk_pop(OCSP_RESPID, (st))\n# define sk_OCSP_RESPID_sort(st) SKM_sk_sort(OCSP_RESPID, (st))\n# define sk_OCSP_RESPID_is_sorted(st) SKM_sk_is_sorted(OCSP_RESPID, (st))\n# define sk_OCSP_SINGLERESP_new(cmp) SKM_sk_new(OCSP_SINGLERESP, (cmp))\n# define sk_OCSP_SINGLERESP_new_null() SKM_sk_new_null(OCSP_SINGLERESP)\n# define sk_OCSP_SINGLERESP_free(st) SKM_sk_free(OCSP_SINGLERESP, (st))\n# define sk_OCSP_SINGLERESP_num(st) SKM_sk_num(OCSP_SINGLERESP, (st))\n# define sk_OCSP_SINGLERESP_value(st, i) SKM_sk_value(OCSP_SINGLERESP, (st), (i))\n# define sk_OCSP_SINGLERESP_set(st, i, val) SKM_sk_set(OCSP_SINGLERESP, (st), (i), (val))\n# define sk_OCSP_SINGLERESP_zero(st) SKM_sk_zero(OCSP_SINGLERESP, (st))\n# define sk_OCSP_SINGLERESP_push(st, val) SKM_sk_push(OCSP_SINGLERESP, (st), (val))\n# define sk_OCSP_SINGLERESP_unshift(st, val) SKM_sk_unshift(OCSP_SINGLERESP, (st), (val))\n# define sk_OCSP_SINGLERESP_find(st, val) SKM_sk_find(OCSP_SINGLERESP, (st), (val))\n# define sk_OCSP_SINGLERESP_find_ex(st, val) SKM_sk_find_ex(OCSP_SINGLERESP, (st), (val))\n# define sk_OCSP_SINGLERESP_delete(st, i) SKM_sk_delete(OCSP_SINGLERESP, (st), (i))\n# define sk_OCSP_SINGLERESP_delete_ptr(st, ptr) SKM_sk_delete_ptr(OCSP_SINGLERESP, (st), (ptr))\n# define sk_OCSP_SINGLERESP_insert(st, val, i) SKM_sk_insert(OCSP_SINGLERESP, (st), (val), (i))\n# define sk_OCSP_SINGLERESP_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(OCSP_SINGLERESP, (st), (cmp))\n# define sk_OCSP_SINGLERESP_dup(st) SKM_sk_dup(OCSP_SINGLERESP, st)\n# define sk_OCSP_SINGLERESP_pop_free(st, free_func) SKM_sk_pop_free(OCSP_SINGLERESP, (st), (free_func))\n# define sk_OCSP_SINGLERESP_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(OCSP_SINGLERESP, (st), (copy_func), (free_func))\n# define sk_OCSP_SINGLERESP_shift(st) SKM_sk_shift(OCSP_SINGLERESP, (st))\n# define sk_OCSP_SINGLERESP_pop(st) SKM_sk_pop(OCSP_SINGLERESP, (st))\n# define sk_OCSP_SINGLERESP_sort(st) SKM_sk_sort(OCSP_SINGLERESP, (st))\n# define sk_OCSP_SINGLERESP_is_sorted(st) SKM_sk_is_sorted(OCSP_SINGLERESP, (st))\n# define sk_PKCS12_SAFEBAG_new(cmp) SKM_sk_new(PKCS12_SAFEBAG, (cmp))\n# define sk_PKCS12_SAFEBAG_new_null() SKM_sk_new_null(PKCS12_SAFEBAG)\n# define sk_PKCS12_SAFEBAG_free(st) SKM_sk_free(PKCS12_SAFEBAG, (st))\n# define sk_PKCS12_SAFEBAG_num(st) SKM_sk_num(PKCS12_SAFEBAG, (st))\n# define sk_PKCS12_SAFEBAG_value(st, i) SKM_sk_value(PKCS12_SAFEBAG, (st), (i))\n# define sk_PKCS12_SAFEBAG_set(st, i, val) SKM_sk_set(PKCS12_SAFEBAG, (st), (i), (val))\n# define sk_PKCS12_SAFEBAG_zero(st) SKM_sk_zero(PKCS12_SAFEBAG, (st))\n# define sk_PKCS12_SAFEBAG_push(st, val) SKM_sk_push(PKCS12_SAFEBAG, (st), (val))\n# define sk_PKCS12_SAFEBAG_unshift(st, val) SKM_sk_unshift(PKCS12_SAFEBAG, (st), (val))\n# define sk_PKCS12_SAFEBAG_find(st, val) SKM_sk_find(PKCS12_SAFEBAG, (st), (val))\n# define sk_PKCS12_SAFEBAG_find_ex(st, val) SKM_sk_find_ex(PKCS12_SAFEBAG, (st), (val))\n# define sk_PKCS12_SAFEBAG_delete(st, i) SKM_sk_delete(PKCS12_SAFEBAG, (st), (i))\n# define sk_PKCS12_SAFEBAG_delete_ptr(st, ptr) SKM_sk_delete_ptr(PKCS12_SAFEBAG, (st), (ptr))\n# define sk_PKCS12_SAFEBAG_insert(st, val, i) SKM_sk_insert(PKCS12_SAFEBAG, (st), (val), (i))\n# define sk_PKCS12_SAFEBAG_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(PKCS12_SAFEBAG, (st), (cmp))\n# define sk_PKCS12_SAFEBAG_dup(st) SKM_sk_dup(PKCS12_SAFEBAG, st)\n# define sk_PKCS12_SAFEBAG_pop_free(st, free_func) SKM_sk_pop_free(PKCS12_SAFEBAG, (st), (free_func))\n# define sk_PKCS12_SAFEBAG_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(PKCS12_SAFEBAG, (st), (copy_func), (free_func))\n# define sk_PKCS12_SAFEBAG_shift(st) SKM_sk_shift(PKCS12_SAFEBAG, (st))\n# define sk_PKCS12_SAFEBAG_pop(st) SKM_sk_pop(PKCS12_SAFEBAG, (st))\n# define sk_PKCS12_SAFEBAG_sort(st) SKM_sk_sort(PKCS12_SAFEBAG, (st))\n# define sk_PKCS12_SAFEBAG_is_sorted(st) SKM_sk_is_sorted(PKCS12_SAFEBAG, (st))\n# define sk_PKCS7_new(cmp) SKM_sk_new(PKCS7, (cmp))\n# define sk_PKCS7_new_null() SKM_sk_new_null(PKCS7)\n# define sk_PKCS7_free(st) SKM_sk_free(PKCS7, (st))\n# define sk_PKCS7_num(st) SKM_sk_num(PKCS7, (st))\n# define sk_PKCS7_value(st, i) SKM_sk_value(PKCS7, (st), (i))\n# define sk_PKCS7_set(st, i, val) SKM_sk_set(PKCS7, (st), (i), (val))\n# define sk_PKCS7_zero(st) SKM_sk_zero(PKCS7, (st))\n# define sk_PKCS7_push(st, val) SKM_sk_push(PKCS7, (st), (val))\n# define sk_PKCS7_unshift(st, val) SKM_sk_unshift(PKCS7, (st), (val))\n# define sk_PKCS7_find(st, val) SKM_sk_find(PKCS7, (st), (val))\n# define sk_PKCS7_find_ex(st, val) SKM_sk_find_ex(PKCS7, (st), (val))\n# define sk_PKCS7_delete(st, i) SKM_sk_delete(PKCS7, (st), (i))\n# define sk_PKCS7_delete_ptr(st, ptr) SKM_sk_delete_ptr(PKCS7, (st), (ptr))\n# define sk_PKCS7_insert(st, val, i) SKM_sk_insert(PKCS7, (st), (val), (i))\n# define sk_PKCS7_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(PKCS7, (st), (cmp))\n# define sk_PKCS7_dup(st) SKM_sk_dup(PKCS7, st)\n# define sk_PKCS7_pop_free(st, free_func) SKM_sk_pop_free(PKCS7, (st), (free_func))\n# define sk_PKCS7_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(PKCS7, (st), (copy_func), (free_func))\n# define sk_PKCS7_shift(st) SKM_sk_shift(PKCS7, (st))\n# define sk_PKCS7_pop(st) SKM_sk_pop(PKCS7, (st))\n# define sk_PKCS7_sort(st) SKM_sk_sort(PKCS7, (st))\n# define sk_PKCS7_is_sorted(st) SKM_sk_is_sorted(PKCS7, (st))\n# define sk_PKCS7_RECIP_INFO_new(cmp) SKM_sk_new(PKCS7_RECIP_INFO, (cmp))\n# define sk_PKCS7_RECIP_INFO_new_null() SKM_sk_new_null(PKCS7_RECIP_INFO)\n# define sk_PKCS7_RECIP_INFO_free(st) SKM_sk_free(PKCS7_RECIP_INFO, (st))\n# define sk_PKCS7_RECIP_INFO_num(st) SKM_sk_num(PKCS7_RECIP_INFO, (st))\n# define sk_PKCS7_RECIP_INFO_value(st, i) SKM_sk_value(PKCS7_RECIP_INFO, (st), (i))\n# define sk_PKCS7_RECIP_INFO_set(st, i, val) SKM_sk_set(PKCS7_RECIP_INFO, (st), (i), (val))\n# define sk_PKCS7_RECIP_INFO_zero(st) SKM_sk_zero(PKCS7_RECIP_INFO, (st))\n# define sk_PKCS7_RECIP_INFO_push(st, val) SKM_sk_push(PKCS7_RECIP_INFO, (st), (val))\n# define sk_PKCS7_RECIP_INFO_unshift(st, val) SKM_sk_unshift(PKCS7_RECIP_INFO, (st), (val))\n# define sk_PKCS7_RECIP_INFO_find(st, val) SKM_sk_find(PKCS7_RECIP_INFO, (st), (val))\n# define sk_PKCS7_RECIP_INFO_find_ex(st, val) SKM_sk_find_ex(PKCS7_RECIP_INFO, (st), (val))\n# define sk_PKCS7_RECIP_INFO_delete(st, i) SKM_sk_delete(PKCS7_RECIP_INFO, (st), (i))\n# define sk_PKCS7_RECIP_INFO_delete_ptr(st, ptr) SKM_sk_delete_ptr(PKCS7_RECIP_INFO, (st), (ptr))\n# define sk_PKCS7_RECIP_INFO_insert(st, val, i) SKM_sk_insert(PKCS7_RECIP_INFO, (st), (val), (i))\n# define sk_PKCS7_RECIP_INFO_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(PKCS7_RECIP_INFO, (st), (cmp))\n# define sk_PKCS7_RECIP_INFO_dup(st) SKM_sk_dup(PKCS7_RECIP_INFO, st)\n# define sk_PKCS7_RECIP_INFO_pop_free(st, free_func) SKM_sk_pop_free(PKCS7_RECIP_INFO, (st), (free_func))\n# define sk_PKCS7_RECIP_INFO_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(PKCS7_RECIP_INFO, (st), (copy_func), (free_func))\n# define sk_PKCS7_RECIP_INFO_shift(st) SKM_sk_shift(PKCS7_RECIP_INFO, (st))\n# define sk_PKCS7_RECIP_INFO_pop(st) SKM_sk_pop(PKCS7_RECIP_INFO, (st))\n# define sk_PKCS7_RECIP_INFO_sort(st) SKM_sk_sort(PKCS7_RECIP_INFO, (st))\n# define sk_PKCS7_RECIP_INFO_is_sorted(st) SKM_sk_is_sorted(PKCS7_RECIP_INFO, (st))\n# define sk_PKCS7_SIGNER_INFO_new(cmp) SKM_sk_new(PKCS7_SIGNER_INFO, (cmp))\n# define sk_PKCS7_SIGNER_INFO_new_null() SKM_sk_new_null(PKCS7_SIGNER_INFO)\n# define sk_PKCS7_SIGNER_INFO_free(st) SKM_sk_free(PKCS7_SIGNER_INFO, (st))\n# define sk_PKCS7_SIGNER_INFO_num(st) SKM_sk_num(PKCS7_SIGNER_INFO, (st))\n# define sk_PKCS7_SIGNER_INFO_value(st, i) SKM_sk_value(PKCS7_SIGNER_INFO, (st), (i))\n# define sk_PKCS7_SIGNER_INFO_set(st, i, val) SKM_sk_set(PKCS7_SIGNER_INFO, (st), (i), (val))\n# define sk_PKCS7_SIGNER_INFO_zero(st) SKM_sk_zero(PKCS7_SIGNER_INFO, (st))\n# define sk_PKCS7_SIGNER_INFO_push(st, val) SKM_sk_push(PKCS7_SIGNER_INFO, (st), (val))\n# define sk_PKCS7_SIGNER_INFO_unshift(st, val) SKM_sk_unshift(PKCS7_SIGNER_INFO, (st), (val))\n# define sk_PKCS7_SIGNER_INFO_find(st, val) SKM_sk_find(PKCS7_SIGNER_INFO, (st), (val))\n# define sk_PKCS7_SIGNER_INFO_find_ex(st, val) SKM_sk_find_ex(PKCS7_SIGNER_INFO, (st), (val))\n# define sk_PKCS7_SIGNER_INFO_delete(st, i) SKM_sk_delete(PKCS7_SIGNER_INFO, (st), (i))\n# define sk_PKCS7_SIGNER_INFO_delete_ptr(st, ptr) SKM_sk_delete_ptr(PKCS7_SIGNER_INFO, (st), (ptr))\n# define sk_PKCS7_SIGNER_INFO_insert(st, val, i) SKM_sk_insert(PKCS7_SIGNER_INFO, (st), (val), (i))\n# define sk_PKCS7_SIGNER_INFO_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(PKCS7_SIGNER_INFO, (st), (cmp))\n# define sk_PKCS7_SIGNER_INFO_dup(st) SKM_sk_dup(PKCS7_SIGNER_INFO, st)\n# define sk_PKCS7_SIGNER_INFO_pop_free(st, free_func) SKM_sk_pop_free(PKCS7_SIGNER_INFO, (st), (free_func))\n# define sk_PKCS7_SIGNER_INFO_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(PKCS7_SIGNER_INFO, (st), (copy_func), (free_func))\n# define sk_PKCS7_SIGNER_INFO_shift(st) SKM_sk_shift(PKCS7_SIGNER_INFO, (st))\n# define sk_PKCS7_SIGNER_INFO_pop(st) SKM_sk_pop(PKCS7_SIGNER_INFO, (st))\n# define sk_PKCS7_SIGNER_INFO_sort(st) SKM_sk_sort(PKCS7_SIGNER_INFO, (st))\n# define sk_PKCS7_SIGNER_INFO_is_sorted(st) SKM_sk_is_sorted(PKCS7_SIGNER_INFO, (st))\n# define sk_POLICYINFO_new(cmp) SKM_sk_new(POLICYINFO, (cmp))\n# define sk_POLICYINFO_new_null() SKM_sk_new_null(POLICYINFO)\n# define sk_POLICYINFO_free(st) SKM_sk_free(POLICYINFO, (st))\n# define sk_POLICYINFO_num(st) SKM_sk_num(POLICYINFO, (st))\n# define sk_POLICYINFO_value(st, i) SKM_sk_value(POLICYINFO, (st), (i))\n# define sk_POLICYINFO_set(st, i, val) SKM_sk_set(POLICYINFO, (st), (i), (val))\n# define sk_POLICYINFO_zero(st) SKM_sk_zero(POLICYINFO, (st))\n# define sk_POLICYINFO_push(st, val) SKM_sk_push(POLICYINFO, (st), (val))\n# define sk_POLICYINFO_unshift(st, val) SKM_sk_unshift(POLICYINFO, (st), (val))\n# define sk_POLICYINFO_find(st, val) SKM_sk_find(POLICYINFO, (st), (val))\n# define sk_POLICYINFO_find_ex(st, val) SKM_sk_find_ex(POLICYINFO, (st), (val))\n# define sk_POLICYINFO_delete(st, i) SKM_sk_delete(POLICYINFO, (st), (i))\n# define sk_POLICYINFO_delete_ptr(st, ptr) SKM_sk_delete_ptr(POLICYINFO, (st), (ptr))\n# define sk_POLICYINFO_insert(st, val, i) SKM_sk_insert(POLICYINFO, (st), (val), (i))\n# define sk_POLICYINFO_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(POLICYINFO, (st), (cmp))\n# define sk_POLICYINFO_dup(st) SKM_sk_dup(POLICYINFO, st)\n# define sk_POLICYINFO_pop_free(st, free_func) SKM_sk_pop_free(POLICYINFO, (st), (free_func))\n# define sk_POLICYINFO_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(POLICYINFO, (st), (copy_func), (free_func))\n# define sk_POLICYINFO_shift(st) SKM_sk_shift(POLICYINFO, (st))\n# define sk_POLICYINFO_pop(st) SKM_sk_pop(POLICYINFO, (st))\n# define sk_POLICYINFO_sort(st) SKM_sk_sort(POLICYINFO, (st))\n# define sk_POLICYINFO_is_sorted(st) SKM_sk_is_sorted(POLICYINFO, (st))\n# define sk_POLICYQUALINFO_new(cmp) SKM_sk_new(POLICYQUALINFO, (cmp))\n# define sk_POLICYQUALINFO_new_null() SKM_sk_new_null(POLICYQUALINFO)\n# define sk_POLICYQUALINFO_free(st) SKM_sk_free(POLICYQUALINFO, (st))\n# define sk_POLICYQUALINFO_num(st) SKM_sk_num(POLICYQUALINFO, (st))\n# define sk_POLICYQUALINFO_value(st, i) SKM_sk_value(POLICYQUALINFO, (st), (i))\n# define sk_POLICYQUALINFO_set(st, i, val) SKM_sk_set(POLICYQUALINFO, (st), (i), (val))\n# define sk_POLICYQUALINFO_zero(st) SKM_sk_zero(POLICYQUALINFO, (st))\n# define sk_POLICYQUALINFO_push(st, val) SKM_sk_push(POLICYQUALINFO, (st), (val))\n# define sk_POLICYQUALINFO_unshift(st, val) SKM_sk_unshift(POLICYQUALINFO, (st), (val))\n# define sk_POLICYQUALINFO_find(st, val) SKM_sk_find(POLICYQUALINFO, (st), (val))\n# define sk_POLICYQUALINFO_find_ex(st, val) SKM_sk_find_ex(POLICYQUALINFO, (st), (val))\n# define sk_POLICYQUALINFO_delete(st, i) SKM_sk_delete(POLICYQUALINFO, (st), (i))\n# define sk_POLICYQUALINFO_delete_ptr(st, ptr) SKM_sk_delete_ptr(POLICYQUALINFO, (st), (ptr))\n# define sk_POLICYQUALINFO_insert(st, val, i) SKM_sk_insert(POLICYQUALINFO, (st), (val), (i))\n# define sk_POLICYQUALINFO_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(POLICYQUALINFO, (st), (cmp))\n# define sk_POLICYQUALINFO_dup(st) SKM_sk_dup(POLICYQUALINFO, st)\n# define sk_POLICYQUALINFO_pop_free(st, free_func) SKM_sk_pop_free(POLICYQUALINFO, (st), (free_func))\n# define sk_POLICYQUALINFO_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(POLICYQUALINFO, (st), (copy_func), (free_func))\n# define sk_POLICYQUALINFO_shift(st) SKM_sk_shift(POLICYQUALINFO, (st))\n# define sk_POLICYQUALINFO_pop(st) SKM_sk_pop(POLICYQUALINFO, (st))\n# define sk_POLICYQUALINFO_sort(st) SKM_sk_sort(POLICYQUALINFO, (st))\n# define sk_POLICYQUALINFO_is_sorted(st) SKM_sk_is_sorted(POLICYQUALINFO, (st))\n# define sk_POLICY_MAPPING_new(cmp) SKM_sk_new(POLICY_MAPPING, (cmp))\n# define sk_POLICY_MAPPING_new_null() SKM_sk_new_null(POLICY_MAPPING)\n# define sk_POLICY_MAPPING_free(st) SKM_sk_free(POLICY_MAPPING, (st))\n# define sk_POLICY_MAPPING_num(st) SKM_sk_num(POLICY_MAPPING, (st))\n# define sk_POLICY_MAPPING_value(st, i) SKM_sk_value(POLICY_MAPPING, (st), (i))\n# define sk_POLICY_MAPPING_set(st, i, val) SKM_sk_set(POLICY_MAPPING, (st), (i), (val))\n# define sk_POLICY_MAPPING_zero(st) SKM_sk_zero(POLICY_MAPPING, (st))\n# define sk_POLICY_MAPPING_push(st, val) SKM_sk_push(POLICY_MAPPING, (st), (val))\n# define sk_POLICY_MAPPING_unshift(st, val) SKM_sk_unshift(POLICY_MAPPING, (st), (val))\n# define sk_POLICY_MAPPING_find(st, val) SKM_sk_find(POLICY_MAPPING, (st), (val))\n# define sk_POLICY_MAPPING_find_ex(st, val) SKM_sk_find_ex(POLICY_MAPPING, (st), (val))\n# define sk_POLICY_MAPPING_delete(st, i) SKM_sk_delete(POLICY_MAPPING, (st), (i))\n# define sk_POLICY_MAPPING_delete_ptr(st, ptr) SKM_sk_delete_ptr(POLICY_MAPPING, (st), (ptr))\n# define sk_POLICY_MAPPING_insert(st, val, i) SKM_sk_insert(POLICY_MAPPING, (st), (val), (i))\n# define sk_POLICY_MAPPING_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(POLICY_MAPPING, (st), (cmp))\n# define sk_POLICY_MAPPING_dup(st) SKM_sk_dup(POLICY_MAPPING, st)\n# define sk_POLICY_MAPPING_pop_free(st, free_func) SKM_sk_pop_free(POLICY_MAPPING, (st), (free_func))\n# define sk_POLICY_MAPPING_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(POLICY_MAPPING, (st), (copy_func), (free_func))\n# define sk_POLICY_MAPPING_shift(st) SKM_sk_shift(POLICY_MAPPING, (st))\n# define sk_POLICY_MAPPING_pop(st) SKM_sk_pop(POLICY_MAPPING, (st))\n# define sk_POLICY_MAPPING_sort(st) SKM_sk_sort(POLICY_MAPPING, (st))\n# define sk_POLICY_MAPPING_is_sorted(st) SKM_sk_is_sorted(POLICY_MAPPING, (st))\n# define sk_SCT_new(cmp) SKM_sk_new(SCT, (cmp))\n# define sk_SCT_new_null() SKM_sk_new_null(SCT)\n# define sk_SCT_free(st) SKM_sk_free(SCT, (st))\n# define sk_SCT_num(st) SKM_sk_num(SCT, (st))\n# define sk_SCT_value(st, i) SKM_sk_value(SCT, (st), (i))\n# define sk_SCT_set(st, i, val) SKM_sk_set(SCT, (st), (i), (val))\n# define sk_SCT_zero(st) SKM_sk_zero(SCT, (st))\n# define sk_SCT_push(st, val) SKM_sk_push(SCT, (st), (val))\n# define sk_SCT_unshift(st, val) SKM_sk_unshift(SCT, (st), (val))\n# define sk_SCT_find(st, val) SKM_sk_find(SCT, (st), (val))\n# define sk_SCT_find_ex(st, val) SKM_sk_find_ex(SCT, (st), (val))\n# define sk_SCT_delete(st, i) SKM_sk_delete(SCT, (st), (i))\n# define sk_SCT_delete_ptr(st, ptr) SKM_sk_delete_ptr(SCT, (st), (ptr))\n# define sk_SCT_insert(st, val, i) SKM_sk_insert(SCT, (st), (val), (i))\n# define sk_SCT_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(SCT, (st), (cmp))\n# define sk_SCT_dup(st) SKM_sk_dup(SCT, st)\n# define sk_SCT_pop_free(st, free_func) SKM_sk_pop_free(SCT, (st), (free_func))\n# define sk_SCT_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(SCT, (st), (copy_func), (free_func))\n# define sk_SCT_shift(st) SKM_sk_shift(SCT, (st))\n# define sk_SCT_pop(st) SKM_sk_pop(SCT, (st))\n# define sk_SCT_sort(st) SKM_sk_sort(SCT, (st))\n# define sk_SCT_is_sorted(st) SKM_sk_is_sorted(SCT, (st))\n# define sk_SRP_gN_new(cmp) SKM_sk_new(SRP_gN, (cmp))\n# define sk_SRP_gN_new_null() SKM_sk_new_null(SRP_gN)\n# define sk_SRP_gN_free(st) SKM_sk_free(SRP_gN, (st))\n# define sk_SRP_gN_num(st) SKM_sk_num(SRP_gN, (st))\n# define sk_SRP_gN_value(st, i) SKM_sk_value(SRP_gN, (st), (i))\n# define sk_SRP_gN_set(st, i, val) SKM_sk_set(SRP_gN, (st), (i), (val))\n# define sk_SRP_gN_zero(st) SKM_sk_zero(SRP_gN, (st))\n# define sk_SRP_gN_push(st, val) SKM_sk_push(SRP_gN, (st), (val))\n# define sk_SRP_gN_unshift(st, val) SKM_sk_unshift(SRP_gN, (st), (val))\n# define sk_SRP_gN_find(st, val) SKM_sk_find(SRP_gN, (st), (val))\n# define sk_SRP_gN_find_ex(st, val) SKM_sk_find_ex(SRP_gN, (st), (val))\n# define sk_SRP_gN_delete(st, i) SKM_sk_delete(SRP_gN, (st), (i))\n# define sk_SRP_gN_delete_ptr(st, ptr) SKM_sk_delete_ptr(SRP_gN, (st), (ptr))\n# define sk_SRP_gN_insert(st, val, i) SKM_sk_insert(SRP_gN, (st), (val), (i))\n# define sk_SRP_gN_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(SRP_gN, (st), (cmp))\n# define sk_SRP_gN_dup(st) SKM_sk_dup(SRP_gN, st)\n# define sk_SRP_gN_pop_free(st, free_func) SKM_sk_pop_free(SRP_gN, (st), (free_func))\n# define sk_SRP_gN_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(SRP_gN, (st), (copy_func), (free_func))\n# define sk_SRP_gN_shift(st) SKM_sk_shift(SRP_gN, (st))\n# define sk_SRP_gN_pop(st) SKM_sk_pop(SRP_gN, (st))\n# define sk_SRP_gN_sort(st) SKM_sk_sort(SRP_gN, (st))\n# define sk_SRP_gN_is_sorted(st) SKM_sk_is_sorted(SRP_gN, (st))\n# define sk_SRP_gN_cache_new(cmp) SKM_sk_new(SRP_gN_cache, (cmp))\n# define sk_SRP_gN_cache_new_null() SKM_sk_new_null(SRP_gN_cache)\n# define sk_SRP_gN_cache_free(st) SKM_sk_free(SRP_gN_cache, (st))\n# define sk_SRP_gN_cache_num(st) SKM_sk_num(SRP_gN_cache, (st))\n# define sk_SRP_gN_cache_value(st, i) SKM_sk_value(SRP_gN_cache, (st), (i))\n# define sk_SRP_gN_cache_set(st, i, val) SKM_sk_set(SRP_gN_cache, (st), (i), (val))\n# define sk_SRP_gN_cache_zero(st) SKM_sk_zero(SRP_gN_cache, (st))\n# define sk_SRP_gN_cache_push(st, val) SKM_sk_push(SRP_gN_cache, (st), (val))\n# define sk_SRP_gN_cache_unshift(st, val) SKM_sk_unshift(SRP_gN_cache, (st), (val))\n# define sk_SRP_gN_cache_find(st, val) SKM_sk_find(SRP_gN_cache, (st), (val))\n# define sk_SRP_gN_cache_find_ex(st, val) SKM_sk_find_ex(SRP_gN_cache, (st), (val))\n# define sk_SRP_gN_cache_delete(st, i) SKM_sk_delete(SRP_gN_cache, (st), (i))\n# define sk_SRP_gN_cache_delete_ptr(st, ptr) SKM_sk_delete_ptr(SRP_gN_cache, (st), (ptr))\n# define sk_SRP_gN_cache_insert(st, val, i) SKM_sk_insert(SRP_gN_cache, (st), (val), (i))\n# define sk_SRP_gN_cache_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(SRP_gN_cache, (st), (cmp))\n# define sk_SRP_gN_cache_dup(st) SKM_sk_dup(SRP_gN_cache, st)\n# define sk_SRP_gN_cache_pop_free(st, free_func) SKM_sk_pop_free(SRP_gN_cache, (st), (free_func))\n# define sk_SRP_gN_cache_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(SRP_gN_cache, (st), (copy_func), (free_func))\n# define sk_SRP_gN_cache_shift(st) SKM_sk_shift(SRP_gN_cache, (st))\n# define sk_SRP_gN_cache_pop(st) SKM_sk_pop(SRP_gN_cache, (st))\n# define sk_SRP_gN_cache_sort(st) SKM_sk_sort(SRP_gN_cache, (st))\n# define sk_SRP_gN_cache_is_sorted(st) SKM_sk_is_sorted(SRP_gN_cache, (st))\n# define sk_SRP_user_pwd_new(cmp) SKM_sk_new(SRP_user_pwd, (cmp))\n# define sk_SRP_user_pwd_new_null() SKM_sk_new_null(SRP_user_pwd)\n# define sk_SRP_user_pwd_free(st) SKM_sk_free(SRP_user_pwd, (st))\n# define sk_SRP_user_pwd_num(st) SKM_sk_num(SRP_user_pwd, (st))\n# define sk_SRP_user_pwd_value(st, i) SKM_sk_value(SRP_user_pwd, (st), (i))\n# define sk_SRP_user_pwd_set(st, i, val) SKM_sk_set(SRP_user_pwd, (st), (i), (val))\n# define sk_SRP_user_pwd_zero(st) SKM_sk_zero(SRP_user_pwd, (st))\n# define sk_SRP_user_pwd_push(st, val) SKM_sk_push(SRP_user_pwd, (st), (val))\n# define sk_SRP_user_pwd_unshift(st, val) SKM_sk_unshift(SRP_user_pwd, (st), (val))\n# define sk_SRP_user_pwd_find(st, val) SKM_sk_find(SRP_user_pwd, (st), (val))\n# define sk_SRP_user_pwd_find_ex(st, val) SKM_sk_find_ex(SRP_user_pwd, (st), (val))\n# define sk_SRP_user_pwd_delete(st, i) SKM_sk_delete(SRP_user_pwd, (st), (i))\n# define sk_SRP_user_pwd_delete_ptr(st, ptr) SKM_sk_delete_ptr(SRP_user_pwd, (st), (ptr))\n# define sk_SRP_user_pwd_insert(st, val, i) SKM_sk_insert(SRP_user_pwd, (st), (val), (i))\n# define sk_SRP_user_pwd_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(SRP_user_pwd, (st), (cmp))\n# define sk_SRP_user_pwd_dup(st) SKM_sk_dup(SRP_user_pwd, st)\n# define sk_SRP_user_pwd_pop_free(st, free_func) SKM_sk_pop_free(SRP_user_pwd, (st), (free_func))\n# define sk_SRP_user_pwd_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(SRP_user_pwd, (st), (copy_func), (free_func))\n# define sk_SRP_user_pwd_shift(st) SKM_sk_shift(SRP_user_pwd, (st))\n# define sk_SRP_user_pwd_pop(st) SKM_sk_pop(SRP_user_pwd, (st))\n# define sk_SRP_user_pwd_sort(st) SKM_sk_sort(SRP_user_pwd, (st))\n# define sk_SRP_user_pwd_is_sorted(st) SKM_sk_is_sorted(SRP_user_pwd, (st))\n# define sk_SRTP_PROTECTION_PROFILE_new(cmp) SKM_sk_new(SRTP_PROTECTION_PROFILE, (cmp))\n# define sk_SRTP_PROTECTION_PROFILE_new_null() SKM_sk_new_null(SRTP_PROTECTION_PROFILE)\n# define sk_SRTP_PROTECTION_PROFILE_free(st) SKM_sk_free(SRTP_PROTECTION_PROFILE, (st))\n# define sk_SRTP_PROTECTION_PROFILE_num(st) SKM_sk_num(SRTP_PROTECTION_PROFILE, (st))\n# define sk_SRTP_PROTECTION_PROFILE_value(st, i) SKM_sk_value(SRTP_PROTECTION_PROFILE, (st), (i))\n# define sk_SRTP_PROTECTION_PROFILE_set(st, i, val) SKM_sk_set(SRTP_PROTECTION_PROFILE, (st), (i), (val))\n# define sk_SRTP_PROTECTION_PROFILE_zero(st) SKM_sk_zero(SRTP_PROTECTION_PROFILE, (st))\n# define sk_SRTP_PROTECTION_PROFILE_push(st, val) SKM_sk_push(SRTP_PROTECTION_PROFILE, (st), (val))\n# define sk_SRTP_PROTECTION_PROFILE_unshift(st, val) SKM_sk_unshift(SRTP_PROTECTION_PROFILE, (st), (val))\n# define sk_SRTP_PROTECTION_PROFILE_find(st, val) SKM_sk_find(SRTP_PROTECTION_PROFILE, (st), (val))\n# define sk_SRTP_PROTECTION_PROFILE_find_ex(st, val) SKM_sk_find_ex(SRTP_PROTECTION_PROFILE, (st), (val))\n# define sk_SRTP_PROTECTION_PROFILE_delete(st, i) SKM_sk_delete(SRTP_PROTECTION_PROFILE, (st), (i))\n# define sk_SRTP_PROTECTION_PROFILE_delete_ptr(st, ptr) SKM_sk_delete_ptr(SRTP_PROTECTION_PROFILE, (st), (ptr))\n# define sk_SRTP_PROTECTION_PROFILE_insert(st, val, i) SKM_sk_insert(SRTP_PROTECTION_PROFILE, (st), (val), (i))\n# define sk_SRTP_PROTECTION_PROFILE_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(SRTP_PROTECTION_PROFILE, (st), (cmp))\n# define sk_SRTP_PROTECTION_PROFILE_dup(st) SKM_sk_dup(SRTP_PROTECTION_PROFILE, st)\n# define sk_SRTP_PROTECTION_PROFILE_pop_free(st, free_func) SKM_sk_pop_free(SRTP_PROTECTION_PROFILE, (st), (free_func))\n# define sk_SRTP_PROTECTION_PROFILE_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(SRTP_PROTECTION_PROFILE, (st), (copy_func), (free_func))\n# define sk_SRTP_PROTECTION_PROFILE_shift(st) SKM_sk_shift(SRTP_PROTECTION_PROFILE, (st))\n# define sk_SRTP_PROTECTION_PROFILE_pop(st) SKM_sk_pop(SRTP_PROTECTION_PROFILE, (st))\n# define sk_SRTP_PROTECTION_PROFILE_sort(st) SKM_sk_sort(SRTP_PROTECTION_PROFILE, (st))\n# define sk_SRTP_PROTECTION_PROFILE_is_sorted(st) SKM_sk_is_sorted(SRTP_PROTECTION_PROFILE, (st))\n# define sk_SSL_CIPHER_new(cmp) SKM_sk_new(SSL_CIPHER, (cmp))\n# define sk_SSL_CIPHER_new_null() SKM_sk_new_null(SSL_CIPHER)\n# define sk_SSL_CIPHER_free(st) SKM_sk_free(SSL_CIPHER, (st))\n# define sk_SSL_CIPHER_num(st) SKM_sk_num(SSL_CIPHER, (st))\n# define sk_SSL_CIPHER_value(st, i) SKM_sk_value(SSL_CIPHER, (st), (i))\n# define sk_SSL_CIPHER_set(st, i, val) SKM_sk_set(SSL_CIPHER, (st), (i), (val))\n# define sk_SSL_CIPHER_zero(st) SKM_sk_zero(SSL_CIPHER, (st))\n# define sk_SSL_CIPHER_push(st, val) SKM_sk_push(SSL_CIPHER, (st), (val))\n# define sk_SSL_CIPHER_unshift(st, val) SKM_sk_unshift(SSL_CIPHER, (st), (val))\n# define sk_SSL_CIPHER_find(st, val) SKM_sk_find(SSL_CIPHER, (st), (val))\n# define sk_SSL_CIPHER_find_ex(st, val) SKM_sk_find_ex(SSL_CIPHER, (st), (val))\n# define sk_SSL_CIPHER_delete(st, i) SKM_sk_delete(SSL_CIPHER, (st), (i))\n# define sk_SSL_CIPHER_delete_ptr(st, ptr) SKM_sk_delete_ptr(SSL_CIPHER, (st), (ptr))\n# define sk_SSL_CIPHER_insert(st, val, i) SKM_sk_insert(SSL_CIPHER, (st), (val), (i))\n# define sk_SSL_CIPHER_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(SSL_CIPHER, (st), (cmp))\n# define sk_SSL_CIPHER_dup(st) SKM_sk_dup(SSL_CIPHER, st)\n# define sk_SSL_CIPHER_pop_free(st, free_func) SKM_sk_pop_free(SSL_CIPHER, (st), (free_func))\n# define sk_SSL_CIPHER_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(SSL_CIPHER, (st), (copy_func), (free_func))\n# define sk_SSL_CIPHER_shift(st) SKM_sk_shift(SSL_CIPHER, (st))\n# define sk_SSL_CIPHER_pop(st) SKM_sk_pop(SSL_CIPHER, (st))\n# define sk_SSL_CIPHER_sort(st) SKM_sk_sort(SSL_CIPHER, (st))\n# define sk_SSL_CIPHER_is_sorted(st) SKM_sk_is_sorted(SSL_CIPHER, (st))\n# define sk_SSL_COMP_new(cmp) SKM_sk_new(SSL_COMP, (cmp))\n# define sk_SSL_COMP_new_null() SKM_sk_new_null(SSL_COMP)\n# define sk_SSL_COMP_free(st) SKM_sk_free(SSL_COMP, (st))\n# define sk_SSL_COMP_num(st) SKM_sk_num(SSL_COMP, (st))\n# define sk_SSL_COMP_value(st, i) SKM_sk_value(SSL_COMP, (st), (i))\n# define sk_SSL_COMP_set(st, i, val) SKM_sk_set(SSL_COMP, (st), (i), (val))\n# define sk_SSL_COMP_zero(st) SKM_sk_zero(SSL_COMP, (st))\n# define sk_SSL_COMP_push(st, val) SKM_sk_push(SSL_COMP, (st), (val))\n# define sk_SSL_COMP_unshift(st, val) SKM_sk_unshift(SSL_COMP, (st), (val))\n# define sk_SSL_COMP_find(st, val) SKM_sk_find(SSL_COMP, (st), (val))\n# define sk_SSL_COMP_find_ex(st, val) SKM_sk_find_ex(SSL_COMP, (st), (val))\n# define sk_SSL_COMP_delete(st, i) SKM_sk_delete(SSL_COMP, (st), (i))\n# define sk_SSL_COMP_delete_ptr(st, ptr) SKM_sk_delete_ptr(SSL_COMP, (st), (ptr))\n# define sk_SSL_COMP_insert(st, val, i) SKM_sk_insert(SSL_COMP, (st), (val), (i))\n# define sk_SSL_COMP_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(SSL_COMP, (st), (cmp))\n# define sk_SSL_COMP_dup(st) SKM_sk_dup(SSL_COMP, st)\n# define sk_SSL_COMP_pop_free(st, free_func) SKM_sk_pop_free(SSL_COMP, (st), (free_func))\n# define sk_SSL_COMP_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(SSL_COMP, (st), (copy_func), (free_func))\n# define sk_SSL_COMP_shift(st) SKM_sk_shift(SSL_COMP, (st))\n# define sk_SSL_COMP_pop(st) SKM_sk_pop(SSL_COMP, (st))\n# define sk_SSL_COMP_sort(st) SKM_sk_sort(SSL_COMP, (st))\n# define sk_SSL_COMP_is_sorted(st) SKM_sk_is_sorted(SSL_COMP, (st))\n# define sk_STACK_OF_X509_NAME_ENTRY_new(cmp) SKM_sk_new(STACK_OF_X509_NAME_ENTRY, (cmp))\n# define sk_STACK_OF_X509_NAME_ENTRY_new_null() SKM_sk_new_null(STACK_OF_X509_NAME_ENTRY)\n# define sk_STACK_OF_X509_NAME_ENTRY_free(st) SKM_sk_free(STACK_OF_X509_NAME_ENTRY, (st))\n# define sk_STACK_OF_X509_NAME_ENTRY_num(st) SKM_sk_num(STACK_OF_X509_NAME_ENTRY, (st))\n# define sk_STACK_OF_X509_NAME_ENTRY_value(st, i) SKM_sk_value(STACK_OF_X509_NAME_ENTRY, (st), (i))\n# define sk_STACK_OF_X509_NAME_ENTRY_set(st, i, val) SKM_sk_set(STACK_OF_X509_NAME_ENTRY, (st), (i), (val))\n# define sk_STACK_OF_X509_NAME_ENTRY_zero(st) SKM_sk_zero(STACK_OF_X509_NAME_ENTRY, (st))\n# define sk_STACK_OF_X509_NAME_ENTRY_push(st, val) SKM_sk_push(STACK_OF_X509_NAME_ENTRY, (st), (val))\n# define sk_STACK_OF_X509_NAME_ENTRY_unshift(st, val) SKM_sk_unshift(STACK_OF_X509_NAME_ENTRY, (st), (val))\n# define sk_STACK_OF_X509_NAME_ENTRY_find(st, val) SKM_sk_find(STACK_OF_X509_NAME_ENTRY, (st), (val))\n# define sk_STACK_OF_X509_NAME_ENTRY_find_ex(st, val) SKM_sk_find_ex(STACK_OF_X509_NAME_ENTRY, (st), (val))\n# define sk_STACK_OF_X509_NAME_ENTRY_delete(st, i) SKM_sk_delete(STACK_OF_X509_NAME_ENTRY, (st), (i))\n# define sk_STACK_OF_X509_NAME_ENTRY_delete_ptr(st, ptr) SKM_sk_delete_ptr(STACK_OF_X509_NAME_ENTRY, (st), (ptr))\n# define sk_STACK_OF_X509_NAME_ENTRY_insert(st, val, i) SKM_sk_insert(STACK_OF_X509_NAME_ENTRY, (st), (val), (i))\n# define sk_STACK_OF_X509_NAME_ENTRY_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(STACK_OF_X509_NAME_ENTRY, (st), (cmp))\n# define sk_STACK_OF_X509_NAME_ENTRY_dup(st) SKM_sk_dup(STACK_OF_X509_NAME_ENTRY, st)\n# define sk_STACK_OF_X509_NAME_ENTRY_pop_free(st, free_func) SKM_sk_pop_free(STACK_OF_X509_NAME_ENTRY, (st), (free_func))\n# define sk_STACK_OF_X509_NAME_ENTRY_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(STACK_OF_X509_NAME_ENTRY, (st), (copy_func), (free_func))\n# define sk_STACK_OF_X509_NAME_ENTRY_shift(st) SKM_sk_shift(STACK_OF_X509_NAME_ENTRY, (st))\n# define sk_STACK_OF_X509_NAME_ENTRY_pop(st) SKM_sk_pop(STACK_OF_X509_NAME_ENTRY, (st))\n# define sk_STACK_OF_X509_NAME_ENTRY_sort(st) SKM_sk_sort(STACK_OF_X509_NAME_ENTRY, (st))\n# define sk_STACK_OF_X509_NAME_ENTRY_is_sorted(st) SKM_sk_is_sorted(STACK_OF_X509_NAME_ENTRY, (st))\n# define sk_STORE_ATTR_INFO_new(cmp) SKM_sk_new(STORE_ATTR_INFO, (cmp))\n# define sk_STORE_ATTR_INFO_new_null() SKM_sk_new_null(STORE_ATTR_INFO)\n# define sk_STORE_ATTR_INFO_free(st) SKM_sk_free(STORE_ATTR_INFO, (st))\n# define sk_STORE_ATTR_INFO_num(st) SKM_sk_num(STORE_ATTR_INFO, (st))\n# define sk_STORE_ATTR_INFO_value(st, i) SKM_sk_value(STORE_ATTR_INFO, (st), (i))\n# define sk_STORE_ATTR_INFO_set(st, i, val) SKM_sk_set(STORE_ATTR_INFO, (st), (i), (val))\n# define sk_STORE_ATTR_INFO_zero(st) SKM_sk_zero(STORE_ATTR_INFO, (st))\n# define sk_STORE_ATTR_INFO_push(st, val) SKM_sk_push(STORE_ATTR_INFO, (st), (val))\n# define sk_STORE_ATTR_INFO_unshift(st, val) SKM_sk_unshift(STORE_ATTR_INFO, (st), (val))\n# define sk_STORE_ATTR_INFO_find(st, val) SKM_sk_find(STORE_ATTR_INFO, (st), (val))\n# define sk_STORE_ATTR_INFO_find_ex(st, val) SKM_sk_find_ex(STORE_ATTR_INFO, (st), (val))\n# define sk_STORE_ATTR_INFO_delete(st, i) SKM_sk_delete(STORE_ATTR_INFO, (st), (i))\n# define sk_STORE_ATTR_INFO_delete_ptr(st, ptr) SKM_sk_delete_ptr(STORE_ATTR_INFO, (st), (ptr))\n# define sk_STORE_ATTR_INFO_insert(st, val, i) SKM_sk_insert(STORE_ATTR_INFO, (st), (val), (i))\n# define sk_STORE_ATTR_INFO_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(STORE_ATTR_INFO, (st), (cmp))\n# define sk_STORE_ATTR_INFO_dup(st) SKM_sk_dup(STORE_ATTR_INFO, st)\n# define sk_STORE_ATTR_INFO_pop_free(st, free_func) SKM_sk_pop_free(STORE_ATTR_INFO, (st), (free_func))\n# define sk_STORE_ATTR_INFO_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(STORE_ATTR_INFO, (st), (copy_func), (free_func))\n# define sk_STORE_ATTR_INFO_shift(st) SKM_sk_shift(STORE_ATTR_INFO, (st))\n# define sk_STORE_ATTR_INFO_pop(st) SKM_sk_pop(STORE_ATTR_INFO, (st))\n# define sk_STORE_ATTR_INFO_sort(st) SKM_sk_sort(STORE_ATTR_INFO, (st))\n# define sk_STORE_ATTR_INFO_is_sorted(st) SKM_sk_is_sorted(STORE_ATTR_INFO, (st))\n# define sk_STORE_OBJECT_new(cmp) SKM_sk_new(STORE_OBJECT, (cmp))\n# define sk_STORE_OBJECT_new_null() SKM_sk_new_null(STORE_OBJECT)\n# define sk_STORE_OBJECT_free(st) SKM_sk_free(STORE_OBJECT, (st))\n# define sk_STORE_OBJECT_num(st) SKM_sk_num(STORE_OBJECT, (st))\n# define sk_STORE_OBJECT_value(st, i) SKM_sk_value(STORE_OBJECT, (st), (i))\n# define sk_STORE_OBJECT_set(st, i, val) SKM_sk_set(STORE_OBJECT, (st), (i), (val))\n# define sk_STORE_OBJECT_zero(st) SKM_sk_zero(STORE_OBJECT, (st))\n# define sk_STORE_OBJECT_push(st, val) SKM_sk_push(STORE_OBJECT, (st), (val))\n# define sk_STORE_OBJECT_unshift(st, val) SKM_sk_unshift(STORE_OBJECT, (st), (val))\n# define sk_STORE_OBJECT_find(st, val) SKM_sk_find(STORE_OBJECT, (st), (val))\n# define sk_STORE_OBJECT_find_ex(st, val) SKM_sk_find_ex(STORE_OBJECT, (st), (val))\n# define sk_STORE_OBJECT_delete(st, i) SKM_sk_delete(STORE_OBJECT, (st), (i))\n# define sk_STORE_OBJECT_delete_ptr(st, ptr) SKM_sk_delete_ptr(STORE_OBJECT, (st), (ptr))\n# define sk_STORE_OBJECT_insert(st, val, i) SKM_sk_insert(STORE_OBJECT, (st), (val), (i))\n# define sk_STORE_OBJECT_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(STORE_OBJECT, (st), (cmp))\n# define sk_STORE_OBJECT_dup(st) SKM_sk_dup(STORE_OBJECT, st)\n# define sk_STORE_OBJECT_pop_free(st, free_func) SKM_sk_pop_free(STORE_OBJECT, (st), (free_func))\n# define sk_STORE_OBJECT_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(STORE_OBJECT, (st), (copy_func), (free_func))\n# define sk_STORE_OBJECT_shift(st) SKM_sk_shift(STORE_OBJECT, (st))\n# define sk_STORE_OBJECT_pop(st) SKM_sk_pop(STORE_OBJECT, (st))\n# define sk_STORE_OBJECT_sort(st) SKM_sk_sort(STORE_OBJECT, (st))\n# define sk_STORE_OBJECT_is_sorted(st) SKM_sk_is_sorted(STORE_OBJECT, (st))\n# define sk_SXNETID_new(cmp) SKM_sk_new(SXNETID, (cmp))\n# define sk_SXNETID_new_null() SKM_sk_new_null(SXNETID)\n# define sk_SXNETID_free(st) SKM_sk_free(SXNETID, (st))\n# define sk_SXNETID_num(st) SKM_sk_num(SXNETID, (st))\n# define sk_SXNETID_value(st, i) SKM_sk_value(SXNETID, (st), (i))\n# define sk_SXNETID_set(st, i, val) SKM_sk_set(SXNETID, (st), (i), (val))\n# define sk_SXNETID_zero(st) SKM_sk_zero(SXNETID, (st))\n# define sk_SXNETID_push(st, val) SKM_sk_push(SXNETID, (st), (val))\n# define sk_SXNETID_unshift(st, val) SKM_sk_unshift(SXNETID, (st), (val))\n# define sk_SXNETID_find(st, val) SKM_sk_find(SXNETID, (st), (val))\n# define sk_SXNETID_find_ex(st, val) SKM_sk_find_ex(SXNETID, (st), (val))\n# define sk_SXNETID_delete(st, i) SKM_sk_delete(SXNETID, (st), (i))\n# define sk_SXNETID_delete_ptr(st, ptr) SKM_sk_delete_ptr(SXNETID, (st), (ptr))\n# define sk_SXNETID_insert(st, val, i) SKM_sk_insert(SXNETID, (st), (val), (i))\n# define sk_SXNETID_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(SXNETID, (st), (cmp))\n# define sk_SXNETID_dup(st) SKM_sk_dup(SXNETID, st)\n# define sk_SXNETID_pop_free(st, free_func) SKM_sk_pop_free(SXNETID, (st), (free_func))\n# define sk_SXNETID_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(SXNETID, (st), (copy_func), (free_func))\n# define sk_SXNETID_shift(st) SKM_sk_shift(SXNETID, (st))\n# define sk_SXNETID_pop(st) SKM_sk_pop(SXNETID, (st))\n# define sk_SXNETID_sort(st) SKM_sk_sort(SXNETID, (st))\n# define sk_SXNETID_is_sorted(st) SKM_sk_is_sorted(SXNETID, (st))\n# define sk_UI_STRING_new(cmp) SKM_sk_new(UI_STRING, (cmp))\n# define sk_UI_STRING_new_null() SKM_sk_new_null(UI_STRING)\n# define sk_UI_STRING_free(st) SKM_sk_free(UI_STRING, (st))\n# define sk_UI_STRING_num(st) SKM_sk_num(UI_STRING, (st))\n# define sk_UI_STRING_value(st, i) SKM_sk_value(UI_STRING, (st), (i))\n# define sk_UI_STRING_set(st, i, val) SKM_sk_set(UI_STRING, (st), (i), (val))\n# define sk_UI_STRING_zero(st) SKM_sk_zero(UI_STRING, (st))\n# define sk_UI_STRING_push(st, val) SKM_sk_push(UI_STRING, (st), (val))\n# define sk_UI_STRING_unshift(st, val) SKM_sk_unshift(UI_STRING, (st), (val))\n# define sk_UI_STRING_find(st, val) SKM_sk_find(UI_STRING, (st), (val))\n# define sk_UI_STRING_find_ex(st, val) SKM_sk_find_ex(UI_STRING, (st), (val))\n# define sk_UI_STRING_delete(st, i) SKM_sk_delete(UI_STRING, (st), (i))\n# define sk_UI_STRING_delete_ptr(st, ptr) SKM_sk_delete_ptr(UI_STRING, (st), (ptr))\n# define sk_UI_STRING_insert(st, val, i) SKM_sk_insert(UI_STRING, (st), (val), (i))\n# define sk_UI_STRING_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(UI_STRING, (st), (cmp))\n# define sk_UI_STRING_dup(st) SKM_sk_dup(UI_STRING, st)\n# define sk_UI_STRING_pop_free(st, free_func) SKM_sk_pop_free(UI_STRING, (st), (free_func))\n# define sk_UI_STRING_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(UI_STRING, (st), (copy_func), (free_func))\n# define sk_UI_STRING_shift(st) SKM_sk_shift(UI_STRING, (st))\n# define sk_UI_STRING_pop(st) SKM_sk_pop(UI_STRING, (st))\n# define sk_UI_STRING_sort(st) SKM_sk_sort(UI_STRING, (st))\n# define sk_UI_STRING_is_sorted(st) SKM_sk_is_sorted(UI_STRING, (st))\n# define sk_X509_new(cmp) SKM_sk_new(X509, (cmp))\n# define sk_X509_new_null() SKM_sk_new_null(X509)\n# define sk_X509_free(st) SKM_sk_free(X509, (st))\n# define sk_X509_num(st) SKM_sk_num(X509, (st))\n# define sk_X509_value(st, i) SKM_sk_value(X509, (st), (i))\n# define sk_X509_set(st, i, val) SKM_sk_set(X509, (st), (i), (val))\n# define sk_X509_zero(st) SKM_sk_zero(X509, (st))\n# define sk_X509_push(st, val) SKM_sk_push(X509, (st), (val))\n# define sk_X509_unshift(st, val) SKM_sk_unshift(X509, (st), (val))\n# define sk_X509_find(st, val) SKM_sk_find(X509, (st), (val))\n# define sk_X509_find_ex(st, val) SKM_sk_find_ex(X509, (st), (val))\n# define sk_X509_delete(st, i) SKM_sk_delete(X509, (st), (i))\n# define sk_X509_delete_ptr(st, ptr) SKM_sk_delete_ptr(X509, (st), (ptr))\n# define sk_X509_insert(st, val, i) SKM_sk_insert(X509, (st), (val), (i))\n# define sk_X509_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(X509, (st), (cmp))\n# define sk_X509_dup(st) SKM_sk_dup(X509, st)\n# define sk_X509_pop_free(st, free_func) SKM_sk_pop_free(X509, (st), (free_func))\n# define sk_X509_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(X509, (st), (copy_func), (free_func))\n# define sk_X509_shift(st) SKM_sk_shift(X509, (st))\n# define sk_X509_pop(st) SKM_sk_pop(X509, (st))\n# define sk_X509_sort(st) SKM_sk_sort(X509, (st))\n# define sk_X509_is_sorted(st) SKM_sk_is_sorted(X509, (st))\n# define sk_X509V3_EXT_METHOD_new(cmp) SKM_sk_new(X509V3_EXT_METHOD, (cmp))\n# define sk_X509V3_EXT_METHOD_new_null() SKM_sk_new_null(X509V3_EXT_METHOD)\n# define sk_X509V3_EXT_METHOD_free(st) SKM_sk_free(X509V3_EXT_METHOD, (st))\n# define sk_X509V3_EXT_METHOD_num(st) SKM_sk_num(X509V3_EXT_METHOD, (st))\n# define sk_X509V3_EXT_METHOD_value(st, i) SKM_sk_value(X509V3_EXT_METHOD, (st), (i))\n# define sk_X509V3_EXT_METHOD_set(st, i, val) SKM_sk_set(X509V3_EXT_METHOD, (st), (i), (val))\n# define sk_X509V3_EXT_METHOD_zero(st) SKM_sk_zero(X509V3_EXT_METHOD, (st))\n# define sk_X509V3_EXT_METHOD_push(st, val) SKM_sk_push(X509V3_EXT_METHOD, (st), (val))\n# define sk_X509V3_EXT_METHOD_unshift(st, val) SKM_sk_unshift(X509V3_EXT_METHOD, (st), (val))\n# define sk_X509V3_EXT_METHOD_find(st, val) SKM_sk_find(X509V3_EXT_METHOD, (st), (val))\n# define sk_X509V3_EXT_METHOD_find_ex(st, val) SKM_sk_find_ex(X509V3_EXT_METHOD, (st), (val))\n# define sk_X509V3_EXT_METHOD_delete(st, i) SKM_sk_delete(X509V3_EXT_METHOD, (st), (i))\n# define sk_X509V3_EXT_METHOD_delete_ptr(st, ptr) SKM_sk_delete_ptr(X509V3_EXT_METHOD, (st), (ptr))\n# define sk_X509V3_EXT_METHOD_insert(st, val, i) SKM_sk_insert(X509V3_EXT_METHOD, (st), (val), (i))\n# define sk_X509V3_EXT_METHOD_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(X509V3_EXT_METHOD, (st), (cmp))\n# define sk_X509V3_EXT_METHOD_dup(st) SKM_sk_dup(X509V3_EXT_METHOD, st)\n# define sk_X509V3_EXT_METHOD_pop_free(st, free_func) SKM_sk_pop_free(X509V3_EXT_METHOD, (st), (free_func))\n# define sk_X509V3_EXT_METHOD_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(X509V3_EXT_METHOD, (st), (copy_func), (free_func))\n# define sk_X509V3_EXT_METHOD_shift(st) SKM_sk_shift(X509V3_EXT_METHOD, (st))\n# define sk_X509V3_EXT_METHOD_pop(st) SKM_sk_pop(X509V3_EXT_METHOD, (st))\n# define sk_X509V3_EXT_METHOD_sort(st) SKM_sk_sort(X509V3_EXT_METHOD, (st))\n# define sk_X509V3_EXT_METHOD_is_sorted(st) SKM_sk_is_sorted(X509V3_EXT_METHOD, (st))\n# define sk_X509_ALGOR_new(cmp) SKM_sk_new(X509_ALGOR, (cmp))\n# define sk_X509_ALGOR_new_null() SKM_sk_new_null(X509_ALGOR)\n# define sk_X509_ALGOR_free(st) SKM_sk_free(X509_ALGOR, (st))\n# define sk_X509_ALGOR_num(st) SKM_sk_num(X509_ALGOR, (st))\n# define sk_X509_ALGOR_value(st, i) SKM_sk_value(X509_ALGOR, (st), (i))\n# define sk_X509_ALGOR_set(st, i, val) SKM_sk_set(X509_ALGOR, (st), (i), (val))\n# define sk_X509_ALGOR_zero(st) SKM_sk_zero(X509_ALGOR, (st))\n# define sk_X509_ALGOR_push(st, val) SKM_sk_push(X509_ALGOR, (st), (val))\n# define sk_X509_ALGOR_unshift(st, val) SKM_sk_unshift(X509_ALGOR, (st), (val))\n# define sk_X509_ALGOR_find(st, val) SKM_sk_find(X509_ALGOR, (st), (val))\n# define sk_X509_ALGOR_find_ex(st, val) SKM_sk_find_ex(X509_ALGOR, (st), (val))\n# define sk_X509_ALGOR_delete(st, i) SKM_sk_delete(X509_ALGOR, (st), (i))\n# define sk_X509_ALGOR_delete_ptr(st, ptr) SKM_sk_delete_ptr(X509_ALGOR, (st), (ptr))\n# define sk_X509_ALGOR_insert(st, val, i) SKM_sk_insert(X509_ALGOR, (st), (val), (i))\n# define sk_X509_ALGOR_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(X509_ALGOR, (st), (cmp))\n# define sk_X509_ALGOR_dup(st) SKM_sk_dup(X509_ALGOR, st)\n# define sk_X509_ALGOR_pop_free(st, free_func) SKM_sk_pop_free(X509_ALGOR, (st), (free_func))\n# define sk_X509_ALGOR_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(X509_ALGOR, (st), (copy_func), (free_func))\n# define sk_X509_ALGOR_shift(st) SKM_sk_shift(X509_ALGOR, (st))\n# define sk_X509_ALGOR_pop(st) SKM_sk_pop(X509_ALGOR, (st))\n# define sk_X509_ALGOR_sort(st) SKM_sk_sort(X509_ALGOR, (st))\n# define sk_X509_ALGOR_is_sorted(st) SKM_sk_is_sorted(X509_ALGOR, (st))\n# define sk_X509_ATTRIBUTE_new(cmp) SKM_sk_new(X509_ATTRIBUTE, (cmp))\n# define sk_X509_ATTRIBUTE_new_null() SKM_sk_new_null(X509_ATTRIBUTE)\n# define sk_X509_ATTRIBUTE_free(st) SKM_sk_free(X509_ATTRIBUTE, (st))\n# define sk_X509_ATTRIBUTE_num(st) SKM_sk_num(X509_ATTRIBUTE, (st))\n# define sk_X509_ATTRIBUTE_value(st, i) SKM_sk_value(X509_ATTRIBUTE, (st), (i))\n# define sk_X509_ATTRIBUTE_set(st, i, val) SKM_sk_set(X509_ATTRIBUTE, (st), (i), (val))\n# define sk_X509_ATTRIBUTE_zero(st) SKM_sk_zero(X509_ATTRIBUTE, (st))\n# define sk_X509_ATTRIBUTE_push(st, val) SKM_sk_push(X509_ATTRIBUTE, (st), (val))\n# define sk_X509_ATTRIBUTE_unshift(st, val) SKM_sk_unshift(X509_ATTRIBUTE, (st), (val))\n# define sk_X509_ATTRIBUTE_find(st, val) SKM_sk_find(X509_ATTRIBUTE, (st), (val))\n# define sk_X509_ATTRIBUTE_find_ex(st, val) SKM_sk_find_ex(X509_ATTRIBUTE, (st), (val))\n# define sk_X509_ATTRIBUTE_delete(st, i) SKM_sk_delete(X509_ATTRIBUTE, (st), (i))\n# define sk_X509_ATTRIBUTE_delete_ptr(st, ptr) SKM_sk_delete_ptr(X509_ATTRIBUTE, (st), (ptr))\n# define sk_X509_ATTRIBUTE_insert(st, val, i) SKM_sk_insert(X509_ATTRIBUTE, (st), (val), (i))\n# define sk_X509_ATTRIBUTE_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(X509_ATTRIBUTE, (st), (cmp))\n# define sk_X509_ATTRIBUTE_dup(st) SKM_sk_dup(X509_ATTRIBUTE, st)\n# define sk_X509_ATTRIBUTE_pop_free(st, free_func) SKM_sk_pop_free(X509_ATTRIBUTE, (st), (free_func))\n# define sk_X509_ATTRIBUTE_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(X509_ATTRIBUTE, (st), (copy_func), (free_func))\n# define sk_X509_ATTRIBUTE_shift(st) SKM_sk_shift(X509_ATTRIBUTE, (st))\n# define sk_X509_ATTRIBUTE_pop(st) SKM_sk_pop(X509_ATTRIBUTE, (st))\n# define sk_X509_ATTRIBUTE_sort(st) SKM_sk_sort(X509_ATTRIBUTE, (st))\n# define sk_X509_ATTRIBUTE_is_sorted(st) SKM_sk_is_sorted(X509_ATTRIBUTE, (st))\n# define sk_X509_CRL_new(cmp) SKM_sk_new(X509_CRL, (cmp))\n# define sk_X509_CRL_new_null() SKM_sk_new_null(X509_CRL)\n# define sk_X509_CRL_free(st) SKM_sk_free(X509_CRL, (st))\n# define sk_X509_CRL_num(st) SKM_sk_num(X509_CRL, (st))\n# define sk_X509_CRL_value(st, i) SKM_sk_value(X509_CRL, (st), (i))\n# define sk_X509_CRL_set(st, i, val) SKM_sk_set(X509_CRL, (st), (i), (val))\n# define sk_X509_CRL_zero(st) SKM_sk_zero(X509_CRL, (st))\n# define sk_X509_CRL_push(st, val) SKM_sk_push(X509_CRL, (st), (val))\n# define sk_X509_CRL_unshift(st, val) SKM_sk_unshift(X509_CRL, (st), (val))\n# define sk_X509_CRL_find(st, val) SKM_sk_find(X509_CRL, (st), (val))\n# define sk_X509_CRL_find_ex(st, val) SKM_sk_find_ex(X509_CRL, (st), (val))\n# define sk_X509_CRL_delete(st, i) SKM_sk_delete(X509_CRL, (st), (i))\n# define sk_X509_CRL_delete_ptr(st, ptr) SKM_sk_delete_ptr(X509_CRL, (st), (ptr))\n# define sk_X509_CRL_insert(st, val, i) SKM_sk_insert(X509_CRL, (st), (val), (i))\n# define sk_X509_CRL_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(X509_CRL, (st), (cmp))\n# define sk_X509_CRL_dup(st) SKM_sk_dup(X509_CRL, st)\n# define sk_X509_CRL_pop_free(st, free_func) SKM_sk_pop_free(X509_CRL, (st), (free_func))\n# define sk_X509_CRL_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(X509_CRL, (st), (copy_func), (free_func))\n# define sk_X509_CRL_shift(st) SKM_sk_shift(X509_CRL, (st))\n# define sk_X509_CRL_pop(st) SKM_sk_pop(X509_CRL, (st))\n# define sk_X509_CRL_sort(st) SKM_sk_sort(X509_CRL, (st))\n# define sk_X509_CRL_is_sorted(st) SKM_sk_is_sorted(X509_CRL, (st))\n# define sk_X509_EXTENSION_new(cmp) SKM_sk_new(X509_EXTENSION, (cmp))\n# define sk_X509_EXTENSION_new_null() SKM_sk_new_null(X509_EXTENSION)\n# define sk_X509_EXTENSION_free(st) SKM_sk_free(X509_EXTENSION, (st))\n# define sk_X509_EXTENSION_num(st) SKM_sk_num(X509_EXTENSION, (st))\n# define sk_X509_EXTENSION_value(st, i) SKM_sk_value(X509_EXTENSION, (st), (i))\n# define sk_X509_EXTENSION_set(st, i, val) SKM_sk_set(X509_EXTENSION, (st), (i), (val))\n# define sk_X509_EXTENSION_zero(st) SKM_sk_zero(X509_EXTENSION, (st))\n# define sk_X509_EXTENSION_push(st, val) SKM_sk_push(X509_EXTENSION, (st), (val))\n# define sk_X509_EXTENSION_unshift(st, val) SKM_sk_unshift(X509_EXTENSION, (st), (val))\n# define sk_X509_EXTENSION_find(st, val) SKM_sk_find(X509_EXTENSION, (st), (val))\n# define sk_X509_EXTENSION_find_ex(st, val) SKM_sk_find_ex(X509_EXTENSION, (st), (val))\n# define sk_X509_EXTENSION_delete(st, i) SKM_sk_delete(X509_EXTENSION, (st), (i))\n# define sk_X509_EXTENSION_delete_ptr(st, ptr) SKM_sk_delete_ptr(X509_EXTENSION, (st), (ptr))\n# define sk_X509_EXTENSION_insert(st, val, i) SKM_sk_insert(X509_EXTENSION, (st), (val), (i))\n# define sk_X509_EXTENSION_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(X509_EXTENSION, (st), (cmp))\n# define sk_X509_EXTENSION_dup(st) SKM_sk_dup(X509_EXTENSION, st)\n# define sk_X509_EXTENSION_pop_free(st, free_func) SKM_sk_pop_free(X509_EXTENSION, (st), (free_func))\n# define sk_X509_EXTENSION_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(X509_EXTENSION, (st), (copy_func), (free_func))\n# define sk_X509_EXTENSION_shift(st) SKM_sk_shift(X509_EXTENSION, (st))\n# define sk_X509_EXTENSION_pop(st) SKM_sk_pop(X509_EXTENSION, (st))\n# define sk_X509_EXTENSION_sort(st) SKM_sk_sort(X509_EXTENSION, (st))\n# define sk_X509_EXTENSION_is_sorted(st) SKM_sk_is_sorted(X509_EXTENSION, (st))\n# define sk_X509_INFO_new(cmp) SKM_sk_new(X509_INFO, (cmp))\n# define sk_X509_INFO_new_null() SKM_sk_new_null(X509_INFO)\n# define sk_X509_INFO_free(st) SKM_sk_free(X509_INFO, (st))\n# define sk_X509_INFO_num(st) SKM_sk_num(X509_INFO, (st))\n# define sk_X509_INFO_value(st, i) SKM_sk_value(X509_INFO, (st), (i))\n# define sk_X509_INFO_set(st, i, val) SKM_sk_set(X509_INFO, (st), (i), (val))\n# define sk_X509_INFO_zero(st) SKM_sk_zero(X509_INFO, (st))\n# define sk_X509_INFO_push(st, val) SKM_sk_push(X509_INFO, (st), (val))\n# define sk_X509_INFO_unshift(st, val) SKM_sk_unshift(X509_INFO, (st), (val))\n# define sk_X509_INFO_find(st, val) SKM_sk_find(X509_INFO, (st), (val))\n# define sk_X509_INFO_find_ex(st, val) SKM_sk_find_ex(X509_INFO, (st), (val))\n# define sk_X509_INFO_delete(st, i) SKM_sk_delete(X509_INFO, (st), (i))\n# define sk_X509_INFO_delete_ptr(st, ptr) SKM_sk_delete_ptr(X509_INFO, (st), (ptr))\n# define sk_X509_INFO_insert(st, val, i) SKM_sk_insert(X509_INFO, (st), (val), (i))\n# define sk_X509_INFO_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(X509_INFO, (st), (cmp))\n# define sk_X509_INFO_dup(st) SKM_sk_dup(X509_INFO, st)\n# define sk_X509_INFO_pop_free(st, free_func) SKM_sk_pop_free(X509_INFO, (st), (free_func))\n# define sk_X509_INFO_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(X509_INFO, (st), (copy_func), (free_func))\n# define sk_X509_INFO_shift(st) SKM_sk_shift(X509_INFO, (st))\n# define sk_X509_INFO_pop(st) SKM_sk_pop(X509_INFO, (st))\n# define sk_X509_INFO_sort(st) SKM_sk_sort(X509_INFO, (st))\n# define sk_X509_INFO_is_sorted(st) SKM_sk_is_sorted(X509_INFO, (st))\n# define sk_X509_LOOKUP_new(cmp) SKM_sk_new(X509_LOOKUP, (cmp))\n# define sk_X509_LOOKUP_new_null() SKM_sk_new_null(X509_LOOKUP)\n# define sk_X509_LOOKUP_free(st) SKM_sk_free(X509_LOOKUP, (st))\n# define sk_X509_LOOKUP_num(st) SKM_sk_num(X509_LOOKUP, (st))\n# define sk_X509_LOOKUP_value(st, i) SKM_sk_value(X509_LOOKUP, (st), (i))\n# define sk_X509_LOOKUP_set(st, i, val) SKM_sk_set(X509_LOOKUP, (st), (i), (val))\n# define sk_X509_LOOKUP_zero(st) SKM_sk_zero(X509_LOOKUP, (st))\n# define sk_X509_LOOKUP_push(st, val) SKM_sk_push(X509_LOOKUP, (st), (val))\n# define sk_X509_LOOKUP_unshift(st, val) SKM_sk_unshift(X509_LOOKUP, (st), (val))\n# define sk_X509_LOOKUP_find(st, val) SKM_sk_find(X509_LOOKUP, (st), (val))\n# define sk_X509_LOOKUP_find_ex(st, val) SKM_sk_find_ex(X509_LOOKUP, (st), (val))\n# define sk_X509_LOOKUP_delete(st, i) SKM_sk_delete(X509_LOOKUP, (st), (i))\n# define sk_X509_LOOKUP_delete_ptr(st, ptr) SKM_sk_delete_ptr(X509_LOOKUP, (st), (ptr))\n# define sk_X509_LOOKUP_insert(st, val, i) SKM_sk_insert(X509_LOOKUP, (st), (val), (i))\n# define sk_X509_LOOKUP_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(X509_LOOKUP, (st), (cmp))\n# define sk_X509_LOOKUP_dup(st) SKM_sk_dup(X509_LOOKUP, st)\n# define sk_X509_LOOKUP_pop_free(st, free_func) SKM_sk_pop_free(X509_LOOKUP, (st), (free_func))\n# define sk_X509_LOOKUP_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(X509_LOOKUP, (st), (copy_func), (free_func))\n# define sk_X509_LOOKUP_shift(st) SKM_sk_shift(X509_LOOKUP, (st))\n# define sk_X509_LOOKUP_pop(st) SKM_sk_pop(X509_LOOKUP, (st))\n# define sk_X509_LOOKUP_sort(st) SKM_sk_sort(X509_LOOKUP, (st))\n# define sk_X509_LOOKUP_is_sorted(st) SKM_sk_is_sorted(X509_LOOKUP, (st))\n# define sk_X509_NAME_new(cmp) SKM_sk_new(X509_NAME, (cmp))\n# define sk_X509_NAME_new_null() SKM_sk_new_null(X509_NAME)\n# define sk_X509_NAME_free(st) SKM_sk_free(X509_NAME, (st))\n# define sk_X509_NAME_num(st) SKM_sk_num(X509_NAME, (st))\n# define sk_X509_NAME_value(st, i) SKM_sk_value(X509_NAME, (st), (i))\n# define sk_X509_NAME_set(st, i, val) SKM_sk_set(X509_NAME, (st), (i), (val))\n# define sk_X509_NAME_zero(st) SKM_sk_zero(X509_NAME, (st))\n# define sk_X509_NAME_push(st, val) SKM_sk_push(X509_NAME, (st), (val))\n# define sk_X509_NAME_unshift(st, val) SKM_sk_unshift(X509_NAME, (st), (val))\n# define sk_X509_NAME_find(st, val) SKM_sk_find(X509_NAME, (st), (val))\n# define sk_X509_NAME_find_ex(st, val) SKM_sk_find_ex(X509_NAME, (st), (val))\n# define sk_X509_NAME_delete(st, i) SKM_sk_delete(X509_NAME, (st), (i))\n# define sk_X509_NAME_delete_ptr(st, ptr) SKM_sk_delete_ptr(X509_NAME, (st), (ptr))\n# define sk_X509_NAME_insert(st, val, i) SKM_sk_insert(X509_NAME, (st), (val), (i))\n# define sk_X509_NAME_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(X509_NAME, (st), (cmp))\n# define sk_X509_NAME_dup(st) SKM_sk_dup(X509_NAME, st)\n# define sk_X509_NAME_pop_free(st, free_func) SKM_sk_pop_free(X509_NAME, (st), (free_func))\n# define sk_X509_NAME_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(X509_NAME, (st), (copy_func), (free_func))\n# define sk_X509_NAME_shift(st) SKM_sk_shift(X509_NAME, (st))\n# define sk_X509_NAME_pop(st) SKM_sk_pop(X509_NAME, (st))\n# define sk_X509_NAME_sort(st) SKM_sk_sort(X509_NAME, (st))\n# define sk_X509_NAME_is_sorted(st) SKM_sk_is_sorted(X509_NAME, (st))\n# define sk_X509_NAME_ENTRY_new(cmp) SKM_sk_new(X509_NAME_ENTRY, (cmp))\n# define sk_X509_NAME_ENTRY_new_null() SKM_sk_new_null(X509_NAME_ENTRY)\n# define sk_X509_NAME_ENTRY_free(st) SKM_sk_free(X509_NAME_ENTRY, (st))\n# define sk_X509_NAME_ENTRY_num(st) SKM_sk_num(X509_NAME_ENTRY, (st))\n# define sk_X509_NAME_ENTRY_value(st, i) SKM_sk_value(X509_NAME_ENTRY, (st), (i))\n# define sk_X509_NAME_ENTRY_set(st, i, val) SKM_sk_set(X509_NAME_ENTRY, (st), (i), (val))\n# define sk_X509_NAME_ENTRY_zero(st) SKM_sk_zero(X509_NAME_ENTRY, (st))\n# define sk_X509_NAME_ENTRY_push(st, val) SKM_sk_push(X509_NAME_ENTRY, (st), (val))\n# define sk_X509_NAME_ENTRY_unshift(st, val) SKM_sk_unshift(X509_NAME_ENTRY, (st), (val))\n# define sk_X509_NAME_ENTRY_find(st, val) SKM_sk_find(X509_NAME_ENTRY, (st), (val))\n# define sk_X509_NAME_ENTRY_find_ex(st, val) SKM_sk_find_ex(X509_NAME_ENTRY, (st), (val))\n# define sk_X509_NAME_ENTRY_delete(st, i) SKM_sk_delete(X509_NAME_ENTRY, (st), (i))\n# define sk_X509_NAME_ENTRY_delete_ptr(st, ptr) SKM_sk_delete_ptr(X509_NAME_ENTRY, (st), (ptr))\n# define sk_X509_NAME_ENTRY_insert(st, val, i) SKM_sk_insert(X509_NAME_ENTRY, (st), (val), (i))\n# define sk_X509_NAME_ENTRY_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(X509_NAME_ENTRY, (st), (cmp))\n# define sk_X509_NAME_ENTRY_dup(st) SKM_sk_dup(X509_NAME_ENTRY, st)\n# define sk_X509_NAME_ENTRY_pop_free(st, free_func) SKM_sk_pop_free(X509_NAME_ENTRY, (st), (free_func))\n# define sk_X509_NAME_ENTRY_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(X509_NAME_ENTRY, (st), (copy_func), (free_func))\n# define sk_X509_NAME_ENTRY_shift(st) SKM_sk_shift(X509_NAME_ENTRY, (st))\n# define sk_X509_NAME_ENTRY_pop(st) SKM_sk_pop(X509_NAME_ENTRY, (st))\n# define sk_X509_NAME_ENTRY_sort(st) SKM_sk_sort(X509_NAME_ENTRY, (st))\n# define sk_X509_NAME_ENTRY_is_sorted(st) SKM_sk_is_sorted(X509_NAME_ENTRY, (st))\n# define sk_X509_OBJECT_new(cmp) SKM_sk_new(X509_OBJECT, (cmp))\n# define sk_X509_OBJECT_new_null() SKM_sk_new_null(X509_OBJECT)\n# define sk_X509_OBJECT_free(st) SKM_sk_free(X509_OBJECT, (st))\n# define sk_X509_OBJECT_num(st) SKM_sk_num(X509_OBJECT, (st))\n# define sk_X509_OBJECT_value(st, i) SKM_sk_value(X509_OBJECT, (st), (i))\n# define sk_X509_OBJECT_set(st, i, val) SKM_sk_set(X509_OBJECT, (st), (i), (val))\n# define sk_X509_OBJECT_zero(st) SKM_sk_zero(X509_OBJECT, (st))\n# define sk_X509_OBJECT_push(st, val) SKM_sk_push(X509_OBJECT, (st), (val))\n# define sk_X509_OBJECT_unshift(st, val) SKM_sk_unshift(X509_OBJECT, (st), (val))\n# define sk_X509_OBJECT_find(st, val) SKM_sk_find(X509_OBJECT, (st), (val))\n# define sk_X509_OBJECT_find_ex(st, val) SKM_sk_find_ex(X509_OBJECT, (st), (val))\n# define sk_X509_OBJECT_delete(st, i) SKM_sk_delete(X509_OBJECT, (st), (i))\n# define sk_X509_OBJECT_delete_ptr(st, ptr) SKM_sk_delete_ptr(X509_OBJECT, (st), (ptr))\n# define sk_X509_OBJECT_insert(st, val, i) SKM_sk_insert(X509_OBJECT, (st), (val), (i))\n# define sk_X509_OBJECT_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(X509_OBJECT, (st), (cmp))\n# define sk_X509_OBJECT_dup(st) SKM_sk_dup(X509_OBJECT, st)\n# define sk_X509_OBJECT_pop_free(st, free_func) SKM_sk_pop_free(X509_OBJECT, (st), (free_func))\n# define sk_X509_OBJECT_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(X509_OBJECT, (st), (copy_func), (free_func))\n# define sk_X509_OBJECT_shift(st) SKM_sk_shift(X509_OBJECT, (st))\n# define sk_X509_OBJECT_pop(st) SKM_sk_pop(X509_OBJECT, (st))\n# define sk_X509_OBJECT_sort(st) SKM_sk_sort(X509_OBJECT, (st))\n# define sk_X509_OBJECT_is_sorted(st) SKM_sk_is_sorted(X509_OBJECT, (st))\n# define sk_X509_POLICY_DATA_new(cmp) SKM_sk_new(X509_POLICY_DATA, (cmp))\n# define sk_X509_POLICY_DATA_new_null() SKM_sk_new_null(X509_POLICY_DATA)\n# define sk_X509_POLICY_DATA_free(st) SKM_sk_free(X509_POLICY_DATA, (st))\n# define sk_X509_POLICY_DATA_num(st) SKM_sk_num(X509_POLICY_DATA, (st))\n# define sk_X509_POLICY_DATA_value(st, i) SKM_sk_value(X509_POLICY_DATA, (st), (i))\n# define sk_X509_POLICY_DATA_set(st, i, val) SKM_sk_set(X509_POLICY_DATA, (st), (i), (val))\n# define sk_X509_POLICY_DATA_zero(st) SKM_sk_zero(X509_POLICY_DATA, (st))\n# define sk_X509_POLICY_DATA_push(st, val) SKM_sk_push(X509_POLICY_DATA, (st), (val))\n# define sk_X509_POLICY_DATA_unshift(st, val) SKM_sk_unshift(X509_POLICY_DATA, (st), (val))\n# define sk_X509_POLICY_DATA_find(st, val) SKM_sk_find(X509_POLICY_DATA, (st), (val))\n# define sk_X509_POLICY_DATA_find_ex(st, val) SKM_sk_find_ex(X509_POLICY_DATA, (st), (val))\n# define sk_X509_POLICY_DATA_delete(st, i) SKM_sk_delete(X509_POLICY_DATA, (st), (i))\n# define sk_X509_POLICY_DATA_delete_ptr(st, ptr) SKM_sk_delete_ptr(X509_POLICY_DATA, (st), (ptr))\n# define sk_X509_POLICY_DATA_insert(st, val, i) SKM_sk_insert(X509_POLICY_DATA, (st), (val), (i))\n# define sk_X509_POLICY_DATA_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(X509_POLICY_DATA, (st), (cmp))\n# define sk_X509_POLICY_DATA_dup(st) SKM_sk_dup(X509_POLICY_DATA, st)\n# define sk_X509_POLICY_DATA_pop_free(st, free_func) SKM_sk_pop_free(X509_POLICY_DATA, (st), (free_func))\n# define sk_X509_POLICY_DATA_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(X509_POLICY_DATA, (st), (copy_func), (free_func))\n# define sk_X509_POLICY_DATA_shift(st) SKM_sk_shift(X509_POLICY_DATA, (st))\n# define sk_X509_POLICY_DATA_pop(st) SKM_sk_pop(X509_POLICY_DATA, (st))\n# define sk_X509_POLICY_DATA_sort(st) SKM_sk_sort(X509_POLICY_DATA, (st))\n# define sk_X509_POLICY_DATA_is_sorted(st) SKM_sk_is_sorted(X509_POLICY_DATA, (st))\n# define sk_X509_POLICY_NODE_new(cmp) SKM_sk_new(X509_POLICY_NODE, (cmp))\n# define sk_X509_POLICY_NODE_new_null() SKM_sk_new_null(X509_POLICY_NODE)\n# define sk_X509_POLICY_NODE_free(st) SKM_sk_free(X509_POLICY_NODE, (st))\n# define sk_X509_POLICY_NODE_num(st) SKM_sk_num(X509_POLICY_NODE, (st))\n# define sk_X509_POLICY_NODE_value(st, i) SKM_sk_value(X509_POLICY_NODE, (st), (i))\n# define sk_X509_POLICY_NODE_set(st, i, val) SKM_sk_set(X509_POLICY_NODE, (st), (i), (val))\n# define sk_X509_POLICY_NODE_zero(st) SKM_sk_zero(X509_POLICY_NODE, (st))\n# define sk_X509_POLICY_NODE_push(st, val) SKM_sk_push(X509_POLICY_NODE, (st), (val))\n# define sk_X509_POLICY_NODE_unshift(st, val) SKM_sk_unshift(X509_POLICY_NODE, (st), (val))\n# define sk_X509_POLICY_NODE_find(st, val) SKM_sk_find(X509_POLICY_NODE, (st), (val))\n# define sk_X509_POLICY_NODE_find_ex(st, val) SKM_sk_find_ex(X509_POLICY_NODE, (st), (val))\n# define sk_X509_POLICY_NODE_delete(st, i) SKM_sk_delete(X509_POLICY_NODE, (st), (i))\n# define sk_X509_POLICY_NODE_delete_ptr(st, ptr) SKM_sk_delete_ptr(X509_POLICY_NODE, (st), (ptr))\n# define sk_X509_POLICY_NODE_insert(st, val, i) SKM_sk_insert(X509_POLICY_NODE, (st), (val), (i))\n# define sk_X509_POLICY_NODE_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(X509_POLICY_NODE, (st), (cmp))\n# define sk_X509_POLICY_NODE_dup(st) SKM_sk_dup(X509_POLICY_NODE, st)\n# define sk_X509_POLICY_NODE_pop_free(st, free_func) SKM_sk_pop_free(X509_POLICY_NODE, (st), (free_func))\n# define sk_X509_POLICY_NODE_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(X509_POLICY_NODE, (st), (copy_func), (free_func))\n# define sk_X509_POLICY_NODE_shift(st) SKM_sk_shift(X509_POLICY_NODE, (st))\n# define sk_X509_POLICY_NODE_pop(st) SKM_sk_pop(X509_POLICY_NODE, (st))\n# define sk_X509_POLICY_NODE_sort(st) SKM_sk_sort(X509_POLICY_NODE, (st))\n# define sk_X509_POLICY_NODE_is_sorted(st) SKM_sk_is_sorted(X509_POLICY_NODE, (st))\n# define sk_X509_PURPOSE_new(cmp) SKM_sk_new(X509_PURPOSE, (cmp))\n# define sk_X509_PURPOSE_new_null() SKM_sk_new_null(X509_PURPOSE)\n# define sk_X509_PURPOSE_free(st) SKM_sk_free(X509_PURPOSE, (st))\n# define sk_X509_PURPOSE_num(st) SKM_sk_num(X509_PURPOSE, (st))\n# define sk_X509_PURPOSE_value(st, i) SKM_sk_value(X509_PURPOSE, (st), (i))\n# define sk_X509_PURPOSE_set(st, i, val) SKM_sk_set(X509_PURPOSE, (st), (i), (val))\n# define sk_X509_PURPOSE_zero(st) SKM_sk_zero(X509_PURPOSE, (st))\n# define sk_X509_PURPOSE_push(st, val) SKM_sk_push(X509_PURPOSE, (st), (val))\n# define sk_X509_PURPOSE_unshift(st, val) SKM_sk_unshift(X509_PURPOSE, (st), (val))\n# define sk_X509_PURPOSE_find(st, val) SKM_sk_find(X509_PURPOSE, (st), (val))\n# define sk_X509_PURPOSE_find_ex(st, val) SKM_sk_find_ex(X509_PURPOSE, (st), (val))\n# define sk_X509_PURPOSE_delete(st, i) SKM_sk_delete(X509_PURPOSE, (st), (i))\n# define sk_X509_PURPOSE_delete_ptr(st, ptr) SKM_sk_delete_ptr(X509_PURPOSE, (st), (ptr))\n# define sk_X509_PURPOSE_insert(st, val, i) SKM_sk_insert(X509_PURPOSE, (st), (val), (i))\n# define sk_X509_PURPOSE_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(X509_PURPOSE, (st), (cmp))\n# define sk_X509_PURPOSE_dup(st) SKM_sk_dup(X509_PURPOSE, st)\n# define sk_X509_PURPOSE_pop_free(st, free_func) SKM_sk_pop_free(X509_PURPOSE, (st), (free_func))\n# define sk_X509_PURPOSE_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(X509_PURPOSE, (st), (copy_func), (free_func))\n# define sk_X509_PURPOSE_shift(st) SKM_sk_shift(X509_PURPOSE, (st))\n# define sk_X509_PURPOSE_pop(st) SKM_sk_pop(X509_PURPOSE, (st))\n# define sk_X509_PURPOSE_sort(st) SKM_sk_sort(X509_PURPOSE, (st))\n# define sk_X509_PURPOSE_is_sorted(st) SKM_sk_is_sorted(X509_PURPOSE, (st))\n# define sk_X509_REVOKED_new(cmp) SKM_sk_new(X509_REVOKED, (cmp))\n# define sk_X509_REVOKED_new_null() SKM_sk_new_null(X509_REVOKED)\n# define sk_X509_REVOKED_free(st) SKM_sk_free(X509_REVOKED, (st))\n# define sk_X509_REVOKED_num(st) SKM_sk_num(X509_REVOKED, (st))\n# define sk_X509_REVOKED_value(st, i) SKM_sk_value(X509_REVOKED, (st), (i))\n# define sk_X509_REVOKED_set(st, i, val) SKM_sk_set(X509_REVOKED, (st), (i), (val))\n# define sk_X509_REVOKED_zero(st) SKM_sk_zero(X509_REVOKED, (st))\n# define sk_X509_REVOKED_push(st, val) SKM_sk_push(X509_REVOKED, (st), (val))\n# define sk_X509_REVOKED_unshift(st, val) SKM_sk_unshift(X509_REVOKED, (st), (val))\n# define sk_X509_REVOKED_find(st, val) SKM_sk_find(X509_REVOKED, (st), (val))\n# define sk_X509_REVOKED_find_ex(st, val) SKM_sk_find_ex(X509_REVOKED, (st), (val))\n# define sk_X509_REVOKED_delete(st, i) SKM_sk_delete(X509_REVOKED, (st), (i))\n# define sk_X509_REVOKED_delete_ptr(st, ptr) SKM_sk_delete_ptr(X509_REVOKED, (st), (ptr))\n# define sk_X509_REVOKED_insert(st, val, i) SKM_sk_insert(X509_REVOKED, (st), (val), (i))\n# define sk_X509_REVOKED_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(X509_REVOKED, (st), (cmp))\n# define sk_X509_REVOKED_dup(st) SKM_sk_dup(X509_REVOKED, st)\n# define sk_X509_REVOKED_pop_free(st, free_func) SKM_sk_pop_free(X509_REVOKED, (st), (free_func))\n# define sk_X509_REVOKED_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(X509_REVOKED, (st), (copy_func), (free_func))\n# define sk_X509_REVOKED_shift(st) SKM_sk_shift(X509_REVOKED, (st))\n# define sk_X509_REVOKED_pop(st) SKM_sk_pop(X509_REVOKED, (st))\n# define sk_X509_REVOKED_sort(st) SKM_sk_sort(X509_REVOKED, (st))\n# define sk_X509_REVOKED_is_sorted(st) SKM_sk_is_sorted(X509_REVOKED, (st))\n# define sk_X509_TRUST_new(cmp) SKM_sk_new(X509_TRUST, (cmp))\n# define sk_X509_TRUST_new_null() SKM_sk_new_null(X509_TRUST)\n# define sk_X509_TRUST_free(st) SKM_sk_free(X509_TRUST, (st))\n# define sk_X509_TRUST_num(st) SKM_sk_num(X509_TRUST, (st))\n# define sk_X509_TRUST_value(st, i) SKM_sk_value(X509_TRUST, (st), (i))\n# define sk_X509_TRUST_set(st, i, val) SKM_sk_set(X509_TRUST, (st), (i), (val))\n# define sk_X509_TRUST_zero(st) SKM_sk_zero(X509_TRUST, (st))\n# define sk_X509_TRUST_push(st, val) SKM_sk_push(X509_TRUST, (st), (val))\n# define sk_X509_TRUST_unshift(st, val) SKM_sk_unshift(X509_TRUST, (st), (val))\n# define sk_X509_TRUST_find(st, val) SKM_sk_find(X509_TRUST, (st), (val))\n# define sk_X509_TRUST_find_ex(st, val) SKM_sk_find_ex(X509_TRUST, (st), (val))\n# define sk_X509_TRUST_delete(st, i) SKM_sk_delete(X509_TRUST, (st), (i))\n# define sk_X509_TRUST_delete_ptr(st, ptr) SKM_sk_delete_ptr(X509_TRUST, (st), (ptr))\n# define sk_X509_TRUST_insert(st, val, i) SKM_sk_insert(X509_TRUST, (st), (val), (i))\n# define sk_X509_TRUST_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(X509_TRUST, (st), (cmp))\n# define sk_X509_TRUST_dup(st) SKM_sk_dup(X509_TRUST, st)\n# define sk_X509_TRUST_pop_free(st, free_func) SKM_sk_pop_free(X509_TRUST, (st), (free_func))\n# define sk_X509_TRUST_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(X509_TRUST, (st), (copy_func), (free_func))\n# define sk_X509_TRUST_shift(st) SKM_sk_shift(X509_TRUST, (st))\n# define sk_X509_TRUST_pop(st) SKM_sk_pop(X509_TRUST, (st))\n# define sk_X509_TRUST_sort(st) SKM_sk_sort(X509_TRUST, (st))\n# define sk_X509_TRUST_is_sorted(st) SKM_sk_is_sorted(X509_TRUST, (st))\n# define sk_X509_VERIFY_PARAM_new(cmp) SKM_sk_new(X509_VERIFY_PARAM, (cmp))\n# define sk_X509_VERIFY_PARAM_new_null() SKM_sk_new_null(X509_VERIFY_PARAM)\n# define sk_X509_VERIFY_PARAM_free(st) SKM_sk_free(X509_VERIFY_PARAM, (st))\n# define sk_X509_VERIFY_PARAM_num(st) SKM_sk_num(X509_VERIFY_PARAM, (st))\n# define sk_X509_VERIFY_PARAM_value(st, i) SKM_sk_value(X509_VERIFY_PARAM, (st), (i))\n# define sk_X509_VERIFY_PARAM_set(st, i, val) SKM_sk_set(X509_VERIFY_PARAM, (st), (i), (val))\n# define sk_X509_VERIFY_PARAM_zero(st) SKM_sk_zero(X509_VERIFY_PARAM, (st))\n# define sk_X509_VERIFY_PARAM_push(st, val) SKM_sk_push(X509_VERIFY_PARAM, (st), (val))\n# define sk_X509_VERIFY_PARAM_unshift(st, val) SKM_sk_unshift(X509_VERIFY_PARAM, (st), (val))\n# define sk_X509_VERIFY_PARAM_find(st, val) SKM_sk_find(X509_VERIFY_PARAM, (st), (val))\n# define sk_X509_VERIFY_PARAM_find_ex(st, val) SKM_sk_find_ex(X509_VERIFY_PARAM, (st), (val))\n# define sk_X509_VERIFY_PARAM_delete(st, i) SKM_sk_delete(X509_VERIFY_PARAM, (st), (i))\n# define sk_X509_VERIFY_PARAM_delete_ptr(st, ptr) SKM_sk_delete_ptr(X509_VERIFY_PARAM, (st), (ptr))\n# define sk_X509_VERIFY_PARAM_insert(st, val, i) SKM_sk_insert(X509_VERIFY_PARAM, (st), (val), (i))\n# define sk_X509_VERIFY_PARAM_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(X509_VERIFY_PARAM, (st), (cmp))\n# define sk_X509_VERIFY_PARAM_dup(st) SKM_sk_dup(X509_VERIFY_PARAM, st)\n# define sk_X509_VERIFY_PARAM_pop_free(st, free_func) SKM_sk_pop_free(X509_VERIFY_PARAM, (st), (free_func))\n# define sk_X509_VERIFY_PARAM_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(X509_VERIFY_PARAM, (st), (copy_func), (free_func))\n# define sk_X509_VERIFY_PARAM_shift(st) SKM_sk_shift(X509_VERIFY_PARAM, (st))\n# define sk_X509_VERIFY_PARAM_pop(st) SKM_sk_pop(X509_VERIFY_PARAM, (st))\n# define sk_X509_VERIFY_PARAM_sort(st) SKM_sk_sort(X509_VERIFY_PARAM, (st))\n# define sk_X509_VERIFY_PARAM_is_sorted(st) SKM_sk_is_sorted(X509_VERIFY_PARAM, (st))\n# define sk_nid_triple_new(cmp) SKM_sk_new(nid_triple, (cmp))\n# define sk_nid_triple_new_null() SKM_sk_new_null(nid_triple)\n# define sk_nid_triple_free(st) SKM_sk_free(nid_triple, (st))\n# define sk_nid_triple_num(st) SKM_sk_num(nid_triple, (st))\n# define sk_nid_triple_value(st, i) SKM_sk_value(nid_triple, (st), (i))\n# define sk_nid_triple_set(st, i, val) SKM_sk_set(nid_triple, (st), (i), (val))\n# define sk_nid_triple_zero(st) SKM_sk_zero(nid_triple, (st))\n# define sk_nid_triple_push(st, val) SKM_sk_push(nid_triple, (st), (val))\n# define sk_nid_triple_unshift(st, val) SKM_sk_unshift(nid_triple, (st), (val))\n# define sk_nid_triple_find(st, val) SKM_sk_find(nid_triple, (st), (val))\n# define sk_nid_triple_find_ex(st, val) SKM_sk_find_ex(nid_triple, (st), (val))\n# define sk_nid_triple_delete(st, i) SKM_sk_delete(nid_triple, (st), (i))\n# define sk_nid_triple_delete_ptr(st, ptr) SKM_sk_delete_ptr(nid_triple, (st), (ptr))\n# define sk_nid_triple_insert(st, val, i) SKM_sk_insert(nid_triple, (st), (val), (i))\n# define sk_nid_triple_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(nid_triple, (st), (cmp))\n# define sk_nid_triple_dup(st) SKM_sk_dup(nid_triple, st)\n# define sk_nid_triple_pop_free(st, free_func) SKM_sk_pop_free(nid_triple, (st), (free_func))\n# define sk_nid_triple_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(nid_triple, (st), (copy_func), (free_func))\n# define sk_nid_triple_shift(st) SKM_sk_shift(nid_triple, (st))\n# define sk_nid_triple_pop(st) SKM_sk_pop(nid_triple, (st))\n# define sk_nid_triple_sort(st) SKM_sk_sort(nid_triple, (st))\n# define sk_nid_triple_is_sorted(st) SKM_sk_is_sorted(nid_triple, (st))\n# define sk_void_new(cmp) SKM_sk_new(void, (cmp))\n# define sk_void_new_null() SKM_sk_new_null(void)\n# define sk_void_free(st) SKM_sk_free(void, (st))\n# define sk_void_num(st) SKM_sk_num(void, (st))\n# define sk_void_value(st, i) SKM_sk_value(void, (st), (i))\n# define sk_void_set(st, i, val) SKM_sk_set(void, (st), (i), (val))\n# define sk_void_zero(st) SKM_sk_zero(void, (st))\n# define sk_void_push(st, val) SKM_sk_push(void, (st), (val))\n# define sk_void_unshift(st, val) SKM_sk_unshift(void, (st), (val))\n# define sk_void_find(st, val) SKM_sk_find(void, (st), (val))\n# define sk_void_find_ex(st, val) SKM_sk_find_ex(void, (st), (val))\n# define sk_void_delete(st, i) SKM_sk_delete(void, (st), (i))\n# define sk_void_delete_ptr(st, ptr) SKM_sk_delete_ptr(void, (st), (ptr))\n# define sk_void_insert(st, val, i) SKM_sk_insert(void, (st), (val), (i))\n# define sk_void_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(void, (st), (cmp))\n# define sk_void_dup(st) SKM_sk_dup(void, st)\n# define sk_void_pop_free(st, free_func) SKM_sk_pop_free(void, (st), (free_func))\n# define sk_void_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(void, (st), (copy_func), (free_func))\n# define sk_void_shift(st) SKM_sk_shift(void, (st))\n# define sk_void_pop(st) SKM_sk_pop(void, (st))\n# define sk_void_sort(st) SKM_sk_sort(void, (st))\n# define sk_void_is_sorted(st) SKM_sk_is_sorted(void, (st))\n# define sk_OPENSSL_STRING_new(cmp) ((STACK_OF(OPENSSL_STRING) *)sk_new(CHECKED_SK_CMP_FUNC(char, cmp)))\n# define sk_OPENSSL_STRING_new_null() ((STACK_OF(OPENSSL_STRING) *)sk_new_null())\n# define sk_OPENSSL_STRING_push(st, val) sk_push(CHECKED_STACK_OF(OPENSSL_STRING, st), CHECKED_PTR_OF(char, val))\n# define sk_OPENSSL_STRING_find(st, val) sk_find(CHECKED_STACK_OF(OPENSSL_STRING, st), CHECKED_PTR_OF(char, val))\n# define sk_OPENSSL_STRING_value(st, i) ((OPENSSL_STRING)sk_value(CHECKED_STACK_OF(OPENSSL_STRING, st), i))\n# define sk_OPENSSL_STRING_num(st) SKM_sk_num(OPENSSL_STRING, st)\n# define sk_OPENSSL_STRING_pop_free(st, free_func) sk_pop_free(CHECKED_STACK_OF(OPENSSL_STRING, st), CHECKED_SK_FREE_FUNC(char, free_func))\n# define sk_OPENSSL_STRING_deep_copy(st, copy_func, free_func) ((STACK_OF(OPENSSL_STRING) *)sk_deep_copy(CHECKED_STACK_OF(OPENSSL_STRING, st), CHECKED_SK_COPY_FUNC(char, copy_func), CHECKED_SK_FREE_FUNC(char, free_func)))\n# define sk_OPENSSL_STRING_insert(st, val, i) sk_insert(CHECKED_STACK_OF(OPENSSL_STRING, st), CHECKED_PTR_OF(char, val), i)\n# define sk_OPENSSL_STRING_free(st) SKM_sk_free(OPENSSL_STRING, st)\n# define sk_OPENSSL_STRING_set(st, i, val) sk_set(CHECKED_STACK_OF(OPENSSL_STRING, st), i, CHECKED_PTR_OF(char, val))\n# define sk_OPENSSL_STRING_zero(st) SKM_sk_zero(OPENSSL_STRING, (st))\n# define sk_OPENSSL_STRING_unshift(st, val) sk_unshift(CHECKED_STACK_OF(OPENSSL_STRING, st), CHECKED_PTR_OF(char, val))\n# define sk_OPENSSL_STRING_find_ex(st, val) sk_find_ex((_STACK *)CHECKED_CONST_PTR_OF(STACK_OF(OPENSSL_STRING), st), CHECKED_CONST_PTR_OF(char, val))\n# define sk_OPENSSL_STRING_delete(st, i) SKM_sk_delete(OPENSSL_STRING, (st), (i))\n# define sk_OPENSSL_STRING_delete_ptr(st, ptr) (OPENSSL_STRING *)sk_delete_ptr(CHECKED_STACK_OF(OPENSSL_STRING, st), CHECKED_PTR_OF(char, ptr))\n# define sk_OPENSSL_STRING_set_cmp_func(st, cmp)  \\\n        ((int (*)(const char * const *,const char * const *)) \\\n        sk_set_cmp_func(CHECKED_STACK_OF(OPENSSL_STRING, st), CHECKED_SK_CMP_FUNC(char, cmp)))\n# define sk_OPENSSL_STRING_dup(st) SKM_sk_dup(OPENSSL_STRING, st)\n# define sk_OPENSSL_STRING_shift(st) SKM_sk_shift(OPENSSL_STRING, (st))\n# define sk_OPENSSL_STRING_pop(st) (char *)sk_pop(CHECKED_STACK_OF(OPENSSL_STRING, st))\n# define sk_OPENSSL_STRING_sort(st) SKM_sk_sort(OPENSSL_STRING, (st))\n# define sk_OPENSSL_STRING_is_sorted(st) SKM_sk_is_sorted(OPENSSL_STRING, (st))\n# define sk_OPENSSL_BLOCK_new(cmp) ((STACK_OF(OPENSSL_BLOCK) *)sk_new(CHECKED_SK_CMP_FUNC(void, cmp)))\n# define sk_OPENSSL_BLOCK_new_null() ((STACK_OF(OPENSSL_BLOCK) *)sk_new_null())\n# define sk_OPENSSL_BLOCK_push(st, val) sk_push(CHECKED_STACK_OF(OPENSSL_BLOCK, st), CHECKED_PTR_OF(void, val))\n# define sk_OPENSSL_BLOCK_find(st, val) sk_find(CHECKED_STACK_OF(OPENSSL_BLOCK, st), CHECKED_PTR_OF(void, val))\n# define sk_OPENSSL_BLOCK_value(st, i) ((OPENSSL_BLOCK)sk_value(CHECKED_STACK_OF(OPENSSL_BLOCK, st), i))\n# define sk_OPENSSL_BLOCK_num(st) SKM_sk_num(OPENSSL_BLOCK, st)\n# define sk_OPENSSL_BLOCK_pop_free(st, free_func) sk_pop_free(CHECKED_STACK_OF(OPENSSL_BLOCK, st), CHECKED_SK_FREE_FUNC(void, free_func))\n# define sk_OPENSSL_BLOCK_deep_copy(st, copy_func, free_func) ((STACK_OF(OPENSSL_BLOCK) *)sk_deep_copy(CHECKED_STACK_OF(OPENSSL_BLOCK, st), CHECKED_SK_COPY_FUNC(void, copy_func), CHECKED_SK_FREE_FUNC(void, free_func)))\n# define sk_OPENSSL_BLOCK_insert(st, val, i) sk_insert(CHECKED_STACK_OF(OPENSSL_BLOCK, st), CHECKED_PTR_OF(void, val), i)\n# define sk_OPENSSL_BLOCK_free(st) SKM_sk_free(OPENSSL_BLOCK, st)\n# define sk_OPENSSL_BLOCK_set(st, i, val) sk_set(CHECKED_STACK_OF(OPENSSL_BLOCK, st), i, CHECKED_PTR_OF(void, val))\n# define sk_OPENSSL_BLOCK_zero(st) SKM_sk_zero(OPENSSL_BLOCK, (st))\n# define sk_OPENSSL_BLOCK_unshift(st, val) sk_unshift(CHECKED_STACK_OF(OPENSSL_BLOCK, st), CHECKED_PTR_OF(void, val))\n# define sk_OPENSSL_BLOCK_find_ex(st, val) sk_find_ex((_STACK *)CHECKED_CONST_PTR_OF(STACK_OF(OPENSSL_BLOCK), st), CHECKED_CONST_PTR_OF(void, val))\n# define sk_OPENSSL_BLOCK_delete(st, i) SKM_sk_delete(OPENSSL_BLOCK, (st), (i))\n# define sk_OPENSSL_BLOCK_delete_ptr(st, ptr) (OPENSSL_BLOCK *)sk_delete_ptr(CHECKED_STACK_OF(OPENSSL_BLOCK, st), CHECKED_PTR_OF(void, ptr))\n# define sk_OPENSSL_BLOCK_set_cmp_func(st, cmp)  \\\n        ((int (*)(const void * const *,const void * const *)) \\\n        sk_set_cmp_func(CHECKED_STACK_OF(OPENSSL_BLOCK, st), CHECKED_SK_CMP_FUNC(void, cmp)))\n# define sk_OPENSSL_BLOCK_dup(st) SKM_sk_dup(OPENSSL_BLOCK, st)\n# define sk_OPENSSL_BLOCK_shift(st) SKM_sk_shift(OPENSSL_BLOCK, (st))\n# define sk_OPENSSL_BLOCK_pop(st) (void *)sk_pop(CHECKED_STACK_OF(OPENSSL_BLOCK, st))\n# define sk_OPENSSL_BLOCK_sort(st) SKM_sk_sort(OPENSSL_BLOCK, (st))\n# define sk_OPENSSL_BLOCK_is_sorted(st) SKM_sk_is_sorted(OPENSSL_BLOCK, (st))\n# define sk_OPENSSL_PSTRING_new(cmp) ((STACK_OF(OPENSSL_PSTRING) *)sk_new(CHECKED_SK_CMP_FUNC(OPENSSL_STRING, cmp)))\n# define sk_OPENSSL_PSTRING_new_null() ((STACK_OF(OPENSSL_PSTRING) *)sk_new_null())\n# define sk_OPENSSL_PSTRING_push(st, val) sk_push(CHECKED_STACK_OF(OPENSSL_PSTRING, st), CHECKED_PTR_OF(OPENSSL_STRING, val))\n# define sk_OPENSSL_PSTRING_find(st, val) sk_find(CHECKED_STACK_OF(OPENSSL_PSTRING, st), CHECKED_PTR_OF(OPENSSL_STRING, val))\n# define sk_OPENSSL_PSTRING_value(st, i) ((OPENSSL_PSTRING)sk_value(CHECKED_STACK_OF(OPENSSL_PSTRING, st), i))\n# define sk_OPENSSL_PSTRING_num(st) SKM_sk_num(OPENSSL_PSTRING, st)\n# define sk_OPENSSL_PSTRING_pop_free(st, free_func) sk_pop_free(CHECKED_STACK_OF(OPENSSL_PSTRING, st), CHECKED_SK_FREE_FUNC(OPENSSL_STRING, free_func))\n# define sk_OPENSSL_PSTRING_deep_copy(st, copy_func, free_func) ((STACK_OF(OPENSSL_PSTRING) *)sk_deep_copy(CHECKED_STACK_OF(OPENSSL_PSTRING, st), CHECKED_SK_COPY_FUNC(OPENSSL_STRING, copy_func), CHECKED_SK_FREE_FUNC(OPENSSL_STRING, free_func)))\n# define sk_OPENSSL_PSTRING_insert(st, val, i) sk_insert(CHECKED_STACK_OF(OPENSSL_PSTRING, st), CHECKED_PTR_OF(OPENSSL_STRING, val), i)\n# define sk_OPENSSL_PSTRING_free(st) SKM_sk_free(OPENSSL_PSTRING, st)\n# define sk_OPENSSL_PSTRING_set(st, i, val) sk_set(CHECKED_STACK_OF(OPENSSL_PSTRING, st), i, CHECKED_PTR_OF(OPENSSL_STRING, val))\n# define sk_OPENSSL_PSTRING_zero(st) SKM_sk_zero(OPENSSL_PSTRING, (st))\n# define sk_OPENSSL_PSTRING_unshift(st, val) sk_unshift(CHECKED_STACK_OF(OPENSSL_PSTRING, st), CHECKED_PTR_OF(OPENSSL_STRING, val))\n# define sk_OPENSSL_PSTRING_find_ex(st, val) sk_find_ex((_STACK *)CHECKED_CONST_PTR_OF(STACK_OF(OPENSSL_PSTRING), st), CHECKED_CONST_PTR_OF(OPENSSL_STRING, val))\n# define sk_OPENSSL_PSTRING_delete(st, i) SKM_sk_delete(OPENSSL_PSTRING, (st), (i))\n# define sk_OPENSSL_PSTRING_delete_ptr(st, ptr) (OPENSSL_PSTRING *)sk_delete_ptr(CHECKED_STACK_OF(OPENSSL_PSTRING, st), CHECKED_PTR_OF(OPENSSL_STRING, ptr))\n# define sk_OPENSSL_PSTRING_set_cmp_func(st, cmp)  \\\n        ((int (*)(const OPENSSL_STRING * const *,const OPENSSL_STRING * const *)) \\\n        sk_set_cmp_func(CHECKED_STACK_OF(OPENSSL_PSTRING, st), CHECKED_SK_CMP_FUNC(OPENSSL_STRING, cmp)))\n# define sk_OPENSSL_PSTRING_dup(st) SKM_sk_dup(OPENSSL_PSTRING, st)\n# define sk_OPENSSL_PSTRING_shift(st) SKM_sk_shift(OPENSSL_PSTRING, (st))\n# define sk_OPENSSL_PSTRING_pop(st) (OPENSSL_STRING *)sk_pop(CHECKED_STACK_OF(OPENSSL_PSTRING, st))\n# define sk_OPENSSL_PSTRING_sort(st) SKM_sk_sort(OPENSSL_PSTRING, (st))\n# define sk_OPENSSL_PSTRING_is_sorted(st) SKM_sk_is_sorted(OPENSSL_PSTRING, (st))\n# define d2i_ASN1_SET_OF_ACCESS_DESCRIPTION(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \\\n        SKM_ASN1_SET_OF_d2i(ACCESS_DESCRIPTION, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class))\n# define i2d_ASN1_SET_OF_ACCESS_DESCRIPTION(st, pp, i2d_func, ex_tag, ex_class, is_set) \\\n        SKM_ASN1_SET_OF_i2d(ACCESS_DESCRIPTION, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set))\n# define ASN1_seq_pack_ACCESS_DESCRIPTION(st, i2d_func, buf, len) \\\n        SKM_ASN1_seq_pack(ACCESS_DESCRIPTION, (st), (i2d_func), (buf), (len))\n# define ASN1_seq_unpack_ACCESS_DESCRIPTION(buf, len, d2i_func, free_func) \\\n        SKM_ASN1_seq_unpack(ACCESS_DESCRIPTION, (buf), (len), (d2i_func), (free_func))\n# define d2i_ASN1_SET_OF_ASN1_INTEGER(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \\\n        SKM_ASN1_SET_OF_d2i(ASN1_INTEGER, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class))\n# define i2d_ASN1_SET_OF_ASN1_INTEGER(st, pp, i2d_func, ex_tag, ex_class, is_set) \\\n        SKM_ASN1_SET_OF_i2d(ASN1_INTEGER, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set))\n# define ASN1_seq_pack_ASN1_INTEGER(st, i2d_func, buf, len) \\\n        SKM_ASN1_seq_pack(ASN1_INTEGER, (st), (i2d_func), (buf), (len))\n# define ASN1_seq_unpack_ASN1_INTEGER(buf, len, d2i_func, free_func) \\\n        SKM_ASN1_seq_unpack(ASN1_INTEGER, (buf), (len), (d2i_func), (free_func))\n# define d2i_ASN1_SET_OF_ASN1_OBJECT(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \\\n        SKM_ASN1_SET_OF_d2i(ASN1_OBJECT, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class))\n# define i2d_ASN1_SET_OF_ASN1_OBJECT(st, pp, i2d_func, ex_tag, ex_class, is_set) \\\n        SKM_ASN1_SET_OF_i2d(ASN1_OBJECT, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set))\n# define ASN1_seq_pack_ASN1_OBJECT(st, i2d_func, buf, len) \\\n        SKM_ASN1_seq_pack(ASN1_OBJECT, (st), (i2d_func), (buf), (len))\n# define ASN1_seq_unpack_ASN1_OBJECT(buf, len, d2i_func, free_func) \\\n        SKM_ASN1_seq_unpack(ASN1_OBJECT, (buf), (len), (d2i_func), (free_func))\n# define d2i_ASN1_SET_OF_ASN1_TYPE(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \\\n        SKM_ASN1_SET_OF_d2i(ASN1_TYPE, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class))\n# define i2d_ASN1_SET_OF_ASN1_TYPE(st, pp, i2d_func, ex_tag, ex_class, is_set) \\\n        SKM_ASN1_SET_OF_i2d(ASN1_TYPE, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set))\n# define ASN1_seq_pack_ASN1_TYPE(st, i2d_func, buf, len) \\\n        SKM_ASN1_seq_pack(ASN1_TYPE, (st), (i2d_func), (buf), (len))\n# define ASN1_seq_unpack_ASN1_TYPE(buf, len, d2i_func, free_func) \\\n        SKM_ASN1_seq_unpack(ASN1_TYPE, (buf), (len), (d2i_func), (free_func))\n# define d2i_ASN1_SET_OF_ASN1_UTF8STRING(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \\\n        SKM_ASN1_SET_OF_d2i(ASN1_UTF8STRING, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class))\n# define i2d_ASN1_SET_OF_ASN1_UTF8STRING(st, pp, i2d_func, ex_tag, ex_class, is_set) \\\n        SKM_ASN1_SET_OF_i2d(ASN1_UTF8STRING, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set))\n# define ASN1_seq_pack_ASN1_UTF8STRING(st, i2d_func, buf, len) \\\n        SKM_ASN1_seq_pack(ASN1_UTF8STRING, (st), (i2d_func), (buf), (len))\n# define ASN1_seq_unpack_ASN1_UTF8STRING(buf, len, d2i_func, free_func) \\\n        SKM_ASN1_seq_unpack(ASN1_UTF8STRING, (buf), (len), (d2i_func), (free_func))\n# define d2i_ASN1_SET_OF_DIST_POINT(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \\\n        SKM_ASN1_SET_OF_d2i(DIST_POINT, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class))\n# define i2d_ASN1_SET_OF_DIST_POINT(st, pp, i2d_func, ex_tag, ex_class, is_set) \\\n        SKM_ASN1_SET_OF_i2d(DIST_POINT, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set))\n# define ASN1_seq_pack_DIST_POINT(st, i2d_func, buf, len) \\\n        SKM_ASN1_seq_pack(DIST_POINT, (st), (i2d_func), (buf), (len))\n# define ASN1_seq_unpack_DIST_POINT(buf, len, d2i_func, free_func) \\\n        SKM_ASN1_seq_unpack(DIST_POINT, (buf), (len), (d2i_func), (free_func))\n# define d2i_ASN1_SET_OF_ESS_CERT_ID(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \\\n        SKM_ASN1_SET_OF_d2i(ESS_CERT_ID, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class))\n# define i2d_ASN1_SET_OF_ESS_CERT_ID(st, pp, i2d_func, ex_tag, ex_class, is_set) \\\n        SKM_ASN1_SET_OF_i2d(ESS_CERT_ID, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set))\n# define ASN1_seq_pack_ESS_CERT_ID(st, i2d_func, buf, len) \\\n        SKM_ASN1_seq_pack(ESS_CERT_ID, (st), (i2d_func), (buf), (len))\n# define ASN1_seq_unpack_ESS_CERT_ID(buf, len, d2i_func, free_func) \\\n        SKM_ASN1_seq_unpack(ESS_CERT_ID, (buf), (len), (d2i_func), (free_func))\n# define d2i_ASN1_SET_OF_EVP_MD(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \\\n        SKM_ASN1_SET_OF_d2i(EVP_MD, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class))\n# define i2d_ASN1_SET_OF_EVP_MD(st, pp, i2d_func, ex_tag, ex_class, is_set) \\\n        SKM_ASN1_SET_OF_i2d(EVP_MD, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set))\n# define ASN1_seq_pack_EVP_MD(st, i2d_func, buf, len) \\\n        SKM_ASN1_seq_pack(EVP_MD, (st), (i2d_func), (buf), (len))\n# define ASN1_seq_unpack_EVP_MD(buf, len, d2i_func, free_func) \\\n        SKM_ASN1_seq_unpack(EVP_MD, (buf), (len), (d2i_func), (free_func))\n# define d2i_ASN1_SET_OF_GENERAL_NAME(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \\\n        SKM_ASN1_SET_OF_d2i(GENERAL_NAME, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class))\n# define i2d_ASN1_SET_OF_GENERAL_NAME(st, pp, i2d_func, ex_tag, ex_class, is_set) \\\n        SKM_ASN1_SET_OF_i2d(GENERAL_NAME, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set))\n# define ASN1_seq_pack_GENERAL_NAME(st, i2d_func, buf, len) \\\n        SKM_ASN1_seq_pack(GENERAL_NAME, (st), (i2d_func), (buf), (len))\n# define ASN1_seq_unpack_GENERAL_NAME(buf, len, d2i_func, free_func) \\\n        SKM_ASN1_seq_unpack(GENERAL_NAME, (buf), (len), (d2i_func), (free_func))\n# define d2i_ASN1_SET_OF_OCSP_ONEREQ(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \\\n        SKM_ASN1_SET_OF_d2i(OCSP_ONEREQ, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class))\n# define i2d_ASN1_SET_OF_OCSP_ONEREQ(st, pp, i2d_func, ex_tag, ex_class, is_set) \\\n        SKM_ASN1_SET_OF_i2d(OCSP_ONEREQ, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set))\n# define ASN1_seq_pack_OCSP_ONEREQ(st, i2d_func, buf, len) \\\n        SKM_ASN1_seq_pack(OCSP_ONEREQ, (st), (i2d_func), (buf), (len))\n# define ASN1_seq_unpack_OCSP_ONEREQ(buf, len, d2i_func, free_func) \\\n        SKM_ASN1_seq_unpack(OCSP_ONEREQ, (buf), (len), (d2i_func), (free_func))\n# define d2i_ASN1_SET_OF_OCSP_SINGLERESP(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \\\n        SKM_ASN1_SET_OF_d2i(OCSP_SINGLERESP, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class))\n# define i2d_ASN1_SET_OF_OCSP_SINGLERESP(st, pp, i2d_func, ex_tag, ex_class, is_set) \\\n        SKM_ASN1_SET_OF_i2d(OCSP_SINGLERESP, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set))\n# define ASN1_seq_pack_OCSP_SINGLERESP(st, i2d_func, buf, len) \\\n        SKM_ASN1_seq_pack(OCSP_SINGLERESP, (st), (i2d_func), (buf), (len))\n# define ASN1_seq_unpack_OCSP_SINGLERESP(buf, len, d2i_func, free_func) \\\n        SKM_ASN1_seq_unpack(OCSP_SINGLERESP, (buf), (len), (d2i_func), (free_func))\n# define d2i_ASN1_SET_OF_PKCS12_SAFEBAG(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \\\n        SKM_ASN1_SET_OF_d2i(PKCS12_SAFEBAG, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class))\n# define i2d_ASN1_SET_OF_PKCS12_SAFEBAG(st, pp, i2d_func, ex_tag, ex_class, is_set) \\\n        SKM_ASN1_SET_OF_i2d(PKCS12_SAFEBAG, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set))\n# define ASN1_seq_pack_PKCS12_SAFEBAG(st, i2d_func, buf, len) \\\n        SKM_ASN1_seq_pack(PKCS12_SAFEBAG, (st), (i2d_func), (buf), (len))\n# define ASN1_seq_unpack_PKCS12_SAFEBAG(buf, len, d2i_func, free_func) \\\n        SKM_ASN1_seq_unpack(PKCS12_SAFEBAG, (buf), (len), (d2i_func), (free_func))\n# define d2i_ASN1_SET_OF_PKCS7(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \\\n        SKM_ASN1_SET_OF_d2i(PKCS7, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class))\n# define i2d_ASN1_SET_OF_PKCS7(st, pp, i2d_func, ex_tag, ex_class, is_set) \\\n        SKM_ASN1_SET_OF_i2d(PKCS7, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set))\n# define ASN1_seq_pack_PKCS7(st, i2d_func, buf, len) \\\n        SKM_ASN1_seq_pack(PKCS7, (st), (i2d_func), (buf), (len))\n# define ASN1_seq_unpack_PKCS7(buf, len, d2i_func, free_func) \\\n        SKM_ASN1_seq_unpack(PKCS7, (buf), (len), (d2i_func), (free_func))\n# define d2i_ASN1_SET_OF_PKCS7_RECIP_INFO(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \\\n        SKM_ASN1_SET_OF_d2i(PKCS7_RECIP_INFO, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class))\n# define i2d_ASN1_SET_OF_PKCS7_RECIP_INFO(st, pp, i2d_func, ex_tag, ex_class, is_set) \\\n        SKM_ASN1_SET_OF_i2d(PKCS7_RECIP_INFO, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set))\n# define ASN1_seq_pack_PKCS7_RECIP_INFO(st, i2d_func, buf, len) \\\n        SKM_ASN1_seq_pack(PKCS7_RECIP_INFO, (st), (i2d_func), (buf), (len))\n# define ASN1_seq_unpack_PKCS7_RECIP_INFO(buf, len, d2i_func, free_func) \\\n        SKM_ASN1_seq_unpack(PKCS7_RECIP_INFO, (buf), (len), (d2i_func), (free_func))\n# define d2i_ASN1_SET_OF_PKCS7_SIGNER_INFO(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \\\n        SKM_ASN1_SET_OF_d2i(PKCS7_SIGNER_INFO, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class))\n# define i2d_ASN1_SET_OF_PKCS7_SIGNER_INFO(st, pp, i2d_func, ex_tag, ex_class, is_set) \\\n        SKM_ASN1_SET_OF_i2d(PKCS7_SIGNER_INFO, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set))\n# define ASN1_seq_pack_PKCS7_SIGNER_INFO(st, i2d_func, buf, len) \\\n        SKM_ASN1_seq_pack(PKCS7_SIGNER_INFO, (st), (i2d_func), (buf), (len))\n# define ASN1_seq_unpack_PKCS7_SIGNER_INFO(buf, len, d2i_func, free_func) \\\n        SKM_ASN1_seq_unpack(PKCS7_SIGNER_INFO, (buf), (len), (d2i_func), (free_func))\n# define d2i_ASN1_SET_OF_POLICYINFO(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \\\n        SKM_ASN1_SET_OF_d2i(POLICYINFO, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class))\n# define i2d_ASN1_SET_OF_POLICYINFO(st, pp, i2d_func, ex_tag, ex_class, is_set) \\\n        SKM_ASN1_SET_OF_i2d(POLICYINFO, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set))\n# define ASN1_seq_pack_POLICYINFO(st, i2d_func, buf, len) \\\n        SKM_ASN1_seq_pack(POLICYINFO, (st), (i2d_func), (buf), (len))\n# define ASN1_seq_unpack_POLICYINFO(buf, len, d2i_func, free_func) \\\n        SKM_ASN1_seq_unpack(POLICYINFO, (buf), (len), (d2i_func), (free_func))\n# define d2i_ASN1_SET_OF_POLICYQUALINFO(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \\\n        SKM_ASN1_SET_OF_d2i(POLICYQUALINFO, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class))\n# define i2d_ASN1_SET_OF_POLICYQUALINFO(st, pp, i2d_func, ex_tag, ex_class, is_set) \\\n        SKM_ASN1_SET_OF_i2d(POLICYQUALINFO, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set))\n# define ASN1_seq_pack_POLICYQUALINFO(st, i2d_func, buf, len) \\\n        SKM_ASN1_seq_pack(POLICYQUALINFO, (st), (i2d_func), (buf), (len))\n# define ASN1_seq_unpack_POLICYQUALINFO(buf, len, d2i_func, free_func) \\\n        SKM_ASN1_seq_unpack(POLICYQUALINFO, (buf), (len), (d2i_func), (free_func))\n# define d2i_ASN1_SET_OF_SXNETID(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \\\n        SKM_ASN1_SET_OF_d2i(SXNETID, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class))\n# define i2d_ASN1_SET_OF_SXNETID(st, pp, i2d_func, ex_tag, ex_class, is_set) \\\n        SKM_ASN1_SET_OF_i2d(SXNETID, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set))\n# define ASN1_seq_pack_SXNETID(st, i2d_func, buf, len) \\\n        SKM_ASN1_seq_pack(SXNETID, (st), (i2d_func), (buf), (len))\n# define ASN1_seq_unpack_SXNETID(buf, len, d2i_func, free_func) \\\n        SKM_ASN1_seq_unpack(SXNETID, (buf), (len), (d2i_func), (free_func))\n# define d2i_ASN1_SET_OF_X509(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \\\n        SKM_ASN1_SET_OF_d2i(X509, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class))\n# define i2d_ASN1_SET_OF_X509(st, pp, i2d_func, ex_tag, ex_class, is_set) \\\n        SKM_ASN1_SET_OF_i2d(X509, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set))\n# define ASN1_seq_pack_X509(st, i2d_func, buf, len) \\\n        SKM_ASN1_seq_pack(X509, (st), (i2d_func), (buf), (len))\n# define ASN1_seq_unpack_X509(buf, len, d2i_func, free_func) \\\n        SKM_ASN1_seq_unpack(X509, (buf), (len), (d2i_func), (free_func))\n# define d2i_ASN1_SET_OF_X509_ALGOR(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \\\n        SKM_ASN1_SET_OF_d2i(X509_ALGOR, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class))\n# define i2d_ASN1_SET_OF_X509_ALGOR(st, pp, i2d_func, ex_tag, ex_class, is_set) \\\n        SKM_ASN1_SET_OF_i2d(X509_ALGOR, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set))\n# define ASN1_seq_pack_X509_ALGOR(st, i2d_func, buf, len) \\\n        SKM_ASN1_seq_pack(X509_ALGOR, (st), (i2d_func), (buf), (len))\n# define ASN1_seq_unpack_X509_ALGOR(buf, len, d2i_func, free_func) \\\n        SKM_ASN1_seq_unpack(X509_ALGOR, (buf), (len), (d2i_func), (free_func))\n# define d2i_ASN1_SET_OF_X509_ATTRIBUTE(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \\\n        SKM_ASN1_SET_OF_d2i(X509_ATTRIBUTE, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class))\n# define i2d_ASN1_SET_OF_X509_ATTRIBUTE(st, pp, i2d_func, ex_tag, ex_class, is_set) \\\n        SKM_ASN1_SET_OF_i2d(X509_ATTRIBUTE, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set))\n# define ASN1_seq_pack_X509_ATTRIBUTE(st, i2d_func, buf, len) \\\n        SKM_ASN1_seq_pack(X509_ATTRIBUTE, (st), (i2d_func), (buf), (len))\n# define ASN1_seq_unpack_X509_ATTRIBUTE(buf, len, d2i_func, free_func) \\\n        SKM_ASN1_seq_unpack(X509_ATTRIBUTE, (buf), (len), (d2i_func), (free_func))\n# define d2i_ASN1_SET_OF_X509_CRL(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \\\n        SKM_ASN1_SET_OF_d2i(X509_CRL, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class))\n# define i2d_ASN1_SET_OF_X509_CRL(st, pp, i2d_func, ex_tag, ex_class, is_set) \\\n        SKM_ASN1_SET_OF_i2d(X509_CRL, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set))\n# define ASN1_seq_pack_X509_CRL(st, i2d_func, buf, len) \\\n        SKM_ASN1_seq_pack(X509_CRL, (st), (i2d_func), (buf), (len))\n# define ASN1_seq_unpack_X509_CRL(buf, len, d2i_func, free_func) \\\n        SKM_ASN1_seq_unpack(X509_CRL, (buf), (len), (d2i_func), (free_func))\n# define d2i_ASN1_SET_OF_X509_EXTENSION(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \\\n        SKM_ASN1_SET_OF_d2i(X509_EXTENSION, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class))\n# define i2d_ASN1_SET_OF_X509_EXTENSION(st, pp, i2d_func, ex_tag, ex_class, is_set) \\\n        SKM_ASN1_SET_OF_i2d(X509_EXTENSION, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set))\n# define ASN1_seq_pack_X509_EXTENSION(st, i2d_func, buf, len) \\\n        SKM_ASN1_seq_pack(X509_EXTENSION, (st), (i2d_func), (buf), (len))\n# define ASN1_seq_unpack_X509_EXTENSION(buf, len, d2i_func, free_func) \\\n        SKM_ASN1_seq_unpack(X509_EXTENSION, (buf), (len), (d2i_func), (free_func))\n# define d2i_ASN1_SET_OF_X509_NAME_ENTRY(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \\\n        SKM_ASN1_SET_OF_d2i(X509_NAME_ENTRY, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class))\n# define i2d_ASN1_SET_OF_X509_NAME_ENTRY(st, pp, i2d_func, ex_tag, ex_class, is_set) \\\n        SKM_ASN1_SET_OF_i2d(X509_NAME_ENTRY, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set))\n# define ASN1_seq_pack_X509_NAME_ENTRY(st, i2d_func, buf, len) \\\n        SKM_ASN1_seq_pack(X509_NAME_ENTRY, (st), (i2d_func), (buf), (len))\n# define ASN1_seq_unpack_X509_NAME_ENTRY(buf, len, d2i_func, free_func) \\\n        SKM_ASN1_seq_unpack(X509_NAME_ENTRY, (buf), (len), (d2i_func), (free_func))\n# define d2i_ASN1_SET_OF_X509_REVOKED(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \\\n        SKM_ASN1_SET_OF_d2i(X509_REVOKED, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class))\n# define i2d_ASN1_SET_OF_X509_REVOKED(st, pp, i2d_func, ex_tag, ex_class, is_set) \\\n        SKM_ASN1_SET_OF_i2d(X509_REVOKED, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set))\n# define ASN1_seq_pack_X509_REVOKED(st, i2d_func, buf, len) \\\n        SKM_ASN1_seq_pack(X509_REVOKED, (st), (i2d_func), (buf), (len))\n# define ASN1_seq_unpack_X509_REVOKED(buf, len, d2i_func, free_func) \\\n        SKM_ASN1_seq_unpack(X509_REVOKED, (buf), (len), (d2i_func), (free_func))\n# define PKCS12_decrypt_d2i_PKCS12_SAFEBAG(algor, d2i_func, free_func, pass, passlen, oct, seq) \\\n        SKM_PKCS12_decrypt_d2i(PKCS12_SAFEBAG, (algor), (d2i_func), (free_func), (pass), (passlen), (oct), (seq))\n# define PKCS12_decrypt_d2i_PKCS7(algor, d2i_func, free_func, pass, passlen, oct, seq) \\\n        SKM_PKCS12_decrypt_d2i(PKCS7, (algor), (d2i_func), (free_func), (pass), (passlen), (oct), (seq))\n# define lh_ADDED_OBJ_new() LHM_lh_new(ADDED_OBJ,added_obj)\n# define lh_ADDED_OBJ_insert(lh,inst) LHM_lh_insert(ADDED_OBJ,lh,inst)\n# define lh_ADDED_OBJ_retrieve(lh,inst) LHM_lh_retrieve(ADDED_OBJ,lh,inst)\n# define lh_ADDED_OBJ_delete(lh,inst) LHM_lh_delete(ADDED_OBJ,lh,inst)\n# define lh_ADDED_OBJ_doall(lh,fn) LHM_lh_doall(ADDED_OBJ,lh,fn)\n# define lh_ADDED_OBJ_doall_arg(lh,fn,arg_type,arg) \\\n  LHM_lh_doall_arg(ADDED_OBJ,lh,fn,arg_type,arg)\n# define lh_ADDED_OBJ_error(lh) LHM_lh_error(ADDED_OBJ,lh)\n# define lh_ADDED_OBJ_num_items(lh) LHM_lh_num_items(ADDED_OBJ,lh)\n# define lh_ADDED_OBJ_down_load(lh) LHM_lh_down_load(ADDED_OBJ,lh)\n# define lh_ADDED_OBJ_node_stats_bio(lh,out) \\\n  LHM_lh_node_stats_bio(ADDED_OBJ,lh,out)\n# define lh_ADDED_OBJ_node_usage_stats_bio(lh,out) \\\n  LHM_lh_node_usage_stats_bio(ADDED_OBJ,lh,out)\n# define lh_ADDED_OBJ_stats_bio(lh,out) \\\n  LHM_lh_stats_bio(ADDED_OBJ,lh,out)\n# define lh_ADDED_OBJ_free(lh) LHM_lh_free(ADDED_OBJ,lh)\n# define lh_APP_INFO_new() LHM_lh_new(APP_INFO,app_info)\n# define lh_APP_INFO_insert(lh,inst) LHM_lh_insert(APP_INFO,lh,inst)\n# define lh_APP_INFO_retrieve(lh,inst) LHM_lh_retrieve(APP_INFO,lh,inst)\n# define lh_APP_INFO_delete(lh,inst) LHM_lh_delete(APP_INFO,lh,inst)\n# define lh_APP_INFO_doall(lh,fn) LHM_lh_doall(APP_INFO,lh,fn)\n# define lh_APP_INFO_doall_arg(lh,fn,arg_type,arg) \\\n  LHM_lh_doall_arg(APP_INFO,lh,fn,arg_type,arg)\n# define lh_APP_INFO_error(lh) LHM_lh_error(APP_INFO,lh)\n# define lh_APP_INFO_num_items(lh) LHM_lh_num_items(APP_INFO,lh)\n# define lh_APP_INFO_down_load(lh) LHM_lh_down_load(APP_INFO,lh)\n# define lh_APP_INFO_node_stats_bio(lh,out) \\\n  LHM_lh_node_stats_bio(APP_INFO,lh,out)\n# define lh_APP_INFO_node_usage_stats_bio(lh,out) \\\n  LHM_lh_node_usage_stats_bio(APP_INFO,lh,out)\n# define lh_APP_INFO_stats_bio(lh,out) \\\n  LHM_lh_stats_bio(APP_INFO,lh,out)\n# define lh_APP_INFO_free(lh) LHM_lh_free(APP_INFO,lh)\n# define lh_CONF_VALUE_new() LHM_lh_new(CONF_VALUE,conf_value)\n# define lh_CONF_VALUE_insert(lh,inst) LHM_lh_insert(CONF_VALUE,lh,inst)\n# define lh_CONF_VALUE_retrieve(lh,inst) LHM_lh_retrieve(CONF_VALUE,lh,inst)\n# define lh_CONF_VALUE_delete(lh,inst) LHM_lh_delete(CONF_VALUE,lh,inst)\n# define lh_CONF_VALUE_doall(lh,fn) LHM_lh_doall(CONF_VALUE,lh,fn)\n# define lh_CONF_VALUE_doall_arg(lh,fn,arg_type,arg) \\\n  LHM_lh_doall_arg(CONF_VALUE,lh,fn,arg_type,arg)\n# define lh_CONF_VALUE_error(lh) LHM_lh_error(CONF_VALUE,lh)\n# define lh_CONF_VALUE_num_items(lh) LHM_lh_num_items(CONF_VALUE,lh)\n# define lh_CONF_VALUE_down_load(lh) LHM_lh_down_load(CONF_VALUE,lh)\n# define lh_CONF_VALUE_node_stats_bio(lh,out) \\\n  LHM_lh_node_stats_bio(CONF_VALUE,lh,out)\n# define lh_CONF_VALUE_node_usage_stats_bio(lh,out) \\\n  LHM_lh_node_usage_stats_bio(CONF_VALUE,lh,out)\n# define lh_CONF_VALUE_stats_bio(lh,out) \\\n  LHM_lh_stats_bio(CONF_VALUE,lh,out)\n# define lh_CONF_VALUE_free(lh) LHM_lh_free(CONF_VALUE,lh)\n# define lh_ENGINE_PILE_new() LHM_lh_new(ENGINE_PILE,engine_pile)\n# define lh_ENGINE_PILE_insert(lh,inst) LHM_lh_insert(ENGINE_PILE,lh,inst)\n# define lh_ENGINE_PILE_retrieve(lh,inst) LHM_lh_retrieve(ENGINE_PILE,lh,inst)\n# define lh_ENGINE_PILE_delete(lh,inst) LHM_lh_delete(ENGINE_PILE,lh,inst)\n# define lh_ENGINE_PILE_doall(lh,fn) LHM_lh_doall(ENGINE_PILE,lh,fn)\n# define lh_ENGINE_PILE_doall_arg(lh,fn,arg_type,arg) \\\n  LHM_lh_doall_arg(ENGINE_PILE,lh,fn,arg_type,arg)\n# define lh_ENGINE_PILE_error(lh) LHM_lh_error(ENGINE_PILE,lh)\n# define lh_ENGINE_PILE_num_items(lh) LHM_lh_num_items(ENGINE_PILE,lh)\n# define lh_ENGINE_PILE_down_load(lh) LHM_lh_down_load(ENGINE_PILE,lh)\n# define lh_ENGINE_PILE_node_stats_bio(lh,out) \\\n  LHM_lh_node_stats_bio(ENGINE_PILE,lh,out)\n# define lh_ENGINE_PILE_node_usage_stats_bio(lh,out) \\\n  LHM_lh_node_usage_stats_bio(ENGINE_PILE,lh,out)\n# define lh_ENGINE_PILE_stats_bio(lh,out) \\\n  LHM_lh_stats_bio(ENGINE_PILE,lh,out)\n# define lh_ENGINE_PILE_free(lh) LHM_lh_free(ENGINE_PILE,lh)\n# define lh_ERR_STATE_new() LHM_lh_new(ERR_STATE,err_state)\n# define lh_ERR_STATE_insert(lh,inst) LHM_lh_insert(ERR_STATE,lh,inst)\n# define lh_ERR_STATE_retrieve(lh,inst) LHM_lh_retrieve(ERR_STATE,lh,inst)\n# define lh_ERR_STATE_delete(lh,inst) LHM_lh_delete(ERR_STATE,lh,inst)\n# define lh_ERR_STATE_doall(lh,fn) LHM_lh_doall(ERR_STATE,lh,fn)\n# define lh_ERR_STATE_doall_arg(lh,fn,arg_type,arg) \\\n  LHM_lh_doall_arg(ERR_STATE,lh,fn,arg_type,arg)\n# define lh_ERR_STATE_error(lh) LHM_lh_error(ERR_STATE,lh)\n# define lh_ERR_STATE_num_items(lh) LHM_lh_num_items(ERR_STATE,lh)\n# define lh_ERR_STATE_down_load(lh) LHM_lh_down_load(ERR_STATE,lh)\n# define lh_ERR_STATE_node_stats_bio(lh,out) \\\n  LHM_lh_node_stats_bio(ERR_STATE,lh,out)\n# define lh_ERR_STATE_node_usage_stats_bio(lh,out) \\\n  LHM_lh_node_usage_stats_bio(ERR_STATE,lh,out)\n# define lh_ERR_STATE_stats_bio(lh,out) \\\n  LHM_lh_stats_bio(ERR_STATE,lh,out)\n# define lh_ERR_STATE_free(lh) LHM_lh_free(ERR_STATE,lh)\n# define lh_ERR_STRING_DATA_new() LHM_lh_new(ERR_STRING_DATA,err_string_data)\n# define lh_ERR_STRING_DATA_insert(lh,inst) LHM_lh_insert(ERR_STRING_DATA,lh,inst)\n# define lh_ERR_STRING_DATA_retrieve(lh,inst) LHM_lh_retrieve(ERR_STRING_DATA,lh,inst)\n# define lh_ERR_STRING_DATA_delete(lh,inst) LHM_lh_delete(ERR_STRING_DATA,lh,inst)\n# define lh_ERR_STRING_DATA_doall(lh,fn) LHM_lh_doall(ERR_STRING_DATA,lh,fn)\n# define lh_ERR_STRING_DATA_doall_arg(lh,fn,arg_type,arg) \\\n  LHM_lh_doall_arg(ERR_STRING_DATA,lh,fn,arg_type,arg)\n# define lh_ERR_STRING_DATA_error(lh) LHM_lh_error(ERR_STRING_DATA,lh)\n# define lh_ERR_STRING_DATA_num_items(lh) LHM_lh_num_items(ERR_STRING_DATA,lh)\n# define lh_ERR_STRING_DATA_down_load(lh) LHM_lh_down_load(ERR_STRING_DATA,lh)\n# define lh_ERR_STRING_DATA_node_stats_bio(lh,out) \\\n  LHM_lh_node_stats_bio(ERR_STRING_DATA,lh,out)\n# define lh_ERR_STRING_DATA_node_usage_stats_bio(lh,out) \\\n  LHM_lh_node_usage_stats_bio(ERR_STRING_DATA,lh,out)\n# define lh_ERR_STRING_DATA_stats_bio(lh,out) \\\n  LHM_lh_stats_bio(ERR_STRING_DATA,lh,out)\n# define lh_ERR_STRING_DATA_free(lh) LHM_lh_free(ERR_STRING_DATA,lh)\n# define lh_EX_CLASS_ITEM_new() LHM_lh_new(EX_CLASS_ITEM,ex_class_item)\n# define lh_EX_CLASS_ITEM_insert(lh,inst) LHM_lh_insert(EX_CLASS_ITEM,lh,inst)\n# define lh_EX_CLASS_ITEM_retrieve(lh,inst) LHM_lh_retrieve(EX_CLASS_ITEM,lh,inst)\n# define lh_EX_CLASS_ITEM_delete(lh,inst) LHM_lh_delete(EX_CLASS_ITEM,lh,inst)\n# define lh_EX_CLASS_ITEM_doall(lh,fn) LHM_lh_doall(EX_CLASS_ITEM,lh,fn)\n# define lh_EX_CLASS_ITEM_doall_arg(lh,fn,arg_type,arg) \\\n  LHM_lh_doall_arg(EX_CLASS_ITEM,lh,fn,arg_type,arg)\n# define lh_EX_CLASS_ITEM_error(lh) LHM_lh_error(EX_CLASS_ITEM,lh)\n# define lh_EX_CLASS_ITEM_num_items(lh) LHM_lh_num_items(EX_CLASS_ITEM,lh)\n# define lh_EX_CLASS_ITEM_down_load(lh) LHM_lh_down_load(EX_CLASS_ITEM,lh)\n# define lh_EX_CLASS_ITEM_node_stats_bio(lh,out) \\\n  LHM_lh_node_stats_bio(EX_CLASS_ITEM,lh,out)\n# define lh_EX_CLASS_ITEM_node_usage_stats_bio(lh,out) \\\n  LHM_lh_node_usage_stats_bio(EX_CLASS_ITEM,lh,out)\n# define lh_EX_CLASS_ITEM_stats_bio(lh,out) \\\n  LHM_lh_stats_bio(EX_CLASS_ITEM,lh,out)\n# define lh_EX_CLASS_ITEM_free(lh) LHM_lh_free(EX_CLASS_ITEM,lh)\n# define lh_FUNCTION_new() LHM_lh_new(FUNCTION,function)\n# define lh_FUNCTION_insert(lh,inst) LHM_lh_insert(FUNCTION,lh,inst)\n# define lh_FUNCTION_retrieve(lh,inst) LHM_lh_retrieve(FUNCTION,lh,inst)\n# define lh_FUNCTION_delete(lh,inst) LHM_lh_delete(FUNCTION,lh,inst)\n# define lh_FUNCTION_doall(lh,fn) LHM_lh_doall(FUNCTION,lh,fn)\n# define lh_FUNCTION_doall_arg(lh,fn,arg_type,arg) \\\n  LHM_lh_doall_arg(FUNCTION,lh,fn,arg_type,arg)\n# define lh_FUNCTION_error(lh) LHM_lh_error(FUNCTION,lh)\n# define lh_FUNCTION_num_items(lh) LHM_lh_num_items(FUNCTION,lh)\n# define lh_FUNCTION_down_load(lh) LHM_lh_down_load(FUNCTION,lh)\n# define lh_FUNCTION_node_stats_bio(lh,out) \\\n  LHM_lh_node_stats_bio(FUNCTION,lh,out)\n# define lh_FUNCTION_node_usage_stats_bio(lh,out) \\\n  LHM_lh_node_usage_stats_bio(FUNCTION,lh,out)\n# define lh_FUNCTION_stats_bio(lh,out) \\\n  LHM_lh_stats_bio(FUNCTION,lh,out)\n# define lh_FUNCTION_free(lh) LHM_lh_free(FUNCTION,lh)\n# define lh_MEM_new() LHM_lh_new(MEM,mem)\n# define lh_MEM_insert(lh,inst) LHM_lh_insert(MEM,lh,inst)\n# define lh_MEM_retrieve(lh,inst) LHM_lh_retrieve(MEM,lh,inst)\n# define lh_MEM_delete(lh,inst) LHM_lh_delete(MEM,lh,inst)\n# define lh_MEM_doall(lh,fn) LHM_lh_doall(MEM,lh,fn)\n# define lh_MEM_doall_arg(lh,fn,arg_type,arg) \\\n  LHM_lh_doall_arg(MEM,lh,fn,arg_type,arg)\n# define lh_MEM_error(lh) LHM_lh_error(MEM,lh)\n# define lh_MEM_num_items(lh) LHM_lh_num_items(MEM,lh)\n# define lh_MEM_down_load(lh) LHM_lh_down_load(MEM,lh)\n# define lh_MEM_node_stats_bio(lh,out) \\\n  LHM_lh_node_stats_bio(MEM,lh,out)\n# define lh_MEM_node_usage_stats_bio(lh,out) \\\n  LHM_lh_node_usage_stats_bio(MEM,lh,out)\n# define lh_MEM_stats_bio(lh,out) \\\n  LHM_lh_stats_bio(MEM,lh,out)\n# define lh_MEM_free(lh) LHM_lh_free(MEM,lh)\n# define lh_OBJ_NAME_new() LHM_lh_new(OBJ_NAME,obj_name)\n# define lh_OBJ_NAME_insert(lh,inst) LHM_lh_insert(OBJ_NAME,lh,inst)\n# define lh_OBJ_NAME_retrieve(lh,inst) LHM_lh_retrieve(OBJ_NAME,lh,inst)\n# define lh_OBJ_NAME_delete(lh,inst) LHM_lh_delete(OBJ_NAME,lh,inst)\n# define lh_OBJ_NAME_doall(lh,fn) LHM_lh_doall(OBJ_NAME,lh,fn)\n# define lh_OBJ_NAME_doall_arg(lh,fn,arg_type,arg) \\\n  LHM_lh_doall_arg(OBJ_NAME,lh,fn,arg_type,arg)\n# define lh_OBJ_NAME_error(lh) LHM_lh_error(OBJ_NAME,lh)\n# define lh_OBJ_NAME_num_items(lh) LHM_lh_num_items(OBJ_NAME,lh)\n# define lh_OBJ_NAME_down_load(lh) LHM_lh_down_load(OBJ_NAME,lh)\n# define lh_OBJ_NAME_node_stats_bio(lh,out) \\\n  LHM_lh_node_stats_bio(OBJ_NAME,lh,out)\n# define lh_OBJ_NAME_node_usage_stats_bio(lh,out) \\\n  LHM_lh_node_usage_stats_bio(OBJ_NAME,lh,out)\n# define lh_OBJ_NAME_stats_bio(lh,out) \\\n  LHM_lh_stats_bio(OBJ_NAME,lh,out)\n# define lh_OBJ_NAME_free(lh) LHM_lh_free(OBJ_NAME,lh)\n# define lh_OPENSSL_CSTRING_new() LHM_lh_new(OPENSSL_CSTRING,openssl_cstring)\n# define lh_OPENSSL_CSTRING_insert(lh,inst) LHM_lh_insert(OPENSSL_CSTRING,lh,inst)\n# define lh_OPENSSL_CSTRING_retrieve(lh,inst) LHM_lh_retrieve(OPENSSL_CSTRING,lh,inst)\n# define lh_OPENSSL_CSTRING_delete(lh,inst) LHM_lh_delete(OPENSSL_CSTRING,lh,inst)\n# define lh_OPENSSL_CSTRING_doall(lh,fn) LHM_lh_doall(OPENSSL_CSTRING,lh,fn)\n# define lh_OPENSSL_CSTRING_doall_arg(lh,fn,arg_type,arg) \\\n  LHM_lh_doall_arg(OPENSSL_CSTRING,lh,fn,arg_type,arg)\n# define lh_OPENSSL_CSTRING_error(lh) LHM_lh_error(OPENSSL_CSTRING,lh)\n# define lh_OPENSSL_CSTRING_num_items(lh) LHM_lh_num_items(OPENSSL_CSTRING,lh)\n# define lh_OPENSSL_CSTRING_down_load(lh) LHM_lh_down_load(OPENSSL_CSTRING,lh)\n# define lh_OPENSSL_CSTRING_node_stats_bio(lh,out) \\\n  LHM_lh_node_stats_bio(OPENSSL_CSTRING,lh,out)\n# define lh_OPENSSL_CSTRING_node_usage_stats_bio(lh,out) \\\n  LHM_lh_node_usage_stats_bio(OPENSSL_CSTRING,lh,out)\n# define lh_OPENSSL_CSTRING_stats_bio(lh,out) \\\n  LHM_lh_stats_bio(OPENSSL_CSTRING,lh,out)\n# define lh_OPENSSL_CSTRING_free(lh) LHM_lh_free(OPENSSL_CSTRING,lh)\n# define lh_OPENSSL_STRING_new() LHM_lh_new(OPENSSL_STRING,openssl_string)\n# define lh_OPENSSL_STRING_insert(lh,inst) LHM_lh_insert(OPENSSL_STRING,lh,inst)\n# define lh_OPENSSL_STRING_retrieve(lh,inst) LHM_lh_retrieve(OPENSSL_STRING,lh,inst)\n# define lh_OPENSSL_STRING_delete(lh,inst) LHM_lh_delete(OPENSSL_STRING,lh,inst)\n# define lh_OPENSSL_STRING_doall(lh,fn) LHM_lh_doall(OPENSSL_STRING,lh,fn)\n# define lh_OPENSSL_STRING_doall_arg(lh,fn,arg_type,arg) \\\n  LHM_lh_doall_arg(OPENSSL_STRING,lh,fn,arg_type,arg)\n# define lh_OPENSSL_STRING_error(lh) LHM_lh_error(OPENSSL_STRING,lh)\n# define lh_OPENSSL_STRING_num_items(lh) LHM_lh_num_items(OPENSSL_STRING,lh)\n# define lh_OPENSSL_STRING_down_load(lh) LHM_lh_down_load(OPENSSL_STRING,lh)\n# define lh_OPENSSL_STRING_node_stats_bio(lh,out) \\\n  LHM_lh_node_stats_bio(OPENSSL_STRING,lh,out)\n# define lh_OPENSSL_STRING_node_usage_stats_bio(lh,out) \\\n  LHM_lh_node_usage_stats_bio(OPENSSL_STRING,lh,out)\n# define lh_OPENSSL_STRING_stats_bio(lh,out) \\\n  LHM_lh_stats_bio(OPENSSL_STRING,lh,out)\n# define lh_OPENSSL_STRING_free(lh) LHM_lh_free(OPENSSL_STRING,lh)\n# define lh_SSL_SESSION_new() LHM_lh_new(SSL_SESSION,ssl_session)\n# define lh_SSL_SESSION_insert(lh,inst) LHM_lh_insert(SSL_SESSION,lh,inst)\n# define lh_SSL_SESSION_retrieve(lh,inst) LHM_lh_retrieve(SSL_SESSION,lh,inst)\n# define lh_SSL_SESSION_delete(lh,inst) LHM_lh_delete(SSL_SESSION,lh,inst)\n# define lh_SSL_SESSION_doall(lh,fn) LHM_lh_doall(SSL_SESSION,lh,fn)\n# define lh_SSL_SESSION_doall_arg(lh,fn,arg_type,arg) \\\n  LHM_lh_doall_arg(SSL_SESSION,lh,fn,arg_type,arg)\n# define lh_SSL_SESSION_error(lh) LHM_lh_error(SSL_SESSION,lh)\n# define lh_SSL_SESSION_num_items(lh) LHM_lh_num_items(SSL_SESSION,lh)\n# define lh_SSL_SESSION_down_load(lh) LHM_lh_down_load(SSL_SESSION,lh)\n# define lh_SSL_SESSION_node_stats_bio(lh,out) \\\n  LHM_lh_node_stats_bio(SSL_SESSION,lh,out)\n# define lh_SSL_SESSION_node_usage_stats_bio(lh,out) \\\n  LHM_lh_node_usage_stats_bio(SSL_SESSION,lh,out)\n# define lh_SSL_SESSION_stats_bio(lh,out) \\\n  LHM_lh_stats_bio(SSL_SESSION,lh,out)\n# define lh_SSL_SESSION_free(lh) LHM_lh_free(SSL_SESSION,lh)\n#ifdef  __cplusplus\n}\n#endif\n#endif                          /* !defined HEADER_SAFESTACK_H */\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/arm/include/openssl/seed.h",
    "content": "/*\n * Copyright (c) 2007 KISA(Korea Information Security Agency). All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n * 2. Neither the name of author nor the names of its contributors may\n *    be used to endorse or promote products derived from this software\n *    without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED.  IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n * SUCH DAMAGE.\n *\n */\n/* ====================================================================\n * Copyright (c) 1998-2007 The OpenSSL Project.  All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n *\n * 1. Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n *\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in\n *    the documentation and/or other materials provided with the\n *    distribution.\n *\n * 3. All advertising materials mentioning features or use of this\n *    software must display the following acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit. (http://www.openssl.org/)\"\n *\n * 4. The names \"OpenSSL Toolkit\" and \"OpenSSL Project\" must not be used to\n *    endorse or promote products derived from this software without\n *    prior written permission. For written permission, please contact\n *    openssl-core@openssl.org.\n *\n * 5. Products derived from this software may not be called \"OpenSSL\"\n *    nor may \"OpenSSL\" appear in their names without prior written\n *    permission of the OpenSSL Project.\n *\n * 6. Redistributions of any form whatsoever must retain the following\n *    acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit (http://www.openssl.org/)\"\n *\n * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY\n * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\n * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR\n * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\n * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,\n * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED\n * OF THE POSSIBILITY OF SUCH DAMAGE.\n * ====================================================================\n *\n * This product includes cryptographic software written by Eric Young\n * (eay@cryptsoft.com).  This product includes software written by Tim\n * Hudson (tjh@cryptsoft.com).\n *\n */\n\n#ifndef HEADER_SEED_H\n# define HEADER_SEED_H\n\n# include <openssl/opensslconf.h>\n# include <openssl/e_os2.h>\n# include <openssl/crypto.h>\n\n# ifdef OPENSSL_NO_SEED\n#  error SEED is disabled.\n# endif\n\n/* look whether we need 'long' to get 32 bits */\n# ifdef AES_LONG\n#  ifndef SEED_LONG\n#   define SEED_LONG 1\n#  endif\n# endif\n\n# if !defined(NO_SYS_TYPES_H)\n#  include <sys/types.h>\n# endif\n\n# define SEED_BLOCK_SIZE 16\n# define SEED_KEY_LENGTH 16\n\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\ntypedef struct seed_key_st {\n# ifdef SEED_LONG\n    unsigned long data[32];\n# else\n    unsigned int data[32];\n# endif\n} SEED_KEY_SCHEDULE;\n\n# ifdef OPENSSL_FIPS\nvoid private_SEED_set_key(const unsigned char rawkey[SEED_KEY_LENGTH],\n                          SEED_KEY_SCHEDULE *ks);\n# endif\nvoid SEED_set_key(const unsigned char rawkey[SEED_KEY_LENGTH],\n                  SEED_KEY_SCHEDULE *ks);\n\nvoid SEED_encrypt(const unsigned char s[SEED_BLOCK_SIZE],\n                  unsigned char d[SEED_BLOCK_SIZE],\n                  const SEED_KEY_SCHEDULE *ks);\nvoid SEED_decrypt(const unsigned char s[SEED_BLOCK_SIZE],\n                  unsigned char d[SEED_BLOCK_SIZE],\n                  const SEED_KEY_SCHEDULE *ks);\n\nvoid SEED_ecb_encrypt(const unsigned char *in, unsigned char *out,\n                      const SEED_KEY_SCHEDULE *ks, int enc);\nvoid SEED_cbc_encrypt(const unsigned char *in, unsigned char *out, size_t len,\n                      const SEED_KEY_SCHEDULE *ks,\n                      unsigned char ivec[SEED_BLOCK_SIZE], int enc);\nvoid SEED_cfb128_encrypt(const unsigned char *in, unsigned char *out,\n                         size_t len, const SEED_KEY_SCHEDULE *ks,\n                         unsigned char ivec[SEED_BLOCK_SIZE], int *num,\n                         int enc);\nvoid SEED_ofb128_encrypt(const unsigned char *in, unsigned char *out,\n                         size_t len, const SEED_KEY_SCHEDULE *ks,\n                         unsigned char ivec[SEED_BLOCK_SIZE], int *num);\n\n#ifdef  __cplusplus\n}\n#endif\n\n#endif                          /* HEADER_SEED_H */\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/arm/include/openssl/sha.h",
    "content": "/* crypto/sha/sha.h */\n/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)\n * All rights reserved.\n *\n * This package is an SSL implementation written\n * by Eric Young (eay@cryptsoft.com).\n * The implementation was written so as to conform with Netscapes SSL.\n *\n * This library is free for commercial and non-commercial use as long as\n * the following conditions are aheared to.  The following conditions\n * apply to all code found in this distribution, be it the RC4, RSA,\n * lhash, DES, etc., code; not just the SSL code.  The SSL documentation\n * included with this distribution is covered by the same copyright terms\n * except that the holder is Tim Hudson (tjh@cryptsoft.com).\n *\n * Copyright remains Eric Young's, and as such any Copyright notices in\n * the code are not to be removed.\n * If this package is used in a product, Eric Young should be given attribution\n * as the author of the parts of the library used.\n * This can be in the form of a textual message at program startup or\n * in documentation (online or textual) provided with the package.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the copyright\n *    notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in the\n *    documentation and/or other materials provided with the distribution.\n * 3. All advertising materials mentioning features or use of this software\n *    must display the following acknowledgement:\n *    \"This product includes cryptographic software written by\n *     Eric Young (eay@cryptsoft.com)\"\n *    The word 'cryptographic' can be left out if the rouines from the library\n *    being used are not cryptographic related :-).\n * 4. If you include any Windows specific code (or a derivative thereof) from\n *    the apps directory (application code) you must include an acknowledgement:\n *    \"This product includes software written by Tim Hudson (tjh@cryptsoft.com)\"\n *\n * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n * SUCH DAMAGE.\n *\n * The licence and distribution terms for any publically available version or\n * derivative of this code cannot be changed.  i.e. this code cannot simply be\n * copied and put under another distribution licence\n * [including the GNU Public Licence.]\n */\n\n#ifndef HEADER_SHA_H\n# define HEADER_SHA_H\n\n# include <openssl/e_os2.h>\n# include <stddef.h>\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n# if defined(OPENSSL_NO_SHA) || (defined(OPENSSL_NO_SHA0) && defined(OPENSSL_NO_SHA1))\n#  error SHA is disabled.\n# endif\n\n# if defined(OPENSSL_FIPS)\n#  define FIPS_SHA_SIZE_T size_t\n# endif\n\n/*-\n * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n * ! SHA_LONG has to be at least 32 bits wide. If it's wider, then !\n * ! SHA_LONG_LOG2 has to be defined along.                        !\n * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n */\n\n# if defined(__LP32__)\n#  define SHA_LONG unsigned long\n# elif defined(OPENSSL_SYS_CRAY) || defined(__ILP64__)\n#  define SHA_LONG unsigned long\n#  define SHA_LONG_LOG2 3\n# else\n#  define SHA_LONG unsigned int\n# endif\n\n# define SHA_LBLOCK      16\n# define SHA_CBLOCK      (SHA_LBLOCK*4)/* SHA treats input data as a\n                                        * contiguous array of 32 bit wide\n                                        * big-endian values. */\n# define SHA_LAST_BLOCK  (SHA_CBLOCK-8)\n# define SHA_DIGEST_LENGTH 20\n\ntypedef struct SHAstate_st {\n    SHA_LONG h0, h1, h2, h3, h4;\n    SHA_LONG Nl, Nh;\n    SHA_LONG data[SHA_LBLOCK];\n    unsigned int num;\n} SHA_CTX;\n\n# ifndef OPENSSL_NO_SHA0\n#  ifdef OPENSSL_FIPS\nint private_SHA_Init(SHA_CTX *c);\n#  endif\nint SHA_Init(SHA_CTX *c);\nint SHA_Update(SHA_CTX *c, const void *data, size_t len);\nint SHA_Final(unsigned char *md, SHA_CTX *c);\nunsigned char *SHA(const unsigned char *d, size_t n, unsigned char *md);\nvoid SHA_Transform(SHA_CTX *c, const unsigned char *data);\n# endif\n# ifndef OPENSSL_NO_SHA1\n#  ifdef OPENSSL_FIPS\nint private_SHA1_Init(SHA_CTX *c);\n#  endif\nint SHA1_Init(SHA_CTX *c);\nint SHA1_Update(SHA_CTX *c, const void *data, size_t len);\nint SHA1_Final(unsigned char *md, SHA_CTX *c);\nunsigned char *SHA1(const unsigned char *d, size_t n, unsigned char *md);\nvoid SHA1_Transform(SHA_CTX *c, const unsigned char *data);\n# endif\n\n# define SHA256_CBLOCK   (SHA_LBLOCK*4)/* SHA-256 treats input data as a\n                                        * contiguous array of 32 bit wide\n                                        * big-endian values. */\n# define SHA224_DIGEST_LENGTH    28\n# define SHA256_DIGEST_LENGTH    32\n\ntypedef struct SHA256state_st {\n    SHA_LONG h[8];\n    SHA_LONG Nl, Nh;\n    SHA_LONG data[SHA_LBLOCK];\n    unsigned int num, md_len;\n} SHA256_CTX;\n\n# ifndef OPENSSL_NO_SHA256\n#  ifdef OPENSSL_FIPS\nint private_SHA224_Init(SHA256_CTX *c);\nint private_SHA256_Init(SHA256_CTX *c);\n#  endif\nint SHA224_Init(SHA256_CTX *c);\nint SHA224_Update(SHA256_CTX *c, const void *data, size_t len);\nint SHA224_Final(unsigned char *md, SHA256_CTX *c);\nunsigned char *SHA224(const unsigned char *d, size_t n, unsigned char *md);\nint SHA256_Init(SHA256_CTX *c);\nint SHA256_Update(SHA256_CTX *c, const void *data, size_t len);\nint SHA256_Final(unsigned char *md, SHA256_CTX *c);\nunsigned char *SHA256(const unsigned char *d, size_t n, unsigned char *md);\nvoid SHA256_Transform(SHA256_CTX *c, const unsigned char *data);\n# endif\n\n# define SHA384_DIGEST_LENGTH    48\n# define SHA512_DIGEST_LENGTH    64\n\n# ifndef OPENSSL_NO_SHA512\n/*\n * Unlike 32-bit digest algorithms, SHA-512 *relies* on SHA_LONG64\n * being exactly 64-bit wide. See Implementation Notes in sha512.c\n * for further details.\n */\n/*\n * SHA-512 treats input data as a\n * contiguous array of 64 bit\n * wide big-endian values.\n */\n#  define SHA512_CBLOCK   (SHA_LBLOCK*8)\n#  if (defined(_WIN32) || defined(_WIN64)) && !defined(__MINGW32__)\n#   define SHA_LONG64 unsigned __int64\n#   define U64(C)     C##UI64\n#  elif defined(__arch64__)\n#   define SHA_LONG64 unsigned long\n#   define U64(C)     C##UL\n#  else\n#   define SHA_LONG64 unsigned long long\n#   define U64(C)     C##ULL\n#  endif\n\ntypedef struct SHA512state_st {\n    SHA_LONG64 h[8];\n    SHA_LONG64 Nl, Nh;\n    union {\n        SHA_LONG64 d[SHA_LBLOCK];\n        unsigned char p[SHA512_CBLOCK];\n    } u;\n    unsigned int num, md_len;\n} SHA512_CTX;\n# endif\n\n# ifndef OPENSSL_NO_SHA512\n#  ifdef OPENSSL_FIPS\nint private_SHA384_Init(SHA512_CTX *c);\nint private_SHA512_Init(SHA512_CTX *c);\n#  endif\nint SHA384_Init(SHA512_CTX *c);\nint SHA384_Update(SHA512_CTX *c, const void *data, size_t len);\nint SHA384_Final(unsigned char *md, SHA512_CTX *c);\nunsigned char *SHA384(const unsigned char *d, size_t n, unsigned char *md);\nint SHA512_Init(SHA512_CTX *c);\nint SHA512_Update(SHA512_CTX *c, const void *data, size_t len);\nint SHA512_Final(unsigned char *md, SHA512_CTX *c);\nunsigned char *SHA512(const unsigned char *d, size_t n, unsigned char *md);\nvoid SHA512_Transform(SHA512_CTX *c, const unsigned char *data);\n# endif\n\n#ifdef  __cplusplus\n}\n#endif\n\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/arm/include/openssl/srp.h",
    "content": "/* crypto/srp/srp.h */\n/*\n * Written by Christophe Renou (christophe.renou@edelweb.fr) with the\n * precious help of Peter Sylvester (peter.sylvester@edelweb.fr) for the\n * EdelKey project and contributed to the OpenSSL project 2004.\n */\n/* ====================================================================\n * Copyright (c) 2004 The OpenSSL Project.  All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n *\n * 1. Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n *\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in\n *    the documentation and/or other materials provided with the\n *    distribution.\n *\n * 3. All advertising materials mentioning features or use of this\n *    software must display the following acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)\"\n *\n * 4. The names \"OpenSSL Toolkit\" and \"OpenSSL Project\" must not be used to\n *    endorse or promote products derived from this software without\n *    prior written permission. For written permission, please contact\n *    licensing@OpenSSL.org.\n *\n * 5. Products derived from this software may not be called \"OpenSSL\"\n *    nor may \"OpenSSL\" appear in their names without prior written\n *    permission of the OpenSSL Project.\n *\n * 6. Redistributions of any form whatsoever must retain the following\n *    acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)\"\n *\n * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY\n * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\n * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR\n * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\n * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,\n * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED\n * OF THE POSSIBILITY OF SUCH DAMAGE.\n * ====================================================================\n *\n * This product includes cryptographic software written by Eric Young\n * (eay@cryptsoft.com).  This product includes software written by Tim\n * Hudson (tjh@cryptsoft.com).\n *\n */\n#ifndef __SRP_H__\n# define __SRP_H__\n\n# ifndef OPENSSL_NO_SRP\n\n#  include <stdio.h>\n#  include <string.h>\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n#  include <openssl/safestack.h>\n#  include <openssl/bn.h>\n#  include <openssl/crypto.h>\n\ntypedef struct SRP_gN_cache_st {\n    char *b64_bn;\n    BIGNUM *bn;\n} SRP_gN_cache;\n\n\nDECLARE_STACK_OF(SRP_gN_cache)\n\ntypedef struct SRP_user_pwd_st {\n    /* Owned by us. */\n    char *id;\n    BIGNUM *s;\n    BIGNUM *v;\n    /* Not owned by us. */\n    const BIGNUM *g;\n    const BIGNUM *N;\n    /* Owned by us. */\n    char *info;\n} SRP_user_pwd;\n\nDECLARE_STACK_OF(SRP_user_pwd)\n\nvoid SRP_user_pwd_free(SRP_user_pwd *user_pwd);\n\ntypedef struct SRP_VBASE_st {\n    STACK_OF(SRP_user_pwd) *users_pwd;\n    STACK_OF(SRP_gN_cache) *gN_cache;\n/* to simulate a user */\n    char *seed_key;\n    BIGNUM *default_g;\n    BIGNUM *default_N;\n} SRP_VBASE;\n\n/*\n * Structure interne pour retenir les couples N et g\n */\ntypedef struct SRP_gN_st {\n    char *id;\n    BIGNUM *g;\n    BIGNUM *N;\n} SRP_gN;\n\nDECLARE_STACK_OF(SRP_gN)\n\nSRP_VBASE *SRP_VBASE_new(char *seed_key);\nint SRP_VBASE_free(SRP_VBASE *vb);\nint SRP_VBASE_init(SRP_VBASE *vb, char *verifier_file);\n\n/* This method ignores the configured seed and fails for an unknown user. */\nSRP_user_pwd *SRP_VBASE_get_by_user(SRP_VBASE *vb, char *username);\n/* NOTE: unlike in SRP_VBASE_get_by_user, caller owns the returned pointer.*/\nSRP_user_pwd *SRP_VBASE_get1_by_user(SRP_VBASE *vb, char *username);\n\nchar *SRP_create_verifier(const char *user, const char *pass, char **salt,\n                          char **verifier, const char *N, const char *g);\nint SRP_create_verifier_BN(const char *user, const char *pass, BIGNUM **salt,\n                           BIGNUM **verifier, BIGNUM *N, BIGNUM *g);\n\n#  define SRP_NO_ERROR 0\n#  define SRP_ERR_VBASE_INCOMPLETE_FILE 1\n#  define SRP_ERR_VBASE_BN_LIB 2\n#  define SRP_ERR_OPEN_FILE 3\n#  define SRP_ERR_MEMORY 4\n\n#  define DB_srptype      0\n#  define DB_srpverifier  1\n#  define DB_srpsalt      2\n#  define DB_srpid        3\n#  define DB_srpgN        4\n#  define DB_srpinfo      5\n#  undef  DB_NUMBER\n#  define DB_NUMBER       6\n\n#  define DB_SRP_INDEX    'I'\n#  define DB_SRP_VALID    'V'\n#  define DB_SRP_REVOKED  'R'\n#  define DB_SRP_MODIF    'v'\n\n/* see srp.c */\nchar *SRP_check_known_gN_param(BIGNUM *g, BIGNUM *N);\nSRP_gN *SRP_get_default_gN(const char *id);\n\n/* server side .... */\nBIGNUM *SRP_Calc_server_key(BIGNUM *A, BIGNUM *v, BIGNUM *u, BIGNUM *b,\n                            BIGNUM *N);\nBIGNUM *SRP_Calc_B(BIGNUM *b, BIGNUM *N, BIGNUM *g, BIGNUM *v);\nint SRP_Verify_A_mod_N(BIGNUM *A, BIGNUM *N);\nBIGNUM *SRP_Calc_u(BIGNUM *A, BIGNUM *B, BIGNUM *N);\n\n/* client side .... */\nBIGNUM *SRP_Calc_x(BIGNUM *s, const char *user, const char *pass);\nBIGNUM *SRP_Calc_A(BIGNUM *a, BIGNUM *N, BIGNUM *g);\nBIGNUM *SRP_Calc_client_key(BIGNUM *N, BIGNUM *B, BIGNUM *g, BIGNUM *x,\n                            BIGNUM *a, BIGNUM *u);\nint SRP_Verify_B_mod_N(BIGNUM *B, BIGNUM *N);\n\n#  define SRP_MINIMAL_N 1024\n\n#ifdef  __cplusplus\n}\n#endif\n\n# endif\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/arm/include/openssl/srtp.h",
    "content": "/* ssl/srtp.h */\n/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)\n * All rights reserved.\n *\n * This package is an SSL implementation written\n * by Eric Young (eay@cryptsoft.com).\n * The implementation was written so as to conform with Netscapes SSL.\n *\n * This library is free for commercial and non-commercial use as long as\n * the following conditions are aheared to.  The following conditions\n * apply to all code found in this distribution, be it the RC4, RSA,\n * lhash, DES, etc., code; not just the SSL code.  The SSL documentation\n * included with this distribution is covered by the same copyright terms\n * except that the holder is Tim Hudson (tjh@cryptsoft.com).\n *\n * Copyright remains Eric Young's, and as such any Copyright notices in\n * the code are not to be removed.\n * If this package is used in a product, Eric Young should be given attribution\n * as the author of the parts of the library used.\n * This can be in the form of a textual message at program startup or\n * in documentation (online or textual) provided with the package.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the copyright\n *    notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in the\n *    documentation and/or other materials provided with the distribution.\n * 3. All advertising materials mentioning features or use of this software\n *    must display the following acknowledgement:\n *    \"This product includes cryptographic software written by\n *     Eric Young (eay@cryptsoft.com)\"\n *    The word 'cryptographic' can be left out if the rouines from the library\n *    being used are not cryptographic related :-).\n * 4. If you include any Windows specific code (or a derivative thereof) from\n *    the apps directory (application code) you must include an acknowledgement:\n *    \"This product includes software written by Tim Hudson (tjh@cryptsoft.com)\"\n *\n * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n * SUCH DAMAGE.\n *\n * The licence and distribution terms for any publically available version or\n * derivative of this code cannot be changed.  i.e. this code cannot simply be\n * copied and put under another distribution licence\n * [including the GNU Public Licence.]\n */\n/* ====================================================================\n * Copyright (c) 1998-2006 The OpenSSL Project.  All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n *\n * 1. Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n *\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in\n *    the documentation and/or other materials provided with the\n *    distribution.\n *\n * 3. All advertising materials mentioning features or use of this\n *    software must display the following acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit. (http://www.openssl.org/)\"\n *\n * 4. The names \"OpenSSL Toolkit\" and \"OpenSSL Project\" must not be used to\n *    endorse or promote products derived from this software without\n *    prior written permission. For written permission, please contact\n *    openssl-core@openssl.org.\n *\n * 5. Products derived from this software may not be called \"OpenSSL\"\n *    nor may \"OpenSSL\" appear in their names without prior written\n *    permission of the OpenSSL Project.\n *\n * 6. Redistributions of any form whatsoever must retain the following\n *    acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit (http://www.openssl.org/)\"\n *\n * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY\n * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\n * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR\n * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\n * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,\n * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED\n * OF THE POSSIBILITY OF SUCH DAMAGE.\n * ====================================================================\n *\n * This product includes cryptographic software written by Eric Young\n * (eay@cryptsoft.com).  This product includes software written by Tim\n * Hudson (tjh@cryptsoft.com).\n *\n */\n/*\n * DTLS code by Eric Rescorla <ekr@rtfm.com>\n *\n * Copyright (C) 2006, Network Resonance, Inc. Copyright (C) 2011, RTFM, Inc.\n */\n\n#ifndef HEADER_D1_SRTP_H\n# define HEADER_D1_SRTP_H\n\n# include <openssl/ssl.h>\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n# define SRTP_AES128_CM_SHA1_80 0x0001\n# define SRTP_AES128_CM_SHA1_32 0x0002\n# define SRTP_AES128_F8_SHA1_80 0x0003\n# define SRTP_AES128_F8_SHA1_32 0x0004\n# define SRTP_NULL_SHA1_80      0x0005\n# define SRTP_NULL_SHA1_32      0x0006\n\n# ifndef OPENSSL_NO_SRTP\n\nint SSL_CTX_set_tlsext_use_srtp(SSL_CTX *ctx, const char *profiles);\nint SSL_set_tlsext_use_srtp(SSL *ctx, const char *profiles);\n\nSTACK_OF(SRTP_PROTECTION_PROFILE) *SSL_get_srtp_profiles(SSL *ssl);\nSRTP_PROTECTION_PROFILE *SSL_get_selected_srtp_profile(SSL *s);\n\n# endif\n\n#ifdef  __cplusplus\n}\n#endif\n\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/arm/include/openssl/ssl.h",
    "content": "/* ssl/ssl.h */\n/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)\n * All rights reserved.\n *\n * This package is an SSL implementation written\n * by Eric Young (eay@cryptsoft.com).\n * The implementation was written so as to conform with Netscapes SSL.\n *\n * This library is free for commercial and non-commercial use as long as\n * the following conditions are aheared to.  The following conditions\n * apply to all code found in this distribution, be it the RC4, RSA,\n * lhash, DES, etc., code; not just the SSL code.  The SSL documentation\n * included with this distribution is covered by the same copyright terms\n * except that the holder is Tim Hudson (tjh@cryptsoft.com).\n *\n * Copyright remains Eric Young's, and as such any Copyright notices in\n * the code are not to be removed.\n * If this package is used in a product, Eric Young should be given attribution\n * as the author of the parts of the library used.\n * This can be in the form of a textual message at program startup or\n * in documentation (online or textual) provided with the package.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the copyright\n *    notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in the\n *    documentation and/or other materials provided with the distribution.\n * 3. All advertising materials mentioning features or use of this software\n *    must display the following acknowledgement:\n *    \"This product includes cryptographic software written by\n *     Eric Young (eay@cryptsoft.com)\"\n *    The word 'cryptographic' can be left out if the rouines from the library\n *    being used are not cryptographic related :-).\n * 4. If you include any Windows specific code (or a derivative thereof) from\n *    the apps directory (application code) you must include an acknowledgement:\n *    \"This product includes software written by Tim Hudson (tjh@cryptsoft.com)\"\n *\n * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n * SUCH DAMAGE.\n *\n * The licence and distribution terms for any publically available version or\n * derivative of this code cannot be changed.  i.e. this code cannot simply be\n * copied and put under another distribution licence\n * [including the GNU Public Licence.]\n */\n/* ====================================================================\n * Copyright (c) 1998-2007 The OpenSSL Project.  All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n *\n * 1. Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n *\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in\n *    the documentation and/or other materials provided with the\n *    distribution.\n *\n * 3. All advertising materials mentioning features or use of this\n *    software must display the following acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit. (http://www.openssl.org/)\"\n *\n * 4. The names \"OpenSSL Toolkit\" and \"OpenSSL Project\" must not be used to\n *    endorse or promote products derived from this software without\n *    prior written permission. For written permission, please contact\n *    openssl-core@openssl.org.\n *\n * 5. Products derived from this software may not be called \"OpenSSL\"\n *    nor may \"OpenSSL\" appear in their names without prior written\n *    permission of the OpenSSL Project.\n *\n * 6. Redistributions of any form whatsoever must retain the following\n *    acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit (http://www.openssl.org/)\"\n *\n * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY\n * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\n * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR\n * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\n * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,\n * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED\n * OF THE POSSIBILITY OF SUCH DAMAGE.\n * ====================================================================\n *\n * This product includes cryptographic software written by Eric Young\n * (eay@cryptsoft.com).  This product includes software written by Tim\n * Hudson (tjh@cryptsoft.com).\n *\n */\n/* ====================================================================\n * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED.\n * ECC cipher suite support in OpenSSL originally developed by\n * SUN MICROSYSTEMS, INC., and contributed to the OpenSSL project.\n */\n/* ====================================================================\n * Copyright 2005 Nokia. All rights reserved.\n *\n * The portions of the attached software (\"Contribution\") is developed by\n * Nokia Corporation and is licensed pursuant to the OpenSSL open source\n * license.\n *\n * The Contribution, originally written by Mika Kousa and Pasi Eronen of\n * Nokia Corporation, consists of the \"PSK\" (Pre-Shared Key) ciphersuites\n * support (see RFC 4279) to OpenSSL.\n *\n * No patent licenses or other rights except those expressly stated in\n * the OpenSSL open source license shall be deemed granted or received\n * expressly, by implication, estoppel, or otherwise.\n *\n * No assurances are provided by Nokia that the Contribution does not\n * infringe the patent or other intellectual property rights of any third\n * party or that the license provides you with all the necessary rights\n * to make use of the Contribution.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\" WITHOUT WARRANTY OF ANY KIND. IN\n * ADDITION TO THE DISCLAIMERS INCLUDED IN THE LICENSE, NOKIA\n * SPECIFICALLY DISCLAIMS ANY LIABILITY FOR CLAIMS BROUGHT BY YOU OR ANY\n * OTHER ENTITY BASED ON INFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS OR\n * OTHERWISE.\n */\n\n#ifndef HEADER_SSL_H\n# define HEADER_SSL_H\n\n# include <openssl/e_os2.h>\n\n# ifndef OPENSSL_NO_COMP\n#  include <openssl/comp.h>\n# endif\n# ifndef OPENSSL_NO_BIO\n#  include <openssl/bio.h>\n# endif\n# ifndef OPENSSL_NO_DEPRECATED\n#  ifndef OPENSSL_NO_X509\n#   include <openssl/x509.h>\n#  endif\n#  include <openssl/crypto.h>\n#  include <openssl/lhash.h>\n#  include <openssl/buffer.h>\n# endif\n# include <openssl/pem.h>\n# include <openssl/hmac.h>\n\n# include <openssl/kssl.h>\n# include <openssl/safestack.h>\n# include <openssl/symhacks.h>\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n/* SSLeay version number for ASN.1 encoding of the session information */\n/*-\n * Version 0 - initial version\n * Version 1 - added the optional peer certificate\n */\n# define SSL_SESSION_ASN1_VERSION 0x0001\n\n/* text strings for the ciphers */\n# define SSL_TXT_NULL_WITH_MD5           SSL2_TXT_NULL_WITH_MD5\n# define SSL_TXT_RC4_128_WITH_MD5        SSL2_TXT_RC4_128_WITH_MD5\n# define SSL_TXT_RC4_128_EXPORT40_WITH_MD5 SSL2_TXT_RC4_128_EXPORT40_WITH_MD5\n# define SSL_TXT_RC2_128_CBC_WITH_MD5    SSL2_TXT_RC2_128_CBC_WITH_MD5\n# define SSL_TXT_RC2_128_CBC_EXPORT40_WITH_MD5 SSL2_TXT_RC2_128_CBC_EXPORT40_WITH_MD5\n# define SSL_TXT_IDEA_128_CBC_WITH_MD5   SSL2_TXT_IDEA_128_CBC_WITH_MD5\n# define SSL_TXT_DES_64_CBC_WITH_MD5     SSL2_TXT_DES_64_CBC_WITH_MD5\n# define SSL_TXT_DES_64_CBC_WITH_SHA     SSL2_TXT_DES_64_CBC_WITH_SHA\n# define SSL_TXT_DES_192_EDE3_CBC_WITH_MD5 SSL2_TXT_DES_192_EDE3_CBC_WITH_MD5\n# define SSL_TXT_DES_192_EDE3_CBC_WITH_SHA SSL2_TXT_DES_192_EDE3_CBC_WITH_SHA\n\n/*\n * VRS Additional Kerberos5 entries\n */\n# define SSL_TXT_KRB5_DES_64_CBC_SHA   SSL3_TXT_KRB5_DES_64_CBC_SHA\n# define SSL_TXT_KRB5_DES_192_CBC3_SHA SSL3_TXT_KRB5_DES_192_CBC3_SHA\n# define SSL_TXT_KRB5_RC4_128_SHA      SSL3_TXT_KRB5_RC4_128_SHA\n# define SSL_TXT_KRB5_IDEA_128_CBC_SHA SSL3_TXT_KRB5_IDEA_128_CBC_SHA\n# define SSL_TXT_KRB5_DES_64_CBC_MD5   SSL3_TXT_KRB5_DES_64_CBC_MD5\n# define SSL_TXT_KRB5_DES_192_CBC3_MD5 SSL3_TXT_KRB5_DES_192_CBC3_MD5\n# define SSL_TXT_KRB5_RC4_128_MD5      SSL3_TXT_KRB5_RC4_128_MD5\n# define SSL_TXT_KRB5_IDEA_128_CBC_MD5 SSL3_TXT_KRB5_IDEA_128_CBC_MD5\n\n# define SSL_TXT_KRB5_DES_40_CBC_SHA   SSL3_TXT_KRB5_DES_40_CBC_SHA\n# define SSL_TXT_KRB5_RC2_40_CBC_SHA   SSL3_TXT_KRB5_RC2_40_CBC_SHA\n# define SSL_TXT_KRB5_RC4_40_SHA       SSL3_TXT_KRB5_RC4_40_SHA\n# define SSL_TXT_KRB5_DES_40_CBC_MD5   SSL3_TXT_KRB5_DES_40_CBC_MD5\n# define SSL_TXT_KRB5_RC2_40_CBC_MD5   SSL3_TXT_KRB5_RC2_40_CBC_MD5\n# define SSL_TXT_KRB5_RC4_40_MD5       SSL3_TXT_KRB5_RC4_40_MD5\n\n# define SSL_TXT_KRB5_DES_40_CBC_SHA   SSL3_TXT_KRB5_DES_40_CBC_SHA\n# define SSL_TXT_KRB5_DES_40_CBC_MD5   SSL3_TXT_KRB5_DES_40_CBC_MD5\n# define SSL_TXT_KRB5_DES_64_CBC_SHA   SSL3_TXT_KRB5_DES_64_CBC_SHA\n# define SSL_TXT_KRB5_DES_64_CBC_MD5   SSL3_TXT_KRB5_DES_64_CBC_MD5\n# define SSL_TXT_KRB5_DES_192_CBC3_SHA SSL3_TXT_KRB5_DES_192_CBC3_SHA\n# define SSL_TXT_KRB5_DES_192_CBC3_MD5 SSL3_TXT_KRB5_DES_192_CBC3_MD5\n# define SSL_MAX_KRB5_PRINCIPAL_LENGTH  256\n\n# define SSL_MAX_SSL_SESSION_ID_LENGTH           32\n# define SSL_MAX_SID_CTX_LENGTH                  32\n\n# define SSL_MIN_RSA_MODULUS_LENGTH_IN_BYTES     (512/8)\n# define SSL_MAX_KEY_ARG_LENGTH                  8\n# define SSL_MAX_MASTER_KEY_LENGTH               48\n\n/* These are used to specify which ciphers to use and not to use */\n\n# define SSL_TXT_EXP40           \"EXPORT40\"\n# define SSL_TXT_EXP56           \"EXPORT56\"\n# define SSL_TXT_LOW             \"LOW\"\n# define SSL_TXT_MEDIUM          \"MEDIUM\"\n# define SSL_TXT_HIGH            \"HIGH\"\n# define SSL_TXT_FIPS            \"FIPS\"\n\n# define SSL_TXT_kFZA            \"kFZA\"/* unused! */\n# define SSL_TXT_aFZA            \"aFZA\"/* unused! */\n# define SSL_TXT_eFZA            \"eFZA\"/* unused! */\n# define SSL_TXT_FZA             \"FZA\"/* unused! */\n\n# define SSL_TXT_aNULL           \"aNULL\"\n# define SSL_TXT_eNULL           \"eNULL\"\n# define SSL_TXT_NULL            \"NULL\"\n\n# define SSL_TXT_kRSA            \"kRSA\"\n# define SSL_TXT_kDHr            \"kDHr\"\n# define SSL_TXT_kDHd            \"kDHd\"\n# define SSL_TXT_kDH             \"kDH\"\n# define SSL_TXT_kEDH            \"kEDH\"\n# define SSL_TXT_kDHE            \"kDHE\"/* alias for kEDH */\n# define SSL_TXT_kKRB5           \"kKRB5\"\n# define SSL_TXT_kECDHr          \"kECDHr\"\n# define SSL_TXT_kECDHe          \"kECDHe\"\n# define SSL_TXT_kECDH           \"kECDH\"\n# define SSL_TXT_kEECDH          \"kEECDH\"\n# define SSL_TXT_kECDHE          \"kECDHE\"/* alias for kEECDH */\n# define SSL_TXT_kPSK            \"kPSK\"\n# define SSL_TXT_kGOST           \"kGOST\"\n# define SSL_TXT_kSRP            \"kSRP\"\n\n# define SSL_TXT_aRSA            \"aRSA\"\n# define SSL_TXT_aDSS            \"aDSS\"\n# define SSL_TXT_aDH             \"aDH\"\n# define SSL_TXT_aECDH           \"aECDH\"\n# define SSL_TXT_aKRB5           \"aKRB5\"\n# define SSL_TXT_aECDSA          \"aECDSA\"\n# define SSL_TXT_aPSK            \"aPSK\"\n# define SSL_TXT_aGOST94 \"aGOST94\"\n# define SSL_TXT_aGOST01 \"aGOST01\"\n# define SSL_TXT_aGOST  \"aGOST\"\n# define SSL_TXT_aSRP            \"aSRP\"\n\n# define SSL_TXT_DSS             \"DSS\"\n# define SSL_TXT_DH              \"DH\"\n# define SSL_TXT_EDH             \"EDH\"/* same as \"kEDH:-ADH\" */\n# define SSL_TXT_DHE             \"DHE\"/* alias for EDH */\n# define SSL_TXT_ADH             \"ADH\"\n# define SSL_TXT_RSA             \"RSA\"\n# define SSL_TXT_ECDH            \"ECDH\"\n# define SSL_TXT_EECDH           \"EECDH\"/* same as \"kEECDH:-AECDH\" */\n# define SSL_TXT_ECDHE           \"ECDHE\"/* alias for ECDHE\" */\n# define SSL_TXT_AECDH           \"AECDH\"\n# define SSL_TXT_ECDSA           \"ECDSA\"\n# define SSL_TXT_KRB5            \"KRB5\"\n# define SSL_TXT_PSK             \"PSK\"\n# define SSL_TXT_SRP             \"SRP\"\n\n# define SSL_TXT_DES             \"DES\"\n# define SSL_TXT_3DES            \"3DES\"\n# define SSL_TXT_RC4             \"RC4\"\n# define SSL_TXT_RC2             \"RC2\"\n# define SSL_TXT_IDEA            \"IDEA\"\n# define SSL_TXT_SEED            \"SEED\"\n# define SSL_TXT_AES128          \"AES128\"\n# define SSL_TXT_AES256          \"AES256\"\n# define SSL_TXT_AES             \"AES\"\n# define SSL_TXT_AES_GCM         \"AESGCM\"\n# define SSL_TXT_CAMELLIA128     \"CAMELLIA128\"\n# define SSL_TXT_CAMELLIA256     \"CAMELLIA256\"\n# define SSL_TXT_CAMELLIA        \"CAMELLIA\"\n\n# define SSL_TXT_MD5             \"MD5\"\n# define SSL_TXT_SHA1            \"SHA1\"\n# define SSL_TXT_SHA             \"SHA\"/* same as \"SHA1\" */\n# define SSL_TXT_GOST94          \"GOST94\"\n# define SSL_TXT_GOST89MAC               \"GOST89MAC\"\n# define SSL_TXT_SHA256          \"SHA256\"\n# define SSL_TXT_SHA384          \"SHA384\"\n\n# define SSL_TXT_SSLV2           \"SSLv2\"\n# define SSL_TXT_SSLV3           \"SSLv3\"\n# define SSL_TXT_TLSV1           \"TLSv1\"\n# define SSL_TXT_TLSV1_1         \"TLSv1.1\"\n# define SSL_TXT_TLSV1_2         \"TLSv1.2\"\n\n# define SSL_TXT_EXP             \"EXP\"\n# define SSL_TXT_EXPORT          \"EXPORT\"\n\n# define SSL_TXT_ALL             \"ALL\"\n\n/*-\n * COMPLEMENTOF* definitions. These identifiers are used to (de-select)\n * ciphers normally not being used.\n * Example: \"RC4\" will activate all ciphers using RC4 including ciphers\n * without authentication, which would normally disabled by DEFAULT (due\n * the \"!ADH\" being part of default). Therefore \"RC4:!COMPLEMENTOFDEFAULT\"\n * will make sure that it is also disabled in the specific selection.\n * COMPLEMENTOF* identifiers are portable between version, as adjustments\n * to the default cipher setup will also be included here.\n *\n * COMPLEMENTOFDEFAULT does not experience the same special treatment that\n * DEFAULT gets, as only selection is being done and no sorting as needed\n * for DEFAULT.\n */\n# define SSL_TXT_CMPALL          \"COMPLEMENTOFALL\"\n# define SSL_TXT_CMPDEF          \"COMPLEMENTOFDEFAULT\"\n\n/*\n * The following cipher list is used by default. It also is substituted when\n * an application-defined cipher list string starts with 'DEFAULT'.\n */\n# define SSL_DEFAULT_CIPHER_LIST \"ALL:!EXPORT:!LOW:!aNULL:!eNULL:!SSLv2\"\n/*\n * As of OpenSSL 1.0.0, ssl_create_cipher_list() in ssl/ssl_ciph.c always\n * starts with a reasonable order, and all we have to do for DEFAULT is\n * throwing out anonymous and unencrypted ciphersuites! (The latter are not\n * actually enabled by ALL, but \"ALL:RSA\" would enable some of them.)\n */\n\n/* Used in SSL_set_shutdown()/SSL_get_shutdown(); */\n# define SSL_SENT_SHUTDOWN       1\n# define SSL_RECEIVED_SHUTDOWN   2\n\n#ifdef __cplusplus\n}\n#endif\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n# if (defined(OPENSSL_NO_RSA) || defined(OPENSSL_NO_MD5)) && !defined(OPENSSL_NO_SSL2)\n#  define OPENSSL_NO_SSL2\n# endif\n\n# define SSL_FILETYPE_ASN1       X509_FILETYPE_ASN1\n# define SSL_FILETYPE_PEM        X509_FILETYPE_PEM\n\n/*\n * This is needed to stop compilers complaining about the 'struct ssl_st *'\n * function parameters used to prototype callbacks in SSL_CTX.\n */\ntypedef struct ssl_st *ssl_crock_st;\ntypedef struct tls_session_ticket_ext_st TLS_SESSION_TICKET_EXT;\ntypedef struct ssl_method_st SSL_METHOD;\ntypedef struct ssl_cipher_st SSL_CIPHER;\ntypedef struct ssl_session_st SSL_SESSION;\ntypedef struct tls_sigalgs_st TLS_SIGALGS;\ntypedef struct ssl_conf_ctx_st SSL_CONF_CTX;\n\nDECLARE_STACK_OF(SSL_CIPHER)\n\n/* SRTP protection profiles for use with the use_srtp extension (RFC 5764)*/\ntypedef struct srtp_protection_profile_st {\n    const char *name;\n    unsigned long id;\n} SRTP_PROTECTION_PROFILE;\n\nDECLARE_STACK_OF(SRTP_PROTECTION_PROFILE)\n\ntypedef int (*tls_session_ticket_ext_cb_fn) (SSL *s,\n                                             const unsigned char *data,\n                                             int len, void *arg);\ntypedef int (*tls_session_secret_cb_fn) (SSL *s, void *secret,\n                                         int *secret_len,\n                                         STACK_OF(SSL_CIPHER) *peer_ciphers,\n                                         SSL_CIPHER **cipher, void *arg);\n\n# ifndef OPENSSL_NO_TLSEXT\n\n/* Typedefs for handling custom extensions */\n\ntypedef int (*custom_ext_add_cb) (SSL *s, unsigned int ext_type,\n                                  const unsigned char **out,\n                                  size_t *outlen, int *al, void *add_arg);\n\ntypedef void (*custom_ext_free_cb) (SSL *s, unsigned int ext_type,\n                                    const unsigned char *out, void *add_arg);\n\ntypedef int (*custom_ext_parse_cb) (SSL *s, unsigned int ext_type,\n                                    const unsigned char *in,\n                                    size_t inlen, int *al, void *parse_arg);\n\n# endif\n\n# ifndef OPENSSL_NO_SSL_INTERN\n\n/* used to hold info on the particular ciphers used */\nstruct ssl_cipher_st {\n    int valid;\n    const char *name;           /* text name */\n    unsigned long id;           /* id, 4 bytes, first is version */\n    /*\n     * changed in 0.9.9: these four used to be portions of a single value\n     * 'algorithms'\n     */\n    unsigned long algorithm_mkey; /* key exchange algorithm */\n    unsigned long algorithm_auth; /* server authentication */\n    unsigned long algorithm_enc; /* symmetric encryption */\n    unsigned long algorithm_mac; /* symmetric authentication */\n    unsigned long algorithm_ssl; /* (major) protocol version */\n    unsigned long algo_strength; /* strength and export flags */\n    unsigned long algorithm2;   /* Extra flags */\n    int strength_bits;          /* Number of bits really used */\n    int alg_bits;               /* Number of bits for algorithm */\n};\n\n/* Used to hold functions for SSLv2 or SSLv3/TLSv1 functions */\nstruct ssl_method_st {\n    int version;\n    int (*ssl_new) (SSL *s);\n    void (*ssl_clear) (SSL *s);\n    void (*ssl_free) (SSL *s);\n    int (*ssl_accept) (SSL *s);\n    int (*ssl_connect) (SSL *s);\n    int (*ssl_read) (SSL *s, void *buf, int len);\n    int (*ssl_peek) (SSL *s, void *buf, int len);\n    int (*ssl_write) (SSL *s, const void *buf, int len);\n    int (*ssl_shutdown) (SSL *s);\n    int (*ssl_renegotiate) (SSL *s);\n    int (*ssl_renegotiate_check) (SSL *s);\n    long (*ssl_get_message) (SSL *s, int st1, int stn, int mt, long\n                             max, int *ok);\n    int (*ssl_read_bytes) (SSL *s, int type, unsigned char *buf, int len,\n                           int peek);\n    int (*ssl_write_bytes) (SSL *s, int type, const void *buf_, int len);\n    int (*ssl_dispatch_alert) (SSL *s);\n    long (*ssl_ctrl) (SSL *s, int cmd, long larg, void *parg);\n    long (*ssl_ctx_ctrl) (SSL_CTX *ctx, int cmd, long larg, void *parg);\n    const SSL_CIPHER *(*get_cipher_by_char) (const unsigned char *ptr);\n    int (*put_cipher_by_char) (const SSL_CIPHER *cipher, unsigned char *ptr);\n    int (*ssl_pending) (const SSL *s);\n    int (*num_ciphers) (void);\n    const SSL_CIPHER *(*get_cipher) (unsigned ncipher);\n    const struct ssl_method_st *(*get_ssl_method) (int version);\n    long (*get_timeout) (void);\n    struct ssl3_enc_method *ssl3_enc; /* Extra SSLv3/TLS stuff */\n    int (*ssl_version) (void);\n    long (*ssl_callback_ctrl) (SSL *s, int cb_id, void (*fp) (void));\n    long (*ssl_ctx_callback_ctrl) (SSL_CTX *s, int cb_id, void (*fp) (void));\n};\n\n/*-\n * Lets make this into an ASN.1 type structure as follows\n * SSL_SESSION_ID ::= SEQUENCE {\n *      version                 INTEGER,        -- structure version number\n *      SSLversion              INTEGER,        -- SSL version number\n *      Cipher                  OCTET STRING,   -- the 3 byte cipher ID\n *      Session_ID              OCTET STRING,   -- the Session ID\n *      Master_key              OCTET STRING,   -- the master key\n *      KRB5_principal          OCTET STRING    -- optional Kerberos principal\n *      Key_Arg [ 0 ] IMPLICIT  OCTET STRING,   -- the optional Key argument\n *      Time [ 1 ] EXPLICIT     INTEGER,        -- optional Start Time\n *      Timeout [ 2 ] EXPLICIT  INTEGER,        -- optional Timeout ins seconds\n *      Peer [ 3 ] EXPLICIT     X509,           -- optional Peer Certificate\n *      Session_ID_context [ 4 ] EXPLICIT OCTET STRING,   -- the Session ID context\n *      Verify_result [ 5 ] EXPLICIT INTEGER,   -- X509_V_... code for `Peer'\n *      HostName [ 6 ] EXPLICIT OCTET STRING,   -- optional HostName from servername TLS extension\n *      PSK_identity_hint [ 7 ] EXPLICIT OCTET STRING, -- optional PSK identity hint\n *      PSK_identity [ 8 ] EXPLICIT OCTET STRING,  -- optional PSK identity\n *      Ticket_lifetime_hint [9] EXPLICIT INTEGER, -- server's lifetime hint for session ticket\n *      Ticket [10]             EXPLICIT OCTET STRING, -- session ticket (clients only)\n *      Compression_meth [11]   EXPLICIT OCTET STRING, -- optional compression method\n *      SRP_username [ 12 ] EXPLICIT OCTET STRING -- optional SRP username\n *      }\n * Look in ssl/ssl_asn1.c for more details\n * I'm using EXPLICIT tags so I can read the damn things using asn1parse :-).\n */\nstruct ssl_session_st {\n    int ssl_version;            /* what ssl version session info is being\n                                 * kept in here? */\n    /* only really used in SSLv2 */\n    unsigned int key_arg_length;\n    unsigned char key_arg[SSL_MAX_KEY_ARG_LENGTH];\n    int master_key_length;\n    unsigned char master_key[SSL_MAX_MASTER_KEY_LENGTH];\n    /* session_id - valid? */\n    unsigned int session_id_length;\n    unsigned char session_id[SSL_MAX_SSL_SESSION_ID_LENGTH];\n    /*\n     * this is used to determine whether the session is being reused in the\n     * appropriate context. It is up to the application to set this, via\n     * SSL_new\n     */\n    unsigned int sid_ctx_length;\n    unsigned char sid_ctx[SSL_MAX_SID_CTX_LENGTH];\n#  ifndef OPENSSL_NO_KRB5\n    unsigned int krb5_client_princ_len;\n    unsigned char krb5_client_princ[SSL_MAX_KRB5_PRINCIPAL_LENGTH];\n#  endif                        /* OPENSSL_NO_KRB5 */\n#  ifndef OPENSSL_NO_PSK\n    char *psk_identity_hint;\n    char *psk_identity;\n#  endif\n    /*\n     * Used to indicate that session resumption is not allowed. Applications\n     * can also set this bit for a new session via not_resumable_session_cb\n     * to disable session caching and tickets.\n     */\n    int not_resumable;\n    /* The cert is the certificate used to establish this connection */\n    struct sess_cert_st /* SESS_CERT */ *sess_cert;\n    /*\n     * This is the cert for the other end. On clients, it will be the same as\n     * sess_cert->peer_key->x509 (the latter is not enough as sess_cert is\n     * not retained in the external representation of sessions, see\n     * ssl_asn1.c).\n     */\n    X509 *peer;\n    /*\n     * when app_verify_callback accepts a session where the peer's\n     * certificate is not ok, we must remember the error for session reuse:\n     */\n    long verify_result;         /* only for servers */\n    int references;\n    long timeout;\n    long time;\n    unsigned int compress_meth; /* Need to lookup the method */\n    const SSL_CIPHER *cipher;\n    unsigned long cipher_id;    /* when ASN.1 loaded, this needs to be used\n                                 * to load the 'cipher' structure */\n    STACK_OF(SSL_CIPHER) *ciphers; /* shared ciphers? */\n    CRYPTO_EX_DATA ex_data;     /* application specific data */\n    /*\n     * These are used to make removal of session-ids more efficient and to\n     * implement a maximum cache size.\n     */\n    struct ssl_session_st *prev, *next;\n#  ifndef OPENSSL_NO_TLSEXT\n    char *tlsext_hostname;\n#   ifndef OPENSSL_NO_EC\n    size_t tlsext_ecpointformatlist_length;\n    unsigned char *tlsext_ecpointformatlist; /* peer's list */\n    size_t tlsext_ellipticcurvelist_length;\n    unsigned char *tlsext_ellipticcurvelist; /* peer's list */\n#   endif                       /* OPENSSL_NO_EC */\n    /* RFC4507 info */\n    unsigned char *tlsext_tick; /* Session ticket */\n    size_t tlsext_ticklen;      /* Session ticket length */\n    long tlsext_tick_lifetime_hint; /* Session lifetime hint in seconds */\n#  endif\n#  ifndef OPENSSL_NO_SRP\n    char *srp_username;\n#  endif\n};\n\n# endif\n\n# define SSL_OP_MICROSOFT_SESS_ID_BUG                    0x00000001L\n# define SSL_OP_NETSCAPE_CHALLENGE_BUG                   0x00000002L\n/* Allow initial connection to servers that don't support RI */\n# define SSL_OP_LEGACY_SERVER_CONNECT                    0x00000004L\n# define SSL_OP_NETSCAPE_REUSE_CIPHER_CHANGE_BUG         0x00000008L\n# define SSL_OP_TLSEXT_PADDING                           0x00000010L\n# define SSL_OP_MICROSOFT_BIG_SSLV3_BUFFER               0x00000020L\n# define SSL_OP_SAFARI_ECDHE_ECDSA_BUG                   0x00000040L\n# define SSL_OP_SSLEAY_080_CLIENT_DH_BUG                 0x00000080L\n# define SSL_OP_TLS_D5_BUG                               0x00000100L\n# define SSL_OP_TLS_BLOCK_PADDING_BUG                    0x00000200L\n\n/* Hasn't done anything since OpenSSL 0.9.7h, retained for compatibility */\n# define SSL_OP_MSIE_SSLV2_RSA_PADDING                   0x0\n/* Refers to ancient SSLREF and SSLv2, retained for compatibility */\n# define SSL_OP_SSLREF2_REUSE_CERT_TYPE_BUG              0x0\n\n/*\n * Disable SSL 3.0/TLS 1.0 CBC vulnerability workaround that was added in\n * OpenSSL 0.9.6d.  Usually (depending on the application protocol) the\n * workaround is not needed.  Unfortunately some broken SSL/TLS\n * implementations cannot handle it at all, which is why we include it in\n * SSL_OP_ALL.\n */\n/* added in 0.9.6e */\n# define SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS              0x00000800L\n\n/*\n * SSL_OP_ALL: various bug workarounds that should be rather harmless.  This\n * used to be 0x000FFFFFL before 0.9.7.\n */\n# define SSL_OP_ALL                                      0x80000BFFL\n\n/* DTLS options */\n# define SSL_OP_NO_QUERY_MTU                 0x00001000L\n/* Turn on Cookie Exchange (on relevant for servers) */\n# define SSL_OP_COOKIE_EXCHANGE              0x00002000L\n/* Don't use RFC4507 ticket extension */\n# define SSL_OP_NO_TICKET                    0x00004000L\n/* Use Cisco's \"speshul\" version of DTLS_BAD_VER (as client)  */\n# define SSL_OP_CISCO_ANYCONNECT             0x00008000L\n\n/* As server, disallow session resumption on renegotiation */\n# define SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION   0x00010000L\n/* Don't use compression even if supported */\n# define SSL_OP_NO_COMPRESSION                           0x00020000L\n/* Permit unsafe legacy renegotiation */\n# define SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION        0x00040000L\n/* If set, always create a new key when using tmp_ecdh parameters */\n# define SSL_OP_SINGLE_ECDH_USE                          0x00080000L\n/* Does nothing: retained for compatibility */\n# define SSL_OP_SINGLE_DH_USE                            0x00100000L\n/* Does nothing: retained for compatibiity */\n# define SSL_OP_EPHEMERAL_RSA                            0x0\n/*\n * Set on servers to choose the cipher according to the server's preferences\n */\n# define SSL_OP_CIPHER_SERVER_PREFERENCE                 0x00400000L\n/*\n * If set, a server will allow a client to issue a SSLv3.0 version number as\n * latest version supported in the premaster secret, even when TLSv1.0\n * (version 3.1) was announced in the client hello. Normally this is\n * forbidden to prevent version rollback attacks.\n */\n# define SSL_OP_TLS_ROLLBACK_BUG                         0x00800000L\n\n# define SSL_OP_NO_SSLv2                                 0x01000000L\n# define SSL_OP_NO_SSLv3                                 0x02000000L\n# define SSL_OP_NO_TLSv1                                 0x04000000L\n# define SSL_OP_NO_TLSv1_2                               0x08000000L\n# define SSL_OP_NO_TLSv1_1                               0x10000000L\n\n# define SSL_OP_NO_DTLSv1                                0x04000000L\n# define SSL_OP_NO_DTLSv1_2                              0x08000000L\n\n# define SSL_OP_NO_SSL_MASK (SSL_OP_NO_SSLv2|SSL_OP_NO_SSLv3|\\\n        SSL_OP_NO_TLSv1|SSL_OP_NO_TLSv1_1|SSL_OP_NO_TLSv1_2)\n\n/*\n * These next two were never actually used for anything since SSLeay zap so\n * we have some more flags.\n */\n/*\n * The next flag deliberately changes the ciphertest, this is a check for the\n * PKCS#1 attack\n */\n# define SSL_OP_PKCS1_CHECK_1                            0x0\n# define SSL_OP_PKCS1_CHECK_2                            0x0\n\n# define SSL_OP_NETSCAPE_CA_DN_BUG                       0x20000000L\n# define SSL_OP_NETSCAPE_DEMO_CIPHER_CHANGE_BUG          0x40000000L\n/*\n * Make server add server-hello extension from early version of cryptopro\n * draft, when GOST ciphersuite is negotiated. Required for interoperability\n * with CryptoPro CSP 3.x\n */\n# define SSL_OP_CRYPTOPRO_TLSEXT_BUG                     0x80000000L\n\n/*\n * Allow SSL_write(..., n) to return r with 0 < r < n (i.e. report success\n * when just a single record has been written):\n */\n# define SSL_MODE_ENABLE_PARTIAL_WRITE       0x00000001L\n/*\n * Make it possible to retry SSL_write() with changed buffer location (buffer\n * contents must stay the same!); this is not the default to avoid the\n * misconception that non-blocking SSL_write() behaves like non-blocking\n * write():\n */\n# define SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER 0x00000002L\n/*\n * Never bother the application with retries if the transport is blocking:\n */\n# define SSL_MODE_AUTO_RETRY 0x00000004L\n/* Don't attempt to automatically build certificate chain */\n# define SSL_MODE_NO_AUTO_CHAIN 0x00000008L\n/*\n * Save RAM by releasing read and write buffers when they're empty. (SSL3 and\n * TLS only.) \"Released\" buffers are put onto a free-list in the context or\n * just freed (depending on the context's setting for freelist_max_len).\n */\n# define SSL_MODE_RELEASE_BUFFERS 0x00000010L\n/*\n * Send the current time in the Random fields of the ClientHello and\n * ServerHello records for compatibility with hypothetical implementations\n * that require it.\n */\n# define SSL_MODE_SEND_CLIENTHELLO_TIME 0x00000020L\n# define SSL_MODE_SEND_SERVERHELLO_TIME 0x00000040L\n/*\n * Send TLS_FALLBACK_SCSV in the ClientHello. To be set only by applications\n * that reconnect with a downgraded protocol version; see\n * draft-ietf-tls-downgrade-scsv-00 for details. DO NOT ENABLE THIS if your\n * application attempts a normal handshake. Only use this in explicit\n * fallback retries, following the guidance in\n * draft-ietf-tls-downgrade-scsv-00.\n */\n# define SSL_MODE_SEND_FALLBACK_SCSV 0x00000080L\n\n/* Cert related flags */\n/*\n * Many implementations ignore some aspects of the TLS standards such as\n * enforcing certifcate chain algorithms. When this is set we enforce them.\n */\n# define SSL_CERT_FLAG_TLS_STRICT                0x00000001L\n\n/* Suite B modes, takes same values as certificate verify flags */\n# define SSL_CERT_FLAG_SUITEB_128_LOS_ONLY       0x10000\n/* Suite B 192 bit only mode */\n# define SSL_CERT_FLAG_SUITEB_192_LOS            0x20000\n/* Suite B 128 bit mode allowing 192 bit algorithms */\n# define SSL_CERT_FLAG_SUITEB_128_LOS            0x30000\n\n/* Perform all sorts of protocol violations for testing purposes */\n# define SSL_CERT_FLAG_BROKEN_PROTOCOL           0x10000000\n\n/* Flags for building certificate chains */\n/* Treat any existing certificates as untrusted CAs */\n# define SSL_BUILD_CHAIN_FLAG_UNTRUSTED          0x1\n/* Don't include root CA in chain */\n# define SSL_BUILD_CHAIN_FLAG_NO_ROOT            0x2\n/* Just check certificates already there */\n# define SSL_BUILD_CHAIN_FLAG_CHECK              0x4\n/* Ignore verification errors */\n# define SSL_BUILD_CHAIN_FLAG_IGNORE_ERROR       0x8\n/* Clear verification errors from queue */\n# define SSL_BUILD_CHAIN_FLAG_CLEAR_ERROR        0x10\n\n/* Flags returned by SSL_check_chain */\n/* Certificate can be used with this session */\n# define CERT_PKEY_VALID         0x1\n/* Certificate can also be used for signing */\n# define CERT_PKEY_SIGN          0x2\n/* EE certificate signing algorithm OK */\n# define CERT_PKEY_EE_SIGNATURE  0x10\n/* CA signature algorithms OK */\n# define CERT_PKEY_CA_SIGNATURE  0x20\n/* EE certificate parameters OK */\n# define CERT_PKEY_EE_PARAM      0x40\n/* CA certificate parameters OK */\n# define CERT_PKEY_CA_PARAM      0x80\n/* Signing explicitly allowed as opposed to SHA1 fallback */\n# define CERT_PKEY_EXPLICIT_SIGN 0x100\n/* Client CA issuer names match (always set for server cert) */\n# define CERT_PKEY_ISSUER_NAME   0x200\n/* Cert type matches client types (always set for server cert) */\n# define CERT_PKEY_CERT_TYPE     0x400\n/* Cert chain suitable to Suite B */\n# define CERT_PKEY_SUITEB        0x800\n\n# define SSL_CONF_FLAG_CMDLINE           0x1\n# define SSL_CONF_FLAG_FILE              0x2\n# define SSL_CONF_FLAG_CLIENT            0x4\n# define SSL_CONF_FLAG_SERVER            0x8\n# define SSL_CONF_FLAG_SHOW_ERRORS       0x10\n# define SSL_CONF_FLAG_CERTIFICATE       0x20\n/* Configuration value types */\n# define SSL_CONF_TYPE_UNKNOWN           0x0\n# define SSL_CONF_TYPE_STRING            0x1\n# define SSL_CONF_TYPE_FILE              0x2\n# define SSL_CONF_TYPE_DIR               0x3\n\n/*\n * Note: SSL[_CTX]_set_{options,mode} use |= op on the previous value, they\n * cannot be used to clear bits.\n */\n\n# define SSL_CTX_set_options(ctx,op) \\\n        SSL_CTX_ctrl((ctx),SSL_CTRL_OPTIONS,(op),NULL)\n# define SSL_CTX_clear_options(ctx,op) \\\n        SSL_CTX_ctrl((ctx),SSL_CTRL_CLEAR_OPTIONS,(op),NULL)\n# define SSL_CTX_get_options(ctx) \\\n        SSL_CTX_ctrl((ctx),SSL_CTRL_OPTIONS,0,NULL)\n# define SSL_set_options(ssl,op) \\\n        SSL_ctrl((ssl),SSL_CTRL_OPTIONS,(op),NULL)\n# define SSL_clear_options(ssl,op) \\\n        SSL_ctrl((ssl),SSL_CTRL_CLEAR_OPTIONS,(op),NULL)\n# define SSL_get_options(ssl) \\\n        SSL_ctrl((ssl),SSL_CTRL_OPTIONS,0,NULL)\n\n# define SSL_CTX_set_mode(ctx,op) \\\n        SSL_CTX_ctrl((ctx),SSL_CTRL_MODE,(op),NULL)\n# define SSL_CTX_clear_mode(ctx,op) \\\n        SSL_CTX_ctrl((ctx),SSL_CTRL_CLEAR_MODE,(op),NULL)\n# define SSL_CTX_get_mode(ctx) \\\n        SSL_CTX_ctrl((ctx),SSL_CTRL_MODE,0,NULL)\n# define SSL_clear_mode(ssl,op) \\\n        SSL_ctrl((ssl),SSL_CTRL_CLEAR_MODE,(op),NULL)\n# define SSL_set_mode(ssl,op) \\\n        SSL_ctrl((ssl),SSL_CTRL_MODE,(op),NULL)\n# define SSL_get_mode(ssl) \\\n        SSL_ctrl((ssl),SSL_CTRL_MODE,0,NULL)\n# define SSL_set_mtu(ssl, mtu) \\\n        SSL_ctrl((ssl),SSL_CTRL_SET_MTU,(mtu),NULL)\n# define DTLS_set_link_mtu(ssl, mtu) \\\n        SSL_ctrl((ssl),DTLS_CTRL_SET_LINK_MTU,(mtu),NULL)\n# define DTLS_get_link_min_mtu(ssl) \\\n        SSL_ctrl((ssl),DTLS_CTRL_GET_LINK_MIN_MTU,0,NULL)\n\n# define SSL_get_secure_renegotiation_support(ssl) \\\n        SSL_ctrl((ssl), SSL_CTRL_GET_RI_SUPPORT, 0, NULL)\n\n# ifndef OPENSSL_NO_HEARTBEATS\n#  define SSL_heartbeat(ssl) \\\n        SSL_ctrl((ssl),SSL_CTRL_TLS_EXT_SEND_HEARTBEAT,0,NULL)\n# endif\n\n# define SSL_CTX_set_cert_flags(ctx,op) \\\n        SSL_CTX_ctrl((ctx),SSL_CTRL_CERT_FLAGS,(op),NULL)\n# define SSL_set_cert_flags(s,op) \\\n        SSL_ctrl((s),SSL_CTRL_CERT_FLAGS,(op),NULL)\n# define SSL_CTX_clear_cert_flags(ctx,op) \\\n        SSL_CTX_ctrl((ctx),SSL_CTRL_CLEAR_CERT_FLAGS,(op),NULL)\n# define SSL_clear_cert_flags(s,op) \\\n        SSL_ctrl((s),SSL_CTRL_CLEAR_CERT_FLAGS,(op),NULL)\n\nvoid SSL_CTX_set_msg_callback(SSL_CTX *ctx,\n                              void (*cb) (int write_p, int version,\n                                          int content_type, const void *buf,\n                                          size_t len, SSL *ssl, void *arg));\nvoid SSL_set_msg_callback(SSL *ssl,\n                          void (*cb) (int write_p, int version,\n                                      int content_type, const void *buf,\n                                      size_t len, SSL *ssl, void *arg));\n# define SSL_CTX_set_msg_callback_arg(ctx, arg) SSL_CTX_ctrl((ctx), SSL_CTRL_SET_MSG_CALLBACK_ARG, 0, (arg))\n# define SSL_set_msg_callback_arg(ssl, arg) SSL_ctrl((ssl), SSL_CTRL_SET_MSG_CALLBACK_ARG, 0, (arg))\n\n# ifndef OPENSSL_NO_SRP\n\n#  ifndef OPENSSL_NO_SSL_INTERN\n\ntypedef struct srp_ctx_st {\n    /* param for all the callbacks */\n    void *SRP_cb_arg;\n    /* set client Hello login callback */\n    int (*TLS_ext_srp_username_callback) (SSL *, int *, void *);\n    /* set SRP N/g param callback for verification */\n    int (*SRP_verify_param_callback) (SSL *, void *);\n    /* set SRP client passwd callback */\n    char *(*SRP_give_srp_client_pwd_callback) (SSL *, void *);\n    char *login;\n    BIGNUM *N, *g, *s, *B, *A;\n    BIGNUM *a, *b, *v;\n    char *info;\n    int strength;\n    unsigned long srp_Mask;\n} SRP_CTX;\n\n#  endif\n\n/* see tls_srp.c */\nint SSL_SRP_CTX_init(SSL *s);\nint SSL_CTX_SRP_CTX_init(SSL_CTX *ctx);\nint SSL_SRP_CTX_free(SSL *ctx);\nint SSL_CTX_SRP_CTX_free(SSL_CTX *ctx);\nint SSL_srp_server_param_with_username(SSL *s, int *ad);\nint SRP_generate_server_master_secret(SSL *s, unsigned char *master_key);\nint SRP_Calc_A_param(SSL *s);\nint SRP_generate_client_master_secret(SSL *s, unsigned char *master_key);\n\n# endif\n\n# if defined(OPENSSL_SYS_MSDOS) && !defined(OPENSSL_SYS_WIN32)\n#  define SSL_MAX_CERT_LIST_DEFAULT 1024*30\n                                          /* 30k max cert list :-) */\n# else\n#  define SSL_MAX_CERT_LIST_DEFAULT 1024*100\n                                           /* 100k max cert list :-) */\n# endif\n\n# define SSL_SESSION_CACHE_MAX_SIZE_DEFAULT      (1024*20)\n\n/*\n * This callback type is used inside SSL_CTX, SSL, and in the functions that\n * set them. It is used to override the generation of SSL/TLS session IDs in\n * a server. Return value should be zero on an error, non-zero to proceed.\n * Also, callbacks should themselves check if the id they generate is unique\n * otherwise the SSL handshake will fail with an error - callbacks can do\n * this using the 'ssl' value they're passed by;\n * SSL_has_matching_session_id(ssl, id, *id_len) The length value passed in\n * is set at the maximum size the session ID can be. In SSLv2 this is 16\n * bytes, whereas SSLv3/TLSv1 it is 32 bytes. The callback can alter this\n * length to be less if desired, but under SSLv2 session IDs are supposed to\n * be fixed at 16 bytes so the id will be padded after the callback returns\n * in this case. It is also an error for the callback to set the size to\n * zero.\n */\ntypedef int (*GEN_SESSION_CB) (const SSL *ssl, unsigned char *id,\n                               unsigned int *id_len);\n\ntypedef struct ssl_comp_st SSL_COMP;\n\n# ifndef OPENSSL_NO_SSL_INTERN\n\nstruct ssl_comp_st {\n    int id;\n    const char *name;\n#  ifndef OPENSSL_NO_COMP\n    COMP_METHOD *method;\n#  else\n    char *method;\n#  endif\n};\n\nDECLARE_STACK_OF(SSL_COMP)\nDECLARE_LHASH_OF(SSL_SESSION);\n\nstruct ssl_ctx_st {\n    const SSL_METHOD *method;\n    STACK_OF(SSL_CIPHER) *cipher_list;\n    /* same as above but sorted for lookup */\n    STACK_OF(SSL_CIPHER) *cipher_list_by_id;\n    struct x509_store_st /* X509_STORE */ *cert_store;\n    LHASH_OF(SSL_SESSION) *sessions;\n    /*\n     * Most session-ids that will be cached, default is\n     * SSL_SESSION_CACHE_MAX_SIZE_DEFAULT. 0 is unlimited.\n     */\n    unsigned long session_cache_size;\n    struct ssl_session_st *session_cache_head;\n    struct ssl_session_st *session_cache_tail;\n    /*\n     * This can have one of 2 values, ored together, SSL_SESS_CACHE_CLIENT,\n     * SSL_SESS_CACHE_SERVER, Default is SSL_SESSION_CACHE_SERVER, which\n     * means only SSL_accept which cache SSL_SESSIONS.\n     */\n    int session_cache_mode;\n    /*\n     * If timeout is not 0, it is the default timeout value set when\n     * SSL_new() is called.  This has been put in to make life easier to set\n     * things up\n     */\n    long session_timeout;\n    /*\n     * If this callback is not null, it will be called each time a session id\n     * is added to the cache.  If this function returns 1, it means that the\n     * callback will do a SSL_SESSION_free() when it has finished using it.\n     * Otherwise, on 0, it means the callback has finished with it. If\n     * remove_session_cb is not null, it will be called when a session-id is\n     * removed from the cache.  After the call, OpenSSL will\n     * SSL_SESSION_free() it.\n     */\n    int (*new_session_cb) (struct ssl_st *ssl, SSL_SESSION *sess);\n    void (*remove_session_cb) (struct ssl_ctx_st *ctx, SSL_SESSION *sess);\n    SSL_SESSION *(*get_session_cb) (struct ssl_st *ssl,\n                                    unsigned char *data, int len, int *copy);\n    struct {\n        int sess_connect;       /* SSL new conn - started */\n        int sess_connect_renegotiate; /* SSL reneg - requested */\n        int sess_connect_good;  /* SSL new conne/reneg - finished */\n        int sess_accept;        /* SSL new accept - started */\n        int sess_accept_renegotiate; /* SSL reneg - requested */\n        int sess_accept_good;   /* SSL accept/reneg - finished */\n        int sess_miss;          /* session lookup misses */\n        int sess_timeout;       /* reuse attempt on timeouted session */\n        int sess_cache_full;    /* session removed due to full cache */\n        int sess_hit;           /* session reuse actually done */\n        int sess_cb_hit;        /* session-id that was not in the cache was\n                                 * passed back via the callback.  This\n                                 * indicates that the application is\n                                 * supplying session-id's from other\n                                 * processes - spooky :-) */\n    } stats;\n\n    int references;\n\n    /* if defined, these override the X509_verify_cert() calls */\n    int (*app_verify_callback) (X509_STORE_CTX *, void *);\n    void *app_verify_arg;\n    /*\n     * before OpenSSL 0.9.7, 'app_verify_arg' was ignored\n     * ('app_verify_callback' was called with just one argument)\n     */\n\n    /* Default password callback. */\n    pem_password_cb *default_passwd_callback;\n\n    /* Default password callback user data. */\n    void *default_passwd_callback_userdata;\n\n    /* get client cert callback */\n    int (*client_cert_cb) (SSL *ssl, X509 **x509, EVP_PKEY **pkey);\n\n    /* cookie generate callback */\n    int (*app_gen_cookie_cb) (SSL *ssl, unsigned char *cookie,\n                              unsigned int *cookie_len);\n\n    /* verify cookie callback */\n    int (*app_verify_cookie_cb) (SSL *ssl, unsigned char *cookie,\n                                 unsigned int cookie_len);\n\n    CRYPTO_EX_DATA ex_data;\n\n    const EVP_MD *rsa_md5;      /* For SSLv2 - name is 'ssl2-md5' */\n    const EVP_MD *md5;          /* For SSLv3/TLSv1 'ssl3-md5' */\n    const EVP_MD *sha1;         /* For SSLv3/TLSv1 'ssl3->sha1' */\n\n    STACK_OF(X509) *extra_certs;\n    STACK_OF(SSL_COMP) *comp_methods; /* stack of SSL_COMP, SSLv3/TLSv1 */\n\n    /* Default values used when no per-SSL value is defined follow */\n\n    /* used if SSL's info_callback is NULL */\n    void (*info_callback) (const SSL *ssl, int type, int val);\n\n    /* what we put in client cert requests */\n    STACK_OF(X509_NAME) *client_CA;\n\n    /*\n     * Default values to use in SSL structures follow (these are copied by\n     * SSL_new)\n     */\n\n    unsigned long options;\n    unsigned long mode;\n    long max_cert_list;\n\n    struct cert_st /* CERT */ *cert;\n    int read_ahead;\n\n    /* callback that allows applications to peek at protocol messages */\n    void (*msg_callback) (int write_p, int version, int content_type,\n                          const void *buf, size_t len, SSL *ssl, void *arg);\n    void *msg_callback_arg;\n\n    int verify_mode;\n    unsigned int sid_ctx_length;\n    unsigned char sid_ctx[SSL_MAX_SID_CTX_LENGTH];\n    /* called 'verify_callback' in the SSL */\n    int (*default_verify_callback) (int ok, X509_STORE_CTX *ctx);\n\n    /* Default generate session ID callback. */\n    GEN_SESSION_CB generate_session_id;\n\n    X509_VERIFY_PARAM *param;\n\n#  if 0\n    int purpose;                /* Purpose setting */\n    int trust;                  /* Trust setting */\n#  endif\n\n    int quiet_shutdown;\n\n    /*\n     * Maximum amount of data to send in one fragment. actual record size can\n     * be more than this due to padding and MAC overheads.\n     */\n    unsigned int max_send_fragment;\n\n#  ifndef OPENSSL_NO_ENGINE\n    /*\n     * Engine to pass requests for client certs to\n     */\n    ENGINE *client_cert_engine;\n#  endif\n\n#  ifndef OPENSSL_NO_TLSEXT\n    /* TLS extensions servername callback */\n    int (*tlsext_servername_callback) (SSL *, int *, void *);\n    void *tlsext_servername_arg;\n    /* RFC 4507 session ticket keys */\n    unsigned char tlsext_tick_key_name[16];\n    unsigned char tlsext_tick_hmac_key[16];\n    unsigned char tlsext_tick_aes_key[16];\n    /* Callback to support customisation of ticket key setting */\n    int (*tlsext_ticket_key_cb) (SSL *ssl,\n                                 unsigned char *name, unsigned char *iv,\n                                 EVP_CIPHER_CTX *ectx,\n                                 HMAC_CTX *hctx, int enc);\n\n    /* certificate status request info */\n    /* Callback for status request */\n    int (*tlsext_status_cb) (SSL *ssl, void *arg);\n    void *tlsext_status_arg;\n\n    /* draft-rescorla-tls-opaque-prf-input-00.txt information */\n    int (*tlsext_opaque_prf_input_callback) (SSL *, void *peerinput,\n                                             size_t len, void *arg);\n    void *tlsext_opaque_prf_input_callback_arg;\n#  endif\n\n#  ifndef OPENSSL_NO_PSK\n    char *psk_identity_hint;\n    unsigned int (*psk_client_callback) (SSL *ssl, const char *hint,\n                                         char *identity,\n                                         unsigned int max_identity_len,\n                                         unsigned char *psk,\n                                         unsigned int max_psk_len);\n    unsigned int (*psk_server_callback) (SSL *ssl, const char *identity,\n                                         unsigned char *psk,\n                                         unsigned int max_psk_len);\n#  endif\n\n#  ifndef OPENSSL_NO_BUF_FREELISTS\n#   define SSL_MAX_BUF_FREELIST_LEN_DEFAULT 32\n    unsigned int freelist_max_len;\n    struct ssl3_buf_freelist_st *wbuf_freelist;\n    struct ssl3_buf_freelist_st *rbuf_freelist;\n#  endif\n#  ifndef OPENSSL_NO_SRP\n    SRP_CTX srp_ctx;            /* ctx for SRP authentication */\n#  endif\n\n#  ifndef OPENSSL_NO_TLSEXT\n\n#   ifndef OPENSSL_NO_NEXTPROTONEG\n    /* Next protocol negotiation information */\n    /* (for experimental NPN extension). */\n\n    /*\n     * For a server, this contains a callback function by which the set of\n     * advertised protocols can be provided.\n     */\n    int (*next_protos_advertised_cb) (SSL *s, const unsigned char **buf,\n                                      unsigned int *len, void *arg);\n    void *next_protos_advertised_cb_arg;\n    /*\n     * For a client, this contains a callback function that selects the next\n     * protocol from the list provided by the server.\n     */\n    int (*next_proto_select_cb) (SSL *s, unsigned char **out,\n                                 unsigned char *outlen,\n                                 const unsigned char *in,\n                                 unsigned int inlen, void *arg);\n    void *next_proto_select_cb_arg;\n#   endif\n    /* SRTP profiles we are willing to do from RFC 5764 */\n    STACK_OF(SRTP_PROTECTION_PROFILE) *srtp_profiles;\n\n    /*\n     * ALPN information (we are in the process of transitioning from NPN to\n     * ALPN.)\n     */\n\n    /*-\n     * For a server, this contains a callback function that allows the\n     * server to select the protocol for the connection.\n     *   out: on successful return, this must point to the raw protocol\n     *        name (without the length prefix).\n     *   outlen: on successful return, this contains the length of |*out|.\n     *   in: points to the client's list of supported protocols in\n     *       wire-format.\n     *   inlen: the length of |in|.\n     */\n    int (*alpn_select_cb) (SSL *s,\n                           const unsigned char **out,\n                           unsigned char *outlen,\n                           const unsigned char *in,\n                           unsigned int inlen, void *arg);\n    void *alpn_select_cb_arg;\n\n    /*\n     * For a client, this contains the list of supported protocols in wire\n     * format.\n     */\n    unsigned char *alpn_client_proto_list;\n    unsigned alpn_client_proto_list_len;\n\n#   ifndef OPENSSL_NO_EC\n    /* EC extension values inherited by SSL structure */\n    size_t tlsext_ecpointformatlist_length;\n    unsigned char *tlsext_ecpointformatlist;\n    size_t tlsext_ellipticcurvelist_length;\n    unsigned char *tlsext_ellipticcurvelist;\n#   endif                       /* OPENSSL_NO_EC */\n#  endif\n};\n\n# endif\n\n# define SSL_SESS_CACHE_OFF                      0x0000\n# define SSL_SESS_CACHE_CLIENT                   0x0001\n# define SSL_SESS_CACHE_SERVER                   0x0002\n# define SSL_SESS_CACHE_BOTH     (SSL_SESS_CACHE_CLIENT|SSL_SESS_CACHE_SERVER)\n# define SSL_SESS_CACHE_NO_AUTO_CLEAR            0x0080\n/* enough comments already ... see SSL_CTX_set_session_cache_mode(3) */\n# define SSL_SESS_CACHE_NO_INTERNAL_LOOKUP       0x0100\n# define SSL_SESS_CACHE_NO_INTERNAL_STORE        0x0200\n# define SSL_SESS_CACHE_NO_INTERNAL \\\n        (SSL_SESS_CACHE_NO_INTERNAL_LOOKUP|SSL_SESS_CACHE_NO_INTERNAL_STORE)\n\nLHASH_OF(SSL_SESSION) *SSL_CTX_sessions(SSL_CTX *ctx);\n# define SSL_CTX_sess_number(ctx) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_SESS_NUMBER,0,NULL)\n# define SSL_CTX_sess_connect(ctx) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_SESS_CONNECT,0,NULL)\n# define SSL_CTX_sess_connect_good(ctx) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_SESS_CONNECT_GOOD,0,NULL)\n# define SSL_CTX_sess_connect_renegotiate(ctx) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_SESS_CONNECT_RENEGOTIATE,0,NULL)\n# define SSL_CTX_sess_accept(ctx) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_SESS_ACCEPT,0,NULL)\n# define SSL_CTX_sess_accept_renegotiate(ctx) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_SESS_ACCEPT_RENEGOTIATE,0,NULL)\n# define SSL_CTX_sess_accept_good(ctx) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_SESS_ACCEPT_GOOD,0,NULL)\n# define SSL_CTX_sess_hits(ctx) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_SESS_HIT,0,NULL)\n# define SSL_CTX_sess_cb_hits(ctx) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_SESS_CB_HIT,0,NULL)\n# define SSL_CTX_sess_misses(ctx) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_SESS_MISSES,0,NULL)\n# define SSL_CTX_sess_timeouts(ctx) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_SESS_TIMEOUTS,0,NULL)\n# define SSL_CTX_sess_cache_full(ctx) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_SESS_CACHE_FULL,0,NULL)\n\nvoid SSL_CTX_sess_set_new_cb(SSL_CTX *ctx,\n                             int (*new_session_cb) (struct ssl_st *ssl,\n                                                    SSL_SESSION *sess));\nint (*SSL_CTX_sess_get_new_cb(SSL_CTX *ctx)) (struct ssl_st *ssl,\n                                              SSL_SESSION *sess);\nvoid SSL_CTX_sess_set_remove_cb(SSL_CTX *ctx,\n                                void (*remove_session_cb) (struct ssl_ctx_st\n                                                           *ctx,\n                                                           SSL_SESSION\n                                                           *sess));\nvoid (*SSL_CTX_sess_get_remove_cb(SSL_CTX *ctx)) (struct ssl_ctx_st *ctx,\n                                                  SSL_SESSION *sess);\nvoid SSL_CTX_sess_set_get_cb(SSL_CTX *ctx,\n                             SSL_SESSION *(*get_session_cb) (struct ssl_st\n                                                             *ssl,\n                                                             unsigned char\n                                                             *data, int len,\n                                                             int *copy));\nSSL_SESSION *(*SSL_CTX_sess_get_get_cb(SSL_CTX *ctx)) (struct ssl_st *ssl,\n                                                       unsigned char *Data,\n                                                       int len, int *copy);\nvoid SSL_CTX_set_info_callback(SSL_CTX *ctx,\n                               void (*cb) (const SSL *ssl, int type,\n                                           int val));\nvoid (*SSL_CTX_get_info_callback(SSL_CTX *ctx)) (const SSL *ssl, int type,\n                                                 int val);\nvoid SSL_CTX_set_client_cert_cb(SSL_CTX *ctx,\n                                int (*client_cert_cb) (SSL *ssl, X509 **x509,\n                                                       EVP_PKEY **pkey));\nint (*SSL_CTX_get_client_cert_cb(SSL_CTX *ctx)) (SSL *ssl, X509 **x509,\n                                                 EVP_PKEY **pkey);\n# ifndef OPENSSL_NO_ENGINE\nint SSL_CTX_set_client_cert_engine(SSL_CTX *ctx, ENGINE *e);\n# endif\nvoid SSL_CTX_set_cookie_generate_cb(SSL_CTX *ctx,\n                                    int (*app_gen_cookie_cb) (SSL *ssl,\n                                                              unsigned char\n                                                              *cookie,\n                                                              unsigned int\n                                                              *cookie_len));\nvoid SSL_CTX_set_cookie_verify_cb(SSL_CTX *ctx,\n                                  int (*app_verify_cookie_cb) (SSL *ssl,\n                                                               unsigned char\n                                                               *cookie,\n                                                               unsigned int\n                                                               cookie_len));\n# ifndef OPENSSL_NO_NEXTPROTONEG\nvoid SSL_CTX_set_next_protos_advertised_cb(SSL_CTX *s,\n                                           int (*cb) (SSL *ssl,\n                                                      const unsigned char\n                                                      **out,\n                                                      unsigned int *outlen,\n                                                      void *arg), void *arg);\nvoid SSL_CTX_set_next_proto_select_cb(SSL_CTX *s,\n                                      int (*cb) (SSL *ssl,\n                                                 unsigned char **out,\n                                                 unsigned char *outlen,\n                                                 const unsigned char *in,\n                                                 unsigned int inlen,\n                                                 void *arg), void *arg);\nvoid SSL_get0_next_proto_negotiated(const SSL *s, const unsigned char **data,\n                                    unsigned *len);\n# endif\n\n# ifndef OPENSSL_NO_TLSEXT\nint SSL_select_next_proto(unsigned char **out, unsigned char *outlen,\n                          const unsigned char *in, unsigned int inlen,\n                          const unsigned char *client,\n                          unsigned int client_len);\n# endif\n\n# define OPENSSL_NPN_UNSUPPORTED 0\n# define OPENSSL_NPN_NEGOTIATED  1\n# define OPENSSL_NPN_NO_OVERLAP  2\n\nint SSL_CTX_set_alpn_protos(SSL_CTX *ctx, const unsigned char *protos,\n                            unsigned protos_len);\nint SSL_set_alpn_protos(SSL *ssl, const unsigned char *protos,\n                        unsigned protos_len);\nvoid SSL_CTX_set_alpn_select_cb(SSL_CTX *ctx,\n                                int (*cb) (SSL *ssl,\n                                           const unsigned char **out,\n                                           unsigned char *outlen,\n                                           const unsigned char *in,\n                                           unsigned int inlen,\n                                           void *arg), void *arg);\nvoid SSL_get0_alpn_selected(const SSL *ssl, const unsigned char **data,\n                            unsigned *len);\n\n# ifndef OPENSSL_NO_PSK\n/*\n * the maximum length of the buffer given to callbacks containing the\n * resulting identity/psk\n */\n#  define PSK_MAX_IDENTITY_LEN 128\n#  define PSK_MAX_PSK_LEN 256\nvoid SSL_CTX_set_psk_client_callback(SSL_CTX *ctx,\n                                     unsigned int (*psk_client_callback) (SSL\n                                                                          *ssl,\n                                                                          const\n                                                                          char\n                                                                          *hint,\n                                                                          char\n                                                                          *identity,\n                                                                          unsigned\n                                                                          int\n                                                                          max_identity_len,\n                                                                          unsigned\n                                                                          char\n                                                                          *psk,\n                                                                          unsigned\n                                                                          int\n                                                                          max_psk_len));\nvoid SSL_set_psk_client_callback(SSL *ssl,\n                                 unsigned int (*psk_client_callback) (SSL\n                                                                      *ssl,\n                                                                      const\n                                                                      char\n                                                                      *hint,\n                                                                      char\n                                                                      *identity,\n                                                                      unsigned\n                                                                      int\n                                                                      max_identity_len,\n                                                                      unsigned\n                                                                      char\n                                                                      *psk,\n                                                                      unsigned\n                                                                      int\n                                                                      max_psk_len));\nvoid SSL_CTX_set_psk_server_callback(SSL_CTX *ctx,\n                                     unsigned int (*psk_server_callback) (SSL\n                                                                          *ssl,\n                                                                          const\n                                                                          char\n                                                                          *identity,\n                                                                          unsigned\n                                                                          char\n                                                                          *psk,\n                                                                          unsigned\n                                                                          int\n                                                                          max_psk_len));\nvoid SSL_set_psk_server_callback(SSL *ssl,\n                                 unsigned int (*psk_server_callback) (SSL\n                                                                      *ssl,\n                                                                      const\n                                                                      char\n                                                                      *identity,\n                                                                      unsigned\n                                                                      char\n                                                                      *psk,\n                                                                      unsigned\n                                                                      int\n                                                                      max_psk_len));\nint SSL_CTX_use_psk_identity_hint(SSL_CTX *ctx, const char *identity_hint);\nint SSL_use_psk_identity_hint(SSL *s, const char *identity_hint);\nconst char *SSL_get_psk_identity_hint(const SSL *s);\nconst char *SSL_get_psk_identity(const SSL *s);\n# endif\n\n# ifndef OPENSSL_NO_TLSEXT\n/* Register callbacks to handle custom TLS Extensions for client or server. */\n\nint SSL_CTX_add_client_custom_ext(SSL_CTX *ctx, unsigned int ext_type,\n                                  custom_ext_add_cb add_cb,\n                                  custom_ext_free_cb free_cb,\n                                  void *add_arg,\n                                  custom_ext_parse_cb parse_cb,\n                                  void *parse_arg);\n\nint SSL_CTX_add_server_custom_ext(SSL_CTX *ctx, unsigned int ext_type,\n                                  custom_ext_add_cb add_cb,\n                                  custom_ext_free_cb free_cb,\n                                  void *add_arg,\n                                  custom_ext_parse_cb parse_cb,\n                                  void *parse_arg);\n\nint SSL_extension_supported(unsigned int ext_type);\n\n# endif\n\n# define SSL_NOTHING     1\n# define SSL_WRITING     2\n# define SSL_READING     3\n# define SSL_X509_LOOKUP 4\n\n/* These will only be used when doing non-blocking IO */\n# define SSL_want_nothing(s)     (SSL_want(s) == SSL_NOTHING)\n# define SSL_want_read(s)        (SSL_want(s) == SSL_READING)\n# define SSL_want_write(s)       (SSL_want(s) == SSL_WRITING)\n# define SSL_want_x509_lookup(s) (SSL_want(s) == SSL_X509_LOOKUP)\n\n# define SSL_MAC_FLAG_READ_MAC_STREAM 1\n# define SSL_MAC_FLAG_WRITE_MAC_STREAM 2\n\n# ifndef OPENSSL_NO_SSL_INTERN\n\nstruct ssl_st {\n    /*\n     * protocol version (one of SSL2_VERSION, SSL3_VERSION, TLS1_VERSION,\n     * DTLS1_VERSION)\n     */\n    int version;\n    /* SSL_ST_CONNECT or SSL_ST_ACCEPT */\n    int type;\n    /* SSLv3 */\n    const SSL_METHOD *method;\n    /*\n     * There are 2 BIO's even though they are normally both the same.  This\n     * is so data can be read and written to different handlers\n     */\n#  ifndef OPENSSL_NO_BIO\n    /* used by SSL_read */\n    BIO *rbio;\n    /* used by SSL_write */\n    BIO *wbio;\n    /* used during session-id reuse to concatenate messages */\n    BIO *bbio;\n#  else\n    /* used by SSL_read */\n    char *rbio;\n    /* used by SSL_write */\n    char *wbio;\n    char *bbio;\n#  endif\n    /*\n     * This holds a variable that indicates what we were doing when a 0 or -1\n     * is returned.  This is needed for non-blocking IO so we know what\n     * request needs re-doing when in SSL_accept or SSL_connect\n     */\n    int rwstate;\n    /* true when we are actually in SSL_accept() or SSL_connect() */\n    int in_handshake;\n    int (*handshake_func) (SSL *);\n    /*\n     * Imagine that here's a boolean member \"init\" that is switched as soon\n     * as SSL_set_{accept/connect}_state is called for the first time, so\n     * that \"state\" and \"handshake_func\" are properly initialized.  But as\n     * handshake_func is == 0 until then, we use this test instead of an\n     * \"init\" member.\n     */\n    /* are we the server side? - mostly used by SSL_clear */\n    int server;\n    /*\n     * Generate a new session or reuse an old one.\n     * NB: For servers, the 'new' session may actually be a previously\n     * cached session or even the previous session unless\n     * SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION is set\n     */\n    int new_session;\n    /* don't send shutdown packets */\n    int quiet_shutdown;\n    /* we have shut things down, 0x01 sent, 0x02 for received */\n    int shutdown;\n    /* where we are */\n    int state;\n    /* where we are when reading */\n    int rstate;\n    BUF_MEM *init_buf;          /* buffer used during init */\n    void *init_msg;             /* pointer to handshake message body, set by\n                                 * ssl3_get_message() */\n    int init_num;               /* amount read/written */\n    int init_off;               /* amount read/written */\n    /* used internally to point at a raw packet */\n    unsigned char *packet;\n    unsigned int packet_length;\n    struct ssl2_state_st *s2;   /* SSLv2 variables */\n    struct ssl3_state_st *s3;   /* SSLv3 variables */\n    struct dtls1_state_st *d1;  /* DTLSv1 variables */\n    int read_ahead;             /* Read as many input bytes as possible (for\n                                 * non-blocking reads) */\n    /* callback that allows applications to peek at protocol messages */\n    void (*msg_callback) (int write_p, int version, int content_type,\n                          const void *buf, size_t len, SSL *ssl, void *arg);\n    void *msg_callback_arg;\n    int hit;                    /* reusing a previous session */\n    X509_VERIFY_PARAM *param;\n#  if 0\n    int purpose;                /* Purpose setting */\n    int trust;                  /* Trust setting */\n#  endif\n    /* crypto */\n    STACK_OF(SSL_CIPHER) *cipher_list;\n    STACK_OF(SSL_CIPHER) *cipher_list_by_id;\n    /*\n     * These are the ones being used, the ones in SSL_SESSION are the ones to\n     * be 'copied' into these ones\n     */\n    int mac_flags;\n    EVP_CIPHER_CTX *enc_read_ctx; /* cryptographic state */\n    EVP_MD_CTX *read_hash;      /* used for mac generation */\n#  ifndef OPENSSL_NO_COMP\n    COMP_CTX *expand;           /* uncompress */\n#  else\n    char *expand;\n#  endif\n    EVP_CIPHER_CTX *enc_write_ctx; /* cryptographic state */\n    EVP_MD_CTX *write_hash;     /* used for mac generation */\n#  ifndef OPENSSL_NO_COMP\n    COMP_CTX *compress;         /* compression */\n#  else\n    char *compress;\n#  endif\n    /* session info */\n    /* client cert? */\n    /* This is used to hold the server certificate used */\n    struct cert_st /* CERT */ *cert;\n    /*\n     * the session_id_context is used to ensure sessions are only reused in\n     * the appropriate context\n     */\n    unsigned int sid_ctx_length;\n    unsigned char sid_ctx[SSL_MAX_SID_CTX_LENGTH];\n    /* This can also be in the session once a session is established */\n    SSL_SESSION *session;\n    /* Default generate session ID callback. */\n    GEN_SESSION_CB generate_session_id;\n    /* Used in SSL2 and SSL3 */\n    /*\n     * 0 don't care about verify failure.\n     * 1 fail if verify fails\n     */\n    int verify_mode;\n    /* fail if callback returns 0 */\n    int (*verify_callback) (int ok, X509_STORE_CTX *ctx);\n    /* optional informational callback */\n    void (*info_callback) (const SSL *ssl, int type, int val);\n    /* error bytes to be written */\n    int error;\n    /* actual code */\n    int error_code;\n#  ifndef OPENSSL_NO_KRB5\n    /* Kerberos 5 context */\n    KSSL_CTX *kssl_ctx;\n#  endif                        /* OPENSSL_NO_KRB5 */\n#  ifndef OPENSSL_NO_PSK\n    unsigned int (*psk_client_callback) (SSL *ssl, const char *hint,\n                                         char *identity,\n                                         unsigned int max_identity_len,\n                                         unsigned char *psk,\n                                         unsigned int max_psk_len);\n    unsigned int (*psk_server_callback) (SSL *ssl, const char *identity,\n                                         unsigned char *psk,\n                                         unsigned int max_psk_len);\n#  endif\n    SSL_CTX *ctx;\n    /*\n     * set this flag to 1 and a sleep(1) is put into all SSL_read() and\n     * SSL_write() calls, good for nbio debuging :-)\n     */\n    int debug;\n    /* extra application data */\n    long verify_result;\n    CRYPTO_EX_DATA ex_data;\n    /* for server side, keep the list of CA_dn we can use */\n    STACK_OF(X509_NAME) *client_CA;\n    int references;\n    /* protocol behaviour */\n    unsigned long options;\n    /* API behaviour */\n    unsigned long mode;\n    long max_cert_list;\n    int first_packet;\n    /* what was passed, used for SSLv3/TLS rollback check */\n    int client_version;\n    unsigned int max_send_fragment;\n#  ifndef OPENSSL_NO_TLSEXT\n    /* TLS extension debug callback */\n    void (*tlsext_debug_cb) (SSL *s, int client_server, int type,\n                             unsigned char *data, int len, void *arg);\n    void *tlsext_debug_arg;\n    char *tlsext_hostname;\n    /*-\n     * no further mod of servername\n     * 0 : call the servername extension callback.\n     * 1 : prepare 2, allow last ack just after in server callback.\n     * 2 : don't call servername callback, no ack in server hello\n     */\n    int servername_done;\n    /* certificate status request info */\n    /* Status type or -1 if no status type */\n    int tlsext_status_type;\n    /* Expect OCSP CertificateStatus message */\n    int tlsext_status_expected;\n    /* OCSP status request only */\n    STACK_OF(OCSP_RESPID) *tlsext_ocsp_ids;\n    X509_EXTENSIONS *tlsext_ocsp_exts;\n    /* OCSP response received or to be sent */\n    unsigned char *tlsext_ocsp_resp;\n    int tlsext_ocsp_resplen;\n    /* RFC4507 session ticket expected to be received or sent */\n    int tlsext_ticket_expected;\n#   ifndef OPENSSL_NO_EC\n    size_t tlsext_ecpointformatlist_length;\n    /* our list */\n    unsigned char *tlsext_ecpointformatlist;\n    size_t tlsext_ellipticcurvelist_length;\n    /* our list */\n    unsigned char *tlsext_ellipticcurvelist;\n#   endif                       /* OPENSSL_NO_EC */\n    /*\n     * draft-rescorla-tls-opaque-prf-input-00.txt information to be used for\n     * handshakes\n     */\n    void *tlsext_opaque_prf_input;\n    size_t tlsext_opaque_prf_input_len;\n    /* TLS Session Ticket extension override */\n    TLS_SESSION_TICKET_EXT *tlsext_session_ticket;\n    /* TLS Session Ticket extension callback */\n    tls_session_ticket_ext_cb_fn tls_session_ticket_ext_cb;\n    void *tls_session_ticket_ext_cb_arg;\n    /* TLS pre-shared secret session resumption */\n    tls_session_secret_cb_fn tls_session_secret_cb;\n    void *tls_session_secret_cb_arg;\n    SSL_CTX *initial_ctx;       /* initial ctx, used to store sessions */\n#   ifndef OPENSSL_NO_NEXTPROTONEG\n    /*\n     * Next protocol negotiation. For the client, this is the protocol that\n     * we sent in NextProtocol and is set when handling ServerHello\n     * extensions. For a server, this is the client's selected_protocol from\n     * NextProtocol and is set when handling the NextProtocol message, before\n     * the Finished message.\n     */\n    unsigned char *next_proto_negotiated;\n    unsigned char next_proto_negotiated_len;\n#   endif\n#   define session_ctx initial_ctx\n    /* What we'll do */\n    STACK_OF(SRTP_PROTECTION_PROFILE) *srtp_profiles;\n    /* What's been chosen */\n    SRTP_PROTECTION_PROFILE *srtp_profile;\n        /*-\n         * Is use of the Heartbeat extension negotiated?\n         * 0: disabled\n         * 1: enabled\n         * 2: enabled, but not allowed to send Requests\n         */\n    unsigned int tlsext_heartbeat;\n    /* Indicates if a HeartbeatRequest is in flight */\n    unsigned int tlsext_hb_pending;\n    /* HeartbeatRequest sequence number */\n    unsigned int tlsext_hb_seq;\n#  else\n#   define session_ctx ctx\n#  endif                        /* OPENSSL_NO_TLSEXT */\n    /*-\n     * 1 if we are renegotiating.\n     * 2 if we are a server and are inside a handshake\n     * (i.e. not just sending a HelloRequest)\n     */\n    int renegotiate;\n#  ifndef OPENSSL_NO_SRP\n    /* ctx for SRP authentication */\n    SRP_CTX srp_ctx;\n#  endif\n#  ifndef OPENSSL_NO_TLSEXT\n    /*\n     * For a client, this contains the list of supported protocols in wire\n     * format.\n     */\n    unsigned char *alpn_client_proto_list;\n    unsigned alpn_client_proto_list_len;\n#  endif                        /* OPENSSL_NO_TLSEXT */\n};\n\n# endif\n\n#ifdef __cplusplus\n}\n#endif\n\n# include <openssl/ssl2.h>\n# include <openssl/ssl3.h>\n# include <openssl/tls1.h>      /* This is mostly sslv3 with a few tweaks */\n# include <openssl/dtls1.h>     /* Datagram TLS */\n# include <openssl/ssl23.h>\n# include <openssl/srtp.h>      /* Support for the use_srtp extension */\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n/* compatibility */\n# define SSL_set_app_data(s,arg)         (SSL_set_ex_data(s,0,(char *)arg))\n# define SSL_get_app_data(s)             (SSL_get_ex_data(s,0))\n# define SSL_SESSION_set_app_data(s,a)   (SSL_SESSION_set_ex_data(s,0,(char *)a))\n# define SSL_SESSION_get_app_data(s)     (SSL_SESSION_get_ex_data(s,0))\n# define SSL_CTX_get_app_data(ctx)       (SSL_CTX_get_ex_data(ctx,0))\n# define SSL_CTX_set_app_data(ctx,arg)   (SSL_CTX_set_ex_data(ctx,0,(char *)arg))\n\n/*\n * The following are the possible values for ssl->state are are used to\n * indicate where we are up to in the SSL connection establishment. The\n * macros that follow are about the only things you should need to use and\n * even then, only when using non-blocking IO. It can also be useful to work\n * out where you were when the connection failed\n */\n\n# define SSL_ST_CONNECT                  0x1000\n# define SSL_ST_ACCEPT                   0x2000\n# define SSL_ST_MASK                     0x0FFF\n# define SSL_ST_INIT                     (SSL_ST_CONNECT|SSL_ST_ACCEPT)\n# define SSL_ST_BEFORE                   0x4000\n# define SSL_ST_OK                       0x03\n# define SSL_ST_RENEGOTIATE              (0x04|SSL_ST_INIT)\n# define SSL_ST_ERR                      0x05\n\n# define SSL_CB_LOOP                     0x01\n# define SSL_CB_EXIT                     0x02\n# define SSL_CB_READ                     0x04\n# define SSL_CB_WRITE                    0x08\n# define SSL_CB_ALERT                    0x4000/* used in callback */\n# define SSL_CB_READ_ALERT               (SSL_CB_ALERT|SSL_CB_READ)\n# define SSL_CB_WRITE_ALERT              (SSL_CB_ALERT|SSL_CB_WRITE)\n# define SSL_CB_ACCEPT_LOOP              (SSL_ST_ACCEPT|SSL_CB_LOOP)\n# define SSL_CB_ACCEPT_EXIT              (SSL_ST_ACCEPT|SSL_CB_EXIT)\n# define SSL_CB_CONNECT_LOOP             (SSL_ST_CONNECT|SSL_CB_LOOP)\n# define SSL_CB_CONNECT_EXIT             (SSL_ST_CONNECT|SSL_CB_EXIT)\n# define SSL_CB_HANDSHAKE_START          0x10\n# define SSL_CB_HANDSHAKE_DONE           0x20\n\n/* Is the SSL_connection established? */\n# define SSL_get_state(a)                SSL_state(a)\n# define SSL_is_init_finished(a)         (SSL_state(a) == SSL_ST_OK)\n# define SSL_in_init(a)                  (SSL_state(a)&SSL_ST_INIT)\n# define SSL_in_before(a)                (SSL_state(a)&SSL_ST_BEFORE)\n# define SSL_in_connect_init(a)          (SSL_state(a)&SSL_ST_CONNECT)\n# define SSL_in_accept_init(a)           (SSL_state(a)&SSL_ST_ACCEPT)\n\n/*\n * The following 2 states are kept in ssl->rstate when reads fail, you should\n * not need these\n */\n# define SSL_ST_READ_HEADER                      0xF0\n# define SSL_ST_READ_BODY                        0xF1\n# define SSL_ST_READ_DONE                        0xF2\n\n/*-\n * Obtain latest Finished message\n *   -- that we sent (SSL_get_finished)\n *   -- that we expected from peer (SSL_get_peer_finished).\n * Returns length (0 == no Finished so far), copies up to 'count' bytes.\n */\nsize_t SSL_get_finished(const SSL *s, void *buf, size_t count);\nsize_t SSL_get_peer_finished(const SSL *s, void *buf, size_t count);\n\n/*\n * use either SSL_VERIFY_NONE or SSL_VERIFY_PEER, the last 2 options are\n * 'ored' with SSL_VERIFY_PEER if they are desired\n */\n# define SSL_VERIFY_NONE                 0x00\n# define SSL_VERIFY_PEER                 0x01\n# define SSL_VERIFY_FAIL_IF_NO_PEER_CERT 0x02\n# define SSL_VERIFY_CLIENT_ONCE          0x04\n\n# define OpenSSL_add_ssl_algorithms()    SSL_library_init()\n# define SSLeay_add_ssl_algorithms()     SSL_library_init()\n\n/* this is for backward compatibility */\n# if 0                          /* NEW_SSLEAY */\n#  define SSL_CTX_set_default_verify(a,b,c) SSL_CTX_set_verify(a,b,c)\n#  define SSL_set_pref_cipher(c,n)        SSL_set_cipher_list(c,n)\n#  define SSL_add_session(a,b)            SSL_CTX_add_session((a),(b))\n#  define SSL_remove_session(a,b)         SSL_CTX_remove_session((a),(b))\n#  define SSL_flush_sessions(a,b)         SSL_CTX_flush_sessions((a),(b))\n# endif\n/* More backward compatibility */\n# define SSL_get_cipher(s) \\\n                SSL_CIPHER_get_name(SSL_get_current_cipher(s))\n# define SSL_get_cipher_bits(s,np) \\\n                SSL_CIPHER_get_bits(SSL_get_current_cipher(s),np)\n# define SSL_get_cipher_version(s) \\\n                SSL_CIPHER_get_version(SSL_get_current_cipher(s))\n# define SSL_get_cipher_name(s) \\\n                SSL_CIPHER_get_name(SSL_get_current_cipher(s))\n# define SSL_get_time(a)         SSL_SESSION_get_time(a)\n# define SSL_set_time(a,b)       SSL_SESSION_set_time((a),(b))\n# define SSL_get_timeout(a)      SSL_SESSION_get_timeout(a)\n# define SSL_set_timeout(a,b)    SSL_SESSION_set_timeout((a),(b))\n\n# define d2i_SSL_SESSION_bio(bp,s_id) ASN1_d2i_bio_of(SSL_SESSION,SSL_SESSION_new,d2i_SSL_SESSION,bp,s_id)\n# define i2d_SSL_SESSION_bio(bp,s_id) ASN1_i2d_bio_of(SSL_SESSION,i2d_SSL_SESSION,bp,s_id)\n\nDECLARE_PEM_rw(SSL_SESSION, SSL_SESSION)\n# define SSL_AD_REASON_OFFSET            1000/* offset to get SSL_R_... value\n                                              * from SSL_AD_... */\n/* These alert types are for SSLv3 and TLSv1 */\n# define SSL_AD_CLOSE_NOTIFY             SSL3_AD_CLOSE_NOTIFY\n/* fatal */\n# define SSL_AD_UNEXPECTED_MESSAGE       SSL3_AD_UNEXPECTED_MESSAGE\n/* fatal */\n# define SSL_AD_BAD_RECORD_MAC           SSL3_AD_BAD_RECORD_MAC\n# define SSL_AD_DECRYPTION_FAILED        TLS1_AD_DECRYPTION_FAILED\n# define SSL_AD_RECORD_OVERFLOW          TLS1_AD_RECORD_OVERFLOW\n/* fatal */\n# define SSL_AD_DECOMPRESSION_FAILURE    SSL3_AD_DECOMPRESSION_FAILURE\n/* fatal */\n# define SSL_AD_HANDSHAKE_FAILURE        SSL3_AD_HANDSHAKE_FAILURE\n/* Not for TLS */\n# define SSL_AD_NO_CERTIFICATE           SSL3_AD_NO_CERTIFICATE\n# define SSL_AD_BAD_CERTIFICATE          SSL3_AD_BAD_CERTIFICATE\n# define SSL_AD_UNSUPPORTED_CERTIFICATE  SSL3_AD_UNSUPPORTED_CERTIFICATE\n# define SSL_AD_CERTIFICATE_REVOKED      SSL3_AD_CERTIFICATE_REVOKED\n# define SSL_AD_CERTIFICATE_EXPIRED      SSL3_AD_CERTIFICATE_EXPIRED\n# define SSL_AD_CERTIFICATE_UNKNOWN      SSL3_AD_CERTIFICATE_UNKNOWN\n/* fatal */\n# define SSL_AD_ILLEGAL_PARAMETER        SSL3_AD_ILLEGAL_PARAMETER\n/* fatal */\n# define SSL_AD_UNKNOWN_CA               TLS1_AD_UNKNOWN_CA\n/* fatal */\n# define SSL_AD_ACCESS_DENIED            TLS1_AD_ACCESS_DENIED\n/* fatal */\n# define SSL_AD_DECODE_ERROR             TLS1_AD_DECODE_ERROR\n# define SSL_AD_DECRYPT_ERROR            TLS1_AD_DECRYPT_ERROR\n/* fatal */\n# define SSL_AD_EXPORT_RESTRICTION       TLS1_AD_EXPORT_RESTRICTION\n/* fatal */\n# define SSL_AD_PROTOCOL_VERSION         TLS1_AD_PROTOCOL_VERSION\n/* fatal */\n# define SSL_AD_INSUFFICIENT_SECURITY    TLS1_AD_INSUFFICIENT_SECURITY\n/* fatal */\n# define SSL_AD_INTERNAL_ERROR           TLS1_AD_INTERNAL_ERROR\n# define SSL_AD_USER_CANCELLED           TLS1_AD_USER_CANCELLED\n# define SSL_AD_NO_RENEGOTIATION         TLS1_AD_NO_RENEGOTIATION\n# define SSL_AD_UNSUPPORTED_EXTENSION    TLS1_AD_UNSUPPORTED_EXTENSION\n# define SSL_AD_CERTIFICATE_UNOBTAINABLE TLS1_AD_CERTIFICATE_UNOBTAINABLE\n# define SSL_AD_UNRECOGNIZED_NAME        TLS1_AD_UNRECOGNIZED_NAME\n# define SSL_AD_BAD_CERTIFICATE_STATUS_RESPONSE TLS1_AD_BAD_CERTIFICATE_STATUS_RESPONSE\n# define SSL_AD_BAD_CERTIFICATE_HASH_VALUE TLS1_AD_BAD_CERTIFICATE_HASH_VALUE\n/* fatal */\n# define SSL_AD_UNKNOWN_PSK_IDENTITY     TLS1_AD_UNKNOWN_PSK_IDENTITY\n/* fatal */\n# define SSL_AD_INAPPROPRIATE_FALLBACK   TLS1_AD_INAPPROPRIATE_FALLBACK\n# define SSL_ERROR_NONE                  0\n# define SSL_ERROR_SSL                   1\n# define SSL_ERROR_WANT_READ             2\n# define SSL_ERROR_WANT_WRITE            3\n# define SSL_ERROR_WANT_X509_LOOKUP      4\n# define SSL_ERROR_SYSCALL               5/* look at error stack/return\n                                           * value/errno */\n# define SSL_ERROR_ZERO_RETURN           6\n# define SSL_ERROR_WANT_CONNECT          7\n# define SSL_ERROR_WANT_ACCEPT           8\n# define SSL_CTRL_NEED_TMP_RSA                   1\n# define SSL_CTRL_SET_TMP_RSA                    2\n# define SSL_CTRL_SET_TMP_DH                     3\n# define SSL_CTRL_SET_TMP_ECDH                   4\n# define SSL_CTRL_SET_TMP_RSA_CB                 5\n# define SSL_CTRL_SET_TMP_DH_CB                  6\n# define SSL_CTRL_SET_TMP_ECDH_CB                7\n# define SSL_CTRL_GET_SESSION_REUSED             8\n# define SSL_CTRL_GET_CLIENT_CERT_REQUEST        9\n# define SSL_CTRL_GET_NUM_RENEGOTIATIONS         10\n# define SSL_CTRL_CLEAR_NUM_RENEGOTIATIONS       11\n# define SSL_CTRL_GET_TOTAL_RENEGOTIATIONS       12\n# define SSL_CTRL_GET_FLAGS                      13\n# define SSL_CTRL_EXTRA_CHAIN_CERT               14\n# define SSL_CTRL_SET_MSG_CALLBACK               15\n# define SSL_CTRL_SET_MSG_CALLBACK_ARG           16\n/* only applies to datagram connections */\n# define SSL_CTRL_SET_MTU                17\n/* Stats */\n# define SSL_CTRL_SESS_NUMBER                    20\n# define SSL_CTRL_SESS_CONNECT                   21\n# define SSL_CTRL_SESS_CONNECT_GOOD              22\n# define SSL_CTRL_SESS_CONNECT_RENEGOTIATE       23\n# define SSL_CTRL_SESS_ACCEPT                    24\n# define SSL_CTRL_SESS_ACCEPT_GOOD               25\n# define SSL_CTRL_SESS_ACCEPT_RENEGOTIATE        26\n# define SSL_CTRL_SESS_HIT                       27\n# define SSL_CTRL_SESS_CB_HIT                    28\n# define SSL_CTRL_SESS_MISSES                    29\n# define SSL_CTRL_SESS_TIMEOUTS                  30\n# define SSL_CTRL_SESS_CACHE_FULL                31\n# define SSL_CTRL_OPTIONS                        32\n# define SSL_CTRL_MODE                           33\n# define SSL_CTRL_GET_READ_AHEAD                 40\n# define SSL_CTRL_SET_READ_AHEAD                 41\n# define SSL_CTRL_SET_SESS_CACHE_SIZE            42\n# define SSL_CTRL_GET_SESS_CACHE_SIZE            43\n# define SSL_CTRL_SET_SESS_CACHE_MODE            44\n# define SSL_CTRL_GET_SESS_CACHE_MODE            45\n# define SSL_CTRL_GET_MAX_CERT_LIST              50\n# define SSL_CTRL_SET_MAX_CERT_LIST              51\n# define SSL_CTRL_SET_MAX_SEND_FRAGMENT          52\n/* see tls1.h for macros based on these */\n# ifndef OPENSSL_NO_TLSEXT\n#  define SSL_CTRL_SET_TLSEXT_SERVERNAME_CB       53\n#  define SSL_CTRL_SET_TLSEXT_SERVERNAME_ARG      54\n#  define SSL_CTRL_SET_TLSEXT_HOSTNAME            55\n#  define SSL_CTRL_SET_TLSEXT_DEBUG_CB            56\n#  define SSL_CTRL_SET_TLSEXT_DEBUG_ARG           57\n#  define SSL_CTRL_GET_TLSEXT_TICKET_KEYS         58\n#  define SSL_CTRL_SET_TLSEXT_TICKET_KEYS         59\n#  define SSL_CTRL_SET_TLSEXT_OPAQUE_PRF_INPUT    60\n#  define SSL_CTRL_SET_TLSEXT_OPAQUE_PRF_INPUT_CB 61\n#  define SSL_CTRL_SET_TLSEXT_OPAQUE_PRF_INPUT_CB_ARG 62\n#  define SSL_CTRL_SET_TLSEXT_STATUS_REQ_CB       63\n#  define SSL_CTRL_SET_TLSEXT_STATUS_REQ_CB_ARG   64\n#  define SSL_CTRL_SET_TLSEXT_STATUS_REQ_TYPE     65\n#  define SSL_CTRL_GET_TLSEXT_STATUS_REQ_EXTS     66\n#  define SSL_CTRL_SET_TLSEXT_STATUS_REQ_EXTS     67\n#  define SSL_CTRL_GET_TLSEXT_STATUS_REQ_IDS      68\n#  define SSL_CTRL_SET_TLSEXT_STATUS_REQ_IDS      69\n#  define SSL_CTRL_GET_TLSEXT_STATUS_REQ_OCSP_RESP        70\n#  define SSL_CTRL_SET_TLSEXT_STATUS_REQ_OCSP_RESP        71\n#  define SSL_CTRL_SET_TLSEXT_TICKET_KEY_CB       72\n#  define SSL_CTRL_SET_TLS_EXT_SRP_USERNAME_CB    75\n#  define SSL_CTRL_SET_SRP_VERIFY_PARAM_CB                76\n#  define SSL_CTRL_SET_SRP_GIVE_CLIENT_PWD_CB             77\n#  define SSL_CTRL_SET_SRP_ARG            78\n#  define SSL_CTRL_SET_TLS_EXT_SRP_USERNAME               79\n#  define SSL_CTRL_SET_TLS_EXT_SRP_STRENGTH               80\n#  define SSL_CTRL_SET_TLS_EXT_SRP_PASSWORD               81\n#  ifndef OPENSSL_NO_HEARTBEATS\n#   define SSL_CTRL_TLS_EXT_SEND_HEARTBEAT                         85\n#   define SSL_CTRL_GET_TLS_EXT_HEARTBEAT_PENDING          86\n#   define SSL_CTRL_SET_TLS_EXT_HEARTBEAT_NO_REQUESTS      87\n#  endif\n# endif                         /* OPENSSL_NO_TLSEXT */\n# define DTLS_CTRL_GET_TIMEOUT           73\n# define DTLS_CTRL_HANDLE_TIMEOUT        74\n# define DTLS_CTRL_LISTEN                        75\n# define SSL_CTRL_GET_RI_SUPPORT                 76\n# define SSL_CTRL_CLEAR_OPTIONS                  77\n# define SSL_CTRL_CLEAR_MODE                     78\n# define SSL_CTRL_GET_EXTRA_CHAIN_CERTS          82\n# define SSL_CTRL_CLEAR_EXTRA_CHAIN_CERTS        83\n# define SSL_CTRL_CHAIN                          88\n# define SSL_CTRL_CHAIN_CERT                     89\n# define SSL_CTRL_GET_CURVES                     90\n# define SSL_CTRL_SET_CURVES                     91\n# define SSL_CTRL_SET_CURVES_LIST                92\n# define SSL_CTRL_GET_SHARED_CURVE               93\n# define SSL_CTRL_SET_ECDH_AUTO                  94\n# define SSL_CTRL_SET_SIGALGS                    97\n# define SSL_CTRL_SET_SIGALGS_LIST               98\n# define SSL_CTRL_CERT_FLAGS                     99\n# define SSL_CTRL_CLEAR_CERT_FLAGS               100\n# define SSL_CTRL_SET_CLIENT_SIGALGS             101\n# define SSL_CTRL_SET_CLIENT_SIGALGS_LIST        102\n# define SSL_CTRL_GET_CLIENT_CERT_TYPES          103\n# define SSL_CTRL_SET_CLIENT_CERT_TYPES          104\n# define SSL_CTRL_BUILD_CERT_CHAIN               105\n# define SSL_CTRL_SET_VERIFY_CERT_STORE          106\n# define SSL_CTRL_SET_CHAIN_CERT_STORE           107\n# define SSL_CTRL_GET_PEER_SIGNATURE_NID         108\n# define SSL_CTRL_GET_SERVER_TMP_KEY             109\n# define SSL_CTRL_GET_RAW_CIPHERLIST             110\n# define SSL_CTRL_GET_EC_POINT_FORMATS           111\n# define SSL_CTRL_GET_CHAIN_CERTS                115\n# define SSL_CTRL_SELECT_CURRENT_CERT            116\n# define SSL_CTRL_SET_CURRENT_CERT               117\n# define SSL_CTRL_CHECK_PROTO_VERSION            119\n# define DTLS_CTRL_SET_LINK_MTU                  120\n# define DTLS_CTRL_GET_LINK_MIN_MTU              121\n# define SSL_CERT_SET_FIRST                      1\n# define SSL_CERT_SET_NEXT                       2\n# define SSL_CERT_SET_SERVER                     3\n# define DTLSv1_get_timeout(ssl, arg) \\\n        SSL_ctrl(ssl,DTLS_CTRL_GET_TIMEOUT,0, (void *)arg)\n# define DTLSv1_handle_timeout(ssl) \\\n        SSL_ctrl(ssl,DTLS_CTRL_HANDLE_TIMEOUT,0, NULL)\n# define DTLSv1_listen(ssl, peer) \\\n        SSL_ctrl(ssl,DTLS_CTRL_LISTEN,0, (void *)peer)\n# define SSL_session_reused(ssl) \\\n        SSL_ctrl((ssl),SSL_CTRL_GET_SESSION_REUSED,0,NULL)\n# define SSL_num_renegotiations(ssl) \\\n        SSL_ctrl((ssl),SSL_CTRL_GET_NUM_RENEGOTIATIONS,0,NULL)\n# define SSL_clear_num_renegotiations(ssl) \\\n        SSL_ctrl((ssl),SSL_CTRL_CLEAR_NUM_RENEGOTIATIONS,0,NULL)\n# define SSL_total_renegotiations(ssl) \\\n        SSL_ctrl((ssl),SSL_CTRL_GET_TOTAL_RENEGOTIATIONS,0,NULL)\n# define SSL_CTX_need_tmp_RSA(ctx) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_NEED_TMP_RSA,0,NULL)\n# define SSL_CTX_set_tmp_rsa(ctx,rsa) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_SET_TMP_RSA,0,(char *)rsa)\n# define SSL_CTX_set_tmp_dh(ctx,dh) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_SET_TMP_DH,0,(char *)dh)\n# define SSL_CTX_set_tmp_ecdh(ctx,ecdh) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_SET_TMP_ECDH,0,(char *)ecdh)\n# define SSL_need_tmp_RSA(ssl) \\\n        SSL_ctrl(ssl,SSL_CTRL_NEED_TMP_RSA,0,NULL)\n# define SSL_set_tmp_rsa(ssl,rsa) \\\n        SSL_ctrl(ssl,SSL_CTRL_SET_TMP_RSA,0,(char *)rsa)\n# define SSL_set_tmp_dh(ssl,dh) \\\n        SSL_ctrl(ssl,SSL_CTRL_SET_TMP_DH,0,(char *)dh)\n# define SSL_set_tmp_ecdh(ssl,ecdh) \\\n        SSL_ctrl(ssl,SSL_CTRL_SET_TMP_ECDH,0,(char *)ecdh)\n# define SSL_CTX_add_extra_chain_cert(ctx,x509) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_EXTRA_CHAIN_CERT,0,(char *)x509)\n# define SSL_CTX_get_extra_chain_certs(ctx,px509) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_GET_EXTRA_CHAIN_CERTS,0,px509)\n# define SSL_CTX_get_extra_chain_certs_only(ctx,px509) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_GET_EXTRA_CHAIN_CERTS,1,px509)\n# define SSL_CTX_clear_extra_chain_certs(ctx) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_CLEAR_EXTRA_CHAIN_CERTS,0,NULL)\n# define SSL_CTX_set0_chain(ctx,sk) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_CHAIN,0,(char *)sk)\n# define SSL_CTX_set1_chain(ctx,sk) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_CHAIN,1,(char *)sk)\n# define SSL_CTX_add0_chain_cert(ctx,x509) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_CHAIN_CERT,0,(char *)x509)\n# define SSL_CTX_add1_chain_cert(ctx,x509) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_CHAIN_CERT,1,(char *)x509)\n# define SSL_CTX_get0_chain_certs(ctx,px509) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_GET_CHAIN_CERTS,0,px509)\n# define SSL_CTX_clear_chain_certs(ctx) \\\n        SSL_CTX_set0_chain(ctx,NULL)\n# define SSL_CTX_build_cert_chain(ctx, flags) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_BUILD_CERT_CHAIN, flags, NULL)\n# define SSL_CTX_select_current_cert(ctx,x509) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_SELECT_CURRENT_CERT,0,(char *)x509)\n# define SSL_CTX_set_current_cert(ctx, op) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_SET_CURRENT_CERT, op, NULL)\n# define SSL_CTX_set0_verify_cert_store(ctx,st) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_SET_VERIFY_CERT_STORE,0,(char *)st)\n# define SSL_CTX_set1_verify_cert_store(ctx,st) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_SET_VERIFY_CERT_STORE,1,(char *)st)\n# define SSL_CTX_set0_chain_cert_store(ctx,st) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_SET_CHAIN_CERT_STORE,0,(char *)st)\n# define SSL_CTX_set1_chain_cert_store(ctx,st) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_SET_CHAIN_CERT_STORE,1,(char *)st)\n# define SSL_set0_chain(ctx,sk) \\\n        SSL_ctrl(ctx,SSL_CTRL_CHAIN,0,(char *)sk)\n# define SSL_set1_chain(ctx,sk) \\\n        SSL_ctrl(ctx,SSL_CTRL_CHAIN,1,(char *)sk)\n# define SSL_add0_chain_cert(ctx,x509) \\\n        SSL_ctrl(ctx,SSL_CTRL_CHAIN_CERT,0,(char *)x509)\n# define SSL_add1_chain_cert(ctx,x509) \\\n        SSL_ctrl(ctx,SSL_CTRL_CHAIN_CERT,1,(char *)x509)\n# define SSL_get0_chain_certs(ctx,px509) \\\n        SSL_ctrl(ctx,SSL_CTRL_GET_CHAIN_CERTS,0,px509)\n# define SSL_clear_chain_certs(ctx) \\\n        SSL_set0_chain(ctx,NULL)\n# define SSL_build_cert_chain(s, flags) \\\n        SSL_ctrl(s,SSL_CTRL_BUILD_CERT_CHAIN, flags, NULL)\n# define SSL_select_current_cert(ctx,x509) \\\n        SSL_ctrl(ctx,SSL_CTRL_SELECT_CURRENT_CERT,0,(char *)x509)\n# define SSL_set_current_cert(ctx,op) \\\n        SSL_ctrl(ctx,SSL_CTRL_SET_CURRENT_CERT, op, NULL)\n# define SSL_set0_verify_cert_store(s,st) \\\n        SSL_ctrl(s,SSL_CTRL_SET_VERIFY_CERT_STORE,0,(char *)st)\n# define SSL_set1_verify_cert_store(s,st) \\\n        SSL_ctrl(s,SSL_CTRL_SET_VERIFY_CERT_STORE,1,(char *)st)\n# define SSL_set0_chain_cert_store(s,st) \\\n        SSL_ctrl(s,SSL_CTRL_SET_CHAIN_CERT_STORE,0,(char *)st)\n# define SSL_set1_chain_cert_store(s,st) \\\n        SSL_ctrl(s,SSL_CTRL_SET_CHAIN_CERT_STORE,1,(char *)st)\n# define SSL_get1_curves(ctx, s) \\\n        SSL_ctrl(ctx,SSL_CTRL_GET_CURVES,0,(char *)s)\n# define SSL_CTX_set1_curves(ctx, clist, clistlen) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_SET_CURVES,clistlen,(char *)clist)\n# define SSL_CTX_set1_curves_list(ctx, s) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_SET_CURVES_LIST,0,(char *)s)\n# define SSL_set1_curves(ctx, clist, clistlen) \\\n        SSL_ctrl(ctx,SSL_CTRL_SET_CURVES,clistlen,(char *)clist)\n# define SSL_set1_curves_list(ctx, s) \\\n        SSL_ctrl(ctx,SSL_CTRL_SET_CURVES_LIST,0,(char *)s)\n# define SSL_get_shared_curve(s, n) \\\n        SSL_ctrl(s,SSL_CTRL_GET_SHARED_CURVE,n,NULL)\n# define SSL_CTX_set_ecdh_auto(ctx, onoff) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_SET_ECDH_AUTO,onoff,NULL)\n# define SSL_set_ecdh_auto(s, onoff) \\\n        SSL_ctrl(s,SSL_CTRL_SET_ECDH_AUTO,onoff,NULL)\n# define SSL_CTX_set1_sigalgs(ctx, slist, slistlen) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_SET_SIGALGS,slistlen,(int *)slist)\n# define SSL_CTX_set1_sigalgs_list(ctx, s) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_SET_SIGALGS_LIST,0,(char *)s)\n# define SSL_set1_sigalgs(ctx, slist, slistlen) \\\n        SSL_ctrl(ctx,SSL_CTRL_SET_SIGALGS,slistlen,(int *)slist)\n# define SSL_set1_sigalgs_list(ctx, s) \\\n        SSL_ctrl(ctx,SSL_CTRL_SET_SIGALGS_LIST,0,(char *)s)\n# define SSL_CTX_set1_client_sigalgs(ctx, slist, slistlen) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_SET_CLIENT_SIGALGS,slistlen,(int *)slist)\n# define SSL_CTX_set1_client_sigalgs_list(ctx, s) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_SET_CLIENT_SIGALGS_LIST,0,(char *)s)\n# define SSL_set1_client_sigalgs(ctx, slist, slistlen) \\\n        SSL_ctrl(ctx,SSL_CTRL_SET_CLIENT_SIGALGS,clistlen,(int *)slist)\n# define SSL_set1_client_sigalgs_list(ctx, s) \\\n        SSL_ctrl(ctx,SSL_CTRL_SET_CLIENT_SIGALGS_LIST,0,(char *)s)\n# define SSL_get0_certificate_types(s, clist) \\\n        SSL_ctrl(s, SSL_CTRL_GET_CLIENT_CERT_TYPES, 0, (char *)clist)\n# define SSL_CTX_set1_client_certificate_types(ctx, clist, clistlen) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_SET_CLIENT_CERT_TYPES,clistlen,(char *)clist)\n# define SSL_set1_client_certificate_types(s, clist, clistlen) \\\n        SSL_ctrl(s,SSL_CTRL_SET_CLIENT_CERT_TYPES,clistlen,(char *)clist)\n# define SSL_get_peer_signature_nid(s, pn) \\\n        SSL_ctrl(s,SSL_CTRL_GET_PEER_SIGNATURE_NID,0,pn)\n# define SSL_get_server_tmp_key(s, pk) \\\n        SSL_ctrl(s,SSL_CTRL_GET_SERVER_TMP_KEY,0,pk)\n# define SSL_get0_raw_cipherlist(s, plst) \\\n        SSL_ctrl(s,SSL_CTRL_GET_RAW_CIPHERLIST,0,(char *)plst)\n# define SSL_get0_ec_point_formats(s, plst) \\\n        SSL_ctrl(s,SSL_CTRL_GET_EC_POINT_FORMATS,0,(char *)plst)\n# ifndef OPENSSL_NO_BIO\nBIO_METHOD *BIO_f_ssl(void);\nBIO *BIO_new_ssl(SSL_CTX *ctx, int client);\nBIO *BIO_new_ssl_connect(SSL_CTX *ctx);\nBIO *BIO_new_buffer_ssl_connect(SSL_CTX *ctx);\nint BIO_ssl_copy_session_id(BIO *to, BIO *from);\nvoid BIO_ssl_shutdown(BIO *ssl_bio);\n\n# endif\n\nint SSL_CTX_set_cipher_list(SSL_CTX *, const char *str);\nSSL_CTX *SSL_CTX_new(const SSL_METHOD *meth);\nvoid SSL_CTX_free(SSL_CTX *);\nlong SSL_CTX_set_timeout(SSL_CTX *ctx, long t);\nlong SSL_CTX_get_timeout(const SSL_CTX *ctx);\nX509_STORE *SSL_CTX_get_cert_store(const SSL_CTX *);\nvoid SSL_CTX_set_cert_store(SSL_CTX *, X509_STORE *);\nint SSL_want(const SSL *s);\nint SSL_clear(SSL *s);\n\nvoid SSL_CTX_flush_sessions(SSL_CTX *ctx, long tm);\n\nconst SSL_CIPHER *SSL_get_current_cipher(const SSL *s);\nint SSL_CIPHER_get_bits(const SSL_CIPHER *c, int *alg_bits);\nchar *SSL_CIPHER_get_version(const SSL_CIPHER *c);\nconst char *SSL_CIPHER_get_name(const SSL_CIPHER *c);\nunsigned long SSL_CIPHER_get_id(const SSL_CIPHER *c);\n\nint SSL_get_fd(const SSL *s);\nint SSL_get_rfd(const SSL *s);\nint SSL_get_wfd(const SSL *s);\nconst char *SSL_get_cipher_list(const SSL *s, int n);\nchar *SSL_get_shared_ciphers(const SSL *s, char *buf, int len);\nint SSL_get_read_ahead(const SSL *s);\nint SSL_pending(const SSL *s);\n# ifndef OPENSSL_NO_SOCK\nint SSL_set_fd(SSL *s, int fd);\nint SSL_set_rfd(SSL *s, int fd);\nint SSL_set_wfd(SSL *s, int fd);\n# endif\n# ifndef OPENSSL_NO_BIO\nvoid SSL_set_bio(SSL *s, BIO *rbio, BIO *wbio);\nBIO *SSL_get_rbio(const SSL *s);\nBIO *SSL_get_wbio(const SSL *s);\n# endif\nint SSL_set_cipher_list(SSL *s, const char *str);\nvoid SSL_set_read_ahead(SSL *s, int yes);\nint SSL_get_verify_mode(const SSL *s);\nint SSL_get_verify_depth(const SSL *s);\nint (*SSL_get_verify_callback(const SSL *s)) (int, X509_STORE_CTX *);\nvoid SSL_set_verify(SSL *s, int mode,\n                    int (*callback) (int ok, X509_STORE_CTX *ctx));\nvoid SSL_set_verify_depth(SSL *s, int depth);\nvoid SSL_set_cert_cb(SSL *s, int (*cb) (SSL *ssl, void *arg), void *arg);\n# ifndef OPENSSL_NO_RSA\nint SSL_use_RSAPrivateKey(SSL *ssl, RSA *rsa);\n# endif\nint SSL_use_RSAPrivateKey_ASN1(SSL *ssl, unsigned char *d, long len);\nint SSL_use_PrivateKey(SSL *ssl, EVP_PKEY *pkey);\nint SSL_use_PrivateKey_ASN1(int pk, SSL *ssl, const unsigned char *d,\n                            long len);\nint SSL_use_certificate(SSL *ssl, X509 *x);\nint SSL_use_certificate_ASN1(SSL *ssl, const unsigned char *d, int len);\n\n# ifndef OPENSSL_NO_TLSEXT\n/* Set serverinfo data for the current active cert. */\nint SSL_CTX_use_serverinfo(SSL_CTX *ctx, const unsigned char *serverinfo,\n                           size_t serverinfo_length);\n#  ifndef OPENSSL_NO_STDIO\nint SSL_CTX_use_serverinfo_file(SSL_CTX *ctx, const char *file);\n#  endif                        /* NO_STDIO */\n\n# endif\n\n# ifndef OPENSSL_NO_STDIO\nint SSL_use_RSAPrivateKey_file(SSL *ssl, const char *file, int type);\nint SSL_use_PrivateKey_file(SSL *ssl, const char *file, int type);\nint SSL_use_certificate_file(SSL *ssl, const char *file, int type);\nint SSL_CTX_use_RSAPrivateKey_file(SSL_CTX *ctx, const char *file, int type);\nint SSL_CTX_use_PrivateKey_file(SSL_CTX *ctx, const char *file, int type);\nint SSL_CTX_use_certificate_file(SSL_CTX *ctx, const char *file, int type);\n/* PEM type */\nint SSL_CTX_use_certificate_chain_file(SSL_CTX *ctx, const char *file);\nSTACK_OF(X509_NAME) *SSL_load_client_CA_file(const char *file);\nint SSL_add_file_cert_subjects_to_stack(STACK_OF(X509_NAME) *stackCAs,\n                                        const char *file);\n#  ifndef OPENSSL_SYS_VMS\n/* XXXXX: Better scheme needed! [was: #ifndef MAC_OS_pre_X] */\n#   ifndef OPENSSL_SYS_MACINTOSH_CLASSIC\nint SSL_add_dir_cert_subjects_to_stack(STACK_OF(X509_NAME) *stackCAs,\n                                       const char *dir);\n#   endif\n#  endif\n\n# endif\n\nvoid SSL_load_error_strings(void);\nconst char *SSL_state_string(const SSL *s);\nconst char *SSL_rstate_string(const SSL *s);\nconst char *SSL_state_string_long(const SSL *s);\nconst char *SSL_rstate_string_long(const SSL *s);\nlong SSL_SESSION_get_time(const SSL_SESSION *s);\nlong SSL_SESSION_set_time(SSL_SESSION *s, long t);\nlong SSL_SESSION_get_timeout(const SSL_SESSION *s);\nlong SSL_SESSION_set_timeout(SSL_SESSION *s, long t);\nvoid SSL_copy_session_id(SSL *to, const SSL *from);\nX509 *SSL_SESSION_get0_peer(SSL_SESSION *s);\nint SSL_SESSION_set1_id_context(SSL_SESSION *s, const unsigned char *sid_ctx,\n                                unsigned int sid_ctx_len);\n\nSSL_SESSION *SSL_SESSION_new(void);\nconst unsigned char *SSL_SESSION_get_id(const SSL_SESSION *s,\n                                        unsigned int *len);\nunsigned int SSL_SESSION_get_compress_id(const SSL_SESSION *s);\n# ifndef OPENSSL_NO_FP_API\nint SSL_SESSION_print_fp(FILE *fp, const SSL_SESSION *ses);\n# endif\n# ifndef OPENSSL_NO_BIO\nint SSL_SESSION_print(BIO *fp, const SSL_SESSION *ses);\n# endif\nvoid SSL_SESSION_free(SSL_SESSION *ses);\nint i2d_SSL_SESSION(SSL_SESSION *in, unsigned char **pp);\nint SSL_set_session(SSL *to, SSL_SESSION *session);\nint SSL_CTX_add_session(SSL_CTX *s, SSL_SESSION *c);\nint SSL_CTX_remove_session(SSL_CTX *, SSL_SESSION *c);\nint SSL_CTX_set_generate_session_id(SSL_CTX *, GEN_SESSION_CB);\nint SSL_set_generate_session_id(SSL *, GEN_SESSION_CB);\nint SSL_has_matching_session_id(const SSL *ssl, const unsigned char *id,\n                                unsigned int id_len);\nSSL_SESSION *d2i_SSL_SESSION(SSL_SESSION **a, const unsigned char **pp,\n                             long length);\n\n# ifdef HEADER_X509_H\nX509 *SSL_get_peer_certificate(const SSL *s);\n# endif\n\nSTACK_OF(X509) *SSL_get_peer_cert_chain(const SSL *s);\n\nint SSL_CTX_get_verify_mode(const SSL_CTX *ctx);\nint SSL_CTX_get_verify_depth(const SSL_CTX *ctx);\nint (*SSL_CTX_get_verify_callback(const SSL_CTX *ctx)) (int,\n                                                        X509_STORE_CTX *);\nvoid SSL_CTX_set_verify(SSL_CTX *ctx, int mode,\n                        int (*callback) (int, X509_STORE_CTX *));\nvoid SSL_CTX_set_verify_depth(SSL_CTX *ctx, int depth);\nvoid SSL_CTX_set_cert_verify_callback(SSL_CTX *ctx,\n                                      int (*cb) (X509_STORE_CTX *, void *),\n                                      void *arg);\nvoid SSL_CTX_set_cert_cb(SSL_CTX *c, int (*cb) (SSL *ssl, void *arg),\n                         void *arg);\n# ifndef OPENSSL_NO_RSA\nint SSL_CTX_use_RSAPrivateKey(SSL_CTX *ctx, RSA *rsa);\n# endif\nint SSL_CTX_use_RSAPrivateKey_ASN1(SSL_CTX *ctx, const unsigned char *d,\n                                   long len);\nint SSL_CTX_use_PrivateKey(SSL_CTX *ctx, EVP_PKEY *pkey);\nint SSL_CTX_use_PrivateKey_ASN1(int pk, SSL_CTX *ctx,\n                                const unsigned char *d, long len);\nint SSL_CTX_use_certificate(SSL_CTX *ctx, X509 *x);\nint SSL_CTX_use_certificate_ASN1(SSL_CTX *ctx, int len,\n                                 const unsigned char *d);\n\nvoid SSL_CTX_set_default_passwd_cb(SSL_CTX *ctx, pem_password_cb *cb);\nvoid SSL_CTX_set_default_passwd_cb_userdata(SSL_CTX *ctx, void *u);\n\nint SSL_CTX_check_private_key(const SSL_CTX *ctx);\nint SSL_check_private_key(const SSL *ctx);\n\nint SSL_CTX_set_session_id_context(SSL_CTX *ctx, const unsigned char *sid_ctx,\n                                   unsigned int sid_ctx_len);\n\nSSL *SSL_new(SSL_CTX *ctx);\nint SSL_set_session_id_context(SSL *ssl, const unsigned char *sid_ctx,\n                               unsigned int sid_ctx_len);\n\nint SSL_CTX_set_purpose(SSL_CTX *s, int purpose);\nint SSL_set_purpose(SSL *s, int purpose);\nint SSL_CTX_set_trust(SSL_CTX *s, int trust);\nint SSL_set_trust(SSL *s, int trust);\n\nint SSL_CTX_set1_param(SSL_CTX *ctx, X509_VERIFY_PARAM *vpm);\nint SSL_set1_param(SSL *ssl, X509_VERIFY_PARAM *vpm);\n\nX509_VERIFY_PARAM *SSL_CTX_get0_param(SSL_CTX *ctx);\nX509_VERIFY_PARAM *SSL_get0_param(SSL *ssl);\n\n# ifndef OPENSSL_NO_SRP\nint SSL_CTX_set_srp_username(SSL_CTX *ctx, char *name);\nint SSL_CTX_set_srp_password(SSL_CTX *ctx, char *password);\nint SSL_CTX_set_srp_strength(SSL_CTX *ctx, int strength);\nint SSL_CTX_set_srp_client_pwd_callback(SSL_CTX *ctx,\n                                        char *(*cb) (SSL *, void *));\nint SSL_CTX_set_srp_verify_param_callback(SSL_CTX *ctx,\n                                          int (*cb) (SSL *, void *));\nint SSL_CTX_set_srp_username_callback(SSL_CTX *ctx,\n                                      int (*cb) (SSL *, int *, void *));\nint SSL_CTX_set_srp_cb_arg(SSL_CTX *ctx, void *arg);\n\nint SSL_set_srp_server_param(SSL *s, const BIGNUM *N, const BIGNUM *g,\n                             BIGNUM *sa, BIGNUM *v, char *info);\nint SSL_set_srp_server_param_pw(SSL *s, const char *user, const char *pass,\n                                const char *grp);\n\nBIGNUM *SSL_get_srp_g(SSL *s);\nBIGNUM *SSL_get_srp_N(SSL *s);\n\nchar *SSL_get_srp_username(SSL *s);\nchar *SSL_get_srp_userinfo(SSL *s);\n# endif\n\nvoid SSL_certs_clear(SSL *s);\nvoid SSL_free(SSL *ssl);\nint SSL_accept(SSL *ssl);\nint SSL_connect(SSL *ssl);\nint SSL_read(SSL *ssl, void *buf, int num);\nint SSL_peek(SSL *ssl, void *buf, int num);\nint SSL_write(SSL *ssl, const void *buf, int num);\nlong SSL_ctrl(SSL *ssl, int cmd, long larg, void *parg);\nlong SSL_callback_ctrl(SSL *, int, void (*)(void));\nlong SSL_CTX_ctrl(SSL_CTX *ctx, int cmd, long larg, void *parg);\nlong SSL_CTX_callback_ctrl(SSL_CTX *, int, void (*)(void));\n\nint SSL_get_error(const SSL *s, int ret_code);\nconst char *SSL_get_version(const SSL *s);\n\n/* This sets the 'default' SSL version that SSL_new() will create */\nint SSL_CTX_set_ssl_version(SSL_CTX *ctx, const SSL_METHOD *meth);\n\n# ifndef OPENSSL_NO_SSL2_METHOD\nconst SSL_METHOD *SSLv2_method(void); /* SSLv2 */\nconst SSL_METHOD *SSLv2_server_method(void); /* SSLv2 */\nconst SSL_METHOD *SSLv2_client_method(void); /* SSLv2 */\n# endif\n\n# ifndef OPENSSL_NO_SSL3_METHOD\nconst SSL_METHOD *SSLv3_method(void); /* SSLv3 */\nconst SSL_METHOD *SSLv3_server_method(void); /* SSLv3 */\nconst SSL_METHOD *SSLv3_client_method(void); /* SSLv3 */\n# endif\n\nconst SSL_METHOD *SSLv23_method(void); /* Negotiate highest available SSL/TLS\n                                        * version */\nconst SSL_METHOD *SSLv23_server_method(void); /* Negotiate highest available\n                                               * SSL/TLS version */\nconst SSL_METHOD *SSLv23_client_method(void); /* Negotiate highest available\n                                               * SSL/TLS version */\n\nconst SSL_METHOD *TLSv1_method(void); /* TLSv1.0 */\nconst SSL_METHOD *TLSv1_server_method(void); /* TLSv1.0 */\nconst SSL_METHOD *TLSv1_client_method(void); /* TLSv1.0 */\n\nconst SSL_METHOD *TLSv1_1_method(void); /* TLSv1.1 */\nconst SSL_METHOD *TLSv1_1_server_method(void); /* TLSv1.1 */\nconst SSL_METHOD *TLSv1_1_client_method(void); /* TLSv1.1 */\n\nconst SSL_METHOD *TLSv1_2_method(void); /* TLSv1.2 */\nconst SSL_METHOD *TLSv1_2_server_method(void); /* TLSv1.2 */\nconst SSL_METHOD *TLSv1_2_client_method(void); /* TLSv1.2 */\n\nconst SSL_METHOD *DTLSv1_method(void); /* DTLSv1.0 */\nconst SSL_METHOD *DTLSv1_server_method(void); /* DTLSv1.0 */\nconst SSL_METHOD *DTLSv1_client_method(void); /* DTLSv1.0 */\n\nconst SSL_METHOD *DTLSv1_2_method(void); /* DTLSv1.2 */\nconst SSL_METHOD *DTLSv1_2_server_method(void); /* DTLSv1.2 */\nconst SSL_METHOD *DTLSv1_2_client_method(void); /* DTLSv1.2 */\n\nconst SSL_METHOD *DTLS_method(void); /* DTLS 1.0 and 1.2 */\nconst SSL_METHOD *DTLS_server_method(void); /* DTLS 1.0 and 1.2 */\nconst SSL_METHOD *DTLS_client_method(void); /* DTLS 1.0 and 1.2 */\n\nSTACK_OF(SSL_CIPHER) *SSL_get_ciphers(const SSL *s);\n\nint SSL_do_handshake(SSL *s);\nint SSL_renegotiate(SSL *s);\nint SSL_renegotiate_abbreviated(SSL *s);\nint SSL_renegotiate_pending(SSL *s);\nint SSL_shutdown(SSL *s);\n\nconst SSL_METHOD *SSL_CTX_get_ssl_method(SSL_CTX *ctx);\nconst SSL_METHOD *SSL_get_ssl_method(SSL *s);\nint SSL_set_ssl_method(SSL *s, const SSL_METHOD *method);\nconst char *SSL_alert_type_string_long(int value);\nconst char *SSL_alert_type_string(int value);\nconst char *SSL_alert_desc_string_long(int value);\nconst char *SSL_alert_desc_string(int value);\n\nvoid SSL_set_client_CA_list(SSL *s, STACK_OF(X509_NAME) *name_list);\nvoid SSL_CTX_set_client_CA_list(SSL_CTX *ctx, STACK_OF(X509_NAME) *name_list);\nSTACK_OF(X509_NAME) *SSL_get_client_CA_list(const SSL *s);\nSTACK_OF(X509_NAME) *SSL_CTX_get_client_CA_list(const SSL_CTX *s);\nint SSL_add_client_CA(SSL *ssl, X509 *x);\nint SSL_CTX_add_client_CA(SSL_CTX *ctx, X509 *x);\n\nvoid SSL_set_connect_state(SSL *s);\nvoid SSL_set_accept_state(SSL *s);\n\nlong SSL_get_default_timeout(const SSL *s);\n\nint SSL_library_init(void);\n\nchar *SSL_CIPHER_description(const SSL_CIPHER *, char *buf, int size);\nSTACK_OF(X509_NAME) *SSL_dup_CA_list(STACK_OF(X509_NAME) *sk);\n\nSSL *SSL_dup(SSL *ssl);\n\nX509 *SSL_get_certificate(const SSL *ssl);\n/*\n * EVP_PKEY\n */ struct evp_pkey_st *SSL_get_privatekey(const SSL *ssl);\n\nX509 *SSL_CTX_get0_certificate(const SSL_CTX *ctx);\nEVP_PKEY *SSL_CTX_get0_privatekey(const SSL_CTX *ctx);\n\nvoid SSL_CTX_set_quiet_shutdown(SSL_CTX *ctx, int mode);\nint SSL_CTX_get_quiet_shutdown(const SSL_CTX *ctx);\nvoid SSL_set_quiet_shutdown(SSL *ssl, int mode);\nint SSL_get_quiet_shutdown(const SSL *ssl);\nvoid SSL_set_shutdown(SSL *ssl, int mode);\nint SSL_get_shutdown(const SSL *ssl);\nint SSL_version(const SSL *ssl);\nint SSL_CTX_set_default_verify_paths(SSL_CTX *ctx);\nint SSL_CTX_load_verify_locations(SSL_CTX *ctx, const char *CAfile,\n                                  const char *CApath);\n# define SSL_get0_session SSL_get_session/* just peek at pointer */\nSSL_SESSION *SSL_get_session(const SSL *ssl);\nSSL_SESSION *SSL_get1_session(SSL *ssl); /* obtain a reference count */\nSSL_CTX *SSL_get_SSL_CTX(const SSL *ssl);\nSSL_CTX *SSL_set_SSL_CTX(SSL *ssl, SSL_CTX *ctx);\nvoid SSL_set_info_callback(SSL *ssl,\n                           void (*cb) (const SSL *ssl, int type, int val));\nvoid (*SSL_get_info_callback(const SSL *ssl)) (const SSL *ssl, int type,\n                                               int val);\nint SSL_state(const SSL *ssl);\nvoid SSL_set_state(SSL *ssl, int state);\n\nvoid SSL_set_verify_result(SSL *ssl, long v);\nlong SSL_get_verify_result(const SSL *ssl);\n\nint SSL_set_ex_data(SSL *ssl, int idx, void *data);\nvoid *SSL_get_ex_data(const SSL *ssl, int idx);\nint SSL_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func,\n                         CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func);\n\nint SSL_SESSION_set_ex_data(SSL_SESSION *ss, int idx, void *data);\nvoid *SSL_SESSION_get_ex_data(const SSL_SESSION *ss, int idx);\nint SSL_SESSION_get_ex_new_index(long argl, void *argp,\n                                 CRYPTO_EX_new *new_func,\n                                 CRYPTO_EX_dup *dup_func,\n                                 CRYPTO_EX_free *free_func);\n\nint SSL_CTX_set_ex_data(SSL_CTX *ssl, int idx, void *data);\nvoid *SSL_CTX_get_ex_data(const SSL_CTX *ssl, int idx);\nint SSL_CTX_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func,\n                             CRYPTO_EX_dup *dup_func,\n                             CRYPTO_EX_free *free_func);\n\nint SSL_get_ex_data_X509_STORE_CTX_idx(void);\n\n# define SSL_CTX_sess_set_cache_size(ctx,t) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_SET_SESS_CACHE_SIZE,t,NULL)\n# define SSL_CTX_sess_get_cache_size(ctx) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_GET_SESS_CACHE_SIZE,0,NULL)\n# define SSL_CTX_set_session_cache_mode(ctx,m) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_SET_SESS_CACHE_MODE,m,NULL)\n# define SSL_CTX_get_session_cache_mode(ctx) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_GET_SESS_CACHE_MODE,0,NULL)\n\n# define SSL_CTX_get_default_read_ahead(ctx) SSL_CTX_get_read_ahead(ctx)\n# define SSL_CTX_set_default_read_ahead(ctx,m) SSL_CTX_set_read_ahead(ctx,m)\n# define SSL_CTX_get_read_ahead(ctx) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_GET_READ_AHEAD,0,NULL)\n# define SSL_CTX_set_read_ahead(ctx,m) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_SET_READ_AHEAD,m,NULL)\n# define SSL_CTX_get_max_cert_list(ctx) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_GET_MAX_CERT_LIST,0,NULL)\n# define SSL_CTX_set_max_cert_list(ctx,m) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_SET_MAX_CERT_LIST,m,NULL)\n# define SSL_get_max_cert_list(ssl) \\\n        SSL_ctrl(ssl,SSL_CTRL_GET_MAX_CERT_LIST,0,NULL)\n# define SSL_set_max_cert_list(ssl,m) \\\n        SSL_ctrl(ssl,SSL_CTRL_SET_MAX_CERT_LIST,m,NULL)\n\n# define SSL_CTX_set_max_send_fragment(ctx,m) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_SET_MAX_SEND_FRAGMENT,m,NULL)\n# define SSL_set_max_send_fragment(ssl,m) \\\n        SSL_ctrl(ssl,SSL_CTRL_SET_MAX_SEND_FRAGMENT,m,NULL)\n\n     /* NB: the keylength is only applicable when is_export is true */\n# ifndef OPENSSL_NO_RSA\nvoid SSL_CTX_set_tmp_rsa_callback(SSL_CTX *ctx,\n                                  RSA *(*cb) (SSL *ssl, int is_export,\n                                              int keylength));\n\nvoid SSL_set_tmp_rsa_callback(SSL *ssl,\n                              RSA *(*cb) (SSL *ssl, int is_export,\n                                          int keylength));\n# endif\n# ifndef OPENSSL_NO_DH\nvoid SSL_CTX_set_tmp_dh_callback(SSL_CTX *ctx,\n                                 DH *(*dh) (SSL *ssl, int is_export,\n                                            int keylength));\nvoid SSL_set_tmp_dh_callback(SSL *ssl,\n                             DH *(*dh) (SSL *ssl, int is_export,\n                                        int keylength));\n# endif\n# ifndef OPENSSL_NO_ECDH\nvoid SSL_CTX_set_tmp_ecdh_callback(SSL_CTX *ctx,\n                                   EC_KEY *(*ecdh) (SSL *ssl, int is_export,\n                                                    int keylength));\nvoid SSL_set_tmp_ecdh_callback(SSL *ssl,\n                               EC_KEY *(*ecdh) (SSL *ssl, int is_export,\n                                                int keylength));\n# endif\n\n# ifndef OPENSSL_NO_COMP\nconst COMP_METHOD *SSL_get_current_compression(SSL *s);\nconst COMP_METHOD *SSL_get_current_expansion(SSL *s);\nconst char *SSL_COMP_get_name(const COMP_METHOD *comp);\nSTACK_OF(SSL_COMP) *SSL_COMP_get_compression_methods(void);\nSTACK_OF(SSL_COMP) *SSL_COMP_set0_compression_methods(STACK_OF(SSL_COMP)\n                                                      *meths);\nvoid SSL_COMP_free_compression_methods(void);\nint SSL_COMP_add_compression_method(int id, COMP_METHOD *cm);\n# else\nconst void *SSL_get_current_compression(SSL *s);\nconst void *SSL_get_current_expansion(SSL *s);\nconst char *SSL_COMP_get_name(const void *comp);\nvoid *SSL_COMP_get_compression_methods(void);\nint SSL_COMP_add_compression_method(int id, void *cm);\n# endif\n\nconst SSL_CIPHER *SSL_CIPHER_find(SSL *ssl, const unsigned char *ptr);\n\n/* TLS extensions functions */\nint SSL_set_session_ticket_ext(SSL *s, void *ext_data, int ext_len);\n\nint SSL_set_session_ticket_ext_cb(SSL *s, tls_session_ticket_ext_cb_fn cb,\n                                  void *arg);\n\n/* Pre-shared secret session resumption functions */\nint SSL_set_session_secret_cb(SSL *s,\n                              tls_session_secret_cb_fn tls_session_secret_cb,\n                              void *arg);\n\nvoid SSL_set_debug(SSL *s, int debug);\nint SSL_cache_hit(SSL *s);\nint SSL_is_server(SSL *s);\n\nSSL_CONF_CTX *SSL_CONF_CTX_new(void);\nint SSL_CONF_CTX_finish(SSL_CONF_CTX *cctx);\nvoid SSL_CONF_CTX_free(SSL_CONF_CTX *cctx);\nunsigned int SSL_CONF_CTX_set_flags(SSL_CONF_CTX *cctx, unsigned int flags);\nunsigned int SSL_CONF_CTX_clear_flags(SSL_CONF_CTX *cctx, unsigned int flags);\nint SSL_CONF_CTX_set1_prefix(SSL_CONF_CTX *cctx, const char *pre);\n\nvoid SSL_CONF_CTX_set_ssl(SSL_CONF_CTX *cctx, SSL *ssl);\nvoid SSL_CONF_CTX_set_ssl_ctx(SSL_CONF_CTX *cctx, SSL_CTX *ctx);\n\nint SSL_CONF_cmd(SSL_CONF_CTX *cctx, const char *cmd, const char *value);\nint SSL_CONF_cmd_argv(SSL_CONF_CTX *cctx, int *pargc, char ***pargv);\nint SSL_CONF_cmd_value_type(SSL_CONF_CTX *cctx, const char *cmd);\n\n# ifndef OPENSSL_NO_SSL_TRACE\nvoid SSL_trace(int write_p, int version, int content_type,\n               const void *buf, size_t len, SSL *ssl, void *arg);\nconst char *SSL_CIPHER_standard_name(const SSL_CIPHER *c);\n# endif\n\n# ifndef OPENSSL_NO_UNIT_TEST\nconst struct openssl_ssl_test_functions *SSL_test_functions(void);\n# endif\n\n/* BEGIN ERROR CODES */\n/*\n * The following lines are auto generated by the script mkerr.pl. Any changes\n * made after this point may be overwritten when the script is next run.\n */\nvoid ERR_load_SSL_strings(void);\n\n/* Error codes for the SSL functions. */\n\n/* Function codes. */\n# define SSL_F_CHECK_SUITEB_CIPHER_LIST                   331\n# define SSL_F_CLIENT_CERTIFICATE                         100\n# define SSL_F_CLIENT_FINISHED                            167\n# define SSL_F_CLIENT_HELLO                               101\n# define SSL_F_CLIENT_MASTER_KEY                          102\n# define SSL_F_D2I_SSL_SESSION                            103\n# define SSL_F_DO_DTLS1_WRITE                             245\n# define SSL_F_DO_SSL3_WRITE                              104\n# define SSL_F_DTLS1_ACCEPT                               246\n# define SSL_F_DTLS1_ADD_CERT_TO_BUF                      295\n# define SSL_F_DTLS1_BUFFER_RECORD                        247\n# define SSL_F_DTLS1_CHECK_TIMEOUT_NUM                    316\n# define SSL_F_DTLS1_CLIENT_HELLO                         248\n# define SSL_F_DTLS1_CONNECT                              249\n# define SSL_F_DTLS1_ENC                                  250\n# define SSL_F_DTLS1_GET_HELLO_VERIFY                     251\n# define SSL_F_DTLS1_GET_MESSAGE                          252\n# define SSL_F_DTLS1_GET_MESSAGE_FRAGMENT                 253\n# define SSL_F_DTLS1_GET_RECORD                           254\n# define SSL_F_DTLS1_HANDLE_TIMEOUT                       297\n# define SSL_F_DTLS1_HEARTBEAT                            305\n# define SSL_F_DTLS1_OUTPUT_CERT_CHAIN                    255\n# define SSL_F_DTLS1_PREPROCESS_FRAGMENT                  288\n# define SSL_F_DTLS1_PROCESS_OUT_OF_SEQ_MESSAGE           256\n# define SSL_F_DTLS1_PROCESS_RECORD                       257\n# define SSL_F_DTLS1_READ_BYTES                           258\n# define SSL_F_DTLS1_READ_FAILED                          259\n# define SSL_F_DTLS1_SEND_CERTIFICATE_REQUEST             260\n# define SSL_F_DTLS1_SEND_CLIENT_CERTIFICATE              261\n# define SSL_F_DTLS1_SEND_CLIENT_KEY_EXCHANGE             262\n# define SSL_F_DTLS1_SEND_CLIENT_VERIFY                   263\n# define SSL_F_DTLS1_SEND_HELLO_VERIFY_REQUEST            264\n# define SSL_F_DTLS1_SEND_SERVER_CERTIFICATE              265\n# define SSL_F_DTLS1_SEND_SERVER_HELLO                    266\n# define SSL_F_DTLS1_SEND_SERVER_KEY_EXCHANGE             267\n# define SSL_F_DTLS1_WRITE_APP_DATA_BYTES                 268\n# define SSL_F_GET_CLIENT_FINISHED                        105\n# define SSL_F_GET_CLIENT_HELLO                           106\n# define SSL_F_GET_CLIENT_MASTER_KEY                      107\n# define SSL_F_GET_SERVER_FINISHED                        108\n# define SSL_F_GET_SERVER_HELLO                           109\n# define SSL_F_GET_SERVER_STATIC_DH_KEY                   340\n# define SSL_F_GET_SERVER_VERIFY                          110\n# define SSL_F_I2D_SSL_SESSION                            111\n# define SSL_F_READ_N                                     112\n# define SSL_F_REQUEST_CERTIFICATE                        113\n# define SSL_F_SERVER_FINISH                              239\n# define SSL_F_SERVER_HELLO                               114\n# define SSL_F_SERVER_VERIFY                              240\n# define SSL_F_SSL23_ACCEPT                               115\n# define SSL_F_SSL23_CLIENT_HELLO                         116\n# define SSL_F_SSL23_CONNECT                              117\n# define SSL_F_SSL23_GET_CLIENT_HELLO                     118\n# define SSL_F_SSL23_GET_SERVER_HELLO                     119\n# define SSL_F_SSL23_PEEK                                 237\n# define SSL_F_SSL23_READ                                 120\n# define SSL_F_SSL23_WRITE                                121\n# define SSL_F_SSL2_ACCEPT                                122\n# define SSL_F_SSL2_CONNECT                               123\n# define SSL_F_SSL2_ENC_INIT                              124\n# define SSL_F_SSL2_GENERATE_KEY_MATERIAL                 241\n# define SSL_F_SSL2_PEEK                                  234\n# define SSL_F_SSL2_READ                                  125\n# define SSL_F_SSL2_READ_INTERNAL                         236\n# define SSL_F_SSL2_SET_CERTIFICATE                       126\n# define SSL_F_SSL2_WRITE                                 127\n# define SSL_F_SSL3_ACCEPT                                128\n# define SSL_F_SSL3_ADD_CERT_TO_BUF                       296\n# define SSL_F_SSL3_CALLBACK_CTRL                         233\n# define SSL_F_SSL3_CHANGE_CIPHER_STATE                   129\n# define SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM              130\n# define SSL_F_SSL3_CHECK_CLIENT_HELLO                    304\n# define SSL_F_SSL3_CHECK_FINISHED                        339\n# define SSL_F_SSL3_CLIENT_HELLO                          131\n# define SSL_F_SSL3_CONNECT                               132\n# define SSL_F_SSL3_CTRL                                  213\n# define SSL_F_SSL3_CTX_CTRL                              133\n# define SSL_F_SSL3_DIGEST_CACHED_RECORDS                 293\n# define SSL_F_SSL3_DO_CHANGE_CIPHER_SPEC                 292\n# define SSL_F_SSL3_ENC                                   134\n# define SSL_F_SSL3_GENERATE_KEY_BLOCK                    238\n# define SSL_F_SSL3_GENERATE_MASTER_SECRET                388\n# define SSL_F_SSL3_GET_CERTIFICATE_REQUEST               135\n# define SSL_F_SSL3_GET_CERT_STATUS                       289\n# define SSL_F_SSL3_GET_CERT_VERIFY                       136\n# define SSL_F_SSL3_GET_CLIENT_CERTIFICATE                137\n# define SSL_F_SSL3_GET_CLIENT_HELLO                      138\n# define SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE               139\n# define SSL_F_SSL3_GET_FINISHED                          140\n# define SSL_F_SSL3_GET_KEY_EXCHANGE                      141\n# define SSL_F_SSL3_GET_MESSAGE                           142\n# define SSL_F_SSL3_GET_NEW_SESSION_TICKET                283\n# define SSL_F_SSL3_GET_NEXT_PROTO                        306\n# define SSL_F_SSL3_GET_RECORD                            143\n# define SSL_F_SSL3_GET_SERVER_CERTIFICATE                144\n# define SSL_F_SSL3_GET_SERVER_DONE                       145\n# define SSL_F_SSL3_GET_SERVER_HELLO                      146\n# define SSL_F_SSL3_HANDSHAKE_MAC                         285\n# define SSL_F_SSL3_NEW_SESSION_TICKET                    287\n# define SSL_F_SSL3_OUTPUT_CERT_CHAIN                     147\n# define SSL_F_SSL3_PEEK                                  235\n# define SSL_F_SSL3_READ_BYTES                            148\n# define SSL_F_SSL3_READ_N                                149\n# define SSL_F_SSL3_SEND_CERTIFICATE_REQUEST              150\n# define SSL_F_SSL3_SEND_CLIENT_CERTIFICATE               151\n# define SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE              152\n# define SSL_F_SSL3_SEND_CLIENT_VERIFY                    153\n# define SSL_F_SSL3_SEND_SERVER_CERTIFICATE               154\n# define SSL_F_SSL3_SEND_SERVER_HELLO                     242\n# define SSL_F_SSL3_SEND_SERVER_KEY_EXCHANGE              155\n# define SSL_F_SSL3_SETUP_KEY_BLOCK                       157\n# define SSL_F_SSL3_SETUP_READ_BUFFER                     156\n# define SSL_F_SSL3_SETUP_WRITE_BUFFER                    291\n# define SSL_F_SSL3_WRITE_BYTES                           158\n# define SSL_F_SSL3_WRITE_PENDING                         159\n# define SSL_F_SSL_ADD_CERT_CHAIN                         318\n# define SSL_F_SSL_ADD_CERT_TO_BUF                        319\n# define SSL_F_SSL_ADD_CLIENTHELLO_RENEGOTIATE_EXT        298\n# define SSL_F_SSL_ADD_CLIENTHELLO_TLSEXT                 277\n# define SSL_F_SSL_ADD_CLIENTHELLO_USE_SRTP_EXT           307\n# define SSL_F_SSL_ADD_DIR_CERT_SUBJECTS_TO_STACK         215\n# define SSL_F_SSL_ADD_FILE_CERT_SUBJECTS_TO_STACK        216\n# define SSL_F_SSL_ADD_SERVERHELLO_RENEGOTIATE_EXT        299\n# define SSL_F_SSL_ADD_SERVERHELLO_TLSEXT                 278\n# define SSL_F_SSL_ADD_SERVERHELLO_USE_SRTP_EXT           308\n# define SSL_F_SSL_BAD_METHOD                             160\n# define SSL_F_SSL_BUILD_CERT_CHAIN                       332\n# define SSL_F_SSL_BYTES_TO_CIPHER_LIST                   161\n# define SSL_F_SSL_CERT_DUP                               221\n# define SSL_F_SSL_CERT_INST                              222\n# define SSL_F_SSL_CERT_INSTANTIATE                       214\n# define SSL_F_SSL_CERT_NEW                               162\n# define SSL_F_SSL_CHECK_PRIVATE_KEY                      163\n# define SSL_F_SSL_CHECK_SERVERHELLO_TLSEXT               280\n# define SSL_F_SSL_CHECK_SRVR_ECC_CERT_AND_ALG            279\n# define SSL_F_SSL_CIPHER_PROCESS_RULESTR                 230\n# define SSL_F_SSL_CIPHER_STRENGTH_SORT                   231\n# define SSL_F_SSL_CLEAR                                  164\n# define SSL_F_SSL_COMP_ADD_COMPRESSION_METHOD            165\n# define SSL_F_SSL_CONF_CMD                               334\n# define SSL_F_SSL_CREATE_CIPHER_LIST                     166\n# define SSL_F_SSL_CTRL                                   232\n# define SSL_F_SSL_CTX_CHECK_PRIVATE_KEY                  168\n# define SSL_F_SSL_CTX_MAKE_PROFILES                      309\n# define SSL_F_SSL_CTX_NEW                                169\n# define SSL_F_SSL_CTX_SET_CIPHER_LIST                    269\n# define SSL_F_SSL_CTX_SET_CLIENT_CERT_ENGINE             290\n# define SSL_F_SSL_CTX_SET_PURPOSE                        226\n# define SSL_F_SSL_CTX_SET_SESSION_ID_CONTEXT             219\n# define SSL_F_SSL_CTX_SET_SSL_VERSION                    170\n# define SSL_F_SSL_CTX_SET_TRUST                          229\n# define SSL_F_SSL_CTX_USE_CERTIFICATE                    171\n# define SSL_F_SSL_CTX_USE_CERTIFICATE_ASN1               172\n# define SSL_F_SSL_CTX_USE_CERTIFICATE_CHAIN_FILE         220\n# define SSL_F_SSL_CTX_USE_CERTIFICATE_FILE               173\n# define SSL_F_SSL_CTX_USE_PRIVATEKEY                     174\n# define SSL_F_SSL_CTX_USE_PRIVATEKEY_ASN1                175\n# define SSL_F_SSL_CTX_USE_PRIVATEKEY_FILE                176\n# define SSL_F_SSL_CTX_USE_PSK_IDENTITY_HINT              272\n# define SSL_F_SSL_CTX_USE_RSAPRIVATEKEY                  177\n# define SSL_F_SSL_CTX_USE_RSAPRIVATEKEY_ASN1             178\n# define SSL_F_SSL_CTX_USE_RSAPRIVATEKEY_FILE             179\n# define SSL_F_SSL_CTX_USE_SERVERINFO                     336\n# define SSL_F_SSL_CTX_USE_SERVERINFO_FILE                337\n# define SSL_F_SSL_DO_HANDSHAKE                           180\n# define SSL_F_SSL_GET_NEW_SESSION                        181\n# define SSL_F_SSL_GET_PREV_SESSION                       217\n# define SSL_F_SSL_GET_SERVER_CERT_INDEX                  322\n# define SSL_F_SSL_GET_SERVER_SEND_CERT                   182\n# define SSL_F_SSL_GET_SERVER_SEND_PKEY                   317\n# define SSL_F_SSL_GET_SIGN_PKEY                          183\n# define SSL_F_SSL_INIT_WBIO_BUFFER                       184\n# define SSL_F_SSL_LOAD_CLIENT_CA_FILE                    185\n# define SSL_F_SSL_NEW                                    186\n# define SSL_F_SSL_PARSE_CLIENTHELLO_RENEGOTIATE_EXT      300\n# define SSL_F_SSL_PARSE_CLIENTHELLO_TLSEXT               302\n# define SSL_F_SSL_PARSE_CLIENTHELLO_USE_SRTP_EXT         310\n# define SSL_F_SSL_PARSE_SERVERHELLO_RENEGOTIATE_EXT      301\n# define SSL_F_SSL_PARSE_SERVERHELLO_TLSEXT               303\n# define SSL_F_SSL_PARSE_SERVERHELLO_USE_SRTP_EXT         311\n# define SSL_F_SSL_PEEK                                   270\n# define SSL_F_SSL_PREPARE_CLIENTHELLO_TLSEXT             281\n# define SSL_F_SSL_PREPARE_SERVERHELLO_TLSEXT             282\n# define SSL_F_SSL_READ                                   223\n# define SSL_F_SSL_RSA_PRIVATE_DECRYPT                    187\n# define SSL_F_SSL_RSA_PUBLIC_ENCRYPT                     188\n# define SSL_F_SSL_SCAN_CLIENTHELLO_TLSEXT                320\n# define SSL_F_SSL_SCAN_SERVERHELLO_TLSEXT                321\n# define SSL_F_SSL_SESSION_DUP                            348\n# define SSL_F_SSL_SESSION_NEW                            189\n# define SSL_F_SSL_SESSION_PRINT_FP                       190\n# define SSL_F_SSL_SESSION_SET1_ID_CONTEXT                312\n# define SSL_F_SSL_SESS_CERT_NEW                          225\n# define SSL_F_SSL_SET_CERT                               191\n# define SSL_F_SSL_SET_CIPHER_LIST                        271\n# define SSL_F_SSL_SET_FD                                 192\n# define SSL_F_SSL_SET_PKEY                               193\n# define SSL_F_SSL_SET_PURPOSE                            227\n# define SSL_F_SSL_SET_RFD                                194\n# define SSL_F_SSL_SET_SESSION                            195\n# define SSL_F_SSL_SET_SESSION_ID_CONTEXT                 218\n# define SSL_F_SSL_SET_SESSION_TICKET_EXT                 294\n# define SSL_F_SSL_SET_TRUST                              228\n# define SSL_F_SSL_SET_WFD                                196\n# define SSL_F_SSL_SHUTDOWN                               224\n# define SSL_F_SSL_SRP_CTX_INIT                           313\n# define SSL_F_SSL_UNDEFINED_CONST_FUNCTION               243\n# define SSL_F_SSL_UNDEFINED_FUNCTION                     197\n# define SSL_F_SSL_UNDEFINED_VOID_FUNCTION                244\n# define SSL_F_SSL_USE_CERTIFICATE                        198\n# define SSL_F_SSL_USE_CERTIFICATE_ASN1                   199\n# define SSL_F_SSL_USE_CERTIFICATE_FILE                   200\n# define SSL_F_SSL_USE_PRIVATEKEY                         201\n# define SSL_F_SSL_USE_PRIVATEKEY_ASN1                    202\n# define SSL_F_SSL_USE_PRIVATEKEY_FILE                    203\n# define SSL_F_SSL_USE_PSK_IDENTITY_HINT                  273\n# define SSL_F_SSL_USE_RSAPRIVATEKEY                      204\n# define SSL_F_SSL_USE_RSAPRIVATEKEY_ASN1                 205\n# define SSL_F_SSL_USE_RSAPRIVATEKEY_FILE                 206\n# define SSL_F_SSL_VERIFY_CERT_CHAIN                      207\n# define SSL_F_SSL_WRITE                                  208\n# define SSL_F_TLS12_CHECK_PEER_SIGALG                    333\n# define SSL_F_TLS1_CERT_VERIFY_MAC                       286\n# define SSL_F_TLS1_CHANGE_CIPHER_STATE                   209\n# define SSL_F_TLS1_CHECK_SERVERHELLO_TLSEXT              274\n# define SSL_F_TLS1_ENC                                   210\n# define SSL_F_TLS1_EXPORT_KEYING_MATERIAL                314\n# define SSL_F_TLS1_GET_CURVELIST                         338\n# define SSL_F_TLS1_HEARTBEAT                             315\n# define SSL_F_TLS1_PREPARE_CLIENTHELLO_TLSEXT            275\n# define SSL_F_TLS1_PREPARE_SERVERHELLO_TLSEXT            276\n# define SSL_F_TLS1_PRF                                   284\n# define SSL_F_TLS1_SETUP_KEY_BLOCK                       211\n# define SSL_F_TLS1_SET_SERVER_SIGALGS                    335\n# define SSL_F_WRITE_PENDING                              212\n\n/* Reason codes. */\n# define SSL_R_APP_DATA_IN_HANDSHAKE                      100\n# define SSL_R_ATTEMPT_TO_REUSE_SESSION_IN_DIFFERENT_CONTEXT 272\n# define SSL_R_BAD_ALERT_RECORD                           101\n# define SSL_R_BAD_AUTHENTICATION_TYPE                    102\n# define SSL_R_BAD_CHANGE_CIPHER_SPEC                     103\n# define SSL_R_BAD_CHECKSUM                               104\n# define SSL_R_BAD_DATA                                   390\n# define SSL_R_BAD_DATA_RETURNED_BY_CALLBACK              106\n# define SSL_R_BAD_DECOMPRESSION                          107\n# define SSL_R_BAD_DH_G_LENGTH                            108\n# define SSL_R_BAD_DH_G_VALUE                             375\n# define SSL_R_BAD_DH_PUB_KEY_LENGTH                      109\n# define SSL_R_BAD_DH_PUB_KEY_VALUE                       393\n# define SSL_R_BAD_DH_P_LENGTH                            110\n# define SSL_R_BAD_DH_P_VALUE                             395\n# define SSL_R_BAD_DIGEST_LENGTH                          111\n# define SSL_R_BAD_DSA_SIGNATURE                          112\n# define SSL_R_BAD_ECC_CERT                               304\n# define SSL_R_BAD_ECDSA_SIGNATURE                        305\n# define SSL_R_BAD_ECPOINT                                306\n# define SSL_R_BAD_HANDSHAKE_LENGTH                       332\n# define SSL_R_BAD_HELLO_REQUEST                          105\n# define SSL_R_BAD_LENGTH                                 271\n# define SSL_R_BAD_MAC_DECODE                             113\n# define SSL_R_BAD_MAC_LENGTH                             333\n# define SSL_R_BAD_MESSAGE_TYPE                           114\n# define SSL_R_BAD_PACKET_LENGTH                          115\n# define SSL_R_BAD_PROTOCOL_VERSION_NUMBER                116\n# define SSL_R_BAD_PSK_IDENTITY_HINT_LENGTH               316\n# define SSL_R_BAD_RESPONSE_ARGUMENT                      117\n# define SSL_R_BAD_RSA_DECRYPT                            118\n# define SSL_R_BAD_RSA_ENCRYPT                            119\n# define SSL_R_BAD_RSA_E_LENGTH                           120\n# define SSL_R_BAD_RSA_MODULUS_LENGTH                     121\n# define SSL_R_BAD_RSA_SIGNATURE                          122\n# define SSL_R_BAD_SIGNATURE                              123\n# define SSL_R_BAD_SRP_A_LENGTH                           347\n# define SSL_R_BAD_SRP_B_LENGTH                           348\n# define SSL_R_BAD_SRP_G_LENGTH                           349\n# define SSL_R_BAD_SRP_N_LENGTH                           350\n# define SSL_R_BAD_SRP_PARAMETERS                         371\n# define SSL_R_BAD_SRP_S_LENGTH                           351\n# define SSL_R_BAD_SRTP_MKI_VALUE                         352\n# define SSL_R_BAD_SRTP_PROTECTION_PROFILE_LIST           353\n# define SSL_R_BAD_SSL_FILETYPE                           124\n# define SSL_R_BAD_SSL_SESSION_ID_LENGTH                  125\n# define SSL_R_BAD_STATE                                  126\n# define SSL_R_BAD_VALUE                                  384\n# define SSL_R_BAD_WRITE_RETRY                            127\n# define SSL_R_BIO_NOT_SET                                128\n# define SSL_R_BLOCK_CIPHER_PAD_IS_WRONG                  129\n# define SSL_R_BN_LIB                                     130\n# define SSL_R_CA_DN_LENGTH_MISMATCH                      131\n# define SSL_R_CA_DN_TOO_LONG                             132\n# define SSL_R_CCS_RECEIVED_EARLY                         133\n# define SSL_R_CERTIFICATE_VERIFY_FAILED                  134\n# define SSL_R_CERT_CB_ERROR                              377\n# define SSL_R_CERT_LENGTH_MISMATCH                       135\n# define SSL_R_CHALLENGE_IS_DIFFERENT                     136\n# define SSL_R_CIPHER_CODE_WRONG_LENGTH                   137\n# define SSL_R_CIPHER_OR_HASH_UNAVAILABLE                 138\n# define SSL_R_CIPHER_TABLE_SRC_ERROR                     139\n# define SSL_R_CLIENTHELLO_TLSEXT                         226\n# define SSL_R_COMPRESSED_LENGTH_TOO_LONG                 140\n# define SSL_R_COMPRESSION_DISABLED                       343\n# define SSL_R_COMPRESSION_FAILURE                        141\n# define SSL_R_COMPRESSION_ID_NOT_WITHIN_PRIVATE_RANGE    307\n# define SSL_R_COMPRESSION_LIBRARY_ERROR                  142\n# define SSL_R_CONNECTION_ID_IS_DIFFERENT                 143\n# define SSL_R_CONNECTION_TYPE_NOT_SET                    144\n# define SSL_R_COOKIE_MISMATCH                            308\n# define SSL_R_DATA_BETWEEN_CCS_AND_FINISHED              145\n# define SSL_R_DATA_LENGTH_TOO_LONG                       146\n# define SSL_R_DECRYPTION_FAILED                          147\n# define SSL_R_DECRYPTION_FAILED_OR_BAD_RECORD_MAC        281\n# define SSL_R_DH_KEY_TOO_SMALL                           372\n# define SSL_R_DH_PUBLIC_VALUE_LENGTH_IS_WRONG            148\n# define SSL_R_DIGEST_CHECK_FAILED                        149\n# define SSL_R_DTLS_MESSAGE_TOO_BIG                       334\n# define SSL_R_DUPLICATE_COMPRESSION_ID                   309\n# define SSL_R_ECC_CERT_NOT_FOR_KEY_AGREEMENT             317\n# define SSL_R_ECC_CERT_NOT_FOR_SIGNING                   318\n# define SSL_R_ECC_CERT_SHOULD_HAVE_RSA_SIGNATURE         322\n# define SSL_R_ECC_CERT_SHOULD_HAVE_SHA1_SIGNATURE        323\n# define SSL_R_ECDH_REQUIRED_FOR_SUITEB_MODE              374\n# define SSL_R_ECGROUP_TOO_LARGE_FOR_CIPHER               310\n# define SSL_R_EMPTY_SRTP_PROTECTION_PROFILE_LIST         354\n# define SSL_R_ENCRYPTED_LENGTH_TOO_LONG                  150\n# define SSL_R_ERROR_GENERATING_TMP_RSA_KEY               282\n# define SSL_R_ERROR_IN_RECEIVED_CIPHER_LIST              151\n# define SSL_R_EXCESSIVE_MESSAGE_SIZE                     152\n# define SSL_R_EXTRA_DATA_IN_MESSAGE                      153\n# define SSL_R_GOT_A_FIN_BEFORE_A_CCS                     154\n# define SSL_R_GOT_NEXT_PROTO_BEFORE_A_CCS                355\n# define SSL_R_GOT_NEXT_PROTO_WITHOUT_EXTENSION           356\n# define SSL_R_HTTPS_PROXY_REQUEST                        155\n# define SSL_R_HTTP_REQUEST                               156\n# define SSL_R_ILLEGAL_PADDING                            283\n# define SSL_R_ILLEGAL_SUITEB_DIGEST                      380\n# define SSL_R_INAPPROPRIATE_FALLBACK                     373\n# define SSL_R_INCONSISTENT_COMPRESSION                   340\n# define SSL_R_INVALID_CHALLENGE_LENGTH                   158\n# define SSL_R_INVALID_COMMAND                            280\n# define SSL_R_INVALID_COMPRESSION_ALGORITHM              341\n# define SSL_R_INVALID_NULL_CMD_NAME                      385\n# define SSL_R_INVALID_PURPOSE                            278\n# define SSL_R_INVALID_SERVERINFO_DATA                    388\n# define SSL_R_INVALID_SRP_USERNAME                       357\n# define SSL_R_INVALID_STATUS_RESPONSE                    328\n# define SSL_R_INVALID_TICKET_KEYS_LENGTH                 325\n# define SSL_R_INVALID_TRUST                              279\n# define SSL_R_KEY_ARG_TOO_LONG                           284\n# define SSL_R_KRB5                                       285\n# define SSL_R_KRB5_C_CC_PRINC                            286\n# define SSL_R_KRB5_C_GET_CRED                            287\n# define SSL_R_KRB5_C_INIT                                288\n# define SSL_R_KRB5_C_MK_REQ                              289\n# define SSL_R_KRB5_S_BAD_TICKET                          290\n# define SSL_R_KRB5_S_INIT                                291\n# define SSL_R_KRB5_S_RD_REQ                              292\n# define SSL_R_KRB5_S_TKT_EXPIRED                         293\n# define SSL_R_KRB5_S_TKT_NYV                             294\n# define SSL_R_KRB5_S_TKT_SKEW                            295\n# define SSL_R_LENGTH_MISMATCH                            159\n# define SSL_R_LENGTH_TOO_SHORT                           160\n# define SSL_R_LIBRARY_BUG                                274\n# define SSL_R_LIBRARY_HAS_NO_CIPHERS                     161\n# define SSL_R_MESSAGE_TOO_LONG                           296\n# define SSL_R_MISSING_DH_DSA_CERT                        162\n# define SSL_R_MISSING_DH_KEY                             163\n# define SSL_R_MISSING_DH_RSA_CERT                        164\n# define SSL_R_MISSING_DSA_SIGNING_CERT                   165\n# define SSL_R_MISSING_ECDH_CERT                          382\n# define SSL_R_MISSING_ECDSA_SIGNING_CERT                 381\n# define SSL_R_MISSING_EXPORT_TMP_DH_KEY                  166\n# define SSL_R_MISSING_EXPORT_TMP_RSA_KEY                 167\n# define SSL_R_MISSING_RSA_CERTIFICATE                    168\n# define SSL_R_MISSING_RSA_ENCRYPTING_CERT                169\n# define SSL_R_MISSING_RSA_SIGNING_CERT                   170\n# define SSL_R_MISSING_SRP_PARAM                          358\n# define SSL_R_MISSING_TMP_DH_KEY                         171\n# define SSL_R_MISSING_TMP_ECDH_KEY                       311\n# define SSL_R_MISSING_TMP_RSA_KEY                        172\n# define SSL_R_MISSING_TMP_RSA_PKEY                       173\n# define SSL_R_MISSING_VERIFY_MESSAGE                     174\n# define SSL_R_MULTIPLE_SGC_RESTARTS                      346\n# define SSL_R_NON_SSLV2_INITIAL_PACKET                   175\n# define SSL_R_NO_CERTIFICATES_RETURNED                   176\n# define SSL_R_NO_CERTIFICATE_ASSIGNED                    177\n# define SSL_R_NO_CERTIFICATE_RETURNED                    178\n# define SSL_R_NO_CERTIFICATE_SET                         179\n# define SSL_R_NO_CERTIFICATE_SPECIFIED                   180\n# define SSL_R_NO_CIPHERS_AVAILABLE                       181\n# define SSL_R_NO_CIPHERS_PASSED                          182\n# define SSL_R_NO_CIPHERS_SPECIFIED                       183\n# define SSL_R_NO_CIPHER_LIST                             184\n# define SSL_R_NO_CIPHER_MATCH                            185\n# define SSL_R_NO_CLIENT_CERT_METHOD                      331\n# define SSL_R_NO_CLIENT_CERT_RECEIVED                    186\n# define SSL_R_NO_COMPRESSION_SPECIFIED                   187\n# define SSL_R_NO_GOST_CERTIFICATE_SENT_BY_PEER           330\n# define SSL_R_NO_METHOD_SPECIFIED                        188\n# define SSL_R_NO_PEM_EXTENSIONS                          389\n# define SSL_R_NO_PRIVATEKEY                              189\n# define SSL_R_NO_PRIVATE_KEY_ASSIGNED                    190\n# define SSL_R_NO_PROTOCOLS_AVAILABLE                     191\n# define SSL_R_NO_PUBLICKEY                               192\n# define SSL_R_NO_RENEGOTIATION                           339\n# define SSL_R_NO_REQUIRED_DIGEST                         324\n# define SSL_R_NO_SHARED_CIPHER                           193\n# define SSL_R_NO_SHARED_SIGATURE_ALGORITHMS              376\n# define SSL_R_NO_SRTP_PROFILES                           359\n# define SSL_R_NO_VERIFY_CALLBACK                         194\n# define SSL_R_NULL_SSL_CTX                               195\n# define SSL_R_NULL_SSL_METHOD_PASSED                     196\n# define SSL_R_OLD_SESSION_CIPHER_NOT_RETURNED            197\n# define SSL_R_OLD_SESSION_COMPRESSION_ALGORITHM_NOT_RETURNED 344\n# define SSL_R_ONLY_DTLS_1_2_ALLOWED_IN_SUITEB_MODE       387\n# define SSL_R_ONLY_TLS_1_2_ALLOWED_IN_SUITEB_MODE        379\n# define SSL_R_ONLY_TLS_ALLOWED_IN_FIPS_MODE              297\n# define SSL_R_OPAQUE_PRF_INPUT_TOO_LONG                  327\n# define SSL_R_PACKET_LENGTH_TOO_LONG                     198\n# define SSL_R_PARSE_TLSEXT                               227\n# define SSL_R_PATH_TOO_LONG                              270\n# define SSL_R_PEER_DID_NOT_RETURN_A_CERTIFICATE          199\n# define SSL_R_PEER_ERROR                                 200\n# define SSL_R_PEER_ERROR_CERTIFICATE                     201\n# define SSL_R_PEER_ERROR_NO_CERTIFICATE                  202\n# define SSL_R_PEER_ERROR_NO_CIPHER                       203\n# define SSL_R_PEER_ERROR_UNSUPPORTED_CERTIFICATE_TYPE    204\n# define SSL_R_PEM_NAME_BAD_PREFIX                        391\n# define SSL_R_PEM_NAME_TOO_SHORT                         392\n# define SSL_R_PRE_MAC_LENGTH_TOO_LONG                    205\n# define SSL_R_PROBLEMS_MAPPING_CIPHER_FUNCTIONS          206\n# define SSL_R_PROTOCOL_IS_SHUTDOWN                       207\n# define SSL_R_PSK_IDENTITY_NOT_FOUND                     223\n# define SSL_R_PSK_NO_CLIENT_CB                           224\n# define SSL_R_PSK_NO_SERVER_CB                           225\n# define SSL_R_PUBLIC_KEY_ENCRYPT_ERROR                   208\n# define SSL_R_PUBLIC_KEY_IS_NOT_RSA                      209\n# define SSL_R_PUBLIC_KEY_NOT_RSA                         210\n# define SSL_R_READ_BIO_NOT_SET                           211\n# define SSL_R_READ_TIMEOUT_EXPIRED                       312\n# define SSL_R_READ_WRONG_PACKET_TYPE                     212\n# define SSL_R_RECORD_LENGTH_MISMATCH                     213\n# define SSL_R_RECORD_TOO_LARGE                           214\n# define SSL_R_RECORD_TOO_SMALL                           298\n# define SSL_R_RENEGOTIATE_EXT_TOO_LONG                   335\n# define SSL_R_RENEGOTIATION_ENCODING_ERR                 336\n# define SSL_R_RENEGOTIATION_MISMATCH                     337\n# define SSL_R_REQUIRED_CIPHER_MISSING                    215\n# define SSL_R_REQUIRED_COMPRESSSION_ALGORITHM_MISSING    342\n# define SSL_R_REUSE_CERT_LENGTH_NOT_ZERO                 216\n# define SSL_R_REUSE_CERT_TYPE_NOT_ZERO                   217\n# define SSL_R_REUSE_CIPHER_LIST_NOT_ZERO                 218\n# define SSL_R_SCSV_RECEIVED_WHEN_RENEGOTIATING           345\n# define SSL_R_SERVERHELLO_TLSEXT                         275\n# define SSL_R_SESSION_ID_CONTEXT_UNINITIALIZED           277\n# define SSL_R_SHORT_READ                                 219\n# define SSL_R_SHUTDOWN_WHILE_IN_INIT                     407\n# define SSL_R_SIGNATURE_ALGORITHMS_ERROR                 360\n# define SSL_R_SIGNATURE_FOR_NON_SIGNING_CERTIFICATE      220\n# define SSL_R_SRP_A_CALC                                 361\n# define SSL_R_SRTP_COULD_NOT_ALLOCATE_PROFILES           362\n# define SSL_R_SRTP_PROTECTION_PROFILE_LIST_TOO_LONG      363\n# define SSL_R_SRTP_UNKNOWN_PROTECTION_PROFILE            364\n# define SSL_R_SSL23_DOING_SESSION_ID_REUSE               221\n# define SSL_R_SSL2_CONNECTION_ID_TOO_LONG                299\n# define SSL_R_SSL3_EXT_INVALID_ECPOINTFORMAT             321\n# define SSL_R_SSL3_EXT_INVALID_SERVERNAME                319\n# define SSL_R_SSL3_EXT_INVALID_SERVERNAME_TYPE           320\n# define SSL_R_SSL3_SESSION_ID_TOO_LONG                   300\n# define SSL_R_SSL3_SESSION_ID_TOO_SHORT                  222\n# define SSL_R_SSLV3_ALERT_BAD_CERTIFICATE                1042\n# define SSL_R_SSLV3_ALERT_BAD_RECORD_MAC                 1020\n# define SSL_R_SSLV3_ALERT_CERTIFICATE_EXPIRED            1045\n# define SSL_R_SSLV3_ALERT_CERTIFICATE_REVOKED            1044\n# define SSL_R_SSLV3_ALERT_CERTIFICATE_UNKNOWN            1046\n# define SSL_R_SSLV3_ALERT_DECOMPRESSION_FAILURE          1030\n# define SSL_R_SSLV3_ALERT_HANDSHAKE_FAILURE              1040\n# define SSL_R_SSLV3_ALERT_ILLEGAL_PARAMETER              1047\n# define SSL_R_SSLV3_ALERT_NO_CERTIFICATE                 1041\n# define SSL_R_SSLV3_ALERT_UNEXPECTED_MESSAGE             1010\n# define SSL_R_SSLV3_ALERT_UNSUPPORTED_CERTIFICATE        1043\n# define SSL_R_SSL_CTX_HAS_NO_DEFAULT_SSL_VERSION         228\n# define SSL_R_SSL_HANDSHAKE_FAILURE                      229\n# define SSL_R_SSL_LIBRARY_HAS_NO_CIPHERS                 230\n# define SSL_R_SSL_SESSION_ID_CALLBACK_FAILED             301\n# define SSL_R_SSL_SESSION_ID_CONFLICT                    302\n# define SSL_R_SSL_SESSION_ID_CONTEXT_TOO_LONG            273\n# define SSL_R_SSL_SESSION_ID_HAS_BAD_LENGTH              303\n# define SSL_R_SSL_SESSION_ID_IS_DIFFERENT                231\n# define SSL_R_TLSV1_ALERT_ACCESS_DENIED                  1049\n# define SSL_R_TLSV1_ALERT_DECODE_ERROR                   1050\n# define SSL_R_TLSV1_ALERT_DECRYPTION_FAILED              1021\n# define SSL_R_TLSV1_ALERT_DECRYPT_ERROR                  1051\n# define SSL_R_TLSV1_ALERT_EXPORT_RESTRICTION             1060\n# define SSL_R_TLSV1_ALERT_INAPPROPRIATE_FALLBACK         1086\n# define SSL_R_TLSV1_ALERT_INSUFFICIENT_SECURITY          1071\n# define SSL_R_TLSV1_ALERT_INTERNAL_ERROR                 1080\n# define SSL_R_TLSV1_ALERT_NO_RENEGOTIATION               1100\n# define SSL_R_TLSV1_ALERT_PROTOCOL_VERSION               1070\n# define SSL_R_TLSV1_ALERT_RECORD_OVERFLOW                1022\n# define SSL_R_TLSV1_ALERT_UNKNOWN_CA                     1048\n# define SSL_R_TLSV1_ALERT_USER_CANCELLED                 1090\n# define SSL_R_TLSV1_BAD_CERTIFICATE_HASH_VALUE           1114\n# define SSL_R_TLSV1_BAD_CERTIFICATE_STATUS_RESPONSE      1113\n# define SSL_R_TLSV1_CERTIFICATE_UNOBTAINABLE             1111\n# define SSL_R_TLSV1_UNRECOGNIZED_NAME                    1112\n# define SSL_R_TLSV1_UNSUPPORTED_EXTENSION                1110\n# define SSL_R_TLS_CLIENT_CERT_REQ_WITH_ANON_CIPHER       232\n# define SSL_R_TLS_HEARTBEAT_PEER_DOESNT_ACCEPT           365\n# define SSL_R_TLS_HEARTBEAT_PENDING                      366\n# define SSL_R_TLS_ILLEGAL_EXPORTER_LABEL                 367\n# define SSL_R_TLS_INVALID_ECPOINTFORMAT_LIST             157\n# define SSL_R_TLS_PEER_DID_NOT_RESPOND_WITH_CERTIFICATE_LIST 233\n# define SSL_R_TLS_RSA_ENCRYPTED_VALUE_LENGTH_IS_WRONG    234\n# define SSL_R_TRIED_TO_USE_UNSUPPORTED_CIPHER            235\n# define SSL_R_UNABLE_TO_DECODE_DH_CERTS                  236\n# define SSL_R_UNABLE_TO_DECODE_ECDH_CERTS                313\n# define SSL_R_UNABLE_TO_EXTRACT_PUBLIC_KEY               237\n# define SSL_R_UNABLE_TO_FIND_DH_PARAMETERS               238\n# define SSL_R_UNABLE_TO_FIND_ECDH_PARAMETERS             314\n# define SSL_R_UNABLE_TO_FIND_PUBLIC_KEY_PARAMETERS       239\n# define SSL_R_UNABLE_TO_FIND_SSL_METHOD                  240\n# define SSL_R_UNABLE_TO_LOAD_SSL2_MD5_ROUTINES           241\n# define SSL_R_UNABLE_TO_LOAD_SSL3_MD5_ROUTINES           242\n# define SSL_R_UNABLE_TO_LOAD_SSL3_SHA1_ROUTINES          243\n# define SSL_R_UNEXPECTED_MESSAGE                         244\n# define SSL_R_UNEXPECTED_RECORD                          245\n# define SSL_R_UNINITIALIZED                              276\n# define SSL_R_UNKNOWN_ALERT_TYPE                         246\n# define SSL_R_UNKNOWN_CERTIFICATE_TYPE                   247\n# define SSL_R_UNKNOWN_CIPHER_RETURNED                    248\n# define SSL_R_UNKNOWN_CIPHER_TYPE                        249\n# define SSL_R_UNKNOWN_CMD_NAME                           386\n# define SSL_R_UNKNOWN_DIGEST                             368\n# define SSL_R_UNKNOWN_KEY_EXCHANGE_TYPE                  250\n# define SSL_R_UNKNOWN_PKEY_TYPE                          251\n# define SSL_R_UNKNOWN_PROTOCOL                           252\n# define SSL_R_UNKNOWN_REMOTE_ERROR_TYPE                  253\n# define SSL_R_UNKNOWN_SSL_VERSION                        254\n# define SSL_R_UNKNOWN_STATE                              255\n# define SSL_R_UNSAFE_LEGACY_RENEGOTIATION_DISABLED       338\n# define SSL_R_UNSUPPORTED_CIPHER                         256\n# define SSL_R_UNSUPPORTED_COMPRESSION_ALGORITHM          257\n# define SSL_R_UNSUPPORTED_DIGEST_TYPE                    326\n# define SSL_R_UNSUPPORTED_ELLIPTIC_CURVE                 315\n# define SSL_R_UNSUPPORTED_PROTOCOL                       258\n# define SSL_R_UNSUPPORTED_SSL_VERSION                    259\n# define SSL_R_UNSUPPORTED_STATUS_TYPE                    329\n# define SSL_R_USE_SRTP_NOT_NEGOTIATED                    369\n# define SSL_R_WRITE_BIO_NOT_SET                          260\n# define SSL_R_WRONG_CERTIFICATE_TYPE                     383\n# define SSL_R_WRONG_CIPHER_RETURNED                      261\n# define SSL_R_WRONG_CURVE                                378\n# define SSL_R_WRONG_MESSAGE_TYPE                         262\n# define SSL_R_WRONG_NUMBER_OF_KEY_BITS                   263\n# define SSL_R_WRONG_SIGNATURE_LENGTH                     264\n# define SSL_R_WRONG_SIGNATURE_SIZE                       265\n# define SSL_R_WRONG_SIGNATURE_TYPE                       370\n# define SSL_R_WRONG_SSL_VERSION                          266\n# define SSL_R_WRONG_VERSION_NUMBER                       267\n# define SSL_R_X509_LIB                                   268\n# define SSL_R_X509_VERIFICATION_SETUP_PROBLEMS           269\n\n#ifdef  __cplusplus\n}\n#endif\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/arm/include/openssl/ssl2.h",
    "content": "/* ssl/ssl2.h */\n/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)\n * All rights reserved.\n *\n * This package is an SSL implementation written\n * by Eric Young (eay@cryptsoft.com).\n * The implementation was written so as to conform with Netscapes SSL.\n *\n * This library is free for commercial and non-commercial use as long as\n * the following conditions are aheared to.  The following conditions\n * apply to all code found in this distribution, be it the RC4, RSA,\n * lhash, DES, etc., code; not just the SSL code.  The SSL documentation\n * included with this distribution is covered by the same copyright terms\n * except that the holder is Tim Hudson (tjh@cryptsoft.com).\n *\n * Copyright remains Eric Young's, and as such any Copyright notices in\n * the code are not to be removed.\n * If this package is used in a product, Eric Young should be given attribution\n * as the author of the parts of the library used.\n * This can be in the form of a textual message at program startup or\n * in documentation (online or textual) provided with the package.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the copyright\n *    notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in the\n *    documentation and/or other materials provided with the distribution.\n * 3. All advertising materials mentioning features or use of this software\n *    must display the following acknowledgement:\n *    \"This product includes cryptographic software written by\n *     Eric Young (eay@cryptsoft.com)\"\n *    The word 'cryptographic' can be left out if the rouines from the library\n *    being used are not cryptographic related :-).\n * 4. If you include any Windows specific code (or a derivative thereof) from\n *    the apps directory (application code) you must include an acknowledgement:\n *    \"This product includes software written by Tim Hudson (tjh@cryptsoft.com)\"\n *\n * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n * SUCH DAMAGE.\n *\n * The licence and distribution terms for any publically available version or\n * derivative of this code cannot be changed.  i.e. this code cannot simply be\n * copied and put under another distribution licence\n * [including the GNU Public Licence.]\n */\n\n#ifndef HEADER_SSL2_H\n# define HEADER_SSL2_H\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n/* Protocol Version Codes */\n# define SSL2_VERSION            0x0002\n# define SSL2_VERSION_MAJOR      0x00\n# define SSL2_VERSION_MINOR      0x02\n/* #define SSL2_CLIENT_VERSION  0x0002 */\n/* #define SSL2_SERVER_VERSION  0x0002 */\n\n/* Protocol Message Codes */\n# define SSL2_MT_ERROR                   0\n# define SSL2_MT_CLIENT_HELLO            1\n# define SSL2_MT_CLIENT_MASTER_KEY       2\n# define SSL2_MT_CLIENT_FINISHED         3\n# define SSL2_MT_SERVER_HELLO            4\n# define SSL2_MT_SERVER_VERIFY           5\n# define SSL2_MT_SERVER_FINISHED         6\n# define SSL2_MT_REQUEST_CERTIFICATE     7\n# define SSL2_MT_CLIENT_CERTIFICATE      8\n\n/* Error Message Codes */\n# define SSL2_PE_UNDEFINED_ERROR         0x0000\n# define SSL2_PE_NO_CIPHER               0x0001\n# define SSL2_PE_NO_CERTIFICATE          0x0002\n# define SSL2_PE_BAD_CERTIFICATE         0x0004\n# define SSL2_PE_UNSUPPORTED_CERTIFICATE_TYPE 0x0006\n\n/* Cipher Kind Values */\n# define SSL2_CK_NULL_WITH_MD5                   0x02000000/* v3 */\n# define SSL2_CK_RC4_128_WITH_MD5                0x02010080\n# define SSL2_CK_RC4_128_EXPORT40_WITH_MD5       0x02020080\n# define SSL2_CK_RC2_128_CBC_WITH_MD5            0x02030080\n# define SSL2_CK_RC2_128_CBC_EXPORT40_WITH_MD5   0x02040080\n# define SSL2_CK_IDEA_128_CBC_WITH_MD5           0x02050080\n# define SSL2_CK_DES_64_CBC_WITH_MD5             0x02060040\n# define SSL2_CK_DES_64_CBC_WITH_SHA             0x02060140/* v3 */\n# define SSL2_CK_DES_192_EDE3_CBC_WITH_MD5       0x020700c0\n# define SSL2_CK_DES_192_EDE3_CBC_WITH_SHA       0x020701c0/* v3 */\n# define SSL2_CK_RC4_64_WITH_MD5                 0x02080080/* MS hack */\n\n# define SSL2_CK_DES_64_CFB64_WITH_MD5_1         0x02ff0800/* SSLeay */\n# define SSL2_CK_NULL                            0x02ff0810/* SSLeay */\n\n# define SSL2_TXT_DES_64_CFB64_WITH_MD5_1        \"DES-CFB-M1\"\n# define SSL2_TXT_NULL_WITH_MD5                  \"NULL-MD5\"\n# define SSL2_TXT_RC4_128_WITH_MD5               \"RC4-MD5\"\n# define SSL2_TXT_RC4_128_EXPORT40_WITH_MD5      \"EXP-RC4-MD5\"\n# define SSL2_TXT_RC2_128_CBC_WITH_MD5           \"RC2-CBC-MD5\"\n# define SSL2_TXT_RC2_128_CBC_EXPORT40_WITH_MD5  \"EXP-RC2-CBC-MD5\"\n# define SSL2_TXT_IDEA_128_CBC_WITH_MD5          \"IDEA-CBC-MD5\"\n# define SSL2_TXT_DES_64_CBC_WITH_MD5            \"DES-CBC-MD5\"\n# define SSL2_TXT_DES_64_CBC_WITH_SHA            \"DES-CBC-SHA\"\n# define SSL2_TXT_DES_192_EDE3_CBC_WITH_MD5      \"DES-CBC3-MD5\"\n# define SSL2_TXT_DES_192_EDE3_CBC_WITH_SHA      \"DES-CBC3-SHA\"\n# define SSL2_TXT_RC4_64_WITH_MD5                \"RC4-64-MD5\"\n\n# define SSL2_TXT_NULL                           \"NULL\"\n\n/* Flags for the SSL_CIPHER.algorithm2 field */\n# define SSL2_CF_5_BYTE_ENC                      0x01\n# define SSL2_CF_8_BYTE_ENC                      0x02\n\n/* Certificate Type Codes */\n# define SSL2_CT_X509_CERTIFICATE                0x01\n\n/* Authentication Type Code */\n# define SSL2_AT_MD5_WITH_RSA_ENCRYPTION         0x01\n\n# define SSL2_MAX_SSL_SESSION_ID_LENGTH          32\n\n/* Upper/Lower Bounds */\n# define SSL2_MAX_MASTER_KEY_LENGTH_IN_BITS      256\n# ifdef OPENSSL_SYS_MPE\n#  define SSL2_MAX_RECORD_LENGTH_2_BYTE_HEADER    29998u\n# else\n#  define SSL2_MAX_RECORD_LENGTH_2_BYTE_HEADER    32767u\n                                                       /* 2^15-1 */\n# endif\n# define SSL2_MAX_RECORD_LENGTH_3_BYTE_HEADER    16383/* 2^14-1 */\n\n# define SSL2_CHALLENGE_LENGTH   16\n/*\n * #define SSL2_CHALLENGE_LENGTH 32\n */\n# define SSL2_MIN_CHALLENGE_LENGTH       16\n# define SSL2_MAX_CHALLENGE_LENGTH       32\n# define SSL2_CONNECTION_ID_LENGTH       16\n# define SSL2_MAX_CONNECTION_ID_LENGTH   16\n# define SSL2_SSL_SESSION_ID_LENGTH      16\n# define SSL2_MAX_CERT_CHALLENGE_LENGTH  32\n# define SSL2_MIN_CERT_CHALLENGE_LENGTH  16\n# define SSL2_MAX_KEY_MATERIAL_LENGTH    24\n\n# ifndef HEADER_SSL_LOCL_H\n#  define  CERT           char\n# endif\n\n# ifndef OPENSSL_NO_SSL_INTERN\n\ntypedef struct ssl2_state_st {\n    int three_byte_header;\n    int clear_text;             /* clear text */\n    int escape;                 /* not used in SSLv2 */\n    int ssl2_rollback;          /* used if SSLv23 rolled back to SSLv2 */\n    /*\n     * non-blocking io info, used to make sure the same args were passwd\n     */\n    unsigned int wnum;          /* number of bytes sent so far */\n    int wpend_tot;\n    const unsigned char *wpend_buf;\n    int wpend_off;              /* offset to data to write */\n    int wpend_len;              /* number of bytes passwd to write */\n    int wpend_ret;              /* number of bytes to return to caller */\n    /* buffer raw data */\n    int rbuf_left;\n    int rbuf_offs;\n    unsigned char *rbuf;\n    unsigned char *wbuf;\n    unsigned char *write_ptr;   /* used to point to the start due to 2/3 byte\n                                 * header. */\n    unsigned int padding;\n    unsigned int rlength;       /* passed to ssl2_enc */\n    int ract_data_length;       /* Set when things are encrypted. */\n    unsigned int wlength;       /* passed to ssl2_enc */\n    int wact_data_length;       /* Set when things are decrypted. */\n    unsigned char *ract_data;\n    unsigned char *wact_data;\n    unsigned char *mac_data;\n    unsigned char *read_key;\n    unsigned char *write_key;\n    /* Stuff specifically to do with this SSL session */\n    unsigned int challenge_length;\n    unsigned char challenge[SSL2_MAX_CHALLENGE_LENGTH];\n    unsigned int conn_id_length;\n    unsigned char conn_id[SSL2_MAX_CONNECTION_ID_LENGTH];\n    unsigned int key_material_length;\n    unsigned char key_material[SSL2_MAX_KEY_MATERIAL_LENGTH * 2];\n    unsigned long read_sequence;\n    unsigned long write_sequence;\n    struct {\n        unsigned int conn_id_length;\n        unsigned int cert_type;\n        unsigned int cert_length;\n        unsigned int csl;\n        unsigned int clear;\n        unsigned int enc;\n        unsigned char ccl[SSL2_MAX_CERT_CHALLENGE_LENGTH];\n        unsigned int cipher_spec_length;\n        unsigned int session_id_length;\n        unsigned int clen;\n        unsigned int rlen;\n    } tmp;\n} SSL2_STATE;\n\n# endif\n\n/* SSLv2 */\n/* client */\n# define SSL2_ST_SEND_CLIENT_HELLO_A             (0x10|SSL_ST_CONNECT)\n# define SSL2_ST_SEND_CLIENT_HELLO_B             (0x11|SSL_ST_CONNECT)\n# define SSL2_ST_GET_SERVER_HELLO_A              (0x20|SSL_ST_CONNECT)\n# define SSL2_ST_GET_SERVER_HELLO_B              (0x21|SSL_ST_CONNECT)\n# define SSL2_ST_SEND_CLIENT_MASTER_KEY_A        (0x30|SSL_ST_CONNECT)\n# define SSL2_ST_SEND_CLIENT_MASTER_KEY_B        (0x31|SSL_ST_CONNECT)\n# define SSL2_ST_SEND_CLIENT_FINISHED_A          (0x40|SSL_ST_CONNECT)\n# define SSL2_ST_SEND_CLIENT_FINISHED_B          (0x41|SSL_ST_CONNECT)\n# define SSL2_ST_SEND_CLIENT_CERTIFICATE_A       (0x50|SSL_ST_CONNECT)\n# define SSL2_ST_SEND_CLIENT_CERTIFICATE_B       (0x51|SSL_ST_CONNECT)\n# define SSL2_ST_SEND_CLIENT_CERTIFICATE_C       (0x52|SSL_ST_CONNECT)\n# define SSL2_ST_SEND_CLIENT_CERTIFICATE_D       (0x53|SSL_ST_CONNECT)\n# define SSL2_ST_GET_SERVER_VERIFY_A             (0x60|SSL_ST_CONNECT)\n# define SSL2_ST_GET_SERVER_VERIFY_B             (0x61|SSL_ST_CONNECT)\n# define SSL2_ST_GET_SERVER_FINISHED_A           (0x70|SSL_ST_CONNECT)\n# define SSL2_ST_GET_SERVER_FINISHED_B           (0x71|SSL_ST_CONNECT)\n# define SSL2_ST_CLIENT_START_ENCRYPTION         (0x80|SSL_ST_CONNECT)\n# define SSL2_ST_X509_GET_CLIENT_CERTIFICATE     (0x90|SSL_ST_CONNECT)\n/* server */\n# define SSL2_ST_GET_CLIENT_HELLO_A              (0x10|SSL_ST_ACCEPT)\n# define SSL2_ST_GET_CLIENT_HELLO_B              (0x11|SSL_ST_ACCEPT)\n# define SSL2_ST_GET_CLIENT_HELLO_C              (0x12|SSL_ST_ACCEPT)\n# define SSL2_ST_SEND_SERVER_HELLO_A             (0x20|SSL_ST_ACCEPT)\n# define SSL2_ST_SEND_SERVER_HELLO_B             (0x21|SSL_ST_ACCEPT)\n# define SSL2_ST_GET_CLIENT_MASTER_KEY_A         (0x30|SSL_ST_ACCEPT)\n# define SSL2_ST_GET_CLIENT_MASTER_KEY_B         (0x31|SSL_ST_ACCEPT)\n# define SSL2_ST_SEND_SERVER_VERIFY_A            (0x40|SSL_ST_ACCEPT)\n# define SSL2_ST_SEND_SERVER_VERIFY_B            (0x41|SSL_ST_ACCEPT)\n# define SSL2_ST_SEND_SERVER_VERIFY_C            (0x42|SSL_ST_ACCEPT)\n# define SSL2_ST_GET_CLIENT_FINISHED_A           (0x50|SSL_ST_ACCEPT)\n# define SSL2_ST_GET_CLIENT_FINISHED_B           (0x51|SSL_ST_ACCEPT)\n# define SSL2_ST_SEND_SERVER_FINISHED_A          (0x60|SSL_ST_ACCEPT)\n# define SSL2_ST_SEND_SERVER_FINISHED_B          (0x61|SSL_ST_ACCEPT)\n# define SSL2_ST_SEND_REQUEST_CERTIFICATE_A      (0x70|SSL_ST_ACCEPT)\n# define SSL2_ST_SEND_REQUEST_CERTIFICATE_B      (0x71|SSL_ST_ACCEPT)\n# define SSL2_ST_SEND_REQUEST_CERTIFICATE_C      (0x72|SSL_ST_ACCEPT)\n# define SSL2_ST_SEND_REQUEST_CERTIFICATE_D      (0x73|SSL_ST_ACCEPT)\n# define SSL2_ST_SERVER_START_ENCRYPTION         (0x80|SSL_ST_ACCEPT)\n# define SSL2_ST_X509_GET_SERVER_CERTIFICATE     (0x90|SSL_ST_ACCEPT)\n\n#ifdef  __cplusplus\n}\n#endif\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/arm/include/openssl/ssl23.h",
    "content": "/* ssl/ssl23.h */\n/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)\n * All rights reserved.\n *\n * This package is an SSL implementation written\n * by Eric Young (eay@cryptsoft.com).\n * The implementation was written so as to conform with Netscapes SSL.\n *\n * This library is free for commercial and non-commercial use as long as\n * the following conditions are aheared to.  The following conditions\n * apply to all code found in this distribution, be it the RC4, RSA,\n * lhash, DES, etc., code; not just the SSL code.  The SSL documentation\n * included with this distribution is covered by the same copyright terms\n * except that the holder is Tim Hudson (tjh@cryptsoft.com).\n *\n * Copyright remains Eric Young's, and as such any Copyright notices in\n * the code are not to be removed.\n * If this package is used in a product, Eric Young should be given attribution\n * as the author of the parts of the library used.\n * This can be in the form of a textual message at program startup or\n * in documentation (online or textual) provided with the package.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the copyright\n *    notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in the\n *    documentation and/or other materials provided with the distribution.\n * 3. All advertising materials mentioning features or use of this software\n *    must display the following acknowledgement:\n *    \"This product includes cryptographic software written by\n *     Eric Young (eay@cryptsoft.com)\"\n *    The word 'cryptographic' can be left out if the rouines from the library\n *    being used are not cryptographic related :-).\n * 4. If you include any Windows specific code (or a derivative thereof) from\n *    the apps directory (application code) you must include an acknowledgement:\n *    \"This product includes software written by Tim Hudson (tjh@cryptsoft.com)\"\n *\n * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n * SUCH DAMAGE.\n *\n * The licence and distribution terms for any publically available version or\n * derivative of this code cannot be changed.  i.e. this code cannot simply be\n * copied and put under another distribution licence\n * [including the GNU Public Licence.]\n */\n\n#ifndef HEADER_SSL23_H\n# define HEADER_SSL23_H\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n/*\n * client\n */\n/* write to server */\n# define SSL23_ST_CW_CLNT_HELLO_A        (0x210|SSL_ST_CONNECT)\n# define SSL23_ST_CW_CLNT_HELLO_B        (0x211|SSL_ST_CONNECT)\n/* read from server */\n# define SSL23_ST_CR_SRVR_HELLO_A        (0x220|SSL_ST_CONNECT)\n# define SSL23_ST_CR_SRVR_HELLO_B        (0x221|SSL_ST_CONNECT)\n\n/* server */\n/* read from client */\n# define SSL23_ST_SR_CLNT_HELLO_A        (0x210|SSL_ST_ACCEPT)\n# define SSL23_ST_SR_CLNT_HELLO_B        (0x211|SSL_ST_ACCEPT)\n\n#ifdef  __cplusplus\n}\n#endif\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/arm/include/openssl/ssl3.h",
    "content": "/* ssl/ssl3.h */\n/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)\n * All rights reserved.\n *\n * This package is an SSL implementation written\n * by Eric Young (eay@cryptsoft.com).\n * The implementation was written so as to conform with Netscapes SSL.\n *\n * This library is free for commercial and non-commercial use as long as\n * the following conditions are aheared to.  The following conditions\n * apply to all code found in this distribution, be it the RC4, RSA,\n * lhash, DES, etc., code; not just the SSL code.  The SSL documentation\n * included with this distribution is covered by the same copyright terms\n * except that the holder is Tim Hudson (tjh@cryptsoft.com).\n *\n * Copyright remains Eric Young's, and as such any Copyright notices in\n * the code are not to be removed.\n * If this package is used in a product, Eric Young should be given attribution\n * as the author of the parts of the library used.\n * This can be in the form of a textual message at program startup or\n * in documentation (online or textual) provided with the package.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the copyright\n *    notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in the\n *    documentation and/or other materials provided with the distribution.\n * 3. All advertising materials mentioning features or use of this software\n *    must display the following acknowledgement:\n *    \"This product includes cryptographic software written by\n *     Eric Young (eay@cryptsoft.com)\"\n *    The word 'cryptographic' can be left out if the rouines from the library\n *    being used are not cryptographic related :-).\n * 4. If you include any Windows specific code (or a derivative thereof) from\n *    the apps directory (application code) you must include an acknowledgement:\n *    \"This product includes software written by Tim Hudson (tjh@cryptsoft.com)\"\n *\n * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n * SUCH DAMAGE.\n *\n * The licence and distribution terms for any publically available version or\n * derivative of this code cannot be changed.  i.e. this code cannot simply be\n * copied and put under another distribution licence\n * [including the GNU Public Licence.]\n */\n/* ====================================================================\n * Copyright (c) 1998-2002 The OpenSSL Project.  All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n *\n * 1. Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n *\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in\n *    the documentation and/or other materials provided with the\n *    distribution.\n *\n * 3. All advertising materials mentioning features or use of this\n *    software must display the following acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit. (http://www.openssl.org/)\"\n *\n * 4. The names \"OpenSSL Toolkit\" and \"OpenSSL Project\" must not be used to\n *    endorse or promote products derived from this software without\n *    prior written permission. For written permission, please contact\n *    openssl-core@openssl.org.\n *\n * 5. Products derived from this software may not be called \"OpenSSL\"\n *    nor may \"OpenSSL\" appear in their names without prior written\n *    permission of the OpenSSL Project.\n *\n * 6. Redistributions of any form whatsoever must retain the following\n *    acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit (http://www.openssl.org/)\"\n *\n * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY\n * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\n * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR\n * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\n * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,\n * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED\n * OF THE POSSIBILITY OF SUCH DAMAGE.\n * ====================================================================\n *\n * This product includes cryptographic software written by Eric Young\n * (eay@cryptsoft.com).  This product includes software written by Tim\n * Hudson (tjh@cryptsoft.com).\n *\n */\n/* ====================================================================\n * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED.\n * ECC cipher suite support in OpenSSL originally developed by\n * SUN MICROSYSTEMS, INC., and contributed to the OpenSSL project.\n */\n\n#ifndef HEADER_SSL3_H\n# define HEADER_SSL3_H\n\n# ifndef OPENSSL_NO_COMP\n#  include <openssl/comp.h>\n# endif\n# include <openssl/buffer.h>\n# include <openssl/evp.h>\n# include <openssl/ssl.h>\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n/*\n * Signalling cipher suite value from RFC 5746\n * (TLS_EMPTY_RENEGOTIATION_INFO_SCSV)\n */\n# define SSL3_CK_SCSV                            0x030000FF\n\n/*\n * Signalling cipher suite value from draft-ietf-tls-downgrade-scsv-00\n * (TLS_FALLBACK_SCSV)\n */\n# define SSL3_CK_FALLBACK_SCSV                   0x03005600\n\n# define SSL3_CK_RSA_NULL_MD5                    0x03000001\n# define SSL3_CK_RSA_NULL_SHA                    0x03000002\n# define SSL3_CK_RSA_RC4_40_MD5                  0x03000003\n# define SSL3_CK_RSA_RC4_128_MD5                 0x03000004\n# define SSL3_CK_RSA_RC4_128_SHA                 0x03000005\n# define SSL3_CK_RSA_RC2_40_MD5                  0x03000006\n# define SSL3_CK_RSA_IDEA_128_SHA                0x03000007\n# define SSL3_CK_RSA_DES_40_CBC_SHA              0x03000008\n# define SSL3_CK_RSA_DES_64_CBC_SHA              0x03000009\n# define SSL3_CK_RSA_DES_192_CBC3_SHA            0x0300000A\n\n# define SSL3_CK_DH_DSS_DES_40_CBC_SHA           0x0300000B\n# define SSL3_CK_DH_DSS_DES_64_CBC_SHA           0x0300000C\n# define SSL3_CK_DH_DSS_DES_192_CBC3_SHA         0x0300000D\n# define SSL3_CK_DH_RSA_DES_40_CBC_SHA           0x0300000E\n# define SSL3_CK_DH_RSA_DES_64_CBC_SHA           0x0300000F\n# define SSL3_CK_DH_RSA_DES_192_CBC3_SHA         0x03000010\n\n# define SSL3_CK_EDH_DSS_DES_40_CBC_SHA          0x03000011\n# define SSL3_CK_DHE_DSS_DES_40_CBC_SHA          SSL3_CK_EDH_DSS_DES_40_CBC_SHA\n# define SSL3_CK_EDH_DSS_DES_64_CBC_SHA          0x03000012\n# define SSL3_CK_DHE_DSS_DES_64_CBC_SHA          SSL3_CK_EDH_DSS_DES_64_CBC_SHA\n# define SSL3_CK_EDH_DSS_DES_192_CBC3_SHA        0x03000013\n# define SSL3_CK_DHE_DSS_DES_192_CBC3_SHA        SSL3_CK_EDH_DSS_DES_192_CBC3_SHA\n# define SSL3_CK_EDH_RSA_DES_40_CBC_SHA          0x03000014\n# define SSL3_CK_DHE_RSA_DES_40_CBC_SHA          SSL3_CK_EDH_RSA_DES_40_CBC_SHA\n# define SSL3_CK_EDH_RSA_DES_64_CBC_SHA          0x03000015\n# define SSL3_CK_DHE_RSA_DES_64_CBC_SHA          SSL3_CK_EDH_RSA_DES_64_CBC_SHA\n# define SSL3_CK_EDH_RSA_DES_192_CBC3_SHA        0x03000016\n# define SSL3_CK_DHE_RSA_DES_192_CBC3_SHA        SSL3_CK_EDH_RSA_DES_192_CBC3_SHA\n\n# define SSL3_CK_ADH_RC4_40_MD5                  0x03000017\n# define SSL3_CK_ADH_RC4_128_MD5                 0x03000018\n# define SSL3_CK_ADH_DES_40_CBC_SHA              0x03000019\n# define SSL3_CK_ADH_DES_64_CBC_SHA              0x0300001A\n# define SSL3_CK_ADH_DES_192_CBC_SHA             0x0300001B\n\n# if 0\n#  define SSL3_CK_FZA_DMS_NULL_SHA                0x0300001C\n#  define SSL3_CK_FZA_DMS_FZA_SHA                 0x0300001D\n#  if 0                         /* Because it clashes with KRB5, is never\n                                 * used any more, and is safe to remove\n                                 * according to David Hopwood\n                                 * <david.hopwood@zetnet.co.uk> of the\n                                 * ietf-tls list */\n#   define SSL3_CK_FZA_DMS_RC4_SHA                 0x0300001E\n#  endif\n# endif\n\n/*\n * VRS Additional Kerberos5 entries\n */\n# define SSL3_CK_KRB5_DES_64_CBC_SHA             0x0300001E\n# define SSL3_CK_KRB5_DES_192_CBC3_SHA           0x0300001F\n# define SSL3_CK_KRB5_RC4_128_SHA                0x03000020\n# define SSL3_CK_KRB5_IDEA_128_CBC_SHA           0x03000021\n# define SSL3_CK_KRB5_DES_64_CBC_MD5             0x03000022\n# define SSL3_CK_KRB5_DES_192_CBC3_MD5           0x03000023\n# define SSL3_CK_KRB5_RC4_128_MD5                0x03000024\n# define SSL3_CK_KRB5_IDEA_128_CBC_MD5           0x03000025\n\n# define SSL3_CK_KRB5_DES_40_CBC_SHA             0x03000026\n# define SSL3_CK_KRB5_RC2_40_CBC_SHA             0x03000027\n# define SSL3_CK_KRB5_RC4_40_SHA                 0x03000028\n# define SSL3_CK_KRB5_DES_40_CBC_MD5             0x03000029\n# define SSL3_CK_KRB5_RC2_40_CBC_MD5             0x0300002A\n# define SSL3_CK_KRB5_RC4_40_MD5                 0x0300002B\n\n# define SSL3_TXT_RSA_NULL_MD5                   \"NULL-MD5\"\n# define SSL3_TXT_RSA_NULL_SHA                   \"NULL-SHA\"\n# define SSL3_TXT_RSA_RC4_40_MD5                 \"EXP-RC4-MD5\"\n# define SSL3_TXT_RSA_RC4_128_MD5                \"RC4-MD5\"\n# define SSL3_TXT_RSA_RC4_128_SHA                \"RC4-SHA\"\n# define SSL3_TXT_RSA_RC2_40_MD5                 \"EXP-RC2-CBC-MD5\"\n# define SSL3_TXT_RSA_IDEA_128_SHA               \"IDEA-CBC-SHA\"\n# define SSL3_TXT_RSA_DES_40_CBC_SHA             \"EXP-DES-CBC-SHA\"\n# define SSL3_TXT_RSA_DES_64_CBC_SHA             \"DES-CBC-SHA\"\n# define SSL3_TXT_RSA_DES_192_CBC3_SHA           \"DES-CBC3-SHA\"\n\n# define SSL3_TXT_DH_DSS_DES_40_CBC_SHA          \"EXP-DH-DSS-DES-CBC-SHA\"\n# define SSL3_TXT_DH_DSS_DES_64_CBC_SHA          \"DH-DSS-DES-CBC-SHA\"\n# define SSL3_TXT_DH_DSS_DES_192_CBC3_SHA        \"DH-DSS-DES-CBC3-SHA\"\n# define SSL3_TXT_DH_RSA_DES_40_CBC_SHA          \"EXP-DH-RSA-DES-CBC-SHA\"\n# define SSL3_TXT_DH_RSA_DES_64_CBC_SHA          \"DH-RSA-DES-CBC-SHA\"\n# define SSL3_TXT_DH_RSA_DES_192_CBC3_SHA        \"DH-RSA-DES-CBC3-SHA\"\n\n# define SSL3_TXT_DHE_DSS_DES_40_CBC_SHA         \"EXP-DHE-DSS-DES-CBC-SHA\"\n# define SSL3_TXT_DHE_DSS_DES_64_CBC_SHA         \"DHE-DSS-DES-CBC-SHA\"\n# define SSL3_TXT_DHE_DSS_DES_192_CBC3_SHA       \"DHE-DSS-DES-CBC3-SHA\"\n# define SSL3_TXT_DHE_RSA_DES_40_CBC_SHA         \"EXP-DHE-RSA-DES-CBC-SHA\"\n# define SSL3_TXT_DHE_RSA_DES_64_CBC_SHA         \"DHE-RSA-DES-CBC-SHA\"\n# define SSL3_TXT_DHE_RSA_DES_192_CBC3_SHA       \"DHE-RSA-DES-CBC3-SHA\"\n\n/*\n * This next block of six \"EDH\" labels is for backward compatibility with\n * older versions of OpenSSL.  New code should use the six \"DHE\" labels above\n * instead:\n */\n# define SSL3_TXT_EDH_DSS_DES_40_CBC_SHA         \"EXP-EDH-DSS-DES-CBC-SHA\"\n# define SSL3_TXT_EDH_DSS_DES_64_CBC_SHA         \"EDH-DSS-DES-CBC-SHA\"\n# define SSL3_TXT_EDH_DSS_DES_192_CBC3_SHA       \"EDH-DSS-DES-CBC3-SHA\"\n# define SSL3_TXT_EDH_RSA_DES_40_CBC_SHA         \"EXP-EDH-RSA-DES-CBC-SHA\"\n# define SSL3_TXT_EDH_RSA_DES_64_CBC_SHA         \"EDH-RSA-DES-CBC-SHA\"\n# define SSL3_TXT_EDH_RSA_DES_192_CBC3_SHA       \"EDH-RSA-DES-CBC3-SHA\"\n\n# define SSL3_TXT_ADH_RC4_40_MD5                 \"EXP-ADH-RC4-MD5\"\n# define SSL3_TXT_ADH_RC4_128_MD5                \"ADH-RC4-MD5\"\n# define SSL3_TXT_ADH_DES_40_CBC_SHA             \"EXP-ADH-DES-CBC-SHA\"\n# define SSL3_TXT_ADH_DES_64_CBC_SHA             \"ADH-DES-CBC-SHA\"\n# define SSL3_TXT_ADH_DES_192_CBC_SHA            \"ADH-DES-CBC3-SHA\"\n\n# if 0\n#  define SSL3_TXT_FZA_DMS_NULL_SHA               \"FZA-NULL-SHA\"\n#  define SSL3_TXT_FZA_DMS_FZA_SHA                \"FZA-FZA-CBC-SHA\"\n#  define SSL3_TXT_FZA_DMS_RC4_SHA                \"FZA-RC4-SHA\"\n# endif\n\n# define SSL3_TXT_KRB5_DES_64_CBC_SHA            \"KRB5-DES-CBC-SHA\"\n# define SSL3_TXT_KRB5_DES_192_CBC3_SHA          \"KRB5-DES-CBC3-SHA\"\n# define SSL3_TXT_KRB5_RC4_128_SHA               \"KRB5-RC4-SHA\"\n# define SSL3_TXT_KRB5_IDEA_128_CBC_SHA          \"KRB5-IDEA-CBC-SHA\"\n# define SSL3_TXT_KRB5_DES_64_CBC_MD5            \"KRB5-DES-CBC-MD5\"\n# define SSL3_TXT_KRB5_DES_192_CBC3_MD5          \"KRB5-DES-CBC3-MD5\"\n# define SSL3_TXT_KRB5_RC4_128_MD5               \"KRB5-RC4-MD5\"\n# define SSL3_TXT_KRB5_IDEA_128_CBC_MD5          \"KRB5-IDEA-CBC-MD5\"\n\n# define SSL3_TXT_KRB5_DES_40_CBC_SHA            \"EXP-KRB5-DES-CBC-SHA\"\n# define SSL3_TXT_KRB5_RC2_40_CBC_SHA            \"EXP-KRB5-RC2-CBC-SHA\"\n# define SSL3_TXT_KRB5_RC4_40_SHA                \"EXP-KRB5-RC4-SHA\"\n# define SSL3_TXT_KRB5_DES_40_CBC_MD5            \"EXP-KRB5-DES-CBC-MD5\"\n# define SSL3_TXT_KRB5_RC2_40_CBC_MD5            \"EXP-KRB5-RC2-CBC-MD5\"\n# define SSL3_TXT_KRB5_RC4_40_MD5                \"EXP-KRB5-RC4-MD5\"\n\n# define SSL3_SSL_SESSION_ID_LENGTH              32\n# define SSL3_MAX_SSL_SESSION_ID_LENGTH          32\n\n# define SSL3_MASTER_SECRET_SIZE                 48\n# define SSL3_RANDOM_SIZE                        32\n# define SSL3_SESSION_ID_SIZE                    32\n# define SSL3_RT_HEADER_LENGTH                   5\n\n# define SSL3_HM_HEADER_LENGTH                  4\n\n# ifndef SSL3_ALIGN_PAYLOAD\n /*\n  * Some will argue that this increases memory footprint, but it's not\n  * actually true. Point is that malloc has to return at least 64-bit aligned\n  * pointers, meaning that allocating 5 bytes wastes 3 bytes in either case.\n  * Suggested pre-gaping simply moves these wasted bytes from the end of\n  * allocated region to its front, but makes data payload aligned, which\n  * improves performance:-)\n  */\n#  define SSL3_ALIGN_PAYLOAD                     8\n# else\n#  if (SSL3_ALIGN_PAYLOAD&(SSL3_ALIGN_PAYLOAD-1))!=0\n#   error \"insane SSL3_ALIGN_PAYLOAD\"\n#   undef SSL3_ALIGN_PAYLOAD\n#  endif\n# endif\n\n/*\n * This is the maximum MAC (digest) size used by the SSL library. Currently\n * maximum of 20 is used by SHA1, but we reserve for future extension for\n * 512-bit hashes.\n */\n\n# define SSL3_RT_MAX_MD_SIZE                     64\n\n/*\n * Maximum block size used in all ciphersuites. Currently 16 for AES.\n */\n\n# define SSL_RT_MAX_CIPHER_BLOCK_SIZE            16\n\n# define SSL3_RT_MAX_EXTRA                       (16384)\n\n/* Maximum plaintext length: defined by SSL/TLS standards */\n# define SSL3_RT_MAX_PLAIN_LENGTH                16384\n/* Maximum compression overhead: defined by SSL/TLS standards */\n# define SSL3_RT_MAX_COMPRESSED_OVERHEAD         1024\n\n/*\n * The standards give a maximum encryption overhead of 1024 bytes. In\n * practice the value is lower than this. The overhead is the maximum number\n * of padding bytes (256) plus the mac size.\n */\n# define SSL3_RT_MAX_ENCRYPTED_OVERHEAD  (256 + SSL3_RT_MAX_MD_SIZE)\n\n/*\n * OpenSSL currently only uses a padding length of at most one block so the\n * send overhead is smaller.\n */\n\n# define SSL3_RT_SEND_MAX_ENCRYPTED_OVERHEAD \\\n                        (SSL_RT_MAX_CIPHER_BLOCK_SIZE + SSL3_RT_MAX_MD_SIZE)\n\n/* If compression isn't used don't include the compression overhead */\n\n# ifdef OPENSSL_NO_COMP\n#  define SSL3_RT_MAX_COMPRESSED_LENGTH           SSL3_RT_MAX_PLAIN_LENGTH\n# else\n#  define SSL3_RT_MAX_COMPRESSED_LENGTH   \\\n                (SSL3_RT_MAX_PLAIN_LENGTH+SSL3_RT_MAX_COMPRESSED_OVERHEAD)\n# endif\n# define SSL3_RT_MAX_ENCRYPTED_LENGTH    \\\n                (SSL3_RT_MAX_ENCRYPTED_OVERHEAD+SSL3_RT_MAX_COMPRESSED_LENGTH)\n# define SSL3_RT_MAX_PACKET_SIZE         \\\n                (SSL3_RT_MAX_ENCRYPTED_LENGTH+SSL3_RT_HEADER_LENGTH)\n\n# define SSL3_MD_CLIENT_FINISHED_CONST   \"\\x43\\x4C\\x4E\\x54\"\n# define SSL3_MD_SERVER_FINISHED_CONST   \"\\x53\\x52\\x56\\x52\"\n\n# define SSL3_VERSION                    0x0300\n# define SSL3_VERSION_MAJOR              0x03\n# define SSL3_VERSION_MINOR              0x00\n\n# define SSL3_RT_CHANGE_CIPHER_SPEC      20\n# define SSL3_RT_ALERT                   21\n# define SSL3_RT_HANDSHAKE               22\n# define SSL3_RT_APPLICATION_DATA        23\n# define TLS1_RT_HEARTBEAT               24\n\n/* Pseudo content types to indicate additional parameters */\n# define TLS1_RT_CRYPTO                  0x1000\n# define TLS1_RT_CRYPTO_PREMASTER        (TLS1_RT_CRYPTO | 0x1)\n# define TLS1_RT_CRYPTO_CLIENT_RANDOM    (TLS1_RT_CRYPTO | 0x2)\n# define TLS1_RT_CRYPTO_SERVER_RANDOM    (TLS1_RT_CRYPTO | 0x3)\n# define TLS1_RT_CRYPTO_MASTER           (TLS1_RT_CRYPTO | 0x4)\n\n# define TLS1_RT_CRYPTO_READ             0x0000\n# define TLS1_RT_CRYPTO_WRITE            0x0100\n# define TLS1_RT_CRYPTO_MAC              (TLS1_RT_CRYPTO | 0x5)\n# define TLS1_RT_CRYPTO_KEY              (TLS1_RT_CRYPTO | 0x6)\n# define TLS1_RT_CRYPTO_IV               (TLS1_RT_CRYPTO | 0x7)\n# define TLS1_RT_CRYPTO_FIXED_IV         (TLS1_RT_CRYPTO | 0x8)\n\n/* Pseudo content type for SSL/TLS header info */\n# define SSL3_RT_HEADER                  0x100\n\n# define SSL3_AL_WARNING                 1\n# define SSL3_AL_FATAL                   2\n\n# define SSL3_AD_CLOSE_NOTIFY             0\n# define SSL3_AD_UNEXPECTED_MESSAGE      10/* fatal */\n# define SSL3_AD_BAD_RECORD_MAC          20/* fatal */\n# define SSL3_AD_DECOMPRESSION_FAILURE   30/* fatal */\n# define SSL3_AD_HANDSHAKE_FAILURE       40/* fatal */\n# define SSL3_AD_NO_CERTIFICATE          41\n# define SSL3_AD_BAD_CERTIFICATE         42\n# define SSL3_AD_UNSUPPORTED_CERTIFICATE 43\n# define SSL3_AD_CERTIFICATE_REVOKED     44\n# define SSL3_AD_CERTIFICATE_EXPIRED     45\n# define SSL3_AD_CERTIFICATE_UNKNOWN     46\n# define SSL3_AD_ILLEGAL_PARAMETER       47/* fatal */\n\n# define TLS1_HB_REQUEST         1\n# define TLS1_HB_RESPONSE        2\n\n# ifndef OPENSSL_NO_SSL_INTERN\n\ntypedef struct ssl3_record_st {\n    /* type of record */\n    /*\n     * r\n     */ int type;\n    /* How many bytes available */\n    /*\n     * rw\n     */ unsigned int length;\n    /* read/write offset into 'buf' */\n    /*\n     * r\n     */ unsigned int off;\n    /* pointer to the record data */\n    /*\n     * rw\n     */ unsigned char *data;\n    /* where the decode bytes are */\n    /*\n     * rw\n     */ unsigned char *input;\n    /* only used with decompression - malloc()ed */\n    /*\n     * r\n     */ unsigned char *comp;\n    /* epoch number, needed by DTLS1 */\n    /*\n     * r\n     */ unsigned long epoch;\n    /* sequence number, needed by DTLS1 */\n    /*\n     * r\n     */ unsigned char seq_num[8];\n} SSL3_RECORD;\n\ntypedef struct ssl3_buffer_st {\n    /* at least SSL3_RT_MAX_PACKET_SIZE bytes, see ssl3_setup_buffers() */\n    unsigned char *buf;\n    /* buffer size */\n    size_t len;\n    /* where to 'copy from' */\n    int offset;\n    /* how many bytes left */\n    int left;\n} SSL3_BUFFER;\n\n# endif\n\n# define SSL3_CT_RSA_SIGN                        1\n# define SSL3_CT_DSS_SIGN                        2\n# define SSL3_CT_RSA_FIXED_DH                    3\n# define SSL3_CT_DSS_FIXED_DH                    4\n# define SSL3_CT_RSA_EPHEMERAL_DH                5\n# define SSL3_CT_DSS_EPHEMERAL_DH                6\n# define SSL3_CT_FORTEZZA_DMS                    20\n/*\n * SSL3_CT_NUMBER is used to size arrays and it must be large enough to\n * contain all of the cert types defined either for SSLv3 and TLSv1.\n */\n# define SSL3_CT_NUMBER                  9\n\n# define SSL3_FLAGS_NO_RENEGOTIATE_CIPHERS       0x0001\n# define SSL3_FLAGS_DELAY_CLIENT_FINISHED        0x0002\n# define SSL3_FLAGS_POP_BUFFER                   0x0004\n# define TLS1_FLAGS_TLS_PADDING_BUG              0x0008\n# define TLS1_FLAGS_SKIP_CERT_VERIFY             0x0010\n# define TLS1_FLAGS_KEEP_HANDSHAKE               0x0020\n/*\n * Set when the handshake is ready to process peer's ChangeCipherSpec message.\n * Cleared after the message has been processed.\n */\n# define SSL3_FLAGS_CCS_OK                       0x0080\n\n/* SSL3_FLAGS_SGC_RESTART_DONE is no longer used */\n# define SSL3_FLAGS_SGC_RESTART_DONE             0x0040\n\n# ifndef OPENSSL_NO_SSL_INTERN\n\ntypedef struct ssl3_state_st {\n    long flags;\n    int delay_buf_pop_ret;\n    unsigned char read_sequence[8];\n    int read_mac_secret_size;\n    unsigned char read_mac_secret[EVP_MAX_MD_SIZE];\n    unsigned char write_sequence[8];\n    int write_mac_secret_size;\n    unsigned char write_mac_secret[EVP_MAX_MD_SIZE];\n    unsigned char server_random[SSL3_RANDOM_SIZE];\n    unsigned char client_random[SSL3_RANDOM_SIZE];\n    /* flags for countermeasure against known-IV weakness */\n    int need_empty_fragments;\n    int empty_fragment_done;\n    /* The value of 'extra' when the buffers were initialized */\n    int init_extra;\n    SSL3_BUFFER rbuf;           /* read IO goes into here */\n    SSL3_BUFFER wbuf;           /* write IO goes into here */\n    SSL3_RECORD rrec;           /* each decoded record goes in here */\n    SSL3_RECORD wrec;           /* goes out from here */\n    /*\n     * storage for Alert/Handshake protocol data received but not yet\n     * processed by ssl3_read_bytes:\n     */\n    unsigned char alert_fragment[2];\n    unsigned int alert_fragment_len;\n    unsigned char handshake_fragment[4];\n    unsigned int handshake_fragment_len;\n    /* partial write - check the numbers match */\n    unsigned int wnum;          /* number of bytes sent so far */\n    int wpend_tot;              /* number bytes written */\n    int wpend_type;\n    int wpend_ret;              /* number of bytes submitted */\n    const unsigned char *wpend_buf;\n    /* used during startup, digest all incoming/outgoing packets */\n    BIO *handshake_buffer;\n    /*\n     * When set of handshake digests is determined, buffer is hashed and\n     * freed and MD_CTX-es for all required digests are stored in this array\n     */\n    EVP_MD_CTX **handshake_dgst;\n    /*\n     * Set whenever an expected ChangeCipherSpec message is processed.\n     * Unset when the peer's Finished message is received.\n     * Unexpected ChangeCipherSpec messages trigger a fatal alert.\n     */\n    int change_cipher_spec;\n    int warn_alert;\n    int fatal_alert;\n    /*\n     * we allow one fatal and one warning alert to be outstanding, send close\n     * alert via the warning alert\n     */\n    int alert_dispatch;\n    unsigned char send_alert[2];\n    /*\n     * This flag is set when we should renegotiate ASAP, basically when there\n     * is no more data in the read or write buffers\n     */\n    int renegotiate;\n    int total_renegotiations;\n    int num_renegotiations;\n    int in_read_app_data;\n    /*\n     * Opaque PRF input as used for the current handshake. These fields are\n     * used only if TLSEXT_TYPE_opaque_prf_input is defined (otherwise, they\n     * are merely present to improve binary compatibility)\n     */\n    void *client_opaque_prf_input;\n    size_t client_opaque_prf_input_len;\n    void *server_opaque_prf_input;\n    size_t server_opaque_prf_input_len;\n    struct {\n        /* actually only needs to be 16+20 */\n        unsigned char cert_verify_md[EVP_MAX_MD_SIZE * 2];\n        /* actually only need to be 16+20 for SSLv3 and 12 for TLS */\n        unsigned char finish_md[EVP_MAX_MD_SIZE * 2];\n        int finish_md_len;\n        unsigned char peer_finish_md[EVP_MAX_MD_SIZE * 2];\n        int peer_finish_md_len;\n        unsigned long message_size;\n        int message_type;\n        /* used to hold the new cipher we are going to use */\n        const SSL_CIPHER *new_cipher;\n#  ifndef OPENSSL_NO_DH\n        DH *dh;\n#  endif\n#  ifndef OPENSSL_NO_ECDH\n        EC_KEY *ecdh;           /* holds short lived ECDH key */\n#  endif\n        /* used when SSL_ST_FLUSH_DATA is entered */\n        int next_state;\n        int reuse_message;\n        /* used for certificate requests */\n        int cert_req;\n        int ctype_num;\n        char ctype[SSL3_CT_NUMBER];\n        STACK_OF(X509_NAME) *ca_names;\n        int use_rsa_tmp;\n        int key_block_length;\n        unsigned char *key_block;\n        const EVP_CIPHER *new_sym_enc;\n        const EVP_MD *new_hash;\n        int new_mac_pkey_type;\n        int new_mac_secret_size;\n#  ifndef OPENSSL_NO_COMP\n        const SSL_COMP *new_compression;\n#  else\n        char *new_compression;\n#  endif\n        int cert_request;\n    } tmp;\n\n    /* Connection binding to prevent renegotiation attacks */\n    unsigned char previous_client_finished[EVP_MAX_MD_SIZE];\n    unsigned char previous_client_finished_len;\n    unsigned char previous_server_finished[EVP_MAX_MD_SIZE];\n    unsigned char previous_server_finished_len;\n    int send_connection_binding; /* TODOEKR */\n\n#  ifndef OPENSSL_NO_NEXTPROTONEG\n    /*\n     * Set if we saw the Next Protocol Negotiation extension from our peer.\n     */\n    int next_proto_neg_seen;\n#  endif\n\n#  ifndef OPENSSL_NO_TLSEXT\n#   ifndef OPENSSL_NO_EC\n    /*\n     * This is set to true if we believe that this is a version of Safari\n     * running on OS X 10.6 or newer. We wish to know this because Safari on\n     * 10.8 .. 10.8.3 has broken ECDHE-ECDSA support.\n     */\n    char is_probably_safari;\n#   endif                       /* !OPENSSL_NO_EC */\n\n    /*\n     * ALPN information (we are in the process of transitioning from NPN to\n     * ALPN.)\n     */\n\n    /*\n     * In a server these point to the selected ALPN protocol after the\n     * ClientHello has been processed. In a client these contain the protocol\n     * that the server selected once the ServerHello has been processed.\n     */\n    unsigned char *alpn_selected;\n    unsigned alpn_selected_len;\n#  endif                        /* OPENSSL_NO_TLSEXT */\n} SSL3_STATE;\n\n# endif\n\n/* SSLv3 */\n/*\n * client\n */\n/* extra state */\n# define SSL3_ST_CW_FLUSH                (0x100|SSL_ST_CONNECT)\n# ifndef OPENSSL_NO_SCTP\n#  define DTLS1_SCTP_ST_CW_WRITE_SOCK                     (0x310|SSL_ST_CONNECT)\n#  define DTLS1_SCTP_ST_CR_READ_SOCK                      (0x320|SSL_ST_CONNECT)\n# endif\n/* write to server */\n# define SSL3_ST_CW_CLNT_HELLO_A         (0x110|SSL_ST_CONNECT)\n# define SSL3_ST_CW_CLNT_HELLO_B         (0x111|SSL_ST_CONNECT)\n/* read from server */\n# define SSL3_ST_CR_SRVR_HELLO_A         (0x120|SSL_ST_CONNECT)\n# define SSL3_ST_CR_SRVR_HELLO_B         (0x121|SSL_ST_CONNECT)\n# define DTLS1_ST_CR_HELLO_VERIFY_REQUEST_A (0x126|SSL_ST_CONNECT)\n# define DTLS1_ST_CR_HELLO_VERIFY_REQUEST_B (0x127|SSL_ST_CONNECT)\n# define SSL3_ST_CR_CERT_A               (0x130|SSL_ST_CONNECT)\n# define SSL3_ST_CR_CERT_B               (0x131|SSL_ST_CONNECT)\n# define SSL3_ST_CR_KEY_EXCH_A           (0x140|SSL_ST_CONNECT)\n# define SSL3_ST_CR_KEY_EXCH_B           (0x141|SSL_ST_CONNECT)\n# define SSL3_ST_CR_CERT_REQ_A           (0x150|SSL_ST_CONNECT)\n# define SSL3_ST_CR_CERT_REQ_B           (0x151|SSL_ST_CONNECT)\n# define SSL3_ST_CR_SRVR_DONE_A          (0x160|SSL_ST_CONNECT)\n# define SSL3_ST_CR_SRVR_DONE_B          (0x161|SSL_ST_CONNECT)\n/* write to server */\n# define SSL3_ST_CW_CERT_A               (0x170|SSL_ST_CONNECT)\n# define SSL3_ST_CW_CERT_B               (0x171|SSL_ST_CONNECT)\n# define SSL3_ST_CW_CERT_C               (0x172|SSL_ST_CONNECT)\n# define SSL3_ST_CW_CERT_D               (0x173|SSL_ST_CONNECT)\n# define SSL3_ST_CW_KEY_EXCH_A           (0x180|SSL_ST_CONNECT)\n# define SSL3_ST_CW_KEY_EXCH_B           (0x181|SSL_ST_CONNECT)\n# define SSL3_ST_CW_CERT_VRFY_A          (0x190|SSL_ST_CONNECT)\n# define SSL3_ST_CW_CERT_VRFY_B          (0x191|SSL_ST_CONNECT)\n# define SSL3_ST_CW_CHANGE_A             (0x1A0|SSL_ST_CONNECT)\n# define SSL3_ST_CW_CHANGE_B             (0x1A1|SSL_ST_CONNECT)\n# ifndef OPENSSL_NO_NEXTPROTONEG\n#  define SSL3_ST_CW_NEXT_PROTO_A         (0x200|SSL_ST_CONNECT)\n#  define SSL3_ST_CW_NEXT_PROTO_B         (0x201|SSL_ST_CONNECT)\n# endif\n# define SSL3_ST_CW_FINISHED_A           (0x1B0|SSL_ST_CONNECT)\n# define SSL3_ST_CW_FINISHED_B           (0x1B1|SSL_ST_CONNECT)\n/* read from server */\n# define SSL3_ST_CR_CHANGE_A             (0x1C0|SSL_ST_CONNECT)\n# define SSL3_ST_CR_CHANGE_B             (0x1C1|SSL_ST_CONNECT)\n# define SSL3_ST_CR_FINISHED_A           (0x1D0|SSL_ST_CONNECT)\n# define SSL3_ST_CR_FINISHED_B           (0x1D1|SSL_ST_CONNECT)\n# define SSL3_ST_CR_SESSION_TICKET_A     (0x1E0|SSL_ST_CONNECT)\n# define SSL3_ST_CR_SESSION_TICKET_B     (0x1E1|SSL_ST_CONNECT)\n# define SSL3_ST_CR_CERT_STATUS_A        (0x1F0|SSL_ST_CONNECT)\n# define SSL3_ST_CR_CERT_STATUS_B        (0x1F1|SSL_ST_CONNECT)\n\n/* server */\n/* extra state */\n# define SSL3_ST_SW_FLUSH                (0x100|SSL_ST_ACCEPT)\n# ifndef OPENSSL_NO_SCTP\n#  define DTLS1_SCTP_ST_SW_WRITE_SOCK                     (0x310|SSL_ST_ACCEPT)\n#  define DTLS1_SCTP_ST_SR_READ_SOCK                      (0x320|SSL_ST_ACCEPT)\n# endif\n/* read from client */\n/* Do not change the number values, they do matter */\n# define SSL3_ST_SR_CLNT_HELLO_A         (0x110|SSL_ST_ACCEPT)\n# define SSL3_ST_SR_CLNT_HELLO_B         (0x111|SSL_ST_ACCEPT)\n# define SSL3_ST_SR_CLNT_HELLO_C         (0x112|SSL_ST_ACCEPT)\n# define SSL3_ST_SR_CLNT_HELLO_D         (0x115|SSL_ST_ACCEPT)\n/* write to client */\n# define DTLS1_ST_SW_HELLO_VERIFY_REQUEST_A (0x113|SSL_ST_ACCEPT)\n# define DTLS1_ST_SW_HELLO_VERIFY_REQUEST_B (0x114|SSL_ST_ACCEPT)\n# define SSL3_ST_SW_HELLO_REQ_A          (0x120|SSL_ST_ACCEPT)\n# define SSL3_ST_SW_HELLO_REQ_B          (0x121|SSL_ST_ACCEPT)\n# define SSL3_ST_SW_HELLO_REQ_C          (0x122|SSL_ST_ACCEPT)\n# define SSL3_ST_SW_SRVR_HELLO_A         (0x130|SSL_ST_ACCEPT)\n# define SSL3_ST_SW_SRVR_HELLO_B         (0x131|SSL_ST_ACCEPT)\n# define SSL3_ST_SW_CERT_A               (0x140|SSL_ST_ACCEPT)\n# define SSL3_ST_SW_CERT_B               (0x141|SSL_ST_ACCEPT)\n# define SSL3_ST_SW_KEY_EXCH_A           (0x150|SSL_ST_ACCEPT)\n# define SSL3_ST_SW_KEY_EXCH_B           (0x151|SSL_ST_ACCEPT)\n# define SSL3_ST_SW_CERT_REQ_A           (0x160|SSL_ST_ACCEPT)\n# define SSL3_ST_SW_CERT_REQ_B           (0x161|SSL_ST_ACCEPT)\n# define SSL3_ST_SW_SRVR_DONE_A          (0x170|SSL_ST_ACCEPT)\n# define SSL3_ST_SW_SRVR_DONE_B          (0x171|SSL_ST_ACCEPT)\n/* read from client */\n# define SSL3_ST_SR_CERT_A               (0x180|SSL_ST_ACCEPT)\n# define SSL3_ST_SR_CERT_B               (0x181|SSL_ST_ACCEPT)\n# define SSL3_ST_SR_KEY_EXCH_A           (0x190|SSL_ST_ACCEPT)\n# define SSL3_ST_SR_KEY_EXCH_B           (0x191|SSL_ST_ACCEPT)\n# define SSL3_ST_SR_CERT_VRFY_A          (0x1A0|SSL_ST_ACCEPT)\n# define SSL3_ST_SR_CERT_VRFY_B          (0x1A1|SSL_ST_ACCEPT)\n# define SSL3_ST_SR_CHANGE_A             (0x1B0|SSL_ST_ACCEPT)\n# define SSL3_ST_SR_CHANGE_B             (0x1B1|SSL_ST_ACCEPT)\n# ifndef OPENSSL_NO_NEXTPROTONEG\n#  define SSL3_ST_SR_NEXT_PROTO_A         (0x210|SSL_ST_ACCEPT)\n#  define SSL3_ST_SR_NEXT_PROTO_B         (0x211|SSL_ST_ACCEPT)\n# endif\n# define SSL3_ST_SR_FINISHED_A           (0x1C0|SSL_ST_ACCEPT)\n# define SSL3_ST_SR_FINISHED_B           (0x1C1|SSL_ST_ACCEPT)\n/* write to client */\n# define SSL3_ST_SW_CHANGE_A             (0x1D0|SSL_ST_ACCEPT)\n# define SSL3_ST_SW_CHANGE_B             (0x1D1|SSL_ST_ACCEPT)\n# define SSL3_ST_SW_FINISHED_A           (0x1E0|SSL_ST_ACCEPT)\n# define SSL3_ST_SW_FINISHED_B           (0x1E1|SSL_ST_ACCEPT)\n# define SSL3_ST_SW_SESSION_TICKET_A     (0x1F0|SSL_ST_ACCEPT)\n# define SSL3_ST_SW_SESSION_TICKET_B     (0x1F1|SSL_ST_ACCEPT)\n# define SSL3_ST_SW_CERT_STATUS_A        (0x200|SSL_ST_ACCEPT)\n# define SSL3_ST_SW_CERT_STATUS_B        (0x201|SSL_ST_ACCEPT)\n\n# define SSL3_MT_HELLO_REQUEST                   0\n# define SSL3_MT_CLIENT_HELLO                    1\n# define SSL3_MT_SERVER_HELLO                    2\n# define SSL3_MT_NEWSESSION_TICKET               4\n# define SSL3_MT_CERTIFICATE                     11\n# define SSL3_MT_SERVER_KEY_EXCHANGE             12\n# define SSL3_MT_CERTIFICATE_REQUEST             13\n# define SSL3_MT_SERVER_DONE                     14\n# define SSL3_MT_CERTIFICATE_VERIFY              15\n# define SSL3_MT_CLIENT_KEY_EXCHANGE             16\n# define SSL3_MT_FINISHED                        20\n# define SSL3_MT_CERTIFICATE_STATUS              22\n# ifndef OPENSSL_NO_NEXTPROTONEG\n#  define SSL3_MT_NEXT_PROTO                      67\n# endif\n# define DTLS1_MT_HELLO_VERIFY_REQUEST    3\n\n# define SSL3_MT_CCS                             1\n\n/* These are used when changing over to a new cipher */\n# define SSL3_CC_READ            0x01\n# define SSL3_CC_WRITE           0x02\n# define SSL3_CC_CLIENT          0x10\n# define SSL3_CC_SERVER          0x20\n# define SSL3_CHANGE_CIPHER_CLIENT_WRITE (SSL3_CC_CLIENT|SSL3_CC_WRITE)\n# define SSL3_CHANGE_CIPHER_SERVER_READ  (SSL3_CC_SERVER|SSL3_CC_READ)\n# define SSL3_CHANGE_CIPHER_CLIENT_READ  (SSL3_CC_CLIENT|SSL3_CC_READ)\n# define SSL3_CHANGE_CIPHER_SERVER_WRITE (SSL3_CC_SERVER|SSL3_CC_WRITE)\n\n#ifdef  __cplusplus\n}\n#endif\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/arm/include/openssl/stack.h",
    "content": "/* crypto/stack/stack.h */\n/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)\n * All rights reserved.\n *\n * This package is an SSL implementation written\n * by Eric Young (eay@cryptsoft.com).\n * The implementation was written so as to conform with Netscapes SSL.\n *\n * This library is free for commercial and non-commercial use as long as\n * the following conditions are aheared to.  The following conditions\n * apply to all code found in this distribution, be it the RC4, RSA,\n * lhash, DES, etc., code; not just the SSL code.  The SSL documentation\n * included with this distribution is covered by the same copyright terms\n * except that the holder is Tim Hudson (tjh@cryptsoft.com).\n *\n * Copyright remains Eric Young's, and as such any Copyright notices in\n * the code are not to be removed.\n * If this package is used in a product, Eric Young should be given attribution\n * as the author of the parts of the library used.\n * This can be in the form of a textual message at program startup or\n * in documentation (online or textual) provided with the package.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the copyright\n *    notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in the\n *    documentation and/or other materials provided with the distribution.\n * 3. All advertising materials mentioning features or use of this software\n *    must display the following acknowledgement:\n *    \"This product includes cryptographic software written by\n *     Eric Young (eay@cryptsoft.com)\"\n *    The word 'cryptographic' can be left out if the rouines from the library\n *    being used are not cryptographic related :-).\n * 4. If you include any Windows specific code (or a derivative thereof) from\n *    the apps directory (application code) you must include an acknowledgement:\n *    \"This product includes software written by Tim Hudson (tjh@cryptsoft.com)\"\n *\n * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n * SUCH DAMAGE.\n *\n * The licence and distribution terms for any publically available version or\n * derivative of this code cannot be changed.  i.e. this code cannot simply be\n * copied and put under another distribution licence\n * [including the GNU Public Licence.]\n */\n\n#ifndef HEADER_STACK_H\n# define HEADER_STACK_H\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\ntypedef struct stack_st {\n    int num;\n    char **data;\n    int sorted;\n    int num_alloc;\n    int (*comp) (const void *, const void *);\n} _STACK;                       /* Use STACK_OF(...) instead */\n\n# define M_sk_num(sk)            ((sk) ? (sk)->num:-1)\n# define M_sk_value(sk,n)        ((sk) ? (sk)->data[n] : NULL)\n\nint sk_num(const _STACK *);\nvoid *sk_value(const _STACK *, int);\n\nvoid *sk_set(_STACK *, int, void *);\n\n_STACK *sk_new(int (*cmp) (const void *, const void *));\n_STACK *sk_new_null(void);\nvoid sk_free(_STACK *);\nvoid sk_pop_free(_STACK *st, void (*func) (void *));\n_STACK *sk_deep_copy(_STACK *, void *(*)(void *), void (*)(void *));\nint sk_insert(_STACK *sk, void *data, int where);\nvoid *sk_delete(_STACK *st, int loc);\nvoid *sk_delete_ptr(_STACK *st, void *p);\nint sk_find(_STACK *st, void *data);\nint sk_find_ex(_STACK *st, void *data);\nint sk_push(_STACK *st, void *data);\nint sk_unshift(_STACK *st, void *data);\nvoid *sk_shift(_STACK *st);\nvoid *sk_pop(_STACK *st);\nvoid sk_zero(_STACK *st);\nint (*sk_set_cmp_func(_STACK *sk, int (*c) (const void *, const void *)))\n (const void *, const void *);\n_STACK *sk_dup(_STACK *st);\nvoid sk_sort(_STACK *st);\nint sk_is_sorted(const _STACK *st);\n\n#ifdef  __cplusplus\n}\n#endif\n\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/arm/include/openssl/symhacks.h",
    "content": "/* ====================================================================\n * Copyright (c) 1999 The OpenSSL Project.  All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n *\n * 1. Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n *\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in\n *    the documentation and/or other materials provided with the\n *    distribution.\n *\n * 3. All advertising materials mentioning features or use of this\n *    software must display the following acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit. (http://www.openssl.org/)\"\n *\n * 4. The names \"OpenSSL Toolkit\" and \"OpenSSL Project\" must not be used to\n *    endorse or promote products derived from this software without\n *    prior written permission. For written permission, please contact\n *    openssl-core@openssl.org.\n *\n * 5. Products derived from this software may not be called \"OpenSSL\"\n *    nor may \"OpenSSL\" appear in their names without prior written\n *    permission of the OpenSSL Project.\n *\n * 6. Redistributions of any form whatsoever must retain the following\n *    acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit (http://www.openssl.org/)\"\n *\n * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY\n * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\n * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR\n * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\n * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,\n * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED\n * OF THE POSSIBILITY OF SUCH DAMAGE.\n * ====================================================================\n *\n * This product includes cryptographic software written by Eric Young\n * (eay@cryptsoft.com).  This product includes software written by Tim\n * Hudson (tjh@cryptsoft.com).\n *\n */\n\n#ifndef HEADER_SYMHACKS_H\n# define HEADER_SYMHACKS_H\n\n# include <openssl/e_os2.h>\n\n/*\n * Hacks to solve the problem with linkers incapable of handling very long\n * symbol names.  In the case of VMS, the limit is 31 characters on VMS for\n * VAX.\n */\n/*\n * Note that this affects util/libeay.num and util/ssleay.num...  you may\n * change those manually, but that's not recommended, as those files are\n * controlled centrally and updated on Unix, and the central definition may\n * disagree with yours, which in turn may come with shareable library\n * incompatibilities.\n */\n# ifdef OPENSSL_SYS_VMS\n\n/* Hack a long name in crypto/ex_data.c */\n#  undef CRYPTO_get_ex_data_implementation\n#  define CRYPTO_get_ex_data_implementation       CRYPTO_get_ex_data_impl\n#  undef CRYPTO_set_ex_data_implementation\n#  define CRYPTO_set_ex_data_implementation       CRYPTO_set_ex_data_impl\n\n/* Hack a long name in crypto/asn1/a_mbstr.c */\n#  undef ASN1_STRING_set_default_mask_asc\n#  define ASN1_STRING_set_default_mask_asc        ASN1_STRING_set_def_mask_asc\n\n#  if 0                         /* No longer needed, since safestack macro\n                                 * magic does the job */\n/* Hack the names created with DECLARE_ASN1_SET_OF(PKCS7_SIGNER_INFO) */\n#   undef i2d_ASN1_SET_OF_PKCS7_SIGNER_INFO\n#   define i2d_ASN1_SET_OF_PKCS7_SIGNER_INFO       i2d_ASN1_SET_OF_PKCS7_SIGINF\n#   undef d2i_ASN1_SET_OF_PKCS7_SIGNER_INFO\n#   define d2i_ASN1_SET_OF_PKCS7_SIGNER_INFO       d2i_ASN1_SET_OF_PKCS7_SIGINF\n#  endif\n\n#  if 0                         /* No longer needed, since safestack macro\n                                 * magic does the job */\n/* Hack the names created with DECLARE_ASN1_SET_OF(PKCS7_RECIP_INFO) */\n#   undef i2d_ASN1_SET_OF_PKCS7_RECIP_INFO\n#   define i2d_ASN1_SET_OF_PKCS7_RECIP_INFO        i2d_ASN1_SET_OF_PKCS7_RECINF\n#   undef d2i_ASN1_SET_OF_PKCS7_RECIP_INFO\n#   define d2i_ASN1_SET_OF_PKCS7_RECIP_INFO        d2i_ASN1_SET_OF_PKCS7_RECINF\n#  endif\n\n#  if 0                         /* No longer needed, since safestack macro\n                                 * magic does the job */\n/* Hack the names created with DECLARE_ASN1_SET_OF(ACCESS_DESCRIPTION) */\n#   undef i2d_ASN1_SET_OF_ACCESS_DESCRIPTION\n#   define i2d_ASN1_SET_OF_ACCESS_DESCRIPTION      i2d_ASN1_SET_OF_ACC_DESC\n#   undef d2i_ASN1_SET_OF_ACCESS_DESCRIPTION\n#   define d2i_ASN1_SET_OF_ACCESS_DESCRIPTION      d2i_ASN1_SET_OF_ACC_DESC\n#  endif\n\n/* Hack the names created with DECLARE_PEM_rw(NETSCAPE_CERT_SEQUENCE) */\n#  undef PEM_read_NETSCAPE_CERT_SEQUENCE\n#  define PEM_read_NETSCAPE_CERT_SEQUENCE         PEM_read_NS_CERT_SEQ\n#  undef PEM_write_NETSCAPE_CERT_SEQUENCE\n#  define PEM_write_NETSCAPE_CERT_SEQUENCE        PEM_write_NS_CERT_SEQ\n#  undef PEM_read_bio_NETSCAPE_CERT_SEQUENCE\n#  define PEM_read_bio_NETSCAPE_CERT_SEQUENCE     PEM_read_bio_NS_CERT_SEQ\n#  undef PEM_write_bio_NETSCAPE_CERT_SEQUENCE\n#  define PEM_write_bio_NETSCAPE_CERT_SEQUENCE    PEM_write_bio_NS_CERT_SEQ\n#  undef PEM_write_cb_bio_NETSCAPE_CERT_SEQUENCE\n#  define PEM_write_cb_bio_NETSCAPE_CERT_SEQUENCE PEM_write_cb_bio_NS_CERT_SEQ\n\n/* Hack the names created with DECLARE_PEM_rw(PKCS8_PRIV_KEY_INFO) */\n#  undef PEM_read_PKCS8_PRIV_KEY_INFO\n#  define PEM_read_PKCS8_PRIV_KEY_INFO            PEM_read_P8_PRIV_KEY_INFO\n#  undef PEM_write_PKCS8_PRIV_KEY_INFO\n#  define PEM_write_PKCS8_PRIV_KEY_INFO           PEM_write_P8_PRIV_KEY_INFO\n#  undef PEM_read_bio_PKCS8_PRIV_KEY_INFO\n#  define PEM_read_bio_PKCS8_PRIV_KEY_INFO        PEM_read_bio_P8_PRIV_KEY_INFO\n#  undef PEM_write_bio_PKCS8_PRIV_KEY_INFO\n#  define PEM_write_bio_PKCS8_PRIV_KEY_INFO       PEM_write_bio_P8_PRIV_KEY_INFO\n#  undef PEM_write_cb_bio_PKCS8_PRIV_KEY_INFO\n#  define PEM_write_cb_bio_PKCS8_PRIV_KEY_INFO    PEM_wrt_cb_bio_P8_PRIV_KEY_INFO\n\n/* Hack other PEM names */\n#  undef PEM_write_bio_PKCS8PrivateKey_nid\n#  define PEM_write_bio_PKCS8PrivateKey_nid       PEM_write_bio_PKCS8PrivKey_nid\n\n/* Hack some long X509 names */\n#  undef X509_REVOKED_get_ext_by_critical\n#  define X509_REVOKED_get_ext_by_critical        X509_REVOKED_get_ext_by_critic\n#  undef X509_policy_tree_get0_user_policies\n#  define X509_policy_tree_get0_user_policies     X509_pcy_tree_get0_usr_policies\n#  undef X509_policy_node_get0_qualifiers\n#  define X509_policy_node_get0_qualifiers        X509_pcy_node_get0_qualifiers\n#  undef X509_STORE_CTX_get_explicit_policy\n#  define X509_STORE_CTX_get_explicit_policy      X509_STORE_CTX_get_expl_policy\n#  undef X509_STORE_CTX_get0_current_issuer\n#  define X509_STORE_CTX_get0_current_issuer      X509_STORE_CTX_get0_cur_issuer\n\n/* Hack some long CRYPTO names */\n#  undef CRYPTO_set_dynlock_destroy_callback\n#  define CRYPTO_set_dynlock_destroy_callback     CRYPTO_set_dynlock_destroy_cb\n#  undef CRYPTO_set_dynlock_create_callback\n#  define CRYPTO_set_dynlock_create_callback      CRYPTO_set_dynlock_create_cb\n#  undef CRYPTO_set_dynlock_lock_callback\n#  define CRYPTO_set_dynlock_lock_callback        CRYPTO_set_dynlock_lock_cb\n#  undef CRYPTO_get_dynlock_lock_callback\n#  define CRYPTO_get_dynlock_lock_callback        CRYPTO_get_dynlock_lock_cb\n#  undef CRYPTO_get_dynlock_destroy_callback\n#  define CRYPTO_get_dynlock_destroy_callback     CRYPTO_get_dynlock_destroy_cb\n#  undef CRYPTO_get_dynlock_create_callback\n#  define CRYPTO_get_dynlock_create_callback      CRYPTO_get_dynlock_create_cb\n#  undef CRYPTO_set_locked_mem_ex_functions\n#  define CRYPTO_set_locked_mem_ex_functions      CRYPTO_set_locked_mem_ex_funcs\n#  undef CRYPTO_get_locked_mem_ex_functions\n#  define CRYPTO_get_locked_mem_ex_functions      CRYPTO_get_locked_mem_ex_funcs\n\n/* Hack some long SSL/TLS names */\n#  undef SSL_CTX_set_default_verify_paths\n#  define SSL_CTX_set_default_verify_paths        SSL_CTX_set_def_verify_paths\n#  undef SSL_get_ex_data_X509_STORE_CTX_idx\n#  define SSL_get_ex_data_X509_STORE_CTX_idx      SSL_get_ex_d_X509_STORE_CTX_idx\n#  undef SSL_add_file_cert_subjects_to_stack\n#  define SSL_add_file_cert_subjects_to_stack     SSL_add_file_cert_subjs_to_stk\n#  undef SSL_add_dir_cert_subjects_to_stack\n#  define SSL_add_dir_cert_subjects_to_stack      SSL_add_dir_cert_subjs_to_stk\n#  undef SSL_CTX_use_certificate_chain_file\n#  define SSL_CTX_use_certificate_chain_file      SSL_CTX_use_cert_chain_file\n#  undef SSL_CTX_set_cert_verify_callback\n#  define SSL_CTX_set_cert_verify_callback        SSL_CTX_set_cert_verify_cb\n#  undef SSL_CTX_set_default_passwd_cb_userdata\n#  define SSL_CTX_set_default_passwd_cb_userdata  SSL_CTX_set_def_passwd_cb_ud\n#  undef SSL_COMP_get_compression_methods\n#  define SSL_COMP_get_compression_methods        SSL_COMP_get_compress_methods\n#  undef SSL_COMP_set0_compression_methods\n#  define SSL_COMP_set0_compression_methods       SSL_COMP_set0_compress_methods\n#  undef SSL_COMP_free_compression_methods\n#  define SSL_COMP_free_compression_methods       SSL_COMP_free_compress_methods\n#  undef ssl_add_clienthello_renegotiate_ext\n#  define ssl_add_clienthello_renegotiate_ext     ssl_add_clienthello_reneg_ext\n#  undef ssl_add_serverhello_renegotiate_ext\n#  define ssl_add_serverhello_renegotiate_ext     ssl_add_serverhello_reneg_ext\n#  undef ssl_parse_clienthello_renegotiate_ext\n#  define ssl_parse_clienthello_renegotiate_ext   ssl_parse_clienthello_reneg_ext\n#  undef ssl_parse_serverhello_renegotiate_ext\n#  define ssl_parse_serverhello_renegotiate_ext   ssl_parse_serverhello_reneg_ext\n#  undef SSL_srp_server_param_with_username\n#  define SSL_srp_server_param_with_username      SSL_srp_server_param_with_un\n#  undef SSL_CTX_set_srp_client_pwd_callback\n#  define SSL_CTX_set_srp_client_pwd_callback     SSL_CTX_set_srp_client_pwd_cb\n#  undef SSL_CTX_set_srp_verify_param_callback\n#  define SSL_CTX_set_srp_verify_param_callback   SSL_CTX_set_srp_vfy_param_cb\n#  undef SSL_CTX_set_srp_username_callback\n#  define SSL_CTX_set_srp_username_callback       SSL_CTX_set_srp_un_cb\n#  undef ssl_add_clienthello_use_srtp_ext\n#  define ssl_add_clienthello_use_srtp_ext        ssl_add_clihello_use_srtp_ext\n#  undef ssl_add_serverhello_use_srtp_ext\n#  define ssl_add_serverhello_use_srtp_ext        ssl_add_serhello_use_srtp_ext\n#  undef ssl_parse_clienthello_use_srtp_ext\n#  define ssl_parse_clienthello_use_srtp_ext      ssl_parse_clihello_use_srtp_ext\n#  undef ssl_parse_serverhello_use_srtp_ext\n#  define ssl_parse_serverhello_use_srtp_ext      ssl_parse_serhello_use_srtp_ext\n#  undef SSL_CTX_set_next_protos_advertised_cb\n#  define SSL_CTX_set_next_protos_advertised_cb   SSL_CTX_set_next_protos_adv_cb\n#  undef SSL_CTX_set_next_proto_select_cb\n#  define SSL_CTX_set_next_proto_select_cb        SSL_CTX_set_next_proto_sel_cb\n\n#  undef tls1_send_server_supplemental_data\n#  define tls1_send_server_supplemental_data      tls1_send_server_suppl_data\n#  undef tls1_send_client_supplemental_data\n#  define tls1_send_client_supplemental_data      tls1_send_client_suppl_data\n#  undef tls1_get_server_supplemental_data\n#  define tls1_get_server_supplemental_data       tls1_get_server_suppl_data\n#  undef tls1_get_client_supplemental_data\n#  define tls1_get_client_supplemental_data       tls1_get_client_suppl_data\n\n#  undef ssl3_cbc_record_digest_supported\n#  define ssl3_cbc_record_digest_supported        ssl3_cbc_record_digest_support\n#  undef ssl_check_clienthello_tlsext_late\n#  define ssl_check_clienthello_tlsext_late       ssl_check_clihello_tlsext_late\n#  undef ssl_check_clienthello_tlsext_early\n#  define ssl_check_clienthello_tlsext_early      ssl_check_clihello_tlsext_early\n\n/* Hack some RSA long names */\n#  undef RSA_padding_check_PKCS1_OAEP_mgf1\n#  define RSA_padding_check_PKCS1_OAEP_mgf1       RSA_pad_check_PKCS1_OAEP_mgf1\n\n/* Hack some ENGINE long names */\n#  undef ENGINE_get_default_BN_mod_exp_crt\n#  define ENGINE_get_default_BN_mod_exp_crt       ENGINE_get_def_BN_mod_exp_crt\n#  undef ENGINE_set_default_BN_mod_exp_crt\n#  define ENGINE_set_default_BN_mod_exp_crt       ENGINE_set_def_BN_mod_exp_crt\n#  undef ENGINE_set_load_privkey_function\n#  define ENGINE_set_load_privkey_function        ENGINE_set_load_privkey_fn\n#  undef ENGINE_get_load_privkey_function\n#  define ENGINE_get_load_privkey_function        ENGINE_get_load_privkey_fn\n#  undef ENGINE_unregister_pkey_asn1_meths\n#  define ENGINE_unregister_pkey_asn1_meths       ENGINE_unreg_pkey_asn1_meths\n#  undef ENGINE_register_all_pkey_asn1_meths\n#  define ENGINE_register_all_pkey_asn1_meths     ENGINE_reg_all_pkey_asn1_meths\n#  undef ENGINE_set_default_pkey_asn1_meths\n#  define ENGINE_set_default_pkey_asn1_meths      ENGINE_set_def_pkey_asn1_meths\n#  undef ENGINE_get_pkey_asn1_meth_engine\n#  define ENGINE_get_pkey_asn1_meth_engine        ENGINE_get_pkey_asn1_meth_eng\n#  undef ENGINE_set_load_ssl_client_cert_function\n#  define ENGINE_set_load_ssl_client_cert_function \\\n                                                ENGINE_set_ld_ssl_clnt_cert_fn\n#  undef ENGINE_get_ssl_client_cert_function\n#  define ENGINE_get_ssl_client_cert_function     ENGINE_get_ssl_client_cert_fn\n\n/* Hack some long OCSP names */\n#  undef OCSP_REQUEST_get_ext_by_critical\n#  define OCSP_REQUEST_get_ext_by_critical        OCSP_REQUEST_get_ext_by_crit\n#  undef OCSP_BASICRESP_get_ext_by_critical\n#  define OCSP_BASICRESP_get_ext_by_critical      OCSP_BASICRESP_get_ext_by_crit\n#  undef OCSP_SINGLERESP_get_ext_by_critical\n#  define OCSP_SINGLERESP_get_ext_by_critical     OCSP_SINGLERESP_get_ext_by_crit\n\n/* Hack some long DES names */\n#  undef _ossl_old_des_ede3_cfb64_encrypt\n#  define _ossl_old_des_ede3_cfb64_encrypt        _ossl_odes_ede3_cfb64_encrypt\n#  undef _ossl_old_des_ede3_ofb64_encrypt\n#  define _ossl_old_des_ede3_ofb64_encrypt        _ossl_odes_ede3_ofb64_encrypt\n\n/* Hack some long EVP names */\n#  undef OPENSSL_add_all_algorithms_noconf\n#  define OPENSSL_add_all_algorithms_noconf       OPENSSL_add_all_algo_noconf\n#  undef OPENSSL_add_all_algorithms_conf\n#  define OPENSSL_add_all_algorithms_conf         OPENSSL_add_all_algo_conf\n#  undef EVP_PKEY_meth_set_verify_recover\n#  define EVP_PKEY_meth_set_verify_recover        EVP_PKEY_meth_set_vrfy_recover\n\n/* Hack some long EC names */\n#  undef EC_GROUP_set_point_conversion_form\n#  define EC_GROUP_set_point_conversion_form      EC_GROUP_set_point_conv_form\n#  undef EC_GROUP_get_point_conversion_form\n#  define EC_GROUP_get_point_conversion_form      EC_GROUP_get_point_conv_form\n#  undef EC_GROUP_clear_free_all_extra_data\n#  define EC_GROUP_clear_free_all_extra_data      EC_GROUP_clr_free_all_xtra_data\n#  undef EC_KEY_set_public_key_affine_coordinates\n#  define EC_KEY_set_public_key_affine_coordinates \\\n                                                EC_KEY_set_pub_key_aff_coords\n#  undef EC_POINT_set_Jprojective_coordinates_GFp\n#  define EC_POINT_set_Jprojective_coordinates_GFp \\\n                                                EC_POINT_set_Jproj_coords_GFp\n#  undef EC_POINT_get_Jprojective_coordinates_GFp\n#  define EC_POINT_get_Jprojective_coordinates_GFp \\\n                                                EC_POINT_get_Jproj_coords_GFp\n#  undef EC_POINT_set_affine_coordinates_GFp\n#  define EC_POINT_set_affine_coordinates_GFp     EC_POINT_set_affine_coords_GFp\n#  undef EC_POINT_get_affine_coordinates_GFp\n#  define EC_POINT_get_affine_coordinates_GFp     EC_POINT_get_affine_coords_GFp\n#  undef EC_POINT_set_compressed_coordinates_GFp\n#  define EC_POINT_set_compressed_coordinates_GFp EC_POINT_set_compr_coords_GFp\n#  undef EC_POINT_set_affine_coordinates_GF2m\n#  define EC_POINT_set_affine_coordinates_GF2m    EC_POINT_set_affine_coords_GF2m\n#  undef EC_POINT_get_affine_coordinates_GF2m\n#  define EC_POINT_get_affine_coordinates_GF2m    EC_POINT_get_affine_coords_GF2m\n#  undef EC_POINT_set_compressed_coordinates_GF2m\n#  define EC_POINT_set_compressed_coordinates_GF2m \\\n                                                EC_POINT_set_compr_coords_GF2m\n#  undef ec_GF2m_simple_group_clear_finish\n#  define ec_GF2m_simple_group_clear_finish       ec_GF2m_simple_grp_clr_finish\n#  undef ec_GF2m_simple_group_check_discriminant\n#  define ec_GF2m_simple_group_check_discriminant ec_GF2m_simple_grp_chk_discrim\n#  undef ec_GF2m_simple_point_clear_finish\n#  define ec_GF2m_simple_point_clear_finish       ec_GF2m_simple_pt_clr_finish\n#  undef ec_GF2m_simple_point_set_to_infinity\n#  define ec_GF2m_simple_point_set_to_infinity    ec_GF2m_simple_pt_set_to_inf\n#  undef ec_GF2m_simple_points_make_affine\n#  define ec_GF2m_simple_points_make_affine       ec_GF2m_simple_pts_make_affine\n#  undef ec_GF2m_simple_point_set_affine_coordinates\n#  define ec_GF2m_simple_point_set_affine_coordinates \\\n                                                ec_GF2m_smp_pt_set_af_coords\n#  undef ec_GF2m_simple_point_get_affine_coordinates\n#  define ec_GF2m_simple_point_get_affine_coordinates \\\n                                                ec_GF2m_smp_pt_get_af_coords\n#  undef ec_GF2m_simple_set_compressed_coordinates\n#  define ec_GF2m_simple_set_compressed_coordinates \\\n                                                ec_GF2m_smp_set_compr_coords\n#  undef ec_GFp_simple_group_set_curve_GFp\n#  define ec_GFp_simple_group_set_curve_GFp       ec_GFp_simple_grp_set_curve_GFp\n#  undef ec_GFp_simple_group_get_curve_GFp\n#  define ec_GFp_simple_group_get_curve_GFp       ec_GFp_simple_grp_get_curve_GFp\n#  undef ec_GFp_simple_group_clear_finish\n#  define ec_GFp_simple_group_clear_finish        ec_GFp_simple_grp_clear_finish\n#  undef ec_GFp_simple_group_set_generator\n#  define ec_GFp_simple_group_set_generator       ec_GFp_simple_grp_set_generator\n#  undef ec_GFp_simple_group_get0_generator\n#  define ec_GFp_simple_group_get0_generator      ec_GFp_simple_grp_gt0_generator\n#  undef ec_GFp_simple_group_get_cofactor\n#  define ec_GFp_simple_group_get_cofactor        ec_GFp_simple_grp_get_cofactor\n#  undef ec_GFp_simple_point_clear_finish\n#  define ec_GFp_simple_point_clear_finish        ec_GFp_simple_pt_clear_finish\n#  undef ec_GFp_simple_point_set_to_infinity\n#  define ec_GFp_simple_point_set_to_infinity     ec_GFp_simple_pt_set_to_inf\n#  undef ec_GFp_simple_points_make_affine\n#  define ec_GFp_simple_points_make_affine        ec_GFp_simple_pts_make_affine\n#  undef ec_GFp_simple_set_Jprojective_coordinates_GFp\n#  define ec_GFp_simple_set_Jprojective_coordinates_GFp \\\n                                                ec_GFp_smp_set_Jproj_coords_GFp\n#  undef ec_GFp_simple_get_Jprojective_coordinates_GFp\n#  define ec_GFp_simple_get_Jprojective_coordinates_GFp \\\n                                                ec_GFp_smp_get_Jproj_coords_GFp\n#  undef ec_GFp_simple_point_set_affine_coordinates_GFp\n#  define ec_GFp_simple_point_set_affine_coordinates_GFp \\\n                                                ec_GFp_smp_pt_set_af_coords_GFp\n#  undef ec_GFp_simple_point_get_affine_coordinates_GFp\n#  define ec_GFp_simple_point_get_affine_coordinates_GFp \\\n                                                ec_GFp_smp_pt_get_af_coords_GFp\n#  undef ec_GFp_simple_set_compressed_coordinates_GFp\n#  define ec_GFp_simple_set_compressed_coordinates_GFp \\\n                                                ec_GFp_smp_set_compr_coords_GFp\n#  undef ec_GFp_simple_point_set_affine_coordinates\n#  define ec_GFp_simple_point_set_affine_coordinates \\\n                                                ec_GFp_smp_pt_set_af_coords\n#  undef ec_GFp_simple_point_get_affine_coordinates\n#  define ec_GFp_simple_point_get_affine_coordinates \\\n                                                ec_GFp_smp_pt_get_af_coords\n#  undef ec_GFp_simple_set_compressed_coordinates\n#  define ec_GFp_simple_set_compressed_coordinates \\\n                                                ec_GFp_smp_set_compr_coords\n#  undef ec_GFp_simple_group_check_discriminant\n#  define ec_GFp_simple_group_check_discriminant  ec_GFp_simple_grp_chk_discrim\n\n/* Hack som long STORE names */\n#  undef STORE_method_set_initialise_function\n#  define STORE_method_set_initialise_function    STORE_meth_set_initialise_fn\n#  undef STORE_method_set_cleanup_function\n#  define STORE_method_set_cleanup_function       STORE_meth_set_cleanup_fn\n#  undef STORE_method_set_generate_function\n#  define STORE_method_set_generate_function      STORE_meth_set_generate_fn\n#  undef STORE_method_set_modify_function\n#  define STORE_method_set_modify_function        STORE_meth_set_modify_fn\n#  undef STORE_method_set_revoke_function\n#  define STORE_method_set_revoke_function        STORE_meth_set_revoke_fn\n#  undef STORE_method_set_delete_function\n#  define STORE_method_set_delete_function        STORE_meth_set_delete_fn\n#  undef STORE_method_set_list_start_function\n#  define STORE_method_set_list_start_function    STORE_meth_set_list_start_fn\n#  undef STORE_method_set_list_next_function\n#  define STORE_method_set_list_next_function     STORE_meth_set_list_next_fn\n#  undef STORE_method_set_list_end_function\n#  define STORE_method_set_list_end_function      STORE_meth_set_list_end_fn\n#  undef STORE_method_set_update_store_function\n#  define STORE_method_set_update_store_function  STORE_meth_set_update_store_fn\n#  undef STORE_method_set_lock_store_function\n#  define STORE_method_set_lock_store_function    STORE_meth_set_lock_store_fn\n#  undef STORE_method_set_unlock_store_function\n#  define STORE_method_set_unlock_store_function  STORE_meth_set_unlock_store_fn\n#  undef STORE_method_get_initialise_function\n#  define STORE_method_get_initialise_function    STORE_meth_get_initialise_fn\n#  undef STORE_method_get_cleanup_function\n#  define STORE_method_get_cleanup_function       STORE_meth_get_cleanup_fn\n#  undef STORE_method_get_generate_function\n#  define STORE_method_get_generate_function      STORE_meth_get_generate_fn\n#  undef STORE_method_get_modify_function\n#  define STORE_method_get_modify_function        STORE_meth_get_modify_fn\n#  undef STORE_method_get_revoke_function\n#  define STORE_method_get_revoke_function        STORE_meth_get_revoke_fn\n#  undef STORE_method_get_delete_function\n#  define STORE_method_get_delete_function        STORE_meth_get_delete_fn\n#  undef STORE_method_get_list_start_function\n#  define STORE_method_get_list_start_function    STORE_meth_get_list_start_fn\n#  undef STORE_method_get_list_next_function\n#  define STORE_method_get_list_next_function     STORE_meth_get_list_next_fn\n#  undef STORE_method_get_list_end_function\n#  define STORE_method_get_list_end_function      STORE_meth_get_list_end_fn\n#  undef STORE_method_get_update_store_function\n#  define STORE_method_get_update_store_function  STORE_meth_get_update_store_fn\n#  undef STORE_method_get_lock_store_function\n#  define STORE_method_get_lock_store_function    STORE_meth_get_lock_store_fn\n#  undef STORE_method_get_unlock_store_function\n#  define STORE_method_get_unlock_store_function  STORE_meth_get_unlock_store_fn\n\n/* Hack some long TS names */\n#  undef TS_RESP_CTX_set_status_info_cond\n#  define TS_RESP_CTX_set_status_info_cond        TS_RESP_CTX_set_stat_info_cond\n#  undef TS_RESP_CTX_set_clock_precision_digits\n#  define TS_RESP_CTX_set_clock_precision_digits  TS_RESP_CTX_set_clk_prec_digits\n#  undef TS_CONF_set_clock_precision_digits\n#  define TS_CONF_set_clock_precision_digits      TS_CONF_set_clk_prec_digits\n\n/* Hack some long CMS names */\n#  undef CMS_RecipientInfo_ktri_get0_algs\n#  define CMS_RecipientInfo_ktri_get0_algs        CMS_RecipInfo_ktri_get0_algs\n#  undef CMS_RecipientInfo_ktri_get0_signer_id\n#  define CMS_RecipientInfo_ktri_get0_signer_id   CMS_RecipInfo_ktri_get0_sigr_id\n#  undef CMS_OtherRevocationInfoFormat_it\n#  define CMS_OtherRevocationInfoFormat_it        CMS_OtherRevocInfoFormat_it\n#  undef CMS_KeyAgreeRecipientIdentifier_it\n#  define CMS_KeyAgreeRecipientIdentifier_it      CMS_KeyAgreeRecipIdentifier_it\n#  undef CMS_OriginatorIdentifierOrKey_it\n#  define CMS_OriginatorIdentifierOrKey_it        CMS_OriginatorIdOrKey_it\n#  undef cms_SignerIdentifier_get0_signer_id\n#  define cms_SignerIdentifier_get0_signer_id     cms_SignerId_get0_signer_id\n#  undef CMS_RecipientInfo_kari_get0_orig_id\n#  define CMS_RecipientInfo_kari_get0_orig_id     CMS_RecipInfo_kari_get0_orig_id\n#  undef CMS_RecipientInfo_kari_get0_reks\n#  define CMS_RecipientInfo_kari_get0_reks        CMS_RecipInfo_kari_get0_reks\n#  undef CMS_RecipientEncryptedKey_cert_cmp\n#  define CMS_RecipientEncryptedKey_cert_cmp      CMS_RecipEncryptedKey_cert_cmp\n#  undef CMS_RecipientInfo_kari_set0_pkey\n#  define CMS_RecipientInfo_kari_set0_pkey        CMS_RecipInfo_kari_set0_pkey\n#  undef CMS_RecipientEncryptedKey_get0_id\n#  define CMS_RecipientEncryptedKey_get0_id       CMS_RecipEncryptedKey_get0_id\n#  undef CMS_RecipientInfo_kari_orig_id_cmp\n#  define CMS_RecipientInfo_kari_orig_id_cmp      CMS_RecipInfo_kari_orig_id_cmp\n\n/* Hack some long DTLS1 names */\n#  undef dtls1_retransmit_buffered_messages\n#  define dtls1_retransmit_buffered_messages      dtls1_retransmit_buffered_msgs\n\n/* Hack some long SRP names */\n#  undef SRP_generate_server_master_secret\n#  define SRP_generate_server_master_secret       SRP_gen_server_master_secret\n#  undef SRP_generate_client_master_secret\n#  define SRP_generate_client_master_secret       SRP_gen_client_master_secret\n\n/* Hack some long UI names */\n#  undef UI_method_get_prompt_constructor\n#  define UI_method_get_prompt_constructor        UI_method_get_prompt_constructr\n#  undef UI_method_set_prompt_constructor\n#  define UI_method_set_prompt_constructor        UI_method_set_prompt_constructr\n\n# endif                         /* defined OPENSSL_SYS_VMS */\n\n/* Case insensitive linking causes problems.... */\n# if defined(OPENSSL_SYS_VMS) || defined(OPENSSL_SYS_OS2)\n#  undef ERR_load_CRYPTO_strings\n#  define ERR_load_CRYPTO_strings                 ERR_load_CRYPTOlib_strings\n#  undef OCSP_crlID_new\n#  define OCSP_crlID_new                          OCSP_crlID2_new\n\n#  undef d2i_ECPARAMETERS\n#  define d2i_ECPARAMETERS                        d2i_UC_ECPARAMETERS\n#  undef i2d_ECPARAMETERS\n#  define i2d_ECPARAMETERS                        i2d_UC_ECPARAMETERS\n#  undef d2i_ECPKPARAMETERS\n#  define d2i_ECPKPARAMETERS                      d2i_UC_ECPKPARAMETERS\n#  undef i2d_ECPKPARAMETERS\n#  define i2d_ECPKPARAMETERS                      i2d_UC_ECPKPARAMETERS\n\n/*\n * These functions do not seem to exist! However, I'm paranoid... Original\n * command in x509v3.h: These functions are being redefined in another\n * directory, and clash when the linker is case-insensitive, so let's hide\n * them a little, by giving them an extra 'o' at the beginning of the name...\n */\n#  undef X509v3_cleanup_extensions\n#  define X509v3_cleanup_extensions               oX509v3_cleanup_extensions\n#  undef X509v3_add_extension\n#  define X509v3_add_extension                    oX509v3_add_extension\n#  undef X509v3_add_netscape_extensions\n#  define X509v3_add_netscape_extensions          oX509v3_add_netscape_extensions\n#  undef X509v3_add_standard_extensions\n#  define X509v3_add_standard_extensions          oX509v3_add_standard_extensions\n\n/* This one clashes with CMS_data_create */\n#  undef cms_Data_create\n#  define cms_Data_create                         priv_cms_Data_create\n\n# endif\n\n#endif                          /* ! defined HEADER_VMS_IDHACKS_H */\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/arm/include/openssl/tls1.h",
    "content": "/* ssl/tls1.h */\n/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)\n * All rights reserved.\n *\n * This package is an SSL implementation written\n * by Eric Young (eay@cryptsoft.com).\n * The implementation was written so as to conform with Netscapes SSL.\n *\n * This library is free for commercial and non-commercial use as long as\n * the following conditions are aheared to.  The following conditions\n * apply to all code found in this distribution, be it the RC4, RSA,\n * lhash, DES, etc., code; not just the SSL code.  The SSL documentation\n * included with this distribution is covered by the same copyright terms\n * except that the holder is Tim Hudson (tjh@cryptsoft.com).\n *\n * Copyright remains Eric Young's, and as such any Copyright notices in\n * the code are not to be removed.\n * If this package is used in a product, Eric Young should be given attribution\n * as the author of the parts of the library used.\n * This can be in the form of a textual message at program startup or\n * in documentation (online or textual) provided with the package.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the copyright\n *    notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in the\n *    documentation and/or other materials provided with the distribution.\n * 3. All advertising materials mentioning features or use of this software\n *    must display the following acknowledgement:\n *    \"This product includes cryptographic software written by\n *     Eric Young (eay@cryptsoft.com)\"\n *    The word 'cryptographic' can be left out if the rouines from the library\n *    being used are not cryptographic related :-).\n * 4. If you include any Windows specific code (or a derivative thereof) from\n *    the apps directory (application code) you must include an acknowledgement:\n *    \"This product includes software written by Tim Hudson (tjh@cryptsoft.com)\"\n *\n * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n * SUCH DAMAGE.\n *\n * The licence and distribution terms for any publically available version or\n * derivative of this code cannot be changed.  i.e. this code cannot simply be\n * copied and put under another distribution licence\n * [including the GNU Public Licence.]\n */\n/* ====================================================================\n * Copyright (c) 1998-2006 The OpenSSL Project.  All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n *\n * 1. Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n *\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in\n *    the documentation and/or other materials provided with the\n *    distribution.\n *\n * 3. All advertising materials mentioning features or use of this\n *    software must display the following acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit. (http://www.openssl.org/)\"\n *\n * 4. The names \"OpenSSL Toolkit\" and \"OpenSSL Project\" must not be used to\n *    endorse or promote products derived from this software without\n *    prior written permission. For written permission, please contact\n *    openssl-core@openssl.org.\n *\n * 5. Products derived from this software may not be called \"OpenSSL\"\n *    nor may \"OpenSSL\" appear in their names without prior written\n *    permission of the OpenSSL Project.\n *\n * 6. Redistributions of any form whatsoever must retain the following\n *    acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit (http://www.openssl.org/)\"\n *\n * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY\n * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\n * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR\n * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\n * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,\n * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED\n * OF THE POSSIBILITY OF SUCH DAMAGE.\n * ====================================================================\n *\n * This product includes cryptographic software written by Eric Young\n * (eay@cryptsoft.com).  This product includes software written by Tim\n * Hudson (tjh@cryptsoft.com).\n *\n */\n/* ====================================================================\n * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED.\n *\n * Portions of the attached software (\"Contribution\") are developed by\n * SUN MICROSYSTEMS, INC., and are contributed to the OpenSSL project.\n *\n * The Contribution is licensed pursuant to the OpenSSL open source\n * license provided above.\n *\n * ECC cipher suite support in OpenSSL originally written by\n * Vipul Gupta and Sumit Gupta of Sun Microsystems Laboratories.\n *\n */\n/* ====================================================================\n * Copyright 2005 Nokia. All rights reserved.\n *\n * The portions of the attached software (\"Contribution\") is developed by\n * Nokia Corporation and is licensed pursuant to the OpenSSL open source\n * license.\n *\n * The Contribution, originally written by Mika Kousa and Pasi Eronen of\n * Nokia Corporation, consists of the \"PSK\" (Pre-Shared Key) ciphersuites\n * support (see RFC 4279) to OpenSSL.\n *\n * No patent licenses or other rights except those expressly stated in\n * the OpenSSL open source license shall be deemed granted or received\n * expressly, by implication, estoppel, or otherwise.\n *\n * No assurances are provided by Nokia that the Contribution does not\n * infringe the patent or other intellectual property rights of any third\n * party or that the license provides you with all the necessary rights\n * to make use of the Contribution.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\" WITHOUT WARRANTY OF ANY KIND. IN\n * ADDITION TO THE DISCLAIMERS INCLUDED IN THE LICENSE, NOKIA\n * SPECIFICALLY DISCLAIMS ANY LIABILITY FOR CLAIMS BROUGHT BY YOU OR ANY\n * OTHER ENTITY BASED ON INFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS OR\n * OTHERWISE.\n */\n\n#ifndef HEADER_TLS1_H\n# define HEADER_TLS1_H\n\n# include <openssl/buffer.h>\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n# define TLS1_ALLOW_EXPERIMENTAL_CIPHERSUITES    0\n\n# define TLS1_VERSION                    0x0301\n# define TLS1_1_VERSION                  0x0302\n# define TLS1_2_VERSION                  0x0303\n# define TLS_MAX_VERSION                 TLS1_2_VERSION\n\n# define TLS1_VERSION_MAJOR              0x03\n# define TLS1_VERSION_MINOR              0x01\n\n# define TLS1_1_VERSION_MAJOR            0x03\n# define TLS1_1_VERSION_MINOR            0x02\n\n# define TLS1_2_VERSION_MAJOR            0x03\n# define TLS1_2_VERSION_MINOR            0x03\n\n# define TLS1_get_version(s) \\\n                ((s->version >> 8) == TLS1_VERSION_MAJOR ? s->version : 0)\n\n# define TLS1_get_client_version(s) \\\n                ((s->client_version >> 8) == TLS1_VERSION_MAJOR ? s->client_version : 0)\n\n# define TLS1_AD_DECRYPTION_FAILED       21\n# define TLS1_AD_RECORD_OVERFLOW         22\n# define TLS1_AD_UNKNOWN_CA              48/* fatal */\n# define TLS1_AD_ACCESS_DENIED           49/* fatal */\n# define TLS1_AD_DECODE_ERROR            50/* fatal */\n# define TLS1_AD_DECRYPT_ERROR           51\n# define TLS1_AD_EXPORT_RESTRICTION      60/* fatal */\n# define TLS1_AD_PROTOCOL_VERSION        70/* fatal */\n# define TLS1_AD_INSUFFICIENT_SECURITY   71/* fatal */\n# define TLS1_AD_INTERNAL_ERROR          80/* fatal */\n# define TLS1_AD_INAPPROPRIATE_FALLBACK  86/* fatal */\n# define TLS1_AD_USER_CANCELLED          90\n# define TLS1_AD_NO_RENEGOTIATION        100\n/* codes 110-114 are from RFC3546 */\n# define TLS1_AD_UNSUPPORTED_EXTENSION   110\n# define TLS1_AD_CERTIFICATE_UNOBTAINABLE 111\n# define TLS1_AD_UNRECOGNIZED_NAME       112\n# define TLS1_AD_BAD_CERTIFICATE_STATUS_RESPONSE 113\n# define TLS1_AD_BAD_CERTIFICATE_HASH_VALUE 114\n# define TLS1_AD_UNKNOWN_PSK_IDENTITY    115/* fatal */\n\n/* ExtensionType values from RFC3546 / RFC4366 / RFC6066 */\n# define TLSEXT_TYPE_server_name                 0\n# define TLSEXT_TYPE_max_fragment_length         1\n# define TLSEXT_TYPE_client_certificate_url      2\n# define TLSEXT_TYPE_trusted_ca_keys             3\n# define TLSEXT_TYPE_truncated_hmac              4\n# define TLSEXT_TYPE_status_request              5\n/* ExtensionType values from RFC4681 */\n# define TLSEXT_TYPE_user_mapping                6\n/* ExtensionType values from RFC5878 */\n# define TLSEXT_TYPE_client_authz                7\n# define TLSEXT_TYPE_server_authz                8\n/* ExtensionType values from RFC6091 */\n# define TLSEXT_TYPE_cert_type           9\n\n/* ExtensionType values from RFC4492 */\n# define TLSEXT_TYPE_elliptic_curves             10\n# define TLSEXT_TYPE_ec_point_formats            11\n\n/* ExtensionType value from RFC5054 */\n# define TLSEXT_TYPE_srp                         12\n\n/* ExtensionType values from RFC5246 */\n# define TLSEXT_TYPE_signature_algorithms        13\n\n/* ExtensionType value from RFC5764 */\n# define TLSEXT_TYPE_use_srtp    14\n\n/* ExtensionType value from RFC5620 */\n# define TLSEXT_TYPE_heartbeat   15\n\n/* ExtensionType value from RFC7301 */\n# define TLSEXT_TYPE_application_layer_protocol_negotiation 16\n\n/*\n * ExtensionType value for TLS padding extension.\n * http://tools.ietf.org/html/draft-agl-tls-padding\n */\n# define TLSEXT_TYPE_padding     21\n\n/* ExtensionType value from RFC4507 */\n# define TLSEXT_TYPE_session_ticket              35\n\n/* ExtensionType value from draft-rescorla-tls-opaque-prf-input-00.txt */\n# if 0\n/*\n * will have to be provided externally for now ,\n * i.e. build with -DTLSEXT_TYPE_opaque_prf_input=38183\n * using whatever extension number you'd like to try\n */\n#  define TLSEXT_TYPE_opaque_prf_input           ??\n# endif\n\n/* Temporary extension type */\n# define TLSEXT_TYPE_renegotiate                 0xff01\n\n# ifndef OPENSSL_NO_NEXTPROTONEG\n/* This is not an IANA defined extension number */\n#  define TLSEXT_TYPE_next_proto_neg              13172\n# endif\n\n/* NameType value from RFC3546 */\n# define TLSEXT_NAMETYPE_host_name 0\n/* status request value from RFC3546 */\n# define TLSEXT_STATUSTYPE_ocsp 1\n\n/* ECPointFormat values from RFC4492 */\n# define TLSEXT_ECPOINTFORMAT_first                      0\n# define TLSEXT_ECPOINTFORMAT_uncompressed               0\n# define TLSEXT_ECPOINTFORMAT_ansiX962_compressed_prime  1\n# define TLSEXT_ECPOINTFORMAT_ansiX962_compressed_char2  2\n# define TLSEXT_ECPOINTFORMAT_last                       2\n\n/* Signature and hash algorithms from RFC5246 */\n# define TLSEXT_signature_anonymous                      0\n# define TLSEXT_signature_rsa                            1\n# define TLSEXT_signature_dsa                            2\n# define TLSEXT_signature_ecdsa                          3\n\n/* Total number of different signature algorithms */\n# define TLSEXT_signature_num                            4\n\n# define TLSEXT_hash_none                                0\n# define TLSEXT_hash_md5                                 1\n# define TLSEXT_hash_sha1                                2\n# define TLSEXT_hash_sha224                              3\n# define TLSEXT_hash_sha256                              4\n# define TLSEXT_hash_sha384                              5\n# define TLSEXT_hash_sha512                              6\n\n/* Total number of different digest algorithms */\n\n# define TLSEXT_hash_num                                 7\n\n/* Flag set for unrecognised algorithms */\n# define TLSEXT_nid_unknown                              0x1000000\n\n/* ECC curves */\n\n# define TLSEXT_curve_P_256                              23\n# define TLSEXT_curve_P_384                              24\n\n# ifndef OPENSSL_NO_TLSEXT\n\n#  define TLSEXT_MAXLEN_host_name 255\n\nconst char *SSL_get_servername(const SSL *s, const int type);\nint SSL_get_servername_type(const SSL *s);\n/*\n * SSL_export_keying_material exports a value derived from the master secret,\n * as specified in RFC 5705. It writes |olen| bytes to |out| given a label and\n * optional context. (Since a zero length context is allowed, the |use_context|\n * flag controls whether a context is included.) It returns 1 on success and\n * zero otherwise.\n */\nint SSL_export_keying_material(SSL *s, unsigned char *out, size_t olen,\n                               const char *label, size_t llen,\n                               const unsigned char *p, size_t plen,\n                               int use_context);\n\nint SSL_get_sigalgs(SSL *s, int idx,\n                    int *psign, int *phash, int *psignandhash,\n                    unsigned char *rsig, unsigned char *rhash);\n\nint SSL_get_shared_sigalgs(SSL *s, int idx,\n                           int *psign, int *phash, int *psignandhash,\n                           unsigned char *rsig, unsigned char *rhash);\n\nint SSL_check_chain(SSL *s, X509 *x, EVP_PKEY *pk, STACK_OF(X509) *chain);\n\n#  define SSL_set_tlsext_host_name(s,name) \\\nSSL_ctrl(s,SSL_CTRL_SET_TLSEXT_HOSTNAME,TLSEXT_NAMETYPE_host_name,(char *)name)\n\n#  define SSL_set_tlsext_debug_callback(ssl, cb) \\\nSSL_callback_ctrl(ssl,SSL_CTRL_SET_TLSEXT_DEBUG_CB,(void (*)(void))cb)\n\n#  define SSL_set_tlsext_debug_arg(ssl, arg) \\\nSSL_ctrl(ssl,SSL_CTRL_SET_TLSEXT_DEBUG_ARG,0, (void *)arg)\n\n#  define SSL_set_tlsext_status_type(ssl, type) \\\nSSL_ctrl(ssl,SSL_CTRL_SET_TLSEXT_STATUS_REQ_TYPE,type, NULL)\n\n#  define SSL_get_tlsext_status_exts(ssl, arg) \\\nSSL_ctrl(ssl,SSL_CTRL_GET_TLSEXT_STATUS_REQ_EXTS,0, (void *)arg)\n\n#  define SSL_set_tlsext_status_exts(ssl, arg) \\\nSSL_ctrl(ssl,SSL_CTRL_SET_TLSEXT_STATUS_REQ_EXTS,0, (void *)arg)\n\n#  define SSL_get_tlsext_status_ids(ssl, arg) \\\nSSL_ctrl(ssl,SSL_CTRL_GET_TLSEXT_STATUS_REQ_IDS,0, (void *)arg)\n\n#  define SSL_set_tlsext_status_ids(ssl, arg) \\\nSSL_ctrl(ssl,SSL_CTRL_SET_TLSEXT_STATUS_REQ_IDS,0, (void *)arg)\n\n#  define SSL_get_tlsext_status_ocsp_resp(ssl, arg) \\\nSSL_ctrl(ssl,SSL_CTRL_GET_TLSEXT_STATUS_REQ_OCSP_RESP,0, (void *)arg)\n\n#  define SSL_set_tlsext_status_ocsp_resp(ssl, arg, arglen) \\\nSSL_ctrl(ssl,SSL_CTRL_SET_TLSEXT_STATUS_REQ_OCSP_RESP,arglen, (void *)arg)\n\n#  define SSL_CTX_set_tlsext_servername_callback(ctx, cb) \\\nSSL_CTX_callback_ctrl(ctx,SSL_CTRL_SET_TLSEXT_SERVERNAME_CB,(void (*)(void))cb)\n\n#  define SSL_TLSEXT_ERR_OK 0\n#  define SSL_TLSEXT_ERR_ALERT_WARNING 1\n#  define SSL_TLSEXT_ERR_ALERT_FATAL 2\n#  define SSL_TLSEXT_ERR_NOACK 3\n\n#  define SSL_CTX_set_tlsext_servername_arg(ctx, arg) \\\nSSL_CTX_ctrl(ctx,SSL_CTRL_SET_TLSEXT_SERVERNAME_ARG,0, (void *)arg)\n\n#  define SSL_CTX_get_tlsext_ticket_keys(ctx, keys, keylen) \\\n        SSL_CTX_ctrl((ctx),SSL_CTRL_GET_TLSEXT_TICKET_KEYS,(keylen),(keys))\n#  define SSL_CTX_set_tlsext_ticket_keys(ctx, keys, keylen) \\\n        SSL_CTX_ctrl((ctx),SSL_CTRL_SET_TLSEXT_TICKET_KEYS,(keylen),(keys))\n\n#  define SSL_CTX_set_tlsext_status_cb(ssl, cb) \\\nSSL_CTX_callback_ctrl(ssl,SSL_CTRL_SET_TLSEXT_STATUS_REQ_CB,(void (*)(void))cb)\n\n#  define SSL_CTX_set_tlsext_status_arg(ssl, arg) \\\nSSL_CTX_ctrl(ssl,SSL_CTRL_SET_TLSEXT_STATUS_REQ_CB_ARG,0, (void *)arg)\n\n#  define SSL_set_tlsext_opaque_prf_input(s, src, len) \\\nSSL_ctrl(s,SSL_CTRL_SET_TLSEXT_OPAQUE_PRF_INPUT, len, src)\n#  define SSL_CTX_set_tlsext_opaque_prf_input_callback(ctx, cb) \\\nSSL_CTX_callback_ctrl(ctx,SSL_CTRL_SET_TLSEXT_OPAQUE_PRF_INPUT_CB, (void (*)(void))cb)\n#  define SSL_CTX_set_tlsext_opaque_prf_input_callback_arg(ctx, arg) \\\nSSL_CTX_ctrl(ctx,SSL_CTRL_SET_TLSEXT_OPAQUE_PRF_INPUT_CB_ARG, 0, arg)\n\n#  define SSL_CTX_set_tlsext_ticket_key_cb(ssl, cb) \\\nSSL_CTX_callback_ctrl(ssl,SSL_CTRL_SET_TLSEXT_TICKET_KEY_CB,(void (*)(void))cb)\n\n#  ifndef OPENSSL_NO_HEARTBEATS\n#   define SSL_TLSEXT_HB_ENABLED                           0x01\n#   define SSL_TLSEXT_HB_DONT_SEND_REQUESTS        0x02\n#   define SSL_TLSEXT_HB_DONT_RECV_REQUESTS        0x04\n\n#   define SSL_get_tlsext_heartbeat_pending(ssl) \\\n        SSL_ctrl((ssl),SSL_CTRL_GET_TLS_EXT_HEARTBEAT_PENDING,0,NULL)\n#   define SSL_set_tlsext_heartbeat_no_requests(ssl, arg) \\\n        SSL_ctrl((ssl),SSL_CTRL_SET_TLS_EXT_HEARTBEAT_NO_REQUESTS,arg,NULL)\n#  endif\n# endif\n\n/* PSK ciphersuites from 4279 */\n# define TLS1_CK_PSK_WITH_RC4_128_SHA                    0x0300008A\n# define TLS1_CK_PSK_WITH_3DES_EDE_CBC_SHA               0x0300008B\n# define TLS1_CK_PSK_WITH_AES_128_CBC_SHA                0x0300008C\n# define TLS1_CK_PSK_WITH_AES_256_CBC_SHA                0x0300008D\n\n/*\n * Additional TLS ciphersuites from expired Internet Draft\n * draft-ietf-tls-56-bit-ciphersuites-01.txt (available if\n * TLS1_ALLOW_EXPERIMENTAL_CIPHERSUITES is defined, see s3_lib.c).  We\n * actually treat them like SSL 3.0 ciphers, which we probably shouldn't.\n * Note that the first two are actually not in the IDs.\n */\n# define TLS1_CK_RSA_EXPORT1024_WITH_RC4_56_MD5          0x03000060/* not in\n                                                                    * ID */\n# define TLS1_CK_RSA_EXPORT1024_WITH_RC2_CBC_56_MD5      0x03000061/* not in\n                                                                    * ID */\n# define TLS1_CK_RSA_EXPORT1024_WITH_DES_CBC_SHA         0x03000062\n# define TLS1_CK_DHE_DSS_EXPORT1024_WITH_DES_CBC_SHA     0x03000063\n# define TLS1_CK_RSA_EXPORT1024_WITH_RC4_56_SHA          0x03000064\n# define TLS1_CK_DHE_DSS_EXPORT1024_WITH_RC4_56_SHA      0x03000065\n# define TLS1_CK_DHE_DSS_WITH_RC4_128_SHA                0x03000066\n\n/* AES ciphersuites from RFC3268 */\n# define TLS1_CK_RSA_WITH_AES_128_SHA                    0x0300002F\n# define TLS1_CK_DH_DSS_WITH_AES_128_SHA                 0x03000030\n# define TLS1_CK_DH_RSA_WITH_AES_128_SHA                 0x03000031\n# define TLS1_CK_DHE_DSS_WITH_AES_128_SHA                0x03000032\n# define TLS1_CK_DHE_RSA_WITH_AES_128_SHA                0x03000033\n# define TLS1_CK_ADH_WITH_AES_128_SHA                    0x03000034\n\n# define TLS1_CK_RSA_WITH_AES_256_SHA                    0x03000035\n# define TLS1_CK_DH_DSS_WITH_AES_256_SHA                 0x03000036\n# define TLS1_CK_DH_RSA_WITH_AES_256_SHA                 0x03000037\n# define TLS1_CK_DHE_DSS_WITH_AES_256_SHA                0x03000038\n# define TLS1_CK_DHE_RSA_WITH_AES_256_SHA                0x03000039\n# define TLS1_CK_ADH_WITH_AES_256_SHA                    0x0300003A\n\n/* TLS v1.2 ciphersuites */\n# define TLS1_CK_RSA_WITH_NULL_SHA256                    0x0300003B\n# define TLS1_CK_RSA_WITH_AES_128_SHA256                 0x0300003C\n# define TLS1_CK_RSA_WITH_AES_256_SHA256                 0x0300003D\n# define TLS1_CK_DH_DSS_WITH_AES_128_SHA256              0x0300003E\n# define TLS1_CK_DH_RSA_WITH_AES_128_SHA256              0x0300003F\n# define TLS1_CK_DHE_DSS_WITH_AES_128_SHA256             0x03000040\n\n/* Camellia ciphersuites from RFC4132 */\n# define TLS1_CK_RSA_WITH_CAMELLIA_128_CBC_SHA           0x03000041\n# define TLS1_CK_DH_DSS_WITH_CAMELLIA_128_CBC_SHA        0x03000042\n# define TLS1_CK_DH_RSA_WITH_CAMELLIA_128_CBC_SHA        0x03000043\n# define TLS1_CK_DHE_DSS_WITH_CAMELLIA_128_CBC_SHA       0x03000044\n# define TLS1_CK_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA       0x03000045\n# define TLS1_CK_ADH_WITH_CAMELLIA_128_CBC_SHA           0x03000046\n\n/* TLS v1.2 ciphersuites */\n# define TLS1_CK_DHE_RSA_WITH_AES_128_SHA256             0x03000067\n# define TLS1_CK_DH_DSS_WITH_AES_256_SHA256              0x03000068\n# define TLS1_CK_DH_RSA_WITH_AES_256_SHA256              0x03000069\n# define TLS1_CK_DHE_DSS_WITH_AES_256_SHA256             0x0300006A\n# define TLS1_CK_DHE_RSA_WITH_AES_256_SHA256             0x0300006B\n# define TLS1_CK_ADH_WITH_AES_128_SHA256                 0x0300006C\n# define TLS1_CK_ADH_WITH_AES_256_SHA256                 0x0300006D\n\n/* Camellia ciphersuites from RFC4132 */\n# define TLS1_CK_RSA_WITH_CAMELLIA_256_CBC_SHA           0x03000084\n# define TLS1_CK_DH_DSS_WITH_CAMELLIA_256_CBC_SHA        0x03000085\n# define TLS1_CK_DH_RSA_WITH_CAMELLIA_256_CBC_SHA        0x03000086\n# define TLS1_CK_DHE_DSS_WITH_CAMELLIA_256_CBC_SHA       0x03000087\n# define TLS1_CK_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA       0x03000088\n# define TLS1_CK_ADH_WITH_CAMELLIA_256_CBC_SHA           0x03000089\n\n/* SEED ciphersuites from RFC4162 */\n# define TLS1_CK_RSA_WITH_SEED_SHA                       0x03000096\n# define TLS1_CK_DH_DSS_WITH_SEED_SHA                    0x03000097\n# define TLS1_CK_DH_RSA_WITH_SEED_SHA                    0x03000098\n# define TLS1_CK_DHE_DSS_WITH_SEED_SHA                   0x03000099\n# define TLS1_CK_DHE_RSA_WITH_SEED_SHA                   0x0300009A\n# define TLS1_CK_ADH_WITH_SEED_SHA                       0x0300009B\n\n/* TLS v1.2 GCM ciphersuites from RFC5288 */\n# define TLS1_CK_RSA_WITH_AES_128_GCM_SHA256             0x0300009C\n# define TLS1_CK_RSA_WITH_AES_256_GCM_SHA384             0x0300009D\n# define TLS1_CK_DHE_RSA_WITH_AES_128_GCM_SHA256         0x0300009E\n# define TLS1_CK_DHE_RSA_WITH_AES_256_GCM_SHA384         0x0300009F\n# define TLS1_CK_DH_RSA_WITH_AES_128_GCM_SHA256          0x030000A0\n# define TLS1_CK_DH_RSA_WITH_AES_256_GCM_SHA384          0x030000A1\n# define TLS1_CK_DHE_DSS_WITH_AES_128_GCM_SHA256         0x030000A2\n# define TLS1_CK_DHE_DSS_WITH_AES_256_GCM_SHA384         0x030000A3\n# define TLS1_CK_DH_DSS_WITH_AES_128_GCM_SHA256          0x030000A4\n# define TLS1_CK_DH_DSS_WITH_AES_256_GCM_SHA384          0x030000A5\n# define TLS1_CK_ADH_WITH_AES_128_GCM_SHA256             0x030000A6\n# define TLS1_CK_ADH_WITH_AES_256_GCM_SHA384             0x030000A7\n\n/*\n * ECC ciphersuites from draft-ietf-tls-ecc-12.txt with changes soon to be in\n * draft 13\n */\n# define TLS1_CK_ECDH_ECDSA_WITH_NULL_SHA                0x0300C001\n# define TLS1_CK_ECDH_ECDSA_WITH_RC4_128_SHA             0x0300C002\n# define TLS1_CK_ECDH_ECDSA_WITH_DES_192_CBC3_SHA        0x0300C003\n# define TLS1_CK_ECDH_ECDSA_WITH_AES_128_CBC_SHA         0x0300C004\n# define TLS1_CK_ECDH_ECDSA_WITH_AES_256_CBC_SHA         0x0300C005\n\n# define TLS1_CK_ECDHE_ECDSA_WITH_NULL_SHA               0x0300C006\n# define TLS1_CK_ECDHE_ECDSA_WITH_RC4_128_SHA            0x0300C007\n# define TLS1_CK_ECDHE_ECDSA_WITH_DES_192_CBC3_SHA       0x0300C008\n# define TLS1_CK_ECDHE_ECDSA_WITH_AES_128_CBC_SHA        0x0300C009\n# define TLS1_CK_ECDHE_ECDSA_WITH_AES_256_CBC_SHA        0x0300C00A\n\n# define TLS1_CK_ECDH_RSA_WITH_NULL_SHA                  0x0300C00B\n# define TLS1_CK_ECDH_RSA_WITH_RC4_128_SHA               0x0300C00C\n# define TLS1_CK_ECDH_RSA_WITH_DES_192_CBC3_SHA          0x0300C00D\n# define TLS1_CK_ECDH_RSA_WITH_AES_128_CBC_SHA           0x0300C00E\n# define TLS1_CK_ECDH_RSA_WITH_AES_256_CBC_SHA           0x0300C00F\n\n# define TLS1_CK_ECDHE_RSA_WITH_NULL_SHA                 0x0300C010\n# define TLS1_CK_ECDHE_RSA_WITH_RC4_128_SHA              0x0300C011\n# define TLS1_CK_ECDHE_RSA_WITH_DES_192_CBC3_SHA         0x0300C012\n# define TLS1_CK_ECDHE_RSA_WITH_AES_128_CBC_SHA          0x0300C013\n# define TLS1_CK_ECDHE_RSA_WITH_AES_256_CBC_SHA          0x0300C014\n\n# define TLS1_CK_ECDH_anon_WITH_NULL_SHA                 0x0300C015\n# define TLS1_CK_ECDH_anon_WITH_RC4_128_SHA              0x0300C016\n# define TLS1_CK_ECDH_anon_WITH_DES_192_CBC3_SHA         0x0300C017\n# define TLS1_CK_ECDH_anon_WITH_AES_128_CBC_SHA          0x0300C018\n# define TLS1_CK_ECDH_anon_WITH_AES_256_CBC_SHA          0x0300C019\n\n/* SRP ciphersuites from RFC 5054 */\n# define TLS1_CK_SRP_SHA_WITH_3DES_EDE_CBC_SHA           0x0300C01A\n# define TLS1_CK_SRP_SHA_RSA_WITH_3DES_EDE_CBC_SHA       0x0300C01B\n# define TLS1_CK_SRP_SHA_DSS_WITH_3DES_EDE_CBC_SHA       0x0300C01C\n# define TLS1_CK_SRP_SHA_WITH_AES_128_CBC_SHA            0x0300C01D\n# define TLS1_CK_SRP_SHA_RSA_WITH_AES_128_CBC_SHA        0x0300C01E\n# define TLS1_CK_SRP_SHA_DSS_WITH_AES_128_CBC_SHA        0x0300C01F\n# define TLS1_CK_SRP_SHA_WITH_AES_256_CBC_SHA            0x0300C020\n# define TLS1_CK_SRP_SHA_RSA_WITH_AES_256_CBC_SHA        0x0300C021\n# define TLS1_CK_SRP_SHA_DSS_WITH_AES_256_CBC_SHA        0x0300C022\n\n/* ECDH HMAC based ciphersuites from RFC5289 */\n\n# define TLS1_CK_ECDHE_ECDSA_WITH_AES_128_SHA256         0x0300C023\n# define TLS1_CK_ECDHE_ECDSA_WITH_AES_256_SHA384         0x0300C024\n# define TLS1_CK_ECDH_ECDSA_WITH_AES_128_SHA256          0x0300C025\n# define TLS1_CK_ECDH_ECDSA_WITH_AES_256_SHA384          0x0300C026\n# define TLS1_CK_ECDHE_RSA_WITH_AES_128_SHA256           0x0300C027\n# define TLS1_CK_ECDHE_RSA_WITH_AES_256_SHA384           0x0300C028\n# define TLS1_CK_ECDH_RSA_WITH_AES_128_SHA256            0x0300C029\n# define TLS1_CK_ECDH_RSA_WITH_AES_256_SHA384            0x0300C02A\n\n/* ECDH GCM based ciphersuites from RFC5289 */\n# define TLS1_CK_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256     0x0300C02B\n# define TLS1_CK_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384     0x0300C02C\n# define TLS1_CK_ECDH_ECDSA_WITH_AES_128_GCM_SHA256      0x0300C02D\n# define TLS1_CK_ECDH_ECDSA_WITH_AES_256_GCM_SHA384      0x0300C02E\n# define TLS1_CK_ECDHE_RSA_WITH_AES_128_GCM_SHA256       0x0300C02F\n# define TLS1_CK_ECDHE_RSA_WITH_AES_256_GCM_SHA384       0x0300C030\n# define TLS1_CK_ECDH_RSA_WITH_AES_128_GCM_SHA256        0x0300C031\n# define TLS1_CK_ECDH_RSA_WITH_AES_256_GCM_SHA384        0x0300C032\n\n/*\n * XXX * Backward compatibility alert: + * Older versions of OpenSSL gave\n * some DHE ciphers names with \"EDH\" + * instead of \"DHE\".  Going forward, we\n * should be using DHE + * everywhere, though we may indefinitely maintain\n * aliases for users + * or configurations that used \"EDH\" +\n */\n# define TLS1_TXT_RSA_EXPORT1024_WITH_RC4_56_MD5         \"EXP1024-RC4-MD5\"\n# define TLS1_TXT_RSA_EXPORT1024_WITH_RC2_CBC_56_MD5     \"EXP1024-RC2-CBC-MD5\"\n# define TLS1_TXT_RSA_EXPORT1024_WITH_DES_CBC_SHA        \"EXP1024-DES-CBC-SHA\"\n# define TLS1_TXT_DHE_DSS_EXPORT1024_WITH_DES_CBC_SHA    \"EXP1024-DHE-DSS-DES-CBC-SHA\"\n# define TLS1_TXT_RSA_EXPORT1024_WITH_RC4_56_SHA         \"EXP1024-RC4-SHA\"\n# define TLS1_TXT_DHE_DSS_EXPORT1024_WITH_RC4_56_SHA     \"EXP1024-DHE-DSS-RC4-SHA\"\n# define TLS1_TXT_DHE_DSS_WITH_RC4_128_SHA               \"DHE-DSS-RC4-SHA\"\n\n/* AES ciphersuites from RFC3268 */\n# define TLS1_TXT_RSA_WITH_AES_128_SHA                   \"AES128-SHA\"\n# define TLS1_TXT_DH_DSS_WITH_AES_128_SHA                \"DH-DSS-AES128-SHA\"\n# define TLS1_TXT_DH_RSA_WITH_AES_128_SHA                \"DH-RSA-AES128-SHA\"\n# define TLS1_TXT_DHE_DSS_WITH_AES_128_SHA               \"DHE-DSS-AES128-SHA\"\n# define TLS1_TXT_DHE_RSA_WITH_AES_128_SHA               \"DHE-RSA-AES128-SHA\"\n# define TLS1_TXT_ADH_WITH_AES_128_SHA                   \"ADH-AES128-SHA\"\n\n# define TLS1_TXT_RSA_WITH_AES_256_SHA                   \"AES256-SHA\"\n# define TLS1_TXT_DH_DSS_WITH_AES_256_SHA                \"DH-DSS-AES256-SHA\"\n# define TLS1_TXT_DH_RSA_WITH_AES_256_SHA                \"DH-RSA-AES256-SHA\"\n# define TLS1_TXT_DHE_DSS_WITH_AES_256_SHA               \"DHE-DSS-AES256-SHA\"\n# define TLS1_TXT_DHE_RSA_WITH_AES_256_SHA               \"DHE-RSA-AES256-SHA\"\n# define TLS1_TXT_ADH_WITH_AES_256_SHA                   \"ADH-AES256-SHA\"\n\n/* ECC ciphersuites from RFC4492 */\n# define TLS1_TXT_ECDH_ECDSA_WITH_NULL_SHA               \"ECDH-ECDSA-NULL-SHA\"\n# define TLS1_TXT_ECDH_ECDSA_WITH_RC4_128_SHA            \"ECDH-ECDSA-RC4-SHA\"\n# define TLS1_TXT_ECDH_ECDSA_WITH_DES_192_CBC3_SHA       \"ECDH-ECDSA-DES-CBC3-SHA\"\n# define TLS1_TXT_ECDH_ECDSA_WITH_AES_128_CBC_SHA        \"ECDH-ECDSA-AES128-SHA\"\n# define TLS1_TXT_ECDH_ECDSA_WITH_AES_256_CBC_SHA        \"ECDH-ECDSA-AES256-SHA\"\n\n# define TLS1_TXT_ECDHE_ECDSA_WITH_NULL_SHA              \"ECDHE-ECDSA-NULL-SHA\"\n# define TLS1_TXT_ECDHE_ECDSA_WITH_RC4_128_SHA           \"ECDHE-ECDSA-RC4-SHA\"\n# define TLS1_TXT_ECDHE_ECDSA_WITH_DES_192_CBC3_SHA      \"ECDHE-ECDSA-DES-CBC3-SHA\"\n# define TLS1_TXT_ECDHE_ECDSA_WITH_AES_128_CBC_SHA       \"ECDHE-ECDSA-AES128-SHA\"\n# define TLS1_TXT_ECDHE_ECDSA_WITH_AES_256_CBC_SHA       \"ECDHE-ECDSA-AES256-SHA\"\n\n# define TLS1_TXT_ECDH_RSA_WITH_NULL_SHA                 \"ECDH-RSA-NULL-SHA\"\n# define TLS1_TXT_ECDH_RSA_WITH_RC4_128_SHA              \"ECDH-RSA-RC4-SHA\"\n# define TLS1_TXT_ECDH_RSA_WITH_DES_192_CBC3_SHA         \"ECDH-RSA-DES-CBC3-SHA\"\n# define TLS1_TXT_ECDH_RSA_WITH_AES_128_CBC_SHA          \"ECDH-RSA-AES128-SHA\"\n# define TLS1_TXT_ECDH_RSA_WITH_AES_256_CBC_SHA          \"ECDH-RSA-AES256-SHA\"\n\n# define TLS1_TXT_ECDHE_RSA_WITH_NULL_SHA                \"ECDHE-RSA-NULL-SHA\"\n# define TLS1_TXT_ECDHE_RSA_WITH_RC4_128_SHA             \"ECDHE-RSA-RC4-SHA\"\n# define TLS1_TXT_ECDHE_RSA_WITH_DES_192_CBC3_SHA        \"ECDHE-RSA-DES-CBC3-SHA\"\n# define TLS1_TXT_ECDHE_RSA_WITH_AES_128_CBC_SHA         \"ECDHE-RSA-AES128-SHA\"\n# define TLS1_TXT_ECDHE_RSA_WITH_AES_256_CBC_SHA         \"ECDHE-RSA-AES256-SHA\"\n\n# define TLS1_TXT_ECDH_anon_WITH_NULL_SHA                \"AECDH-NULL-SHA\"\n# define TLS1_TXT_ECDH_anon_WITH_RC4_128_SHA             \"AECDH-RC4-SHA\"\n# define TLS1_TXT_ECDH_anon_WITH_DES_192_CBC3_SHA        \"AECDH-DES-CBC3-SHA\"\n# define TLS1_TXT_ECDH_anon_WITH_AES_128_CBC_SHA         \"AECDH-AES128-SHA\"\n# define TLS1_TXT_ECDH_anon_WITH_AES_256_CBC_SHA         \"AECDH-AES256-SHA\"\n\n/* PSK ciphersuites from RFC 4279 */\n# define TLS1_TXT_PSK_WITH_RC4_128_SHA                   \"PSK-RC4-SHA\"\n# define TLS1_TXT_PSK_WITH_3DES_EDE_CBC_SHA              \"PSK-3DES-EDE-CBC-SHA\"\n# define TLS1_TXT_PSK_WITH_AES_128_CBC_SHA               \"PSK-AES128-CBC-SHA\"\n# define TLS1_TXT_PSK_WITH_AES_256_CBC_SHA               \"PSK-AES256-CBC-SHA\"\n\n/* SRP ciphersuite from RFC 5054 */\n# define TLS1_TXT_SRP_SHA_WITH_3DES_EDE_CBC_SHA          \"SRP-3DES-EDE-CBC-SHA\"\n# define TLS1_TXT_SRP_SHA_RSA_WITH_3DES_EDE_CBC_SHA      \"SRP-RSA-3DES-EDE-CBC-SHA\"\n# define TLS1_TXT_SRP_SHA_DSS_WITH_3DES_EDE_CBC_SHA      \"SRP-DSS-3DES-EDE-CBC-SHA\"\n# define TLS1_TXT_SRP_SHA_WITH_AES_128_CBC_SHA           \"SRP-AES-128-CBC-SHA\"\n# define TLS1_TXT_SRP_SHA_RSA_WITH_AES_128_CBC_SHA       \"SRP-RSA-AES-128-CBC-SHA\"\n# define TLS1_TXT_SRP_SHA_DSS_WITH_AES_128_CBC_SHA       \"SRP-DSS-AES-128-CBC-SHA\"\n# define TLS1_TXT_SRP_SHA_WITH_AES_256_CBC_SHA           \"SRP-AES-256-CBC-SHA\"\n# define TLS1_TXT_SRP_SHA_RSA_WITH_AES_256_CBC_SHA       \"SRP-RSA-AES-256-CBC-SHA\"\n# define TLS1_TXT_SRP_SHA_DSS_WITH_AES_256_CBC_SHA       \"SRP-DSS-AES-256-CBC-SHA\"\n\n/* Camellia ciphersuites from RFC4132 */\n# define TLS1_TXT_RSA_WITH_CAMELLIA_128_CBC_SHA          \"CAMELLIA128-SHA\"\n# define TLS1_TXT_DH_DSS_WITH_CAMELLIA_128_CBC_SHA       \"DH-DSS-CAMELLIA128-SHA\"\n# define TLS1_TXT_DH_RSA_WITH_CAMELLIA_128_CBC_SHA       \"DH-RSA-CAMELLIA128-SHA\"\n# define TLS1_TXT_DHE_DSS_WITH_CAMELLIA_128_CBC_SHA      \"DHE-DSS-CAMELLIA128-SHA\"\n# define TLS1_TXT_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA      \"DHE-RSA-CAMELLIA128-SHA\"\n# define TLS1_TXT_ADH_WITH_CAMELLIA_128_CBC_SHA          \"ADH-CAMELLIA128-SHA\"\n\n# define TLS1_TXT_RSA_WITH_CAMELLIA_256_CBC_SHA          \"CAMELLIA256-SHA\"\n# define TLS1_TXT_DH_DSS_WITH_CAMELLIA_256_CBC_SHA       \"DH-DSS-CAMELLIA256-SHA\"\n# define TLS1_TXT_DH_RSA_WITH_CAMELLIA_256_CBC_SHA       \"DH-RSA-CAMELLIA256-SHA\"\n# define TLS1_TXT_DHE_DSS_WITH_CAMELLIA_256_CBC_SHA      \"DHE-DSS-CAMELLIA256-SHA\"\n# define TLS1_TXT_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA      \"DHE-RSA-CAMELLIA256-SHA\"\n# define TLS1_TXT_ADH_WITH_CAMELLIA_256_CBC_SHA          \"ADH-CAMELLIA256-SHA\"\n\n/* SEED ciphersuites from RFC4162 */\n# define TLS1_TXT_RSA_WITH_SEED_SHA                      \"SEED-SHA\"\n# define TLS1_TXT_DH_DSS_WITH_SEED_SHA                   \"DH-DSS-SEED-SHA\"\n# define TLS1_TXT_DH_RSA_WITH_SEED_SHA                   \"DH-RSA-SEED-SHA\"\n# define TLS1_TXT_DHE_DSS_WITH_SEED_SHA                  \"DHE-DSS-SEED-SHA\"\n# define TLS1_TXT_DHE_RSA_WITH_SEED_SHA                  \"DHE-RSA-SEED-SHA\"\n# define TLS1_TXT_ADH_WITH_SEED_SHA                      \"ADH-SEED-SHA\"\n\n/* TLS v1.2 ciphersuites */\n# define TLS1_TXT_RSA_WITH_NULL_SHA256                   \"NULL-SHA256\"\n# define TLS1_TXT_RSA_WITH_AES_128_SHA256                \"AES128-SHA256\"\n# define TLS1_TXT_RSA_WITH_AES_256_SHA256                \"AES256-SHA256\"\n# define TLS1_TXT_DH_DSS_WITH_AES_128_SHA256             \"DH-DSS-AES128-SHA256\"\n# define TLS1_TXT_DH_RSA_WITH_AES_128_SHA256             \"DH-RSA-AES128-SHA256\"\n# define TLS1_TXT_DHE_DSS_WITH_AES_128_SHA256            \"DHE-DSS-AES128-SHA256\"\n# define TLS1_TXT_DHE_RSA_WITH_AES_128_SHA256            \"DHE-RSA-AES128-SHA256\"\n# define TLS1_TXT_DH_DSS_WITH_AES_256_SHA256             \"DH-DSS-AES256-SHA256\"\n# define TLS1_TXT_DH_RSA_WITH_AES_256_SHA256             \"DH-RSA-AES256-SHA256\"\n# define TLS1_TXT_DHE_DSS_WITH_AES_256_SHA256            \"DHE-DSS-AES256-SHA256\"\n# define TLS1_TXT_DHE_RSA_WITH_AES_256_SHA256            \"DHE-RSA-AES256-SHA256\"\n# define TLS1_TXT_ADH_WITH_AES_128_SHA256                \"ADH-AES128-SHA256\"\n# define TLS1_TXT_ADH_WITH_AES_256_SHA256                \"ADH-AES256-SHA256\"\n\n/* TLS v1.2 GCM ciphersuites from RFC5288 */\n# define TLS1_TXT_RSA_WITH_AES_128_GCM_SHA256            \"AES128-GCM-SHA256\"\n# define TLS1_TXT_RSA_WITH_AES_256_GCM_SHA384            \"AES256-GCM-SHA384\"\n# define TLS1_TXT_DHE_RSA_WITH_AES_128_GCM_SHA256        \"DHE-RSA-AES128-GCM-SHA256\"\n# define TLS1_TXT_DHE_RSA_WITH_AES_256_GCM_SHA384        \"DHE-RSA-AES256-GCM-SHA384\"\n# define TLS1_TXT_DH_RSA_WITH_AES_128_GCM_SHA256         \"DH-RSA-AES128-GCM-SHA256\"\n# define TLS1_TXT_DH_RSA_WITH_AES_256_GCM_SHA384         \"DH-RSA-AES256-GCM-SHA384\"\n# define TLS1_TXT_DHE_DSS_WITH_AES_128_GCM_SHA256        \"DHE-DSS-AES128-GCM-SHA256\"\n# define TLS1_TXT_DHE_DSS_WITH_AES_256_GCM_SHA384        \"DHE-DSS-AES256-GCM-SHA384\"\n# define TLS1_TXT_DH_DSS_WITH_AES_128_GCM_SHA256         \"DH-DSS-AES128-GCM-SHA256\"\n# define TLS1_TXT_DH_DSS_WITH_AES_256_GCM_SHA384         \"DH-DSS-AES256-GCM-SHA384\"\n# define TLS1_TXT_ADH_WITH_AES_128_GCM_SHA256            \"ADH-AES128-GCM-SHA256\"\n# define TLS1_TXT_ADH_WITH_AES_256_GCM_SHA384            \"ADH-AES256-GCM-SHA384\"\n\n/* ECDH HMAC based ciphersuites from RFC5289 */\n\n# define TLS1_TXT_ECDHE_ECDSA_WITH_AES_128_SHA256    \"ECDHE-ECDSA-AES128-SHA256\"\n# define TLS1_TXT_ECDHE_ECDSA_WITH_AES_256_SHA384    \"ECDHE-ECDSA-AES256-SHA384\"\n# define TLS1_TXT_ECDH_ECDSA_WITH_AES_128_SHA256     \"ECDH-ECDSA-AES128-SHA256\"\n# define TLS1_TXT_ECDH_ECDSA_WITH_AES_256_SHA384     \"ECDH-ECDSA-AES256-SHA384\"\n# define TLS1_TXT_ECDHE_RSA_WITH_AES_128_SHA256      \"ECDHE-RSA-AES128-SHA256\"\n# define TLS1_TXT_ECDHE_RSA_WITH_AES_256_SHA384      \"ECDHE-RSA-AES256-SHA384\"\n# define TLS1_TXT_ECDH_RSA_WITH_AES_128_SHA256       \"ECDH-RSA-AES128-SHA256\"\n# define TLS1_TXT_ECDH_RSA_WITH_AES_256_SHA384       \"ECDH-RSA-AES256-SHA384\"\n\n/* ECDH GCM based ciphersuites from RFC5289 */\n# define TLS1_TXT_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256    \"ECDHE-ECDSA-AES128-GCM-SHA256\"\n# define TLS1_TXT_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384    \"ECDHE-ECDSA-AES256-GCM-SHA384\"\n# define TLS1_TXT_ECDH_ECDSA_WITH_AES_128_GCM_SHA256     \"ECDH-ECDSA-AES128-GCM-SHA256\"\n# define TLS1_TXT_ECDH_ECDSA_WITH_AES_256_GCM_SHA384     \"ECDH-ECDSA-AES256-GCM-SHA384\"\n# define TLS1_TXT_ECDHE_RSA_WITH_AES_128_GCM_SHA256      \"ECDHE-RSA-AES128-GCM-SHA256\"\n# define TLS1_TXT_ECDHE_RSA_WITH_AES_256_GCM_SHA384      \"ECDHE-RSA-AES256-GCM-SHA384\"\n# define TLS1_TXT_ECDH_RSA_WITH_AES_128_GCM_SHA256       \"ECDH-RSA-AES128-GCM-SHA256\"\n# define TLS1_TXT_ECDH_RSA_WITH_AES_256_GCM_SHA384       \"ECDH-RSA-AES256-GCM-SHA384\"\n\n# define TLS_CT_RSA_SIGN                 1\n# define TLS_CT_DSS_SIGN                 2\n# define TLS_CT_RSA_FIXED_DH             3\n# define TLS_CT_DSS_FIXED_DH             4\n# define TLS_CT_ECDSA_SIGN               64\n# define TLS_CT_RSA_FIXED_ECDH           65\n# define TLS_CT_ECDSA_FIXED_ECDH         66\n# define TLS_CT_GOST94_SIGN              21\n# define TLS_CT_GOST01_SIGN              22\n/*\n * when correcting this number, correct also SSL3_CT_NUMBER in ssl3.h (see\n * comment there)\n */\n# define TLS_CT_NUMBER                   9\n\n# define TLS1_FINISH_MAC_LENGTH          12\n\n# define TLS_MD_MAX_CONST_SIZE                   20\n# define TLS_MD_CLIENT_FINISH_CONST              \"client finished\"\n# define TLS_MD_CLIENT_FINISH_CONST_SIZE         15\n# define TLS_MD_SERVER_FINISH_CONST              \"server finished\"\n# define TLS_MD_SERVER_FINISH_CONST_SIZE         15\n# define TLS_MD_SERVER_WRITE_KEY_CONST           \"server write key\"\n# define TLS_MD_SERVER_WRITE_KEY_CONST_SIZE      16\n# define TLS_MD_KEY_EXPANSION_CONST              \"key expansion\"\n# define TLS_MD_KEY_EXPANSION_CONST_SIZE         13\n# define TLS_MD_CLIENT_WRITE_KEY_CONST           \"client write key\"\n# define TLS_MD_CLIENT_WRITE_KEY_CONST_SIZE      16\n# define TLS_MD_SERVER_WRITE_KEY_CONST           \"server write key\"\n# define TLS_MD_SERVER_WRITE_KEY_CONST_SIZE      16\n# define TLS_MD_IV_BLOCK_CONST                   \"IV block\"\n# define TLS_MD_IV_BLOCK_CONST_SIZE              8\n# define TLS_MD_MASTER_SECRET_CONST              \"master secret\"\n# define TLS_MD_MASTER_SECRET_CONST_SIZE         13\n\n# ifdef CHARSET_EBCDIC\n#  undef TLS_MD_CLIENT_FINISH_CONST\n/*\n * client finished\n */\n#  define TLS_MD_CLIENT_FINISH_CONST    \"\\x63\\x6c\\x69\\x65\\x6e\\x74\\x20\\x66\\x69\\x6e\\x69\\x73\\x68\\x65\\x64\"\n\n#  undef TLS_MD_SERVER_FINISH_CONST\n/*\n * server finished\n */\n#  define TLS_MD_SERVER_FINISH_CONST    \"\\x73\\x65\\x72\\x76\\x65\\x72\\x20\\x66\\x69\\x6e\\x69\\x73\\x68\\x65\\x64\"\n\n#  undef TLS_MD_SERVER_WRITE_KEY_CONST\n/*\n * server write key\n */\n#  define TLS_MD_SERVER_WRITE_KEY_CONST \"\\x73\\x65\\x72\\x76\\x65\\x72\\x20\\x77\\x72\\x69\\x74\\x65\\x20\\x6b\\x65\\x79\"\n\n#  undef TLS_MD_KEY_EXPANSION_CONST\n/*\n * key expansion\n */\n#  define TLS_MD_KEY_EXPANSION_CONST    \"\\x6b\\x65\\x79\\x20\\x65\\x78\\x70\\x61\\x6e\\x73\\x69\\x6f\\x6e\"\n\n#  undef TLS_MD_CLIENT_WRITE_KEY_CONST\n/*\n * client write key\n */\n#  define TLS_MD_CLIENT_WRITE_KEY_CONST \"\\x63\\x6c\\x69\\x65\\x6e\\x74\\x20\\x77\\x72\\x69\\x74\\x65\\x20\\x6b\\x65\\x79\"\n\n#  undef TLS_MD_SERVER_WRITE_KEY_CONST\n/*\n * server write key\n */\n#  define TLS_MD_SERVER_WRITE_KEY_CONST \"\\x73\\x65\\x72\\x76\\x65\\x72\\x20\\x77\\x72\\x69\\x74\\x65\\x20\\x6b\\x65\\x79\"\n\n#  undef TLS_MD_IV_BLOCK_CONST\n/*\n * IV block\n */\n#  define TLS_MD_IV_BLOCK_CONST         \"\\x49\\x56\\x20\\x62\\x6c\\x6f\\x63\\x6b\"\n\n#  undef TLS_MD_MASTER_SECRET_CONST\n/*\n * master secret\n */\n#  define TLS_MD_MASTER_SECRET_CONST    \"\\x6d\\x61\\x73\\x74\\x65\\x72\\x20\\x73\\x65\\x63\\x72\\x65\\x74\"\n# endif\n\n/* TLS Session Ticket extension struct */\nstruct tls_session_ticket_ext_st {\n    unsigned short length;\n    void *data;\n};\n\n#ifdef  __cplusplus\n}\n#endif\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/arm/include/openssl/ts.h",
    "content": "/* crypto/ts/ts.h */\n/*\n * Written by Zoltan Glozik (zglozik@opentsa.org) for the OpenSSL project\n * 2002, 2003, 2004.\n */\n/* ====================================================================\n * Copyright (c) 2006 The OpenSSL Project.  All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n *\n * 1. Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n *\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in\n *    the documentation and/or other materials provided with the\n *    distribution.\n *\n * 3. All advertising materials mentioning features or use of this\n *    software must display the following acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)\"\n *\n * 4. The names \"OpenSSL Toolkit\" and \"OpenSSL Project\" must not be used to\n *    endorse or promote products derived from this software without\n *    prior written permission. For written permission, please contact\n *    licensing@OpenSSL.org.\n *\n * 5. Products derived from this software may not be called \"OpenSSL\"\n *    nor may \"OpenSSL\" appear in their names without prior written\n *    permission of the OpenSSL Project.\n *\n * 6. Redistributions of any form whatsoever must retain the following\n *    acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)\"\n *\n * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY\n * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\n * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR\n * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\n * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,\n * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED\n * OF THE POSSIBILITY OF SUCH DAMAGE.\n * ====================================================================\n *\n * This product includes cryptographic software written by Eric Young\n * (eay@cryptsoft.com).  This product includes software written by Tim\n * Hudson (tjh@cryptsoft.com).\n *\n */\n\n#ifndef HEADER_TS_H\n# define HEADER_TS_H\n\n# include <openssl/opensslconf.h>\n# include <openssl/symhacks.h>\n# ifndef OPENSSL_NO_BUFFER\n#  include <openssl/buffer.h>\n# endif\n# ifndef OPENSSL_NO_EVP\n#  include <openssl/evp.h>\n# endif\n# ifndef OPENSSL_NO_BIO\n#  include <openssl/bio.h>\n# endif\n# include <openssl/stack.h>\n# include <openssl/asn1.h>\n# include <openssl/safestack.h>\n\n# ifndef OPENSSL_NO_RSA\n#  include <openssl/rsa.h>\n# endif\n\n# ifndef OPENSSL_NO_DSA\n#  include <openssl/dsa.h>\n# endif\n\n# ifndef OPENSSL_NO_DH\n#  include <openssl/dh.h>\n# endif\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n# ifdef WIN32\n/* Under Win32 this is defined in wincrypt.h */\n#  undef X509_NAME\n# endif\n\n# include <openssl/x509.h>\n# include <openssl/x509v3.h>\n\n/*-\nMessageImprint ::= SEQUENCE  {\n     hashAlgorithm                AlgorithmIdentifier,\n     hashedMessage                OCTET STRING  }\n*/\n\ntypedef struct TS_msg_imprint_st {\n    X509_ALGOR *hash_algo;\n    ASN1_OCTET_STRING *hashed_msg;\n} TS_MSG_IMPRINT;\n\n/*-\nTimeStampReq ::= SEQUENCE  {\n   version                  INTEGER  { v1(1) },\n   messageImprint           MessageImprint,\n     --a hash algorithm OID and the hash value of the data to be\n     --time-stamped\n   reqPolicy                TSAPolicyId                OPTIONAL,\n   nonce                    INTEGER                    OPTIONAL,\n   certReq                  BOOLEAN                    DEFAULT FALSE,\n   extensions               [0] IMPLICIT Extensions    OPTIONAL  }\n*/\n\ntypedef struct TS_req_st {\n    ASN1_INTEGER *version;\n    TS_MSG_IMPRINT *msg_imprint;\n    ASN1_OBJECT *policy_id;     /* OPTIONAL */\n    ASN1_INTEGER *nonce;        /* OPTIONAL */\n    ASN1_BOOLEAN cert_req;      /* DEFAULT FALSE */\n    STACK_OF(X509_EXTENSION) *extensions; /* [0] OPTIONAL */\n} TS_REQ;\n\n/*-\nAccuracy ::= SEQUENCE {\n                seconds        INTEGER           OPTIONAL,\n                millis     [0] INTEGER  (1..999) OPTIONAL,\n                micros     [1] INTEGER  (1..999) OPTIONAL  }\n*/\n\ntypedef struct TS_accuracy_st {\n    ASN1_INTEGER *seconds;\n    ASN1_INTEGER *millis;\n    ASN1_INTEGER *micros;\n} TS_ACCURACY;\n\n/*-\nTSTInfo ::= SEQUENCE  {\n    version                      INTEGER  { v1(1) },\n    policy                       TSAPolicyId,\n    messageImprint               MessageImprint,\n      -- MUST have the same value as the similar field in\n      -- TimeStampReq\n    serialNumber                 INTEGER,\n     -- Time-Stamping users MUST be ready to accommodate integers\n     -- up to 160 bits.\n    genTime                      GeneralizedTime,\n    accuracy                     Accuracy                 OPTIONAL,\n    ordering                     BOOLEAN             DEFAULT FALSE,\n    nonce                        INTEGER                  OPTIONAL,\n      -- MUST be present if the similar field was present\n      -- in TimeStampReq.  In that case it MUST have the same value.\n    tsa                          [0] GeneralName          OPTIONAL,\n    extensions                   [1] IMPLICIT Extensions  OPTIONAL   }\n*/\n\ntypedef struct TS_tst_info_st {\n    ASN1_INTEGER *version;\n    ASN1_OBJECT *policy_id;\n    TS_MSG_IMPRINT *msg_imprint;\n    ASN1_INTEGER *serial;\n    ASN1_GENERALIZEDTIME *time;\n    TS_ACCURACY *accuracy;\n    ASN1_BOOLEAN ordering;\n    ASN1_INTEGER *nonce;\n    GENERAL_NAME *tsa;\n    STACK_OF(X509_EXTENSION) *extensions;\n} TS_TST_INFO;\n\n/*-\nPKIStatusInfo ::= SEQUENCE {\n    status        PKIStatus,\n    statusString  PKIFreeText     OPTIONAL,\n    failInfo      PKIFailureInfo  OPTIONAL  }\n\nFrom RFC 1510 - section 3.1.1:\nPKIFreeText ::= SEQUENCE SIZE (1..MAX) OF UTF8String\n        -- text encoded as UTF-8 String (note:  each UTF8String SHOULD\n        -- include an RFC 1766 language tag to indicate the language\n        -- of the contained text)\n*/\n\n/* Possible values for status. See ts_resp_print.c && ts_resp_verify.c. */\n\n# define TS_STATUS_GRANTED                       0\n# define TS_STATUS_GRANTED_WITH_MODS             1\n# define TS_STATUS_REJECTION                     2\n# define TS_STATUS_WAITING                       3\n# define TS_STATUS_REVOCATION_WARNING            4\n# define TS_STATUS_REVOCATION_NOTIFICATION       5\n\n/*\n * Possible values for failure_info. See ts_resp_print.c && ts_resp_verify.c\n */\n\n# define TS_INFO_BAD_ALG                 0\n# define TS_INFO_BAD_REQUEST             2\n# define TS_INFO_BAD_DATA_FORMAT         5\n# define TS_INFO_TIME_NOT_AVAILABLE      14\n# define TS_INFO_UNACCEPTED_POLICY       15\n# define TS_INFO_UNACCEPTED_EXTENSION    16\n# define TS_INFO_ADD_INFO_NOT_AVAILABLE  17\n# define TS_INFO_SYSTEM_FAILURE          25\n\ntypedef struct TS_status_info_st {\n    ASN1_INTEGER *status;\n    STACK_OF(ASN1_UTF8STRING) *text;\n    ASN1_BIT_STRING *failure_info;\n} TS_STATUS_INFO;\n\nDECLARE_STACK_OF(ASN1_UTF8STRING)\nDECLARE_ASN1_SET_OF(ASN1_UTF8STRING)\n\n/*-\nTimeStampResp ::= SEQUENCE  {\n     status                  PKIStatusInfo,\n     timeStampToken          TimeStampToken     OPTIONAL }\n*/\n\ntypedef struct TS_resp_st {\n    TS_STATUS_INFO *status_info;\n    PKCS7 *token;\n    TS_TST_INFO *tst_info;\n} TS_RESP;\n\n/* The structure below would belong to the ESS component. */\n\n/*-\nIssuerSerial ::= SEQUENCE {\n        issuer                   GeneralNames,\n        serialNumber             CertificateSerialNumber\n        }\n*/\n\ntypedef struct ESS_issuer_serial {\n    STACK_OF(GENERAL_NAME) *issuer;\n    ASN1_INTEGER *serial;\n} ESS_ISSUER_SERIAL;\n\n/*-\nESSCertID ::=  SEQUENCE {\n        certHash                 Hash,\n        issuerSerial             IssuerSerial OPTIONAL\n}\n*/\n\ntypedef struct ESS_cert_id {\n    ASN1_OCTET_STRING *hash;    /* Always SHA-1 digest. */\n    ESS_ISSUER_SERIAL *issuer_serial;\n} ESS_CERT_ID;\n\nDECLARE_STACK_OF(ESS_CERT_ID)\nDECLARE_ASN1_SET_OF(ESS_CERT_ID)\n\n/*-\nSigningCertificate ::=  SEQUENCE {\n       certs        SEQUENCE OF ESSCertID,\n       policies     SEQUENCE OF PolicyInformation OPTIONAL\n}\n*/\n\ntypedef struct ESS_signing_cert {\n    STACK_OF(ESS_CERT_ID) *cert_ids;\n    STACK_OF(POLICYINFO) *policy_info;\n} ESS_SIGNING_CERT;\n\nTS_REQ *TS_REQ_new(void);\nvoid TS_REQ_free(TS_REQ *a);\nint i2d_TS_REQ(const TS_REQ *a, unsigned char **pp);\nTS_REQ *d2i_TS_REQ(TS_REQ **a, const unsigned char **pp, long length);\n\nTS_REQ *TS_REQ_dup(TS_REQ *a);\n\nTS_REQ *d2i_TS_REQ_fp(FILE *fp, TS_REQ **a);\nint i2d_TS_REQ_fp(FILE *fp, TS_REQ *a);\nTS_REQ *d2i_TS_REQ_bio(BIO *fp, TS_REQ **a);\nint i2d_TS_REQ_bio(BIO *fp, TS_REQ *a);\n\nTS_MSG_IMPRINT *TS_MSG_IMPRINT_new(void);\nvoid TS_MSG_IMPRINT_free(TS_MSG_IMPRINT *a);\nint i2d_TS_MSG_IMPRINT(const TS_MSG_IMPRINT *a, unsigned char **pp);\nTS_MSG_IMPRINT *d2i_TS_MSG_IMPRINT(TS_MSG_IMPRINT **a,\n                                   const unsigned char **pp, long length);\n\nTS_MSG_IMPRINT *TS_MSG_IMPRINT_dup(TS_MSG_IMPRINT *a);\n\nTS_MSG_IMPRINT *d2i_TS_MSG_IMPRINT_fp(FILE *fp, TS_MSG_IMPRINT **a);\nint i2d_TS_MSG_IMPRINT_fp(FILE *fp, TS_MSG_IMPRINT *a);\nTS_MSG_IMPRINT *d2i_TS_MSG_IMPRINT_bio(BIO *fp, TS_MSG_IMPRINT **a);\nint i2d_TS_MSG_IMPRINT_bio(BIO *fp, TS_MSG_IMPRINT *a);\n\nTS_RESP *TS_RESP_new(void);\nvoid TS_RESP_free(TS_RESP *a);\nint i2d_TS_RESP(const TS_RESP *a, unsigned char **pp);\nTS_RESP *d2i_TS_RESP(TS_RESP **a, const unsigned char **pp, long length);\nTS_TST_INFO *PKCS7_to_TS_TST_INFO(PKCS7 *token);\nTS_RESP *TS_RESP_dup(TS_RESP *a);\n\nTS_RESP *d2i_TS_RESP_fp(FILE *fp, TS_RESP **a);\nint i2d_TS_RESP_fp(FILE *fp, TS_RESP *a);\nTS_RESP *d2i_TS_RESP_bio(BIO *fp, TS_RESP **a);\nint i2d_TS_RESP_bio(BIO *fp, TS_RESP *a);\n\nTS_STATUS_INFO *TS_STATUS_INFO_new(void);\nvoid TS_STATUS_INFO_free(TS_STATUS_INFO *a);\nint i2d_TS_STATUS_INFO(const TS_STATUS_INFO *a, unsigned char **pp);\nTS_STATUS_INFO *d2i_TS_STATUS_INFO(TS_STATUS_INFO **a,\n                                   const unsigned char **pp, long length);\nTS_STATUS_INFO *TS_STATUS_INFO_dup(TS_STATUS_INFO *a);\n\nTS_TST_INFO *TS_TST_INFO_new(void);\nvoid TS_TST_INFO_free(TS_TST_INFO *a);\nint i2d_TS_TST_INFO(const TS_TST_INFO *a, unsigned char **pp);\nTS_TST_INFO *d2i_TS_TST_INFO(TS_TST_INFO **a, const unsigned char **pp,\n                             long length);\nTS_TST_INFO *TS_TST_INFO_dup(TS_TST_INFO *a);\n\nTS_TST_INFO *d2i_TS_TST_INFO_fp(FILE *fp, TS_TST_INFO **a);\nint i2d_TS_TST_INFO_fp(FILE *fp, TS_TST_INFO *a);\nTS_TST_INFO *d2i_TS_TST_INFO_bio(BIO *fp, TS_TST_INFO **a);\nint i2d_TS_TST_INFO_bio(BIO *fp, TS_TST_INFO *a);\n\nTS_ACCURACY *TS_ACCURACY_new(void);\nvoid TS_ACCURACY_free(TS_ACCURACY *a);\nint i2d_TS_ACCURACY(const TS_ACCURACY *a, unsigned char **pp);\nTS_ACCURACY *d2i_TS_ACCURACY(TS_ACCURACY **a, const unsigned char **pp,\n                             long length);\nTS_ACCURACY *TS_ACCURACY_dup(TS_ACCURACY *a);\n\nESS_ISSUER_SERIAL *ESS_ISSUER_SERIAL_new(void);\nvoid ESS_ISSUER_SERIAL_free(ESS_ISSUER_SERIAL *a);\nint i2d_ESS_ISSUER_SERIAL(const ESS_ISSUER_SERIAL *a, unsigned char **pp);\nESS_ISSUER_SERIAL *d2i_ESS_ISSUER_SERIAL(ESS_ISSUER_SERIAL **a,\n                                         const unsigned char **pp,\n                                         long length);\nESS_ISSUER_SERIAL *ESS_ISSUER_SERIAL_dup(ESS_ISSUER_SERIAL *a);\n\nESS_CERT_ID *ESS_CERT_ID_new(void);\nvoid ESS_CERT_ID_free(ESS_CERT_ID *a);\nint i2d_ESS_CERT_ID(const ESS_CERT_ID *a, unsigned char **pp);\nESS_CERT_ID *d2i_ESS_CERT_ID(ESS_CERT_ID **a, const unsigned char **pp,\n                             long length);\nESS_CERT_ID *ESS_CERT_ID_dup(ESS_CERT_ID *a);\n\nESS_SIGNING_CERT *ESS_SIGNING_CERT_new(void);\nvoid ESS_SIGNING_CERT_free(ESS_SIGNING_CERT *a);\nint i2d_ESS_SIGNING_CERT(const ESS_SIGNING_CERT *a, unsigned char **pp);\nESS_SIGNING_CERT *d2i_ESS_SIGNING_CERT(ESS_SIGNING_CERT **a,\n                                       const unsigned char **pp, long length);\nESS_SIGNING_CERT *ESS_SIGNING_CERT_dup(ESS_SIGNING_CERT *a);\n\nvoid ERR_load_TS_strings(void);\n\nint TS_REQ_set_version(TS_REQ *a, long version);\nlong TS_REQ_get_version(const TS_REQ *a);\n\nint TS_REQ_set_msg_imprint(TS_REQ *a, TS_MSG_IMPRINT *msg_imprint);\nTS_MSG_IMPRINT *TS_REQ_get_msg_imprint(TS_REQ *a);\n\nint TS_MSG_IMPRINT_set_algo(TS_MSG_IMPRINT *a, X509_ALGOR *alg);\nX509_ALGOR *TS_MSG_IMPRINT_get_algo(TS_MSG_IMPRINT *a);\n\nint TS_MSG_IMPRINT_set_msg(TS_MSG_IMPRINT *a, unsigned char *d, int len);\nASN1_OCTET_STRING *TS_MSG_IMPRINT_get_msg(TS_MSG_IMPRINT *a);\n\nint TS_REQ_set_policy_id(TS_REQ *a, ASN1_OBJECT *policy);\nASN1_OBJECT *TS_REQ_get_policy_id(TS_REQ *a);\n\nint TS_REQ_set_nonce(TS_REQ *a, const ASN1_INTEGER *nonce);\nconst ASN1_INTEGER *TS_REQ_get_nonce(const TS_REQ *a);\n\nint TS_REQ_set_cert_req(TS_REQ *a, int cert_req);\nint TS_REQ_get_cert_req(const TS_REQ *a);\n\nSTACK_OF(X509_EXTENSION) *TS_REQ_get_exts(TS_REQ *a);\nvoid TS_REQ_ext_free(TS_REQ *a);\nint TS_REQ_get_ext_count(TS_REQ *a);\nint TS_REQ_get_ext_by_NID(TS_REQ *a, int nid, int lastpos);\nint TS_REQ_get_ext_by_OBJ(TS_REQ *a, ASN1_OBJECT *obj, int lastpos);\nint TS_REQ_get_ext_by_critical(TS_REQ *a, int crit, int lastpos);\nX509_EXTENSION *TS_REQ_get_ext(TS_REQ *a, int loc);\nX509_EXTENSION *TS_REQ_delete_ext(TS_REQ *a, int loc);\nint TS_REQ_add_ext(TS_REQ *a, X509_EXTENSION *ex, int loc);\nvoid *TS_REQ_get_ext_d2i(TS_REQ *a, int nid, int *crit, int *idx);\n\n/* Function declarations for TS_REQ defined in ts/ts_req_print.c */\n\nint TS_REQ_print_bio(BIO *bio, TS_REQ *a);\n\n/* Function declarations for TS_RESP defined in ts/ts_resp_utils.c */\n\nint TS_RESP_set_status_info(TS_RESP *a, TS_STATUS_INFO *info);\nTS_STATUS_INFO *TS_RESP_get_status_info(TS_RESP *a);\n\n/* Caller loses ownership of PKCS7 and TS_TST_INFO objects. */\nvoid TS_RESP_set_tst_info(TS_RESP *a, PKCS7 *p7, TS_TST_INFO *tst_info);\nPKCS7 *TS_RESP_get_token(TS_RESP *a);\nTS_TST_INFO *TS_RESP_get_tst_info(TS_RESP *a);\n\nint TS_TST_INFO_set_version(TS_TST_INFO *a, long version);\nlong TS_TST_INFO_get_version(const TS_TST_INFO *a);\n\nint TS_TST_INFO_set_policy_id(TS_TST_INFO *a, ASN1_OBJECT *policy_id);\nASN1_OBJECT *TS_TST_INFO_get_policy_id(TS_TST_INFO *a);\n\nint TS_TST_INFO_set_msg_imprint(TS_TST_INFO *a, TS_MSG_IMPRINT *msg_imprint);\nTS_MSG_IMPRINT *TS_TST_INFO_get_msg_imprint(TS_TST_INFO *a);\n\nint TS_TST_INFO_set_serial(TS_TST_INFO *a, const ASN1_INTEGER *serial);\nconst ASN1_INTEGER *TS_TST_INFO_get_serial(const TS_TST_INFO *a);\n\nint TS_TST_INFO_set_time(TS_TST_INFO *a, const ASN1_GENERALIZEDTIME *gtime);\nconst ASN1_GENERALIZEDTIME *TS_TST_INFO_get_time(const TS_TST_INFO *a);\n\nint TS_TST_INFO_set_accuracy(TS_TST_INFO *a, TS_ACCURACY *accuracy);\nTS_ACCURACY *TS_TST_INFO_get_accuracy(TS_TST_INFO *a);\n\nint TS_ACCURACY_set_seconds(TS_ACCURACY *a, const ASN1_INTEGER *seconds);\nconst ASN1_INTEGER *TS_ACCURACY_get_seconds(const TS_ACCURACY *a);\n\nint TS_ACCURACY_set_millis(TS_ACCURACY *a, const ASN1_INTEGER *millis);\nconst ASN1_INTEGER *TS_ACCURACY_get_millis(const TS_ACCURACY *a);\n\nint TS_ACCURACY_set_micros(TS_ACCURACY *a, const ASN1_INTEGER *micros);\nconst ASN1_INTEGER *TS_ACCURACY_get_micros(const TS_ACCURACY *a);\n\nint TS_TST_INFO_set_ordering(TS_TST_INFO *a, int ordering);\nint TS_TST_INFO_get_ordering(const TS_TST_INFO *a);\n\nint TS_TST_INFO_set_nonce(TS_TST_INFO *a, const ASN1_INTEGER *nonce);\nconst ASN1_INTEGER *TS_TST_INFO_get_nonce(const TS_TST_INFO *a);\n\nint TS_TST_INFO_set_tsa(TS_TST_INFO *a, GENERAL_NAME *tsa);\nGENERAL_NAME *TS_TST_INFO_get_tsa(TS_TST_INFO *a);\n\nSTACK_OF(X509_EXTENSION) *TS_TST_INFO_get_exts(TS_TST_INFO *a);\nvoid TS_TST_INFO_ext_free(TS_TST_INFO *a);\nint TS_TST_INFO_get_ext_count(TS_TST_INFO *a);\nint TS_TST_INFO_get_ext_by_NID(TS_TST_INFO *a, int nid, int lastpos);\nint TS_TST_INFO_get_ext_by_OBJ(TS_TST_INFO *a, ASN1_OBJECT *obj, int lastpos);\nint TS_TST_INFO_get_ext_by_critical(TS_TST_INFO *a, int crit, int lastpos);\nX509_EXTENSION *TS_TST_INFO_get_ext(TS_TST_INFO *a, int loc);\nX509_EXTENSION *TS_TST_INFO_delete_ext(TS_TST_INFO *a, int loc);\nint TS_TST_INFO_add_ext(TS_TST_INFO *a, X509_EXTENSION *ex, int loc);\nvoid *TS_TST_INFO_get_ext_d2i(TS_TST_INFO *a, int nid, int *crit, int *idx);\n\n/*\n * Declarations related to response generation, defined in ts/ts_resp_sign.c.\n */\n\n/* Optional flags for response generation. */\n\n/* Don't include the TSA name in response. */\n# define TS_TSA_NAME             0x01\n\n/* Set ordering to true in response. */\n# define TS_ORDERING             0x02\n\n/*\n * Include the signer certificate and the other specified certificates in\n * the ESS signing certificate attribute beside the PKCS7 signed data.\n * Only the signer certificates is included by default.\n */\n# define TS_ESS_CERT_ID_CHAIN    0x04\n\n/* Forward declaration. */\nstruct TS_resp_ctx;\n\n/* This must return a unique number less than 160 bits long. */\ntypedef ASN1_INTEGER *(*TS_serial_cb) (struct TS_resp_ctx *, void *);\n\n/*\n * This must return the seconds and microseconds since Jan 1, 1970 in the sec\n * and usec variables allocated by the caller. Return non-zero for success\n * and zero for failure.\n */\ntypedef int (*TS_time_cb) (struct TS_resp_ctx *, void *, long *sec,\n                           long *usec);\n\n/*\n * This must process the given extension. It can modify the TS_TST_INFO\n * object of the context. Return values: !0 (processed), 0 (error, it must\n * set the status info/failure info of the response).\n */\ntypedef int (*TS_extension_cb) (struct TS_resp_ctx *, X509_EXTENSION *,\n                                void *);\n\ntypedef struct TS_resp_ctx {\n    X509 *signer_cert;\n    EVP_PKEY *signer_key;\n    STACK_OF(X509) *certs;      /* Certs to include in signed data. */\n    STACK_OF(ASN1_OBJECT) *policies; /* Acceptable policies. */\n    ASN1_OBJECT *default_policy; /* It may appear in policies, too. */\n    STACK_OF(EVP_MD) *mds;      /* Acceptable message digests. */\n    ASN1_INTEGER *seconds;      /* accuracy, 0 means not specified. */\n    ASN1_INTEGER *millis;       /* accuracy, 0 means not specified. */\n    ASN1_INTEGER *micros;       /* accuracy, 0 means not specified. */\n    unsigned clock_precision_digits; /* fraction of seconds in time stamp\n                                      * token. */\n    unsigned flags;             /* Optional info, see values above. */\n    /* Callback functions. */\n    TS_serial_cb serial_cb;\n    void *serial_cb_data;       /* User data for serial_cb. */\n    TS_time_cb time_cb;\n    void *time_cb_data;         /* User data for time_cb. */\n    TS_extension_cb extension_cb;\n    void *extension_cb_data;    /* User data for extension_cb. */\n    /* These members are used only while creating the response. */\n    TS_REQ *request;\n    TS_RESP *response;\n    TS_TST_INFO *tst_info;\n} TS_RESP_CTX;\n\nDECLARE_STACK_OF(EVP_MD)\nDECLARE_ASN1_SET_OF(EVP_MD)\n\n/* Creates a response context that can be used for generating responses. */\nTS_RESP_CTX *TS_RESP_CTX_new(void);\nvoid TS_RESP_CTX_free(TS_RESP_CTX *ctx);\n\n/* This parameter must be set. */\nint TS_RESP_CTX_set_signer_cert(TS_RESP_CTX *ctx, X509 *signer);\n\n/* This parameter must be set. */\nint TS_RESP_CTX_set_signer_key(TS_RESP_CTX *ctx, EVP_PKEY *key);\n\n/* This parameter must be set. */\nint TS_RESP_CTX_set_def_policy(TS_RESP_CTX *ctx, ASN1_OBJECT *def_policy);\n\n/* No additional certs are included in the response by default. */\nint TS_RESP_CTX_set_certs(TS_RESP_CTX *ctx, STACK_OF(X509) *certs);\n\n/*\n * Adds a new acceptable policy, only the default policy is accepted by\n * default.\n */\nint TS_RESP_CTX_add_policy(TS_RESP_CTX *ctx, ASN1_OBJECT *policy);\n\n/*\n * Adds a new acceptable message digest. Note that no message digests are\n * accepted by default. The md argument is shared with the caller.\n */\nint TS_RESP_CTX_add_md(TS_RESP_CTX *ctx, const EVP_MD *md);\n\n/* Accuracy is not included by default. */\nint TS_RESP_CTX_set_accuracy(TS_RESP_CTX *ctx,\n                             int secs, int millis, int micros);\n\n/*\n * Clock precision digits, i.e. the number of decimal digits: '0' means sec,\n * '3' msec, '6' usec, and so on. Default is 0.\n */\nint TS_RESP_CTX_set_clock_precision_digits(TS_RESP_CTX *ctx,\n                                           unsigned clock_precision_digits);\n/* At most we accept usec precision. */\n# define TS_MAX_CLOCK_PRECISION_DIGITS   6\n\n/* Maximum status message length */\n# define TS_MAX_STATUS_LENGTH   (1024 * 1024)\n\n/* No flags are set by default. */\nvoid TS_RESP_CTX_add_flags(TS_RESP_CTX *ctx, int flags);\n\n/* Default callback always returns a constant. */\nvoid TS_RESP_CTX_set_serial_cb(TS_RESP_CTX *ctx, TS_serial_cb cb, void *data);\n\n/* Default callback uses the gettimeofday() and gmtime() system calls. */\nvoid TS_RESP_CTX_set_time_cb(TS_RESP_CTX *ctx, TS_time_cb cb, void *data);\n\n/*\n * Default callback rejects all extensions. The extension callback is called\n * when the TS_TST_INFO object is already set up and not signed yet.\n */\n/* FIXME: extension handling is not tested yet. */\nvoid TS_RESP_CTX_set_extension_cb(TS_RESP_CTX *ctx,\n                                  TS_extension_cb cb, void *data);\n\n/* The following methods can be used in the callbacks. */\nint TS_RESP_CTX_set_status_info(TS_RESP_CTX *ctx,\n                                int status, const char *text);\n\n/* Sets the status info only if it is still TS_STATUS_GRANTED. */\nint TS_RESP_CTX_set_status_info_cond(TS_RESP_CTX *ctx,\n                                     int status, const char *text);\n\nint TS_RESP_CTX_add_failure_info(TS_RESP_CTX *ctx, int failure);\n\n/* The get methods below can be used in the extension callback. */\nTS_REQ *TS_RESP_CTX_get_request(TS_RESP_CTX *ctx);\n\nTS_TST_INFO *TS_RESP_CTX_get_tst_info(TS_RESP_CTX *ctx);\n\n/*\n * Creates the signed TS_TST_INFO and puts it in TS_RESP.\n * In case of errors it sets the status info properly.\n * Returns NULL only in case of memory allocation/fatal error.\n */\nTS_RESP *TS_RESP_create_response(TS_RESP_CTX *ctx, BIO *req_bio);\n\n/*\n * Declarations related to response verification,\n * they are defined in ts/ts_resp_verify.c.\n */\n\nint TS_RESP_verify_signature(PKCS7 *token, STACK_OF(X509) *certs,\n                             X509_STORE *store, X509 **signer_out);\n\n/* Context structure for the generic verify method. */\n\n/* Verify the signer's certificate and the signature of the response. */\n# define TS_VFY_SIGNATURE        (1u << 0)\n/* Verify the version number of the response. */\n# define TS_VFY_VERSION          (1u << 1)\n/* Verify if the policy supplied by the user matches the policy of the TSA. */\n# define TS_VFY_POLICY           (1u << 2)\n/*\n * Verify the message imprint provided by the user. This flag should not be\n * specified with TS_VFY_DATA.\n */\n# define TS_VFY_IMPRINT          (1u << 3)\n/*\n * Verify the message imprint computed by the verify method from the user\n * provided data and the MD algorithm of the response. This flag should not\n * be specified with TS_VFY_IMPRINT.\n */\n# define TS_VFY_DATA             (1u << 4)\n/* Verify the nonce value. */\n# define TS_VFY_NONCE            (1u << 5)\n/* Verify if the TSA name field matches the signer certificate. */\n# define TS_VFY_SIGNER           (1u << 6)\n/* Verify if the TSA name field equals to the user provided name. */\n# define TS_VFY_TSA_NAME         (1u << 7)\n\n/* You can use the following convenience constants. */\n# define TS_VFY_ALL_IMPRINT      (TS_VFY_SIGNATURE       \\\n                                 | TS_VFY_VERSION       \\\n                                 | TS_VFY_POLICY        \\\n                                 | TS_VFY_IMPRINT       \\\n                                 | TS_VFY_NONCE         \\\n                                 | TS_VFY_SIGNER        \\\n                                 | TS_VFY_TSA_NAME)\n# define TS_VFY_ALL_DATA         (TS_VFY_SIGNATURE       \\\n                                 | TS_VFY_VERSION       \\\n                                 | TS_VFY_POLICY        \\\n                                 | TS_VFY_DATA          \\\n                                 | TS_VFY_NONCE         \\\n                                 | TS_VFY_SIGNER        \\\n                                 | TS_VFY_TSA_NAME)\n\ntypedef struct TS_verify_ctx {\n    /* Set this to the union of TS_VFY_... flags you want to carry out. */\n    unsigned flags;\n    /* Must be set only with TS_VFY_SIGNATURE. certs is optional. */\n    X509_STORE *store;\n    STACK_OF(X509) *certs;\n    /* Must be set only with TS_VFY_POLICY. */\n    ASN1_OBJECT *policy;\n    /*\n     * Must be set only with TS_VFY_IMPRINT. If md_alg is NULL, the\n     * algorithm from the response is used.\n     */\n    X509_ALGOR *md_alg;\n    unsigned char *imprint;\n    unsigned imprint_len;\n    /* Must be set only with TS_VFY_DATA. */\n    BIO *data;\n    /* Must be set only with TS_VFY_TSA_NAME. */\n    ASN1_INTEGER *nonce;\n    /* Must be set only with TS_VFY_TSA_NAME. */\n    GENERAL_NAME *tsa_name;\n} TS_VERIFY_CTX;\n\nint TS_RESP_verify_response(TS_VERIFY_CTX *ctx, TS_RESP *response);\nint TS_RESP_verify_token(TS_VERIFY_CTX *ctx, PKCS7 *token);\n\n/*\n * Declarations related to response verification context,\n * they are defined in ts/ts_verify_ctx.c.\n */\n\n/* Set all fields to zero. */\nTS_VERIFY_CTX *TS_VERIFY_CTX_new(void);\nvoid TS_VERIFY_CTX_init(TS_VERIFY_CTX *ctx);\nvoid TS_VERIFY_CTX_free(TS_VERIFY_CTX *ctx);\nvoid TS_VERIFY_CTX_cleanup(TS_VERIFY_CTX *ctx);\n\n/*-\n * If ctx is NULL, it allocates and returns a new object, otherwise\n * it returns ctx. It initialises all the members as follows:\n * flags = TS_VFY_ALL_IMPRINT & ~(TS_VFY_TSA_NAME | TS_VFY_SIGNATURE)\n * certs = NULL\n * store = NULL\n * policy = policy from the request or NULL if absent (in this case\n *      TS_VFY_POLICY is cleared from flags as well)\n * md_alg = MD algorithm from request\n * imprint, imprint_len = imprint from request\n * data = NULL\n * nonce, nonce_len = nonce from the request or NULL if absent (in this case\n *      TS_VFY_NONCE is cleared from flags as well)\n * tsa_name = NULL\n * Important: after calling this method TS_VFY_SIGNATURE should be added!\n */\nTS_VERIFY_CTX *TS_REQ_to_TS_VERIFY_CTX(TS_REQ *req, TS_VERIFY_CTX *ctx);\n\n/* Function declarations for TS_RESP defined in ts/ts_resp_print.c */\n\nint TS_RESP_print_bio(BIO *bio, TS_RESP *a);\nint TS_STATUS_INFO_print_bio(BIO *bio, TS_STATUS_INFO *a);\nint TS_TST_INFO_print_bio(BIO *bio, TS_TST_INFO *a);\n\n/* Common utility functions defined in ts/ts_lib.c */\n\nint TS_ASN1_INTEGER_print_bio(BIO *bio, const ASN1_INTEGER *num);\nint TS_OBJ_print_bio(BIO *bio, const ASN1_OBJECT *obj);\nint TS_ext_print_bio(BIO *bio, const STACK_OF(X509_EXTENSION) *extensions);\nint TS_X509_ALGOR_print_bio(BIO *bio, const X509_ALGOR *alg);\nint TS_MSG_IMPRINT_print_bio(BIO *bio, TS_MSG_IMPRINT *msg);\n\n/*\n * Function declarations for handling configuration options, defined in\n * ts/ts_conf.c\n */\n\nX509 *TS_CONF_load_cert(const char *file);\nSTACK_OF(X509) *TS_CONF_load_certs(const char *file);\nEVP_PKEY *TS_CONF_load_key(const char *file, const char *pass);\nconst char *TS_CONF_get_tsa_section(CONF *conf, const char *section);\nint TS_CONF_set_serial(CONF *conf, const char *section, TS_serial_cb cb,\n                       TS_RESP_CTX *ctx);\nint TS_CONF_set_crypto_device(CONF *conf, const char *section,\n                              const char *device);\nint TS_CONF_set_default_engine(const char *name);\nint TS_CONF_set_signer_cert(CONF *conf, const char *section,\n                            const char *cert, TS_RESP_CTX *ctx);\nint TS_CONF_set_certs(CONF *conf, const char *section, const char *certs,\n                      TS_RESP_CTX *ctx);\nint TS_CONF_set_signer_key(CONF *conf, const char *section,\n                           const char *key, const char *pass,\n                           TS_RESP_CTX *ctx);\nint TS_CONF_set_def_policy(CONF *conf, const char *section,\n                           const char *policy, TS_RESP_CTX *ctx);\nint TS_CONF_set_policies(CONF *conf, const char *section, TS_RESP_CTX *ctx);\nint TS_CONF_set_digests(CONF *conf, const char *section, TS_RESP_CTX *ctx);\nint TS_CONF_set_accuracy(CONF *conf, const char *section, TS_RESP_CTX *ctx);\nint TS_CONF_set_clock_precision_digits(CONF *conf, const char *section,\n                                       TS_RESP_CTX *ctx);\nint TS_CONF_set_ordering(CONF *conf, const char *section, TS_RESP_CTX *ctx);\nint TS_CONF_set_tsa_name(CONF *conf, const char *section, TS_RESP_CTX *ctx);\nint TS_CONF_set_ess_cert_id_chain(CONF *conf, const char *section,\n                                  TS_RESP_CTX *ctx);\n\n/* -------------------------------------------------- */\n/* BEGIN ERROR CODES */\n/*\n * The following lines are auto generated by the script mkerr.pl. Any changes\n * made after this point may be overwritten when the script is next run.\n */\nvoid ERR_load_TS_strings(void);\n\n/* Error codes for the TS functions. */\n\n/* Function codes. */\n# define TS_F_D2I_TS_RESP                                 147\n# define TS_F_DEF_SERIAL_CB                               110\n# define TS_F_DEF_TIME_CB                                 111\n# define TS_F_ESS_ADD_SIGNING_CERT                        112\n# define TS_F_ESS_CERT_ID_NEW_INIT                        113\n# define TS_F_ESS_SIGNING_CERT_NEW_INIT                   114\n# define TS_F_INT_TS_RESP_VERIFY_TOKEN                    149\n# define TS_F_PKCS7_TO_TS_TST_INFO                        148\n# define TS_F_TS_ACCURACY_SET_MICROS                      115\n# define TS_F_TS_ACCURACY_SET_MILLIS                      116\n# define TS_F_TS_ACCURACY_SET_SECONDS                     117\n# define TS_F_TS_CHECK_IMPRINTS                           100\n# define TS_F_TS_CHECK_NONCES                             101\n# define TS_F_TS_CHECK_POLICY                             102\n# define TS_F_TS_CHECK_SIGNING_CERTS                      103\n# define TS_F_TS_CHECK_STATUS_INFO                        104\n# define TS_F_TS_COMPUTE_IMPRINT                          145\n# define TS_F_TS_CONF_SET_DEFAULT_ENGINE                  146\n# define TS_F_TS_GET_STATUS_TEXT                          105\n# define TS_F_TS_MSG_IMPRINT_SET_ALGO                     118\n# define TS_F_TS_REQ_SET_MSG_IMPRINT                      119\n# define TS_F_TS_REQ_SET_NONCE                            120\n# define TS_F_TS_REQ_SET_POLICY_ID                        121\n# define TS_F_TS_RESP_CREATE_RESPONSE                     122\n# define TS_F_TS_RESP_CREATE_TST_INFO                     123\n# define TS_F_TS_RESP_CTX_ADD_FAILURE_INFO                124\n# define TS_F_TS_RESP_CTX_ADD_MD                          125\n# define TS_F_TS_RESP_CTX_ADD_POLICY                      126\n# define TS_F_TS_RESP_CTX_NEW                             127\n# define TS_F_TS_RESP_CTX_SET_ACCURACY                    128\n# define TS_F_TS_RESP_CTX_SET_CERTS                       129\n# define TS_F_TS_RESP_CTX_SET_DEF_POLICY                  130\n# define TS_F_TS_RESP_CTX_SET_SIGNER_CERT                 131\n# define TS_F_TS_RESP_CTX_SET_STATUS_INFO                 132\n# define TS_F_TS_RESP_GET_POLICY                          133\n# define TS_F_TS_RESP_SET_GENTIME_WITH_PRECISION          134\n# define TS_F_TS_RESP_SET_STATUS_INFO                     135\n# define TS_F_TS_RESP_SET_TST_INFO                        150\n# define TS_F_TS_RESP_SIGN                                136\n# define TS_F_TS_RESP_VERIFY_SIGNATURE                    106\n# define TS_F_TS_RESP_VERIFY_TOKEN                        107\n# define TS_F_TS_TST_INFO_SET_ACCURACY                    137\n# define TS_F_TS_TST_INFO_SET_MSG_IMPRINT                 138\n# define TS_F_TS_TST_INFO_SET_NONCE                       139\n# define TS_F_TS_TST_INFO_SET_POLICY_ID                   140\n# define TS_F_TS_TST_INFO_SET_SERIAL                      141\n# define TS_F_TS_TST_INFO_SET_TIME                        142\n# define TS_F_TS_TST_INFO_SET_TSA                         143\n# define TS_F_TS_VERIFY                                   108\n# define TS_F_TS_VERIFY_CERT                              109\n# define TS_F_TS_VERIFY_CTX_NEW                           144\n\n/* Reason codes. */\n# define TS_R_BAD_PKCS7_TYPE                              132\n# define TS_R_BAD_TYPE                                    133\n# define TS_R_CERTIFICATE_VERIFY_ERROR                    100\n# define TS_R_COULD_NOT_SET_ENGINE                        127\n# define TS_R_COULD_NOT_SET_TIME                          115\n# define TS_R_D2I_TS_RESP_INT_FAILED                      128\n# define TS_R_DETACHED_CONTENT                            134\n# define TS_R_ESS_ADD_SIGNING_CERT_ERROR                  116\n# define TS_R_ESS_SIGNING_CERTIFICATE_ERROR               101\n# define TS_R_INVALID_NULL_POINTER                        102\n# define TS_R_INVALID_SIGNER_CERTIFICATE_PURPOSE          117\n# define TS_R_MESSAGE_IMPRINT_MISMATCH                    103\n# define TS_R_NONCE_MISMATCH                              104\n# define TS_R_NONCE_NOT_RETURNED                          105\n# define TS_R_NO_CONTENT                                  106\n# define TS_R_NO_TIME_STAMP_TOKEN                         107\n# define TS_R_PKCS7_ADD_SIGNATURE_ERROR                   118\n# define TS_R_PKCS7_ADD_SIGNED_ATTR_ERROR                 119\n# define TS_R_PKCS7_TO_TS_TST_INFO_FAILED                 129\n# define TS_R_POLICY_MISMATCH                             108\n# define TS_R_PRIVATE_KEY_DOES_NOT_MATCH_CERTIFICATE      120\n# define TS_R_RESPONSE_SETUP_ERROR                        121\n# define TS_R_SIGNATURE_FAILURE                           109\n# define TS_R_THERE_MUST_BE_ONE_SIGNER                    110\n# define TS_R_TIME_SYSCALL_ERROR                          122\n# define TS_R_TOKEN_NOT_PRESENT                           130\n# define TS_R_TOKEN_PRESENT                               131\n# define TS_R_TSA_NAME_MISMATCH                           111\n# define TS_R_TSA_UNTRUSTED                               112\n# define TS_R_TST_INFO_SETUP_ERROR                        123\n# define TS_R_TS_DATASIGN                                 124\n# define TS_R_UNACCEPTABLE_POLICY                         125\n# define TS_R_UNSUPPORTED_MD_ALGORITHM                    126\n# define TS_R_UNSUPPORTED_VERSION                         113\n# define TS_R_WRONG_CONTENT_TYPE                          114\n\n#ifdef  __cplusplus\n}\n#endif\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/arm/include/openssl/txt_db.h",
    "content": "/* crypto/txt_db/txt_db.h */\n/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)\n * All rights reserved.\n *\n * This package is an SSL implementation written\n * by Eric Young (eay@cryptsoft.com).\n * The implementation was written so as to conform with Netscapes SSL.\n *\n * This library is free for commercial and non-commercial use as long as\n * the following conditions are aheared to.  The following conditions\n * apply to all code found in this distribution, be it the RC4, RSA,\n * lhash, DES, etc., code; not just the SSL code.  The SSL documentation\n * included with this distribution is covered by the same copyright terms\n * except that the holder is Tim Hudson (tjh@cryptsoft.com).\n *\n * Copyright remains Eric Young's, and as such any Copyright notices in\n * the code are not to be removed.\n * If this package is used in a product, Eric Young should be given attribution\n * as the author of the parts of the library used.\n * This can be in the form of a textual message at program startup or\n * in documentation (online or textual) provided with the package.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the copyright\n *    notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in the\n *    documentation and/or other materials provided with the distribution.\n * 3. All advertising materials mentioning features or use of this software\n *    must display the following acknowledgement:\n *    \"This product includes cryptographic software written by\n *     Eric Young (eay@cryptsoft.com)\"\n *    The word 'cryptographic' can be left out if the rouines from the library\n *    being used are not cryptographic related :-).\n * 4. If you include any Windows specific code (or a derivative thereof) from\n *    the apps directory (application code) you must include an acknowledgement:\n *    \"This product includes software written by Tim Hudson (tjh@cryptsoft.com)\"\n *\n * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n * SUCH DAMAGE.\n *\n * The licence and distribution terms for any publically available version or\n * derivative of this code cannot be changed.  i.e. this code cannot simply be\n * copied and put under another distribution licence\n * [including the GNU Public Licence.]\n */\n\n#ifndef HEADER_TXT_DB_H\n# define HEADER_TXT_DB_H\n\n# include <openssl/opensslconf.h>\n# ifndef OPENSSL_NO_BIO\n#  include <openssl/bio.h>\n# endif\n# include <openssl/stack.h>\n# include <openssl/lhash.h>\n\n# define DB_ERROR_OK                     0\n# define DB_ERROR_MALLOC                 1\n# define DB_ERROR_INDEX_CLASH            2\n# define DB_ERROR_INDEX_OUT_OF_RANGE     3\n# define DB_ERROR_NO_INDEX               4\n# define DB_ERROR_INSERT_INDEX_CLASH     5\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\ntypedef OPENSSL_STRING *OPENSSL_PSTRING;\nDECLARE_SPECIAL_STACK_OF(OPENSSL_PSTRING, OPENSSL_STRING)\n\ntypedef struct txt_db_st {\n    int num_fields;\n    STACK_OF(OPENSSL_PSTRING) *data;\n    LHASH_OF(OPENSSL_STRING) **index;\n    int (**qual) (OPENSSL_STRING *);\n    long error;\n    long arg1;\n    long arg2;\n    OPENSSL_STRING *arg_row;\n} TXT_DB;\n\n# ifndef OPENSSL_NO_BIO\nTXT_DB *TXT_DB_read(BIO *in, int num);\nlong TXT_DB_write(BIO *out, TXT_DB *db);\n# else\nTXT_DB *TXT_DB_read(char *in, int num);\nlong TXT_DB_write(char *out, TXT_DB *db);\n# endif\nint TXT_DB_create_index(TXT_DB *db, int field, int (*qual) (OPENSSL_STRING *),\n                        LHASH_HASH_FN_TYPE hash, LHASH_COMP_FN_TYPE cmp);\nvoid TXT_DB_free(TXT_DB *db);\nOPENSSL_STRING *TXT_DB_get_by_index(TXT_DB *db, int idx,\n                                    OPENSSL_STRING *value);\nint TXT_DB_insert(TXT_DB *db, OPENSSL_STRING *value);\n\n#ifdef  __cplusplus\n}\n#endif\n\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/arm/include/openssl/ui.h",
    "content": "/* crypto/ui/ui.h */\n/*\n * Written by Richard Levitte (richard@levitte.org) for the OpenSSL project\n * 2001.\n */\n/* ====================================================================\n * Copyright (c) 2001 The OpenSSL Project.  All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n *\n * 1. Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n *\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in\n *    the documentation and/or other materials provided with the\n *    distribution.\n *\n * 3. All advertising materials mentioning features or use of this\n *    software must display the following acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit. (http://www.openssl.org/)\"\n *\n * 4. The names \"OpenSSL Toolkit\" and \"OpenSSL Project\" must not be used to\n *    endorse or promote products derived from this software without\n *    prior written permission. For written permission, please contact\n *    openssl-core@openssl.org.\n *\n * 5. Products derived from this software may not be called \"OpenSSL\"\n *    nor may \"OpenSSL\" appear in their names without prior written\n *    permission of the OpenSSL Project.\n *\n * 6. Redistributions of any form whatsoever must retain the following\n *    acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit (http://www.openssl.org/)\"\n *\n * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY\n * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\n * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR\n * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\n * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,\n * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED\n * OF THE POSSIBILITY OF SUCH DAMAGE.\n * ====================================================================\n *\n * This product includes cryptographic software written by Eric Young\n * (eay@cryptsoft.com).  This product includes software written by Tim\n * Hudson (tjh@cryptsoft.com).\n *\n */\n\n#ifndef HEADER_UI_H\n# define HEADER_UI_H\n\n# ifndef OPENSSL_NO_DEPRECATED\n#  include <openssl/crypto.h>\n# endif\n# include <openssl/safestack.h>\n# include <openssl/ossl_typ.h>\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n/* Declared already in ossl_typ.h */\n/* typedef struct ui_st UI; */\n/* typedef struct ui_method_st UI_METHOD; */\n\n/*\n * All the following functions return -1 or NULL on error and in some cases\n * (UI_process()) -2 if interrupted or in some other way cancelled. When\n * everything is fine, they return 0, a positive value or a non-NULL pointer,\n * all depending on their purpose.\n */\n\n/* Creators and destructor.   */\nUI *UI_new(void);\nUI *UI_new_method(const UI_METHOD *method);\nvoid UI_free(UI *ui);\n\n/*-\n   The following functions are used to add strings to be printed and prompt\n   strings to prompt for data.  The names are UI_{add,dup}_<function>_string\n   and UI_{add,dup}_input_boolean.\n\n   UI_{add,dup}_<function>_string have the following meanings:\n        add     add a text or prompt string.  The pointers given to these\n                functions are used verbatim, no copying is done.\n        dup     make a copy of the text or prompt string, then add the copy\n                to the collection of strings in the user interface.\n        <function>\n                The function is a name for the functionality that the given\n                string shall be used for.  It can be one of:\n                        input   use the string as data prompt.\n                        verify  use the string as verification prompt.  This\n                                is used to verify a previous input.\n                        info    use the string for informational output.\n                        error   use the string for error output.\n   Honestly, there's currently no difference between info and error for the\n   moment.\n\n   UI_{add,dup}_input_boolean have the same semantics for \"add\" and \"dup\",\n   and are typically used when one wants to prompt for a yes/no response.\n\n   All of the functions in this group take a UI and a prompt string.\n   The string input and verify addition functions also take a flag argument,\n   a buffer for the result to end up with, a minimum input size and a maximum\n   input size (the result buffer MUST be large enough to be able to contain\n   the maximum number of characters).  Additionally, the verify addition\n   functions takes another buffer to compare the result against.\n   The boolean input functions take an action description string (which should\n   be safe to ignore if the expected user action is obvious, for example with\n   a dialog box with an OK button and a Cancel button), a string of acceptable\n   characters to mean OK and to mean Cancel.  The two last strings are checked\n   to make sure they don't have common characters.  Additionally, the same\n   flag argument as for the string input is taken, as well as a result buffer.\n   The result buffer is required to be at least one byte long.  Depending on\n   the answer, the first character from the OK or the Cancel character strings\n   will be stored in the first byte of the result buffer.  No NUL will be\n   added, so the result is *not* a string.\n\n   On success, the all return an index of the added information.  That index\n   is usefull when retrieving results with UI_get0_result(). */\nint UI_add_input_string(UI *ui, const char *prompt, int flags,\n                        char *result_buf, int minsize, int maxsize);\nint UI_dup_input_string(UI *ui, const char *prompt, int flags,\n                        char *result_buf, int minsize, int maxsize);\nint UI_add_verify_string(UI *ui, const char *prompt, int flags,\n                         char *result_buf, int minsize, int maxsize,\n                         const char *test_buf);\nint UI_dup_verify_string(UI *ui, const char *prompt, int flags,\n                         char *result_buf, int minsize, int maxsize,\n                         const char *test_buf);\nint UI_add_input_boolean(UI *ui, const char *prompt, const char *action_desc,\n                         const char *ok_chars, const char *cancel_chars,\n                         int flags, char *result_buf);\nint UI_dup_input_boolean(UI *ui, const char *prompt, const char *action_desc,\n                         const char *ok_chars, const char *cancel_chars,\n                         int flags, char *result_buf);\nint UI_add_info_string(UI *ui, const char *text);\nint UI_dup_info_string(UI *ui, const char *text);\nint UI_add_error_string(UI *ui, const char *text);\nint UI_dup_error_string(UI *ui, const char *text);\n\n/* These are the possible flags.  They can be or'ed together. */\n/* Use to have echoing of input */\n# define UI_INPUT_FLAG_ECHO              0x01\n/*\n * Use a default password.  Where that password is found is completely up to\n * the application, it might for example be in the user data set with\n * UI_add_user_data().  It is not recommended to have more than one input in\n * each UI being marked with this flag, or the application might get\n * confused.\n */\n# define UI_INPUT_FLAG_DEFAULT_PWD       0x02\n\n/*-\n * The user of these routines may want to define flags of their own.  The core\n * UI won't look at those, but will pass them on to the method routines.  They\n * must use higher bits so they don't get confused with the UI bits above.\n * UI_INPUT_FLAG_USER_BASE tells which is the lowest bit to use.  A good\n * example of use is this:\n *\n *    #define MY_UI_FLAG1       (0x01 << UI_INPUT_FLAG_USER_BASE)\n *\n*/\n# define UI_INPUT_FLAG_USER_BASE 16\n\n/*-\n * The following function helps construct a prompt.  object_desc is a\n * textual short description of the object, for example \"pass phrase\",\n * and object_name is the name of the object (might be a card name or\n * a file name.\n * The returned string shall always be allocated on the heap with\n * OPENSSL_malloc(), and need to be free'd with OPENSSL_free().\n *\n * If the ui_method doesn't contain a pointer to a user-defined prompt\n * constructor, a default string is built, looking like this:\n *\n *       \"Enter {object_desc} for {object_name}:\"\n *\n * So, if object_desc has the value \"pass phrase\" and object_name has\n * the value \"foo.key\", the resulting string is:\n *\n *       \"Enter pass phrase for foo.key:\"\n*/\nchar *UI_construct_prompt(UI *ui_method,\n                          const char *object_desc, const char *object_name);\n\n/*\n * The following function is used to store a pointer to user-specific data.\n * Any previous such pointer will be returned and replaced.\n *\n * For callback purposes, this function makes a lot more sense than using\n * ex_data, since the latter requires that different parts of OpenSSL or\n * applications share the same ex_data index.\n *\n * Note that the UI_OpenSSL() method completely ignores the user data. Other\n * methods may not, however.\n */\nvoid *UI_add_user_data(UI *ui, void *user_data);\n/* We need a user data retrieving function as well.  */\nvoid *UI_get0_user_data(UI *ui);\n\n/* Return the result associated with a prompt given with the index i. */\nconst char *UI_get0_result(UI *ui, int i);\n\n/* When all strings have been added, process the whole thing. */\nint UI_process(UI *ui);\n\n/*\n * Give a user interface parametrised control commands.  This can be used to\n * send down an integer, a data pointer or a function pointer, as well as be\n * used to get information from a UI.\n */\nint UI_ctrl(UI *ui, int cmd, long i, void *p, void (*f) (void));\n\n/* The commands */\n/*\n * Use UI_CONTROL_PRINT_ERRORS with the value 1 to have UI_process print the\n * OpenSSL error stack before printing any info or added error messages and\n * before any prompting.\n */\n# define UI_CTRL_PRINT_ERRORS            1\n/*\n * Check if a UI_process() is possible to do again with the same instance of\n * a user interface.  This makes UI_ctrl() return 1 if it is redoable, and 0\n * if not.\n */\n# define UI_CTRL_IS_REDOABLE             2\n\n/* Some methods may use extra data */\n# define UI_set_app_data(s,arg)         UI_set_ex_data(s,0,arg)\n# define UI_get_app_data(s)             UI_get_ex_data(s,0)\nint UI_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func,\n                        CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func);\nint UI_set_ex_data(UI *r, int idx, void *arg);\nvoid *UI_get_ex_data(UI *r, int idx);\n\n/* Use specific methods instead of the built-in one */\nvoid UI_set_default_method(const UI_METHOD *meth);\nconst UI_METHOD *UI_get_default_method(void);\nconst UI_METHOD *UI_get_method(UI *ui);\nconst UI_METHOD *UI_set_method(UI *ui, const UI_METHOD *meth);\n\n/* The method with all the built-in thingies */\nUI_METHOD *UI_OpenSSL(void);\n\n/* ---------- For method writers ---------- */\n/*-\n   A method contains a number of functions that implement the low level\n   of the User Interface.  The functions are:\n\n        an opener       This function starts a session, maybe by opening\n                        a channel to a tty, or by opening a window.\n        a writer        This function is called to write a given string,\n                        maybe to the tty, maybe as a field label in a\n                        window.\n        a flusher       This function is called to flush everything that\n                        has been output so far.  It can be used to actually\n                        display a dialog box after it has been built.\n        a reader        This function is called to read a given prompt,\n                        maybe from the tty, maybe from a field in a\n                        window.  Note that it's called wth all string\n                        structures, not only the prompt ones, so it must\n                        check such things itself.\n        a closer        This function closes the session, maybe by closing\n                        the channel to the tty, or closing the window.\n\n   All these functions are expected to return:\n\n        0       on error.\n        1       on success.\n        -1      on out-of-band events, for example if some prompting has\n                been canceled (by pressing Ctrl-C, for example).  This is\n                only checked when returned by the flusher or the reader.\n\n   The way this is used, the opener is first called, then the writer for all\n   strings, then the flusher, then the reader for all strings and finally the\n   closer.  Note that if you want to prompt from a terminal or other command\n   line interface, the best is to have the reader also write the prompts\n   instead of having the writer do it.  If you want to prompt from a dialog\n   box, the writer can be used to build up the contents of the box, and the\n   flusher to actually display the box and run the event loop until all data\n   has been given, after which the reader only grabs the given data and puts\n   them back into the UI strings.\n\n   All method functions take a UI as argument.  Additionally, the writer and\n   the reader take a UI_STRING.\n*/\n\n/*\n * The UI_STRING type is the data structure that contains all the needed info\n * about a string or a prompt, including test data for a verification prompt.\n */\ntypedef struct ui_string_st UI_STRING;\nDECLARE_STACK_OF(UI_STRING)\n\n/*\n * The different types of strings that are currently supported. This is only\n * needed by method authors.\n */\nenum UI_string_types {\n    UIT_NONE = 0,\n    UIT_PROMPT,                 /* Prompt for a string */\n    UIT_VERIFY,                 /* Prompt for a string and verify */\n    UIT_BOOLEAN,                /* Prompt for a yes/no response */\n    UIT_INFO,                   /* Send info to the user */\n    UIT_ERROR                   /* Send an error message to the user */\n};\n\n/* Create and manipulate methods */\nUI_METHOD *UI_create_method(char *name);\nvoid UI_destroy_method(UI_METHOD *ui_method);\nint UI_method_set_opener(UI_METHOD *method, int (*opener) (UI *ui));\nint UI_method_set_writer(UI_METHOD *method,\n                         int (*writer) (UI *ui, UI_STRING *uis));\nint UI_method_set_flusher(UI_METHOD *method, int (*flusher) (UI *ui));\nint UI_method_set_reader(UI_METHOD *method,\n                         int (*reader) (UI *ui, UI_STRING *uis));\nint UI_method_set_closer(UI_METHOD *method, int (*closer) (UI *ui));\nint UI_method_set_prompt_constructor(UI_METHOD *method,\n                                     char *(*prompt_constructor) (UI *ui,\n                                                                  const char\n                                                                  *object_desc,\n                                                                  const char\n                                                                  *object_name));\nint (*UI_method_get_opener(UI_METHOD *method)) (UI *);\nint (*UI_method_get_writer(UI_METHOD *method)) (UI *, UI_STRING *);\nint (*UI_method_get_flusher(UI_METHOD *method)) (UI *);\nint (*UI_method_get_reader(UI_METHOD *method)) (UI *, UI_STRING *);\nint (*UI_method_get_closer(UI_METHOD *method)) (UI *);\nchar *(*UI_method_get_prompt_constructor(UI_METHOD *method)) (UI *,\n                                                              const char *,\n                                                              const char *);\n\n/*\n * The following functions are helpers for method writers to access relevant\n * data from a UI_STRING.\n */\n\n/* Return type of the UI_STRING */\nenum UI_string_types UI_get_string_type(UI_STRING *uis);\n/* Return input flags of the UI_STRING */\nint UI_get_input_flags(UI_STRING *uis);\n/* Return the actual string to output (the prompt, info or error) */\nconst char *UI_get0_output_string(UI_STRING *uis);\n/*\n * Return the optional action string to output (the boolean promtp\n * instruction)\n */\nconst char *UI_get0_action_string(UI_STRING *uis);\n/* Return the result of a prompt */\nconst char *UI_get0_result_string(UI_STRING *uis);\n/*\n * Return the string to test the result against.  Only useful with verifies.\n */\nconst char *UI_get0_test_string(UI_STRING *uis);\n/* Return the required minimum size of the result */\nint UI_get_result_minsize(UI_STRING *uis);\n/* Return the required maximum size of the result */\nint UI_get_result_maxsize(UI_STRING *uis);\n/* Set the result of a UI_STRING. */\nint UI_set_result(UI *ui, UI_STRING *uis, const char *result);\n\n/* A couple of popular utility functions */\nint UI_UTIL_read_pw_string(char *buf, int length, const char *prompt,\n                           int verify);\nint UI_UTIL_read_pw(char *buf, char *buff, int size, const char *prompt,\n                    int verify);\n\n/* BEGIN ERROR CODES */\n/*\n * The following lines are auto generated by the script mkerr.pl. Any changes\n * made after this point may be overwritten when the script is next run.\n */\nvoid ERR_load_UI_strings(void);\n\n/* Error codes for the UI functions. */\n\n/* Function codes. */\n# define UI_F_GENERAL_ALLOCATE_BOOLEAN                    108\n# define UI_F_GENERAL_ALLOCATE_PROMPT                     109\n# define UI_F_GENERAL_ALLOCATE_STRING                     100\n# define UI_F_UI_CTRL                                     111\n# define UI_F_UI_DUP_ERROR_STRING                         101\n# define UI_F_UI_DUP_INFO_STRING                          102\n# define UI_F_UI_DUP_INPUT_BOOLEAN                        110\n# define UI_F_UI_DUP_INPUT_STRING                         103\n# define UI_F_UI_DUP_VERIFY_STRING                        106\n# define UI_F_UI_GET0_RESULT                              107\n# define UI_F_UI_NEW_METHOD                               104\n# define UI_F_UI_SET_RESULT                               105\n\n/* Reason codes. */\n# define UI_R_COMMON_OK_AND_CANCEL_CHARACTERS             104\n# define UI_R_INDEX_TOO_LARGE                             102\n# define UI_R_INDEX_TOO_SMALL                             103\n# define UI_R_NO_RESULT_BUFFER                            105\n# define UI_R_RESULT_TOO_LARGE                            100\n# define UI_R_RESULT_TOO_SMALL                            101\n# define UI_R_UNKNOWN_CONTROL_COMMAND                     106\n\n#ifdef  __cplusplus\n}\n#endif\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/arm/include/openssl/ui_compat.h",
    "content": "/* crypto/ui/ui.h */\n/*\n * Written by Richard Levitte (richard@levitte.org) for the OpenSSL project\n * 2001.\n */\n/* ====================================================================\n * Copyright (c) 2001 The OpenSSL Project.  All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n *\n * 1. Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n *\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in\n *    the documentation and/or other materials provided with the\n *    distribution.\n *\n * 3. All advertising materials mentioning features or use of this\n *    software must display the following acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit. (http://www.openssl.org/)\"\n *\n * 4. The names \"OpenSSL Toolkit\" and \"OpenSSL Project\" must not be used to\n *    endorse or promote products derived from this software without\n *    prior written permission. For written permission, please contact\n *    openssl-core@openssl.org.\n *\n * 5. Products derived from this software may not be called \"OpenSSL\"\n *    nor may \"OpenSSL\" appear in their names without prior written\n *    permission of the OpenSSL Project.\n *\n * 6. Redistributions of any form whatsoever must retain the following\n *    acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit (http://www.openssl.org/)\"\n *\n * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY\n * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\n * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR\n * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\n * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,\n * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED\n * OF THE POSSIBILITY OF SUCH DAMAGE.\n * ====================================================================\n *\n * This product includes cryptographic software written by Eric Young\n * (eay@cryptsoft.com).  This product includes software written by Tim\n * Hudson (tjh@cryptsoft.com).\n *\n */\n\n#ifndef HEADER_UI_COMPAT_H\n# define HEADER_UI_COMPAT_H\n\n# include <openssl/opensslconf.h>\n# include <openssl/ui.h>\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n/*\n * The following functions were previously part of the DES section, and are\n * provided here for backward compatibility reasons.\n */\n\n# define des_read_pw_string(b,l,p,v) \\\n        _ossl_old_des_read_pw_string((b),(l),(p),(v))\n# define des_read_pw(b,bf,s,p,v) \\\n        _ossl_old_des_read_pw((b),(bf),(s),(p),(v))\n\nint _ossl_old_des_read_pw_string(char *buf, int length, const char *prompt,\n                                 int verify);\nint _ossl_old_des_read_pw(char *buf, char *buff, int size, const char *prompt,\n                          int verify);\n\n#ifdef  __cplusplus\n}\n#endif\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/arm/include/openssl/whrlpool.h",
    "content": "#ifndef HEADER_WHRLPOOL_H\n# define HEADER_WHRLPOOL_H\n\n# include <openssl/e_os2.h>\n# include <stddef.h>\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n# define WHIRLPOOL_DIGEST_LENGTH (512/8)\n# define WHIRLPOOL_BBLOCK        512\n# define WHIRLPOOL_COUNTER       (256/8)\n\ntypedef struct {\n    union {\n        unsigned char c[WHIRLPOOL_DIGEST_LENGTH];\n        /* double q is here to ensure 64-bit alignment */\n        double q[WHIRLPOOL_DIGEST_LENGTH / sizeof(double)];\n    } H;\n    unsigned char data[WHIRLPOOL_BBLOCK / 8];\n    unsigned int bitoff;\n    size_t bitlen[WHIRLPOOL_COUNTER / sizeof(size_t)];\n} WHIRLPOOL_CTX;\n\n# ifndef OPENSSL_NO_WHIRLPOOL\n#  ifdef OPENSSL_FIPS\nint private_WHIRLPOOL_Init(WHIRLPOOL_CTX *c);\n#  endif\nint WHIRLPOOL_Init(WHIRLPOOL_CTX *c);\nint WHIRLPOOL_Update(WHIRLPOOL_CTX *c, const void *inp, size_t bytes);\nvoid WHIRLPOOL_BitUpdate(WHIRLPOOL_CTX *c, const void *inp, size_t bits);\nint WHIRLPOOL_Final(unsigned char *md, WHIRLPOOL_CTX *c);\nunsigned char *WHIRLPOOL(const void *inp, size_t bytes, unsigned char *md);\n# endif\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/arm/include/openssl/x509.h",
    "content": "/* crypto/x509/x509.h */\n/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)\n * All rights reserved.\n *\n * This package is an SSL implementation written\n * by Eric Young (eay@cryptsoft.com).\n * The implementation was written so as to conform with Netscapes SSL.\n *\n * This library is free for commercial and non-commercial use as long as\n * the following conditions are aheared to.  The following conditions\n * apply to all code found in this distribution, be it the RC4, RSA,\n * lhash, DES, etc., code; not just the SSL code.  The SSL documentation\n * included with this distribution is covered by the same copyright terms\n * except that the holder is Tim Hudson (tjh@cryptsoft.com).\n *\n * Copyright remains Eric Young's, and as such any Copyright notices in\n * the code are not to be removed.\n * If this package is used in a product, Eric Young should be given attribution\n * as the author of the parts of the library used.\n * This can be in the form of a textual message at program startup or\n * in documentation (online or textual) provided with the package.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the copyright\n *    notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in the\n *    documentation and/or other materials provided with the distribution.\n * 3. All advertising materials mentioning features or use of this software\n *    must display the following acknowledgement:\n *    \"This product includes cryptographic software written by\n *     Eric Young (eay@cryptsoft.com)\"\n *    The word 'cryptographic' can be left out if the rouines from the library\n *    being used are not cryptographic related :-).\n * 4. If you include any Windows specific code (or a derivative thereof) from\n *    the apps directory (application code) you must include an acknowledgement:\n *    \"This product includes software written by Tim Hudson (tjh@cryptsoft.com)\"\n *\n * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n * SUCH DAMAGE.\n *\n * The licence and distribution terms for any publically available version or\n * derivative of this code cannot be changed.  i.e. this code cannot simply be\n * copied and put under another distribution licence\n * [including the GNU Public Licence.]\n */\n/* ====================================================================\n * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED.\n * ECDH support in OpenSSL originally developed by\n * SUN MICROSYSTEMS, INC., and contributed to the OpenSSL project.\n */\n\n#ifndef HEADER_X509_H\n# define HEADER_X509_H\n\n# include <openssl/e_os2.h>\n# include <openssl/symhacks.h>\n# ifndef OPENSSL_NO_BUFFER\n#  include <openssl/buffer.h>\n# endif\n# ifndef OPENSSL_NO_EVP\n#  include <openssl/evp.h>\n# endif\n# ifndef OPENSSL_NO_BIO\n#  include <openssl/bio.h>\n# endif\n# include <openssl/stack.h>\n# include <openssl/asn1.h>\n# include <openssl/safestack.h>\n\n# ifndef OPENSSL_NO_EC\n#  include <openssl/ec.h>\n# endif\n\n# ifndef OPENSSL_NO_ECDSA\n#  include <openssl/ecdsa.h>\n# endif\n\n# ifndef OPENSSL_NO_ECDH\n#  include <openssl/ecdh.h>\n# endif\n\n# ifndef OPENSSL_NO_DEPRECATED\n#  ifndef OPENSSL_NO_RSA\n#   include <openssl/rsa.h>\n#  endif\n#  ifndef OPENSSL_NO_DSA\n#   include <openssl/dsa.h>\n#  endif\n#  ifndef OPENSSL_NO_DH\n#   include <openssl/dh.h>\n#  endif\n# endif\n\n# ifndef OPENSSL_NO_SHA\n#  include <openssl/sha.h>\n# endif\n# include <openssl/ossl_typ.h>\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n# ifdef OPENSSL_SYS_WIN32\n/* Under Win32 these are defined in wincrypt.h */\n#  undef X509_NAME\n#  undef X509_CERT_PAIR\n#  undef X509_EXTENSIONS\n# endif\n\n# define X509_FILETYPE_PEM       1\n# define X509_FILETYPE_ASN1      2\n# define X509_FILETYPE_DEFAULT   3\n\n# define X509v3_KU_DIGITAL_SIGNATURE     0x0080\n# define X509v3_KU_NON_REPUDIATION       0x0040\n# define X509v3_KU_KEY_ENCIPHERMENT      0x0020\n# define X509v3_KU_DATA_ENCIPHERMENT     0x0010\n# define X509v3_KU_KEY_AGREEMENT         0x0008\n# define X509v3_KU_KEY_CERT_SIGN         0x0004\n# define X509v3_KU_CRL_SIGN              0x0002\n# define X509v3_KU_ENCIPHER_ONLY         0x0001\n# define X509v3_KU_DECIPHER_ONLY         0x8000\n# define X509v3_KU_UNDEF                 0xffff\n\ntypedef struct X509_objects_st {\n    int nid;\n    int (*a2i) (void);\n    int (*i2a) (void);\n} X509_OBJECTS;\n\nstruct X509_algor_st {\n    ASN1_OBJECT *algorithm;\n    ASN1_TYPE *parameter;\n} /* X509_ALGOR */ ;\n\nDECLARE_ASN1_SET_OF(X509_ALGOR)\n\ntypedef STACK_OF(X509_ALGOR) X509_ALGORS;\n\ntypedef struct X509_val_st {\n    ASN1_TIME *notBefore;\n    ASN1_TIME *notAfter;\n} X509_VAL;\n\nstruct X509_pubkey_st {\n    X509_ALGOR *algor;\n    ASN1_BIT_STRING *public_key;\n    EVP_PKEY *pkey;\n};\n\ntypedef struct X509_sig_st {\n    X509_ALGOR *algor;\n    ASN1_OCTET_STRING *digest;\n} X509_SIG;\n\ntypedef struct X509_name_entry_st {\n    ASN1_OBJECT *object;\n    ASN1_STRING *value;\n    int set;\n    int size;                   /* temp variable */\n} X509_NAME_ENTRY;\n\nDECLARE_STACK_OF(X509_NAME_ENTRY)\nDECLARE_ASN1_SET_OF(X509_NAME_ENTRY)\n\n/* we always keep X509_NAMEs in 2 forms. */\nstruct X509_name_st {\n    STACK_OF(X509_NAME_ENTRY) *entries;\n    int modified;               /* true if 'bytes' needs to be built */\n# ifndef OPENSSL_NO_BUFFER\n    BUF_MEM *bytes;\n# else\n    char *bytes;\n# endif\n/*      unsigned long hash; Keep the hash around for lookups */\n    unsigned char *canon_enc;\n    int canon_enclen;\n} /* X509_NAME */ ;\n\nDECLARE_STACK_OF(X509_NAME)\n\n# define X509_EX_V_NETSCAPE_HACK         0x8000\n# define X509_EX_V_INIT                  0x0001\ntypedef struct X509_extension_st {\n    ASN1_OBJECT *object;\n    ASN1_BOOLEAN critical;\n    ASN1_OCTET_STRING *value;\n} X509_EXTENSION;\n\ntypedef STACK_OF(X509_EXTENSION) X509_EXTENSIONS;\n\nDECLARE_STACK_OF(X509_EXTENSION)\nDECLARE_ASN1_SET_OF(X509_EXTENSION)\n\n/* a sequence of these are used */\ntypedef struct x509_attributes_st {\n    ASN1_OBJECT *object;\n    int single;                 /* 0 for a set, 1 for a single item (which is\n                                 * wrong) */\n    union {\n        char *ptr;\n        /*\n         * 0\n         */ STACK_OF(ASN1_TYPE) *set;\n        /*\n         * 1\n         */ ASN1_TYPE *single;\n    } value;\n} X509_ATTRIBUTE;\n\nDECLARE_STACK_OF(X509_ATTRIBUTE)\nDECLARE_ASN1_SET_OF(X509_ATTRIBUTE)\n\ntypedef struct X509_req_info_st {\n    ASN1_ENCODING enc;\n    ASN1_INTEGER *version;\n    X509_NAME *subject;\n    X509_PUBKEY *pubkey;\n    /*  d=2 hl=2 l=  0 cons: cont: 00 */\n    STACK_OF(X509_ATTRIBUTE) *attributes; /* [ 0 ] */\n} X509_REQ_INFO;\n\ntypedef struct X509_req_st {\n    X509_REQ_INFO *req_info;\n    X509_ALGOR *sig_alg;\n    ASN1_BIT_STRING *signature;\n    int references;\n} X509_REQ;\n\ntypedef struct x509_cinf_st {\n    ASN1_INTEGER *version;      /* [ 0 ] default of v1 */\n    ASN1_INTEGER *serialNumber;\n    X509_ALGOR *signature;\n    X509_NAME *issuer;\n    X509_VAL *validity;\n    X509_NAME *subject;\n    X509_PUBKEY *key;\n    ASN1_BIT_STRING *issuerUID; /* [ 1 ] optional in v2 */\n    ASN1_BIT_STRING *subjectUID; /* [ 2 ] optional in v2 */\n    STACK_OF(X509_EXTENSION) *extensions; /* [ 3 ] optional in v3 */\n    ASN1_ENCODING enc;\n} X509_CINF;\n\n/*\n * This stuff is certificate \"auxiliary info\" it contains details which are\n * useful in certificate stores and databases. When used this is tagged onto\n * the end of the certificate itself\n */\n\ntypedef struct x509_cert_aux_st {\n    STACK_OF(ASN1_OBJECT) *trust; /* trusted uses */\n    STACK_OF(ASN1_OBJECT) *reject; /* rejected uses */\n    ASN1_UTF8STRING *alias;     /* \"friendly name\" */\n    ASN1_OCTET_STRING *keyid;   /* key id of private key */\n    STACK_OF(X509_ALGOR) *other; /* other unspecified info */\n} X509_CERT_AUX;\n\nstruct x509_st {\n    X509_CINF *cert_info;\n    X509_ALGOR *sig_alg;\n    ASN1_BIT_STRING *signature;\n    int valid;\n    int references;\n    char *name;\n    CRYPTO_EX_DATA ex_data;\n    /* These contain copies of various extension values */\n    long ex_pathlen;\n    long ex_pcpathlen;\n    unsigned long ex_flags;\n    unsigned long ex_kusage;\n    unsigned long ex_xkusage;\n    unsigned long ex_nscert;\n    ASN1_OCTET_STRING *skid;\n    AUTHORITY_KEYID *akid;\n    X509_POLICY_CACHE *policy_cache;\n    STACK_OF(DIST_POINT) *crldp;\n    STACK_OF(GENERAL_NAME) *altname;\n    NAME_CONSTRAINTS *nc;\n# ifndef OPENSSL_NO_RFC3779\n    STACK_OF(IPAddressFamily) *rfc3779_addr;\n    struct ASIdentifiers_st *rfc3779_asid;\n# endif\n# ifndef OPENSSL_NO_SHA\n    unsigned char sha1_hash[SHA_DIGEST_LENGTH];\n# endif\n    X509_CERT_AUX *aux;\n} /* X509 */ ;\n\nDECLARE_STACK_OF(X509)\nDECLARE_ASN1_SET_OF(X509)\n\n/* This is used for a table of trust checking functions */\n\ntypedef struct x509_trust_st {\n    int trust;\n    int flags;\n    int (*check_trust) (struct x509_trust_st *, X509 *, int);\n    char *name;\n    int arg1;\n    void *arg2;\n} X509_TRUST;\n\nDECLARE_STACK_OF(X509_TRUST)\n\ntypedef struct x509_cert_pair_st {\n    X509 *forward;\n    X509 *reverse;\n} X509_CERT_PAIR;\n\n/* standard trust ids */\n\n# define X509_TRUST_DEFAULT      -1/* Only valid in purpose settings */\n\n# define X509_TRUST_COMPAT       1\n# define X509_TRUST_SSL_CLIENT   2\n# define X509_TRUST_SSL_SERVER   3\n# define X509_TRUST_EMAIL        4\n# define X509_TRUST_OBJECT_SIGN  5\n# define X509_TRUST_OCSP_SIGN    6\n# define X509_TRUST_OCSP_REQUEST 7\n# define X509_TRUST_TSA          8\n\n/* Keep these up to date! */\n# define X509_TRUST_MIN          1\n# define X509_TRUST_MAX          8\n\n/* trust_flags values */\n# define X509_TRUST_DYNAMIC      1\n# define X509_TRUST_DYNAMIC_NAME 2\n\n/* check_trust return codes */\n\n# define X509_TRUST_TRUSTED      1\n# define X509_TRUST_REJECTED     2\n# define X509_TRUST_UNTRUSTED    3\n\n/* Flags for X509_print_ex() */\n\n# define X509_FLAG_COMPAT                0\n# define X509_FLAG_NO_HEADER             1L\n# define X509_FLAG_NO_VERSION            (1L << 1)\n# define X509_FLAG_NO_SERIAL             (1L << 2)\n# define X509_FLAG_NO_SIGNAME            (1L << 3)\n# define X509_FLAG_NO_ISSUER             (1L << 4)\n# define X509_FLAG_NO_VALIDITY           (1L << 5)\n# define X509_FLAG_NO_SUBJECT            (1L << 6)\n# define X509_FLAG_NO_PUBKEY             (1L << 7)\n# define X509_FLAG_NO_EXTENSIONS         (1L << 8)\n# define X509_FLAG_NO_SIGDUMP            (1L << 9)\n# define X509_FLAG_NO_AUX                (1L << 10)\n# define X509_FLAG_NO_ATTRIBUTES         (1L << 11)\n# define X509_FLAG_NO_IDS                (1L << 12)\n\n/* Flags specific to X509_NAME_print_ex() */\n\n/* The field separator information */\n\n# define XN_FLAG_SEP_MASK        (0xf << 16)\n\n# define XN_FLAG_COMPAT          0/* Traditional SSLeay: use old\n                                   * X509_NAME_print */\n# define XN_FLAG_SEP_COMMA_PLUS  (1 << 16)/* RFC2253 ,+ */\n# define XN_FLAG_SEP_CPLUS_SPC   (2 << 16)/* ,+ spaced: more readable */\n# define XN_FLAG_SEP_SPLUS_SPC   (3 << 16)/* ;+ spaced */\n# define XN_FLAG_SEP_MULTILINE   (4 << 16)/* One line per field */\n\n# define XN_FLAG_DN_REV          (1 << 20)/* Reverse DN order */\n\n/* How the field name is shown */\n\n# define XN_FLAG_FN_MASK         (0x3 << 21)\n\n# define XN_FLAG_FN_SN           0/* Object short name */\n# define XN_FLAG_FN_LN           (1 << 21)/* Object long name */\n# define XN_FLAG_FN_OID          (2 << 21)/* Always use OIDs */\n# define XN_FLAG_FN_NONE         (3 << 21)/* No field names */\n\n# define XN_FLAG_SPC_EQ          (1 << 23)/* Put spaces round '=' */\n\n/*\n * This determines if we dump fields we don't recognise: RFC2253 requires\n * this.\n */\n\n# define XN_FLAG_DUMP_UNKNOWN_FIELDS (1 << 24)\n\n# define XN_FLAG_FN_ALIGN        (1 << 25)/* Align field names to 20\n                                           * characters */\n\n/* Complete set of RFC2253 flags */\n\n# define XN_FLAG_RFC2253 (ASN1_STRFLGS_RFC2253 | \\\n                        XN_FLAG_SEP_COMMA_PLUS | \\\n                        XN_FLAG_DN_REV | \\\n                        XN_FLAG_FN_SN | \\\n                        XN_FLAG_DUMP_UNKNOWN_FIELDS)\n\n/* readable oneline form */\n\n# define XN_FLAG_ONELINE (ASN1_STRFLGS_RFC2253 | \\\n                        ASN1_STRFLGS_ESC_QUOTE | \\\n                        XN_FLAG_SEP_CPLUS_SPC | \\\n                        XN_FLAG_SPC_EQ | \\\n                        XN_FLAG_FN_SN)\n\n/* readable multiline form */\n\n# define XN_FLAG_MULTILINE (ASN1_STRFLGS_ESC_CTRL | \\\n                        ASN1_STRFLGS_ESC_MSB | \\\n                        XN_FLAG_SEP_MULTILINE | \\\n                        XN_FLAG_SPC_EQ | \\\n                        XN_FLAG_FN_LN | \\\n                        XN_FLAG_FN_ALIGN)\n\nstruct x509_revoked_st {\n    ASN1_INTEGER *serialNumber;\n    ASN1_TIME *revocationDate;\n    STACK_OF(X509_EXTENSION) /* optional */ *extensions;\n    /* Set up if indirect CRL */\n    STACK_OF(GENERAL_NAME) *issuer;\n    /* Revocation reason */\n    int reason;\n    int sequence;               /* load sequence */\n};\n\nDECLARE_STACK_OF(X509_REVOKED)\nDECLARE_ASN1_SET_OF(X509_REVOKED)\n\ntypedef struct X509_crl_info_st {\n    ASN1_INTEGER *version;\n    X509_ALGOR *sig_alg;\n    X509_NAME *issuer;\n    ASN1_TIME *lastUpdate;\n    ASN1_TIME *nextUpdate;\n    STACK_OF(X509_REVOKED) *revoked;\n    STACK_OF(X509_EXTENSION) /* [0] */ *extensions;\n    ASN1_ENCODING enc;\n} X509_CRL_INFO;\n\nstruct X509_crl_st {\n    /* actual signature */\n    X509_CRL_INFO *crl;\n    X509_ALGOR *sig_alg;\n    ASN1_BIT_STRING *signature;\n    int references;\n    int flags;\n    /* Copies of various extensions */\n    AUTHORITY_KEYID *akid;\n    ISSUING_DIST_POINT *idp;\n    /* Convenient breakdown of IDP */\n    int idp_flags;\n    int idp_reasons;\n    /* CRL and base CRL numbers for delta processing */\n    ASN1_INTEGER *crl_number;\n    ASN1_INTEGER *base_crl_number;\n# ifndef OPENSSL_NO_SHA\n    unsigned char sha1_hash[SHA_DIGEST_LENGTH];\n# endif\n    STACK_OF(GENERAL_NAMES) *issuers;\n    const X509_CRL_METHOD *meth;\n    void *meth_data;\n} /* X509_CRL */ ;\n\nDECLARE_STACK_OF(X509_CRL)\nDECLARE_ASN1_SET_OF(X509_CRL)\n\ntypedef struct private_key_st {\n    int version;\n    /* The PKCS#8 data types */\n    X509_ALGOR *enc_algor;\n    ASN1_OCTET_STRING *enc_pkey; /* encrypted pub key */\n    /* When decrypted, the following will not be NULL */\n    EVP_PKEY *dec_pkey;\n    /* used to encrypt and decrypt */\n    int key_length;\n    char *key_data;\n    int key_free;               /* true if we should auto free key_data */\n    /* expanded version of 'enc_algor' */\n    EVP_CIPHER_INFO cipher;\n    int references;\n} X509_PKEY;\n\n# ifndef OPENSSL_NO_EVP\ntypedef struct X509_info_st {\n    X509 *x509;\n    X509_CRL *crl;\n    X509_PKEY *x_pkey;\n    EVP_CIPHER_INFO enc_cipher;\n    int enc_len;\n    char *enc_data;\n    int references;\n} X509_INFO;\n\nDECLARE_STACK_OF(X509_INFO)\n# endif\n\n/*\n * The next 2 structures and their 8 routines were sent to me by Pat Richard\n * <patr@x509.com> and are used to manipulate Netscapes spki structures -\n * useful if you are writing a CA web page\n */\ntypedef struct Netscape_spkac_st {\n    X509_PUBKEY *pubkey;\n    ASN1_IA5STRING *challenge;  /* challenge sent in atlas >= PR2 */\n} NETSCAPE_SPKAC;\n\ntypedef struct Netscape_spki_st {\n    NETSCAPE_SPKAC *spkac;      /* signed public key and challenge */\n    X509_ALGOR *sig_algor;\n    ASN1_BIT_STRING *signature;\n} NETSCAPE_SPKI;\n\n/* Netscape certificate sequence structure */\ntypedef struct Netscape_certificate_sequence {\n    ASN1_OBJECT *type;\n    STACK_OF(X509) *certs;\n} NETSCAPE_CERT_SEQUENCE;\n\n/*- Unused (and iv length is wrong)\ntypedef struct CBCParameter_st\n        {\n        unsigned char iv[8];\n        } CBC_PARAM;\n*/\n\n/* Password based encryption structure */\n\ntypedef struct PBEPARAM_st {\n    ASN1_OCTET_STRING *salt;\n    ASN1_INTEGER *iter;\n} PBEPARAM;\n\n/* Password based encryption V2 structures */\n\ntypedef struct PBE2PARAM_st {\n    X509_ALGOR *keyfunc;\n    X509_ALGOR *encryption;\n} PBE2PARAM;\n\ntypedef struct PBKDF2PARAM_st {\n/* Usually OCTET STRING but could be anything */\n    ASN1_TYPE *salt;\n    ASN1_INTEGER *iter;\n    ASN1_INTEGER *keylength;\n    X509_ALGOR *prf;\n} PBKDF2PARAM;\n\n/* PKCS#8 private key info structure */\n\nstruct pkcs8_priv_key_info_st {\n    /* Flag for various broken formats */\n    int broken;\n# define PKCS8_OK                0\n# define PKCS8_NO_OCTET          1\n# define PKCS8_EMBEDDED_PARAM    2\n# define PKCS8_NS_DB             3\n# define PKCS8_NEG_PRIVKEY       4\n    ASN1_INTEGER *version;\n    X509_ALGOR *pkeyalg;\n    /* Should be OCTET STRING but some are broken */\n    ASN1_TYPE *pkey;\n    STACK_OF(X509_ATTRIBUTE) *attributes;\n};\n\n#ifdef  __cplusplus\n}\n#endif\n\n# include <openssl/x509_vfy.h>\n# include <openssl/pkcs7.h>\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n# define X509_EXT_PACK_UNKNOWN   1\n# define X509_EXT_PACK_STRING    2\n\n# define         X509_get_version(x) ASN1_INTEGER_get((x)->cert_info->version)\n/* #define      X509_get_serialNumber(x) ((x)->cert_info->serialNumber) */\n# define         X509_get_notBefore(x) ((x)->cert_info->validity->notBefore)\n# define         X509_get_notAfter(x) ((x)->cert_info->validity->notAfter)\n# define         X509_extract_key(x)     X509_get_pubkey(x)/*****/\n# define         X509_REQ_get_version(x) ASN1_INTEGER_get((x)->req_info->version)\n# define         X509_REQ_get_subject_name(x) ((x)->req_info->subject)\n# define         X509_REQ_extract_key(a) X509_REQ_get_pubkey(a)\n# define         X509_name_cmp(a,b)      X509_NAME_cmp((a),(b))\n# define         X509_get_signature_type(x) EVP_PKEY_type(OBJ_obj2nid((x)->sig_alg->algorithm))\n\n# define         X509_CRL_get_version(x) ASN1_INTEGER_get((x)->crl->version)\n# define         X509_CRL_get_lastUpdate(x) ((x)->crl->lastUpdate)\n# define         X509_CRL_get_nextUpdate(x) ((x)->crl->nextUpdate)\n# define         X509_CRL_get_issuer(x) ((x)->crl->issuer)\n# define         X509_CRL_get_REVOKED(x) ((x)->crl->revoked)\n\nvoid X509_CRL_set_default_method(const X509_CRL_METHOD *meth);\nX509_CRL_METHOD *X509_CRL_METHOD_new(int (*crl_init) (X509_CRL *crl),\n                                     int (*crl_free) (X509_CRL *crl),\n                                     int (*crl_lookup) (X509_CRL *crl,\n                                                        X509_REVOKED **ret,\n                                                        ASN1_INTEGER *ser,\n                                                        X509_NAME *issuer),\n                                     int (*crl_verify) (X509_CRL *crl,\n                                                        EVP_PKEY *pk));\nvoid X509_CRL_METHOD_free(X509_CRL_METHOD *m);\n\nvoid X509_CRL_set_meth_data(X509_CRL *crl, void *dat);\nvoid *X509_CRL_get_meth_data(X509_CRL *crl);\n\n/*\n * This one is only used so that a binary form can output, as in\n * i2d_X509_NAME(X509_get_X509_PUBKEY(x),&buf)\n */\n# define         X509_get_X509_PUBKEY(x) ((x)->cert_info->key)\n\nconst char *X509_verify_cert_error_string(long n);\n\n# ifndef OPENSSL_NO_EVP\nint X509_verify(X509 *a, EVP_PKEY *r);\n\nint X509_REQ_verify(X509_REQ *a, EVP_PKEY *r);\nint X509_CRL_verify(X509_CRL *a, EVP_PKEY *r);\nint NETSCAPE_SPKI_verify(NETSCAPE_SPKI *a, EVP_PKEY *r);\n\nNETSCAPE_SPKI *NETSCAPE_SPKI_b64_decode(const char *str, int len);\nchar *NETSCAPE_SPKI_b64_encode(NETSCAPE_SPKI *x);\nEVP_PKEY *NETSCAPE_SPKI_get_pubkey(NETSCAPE_SPKI *x);\nint NETSCAPE_SPKI_set_pubkey(NETSCAPE_SPKI *x, EVP_PKEY *pkey);\n\nint NETSCAPE_SPKI_print(BIO *out, NETSCAPE_SPKI *spki);\n\nint X509_signature_dump(BIO *bp, const ASN1_STRING *sig, int indent);\nint X509_signature_print(BIO *bp, X509_ALGOR *alg, ASN1_STRING *sig);\n\nint X509_sign(X509 *x, EVP_PKEY *pkey, const EVP_MD *md);\nint X509_sign_ctx(X509 *x, EVP_MD_CTX *ctx);\nint X509_http_nbio(OCSP_REQ_CTX *rctx, X509 **pcert);\nint X509_REQ_sign(X509_REQ *x, EVP_PKEY *pkey, const EVP_MD *md);\nint X509_REQ_sign_ctx(X509_REQ *x, EVP_MD_CTX *ctx);\nint X509_CRL_sign(X509_CRL *x, EVP_PKEY *pkey, const EVP_MD *md);\nint X509_CRL_sign_ctx(X509_CRL *x, EVP_MD_CTX *ctx);\nint X509_CRL_http_nbio(OCSP_REQ_CTX *rctx, X509_CRL **pcrl);\nint NETSCAPE_SPKI_sign(NETSCAPE_SPKI *x, EVP_PKEY *pkey, const EVP_MD *md);\n\nint X509_pubkey_digest(const X509 *data, const EVP_MD *type,\n                       unsigned char *md, unsigned int *len);\nint X509_digest(const X509 *data, const EVP_MD *type,\n                unsigned char *md, unsigned int *len);\nint X509_CRL_digest(const X509_CRL *data, const EVP_MD *type,\n                    unsigned char *md, unsigned int *len);\nint X509_REQ_digest(const X509_REQ *data, const EVP_MD *type,\n                    unsigned char *md, unsigned int *len);\nint X509_NAME_digest(const X509_NAME *data, const EVP_MD *type,\n                     unsigned char *md, unsigned int *len);\n# endif\n\n# ifndef OPENSSL_NO_FP_API\nX509 *d2i_X509_fp(FILE *fp, X509 **x509);\nint i2d_X509_fp(FILE *fp, X509 *x509);\nX509_CRL *d2i_X509_CRL_fp(FILE *fp, X509_CRL **crl);\nint i2d_X509_CRL_fp(FILE *fp, X509_CRL *crl);\nX509_REQ *d2i_X509_REQ_fp(FILE *fp, X509_REQ **req);\nint i2d_X509_REQ_fp(FILE *fp, X509_REQ *req);\n#  ifndef OPENSSL_NO_RSA\nRSA *d2i_RSAPrivateKey_fp(FILE *fp, RSA **rsa);\nint i2d_RSAPrivateKey_fp(FILE *fp, RSA *rsa);\nRSA *d2i_RSAPublicKey_fp(FILE *fp, RSA **rsa);\nint i2d_RSAPublicKey_fp(FILE *fp, RSA *rsa);\nRSA *d2i_RSA_PUBKEY_fp(FILE *fp, RSA **rsa);\nint i2d_RSA_PUBKEY_fp(FILE *fp, RSA *rsa);\n#  endif\n#  ifndef OPENSSL_NO_DSA\nDSA *d2i_DSA_PUBKEY_fp(FILE *fp, DSA **dsa);\nint i2d_DSA_PUBKEY_fp(FILE *fp, DSA *dsa);\nDSA *d2i_DSAPrivateKey_fp(FILE *fp, DSA **dsa);\nint i2d_DSAPrivateKey_fp(FILE *fp, DSA *dsa);\n#  endif\n#  ifndef OPENSSL_NO_EC\nEC_KEY *d2i_EC_PUBKEY_fp(FILE *fp, EC_KEY **eckey);\nint i2d_EC_PUBKEY_fp(FILE *fp, EC_KEY *eckey);\nEC_KEY *d2i_ECPrivateKey_fp(FILE *fp, EC_KEY **eckey);\nint i2d_ECPrivateKey_fp(FILE *fp, EC_KEY *eckey);\n#  endif\nX509_SIG *d2i_PKCS8_fp(FILE *fp, X509_SIG **p8);\nint i2d_PKCS8_fp(FILE *fp, X509_SIG *p8);\nPKCS8_PRIV_KEY_INFO *d2i_PKCS8_PRIV_KEY_INFO_fp(FILE *fp,\n                                                PKCS8_PRIV_KEY_INFO **p8inf);\nint i2d_PKCS8_PRIV_KEY_INFO_fp(FILE *fp, PKCS8_PRIV_KEY_INFO *p8inf);\nint i2d_PKCS8PrivateKeyInfo_fp(FILE *fp, EVP_PKEY *key);\nint i2d_PrivateKey_fp(FILE *fp, EVP_PKEY *pkey);\nEVP_PKEY *d2i_PrivateKey_fp(FILE *fp, EVP_PKEY **a);\nint i2d_PUBKEY_fp(FILE *fp, EVP_PKEY *pkey);\nEVP_PKEY *d2i_PUBKEY_fp(FILE *fp, EVP_PKEY **a);\n# endif\n\n# ifndef OPENSSL_NO_BIO\nX509 *d2i_X509_bio(BIO *bp, X509 **x509);\nint i2d_X509_bio(BIO *bp, X509 *x509);\nX509_CRL *d2i_X509_CRL_bio(BIO *bp, X509_CRL **crl);\nint i2d_X509_CRL_bio(BIO *bp, X509_CRL *crl);\nX509_REQ *d2i_X509_REQ_bio(BIO *bp, X509_REQ **req);\nint i2d_X509_REQ_bio(BIO *bp, X509_REQ *req);\n#  ifndef OPENSSL_NO_RSA\nRSA *d2i_RSAPrivateKey_bio(BIO *bp, RSA **rsa);\nint i2d_RSAPrivateKey_bio(BIO *bp, RSA *rsa);\nRSA *d2i_RSAPublicKey_bio(BIO *bp, RSA **rsa);\nint i2d_RSAPublicKey_bio(BIO *bp, RSA *rsa);\nRSA *d2i_RSA_PUBKEY_bio(BIO *bp, RSA **rsa);\nint i2d_RSA_PUBKEY_bio(BIO *bp, RSA *rsa);\n#  endif\n#  ifndef OPENSSL_NO_DSA\nDSA *d2i_DSA_PUBKEY_bio(BIO *bp, DSA **dsa);\nint i2d_DSA_PUBKEY_bio(BIO *bp, DSA *dsa);\nDSA *d2i_DSAPrivateKey_bio(BIO *bp, DSA **dsa);\nint i2d_DSAPrivateKey_bio(BIO *bp, DSA *dsa);\n#  endif\n#  ifndef OPENSSL_NO_EC\nEC_KEY *d2i_EC_PUBKEY_bio(BIO *bp, EC_KEY **eckey);\nint i2d_EC_PUBKEY_bio(BIO *bp, EC_KEY *eckey);\nEC_KEY *d2i_ECPrivateKey_bio(BIO *bp, EC_KEY **eckey);\nint i2d_ECPrivateKey_bio(BIO *bp, EC_KEY *eckey);\n#  endif\nX509_SIG *d2i_PKCS8_bio(BIO *bp, X509_SIG **p8);\nint i2d_PKCS8_bio(BIO *bp, X509_SIG *p8);\nPKCS8_PRIV_KEY_INFO *d2i_PKCS8_PRIV_KEY_INFO_bio(BIO *bp,\n                                                 PKCS8_PRIV_KEY_INFO **p8inf);\nint i2d_PKCS8_PRIV_KEY_INFO_bio(BIO *bp, PKCS8_PRIV_KEY_INFO *p8inf);\nint i2d_PKCS8PrivateKeyInfo_bio(BIO *bp, EVP_PKEY *key);\nint i2d_PrivateKey_bio(BIO *bp, EVP_PKEY *pkey);\nEVP_PKEY *d2i_PrivateKey_bio(BIO *bp, EVP_PKEY **a);\nint i2d_PUBKEY_bio(BIO *bp, EVP_PKEY *pkey);\nEVP_PKEY *d2i_PUBKEY_bio(BIO *bp, EVP_PKEY **a);\n# endif\n\nX509 *X509_dup(X509 *x509);\nX509_ATTRIBUTE *X509_ATTRIBUTE_dup(X509_ATTRIBUTE *xa);\nX509_EXTENSION *X509_EXTENSION_dup(X509_EXTENSION *ex);\nX509_CRL *X509_CRL_dup(X509_CRL *crl);\nX509_REVOKED *X509_REVOKED_dup(X509_REVOKED *rev);\nX509_REQ *X509_REQ_dup(X509_REQ *req);\nX509_ALGOR *X509_ALGOR_dup(X509_ALGOR *xn);\nint X509_ALGOR_set0(X509_ALGOR *alg, ASN1_OBJECT *aobj, int ptype,\n                    void *pval);\nvoid X509_ALGOR_get0(ASN1_OBJECT **paobj, int *pptype, void **ppval,\n                     X509_ALGOR *algor);\nvoid X509_ALGOR_set_md(X509_ALGOR *alg, const EVP_MD *md);\nint X509_ALGOR_cmp(const X509_ALGOR *a, const X509_ALGOR *b);\n\nX509_NAME *X509_NAME_dup(X509_NAME *xn);\nX509_NAME_ENTRY *X509_NAME_ENTRY_dup(X509_NAME_ENTRY *ne);\n\nint X509_cmp_time(const ASN1_TIME *s, time_t *t);\nint X509_cmp_current_time(const ASN1_TIME *s);\nASN1_TIME *X509_time_adj(ASN1_TIME *s, long adj, time_t *t);\nASN1_TIME *X509_time_adj_ex(ASN1_TIME *s,\n                            int offset_day, long offset_sec, time_t *t);\nASN1_TIME *X509_gmtime_adj(ASN1_TIME *s, long adj);\n\nconst char *X509_get_default_cert_area(void);\nconst char *X509_get_default_cert_dir(void);\nconst char *X509_get_default_cert_file(void);\nconst char *X509_get_default_cert_dir_env(void);\nconst char *X509_get_default_cert_file_env(void);\nconst char *X509_get_default_private_dir(void);\n\nX509_REQ *X509_to_X509_REQ(X509 *x, EVP_PKEY *pkey, const EVP_MD *md);\nX509 *X509_REQ_to_X509(X509_REQ *r, int days, EVP_PKEY *pkey);\n\nDECLARE_ASN1_FUNCTIONS(X509_ALGOR)\nDECLARE_ASN1_ENCODE_FUNCTIONS(X509_ALGORS, X509_ALGORS, X509_ALGORS)\nDECLARE_ASN1_FUNCTIONS(X509_VAL)\n\nDECLARE_ASN1_FUNCTIONS(X509_PUBKEY)\n\nint X509_PUBKEY_set(X509_PUBKEY **x, EVP_PKEY *pkey);\nEVP_PKEY *X509_PUBKEY_get(X509_PUBKEY *key);\nint X509_get_pubkey_parameters(EVP_PKEY *pkey, STACK_OF(X509) *chain);\nint i2d_PUBKEY(EVP_PKEY *a, unsigned char **pp);\nEVP_PKEY *d2i_PUBKEY(EVP_PKEY **a, const unsigned char **pp, long length);\n# ifndef OPENSSL_NO_RSA\nint i2d_RSA_PUBKEY(RSA *a, unsigned char **pp);\nRSA *d2i_RSA_PUBKEY(RSA **a, const unsigned char **pp, long length);\n# endif\n# ifndef OPENSSL_NO_DSA\nint i2d_DSA_PUBKEY(DSA *a, unsigned char **pp);\nDSA *d2i_DSA_PUBKEY(DSA **a, const unsigned char **pp, long length);\n# endif\n# ifndef OPENSSL_NO_EC\nint i2d_EC_PUBKEY(EC_KEY *a, unsigned char **pp);\nEC_KEY *d2i_EC_PUBKEY(EC_KEY **a, const unsigned char **pp, long length);\n# endif\n\nDECLARE_ASN1_FUNCTIONS(X509_SIG)\nDECLARE_ASN1_FUNCTIONS(X509_REQ_INFO)\nDECLARE_ASN1_FUNCTIONS(X509_REQ)\n\nDECLARE_ASN1_FUNCTIONS(X509_ATTRIBUTE)\nX509_ATTRIBUTE *X509_ATTRIBUTE_create(int nid, int atrtype, void *value);\n\nDECLARE_ASN1_FUNCTIONS(X509_EXTENSION)\nDECLARE_ASN1_ENCODE_FUNCTIONS(X509_EXTENSIONS, X509_EXTENSIONS, X509_EXTENSIONS)\n\nDECLARE_ASN1_FUNCTIONS(X509_NAME_ENTRY)\n\nDECLARE_ASN1_FUNCTIONS(X509_NAME)\n\nint X509_NAME_set(X509_NAME **xn, X509_NAME *name);\n\nDECLARE_ASN1_FUNCTIONS(X509_CINF)\n\nDECLARE_ASN1_FUNCTIONS(X509)\nDECLARE_ASN1_FUNCTIONS(X509_CERT_AUX)\n\nDECLARE_ASN1_FUNCTIONS(X509_CERT_PAIR)\n\nint X509_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func,\n                          CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func);\nint X509_set_ex_data(X509 *r, int idx, void *arg);\nvoid *X509_get_ex_data(X509 *r, int idx);\nint i2d_X509_AUX(X509 *a, unsigned char **pp);\nX509 *d2i_X509_AUX(X509 **a, const unsigned char **pp, long length);\n\nint i2d_re_X509_tbs(X509 *x, unsigned char **pp);\n\nvoid X509_get0_signature(ASN1_BIT_STRING **psig, X509_ALGOR **palg,\n                         const X509 *x);\nint X509_get_signature_nid(const X509 *x);\n\nint X509_alias_set1(X509 *x, unsigned char *name, int len);\nint X509_keyid_set1(X509 *x, unsigned char *id, int len);\nunsigned char *X509_alias_get0(X509 *x, int *len);\nunsigned char *X509_keyid_get0(X509 *x, int *len);\nint (*X509_TRUST_set_default(int (*trust) (int, X509 *, int))) (int, X509 *,\n                                                                int);\nint X509_TRUST_set(int *t, int trust);\nint X509_add1_trust_object(X509 *x, ASN1_OBJECT *obj);\nint X509_add1_reject_object(X509 *x, ASN1_OBJECT *obj);\nvoid X509_trust_clear(X509 *x);\nvoid X509_reject_clear(X509 *x);\n\nDECLARE_ASN1_FUNCTIONS(X509_REVOKED)\nDECLARE_ASN1_FUNCTIONS(X509_CRL_INFO)\nDECLARE_ASN1_FUNCTIONS(X509_CRL)\n\nint X509_CRL_add0_revoked(X509_CRL *crl, X509_REVOKED *rev);\nint X509_CRL_get0_by_serial(X509_CRL *crl,\n                            X509_REVOKED **ret, ASN1_INTEGER *serial);\nint X509_CRL_get0_by_cert(X509_CRL *crl, X509_REVOKED **ret, X509 *x);\n\nX509_PKEY *X509_PKEY_new(void);\nvoid X509_PKEY_free(X509_PKEY *a);\nint i2d_X509_PKEY(X509_PKEY *a, unsigned char **pp);\nX509_PKEY *d2i_X509_PKEY(X509_PKEY **a, const unsigned char **pp,\n                         long length);\n\nDECLARE_ASN1_FUNCTIONS(NETSCAPE_SPKI)\nDECLARE_ASN1_FUNCTIONS(NETSCAPE_SPKAC)\nDECLARE_ASN1_FUNCTIONS(NETSCAPE_CERT_SEQUENCE)\n\n# ifndef OPENSSL_NO_EVP\nX509_INFO *X509_INFO_new(void);\nvoid X509_INFO_free(X509_INFO *a);\nchar *X509_NAME_oneline(X509_NAME *a, char *buf, int size);\n\nint ASN1_verify(i2d_of_void *i2d, X509_ALGOR *algor1,\n                ASN1_BIT_STRING *signature, char *data, EVP_PKEY *pkey);\n\nint ASN1_digest(i2d_of_void *i2d, const EVP_MD *type, char *data,\n                unsigned char *md, unsigned int *len);\n\nint ASN1_sign(i2d_of_void *i2d, X509_ALGOR *algor1,\n              X509_ALGOR *algor2, ASN1_BIT_STRING *signature,\n              char *data, EVP_PKEY *pkey, const EVP_MD *type);\n\nint ASN1_item_digest(const ASN1_ITEM *it, const EVP_MD *type, void *data,\n                     unsigned char *md, unsigned int *len);\n\nint ASN1_item_verify(const ASN1_ITEM *it, X509_ALGOR *algor1,\n                     ASN1_BIT_STRING *signature, void *data, EVP_PKEY *pkey);\n\nint ASN1_item_sign(const ASN1_ITEM *it, X509_ALGOR *algor1,\n                   X509_ALGOR *algor2, ASN1_BIT_STRING *signature, void *data,\n                   EVP_PKEY *pkey, const EVP_MD *type);\nint ASN1_item_sign_ctx(const ASN1_ITEM *it, X509_ALGOR *algor1,\n                       X509_ALGOR *algor2, ASN1_BIT_STRING *signature,\n                       void *asn, EVP_MD_CTX *ctx);\n# endif\n\nint X509_set_version(X509 *x, long version);\nint X509_set_serialNumber(X509 *x, ASN1_INTEGER *serial);\nASN1_INTEGER *X509_get_serialNumber(X509 *x);\nint X509_set_issuer_name(X509 *x, X509_NAME *name);\nX509_NAME *X509_get_issuer_name(X509 *a);\nint X509_set_subject_name(X509 *x, X509_NAME *name);\nX509_NAME *X509_get_subject_name(X509 *a);\nint X509_set_notBefore(X509 *x, const ASN1_TIME *tm);\nint X509_set_notAfter(X509 *x, const ASN1_TIME *tm);\nint X509_set_pubkey(X509 *x, EVP_PKEY *pkey);\nEVP_PKEY *X509_get_pubkey(X509 *x);\nASN1_BIT_STRING *X509_get0_pubkey_bitstr(const X509 *x);\nint X509_certificate_type(X509 *x, EVP_PKEY *pubkey /* optional */ );\n\nint X509_REQ_set_version(X509_REQ *x, long version);\nint X509_REQ_set_subject_name(X509_REQ *req, X509_NAME *name);\nint X509_REQ_set_pubkey(X509_REQ *x, EVP_PKEY *pkey);\nEVP_PKEY *X509_REQ_get_pubkey(X509_REQ *req);\nint X509_REQ_extension_nid(int nid);\nint *X509_REQ_get_extension_nids(void);\nvoid X509_REQ_set_extension_nids(int *nids);\nSTACK_OF(X509_EXTENSION) *X509_REQ_get_extensions(X509_REQ *req);\nint X509_REQ_add_extensions_nid(X509_REQ *req, STACK_OF(X509_EXTENSION) *exts,\n                                int nid);\nint X509_REQ_add_extensions(X509_REQ *req, STACK_OF(X509_EXTENSION) *exts);\nint X509_REQ_get_attr_count(const X509_REQ *req);\nint X509_REQ_get_attr_by_NID(const X509_REQ *req, int nid, int lastpos);\nint X509_REQ_get_attr_by_OBJ(const X509_REQ *req, ASN1_OBJECT *obj,\n                             int lastpos);\nX509_ATTRIBUTE *X509_REQ_get_attr(const X509_REQ *req, int loc);\nX509_ATTRIBUTE *X509_REQ_delete_attr(X509_REQ *req, int loc);\nint X509_REQ_add1_attr(X509_REQ *req, X509_ATTRIBUTE *attr);\nint X509_REQ_add1_attr_by_OBJ(X509_REQ *req,\n                              const ASN1_OBJECT *obj, int type,\n                              const unsigned char *bytes, int len);\nint X509_REQ_add1_attr_by_NID(X509_REQ *req,\n                              int nid, int type,\n                              const unsigned char *bytes, int len);\nint X509_REQ_add1_attr_by_txt(X509_REQ *req,\n                              const char *attrname, int type,\n                              const unsigned char *bytes, int len);\n\nint X509_CRL_set_version(X509_CRL *x, long version);\nint X509_CRL_set_issuer_name(X509_CRL *x, X509_NAME *name);\nint X509_CRL_set_lastUpdate(X509_CRL *x, const ASN1_TIME *tm);\nint X509_CRL_set_nextUpdate(X509_CRL *x, const ASN1_TIME *tm);\nint X509_CRL_sort(X509_CRL *crl);\n\nint X509_REVOKED_set_serialNumber(X509_REVOKED *x, ASN1_INTEGER *serial);\nint X509_REVOKED_set_revocationDate(X509_REVOKED *r, ASN1_TIME *tm);\n\nX509_CRL *X509_CRL_diff(X509_CRL *base, X509_CRL *newer,\n                        EVP_PKEY *skey, const EVP_MD *md, unsigned int flags);\n\nint X509_REQ_check_private_key(X509_REQ *x509, EVP_PKEY *pkey);\n\nint X509_check_private_key(X509 *x509, EVP_PKEY *pkey);\nint X509_chain_check_suiteb(int *perror_depth,\n                            X509 *x, STACK_OF(X509) *chain,\n                            unsigned long flags);\nint X509_CRL_check_suiteb(X509_CRL *crl, EVP_PKEY *pk, unsigned long flags);\nSTACK_OF(X509) *X509_chain_up_ref(STACK_OF(X509) *chain);\n\nint X509_issuer_and_serial_cmp(const X509 *a, const X509 *b);\nunsigned long X509_issuer_and_serial_hash(X509 *a);\n\nint X509_issuer_name_cmp(const X509 *a, const X509 *b);\nunsigned long X509_issuer_name_hash(X509 *a);\n\nint X509_subject_name_cmp(const X509 *a, const X509 *b);\nunsigned long X509_subject_name_hash(X509 *x);\n\n# ifndef OPENSSL_NO_MD5\nunsigned long X509_issuer_name_hash_old(X509 *a);\nunsigned long X509_subject_name_hash_old(X509 *x);\n# endif\n\nint X509_cmp(const X509 *a, const X509 *b);\nint X509_NAME_cmp(const X509_NAME *a, const X509_NAME *b);\nunsigned long X509_NAME_hash(X509_NAME *x);\nunsigned long X509_NAME_hash_old(X509_NAME *x);\n\nint X509_CRL_cmp(const X509_CRL *a, const X509_CRL *b);\nint X509_CRL_match(const X509_CRL *a, const X509_CRL *b);\n# ifndef OPENSSL_NO_FP_API\nint X509_print_ex_fp(FILE *bp, X509 *x, unsigned long nmflag,\n                     unsigned long cflag);\nint X509_print_fp(FILE *bp, X509 *x);\nint X509_CRL_print_fp(FILE *bp, X509_CRL *x);\nint X509_REQ_print_fp(FILE *bp, X509_REQ *req);\nint X509_NAME_print_ex_fp(FILE *fp, X509_NAME *nm, int indent,\n                          unsigned long flags);\n# endif\n\n# ifndef OPENSSL_NO_BIO\nint X509_NAME_print(BIO *bp, X509_NAME *name, int obase);\nint X509_NAME_print_ex(BIO *out, X509_NAME *nm, int indent,\n                       unsigned long flags);\nint X509_print_ex(BIO *bp, X509 *x, unsigned long nmflag,\n                  unsigned long cflag);\nint X509_print(BIO *bp, X509 *x);\nint X509_ocspid_print(BIO *bp, X509 *x);\nint X509_CERT_AUX_print(BIO *bp, X509_CERT_AUX *x, int indent);\nint X509_CRL_print(BIO *bp, X509_CRL *x);\nint X509_REQ_print_ex(BIO *bp, X509_REQ *x, unsigned long nmflag,\n                      unsigned long cflag);\nint X509_REQ_print(BIO *bp, X509_REQ *req);\n# endif\n\nint X509_NAME_entry_count(X509_NAME *name);\nint X509_NAME_get_text_by_NID(X509_NAME *name, int nid, char *buf, int len);\nint X509_NAME_get_text_by_OBJ(X509_NAME *name, ASN1_OBJECT *obj,\n                              char *buf, int len);\n\n/*\n * NOTE: you should be passsing -1, not 0 as lastpos.  The functions that use\n * lastpos, search after that position on.\n */\nint X509_NAME_get_index_by_NID(X509_NAME *name, int nid, int lastpos);\nint X509_NAME_get_index_by_OBJ(X509_NAME *name, ASN1_OBJECT *obj,\n                               int lastpos);\nX509_NAME_ENTRY *X509_NAME_get_entry(X509_NAME *name, int loc);\nX509_NAME_ENTRY *X509_NAME_delete_entry(X509_NAME *name, int loc);\nint X509_NAME_add_entry(X509_NAME *name, X509_NAME_ENTRY *ne,\n                        int loc, int set);\nint X509_NAME_add_entry_by_OBJ(X509_NAME *name, ASN1_OBJECT *obj, int type,\n                               unsigned char *bytes, int len, int loc,\n                               int set);\nint X509_NAME_add_entry_by_NID(X509_NAME *name, int nid, int type,\n                               unsigned char *bytes, int len, int loc,\n                               int set);\nX509_NAME_ENTRY *X509_NAME_ENTRY_create_by_txt(X509_NAME_ENTRY **ne,\n                                               const char *field, int type,\n                                               const unsigned char *bytes,\n                                               int len);\nX509_NAME_ENTRY *X509_NAME_ENTRY_create_by_NID(X509_NAME_ENTRY **ne, int nid,\n                                               int type, unsigned char *bytes,\n                                               int len);\nint X509_NAME_add_entry_by_txt(X509_NAME *name, const char *field, int type,\n                               const unsigned char *bytes, int len, int loc,\n                               int set);\nX509_NAME_ENTRY *X509_NAME_ENTRY_create_by_OBJ(X509_NAME_ENTRY **ne,\n                                               ASN1_OBJECT *obj, int type,\n                                               const unsigned char *bytes,\n                                               int len);\nint X509_NAME_ENTRY_set_object(X509_NAME_ENTRY *ne, ASN1_OBJECT *obj);\nint X509_NAME_ENTRY_set_data(X509_NAME_ENTRY *ne, int type,\n                             const unsigned char *bytes, int len);\nASN1_OBJECT *X509_NAME_ENTRY_get_object(X509_NAME_ENTRY *ne);\nASN1_STRING *X509_NAME_ENTRY_get_data(X509_NAME_ENTRY *ne);\n\nint X509v3_get_ext_count(const STACK_OF(X509_EXTENSION) *x);\nint X509v3_get_ext_by_NID(const STACK_OF(X509_EXTENSION) *x,\n                          int nid, int lastpos);\nint X509v3_get_ext_by_OBJ(const STACK_OF(X509_EXTENSION) *x,\n                          ASN1_OBJECT *obj, int lastpos);\nint X509v3_get_ext_by_critical(const STACK_OF(X509_EXTENSION) *x,\n                               int crit, int lastpos);\nX509_EXTENSION *X509v3_get_ext(const STACK_OF(X509_EXTENSION) *x, int loc);\nX509_EXTENSION *X509v3_delete_ext(STACK_OF(X509_EXTENSION) *x, int loc);\nSTACK_OF(X509_EXTENSION) *X509v3_add_ext(STACK_OF(X509_EXTENSION) **x,\n                                         X509_EXTENSION *ex, int loc);\n\nint X509_get_ext_count(X509 *x);\nint X509_get_ext_by_NID(X509 *x, int nid, int lastpos);\nint X509_get_ext_by_OBJ(X509 *x, ASN1_OBJECT *obj, int lastpos);\nint X509_get_ext_by_critical(X509 *x, int crit, int lastpos);\nX509_EXTENSION *X509_get_ext(X509 *x, int loc);\nX509_EXTENSION *X509_delete_ext(X509 *x, int loc);\nint X509_add_ext(X509 *x, X509_EXTENSION *ex, int loc);\nvoid *X509_get_ext_d2i(X509 *x, int nid, int *crit, int *idx);\nint X509_add1_ext_i2d(X509 *x, int nid, void *value, int crit,\n                      unsigned long flags);\n\nint X509_CRL_get_ext_count(X509_CRL *x);\nint X509_CRL_get_ext_by_NID(X509_CRL *x, int nid, int lastpos);\nint X509_CRL_get_ext_by_OBJ(X509_CRL *x, ASN1_OBJECT *obj, int lastpos);\nint X509_CRL_get_ext_by_critical(X509_CRL *x, int crit, int lastpos);\nX509_EXTENSION *X509_CRL_get_ext(X509_CRL *x, int loc);\nX509_EXTENSION *X509_CRL_delete_ext(X509_CRL *x, int loc);\nint X509_CRL_add_ext(X509_CRL *x, X509_EXTENSION *ex, int loc);\nvoid *X509_CRL_get_ext_d2i(X509_CRL *x, int nid, int *crit, int *idx);\nint X509_CRL_add1_ext_i2d(X509_CRL *x, int nid, void *value, int crit,\n                          unsigned long flags);\n\nint X509_REVOKED_get_ext_count(X509_REVOKED *x);\nint X509_REVOKED_get_ext_by_NID(X509_REVOKED *x, int nid, int lastpos);\nint X509_REVOKED_get_ext_by_OBJ(X509_REVOKED *x, ASN1_OBJECT *obj,\n                                int lastpos);\nint X509_REVOKED_get_ext_by_critical(X509_REVOKED *x, int crit, int lastpos);\nX509_EXTENSION *X509_REVOKED_get_ext(X509_REVOKED *x, int loc);\nX509_EXTENSION *X509_REVOKED_delete_ext(X509_REVOKED *x, int loc);\nint X509_REVOKED_add_ext(X509_REVOKED *x, X509_EXTENSION *ex, int loc);\nvoid *X509_REVOKED_get_ext_d2i(X509_REVOKED *x, int nid, int *crit, int *idx);\nint X509_REVOKED_add1_ext_i2d(X509_REVOKED *x, int nid, void *value, int crit,\n                              unsigned long flags);\n\nX509_EXTENSION *X509_EXTENSION_create_by_NID(X509_EXTENSION **ex,\n                                             int nid, int crit,\n                                             ASN1_OCTET_STRING *data);\nX509_EXTENSION *X509_EXTENSION_create_by_OBJ(X509_EXTENSION **ex,\n                                             ASN1_OBJECT *obj, int crit,\n                                             ASN1_OCTET_STRING *data);\nint X509_EXTENSION_set_object(X509_EXTENSION *ex, ASN1_OBJECT *obj);\nint X509_EXTENSION_set_critical(X509_EXTENSION *ex, int crit);\nint X509_EXTENSION_set_data(X509_EXTENSION *ex, ASN1_OCTET_STRING *data);\nASN1_OBJECT *X509_EXTENSION_get_object(X509_EXTENSION *ex);\nASN1_OCTET_STRING *X509_EXTENSION_get_data(X509_EXTENSION *ne);\nint X509_EXTENSION_get_critical(X509_EXTENSION *ex);\n\nint X509at_get_attr_count(const STACK_OF(X509_ATTRIBUTE) *x);\nint X509at_get_attr_by_NID(const STACK_OF(X509_ATTRIBUTE) *x, int nid,\n                           int lastpos);\nint X509at_get_attr_by_OBJ(const STACK_OF(X509_ATTRIBUTE) *sk,\n                           ASN1_OBJECT *obj, int lastpos);\nX509_ATTRIBUTE *X509at_get_attr(const STACK_OF(X509_ATTRIBUTE) *x, int loc);\nX509_ATTRIBUTE *X509at_delete_attr(STACK_OF(X509_ATTRIBUTE) *x, int loc);\nSTACK_OF(X509_ATTRIBUTE) *X509at_add1_attr(STACK_OF(X509_ATTRIBUTE) **x,\n                                           X509_ATTRIBUTE *attr);\nSTACK_OF(X509_ATTRIBUTE) *X509at_add1_attr_by_OBJ(STACK_OF(X509_ATTRIBUTE)\n                                                  **x, const ASN1_OBJECT *obj,\n                                                  int type,\n                                                  const unsigned char *bytes,\n                                                  int len);\nSTACK_OF(X509_ATTRIBUTE) *X509at_add1_attr_by_NID(STACK_OF(X509_ATTRIBUTE)\n                                                  **x, int nid, int type,\n                                                  const unsigned char *bytes,\n                                                  int len);\nSTACK_OF(X509_ATTRIBUTE) *X509at_add1_attr_by_txt(STACK_OF(X509_ATTRIBUTE)\n                                                  **x, const char *attrname,\n                                                  int type,\n                                                  const unsigned char *bytes,\n                                                  int len);\nvoid *X509at_get0_data_by_OBJ(STACK_OF(X509_ATTRIBUTE) *x, ASN1_OBJECT *obj,\n                              int lastpos, int type);\nX509_ATTRIBUTE *X509_ATTRIBUTE_create_by_NID(X509_ATTRIBUTE **attr, int nid,\n                                             int atrtype, const void *data,\n                                             int len);\nX509_ATTRIBUTE *X509_ATTRIBUTE_create_by_OBJ(X509_ATTRIBUTE **attr,\n                                             const ASN1_OBJECT *obj,\n                                             int atrtype, const void *data,\n                                             int len);\nX509_ATTRIBUTE *X509_ATTRIBUTE_create_by_txt(X509_ATTRIBUTE **attr,\n                                             const char *atrname, int type,\n                                             const unsigned char *bytes,\n                                             int len);\nint X509_ATTRIBUTE_set1_object(X509_ATTRIBUTE *attr, const ASN1_OBJECT *obj);\nint X509_ATTRIBUTE_set1_data(X509_ATTRIBUTE *attr, int attrtype,\n                             const void *data, int len);\nvoid *X509_ATTRIBUTE_get0_data(X509_ATTRIBUTE *attr, int idx, int atrtype,\n                               void *data);\nint X509_ATTRIBUTE_count(X509_ATTRIBUTE *attr);\nASN1_OBJECT *X509_ATTRIBUTE_get0_object(X509_ATTRIBUTE *attr);\nASN1_TYPE *X509_ATTRIBUTE_get0_type(X509_ATTRIBUTE *attr, int idx);\n\nint EVP_PKEY_get_attr_count(const EVP_PKEY *key);\nint EVP_PKEY_get_attr_by_NID(const EVP_PKEY *key, int nid, int lastpos);\nint EVP_PKEY_get_attr_by_OBJ(const EVP_PKEY *key, ASN1_OBJECT *obj,\n                             int lastpos);\nX509_ATTRIBUTE *EVP_PKEY_get_attr(const EVP_PKEY *key, int loc);\nX509_ATTRIBUTE *EVP_PKEY_delete_attr(EVP_PKEY *key, int loc);\nint EVP_PKEY_add1_attr(EVP_PKEY *key, X509_ATTRIBUTE *attr);\nint EVP_PKEY_add1_attr_by_OBJ(EVP_PKEY *key,\n                              const ASN1_OBJECT *obj, int type,\n                              const unsigned char *bytes, int len);\nint EVP_PKEY_add1_attr_by_NID(EVP_PKEY *key,\n                              int nid, int type,\n                              const unsigned char *bytes, int len);\nint EVP_PKEY_add1_attr_by_txt(EVP_PKEY *key,\n                              const char *attrname, int type,\n                              const unsigned char *bytes, int len);\n\nint X509_verify_cert(X509_STORE_CTX *ctx);\n\n/* lookup a cert from a X509 STACK */\nX509 *X509_find_by_issuer_and_serial(STACK_OF(X509) *sk, X509_NAME *name,\n                                     ASN1_INTEGER *serial);\nX509 *X509_find_by_subject(STACK_OF(X509) *sk, X509_NAME *name);\n\nDECLARE_ASN1_FUNCTIONS(PBEPARAM)\nDECLARE_ASN1_FUNCTIONS(PBE2PARAM)\nDECLARE_ASN1_FUNCTIONS(PBKDF2PARAM)\n\nint PKCS5_pbe_set0_algor(X509_ALGOR *algor, int alg, int iter,\n                         const unsigned char *salt, int saltlen);\n\nX509_ALGOR *PKCS5_pbe_set(int alg, int iter,\n                          const unsigned char *salt, int saltlen);\nX509_ALGOR *PKCS5_pbe2_set(const EVP_CIPHER *cipher, int iter,\n                           unsigned char *salt, int saltlen);\nX509_ALGOR *PKCS5_pbe2_set_iv(const EVP_CIPHER *cipher, int iter,\n                              unsigned char *salt, int saltlen,\n                              unsigned char *aiv, int prf_nid);\n\nX509_ALGOR *PKCS5_pbkdf2_set(int iter, unsigned char *salt, int saltlen,\n                             int prf_nid, int keylen);\n\n/* PKCS#8 utilities */\n\nDECLARE_ASN1_FUNCTIONS(PKCS8_PRIV_KEY_INFO)\n\nEVP_PKEY *EVP_PKCS82PKEY(PKCS8_PRIV_KEY_INFO *p8);\nPKCS8_PRIV_KEY_INFO *EVP_PKEY2PKCS8(EVP_PKEY *pkey);\nPKCS8_PRIV_KEY_INFO *EVP_PKEY2PKCS8_broken(EVP_PKEY *pkey, int broken);\nPKCS8_PRIV_KEY_INFO *PKCS8_set_broken(PKCS8_PRIV_KEY_INFO *p8, int broken);\n\nint PKCS8_pkey_set0(PKCS8_PRIV_KEY_INFO *priv, ASN1_OBJECT *aobj,\n                    int version, int ptype, void *pval,\n                    unsigned char *penc, int penclen);\nint PKCS8_pkey_get0(ASN1_OBJECT **ppkalg,\n                    const unsigned char **pk, int *ppklen,\n                    X509_ALGOR **pa, PKCS8_PRIV_KEY_INFO *p8);\n\nint X509_PUBKEY_set0_param(X509_PUBKEY *pub, ASN1_OBJECT *aobj,\n                           int ptype, void *pval,\n                           unsigned char *penc, int penclen);\nint X509_PUBKEY_get0_param(ASN1_OBJECT **ppkalg,\n                           const unsigned char **pk, int *ppklen,\n                           X509_ALGOR **pa, X509_PUBKEY *pub);\n\nint X509_check_trust(X509 *x, int id, int flags);\nint X509_TRUST_get_count(void);\nX509_TRUST *X509_TRUST_get0(int idx);\nint X509_TRUST_get_by_id(int id);\nint X509_TRUST_add(int id, int flags, int (*ck) (X509_TRUST *, X509 *, int),\n                   char *name, int arg1, void *arg2);\nvoid X509_TRUST_cleanup(void);\nint X509_TRUST_get_flags(X509_TRUST *xp);\nchar *X509_TRUST_get0_name(X509_TRUST *xp);\nint X509_TRUST_get_trust(X509_TRUST *xp);\n\n/* BEGIN ERROR CODES */\n/*\n * The following lines are auto generated by the script mkerr.pl. Any changes\n * made after this point may be overwritten when the script is next run.\n */\n\nvoid ERR_load_X509_strings(void);\n\n/* Error codes for the X509 functions. */\n\n/* Function codes. */\n# define X509_F_ADD_CERT_DIR                              100\n# define X509_F_BY_FILE_CTRL                              101\n# define X509_F_CHECK_NAME_CONSTRAINTS                    106\n# define X509_F_CHECK_POLICY                              145\n# define X509_F_DIR_CTRL                                  102\n# define X509_F_GET_CERT_BY_SUBJECT                       103\n# define X509_F_NETSCAPE_SPKI_B64_DECODE                  129\n# define X509_F_NETSCAPE_SPKI_B64_ENCODE                  130\n# define X509_F_X509AT_ADD1_ATTR                          135\n# define X509_F_X509V3_ADD_EXT                            104\n# define X509_F_X509_ATTRIBUTE_CREATE_BY_NID              136\n# define X509_F_X509_ATTRIBUTE_CREATE_BY_OBJ              137\n# define X509_F_X509_ATTRIBUTE_CREATE_BY_TXT              140\n# define X509_F_X509_ATTRIBUTE_GET0_DATA                  139\n# define X509_F_X509_ATTRIBUTE_SET1_DATA                  138\n# define X509_F_X509_CHECK_PRIVATE_KEY                    128\n# define X509_F_X509_CRL_DIFF                             105\n# define X509_F_X509_CRL_PRINT_FP                         147\n# define X509_F_X509_EXTENSION_CREATE_BY_NID              108\n# define X509_F_X509_EXTENSION_CREATE_BY_OBJ              109\n# define X509_F_X509_GET_PUBKEY_PARAMETERS                110\n# define X509_F_X509_LOAD_CERT_CRL_FILE                   132\n# define X509_F_X509_LOAD_CERT_FILE                       111\n# define X509_F_X509_LOAD_CRL_FILE                        112\n# define X509_F_X509_NAME_ADD_ENTRY                       113\n# define X509_F_X509_NAME_ENTRY_CREATE_BY_NID             114\n# define X509_F_X509_NAME_ENTRY_CREATE_BY_TXT             131\n# define X509_F_X509_NAME_ENTRY_SET_OBJECT                115\n# define X509_F_X509_NAME_ONELINE                         116\n# define X509_F_X509_NAME_PRINT                           117\n# define X509_F_X509_PRINT_EX_FP                          118\n# define X509_F_X509_PUBKEY_GET                           119\n# define X509_F_X509_PUBKEY_SET                           120\n# define X509_F_X509_REQ_CHECK_PRIVATE_KEY                144\n# define X509_F_X509_REQ_PRINT_EX                         121\n# define X509_F_X509_REQ_PRINT_FP                         122\n# define X509_F_X509_REQ_TO_X509                          123\n# define X509_F_X509_STORE_ADD_CERT                       124\n# define X509_F_X509_STORE_ADD_CRL                        125\n# define X509_F_X509_STORE_CTX_GET1_ISSUER                146\n# define X509_F_X509_STORE_CTX_INIT                       143\n# define X509_F_X509_STORE_CTX_NEW                        142\n# define X509_F_X509_STORE_CTX_PURPOSE_INHERIT            134\n# define X509_F_X509_TO_X509_REQ                          126\n# define X509_F_X509_TRUST_ADD                            133\n# define X509_F_X509_TRUST_SET                            141\n# define X509_F_X509_VERIFY_CERT                          127\n\n/* Reason codes. */\n# define X509_R_AKID_MISMATCH                             110\n# define X509_R_BAD_X509_FILETYPE                         100\n# define X509_R_BASE64_DECODE_ERROR                       118\n# define X509_R_CANT_CHECK_DH_KEY                         114\n# define X509_R_CERT_ALREADY_IN_HASH_TABLE                101\n# define X509_R_CRL_ALREADY_DELTA                         127\n# define X509_R_CRL_VERIFY_FAILURE                        131\n# define X509_R_ERR_ASN1_LIB                              102\n# define X509_R_IDP_MISMATCH                              128\n# define X509_R_INVALID_DIRECTORY                         113\n# define X509_R_INVALID_FIELD_NAME                        119\n# define X509_R_INVALID_TRUST                             123\n# define X509_R_ISSUER_MISMATCH                           129\n# define X509_R_KEY_TYPE_MISMATCH                         115\n# define X509_R_KEY_VALUES_MISMATCH                       116\n# define X509_R_LOADING_CERT_DIR                          103\n# define X509_R_LOADING_DEFAULTS                          104\n# define X509_R_METHOD_NOT_SUPPORTED                      124\n# define X509_R_NAME_TOO_LONG                             134\n# define X509_R_NEWER_CRL_NOT_NEWER                       132\n# define X509_R_NO_CERT_SET_FOR_US_TO_VERIFY              105\n# define X509_R_NO_CRL_NUMBER                             130\n# define X509_R_PUBLIC_KEY_DECODE_ERROR                   125\n# define X509_R_PUBLIC_KEY_ENCODE_ERROR                   126\n# define X509_R_SHOULD_RETRY                              106\n# define X509_R_UNABLE_TO_FIND_PARAMETERS_IN_CHAIN        107\n# define X509_R_UNABLE_TO_GET_CERTS_PUBLIC_KEY            108\n# define X509_R_UNKNOWN_KEY_TYPE                          117\n# define X509_R_UNKNOWN_NID                               109\n# define X509_R_UNKNOWN_PURPOSE_ID                        121\n# define X509_R_UNKNOWN_TRUST_ID                          120\n# define X509_R_UNSUPPORTED_ALGORITHM                     111\n# define X509_R_WRONG_LOOKUP_TYPE                         112\n# define X509_R_WRONG_TYPE                                122\n\n# ifdef  __cplusplus\n}\n# endif\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/arm/include/openssl/x509_vfy.h",
    "content": "/* crypto/x509/x509_vfy.h */\n/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)\n * All rights reserved.\n *\n * This package is an SSL implementation written\n * by Eric Young (eay@cryptsoft.com).\n * The implementation was written so as to conform with Netscapes SSL.\n *\n * This library is free for commercial and non-commercial use as long as\n * the following conditions are aheared to.  The following conditions\n * apply to all code found in this distribution, be it the RC4, RSA,\n * lhash, DES, etc., code; not just the SSL code.  The SSL documentation\n * included with this distribution is covered by the same copyright terms\n * except that the holder is Tim Hudson (tjh@cryptsoft.com).\n *\n * Copyright remains Eric Young's, and as such any Copyright notices in\n * the code are not to be removed.\n * If this package is used in a product, Eric Young should be given attribution\n * as the author of the parts of the library used.\n * This can be in the form of a textual message at program startup or\n * in documentation (online or textual) provided with the package.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the copyright\n *    notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in the\n *    documentation and/or other materials provided with the distribution.\n * 3. All advertising materials mentioning features or use of this software\n *    must display the following acknowledgement:\n *    \"This product includes cryptographic software written by\n *     Eric Young (eay@cryptsoft.com)\"\n *    The word 'cryptographic' can be left out if the rouines from the library\n *    being used are not cryptographic related :-).\n * 4. If you include any Windows specific code (or a derivative thereof) from\n *    the apps directory (application code) you must include an acknowledgement:\n *    \"This product includes software written by Tim Hudson (tjh@cryptsoft.com)\"\n *\n * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n * SUCH DAMAGE.\n *\n * The licence and distribution terms for any publically available version or\n * derivative of this code cannot be changed.  i.e. this code cannot simply be\n * copied and put under another distribution licence\n * [including the GNU Public Licence.]\n */\n\n#ifndef HEADER_X509_H\n# include <openssl/x509.h>\n/*\n * openssl/x509.h ends up #include-ing this file at about the only\n * appropriate moment.\n */\n#endif\n\n#ifndef HEADER_X509_VFY_H\n# define HEADER_X509_VFY_H\n\n# include <openssl/opensslconf.h>\n# ifndef OPENSSL_NO_LHASH\n#  include <openssl/lhash.h>\n# endif\n# include <openssl/bio.h>\n# include <openssl/crypto.h>\n# include <openssl/symhacks.h>\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n# if 0\n/* Outer object */\ntypedef struct x509_hash_dir_st {\n    int num_dirs;\n    char **dirs;\n    int *dirs_type;\n    int num_dirs_alloced;\n} X509_HASH_DIR_CTX;\n# endif\n\ntypedef struct x509_file_st {\n    int num_paths;              /* number of paths to files or directories */\n    int num_alloced;\n    char **paths;               /* the list of paths or directories */\n    int *path_type;\n} X509_CERT_FILE_CTX;\n\n/*******************************/\n/*-\nSSL_CTX -> X509_STORE\n                -> X509_LOOKUP\n                        ->X509_LOOKUP_METHOD\n                -> X509_LOOKUP\n                        ->X509_LOOKUP_METHOD\n\nSSL     -> X509_STORE_CTX\n                ->X509_STORE\n\nThe X509_STORE holds the tables etc for verification stuff.\nA X509_STORE_CTX is used while validating a single certificate.\nThe X509_STORE has X509_LOOKUPs for looking up certs.\nThe X509_STORE then calls a function to actually verify the\ncertificate chain.\n*/\n\n# define X509_LU_RETRY           -1\n# define X509_LU_FAIL            0\n# define X509_LU_X509            1\n# define X509_LU_CRL             2\n# define X509_LU_PKEY            3\n\ntypedef struct x509_object_st {\n    /* one of the above types */\n    int type;\n    union {\n        char *ptr;\n        X509 *x509;\n        X509_CRL *crl;\n        EVP_PKEY *pkey;\n    } data;\n} X509_OBJECT;\n\ntypedef struct x509_lookup_st X509_LOOKUP;\n\nDECLARE_STACK_OF(X509_LOOKUP)\nDECLARE_STACK_OF(X509_OBJECT)\n\n/* This is a static that defines the function interface */\ntypedef struct x509_lookup_method_st {\n    const char *name;\n    int (*new_item) (X509_LOOKUP *ctx);\n    void (*free) (X509_LOOKUP *ctx);\n    int (*init) (X509_LOOKUP *ctx);\n    int (*shutdown) (X509_LOOKUP *ctx);\n    int (*ctrl) (X509_LOOKUP *ctx, int cmd, const char *argc, long argl,\n                 char **ret);\n    int (*get_by_subject) (X509_LOOKUP *ctx, int type, X509_NAME *name,\n                           X509_OBJECT *ret);\n    int (*get_by_issuer_serial) (X509_LOOKUP *ctx, int type, X509_NAME *name,\n                                 ASN1_INTEGER *serial, X509_OBJECT *ret);\n    int (*get_by_fingerprint) (X509_LOOKUP *ctx, int type,\n                               unsigned char *bytes, int len,\n                               X509_OBJECT *ret);\n    int (*get_by_alias) (X509_LOOKUP *ctx, int type, char *str, int len,\n                         X509_OBJECT *ret);\n} X509_LOOKUP_METHOD;\n\ntypedef struct X509_VERIFY_PARAM_ID_st X509_VERIFY_PARAM_ID;\n\n/*\n * This structure hold all parameters associated with a verify operation by\n * including an X509_VERIFY_PARAM structure in related structures the\n * parameters used can be customized\n */\n\ntypedef struct X509_VERIFY_PARAM_st {\n    char *name;\n    time_t check_time;          /* Time to use */\n    unsigned long inh_flags;    /* Inheritance flags */\n    unsigned long flags;        /* Various verify flags */\n    int purpose;                /* purpose to check untrusted certificates */\n    int trust;                  /* trust setting to check */\n    int depth;                  /* Verify depth */\n    STACK_OF(ASN1_OBJECT) *policies; /* Permissible policies */\n    X509_VERIFY_PARAM_ID *id;   /* opaque ID data */\n} X509_VERIFY_PARAM;\n\nDECLARE_STACK_OF(X509_VERIFY_PARAM)\n\n/*\n * This is used to hold everything.  It is used for all certificate\n * validation.  Once we have a certificate chain, the 'verify' function is\n * then called to actually check the cert chain.\n */\nstruct x509_store_st {\n    /* The following is a cache of trusted certs */\n    int cache;                  /* if true, stash any hits */\n    STACK_OF(X509_OBJECT) *objs; /* Cache of all objects */\n    /* These are external lookup methods */\n    STACK_OF(X509_LOOKUP) *get_cert_methods;\n    X509_VERIFY_PARAM *param;\n    /* Callbacks for various operations */\n    /* called to verify a certificate */\n    int (*verify) (X509_STORE_CTX *ctx);\n    /* error callback */\n    int (*verify_cb) (int ok, X509_STORE_CTX *ctx);\n    /* get issuers cert from ctx */\n    int (*get_issuer) (X509 **issuer, X509_STORE_CTX *ctx, X509 *x);\n    /* check issued */\n    int (*check_issued) (X509_STORE_CTX *ctx, X509 *x, X509 *issuer);\n    /* Check revocation status of chain */\n    int (*check_revocation) (X509_STORE_CTX *ctx);\n    /* retrieve CRL */\n    int (*get_crl) (X509_STORE_CTX *ctx, X509_CRL **crl, X509 *x);\n    /* Check CRL validity */\n    int (*check_crl) (X509_STORE_CTX *ctx, X509_CRL *crl);\n    /* Check certificate against CRL */\n    int (*cert_crl) (X509_STORE_CTX *ctx, X509_CRL *crl, X509 *x);\n    STACK_OF(X509) *(*lookup_certs) (X509_STORE_CTX *ctx, X509_NAME *nm);\n    STACK_OF(X509_CRL) *(*lookup_crls) (X509_STORE_CTX *ctx, X509_NAME *nm);\n    int (*cleanup) (X509_STORE_CTX *ctx);\n    CRYPTO_EX_DATA ex_data;\n    int references;\n} /* X509_STORE */ ;\n\nint X509_STORE_set_depth(X509_STORE *store, int depth);\n\n# define X509_STORE_set_verify_cb_func(ctx,func) ((ctx)->verify_cb=(func))\n# define X509_STORE_set_verify_func(ctx,func)    ((ctx)->verify=(func))\n\n/* This is the functions plus an instance of the local variables. */\nstruct x509_lookup_st {\n    int init;                   /* have we been started */\n    int skip;                   /* don't use us. */\n    X509_LOOKUP_METHOD *method; /* the functions */\n    char *method_data;          /* method data */\n    X509_STORE *store_ctx;      /* who owns us */\n} /* X509_LOOKUP */ ;\n\n/*\n * This is a used when verifying cert chains.  Since the gathering of the\n * cert chain can take some time (and have to be 'retried', this needs to be\n * kept and passed around.\n */\nstruct x509_store_ctx_st {      /* X509_STORE_CTX */\n    X509_STORE *ctx;\n    /* used when looking up certs */\n    int current_method;\n    /* The following are set by the caller */\n    /* The cert to check */\n    X509 *cert;\n    /* chain of X509s - untrusted - passed in */\n    STACK_OF(X509) *untrusted;\n    /* set of CRLs passed in */\n    STACK_OF(X509_CRL) *crls;\n    X509_VERIFY_PARAM *param;\n    /* Other info for use with get_issuer() */\n    void *other_ctx;\n    /* Callbacks for various operations */\n    /* called to verify a certificate */\n    int (*verify) (X509_STORE_CTX *ctx);\n    /* error callback */\n    int (*verify_cb) (int ok, X509_STORE_CTX *ctx);\n    /* get issuers cert from ctx */\n    int (*get_issuer) (X509 **issuer, X509_STORE_CTX *ctx, X509 *x);\n    /* check issued */\n    int (*check_issued) (X509_STORE_CTX *ctx, X509 *x, X509 *issuer);\n    /* Check revocation status of chain */\n    int (*check_revocation) (X509_STORE_CTX *ctx);\n    /* retrieve CRL */\n    int (*get_crl) (X509_STORE_CTX *ctx, X509_CRL **crl, X509 *x);\n    /* Check CRL validity */\n    int (*check_crl) (X509_STORE_CTX *ctx, X509_CRL *crl);\n    /* Check certificate against CRL */\n    int (*cert_crl) (X509_STORE_CTX *ctx, X509_CRL *crl, X509 *x);\n    int (*check_policy) (X509_STORE_CTX *ctx);\n    STACK_OF(X509) *(*lookup_certs) (X509_STORE_CTX *ctx, X509_NAME *nm);\n    STACK_OF(X509_CRL) *(*lookup_crls) (X509_STORE_CTX *ctx, X509_NAME *nm);\n    int (*cleanup) (X509_STORE_CTX *ctx);\n    /* The following is built up */\n    /* if 0, rebuild chain */\n    int valid;\n    /* index of last untrusted cert */\n    int last_untrusted;\n    /* chain of X509s - built up and trusted */\n    STACK_OF(X509) *chain;\n    /* Valid policy tree */\n    X509_POLICY_TREE *tree;\n    /* Require explicit policy value */\n    int explicit_policy;\n    /* When something goes wrong, this is why */\n    int error_depth;\n    int error;\n    X509 *current_cert;\n    /* cert currently being tested as valid issuer */\n    X509 *current_issuer;\n    /* current CRL */\n    X509_CRL *current_crl;\n    /* score of current CRL */\n    int current_crl_score;\n    /* Reason mask */\n    unsigned int current_reasons;\n    /* For CRL path validation: parent context */\n    X509_STORE_CTX *parent;\n    CRYPTO_EX_DATA ex_data;\n} /* X509_STORE_CTX */ ;\n\nvoid X509_STORE_CTX_set_depth(X509_STORE_CTX *ctx, int depth);\n\n# define X509_STORE_CTX_set_app_data(ctx,data) \\\n        X509_STORE_CTX_set_ex_data(ctx,0,data)\n# define X509_STORE_CTX_get_app_data(ctx) \\\n        X509_STORE_CTX_get_ex_data(ctx,0)\n\n# define X509_L_FILE_LOAD        1\n# define X509_L_ADD_DIR          2\n\n# define X509_LOOKUP_load_file(x,name,type) \\\n                X509_LOOKUP_ctrl((x),X509_L_FILE_LOAD,(name),(long)(type),NULL)\n\n# define X509_LOOKUP_add_dir(x,name,type) \\\n                X509_LOOKUP_ctrl((x),X509_L_ADD_DIR,(name),(long)(type),NULL)\n\n# define         X509_V_OK                                       0\n# define         X509_V_ERR_UNSPECIFIED                          1\n\n# define         X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT            2\n# define         X509_V_ERR_UNABLE_TO_GET_CRL                    3\n# define         X509_V_ERR_UNABLE_TO_DECRYPT_CERT_SIGNATURE     4\n# define         X509_V_ERR_UNABLE_TO_DECRYPT_CRL_SIGNATURE      5\n# define         X509_V_ERR_UNABLE_TO_DECODE_ISSUER_PUBLIC_KEY   6\n# define         X509_V_ERR_CERT_SIGNATURE_FAILURE               7\n# define         X509_V_ERR_CRL_SIGNATURE_FAILURE                8\n# define         X509_V_ERR_CERT_NOT_YET_VALID                   9\n# define         X509_V_ERR_CERT_HAS_EXPIRED                     10\n# define         X509_V_ERR_CRL_NOT_YET_VALID                    11\n# define         X509_V_ERR_CRL_HAS_EXPIRED                      12\n# define         X509_V_ERR_ERROR_IN_CERT_NOT_BEFORE_FIELD       13\n# define         X509_V_ERR_ERROR_IN_CERT_NOT_AFTER_FIELD        14\n# define         X509_V_ERR_ERROR_IN_CRL_LAST_UPDATE_FIELD       15\n# define         X509_V_ERR_ERROR_IN_CRL_NEXT_UPDATE_FIELD       16\n# define         X509_V_ERR_OUT_OF_MEM                           17\n# define         X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT          18\n# define         X509_V_ERR_SELF_SIGNED_CERT_IN_CHAIN            19\n# define         X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY    20\n# define         X509_V_ERR_UNABLE_TO_VERIFY_LEAF_SIGNATURE      21\n# define         X509_V_ERR_CERT_CHAIN_TOO_LONG                  22\n# define         X509_V_ERR_CERT_REVOKED                         23\n# define         X509_V_ERR_INVALID_CA                           24\n# define         X509_V_ERR_PATH_LENGTH_EXCEEDED                 25\n# define         X509_V_ERR_INVALID_PURPOSE                      26\n# define         X509_V_ERR_CERT_UNTRUSTED                       27\n# define         X509_V_ERR_CERT_REJECTED                        28\n/* These are 'informational' when looking for issuer cert */\n# define         X509_V_ERR_SUBJECT_ISSUER_MISMATCH              29\n# define         X509_V_ERR_AKID_SKID_MISMATCH                   30\n# define         X509_V_ERR_AKID_ISSUER_SERIAL_MISMATCH          31\n# define         X509_V_ERR_KEYUSAGE_NO_CERTSIGN                 32\n\n# define         X509_V_ERR_UNABLE_TO_GET_CRL_ISSUER             33\n# define         X509_V_ERR_UNHANDLED_CRITICAL_EXTENSION         34\n# define         X509_V_ERR_KEYUSAGE_NO_CRL_SIGN                 35\n# define         X509_V_ERR_UNHANDLED_CRITICAL_CRL_EXTENSION     36\n# define         X509_V_ERR_INVALID_NON_CA                       37\n# define         X509_V_ERR_PROXY_PATH_LENGTH_EXCEEDED           38\n# define         X509_V_ERR_KEYUSAGE_NO_DIGITAL_SIGNATURE        39\n# define         X509_V_ERR_PROXY_CERTIFICATES_NOT_ALLOWED       40\n\n# define         X509_V_ERR_INVALID_EXTENSION                    41\n# define         X509_V_ERR_INVALID_POLICY_EXTENSION             42\n# define         X509_V_ERR_NO_EXPLICIT_POLICY                   43\n# define         X509_V_ERR_DIFFERENT_CRL_SCOPE                  44\n# define         X509_V_ERR_UNSUPPORTED_EXTENSION_FEATURE        45\n\n# define         X509_V_ERR_UNNESTED_RESOURCE                    46\n\n# define         X509_V_ERR_PERMITTED_VIOLATION                  47\n# define         X509_V_ERR_EXCLUDED_VIOLATION                   48\n# define         X509_V_ERR_SUBTREE_MINMAX                       49\n# define         X509_V_ERR_APPLICATION_VERIFICATION             50\n# define         X509_V_ERR_UNSUPPORTED_CONSTRAINT_TYPE          51\n# define         X509_V_ERR_UNSUPPORTED_CONSTRAINT_SYNTAX        52\n# define         X509_V_ERR_UNSUPPORTED_NAME_SYNTAX              53\n# define         X509_V_ERR_CRL_PATH_VALIDATION_ERROR            54\n\n/* Suite B mode algorithm violation */\n# define         X509_V_ERR_SUITE_B_INVALID_VERSION              56\n# define         X509_V_ERR_SUITE_B_INVALID_ALGORITHM            57\n# define         X509_V_ERR_SUITE_B_INVALID_CURVE                58\n# define         X509_V_ERR_SUITE_B_INVALID_SIGNATURE_ALGORITHM  59\n# define         X509_V_ERR_SUITE_B_LOS_NOT_ALLOWED              60\n# define         X509_V_ERR_SUITE_B_CANNOT_SIGN_P_384_WITH_P_256 61\n\n/* Host, email and IP check errors */\n# define         X509_V_ERR_HOSTNAME_MISMATCH                    62\n# define         X509_V_ERR_EMAIL_MISMATCH                       63\n# define         X509_V_ERR_IP_ADDRESS_MISMATCH                  64\n\n/* Caller error */\n# define         X509_V_ERR_INVALID_CALL                         65\n/* Issuer lookup error */\n# define         X509_V_ERR_STORE_LOOKUP                         66\n\n# define         X509_V_ERR_PROXY_SUBJECT_NAME_VIOLATION         67\n\n/* Certificate verify flags */\n\n/* Send issuer+subject checks to verify_cb */\n# define X509_V_FLAG_CB_ISSUER_CHECK             0x1\n/* Use check time instead of current time */\n# define X509_V_FLAG_USE_CHECK_TIME              0x2\n/* Lookup CRLs */\n# define X509_V_FLAG_CRL_CHECK                   0x4\n/* Lookup CRLs for whole chain */\n# define X509_V_FLAG_CRL_CHECK_ALL               0x8\n/* Ignore unhandled critical extensions */\n# define X509_V_FLAG_IGNORE_CRITICAL             0x10\n/* Disable workarounds for broken certificates */\n# define X509_V_FLAG_X509_STRICT                 0x20\n/* Enable proxy certificate validation */\n# define X509_V_FLAG_ALLOW_PROXY_CERTS           0x40\n/* Enable policy checking */\n# define X509_V_FLAG_POLICY_CHECK                0x80\n/* Policy variable require-explicit-policy */\n# define X509_V_FLAG_EXPLICIT_POLICY             0x100\n/* Policy variable inhibit-any-policy */\n# define X509_V_FLAG_INHIBIT_ANY                 0x200\n/* Policy variable inhibit-policy-mapping */\n# define X509_V_FLAG_INHIBIT_MAP                 0x400\n/* Notify callback that policy is OK */\n# define X509_V_FLAG_NOTIFY_POLICY               0x800\n/* Extended CRL features such as indirect CRLs, alternate CRL signing keys */\n# define X509_V_FLAG_EXTENDED_CRL_SUPPORT        0x1000\n/* Delta CRL support */\n# define X509_V_FLAG_USE_DELTAS                  0x2000\n/* Check selfsigned CA signature */\n# define X509_V_FLAG_CHECK_SS_SIGNATURE          0x4000\n/* Use trusted store first */\n# define X509_V_FLAG_TRUSTED_FIRST               0x8000\n/* Suite B 128 bit only mode: not normally used */\n# define X509_V_FLAG_SUITEB_128_LOS_ONLY         0x10000\n/* Suite B 192 bit only mode */\n# define X509_V_FLAG_SUITEB_192_LOS              0x20000\n/* Suite B 128 bit mode allowing 192 bit algorithms */\n# define X509_V_FLAG_SUITEB_128_LOS              0x30000\n\n/* Allow partial chains if at least one certificate is in trusted store */\n# define X509_V_FLAG_PARTIAL_CHAIN               0x80000\n/*\n * If the initial chain is not trusted, do not attempt to build an alternative\n * chain. Alternate chain checking was introduced in 1.0.2b. Setting this flag\n * will force the behaviour to match that of previous versions.\n */\n# define X509_V_FLAG_NO_ALT_CHAINS               0x100000\n\n# define X509_VP_FLAG_DEFAULT                    0x1\n# define X509_VP_FLAG_OVERWRITE                  0x2\n# define X509_VP_FLAG_RESET_FLAGS                0x4\n# define X509_VP_FLAG_LOCKED                     0x8\n# define X509_VP_FLAG_ONCE                       0x10\n\n/* Internal use: mask of policy related options */\n# define X509_V_FLAG_POLICY_MASK (X509_V_FLAG_POLICY_CHECK \\\n                                | X509_V_FLAG_EXPLICIT_POLICY \\\n                                | X509_V_FLAG_INHIBIT_ANY \\\n                                | X509_V_FLAG_INHIBIT_MAP)\n\nint X509_OBJECT_idx_by_subject(STACK_OF(X509_OBJECT) *h, int type,\n                               X509_NAME *name);\nX509_OBJECT *X509_OBJECT_retrieve_by_subject(STACK_OF(X509_OBJECT) *h,\n                                             int type, X509_NAME *name);\nX509_OBJECT *X509_OBJECT_retrieve_match(STACK_OF(X509_OBJECT) *h,\n                                        X509_OBJECT *x);\nvoid X509_OBJECT_up_ref_count(X509_OBJECT *a);\nvoid X509_OBJECT_free_contents(X509_OBJECT *a);\nX509_STORE *X509_STORE_new(void);\nvoid X509_STORE_free(X509_STORE *v);\n\nSTACK_OF(X509) *X509_STORE_get1_certs(X509_STORE_CTX *st, X509_NAME *nm);\nSTACK_OF(X509_CRL) *X509_STORE_get1_crls(X509_STORE_CTX *st, X509_NAME *nm);\nint X509_STORE_set_flags(X509_STORE *ctx, unsigned long flags);\nint X509_STORE_set_purpose(X509_STORE *ctx, int purpose);\nint X509_STORE_set_trust(X509_STORE *ctx, int trust);\nint X509_STORE_set1_param(X509_STORE *ctx, X509_VERIFY_PARAM *pm);\n\nvoid X509_STORE_set_verify_cb(X509_STORE *ctx,\n                              int (*verify_cb) (int, X509_STORE_CTX *));\n\nvoid X509_STORE_set_lookup_crls_cb(X509_STORE *ctx,\n                                   STACK_OF(X509_CRL) *(*cb) (X509_STORE_CTX\n                                                              *ctx,\n                                                              X509_NAME *nm));\n\nX509_STORE_CTX *X509_STORE_CTX_new(void);\n\nint X509_STORE_CTX_get1_issuer(X509 **issuer, X509_STORE_CTX *ctx, X509 *x);\n\nvoid X509_STORE_CTX_free(X509_STORE_CTX *ctx);\nint X509_STORE_CTX_init(X509_STORE_CTX *ctx, X509_STORE *store,\n                        X509 *x509, STACK_OF(X509) *chain);\nvoid X509_STORE_CTX_trusted_stack(X509_STORE_CTX *ctx, STACK_OF(X509) *sk);\nvoid X509_STORE_CTX_cleanup(X509_STORE_CTX *ctx);\n\nX509_STORE *X509_STORE_CTX_get0_store(X509_STORE_CTX *ctx);\n\nX509_LOOKUP *X509_STORE_add_lookup(X509_STORE *v, X509_LOOKUP_METHOD *m);\n\nX509_LOOKUP_METHOD *X509_LOOKUP_hash_dir(void);\nX509_LOOKUP_METHOD *X509_LOOKUP_file(void);\n\nint X509_STORE_add_cert(X509_STORE *ctx, X509 *x);\nint X509_STORE_add_crl(X509_STORE *ctx, X509_CRL *x);\n\nint X509_STORE_get_by_subject(X509_STORE_CTX *vs, int type, X509_NAME *name,\n                              X509_OBJECT *ret);\n\nint X509_LOOKUP_ctrl(X509_LOOKUP *ctx, int cmd, const char *argc,\n                     long argl, char **ret);\n\n# ifndef OPENSSL_NO_STDIO\nint X509_load_cert_file(X509_LOOKUP *ctx, const char *file, int type);\nint X509_load_crl_file(X509_LOOKUP *ctx, const char *file, int type);\nint X509_load_cert_crl_file(X509_LOOKUP *ctx, const char *file, int type);\n# endif\n\nX509_LOOKUP *X509_LOOKUP_new(X509_LOOKUP_METHOD *method);\nvoid X509_LOOKUP_free(X509_LOOKUP *ctx);\nint X509_LOOKUP_init(X509_LOOKUP *ctx);\nint X509_LOOKUP_by_subject(X509_LOOKUP *ctx, int type, X509_NAME *name,\n                           X509_OBJECT *ret);\nint X509_LOOKUP_by_issuer_serial(X509_LOOKUP *ctx, int type, X509_NAME *name,\n                                 ASN1_INTEGER *serial, X509_OBJECT *ret);\nint X509_LOOKUP_by_fingerprint(X509_LOOKUP *ctx, int type,\n                               unsigned char *bytes, int len,\n                               X509_OBJECT *ret);\nint X509_LOOKUP_by_alias(X509_LOOKUP *ctx, int type, char *str, int len,\n                         X509_OBJECT *ret);\nint X509_LOOKUP_shutdown(X509_LOOKUP *ctx);\n\n# ifndef OPENSSL_NO_STDIO\nint X509_STORE_load_locations(X509_STORE *ctx,\n                              const char *file, const char *dir);\nint X509_STORE_set_default_paths(X509_STORE *ctx);\n# endif\n\nint X509_STORE_CTX_get_ex_new_index(long argl, void *argp,\n                                    CRYPTO_EX_new *new_func,\n                                    CRYPTO_EX_dup *dup_func,\n                                    CRYPTO_EX_free *free_func);\nint X509_STORE_CTX_set_ex_data(X509_STORE_CTX *ctx, int idx, void *data);\nvoid *X509_STORE_CTX_get_ex_data(X509_STORE_CTX *ctx, int idx);\nint X509_STORE_CTX_get_error(X509_STORE_CTX *ctx);\nvoid X509_STORE_CTX_set_error(X509_STORE_CTX *ctx, int s);\nint X509_STORE_CTX_get_error_depth(X509_STORE_CTX *ctx);\nX509 *X509_STORE_CTX_get_current_cert(X509_STORE_CTX *ctx);\nX509 *X509_STORE_CTX_get0_current_issuer(X509_STORE_CTX *ctx);\nX509_CRL *X509_STORE_CTX_get0_current_crl(X509_STORE_CTX *ctx);\nX509_STORE_CTX *X509_STORE_CTX_get0_parent_ctx(X509_STORE_CTX *ctx);\nSTACK_OF(X509) *X509_STORE_CTX_get_chain(X509_STORE_CTX *ctx);\nSTACK_OF(X509) *X509_STORE_CTX_get1_chain(X509_STORE_CTX *ctx);\nvoid X509_STORE_CTX_set_cert(X509_STORE_CTX *c, X509 *x);\nvoid X509_STORE_CTX_set_chain(X509_STORE_CTX *c, STACK_OF(X509) *sk);\nvoid X509_STORE_CTX_set0_crls(X509_STORE_CTX *c, STACK_OF(X509_CRL) *sk);\nint X509_STORE_CTX_set_purpose(X509_STORE_CTX *ctx, int purpose);\nint X509_STORE_CTX_set_trust(X509_STORE_CTX *ctx, int trust);\nint X509_STORE_CTX_purpose_inherit(X509_STORE_CTX *ctx, int def_purpose,\n                                   int purpose, int trust);\nvoid X509_STORE_CTX_set_flags(X509_STORE_CTX *ctx, unsigned long flags);\nvoid X509_STORE_CTX_set_time(X509_STORE_CTX *ctx, unsigned long flags,\n                             time_t t);\nvoid X509_STORE_CTX_set_verify_cb(X509_STORE_CTX *ctx,\n                                  int (*verify_cb) (int, X509_STORE_CTX *));\n\nX509_POLICY_TREE *X509_STORE_CTX_get0_policy_tree(X509_STORE_CTX *ctx);\nint X509_STORE_CTX_get_explicit_policy(X509_STORE_CTX *ctx);\n\nX509_VERIFY_PARAM *X509_STORE_CTX_get0_param(X509_STORE_CTX *ctx);\nvoid X509_STORE_CTX_set0_param(X509_STORE_CTX *ctx, X509_VERIFY_PARAM *param);\nint X509_STORE_CTX_set_default(X509_STORE_CTX *ctx, const char *name);\n\n/* X509_VERIFY_PARAM functions */\n\nX509_VERIFY_PARAM *X509_VERIFY_PARAM_new(void);\nvoid X509_VERIFY_PARAM_free(X509_VERIFY_PARAM *param);\nint X509_VERIFY_PARAM_inherit(X509_VERIFY_PARAM *to,\n                              const X509_VERIFY_PARAM *from);\nint X509_VERIFY_PARAM_set1(X509_VERIFY_PARAM *to,\n                           const X509_VERIFY_PARAM *from);\nint X509_VERIFY_PARAM_set1_name(X509_VERIFY_PARAM *param, const char *name);\nint X509_VERIFY_PARAM_set_flags(X509_VERIFY_PARAM *param,\n                                unsigned long flags);\nint X509_VERIFY_PARAM_clear_flags(X509_VERIFY_PARAM *param,\n                                  unsigned long flags);\nunsigned long X509_VERIFY_PARAM_get_flags(X509_VERIFY_PARAM *param);\nint X509_VERIFY_PARAM_set_purpose(X509_VERIFY_PARAM *param, int purpose);\nint X509_VERIFY_PARAM_set_trust(X509_VERIFY_PARAM *param, int trust);\nvoid X509_VERIFY_PARAM_set_depth(X509_VERIFY_PARAM *param, int depth);\nvoid X509_VERIFY_PARAM_set_time(X509_VERIFY_PARAM *param, time_t t);\nint X509_VERIFY_PARAM_add0_policy(X509_VERIFY_PARAM *param,\n                                  ASN1_OBJECT *policy);\nint X509_VERIFY_PARAM_set1_policies(X509_VERIFY_PARAM *param,\n                                    STACK_OF(ASN1_OBJECT) *policies);\n\nint X509_VERIFY_PARAM_set1_host(X509_VERIFY_PARAM *param,\n                                const char *name, size_t namelen);\nint X509_VERIFY_PARAM_add1_host(X509_VERIFY_PARAM *param,\n                                const char *name, size_t namelen);\nvoid X509_VERIFY_PARAM_set_hostflags(X509_VERIFY_PARAM *param,\n                                     unsigned int flags);\nchar *X509_VERIFY_PARAM_get0_peername(X509_VERIFY_PARAM *);\nint X509_VERIFY_PARAM_set1_email(X509_VERIFY_PARAM *param,\n                                 const char *email, size_t emaillen);\nint X509_VERIFY_PARAM_set1_ip(X509_VERIFY_PARAM *param,\n                              const unsigned char *ip, size_t iplen);\nint X509_VERIFY_PARAM_set1_ip_asc(X509_VERIFY_PARAM *param,\n                                  const char *ipasc);\n\nint X509_VERIFY_PARAM_get_depth(const X509_VERIFY_PARAM *param);\nconst char *X509_VERIFY_PARAM_get0_name(const X509_VERIFY_PARAM *param);\n\nint X509_VERIFY_PARAM_add0_table(X509_VERIFY_PARAM *param);\nint X509_VERIFY_PARAM_get_count(void);\nconst X509_VERIFY_PARAM *X509_VERIFY_PARAM_get0(int id);\nconst X509_VERIFY_PARAM *X509_VERIFY_PARAM_lookup(const char *name);\nvoid X509_VERIFY_PARAM_table_cleanup(void);\n\nint X509_policy_check(X509_POLICY_TREE **ptree, int *pexplicit_policy,\n                      STACK_OF(X509) *certs,\n                      STACK_OF(ASN1_OBJECT) *policy_oids, unsigned int flags);\n\nvoid X509_policy_tree_free(X509_POLICY_TREE *tree);\n\nint X509_policy_tree_level_count(const X509_POLICY_TREE *tree);\nX509_POLICY_LEVEL *X509_policy_tree_get0_level(const X509_POLICY_TREE *tree,\n                                               int i);\n\nSTACK_OF(X509_POLICY_NODE) *X509_policy_tree_get0_policies(const\n                                                           X509_POLICY_TREE\n                                                           *tree);\n\nSTACK_OF(X509_POLICY_NODE) *X509_policy_tree_get0_user_policies(const\n                                                                X509_POLICY_TREE\n                                                                *tree);\n\nint X509_policy_level_node_count(X509_POLICY_LEVEL *level);\n\nX509_POLICY_NODE *X509_policy_level_get0_node(X509_POLICY_LEVEL *level,\n                                              int i);\n\nconst ASN1_OBJECT *X509_policy_node_get0_policy(const X509_POLICY_NODE *node);\n\nSTACK_OF(POLICYQUALINFO) *X509_policy_node_get0_qualifiers(const\n                                                           X509_POLICY_NODE\n                                                           *node);\nconst X509_POLICY_NODE *X509_policy_node_get0_parent(const X509_POLICY_NODE\n                                                     *node);\n\n#ifdef  __cplusplus\n}\n#endif\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/arm/include/openssl/x509v3.h",
    "content": "/* x509v3.h */\n/*\n * Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL project\n * 1999.\n */\n/* ====================================================================\n * Copyright (c) 1999-2004 The OpenSSL Project.  All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n *\n * 1. Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n *\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in\n *    the documentation and/or other materials provided with the\n *    distribution.\n *\n * 3. All advertising materials mentioning features or use of this\n *    software must display the following acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)\"\n *\n * 4. The names \"OpenSSL Toolkit\" and \"OpenSSL Project\" must not be used to\n *    endorse or promote products derived from this software without\n *    prior written permission. For written permission, please contact\n *    licensing@OpenSSL.org.\n *\n * 5. Products derived from this software may not be called \"OpenSSL\"\n *    nor may \"OpenSSL\" appear in their names without prior written\n *    permission of the OpenSSL Project.\n *\n * 6. Redistributions of any form whatsoever must retain the following\n *    acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)\"\n *\n * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY\n * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\n * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR\n * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\n * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,\n * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED\n * OF THE POSSIBILITY OF SUCH DAMAGE.\n * ====================================================================\n *\n * This product includes cryptographic software written by Eric Young\n * (eay@cryptsoft.com).  This product includes software written by Tim\n * Hudson (tjh@cryptsoft.com).\n *\n */\n#ifndef HEADER_X509V3_H\n# define HEADER_X509V3_H\n\n# include <openssl/bio.h>\n# include <openssl/x509.h>\n# include <openssl/conf.h>\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n# ifdef OPENSSL_SYS_WIN32\n/* Under Win32 these are defined in wincrypt.h */\n#  undef X509_NAME\n#  undef X509_CERT_PAIR\n#  undef X509_EXTENSIONS\n# endif\n\n/* Forward reference */\nstruct v3_ext_method;\nstruct v3_ext_ctx;\n\n/* Useful typedefs */\n\ntypedef void *(*X509V3_EXT_NEW)(void);\ntypedef void (*X509V3_EXT_FREE) (void *);\ntypedef void *(*X509V3_EXT_D2I)(void *, const unsigned char **, long);\ntypedef int (*X509V3_EXT_I2D) (void *, unsigned char **);\ntypedef STACK_OF(CONF_VALUE) *\n    (*X509V3_EXT_I2V) (const struct v3_ext_method *method, void *ext,\n                       STACK_OF(CONF_VALUE) *extlist);\ntypedef void *(*X509V3_EXT_V2I)(const struct v3_ext_method *method,\n                                struct v3_ext_ctx *ctx,\n                                STACK_OF(CONF_VALUE) *values);\ntypedef char *(*X509V3_EXT_I2S)(const struct v3_ext_method *method,\n                                void *ext);\ntypedef void *(*X509V3_EXT_S2I)(const struct v3_ext_method *method,\n                                struct v3_ext_ctx *ctx, const char *str);\ntypedef int (*X509V3_EXT_I2R) (const struct v3_ext_method *method, void *ext,\n                               BIO *out, int indent);\ntypedef void *(*X509V3_EXT_R2I)(const struct v3_ext_method *method,\n                                struct v3_ext_ctx *ctx, const char *str);\n\n/* V3 extension structure */\n\nstruct v3_ext_method {\n    int ext_nid;\n    int ext_flags;\n/* If this is set the following four fields are ignored */\n    ASN1_ITEM_EXP *it;\n/* Old style ASN1 calls */\n    X509V3_EXT_NEW ext_new;\n    X509V3_EXT_FREE ext_free;\n    X509V3_EXT_D2I d2i;\n    X509V3_EXT_I2D i2d;\n/* The following pair is used for string extensions */\n    X509V3_EXT_I2S i2s;\n    X509V3_EXT_S2I s2i;\n/* The following pair is used for multi-valued extensions */\n    X509V3_EXT_I2V i2v;\n    X509V3_EXT_V2I v2i;\n/* The following are used for raw extensions */\n    X509V3_EXT_I2R i2r;\n    X509V3_EXT_R2I r2i;\n    void *usr_data;             /* Any extension specific data */\n};\n\ntypedef struct X509V3_CONF_METHOD_st {\n    char *(*get_string) (void *db, char *section, char *value);\n    STACK_OF(CONF_VALUE) *(*get_section) (void *db, char *section);\n    void (*free_string) (void *db, char *string);\n    void (*free_section) (void *db, STACK_OF(CONF_VALUE) *section);\n} X509V3_CONF_METHOD;\n\n/* Context specific info */\nstruct v3_ext_ctx {\n# define CTX_TEST 0x1\n    int flags;\n    X509 *issuer_cert;\n    X509 *subject_cert;\n    X509_REQ *subject_req;\n    X509_CRL *crl;\n    X509V3_CONF_METHOD *db_meth;\n    void *db;\n/* Maybe more here */\n};\n\ntypedef struct v3_ext_method X509V3_EXT_METHOD;\n\nDECLARE_STACK_OF(X509V3_EXT_METHOD)\n\n/* ext_flags values */\n# define X509V3_EXT_DYNAMIC      0x1\n# define X509V3_EXT_CTX_DEP      0x2\n# define X509V3_EXT_MULTILINE    0x4\n\ntypedef BIT_STRING_BITNAME ENUMERATED_NAMES;\n\ntypedef struct BASIC_CONSTRAINTS_st {\n    int ca;\n    ASN1_INTEGER *pathlen;\n} BASIC_CONSTRAINTS;\n\ntypedef struct PKEY_USAGE_PERIOD_st {\n    ASN1_GENERALIZEDTIME *notBefore;\n    ASN1_GENERALIZEDTIME *notAfter;\n} PKEY_USAGE_PERIOD;\n\ntypedef struct otherName_st {\n    ASN1_OBJECT *type_id;\n    ASN1_TYPE *value;\n} OTHERNAME;\n\ntypedef struct EDIPartyName_st {\n    ASN1_STRING *nameAssigner;\n    ASN1_STRING *partyName;\n} EDIPARTYNAME;\n\ntypedef struct GENERAL_NAME_st {\n# define GEN_OTHERNAME   0\n# define GEN_EMAIL       1\n# define GEN_DNS         2\n# define GEN_X400        3\n# define GEN_DIRNAME     4\n# define GEN_EDIPARTY    5\n# define GEN_URI         6\n# define GEN_IPADD       7\n# define GEN_RID         8\n    int type;\n    union {\n        char *ptr;\n        OTHERNAME *otherName;   /* otherName */\n        ASN1_IA5STRING *rfc822Name;\n        ASN1_IA5STRING *dNSName;\n        ASN1_TYPE *x400Address;\n        X509_NAME *directoryName;\n        EDIPARTYNAME *ediPartyName;\n        ASN1_IA5STRING *uniformResourceIdentifier;\n        ASN1_OCTET_STRING *iPAddress;\n        ASN1_OBJECT *registeredID;\n        /* Old names */\n        ASN1_OCTET_STRING *ip;  /* iPAddress */\n        X509_NAME *dirn;        /* dirn */\n        ASN1_IA5STRING *ia5;    /* rfc822Name, dNSName,\n                                 * uniformResourceIdentifier */\n        ASN1_OBJECT *rid;       /* registeredID */\n        ASN1_TYPE *other;       /* x400Address */\n    } d;\n} GENERAL_NAME;\n\ntypedef STACK_OF(GENERAL_NAME) GENERAL_NAMES;\n\ntypedef struct ACCESS_DESCRIPTION_st {\n    ASN1_OBJECT *method;\n    GENERAL_NAME *location;\n} ACCESS_DESCRIPTION;\n\ntypedef STACK_OF(ACCESS_DESCRIPTION) AUTHORITY_INFO_ACCESS;\n\ntypedef STACK_OF(ASN1_OBJECT) EXTENDED_KEY_USAGE;\n\nDECLARE_STACK_OF(GENERAL_NAME)\nDECLARE_ASN1_SET_OF(GENERAL_NAME)\n\nDECLARE_STACK_OF(ACCESS_DESCRIPTION)\nDECLARE_ASN1_SET_OF(ACCESS_DESCRIPTION)\n\ntypedef struct DIST_POINT_NAME_st {\n    int type;\n    union {\n        GENERAL_NAMES *fullname;\n        STACK_OF(X509_NAME_ENTRY) *relativename;\n    } name;\n/* If relativename then this contains the full distribution point name */\n    X509_NAME *dpname;\n} DIST_POINT_NAME;\n/* All existing reasons */\n# define CRLDP_ALL_REASONS       0x807f\n\n# define CRL_REASON_NONE                         -1\n# define CRL_REASON_UNSPECIFIED                  0\n# define CRL_REASON_KEY_COMPROMISE               1\n# define CRL_REASON_CA_COMPROMISE                2\n# define CRL_REASON_AFFILIATION_CHANGED          3\n# define CRL_REASON_SUPERSEDED                   4\n# define CRL_REASON_CESSATION_OF_OPERATION       5\n# define CRL_REASON_CERTIFICATE_HOLD             6\n# define CRL_REASON_REMOVE_FROM_CRL              8\n# define CRL_REASON_PRIVILEGE_WITHDRAWN          9\n# define CRL_REASON_AA_COMPROMISE                10\n\nstruct DIST_POINT_st {\n    DIST_POINT_NAME *distpoint;\n    ASN1_BIT_STRING *reasons;\n    GENERAL_NAMES *CRLissuer;\n    int dp_reasons;\n};\n\ntypedef STACK_OF(DIST_POINT) CRL_DIST_POINTS;\n\nDECLARE_STACK_OF(DIST_POINT)\nDECLARE_ASN1_SET_OF(DIST_POINT)\n\nstruct AUTHORITY_KEYID_st {\n    ASN1_OCTET_STRING *keyid;\n    GENERAL_NAMES *issuer;\n    ASN1_INTEGER *serial;\n};\n\n/* Strong extranet structures */\n\ntypedef struct SXNET_ID_st {\n    ASN1_INTEGER *zone;\n    ASN1_OCTET_STRING *user;\n} SXNETID;\n\nDECLARE_STACK_OF(SXNETID)\nDECLARE_ASN1_SET_OF(SXNETID)\n\ntypedef struct SXNET_st {\n    ASN1_INTEGER *version;\n    STACK_OF(SXNETID) *ids;\n} SXNET;\n\ntypedef struct NOTICEREF_st {\n    ASN1_STRING *organization;\n    STACK_OF(ASN1_INTEGER) *noticenos;\n} NOTICEREF;\n\ntypedef struct USERNOTICE_st {\n    NOTICEREF *noticeref;\n    ASN1_STRING *exptext;\n} USERNOTICE;\n\ntypedef struct POLICYQUALINFO_st {\n    ASN1_OBJECT *pqualid;\n    union {\n        ASN1_IA5STRING *cpsuri;\n        USERNOTICE *usernotice;\n        ASN1_TYPE *other;\n    } d;\n} POLICYQUALINFO;\n\nDECLARE_STACK_OF(POLICYQUALINFO)\nDECLARE_ASN1_SET_OF(POLICYQUALINFO)\n\ntypedef struct POLICYINFO_st {\n    ASN1_OBJECT *policyid;\n    STACK_OF(POLICYQUALINFO) *qualifiers;\n} POLICYINFO;\n\ntypedef STACK_OF(POLICYINFO) CERTIFICATEPOLICIES;\n\nDECLARE_STACK_OF(POLICYINFO)\nDECLARE_ASN1_SET_OF(POLICYINFO)\n\ntypedef struct POLICY_MAPPING_st {\n    ASN1_OBJECT *issuerDomainPolicy;\n    ASN1_OBJECT *subjectDomainPolicy;\n} POLICY_MAPPING;\n\nDECLARE_STACK_OF(POLICY_MAPPING)\n\ntypedef STACK_OF(POLICY_MAPPING) POLICY_MAPPINGS;\n\ntypedef struct GENERAL_SUBTREE_st {\n    GENERAL_NAME *base;\n    ASN1_INTEGER *minimum;\n    ASN1_INTEGER *maximum;\n} GENERAL_SUBTREE;\n\nDECLARE_STACK_OF(GENERAL_SUBTREE)\n\nstruct NAME_CONSTRAINTS_st {\n    STACK_OF(GENERAL_SUBTREE) *permittedSubtrees;\n    STACK_OF(GENERAL_SUBTREE) *excludedSubtrees;\n};\n\ntypedef struct POLICY_CONSTRAINTS_st {\n    ASN1_INTEGER *requireExplicitPolicy;\n    ASN1_INTEGER *inhibitPolicyMapping;\n} POLICY_CONSTRAINTS;\n\n/* Proxy certificate structures, see RFC 3820 */\ntypedef struct PROXY_POLICY_st {\n    ASN1_OBJECT *policyLanguage;\n    ASN1_OCTET_STRING *policy;\n} PROXY_POLICY;\n\ntypedef struct PROXY_CERT_INFO_EXTENSION_st {\n    ASN1_INTEGER *pcPathLengthConstraint;\n    PROXY_POLICY *proxyPolicy;\n} PROXY_CERT_INFO_EXTENSION;\n\nDECLARE_ASN1_FUNCTIONS(PROXY_POLICY)\nDECLARE_ASN1_FUNCTIONS(PROXY_CERT_INFO_EXTENSION)\n\nstruct ISSUING_DIST_POINT_st {\n    DIST_POINT_NAME *distpoint;\n    int onlyuser;\n    int onlyCA;\n    ASN1_BIT_STRING *onlysomereasons;\n    int indirectCRL;\n    int onlyattr;\n};\n\n/* Values in idp_flags field */\n/* IDP present */\n# define IDP_PRESENT     0x1\n/* IDP values inconsistent */\n# define IDP_INVALID     0x2\n/* onlyuser true */\n# define IDP_ONLYUSER    0x4\n/* onlyCA true */\n# define IDP_ONLYCA      0x8\n/* onlyattr true */\n# define IDP_ONLYATTR    0x10\n/* indirectCRL true */\n# define IDP_INDIRECT    0x20\n/* onlysomereasons present */\n# define IDP_REASONS     0x40\n\n# define X509V3_conf_err(val) ERR_add_error_data(6, \"section:\", val->section, \\\n\",name:\", val->name, \",value:\", val->value);\n\n# define X509V3_set_ctx_test(ctx) \\\n                        X509V3_set_ctx(ctx, NULL, NULL, NULL, NULL, CTX_TEST)\n# define X509V3_set_ctx_nodb(ctx) (ctx)->db = NULL;\n\n# define EXT_BITSTRING(nid, table) { nid, 0, ASN1_ITEM_ref(ASN1_BIT_STRING), \\\n                        0,0,0,0, \\\n                        0,0, \\\n                        (X509V3_EXT_I2V)i2v_ASN1_BIT_STRING, \\\n                        (X509V3_EXT_V2I)v2i_ASN1_BIT_STRING, \\\n                        NULL, NULL, \\\n                        table}\n\n# define EXT_IA5STRING(nid) { nid, 0, ASN1_ITEM_ref(ASN1_IA5STRING), \\\n                        0,0,0,0, \\\n                        (X509V3_EXT_I2S)i2s_ASN1_IA5STRING, \\\n                        (X509V3_EXT_S2I)s2i_ASN1_IA5STRING, \\\n                        0,0,0,0, \\\n                        NULL}\n\n# define EXT_END { -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}\n\n/* X509_PURPOSE stuff */\n\n# define EXFLAG_BCONS            0x1\n# define EXFLAG_KUSAGE           0x2\n# define EXFLAG_XKUSAGE          0x4\n# define EXFLAG_NSCERT           0x8\n\n# define EXFLAG_CA               0x10\n/* Really self issued not necessarily self signed */\n# define EXFLAG_SI               0x20\n# define EXFLAG_V1               0x40\n# define EXFLAG_INVALID          0x80\n# define EXFLAG_SET              0x100\n# define EXFLAG_CRITICAL         0x200\n# define EXFLAG_PROXY            0x400\n\n# define EXFLAG_INVALID_POLICY   0x800\n# define EXFLAG_FRESHEST         0x1000\n/* Self signed */\n# define EXFLAG_SS               0x2000\n\n# define KU_DIGITAL_SIGNATURE    0x0080\n# define KU_NON_REPUDIATION      0x0040\n# define KU_KEY_ENCIPHERMENT     0x0020\n# define KU_DATA_ENCIPHERMENT    0x0010\n# define KU_KEY_AGREEMENT        0x0008\n# define KU_KEY_CERT_SIGN        0x0004\n# define KU_CRL_SIGN             0x0002\n# define KU_ENCIPHER_ONLY        0x0001\n# define KU_DECIPHER_ONLY        0x8000\n\n# define NS_SSL_CLIENT           0x80\n# define NS_SSL_SERVER           0x40\n# define NS_SMIME                0x20\n# define NS_OBJSIGN              0x10\n# define NS_SSL_CA               0x04\n# define NS_SMIME_CA             0x02\n# define NS_OBJSIGN_CA           0x01\n# define NS_ANY_CA               (NS_SSL_CA|NS_SMIME_CA|NS_OBJSIGN_CA)\n\n# define XKU_SSL_SERVER          0x1\n# define XKU_SSL_CLIENT          0x2\n# define XKU_SMIME               0x4\n# define XKU_CODE_SIGN           0x8\n# define XKU_SGC                 0x10\n# define XKU_OCSP_SIGN           0x20\n# define XKU_TIMESTAMP           0x40\n# define XKU_DVCS                0x80\n# define XKU_ANYEKU              0x100\n\n# define X509_PURPOSE_DYNAMIC    0x1\n# define X509_PURPOSE_DYNAMIC_NAME       0x2\n\ntypedef struct x509_purpose_st {\n    int purpose;\n    int trust;                  /* Default trust ID */\n    int flags;\n    int (*check_purpose) (const struct x509_purpose_st *, const X509 *, int);\n    char *name;\n    char *sname;\n    void *usr_data;\n} X509_PURPOSE;\n\n# define X509_PURPOSE_SSL_CLIENT         1\n# define X509_PURPOSE_SSL_SERVER         2\n# define X509_PURPOSE_NS_SSL_SERVER      3\n# define X509_PURPOSE_SMIME_SIGN         4\n# define X509_PURPOSE_SMIME_ENCRYPT      5\n# define X509_PURPOSE_CRL_SIGN           6\n# define X509_PURPOSE_ANY                7\n# define X509_PURPOSE_OCSP_HELPER        8\n# define X509_PURPOSE_TIMESTAMP_SIGN     9\n\n# define X509_PURPOSE_MIN                1\n# define X509_PURPOSE_MAX                9\n\n/* Flags for X509V3_EXT_print() */\n\n# define X509V3_EXT_UNKNOWN_MASK         (0xfL << 16)\n/* Return error for unknown extensions */\n# define X509V3_EXT_DEFAULT              0\n/* Print error for unknown extensions */\n# define X509V3_EXT_ERROR_UNKNOWN        (1L << 16)\n/* ASN1 parse unknown extensions */\n# define X509V3_EXT_PARSE_UNKNOWN        (2L << 16)\n/* BIO_dump unknown extensions */\n# define X509V3_EXT_DUMP_UNKNOWN         (3L << 16)\n\n/* Flags for X509V3_add1_i2d */\n\n# define X509V3_ADD_OP_MASK              0xfL\n# define X509V3_ADD_DEFAULT              0L\n# define X509V3_ADD_APPEND               1L\n# define X509V3_ADD_REPLACE              2L\n# define X509V3_ADD_REPLACE_EXISTING     3L\n# define X509V3_ADD_KEEP_EXISTING        4L\n# define X509V3_ADD_DELETE               5L\n# define X509V3_ADD_SILENT               0x10\n\nDECLARE_STACK_OF(X509_PURPOSE)\n\nDECLARE_ASN1_FUNCTIONS(BASIC_CONSTRAINTS)\n\nDECLARE_ASN1_FUNCTIONS(SXNET)\nDECLARE_ASN1_FUNCTIONS(SXNETID)\n\nint SXNET_add_id_asc(SXNET **psx, char *zone, char *user, int userlen);\nint SXNET_add_id_ulong(SXNET **psx, unsigned long lzone, char *user,\n                       int userlen);\nint SXNET_add_id_INTEGER(SXNET **psx, ASN1_INTEGER *izone, char *user,\n                         int userlen);\n\nASN1_OCTET_STRING *SXNET_get_id_asc(SXNET *sx, char *zone);\nASN1_OCTET_STRING *SXNET_get_id_ulong(SXNET *sx, unsigned long lzone);\nASN1_OCTET_STRING *SXNET_get_id_INTEGER(SXNET *sx, ASN1_INTEGER *zone);\n\nDECLARE_ASN1_FUNCTIONS(AUTHORITY_KEYID)\n\nDECLARE_ASN1_FUNCTIONS(PKEY_USAGE_PERIOD)\n\nDECLARE_ASN1_FUNCTIONS(GENERAL_NAME)\nGENERAL_NAME *GENERAL_NAME_dup(GENERAL_NAME *a);\nint GENERAL_NAME_cmp(GENERAL_NAME *a, GENERAL_NAME *b);\n\nASN1_BIT_STRING *v2i_ASN1_BIT_STRING(X509V3_EXT_METHOD *method,\n                                     X509V3_CTX *ctx,\n                                     STACK_OF(CONF_VALUE) *nval);\nSTACK_OF(CONF_VALUE) *i2v_ASN1_BIT_STRING(X509V3_EXT_METHOD *method,\n                                          ASN1_BIT_STRING *bits,\n                                          STACK_OF(CONF_VALUE) *extlist);\n\nSTACK_OF(CONF_VALUE) *i2v_GENERAL_NAME(X509V3_EXT_METHOD *method,\n                                       GENERAL_NAME *gen,\n                                       STACK_OF(CONF_VALUE) *ret);\nint GENERAL_NAME_print(BIO *out, GENERAL_NAME *gen);\n\nDECLARE_ASN1_FUNCTIONS(GENERAL_NAMES)\n\nSTACK_OF(CONF_VALUE) *i2v_GENERAL_NAMES(X509V3_EXT_METHOD *method,\n                                        GENERAL_NAMES *gen,\n                                        STACK_OF(CONF_VALUE) *extlist);\nGENERAL_NAMES *v2i_GENERAL_NAMES(const X509V3_EXT_METHOD *method,\n                                 X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *nval);\n\nDECLARE_ASN1_FUNCTIONS(OTHERNAME)\nDECLARE_ASN1_FUNCTIONS(EDIPARTYNAME)\nint OTHERNAME_cmp(OTHERNAME *a, OTHERNAME *b);\nvoid GENERAL_NAME_set0_value(GENERAL_NAME *a, int type, void *value);\nvoid *GENERAL_NAME_get0_value(GENERAL_NAME *a, int *ptype);\nint GENERAL_NAME_set0_othername(GENERAL_NAME *gen,\n                                ASN1_OBJECT *oid, ASN1_TYPE *value);\nint GENERAL_NAME_get0_otherName(GENERAL_NAME *gen,\n                                ASN1_OBJECT **poid, ASN1_TYPE **pvalue);\n\nchar *i2s_ASN1_OCTET_STRING(X509V3_EXT_METHOD *method,\n                            ASN1_OCTET_STRING *ia5);\nASN1_OCTET_STRING *s2i_ASN1_OCTET_STRING(X509V3_EXT_METHOD *method,\n                                         X509V3_CTX *ctx, char *str);\n\nDECLARE_ASN1_FUNCTIONS(EXTENDED_KEY_USAGE)\nint i2a_ACCESS_DESCRIPTION(BIO *bp, ACCESS_DESCRIPTION *a);\n\nDECLARE_ASN1_FUNCTIONS(CERTIFICATEPOLICIES)\nDECLARE_ASN1_FUNCTIONS(POLICYINFO)\nDECLARE_ASN1_FUNCTIONS(POLICYQUALINFO)\nDECLARE_ASN1_FUNCTIONS(USERNOTICE)\nDECLARE_ASN1_FUNCTIONS(NOTICEREF)\n\nDECLARE_ASN1_FUNCTIONS(CRL_DIST_POINTS)\nDECLARE_ASN1_FUNCTIONS(DIST_POINT)\nDECLARE_ASN1_FUNCTIONS(DIST_POINT_NAME)\nDECLARE_ASN1_FUNCTIONS(ISSUING_DIST_POINT)\n\nint DIST_POINT_set_dpname(DIST_POINT_NAME *dpn, X509_NAME *iname);\n\nint NAME_CONSTRAINTS_check(X509 *x, NAME_CONSTRAINTS *nc);\n\nDECLARE_ASN1_FUNCTIONS(ACCESS_DESCRIPTION)\nDECLARE_ASN1_FUNCTIONS(AUTHORITY_INFO_ACCESS)\n\nDECLARE_ASN1_ITEM(POLICY_MAPPING)\nDECLARE_ASN1_ALLOC_FUNCTIONS(POLICY_MAPPING)\nDECLARE_ASN1_ITEM(POLICY_MAPPINGS)\n\nDECLARE_ASN1_ITEM(GENERAL_SUBTREE)\nDECLARE_ASN1_ALLOC_FUNCTIONS(GENERAL_SUBTREE)\n\nDECLARE_ASN1_ITEM(NAME_CONSTRAINTS)\nDECLARE_ASN1_ALLOC_FUNCTIONS(NAME_CONSTRAINTS)\n\nDECLARE_ASN1_ALLOC_FUNCTIONS(POLICY_CONSTRAINTS)\nDECLARE_ASN1_ITEM(POLICY_CONSTRAINTS)\n\nGENERAL_NAME *a2i_GENERAL_NAME(GENERAL_NAME *out,\n                               const X509V3_EXT_METHOD *method,\n                               X509V3_CTX *ctx, int gen_type, char *value,\n                               int is_nc);\n\n# ifdef HEADER_CONF_H\nGENERAL_NAME *v2i_GENERAL_NAME(const X509V3_EXT_METHOD *method,\n                               X509V3_CTX *ctx, CONF_VALUE *cnf);\nGENERAL_NAME *v2i_GENERAL_NAME_ex(GENERAL_NAME *out,\n                                  const X509V3_EXT_METHOD *method,\n                                  X509V3_CTX *ctx, CONF_VALUE *cnf,\n                                  int is_nc);\nvoid X509V3_conf_free(CONF_VALUE *val);\n\nX509_EXTENSION *X509V3_EXT_nconf_nid(CONF *conf, X509V3_CTX *ctx, int ext_nid,\n                                     char *value);\nX509_EXTENSION *X509V3_EXT_nconf(CONF *conf, X509V3_CTX *ctx, char *name,\n                                 char *value);\nint X509V3_EXT_add_nconf_sk(CONF *conf, X509V3_CTX *ctx, char *section,\n                            STACK_OF(X509_EXTENSION) **sk);\nint X509V3_EXT_add_nconf(CONF *conf, X509V3_CTX *ctx, char *section,\n                         X509 *cert);\nint X509V3_EXT_REQ_add_nconf(CONF *conf, X509V3_CTX *ctx, char *section,\n                             X509_REQ *req);\nint X509V3_EXT_CRL_add_nconf(CONF *conf, X509V3_CTX *ctx, char *section,\n                             X509_CRL *crl);\n\nX509_EXTENSION *X509V3_EXT_conf_nid(LHASH_OF(CONF_VALUE) *conf,\n                                    X509V3_CTX *ctx, int ext_nid,\n                                    char *value);\nX509_EXTENSION *X509V3_EXT_conf(LHASH_OF(CONF_VALUE) *conf, X509V3_CTX *ctx,\n                                char *name, char *value);\nint X509V3_EXT_add_conf(LHASH_OF(CONF_VALUE) *conf, X509V3_CTX *ctx,\n                        char *section, X509 *cert);\nint X509V3_EXT_REQ_add_conf(LHASH_OF(CONF_VALUE) *conf, X509V3_CTX *ctx,\n                            char *section, X509_REQ *req);\nint X509V3_EXT_CRL_add_conf(LHASH_OF(CONF_VALUE) *conf, X509V3_CTX *ctx,\n                            char *section, X509_CRL *crl);\n\nint X509V3_add_value_bool_nf(char *name, int asn1_bool,\n                             STACK_OF(CONF_VALUE) **extlist);\nint X509V3_get_value_bool(CONF_VALUE *value, int *asn1_bool);\nint X509V3_get_value_int(CONF_VALUE *value, ASN1_INTEGER **aint);\nvoid X509V3_set_nconf(X509V3_CTX *ctx, CONF *conf);\nvoid X509V3_set_conf_lhash(X509V3_CTX *ctx, LHASH_OF(CONF_VALUE) *lhash);\n# endif\n\nchar *X509V3_get_string(X509V3_CTX *ctx, char *name, char *section);\nSTACK_OF(CONF_VALUE) *X509V3_get_section(X509V3_CTX *ctx, char *section);\nvoid X509V3_string_free(X509V3_CTX *ctx, char *str);\nvoid X509V3_section_free(X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *section);\nvoid X509V3_set_ctx(X509V3_CTX *ctx, X509 *issuer, X509 *subject,\n                    X509_REQ *req, X509_CRL *crl, int flags);\n\nint X509V3_add_value(const char *name, const char *value,\n                     STACK_OF(CONF_VALUE) **extlist);\nint X509V3_add_value_uchar(const char *name, const unsigned char *value,\n                           STACK_OF(CONF_VALUE) **extlist);\nint X509V3_add_value_bool(const char *name, int asn1_bool,\n                          STACK_OF(CONF_VALUE) **extlist);\nint X509V3_add_value_int(const char *name, ASN1_INTEGER *aint,\n                         STACK_OF(CONF_VALUE) **extlist);\nchar *i2s_ASN1_INTEGER(X509V3_EXT_METHOD *meth, ASN1_INTEGER *aint);\nASN1_INTEGER *s2i_ASN1_INTEGER(X509V3_EXT_METHOD *meth, char *value);\nchar *i2s_ASN1_ENUMERATED(X509V3_EXT_METHOD *meth, ASN1_ENUMERATED *aint);\nchar *i2s_ASN1_ENUMERATED_TABLE(X509V3_EXT_METHOD *meth,\n                                ASN1_ENUMERATED *aint);\nint X509V3_EXT_add(X509V3_EXT_METHOD *ext);\nint X509V3_EXT_add_list(X509V3_EXT_METHOD *extlist);\nint X509V3_EXT_add_alias(int nid_to, int nid_from);\nvoid X509V3_EXT_cleanup(void);\n\nconst X509V3_EXT_METHOD *X509V3_EXT_get(X509_EXTENSION *ext);\nconst X509V3_EXT_METHOD *X509V3_EXT_get_nid(int nid);\nint X509V3_add_standard_extensions(void);\nSTACK_OF(CONF_VALUE) *X509V3_parse_list(const char *line);\nvoid *X509V3_EXT_d2i(X509_EXTENSION *ext);\nvoid *X509V3_get_d2i(STACK_OF(X509_EXTENSION) *x, int nid, int *crit,\n                     int *idx);\nint X509V3_EXT_free(int nid, void *ext_data);\n\nX509_EXTENSION *X509V3_EXT_i2d(int ext_nid, int crit, void *ext_struc);\nint X509V3_add1_i2d(STACK_OF(X509_EXTENSION) **x, int nid, void *value,\n                    int crit, unsigned long flags);\n\nchar *hex_to_string(const unsigned char *buffer, long len);\nunsigned char *string_to_hex(const char *str, long *len);\nint name_cmp(const char *name, const char *cmp);\n\nvoid X509V3_EXT_val_prn(BIO *out, STACK_OF(CONF_VALUE) *val, int indent,\n                        int ml);\nint X509V3_EXT_print(BIO *out, X509_EXTENSION *ext, unsigned long flag,\n                     int indent);\nint X509V3_EXT_print_fp(FILE *out, X509_EXTENSION *ext, int flag, int indent);\n\nint X509V3_extensions_print(BIO *out, char *title,\n                            STACK_OF(X509_EXTENSION) *exts,\n                            unsigned long flag, int indent);\n\nint X509_check_ca(X509 *x);\nint X509_check_purpose(X509 *x, int id, int ca);\nint X509_supported_extension(X509_EXTENSION *ex);\nint X509_PURPOSE_set(int *p, int purpose);\nint X509_check_issued(X509 *issuer, X509 *subject);\nint X509_check_akid(X509 *issuer, AUTHORITY_KEYID *akid);\nint X509_PURPOSE_get_count(void);\nX509_PURPOSE *X509_PURPOSE_get0(int idx);\nint X509_PURPOSE_get_by_sname(char *sname);\nint X509_PURPOSE_get_by_id(int id);\nint X509_PURPOSE_add(int id, int trust, int flags,\n                     int (*ck) (const X509_PURPOSE *, const X509 *, int),\n                     char *name, char *sname, void *arg);\nchar *X509_PURPOSE_get0_name(X509_PURPOSE *xp);\nchar *X509_PURPOSE_get0_sname(X509_PURPOSE *xp);\nint X509_PURPOSE_get_trust(X509_PURPOSE *xp);\nvoid X509_PURPOSE_cleanup(void);\nint X509_PURPOSE_get_id(X509_PURPOSE *);\n\nSTACK_OF(OPENSSL_STRING) *X509_get1_email(X509 *x);\nSTACK_OF(OPENSSL_STRING) *X509_REQ_get1_email(X509_REQ *x);\nvoid X509_email_free(STACK_OF(OPENSSL_STRING) *sk);\nSTACK_OF(OPENSSL_STRING) *X509_get1_ocsp(X509 *x);\n/* Flags for X509_check_* functions */\n\n/*\n * Always check subject name for host match even if subject alt names present\n */\n# define X509_CHECK_FLAG_ALWAYS_CHECK_SUBJECT    0x1\n/* Disable wildcard matching for dnsName fields and common name. */\n# define X509_CHECK_FLAG_NO_WILDCARDS    0x2\n/* Wildcards must not match a partial label. */\n# define X509_CHECK_FLAG_NO_PARTIAL_WILDCARDS 0x4\n/* Allow (non-partial) wildcards to match multiple labels. */\n# define X509_CHECK_FLAG_MULTI_LABEL_WILDCARDS 0x8\n/* Constraint verifier subdomain patterns to match a single labels. */\n# define X509_CHECK_FLAG_SINGLE_LABEL_SUBDOMAINS 0x10\n/*\n * Match reference identifiers starting with \".\" to any sub-domain.\n * This is a non-public flag, turned on implicitly when the subject\n * reference identity is a DNS name.\n */\n# define _X509_CHECK_FLAG_DOT_SUBDOMAINS 0x8000\n\nint X509_check_host(X509 *x, const char *chk, size_t chklen,\n                    unsigned int flags, char **peername);\nint X509_check_email(X509 *x, const char *chk, size_t chklen,\n                     unsigned int flags);\nint X509_check_ip(X509 *x, const unsigned char *chk, size_t chklen,\n                  unsigned int flags);\nint X509_check_ip_asc(X509 *x, const char *ipasc, unsigned int flags);\n\nASN1_OCTET_STRING *a2i_IPADDRESS(const char *ipasc);\nASN1_OCTET_STRING *a2i_IPADDRESS_NC(const char *ipasc);\nint a2i_ipadd(unsigned char *ipout, const char *ipasc);\nint X509V3_NAME_from_section(X509_NAME *nm, STACK_OF(CONF_VALUE) *dn_sk,\n                             unsigned long chtype);\n\nvoid X509_POLICY_NODE_print(BIO *out, X509_POLICY_NODE *node, int indent);\nDECLARE_STACK_OF(X509_POLICY_NODE)\n\n# ifndef OPENSSL_NO_RFC3779\n\ntypedef struct ASRange_st {\n    ASN1_INTEGER *min, *max;\n} ASRange;\n\n#  define ASIdOrRange_id          0\n#  define ASIdOrRange_range       1\n\ntypedef struct ASIdOrRange_st {\n    int type;\n    union {\n        ASN1_INTEGER *id;\n        ASRange *range;\n    } u;\n} ASIdOrRange;\n\ntypedef STACK_OF(ASIdOrRange) ASIdOrRanges;\nDECLARE_STACK_OF(ASIdOrRange)\n\n#  define ASIdentifierChoice_inherit              0\n#  define ASIdentifierChoice_asIdsOrRanges        1\n\ntypedef struct ASIdentifierChoice_st {\n    int type;\n    union {\n        ASN1_NULL *inherit;\n        ASIdOrRanges *asIdsOrRanges;\n    } u;\n} ASIdentifierChoice;\n\ntypedef struct ASIdentifiers_st {\n    ASIdentifierChoice *asnum, *rdi;\n} ASIdentifiers;\n\nDECLARE_ASN1_FUNCTIONS(ASRange)\nDECLARE_ASN1_FUNCTIONS(ASIdOrRange)\nDECLARE_ASN1_FUNCTIONS(ASIdentifierChoice)\nDECLARE_ASN1_FUNCTIONS(ASIdentifiers)\n\ntypedef struct IPAddressRange_st {\n    ASN1_BIT_STRING *min, *max;\n} IPAddressRange;\n\n#  define IPAddressOrRange_addressPrefix  0\n#  define IPAddressOrRange_addressRange   1\n\ntypedef struct IPAddressOrRange_st {\n    int type;\n    union {\n        ASN1_BIT_STRING *addressPrefix;\n        IPAddressRange *addressRange;\n    } u;\n} IPAddressOrRange;\n\ntypedef STACK_OF(IPAddressOrRange) IPAddressOrRanges;\nDECLARE_STACK_OF(IPAddressOrRange)\n\n#  define IPAddressChoice_inherit                 0\n#  define IPAddressChoice_addressesOrRanges       1\n\ntypedef struct IPAddressChoice_st {\n    int type;\n    union {\n        ASN1_NULL *inherit;\n        IPAddressOrRanges *addressesOrRanges;\n    } u;\n} IPAddressChoice;\n\ntypedef struct IPAddressFamily_st {\n    ASN1_OCTET_STRING *addressFamily;\n    IPAddressChoice *ipAddressChoice;\n} IPAddressFamily;\n\ntypedef STACK_OF(IPAddressFamily) IPAddrBlocks;\nDECLARE_STACK_OF(IPAddressFamily)\n\nDECLARE_ASN1_FUNCTIONS(IPAddressRange)\nDECLARE_ASN1_FUNCTIONS(IPAddressOrRange)\nDECLARE_ASN1_FUNCTIONS(IPAddressChoice)\nDECLARE_ASN1_FUNCTIONS(IPAddressFamily)\n\n/*\n * API tag for elements of the ASIdentifer SEQUENCE.\n */\n#  define V3_ASID_ASNUM   0\n#  define V3_ASID_RDI     1\n\n/*\n * AFI values, assigned by IANA.  It'd be nice to make the AFI\n * handling code totally generic, but there are too many little things\n * that would need to be defined for other address families for it to\n * be worth the trouble.\n */\n#  define IANA_AFI_IPV4   1\n#  define IANA_AFI_IPV6   2\n\n/*\n * Utilities to construct and extract values from RFC3779 extensions,\n * since some of the encodings (particularly for IP address prefixes\n * and ranges) are a bit tedious to work with directly.\n */\nint v3_asid_add_inherit(ASIdentifiers *asid, int which);\nint v3_asid_add_id_or_range(ASIdentifiers *asid, int which,\n                            ASN1_INTEGER *min, ASN1_INTEGER *max);\nint v3_addr_add_inherit(IPAddrBlocks *addr,\n                        const unsigned afi, const unsigned *safi);\nint v3_addr_add_prefix(IPAddrBlocks *addr,\n                       const unsigned afi, const unsigned *safi,\n                       unsigned char *a, const int prefixlen);\nint v3_addr_add_range(IPAddrBlocks *addr,\n                      const unsigned afi, const unsigned *safi,\n                      unsigned char *min, unsigned char *max);\nunsigned v3_addr_get_afi(const IPAddressFamily *f);\nint v3_addr_get_range(IPAddressOrRange *aor, const unsigned afi,\n                      unsigned char *min, unsigned char *max,\n                      const int length);\n\n/*\n * Canonical forms.\n */\nint v3_asid_is_canonical(ASIdentifiers *asid);\nint v3_addr_is_canonical(IPAddrBlocks *addr);\nint v3_asid_canonize(ASIdentifiers *asid);\nint v3_addr_canonize(IPAddrBlocks *addr);\n\n/*\n * Tests for inheritance and containment.\n */\nint v3_asid_inherits(ASIdentifiers *asid);\nint v3_addr_inherits(IPAddrBlocks *addr);\nint v3_asid_subset(ASIdentifiers *a, ASIdentifiers *b);\nint v3_addr_subset(IPAddrBlocks *a, IPAddrBlocks *b);\n\n/*\n * Check whether RFC 3779 extensions nest properly in chains.\n */\nint v3_asid_validate_path(X509_STORE_CTX *);\nint v3_addr_validate_path(X509_STORE_CTX *);\nint v3_asid_validate_resource_set(STACK_OF(X509) *chain,\n                                  ASIdentifiers *ext, int allow_inheritance);\nint v3_addr_validate_resource_set(STACK_OF(X509) *chain,\n                                  IPAddrBlocks *ext, int allow_inheritance);\n\n# endif                         /* OPENSSL_NO_RFC3779 */\n\n/* BEGIN ERROR CODES */\n/*\n * The following lines are auto generated by the script mkerr.pl. Any changes\n * made after this point may be overwritten when the script is next run.\n */\nvoid ERR_load_X509V3_strings(void);\n\n/* Error codes for the X509V3 functions. */\n\n/* Function codes. */\n# define X509V3_F_A2I_GENERAL_NAME                        164\n# define X509V3_F_ASIDENTIFIERCHOICE_CANONIZE             161\n# define X509V3_F_ASIDENTIFIERCHOICE_IS_CANONICAL         162\n# define X509V3_F_COPY_EMAIL                              122\n# define X509V3_F_COPY_ISSUER                             123\n# define X509V3_F_DO_DIRNAME                              144\n# define X509V3_F_DO_EXT_CONF                             124\n# define X509V3_F_DO_EXT_I2D                              135\n# define X509V3_F_DO_EXT_NCONF                            151\n# define X509V3_F_DO_I2V_NAME_CONSTRAINTS                 148\n# define X509V3_F_GNAMES_FROM_SECTNAME                    156\n# define X509V3_F_HEX_TO_STRING                           111\n# define X509V3_F_I2S_ASN1_ENUMERATED                     121\n# define X509V3_F_I2S_ASN1_IA5STRING                      149\n# define X509V3_F_I2S_ASN1_INTEGER                        120\n# define X509V3_F_I2V_AUTHORITY_INFO_ACCESS               138\n# define X509V3_F_NOTICE_SECTION                          132\n# define X509V3_F_NREF_NOS                                133\n# define X509V3_F_POLICY_SECTION                          131\n# define X509V3_F_PROCESS_PCI_VALUE                       150\n# define X509V3_F_R2I_CERTPOL                             130\n# define X509V3_F_R2I_PCI                                 155\n# define X509V3_F_S2I_ASN1_IA5STRING                      100\n# define X509V3_F_S2I_ASN1_INTEGER                        108\n# define X509V3_F_S2I_ASN1_OCTET_STRING                   112\n# define X509V3_F_S2I_ASN1_SKEY_ID                        114\n# define X509V3_F_S2I_SKEY_ID                             115\n# define X509V3_F_SET_DIST_POINT_NAME                     158\n# define X509V3_F_STRING_TO_HEX                           113\n# define X509V3_F_SXNET_ADD_ID_ASC                        125\n# define X509V3_F_SXNET_ADD_ID_INTEGER                    126\n# define X509V3_F_SXNET_ADD_ID_ULONG                      127\n# define X509V3_F_SXNET_GET_ID_ASC                        128\n# define X509V3_F_SXNET_GET_ID_ULONG                      129\n# define X509V3_F_V2I_ASIDENTIFIERS                       163\n# define X509V3_F_V2I_ASN1_BIT_STRING                     101\n# define X509V3_F_V2I_AUTHORITY_INFO_ACCESS               139\n# define X509V3_F_V2I_AUTHORITY_KEYID                     119\n# define X509V3_F_V2I_BASIC_CONSTRAINTS                   102\n# define X509V3_F_V2I_CRLD                                134\n# define X509V3_F_V2I_EXTENDED_KEY_USAGE                  103\n# define X509V3_F_V2I_GENERAL_NAMES                       118\n# define X509V3_F_V2I_GENERAL_NAME_EX                     117\n# define X509V3_F_V2I_IDP                                 157\n# define X509V3_F_V2I_IPADDRBLOCKS                        159\n# define X509V3_F_V2I_ISSUER_ALT                          153\n# define X509V3_F_V2I_NAME_CONSTRAINTS                    147\n# define X509V3_F_V2I_POLICY_CONSTRAINTS                  146\n# define X509V3_F_V2I_POLICY_MAPPINGS                     145\n# define X509V3_F_V2I_SUBJECT_ALT                         154\n# define X509V3_F_V3_ADDR_VALIDATE_PATH_INTERNAL          160\n# define X509V3_F_V3_GENERIC_EXTENSION                    116\n# define X509V3_F_X509V3_ADD1_I2D                         140\n# define X509V3_F_X509V3_ADD_VALUE                        105\n# define X509V3_F_X509V3_EXT_ADD                          104\n# define X509V3_F_X509V3_EXT_ADD_ALIAS                    106\n# define X509V3_F_X509V3_EXT_CONF                         107\n# define X509V3_F_X509V3_EXT_FREE                         165\n# define X509V3_F_X509V3_EXT_I2D                          136\n# define X509V3_F_X509V3_EXT_NCONF                        152\n# define X509V3_F_X509V3_GET_SECTION                      142\n# define X509V3_F_X509V3_GET_STRING                       143\n# define X509V3_F_X509V3_GET_VALUE_BOOL                   110\n# define X509V3_F_X509V3_PARSE_LIST                       109\n# define X509V3_F_X509_PURPOSE_ADD                        137\n# define X509V3_F_X509_PURPOSE_SET                        141\n\n/* Reason codes. */\n# define X509V3_R_BAD_IP_ADDRESS                          118\n# define X509V3_R_BAD_OBJECT                              119\n# define X509V3_R_BN_DEC2BN_ERROR                         100\n# define X509V3_R_BN_TO_ASN1_INTEGER_ERROR                101\n# define X509V3_R_CANNOT_FIND_FREE_FUNCTION               168\n# define X509V3_R_DIRNAME_ERROR                           149\n# define X509V3_R_DISTPOINT_ALREADY_SET                   160\n# define X509V3_R_DUPLICATE_ZONE_ID                       133\n# define X509V3_R_ERROR_CONVERTING_ZONE                   131\n# define X509V3_R_ERROR_CREATING_EXTENSION                144\n# define X509V3_R_ERROR_IN_EXTENSION                      128\n# define X509V3_R_EXPECTED_A_SECTION_NAME                 137\n# define X509V3_R_EXTENSION_EXISTS                        145\n# define X509V3_R_EXTENSION_NAME_ERROR                    115\n# define X509V3_R_EXTENSION_NOT_FOUND                     102\n# define X509V3_R_EXTENSION_SETTING_NOT_SUPPORTED         103\n# define X509V3_R_EXTENSION_VALUE_ERROR                   116\n# define X509V3_R_ILLEGAL_EMPTY_EXTENSION                 151\n# define X509V3_R_ILLEGAL_HEX_DIGIT                       113\n# define X509V3_R_INCORRECT_POLICY_SYNTAX_TAG             152\n# define X509V3_R_INVALID_ASNUMBER                        162\n# define X509V3_R_INVALID_ASRANGE                         163\n# define X509V3_R_INVALID_BOOLEAN_STRING                  104\n# define X509V3_R_INVALID_EXTENSION_STRING                105\n# define X509V3_R_INVALID_INHERITANCE                     165\n# define X509V3_R_INVALID_IPADDRESS                       166\n# define X509V3_R_INVALID_MULTIPLE_RDNS                   161\n# define X509V3_R_INVALID_NAME                            106\n# define X509V3_R_INVALID_NULL_ARGUMENT                   107\n# define X509V3_R_INVALID_NULL_NAME                       108\n# define X509V3_R_INVALID_NULL_VALUE                      109\n# define X509V3_R_INVALID_NUMBER                          140\n# define X509V3_R_INVALID_NUMBERS                         141\n# define X509V3_R_INVALID_OBJECT_IDENTIFIER               110\n# define X509V3_R_INVALID_OPTION                          138\n# define X509V3_R_INVALID_POLICY_IDENTIFIER               134\n# define X509V3_R_INVALID_PROXY_POLICY_SETTING            153\n# define X509V3_R_INVALID_PURPOSE                         146\n# define X509V3_R_INVALID_SAFI                            164\n# define X509V3_R_INVALID_SECTION                         135\n# define X509V3_R_INVALID_SYNTAX                          143\n# define X509V3_R_ISSUER_DECODE_ERROR                     126\n# define X509V3_R_MISSING_VALUE                           124\n# define X509V3_R_NEED_ORGANIZATION_AND_NUMBERS           142\n# define X509V3_R_NO_CONFIG_DATABASE                      136\n# define X509V3_R_NO_ISSUER_CERTIFICATE                   121\n# define X509V3_R_NO_ISSUER_DETAILS                       127\n# define X509V3_R_NO_POLICY_IDENTIFIER                    139\n# define X509V3_R_NO_PROXY_CERT_POLICY_LANGUAGE_DEFINED   154\n# define X509V3_R_NO_PUBLIC_KEY                           114\n# define X509V3_R_NO_SUBJECT_DETAILS                      125\n# define X509V3_R_ODD_NUMBER_OF_DIGITS                    112\n# define X509V3_R_OPERATION_NOT_DEFINED                   148\n# define X509V3_R_OTHERNAME_ERROR                         147\n# define X509V3_R_POLICY_LANGUAGE_ALREADY_DEFINED         155\n# define X509V3_R_POLICY_PATH_LENGTH                      156\n# define X509V3_R_POLICY_PATH_LENGTH_ALREADY_DEFINED      157\n# define X509V3_R_POLICY_SYNTAX_NOT_CURRENTLY_SUPPORTED   158\n# define X509V3_R_POLICY_WHEN_PROXY_LANGUAGE_REQUIRES_NO_POLICY 159\n# define X509V3_R_SECTION_NOT_FOUND                       150\n# define X509V3_R_UNABLE_TO_GET_ISSUER_DETAILS            122\n# define X509V3_R_UNABLE_TO_GET_ISSUER_KEYID              123\n# define X509V3_R_UNKNOWN_BIT_STRING_ARGUMENT             111\n# define X509V3_R_UNKNOWN_EXTENSION                       129\n# define X509V3_R_UNKNOWN_EXTENSION_NAME                  130\n# define X509V3_R_UNKNOWN_OPTION                          120\n# define X509V3_R_UNSUPPORTED_OPTION                      117\n# define X509V3_R_UNSUPPORTED_TYPE                        167\n# define X509V3_R_USER_TOO_LONG                           132\n\n#ifdef  __cplusplus\n}\n#endif\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/arm64/include/openssl/aes.h",
    "content": "/* crypto/aes/aes.h */\n/* ====================================================================\n * Copyright (c) 1998-2002 The OpenSSL Project.  All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n *\n * 1. Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n *\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in\n *    the documentation and/or other materials provided with the\n *    distribution.\n *\n * 3. All advertising materials mentioning features or use of this\n *    software must display the following acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit. (http://www.openssl.org/)\"\n *\n * 4. The names \"OpenSSL Toolkit\" and \"OpenSSL Project\" must not be used to\n *    endorse or promote products derived from this software without\n *    prior written permission. For written permission, please contact\n *    openssl-core@openssl.org.\n *\n * 5. Products derived from this software may not be called \"OpenSSL\"\n *    nor may \"OpenSSL\" appear in their names without prior written\n *    permission of the OpenSSL Project.\n *\n * 6. Redistributions of any form whatsoever must retain the following\n *    acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit (http://www.openssl.org/)\"\n *\n * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY\n * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\n * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR\n * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\n * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,\n * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED\n * OF THE POSSIBILITY OF SUCH DAMAGE.\n * ====================================================================\n *\n */\n\n#ifndef HEADER_AES_H\n# define HEADER_AES_H\n\n# include <openssl/opensslconf.h>\n\n# ifdef OPENSSL_NO_AES\n#  error AES is disabled.\n# endif\n\n# include <stddef.h>\n\n# define AES_ENCRYPT     1\n# define AES_DECRYPT     0\n\n/*\n * Because array size can't be a const in C, the following two are macros.\n * Both sizes are in bytes.\n */\n# define AES_MAXNR 14\n# define AES_BLOCK_SIZE 16\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n/* This should be a hidden type, but EVP requires that the size be known */\nstruct aes_key_st {\n# ifdef AES_LONG\n    unsigned long rd_key[4 * (AES_MAXNR + 1)];\n# else\n    unsigned int rd_key[4 * (AES_MAXNR + 1)];\n# endif\n    int rounds;\n};\ntypedef struct aes_key_st AES_KEY;\n\nconst char *AES_options(void);\n\nint AES_set_encrypt_key(const unsigned char *userKey, const int bits,\n                        AES_KEY *key);\nint AES_set_decrypt_key(const unsigned char *userKey, const int bits,\n                        AES_KEY *key);\n\nint private_AES_set_encrypt_key(const unsigned char *userKey, const int bits,\n                                AES_KEY *key);\nint private_AES_set_decrypt_key(const unsigned char *userKey, const int bits,\n                                AES_KEY *key);\n\nvoid AES_encrypt(const unsigned char *in, unsigned char *out,\n                 const AES_KEY *key);\nvoid AES_decrypt(const unsigned char *in, unsigned char *out,\n                 const AES_KEY *key);\n\nvoid AES_ecb_encrypt(const unsigned char *in, unsigned char *out,\n                     const AES_KEY *key, const int enc);\nvoid AES_cbc_encrypt(const unsigned char *in, unsigned char *out,\n                     size_t length, const AES_KEY *key,\n                     unsigned char *ivec, const int enc);\nvoid AES_cfb128_encrypt(const unsigned char *in, unsigned char *out,\n                        size_t length, const AES_KEY *key,\n                        unsigned char *ivec, int *num, const int enc);\nvoid AES_cfb1_encrypt(const unsigned char *in, unsigned char *out,\n                      size_t length, const AES_KEY *key,\n                      unsigned char *ivec, int *num, const int enc);\nvoid AES_cfb8_encrypt(const unsigned char *in, unsigned char *out,\n                      size_t length, const AES_KEY *key,\n                      unsigned char *ivec, int *num, const int enc);\nvoid AES_ofb128_encrypt(const unsigned char *in, unsigned char *out,\n                        size_t length, const AES_KEY *key,\n                        unsigned char *ivec, int *num);\nvoid AES_ctr128_encrypt(const unsigned char *in, unsigned char *out,\n                        size_t length, const AES_KEY *key,\n                        unsigned char ivec[AES_BLOCK_SIZE],\n                        unsigned char ecount_buf[AES_BLOCK_SIZE],\n                        unsigned int *num);\n/* NB: the IV is _two_ blocks long */\nvoid AES_ige_encrypt(const unsigned char *in, unsigned char *out,\n                     size_t length, const AES_KEY *key,\n                     unsigned char *ivec, const int enc);\n/* NB: the IV is _four_ blocks long */\nvoid AES_bi_ige_encrypt(const unsigned char *in, unsigned char *out,\n                        size_t length, const AES_KEY *key,\n                        const AES_KEY *key2, const unsigned char *ivec,\n                        const int enc);\n\nint AES_wrap_key(AES_KEY *key, const unsigned char *iv,\n                 unsigned char *out,\n                 const unsigned char *in, unsigned int inlen);\nint AES_unwrap_key(AES_KEY *key, const unsigned char *iv,\n                   unsigned char *out,\n                   const unsigned char *in, unsigned int inlen);\n\n\n#ifdef  __cplusplus\n}\n#endif\n\n#endif                          /* !HEADER_AES_H */\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/arm64/include/openssl/asn1.h",
    "content": "/* crypto/asn1/asn1.h */\n/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)\n * All rights reserved.\n *\n * This package is an SSL implementation written\n * by Eric Young (eay@cryptsoft.com).\n * The implementation was written so as to conform with Netscapes SSL.\n *\n * This library is free for commercial and non-commercial use as long as\n * the following conditions are aheared to.  The following conditions\n * apply to all code found in this distribution, be it the RC4, RSA,\n * lhash, DES, etc., code; not just the SSL code.  The SSL documentation\n * included with this distribution is covered by the same copyright terms\n * except that the holder is Tim Hudson (tjh@cryptsoft.com).\n *\n * Copyright remains Eric Young's, and as such any Copyright notices in\n * the code are not to be removed.\n * If this package is used in a product, Eric Young should be given attribution\n * as the author of the parts of the library used.\n * This can be in the form of a textual message at program startup or\n * in documentation (online or textual) provided with the package.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the copyright\n *    notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in the\n *    documentation and/or other materials provided with the distribution.\n * 3. All advertising materials mentioning features or use of this software\n *    must display the following acknowledgement:\n *    \"This product includes cryptographic software written by\n *     Eric Young (eay@cryptsoft.com)\"\n *    The word 'cryptographic' can be left out if the rouines from the library\n *    being used are not cryptographic related :-).\n * 4. If you include any Windows specific code (or a derivative thereof) from\n *    the apps directory (application code) you must include an acknowledgement:\n *    \"This product includes software written by Tim Hudson (tjh@cryptsoft.com)\"\n *\n * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n * SUCH DAMAGE.\n *\n * The licence and distribution terms for any publically available version or\n * derivative of this code cannot be changed.  i.e. this code cannot simply be\n * copied and put under another distribution licence\n * [including the GNU Public Licence.]\n */\n\n#ifndef HEADER_ASN1_H\n# define HEADER_ASN1_H\n\n# include <time.h>\n# include <openssl/e_os2.h>\n# ifndef OPENSSL_NO_BIO\n#  include <openssl/bio.h>\n# endif\n# include <openssl/stack.h>\n# include <openssl/safestack.h>\n\n# include <openssl/symhacks.h>\n\n# include <openssl/ossl_typ.h>\n# ifndef OPENSSL_NO_DEPRECATED\n#  include <openssl/bn.h>\n# endif\n\n# ifdef OPENSSL_BUILD_SHLIBCRYPTO\n#  undef OPENSSL_EXTERN\n#  define OPENSSL_EXTERN OPENSSL_EXPORT\n# endif\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n# define V_ASN1_UNIVERSAL                0x00\n# define V_ASN1_APPLICATION              0x40\n# define V_ASN1_CONTEXT_SPECIFIC         0x80\n# define V_ASN1_PRIVATE                  0xc0\n\n# define V_ASN1_CONSTRUCTED              0x20\n# define V_ASN1_PRIMITIVE_TAG            0x1f\n# define V_ASN1_PRIMATIVE_TAG            0x1f\n\n# define V_ASN1_APP_CHOOSE               -2/* let the recipient choose */\n# define V_ASN1_OTHER                    -3/* used in ASN1_TYPE */\n# define V_ASN1_ANY                      -4/* used in ASN1 template code */\n\n# define V_ASN1_NEG                      0x100/* negative flag */\n\n# define V_ASN1_UNDEF                    -1\n# define V_ASN1_EOC                      0\n# define V_ASN1_BOOLEAN                  1 /**/\n# define V_ASN1_INTEGER                  2\n# define V_ASN1_NEG_INTEGER              (2 | V_ASN1_NEG)\n# define V_ASN1_BIT_STRING               3\n# define V_ASN1_OCTET_STRING             4\n# define V_ASN1_NULL                     5\n# define V_ASN1_OBJECT                   6\n# define V_ASN1_OBJECT_DESCRIPTOR        7\n# define V_ASN1_EXTERNAL                 8\n# define V_ASN1_REAL                     9\n# define V_ASN1_ENUMERATED               10\n# define V_ASN1_NEG_ENUMERATED           (10 | V_ASN1_NEG)\n# define V_ASN1_UTF8STRING               12\n# define V_ASN1_SEQUENCE                 16\n# define V_ASN1_SET                      17\n# define V_ASN1_NUMERICSTRING            18 /**/\n# define V_ASN1_PRINTABLESTRING          19\n# define V_ASN1_T61STRING                20\n# define V_ASN1_TELETEXSTRING            20/* alias */\n# define V_ASN1_VIDEOTEXSTRING           21 /**/\n# define V_ASN1_IA5STRING                22\n# define V_ASN1_UTCTIME                  23\n# define V_ASN1_GENERALIZEDTIME          24 /**/\n# define V_ASN1_GRAPHICSTRING            25 /**/\n# define V_ASN1_ISO64STRING              26 /**/\n# define V_ASN1_VISIBLESTRING            26/* alias */\n# define V_ASN1_GENERALSTRING            27 /**/\n# define V_ASN1_UNIVERSALSTRING          28 /**/\n# define V_ASN1_BMPSTRING                30\n/* For use with d2i_ASN1_type_bytes() */\n# define B_ASN1_NUMERICSTRING    0x0001\n# define B_ASN1_PRINTABLESTRING  0x0002\n# define B_ASN1_T61STRING        0x0004\n# define B_ASN1_TELETEXSTRING    0x0004\n# define B_ASN1_VIDEOTEXSTRING   0x0008\n# define B_ASN1_IA5STRING        0x0010\n# define B_ASN1_GRAPHICSTRING    0x0020\n# define B_ASN1_ISO64STRING      0x0040\n# define B_ASN1_VISIBLESTRING    0x0040\n# define B_ASN1_GENERALSTRING    0x0080\n# define B_ASN1_UNIVERSALSTRING  0x0100\n# define B_ASN1_OCTET_STRING     0x0200\n# define B_ASN1_BIT_STRING       0x0400\n# define B_ASN1_BMPSTRING        0x0800\n# define B_ASN1_UNKNOWN          0x1000\n# define B_ASN1_UTF8STRING       0x2000\n# define B_ASN1_UTCTIME          0x4000\n# define B_ASN1_GENERALIZEDTIME  0x8000\n# define B_ASN1_SEQUENCE         0x10000\n/* For use with ASN1_mbstring_copy() */\n# define MBSTRING_FLAG           0x1000\n# define MBSTRING_UTF8           (MBSTRING_FLAG)\n# define MBSTRING_ASC            (MBSTRING_FLAG|1)\n# define MBSTRING_BMP            (MBSTRING_FLAG|2)\n# define MBSTRING_UNIV           (MBSTRING_FLAG|4)\n# define SMIME_OLDMIME           0x400\n# define SMIME_CRLFEOL           0x800\n# define SMIME_STREAM            0x1000\n    struct X509_algor_st;\nDECLARE_STACK_OF(X509_ALGOR)\n\n# define DECLARE_ASN1_SET_OF(type)/* filled in by mkstack.pl */\n# define IMPLEMENT_ASN1_SET_OF(type)/* nothing, no longer needed */\n\n/*\n * We MUST make sure that, except for constness, asn1_ctx_st and\n * asn1_const_ctx are exactly the same.  Fortunately, as soon as the old ASN1\n * parsing macros are gone, we can throw this away as well...\n */\ntypedef struct asn1_ctx_st {\n    unsigned char *p;           /* work char pointer */\n    int eos;                    /* end of sequence read for indefinite\n                                 * encoding */\n    int error;                  /* error code to use when returning an error */\n    int inf;                    /* constructed if 0x20, indefinite is 0x21 */\n    int tag;                    /* tag from last 'get object' */\n    int xclass;                 /* class from last 'get object' */\n    long slen;                  /* length of last 'get object' */\n    unsigned char *max;         /* largest value of p allowed */\n    unsigned char *q;           /* temporary variable */\n    unsigned char **pp;         /* variable */\n    int line;                   /* used in error processing */\n} ASN1_CTX;\n\ntypedef struct asn1_const_ctx_st {\n    const unsigned char *p;     /* work char pointer */\n    int eos;                    /* end of sequence read for indefinite\n                                 * encoding */\n    int error;                  /* error code to use when returning an error */\n    int inf;                    /* constructed if 0x20, indefinite is 0x21 */\n    int tag;                    /* tag from last 'get object' */\n    int xclass;                 /* class from last 'get object' */\n    long slen;                  /* length of last 'get object' */\n    const unsigned char *max;   /* largest value of p allowed */\n    const unsigned char *q;     /* temporary variable */\n    const unsigned char **pp;   /* variable */\n    int line;                   /* used in error processing */\n} ASN1_const_CTX;\n\n/*\n * These are used internally in the ASN1_OBJECT to keep track of whether the\n * names and data need to be free()ed\n */\n# define ASN1_OBJECT_FLAG_DYNAMIC         0x01/* internal use */\n# define ASN1_OBJECT_FLAG_CRITICAL        0x02/* critical x509v3 object id */\n# define ASN1_OBJECT_FLAG_DYNAMIC_STRINGS 0x04/* internal use */\n# define ASN1_OBJECT_FLAG_DYNAMIC_DATA    0x08/* internal use */\nstruct asn1_object_st {\n    const char *sn, *ln;\n    int nid;\n    int length;\n    const unsigned char *data;  /* data remains const after init */\n    int flags;                  /* Should we free this one */\n};\n\n# define ASN1_STRING_FLAG_BITS_LEFT 0x08/* Set if 0x07 has bits left value */\n/*\n * This indicates that the ASN1_STRING is not a real value but just a place\n * holder for the location where indefinite length constructed data should be\n * inserted in the memory buffer\n */\n# define ASN1_STRING_FLAG_NDEF 0x010\n\n/*\n * This flag is used by the CMS code to indicate that a string is not\n * complete and is a place holder for content when it had all been accessed.\n * The flag will be reset when content has been written to it.\n */\n\n# define ASN1_STRING_FLAG_CONT 0x020\n/*\n * This flag is used by ASN1 code to indicate an ASN1_STRING is an MSTRING\n * type.\n */\n# define ASN1_STRING_FLAG_MSTRING 0x040\n/* This is the base type that holds just about everything :-) */\nstruct asn1_string_st {\n    int length;\n    int type;\n    unsigned char *data;\n    /*\n     * The value of the following field depends on the type being held.  It\n     * is mostly being used for BIT_STRING so if the input data has a\n     * non-zero 'unused bits' value, it will be handled correctly\n     */\n    long flags;\n};\n\n/*\n * ASN1_ENCODING structure: this is used to save the received encoding of an\n * ASN1 type. This is useful to get round problems with invalid encodings\n * which can break signatures.\n */\n\ntypedef struct ASN1_ENCODING_st {\n    unsigned char *enc;         /* DER encoding */\n    long len;                   /* Length of encoding */\n    int modified;               /* set to 1 if 'enc' is invalid */\n} ASN1_ENCODING;\n\n/* Used with ASN1 LONG type: if a long is set to this it is omitted */\n# define ASN1_LONG_UNDEF 0x7fffffffL\n\n# define STABLE_FLAGS_MALLOC     0x01\n# define STABLE_NO_MASK          0x02\n# define DIRSTRING_TYPE  \\\n (B_ASN1_PRINTABLESTRING|B_ASN1_T61STRING|B_ASN1_BMPSTRING|B_ASN1_UTF8STRING)\n# define PKCS9STRING_TYPE (DIRSTRING_TYPE|B_ASN1_IA5STRING)\n\ntypedef struct asn1_string_table_st {\n    int nid;\n    long minsize;\n    long maxsize;\n    unsigned long mask;\n    unsigned long flags;\n} ASN1_STRING_TABLE;\n\nDECLARE_STACK_OF(ASN1_STRING_TABLE)\n\n/* size limits: this stuff is taken straight from RFC2459 */\n\n# define ub_name                         32768\n# define ub_common_name                  64\n# define ub_locality_name                128\n# define ub_state_name                   128\n# define ub_organization_name            64\n# define ub_organization_unit_name       64\n# define ub_title                        64\n# define ub_email_address                128\n\n/*\n * Declarations for template structures: for full definitions see asn1t.h\n */\ntypedef struct ASN1_TEMPLATE_st ASN1_TEMPLATE;\ntypedef struct ASN1_TLC_st ASN1_TLC;\n/* This is just an opaque pointer */\ntypedef struct ASN1_VALUE_st ASN1_VALUE;\n\n/* Declare ASN1 functions: the implement macro in in asn1t.h */\n\n# define DECLARE_ASN1_FUNCTIONS(type) DECLARE_ASN1_FUNCTIONS_name(type, type)\n\n# define DECLARE_ASN1_ALLOC_FUNCTIONS(type) \\\n        DECLARE_ASN1_ALLOC_FUNCTIONS_name(type, type)\n\n# define DECLARE_ASN1_FUNCTIONS_name(type, name) \\\n        DECLARE_ASN1_ALLOC_FUNCTIONS_name(type, name) \\\n        DECLARE_ASN1_ENCODE_FUNCTIONS(type, name, name)\n\n# define DECLARE_ASN1_FUNCTIONS_fname(type, itname, name) \\\n        DECLARE_ASN1_ALLOC_FUNCTIONS_name(type, name) \\\n        DECLARE_ASN1_ENCODE_FUNCTIONS(type, itname, name)\n\n# define DECLARE_ASN1_ENCODE_FUNCTIONS(type, itname, name) \\\n        type *d2i_##name(type **a, const unsigned char **in, long len); \\\n        int i2d_##name(type *a, unsigned char **out); \\\n        DECLARE_ASN1_ITEM(itname)\n\n# define DECLARE_ASN1_ENCODE_FUNCTIONS_const(type, name) \\\n        type *d2i_##name(type **a, const unsigned char **in, long len); \\\n        int i2d_##name(const type *a, unsigned char **out); \\\n        DECLARE_ASN1_ITEM(name)\n\n# define DECLARE_ASN1_NDEF_FUNCTION(name) \\\n        int i2d_##name##_NDEF(name *a, unsigned char **out);\n\n# define DECLARE_ASN1_FUNCTIONS_const(name) \\\n        DECLARE_ASN1_ALLOC_FUNCTIONS(name) \\\n        DECLARE_ASN1_ENCODE_FUNCTIONS_const(name, name)\n\n# define DECLARE_ASN1_ALLOC_FUNCTIONS_name(type, name) \\\n        type *name##_new(void); \\\n        void name##_free(type *a);\n\n# define DECLARE_ASN1_PRINT_FUNCTION(stname) \\\n        DECLARE_ASN1_PRINT_FUNCTION_fname(stname, stname)\n\n# define DECLARE_ASN1_PRINT_FUNCTION_fname(stname, fname) \\\n        int fname##_print_ctx(BIO *out, stname *x, int indent, \\\n                                         const ASN1_PCTX *pctx);\n\n# define D2I_OF(type) type *(*)(type **,const unsigned char **,long)\n# define I2D_OF(type) int (*)(type *,unsigned char **)\n# define I2D_OF_const(type) int (*)(const type *,unsigned char **)\n\n# define CHECKED_D2I_OF(type, d2i) \\\n    ((d2i_of_void*) (1 ? d2i : ((D2I_OF(type))0)))\n# define CHECKED_I2D_OF(type, i2d) \\\n    ((i2d_of_void*) (1 ? i2d : ((I2D_OF(type))0)))\n# define CHECKED_NEW_OF(type, xnew) \\\n    ((void *(*)(void)) (1 ? xnew : ((type *(*)(void))0)))\n# define CHECKED_PTR_OF(type, p) \\\n    ((void*) (1 ? p : (type*)0))\n# define CHECKED_PPTR_OF(type, p) \\\n    ((void**) (1 ? p : (type**)0))\n\n# define TYPEDEF_D2I_OF(type) typedef type *d2i_of_##type(type **,const unsigned char **,long)\n# define TYPEDEF_I2D_OF(type) typedef int i2d_of_##type(type *,unsigned char **)\n# define TYPEDEF_D2I2D_OF(type) TYPEDEF_D2I_OF(type); TYPEDEF_I2D_OF(type)\n\nTYPEDEF_D2I2D_OF(void);\n\n/*-\n * The following macros and typedefs allow an ASN1_ITEM\n * to be embedded in a structure and referenced. Since\n * the ASN1_ITEM pointers need to be globally accessible\n * (possibly from shared libraries) they may exist in\n * different forms. On platforms that support it the\n * ASN1_ITEM structure itself will be globally exported.\n * Other platforms will export a function that returns\n * an ASN1_ITEM pointer.\n *\n * To handle both cases transparently the macros below\n * should be used instead of hard coding an ASN1_ITEM\n * pointer in a structure.\n *\n * The structure will look like this:\n *\n * typedef struct SOMETHING_st {\n *      ...\n *      ASN1_ITEM_EXP *iptr;\n *      ...\n * } SOMETHING;\n *\n * It would be initialised as e.g.:\n *\n * SOMETHING somevar = {...,ASN1_ITEM_ref(X509),...};\n *\n * and the actual pointer extracted with:\n *\n * const ASN1_ITEM *it = ASN1_ITEM_ptr(somevar.iptr);\n *\n * Finally an ASN1_ITEM pointer can be extracted from an\n * appropriate reference with: ASN1_ITEM_rptr(X509). This\n * would be used when a function takes an ASN1_ITEM * argument.\n *\n */\n\n# ifndef OPENSSL_EXPORT_VAR_AS_FUNCTION\n\n/* ASN1_ITEM pointer exported type */\ntypedef const ASN1_ITEM ASN1_ITEM_EXP;\n\n/* Macro to obtain ASN1_ITEM pointer from exported type */\n#  define ASN1_ITEM_ptr(iptr) (iptr)\n\n/* Macro to include ASN1_ITEM pointer from base type */\n#  define ASN1_ITEM_ref(iptr) (&(iptr##_it))\n\n#  define ASN1_ITEM_rptr(ref) (&(ref##_it))\n\n#  define DECLARE_ASN1_ITEM(name) \\\n        OPENSSL_EXTERN const ASN1_ITEM name##_it;\n\n# else\n\n/*\n * Platforms that can't easily handle shared global variables are declared as\n * functions returning ASN1_ITEM pointers.\n */\n\n/* ASN1_ITEM pointer exported type */\ntypedef const ASN1_ITEM *ASN1_ITEM_EXP (void);\n\n/* Macro to obtain ASN1_ITEM pointer from exported type */\n#  define ASN1_ITEM_ptr(iptr) (iptr())\n\n/* Macro to include ASN1_ITEM pointer from base type */\n#  define ASN1_ITEM_ref(iptr) (iptr##_it)\n\n#  define ASN1_ITEM_rptr(ref) (ref##_it())\n\n#  define DECLARE_ASN1_ITEM(name) \\\n        const ASN1_ITEM * name##_it(void);\n\n# endif\n\n/* Parameters used by ASN1_STRING_print_ex() */\n\n/*\n * These determine which characters to escape: RFC2253 special characters,\n * control characters and MSB set characters\n */\n\n# define ASN1_STRFLGS_ESC_2253           1\n# define ASN1_STRFLGS_ESC_CTRL           2\n# define ASN1_STRFLGS_ESC_MSB            4\n\n/*\n * This flag determines how we do escaping: normally RC2253 backslash only,\n * set this to use backslash and quote.\n */\n\n# define ASN1_STRFLGS_ESC_QUOTE          8\n\n/* These three flags are internal use only. */\n\n/* Character is a valid PrintableString character */\n# define CHARTYPE_PRINTABLESTRING        0x10\n/* Character needs escaping if it is the first character */\n# define CHARTYPE_FIRST_ESC_2253         0x20\n/* Character needs escaping if it is the last character */\n# define CHARTYPE_LAST_ESC_2253          0x40\n\n/*\n * NB the internal flags are safely reused below by flags handled at the top\n * level.\n */\n\n/*\n * If this is set we convert all character strings to UTF8 first\n */\n\n# define ASN1_STRFLGS_UTF8_CONVERT       0x10\n\n/*\n * If this is set we don't attempt to interpret content: just assume all\n * strings are 1 byte per character. This will produce some pretty odd\n * looking output!\n */\n\n# define ASN1_STRFLGS_IGNORE_TYPE        0x20\n\n/* If this is set we include the string type in the output */\n# define ASN1_STRFLGS_SHOW_TYPE          0x40\n\n/*\n * This determines which strings to display and which to 'dump' (hex dump of\n * content octets or DER encoding). We can only dump non character strings or\n * everything. If we don't dump 'unknown' they are interpreted as character\n * strings with 1 octet per character and are subject to the usual escaping\n * options.\n */\n\n# define ASN1_STRFLGS_DUMP_ALL           0x80\n# define ASN1_STRFLGS_DUMP_UNKNOWN       0x100\n\n/*\n * These determine what 'dumping' does, we can dump the content octets or the\n * DER encoding: both use the RFC2253 #XXXXX notation.\n */\n\n# define ASN1_STRFLGS_DUMP_DER           0x200\n\n/*\n * All the string flags consistent with RFC2253, escaping control characters\n * isn't essential in RFC2253 but it is advisable anyway.\n */\n\n# define ASN1_STRFLGS_RFC2253    (ASN1_STRFLGS_ESC_2253 | \\\n                                ASN1_STRFLGS_ESC_CTRL | \\\n                                ASN1_STRFLGS_ESC_MSB | \\\n                                ASN1_STRFLGS_UTF8_CONVERT | \\\n                                ASN1_STRFLGS_DUMP_UNKNOWN | \\\n                                ASN1_STRFLGS_DUMP_DER)\n\nDECLARE_STACK_OF(ASN1_INTEGER)\nDECLARE_ASN1_SET_OF(ASN1_INTEGER)\n\nDECLARE_STACK_OF(ASN1_GENERALSTRING)\n\ntypedef struct asn1_type_st {\n    int type;\n    union {\n        char *ptr;\n        ASN1_BOOLEAN boolean;\n        ASN1_STRING *asn1_string;\n        ASN1_OBJECT *object;\n        ASN1_INTEGER *integer;\n        ASN1_ENUMERATED *enumerated;\n        ASN1_BIT_STRING *bit_string;\n        ASN1_OCTET_STRING *octet_string;\n        ASN1_PRINTABLESTRING *printablestring;\n        ASN1_T61STRING *t61string;\n        ASN1_IA5STRING *ia5string;\n        ASN1_GENERALSTRING *generalstring;\n        ASN1_BMPSTRING *bmpstring;\n        ASN1_UNIVERSALSTRING *universalstring;\n        ASN1_UTCTIME *utctime;\n        ASN1_GENERALIZEDTIME *generalizedtime;\n        ASN1_VISIBLESTRING *visiblestring;\n        ASN1_UTF8STRING *utf8string;\n        /*\n         * set and sequence are left complete and still contain the set or\n         * sequence bytes\n         */\n        ASN1_STRING *set;\n        ASN1_STRING *sequence;\n        ASN1_VALUE *asn1_value;\n    } value;\n} ASN1_TYPE;\n\nDECLARE_STACK_OF(ASN1_TYPE)\nDECLARE_ASN1_SET_OF(ASN1_TYPE)\n\ntypedef STACK_OF(ASN1_TYPE) ASN1_SEQUENCE_ANY;\n\nDECLARE_ASN1_ENCODE_FUNCTIONS_const(ASN1_SEQUENCE_ANY, ASN1_SEQUENCE_ANY)\nDECLARE_ASN1_ENCODE_FUNCTIONS_const(ASN1_SEQUENCE_ANY, ASN1_SET_ANY)\n\ntypedef struct NETSCAPE_X509_st {\n    ASN1_OCTET_STRING *header;\n    X509 *cert;\n} NETSCAPE_X509;\n\n/* This is used to contain a list of bit names */\ntypedef struct BIT_STRING_BITNAME_st {\n    int bitnum;\n    const char *lname;\n    const char *sname;\n} BIT_STRING_BITNAME;\n\n# define M_ASN1_STRING_length(x) ((x)->length)\n# define M_ASN1_STRING_length_set(x, n)  ((x)->length = (n))\n# define M_ASN1_STRING_type(x)   ((x)->type)\n# define M_ASN1_STRING_data(x)   ((x)->data)\n\n/* Macros for string operations */\n# define M_ASN1_BIT_STRING_new() (ASN1_BIT_STRING *)\\\n                ASN1_STRING_type_new(V_ASN1_BIT_STRING)\n# define M_ASN1_BIT_STRING_free(a)       ASN1_STRING_free((ASN1_STRING *)a)\n# define M_ASN1_BIT_STRING_dup(a) (ASN1_BIT_STRING *)\\\n                ASN1_STRING_dup((const ASN1_STRING *)a)\n# define M_ASN1_BIT_STRING_cmp(a,b) ASN1_STRING_cmp(\\\n                (const ASN1_STRING *)a,(const ASN1_STRING *)b)\n# define M_ASN1_BIT_STRING_set(a,b,c) ASN1_STRING_set((ASN1_STRING *)a,b,c)\n\n# define M_ASN1_INTEGER_new()    (ASN1_INTEGER *)\\\n                ASN1_STRING_type_new(V_ASN1_INTEGER)\n# define M_ASN1_INTEGER_free(a)          ASN1_STRING_free((ASN1_STRING *)a)\n# define M_ASN1_INTEGER_dup(a) (ASN1_INTEGER *)\\\n                ASN1_STRING_dup((const ASN1_STRING *)a)\n# define M_ASN1_INTEGER_cmp(a,b) ASN1_STRING_cmp(\\\n                (const ASN1_STRING *)a,(const ASN1_STRING *)b)\n\n# define M_ASN1_ENUMERATED_new() (ASN1_ENUMERATED *)\\\n                ASN1_STRING_type_new(V_ASN1_ENUMERATED)\n# define M_ASN1_ENUMERATED_free(a)       ASN1_STRING_free((ASN1_STRING *)a)\n# define M_ASN1_ENUMERATED_dup(a) (ASN1_ENUMERATED *)\\\n                ASN1_STRING_dup((const ASN1_STRING *)a)\n# define M_ASN1_ENUMERATED_cmp(a,b)      ASN1_STRING_cmp(\\\n                (const ASN1_STRING *)a,(const ASN1_STRING *)b)\n\n# define M_ASN1_OCTET_STRING_new()       (ASN1_OCTET_STRING *)\\\n                ASN1_STRING_type_new(V_ASN1_OCTET_STRING)\n# define M_ASN1_OCTET_STRING_free(a)     ASN1_STRING_free((ASN1_STRING *)a)\n# define M_ASN1_OCTET_STRING_dup(a) (ASN1_OCTET_STRING *)\\\n                ASN1_STRING_dup((const ASN1_STRING *)a)\n# define M_ASN1_OCTET_STRING_cmp(a,b) ASN1_STRING_cmp(\\\n                (const ASN1_STRING *)a,(const ASN1_STRING *)b)\n# define M_ASN1_OCTET_STRING_set(a,b,c)  ASN1_STRING_set((ASN1_STRING *)a,b,c)\n# define M_ASN1_OCTET_STRING_print(a,b)  ASN1_STRING_print(a,(ASN1_STRING *)b)\n# define M_i2d_ASN1_OCTET_STRING(a,pp) \\\n                i2d_ASN1_bytes((ASN1_STRING *)a,pp,V_ASN1_OCTET_STRING,\\\n                V_ASN1_UNIVERSAL)\n\n# define B_ASN1_TIME \\\n                        B_ASN1_UTCTIME | \\\n                        B_ASN1_GENERALIZEDTIME\n\n# define B_ASN1_PRINTABLE \\\n                        B_ASN1_NUMERICSTRING| \\\n                        B_ASN1_PRINTABLESTRING| \\\n                        B_ASN1_T61STRING| \\\n                        B_ASN1_IA5STRING| \\\n                        B_ASN1_BIT_STRING| \\\n                        B_ASN1_UNIVERSALSTRING|\\\n                        B_ASN1_BMPSTRING|\\\n                        B_ASN1_UTF8STRING|\\\n                        B_ASN1_SEQUENCE|\\\n                        B_ASN1_UNKNOWN\n\n# define B_ASN1_DIRECTORYSTRING \\\n                        B_ASN1_PRINTABLESTRING| \\\n                        B_ASN1_TELETEXSTRING|\\\n                        B_ASN1_BMPSTRING|\\\n                        B_ASN1_UNIVERSALSTRING|\\\n                        B_ASN1_UTF8STRING\n\n# define B_ASN1_DISPLAYTEXT \\\n                        B_ASN1_IA5STRING| \\\n                        B_ASN1_VISIBLESTRING| \\\n                        B_ASN1_BMPSTRING|\\\n                        B_ASN1_UTF8STRING\n\n# define M_ASN1_PRINTABLE_new()  ASN1_STRING_type_new(V_ASN1_T61STRING)\n# define M_ASN1_PRINTABLE_free(a)        ASN1_STRING_free((ASN1_STRING *)a)\n# define M_i2d_ASN1_PRINTABLE(a,pp) i2d_ASN1_bytes((ASN1_STRING *)a,\\\n                pp,a->type,V_ASN1_UNIVERSAL)\n# define M_d2i_ASN1_PRINTABLE(a,pp,l) \\\n                d2i_ASN1_type_bytes((ASN1_STRING **)a,pp,l, \\\n                        B_ASN1_PRINTABLE)\n\n# define M_DIRECTORYSTRING_new() ASN1_STRING_type_new(V_ASN1_PRINTABLESTRING)\n# define M_DIRECTORYSTRING_free(a)       ASN1_STRING_free((ASN1_STRING *)a)\n# define M_i2d_DIRECTORYSTRING(a,pp) i2d_ASN1_bytes((ASN1_STRING *)a,\\\n                                                pp,a->type,V_ASN1_UNIVERSAL)\n# define M_d2i_DIRECTORYSTRING(a,pp,l) \\\n                d2i_ASN1_type_bytes((ASN1_STRING **)a,pp,l, \\\n                        B_ASN1_DIRECTORYSTRING)\n\n# define M_DISPLAYTEXT_new() ASN1_STRING_type_new(V_ASN1_VISIBLESTRING)\n# define M_DISPLAYTEXT_free(a) ASN1_STRING_free((ASN1_STRING *)a)\n# define M_i2d_DISPLAYTEXT(a,pp) i2d_ASN1_bytes((ASN1_STRING *)a,\\\n                                                pp,a->type,V_ASN1_UNIVERSAL)\n# define M_d2i_DISPLAYTEXT(a,pp,l) \\\n                d2i_ASN1_type_bytes((ASN1_STRING **)a,pp,l, \\\n                        B_ASN1_DISPLAYTEXT)\n\n# define M_ASN1_PRINTABLESTRING_new() (ASN1_PRINTABLESTRING *)\\\n                ASN1_STRING_type_new(V_ASN1_PRINTABLESTRING)\n# define M_ASN1_PRINTABLESTRING_free(a)  ASN1_STRING_free((ASN1_STRING *)a)\n# define M_i2d_ASN1_PRINTABLESTRING(a,pp) \\\n                i2d_ASN1_bytes((ASN1_STRING *)a,pp,V_ASN1_PRINTABLESTRING,\\\n                V_ASN1_UNIVERSAL)\n# define M_d2i_ASN1_PRINTABLESTRING(a,pp,l) \\\n                (ASN1_PRINTABLESTRING *)d2i_ASN1_type_bytes\\\n                ((ASN1_STRING **)a,pp,l,B_ASN1_PRINTABLESTRING)\n\n# define M_ASN1_T61STRING_new()  (ASN1_T61STRING *)\\\n                ASN1_STRING_type_new(V_ASN1_T61STRING)\n# define M_ASN1_T61STRING_free(a)        ASN1_STRING_free((ASN1_STRING *)a)\n# define M_i2d_ASN1_T61STRING(a,pp) \\\n                i2d_ASN1_bytes((ASN1_STRING *)a,pp,V_ASN1_T61STRING,\\\n                V_ASN1_UNIVERSAL)\n# define M_d2i_ASN1_T61STRING(a,pp,l) \\\n                (ASN1_T61STRING *)d2i_ASN1_type_bytes\\\n                ((ASN1_STRING **)a,pp,l,B_ASN1_T61STRING)\n\n# define M_ASN1_IA5STRING_new()  (ASN1_IA5STRING *)\\\n                ASN1_STRING_type_new(V_ASN1_IA5STRING)\n# define M_ASN1_IA5STRING_free(a)        ASN1_STRING_free((ASN1_STRING *)a)\n# define M_ASN1_IA5STRING_dup(a) \\\n                (ASN1_IA5STRING *)ASN1_STRING_dup((const ASN1_STRING *)a)\n# define M_i2d_ASN1_IA5STRING(a,pp) \\\n                i2d_ASN1_bytes((ASN1_STRING *)a,pp,V_ASN1_IA5STRING,\\\n                        V_ASN1_UNIVERSAL)\n# define M_d2i_ASN1_IA5STRING(a,pp,l) \\\n                (ASN1_IA5STRING *)d2i_ASN1_type_bytes((ASN1_STRING **)a,pp,l,\\\n                        B_ASN1_IA5STRING)\n\n# define M_ASN1_UTCTIME_new()    (ASN1_UTCTIME *)\\\n                ASN1_STRING_type_new(V_ASN1_UTCTIME)\n# define M_ASN1_UTCTIME_free(a)  ASN1_STRING_free((ASN1_STRING *)a)\n# define M_ASN1_UTCTIME_dup(a) (ASN1_UTCTIME *)\\\n                ASN1_STRING_dup((const ASN1_STRING *)a)\n\n# define M_ASN1_GENERALIZEDTIME_new()    (ASN1_GENERALIZEDTIME *)\\\n                ASN1_STRING_type_new(V_ASN1_GENERALIZEDTIME)\n# define M_ASN1_GENERALIZEDTIME_free(a)  ASN1_STRING_free((ASN1_STRING *)a)\n# define M_ASN1_GENERALIZEDTIME_dup(a) (ASN1_GENERALIZEDTIME *)ASN1_STRING_dup(\\\n        (const ASN1_STRING *)a)\n\n# define M_ASN1_TIME_new()       (ASN1_TIME *)\\\n                ASN1_STRING_type_new(V_ASN1_UTCTIME)\n# define M_ASN1_TIME_free(a)     ASN1_STRING_free((ASN1_STRING *)a)\n# define M_ASN1_TIME_dup(a) (ASN1_TIME *)\\\n        ASN1_STRING_dup((const ASN1_STRING *)a)\n\n# define M_ASN1_GENERALSTRING_new()      (ASN1_GENERALSTRING *)\\\n                ASN1_STRING_type_new(V_ASN1_GENERALSTRING)\n# define M_ASN1_GENERALSTRING_free(a)    ASN1_STRING_free((ASN1_STRING *)a)\n# define M_i2d_ASN1_GENERALSTRING(a,pp) \\\n                i2d_ASN1_bytes((ASN1_STRING *)a,pp,V_ASN1_GENERALSTRING,\\\n                        V_ASN1_UNIVERSAL)\n# define M_d2i_ASN1_GENERALSTRING(a,pp,l) \\\n                (ASN1_GENERALSTRING *)d2i_ASN1_type_bytes\\\n                ((ASN1_STRING **)a,pp,l,B_ASN1_GENERALSTRING)\n\n# define M_ASN1_UNIVERSALSTRING_new()    (ASN1_UNIVERSALSTRING *)\\\n                ASN1_STRING_type_new(V_ASN1_UNIVERSALSTRING)\n# define M_ASN1_UNIVERSALSTRING_free(a)  ASN1_STRING_free((ASN1_STRING *)a)\n# define M_i2d_ASN1_UNIVERSALSTRING(a,pp) \\\n                i2d_ASN1_bytes((ASN1_STRING *)a,pp,V_ASN1_UNIVERSALSTRING,\\\n                        V_ASN1_UNIVERSAL)\n# define M_d2i_ASN1_UNIVERSALSTRING(a,pp,l) \\\n                (ASN1_UNIVERSALSTRING *)d2i_ASN1_type_bytes\\\n                ((ASN1_STRING **)a,pp,l,B_ASN1_UNIVERSALSTRING)\n\n# define M_ASN1_BMPSTRING_new()  (ASN1_BMPSTRING *)\\\n                ASN1_STRING_type_new(V_ASN1_BMPSTRING)\n# define M_ASN1_BMPSTRING_free(a)        ASN1_STRING_free((ASN1_STRING *)a)\n# define M_i2d_ASN1_BMPSTRING(a,pp) \\\n                i2d_ASN1_bytes((ASN1_STRING *)a,pp,V_ASN1_BMPSTRING,\\\n                        V_ASN1_UNIVERSAL)\n# define M_d2i_ASN1_BMPSTRING(a,pp,l) \\\n                (ASN1_BMPSTRING *)d2i_ASN1_type_bytes\\\n                ((ASN1_STRING **)a,pp,l,B_ASN1_BMPSTRING)\n\n# define M_ASN1_VISIBLESTRING_new()      (ASN1_VISIBLESTRING *)\\\n                ASN1_STRING_type_new(V_ASN1_VISIBLESTRING)\n# define M_ASN1_VISIBLESTRING_free(a)    ASN1_STRING_free((ASN1_STRING *)a)\n# define M_i2d_ASN1_VISIBLESTRING(a,pp) \\\n                i2d_ASN1_bytes((ASN1_STRING *)a,pp,V_ASN1_VISIBLESTRING,\\\n                        V_ASN1_UNIVERSAL)\n# define M_d2i_ASN1_VISIBLESTRING(a,pp,l) \\\n                (ASN1_VISIBLESTRING *)d2i_ASN1_type_bytes\\\n                ((ASN1_STRING **)a,pp,l,B_ASN1_VISIBLESTRING)\n\n# define M_ASN1_UTF8STRING_new() (ASN1_UTF8STRING *)\\\n                ASN1_STRING_type_new(V_ASN1_UTF8STRING)\n# define M_ASN1_UTF8STRING_free(a)       ASN1_STRING_free((ASN1_STRING *)a)\n# define M_i2d_ASN1_UTF8STRING(a,pp) \\\n                i2d_ASN1_bytes((ASN1_STRING *)a,pp,V_ASN1_UTF8STRING,\\\n                        V_ASN1_UNIVERSAL)\n# define M_d2i_ASN1_UTF8STRING(a,pp,l) \\\n                (ASN1_UTF8STRING *)d2i_ASN1_type_bytes\\\n                ((ASN1_STRING **)a,pp,l,B_ASN1_UTF8STRING)\n\n  /* for the is_set parameter to i2d_ASN1_SET */\n# define IS_SEQUENCE     0\n# define IS_SET          1\n\nDECLARE_ASN1_FUNCTIONS_fname(ASN1_TYPE, ASN1_ANY, ASN1_TYPE)\n\nint ASN1_TYPE_get(ASN1_TYPE *a);\nvoid ASN1_TYPE_set(ASN1_TYPE *a, int type, void *value);\nint ASN1_TYPE_set1(ASN1_TYPE *a, int type, const void *value);\nint ASN1_TYPE_cmp(const ASN1_TYPE *a, const ASN1_TYPE *b);\n\nASN1_OBJECT *ASN1_OBJECT_new(void);\nvoid ASN1_OBJECT_free(ASN1_OBJECT *a);\nint i2d_ASN1_OBJECT(ASN1_OBJECT *a, unsigned char **pp);\nASN1_OBJECT *c2i_ASN1_OBJECT(ASN1_OBJECT **a, const unsigned char **pp,\n                             long length);\nASN1_OBJECT *d2i_ASN1_OBJECT(ASN1_OBJECT **a, const unsigned char **pp,\n                             long length);\n\nDECLARE_ASN1_ITEM(ASN1_OBJECT)\n\nDECLARE_STACK_OF(ASN1_OBJECT)\nDECLARE_ASN1_SET_OF(ASN1_OBJECT)\n\nASN1_STRING *ASN1_STRING_new(void);\nvoid ASN1_STRING_free(ASN1_STRING *a);\nvoid ASN1_STRING_clear_free(ASN1_STRING *a);\nint ASN1_STRING_copy(ASN1_STRING *dst, const ASN1_STRING *str);\nASN1_STRING *ASN1_STRING_dup(const ASN1_STRING *a);\nASN1_STRING *ASN1_STRING_type_new(int type);\nint ASN1_STRING_cmp(const ASN1_STRING *a, const ASN1_STRING *b);\n  /*\n   * Since this is used to store all sorts of things, via macros, for now,\n   * make its data void *\n   */\nint ASN1_STRING_set(ASN1_STRING *str, const void *data, int len);\nvoid ASN1_STRING_set0(ASN1_STRING *str, void *data, int len);\nint ASN1_STRING_length(const ASN1_STRING *x);\nvoid ASN1_STRING_length_set(ASN1_STRING *x, int n);\nint ASN1_STRING_type(ASN1_STRING *x);\nunsigned char *ASN1_STRING_data(ASN1_STRING *x);\n\nDECLARE_ASN1_FUNCTIONS(ASN1_BIT_STRING)\nint i2c_ASN1_BIT_STRING(ASN1_BIT_STRING *a, unsigned char **pp);\nASN1_BIT_STRING *c2i_ASN1_BIT_STRING(ASN1_BIT_STRING **a,\n                                     const unsigned char **pp, long length);\nint ASN1_BIT_STRING_set(ASN1_BIT_STRING *a, unsigned char *d, int length);\nint ASN1_BIT_STRING_set_bit(ASN1_BIT_STRING *a, int n, int value);\nint ASN1_BIT_STRING_get_bit(ASN1_BIT_STRING *a, int n);\nint ASN1_BIT_STRING_check(ASN1_BIT_STRING *a,\n                          unsigned char *flags, int flags_len);\n\n# ifndef OPENSSL_NO_BIO\nint ASN1_BIT_STRING_name_print(BIO *out, ASN1_BIT_STRING *bs,\n                               BIT_STRING_BITNAME *tbl, int indent);\n# endif\nint ASN1_BIT_STRING_num_asc(char *name, BIT_STRING_BITNAME *tbl);\nint ASN1_BIT_STRING_set_asc(ASN1_BIT_STRING *bs, char *name, int value,\n                            BIT_STRING_BITNAME *tbl);\n\nint i2d_ASN1_BOOLEAN(int a, unsigned char **pp);\nint d2i_ASN1_BOOLEAN(int *a, const unsigned char **pp, long length);\n\nDECLARE_ASN1_FUNCTIONS(ASN1_INTEGER)\nint i2c_ASN1_INTEGER(ASN1_INTEGER *a, unsigned char **pp);\nASN1_INTEGER *c2i_ASN1_INTEGER(ASN1_INTEGER **a, const unsigned char **pp,\n                               long length);\nASN1_INTEGER *d2i_ASN1_UINTEGER(ASN1_INTEGER **a, const unsigned char **pp,\n                                long length);\nASN1_INTEGER *ASN1_INTEGER_dup(const ASN1_INTEGER *x);\nint ASN1_INTEGER_cmp(const ASN1_INTEGER *x, const ASN1_INTEGER *y);\n\nDECLARE_ASN1_FUNCTIONS(ASN1_ENUMERATED)\n\nint ASN1_UTCTIME_check(const ASN1_UTCTIME *a);\nASN1_UTCTIME *ASN1_UTCTIME_set(ASN1_UTCTIME *s, time_t t);\nASN1_UTCTIME *ASN1_UTCTIME_adj(ASN1_UTCTIME *s, time_t t,\n                               int offset_day, long offset_sec);\nint ASN1_UTCTIME_set_string(ASN1_UTCTIME *s, const char *str);\nint ASN1_UTCTIME_cmp_time_t(const ASN1_UTCTIME *s, time_t t);\n# if 0\ntime_t ASN1_UTCTIME_get(const ASN1_UTCTIME *s);\n# endif\n\nint ASN1_GENERALIZEDTIME_check(const ASN1_GENERALIZEDTIME *a);\nASN1_GENERALIZEDTIME *ASN1_GENERALIZEDTIME_set(ASN1_GENERALIZEDTIME *s,\n                                               time_t t);\nASN1_GENERALIZEDTIME *ASN1_GENERALIZEDTIME_adj(ASN1_GENERALIZEDTIME *s,\n                                               time_t t, int offset_day,\n                                               long offset_sec);\nint ASN1_GENERALIZEDTIME_set_string(ASN1_GENERALIZEDTIME *s, const char *str);\nint ASN1_TIME_diff(int *pday, int *psec,\n                   const ASN1_TIME *from, const ASN1_TIME *to);\n\nDECLARE_ASN1_FUNCTIONS(ASN1_OCTET_STRING)\nASN1_OCTET_STRING *ASN1_OCTET_STRING_dup(const ASN1_OCTET_STRING *a);\nint ASN1_OCTET_STRING_cmp(const ASN1_OCTET_STRING *a,\n                          const ASN1_OCTET_STRING *b);\nint ASN1_OCTET_STRING_set(ASN1_OCTET_STRING *str, const unsigned char *data,\n                          int len);\n\nDECLARE_ASN1_FUNCTIONS(ASN1_VISIBLESTRING)\nDECLARE_ASN1_FUNCTIONS(ASN1_UNIVERSALSTRING)\nDECLARE_ASN1_FUNCTIONS(ASN1_UTF8STRING)\nDECLARE_ASN1_FUNCTIONS(ASN1_NULL)\nDECLARE_ASN1_FUNCTIONS(ASN1_BMPSTRING)\n\nint UTF8_getc(const unsigned char *str, int len, unsigned long *val);\nint UTF8_putc(unsigned char *str, int len, unsigned long value);\n\nDECLARE_ASN1_FUNCTIONS_name(ASN1_STRING, ASN1_PRINTABLE)\n\nDECLARE_ASN1_FUNCTIONS_name(ASN1_STRING, DIRECTORYSTRING)\nDECLARE_ASN1_FUNCTIONS_name(ASN1_STRING, DISPLAYTEXT)\nDECLARE_ASN1_FUNCTIONS(ASN1_PRINTABLESTRING)\nDECLARE_ASN1_FUNCTIONS(ASN1_T61STRING)\nDECLARE_ASN1_FUNCTIONS(ASN1_IA5STRING)\nDECLARE_ASN1_FUNCTIONS(ASN1_GENERALSTRING)\nDECLARE_ASN1_FUNCTIONS(ASN1_UTCTIME)\nDECLARE_ASN1_FUNCTIONS(ASN1_GENERALIZEDTIME)\nDECLARE_ASN1_FUNCTIONS(ASN1_TIME)\n\nDECLARE_ASN1_ITEM(ASN1_OCTET_STRING_NDEF)\n\nASN1_TIME *ASN1_TIME_set(ASN1_TIME *s, time_t t);\nASN1_TIME *ASN1_TIME_adj(ASN1_TIME *s, time_t t,\n                         int offset_day, long offset_sec);\nint ASN1_TIME_check(ASN1_TIME *t);\nASN1_GENERALIZEDTIME *ASN1_TIME_to_generalizedtime(ASN1_TIME *t, ASN1_GENERALIZEDTIME\n                                                   **out);\nint ASN1_TIME_set_string(ASN1_TIME *s, const char *str);\n\nint i2d_ASN1_SET(STACK_OF(OPENSSL_BLOCK) *a, unsigned char **pp,\n                 i2d_of_void *i2d, int ex_tag, int ex_class, int is_set);\nSTACK_OF(OPENSSL_BLOCK) *d2i_ASN1_SET(STACK_OF(OPENSSL_BLOCK) **a,\n                                      const unsigned char **pp,\n                                      long length, d2i_of_void *d2i,\n                                      void (*free_func) (OPENSSL_BLOCK),\n                                      int ex_tag, int ex_class);\n\n# ifndef OPENSSL_NO_BIO\nint i2a_ASN1_INTEGER(BIO *bp, ASN1_INTEGER *a);\nint a2i_ASN1_INTEGER(BIO *bp, ASN1_INTEGER *bs, char *buf, int size);\nint i2a_ASN1_ENUMERATED(BIO *bp, ASN1_ENUMERATED *a);\nint a2i_ASN1_ENUMERATED(BIO *bp, ASN1_ENUMERATED *bs, char *buf, int size);\nint i2a_ASN1_OBJECT(BIO *bp, ASN1_OBJECT *a);\nint a2i_ASN1_STRING(BIO *bp, ASN1_STRING *bs, char *buf, int size);\nint i2a_ASN1_STRING(BIO *bp, ASN1_STRING *a, int type);\n# endif\nint i2t_ASN1_OBJECT(char *buf, int buf_len, ASN1_OBJECT *a);\n\nint a2d_ASN1_OBJECT(unsigned char *out, int olen, const char *buf, int num);\nASN1_OBJECT *ASN1_OBJECT_create(int nid, unsigned char *data, int len,\n                                const char *sn, const char *ln);\n\nint ASN1_INTEGER_set(ASN1_INTEGER *a, long v);\nlong ASN1_INTEGER_get(const ASN1_INTEGER *a);\nASN1_INTEGER *BN_to_ASN1_INTEGER(const BIGNUM *bn, ASN1_INTEGER *ai);\nBIGNUM *ASN1_INTEGER_to_BN(const ASN1_INTEGER *ai, BIGNUM *bn);\n\nint ASN1_ENUMERATED_set(ASN1_ENUMERATED *a, long v);\nlong ASN1_ENUMERATED_get(ASN1_ENUMERATED *a);\nASN1_ENUMERATED *BN_to_ASN1_ENUMERATED(BIGNUM *bn, ASN1_ENUMERATED *ai);\nBIGNUM *ASN1_ENUMERATED_to_BN(ASN1_ENUMERATED *ai, BIGNUM *bn);\n\n/* General */\n/* given a string, return the correct type, max is the maximum length */\nint ASN1_PRINTABLE_type(const unsigned char *s, int max);\n\nint i2d_ASN1_bytes(ASN1_STRING *a, unsigned char **pp, int tag, int xclass);\nASN1_STRING *d2i_ASN1_bytes(ASN1_STRING **a, const unsigned char **pp,\n                            long length, int Ptag, int Pclass);\nunsigned long ASN1_tag2bit(int tag);\n/* type is one or more of the B_ASN1_ values. */\nASN1_STRING *d2i_ASN1_type_bytes(ASN1_STRING **a, const unsigned char **pp,\n                                 long length, int type);\n\n/* PARSING */\nint asn1_Finish(ASN1_CTX *c);\nint asn1_const_Finish(ASN1_const_CTX *c);\n\n/* SPECIALS */\nint ASN1_get_object(const unsigned char **pp, long *plength, int *ptag,\n                    int *pclass, long omax);\nint ASN1_check_infinite_end(unsigned char **p, long len);\nint ASN1_const_check_infinite_end(const unsigned char **p, long len);\nvoid ASN1_put_object(unsigned char **pp, int constructed, int length,\n                     int tag, int xclass);\nint ASN1_put_eoc(unsigned char **pp);\nint ASN1_object_size(int constructed, int length, int tag);\n\n/* Used to implement other functions */\nvoid *ASN1_dup(i2d_of_void *i2d, d2i_of_void *d2i, void *x);\n\n# define ASN1_dup_of(type,i2d,d2i,x) \\\n    ((type*)ASN1_dup(CHECKED_I2D_OF(type, i2d), \\\n                     CHECKED_D2I_OF(type, d2i), \\\n                     CHECKED_PTR_OF(type, x)))\n\n# define ASN1_dup_of_const(type,i2d,d2i,x) \\\n    ((type*)ASN1_dup(CHECKED_I2D_OF(const type, i2d), \\\n                     CHECKED_D2I_OF(type, d2i), \\\n                     CHECKED_PTR_OF(const type, x)))\n\nvoid *ASN1_item_dup(const ASN1_ITEM *it, void *x);\n\n/* ASN1 alloc/free macros for when a type is only used internally */\n\n# define M_ASN1_new_of(type) (type *)ASN1_item_new(ASN1_ITEM_rptr(type))\n# define M_ASN1_free_of(x, type) \\\n                ASN1_item_free(CHECKED_PTR_OF(type, x), ASN1_ITEM_rptr(type))\n\n# ifndef OPENSSL_NO_FP_API\nvoid *ASN1_d2i_fp(void *(*xnew) (void), d2i_of_void *d2i, FILE *in, void **x);\n\n#  define ASN1_d2i_fp_of(type,xnew,d2i,in,x) \\\n    ((type*)ASN1_d2i_fp(CHECKED_NEW_OF(type, xnew), \\\n                        CHECKED_D2I_OF(type, d2i), \\\n                        in, \\\n                        CHECKED_PPTR_OF(type, x)))\n\nvoid *ASN1_item_d2i_fp(const ASN1_ITEM *it, FILE *in, void *x);\nint ASN1_i2d_fp(i2d_of_void *i2d, FILE *out, void *x);\n\n#  define ASN1_i2d_fp_of(type,i2d,out,x) \\\n    (ASN1_i2d_fp(CHECKED_I2D_OF(type, i2d), \\\n                 out, \\\n                 CHECKED_PTR_OF(type, x)))\n\n#  define ASN1_i2d_fp_of_const(type,i2d,out,x) \\\n    (ASN1_i2d_fp(CHECKED_I2D_OF(const type, i2d), \\\n                 out, \\\n                 CHECKED_PTR_OF(const type, x)))\n\nint ASN1_item_i2d_fp(const ASN1_ITEM *it, FILE *out, void *x);\nint ASN1_STRING_print_ex_fp(FILE *fp, ASN1_STRING *str, unsigned long flags);\n# endif\n\nint ASN1_STRING_to_UTF8(unsigned char **out, ASN1_STRING *in);\n\n# ifndef OPENSSL_NO_BIO\nvoid *ASN1_d2i_bio(void *(*xnew) (void), d2i_of_void *d2i, BIO *in, void **x);\n\n#  define ASN1_d2i_bio_of(type,xnew,d2i,in,x) \\\n    ((type*)ASN1_d2i_bio( CHECKED_NEW_OF(type, xnew), \\\n                          CHECKED_D2I_OF(type, d2i), \\\n                          in, \\\n                          CHECKED_PPTR_OF(type, x)))\n\nvoid *ASN1_item_d2i_bio(const ASN1_ITEM *it, BIO *in, void *x);\nint ASN1_i2d_bio(i2d_of_void *i2d, BIO *out, unsigned char *x);\n\n#  define ASN1_i2d_bio_of(type,i2d,out,x) \\\n    (ASN1_i2d_bio(CHECKED_I2D_OF(type, i2d), \\\n                  out, \\\n                  CHECKED_PTR_OF(type, x)))\n\n#  define ASN1_i2d_bio_of_const(type,i2d,out,x) \\\n    (ASN1_i2d_bio(CHECKED_I2D_OF(const type, i2d), \\\n                  out, \\\n                  CHECKED_PTR_OF(const type, x)))\n\nint ASN1_item_i2d_bio(const ASN1_ITEM *it, BIO *out, void *x);\nint ASN1_UTCTIME_print(BIO *fp, const ASN1_UTCTIME *a);\nint ASN1_GENERALIZEDTIME_print(BIO *fp, const ASN1_GENERALIZEDTIME *a);\nint ASN1_TIME_print(BIO *fp, const ASN1_TIME *a);\nint ASN1_STRING_print(BIO *bp, const ASN1_STRING *v);\nint ASN1_STRING_print_ex(BIO *out, ASN1_STRING *str, unsigned long flags);\nint ASN1_bn_print(BIO *bp, const char *number, const BIGNUM *num,\n                  unsigned char *buf, int off);\nint ASN1_parse(BIO *bp, const unsigned char *pp, long len, int indent);\nint ASN1_parse_dump(BIO *bp, const unsigned char *pp, long len, int indent,\n                    int dump);\n# endif\nconst char *ASN1_tag2str(int tag);\n\n/* Used to load and write netscape format cert */\n\nDECLARE_ASN1_FUNCTIONS(NETSCAPE_X509)\n\nint ASN1_UNIVERSALSTRING_to_string(ASN1_UNIVERSALSTRING *s);\n\nint ASN1_TYPE_set_octetstring(ASN1_TYPE *a, unsigned char *data, int len);\nint ASN1_TYPE_get_octetstring(ASN1_TYPE *a, unsigned char *data, int max_len);\nint ASN1_TYPE_set_int_octetstring(ASN1_TYPE *a, long num,\n                                  unsigned char *data, int len);\nint ASN1_TYPE_get_int_octetstring(ASN1_TYPE *a, long *num,\n                                  unsigned char *data, int max_len);\n\nSTACK_OF(OPENSSL_BLOCK) *ASN1_seq_unpack(const unsigned char *buf, int len,\n                                         d2i_of_void *d2i,\n                                         void (*free_func) (OPENSSL_BLOCK));\nunsigned char *ASN1_seq_pack(STACK_OF(OPENSSL_BLOCK) *safes, i2d_of_void *i2d,\n                             unsigned char **buf, int *len);\nvoid *ASN1_unpack_string(ASN1_STRING *oct, d2i_of_void *d2i);\nvoid *ASN1_item_unpack(ASN1_STRING *oct, const ASN1_ITEM *it);\nASN1_STRING *ASN1_pack_string(void *obj, i2d_of_void *i2d,\n                              ASN1_OCTET_STRING **oct);\n\n# define ASN1_pack_string_of(type,obj,i2d,oct) \\\n    (ASN1_pack_string(CHECKED_PTR_OF(type, obj), \\\n                      CHECKED_I2D_OF(type, i2d), \\\n                      oct))\n\nASN1_STRING *ASN1_item_pack(void *obj, const ASN1_ITEM *it,\n                            ASN1_OCTET_STRING **oct);\n\nvoid ASN1_STRING_set_default_mask(unsigned long mask);\nint ASN1_STRING_set_default_mask_asc(const char *p);\nunsigned long ASN1_STRING_get_default_mask(void);\nint ASN1_mbstring_copy(ASN1_STRING **out, const unsigned char *in, int len,\n                       int inform, unsigned long mask);\nint ASN1_mbstring_ncopy(ASN1_STRING **out, const unsigned char *in, int len,\n                        int inform, unsigned long mask,\n                        long minsize, long maxsize);\n\nASN1_STRING *ASN1_STRING_set_by_NID(ASN1_STRING **out,\n                                    const unsigned char *in, int inlen,\n                                    int inform, int nid);\nASN1_STRING_TABLE *ASN1_STRING_TABLE_get(int nid);\nint ASN1_STRING_TABLE_add(int, long, long, unsigned long, unsigned long);\nvoid ASN1_STRING_TABLE_cleanup(void);\n\n/* ASN1 template functions */\n\n/* Old API compatible functions */\nASN1_VALUE *ASN1_item_new(const ASN1_ITEM *it);\nvoid ASN1_item_free(ASN1_VALUE *val, const ASN1_ITEM *it);\nASN1_VALUE *ASN1_item_d2i(ASN1_VALUE **val, const unsigned char **in,\n                          long len, const ASN1_ITEM *it);\nint ASN1_item_i2d(ASN1_VALUE *val, unsigned char **out, const ASN1_ITEM *it);\nint ASN1_item_ndef_i2d(ASN1_VALUE *val, unsigned char **out,\n                       const ASN1_ITEM *it);\n\nvoid ASN1_add_oid_module(void);\n\nASN1_TYPE *ASN1_generate_nconf(char *str, CONF *nconf);\nASN1_TYPE *ASN1_generate_v3(char *str, X509V3_CTX *cnf);\n\n/* ASN1 Print flags */\n\n/* Indicate missing OPTIONAL fields */\n# define ASN1_PCTX_FLAGS_SHOW_ABSENT             0x001\n/* Mark start and end of SEQUENCE */\n# define ASN1_PCTX_FLAGS_SHOW_SEQUENCE           0x002\n/* Mark start and end of SEQUENCE/SET OF */\n# define ASN1_PCTX_FLAGS_SHOW_SSOF               0x004\n/* Show the ASN1 type of primitives */\n# define ASN1_PCTX_FLAGS_SHOW_TYPE               0x008\n/* Don't show ASN1 type of ANY */\n# define ASN1_PCTX_FLAGS_NO_ANY_TYPE             0x010\n/* Don't show ASN1 type of MSTRINGs */\n# define ASN1_PCTX_FLAGS_NO_MSTRING_TYPE         0x020\n/* Don't show field names in SEQUENCE */\n# define ASN1_PCTX_FLAGS_NO_FIELD_NAME           0x040\n/* Show structure names of each SEQUENCE field */\n# define ASN1_PCTX_FLAGS_SHOW_FIELD_STRUCT_NAME  0x080\n/* Don't show structure name even at top level */\n# define ASN1_PCTX_FLAGS_NO_STRUCT_NAME          0x100\n\nint ASN1_item_print(BIO *out, ASN1_VALUE *ifld, int indent,\n                    const ASN1_ITEM *it, const ASN1_PCTX *pctx);\nASN1_PCTX *ASN1_PCTX_new(void);\nvoid ASN1_PCTX_free(ASN1_PCTX *p);\nunsigned long ASN1_PCTX_get_flags(ASN1_PCTX *p);\nvoid ASN1_PCTX_set_flags(ASN1_PCTX *p, unsigned long flags);\nunsigned long ASN1_PCTX_get_nm_flags(ASN1_PCTX *p);\nvoid ASN1_PCTX_set_nm_flags(ASN1_PCTX *p, unsigned long flags);\nunsigned long ASN1_PCTX_get_cert_flags(ASN1_PCTX *p);\nvoid ASN1_PCTX_set_cert_flags(ASN1_PCTX *p, unsigned long flags);\nunsigned long ASN1_PCTX_get_oid_flags(ASN1_PCTX *p);\nvoid ASN1_PCTX_set_oid_flags(ASN1_PCTX *p, unsigned long flags);\nunsigned long ASN1_PCTX_get_str_flags(ASN1_PCTX *p);\nvoid ASN1_PCTX_set_str_flags(ASN1_PCTX *p, unsigned long flags);\n\nBIO_METHOD *BIO_f_asn1(void);\n\nBIO *BIO_new_NDEF(BIO *out, ASN1_VALUE *val, const ASN1_ITEM *it);\n\nint i2d_ASN1_bio_stream(BIO *out, ASN1_VALUE *val, BIO *in, int flags,\n                        const ASN1_ITEM *it);\nint PEM_write_bio_ASN1_stream(BIO *out, ASN1_VALUE *val, BIO *in, int flags,\n                              const char *hdr, const ASN1_ITEM *it);\nint SMIME_write_ASN1(BIO *bio, ASN1_VALUE *val, BIO *data, int flags,\n                     int ctype_nid, int econt_nid,\n                     STACK_OF(X509_ALGOR) *mdalgs, const ASN1_ITEM *it);\nASN1_VALUE *SMIME_read_ASN1(BIO *bio, BIO **bcont, const ASN1_ITEM *it);\nint SMIME_crlf_copy(BIO *in, BIO *out, int flags);\nint SMIME_text(BIO *in, BIO *out);\n\n/* BEGIN ERROR CODES */\n/*\n * The following lines are auto generated by the script mkerr.pl. Any changes\n * made after this point may be overwritten when the script is next run.\n */\nvoid ERR_load_ASN1_strings(void);\n\n/* Error codes for the ASN1 functions. */\n\n/* Function codes. */\n# define ASN1_F_A2D_ASN1_OBJECT                           100\n# define ASN1_F_A2I_ASN1_ENUMERATED                       101\n# define ASN1_F_A2I_ASN1_INTEGER                          102\n# define ASN1_F_A2I_ASN1_STRING                           103\n# define ASN1_F_APPEND_EXP                                176\n# define ASN1_F_ASN1_BIT_STRING_SET_BIT                   183\n# define ASN1_F_ASN1_CB                                   177\n# define ASN1_F_ASN1_CHECK_TLEN                           104\n# define ASN1_F_ASN1_COLLATE_PRIMITIVE                    105\n# define ASN1_F_ASN1_COLLECT                              106\n# define ASN1_F_ASN1_D2I_EX_PRIMITIVE                     108\n# define ASN1_F_ASN1_D2I_FP                               109\n# define ASN1_F_ASN1_D2I_READ_BIO                         107\n# define ASN1_F_ASN1_DIGEST                               184\n# define ASN1_F_ASN1_DO_ADB                               110\n# define ASN1_F_ASN1_DUP                                  111\n# define ASN1_F_ASN1_ENUMERATED_SET                       112\n# define ASN1_F_ASN1_ENUMERATED_TO_BN                     113\n# define ASN1_F_ASN1_EX_C2I                               204\n# define ASN1_F_ASN1_FIND_END                             190\n# define ASN1_F_ASN1_GENERALIZEDTIME_ADJ                  216\n# define ASN1_F_ASN1_GENERALIZEDTIME_SET                  185\n# define ASN1_F_ASN1_GENERATE_V3                          178\n# define ASN1_F_ASN1_GET_OBJECT                           114\n# define ASN1_F_ASN1_HEADER_NEW                           115\n# define ASN1_F_ASN1_I2D_BIO                              116\n# define ASN1_F_ASN1_I2D_FP                               117\n# define ASN1_F_ASN1_INTEGER_SET                          118\n# define ASN1_F_ASN1_INTEGER_TO_BN                        119\n# define ASN1_F_ASN1_ITEM_D2I_FP                          206\n# define ASN1_F_ASN1_ITEM_DUP                             191\n# define ASN1_F_ASN1_ITEM_EX_COMBINE_NEW                  121\n# define ASN1_F_ASN1_ITEM_EX_D2I                          120\n# define ASN1_F_ASN1_ITEM_I2D_BIO                         192\n# define ASN1_F_ASN1_ITEM_I2D_FP                          193\n# define ASN1_F_ASN1_ITEM_PACK                            198\n# define ASN1_F_ASN1_ITEM_SIGN                            195\n# define ASN1_F_ASN1_ITEM_SIGN_CTX                        220\n# define ASN1_F_ASN1_ITEM_UNPACK                          199\n# define ASN1_F_ASN1_ITEM_VERIFY                          197\n# define ASN1_F_ASN1_MBSTRING_NCOPY                       122\n# define ASN1_F_ASN1_OBJECT_NEW                           123\n# define ASN1_F_ASN1_OUTPUT_DATA                          214\n# define ASN1_F_ASN1_PACK_STRING                          124\n# define ASN1_F_ASN1_PCTX_NEW                             205\n# define ASN1_F_ASN1_PKCS5_PBE_SET                        125\n# define ASN1_F_ASN1_SEQ_PACK                             126\n# define ASN1_F_ASN1_SEQ_UNPACK                           127\n# define ASN1_F_ASN1_SIGN                                 128\n# define ASN1_F_ASN1_STR2TYPE                             179\n# define ASN1_F_ASN1_STRING_SET                           186\n# define ASN1_F_ASN1_STRING_TABLE_ADD                     129\n# define ASN1_F_ASN1_STRING_TYPE_NEW                      130\n# define ASN1_F_ASN1_TEMPLATE_EX_D2I                      132\n# define ASN1_F_ASN1_TEMPLATE_NEW                         133\n# define ASN1_F_ASN1_TEMPLATE_NOEXP_D2I                   131\n# define ASN1_F_ASN1_TIME_ADJ                             217\n# define ASN1_F_ASN1_TIME_SET                             175\n# define ASN1_F_ASN1_TYPE_GET_INT_OCTETSTRING             134\n# define ASN1_F_ASN1_TYPE_GET_OCTETSTRING                 135\n# define ASN1_F_ASN1_UNPACK_STRING                        136\n# define ASN1_F_ASN1_UTCTIME_ADJ                          218\n# define ASN1_F_ASN1_UTCTIME_SET                          187\n# define ASN1_F_ASN1_VERIFY                               137\n# define ASN1_F_B64_READ_ASN1                             209\n# define ASN1_F_B64_WRITE_ASN1                            210\n# define ASN1_F_BIO_NEW_NDEF                              208\n# define ASN1_F_BITSTR_CB                                 180\n# define ASN1_F_BN_TO_ASN1_ENUMERATED                     138\n# define ASN1_F_BN_TO_ASN1_INTEGER                        139\n# define ASN1_F_C2I_ASN1_BIT_STRING                       189\n# define ASN1_F_C2I_ASN1_INTEGER                          194\n# define ASN1_F_C2I_ASN1_OBJECT                           196\n# define ASN1_F_COLLECT_DATA                              140\n# define ASN1_F_D2I_ASN1_BIT_STRING                       141\n# define ASN1_F_D2I_ASN1_BOOLEAN                          142\n# define ASN1_F_D2I_ASN1_BYTES                            143\n# define ASN1_F_D2I_ASN1_GENERALIZEDTIME                  144\n# define ASN1_F_D2I_ASN1_HEADER                           145\n# define ASN1_F_D2I_ASN1_INTEGER                          146\n# define ASN1_F_D2I_ASN1_OBJECT                           147\n# define ASN1_F_D2I_ASN1_SET                              148\n# define ASN1_F_D2I_ASN1_TYPE_BYTES                       149\n# define ASN1_F_D2I_ASN1_UINTEGER                         150\n# define ASN1_F_D2I_ASN1_UTCTIME                          151\n# define ASN1_F_D2I_AUTOPRIVATEKEY                        207\n# define ASN1_F_D2I_NETSCAPE_RSA                          152\n# define ASN1_F_D2I_NETSCAPE_RSA_2                        153\n# define ASN1_F_D2I_PRIVATEKEY                            154\n# define ASN1_F_D2I_PUBLICKEY                             155\n# define ASN1_F_D2I_RSA_NET                               200\n# define ASN1_F_D2I_RSA_NET_2                             201\n# define ASN1_F_D2I_X509                                  156\n# define ASN1_F_D2I_X509_CINF                             157\n# define ASN1_F_D2I_X509_PKEY                             159\n# define ASN1_F_I2D_ASN1_BIO_STREAM                       211\n# define ASN1_F_I2D_ASN1_SET                              188\n# define ASN1_F_I2D_ASN1_TIME                             160\n# define ASN1_F_I2D_DSA_PUBKEY                            161\n# define ASN1_F_I2D_EC_PUBKEY                             181\n# define ASN1_F_I2D_PRIVATEKEY                            163\n# define ASN1_F_I2D_PUBLICKEY                             164\n# define ASN1_F_I2D_RSA_NET                               162\n# define ASN1_F_I2D_RSA_PUBKEY                            165\n# define ASN1_F_LONG_C2I                                  166\n# define ASN1_F_OID_MODULE_INIT                           174\n# define ASN1_F_PARSE_TAGGING                             182\n# define ASN1_F_PKCS5_PBE2_SET_IV                         167\n# define ASN1_F_PKCS5_PBE_SET                             202\n# define ASN1_F_PKCS5_PBE_SET0_ALGOR                      215\n# define ASN1_F_PKCS5_PBKDF2_SET                          219\n# define ASN1_F_SMIME_READ_ASN1                           212\n# define ASN1_F_SMIME_TEXT                                213\n# define ASN1_F_X509_CINF_NEW                             168\n# define ASN1_F_X509_CRL_ADD0_REVOKED                     169\n# define ASN1_F_X509_INFO_NEW                             170\n# define ASN1_F_X509_NAME_ENCODE                          203\n# define ASN1_F_X509_NAME_EX_D2I                          158\n# define ASN1_F_X509_NAME_EX_NEW                          171\n# define ASN1_F_X509_NEW                                  172\n# define ASN1_F_X509_PKEY_NEW                             173\n\n/* Reason codes. */\n# define ASN1_R_ADDING_OBJECT                             171\n# define ASN1_R_ASN1_PARSE_ERROR                          203\n# define ASN1_R_ASN1_SIG_PARSE_ERROR                      204\n# define ASN1_R_AUX_ERROR                                 100\n# define ASN1_R_BAD_CLASS                                 101\n# define ASN1_R_BAD_OBJECT_HEADER                         102\n# define ASN1_R_BAD_PASSWORD_READ                         103\n# define ASN1_R_BAD_TAG                                   104\n# define ASN1_R_BMPSTRING_IS_WRONG_LENGTH                 214\n# define ASN1_R_BN_LIB                                    105\n# define ASN1_R_BOOLEAN_IS_WRONG_LENGTH                   106\n# define ASN1_R_BUFFER_TOO_SMALL                          107\n# define ASN1_R_CIPHER_HAS_NO_OBJECT_IDENTIFIER           108\n# define ASN1_R_CONTEXT_NOT_INITIALISED                   217\n# define ASN1_R_DATA_IS_WRONG                             109\n# define ASN1_R_DECODE_ERROR                              110\n# define ASN1_R_DECODING_ERROR                            111\n# define ASN1_R_DEPTH_EXCEEDED                            174\n# define ASN1_R_DIGEST_AND_KEY_TYPE_NOT_SUPPORTED         198\n# define ASN1_R_ENCODE_ERROR                              112\n# define ASN1_R_ERROR_GETTING_TIME                        173\n# define ASN1_R_ERROR_LOADING_SECTION                     172\n# define ASN1_R_ERROR_PARSING_SET_ELEMENT                 113\n# define ASN1_R_ERROR_SETTING_CIPHER_PARAMS               114\n# define ASN1_R_EXPECTING_AN_INTEGER                      115\n# define ASN1_R_EXPECTING_AN_OBJECT                       116\n# define ASN1_R_EXPECTING_A_BOOLEAN                       117\n# define ASN1_R_EXPECTING_A_TIME                          118\n# define ASN1_R_EXPLICIT_LENGTH_MISMATCH                  119\n# define ASN1_R_EXPLICIT_TAG_NOT_CONSTRUCTED              120\n# define ASN1_R_FIELD_MISSING                             121\n# define ASN1_R_FIRST_NUM_TOO_LARGE                       122\n# define ASN1_R_HEADER_TOO_LONG                           123\n# define ASN1_R_ILLEGAL_BITSTRING_FORMAT                  175\n# define ASN1_R_ILLEGAL_BOOLEAN                           176\n# define ASN1_R_ILLEGAL_CHARACTERS                        124\n# define ASN1_R_ILLEGAL_FORMAT                            177\n# define ASN1_R_ILLEGAL_HEX                               178\n# define ASN1_R_ILLEGAL_IMPLICIT_TAG                      179\n# define ASN1_R_ILLEGAL_INTEGER                           180\n# define ASN1_R_ILLEGAL_NESTED_TAGGING                    181\n# define ASN1_R_ILLEGAL_NULL                              125\n# define ASN1_R_ILLEGAL_NULL_VALUE                        182\n# define ASN1_R_ILLEGAL_OBJECT                            183\n# define ASN1_R_ILLEGAL_OPTIONAL_ANY                      126\n# define ASN1_R_ILLEGAL_OPTIONS_ON_ITEM_TEMPLATE          170\n# define ASN1_R_ILLEGAL_TAGGED_ANY                        127\n# define ASN1_R_ILLEGAL_TIME_VALUE                        184\n# define ASN1_R_INTEGER_NOT_ASCII_FORMAT                  185\n# define ASN1_R_INTEGER_TOO_LARGE_FOR_LONG                128\n# define ASN1_R_INVALID_BIT_STRING_BITS_LEFT              220\n# define ASN1_R_INVALID_BMPSTRING_LENGTH                  129\n# define ASN1_R_INVALID_DIGIT                             130\n# define ASN1_R_INVALID_MIME_TYPE                         205\n# define ASN1_R_INVALID_MODIFIER                          186\n# define ASN1_R_INVALID_NUMBER                            187\n# define ASN1_R_INVALID_OBJECT_ENCODING                   216\n# define ASN1_R_INVALID_SEPARATOR                         131\n# define ASN1_R_INVALID_TIME_FORMAT                       132\n# define ASN1_R_INVALID_UNIVERSALSTRING_LENGTH            133\n# define ASN1_R_INVALID_UTF8STRING                        134\n# define ASN1_R_IV_TOO_LARGE                              135\n# define ASN1_R_LENGTH_ERROR                              136\n# define ASN1_R_LIST_ERROR                                188\n# define ASN1_R_MIME_NO_CONTENT_TYPE                      206\n# define ASN1_R_MIME_PARSE_ERROR                          207\n# define ASN1_R_MIME_SIG_PARSE_ERROR                      208\n# define ASN1_R_MISSING_EOC                               137\n# define ASN1_R_MISSING_SECOND_NUMBER                     138\n# define ASN1_R_MISSING_VALUE                             189\n# define ASN1_R_MSTRING_NOT_UNIVERSAL                     139\n# define ASN1_R_MSTRING_WRONG_TAG                         140\n# define ASN1_R_NESTED_ASN1_STRING                        197\n# define ASN1_R_NON_HEX_CHARACTERS                        141\n# define ASN1_R_NOT_ASCII_FORMAT                          190\n# define ASN1_R_NOT_ENOUGH_DATA                           142\n# define ASN1_R_NO_CONTENT_TYPE                           209\n# define ASN1_R_NO_DEFAULT_DIGEST                         201\n# define ASN1_R_NO_MATCHING_CHOICE_TYPE                   143\n# define ASN1_R_NO_MULTIPART_BODY_FAILURE                 210\n# define ASN1_R_NO_MULTIPART_BOUNDARY                     211\n# define ASN1_R_NO_SIG_CONTENT_TYPE                       212\n# define ASN1_R_NULL_IS_WRONG_LENGTH                      144\n# define ASN1_R_OBJECT_NOT_ASCII_FORMAT                   191\n# define ASN1_R_ODD_NUMBER_OF_CHARS                       145\n# define ASN1_R_PRIVATE_KEY_HEADER_MISSING                146\n# define ASN1_R_SECOND_NUMBER_TOO_LARGE                   147\n# define ASN1_R_SEQUENCE_LENGTH_MISMATCH                  148\n# define ASN1_R_SEQUENCE_NOT_CONSTRUCTED                  149\n# define ASN1_R_SEQUENCE_OR_SET_NEEDS_CONFIG              192\n# define ASN1_R_SHORT_LINE                                150\n# define ASN1_R_SIG_INVALID_MIME_TYPE                     213\n# define ASN1_R_STREAMING_NOT_SUPPORTED                   202\n# define ASN1_R_STRING_TOO_LONG                           151\n# define ASN1_R_STRING_TOO_SHORT                          152\n# define ASN1_R_TAG_VALUE_TOO_HIGH                        153\n# define ASN1_R_THE_ASN1_OBJECT_IDENTIFIER_IS_NOT_KNOWN_FOR_THIS_MD 154\n# define ASN1_R_TIME_NOT_ASCII_FORMAT                     193\n# define ASN1_R_TOO_LONG                                  155\n# define ASN1_R_TYPE_NOT_CONSTRUCTED                      156\n# define ASN1_R_TYPE_NOT_PRIMITIVE                        218\n# define ASN1_R_UNABLE_TO_DECODE_RSA_KEY                  157\n# define ASN1_R_UNABLE_TO_DECODE_RSA_PRIVATE_KEY          158\n# define ASN1_R_UNEXPECTED_EOC                            159\n# define ASN1_R_UNIVERSALSTRING_IS_WRONG_LENGTH           215\n# define ASN1_R_UNKNOWN_FORMAT                            160\n# define ASN1_R_UNKNOWN_MESSAGE_DIGEST_ALGORITHM          161\n# define ASN1_R_UNKNOWN_OBJECT_TYPE                       162\n# define ASN1_R_UNKNOWN_PUBLIC_KEY_TYPE                   163\n# define ASN1_R_UNKNOWN_SIGNATURE_ALGORITHM               199\n# define ASN1_R_UNKNOWN_TAG                               194\n# define ASN1_R_UNKOWN_FORMAT                             195\n# define ASN1_R_UNSUPPORTED_ANY_DEFINED_BY_TYPE           164\n# define ASN1_R_UNSUPPORTED_CIPHER                        165\n# define ASN1_R_UNSUPPORTED_ENCRYPTION_ALGORITHM          166\n# define ASN1_R_UNSUPPORTED_PUBLIC_KEY_TYPE               167\n# define ASN1_R_UNSUPPORTED_TYPE                          196\n# define ASN1_R_WRONG_PUBLIC_KEY_TYPE                     200\n# define ASN1_R_WRONG_TAG                                 168\n# define ASN1_R_WRONG_TYPE                                169\n\n#ifdef  __cplusplus\n}\n#endif\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/arm64/include/openssl/asn1_mac.h",
    "content": "/* crypto/asn1/asn1_mac.h */\n/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)\n * All rights reserved.\n *\n * This package is an SSL implementation written\n * by Eric Young (eay@cryptsoft.com).\n * The implementation was written so as to conform with Netscapes SSL.\n *\n * This library is free for commercial and non-commercial use as long as\n * the following conditions are aheared to.  The following conditions\n * apply to all code found in this distribution, be it the RC4, RSA,\n * lhash, DES, etc., code; not just the SSL code.  The SSL documentation\n * included with this distribution is covered by the same copyright terms\n * except that the holder is Tim Hudson (tjh@cryptsoft.com).\n *\n * Copyright remains Eric Young's, and as such any Copyright notices in\n * the code are not to be removed.\n * If this package is used in a product, Eric Young should be given attribution\n * as the author of the parts of the library used.\n * This can be in the form of a textual message at program startup or\n * in documentation (online or textual) provided with the package.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the copyright\n *    notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in the\n *    documentation and/or other materials provided with the distribution.\n * 3. All advertising materials mentioning features or use of this software\n *    must display the following acknowledgement:\n *    \"This product includes cryptographic software written by\n *     Eric Young (eay@cryptsoft.com)\"\n *    The word 'cryptographic' can be left out if the rouines from the library\n *    being used are not cryptographic related :-).\n * 4. If you include any Windows specific code (or a derivative thereof) from\n *    the apps directory (application code) you must include an acknowledgement:\n *    \"This product includes software written by Tim Hudson (tjh@cryptsoft.com)\"\n *\n * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n * SUCH DAMAGE.\n *\n * The licence and distribution terms for any publically available version or\n * derivative of this code cannot be changed.  i.e. this code cannot simply be\n * copied and put under another distribution licence\n * [including the GNU Public Licence.]\n */\n\n#ifndef HEADER_ASN1_MAC_H\n# define HEADER_ASN1_MAC_H\n\n# include <openssl/asn1.h>\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n# ifndef ASN1_MAC_ERR_LIB\n#  define ASN1_MAC_ERR_LIB        ERR_LIB_ASN1\n# endif\n\n# define ASN1_MAC_H_err(f,r,line) \\\n        ERR_PUT_error(ASN1_MAC_ERR_LIB,(f),(r),__FILE__,(line))\n\n# define M_ASN1_D2I_vars(a,type,func) \\\n        ASN1_const_CTX c; \\\n        type ret=NULL; \\\n        \\\n        c.pp=(const unsigned char **)pp; \\\n        c.q= *(const unsigned char **)pp; \\\n        c.error=ERR_R_NESTED_ASN1_ERROR; \\\n        if ((a == NULL) || ((*a) == NULL)) \\\n                { if ((ret=(type)func()) == NULL) \\\n                        { c.line=__LINE__; goto err; } } \\\n        else    ret=(*a);\n\n# define M_ASN1_D2I_Init() \\\n        c.p= *(const unsigned char **)pp; \\\n        c.max=(length == 0)?0:(c.p+length);\n\n# define M_ASN1_D2I_Finish_2(a) \\\n        if (!asn1_const_Finish(&c)) \\\n                { c.line=__LINE__; goto err; } \\\n        *(const unsigned char **)pp=c.p; \\\n        if (a != NULL) (*a)=ret; \\\n        return(ret);\n\n# define M_ASN1_D2I_Finish(a,func,e) \\\n        M_ASN1_D2I_Finish_2(a); \\\nerr:\\\n        ASN1_MAC_H_err((e),c.error,c.line); \\\n        asn1_add_error(*(const unsigned char **)pp,(int)(c.q- *pp)); \\\n        if ((ret != NULL) && ((a == NULL) || (*a != ret))) func(ret); \\\n        return(NULL)\n\n# define M_ASN1_D2I_start_sequence() \\\n        if (!asn1_GetSequence(&c,&length)) \\\n                { c.line=__LINE__; goto err; }\n/* Begin reading ASN1 without a surrounding sequence */\n# define M_ASN1_D2I_begin() \\\n        c.slen = length;\n\n/* End reading ASN1 with no check on length */\n# define M_ASN1_D2I_Finish_nolen(a, func, e) \\\n        *pp=c.p; \\\n        if (a != NULL) (*a)=ret; \\\n        return(ret); \\\nerr:\\\n        ASN1_MAC_H_err((e),c.error,c.line); \\\n        asn1_add_error(*pp,(int)(c.q- *pp)); \\\n        if ((ret != NULL) && ((a == NULL) || (*a != ret))) func(ret); \\\n        return(NULL)\n\n# define M_ASN1_D2I_end_sequence() \\\n        (((c.inf&1) == 0)?(c.slen <= 0): \\\n                (c.eos=ASN1_const_check_infinite_end(&c.p,c.slen)))\n\n/* Don't use this with d2i_ASN1_BOOLEAN() */\n# define M_ASN1_D2I_get(b, func) \\\n        c.q=c.p; \\\n        if (func(&(b),&c.p,c.slen) == NULL) \\\n                {c.line=__LINE__; goto err; } \\\n        c.slen-=(c.p-c.q);\n\n/* Don't use this with d2i_ASN1_BOOLEAN() */\n# define M_ASN1_D2I_get_x(type,b,func) \\\n        c.q=c.p; \\\n        if (((D2I_OF(type))func)(&(b),&c.p,c.slen) == NULL) \\\n                {c.line=__LINE__; goto err; } \\\n        c.slen-=(c.p-c.q);\n\n/* use this instead () */\n# define M_ASN1_D2I_get_int(b,func) \\\n        c.q=c.p; \\\n        if (func(&(b),&c.p,c.slen) < 0) \\\n                {c.line=__LINE__; goto err; } \\\n        c.slen-=(c.p-c.q);\n\n# define M_ASN1_D2I_get_opt(b,func,type) \\\n        if ((c.slen != 0) && ((M_ASN1_next & (~V_ASN1_CONSTRUCTED)) \\\n                == (V_ASN1_UNIVERSAL|(type)))) \\\n                { \\\n                M_ASN1_D2I_get(b,func); \\\n                }\n\n# define M_ASN1_D2I_get_int_opt(b,func,type) \\\n        if ((c.slen != 0) && ((M_ASN1_next & (~V_ASN1_CONSTRUCTED)) \\\n                == (V_ASN1_UNIVERSAL|(type)))) \\\n                { \\\n                M_ASN1_D2I_get_int(b,func); \\\n                }\n\n# define M_ASN1_D2I_get_imp(b,func, type) \\\n        M_ASN1_next=(_tmp& V_ASN1_CONSTRUCTED)|type; \\\n        c.q=c.p; \\\n        if (func(&(b),&c.p,c.slen) == NULL) \\\n                {c.line=__LINE__; M_ASN1_next_prev = _tmp; goto err; } \\\n        c.slen-=(c.p-c.q);\\\n        M_ASN1_next_prev=_tmp;\n\n# define M_ASN1_D2I_get_IMP_opt(b,func,tag,type) \\\n        if ((c.slen != 0) && ((M_ASN1_next & (~V_ASN1_CONSTRUCTED)) == \\\n                (V_ASN1_CONTEXT_SPECIFIC|(tag)))) \\\n                { \\\n                unsigned char _tmp = M_ASN1_next; \\\n                M_ASN1_D2I_get_imp(b,func, type);\\\n                }\n\n# define M_ASN1_D2I_get_set(r,func,free_func) \\\n                M_ASN1_D2I_get_imp_set(r,func,free_func, \\\n                        V_ASN1_SET,V_ASN1_UNIVERSAL);\n\n# define M_ASN1_D2I_get_set_type(type,r,func,free_func) \\\n                M_ASN1_D2I_get_imp_set_type(type,r,func,free_func, \\\n                        V_ASN1_SET,V_ASN1_UNIVERSAL);\n\n# define M_ASN1_D2I_get_set_opt(r,func,free_func) \\\n        if ((c.slen != 0) && (M_ASN1_next == (V_ASN1_UNIVERSAL| \\\n                V_ASN1_CONSTRUCTED|V_ASN1_SET)))\\\n                { M_ASN1_D2I_get_set(r,func,free_func); }\n\n# define M_ASN1_D2I_get_set_opt_type(type,r,func,free_func) \\\n        if ((c.slen != 0) && (M_ASN1_next == (V_ASN1_UNIVERSAL| \\\n                V_ASN1_CONSTRUCTED|V_ASN1_SET)))\\\n                { M_ASN1_D2I_get_set_type(type,r,func,free_func); }\n\n# define M_ASN1_I2D_len_SET_opt(a,f) \\\n        if ((a != NULL) && (sk_num(a) != 0)) \\\n                M_ASN1_I2D_len_SET(a,f);\n\n# define M_ASN1_I2D_put_SET_opt(a,f) \\\n        if ((a != NULL) && (sk_num(a) != 0)) \\\n                M_ASN1_I2D_put_SET(a,f);\n\n# define M_ASN1_I2D_put_SEQUENCE_opt(a,f) \\\n        if ((a != NULL) && (sk_num(a) != 0)) \\\n                M_ASN1_I2D_put_SEQUENCE(a,f);\n\n# define M_ASN1_I2D_put_SEQUENCE_opt_type(type,a,f) \\\n        if ((a != NULL) && (sk_##type##_num(a) != 0)) \\\n                M_ASN1_I2D_put_SEQUENCE_type(type,a,f);\n\n# define M_ASN1_D2I_get_IMP_set_opt(b,func,free_func,tag) \\\n        if ((c.slen != 0) && \\\n                (M_ASN1_next == \\\n                (V_ASN1_CONTEXT_SPECIFIC|V_ASN1_CONSTRUCTED|(tag))))\\\n                { \\\n                M_ASN1_D2I_get_imp_set(b,func,free_func,\\\n                        tag,V_ASN1_CONTEXT_SPECIFIC); \\\n                }\n\n# define M_ASN1_D2I_get_IMP_set_opt_type(type,b,func,free_func,tag) \\\n        if ((c.slen != 0) && \\\n                (M_ASN1_next == \\\n                (V_ASN1_CONTEXT_SPECIFIC|V_ASN1_CONSTRUCTED|(tag))))\\\n                { \\\n                M_ASN1_D2I_get_imp_set_type(type,b,func,free_func,\\\n                        tag,V_ASN1_CONTEXT_SPECIFIC); \\\n                }\n\n# define M_ASN1_D2I_get_seq(r,func,free_func) \\\n                M_ASN1_D2I_get_imp_set(r,func,free_func,\\\n                        V_ASN1_SEQUENCE,V_ASN1_UNIVERSAL);\n\n# define M_ASN1_D2I_get_seq_type(type,r,func,free_func) \\\n                M_ASN1_D2I_get_imp_set_type(type,r,func,free_func,\\\n                                            V_ASN1_SEQUENCE,V_ASN1_UNIVERSAL)\n\n# define M_ASN1_D2I_get_seq_opt(r,func,free_func) \\\n        if ((c.slen != 0) && (M_ASN1_next == (V_ASN1_UNIVERSAL| \\\n                V_ASN1_CONSTRUCTED|V_ASN1_SEQUENCE)))\\\n                { M_ASN1_D2I_get_seq(r,func,free_func); }\n\n# define M_ASN1_D2I_get_seq_opt_type(type,r,func,free_func) \\\n        if ((c.slen != 0) && (M_ASN1_next == (V_ASN1_UNIVERSAL| \\\n                V_ASN1_CONSTRUCTED|V_ASN1_SEQUENCE)))\\\n                { M_ASN1_D2I_get_seq_type(type,r,func,free_func); }\n\n# define M_ASN1_D2I_get_IMP_set(r,func,free_func,x) \\\n                M_ASN1_D2I_get_imp_set(r,func,free_func,\\\n                        x,V_ASN1_CONTEXT_SPECIFIC);\n\n# define M_ASN1_D2I_get_IMP_set_type(type,r,func,free_func,x) \\\n                M_ASN1_D2I_get_imp_set_type(type,r,func,free_func,\\\n                        x,V_ASN1_CONTEXT_SPECIFIC);\n\n# define M_ASN1_D2I_get_imp_set(r,func,free_func,a,b) \\\n        c.q=c.p; \\\n        if (d2i_ASN1_SET(&(r),&c.p,c.slen,(char *(*)())func,\\\n                (void (*)())free_func,a,b) == NULL) \\\n                { c.line=__LINE__; goto err; } \\\n        c.slen-=(c.p-c.q);\n\n# define M_ASN1_D2I_get_imp_set_type(type,r,func,free_func,a,b) \\\n        c.q=c.p; \\\n        if (d2i_ASN1_SET_OF_##type(&(r),&c.p,c.slen,func,\\\n                                   free_func,a,b) == NULL) \\\n                { c.line=__LINE__; goto err; } \\\n        c.slen-=(c.p-c.q);\n\n# define M_ASN1_D2I_get_set_strings(r,func,a,b) \\\n        c.q=c.p; \\\n        if (d2i_ASN1_STRING_SET(&(r),&c.p,c.slen,a,b) == NULL) \\\n                { c.line=__LINE__; goto err; } \\\n        c.slen-=(c.p-c.q);\n\n# define M_ASN1_D2I_get_EXP_opt(r,func,tag) \\\n        if ((c.slen != 0L) && (M_ASN1_next == \\\n                (V_ASN1_CONSTRUCTED|V_ASN1_CONTEXT_SPECIFIC|tag))) \\\n                { \\\n                int Tinf,Ttag,Tclass; \\\n                long Tlen; \\\n                \\\n                c.q=c.p; \\\n                Tinf=ASN1_get_object(&c.p,&Tlen,&Ttag,&Tclass,c.slen); \\\n                if (Tinf & 0x80) \\\n                        { c.error=ERR_R_BAD_ASN1_OBJECT_HEADER; \\\n                        c.line=__LINE__; goto err; } \\\n                if (Tinf == (V_ASN1_CONSTRUCTED+1)) \\\n                                        Tlen = c.slen - (c.p - c.q) - 2; \\\n                if (func(&(r),&c.p,Tlen) == NULL) \\\n                        { c.line=__LINE__; goto err; } \\\n                if (Tinf == (V_ASN1_CONSTRUCTED+1)) { \\\n                        Tlen = c.slen - (c.p - c.q); \\\n                        if(!ASN1_const_check_infinite_end(&c.p, Tlen)) \\\n                                { c.error=ERR_R_MISSING_ASN1_EOS; \\\n                                c.line=__LINE__; goto err; } \\\n                }\\\n                c.slen-=(c.p-c.q); \\\n                }\n\n# define M_ASN1_D2I_get_EXP_set_opt(r,func,free_func,tag,b) \\\n        if ((c.slen != 0) && (M_ASN1_next == \\\n                (V_ASN1_CONSTRUCTED|V_ASN1_CONTEXT_SPECIFIC|tag))) \\\n                { \\\n                int Tinf,Ttag,Tclass; \\\n                long Tlen; \\\n                \\\n                c.q=c.p; \\\n                Tinf=ASN1_get_object(&c.p,&Tlen,&Ttag,&Tclass,c.slen); \\\n                if (Tinf & 0x80) \\\n                        { c.error=ERR_R_BAD_ASN1_OBJECT_HEADER; \\\n                        c.line=__LINE__; goto err; } \\\n                if (Tinf == (V_ASN1_CONSTRUCTED+1)) \\\n                                        Tlen = c.slen - (c.p - c.q) - 2; \\\n                if (d2i_ASN1_SET(&(r),&c.p,Tlen,(char *(*)())func, \\\n                        (void (*)())free_func, \\\n                        b,V_ASN1_UNIVERSAL) == NULL) \\\n                        { c.line=__LINE__; goto err; } \\\n                if (Tinf == (V_ASN1_CONSTRUCTED+1)) { \\\n                        Tlen = c.slen - (c.p - c.q); \\\n                        if(!ASN1_check_infinite_end(&c.p, Tlen)) \\\n                                { c.error=ERR_R_MISSING_ASN1_EOS; \\\n                                c.line=__LINE__; goto err; } \\\n                }\\\n                c.slen-=(c.p-c.q); \\\n                }\n\n# define M_ASN1_D2I_get_EXP_set_opt_type(type,r,func,free_func,tag,b) \\\n        if ((c.slen != 0) && (M_ASN1_next == \\\n                (V_ASN1_CONSTRUCTED|V_ASN1_CONTEXT_SPECIFIC|tag))) \\\n                { \\\n                int Tinf,Ttag,Tclass; \\\n                long Tlen; \\\n                \\\n                c.q=c.p; \\\n                Tinf=ASN1_get_object(&c.p,&Tlen,&Ttag,&Tclass,c.slen); \\\n                if (Tinf & 0x80) \\\n                        { c.error=ERR_R_BAD_ASN1_OBJECT_HEADER; \\\n                        c.line=__LINE__; goto err; } \\\n                if (Tinf == (V_ASN1_CONSTRUCTED+1)) \\\n                                        Tlen = c.slen - (c.p - c.q) - 2; \\\n                if (d2i_ASN1_SET_OF_##type(&(r),&c.p,Tlen,func, \\\n                        free_func,b,V_ASN1_UNIVERSAL) == NULL) \\\n                        { c.line=__LINE__; goto err; } \\\n                if (Tinf == (V_ASN1_CONSTRUCTED+1)) { \\\n                        Tlen = c.slen - (c.p - c.q); \\\n                        if(!ASN1_check_infinite_end(&c.p, Tlen)) \\\n                                { c.error=ERR_R_MISSING_ASN1_EOS; \\\n                                c.line=__LINE__; goto err; } \\\n                }\\\n                c.slen-=(c.p-c.q); \\\n                }\n\n/* New macros */\n# define M_ASN1_New_Malloc(ret,type) \\\n        if ((ret=(type *)OPENSSL_malloc(sizeof(type))) == NULL) \\\n                { c.line=__LINE__; goto err2; }\n\n# define M_ASN1_New(arg,func) \\\n        if (((arg)=func()) == NULL) return(NULL)\n\n# define M_ASN1_New_Error(a) \\\n/*-     err:    ASN1_MAC_H_err((a),ERR_R_NESTED_ASN1_ERROR,c.line); \\\n                return(NULL);*/ \\\n        err2:   ASN1_MAC_H_err((a),ERR_R_MALLOC_FAILURE,c.line); \\\n                return(NULL)\n\n/*\n * BIG UGLY WARNING! This is so damn ugly I wanna puke.  Unfortunately, some\n * macros that use ASN1_const_CTX still insist on writing in the input\n * stream.  ARGH! ARGH! ARGH! Let's get rid of this macro package. Please? --\n * Richard Levitte\n */\n# define M_ASN1_next             (*((unsigned char *)(c.p)))\n# define M_ASN1_next_prev        (*((unsigned char *)(c.q)))\n\n/*************************************************/\n\n# define M_ASN1_I2D_vars(a)      int r=0,ret=0; \\\n                                unsigned char *p; \\\n                                if (a == NULL) return(0)\n\n/* Length Macros */\n# define M_ASN1_I2D_len(a,f)     ret+=f(a,NULL)\n# define M_ASN1_I2D_len_IMP_opt(a,f)     if (a != NULL) M_ASN1_I2D_len(a,f)\n\n# define M_ASN1_I2D_len_SET(a,f) \\\n                ret+=i2d_ASN1_SET(a,NULL,f,V_ASN1_SET,V_ASN1_UNIVERSAL,IS_SET);\n\n# define M_ASN1_I2D_len_SET_type(type,a,f) \\\n                ret+=i2d_ASN1_SET_OF_##type(a,NULL,f,V_ASN1_SET, \\\n                                            V_ASN1_UNIVERSAL,IS_SET);\n\n# define M_ASN1_I2D_len_SEQUENCE(a,f) \\\n                ret+=i2d_ASN1_SET(a,NULL,f,V_ASN1_SEQUENCE,V_ASN1_UNIVERSAL, \\\n                                  IS_SEQUENCE);\n\n# define M_ASN1_I2D_len_SEQUENCE_type(type,a,f) \\\n                ret+=i2d_ASN1_SET_OF_##type(a,NULL,f,V_ASN1_SEQUENCE, \\\n                                            V_ASN1_UNIVERSAL,IS_SEQUENCE)\n\n# define M_ASN1_I2D_len_SEQUENCE_opt(a,f) \\\n                if ((a != NULL) && (sk_num(a) != 0)) \\\n                        M_ASN1_I2D_len_SEQUENCE(a,f);\n\n# define M_ASN1_I2D_len_SEQUENCE_opt_type(type,a,f) \\\n                if ((a != NULL) && (sk_##type##_num(a) != 0)) \\\n                        M_ASN1_I2D_len_SEQUENCE_type(type,a,f);\n\n# define M_ASN1_I2D_len_IMP_SET(a,f,x) \\\n                ret+=i2d_ASN1_SET(a,NULL,f,x,V_ASN1_CONTEXT_SPECIFIC,IS_SET);\n\n# define M_ASN1_I2D_len_IMP_SET_type(type,a,f,x) \\\n                ret+=i2d_ASN1_SET_OF_##type(a,NULL,f,x, \\\n                                            V_ASN1_CONTEXT_SPECIFIC,IS_SET);\n\n# define M_ASN1_I2D_len_IMP_SET_opt(a,f,x) \\\n                if ((a != NULL) && (sk_num(a) != 0)) \\\n                        ret+=i2d_ASN1_SET(a,NULL,f,x,V_ASN1_CONTEXT_SPECIFIC, \\\n                                          IS_SET);\n\n# define M_ASN1_I2D_len_IMP_SET_opt_type(type,a,f,x) \\\n                if ((a != NULL) && (sk_##type##_num(a) != 0)) \\\n                        ret+=i2d_ASN1_SET_OF_##type(a,NULL,f,x, \\\n                                               V_ASN1_CONTEXT_SPECIFIC,IS_SET);\n\n# define M_ASN1_I2D_len_IMP_SEQUENCE(a,f,x) \\\n                ret+=i2d_ASN1_SET(a,NULL,f,x,V_ASN1_CONTEXT_SPECIFIC, \\\n                                  IS_SEQUENCE);\n\n# define M_ASN1_I2D_len_IMP_SEQUENCE_opt(a,f,x) \\\n                if ((a != NULL) && (sk_num(a) != 0)) \\\n                        ret+=i2d_ASN1_SET(a,NULL,f,x,V_ASN1_CONTEXT_SPECIFIC, \\\n                                          IS_SEQUENCE);\n\n# define M_ASN1_I2D_len_IMP_SEQUENCE_opt_type(type,a,f,x) \\\n                if ((a != NULL) && (sk_##type##_num(a) != 0)) \\\n                        ret+=i2d_ASN1_SET_OF_##type(a,NULL,f,x, \\\n                                                    V_ASN1_CONTEXT_SPECIFIC, \\\n                                                    IS_SEQUENCE);\n\n# define M_ASN1_I2D_len_EXP_opt(a,f,mtag,v) \\\n                if (a != NULL)\\\n                        { \\\n                        v=f(a,NULL); \\\n                        ret+=ASN1_object_size(1,v,mtag); \\\n                        }\n\n# define M_ASN1_I2D_len_EXP_SET_opt(a,f,mtag,tag,v) \\\n                if ((a != NULL) && (sk_num(a) != 0))\\\n                        { \\\n                        v=i2d_ASN1_SET(a,NULL,f,tag,V_ASN1_UNIVERSAL,IS_SET); \\\n                        ret+=ASN1_object_size(1,v,mtag); \\\n                        }\n\n# define M_ASN1_I2D_len_EXP_SEQUENCE_opt(a,f,mtag,tag,v) \\\n                if ((a != NULL) && (sk_num(a) != 0))\\\n                        { \\\n                        v=i2d_ASN1_SET(a,NULL,f,tag,V_ASN1_UNIVERSAL, \\\n                                       IS_SEQUENCE); \\\n                        ret+=ASN1_object_size(1,v,mtag); \\\n                        }\n\n# define M_ASN1_I2D_len_EXP_SEQUENCE_opt_type(type,a,f,mtag,tag,v) \\\n                if ((a != NULL) && (sk_##type##_num(a) != 0))\\\n                        { \\\n                        v=i2d_ASN1_SET_OF_##type(a,NULL,f,tag, \\\n                                                 V_ASN1_UNIVERSAL, \\\n                                                 IS_SEQUENCE); \\\n                        ret+=ASN1_object_size(1,v,mtag); \\\n                        }\n\n/* Put Macros */\n# define M_ASN1_I2D_put(a,f)     f(a,&p)\n\n# define M_ASN1_I2D_put_IMP_opt(a,f,t)   \\\n                if (a != NULL) \\\n                        { \\\n                        unsigned char *q=p; \\\n                        f(a,&p); \\\n                        *q=(V_ASN1_CONTEXT_SPECIFIC|t|(*q&V_ASN1_CONSTRUCTED));\\\n                        }\n\n# define M_ASN1_I2D_put_SET(a,f) i2d_ASN1_SET(a,&p,f,V_ASN1_SET,\\\n                        V_ASN1_UNIVERSAL,IS_SET)\n# define M_ASN1_I2D_put_SET_type(type,a,f) \\\n     i2d_ASN1_SET_OF_##type(a,&p,f,V_ASN1_SET,V_ASN1_UNIVERSAL,IS_SET)\n# define M_ASN1_I2D_put_IMP_SET(a,f,x) i2d_ASN1_SET(a,&p,f,x,\\\n                        V_ASN1_CONTEXT_SPECIFIC,IS_SET)\n# define M_ASN1_I2D_put_IMP_SET_type(type,a,f,x) \\\n     i2d_ASN1_SET_OF_##type(a,&p,f,x,V_ASN1_CONTEXT_SPECIFIC,IS_SET)\n# define M_ASN1_I2D_put_IMP_SEQUENCE(a,f,x) i2d_ASN1_SET(a,&p,f,x,\\\n                        V_ASN1_CONTEXT_SPECIFIC,IS_SEQUENCE)\n\n# define M_ASN1_I2D_put_SEQUENCE(a,f) i2d_ASN1_SET(a,&p,f,V_ASN1_SEQUENCE,\\\n                                             V_ASN1_UNIVERSAL,IS_SEQUENCE)\n\n# define M_ASN1_I2D_put_SEQUENCE_type(type,a,f) \\\n     i2d_ASN1_SET_OF_##type(a,&p,f,V_ASN1_SEQUENCE,V_ASN1_UNIVERSAL, \\\n                            IS_SEQUENCE)\n\n# define M_ASN1_I2D_put_SEQUENCE_opt(a,f) \\\n                if ((a != NULL) && (sk_num(a) != 0)) \\\n                        M_ASN1_I2D_put_SEQUENCE(a,f);\n\n# define M_ASN1_I2D_put_IMP_SET_opt(a,f,x) \\\n                if ((a != NULL) && (sk_num(a) != 0)) \\\n                        { i2d_ASN1_SET(a,&p,f,x,V_ASN1_CONTEXT_SPECIFIC, \\\n                                       IS_SET); }\n\n# define M_ASN1_I2D_put_IMP_SET_opt_type(type,a,f,x) \\\n                if ((a != NULL) && (sk_##type##_num(a) != 0)) \\\n                        { i2d_ASN1_SET_OF_##type(a,&p,f,x, \\\n                                                 V_ASN1_CONTEXT_SPECIFIC, \\\n                                                 IS_SET); }\n\n# define M_ASN1_I2D_put_IMP_SEQUENCE_opt(a,f,x) \\\n                if ((a != NULL) && (sk_num(a) != 0)) \\\n                        { i2d_ASN1_SET(a,&p,f,x,V_ASN1_CONTEXT_SPECIFIC, \\\n                                       IS_SEQUENCE); }\n\n# define M_ASN1_I2D_put_IMP_SEQUENCE_opt_type(type,a,f,x) \\\n                if ((a != NULL) && (sk_##type##_num(a) != 0)) \\\n                        { i2d_ASN1_SET_OF_##type(a,&p,f,x, \\\n                                                 V_ASN1_CONTEXT_SPECIFIC, \\\n                                                 IS_SEQUENCE); }\n\n# define M_ASN1_I2D_put_EXP_opt(a,f,tag,v) \\\n                if (a != NULL) \\\n                        { \\\n                        ASN1_put_object(&p,1,v,tag,V_ASN1_CONTEXT_SPECIFIC); \\\n                        f(a,&p); \\\n                        }\n\n# define M_ASN1_I2D_put_EXP_SET_opt(a,f,mtag,tag,v) \\\n                if ((a != NULL) && (sk_num(a) != 0)) \\\n                        { \\\n                        ASN1_put_object(&p,1,v,mtag,V_ASN1_CONTEXT_SPECIFIC); \\\n                        i2d_ASN1_SET(a,&p,f,tag,V_ASN1_UNIVERSAL,IS_SET); \\\n                        }\n\n# define M_ASN1_I2D_put_EXP_SEQUENCE_opt(a,f,mtag,tag,v) \\\n                if ((a != NULL) && (sk_num(a) != 0)) \\\n                        { \\\n                        ASN1_put_object(&p,1,v,mtag,V_ASN1_CONTEXT_SPECIFIC); \\\n                        i2d_ASN1_SET(a,&p,f,tag,V_ASN1_UNIVERSAL,IS_SEQUENCE); \\\n                        }\n\n# define M_ASN1_I2D_put_EXP_SEQUENCE_opt_type(type,a,f,mtag,tag,v) \\\n                if ((a != NULL) && (sk_##type##_num(a) != 0)) \\\n                        { \\\n                        ASN1_put_object(&p,1,v,mtag,V_ASN1_CONTEXT_SPECIFIC); \\\n                        i2d_ASN1_SET_OF_##type(a,&p,f,tag,V_ASN1_UNIVERSAL, \\\n                                               IS_SEQUENCE); \\\n                        }\n\n# define M_ASN1_I2D_seq_total() \\\n                r=ASN1_object_size(1,ret,V_ASN1_SEQUENCE); \\\n                if (pp == NULL) return(r); \\\n                p= *pp; \\\n                ASN1_put_object(&p,1,ret,V_ASN1_SEQUENCE,V_ASN1_UNIVERSAL)\n\n# define M_ASN1_I2D_INF_seq_start(tag,ctx) \\\n                *(p++)=(V_ASN1_CONSTRUCTED|(tag)|(ctx)); \\\n                *(p++)=0x80\n\n# define M_ASN1_I2D_INF_seq_end() *(p++)=0x00; *(p++)=0x00\n\n# define M_ASN1_I2D_finish()     *pp=p; \\\n                                return(r);\n\nint asn1_GetSequence(ASN1_const_CTX *c, long *length);\nvoid asn1_add_error(const unsigned char *address, int offset);\n#ifdef  __cplusplus\n}\n#endif\n\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/arm64/include/openssl/asn1t.h",
    "content": "/* asn1t.h */\n/*\n * Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL project\n * 2000.\n */\n/* ====================================================================\n * Copyright (c) 2000-2005 The OpenSSL Project.  All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n *\n * 1. Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n *\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in\n *    the documentation and/or other materials provided with the\n *    distribution.\n *\n * 3. All advertising materials mentioning features or use of this\n *    software must display the following acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)\"\n *\n * 4. The names \"OpenSSL Toolkit\" and \"OpenSSL Project\" must not be used to\n *    endorse or promote products derived from this software without\n *    prior written permission. For written permission, please contact\n *    licensing@OpenSSL.org.\n *\n * 5. Products derived from this software may not be called \"OpenSSL\"\n *    nor may \"OpenSSL\" appear in their names without prior written\n *    permission of the OpenSSL Project.\n *\n * 6. Redistributions of any form whatsoever must retain the following\n *    acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)\"\n *\n * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY\n * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\n * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR\n * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\n * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,\n * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED\n * OF THE POSSIBILITY OF SUCH DAMAGE.\n * ====================================================================\n *\n * This product includes cryptographic software written by Eric Young\n * (eay@cryptsoft.com).  This product includes software written by Tim\n * Hudson (tjh@cryptsoft.com).\n *\n */\n#ifndef HEADER_ASN1T_H\n# define HEADER_ASN1T_H\n\n# include <stddef.h>\n# include <openssl/e_os2.h>\n# include <openssl/asn1.h>\n\n# ifdef OPENSSL_BUILD_SHLIBCRYPTO\n#  undef OPENSSL_EXTERN\n#  define OPENSSL_EXTERN OPENSSL_EXPORT\n# endif\n\n/* ASN1 template defines, structures and functions */\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n# ifndef OPENSSL_EXPORT_VAR_AS_FUNCTION\n\n/* Macro to obtain ASN1_ADB pointer from a type (only used internally) */\n#  define ASN1_ADB_ptr(iptr) ((const ASN1_ADB *)(iptr))\n\n/* Macros for start and end of ASN1_ITEM definition */\n\n#  define ASN1_ITEM_start(itname) \\\n        OPENSSL_GLOBAL const ASN1_ITEM itname##_it = {\n\n#  define ASN1_ITEM_end(itname) \\\n                };\n\n# else\n\n/* Macro to obtain ASN1_ADB pointer from a type (only used internally) */\n#  define ASN1_ADB_ptr(iptr) ((const ASN1_ADB *)(iptr()))\n\n/* Macros for start and end of ASN1_ITEM definition */\n\n#  define ASN1_ITEM_start(itname) \\\n        const ASN1_ITEM * itname##_it(void) \\\n        { \\\n                static const ASN1_ITEM local_it = {\n\n#  define ASN1_ITEM_end(itname) \\\n                }; \\\n        return &local_it; \\\n        }\n\n# endif\n\n/* Macros to aid ASN1 template writing */\n\n# define ASN1_ITEM_TEMPLATE(tname) \\\n        static const ASN1_TEMPLATE tname##_item_tt\n\n# define ASN1_ITEM_TEMPLATE_END(tname) \\\n        ;\\\n        ASN1_ITEM_start(tname) \\\n                ASN1_ITYPE_PRIMITIVE,\\\n                -1,\\\n                &tname##_item_tt,\\\n                0,\\\n                NULL,\\\n                0,\\\n                #tname \\\n        ASN1_ITEM_end(tname)\n\n/* This is a ASN1 type which just embeds a template */\n\n/*-\n * This pair helps declare a SEQUENCE. We can do:\n *\n *      ASN1_SEQUENCE(stname) = {\n *              ... SEQUENCE components ...\n *      } ASN1_SEQUENCE_END(stname)\n *\n *      This will produce an ASN1_ITEM called stname_it\n *      for a structure called stname.\n *\n *      If you want the same structure but a different\n *      name then use:\n *\n *      ASN1_SEQUENCE(itname) = {\n *              ... SEQUENCE components ...\n *      } ASN1_SEQUENCE_END_name(stname, itname)\n *\n *      This will create an item called itname_it using\n *      a structure called stname.\n */\n\n# define ASN1_SEQUENCE(tname) \\\n        static const ASN1_TEMPLATE tname##_seq_tt[]\n\n# define ASN1_SEQUENCE_END(stname) ASN1_SEQUENCE_END_name(stname, stname)\n\n# define ASN1_SEQUENCE_END_name(stname, tname) \\\n        ;\\\n        ASN1_ITEM_start(tname) \\\n                ASN1_ITYPE_SEQUENCE,\\\n                V_ASN1_SEQUENCE,\\\n                tname##_seq_tt,\\\n                sizeof(tname##_seq_tt) / sizeof(ASN1_TEMPLATE),\\\n                NULL,\\\n                sizeof(stname),\\\n                #stname \\\n        ASN1_ITEM_end(tname)\n\n# define ASN1_NDEF_SEQUENCE(tname) \\\n        ASN1_SEQUENCE(tname)\n\n# define ASN1_NDEF_SEQUENCE_cb(tname, cb) \\\n        ASN1_SEQUENCE_cb(tname, cb)\n\n# define ASN1_SEQUENCE_cb(tname, cb) \\\n        static const ASN1_AUX tname##_aux = {NULL, 0, 0, 0, cb, 0}; \\\n        ASN1_SEQUENCE(tname)\n\n# define ASN1_BROKEN_SEQUENCE(tname) \\\n        static const ASN1_AUX tname##_aux = {NULL, ASN1_AFLG_BROKEN, 0, 0, 0, 0}; \\\n        ASN1_SEQUENCE(tname)\n\n# define ASN1_SEQUENCE_ref(tname, cb, lck) \\\n        static const ASN1_AUX tname##_aux = {NULL, ASN1_AFLG_REFCOUNT, offsetof(tname, references), lck, cb, 0}; \\\n        ASN1_SEQUENCE(tname)\n\n# define ASN1_SEQUENCE_enc(tname, enc, cb) \\\n        static const ASN1_AUX tname##_aux = {NULL, ASN1_AFLG_ENCODING, 0, 0, cb, offsetof(tname, enc)}; \\\n        ASN1_SEQUENCE(tname)\n\n# define ASN1_NDEF_SEQUENCE_END(tname) \\\n        ;\\\n        ASN1_ITEM_start(tname) \\\n                ASN1_ITYPE_NDEF_SEQUENCE,\\\n                V_ASN1_SEQUENCE,\\\n                tname##_seq_tt,\\\n                sizeof(tname##_seq_tt) / sizeof(ASN1_TEMPLATE),\\\n                NULL,\\\n                sizeof(tname),\\\n                #tname \\\n        ASN1_ITEM_end(tname)\n\n# define ASN1_BROKEN_SEQUENCE_END(stname) ASN1_SEQUENCE_END_ref(stname, stname)\n\n# define ASN1_SEQUENCE_END_enc(stname, tname) ASN1_SEQUENCE_END_ref(stname, tname)\n\n# define ASN1_SEQUENCE_END_cb(stname, tname) ASN1_SEQUENCE_END_ref(stname, tname)\n\n# define ASN1_SEQUENCE_END_ref(stname, tname) \\\n        ;\\\n        ASN1_ITEM_start(tname) \\\n                ASN1_ITYPE_SEQUENCE,\\\n                V_ASN1_SEQUENCE,\\\n                tname##_seq_tt,\\\n                sizeof(tname##_seq_tt) / sizeof(ASN1_TEMPLATE),\\\n                &tname##_aux,\\\n                sizeof(stname),\\\n                #stname \\\n        ASN1_ITEM_end(tname)\n\n# define ASN1_NDEF_SEQUENCE_END_cb(stname, tname) \\\n        ;\\\n        ASN1_ITEM_start(tname) \\\n                ASN1_ITYPE_NDEF_SEQUENCE,\\\n                V_ASN1_SEQUENCE,\\\n                tname##_seq_tt,\\\n                sizeof(tname##_seq_tt) / sizeof(ASN1_TEMPLATE),\\\n                &tname##_aux,\\\n                sizeof(stname),\\\n                #stname \\\n        ASN1_ITEM_end(tname)\n\n/*-\n * This pair helps declare a CHOICE type. We can do:\n *\n *      ASN1_CHOICE(chname) = {\n *              ... CHOICE options ...\n *      ASN1_CHOICE_END(chname)\n *\n *      This will produce an ASN1_ITEM called chname_it\n *      for a structure called chname. The structure\n *      definition must look like this:\n *      typedef struct {\n *              int type;\n *              union {\n *                      ASN1_SOMETHING *opt1;\n *                      ASN1_SOMEOTHER *opt2;\n *              } value;\n *      } chname;\n *\n *      the name of the selector must be 'type'.\n *      to use an alternative selector name use the\n *      ASN1_CHOICE_END_selector() version.\n */\n\n# define ASN1_CHOICE(tname) \\\n        static const ASN1_TEMPLATE tname##_ch_tt[]\n\n# define ASN1_CHOICE_cb(tname, cb) \\\n        static const ASN1_AUX tname##_aux = {NULL, 0, 0, 0, cb, 0}; \\\n        ASN1_CHOICE(tname)\n\n# define ASN1_CHOICE_END(stname) ASN1_CHOICE_END_name(stname, stname)\n\n# define ASN1_CHOICE_END_name(stname, tname) ASN1_CHOICE_END_selector(stname, tname, type)\n\n# define ASN1_CHOICE_END_selector(stname, tname, selname) \\\n        ;\\\n        ASN1_ITEM_start(tname) \\\n                ASN1_ITYPE_CHOICE,\\\n                offsetof(stname,selname) ,\\\n                tname##_ch_tt,\\\n                sizeof(tname##_ch_tt) / sizeof(ASN1_TEMPLATE),\\\n                NULL,\\\n                sizeof(stname),\\\n                #stname \\\n        ASN1_ITEM_end(tname)\n\n# define ASN1_CHOICE_END_cb(stname, tname, selname) \\\n        ;\\\n        ASN1_ITEM_start(tname) \\\n                ASN1_ITYPE_CHOICE,\\\n                offsetof(stname,selname) ,\\\n                tname##_ch_tt,\\\n                sizeof(tname##_ch_tt) / sizeof(ASN1_TEMPLATE),\\\n                &tname##_aux,\\\n                sizeof(stname),\\\n                #stname \\\n        ASN1_ITEM_end(tname)\n\n/* This helps with the template wrapper form of ASN1_ITEM */\n\n# define ASN1_EX_TEMPLATE_TYPE(flags, tag, name, type) { \\\n        (flags), (tag), 0,\\\n        #name, ASN1_ITEM_ref(type) }\n\n/* These help with SEQUENCE or CHOICE components */\n\n/* used to declare other types */\n\n# define ASN1_EX_TYPE(flags, tag, stname, field, type) { \\\n        (flags), (tag), offsetof(stname, field),\\\n        #field, ASN1_ITEM_ref(type) }\n\n/* used when the structure is combined with the parent */\n\n# define ASN1_EX_COMBINE(flags, tag, type) { \\\n        (flags)|ASN1_TFLG_COMBINE, (tag), 0, NULL, ASN1_ITEM_ref(type) }\n\n/* implicit and explicit helper macros */\n\n# define ASN1_IMP_EX(stname, field, type, tag, ex) \\\n                ASN1_EX_TYPE(ASN1_TFLG_IMPLICIT | ex, tag, stname, field, type)\n\n# define ASN1_EXP_EX(stname, field, type, tag, ex) \\\n                ASN1_EX_TYPE(ASN1_TFLG_EXPLICIT | ex, tag, stname, field, type)\n\n/* Any defined by macros: the field used is in the table itself */\n\n# ifndef OPENSSL_EXPORT_VAR_AS_FUNCTION\n#  define ASN1_ADB_OBJECT(tblname) { ASN1_TFLG_ADB_OID, -1, 0, #tblname, (const ASN1_ITEM *)&(tblname##_adb) }\n#  define ASN1_ADB_INTEGER(tblname) { ASN1_TFLG_ADB_INT, -1, 0, #tblname, (const ASN1_ITEM *)&(tblname##_adb) }\n# else\n#  define ASN1_ADB_OBJECT(tblname) { ASN1_TFLG_ADB_OID, -1, 0, #tblname, tblname##_adb }\n#  define ASN1_ADB_INTEGER(tblname) { ASN1_TFLG_ADB_INT, -1, 0, #tblname, tblname##_adb }\n# endif\n/* Plain simple type */\n# define ASN1_SIMPLE(stname, field, type) ASN1_EX_TYPE(0,0, stname, field, type)\n\n/* OPTIONAL simple type */\n# define ASN1_OPT(stname, field, type) ASN1_EX_TYPE(ASN1_TFLG_OPTIONAL, 0, stname, field, type)\n\n/* IMPLICIT tagged simple type */\n# define ASN1_IMP(stname, field, type, tag) ASN1_IMP_EX(stname, field, type, tag, 0)\n\n/* IMPLICIT tagged OPTIONAL simple type */\n# define ASN1_IMP_OPT(stname, field, type, tag) ASN1_IMP_EX(stname, field, type, tag, ASN1_TFLG_OPTIONAL)\n\n/* Same as above but EXPLICIT */\n\n# define ASN1_EXP(stname, field, type, tag) ASN1_EXP_EX(stname, field, type, tag, 0)\n# define ASN1_EXP_OPT(stname, field, type, tag) ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_OPTIONAL)\n\n/* SEQUENCE OF type */\n# define ASN1_SEQUENCE_OF(stname, field, type) \\\n                ASN1_EX_TYPE(ASN1_TFLG_SEQUENCE_OF, 0, stname, field, type)\n\n/* OPTIONAL SEQUENCE OF */\n# define ASN1_SEQUENCE_OF_OPT(stname, field, type) \\\n                ASN1_EX_TYPE(ASN1_TFLG_SEQUENCE_OF|ASN1_TFLG_OPTIONAL, 0, stname, field, type)\n\n/* Same as above but for SET OF */\n\n# define ASN1_SET_OF(stname, field, type) \\\n                ASN1_EX_TYPE(ASN1_TFLG_SET_OF, 0, stname, field, type)\n\n# define ASN1_SET_OF_OPT(stname, field, type) \\\n                ASN1_EX_TYPE(ASN1_TFLG_SET_OF|ASN1_TFLG_OPTIONAL, 0, stname, field, type)\n\n/* Finally compound types of SEQUENCE, SET, IMPLICIT, EXPLICIT and OPTIONAL */\n\n# define ASN1_IMP_SET_OF(stname, field, type, tag) \\\n                        ASN1_IMP_EX(stname, field, type, tag, ASN1_TFLG_SET_OF)\n\n# define ASN1_EXP_SET_OF(stname, field, type, tag) \\\n                        ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_SET_OF)\n\n# define ASN1_IMP_SET_OF_OPT(stname, field, type, tag) \\\n                        ASN1_IMP_EX(stname, field, type, tag, ASN1_TFLG_SET_OF|ASN1_TFLG_OPTIONAL)\n\n# define ASN1_EXP_SET_OF_OPT(stname, field, type, tag) \\\n                        ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_SET_OF|ASN1_TFLG_OPTIONAL)\n\n# define ASN1_IMP_SEQUENCE_OF(stname, field, type, tag) \\\n                        ASN1_IMP_EX(stname, field, type, tag, ASN1_TFLG_SEQUENCE_OF)\n\n# define ASN1_IMP_SEQUENCE_OF_OPT(stname, field, type, tag) \\\n                        ASN1_IMP_EX(stname, field, type, tag, ASN1_TFLG_SEQUENCE_OF|ASN1_TFLG_OPTIONAL)\n\n# define ASN1_EXP_SEQUENCE_OF(stname, field, type, tag) \\\n                        ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_SEQUENCE_OF)\n\n# define ASN1_EXP_SEQUENCE_OF_OPT(stname, field, type, tag) \\\n                        ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_SEQUENCE_OF|ASN1_TFLG_OPTIONAL)\n\n/* EXPLICIT using indefinite length constructed form */\n# define ASN1_NDEF_EXP(stname, field, type, tag) \\\n                        ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_NDEF)\n\n/* EXPLICIT OPTIONAL using indefinite length constructed form */\n# define ASN1_NDEF_EXP_OPT(stname, field, type, tag) \\\n                        ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_OPTIONAL|ASN1_TFLG_NDEF)\n\n/* Macros for the ASN1_ADB structure */\n\n# define ASN1_ADB(name) \\\n        static const ASN1_ADB_TABLE name##_adbtbl[]\n\n# ifndef OPENSSL_EXPORT_VAR_AS_FUNCTION\n\n#  define ASN1_ADB_END(name, flags, field, app_table, def, none) \\\n        ;\\\n        static const ASN1_ADB name##_adb = {\\\n                flags,\\\n                offsetof(name, field),\\\n                app_table,\\\n                name##_adbtbl,\\\n                sizeof(name##_adbtbl) / sizeof(ASN1_ADB_TABLE),\\\n                def,\\\n                none\\\n        }\n\n# else\n\n#  define ASN1_ADB_END(name, flags, field, app_table, def, none) \\\n        ;\\\n        static const ASN1_ITEM *name##_adb(void) \\\n        { \\\n        static const ASN1_ADB internal_adb = \\\n                {\\\n                flags,\\\n                offsetof(name, field),\\\n                app_table,\\\n                name##_adbtbl,\\\n                sizeof(name##_adbtbl) / sizeof(ASN1_ADB_TABLE),\\\n                def,\\\n                none\\\n                }; \\\n                return (const ASN1_ITEM *) &internal_adb; \\\n        } \\\n        void dummy_function(void)\n\n# endif\n\n# define ADB_ENTRY(val, template) {val, template}\n\n# define ASN1_ADB_TEMPLATE(name) \\\n        static const ASN1_TEMPLATE name##_tt\n\n/*\n * This is the ASN1 template structure that defines a wrapper round the\n * actual type. It determines the actual position of the field in the value\n * structure, various flags such as OPTIONAL and the field name.\n */\n\nstruct ASN1_TEMPLATE_st {\n    unsigned long flags;        /* Various flags */\n    long tag;                   /* tag, not used if no tagging */\n    unsigned long offset;       /* Offset of this field in structure */\n# ifndef NO_ASN1_FIELD_NAMES\n    const char *field_name;     /* Field name */\n# endif\n    ASN1_ITEM_EXP *item;        /* Relevant ASN1_ITEM or ASN1_ADB */\n};\n\n/* Macro to extract ASN1_ITEM and ASN1_ADB pointer from ASN1_TEMPLATE */\n\n# define ASN1_TEMPLATE_item(t) (t->item_ptr)\n# define ASN1_TEMPLATE_adb(t) (t->item_ptr)\n\ntypedef struct ASN1_ADB_TABLE_st ASN1_ADB_TABLE;\ntypedef struct ASN1_ADB_st ASN1_ADB;\n\nstruct ASN1_ADB_st {\n    unsigned long flags;        /* Various flags */\n    unsigned long offset;       /* Offset of selector field */\n    STACK_OF(ASN1_ADB_TABLE) **app_items; /* Application defined items */\n    const ASN1_ADB_TABLE *tbl;  /* Table of possible types */\n    long tblcount;              /* Number of entries in tbl */\n    const ASN1_TEMPLATE *default_tt; /* Type to use if no match */\n    const ASN1_TEMPLATE *null_tt; /* Type to use if selector is NULL */\n};\n\nstruct ASN1_ADB_TABLE_st {\n    long value;                 /* NID for an object or value for an int */\n    const ASN1_TEMPLATE tt;     /* item for this value */\n};\n\n/* template flags */\n\n/* Field is optional */\n# define ASN1_TFLG_OPTIONAL      (0x1)\n\n/* Field is a SET OF */\n# define ASN1_TFLG_SET_OF        (0x1 << 1)\n\n/* Field is a SEQUENCE OF */\n# define ASN1_TFLG_SEQUENCE_OF   (0x2 << 1)\n\n/*\n * Special case: this refers to a SET OF that will be sorted into DER order\n * when encoded *and* the corresponding STACK will be modified to match the\n * new order.\n */\n# define ASN1_TFLG_SET_ORDER     (0x3 << 1)\n\n/* Mask for SET OF or SEQUENCE OF */\n# define ASN1_TFLG_SK_MASK       (0x3 << 1)\n\n/*\n * These flags mean the tag should be taken from the tag field. If EXPLICIT\n * then the underlying type is used for the inner tag.\n */\n\n/* IMPLICIT tagging */\n# define ASN1_TFLG_IMPTAG        (0x1 << 3)\n\n/* EXPLICIT tagging, inner tag from underlying type */\n# define ASN1_TFLG_EXPTAG        (0x2 << 3)\n\n# define ASN1_TFLG_TAG_MASK      (0x3 << 3)\n\n/* context specific IMPLICIT */\n# define ASN1_TFLG_IMPLICIT      ASN1_TFLG_IMPTAG|ASN1_TFLG_CONTEXT\n\n/* context specific EXPLICIT */\n# define ASN1_TFLG_EXPLICIT      ASN1_TFLG_EXPTAG|ASN1_TFLG_CONTEXT\n\n/*\n * If tagging is in force these determine the type of tag to use. Otherwise\n * the tag is determined by the underlying type. These values reflect the\n * actual octet format.\n */\n\n/* Universal tag */\n# define ASN1_TFLG_UNIVERSAL     (0x0<<6)\n/* Application tag */\n# define ASN1_TFLG_APPLICATION   (0x1<<6)\n/* Context specific tag */\n# define ASN1_TFLG_CONTEXT       (0x2<<6)\n/* Private tag */\n# define ASN1_TFLG_PRIVATE       (0x3<<6)\n\n# define ASN1_TFLG_TAG_CLASS     (0x3<<6)\n\n/*\n * These are for ANY DEFINED BY type. In this case the 'item' field points to\n * an ASN1_ADB structure which contains a table of values to decode the\n * relevant type\n */\n\n# define ASN1_TFLG_ADB_MASK      (0x3<<8)\n\n# define ASN1_TFLG_ADB_OID       (0x1<<8)\n\n# define ASN1_TFLG_ADB_INT       (0x1<<9)\n\n/*\n * This flag means a parent structure is passed instead of the field: this is\n * useful is a SEQUENCE is being combined with a CHOICE for example. Since\n * this means the structure and item name will differ we need to use the\n * ASN1_CHOICE_END_name() macro for example.\n */\n\n# define ASN1_TFLG_COMBINE       (0x1<<10)\n\n/*\n * This flag when present in a SEQUENCE OF, SET OF or EXPLICIT causes\n * indefinite length constructed encoding to be used if required.\n */\n\n# define ASN1_TFLG_NDEF          (0x1<<11)\n\n/* This is the actual ASN1 item itself */\n\nstruct ASN1_ITEM_st {\n    char itype;                 /* The item type, primitive, SEQUENCE, CHOICE\n                                 * or extern */\n    long utype;                 /* underlying type */\n    const ASN1_TEMPLATE *templates; /* If SEQUENCE or CHOICE this contains\n                                     * the contents */\n    long tcount;                /* Number of templates if SEQUENCE or CHOICE */\n    const void *funcs;          /* functions that handle this type */\n    long size;                  /* Structure size (usually) */\n# ifndef NO_ASN1_FIELD_NAMES\n    const char *sname;          /* Structure name */\n# endif\n};\n\n/*-\n * These are values for the itype field and\n * determine how the type is interpreted.\n *\n * For PRIMITIVE types the underlying type\n * determines the behaviour if items is NULL.\n *\n * Otherwise templates must contain a single\n * template and the type is treated in the\n * same way as the type specified in the template.\n *\n * For SEQUENCE types the templates field points\n * to the members, the size field is the\n * structure size.\n *\n * For CHOICE types the templates field points\n * to each possible member (typically a union)\n * and the 'size' field is the offset of the\n * selector.\n *\n * The 'funcs' field is used for application\n * specific functions.\n *\n * For COMPAT types the funcs field gives a\n * set of functions that handle this type, this\n * supports the old d2i, i2d convention.\n *\n * The EXTERN type uses a new style d2i/i2d.\n * The new style should be used where possible\n * because it avoids things like the d2i IMPLICIT\n * hack.\n *\n * MSTRING is a multiple string type, it is used\n * for a CHOICE of character strings where the\n * actual strings all occupy an ASN1_STRING\n * structure. In this case the 'utype' field\n * has a special meaning, it is used as a mask\n * of acceptable types using the B_ASN1 constants.\n *\n * NDEF_SEQUENCE is the same as SEQUENCE except\n * that it will use indefinite length constructed\n * encoding if requested.\n *\n */\n\n# define ASN1_ITYPE_PRIMITIVE            0x0\n\n# define ASN1_ITYPE_SEQUENCE             0x1\n\n# define ASN1_ITYPE_CHOICE               0x2\n\n# define ASN1_ITYPE_COMPAT               0x3\n\n# define ASN1_ITYPE_EXTERN               0x4\n\n# define ASN1_ITYPE_MSTRING              0x5\n\n# define ASN1_ITYPE_NDEF_SEQUENCE        0x6\n\n/*\n * Cache for ASN1 tag and length, so we don't keep re-reading it for things\n * like CHOICE\n */\n\nstruct ASN1_TLC_st {\n    char valid;                 /* Values below are valid */\n    int ret;                    /* return value */\n    long plen;                  /* length */\n    int ptag;                   /* class value */\n    int pclass;                 /* class value */\n    int hdrlen;                 /* header length */\n};\n\n/* Typedefs for ASN1 function pointers */\n\ntypedef ASN1_VALUE *ASN1_new_func(void);\ntypedef void ASN1_free_func(ASN1_VALUE *a);\ntypedef ASN1_VALUE *ASN1_d2i_func(ASN1_VALUE **a, const unsigned char **in,\n                                  long length);\ntypedef int ASN1_i2d_func(ASN1_VALUE *a, unsigned char **in);\n\ntypedef int ASN1_ex_d2i(ASN1_VALUE **pval, const unsigned char **in, long len,\n                        const ASN1_ITEM *it, int tag, int aclass, char opt,\n                        ASN1_TLC *ctx);\n\ntypedef int ASN1_ex_i2d(ASN1_VALUE **pval, unsigned char **out,\n                        const ASN1_ITEM *it, int tag, int aclass);\ntypedef int ASN1_ex_new_func(ASN1_VALUE **pval, const ASN1_ITEM *it);\ntypedef void ASN1_ex_free_func(ASN1_VALUE **pval, const ASN1_ITEM *it);\n\ntypedef int ASN1_ex_print_func(BIO *out, ASN1_VALUE **pval,\n                               int indent, const char *fname,\n                               const ASN1_PCTX *pctx);\n\ntypedef int ASN1_primitive_i2c(ASN1_VALUE **pval, unsigned char *cont,\n                               int *putype, const ASN1_ITEM *it);\ntypedef int ASN1_primitive_c2i(ASN1_VALUE **pval, const unsigned char *cont,\n                               int len, int utype, char *free_cont,\n                               const ASN1_ITEM *it);\ntypedef int ASN1_primitive_print(BIO *out, ASN1_VALUE **pval,\n                                 const ASN1_ITEM *it, int indent,\n                                 const ASN1_PCTX *pctx);\n\ntypedef struct ASN1_COMPAT_FUNCS_st {\n    ASN1_new_func *asn1_new;\n    ASN1_free_func *asn1_free;\n    ASN1_d2i_func *asn1_d2i;\n    ASN1_i2d_func *asn1_i2d;\n} ASN1_COMPAT_FUNCS;\n\ntypedef struct ASN1_EXTERN_FUNCS_st {\n    void *app_data;\n    ASN1_ex_new_func *asn1_ex_new;\n    ASN1_ex_free_func *asn1_ex_free;\n    ASN1_ex_free_func *asn1_ex_clear;\n    ASN1_ex_d2i *asn1_ex_d2i;\n    ASN1_ex_i2d *asn1_ex_i2d;\n    ASN1_ex_print_func *asn1_ex_print;\n} ASN1_EXTERN_FUNCS;\n\ntypedef struct ASN1_PRIMITIVE_FUNCS_st {\n    void *app_data;\n    unsigned long flags;\n    ASN1_ex_new_func *prim_new;\n    ASN1_ex_free_func *prim_free;\n    ASN1_ex_free_func *prim_clear;\n    ASN1_primitive_c2i *prim_c2i;\n    ASN1_primitive_i2c *prim_i2c;\n    ASN1_primitive_print *prim_print;\n} ASN1_PRIMITIVE_FUNCS;\n\n/*\n * This is the ASN1_AUX structure: it handles various miscellaneous\n * requirements. For example the use of reference counts and an informational\n * callback. The \"informational callback\" is called at various points during\n * the ASN1 encoding and decoding. It can be used to provide minor\n * customisation of the structures used. This is most useful where the\n * supplied routines *almost* do the right thing but need some extra help at\n * a few points. If the callback returns zero then it is assumed a fatal\n * error has occurred and the main operation should be abandoned. If major\n * changes in the default behaviour are required then an external type is\n * more appropriate.\n */\n\ntypedef int ASN1_aux_cb(int operation, ASN1_VALUE **in, const ASN1_ITEM *it,\n                        void *exarg);\n\ntypedef struct ASN1_AUX_st {\n    void *app_data;\n    int flags;\n    int ref_offset;             /* Offset of reference value */\n    int ref_lock;               /* Lock type to use */\n    ASN1_aux_cb *asn1_cb;\n    int enc_offset;             /* Offset of ASN1_ENCODING structure */\n} ASN1_AUX;\n\n/* For print related callbacks exarg points to this structure */\ntypedef struct ASN1_PRINT_ARG_st {\n    BIO *out;\n    int indent;\n    const ASN1_PCTX *pctx;\n} ASN1_PRINT_ARG;\n\n/* For streaming related callbacks exarg points to this structure */\ntypedef struct ASN1_STREAM_ARG_st {\n    /* BIO to stream through */\n    BIO *out;\n    /* BIO with filters appended */\n    BIO *ndef_bio;\n    /* Streaming I/O boundary */\n    unsigned char **boundary;\n} ASN1_STREAM_ARG;\n\n/* Flags in ASN1_AUX */\n\n/* Use a reference count */\n# define ASN1_AFLG_REFCOUNT      1\n/* Save the encoding of structure (useful for signatures) */\n# define ASN1_AFLG_ENCODING      2\n/* The Sequence length is invalid */\n# define ASN1_AFLG_BROKEN        4\n\n/* operation values for asn1_cb */\n\n# define ASN1_OP_NEW_PRE         0\n# define ASN1_OP_NEW_POST        1\n# define ASN1_OP_FREE_PRE        2\n# define ASN1_OP_FREE_POST       3\n# define ASN1_OP_D2I_PRE         4\n# define ASN1_OP_D2I_POST        5\n# define ASN1_OP_I2D_PRE         6\n# define ASN1_OP_I2D_POST        7\n# define ASN1_OP_PRINT_PRE       8\n# define ASN1_OP_PRINT_POST      9\n# define ASN1_OP_STREAM_PRE      10\n# define ASN1_OP_STREAM_POST     11\n# define ASN1_OP_DETACHED_PRE    12\n# define ASN1_OP_DETACHED_POST   13\n\n/* Macro to implement a primitive type */\n# define IMPLEMENT_ASN1_TYPE(stname) IMPLEMENT_ASN1_TYPE_ex(stname, stname, 0)\n# define IMPLEMENT_ASN1_TYPE_ex(itname, vname, ex) \\\n                                ASN1_ITEM_start(itname) \\\n                                        ASN1_ITYPE_PRIMITIVE, V_##vname, NULL, 0, NULL, ex, #itname \\\n                                ASN1_ITEM_end(itname)\n\n/* Macro to implement a multi string type */\n# define IMPLEMENT_ASN1_MSTRING(itname, mask) \\\n                                ASN1_ITEM_start(itname) \\\n                                        ASN1_ITYPE_MSTRING, mask, NULL, 0, NULL, sizeof(ASN1_STRING), #itname \\\n                                ASN1_ITEM_end(itname)\n\n/* Macro to implement an ASN1_ITEM in terms of old style funcs */\n\n# define IMPLEMENT_COMPAT_ASN1(sname) IMPLEMENT_COMPAT_ASN1_type(sname, V_ASN1_SEQUENCE)\n\n# define IMPLEMENT_COMPAT_ASN1_type(sname, tag) \\\n        static const ASN1_COMPAT_FUNCS sname##_ff = { \\\n                (ASN1_new_func *)sname##_new, \\\n                (ASN1_free_func *)sname##_free, \\\n                (ASN1_d2i_func *)d2i_##sname, \\\n                (ASN1_i2d_func *)i2d_##sname, \\\n        }; \\\n        ASN1_ITEM_start(sname) \\\n                ASN1_ITYPE_COMPAT, \\\n                tag, \\\n                NULL, \\\n                0, \\\n                &sname##_ff, \\\n                0, \\\n                #sname \\\n        ASN1_ITEM_end(sname)\n\n# define IMPLEMENT_EXTERN_ASN1(sname, tag, fptrs) \\\n        ASN1_ITEM_start(sname) \\\n                ASN1_ITYPE_EXTERN, \\\n                tag, \\\n                NULL, \\\n                0, \\\n                &fptrs, \\\n                0, \\\n                #sname \\\n        ASN1_ITEM_end(sname)\n\n/* Macro to implement standard functions in terms of ASN1_ITEM structures */\n\n# define IMPLEMENT_ASN1_FUNCTIONS(stname) IMPLEMENT_ASN1_FUNCTIONS_fname(stname, stname, stname)\n\n# define IMPLEMENT_ASN1_FUNCTIONS_name(stname, itname) IMPLEMENT_ASN1_FUNCTIONS_fname(stname, itname, itname)\n\n# define IMPLEMENT_ASN1_FUNCTIONS_ENCODE_name(stname, itname) \\\n                        IMPLEMENT_ASN1_FUNCTIONS_ENCODE_fname(stname, itname, itname)\n\n# define IMPLEMENT_STATIC_ASN1_ALLOC_FUNCTIONS(stname) \\\n                IMPLEMENT_ASN1_ALLOC_FUNCTIONS_pfname(static, stname, stname, stname)\n\n# define IMPLEMENT_ASN1_ALLOC_FUNCTIONS(stname) \\\n                IMPLEMENT_ASN1_ALLOC_FUNCTIONS_fname(stname, stname, stname)\n\n# define IMPLEMENT_ASN1_ALLOC_FUNCTIONS_pfname(pre, stname, itname, fname) \\\n        pre stname *fname##_new(void) \\\n        { \\\n                return (stname *)ASN1_item_new(ASN1_ITEM_rptr(itname)); \\\n        } \\\n        pre void fname##_free(stname *a) \\\n        { \\\n                ASN1_item_free((ASN1_VALUE *)a, ASN1_ITEM_rptr(itname)); \\\n        }\n\n# define IMPLEMENT_ASN1_ALLOC_FUNCTIONS_fname(stname, itname, fname) \\\n        stname *fname##_new(void) \\\n        { \\\n                return (stname *)ASN1_item_new(ASN1_ITEM_rptr(itname)); \\\n        } \\\n        void fname##_free(stname *a) \\\n        { \\\n                ASN1_item_free((ASN1_VALUE *)a, ASN1_ITEM_rptr(itname)); \\\n        }\n\n# define IMPLEMENT_ASN1_FUNCTIONS_fname(stname, itname, fname) \\\n        IMPLEMENT_ASN1_ENCODE_FUNCTIONS_fname(stname, itname, fname) \\\n        IMPLEMENT_ASN1_ALLOC_FUNCTIONS_fname(stname, itname, fname)\n\n# define IMPLEMENT_ASN1_ENCODE_FUNCTIONS_fname(stname, itname, fname) \\\n        stname *d2i_##fname(stname **a, const unsigned char **in, long len) \\\n        { \\\n                return (stname *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, ASN1_ITEM_rptr(itname));\\\n        } \\\n        int i2d_##fname(stname *a, unsigned char **out) \\\n        { \\\n                return ASN1_item_i2d((ASN1_VALUE *)a, out, ASN1_ITEM_rptr(itname));\\\n        }\n\n# define IMPLEMENT_ASN1_NDEF_FUNCTION(stname) \\\n        int i2d_##stname##_NDEF(stname *a, unsigned char **out) \\\n        { \\\n                return ASN1_item_ndef_i2d((ASN1_VALUE *)a, out, ASN1_ITEM_rptr(stname));\\\n        }\n\n/*\n * This includes evil casts to remove const: they will go away when full ASN1\n * constification is done.\n */\n# define IMPLEMENT_ASN1_ENCODE_FUNCTIONS_const_fname(stname, itname, fname) \\\n        stname *d2i_##fname(stname **a, const unsigned char **in, long len) \\\n        { \\\n                return (stname *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, ASN1_ITEM_rptr(itname));\\\n        } \\\n        int i2d_##fname(const stname *a, unsigned char **out) \\\n        { \\\n                return ASN1_item_i2d((ASN1_VALUE *)a, out, ASN1_ITEM_rptr(itname));\\\n        }\n\n# define IMPLEMENT_ASN1_DUP_FUNCTION(stname) \\\n        stname * stname##_dup(stname *x) \\\n        { \\\n        return ASN1_item_dup(ASN1_ITEM_rptr(stname), x); \\\n        }\n\n# define IMPLEMENT_ASN1_PRINT_FUNCTION(stname) \\\n        IMPLEMENT_ASN1_PRINT_FUNCTION_fname(stname, stname, stname)\n\n# define IMPLEMENT_ASN1_PRINT_FUNCTION_fname(stname, itname, fname) \\\n        int fname##_print_ctx(BIO *out, stname *x, int indent, \\\n                                                const ASN1_PCTX *pctx) \\\n        { \\\n                return ASN1_item_print(out, (ASN1_VALUE *)x, indent, \\\n                        ASN1_ITEM_rptr(itname), pctx); \\\n        }\n\n# define IMPLEMENT_ASN1_FUNCTIONS_const(name) \\\n                IMPLEMENT_ASN1_FUNCTIONS_const_fname(name, name, name)\n\n# define IMPLEMENT_ASN1_FUNCTIONS_const_fname(stname, itname, fname) \\\n        IMPLEMENT_ASN1_ENCODE_FUNCTIONS_const_fname(stname, itname, fname) \\\n        IMPLEMENT_ASN1_ALLOC_FUNCTIONS_fname(stname, itname, fname)\n\n/* external definitions for primitive types */\n\nDECLARE_ASN1_ITEM(ASN1_BOOLEAN)\nDECLARE_ASN1_ITEM(ASN1_TBOOLEAN)\nDECLARE_ASN1_ITEM(ASN1_FBOOLEAN)\nDECLARE_ASN1_ITEM(ASN1_SEQUENCE)\nDECLARE_ASN1_ITEM(CBIGNUM)\nDECLARE_ASN1_ITEM(BIGNUM)\nDECLARE_ASN1_ITEM(LONG)\nDECLARE_ASN1_ITEM(ZLONG)\n\nDECLARE_STACK_OF(ASN1_VALUE)\n\n/* Functions used internally by the ASN1 code */\n\nint ASN1_item_ex_new(ASN1_VALUE **pval, const ASN1_ITEM *it);\nvoid ASN1_item_ex_free(ASN1_VALUE **pval, const ASN1_ITEM *it);\nint ASN1_template_new(ASN1_VALUE **pval, const ASN1_TEMPLATE *tt);\nint ASN1_primitive_new(ASN1_VALUE **pval, const ASN1_ITEM *it);\n\nvoid ASN1_template_free(ASN1_VALUE **pval, const ASN1_TEMPLATE *tt);\nint ASN1_template_d2i(ASN1_VALUE **pval, const unsigned char **in, long len,\n                      const ASN1_TEMPLATE *tt);\nint ASN1_item_ex_d2i(ASN1_VALUE **pval, const unsigned char **in, long len,\n                     const ASN1_ITEM *it, int tag, int aclass, char opt,\n                     ASN1_TLC *ctx);\n\nint ASN1_item_ex_i2d(ASN1_VALUE **pval, unsigned char **out,\n                     const ASN1_ITEM *it, int tag, int aclass);\nint ASN1_template_i2d(ASN1_VALUE **pval, unsigned char **out,\n                      const ASN1_TEMPLATE *tt);\nvoid ASN1_primitive_free(ASN1_VALUE **pval, const ASN1_ITEM *it);\n\nint asn1_ex_i2c(ASN1_VALUE **pval, unsigned char *cont, int *putype,\n                const ASN1_ITEM *it);\nint asn1_ex_c2i(ASN1_VALUE **pval, const unsigned char *cont, int len,\n                int utype, char *free_cont, const ASN1_ITEM *it);\n\nint asn1_get_choice_selector(ASN1_VALUE **pval, const ASN1_ITEM *it);\nint asn1_set_choice_selector(ASN1_VALUE **pval, int value,\n                             const ASN1_ITEM *it);\n\nASN1_VALUE **asn1_get_field_ptr(ASN1_VALUE **pval, const ASN1_TEMPLATE *tt);\n\nconst ASN1_TEMPLATE *asn1_do_adb(ASN1_VALUE **pval, const ASN1_TEMPLATE *tt,\n                                 int nullerr);\n\nint asn1_do_lock(ASN1_VALUE **pval, int op, const ASN1_ITEM *it);\n\nvoid asn1_enc_init(ASN1_VALUE **pval, const ASN1_ITEM *it);\nvoid asn1_enc_free(ASN1_VALUE **pval, const ASN1_ITEM *it);\nint asn1_enc_restore(int *len, unsigned char **out, ASN1_VALUE **pval,\n                     const ASN1_ITEM *it);\nint asn1_enc_save(ASN1_VALUE **pval, const unsigned char *in, int inlen,\n                  const ASN1_ITEM *it);\n\n#ifdef  __cplusplus\n}\n#endif\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/arm64/include/openssl/bio.h",
    "content": "/* crypto/bio/bio.h */\n/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)\n * All rights reserved.\n *\n * This package is an SSL implementation written\n * by Eric Young (eay@cryptsoft.com).\n * The implementation was written so as to conform with Netscapes SSL.\n *\n * This library is free for commercial and non-commercial use as long as\n * the following conditions are aheared to.  The following conditions\n * apply to all code found in this distribution, be it the RC4, RSA,\n * lhash, DES, etc., code; not just the SSL code.  The SSL documentation\n * included with this distribution is covered by the same copyright terms\n * except that the holder is Tim Hudson (tjh@cryptsoft.com).\n *\n * Copyright remains Eric Young's, and as such any Copyright notices in\n * the code are not to be removed.\n * If this package is used in a product, Eric Young should be given attribution\n * as the author of the parts of the library used.\n * This can be in the form of a textual message at program startup or\n * in documentation (online or textual) provided with the package.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the copyright\n *    notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in the\n *    documentation and/or other materials provided with the distribution.\n * 3. All advertising materials mentioning features or use of this software\n *    must display the following acknowledgement:\n *    \"This product includes cryptographic software written by\n *     Eric Young (eay@cryptsoft.com)\"\n *    The word 'cryptographic' can be left out if the rouines from the library\n *    being used are not cryptographic related :-).\n * 4. If you include any Windows specific code (or a derivative thereof) from\n *    the apps directory (application code) you must include an acknowledgement:\n *    \"This product includes software written by Tim Hudson (tjh@cryptsoft.com)\"\n *\n * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n * SUCH DAMAGE.\n *\n * The licence and distribution terms for any publically available version or\n * derivative of this code cannot be changed.  i.e. this code cannot simply be\n * copied and put under another distribution licence\n * [including the GNU Public Licence.]\n */\n\n#ifndef HEADER_BIO_H\n# define HEADER_BIO_H\n\n# include <openssl/e_os2.h>\n\n# ifndef OPENSSL_NO_FP_API\n#  include <stdio.h>\n# endif\n# include <stdarg.h>\n\n# include <openssl/crypto.h>\n\n# ifndef OPENSSL_NO_SCTP\n#  ifndef OPENSSL_SYS_VMS\n#   include <stdint.h>\n#  else\n#   include <inttypes.h>\n#  endif\n# endif\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n/* These are the 'types' of BIOs */\n# define BIO_TYPE_NONE           0\n# define BIO_TYPE_MEM            (1|0x0400)\n# define BIO_TYPE_FILE           (2|0x0400)\n\n# define BIO_TYPE_FD             (4|0x0400|0x0100)\n# define BIO_TYPE_SOCKET         (5|0x0400|0x0100)\n# define BIO_TYPE_NULL           (6|0x0400)\n# define BIO_TYPE_SSL            (7|0x0200)\n# define BIO_TYPE_MD             (8|0x0200)/* passive filter */\n# define BIO_TYPE_BUFFER         (9|0x0200)/* filter */\n# define BIO_TYPE_CIPHER         (10|0x0200)/* filter */\n# define BIO_TYPE_BASE64         (11|0x0200)/* filter */\n# define BIO_TYPE_CONNECT        (12|0x0400|0x0100)/* socket - connect */\n# define BIO_TYPE_ACCEPT         (13|0x0400|0x0100)/* socket for accept */\n# define BIO_TYPE_PROXY_CLIENT   (14|0x0200)/* client proxy BIO */\n# define BIO_TYPE_PROXY_SERVER   (15|0x0200)/* server proxy BIO */\n# define BIO_TYPE_NBIO_TEST      (16|0x0200)/* server proxy BIO */\n# define BIO_TYPE_NULL_FILTER    (17|0x0200)\n# define BIO_TYPE_BER            (18|0x0200)/* BER -> bin filter */\n# define BIO_TYPE_BIO            (19|0x0400)/* (half a) BIO pair */\n# define BIO_TYPE_LINEBUFFER     (20|0x0200)/* filter */\n# define BIO_TYPE_DGRAM          (21|0x0400|0x0100)\n# ifndef OPENSSL_NO_SCTP\n#  define BIO_TYPE_DGRAM_SCTP     (24|0x0400|0x0100)\n# endif\n# define BIO_TYPE_ASN1           (22|0x0200)/* filter */\n# define BIO_TYPE_COMP           (23|0x0200)/* filter */\n\n# define BIO_TYPE_DESCRIPTOR     0x0100/* socket, fd, connect or accept */\n# define BIO_TYPE_FILTER         0x0200\n# define BIO_TYPE_SOURCE_SINK    0x0400\n\n/*\n * BIO_FILENAME_READ|BIO_CLOSE to open or close on free.\n * BIO_set_fp(in,stdin,BIO_NOCLOSE);\n */\n# define BIO_NOCLOSE             0x00\n# define BIO_CLOSE               0x01\n\n/*\n * These are used in the following macros and are passed to BIO_ctrl()\n */\n# define BIO_CTRL_RESET          1/* opt - rewind/zero etc */\n# define BIO_CTRL_EOF            2/* opt - are we at the eof */\n# define BIO_CTRL_INFO           3/* opt - extra tit-bits */\n# define BIO_CTRL_SET            4/* man - set the 'IO' type */\n# define BIO_CTRL_GET            5/* man - get the 'IO' type */\n# define BIO_CTRL_PUSH           6/* opt - internal, used to signify change */\n# define BIO_CTRL_POP            7/* opt - internal, used to signify change */\n# define BIO_CTRL_GET_CLOSE      8/* man - set the 'close' on free */\n# define BIO_CTRL_SET_CLOSE      9/* man - set the 'close' on free */\n# define BIO_CTRL_PENDING        10/* opt - is their more data buffered */\n# define BIO_CTRL_FLUSH          11/* opt - 'flush' buffered output */\n# define BIO_CTRL_DUP            12/* man - extra stuff for 'duped' BIO */\n# define BIO_CTRL_WPENDING       13/* opt - number of bytes still to write */\n/* callback is int cb(BIO *bio,state,ret); */\n# define BIO_CTRL_SET_CALLBACK   14/* opt - set callback function */\n# define BIO_CTRL_GET_CALLBACK   15/* opt - set callback function */\n\n# define BIO_CTRL_SET_FILENAME   30/* BIO_s_file special */\n\n/* dgram BIO stuff */\n# define BIO_CTRL_DGRAM_CONNECT       31/* BIO dgram special */\n# define BIO_CTRL_DGRAM_SET_CONNECTED 32/* allow for an externally connected\n                                         * socket to be passed in */\n# define BIO_CTRL_DGRAM_SET_RECV_TIMEOUT 33/* setsockopt, essentially */\n# define BIO_CTRL_DGRAM_GET_RECV_TIMEOUT 34/* getsockopt, essentially */\n# define BIO_CTRL_DGRAM_SET_SEND_TIMEOUT 35/* setsockopt, essentially */\n# define BIO_CTRL_DGRAM_GET_SEND_TIMEOUT 36/* getsockopt, essentially */\n\n# define BIO_CTRL_DGRAM_GET_RECV_TIMER_EXP 37/* flag whether the last */\n# define BIO_CTRL_DGRAM_GET_SEND_TIMER_EXP 38/* I/O operation tiemd out */\n\n/* #ifdef IP_MTU_DISCOVER */\n# define BIO_CTRL_DGRAM_MTU_DISCOVER       39/* set DF bit on egress packets */\n/* #endif */\n\n# define BIO_CTRL_DGRAM_QUERY_MTU          40/* as kernel for current MTU */\n# define BIO_CTRL_DGRAM_GET_FALLBACK_MTU   47\n# define BIO_CTRL_DGRAM_GET_MTU            41/* get cached value for MTU */\n# define BIO_CTRL_DGRAM_SET_MTU            42/* set cached value for MTU.\n                                              * want to use this if asking\n                                              * the kernel fails */\n\n# define BIO_CTRL_DGRAM_MTU_EXCEEDED       43/* check whether the MTU was\n                                              * exceed in the previous write\n                                              * operation */\n\n# define BIO_CTRL_DGRAM_GET_PEER           46\n# define BIO_CTRL_DGRAM_SET_PEER           44/* Destination for the data */\n\n# define BIO_CTRL_DGRAM_SET_NEXT_TIMEOUT   45/* Next DTLS handshake timeout\n                                              * to adjust socket timeouts */\n# define BIO_CTRL_DGRAM_SET_DONT_FRAG      48\n\n# define BIO_CTRL_DGRAM_GET_MTU_OVERHEAD   49\n\n# ifndef OPENSSL_NO_SCTP\n/* SCTP stuff */\n#  define BIO_CTRL_DGRAM_SCTP_SET_IN_HANDSHAKE    50\n#  define BIO_CTRL_DGRAM_SCTP_ADD_AUTH_KEY                51\n#  define BIO_CTRL_DGRAM_SCTP_NEXT_AUTH_KEY               52\n#  define BIO_CTRL_DGRAM_SCTP_AUTH_CCS_RCVD               53\n#  define BIO_CTRL_DGRAM_SCTP_GET_SNDINFO         60\n#  define BIO_CTRL_DGRAM_SCTP_SET_SNDINFO         61\n#  define BIO_CTRL_DGRAM_SCTP_GET_RCVINFO         62\n#  define BIO_CTRL_DGRAM_SCTP_SET_RCVINFO         63\n#  define BIO_CTRL_DGRAM_SCTP_GET_PRINFO                  64\n#  define BIO_CTRL_DGRAM_SCTP_SET_PRINFO                  65\n#  define BIO_CTRL_DGRAM_SCTP_SAVE_SHUTDOWN               70\n# endif\n\n/* modifiers */\n# define BIO_FP_READ             0x02\n# define BIO_FP_WRITE            0x04\n# define BIO_FP_APPEND           0x08\n# define BIO_FP_TEXT             0x10\n\n# define BIO_FLAGS_READ          0x01\n# define BIO_FLAGS_WRITE         0x02\n# define BIO_FLAGS_IO_SPECIAL    0x04\n# define BIO_FLAGS_RWS (BIO_FLAGS_READ|BIO_FLAGS_WRITE|BIO_FLAGS_IO_SPECIAL)\n# define BIO_FLAGS_SHOULD_RETRY  0x08\n# ifndef BIO_FLAGS_UPLINK\n/*\n * \"UPLINK\" flag denotes file descriptors provided by application. It\n * defaults to 0, as most platforms don't require UPLINK interface.\n */\n#  define BIO_FLAGS_UPLINK        0\n# endif\n\n/* Used in BIO_gethostbyname() */\n# define BIO_GHBN_CTRL_HITS              1\n# define BIO_GHBN_CTRL_MISSES            2\n# define BIO_GHBN_CTRL_CACHE_SIZE        3\n# define BIO_GHBN_CTRL_GET_ENTRY         4\n# define BIO_GHBN_CTRL_FLUSH             5\n\n/* Mostly used in the SSL BIO */\n/*-\n * Not used anymore\n * #define BIO_FLAGS_PROTOCOL_DELAYED_READ 0x10\n * #define BIO_FLAGS_PROTOCOL_DELAYED_WRITE 0x20\n * #define BIO_FLAGS_PROTOCOL_STARTUP   0x40\n */\n\n# define BIO_FLAGS_BASE64_NO_NL  0x100\n\n/*\n * This is used with memory BIOs: it means we shouldn't free up or change the\n * data in any way.\n */\n# define BIO_FLAGS_MEM_RDONLY    0x200\n\ntypedef struct bio_st BIO;\n\nvoid BIO_set_flags(BIO *b, int flags);\nint BIO_test_flags(const BIO *b, int flags);\nvoid BIO_clear_flags(BIO *b, int flags);\n\n# define BIO_get_flags(b) BIO_test_flags(b, ~(0x0))\n# define BIO_set_retry_special(b) \\\n                BIO_set_flags(b, (BIO_FLAGS_IO_SPECIAL|BIO_FLAGS_SHOULD_RETRY))\n# define BIO_set_retry_read(b) \\\n                BIO_set_flags(b, (BIO_FLAGS_READ|BIO_FLAGS_SHOULD_RETRY))\n# define BIO_set_retry_write(b) \\\n                BIO_set_flags(b, (BIO_FLAGS_WRITE|BIO_FLAGS_SHOULD_RETRY))\n\n/* These are normally used internally in BIOs */\n# define BIO_clear_retry_flags(b) \\\n                BIO_clear_flags(b, (BIO_FLAGS_RWS|BIO_FLAGS_SHOULD_RETRY))\n# define BIO_get_retry_flags(b) \\\n                BIO_test_flags(b, (BIO_FLAGS_RWS|BIO_FLAGS_SHOULD_RETRY))\n\n/* These should be used by the application to tell why we should retry */\n# define BIO_should_read(a)              BIO_test_flags(a, BIO_FLAGS_READ)\n# define BIO_should_write(a)             BIO_test_flags(a, BIO_FLAGS_WRITE)\n# define BIO_should_io_special(a)        BIO_test_flags(a, BIO_FLAGS_IO_SPECIAL)\n# define BIO_retry_type(a)               BIO_test_flags(a, BIO_FLAGS_RWS)\n# define BIO_should_retry(a)             BIO_test_flags(a, BIO_FLAGS_SHOULD_RETRY)\n\n/*\n * The next three are used in conjunction with the BIO_should_io_special()\n * condition.  After this returns true, BIO *BIO_get_retry_BIO(BIO *bio, int\n * *reason); will walk the BIO stack and return the 'reason' for the special\n * and the offending BIO. Given a BIO, BIO_get_retry_reason(bio) will return\n * the code.\n */\n/*\n * Returned from the SSL bio when the certificate retrieval code had an error\n */\n# define BIO_RR_SSL_X509_LOOKUP          0x01\n/* Returned from the connect BIO when a connect would have blocked */\n# define BIO_RR_CONNECT                  0x02\n/* Returned from the accept BIO when an accept would have blocked */\n# define BIO_RR_ACCEPT                   0x03\n\n/* These are passed by the BIO callback */\n# define BIO_CB_FREE     0x01\n# define BIO_CB_READ     0x02\n# define BIO_CB_WRITE    0x03\n# define BIO_CB_PUTS     0x04\n# define BIO_CB_GETS     0x05\n# define BIO_CB_CTRL     0x06\n\n/*\n * The callback is called before and after the underling operation, The\n * BIO_CB_RETURN flag indicates if it is after the call\n */\n# define BIO_CB_RETURN   0x80\n# define BIO_CB_return(a) ((a)|BIO_CB_RETURN)\n# define BIO_cb_pre(a)   (!((a)&BIO_CB_RETURN))\n# define BIO_cb_post(a)  ((a)&BIO_CB_RETURN)\n\nlong (*BIO_get_callback(const BIO *b)) (struct bio_st *, int, const char *,\n                                        int, long, long);\nvoid BIO_set_callback(BIO *b,\n                      long (*callback) (struct bio_st *, int, const char *,\n                                        int, long, long));\nchar *BIO_get_callback_arg(const BIO *b);\nvoid BIO_set_callback_arg(BIO *b, char *arg);\n\nconst char *BIO_method_name(const BIO *b);\nint BIO_method_type(const BIO *b);\n\ntypedef void bio_info_cb (struct bio_st *, int, const char *, int, long,\n                          long);\n\ntypedef struct bio_method_st {\n    int type;\n    const char *name;\n    int (*bwrite) (BIO *, const char *, int);\n    int (*bread) (BIO *, char *, int);\n    int (*bputs) (BIO *, const char *);\n    int (*bgets) (BIO *, char *, int);\n    long (*ctrl) (BIO *, int, long, void *);\n    int (*create) (BIO *);\n    int (*destroy) (BIO *);\n    long (*callback_ctrl) (BIO *, int, bio_info_cb *);\n} BIO_METHOD;\n\nstruct bio_st {\n    BIO_METHOD *method;\n    /* bio, mode, argp, argi, argl, ret */\n    long (*callback) (struct bio_st *, int, const char *, int, long, long);\n    char *cb_arg;               /* first argument for the callback */\n    int init;\n    int shutdown;\n    int flags;                  /* extra storage */\n    int retry_reason;\n    int num;\n    void *ptr;\n    struct bio_st *next_bio;    /* used by filter BIOs */\n    struct bio_st *prev_bio;    /* used by filter BIOs */\n    int references;\n    unsigned long num_read;\n    unsigned long num_write;\n    CRYPTO_EX_DATA ex_data;\n};\n\nDECLARE_STACK_OF(BIO)\n\ntypedef struct bio_f_buffer_ctx_struct {\n    /*-\n     * Buffers are setup like this:\n     *\n     * <---------------------- size ----------------------->\n     * +---------------------------------------------------+\n     * | consumed | remaining          | free space        |\n     * +---------------------------------------------------+\n     * <-- off --><------- len ------->\n     */\n    /*- BIO *bio; *//*\n     * this is now in the BIO struct\n     */\n    int ibuf_size;              /* how big is the input buffer */\n    int obuf_size;              /* how big is the output buffer */\n    char *ibuf;                 /* the char array */\n    int ibuf_len;               /* how many bytes are in it */\n    int ibuf_off;               /* write/read offset */\n    char *obuf;                 /* the char array */\n    int obuf_len;               /* how many bytes are in it */\n    int obuf_off;               /* write/read offset */\n} BIO_F_BUFFER_CTX;\n\n/* Prefix and suffix callback in ASN1 BIO */\ntypedef int asn1_ps_func (BIO *b, unsigned char **pbuf, int *plen,\n                          void *parg);\n\n# ifndef OPENSSL_NO_SCTP\n/* SCTP parameter structs */\nstruct bio_dgram_sctp_sndinfo {\n    uint16_t snd_sid;\n    uint16_t snd_flags;\n    uint32_t snd_ppid;\n    uint32_t snd_context;\n};\n\nstruct bio_dgram_sctp_rcvinfo {\n    uint16_t rcv_sid;\n    uint16_t rcv_ssn;\n    uint16_t rcv_flags;\n    uint32_t rcv_ppid;\n    uint32_t rcv_tsn;\n    uint32_t rcv_cumtsn;\n    uint32_t rcv_context;\n};\n\nstruct bio_dgram_sctp_prinfo {\n    uint16_t pr_policy;\n    uint32_t pr_value;\n};\n# endif\n\n/* connect BIO stuff */\n# define BIO_CONN_S_BEFORE               1\n# define BIO_CONN_S_GET_IP               2\n# define BIO_CONN_S_GET_PORT             3\n# define BIO_CONN_S_CREATE_SOCKET        4\n# define BIO_CONN_S_CONNECT              5\n# define BIO_CONN_S_OK                   6\n# define BIO_CONN_S_BLOCKED_CONNECT      7\n# define BIO_CONN_S_NBIO                 8\n/*\n * #define BIO_CONN_get_param_hostname BIO_ctrl\n */\n\n# define BIO_C_SET_CONNECT                       100\n# define BIO_C_DO_STATE_MACHINE                  101\n# define BIO_C_SET_NBIO                          102\n# define BIO_C_SET_PROXY_PARAM                   103\n# define BIO_C_SET_FD                            104\n# define BIO_C_GET_FD                            105\n# define BIO_C_SET_FILE_PTR                      106\n# define BIO_C_GET_FILE_PTR                      107\n# define BIO_C_SET_FILENAME                      108\n# define BIO_C_SET_SSL                           109\n# define BIO_C_GET_SSL                           110\n# define BIO_C_SET_MD                            111\n# define BIO_C_GET_MD                            112\n# define BIO_C_GET_CIPHER_STATUS                 113\n# define BIO_C_SET_BUF_MEM                       114\n# define BIO_C_GET_BUF_MEM_PTR                   115\n# define BIO_C_GET_BUFF_NUM_LINES                116\n# define BIO_C_SET_BUFF_SIZE                     117\n# define BIO_C_SET_ACCEPT                        118\n# define BIO_C_SSL_MODE                          119\n# define BIO_C_GET_MD_CTX                        120\n# define BIO_C_GET_PROXY_PARAM                   121\n# define BIO_C_SET_BUFF_READ_DATA                122/* data to read first */\n# define BIO_C_GET_CONNECT                       123\n# define BIO_C_GET_ACCEPT                        124\n# define BIO_C_SET_SSL_RENEGOTIATE_BYTES         125\n# define BIO_C_GET_SSL_NUM_RENEGOTIATES          126\n# define BIO_C_SET_SSL_RENEGOTIATE_TIMEOUT       127\n# define BIO_C_FILE_SEEK                         128\n# define BIO_C_GET_CIPHER_CTX                    129\n# define BIO_C_SET_BUF_MEM_EOF_RETURN            130/* return end of input\n                                                     * value */\n# define BIO_C_SET_BIND_MODE                     131\n# define BIO_C_GET_BIND_MODE                     132\n# define BIO_C_FILE_TELL                         133\n# define BIO_C_GET_SOCKS                         134\n# define BIO_C_SET_SOCKS                         135\n\n# define BIO_C_SET_WRITE_BUF_SIZE                136/* for BIO_s_bio */\n# define BIO_C_GET_WRITE_BUF_SIZE                137\n# define BIO_C_MAKE_BIO_PAIR                     138\n# define BIO_C_DESTROY_BIO_PAIR                  139\n# define BIO_C_GET_WRITE_GUARANTEE               140\n# define BIO_C_GET_READ_REQUEST                  141\n# define BIO_C_SHUTDOWN_WR                       142\n# define BIO_C_NREAD0                            143\n# define BIO_C_NREAD                             144\n# define BIO_C_NWRITE0                           145\n# define BIO_C_NWRITE                            146\n# define BIO_C_RESET_READ_REQUEST                147\n# define BIO_C_SET_MD_CTX                        148\n\n# define BIO_C_SET_PREFIX                        149\n# define BIO_C_GET_PREFIX                        150\n# define BIO_C_SET_SUFFIX                        151\n# define BIO_C_GET_SUFFIX                        152\n\n# define BIO_C_SET_EX_ARG                        153\n# define BIO_C_GET_EX_ARG                        154\n\n# define BIO_set_app_data(s,arg)         BIO_set_ex_data(s,0,arg)\n# define BIO_get_app_data(s)             BIO_get_ex_data(s,0)\n\n/* BIO_s_connect() and BIO_s_socks4a_connect() */\n# define BIO_set_conn_hostname(b,name) BIO_ctrl(b,BIO_C_SET_CONNECT,0,(char *)name)\n# define BIO_set_conn_port(b,port) BIO_ctrl(b,BIO_C_SET_CONNECT,1,(char *)port)\n# define BIO_set_conn_ip(b,ip)     BIO_ctrl(b,BIO_C_SET_CONNECT,2,(char *)ip)\n# define BIO_set_conn_int_port(b,port) BIO_ctrl(b,BIO_C_SET_CONNECT,3,(char *)port)\n# define BIO_get_conn_hostname(b)  BIO_ptr_ctrl(b,BIO_C_GET_CONNECT,0)\n# define BIO_get_conn_port(b)      BIO_ptr_ctrl(b,BIO_C_GET_CONNECT,1)\n# define BIO_get_conn_ip(b)               BIO_ptr_ctrl(b,BIO_C_GET_CONNECT,2)\n# define BIO_get_conn_int_port(b) BIO_ctrl(b,BIO_C_GET_CONNECT,3,NULL)\n\n# define BIO_set_nbio(b,n)       BIO_ctrl(b,BIO_C_SET_NBIO,(n),NULL)\n\n/* BIO_s_accept() */\n# define BIO_set_accept_port(b,name) BIO_ctrl(b,BIO_C_SET_ACCEPT,0,(char *)name)\n# define BIO_get_accept_port(b)  BIO_ptr_ctrl(b,BIO_C_GET_ACCEPT,0)\n/* #define BIO_set_nbio(b,n)    BIO_ctrl(b,BIO_C_SET_NBIO,(n),NULL) */\n# define BIO_set_nbio_accept(b,n) BIO_ctrl(b,BIO_C_SET_ACCEPT,1,(n)?(void *)\"a\":NULL)\n# define BIO_set_accept_bios(b,bio) BIO_ctrl(b,BIO_C_SET_ACCEPT,2,(char *)bio)\n\n# define BIO_BIND_NORMAL                 0\n# define BIO_BIND_REUSEADDR_IF_UNUSED    1\n# define BIO_BIND_REUSEADDR              2\n# define BIO_set_bind_mode(b,mode) BIO_ctrl(b,BIO_C_SET_BIND_MODE,mode,NULL)\n# define BIO_get_bind_mode(b,mode) BIO_ctrl(b,BIO_C_GET_BIND_MODE,0,NULL)\n\n/* BIO_s_accept() and BIO_s_connect() */\n# define BIO_do_connect(b)       BIO_do_handshake(b)\n# define BIO_do_accept(b)        BIO_do_handshake(b)\n# define BIO_do_handshake(b)     BIO_ctrl(b,BIO_C_DO_STATE_MACHINE,0,NULL)\n\n/* BIO_s_proxy_client() */\n# define BIO_set_url(b,url)      BIO_ctrl(b,BIO_C_SET_PROXY_PARAM,0,(char *)(url))\n# define BIO_set_proxies(b,p)    BIO_ctrl(b,BIO_C_SET_PROXY_PARAM,1,(char *)(p))\n/* BIO_set_nbio(b,n) */\n# define BIO_set_filter_bio(b,s) BIO_ctrl(b,BIO_C_SET_PROXY_PARAM,2,(char *)(s))\n/* BIO *BIO_get_filter_bio(BIO *bio); */\n# define BIO_set_proxy_cb(b,cb) BIO_callback_ctrl(b,BIO_C_SET_PROXY_PARAM,3,(void *(*cb)()))\n# define BIO_set_proxy_header(b,sk) BIO_ctrl(b,BIO_C_SET_PROXY_PARAM,4,(char *)sk)\n# define BIO_set_no_connect_return(b,bool) BIO_int_ctrl(b,BIO_C_SET_PROXY_PARAM,5,bool)\n\n# define BIO_get_proxy_header(b,skp) BIO_ctrl(b,BIO_C_GET_PROXY_PARAM,0,(char *)skp)\n# define BIO_get_proxies(b,pxy_p) BIO_ctrl(b,BIO_C_GET_PROXY_PARAM,1,(char *)(pxy_p))\n# define BIO_get_url(b,url)      BIO_ctrl(b,BIO_C_GET_PROXY_PARAM,2,(char *)(url))\n# define BIO_get_no_connect_return(b)    BIO_ctrl(b,BIO_C_GET_PROXY_PARAM,5,NULL)\n\n/* BIO_s_datagram(), BIO_s_fd(), BIO_s_socket(), BIO_s_accept() and BIO_s_connect() */\n# define BIO_set_fd(b,fd,c)      BIO_int_ctrl(b,BIO_C_SET_FD,c,fd)\n# define BIO_get_fd(b,c)         BIO_ctrl(b,BIO_C_GET_FD,0,(char *)c)\n\n/* BIO_s_file() */\n# define BIO_set_fp(b,fp,c)      BIO_ctrl(b,BIO_C_SET_FILE_PTR,c,(char *)fp)\n# define BIO_get_fp(b,fpp)       BIO_ctrl(b,BIO_C_GET_FILE_PTR,0,(char *)fpp)\n\n/* BIO_s_fd() and BIO_s_file() */\n# define BIO_seek(b,ofs) (int)BIO_ctrl(b,BIO_C_FILE_SEEK,ofs,NULL)\n# define BIO_tell(b)     (int)BIO_ctrl(b,BIO_C_FILE_TELL,0,NULL)\n\n/*\n * name is cast to lose const, but might be better to route through a\n * function so we can do it safely\n */\n# ifdef CONST_STRICT\n/*\n * If you are wondering why this isn't defined, its because CONST_STRICT is\n * purely a compile-time kludge to allow const to be checked.\n */\nint BIO_read_filename(BIO *b, const char *name);\n# else\n#  define BIO_read_filename(b,name) BIO_ctrl(b,BIO_C_SET_FILENAME, \\\n                BIO_CLOSE|BIO_FP_READ,(char *)name)\n# endif\n# define BIO_write_filename(b,name) BIO_ctrl(b,BIO_C_SET_FILENAME, \\\n                BIO_CLOSE|BIO_FP_WRITE,name)\n# define BIO_append_filename(b,name) BIO_ctrl(b,BIO_C_SET_FILENAME, \\\n                BIO_CLOSE|BIO_FP_APPEND,name)\n# define BIO_rw_filename(b,name) BIO_ctrl(b,BIO_C_SET_FILENAME, \\\n                BIO_CLOSE|BIO_FP_READ|BIO_FP_WRITE,name)\n\n/*\n * WARNING WARNING, this ups the reference count on the read bio of the SSL\n * structure.  This is because the ssl read BIO is now pointed to by the\n * next_bio field in the bio.  So when you free the BIO, make sure you are\n * doing a BIO_free_all() to catch the underlying BIO.\n */\n# define BIO_set_ssl(b,ssl,c)    BIO_ctrl(b,BIO_C_SET_SSL,c,(char *)ssl)\n# define BIO_get_ssl(b,sslp)     BIO_ctrl(b,BIO_C_GET_SSL,0,(char *)sslp)\n# define BIO_set_ssl_mode(b,client)      BIO_ctrl(b,BIO_C_SSL_MODE,client,NULL)\n# define BIO_set_ssl_renegotiate_bytes(b,num) \\\n        BIO_ctrl(b,BIO_C_SET_SSL_RENEGOTIATE_BYTES,num,NULL)\n# define BIO_get_num_renegotiates(b) \\\n        BIO_ctrl(b,BIO_C_GET_SSL_NUM_RENEGOTIATES,0,NULL)\n# define BIO_set_ssl_renegotiate_timeout(b,seconds) \\\n        BIO_ctrl(b,BIO_C_SET_SSL_RENEGOTIATE_TIMEOUT,seconds,NULL)\n\n/* defined in evp.h */\n/* #define BIO_set_md(b,md)     BIO_ctrl(b,BIO_C_SET_MD,1,(char *)md) */\n\n# define BIO_get_mem_data(b,pp)  BIO_ctrl(b,BIO_CTRL_INFO,0,(char *)pp)\n# define BIO_set_mem_buf(b,bm,c) BIO_ctrl(b,BIO_C_SET_BUF_MEM,c,(char *)bm)\n# define BIO_get_mem_ptr(b,pp)   BIO_ctrl(b,BIO_C_GET_BUF_MEM_PTR,0,(char *)pp)\n# define BIO_set_mem_eof_return(b,v) \\\n                                BIO_ctrl(b,BIO_C_SET_BUF_MEM_EOF_RETURN,v,NULL)\n\n/* For the BIO_f_buffer() type */\n# define BIO_get_buffer_num_lines(b)     BIO_ctrl(b,BIO_C_GET_BUFF_NUM_LINES,0,NULL)\n# define BIO_set_buffer_size(b,size)     BIO_ctrl(b,BIO_C_SET_BUFF_SIZE,size,NULL)\n# define BIO_set_read_buffer_size(b,size) BIO_int_ctrl(b,BIO_C_SET_BUFF_SIZE,size,0)\n# define BIO_set_write_buffer_size(b,size) BIO_int_ctrl(b,BIO_C_SET_BUFF_SIZE,size,1)\n# define BIO_set_buffer_read_data(b,buf,num) BIO_ctrl(b,BIO_C_SET_BUFF_READ_DATA,num,buf)\n\n/* Don't use the next one unless you know what you are doing :-) */\n# define BIO_dup_state(b,ret)    BIO_ctrl(b,BIO_CTRL_DUP,0,(char *)(ret))\n\n# define BIO_reset(b)            (int)BIO_ctrl(b,BIO_CTRL_RESET,0,NULL)\n# define BIO_eof(b)              (int)BIO_ctrl(b,BIO_CTRL_EOF,0,NULL)\n# define BIO_set_close(b,c)      (int)BIO_ctrl(b,BIO_CTRL_SET_CLOSE,(c),NULL)\n# define BIO_get_close(b)        (int)BIO_ctrl(b,BIO_CTRL_GET_CLOSE,0,NULL)\n# define BIO_pending(b)          (int)BIO_ctrl(b,BIO_CTRL_PENDING,0,NULL)\n# define BIO_wpending(b)         (int)BIO_ctrl(b,BIO_CTRL_WPENDING,0,NULL)\n/* ...pending macros have inappropriate return type */\nsize_t BIO_ctrl_pending(BIO *b);\nsize_t BIO_ctrl_wpending(BIO *b);\n# define BIO_flush(b)            (int)BIO_ctrl(b,BIO_CTRL_FLUSH,0,NULL)\n# define BIO_get_info_callback(b,cbp) (int)BIO_ctrl(b,BIO_CTRL_GET_CALLBACK,0, \\\n                                                   cbp)\n# define BIO_set_info_callback(b,cb) (int)BIO_callback_ctrl(b,BIO_CTRL_SET_CALLBACK,cb)\n\n/* For the BIO_f_buffer() type */\n# define BIO_buffer_get_num_lines(b) BIO_ctrl(b,BIO_CTRL_GET,0,NULL)\n\n/* For BIO_s_bio() */\n# define BIO_set_write_buf_size(b,size) (int)BIO_ctrl(b,BIO_C_SET_WRITE_BUF_SIZE,size,NULL)\n# define BIO_get_write_buf_size(b,size) (size_t)BIO_ctrl(b,BIO_C_GET_WRITE_BUF_SIZE,size,NULL)\n# define BIO_make_bio_pair(b1,b2)   (int)BIO_ctrl(b1,BIO_C_MAKE_BIO_PAIR,0,b2)\n# define BIO_destroy_bio_pair(b)    (int)BIO_ctrl(b,BIO_C_DESTROY_BIO_PAIR,0,NULL)\n# define BIO_shutdown_wr(b) (int)BIO_ctrl(b, BIO_C_SHUTDOWN_WR, 0, NULL)\n/* macros with inappropriate type -- but ...pending macros use int too: */\n# define BIO_get_write_guarantee(b) (int)BIO_ctrl(b,BIO_C_GET_WRITE_GUARANTEE,0,NULL)\n# define BIO_get_read_request(b)    (int)BIO_ctrl(b,BIO_C_GET_READ_REQUEST,0,NULL)\nsize_t BIO_ctrl_get_write_guarantee(BIO *b);\nsize_t BIO_ctrl_get_read_request(BIO *b);\nint BIO_ctrl_reset_read_request(BIO *b);\n\n/* ctrl macros for dgram */\n# define BIO_ctrl_dgram_connect(b,peer)  \\\n                     (int)BIO_ctrl(b,BIO_CTRL_DGRAM_CONNECT,0, (char *)peer)\n# define BIO_ctrl_set_connected(b, state, peer) \\\n         (int)BIO_ctrl(b, BIO_CTRL_DGRAM_SET_CONNECTED, state, (char *)peer)\n# define BIO_dgram_recv_timedout(b) \\\n         (int)BIO_ctrl(b, BIO_CTRL_DGRAM_GET_RECV_TIMER_EXP, 0, NULL)\n# define BIO_dgram_send_timedout(b) \\\n         (int)BIO_ctrl(b, BIO_CTRL_DGRAM_GET_SEND_TIMER_EXP, 0, NULL)\n# define BIO_dgram_get_peer(b,peer) \\\n         (int)BIO_ctrl(b, BIO_CTRL_DGRAM_GET_PEER, 0, (char *)peer)\n# define BIO_dgram_set_peer(b,peer) \\\n         (int)BIO_ctrl(b, BIO_CTRL_DGRAM_SET_PEER, 0, (char *)peer)\n# define BIO_dgram_get_mtu_overhead(b) \\\n         (unsigned int)BIO_ctrl((b), BIO_CTRL_DGRAM_GET_MTU_OVERHEAD, 0, NULL)\n\n/* These two aren't currently implemented */\n/* int BIO_get_ex_num(BIO *bio); */\n/* void BIO_set_ex_free_func(BIO *bio,int idx,void (*cb)()); */\nint BIO_set_ex_data(BIO *bio, int idx, void *data);\nvoid *BIO_get_ex_data(BIO *bio, int idx);\nint BIO_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func,\n                         CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func);\nunsigned long BIO_number_read(BIO *bio);\nunsigned long BIO_number_written(BIO *bio);\n\n/* For BIO_f_asn1() */\nint BIO_asn1_set_prefix(BIO *b, asn1_ps_func *prefix,\n                        asn1_ps_func *prefix_free);\nint BIO_asn1_get_prefix(BIO *b, asn1_ps_func **pprefix,\n                        asn1_ps_func **pprefix_free);\nint BIO_asn1_set_suffix(BIO *b, asn1_ps_func *suffix,\n                        asn1_ps_func *suffix_free);\nint BIO_asn1_get_suffix(BIO *b, asn1_ps_func **psuffix,\n                        asn1_ps_func **psuffix_free);\n\n# ifndef OPENSSL_NO_FP_API\nBIO_METHOD *BIO_s_file(void);\nBIO *BIO_new_file(const char *filename, const char *mode);\nBIO *BIO_new_fp(FILE *stream, int close_flag);\n#  define BIO_s_file_internal    BIO_s_file\n# endif\nBIO *BIO_new(BIO_METHOD *type);\nint BIO_set(BIO *a, BIO_METHOD *type);\nint BIO_free(BIO *a);\nvoid BIO_vfree(BIO *a);\nint BIO_read(BIO *b, void *data, int len);\nint BIO_gets(BIO *bp, char *buf, int size);\nint BIO_write(BIO *b, const void *data, int len);\nint BIO_puts(BIO *bp, const char *buf);\nint BIO_indent(BIO *b, int indent, int max);\nlong BIO_ctrl(BIO *bp, int cmd, long larg, void *parg);\nlong BIO_callback_ctrl(BIO *b, int cmd,\n                       void (*fp) (struct bio_st *, int, const char *, int,\n                                   long, long));\nchar *BIO_ptr_ctrl(BIO *bp, int cmd, long larg);\nlong BIO_int_ctrl(BIO *bp, int cmd, long larg, int iarg);\nBIO *BIO_push(BIO *b, BIO *append);\nBIO *BIO_pop(BIO *b);\nvoid BIO_free_all(BIO *a);\nBIO *BIO_find_type(BIO *b, int bio_type);\nBIO *BIO_next(BIO *b);\nBIO *BIO_get_retry_BIO(BIO *bio, int *reason);\nint BIO_get_retry_reason(BIO *bio);\nBIO *BIO_dup_chain(BIO *in);\n\nint BIO_nread0(BIO *bio, char **buf);\nint BIO_nread(BIO *bio, char **buf, int num);\nint BIO_nwrite0(BIO *bio, char **buf);\nint BIO_nwrite(BIO *bio, char **buf, int num);\n\nlong BIO_debug_callback(BIO *bio, int cmd, const char *argp, int argi,\n                        long argl, long ret);\n\nBIO_METHOD *BIO_s_mem(void);\nBIO *BIO_new_mem_buf(const void *buf, int len);\nBIO_METHOD *BIO_s_socket(void);\nBIO_METHOD *BIO_s_connect(void);\nBIO_METHOD *BIO_s_accept(void);\nBIO_METHOD *BIO_s_fd(void);\n# ifndef OPENSSL_SYS_OS2\nBIO_METHOD *BIO_s_log(void);\n# endif\nBIO_METHOD *BIO_s_bio(void);\nBIO_METHOD *BIO_s_null(void);\nBIO_METHOD *BIO_f_null(void);\nBIO_METHOD *BIO_f_buffer(void);\n# ifdef OPENSSL_SYS_VMS\nBIO_METHOD *BIO_f_linebuffer(void);\n# endif\nBIO_METHOD *BIO_f_nbio_test(void);\n# ifndef OPENSSL_NO_DGRAM\nBIO_METHOD *BIO_s_datagram(void);\n#  ifndef OPENSSL_NO_SCTP\nBIO_METHOD *BIO_s_datagram_sctp(void);\n#  endif\n# endif\n\n/* BIO_METHOD *BIO_f_ber(void); */\n\nint BIO_sock_should_retry(int i);\nint BIO_sock_non_fatal_error(int error);\nint BIO_dgram_non_fatal_error(int error);\n\nint BIO_fd_should_retry(int i);\nint BIO_fd_non_fatal_error(int error);\nint BIO_dump_cb(int (*cb) (const void *data, size_t len, void *u),\n                void *u, const char *s, int len);\nint BIO_dump_indent_cb(int (*cb) (const void *data, size_t len, void *u),\n                       void *u, const char *s, int len, int indent);\nint BIO_dump(BIO *b, const char *bytes, int len);\nint BIO_dump_indent(BIO *b, const char *bytes, int len, int indent);\n# ifndef OPENSSL_NO_FP_API\nint BIO_dump_fp(FILE *fp, const char *s, int len);\nint BIO_dump_indent_fp(FILE *fp, const char *s, int len, int indent);\n# endif\nint BIO_hex_string(BIO *out, int indent, int width, unsigned char *data,\n                   int datalen);\n\nstruct hostent *BIO_gethostbyname(const char *name);\n/*-\n * We might want a thread-safe interface too:\n * struct hostent *BIO_gethostbyname_r(const char *name,\n *     struct hostent *result, void *buffer, size_t buflen);\n * or something similar (caller allocates a struct hostent,\n * pointed to by \"result\", and additional buffer space for the various\n * substructures; if the buffer does not suffice, NULL is returned\n * and an appropriate error code is set).\n */\nint BIO_sock_error(int sock);\nint BIO_socket_ioctl(int fd, long type, void *arg);\nint BIO_socket_nbio(int fd, int mode);\nint BIO_get_port(const char *str, unsigned short *port_ptr);\nint BIO_get_host_ip(const char *str, unsigned char *ip);\nint BIO_get_accept_socket(char *host_port, int mode);\nint BIO_accept(int sock, char **ip_port);\nint BIO_sock_init(void);\nvoid BIO_sock_cleanup(void);\nint BIO_set_tcp_ndelay(int sock, int turn_on);\n\nBIO *BIO_new_socket(int sock, int close_flag);\nBIO *BIO_new_dgram(int fd, int close_flag);\n# ifndef OPENSSL_NO_SCTP\nBIO *BIO_new_dgram_sctp(int fd, int close_flag);\nint BIO_dgram_is_sctp(BIO *bio);\nint BIO_dgram_sctp_notification_cb(BIO *b,\n                                   void (*handle_notifications) (BIO *bio,\n                                                                 void\n                                                                 *context,\n                                                                 void *buf),\n                                   void *context);\nint BIO_dgram_sctp_wait_for_dry(BIO *b);\nint BIO_dgram_sctp_msg_waiting(BIO *b);\n# endif\nBIO *BIO_new_fd(int fd, int close_flag);\nBIO *BIO_new_connect(const char *host_port);\nBIO *BIO_new_accept(const char *host_port);\n\nint BIO_new_bio_pair(BIO **bio1, size_t writebuf1,\n                     BIO **bio2, size_t writebuf2);\n/*\n * If successful, returns 1 and in *bio1, *bio2 two BIO pair endpoints.\n * Otherwise returns 0 and sets *bio1 and *bio2 to NULL. Size 0 uses default\n * value.\n */\n\nvoid BIO_copy_next_retry(BIO *b);\n\n/*\n * long BIO_ghbn_ctrl(int cmd,int iarg,char *parg);\n */\n\n# ifdef __GNUC__\n#  define __bio_h__attr__ __attribute__\n# else\n#  define __bio_h__attr__(x)\n# endif\nint BIO_printf(BIO *bio, const char *format, ...)\n__bio_h__attr__((__format__(__printf__, 2, 3)));\nint BIO_vprintf(BIO *bio, const char *format, va_list args)\n__bio_h__attr__((__format__(__printf__, 2, 0)));\nint BIO_snprintf(char *buf, size_t n, const char *format, ...)\n__bio_h__attr__((__format__(__printf__, 3, 4)));\nint BIO_vsnprintf(char *buf, size_t n, const char *format, va_list args)\n__bio_h__attr__((__format__(__printf__, 3, 0)));\n# undef __bio_h__attr__\n\n/* BEGIN ERROR CODES */\n/*\n * The following lines are auto generated by the script mkerr.pl. Any changes\n * made after this point may be overwritten when the script is next run.\n */\nvoid ERR_load_BIO_strings(void);\n\n/* Error codes for the BIO functions. */\n\n/* Function codes. */\n# define BIO_F_ACPT_STATE                                 100\n# define BIO_F_BIO_ACCEPT                                 101\n# define BIO_F_BIO_BER_GET_HEADER                         102\n# define BIO_F_BIO_CALLBACK_CTRL                          131\n# define BIO_F_BIO_CTRL                                   103\n# define BIO_F_BIO_GETHOSTBYNAME                          120\n# define BIO_F_BIO_GETS                                   104\n# define BIO_F_BIO_GET_ACCEPT_SOCKET                      105\n# define BIO_F_BIO_GET_HOST_IP                            106\n# define BIO_F_BIO_GET_PORT                               107\n# define BIO_F_BIO_MAKE_PAIR                              121\n# define BIO_F_BIO_NEW                                    108\n# define BIO_F_BIO_NEW_FILE                               109\n# define BIO_F_BIO_NEW_MEM_BUF                            126\n# define BIO_F_BIO_NREAD                                  123\n# define BIO_F_BIO_NREAD0                                 124\n# define BIO_F_BIO_NWRITE                                 125\n# define BIO_F_BIO_NWRITE0                                122\n# define BIO_F_BIO_PUTS                                   110\n# define BIO_F_BIO_READ                                   111\n# define BIO_F_BIO_SOCK_INIT                              112\n# define BIO_F_BIO_WRITE                                  113\n# define BIO_F_BUFFER_CTRL                                114\n# define BIO_F_CONN_CTRL                                  127\n# define BIO_F_CONN_STATE                                 115\n# define BIO_F_DGRAM_SCTP_READ                            132\n# define BIO_F_DGRAM_SCTP_WRITE                           133\n# define BIO_F_FILE_CTRL                                  116\n# define BIO_F_FILE_READ                                  130\n# define BIO_F_LINEBUFFER_CTRL                            129\n# define BIO_F_MEM_READ                                   128\n# define BIO_F_MEM_WRITE                                  117\n# define BIO_F_SSL_NEW                                    118\n# define BIO_F_WSASTARTUP                                 119\n\n/* Reason codes. */\n# define BIO_R_ACCEPT_ERROR                               100\n# define BIO_R_BAD_FOPEN_MODE                             101\n# define BIO_R_BAD_HOSTNAME_LOOKUP                        102\n# define BIO_R_BROKEN_PIPE                                124\n# define BIO_R_CONNECT_ERROR                              103\n# define BIO_R_EOF_ON_MEMORY_BIO                          127\n# define BIO_R_ERROR_SETTING_NBIO                         104\n# define BIO_R_ERROR_SETTING_NBIO_ON_ACCEPTED_SOCKET      105\n# define BIO_R_ERROR_SETTING_NBIO_ON_ACCEPT_SOCKET        106\n# define BIO_R_GETHOSTBYNAME_ADDR_IS_NOT_AF_INET          107\n# define BIO_R_INVALID_ARGUMENT                           125\n# define BIO_R_INVALID_IP_ADDRESS                         108\n# define BIO_R_IN_USE                                     123\n# define BIO_R_KEEPALIVE                                  109\n# define BIO_R_NBIO_CONNECT_ERROR                         110\n# define BIO_R_NO_ACCEPT_PORT_SPECIFIED                   111\n# define BIO_R_NO_HOSTNAME_SPECIFIED                      112\n# define BIO_R_NO_PORT_DEFINED                            113\n# define BIO_R_NO_PORT_SPECIFIED                          114\n# define BIO_R_NO_SUCH_FILE                               128\n# define BIO_R_NULL_PARAMETER                             115\n# define BIO_R_TAG_MISMATCH                               116\n# define BIO_R_UNABLE_TO_BIND_SOCKET                      117\n# define BIO_R_UNABLE_TO_CREATE_SOCKET                    118\n# define BIO_R_UNABLE_TO_LISTEN_SOCKET                    119\n# define BIO_R_UNINITIALIZED                              120\n# define BIO_R_UNSUPPORTED_METHOD                         121\n# define BIO_R_WRITE_TO_READ_ONLY_BIO                     126\n# define BIO_R_WSASTARTUP                                 122\n\n#ifdef  __cplusplus\n}\n#endif\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/arm64/include/openssl/blowfish.h",
    "content": "/* crypto/bf/blowfish.h */\n/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)\n * All rights reserved.\n *\n * This package is an SSL implementation written\n * by Eric Young (eay@cryptsoft.com).\n * The implementation was written so as to conform with Netscapes SSL.\n *\n * This library is free for commercial and non-commercial use as long as\n * the following conditions are aheared to.  The following conditions\n * apply to all code found in this distribution, be it the RC4, RSA,\n * lhash, DES, etc., code; not just the SSL code.  The SSL documentation\n * included with this distribution is covered by the same copyright terms\n * except that the holder is Tim Hudson (tjh@cryptsoft.com).\n *\n * Copyright remains Eric Young's, and as such any Copyright notices in\n * the code are not to be removed.\n * If this package is used in a product, Eric Young should be given attribution\n * as the author of the parts of the library used.\n * This can be in the form of a textual message at program startup or\n * in documentation (online or textual) provided with the package.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the copyright\n *    notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in the\n *    documentation and/or other materials provided with the distribution.\n * 3. All advertising materials mentioning features or use of this software\n *    must display the following acknowledgement:\n *    \"This product includes cryptographic software written by\n *     Eric Young (eay@cryptsoft.com)\"\n *    The word 'cryptographic' can be left out if the rouines from the library\n *    being used are not cryptographic related :-).\n * 4. If you include any Windows specific code (or a derivative thereof) from\n *    the apps directory (application code) you must include an acknowledgement:\n *    \"This product includes software written by Tim Hudson (tjh@cryptsoft.com)\"\n *\n * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n * SUCH DAMAGE.\n *\n * The licence and distribution terms for any publically available version or\n * derivative of this code cannot be changed.  i.e. this code cannot simply be\n * copied and put under another distribution licence\n * [including the GNU Public Licence.]\n */\n\n#ifndef HEADER_BLOWFISH_H\n# define HEADER_BLOWFISH_H\n\n# include <openssl/e_os2.h>\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n# ifdef OPENSSL_NO_BF\n#  error BF is disabled.\n# endif\n\n# define BF_ENCRYPT      1\n# define BF_DECRYPT      0\n\n/*-\n * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n * ! BF_LONG has to be at least 32 bits wide. If it's wider, then !\n * ! BF_LONG_LOG2 has to be defined along.                        !\n * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n */\n\n# if defined(__LP32__)\n#  define BF_LONG unsigned long\n# elif defined(OPENSSL_SYS_CRAY) || defined(__ILP64__)\n#  define BF_LONG unsigned long\n#  define BF_LONG_LOG2 3\n/*\n * _CRAY note. I could declare short, but I have no idea what impact\n * does it have on performance on none-T3E machines. I could declare\n * int, but at least on C90 sizeof(int) can be chosen at compile time.\n * So I've chosen long...\n *                                      <appro@fy.chalmers.se>\n */\n# else\n#  define BF_LONG unsigned int\n# endif\n\n# define BF_ROUNDS       16\n# define BF_BLOCK        8\n\ntypedef struct bf_key_st {\n    BF_LONG P[BF_ROUNDS + 2];\n    BF_LONG S[4 * 256];\n} BF_KEY;\n\n# ifdef OPENSSL_FIPS\nvoid private_BF_set_key(BF_KEY *key, int len, const unsigned char *data);\n# endif\nvoid BF_set_key(BF_KEY *key, int len, const unsigned char *data);\n\nvoid BF_encrypt(BF_LONG *data, const BF_KEY *key);\nvoid BF_decrypt(BF_LONG *data, const BF_KEY *key);\n\nvoid BF_ecb_encrypt(const unsigned char *in, unsigned char *out,\n                    const BF_KEY *key, int enc);\nvoid BF_cbc_encrypt(const unsigned char *in, unsigned char *out, long length,\n                    const BF_KEY *schedule, unsigned char *ivec, int enc);\nvoid BF_cfb64_encrypt(const unsigned char *in, unsigned char *out,\n                      long length, const BF_KEY *schedule,\n                      unsigned char *ivec, int *num, int enc);\nvoid BF_ofb64_encrypt(const unsigned char *in, unsigned char *out,\n                      long length, const BF_KEY *schedule,\n                      unsigned char *ivec, int *num);\nconst char *BF_options(void);\n\n#ifdef  __cplusplus\n}\n#endif\n\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/arm64/include/openssl/bn.h",
    "content": "/* crypto/bn/bn.h */\n/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)\n * All rights reserved.\n *\n * This package is an SSL implementation written\n * by Eric Young (eay@cryptsoft.com).\n * The implementation was written so as to conform with Netscapes SSL.\n *\n * This library is free for commercial and non-commercial use as long as\n * the following conditions are aheared to.  The following conditions\n * apply to all code found in this distribution, be it the RC4, RSA,\n * lhash, DES, etc., code; not just the SSL code.  The SSL documentation\n * included with this distribution is covered by the same copyright terms\n * except that the holder is Tim Hudson (tjh@cryptsoft.com).\n *\n * Copyright remains Eric Young's, and as such any Copyright notices in\n * the code are not to be removed.\n * If this package is used in a product, Eric Young should be given attribution\n * as the author of the parts of the library used.\n * This can be in the form of a textual message at program startup or\n * in documentation (online or textual) provided with the package.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the copyright\n *    notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in the\n *    documentation and/or other materials provided with the distribution.\n * 3. All advertising materials mentioning features or use of this software\n *    must display the following acknowledgement:\n *    \"This product includes cryptographic software written by\n *     Eric Young (eay@cryptsoft.com)\"\n *    The word 'cryptographic' can be left out if the rouines from the library\n *    being used are not cryptographic related :-).\n * 4. If you include any Windows specific code (or a derivative thereof) from\n *    the apps directory (application code) you must include an acknowledgement:\n *    \"This product includes software written by Tim Hudson (tjh@cryptsoft.com)\"\n *\n * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n * SUCH DAMAGE.\n *\n * The licence and distribution terms for any publically available version or\n * derivative of this code cannot be changed.  i.e. this code cannot simply be\n * copied and put under another distribution licence\n * [including the GNU Public Licence.]\n */\n/* ====================================================================\n * Copyright (c) 1998-2006 The OpenSSL Project.  All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n *\n * 1. Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n *\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in\n *    the documentation and/or other materials provided with the\n *    distribution.\n *\n * 3. All advertising materials mentioning features or use of this\n *    software must display the following acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit. (http://www.openssl.org/)\"\n *\n * 4. The names \"OpenSSL Toolkit\" and \"OpenSSL Project\" must not be used to\n *    endorse or promote products derived from this software without\n *    prior written permission. For written permission, please contact\n *    openssl-core@openssl.org.\n *\n * 5. Products derived from this software may not be called \"OpenSSL\"\n *    nor may \"OpenSSL\" appear in their names without prior written\n *    permission of the OpenSSL Project.\n *\n * 6. Redistributions of any form whatsoever must retain the following\n *    acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit (http://www.openssl.org/)\"\n *\n * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY\n * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\n * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR\n * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\n * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,\n * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED\n * OF THE POSSIBILITY OF SUCH DAMAGE.\n * ====================================================================\n *\n * This product includes cryptographic software written by Eric Young\n * (eay@cryptsoft.com).  This product includes software written by Tim\n * Hudson (tjh@cryptsoft.com).\n *\n */\n/* ====================================================================\n * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED.\n *\n * Portions of the attached software (\"Contribution\") are developed by\n * SUN MICROSYSTEMS, INC., and are contributed to the OpenSSL project.\n *\n * The Contribution is licensed pursuant to the Eric Young open source\n * license provided above.\n *\n * The binary polynomial arithmetic software is originally written by\n * Sheueling Chang Shantz and Douglas Stebila of Sun Microsystems Laboratories.\n *\n */\n\n#ifndef HEADER_BN_H\n# define HEADER_BN_H\n\n# include <limits.h>\n# include <openssl/e_os2.h>\n# ifndef OPENSSL_NO_FP_API\n#  include <stdio.h>            /* FILE */\n# endif\n# include <openssl/ossl_typ.h>\n# include <openssl/crypto.h>\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n/*\n * These preprocessor symbols control various aspects of the bignum headers\n * and library code. They're not defined by any \"normal\" configuration, as\n * they are intended for development and testing purposes. NB: defining all\n * three can be useful for debugging application code as well as openssl\n * itself. BN_DEBUG - turn on various debugging alterations to the bignum\n * code BN_DEBUG_RAND - uses random poisoning of unused words to trip up\n * mismanagement of bignum internals. You must also define BN_DEBUG.\n */\n/* #define BN_DEBUG */\n/* #define BN_DEBUG_RAND */\n\n# ifndef OPENSSL_SMALL_FOOTPRINT\n#  define BN_MUL_COMBA\n#  define BN_SQR_COMBA\n#  define BN_RECURSION\n# endif\n\n/*\n * This next option uses the C libraries (2 word)/(1 word) function. If it is\n * not defined, I use my C version (which is slower). The reason for this\n * flag is that when the particular C compiler library routine is used, and\n * the library is linked with a different compiler, the library is missing.\n * This mostly happens when the library is built with gcc and then linked\n * using normal cc.  This would be a common occurrence because gcc normally\n * produces code that is 2 times faster than system compilers for the big\n * number stuff. For machines with only one compiler (or shared libraries),\n * this should be on.  Again this in only really a problem on machines using\n * \"long long's\", are 32bit, and are not using my assembler code.\n */\n# if defined(OPENSSL_SYS_MSDOS) || defined(OPENSSL_SYS_WINDOWS) || \\\n    defined(OPENSSL_SYS_WIN32) || defined(linux)\n#  ifndef BN_DIV2W\n#   define BN_DIV2W\n#  endif\n# endif\n\n/*\n * assuming long is 64bit - this is the DEC Alpha unsigned long long is only\n * 64 bits :-(, don't define BN_LLONG for the DEC Alpha\n */\n# ifdef SIXTY_FOUR_BIT_LONG\n#  define BN_ULLONG       unsigned long long\n#  define BN_ULONG        unsigned long\n#  define BN_LONG         long\n#  define BN_BITS         128\n#  define BN_BYTES        8\n#  define BN_BITS2        64\n#  define BN_BITS4        32\n#  define BN_MASK         (0xffffffffffffffffffffffffffffffffLL)\n#  define BN_MASK2        (0xffffffffffffffffL)\n#  define BN_MASK2l       (0xffffffffL)\n#  define BN_MASK2h       (0xffffffff00000000L)\n#  define BN_MASK2h1      (0xffffffff80000000L)\n#  define BN_TBIT         (0x8000000000000000L)\n#  define BN_DEC_CONV     (10000000000000000000UL)\n#  define BN_DEC_FMT1     \"%lu\"\n#  define BN_DEC_FMT2     \"%019lu\"\n#  define BN_DEC_NUM      19\n#  define BN_HEX_FMT1     \"%lX\"\n#  define BN_HEX_FMT2     \"%016lX\"\n# endif\n\n/*\n * This is where the long long data type is 64 bits, but long is 32. For\n * machines where there are 64bit registers, this is the mode to use. IRIX,\n * on R4000 and above should use this mode, along with the relevant assembler\n * code :-).  Do NOT define BN_LLONG.\n */\n# ifdef SIXTY_FOUR_BIT\n#  undef BN_LLONG\n#  undef BN_ULLONG\n#  define BN_ULONG        unsigned long long\n#  define BN_LONG         long long\n#  define BN_BITS         128\n#  define BN_BYTES        8\n#  define BN_BITS2        64\n#  define BN_BITS4        32\n#  define BN_MASK2        (0xffffffffffffffffLL)\n#  define BN_MASK2l       (0xffffffffL)\n#  define BN_MASK2h       (0xffffffff00000000LL)\n#  define BN_MASK2h1      (0xffffffff80000000LL)\n#  define BN_TBIT         (0x8000000000000000LL)\n#  define BN_DEC_CONV     (10000000000000000000ULL)\n#  define BN_DEC_FMT1     \"%llu\"\n#  define BN_DEC_FMT2     \"%019llu\"\n#  define BN_DEC_NUM      19\n#  define BN_HEX_FMT1     \"%llX\"\n#  define BN_HEX_FMT2     \"%016llX\"\n# endif\n\n# ifdef THIRTY_TWO_BIT\n#  ifdef BN_LLONG\n#   if defined(_WIN32) && !defined(__GNUC__)\n#    define BN_ULLONG     unsigned __int64\n#    define BN_MASK       (0xffffffffffffffffI64)\n#   else\n#    define BN_ULLONG     unsigned long long\n#    define BN_MASK       (0xffffffffffffffffLL)\n#   endif\n#  endif\n#  define BN_ULONG        unsigned int\n#  define BN_LONG         int\n#  define BN_BITS         64\n#  define BN_BYTES        4\n#  define BN_BITS2        32\n#  define BN_BITS4        16\n#  define BN_MASK2        (0xffffffffL)\n#  define BN_MASK2l       (0xffff)\n#  define BN_MASK2h1      (0xffff8000L)\n#  define BN_MASK2h       (0xffff0000L)\n#  define BN_TBIT         (0x80000000L)\n#  define BN_DEC_CONV     (1000000000L)\n#  define BN_DEC_FMT1     \"%u\"\n#  define BN_DEC_FMT2     \"%09u\"\n#  define BN_DEC_NUM      9\n#  define BN_HEX_FMT1     \"%X\"\n#  define BN_HEX_FMT2     \"%08X\"\n# endif\n\n# define BN_DEFAULT_BITS 1280\n\n# define BN_FLG_MALLOCED         0x01\n# define BN_FLG_STATIC_DATA      0x02\n\n/*\n * avoid leaking exponent information through timing,\n * BN_mod_exp_mont() will call BN_mod_exp_mont_consttime,\n * BN_div() will call BN_div_no_branch,\n * BN_mod_inverse() will call BN_mod_inverse_no_branch.\n */\n# define BN_FLG_CONSTTIME        0x04\n\n# ifdef OPENSSL_NO_DEPRECATED\n/* deprecated name for the flag */\n#  define BN_FLG_EXP_CONSTTIME BN_FLG_CONSTTIME\n/*\n * avoid leaking exponent information through timings\n * (BN_mod_exp_mont() will call BN_mod_exp_mont_consttime)\n */\n# endif\n\n# ifndef OPENSSL_NO_DEPRECATED\n#  define BN_FLG_FREE             0x8000\n                                       /* used for debuging */\n# endif\n# define BN_set_flags(b,n)       ((b)->flags|=(n))\n# define BN_get_flags(b,n)       ((b)->flags&(n))\n\n/*\n * get a clone of a BIGNUM with changed flags, for *temporary* use only (the\n * two BIGNUMs cannot not be used in parallel!)\n */\n# define BN_with_flags(dest,b,n)  ((dest)->d=(b)->d, \\\n                                  (dest)->top=(b)->top, \\\n                                  (dest)->dmax=(b)->dmax, \\\n                                  (dest)->neg=(b)->neg, \\\n                                  (dest)->flags=(((dest)->flags & BN_FLG_MALLOCED) \\\n                                                 |  ((b)->flags & ~BN_FLG_MALLOCED) \\\n                                                 |  BN_FLG_STATIC_DATA \\\n                                                 |  (n)))\n\n/* Already declared in ossl_typ.h */\n# if 0\ntypedef struct bignum_st BIGNUM;\n/* Used for temp variables (declaration hidden in bn_lcl.h) */\ntypedef struct bignum_ctx BN_CTX;\ntypedef struct bn_blinding_st BN_BLINDING;\ntypedef struct bn_mont_ctx_st BN_MONT_CTX;\ntypedef struct bn_recp_ctx_st BN_RECP_CTX;\ntypedef struct bn_gencb_st BN_GENCB;\n# endif\n\nstruct bignum_st {\n    BN_ULONG *d;                /* Pointer to an array of 'BN_BITS2' bit\n                                 * chunks. */\n    int top;                    /* Index of last used d +1. */\n    /* The next are internal book keeping for bn_expand. */\n    int dmax;                   /* Size of the d array. */\n    int neg;                    /* one if the number is negative */\n    int flags;\n};\n\n/* Used for montgomery multiplication */\nstruct bn_mont_ctx_st {\n    int ri;                     /* number of bits in R */\n    BIGNUM RR;                  /* used to convert to montgomery form */\n    BIGNUM N;                   /* The modulus */\n    BIGNUM Ni;                  /* R*(1/R mod N) - N*Ni = 1 (Ni is only\n                                 * stored for bignum algorithm) */\n    BN_ULONG n0[2];             /* least significant word(s) of Ni; (type\n                                 * changed with 0.9.9, was \"BN_ULONG n0;\"\n                                 * before) */\n    int flags;\n};\n\n/*\n * Used for reciprocal division/mod functions It cannot be shared between\n * threads\n */\nstruct bn_recp_ctx_st {\n    BIGNUM N;                   /* the divisor */\n    BIGNUM Nr;                  /* the reciprocal */\n    int num_bits;\n    int shift;\n    int flags;\n};\n\n/* Used for slow \"generation\" functions. */\nstruct bn_gencb_st {\n    unsigned int ver;           /* To handle binary (in)compatibility */\n    void *arg;                  /* callback-specific data */\n    union {\n        /* if(ver==1) - handles old style callbacks */\n        void (*cb_1) (int, int, void *);\n        /* if(ver==2) - new callback style */\n        int (*cb_2) (int, int, BN_GENCB *);\n    } cb;\n};\n/* Wrapper function to make using BN_GENCB easier,  */\nint BN_GENCB_call(BN_GENCB *cb, int a, int b);\n/* Macro to populate a BN_GENCB structure with an \"old\"-style callback */\n# define BN_GENCB_set_old(gencb, callback, cb_arg) { \\\n                BN_GENCB *tmp_gencb = (gencb); \\\n                tmp_gencb->ver = 1; \\\n                tmp_gencb->arg = (cb_arg); \\\n                tmp_gencb->cb.cb_1 = (callback); }\n/* Macro to populate a BN_GENCB structure with a \"new\"-style callback */\n# define BN_GENCB_set(gencb, callback, cb_arg) { \\\n                BN_GENCB *tmp_gencb = (gencb); \\\n                tmp_gencb->ver = 2; \\\n                tmp_gencb->arg = (cb_arg); \\\n                tmp_gencb->cb.cb_2 = (callback); }\n\n# define BN_prime_checks 0      /* default: select number of iterations based\n                                 * on the size of the number */\n\n/*\n * number of Miller-Rabin iterations for an error rate of less than 2^-80 for\n * random 'b'-bit input, b >= 100 (taken from table 4.4 in the Handbook of\n * Applied Cryptography [Menezes, van Oorschot, Vanstone; CRC Press 1996];\n * original paper: Damgaard, Landrock, Pomerance: Average case error\n * estimates for the strong probable prime test. -- Math. Comp. 61 (1993)\n * 177-194)\n */\n# define BN_prime_checks_for_size(b) ((b) >= 1300 ?  2 : \\\n                                (b) >=  850 ?  3 : \\\n                                (b) >=  650 ?  4 : \\\n                                (b) >=  550 ?  5 : \\\n                                (b) >=  450 ?  6 : \\\n                                (b) >=  400 ?  7 : \\\n                                (b) >=  350 ?  8 : \\\n                                (b) >=  300 ?  9 : \\\n                                (b) >=  250 ? 12 : \\\n                                (b) >=  200 ? 15 : \\\n                                (b) >=  150 ? 18 : \\\n                                /* b >= 100 */ 27)\n\n# define BN_num_bytes(a) ((BN_num_bits(a)+7)/8)\n\n/* Note that BN_abs_is_word didn't work reliably for w == 0 until 0.9.8 */\n# define BN_abs_is_word(a,w) ((((a)->top == 1) && ((a)->d[0] == (BN_ULONG)(w))) || \\\n                                (((w) == 0) && ((a)->top == 0)))\n# define BN_is_zero(a)       ((a)->top == 0)\n# define BN_is_one(a)        (BN_abs_is_word((a),1) && !(a)->neg)\n# define BN_is_word(a,w)     (BN_abs_is_word((a),(w)) && (!(w) || !(a)->neg))\n# define BN_is_odd(a)        (((a)->top > 0) && ((a)->d[0] & 1))\n\n# define BN_one(a)       (BN_set_word((a),1))\n# define BN_zero_ex(a) \\\n        do { \\\n                BIGNUM *_tmp_bn = (a); \\\n                _tmp_bn->top = 0; \\\n                _tmp_bn->neg = 0; \\\n        } while(0)\n# ifdef OPENSSL_NO_DEPRECATED\n#  define BN_zero(a)      BN_zero_ex(a)\n# else\n#  define BN_zero(a)      (BN_set_word((a),0))\n# endif\n\nconst BIGNUM *BN_value_one(void);\nchar *BN_options(void);\nBN_CTX *BN_CTX_new(void);\n# ifndef OPENSSL_NO_DEPRECATED\nvoid BN_CTX_init(BN_CTX *c);\n# endif\nvoid BN_CTX_free(BN_CTX *c);\nvoid BN_CTX_start(BN_CTX *ctx);\nBIGNUM *BN_CTX_get(BN_CTX *ctx);\nvoid BN_CTX_end(BN_CTX *ctx);\nint BN_rand(BIGNUM *rnd, int bits, int top, int bottom);\nint BN_pseudo_rand(BIGNUM *rnd, int bits, int top, int bottom);\nint BN_rand_range(BIGNUM *rnd, const BIGNUM *range);\nint BN_pseudo_rand_range(BIGNUM *rnd, const BIGNUM *range);\nint BN_num_bits(const BIGNUM *a);\nint BN_num_bits_word(BN_ULONG);\nBIGNUM *BN_new(void);\nvoid BN_init(BIGNUM *);\nvoid BN_clear_free(BIGNUM *a);\nBIGNUM *BN_copy(BIGNUM *a, const BIGNUM *b);\nvoid BN_swap(BIGNUM *a, BIGNUM *b);\nBIGNUM *BN_bin2bn(const unsigned char *s, int len, BIGNUM *ret);\nint BN_bn2bin(const BIGNUM *a, unsigned char *to);\nBIGNUM *BN_mpi2bn(const unsigned char *s, int len, BIGNUM *ret);\nint BN_bn2mpi(const BIGNUM *a, unsigned char *to);\nint BN_sub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b);\nint BN_usub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b);\nint BN_uadd(BIGNUM *r, const BIGNUM *a, const BIGNUM *b);\nint BN_add(BIGNUM *r, const BIGNUM *a, const BIGNUM *b);\nint BN_mul(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx);\nint BN_sqr(BIGNUM *r, const BIGNUM *a, BN_CTX *ctx);\n/** BN_set_negative sets sign of a BIGNUM\n * \\param  b  pointer to the BIGNUM object\n * \\param  n  0 if the BIGNUM b should be positive and a value != 0 otherwise\n */\nvoid BN_set_negative(BIGNUM *b, int n);\n/** BN_is_negative returns 1 if the BIGNUM is negative\n * \\param  a  pointer to the BIGNUM object\n * \\return 1 if a < 0 and 0 otherwise\n */\n# define BN_is_negative(a) ((a)->neg != 0)\n\nint BN_div(BIGNUM *dv, BIGNUM *rem, const BIGNUM *m, const BIGNUM *d,\n           BN_CTX *ctx);\n# define BN_mod(rem,m,d,ctx) BN_div(NULL,(rem),(m),(d),(ctx))\nint BN_nnmod(BIGNUM *r, const BIGNUM *m, const BIGNUM *d, BN_CTX *ctx);\nint BN_mod_add(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *m,\n               BN_CTX *ctx);\nint BN_mod_add_quick(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,\n                     const BIGNUM *m);\nint BN_mod_sub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *m,\n               BN_CTX *ctx);\nint BN_mod_sub_quick(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,\n                     const BIGNUM *m);\nint BN_mod_mul(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *m,\n               BN_CTX *ctx);\nint BN_mod_sqr(BIGNUM *r, const BIGNUM *a, const BIGNUM *m, BN_CTX *ctx);\nint BN_mod_lshift1(BIGNUM *r, const BIGNUM *a, const BIGNUM *m, BN_CTX *ctx);\nint BN_mod_lshift1_quick(BIGNUM *r, const BIGNUM *a, const BIGNUM *m);\nint BN_mod_lshift(BIGNUM *r, const BIGNUM *a, int n, const BIGNUM *m,\n                  BN_CTX *ctx);\nint BN_mod_lshift_quick(BIGNUM *r, const BIGNUM *a, int n, const BIGNUM *m);\n\nBN_ULONG BN_mod_word(const BIGNUM *a, BN_ULONG w);\nBN_ULONG BN_div_word(BIGNUM *a, BN_ULONG w);\nint BN_mul_word(BIGNUM *a, BN_ULONG w);\nint BN_add_word(BIGNUM *a, BN_ULONG w);\nint BN_sub_word(BIGNUM *a, BN_ULONG w);\nint BN_set_word(BIGNUM *a, BN_ULONG w);\nBN_ULONG BN_get_word(const BIGNUM *a);\n\nint BN_cmp(const BIGNUM *a, const BIGNUM *b);\nvoid BN_free(BIGNUM *a);\nint BN_is_bit_set(const BIGNUM *a, int n);\nint BN_lshift(BIGNUM *r, const BIGNUM *a, int n);\nint BN_lshift1(BIGNUM *r, const BIGNUM *a);\nint BN_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx);\n\nint BN_mod_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,\n               const BIGNUM *m, BN_CTX *ctx);\nint BN_mod_exp_mont(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,\n                    const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx);\nint BN_mod_exp_mont_consttime(BIGNUM *rr, const BIGNUM *a, const BIGNUM *p,\n                              const BIGNUM *m, BN_CTX *ctx,\n                              BN_MONT_CTX *in_mont);\nint BN_mod_exp_mont_word(BIGNUM *r, BN_ULONG a, const BIGNUM *p,\n                         const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx);\nint BN_mod_exp2_mont(BIGNUM *r, const BIGNUM *a1, const BIGNUM *p1,\n                     const BIGNUM *a2, const BIGNUM *p2, const BIGNUM *m,\n                     BN_CTX *ctx, BN_MONT_CTX *m_ctx);\nint BN_mod_exp_simple(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,\n                      const BIGNUM *m, BN_CTX *ctx);\n\nint BN_mask_bits(BIGNUM *a, int n);\n# ifndef OPENSSL_NO_FP_API\nint BN_print_fp(FILE *fp, const BIGNUM *a);\n# endif\n# ifdef HEADER_BIO_H\nint BN_print(BIO *fp, const BIGNUM *a);\n# else\nint BN_print(void *fp, const BIGNUM *a);\n# endif\nint BN_reciprocal(BIGNUM *r, const BIGNUM *m, int len, BN_CTX *ctx);\nint BN_rshift(BIGNUM *r, const BIGNUM *a, int n);\nint BN_rshift1(BIGNUM *r, const BIGNUM *a);\nvoid BN_clear(BIGNUM *a);\nBIGNUM *BN_dup(const BIGNUM *a);\nint BN_ucmp(const BIGNUM *a, const BIGNUM *b);\nint BN_set_bit(BIGNUM *a, int n);\nint BN_clear_bit(BIGNUM *a, int n);\nchar *BN_bn2hex(const BIGNUM *a);\nchar *BN_bn2dec(const BIGNUM *a);\nint BN_hex2bn(BIGNUM **a, const char *str);\nint BN_dec2bn(BIGNUM **a, const char *str);\nint BN_asc2bn(BIGNUM **a, const char *str);\nint BN_gcd(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx);\nint BN_kronecker(const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx); /* returns\n                                                                  * -2 for\n                                                                  * error */\nBIGNUM *BN_mod_inverse(BIGNUM *ret,\n                       const BIGNUM *a, const BIGNUM *n, BN_CTX *ctx);\nBIGNUM *BN_mod_sqrt(BIGNUM *ret,\n                    const BIGNUM *a, const BIGNUM *n, BN_CTX *ctx);\n\nvoid BN_consttime_swap(BN_ULONG swap, BIGNUM *a, BIGNUM *b, int nwords);\n\n/* Deprecated versions */\n# ifndef OPENSSL_NO_DEPRECATED\nBIGNUM *BN_generate_prime(BIGNUM *ret, int bits, int safe,\n                          const BIGNUM *add, const BIGNUM *rem,\n                          void (*callback) (int, int, void *), void *cb_arg);\nint BN_is_prime(const BIGNUM *p, int nchecks,\n                void (*callback) (int, int, void *),\n                BN_CTX *ctx, void *cb_arg);\nint BN_is_prime_fasttest(const BIGNUM *p, int nchecks,\n                         void (*callback) (int, int, void *), BN_CTX *ctx,\n                         void *cb_arg, int do_trial_division);\n# endif                         /* !defined(OPENSSL_NO_DEPRECATED) */\n\n/* Newer versions */\nint BN_generate_prime_ex(BIGNUM *ret, int bits, int safe, const BIGNUM *add,\n                         const BIGNUM *rem, BN_GENCB *cb);\nint BN_is_prime_ex(const BIGNUM *p, int nchecks, BN_CTX *ctx, BN_GENCB *cb);\nint BN_is_prime_fasttest_ex(const BIGNUM *p, int nchecks, BN_CTX *ctx,\n                            int do_trial_division, BN_GENCB *cb);\n\nint BN_X931_generate_Xpq(BIGNUM *Xp, BIGNUM *Xq, int nbits, BN_CTX *ctx);\n\nint BN_X931_derive_prime_ex(BIGNUM *p, BIGNUM *p1, BIGNUM *p2,\n                            const BIGNUM *Xp, const BIGNUM *Xp1,\n                            const BIGNUM *Xp2, const BIGNUM *e, BN_CTX *ctx,\n                            BN_GENCB *cb);\nint BN_X931_generate_prime_ex(BIGNUM *p, BIGNUM *p1, BIGNUM *p2, BIGNUM *Xp1,\n                              BIGNUM *Xp2, const BIGNUM *Xp, const BIGNUM *e,\n                              BN_CTX *ctx, BN_GENCB *cb);\n\nBN_MONT_CTX *BN_MONT_CTX_new(void);\nvoid BN_MONT_CTX_init(BN_MONT_CTX *ctx);\nint BN_mod_mul_montgomery(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,\n                          BN_MONT_CTX *mont, BN_CTX *ctx);\n# define BN_to_montgomery(r,a,mont,ctx)  BN_mod_mul_montgomery(\\\n        (r),(a),&((mont)->RR),(mont),(ctx))\nint BN_from_montgomery(BIGNUM *r, const BIGNUM *a,\n                       BN_MONT_CTX *mont, BN_CTX *ctx);\nvoid BN_MONT_CTX_free(BN_MONT_CTX *mont);\nint BN_MONT_CTX_set(BN_MONT_CTX *mont, const BIGNUM *mod, BN_CTX *ctx);\nBN_MONT_CTX *BN_MONT_CTX_copy(BN_MONT_CTX *to, BN_MONT_CTX *from);\nBN_MONT_CTX *BN_MONT_CTX_set_locked(BN_MONT_CTX **pmont, int lock,\n                                    const BIGNUM *mod, BN_CTX *ctx);\n\n/* BN_BLINDING flags */\n# define BN_BLINDING_NO_UPDATE   0x00000001\n# define BN_BLINDING_NO_RECREATE 0x00000002\n\nBN_BLINDING *BN_BLINDING_new(const BIGNUM *A, const BIGNUM *Ai, BIGNUM *mod);\nvoid BN_BLINDING_free(BN_BLINDING *b);\nint BN_BLINDING_update(BN_BLINDING *b, BN_CTX *ctx);\nint BN_BLINDING_convert(BIGNUM *n, BN_BLINDING *b, BN_CTX *ctx);\nint BN_BLINDING_invert(BIGNUM *n, BN_BLINDING *b, BN_CTX *ctx);\nint BN_BLINDING_convert_ex(BIGNUM *n, BIGNUM *r, BN_BLINDING *b, BN_CTX *);\nint BN_BLINDING_invert_ex(BIGNUM *n, const BIGNUM *r, BN_BLINDING *b,\n                          BN_CTX *);\n# ifndef OPENSSL_NO_DEPRECATED\nunsigned long BN_BLINDING_get_thread_id(const BN_BLINDING *);\nvoid BN_BLINDING_set_thread_id(BN_BLINDING *, unsigned long);\n# endif\nCRYPTO_THREADID *BN_BLINDING_thread_id(BN_BLINDING *);\nunsigned long BN_BLINDING_get_flags(const BN_BLINDING *);\nvoid BN_BLINDING_set_flags(BN_BLINDING *, unsigned long);\nBN_BLINDING *BN_BLINDING_create_param(BN_BLINDING *b,\n                                      const BIGNUM *e, BIGNUM *m, BN_CTX *ctx,\n                                      int (*bn_mod_exp) (BIGNUM *r,\n                                                         const BIGNUM *a,\n                                                         const BIGNUM *p,\n                                                         const BIGNUM *m,\n                                                         BN_CTX *ctx,\n                                                         BN_MONT_CTX *m_ctx),\n                                      BN_MONT_CTX *m_ctx);\n\n# ifndef OPENSSL_NO_DEPRECATED\nvoid BN_set_params(int mul, int high, int low, int mont);\nint BN_get_params(int which);   /* 0, mul, 1 high, 2 low, 3 mont */\n# endif\n\nvoid BN_RECP_CTX_init(BN_RECP_CTX *recp);\nBN_RECP_CTX *BN_RECP_CTX_new(void);\nvoid BN_RECP_CTX_free(BN_RECP_CTX *recp);\nint BN_RECP_CTX_set(BN_RECP_CTX *recp, const BIGNUM *rdiv, BN_CTX *ctx);\nint BN_mod_mul_reciprocal(BIGNUM *r, const BIGNUM *x, const BIGNUM *y,\n                          BN_RECP_CTX *recp, BN_CTX *ctx);\nint BN_mod_exp_recp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,\n                    const BIGNUM *m, BN_CTX *ctx);\nint BN_div_recp(BIGNUM *dv, BIGNUM *rem, const BIGNUM *m,\n                BN_RECP_CTX *recp, BN_CTX *ctx);\n\n# ifndef OPENSSL_NO_EC2M\n\n/*\n * Functions for arithmetic over binary polynomials represented by BIGNUMs.\n * The BIGNUM::neg property of BIGNUMs representing binary polynomials is\n * ignored. Note that input arguments are not const so that their bit arrays\n * can be expanded to the appropriate size if needed.\n */\n\n/*\n * r = a + b\n */\nint BN_GF2m_add(BIGNUM *r, const BIGNUM *a, const BIGNUM *b);\n#  define BN_GF2m_sub(r, a, b) BN_GF2m_add(r, a, b)\n/*\n * r=a mod p\n */\nint BN_GF2m_mod(BIGNUM *r, const BIGNUM *a, const BIGNUM *p);\n/* r = (a * b) mod p */\nint BN_GF2m_mod_mul(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,\n                    const BIGNUM *p, BN_CTX *ctx);\n/* r = (a * a) mod p */\nint BN_GF2m_mod_sqr(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx);\n/* r = (1 / b) mod p */\nint BN_GF2m_mod_inv(BIGNUM *r, const BIGNUM *b, const BIGNUM *p, BN_CTX *ctx);\n/* r = (a / b) mod p */\nint BN_GF2m_mod_div(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,\n                    const BIGNUM *p, BN_CTX *ctx);\n/* r = (a ^ b) mod p */\nint BN_GF2m_mod_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,\n                    const BIGNUM *p, BN_CTX *ctx);\n/* r = sqrt(a) mod p */\nint BN_GF2m_mod_sqrt(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,\n                     BN_CTX *ctx);\n/* r^2 + r = a mod p */\nint BN_GF2m_mod_solve_quad(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,\n                           BN_CTX *ctx);\n#  define BN_GF2m_cmp(a, b) BN_ucmp((a), (b))\n/*-\n * Some functions allow for representation of the irreducible polynomials\n * as an unsigned int[], say p.  The irreducible f(t) is then of the form:\n *     t^p[0] + t^p[1] + ... + t^p[k]\n * where m = p[0] > p[1] > ... > p[k] = 0.\n */\n/* r = a mod p */\nint BN_GF2m_mod_arr(BIGNUM *r, const BIGNUM *a, const int p[]);\n/* r = (a * b) mod p */\nint BN_GF2m_mod_mul_arr(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,\n                        const int p[], BN_CTX *ctx);\n/* r = (a * a) mod p */\nint BN_GF2m_mod_sqr_arr(BIGNUM *r, const BIGNUM *a, const int p[],\n                        BN_CTX *ctx);\n/* r = (1 / b) mod p */\nint BN_GF2m_mod_inv_arr(BIGNUM *r, const BIGNUM *b, const int p[],\n                        BN_CTX *ctx);\n/* r = (a / b) mod p */\nint BN_GF2m_mod_div_arr(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,\n                        const int p[], BN_CTX *ctx);\n/* r = (a ^ b) mod p */\nint BN_GF2m_mod_exp_arr(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,\n                        const int p[], BN_CTX *ctx);\n/* r = sqrt(a) mod p */\nint BN_GF2m_mod_sqrt_arr(BIGNUM *r, const BIGNUM *a,\n                         const int p[], BN_CTX *ctx);\n/* r^2 + r = a mod p */\nint BN_GF2m_mod_solve_quad_arr(BIGNUM *r, const BIGNUM *a,\n                               const int p[], BN_CTX *ctx);\nint BN_GF2m_poly2arr(const BIGNUM *a, int p[], int max);\nint BN_GF2m_arr2poly(const int p[], BIGNUM *a);\n\n# endif\n\n/*\n * faster mod functions for the 'NIST primes' 0 <= a < p^2\n */\nint BN_nist_mod_192(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx);\nint BN_nist_mod_224(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx);\nint BN_nist_mod_256(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx);\nint BN_nist_mod_384(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx);\nint BN_nist_mod_521(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx);\n\nconst BIGNUM *BN_get0_nist_prime_192(void);\nconst BIGNUM *BN_get0_nist_prime_224(void);\nconst BIGNUM *BN_get0_nist_prime_256(void);\nconst BIGNUM *BN_get0_nist_prime_384(void);\nconst BIGNUM *BN_get0_nist_prime_521(void);\n\n/* library internal functions */\n\n# define bn_expand(a,bits) \\\n    ( \\\n        bits > (INT_MAX - BN_BITS2 + 1) ? \\\n            NULL \\\n        : \\\n            (((bits+BN_BITS2-1)/BN_BITS2) <= (a)->dmax) ? \\\n                (a) \\\n            : \\\n                bn_expand2((a),(bits+BN_BITS2-1)/BN_BITS2) \\\n    )\n\n# define bn_wexpand(a,words) (((words) <= (a)->dmax)?(a):bn_expand2((a),(words)))\nBIGNUM *bn_expand2(BIGNUM *a, int words);\n# ifndef OPENSSL_NO_DEPRECATED\nBIGNUM *bn_dup_expand(const BIGNUM *a, int words); /* unused */\n# endif\n\n/*-\n * Bignum consistency macros\n * There is one \"API\" macro, bn_fix_top(), for stripping leading zeroes from\n * bignum data after direct manipulations on the data. There is also an\n * \"internal\" macro, bn_check_top(), for verifying that there are no leading\n * zeroes. Unfortunately, some auditing is required due to the fact that\n * bn_fix_top() has become an overabused duct-tape because bignum data is\n * occasionally passed around in an inconsistent state. So the following\n * changes have been made to sort this out;\n * - bn_fix_top()s implementation has been moved to bn_correct_top()\n * - if BN_DEBUG isn't defined, bn_fix_top() maps to bn_correct_top(), and\n *   bn_check_top() is as before.\n * - if BN_DEBUG *is* defined;\n *   - bn_check_top() tries to pollute unused words even if the bignum 'top' is\n *     consistent. (ed: only if BN_DEBUG_RAND is defined)\n *   - bn_fix_top() maps to bn_check_top() rather than \"fixing\" anything.\n * The idea is to have debug builds flag up inconsistent bignums when they\n * occur. If that occurs in a bn_fix_top(), we examine the code in question; if\n * the use of bn_fix_top() was appropriate (ie. it follows directly after code\n * that manipulates the bignum) it is converted to bn_correct_top(), and if it\n * was not appropriate, we convert it permanently to bn_check_top() and track\n * down the cause of the bug. Eventually, no internal code should be using the\n * bn_fix_top() macro. External applications and libraries should try this with\n * their own code too, both in terms of building against the openssl headers\n * with BN_DEBUG defined *and* linking with a version of OpenSSL built with it\n * defined. This not only improves external code, it provides more test\n * coverage for openssl's own code.\n */\n\n# ifdef BN_DEBUG\n\n/* We only need assert() when debugging */\n#  include <assert.h>\n\n#  ifdef BN_DEBUG_RAND\n/* To avoid \"make update\" cvs wars due to BN_DEBUG, use some tricks */\n#   ifndef RAND_pseudo_bytes\nint RAND_pseudo_bytes(unsigned char *buf, int num);\n#    define BN_DEBUG_TRIX\n#   endif\n#   define bn_pollute(a) \\\n        do { \\\n                const BIGNUM *_bnum1 = (a); \\\n                if(_bnum1->top < _bnum1->dmax) { \\\n                        unsigned char _tmp_char; \\\n                        /* We cast away const without the compiler knowing, any \\\n                         * *genuinely* constant variables that aren't mutable \\\n                         * wouldn't be constructed with top!=dmax. */ \\\n                        BN_ULONG *_not_const; \\\n                        memcpy(&_not_const, &_bnum1->d, sizeof(BN_ULONG*)); \\\n                        /* Debug only - safe to ignore error return */ \\\n                        RAND_pseudo_bytes(&_tmp_char, 1); \\\n                        memset((unsigned char *)(_not_const + _bnum1->top), _tmp_char, \\\n                                (_bnum1->dmax - _bnum1->top) * sizeof(BN_ULONG)); \\\n                } \\\n        } while(0)\n#   ifdef BN_DEBUG_TRIX\n#    undef RAND_pseudo_bytes\n#   endif\n#  else\n#   define bn_pollute(a)\n#  endif\n#  define bn_check_top(a) \\\n        do { \\\n                const BIGNUM *_bnum2 = (a); \\\n                if (_bnum2 != NULL) { \\\n                        assert((_bnum2->top == 0) || \\\n                                (_bnum2->d[_bnum2->top - 1] != 0)); \\\n                        bn_pollute(_bnum2); \\\n                } \\\n        } while(0)\n\n#  define bn_fix_top(a)           bn_check_top(a)\n\n#  define bn_check_size(bn, bits) bn_wcheck_size(bn, ((bits+BN_BITS2-1))/BN_BITS2)\n#  define bn_wcheck_size(bn, words) \\\n        do { \\\n                const BIGNUM *_bnum2 = (bn); \\\n                assert((words) <= (_bnum2)->dmax && (words) >= (_bnum2)->top); \\\n                /* avoid unused variable warning with NDEBUG */ \\\n                (void)(_bnum2); \\\n        } while(0)\n\n# else                          /* !BN_DEBUG */\n\n#  define bn_pollute(a)\n#  define bn_check_top(a)\n#  define bn_fix_top(a)           bn_correct_top(a)\n#  define bn_check_size(bn, bits)\n#  define bn_wcheck_size(bn, words)\n\n# endif\n\n# define bn_correct_top(a) \\\n        { \\\n        BN_ULONG *ftl; \\\n        int tmp_top = (a)->top; \\\n        if (tmp_top > 0) \\\n                { \\\n                for (ftl= &((a)->d[tmp_top-1]); tmp_top > 0; tmp_top--) \\\n                        if (*(ftl--)) break; \\\n                (a)->top = tmp_top; \\\n                } \\\n        if ((a)->top == 0) \\\n            (a)->neg = 0; \\\n        bn_pollute(a); \\\n        }\n\nBN_ULONG bn_mul_add_words(BN_ULONG *rp, const BN_ULONG *ap, int num,\n                          BN_ULONG w);\nBN_ULONG bn_mul_words(BN_ULONG *rp, const BN_ULONG *ap, int num, BN_ULONG w);\nvoid bn_sqr_words(BN_ULONG *rp, const BN_ULONG *ap, int num);\nBN_ULONG bn_div_words(BN_ULONG h, BN_ULONG l, BN_ULONG d);\nBN_ULONG bn_add_words(BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp,\n                      int num);\nBN_ULONG bn_sub_words(BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp,\n                      int num);\n\n/* Primes from RFC 2409 */\nBIGNUM *get_rfc2409_prime_768(BIGNUM *bn);\nBIGNUM *get_rfc2409_prime_1024(BIGNUM *bn);\n\n/* Primes from RFC 3526 */\nBIGNUM *get_rfc3526_prime_1536(BIGNUM *bn);\nBIGNUM *get_rfc3526_prime_2048(BIGNUM *bn);\nBIGNUM *get_rfc3526_prime_3072(BIGNUM *bn);\nBIGNUM *get_rfc3526_prime_4096(BIGNUM *bn);\nBIGNUM *get_rfc3526_prime_6144(BIGNUM *bn);\nBIGNUM *get_rfc3526_prime_8192(BIGNUM *bn);\n\nint BN_bntest_rand(BIGNUM *rnd, int bits, int top, int bottom);\n\n/* BEGIN ERROR CODES */\n/*\n * The following lines are auto generated by the script mkerr.pl. Any changes\n * made after this point may be overwritten when the script is next run.\n */\nvoid ERR_load_BN_strings(void);\n\n/* Error codes for the BN functions. */\n\n/* Function codes. */\n# define BN_F_BNRAND                                      127\n# define BN_F_BN_BLINDING_CONVERT_EX                      100\n# define BN_F_BN_BLINDING_CREATE_PARAM                    128\n# define BN_F_BN_BLINDING_INVERT_EX                       101\n# define BN_F_BN_BLINDING_NEW                             102\n# define BN_F_BN_BLINDING_UPDATE                          103\n# define BN_F_BN_BN2DEC                                   104\n# define BN_F_BN_BN2HEX                                   105\n# define BN_F_BN_CTX_GET                                  116\n# define BN_F_BN_CTX_NEW                                  106\n# define BN_F_BN_CTX_START                                129\n# define BN_F_BN_DIV                                      107\n# define BN_F_BN_DIV_NO_BRANCH                            138\n# define BN_F_BN_DIV_RECP                                 130\n# define BN_F_BN_EXP                                      123\n# define BN_F_BN_EXPAND2                                  108\n# define BN_F_BN_EXPAND_INTERNAL                          120\n# define BN_F_BN_GF2M_MOD                                 131\n# define BN_F_BN_GF2M_MOD_EXP                             132\n# define BN_F_BN_GF2M_MOD_MUL                             133\n# define BN_F_BN_GF2M_MOD_SOLVE_QUAD                      134\n# define BN_F_BN_GF2M_MOD_SOLVE_QUAD_ARR                  135\n# define BN_F_BN_GF2M_MOD_SQR                             136\n# define BN_F_BN_GF2M_MOD_SQRT                            137\n# define BN_F_BN_LSHIFT                                   145\n# define BN_F_BN_MOD_EXP2_MONT                            118\n# define BN_F_BN_MOD_EXP_MONT                             109\n# define BN_F_BN_MOD_EXP_MONT_CONSTTIME                   124\n# define BN_F_BN_MOD_EXP_MONT_WORD                        117\n# define BN_F_BN_MOD_EXP_RECP                             125\n# define BN_F_BN_MOD_EXP_SIMPLE                           126\n# define BN_F_BN_MOD_INVERSE                              110\n# define BN_F_BN_MOD_INVERSE_NO_BRANCH                    139\n# define BN_F_BN_MOD_LSHIFT_QUICK                         119\n# define BN_F_BN_MOD_MUL_RECIPROCAL                       111\n# define BN_F_BN_MOD_SQRT                                 121\n# define BN_F_BN_MPI2BN                                   112\n# define BN_F_BN_NEW                                      113\n# define BN_F_BN_RAND                                     114\n# define BN_F_BN_RAND_RANGE                               122\n# define BN_F_BN_RSHIFT                                   146\n# define BN_F_BN_USUB                                     115\n\n/* Reason codes. */\n# define BN_R_ARG2_LT_ARG3                                100\n# define BN_R_BAD_RECIPROCAL                              101\n# define BN_R_BIGNUM_TOO_LONG                             114\n# define BN_R_BITS_TOO_SMALL                              118\n# define BN_R_CALLED_WITH_EVEN_MODULUS                    102\n# define BN_R_DIV_BY_ZERO                                 103\n# define BN_R_ENCODING_ERROR                              104\n# define BN_R_EXPAND_ON_STATIC_BIGNUM_DATA                105\n# define BN_R_INPUT_NOT_REDUCED                           110\n# define BN_R_INVALID_LENGTH                              106\n# define BN_R_INVALID_RANGE                               115\n# define BN_R_INVALID_SHIFT                               119\n# define BN_R_NOT_A_SQUARE                                111\n# define BN_R_NOT_INITIALIZED                             107\n# define BN_R_NO_INVERSE                                  108\n# define BN_R_NO_SOLUTION                                 116\n# define BN_R_P_IS_NOT_PRIME                              112\n# define BN_R_TOO_MANY_ITERATIONS                         113\n# define BN_R_TOO_MANY_TEMPORARY_VARIABLES                109\n\n#ifdef  __cplusplus\n}\n#endif\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/arm64/include/openssl/buffer.h",
    "content": "/* crypto/buffer/buffer.h */\n/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)\n * All rights reserved.\n *\n * This package is an SSL implementation written\n * by Eric Young (eay@cryptsoft.com).\n * The implementation was written so as to conform with Netscapes SSL.\n *\n * This library is free for commercial and non-commercial use as long as\n * the following conditions are aheared to.  The following conditions\n * apply to all code found in this distribution, be it the RC4, RSA,\n * lhash, DES, etc., code; not just the SSL code.  The SSL documentation\n * included with this distribution is covered by the same copyright terms\n * except that the holder is Tim Hudson (tjh@cryptsoft.com).\n *\n * Copyright remains Eric Young's, and as such any Copyright notices in\n * the code are not to be removed.\n * If this package is used in a product, Eric Young should be given attribution\n * as the author of the parts of the library used.\n * This can be in the form of a textual message at program startup or\n * in documentation (online or textual) provided with the package.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the copyright\n *    notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in the\n *    documentation and/or other materials provided with the distribution.\n * 3. All advertising materials mentioning features or use of this software\n *    must display the following acknowledgement:\n *    \"This product includes cryptographic software written by\n *     Eric Young (eay@cryptsoft.com)\"\n *    The word 'cryptographic' can be left out if the rouines from the library\n *    being used are not cryptographic related :-).\n * 4. If you include any Windows specific code (or a derivative thereof) from\n *    the apps directory (application code) you must include an acknowledgement:\n *    \"This product includes software written by Tim Hudson (tjh@cryptsoft.com)\"\n *\n * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n * SUCH DAMAGE.\n *\n * The licence and distribution terms for any publically available version or\n * derivative of this code cannot be changed.  i.e. this code cannot simply be\n * copied and put under another distribution licence\n * [including the GNU Public Licence.]\n */\n\n#ifndef HEADER_BUFFER_H\n# define HEADER_BUFFER_H\n\n# include <openssl/ossl_typ.h>\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n# include <stddef.h>\n\n# if !defined(NO_SYS_TYPES_H)\n#  include <sys/types.h>\n# endif\n\n/* Already declared in ossl_typ.h */\n/* typedef struct buf_mem_st BUF_MEM; */\n\nstruct buf_mem_st {\n    size_t length;              /* current number of bytes */\n    char *data;\n    size_t max;                 /* size of buffer */\n};\n\nBUF_MEM *BUF_MEM_new(void);\nvoid BUF_MEM_free(BUF_MEM *a);\nint BUF_MEM_grow(BUF_MEM *str, size_t len);\nint BUF_MEM_grow_clean(BUF_MEM *str, size_t len);\nsize_t BUF_strnlen(const char *str, size_t maxlen);\nchar *BUF_strdup(const char *str);\n\n/*\n * Like strndup, but in addition, explicitly guarantees to never read past the\n * first |siz| bytes of |str|.\n */\nchar *BUF_strndup(const char *str, size_t siz);\n\nvoid *BUF_memdup(const void *data, size_t siz);\nvoid BUF_reverse(unsigned char *out, const unsigned char *in, size_t siz);\n\n/* safe string functions */\nsize_t BUF_strlcpy(char *dst, const char *src, size_t siz);\nsize_t BUF_strlcat(char *dst, const char *src, size_t siz);\n\n/* BEGIN ERROR CODES */\n/*\n * The following lines are auto generated by the script mkerr.pl. Any changes\n * made after this point may be overwritten when the script is next run.\n */\nvoid ERR_load_BUF_strings(void);\n\n/* Error codes for the BUF functions. */\n\n/* Function codes. */\n# define BUF_F_BUF_MEMDUP                                 103\n# define BUF_F_BUF_MEM_GROW                               100\n# define BUF_F_BUF_MEM_GROW_CLEAN                         105\n# define BUF_F_BUF_MEM_NEW                                101\n# define BUF_F_BUF_STRDUP                                 102\n# define BUF_F_BUF_STRNDUP                                104\n\n/* Reason codes. */\n\n#ifdef  __cplusplus\n}\n#endif\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/arm64/include/openssl/camellia.h",
    "content": "/* crypto/camellia/camellia.h */\n/* ====================================================================\n * Copyright (c) 2006 The OpenSSL Project.  All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n *\n * 1. Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n *\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in\n *    the documentation and/or other materials provided with the\n *    distribution.\n *\n * 3. All advertising materials mentioning features or use of this\n *    software must display the following acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit. (http://www.openssl.org/)\"\n *\n * 4. The names \"OpenSSL Toolkit\" and \"OpenSSL Project\" must not be used to\n *    endorse or promote products derived from this software without\n *    prior written permission. For written permission, please contact\n *    openssl-core@openssl.org.\n *\n * 5. Products derived from this software may not be called \"OpenSSL\"\n *    nor may \"OpenSSL\" appear in their names without prior written\n *    permission of the OpenSSL Project.\n *\n * 6. Redistributions of any form whatsoever must retain the following\n *    acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit (http://www.openssl.org/)\"\n *\n * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY\n * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\n * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR\n * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\n * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,\n * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED\n * OF THE POSSIBILITY OF SUCH DAMAGE.\n * ====================================================================\n *\n */\n\n#ifndef HEADER_CAMELLIA_H\n# define HEADER_CAMELLIA_H\n\n# include <openssl/opensslconf.h>\n\n# ifdef OPENSSL_NO_CAMELLIA\n#  error CAMELLIA is disabled.\n# endif\n\n# include <stddef.h>\n\n# define CAMELLIA_ENCRYPT        1\n# define CAMELLIA_DECRYPT        0\n\n/*\n * Because array size can't be a const in C, the following two are macros.\n * Both sizes are in bytes.\n */\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n/* This should be a hidden type, but EVP requires that the size be known */\n\n# define CAMELLIA_BLOCK_SIZE 16\n# define CAMELLIA_TABLE_BYTE_LEN 272\n# define CAMELLIA_TABLE_WORD_LEN (CAMELLIA_TABLE_BYTE_LEN / 4)\n\ntypedef unsigned int KEY_TABLE_TYPE[CAMELLIA_TABLE_WORD_LEN]; /* to match\n                                                               * with WORD */\n\nstruct camellia_key_st {\n    union {\n        double d;               /* ensures 64-bit align */\n        KEY_TABLE_TYPE rd_key;\n    } u;\n    int grand_rounds;\n};\ntypedef struct camellia_key_st CAMELLIA_KEY;\n\n# ifdef OPENSSL_FIPS\nint private_Camellia_set_key(const unsigned char *userKey, const int bits,\n                             CAMELLIA_KEY *key);\n# endif\nint Camellia_set_key(const unsigned char *userKey, const int bits,\n                     CAMELLIA_KEY *key);\n\nvoid Camellia_encrypt(const unsigned char *in, unsigned char *out,\n                      const CAMELLIA_KEY *key);\nvoid Camellia_decrypt(const unsigned char *in, unsigned char *out,\n                      const CAMELLIA_KEY *key);\n\nvoid Camellia_ecb_encrypt(const unsigned char *in, unsigned char *out,\n                          const CAMELLIA_KEY *key, const int enc);\nvoid Camellia_cbc_encrypt(const unsigned char *in, unsigned char *out,\n                          size_t length, const CAMELLIA_KEY *key,\n                          unsigned char *ivec, const int enc);\nvoid Camellia_cfb128_encrypt(const unsigned char *in, unsigned char *out,\n                             size_t length, const CAMELLIA_KEY *key,\n                             unsigned char *ivec, int *num, const int enc);\nvoid Camellia_cfb1_encrypt(const unsigned char *in, unsigned char *out,\n                           size_t length, const CAMELLIA_KEY *key,\n                           unsigned char *ivec, int *num, const int enc);\nvoid Camellia_cfb8_encrypt(const unsigned char *in, unsigned char *out,\n                           size_t length, const CAMELLIA_KEY *key,\n                           unsigned char *ivec, int *num, const int enc);\nvoid Camellia_ofb128_encrypt(const unsigned char *in, unsigned char *out,\n                             size_t length, const CAMELLIA_KEY *key,\n                             unsigned char *ivec, int *num);\nvoid Camellia_ctr128_encrypt(const unsigned char *in, unsigned char *out,\n                             size_t length, const CAMELLIA_KEY *key,\n                             unsigned char ivec[CAMELLIA_BLOCK_SIZE],\n                             unsigned char ecount_buf[CAMELLIA_BLOCK_SIZE],\n                             unsigned int *num);\n\n#ifdef  __cplusplus\n}\n#endif\n\n#endif                          /* !HEADER_Camellia_H */\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/arm64/include/openssl/cast.h",
    "content": "/* crypto/cast/cast.h */\n/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)\n * All rights reserved.\n *\n * This package is an SSL implementation written\n * by Eric Young (eay@cryptsoft.com).\n * The implementation was written so as to conform with Netscapes SSL.\n *\n * This library is free for commercial and non-commercial use as long as\n * the following conditions are aheared to.  The following conditions\n * apply to all code found in this distribution, be it the RC4, RSA,\n * lhash, DES, etc., code; not just the SSL code.  The SSL documentation\n * included with this distribution is covered by the same copyright terms\n * except that the holder is Tim Hudson (tjh@cryptsoft.com).\n *\n * Copyright remains Eric Young's, and as such any Copyright notices in\n * the code are not to be removed.\n * If this package is used in a product, Eric Young should be given attribution\n * as the author of the parts of the library used.\n * This can be in the form of a textual message at program startup or\n * in documentation (online or textual) provided with the package.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the copyright\n *    notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in the\n *    documentation and/or other materials provided with the distribution.\n * 3. All advertising materials mentioning features or use of this software\n *    must display the following acknowledgement:\n *    \"This product includes cryptographic software written by\n *     Eric Young (eay@cryptsoft.com)\"\n *    The word 'cryptographic' can be left out if the rouines from the library\n *    being used are not cryptographic related :-).\n * 4. If you include any Windows specific code (or a derivative thereof) from\n *    the apps directory (application code) you must include an acknowledgement:\n *    \"This product includes software written by Tim Hudson (tjh@cryptsoft.com)\"\n *\n * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n * SUCH DAMAGE.\n *\n * The licence and distribution terms for any publically available version or\n * derivative of this code cannot be changed.  i.e. this code cannot simply be\n * copied and put under another distribution licence\n * [including the GNU Public Licence.]\n */\n\n#ifndef HEADER_CAST_H\n# define HEADER_CAST_H\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n# include <openssl/opensslconf.h>\n\n# ifdef OPENSSL_NO_CAST\n#  error CAST is disabled.\n# endif\n\n# define CAST_ENCRYPT    1\n# define CAST_DECRYPT    0\n\n# define CAST_LONG unsigned int\n\n# define CAST_BLOCK      8\n# define CAST_KEY_LENGTH 16\n\ntypedef struct cast_key_st {\n    CAST_LONG data[32];\n    int short_key;              /* Use reduced rounds for short key */\n} CAST_KEY;\n\n# ifdef OPENSSL_FIPS\nvoid private_CAST_set_key(CAST_KEY *key, int len, const unsigned char *data);\n# endif\nvoid CAST_set_key(CAST_KEY *key, int len, const unsigned char *data);\nvoid CAST_ecb_encrypt(const unsigned char *in, unsigned char *out,\n                      const CAST_KEY *key, int enc);\nvoid CAST_encrypt(CAST_LONG *data, const CAST_KEY *key);\nvoid CAST_decrypt(CAST_LONG *data, const CAST_KEY *key);\nvoid CAST_cbc_encrypt(const unsigned char *in, unsigned char *out,\n                      long length, const CAST_KEY *ks, unsigned char *iv,\n                      int enc);\nvoid CAST_cfb64_encrypt(const unsigned char *in, unsigned char *out,\n                        long length, const CAST_KEY *schedule,\n                        unsigned char *ivec, int *num, int enc);\nvoid CAST_ofb64_encrypt(const unsigned char *in, unsigned char *out,\n                        long length, const CAST_KEY *schedule,\n                        unsigned char *ivec, int *num);\n\n#ifdef  __cplusplus\n}\n#endif\n\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/arm64/include/openssl/cmac.h",
    "content": "/* crypto/cmac/cmac.h */\n/*\n * Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL\n * project.\n */\n/* ====================================================================\n * Copyright (c) 2010 The OpenSSL Project.  All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n *\n * 1. Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n *\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in\n *    the documentation and/or other materials provided with the\n *    distribution.\n *\n * 3. All advertising materials mentioning features or use of this\n *    software must display the following acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)\"\n *\n * 4. The names \"OpenSSL Toolkit\" and \"OpenSSL Project\" must not be used to\n *    endorse or promote products derived from this software without\n *    prior written permission. For written permission, please contact\n *    licensing@OpenSSL.org.\n *\n * 5. Products derived from this software may not be called \"OpenSSL\"\n *    nor may \"OpenSSL\" appear in their names without prior written\n *    permission of the OpenSSL Project.\n *\n * 6. Redistributions of any form whatsoever must retain the following\n *    acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)\"\n *\n * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY\n * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\n * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR\n * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\n * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,\n * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED\n * OF THE POSSIBILITY OF SUCH DAMAGE.\n * ====================================================================\n */\n\n#ifndef HEADER_CMAC_H\n# define HEADER_CMAC_H\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n# include <openssl/evp.h>\n\n/* Opaque */\ntypedef struct CMAC_CTX_st CMAC_CTX;\n\nCMAC_CTX *CMAC_CTX_new(void);\nvoid CMAC_CTX_cleanup(CMAC_CTX *ctx);\nvoid CMAC_CTX_free(CMAC_CTX *ctx);\nEVP_CIPHER_CTX *CMAC_CTX_get0_cipher_ctx(CMAC_CTX *ctx);\nint CMAC_CTX_copy(CMAC_CTX *out, const CMAC_CTX *in);\n\nint CMAC_Init(CMAC_CTX *ctx, const void *key, size_t keylen,\n              const EVP_CIPHER *cipher, ENGINE *impl);\nint CMAC_Update(CMAC_CTX *ctx, const void *data, size_t dlen);\nint CMAC_Final(CMAC_CTX *ctx, unsigned char *out, size_t *poutlen);\nint CMAC_resume(CMAC_CTX *ctx);\n\n#ifdef  __cplusplus\n}\n#endif\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/arm64/include/openssl/cms.h",
    "content": "/* crypto/cms/cms.h */\n/*\n * Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL\n * project.\n */\n/* ====================================================================\n * Copyright (c) 2008 The OpenSSL Project.  All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n *\n * 1. Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n *\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in\n *    the documentation and/or other materials provided with the\n *    distribution.\n *\n * 3. All advertising materials mentioning features or use of this\n *    software must display the following acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)\"\n *\n * 4. The names \"OpenSSL Toolkit\" and \"OpenSSL Project\" must not be used to\n *    endorse or promote products derived from this software without\n *    prior written permission. For written permission, please contact\n *    licensing@OpenSSL.org.\n *\n * 5. Products derived from this software may not be called \"OpenSSL\"\n *    nor may \"OpenSSL\" appear in their names without prior written\n *    permission of the OpenSSL Project.\n *\n * 6. Redistributions of any form whatsoever must retain the following\n *    acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)\"\n *\n * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY\n * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\n * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR\n * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\n * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,\n * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED\n * OF THE POSSIBILITY OF SUCH DAMAGE.\n * ====================================================================\n */\n\n#ifndef HEADER_CMS_H\n# define HEADER_CMS_H\n\n# include <openssl/x509.h>\n\n# ifdef OPENSSL_NO_CMS\n#  error CMS is disabled.\n# endif\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\ntypedef struct CMS_ContentInfo_st CMS_ContentInfo;\ntypedef struct CMS_SignerInfo_st CMS_SignerInfo;\ntypedef struct CMS_CertificateChoices CMS_CertificateChoices;\ntypedef struct CMS_RevocationInfoChoice_st CMS_RevocationInfoChoice;\ntypedef struct CMS_RecipientInfo_st CMS_RecipientInfo;\ntypedef struct CMS_ReceiptRequest_st CMS_ReceiptRequest;\ntypedef struct CMS_Receipt_st CMS_Receipt;\ntypedef struct CMS_RecipientEncryptedKey_st CMS_RecipientEncryptedKey;\ntypedef struct CMS_OtherKeyAttribute_st CMS_OtherKeyAttribute;\n\nDECLARE_STACK_OF(CMS_SignerInfo)\nDECLARE_STACK_OF(GENERAL_NAMES)\nDECLARE_STACK_OF(CMS_RecipientEncryptedKey)\nDECLARE_ASN1_FUNCTIONS(CMS_ContentInfo)\nDECLARE_ASN1_FUNCTIONS(CMS_ReceiptRequest)\nDECLARE_ASN1_PRINT_FUNCTION(CMS_ContentInfo)\n\n# define CMS_SIGNERINFO_ISSUER_SERIAL    0\n# define CMS_SIGNERINFO_KEYIDENTIFIER    1\n\n# define CMS_RECIPINFO_NONE              -1\n# define CMS_RECIPINFO_TRANS             0\n# define CMS_RECIPINFO_AGREE             1\n# define CMS_RECIPINFO_KEK               2\n# define CMS_RECIPINFO_PASS              3\n# define CMS_RECIPINFO_OTHER             4\n\n/* S/MIME related flags */\n\n# define CMS_TEXT                        0x1\n# define CMS_NOCERTS                     0x2\n# define CMS_NO_CONTENT_VERIFY           0x4\n# define CMS_NO_ATTR_VERIFY              0x8\n# define CMS_NOSIGS                      \\\n                        (CMS_NO_CONTENT_VERIFY|CMS_NO_ATTR_VERIFY)\n# define CMS_NOINTERN                    0x10\n# define CMS_NO_SIGNER_CERT_VERIFY       0x20\n# define CMS_NOVERIFY                    0x20\n# define CMS_DETACHED                    0x40\n# define CMS_BINARY                      0x80\n# define CMS_NOATTR                      0x100\n# define CMS_NOSMIMECAP                  0x200\n# define CMS_NOOLDMIMETYPE               0x400\n# define CMS_CRLFEOL                     0x800\n# define CMS_STREAM                      0x1000\n# define CMS_NOCRL                       0x2000\n# define CMS_PARTIAL                     0x4000\n# define CMS_REUSE_DIGEST                0x8000\n# define CMS_USE_KEYID                   0x10000\n# define CMS_DEBUG_DECRYPT               0x20000\n# define CMS_KEY_PARAM                   0x40000\n\nconst ASN1_OBJECT *CMS_get0_type(CMS_ContentInfo *cms);\n\nBIO *CMS_dataInit(CMS_ContentInfo *cms, BIO *icont);\nint CMS_dataFinal(CMS_ContentInfo *cms, BIO *bio);\n\nASN1_OCTET_STRING **CMS_get0_content(CMS_ContentInfo *cms);\nint CMS_is_detached(CMS_ContentInfo *cms);\nint CMS_set_detached(CMS_ContentInfo *cms, int detached);\n\n# ifdef HEADER_PEM_H\nDECLARE_PEM_rw_const(CMS, CMS_ContentInfo)\n# endif\nint CMS_stream(unsigned char ***boundary, CMS_ContentInfo *cms);\nCMS_ContentInfo *d2i_CMS_bio(BIO *bp, CMS_ContentInfo **cms);\nint i2d_CMS_bio(BIO *bp, CMS_ContentInfo *cms);\n\nBIO *BIO_new_CMS(BIO *out, CMS_ContentInfo *cms);\nint i2d_CMS_bio_stream(BIO *out, CMS_ContentInfo *cms, BIO *in, int flags);\nint PEM_write_bio_CMS_stream(BIO *out, CMS_ContentInfo *cms, BIO *in,\n                             int flags);\nCMS_ContentInfo *SMIME_read_CMS(BIO *bio, BIO **bcont);\nint SMIME_write_CMS(BIO *bio, CMS_ContentInfo *cms, BIO *data, int flags);\n\nint CMS_final(CMS_ContentInfo *cms, BIO *data, BIO *dcont,\n              unsigned int flags);\n\nCMS_ContentInfo *CMS_sign(X509 *signcert, EVP_PKEY *pkey,\n                          STACK_OF(X509) *certs, BIO *data,\n                          unsigned int flags);\n\nCMS_ContentInfo *CMS_sign_receipt(CMS_SignerInfo *si,\n                                  X509 *signcert, EVP_PKEY *pkey,\n                                  STACK_OF(X509) *certs, unsigned int flags);\n\nint CMS_data(CMS_ContentInfo *cms, BIO *out, unsigned int flags);\nCMS_ContentInfo *CMS_data_create(BIO *in, unsigned int flags);\n\nint CMS_digest_verify(CMS_ContentInfo *cms, BIO *dcont, BIO *out,\n                      unsigned int flags);\nCMS_ContentInfo *CMS_digest_create(BIO *in, const EVP_MD *md,\n                                   unsigned int flags);\n\nint CMS_EncryptedData_decrypt(CMS_ContentInfo *cms,\n                              const unsigned char *key, size_t keylen,\n                              BIO *dcont, BIO *out, unsigned int flags);\n\nCMS_ContentInfo *CMS_EncryptedData_encrypt(BIO *in, const EVP_CIPHER *cipher,\n                                           const unsigned char *key,\n                                           size_t keylen, unsigned int flags);\n\nint CMS_EncryptedData_set1_key(CMS_ContentInfo *cms, const EVP_CIPHER *ciph,\n                               const unsigned char *key, size_t keylen);\n\nint CMS_verify(CMS_ContentInfo *cms, STACK_OF(X509) *certs,\n               X509_STORE *store, BIO *dcont, BIO *out, unsigned int flags);\n\nint CMS_verify_receipt(CMS_ContentInfo *rcms, CMS_ContentInfo *ocms,\n                       STACK_OF(X509) *certs,\n                       X509_STORE *store, unsigned int flags);\n\nSTACK_OF(X509) *CMS_get0_signers(CMS_ContentInfo *cms);\n\nCMS_ContentInfo *CMS_encrypt(STACK_OF(X509) *certs, BIO *in,\n                             const EVP_CIPHER *cipher, unsigned int flags);\n\nint CMS_decrypt(CMS_ContentInfo *cms, EVP_PKEY *pkey, X509 *cert,\n                BIO *dcont, BIO *out, unsigned int flags);\n\nint CMS_decrypt_set1_pkey(CMS_ContentInfo *cms, EVP_PKEY *pk, X509 *cert);\nint CMS_decrypt_set1_key(CMS_ContentInfo *cms,\n                         unsigned char *key, size_t keylen,\n                         unsigned char *id, size_t idlen);\nint CMS_decrypt_set1_password(CMS_ContentInfo *cms,\n                              unsigned char *pass, ossl_ssize_t passlen);\n\nSTACK_OF(CMS_RecipientInfo) *CMS_get0_RecipientInfos(CMS_ContentInfo *cms);\nint CMS_RecipientInfo_type(CMS_RecipientInfo *ri);\nEVP_PKEY_CTX *CMS_RecipientInfo_get0_pkey_ctx(CMS_RecipientInfo *ri);\nCMS_ContentInfo *CMS_EnvelopedData_create(const EVP_CIPHER *cipher);\nCMS_RecipientInfo *CMS_add1_recipient_cert(CMS_ContentInfo *cms,\n                                           X509 *recip, unsigned int flags);\nint CMS_RecipientInfo_set0_pkey(CMS_RecipientInfo *ri, EVP_PKEY *pkey);\nint CMS_RecipientInfo_ktri_cert_cmp(CMS_RecipientInfo *ri, X509 *cert);\nint CMS_RecipientInfo_ktri_get0_algs(CMS_RecipientInfo *ri,\n                                     EVP_PKEY **pk, X509 **recip,\n                                     X509_ALGOR **palg);\nint CMS_RecipientInfo_ktri_get0_signer_id(CMS_RecipientInfo *ri,\n                                          ASN1_OCTET_STRING **keyid,\n                                          X509_NAME **issuer,\n                                          ASN1_INTEGER **sno);\n\nCMS_RecipientInfo *CMS_add0_recipient_key(CMS_ContentInfo *cms, int nid,\n                                          unsigned char *key, size_t keylen,\n                                          unsigned char *id, size_t idlen,\n                                          ASN1_GENERALIZEDTIME *date,\n                                          ASN1_OBJECT *otherTypeId,\n                                          ASN1_TYPE *otherType);\n\nint CMS_RecipientInfo_kekri_get0_id(CMS_RecipientInfo *ri,\n                                    X509_ALGOR **palg,\n                                    ASN1_OCTET_STRING **pid,\n                                    ASN1_GENERALIZEDTIME **pdate,\n                                    ASN1_OBJECT **potherid,\n                                    ASN1_TYPE **pothertype);\n\nint CMS_RecipientInfo_set0_key(CMS_RecipientInfo *ri,\n                               unsigned char *key, size_t keylen);\n\nint CMS_RecipientInfo_kekri_id_cmp(CMS_RecipientInfo *ri,\n                                   const unsigned char *id, size_t idlen);\n\nint CMS_RecipientInfo_set0_password(CMS_RecipientInfo *ri,\n                                    unsigned char *pass,\n                                    ossl_ssize_t passlen);\n\nCMS_RecipientInfo *CMS_add0_recipient_password(CMS_ContentInfo *cms,\n                                               int iter, int wrap_nid,\n                                               int pbe_nid,\n                                               unsigned char *pass,\n                                               ossl_ssize_t passlen,\n                                               const EVP_CIPHER *kekciph);\n\nint CMS_RecipientInfo_decrypt(CMS_ContentInfo *cms, CMS_RecipientInfo *ri);\nint CMS_RecipientInfo_encrypt(CMS_ContentInfo *cms, CMS_RecipientInfo *ri);\n\nint CMS_uncompress(CMS_ContentInfo *cms, BIO *dcont, BIO *out,\n                   unsigned int flags);\nCMS_ContentInfo *CMS_compress(BIO *in, int comp_nid, unsigned int flags);\n\nint CMS_set1_eContentType(CMS_ContentInfo *cms, const ASN1_OBJECT *oid);\nconst ASN1_OBJECT *CMS_get0_eContentType(CMS_ContentInfo *cms);\n\nCMS_CertificateChoices *CMS_add0_CertificateChoices(CMS_ContentInfo *cms);\nint CMS_add0_cert(CMS_ContentInfo *cms, X509 *cert);\nint CMS_add1_cert(CMS_ContentInfo *cms, X509 *cert);\nSTACK_OF(X509) *CMS_get1_certs(CMS_ContentInfo *cms);\n\nCMS_RevocationInfoChoice *CMS_add0_RevocationInfoChoice(CMS_ContentInfo *cms);\nint CMS_add0_crl(CMS_ContentInfo *cms, X509_CRL *crl);\nint CMS_add1_crl(CMS_ContentInfo *cms, X509_CRL *crl);\nSTACK_OF(X509_CRL) *CMS_get1_crls(CMS_ContentInfo *cms);\n\nint CMS_SignedData_init(CMS_ContentInfo *cms);\nCMS_SignerInfo *CMS_add1_signer(CMS_ContentInfo *cms,\n                                X509 *signer, EVP_PKEY *pk, const EVP_MD *md,\n                                unsigned int flags);\nEVP_PKEY_CTX *CMS_SignerInfo_get0_pkey_ctx(CMS_SignerInfo *si);\nEVP_MD_CTX *CMS_SignerInfo_get0_md_ctx(CMS_SignerInfo *si);\nSTACK_OF(CMS_SignerInfo) *CMS_get0_SignerInfos(CMS_ContentInfo *cms);\n\nvoid CMS_SignerInfo_set1_signer_cert(CMS_SignerInfo *si, X509 *signer);\nint CMS_SignerInfo_get0_signer_id(CMS_SignerInfo *si,\n                                  ASN1_OCTET_STRING **keyid,\n                                  X509_NAME **issuer, ASN1_INTEGER **sno);\nint CMS_SignerInfo_cert_cmp(CMS_SignerInfo *si, X509 *cert);\nint CMS_set1_signers_certs(CMS_ContentInfo *cms, STACK_OF(X509) *certs,\n                           unsigned int flags);\nvoid CMS_SignerInfo_get0_algs(CMS_SignerInfo *si, EVP_PKEY **pk,\n                              X509 **signer, X509_ALGOR **pdig,\n                              X509_ALGOR **psig);\nASN1_OCTET_STRING *CMS_SignerInfo_get0_signature(CMS_SignerInfo *si);\nint CMS_SignerInfo_sign(CMS_SignerInfo *si);\nint CMS_SignerInfo_verify(CMS_SignerInfo *si);\nint CMS_SignerInfo_verify_content(CMS_SignerInfo *si, BIO *chain);\n\nint CMS_add_smimecap(CMS_SignerInfo *si, STACK_OF(X509_ALGOR) *algs);\nint CMS_add_simple_smimecap(STACK_OF(X509_ALGOR) **algs,\n                            int algnid, int keysize);\nint CMS_add_standard_smimecap(STACK_OF(X509_ALGOR) **smcap);\n\nint CMS_signed_get_attr_count(const CMS_SignerInfo *si);\nint CMS_signed_get_attr_by_NID(const CMS_SignerInfo *si, int nid,\n                               int lastpos);\nint CMS_signed_get_attr_by_OBJ(const CMS_SignerInfo *si, ASN1_OBJECT *obj,\n                               int lastpos);\nX509_ATTRIBUTE *CMS_signed_get_attr(const CMS_SignerInfo *si, int loc);\nX509_ATTRIBUTE *CMS_signed_delete_attr(CMS_SignerInfo *si, int loc);\nint CMS_signed_add1_attr(CMS_SignerInfo *si, X509_ATTRIBUTE *attr);\nint CMS_signed_add1_attr_by_OBJ(CMS_SignerInfo *si,\n                                const ASN1_OBJECT *obj, int type,\n                                const void *bytes, int len);\nint CMS_signed_add1_attr_by_NID(CMS_SignerInfo *si,\n                                int nid, int type,\n                                const void *bytes, int len);\nint CMS_signed_add1_attr_by_txt(CMS_SignerInfo *si,\n                                const char *attrname, int type,\n                                const void *bytes, int len);\nvoid *CMS_signed_get0_data_by_OBJ(CMS_SignerInfo *si, ASN1_OBJECT *oid,\n                                  int lastpos, int type);\n\nint CMS_unsigned_get_attr_count(const CMS_SignerInfo *si);\nint CMS_unsigned_get_attr_by_NID(const CMS_SignerInfo *si, int nid,\n                                 int lastpos);\nint CMS_unsigned_get_attr_by_OBJ(const CMS_SignerInfo *si, ASN1_OBJECT *obj,\n                                 int lastpos);\nX509_ATTRIBUTE *CMS_unsigned_get_attr(const CMS_SignerInfo *si, int loc);\nX509_ATTRIBUTE *CMS_unsigned_delete_attr(CMS_SignerInfo *si, int loc);\nint CMS_unsigned_add1_attr(CMS_SignerInfo *si, X509_ATTRIBUTE *attr);\nint CMS_unsigned_add1_attr_by_OBJ(CMS_SignerInfo *si,\n                                  const ASN1_OBJECT *obj, int type,\n                                  const void *bytes, int len);\nint CMS_unsigned_add1_attr_by_NID(CMS_SignerInfo *si,\n                                  int nid, int type,\n                                  const void *bytes, int len);\nint CMS_unsigned_add1_attr_by_txt(CMS_SignerInfo *si,\n                                  const char *attrname, int type,\n                                  const void *bytes, int len);\nvoid *CMS_unsigned_get0_data_by_OBJ(CMS_SignerInfo *si, ASN1_OBJECT *oid,\n                                    int lastpos, int type);\n\n# ifdef HEADER_X509V3_H\n\nint CMS_get1_ReceiptRequest(CMS_SignerInfo *si, CMS_ReceiptRequest **prr);\nCMS_ReceiptRequest *CMS_ReceiptRequest_create0(unsigned char *id, int idlen,\n                                               int allorfirst,\n                                               STACK_OF(GENERAL_NAMES)\n                                               *receiptList, STACK_OF(GENERAL_NAMES)\n                                               *receiptsTo);\nint CMS_add1_ReceiptRequest(CMS_SignerInfo *si, CMS_ReceiptRequest *rr);\nvoid CMS_ReceiptRequest_get0_values(CMS_ReceiptRequest *rr,\n                                    ASN1_STRING **pcid,\n                                    int *pallorfirst,\n                                    STACK_OF(GENERAL_NAMES) **plist,\n                                    STACK_OF(GENERAL_NAMES) **prto);\n# endif\nint CMS_RecipientInfo_kari_get0_alg(CMS_RecipientInfo *ri,\n                                    X509_ALGOR **palg,\n                                    ASN1_OCTET_STRING **pukm);\nSTACK_OF(CMS_RecipientEncryptedKey)\n*CMS_RecipientInfo_kari_get0_reks(CMS_RecipientInfo *ri);\n\nint CMS_RecipientInfo_kari_get0_orig_id(CMS_RecipientInfo *ri,\n                                        X509_ALGOR **pubalg,\n                                        ASN1_BIT_STRING **pubkey,\n                                        ASN1_OCTET_STRING **keyid,\n                                        X509_NAME **issuer,\n                                        ASN1_INTEGER **sno);\n\nint CMS_RecipientInfo_kari_orig_id_cmp(CMS_RecipientInfo *ri, X509 *cert);\n\nint CMS_RecipientEncryptedKey_get0_id(CMS_RecipientEncryptedKey *rek,\n                                      ASN1_OCTET_STRING **keyid,\n                                      ASN1_GENERALIZEDTIME **tm,\n                                      CMS_OtherKeyAttribute **other,\n                                      X509_NAME **issuer, ASN1_INTEGER **sno);\nint CMS_RecipientEncryptedKey_cert_cmp(CMS_RecipientEncryptedKey *rek,\n                                       X509 *cert);\nint CMS_RecipientInfo_kari_set0_pkey(CMS_RecipientInfo *ri, EVP_PKEY *pk);\nEVP_CIPHER_CTX *CMS_RecipientInfo_kari_get0_ctx(CMS_RecipientInfo *ri);\nint CMS_RecipientInfo_kari_decrypt(CMS_ContentInfo *cms,\n                                   CMS_RecipientInfo *ri,\n                                   CMS_RecipientEncryptedKey *rek);\n\nint CMS_SharedInfo_encode(unsigned char **pder, X509_ALGOR *kekalg,\n                          ASN1_OCTET_STRING *ukm, int keylen);\n\n/* BEGIN ERROR CODES */\n/*\n * The following lines are auto generated by the script mkerr.pl. Any changes\n * made after this point may be overwritten when the script is next run.\n */\nvoid ERR_load_CMS_strings(void);\n\n/* Error codes for the CMS functions. */\n\n/* Function codes. */\n# define CMS_F_CHECK_CONTENT                              99\n# define CMS_F_CMS_ADD0_CERT                              164\n# define CMS_F_CMS_ADD0_RECIPIENT_KEY                     100\n# define CMS_F_CMS_ADD0_RECIPIENT_PASSWORD                165\n# define CMS_F_CMS_ADD1_RECEIPTREQUEST                    158\n# define CMS_F_CMS_ADD1_RECIPIENT_CERT                    101\n# define CMS_F_CMS_ADD1_SIGNER                            102\n# define CMS_F_CMS_ADD1_SIGNINGTIME                       103\n# define CMS_F_CMS_COMPRESS                               104\n# define CMS_F_CMS_COMPRESSEDDATA_CREATE                  105\n# define CMS_F_CMS_COMPRESSEDDATA_INIT_BIO                106\n# define CMS_F_CMS_COPY_CONTENT                           107\n# define CMS_F_CMS_COPY_MESSAGEDIGEST                     108\n# define CMS_F_CMS_DATA                                   109\n# define CMS_F_CMS_DATAFINAL                              110\n# define CMS_F_CMS_DATAINIT                               111\n# define CMS_F_CMS_DECRYPT                                112\n# define CMS_F_CMS_DECRYPT_SET1_KEY                       113\n# define CMS_F_CMS_DECRYPT_SET1_PASSWORD                  166\n# define CMS_F_CMS_DECRYPT_SET1_PKEY                      114\n# define CMS_F_CMS_DIGESTALGORITHM_FIND_CTX               115\n# define CMS_F_CMS_DIGESTALGORITHM_INIT_BIO               116\n# define CMS_F_CMS_DIGESTEDDATA_DO_FINAL                  117\n# define CMS_F_CMS_DIGEST_VERIFY                          118\n# define CMS_F_CMS_ENCODE_RECEIPT                         161\n# define CMS_F_CMS_ENCRYPT                                119\n# define CMS_F_CMS_ENCRYPTEDCONTENT_INIT_BIO              120\n# define CMS_F_CMS_ENCRYPTEDDATA_DECRYPT                  121\n# define CMS_F_CMS_ENCRYPTEDDATA_ENCRYPT                  122\n# define CMS_F_CMS_ENCRYPTEDDATA_SET1_KEY                 123\n# define CMS_F_CMS_ENVELOPEDDATA_CREATE                   124\n# define CMS_F_CMS_ENVELOPEDDATA_INIT_BIO                 125\n# define CMS_F_CMS_ENVELOPED_DATA_INIT                    126\n# define CMS_F_CMS_ENV_ASN1_CTRL                          171\n# define CMS_F_CMS_FINAL                                  127\n# define CMS_F_CMS_GET0_CERTIFICATE_CHOICES               128\n# define CMS_F_CMS_GET0_CONTENT                           129\n# define CMS_F_CMS_GET0_ECONTENT_TYPE                     130\n# define CMS_F_CMS_GET0_ENVELOPED                         131\n# define CMS_F_CMS_GET0_REVOCATION_CHOICES                132\n# define CMS_F_CMS_GET0_SIGNED                            133\n# define CMS_F_CMS_MSGSIGDIGEST_ADD1                      162\n# define CMS_F_CMS_RECEIPTREQUEST_CREATE0                 159\n# define CMS_F_CMS_RECEIPT_VERIFY                         160\n# define CMS_F_CMS_RECIPIENTINFO_DECRYPT                  134\n# define CMS_F_CMS_RECIPIENTINFO_ENCRYPT                  169\n# define CMS_F_CMS_RECIPIENTINFO_KARI_ENCRYPT             178\n# define CMS_F_CMS_RECIPIENTINFO_KARI_GET0_ALG            175\n# define CMS_F_CMS_RECIPIENTINFO_KARI_GET0_ORIG_ID        173\n# define CMS_F_CMS_RECIPIENTINFO_KARI_GET0_REKS           172\n# define CMS_F_CMS_RECIPIENTINFO_KARI_ORIG_ID_CMP         174\n# define CMS_F_CMS_RECIPIENTINFO_KEKRI_DECRYPT            135\n# define CMS_F_CMS_RECIPIENTINFO_KEKRI_ENCRYPT            136\n# define CMS_F_CMS_RECIPIENTINFO_KEKRI_GET0_ID            137\n# define CMS_F_CMS_RECIPIENTINFO_KEKRI_ID_CMP             138\n# define CMS_F_CMS_RECIPIENTINFO_KTRI_CERT_CMP            139\n# define CMS_F_CMS_RECIPIENTINFO_KTRI_DECRYPT             140\n# define CMS_F_CMS_RECIPIENTINFO_KTRI_ENCRYPT             141\n# define CMS_F_CMS_RECIPIENTINFO_KTRI_GET0_ALGS           142\n# define CMS_F_CMS_RECIPIENTINFO_KTRI_GET0_SIGNER_ID      143\n# define CMS_F_CMS_RECIPIENTINFO_PWRI_CRYPT               167\n# define CMS_F_CMS_RECIPIENTINFO_SET0_KEY                 144\n# define CMS_F_CMS_RECIPIENTINFO_SET0_PASSWORD            168\n# define CMS_F_CMS_RECIPIENTINFO_SET0_PKEY                145\n# define CMS_F_CMS_SD_ASN1_CTRL                           170\n# define CMS_F_CMS_SET1_IAS                               176\n# define CMS_F_CMS_SET1_KEYID                             177\n# define CMS_F_CMS_SET1_SIGNERIDENTIFIER                  146\n# define CMS_F_CMS_SET_DETACHED                           147\n# define CMS_F_CMS_SIGN                                   148\n# define CMS_F_CMS_SIGNED_DATA_INIT                       149\n# define CMS_F_CMS_SIGNERINFO_CONTENT_SIGN                150\n# define CMS_F_CMS_SIGNERINFO_SIGN                        151\n# define CMS_F_CMS_SIGNERINFO_VERIFY                      152\n# define CMS_F_CMS_SIGNERINFO_VERIFY_CERT                 153\n# define CMS_F_CMS_SIGNERINFO_VERIFY_CONTENT              154\n# define CMS_F_CMS_SIGN_RECEIPT                           163\n# define CMS_F_CMS_STREAM                                 155\n# define CMS_F_CMS_UNCOMPRESS                             156\n# define CMS_F_CMS_VERIFY                                 157\n\n/* Reason codes. */\n# define CMS_R_ADD_SIGNER_ERROR                           99\n# define CMS_R_CERTIFICATE_ALREADY_PRESENT                175\n# define CMS_R_CERTIFICATE_HAS_NO_KEYID                   160\n# define CMS_R_CERTIFICATE_VERIFY_ERROR                   100\n# define CMS_R_CIPHER_INITIALISATION_ERROR                101\n# define CMS_R_CIPHER_PARAMETER_INITIALISATION_ERROR      102\n# define CMS_R_CMS_DATAFINAL_ERROR                        103\n# define CMS_R_CMS_LIB                                    104\n# define CMS_R_CONTENTIDENTIFIER_MISMATCH                 170\n# define CMS_R_CONTENT_NOT_FOUND                          105\n# define CMS_R_CONTENT_TYPE_MISMATCH                      171\n# define CMS_R_CONTENT_TYPE_NOT_COMPRESSED_DATA           106\n# define CMS_R_CONTENT_TYPE_NOT_ENVELOPED_DATA            107\n# define CMS_R_CONTENT_TYPE_NOT_SIGNED_DATA               108\n# define CMS_R_CONTENT_VERIFY_ERROR                       109\n# define CMS_R_CTRL_ERROR                                 110\n# define CMS_R_CTRL_FAILURE                               111\n# define CMS_R_DECRYPT_ERROR                              112\n# define CMS_R_DIGEST_ERROR                               161\n# define CMS_R_ERROR_GETTING_PUBLIC_KEY                   113\n# define CMS_R_ERROR_READING_MESSAGEDIGEST_ATTRIBUTE      114\n# define CMS_R_ERROR_SETTING_KEY                          115\n# define CMS_R_ERROR_SETTING_RECIPIENTINFO                116\n# define CMS_R_INVALID_ENCRYPTED_KEY_LENGTH               117\n# define CMS_R_INVALID_KEY_ENCRYPTION_PARAMETER           176\n# define CMS_R_INVALID_KEY_LENGTH                         118\n# define CMS_R_MD_BIO_INIT_ERROR                          119\n# define CMS_R_MESSAGEDIGEST_ATTRIBUTE_WRONG_LENGTH       120\n# define CMS_R_MESSAGEDIGEST_WRONG_LENGTH                 121\n# define CMS_R_MSGSIGDIGEST_ERROR                         172\n# define CMS_R_MSGSIGDIGEST_VERIFICATION_FAILURE          162\n# define CMS_R_MSGSIGDIGEST_WRONG_LENGTH                  163\n# define CMS_R_NEED_ONE_SIGNER                            164\n# define CMS_R_NOT_A_SIGNED_RECEIPT                       165\n# define CMS_R_NOT_ENCRYPTED_DATA                         122\n# define CMS_R_NOT_KEK                                    123\n# define CMS_R_NOT_KEY_AGREEMENT                          181\n# define CMS_R_NOT_KEY_TRANSPORT                          124\n# define CMS_R_NOT_PWRI                                   177\n# define CMS_R_NOT_SUPPORTED_FOR_THIS_KEY_TYPE            125\n# define CMS_R_NO_CIPHER                                  126\n# define CMS_R_NO_CONTENT                                 127\n# define CMS_R_NO_CONTENT_TYPE                            173\n# define CMS_R_NO_DEFAULT_DIGEST                          128\n# define CMS_R_NO_DIGEST_SET                              129\n# define CMS_R_NO_KEY                                     130\n# define CMS_R_NO_KEY_OR_CERT                             174\n# define CMS_R_NO_MATCHING_DIGEST                         131\n# define CMS_R_NO_MATCHING_RECIPIENT                      132\n# define CMS_R_NO_MATCHING_SIGNATURE                      166\n# define CMS_R_NO_MSGSIGDIGEST                            167\n# define CMS_R_NO_PASSWORD                                178\n# define CMS_R_NO_PRIVATE_KEY                             133\n# define CMS_R_NO_PUBLIC_KEY                              134\n# define CMS_R_NO_RECEIPT_REQUEST                         168\n# define CMS_R_NO_SIGNERS                                 135\n# define CMS_R_PRIVATE_KEY_DOES_NOT_MATCH_CERTIFICATE     136\n# define CMS_R_RECEIPT_DECODE_ERROR                       169\n# define CMS_R_RECIPIENT_ERROR                            137\n# define CMS_R_SIGNER_CERTIFICATE_NOT_FOUND               138\n# define CMS_R_SIGNFINAL_ERROR                            139\n# define CMS_R_SMIME_TEXT_ERROR                           140\n# define CMS_R_STORE_INIT_ERROR                           141\n# define CMS_R_TYPE_NOT_COMPRESSED_DATA                   142\n# define CMS_R_TYPE_NOT_DATA                              143\n# define CMS_R_TYPE_NOT_DIGESTED_DATA                     144\n# define CMS_R_TYPE_NOT_ENCRYPTED_DATA                    145\n# define CMS_R_TYPE_NOT_ENVELOPED_DATA                    146\n# define CMS_R_UNABLE_TO_FINALIZE_CONTEXT                 147\n# define CMS_R_UNKNOWN_CIPHER                             148\n# define CMS_R_UNKNOWN_DIGEST_ALGORIHM                    149\n# define CMS_R_UNKNOWN_ID                                 150\n# define CMS_R_UNSUPPORTED_COMPRESSION_ALGORITHM          151\n# define CMS_R_UNSUPPORTED_CONTENT_TYPE                   152\n# define CMS_R_UNSUPPORTED_KEK_ALGORITHM                  153\n# define CMS_R_UNSUPPORTED_KEY_ENCRYPTION_ALGORITHM       179\n# define CMS_R_UNSUPPORTED_RECIPIENT_TYPE                 154\n# define CMS_R_UNSUPPORTED_RECPIENTINFO_TYPE              155\n# define CMS_R_UNSUPPORTED_TYPE                           156\n# define CMS_R_UNWRAP_ERROR                               157\n# define CMS_R_UNWRAP_FAILURE                             180\n# define CMS_R_VERIFICATION_FAILURE                       158\n# define CMS_R_WRAP_ERROR                                 159\n\n#ifdef  __cplusplus\n}\n#endif\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/arm64/include/openssl/conf.h",
    "content": "/* crypto/conf/conf.h */\n/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)\n * All rights reserved.\n *\n * This package is an SSL implementation written\n * by Eric Young (eay@cryptsoft.com).\n * The implementation was written so as to conform with Netscapes SSL.\n *\n * This library is free for commercial and non-commercial use as long as\n * the following conditions are aheared to.  The following conditions\n * apply to all code found in this distribution, be it the RC4, RSA,\n * lhash, DES, etc., code; not just the SSL code.  The SSL documentation\n * included with this distribution is covered by the same copyright terms\n * except that the holder is Tim Hudson (tjh@cryptsoft.com).\n *\n * Copyright remains Eric Young's, and as such any Copyright notices in\n * the code are not to be removed.\n * If this package is used in a product, Eric Young should be given attribution\n * as the author of the parts of the library used.\n * This can be in the form of a textual message at program startup or\n * in documentation (online or textual) provided with the package.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the copyright\n *    notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in the\n *    documentation and/or other materials provided with the distribution.\n * 3. All advertising materials mentioning features or use of this software\n *    must display the following acknowledgement:\n *    \"This product includes cryptographic software written by\n *     Eric Young (eay@cryptsoft.com)\"\n *    The word 'cryptographic' can be left out if the rouines from the library\n *    being used are not cryptographic related :-).\n * 4. If you include any Windows specific code (or a derivative thereof) from\n *    the apps directory (application code) you must include an acknowledgement:\n *    \"This product includes software written by Tim Hudson (tjh@cryptsoft.com)\"\n *\n * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n * SUCH DAMAGE.\n *\n * The licence and distribution terms for any publically available version or\n * derivative of this code cannot be changed.  i.e. this code cannot simply be\n * copied and put under another distribution licence\n * [including the GNU Public Licence.]\n */\n\n#ifndef  HEADER_CONF_H\n# define HEADER_CONF_H\n\n# include <openssl/bio.h>\n# include <openssl/lhash.h>\n# include <openssl/stack.h>\n# include <openssl/safestack.h>\n# include <openssl/e_os2.h>\n\n# include <openssl/ossl_typ.h>\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\ntypedef struct {\n    char *section;\n    char *name;\n    char *value;\n} CONF_VALUE;\n\nDECLARE_STACK_OF(CONF_VALUE)\nDECLARE_LHASH_OF(CONF_VALUE);\n\nstruct conf_st;\nstruct conf_method_st;\ntypedef struct conf_method_st CONF_METHOD;\n\nstruct conf_method_st {\n    const char *name;\n    CONF *(*create) (CONF_METHOD *meth);\n    int (*init) (CONF *conf);\n    int (*destroy) (CONF *conf);\n    int (*destroy_data) (CONF *conf);\n    int (*load_bio) (CONF *conf, BIO *bp, long *eline);\n    int (*dump) (const CONF *conf, BIO *bp);\n    int (*is_number) (const CONF *conf, char c);\n    int (*to_int) (const CONF *conf, char c);\n    int (*load) (CONF *conf, const char *name, long *eline);\n};\n\n/* Module definitions */\n\ntypedef struct conf_imodule_st CONF_IMODULE;\ntypedef struct conf_module_st CONF_MODULE;\n\nDECLARE_STACK_OF(CONF_MODULE)\nDECLARE_STACK_OF(CONF_IMODULE)\n\n/* DSO module function typedefs */\ntypedef int conf_init_func (CONF_IMODULE *md, const CONF *cnf);\ntypedef void conf_finish_func (CONF_IMODULE *md);\n\n# define CONF_MFLAGS_IGNORE_ERRORS       0x1\n# define CONF_MFLAGS_IGNORE_RETURN_CODES 0x2\n# define CONF_MFLAGS_SILENT              0x4\n# define CONF_MFLAGS_NO_DSO              0x8\n# define CONF_MFLAGS_IGNORE_MISSING_FILE 0x10\n# define CONF_MFLAGS_DEFAULT_SECTION     0x20\n\nint CONF_set_default_method(CONF_METHOD *meth);\nvoid CONF_set_nconf(CONF *conf, LHASH_OF(CONF_VALUE) *hash);\nLHASH_OF(CONF_VALUE) *CONF_load(LHASH_OF(CONF_VALUE) *conf, const char *file,\n                                long *eline);\n# ifndef OPENSSL_NO_FP_API\nLHASH_OF(CONF_VALUE) *CONF_load_fp(LHASH_OF(CONF_VALUE) *conf, FILE *fp,\n                                   long *eline);\n# endif\nLHASH_OF(CONF_VALUE) *CONF_load_bio(LHASH_OF(CONF_VALUE) *conf, BIO *bp,\n                                    long *eline);\nSTACK_OF(CONF_VALUE) *CONF_get_section(LHASH_OF(CONF_VALUE) *conf,\n                                       const char *section);\nchar *CONF_get_string(LHASH_OF(CONF_VALUE) *conf, const char *group,\n                      const char *name);\nlong CONF_get_number(LHASH_OF(CONF_VALUE) *conf, const char *group,\n                     const char *name);\nvoid CONF_free(LHASH_OF(CONF_VALUE) *conf);\nint CONF_dump_fp(LHASH_OF(CONF_VALUE) *conf, FILE *out);\nint CONF_dump_bio(LHASH_OF(CONF_VALUE) *conf, BIO *out);\n\nvoid OPENSSL_config(const char *config_name);\nvoid OPENSSL_no_config(void);\n\n/*\n * New conf code.  The semantics are different from the functions above. If\n * that wasn't the case, the above functions would have been replaced\n */\n\nstruct conf_st {\n    CONF_METHOD *meth;\n    void *meth_data;\n    LHASH_OF(CONF_VALUE) *data;\n};\n\nCONF *NCONF_new(CONF_METHOD *meth);\nCONF_METHOD *NCONF_default(void);\nCONF_METHOD *NCONF_WIN32(void);\n# if 0                          /* Just to give you an idea of what I have in\n                                 * mind */\nCONF_METHOD *NCONF_XML(void);\n# endif\nvoid NCONF_free(CONF *conf);\nvoid NCONF_free_data(CONF *conf);\n\nint NCONF_load(CONF *conf, const char *file, long *eline);\n# ifndef OPENSSL_NO_FP_API\nint NCONF_load_fp(CONF *conf, FILE *fp, long *eline);\n# endif\nint NCONF_load_bio(CONF *conf, BIO *bp, long *eline);\nSTACK_OF(CONF_VALUE) *NCONF_get_section(const CONF *conf,\n                                        const char *section);\nchar *NCONF_get_string(const CONF *conf, const char *group, const char *name);\nint NCONF_get_number_e(const CONF *conf, const char *group, const char *name,\n                       long *result);\nint NCONF_dump_fp(const CONF *conf, FILE *out);\nint NCONF_dump_bio(const CONF *conf, BIO *out);\n\n# if 0                          /* The following function has no error\n                                 * checking, and should therefore be avoided */\nlong NCONF_get_number(CONF *conf, char *group, char *name);\n# else\n#  define NCONF_get_number(c,g,n,r) NCONF_get_number_e(c,g,n,r)\n# endif\n\n/* Module functions */\n\nint CONF_modules_load(const CONF *cnf, const char *appname,\n                      unsigned long flags);\nint CONF_modules_load_file(const char *filename, const char *appname,\n                           unsigned long flags);\nvoid CONF_modules_unload(int all);\nvoid CONF_modules_finish(void);\nvoid CONF_modules_free(void);\nint CONF_module_add(const char *name, conf_init_func *ifunc,\n                    conf_finish_func *ffunc);\n\nconst char *CONF_imodule_get_name(const CONF_IMODULE *md);\nconst char *CONF_imodule_get_value(const CONF_IMODULE *md);\nvoid *CONF_imodule_get_usr_data(const CONF_IMODULE *md);\nvoid CONF_imodule_set_usr_data(CONF_IMODULE *md, void *usr_data);\nCONF_MODULE *CONF_imodule_get_module(const CONF_IMODULE *md);\nunsigned long CONF_imodule_get_flags(const CONF_IMODULE *md);\nvoid CONF_imodule_set_flags(CONF_IMODULE *md, unsigned long flags);\nvoid *CONF_module_get_usr_data(CONF_MODULE *pmod);\nvoid CONF_module_set_usr_data(CONF_MODULE *pmod, void *usr_data);\n\nchar *CONF_get1_default_config_file(void);\n\nint CONF_parse_list(const char *list, int sep, int nospc,\n                    int (*list_cb) (const char *elem, int len, void *usr),\n                    void *arg);\n\nvoid OPENSSL_load_builtin_modules(void);\n\n/* BEGIN ERROR CODES */\n/*\n * The following lines are auto generated by the script mkerr.pl. Any changes\n * made after this point may be overwritten when the script is next run.\n */\nvoid ERR_load_CONF_strings(void);\n\n/* Error codes for the CONF functions. */\n\n/* Function codes. */\n# define CONF_F_CONF_DUMP_FP                              104\n# define CONF_F_CONF_LOAD                                 100\n# define CONF_F_CONF_LOAD_BIO                             102\n# define CONF_F_CONF_LOAD_FP                              103\n# define CONF_F_CONF_MODULES_LOAD                         116\n# define CONF_F_CONF_PARSE_LIST                           119\n# define CONF_F_DEF_LOAD                                  120\n# define CONF_F_DEF_LOAD_BIO                              121\n# define CONF_F_MODULE_INIT                               115\n# define CONF_F_MODULE_LOAD_DSO                           117\n# define CONF_F_MODULE_RUN                                118\n# define CONF_F_NCONF_DUMP_BIO                            105\n# define CONF_F_NCONF_DUMP_FP                             106\n# define CONF_F_NCONF_GET_NUMBER                          107\n# define CONF_F_NCONF_GET_NUMBER_E                        112\n# define CONF_F_NCONF_GET_SECTION                         108\n# define CONF_F_NCONF_GET_STRING                          109\n# define CONF_F_NCONF_LOAD                                113\n# define CONF_F_NCONF_LOAD_BIO                            110\n# define CONF_F_NCONF_LOAD_FP                             114\n# define CONF_F_NCONF_NEW                                 111\n# define CONF_F_STR_COPY                                  101\n\n/* Reason codes. */\n# define CONF_R_ERROR_LOADING_DSO                         110\n# define CONF_R_LIST_CANNOT_BE_NULL                       115\n# define CONF_R_MISSING_CLOSE_SQUARE_BRACKET              100\n# define CONF_R_MISSING_EQUAL_SIGN                        101\n# define CONF_R_MISSING_FINISH_FUNCTION                   111\n# define CONF_R_MISSING_INIT_FUNCTION                     112\n# define CONF_R_MODULE_INITIALIZATION_ERROR               109\n# define CONF_R_NO_CLOSE_BRACE                            102\n# define CONF_R_NO_CONF                                   105\n# define CONF_R_NO_CONF_OR_ENVIRONMENT_VARIABLE           106\n# define CONF_R_NO_SECTION                                107\n# define CONF_R_NO_SUCH_FILE                              114\n# define CONF_R_NO_VALUE                                  108\n# define CONF_R_UNABLE_TO_CREATE_NEW_SECTION              103\n# define CONF_R_UNKNOWN_MODULE_NAME                       113\n# define CONF_R_VARIABLE_HAS_NO_VALUE                     104\n\n#ifdef  __cplusplus\n}\n#endif\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/arm64/include/openssl/conf_api.h",
    "content": "/* conf_api.h */\n/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)\n * All rights reserved.\n *\n * This package is an SSL implementation written\n * by Eric Young (eay@cryptsoft.com).\n * The implementation was written so as to conform with Netscapes SSL.\n *\n * This library is free for commercial and non-commercial use as long as\n * the following conditions are aheared to.  The following conditions\n * apply to all code found in this distribution, be it the RC4, RSA,\n * lhash, DES, etc., code; not just the SSL code.  The SSL documentation\n * included with this distribution is covered by the same copyright terms\n * except that the holder is Tim Hudson (tjh@cryptsoft.com).\n *\n * Copyright remains Eric Young's, and as such any Copyright notices in\n * the code are not to be removed.\n * If this package is used in a product, Eric Young should be given attribution\n * as the author of the parts of the library used.\n * This can be in the form of a textual message at program startup or\n * in documentation (online or textual) provided with the package.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the copyright\n *    notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in the\n *    documentation and/or other materials provided with the distribution.\n * 3. All advertising materials mentioning features or use of this software\n *    must display the following acknowledgement:\n *    \"This product includes cryptographic software written by\n *     Eric Young (eay@cryptsoft.com)\"\n *    The word 'cryptographic' can be left out if the rouines from the library\n *    being used are not cryptographic related :-).\n * 4. If you include any Windows specific code (or a derivative thereof) from\n *    the apps directory (application code) you must include an acknowledgement:\n *    \"This product includes software written by Tim Hudson (tjh@cryptsoft.com)\"\n *\n * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n * SUCH DAMAGE.\n *\n * The licence and distribution terms for any publically available version or\n * derivative of this code cannot be changed.  i.e. this code cannot simply be\n * copied and put under another distribution licence\n * [including the GNU Public Licence.]\n */\n\n#ifndef  HEADER_CONF_API_H\n# define HEADER_CONF_API_H\n\n# include <openssl/lhash.h>\n# include <openssl/conf.h>\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n/* Up until OpenSSL 0.9.5a, this was new_section */\nCONF_VALUE *_CONF_new_section(CONF *conf, const char *section);\n/* Up until OpenSSL 0.9.5a, this was get_section */\nCONF_VALUE *_CONF_get_section(const CONF *conf, const char *section);\n/* Up until OpenSSL 0.9.5a, this was CONF_get_section */\nSTACK_OF(CONF_VALUE) *_CONF_get_section_values(const CONF *conf,\n                                               const char *section);\n\nint _CONF_add_string(CONF *conf, CONF_VALUE *section, CONF_VALUE *value);\nchar *_CONF_get_string(const CONF *conf, const char *section,\n                       const char *name);\nlong _CONF_get_number(const CONF *conf, const char *section,\n                      const char *name);\n\nint _CONF_new_data(CONF *conf);\nvoid _CONF_free_data(CONF *conf);\n\n#ifdef  __cplusplus\n}\n#endif\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/arm64/include/openssl/crypto.h",
    "content": "/* crypto/crypto.h */\n/* ====================================================================\n * Copyright (c) 1998-2006 The OpenSSL Project.  All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n *\n * 1. Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n *\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in\n *    the documentation and/or other materials provided with the\n *    distribution.\n *\n * 3. All advertising materials mentioning features or use of this\n *    software must display the following acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit. (http://www.openssl.org/)\"\n *\n * 4. The names \"OpenSSL Toolkit\" and \"OpenSSL Project\" must not be used to\n *    endorse or promote products derived from this software without\n *    prior written permission. For written permission, please contact\n *    openssl-core@openssl.org.\n *\n * 5. Products derived from this software may not be called \"OpenSSL\"\n *    nor may \"OpenSSL\" appear in their names without prior written\n *    permission of the OpenSSL Project.\n *\n * 6. Redistributions of any form whatsoever must retain the following\n *    acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit (http://www.openssl.org/)\"\n *\n * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY\n * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\n * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR\n * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\n * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,\n * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED\n * OF THE POSSIBILITY OF SUCH DAMAGE.\n * ====================================================================\n *\n * This product includes cryptographic software written by Eric Young\n * (eay@cryptsoft.com).  This product includes software written by Tim\n * Hudson (tjh@cryptsoft.com).\n *\n */\n/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)\n * All rights reserved.\n *\n * This package is an SSL implementation written\n * by Eric Young (eay@cryptsoft.com).\n * The implementation was written so as to conform with Netscapes SSL.\n *\n * This library is free for commercial and non-commercial use as long as\n * the following conditions are aheared to.  The following conditions\n * apply to all code found in this distribution, be it the RC4, RSA,\n * lhash, DES, etc., code; not just the SSL code.  The SSL documentation\n * included with this distribution is covered by the same copyright terms\n * except that the holder is Tim Hudson (tjh@cryptsoft.com).\n *\n * Copyright remains Eric Young's, and as such any Copyright notices in\n * the code are not to be removed.\n * If this package is used in a product, Eric Young should be given attribution\n * as the author of the parts of the library used.\n * This can be in the form of a textual message at program startup or\n * in documentation (online or textual) provided with the package.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the copyright\n *    notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in the\n *    documentation and/or other materials provided with the distribution.\n * 3. All advertising materials mentioning features or use of this software\n *    must display the following acknowledgement:\n *    \"This product includes cryptographic software written by\n *     Eric Young (eay@cryptsoft.com)\"\n *    The word 'cryptographic' can be left out if the rouines from the library\n *    being used are not cryptographic related :-).\n * 4. If you include any Windows specific code (or a derivative thereof) from\n *    the apps directory (application code) you must include an acknowledgement:\n *    \"This product includes software written by Tim Hudson (tjh@cryptsoft.com)\"\n *\n * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n * SUCH DAMAGE.\n *\n * The licence and distribution terms for any publically available version or\n * derivative of this code cannot be changed.  i.e. this code cannot simply be\n * copied and put under another distribution licence\n * [including the GNU Public Licence.]\n */\n/* ====================================================================\n * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED.\n * ECDH support in OpenSSL originally developed by\n * SUN MICROSYSTEMS, INC., and contributed to the OpenSSL project.\n */\n\n#ifndef HEADER_CRYPTO_H\n# define HEADER_CRYPTO_H\n\n# include <stdlib.h>\n\n# include <openssl/e_os2.h>\n\n# ifndef OPENSSL_NO_FP_API\n#  include <stdio.h>\n# endif\n\n# include <openssl/stack.h>\n# include <openssl/safestack.h>\n# include <openssl/opensslv.h>\n# include <openssl/ossl_typ.h>\n\n# ifdef CHARSET_EBCDIC\n#  include <openssl/ebcdic.h>\n# endif\n\n/*\n * Resolve problems on some operating systems with symbol names that clash\n * one way or another\n */\n# include <openssl/symhacks.h>\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n/* Backward compatibility to SSLeay */\n/*\n * This is more to be used to check the correct DLL is being used in the MS\n * world.\n */\n# define SSLEAY_VERSION_NUMBER   OPENSSL_VERSION_NUMBER\n# define SSLEAY_VERSION          0\n/* #define SSLEAY_OPTIONS       1 no longer supported */\n# define SSLEAY_CFLAGS           2\n# define SSLEAY_BUILT_ON         3\n# define SSLEAY_PLATFORM         4\n# define SSLEAY_DIR              5\n\n/* Already declared in ossl_typ.h */\n# if 0\ntypedef struct crypto_ex_data_st CRYPTO_EX_DATA;\n/* Called when a new object is created */\ntypedef int CRYPTO_EX_new (void *parent, void *ptr, CRYPTO_EX_DATA *ad,\n                           int idx, long argl, void *argp);\n/* Called when an object is free()ed */\ntypedef void CRYPTO_EX_free (void *parent, void *ptr, CRYPTO_EX_DATA *ad,\n                             int idx, long argl, void *argp);\n/* Called when we need to dup an object */\ntypedef int CRYPTO_EX_dup (CRYPTO_EX_DATA *to, CRYPTO_EX_DATA *from,\n                           void *from_d, int idx, long argl, void *argp);\n# endif\n\n/* A generic structure to pass assorted data in a expandable way */\ntypedef struct openssl_item_st {\n    int code;\n    void *value;                /* Not used for flag attributes */\n    size_t value_size;          /* Max size of value for output, length for\n                                 * input */\n    size_t *value_length;       /* Returned length of value for output */\n} OPENSSL_ITEM;\n\n/*\n * When changing the CRYPTO_LOCK_* list, be sure to maintin the text lock\n * names in cryptlib.c\n */\n\n# define CRYPTO_LOCK_ERR                 1\n# define CRYPTO_LOCK_EX_DATA             2\n# define CRYPTO_LOCK_X509                3\n# define CRYPTO_LOCK_X509_INFO           4\n# define CRYPTO_LOCK_X509_PKEY           5\n# define CRYPTO_LOCK_X509_CRL            6\n# define CRYPTO_LOCK_X509_REQ            7\n# define CRYPTO_LOCK_DSA                 8\n# define CRYPTO_LOCK_RSA                 9\n# define CRYPTO_LOCK_EVP_PKEY            10\n# define CRYPTO_LOCK_X509_STORE          11\n# define CRYPTO_LOCK_SSL_CTX             12\n# define CRYPTO_LOCK_SSL_CERT            13\n# define CRYPTO_LOCK_SSL_SESSION         14\n# define CRYPTO_LOCK_SSL_SESS_CERT       15\n# define CRYPTO_LOCK_SSL                 16\n# define CRYPTO_LOCK_SSL_METHOD          17\n# define CRYPTO_LOCK_RAND                18\n# define CRYPTO_LOCK_RAND2               19\n# define CRYPTO_LOCK_MALLOC              20\n# define CRYPTO_LOCK_BIO                 21\n# define CRYPTO_LOCK_GETHOSTBYNAME       22\n# define CRYPTO_LOCK_GETSERVBYNAME       23\n# define CRYPTO_LOCK_READDIR             24\n# define CRYPTO_LOCK_RSA_BLINDING        25\n# define CRYPTO_LOCK_DH                  26\n# define CRYPTO_LOCK_MALLOC2             27\n# define CRYPTO_LOCK_DSO                 28\n# define CRYPTO_LOCK_DYNLOCK             29\n# define CRYPTO_LOCK_ENGINE              30\n# define CRYPTO_LOCK_UI                  31\n# define CRYPTO_LOCK_ECDSA               32\n# define CRYPTO_LOCK_EC                  33\n# define CRYPTO_LOCK_ECDH                34\n# define CRYPTO_LOCK_BN                  35\n# define CRYPTO_LOCK_EC_PRE_COMP         36\n# define CRYPTO_LOCK_STORE               37\n# define CRYPTO_LOCK_COMP                38\n# define CRYPTO_LOCK_FIPS                39\n# define CRYPTO_LOCK_FIPS2               40\n# define CRYPTO_NUM_LOCKS                41\n\n# define CRYPTO_LOCK             1\n# define CRYPTO_UNLOCK           2\n# define CRYPTO_READ             4\n# define CRYPTO_WRITE            8\n\n# ifndef OPENSSL_NO_LOCKING\n#  ifndef CRYPTO_w_lock\n#   define CRYPTO_w_lock(type)     \\\n        CRYPTO_lock(CRYPTO_LOCK|CRYPTO_WRITE,type,__FILE__,__LINE__)\n#   define CRYPTO_w_unlock(type)   \\\n        CRYPTO_lock(CRYPTO_UNLOCK|CRYPTO_WRITE,type,__FILE__,__LINE__)\n#   define CRYPTO_r_lock(type)     \\\n        CRYPTO_lock(CRYPTO_LOCK|CRYPTO_READ,type,__FILE__,__LINE__)\n#   define CRYPTO_r_unlock(type)   \\\n        CRYPTO_lock(CRYPTO_UNLOCK|CRYPTO_READ,type,__FILE__,__LINE__)\n#   define CRYPTO_add(addr,amount,type)    \\\n        CRYPTO_add_lock(addr,amount,type,__FILE__,__LINE__)\n#  endif\n# else\n#  define CRYPTO_w_lock(a)\n#  define CRYPTO_w_unlock(a)\n#  define CRYPTO_r_lock(a)\n#  define CRYPTO_r_unlock(a)\n#  define CRYPTO_add(a,b,c)       ((*(a))+=(b))\n# endif\n\n/*\n * Some applications as well as some parts of OpenSSL need to allocate and\n * deallocate locks in a dynamic fashion.  The following typedef makes this\n * possible in a type-safe manner.\n */\n/* struct CRYPTO_dynlock_value has to be defined by the application. */\ntypedef struct {\n    int references;\n    struct CRYPTO_dynlock_value *data;\n} CRYPTO_dynlock;\n\n/*\n * The following can be used to detect memory leaks in the SSLeay library. It\n * used, it turns on malloc checking\n */\n\n# define CRYPTO_MEM_CHECK_OFF    0x0/* an enume */\n# define CRYPTO_MEM_CHECK_ON     0x1/* a bit */\n# define CRYPTO_MEM_CHECK_ENABLE 0x2/* a bit */\n# define CRYPTO_MEM_CHECK_DISABLE 0x3/* an enume */\n\n/*\n * The following are bit values to turn on or off options connected to the\n * malloc checking functionality\n */\n\n/* Adds time to the memory checking information */\n# define V_CRYPTO_MDEBUG_TIME    0x1/* a bit */\n/* Adds thread number to the memory checking information */\n# define V_CRYPTO_MDEBUG_THREAD  0x2/* a bit */\n\n# define V_CRYPTO_MDEBUG_ALL (V_CRYPTO_MDEBUG_TIME | V_CRYPTO_MDEBUG_THREAD)\n\n/* predec of the BIO type */\ntypedef struct bio_st BIO_dummy;\n\nstruct crypto_ex_data_st {\n    STACK_OF(void) *sk;\n    /* gcc is screwing up this data structure :-( */\n    int dummy;\n};\nDECLARE_STACK_OF(void)\n\n/*\n * This stuff is basically class callback functions The current classes are\n * SSL_CTX, SSL, SSL_SESSION, and a few more\n */\n\ntypedef struct crypto_ex_data_func_st {\n    long argl;                  /* Arbitary long */\n    void *argp;                 /* Arbitary void * */\n    CRYPTO_EX_new *new_func;\n    CRYPTO_EX_free *free_func;\n    CRYPTO_EX_dup *dup_func;\n} CRYPTO_EX_DATA_FUNCS;\n\nDECLARE_STACK_OF(CRYPTO_EX_DATA_FUNCS)\n\n/*\n * Per class, we have a STACK of CRYPTO_EX_DATA_FUNCS for each CRYPTO_EX_DATA\n * entry.\n */\n\n# define CRYPTO_EX_INDEX_BIO             0\n# define CRYPTO_EX_INDEX_SSL             1\n# define CRYPTO_EX_INDEX_SSL_CTX         2\n# define CRYPTO_EX_INDEX_SSL_SESSION     3\n# define CRYPTO_EX_INDEX_X509_STORE      4\n# define CRYPTO_EX_INDEX_X509_STORE_CTX  5\n# define CRYPTO_EX_INDEX_RSA             6\n# define CRYPTO_EX_INDEX_DSA             7\n# define CRYPTO_EX_INDEX_DH              8\n# define CRYPTO_EX_INDEX_ENGINE          9\n# define CRYPTO_EX_INDEX_X509            10\n# define CRYPTO_EX_INDEX_UI              11\n# define CRYPTO_EX_INDEX_ECDSA           12\n# define CRYPTO_EX_INDEX_ECDH            13\n# define CRYPTO_EX_INDEX_COMP            14\n# define CRYPTO_EX_INDEX_STORE           15\n\n/*\n * Dynamically assigned indexes start from this value (don't use directly,\n * use via CRYPTO_ex_data_new_class).\n */\n# define CRYPTO_EX_INDEX_USER            100\n\n/*\n * This is the default callbacks, but we can have others as well: this is\n * needed in Win32 where the application malloc and the library malloc may\n * not be the same.\n */\n# define CRYPTO_malloc_init()    CRYPTO_set_mem_functions(\\\n        malloc, realloc, free)\n\n# if defined CRYPTO_MDEBUG_ALL || defined CRYPTO_MDEBUG_TIME || defined CRYPTO_MDEBUG_THREAD\n#  ifndef CRYPTO_MDEBUG         /* avoid duplicate #define */\n#   define CRYPTO_MDEBUG\n#  endif\n# endif\n\n/*\n * Set standard debugging functions (not done by default unless CRYPTO_MDEBUG\n * is defined)\n */\n# define CRYPTO_malloc_debug_init()      do {\\\n        CRYPTO_set_mem_debug_functions(\\\n                CRYPTO_dbg_malloc,\\\n                CRYPTO_dbg_realloc,\\\n                CRYPTO_dbg_free,\\\n                CRYPTO_dbg_set_options,\\\n                CRYPTO_dbg_get_options);\\\n        } while(0)\n\nint CRYPTO_mem_ctrl(int mode);\nint CRYPTO_is_mem_check_on(void);\n\n/* for applications */\n# define MemCheck_start() CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON)\n# define MemCheck_stop() CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_OFF)\n\n/* for library-internal use */\n# define MemCheck_on()   CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ENABLE)\n# define MemCheck_off()  CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_DISABLE)\n# define is_MemCheck_on() CRYPTO_is_mem_check_on()\n\n# define OPENSSL_malloc(num)     CRYPTO_malloc((int)num,__FILE__,__LINE__)\n# define OPENSSL_strdup(str)     CRYPTO_strdup((str),__FILE__,__LINE__)\n# define OPENSSL_realloc(addr,num) \\\n        CRYPTO_realloc((char *)addr,(int)num,__FILE__,__LINE__)\n# define OPENSSL_realloc_clean(addr,old_num,num) \\\n        CRYPTO_realloc_clean(addr,old_num,num,__FILE__,__LINE__)\n# define OPENSSL_remalloc(addr,num) \\\n        CRYPTO_remalloc((char **)addr,(int)num,__FILE__,__LINE__)\n# define OPENSSL_freeFunc        CRYPTO_free\n# define OPENSSL_free(addr)      CRYPTO_free(addr)\n\n# define OPENSSL_malloc_locked(num) \\\n        CRYPTO_malloc_locked((int)num,__FILE__,__LINE__)\n# define OPENSSL_free_locked(addr) CRYPTO_free_locked(addr)\n\nconst char *SSLeay_version(int type);\nunsigned long SSLeay(void);\n\nint OPENSSL_issetugid(void);\n\n/* An opaque type representing an implementation of \"ex_data\" support */\ntypedef struct st_CRYPTO_EX_DATA_IMPL CRYPTO_EX_DATA_IMPL;\n/* Return an opaque pointer to the current \"ex_data\" implementation */\nconst CRYPTO_EX_DATA_IMPL *CRYPTO_get_ex_data_implementation(void);\n/* Sets the \"ex_data\" implementation to be used (if it's not too late) */\nint CRYPTO_set_ex_data_implementation(const CRYPTO_EX_DATA_IMPL *i);\n/* Get a new \"ex_data\" class, and return the corresponding \"class_index\" */\nint CRYPTO_ex_data_new_class(void);\n/* Within a given class, get/register a new index */\nint CRYPTO_get_ex_new_index(int class_index, long argl, void *argp,\n                            CRYPTO_EX_new *new_func, CRYPTO_EX_dup *dup_func,\n                            CRYPTO_EX_free *free_func);\n/*\n * Initialise/duplicate/free CRYPTO_EX_DATA variables corresponding to a\n * given class (invokes whatever per-class callbacks are applicable)\n */\nint CRYPTO_new_ex_data(int class_index, void *obj, CRYPTO_EX_DATA *ad);\nint CRYPTO_dup_ex_data(int class_index, CRYPTO_EX_DATA *to,\n                       CRYPTO_EX_DATA *from);\nvoid CRYPTO_free_ex_data(int class_index, void *obj, CRYPTO_EX_DATA *ad);\n/*\n * Get/set data in a CRYPTO_EX_DATA variable corresponding to a particular\n * index (relative to the class type involved)\n */\nint CRYPTO_set_ex_data(CRYPTO_EX_DATA *ad, int idx, void *val);\nvoid *CRYPTO_get_ex_data(const CRYPTO_EX_DATA *ad, int idx);\n/*\n * This function cleans up all \"ex_data\" state. It mustn't be called under\n * potential race-conditions.\n */\nvoid CRYPTO_cleanup_all_ex_data(void);\n\nint CRYPTO_get_new_lockid(char *name);\n\nint CRYPTO_num_locks(void);     /* return CRYPTO_NUM_LOCKS (shared libs!) */\nvoid CRYPTO_lock(int mode, int type, const char *file, int line);\nvoid CRYPTO_set_locking_callback(void (*func) (int mode, int type,\n                                               const char *file, int line));\nvoid (*CRYPTO_get_locking_callback(void)) (int mode, int type,\n                                           const char *file, int line);\nvoid CRYPTO_set_add_lock_callback(int (*func)\n                                   (int *num, int mount, int type,\n                                    const char *file, int line));\nint (*CRYPTO_get_add_lock_callback(void)) (int *num, int mount, int type,\n                                           const char *file, int line);\n\n/* Don't use this structure directly. */\ntypedef struct crypto_threadid_st {\n    void *ptr;\n    unsigned long val;\n} CRYPTO_THREADID;\n/* Only use CRYPTO_THREADID_set_[numeric|pointer]() within callbacks */\nvoid CRYPTO_THREADID_set_numeric(CRYPTO_THREADID *id, unsigned long val);\nvoid CRYPTO_THREADID_set_pointer(CRYPTO_THREADID *id, void *ptr);\nint CRYPTO_THREADID_set_callback(void (*threadid_func) (CRYPTO_THREADID *));\nvoid (*CRYPTO_THREADID_get_callback(void)) (CRYPTO_THREADID *);\nvoid CRYPTO_THREADID_current(CRYPTO_THREADID *id);\nint CRYPTO_THREADID_cmp(const CRYPTO_THREADID *a, const CRYPTO_THREADID *b);\nvoid CRYPTO_THREADID_cpy(CRYPTO_THREADID *dest, const CRYPTO_THREADID *src);\nunsigned long CRYPTO_THREADID_hash(const CRYPTO_THREADID *id);\n# ifndef OPENSSL_NO_DEPRECATED\nvoid CRYPTO_set_id_callback(unsigned long (*func) (void));\nunsigned long (*CRYPTO_get_id_callback(void)) (void);\nunsigned long CRYPTO_thread_id(void);\n# endif\n\nconst char *CRYPTO_get_lock_name(int type);\nint CRYPTO_add_lock(int *pointer, int amount, int type, const char *file,\n                    int line);\n\nint CRYPTO_get_new_dynlockid(void);\nvoid CRYPTO_destroy_dynlockid(int i);\nstruct CRYPTO_dynlock_value *CRYPTO_get_dynlock_value(int i);\nvoid CRYPTO_set_dynlock_create_callback(struct CRYPTO_dynlock_value\n                                        *(*dyn_create_function) (const char\n                                                                 *file,\n                                                                 int line));\nvoid CRYPTO_set_dynlock_lock_callback(void (*dyn_lock_function)\n                                       (int mode,\n                                        struct CRYPTO_dynlock_value *l,\n                                        const char *file, int line));\nvoid CRYPTO_set_dynlock_destroy_callback(void (*dyn_destroy_function)\n                                          (struct CRYPTO_dynlock_value *l,\n                                           const char *file, int line));\nstruct CRYPTO_dynlock_value\n*(*CRYPTO_get_dynlock_create_callback(void)) (const char *file, int line);\nvoid (*CRYPTO_get_dynlock_lock_callback(void)) (int mode,\n                                                struct CRYPTO_dynlock_value\n                                                *l, const char *file,\n                                                int line);\nvoid (*CRYPTO_get_dynlock_destroy_callback(void)) (struct CRYPTO_dynlock_value\n                                                   *l, const char *file,\n                                                   int line);\n\n/*\n * CRYPTO_set_mem_functions includes CRYPTO_set_locked_mem_functions -- call\n * the latter last if you need different functions\n */\nint CRYPTO_set_mem_functions(void *(*m) (size_t), void *(*r) (void *, size_t),\n                             void (*f) (void *));\nint CRYPTO_set_locked_mem_functions(void *(*m) (size_t),\n                                    void (*free_func) (void *));\nint CRYPTO_set_mem_ex_functions(void *(*m) (size_t, const char *, int),\n                                void *(*r) (void *, size_t, const char *,\n                                            int), void (*f) (void *));\nint CRYPTO_set_locked_mem_ex_functions(void *(*m) (size_t, const char *, int),\n                                       void (*free_func) (void *));\nint CRYPTO_set_mem_debug_functions(void (*m)\n                                    (void *, int, const char *, int, int),\n                                   void (*r) (void *, void *, int,\n                                              const char *, int, int),\n                                   void (*f) (void *, int), void (*so) (long),\n                                   long (*go) (void));\nvoid CRYPTO_get_mem_functions(void *(**m) (size_t),\n                              void *(**r) (void *, size_t),\n                              void (**f) (void *));\nvoid CRYPTO_get_locked_mem_functions(void *(**m) (size_t),\n                                     void (**f) (void *));\nvoid CRYPTO_get_mem_ex_functions(void *(**m) (size_t, const char *, int),\n                                 void *(**r) (void *, size_t, const char *,\n                                              int), void (**f) (void *));\nvoid CRYPTO_get_locked_mem_ex_functions(void\n                                        *(**m) (size_t, const char *, int),\n                                        void (**f) (void *));\nvoid CRYPTO_get_mem_debug_functions(void (**m)\n                                     (void *, int, const char *, int, int),\n                                    void (**r) (void *, void *, int,\n                                                const char *, int, int),\n                                    void (**f) (void *, int),\n                                    void (**so) (long), long (**go) (void));\n\nvoid *CRYPTO_malloc_locked(int num, const char *file, int line);\nvoid CRYPTO_free_locked(void *ptr);\nvoid *CRYPTO_malloc(int num, const char *file, int line);\nchar *CRYPTO_strdup(const char *str, const char *file, int line);\nvoid CRYPTO_free(void *ptr);\nvoid *CRYPTO_realloc(void *addr, int num, const char *file, int line);\nvoid *CRYPTO_realloc_clean(void *addr, int old_num, int num, const char *file,\n                           int line);\nvoid *CRYPTO_remalloc(void *addr, int num, const char *file, int line);\n\nvoid OPENSSL_cleanse(void *ptr, size_t len);\n\nvoid CRYPTO_set_mem_debug_options(long bits);\nlong CRYPTO_get_mem_debug_options(void);\n\n# define CRYPTO_push_info(info) \\\n        CRYPTO_push_info_(info, __FILE__, __LINE__);\nint CRYPTO_push_info_(const char *info, const char *file, int line);\nint CRYPTO_pop_info(void);\nint CRYPTO_remove_all_info(void);\n\n/*\n * Default debugging functions (enabled by CRYPTO_malloc_debug_init() macro;\n * used as default in CRYPTO_MDEBUG compilations):\n */\n/*-\n * The last argument has the following significance:\n *\n * 0:   called before the actual memory allocation has taken place\n * 1:   called after the actual memory allocation has taken place\n */\nvoid CRYPTO_dbg_malloc(void *addr, int num, const char *file, int line,\n                       int before_p);\nvoid CRYPTO_dbg_realloc(void *addr1, void *addr2, int num, const char *file,\n                        int line, int before_p);\nvoid CRYPTO_dbg_free(void *addr, int before_p);\n/*-\n * Tell the debugging code about options.  By default, the following values\n * apply:\n *\n * 0:                           Clear all options.\n * V_CRYPTO_MDEBUG_TIME (1):    Set the \"Show Time\" option.\n * V_CRYPTO_MDEBUG_THREAD (2):  Set the \"Show Thread Number\" option.\n * V_CRYPTO_MDEBUG_ALL (3):     1 + 2\n */\nvoid CRYPTO_dbg_set_options(long bits);\nlong CRYPTO_dbg_get_options(void);\n\n# ifndef OPENSSL_NO_FP_API\nvoid CRYPTO_mem_leaks_fp(FILE *);\n# endif\nvoid CRYPTO_mem_leaks(struct bio_st *bio);\n/* unsigned long order, char *file, int line, int num_bytes, char *addr */\ntypedef void *CRYPTO_MEM_LEAK_CB (unsigned long, const char *, int, int,\n                                  void *);\nvoid CRYPTO_mem_leaks_cb(CRYPTO_MEM_LEAK_CB *cb);\n\n/* die if we have to */\nvoid OpenSSLDie(const char *file, int line, const char *assertion);\n# define OPENSSL_assert(e)       (void)((e) ? 0 : (OpenSSLDie(__FILE__, __LINE__, #e),1))\n\nunsigned long *OPENSSL_ia32cap_loc(void);\n# define OPENSSL_ia32cap (*(OPENSSL_ia32cap_loc()))\nint OPENSSL_isservice(void);\n\nint FIPS_mode(void);\nint FIPS_mode_set(int r);\n\nvoid OPENSSL_init(void);\n\n# define fips_md_init(alg) fips_md_init_ctx(alg, alg)\n\n# ifdef OPENSSL_FIPS\n#  define fips_md_init_ctx(alg, cx) \\\n        int alg##_Init(cx##_CTX *c) \\\n        { \\\n        if (FIPS_mode()) OpenSSLDie(__FILE__, __LINE__, \\\n                \"Low level API call to digest \" #alg \" forbidden in FIPS mode!\"); \\\n        return private_##alg##_Init(c); \\\n        } \\\n        int private_##alg##_Init(cx##_CTX *c)\n\n#  define fips_cipher_abort(alg) \\\n        if (FIPS_mode()) OpenSSLDie(__FILE__, __LINE__, \\\n                \"Low level API call to cipher \" #alg \" forbidden in FIPS mode!\")\n\n# else\n#  define fips_md_init_ctx(alg, cx) \\\n        int alg##_Init(cx##_CTX *c)\n#  define fips_cipher_abort(alg) while(0)\n# endif\n\n/*\n * CRYPTO_memcmp returns zero iff the |len| bytes at |a| and |b| are equal.\n * It takes an amount of time dependent on |len|, but independent of the\n * contents of |a| and |b|. Unlike memcmp, it cannot be used to put elements\n * into a defined order as the return value when a != b is undefined, other\n * than to be non-zero.\n */\nint CRYPTO_memcmp(const volatile void *a, const volatile void *b, size_t len);\n\n/* BEGIN ERROR CODES */\n/*\n * The following lines are auto generated by the script mkerr.pl. Any changes\n * made after this point may be overwritten when the script is next run.\n */\nvoid ERR_load_CRYPTO_strings(void);\n\n/* Error codes for the CRYPTO functions. */\n\n/* Function codes. */\n# define CRYPTO_F_CRYPTO_GET_EX_NEW_INDEX                 100\n# define CRYPTO_F_CRYPTO_GET_NEW_DYNLOCKID                103\n# define CRYPTO_F_CRYPTO_GET_NEW_LOCKID                   101\n# define CRYPTO_F_CRYPTO_SET_EX_DATA                      102\n# define CRYPTO_F_DEF_ADD_INDEX                           104\n# define CRYPTO_F_DEF_GET_CLASS                           105\n# define CRYPTO_F_FIPS_MODE_SET                           109\n# define CRYPTO_F_INT_DUP_EX_DATA                         106\n# define CRYPTO_F_INT_FREE_EX_DATA                        107\n# define CRYPTO_F_INT_NEW_EX_DATA                         108\n\n/* Reason codes. */\n# define CRYPTO_R_FIPS_MODE_NOT_SUPPORTED                 101\n# define CRYPTO_R_NO_DYNLOCK_CREATE_CALLBACK              100\n\n#ifdef  __cplusplus\n}\n#endif\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/arm64/include/openssl/des.h",
    "content": "/* crypto/des/des.h */\n/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)\n * All rights reserved.\n *\n * This package is an SSL implementation written\n * by Eric Young (eay@cryptsoft.com).\n * The implementation was written so as to conform with Netscapes SSL.\n *\n * This library is free for commercial and non-commercial use as long as\n * the following conditions are aheared to.  The following conditions\n * apply to all code found in this distribution, be it the RC4, RSA,\n * lhash, DES, etc., code; not just the SSL code.  The SSL documentation\n * included with this distribution is covered by the same copyright terms\n * except that the holder is Tim Hudson (tjh@cryptsoft.com).\n *\n * Copyright remains Eric Young's, and as such any Copyright notices in\n * the code are not to be removed.\n * If this package is used in a product, Eric Young should be given attribution\n * as the author of the parts of the library used.\n * This can be in the form of a textual message at program startup or\n * in documentation (online or textual) provided with the package.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the copyright\n *    notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in the\n *    documentation and/or other materials provided with the distribution.\n * 3. All advertising materials mentioning features or use of this software\n *    must display the following acknowledgement:\n *    \"This product includes cryptographic software written by\n *     Eric Young (eay@cryptsoft.com)\"\n *    The word 'cryptographic' can be left out if the rouines from the library\n *    being used are not cryptographic related :-).\n * 4. If you include any Windows specific code (or a derivative thereof) from\n *    the apps directory (application code) you must include an acknowledgement:\n *    \"This product includes software written by Tim Hudson (tjh@cryptsoft.com)\"\n *\n * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n * SUCH DAMAGE.\n *\n * The licence and distribution terms for any publically available version or\n * derivative of this code cannot be changed.  i.e. this code cannot simply be\n * copied and put under another distribution licence\n * [including the GNU Public Licence.]\n */\n\n#ifndef HEADER_NEW_DES_H\n# define HEADER_NEW_DES_H\n\n# include <openssl/e_os2.h>     /* OPENSSL_EXTERN, OPENSSL_NO_DES, DES_LONG\n                                 * (via openssl/opensslconf.h */\n\n# ifdef OPENSSL_NO_DES\n#  error DES is disabled.\n# endif\n\n# ifdef OPENSSL_BUILD_SHLIBCRYPTO\n#  undef OPENSSL_EXTERN\n#  define OPENSSL_EXTERN OPENSSL_EXPORT\n# endif\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\ntypedef unsigned char DES_cblock[8];\ntypedef /* const */ unsigned char const_DES_cblock[8];\n/*\n * With \"const\", gcc 2.8.1 on Solaris thinks that DES_cblock * and\n * const_DES_cblock * are incompatible pointer types.\n */\n\ntypedef struct DES_ks {\n    union {\n        DES_cblock cblock;\n        /*\n         * make sure things are correct size on machines with 8 byte longs\n         */\n        DES_LONG deslong[2];\n    } ks[16];\n} DES_key_schedule;\n\n# ifndef OPENSSL_DISABLE_OLD_DES_SUPPORT\n#  ifndef OPENSSL_ENABLE_OLD_DES_SUPPORT\n#   define OPENSSL_ENABLE_OLD_DES_SUPPORT\n#  endif\n# endif\n\n# ifdef OPENSSL_ENABLE_OLD_DES_SUPPORT\n#  include <openssl/des_old.h>\n# endif\n\n# define DES_KEY_SZ      (sizeof(DES_cblock))\n# define DES_SCHEDULE_SZ (sizeof(DES_key_schedule))\n\n# define DES_ENCRYPT     1\n# define DES_DECRYPT     0\n\n# define DES_CBC_MODE    0\n# define DES_PCBC_MODE   1\n\n# define DES_ecb2_encrypt(i,o,k1,k2,e) \\\n        DES_ecb3_encrypt((i),(o),(k1),(k2),(k1),(e))\n\n# define DES_ede2_cbc_encrypt(i,o,l,k1,k2,iv,e) \\\n        DES_ede3_cbc_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(e))\n\n# define DES_ede2_cfb64_encrypt(i,o,l,k1,k2,iv,n,e) \\\n        DES_ede3_cfb64_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(n),(e))\n\n# define DES_ede2_ofb64_encrypt(i,o,l,k1,k2,iv,n) \\\n        DES_ede3_ofb64_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(n))\n\nOPENSSL_DECLARE_GLOBAL(int, DES_check_key); /* defaults to false */\n# define DES_check_key OPENSSL_GLOBAL_REF(DES_check_key)\nOPENSSL_DECLARE_GLOBAL(int, DES_rw_mode); /* defaults to DES_PCBC_MODE */\n# define DES_rw_mode OPENSSL_GLOBAL_REF(DES_rw_mode)\n\nconst char *DES_options(void);\nvoid DES_ecb3_encrypt(const_DES_cblock *input, DES_cblock *output,\n                      DES_key_schedule *ks1, DES_key_schedule *ks2,\n                      DES_key_schedule *ks3, int enc);\nDES_LONG DES_cbc_cksum(const unsigned char *input, DES_cblock *output,\n                       long length, DES_key_schedule *schedule,\n                       const_DES_cblock *ivec);\n/* DES_cbc_encrypt does not update the IV!  Use DES_ncbc_encrypt instead. */\nvoid DES_cbc_encrypt(const unsigned char *input, unsigned char *output,\n                     long length, DES_key_schedule *schedule,\n                     DES_cblock *ivec, int enc);\nvoid DES_ncbc_encrypt(const unsigned char *input, unsigned char *output,\n                      long length, DES_key_schedule *schedule,\n                      DES_cblock *ivec, int enc);\nvoid DES_xcbc_encrypt(const unsigned char *input, unsigned char *output,\n                      long length, DES_key_schedule *schedule,\n                      DES_cblock *ivec, const_DES_cblock *inw,\n                      const_DES_cblock *outw, int enc);\nvoid DES_cfb_encrypt(const unsigned char *in, unsigned char *out, int numbits,\n                     long length, DES_key_schedule *schedule,\n                     DES_cblock *ivec, int enc);\nvoid DES_ecb_encrypt(const_DES_cblock *input, DES_cblock *output,\n                     DES_key_schedule *ks, int enc);\n\n/*\n * This is the DES encryption function that gets called by just about every\n * other DES routine in the library.  You should not use this function except\n * to implement 'modes' of DES.  I say this because the functions that call\n * this routine do the conversion from 'char *' to long, and this needs to be\n * done to make sure 'non-aligned' memory access do not occur.  The\n * characters are loaded 'little endian'. Data is a pointer to 2 unsigned\n * long's and ks is the DES_key_schedule to use.  enc, is non zero specifies\n * encryption, zero if decryption.\n */\nvoid DES_encrypt1(DES_LONG *data, DES_key_schedule *ks, int enc);\n\n/*\n * This functions is the same as DES_encrypt1() except that the DES initial\n * permutation (IP) and final permutation (FP) have been left out.  As for\n * DES_encrypt1(), you should not use this function. It is used by the\n * routines in the library that implement triple DES. IP() DES_encrypt2()\n * DES_encrypt2() DES_encrypt2() FP() is the same as DES_encrypt1()\n * DES_encrypt1() DES_encrypt1() except faster :-).\n */\nvoid DES_encrypt2(DES_LONG *data, DES_key_schedule *ks, int enc);\n\nvoid DES_encrypt3(DES_LONG *data, DES_key_schedule *ks1,\n                  DES_key_schedule *ks2, DES_key_schedule *ks3);\nvoid DES_decrypt3(DES_LONG *data, DES_key_schedule *ks1,\n                  DES_key_schedule *ks2, DES_key_schedule *ks3);\nvoid DES_ede3_cbc_encrypt(const unsigned char *input, unsigned char *output,\n                          long length,\n                          DES_key_schedule *ks1, DES_key_schedule *ks2,\n                          DES_key_schedule *ks3, DES_cblock *ivec, int enc);\nvoid DES_ede3_cbcm_encrypt(const unsigned char *in, unsigned char *out,\n                           long length,\n                           DES_key_schedule *ks1, DES_key_schedule *ks2,\n                           DES_key_schedule *ks3,\n                           DES_cblock *ivec1, DES_cblock *ivec2, int enc);\nvoid DES_ede3_cfb64_encrypt(const unsigned char *in, unsigned char *out,\n                            long length, DES_key_schedule *ks1,\n                            DES_key_schedule *ks2, DES_key_schedule *ks3,\n                            DES_cblock *ivec, int *num, int enc);\nvoid DES_ede3_cfb_encrypt(const unsigned char *in, unsigned char *out,\n                          int numbits, long length, DES_key_schedule *ks1,\n                          DES_key_schedule *ks2, DES_key_schedule *ks3,\n                          DES_cblock *ivec, int enc);\nvoid DES_ede3_ofb64_encrypt(const unsigned char *in, unsigned char *out,\n                            long length, DES_key_schedule *ks1,\n                            DES_key_schedule *ks2, DES_key_schedule *ks3,\n                            DES_cblock *ivec, int *num);\n# if 0\nvoid DES_xwhite_in2out(const_DES_cblock *DES_key, const_DES_cblock *in_white,\n                       DES_cblock *out_white);\n# endif\n\nint DES_enc_read(int fd, void *buf, int len, DES_key_schedule *sched,\n                 DES_cblock *iv);\nint DES_enc_write(int fd, const void *buf, int len, DES_key_schedule *sched,\n                  DES_cblock *iv);\nchar *DES_fcrypt(const char *buf, const char *salt, char *ret);\nchar *DES_crypt(const char *buf, const char *salt);\nvoid DES_ofb_encrypt(const unsigned char *in, unsigned char *out, int numbits,\n                     long length, DES_key_schedule *schedule,\n                     DES_cblock *ivec);\nvoid DES_pcbc_encrypt(const unsigned char *input, unsigned char *output,\n                      long length, DES_key_schedule *schedule,\n                      DES_cblock *ivec, int enc);\nDES_LONG DES_quad_cksum(const unsigned char *input, DES_cblock output[],\n                        long length, int out_count, DES_cblock *seed);\nint DES_random_key(DES_cblock *ret);\nvoid DES_set_odd_parity(DES_cblock *key);\nint DES_check_key_parity(const_DES_cblock *key);\nint DES_is_weak_key(const_DES_cblock *key);\n/*\n * DES_set_key (= set_key = DES_key_sched = key_sched) calls\n * DES_set_key_checked if global variable DES_check_key is set,\n * DES_set_key_unchecked otherwise.\n */\nint DES_set_key(const_DES_cblock *key, DES_key_schedule *schedule);\nint DES_key_sched(const_DES_cblock *key, DES_key_schedule *schedule);\nint DES_set_key_checked(const_DES_cblock *key, DES_key_schedule *schedule);\nvoid DES_set_key_unchecked(const_DES_cblock *key, DES_key_schedule *schedule);\n# ifdef OPENSSL_FIPS\nvoid private_DES_set_key_unchecked(const_DES_cblock *key,\n                                   DES_key_schedule *schedule);\n# endif\nvoid DES_string_to_key(const char *str, DES_cblock *key);\nvoid DES_string_to_2keys(const char *str, DES_cblock *key1, DES_cblock *key2);\nvoid DES_cfb64_encrypt(const unsigned char *in, unsigned char *out,\n                       long length, DES_key_schedule *schedule,\n                       DES_cblock *ivec, int *num, int enc);\nvoid DES_ofb64_encrypt(const unsigned char *in, unsigned char *out,\n                       long length, DES_key_schedule *schedule,\n                       DES_cblock *ivec, int *num);\n\nint DES_read_password(DES_cblock *key, const char *prompt, int verify);\nint DES_read_2passwords(DES_cblock *key1, DES_cblock *key2,\n                        const char *prompt, int verify);\n\n# define DES_fixup_key_parity DES_set_odd_parity\n\n#ifdef  __cplusplus\n}\n#endif\n\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/arm64/include/openssl/des_old.h",
    "content": "/* crypto/des/des_old.h */\n\n/*-\n * WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING\n *\n * The function names in here are deprecated and are only present to\n * provide an interface compatible with openssl 0.9.6 and older as\n * well as libdes.  OpenSSL now provides functions where \"des_\" has\n * been replaced with \"DES_\" in the names, to make it possible to\n * make incompatible changes that are needed for C type security and\n * other stuff.\n *\n * This include files has two compatibility modes:\n *\n *   - If OPENSSL_DES_LIBDES_COMPATIBILITY is defined, you get an API\n *     that is compatible with libdes and SSLeay.\n *   - If OPENSSL_DES_LIBDES_COMPATIBILITY isn't defined, you get an\n *     API that is compatible with OpenSSL 0.9.5x to 0.9.6x.\n *\n * Note that these modes break earlier snapshots of OpenSSL, where\n * libdes compatibility was the only available mode or (later on) the\n * prefered compatibility mode.  However, after much consideration\n * (and more or less violent discussions with external parties), it\n * was concluded that OpenSSL should be compatible with earlier versions\n * of itself before anything else.  Also, in all honesty, libdes is\n * an old beast that shouldn't really be used any more.\n *\n * Please consider starting to use the DES_ functions rather than the\n * des_ ones.  The des_ functions will disappear completely before\n * OpenSSL 1.0!\n *\n * WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING\n */\n\n/*\n * Written by Richard Levitte (richard@levitte.org) for the OpenSSL project\n * 2001.\n */\n/* ====================================================================\n * Copyright (c) 1998-2002 The OpenSSL Project.  All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n *\n * 1. Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n *\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in\n *    the documentation and/or other materials provided with the\n *    distribution.\n *\n * 3. All advertising materials mentioning features or use of this\n *    software must display the following acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit. (http://www.openssl.org/)\"\n *\n * 4. The names \"OpenSSL Toolkit\" and \"OpenSSL Project\" must not be used to\n *    endorse or promote products derived from this software without\n *    prior written permission. For written permission, please contact\n *    openssl-core@openssl.org.\n *\n * 5. Products derived from this software may not be called \"OpenSSL\"\n *    nor may \"OpenSSL\" appear in their names without prior written\n *    permission of the OpenSSL Project.\n *\n * 6. Redistributions of any form whatsoever must retain the following\n *    acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit (http://www.openssl.org/)\"\n *\n * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY\n * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\n * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR\n * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\n * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,\n * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED\n * OF THE POSSIBILITY OF SUCH DAMAGE.\n * ====================================================================\n *\n * This product includes cryptographic software written by Eric Young\n * (eay@cryptsoft.com).  This product includes software written by Tim\n * Hudson (tjh@cryptsoft.com).\n *\n */\n\n#ifndef HEADER_DES_H\n# define HEADER_DES_H\n\n# include <openssl/e_os2.h>     /* OPENSSL_EXTERN, OPENSSL_NO_DES, DES_LONG */\n\n# ifdef OPENSSL_NO_DES\n#  error DES is disabled.\n# endif\n\n# ifndef HEADER_NEW_DES_H\n#  error You must include des.h, not des_old.h directly.\n# endif\n\n# ifdef _KERBEROS_DES_H\n#  error <openssl/des_old.h> replaces <kerberos/des.h>.\n# endif\n\n# include <openssl/symhacks.h>\n\n# ifdef OPENSSL_BUILD_SHLIBCRYPTO\n#  undef OPENSSL_EXTERN\n#  define OPENSSL_EXTERN OPENSSL_EXPORT\n# endif\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n# ifdef _\n#  undef _\n# endif\n\ntypedef unsigned char _ossl_old_des_cblock[8];\ntypedef struct _ossl_old_des_ks_struct {\n    union {\n        _ossl_old_des_cblock _;\n        /*\n         * make sure things are correct size on machines with 8 byte longs\n         */\n        DES_LONG pad[2];\n    } ks;\n} _ossl_old_des_key_schedule[16];\n\n# ifndef OPENSSL_DES_LIBDES_COMPATIBILITY\n#  define des_cblock DES_cblock\n#  define const_des_cblock const_DES_cblock\n#  define des_key_schedule DES_key_schedule\n#  define des_ecb3_encrypt(i,o,k1,k2,k3,e)\\\n        DES_ecb3_encrypt((i),(o),&(k1),&(k2),&(k3),(e))\n#  define des_ede3_cbc_encrypt(i,o,l,k1,k2,k3,iv,e)\\\n        DES_ede3_cbc_encrypt((i),(o),(l),&(k1),&(k2),&(k3),(iv),(e))\n#  define des_ede3_cbcm_encrypt(i,o,l,k1,k2,k3,iv1,iv2,e)\\\n        DES_ede3_cbcm_encrypt((i),(o),(l),&(k1),&(k2),&(k3),(iv1),(iv2),(e))\n#  define des_ede3_cfb64_encrypt(i,o,l,k1,k2,k3,iv,n,e)\\\n        DES_ede3_cfb64_encrypt((i),(o),(l),&(k1),&(k2),&(k3),(iv),(n),(e))\n#  define des_ede3_ofb64_encrypt(i,o,l,k1,k2,k3,iv,n)\\\n        DES_ede3_ofb64_encrypt((i),(o),(l),&(k1),&(k2),&(k3),(iv),(n))\n#  define des_options()\\\n        DES_options()\n#  define des_cbc_cksum(i,o,l,k,iv)\\\n        DES_cbc_cksum((i),(o),(l),&(k),(iv))\n#  define des_cbc_encrypt(i,o,l,k,iv,e)\\\n        DES_cbc_encrypt((i),(o),(l),&(k),(iv),(e))\n#  define des_ncbc_encrypt(i,o,l,k,iv,e)\\\n        DES_ncbc_encrypt((i),(o),(l),&(k),(iv),(e))\n#  define des_xcbc_encrypt(i,o,l,k,iv,inw,outw,e)\\\n        DES_xcbc_encrypt((i),(o),(l),&(k),(iv),(inw),(outw),(e))\n#  define des_cfb_encrypt(i,o,n,l,k,iv,e)\\\n        DES_cfb_encrypt((i),(o),(n),(l),&(k),(iv),(e))\n#  define des_ecb_encrypt(i,o,k,e)\\\n        DES_ecb_encrypt((i),(o),&(k),(e))\n#  define des_encrypt1(d,k,e)\\\n        DES_encrypt1((d),&(k),(e))\n#  define des_encrypt2(d,k,e)\\\n        DES_encrypt2((d),&(k),(e))\n#  define des_encrypt3(d,k1,k2,k3)\\\n        DES_encrypt3((d),&(k1),&(k2),&(k3))\n#  define des_decrypt3(d,k1,k2,k3)\\\n        DES_decrypt3((d),&(k1),&(k2),&(k3))\n#  define des_xwhite_in2out(k,i,o)\\\n        DES_xwhite_in2out((k),(i),(o))\n#  define des_enc_read(f,b,l,k,iv)\\\n        DES_enc_read((f),(b),(l),&(k),(iv))\n#  define des_enc_write(f,b,l,k,iv)\\\n        DES_enc_write((f),(b),(l),&(k),(iv))\n#  define des_fcrypt(b,s,r)\\\n        DES_fcrypt((b),(s),(r))\n#  if 0\n#   define des_crypt(b,s)\\\n        DES_crypt((b),(s))\n#   if !defined(PERL5) && !defined(__FreeBSD__) && !defined(NeXT) && !defined(__OpenBSD__)\n#    define crypt(b,s)\\\n        DES_crypt((b),(s))\n#   endif\n#  endif\n#  define des_ofb_encrypt(i,o,n,l,k,iv)\\\n        DES_ofb_encrypt((i),(o),(n),(l),&(k),(iv))\n#  define des_pcbc_encrypt(i,o,l,k,iv,e)\\\n        DES_pcbc_encrypt((i),(o),(l),&(k),(iv),(e))\n#  define des_quad_cksum(i,o,l,c,s)\\\n        DES_quad_cksum((i),(o),(l),(c),(s))\n#  define des_random_seed(k)\\\n        _ossl_096_des_random_seed((k))\n#  define des_random_key(r)\\\n        DES_random_key((r))\n#  define des_read_password(k,p,v) \\\n        DES_read_password((k),(p),(v))\n#  define des_read_2passwords(k1,k2,p,v) \\\n        DES_read_2passwords((k1),(k2),(p),(v))\n#  define des_set_odd_parity(k)\\\n        DES_set_odd_parity((k))\n#  define des_check_key_parity(k)\\\n        DES_check_key_parity((k))\n#  define des_is_weak_key(k)\\\n        DES_is_weak_key((k))\n#  define des_set_key(k,ks)\\\n        DES_set_key((k),&(ks))\n#  define des_key_sched(k,ks)\\\n        DES_key_sched((k),&(ks))\n#  define des_set_key_checked(k,ks)\\\n        DES_set_key_checked((k),&(ks))\n#  define des_set_key_unchecked(k,ks)\\\n        DES_set_key_unchecked((k),&(ks))\n#  define des_string_to_key(s,k)\\\n        DES_string_to_key((s),(k))\n#  define des_string_to_2keys(s,k1,k2)\\\n        DES_string_to_2keys((s),(k1),(k2))\n#  define des_cfb64_encrypt(i,o,l,ks,iv,n,e)\\\n        DES_cfb64_encrypt((i),(o),(l),&(ks),(iv),(n),(e))\n#  define des_ofb64_encrypt(i,o,l,ks,iv,n)\\\n        DES_ofb64_encrypt((i),(o),(l),&(ks),(iv),(n))\n\n#  define des_ecb2_encrypt(i,o,k1,k2,e) \\\n        des_ecb3_encrypt((i),(o),(k1),(k2),(k1),(e))\n\n#  define des_ede2_cbc_encrypt(i,o,l,k1,k2,iv,e) \\\n        des_ede3_cbc_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(e))\n\n#  define des_ede2_cfb64_encrypt(i,o,l,k1,k2,iv,n,e) \\\n        des_ede3_cfb64_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(n),(e))\n\n#  define des_ede2_ofb64_encrypt(i,o,l,k1,k2,iv,n) \\\n        des_ede3_ofb64_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(n))\n\n#  define des_check_key DES_check_key\n#  define des_rw_mode DES_rw_mode\n# else                          /* libdes compatibility */\n/*\n * Map all symbol names to _ossl_old_des_* form, so we avoid all clashes with\n * libdes\n */\n#  define des_cblock _ossl_old_des_cblock\n#  define des_key_schedule _ossl_old_des_key_schedule\n#  define des_ecb3_encrypt(i,o,k1,k2,k3,e)\\\n        _ossl_old_des_ecb3_encrypt((i),(o),(k1),(k2),(k3),(e))\n#  define des_ede3_cbc_encrypt(i,o,l,k1,k2,k3,iv,e)\\\n        _ossl_old_des_ede3_cbc_encrypt((i),(o),(l),(k1),(k2),(k3),(iv),(e))\n#  define des_ede3_cfb64_encrypt(i,o,l,k1,k2,k3,iv,n,e)\\\n        _ossl_old_des_ede3_cfb64_encrypt((i),(o),(l),(k1),(k2),(k3),(iv),(n),(e))\n#  define des_ede3_ofb64_encrypt(i,o,l,k1,k2,k3,iv,n)\\\n        _ossl_old_des_ede3_ofb64_encrypt((i),(o),(l),(k1),(k2),(k3),(iv),(n))\n#  define des_options()\\\n        _ossl_old_des_options()\n#  define des_cbc_cksum(i,o,l,k,iv)\\\n        _ossl_old_des_cbc_cksum((i),(o),(l),(k),(iv))\n#  define des_cbc_encrypt(i,o,l,k,iv,e)\\\n        _ossl_old_des_cbc_encrypt((i),(o),(l),(k),(iv),(e))\n#  define des_ncbc_encrypt(i,o,l,k,iv,e)\\\n        _ossl_old_des_ncbc_encrypt((i),(o),(l),(k),(iv),(e))\n#  define des_xcbc_encrypt(i,o,l,k,iv,inw,outw,e)\\\n        _ossl_old_des_xcbc_encrypt((i),(o),(l),(k),(iv),(inw),(outw),(e))\n#  define des_cfb_encrypt(i,o,n,l,k,iv,e)\\\n        _ossl_old_des_cfb_encrypt((i),(o),(n),(l),(k),(iv),(e))\n#  define des_ecb_encrypt(i,o,k,e)\\\n        _ossl_old_des_ecb_encrypt((i),(o),(k),(e))\n#  define des_encrypt(d,k,e)\\\n        _ossl_old_des_encrypt((d),(k),(e))\n#  define des_encrypt2(d,k,e)\\\n        _ossl_old_des_encrypt2((d),(k),(e))\n#  define des_encrypt3(d,k1,k2,k3)\\\n        _ossl_old_des_encrypt3((d),(k1),(k2),(k3))\n#  define des_decrypt3(d,k1,k2,k3)\\\n        _ossl_old_des_decrypt3((d),(k1),(k2),(k3))\n#  define des_xwhite_in2out(k,i,o)\\\n        _ossl_old_des_xwhite_in2out((k),(i),(o))\n#  define des_enc_read(f,b,l,k,iv)\\\n        _ossl_old_des_enc_read((f),(b),(l),(k),(iv))\n#  define des_enc_write(f,b,l,k,iv)\\\n        _ossl_old_des_enc_write((f),(b),(l),(k),(iv))\n#  define des_fcrypt(b,s,r)\\\n        _ossl_old_des_fcrypt((b),(s),(r))\n#  define des_crypt(b,s)\\\n        _ossl_old_des_crypt((b),(s))\n#  if 0\n#   define crypt(b,s)\\\n        _ossl_old_crypt((b),(s))\n#  endif\n#  define des_ofb_encrypt(i,o,n,l,k,iv)\\\n        _ossl_old_des_ofb_encrypt((i),(o),(n),(l),(k),(iv))\n#  define des_pcbc_encrypt(i,o,l,k,iv,e)\\\n        _ossl_old_des_pcbc_encrypt((i),(o),(l),(k),(iv),(e))\n#  define des_quad_cksum(i,o,l,c,s)\\\n        _ossl_old_des_quad_cksum((i),(o),(l),(c),(s))\n#  define des_random_seed(k)\\\n        _ossl_old_des_random_seed((k))\n#  define des_random_key(r)\\\n        _ossl_old_des_random_key((r))\n#  define des_read_password(k,p,v) \\\n        _ossl_old_des_read_password((k),(p),(v))\n#  define des_read_2passwords(k1,k2,p,v) \\\n        _ossl_old_des_read_2passwords((k1),(k2),(p),(v))\n#  define des_set_odd_parity(k)\\\n        _ossl_old_des_set_odd_parity((k))\n#  define des_is_weak_key(k)\\\n        _ossl_old_des_is_weak_key((k))\n#  define des_set_key(k,ks)\\\n        _ossl_old_des_set_key((k),(ks))\n#  define des_key_sched(k,ks)\\\n        _ossl_old_des_key_sched((k),(ks))\n#  define des_string_to_key(s,k)\\\n        _ossl_old_des_string_to_key((s),(k))\n#  define des_string_to_2keys(s,k1,k2)\\\n        _ossl_old_des_string_to_2keys((s),(k1),(k2))\n#  define des_cfb64_encrypt(i,o,l,ks,iv,n,e)\\\n        _ossl_old_des_cfb64_encrypt((i),(o),(l),(ks),(iv),(n),(e))\n#  define des_ofb64_encrypt(i,o,l,ks,iv,n)\\\n        _ossl_old_des_ofb64_encrypt((i),(o),(l),(ks),(iv),(n))\n\n#  define des_ecb2_encrypt(i,o,k1,k2,e) \\\n        des_ecb3_encrypt((i),(o),(k1),(k2),(k1),(e))\n\n#  define des_ede2_cbc_encrypt(i,o,l,k1,k2,iv,e) \\\n        des_ede3_cbc_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(e))\n\n#  define des_ede2_cfb64_encrypt(i,o,l,k1,k2,iv,n,e) \\\n        des_ede3_cfb64_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(n),(e))\n\n#  define des_ede2_ofb64_encrypt(i,o,l,k1,k2,iv,n) \\\n        des_ede3_ofb64_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(n))\n\n#  define des_check_key DES_check_key\n#  define des_rw_mode DES_rw_mode\n# endif\n\nconst char *_ossl_old_des_options(void);\nvoid _ossl_old_des_ecb3_encrypt(_ossl_old_des_cblock *input,\n                                _ossl_old_des_cblock *output,\n                                _ossl_old_des_key_schedule ks1,\n                                _ossl_old_des_key_schedule ks2,\n                                _ossl_old_des_key_schedule ks3, int enc);\nDES_LONG _ossl_old_des_cbc_cksum(_ossl_old_des_cblock *input,\n                                 _ossl_old_des_cblock *output, long length,\n                                 _ossl_old_des_key_schedule schedule,\n                                 _ossl_old_des_cblock *ivec);\nvoid _ossl_old_des_cbc_encrypt(_ossl_old_des_cblock *input,\n                               _ossl_old_des_cblock *output, long length,\n                               _ossl_old_des_key_schedule schedule,\n                               _ossl_old_des_cblock *ivec, int enc);\nvoid _ossl_old_des_ncbc_encrypt(_ossl_old_des_cblock *input,\n                                _ossl_old_des_cblock *output, long length,\n                                _ossl_old_des_key_schedule schedule,\n                                _ossl_old_des_cblock *ivec, int enc);\nvoid _ossl_old_des_xcbc_encrypt(_ossl_old_des_cblock *input,\n                                _ossl_old_des_cblock *output, long length,\n                                _ossl_old_des_key_schedule schedule,\n                                _ossl_old_des_cblock *ivec,\n                                _ossl_old_des_cblock *inw,\n                                _ossl_old_des_cblock *outw, int enc);\nvoid _ossl_old_des_cfb_encrypt(unsigned char *in, unsigned char *out,\n                               int numbits, long length,\n                               _ossl_old_des_key_schedule schedule,\n                               _ossl_old_des_cblock *ivec, int enc);\nvoid _ossl_old_des_ecb_encrypt(_ossl_old_des_cblock *input,\n                               _ossl_old_des_cblock *output,\n                               _ossl_old_des_key_schedule ks, int enc);\nvoid _ossl_old_des_encrypt(DES_LONG *data, _ossl_old_des_key_schedule ks,\n                           int enc);\nvoid _ossl_old_des_encrypt2(DES_LONG *data, _ossl_old_des_key_schedule ks,\n                            int enc);\nvoid _ossl_old_des_encrypt3(DES_LONG *data, _ossl_old_des_key_schedule ks1,\n                            _ossl_old_des_key_schedule ks2,\n                            _ossl_old_des_key_schedule ks3);\nvoid _ossl_old_des_decrypt3(DES_LONG *data, _ossl_old_des_key_schedule ks1,\n                            _ossl_old_des_key_schedule ks2,\n                            _ossl_old_des_key_schedule ks3);\nvoid _ossl_old_des_ede3_cbc_encrypt(_ossl_old_des_cblock *input,\n                                    _ossl_old_des_cblock *output, long length,\n                                    _ossl_old_des_key_schedule ks1,\n                                    _ossl_old_des_key_schedule ks2,\n                                    _ossl_old_des_key_schedule ks3,\n                                    _ossl_old_des_cblock *ivec, int enc);\nvoid _ossl_old_des_ede3_cfb64_encrypt(unsigned char *in, unsigned char *out,\n                                      long length,\n                                      _ossl_old_des_key_schedule ks1,\n                                      _ossl_old_des_key_schedule ks2,\n                                      _ossl_old_des_key_schedule ks3,\n                                      _ossl_old_des_cblock *ivec, int *num,\n                                      int enc);\nvoid _ossl_old_des_ede3_ofb64_encrypt(unsigned char *in, unsigned char *out,\n                                      long length,\n                                      _ossl_old_des_key_schedule ks1,\n                                      _ossl_old_des_key_schedule ks2,\n                                      _ossl_old_des_key_schedule ks3,\n                                      _ossl_old_des_cblock *ivec, int *num);\n# if 0\nvoid _ossl_old_des_xwhite_in2out(_ossl_old_des_cblock (*des_key),\n                                 _ossl_old_des_cblock (*in_white),\n                                 _ossl_old_des_cblock (*out_white));\n# endif\n\nint _ossl_old_des_enc_read(int fd, char *buf, int len,\n                           _ossl_old_des_key_schedule sched,\n                           _ossl_old_des_cblock *iv);\nint _ossl_old_des_enc_write(int fd, char *buf, int len,\n                            _ossl_old_des_key_schedule sched,\n                            _ossl_old_des_cblock *iv);\nchar *_ossl_old_des_fcrypt(const char *buf, const char *salt, char *ret);\nchar *_ossl_old_des_crypt(const char *buf, const char *salt);\n# if !defined(PERL5) && !defined(NeXT)\nchar *_ossl_old_crypt(const char *buf, const char *salt);\n# endif\nvoid _ossl_old_des_ofb_encrypt(unsigned char *in, unsigned char *out,\n                               int numbits, long length,\n                               _ossl_old_des_key_schedule schedule,\n                               _ossl_old_des_cblock *ivec);\nvoid _ossl_old_des_pcbc_encrypt(_ossl_old_des_cblock *input,\n                                _ossl_old_des_cblock *output, long length,\n                                _ossl_old_des_key_schedule schedule,\n                                _ossl_old_des_cblock *ivec, int enc);\nDES_LONG _ossl_old_des_quad_cksum(_ossl_old_des_cblock *input,\n                                  _ossl_old_des_cblock *output, long length,\n                                  int out_count, _ossl_old_des_cblock *seed);\nvoid _ossl_old_des_random_seed(_ossl_old_des_cblock key);\nvoid _ossl_old_des_random_key(_ossl_old_des_cblock ret);\nint _ossl_old_des_read_password(_ossl_old_des_cblock *key, const char *prompt,\n                                int verify);\nint _ossl_old_des_read_2passwords(_ossl_old_des_cblock *key1,\n                                  _ossl_old_des_cblock *key2,\n                                  const char *prompt, int verify);\nvoid _ossl_old_des_set_odd_parity(_ossl_old_des_cblock *key);\nint _ossl_old_des_is_weak_key(_ossl_old_des_cblock *key);\nint _ossl_old_des_set_key(_ossl_old_des_cblock *key,\n                          _ossl_old_des_key_schedule schedule);\nint _ossl_old_des_key_sched(_ossl_old_des_cblock *key,\n                            _ossl_old_des_key_schedule schedule);\nvoid _ossl_old_des_string_to_key(char *str, _ossl_old_des_cblock *key);\nvoid _ossl_old_des_string_to_2keys(char *str, _ossl_old_des_cblock *key1,\n                                   _ossl_old_des_cblock *key2);\nvoid _ossl_old_des_cfb64_encrypt(unsigned char *in, unsigned char *out,\n                                 long length,\n                                 _ossl_old_des_key_schedule schedule,\n                                 _ossl_old_des_cblock *ivec, int *num,\n                                 int enc);\nvoid _ossl_old_des_ofb64_encrypt(unsigned char *in, unsigned char *out,\n                                 long length,\n                                 _ossl_old_des_key_schedule schedule,\n                                 _ossl_old_des_cblock *ivec, int *num);\n\nvoid _ossl_096_des_random_seed(des_cblock *key);\n\n/*\n * The following definitions provide compatibility with the MIT Kerberos\n * library. The _ossl_old_des_key_schedule structure is not binary\n * compatible.\n */\n\n# define _KERBEROS_DES_H\n\n# define KRBDES_ENCRYPT DES_ENCRYPT\n# define KRBDES_DECRYPT DES_DECRYPT\n\n# ifdef KERBEROS\n#  define ENCRYPT DES_ENCRYPT\n#  define DECRYPT DES_DECRYPT\n# endif\n\n# ifndef NCOMPAT\n#  define C_Block des_cblock\n#  define Key_schedule des_key_schedule\n#  define KEY_SZ DES_KEY_SZ\n#  define string_to_key des_string_to_key\n#  define read_pw_string des_read_pw_string\n#  define random_key des_random_key\n#  define pcbc_encrypt des_pcbc_encrypt\n#  define set_key des_set_key\n#  define key_sched des_key_sched\n#  define ecb_encrypt des_ecb_encrypt\n#  define cbc_encrypt des_cbc_encrypt\n#  define ncbc_encrypt des_ncbc_encrypt\n#  define xcbc_encrypt des_xcbc_encrypt\n#  define cbc_cksum des_cbc_cksum\n#  define quad_cksum des_quad_cksum\n#  define check_parity des_check_key_parity\n# endif\n\n# define des_fixup_key_parity DES_fixup_key_parity\n\n#ifdef  __cplusplus\n}\n#endif\n\n/* for DES_read_pw_string et al */\n# include <openssl/ui_compat.h>\n\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/arm64/include/openssl/dh.h",
    "content": "/* crypto/dh/dh.h */\n/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)\n * All rights reserved.\n *\n * This package is an SSL implementation written\n * by Eric Young (eay@cryptsoft.com).\n * The implementation was written so as to conform with Netscapes SSL.\n *\n * This library is free for commercial and non-commercial use as long as\n * the following conditions are aheared to.  The following conditions\n * apply to all code found in this distribution, be it the RC4, RSA,\n * lhash, DES, etc., code; not just the SSL code.  The SSL documentation\n * included with this distribution is covered by the same copyright terms\n * except that the holder is Tim Hudson (tjh@cryptsoft.com).\n *\n * Copyright remains Eric Young's, and as such any Copyright notices in\n * the code are not to be removed.\n * If this package is used in a product, Eric Young should be given attribution\n * as the author of the parts of the library used.\n * This can be in the form of a textual message at program startup or\n * in documentation (online or textual) provided with the package.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the copyright\n *    notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in the\n *    documentation and/or other materials provided with the distribution.\n * 3. All advertising materials mentioning features or use of this software\n *    must display the following acknowledgement:\n *    \"This product includes cryptographic software written by\n *     Eric Young (eay@cryptsoft.com)\"\n *    The word 'cryptographic' can be left out if the rouines from the library\n *    being used are not cryptographic related :-).\n * 4. If you include any Windows specific code (or a derivative thereof) from\n *    the apps directory (application code) you must include an acknowledgement:\n *    \"This product includes software written by Tim Hudson (tjh@cryptsoft.com)\"\n *\n * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n * SUCH DAMAGE.\n *\n * The licence and distribution terms for any publically available version or\n * derivative of this code cannot be changed.  i.e. this code cannot simply be\n * copied and put under another distribution licence\n * [including the GNU Public Licence.]\n */\n\n#ifndef HEADER_DH_H\n# define HEADER_DH_H\n\n# include <openssl/e_os2.h>\n\n# ifdef OPENSSL_NO_DH\n#  error DH is disabled.\n# endif\n\n# ifndef OPENSSL_NO_BIO\n#  include <openssl/bio.h>\n# endif\n# include <openssl/ossl_typ.h>\n# ifndef OPENSSL_NO_DEPRECATED\n#  include <openssl/bn.h>\n# endif\n\n# ifndef OPENSSL_DH_MAX_MODULUS_BITS\n#  define OPENSSL_DH_MAX_MODULUS_BITS    10000\n# endif\n\n# define DH_FLAG_CACHE_MONT_P     0x01\n\n/*\n * new with 0.9.7h; the built-in DH\n * implementation now uses constant time\n * modular exponentiation for secret exponents\n * by default. This flag causes the\n * faster variable sliding window method to\n * be used for all exponents.\n */\n# define DH_FLAG_NO_EXP_CONSTTIME 0x02\n\n/*\n * If this flag is set the DH method is FIPS compliant and can be used in\n * FIPS mode. This is set in the validated module method. If an application\n * sets this flag in its own methods it is its reposibility to ensure the\n * result is compliant.\n */\n\n# define DH_FLAG_FIPS_METHOD                     0x0400\n\n/*\n * If this flag is set the operations normally disabled in FIPS mode are\n * permitted it is then the applications responsibility to ensure that the\n * usage is compliant.\n */\n\n# define DH_FLAG_NON_FIPS_ALLOW                  0x0400\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n/* Already defined in ossl_typ.h */\n/* typedef struct dh_st DH; */\n/* typedef struct dh_method DH_METHOD; */\n\nstruct dh_method {\n    const char *name;\n    /* Methods here */\n    int (*generate_key) (DH *dh);\n    int (*compute_key) (unsigned char *key, const BIGNUM *pub_key, DH *dh);\n    /* Can be null */\n    int (*bn_mod_exp) (const DH *dh, BIGNUM *r, const BIGNUM *a,\n                       const BIGNUM *p, const BIGNUM *m, BN_CTX *ctx,\n                       BN_MONT_CTX *m_ctx);\n    int (*init) (DH *dh);\n    int (*finish) (DH *dh);\n    int flags;\n    char *app_data;\n    /* If this is non-NULL, it will be used to generate parameters */\n    int (*generate_params) (DH *dh, int prime_len, int generator,\n                            BN_GENCB *cb);\n};\n\nstruct dh_st {\n    /*\n     * This first argument is used to pick up errors when a DH is passed\n     * instead of a EVP_PKEY\n     */\n    int pad;\n    int version;\n    BIGNUM *p;\n    BIGNUM *g;\n    long length;                /* optional */\n    BIGNUM *pub_key;            /* g^x % p */\n    BIGNUM *priv_key;           /* x */\n    int flags;\n    BN_MONT_CTX *method_mont_p;\n    /* Place holders if we want to do X9.42 DH */\n    BIGNUM *q;\n    BIGNUM *j;\n    unsigned char *seed;\n    int seedlen;\n    BIGNUM *counter;\n    int references;\n    CRYPTO_EX_DATA ex_data;\n    const DH_METHOD *meth;\n    ENGINE *engine;\n};\n\n# define DH_GENERATOR_2          2\n/* #define DH_GENERATOR_3       3 */\n# define DH_GENERATOR_5          5\n\n/* DH_check error codes */\n# define DH_CHECK_P_NOT_PRIME            0x01\n# define DH_CHECK_P_NOT_SAFE_PRIME       0x02\n# define DH_UNABLE_TO_CHECK_GENERATOR    0x04\n# define DH_NOT_SUITABLE_GENERATOR       0x08\n# define DH_CHECK_Q_NOT_PRIME            0x10\n# define DH_CHECK_INVALID_Q_VALUE        0x20\n# define DH_CHECK_INVALID_J_VALUE        0x40\n\n/* DH_check_pub_key error codes */\n# define DH_CHECK_PUBKEY_TOO_SMALL       0x01\n# define DH_CHECK_PUBKEY_TOO_LARGE       0x02\n# define DH_CHECK_PUBKEY_INVALID         0x04\n\n/*\n * primes p where (p-1)/2 is prime too are called \"safe\"; we define this for\n * backward compatibility:\n */\n# define DH_CHECK_P_NOT_STRONG_PRIME     DH_CHECK_P_NOT_SAFE_PRIME\n\n# define d2i_DHparams_fp(fp,x) (DH *)ASN1_d2i_fp((char *(*)())DH_new, \\\n                (char *(*)())d2i_DHparams,(fp),(unsigned char **)(x))\n# define i2d_DHparams_fp(fp,x) ASN1_i2d_fp(i2d_DHparams,(fp), \\\n                (unsigned char *)(x))\n# define d2i_DHparams_bio(bp,x) ASN1_d2i_bio_of(DH,DH_new,d2i_DHparams,bp,x)\n# define i2d_DHparams_bio(bp,x) ASN1_i2d_bio_of_const(DH,i2d_DHparams,bp,x)\n\nDH *DHparams_dup(DH *);\n\nconst DH_METHOD *DH_OpenSSL(void);\n\nvoid DH_set_default_method(const DH_METHOD *meth);\nconst DH_METHOD *DH_get_default_method(void);\nint DH_set_method(DH *dh, const DH_METHOD *meth);\nDH *DH_new_method(ENGINE *engine);\n\nDH *DH_new(void);\nvoid DH_free(DH *dh);\nint DH_up_ref(DH *dh);\nint DH_size(const DH *dh);\nint DH_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func,\n                        CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func);\nint DH_set_ex_data(DH *d, int idx, void *arg);\nvoid *DH_get_ex_data(DH *d, int idx);\n\n/* Deprecated version */\n# ifndef OPENSSL_NO_DEPRECATED\nDH *DH_generate_parameters(int prime_len, int generator,\n                           void (*callback) (int, int, void *), void *cb_arg);\n# endif                         /* !defined(OPENSSL_NO_DEPRECATED) */\n\n/* New version */\nint DH_generate_parameters_ex(DH *dh, int prime_len, int generator,\n                              BN_GENCB *cb);\n\nint DH_check(const DH *dh, int *codes);\nint DH_check_pub_key(const DH *dh, const BIGNUM *pub_key, int *codes);\nint DH_generate_key(DH *dh);\nint DH_compute_key(unsigned char *key, const BIGNUM *pub_key, DH *dh);\nint DH_compute_key_padded(unsigned char *key, const BIGNUM *pub_key, DH *dh);\nDH *d2i_DHparams(DH **a, const unsigned char **pp, long length);\nint i2d_DHparams(const DH *a, unsigned char **pp);\nDH *d2i_DHxparams(DH **a, const unsigned char **pp, long length);\nint i2d_DHxparams(const DH *a, unsigned char **pp);\n# ifndef OPENSSL_NO_FP_API\nint DHparams_print_fp(FILE *fp, const DH *x);\n# endif\n# ifndef OPENSSL_NO_BIO\nint DHparams_print(BIO *bp, const DH *x);\n# else\nint DHparams_print(char *bp, const DH *x);\n# endif\n\n/* RFC 5114 parameters */\nDH *DH_get_1024_160(void);\nDH *DH_get_2048_224(void);\nDH *DH_get_2048_256(void);\n\n/* RFC2631 KDF */\nint DH_KDF_X9_42(unsigned char *out, size_t outlen,\n                 const unsigned char *Z, size_t Zlen,\n                 ASN1_OBJECT *key_oid,\n                 const unsigned char *ukm, size_t ukmlen, const EVP_MD *md);\n\n# define EVP_PKEY_CTX_set_dh_paramgen_prime_len(ctx, len) \\\n        EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DH, EVP_PKEY_OP_PARAMGEN, \\\n                        EVP_PKEY_CTRL_DH_PARAMGEN_PRIME_LEN, len, NULL)\n\n# define EVP_PKEY_CTX_set_dh_paramgen_subprime_len(ctx, len) \\\n        EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DH, EVP_PKEY_OP_PARAMGEN, \\\n                        EVP_PKEY_CTRL_DH_PARAMGEN_SUBPRIME_LEN, len, NULL)\n\n# define EVP_PKEY_CTX_set_dh_paramgen_type(ctx, typ) \\\n        EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DH, EVP_PKEY_OP_PARAMGEN, \\\n                        EVP_PKEY_CTRL_DH_PARAMGEN_TYPE, typ, NULL)\n\n# define EVP_PKEY_CTX_set_dh_paramgen_generator(ctx, gen) \\\n        EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DH, EVP_PKEY_OP_PARAMGEN, \\\n                        EVP_PKEY_CTRL_DH_PARAMGEN_GENERATOR, gen, NULL)\n\n# define EVP_PKEY_CTX_set_dh_rfc5114(ctx, gen) \\\n        EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DHX, EVP_PKEY_OP_PARAMGEN, \\\n                        EVP_PKEY_CTRL_DH_RFC5114, gen, NULL)\n\n# define EVP_PKEY_CTX_set_dhx_rfc5114(ctx, gen) \\\n        EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DHX, EVP_PKEY_OP_PARAMGEN, \\\n                        EVP_PKEY_CTRL_DH_RFC5114, gen, NULL)\n\n# define EVP_PKEY_CTX_set_dh_kdf_type(ctx, kdf) \\\n        EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DHX, \\\n                                EVP_PKEY_OP_DERIVE, \\\n                                EVP_PKEY_CTRL_DH_KDF_TYPE, kdf, NULL)\n\n# define EVP_PKEY_CTX_get_dh_kdf_type(ctx) \\\n        EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DHX, \\\n                                EVP_PKEY_OP_DERIVE, \\\n                                EVP_PKEY_CTRL_DH_KDF_TYPE, -2, NULL)\n\n# define EVP_PKEY_CTX_set0_dh_kdf_oid(ctx, oid) \\\n        EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DHX, \\\n                                EVP_PKEY_OP_DERIVE, \\\n                                EVP_PKEY_CTRL_DH_KDF_OID, 0, (void *)oid)\n\n# define EVP_PKEY_CTX_get0_dh_kdf_oid(ctx, poid) \\\n        EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DHX, \\\n                                EVP_PKEY_OP_DERIVE, \\\n                                EVP_PKEY_CTRL_GET_DH_KDF_OID, 0, (void *)poid)\n\n# define EVP_PKEY_CTX_set_dh_kdf_md(ctx, md) \\\n        EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DHX, \\\n                                EVP_PKEY_OP_DERIVE, \\\n                                EVP_PKEY_CTRL_DH_KDF_MD, 0, (void *)md)\n\n# define EVP_PKEY_CTX_get_dh_kdf_md(ctx, pmd) \\\n        EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DHX, \\\n                                EVP_PKEY_OP_DERIVE, \\\n                                EVP_PKEY_CTRL_GET_DH_KDF_MD, 0, (void *)pmd)\n\n# define EVP_PKEY_CTX_set_dh_kdf_outlen(ctx, len) \\\n        EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DHX, \\\n                                EVP_PKEY_OP_DERIVE, \\\n                                EVP_PKEY_CTRL_DH_KDF_OUTLEN, len, NULL)\n\n# define EVP_PKEY_CTX_get_dh_kdf_outlen(ctx, plen) \\\n        EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DHX, \\\n                                EVP_PKEY_OP_DERIVE, \\\n                        EVP_PKEY_CTRL_GET_DH_KDF_OUTLEN, 0, (void *)plen)\n\n# define EVP_PKEY_CTX_set0_dh_kdf_ukm(ctx, p, plen) \\\n        EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DHX, \\\n                                EVP_PKEY_OP_DERIVE, \\\n                                EVP_PKEY_CTRL_DH_KDF_UKM, plen, (void *)p)\n\n# define EVP_PKEY_CTX_get0_dh_kdf_ukm(ctx, p) \\\n        EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DHX, \\\n                                EVP_PKEY_OP_DERIVE, \\\n                                EVP_PKEY_CTRL_GET_DH_KDF_UKM, 0, (void *)p)\n\n# define EVP_PKEY_CTRL_DH_PARAMGEN_PRIME_LEN     (EVP_PKEY_ALG_CTRL + 1)\n# define EVP_PKEY_CTRL_DH_PARAMGEN_GENERATOR     (EVP_PKEY_ALG_CTRL + 2)\n# define EVP_PKEY_CTRL_DH_RFC5114                (EVP_PKEY_ALG_CTRL + 3)\n# define EVP_PKEY_CTRL_DH_PARAMGEN_SUBPRIME_LEN  (EVP_PKEY_ALG_CTRL + 4)\n# define EVP_PKEY_CTRL_DH_PARAMGEN_TYPE          (EVP_PKEY_ALG_CTRL + 5)\n# define EVP_PKEY_CTRL_DH_KDF_TYPE               (EVP_PKEY_ALG_CTRL + 6)\n# define EVP_PKEY_CTRL_DH_KDF_MD                 (EVP_PKEY_ALG_CTRL + 7)\n# define EVP_PKEY_CTRL_GET_DH_KDF_MD             (EVP_PKEY_ALG_CTRL + 8)\n# define EVP_PKEY_CTRL_DH_KDF_OUTLEN             (EVP_PKEY_ALG_CTRL + 9)\n# define EVP_PKEY_CTRL_GET_DH_KDF_OUTLEN         (EVP_PKEY_ALG_CTRL + 10)\n# define EVP_PKEY_CTRL_DH_KDF_UKM                (EVP_PKEY_ALG_CTRL + 11)\n# define EVP_PKEY_CTRL_GET_DH_KDF_UKM            (EVP_PKEY_ALG_CTRL + 12)\n# define EVP_PKEY_CTRL_DH_KDF_OID                (EVP_PKEY_ALG_CTRL + 13)\n# define EVP_PKEY_CTRL_GET_DH_KDF_OID            (EVP_PKEY_ALG_CTRL + 14)\n\n/* KDF types */\n# define EVP_PKEY_DH_KDF_NONE                            1\n# define EVP_PKEY_DH_KDF_X9_42                           2\n\n/* BEGIN ERROR CODES */\n/*\n * The following lines are auto generated by the script mkerr.pl. Any changes\n * made after this point may be overwritten when the script is next run.\n */\nvoid ERR_load_DH_strings(void);\n\n/* Error codes for the DH functions. */\n\n/* Function codes. */\n# define DH_F_COMPUTE_KEY                                 102\n# define DH_F_DHPARAMS_PRINT_FP                           101\n# define DH_F_DH_BUILTIN_GENPARAMS                        106\n# define DH_F_DH_CMS_DECRYPT                              117\n# define DH_F_DH_CMS_SET_PEERKEY                          118\n# define DH_F_DH_CMS_SET_SHARED_INFO                      119\n# define DH_F_DH_COMPUTE_KEY                              114\n# define DH_F_DH_GENERATE_KEY                             115\n# define DH_F_DH_GENERATE_PARAMETERS_EX                   116\n# define DH_F_DH_NEW_METHOD                               105\n# define DH_F_DH_PARAM_DECODE                             107\n# define DH_F_DH_PRIV_DECODE                              110\n# define DH_F_DH_PRIV_ENCODE                              111\n# define DH_F_DH_PUB_DECODE                               108\n# define DH_F_DH_PUB_ENCODE                               109\n# define DH_F_DO_DH_PRINT                                 100\n# define DH_F_GENERATE_KEY                                103\n# define DH_F_GENERATE_PARAMETERS                         104\n# define DH_F_PKEY_DH_DERIVE                              112\n# define DH_F_PKEY_DH_KEYGEN                              113\n\n/* Reason codes. */\n# define DH_R_BAD_GENERATOR                               101\n# define DH_R_BN_DECODE_ERROR                             109\n# define DH_R_BN_ERROR                                    106\n# define DH_R_DECODE_ERROR                                104\n# define DH_R_INVALID_PUBKEY                              102\n# define DH_R_KDF_PARAMETER_ERROR                         112\n# define DH_R_KEYS_NOT_SET                                108\n# define DH_R_KEY_SIZE_TOO_SMALL                          110\n# define DH_R_MODULUS_TOO_LARGE                           103\n# define DH_R_NON_FIPS_METHOD                             111\n# define DH_R_NO_PARAMETERS_SET                           107\n# define DH_R_NO_PRIVATE_VALUE                            100\n# define DH_R_PARAMETER_ENCODING_ERROR                    105\n# define DH_R_PEER_KEY_ERROR                              113\n# define DH_R_SHARED_INFO_ERROR                           114\n\n#ifdef  __cplusplus\n}\n#endif\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/arm64/include/openssl/dsa.h",
    "content": "/* crypto/dsa/dsa.h */\n/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)\n * All rights reserved.\n *\n * This package is an SSL implementation written\n * by Eric Young (eay@cryptsoft.com).\n * The implementation was written so as to conform with Netscapes SSL.\n *\n * This library is free for commercial and non-commercial use as long as\n * the following conditions are aheared to.  The following conditions\n * apply to all code found in this distribution, be it the RC4, RSA,\n * lhash, DES, etc., code; not just the SSL code.  The SSL documentation\n * included with this distribution is covered by the same copyright terms\n * except that the holder is Tim Hudson (tjh@cryptsoft.com).\n *\n * Copyright remains Eric Young's, and as such any Copyright notices in\n * the code are not to be removed.\n * If this package is used in a product, Eric Young should be given attribution\n * as the author of the parts of the library used.\n * This can be in the form of a textual message at program startup or\n * in documentation (online or textual) provided with the package.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the copyright\n *    notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in the\n *    documentation and/or other materials provided with the distribution.\n * 3. All advertising materials mentioning features or use of this software\n *    must display the following acknowledgement:\n *    \"This product includes cryptographic software written by\n *     Eric Young (eay@cryptsoft.com)\"\n *    The word 'cryptographic' can be left out if the rouines from the library\n *    being used are not cryptographic related :-).\n * 4. If you include any Windows specific code (or a derivative thereof) from\n *    the apps directory (application code) you must include an acknowledgement:\n *    \"This product includes software written by Tim Hudson (tjh@cryptsoft.com)\"\n *\n * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n * SUCH DAMAGE.\n *\n * The licence and distribution terms for any publically available version or\n * derivative of this code cannot be changed.  i.e. this code cannot simply be\n * copied and put under another distribution licence\n * [including the GNU Public Licence.]\n */\n\n/*\n * The DSS routines are based on patches supplied by\n * Steven Schoch <schoch@sheba.arc.nasa.gov>.  He basically did the\n * work and I have just tweaked them a little to fit into my\n * stylistic vision for SSLeay :-) */\n\n#ifndef HEADER_DSA_H\n# define HEADER_DSA_H\n\n# include <openssl/e_os2.h>\n\n# ifdef OPENSSL_NO_DSA\n#  error DSA is disabled.\n# endif\n\n# ifndef OPENSSL_NO_BIO\n#  include <openssl/bio.h>\n# endif\n# include <openssl/crypto.h>\n# include <openssl/ossl_typ.h>\n\n# ifndef OPENSSL_NO_DEPRECATED\n#  include <openssl/bn.h>\n#  ifndef OPENSSL_NO_DH\n#   include <openssl/dh.h>\n#  endif\n# endif\n\n# ifndef OPENSSL_DSA_MAX_MODULUS_BITS\n#  define OPENSSL_DSA_MAX_MODULUS_BITS   10000\n# endif\n\n# define DSA_FLAG_CACHE_MONT_P   0x01\n/*\n * new with 0.9.7h; the built-in DSA implementation now uses constant time\n * modular exponentiation for secret exponents by default. This flag causes\n * the faster variable sliding window method to be used for all exponents.\n */\n# define DSA_FLAG_NO_EXP_CONSTTIME       0x02\n\n/*\n * If this flag is set the DSA method is FIPS compliant and can be used in\n * FIPS mode. This is set in the validated module method. If an application\n * sets this flag in its own methods it is its reposibility to ensure the\n * result is compliant.\n */\n\n# define DSA_FLAG_FIPS_METHOD                    0x0400\n\n/*\n * If this flag is set the operations normally disabled in FIPS mode are\n * permitted it is then the applications responsibility to ensure that the\n * usage is compliant.\n */\n\n# define DSA_FLAG_NON_FIPS_ALLOW                 0x0400\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n/* Already defined in ossl_typ.h */\n/* typedef struct dsa_st DSA; */\n/* typedef struct dsa_method DSA_METHOD; */\n\ntypedef struct DSA_SIG_st {\n    BIGNUM *r;\n    BIGNUM *s;\n} DSA_SIG;\n\nstruct dsa_method {\n    const char *name;\n    DSA_SIG *(*dsa_do_sign) (const unsigned char *dgst, int dlen, DSA *dsa);\n    int (*dsa_sign_setup) (DSA *dsa, BN_CTX *ctx_in, BIGNUM **kinvp,\n                           BIGNUM **rp);\n    int (*dsa_do_verify) (const unsigned char *dgst, int dgst_len,\n                          DSA_SIG *sig, DSA *dsa);\n    int (*dsa_mod_exp) (DSA *dsa, BIGNUM *rr, BIGNUM *a1, BIGNUM *p1,\n                        BIGNUM *a2, BIGNUM *p2, BIGNUM *m, BN_CTX *ctx,\n                        BN_MONT_CTX *in_mont);\n    /* Can be null */\n    int (*bn_mod_exp) (DSA *dsa, BIGNUM *r, BIGNUM *a, const BIGNUM *p,\n                       const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx);\n    int (*init) (DSA *dsa);\n    int (*finish) (DSA *dsa);\n    int flags;\n    char *app_data;\n    /* If this is non-NULL, it is used to generate DSA parameters */\n    int (*dsa_paramgen) (DSA *dsa, int bits,\n                         const unsigned char *seed, int seed_len,\n                         int *counter_ret, unsigned long *h_ret,\n                         BN_GENCB *cb);\n    /* If this is non-NULL, it is used to generate DSA keys */\n    int (*dsa_keygen) (DSA *dsa);\n};\n\nstruct dsa_st {\n    /*\n     * This first variable is used to pick up errors where a DSA is passed\n     * instead of of a EVP_PKEY\n     */\n    int pad;\n    long version;\n    int write_params;\n    BIGNUM *p;\n    BIGNUM *q;                  /* == 20 */\n    BIGNUM *g;\n    BIGNUM *pub_key;            /* y public key */\n    BIGNUM *priv_key;           /* x private key */\n    BIGNUM *kinv;               /* Signing pre-calc */\n    BIGNUM *r;                  /* Signing pre-calc */\n    int flags;\n    /* Normally used to cache montgomery values */\n    BN_MONT_CTX *method_mont_p;\n    int references;\n    CRYPTO_EX_DATA ex_data;\n    const DSA_METHOD *meth;\n    /* functional reference if 'meth' is ENGINE-provided */\n    ENGINE *engine;\n};\n\n# define d2i_DSAparams_fp(fp,x) (DSA *)ASN1_d2i_fp((char *(*)())DSA_new, \\\n                (char *(*)())d2i_DSAparams,(fp),(unsigned char **)(x))\n# define i2d_DSAparams_fp(fp,x) ASN1_i2d_fp(i2d_DSAparams,(fp), \\\n                (unsigned char *)(x))\n# define d2i_DSAparams_bio(bp,x) ASN1_d2i_bio_of(DSA,DSA_new,d2i_DSAparams,bp,x)\n# define i2d_DSAparams_bio(bp,x) ASN1_i2d_bio_of_const(DSA,i2d_DSAparams,bp,x)\n\nDSA *DSAparams_dup(DSA *x);\nDSA_SIG *DSA_SIG_new(void);\nvoid DSA_SIG_free(DSA_SIG *a);\nint i2d_DSA_SIG(const DSA_SIG *a, unsigned char **pp);\nDSA_SIG *d2i_DSA_SIG(DSA_SIG **v, const unsigned char **pp, long length);\n\nDSA_SIG *DSA_do_sign(const unsigned char *dgst, int dlen, DSA *dsa);\nint DSA_do_verify(const unsigned char *dgst, int dgst_len,\n                  DSA_SIG *sig, DSA *dsa);\n\nconst DSA_METHOD *DSA_OpenSSL(void);\n\nvoid DSA_set_default_method(const DSA_METHOD *);\nconst DSA_METHOD *DSA_get_default_method(void);\nint DSA_set_method(DSA *dsa, const DSA_METHOD *);\n\nDSA *DSA_new(void);\nDSA *DSA_new_method(ENGINE *engine);\nvoid DSA_free(DSA *r);\n/* \"up\" the DSA object's reference count */\nint DSA_up_ref(DSA *r);\nint DSA_size(const DSA *);\n        /* next 4 return -1 on error */\nint DSA_sign_setup(DSA *dsa, BN_CTX *ctx_in, BIGNUM **kinvp, BIGNUM **rp);\nint DSA_sign(int type, const unsigned char *dgst, int dlen,\n             unsigned char *sig, unsigned int *siglen, DSA *dsa);\nint DSA_verify(int type, const unsigned char *dgst, int dgst_len,\n               const unsigned char *sigbuf, int siglen, DSA *dsa);\nint DSA_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func,\n                         CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func);\nint DSA_set_ex_data(DSA *d, int idx, void *arg);\nvoid *DSA_get_ex_data(DSA *d, int idx);\n\nDSA *d2i_DSAPublicKey(DSA **a, const unsigned char **pp, long length);\nDSA *d2i_DSAPrivateKey(DSA **a, const unsigned char **pp, long length);\nDSA *d2i_DSAparams(DSA **a, const unsigned char **pp, long length);\n\n/* Deprecated version */\n# ifndef OPENSSL_NO_DEPRECATED\nDSA *DSA_generate_parameters(int bits,\n                             unsigned char *seed, int seed_len,\n                             int *counter_ret, unsigned long *h_ret, void\n                              (*callback) (int, int, void *), void *cb_arg);\n# endif                         /* !defined(OPENSSL_NO_DEPRECATED) */\n\n/* New version */\nint DSA_generate_parameters_ex(DSA *dsa, int bits,\n                               const unsigned char *seed, int seed_len,\n                               int *counter_ret, unsigned long *h_ret,\n                               BN_GENCB *cb);\n\nint DSA_generate_key(DSA *a);\nint i2d_DSAPublicKey(const DSA *a, unsigned char **pp);\nint i2d_DSAPrivateKey(const DSA *a, unsigned char **pp);\nint i2d_DSAparams(const DSA *a, unsigned char **pp);\n\n# ifndef OPENSSL_NO_BIO\nint DSAparams_print(BIO *bp, const DSA *x);\nint DSA_print(BIO *bp, const DSA *x, int off);\n# endif\n# ifndef OPENSSL_NO_FP_API\nint DSAparams_print_fp(FILE *fp, const DSA *x);\nint DSA_print_fp(FILE *bp, const DSA *x, int off);\n# endif\n\n# define DSS_prime_checks 50\n/*\n * Primality test according to FIPS PUB 186[-1], Appendix 2.1: 50 rounds of\n * Rabin-Miller\n */\n# define DSA_is_prime(n, callback, cb_arg) \\\n        BN_is_prime(n, DSS_prime_checks, callback, NULL, cb_arg)\n\n# ifndef OPENSSL_NO_DH\n/*\n * Convert DSA structure (key or just parameters) into DH structure (be\n * careful to avoid small subgroup attacks when using this!)\n */\nDH *DSA_dup_DH(const DSA *r);\n# endif\n\n# define EVP_PKEY_CTX_set_dsa_paramgen_bits(ctx, nbits) \\\n        EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DSA, EVP_PKEY_OP_PARAMGEN, \\\n                                EVP_PKEY_CTRL_DSA_PARAMGEN_BITS, nbits, NULL)\n\n# define EVP_PKEY_CTRL_DSA_PARAMGEN_BITS         (EVP_PKEY_ALG_CTRL + 1)\n# define EVP_PKEY_CTRL_DSA_PARAMGEN_Q_BITS       (EVP_PKEY_ALG_CTRL + 2)\n# define EVP_PKEY_CTRL_DSA_PARAMGEN_MD           (EVP_PKEY_ALG_CTRL + 3)\n\n/* BEGIN ERROR CODES */\n/*\n * The following lines are auto generated by the script mkerr.pl. Any changes\n * made after this point may be overwritten when the script is next run.\n */\nvoid ERR_load_DSA_strings(void);\n\n/* Error codes for the DSA functions. */\n\n/* Function codes. */\n# define DSA_F_D2I_DSA_SIG                                110\n# define DSA_F_DO_DSA_PRINT                               104\n# define DSA_F_DSAPARAMS_PRINT                            100\n# define DSA_F_DSAPARAMS_PRINT_FP                         101\n# define DSA_F_DSA_BUILTIN_PARAMGEN2                      126\n# define DSA_F_DSA_DO_SIGN                                112\n# define DSA_F_DSA_DO_VERIFY                              113\n# define DSA_F_DSA_GENERATE_KEY                           124\n# define DSA_F_DSA_GENERATE_PARAMETERS_EX                 123\n# define DSA_F_DSA_NEW_METHOD                             103\n# define DSA_F_DSA_PARAM_DECODE                           119\n# define DSA_F_DSA_PRINT_FP                               105\n# define DSA_F_DSA_PRIV_DECODE                            115\n# define DSA_F_DSA_PRIV_ENCODE                            116\n# define DSA_F_DSA_PUB_DECODE                             117\n# define DSA_F_DSA_PUB_ENCODE                             118\n# define DSA_F_DSA_SIGN                                   106\n# define DSA_F_DSA_SIGN_SETUP                             107\n# define DSA_F_DSA_SIG_NEW                                109\n# define DSA_F_DSA_SIG_PRINT                              125\n# define DSA_F_DSA_VERIFY                                 108\n# define DSA_F_I2D_DSA_SIG                                111\n# define DSA_F_OLD_DSA_PRIV_DECODE                        122\n# define DSA_F_PKEY_DSA_CTRL                              120\n# define DSA_F_PKEY_DSA_KEYGEN                            121\n# define DSA_F_SIG_CB                                     114\n\n/* Reason codes. */\n# define DSA_R_BAD_Q_VALUE                                102\n# define DSA_R_BN_DECODE_ERROR                            108\n# define DSA_R_BN_ERROR                                   109\n# define DSA_R_DATA_TOO_LARGE_FOR_KEY_SIZE                100\n# define DSA_R_DECODE_ERROR                               104\n# define DSA_R_INVALID_DIGEST_TYPE                        106\n# define DSA_R_INVALID_PARAMETERS                         112\n# define DSA_R_MISSING_PARAMETERS                         101\n# define DSA_R_MODULUS_TOO_LARGE                          103\n# define DSA_R_NEED_NEW_SETUP_VALUES                      110\n# define DSA_R_NON_FIPS_DSA_METHOD                        111\n# define DSA_R_NO_PARAMETERS_SET                          107\n# define DSA_R_PARAMETER_ENCODING_ERROR                   105\n# define DSA_R_Q_NOT_PRIME                                113\n\n#ifdef  __cplusplus\n}\n#endif\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/arm64/include/openssl/dso.h",
    "content": "/* dso.h */\n/*\n * Written by Geoff Thorpe (geoff@geoffthorpe.net) for the OpenSSL project\n * 2000.\n */\n/* ====================================================================\n * Copyright (c) 2000 The OpenSSL Project.  All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n *\n * 1. Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n *\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in\n *    the documentation and/or other materials provided with the\n *    distribution.\n *\n * 3. All advertising materials mentioning features or use of this\n *    software must display the following acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)\"\n *\n * 4. The names \"OpenSSL Toolkit\" and \"OpenSSL Project\" must not be used to\n *    endorse or promote products derived from this software without\n *    prior written permission. For written permission, please contact\n *    licensing@OpenSSL.org.\n *\n * 5. Products derived from this software may not be called \"OpenSSL\"\n *    nor may \"OpenSSL\" appear in their names without prior written\n *    permission of the OpenSSL Project.\n *\n * 6. Redistributions of any form whatsoever must retain the following\n *    acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)\"\n *\n * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY\n * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\n * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR\n * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\n * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,\n * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED\n * OF THE POSSIBILITY OF SUCH DAMAGE.\n * ====================================================================\n *\n * This product includes cryptographic software written by Eric Young\n * (eay@cryptsoft.com).  This product includes software written by Tim\n * Hudson (tjh@cryptsoft.com).\n *\n */\n\n#ifndef HEADER_DSO_H\n# define HEADER_DSO_H\n\n# include <openssl/crypto.h>\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/* These values are used as commands to DSO_ctrl() */\n# define DSO_CTRL_GET_FLAGS      1\n# define DSO_CTRL_SET_FLAGS      2\n# define DSO_CTRL_OR_FLAGS       3\n\n/*\n * By default, DSO_load() will translate the provided filename into a form\n * typical for the platform (more specifically the DSO_METHOD) using the\n * dso_name_converter function of the method. Eg. win32 will transform \"blah\"\n * into \"blah.dll\", and dlfcn will transform it into \"libblah.so\". The\n * behaviour can be overriden by setting the name_converter callback in the\n * DSO object (using DSO_set_name_converter()). This callback could even\n * utilise the DSO_METHOD's converter too if it only wants to override\n * behaviour for one or two possible DSO methods. However, the following flag\n * can be set in a DSO to prevent *any* native name-translation at all - eg.\n * if the caller has prompted the user for a path to a driver library so the\n * filename should be interpreted as-is.\n */\n# define DSO_FLAG_NO_NAME_TRANSLATION            0x01\n/*\n * An extra flag to give if only the extension should be added as\n * translation.  This is obviously only of importance on Unix and other\n * operating systems where the translation also may prefix the name with\n * something, like 'lib', and ignored everywhere else. This flag is also\n * ignored if DSO_FLAG_NO_NAME_TRANSLATION is used at the same time.\n */\n# define DSO_FLAG_NAME_TRANSLATION_EXT_ONLY      0x02\n\n/*\n * The following flag controls the translation of symbol names to upper case.\n * This is currently only being implemented for OpenVMS.\n */\n# define DSO_FLAG_UPCASE_SYMBOL                  0x10\n\n/*\n * This flag loads the library with public symbols. Meaning: The exported\n * symbols of this library are public to all libraries loaded after this\n * library. At the moment only implemented in unix.\n */\n# define DSO_FLAG_GLOBAL_SYMBOLS                 0x20\n\ntypedef void (*DSO_FUNC_TYPE) (void);\n\ntypedef struct dso_st DSO;\n\n/*\n * The function prototype used for method functions (or caller-provided\n * callbacks) that transform filenames. They are passed a DSO structure\n * pointer (or NULL if they are to be used independantly of a DSO object) and\n * a filename to transform. They should either return NULL (if there is an\n * error condition) or a newly allocated string containing the transformed\n * form that the caller will need to free with OPENSSL_free() when done.\n */\ntypedef char *(*DSO_NAME_CONVERTER_FUNC)(DSO *, const char *);\n/*\n * The function prototype used for method functions (or caller-provided\n * callbacks) that merge two file specifications. They are passed a DSO\n * structure pointer (or NULL if they are to be used independantly of a DSO\n * object) and two file specifications to merge. They should either return\n * NULL (if there is an error condition) or a newly allocated string\n * containing the result of merging that the caller will need to free with\n * OPENSSL_free() when done. Here, merging means that bits and pieces are\n * taken from each of the file specifications and added together in whatever\n * fashion that is sensible for the DSO method in question.  The only rule\n * that really applies is that if the two specification contain pieces of the\n * same type, the copy from the first string takes priority.  One could see\n * it as the first specification is the one given by the user and the second\n * being a bunch of defaults to add on if they're missing in the first.\n */\ntypedef char *(*DSO_MERGER_FUNC)(DSO *, const char *, const char *);\n\ntypedef struct dso_meth_st {\n    const char *name;\n    /*\n     * Loads a shared library, NB: new DSO_METHODs must ensure that a\n     * successful load populates the loaded_filename field, and likewise a\n     * successful unload OPENSSL_frees and NULLs it out.\n     */\n    int (*dso_load) (DSO *dso);\n    /* Unloads a shared library */\n    int (*dso_unload) (DSO *dso);\n    /* Binds a variable */\n    void *(*dso_bind_var) (DSO *dso, const char *symname);\n    /*\n     * Binds a function - assumes a return type of DSO_FUNC_TYPE. This should\n     * be cast to the real function prototype by the caller. Platforms that\n     * don't have compatible representations for different prototypes (this\n     * is possible within ANSI C) are highly unlikely to have shared\n     * libraries at all, let alone a DSO_METHOD implemented for them.\n     */\n    DSO_FUNC_TYPE (*dso_bind_func) (DSO *dso, const char *symname);\n/* I don't think this would actually be used in any circumstances. */\n# if 0\n    /* Unbinds a variable */\n    int (*dso_unbind_var) (DSO *dso, char *symname, void *symptr);\n    /* Unbinds a function */\n    int (*dso_unbind_func) (DSO *dso, char *symname, DSO_FUNC_TYPE symptr);\n# endif\n    /*\n     * The generic (yuck) \"ctrl()\" function. NB: Negative return values\n     * (rather than zero) indicate errors.\n     */\n    long (*dso_ctrl) (DSO *dso, int cmd, long larg, void *parg);\n    /*\n     * The default DSO_METHOD-specific function for converting filenames to a\n     * canonical native form.\n     */\n    DSO_NAME_CONVERTER_FUNC dso_name_converter;\n    /*\n     * The default DSO_METHOD-specific function for converting filenames to a\n     * canonical native form.\n     */\n    DSO_MERGER_FUNC dso_merger;\n    /* [De]Initialisation handlers. */\n    int (*init) (DSO *dso);\n    int (*finish) (DSO *dso);\n    /* Return pathname of the module containing location */\n    int (*pathbyaddr) (void *addr, char *path, int sz);\n    /* Perform global symbol lookup, i.e. among *all* modules */\n    void *(*globallookup) (const char *symname);\n} DSO_METHOD;\n\n/**********************************************************************/\n/* The low-level handle type used to refer to a loaded shared library */\n\nstruct dso_st {\n    DSO_METHOD *meth;\n    /*\n     * Standard dlopen uses a (void *). Win32 uses a HANDLE. VMS doesn't use\n     * anything but will need to cache the filename for use in the dso_bind\n     * handler. All in all, let each method control its own destiny.\n     * \"Handles\" and such go in a STACK.\n     */\n    STACK_OF(void) *meth_data;\n    int references;\n    int flags;\n    /*\n     * For use by applications etc ... use this for your bits'n'pieces, don't\n     * touch meth_data!\n     */\n    CRYPTO_EX_DATA ex_data;\n    /*\n     * If this callback function pointer is set to non-NULL, then it will be\n     * used in DSO_load() in place of meth->dso_name_converter. NB: This\n     * should normally set using DSO_set_name_converter().\n     */\n    DSO_NAME_CONVERTER_FUNC name_converter;\n    /*\n     * If this callback function pointer is set to non-NULL, then it will be\n     * used in DSO_load() in place of meth->dso_merger. NB: This should\n     * normally set using DSO_set_merger().\n     */\n    DSO_MERGER_FUNC merger;\n    /*\n     * This is populated with (a copy of) the platform-independant filename\n     * used for this DSO.\n     */\n    char *filename;\n    /*\n     * This is populated with (a copy of) the translated filename by which\n     * the DSO was actually loaded. It is NULL iff the DSO is not currently\n     * loaded. NB: This is here because the filename translation process may\n     * involve a callback being invoked more than once not only to convert to\n     * a platform-specific form, but also to try different filenames in the\n     * process of trying to perform a load. As such, this variable can be\n     * used to indicate (a) whether this DSO structure corresponds to a\n     * loaded library or not, and (b) the filename with which it was actually\n     * loaded.\n     */\n    char *loaded_filename;\n};\n\nDSO *DSO_new(void);\nDSO *DSO_new_method(DSO_METHOD *method);\nint DSO_free(DSO *dso);\nint DSO_flags(DSO *dso);\nint DSO_up_ref(DSO *dso);\nlong DSO_ctrl(DSO *dso, int cmd, long larg, void *parg);\n\n/*\n * This function sets the DSO's name_converter callback. If it is non-NULL,\n * then it will be used instead of the associated DSO_METHOD's function. If\n * oldcb is non-NULL then it is set to the function pointer value being\n * replaced. Return value is non-zero for success.\n */\nint DSO_set_name_converter(DSO *dso, DSO_NAME_CONVERTER_FUNC cb,\n                           DSO_NAME_CONVERTER_FUNC *oldcb);\n/*\n * These functions can be used to get/set the platform-independant filename\n * used for a DSO. NB: set will fail if the DSO is already loaded.\n */\nconst char *DSO_get_filename(DSO *dso);\nint DSO_set_filename(DSO *dso, const char *filename);\n/*\n * This function will invoke the DSO's name_converter callback to translate a\n * filename, or if the callback isn't set it will instead use the DSO_METHOD's\n * converter. If \"filename\" is NULL, the \"filename\" in the DSO itself will be\n * used. If the DSO_FLAG_NO_NAME_TRANSLATION flag is set, then the filename is\n * simply duplicated. NB: This function is usually called from within a\n * DSO_METHOD during the processing of a DSO_load() call, and is exposed so\n * that caller-created DSO_METHODs can do the same thing. A non-NULL return\n * value will need to be OPENSSL_free()'d.\n */\nchar *DSO_convert_filename(DSO *dso, const char *filename);\n/*\n * This function will invoke the DSO's merger callback to merge two file\n * specifications, or if the callback isn't set it will instead use the\n * DSO_METHOD's merger.  A non-NULL return value will need to be\n * OPENSSL_free()'d.\n */\nchar *DSO_merge(DSO *dso, const char *filespec1, const char *filespec2);\n/*\n * If the DSO is currently loaded, this returns the filename that it was\n * loaded under, otherwise it returns NULL. So it is also useful as a test as\n * to whether the DSO is currently loaded. NB: This will not necessarily\n * return the same value as DSO_convert_filename(dso, dso->filename), because\n * the DSO_METHOD's load function may have tried a variety of filenames (with\n * and/or without the aid of the converters) before settling on the one it\n * actually loaded.\n */\nconst char *DSO_get_loaded_filename(DSO *dso);\n\nvoid DSO_set_default_method(DSO_METHOD *meth);\nDSO_METHOD *DSO_get_default_method(void);\nDSO_METHOD *DSO_get_method(DSO *dso);\nDSO_METHOD *DSO_set_method(DSO *dso, DSO_METHOD *meth);\n\n/*\n * The all-singing all-dancing load function, you normally pass NULL for the\n * first and third parameters. Use DSO_up and DSO_free for subsequent\n * reference count handling. Any flags passed in will be set in the\n * constructed DSO after its init() function but before the load operation.\n * If 'dso' is non-NULL, 'flags' is ignored.\n */\nDSO *DSO_load(DSO *dso, const char *filename, DSO_METHOD *meth, int flags);\n\n/* This function binds to a variable inside a shared library. */\nvoid *DSO_bind_var(DSO *dso, const char *symname);\n\n/* This function binds to a function inside a shared library. */\nDSO_FUNC_TYPE DSO_bind_func(DSO *dso, const char *symname);\n\n/*\n * This method is the default, but will beg, borrow, or steal whatever method\n * should be the default on any particular platform (including\n * DSO_METH_null() if necessary).\n */\nDSO_METHOD *DSO_METHOD_openssl(void);\n\n/*\n * This method is defined for all platforms - if a platform has no DSO\n * support then this will be the only method!\n */\nDSO_METHOD *DSO_METHOD_null(void);\n\n/*\n * If DSO_DLFCN is defined, the standard dlfcn.h-style functions (dlopen,\n * dlclose, dlsym, etc) will be used and incorporated into this method. If\n * not, this method will return NULL.\n */\nDSO_METHOD *DSO_METHOD_dlfcn(void);\n\n/*\n * If DSO_DL is defined, the standard dl.h-style functions (shl_load,\n * shl_unload, shl_findsym, etc) will be used and incorporated into this\n * method. If not, this method will return NULL.\n */\nDSO_METHOD *DSO_METHOD_dl(void);\n\n/* If WIN32 is defined, use DLLs. If not, return NULL. */\nDSO_METHOD *DSO_METHOD_win32(void);\n\n/* If VMS is defined, use shared images. If not, return NULL. */\nDSO_METHOD *DSO_METHOD_vms(void);\n\n/*\n * This function writes null-terminated pathname of DSO module containing\n * 'addr' into 'sz' large caller-provided 'path' and returns the number of\n * characters [including trailing zero] written to it. If 'sz' is 0 or\n * negative, 'path' is ignored and required amount of charachers [including\n * trailing zero] to accomodate pathname is returned. If 'addr' is NULL, then\n * pathname of cryptolib itself is returned. Negative or zero return value\n * denotes error.\n */\nint DSO_pathbyaddr(void *addr, char *path, int sz);\n\n/*\n * This function should be used with caution! It looks up symbols in *all*\n * loaded modules and if module gets unloaded by somebody else attempt to\n * dereference the pointer is doomed to have fatal consequences. Primary\n * usage for this function is to probe *core* system functionality, e.g.\n * check if getnameinfo(3) is available at run-time without bothering about\n * OS-specific details such as libc.so.versioning or where does it actually\n * reside: in libc itself or libsocket.\n */\nvoid *DSO_global_lookup(const char *name);\n\n/* If BeOS is defined, use shared images. If not, return NULL. */\nDSO_METHOD *DSO_METHOD_beos(void);\n\n/* BEGIN ERROR CODES */\n/*\n * The following lines are auto generated by the script mkerr.pl. Any changes\n * made after this point may be overwritten when the script is next run.\n */\nvoid ERR_load_DSO_strings(void);\n\n/* Error codes for the DSO functions. */\n\n/* Function codes. */\n# define DSO_F_BEOS_BIND_FUNC                             144\n# define DSO_F_BEOS_BIND_VAR                              145\n# define DSO_F_BEOS_LOAD                                  146\n# define DSO_F_BEOS_NAME_CONVERTER                        147\n# define DSO_F_BEOS_UNLOAD                                148\n# define DSO_F_DLFCN_BIND_FUNC                            100\n# define DSO_F_DLFCN_BIND_VAR                             101\n# define DSO_F_DLFCN_LOAD                                 102\n# define DSO_F_DLFCN_MERGER                               130\n# define DSO_F_DLFCN_NAME_CONVERTER                       123\n# define DSO_F_DLFCN_UNLOAD                               103\n# define DSO_F_DL_BIND_FUNC                               104\n# define DSO_F_DL_BIND_VAR                                105\n# define DSO_F_DL_LOAD                                    106\n# define DSO_F_DL_MERGER                                  131\n# define DSO_F_DL_NAME_CONVERTER                          124\n# define DSO_F_DL_UNLOAD                                  107\n# define DSO_F_DSO_BIND_FUNC                              108\n# define DSO_F_DSO_BIND_VAR                               109\n# define DSO_F_DSO_CONVERT_FILENAME                       126\n# define DSO_F_DSO_CTRL                                   110\n# define DSO_F_DSO_FREE                                   111\n# define DSO_F_DSO_GET_FILENAME                           127\n# define DSO_F_DSO_GET_LOADED_FILENAME                    128\n# define DSO_F_DSO_GLOBAL_LOOKUP                          139\n# define DSO_F_DSO_LOAD                                   112\n# define DSO_F_DSO_MERGE                                  132\n# define DSO_F_DSO_NEW_METHOD                             113\n# define DSO_F_DSO_PATHBYADDR                             140\n# define DSO_F_DSO_SET_FILENAME                           129\n# define DSO_F_DSO_SET_NAME_CONVERTER                     122\n# define DSO_F_DSO_UP_REF                                 114\n# define DSO_F_GLOBAL_LOOKUP_FUNC                         138\n# define DSO_F_PATHBYADDR                                 137\n# define DSO_F_VMS_BIND_SYM                               115\n# define DSO_F_VMS_LOAD                                   116\n# define DSO_F_VMS_MERGER                                 133\n# define DSO_F_VMS_UNLOAD                                 117\n# define DSO_F_WIN32_BIND_FUNC                            118\n# define DSO_F_WIN32_BIND_VAR                             119\n# define DSO_F_WIN32_GLOBALLOOKUP                         142\n# define DSO_F_WIN32_GLOBALLOOKUP_FUNC                    143\n# define DSO_F_WIN32_JOINER                               135\n# define DSO_F_WIN32_LOAD                                 120\n# define DSO_F_WIN32_MERGER                               134\n# define DSO_F_WIN32_NAME_CONVERTER                       125\n# define DSO_F_WIN32_PATHBYADDR                           141\n# define DSO_F_WIN32_SPLITTER                             136\n# define DSO_F_WIN32_UNLOAD                               121\n\n/* Reason codes. */\n# define DSO_R_CTRL_FAILED                                100\n# define DSO_R_DSO_ALREADY_LOADED                         110\n# define DSO_R_EMPTY_FILE_STRUCTURE                       113\n# define DSO_R_FAILURE                                    114\n# define DSO_R_FILENAME_TOO_BIG                           101\n# define DSO_R_FINISH_FAILED                              102\n# define DSO_R_INCORRECT_FILE_SYNTAX                      115\n# define DSO_R_LOAD_FAILED                                103\n# define DSO_R_NAME_TRANSLATION_FAILED                    109\n# define DSO_R_NO_FILENAME                                111\n# define DSO_R_NO_FILE_SPECIFICATION                      116\n# define DSO_R_NULL_HANDLE                                104\n# define DSO_R_SET_FILENAME_FAILED                        112\n# define DSO_R_STACK_ERROR                                105\n# define DSO_R_SYM_FAILURE                                106\n# define DSO_R_UNLOAD_FAILED                              107\n# define DSO_R_UNSUPPORTED                                108\n\n#ifdef  __cplusplus\n}\n#endif\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/arm64/include/openssl/dtls1.h",
    "content": "/* ssl/dtls1.h */\n/*\n * DTLS implementation written by Nagendra Modadugu\n * (nagendra@cs.stanford.edu) for the OpenSSL project 2005.\n */\n/* ====================================================================\n * Copyright (c) 1999-2005 The OpenSSL Project.  All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n *\n * 1. Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n *\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in\n *    the documentation and/or other materials provided with the\n *    distribution.\n *\n * 3. All advertising materials mentioning features or use of this\n *    software must display the following acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)\"\n *\n * 4. The names \"OpenSSL Toolkit\" and \"OpenSSL Project\" must not be used to\n *    endorse or promote products derived from this software without\n *    prior written permission. For written permission, please contact\n *    openssl-core@OpenSSL.org.\n *\n * 5. Products derived from this software may not be called \"OpenSSL\"\n *    nor may \"OpenSSL\" appear in their names without prior written\n *    permission of the OpenSSL Project.\n *\n * 6. Redistributions of any form whatsoever must retain the following\n *    acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)\"\n *\n * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY\n * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\n * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR\n * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\n * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,\n * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED\n * OF THE POSSIBILITY OF SUCH DAMAGE.\n * ====================================================================\n *\n * This product includes cryptographic software written by Eric Young\n * (eay@cryptsoft.com).  This product includes software written by Tim\n * Hudson (tjh@cryptsoft.com).\n *\n */\n\n#ifndef HEADER_DTLS1_H\n# define HEADER_DTLS1_H\n\n# include <openssl/buffer.h>\n# include <openssl/pqueue.h>\n# ifdef OPENSSL_SYS_VMS\n#  include <resource.h>\n#  include <sys/timeb.h>\n# endif\n# ifdef OPENSSL_SYS_WIN32\n/* Needed for struct timeval */\n#  include <winsock.h>\n# elif defined(OPENSSL_SYS_NETWARE) && !defined(_WINSOCK2API_)\n#  include <sys/timeval.h>\n# else\n#  if defined(OPENSSL_SYS_VXWORKS)\n#   include <sys/times.h>\n#  else\n#   include <sys/time.h>\n#  endif\n# endif\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n# define DTLS1_VERSION                   0xFEFF\n# define DTLS1_2_VERSION                 0xFEFD\n# define DTLS_MAX_VERSION                DTLS1_2_VERSION\n# define DTLS1_VERSION_MAJOR             0xFE\n\n# define DTLS1_BAD_VER                   0x0100\n\n/* Special value for method supporting multiple versions */\n# define DTLS_ANY_VERSION                0x1FFFF\n\n# if 0\n/* this alert description is not specified anywhere... */\n#  define DTLS1_AD_MISSING_HANDSHAKE_MESSAGE    110\n# endif\n\n/* lengths of messages */\n# define DTLS1_COOKIE_LENGTH                     256\n\n# define DTLS1_RT_HEADER_LENGTH                  13\n\n# define DTLS1_HM_HEADER_LENGTH                  12\n\n# define DTLS1_HM_BAD_FRAGMENT                   -2\n# define DTLS1_HM_FRAGMENT_RETRY                 -3\n\n# define DTLS1_CCS_HEADER_LENGTH                  1\n\n# ifdef DTLS1_AD_MISSING_HANDSHAKE_MESSAGE\n#  define DTLS1_AL_HEADER_LENGTH                   7\n# else\n#  define DTLS1_AL_HEADER_LENGTH                   2\n# endif\n\n# ifndef OPENSSL_NO_SSL_INTERN\n\n#  ifndef OPENSSL_NO_SCTP\n#   define DTLS1_SCTP_AUTH_LABEL   \"EXPORTER_DTLS_OVER_SCTP\"\n#  endif\n\n/* Max MTU overhead we know about so far is 40 for IPv6 + 8 for UDP */\n#  define DTLS1_MAX_MTU_OVERHEAD                   48\n\ntypedef struct dtls1_bitmap_st {\n    unsigned long map;          /* track 32 packets on 32-bit systems and 64\n                                 * - on 64-bit systems */\n    unsigned char max_seq_num[8]; /* max record number seen so far, 64-bit\n                                   * value in big-endian encoding */\n} DTLS1_BITMAP;\n\nstruct dtls1_retransmit_state {\n    EVP_CIPHER_CTX *enc_write_ctx; /* cryptographic state */\n    EVP_MD_CTX *write_hash;     /* used for mac generation */\n#  ifndef OPENSSL_NO_COMP\n    COMP_CTX *compress;         /* compression */\n#  else\n    char *compress;\n#  endif\n    SSL_SESSION *session;\n    unsigned short epoch;\n};\n\nstruct hm_header_st {\n    unsigned char type;\n    unsigned long msg_len;\n    unsigned short seq;\n    unsigned long frag_off;\n    unsigned long frag_len;\n    unsigned int is_ccs;\n    struct dtls1_retransmit_state saved_retransmit_state;\n};\n\nstruct ccs_header_st {\n    unsigned char type;\n    unsigned short seq;\n};\n\nstruct dtls1_timeout_st {\n    /* Number of read timeouts so far */\n    unsigned int read_timeouts;\n    /* Number of write timeouts so far */\n    unsigned int write_timeouts;\n    /* Number of alerts received so far */\n    unsigned int num_alerts;\n};\n\ntypedef struct record_pqueue_st {\n    unsigned short epoch;\n    pqueue q;\n} record_pqueue;\n\ntypedef struct hm_fragment_st {\n    struct hm_header_st msg_header;\n    unsigned char *fragment;\n    unsigned char *reassembly;\n} hm_fragment;\n\ntypedef struct dtls1_state_st {\n    unsigned int send_cookie;\n    unsigned char cookie[DTLS1_COOKIE_LENGTH];\n    unsigned char rcvd_cookie[DTLS1_COOKIE_LENGTH];\n    unsigned int cookie_len;\n    /*\n     * The current data and handshake epoch.  This is initially\n     * undefined, and starts at zero once the initial handshake is\n     * completed\n     */\n    unsigned short r_epoch;\n    unsigned short w_epoch;\n    /* records being received in the current epoch */\n    DTLS1_BITMAP bitmap;\n    /* renegotiation starts a new set of sequence numbers */\n    DTLS1_BITMAP next_bitmap;\n    /* handshake message numbers */\n    unsigned short handshake_write_seq;\n    unsigned short next_handshake_write_seq;\n    unsigned short handshake_read_seq;\n    /* save last sequence number for retransmissions */\n    unsigned char last_write_sequence[8];\n    /* Received handshake records (processed and unprocessed) */\n    record_pqueue unprocessed_rcds;\n    record_pqueue processed_rcds;\n    /* Buffered handshake messages */\n    pqueue buffered_messages;\n    /* Buffered (sent) handshake records */\n    pqueue sent_messages;\n    /*\n     * Buffered application records. Only for records between CCS and\n     * Finished to prevent either protocol violation or unnecessary message\n     * loss.\n     */\n    record_pqueue buffered_app_data;\n    /* Is set when listening for new connections with dtls1_listen() */\n    unsigned int listen;\n    unsigned int link_mtu;      /* max on-the-wire DTLS packet size */\n    unsigned int mtu;           /* max DTLS packet size */\n    struct hm_header_st w_msg_hdr;\n    struct hm_header_st r_msg_hdr;\n    struct dtls1_timeout_st timeout;\n    /*\n     * Indicates when the last handshake msg or heartbeat sent will timeout\n     */\n    struct timeval next_timeout;\n    /* Timeout duration */\n    unsigned short timeout_duration;\n    /*\n     * storage for Alert/Handshake protocol data received but not yet\n     * processed by ssl3_read_bytes:\n     */\n    unsigned char alert_fragment[DTLS1_AL_HEADER_LENGTH];\n    unsigned int alert_fragment_len;\n    unsigned char handshake_fragment[DTLS1_HM_HEADER_LENGTH];\n    unsigned int handshake_fragment_len;\n    unsigned int retransmitting;\n    /*\n     * Set when the handshake is ready to process peer's ChangeCipherSpec message.\n     * Cleared after the message has been processed.\n     */\n    unsigned int change_cipher_spec_ok;\n#  ifndef OPENSSL_NO_SCTP\n    /* used when SSL_ST_XX_FLUSH is entered */\n    int next_state;\n    int shutdown_received;\n#  endif\n} DTLS1_STATE;\n\ntypedef struct dtls1_record_data_st {\n    unsigned char *packet;\n    unsigned int packet_length;\n    SSL3_BUFFER rbuf;\n    SSL3_RECORD rrec;\n#  ifndef OPENSSL_NO_SCTP\n    struct bio_dgram_sctp_rcvinfo recordinfo;\n#  endif\n} DTLS1_RECORD_DATA;\n\n# endif\n\n/* Timeout multipliers (timeout slice is defined in apps/timeouts.h */\n# define DTLS1_TMO_READ_COUNT                      2\n# define DTLS1_TMO_WRITE_COUNT                     2\n\n# define DTLS1_TMO_ALERT_COUNT                     12\n\n#ifdef  __cplusplus\n}\n#endif\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/arm64/include/openssl/e_os2.h",
    "content": "/* e_os2.h */\n/* ====================================================================\n * Copyright (c) 1998-2000 The OpenSSL Project.  All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n *\n * 1. Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n *\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in\n *    the documentation and/or other materials provided with the\n *    distribution.\n *\n * 3. All advertising materials mentioning features or use of this\n *    software must display the following acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit. (http://www.openssl.org/)\"\n *\n * 4. The names \"OpenSSL Toolkit\" and \"OpenSSL Project\" must not be used to\n *    endorse or promote products derived from this software without\n *    prior written permission. For written permission, please contact\n *    openssl-core@openssl.org.\n *\n * 5. Products derived from this software may not be called \"OpenSSL\"\n *    nor may \"OpenSSL\" appear in their names without prior written\n *    permission of the OpenSSL Project.\n *\n * 6. Redistributions of any form whatsoever must retain the following\n *    acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit (http://www.openssl.org/)\"\n *\n * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY\n * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\n * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR\n * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\n * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,\n * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED\n * OF THE POSSIBILITY OF SUCH DAMAGE.\n * ====================================================================\n *\n * This product includes cryptographic software written by Eric Young\n * (eay@cryptsoft.com).  This product includes software written by Tim\n * Hudson (tjh@cryptsoft.com).\n *\n */\n\n#include <openssl/opensslconf.h>\n\n#ifndef HEADER_E_OS2_H\n# define HEADER_E_OS2_H\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n/******************************************************************************\n * Detect operating systems.  This probably needs completing.\n * The result is that at least one OPENSSL_SYS_os macro should be defined.\n * However, if none is defined, Unix is assumed.\n **/\n\n# define OPENSSL_SYS_UNIX\n\n/* ---------------------- Macintosh, before MacOS X ----------------------- */\n# if defined(__MWERKS__) && defined(macintosh) || defined(OPENSSL_SYSNAME_MAC)\n#  undef OPENSSL_SYS_UNIX\n#  define OPENSSL_SYS_MACINTOSH_CLASSIC\n# endif\n\n/* ---------------------- NetWare ----------------------------------------- */\n# if defined(NETWARE) || defined(OPENSSL_SYSNAME_NETWARE)\n#  undef OPENSSL_SYS_UNIX\n#  define OPENSSL_SYS_NETWARE\n# endif\n\n/* --------------------- Microsoft operating systems ---------------------- */\n\n/*\n * Note that MSDOS actually denotes 32-bit environments running on top of\n * MS-DOS, such as DJGPP one.\n */\n# if defined(OPENSSL_SYSNAME_MSDOS)\n#  undef OPENSSL_SYS_UNIX\n#  define OPENSSL_SYS_MSDOS\n# endif\n\n/*\n * For 32 bit environment, there seems to be the CygWin environment and then\n * all the others that try to do the same thing Microsoft does...\n */\n# if defined(OPENSSL_SYSNAME_UWIN)\n#  undef OPENSSL_SYS_UNIX\n#  define OPENSSL_SYS_WIN32_UWIN\n# else\n#  if defined(__CYGWIN__) || defined(OPENSSL_SYSNAME_CYGWIN)\n#   undef OPENSSL_SYS_UNIX\n#   define OPENSSL_SYS_WIN32_CYGWIN\n#  else\n#   if defined(_WIN32) || defined(OPENSSL_SYSNAME_WIN32)\n#    undef OPENSSL_SYS_UNIX\n#    define OPENSSL_SYS_WIN32\n#   endif\n#   if defined(_WIN64) || defined(OPENSSL_SYSNAME_WIN64)\n#    undef OPENSSL_SYS_UNIX\n#    if !defined(OPENSSL_SYS_WIN64)\n#     define OPENSSL_SYS_WIN64\n#    endif\n#   endif\n#   if defined(OPENSSL_SYSNAME_WINNT)\n#    undef OPENSSL_SYS_UNIX\n#    define OPENSSL_SYS_WINNT\n#   endif\n#   if defined(OPENSSL_SYSNAME_WINCE)\n#    undef OPENSSL_SYS_UNIX\n#    define OPENSSL_SYS_WINCE\n#   endif\n#  endif\n# endif\n\n/* Anything that tries to look like Microsoft is \"Windows\" */\n# if defined(OPENSSL_SYS_WIN32) || defined(OPENSSL_SYS_WIN64) || defined(OPENSSL_SYS_WINNT) || defined(OPENSSL_SYS_WINCE)\n#  undef OPENSSL_SYS_UNIX\n#  define OPENSSL_SYS_WINDOWS\n#  ifndef OPENSSL_SYS_MSDOS\n#   define OPENSSL_SYS_MSDOS\n#  endif\n# endif\n\n/*\n * DLL settings.  This part is a bit tough, because it's up to the\n * application implementor how he or she will link the application, so it\n * requires some macro to be used.\n */\n# ifdef OPENSSL_SYS_WINDOWS\n#  ifndef OPENSSL_OPT_WINDLL\n#   if defined(_WINDLL)         /* This is used when building OpenSSL to\n                                 * indicate that DLL linkage should be used */\n#    define OPENSSL_OPT_WINDLL\n#   endif\n#  endif\n# endif\n\n/* ------------------------------- OpenVMS -------------------------------- */\n# if defined(__VMS) || defined(VMS) || defined(OPENSSL_SYSNAME_VMS)\n#  undef OPENSSL_SYS_UNIX\n#  define OPENSSL_SYS_VMS\n#  if defined(__DECC)\n#   define OPENSSL_SYS_VMS_DECC\n#  elif defined(__DECCXX)\n#   define OPENSSL_SYS_VMS_DECC\n#   define OPENSSL_SYS_VMS_DECCXX\n#  else\n#   define OPENSSL_SYS_VMS_NODECC\n#  endif\n# endif\n\n/* -------------------------------- OS/2 ---------------------------------- */\n# if defined(__EMX__) || defined(__OS2__)\n#  undef OPENSSL_SYS_UNIX\n#  define OPENSSL_SYS_OS2\n# endif\n\n/* -------------------------------- Unix ---------------------------------- */\n# ifdef OPENSSL_SYS_UNIX\n#  if defined(linux) || defined(__linux__) || defined(OPENSSL_SYSNAME_LINUX)\n#   define OPENSSL_SYS_LINUX\n#  endif\n#  ifdef OPENSSL_SYSNAME_MPE\n#   define OPENSSL_SYS_MPE\n#  endif\n#  ifdef OPENSSL_SYSNAME_SNI\n#   define OPENSSL_SYS_SNI\n#  endif\n#  ifdef OPENSSL_SYSNAME_ULTRASPARC\n#   define OPENSSL_SYS_ULTRASPARC\n#  endif\n#  ifdef OPENSSL_SYSNAME_NEWS4\n#   define OPENSSL_SYS_NEWS4\n#  endif\n#  ifdef OPENSSL_SYSNAME_MACOSX\n#   define OPENSSL_SYS_MACOSX\n#  endif\n#  ifdef OPENSSL_SYSNAME_MACOSX_RHAPSODY\n#   define OPENSSL_SYS_MACOSX_RHAPSODY\n#   define OPENSSL_SYS_MACOSX\n#  endif\n#  ifdef OPENSSL_SYSNAME_SUNOS\n#   define OPENSSL_SYS_SUNOS\n#  endif\n#  if defined(_CRAY) || defined(OPENSSL_SYSNAME_CRAY)\n#   define OPENSSL_SYS_CRAY\n#  endif\n#  if defined(_AIX) || defined(OPENSSL_SYSNAME_AIX)\n#   define OPENSSL_SYS_AIX\n#  endif\n# endif\n\n/* -------------------------------- VOS ----------------------------------- */\n# if defined(__VOS__) || defined(OPENSSL_SYSNAME_VOS)\n#  define OPENSSL_SYS_VOS\n#  ifdef __HPPA__\n#   define OPENSSL_SYS_VOS_HPPA\n#  endif\n#  ifdef __IA32__\n#   define OPENSSL_SYS_VOS_IA32\n#  endif\n# endif\n\n/* ------------------------------ VxWorks --------------------------------- */\n# ifdef OPENSSL_SYSNAME_VXWORKS\n#  define OPENSSL_SYS_VXWORKS\n# endif\n\n/* -------------------------------- BeOS ---------------------------------- */\n# if defined(__BEOS__)\n#  define OPENSSL_SYS_BEOS\n#  include <sys/socket.h>\n#  if defined(BONE_VERSION)\n#   define OPENSSL_SYS_BEOS_BONE\n#  else\n#   define OPENSSL_SYS_BEOS_R5\n#  endif\n# endif\n\n/**\n * That's it for OS-specific stuff\n *****************************************************************************/\n\n/* Specials for I/O an exit */\n# ifdef OPENSSL_SYS_MSDOS\n#  define OPENSSL_UNISTD_IO <io.h>\n#  define OPENSSL_DECLARE_EXIT extern void exit(int);\n# else\n#  define OPENSSL_UNISTD_IO OPENSSL_UNISTD\n#  define OPENSSL_DECLARE_EXIT  /* declared in unistd.h */\n# endif\n\n/*-\n * Definitions of OPENSSL_GLOBAL and OPENSSL_EXTERN, to define and declare\n * certain global symbols that, with some compilers under VMS, have to be\n * defined and declared explicitely with globaldef and globalref.\n * Definitions of OPENSSL_EXPORT and OPENSSL_IMPORT, to define and declare\n * DLL exports and imports for compilers under Win32.  These are a little\n * more complicated to use.  Basically, for any library that exports some\n * global variables, the following code must be present in the header file\n * that declares them, before OPENSSL_EXTERN is used:\n *\n * #ifdef SOME_BUILD_FLAG_MACRO\n * # undef OPENSSL_EXTERN\n * # define OPENSSL_EXTERN OPENSSL_EXPORT\n * #endif\n *\n * The default is to have OPENSSL_EXPORT, OPENSSL_IMPORT and OPENSSL_GLOBAL\n * have some generally sensible values, and for OPENSSL_EXTERN to have the\n * value OPENSSL_IMPORT.\n */\n\n# if defined(OPENSSL_SYS_VMS_NODECC)\n#  define OPENSSL_EXPORT globalref\n#  define OPENSSL_IMPORT globalref\n#  define OPENSSL_GLOBAL globaldef\n# elif defined(OPENSSL_SYS_WINDOWS) && defined(OPENSSL_OPT_WINDLL)\n#  define OPENSSL_EXPORT extern __declspec(dllexport)\n#  define OPENSSL_IMPORT extern __declspec(dllimport)\n#  define OPENSSL_GLOBAL\n# else\n#  define OPENSSL_EXPORT extern\n#  define OPENSSL_IMPORT extern\n#  define OPENSSL_GLOBAL\n# endif\n# define OPENSSL_EXTERN OPENSSL_IMPORT\n\n/*-\n * Macros to allow global variables to be reached through function calls when\n * required (if a shared library version requires it, for example.\n * The way it's done allows definitions like this:\n *\n *      // in foobar.c\n *      OPENSSL_IMPLEMENT_GLOBAL(int,foobar,0)\n *      // in foobar.h\n *      OPENSSL_DECLARE_GLOBAL(int,foobar);\n *      #define foobar OPENSSL_GLOBAL_REF(foobar)\n */\n# ifdef OPENSSL_EXPORT_VAR_AS_FUNCTION\n#  define OPENSSL_IMPLEMENT_GLOBAL(type,name,value)                      \\\n        type *_shadow_##name(void)                                      \\\n        { static type _hide_##name=value; return &_hide_##name; }\n#  define OPENSSL_DECLARE_GLOBAL(type,name) type *_shadow_##name(void)\n#  define OPENSSL_GLOBAL_REF(name) (*(_shadow_##name()))\n# else\n#  define OPENSSL_IMPLEMENT_GLOBAL(type,name,value) OPENSSL_GLOBAL type _shadow_##name=value;\n#  define OPENSSL_DECLARE_GLOBAL(type,name) OPENSSL_EXPORT type _shadow_##name\n#  define OPENSSL_GLOBAL_REF(name) _shadow_##name\n# endif\n\n# if defined(OPENSSL_SYS_MACINTOSH_CLASSIC) && macintosh==1 && !defined(MAC_OS_GUSI_SOURCE)\n#  define ossl_ssize_t long\n# endif\n\n# ifdef OPENSSL_SYS_MSDOS\n#  define ossl_ssize_t long\n# endif\n\n# if defined(NeXT) || defined(OPENSSL_SYS_NEWS4) || defined(OPENSSL_SYS_SUNOS)\n#  define ssize_t int\n# endif\n\n# if defined(__ultrix) && !defined(ssize_t)\n#  define ossl_ssize_t int\n# endif\n\n# ifndef ossl_ssize_t\n#  define ossl_ssize_t ssize_t\n# endif\n\n#ifdef  __cplusplus\n}\n#endif\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/arm64/include/openssl/ebcdic.h",
    "content": "/* crypto/ebcdic.h */\n\n#ifndef HEADER_EBCDIC_H\n# define HEADER_EBCDIC_H\n\n# include <sys/types.h>\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n/* Avoid name clashes with other applications */\n# define os_toascii   _openssl_os_toascii\n# define os_toebcdic  _openssl_os_toebcdic\n# define ebcdic2ascii _openssl_ebcdic2ascii\n# define ascii2ebcdic _openssl_ascii2ebcdic\n\nextern const unsigned char os_toascii[256];\nextern const unsigned char os_toebcdic[256];\nvoid *ebcdic2ascii(void *dest, const void *srce, size_t count);\nvoid *ascii2ebcdic(void *dest, const void *srce, size_t count);\n\n#ifdef  __cplusplus\n}\n#endif\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/arm64/include/openssl/ec.h",
    "content": "/* crypto/ec/ec.h */\n/*\n * Originally written by Bodo Moeller for the OpenSSL project.\n */\n/**\n * \\file crypto/ec/ec.h Include file for the OpenSSL EC functions\n * \\author Originally written by Bodo Moeller for the OpenSSL project\n */\n/* ====================================================================\n * Copyright (c) 1998-2005 The OpenSSL Project.  All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n *\n * 1. Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n *\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in\n *    the documentation and/or other materials provided with the\n *    distribution.\n *\n * 3. All advertising materials mentioning features or use of this\n *    software must display the following acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit. (http://www.openssl.org/)\"\n *\n * 4. The names \"OpenSSL Toolkit\" and \"OpenSSL Project\" must not be used to\n *    endorse or promote products derived from this software without\n *    prior written permission. For written permission, please contact\n *    openssl-core@openssl.org.\n *\n * 5. Products derived from this software may not be called \"OpenSSL\"\n *    nor may \"OpenSSL\" appear in their names without prior written\n *    permission of the OpenSSL Project.\n *\n * 6. Redistributions of any form whatsoever must retain the following\n *    acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit (http://www.openssl.org/)\"\n *\n * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY\n * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\n * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR\n * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\n * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,\n * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED\n * OF THE POSSIBILITY OF SUCH DAMAGE.\n * ====================================================================\n *\n * This product includes cryptographic software written by Eric Young\n * (eay@cryptsoft.com).  This product includes software written by Tim\n * Hudson (tjh@cryptsoft.com).\n *\n */\n/* ====================================================================\n * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED.\n *\n * Portions of the attached software (\"Contribution\") are developed by\n * SUN MICROSYSTEMS, INC., and are contributed to the OpenSSL project.\n *\n * The Contribution is licensed pursuant to the OpenSSL open source\n * license provided above.\n *\n * The elliptic curve binary polynomial software is originally written by\n * Sheueling Chang Shantz and Douglas Stebila of Sun Microsystems Laboratories.\n *\n */\n\n#ifndef HEADER_EC_H\n# define HEADER_EC_H\n\n# include <openssl/opensslconf.h>\n\n# ifdef OPENSSL_NO_EC\n#  error EC is disabled.\n# endif\n\n# include <openssl/asn1.h>\n# include <openssl/symhacks.h>\n# ifndef OPENSSL_NO_DEPRECATED\n#  include <openssl/bn.h>\n# endif\n\n# ifdef  __cplusplus\nextern \"C\" {\n# elif defined(__SUNPRO_C)\n#  if __SUNPRO_C >= 0x520\n#   pragma error_messages (off,E_ARRAY_OF_INCOMPLETE_NONAME,E_ARRAY_OF_INCOMPLETE)\n#  endif\n# endif\n\n# ifndef OPENSSL_ECC_MAX_FIELD_BITS\n#  define OPENSSL_ECC_MAX_FIELD_BITS 661\n# endif\n\n/** Enum for the point conversion form as defined in X9.62 (ECDSA)\n *  for the encoding of a elliptic curve point (x,y) */\ntypedef enum {\n        /** the point is encoded as z||x, where the octet z specifies\n         *  which solution of the quadratic equation y is  */\n    POINT_CONVERSION_COMPRESSED = 2,\n        /** the point is encoded as z||x||y, where z is the octet 0x04  */\n    POINT_CONVERSION_UNCOMPRESSED = 4,\n        /** the point is encoded as z||x||y, where the octet z specifies\n         *  which solution of the quadratic equation y is  */\n    POINT_CONVERSION_HYBRID = 6\n} point_conversion_form_t;\n\ntypedef struct ec_method_st EC_METHOD;\n\ntypedef struct ec_group_st\n    /*-\n     EC_METHOD *meth;\n     -- field definition\n     -- curve coefficients\n     -- optional generator with associated information (order, cofactor)\n     -- optional extra data (precomputed table for fast computation of multiples of generator)\n     -- ASN1 stuff\n    */\n    EC_GROUP;\n\ntypedef struct ec_point_st EC_POINT;\n\n/********************************************************************/\n/*               EC_METHODs for curves over GF(p)                   */\n/********************************************************************/\n\n/** Returns the basic GFp ec methods which provides the basis for the\n *  optimized methods.\n *  \\return  EC_METHOD object\n */\nconst EC_METHOD *EC_GFp_simple_method(void);\n\n/** Returns GFp methods using montgomery multiplication.\n *  \\return  EC_METHOD object\n */\nconst EC_METHOD *EC_GFp_mont_method(void);\n\n/** Returns GFp methods using optimized methods for NIST recommended curves\n *  \\return  EC_METHOD object\n */\nconst EC_METHOD *EC_GFp_nist_method(void);\n\n# ifndef OPENSSL_NO_EC_NISTP_64_GCC_128\n/** Returns 64-bit optimized methods for nistp224\n *  \\return  EC_METHOD object\n */\nconst EC_METHOD *EC_GFp_nistp224_method(void);\n\n/** Returns 64-bit optimized methods for nistp256\n *  \\return  EC_METHOD object\n */\nconst EC_METHOD *EC_GFp_nistp256_method(void);\n\n/** Returns 64-bit optimized methods for nistp521\n *  \\return  EC_METHOD object\n */\nconst EC_METHOD *EC_GFp_nistp521_method(void);\n# endif\n\n# ifndef OPENSSL_NO_EC2M\n/********************************************************************/\n/*           EC_METHOD for curves over GF(2^m)                      */\n/********************************************************************/\n\n/** Returns the basic GF2m ec method\n *  \\return  EC_METHOD object\n */\nconst EC_METHOD *EC_GF2m_simple_method(void);\n\n# endif\n\n/********************************************************************/\n/*                   EC_GROUP functions                             */\n/********************************************************************/\n\n/** Creates a new EC_GROUP object\n *  \\param   meth  EC_METHOD to use\n *  \\return  newly created EC_GROUP object or NULL in case of an error.\n */\nEC_GROUP *EC_GROUP_new(const EC_METHOD *meth);\n\n/** Frees a EC_GROUP object\n *  \\param  group  EC_GROUP object to be freed.\n */\nvoid EC_GROUP_free(EC_GROUP *group);\n\n/** Clears and frees a EC_GROUP object\n *  \\param  group  EC_GROUP object to be cleared and freed.\n */\nvoid EC_GROUP_clear_free(EC_GROUP *group);\n\n/** Copies EC_GROUP objects. Note: both EC_GROUPs must use the same EC_METHOD.\n *  \\param  dst  destination EC_GROUP object\n *  \\param  src  source EC_GROUP object\n *  \\return 1 on success and 0 if an error occurred.\n */\nint EC_GROUP_copy(EC_GROUP *dst, const EC_GROUP *src);\n\n/** Creates a new EC_GROUP object and copies the copies the content\n *  form src to the newly created EC_KEY object\n *  \\param  src  source EC_GROUP object\n *  \\return newly created EC_GROUP object or NULL in case of an error.\n */\nEC_GROUP *EC_GROUP_dup(const EC_GROUP *src);\n\n/** Returns the EC_METHOD of the EC_GROUP object.\n *  \\param  group  EC_GROUP object\n *  \\return EC_METHOD used in this EC_GROUP object.\n */\nconst EC_METHOD *EC_GROUP_method_of(const EC_GROUP *group);\n\n/** Returns the field type of the EC_METHOD.\n *  \\param  meth  EC_METHOD object\n *  \\return NID of the underlying field type OID.\n */\nint EC_METHOD_get_field_type(const EC_METHOD *meth);\n\n/** Sets the generator and it's order/cofactor of a EC_GROUP object.\n *  \\param  group      EC_GROUP object\n *  \\param  generator  EC_POINT object with the generator.\n *  \\param  order      the order of the group generated by the generator.\n *  \\param  cofactor   the index of the sub-group generated by the generator\n *                     in the group of all points on the elliptic curve.\n *  \\return 1 on success and 0 if an error occured\n */\nint EC_GROUP_set_generator(EC_GROUP *group, const EC_POINT *generator,\n                           const BIGNUM *order, const BIGNUM *cofactor);\n\n/** Returns the generator of a EC_GROUP object.\n *  \\param  group  EC_GROUP object\n *  \\return the currently used generator (possibly NULL).\n */\nconst EC_POINT *EC_GROUP_get0_generator(const EC_GROUP *group);\n\n/** Returns the montgomery data for order(Generator)\n *  \\param  group  EC_GROUP object\n *  \\return the currently used generator (possibly NULL).\n*/\nBN_MONT_CTX *EC_GROUP_get_mont_data(const EC_GROUP *group);\n\n/** Gets the order of a EC_GROUP\n *  \\param  group  EC_GROUP object\n *  \\param  order  BIGNUM to which the order is copied\n *  \\param  ctx    BN_CTX object (optional)\n *  \\return 1 on success and 0 if an error occured\n */\nint EC_GROUP_get_order(const EC_GROUP *group, BIGNUM *order, BN_CTX *ctx);\n\n/** Gets the cofactor of a EC_GROUP\n *  \\param  group     EC_GROUP object\n *  \\param  cofactor  BIGNUM to which the cofactor is copied\n *  \\param  ctx       BN_CTX object (optional)\n *  \\return 1 on success and 0 if an error occured\n */\nint EC_GROUP_get_cofactor(const EC_GROUP *group, BIGNUM *cofactor,\n                          BN_CTX *ctx);\n\n/** Sets the name of a EC_GROUP object\n *  \\param  group  EC_GROUP object\n *  \\param  nid    NID of the curve name OID\n */\nvoid EC_GROUP_set_curve_name(EC_GROUP *group, int nid);\n\n/** Returns the curve name of a EC_GROUP object\n *  \\param  group  EC_GROUP object\n *  \\return NID of the curve name OID or 0 if not set.\n */\nint EC_GROUP_get_curve_name(const EC_GROUP *group);\n\nvoid EC_GROUP_set_asn1_flag(EC_GROUP *group, int flag);\nint EC_GROUP_get_asn1_flag(const EC_GROUP *group);\n\nvoid EC_GROUP_set_point_conversion_form(EC_GROUP *group,\n                                        point_conversion_form_t form);\npoint_conversion_form_t EC_GROUP_get_point_conversion_form(const EC_GROUP *);\n\nunsigned char *EC_GROUP_get0_seed(const EC_GROUP *x);\nsize_t EC_GROUP_get_seed_len(const EC_GROUP *);\nsize_t EC_GROUP_set_seed(EC_GROUP *, const unsigned char *, size_t len);\n\n/** Sets the parameter of a ec over GFp defined by y^2 = x^3 + a*x + b\n *  \\param  group  EC_GROUP object\n *  \\param  p      BIGNUM with the prime number\n *  \\param  a      BIGNUM with parameter a of the equation\n *  \\param  b      BIGNUM with parameter b of the equation\n *  \\param  ctx    BN_CTX object (optional)\n *  \\return 1 on success and 0 if an error occured\n */\nint EC_GROUP_set_curve_GFp(EC_GROUP *group, const BIGNUM *p, const BIGNUM *a,\n                           const BIGNUM *b, BN_CTX *ctx);\n\n/** Gets the parameter of the ec over GFp defined by y^2 = x^3 + a*x + b\n *  \\param  group  EC_GROUP object\n *  \\param  p      BIGNUM for the prime number\n *  \\param  a      BIGNUM for parameter a of the equation\n *  \\param  b      BIGNUM for parameter b of the equation\n *  \\param  ctx    BN_CTX object (optional)\n *  \\return 1 on success and 0 if an error occured\n */\nint EC_GROUP_get_curve_GFp(const EC_GROUP *group, BIGNUM *p, BIGNUM *a,\n                           BIGNUM *b, BN_CTX *ctx);\n\n# ifndef OPENSSL_NO_EC2M\n/** Sets the parameter of a ec over GF2m defined by y^2 + x*y = x^3 + a*x^2 + b\n *  \\param  group  EC_GROUP object\n *  \\param  p      BIGNUM with the polynomial defining the underlying field\n *  \\param  a      BIGNUM with parameter a of the equation\n *  \\param  b      BIGNUM with parameter b of the equation\n *  \\param  ctx    BN_CTX object (optional)\n *  \\return 1 on success and 0 if an error occured\n */\nint EC_GROUP_set_curve_GF2m(EC_GROUP *group, const BIGNUM *p, const BIGNUM *a,\n                            const BIGNUM *b, BN_CTX *ctx);\n\n/** Gets the parameter of the ec over GF2m defined by y^2 + x*y = x^3 + a*x^2 + b\n *  \\param  group  EC_GROUP object\n *  \\param  p      BIGNUM for the polynomial defining the underlying field\n *  \\param  a      BIGNUM for parameter a of the equation\n *  \\param  b      BIGNUM for parameter b of the equation\n *  \\param  ctx    BN_CTX object (optional)\n *  \\return 1 on success and 0 if an error occured\n */\nint EC_GROUP_get_curve_GF2m(const EC_GROUP *group, BIGNUM *p, BIGNUM *a,\n                            BIGNUM *b, BN_CTX *ctx);\n# endif\n/** Returns the number of bits needed to represent a field element\n *  \\param  group  EC_GROUP object\n *  \\return number of bits needed to represent a field element\n */\nint EC_GROUP_get_degree(const EC_GROUP *group);\n\n/** Checks whether the parameter in the EC_GROUP define a valid ec group\n *  \\param  group  EC_GROUP object\n *  \\param  ctx    BN_CTX object (optional)\n *  \\return 1 if group is a valid ec group and 0 otherwise\n */\nint EC_GROUP_check(const EC_GROUP *group, BN_CTX *ctx);\n\n/** Checks whether the discriminant of the elliptic curve is zero or not\n *  \\param  group  EC_GROUP object\n *  \\param  ctx    BN_CTX object (optional)\n *  \\return 1 if the discriminant is not zero and 0 otherwise\n */\nint EC_GROUP_check_discriminant(const EC_GROUP *group, BN_CTX *ctx);\n\n/** Compares two EC_GROUP objects\n *  \\param  a    first EC_GROUP object\n *  \\param  b    second EC_GROUP object\n *  \\param  ctx  BN_CTX object (optional)\n *  \\return 0 if both groups are equal and 1 otherwise\n */\nint EC_GROUP_cmp(const EC_GROUP *a, const EC_GROUP *b, BN_CTX *ctx);\n\n/*\n * EC_GROUP_new_GF*() calls EC_GROUP_new() and EC_GROUP_set_GF*() after\n * choosing an appropriate EC_METHOD\n */\n\n/** Creates a new EC_GROUP object with the specified parameters defined\n *  over GFp (defined by the equation y^2 = x^3 + a*x + b)\n *  \\param  p    BIGNUM with the prime number\n *  \\param  a    BIGNUM with the parameter a of the equation\n *  \\param  b    BIGNUM with the parameter b of the equation\n *  \\param  ctx  BN_CTX object (optional)\n *  \\return newly created EC_GROUP object with the specified parameters\n */\nEC_GROUP *EC_GROUP_new_curve_GFp(const BIGNUM *p, const BIGNUM *a,\n                                 const BIGNUM *b, BN_CTX *ctx);\n# ifndef OPENSSL_NO_EC2M\n/** Creates a new EC_GROUP object with the specified parameters defined\n *  over GF2m (defined by the equation y^2 + x*y = x^3 + a*x^2 + b)\n *  \\param  p    BIGNUM with the polynomial defining the underlying field\n *  \\param  a    BIGNUM with the parameter a of the equation\n *  \\param  b    BIGNUM with the parameter b of the equation\n *  \\param  ctx  BN_CTX object (optional)\n *  \\return newly created EC_GROUP object with the specified parameters\n */\nEC_GROUP *EC_GROUP_new_curve_GF2m(const BIGNUM *p, const BIGNUM *a,\n                                  const BIGNUM *b, BN_CTX *ctx);\n# endif\n/** Creates a EC_GROUP object with a curve specified by a NID\n *  \\param  nid  NID of the OID of the curve name\n *  \\return newly created EC_GROUP object with specified curve or NULL\n *          if an error occurred\n */\nEC_GROUP *EC_GROUP_new_by_curve_name(int nid);\n\n/********************************************************************/\n/*               handling of internal curves                        */\n/********************************************************************/\n\ntypedef struct {\n    int nid;\n    const char *comment;\n} EC_builtin_curve;\n\n/*\n * EC_builtin_curves(EC_builtin_curve *r, size_t size) returns number of all\n * available curves or zero if a error occurred. In case r ist not zero\n * nitems EC_builtin_curve structures are filled with the data of the first\n * nitems internal groups\n */\nsize_t EC_get_builtin_curves(EC_builtin_curve *r, size_t nitems);\n\nconst char *EC_curve_nid2nist(int nid);\nint EC_curve_nist2nid(const char *name);\n\n/********************************************************************/\n/*                    EC_POINT functions                            */\n/********************************************************************/\n\n/** Creates a new EC_POINT object for the specified EC_GROUP\n *  \\param  group  EC_GROUP the underlying EC_GROUP object\n *  \\return newly created EC_POINT object or NULL if an error occurred\n */\nEC_POINT *EC_POINT_new(const EC_GROUP *group);\n\n/** Frees a EC_POINT object\n *  \\param  point  EC_POINT object to be freed\n */\nvoid EC_POINT_free(EC_POINT *point);\n\n/** Clears and frees a EC_POINT object\n *  \\param  point  EC_POINT object to be cleared and freed\n */\nvoid EC_POINT_clear_free(EC_POINT *point);\n\n/** Copies EC_POINT object\n *  \\param  dst  destination EC_POINT object\n *  \\param  src  source EC_POINT object\n *  \\return 1 on success and 0 if an error occured\n */\nint EC_POINT_copy(EC_POINT *dst, const EC_POINT *src);\n\n/** Creates a new EC_POINT object and copies the content of the supplied\n *  EC_POINT\n *  \\param  src    source EC_POINT object\n *  \\param  group  underlying the EC_GROUP object\n *  \\return newly created EC_POINT object or NULL if an error occurred\n */\nEC_POINT *EC_POINT_dup(const EC_POINT *src, const EC_GROUP *group);\n\n/** Returns the EC_METHOD used in EC_POINT object\n *  \\param  point  EC_POINT object\n *  \\return the EC_METHOD used\n */\nconst EC_METHOD *EC_POINT_method_of(const EC_POINT *point);\n\n/** Sets a point to infinity (neutral element)\n *  \\param  group  underlying EC_GROUP object\n *  \\param  point  EC_POINT to set to infinity\n *  \\return 1 on success and 0 if an error occured\n */\nint EC_POINT_set_to_infinity(const EC_GROUP *group, EC_POINT *point);\n\n/** Sets the jacobian projective coordinates of a EC_POINT over GFp\n *  \\param  group  underlying EC_GROUP object\n *  \\param  p      EC_POINT object\n *  \\param  x      BIGNUM with the x-coordinate\n *  \\param  y      BIGNUM with the y-coordinate\n *  \\param  z      BIGNUM with the z-coordinate\n *  \\param  ctx    BN_CTX object (optional)\n *  \\return 1 on success and 0 if an error occured\n */\nint EC_POINT_set_Jprojective_coordinates_GFp(const EC_GROUP *group,\n                                             EC_POINT *p, const BIGNUM *x,\n                                             const BIGNUM *y, const BIGNUM *z,\n                                             BN_CTX *ctx);\n\n/** Gets the jacobian projective coordinates of a EC_POINT over GFp\n *  \\param  group  underlying EC_GROUP object\n *  \\param  p      EC_POINT object\n *  \\param  x      BIGNUM for the x-coordinate\n *  \\param  y      BIGNUM for the y-coordinate\n *  \\param  z      BIGNUM for the z-coordinate\n *  \\param  ctx    BN_CTX object (optional)\n *  \\return 1 on success and 0 if an error occured\n */\nint EC_POINT_get_Jprojective_coordinates_GFp(const EC_GROUP *group,\n                                             const EC_POINT *p, BIGNUM *x,\n                                             BIGNUM *y, BIGNUM *z,\n                                             BN_CTX *ctx);\n\n/** Sets the affine coordinates of a EC_POINT over GFp\n *  \\param  group  underlying EC_GROUP object\n *  \\param  p      EC_POINT object\n *  \\param  x      BIGNUM with the x-coordinate\n *  \\param  y      BIGNUM with the y-coordinate\n *  \\param  ctx    BN_CTX object (optional)\n *  \\return 1 on success and 0 if an error occured\n */\nint EC_POINT_set_affine_coordinates_GFp(const EC_GROUP *group, EC_POINT *p,\n                                        const BIGNUM *x, const BIGNUM *y,\n                                        BN_CTX *ctx);\n\n/** Gets the affine coordinates of a EC_POINT over GFp\n *  \\param  group  underlying EC_GROUP object\n *  \\param  p      EC_POINT object\n *  \\param  x      BIGNUM for the x-coordinate\n *  \\param  y      BIGNUM for the y-coordinate\n *  \\param  ctx    BN_CTX object (optional)\n *  \\return 1 on success and 0 if an error occured\n */\nint EC_POINT_get_affine_coordinates_GFp(const EC_GROUP *group,\n                                        const EC_POINT *p, BIGNUM *x,\n                                        BIGNUM *y, BN_CTX *ctx);\n\n/** Sets the x9.62 compressed coordinates of a EC_POINT over GFp\n *  \\param  group  underlying EC_GROUP object\n *  \\param  p      EC_POINT object\n *  \\param  x      BIGNUM with x-coordinate\n *  \\param  y_bit  integer with the y-Bit (either 0 or 1)\n *  \\param  ctx    BN_CTX object (optional)\n *  \\return 1 on success and 0 if an error occured\n */\nint EC_POINT_set_compressed_coordinates_GFp(const EC_GROUP *group,\n                                            EC_POINT *p, const BIGNUM *x,\n                                            int y_bit, BN_CTX *ctx);\n# ifndef OPENSSL_NO_EC2M\n/** Sets the affine coordinates of a EC_POINT over GF2m\n *  \\param  group  underlying EC_GROUP object\n *  \\param  p      EC_POINT object\n *  \\param  x      BIGNUM with the x-coordinate\n *  \\param  y      BIGNUM with the y-coordinate\n *  \\param  ctx    BN_CTX object (optional)\n *  \\return 1 on success and 0 if an error occured\n */\nint EC_POINT_set_affine_coordinates_GF2m(const EC_GROUP *group, EC_POINT *p,\n                                         const BIGNUM *x, const BIGNUM *y,\n                                         BN_CTX *ctx);\n\n/** Gets the affine coordinates of a EC_POINT over GF2m\n *  \\param  group  underlying EC_GROUP object\n *  \\param  p      EC_POINT object\n *  \\param  x      BIGNUM for the x-coordinate\n *  \\param  y      BIGNUM for the y-coordinate\n *  \\param  ctx    BN_CTX object (optional)\n *  \\return 1 on success and 0 if an error occured\n */\nint EC_POINT_get_affine_coordinates_GF2m(const EC_GROUP *group,\n                                         const EC_POINT *p, BIGNUM *x,\n                                         BIGNUM *y, BN_CTX *ctx);\n\n/** Sets the x9.62 compressed coordinates of a EC_POINT over GF2m\n *  \\param  group  underlying EC_GROUP object\n *  \\param  p      EC_POINT object\n *  \\param  x      BIGNUM with x-coordinate\n *  \\param  y_bit  integer with the y-Bit (either 0 or 1)\n *  \\param  ctx    BN_CTX object (optional)\n *  \\return 1 on success and 0 if an error occured\n */\nint EC_POINT_set_compressed_coordinates_GF2m(const EC_GROUP *group,\n                                             EC_POINT *p, const BIGNUM *x,\n                                             int y_bit, BN_CTX *ctx);\n# endif\n/** Encodes a EC_POINT object to a octet string\n *  \\param  group  underlying EC_GROUP object\n *  \\param  p      EC_POINT object\n *  \\param  form   point conversion form\n *  \\param  buf    memory buffer for the result. If NULL the function returns\n *                 required buffer size.\n *  \\param  len    length of the memory buffer\n *  \\param  ctx    BN_CTX object (optional)\n *  \\return the length of the encoded octet string or 0 if an error occurred\n */\nsize_t EC_POINT_point2oct(const EC_GROUP *group, const EC_POINT *p,\n                          point_conversion_form_t form,\n                          unsigned char *buf, size_t len, BN_CTX *ctx);\n\n/** Decodes a EC_POINT from a octet string\n *  \\param  group  underlying EC_GROUP object\n *  \\param  p      EC_POINT object\n *  \\param  buf    memory buffer with the encoded ec point\n *  \\param  len    length of the encoded ec point\n *  \\param  ctx    BN_CTX object (optional)\n *  \\return 1 on success and 0 if an error occured\n */\nint EC_POINT_oct2point(const EC_GROUP *group, EC_POINT *p,\n                       const unsigned char *buf, size_t len, BN_CTX *ctx);\n\n/* other interfaces to point2oct/oct2point: */\nBIGNUM *EC_POINT_point2bn(const EC_GROUP *, const EC_POINT *,\n                          point_conversion_form_t form, BIGNUM *, BN_CTX *);\nEC_POINT *EC_POINT_bn2point(const EC_GROUP *, const BIGNUM *,\n                            EC_POINT *, BN_CTX *);\nchar *EC_POINT_point2hex(const EC_GROUP *, const EC_POINT *,\n                         point_conversion_form_t form, BN_CTX *);\nEC_POINT *EC_POINT_hex2point(const EC_GROUP *, const char *,\n                             EC_POINT *, BN_CTX *);\n\n/********************************************************************/\n/*         functions for doing EC_POINT arithmetic                  */\n/********************************************************************/\n\n/** Computes the sum of two EC_POINT\n *  \\param  group  underlying EC_GROUP object\n *  \\param  r      EC_POINT object for the result (r = a + b)\n *  \\param  a      EC_POINT object with the first summand\n *  \\param  b      EC_POINT object with the second summand\n *  \\param  ctx    BN_CTX object (optional)\n *  \\return 1 on success and 0 if an error occured\n */\nint EC_POINT_add(const EC_GROUP *group, EC_POINT *r, const EC_POINT *a,\n                 const EC_POINT *b, BN_CTX *ctx);\n\n/** Computes the double of a EC_POINT\n *  \\param  group  underlying EC_GROUP object\n *  \\param  r      EC_POINT object for the result (r = 2 * a)\n *  \\param  a      EC_POINT object\n *  \\param  ctx    BN_CTX object (optional)\n *  \\return 1 on success and 0 if an error occured\n */\nint EC_POINT_dbl(const EC_GROUP *group, EC_POINT *r, const EC_POINT *a,\n                 BN_CTX *ctx);\n\n/** Computes the inverse of a EC_POINT\n *  \\param  group  underlying EC_GROUP object\n *  \\param  a      EC_POINT object to be inverted (it's used for the result as well)\n *  \\param  ctx    BN_CTX object (optional)\n *  \\return 1 on success and 0 if an error occured\n */\nint EC_POINT_invert(const EC_GROUP *group, EC_POINT *a, BN_CTX *ctx);\n\n/** Checks whether the point is the neutral element of the group\n *  \\param  group  the underlying EC_GROUP object\n *  \\param  p      EC_POINT object\n *  \\return 1 if the point is the neutral element and 0 otherwise\n */\nint EC_POINT_is_at_infinity(const EC_GROUP *group, const EC_POINT *p);\n\n/** Checks whether the point is on the curve\n *  \\param  group  underlying EC_GROUP object\n *  \\param  point  EC_POINT object to check\n *  \\param  ctx    BN_CTX object (optional)\n *  \\return 1 if point if on the curve and 0 otherwise\n */\nint EC_POINT_is_on_curve(const EC_GROUP *group, const EC_POINT *point,\n                         BN_CTX *ctx);\n\n/** Compares two EC_POINTs\n *  \\param  group  underlying EC_GROUP object\n *  \\param  a      first EC_POINT object\n *  \\param  b      second EC_POINT object\n *  \\param  ctx    BN_CTX object (optional)\n *  \\return 0 if both points are equal and a value != 0 otherwise\n */\nint EC_POINT_cmp(const EC_GROUP *group, const EC_POINT *a, const EC_POINT *b,\n                 BN_CTX *ctx);\n\nint EC_POINT_make_affine(const EC_GROUP *group, EC_POINT *point, BN_CTX *ctx);\nint EC_POINTs_make_affine(const EC_GROUP *group, size_t num,\n                          EC_POINT *points[], BN_CTX *ctx);\n\n/** Computes r = generator * n sum_{i=0}^{num-1} p[i] * m[i]\n *  \\param  group  underlying EC_GROUP object\n *  \\param  r      EC_POINT object for the result\n *  \\param  n      BIGNUM with the multiplier for the group generator (optional)\n *  \\param  num    number futher summands\n *  \\param  p      array of size num of EC_POINT objects\n *  \\param  m      array of size num of BIGNUM objects\n *  \\param  ctx    BN_CTX object (optional)\n *  \\return 1 on success and 0 if an error occured\n */\nint EC_POINTs_mul(const EC_GROUP *group, EC_POINT *r, const BIGNUM *n,\n                  size_t num, const EC_POINT *p[], const BIGNUM *m[],\n                  BN_CTX *ctx);\n\n/** Computes r = generator * n + q * m\n *  \\param  group  underlying EC_GROUP object\n *  \\param  r      EC_POINT object for the result\n *  \\param  n      BIGNUM with the multiplier for the group generator (optional)\n *  \\param  q      EC_POINT object with the first factor of the second summand\n *  \\param  m      BIGNUM with the second factor of the second summand\n *  \\param  ctx    BN_CTX object (optional)\n *  \\return 1 on success and 0 if an error occured\n */\nint EC_POINT_mul(const EC_GROUP *group, EC_POINT *r, const BIGNUM *n,\n                 const EC_POINT *q, const BIGNUM *m, BN_CTX *ctx);\n\n/** Stores multiples of generator for faster point multiplication\n *  \\param  group  EC_GROUP object\n *  \\param  ctx    BN_CTX object (optional)\n *  \\return 1 on success and 0 if an error occured\n */\nint EC_GROUP_precompute_mult(EC_GROUP *group, BN_CTX *ctx);\n\n/** Reports whether a precomputation has been done\n *  \\param  group  EC_GROUP object\n *  \\return 1 if a pre-computation has been done and 0 otherwise\n */\nint EC_GROUP_have_precompute_mult(const EC_GROUP *group);\n\n/********************************************************************/\n/*                       ASN1 stuff                                 */\n/********************************************************************/\n\n/*\n * EC_GROUP_get_basis_type() returns the NID of the basis type used to\n * represent the field elements\n */\nint EC_GROUP_get_basis_type(const EC_GROUP *);\n# ifndef OPENSSL_NO_EC2M\nint EC_GROUP_get_trinomial_basis(const EC_GROUP *, unsigned int *k);\nint EC_GROUP_get_pentanomial_basis(const EC_GROUP *, unsigned int *k1,\n                                   unsigned int *k2, unsigned int *k3);\n# endif\n\n# define OPENSSL_EC_NAMED_CURVE  0x001\n\ntypedef struct ecpk_parameters_st ECPKPARAMETERS;\n\nEC_GROUP *d2i_ECPKParameters(EC_GROUP **, const unsigned char **in, long len);\nint i2d_ECPKParameters(const EC_GROUP *, unsigned char **out);\n\n# define d2i_ECPKParameters_bio(bp,x) ASN1_d2i_bio_of(EC_GROUP,NULL,d2i_ECPKParameters,bp,x)\n# define i2d_ECPKParameters_bio(bp,x) ASN1_i2d_bio_of_const(EC_GROUP,i2d_ECPKParameters,bp,x)\n# define d2i_ECPKParameters_fp(fp,x) (EC_GROUP *)ASN1_d2i_fp(NULL, \\\n                (char *(*)())d2i_ECPKParameters,(fp),(unsigned char **)(x))\n# define i2d_ECPKParameters_fp(fp,x) ASN1_i2d_fp(i2d_ECPKParameters,(fp), \\\n                (unsigned char *)(x))\n\n# ifndef OPENSSL_NO_BIO\nint ECPKParameters_print(BIO *bp, const EC_GROUP *x, int off);\n# endif\n# ifndef OPENSSL_NO_FP_API\nint ECPKParameters_print_fp(FILE *fp, const EC_GROUP *x, int off);\n# endif\n\n/********************************************************************/\n/*                      EC_KEY functions                            */\n/********************************************************************/\n\ntypedef struct ec_key_st EC_KEY;\n\n/* some values for the encoding_flag */\n# define EC_PKEY_NO_PARAMETERS   0x001\n# define EC_PKEY_NO_PUBKEY       0x002\n\n/* some values for the flags field */\n# define EC_FLAG_NON_FIPS_ALLOW  0x1\n# define EC_FLAG_FIPS_CHECKED    0x2\n\n/** Creates a new EC_KEY object.\n *  \\return EC_KEY object or NULL if an error occurred.\n */\nEC_KEY *EC_KEY_new(void);\n\nint EC_KEY_get_flags(const EC_KEY *key);\n\nvoid EC_KEY_set_flags(EC_KEY *key, int flags);\n\nvoid EC_KEY_clear_flags(EC_KEY *key, int flags);\n\n/** Creates a new EC_KEY object using a named curve as underlying\n *  EC_GROUP object.\n *  \\param  nid  NID of the named curve.\n *  \\return EC_KEY object or NULL if an error occurred.\n */\nEC_KEY *EC_KEY_new_by_curve_name(int nid);\n\n/** Frees a EC_KEY object.\n *  \\param  key  EC_KEY object to be freed.\n */\nvoid EC_KEY_free(EC_KEY *key);\n\n/** Copies a EC_KEY object.\n *  \\param  dst  destination EC_KEY object\n *  \\param  src  src EC_KEY object\n *  \\return dst or NULL if an error occurred.\n */\nEC_KEY *EC_KEY_copy(EC_KEY *dst, const EC_KEY *src);\n\n/** Creates a new EC_KEY object and copies the content from src to it.\n *  \\param  src  the source EC_KEY object\n *  \\return newly created EC_KEY object or NULL if an error occurred.\n */\nEC_KEY *EC_KEY_dup(const EC_KEY *src);\n\n/** Increases the internal reference count of a EC_KEY object.\n *  \\param  key  EC_KEY object\n *  \\return 1 on success and 0 if an error occurred.\n */\nint EC_KEY_up_ref(EC_KEY *key);\n\n/** Returns the EC_GROUP object of a EC_KEY object\n *  \\param  key  EC_KEY object\n *  \\return the EC_GROUP object (possibly NULL).\n */\nconst EC_GROUP *EC_KEY_get0_group(const EC_KEY *key);\n\n/** Sets the EC_GROUP of a EC_KEY object.\n *  \\param  key    EC_KEY object\n *  \\param  group  EC_GROUP to use in the EC_KEY object (note: the EC_KEY\n *                 object will use an own copy of the EC_GROUP).\n *  \\return 1 on success and 0 if an error occurred.\n */\nint EC_KEY_set_group(EC_KEY *key, const EC_GROUP *group);\n\n/** Returns the private key of a EC_KEY object.\n *  \\param  key  EC_KEY object\n *  \\return a BIGNUM with the private key (possibly NULL).\n */\nconst BIGNUM *EC_KEY_get0_private_key(const EC_KEY *key);\n\n/** Sets the private key of a EC_KEY object.\n *  \\param  key  EC_KEY object\n *  \\param  prv  BIGNUM with the private key (note: the EC_KEY object\n *               will use an own copy of the BIGNUM).\n *  \\return 1 on success and 0 if an error occurred.\n */\nint EC_KEY_set_private_key(EC_KEY *key, const BIGNUM *prv);\n\n/** Returns the public key of a EC_KEY object.\n *  \\param  key  the EC_KEY object\n *  \\return a EC_POINT object with the public key (possibly NULL)\n */\nconst EC_POINT *EC_KEY_get0_public_key(const EC_KEY *key);\n\n/** Sets the public key of a EC_KEY object.\n *  \\param  key  EC_KEY object\n *  \\param  pub  EC_POINT object with the public key (note: the EC_KEY object\n *               will use an own copy of the EC_POINT object).\n *  \\return 1 on success and 0 if an error occurred.\n */\nint EC_KEY_set_public_key(EC_KEY *key, const EC_POINT *pub);\n\nunsigned EC_KEY_get_enc_flags(const EC_KEY *key);\nvoid EC_KEY_set_enc_flags(EC_KEY *eckey, unsigned int flags);\npoint_conversion_form_t EC_KEY_get_conv_form(const EC_KEY *key);\nvoid EC_KEY_set_conv_form(EC_KEY *eckey, point_conversion_form_t cform);\n/* functions to set/get method specific data  */\nvoid *EC_KEY_get_key_method_data(EC_KEY *key,\n                                 void *(*dup_func) (void *),\n                                 void (*free_func) (void *),\n                                 void (*clear_free_func) (void *));\n/** Sets the key method data of an EC_KEY object, if none has yet been set.\n *  \\param  key              EC_KEY object\n *  \\param  data             opaque data to install.\n *  \\param  dup_func         a function that duplicates |data|.\n *  \\param  free_func        a function that frees |data|.\n *  \\param  clear_free_func  a function that wipes and frees |data|.\n *  \\return the previously set data pointer, or NULL if |data| was inserted.\n */\nvoid *EC_KEY_insert_key_method_data(EC_KEY *key, void *data,\n                                    void *(*dup_func) (void *),\n                                    void (*free_func) (void *),\n                                    void (*clear_free_func) (void *));\n/* wrapper functions for the underlying EC_GROUP object */\nvoid EC_KEY_set_asn1_flag(EC_KEY *eckey, int asn1_flag);\n\n/** Creates a table of pre-computed multiples of the generator to\n *  accelerate further EC_KEY operations.\n *  \\param  key  EC_KEY object\n *  \\param  ctx  BN_CTX object (optional)\n *  \\return 1 on success and 0 if an error occurred.\n */\nint EC_KEY_precompute_mult(EC_KEY *key, BN_CTX *ctx);\n\n/** Creates a new ec private (and optional a new public) key.\n *  \\param  key  EC_KEY object\n *  \\return 1 on success and 0 if an error occurred.\n */\nint EC_KEY_generate_key(EC_KEY *key);\n\n/** Verifies that a private and/or public key is valid.\n *  \\param  key  the EC_KEY object\n *  \\return 1 on success and 0 otherwise.\n */\nint EC_KEY_check_key(const EC_KEY *key);\n\n/** Sets a public key from affine coordindates performing\n *  neccessary NIST PKV tests.\n *  \\param  key  the EC_KEY object\n *  \\param  x    public key x coordinate\n *  \\param  y    public key y coordinate\n *  \\return 1 on success and 0 otherwise.\n */\nint EC_KEY_set_public_key_affine_coordinates(EC_KEY *key, BIGNUM *x,\n                                             BIGNUM *y);\n\n/********************************************************************/\n/*        de- and encoding functions for SEC1 ECPrivateKey          */\n/********************************************************************/\n\n/** Decodes a private key from a memory buffer.\n *  \\param  key  a pointer to a EC_KEY object which should be used (or NULL)\n *  \\param  in   pointer to memory with the DER encoded private key\n *  \\param  len  length of the DER encoded private key\n *  \\return the decoded private key or NULL if an error occurred.\n */\nEC_KEY *d2i_ECPrivateKey(EC_KEY **key, const unsigned char **in, long len);\n\n/** Encodes a private key object and stores the result in a buffer.\n *  \\param  key  the EC_KEY object to encode\n *  \\param  out  the buffer for the result (if NULL the function returns number\n *               of bytes needed).\n *  \\return 1 on success and 0 if an error occurred.\n */\nint i2d_ECPrivateKey(EC_KEY *key, unsigned char **out);\n\n/********************************************************************/\n/*        de- and encoding functions for EC parameters              */\n/********************************************************************/\n\n/** Decodes ec parameter from a memory buffer.\n *  \\param  key  a pointer to a EC_KEY object which should be used (or NULL)\n *  \\param  in   pointer to memory with the DER encoded ec parameters\n *  \\param  len  length of the DER encoded ec parameters\n *  \\return a EC_KEY object with the decoded parameters or NULL if an error\n *          occurred.\n */\nEC_KEY *d2i_ECParameters(EC_KEY **key, const unsigned char **in, long len);\n\n/** Encodes ec parameter and stores the result in a buffer.\n *  \\param  key  the EC_KEY object with ec paramters to encode\n *  \\param  out  the buffer for the result (if NULL the function returns number\n *               of bytes needed).\n *  \\return 1 on success and 0 if an error occurred.\n */\nint i2d_ECParameters(EC_KEY *key, unsigned char **out);\n\n/********************************************************************/\n/*         de- and encoding functions for EC public key             */\n/*         (octet string, not DER -- hence 'o2i' and 'i2o')         */\n/********************************************************************/\n\n/** Decodes a ec public key from a octet string.\n *  \\param  key  a pointer to a EC_KEY object which should be used\n *  \\param  in   memory buffer with the encoded public key\n *  \\param  len  length of the encoded public key\n *  \\return EC_KEY object with decoded public key or NULL if an error\n *          occurred.\n */\nEC_KEY *o2i_ECPublicKey(EC_KEY **key, const unsigned char **in, long len);\n\n/** Encodes a ec public key in an octet string.\n *  \\param  key  the EC_KEY object with the public key\n *  \\param  out  the buffer for the result (if NULL the function returns number\n *               of bytes needed).\n *  \\return 1 on success and 0 if an error occurred\n */\nint i2o_ECPublicKey(EC_KEY *key, unsigned char **out);\n\n# ifndef OPENSSL_NO_BIO\n/** Prints out the ec parameters on human readable form.\n *  \\param  bp   BIO object to which the information is printed\n *  \\param  key  EC_KEY object\n *  \\return 1 on success and 0 if an error occurred\n */\nint ECParameters_print(BIO *bp, const EC_KEY *key);\n\n/** Prints out the contents of a EC_KEY object\n *  \\param  bp   BIO object to which the information is printed\n *  \\param  key  EC_KEY object\n *  \\param  off  line offset\n *  \\return 1 on success and 0 if an error occurred\n */\nint EC_KEY_print(BIO *bp, const EC_KEY *key, int off);\n\n# endif\n# ifndef OPENSSL_NO_FP_API\n/** Prints out the ec parameters on human readable form.\n *  \\param  fp   file descriptor to which the information is printed\n *  \\param  key  EC_KEY object\n *  \\return 1 on success and 0 if an error occurred\n */\nint ECParameters_print_fp(FILE *fp, const EC_KEY *key);\n\n/** Prints out the contents of a EC_KEY object\n *  \\param  fp   file descriptor to which the information is printed\n *  \\param  key  EC_KEY object\n *  \\param  off  line offset\n *  \\return 1 on success and 0 if an error occurred\n */\nint EC_KEY_print_fp(FILE *fp, const EC_KEY *key, int off);\n\n# endif\n\n# define ECParameters_dup(x) ASN1_dup_of(EC_KEY,i2d_ECParameters,d2i_ECParameters,x)\n\n# ifndef __cplusplus\n#  if defined(__SUNPRO_C)\n#   if __SUNPRO_C >= 0x520\n#    pragma error_messages (default,E_ARRAY_OF_INCOMPLETE_NONAME,E_ARRAY_OF_INCOMPLETE)\n#   endif\n#  endif\n# endif\n\n# define EVP_PKEY_CTX_set_ec_paramgen_curve_nid(ctx, nid) \\\n        EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_EC, \\\n                                EVP_PKEY_OP_PARAMGEN|EVP_PKEY_OP_KEYGEN, \\\n                                EVP_PKEY_CTRL_EC_PARAMGEN_CURVE_NID, nid, NULL)\n\n# define EVP_PKEY_CTX_set_ec_param_enc(ctx, flag) \\\n        EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_EC, \\\n                                EVP_PKEY_OP_PARAMGEN|EVP_PKEY_OP_KEYGEN, \\\n                                EVP_PKEY_CTRL_EC_PARAM_ENC, flag, NULL)\n\n# define EVP_PKEY_CTX_set_ecdh_cofactor_mode(ctx, flag) \\\n        EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_EC, \\\n                                EVP_PKEY_OP_DERIVE, \\\n                                EVP_PKEY_CTRL_EC_ECDH_COFACTOR, flag, NULL)\n\n# define EVP_PKEY_CTX_get_ecdh_cofactor_mode(ctx) \\\n        EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_EC, \\\n                                EVP_PKEY_OP_DERIVE, \\\n                                EVP_PKEY_CTRL_EC_ECDH_COFACTOR, -2, NULL)\n\n# define EVP_PKEY_CTX_set_ecdh_kdf_type(ctx, kdf) \\\n        EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_EC, \\\n                                EVP_PKEY_OP_DERIVE, \\\n                                EVP_PKEY_CTRL_EC_KDF_TYPE, kdf, NULL)\n\n# define EVP_PKEY_CTX_get_ecdh_kdf_type(ctx) \\\n        EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_EC, \\\n                                EVP_PKEY_OP_DERIVE, \\\n                                EVP_PKEY_CTRL_EC_KDF_TYPE, -2, NULL)\n\n# define EVP_PKEY_CTX_set_ecdh_kdf_md(ctx, md) \\\n        EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_EC, \\\n                                EVP_PKEY_OP_DERIVE, \\\n                                EVP_PKEY_CTRL_EC_KDF_MD, 0, (void *)md)\n\n# define EVP_PKEY_CTX_get_ecdh_kdf_md(ctx, pmd) \\\n        EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_EC, \\\n                                EVP_PKEY_OP_DERIVE, \\\n                                EVP_PKEY_CTRL_GET_EC_KDF_MD, 0, (void *)pmd)\n\n# define EVP_PKEY_CTX_set_ecdh_kdf_outlen(ctx, len) \\\n        EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_EC, \\\n                                EVP_PKEY_OP_DERIVE, \\\n                                EVP_PKEY_CTRL_EC_KDF_OUTLEN, len, NULL)\n\n# define EVP_PKEY_CTX_get_ecdh_kdf_outlen(ctx, plen) \\\n        EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_EC, \\\n                                EVP_PKEY_OP_DERIVE, \\\n                        EVP_PKEY_CTRL_GET_EC_KDF_OUTLEN, 0, (void *)plen)\n\n# define EVP_PKEY_CTX_set0_ecdh_kdf_ukm(ctx, p, plen) \\\n        EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_EC, \\\n                                EVP_PKEY_OP_DERIVE, \\\n                                EVP_PKEY_CTRL_EC_KDF_UKM, plen, (void *)p)\n\n# define EVP_PKEY_CTX_get0_ecdh_kdf_ukm(ctx, p) \\\n        EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_EC, \\\n                                EVP_PKEY_OP_DERIVE, \\\n                                EVP_PKEY_CTRL_GET_EC_KDF_UKM, 0, (void *)p)\n\n# define EVP_PKEY_CTRL_EC_PARAMGEN_CURVE_NID             (EVP_PKEY_ALG_CTRL + 1)\n# define EVP_PKEY_CTRL_EC_PARAM_ENC                      (EVP_PKEY_ALG_CTRL + 2)\n# define EVP_PKEY_CTRL_EC_ECDH_COFACTOR                  (EVP_PKEY_ALG_CTRL + 3)\n# define EVP_PKEY_CTRL_EC_KDF_TYPE                       (EVP_PKEY_ALG_CTRL + 4)\n# define EVP_PKEY_CTRL_EC_KDF_MD                         (EVP_PKEY_ALG_CTRL + 5)\n# define EVP_PKEY_CTRL_GET_EC_KDF_MD                     (EVP_PKEY_ALG_CTRL + 6)\n# define EVP_PKEY_CTRL_EC_KDF_OUTLEN                     (EVP_PKEY_ALG_CTRL + 7)\n# define EVP_PKEY_CTRL_GET_EC_KDF_OUTLEN                 (EVP_PKEY_ALG_CTRL + 8)\n# define EVP_PKEY_CTRL_EC_KDF_UKM                        (EVP_PKEY_ALG_CTRL + 9)\n# define EVP_PKEY_CTRL_GET_EC_KDF_UKM                    (EVP_PKEY_ALG_CTRL + 10)\n/* KDF types */\n# define EVP_PKEY_ECDH_KDF_NONE                          1\n# define EVP_PKEY_ECDH_KDF_X9_62                         2\n\n/* BEGIN ERROR CODES */\n/*\n * The following lines are auto generated by the script mkerr.pl. Any changes\n * made after this point may be overwritten when the script is next run.\n */\nvoid ERR_load_EC_strings(void);\n\n/* Error codes for the EC functions. */\n\n/* Function codes. */\n# define EC_F_BN_TO_FELEM                                 224\n# define EC_F_COMPUTE_WNAF                                143\n# define EC_F_D2I_ECPARAMETERS                            144\n# define EC_F_D2I_ECPKPARAMETERS                          145\n# define EC_F_D2I_ECPRIVATEKEY                            146\n# define EC_F_DO_EC_KEY_PRINT                             221\n# define EC_F_ECDH_CMS_DECRYPT                            238\n# define EC_F_ECDH_CMS_SET_SHARED_INFO                    239\n# define EC_F_ECKEY_PARAM2TYPE                            223\n# define EC_F_ECKEY_PARAM_DECODE                          212\n# define EC_F_ECKEY_PRIV_DECODE                           213\n# define EC_F_ECKEY_PRIV_ENCODE                           214\n# define EC_F_ECKEY_PUB_DECODE                            215\n# define EC_F_ECKEY_PUB_ENCODE                            216\n# define EC_F_ECKEY_TYPE2PARAM                            220\n# define EC_F_ECPARAMETERS_PRINT                          147\n# define EC_F_ECPARAMETERS_PRINT_FP                       148\n# define EC_F_ECPKPARAMETERS_PRINT                        149\n# define EC_F_ECPKPARAMETERS_PRINT_FP                     150\n# define EC_F_ECP_NISTZ256_GET_AFFINE                     240\n# define EC_F_ECP_NISTZ256_MULT_PRECOMPUTE                243\n# define EC_F_ECP_NISTZ256_POINTS_MUL                     241\n# define EC_F_ECP_NISTZ256_PRE_COMP_NEW                   244\n# define EC_F_ECP_NISTZ256_SET_WORDS                      245\n# define EC_F_ECP_NISTZ256_WINDOWED_MUL                   242\n# define EC_F_ECP_NIST_MOD_192                            203\n# define EC_F_ECP_NIST_MOD_224                            204\n# define EC_F_ECP_NIST_MOD_256                            205\n# define EC_F_ECP_NIST_MOD_521                            206\n# define EC_F_EC_ASN1_GROUP2CURVE                         153\n# define EC_F_EC_ASN1_GROUP2FIELDID                       154\n# define EC_F_EC_ASN1_GROUP2PARAMETERS                    155\n# define EC_F_EC_ASN1_GROUP2PKPARAMETERS                  156\n# define EC_F_EC_ASN1_PARAMETERS2GROUP                    157\n# define EC_F_EC_ASN1_PKPARAMETERS2GROUP                  158\n# define EC_F_EC_EX_DATA_SET_DATA                         211\n# define EC_F_EC_GF2M_MONTGOMERY_POINT_MULTIPLY           208\n# define EC_F_EC_GF2M_SIMPLE_GROUP_CHECK_DISCRIMINANT     159\n# define EC_F_EC_GF2M_SIMPLE_GROUP_SET_CURVE              195\n# define EC_F_EC_GF2M_SIMPLE_OCT2POINT                    160\n# define EC_F_EC_GF2M_SIMPLE_POINT2OCT                    161\n# define EC_F_EC_GF2M_SIMPLE_POINT_GET_AFFINE_COORDINATES 162\n# define EC_F_EC_GF2M_SIMPLE_POINT_SET_AFFINE_COORDINATES 163\n# define EC_F_EC_GF2M_SIMPLE_SET_COMPRESSED_COORDINATES   164\n# define EC_F_EC_GFP_MONT_FIELD_DECODE                    133\n# define EC_F_EC_GFP_MONT_FIELD_ENCODE                    134\n# define EC_F_EC_GFP_MONT_FIELD_MUL                       131\n# define EC_F_EC_GFP_MONT_FIELD_SET_TO_ONE                209\n# define EC_F_EC_GFP_MONT_FIELD_SQR                       132\n# define EC_F_EC_GFP_MONT_GROUP_SET_CURVE                 189\n# define EC_F_EC_GFP_MONT_GROUP_SET_CURVE_GFP             135\n# define EC_F_EC_GFP_NISTP224_GROUP_SET_CURVE             225\n# define EC_F_EC_GFP_NISTP224_POINTS_MUL                  228\n# define EC_F_EC_GFP_NISTP224_POINT_GET_AFFINE_COORDINATES 226\n# define EC_F_EC_GFP_NISTP256_GROUP_SET_CURVE             230\n# define EC_F_EC_GFP_NISTP256_POINTS_MUL                  231\n# define EC_F_EC_GFP_NISTP256_POINT_GET_AFFINE_COORDINATES 232\n# define EC_F_EC_GFP_NISTP521_GROUP_SET_CURVE             233\n# define EC_F_EC_GFP_NISTP521_POINTS_MUL                  234\n# define EC_F_EC_GFP_NISTP521_POINT_GET_AFFINE_COORDINATES 235\n# define EC_F_EC_GFP_NIST_FIELD_MUL                       200\n# define EC_F_EC_GFP_NIST_FIELD_SQR                       201\n# define EC_F_EC_GFP_NIST_GROUP_SET_CURVE                 202\n# define EC_F_EC_GFP_SIMPLE_GROUP_CHECK_DISCRIMINANT      165\n# define EC_F_EC_GFP_SIMPLE_GROUP_SET_CURVE               166\n# define EC_F_EC_GFP_SIMPLE_GROUP_SET_CURVE_GFP           100\n# define EC_F_EC_GFP_SIMPLE_GROUP_SET_GENERATOR           101\n# define EC_F_EC_GFP_SIMPLE_MAKE_AFFINE                   102\n# define EC_F_EC_GFP_SIMPLE_OCT2POINT                     103\n# define EC_F_EC_GFP_SIMPLE_POINT2OCT                     104\n# define EC_F_EC_GFP_SIMPLE_POINTS_MAKE_AFFINE            137\n# define EC_F_EC_GFP_SIMPLE_POINT_GET_AFFINE_COORDINATES  167\n# define EC_F_EC_GFP_SIMPLE_POINT_GET_AFFINE_COORDINATES_GFP 105\n# define EC_F_EC_GFP_SIMPLE_POINT_SET_AFFINE_COORDINATES  168\n# define EC_F_EC_GFP_SIMPLE_POINT_SET_AFFINE_COORDINATES_GFP 128\n# define EC_F_EC_GFP_SIMPLE_SET_COMPRESSED_COORDINATES    169\n# define EC_F_EC_GFP_SIMPLE_SET_COMPRESSED_COORDINATES_GFP 129\n# define EC_F_EC_GROUP_CHECK                              170\n# define EC_F_EC_GROUP_CHECK_DISCRIMINANT                 171\n# define EC_F_EC_GROUP_COPY                               106\n# define EC_F_EC_GROUP_GET0_GENERATOR                     139\n# define EC_F_EC_GROUP_GET_COFACTOR                       140\n# define EC_F_EC_GROUP_GET_CURVE_GF2M                     172\n# define EC_F_EC_GROUP_GET_CURVE_GFP                      130\n# define EC_F_EC_GROUP_GET_DEGREE                         173\n# define EC_F_EC_GROUP_GET_ORDER                          141\n# define EC_F_EC_GROUP_GET_PENTANOMIAL_BASIS              193\n# define EC_F_EC_GROUP_GET_TRINOMIAL_BASIS                194\n# define EC_F_EC_GROUP_NEW                                108\n# define EC_F_EC_GROUP_NEW_BY_CURVE_NAME                  174\n# define EC_F_EC_GROUP_NEW_FROM_DATA                      175\n# define EC_F_EC_GROUP_PRECOMPUTE_MULT                    142\n# define EC_F_EC_GROUP_SET_CURVE_GF2M                     176\n# define EC_F_EC_GROUP_SET_CURVE_GFP                      109\n# define EC_F_EC_GROUP_SET_EXTRA_DATA                     110\n# define EC_F_EC_GROUP_SET_GENERATOR                      111\n# define EC_F_EC_KEY_CHECK_KEY                            177\n# define EC_F_EC_KEY_COPY                                 178\n# define EC_F_EC_KEY_GENERATE_KEY                         179\n# define EC_F_EC_KEY_NEW                                  182\n# define EC_F_EC_KEY_PRINT                                180\n# define EC_F_EC_KEY_PRINT_FP                             181\n# define EC_F_EC_KEY_SET_PUBLIC_KEY_AFFINE_COORDINATES    229\n# define EC_F_EC_POINTS_MAKE_AFFINE                       136\n# define EC_F_EC_POINT_ADD                                112\n# define EC_F_EC_POINT_CMP                                113\n# define EC_F_EC_POINT_COPY                               114\n# define EC_F_EC_POINT_DBL                                115\n# define EC_F_EC_POINT_GET_AFFINE_COORDINATES_GF2M        183\n# define EC_F_EC_POINT_GET_AFFINE_COORDINATES_GFP         116\n# define EC_F_EC_POINT_GET_JPROJECTIVE_COORDINATES_GFP    117\n# define EC_F_EC_POINT_INVERT                             210\n# define EC_F_EC_POINT_IS_AT_INFINITY                     118\n# define EC_F_EC_POINT_IS_ON_CURVE                        119\n# define EC_F_EC_POINT_MAKE_AFFINE                        120\n# define EC_F_EC_POINT_MUL                                184\n# define EC_F_EC_POINT_NEW                                121\n# define EC_F_EC_POINT_OCT2POINT                          122\n# define EC_F_EC_POINT_POINT2OCT                          123\n# define EC_F_EC_POINT_SET_AFFINE_COORDINATES_GF2M        185\n# define EC_F_EC_POINT_SET_AFFINE_COORDINATES_GFP         124\n# define EC_F_EC_POINT_SET_COMPRESSED_COORDINATES_GF2M    186\n# define EC_F_EC_POINT_SET_COMPRESSED_COORDINATES_GFP     125\n# define EC_F_EC_POINT_SET_JPROJECTIVE_COORDINATES_GFP    126\n# define EC_F_EC_POINT_SET_TO_INFINITY                    127\n# define EC_F_EC_PRE_COMP_DUP                             207\n# define EC_F_EC_PRE_COMP_NEW                             196\n# define EC_F_EC_WNAF_MUL                                 187\n# define EC_F_EC_WNAF_PRECOMPUTE_MULT                     188\n# define EC_F_I2D_ECPARAMETERS                            190\n# define EC_F_I2D_ECPKPARAMETERS                          191\n# define EC_F_I2D_ECPRIVATEKEY                            192\n# define EC_F_I2O_ECPUBLICKEY                             151\n# define EC_F_NISTP224_PRE_COMP_NEW                       227\n# define EC_F_NISTP256_PRE_COMP_NEW                       236\n# define EC_F_NISTP521_PRE_COMP_NEW                       237\n# define EC_F_O2I_ECPUBLICKEY                             152\n# define EC_F_OLD_EC_PRIV_DECODE                          222\n# define EC_F_PKEY_EC_CTRL                                197\n# define EC_F_PKEY_EC_CTRL_STR                            198\n# define EC_F_PKEY_EC_DERIVE                              217\n# define EC_F_PKEY_EC_KEYGEN                              199\n# define EC_F_PKEY_EC_PARAMGEN                            219\n# define EC_F_PKEY_EC_SIGN                                218\n\n/* Reason codes. */\n# define EC_R_ASN1_ERROR                                  115\n# define EC_R_ASN1_UNKNOWN_FIELD                          116\n# define EC_R_BIGNUM_OUT_OF_RANGE                         144\n# define EC_R_BUFFER_TOO_SMALL                            100\n# define EC_R_COORDINATES_OUT_OF_RANGE                    146\n# define EC_R_D2I_ECPKPARAMETERS_FAILURE                  117\n# define EC_R_DECODE_ERROR                                142\n# define EC_R_DISCRIMINANT_IS_ZERO                        118\n# define EC_R_EC_GROUP_NEW_BY_NAME_FAILURE                119\n# define EC_R_FIELD_TOO_LARGE                             143\n# define EC_R_GF2M_NOT_SUPPORTED                          147\n# define EC_R_GROUP2PKPARAMETERS_FAILURE                  120\n# define EC_R_I2D_ECPKPARAMETERS_FAILURE                  121\n# define EC_R_INCOMPATIBLE_OBJECTS                        101\n# define EC_R_INVALID_ARGUMENT                            112\n# define EC_R_INVALID_COMPRESSED_POINT                    110\n# define EC_R_INVALID_COMPRESSION_BIT                     109\n# define EC_R_INVALID_CURVE                               141\n# define EC_R_INVALID_DIGEST                              151\n# define EC_R_INVALID_DIGEST_TYPE                         138\n# define EC_R_INVALID_ENCODING                            102\n# define EC_R_INVALID_FIELD                               103\n# define EC_R_INVALID_FORM                                104\n# define EC_R_INVALID_GROUP_ORDER                         122\n# define EC_R_INVALID_PENTANOMIAL_BASIS                   132\n# define EC_R_INVALID_PRIVATE_KEY                         123\n# define EC_R_INVALID_TRINOMIAL_BASIS                     137\n# define EC_R_KDF_PARAMETER_ERROR                         148\n# define EC_R_KEYS_NOT_SET                                140\n# define EC_R_MISSING_PARAMETERS                          124\n# define EC_R_MISSING_PRIVATE_KEY                         125\n# define EC_R_NOT_A_NIST_PRIME                            135\n# define EC_R_NOT_A_SUPPORTED_NIST_PRIME                  136\n# define EC_R_NOT_IMPLEMENTED                             126\n# define EC_R_NOT_INITIALIZED                             111\n# define EC_R_NO_FIELD_MOD                                133\n# define EC_R_NO_PARAMETERS_SET                           139\n# define EC_R_PASSED_NULL_PARAMETER                       134\n# define EC_R_PEER_KEY_ERROR                              149\n# define EC_R_PKPARAMETERS2GROUP_FAILURE                  127\n# define EC_R_POINT_AT_INFINITY                           106\n# define EC_R_POINT_IS_NOT_ON_CURVE                       107\n# define EC_R_SHARED_INFO_ERROR                           150\n# define EC_R_SLOT_FULL                                   108\n# define EC_R_UNDEFINED_GENERATOR                         113\n# define EC_R_UNDEFINED_ORDER                             128\n# define EC_R_UNKNOWN_GROUP                               129\n# define EC_R_UNKNOWN_ORDER                               114\n# define EC_R_UNSUPPORTED_FIELD                           131\n# define EC_R_WRONG_CURVE_PARAMETERS                      145\n# define EC_R_WRONG_ORDER                                 130\n\n#ifdef  __cplusplus\n}\n#endif\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/arm64/include/openssl/ecdh.h",
    "content": "/* crypto/ecdh/ecdh.h */\n/* ====================================================================\n * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED.\n *\n * The Elliptic Curve Public-Key Crypto Library (ECC Code) included\n * herein is developed by SUN MICROSYSTEMS, INC., and is contributed\n * to the OpenSSL project.\n *\n * The ECC Code is licensed pursuant to the OpenSSL open source\n * license provided below.\n *\n * The ECDH software is originally written by Douglas Stebila of\n * Sun Microsystems Laboratories.\n *\n */\n/* ====================================================================\n * Copyright (c) 2000-2002 The OpenSSL Project.  All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n *\n * 1. Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n *\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in\n *    the documentation and/or other materials provided with the\n *    distribution.\n *\n * 3. All advertising materials mentioning features or use of this\n *    software must display the following acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)\"\n *\n * 4. The names \"OpenSSL Toolkit\" and \"OpenSSL Project\" must not be used to\n *    endorse or promote products derived from this software without\n *    prior written permission. For written permission, please contact\n *    licensing@OpenSSL.org.\n *\n * 5. Products derived from this software may not be called \"OpenSSL\"\n *    nor may \"OpenSSL\" appear in their names without prior written\n *    permission of the OpenSSL Project.\n *\n * 6. Redistributions of any form whatsoever must retain the following\n *    acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)\"\n *\n * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY\n * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\n * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR\n * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\n * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,\n * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED\n * OF THE POSSIBILITY OF SUCH DAMAGE.\n * ====================================================================\n *\n * This product includes cryptographic software written by Eric Young\n * (eay@cryptsoft.com).  This product includes software written by Tim\n * Hudson (tjh@cryptsoft.com).\n *\n */\n#ifndef HEADER_ECDH_H\n# define HEADER_ECDH_H\n\n# include <openssl/opensslconf.h>\n\n# ifdef OPENSSL_NO_ECDH\n#  error ECDH is disabled.\n# endif\n\n# include <openssl/ec.h>\n# include <openssl/ossl_typ.h>\n# ifndef OPENSSL_NO_DEPRECATED\n#  include <openssl/bn.h>\n# endif\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n# define EC_FLAG_COFACTOR_ECDH   0x1000\n\nconst ECDH_METHOD *ECDH_OpenSSL(void);\n\nvoid ECDH_set_default_method(const ECDH_METHOD *);\nconst ECDH_METHOD *ECDH_get_default_method(void);\nint ECDH_set_method(EC_KEY *, const ECDH_METHOD *);\n\nint ECDH_compute_key(void *out, size_t outlen, const EC_POINT *pub_key,\n                     EC_KEY *ecdh, void *(*KDF) (const void *in, size_t inlen,\n                                                 void *out, size_t *outlen));\n\nint ECDH_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new\n                          *new_func, CRYPTO_EX_dup *dup_func,\n                          CRYPTO_EX_free *free_func);\nint ECDH_set_ex_data(EC_KEY *d, int idx, void *arg);\nvoid *ECDH_get_ex_data(EC_KEY *d, int idx);\n\nint ECDH_KDF_X9_62(unsigned char *out, size_t outlen,\n                   const unsigned char *Z, size_t Zlen,\n                   const unsigned char *sinfo, size_t sinfolen,\n                   const EVP_MD *md);\n\n/* BEGIN ERROR CODES */\n/*\n * The following lines are auto generated by the script mkerr.pl. Any changes\n * made after this point may be overwritten when the script is next run.\n */\nvoid ERR_load_ECDH_strings(void);\n\n/* Error codes for the ECDH functions. */\n\n/* Function codes. */\n# define ECDH_F_ECDH_CHECK                                102\n# define ECDH_F_ECDH_COMPUTE_KEY                          100\n# define ECDH_F_ECDH_DATA_NEW_METHOD                      101\n\n/* Reason codes. */\n# define ECDH_R_KDF_FAILED                                102\n# define ECDH_R_NON_FIPS_METHOD                           103\n# define ECDH_R_NO_PRIVATE_VALUE                          100\n# define ECDH_R_POINT_ARITHMETIC_FAILURE                  101\n\n#ifdef  __cplusplus\n}\n#endif\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/arm64/include/openssl/ecdsa.h",
    "content": "/* crypto/ecdsa/ecdsa.h */\n/**\n * \\file   crypto/ecdsa/ecdsa.h Include file for the OpenSSL ECDSA functions\n * \\author Written by Nils Larsch for the OpenSSL project\n */\n/* ====================================================================\n * Copyright (c) 2000-2005 The OpenSSL Project.  All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n *\n * 1. Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n *\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in\n *    the documentation and/or other materials provided with the\n *    distribution.\n *\n * 3. All advertising materials mentioning features or use of this\n *    software must display the following acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)\"\n *\n * 4. The names \"OpenSSL Toolkit\" and \"OpenSSL Project\" must not be used to\n *    endorse or promote products derived from this software without\n *    prior written permission. For written permission, please contact\n *    licensing@OpenSSL.org.\n *\n * 5. Products derived from this software may not be called \"OpenSSL\"\n *    nor may \"OpenSSL\" appear in their names without prior written\n *    permission of the OpenSSL Project.\n *\n * 6. Redistributions of any form whatsoever must retain the following\n *    acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)\"\n *\n * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY\n * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\n * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR\n * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\n * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,\n * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED\n * OF THE POSSIBILITY OF SUCH DAMAGE.\n * ====================================================================\n *\n * This product includes cryptographic software written by Eric Young\n * (eay@cryptsoft.com).  This product includes software written by Tim\n * Hudson (tjh@cryptsoft.com).\n *\n */\n#ifndef HEADER_ECDSA_H\n# define HEADER_ECDSA_H\n\n# include <openssl/opensslconf.h>\n\n# ifdef OPENSSL_NO_ECDSA\n#  error ECDSA is disabled.\n# endif\n\n# include <openssl/ec.h>\n# include <openssl/ossl_typ.h>\n# ifndef OPENSSL_NO_DEPRECATED\n#  include <openssl/bn.h>\n# endif\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\ntypedef struct ECDSA_SIG_st {\n    BIGNUM *r;\n    BIGNUM *s;\n} ECDSA_SIG;\n\n/** Allocates and initialize a ECDSA_SIG structure\n *  \\return pointer to a ECDSA_SIG structure or NULL if an error occurred\n */\nECDSA_SIG *ECDSA_SIG_new(void);\n\n/** frees a ECDSA_SIG structure\n *  \\param  sig  pointer to the ECDSA_SIG structure\n */\nvoid ECDSA_SIG_free(ECDSA_SIG *sig);\n\n/** DER encode content of ECDSA_SIG object (note: this function modifies *pp\n *  (*pp += length of the DER encoded signature)).\n *  \\param  sig  pointer to the ECDSA_SIG object\n *  \\param  pp   pointer to a unsigned char pointer for the output or NULL\n *  \\return the length of the DER encoded ECDSA_SIG object or 0\n */\nint i2d_ECDSA_SIG(const ECDSA_SIG *sig, unsigned char **pp);\n\n/** Decodes a DER encoded ECDSA signature (note: this function changes *pp\n *  (*pp += len)).\n *  \\param  sig  pointer to ECDSA_SIG pointer (may be NULL)\n *  \\param  pp   memory buffer with the DER encoded signature\n *  \\param  len  length of the buffer\n *  \\return pointer to the decoded ECDSA_SIG structure (or NULL)\n */\nECDSA_SIG *d2i_ECDSA_SIG(ECDSA_SIG **sig, const unsigned char **pp, long len);\n\n/** Computes the ECDSA signature of the given hash value using\n *  the supplied private key and returns the created signature.\n *  \\param  dgst      pointer to the hash value\n *  \\param  dgst_len  length of the hash value\n *  \\param  eckey     EC_KEY object containing a private EC key\n *  \\return pointer to a ECDSA_SIG structure or NULL if an error occurred\n */\nECDSA_SIG *ECDSA_do_sign(const unsigned char *dgst, int dgst_len,\n                         EC_KEY *eckey);\n\n/** Computes ECDSA signature of a given hash value using the supplied\n *  private key (note: sig must point to ECDSA_size(eckey) bytes of memory).\n *  \\param  dgst     pointer to the hash value to sign\n *  \\param  dgstlen  length of the hash value\n *  \\param  kinv     BIGNUM with a pre-computed inverse k (optional)\n *  \\param  rp       BIGNUM with a pre-computed rp value (optioanl),\n *                   see ECDSA_sign_setup\n *  \\param  eckey    EC_KEY object containing a private EC key\n *  \\return pointer to a ECDSA_SIG structure or NULL if an error occurred\n */\nECDSA_SIG *ECDSA_do_sign_ex(const unsigned char *dgst, int dgstlen,\n                            const BIGNUM *kinv, const BIGNUM *rp,\n                            EC_KEY *eckey);\n\n/** Verifies that the supplied signature is a valid ECDSA\n *  signature of the supplied hash value using the supplied public key.\n *  \\param  dgst      pointer to the hash value\n *  \\param  dgst_len  length of the hash value\n *  \\param  sig       ECDSA_SIG structure\n *  \\param  eckey     EC_KEY object containing a public EC key\n *  \\return 1 if the signature is valid, 0 if the signature is invalid\n *          and -1 on error\n */\nint ECDSA_do_verify(const unsigned char *dgst, int dgst_len,\n                    const ECDSA_SIG *sig, EC_KEY *eckey);\n\nconst ECDSA_METHOD *ECDSA_OpenSSL(void);\n\n/** Sets the default ECDSA method\n *  \\param  meth  new default ECDSA_METHOD\n */\nvoid ECDSA_set_default_method(const ECDSA_METHOD *meth);\n\n/** Returns the default ECDSA method\n *  \\return pointer to ECDSA_METHOD structure containing the default method\n */\nconst ECDSA_METHOD *ECDSA_get_default_method(void);\n\n/** Sets method to be used for the ECDSA operations\n *  \\param  eckey  EC_KEY object\n *  \\param  meth   new method\n *  \\return 1 on success and 0 otherwise\n */\nint ECDSA_set_method(EC_KEY *eckey, const ECDSA_METHOD *meth);\n\n/** Returns the maximum length of the DER encoded signature\n *  \\param  eckey  EC_KEY object\n *  \\return numbers of bytes required for the DER encoded signature\n */\nint ECDSA_size(const EC_KEY *eckey);\n\n/** Precompute parts of the signing operation\n *  \\param  eckey  EC_KEY object containing a private EC key\n *  \\param  ctx    BN_CTX object (optional)\n *  \\param  kinv   BIGNUM pointer for the inverse of k\n *  \\param  rp     BIGNUM pointer for x coordinate of k * generator\n *  \\return 1 on success and 0 otherwise\n */\nint ECDSA_sign_setup(EC_KEY *eckey, BN_CTX *ctx, BIGNUM **kinv, BIGNUM **rp);\n\n/** Computes ECDSA signature of a given hash value using the supplied\n *  private key (note: sig must point to ECDSA_size(eckey) bytes of memory).\n *  \\param  type     this parameter is ignored\n *  \\param  dgst     pointer to the hash value to sign\n *  \\param  dgstlen  length of the hash value\n *  \\param  sig      memory for the DER encoded created signature\n *  \\param  siglen   pointer to the length of the returned signature\n *  \\param  eckey    EC_KEY object containing a private EC key\n *  \\return 1 on success and 0 otherwise\n */\nint ECDSA_sign(int type, const unsigned char *dgst, int dgstlen,\n               unsigned char *sig, unsigned int *siglen, EC_KEY *eckey);\n\n/** Computes ECDSA signature of a given hash value using the supplied\n *  private key (note: sig must point to ECDSA_size(eckey) bytes of memory).\n *  \\param  type     this parameter is ignored\n *  \\param  dgst     pointer to the hash value to sign\n *  \\param  dgstlen  length of the hash value\n *  \\param  sig      buffer to hold the DER encoded signature\n *  \\param  siglen   pointer to the length of the returned signature\n *  \\param  kinv     BIGNUM with a pre-computed inverse k (optional)\n *  \\param  rp       BIGNUM with a pre-computed rp value (optioanl),\n *                   see ECDSA_sign_setup\n *  \\param  eckey    EC_KEY object containing a private EC key\n *  \\return 1 on success and 0 otherwise\n */\nint ECDSA_sign_ex(int type, const unsigned char *dgst, int dgstlen,\n                  unsigned char *sig, unsigned int *siglen,\n                  const BIGNUM *kinv, const BIGNUM *rp, EC_KEY *eckey);\n\n/** Verifies that the given signature is valid ECDSA signature\n *  of the supplied hash value using the specified public key.\n *  \\param  type     this parameter is ignored\n *  \\param  dgst     pointer to the hash value\n *  \\param  dgstlen  length of the hash value\n *  \\param  sig      pointer to the DER encoded signature\n *  \\param  siglen   length of the DER encoded signature\n *  \\param  eckey    EC_KEY object containing a public EC key\n *  \\return 1 if the signature is valid, 0 if the signature is invalid\n *          and -1 on error\n */\nint ECDSA_verify(int type, const unsigned char *dgst, int dgstlen,\n                 const unsigned char *sig, int siglen, EC_KEY *eckey);\n\n/* the standard ex_data functions */\nint ECDSA_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new\n                           *new_func, CRYPTO_EX_dup *dup_func,\n                           CRYPTO_EX_free *free_func);\nint ECDSA_set_ex_data(EC_KEY *d, int idx, void *arg);\nvoid *ECDSA_get_ex_data(EC_KEY *d, int idx);\n\n/** Allocates and initialize a ECDSA_METHOD structure\n *  \\param ecdsa_method pointer to ECDSA_METHOD to copy.  (May be NULL)\n *  \\return pointer to a ECDSA_METHOD structure or NULL if an error occurred\n */\n\nECDSA_METHOD *ECDSA_METHOD_new(const ECDSA_METHOD *ecdsa_method);\n\n/** frees a ECDSA_METHOD structure\n *  \\param  ecdsa_method  pointer to the ECDSA_METHOD structure\n */\nvoid ECDSA_METHOD_free(ECDSA_METHOD *ecdsa_method);\n\n/**  Sets application specific data in the ECDSA_METHOD\n *   \\param  ecdsa_method pointer to existing ECDSA_METHOD\n *   \\param  app application specific data to set\n */\n\nvoid ECDSA_METHOD_set_app_data(ECDSA_METHOD *ecdsa_method, void *app);\n\n/** Returns application specific data from a ECDSA_METHOD structure\n *  \\param ecdsa_method pointer to ECDSA_METHOD structure\n *  \\return pointer to application specific data.\n */\n\nvoid *ECDSA_METHOD_get_app_data(ECDSA_METHOD *ecdsa_method);\n\n/**  Set the ECDSA_do_sign function in the ECDSA_METHOD\n *   \\param  ecdsa_method  pointer to existing ECDSA_METHOD\n *   \\param  ecdsa_do_sign a funtion of type ECDSA_do_sign\n */\n\nvoid ECDSA_METHOD_set_sign(ECDSA_METHOD *ecdsa_method,\n                           ECDSA_SIG *(*ecdsa_do_sign) (const unsigned char\n                                                        *dgst, int dgst_len,\n                                                        const BIGNUM *inv,\n                                                        const BIGNUM *rp,\n                                                        EC_KEY *eckey));\n\n/**  Set the  ECDSA_sign_setup function in the ECDSA_METHOD\n *   \\param  ecdsa_method  pointer to existing ECDSA_METHOD\n *   \\param  ecdsa_sign_setup a funtion of type ECDSA_sign_setup\n */\n\nvoid ECDSA_METHOD_set_sign_setup(ECDSA_METHOD *ecdsa_method,\n                                 int (*ecdsa_sign_setup) (EC_KEY *eckey,\n                                                          BN_CTX *ctx,\n                                                          BIGNUM **kinv,\n                                                          BIGNUM **r));\n\n/**  Set the ECDSA_do_verify function in the ECDSA_METHOD\n *   \\param  ecdsa_method  pointer to existing ECDSA_METHOD\n *   \\param  ecdsa_do_verify a funtion of type ECDSA_do_verify\n */\n\nvoid ECDSA_METHOD_set_verify(ECDSA_METHOD *ecdsa_method,\n                             int (*ecdsa_do_verify) (const unsigned char\n                                                     *dgst, int dgst_len,\n                                                     const ECDSA_SIG *sig,\n                                                     EC_KEY *eckey));\n\nvoid ECDSA_METHOD_set_flags(ECDSA_METHOD *ecdsa_method, int flags);\n\n/**  Set the flags field in the ECDSA_METHOD\n *   \\param  ecdsa_method  pointer to existing ECDSA_METHOD\n *   \\param  flags flags value to set\n */\n\nvoid ECDSA_METHOD_set_name(ECDSA_METHOD *ecdsa_method, char *name);\n\n/**  Set the name field in the ECDSA_METHOD\n *   \\param  ecdsa_method  pointer to existing ECDSA_METHOD\n *   \\param  name name to set\n */\n\n/* BEGIN ERROR CODES */\n/*\n * The following lines are auto generated by the script mkerr.pl. Any changes\n * made after this point may be overwritten when the script is next run.\n */\nvoid ERR_load_ECDSA_strings(void);\n\n/* Error codes for the ECDSA functions. */\n\n/* Function codes. */\n# define ECDSA_F_ECDSA_CHECK                              104\n# define ECDSA_F_ECDSA_DATA_NEW_METHOD                    100\n# define ECDSA_F_ECDSA_DO_SIGN                            101\n# define ECDSA_F_ECDSA_DO_VERIFY                          102\n# define ECDSA_F_ECDSA_METHOD_NEW                         105\n# define ECDSA_F_ECDSA_SIGN_SETUP                         103\n\n/* Reason codes. */\n# define ECDSA_R_BAD_SIGNATURE                            100\n# define ECDSA_R_DATA_TOO_LARGE_FOR_KEY_SIZE              101\n# define ECDSA_R_ERR_EC_LIB                               102\n# define ECDSA_R_MISSING_PARAMETERS                       103\n# define ECDSA_R_NEED_NEW_SETUP_VALUES                    106\n# define ECDSA_R_NON_FIPS_METHOD                          107\n# define ECDSA_R_RANDOM_NUMBER_GENERATION_FAILED          104\n# define ECDSA_R_SIGNATURE_MALLOC_FAILED                  105\n\n#ifdef  __cplusplus\n}\n#endif\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/arm64/include/openssl/err.h",
    "content": "/* crypto/err/err.h */\n/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)\n * All rights reserved.\n *\n * This package is an SSL implementation written\n * by Eric Young (eay@cryptsoft.com).\n * The implementation was written so as to conform with Netscapes SSL.\n *\n * This library is free for commercial and non-commercial use as long as\n * the following conditions are aheared to.  The following conditions\n * apply to all code found in this distribution, be it the RC4, RSA,\n * lhash, DES, etc., code; not just the SSL code.  The SSL documentation\n * included with this distribution is covered by the same copyright terms\n * except that the holder is Tim Hudson (tjh@cryptsoft.com).\n *\n * Copyright remains Eric Young's, and as such any Copyright notices in\n * the code are not to be removed.\n * If this package is used in a product, Eric Young should be given attribution\n * as the author of the parts of the library used.\n * This can be in the form of a textual message at program startup or\n * in documentation (online or textual) provided with the package.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the copyright\n *    notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in the\n *    documentation and/or other materials provided with the distribution.\n * 3. All advertising materials mentioning features or use of this software\n *    must display the following acknowledgement:\n *    \"This product includes cryptographic software written by\n *     Eric Young (eay@cryptsoft.com)\"\n *    The word 'cryptographic' can be left out if the rouines from the library\n *    being used are not cryptographic related :-).\n * 4. If you include any Windows specific code (or a derivative thereof) from\n *    the apps directory (application code) you must include an acknowledgement:\n *    \"This product includes software written by Tim Hudson (tjh@cryptsoft.com)\"\n *\n * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n * SUCH DAMAGE.\n *\n * The licence and distribution terms for any publically available version or\n * derivative of this code cannot be changed.  i.e. this code cannot simply be\n * copied and put under another distribution licence\n * [including the GNU Public Licence.]\n */\n/* ====================================================================\n * Copyright (c) 1998-2006 The OpenSSL Project.  All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n *\n * 1. Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n *\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in\n *    the documentation and/or other materials provided with the\n *    distribution.\n *\n * 3. All advertising materials mentioning features or use of this\n *    software must display the following acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit. (http://www.openssl.org/)\"\n *\n * 4. The names \"OpenSSL Toolkit\" and \"OpenSSL Project\" must not be used to\n *    endorse or promote products derived from this software without\n *    prior written permission. For written permission, please contact\n *    openssl-core@openssl.org.\n *\n * 5. Products derived from this software may not be called \"OpenSSL\"\n *    nor may \"OpenSSL\" appear in their names without prior written\n *    permission of the OpenSSL Project.\n *\n * 6. Redistributions of any form whatsoever must retain the following\n *    acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit (http://www.openssl.org/)\"\n *\n * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY\n * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\n * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR\n * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\n * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,\n * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED\n * OF THE POSSIBILITY OF SUCH DAMAGE.\n * ====================================================================\n *\n * This product includes cryptographic software written by Eric Young\n * (eay@cryptsoft.com).  This product includes software written by Tim\n * Hudson (tjh@cryptsoft.com).\n *\n */\n\n#ifndef HEADER_ERR_H\n# define HEADER_ERR_H\n\n# include <openssl/e_os2.h>\n\n# ifndef OPENSSL_NO_FP_API\n#  include <stdio.h>\n#  include <stdlib.h>\n# endif\n\n# include <openssl/ossl_typ.h>\n# ifndef OPENSSL_NO_BIO\n#  include <openssl/bio.h>\n# endif\n# ifndef OPENSSL_NO_LHASH\n#  include <openssl/lhash.h>\n# endif\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n# ifndef OPENSSL_NO_ERR\n#  define ERR_PUT_error(a,b,c,d,e)        ERR_put_error(a,b,c,d,e)\n# else\n#  define ERR_PUT_error(a,b,c,d,e)        ERR_put_error(a,b,c,NULL,0)\n# endif\n\n# include <errno.h>\n\n# define ERR_TXT_MALLOCED        0x01\n# define ERR_TXT_STRING          0x02\n\n# define ERR_FLAG_MARK           0x01\n\n# define ERR_NUM_ERRORS  16\ntypedef struct err_state_st {\n    CRYPTO_THREADID tid;\n    int err_flags[ERR_NUM_ERRORS];\n    unsigned long err_buffer[ERR_NUM_ERRORS];\n    char *err_data[ERR_NUM_ERRORS];\n    int err_data_flags[ERR_NUM_ERRORS];\n    const char *err_file[ERR_NUM_ERRORS];\n    int err_line[ERR_NUM_ERRORS];\n    int top, bottom;\n} ERR_STATE;\n\n/* library */\n# define ERR_LIB_NONE            1\n# define ERR_LIB_SYS             2\n# define ERR_LIB_BN              3\n# define ERR_LIB_RSA             4\n# define ERR_LIB_DH              5\n# define ERR_LIB_EVP             6\n# define ERR_LIB_BUF             7\n# define ERR_LIB_OBJ             8\n# define ERR_LIB_PEM             9\n# define ERR_LIB_DSA             10\n# define ERR_LIB_X509            11\n/* #define ERR_LIB_METH         12 */\n# define ERR_LIB_ASN1            13\n# define ERR_LIB_CONF            14\n# define ERR_LIB_CRYPTO          15\n# define ERR_LIB_EC              16\n# define ERR_LIB_SSL             20\n/* #define ERR_LIB_SSL23        21 */\n/* #define ERR_LIB_SSL2         22 */\n/* #define ERR_LIB_SSL3         23 */\n/* #define ERR_LIB_RSAREF       30 */\n/* #define ERR_LIB_PROXY        31 */\n# define ERR_LIB_BIO             32\n# define ERR_LIB_PKCS7           33\n# define ERR_LIB_X509V3          34\n# define ERR_LIB_PKCS12          35\n# define ERR_LIB_RAND            36\n# define ERR_LIB_DSO             37\n# define ERR_LIB_ENGINE          38\n# define ERR_LIB_OCSP            39\n# define ERR_LIB_UI              40\n# define ERR_LIB_COMP            41\n# define ERR_LIB_ECDSA           42\n# define ERR_LIB_ECDH            43\n# define ERR_LIB_STORE           44\n# define ERR_LIB_FIPS            45\n# define ERR_LIB_CMS             46\n# define ERR_LIB_TS              47\n# define ERR_LIB_HMAC            48\n# define ERR_LIB_JPAKE           49\n\n# define ERR_LIB_USER            128\n\n# define SYSerr(f,r)  ERR_PUT_error(ERR_LIB_SYS,(f),(r),__FILE__,__LINE__)\n# define BNerr(f,r)   ERR_PUT_error(ERR_LIB_BN,(f),(r),__FILE__,__LINE__)\n# define RSAerr(f,r)  ERR_PUT_error(ERR_LIB_RSA,(f),(r),__FILE__,__LINE__)\n# define DHerr(f,r)   ERR_PUT_error(ERR_LIB_DH,(f),(r),__FILE__,__LINE__)\n# define EVPerr(f,r)  ERR_PUT_error(ERR_LIB_EVP,(f),(r),__FILE__,__LINE__)\n# define BUFerr(f,r)  ERR_PUT_error(ERR_LIB_BUF,(f),(r),__FILE__,__LINE__)\n# define OBJerr(f,r)  ERR_PUT_error(ERR_LIB_OBJ,(f),(r),__FILE__,__LINE__)\n# define PEMerr(f,r)  ERR_PUT_error(ERR_LIB_PEM,(f),(r),__FILE__,__LINE__)\n# define DSAerr(f,r)  ERR_PUT_error(ERR_LIB_DSA,(f),(r),__FILE__,__LINE__)\n# define X509err(f,r) ERR_PUT_error(ERR_LIB_X509,(f),(r),__FILE__,__LINE__)\n# define ASN1err(f,r) ERR_PUT_error(ERR_LIB_ASN1,(f),(r),__FILE__,__LINE__)\n# define CONFerr(f,r) ERR_PUT_error(ERR_LIB_CONF,(f),(r),__FILE__,__LINE__)\n# define CRYPTOerr(f,r) ERR_PUT_error(ERR_LIB_CRYPTO,(f),(r),__FILE__,__LINE__)\n# define ECerr(f,r)   ERR_PUT_error(ERR_LIB_EC,(f),(r),__FILE__,__LINE__)\n# define SSLerr(f,r)  ERR_PUT_error(ERR_LIB_SSL,(f),(r),__FILE__,__LINE__)\n# define BIOerr(f,r)  ERR_PUT_error(ERR_LIB_BIO,(f),(r),__FILE__,__LINE__)\n# define PKCS7err(f,r) ERR_PUT_error(ERR_LIB_PKCS7,(f),(r),__FILE__,__LINE__)\n# define X509V3err(f,r) ERR_PUT_error(ERR_LIB_X509V3,(f),(r),__FILE__,__LINE__)\n# define PKCS12err(f,r) ERR_PUT_error(ERR_LIB_PKCS12,(f),(r),__FILE__,__LINE__)\n# define RANDerr(f,r) ERR_PUT_error(ERR_LIB_RAND,(f),(r),__FILE__,__LINE__)\n# define DSOerr(f,r) ERR_PUT_error(ERR_LIB_DSO,(f),(r),__FILE__,__LINE__)\n# define ENGINEerr(f,r) ERR_PUT_error(ERR_LIB_ENGINE,(f),(r),__FILE__,__LINE__)\n# define OCSPerr(f,r) ERR_PUT_error(ERR_LIB_OCSP,(f),(r),__FILE__,__LINE__)\n# define UIerr(f,r) ERR_PUT_error(ERR_LIB_UI,(f),(r),__FILE__,__LINE__)\n# define COMPerr(f,r) ERR_PUT_error(ERR_LIB_COMP,(f),(r),__FILE__,__LINE__)\n# define ECDSAerr(f,r)  ERR_PUT_error(ERR_LIB_ECDSA,(f),(r),__FILE__,__LINE__)\n# define ECDHerr(f,r)  ERR_PUT_error(ERR_LIB_ECDH,(f),(r),__FILE__,__LINE__)\n# define STOREerr(f,r) ERR_PUT_error(ERR_LIB_STORE,(f),(r),__FILE__,__LINE__)\n# define FIPSerr(f,r) ERR_PUT_error(ERR_LIB_FIPS,(f),(r),__FILE__,__LINE__)\n# define CMSerr(f,r) ERR_PUT_error(ERR_LIB_CMS,(f),(r),__FILE__,__LINE__)\n# define TSerr(f,r) ERR_PUT_error(ERR_LIB_TS,(f),(r),__FILE__,__LINE__)\n# define HMACerr(f,r) ERR_PUT_error(ERR_LIB_HMAC,(f),(r),__FILE__,__LINE__)\n# define JPAKEerr(f,r) ERR_PUT_error(ERR_LIB_JPAKE,(f),(r),__FILE__,__LINE__)\n\n/*\n * Borland C seems too stupid to be able to shift and do longs in the\n * pre-processor :-(\n */\n# define ERR_PACK(l,f,r)         (((((unsigned long)l)&0xffL)*0x1000000)| \\\n                                ((((unsigned long)f)&0xfffL)*0x1000)| \\\n                                ((((unsigned long)r)&0xfffL)))\n# define ERR_GET_LIB(l)          (int)((((unsigned long)l)>>24L)&0xffL)\n# define ERR_GET_FUNC(l)         (int)((((unsigned long)l)>>12L)&0xfffL)\n# define ERR_GET_REASON(l)       (int)((l)&0xfffL)\n# define ERR_FATAL_ERROR(l)      (int)((l)&ERR_R_FATAL)\n\n/* OS functions */\n# define SYS_F_FOPEN             1\n# define SYS_F_CONNECT           2\n# define SYS_F_GETSERVBYNAME     3\n# define SYS_F_SOCKET            4\n# define SYS_F_IOCTLSOCKET       5\n# define SYS_F_BIND              6\n# define SYS_F_LISTEN            7\n# define SYS_F_ACCEPT            8\n# define SYS_F_WSASTARTUP        9/* Winsock stuff */\n# define SYS_F_OPENDIR           10\n# define SYS_F_FREAD             11\n\n/* reasons */\n# define ERR_R_SYS_LIB   ERR_LIB_SYS/* 2 */\n# define ERR_R_BN_LIB    ERR_LIB_BN/* 3 */\n# define ERR_R_RSA_LIB   ERR_LIB_RSA/* 4 */\n# define ERR_R_DH_LIB    ERR_LIB_DH/* 5 */\n# define ERR_R_EVP_LIB   ERR_LIB_EVP/* 6 */\n# define ERR_R_BUF_LIB   ERR_LIB_BUF/* 7 */\n# define ERR_R_OBJ_LIB   ERR_LIB_OBJ/* 8 */\n# define ERR_R_PEM_LIB   ERR_LIB_PEM/* 9 */\n# define ERR_R_DSA_LIB   ERR_LIB_DSA/* 10 */\n# define ERR_R_X509_LIB  ERR_LIB_X509/* 11 */\n# define ERR_R_ASN1_LIB  ERR_LIB_ASN1/* 13 */\n# define ERR_R_CONF_LIB  ERR_LIB_CONF/* 14 */\n# define ERR_R_CRYPTO_LIB ERR_LIB_CRYPTO/* 15 */\n# define ERR_R_EC_LIB    ERR_LIB_EC/* 16 */\n# define ERR_R_SSL_LIB   ERR_LIB_SSL/* 20 */\n# define ERR_R_BIO_LIB   ERR_LIB_BIO/* 32 */\n# define ERR_R_PKCS7_LIB ERR_LIB_PKCS7/* 33 */\n# define ERR_R_X509V3_LIB ERR_LIB_X509V3/* 34 */\n# define ERR_R_PKCS12_LIB ERR_LIB_PKCS12/* 35 */\n# define ERR_R_RAND_LIB  ERR_LIB_RAND/* 36 */\n# define ERR_R_DSO_LIB   ERR_LIB_DSO/* 37 */\n# define ERR_R_ENGINE_LIB ERR_LIB_ENGINE/* 38 */\n# define ERR_R_OCSP_LIB  ERR_LIB_OCSP/* 39 */\n# define ERR_R_UI_LIB    ERR_LIB_UI/* 40 */\n# define ERR_R_COMP_LIB  ERR_LIB_COMP/* 41 */\n# define ERR_R_ECDSA_LIB ERR_LIB_ECDSA/* 42 */\n# define ERR_R_ECDH_LIB  ERR_LIB_ECDH/* 43 */\n# define ERR_R_STORE_LIB ERR_LIB_STORE/* 44 */\n# define ERR_R_TS_LIB    ERR_LIB_TS/* 45 */\n\n# define ERR_R_NESTED_ASN1_ERROR                 58\n# define ERR_R_BAD_ASN1_OBJECT_HEADER            59\n# define ERR_R_BAD_GET_ASN1_OBJECT_CALL          60\n# define ERR_R_EXPECTING_AN_ASN1_SEQUENCE        61\n# define ERR_R_ASN1_LENGTH_MISMATCH              62\n# define ERR_R_MISSING_ASN1_EOS                  63\n\n/* fatal error */\n# define ERR_R_FATAL                             64\n# define ERR_R_MALLOC_FAILURE                    (1|ERR_R_FATAL)\n# define ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED       (2|ERR_R_FATAL)\n# define ERR_R_PASSED_NULL_PARAMETER             (3|ERR_R_FATAL)\n# define ERR_R_INTERNAL_ERROR                    (4|ERR_R_FATAL)\n# define ERR_R_DISABLED                          (5|ERR_R_FATAL)\n\n/*\n * 99 is the maximum possible ERR_R_... code, higher values are reserved for\n * the individual libraries\n */\n\ntypedef struct ERR_string_data_st {\n    unsigned long error;\n    const char *string;\n} ERR_STRING_DATA;\n\nvoid ERR_put_error(int lib, int func, int reason, const char *file, int line);\nvoid ERR_set_error_data(char *data, int flags);\n\nunsigned long ERR_get_error(void);\nunsigned long ERR_get_error_line(const char **file, int *line);\nunsigned long ERR_get_error_line_data(const char **file, int *line,\n                                      const char **data, int *flags);\nunsigned long ERR_peek_error(void);\nunsigned long ERR_peek_error_line(const char **file, int *line);\nunsigned long ERR_peek_error_line_data(const char **file, int *line,\n                                       const char **data, int *flags);\nunsigned long ERR_peek_last_error(void);\nunsigned long ERR_peek_last_error_line(const char **file, int *line);\nunsigned long ERR_peek_last_error_line_data(const char **file, int *line,\n                                            const char **data, int *flags);\nvoid ERR_clear_error(void);\nchar *ERR_error_string(unsigned long e, char *buf);\nvoid ERR_error_string_n(unsigned long e, char *buf, size_t len);\nconst char *ERR_lib_error_string(unsigned long e);\nconst char *ERR_func_error_string(unsigned long e);\nconst char *ERR_reason_error_string(unsigned long e);\nvoid ERR_print_errors_cb(int (*cb) (const char *str, size_t len, void *u),\n                         void *u);\n# ifndef OPENSSL_NO_FP_API\nvoid ERR_print_errors_fp(FILE *fp);\n# endif\n# ifndef OPENSSL_NO_BIO\nvoid ERR_print_errors(BIO *bp);\n# endif\nvoid ERR_add_error_data(int num, ...);\nvoid ERR_add_error_vdata(int num, va_list args);\nvoid ERR_load_strings(int lib, ERR_STRING_DATA str[]);\nvoid ERR_unload_strings(int lib, ERR_STRING_DATA str[]);\nvoid ERR_load_ERR_strings(void);\nvoid ERR_load_crypto_strings(void);\nvoid ERR_free_strings(void);\n\nvoid ERR_remove_thread_state(const CRYPTO_THREADID *tid);\n# ifndef OPENSSL_NO_DEPRECATED\nvoid ERR_remove_state(unsigned long pid); /* if zero we look it up */\n# endif\nERR_STATE *ERR_get_state(void);\n\n# ifndef OPENSSL_NO_LHASH\nLHASH_OF(ERR_STRING_DATA) *ERR_get_string_table(void);\nLHASH_OF(ERR_STATE) *ERR_get_err_state_table(void);\nvoid ERR_release_err_state_table(LHASH_OF(ERR_STATE) **hash);\n# endif\n\nint ERR_get_next_error_library(void);\n\nint ERR_set_mark(void);\nint ERR_pop_to_mark(void);\n\n/* Already defined in ossl_typ.h */\n/* typedef struct st_ERR_FNS ERR_FNS; */\n/*\n * An application can use this function and provide the return value to\n * loaded modules that should use the application's ERR state/functionality\n */\nconst ERR_FNS *ERR_get_implementation(void);\n/*\n * A loaded module should call this function prior to any ERR operations\n * using the application's \"ERR_FNS\".\n */\nint ERR_set_implementation(const ERR_FNS *fns);\n\n#ifdef  __cplusplus\n}\n#endif\n\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/arm64/include/openssl/evp.h",
    "content": "/* crypto/evp/evp.h */\n/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)\n * All rights reserved.\n *\n * This package is an SSL implementation written\n * by Eric Young (eay@cryptsoft.com).\n * The implementation was written so as to conform with Netscapes SSL.\n *\n * This library is free for commercial and non-commercial use as long as\n * the following conditions are aheared to.  The following conditions\n * apply to all code found in this distribution, be it the RC4, RSA,\n * lhash, DES, etc., code; not just the SSL code.  The SSL documentation\n * included with this distribution is covered by the same copyright terms\n * except that the holder is Tim Hudson (tjh@cryptsoft.com).\n *\n * Copyright remains Eric Young's, and as such any Copyright notices in\n * the code are not to be removed.\n * If this package is used in a product, Eric Young should be given attribution\n * as the author of the parts of the library used.\n * This can be in the form of a textual message at program startup or\n * in documentation (online or textual) provided with the package.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the copyright\n *    notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in the\n *    documentation and/or other materials provided with the distribution.\n * 3. All advertising materials mentioning features or use of this software\n *    must display the following acknowledgement:\n *    \"This product includes cryptographic software written by\n *     Eric Young (eay@cryptsoft.com)\"\n *    The word 'cryptographic' can be left out if the rouines from the library\n *    being used are not cryptographic related :-).\n * 4. If you include any Windows specific code (or a derivative thereof) from\n *    the apps directory (application code) you must include an acknowledgement:\n *    \"This product includes software written by Tim Hudson (tjh@cryptsoft.com)\"\n *\n * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n * SUCH DAMAGE.\n *\n * The licence and distribution terms for any publically available version or\n * derivative of this code cannot be changed.  i.e. this code cannot simply be\n * copied and put under another distribution licence\n * [including the GNU Public Licence.]\n */\n\n#ifndef HEADER_ENVELOPE_H\n# define HEADER_ENVELOPE_H\n\n# ifdef OPENSSL_ALGORITHM_DEFINES\n#  include <openssl/opensslconf.h>\n# else\n#  define OPENSSL_ALGORITHM_DEFINES\n#  include <openssl/opensslconf.h>\n#  undef OPENSSL_ALGORITHM_DEFINES\n# endif\n\n# include <openssl/ossl_typ.h>\n\n# include <openssl/symhacks.h>\n\n# ifndef OPENSSL_NO_BIO\n#  include <openssl/bio.h>\n# endif\n\n/*-\n#define EVP_RC2_KEY_SIZE                16\n#define EVP_RC4_KEY_SIZE                16\n#define EVP_BLOWFISH_KEY_SIZE           16\n#define EVP_CAST5_KEY_SIZE              16\n#define EVP_RC5_32_12_16_KEY_SIZE       16\n*/\n# define EVP_MAX_MD_SIZE                 64/* longest known is SHA512 */\n# define EVP_MAX_KEY_LENGTH              64\n# define EVP_MAX_IV_LENGTH               16\n# define EVP_MAX_BLOCK_LENGTH            32\n\n# define PKCS5_SALT_LEN                  8\n/* Default PKCS#5 iteration count */\n# define PKCS5_DEFAULT_ITER              2048\n\n# include <openssl/objects.h>\n\n# define EVP_PK_RSA      0x0001\n# define EVP_PK_DSA      0x0002\n# define EVP_PK_DH       0x0004\n# define EVP_PK_EC       0x0008\n# define EVP_PKT_SIGN    0x0010\n# define EVP_PKT_ENC     0x0020\n# define EVP_PKT_EXCH    0x0040\n# define EVP_PKS_RSA     0x0100\n# define EVP_PKS_DSA     0x0200\n# define EVP_PKS_EC      0x0400\n\n# define EVP_PKEY_NONE   NID_undef\n# define EVP_PKEY_RSA    NID_rsaEncryption\n# define EVP_PKEY_RSA2   NID_rsa\n# define EVP_PKEY_DSA    NID_dsa\n# define EVP_PKEY_DSA1   NID_dsa_2\n# define EVP_PKEY_DSA2   NID_dsaWithSHA\n# define EVP_PKEY_DSA3   NID_dsaWithSHA1\n# define EVP_PKEY_DSA4   NID_dsaWithSHA1_2\n# define EVP_PKEY_DH     NID_dhKeyAgreement\n# define EVP_PKEY_DHX    NID_dhpublicnumber\n# define EVP_PKEY_EC     NID_X9_62_id_ecPublicKey\n# define EVP_PKEY_HMAC   NID_hmac\n# define EVP_PKEY_CMAC   NID_cmac\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n/*\n * Type needs to be a bit field Sub-type needs to be for variations on the\n * method, as in, can it do arbitrary encryption....\n */\nstruct evp_pkey_st {\n    int type;\n    int save_type;\n    int references;\n    const EVP_PKEY_ASN1_METHOD *ameth;\n    ENGINE *engine;\n    union {\n        char *ptr;\n# ifndef OPENSSL_NO_RSA\n        struct rsa_st *rsa;     /* RSA */\n# endif\n# ifndef OPENSSL_NO_DSA\n        struct dsa_st *dsa;     /* DSA */\n# endif\n# ifndef OPENSSL_NO_DH\n        struct dh_st *dh;       /* DH */\n# endif\n# ifndef OPENSSL_NO_EC\n        struct ec_key_st *ec;   /* ECC */\n# endif\n    } pkey;\n    int save_parameters;\n    STACK_OF(X509_ATTRIBUTE) *attributes; /* [ 0 ] */\n} /* EVP_PKEY */ ;\n\n# define EVP_PKEY_MO_SIGN        0x0001\n# define EVP_PKEY_MO_VERIFY      0x0002\n# define EVP_PKEY_MO_ENCRYPT     0x0004\n# define EVP_PKEY_MO_DECRYPT     0x0008\n\n# ifndef EVP_MD\nstruct env_md_st {\n    int type;\n    int pkey_type;\n    int md_size;\n    unsigned long flags;\n    int (*init) (EVP_MD_CTX *ctx);\n    int (*update) (EVP_MD_CTX *ctx, const void *data, size_t count);\n    int (*final) (EVP_MD_CTX *ctx, unsigned char *md);\n    int (*copy) (EVP_MD_CTX *to, const EVP_MD_CTX *from);\n    int (*cleanup) (EVP_MD_CTX *ctx);\n    /* FIXME: prototype these some day */\n    int (*sign) (int type, const unsigned char *m, unsigned int m_length,\n                 unsigned char *sigret, unsigned int *siglen, void *key);\n    int (*verify) (int type, const unsigned char *m, unsigned int m_length,\n                   const unsigned char *sigbuf, unsigned int siglen,\n                   void *key);\n    int required_pkey_type[5];  /* EVP_PKEY_xxx */\n    int block_size;\n    int ctx_size;               /* how big does the ctx->md_data need to be */\n    /* control function */\n    int (*md_ctrl) (EVP_MD_CTX *ctx, int cmd, int p1, void *p2);\n} /* EVP_MD */ ;\n\ntypedef int evp_sign_method(int type, const unsigned char *m,\n                            unsigned int m_length, unsigned char *sigret,\n                            unsigned int *siglen, void *key);\ntypedef int evp_verify_method(int type, const unsigned char *m,\n                              unsigned int m_length,\n                              const unsigned char *sigbuf,\n                              unsigned int siglen, void *key);\n\n/* digest can only handle a single block */\n#  define EVP_MD_FLAG_ONESHOT     0x0001\n\n/*\n * digest is a \"clone\" digest used\n * which is a copy of an existing\n * one for a specific public key type.\n * EVP_dss1() etc\n */\n#  define EVP_MD_FLAG_PKEY_DIGEST 0x0002\n\n/* Digest uses EVP_PKEY_METHOD for signing instead of MD specific signing */\n\n#  define EVP_MD_FLAG_PKEY_METHOD_SIGNATURE       0x0004\n\n/* DigestAlgorithmIdentifier flags... */\n\n#  define EVP_MD_FLAG_DIGALGID_MASK               0x0018\n\n/* NULL or absent parameter accepted. Use NULL */\n\n#  define EVP_MD_FLAG_DIGALGID_NULL               0x0000\n\n/* NULL or absent parameter accepted. Use NULL for PKCS#1 otherwise absent */\n\n#  define EVP_MD_FLAG_DIGALGID_ABSENT             0x0008\n\n/* Custom handling via ctrl */\n\n#  define EVP_MD_FLAG_DIGALGID_CUSTOM             0x0018\n\n/* Note if suitable for use in FIPS mode */\n#  define EVP_MD_FLAG_FIPS        0x0400\n\n/* Digest ctrls */\n\n#  define EVP_MD_CTRL_DIGALGID                    0x1\n#  define EVP_MD_CTRL_MICALG                      0x2\n\n/* Minimum Algorithm specific ctrl value */\n\n#  define EVP_MD_CTRL_ALG_CTRL                    0x1000\n\n#  define EVP_PKEY_NULL_method    NULL,NULL,{0,0,0,0}\n\n#  ifndef OPENSSL_NO_DSA\n#   define EVP_PKEY_DSA_method     (evp_sign_method *)DSA_sign, \\\n                                (evp_verify_method *)DSA_verify, \\\n                                {EVP_PKEY_DSA,EVP_PKEY_DSA2,EVP_PKEY_DSA3, \\\n                                        EVP_PKEY_DSA4,0}\n#  else\n#   define EVP_PKEY_DSA_method     EVP_PKEY_NULL_method\n#  endif\n\n#  ifndef OPENSSL_NO_ECDSA\n#   define EVP_PKEY_ECDSA_method   (evp_sign_method *)ECDSA_sign, \\\n                                (evp_verify_method *)ECDSA_verify, \\\n                                 {EVP_PKEY_EC,0,0,0}\n#  else\n#   define EVP_PKEY_ECDSA_method   EVP_PKEY_NULL_method\n#  endif\n\n#  ifndef OPENSSL_NO_RSA\n#   define EVP_PKEY_RSA_method     (evp_sign_method *)RSA_sign, \\\n                                (evp_verify_method *)RSA_verify, \\\n                                {EVP_PKEY_RSA,EVP_PKEY_RSA2,0,0}\n#   define EVP_PKEY_RSA_ASN1_OCTET_STRING_method \\\n                                (evp_sign_method *)RSA_sign_ASN1_OCTET_STRING, \\\n                                (evp_verify_method *)RSA_verify_ASN1_OCTET_STRING, \\\n                                {EVP_PKEY_RSA,EVP_PKEY_RSA2,0,0}\n#  else\n#   define EVP_PKEY_RSA_method     EVP_PKEY_NULL_method\n#   define EVP_PKEY_RSA_ASN1_OCTET_STRING_method EVP_PKEY_NULL_method\n#  endif\n\n# endif                         /* !EVP_MD */\n\nstruct env_md_ctx_st {\n    const EVP_MD *digest;\n    ENGINE *engine;             /* functional reference if 'digest' is\n                                 * ENGINE-provided */\n    unsigned long flags;\n    void *md_data;\n    /* Public key context for sign/verify */\n    EVP_PKEY_CTX *pctx;\n    /* Update function: usually copied from EVP_MD */\n    int (*update) (EVP_MD_CTX *ctx, const void *data, size_t count);\n} /* EVP_MD_CTX */ ;\n\n/* values for EVP_MD_CTX flags */\n\n# define EVP_MD_CTX_FLAG_ONESHOT         0x0001/* digest update will be\n                                                * called once only */\n# define EVP_MD_CTX_FLAG_CLEANED         0x0002/* context has already been\n                                                * cleaned */\n# define EVP_MD_CTX_FLAG_REUSE           0x0004/* Don't free up ctx->md_data\n                                                * in EVP_MD_CTX_cleanup */\n/*\n * FIPS and pad options are ignored in 1.0.0, definitions are here so we\n * don't accidentally reuse the values for other purposes.\n */\n\n# define EVP_MD_CTX_FLAG_NON_FIPS_ALLOW  0x0008/* Allow use of non FIPS\n                                                * digest in FIPS mode */\n\n/*\n * The following PAD options are also currently ignored in 1.0.0, digest\n * parameters are handled through EVP_DigestSign*() and EVP_DigestVerify*()\n * instead.\n */\n# define EVP_MD_CTX_FLAG_PAD_MASK        0xF0/* RSA mode to use */\n# define EVP_MD_CTX_FLAG_PAD_PKCS1       0x00/* PKCS#1 v1.5 mode */\n# define EVP_MD_CTX_FLAG_PAD_X931        0x10/* X9.31 mode */\n# define EVP_MD_CTX_FLAG_PAD_PSS         0x20/* PSS mode */\n\n# define EVP_MD_CTX_FLAG_NO_INIT         0x0100/* Don't initialize md_data */\n\nstruct evp_cipher_st {\n    int nid;\n    int block_size;\n    /* Default value for variable length ciphers */\n    int key_len;\n    int iv_len;\n    /* Various flags */\n    unsigned long flags;\n    /* init key */\n    int (*init) (EVP_CIPHER_CTX *ctx, const unsigned char *key,\n                 const unsigned char *iv, int enc);\n    /* encrypt/decrypt data */\n    int (*do_cipher) (EVP_CIPHER_CTX *ctx, unsigned char *out,\n                      const unsigned char *in, size_t inl);\n    /* cleanup ctx */\n    int (*cleanup) (EVP_CIPHER_CTX *);\n    /* how big ctx->cipher_data needs to be */\n    int ctx_size;\n    /* Populate a ASN1_TYPE with parameters */\n    int (*set_asn1_parameters) (EVP_CIPHER_CTX *, ASN1_TYPE *);\n    /* Get parameters from a ASN1_TYPE */\n    int (*get_asn1_parameters) (EVP_CIPHER_CTX *, ASN1_TYPE *);\n    /* Miscellaneous operations */\n    int (*ctrl) (EVP_CIPHER_CTX *, int type, int arg, void *ptr);\n    /* Application data */\n    void *app_data;\n} /* EVP_CIPHER */ ;\n\n/* Values for cipher flags */\n\n/* Modes for ciphers */\n\n# define         EVP_CIPH_STREAM_CIPHER          0x0\n# define         EVP_CIPH_ECB_MODE               0x1\n# define         EVP_CIPH_CBC_MODE               0x2\n# define         EVP_CIPH_CFB_MODE               0x3\n# define         EVP_CIPH_OFB_MODE               0x4\n# define         EVP_CIPH_CTR_MODE               0x5\n# define         EVP_CIPH_GCM_MODE               0x6\n# define         EVP_CIPH_CCM_MODE               0x7\n# define         EVP_CIPH_XTS_MODE               0x10001\n# define         EVP_CIPH_WRAP_MODE              0x10002\n# define         EVP_CIPH_MODE                   0xF0007\n/* Set if variable length cipher */\n# define         EVP_CIPH_VARIABLE_LENGTH        0x8\n/* Set if the iv handling should be done by the cipher itself */\n# define         EVP_CIPH_CUSTOM_IV              0x10\n/* Set if the cipher's init() function should be called if key is NULL */\n# define         EVP_CIPH_ALWAYS_CALL_INIT       0x20\n/* Call ctrl() to init cipher parameters */\n# define         EVP_CIPH_CTRL_INIT              0x40\n/* Don't use standard key length function */\n# define         EVP_CIPH_CUSTOM_KEY_LENGTH      0x80\n/* Don't use standard block padding */\n# define         EVP_CIPH_NO_PADDING             0x100\n/* cipher handles random key generation */\n# define         EVP_CIPH_RAND_KEY               0x200\n/* cipher has its own additional copying logic */\n# define         EVP_CIPH_CUSTOM_COPY            0x400\n/* Allow use default ASN1 get/set iv */\n# define         EVP_CIPH_FLAG_DEFAULT_ASN1      0x1000\n/* Buffer length in bits not bytes: CFB1 mode only */\n# define         EVP_CIPH_FLAG_LENGTH_BITS       0x2000\n/* Note if suitable for use in FIPS mode */\n# define         EVP_CIPH_FLAG_FIPS              0x4000\n/* Allow non FIPS cipher in FIPS mode */\n# define         EVP_CIPH_FLAG_NON_FIPS_ALLOW    0x8000\n/*\n * Cipher handles any and all padding logic as well as finalisation.\n */\n# define         EVP_CIPH_FLAG_CUSTOM_CIPHER     0x100000\n# define         EVP_CIPH_FLAG_AEAD_CIPHER       0x200000\n# define         EVP_CIPH_FLAG_TLS1_1_MULTIBLOCK 0x400000\n\n/*\n * Cipher context flag to indicate we can handle wrap mode: if allowed in\n * older applications it could overflow buffers.\n */\n\n# define         EVP_CIPHER_CTX_FLAG_WRAP_ALLOW  0x1\n\n/* ctrl() values */\n\n# define         EVP_CTRL_INIT                   0x0\n# define         EVP_CTRL_SET_KEY_LENGTH         0x1\n# define         EVP_CTRL_GET_RC2_KEY_BITS       0x2\n# define         EVP_CTRL_SET_RC2_KEY_BITS       0x3\n# define         EVP_CTRL_GET_RC5_ROUNDS         0x4\n# define         EVP_CTRL_SET_RC5_ROUNDS         0x5\n# define         EVP_CTRL_RAND_KEY               0x6\n# define         EVP_CTRL_PBE_PRF_NID            0x7\n# define         EVP_CTRL_COPY                   0x8\n# define         EVP_CTRL_GCM_SET_IVLEN          0x9\n# define         EVP_CTRL_GCM_GET_TAG            0x10\n# define         EVP_CTRL_GCM_SET_TAG            0x11\n# define         EVP_CTRL_GCM_SET_IV_FIXED       0x12\n# define         EVP_CTRL_GCM_IV_GEN             0x13\n# define         EVP_CTRL_CCM_SET_IVLEN          EVP_CTRL_GCM_SET_IVLEN\n# define         EVP_CTRL_CCM_GET_TAG            EVP_CTRL_GCM_GET_TAG\n# define         EVP_CTRL_CCM_SET_TAG            EVP_CTRL_GCM_SET_TAG\n# define         EVP_CTRL_CCM_SET_L              0x14\n# define         EVP_CTRL_CCM_SET_MSGLEN         0x15\n/*\n * AEAD cipher deduces payload length and returns number of bytes required to\n * store MAC and eventual padding. Subsequent call to EVP_Cipher even\n * appends/verifies MAC.\n */\n# define         EVP_CTRL_AEAD_TLS1_AAD          0x16\n/* Used by composite AEAD ciphers, no-op in GCM, CCM... */\n# define         EVP_CTRL_AEAD_SET_MAC_KEY       0x17\n/* Set the GCM invocation field, decrypt only */\n# define         EVP_CTRL_GCM_SET_IV_INV         0x18\n\n# define         EVP_CTRL_TLS1_1_MULTIBLOCK_AAD  0x19\n# define         EVP_CTRL_TLS1_1_MULTIBLOCK_ENCRYPT      0x1a\n# define         EVP_CTRL_TLS1_1_MULTIBLOCK_DECRYPT      0x1b\n# define         EVP_CTRL_TLS1_1_MULTIBLOCK_MAX_BUFSIZE  0x1c\n\n/* RFC 5246 defines additional data to be 13 bytes in length */\n# define         EVP_AEAD_TLS1_AAD_LEN           13\n\ntypedef struct {\n    unsigned char *out;\n    const unsigned char *inp;\n    size_t len;\n    unsigned int interleave;\n} EVP_CTRL_TLS1_1_MULTIBLOCK_PARAM;\n\n/* GCM TLS constants */\n/* Length of fixed part of IV derived from PRF */\n# define EVP_GCM_TLS_FIXED_IV_LEN                        4\n/* Length of explicit part of IV part of TLS records */\n# define EVP_GCM_TLS_EXPLICIT_IV_LEN                     8\n/* Length of tag for TLS */\n# define EVP_GCM_TLS_TAG_LEN                             16\n\ntypedef struct evp_cipher_info_st {\n    const EVP_CIPHER *cipher;\n    unsigned char iv[EVP_MAX_IV_LENGTH];\n} EVP_CIPHER_INFO;\n\nstruct evp_cipher_ctx_st {\n    const EVP_CIPHER *cipher;\n    ENGINE *engine;             /* functional reference if 'cipher' is\n                                 * ENGINE-provided */\n    int encrypt;                /* encrypt or decrypt */\n    int buf_len;                /* number we have left */\n    unsigned char oiv[EVP_MAX_IV_LENGTH]; /* original iv */\n    unsigned char iv[EVP_MAX_IV_LENGTH]; /* working iv */\n    unsigned char buf[EVP_MAX_BLOCK_LENGTH]; /* saved partial block */\n    int num;                    /* used by cfb/ofb/ctr mode */\n    void *app_data;             /* application stuff */\n    int key_len;                /* May change for variable length cipher */\n    unsigned long flags;        /* Various flags */\n    void *cipher_data;          /* per EVP data */\n    int final_used;\n    int block_mask;\n    unsigned char final[EVP_MAX_BLOCK_LENGTH]; /* possible final block */\n} /* EVP_CIPHER_CTX */ ;\n\ntypedef struct evp_Encode_Ctx_st {\n    /* number saved in a partial encode/decode */\n    int num;\n    /*\n     * The length is either the output line length (in input bytes) or the\n     * shortest input line length that is ok.  Once decoding begins, the\n     * length is adjusted up each time a longer line is decoded\n     */\n    int length;\n    /* data to encode */\n    unsigned char enc_data[80];\n    /* number read on current line */\n    int line_num;\n    int expect_nl;\n} EVP_ENCODE_CTX;\n\n/* Password based encryption function */\ntypedef int (EVP_PBE_KEYGEN) (EVP_CIPHER_CTX *ctx, const char *pass,\n                              int passlen, ASN1_TYPE *param,\n                              const EVP_CIPHER *cipher, const EVP_MD *md,\n                              int en_de);\n\n# ifndef OPENSSL_NO_RSA\n#  define EVP_PKEY_assign_RSA(pkey,rsa) EVP_PKEY_assign((pkey),EVP_PKEY_RSA,\\\n                                        (char *)(rsa))\n# endif\n\n# ifndef OPENSSL_NO_DSA\n#  define EVP_PKEY_assign_DSA(pkey,dsa) EVP_PKEY_assign((pkey),EVP_PKEY_DSA,\\\n                                        (char *)(dsa))\n# endif\n\n# ifndef OPENSSL_NO_DH\n#  define EVP_PKEY_assign_DH(pkey,dh) EVP_PKEY_assign((pkey),EVP_PKEY_DH,\\\n                                        (char *)(dh))\n# endif\n\n# ifndef OPENSSL_NO_EC\n#  define EVP_PKEY_assign_EC_KEY(pkey,eckey) EVP_PKEY_assign((pkey),EVP_PKEY_EC,\\\n                                        (char *)(eckey))\n# endif\n\n/* Add some extra combinations */\n# define EVP_get_digestbynid(a) EVP_get_digestbyname(OBJ_nid2sn(a))\n# define EVP_get_digestbyobj(a) EVP_get_digestbynid(OBJ_obj2nid(a))\n# define EVP_get_cipherbynid(a) EVP_get_cipherbyname(OBJ_nid2sn(a))\n# define EVP_get_cipherbyobj(a) EVP_get_cipherbynid(OBJ_obj2nid(a))\n\nint EVP_MD_type(const EVP_MD *md);\n# define EVP_MD_nid(e)                   EVP_MD_type(e)\n# define EVP_MD_name(e)                  OBJ_nid2sn(EVP_MD_nid(e))\nint EVP_MD_pkey_type(const EVP_MD *md);\nint EVP_MD_size(const EVP_MD *md);\nint EVP_MD_block_size(const EVP_MD *md);\nunsigned long EVP_MD_flags(const EVP_MD *md);\n\nconst EVP_MD *EVP_MD_CTX_md(const EVP_MD_CTX *ctx);\n# define EVP_MD_CTX_size(e)              EVP_MD_size(EVP_MD_CTX_md(e))\n# define EVP_MD_CTX_block_size(e)        EVP_MD_block_size(EVP_MD_CTX_md(e))\n# define EVP_MD_CTX_type(e)              EVP_MD_type(EVP_MD_CTX_md(e))\n\nint EVP_CIPHER_nid(const EVP_CIPHER *cipher);\n# define EVP_CIPHER_name(e)              OBJ_nid2sn(EVP_CIPHER_nid(e))\nint EVP_CIPHER_block_size(const EVP_CIPHER *cipher);\nint EVP_CIPHER_key_length(const EVP_CIPHER *cipher);\nint EVP_CIPHER_iv_length(const EVP_CIPHER *cipher);\nunsigned long EVP_CIPHER_flags(const EVP_CIPHER *cipher);\n# define EVP_CIPHER_mode(e)              (EVP_CIPHER_flags(e) & EVP_CIPH_MODE)\n\nconst EVP_CIPHER *EVP_CIPHER_CTX_cipher(const EVP_CIPHER_CTX *ctx);\nint EVP_CIPHER_CTX_nid(const EVP_CIPHER_CTX *ctx);\nint EVP_CIPHER_CTX_block_size(const EVP_CIPHER_CTX *ctx);\nint EVP_CIPHER_CTX_key_length(const EVP_CIPHER_CTX *ctx);\nint EVP_CIPHER_CTX_iv_length(const EVP_CIPHER_CTX *ctx);\nint EVP_CIPHER_CTX_copy(EVP_CIPHER_CTX *out, const EVP_CIPHER_CTX *in);\nvoid *EVP_CIPHER_CTX_get_app_data(const EVP_CIPHER_CTX *ctx);\nvoid EVP_CIPHER_CTX_set_app_data(EVP_CIPHER_CTX *ctx, void *data);\n# define EVP_CIPHER_CTX_type(c)         EVP_CIPHER_type(EVP_CIPHER_CTX_cipher(c))\nunsigned long EVP_CIPHER_CTX_flags(const EVP_CIPHER_CTX *ctx);\n# define EVP_CIPHER_CTX_mode(e)          (EVP_CIPHER_CTX_flags(e) & EVP_CIPH_MODE)\n\n# define EVP_ENCODE_LENGTH(l)    (((l+2)/3*4)+(l/48+1)*2+80)\n# define EVP_DECODE_LENGTH(l)    ((l+3)/4*3+80)\n\n# define EVP_SignInit_ex(a,b,c)          EVP_DigestInit_ex(a,b,c)\n# define EVP_SignInit(a,b)               EVP_DigestInit(a,b)\n# define EVP_SignUpdate(a,b,c)           EVP_DigestUpdate(a,b,c)\n# define EVP_VerifyInit_ex(a,b,c)        EVP_DigestInit_ex(a,b,c)\n# define EVP_VerifyInit(a,b)             EVP_DigestInit(a,b)\n# define EVP_VerifyUpdate(a,b,c)         EVP_DigestUpdate(a,b,c)\n# define EVP_OpenUpdate(a,b,c,d,e)       EVP_DecryptUpdate(a,b,c,d,e)\n# define EVP_SealUpdate(a,b,c,d,e)       EVP_EncryptUpdate(a,b,c,d,e)\n# define EVP_DigestSignUpdate(a,b,c)     EVP_DigestUpdate(a,b,c)\n# define EVP_DigestVerifyUpdate(a,b,c)   EVP_DigestUpdate(a,b,c)\n\n# ifdef CONST_STRICT\nvoid BIO_set_md(BIO *, const EVP_MD *md);\n# else\n#  define BIO_set_md(b,md)               BIO_ctrl(b,BIO_C_SET_MD,0,(char *)md)\n# endif\n# define BIO_get_md(b,mdp)               BIO_ctrl(b,BIO_C_GET_MD,0,(char *)mdp)\n# define BIO_get_md_ctx(b,mdcp)     BIO_ctrl(b,BIO_C_GET_MD_CTX,0,(char *)mdcp)\n# define BIO_set_md_ctx(b,mdcp)     BIO_ctrl(b,BIO_C_SET_MD_CTX,0,(char *)mdcp)\n# define BIO_get_cipher_status(b)        BIO_ctrl(b,BIO_C_GET_CIPHER_STATUS,0,NULL)\n# define BIO_get_cipher_ctx(b,c_pp)      BIO_ctrl(b,BIO_C_GET_CIPHER_CTX,0,(char *)c_pp)\n\nint EVP_Cipher(EVP_CIPHER_CTX *c,\n               unsigned char *out, const unsigned char *in, unsigned int inl);\n\n# define EVP_add_cipher_alias(n,alias) \\\n        OBJ_NAME_add((alias),OBJ_NAME_TYPE_CIPHER_METH|OBJ_NAME_ALIAS,(n))\n# define EVP_add_digest_alias(n,alias) \\\n        OBJ_NAME_add((alias),OBJ_NAME_TYPE_MD_METH|OBJ_NAME_ALIAS,(n))\n# define EVP_delete_cipher_alias(alias) \\\n        OBJ_NAME_remove(alias,OBJ_NAME_TYPE_CIPHER_METH|OBJ_NAME_ALIAS);\n# define EVP_delete_digest_alias(alias) \\\n        OBJ_NAME_remove(alias,OBJ_NAME_TYPE_MD_METH|OBJ_NAME_ALIAS);\n\nvoid EVP_MD_CTX_init(EVP_MD_CTX *ctx);\nint EVP_MD_CTX_cleanup(EVP_MD_CTX *ctx);\nEVP_MD_CTX *EVP_MD_CTX_create(void);\nvoid EVP_MD_CTX_destroy(EVP_MD_CTX *ctx);\nint EVP_MD_CTX_copy_ex(EVP_MD_CTX *out, const EVP_MD_CTX *in);\nvoid EVP_MD_CTX_set_flags(EVP_MD_CTX *ctx, int flags);\nvoid EVP_MD_CTX_clear_flags(EVP_MD_CTX *ctx, int flags);\nint EVP_MD_CTX_test_flags(const EVP_MD_CTX *ctx, int flags);\nint EVP_DigestInit_ex(EVP_MD_CTX *ctx, const EVP_MD *type, ENGINE *impl);\nint EVP_DigestUpdate(EVP_MD_CTX *ctx, const void *d, size_t cnt);\nint EVP_DigestFinal_ex(EVP_MD_CTX *ctx, unsigned char *md, unsigned int *s);\nint EVP_Digest(const void *data, size_t count,\n               unsigned char *md, unsigned int *size, const EVP_MD *type,\n               ENGINE *impl);\n\nint EVP_MD_CTX_copy(EVP_MD_CTX *out, const EVP_MD_CTX *in);\nint EVP_DigestInit(EVP_MD_CTX *ctx, const EVP_MD *type);\nint EVP_DigestFinal(EVP_MD_CTX *ctx, unsigned char *md, unsigned int *s);\n\nint EVP_read_pw_string(char *buf, int length, const char *prompt, int verify);\nint EVP_read_pw_string_min(char *buf, int minlen, int maxlen,\n                           const char *prompt, int verify);\nvoid EVP_set_pw_prompt(const char *prompt);\nchar *EVP_get_pw_prompt(void);\n\nint EVP_BytesToKey(const EVP_CIPHER *type, const EVP_MD *md,\n                   const unsigned char *salt, const unsigned char *data,\n                   int datal, int count, unsigned char *key,\n                   unsigned char *iv);\n\nvoid EVP_CIPHER_CTX_set_flags(EVP_CIPHER_CTX *ctx, int flags);\nvoid EVP_CIPHER_CTX_clear_flags(EVP_CIPHER_CTX *ctx, int flags);\nint EVP_CIPHER_CTX_test_flags(const EVP_CIPHER_CTX *ctx, int flags);\n\nint EVP_EncryptInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher,\n                    const unsigned char *key, const unsigned char *iv);\nint EVP_EncryptInit_ex(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher,\n                       ENGINE *impl, const unsigned char *key,\n                       const unsigned char *iv);\nint EVP_EncryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl,\n                      const unsigned char *in, int inl);\nint EVP_EncryptFinal_ex(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl);\nint EVP_EncryptFinal(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl);\n\nint EVP_DecryptInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher,\n                    const unsigned char *key, const unsigned char *iv);\nint EVP_DecryptInit_ex(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher,\n                       ENGINE *impl, const unsigned char *key,\n                       const unsigned char *iv);\nint EVP_DecryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl,\n                      const unsigned char *in, int inl);\nint EVP_DecryptFinal(EVP_CIPHER_CTX *ctx, unsigned char *outm, int *outl);\nint EVP_DecryptFinal_ex(EVP_CIPHER_CTX *ctx, unsigned char *outm, int *outl);\n\nint EVP_CipherInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher,\n                   const unsigned char *key, const unsigned char *iv,\n                   int enc);\nint EVP_CipherInit_ex(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher,\n                      ENGINE *impl, const unsigned char *key,\n                      const unsigned char *iv, int enc);\nint EVP_CipherUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl,\n                     const unsigned char *in, int inl);\nint EVP_CipherFinal(EVP_CIPHER_CTX *ctx, unsigned char *outm, int *outl);\nint EVP_CipherFinal_ex(EVP_CIPHER_CTX *ctx, unsigned char *outm, int *outl);\n\nint EVP_SignFinal(EVP_MD_CTX *ctx, unsigned char *md, unsigned int *s,\n                  EVP_PKEY *pkey);\n\nint EVP_VerifyFinal(EVP_MD_CTX *ctx, const unsigned char *sigbuf,\n                    unsigned int siglen, EVP_PKEY *pkey);\n\nint EVP_DigestSignInit(EVP_MD_CTX *ctx, EVP_PKEY_CTX **pctx,\n                       const EVP_MD *type, ENGINE *e, EVP_PKEY *pkey);\nint EVP_DigestSignFinal(EVP_MD_CTX *ctx,\n                        unsigned char *sigret, size_t *siglen);\n\nint EVP_DigestVerifyInit(EVP_MD_CTX *ctx, EVP_PKEY_CTX **pctx,\n                         const EVP_MD *type, ENGINE *e, EVP_PKEY *pkey);\nint EVP_DigestVerifyFinal(EVP_MD_CTX *ctx,\n                          const unsigned char *sig, size_t siglen);\n\nint EVP_OpenInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *type,\n                 const unsigned char *ek, int ekl, const unsigned char *iv,\n                 EVP_PKEY *priv);\nint EVP_OpenFinal(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl);\n\nint EVP_SealInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *type,\n                 unsigned char **ek, int *ekl, unsigned char *iv,\n                 EVP_PKEY **pubk, int npubk);\nint EVP_SealFinal(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl);\n\nvoid EVP_EncodeInit(EVP_ENCODE_CTX *ctx);\nvoid EVP_EncodeUpdate(EVP_ENCODE_CTX *ctx, unsigned char *out, int *outl,\n                      const unsigned char *in, int inl);\nvoid EVP_EncodeFinal(EVP_ENCODE_CTX *ctx, unsigned char *out, int *outl);\nint EVP_EncodeBlock(unsigned char *t, const unsigned char *f, int n);\n\nvoid EVP_DecodeInit(EVP_ENCODE_CTX *ctx);\nint EVP_DecodeUpdate(EVP_ENCODE_CTX *ctx, unsigned char *out, int *outl,\n                     const unsigned char *in, int inl);\nint EVP_DecodeFinal(EVP_ENCODE_CTX *ctx, unsigned\n                    char *out, int *outl);\nint EVP_DecodeBlock(unsigned char *t, const unsigned char *f, int n);\n\nvoid EVP_CIPHER_CTX_init(EVP_CIPHER_CTX *a);\nint EVP_CIPHER_CTX_cleanup(EVP_CIPHER_CTX *a);\nEVP_CIPHER_CTX *EVP_CIPHER_CTX_new(void);\nvoid EVP_CIPHER_CTX_free(EVP_CIPHER_CTX *a);\nint EVP_CIPHER_CTX_set_key_length(EVP_CIPHER_CTX *x, int keylen);\nint EVP_CIPHER_CTX_set_padding(EVP_CIPHER_CTX *c, int pad);\nint EVP_CIPHER_CTX_ctrl(EVP_CIPHER_CTX *ctx, int type, int arg, void *ptr);\nint EVP_CIPHER_CTX_rand_key(EVP_CIPHER_CTX *ctx, unsigned char *key);\n\n# ifndef OPENSSL_NO_BIO\nBIO_METHOD *BIO_f_md(void);\nBIO_METHOD *BIO_f_base64(void);\nBIO_METHOD *BIO_f_cipher(void);\nBIO_METHOD *BIO_f_reliable(void);\nvoid BIO_set_cipher(BIO *b, const EVP_CIPHER *c, const unsigned char *k,\n                    const unsigned char *i, int enc);\n# endif\n\nconst EVP_MD *EVP_md_null(void);\n# ifndef OPENSSL_NO_MD2\nconst EVP_MD *EVP_md2(void);\n# endif\n# ifndef OPENSSL_NO_MD4\nconst EVP_MD *EVP_md4(void);\n# endif\n# ifndef OPENSSL_NO_MD5\nconst EVP_MD *EVP_md5(void);\n# endif\n# ifndef OPENSSL_NO_SHA\nconst EVP_MD *EVP_sha(void);\nconst EVP_MD *EVP_sha1(void);\nconst EVP_MD *EVP_dss(void);\nconst EVP_MD *EVP_dss1(void);\nconst EVP_MD *EVP_ecdsa(void);\n# endif\n# ifndef OPENSSL_NO_SHA256\nconst EVP_MD *EVP_sha224(void);\nconst EVP_MD *EVP_sha256(void);\n# endif\n# ifndef OPENSSL_NO_SHA512\nconst EVP_MD *EVP_sha384(void);\nconst EVP_MD *EVP_sha512(void);\n# endif\n# ifndef OPENSSL_NO_MDC2\nconst EVP_MD *EVP_mdc2(void);\n# endif\n# ifndef OPENSSL_NO_RIPEMD\nconst EVP_MD *EVP_ripemd160(void);\n# endif\n# ifndef OPENSSL_NO_WHIRLPOOL\nconst EVP_MD *EVP_whirlpool(void);\n# endif\nconst EVP_CIPHER *EVP_enc_null(void); /* does nothing :-) */\n# ifndef OPENSSL_NO_DES\nconst EVP_CIPHER *EVP_des_ecb(void);\nconst EVP_CIPHER *EVP_des_ede(void);\nconst EVP_CIPHER *EVP_des_ede3(void);\nconst EVP_CIPHER *EVP_des_ede_ecb(void);\nconst EVP_CIPHER *EVP_des_ede3_ecb(void);\nconst EVP_CIPHER *EVP_des_cfb64(void);\n#  define EVP_des_cfb EVP_des_cfb64\nconst EVP_CIPHER *EVP_des_cfb1(void);\nconst EVP_CIPHER *EVP_des_cfb8(void);\nconst EVP_CIPHER *EVP_des_ede_cfb64(void);\n#  define EVP_des_ede_cfb EVP_des_ede_cfb64\n#  if 0\nconst EVP_CIPHER *EVP_des_ede_cfb1(void);\nconst EVP_CIPHER *EVP_des_ede_cfb8(void);\n#  endif\nconst EVP_CIPHER *EVP_des_ede3_cfb64(void);\n#  define EVP_des_ede3_cfb EVP_des_ede3_cfb64\nconst EVP_CIPHER *EVP_des_ede3_cfb1(void);\nconst EVP_CIPHER *EVP_des_ede3_cfb8(void);\nconst EVP_CIPHER *EVP_des_ofb(void);\nconst EVP_CIPHER *EVP_des_ede_ofb(void);\nconst EVP_CIPHER *EVP_des_ede3_ofb(void);\nconst EVP_CIPHER *EVP_des_cbc(void);\nconst EVP_CIPHER *EVP_des_ede_cbc(void);\nconst EVP_CIPHER *EVP_des_ede3_cbc(void);\nconst EVP_CIPHER *EVP_desx_cbc(void);\nconst EVP_CIPHER *EVP_des_ede3_wrap(void);\n/*\n * This should now be supported through the dev_crypto ENGINE. But also, why\n * are rc4 and md5 declarations made here inside a \"NO_DES\" precompiler\n * branch?\n */\n#  if 0\n#   ifdef OPENSSL_OPENBSD_DEV_CRYPTO\nconst EVP_CIPHER *EVP_dev_crypto_des_ede3_cbc(void);\nconst EVP_CIPHER *EVP_dev_crypto_rc4(void);\nconst EVP_MD *EVP_dev_crypto_md5(void);\n#   endif\n#  endif\n# endif\n# ifndef OPENSSL_NO_RC4\nconst EVP_CIPHER *EVP_rc4(void);\nconst EVP_CIPHER *EVP_rc4_40(void);\n#  ifndef OPENSSL_NO_MD5\nconst EVP_CIPHER *EVP_rc4_hmac_md5(void);\n#  endif\n# endif\n# ifndef OPENSSL_NO_IDEA\nconst EVP_CIPHER *EVP_idea_ecb(void);\nconst EVP_CIPHER *EVP_idea_cfb64(void);\n#  define EVP_idea_cfb EVP_idea_cfb64\nconst EVP_CIPHER *EVP_idea_ofb(void);\nconst EVP_CIPHER *EVP_idea_cbc(void);\n# endif\n# ifndef OPENSSL_NO_RC2\nconst EVP_CIPHER *EVP_rc2_ecb(void);\nconst EVP_CIPHER *EVP_rc2_cbc(void);\nconst EVP_CIPHER *EVP_rc2_40_cbc(void);\nconst EVP_CIPHER *EVP_rc2_64_cbc(void);\nconst EVP_CIPHER *EVP_rc2_cfb64(void);\n#  define EVP_rc2_cfb EVP_rc2_cfb64\nconst EVP_CIPHER *EVP_rc2_ofb(void);\n# endif\n# ifndef OPENSSL_NO_BF\nconst EVP_CIPHER *EVP_bf_ecb(void);\nconst EVP_CIPHER *EVP_bf_cbc(void);\nconst EVP_CIPHER *EVP_bf_cfb64(void);\n#  define EVP_bf_cfb EVP_bf_cfb64\nconst EVP_CIPHER *EVP_bf_ofb(void);\n# endif\n# ifndef OPENSSL_NO_CAST\nconst EVP_CIPHER *EVP_cast5_ecb(void);\nconst EVP_CIPHER *EVP_cast5_cbc(void);\nconst EVP_CIPHER *EVP_cast5_cfb64(void);\n#  define EVP_cast5_cfb EVP_cast5_cfb64\nconst EVP_CIPHER *EVP_cast5_ofb(void);\n# endif\n# ifndef OPENSSL_NO_RC5\nconst EVP_CIPHER *EVP_rc5_32_12_16_cbc(void);\nconst EVP_CIPHER *EVP_rc5_32_12_16_ecb(void);\nconst EVP_CIPHER *EVP_rc5_32_12_16_cfb64(void);\n#  define EVP_rc5_32_12_16_cfb EVP_rc5_32_12_16_cfb64\nconst EVP_CIPHER *EVP_rc5_32_12_16_ofb(void);\n# endif\n# ifndef OPENSSL_NO_AES\nconst EVP_CIPHER *EVP_aes_128_ecb(void);\nconst EVP_CIPHER *EVP_aes_128_cbc(void);\nconst EVP_CIPHER *EVP_aes_128_cfb1(void);\nconst EVP_CIPHER *EVP_aes_128_cfb8(void);\nconst EVP_CIPHER *EVP_aes_128_cfb128(void);\n#  define EVP_aes_128_cfb EVP_aes_128_cfb128\nconst EVP_CIPHER *EVP_aes_128_ofb(void);\nconst EVP_CIPHER *EVP_aes_128_ctr(void);\nconst EVP_CIPHER *EVP_aes_128_ccm(void);\nconst EVP_CIPHER *EVP_aes_128_gcm(void);\nconst EVP_CIPHER *EVP_aes_128_xts(void);\nconst EVP_CIPHER *EVP_aes_128_wrap(void);\nconst EVP_CIPHER *EVP_aes_192_ecb(void);\nconst EVP_CIPHER *EVP_aes_192_cbc(void);\nconst EVP_CIPHER *EVP_aes_192_cfb1(void);\nconst EVP_CIPHER *EVP_aes_192_cfb8(void);\nconst EVP_CIPHER *EVP_aes_192_cfb128(void);\n#  define EVP_aes_192_cfb EVP_aes_192_cfb128\nconst EVP_CIPHER *EVP_aes_192_ofb(void);\nconst EVP_CIPHER *EVP_aes_192_ctr(void);\nconst EVP_CIPHER *EVP_aes_192_ccm(void);\nconst EVP_CIPHER *EVP_aes_192_gcm(void);\nconst EVP_CIPHER *EVP_aes_192_wrap(void);\nconst EVP_CIPHER *EVP_aes_256_ecb(void);\nconst EVP_CIPHER *EVP_aes_256_cbc(void);\nconst EVP_CIPHER *EVP_aes_256_cfb1(void);\nconst EVP_CIPHER *EVP_aes_256_cfb8(void);\nconst EVP_CIPHER *EVP_aes_256_cfb128(void);\n#  define EVP_aes_256_cfb EVP_aes_256_cfb128\nconst EVP_CIPHER *EVP_aes_256_ofb(void);\nconst EVP_CIPHER *EVP_aes_256_ctr(void);\nconst EVP_CIPHER *EVP_aes_256_ccm(void);\nconst EVP_CIPHER *EVP_aes_256_gcm(void);\nconst EVP_CIPHER *EVP_aes_256_xts(void);\nconst EVP_CIPHER *EVP_aes_256_wrap(void);\n#  if !defined(OPENSSL_NO_SHA) && !defined(OPENSSL_NO_SHA1)\nconst EVP_CIPHER *EVP_aes_128_cbc_hmac_sha1(void);\nconst EVP_CIPHER *EVP_aes_256_cbc_hmac_sha1(void);\n#  endif\n#  ifndef OPENSSL_NO_SHA256\nconst EVP_CIPHER *EVP_aes_128_cbc_hmac_sha256(void);\nconst EVP_CIPHER *EVP_aes_256_cbc_hmac_sha256(void);\n#  endif\n# endif\n# ifndef OPENSSL_NO_CAMELLIA\nconst EVP_CIPHER *EVP_camellia_128_ecb(void);\nconst EVP_CIPHER *EVP_camellia_128_cbc(void);\nconst EVP_CIPHER *EVP_camellia_128_cfb1(void);\nconst EVP_CIPHER *EVP_camellia_128_cfb8(void);\nconst EVP_CIPHER *EVP_camellia_128_cfb128(void);\n#  define EVP_camellia_128_cfb EVP_camellia_128_cfb128\nconst EVP_CIPHER *EVP_camellia_128_ofb(void);\nconst EVP_CIPHER *EVP_camellia_192_ecb(void);\nconst EVP_CIPHER *EVP_camellia_192_cbc(void);\nconst EVP_CIPHER *EVP_camellia_192_cfb1(void);\nconst EVP_CIPHER *EVP_camellia_192_cfb8(void);\nconst EVP_CIPHER *EVP_camellia_192_cfb128(void);\n#  define EVP_camellia_192_cfb EVP_camellia_192_cfb128\nconst EVP_CIPHER *EVP_camellia_192_ofb(void);\nconst EVP_CIPHER *EVP_camellia_256_ecb(void);\nconst EVP_CIPHER *EVP_camellia_256_cbc(void);\nconst EVP_CIPHER *EVP_camellia_256_cfb1(void);\nconst EVP_CIPHER *EVP_camellia_256_cfb8(void);\nconst EVP_CIPHER *EVP_camellia_256_cfb128(void);\n#  define EVP_camellia_256_cfb EVP_camellia_256_cfb128\nconst EVP_CIPHER *EVP_camellia_256_ofb(void);\n# endif\n\n# ifndef OPENSSL_NO_SEED\nconst EVP_CIPHER *EVP_seed_ecb(void);\nconst EVP_CIPHER *EVP_seed_cbc(void);\nconst EVP_CIPHER *EVP_seed_cfb128(void);\n#  define EVP_seed_cfb EVP_seed_cfb128\nconst EVP_CIPHER *EVP_seed_ofb(void);\n# endif\n\nvoid OPENSSL_add_all_algorithms_noconf(void);\nvoid OPENSSL_add_all_algorithms_conf(void);\n\n# ifdef OPENSSL_LOAD_CONF\n#  define OpenSSL_add_all_algorithms() \\\n                OPENSSL_add_all_algorithms_conf()\n# else\n#  define OpenSSL_add_all_algorithms() \\\n                OPENSSL_add_all_algorithms_noconf()\n# endif\n\nvoid OpenSSL_add_all_ciphers(void);\nvoid OpenSSL_add_all_digests(void);\n# define SSLeay_add_all_algorithms() OpenSSL_add_all_algorithms()\n# define SSLeay_add_all_ciphers() OpenSSL_add_all_ciphers()\n# define SSLeay_add_all_digests() OpenSSL_add_all_digests()\n\nint EVP_add_cipher(const EVP_CIPHER *cipher);\nint EVP_add_digest(const EVP_MD *digest);\n\nconst EVP_CIPHER *EVP_get_cipherbyname(const char *name);\nconst EVP_MD *EVP_get_digestbyname(const char *name);\nvoid EVP_cleanup(void);\n\nvoid EVP_CIPHER_do_all(void (*fn) (const EVP_CIPHER *ciph,\n                                   const char *from, const char *to, void *x),\n                       void *arg);\nvoid EVP_CIPHER_do_all_sorted(void (*fn)\n                               (const EVP_CIPHER *ciph, const char *from,\n                                const char *to, void *x), void *arg);\n\nvoid EVP_MD_do_all(void (*fn) (const EVP_MD *ciph,\n                               const char *from, const char *to, void *x),\n                   void *arg);\nvoid EVP_MD_do_all_sorted(void (*fn)\n                           (const EVP_MD *ciph, const char *from,\n                            const char *to, void *x), void *arg);\n\nint EVP_PKEY_decrypt_old(unsigned char *dec_key,\n                         const unsigned char *enc_key, int enc_key_len,\n                         EVP_PKEY *private_key);\nint EVP_PKEY_encrypt_old(unsigned char *enc_key,\n                         const unsigned char *key, int key_len,\n                         EVP_PKEY *pub_key);\nint EVP_PKEY_type(int type);\nint EVP_PKEY_id(const EVP_PKEY *pkey);\nint EVP_PKEY_base_id(const EVP_PKEY *pkey);\nint EVP_PKEY_bits(EVP_PKEY *pkey);\nint EVP_PKEY_size(EVP_PKEY *pkey);\nint EVP_PKEY_set_type(EVP_PKEY *pkey, int type);\nint EVP_PKEY_set_type_str(EVP_PKEY *pkey, const char *str, int len);\nint EVP_PKEY_assign(EVP_PKEY *pkey, int type, void *key);\nvoid *EVP_PKEY_get0(EVP_PKEY *pkey);\n\n# ifndef OPENSSL_NO_RSA\nstruct rsa_st;\nint EVP_PKEY_set1_RSA(EVP_PKEY *pkey, struct rsa_st *key);\nstruct rsa_st *EVP_PKEY_get1_RSA(EVP_PKEY *pkey);\n# endif\n# ifndef OPENSSL_NO_DSA\nstruct dsa_st;\nint EVP_PKEY_set1_DSA(EVP_PKEY *pkey, struct dsa_st *key);\nstruct dsa_st *EVP_PKEY_get1_DSA(EVP_PKEY *pkey);\n# endif\n# ifndef OPENSSL_NO_DH\nstruct dh_st;\nint EVP_PKEY_set1_DH(EVP_PKEY *pkey, struct dh_st *key);\nstruct dh_st *EVP_PKEY_get1_DH(EVP_PKEY *pkey);\n# endif\n# ifndef OPENSSL_NO_EC\nstruct ec_key_st;\nint EVP_PKEY_set1_EC_KEY(EVP_PKEY *pkey, struct ec_key_st *key);\nstruct ec_key_st *EVP_PKEY_get1_EC_KEY(EVP_PKEY *pkey);\n# endif\n\nEVP_PKEY *EVP_PKEY_new(void);\nvoid EVP_PKEY_free(EVP_PKEY *pkey);\n\nEVP_PKEY *d2i_PublicKey(int type, EVP_PKEY **a, const unsigned char **pp,\n                        long length);\nint i2d_PublicKey(EVP_PKEY *a, unsigned char **pp);\n\nEVP_PKEY *d2i_PrivateKey(int type, EVP_PKEY **a, const unsigned char **pp,\n                         long length);\nEVP_PKEY *d2i_AutoPrivateKey(EVP_PKEY **a, const unsigned char **pp,\n                             long length);\nint i2d_PrivateKey(EVP_PKEY *a, unsigned char **pp);\n\nint EVP_PKEY_copy_parameters(EVP_PKEY *to, const EVP_PKEY *from);\nint EVP_PKEY_missing_parameters(const EVP_PKEY *pkey);\nint EVP_PKEY_save_parameters(EVP_PKEY *pkey, int mode);\nint EVP_PKEY_cmp_parameters(const EVP_PKEY *a, const EVP_PKEY *b);\n\nint EVP_PKEY_cmp(const EVP_PKEY *a, const EVP_PKEY *b);\n\nint EVP_PKEY_print_public(BIO *out, const EVP_PKEY *pkey,\n                          int indent, ASN1_PCTX *pctx);\nint EVP_PKEY_print_private(BIO *out, const EVP_PKEY *pkey,\n                           int indent, ASN1_PCTX *pctx);\nint EVP_PKEY_print_params(BIO *out, const EVP_PKEY *pkey,\n                          int indent, ASN1_PCTX *pctx);\n\nint EVP_PKEY_get_default_digest_nid(EVP_PKEY *pkey, int *pnid);\n\nint EVP_CIPHER_type(const EVP_CIPHER *ctx);\n\n/* calls methods */\nint EVP_CIPHER_param_to_asn1(EVP_CIPHER_CTX *c, ASN1_TYPE *type);\nint EVP_CIPHER_asn1_to_param(EVP_CIPHER_CTX *c, ASN1_TYPE *type);\n\n/* These are used by EVP_CIPHER methods */\nint EVP_CIPHER_set_asn1_iv(EVP_CIPHER_CTX *c, ASN1_TYPE *type);\nint EVP_CIPHER_get_asn1_iv(EVP_CIPHER_CTX *c, ASN1_TYPE *type);\n\n/* PKCS5 password based encryption */\nint PKCS5_PBE_keyivgen(EVP_CIPHER_CTX *ctx, const char *pass, int passlen,\n                       ASN1_TYPE *param, const EVP_CIPHER *cipher,\n                       const EVP_MD *md, int en_de);\nint PKCS5_PBKDF2_HMAC_SHA1(const char *pass, int passlen,\n                           const unsigned char *salt, int saltlen, int iter,\n                           int keylen, unsigned char *out);\nint PKCS5_PBKDF2_HMAC(const char *pass, int passlen,\n                      const unsigned char *salt, int saltlen, int iter,\n                      const EVP_MD *digest, int keylen, unsigned char *out);\nint PKCS5_v2_PBE_keyivgen(EVP_CIPHER_CTX *ctx, const char *pass, int passlen,\n                          ASN1_TYPE *param, const EVP_CIPHER *cipher,\n                          const EVP_MD *md, int en_de);\n\nvoid PKCS5_PBE_add(void);\n\nint EVP_PBE_CipherInit(ASN1_OBJECT *pbe_obj, const char *pass, int passlen,\n                       ASN1_TYPE *param, EVP_CIPHER_CTX *ctx, int en_de);\n\n/* PBE type */\n\n/* Can appear as the outermost AlgorithmIdentifier */\n# define EVP_PBE_TYPE_OUTER      0x0\n/* Is an PRF type OID */\n# define EVP_PBE_TYPE_PRF        0x1\n\nint EVP_PBE_alg_add_type(int pbe_type, int pbe_nid, int cipher_nid,\n                         int md_nid, EVP_PBE_KEYGEN *keygen);\nint EVP_PBE_alg_add(int nid, const EVP_CIPHER *cipher, const EVP_MD *md,\n                    EVP_PBE_KEYGEN *keygen);\nint EVP_PBE_find(int type, int pbe_nid, int *pcnid, int *pmnid,\n                 EVP_PBE_KEYGEN **pkeygen);\nvoid EVP_PBE_cleanup(void);\n\n# define ASN1_PKEY_ALIAS         0x1\n# define ASN1_PKEY_DYNAMIC       0x2\n# define ASN1_PKEY_SIGPARAM_NULL 0x4\n\n# define ASN1_PKEY_CTRL_PKCS7_SIGN       0x1\n# define ASN1_PKEY_CTRL_PKCS7_ENCRYPT    0x2\n# define ASN1_PKEY_CTRL_DEFAULT_MD_NID   0x3\n# define ASN1_PKEY_CTRL_CMS_SIGN         0x5\n# define ASN1_PKEY_CTRL_CMS_ENVELOPE     0x7\n# define ASN1_PKEY_CTRL_CMS_RI_TYPE      0x8\n\nint EVP_PKEY_asn1_get_count(void);\nconst EVP_PKEY_ASN1_METHOD *EVP_PKEY_asn1_get0(int idx);\nconst EVP_PKEY_ASN1_METHOD *EVP_PKEY_asn1_find(ENGINE **pe, int type);\nconst EVP_PKEY_ASN1_METHOD *EVP_PKEY_asn1_find_str(ENGINE **pe,\n                                                   const char *str, int len);\nint EVP_PKEY_asn1_add0(const EVP_PKEY_ASN1_METHOD *ameth);\nint EVP_PKEY_asn1_add_alias(int to, int from);\nint EVP_PKEY_asn1_get0_info(int *ppkey_id, int *pkey_base_id,\n                            int *ppkey_flags, const char **pinfo,\n                            const char **ppem_str,\n                            const EVP_PKEY_ASN1_METHOD *ameth);\n\nconst EVP_PKEY_ASN1_METHOD *EVP_PKEY_get0_asn1(EVP_PKEY *pkey);\nEVP_PKEY_ASN1_METHOD *EVP_PKEY_asn1_new(int id, int flags,\n                                        const char *pem_str,\n                                        const char *info);\nvoid EVP_PKEY_asn1_copy(EVP_PKEY_ASN1_METHOD *dst,\n                        const EVP_PKEY_ASN1_METHOD *src);\nvoid EVP_PKEY_asn1_free(EVP_PKEY_ASN1_METHOD *ameth);\nvoid EVP_PKEY_asn1_set_public(EVP_PKEY_ASN1_METHOD *ameth,\n                              int (*pub_decode) (EVP_PKEY *pk,\n                                                 X509_PUBKEY *pub),\n                              int (*pub_encode) (X509_PUBKEY *pub,\n                                                 const EVP_PKEY *pk),\n                              int (*pub_cmp) (const EVP_PKEY *a,\n                                              const EVP_PKEY *b),\n                              int (*pub_print) (BIO *out,\n                                                const EVP_PKEY *pkey,\n                                                int indent, ASN1_PCTX *pctx),\n                              int (*pkey_size) (const EVP_PKEY *pk),\n                              int (*pkey_bits) (const EVP_PKEY *pk));\nvoid EVP_PKEY_asn1_set_private(EVP_PKEY_ASN1_METHOD *ameth,\n                               int (*priv_decode) (EVP_PKEY *pk,\n                                                   PKCS8_PRIV_KEY_INFO\n                                                   *p8inf),\n                               int (*priv_encode) (PKCS8_PRIV_KEY_INFO *p8,\n                                                   const EVP_PKEY *pk),\n                               int (*priv_print) (BIO *out,\n                                                  const EVP_PKEY *pkey,\n                                                  int indent,\n                                                  ASN1_PCTX *pctx));\nvoid EVP_PKEY_asn1_set_param(EVP_PKEY_ASN1_METHOD *ameth,\n                             int (*param_decode) (EVP_PKEY *pkey,\n                                                  const unsigned char **pder,\n                                                  int derlen),\n                             int (*param_encode) (const EVP_PKEY *pkey,\n                                                  unsigned char **pder),\n                             int (*param_missing) (const EVP_PKEY *pk),\n                             int (*param_copy) (EVP_PKEY *to,\n                                                const EVP_PKEY *from),\n                             int (*param_cmp) (const EVP_PKEY *a,\n                                               const EVP_PKEY *b),\n                             int (*param_print) (BIO *out,\n                                                 const EVP_PKEY *pkey,\n                                                 int indent,\n                                                 ASN1_PCTX *pctx));\n\nvoid EVP_PKEY_asn1_set_free(EVP_PKEY_ASN1_METHOD *ameth,\n                            void (*pkey_free) (EVP_PKEY *pkey));\nvoid EVP_PKEY_asn1_set_ctrl(EVP_PKEY_ASN1_METHOD *ameth,\n                            int (*pkey_ctrl) (EVP_PKEY *pkey, int op,\n                                              long arg1, void *arg2));\nvoid EVP_PKEY_asn1_set_item(EVP_PKEY_ASN1_METHOD *ameth,\n                            int (*item_verify) (EVP_MD_CTX *ctx,\n                                                const ASN1_ITEM *it,\n                                                void *asn,\n                                                X509_ALGOR *a,\n                                                ASN1_BIT_STRING *sig,\n                                                EVP_PKEY *pkey),\n                            int (*item_sign) (EVP_MD_CTX *ctx,\n                                              const ASN1_ITEM *it,\n                                              void *asn,\n                                              X509_ALGOR *alg1,\n                                              X509_ALGOR *alg2,\n                                              ASN1_BIT_STRING *sig));\n\n# define EVP_PKEY_OP_UNDEFINED           0\n# define EVP_PKEY_OP_PARAMGEN            (1<<1)\n# define EVP_PKEY_OP_KEYGEN              (1<<2)\n# define EVP_PKEY_OP_SIGN                (1<<3)\n# define EVP_PKEY_OP_VERIFY              (1<<4)\n# define EVP_PKEY_OP_VERIFYRECOVER       (1<<5)\n# define EVP_PKEY_OP_SIGNCTX             (1<<6)\n# define EVP_PKEY_OP_VERIFYCTX           (1<<7)\n# define EVP_PKEY_OP_ENCRYPT             (1<<8)\n# define EVP_PKEY_OP_DECRYPT             (1<<9)\n# define EVP_PKEY_OP_DERIVE              (1<<10)\n\n# define EVP_PKEY_OP_TYPE_SIG    \\\n        (EVP_PKEY_OP_SIGN | EVP_PKEY_OP_VERIFY | EVP_PKEY_OP_VERIFYRECOVER \\\n                | EVP_PKEY_OP_SIGNCTX | EVP_PKEY_OP_VERIFYCTX)\n\n# define EVP_PKEY_OP_TYPE_CRYPT \\\n        (EVP_PKEY_OP_ENCRYPT | EVP_PKEY_OP_DECRYPT)\n\n# define EVP_PKEY_OP_TYPE_NOGEN \\\n        (EVP_PKEY_OP_SIG | EVP_PKEY_OP_CRYPT | EVP_PKEY_OP_DERIVE)\n\n# define EVP_PKEY_OP_TYPE_GEN \\\n                (EVP_PKEY_OP_PARAMGEN | EVP_PKEY_OP_KEYGEN)\n\n# define  EVP_PKEY_CTX_set_signature_md(ctx, md) \\\n                EVP_PKEY_CTX_ctrl(ctx, -1, EVP_PKEY_OP_TYPE_SIG,  \\\n                                        EVP_PKEY_CTRL_MD, 0, (void *)md)\n\n# define  EVP_PKEY_CTX_get_signature_md(ctx, pmd)        \\\n                EVP_PKEY_CTX_ctrl(ctx, -1, EVP_PKEY_OP_TYPE_SIG,  \\\n                                        EVP_PKEY_CTRL_GET_MD, 0, (void *)pmd)\n\n# define EVP_PKEY_CTRL_MD                1\n# define EVP_PKEY_CTRL_PEER_KEY          2\n\n# define EVP_PKEY_CTRL_PKCS7_ENCRYPT     3\n# define EVP_PKEY_CTRL_PKCS7_DECRYPT     4\n\n# define EVP_PKEY_CTRL_PKCS7_SIGN        5\n\n# define EVP_PKEY_CTRL_SET_MAC_KEY       6\n\n# define EVP_PKEY_CTRL_DIGESTINIT        7\n\n/* Used by GOST key encryption in TLS */\n# define EVP_PKEY_CTRL_SET_IV            8\n\n# define EVP_PKEY_CTRL_CMS_ENCRYPT       9\n# define EVP_PKEY_CTRL_CMS_DECRYPT       10\n# define EVP_PKEY_CTRL_CMS_SIGN          11\n\n# define EVP_PKEY_CTRL_CIPHER            12\n\n# define EVP_PKEY_CTRL_GET_MD            13\n\n# define EVP_PKEY_ALG_CTRL               0x1000\n\n# define EVP_PKEY_FLAG_AUTOARGLEN        2\n/*\n * Method handles all operations: don't assume any digest related defaults.\n */\n# define EVP_PKEY_FLAG_SIGCTX_CUSTOM     4\n\nconst EVP_PKEY_METHOD *EVP_PKEY_meth_find(int type);\nEVP_PKEY_METHOD *EVP_PKEY_meth_new(int id, int flags);\nvoid EVP_PKEY_meth_get0_info(int *ppkey_id, int *pflags,\n                             const EVP_PKEY_METHOD *meth);\nvoid EVP_PKEY_meth_copy(EVP_PKEY_METHOD *dst, const EVP_PKEY_METHOD *src);\nvoid EVP_PKEY_meth_free(EVP_PKEY_METHOD *pmeth);\nint EVP_PKEY_meth_add0(const EVP_PKEY_METHOD *pmeth);\n\nEVP_PKEY_CTX *EVP_PKEY_CTX_new(EVP_PKEY *pkey, ENGINE *e);\nEVP_PKEY_CTX *EVP_PKEY_CTX_new_id(int id, ENGINE *e);\nEVP_PKEY_CTX *EVP_PKEY_CTX_dup(EVP_PKEY_CTX *ctx);\nvoid EVP_PKEY_CTX_free(EVP_PKEY_CTX *ctx);\n\nint EVP_PKEY_CTX_ctrl(EVP_PKEY_CTX *ctx, int keytype, int optype,\n                      int cmd, int p1, void *p2);\nint EVP_PKEY_CTX_ctrl_str(EVP_PKEY_CTX *ctx, const char *type,\n                          const char *value);\n\nint EVP_PKEY_CTX_get_operation(EVP_PKEY_CTX *ctx);\nvoid EVP_PKEY_CTX_set0_keygen_info(EVP_PKEY_CTX *ctx, int *dat, int datlen);\n\nEVP_PKEY *EVP_PKEY_new_mac_key(int type, ENGINE *e,\n                               const unsigned char *key, int keylen);\n\nvoid EVP_PKEY_CTX_set_data(EVP_PKEY_CTX *ctx, void *data);\nvoid *EVP_PKEY_CTX_get_data(EVP_PKEY_CTX *ctx);\nEVP_PKEY *EVP_PKEY_CTX_get0_pkey(EVP_PKEY_CTX *ctx);\n\nEVP_PKEY *EVP_PKEY_CTX_get0_peerkey(EVP_PKEY_CTX *ctx);\n\nvoid EVP_PKEY_CTX_set_app_data(EVP_PKEY_CTX *ctx, void *data);\nvoid *EVP_PKEY_CTX_get_app_data(EVP_PKEY_CTX *ctx);\n\nint EVP_PKEY_sign_init(EVP_PKEY_CTX *ctx);\nint EVP_PKEY_sign(EVP_PKEY_CTX *ctx,\n                  unsigned char *sig, size_t *siglen,\n                  const unsigned char *tbs, size_t tbslen);\nint EVP_PKEY_verify_init(EVP_PKEY_CTX *ctx);\nint EVP_PKEY_verify(EVP_PKEY_CTX *ctx,\n                    const unsigned char *sig, size_t siglen,\n                    const unsigned char *tbs, size_t tbslen);\nint EVP_PKEY_verify_recover_init(EVP_PKEY_CTX *ctx);\nint EVP_PKEY_verify_recover(EVP_PKEY_CTX *ctx,\n                            unsigned char *rout, size_t *routlen,\n                            const unsigned char *sig, size_t siglen);\nint EVP_PKEY_encrypt_init(EVP_PKEY_CTX *ctx);\nint EVP_PKEY_encrypt(EVP_PKEY_CTX *ctx,\n                     unsigned char *out, size_t *outlen,\n                     const unsigned char *in, size_t inlen);\nint EVP_PKEY_decrypt_init(EVP_PKEY_CTX *ctx);\nint EVP_PKEY_decrypt(EVP_PKEY_CTX *ctx,\n                     unsigned char *out, size_t *outlen,\n                     const unsigned char *in, size_t inlen);\n\nint EVP_PKEY_derive_init(EVP_PKEY_CTX *ctx);\nint EVP_PKEY_derive_set_peer(EVP_PKEY_CTX *ctx, EVP_PKEY *peer);\nint EVP_PKEY_derive(EVP_PKEY_CTX *ctx, unsigned char *key, size_t *keylen);\n\ntypedef int EVP_PKEY_gen_cb (EVP_PKEY_CTX *ctx);\n\nint EVP_PKEY_paramgen_init(EVP_PKEY_CTX *ctx);\nint EVP_PKEY_paramgen(EVP_PKEY_CTX *ctx, EVP_PKEY **ppkey);\nint EVP_PKEY_keygen_init(EVP_PKEY_CTX *ctx);\nint EVP_PKEY_keygen(EVP_PKEY_CTX *ctx, EVP_PKEY **ppkey);\n\nvoid EVP_PKEY_CTX_set_cb(EVP_PKEY_CTX *ctx, EVP_PKEY_gen_cb *cb);\nEVP_PKEY_gen_cb *EVP_PKEY_CTX_get_cb(EVP_PKEY_CTX *ctx);\n\nint EVP_PKEY_CTX_get_keygen_info(EVP_PKEY_CTX *ctx, int idx);\n\nvoid EVP_PKEY_meth_set_init(EVP_PKEY_METHOD *pmeth,\n                            int (*init) (EVP_PKEY_CTX *ctx));\n\nvoid EVP_PKEY_meth_set_copy(EVP_PKEY_METHOD *pmeth,\n                            int (*copy) (EVP_PKEY_CTX *dst,\n                                         EVP_PKEY_CTX *src));\n\nvoid EVP_PKEY_meth_set_cleanup(EVP_PKEY_METHOD *pmeth,\n                               void (*cleanup) (EVP_PKEY_CTX *ctx));\n\nvoid EVP_PKEY_meth_set_paramgen(EVP_PKEY_METHOD *pmeth,\n                                int (*paramgen_init) (EVP_PKEY_CTX *ctx),\n                                int (*paramgen) (EVP_PKEY_CTX *ctx,\n                                                 EVP_PKEY *pkey));\n\nvoid EVP_PKEY_meth_set_keygen(EVP_PKEY_METHOD *pmeth,\n                              int (*keygen_init) (EVP_PKEY_CTX *ctx),\n                              int (*keygen) (EVP_PKEY_CTX *ctx,\n                                             EVP_PKEY *pkey));\n\nvoid EVP_PKEY_meth_set_sign(EVP_PKEY_METHOD *pmeth,\n                            int (*sign_init) (EVP_PKEY_CTX *ctx),\n                            int (*sign) (EVP_PKEY_CTX *ctx,\n                                         unsigned char *sig, size_t *siglen,\n                                         const unsigned char *tbs,\n                                         size_t tbslen));\n\nvoid EVP_PKEY_meth_set_verify(EVP_PKEY_METHOD *pmeth,\n                              int (*verify_init) (EVP_PKEY_CTX *ctx),\n                              int (*verify) (EVP_PKEY_CTX *ctx,\n                                             const unsigned char *sig,\n                                             size_t siglen,\n                                             const unsigned char *tbs,\n                                             size_t tbslen));\n\nvoid EVP_PKEY_meth_set_verify_recover(EVP_PKEY_METHOD *pmeth,\n                                      int (*verify_recover_init) (EVP_PKEY_CTX\n                                                                  *ctx),\n                                      int (*verify_recover) (EVP_PKEY_CTX\n                                                             *ctx,\n                                                             unsigned char\n                                                             *sig,\n                                                             size_t *siglen,\n                                                             const unsigned\n                                                             char *tbs,\n                                                             size_t tbslen));\n\nvoid EVP_PKEY_meth_set_signctx(EVP_PKEY_METHOD *pmeth,\n                               int (*signctx_init) (EVP_PKEY_CTX *ctx,\n                                                    EVP_MD_CTX *mctx),\n                               int (*signctx) (EVP_PKEY_CTX *ctx,\n                                               unsigned char *sig,\n                                               size_t *siglen,\n                                               EVP_MD_CTX *mctx));\n\nvoid EVP_PKEY_meth_set_verifyctx(EVP_PKEY_METHOD *pmeth,\n                                 int (*verifyctx_init) (EVP_PKEY_CTX *ctx,\n                                                        EVP_MD_CTX *mctx),\n                                 int (*verifyctx) (EVP_PKEY_CTX *ctx,\n                                                   const unsigned char *sig,\n                                                   int siglen,\n                                                   EVP_MD_CTX *mctx));\n\nvoid EVP_PKEY_meth_set_encrypt(EVP_PKEY_METHOD *pmeth,\n                               int (*encrypt_init) (EVP_PKEY_CTX *ctx),\n                               int (*encryptfn) (EVP_PKEY_CTX *ctx,\n                                                 unsigned char *out,\n                                                 size_t *outlen,\n                                                 const unsigned char *in,\n                                                 size_t inlen));\n\nvoid EVP_PKEY_meth_set_decrypt(EVP_PKEY_METHOD *pmeth,\n                               int (*decrypt_init) (EVP_PKEY_CTX *ctx),\n                               int (*decrypt) (EVP_PKEY_CTX *ctx,\n                                               unsigned char *out,\n                                               size_t *outlen,\n                                               const unsigned char *in,\n                                               size_t inlen));\n\nvoid EVP_PKEY_meth_set_derive(EVP_PKEY_METHOD *pmeth,\n                              int (*derive_init) (EVP_PKEY_CTX *ctx),\n                              int (*derive) (EVP_PKEY_CTX *ctx,\n                                             unsigned char *key,\n                                             size_t *keylen));\n\nvoid EVP_PKEY_meth_set_ctrl(EVP_PKEY_METHOD *pmeth,\n                            int (*ctrl) (EVP_PKEY_CTX *ctx, int type, int p1,\n                                         void *p2),\n                            int (*ctrl_str) (EVP_PKEY_CTX *ctx,\n                                             const char *type,\n                                             const char *value));\n\nvoid EVP_add_alg_module(void);\n\n/* BEGIN ERROR CODES */\n/*\n * The following lines are auto generated by the script mkerr.pl. Any changes\n * made after this point may be overwritten when the script is next run.\n */\n\nvoid ERR_load_EVP_strings(void);\n\n/* Error codes for the EVP functions. */\n\n/* Function codes. */\n# define EVP_F_AESNI_INIT_KEY                             165\n# define EVP_F_AESNI_XTS_CIPHER                           176\n# define EVP_F_AES_INIT_KEY                               133\n# define EVP_F_AES_T4_INIT_KEY                            178\n# define EVP_F_AES_XTS                                    172\n# define EVP_F_AES_XTS_CIPHER                             175\n# define EVP_F_ALG_MODULE_INIT                            177\n# define EVP_F_CAMELLIA_INIT_KEY                          159\n# define EVP_F_CMAC_INIT                                  173\n# define EVP_F_CMLL_T4_INIT_KEY                           179\n# define EVP_F_D2I_PKEY                                   100\n# define EVP_F_DO_SIGVER_INIT                             161\n# define EVP_F_DSAPKEY2PKCS8                              134\n# define EVP_F_DSA_PKEY2PKCS8                             135\n# define EVP_F_ECDSA_PKEY2PKCS8                           129\n# define EVP_F_ECKEY_PKEY2PKCS8                           132\n# define EVP_F_EVP_CIPHERINIT_EX                          123\n# define EVP_F_EVP_CIPHER_CTX_COPY                        163\n# define EVP_F_EVP_CIPHER_CTX_CTRL                        124\n# define EVP_F_EVP_CIPHER_CTX_SET_KEY_LENGTH              122\n# define EVP_F_EVP_DECRYPTFINAL_EX                        101\n# define EVP_F_EVP_DIGESTINIT_EX                          128\n# define EVP_F_EVP_ENCRYPTFINAL_EX                        127\n# define EVP_F_EVP_MD_CTX_COPY_EX                         110\n# define EVP_F_EVP_MD_SIZE                                162\n# define EVP_F_EVP_OPENINIT                               102\n# define EVP_F_EVP_PBE_ALG_ADD                            115\n# define EVP_F_EVP_PBE_ALG_ADD_TYPE                       160\n# define EVP_F_EVP_PBE_CIPHERINIT                         116\n# define EVP_F_EVP_PKCS82PKEY                             111\n# define EVP_F_EVP_PKCS82PKEY_BROKEN                      136\n# define EVP_F_EVP_PKEY2PKCS8_BROKEN                      113\n# define EVP_F_EVP_PKEY_COPY_PARAMETERS                   103\n# define EVP_F_EVP_PKEY_CTX_CTRL                          137\n# define EVP_F_EVP_PKEY_CTX_CTRL_STR                      150\n# define EVP_F_EVP_PKEY_CTX_DUP                           156\n# define EVP_F_EVP_PKEY_DECRYPT                           104\n# define EVP_F_EVP_PKEY_DECRYPT_INIT                      138\n# define EVP_F_EVP_PKEY_DECRYPT_OLD                       151\n# define EVP_F_EVP_PKEY_DERIVE                            153\n# define EVP_F_EVP_PKEY_DERIVE_INIT                       154\n# define EVP_F_EVP_PKEY_DERIVE_SET_PEER                   155\n# define EVP_F_EVP_PKEY_ENCRYPT                           105\n# define EVP_F_EVP_PKEY_ENCRYPT_INIT                      139\n# define EVP_F_EVP_PKEY_ENCRYPT_OLD                       152\n# define EVP_F_EVP_PKEY_GET1_DH                           119\n# define EVP_F_EVP_PKEY_GET1_DSA                          120\n# define EVP_F_EVP_PKEY_GET1_ECDSA                        130\n# define EVP_F_EVP_PKEY_GET1_EC_KEY                       131\n# define EVP_F_EVP_PKEY_GET1_RSA                          121\n# define EVP_F_EVP_PKEY_KEYGEN                            146\n# define EVP_F_EVP_PKEY_KEYGEN_INIT                       147\n# define EVP_F_EVP_PKEY_NEW                               106\n# define EVP_F_EVP_PKEY_PARAMGEN                          148\n# define EVP_F_EVP_PKEY_PARAMGEN_INIT                     149\n# define EVP_F_EVP_PKEY_SIGN                              140\n# define EVP_F_EVP_PKEY_SIGN_INIT                         141\n# define EVP_F_EVP_PKEY_VERIFY                            142\n# define EVP_F_EVP_PKEY_VERIFY_INIT                       143\n# define EVP_F_EVP_PKEY_VERIFY_RECOVER                    144\n# define EVP_F_EVP_PKEY_VERIFY_RECOVER_INIT               145\n# define EVP_F_EVP_RIJNDAEL                               126\n# define EVP_F_EVP_SIGNFINAL                              107\n# define EVP_F_EVP_VERIFYFINAL                            108\n# define EVP_F_FIPS_CIPHERINIT                            166\n# define EVP_F_FIPS_CIPHER_CTX_COPY                       170\n# define EVP_F_FIPS_CIPHER_CTX_CTRL                       167\n# define EVP_F_FIPS_CIPHER_CTX_SET_KEY_LENGTH             171\n# define EVP_F_FIPS_DIGESTINIT                            168\n# define EVP_F_FIPS_MD_CTX_COPY                           169\n# define EVP_F_HMAC_INIT_EX                               174\n# define EVP_F_INT_CTX_NEW                                157\n# define EVP_F_PKCS5_PBE_KEYIVGEN                         117\n# define EVP_F_PKCS5_V2_PBE_KEYIVGEN                      118\n# define EVP_F_PKCS5_V2_PBKDF2_KEYIVGEN                   164\n# define EVP_F_PKCS8_SET_BROKEN                           112\n# define EVP_F_PKEY_SET_TYPE                              158\n# define EVP_F_RC2_MAGIC_TO_METH                          109\n# define EVP_F_RC5_CTRL                                   125\n\n/* Reason codes. */\n# define EVP_R_AES_IV_SETUP_FAILED                        162\n# define EVP_R_AES_KEY_SETUP_FAILED                       143\n# define EVP_R_ASN1_LIB                                   140\n# define EVP_R_BAD_BLOCK_LENGTH                           136\n# define EVP_R_BAD_DECRYPT                                100\n# define EVP_R_BAD_KEY_LENGTH                             137\n# define EVP_R_BN_DECODE_ERROR                            112\n# define EVP_R_BN_PUBKEY_ERROR                            113\n# define EVP_R_BUFFER_TOO_SMALL                           155\n# define EVP_R_CAMELLIA_KEY_SETUP_FAILED                  157\n# define EVP_R_CIPHER_PARAMETER_ERROR                     122\n# define EVP_R_COMMAND_NOT_SUPPORTED                      147\n# define EVP_R_CTRL_NOT_IMPLEMENTED                       132\n# define EVP_R_CTRL_OPERATION_NOT_IMPLEMENTED             133\n# define EVP_R_DATA_NOT_MULTIPLE_OF_BLOCK_LENGTH          138\n# define EVP_R_DECODE_ERROR                               114\n# define EVP_R_DIFFERENT_KEY_TYPES                        101\n# define EVP_R_DIFFERENT_PARAMETERS                       153\n# define EVP_R_DISABLED_FOR_FIPS                          163\n# define EVP_R_ENCODE_ERROR                               115\n# define EVP_R_ERROR_LOADING_SECTION                      165\n# define EVP_R_ERROR_SETTING_FIPS_MODE                    166\n# define EVP_R_EVP_PBE_CIPHERINIT_ERROR                   119\n# define EVP_R_EXPECTING_AN_RSA_KEY                       127\n# define EVP_R_EXPECTING_A_DH_KEY                         128\n# define EVP_R_EXPECTING_A_DSA_KEY                        129\n# define EVP_R_EXPECTING_A_ECDSA_KEY                      141\n# define EVP_R_EXPECTING_A_EC_KEY                         142\n# define EVP_R_FIPS_MODE_NOT_SUPPORTED                    167\n# define EVP_R_INITIALIZATION_ERROR                       134\n# define EVP_R_INPUT_NOT_INITIALIZED                      111\n# define EVP_R_INVALID_DIGEST                             152\n# define EVP_R_INVALID_FIPS_MODE                          168\n# define EVP_R_INVALID_KEY                                171\n# define EVP_R_INVALID_KEY_LENGTH                         130\n# define EVP_R_INVALID_OPERATION                          148\n# define EVP_R_IV_TOO_LARGE                               102\n# define EVP_R_KEYGEN_FAILURE                             120\n# define EVP_R_MESSAGE_DIGEST_IS_NULL                     159\n# define EVP_R_METHOD_NOT_SUPPORTED                       144\n# define EVP_R_MISSING_PARAMETERS                         103\n# define EVP_R_NO_CIPHER_SET                              131\n# define EVP_R_NO_DEFAULT_DIGEST                          158\n# define EVP_R_NO_DIGEST_SET                              139\n# define EVP_R_NO_DSA_PARAMETERS                          116\n# define EVP_R_NO_KEY_SET                                 154\n# define EVP_R_NO_OPERATION_SET                           149\n# define EVP_R_NO_SIGN_FUNCTION_CONFIGURED                104\n# define EVP_R_NO_VERIFY_FUNCTION_CONFIGURED              105\n# define EVP_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE   150\n# define EVP_R_OPERATON_NOT_INITIALIZED                   151\n# define EVP_R_PKCS8_UNKNOWN_BROKEN_TYPE                  117\n# define EVP_R_PRIVATE_KEY_DECODE_ERROR                   145\n# define EVP_R_PRIVATE_KEY_ENCODE_ERROR                   146\n# define EVP_R_PUBLIC_KEY_NOT_RSA                         106\n# define EVP_R_TOO_LARGE                                  164\n# define EVP_R_UNKNOWN_CIPHER                             160\n# define EVP_R_UNKNOWN_DIGEST                             161\n# define EVP_R_UNKNOWN_OPTION                             169\n# define EVP_R_UNKNOWN_PBE_ALGORITHM                      121\n# define EVP_R_UNSUPORTED_NUMBER_OF_ROUNDS                135\n# define EVP_R_UNSUPPORTED_ALGORITHM                      156\n# define EVP_R_UNSUPPORTED_CIPHER                         107\n# define EVP_R_UNSUPPORTED_KEYLENGTH                      123\n# define EVP_R_UNSUPPORTED_KEY_DERIVATION_FUNCTION        124\n# define EVP_R_UNSUPPORTED_KEY_SIZE                       108\n# define EVP_R_UNSUPPORTED_PRF                            125\n# define EVP_R_UNSUPPORTED_PRIVATE_KEY_ALGORITHM          118\n# define EVP_R_UNSUPPORTED_SALT_TYPE                      126\n# define EVP_R_WRAP_MODE_NOT_ALLOWED                      170\n# define EVP_R_WRONG_FINAL_BLOCK_LENGTH                   109\n# define EVP_R_WRONG_PUBLIC_KEY_TYPE                      110\n\n# ifdef  __cplusplus\n}\n# endif\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/arm64/include/openssl/hmac.h",
    "content": "/* crypto/hmac/hmac.h */\n/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)\n * All rights reserved.\n *\n * This package is an SSL implementation written\n * by Eric Young (eay@cryptsoft.com).\n * The implementation was written so as to conform with Netscapes SSL.\n *\n * This library is free for commercial and non-commercial use as long as\n * the following conditions are aheared to.  The following conditions\n * apply to all code found in this distribution, be it the RC4, RSA,\n * lhash, DES, etc., code; not just the SSL code.  The SSL documentation\n * included with this distribution is covered by the same copyright terms\n * except that the holder is Tim Hudson (tjh@cryptsoft.com).\n *\n * Copyright remains Eric Young's, and as such any Copyright notices in\n * the code are not to be removed.\n * If this package is used in a product, Eric Young should be given attribution\n * as the author of the parts of the library used.\n * This can be in the form of a textual message at program startup or\n * in documentation (online or textual) provided with the package.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the copyright\n *    notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in the\n *    documentation and/or other materials provided with the distribution.\n * 3. All advertising materials mentioning features or use of this software\n *    must display the following acknowledgement:\n *    \"This product includes cryptographic software written by\n *     Eric Young (eay@cryptsoft.com)\"\n *    The word 'cryptographic' can be left out if the rouines from the library\n *    being used are not cryptographic related :-).\n * 4. If you include any Windows specific code (or a derivative thereof) from\n *    the apps directory (application code) you must include an acknowledgement:\n *    \"This product includes software written by Tim Hudson (tjh@cryptsoft.com)\"\n *\n * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n * SUCH DAMAGE.\n *\n * The licence and distribution terms for any publically available version or\n * derivative of this code cannot be changed.  i.e. this code cannot simply be\n * copied and put under another distribution licence\n * [including the GNU Public Licence.]\n */\n#ifndef HEADER_HMAC_H\n# define HEADER_HMAC_H\n\n# include <openssl/opensslconf.h>\n\n# ifdef OPENSSL_NO_HMAC\n#  error HMAC is disabled.\n# endif\n\n# include <openssl/evp.h>\n\n# define HMAC_MAX_MD_CBLOCK      128/* largest known is SHA512 */\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\ntypedef struct hmac_ctx_st {\n    const EVP_MD *md;\n    EVP_MD_CTX md_ctx;\n    EVP_MD_CTX i_ctx;\n    EVP_MD_CTX o_ctx;\n    unsigned int key_length;\n    unsigned char key[HMAC_MAX_MD_CBLOCK];\n} HMAC_CTX;\n\n# define HMAC_size(e)    (EVP_MD_size((e)->md))\n\nvoid HMAC_CTX_init(HMAC_CTX *ctx);\nvoid HMAC_CTX_cleanup(HMAC_CTX *ctx);\n\n/* deprecated */\n# define HMAC_cleanup(ctx) HMAC_CTX_cleanup(ctx)\n\n/* deprecated */\nint HMAC_Init(HMAC_CTX *ctx, const void *key, int len, const EVP_MD *md);\nint HMAC_Init_ex(HMAC_CTX *ctx, const void *key, int len,\n                 const EVP_MD *md, ENGINE *impl);\nint HMAC_Update(HMAC_CTX *ctx, const unsigned char *data, size_t len);\nint HMAC_Final(HMAC_CTX *ctx, unsigned char *md, unsigned int *len);\nunsigned char *HMAC(const EVP_MD *evp_md, const void *key, int key_len,\n                    const unsigned char *d, size_t n, unsigned char *md,\n                    unsigned int *md_len);\nint HMAC_CTX_copy(HMAC_CTX *dctx, HMAC_CTX *sctx);\n\nvoid HMAC_CTX_set_flags(HMAC_CTX *ctx, unsigned long flags);\n\n#ifdef  __cplusplus\n}\n#endif\n\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/arm64/include/openssl/idea.h",
    "content": "/* crypto/idea/idea.h */\n/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)\n * All rights reserved.\n *\n * This package is an SSL implementation written\n * by Eric Young (eay@cryptsoft.com).\n * The implementation was written so as to conform with Netscapes SSL.\n *\n * This library is free for commercial and non-commercial use as long as\n * the following conditions are aheared to.  The following conditions\n * apply to all code found in this distribution, be it the RC4, RSA,\n * lhash, DES, etc., code; not just the SSL code.  The SSL documentation\n * included with this distribution is covered by the same copyright terms\n * except that the holder is Tim Hudson (tjh@cryptsoft.com).\n *\n * Copyright remains Eric Young's, and as such any Copyright notices in\n * the code are not to be removed.\n * If this package is used in a product, Eric Young should be given attribution\n * as the author of the parts of the library used.\n * This can be in the form of a textual message at program startup or\n * in documentation (online or textual) provided with the package.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the copyright\n *    notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in the\n *    documentation and/or other materials provided with the distribution.\n * 3. All advertising materials mentioning features or use of this software\n *    must display the following acknowledgement:\n *    \"This product includes cryptographic software written by\n *     Eric Young (eay@cryptsoft.com)\"\n *    The word 'cryptographic' can be left out if the rouines from the library\n *    being used are not cryptographic related :-).\n * 4. If you include any Windows specific code (or a derivative thereof) from\n *    the apps directory (application code) you must include an acknowledgement:\n *    \"This product includes software written by Tim Hudson (tjh@cryptsoft.com)\"\n *\n * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n * SUCH DAMAGE.\n *\n * The licence and distribution terms for any publically available version or\n * derivative of this code cannot be changed.  i.e. this code cannot simply be\n * copied and put under another distribution licence\n * [including the GNU Public Licence.]\n */\n\n#ifndef HEADER_IDEA_H\n# define HEADER_IDEA_H\n\n# include <openssl/opensslconf.h>/* IDEA_INT, OPENSSL_NO_IDEA */\n\n# ifdef OPENSSL_NO_IDEA\n#  error IDEA is disabled.\n# endif\n\n# define IDEA_ENCRYPT    1\n# define IDEA_DECRYPT    0\n\n# define IDEA_BLOCK      8\n# define IDEA_KEY_LENGTH 16\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\ntypedef struct idea_key_st {\n    IDEA_INT data[9][6];\n} IDEA_KEY_SCHEDULE;\n\nconst char *idea_options(void);\nvoid idea_ecb_encrypt(const unsigned char *in, unsigned char *out,\n                      IDEA_KEY_SCHEDULE *ks);\n# ifdef OPENSSL_FIPS\nvoid private_idea_set_encrypt_key(const unsigned char *key,\n                                  IDEA_KEY_SCHEDULE *ks);\n# endif\nvoid idea_set_encrypt_key(const unsigned char *key, IDEA_KEY_SCHEDULE *ks);\nvoid idea_set_decrypt_key(IDEA_KEY_SCHEDULE *ek, IDEA_KEY_SCHEDULE *dk);\nvoid idea_cbc_encrypt(const unsigned char *in, unsigned char *out,\n                      long length, IDEA_KEY_SCHEDULE *ks, unsigned char *iv,\n                      int enc);\nvoid idea_cfb64_encrypt(const unsigned char *in, unsigned char *out,\n                        long length, IDEA_KEY_SCHEDULE *ks, unsigned char *iv,\n                        int *num, int enc);\nvoid idea_ofb64_encrypt(const unsigned char *in, unsigned char *out,\n                        long length, IDEA_KEY_SCHEDULE *ks, unsigned char *iv,\n                        int *num);\nvoid idea_encrypt(unsigned long *in, IDEA_KEY_SCHEDULE *ks);\n#ifdef  __cplusplus\n}\n#endif\n\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/arm64/include/openssl/krb5_asn.h",
    "content": "/* krb5_asn.h */\n/*\n * Written by Vern Staats <staatsvr@asc.hpc.mil> for the OpenSSL project, **\n * using ocsp/{*.h,*asn*.c} as a starting point\n */\n\n/* ====================================================================\n * Copyright (c) 1998-2000 The OpenSSL Project.  All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n *\n * 1. Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n *\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in\n *    the documentation and/or other materials provided with the\n *    distribution.\n *\n * 3. All advertising materials mentioning features or use of this\n *    software must display the following acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit. (http://www.openssl.org/)\"\n *\n * 4. The names \"OpenSSL Toolkit\" and \"OpenSSL Project\" must not be used to\n *    endorse or promote products derived from this software without\n *    prior written permission. For written permission, please contact\n *    openssl-core@openssl.org.\n *\n * 5. Products derived from this software may not be called \"OpenSSL\"\n *    nor may \"OpenSSL\" appear in their names without prior written\n *    permission of the OpenSSL Project.\n *\n * 6. Redistributions of any form whatsoever must retain the following\n *    acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit (http://www.openssl.org/)\"\n *\n * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY\n * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\n * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR\n * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\n * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,\n * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED\n * OF THE POSSIBILITY OF SUCH DAMAGE.\n * ====================================================================\n *\n * This product includes cryptographic software written by Eric Young\n * (eay@cryptsoft.com).  This product includes software written by Tim\n * Hudson (tjh@cryptsoft.com).\n *\n */\n\n#ifndef HEADER_KRB5_ASN_H\n# define HEADER_KRB5_ASN_H\n\n/*\n * #include <krb5.h>\n */\n# include <openssl/safestack.h>\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n/*\n * ASN.1 from Kerberos RFC 1510\n */\n\n/*-     EncryptedData ::=   SEQUENCE {\n *              etype[0]                      INTEGER, -- EncryptionType\n *              kvno[1]                       INTEGER OPTIONAL,\n *              cipher[2]                     OCTET STRING -- ciphertext\n *      }\n */\ntypedef struct krb5_encdata_st {\n    ASN1_INTEGER *etype;\n    ASN1_INTEGER *kvno;\n    ASN1_OCTET_STRING *cipher;\n} KRB5_ENCDATA;\n\nDECLARE_STACK_OF(KRB5_ENCDATA)\n\n/*-     PrincipalName ::=   SEQUENCE {\n *              name-type[0]                  INTEGER,\n *              name-string[1]                SEQUENCE OF GeneralString\n *      }\n */\ntypedef struct krb5_princname_st {\n    ASN1_INTEGER *nametype;\n    STACK_OF(ASN1_GENERALSTRING) *namestring;\n} KRB5_PRINCNAME;\n\nDECLARE_STACK_OF(KRB5_PRINCNAME)\n\n/*-     Ticket ::=      [APPLICATION 1] SEQUENCE {\n *              tkt-vno[0]                    INTEGER,\n *              realm[1]                      Realm,\n *              sname[2]                      PrincipalName,\n *              enc-part[3]                   EncryptedData\n *      }\n */\ntypedef struct krb5_tktbody_st {\n    ASN1_INTEGER *tktvno;\n    ASN1_GENERALSTRING *realm;\n    KRB5_PRINCNAME *sname;\n    KRB5_ENCDATA *encdata;\n} KRB5_TKTBODY;\n\ntypedef STACK_OF(KRB5_TKTBODY) KRB5_TICKET;\nDECLARE_STACK_OF(KRB5_TKTBODY)\n\n/*-     AP-REQ ::=      [APPLICATION 14] SEQUENCE {\n *              pvno[0]                       INTEGER,\n *              msg-type[1]                   INTEGER,\n *              ap-options[2]                 APOptions,\n *              ticket[3]                     Ticket,\n *              authenticator[4]              EncryptedData\n *      }\n *\n *      APOptions ::=   BIT STRING {\n *              reserved(0), use-session-key(1), mutual-required(2) }\n */\ntypedef struct krb5_ap_req_st {\n    ASN1_INTEGER *pvno;\n    ASN1_INTEGER *msgtype;\n    ASN1_BIT_STRING *apoptions;\n    KRB5_TICKET *ticket;\n    KRB5_ENCDATA *authenticator;\n} KRB5_APREQBODY;\n\ntypedef STACK_OF(KRB5_APREQBODY) KRB5_APREQ;\nDECLARE_STACK_OF(KRB5_APREQBODY)\n\n/*      Authenticator Stuff     */\n\n/*-     Checksum ::=   SEQUENCE {\n *              cksumtype[0]                  INTEGER,\n *              checksum[1]                   OCTET STRING\n *      }\n */\ntypedef struct krb5_checksum_st {\n    ASN1_INTEGER *ctype;\n    ASN1_OCTET_STRING *checksum;\n} KRB5_CHECKSUM;\n\nDECLARE_STACK_OF(KRB5_CHECKSUM)\n\n/*-     EncryptionKey ::=   SEQUENCE {\n *              keytype[0]                    INTEGER,\n *              keyvalue[1]                   OCTET STRING\n *      }\n */\ntypedef struct krb5_encryptionkey_st {\n    ASN1_INTEGER *ktype;\n    ASN1_OCTET_STRING *keyvalue;\n} KRB5_ENCKEY;\n\nDECLARE_STACK_OF(KRB5_ENCKEY)\n\n/*-     AuthorizationData ::=   SEQUENCE OF SEQUENCE {\n *              ad-type[0]                    INTEGER,\n *              ad-data[1]                    OCTET STRING\n *      }\n */\ntypedef struct krb5_authorization_st {\n    ASN1_INTEGER *adtype;\n    ASN1_OCTET_STRING *addata;\n} KRB5_AUTHDATA;\n\nDECLARE_STACK_OF(KRB5_AUTHDATA)\n\n/*-     -- Unencrypted authenticator\n *      Authenticator ::=    [APPLICATION 2] SEQUENCE    {\n *              authenticator-vno[0]          INTEGER,\n *              crealm[1]                     Realm,\n *              cname[2]                      PrincipalName,\n *              cksum[3]                      Checksum OPTIONAL,\n *              cusec[4]                      INTEGER,\n *              ctime[5]                      KerberosTime,\n *              subkey[6]                     EncryptionKey OPTIONAL,\n *              seq-number[7]                 INTEGER OPTIONAL,\n *              authorization-data[8]         AuthorizationData OPTIONAL\n *      }\n */\ntypedef struct krb5_authenticator_st {\n    ASN1_INTEGER *avno;\n    ASN1_GENERALSTRING *crealm;\n    KRB5_PRINCNAME *cname;\n    KRB5_CHECKSUM *cksum;\n    ASN1_INTEGER *cusec;\n    ASN1_GENERALIZEDTIME *ctime;\n    KRB5_ENCKEY *subkey;\n    ASN1_INTEGER *seqnum;\n    KRB5_AUTHDATA *authorization;\n} KRB5_AUTHENTBODY;\n\ntypedef STACK_OF(KRB5_AUTHENTBODY) KRB5_AUTHENT;\nDECLARE_STACK_OF(KRB5_AUTHENTBODY)\n\n/*-  DECLARE_ASN1_FUNCTIONS(type) = DECLARE_ASN1_FUNCTIONS_name(type, type) =\n *      type *name##_new(void);\n *      void name##_free(type *a);\n *      DECLARE_ASN1_ENCODE_FUNCTIONS(type, name, name) =\n *       DECLARE_ASN1_ENCODE_FUNCTIONS(type, itname, name) =\n *        type *d2i_##name(type **a, const unsigned char **in, long len);\n *        int i2d_##name(type *a, unsigned char **out);\n *        DECLARE_ASN1_ITEM(itname) = OPENSSL_EXTERN const ASN1_ITEM itname##_it\n */\n\nDECLARE_ASN1_FUNCTIONS(KRB5_ENCDATA)\nDECLARE_ASN1_FUNCTIONS(KRB5_PRINCNAME)\nDECLARE_ASN1_FUNCTIONS(KRB5_TKTBODY)\nDECLARE_ASN1_FUNCTIONS(KRB5_APREQBODY)\nDECLARE_ASN1_FUNCTIONS(KRB5_TICKET)\nDECLARE_ASN1_FUNCTIONS(KRB5_APREQ)\n\nDECLARE_ASN1_FUNCTIONS(KRB5_CHECKSUM)\nDECLARE_ASN1_FUNCTIONS(KRB5_ENCKEY)\nDECLARE_ASN1_FUNCTIONS(KRB5_AUTHDATA)\nDECLARE_ASN1_FUNCTIONS(KRB5_AUTHENTBODY)\nDECLARE_ASN1_FUNCTIONS(KRB5_AUTHENT)\n\n/* BEGIN ERROR CODES */\n/*\n * The following lines are auto generated by the script mkerr.pl. Any changes\n * made after this point may be overwritten when the script is next run.\n */\n\n#ifdef  __cplusplus\n}\n#endif\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/arm64/include/openssl/kssl.h",
    "content": "/* ssl/kssl.h */\n/*\n * Written by Vern Staats <staatsvr@asc.hpc.mil> for the OpenSSL project\n * 2000. project 2000.\n */\n/* ====================================================================\n * Copyright (c) 2000 The OpenSSL Project.  All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n *\n * 1. Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n *\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in\n *    the documentation and/or other materials provided with the\n *    distribution.\n *\n * 3. All advertising materials mentioning features or use of this\n *    software must display the following acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)\"\n *\n * 4. The names \"OpenSSL Toolkit\" and \"OpenSSL Project\" must not be used to\n *    endorse or promote products derived from this software without\n *    prior written permission. For written permission, please contact\n *    licensing@OpenSSL.org.\n *\n * 5. Products derived from this software may not be called \"OpenSSL\"\n *    nor may \"OpenSSL\" appear in their names without prior written\n *    permission of the OpenSSL Project.\n *\n * 6. Redistributions of any form whatsoever must retain the following\n *    acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)\"\n *\n * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY\n * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\n * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR\n * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\n * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,\n * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED\n * OF THE POSSIBILITY OF SUCH DAMAGE.\n * ====================================================================\n *\n * This product includes cryptographic software written by Eric Young\n * (eay@cryptsoft.com).  This product includes software written by Tim\n * Hudson (tjh@cryptsoft.com).\n *\n */\n\n/*\n **      19990701        VRS     Started.\n */\n\n#ifndef KSSL_H\n# define KSSL_H\n\n# include <openssl/opensslconf.h>\n\n# ifndef OPENSSL_NO_KRB5\n\n#  include <stdio.h>\n#  include <ctype.h>\n#  include <krb5.h>\n#  ifdef OPENSSL_SYS_WIN32\n/*\n * These can sometimes get redefined indirectly by krb5 header files after\n * they get undefed in ossl_typ.h\n */\n#   undef X509_NAME\n#   undef X509_EXTENSIONS\n#   undef OCSP_REQUEST\n#   undef OCSP_RESPONSE\n#  endif\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n/*\n *      Depending on which KRB5 implementation used, some types from\n *      the other may be missing.  Resolve that here and now\n */\n#  ifdef KRB5_HEIMDAL\ntypedef unsigned char krb5_octet;\n#   define FAR\n#  else\n\n#   ifndef FAR\n#    define FAR\n#   endif\n\n#  endif\n\n/*-\n *      Uncomment this to debug kssl problems or\n *      to trace usage of the Kerberos session key\n *\n *      #define         KSSL_DEBUG\n */\n\n#  ifndef KRB5SVC\n#   define KRB5SVC \"host\"\n#  endif\n\n#  ifndef KRB5KEYTAB\n#   define KRB5KEYTAB      \"/etc/krb5.keytab\"\n#  endif\n\n#  ifndef KRB5SENDAUTH\n#   define KRB5SENDAUTH    1\n#  endif\n\n#  ifndef KRB5CHECKAUTH\n#   define KRB5CHECKAUTH   1\n#  endif\n\n#  ifndef KSSL_CLOCKSKEW\n#   define KSSL_CLOCKSKEW  300;\n#  endif\n\n#  define KSSL_ERR_MAX    255\ntypedef struct kssl_err_st {\n    int reason;\n    char text[KSSL_ERR_MAX + 1];\n} KSSL_ERR;\n\n/*-     Context for passing\n *              (1) Kerberos session key to SSL, and\n *              (2)     Config data between application and SSL lib\n */\ntypedef struct kssl_ctx_st {\n    /*      used by:    disposition:            */\n    char *service_name;         /* C,S default ok (kssl) */\n    char *service_host;         /* C input, REQUIRED */\n    char *client_princ;         /* S output from krb5 ticket */\n    char *keytab_file;          /* S NULL (/etc/krb5.keytab) */\n    char *cred_cache;           /* C NULL (default) */\n    krb5_enctype enctype;\n    int length;\n    krb5_octet FAR *key;\n} KSSL_CTX;\n\n#  define KSSL_CLIENT     1\n#  define KSSL_SERVER     2\n#  define KSSL_SERVICE    3\n#  define KSSL_KEYTAB     4\n\n#  define KSSL_CTX_OK     0\n#  define KSSL_CTX_ERR    1\n#  define KSSL_NOMEM      2\n\n/* Public (for use by applications that use OpenSSL with Kerberos 5 support */\nkrb5_error_code kssl_ctx_setstring(KSSL_CTX *kssl_ctx, int which, char *text);\nKSSL_CTX *kssl_ctx_new(void);\nKSSL_CTX *kssl_ctx_free(KSSL_CTX *kssl_ctx);\nvoid kssl_ctx_show(KSSL_CTX *kssl_ctx);\nkrb5_error_code kssl_ctx_setprinc(KSSL_CTX *kssl_ctx, int which,\n                                  krb5_data *realm, krb5_data *entity,\n                                  int nentities);\nkrb5_error_code kssl_cget_tkt(KSSL_CTX *kssl_ctx, krb5_data **enc_tktp,\n                              krb5_data *authenp, KSSL_ERR *kssl_err);\nkrb5_error_code kssl_sget_tkt(KSSL_CTX *kssl_ctx, krb5_data *indata,\n                              krb5_ticket_times *ttimes, KSSL_ERR *kssl_err);\nkrb5_error_code kssl_ctx_setkey(KSSL_CTX *kssl_ctx, krb5_keyblock *session);\nvoid kssl_err_set(KSSL_ERR *kssl_err, int reason, char *text);\nvoid kssl_krb5_free_data_contents(krb5_context context, krb5_data *data);\nkrb5_error_code kssl_build_principal_2(krb5_context context,\n                                       krb5_principal *princ, int rlen,\n                                       const char *realm, int slen,\n                                       const char *svc, int hlen,\n                                       const char *host);\nkrb5_error_code kssl_validate_times(krb5_timestamp atime,\n                                    krb5_ticket_times *ttimes);\nkrb5_error_code kssl_check_authent(KSSL_CTX *kssl_ctx, krb5_data *authentp,\n                                   krb5_timestamp *atimep,\n                                   KSSL_ERR *kssl_err);\nunsigned char *kssl_skip_confound(krb5_enctype enctype, unsigned char *authn);\n\nvoid SSL_set0_kssl_ctx(SSL *s, KSSL_CTX *kctx);\nKSSL_CTX *SSL_get0_kssl_ctx(SSL *s);\nchar *kssl_ctx_get0_client_princ(KSSL_CTX *kctx);\n\n#ifdef  __cplusplus\n}\n#endif\n# endif                         /* OPENSSL_NO_KRB5 */\n#endif                          /* KSSL_H */\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/arm64/include/openssl/lhash.h",
    "content": "/* crypto/lhash/lhash.h */\n/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)\n * All rights reserved.\n *\n * This package is an SSL implementation written\n * by Eric Young (eay@cryptsoft.com).\n * The implementation was written so as to conform with Netscapes SSL.\n *\n * This library is free for commercial and non-commercial use as long as\n * the following conditions are aheared to.  The following conditions\n * apply to all code found in this distribution, be it the RC4, RSA,\n * lhash, DES, etc., code; not just the SSL code.  The SSL documentation\n * included with this distribution is covered by the same copyright terms\n * except that the holder is Tim Hudson (tjh@cryptsoft.com).\n *\n * Copyright remains Eric Young's, and as such any Copyright notices in\n * the code are not to be removed.\n * If this package is used in a product, Eric Young should be given attribution\n * as the author of the parts of the library used.\n * This can be in the form of a textual message at program startup or\n * in documentation (online or textual) provided with the package.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the copyright\n *    notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in the\n *    documentation and/or other materials provided with the distribution.\n * 3. All advertising materials mentioning features or use of this software\n *    must display the following acknowledgement:\n *    \"This product includes cryptographic software written by\n *     Eric Young (eay@cryptsoft.com)\"\n *    The word 'cryptographic' can be left out if the rouines from the library\n *    being used are not cryptographic related :-).\n * 4. If you include any Windows specific code (or a derivative thereof) from\n *    the apps directory (application code) you must include an acknowledgement:\n *    \"This product includes software written by Tim Hudson (tjh@cryptsoft.com)\"\n *\n * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n * SUCH DAMAGE.\n *\n * The licence and distribution terms for any publically available version or\n * derivative of this code cannot be changed.  i.e. this code cannot simply be\n * copied and put under another distribution licence\n * [including the GNU Public Licence.]\n */\n\n/*\n * Header for dynamic hash table routines Author - Eric Young\n */\n\n#ifndef HEADER_LHASH_H\n# define HEADER_LHASH_H\n\n# include <openssl/e_os2.h>\n# ifndef OPENSSL_NO_FP_API\n#  include <stdio.h>\n# endif\n\n# ifndef OPENSSL_NO_BIO\n#  include <openssl/bio.h>\n# endif\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\ntypedef struct lhash_node_st {\n    void *data;\n    struct lhash_node_st *next;\n# ifndef OPENSSL_NO_HASH_COMP\n    unsigned long hash;\n# endif\n} LHASH_NODE;\n\ntypedef int (*LHASH_COMP_FN_TYPE) (const void *, const void *);\ntypedef unsigned long (*LHASH_HASH_FN_TYPE) (const void *);\ntypedef void (*LHASH_DOALL_FN_TYPE) (void *);\ntypedef void (*LHASH_DOALL_ARG_FN_TYPE) (void *, void *);\n\n/*\n * Macros for declaring and implementing type-safe wrappers for LHASH\n * callbacks. This way, callbacks can be provided to LHASH structures without\n * function pointer casting and the macro-defined callbacks provide\n * per-variable casting before deferring to the underlying type-specific\n * callbacks. NB: It is possible to place a \"static\" in front of both the\n * DECLARE and IMPLEMENT macros if the functions are strictly internal.\n */\n\n/* First: \"hash\" functions */\n# define DECLARE_LHASH_HASH_FN(name, o_type) \\\n        unsigned long name##_LHASH_HASH(const void *);\n# define IMPLEMENT_LHASH_HASH_FN(name, o_type) \\\n        unsigned long name##_LHASH_HASH(const void *arg) { \\\n                const o_type *a = arg; \\\n                return name##_hash(a); }\n# define LHASH_HASH_FN(name) name##_LHASH_HASH\n\n/* Second: \"compare\" functions */\n# define DECLARE_LHASH_COMP_FN(name, o_type) \\\n        int name##_LHASH_COMP(const void *, const void *);\n# define IMPLEMENT_LHASH_COMP_FN(name, o_type) \\\n        int name##_LHASH_COMP(const void *arg1, const void *arg2) { \\\n                const o_type *a = arg1;             \\\n                const o_type *b = arg2; \\\n                return name##_cmp(a,b); }\n# define LHASH_COMP_FN(name) name##_LHASH_COMP\n\n/* Third: \"doall\" functions */\n# define DECLARE_LHASH_DOALL_FN(name, o_type) \\\n        void name##_LHASH_DOALL(void *);\n# define IMPLEMENT_LHASH_DOALL_FN(name, o_type) \\\n        void name##_LHASH_DOALL(void *arg) { \\\n                o_type *a = arg; \\\n                name##_doall(a); }\n# define LHASH_DOALL_FN(name) name##_LHASH_DOALL\n\n/* Fourth: \"doall_arg\" functions */\n# define DECLARE_LHASH_DOALL_ARG_FN(name, o_type, a_type) \\\n        void name##_LHASH_DOALL_ARG(void *, void *);\n# define IMPLEMENT_LHASH_DOALL_ARG_FN(name, o_type, a_type) \\\n        void name##_LHASH_DOALL_ARG(void *arg1, void *arg2) { \\\n                o_type *a = arg1; \\\n                a_type *b = arg2; \\\n                name##_doall_arg(a, b); }\n# define LHASH_DOALL_ARG_FN(name) name##_LHASH_DOALL_ARG\n\ntypedef struct lhash_st {\n    LHASH_NODE **b;\n    LHASH_COMP_FN_TYPE comp;\n    LHASH_HASH_FN_TYPE hash;\n    unsigned int num_nodes;\n    unsigned int num_alloc_nodes;\n    unsigned int p;\n    unsigned int pmax;\n    unsigned long up_load;      /* load times 256 */\n    unsigned long down_load;    /* load times 256 */\n    unsigned long num_items;\n    unsigned long num_expands;\n    unsigned long num_expand_reallocs;\n    unsigned long num_contracts;\n    unsigned long num_contract_reallocs;\n    unsigned long num_hash_calls;\n    unsigned long num_comp_calls;\n    unsigned long num_insert;\n    unsigned long num_replace;\n    unsigned long num_delete;\n    unsigned long num_no_delete;\n    unsigned long num_retrieve;\n    unsigned long num_retrieve_miss;\n    unsigned long num_hash_comps;\n    int error;\n} _LHASH;                       /* Do not use _LHASH directly, use LHASH_OF\n                                 * and friends */\n\n# define LH_LOAD_MULT    256\n\n/*\n * Indicates a malloc() error in the last call, this is only bad in\n * lh_insert().\n */\n# define lh_error(lh)    ((lh)->error)\n\n_LHASH *lh_new(LHASH_HASH_FN_TYPE h, LHASH_COMP_FN_TYPE c);\nvoid lh_free(_LHASH *lh);\nvoid *lh_insert(_LHASH *lh, void *data);\nvoid *lh_delete(_LHASH *lh, const void *data);\nvoid *lh_retrieve(_LHASH *lh, const void *data);\nvoid lh_doall(_LHASH *lh, LHASH_DOALL_FN_TYPE func);\nvoid lh_doall_arg(_LHASH *lh, LHASH_DOALL_ARG_FN_TYPE func, void *arg);\nunsigned long lh_strhash(const char *c);\nunsigned long lh_num_items(const _LHASH *lh);\n\n# ifndef OPENSSL_NO_FP_API\nvoid lh_stats(const _LHASH *lh, FILE *out);\nvoid lh_node_stats(const _LHASH *lh, FILE *out);\nvoid lh_node_usage_stats(const _LHASH *lh, FILE *out);\n# endif\n\n# ifndef OPENSSL_NO_BIO\nvoid lh_stats_bio(const _LHASH *lh, BIO *out);\nvoid lh_node_stats_bio(const _LHASH *lh, BIO *out);\nvoid lh_node_usage_stats_bio(const _LHASH *lh, BIO *out);\n# endif\n\n/* Type checking... */\n\n# define LHASH_OF(type) struct lhash_st_##type\n\n# define DECLARE_LHASH_OF(type) LHASH_OF(type) { int dummy; }\n\n# define CHECKED_LHASH_OF(type,lh) \\\n  ((_LHASH *)CHECKED_PTR_OF(LHASH_OF(type),lh))\n\n/* Define wrapper functions. */\n# define LHM_lh_new(type, name) \\\n  ((LHASH_OF(type) *)lh_new(LHASH_HASH_FN(name), LHASH_COMP_FN(name)))\n# define LHM_lh_error(type, lh) \\\n  lh_error(CHECKED_LHASH_OF(type,lh))\n# define LHM_lh_insert(type, lh, inst) \\\n  ((type *)lh_insert(CHECKED_LHASH_OF(type, lh), \\\n                     CHECKED_PTR_OF(type, inst)))\n# define LHM_lh_retrieve(type, lh, inst) \\\n  ((type *)lh_retrieve(CHECKED_LHASH_OF(type, lh), \\\n                       CHECKED_PTR_OF(type, inst)))\n# define LHM_lh_delete(type, lh, inst) \\\n  ((type *)lh_delete(CHECKED_LHASH_OF(type, lh),                        \\\n                     CHECKED_PTR_OF(type, inst)))\n# define LHM_lh_doall(type, lh,fn) lh_doall(CHECKED_LHASH_OF(type, lh), fn)\n# define LHM_lh_doall_arg(type, lh, fn, arg_type, arg) \\\n  lh_doall_arg(CHECKED_LHASH_OF(type, lh), fn, CHECKED_PTR_OF(arg_type, arg))\n# define LHM_lh_num_items(type, lh) lh_num_items(CHECKED_LHASH_OF(type, lh))\n# define LHM_lh_down_load(type, lh) (CHECKED_LHASH_OF(type, lh)->down_load)\n# define LHM_lh_node_stats_bio(type, lh, out) \\\n  lh_node_stats_bio(CHECKED_LHASH_OF(type, lh), out)\n# define LHM_lh_node_usage_stats_bio(type, lh, out) \\\n  lh_node_usage_stats_bio(CHECKED_LHASH_OF(type, lh), out)\n# define LHM_lh_stats_bio(type, lh, out) \\\n  lh_stats_bio(CHECKED_LHASH_OF(type, lh), out)\n# define LHM_lh_free(type, lh) lh_free(CHECKED_LHASH_OF(type, lh))\n\nDECLARE_LHASH_OF(OPENSSL_STRING);\nDECLARE_LHASH_OF(OPENSSL_CSTRING);\n\n#ifdef  __cplusplus\n}\n#endif\n\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/arm64/include/openssl/md4.h",
    "content": "/* crypto/md4/md4.h */\n/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)\n * All rights reserved.\n *\n * This package is an SSL implementation written\n * by Eric Young (eay@cryptsoft.com).\n * The implementation was written so as to conform with Netscapes SSL.\n *\n * This library is free for commercial and non-commercial use as long as\n * the following conditions are aheared to.  The following conditions\n * apply to all code found in this distribution, be it the RC4, RSA,\n * lhash, DES, etc., code; not just the SSL code.  The SSL documentation\n * included with this distribution is covered by the same copyright terms\n * except that the holder is Tim Hudson (tjh@cryptsoft.com).\n *\n * Copyright remains Eric Young's, and as such any Copyright notices in\n * the code are not to be removed.\n * If this package is used in a product, Eric Young should be given attribution\n * as the author of the parts of the library used.\n * This can be in the form of a textual message at program startup or\n * in documentation (online or textual) provided with the package.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the copyright\n *    notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in the\n *    documentation and/or other materials provided with the distribution.\n * 3. All advertising materials mentioning features or use of this software\n *    must display the following acknowledgement:\n *    \"This product includes cryptographic software written by\n *     Eric Young (eay@cryptsoft.com)\"\n *    The word 'cryptographic' can be left out if the rouines from the library\n *    being used are not cryptographic related :-).\n * 4. If you include any Windows specific code (or a derivative thereof) from\n *    the apps directory (application code) you must include an acknowledgement:\n *    \"This product includes software written by Tim Hudson (tjh@cryptsoft.com)\"\n *\n * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n * SUCH DAMAGE.\n *\n * The licence and distribution terms for any publically available version or\n * derivative of this code cannot be changed.  i.e. this code cannot simply be\n * copied and put under another distribution licence\n * [including the GNU Public Licence.]\n */\n\n#ifndef HEADER_MD4_H\n# define HEADER_MD4_H\n\n# include <openssl/e_os2.h>\n# include <stddef.h>\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n# ifdef OPENSSL_NO_MD4\n#  error MD4 is disabled.\n# endif\n\n/*-\n * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n * ! MD4_LONG has to be at least 32 bits wide. If it's wider, then !\n * ! MD4_LONG_LOG2 has to be defined along.                        !\n * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n */\n\n# if defined(__LP32__)\n#  define MD4_LONG unsigned long\n# elif defined(OPENSSL_SYS_CRAY) || defined(__ILP64__)\n#  define MD4_LONG unsigned long\n#  define MD4_LONG_LOG2 3\n/*\n * _CRAY note. I could declare short, but I have no idea what impact\n * does it have on performance on none-T3E machines. I could declare\n * int, but at least on C90 sizeof(int) can be chosen at compile time.\n * So I've chosen long...\n *                                      <appro@fy.chalmers.se>\n */\n# else\n#  define MD4_LONG unsigned int\n# endif\n\n# define MD4_CBLOCK      64\n# define MD4_LBLOCK      (MD4_CBLOCK/4)\n# define MD4_DIGEST_LENGTH 16\n\ntypedef struct MD4state_st {\n    MD4_LONG A, B, C, D;\n    MD4_LONG Nl, Nh;\n    MD4_LONG data[MD4_LBLOCK];\n    unsigned int num;\n} MD4_CTX;\n\n# ifdef OPENSSL_FIPS\nint private_MD4_Init(MD4_CTX *c);\n# endif\nint MD4_Init(MD4_CTX *c);\nint MD4_Update(MD4_CTX *c, const void *data, size_t len);\nint MD4_Final(unsigned char *md, MD4_CTX *c);\nunsigned char *MD4(const unsigned char *d, size_t n, unsigned char *md);\nvoid MD4_Transform(MD4_CTX *c, const unsigned char *b);\n#ifdef  __cplusplus\n}\n#endif\n\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/arm64/include/openssl/md5.h",
    "content": "/* crypto/md5/md5.h */\n/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)\n * All rights reserved.\n *\n * This package is an SSL implementation written\n * by Eric Young (eay@cryptsoft.com).\n * The implementation was written so as to conform with Netscapes SSL.\n *\n * This library is free for commercial and non-commercial use as long as\n * the following conditions are aheared to.  The following conditions\n * apply to all code found in this distribution, be it the RC4, RSA,\n * lhash, DES, etc., code; not just the SSL code.  The SSL documentation\n * included with this distribution is covered by the same copyright terms\n * except that the holder is Tim Hudson (tjh@cryptsoft.com).\n *\n * Copyright remains Eric Young's, and as such any Copyright notices in\n * the code are not to be removed.\n * If this package is used in a product, Eric Young should be given attribution\n * as the author of the parts of the library used.\n * This can be in the form of a textual message at program startup or\n * in documentation (online or textual) provided with the package.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the copyright\n *    notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in the\n *    documentation and/or other materials provided with the distribution.\n * 3. All advertising materials mentioning features or use of this software\n *    must display the following acknowledgement:\n *    \"This product includes cryptographic software written by\n *     Eric Young (eay@cryptsoft.com)\"\n *    The word 'cryptographic' can be left out if the rouines from the library\n *    being used are not cryptographic related :-).\n * 4. If you include any Windows specific code (or a derivative thereof) from\n *    the apps directory (application code) you must include an acknowledgement:\n *    \"This product includes software written by Tim Hudson (tjh@cryptsoft.com)\"\n *\n * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n * SUCH DAMAGE.\n *\n * The licence and distribution terms for any publically available version or\n * derivative of this code cannot be changed.  i.e. this code cannot simply be\n * copied and put under another distribution licence\n * [including the GNU Public Licence.]\n */\n\n#ifndef HEADER_MD5_H\n# define HEADER_MD5_H\n\n# include <openssl/e_os2.h>\n# include <stddef.h>\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n# ifdef OPENSSL_NO_MD5\n#  error MD5 is disabled.\n# endif\n\n/*\n * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n * ! MD5_LONG has to be at least 32 bits wide. If it's wider, then !\n * ! MD5_LONG_LOG2 has to be defined along.                        !\n * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n */\n\n# if defined(__LP32__)\n#  define MD5_LONG unsigned long\n# elif defined(OPENSSL_SYS_CRAY) || defined(__ILP64__)\n#  define MD5_LONG unsigned long\n#  define MD5_LONG_LOG2 3\n/*\n * _CRAY note. I could declare short, but I have no idea what impact\n * does it have on performance on none-T3E machines. I could declare\n * int, but at least on C90 sizeof(int) can be chosen at compile time.\n * So I've chosen long...\n *                                      <appro@fy.chalmers.se>\n */\n# else\n#  define MD5_LONG unsigned int\n# endif\n\n# define MD5_CBLOCK      64\n# define MD5_LBLOCK      (MD5_CBLOCK/4)\n# define MD5_DIGEST_LENGTH 16\n\ntypedef struct MD5state_st {\n    MD5_LONG A, B, C, D;\n    MD5_LONG Nl, Nh;\n    MD5_LONG data[MD5_LBLOCK];\n    unsigned int num;\n} MD5_CTX;\n\n# ifdef OPENSSL_FIPS\nint private_MD5_Init(MD5_CTX *c);\n# endif\nint MD5_Init(MD5_CTX *c);\nint MD5_Update(MD5_CTX *c, const void *data, size_t len);\nint MD5_Final(unsigned char *md, MD5_CTX *c);\nunsigned char *MD5(const unsigned char *d, size_t n, unsigned char *md);\nvoid MD5_Transform(MD5_CTX *c, const unsigned char *b);\n#ifdef  __cplusplus\n}\n#endif\n\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/arm64/include/openssl/mdc2.h",
    "content": "/* crypto/mdc2/mdc2.h */\n/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)\n * All rights reserved.\n *\n * This package is an SSL implementation written\n * by Eric Young (eay@cryptsoft.com).\n * The implementation was written so as to conform with Netscapes SSL.\n *\n * This library is free for commercial and non-commercial use as long as\n * the following conditions are aheared to.  The following conditions\n * apply to all code found in this distribution, be it the RC4, RSA,\n * lhash, DES, etc., code; not just the SSL code.  The SSL documentation\n * included with this distribution is covered by the same copyright terms\n * except that the holder is Tim Hudson (tjh@cryptsoft.com).\n *\n * Copyright remains Eric Young's, and as such any Copyright notices in\n * the code are not to be removed.\n * If this package is used in a product, Eric Young should be given attribution\n * as the author of the parts of the library used.\n * This can be in the form of a textual message at program startup or\n * in documentation (online or textual) provided with the package.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the copyright\n *    notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in the\n *    documentation and/or other materials provided with the distribution.\n * 3. All advertising materials mentioning features or use of this software\n *    must display the following acknowledgement:\n *    \"This product includes cryptographic software written by\n *     Eric Young (eay@cryptsoft.com)\"\n *    The word 'cryptographic' can be left out if the rouines from the library\n *    being used are not cryptographic related :-).\n * 4. If you include any Windows specific code (or a derivative thereof) from\n *    the apps directory (application code) you must include an acknowledgement:\n *    \"This product includes software written by Tim Hudson (tjh@cryptsoft.com)\"\n *\n * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n * SUCH DAMAGE.\n *\n * The licence and distribution terms for any publically available version or\n * derivative of this code cannot be changed.  i.e. this code cannot simply be\n * copied and put under another distribution licence\n * [including the GNU Public Licence.]\n */\n\n#ifndef HEADER_MDC2_H\n# define HEADER_MDC2_H\n\n# include <openssl/des.h>\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n# ifdef OPENSSL_NO_MDC2\n#  error MDC2 is disabled.\n# endif\n\n# define MDC2_BLOCK              8\n# define MDC2_DIGEST_LENGTH      16\n\ntypedef struct mdc2_ctx_st {\n    unsigned int num;\n    unsigned char data[MDC2_BLOCK];\n    DES_cblock h, hh;\n    int pad_type;               /* either 1 or 2, default 1 */\n} MDC2_CTX;\n\n# ifdef OPENSSL_FIPS\nint private_MDC2_Init(MDC2_CTX *c);\n# endif\nint MDC2_Init(MDC2_CTX *c);\nint MDC2_Update(MDC2_CTX *c, const unsigned char *data, size_t len);\nint MDC2_Final(unsigned char *md, MDC2_CTX *c);\nunsigned char *MDC2(const unsigned char *d, size_t n, unsigned char *md);\n\n#ifdef  __cplusplus\n}\n#endif\n\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/arm64/include/openssl/modes.h",
    "content": "/* ====================================================================\n * Copyright (c) 2008 The OpenSSL Project. All rights reserved.\n *\n * Rights for redistribution and usage in source and binary\n * forms are granted according to the OpenSSL license.\n */\n\n#include <stddef.h>\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\ntypedef void (*block128_f) (const unsigned char in[16],\n                            unsigned char out[16], const void *key);\n\ntypedef void (*cbc128_f) (const unsigned char *in, unsigned char *out,\n                          size_t len, const void *key,\n                          unsigned char ivec[16], int enc);\n\ntypedef void (*ctr128_f) (const unsigned char *in, unsigned char *out,\n                          size_t blocks, const void *key,\n                          const unsigned char ivec[16]);\n\ntypedef void (*ccm128_f) (const unsigned char *in, unsigned char *out,\n                          size_t blocks, const void *key,\n                          const unsigned char ivec[16],\n                          unsigned char cmac[16]);\n\nvoid CRYPTO_cbc128_encrypt(const unsigned char *in, unsigned char *out,\n                           size_t len, const void *key,\n                           unsigned char ivec[16], block128_f block);\nvoid CRYPTO_cbc128_decrypt(const unsigned char *in, unsigned char *out,\n                           size_t len, const void *key,\n                           unsigned char ivec[16], block128_f block);\n\nvoid CRYPTO_ctr128_encrypt(const unsigned char *in, unsigned char *out,\n                           size_t len, const void *key,\n                           unsigned char ivec[16],\n                           unsigned char ecount_buf[16], unsigned int *num,\n                           block128_f block);\n\nvoid CRYPTO_ctr128_encrypt_ctr32(const unsigned char *in, unsigned char *out,\n                                 size_t len, const void *key,\n                                 unsigned char ivec[16],\n                                 unsigned char ecount_buf[16],\n                                 unsigned int *num, ctr128_f ctr);\n\nvoid CRYPTO_ofb128_encrypt(const unsigned char *in, unsigned char *out,\n                           size_t len, const void *key,\n                           unsigned char ivec[16], int *num,\n                           block128_f block);\n\nvoid CRYPTO_cfb128_encrypt(const unsigned char *in, unsigned char *out,\n                           size_t len, const void *key,\n                           unsigned char ivec[16], int *num,\n                           int enc, block128_f block);\nvoid CRYPTO_cfb128_8_encrypt(const unsigned char *in, unsigned char *out,\n                             size_t length, const void *key,\n                             unsigned char ivec[16], int *num,\n                             int enc, block128_f block);\nvoid CRYPTO_cfb128_1_encrypt(const unsigned char *in, unsigned char *out,\n                             size_t bits, const void *key,\n                             unsigned char ivec[16], int *num,\n                             int enc, block128_f block);\n\nsize_t CRYPTO_cts128_encrypt_block(const unsigned char *in,\n                                   unsigned char *out, size_t len,\n                                   const void *key, unsigned char ivec[16],\n                                   block128_f block);\nsize_t CRYPTO_cts128_encrypt(const unsigned char *in, unsigned char *out,\n                             size_t len, const void *key,\n                             unsigned char ivec[16], cbc128_f cbc);\nsize_t CRYPTO_cts128_decrypt_block(const unsigned char *in,\n                                   unsigned char *out, size_t len,\n                                   const void *key, unsigned char ivec[16],\n                                   block128_f block);\nsize_t CRYPTO_cts128_decrypt(const unsigned char *in, unsigned char *out,\n                             size_t len, const void *key,\n                             unsigned char ivec[16], cbc128_f cbc);\n\nsize_t CRYPTO_nistcts128_encrypt_block(const unsigned char *in,\n                                       unsigned char *out, size_t len,\n                                       const void *key,\n                                       unsigned char ivec[16],\n                                       block128_f block);\nsize_t CRYPTO_nistcts128_encrypt(const unsigned char *in, unsigned char *out,\n                                 size_t len, const void *key,\n                                 unsigned char ivec[16], cbc128_f cbc);\nsize_t CRYPTO_nistcts128_decrypt_block(const unsigned char *in,\n                                       unsigned char *out, size_t len,\n                                       const void *key,\n                                       unsigned char ivec[16],\n                                       block128_f block);\nsize_t CRYPTO_nistcts128_decrypt(const unsigned char *in, unsigned char *out,\n                                 size_t len, const void *key,\n                                 unsigned char ivec[16], cbc128_f cbc);\n\ntypedef struct gcm128_context GCM128_CONTEXT;\n\nGCM128_CONTEXT *CRYPTO_gcm128_new(void *key, block128_f block);\nvoid CRYPTO_gcm128_init(GCM128_CONTEXT *ctx, void *key, block128_f block);\nvoid CRYPTO_gcm128_setiv(GCM128_CONTEXT *ctx, const unsigned char *iv,\n                         size_t len);\nint CRYPTO_gcm128_aad(GCM128_CONTEXT *ctx, const unsigned char *aad,\n                      size_t len);\nint CRYPTO_gcm128_encrypt(GCM128_CONTEXT *ctx,\n                          const unsigned char *in, unsigned char *out,\n                          size_t len);\nint CRYPTO_gcm128_decrypt(GCM128_CONTEXT *ctx,\n                          const unsigned char *in, unsigned char *out,\n                          size_t len);\nint CRYPTO_gcm128_encrypt_ctr32(GCM128_CONTEXT *ctx,\n                                const unsigned char *in, unsigned char *out,\n                                size_t len, ctr128_f stream);\nint CRYPTO_gcm128_decrypt_ctr32(GCM128_CONTEXT *ctx,\n                                const unsigned char *in, unsigned char *out,\n                                size_t len, ctr128_f stream);\nint CRYPTO_gcm128_finish(GCM128_CONTEXT *ctx, const unsigned char *tag,\n                         size_t len);\nvoid CRYPTO_gcm128_tag(GCM128_CONTEXT *ctx, unsigned char *tag, size_t len);\nvoid CRYPTO_gcm128_release(GCM128_CONTEXT *ctx);\n\ntypedef struct ccm128_context CCM128_CONTEXT;\n\nvoid CRYPTO_ccm128_init(CCM128_CONTEXT *ctx,\n                        unsigned int M, unsigned int L, void *key,\n                        block128_f block);\nint CRYPTO_ccm128_setiv(CCM128_CONTEXT *ctx, const unsigned char *nonce,\n                        size_t nlen, size_t mlen);\nvoid CRYPTO_ccm128_aad(CCM128_CONTEXT *ctx, const unsigned char *aad,\n                       size_t alen);\nint CRYPTO_ccm128_encrypt(CCM128_CONTEXT *ctx, const unsigned char *inp,\n                          unsigned char *out, size_t len);\nint CRYPTO_ccm128_decrypt(CCM128_CONTEXT *ctx, const unsigned char *inp,\n                          unsigned char *out, size_t len);\nint CRYPTO_ccm128_encrypt_ccm64(CCM128_CONTEXT *ctx, const unsigned char *inp,\n                                unsigned char *out, size_t len,\n                                ccm128_f stream);\nint CRYPTO_ccm128_decrypt_ccm64(CCM128_CONTEXT *ctx, const unsigned char *inp,\n                                unsigned char *out, size_t len,\n                                ccm128_f stream);\nsize_t CRYPTO_ccm128_tag(CCM128_CONTEXT *ctx, unsigned char *tag, size_t len);\n\ntypedef struct xts128_context XTS128_CONTEXT;\n\nint CRYPTO_xts128_encrypt(const XTS128_CONTEXT *ctx,\n                          const unsigned char iv[16],\n                          const unsigned char *inp, unsigned char *out,\n                          size_t len, int enc);\n\nsize_t CRYPTO_128_wrap(void *key, const unsigned char *iv,\n                       unsigned char *out,\n                       const unsigned char *in, size_t inlen,\n                       block128_f block);\n\nsize_t CRYPTO_128_unwrap(void *key, const unsigned char *iv,\n                         unsigned char *out,\n                         const unsigned char *in, size_t inlen,\n                         block128_f block);\n\n#ifdef  __cplusplus\n}\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/arm64/include/openssl/obj_mac.h",
    "content": "/* crypto/objects/obj_mac.h */\n\n/*\n * THIS FILE IS GENERATED FROM objects.txt by objects.pl via the following\n * command: perl objects.pl objects.txt obj_mac.num obj_mac.h\n */\n\n/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)\n * All rights reserved.\n *\n * This package is an SSL implementation written\n * by Eric Young (eay@cryptsoft.com).\n * The implementation was written so as to conform with Netscapes SSL.\n *\n * This library is free for commercial and non-commercial use as long as\n * the following conditions are aheared to.  The following conditions\n * apply to all code found in this distribution, be it the RC4, RSA,\n * lhash, DES, etc., code; not just the SSL code.  The SSL documentation\n * included with this distribution is covered by the same copyright terms\n * except that the holder is Tim Hudson (tjh@cryptsoft.com).\n *\n * Copyright remains Eric Young's, and as such any Copyright notices in\n * the code are not to be removed.\n * If this package is used in a product, Eric Young should be given attribution\n * as the author of the parts of the library used.\n * This can be in the form of a textual message at program startup or\n * in documentation (online or textual) provided with the package.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the copyright\n *    notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in the\n *    documentation and/or other materials provided with the distribution.\n * 3. All advertising materials mentioning features or use of this software\n *    must display the following acknowledgement:\n *    \"This product includes cryptographic software written by\n *     Eric Young (eay@cryptsoft.com)\"\n *    The word 'cryptographic' can be left out if the rouines from the library\n *    being used are not cryptographic related :-).\n * 4. If you include any Windows specific code (or a derivative thereof) from\n *    the apps directory (application code) you must include an acknowledgement:\n *    \"This product includes software written by Tim Hudson (tjh@cryptsoft.com)\"\n *\n * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n * SUCH DAMAGE.\n *\n * The licence and distribution terms for any publically available version or\n * derivative of this code cannot be changed.  i.e. this code cannot simply be\n * copied and put under another distribution licence\n * [including the GNU Public Licence.]\n */\n\n#define SN_undef                        \"UNDEF\"\n#define LN_undef                        \"undefined\"\n#define NID_undef                       0\n#define OBJ_undef                       0L\n\n#define SN_itu_t                \"ITU-T\"\n#define LN_itu_t                \"itu-t\"\n#define NID_itu_t               645\n#define OBJ_itu_t               0L\n\n#define NID_ccitt               404\n#define OBJ_ccitt               OBJ_itu_t\n\n#define SN_iso          \"ISO\"\n#define LN_iso          \"iso\"\n#define NID_iso         181\n#define OBJ_iso         1L\n\n#define SN_joint_iso_itu_t              \"JOINT-ISO-ITU-T\"\n#define LN_joint_iso_itu_t              \"joint-iso-itu-t\"\n#define NID_joint_iso_itu_t             646\n#define OBJ_joint_iso_itu_t             2L\n\n#define NID_joint_iso_ccitt             393\n#define OBJ_joint_iso_ccitt             OBJ_joint_iso_itu_t\n\n#define SN_member_body          \"member-body\"\n#define LN_member_body          \"ISO Member Body\"\n#define NID_member_body         182\n#define OBJ_member_body         OBJ_iso,2L\n\n#define SN_identified_organization              \"identified-organization\"\n#define NID_identified_organization             676\n#define OBJ_identified_organization             OBJ_iso,3L\n\n#define SN_hmac_md5             \"HMAC-MD5\"\n#define LN_hmac_md5             \"hmac-md5\"\n#define NID_hmac_md5            780\n#define OBJ_hmac_md5            OBJ_identified_organization,6L,1L,5L,5L,8L,1L,1L\n\n#define SN_hmac_sha1            \"HMAC-SHA1\"\n#define LN_hmac_sha1            \"hmac-sha1\"\n#define NID_hmac_sha1           781\n#define OBJ_hmac_sha1           OBJ_identified_organization,6L,1L,5L,5L,8L,1L,2L\n\n#define SN_certicom_arc         \"certicom-arc\"\n#define NID_certicom_arc                677\n#define OBJ_certicom_arc                OBJ_identified_organization,132L\n\n#define SN_international_organizations          \"international-organizations\"\n#define LN_international_organizations          \"International Organizations\"\n#define NID_international_organizations         647\n#define OBJ_international_organizations         OBJ_joint_iso_itu_t,23L\n\n#define SN_wap          \"wap\"\n#define NID_wap         678\n#define OBJ_wap         OBJ_international_organizations,43L\n\n#define SN_wap_wsg              \"wap-wsg\"\n#define NID_wap_wsg             679\n#define OBJ_wap_wsg             OBJ_wap,1L\n\n#define SN_selected_attribute_types             \"selected-attribute-types\"\n#define LN_selected_attribute_types             \"Selected Attribute Types\"\n#define NID_selected_attribute_types            394\n#define OBJ_selected_attribute_types            OBJ_joint_iso_itu_t,5L,1L,5L\n\n#define SN_clearance            \"clearance\"\n#define NID_clearance           395\n#define OBJ_clearance           OBJ_selected_attribute_types,55L\n\n#define SN_ISO_US               \"ISO-US\"\n#define LN_ISO_US               \"ISO US Member Body\"\n#define NID_ISO_US              183\n#define OBJ_ISO_US              OBJ_member_body,840L\n\n#define SN_X9_57                \"X9-57\"\n#define LN_X9_57                \"X9.57\"\n#define NID_X9_57               184\n#define OBJ_X9_57               OBJ_ISO_US,10040L\n\n#define SN_X9cm         \"X9cm\"\n#define LN_X9cm         \"X9.57 CM ?\"\n#define NID_X9cm                185\n#define OBJ_X9cm                OBJ_X9_57,4L\n\n#define SN_dsa          \"DSA\"\n#define LN_dsa          \"dsaEncryption\"\n#define NID_dsa         116\n#define OBJ_dsa         OBJ_X9cm,1L\n\n#define SN_dsaWithSHA1          \"DSA-SHA1\"\n#define LN_dsaWithSHA1          \"dsaWithSHA1\"\n#define NID_dsaWithSHA1         113\n#define OBJ_dsaWithSHA1         OBJ_X9cm,3L\n\n#define SN_ansi_X9_62           \"ansi-X9-62\"\n#define LN_ansi_X9_62           \"ANSI X9.62\"\n#define NID_ansi_X9_62          405\n#define OBJ_ansi_X9_62          OBJ_ISO_US,10045L\n\n#define OBJ_X9_62_id_fieldType          OBJ_ansi_X9_62,1L\n\n#define SN_X9_62_prime_field            \"prime-field\"\n#define NID_X9_62_prime_field           406\n#define OBJ_X9_62_prime_field           OBJ_X9_62_id_fieldType,1L\n\n#define SN_X9_62_characteristic_two_field               \"characteristic-two-field\"\n#define NID_X9_62_characteristic_two_field              407\n#define OBJ_X9_62_characteristic_two_field              OBJ_X9_62_id_fieldType,2L\n\n#define SN_X9_62_id_characteristic_two_basis            \"id-characteristic-two-basis\"\n#define NID_X9_62_id_characteristic_two_basis           680\n#define OBJ_X9_62_id_characteristic_two_basis           OBJ_X9_62_characteristic_two_field,3L\n\n#define SN_X9_62_onBasis                \"onBasis\"\n#define NID_X9_62_onBasis               681\n#define OBJ_X9_62_onBasis               OBJ_X9_62_id_characteristic_two_basis,1L\n\n#define SN_X9_62_tpBasis                \"tpBasis\"\n#define NID_X9_62_tpBasis               682\n#define OBJ_X9_62_tpBasis               OBJ_X9_62_id_characteristic_two_basis,2L\n\n#define SN_X9_62_ppBasis                \"ppBasis\"\n#define NID_X9_62_ppBasis               683\n#define OBJ_X9_62_ppBasis               OBJ_X9_62_id_characteristic_two_basis,3L\n\n#define OBJ_X9_62_id_publicKeyType              OBJ_ansi_X9_62,2L\n\n#define SN_X9_62_id_ecPublicKey         \"id-ecPublicKey\"\n#define NID_X9_62_id_ecPublicKey                408\n#define OBJ_X9_62_id_ecPublicKey                OBJ_X9_62_id_publicKeyType,1L\n\n#define OBJ_X9_62_ellipticCurve         OBJ_ansi_X9_62,3L\n\n#define OBJ_X9_62_c_TwoCurve            OBJ_X9_62_ellipticCurve,0L\n\n#define SN_X9_62_c2pnb163v1             \"c2pnb163v1\"\n#define NID_X9_62_c2pnb163v1            684\n#define OBJ_X9_62_c2pnb163v1            OBJ_X9_62_c_TwoCurve,1L\n\n#define SN_X9_62_c2pnb163v2             \"c2pnb163v2\"\n#define NID_X9_62_c2pnb163v2            685\n#define OBJ_X9_62_c2pnb163v2            OBJ_X9_62_c_TwoCurve,2L\n\n#define SN_X9_62_c2pnb163v3             \"c2pnb163v3\"\n#define NID_X9_62_c2pnb163v3            686\n#define OBJ_X9_62_c2pnb163v3            OBJ_X9_62_c_TwoCurve,3L\n\n#define SN_X9_62_c2pnb176v1             \"c2pnb176v1\"\n#define NID_X9_62_c2pnb176v1            687\n#define OBJ_X9_62_c2pnb176v1            OBJ_X9_62_c_TwoCurve,4L\n\n#define SN_X9_62_c2tnb191v1             \"c2tnb191v1\"\n#define NID_X9_62_c2tnb191v1            688\n#define OBJ_X9_62_c2tnb191v1            OBJ_X9_62_c_TwoCurve,5L\n\n#define SN_X9_62_c2tnb191v2             \"c2tnb191v2\"\n#define NID_X9_62_c2tnb191v2            689\n#define OBJ_X9_62_c2tnb191v2            OBJ_X9_62_c_TwoCurve,6L\n\n#define SN_X9_62_c2tnb191v3             \"c2tnb191v3\"\n#define NID_X9_62_c2tnb191v3            690\n#define OBJ_X9_62_c2tnb191v3            OBJ_X9_62_c_TwoCurve,7L\n\n#define SN_X9_62_c2onb191v4             \"c2onb191v4\"\n#define NID_X9_62_c2onb191v4            691\n#define OBJ_X9_62_c2onb191v4            OBJ_X9_62_c_TwoCurve,8L\n\n#define SN_X9_62_c2onb191v5             \"c2onb191v5\"\n#define NID_X9_62_c2onb191v5            692\n#define OBJ_X9_62_c2onb191v5            OBJ_X9_62_c_TwoCurve,9L\n\n#define SN_X9_62_c2pnb208w1             \"c2pnb208w1\"\n#define NID_X9_62_c2pnb208w1            693\n#define OBJ_X9_62_c2pnb208w1            OBJ_X9_62_c_TwoCurve,10L\n\n#define SN_X9_62_c2tnb239v1             \"c2tnb239v1\"\n#define NID_X9_62_c2tnb239v1            694\n#define OBJ_X9_62_c2tnb239v1            OBJ_X9_62_c_TwoCurve,11L\n\n#define SN_X9_62_c2tnb239v2             \"c2tnb239v2\"\n#define NID_X9_62_c2tnb239v2            695\n#define OBJ_X9_62_c2tnb239v2            OBJ_X9_62_c_TwoCurve,12L\n\n#define SN_X9_62_c2tnb239v3             \"c2tnb239v3\"\n#define NID_X9_62_c2tnb239v3            696\n#define OBJ_X9_62_c2tnb239v3            OBJ_X9_62_c_TwoCurve,13L\n\n#define SN_X9_62_c2onb239v4             \"c2onb239v4\"\n#define NID_X9_62_c2onb239v4            697\n#define OBJ_X9_62_c2onb239v4            OBJ_X9_62_c_TwoCurve,14L\n\n#define SN_X9_62_c2onb239v5             \"c2onb239v5\"\n#define NID_X9_62_c2onb239v5            698\n#define OBJ_X9_62_c2onb239v5            OBJ_X9_62_c_TwoCurve,15L\n\n#define SN_X9_62_c2pnb272w1             \"c2pnb272w1\"\n#define NID_X9_62_c2pnb272w1            699\n#define OBJ_X9_62_c2pnb272w1            OBJ_X9_62_c_TwoCurve,16L\n\n#define SN_X9_62_c2pnb304w1             \"c2pnb304w1\"\n#define NID_X9_62_c2pnb304w1            700\n#define OBJ_X9_62_c2pnb304w1            OBJ_X9_62_c_TwoCurve,17L\n\n#define SN_X9_62_c2tnb359v1             \"c2tnb359v1\"\n#define NID_X9_62_c2tnb359v1            701\n#define OBJ_X9_62_c2tnb359v1            OBJ_X9_62_c_TwoCurve,18L\n\n#define SN_X9_62_c2pnb368w1             \"c2pnb368w1\"\n#define NID_X9_62_c2pnb368w1            702\n#define OBJ_X9_62_c2pnb368w1            OBJ_X9_62_c_TwoCurve,19L\n\n#define SN_X9_62_c2tnb431r1             \"c2tnb431r1\"\n#define NID_X9_62_c2tnb431r1            703\n#define OBJ_X9_62_c2tnb431r1            OBJ_X9_62_c_TwoCurve,20L\n\n#define OBJ_X9_62_primeCurve            OBJ_X9_62_ellipticCurve,1L\n\n#define SN_X9_62_prime192v1             \"prime192v1\"\n#define NID_X9_62_prime192v1            409\n#define OBJ_X9_62_prime192v1            OBJ_X9_62_primeCurve,1L\n\n#define SN_X9_62_prime192v2             \"prime192v2\"\n#define NID_X9_62_prime192v2            410\n#define OBJ_X9_62_prime192v2            OBJ_X9_62_primeCurve,2L\n\n#define SN_X9_62_prime192v3             \"prime192v3\"\n#define NID_X9_62_prime192v3            411\n#define OBJ_X9_62_prime192v3            OBJ_X9_62_primeCurve,3L\n\n#define SN_X9_62_prime239v1             \"prime239v1\"\n#define NID_X9_62_prime239v1            412\n#define OBJ_X9_62_prime239v1            OBJ_X9_62_primeCurve,4L\n\n#define SN_X9_62_prime239v2             \"prime239v2\"\n#define NID_X9_62_prime239v2            413\n#define OBJ_X9_62_prime239v2            OBJ_X9_62_primeCurve,5L\n\n#define SN_X9_62_prime239v3             \"prime239v3\"\n#define NID_X9_62_prime239v3            414\n#define OBJ_X9_62_prime239v3            OBJ_X9_62_primeCurve,6L\n\n#define SN_X9_62_prime256v1             \"prime256v1\"\n#define NID_X9_62_prime256v1            415\n#define OBJ_X9_62_prime256v1            OBJ_X9_62_primeCurve,7L\n\n#define OBJ_X9_62_id_ecSigType          OBJ_ansi_X9_62,4L\n\n#define SN_ecdsa_with_SHA1              \"ecdsa-with-SHA1\"\n#define NID_ecdsa_with_SHA1             416\n#define OBJ_ecdsa_with_SHA1             OBJ_X9_62_id_ecSigType,1L\n\n#define SN_ecdsa_with_Recommended               \"ecdsa-with-Recommended\"\n#define NID_ecdsa_with_Recommended              791\n#define OBJ_ecdsa_with_Recommended              OBJ_X9_62_id_ecSigType,2L\n\n#define SN_ecdsa_with_Specified         \"ecdsa-with-Specified\"\n#define NID_ecdsa_with_Specified                792\n#define OBJ_ecdsa_with_Specified                OBJ_X9_62_id_ecSigType,3L\n\n#define SN_ecdsa_with_SHA224            \"ecdsa-with-SHA224\"\n#define NID_ecdsa_with_SHA224           793\n#define OBJ_ecdsa_with_SHA224           OBJ_ecdsa_with_Specified,1L\n\n#define SN_ecdsa_with_SHA256            \"ecdsa-with-SHA256\"\n#define NID_ecdsa_with_SHA256           794\n#define OBJ_ecdsa_with_SHA256           OBJ_ecdsa_with_Specified,2L\n\n#define SN_ecdsa_with_SHA384            \"ecdsa-with-SHA384\"\n#define NID_ecdsa_with_SHA384           795\n#define OBJ_ecdsa_with_SHA384           OBJ_ecdsa_with_Specified,3L\n\n#define SN_ecdsa_with_SHA512            \"ecdsa-with-SHA512\"\n#define NID_ecdsa_with_SHA512           796\n#define OBJ_ecdsa_with_SHA512           OBJ_ecdsa_with_Specified,4L\n\n#define OBJ_secg_ellipticCurve          OBJ_certicom_arc,0L\n\n#define SN_secp112r1            \"secp112r1\"\n#define NID_secp112r1           704\n#define OBJ_secp112r1           OBJ_secg_ellipticCurve,6L\n\n#define SN_secp112r2            \"secp112r2\"\n#define NID_secp112r2           705\n#define OBJ_secp112r2           OBJ_secg_ellipticCurve,7L\n\n#define SN_secp128r1            \"secp128r1\"\n#define NID_secp128r1           706\n#define OBJ_secp128r1           OBJ_secg_ellipticCurve,28L\n\n#define SN_secp128r2            \"secp128r2\"\n#define NID_secp128r2           707\n#define OBJ_secp128r2           OBJ_secg_ellipticCurve,29L\n\n#define SN_secp160k1            \"secp160k1\"\n#define NID_secp160k1           708\n#define OBJ_secp160k1           OBJ_secg_ellipticCurve,9L\n\n#define SN_secp160r1            \"secp160r1\"\n#define NID_secp160r1           709\n#define OBJ_secp160r1           OBJ_secg_ellipticCurve,8L\n\n#define SN_secp160r2            \"secp160r2\"\n#define NID_secp160r2           710\n#define OBJ_secp160r2           OBJ_secg_ellipticCurve,30L\n\n#define SN_secp192k1            \"secp192k1\"\n#define NID_secp192k1           711\n#define OBJ_secp192k1           OBJ_secg_ellipticCurve,31L\n\n#define SN_secp224k1            \"secp224k1\"\n#define NID_secp224k1           712\n#define OBJ_secp224k1           OBJ_secg_ellipticCurve,32L\n\n#define SN_secp224r1            \"secp224r1\"\n#define NID_secp224r1           713\n#define OBJ_secp224r1           OBJ_secg_ellipticCurve,33L\n\n#define SN_secp256k1            \"secp256k1\"\n#define NID_secp256k1           714\n#define OBJ_secp256k1           OBJ_secg_ellipticCurve,10L\n\n#define SN_secp384r1            \"secp384r1\"\n#define NID_secp384r1           715\n#define OBJ_secp384r1           OBJ_secg_ellipticCurve,34L\n\n#define SN_secp521r1            \"secp521r1\"\n#define NID_secp521r1           716\n#define OBJ_secp521r1           OBJ_secg_ellipticCurve,35L\n\n#define SN_sect113r1            \"sect113r1\"\n#define NID_sect113r1           717\n#define OBJ_sect113r1           OBJ_secg_ellipticCurve,4L\n\n#define SN_sect113r2            \"sect113r2\"\n#define NID_sect113r2           718\n#define OBJ_sect113r2           OBJ_secg_ellipticCurve,5L\n\n#define SN_sect131r1            \"sect131r1\"\n#define NID_sect131r1           719\n#define OBJ_sect131r1           OBJ_secg_ellipticCurve,22L\n\n#define SN_sect131r2            \"sect131r2\"\n#define NID_sect131r2           720\n#define OBJ_sect131r2           OBJ_secg_ellipticCurve,23L\n\n#define SN_sect163k1            \"sect163k1\"\n#define NID_sect163k1           721\n#define OBJ_sect163k1           OBJ_secg_ellipticCurve,1L\n\n#define SN_sect163r1            \"sect163r1\"\n#define NID_sect163r1           722\n#define OBJ_sect163r1           OBJ_secg_ellipticCurve,2L\n\n#define SN_sect163r2            \"sect163r2\"\n#define NID_sect163r2           723\n#define OBJ_sect163r2           OBJ_secg_ellipticCurve,15L\n\n#define SN_sect193r1            \"sect193r1\"\n#define NID_sect193r1           724\n#define OBJ_sect193r1           OBJ_secg_ellipticCurve,24L\n\n#define SN_sect193r2            \"sect193r2\"\n#define NID_sect193r2           725\n#define OBJ_sect193r2           OBJ_secg_ellipticCurve,25L\n\n#define SN_sect233k1            \"sect233k1\"\n#define NID_sect233k1           726\n#define OBJ_sect233k1           OBJ_secg_ellipticCurve,26L\n\n#define SN_sect233r1            \"sect233r1\"\n#define NID_sect233r1           727\n#define OBJ_sect233r1           OBJ_secg_ellipticCurve,27L\n\n#define SN_sect239k1            \"sect239k1\"\n#define NID_sect239k1           728\n#define OBJ_sect239k1           OBJ_secg_ellipticCurve,3L\n\n#define SN_sect283k1            \"sect283k1\"\n#define NID_sect283k1           729\n#define OBJ_sect283k1           OBJ_secg_ellipticCurve,16L\n\n#define SN_sect283r1            \"sect283r1\"\n#define NID_sect283r1           730\n#define OBJ_sect283r1           OBJ_secg_ellipticCurve,17L\n\n#define SN_sect409k1            \"sect409k1\"\n#define NID_sect409k1           731\n#define OBJ_sect409k1           OBJ_secg_ellipticCurve,36L\n\n#define SN_sect409r1            \"sect409r1\"\n#define NID_sect409r1           732\n#define OBJ_sect409r1           OBJ_secg_ellipticCurve,37L\n\n#define SN_sect571k1            \"sect571k1\"\n#define NID_sect571k1           733\n#define OBJ_sect571k1           OBJ_secg_ellipticCurve,38L\n\n#define SN_sect571r1            \"sect571r1\"\n#define NID_sect571r1           734\n#define OBJ_sect571r1           OBJ_secg_ellipticCurve,39L\n\n#define OBJ_wap_wsg_idm_ecid            OBJ_wap_wsg,4L\n\n#define SN_wap_wsg_idm_ecid_wtls1               \"wap-wsg-idm-ecid-wtls1\"\n#define NID_wap_wsg_idm_ecid_wtls1              735\n#define OBJ_wap_wsg_idm_ecid_wtls1              OBJ_wap_wsg_idm_ecid,1L\n\n#define SN_wap_wsg_idm_ecid_wtls3               \"wap-wsg-idm-ecid-wtls3\"\n#define NID_wap_wsg_idm_ecid_wtls3              736\n#define OBJ_wap_wsg_idm_ecid_wtls3              OBJ_wap_wsg_idm_ecid,3L\n\n#define SN_wap_wsg_idm_ecid_wtls4               \"wap-wsg-idm-ecid-wtls4\"\n#define NID_wap_wsg_idm_ecid_wtls4              737\n#define OBJ_wap_wsg_idm_ecid_wtls4              OBJ_wap_wsg_idm_ecid,4L\n\n#define SN_wap_wsg_idm_ecid_wtls5               \"wap-wsg-idm-ecid-wtls5\"\n#define NID_wap_wsg_idm_ecid_wtls5              738\n#define OBJ_wap_wsg_idm_ecid_wtls5              OBJ_wap_wsg_idm_ecid,5L\n\n#define SN_wap_wsg_idm_ecid_wtls6               \"wap-wsg-idm-ecid-wtls6\"\n#define NID_wap_wsg_idm_ecid_wtls6              739\n#define OBJ_wap_wsg_idm_ecid_wtls6              OBJ_wap_wsg_idm_ecid,6L\n\n#define SN_wap_wsg_idm_ecid_wtls7               \"wap-wsg-idm-ecid-wtls7\"\n#define NID_wap_wsg_idm_ecid_wtls7              740\n#define OBJ_wap_wsg_idm_ecid_wtls7              OBJ_wap_wsg_idm_ecid,7L\n\n#define SN_wap_wsg_idm_ecid_wtls8               \"wap-wsg-idm-ecid-wtls8\"\n#define NID_wap_wsg_idm_ecid_wtls8              741\n#define OBJ_wap_wsg_idm_ecid_wtls8              OBJ_wap_wsg_idm_ecid,8L\n\n#define SN_wap_wsg_idm_ecid_wtls9               \"wap-wsg-idm-ecid-wtls9\"\n#define NID_wap_wsg_idm_ecid_wtls9              742\n#define OBJ_wap_wsg_idm_ecid_wtls9              OBJ_wap_wsg_idm_ecid,9L\n\n#define SN_wap_wsg_idm_ecid_wtls10              \"wap-wsg-idm-ecid-wtls10\"\n#define NID_wap_wsg_idm_ecid_wtls10             743\n#define OBJ_wap_wsg_idm_ecid_wtls10             OBJ_wap_wsg_idm_ecid,10L\n\n#define SN_wap_wsg_idm_ecid_wtls11              \"wap-wsg-idm-ecid-wtls11\"\n#define NID_wap_wsg_idm_ecid_wtls11             744\n#define OBJ_wap_wsg_idm_ecid_wtls11             OBJ_wap_wsg_idm_ecid,11L\n\n#define SN_wap_wsg_idm_ecid_wtls12              \"wap-wsg-idm-ecid-wtls12\"\n#define NID_wap_wsg_idm_ecid_wtls12             745\n#define OBJ_wap_wsg_idm_ecid_wtls12             OBJ_wap_wsg_idm_ecid,12L\n\n#define SN_cast5_cbc            \"CAST5-CBC\"\n#define LN_cast5_cbc            \"cast5-cbc\"\n#define NID_cast5_cbc           108\n#define OBJ_cast5_cbc           OBJ_ISO_US,113533L,7L,66L,10L\n\n#define SN_cast5_ecb            \"CAST5-ECB\"\n#define LN_cast5_ecb            \"cast5-ecb\"\n#define NID_cast5_ecb           109\n\n#define SN_cast5_cfb64          \"CAST5-CFB\"\n#define LN_cast5_cfb64          \"cast5-cfb\"\n#define NID_cast5_cfb64         110\n\n#define SN_cast5_ofb64          \"CAST5-OFB\"\n#define LN_cast5_ofb64          \"cast5-ofb\"\n#define NID_cast5_ofb64         111\n\n#define LN_pbeWithMD5AndCast5_CBC               \"pbeWithMD5AndCast5CBC\"\n#define NID_pbeWithMD5AndCast5_CBC              112\n#define OBJ_pbeWithMD5AndCast5_CBC              OBJ_ISO_US,113533L,7L,66L,12L\n\n#define SN_id_PasswordBasedMAC          \"id-PasswordBasedMAC\"\n#define LN_id_PasswordBasedMAC          \"password based MAC\"\n#define NID_id_PasswordBasedMAC         782\n#define OBJ_id_PasswordBasedMAC         OBJ_ISO_US,113533L,7L,66L,13L\n\n#define SN_id_DHBasedMac                \"id-DHBasedMac\"\n#define LN_id_DHBasedMac                \"Diffie-Hellman based MAC\"\n#define NID_id_DHBasedMac               783\n#define OBJ_id_DHBasedMac               OBJ_ISO_US,113533L,7L,66L,30L\n\n#define SN_rsadsi               \"rsadsi\"\n#define LN_rsadsi               \"RSA Data Security, Inc.\"\n#define NID_rsadsi              1\n#define OBJ_rsadsi              OBJ_ISO_US,113549L\n\n#define SN_pkcs         \"pkcs\"\n#define LN_pkcs         \"RSA Data Security, Inc. PKCS\"\n#define NID_pkcs                2\n#define OBJ_pkcs                OBJ_rsadsi,1L\n\n#define SN_pkcs1                \"pkcs1\"\n#define NID_pkcs1               186\n#define OBJ_pkcs1               OBJ_pkcs,1L\n\n#define LN_rsaEncryption                \"rsaEncryption\"\n#define NID_rsaEncryption               6\n#define OBJ_rsaEncryption               OBJ_pkcs1,1L\n\n#define SN_md2WithRSAEncryption         \"RSA-MD2\"\n#define LN_md2WithRSAEncryption         \"md2WithRSAEncryption\"\n#define NID_md2WithRSAEncryption                7\n#define OBJ_md2WithRSAEncryption                OBJ_pkcs1,2L\n\n#define SN_md4WithRSAEncryption         \"RSA-MD4\"\n#define LN_md4WithRSAEncryption         \"md4WithRSAEncryption\"\n#define NID_md4WithRSAEncryption                396\n#define OBJ_md4WithRSAEncryption                OBJ_pkcs1,3L\n\n#define SN_md5WithRSAEncryption         \"RSA-MD5\"\n#define LN_md5WithRSAEncryption         \"md5WithRSAEncryption\"\n#define NID_md5WithRSAEncryption                8\n#define OBJ_md5WithRSAEncryption                OBJ_pkcs1,4L\n\n#define SN_sha1WithRSAEncryption                \"RSA-SHA1\"\n#define LN_sha1WithRSAEncryption                \"sha1WithRSAEncryption\"\n#define NID_sha1WithRSAEncryption               65\n#define OBJ_sha1WithRSAEncryption               OBJ_pkcs1,5L\n\n#define SN_rsaesOaep            \"RSAES-OAEP\"\n#define LN_rsaesOaep            \"rsaesOaep\"\n#define NID_rsaesOaep           919\n#define OBJ_rsaesOaep           OBJ_pkcs1,7L\n\n#define SN_mgf1         \"MGF1\"\n#define LN_mgf1         \"mgf1\"\n#define NID_mgf1                911\n#define OBJ_mgf1                OBJ_pkcs1,8L\n\n#define SN_pSpecified           \"PSPECIFIED\"\n#define LN_pSpecified           \"pSpecified\"\n#define NID_pSpecified          935\n#define OBJ_pSpecified          OBJ_pkcs1,9L\n\n#define SN_rsassaPss            \"RSASSA-PSS\"\n#define LN_rsassaPss            \"rsassaPss\"\n#define NID_rsassaPss           912\n#define OBJ_rsassaPss           OBJ_pkcs1,10L\n\n#define SN_sha256WithRSAEncryption              \"RSA-SHA256\"\n#define LN_sha256WithRSAEncryption              \"sha256WithRSAEncryption\"\n#define NID_sha256WithRSAEncryption             668\n#define OBJ_sha256WithRSAEncryption             OBJ_pkcs1,11L\n\n#define SN_sha384WithRSAEncryption              \"RSA-SHA384\"\n#define LN_sha384WithRSAEncryption              \"sha384WithRSAEncryption\"\n#define NID_sha384WithRSAEncryption             669\n#define OBJ_sha384WithRSAEncryption             OBJ_pkcs1,12L\n\n#define SN_sha512WithRSAEncryption              \"RSA-SHA512\"\n#define LN_sha512WithRSAEncryption              \"sha512WithRSAEncryption\"\n#define NID_sha512WithRSAEncryption             670\n#define OBJ_sha512WithRSAEncryption             OBJ_pkcs1,13L\n\n#define SN_sha224WithRSAEncryption              \"RSA-SHA224\"\n#define LN_sha224WithRSAEncryption              \"sha224WithRSAEncryption\"\n#define NID_sha224WithRSAEncryption             671\n#define OBJ_sha224WithRSAEncryption             OBJ_pkcs1,14L\n\n#define SN_pkcs3                \"pkcs3\"\n#define NID_pkcs3               27\n#define OBJ_pkcs3               OBJ_pkcs,3L\n\n#define LN_dhKeyAgreement               \"dhKeyAgreement\"\n#define NID_dhKeyAgreement              28\n#define OBJ_dhKeyAgreement              OBJ_pkcs3,1L\n\n#define SN_pkcs5                \"pkcs5\"\n#define NID_pkcs5               187\n#define OBJ_pkcs5               OBJ_pkcs,5L\n\n#define SN_pbeWithMD2AndDES_CBC         \"PBE-MD2-DES\"\n#define LN_pbeWithMD2AndDES_CBC         \"pbeWithMD2AndDES-CBC\"\n#define NID_pbeWithMD2AndDES_CBC                9\n#define OBJ_pbeWithMD2AndDES_CBC                OBJ_pkcs5,1L\n\n#define SN_pbeWithMD5AndDES_CBC         \"PBE-MD5-DES\"\n#define LN_pbeWithMD5AndDES_CBC         \"pbeWithMD5AndDES-CBC\"\n#define NID_pbeWithMD5AndDES_CBC                10\n#define OBJ_pbeWithMD5AndDES_CBC                OBJ_pkcs5,3L\n\n#define SN_pbeWithMD2AndRC2_CBC         \"PBE-MD2-RC2-64\"\n#define LN_pbeWithMD2AndRC2_CBC         \"pbeWithMD2AndRC2-CBC\"\n#define NID_pbeWithMD2AndRC2_CBC                168\n#define OBJ_pbeWithMD2AndRC2_CBC                OBJ_pkcs5,4L\n\n#define SN_pbeWithMD5AndRC2_CBC         \"PBE-MD5-RC2-64\"\n#define LN_pbeWithMD5AndRC2_CBC         \"pbeWithMD5AndRC2-CBC\"\n#define NID_pbeWithMD5AndRC2_CBC                169\n#define OBJ_pbeWithMD5AndRC2_CBC                OBJ_pkcs5,6L\n\n#define SN_pbeWithSHA1AndDES_CBC                \"PBE-SHA1-DES\"\n#define LN_pbeWithSHA1AndDES_CBC                \"pbeWithSHA1AndDES-CBC\"\n#define NID_pbeWithSHA1AndDES_CBC               170\n#define OBJ_pbeWithSHA1AndDES_CBC               OBJ_pkcs5,10L\n\n#define SN_pbeWithSHA1AndRC2_CBC                \"PBE-SHA1-RC2-64\"\n#define LN_pbeWithSHA1AndRC2_CBC                \"pbeWithSHA1AndRC2-CBC\"\n#define NID_pbeWithSHA1AndRC2_CBC               68\n#define OBJ_pbeWithSHA1AndRC2_CBC               OBJ_pkcs5,11L\n\n#define LN_id_pbkdf2            \"PBKDF2\"\n#define NID_id_pbkdf2           69\n#define OBJ_id_pbkdf2           OBJ_pkcs5,12L\n\n#define LN_pbes2                \"PBES2\"\n#define NID_pbes2               161\n#define OBJ_pbes2               OBJ_pkcs5,13L\n\n#define LN_pbmac1               \"PBMAC1\"\n#define NID_pbmac1              162\n#define OBJ_pbmac1              OBJ_pkcs5,14L\n\n#define SN_pkcs7                \"pkcs7\"\n#define NID_pkcs7               20\n#define OBJ_pkcs7               OBJ_pkcs,7L\n\n#define LN_pkcs7_data           \"pkcs7-data\"\n#define NID_pkcs7_data          21\n#define OBJ_pkcs7_data          OBJ_pkcs7,1L\n\n#define LN_pkcs7_signed         \"pkcs7-signedData\"\n#define NID_pkcs7_signed                22\n#define OBJ_pkcs7_signed                OBJ_pkcs7,2L\n\n#define LN_pkcs7_enveloped              \"pkcs7-envelopedData\"\n#define NID_pkcs7_enveloped             23\n#define OBJ_pkcs7_enveloped             OBJ_pkcs7,3L\n\n#define LN_pkcs7_signedAndEnveloped             \"pkcs7-signedAndEnvelopedData\"\n#define NID_pkcs7_signedAndEnveloped            24\n#define OBJ_pkcs7_signedAndEnveloped            OBJ_pkcs7,4L\n\n#define LN_pkcs7_digest         \"pkcs7-digestData\"\n#define NID_pkcs7_digest                25\n#define OBJ_pkcs7_digest                OBJ_pkcs7,5L\n\n#define LN_pkcs7_encrypted              \"pkcs7-encryptedData\"\n#define NID_pkcs7_encrypted             26\n#define OBJ_pkcs7_encrypted             OBJ_pkcs7,6L\n\n#define SN_pkcs9                \"pkcs9\"\n#define NID_pkcs9               47\n#define OBJ_pkcs9               OBJ_pkcs,9L\n\n#define LN_pkcs9_emailAddress           \"emailAddress\"\n#define NID_pkcs9_emailAddress          48\n#define OBJ_pkcs9_emailAddress          OBJ_pkcs9,1L\n\n#define LN_pkcs9_unstructuredName               \"unstructuredName\"\n#define NID_pkcs9_unstructuredName              49\n#define OBJ_pkcs9_unstructuredName              OBJ_pkcs9,2L\n\n#define LN_pkcs9_contentType            \"contentType\"\n#define NID_pkcs9_contentType           50\n#define OBJ_pkcs9_contentType           OBJ_pkcs9,3L\n\n#define LN_pkcs9_messageDigest          \"messageDigest\"\n#define NID_pkcs9_messageDigest         51\n#define OBJ_pkcs9_messageDigest         OBJ_pkcs9,4L\n\n#define LN_pkcs9_signingTime            \"signingTime\"\n#define NID_pkcs9_signingTime           52\n#define OBJ_pkcs9_signingTime           OBJ_pkcs9,5L\n\n#define LN_pkcs9_countersignature               \"countersignature\"\n#define NID_pkcs9_countersignature              53\n#define OBJ_pkcs9_countersignature              OBJ_pkcs9,6L\n\n#define LN_pkcs9_challengePassword              \"challengePassword\"\n#define NID_pkcs9_challengePassword             54\n#define OBJ_pkcs9_challengePassword             OBJ_pkcs9,7L\n\n#define LN_pkcs9_unstructuredAddress            \"unstructuredAddress\"\n#define NID_pkcs9_unstructuredAddress           55\n#define OBJ_pkcs9_unstructuredAddress           OBJ_pkcs9,8L\n\n#define LN_pkcs9_extCertAttributes              \"extendedCertificateAttributes\"\n#define NID_pkcs9_extCertAttributes             56\n#define OBJ_pkcs9_extCertAttributes             OBJ_pkcs9,9L\n\n#define SN_ext_req              \"extReq\"\n#define LN_ext_req              \"Extension Request\"\n#define NID_ext_req             172\n#define OBJ_ext_req             OBJ_pkcs9,14L\n\n#define SN_SMIMECapabilities            \"SMIME-CAPS\"\n#define LN_SMIMECapabilities            \"S/MIME Capabilities\"\n#define NID_SMIMECapabilities           167\n#define OBJ_SMIMECapabilities           OBJ_pkcs9,15L\n\n#define SN_SMIME                \"SMIME\"\n#define LN_SMIME                \"S/MIME\"\n#define NID_SMIME               188\n#define OBJ_SMIME               OBJ_pkcs9,16L\n\n#define SN_id_smime_mod         \"id-smime-mod\"\n#define NID_id_smime_mod                189\n#define OBJ_id_smime_mod                OBJ_SMIME,0L\n\n#define SN_id_smime_ct          \"id-smime-ct\"\n#define NID_id_smime_ct         190\n#define OBJ_id_smime_ct         OBJ_SMIME,1L\n\n#define SN_id_smime_aa          \"id-smime-aa\"\n#define NID_id_smime_aa         191\n#define OBJ_id_smime_aa         OBJ_SMIME,2L\n\n#define SN_id_smime_alg         \"id-smime-alg\"\n#define NID_id_smime_alg                192\n#define OBJ_id_smime_alg                OBJ_SMIME,3L\n\n#define SN_id_smime_cd          \"id-smime-cd\"\n#define NID_id_smime_cd         193\n#define OBJ_id_smime_cd         OBJ_SMIME,4L\n\n#define SN_id_smime_spq         \"id-smime-spq\"\n#define NID_id_smime_spq                194\n#define OBJ_id_smime_spq                OBJ_SMIME,5L\n\n#define SN_id_smime_cti         \"id-smime-cti\"\n#define NID_id_smime_cti                195\n#define OBJ_id_smime_cti                OBJ_SMIME,6L\n\n#define SN_id_smime_mod_cms             \"id-smime-mod-cms\"\n#define NID_id_smime_mod_cms            196\n#define OBJ_id_smime_mod_cms            OBJ_id_smime_mod,1L\n\n#define SN_id_smime_mod_ess             \"id-smime-mod-ess\"\n#define NID_id_smime_mod_ess            197\n#define OBJ_id_smime_mod_ess            OBJ_id_smime_mod,2L\n\n#define SN_id_smime_mod_oid             \"id-smime-mod-oid\"\n#define NID_id_smime_mod_oid            198\n#define OBJ_id_smime_mod_oid            OBJ_id_smime_mod,3L\n\n#define SN_id_smime_mod_msg_v3          \"id-smime-mod-msg-v3\"\n#define NID_id_smime_mod_msg_v3         199\n#define OBJ_id_smime_mod_msg_v3         OBJ_id_smime_mod,4L\n\n#define SN_id_smime_mod_ets_eSignature_88               \"id-smime-mod-ets-eSignature-88\"\n#define NID_id_smime_mod_ets_eSignature_88              200\n#define OBJ_id_smime_mod_ets_eSignature_88              OBJ_id_smime_mod,5L\n\n#define SN_id_smime_mod_ets_eSignature_97               \"id-smime-mod-ets-eSignature-97\"\n#define NID_id_smime_mod_ets_eSignature_97              201\n#define OBJ_id_smime_mod_ets_eSignature_97              OBJ_id_smime_mod,6L\n\n#define SN_id_smime_mod_ets_eSigPolicy_88               \"id-smime-mod-ets-eSigPolicy-88\"\n#define NID_id_smime_mod_ets_eSigPolicy_88              202\n#define OBJ_id_smime_mod_ets_eSigPolicy_88              OBJ_id_smime_mod,7L\n\n#define SN_id_smime_mod_ets_eSigPolicy_97               \"id-smime-mod-ets-eSigPolicy-97\"\n#define NID_id_smime_mod_ets_eSigPolicy_97              203\n#define OBJ_id_smime_mod_ets_eSigPolicy_97              OBJ_id_smime_mod,8L\n\n#define SN_id_smime_ct_receipt          \"id-smime-ct-receipt\"\n#define NID_id_smime_ct_receipt         204\n#define OBJ_id_smime_ct_receipt         OBJ_id_smime_ct,1L\n\n#define SN_id_smime_ct_authData         \"id-smime-ct-authData\"\n#define NID_id_smime_ct_authData                205\n#define OBJ_id_smime_ct_authData                OBJ_id_smime_ct,2L\n\n#define SN_id_smime_ct_publishCert              \"id-smime-ct-publishCert\"\n#define NID_id_smime_ct_publishCert             206\n#define OBJ_id_smime_ct_publishCert             OBJ_id_smime_ct,3L\n\n#define SN_id_smime_ct_TSTInfo          \"id-smime-ct-TSTInfo\"\n#define NID_id_smime_ct_TSTInfo         207\n#define OBJ_id_smime_ct_TSTInfo         OBJ_id_smime_ct,4L\n\n#define SN_id_smime_ct_TDTInfo          \"id-smime-ct-TDTInfo\"\n#define NID_id_smime_ct_TDTInfo         208\n#define OBJ_id_smime_ct_TDTInfo         OBJ_id_smime_ct,5L\n\n#define SN_id_smime_ct_contentInfo              \"id-smime-ct-contentInfo\"\n#define NID_id_smime_ct_contentInfo             209\n#define OBJ_id_smime_ct_contentInfo             OBJ_id_smime_ct,6L\n\n#define SN_id_smime_ct_DVCSRequestData          \"id-smime-ct-DVCSRequestData\"\n#define NID_id_smime_ct_DVCSRequestData         210\n#define OBJ_id_smime_ct_DVCSRequestData         OBJ_id_smime_ct,7L\n\n#define SN_id_smime_ct_DVCSResponseData         \"id-smime-ct-DVCSResponseData\"\n#define NID_id_smime_ct_DVCSResponseData                211\n#define OBJ_id_smime_ct_DVCSResponseData                OBJ_id_smime_ct,8L\n\n#define SN_id_smime_ct_compressedData           \"id-smime-ct-compressedData\"\n#define NID_id_smime_ct_compressedData          786\n#define OBJ_id_smime_ct_compressedData          OBJ_id_smime_ct,9L\n\n#define SN_id_ct_asciiTextWithCRLF              \"id-ct-asciiTextWithCRLF\"\n#define NID_id_ct_asciiTextWithCRLF             787\n#define OBJ_id_ct_asciiTextWithCRLF             OBJ_id_smime_ct,27L\n\n#define SN_id_smime_aa_receiptRequest           \"id-smime-aa-receiptRequest\"\n#define NID_id_smime_aa_receiptRequest          212\n#define OBJ_id_smime_aa_receiptRequest          OBJ_id_smime_aa,1L\n\n#define SN_id_smime_aa_securityLabel            \"id-smime-aa-securityLabel\"\n#define NID_id_smime_aa_securityLabel           213\n#define OBJ_id_smime_aa_securityLabel           OBJ_id_smime_aa,2L\n\n#define SN_id_smime_aa_mlExpandHistory          \"id-smime-aa-mlExpandHistory\"\n#define NID_id_smime_aa_mlExpandHistory         214\n#define OBJ_id_smime_aa_mlExpandHistory         OBJ_id_smime_aa,3L\n\n#define SN_id_smime_aa_contentHint              \"id-smime-aa-contentHint\"\n#define NID_id_smime_aa_contentHint             215\n#define OBJ_id_smime_aa_contentHint             OBJ_id_smime_aa,4L\n\n#define SN_id_smime_aa_msgSigDigest             \"id-smime-aa-msgSigDigest\"\n#define NID_id_smime_aa_msgSigDigest            216\n#define OBJ_id_smime_aa_msgSigDigest            OBJ_id_smime_aa,5L\n\n#define SN_id_smime_aa_encapContentType         \"id-smime-aa-encapContentType\"\n#define NID_id_smime_aa_encapContentType                217\n#define OBJ_id_smime_aa_encapContentType                OBJ_id_smime_aa,6L\n\n#define SN_id_smime_aa_contentIdentifier                \"id-smime-aa-contentIdentifier\"\n#define NID_id_smime_aa_contentIdentifier               218\n#define OBJ_id_smime_aa_contentIdentifier               OBJ_id_smime_aa,7L\n\n#define SN_id_smime_aa_macValue         \"id-smime-aa-macValue\"\n#define NID_id_smime_aa_macValue                219\n#define OBJ_id_smime_aa_macValue                OBJ_id_smime_aa,8L\n\n#define SN_id_smime_aa_equivalentLabels         \"id-smime-aa-equivalentLabels\"\n#define NID_id_smime_aa_equivalentLabels                220\n#define OBJ_id_smime_aa_equivalentLabels                OBJ_id_smime_aa,9L\n\n#define SN_id_smime_aa_contentReference         \"id-smime-aa-contentReference\"\n#define NID_id_smime_aa_contentReference                221\n#define OBJ_id_smime_aa_contentReference                OBJ_id_smime_aa,10L\n\n#define SN_id_smime_aa_encrypKeyPref            \"id-smime-aa-encrypKeyPref\"\n#define NID_id_smime_aa_encrypKeyPref           222\n#define OBJ_id_smime_aa_encrypKeyPref           OBJ_id_smime_aa,11L\n\n#define SN_id_smime_aa_signingCertificate               \"id-smime-aa-signingCertificate\"\n#define NID_id_smime_aa_signingCertificate              223\n#define OBJ_id_smime_aa_signingCertificate              OBJ_id_smime_aa,12L\n\n#define SN_id_smime_aa_smimeEncryptCerts                \"id-smime-aa-smimeEncryptCerts\"\n#define NID_id_smime_aa_smimeEncryptCerts               224\n#define OBJ_id_smime_aa_smimeEncryptCerts               OBJ_id_smime_aa,13L\n\n#define SN_id_smime_aa_timeStampToken           \"id-smime-aa-timeStampToken\"\n#define NID_id_smime_aa_timeStampToken          225\n#define OBJ_id_smime_aa_timeStampToken          OBJ_id_smime_aa,14L\n\n#define SN_id_smime_aa_ets_sigPolicyId          \"id-smime-aa-ets-sigPolicyId\"\n#define NID_id_smime_aa_ets_sigPolicyId         226\n#define OBJ_id_smime_aa_ets_sigPolicyId         OBJ_id_smime_aa,15L\n\n#define SN_id_smime_aa_ets_commitmentType               \"id-smime-aa-ets-commitmentType\"\n#define NID_id_smime_aa_ets_commitmentType              227\n#define OBJ_id_smime_aa_ets_commitmentType              OBJ_id_smime_aa,16L\n\n#define SN_id_smime_aa_ets_signerLocation               \"id-smime-aa-ets-signerLocation\"\n#define NID_id_smime_aa_ets_signerLocation              228\n#define OBJ_id_smime_aa_ets_signerLocation              OBJ_id_smime_aa,17L\n\n#define SN_id_smime_aa_ets_signerAttr           \"id-smime-aa-ets-signerAttr\"\n#define NID_id_smime_aa_ets_signerAttr          229\n#define OBJ_id_smime_aa_ets_signerAttr          OBJ_id_smime_aa,18L\n\n#define SN_id_smime_aa_ets_otherSigCert         \"id-smime-aa-ets-otherSigCert\"\n#define NID_id_smime_aa_ets_otherSigCert                230\n#define OBJ_id_smime_aa_ets_otherSigCert                OBJ_id_smime_aa,19L\n\n#define SN_id_smime_aa_ets_contentTimestamp             \"id-smime-aa-ets-contentTimestamp\"\n#define NID_id_smime_aa_ets_contentTimestamp            231\n#define OBJ_id_smime_aa_ets_contentTimestamp            OBJ_id_smime_aa,20L\n\n#define SN_id_smime_aa_ets_CertificateRefs              \"id-smime-aa-ets-CertificateRefs\"\n#define NID_id_smime_aa_ets_CertificateRefs             232\n#define OBJ_id_smime_aa_ets_CertificateRefs             OBJ_id_smime_aa,21L\n\n#define SN_id_smime_aa_ets_RevocationRefs               \"id-smime-aa-ets-RevocationRefs\"\n#define NID_id_smime_aa_ets_RevocationRefs              233\n#define OBJ_id_smime_aa_ets_RevocationRefs              OBJ_id_smime_aa,22L\n\n#define SN_id_smime_aa_ets_certValues           \"id-smime-aa-ets-certValues\"\n#define NID_id_smime_aa_ets_certValues          234\n#define OBJ_id_smime_aa_ets_certValues          OBJ_id_smime_aa,23L\n\n#define SN_id_smime_aa_ets_revocationValues             \"id-smime-aa-ets-revocationValues\"\n#define NID_id_smime_aa_ets_revocationValues            235\n#define OBJ_id_smime_aa_ets_revocationValues            OBJ_id_smime_aa,24L\n\n#define SN_id_smime_aa_ets_escTimeStamp         \"id-smime-aa-ets-escTimeStamp\"\n#define NID_id_smime_aa_ets_escTimeStamp                236\n#define OBJ_id_smime_aa_ets_escTimeStamp                OBJ_id_smime_aa,25L\n\n#define SN_id_smime_aa_ets_certCRLTimestamp             \"id-smime-aa-ets-certCRLTimestamp\"\n#define NID_id_smime_aa_ets_certCRLTimestamp            237\n#define OBJ_id_smime_aa_ets_certCRLTimestamp            OBJ_id_smime_aa,26L\n\n#define SN_id_smime_aa_ets_archiveTimeStamp             \"id-smime-aa-ets-archiveTimeStamp\"\n#define NID_id_smime_aa_ets_archiveTimeStamp            238\n#define OBJ_id_smime_aa_ets_archiveTimeStamp            OBJ_id_smime_aa,27L\n\n#define SN_id_smime_aa_signatureType            \"id-smime-aa-signatureType\"\n#define NID_id_smime_aa_signatureType           239\n#define OBJ_id_smime_aa_signatureType           OBJ_id_smime_aa,28L\n\n#define SN_id_smime_aa_dvcs_dvc         \"id-smime-aa-dvcs-dvc\"\n#define NID_id_smime_aa_dvcs_dvc                240\n#define OBJ_id_smime_aa_dvcs_dvc                OBJ_id_smime_aa,29L\n\n#define SN_id_smime_alg_ESDHwith3DES            \"id-smime-alg-ESDHwith3DES\"\n#define NID_id_smime_alg_ESDHwith3DES           241\n#define OBJ_id_smime_alg_ESDHwith3DES           OBJ_id_smime_alg,1L\n\n#define SN_id_smime_alg_ESDHwithRC2             \"id-smime-alg-ESDHwithRC2\"\n#define NID_id_smime_alg_ESDHwithRC2            242\n#define OBJ_id_smime_alg_ESDHwithRC2            OBJ_id_smime_alg,2L\n\n#define SN_id_smime_alg_3DESwrap                \"id-smime-alg-3DESwrap\"\n#define NID_id_smime_alg_3DESwrap               243\n#define OBJ_id_smime_alg_3DESwrap               OBJ_id_smime_alg,3L\n\n#define SN_id_smime_alg_RC2wrap         \"id-smime-alg-RC2wrap\"\n#define NID_id_smime_alg_RC2wrap                244\n#define OBJ_id_smime_alg_RC2wrap                OBJ_id_smime_alg,4L\n\n#define SN_id_smime_alg_ESDH            \"id-smime-alg-ESDH\"\n#define NID_id_smime_alg_ESDH           245\n#define OBJ_id_smime_alg_ESDH           OBJ_id_smime_alg,5L\n\n#define SN_id_smime_alg_CMS3DESwrap             \"id-smime-alg-CMS3DESwrap\"\n#define NID_id_smime_alg_CMS3DESwrap            246\n#define OBJ_id_smime_alg_CMS3DESwrap            OBJ_id_smime_alg,6L\n\n#define SN_id_smime_alg_CMSRC2wrap              \"id-smime-alg-CMSRC2wrap\"\n#define NID_id_smime_alg_CMSRC2wrap             247\n#define OBJ_id_smime_alg_CMSRC2wrap             OBJ_id_smime_alg,7L\n\n#define SN_id_alg_PWRI_KEK              \"id-alg-PWRI-KEK\"\n#define NID_id_alg_PWRI_KEK             893\n#define OBJ_id_alg_PWRI_KEK             OBJ_id_smime_alg,9L\n\n#define SN_id_smime_cd_ldap             \"id-smime-cd-ldap\"\n#define NID_id_smime_cd_ldap            248\n#define OBJ_id_smime_cd_ldap            OBJ_id_smime_cd,1L\n\n#define SN_id_smime_spq_ets_sqt_uri             \"id-smime-spq-ets-sqt-uri\"\n#define NID_id_smime_spq_ets_sqt_uri            249\n#define OBJ_id_smime_spq_ets_sqt_uri            OBJ_id_smime_spq,1L\n\n#define SN_id_smime_spq_ets_sqt_unotice         \"id-smime-spq-ets-sqt-unotice\"\n#define NID_id_smime_spq_ets_sqt_unotice                250\n#define OBJ_id_smime_spq_ets_sqt_unotice                OBJ_id_smime_spq,2L\n\n#define SN_id_smime_cti_ets_proofOfOrigin               \"id-smime-cti-ets-proofOfOrigin\"\n#define NID_id_smime_cti_ets_proofOfOrigin              251\n#define OBJ_id_smime_cti_ets_proofOfOrigin              OBJ_id_smime_cti,1L\n\n#define SN_id_smime_cti_ets_proofOfReceipt              \"id-smime-cti-ets-proofOfReceipt\"\n#define NID_id_smime_cti_ets_proofOfReceipt             252\n#define OBJ_id_smime_cti_ets_proofOfReceipt             OBJ_id_smime_cti,2L\n\n#define SN_id_smime_cti_ets_proofOfDelivery             \"id-smime-cti-ets-proofOfDelivery\"\n#define NID_id_smime_cti_ets_proofOfDelivery            253\n#define OBJ_id_smime_cti_ets_proofOfDelivery            OBJ_id_smime_cti,3L\n\n#define SN_id_smime_cti_ets_proofOfSender               \"id-smime-cti-ets-proofOfSender\"\n#define NID_id_smime_cti_ets_proofOfSender              254\n#define OBJ_id_smime_cti_ets_proofOfSender              OBJ_id_smime_cti,4L\n\n#define SN_id_smime_cti_ets_proofOfApproval             \"id-smime-cti-ets-proofOfApproval\"\n#define NID_id_smime_cti_ets_proofOfApproval            255\n#define OBJ_id_smime_cti_ets_proofOfApproval            OBJ_id_smime_cti,5L\n\n#define SN_id_smime_cti_ets_proofOfCreation             \"id-smime-cti-ets-proofOfCreation\"\n#define NID_id_smime_cti_ets_proofOfCreation            256\n#define OBJ_id_smime_cti_ets_proofOfCreation            OBJ_id_smime_cti,6L\n\n#define LN_friendlyName         \"friendlyName\"\n#define NID_friendlyName                156\n#define OBJ_friendlyName                OBJ_pkcs9,20L\n\n#define LN_localKeyID           \"localKeyID\"\n#define NID_localKeyID          157\n#define OBJ_localKeyID          OBJ_pkcs9,21L\n\n#define SN_ms_csp_name          \"CSPName\"\n#define LN_ms_csp_name          \"Microsoft CSP Name\"\n#define NID_ms_csp_name         417\n#define OBJ_ms_csp_name         1L,3L,6L,1L,4L,1L,311L,17L,1L\n\n#define SN_LocalKeySet          \"LocalKeySet\"\n#define LN_LocalKeySet          \"Microsoft Local Key set\"\n#define NID_LocalKeySet         856\n#define OBJ_LocalKeySet         1L,3L,6L,1L,4L,1L,311L,17L,2L\n\n#define OBJ_certTypes           OBJ_pkcs9,22L\n\n#define LN_x509Certificate              \"x509Certificate\"\n#define NID_x509Certificate             158\n#define OBJ_x509Certificate             OBJ_certTypes,1L\n\n#define LN_sdsiCertificate              \"sdsiCertificate\"\n#define NID_sdsiCertificate             159\n#define OBJ_sdsiCertificate             OBJ_certTypes,2L\n\n#define OBJ_crlTypes            OBJ_pkcs9,23L\n\n#define LN_x509Crl              \"x509Crl\"\n#define NID_x509Crl             160\n#define OBJ_x509Crl             OBJ_crlTypes,1L\n\n#define OBJ_pkcs12              OBJ_pkcs,12L\n\n#define OBJ_pkcs12_pbeids               OBJ_pkcs12,1L\n\n#define SN_pbe_WithSHA1And128BitRC4             \"PBE-SHA1-RC4-128\"\n#define LN_pbe_WithSHA1And128BitRC4             \"pbeWithSHA1And128BitRC4\"\n#define NID_pbe_WithSHA1And128BitRC4            144\n#define OBJ_pbe_WithSHA1And128BitRC4            OBJ_pkcs12_pbeids,1L\n\n#define SN_pbe_WithSHA1And40BitRC4              \"PBE-SHA1-RC4-40\"\n#define LN_pbe_WithSHA1And40BitRC4              \"pbeWithSHA1And40BitRC4\"\n#define NID_pbe_WithSHA1And40BitRC4             145\n#define OBJ_pbe_WithSHA1And40BitRC4             OBJ_pkcs12_pbeids,2L\n\n#define SN_pbe_WithSHA1And3_Key_TripleDES_CBC           \"PBE-SHA1-3DES\"\n#define LN_pbe_WithSHA1And3_Key_TripleDES_CBC           \"pbeWithSHA1And3-KeyTripleDES-CBC\"\n#define NID_pbe_WithSHA1And3_Key_TripleDES_CBC          146\n#define OBJ_pbe_WithSHA1And3_Key_TripleDES_CBC          OBJ_pkcs12_pbeids,3L\n\n#define SN_pbe_WithSHA1And2_Key_TripleDES_CBC           \"PBE-SHA1-2DES\"\n#define LN_pbe_WithSHA1And2_Key_TripleDES_CBC           \"pbeWithSHA1And2-KeyTripleDES-CBC\"\n#define NID_pbe_WithSHA1And2_Key_TripleDES_CBC          147\n#define OBJ_pbe_WithSHA1And2_Key_TripleDES_CBC          OBJ_pkcs12_pbeids,4L\n\n#define SN_pbe_WithSHA1And128BitRC2_CBC         \"PBE-SHA1-RC2-128\"\n#define LN_pbe_WithSHA1And128BitRC2_CBC         \"pbeWithSHA1And128BitRC2-CBC\"\n#define NID_pbe_WithSHA1And128BitRC2_CBC                148\n#define OBJ_pbe_WithSHA1And128BitRC2_CBC                OBJ_pkcs12_pbeids,5L\n\n#define SN_pbe_WithSHA1And40BitRC2_CBC          \"PBE-SHA1-RC2-40\"\n#define LN_pbe_WithSHA1And40BitRC2_CBC          \"pbeWithSHA1And40BitRC2-CBC\"\n#define NID_pbe_WithSHA1And40BitRC2_CBC         149\n#define OBJ_pbe_WithSHA1And40BitRC2_CBC         OBJ_pkcs12_pbeids,6L\n\n#define OBJ_pkcs12_Version1             OBJ_pkcs12,10L\n\n#define OBJ_pkcs12_BagIds               OBJ_pkcs12_Version1,1L\n\n#define LN_keyBag               \"keyBag\"\n#define NID_keyBag              150\n#define OBJ_keyBag              OBJ_pkcs12_BagIds,1L\n\n#define LN_pkcs8ShroudedKeyBag          \"pkcs8ShroudedKeyBag\"\n#define NID_pkcs8ShroudedKeyBag         151\n#define OBJ_pkcs8ShroudedKeyBag         OBJ_pkcs12_BagIds,2L\n\n#define LN_certBag              \"certBag\"\n#define NID_certBag             152\n#define OBJ_certBag             OBJ_pkcs12_BagIds,3L\n\n#define LN_crlBag               \"crlBag\"\n#define NID_crlBag              153\n#define OBJ_crlBag              OBJ_pkcs12_BagIds,4L\n\n#define LN_secretBag            \"secretBag\"\n#define NID_secretBag           154\n#define OBJ_secretBag           OBJ_pkcs12_BagIds,5L\n\n#define LN_safeContentsBag              \"safeContentsBag\"\n#define NID_safeContentsBag             155\n#define OBJ_safeContentsBag             OBJ_pkcs12_BagIds,6L\n\n#define SN_md2          \"MD2\"\n#define LN_md2          \"md2\"\n#define NID_md2         3\n#define OBJ_md2         OBJ_rsadsi,2L,2L\n\n#define SN_md4          \"MD4\"\n#define LN_md4          \"md4\"\n#define NID_md4         257\n#define OBJ_md4         OBJ_rsadsi,2L,4L\n\n#define SN_md5          \"MD5\"\n#define LN_md5          \"md5\"\n#define NID_md5         4\n#define OBJ_md5         OBJ_rsadsi,2L,5L\n\n#define SN_md5_sha1             \"MD5-SHA1\"\n#define LN_md5_sha1             \"md5-sha1\"\n#define NID_md5_sha1            114\n\n#define LN_hmacWithMD5          \"hmacWithMD5\"\n#define NID_hmacWithMD5         797\n#define OBJ_hmacWithMD5         OBJ_rsadsi,2L,6L\n\n#define LN_hmacWithSHA1         \"hmacWithSHA1\"\n#define NID_hmacWithSHA1                163\n#define OBJ_hmacWithSHA1                OBJ_rsadsi,2L,7L\n\n#define LN_hmacWithSHA224               \"hmacWithSHA224\"\n#define NID_hmacWithSHA224              798\n#define OBJ_hmacWithSHA224              OBJ_rsadsi,2L,8L\n\n#define LN_hmacWithSHA256               \"hmacWithSHA256\"\n#define NID_hmacWithSHA256              799\n#define OBJ_hmacWithSHA256              OBJ_rsadsi,2L,9L\n\n#define LN_hmacWithSHA384               \"hmacWithSHA384\"\n#define NID_hmacWithSHA384              800\n#define OBJ_hmacWithSHA384              OBJ_rsadsi,2L,10L\n\n#define LN_hmacWithSHA512               \"hmacWithSHA512\"\n#define NID_hmacWithSHA512              801\n#define OBJ_hmacWithSHA512              OBJ_rsadsi,2L,11L\n\n#define SN_rc2_cbc              \"RC2-CBC\"\n#define LN_rc2_cbc              \"rc2-cbc\"\n#define NID_rc2_cbc             37\n#define OBJ_rc2_cbc             OBJ_rsadsi,3L,2L\n\n#define SN_rc2_ecb              \"RC2-ECB\"\n#define LN_rc2_ecb              \"rc2-ecb\"\n#define NID_rc2_ecb             38\n\n#define SN_rc2_cfb64            \"RC2-CFB\"\n#define LN_rc2_cfb64            \"rc2-cfb\"\n#define NID_rc2_cfb64           39\n\n#define SN_rc2_ofb64            \"RC2-OFB\"\n#define LN_rc2_ofb64            \"rc2-ofb\"\n#define NID_rc2_ofb64           40\n\n#define SN_rc2_40_cbc           \"RC2-40-CBC\"\n#define LN_rc2_40_cbc           \"rc2-40-cbc\"\n#define NID_rc2_40_cbc          98\n\n#define SN_rc2_64_cbc           \"RC2-64-CBC\"\n#define LN_rc2_64_cbc           \"rc2-64-cbc\"\n#define NID_rc2_64_cbc          166\n\n#define SN_rc4          \"RC4\"\n#define LN_rc4          \"rc4\"\n#define NID_rc4         5\n#define OBJ_rc4         OBJ_rsadsi,3L,4L\n\n#define SN_rc4_40               \"RC4-40\"\n#define LN_rc4_40               \"rc4-40\"\n#define NID_rc4_40              97\n\n#define SN_des_ede3_cbc         \"DES-EDE3-CBC\"\n#define LN_des_ede3_cbc         \"des-ede3-cbc\"\n#define NID_des_ede3_cbc                44\n#define OBJ_des_ede3_cbc                OBJ_rsadsi,3L,7L\n\n#define SN_rc5_cbc              \"RC5-CBC\"\n#define LN_rc5_cbc              \"rc5-cbc\"\n#define NID_rc5_cbc             120\n#define OBJ_rc5_cbc             OBJ_rsadsi,3L,8L\n\n#define SN_rc5_ecb              \"RC5-ECB\"\n#define LN_rc5_ecb              \"rc5-ecb\"\n#define NID_rc5_ecb             121\n\n#define SN_rc5_cfb64            \"RC5-CFB\"\n#define LN_rc5_cfb64            \"rc5-cfb\"\n#define NID_rc5_cfb64           122\n\n#define SN_rc5_ofb64            \"RC5-OFB\"\n#define LN_rc5_ofb64            \"rc5-ofb\"\n#define NID_rc5_ofb64           123\n\n#define SN_ms_ext_req           \"msExtReq\"\n#define LN_ms_ext_req           \"Microsoft Extension Request\"\n#define NID_ms_ext_req          171\n#define OBJ_ms_ext_req          1L,3L,6L,1L,4L,1L,311L,2L,1L,14L\n\n#define SN_ms_code_ind          \"msCodeInd\"\n#define LN_ms_code_ind          \"Microsoft Individual Code Signing\"\n#define NID_ms_code_ind         134\n#define OBJ_ms_code_ind         1L,3L,6L,1L,4L,1L,311L,2L,1L,21L\n\n#define SN_ms_code_com          \"msCodeCom\"\n#define LN_ms_code_com          \"Microsoft Commercial Code Signing\"\n#define NID_ms_code_com         135\n#define OBJ_ms_code_com         1L,3L,6L,1L,4L,1L,311L,2L,1L,22L\n\n#define SN_ms_ctl_sign          \"msCTLSign\"\n#define LN_ms_ctl_sign          \"Microsoft Trust List Signing\"\n#define NID_ms_ctl_sign         136\n#define OBJ_ms_ctl_sign         1L,3L,6L,1L,4L,1L,311L,10L,3L,1L\n\n#define SN_ms_sgc               \"msSGC\"\n#define LN_ms_sgc               \"Microsoft Server Gated Crypto\"\n#define NID_ms_sgc              137\n#define OBJ_ms_sgc              1L,3L,6L,1L,4L,1L,311L,10L,3L,3L\n\n#define SN_ms_efs               \"msEFS\"\n#define LN_ms_efs               \"Microsoft Encrypted File System\"\n#define NID_ms_efs              138\n#define OBJ_ms_efs              1L,3L,6L,1L,4L,1L,311L,10L,3L,4L\n\n#define SN_ms_smartcard_login           \"msSmartcardLogin\"\n#define LN_ms_smartcard_login           \"Microsoft Smartcardlogin\"\n#define NID_ms_smartcard_login          648\n#define OBJ_ms_smartcard_login          1L,3L,6L,1L,4L,1L,311L,20L,2L,2L\n\n#define SN_ms_upn               \"msUPN\"\n#define LN_ms_upn               \"Microsoft Universal Principal Name\"\n#define NID_ms_upn              649\n#define OBJ_ms_upn              1L,3L,6L,1L,4L,1L,311L,20L,2L,3L\n\n#define SN_idea_cbc             \"IDEA-CBC\"\n#define LN_idea_cbc             \"idea-cbc\"\n#define NID_idea_cbc            34\n#define OBJ_idea_cbc            1L,3L,6L,1L,4L,1L,188L,7L,1L,1L,2L\n\n#define SN_idea_ecb             \"IDEA-ECB\"\n#define LN_idea_ecb             \"idea-ecb\"\n#define NID_idea_ecb            36\n\n#define SN_idea_cfb64           \"IDEA-CFB\"\n#define LN_idea_cfb64           \"idea-cfb\"\n#define NID_idea_cfb64          35\n\n#define SN_idea_ofb64           \"IDEA-OFB\"\n#define LN_idea_ofb64           \"idea-ofb\"\n#define NID_idea_ofb64          46\n\n#define SN_bf_cbc               \"BF-CBC\"\n#define LN_bf_cbc               \"bf-cbc\"\n#define NID_bf_cbc              91\n#define OBJ_bf_cbc              1L,3L,6L,1L,4L,1L,3029L,1L,2L\n\n#define SN_bf_ecb               \"BF-ECB\"\n#define LN_bf_ecb               \"bf-ecb\"\n#define NID_bf_ecb              92\n\n#define SN_bf_cfb64             \"BF-CFB\"\n#define LN_bf_cfb64             \"bf-cfb\"\n#define NID_bf_cfb64            93\n\n#define SN_bf_ofb64             \"BF-OFB\"\n#define LN_bf_ofb64             \"bf-ofb\"\n#define NID_bf_ofb64            94\n\n#define SN_id_pkix              \"PKIX\"\n#define NID_id_pkix             127\n#define OBJ_id_pkix             1L,3L,6L,1L,5L,5L,7L\n\n#define SN_id_pkix_mod          \"id-pkix-mod\"\n#define NID_id_pkix_mod         258\n#define OBJ_id_pkix_mod         OBJ_id_pkix,0L\n\n#define SN_id_pe                \"id-pe\"\n#define NID_id_pe               175\n#define OBJ_id_pe               OBJ_id_pkix,1L\n\n#define SN_id_qt                \"id-qt\"\n#define NID_id_qt               259\n#define OBJ_id_qt               OBJ_id_pkix,2L\n\n#define SN_id_kp                \"id-kp\"\n#define NID_id_kp               128\n#define OBJ_id_kp               OBJ_id_pkix,3L\n\n#define SN_id_it                \"id-it\"\n#define NID_id_it               260\n#define OBJ_id_it               OBJ_id_pkix,4L\n\n#define SN_id_pkip              \"id-pkip\"\n#define NID_id_pkip             261\n#define OBJ_id_pkip             OBJ_id_pkix,5L\n\n#define SN_id_alg               \"id-alg\"\n#define NID_id_alg              262\n#define OBJ_id_alg              OBJ_id_pkix,6L\n\n#define SN_id_cmc               \"id-cmc\"\n#define NID_id_cmc              263\n#define OBJ_id_cmc              OBJ_id_pkix,7L\n\n#define SN_id_on                \"id-on\"\n#define NID_id_on               264\n#define OBJ_id_on               OBJ_id_pkix,8L\n\n#define SN_id_pda               \"id-pda\"\n#define NID_id_pda              265\n#define OBJ_id_pda              OBJ_id_pkix,9L\n\n#define SN_id_aca               \"id-aca\"\n#define NID_id_aca              266\n#define OBJ_id_aca              OBJ_id_pkix,10L\n\n#define SN_id_qcs               \"id-qcs\"\n#define NID_id_qcs              267\n#define OBJ_id_qcs              OBJ_id_pkix,11L\n\n#define SN_id_cct               \"id-cct\"\n#define NID_id_cct              268\n#define OBJ_id_cct              OBJ_id_pkix,12L\n\n#define SN_id_ppl               \"id-ppl\"\n#define NID_id_ppl              662\n#define OBJ_id_ppl              OBJ_id_pkix,21L\n\n#define SN_id_ad                \"id-ad\"\n#define NID_id_ad               176\n#define OBJ_id_ad               OBJ_id_pkix,48L\n\n#define SN_id_pkix1_explicit_88         \"id-pkix1-explicit-88\"\n#define NID_id_pkix1_explicit_88                269\n#define OBJ_id_pkix1_explicit_88                OBJ_id_pkix_mod,1L\n\n#define SN_id_pkix1_implicit_88         \"id-pkix1-implicit-88\"\n#define NID_id_pkix1_implicit_88                270\n#define OBJ_id_pkix1_implicit_88                OBJ_id_pkix_mod,2L\n\n#define SN_id_pkix1_explicit_93         \"id-pkix1-explicit-93\"\n#define NID_id_pkix1_explicit_93                271\n#define OBJ_id_pkix1_explicit_93                OBJ_id_pkix_mod,3L\n\n#define SN_id_pkix1_implicit_93         \"id-pkix1-implicit-93\"\n#define NID_id_pkix1_implicit_93                272\n#define OBJ_id_pkix1_implicit_93                OBJ_id_pkix_mod,4L\n\n#define SN_id_mod_crmf          \"id-mod-crmf\"\n#define NID_id_mod_crmf         273\n#define OBJ_id_mod_crmf         OBJ_id_pkix_mod,5L\n\n#define SN_id_mod_cmc           \"id-mod-cmc\"\n#define NID_id_mod_cmc          274\n#define OBJ_id_mod_cmc          OBJ_id_pkix_mod,6L\n\n#define SN_id_mod_kea_profile_88                \"id-mod-kea-profile-88\"\n#define NID_id_mod_kea_profile_88               275\n#define OBJ_id_mod_kea_profile_88               OBJ_id_pkix_mod,7L\n\n#define SN_id_mod_kea_profile_93                \"id-mod-kea-profile-93\"\n#define NID_id_mod_kea_profile_93               276\n#define OBJ_id_mod_kea_profile_93               OBJ_id_pkix_mod,8L\n\n#define SN_id_mod_cmp           \"id-mod-cmp\"\n#define NID_id_mod_cmp          277\n#define OBJ_id_mod_cmp          OBJ_id_pkix_mod,9L\n\n#define SN_id_mod_qualified_cert_88             \"id-mod-qualified-cert-88\"\n#define NID_id_mod_qualified_cert_88            278\n#define OBJ_id_mod_qualified_cert_88            OBJ_id_pkix_mod,10L\n\n#define SN_id_mod_qualified_cert_93             \"id-mod-qualified-cert-93\"\n#define NID_id_mod_qualified_cert_93            279\n#define OBJ_id_mod_qualified_cert_93            OBJ_id_pkix_mod,11L\n\n#define SN_id_mod_attribute_cert                \"id-mod-attribute-cert\"\n#define NID_id_mod_attribute_cert               280\n#define OBJ_id_mod_attribute_cert               OBJ_id_pkix_mod,12L\n\n#define SN_id_mod_timestamp_protocol            \"id-mod-timestamp-protocol\"\n#define NID_id_mod_timestamp_protocol           281\n#define OBJ_id_mod_timestamp_protocol           OBJ_id_pkix_mod,13L\n\n#define SN_id_mod_ocsp          \"id-mod-ocsp\"\n#define NID_id_mod_ocsp         282\n#define OBJ_id_mod_ocsp         OBJ_id_pkix_mod,14L\n\n#define SN_id_mod_dvcs          \"id-mod-dvcs\"\n#define NID_id_mod_dvcs         283\n#define OBJ_id_mod_dvcs         OBJ_id_pkix_mod,15L\n\n#define SN_id_mod_cmp2000               \"id-mod-cmp2000\"\n#define NID_id_mod_cmp2000              284\n#define OBJ_id_mod_cmp2000              OBJ_id_pkix_mod,16L\n\n#define SN_info_access          \"authorityInfoAccess\"\n#define LN_info_access          \"Authority Information Access\"\n#define NID_info_access         177\n#define OBJ_info_access         OBJ_id_pe,1L\n\n#define SN_biometricInfo                \"biometricInfo\"\n#define LN_biometricInfo                \"Biometric Info\"\n#define NID_biometricInfo               285\n#define OBJ_biometricInfo               OBJ_id_pe,2L\n\n#define SN_qcStatements         \"qcStatements\"\n#define NID_qcStatements                286\n#define OBJ_qcStatements                OBJ_id_pe,3L\n\n#define SN_ac_auditEntity               \"ac-auditEntity\"\n#define NID_ac_auditEntity              287\n#define OBJ_ac_auditEntity              OBJ_id_pe,4L\n\n#define SN_ac_targeting         \"ac-targeting\"\n#define NID_ac_targeting                288\n#define OBJ_ac_targeting                OBJ_id_pe,5L\n\n#define SN_aaControls           \"aaControls\"\n#define NID_aaControls          289\n#define OBJ_aaControls          OBJ_id_pe,6L\n\n#define SN_sbgp_ipAddrBlock             \"sbgp-ipAddrBlock\"\n#define NID_sbgp_ipAddrBlock            290\n#define OBJ_sbgp_ipAddrBlock            OBJ_id_pe,7L\n\n#define SN_sbgp_autonomousSysNum                \"sbgp-autonomousSysNum\"\n#define NID_sbgp_autonomousSysNum               291\n#define OBJ_sbgp_autonomousSysNum               OBJ_id_pe,8L\n\n#define SN_sbgp_routerIdentifier                \"sbgp-routerIdentifier\"\n#define NID_sbgp_routerIdentifier               292\n#define OBJ_sbgp_routerIdentifier               OBJ_id_pe,9L\n\n#define SN_ac_proxying          \"ac-proxying\"\n#define NID_ac_proxying         397\n#define OBJ_ac_proxying         OBJ_id_pe,10L\n\n#define SN_sinfo_access         \"subjectInfoAccess\"\n#define LN_sinfo_access         \"Subject Information Access\"\n#define NID_sinfo_access                398\n#define OBJ_sinfo_access                OBJ_id_pe,11L\n\n#define SN_proxyCertInfo                \"proxyCertInfo\"\n#define LN_proxyCertInfo                \"Proxy Certificate Information\"\n#define NID_proxyCertInfo               663\n#define OBJ_proxyCertInfo               OBJ_id_pe,14L\n\n#define SN_id_qt_cps            \"id-qt-cps\"\n#define LN_id_qt_cps            \"Policy Qualifier CPS\"\n#define NID_id_qt_cps           164\n#define OBJ_id_qt_cps           OBJ_id_qt,1L\n\n#define SN_id_qt_unotice                \"id-qt-unotice\"\n#define LN_id_qt_unotice                \"Policy Qualifier User Notice\"\n#define NID_id_qt_unotice               165\n#define OBJ_id_qt_unotice               OBJ_id_qt,2L\n\n#define SN_textNotice           \"textNotice\"\n#define NID_textNotice          293\n#define OBJ_textNotice          OBJ_id_qt,3L\n\n#define SN_server_auth          \"serverAuth\"\n#define LN_server_auth          \"TLS Web Server Authentication\"\n#define NID_server_auth         129\n#define OBJ_server_auth         OBJ_id_kp,1L\n\n#define SN_client_auth          \"clientAuth\"\n#define LN_client_auth          \"TLS Web Client Authentication\"\n#define NID_client_auth         130\n#define OBJ_client_auth         OBJ_id_kp,2L\n\n#define SN_code_sign            \"codeSigning\"\n#define LN_code_sign            \"Code Signing\"\n#define NID_code_sign           131\n#define OBJ_code_sign           OBJ_id_kp,3L\n\n#define SN_email_protect                \"emailProtection\"\n#define LN_email_protect                \"E-mail Protection\"\n#define NID_email_protect               132\n#define OBJ_email_protect               OBJ_id_kp,4L\n\n#define SN_ipsecEndSystem               \"ipsecEndSystem\"\n#define LN_ipsecEndSystem               \"IPSec End System\"\n#define NID_ipsecEndSystem              294\n#define OBJ_ipsecEndSystem              OBJ_id_kp,5L\n\n#define SN_ipsecTunnel          \"ipsecTunnel\"\n#define LN_ipsecTunnel          \"IPSec Tunnel\"\n#define NID_ipsecTunnel         295\n#define OBJ_ipsecTunnel         OBJ_id_kp,6L\n\n#define SN_ipsecUser            \"ipsecUser\"\n#define LN_ipsecUser            \"IPSec User\"\n#define NID_ipsecUser           296\n#define OBJ_ipsecUser           OBJ_id_kp,7L\n\n#define SN_time_stamp           \"timeStamping\"\n#define LN_time_stamp           \"Time Stamping\"\n#define NID_time_stamp          133\n#define OBJ_time_stamp          OBJ_id_kp,8L\n\n#define SN_OCSP_sign            \"OCSPSigning\"\n#define LN_OCSP_sign            \"OCSP Signing\"\n#define NID_OCSP_sign           180\n#define OBJ_OCSP_sign           OBJ_id_kp,9L\n\n#define SN_dvcs         \"DVCS\"\n#define LN_dvcs         \"dvcs\"\n#define NID_dvcs                297\n#define OBJ_dvcs                OBJ_id_kp,10L\n\n#define SN_id_it_caProtEncCert          \"id-it-caProtEncCert\"\n#define NID_id_it_caProtEncCert         298\n#define OBJ_id_it_caProtEncCert         OBJ_id_it,1L\n\n#define SN_id_it_signKeyPairTypes               \"id-it-signKeyPairTypes\"\n#define NID_id_it_signKeyPairTypes              299\n#define OBJ_id_it_signKeyPairTypes              OBJ_id_it,2L\n\n#define SN_id_it_encKeyPairTypes                \"id-it-encKeyPairTypes\"\n#define NID_id_it_encKeyPairTypes               300\n#define OBJ_id_it_encKeyPairTypes               OBJ_id_it,3L\n\n#define SN_id_it_preferredSymmAlg               \"id-it-preferredSymmAlg\"\n#define NID_id_it_preferredSymmAlg              301\n#define OBJ_id_it_preferredSymmAlg              OBJ_id_it,4L\n\n#define SN_id_it_caKeyUpdateInfo                \"id-it-caKeyUpdateInfo\"\n#define NID_id_it_caKeyUpdateInfo               302\n#define OBJ_id_it_caKeyUpdateInfo               OBJ_id_it,5L\n\n#define SN_id_it_currentCRL             \"id-it-currentCRL\"\n#define NID_id_it_currentCRL            303\n#define OBJ_id_it_currentCRL            OBJ_id_it,6L\n\n#define SN_id_it_unsupportedOIDs                \"id-it-unsupportedOIDs\"\n#define NID_id_it_unsupportedOIDs               304\n#define OBJ_id_it_unsupportedOIDs               OBJ_id_it,7L\n\n#define SN_id_it_subscriptionRequest            \"id-it-subscriptionRequest\"\n#define NID_id_it_subscriptionRequest           305\n#define OBJ_id_it_subscriptionRequest           OBJ_id_it,8L\n\n#define SN_id_it_subscriptionResponse           \"id-it-subscriptionResponse\"\n#define NID_id_it_subscriptionResponse          306\n#define OBJ_id_it_subscriptionResponse          OBJ_id_it,9L\n\n#define SN_id_it_keyPairParamReq                \"id-it-keyPairParamReq\"\n#define NID_id_it_keyPairParamReq               307\n#define OBJ_id_it_keyPairParamReq               OBJ_id_it,10L\n\n#define SN_id_it_keyPairParamRep                \"id-it-keyPairParamRep\"\n#define NID_id_it_keyPairParamRep               308\n#define OBJ_id_it_keyPairParamRep               OBJ_id_it,11L\n\n#define SN_id_it_revPassphrase          \"id-it-revPassphrase\"\n#define NID_id_it_revPassphrase         309\n#define OBJ_id_it_revPassphrase         OBJ_id_it,12L\n\n#define SN_id_it_implicitConfirm                \"id-it-implicitConfirm\"\n#define NID_id_it_implicitConfirm               310\n#define OBJ_id_it_implicitConfirm               OBJ_id_it,13L\n\n#define SN_id_it_confirmWaitTime                \"id-it-confirmWaitTime\"\n#define NID_id_it_confirmWaitTime               311\n#define OBJ_id_it_confirmWaitTime               OBJ_id_it,14L\n\n#define SN_id_it_origPKIMessage         \"id-it-origPKIMessage\"\n#define NID_id_it_origPKIMessage                312\n#define OBJ_id_it_origPKIMessage                OBJ_id_it,15L\n\n#define SN_id_it_suppLangTags           \"id-it-suppLangTags\"\n#define NID_id_it_suppLangTags          784\n#define OBJ_id_it_suppLangTags          OBJ_id_it,16L\n\n#define SN_id_regCtrl           \"id-regCtrl\"\n#define NID_id_regCtrl          313\n#define OBJ_id_regCtrl          OBJ_id_pkip,1L\n\n#define SN_id_regInfo           \"id-regInfo\"\n#define NID_id_regInfo          314\n#define OBJ_id_regInfo          OBJ_id_pkip,2L\n\n#define SN_id_regCtrl_regToken          \"id-regCtrl-regToken\"\n#define NID_id_regCtrl_regToken         315\n#define OBJ_id_regCtrl_regToken         OBJ_id_regCtrl,1L\n\n#define SN_id_regCtrl_authenticator             \"id-regCtrl-authenticator\"\n#define NID_id_regCtrl_authenticator            316\n#define OBJ_id_regCtrl_authenticator            OBJ_id_regCtrl,2L\n\n#define SN_id_regCtrl_pkiPublicationInfo                \"id-regCtrl-pkiPublicationInfo\"\n#define NID_id_regCtrl_pkiPublicationInfo               317\n#define OBJ_id_regCtrl_pkiPublicationInfo               OBJ_id_regCtrl,3L\n\n#define SN_id_regCtrl_pkiArchiveOptions         \"id-regCtrl-pkiArchiveOptions\"\n#define NID_id_regCtrl_pkiArchiveOptions                318\n#define OBJ_id_regCtrl_pkiArchiveOptions                OBJ_id_regCtrl,4L\n\n#define SN_id_regCtrl_oldCertID         \"id-regCtrl-oldCertID\"\n#define NID_id_regCtrl_oldCertID                319\n#define OBJ_id_regCtrl_oldCertID                OBJ_id_regCtrl,5L\n\n#define SN_id_regCtrl_protocolEncrKey           \"id-regCtrl-protocolEncrKey\"\n#define NID_id_regCtrl_protocolEncrKey          320\n#define OBJ_id_regCtrl_protocolEncrKey          OBJ_id_regCtrl,6L\n\n#define SN_id_regInfo_utf8Pairs         \"id-regInfo-utf8Pairs\"\n#define NID_id_regInfo_utf8Pairs                321\n#define OBJ_id_regInfo_utf8Pairs                OBJ_id_regInfo,1L\n\n#define SN_id_regInfo_certReq           \"id-regInfo-certReq\"\n#define NID_id_regInfo_certReq          322\n#define OBJ_id_regInfo_certReq          OBJ_id_regInfo,2L\n\n#define SN_id_alg_des40         \"id-alg-des40\"\n#define NID_id_alg_des40                323\n#define OBJ_id_alg_des40                OBJ_id_alg,1L\n\n#define SN_id_alg_noSignature           \"id-alg-noSignature\"\n#define NID_id_alg_noSignature          324\n#define OBJ_id_alg_noSignature          OBJ_id_alg,2L\n\n#define SN_id_alg_dh_sig_hmac_sha1              \"id-alg-dh-sig-hmac-sha1\"\n#define NID_id_alg_dh_sig_hmac_sha1             325\n#define OBJ_id_alg_dh_sig_hmac_sha1             OBJ_id_alg,3L\n\n#define SN_id_alg_dh_pop                \"id-alg-dh-pop\"\n#define NID_id_alg_dh_pop               326\n#define OBJ_id_alg_dh_pop               OBJ_id_alg,4L\n\n#define SN_id_cmc_statusInfo            \"id-cmc-statusInfo\"\n#define NID_id_cmc_statusInfo           327\n#define OBJ_id_cmc_statusInfo           OBJ_id_cmc,1L\n\n#define SN_id_cmc_identification                \"id-cmc-identification\"\n#define NID_id_cmc_identification               328\n#define OBJ_id_cmc_identification               OBJ_id_cmc,2L\n\n#define SN_id_cmc_identityProof         \"id-cmc-identityProof\"\n#define NID_id_cmc_identityProof                329\n#define OBJ_id_cmc_identityProof                OBJ_id_cmc,3L\n\n#define SN_id_cmc_dataReturn            \"id-cmc-dataReturn\"\n#define NID_id_cmc_dataReturn           330\n#define OBJ_id_cmc_dataReturn           OBJ_id_cmc,4L\n\n#define SN_id_cmc_transactionId         \"id-cmc-transactionId\"\n#define NID_id_cmc_transactionId                331\n#define OBJ_id_cmc_transactionId                OBJ_id_cmc,5L\n\n#define SN_id_cmc_senderNonce           \"id-cmc-senderNonce\"\n#define NID_id_cmc_senderNonce          332\n#define OBJ_id_cmc_senderNonce          OBJ_id_cmc,6L\n\n#define SN_id_cmc_recipientNonce                \"id-cmc-recipientNonce\"\n#define NID_id_cmc_recipientNonce               333\n#define OBJ_id_cmc_recipientNonce               OBJ_id_cmc,7L\n\n#define SN_id_cmc_addExtensions         \"id-cmc-addExtensions\"\n#define NID_id_cmc_addExtensions                334\n#define OBJ_id_cmc_addExtensions                OBJ_id_cmc,8L\n\n#define SN_id_cmc_encryptedPOP          \"id-cmc-encryptedPOP\"\n#define NID_id_cmc_encryptedPOP         335\n#define OBJ_id_cmc_encryptedPOP         OBJ_id_cmc,9L\n\n#define SN_id_cmc_decryptedPOP          \"id-cmc-decryptedPOP\"\n#define NID_id_cmc_decryptedPOP         336\n#define OBJ_id_cmc_decryptedPOP         OBJ_id_cmc,10L\n\n#define SN_id_cmc_lraPOPWitness         \"id-cmc-lraPOPWitness\"\n#define NID_id_cmc_lraPOPWitness                337\n#define OBJ_id_cmc_lraPOPWitness                OBJ_id_cmc,11L\n\n#define SN_id_cmc_getCert               \"id-cmc-getCert\"\n#define NID_id_cmc_getCert              338\n#define OBJ_id_cmc_getCert              OBJ_id_cmc,15L\n\n#define SN_id_cmc_getCRL                \"id-cmc-getCRL\"\n#define NID_id_cmc_getCRL               339\n#define OBJ_id_cmc_getCRL               OBJ_id_cmc,16L\n\n#define SN_id_cmc_revokeRequest         \"id-cmc-revokeRequest\"\n#define NID_id_cmc_revokeRequest                340\n#define OBJ_id_cmc_revokeRequest                OBJ_id_cmc,17L\n\n#define SN_id_cmc_regInfo               \"id-cmc-regInfo\"\n#define NID_id_cmc_regInfo              341\n#define OBJ_id_cmc_regInfo              OBJ_id_cmc,18L\n\n#define SN_id_cmc_responseInfo          \"id-cmc-responseInfo\"\n#define NID_id_cmc_responseInfo         342\n#define OBJ_id_cmc_responseInfo         OBJ_id_cmc,19L\n\n#define SN_id_cmc_queryPending          \"id-cmc-queryPending\"\n#define NID_id_cmc_queryPending         343\n#define OBJ_id_cmc_queryPending         OBJ_id_cmc,21L\n\n#define SN_id_cmc_popLinkRandom         \"id-cmc-popLinkRandom\"\n#define NID_id_cmc_popLinkRandom                344\n#define OBJ_id_cmc_popLinkRandom                OBJ_id_cmc,22L\n\n#define SN_id_cmc_popLinkWitness                \"id-cmc-popLinkWitness\"\n#define NID_id_cmc_popLinkWitness               345\n#define OBJ_id_cmc_popLinkWitness               OBJ_id_cmc,23L\n\n#define SN_id_cmc_confirmCertAcceptance         \"id-cmc-confirmCertAcceptance\"\n#define NID_id_cmc_confirmCertAcceptance                346\n#define OBJ_id_cmc_confirmCertAcceptance                OBJ_id_cmc,24L\n\n#define SN_id_on_personalData           \"id-on-personalData\"\n#define NID_id_on_personalData          347\n#define OBJ_id_on_personalData          OBJ_id_on,1L\n\n#define SN_id_on_permanentIdentifier            \"id-on-permanentIdentifier\"\n#define LN_id_on_permanentIdentifier            \"Permanent Identifier\"\n#define NID_id_on_permanentIdentifier           858\n#define OBJ_id_on_permanentIdentifier           OBJ_id_on,3L\n\n#define SN_id_pda_dateOfBirth           \"id-pda-dateOfBirth\"\n#define NID_id_pda_dateOfBirth          348\n#define OBJ_id_pda_dateOfBirth          OBJ_id_pda,1L\n\n#define SN_id_pda_placeOfBirth          \"id-pda-placeOfBirth\"\n#define NID_id_pda_placeOfBirth         349\n#define OBJ_id_pda_placeOfBirth         OBJ_id_pda,2L\n\n#define SN_id_pda_gender                \"id-pda-gender\"\n#define NID_id_pda_gender               351\n#define OBJ_id_pda_gender               OBJ_id_pda,3L\n\n#define SN_id_pda_countryOfCitizenship          \"id-pda-countryOfCitizenship\"\n#define NID_id_pda_countryOfCitizenship         352\n#define OBJ_id_pda_countryOfCitizenship         OBJ_id_pda,4L\n\n#define SN_id_pda_countryOfResidence            \"id-pda-countryOfResidence\"\n#define NID_id_pda_countryOfResidence           353\n#define OBJ_id_pda_countryOfResidence           OBJ_id_pda,5L\n\n#define SN_id_aca_authenticationInfo            \"id-aca-authenticationInfo\"\n#define NID_id_aca_authenticationInfo           354\n#define OBJ_id_aca_authenticationInfo           OBJ_id_aca,1L\n\n#define SN_id_aca_accessIdentity                \"id-aca-accessIdentity\"\n#define NID_id_aca_accessIdentity               355\n#define OBJ_id_aca_accessIdentity               OBJ_id_aca,2L\n\n#define SN_id_aca_chargingIdentity              \"id-aca-chargingIdentity\"\n#define NID_id_aca_chargingIdentity             356\n#define OBJ_id_aca_chargingIdentity             OBJ_id_aca,3L\n\n#define SN_id_aca_group         \"id-aca-group\"\n#define NID_id_aca_group                357\n#define OBJ_id_aca_group                OBJ_id_aca,4L\n\n#define SN_id_aca_role          \"id-aca-role\"\n#define NID_id_aca_role         358\n#define OBJ_id_aca_role         OBJ_id_aca,5L\n\n#define SN_id_aca_encAttrs              \"id-aca-encAttrs\"\n#define NID_id_aca_encAttrs             399\n#define OBJ_id_aca_encAttrs             OBJ_id_aca,6L\n\n#define SN_id_qcs_pkixQCSyntax_v1               \"id-qcs-pkixQCSyntax-v1\"\n#define NID_id_qcs_pkixQCSyntax_v1              359\n#define OBJ_id_qcs_pkixQCSyntax_v1              OBJ_id_qcs,1L\n\n#define SN_id_cct_crs           \"id-cct-crs\"\n#define NID_id_cct_crs          360\n#define OBJ_id_cct_crs          OBJ_id_cct,1L\n\n#define SN_id_cct_PKIData               \"id-cct-PKIData\"\n#define NID_id_cct_PKIData              361\n#define OBJ_id_cct_PKIData              OBJ_id_cct,2L\n\n#define SN_id_cct_PKIResponse           \"id-cct-PKIResponse\"\n#define NID_id_cct_PKIResponse          362\n#define OBJ_id_cct_PKIResponse          OBJ_id_cct,3L\n\n#define SN_id_ppl_anyLanguage           \"id-ppl-anyLanguage\"\n#define LN_id_ppl_anyLanguage           \"Any language\"\n#define NID_id_ppl_anyLanguage          664\n#define OBJ_id_ppl_anyLanguage          OBJ_id_ppl,0L\n\n#define SN_id_ppl_inheritAll            \"id-ppl-inheritAll\"\n#define LN_id_ppl_inheritAll            \"Inherit all\"\n#define NID_id_ppl_inheritAll           665\n#define OBJ_id_ppl_inheritAll           OBJ_id_ppl,1L\n\n#define SN_Independent          \"id-ppl-independent\"\n#define LN_Independent          \"Independent\"\n#define NID_Independent         667\n#define OBJ_Independent         OBJ_id_ppl,2L\n\n#define SN_ad_OCSP              \"OCSP\"\n#define LN_ad_OCSP              \"OCSP\"\n#define NID_ad_OCSP             178\n#define OBJ_ad_OCSP             OBJ_id_ad,1L\n\n#define SN_ad_ca_issuers                \"caIssuers\"\n#define LN_ad_ca_issuers                \"CA Issuers\"\n#define NID_ad_ca_issuers               179\n#define OBJ_ad_ca_issuers               OBJ_id_ad,2L\n\n#define SN_ad_timeStamping              \"ad_timestamping\"\n#define LN_ad_timeStamping              \"AD Time Stamping\"\n#define NID_ad_timeStamping             363\n#define OBJ_ad_timeStamping             OBJ_id_ad,3L\n\n#define SN_ad_dvcs              \"AD_DVCS\"\n#define LN_ad_dvcs              \"ad dvcs\"\n#define NID_ad_dvcs             364\n#define OBJ_ad_dvcs             OBJ_id_ad,4L\n\n#define SN_caRepository         \"caRepository\"\n#define LN_caRepository         \"CA Repository\"\n#define NID_caRepository                785\n#define OBJ_caRepository                OBJ_id_ad,5L\n\n#define OBJ_id_pkix_OCSP                OBJ_ad_OCSP\n\n#define SN_id_pkix_OCSP_basic           \"basicOCSPResponse\"\n#define LN_id_pkix_OCSP_basic           \"Basic OCSP Response\"\n#define NID_id_pkix_OCSP_basic          365\n#define OBJ_id_pkix_OCSP_basic          OBJ_id_pkix_OCSP,1L\n\n#define SN_id_pkix_OCSP_Nonce           \"Nonce\"\n#define LN_id_pkix_OCSP_Nonce           \"OCSP Nonce\"\n#define NID_id_pkix_OCSP_Nonce          366\n#define OBJ_id_pkix_OCSP_Nonce          OBJ_id_pkix_OCSP,2L\n\n#define SN_id_pkix_OCSP_CrlID           \"CrlID\"\n#define LN_id_pkix_OCSP_CrlID           \"OCSP CRL ID\"\n#define NID_id_pkix_OCSP_CrlID          367\n#define OBJ_id_pkix_OCSP_CrlID          OBJ_id_pkix_OCSP,3L\n\n#define SN_id_pkix_OCSP_acceptableResponses             \"acceptableResponses\"\n#define LN_id_pkix_OCSP_acceptableResponses             \"Acceptable OCSP Responses\"\n#define NID_id_pkix_OCSP_acceptableResponses            368\n#define OBJ_id_pkix_OCSP_acceptableResponses            OBJ_id_pkix_OCSP,4L\n\n#define SN_id_pkix_OCSP_noCheck         \"noCheck\"\n#define LN_id_pkix_OCSP_noCheck         \"OCSP No Check\"\n#define NID_id_pkix_OCSP_noCheck                369\n#define OBJ_id_pkix_OCSP_noCheck                OBJ_id_pkix_OCSP,5L\n\n#define SN_id_pkix_OCSP_archiveCutoff           \"archiveCutoff\"\n#define LN_id_pkix_OCSP_archiveCutoff           \"OCSP Archive Cutoff\"\n#define NID_id_pkix_OCSP_archiveCutoff          370\n#define OBJ_id_pkix_OCSP_archiveCutoff          OBJ_id_pkix_OCSP,6L\n\n#define SN_id_pkix_OCSP_serviceLocator          \"serviceLocator\"\n#define LN_id_pkix_OCSP_serviceLocator          \"OCSP Service Locator\"\n#define NID_id_pkix_OCSP_serviceLocator         371\n#define OBJ_id_pkix_OCSP_serviceLocator         OBJ_id_pkix_OCSP,7L\n\n#define SN_id_pkix_OCSP_extendedStatus          \"extendedStatus\"\n#define LN_id_pkix_OCSP_extendedStatus          \"Extended OCSP Status\"\n#define NID_id_pkix_OCSP_extendedStatus         372\n#define OBJ_id_pkix_OCSP_extendedStatus         OBJ_id_pkix_OCSP,8L\n\n#define SN_id_pkix_OCSP_valid           \"valid\"\n#define NID_id_pkix_OCSP_valid          373\n#define OBJ_id_pkix_OCSP_valid          OBJ_id_pkix_OCSP,9L\n\n#define SN_id_pkix_OCSP_path            \"path\"\n#define NID_id_pkix_OCSP_path           374\n#define OBJ_id_pkix_OCSP_path           OBJ_id_pkix_OCSP,10L\n\n#define SN_id_pkix_OCSP_trustRoot               \"trustRoot\"\n#define LN_id_pkix_OCSP_trustRoot               \"Trust Root\"\n#define NID_id_pkix_OCSP_trustRoot              375\n#define OBJ_id_pkix_OCSP_trustRoot              OBJ_id_pkix_OCSP,11L\n\n#define SN_algorithm            \"algorithm\"\n#define LN_algorithm            \"algorithm\"\n#define NID_algorithm           376\n#define OBJ_algorithm           1L,3L,14L,3L,2L\n\n#define SN_md5WithRSA           \"RSA-NP-MD5\"\n#define LN_md5WithRSA           \"md5WithRSA\"\n#define NID_md5WithRSA          104\n#define OBJ_md5WithRSA          OBJ_algorithm,3L\n\n#define SN_des_ecb              \"DES-ECB\"\n#define LN_des_ecb              \"des-ecb\"\n#define NID_des_ecb             29\n#define OBJ_des_ecb             OBJ_algorithm,6L\n\n#define SN_des_cbc              \"DES-CBC\"\n#define LN_des_cbc              \"des-cbc\"\n#define NID_des_cbc             31\n#define OBJ_des_cbc             OBJ_algorithm,7L\n\n#define SN_des_ofb64            \"DES-OFB\"\n#define LN_des_ofb64            \"des-ofb\"\n#define NID_des_ofb64           45\n#define OBJ_des_ofb64           OBJ_algorithm,8L\n\n#define SN_des_cfb64            \"DES-CFB\"\n#define LN_des_cfb64            \"des-cfb\"\n#define NID_des_cfb64           30\n#define OBJ_des_cfb64           OBJ_algorithm,9L\n\n#define SN_rsaSignature         \"rsaSignature\"\n#define NID_rsaSignature                377\n#define OBJ_rsaSignature                OBJ_algorithm,11L\n\n#define SN_dsa_2                \"DSA-old\"\n#define LN_dsa_2                \"dsaEncryption-old\"\n#define NID_dsa_2               67\n#define OBJ_dsa_2               OBJ_algorithm,12L\n\n#define SN_dsaWithSHA           \"DSA-SHA\"\n#define LN_dsaWithSHA           \"dsaWithSHA\"\n#define NID_dsaWithSHA          66\n#define OBJ_dsaWithSHA          OBJ_algorithm,13L\n\n#define SN_shaWithRSAEncryption         \"RSA-SHA\"\n#define LN_shaWithRSAEncryption         \"shaWithRSAEncryption\"\n#define NID_shaWithRSAEncryption                42\n#define OBJ_shaWithRSAEncryption                OBJ_algorithm,15L\n\n#define SN_des_ede_ecb          \"DES-EDE\"\n#define LN_des_ede_ecb          \"des-ede\"\n#define NID_des_ede_ecb         32\n#define OBJ_des_ede_ecb         OBJ_algorithm,17L\n\n#define SN_des_ede3_ecb         \"DES-EDE3\"\n#define LN_des_ede3_ecb         \"des-ede3\"\n#define NID_des_ede3_ecb                33\n\n#define SN_des_ede_cbc          \"DES-EDE-CBC\"\n#define LN_des_ede_cbc          \"des-ede-cbc\"\n#define NID_des_ede_cbc         43\n\n#define SN_des_ede_cfb64                \"DES-EDE-CFB\"\n#define LN_des_ede_cfb64                \"des-ede-cfb\"\n#define NID_des_ede_cfb64               60\n\n#define SN_des_ede3_cfb64               \"DES-EDE3-CFB\"\n#define LN_des_ede3_cfb64               \"des-ede3-cfb\"\n#define NID_des_ede3_cfb64              61\n\n#define SN_des_ede_ofb64                \"DES-EDE-OFB\"\n#define LN_des_ede_ofb64                \"des-ede-ofb\"\n#define NID_des_ede_ofb64               62\n\n#define SN_des_ede3_ofb64               \"DES-EDE3-OFB\"\n#define LN_des_ede3_ofb64               \"des-ede3-ofb\"\n#define NID_des_ede3_ofb64              63\n\n#define SN_desx_cbc             \"DESX-CBC\"\n#define LN_desx_cbc             \"desx-cbc\"\n#define NID_desx_cbc            80\n\n#define SN_sha          \"SHA\"\n#define LN_sha          \"sha\"\n#define NID_sha         41\n#define OBJ_sha         OBJ_algorithm,18L\n\n#define SN_sha1         \"SHA1\"\n#define LN_sha1         \"sha1\"\n#define NID_sha1                64\n#define OBJ_sha1                OBJ_algorithm,26L\n\n#define SN_dsaWithSHA1_2                \"DSA-SHA1-old\"\n#define LN_dsaWithSHA1_2                \"dsaWithSHA1-old\"\n#define NID_dsaWithSHA1_2               70\n#define OBJ_dsaWithSHA1_2               OBJ_algorithm,27L\n\n#define SN_sha1WithRSA          \"RSA-SHA1-2\"\n#define LN_sha1WithRSA          \"sha1WithRSA\"\n#define NID_sha1WithRSA         115\n#define OBJ_sha1WithRSA         OBJ_algorithm,29L\n\n#define SN_ripemd160            \"RIPEMD160\"\n#define LN_ripemd160            \"ripemd160\"\n#define NID_ripemd160           117\n#define OBJ_ripemd160           1L,3L,36L,3L,2L,1L\n\n#define SN_ripemd160WithRSA             \"RSA-RIPEMD160\"\n#define LN_ripemd160WithRSA             \"ripemd160WithRSA\"\n#define NID_ripemd160WithRSA            119\n#define OBJ_ripemd160WithRSA            1L,3L,36L,3L,3L,1L,2L\n\n#define SN_sxnet                \"SXNetID\"\n#define LN_sxnet                \"Strong Extranet ID\"\n#define NID_sxnet               143\n#define OBJ_sxnet               1L,3L,101L,1L,4L,1L\n\n#define SN_X500         \"X500\"\n#define LN_X500         \"directory services (X.500)\"\n#define NID_X500                11\n#define OBJ_X500                2L,5L\n\n#define SN_X509         \"X509\"\n#define NID_X509                12\n#define OBJ_X509                OBJ_X500,4L\n\n#define SN_commonName           \"CN\"\n#define LN_commonName           \"commonName\"\n#define NID_commonName          13\n#define OBJ_commonName          OBJ_X509,3L\n\n#define SN_surname              \"SN\"\n#define LN_surname              \"surname\"\n#define NID_surname             100\n#define OBJ_surname             OBJ_X509,4L\n\n#define LN_serialNumber         \"serialNumber\"\n#define NID_serialNumber                105\n#define OBJ_serialNumber                OBJ_X509,5L\n\n#define SN_countryName          \"C\"\n#define LN_countryName          \"countryName\"\n#define NID_countryName         14\n#define OBJ_countryName         OBJ_X509,6L\n\n#define SN_localityName         \"L\"\n#define LN_localityName         \"localityName\"\n#define NID_localityName                15\n#define OBJ_localityName                OBJ_X509,7L\n\n#define SN_stateOrProvinceName          \"ST\"\n#define LN_stateOrProvinceName          \"stateOrProvinceName\"\n#define NID_stateOrProvinceName         16\n#define OBJ_stateOrProvinceName         OBJ_X509,8L\n\n#define SN_streetAddress                \"street\"\n#define LN_streetAddress                \"streetAddress\"\n#define NID_streetAddress               660\n#define OBJ_streetAddress               OBJ_X509,9L\n\n#define SN_organizationName             \"O\"\n#define LN_organizationName             \"organizationName\"\n#define NID_organizationName            17\n#define OBJ_organizationName            OBJ_X509,10L\n\n#define SN_organizationalUnitName               \"OU\"\n#define LN_organizationalUnitName               \"organizationalUnitName\"\n#define NID_organizationalUnitName              18\n#define OBJ_organizationalUnitName              OBJ_X509,11L\n\n#define SN_title                \"title\"\n#define LN_title                \"title\"\n#define NID_title               106\n#define OBJ_title               OBJ_X509,12L\n\n#define LN_description          \"description\"\n#define NID_description         107\n#define OBJ_description         OBJ_X509,13L\n\n#define LN_searchGuide          \"searchGuide\"\n#define NID_searchGuide         859\n#define OBJ_searchGuide         OBJ_X509,14L\n\n#define LN_businessCategory             \"businessCategory\"\n#define NID_businessCategory            860\n#define OBJ_businessCategory            OBJ_X509,15L\n\n#define LN_postalAddress                \"postalAddress\"\n#define NID_postalAddress               861\n#define OBJ_postalAddress               OBJ_X509,16L\n\n#define LN_postalCode           \"postalCode\"\n#define NID_postalCode          661\n#define OBJ_postalCode          OBJ_X509,17L\n\n#define LN_postOfficeBox                \"postOfficeBox\"\n#define NID_postOfficeBox               862\n#define OBJ_postOfficeBox               OBJ_X509,18L\n\n#define LN_physicalDeliveryOfficeName           \"physicalDeliveryOfficeName\"\n#define NID_physicalDeliveryOfficeName          863\n#define OBJ_physicalDeliveryOfficeName          OBJ_X509,19L\n\n#define LN_telephoneNumber              \"telephoneNumber\"\n#define NID_telephoneNumber             864\n#define OBJ_telephoneNumber             OBJ_X509,20L\n\n#define LN_telexNumber          \"telexNumber\"\n#define NID_telexNumber         865\n#define OBJ_telexNumber         OBJ_X509,21L\n\n#define LN_teletexTerminalIdentifier            \"teletexTerminalIdentifier\"\n#define NID_teletexTerminalIdentifier           866\n#define OBJ_teletexTerminalIdentifier           OBJ_X509,22L\n\n#define LN_facsimileTelephoneNumber             \"facsimileTelephoneNumber\"\n#define NID_facsimileTelephoneNumber            867\n#define OBJ_facsimileTelephoneNumber            OBJ_X509,23L\n\n#define LN_x121Address          \"x121Address\"\n#define NID_x121Address         868\n#define OBJ_x121Address         OBJ_X509,24L\n\n#define LN_internationaliSDNNumber              \"internationaliSDNNumber\"\n#define NID_internationaliSDNNumber             869\n#define OBJ_internationaliSDNNumber             OBJ_X509,25L\n\n#define LN_registeredAddress            \"registeredAddress\"\n#define NID_registeredAddress           870\n#define OBJ_registeredAddress           OBJ_X509,26L\n\n#define LN_destinationIndicator         \"destinationIndicator\"\n#define NID_destinationIndicator                871\n#define OBJ_destinationIndicator                OBJ_X509,27L\n\n#define LN_preferredDeliveryMethod              \"preferredDeliveryMethod\"\n#define NID_preferredDeliveryMethod             872\n#define OBJ_preferredDeliveryMethod             OBJ_X509,28L\n\n#define LN_presentationAddress          \"presentationAddress\"\n#define NID_presentationAddress         873\n#define OBJ_presentationAddress         OBJ_X509,29L\n\n#define LN_supportedApplicationContext          \"supportedApplicationContext\"\n#define NID_supportedApplicationContext         874\n#define OBJ_supportedApplicationContext         OBJ_X509,30L\n\n#define SN_member               \"member\"\n#define NID_member              875\n#define OBJ_member              OBJ_X509,31L\n\n#define SN_owner                \"owner\"\n#define NID_owner               876\n#define OBJ_owner               OBJ_X509,32L\n\n#define LN_roleOccupant         \"roleOccupant\"\n#define NID_roleOccupant                877\n#define OBJ_roleOccupant                OBJ_X509,33L\n\n#define SN_seeAlso              \"seeAlso\"\n#define NID_seeAlso             878\n#define OBJ_seeAlso             OBJ_X509,34L\n\n#define LN_userPassword         \"userPassword\"\n#define NID_userPassword                879\n#define OBJ_userPassword                OBJ_X509,35L\n\n#define LN_userCertificate              \"userCertificate\"\n#define NID_userCertificate             880\n#define OBJ_userCertificate             OBJ_X509,36L\n\n#define LN_cACertificate                \"cACertificate\"\n#define NID_cACertificate               881\n#define OBJ_cACertificate               OBJ_X509,37L\n\n#define LN_authorityRevocationList              \"authorityRevocationList\"\n#define NID_authorityRevocationList             882\n#define OBJ_authorityRevocationList             OBJ_X509,38L\n\n#define LN_certificateRevocationList            \"certificateRevocationList\"\n#define NID_certificateRevocationList           883\n#define OBJ_certificateRevocationList           OBJ_X509,39L\n\n#define LN_crossCertificatePair         \"crossCertificatePair\"\n#define NID_crossCertificatePair                884\n#define OBJ_crossCertificatePair                OBJ_X509,40L\n\n#define SN_name         \"name\"\n#define LN_name         \"name\"\n#define NID_name                173\n#define OBJ_name                OBJ_X509,41L\n\n#define SN_givenName            \"GN\"\n#define LN_givenName            \"givenName\"\n#define NID_givenName           99\n#define OBJ_givenName           OBJ_X509,42L\n\n#define SN_initials             \"initials\"\n#define LN_initials             \"initials\"\n#define NID_initials            101\n#define OBJ_initials            OBJ_X509,43L\n\n#define LN_generationQualifier          \"generationQualifier\"\n#define NID_generationQualifier         509\n#define OBJ_generationQualifier         OBJ_X509,44L\n\n#define LN_x500UniqueIdentifier         \"x500UniqueIdentifier\"\n#define NID_x500UniqueIdentifier                503\n#define OBJ_x500UniqueIdentifier                OBJ_X509,45L\n\n#define SN_dnQualifier          \"dnQualifier\"\n#define LN_dnQualifier          \"dnQualifier\"\n#define NID_dnQualifier         174\n#define OBJ_dnQualifier         OBJ_X509,46L\n\n#define LN_enhancedSearchGuide          \"enhancedSearchGuide\"\n#define NID_enhancedSearchGuide         885\n#define OBJ_enhancedSearchGuide         OBJ_X509,47L\n\n#define LN_protocolInformation          \"protocolInformation\"\n#define NID_protocolInformation         886\n#define OBJ_protocolInformation         OBJ_X509,48L\n\n#define LN_distinguishedName            \"distinguishedName\"\n#define NID_distinguishedName           887\n#define OBJ_distinguishedName           OBJ_X509,49L\n\n#define LN_uniqueMember         \"uniqueMember\"\n#define NID_uniqueMember                888\n#define OBJ_uniqueMember                OBJ_X509,50L\n\n#define LN_houseIdentifier              \"houseIdentifier\"\n#define NID_houseIdentifier             889\n#define OBJ_houseIdentifier             OBJ_X509,51L\n\n#define LN_supportedAlgorithms          \"supportedAlgorithms\"\n#define NID_supportedAlgorithms         890\n#define OBJ_supportedAlgorithms         OBJ_X509,52L\n\n#define LN_deltaRevocationList          \"deltaRevocationList\"\n#define NID_deltaRevocationList         891\n#define OBJ_deltaRevocationList         OBJ_X509,53L\n\n#define SN_dmdName              \"dmdName\"\n#define NID_dmdName             892\n#define OBJ_dmdName             OBJ_X509,54L\n\n#define LN_pseudonym            \"pseudonym\"\n#define NID_pseudonym           510\n#define OBJ_pseudonym           OBJ_X509,65L\n\n#define SN_role         \"role\"\n#define LN_role         \"role\"\n#define NID_role                400\n#define OBJ_role                OBJ_X509,72L\n\n#define SN_X500algorithms               \"X500algorithms\"\n#define LN_X500algorithms               \"directory services - algorithms\"\n#define NID_X500algorithms              378\n#define OBJ_X500algorithms              OBJ_X500,8L\n\n#define SN_rsa          \"RSA\"\n#define LN_rsa          \"rsa\"\n#define NID_rsa         19\n#define OBJ_rsa         OBJ_X500algorithms,1L,1L\n\n#define SN_mdc2WithRSA          \"RSA-MDC2\"\n#define LN_mdc2WithRSA          \"mdc2WithRSA\"\n#define NID_mdc2WithRSA         96\n#define OBJ_mdc2WithRSA         OBJ_X500algorithms,3L,100L\n\n#define SN_mdc2         \"MDC2\"\n#define LN_mdc2         \"mdc2\"\n#define NID_mdc2                95\n#define OBJ_mdc2                OBJ_X500algorithms,3L,101L\n\n#define SN_id_ce                \"id-ce\"\n#define NID_id_ce               81\n#define OBJ_id_ce               OBJ_X500,29L\n\n#define SN_subject_directory_attributes         \"subjectDirectoryAttributes\"\n#define LN_subject_directory_attributes         \"X509v3 Subject Directory Attributes\"\n#define NID_subject_directory_attributes                769\n#define OBJ_subject_directory_attributes                OBJ_id_ce,9L\n\n#define SN_subject_key_identifier               \"subjectKeyIdentifier\"\n#define LN_subject_key_identifier               \"X509v3 Subject Key Identifier\"\n#define NID_subject_key_identifier              82\n#define OBJ_subject_key_identifier              OBJ_id_ce,14L\n\n#define SN_key_usage            \"keyUsage\"\n#define LN_key_usage            \"X509v3 Key Usage\"\n#define NID_key_usage           83\n#define OBJ_key_usage           OBJ_id_ce,15L\n\n#define SN_private_key_usage_period             \"privateKeyUsagePeriod\"\n#define LN_private_key_usage_period             \"X509v3 Private Key Usage Period\"\n#define NID_private_key_usage_period            84\n#define OBJ_private_key_usage_period            OBJ_id_ce,16L\n\n#define SN_subject_alt_name             \"subjectAltName\"\n#define LN_subject_alt_name             \"X509v3 Subject Alternative Name\"\n#define NID_subject_alt_name            85\n#define OBJ_subject_alt_name            OBJ_id_ce,17L\n\n#define SN_issuer_alt_name              \"issuerAltName\"\n#define LN_issuer_alt_name              \"X509v3 Issuer Alternative Name\"\n#define NID_issuer_alt_name             86\n#define OBJ_issuer_alt_name             OBJ_id_ce,18L\n\n#define SN_basic_constraints            \"basicConstraints\"\n#define LN_basic_constraints            \"X509v3 Basic Constraints\"\n#define NID_basic_constraints           87\n#define OBJ_basic_constraints           OBJ_id_ce,19L\n\n#define SN_crl_number           \"crlNumber\"\n#define LN_crl_number           \"X509v3 CRL Number\"\n#define NID_crl_number          88\n#define OBJ_crl_number          OBJ_id_ce,20L\n\n#define SN_crl_reason           \"CRLReason\"\n#define LN_crl_reason           \"X509v3 CRL Reason Code\"\n#define NID_crl_reason          141\n#define OBJ_crl_reason          OBJ_id_ce,21L\n\n#define SN_invalidity_date              \"invalidityDate\"\n#define LN_invalidity_date              \"Invalidity Date\"\n#define NID_invalidity_date             142\n#define OBJ_invalidity_date             OBJ_id_ce,24L\n\n#define SN_delta_crl            \"deltaCRL\"\n#define LN_delta_crl            \"X509v3 Delta CRL Indicator\"\n#define NID_delta_crl           140\n#define OBJ_delta_crl           OBJ_id_ce,27L\n\n#define SN_issuing_distribution_point           \"issuingDistributionPoint\"\n#define LN_issuing_distribution_point           \"X509v3 Issuing Distrubution Point\"\n#define NID_issuing_distribution_point          770\n#define OBJ_issuing_distribution_point          OBJ_id_ce,28L\n\n#define SN_certificate_issuer           \"certificateIssuer\"\n#define LN_certificate_issuer           \"X509v3 Certificate Issuer\"\n#define NID_certificate_issuer          771\n#define OBJ_certificate_issuer          OBJ_id_ce,29L\n\n#define SN_name_constraints             \"nameConstraints\"\n#define LN_name_constraints             \"X509v3 Name Constraints\"\n#define NID_name_constraints            666\n#define OBJ_name_constraints            OBJ_id_ce,30L\n\n#define SN_crl_distribution_points              \"crlDistributionPoints\"\n#define LN_crl_distribution_points              \"X509v3 CRL Distribution Points\"\n#define NID_crl_distribution_points             103\n#define OBJ_crl_distribution_points             OBJ_id_ce,31L\n\n#define SN_certificate_policies         \"certificatePolicies\"\n#define LN_certificate_policies         \"X509v3 Certificate Policies\"\n#define NID_certificate_policies                89\n#define OBJ_certificate_policies                OBJ_id_ce,32L\n\n#define SN_any_policy           \"anyPolicy\"\n#define LN_any_policy           \"X509v3 Any Policy\"\n#define NID_any_policy          746\n#define OBJ_any_policy          OBJ_certificate_policies,0L\n\n#define SN_policy_mappings              \"policyMappings\"\n#define LN_policy_mappings              \"X509v3 Policy Mappings\"\n#define NID_policy_mappings             747\n#define OBJ_policy_mappings             OBJ_id_ce,33L\n\n#define SN_authority_key_identifier             \"authorityKeyIdentifier\"\n#define LN_authority_key_identifier             \"X509v3 Authority Key Identifier\"\n#define NID_authority_key_identifier            90\n#define OBJ_authority_key_identifier            OBJ_id_ce,35L\n\n#define SN_policy_constraints           \"policyConstraints\"\n#define LN_policy_constraints           \"X509v3 Policy Constraints\"\n#define NID_policy_constraints          401\n#define OBJ_policy_constraints          OBJ_id_ce,36L\n\n#define SN_ext_key_usage                \"extendedKeyUsage\"\n#define LN_ext_key_usage                \"X509v3 Extended Key Usage\"\n#define NID_ext_key_usage               126\n#define OBJ_ext_key_usage               OBJ_id_ce,37L\n\n#define SN_freshest_crl         \"freshestCRL\"\n#define LN_freshest_crl         \"X509v3 Freshest CRL\"\n#define NID_freshest_crl                857\n#define OBJ_freshest_crl                OBJ_id_ce,46L\n\n#define SN_inhibit_any_policy           \"inhibitAnyPolicy\"\n#define LN_inhibit_any_policy           \"X509v3 Inhibit Any Policy\"\n#define NID_inhibit_any_policy          748\n#define OBJ_inhibit_any_policy          OBJ_id_ce,54L\n\n#define SN_target_information           \"targetInformation\"\n#define LN_target_information           \"X509v3 AC Targeting\"\n#define NID_target_information          402\n#define OBJ_target_information          OBJ_id_ce,55L\n\n#define SN_no_rev_avail         \"noRevAvail\"\n#define LN_no_rev_avail         \"X509v3 No Revocation Available\"\n#define NID_no_rev_avail                403\n#define OBJ_no_rev_avail                OBJ_id_ce,56L\n\n#define SN_anyExtendedKeyUsage          \"anyExtendedKeyUsage\"\n#define LN_anyExtendedKeyUsage          \"Any Extended Key Usage\"\n#define NID_anyExtendedKeyUsage         910\n#define OBJ_anyExtendedKeyUsage         OBJ_ext_key_usage,0L\n\n#define SN_netscape             \"Netscape\"\n#define LN_netscape             \"Netscape Communications Corp.\"\n#define NID_netscape            57\n#define OBJ_netscape            2L,16L,840L,1L,113730L\n\n#define SN_netscape_cert_extension              \"nsCertExt\"\n#define LN_netscape_cert_extension              \"Netscape Certificate Extension\"\n#define NID_netscape_cert_extension             58\n#define OBJ_netscape_cert_extension             OBJ_netscape,1L\n\n#define SN_netscape_data_type           \"nsDataType\"\n#define LN_netscape_data_type           \"Netscape Data Type\"\n#define NID_netscape_data_type          59\n#define OBJ_netscape_data_type          OBJ_netscape,2L\n\n#define SN_netscape_cert_type           \"nsCertType\"\n#define LN_netscape_cert_type           \"Netscape Cert Type\"\n#define NID_netscape_cert_type          71\n#define OBJ_netscape_cert_type          OBJ_netscape_cert_extension,1L\n\n#define SN_netscape_base_url            \"nsBaseUrl\"\n#define LN_netscape_base_url            \"Netscape Base Url\"\n#define NID_netscape_base_url           72\n#define OBJ_netscape_base_url           OBJ_netscape_cert_extension,2L\n\n#define SN_netscape_revocation_url              \"nsRevocationUrl\"\n#define LN_netscape_revocation_url              \"Netscape Revocation Url\"\n#define NID_netscape_revocation_url             73\n#define OBJ_netscape_revocation_url             OBJ_netscape_cert_extension,3L\n\n#define SN_netscape_ca_revocation_url           \"nsCaRevocationUrl\"\n#define LN_netscape_ca_revocation_url           \"Netscape CA Revocation Url\"\n#define NID_netscape_ca_revocation_url          74\n#define OBJ_netscape_ca_revocation_url          OBJ_netscape_cert_extension,4L\n\n#define SN_netscape_renewal_url         \"nsRenewalUrl\"\n#define LN_netscape_renewal_url         \"Netscape Renewal Url\"\n#define NID_netscape_renewal_url                75\n#define OBJ_netscape_renewal_url                OBJ_netscape_cert_extension,7L\n\n#define SN_netscape_ca_policy_url               \"nsCaPolicyUrl\"\n#define LN_netscape_ca_policy_url               \"Netscape CA Policy Url\"\n#define NID_netscape_ca_policy_url              76\n#define OBJ_netscape_ca_policy_url              OBJ_netscape_cert_extension,8L\n\n#define SN_netscape_ssl_server_name             \"nsSslServerName\"\n#define LN_netscape_ssl_server_name             \"Netscape SSL Server Name\"\n#define NID_netscape_ssl_server_name            77\n#define OBJ_netscape_ssl_server_name            OBJ_netscape_cert_extension,12L\n\n#define SN_netscape_comment             \"nsComment\"\n#define LN_netscape_comment             \"Netscape Comment\"\n#define NID_netscape_comment            78\n#define OBJ_netscape_comment            OBJ_netscape_cert_extension,13L\n\n#define SN_netscape_cert_sequence               \"nsCertSequence\"\n#define LN_netscape_cert_sequence               \"Netscape Certificate Sequence\"\n#define NID_netscape_cert_sequence              79\n#define OBJ_netscape_cert_sequence              OBJ_netscape_data_type,5L\n\n#define SN_ns_sgc               \"nsSGC\"\n#define LN_ns_sgc               \"Netscape Server Gated Crypto\"\n#define NID_ns_sgc              139\n#define OBJ_ns_sgc              OBJ_netscape,4L,1L\n\n#define SN_org          \"ORG\"\n#define LN_org          \"org\"\n#define NID_org         379\n#define OBJ_org         OBJ_iso,3L\n\n#define SN_dod          \"DOD\"\n#define LN_dod          \"dod\"\n#define NID_dod         380\n#define OBJ_dod         OBJ_org,6L\n\n#define SN_iana         \"IANA\"\n#define LN_iana         \"iana\"\n#define NID_iana                381\n#define OBJ_iana                OBJ_dod,1L\n\n#define OBJ_internet            OBJ_iana\n\n#define SN_Directory            \"directory\"\n#define LN_Directory            \"Directory\"\n#define NID_Directory           382\n#define OBJ_Directory           OBJ_internet,1L\n\n#define SN_Management           \"mgmt\"\n#define LN_Management           \"Management\"\n#define NID_Management          383\n#define OBJ_Management          OBJ_internet,2L\n\n#define SN_Experimental         \"experimental\"\n#define LN_Experimental         \"Experimental\"\n#define NID_Experimental                384\n#define OBJ_Experimental                OBJ_internet,3L\n\n#define SN_Private              \"private\"\n#define LN_Private              \"Private\"\n#define NID_Private             385\n#define OBJ_Private             OBJ_internet,4L\n\n#define SN_Security             \"security\"\n#define LN_Security             \"Security\"\n#define NID_Security            386\n#define OBJ_Security            OBJ_internet,5L\n\n#define SN_SNMPv2               \"snmpv2\"\n#define LN_SNMPv2               \"SNMPv2\"\n#define NID_SNMPv2              387\n#define OBJ_SNMPv2              OBJ_internet,6L\n\n#define LN_Mail         \"Mail\"\n#define NID_Mail                388\n#define OBJ_Mail                OBJ_internet,7L\n\n#define SN_Enterprises          \"enterprises\"\n#define LN_Enterprises          \"Enterprises\"\n#define NID_Enterprises         389\n#define OBJ_Enterprises         OBJ_Private,1L\n\n#define SN_dcObject             \"dcobject\"\n#define LN_dcObject             \"dcObject\"\n#define NID_dcObject            390\n#define OBJ_dcObject            OBJ_Enterprises,1466L,344L\n\n#define SN_mime_mhs             \"mime-mhs\"\n#define LN_mime_mhs             \"MIME MHS\"\n#define NID_mime_mhs            504\n#define OBJ_mime_mhs            OBJ_Mail,1L\n\n#define SN_mime_mhs_headings            \"mime-mhs-headings\"\n#define LN_mime_mhs_headings            \"mime-mhs-headings\"\n#define NID_mime_mhs_headings           505\n#define OBJ_mime_mhs_headings           OBJ_mime_mhs,1L\n\n#define SN_mime_mhs_bodies              \"mime-mhs-bodies\"\n#define LN_mime_mhs_bodies              \"mime-mhs-bodies\"\n#define NID_mime_mhs_bodies             506\n#define OBJ_mime_mhs_bodies             OBJ_mime_mhs,2L\n\n#define SN_id_hex_partial_message               \"id-hex-partial-message\"\n#define LN_id_hex_partial_message               \"id-hex-partial-message\"\n#define NID_id_hex_partial_message              507\n#define OBJ_id_hex_partial_message              OBJ_mime_mhs_headings,1L\n\n#define SN_id_hex_multipart_message             \"id-hex-multipart-message\"\n#define LN_id_hex_multipart_message             \"id-hex-multipart-message\"\n#define NID_id_hex_multipart_message            508\n#define OBJ_id_hex_multipart_message            OBJ_mime_mhs_headings,2L\n\n#define SN_rle_compression              \"RLE\"\n#define LN_rle_compression              \"run length compression\"\n#define NID_rle_compression             124\n#define OBJ_rle_compression             1L,1L,1L,1L,666L,1L\n\n#define SN_zlib_compression             \"ZLIB\"\n#define LN_zlib_compression             \"zlib compression\"\n#define NID_zlib_compression            125\n#define OBJ_zlib_compression            OBJ_id_smime_alg,8L\n\n#define OBJ_csor                2L,16L,840L,1L,101L,3L\n\n#define OBJ_nistAlgorithms              OBJ_csor,4L\n\n#define OBJ_aes         OBJ_nistAlgorithms,1L\n\n#define SN_aes_128_ecb          \"AES-128-ECB\"\n#define LN_aes_128_ecb          \"aes-128-ecb\"\n#define NID_aes_128_ecb         418\n#define OBJ_aes_128_ecb         OBJ_aes,1L\n\n#define SN_aes_128_cbc          \"AES-128-CBC\"\n#define LN_aes_128_cbc          \"aes-128-cbc\"\n#define NID_aes_128_cbc         419\n#define OBJ_aes_128_cbc         OBJ_aes,2L\n\n#define SN_aes_128_ofb128               \"AES-128-OFB\"\n#define LN_aes_128_ofb128               \"aes-128-ofb\"\n#define NID_aes_128_ofb128              420\n#define OBJ_aes_128_ofb128              OBJ_aes,3L\n\n#define SN_aes_128_cfb128               \"AES-128-CFB\"\n#define LN_aes_128_cfb128               \"aes-128-cfb\"\n#define NID_aes_128_cfb128              421\n#define OBJ_aes_128_cfb128              OBJ_aes,4L\n\n#define SN_id_aes128_wrap               \"id-aes128-wrap\"\n#define NID_id_aes128_wrap              788\n#define OBJ_id_aes128_wrap              OBJ_aes,5L\n\n#define SN_aes_128_gcm          \"id-aes128-GCM\"\n#define LN_aes_128_gcm          \"aes-128-gcm\"\n#define NID_aes_128_gcm         895\n#define OBJ_aes_128_gcm         OBJ_aes,6L\n\n#define SN_aes_128_ccm          \"id-aes128-CCM\"\n#define LN_aes_128_ccm          \"aes-128-ccm\"\n#define NID_aes_128_ccm         896\n#define OBJ_aes_128_ccm         OBJ_aes,7L\n\n#define SN_id_aes128_wrap_pad           \"id-aes128-wrap-pad\"\n#define NID_id_aes128_wrap_pad          897\n#define OBJ_id_aes128_wrap_pad          OBJ_aes,8L\n\n#define SN_aes_192_ecb          \"AES-192-ECB\"\n#define LN_aes_192_ecb          \"aes-192-ecb\"\n#define NID_aes_192_ecb         422\n#define OBJ_aes_192_ecb         OBJ_aes,21L\n\n#define SN_aes_192_cbc          \"AES-192-CBC\"\n#define LN_aes_192_cbc          \"aes-192-cbc\"\n#define NID_aes_192_cbc         423\n#define OBJ_aes_192_cbc         OBJ_aes,22L\n\n#define SN_aes_192_ofb128               \"AES-192-OFB\"\n#define LN_aes_192_ofb128               \"aes-192-ofb\"\n#define NID_aes_192_ofb128              424\n#define OBJ_aes_192_ofb128              OBJ_aes,23L\n\n#define SN_aes_192_cfb128               \"AES-192-CFB\"\n#define LN_aes_192_cfb128               \"aes-192-cfb\"\n#define NID_aes_192_cfb128              425\n#define OBJ_aes_192_cfb128              OBJ_aes,24L\n\n#define SN_id_aes192_wrap               \"id-aes192-wrap\"\n#define NID_id_aes192_wrap              789\n#define OBJ_id_aes192_wrap              OBJ_aes,25L\n\n#define SN_aes_192_gcm          \"id-aes192-GCM\"\n#define LN_aes_192_gcm          \"aes-192-gcm\"\n#define NID_aes_192_gcm         898\n#define OBJ_aes_192_gcm         OBJ_aes,26L\n\n#define SN_aes_192_ccm          \"id-aes192-CCM\"\n#define LN_aes_192_ccm          \"aes-192-ccm\"\n#define NID_aes_192_ccm         899\n#define OBJ_aes_192_ccm         OBJ_aes,27L\n\n#define SN_id_aes192_wrap_pad           \"id-aes192-wrap-pad\"\n#define NID_id_aes192_wrap_pad          900\n#define OBJ_id_aes192_wrap_pad          OBJ_aes,28L\n\n#define SN_aes_256_ecb          \"AES-256-ECB\"\n#define LN_aes_256_ecb          \"aes-256-ecb\"\n#define NID_aes_256_ecb         426\n#define OBJ_aes_256_ecb         OBJ_aes,41L\n\n#define SN_aes_256_cbc          \"AES-256-CBC\"\n#define LN_aes_256_cbc          \"aes-256-cbc\"\n#define NID_aes_256_cbc         427\n#define OBJ_aes_256_cbc         OBJ_aes,42L\n\n#define SN_aes_256_ofb128               \"AES-256-OFB\"\n#define LN_aes_256_ofb128               \"aes-256-ofb\"\n#define NID_aes_256_ofb128              428\n#define OBJ_aes_256_ofb128              OBJ_aes,43L\n\n#define SN_aes_256_cfb128               \"AES-256-CFB\"\n#define LN_aes_256_cfb128               \"aes-256-cfb\"\n#define NID_aes_256_cfb128              429\n#define OBJ_aes_256_cfb128              OBJ_aes,44L\n\n#define SN_id_aes256_wrap               \"id-aes256-wrap\"\n#define NID_id_aes256_wrap              790\n#define OBJ_id_aes256_wrap              OBJ_aes,45L\n\n#define SN_aes_256_gcm          \"id-aes256-GCM\"\n#define LN_aes_256_gcm          \"aes-256-gcm\"\n#define NID_aes_256_gcm         901\n#define OBJ_aes_256_gcm         OBJ_aes,46L\n\n#define SN_aes_256_ccm          \"id-aes256-CCM\"\n#define LN_aes_256_ccm          \"aes-256-ccm\"\n#define NID_aes_256_ccm         902\n#define OBJ_aes_256_ccm         OBJ_aes,47L\n\n#define SN_id_aes256_wrap_pad           \"id-aes256-wrap-pad\"\n#define NID_id_aes256_wrap_pad          903\n#define OBJ_id_aes256_wrap_pad          OBJ_aes,48L\n\n#define SN_aes_128_cfb1         \"AES-128-CFB1\"\n#define LN_aes_128_cfb1         \"aes-128-cfb1\"\n#define NID_aes_128_cfb1                650\n\n#define SN_aes_192_cfb1         \"AES-192-CFB1\"\n#define LN_aes_192_cfb1         \"aes-192-cfb1\"\n#define NID_aes_192_cfb1                651\n\n#define SN_aes_256_cfb1         \"AES-256-CFB1\"\n#define LN_aes_256_cfb1         \"aes-256-cfb1\"\n#define NID_aes_256_cfb1                652\n\n#define SN_aes_128_cfb8         \"AES-128-CFB8\"\n#define LN_aes_128_cfb8         \"aes-128-cfb8\"\n#define NID_aes_128_cfb8                653\n\n#define SN_aes_192_cfb8         \"AES-192-CFB8\"\n#define LN_aes_192_cfb8         \"aes-192-cfb8\"\n#define NID_aes_192_cfb8                654\n\n#define SN_aes_256_cfb8         \"AES-256-CFB8\"\n#define LN_aes_256_cfb8         \"aes-256-cfb8\"\n#define NID_aes_256_cfb8                655\n\n#define SN_aes_128_ctr          \"AES-128-CTR\"\n#define LN_aes_128_ctr          \"aes-128-ctr\"\n#define NID_aes_128_ctr         904\n\n#define SN_aes_192_ctr          \"AES-192-CTR\"\n#define LN_aes_192_ctr          \"aes-192-ctr\"\n#define NID_aes_192_ctr         905\n\n#define SN_aes_256_ctr          \"AES-256-CTR\"\n#define LN_aes_256_ctr          \"aes-256-ctr\"\n#define NID_aes_256_ctr         906\n\n#define SN_aes_128_xts          \"AES-128-XTS\"\n#define LN_aes_128_xts          \"aes-128-xts\"\n#define NID_aes_128_xts         913\n\n#define SN_aes_256_xts          \"AES-256-XTS\"\n#define LN_aes_256_xts          \"aes-256-xts\"\n#define NID_aes_256_xts         914\n\n#define SN_des_cfb1             \"DES-CFB1\"\n#define LN_des_cfb1             \"des-cfb1\"\n#define NID_des_cfb1            656\n\n#define SN_des_cfb8             \"DES-CFB8\"\n#define LN_des_cfb8             \"des-cfb8\"\n#define NID_des_cfb8            657\n\n#define SN_des_ede3_cfb1                \"DES-EDE3-CFB1\"\n#define LN_des_ede3_cfb1                \"des-ede3-cfb1\"\n#define NID_des_ede3_cfb1               658\n\n#define SN_des_ede3_cfb8                \"DES-EDE3-CFB8\"\n#define LN_des_ede3_cfb8                \"des-ede3-cfb8\"\n#define NID_des_ede3_cfb8               659\n\n#define OBJ_nist_hashalgs               OBJ_nistAlgorithms,2L\n\n#define SN_sha256               \"SHA256\"\n#define LN_sha256               \"sha256\"\n#define NID_sha256              672\n#define OBJ_sha256              OBJ_nist_hashalgs,1L\n\n#define SN_sha384               \"SHA384\"\n#define LN_sha384               \"sha384\"\n#define NID_sha384              673\n#define OBJ_sha384              OBJ_nist_hashalgs,2L\n\n#define SN_sha512               \"SHA512\"\n#define LN_sha512               \"sha512\"\n#define NID_sha512              674\n#define OBJ_sha512              OBJ_nist_hashalgs,3L\n\n#define SN_sha224               \"SHA224\"\n#define LN_sha224               \"sha224\"\n#define NID_sha224              675\n#define OBJ_sha224              OBJ_nist_hashalgs,4L\n\n#define OBJ_dsa_with_sha2               OBJ_nistAlgorithms,3L\n\n#define SN_dsa_with_SHA224              \"dsa_with_SHA224\"\n#define NID_dsa_with_SHA224             802\n#define OBJ_dsa_with_SHA224             OBJ_dsa_with_sha2,1L\n\n#define SN_dsa_with_SHA256              \"dsa_with_SHA256\"\n#define NID_dsa_with_SHA256             803\n#define OBJ_dsa_with_SHA256             OBJ_dsa_with_sha2,2L\n\n#define SN_hold_instruction_code                \"holdInstructionCode\"\n#define LN_hold_instruction_code                \"Hold Instruction Code\"\n#define NID_hold_instruction_code               430\n#define OBJ_hold_instruction_code               OBJ_id_ce,23L\n\n#define OBJ_holdInstruction             OBJ_X9_57,2L\n\n#define SN_hold_instruction_none                \"holdInstructionNone\"\n#define LN_hold_instruction_none                \"Hold Instruction None\"\n#define NID_hold_instruction_none               431\n#define OBJ_hold_instruction_none               OBJ_holdInstruction,1L\n\n#define SN_hold_instruction_call_issuer         \"holdInstructionCallIssuer\"\n#define LN_hold_instruction_call_issuer         \"Hold Instruction Call Issuer\"\n#define NID_hold_instruction_call_issuer                432\n#define OBJ_hold_instruction_call_issuer                OBJ_holdInstruction,2L\n\n#define SN_hold_instruction_reject              \"holdInstructionReject\"\n#define LN_hold_instruction_reject              \"Hold Instruction Reject\"\n#define NID_hold_instruction_reject             433\n#define OBJ_hold_instruction_reject             OBJ_holdInstruction,3L\n\n#define SN_data         \"data\"\n#define NID_data                434\n#define OBJ_data                OBJ_itu_t,9L\n\n#define SN_pss          \"pss\"\n#define NID_pss         435\n#define OBJ_pss         OBJ_data,2342L\n\n#define SN_ucl          \"ucl\"\n#define NID_ucl         436\n#define OBJ_ucl         OBJ_pss,19200300L\n\n#define SN_pilot                \"pilot\"\n#define NID_pilot               437\n#define OBJ_pilot               OBJ_ucl,100L\n\n#define LN_pilotAttributeType           \"pilotAttributeType\"\n#define NID_pilotAttributeType          438\n#define OBJ_pilotAttributeType          OBJ_pilot,1L\n\n#define LN_pilotAttributeSyntax         \"pilotAttributeSyntax\"\n#define NID_pilotAttributeSyntax                439\n#define OBJ_pilotAttributeSyntax                OBJ_pilot,3L\n\n#define LN_pilotObjectClass             \"pilotObjectClass\"\n#define NID_pilotObjectClass            440\n#define OBJ_pilotObjectClass            OBJ_pilot,4L\n\n#define LN_pilotGroups          \"pilotGroups\"\n#define NID_pilotGroups         441\n#define OBJ_pilotGroups         OBJ_pilot,10L\n\n#define LN_iA5StringSyntax              \"iA5StringSyntax\"\n#define NID_iA5StringSyntax             442\n#define OBJ_iA5StringSyntax             OBJ_pilotAttributeSyntax,4L\n\n#define LN_caseIgnoreIA5StringSyntax            \"caseIgnoreIA5StringSyntax\"\n#define NID_caseIgnoreIA5StringSyntax           443\n#define OBJ_caseIgnoreIA5StringSyntax           OBJ_pilotAttributeSyntax,5L\n\n#define LN_pilotObject          \"pilotObject\"\n#define NID_pilotObject         444\n#define OBJ_pilotObject         OBJ_pilotObjectClass,3L\n\n#define LN_pilotPerson          \"pilotPerson\"\n#define NID_pilotPerson         445\n#define OBJ_pilotPerson         OBJ_pilotObjectClass,4L\n\n#define SN_account              \"account\"\n#define NID_account             446\n#define OBJ_account             OBJ_pilotObjectClass,5L\n\n#define SN_document             \"document\"\n#define NID_document            447\n#define OBJ_document            OBJ_pilotObjectClass,6L\n\n#define SN_room         \"room\"\n#define NID_room                448\n#define OBJ_room                OBJ_pilotObjectClass,7L\n\n#define LN_documentSeries               \"documentSeries\"\n#define NID_documentSeries              449\n#define OBJ_documentSeries              OBJ_pilotObjectClass,9L\n\n#define SN_Domain               \"domain\"\n#define LN_Domain               \"Domain\"\n#define NID_Domain              392\n#define OBJ_Domain              OBJ_pilotObjectClass,13L\n\n#define LN_rFC822localPart              \"rFC822localPart\"\n#define NID_rFC822localPart             450\n#define OBJ_rFC822localPart             OBJ_pilotObjectClass,14L\n\n#define LN_dNSDomain            \"dNSDomain\"\n#define NID_dNSDomain           451\n#define OBJ_dNSDomain           OBJ_pilotObjectClass,15L\n\n#define LN_domainRelatedObject          \"domainRelatedObject\"\n#define NID_domainRelatedObject         452\n#define OBJ_domainRelatedObject         OBJ_pilotObjectClass,17L\n\n#define LN_friendlyCountry              \"friendlyCountry\"\n#define NID_friendlyCountry             453\n#define OBJ_friendlyCountry             OBJ_pilotObjectClass,18L\n\n#define LN_simpleSecurityObject         \"simpleSecurityObject\"\n#define NID_simpleSecurityObject                454\n#define OBJ_simpleSecurityObject                OBJ_pilotObjectClass,19L\n\n#define LN_pilotOrganization            \"pilotOrganization\"\n#define NID_pilotOrganization           455\n#define OBJ_pilotOrganization           OBJ_pilotObjectClass,20L\n\n#define LN_pilotDSA             \"pilotDSA\"\n#define NID_pilotDSA            456\n#define OBJ_pilotDSA            OBJ_pilotObjectClass,21L\n\n#define LN_qualityLabelledData          \"qualityLabelledData\"\n#define NID_qualityLabelledData         457\n#define OBJ_qualityLabelledData         OBJ_pilotObjectClass,22L\n\n#define SN_userId               \"UID\"\n#define LN_userId               \"userId\"\n#define NID_userId              458\n#define OBJ_userId              OBJ_pilotAttributeType,1L\n\n#define LN_textEncodedORAddress         \"textEncodedORAddress\"\n#define NID_textEncodedORAddress                459\n#define OBJ_textEncodedORAddress                OBJ_pilotAttributeType,2L\n\n#define SN_rfc822Mailbox                \"mail\"\n#define LN_rfc822Mailbox                \"rfc822Mailbox\"\n#define NID_rfc822Mailbox               460\n#define OBJ_rfc822Mailbox               OBJ_pilotAttributeType,3L\n\n#define SN_info         \"info\"\n#define NID_info                461\n#define OBJ_info                OBJ_pilotAttributeType,4L\n\n#define LN_favouriteDrink               \"favouriteDrink\"\n#define NID_favouriteDrink              462\n#define OBJ_favouriteDrink              OBJ_pilotAttributeType,5L\n\n#define LN_roomNumber           \"roomNumber\"\n#define NID_roomNumber          463\n#define OBJ_roomNumber          OBJ_pilotAttributeType,6L\n\n#define SN_photo                \"photo\"\n#define NID_photo               464\n#define OBJ_photo               OBJ_pilotAttributeType,7L\n\n#define LN_userClass            \"userClass\"\n#define NID_userClass           465\n#define OBJ_userClass           OBJ_pilotAttributeType,8L\n\n#define SN_host         \"host\"\n#define NID_host                466\n#define OBJ_host                OBJ_pilotAttributeType,9L\n\n#define SN_manager              \"manager\"\n#define NID_manager             467\n#define OBJ_manager             OBJ_pilotAttributeType,10L\n\n#define LN_documentIdentifier           \"documentIdentifier\"\n#define NID_documentIdentifier          468\n#define OBJ_documentIdentifier          OBJ_pilotAttributeType,11L\n\n#define LN_documentTitle                \"documentTitle\"\n#define NID_documentTitle               469\n#define OBJ_documentTitle               OBJ_pilotAttributeType,12L\n\n#define LN_documentVersion              \"documentVersion\"\n#define NID_documentVersion             470\n#define OBJ_documentVersion             OBJ_pilotAttributeType,13L\n\n#define LN_documentAuthor               \"documentAuthor\"\n#define NID_documentAuthor              471\n#define OBJ_documentAuthor              OBJ_pilotAttributeType,14L\n\n#define LN_documentLocation             \"documentLocation\"\n#define NID_documentLocation            472\n#define OBJ_documentLocation            OBJ_pilotAttributeType,15L\n\n#define LN_homeTelephoneNumber          \"homeTelephoneNumber\"\n#define NID_homeTelephoneNumber         473\n#define OBJ_homeTelephoneNumber         OBJ_pilotAttributeType,20L\n\n#define SN_secretary            \"secretary\"\n#define NID_secretary           474\n#define OBJ_secretary           OBJ_pilotAttributeType,21L\n\n#define LN_otherMailbox         \"otherMailbox\"\n#define NID_otherMailbox                475\n#define OBJ_otherMailbox                OBJ_pilotAttributeType,22L\n\n#define LN_lastModifiedTime             \"lastModifiedTime\"\n#define NID_lastModifiedTime            476\n#define OBJ_lastModifiedTime            OBJ_pilotAttributeType,23L\n\n#define LN_lastModifiedBy               \"lastModifiedBy\"\n#define NID_lastModifiedBy              477\n#define OBJ_lastModifiedBy              OBJ_pilotAttributeType,24L\n\n#define SN_domainComponent              \"DC\"\n#define LN_domainComponent              \"domainComponent\"\n#define NID_domainComponent             391\n#define OBJ_domainComponent             OBJ_pilotAttributeType,25L\n\n#define LN_aRecord              \"aRecord\"\n#define NID_aRecord             478\n#define OBJ_aRecord             OBJ_pilotAttributeType,26L\n\n#define LN_pilotAttributeType27         \"pilotAttributeType27\"\n#define NID_pilotAttributeType27                479\n#define OBJ_pilotAttributeType27                OBJ_pilotAttributeType,27L\n\n#define LN_mXRecord             \"mXRecord\"\n#define NID_mXRecord            480\n#define OBJ_mXRecord            OBJ_pilotAttributeType,28L\n\n#define LN_nSRecord             \"nSRecord\"\n#define NID_nSRecord            481\n#define OBJ_nSRecord            OBJ_pilotAttributeType,29L\n\n#define LN_sOARecord            \"sOARecord\"\n#define NID_sOARecord           482\n#define OBJ_sOARecord           OBJ_pilotAttributeType,30L\n\n#define LN_cNAMERecord          \"cNAMERecord\"\n#define NID_cNAMERecord         483\n#define OBJ_cNAMERecord         OBJ_pilotAttributeType,31L\n\n#define LN_associatedDomain             \"associatedDomain\"\n#define NID_associatedDomain            484\n#define OBJ_associatedDomain            OBJ_pilotAttributeType,37L\n\n#define LN_associatedName               \"associatedName\"\n#define NID_associatedName              485\n#define OBJ_associatedName              OBJ_pilotAttributeType,38L\n\n#define LN_homePostalAddress            \"homePostalAddress\"\n#define NID_homePostalAddress           486\n#define OBJ_homePostalAddress           OBJ_pilotAttributeType,39L\n\n#define LN_personalTitle                \"personalTitle\"\n#define NID_personalTitle               487\n#define OBJ_personalTitle               OBJ_pilotAttributeType,40L\n\n#define LN_mobileTelephoneNumber                \"mobileTelephoneNumber\"\n#define NID_mobileTelephoneNumber               488\n#define OBJ_mobileTelephoneNumber               OBJ_pilotAttributeType,41L\n\n#define LN_pagerTelephoneNumber         \"pagerTelephoneNumber\"\n#define NID_pagerTelephoneNumber                489\n#define OBJ_pagerTelephoneNumber                OBJ_pilotAttributeType,42L\n\n#define LN_friendlyCountryName          \"friendlyCountryName\"\n#define NID_friendlyCountryName         490\n#define OBJ_friendlyCountryName         OBJ_pilotAttributeType,43L\n\n#define LN_organizationalStatus         \"organizationalStatus\"\n#define NID_organizationalStatus                491\n#define OBJ_organizationalStatus                OBJ_pilotAttributeType,45L\n\n#define LN_janetMailbox         \"janetMailbox\"\n#define NID_janetMailbox                492\n#define OBJ_janetMailbox                OBJ_pilotAttributeType,46L\n\n#define LN_mailPreferenceOption         \"mailPreferenceOption\"\n#define NID_mailPreferenceOption                493\n#define OBJ_mailPreferenceOption                OBJ_pilotAttributeType,47L\n\n#define LN_buildingName         \"buildingName\"\n#define NID_buildingName                494\n#define OBJ_buildingName                OBJ_pilotAttributeType,48L\n\n#define LN_dSAQuality           \"dSAQuality\"\n#define NID_dSAQuality          495\n#define OBJ_dSAQuality          OBJ_pilotAttributeType,49L\n\n#define LN_singleLevelQuality           \"singleLevelQuality\"\n#define NID_singleLevelQuality          496\n#define OBJ_singleLevelQuality          OBJ_pilotAttributeType,50L\n\n#define LN_subtreeMinimumQuality                \"subtreeMinimumQuality\"\n#define NID_subtreeMinimumQuality               497\n#define OBJ_subtreeMinimumQuality               OBJ_pilotAttributeType,51L\n\n#define LN_subtreeMaximumQuality                \"subtreeMaximumQuality\"\n#define NID_subtreeMaximumQuality               498\n#define OBJ_subtreeMaximumQuality               OBJ_pilotAttributeType,52L\n\n#define LN_personalSignature            \"personalSignature\"\n#define NID_personalSignature           499\n#define OBJ_personalSignature           OBJ_pilotAttributeType,53L\n\n#define LN_dITRedirect          \"dITRedirect\"\n#define NID_dITRedirect         500\n#define OBJ_dITRedirect         OBJ_pilotAttributeType,54L\n\n#define SN_audio                \"audio\"\n#define NID_audio               501\n#define OBJ_audio               OBJ_pilotAttributeType,55L\n\n#define LN_documentPublisher            \"documentPublisher\"\n#define NID_documentPublisher           502\n#define OBJ_documentPublisher           OBJ_pilotAttributeType,56L\n\n#define SN_id_set               \"id-set\"\n#define LN_id_set               \"Secure Electronic Transactions\"\n#define NID_id_set              512\n#define OBJ_id_set              OBJ_international_organizations,42L\n\n#define SN_set_ctype            \"set-ctype\"\n#define LN_set_ctype            \"content types\"\n#define NID_set_ctype           513\n#define OBJ_set_ctype           OBJ_id_set,0L\n\n#define SN_set_msgExt           \"set-msgExt\"\n#define LN_set_msgExt           \"message extensions\"\n#define NID_set_msgExt          514\n#define OBJ_set_msgExt          OBJ_id_set,1L\n\n#define SN_set_attr             \"set-attr\"\n#define NID_set_attr            515\n#define OBJ_set_attr            OBJ_id_set,3L\n\n#define SN_set_policy           \"set-policy\"\n#define NID_set_policy          516\n#define OBJ_set_policy          OBJ_id_set,5L\n\n#define SN_set_certExt          \"set-certExt\"\n#define LN_set_certExt          \"certificate extensions\"\n#define NID_set_certExt         517\n#define OBJ_set_certExt         OBJ_id_set,7L\n\n#define SN_set_brand            \"set-brand\"\n#define NID_set_brand           518\n#define OBJ_set_brand           OBJ_id_set,8L\n\n#define SN_setct_PANData                \"setct-PANData\"\n#define NID_setct_PANData               519\n#define OBJ_setct_PANData               OBJ_set_ctype,0L\n\n#define SN_setct_PANToken               \"setct-PANToken\"\n#define NID_setct_PANToken              520\n#define OBJ_setct_PANToken              OBJ_set_ctype,1L\n\n#define SN_setct_PANOnly                \"setct-PANOnly\"\n#define NID_setct_PANOnly               521\n#define OBJ_setct_PANOnly               OBJ_set_ctype,2L\n\n#define SN_setct_OIData         \"setct-OIData\"\n#define NID_setct_OIData                522\n#define OBJ_setct_OIData                OBJ_set_ctype,3L\n\n#define SN_setct_PI             \"setct-PI\"\n#define NID_setct_PI            523\n#define OBJ_setct_PI            OBJ_set_ctype,4L\n\n#define SN_setct_PIData         \"setct-PIData\"\n#define NID_setct_PIData                524\n#define OBJ_setct_PIData                OBJ_set_ctype,5L\n\n#define SN_setct_PIDataUnsigned         \"setct-PIDataUnsigned\"\n#define NID_setct_PIDataUnsigned                525\n#define OBJ_setct_PIDataUnsigned                OBJ_set_ctype,6L\n\n#define SN_setct_HODInput               \"setct-HODInput\"\n#define NID_setct_HODInput              526\n#define OBJ_setct_HODInput              OBJ_set_ctype,7L\n\n#define SN_setct_AuthResBaggage         \"setct-AuthResBaggage\"\n#define NID_setct_AuthResBaggage                527\n#define OBJ_setct_AuthResBaggage                OBJ_set_ctype,8L\n\n#define SN_setct_AuthRevReqBaggage              \"setct-AuthRevReqBaggage\"\n#define NID_setct_AuthRevReqBaggage             528\n#define OBJ_setct_AuthRevReqBaggage             OBJ_set_ctype,9L\n\n#define SN_setct_AuthRevResBaggage              \"setct-AuthRevResBaggage\"\n#define NID_setct_AuthRevResBaggage             529\n#define OBJ_setct_AuthRevResBaggage             OBJ_set_ctype,10L\n\n#define SN_setct_CapTokenSeq            \"setct-CapTokenSeq\"\n#define NID_setct_CapTokenSeq           530\n#define OBJ_setct_CapTokenSeq           OBJ_set_ctype,11L\n\n#define SN_setct_PInitResData           \"setct-PInitResData\"\n#define NID_setct_PInitResData          531\n#define OBJ_setct_PInitResData          OBJ_set_ctype,12L\n\n#define SN_setct_PI_TBS         \"setct-PI-TBS\"\n#define NID_setct_PI_TBS                532\n#define OBJ_setct_PI_TBS                OBJ_set_ctype,13L\n\n#define SN_setct_PResData               \"setct-PResData\"\n#define NID_setct_PResData              533\n#define OBJ_setct_PResData              OBJ_set_ctype,14L\n\n#define SN_setct_AuthReqTBS             \"setct-AuthReqTBS\"\n#define NID_setct_AuthReqTBS            534\n#define OBJ_setct_AuthReqTBS            OBJ_set_ctype,16L\n\n#define SN_setct_AuthResTBS             \"setct-AuthResTBS\"\n#define NID_setct_AuthResTBS            535\n#define OBJ_setct_AuthResTBS            OBJ_set_ctype,17L\n\n#define SN_setct_AuthResTBSX            \"setct-AuthResTBSX\"\n#define NID_setct_AuthResTBSX           536\n#define OBJ_setct_AuthResTBSX           OBJ_set_ctype,18L\n\n#define SN_setct_AuthTokenTBS           \"setct-AuthTokenTBS\"\n#define NID_setct_AuthTokenTBS          537\n#define OBJ_setct_AuthTokenTBS          OBJ_set_ctype,19L\n\n#define SN_setct_CapTokenData           \"setct-CapTokenData\"\n#define NID_setct_CapTokenData          538\n#define OBJ_setct_CapTokenData          OBJ_set_ctype,20L\n\n#define SN_setct_CapTokenTBS            \"setct-CapTokenTBS\"\n#define NID_setct_CapTokenTBS           539\n#define OBJ_setct_CapTokenTBS           OBJ_set_ctype,21L\n\n#define SN_setct_AcqCardCodeMsg         \"setct-AcqCardCodeMsg\"\n#define NID_setct_AcqCardCodeMsg                540\n#define OBJ_setct_AcqCardCodeMsg                OBJ_set_ctype,22L\n\n#define SN_setct_AuthRevReqTBS          \"setct-AuthRevReqTBS\"\n#define NID_setct_AuthRevReqTBS         541\n#define OBJ_setct_AuthRevReqTBS         OBJ_set_ctype,23L\n\n#define SN_setct_AuthRevResData         \"setct-AuthRevResData\"\n#define NID_setct_AuthRevResData                542\n#define OBJ_setct_AuthRevResData                OBJ_set_ctype,24L\n\n#define SN_setct_AuthRevResTBS          \"setct-AuthRevResTBS\"\n#define NID_setct_AuthRevResTBS         543\n#define OBJ_setct_AuthRevResTBS         OBJ_set_ctype,25L\n\n#define SN_setct_CapReqTBS              \"setct-CapReqTBS\"\n#define NID_setct_CapReqTBS             544\n#define OBJ_setct_CapReqTBS             OBJ_set_ctype,26L\n\n#define SN_setct_CapReqTBSX             \"setct-CapReqTBSX\"\n#define NID_setct_CapReqTBSX            545\n#define OBJ_setct_CapReqTBSX            OBJ_set_ctype,27L\n\n#define SN_setct_CapResData             \"setct-CapResData\"\n#define NID_setct_CapResData            546\n#define OBJ_setct_CapResData            OBJ_set_ctype,28L\n\n#define SN_setct_CapRevReqTBS           \"setct-CapRevReqTBS\"\n#define NID_setct_CapRevReqTBS          547\n#define OBJ_setct_CapRevReqTBS          OBJ_set_ctype,29L\n\n#define SN_setct_CapRevReqTBSX          \"setct-CapRevReqTBSX\"\n#define NID_setct_CapRevReqTBSX         548\n#define OBJ_setct_CapRevReqTBSX         OBJ_set_ctype,30L\n\n#define SN_setct_CapRevResData          \"setct-CapRevResData\"\n#define NID_setct_CapRevResData         549\n#define OBJ_setct_CapRevResData         OBJ_set_ctype,31L\n\n#define SN_setct_CredReqTBS             \"setct-CredReqTBS\"\n#define NID_setct_CredReqTBS            550\n#define OBJ_setct_CredReqTBS            OBJ_set_ctype,32L\n\n#define SN_setct_CredReqTBSX            \"setct-CredReqTBSX\"\n#define NID_setct_CredReqTBSX           551\n#define OBJ_setct_CredReqTBSX           OBJ_set_ctype,33L\n\n#define SN_setct_CredResData            \"setct-CredResData\"\n#define NID_setct_CredResData           552\n#define OBJ_setct_CredResData           OBJ_set_ctype,34L\n\n#define SN_setct_CredRevReqTBS          \"setct-CredRevReqTBS\"\n#define NID_setct_CredRevReqTBS         553\n#define OBJ_setct_CredRevReqTBS         OBJ_set_ctype,35L\n\n#define SN_setct_CredRevReqTBSX         \"setct-CredRevReqTBSX\"\n#define NID_setct_CredRevReqTBSX                554\n#define OBJ_setct_CredRevReqTBSX                OBJ_set_ctype,36L\n\n#define SN_setct_CredRevResData         \"setct-CredRevResData\"\n#define NID_setct_CredRevResData                555\n#define OBJ_setct_CredRevResData                OBJ_set_ctype,37L\n\n#define SN_setct_PCertReqData           \"setct-PCertReqData\"\n#define NID_setct_PCertReqData          556\n#define OBJ_setct_PCertReqData          OBJ_set_ctype,38L\n\n#define SN_setct_PCertResTBS            \"setct-PCertResTBS\"\n#define NID_setct_PCertResTBS           557\n#define OBJ_setct_PCertResTBS           OBJ_set_ctype,39L\n\n#define SN_setct_BatchAdminReqData              \"setct-BatchAdminReqData\"\n#define NID_setct_BatchAdminReqData             558\n#define OBJ_setct_BatchAdminReqData             OBJ_set_ctype,40L\n\n#define SN_setct_BatchAdminResData              \"setct-BatchAdminResData\"\n#define NID_setct_BatchAdminResData             559\n#define OBJ_setct_BatchAdminResData             OBJ_set_ctype,41L\n\n#define SN_setct_CardCInitResTBS                \"setct-CardCInitResTBS\"\n#define NID_setct_CardCInitResTBS               560\n#define OBJ_setct_CardCInitResTBS               OBJ_set_ctype,42L\n\n#define SN_setct_MeAqCInitResTBS                \"setct-MeAqCInitResTBS\"\n#define NID_setct_MeAqCInitResTBS               561\n#define OBJ_setct_MeAqCInitResTBS               OBJ_set_ctype,43L\n\n#define SN_setct_RegFormResTBS          \"setct-RegFormResTBS\"\n#define NID_setct_RegFormResTBS         562\n#define OBJ_setct_RegFormResTBS         OBJ_set_ctype,44L\n\n#define SN_setct_CertReqData            \"setct-CertReqData\"\n#define NID_setct_CertReqData           563\n#define OBJ_setct_CertReqData           OBJ_set_ctype,45L\n\n#define SN_setct_CertReqTBS             \"setct-CertReqTBS\"\n#define NID_setct_CertReqTBS            564\n#define OBJ_setct_CertReqTBS            OBJ_set_ctype,46L\n\n#define SN_setct_CertResData            \"setct-CertResData\"\n#define NID_setct_CertResData           565\n#define OBJ_setct_CertResData           OBJ_set_ctype,47L\n\n#define SN_setct_CertInqReqTBS          \"setct-CertInqReqTBS\"\n#define NID_setct_CertInqReqTBS         566\n#define OBJ_setct_CertInqReqTBS         OBJ_set_ctype,48L\n\n#define SN_setct_ErrorTBS               \"setct-ErrorTBS\"\n#define NID_setct_ErrorTBS              567\n#define OBJ_setct_ErrorTBS              OBJ_set_ctype,49L\n\n#define SN_setct_PIDualSignedTBE                \"setct-PIDualSignedTBE\"\n#define NID_setct_PIDualSignedTBE               568\n#define OBJ_setct_PIDualSignedTBE               OBJ_set_ctype,50L\n\n#define SN_setct_PIUnsignedTBE          \"setct-PIUnsignedTBE\"\n#define NID_setct_PIUnsignedTBE         569\n#define OBJ_setct_PIUnsignedTBE         OBJ_set_ctype,51L\n\n#define SN_setct_AuthReqTBE             \"setct-AuthReqTBE\"\n#define NID_setct_AuthReqTBE            570\n#define OBJ_setct_AuthReqTBE            OBJ_set_ctype,52L\n\n#define SN_setct_AuthResTBE             \"setct-AuthResTBE\"\n#define NID_setct_AuthResTBE            571\n#define OBJ_setct_AuthResTBE            OBJ_set_ctype,53L\n\n#define SN_setct_AuthResTBEX            \"setct-AuthResTBEX\"\n#define NID_setct_AuthResTBEX           572\n#define OBJ_setct_AuthResTBEX           OBJ_set_ctype,54L\n\n#define SN_setct_AuthTokenTBE           \"setct-AuthTokenTBE\"\n#define NID_setct_AuthTokenTBE          573\n#define OBJ_setct_AuthTokenTBE          OBJ_set_ctype,55L\n\n#define SN_setct_CapTokenTBE            \"setct-CapTokenTBE\"\n#define NID_setct_CapTokenTBE           574\n#define OBJ_setct_CapTokenTBE           OBJ_set_ctype,56L\n\n#define SN_setct_CapTokenTBEX           \"setct-CapTokenTBEX\"\n#define NID_setct_CapTokenTBEX          575\n#define OBJ_setct_CapTokenTBEX          OBJ_set_ctype,57L\n\n#define SN_setct_AcqCardCodeMsgTBE              \"setct-AcqCardCodeMsgTBE\"\n#define NID_setct_AcqCardCodeMsgTBE             576\n#define OBJ_setct_AcqCardCodeMsgTBE             OBJ_set_ctype,58L\n\n#define SN_setct_AuthRevReqTBE          \"setct-AuthRevReqTBE\"\n#define NID_setct_AuthRevReqTBE         577\n#define OBJ_setct_AuthRevReqTBE         OBJ_set_ctype,59L\n\n#define SN_setct_AuthRevResTBE          \"setct-AuthRevResTBE\"\n#define NID_setct_AuthRevResTBE         578\n#define OBJ_setct_AuthRevResTBE         OBJ_set_ctype,60L\n\n#define SN_setct_AuthRevResTBEB         \"setct-AuthRevResTBEB\"\n#define NID_setct_AuthRevResTBEB                579\n#define OBJ_setct_AuthRevResTBEB                OBJ_set_ctype,61L\n\n#define SN_setct_CapReqTBE              \"setct-CapReqTBE\"\n#define NID_setct_CapReqTBE             580\n#define OBJ_setct_CapReqTBE             OBJ_set_ctype,62L\n\n#define SN_setct_CapReqTBEX             \"setct-CapReqTBEX\"\n#define NID_setct_CapReqTBEX            581\n#define OBJ_setct_CapReqTBEX            OBJ_set_ctype,63L\n\n#define SN_setct_CapResTBE              \"setct-CapResTBE\"\n#define NID_setct_CapResTBE             582\n#define OBJ_setct_CapResTBE             OBJ_set_ctype,64L\n\n#define SN_setct_CapRevReqTBE           \"setct-CapRevReqTBE\"\n#define NID_setct_CapRevReqTBE          583\n#define OBJ_setct_CapRevReqTBE          OBJ_set_ctype,65L\n\n#define SN_setct_CapRevReqTBEX          \"setct-CapRevReqTBEX\"\n#define NID_setct_CapRevReqTBEX         584\n#define OBJ_setct_CapRevReqTBEX         OBJ_set_ctype,66L\n\n#define SN_setct_CapRevResTBE           \"setct-CapRevResTBE\"\n#define NID_setct_CapRevResTBE          585\n#define OBJ_setct_CapRevResTBE          OBJ_set_ctype,67L\n\n#define SN_setct_CredReqTBE             \"setct-CredReqTBE\"\n#define NID_setct_CredReqTBE            586\n#define OBJ_setct_CredReqTBE            OBJ_set_ctype,68L\n\n#define SN_setct_CredReqTBEX            \"setct-CredReqTBEX\"\n#define NID_setct_CredReqTBEX           587\n#define OBJ_setct_CredReqTBEX           OBJ_set_ctype,69L\n\n#define SN_setct_CredResTBE             \"setct-CredResTBE\"\n#define NID_setct_CredResTBE            588\n#define OBJ_setct_CredResTBE            OBJ_set_ctype,70L\n\n#define SN_setct_CredRevReqTBE          \"setct-CredRevReqTBE\"\n#define NID_setct_CredRevReqTBE         589\n#define OBJ_setct_CredRevReqTBE         OBJ_set_ctype,71L\n\n#define SN_setct_CredRevReqTBEX         \"setct-CredRevReqTBEX\"\n#define NID_setct_CredRevReqTBEX                590\n#define OBJ_setct_CredRevReqTBEX                OBJ_set_ctype,72L\n\n#define SN_setct_CredRevResTBE          \"setct-CredRevResTBE\"\n#define NID_setct_CredRevResTBE         591\n#define OBJ_setct_CredRevResTBE         OBJ_set_ctype,73L\n\n#define SN_setct_BatchAdminReqTBE               \"setct-BatchAdminReqTBE\"\n#define NID_setct_BatchAdminReqTBE              592\n#define OBJ_setct_BatchAdminReqTBE              OBJ_set_ctype,74L\n\n#define SN_setct_BatchAdminResTBE               \"setct-BatchAdminResTBE\"\n#define NID_setct_BatchAdminResTBE              593\n#define OBJ_setct_BatchAdminResTBE              OBJ_set_ctype,75L\n\n#define SN_setct_RegFormReqTBE          \"setct-RegFormReqTBE\"\n#define NID_setct_RegFormReqTBE         594\n#define OBJ_setct_RegFormReqTBE         OBJ_set_ctype,76L\n\n#define SN_setct_CertReqTBE             \"setct-CertReqTBE\"\n#define NID_setct_CertReqTBE            595\n#define OBJ_setct_CertReqTBE            OBJ_set_ctype,77L\n\n#define SN_setct_CertReqTBEX            \"setct-CertReqTBEX\"\n#define NID_setct_CertReqTBEX           596\n#define OBJ_setct_CertReqTBEX           OBJ_set_ctype,78L\n\n#define SN_setct_CertResTBE             \"setct-CertResTBE\"\n#define NID_setct_CertResTBE            597\n#define OBJ_setct_CertResTBE            OBJ_set_ctype,79L\n\n#define SN_setct_CRLNotificationTBS             \"setct-CRLNotificationTBS\"\n#define NID_setct_CRLNotificationTBS            598\n#define OBJ_setct_CRLNotificationTBS            OBJ_set_ctype,80L\n\n#define SN_setct_CRLNotificationResTBS          \"setct-CRLNotificationResTBS\"\n#define NID_setct_CRLNotificationResTBS         599\n#define OBJ_setct_CRLNotificationResTBS         OBJ_set_ctype,81L\n\n#define SN_setct_BCIDistributionTBS             \"setct-BCIDistributionTBS\"\n#define NID_setct_BCIDistributionTBS            600\n#define OBJ_setct_BCIDistributionTBS            OBJ_set_ctype,82L\n\n#define SN_setext_genCrypt              \"setext-genCrypt\"\n#define LN_setext_genCrypt              \"generic cryptogram\"\n#define NID_setext_genCrypt             601\n#define OBJ_setext_genCrypt             OBJ_set_msgExt,1L\n\n#define SN_setext_miAuth                \"setext-miAuth\"\n#define LN_setext_miAuth                \"merchant initiated auth\"\n#define NID_setext_miAuth               602\n#define OBJ_setext_miAuth               OBJ_set_msgExt,3L\n\n#define SN_setext_pinSecure             \"setext-pinSecure\"\n#define NID_setext_pinSecure            603\n#define OBJ_setext_pinSecure            OBJ_set_msgExt,4L\n\n#define SN_setext_pinAny                \"setext-pinAny\"\n#define NID_setext_pinAny               604\n#define OBJ_setext_pinAny               OBJ_set_msgExt,5L\n\n#define SN_setext_track2                \"setext-track2\"\n#define NID_setext_track2               605\n#define OBJ_setext_track2               OBJ_set_msgExt,7L\n\n#define SN_setext_cv            \"setext-cv\"\n#define LN_setext_cv            \"additional verification\"\n#define NID_setext_cv           606\n#define OBJ_setext_cv           OBJ_set_msgExt,8L\n\n#define SN_set_policy_root              \"set-policy-root\"\n#define NID_set_policy_root             607\n#define OBJ_set_policy_root             OBJ_set_policy,0L\n\n#define SN_setCext_hashedRoot           \"setCext-hashedRoot\"\n#define NID_setCext_hashedRoot          608\n#define OBJ_setCext_hashedRoot          OBJ_set_certExt,0L\n\n#define SN_setCext_certType             \"setCext-certType\"\n#define NID_setCext_certType            609\n#define OBJ_setCext_certType            OBJ_set_certExt,1L\n\n#define SN_setCext_merchData            \"setCext-merchData\"\n#define NID_setCext_merchData           610\n#define OBJ_setCext_merchData           OBJ_set_certExt,2L\n\n#define SN_setCext_cCertRequired                \"setCext-cCertRequired\"\n#define NID_setCext_cCertRequired               611\n#define OBJ_setCext_cCertRequired               OBJ_set_certExt,3L\n\n#define SN_setCext_tunneling            \"setCext-tunneling\"\n#define NID_setCext_tunneling           612\n#define OBJ_setCext_tunneling           OBJ_set_certExt,4L\n\n#define SN_setCext_setExt               \"setCext-setExt\"\n#define NID_setCext_setExt              613\n#define OBJ_setCext_setExt              OBJ_set_certExt,5L\n\n#define SN_setCext_setQualf             \"setCext-setQualf\"\n#define NID_setCext_setQualf            614\n#define OBJ_setCext_setQualf            OBJ_set_certExt,6L\n\n#define SN_setCext_PGWYcapabilities             \"setCext-PGWYcapabilities\"\n#define NID_setCext_PGWYcapabilities            615\n#define OBJ_setCext_PGWYcapabilities            OBJ_set_certExt,7L\n\n#define SN_setCext_TokenIdentifier              \"setCext-TokenIdentifier\"\n#define NID_setCext_TokenIdentifier             616\n#define OBJ_setCext_TokenIdentifier             OBJ_set_certExt,8L\n\n#define SN_setCext_Track2Data           \"setCext-Track2Data\"\n#define NID_setCext_Track2Data          617\n#define OBJ_setCext_Track2Data          OBJ_set_certExt,9L\n\n#define SN_setCext_TokenType            \"setCext-TokenType\"\n#define NID_setCext_TokenType           618\n#define OBJ_setCext_TokenType           OBJ_set_certExt,10L\n\n#define SN_setCext_IssuerCapabilities           \"setCext-IssuerCapabilities\"\n#define NID_setCext_IssuerCapabilities          619\n#define OBJ_setCext_IssuerCapabilities          OBJ_set_certExt,11L\n\n#define SN_setAttr_Cert         \"setAttr-Cert\"\n#define NID_setAttr_Cert                620\n#define OBJ_setAttr_Cert                OBJ_set_attr,0L\n\n#define SN_setAttr_PGWYcap              \"setAttr-PGWYcap\"\n#define LN_setAttr_PGWYcap              \"payment gateway capabilities\"\n#define NID_setAttr_PGWYcap             621\n#define OBJ_setAttr_PGWYcap             OBJ_set_attr,1L\n\n#define SN_setAttr_TokenType            \"setAttr-TokenType\"\n#define NID_setAttr_TokenType           622\n#define OBJ_setAttr_TokenType           OBJ_set_attr,2L\n\n#define SN_setAttr_IssCap               \"setAttr-IssCap\"\n#define LN_setAttr_IssCap               \"issuer capabilities\"\n#define NID_setAttr_IssCap              623\n#define OBJ_setAttr_IssCap              OBJ_set_attr,3L\n\n#define SN_set_rootKeyThumb             \"set-rootKeyThumb\"\n#define NID_set_rootKeyThumb            624\n#define OBJ_set_rootKeyThumb            OBJ_setAttr_Cert,0L\n\n#define SN_set_addPolicy                \"set-addPolicy\"\n#define NID_set_addPolicy               625\n#define OBJ_set_addPolicy               OBJ_setAttr_Cert,1L\n\n#define SN_setAttr_Token_EMV            \"setAttr-Token-EMV\"\n#define NID_setAttr_Token_EMV           626\n#define OBJ_setAttr_Token_EMV           OBJ_setAttr_TokenType,1L\n\n#define SN_setAttr_Token_B0Prime                \"setAttr-Token-B0Prime\"\n#define NID_setAttr_Token_B0Prime               627\n#define OBJ_setAttr_Token_B0Prime               OBJ_setAttr_TokenType,2L\n\n#define SN_setAttr_IssCap_CVM           \"setAttr-IssCap-CVM\"\n#define NID_setAttr_IssCap_CVM          628\n#define OBJ_setAttr_IssCap_CVM          OBJ_setAttr_IssCap,3L\n\n#define SN_setAttr_IssCap_T2            \"setAttr-IssCap-T2\"\n#define NID_setAttr_IssCap_T2           629\n#define OBJ_setAttr_IssCap_T2           OBJ_setAttr_IssCap,4L\n\n#define SN_setAttr_IssCap_Sig           \"setAttr-IssCap-Sig\"\n#define NID_setAttr_IssCap_Sig          630\n#define OBJ_setAttr_IssCap_Sig          OBJ_setAttr_IssCap,5L\n\n#define SN_setAttr_GenCryptgrm          \"setAttr-GenCryptgrm\"\n#define LN_setAttr_GenCryptgrm          \"generate cryptogram\"\n#define NID_setAttr_GenCryptgrm         631\n#define OBJ_setAttr_GenCryptgrm         OBJ_setAttr_IssCap_CVM,1L\n\n#define SN_setAttr_T2Enc                \"setAttr-T2Enc\"\n#define LN_setAttr_T2Enc                \"encrypted track 2\"\n#define NID_setAttr_T2Enc               632\n#define OBJ_setAttr_T2Enc               OBJ_setAttr_IssCap_T2,1L\n\n#define SN_setAttr_T2cleartxt           \"setAttr-T2cleartxt\"\n#define LN_setAttr_T2cleartxt           \"cleartext track 2\"\n#define NID_setAttr_T2cleartxt          633\n#define OBJ_setAttr_T2cleartxt          OBJ_setAttr_IssCap_T2,2L\n\n#define SN_setAttr_TokICCsig            \"setAttr-TokICCsig\"\n#define LN_setAttr_TokICCsig            \"ICC or token signature\"\n#define NID_setAttr_TokICCsig           634\n#define OBJ_setAttr_TokICCsig           OBJ_setAttr_IssCap_Sig,1L\n\n#define SN_setAttr_SecDevSig            \"setAttr-SecDevSig\"\n#define LN_setAttr_SecDevSig            \"secure device signature\"\n#define NID_setAttr_SecDevSig           635\n#define OBJ_setAttr_SecDevSig           OBJ_setAttr_IssCap_Sig,2L\n\n#define SN_set_brand_IATA_ATA           \"set-brand-IATA-ATA\"\n#define NID_set_brand_IATA_ATA          636\n#define OBJ_set_brand_IATA_ATA          OBJ_set_brand,1L\n\n#define SN_set_brand_Diners             \"set-brand-Diners\"\n#define NID_set_brand_Diners            637\n#define OBJ_set_brand_Diners            OBJ_set_brand,30L\n\n#define SN_set_brand_AmericanExpress            \"set-brand-AmericanExpress\"\n#define NID_set_brand_AmericanExpress           638\n#define OBJ_set_brand_AmericanExpress           OBJ_set_brand,34L\n\n#define SN_set_brand_JCB                \"set-brand-JCB\"\n#define NID_set_brand_JCB               639\n#define OBJ_set_brand_JCB               OBJ_set_brand,35L\n\n#define SN_set_brand_Visa               \"set-brand-Visa\"\n#define NID_set_brand_Visa              640\n#define OBJ_set_brand_Visa              OBJ_set_brand,4L\n\n#define SN_set_brand_MasterCard         \"set-brand-MasterCard\"\n#define NID_set_brand_MasterCard                641\n#define OBJ_set_brand_MasterCard                OBJ_set_brand,5L\n\n#define SN_set_brand_Novus              \"set-brand-Novus\"\n#define NID_set_brand_Novus             642\n#define OBJ_set_brand_Novus             OBJ_set_brand,6011L\n\n#define SN_des_cdmf             \"DES-CDMF\"\n#define LN_des_cdmf             \"des-cdmf\"\n#define NID_des_cdmf            643\n#define OBJ_des_cdmf            OBJ_rsadsi,3L,10L\n\n#define SN_rsaOAEPEncryptionSET         \"rsaOAEPEncryptionSET\"\n#define NID_rsaOAEPEncryptionSET                644\n#define OBJ_rsaOAEPEncryptionSET                OBJ_rsadsi,1L,1L,6L\n\n#define SN_ipsec3               \"Oakley-EC2N-3\"\n#define LN_ipsec3               \"ipsec3\"\n#define NID_ipsec3              749\n\n#define SN_ipsec4               \"Oakley-EC2N-4\"\n#define LN_ipsec4               \"ipsec4\"\n#define NID_ipsec4              750\n\n#define SN_whirlpool            \"whirlpool\"\n#define NID_whirlpool           804\n#define OBJ_whirlpool           OBJ_iso,0L,10118L,3L,0L,55L\n\n#define SN_cryptopro            \"cryptopro\"\n#define NID_cryptopro           805\n#define OBJ_cryptopro           OBJ_member_body,643L,2L,2L\n\n#define SN_cryptocom            \"cryptocom\"\n#define NID_cryptocom           806\n#define OBJ_cryptocom           OBJ_member_body,643L,2L,9L\n\n#define SN_id_GostR3411_94_with_GostR3410_2001          \"id-GostR3411-94-with-GostR3410-2001\"\n#define LN_id_GostR3411_94_with_GostR3410_2001          \"GOST R 34.11-94 with GOST R 34.10-2001\"\n#define NID_id_GostR3411_94_with_GostR3410_2001         807\n#define OBJ_id_GostR3411_94_with_GostR3410_2001         OBJ_cryptopro,3L\n\n#define SN_id_GostR3411_94_with_GostR3410_94            \"id-GostR3411-94-with-GostR3410-94\"\n#define LN_id_GostR3411_94_with_GostR3410_94            \"GOST R 34.11-94 with GOST R 34.10-94\"\n#define NID_id_GostR3411_94_with_GostR3410_94           808\n#define OBJ_id_GostR3411_94_with_GostR3410_94           OBJ_cryptopro,4L\n\n#define SN_id_GostR3411_94              \"md_gost94\"\n#define LN_id_GostR3411_94              \"GOST R 34.11-94\"\n#define NID_id_GostR3411_94             809\n#define OBJ_id_GostR3411_94             OBJ_cryptopro,9L\n\n#define SN_id_HMACGostR3411_94          \"id-HMACGostR3411-94\"\n#define LN_id_HMACGostR3411_94          \"HMAC GOST 34.11-94\"\n#define NID_id_HMACGostR3411_94         810\n#define OBJ_id_HMACGostR3411_94         OBJ_cryptopro,10L\n\n#define SN_id_GostR3410_2001            \"gost2001\"\n#define LN_id_GostR3410_2001            \"GOST R 34.10-2001\"\n#define NID_id_GostR3410_2001           811\n#define OBJ_id_GostR3410_2001           OBJ_cryptopro,19L\n\n#define SN_id_GostR3410_94              \"gost94\"\n#define LN_id_GostR3410_94              \"GOST R 34.10-94\"\n#define NID_id_GostR3410_94             812\n#define OBJ_id_GostR3410_94             OBJ_cryptopro,20L\n\n#define SN_id_Gost28147_89              \"gost89\"\n#define LN_id_Gost28147_89              \"GOST 28147-89\"\n#define NID_id_Gost28147_89             813\n#define OBJ_id_Gost28147_89             OBJ_cryptopro,21L\n\n#define SN_gost89_cnt           \"gost89-cnt\"\n#define NID_gost89_cnt          814\n\n#define SN_id_Gost28147_89_MAC          \"gost-mac\"\n#define LN_id_Gost28147_89_MAC          \"GOST 28147-89 MAC\"\n#define NID_id_Gost28147_89_MAC         815\n#define OBJ_id_Gost28147_89_MAC         OBJ_cryptopro,22L\n\n#define SN_id_GostR3411_94_prf          \"prf-gostr3411-94\"\n#define LN_id_GostR3411_94_prf          \"GOST R 34.11-94 PRF\"\n#define NID_id_GostR3411_94_prf         816\n#define OBJ_id_GostR3411_94_prf         OBJ_cryptopro,23L\n\n#define SN_id_GostR3410_2001DH          \"id-GostR3410-2001DH\"\n#define LN_id_GostR3410_2001DH          \"GOST R 34.10-2001 DH\"\n#define NID_id_GostR3410_2001DH         817\n#define OBJ_id_GostR3410_2001DH         OBJ_cryptopro,98L\n\n#define SN_id_GostR3410_94DH            \"id-GostR3410-94DH\"\n#define LN_id_GostR3410_94DH            \"GOST R 34.10-94 DH\"\n#define NID_id_GostR3410_94DH           818\n#define OBJ_id_GostR3410_94DH           OBJ_cryptopro,99L\n\n#define SN_id_Gost28147_89_CryptoPro_KeyMeshing         \"id-Gost28147-89-CryptoPro-KeyMeshing\"\n#define NID_id_Gost28147_89_CryptoPro_KeyMeshing                819\n#define OBJ_id_Gost28147_89_CryptoPro_KeyMeshing                OBJ_cryptopro,14L,1L\n\n#define SN_id_Gost28147_89_None_KeyMeshing              \"id-Gost28147-89-None-KeyMeshing\"\n#define NID_id_Gost28147_89_None_KeyMeshing             820\n#define OBJ_id_Gost28147_89_None_KeyMeshing             OBJ_cryptopro,14L,0L\n\n#define SN_id_GostR3411_94_TestParamSet         \"id-GostR3411-94-TestParamSet\"\n#define NID_id_GostR3411_94_TestParamSet                821\n#define OBJ_id_GostR3411_94_TestParamSet                OBJ_cryptopro,30L,0L\n\n#define SN_id_GostR3411_94_CryptoProParamSet            \"id-GostR3411-94-CryptoProParamSet\"\n#define NID_id_GostR3411_94_CryptoProParamSet           822\n#define OBJ_id_GostR3411_94_CryptoProParamSet           OBJ_cryptopro,30L,1L\n\n#define SN_id_Gost28147_89_TestParamSet         \"id-Gost28147-89-TestParamSet\"\n#define NID_id_Gost28147_89_TestParamSet                823\n#define OBJ_id_Gost28147_89_TestParamSet                OBJ_cryptopro,31L,0L\n\n#define SN_id_Gost28147_89_CryptoPro_A_ParamSet         \"id-Gost28147-89-CryptoPro-A-ParamSet\"\n#define NID_id_Gost28147_89_CryptoPro_A_ParamSet                824\n#define OBJ_id_Gost28147_89_CryptoPro_A_ParamSet                OBJ_cryptopro,31L,1L\n\n#define SN_id_Gost28147_89_CryptoPro_B_ParamSet         \"id-Gost28147-89-CryptoPro-B-ParamSet\"\n#define NID_id_Gost28147_89_CryptoPro_B_ParamSet                825\n#define OBJ_id_Gost28147_89_CryptoPro_B_ParamSet                OBJ_cryptopro,31L,2L\n\n#define SN_id_Gost28147_89_CryptoPro_C_ParamSet         \"id-Gost28147-89-CryptoPro-C-ParamSet\"\n#define NID_id_Gost28147_89_CryptoPro_C_ParamSet                826\n#define OBJ_id_Gost28147_89_CryptoPro_C_ParamSet                OBJ_cryptopro,31L,3L\n\n#define SN_id_Gost28147_89_CryptoPro_D_ParamSet         \"id-Gost28147-89-CryptoPro-D-ParamSet\"\n#define NID_id_Gost28147_89_CryptoPro_D_ParamSet                827\n#define OBJ_id_Gost28147_89_CryptoPro_D_ParamSet                OBJ_cryptopro,31L,4L\n\n#define SN_id_Gost28147_89_CryptoPro_Oscar_1_1_ParamSet         \"id-Gost28147-89-CryptoPro-Oscar-1-1-ParamSet\"\n#define NID_id_Gost28147_89_CryptoPro_Oscar_1_1_ParamSet                828\n#define OBJ_id_Gost28147_89_CryptoPro_Oscar_1_1_ParamSet                OBJ_cryptopro,31L,5L\n\n#define SN_id_Gost28147_89_CryptoPro_Oscar_1_0_ParamSet         \"id-Gost28147-89-CryptoPro-Oscar-1-0-ParamSet\"\n#define NID_id_Gost28147_89_CryptoPro_Oscar_1_0_ParamSet                829\n#define OBJ_id_Gost28147_89_CryptoPro_Oscar_1_0_ParamSet                OBJ_cryptopro,31L,6L\n\n#define SN_id_Gost28147_89_CryptoPro_RIC_1_ParamSet             \"id-Gost28147-89-CryptoPro-RIC-1-ParamSet\"\n#define NID_id_Gost28147_89_CryptoPro_RIC_1_ParamSet            830\n#define OBJ_id_Gost28147_89_CryptoPro_RIC_1_ParamSet            OBJ_cryptopro,31L,7L\n\n#define SN_id_GostR3410_94_TestParamSet         \"id-GostR3410-94-TestParamSet\"\n#define NID_id_GostR3410_94_TestParamSet                831\n#define OBJ_id_GostR3410_94_TestParamSet                OBJ_cryptopro,32L,0L\n\n#define SN_id_GostR3410_94_CryptoPro_A_ParamSet         \"id-GostR3410-94-CryptoPro-A-ParamSet\"\n#define NID_id_GostR3410_94_CryptoPro_A_ParamSet                832\n#define OBJ_id_GostR3410_94_CryptoPro_A_ParamSet                OBJ_cryptopro,32L,2L\n\n#define SN_id_GostR3410_94_CryptoPro_B_ParamSet         \"id-GostR3410-94-CryptoPro-B-ParamSet\"\n#define NID_id_GostR3410_94_CryptoPro_B_ParamSet                833\n#define OBJ_id_GostR3410_94_CryptoPro_B_ParamSet                OBJ_cryptopro,32L,3L\n\n#define SN_id_GostR3410_94_CryptoPro_C_ParamSet         \"id-GostR3410-94-CryptoPro-C-ParamSet\"\n#define NID_id_GostR3410_94_CryptoPro_C_ParamSet                834\n#define OBJ_id_GostR3410_94_CryptoPro_C_ParamSet                OBJ_cryptopro,32L,4L\n\n#define SN_id_GostR3410_94_CryptoPro_D_ParamSet         \"id-GostR3410-94-CryptoPro-D-ParamSet\"\n#define NID_id_GostR3410_94_CryptoPro_D_ParamSet                835\n#define OBJ_id_GostR3410_94_CryptoPro_D_ParamSet                OBJ_cryptopro,32L,5L\n\n#define SN_id_GostR3410_94_CryptoPro_XchA_ParamSet              \"id-GostR3410-94-CryptoPro-XchA-ParamSet\"\n#define NID_id_GostR3410_94_CryptoPro_XchA_ParamSet             836\n#define OBJ_id_GostR3410_94_CryptoPro_XchA_ParamSet             OBJ_cryptopro,33L,1L\n\n#define SN_id_GostR3410_94_CryptoPro_XchB_ParamSet              \"id-GostR3410-94-CryptoPro-XchB-ParamSet\"\n#define NID_id_GostR3410_94_CryptoPro_XchB_ParamSet             837\n#define OBJ_id_GostR3410_94_CryptoPro_XchB_ParamSet             OBJ_cryptopro,33L,2L\n\n#define SN_id_GostR3410_94_CryptoPro_XchC_ParamSet              \"id-GostR3410-94-CryptoPro-XchC-ParamSet\"\n#define NID_id_GostR3410_94_CryptoPro_XchC_ParamSet             838\n#define OBJ_id_GostR3410_94_CryptoPro_XchC_ParamSet             OBJ_cryptopro,33L,3L\n\n#define SN_id_GostR3410_2001_TestParamSet               \"id-GostR3410-2001-TestParamSet\"\n#define NID_id_GostR3410_2001_TestParamSet              839\n#define OBJ_id_GostR3410_2001_TestParamSet              OBJ_cryptopro,35L,0L\n\n#define SN_id_GostR3410_2001_CryptoPro_A_ParamSet               \"id-GostR3410-2001-CryptoPro-A-ParamSet\"\n#define NID_id_GostR3410_2001_CryptoPro_A_ParamSet              840\n#define OBJ_id_GostR3410_2001_CryptoPro_A_ParamSet              OBJ_cryptopro,35L,1L\n\n#define SN_id_GostR3410_2001_CryptoPro_B_ParamSet               \"id-GostR3410-2001-CryptoPro-B-ParamSet\"\n#define NID_id_GostR3410_2001_CryptoPro_B_ParamSet              841\n#define OBJ_id_GostR3410_2001_CryptoPro_B_ParamSet              OBJ_cryptopro,35L,2L\n\n#define SN_id_GostR3410_2001_CryptoPro_C_ParamSet               \"id-GostR3410-2001-CryptoPro-C-ParamSet\"\n#define NID_id_GostR3410_2001_CryptoPro_C_ParamSet              842\n#define OBJ_id_GostR3410_2001_CryptoPro_C_ParamSet              OBJ_cryptopro,35L,3L\n\n#define SN_id_GostR3410_2001_CryptoPro_XchA_ParamSet            \"id-GostR3410-2001-CryptoPro-XchA-ParamSet\"\n#define NID_id_GostR3410_2001_CryptoPro_XchA_ParamSet           843\n#define OBJ_id_GostR3410_2001_CryptoPro_XchA_ParamSet           OBJ_cryptopro,36L,0L\n\n#define SN_id_GostR3410_2001_CryptoPro_XchB_ParamSet            \"id-GostR3410-2001-CryptoPro-XchB-ParamSet\"\n#define NID_id_GostR3410_2001_CryptoPro_XchB_ParamSet           844\n#define OBJ_id_GostR3410_2001_CryptoPro_XchB_ParamSet           OBJ_cryptopro,36L,1L\n\n#define SN_id_GostR3410_94_a            \"id-GostR3410-94-a\"\n#define NID_id_GostR3410_94_a           845\n#define OBJ_id_GostR3410_94_a           OBJ_id_GostR3410_94,1L\n\n#define SN_id_GostR3410_94_aBis         \"id-GostR3410-94-aBis\"\n#define NID_id_GostR3410_94_aBis                846\n#define OBJ_id_GostR3410_94_aBis                OBJ_id_GostR3410_94,2L\n\n#define SN_id_GostR3410_94_b            \"id-GostR3410-94-b\"\n#define NID_id_GostR3410_94_b           847\n#define OBJ_id_GostR3410_94_b           OBJ_id_GostR3410_94,3L\n\n#define SN_id_GostR3410_94_bBis         \"id-GostR3410-94-bBis\"\n#define NID_id_GostR3410_94_bBis                848\n#define OBJ_id_GostR3410_94_bBis                OBJ_id_GostR3410_94,4L\n\n#define SN_id_Gost28147_89_cc           \"id-Gost28147-89-cc\"\n#define LN_id_Gost28147_89_cc           \"GOST 28147-89 Cryptocom ParamSet\"\n#define NID_id_Gost28147_89_cc          849\n#define OBJ_id_Gost28147_89_cc          OBJ_cryptocom,1L,6L,1L\n\n#define SN_id_GostR3410_94_cc           \"gost94cc\"\n#define LN_id_GostR3410_94_cc           \"GOST 34.10-94 Cryptocom\"\n#define NID_id_GostR3410_94_cc          850\n#define OBJ_id_GostR3410_94_cc          OBJ_cryptocom,1L,5L,3L\n\n#define SN_id_GostR3410_2001_cc         \"gost2001cc\"\n#define LN_id_GostR3410_2001_cc         \"GOST 34.10-2001 Cryptocom\"\n#define NID_id_GostR3410_2001_cc                851\n#define OBJ_id_GostR3410_2001_cc                OBJ_cryptocom,1L,5L,4L\n\n#define SN_id_GostR3411_94_with_GostR3410_94_cc         \"id-GostR3411-94-with-GostR3410-94-cc\"\n#define LN_id_GostR3411_94_with_GostR3410_94_cc         \"GOST R 34.11-94 with GOST R 34.10-94 Cryptocom\"\n#define NID_id_GostR3411_94_with_GostR3410_94_cc                852\n#define OBJ_id_GostR3411_94_with_GostR3410_94_cc                OBJ_cryptocom,1L,3L,3L\n\n#define SN_id_GostR3411_94_with_GostR3410_2001_cc               \"id-GostR3411-94-with-GostR3410-2001-cc\"\n#define LN_id_GostR3411_94_with_GostR3410_2001_cc               \"GOST R 34.11-94 with GOST R 34.10-2001 Cryptocom\"\n#define NID_id_GostR3411_94_with_GostR3410_2001_cc              853\n#define OBJ_id_GostR3411_94_with_GostR3410_2001_cc              OBJ_cryptocom,1L,3L,4L\n\n#define SN_id_GostR3410_2001_ParamSet_cc                \"id-GostR3410-2001-ParamSet-cc\"\n#define LN_id_GostR3410_2001_ParamSet_cc                \"GOST R 3410-2001 Parameter Set Cryptocom\"\n#define NID_id_GostR3410_2001_ParamSet_cc               854\n#define OBJ_id_GostR3410_2001_ParamSet_cc               OBJ_cryptocom,1L,8L,1L\n\n#define SN_camellia_128_cbc             \"CAMELLIA-128-CBC\"\n#define LN_camellia_128_cbc             \"camellia-128-cbc\"\n#define NID_camellia_128_cbc            751\n#define OBJ_camellia_128_cbc            1L,2L,392L,200011L,61L,1L,1L,1L,2L\n\n#define SN_camellia_192_cbc             \"CAMELLIA-192-CBC\"\n#define LN_camellia_192_cbc             \"camellia-192-cbc\"\n#define NID_camellia_192_cbc            752\n#define OBJ_camellia_192_cbc            1L,2L,392L,200011L,61L,1L,1L,1L,3L\n\n#define SN_camellia_256_cbc             \"CAMELLIA-256-CBC\"\n#define LN_camellia_256_cbc             \"camellia-256-cbc\"\n#define NID_camellia_256_cbc            753\n#define OBJ_camellia_256_cbc            1L,2L,392L,200011L,61L,1L,1L,1L,4L\n\n#define SN_id_camellia128_wrap          \"id-camellia128-wrap\"\n#define NID_id_camellia128_wrap         907\n#define OBJ_id_camellia128_wrap         1L,2L,392L,200011L,61L,1L,1L,3L,2L\n\n#define SN_id_camellia192_wrap          \"id-camellia192-wrap\"\n#define NID_id_camellia192_wrap         908\n#define OBJ_id_camellia192_wrap         1L,2L,392L,200011L,61L,1L,1L,3L,3L\n\n#define SN_id_camellia256_wrap          \"id-camellia256-wrap\"\n#define NID_id_camellia256_wrap         909\n#define OBJ_id_camellia256_wrap         1L,2L,392L,200011L,61L,1L,1L,3L,4L\n\n#define OBJ_ntt_ds              0L,3L,4401L,5L\n\n#define OBJ_camellia            OBJ_ntt_ds,3L,1L,9L\n\n#define SN_camellia_128_ecb             \"CAMELLIA-128-ECB\"\n#define LN_camellia_128_ecb             \"camellia-128-ecb\"\n#define NID_camellia_128_ecb            754\n#define OBJ_camellia_128_ecb            OBJ_camellia,1L\n\n#define SN_camellia_128_ofb128          \"CAMELLIA-128-OFB\"\n#define LN_camellia_128_ofb128          \"camellia-128-ofb\"\n#define NID_camellia_128_ofb128         766\n#define OBJ_camellia_128_ofb128         OBJ_camellia,3L\n\n#define SN_camellia_128_cfb128          \"CAMELLIA-128-CFB\"\n#define LN_camellia_128_cfb128          \"camellia-128-cfb\"\n#define NID_camellia_128_cfb128         757\n#define OBJ_camellia_128_cfb128         OBJ_camellia,4L\n\n#define SN_camellia_192_ecb             \"CAMELLIA-192-ECB\"\n#define LN_camellia_192_ecb             \"camellia-192-ecb\"\n#define NID_camellia_192_ecb            755\n#define OBJ_camellia_192_ecb            OBJ_camellia,21L\n\n#define SN_camellia_192_ofb128          \"CAMELLIA-192-OFB\"\n#define LN_camellia_192_ofb128          \"camellia-192-ofb\"\n#define NID_camellia_192_ofb128         767\n#define OBJ_camellia_192_ofb128         OBJ_camellia,23L\n\n#define SN_camellia_192_cfb128          \"CAMELLIA-192-CFB\"\n#define LN_camellia_192_cfb128          \"camellia-192-cfb\"\n#define NID_camellia_192_cfb128         758\n#define OBJ_camellia_192_cfb128         OBJ_camellia,24L\n\n#define SN_camellia_256_ecb             \"CAMELLIA-256-ECB\"\n#define LN_camellia_256_ecb             \"camellia-256-ecb\"\n#define NID_camellia_256_ecb            756\n#define OBJ_camellia_256_ecb            OBJ_camellia,41L\n\n#define SN_camellia_256_ofb128          \"CAMELLIA-256-OFB\"\n#define LN_camellia_256_ofb128          \"camellia-256-ofb\"\n#define NID_camellia_256_ofb128         768\n#define OBJ_camellia_256_ofb128         OBJ_camellia,43L\n\n#define SN_camellia_256_cfb128          \"CAMELLIA-256-CFB\"\n#define LN_camellia_256_cfb128          \"camellia-256-cfb\"\n#define NID_camellia_256_cfb128         759\n#define OBJ_camellia_256_cfb128         OBJ_camellia,44L\n\n#define SN_camellia_128_cfb1            \"CAMELLIA-128-CFB1\"\n#define LN_camellia_128_cfb1            \"camellia-128-cfb1\"\n#define NID_camellia_128_cfb1           760\n\n#define SN_camellia_192_cfb1            \"CAMELLIA-192-CFB1\"\n#define LN_camellia_192_cfb1            \"camellia-192-cfb1\"\n#define NID_camellia_192_cfb1           761\n\n#define SN_camellia_256_cfb1            \"CAMELLIA-256-CFB1\"\n#define LN_camellia_256_cfb1            \"camellia-256-cfb1\"\n#define NID_camellia_256_cfb1           762\n\n#define SN_camellia_128_cfb8            \"CAMELLIA-128-CFB8\"\n#define LN_camellia_128_cfb8            \"camellia-128-cfb8\"\n#define NID_camellia_128_cfb8           763\n\n#define SN_camellia_192_cfb8            \"CAMELLIA-192-CFB8\"\n#define LN_camellia_192_cfb8            \"camellia-192-cfb8\"\n#define NID_camellia_192_cfb8           764\n\n#define SN_camellia_256_cfb8            \"CAMELLIA-256-CFB8\"\n#define LN_camellia_256_cfb8            \"camellia-256-cfb8\"\n#define NID_camellia_256_cfb8           765\n\n#define SN_kisa         \"KISA\"\n#define LN_kisa         \"kisa\"\n#define NID_kisa                773\n#define OBJ_kisa                OBJ_member_body,410L,200004L\n\n#define SN_seed_ecb             \"SEED-ECB\"\n#define LN_seed_ecb             \"seed-ecb\"\n#define NID_seed_ecb            776\n#define OBJ_seed_ecb            OBJ_kisa,1L,3L\n\n#define SN_seed_cbc             \"SEED-CBC\"\n#define LN_seed_cbc             \"seed-cbc\"\n#define NID_seed_cbc            777\n#define OBJ_seed_cbc            OBJ_kisa,1L,4L\n\n#define SN_seed_cfb128          \"SEED-CFB\"\n#define LN_seed_cfb128          \"seed-cfb\"\n#define NID_seed_cfb128         779\n#define OBJ_seed_cfb128         OBJ_kisa,1L,5L\n\n#define SN_seed_ofb128          \"SEED-OFB\"\n#define LN_seed_ofb128          \"seed-ofb\"\n#define NID_seed_ofb128         778\n#define OBJ_seed_ofb128         OBJ_kisa,1L,6L\n\n#define SN_hmac         \"HMAC\"\n#define LN_hmac         \"hmac\"\n#define NID_hmac                855\n\n#define SN_cmac         \"CMAC\"\n#define LN_cmac         \"cmac\"\n#define NID_cmac                894\n\n#define SN_rc4_hmac_md5         \"RC4-HMAC-MD5\"\n#define LN_rc4_hmac_md5         \"rc4-hmac-md5\"\n#define NID_rc4_hmac_md5                915\n\n#define SN_aes_128_cbc_hmac_sha1                \"AES-128-CBC-HMAC-SHA1\"\n#define LN_aes_128_cbc_hmac_sha1                \"aes-128-cbc-hmac-sha1\"\n#define NID_aes_128_cbc_hmac_sha1               916\n\n#define SN_aes_192_cbc_hmac_sha1                \"AES-192-CBC-HMAC-SHA1\"\n#define LN_aes_192_cbc_hmac_sha1                \"aes-192-cbc-hmac-sha1\"\n#define NID_aes_192_cbc_hmac_sha1               917\n\n#define SN_aes_256_cbc_hmac_sha1                \"AES-256-CBC-HMAC-SHA1\"\n#define LN_aes_256_cbc_hmac_sha1                \"aes-256-cbc-hmac-sha1\"\n#define NID_aes_256_cbc_hmac_sha1               918\n\n#define SN_aes_128_cbc_hmac_sha256              \"AES-128-CBC-HMAC-SHA256\"\n#define LN_aes_128_cbc_hmac_sha256              \"aes-128-cbc-hmac-sha256\"\n#define NID_aes_128_cbc_hmac_sha256             948\n\n#define SN_aes_192_cbc_hmac_sha256              \"AES-192-CBC-HMAC-SHA256\"\n#define LN_aes_192_cbc_hmac_sha256              \"aes-192-cbc-hmac-sha256\"\n#define NID_aes_192_cbc_hmac_sha256             949\n\n#define SN_aes_256_cbc_hmac_sha256              \"AES-256-CBC-HMAC-SHA256\"\n#define LN_aes_256_cbc_hmac_sha256              \"aes-256-cbc-hmac-sha256\"\n#define NID_aes_256_cbc_hmac_sha256             950\n\n#define SN_dhpublicnumber               \"dhpublicnumber\"\n#define LN_dhpublicnumber               \"X9.42 DH\"\n#define NID_dhpublicnumber              920\n#define OBJ_dhpublicnumber              OBJ_ISO_US,10046L,2L,1L\n\n#define SN_brainpoolP160r1              \"brainpoolP160r1\"\n#define NID_brainpoolP160r1             921\n#define OBJ_brainpoolP160r1             1L,3L,36L,3L,3L,2L,8L,1L,1L,1L\n\n#define SN_brainpoolP160t1              \"brainpoolP160t1\"\n#define NID_brainpoolP160t1             922\n#define OBJ_brainpoolP160t1             1L,3L,36L,3L,3L,2L,8L,1L,1L,2L\n\n#define SN_brainpoolP192r1              \"brainpoolP192r1\"\n#define NID_brainpoolP192r1             923\n#define OBJ_brainpoolP192r1             1L,3L,36L,3L,3L,2L,8L,1L,1L,3L\n\n#define SN_brainpoolP192t1              \"brainpoolP192t1\"\n#define NID_brainpoolP192t1             924\n#define OBJ_brainpoolP192t1             1L,3L,36L,3L,3L,2L,8L,1L,1L,4L\n\n#define SN_brainpoolP224r1              \"brainpoolP224r1\"\n#define NID_brainpoolP224r1             925\n#define OBJ_brainpoolP224r1             1L,3L,36L,3L,3L,2L,8L,1L,1L,5L\n\n#define SN_brainpoolP224t1              \"brainpoolP224t1\"\n#define NID_brainpoolP224t1             926\n#define OBJ_brainpoolP224t1             1L,3L,36L,3L,3L,2L,8L,1L,1L,6L\n\n#define SN_brainpoolP256r1              \"brainpoolP256r1\"\n#define NID_brainpoolP256r1             927\n#define OBJ_brainpoolP256r1             1L,3L,36L,3L,3L,2L,8L,1L,1L,7L\n\n#define SN_brainpoolP256t1              \"brainpoolP256t1\"\n#define NID_brainpoolP256t1             928\n#define OBJ_brainpoolP256t1             1L,3L,36L,3L,3L,2L,8L,1L,1L,8L\n\n#define SN_brainpoolP320r1              \"brainpoolP320r1\"\n#define NID_brainpoolP320r1             929\n#define OBJ_brainpoolP320r1             1L,3L,36L,3L,3L,2L,8L,1L,1L,9L\n\n#define SN_brainpoolP320t1              \"brainpoolP320t1\"\n#define NID_brainpoolP320t1             930\n#define OBJ_brainpoolP320t1             1L,3L,36L,3L,3L,2L,8L,1L,1L,10L\n\n#define SN_brainpoolP384r1              \"brainpoolP384r1\"\n#define NID_brainpoolP384r1             931\n#define OBJ_brainpoolP384r1             1L,3L,36L,3L,3L,2L,8L,1L,1L,11L\n\n#define SN_brainpoolP384t1              \"brainpoolP384t1\"\n#define NID_brainpoolP384t1             932\n#define OBJ_brainpoolP384t1             1L,3L,36L,3L,3L,2L,8L,1L,1L,12L\n\n#define SN_brainpoolP512r1              \"brainpoolP512r1\"\n#define NID_brainpoolP512r1             933\n#define OBJ_brainpoolP512r1             1L,3L,36L,3L,3L,2L,8L,1L,1L,13L\n\n#define SN_brainpoolP512t1              \"brainpoolP512t1\"\n#define NID_brainpoolP512t1             934\n#define OBJ_brainpoolP512t1             1L,3L,36L,3L,3L,2L,8L,1L,1L,14L\n\n#define OBJ_x9_63_scheme                1L,3L,133L,16L,840L,63L,0L\n\n#define OBJ_secg_scheme         OBJ_certicom_arc,1L\n\n#define SN_dhSinglePass_stdDH_sha1kdf_scheme            \"dhSinglePass-stdDH-sha1kdf-scheme\"\n#define NID_dhSinglePass_stdDH_sha1kdf_scheme           936\n#define OBJ_dhSinglePass_stdDH_sha1kdf_scheme           OBJ_x9_63_scheme,2L\n\n#define SN_dhSinglePass_stdDH_sha224kdf_scheme          \"dhSinglePass-stdDH-sha224kdf-scheme\"\n#define NID_dhSinglePass_stdDH_sha224kdf_scheme         937\n#define OBJ_dhSinglePass_stdDH_sha224kdf_scheme         OBJ_secg_scheme,11L,0L\n\n#define SN_dhSinglePass_stdDH_sha256kdf_scheme          \"dhSinglePass-stdDH-sha256kdf-scheme\"\n#define NID_dhSinglePass_stdDH_sha256kdf_scheme         938\n#define OBJ_dhSinglePass_stdDH_sha256kdf_scheme         OBJ_secg_scheme,11L,1L\n\n#define SN_dhSinglePass_stdDH_sha384kdf_scheme          \"dhSinglePass-stdDH-sha384kdf-scheme\"\n#define NID_dhSinglePass_stdDH_sha384kdf_scheme         939\n#define OBJ_dhSinglePass_stdDH_sha384kdf_scheme         OBJ_secg_scheme,11L,2L\n\n#define SN_dhSinglePass_stdDH_sha512kdf_scheme          \"dhSinglePass-stdDH-sha512kdf-scheme\"\n#define NID_dhSinglePass_stdDH_sha512kdf_scheme         940\n#define OBJ_dhSinglePass_stdDH_sha512kdf_scheme         OBJ_secg_scheme,11L,3L\n\n#define SN_dhSinglePass_cofactorDH_sha1kdf_scheme               \"dhSinglePass-cofactorDH-sha1kdf-scheme\"\n#define NID_dhSinglePass_cofactorDH_sha1kdf_scheme              941\n#define OBJ_dhSinglePass_cofactorDH_sha1kdf_scheme              OBJ_x9_63_scheme,3L\n\n#define SN_dhSinglePass_cofactorDH_sha224kdf_scheme             \"dhSinglePass-cofactorDH-sha224kdf-scheme\"\n#define NID_dhSinglePass_cofactorDH_sha224kdf_scheme            942\n#define OBJ_dhSinglePass_cofactorDH_sha224kdf_scheme            OBJ_secg_scheme,14L,0L\n\n#define SN_dhSinglePass_cofactorDH_sha256kdf_scheme             \"dhSinglePass-cofactorDH-sha256kdf-scheme\"\n#define NID_dhSinglePass_cofactorDH_sha256kdf_scheme            943\n#define OBJ_dhSinglePass_cofactorDH_sha256kdf_scheme            OBJ_secg_scheme,14L,1L\n\n#define SN_dhSinglePass_cofactorDH_sha384kdf_scheme             \"dhSinglePass-cofactorDH-sha384kdf-scheme\"\n#define NID_dhSinglePass_cofactorDH_sha384kdf_scheme            944\n#define OBJ_dhSinglePass_cofactorDH_sha384kdf_scheme            OBJ_secg_scheme,14L,2L\n\n#define SN_dhSinglePass_cofactorDH_sha512kdf_scheme             \"dhSinglePass-cofactorDH-sha512kdf-scheme\"\n#define NID_dhSinglePass_cofactorDH_sha512kdf_scheme            945\n#define OBJ_dhSinglePass_cofactorDH_sha512kdf_scheme            OBJ_secg_scheme,14L,3L\n\n#define SN_dh_std_kdf           \"dh-std-kdf\"\n#define NID_dh_std_kdf          946\n\n#define SN_dh_cofactor_kdf              \"dh-cofactor-kdf\"\n#define NID_dh_cofactor_kdf             947\n\n#define SN_ct_precert_scts              \"ct_precert_scts\"\n#define LN_ct_precert_scts              \"CT Precertificate SCTs\"\n#define NID_ct_precert_scts             951\n#define OBJ_ct_precert_scts             1L,3L,6L,1L,4L,1L,11129L,2L,4L,2L\n\n#define SN_ct_precert_poison            \"ct_precert_poison\"\n#define LN_ct_precert_poison            \"CT Precertificate Poison\"\n#define NID_ct_precert_poison           952\n#define OBJ_ct_precert_poison           1L,3L,6L,1L,4L,1L,11129L,2L,4L,3L\n\n#define SN_ct_precert_signer            \"ct_precert_signer\"\n#define LN_ct_precert_signer            \"CT Precertificate Signer\"\n#define NID_ct_precert_signer           953\n#define OBJ_ct_precert_signer           1L,3L,6L,1L,4L,1L,11129L,2L,4L,4L\n\n#define SN_ct_cert_scts         \"ct_cert_scts\"\n#define LN_ct_cert_scts         \"CT Certificate SCTs\"\n#define NID_ct_cert_scts                954\n#define OBJ_ct_cert_scts                1L,3L,6L,1L,4L,1L,11129L,2L,4L,5L\n\n#define SN_jurisdictionLocalityName             \"jurisdictionL\"\n#define LN_jurisdictionLocalityName             \"jurisdictionLocalityName\"\n#define NID_jurisdictionLocalityName            955\n#define OBJ_jurisdictionLocalityName            1L,3L,6L,1L,4L,1L,311L,60L,2L,1L,1L\n\n#define SN_jurisdictionStateOrProvinceName              \"jurisdictionST\"\n#define LN_jurisdictionStateOrProvinceName              \"jurisdictionStateOrProvinceName\"\n#define NID_jurisdictionStateOrProvinceName             956\n#define OBJ_jurisdictionStateOrProvinceName             1L,3L,6L,1L,4L,1L,311L,60L,2L,1L,2L\n\n#define SN_jurisdictionCountryName              \"jurisdictionC\"\n#define LN_jurisdictionCountryName              \"jurisdictionCountryName\"\n#define NID_jurisdictionCountryName             957\n#define OBJ_jurisdictionCountryName             1L,3L,6L,1L,4L,1L,311L,60L,2L,1L,3L\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/arm64/include/openssl/objects.h",
    "content": "/* crypto/objects/objects.h */\n/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)\n * All rights reserved.\n *\n * This package is an SSL implementation written\n * by Eric Young (eay@cryptsoft.com).\n * The implementation was written so as to conform with Netscapes SSL.\n *\n * This library is free for commercial and non-commercial use as long as\n * the following conditions are aheared to.  The following conditions\n * apply to all code found in this distribution, be it the RC4, RSA,\n * lhash, DES, etc., code; not just the SSL code.  The SSL documentation\n * included with this distribution is covered by the same copyright terms\n * except that the holder is Tim Hudson (tjh@cryptsoft.com).\n *\n * Copyright remains Eric Young's, and as such any Copyright notices in\n * the code are not to be removed.\n * If this package is used in a product, Eric Young should be given attribution\n * as the author of the parts of the library used.\n * This can be in the form of a textual message at program startup or\n * in documentation (online or textual) provided with the package.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the copyright\n *    notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in the\n *    documentation and/or other materials provided with the distribution.\n * 3. All advertising materials mentioning features or use of this software\n *    must display the following acknowledgement:\n *    \"This product includes cryptographic software written by\n *     Eric Young (eay@cryptsoft.com)\"\n *    The word 'cryptographic' can be left out if the rouines from the library\n *    being used are not cryptographic related :-).\n * 4. If you include any Windows specific code (or a derivative thereof) from\n *    the apps directory (application code) you must include an acknowledgement:\n *    \"This product includes software written by Tim Hudson (tjh@cryptsoft.com)\"\n *\n * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n * SUCH DAMAGE.\n *\n * The licence and distribution terms for any publically available version or\n * derivative of this code cannot be changed.  i.e. this code cannot simply be\n * copied and put under another distribution licence\n * [including the GNU Public Licence.]\n */\n\n#ifndef HEADER_OBJECTS_H\n# define HEADER_OBJECTS_H\n\n# define USE_OBJ_MAC\n\n# ifdef USE_OBJ_MAC\n#  include <openssl/obj_mac.h>\n# else\n#  define SN_undef                        \"UNDEF\"\n#  define LN_undef                        \"undefined\"\n#  define NID_undef                       0\n#  define OBJ_undef                       0L\n\n#  define SN_Algorithm                    \"Algorithm\"\n#  define LN_algorithm                    \"algorithm\"\n#  define NID_algorithm                   38\n#  define OBJ_algorithm                   1L,3L,14L,3L,2L\n\n#  define LN_rsadsi                       \"rsadsi\"\n#  define NID_rsadsi                      1\n#  define OBJ_rsadsi                      1L,2L,840L,113549L\n\n#  define LN_pkcs                         \"pkcs\"\n#  define NID_pkcs                        2\n#  define OBJ_pkcs                        OBJ_rsadsi,1L\n\n#  define SN_md2                          \"MD2\"\n#  define LN_md2                          \"md2\"\n#  define NID_md2                         3\n#  define OBJ_md2                         OBJ_rsadsi,2L,2L\n\n#  define SN_md5                          \"MD5\"\n#  define LN_md5                          \"md5\"\n#  define NID_md5                         4\n#  define OBJ_md5                         OBJ_rsadsi,2L,5L\n\n#  define SN_rc4                          \"RC4\"\n#  define LN_rc4                          \"rc4\"\n#  define NID_rc4                         5\n#  define OBJ_rc4                         OBJ_rsadsi,3L,4L\n\n#  define LN_rsaEncryption                \"rsaEncryption\"\n#  define NID_rsaEncryption               6\n#  define OBJ_rsaEncryption               OBJ_pkcs,1L,1L\n\n#  define SN_md2WithRSAEncryption         \"RSA-MD2\"\n#  define LN_md2WithRSAEncryption         \"md2WithRSAEncryption\"\n#  define NID_md2WithRSAEncryption        7\n#  define OBJ_md2WithRSAEncryption        OBJ_pkcs,1L,2L\n\n#  define SN_md5WithRSAEncryption         \"RSA-MD5\"\n#  define LN_md5WithRSAEncryption         \"md5WithRSAEncryption\"\n#  define NID_md5WithRSAEncryption        8\n#  define OBJ_md5WithRSAEncryption        OBJ_pkcs,1L,4L\n\n#  define SN_pbeWithMD2AndDES_CBC         \"PBE-MD2-DES\"\n#  define LN_pbeWithMD2AndDES_CBC         \"pbeWithMD2AndDES-CBC\"\n#  define NID_pbeWithMD2AndDES_CBC        9\n#  define OBJ_pbeWithMD2AndDES_CBC        OBJ_pkcs,5L,1L\n\n#  define SN_pbeWithMD5AndDES_CBC         \"PBE-MD5-DES\"\n#  define LN_pbeWithMD5AndDES_CBC         \"pbeWithMD5AndDES-CBC\"\n#  define NID_pbeWithMD5AndDES_CBC        10\n#  define OBJ_pbeWithMD5AndDES_CBC        OBJ_pkcs,5L,3L\n\n#  define LN_X500                         \"X500\"\n#  define NID_X500                        11\n#  define OBJ_X500                        2L,5L\n\n#  define LN_X509                         \"X509\"\n#  define NID_X509                        12\n#  define OBJ_X509                        OBJ_X500,4L\n\n#  define SN_commonName                   \"CN\"\n#  define LN_commonName                   \"commonName\"\n#  define NID_commonName                  13\n#  define OBJ_commonName                  OBJ_X509,3L\n\n#  define SN_countryName                  \"C\"\n#  define LN_countryName                  \"countryName\"\n#  define NID_countryName                 14\n#  define OBJ_countryName                 OBJ_X509,6L\n\n#  define SN_localityName                 \"L\"\n#  define LN_localityName                 \"localityName\"\n#  define NID_localityName                15\n#  define OBJ_localityName                OBJ_X509,7L\n\n/* Postal Address? PA */\n\n/* should be \"ST\" (rfc1327) but MS uses 'S' */\n#  define SN_stateOrProvinceName          \"ST\"\n#  define LN_stateOrProvinceName          \"stateOrProvinceName\"\n#  define NID_stateOrProvinceName         16\n#  define OBJ_stateOrProvinceName         OBJ_X509,8L\n\n#  define SN_organizationName             \"O\"\n#  define LN_organizationName             \"organizationName\"\n#  define NID_organizationName            17\n#  define OBJ_organizationName            OBJ_X509,10L\n\n#  define SN_organizationalUnitName       \"OU\"\n#  define LN_organizationalUnitName       \"organizationalUnitName\"\n#  define NID_organizationalUnitName      18\n#  define OBJ_organizationalUnitName      OBJ_X509,11L\n\n#  define SN_rsa                          \"RSA\"\n#  define LN_rsa                          \"rsa\"\n#  define NID_rsa                         19\n#  define OBJ_rsa                         OBJ_X500,8L,1L,1L\n\n#  define LN_pkcs7                        \"pkcs7\"\n#  define NID_pkcs7                       20\n#  define OBJ_pkcs7                       OBJ_pkcs,7L\n\n#  define LN_pkcs7_data                   \"pkcs7-data\"\n#  define NID_pkcs7_data                  21\n#  define OBJ_pkcs7_data                  OBJ_pkcs7,1L\n\n#  define LN_pkcs7_signed                 \"pkcs7-signedData\"\n#  define NID_pkcs7_signed                22\n#  define OBJ_pkcs7_signed                OBJ_pkcs7,2L\n\n#  define LN_pkcs7_enveloped              \"pkcs7-envelopedData\"\n#  define NID_pkcs7_enveloped             23\n#  define OBJ_pkcs7_enveloped             OBJ_pkcs7,3L\n\n#  define LN_pkcs7_signedAndEnveloped     \"pkcs7-signedAndEnvelopedData\"\n#  define NID_pkcs7_signedAndEnveloped    24\n#  define OBJ_pkcs7_signedAndEnveloped    OBJ_pkcs7,4L\n\n#  define LN_pkcs7_digest                 \"pkcs7-digestData\"\n#  define NID_pkcs7_digest                25\n#  define OBJ_pkcs7_digest                OBJ_pkcs7,5L\n\n#  define LN_pkcs7_encrypted              \"pkcs7-encryptedData\"\n#  define NID_pkcs7_encrypted             26\n#  define OBJ_pkcs7_encrypted             OBJ_pkcs7,6L\n\n#  define LN_pkcs3                        \"pkcs3\"\n#  define NID_pkcs3                       27\n#  define OBJ_pkcs3                       OBJ_pkcs,3L\n\n#  define LN_dhKeyAgreement               \"dhKeyAgreement\"\n#  define NID_dhKeyAgreement              28\n#  define OBJ_dhKeyAgreement              OBJ_pkcs3,1L\n\n#  define SN_des_ecb                      \"DES-ECB\"\n#  define LN_des_ecb                      \"des-ecb\"\n#  define NID_des_ecb                     29\n#  define OBJ_des_ecb                     OBJ_algorithm,6L\n\n#  define SN_des_cfb64                    \"DES-CFB\"\n#  define LN_des_cfb64                    \"des-cfb\"\n#  define NID_des_cfb64                   30\n/* IV + num */\n#  define OBJ_des_cfb64                   OBJ_algorithm,9L\n\n#  define SN_des_cbc                      \"DES-CBC\"\n#  define LN_des_cbc                      \"des-cbc\"\n#  define NID_des_cbc                     31\n/* IV */\n#  define OBJ_des_cbc                     OBJ_algorithm,7L\n\n#  define SN_des_ede                      \"DES-EDE\"\n#  define LN_des_ede                      \"des-ede\"\n#  define NID_des_ede                     32\n/* ?? */\n#  define OBJ_des_ede                     OBJ_algorithm,17L\n\n#  define SN_des_ede3                     \"DES-EDE3\"\n#  define LN_des_ede3                     \"des-ede3\"\n#  define NID_des_ede3                    33\n\n#  define SN_idea_cbc                     \"IDEA-CBC\"\n#  define LN_idea_cbc                     \"idea-cbc\"\n#  define NID_idea_cbc                    34\n#  define OBJ_idea_cbc                    1L,3L,6L,1L,4L,1L,188L,7L,1L,1L,2L\n\n#  define SN_idea_cfb64                   \"IDEA-CFB\"\n#  define LN_idea_cfb64                   \"idea-cfb\"\n#  define NID_idea_cfb64                  35\n\n#  define SN_idea_ecb                     \"IDEA-ECB\"\n#  define LN_idea_ecb                     \"idea-ecb\"\n#  define NID_idea_ecb                    36\n\n#  define SN_rc2_cbc                      \"RC2-CBC\"\n#  define LN_rc2_cbc                      \"rc2-cbc\"\n#  define NID_rc2_cbc                     37\n#  define OBJ_rc2_cbc                     OBJ_rsadsi,3L,2L\n\n#  define SN_rc2_ecb                      \"RC2-ECB\"\n#  define LN_rc2_ecb                      \"rc2-ecb\"\n#  define NID_rc2_ecb                     38\n\n#  define SN_rc2_cfb64                    \"RC2-CFB\"\n#  define LN_rc2_cfb64                    \"rc2-cfb\"\n#  define NID_rc2_cfb64                   39\n\n#  define SN_rc2_ofb64                    \"RC2-OFB\"\n#  define LN_rc2_ofb64                    \"rc2-ofb\"\n#  define NID_rc2_ofb64                   40\n\n#  define SN_sha                          \"SHA\"\n#  define LN_sha                          \"sha\"\n#  define NID_sha                         41\n#  define OBJ_sha                         OBJ_algorithm,18L\n\n#  define SN_shaWithRSAEncryption         \"RSA-SHA\"\n#  define LN_shaWithRSAEncryption         \"shaWithRSAEncryption\"\n#  define NID_shaWithRSAEncryption        42\n#  define OBJ_shaWithRSAEncryption        OBJ_algorithm,15L\n\n#  define SN_des_ede_cbc                  \"DES-EDE-CBC\"\n#  define LN_des_ede_cbc                  \"des-ede-cbc\"\n#  define NID_des_ede_cbc                 43\n\n#  define SN_des_ede3_cbc                 \"DES-EDE3-CBC\"\n#  define LN_des_ede3_cbc                 \"des-ede3-cbc\"\n#  define NID_des_ede3_cbc                44\n#  define OBJ_des_ede3_cbc                OBJ_rsadsi,3L,7L\n\n#  define SN_des_ofb64                    \"DES-OFB\"\n#  define LN_des_ofb64                    \"des-ofb\"\n#  define NID_des_ofb64                   45\n#  define OBJ_des_ofb64                   OBJ_algorithm,8L\n\n#  define SN_idea_ofb64                   \"IDEA-OFB\"\n#  define LN_idea_ofb64                   \"idea-ofb\"\n#  define NID_idea_ofb64                  46\n\n#  define LN_pkcs9                        \"pkcs9\"\n#  define NID_pkcs9                       47\n#  define OBJ_pkcs9                       OBJ_pkcs,9L\n\n#  define SN_pkcs9_emailAddress           \"Email\"\n#  define LN_pkcs9_emailAddress           \"emailAddress\"\n#  define NID_pkcs9_emailAddress          48\n#  define OBJ_pkcs9_emailAddress          OBJ_pkcs9,1L\n\n#  define LN_pkcs9_unstructuredName       \"unstructuredName\"\n#  define NID_pkcs9_unstructuredName      49\n#  define OBJ_pkcs9_unstructuredName      OBJ_pkcs9,2L\n\n#  define LN_pkcs9_contentType            \"contentType\"\n#  define NID_pkcs9_contentType           50\n#  define OBJ_pkcs9_contentType           OBJ_pkcs9,3L\n\n#  define LN_pkcs9_messageDigest          \"messageDigest\"\n#  define NID_pkcs9_messageDigest         51\n#  define OBJ_pkcs9_messageDigest         OBJ_pkcs9,4L\n\n#  define LN_pkcs9_signingTime            \"signingTime\"\n#  define NID_pkcs9_signingTime           52\n#  define OBJ_pkcs9_signingTime           OBJ_pkcs9,5L\n\n#  define LN_pkcs9_countersignature       \"countersignature\"\n#  define NID_pkcs9_countersignature      53\n#  define OBJ_pkcs9_countersignature      OBJ_pkcs9,6L\n\n#  define LN_pkcs9_challengePassword      \"challengePassword\"\n#  define NID_pkcs9_challengePassword     54\n#  define OBJ_pkcs9_challengePassword     OBJ_pkcs9,7L\n\n#  define LN_pkcs9_unstructuredAddress    \"unstructuredAddress\"\n#  define NID_pkcs9_unstructuredAddress   55\n#  define OBJ_pkcs9_unstructuredAddress   OBJ_pkcs9,8L\n\n#  define LN_pkcs9_extCertAttributes      \"extendedCertificateAttributes\"\n#  define NID_pkcs9_extCertAttributes     56\n#  define OBJ_pkcs9_extCertAttributes     OBJ_pkcs9,9L\n\n#  define SN_netscape                     \"Netscape\"\n#  define LN_netscape                     \"Netscape Communications Corp.\"\n#  define NID_netscape                    57\n#  define OBJ_netscape                    2L,16L,840L,1L,113730L\n\n#  define SN_netscape_cert_extension      \"nsCertExt\"\n#  define LN_netscape_cert_extension      \"Netscape Certificate Extension\"\n#  define NID_netscape_cert_extension     58\n#  define OBJ_netscape_cert_extension     OBJ_netscape,1L\n\n#  define SN_netscape_data_type           \"nsDataType\"\n#  define LN_netscape_data_type           \"Netscape Data Type\"\n#  define NID_netscape_data_type          59\n#  define OBJ_netscape_data_type          OBJ_netscape,2L\n\n#  define SN_des_ede_cfb64                \"DES-EDE-CFB\"\n#  define LN_des_ede_cfb64                \"des-ede-cfb\"\n#  define NID_des_ede_cfb64               60\n\n#  define SN_des_ede3_cfb64               \"DES-EDE3-CFB\"\n#  define LN_des_ede3_cfb64               \"des-ede3-cfb\"\n#  define NID_des_ede3_cfb64              61\n\n#  define SN_des_ede_ofb64                \"DES-EDE-OFB\"\n#  define LN_des_ede_ofb64                \"des-ede-ofb\"\n#  define NID_des_ede_ofb64               62\n\n#  define SN_des_ede3_ofb64               \"DES-EDE3-OFB\"\n#  define LN_des_ede3_ofb64               \"des-ede3-ofb\"\n#  define NID_des_ede3_ofb64              63\n\n/* I'm not sure about the object ID */\n#  define SN_sha1                         \"SHA1\"\n#  define LN_sha1                         \"sha1\"\n#  define NID_sha1                        64\n#  define OBJ_sha1                        OBJ_algorithm,26L\n/* 28 Jun 1996 - eay */\n/* #define OBJ_sha1                     1L,3L,14L,2L,26L,05L <- wrong */\n\n#  define SN_sha1WithRSAEncryption        \"RSA-SHA1\"\n#  define LN_sha1WithRSAEncryption        \"sha1WithRSAEncryption\"\n#  define NID_sha1WithRSAEncryption       65\n#  define OBJ_sha1WithRSAEncryption       OBJ_pkcs,1L,5L\n\n#  define SN_dsaWithSHA                   \"DSA-SHA\"\n#  define LN_dsaWithSHA                   \"dsaWithSHA\"\n#  define NID_dsaWithSHA                  66\n#  define OBJ_dsaWithSHA                  OBJ_algorithm,13L\n\n#  define SN_dsa_2                        \"DSA-old\"\n#  define LN_dsa_2                        \"dsaEncryption-old\"\n#  define NID_dsa_2                       67\n#  define OBJ_dsa_2                       OBJ_algorithm,12L\n\n/* proposed by microsoft to RSA */\n#  define SN_pbeWithSHA1AndRC2_CBC        \"PBE-SHA1-RC2-64\"\n#  define LN_pbeWithSHA1AndRC2_CBC        \"pbeWithSHA1AndRC2-CBC\"\n#  define NID_pbeWithSHA1AndRC2_CBC       68\n#  define OBJ_pbeWithSHA1AndRC2_CBC       OBJ_pkcs,5L,11L\n\n/*\n * proposed by microsoft to RSA as pbeWithSHA1AndRC4: it is now defined\n * explicitly in PKCS#5 v2.0 as id-PBKDF2 which is something completely\n * different.\n */\n#  define LN_id_pbkdf2                    \"PBKDF2\"\n#  define NID_id_pbkdf2                   69\n#  define OBJ_id_pbkdf2                   OBJ_pkcs,5L,12L\n\n#  define SN_dsaWithSHA1_2                \"DSA-SHA1-old\"\n#  define LN_dsaWithSHA1_2                \"dsaWithSHA1-old\"\n#  define NID_dsaWithSHA1_2               70\n/* Got this one from 'sdn706r20.pdf' which is actually an NSA document :-) */\n#  define OBJ_dsaWithSHA1_2               OBJ_algorithm,27L\n\n#  define SN_netscape_cert_type           \"nsCertType\"\n#  define LN_netscape_cert_type           \"Netscape Cert Type\"\n#  define NID_netscape_cert_type          71\n#  define OBJ_netscape_cert_type          OBJ_netscape_cert_extension,1L\n\n#  define SN_netscape_base_url            \"nsBaseUrl\"\n#  define LN_netscape_base_url            \"Netscape Base Url\"\n#  define NID_netscape_base_url           72\n#  define OBJ_netscape_base_url           OBJ_netscape_cert_extension,2L\n\n#  define SN_netscape_revocation_url      \"nsRevocationUrl\"\n#  define LN_netscape_revocation_url      \"Netscape Revocation Url\"\n#  define NID_netscape_revocation_url     73\n#  define OBJ_netscape_revocation_url     OBJ_netscape_cert_extension,3L\n\n#  define SN_netscape_ca_revocation_url   \"nsCaRevocationUrl\"\n#  define LN_netscape_ca_revocation_url   \"Netscape CA Revocation Url\"\n#  define NID_netscape_ca_revocation_url  74\n#  define OBJ_netscape_ca_revocation_url  OBJ_netscape_cert_extension,4L\n\n#  define SN_netscape_renewal_url         \"nsRenewalUrl\"\n#  define LN_netscape_renewal_url         \"Netscape Renewal Url\"\n#  define NID_netscape_renewal_url        75\n#  define OBJ_netscape_renewal_url        OBJ_netscape_cert_extension,7L\n\n#  define SN_netscape_ca_policy_url       \"nsCaPolicyUrl\"\n#  define LN_netscape_ca_policy_url       \"Netscape CA Policy Url\"\n#  define NID_netscape_ca_policy_url      76\n#  define OBJ_netscape_ca_policy_url      OBJ_netscape_cert_extension,8L\n\n#  define SN_netscape_ssl_server_name     \"nsSslServerName\"\n#  define LN_netscape_ssl_server_name     \"Netscape SSL Server Name\"\n#  define NID_netscape_ssl_server_name    77\n#  define OBJ_netscape_ssl_server_name    OBJ_netscape_cert_extension,12L\n\n#  define SN_netscape_comment             \"nsComment\"\n#  define LN_netscape_comment             \"Netscape Comment\"\n#  define NID_netscape_comment            78\n#  define OBJ_netscape_comment            OBJ_netscape_cert_extension,13L\n\n#  define SN_netscape_cert_sequence       \"nsCertSequence\"\n#  define LN_netscape_cert_sequence       \"Netscape Certificate Sequence\"\n#  define NID_netscape_cert_sequence      79\n#  define OBJ_netscape_cert_sequence      OBJ_netscape_data_type,5L\n\n#  define SN_desx_cbc                     \"DESX-CBC\"\n#  define LN_desx_cbc                     \"desx-cbc\"\n#  define NID_desx_cbc                    80\n\n#  define SN_id_ce                        \"id-ce\"\n#  define NID_id_ce                       81\n#  define OBJ_id_ce                       2L,5L,29L\n\n#  define SN_subject_key_identifier       \"subjectKeyIdentifier\"\n#  define LN_subject_key_identifier       \"X509v3 Subject Key Identifier\"\n#  define NID_subject_key_identifier      82\n#  define OBJ_subject_key_identifier      OBJ_id_ce,14L\n\n#  define SN_key_usage                    \"keyUsage\"\n#  define LN_key_usage                    \"X509v3 Key Usage\"\n#  define NID_key_usage                   83\n#  define OBJ_key_usage                   OBJ_id_ce,15L\n\n#  define SN_private_key_usage_period     \"privateKeyUsagePeriod\"\n#  define LN_private_key_usage_period     \"X509v3 Private Key Usage Period\"\n#  define NID_private_key_usage_period    84\n#  define OBJ_private_key_usage_period    OBJ_id_ce,16L\n\n#  define SN_subject_alt_name             \"subjectAltName\"\n#  define LN_subject_alt_name             \"X509v3 Subject Alternative Name\"\n#  define NID_subject_alt_name            85\n#  define OBJ_subject_alt_name            OBJ_id_ce,17L\n\n#  define SN_issuer_alt_name              \"issuerAltName\"\n#  define LN_issuer_alt_name              \"X509v3 Issuer Alternative Name\"\n#  define NID_issuer_alt_name             86\n#  define OBJ_issuer_alt_name             OBJ_id_ce,18L\n\n#  define SN_basic_constraints            \"basicConstraints\"\n#  define LN_basic_constraints            \"X509v3 Basic Constraints\"\n#  define NID_basic_constraints           87\n#  define OBJ_basic_constraints           OBJ_id_ce,19L\n\n#  define SN_crl_number                   \"crlNumber\"\n#  define LN_crl_number                   \"X509v3 CRL Number\"\n#  define NID_crl_number                  88\n#  define OBJ_crl_number                  OBJ_id_ce,20L\n\n#  define SN_certificate_policies         \"certificatePolicies\"\n#  define LN_certificate_policies         \"X509v3 Certificate Policies\"\n#  define NID_certificate_policies        89\n#  define OBJ_certificate_policies        OBJ_id_ce,32L\n\n#  define SN_authority_key_identifier     \"authorityKeyIdentifier\"\n#  define LN_authority_key_identifier     \"X509v3 Authority Key Identifier\"\n#  define NID_authority_key_identifier    90\n#  define OBJ_authority_key_identifier    OBJ_id_ce,35L\n\n#  define SN_bf_cbc                       \"BF-CBC\"\n#  define LN_bf_cbc                       \"bf-cbc\"\n#  define NID_bf_cbc                      91\n#  define OBJ_bf_cbc                      1L,3L,6L,1L,4L,1L,3029L,1L,2L\n\n#  define SN_bf_ecb                       \"BF-ECB\"\n#  define LN_bf_ecb                       \"bf-ecb\"\n#  define NID_bf_ecb                      92\n\n#  define SN_bf_cfb64                     \"BF-CFB\"\n#  define LN_bf_cfb64                     \"bf-cfb\"\n#  define NID_bf_cfb64                    93\n\n#  define SN_bf_ofb64                     \"BF-OFB\"\n#  define LN_bf_ofb64                     \"bf-ofb\"\n#  define NID_bf_ofb64                    94\n\n#  define SN_mdc2                         \"MDC2\"\n#  define LN_mdc2                         \"mdc2\"\n#  define NID_mdc2                        95\n#  define OBJ_mdc2                        2L,5L,8L,3L,101L\n/* An alternative?                      1L,3L,14L,3L,2L,19L */\n\n#  define SN_mdc2WithRSA                  \"RSA-MDC2\"\n#  define LN_mdc2WithRSA                  \"mdc2withRSA\"\n#  define NID_mdc2WithRSA                 96\n#  define OBJ_mdc2WithRSA                 2L,5L,8L,3L,100L\n\n#  define SN_rc4_40                       \"RC4-40\"\n#  define LN_rc4_40                       \"rc4-40\"\n#  define NID_rc4_40                      97\n\n#  define SN_rc2_40_cbc                   \"RC2-40-CBC\"\n#  define LN_rc2_40_cbc                   \"rc2-40-cbc\"\n#  define NID_rc2_40_cbc                  98\n\n#  define SN_givenName                    \"G\"\n#  define LN_givenName                    \"givenName\"\n#  define NID_givenName                   99\n#  define OBJ_givenName                   OBJ_X509,42L\n\n#  define SN_surname                      \"S\"\n#  define LN_surname                      \"surname\"\n#  define NID_surname                     100\n#  define OBJ_surname                     OBJ_X509,4L\n\n#  define SN_initials                     \"I\"\n#  define LN_initials                     \"initials\"\n#  define NID_initials                    101\n#  define OBJ_initials                    OBJ_X509,43L\n\n#  define SN_uniqueIdentifier             \"UID\"\n#  define LN_uniqueIdentifier             \"uniqueIdentifier\"\n#  define NID_uniqueIdentifier            102\n#  define OBJ_uniqueIdentifier            OBJ_X509,45L\n\n#  define SN_crl_distribution_points      \"crlDistributionPoints\"\n#  define LN_crl_distribution_points      \"X509v3 CRL Distribution Points\"\n#  define NID_crl_distribution_points     103\n#  define OBJ_crl_distribution_points     OBJ_id_ce,31L\n\n#  define SN_md5WithRSA                   \"RSA-NP-MD5\"\n#  define LN_md5WithRSA                   \"md5WithRSA\"\n#  define NID_md5WithRSA                  104\n#  define OBJ_md5WithRSA                  OBJ_algorithm,3L\n\n#  define SN_serialNumber                 \"SN\"\n#  define LN_serialNumber                 \"serialNumber\"\n#  define NID_serialNumber                105\n#  define OBJ_serialNumber                OBJ_X509,5L\n\n#  define SN_title                        \"T\"\n#  define LN_title                        \"title\"\n#  define NID_title                       106\n#  define OBJ_title                       OBJ_X509,12L\n\n#  define SN_description                  \"D\"\n#  define LN_description                  \"description\"\n#  define NID_description                 107\n#  define OBJ_description                 OBJ_X509,13L\n\n/* CAST5 is CAST-128, I'm just sticking with the documentation */\n#  define SN_cast5_cbc                    \"CAST5-CBC\"\n#  define LN_cast5_cbc                    \"cast5-cbc\"\n#  define NID_cast5_cbc                   108\n#  define OBJ_cast5_cbc                   1L,2L,840L,113533L,7L,66L,10L\n\n#  define SN_cast5_ecb                    \"CAST5-ECB\"\n#  define LN_cast5_ecb                    \"cast5-ecb\"\n#  define NID_cast5_ecb                   109\n\n#  define SN_cast5_cfb64                  \"CAST5-CFB\"\n#  define LN_cast5_cfb64                  \"cast5-cfb\"\n#  define NID_cast5_cfb64                 110\n\n#  define SN_cast5_ofb64                  \"CAST5-OFB\"\n#  define LN_cast5_ofb64                  \"cast5-ofb\"\n#  define NID_cast5_ofb64                 111\n\n#  define LN_pbeWithMD5AndCast5_CBC       \"pbeWithMD5AndCast5CBC\"\n#  define NID_pbeWithMD5AndCast5_CBC      112\n#  define OBJ_pbeWithMD5AndCast5_CBC      1L,2L,840L,113533L,7L,66L,12L\n\n/*-\n * This is one sun will soon be using :-(\n * id-dsa-with-sha1 ID  ::= {\n *   iso(1) member-body(2) us(840) x9-57 (10040) x9cm(4) 3 }\n */\n#  define SN_dsaWithSHA1                  \"DSA-SHA1\"\n#  define LN_dsaWithSHA1                  \"dsaWithSHA1\"\n#  define NID_dsaWithSHA1                 113\n#  define OBJ_dsaWithSHA1                 1L,2L,840L,10040L,4L,3L\n\n#  define NID_md5_sha1                    114\n#  define SN_md5_sha1                     \"MD5-SHA1\"\n#  define LN_md5_sha1                     \"md5-sha1\"\n\n#  define SN_sha1WithRSA                  \"RSA-SHA1-2\"\n#  define LN_sha1WithRSA                  \"sha1WithRSA\"\n#  define NID_sha1WithRSA                 115\n#  define OBJ_sha1WithRSA                 OBJ_algorithm,29L\n\n#  define SN_dsa                          \"DSA\"\n#  define LN_dsa                          \"dsaEncryption\"\n#  define NID_dsa                         116\n#  define OBJ_dsa                         1L,2L,840L,10040L,4L,1L\n\n#  define SN_ripemd160                    \"RIPEMD160\"\n#  define LN_ripemd160                    \"ripemd160\"\n#  define NID_ripemd160                   117\n#  define OBJ_ripemd160                   1L,3L,36L,3L,2L,1L\n\n/*\n * The name should actually be rsaSignatureWithripemd160, but I'm going to\n * continue using the convention I'm using with the other ciphers\n */\n#  define SN_ripemd160WithRSA             \"RSA-RIPEMD160\"\n#  define LN_ripemd160WithRSA             \"ripemd160WithRSA\"\n#  define NID_ripemd160WithRSA            119\n#  define OBJ_ripemd160WithRSA            1L,3L,36L,3L,3L,1L,2L\n\n/*-\n * Taken from rfc2040\n *  RC5_CBC_Parameters ::= SEQUENCE {\n *      version           INTEGER (v1_0(16)),\n *      rounds            INTEGER (8..127),\n *      blockSizeInBits   INTEGER (64, 128),\n *      iv                OCTET STRING OPTIONAL\n *      }\n */\n#  define SN_rc5_cbc                      \"RC5-CBC\"\n#  define LN_rc5_cbc                      \"rc5-cbc\"\n#  define NID_rc5_cbc                     120\n#  define OBJ_rc5_cbc                     OBJ_rsadsi,3L,8L\n\n#  define SN_rc5_ecb                      \"RC5-ECB\"\n#  define LN_rc5_ecb                      \"rc5-ecb\"\n#  define NID_rc5_ecb                     121\n\n#  define SN_rc5_cfb64                    \"RC5-CFB\"\n#  define LN_rc5_cfb64                    \"rc5-cfb\"\n#  define NID_rc5_cfb64                   122\n\n#  define SN_rc5_ofb64                    \"RC5-OFB\"\n#  define LN_rc5_ofb64                    \"rc5-ofb\"\n#  define NID_rc5_ofb64                   123\n\n#  define SN_rle_compression              \"RLE\"\n#  define LN_rle_compression              \"run length compression\"\n#  define NID_rle_compression             124\n#  define OBJ_rle_compression             1L,1L,1L,1L,666L,1L\n\n#  define SN_zlib_compression             \"ZLIB\"\n#  define LN_zlib_compression             \"zlib compression\"\n#  define NID_zlib_compression            125\n#  define OBJ_zlib_compression            1L,1L,1L,1L,666L,2L\n\n#  define SN_ext_key_usage                \"extendedKeyUsage\"\n#  define LN_ext_key_usage                \"X509v3 Extended Key Usage\"\n#  define NID_ext_key_usage               126\n#  define OBJ_ext_key_usage               OBJ_id_ce,37\n\n#  define SN_id_pkix                      \"PKIX\"\n#  define NID_id_pkix                     127\n#  define OBJ_id_pkix                     1L,3L,6L,1L,5L,5L,7L\n\n#  define SN_id_kp                        \"id-kp\"\n#  define NID_id_kp                       128\n#  define OBJ_id_kp                       OBJ_id_pkix,3L\n\n/* PKIX extended key usage OIDs */\n\n#  define SN_server_auth                  \"serverAuth\"\n#  define LN_server_auth                  \"TLS Web Server Authentication\"\n#  define NID_server_auth                 129\n#  define OBJ_server_auth                 OBJ_id_kp,1L\n\n#  define SN_client_auth                  \"clientAuth\"\n#  define LN_client_auth                  \"TLS Web Client Authentication\"\n#  define NID_client_auth                 130\n#  define OBJ_client_auth                 OBJ_id_kp,2L\n\n#  define SN_code_sign                    \"codeSigning\"\n#  define LN_code_sign                    \"Code Signing\"\n#  define NID_code_sign                   131\n#  define OBJ_code_sign                   OBJ_id_kp,3L\n\n#  define SN_email_protect                \"emailProtection\"\n#  define LN_email_protect                \"E-mail Protection\"\n#  define NID_email_protect               132\n#  define OBJ_email_protect               OBJ_id_kp,4L\n\n#  define SN_time_stamp                   \"timeStamping\"\n#  define LN_time_stamp                   \"Time Stamping\"\n#  define NID_time_stamp                  133\n#  define OBJ_time_stamp                  OBJ_id_kp,8L\n\n/* Additional extended key usage OIDs: Microsoft */\n\n#  define SN_ms_code_ind                  \"msCodeInd\"\n#  define LN_ms_code_ind                  \"Microsoft Individual Code Signing\"\n#  define NID_ms_code_ind                 134\n#  define OBJ_ms_code_ind                 1L,3L,6L,1L,4L,1L,311L,2L,1L,21L\n\n#  define SN_ms_code_com                  \"msCodeCom\"\n#  define LN_ms_code_com                  \"Microsoft Commercial Code Signing\"\n#  define NID_ms_code_com                 135\n#  define OBJ_ms_code_com                 1L,3L,6L,1L,4L,1L,311L,2L,1L,22L\n\n#  define SN_ms_ctl_sign                  \"msCTLSign\"\n#  define LN_ms_ctl_sign                  \"Microsoft Trust List Signing\"\n#  define NID_ms_ctl_sign                 136\n#  define OBJ_ms_ctl_sign                 1L,3L,6L,1L,4L,1L,311L,10L,3L,1L\n\n#  define SN_ms_sgc                       \"msSGC\"\n#  define LN_ms_sgc                       \"Microsoft Server Gated Crypto\"\n#  define NID_ms_sgc                      137\n#  define OBJ_ms_sgc                      1L,3L,6L,1L,4L,1L,311L,10L,3L,3L\n\n#  define SN_ms_efs                       \"msEFS\"\n#  define LN_ms_efs                       \"Microsoft Encrypted File System\"\n#  define NID_ms_efs                      138\n#  define OBJ_ms_efs                      1L,3L,6L,1L,4L,1L,311L,10L,3L,4L\n\n/* Additional usage: Netscape */\n\n#  define SN_ns_sgc                       \"nsSGC\"\n#  define LN_ns_sgc                       \"Netscape Server Gated Crypto\"\n#  define NID_ns_sgc                      139\n#  define OBJ_ns_sgc                      OBJ_netscape,4L,1L\n\n#  define SN_delta_crl                    \"deltaCRL\"\n#  define LN_delta_crl                    \"X509v3 Delta CRL Indicator\"\n#  define NID_delta_crl                   140\n#  define OBJ_delta_crl                   OBJ_id_ce,27L\n\n#  define SN_crl_reason                   \"CRLReason\"\n#  define LN_crl_reason                   \"CRL Reason Code\"\n#  define NID_crl_reason                  141\n#  define OBJ_crl_reason                  OBJ_id_ce,21L\n\n#  define SN_invalidity_date              \"invalidityDate\"\n#  define LN_invalidity_date              \"Invalidity Date\"\n#  define NID_invalidity_date             142\n#  define OBJ_invalidity_date             OBJ_id_ce,24L\n\n#  define SN_sxnet                        \"SXNetID\"\n#  define LN_sxnet                        \"Strong Extranet ID\"\n#  define NID_sxnet                       143\n#  define OBJ_sxnet                       1L,3L,101L,1L,4L,1L\n\n/* PKCS12 and related OBJECT IDENTIFIERS */\n\n#  define OBJ_pkcs12                      OBJ_pkcs,12L\n#  define OBJ_pkcs12_pbeids               OBJ_pkcs12, 1\n\n#  define SN_pbe_WithSHA1And128BitRC4     \"PBE-SHA1-RC4-128\"\n#  define LN_pbe_WithSHA1And128BitRC4     \"pbeWithSHA1And128BitRC4\"\n#  define NID_pbe_WithSHA1And128BitRC4    144\n#  define OBJ_pbe_WithSHA1And128BitRC4    OBJ_pkcs12_pbeids, 1L\n\n#  define SN_pbe_WithSHA1And40BitRC4      \"PBE-SHA1-RC4-40\"\n#  define LN_pbe_WithSHA1And40BitRC4      \"pbeWithSHA1And40BitRC4\"\n#  define NID_pbe_WithSHA1And40BitRC4     145\n#  define OBJ_pbe_WithSHA1And40BitRC4     OBJ_pkcs12_pbeids, 2L\n\n#  define SN_pbe_WithSHA1And3_Key_TripleDES_CBC   \"PBE-SHA1-3DES\"\n#  define LN_pbe_WithSHA1And3_Key_TripleDES_CBC   \"pbeWithSHA1And3-KeyTripleDES-CBC\"\n#  define NID_pbe_WithSHA1And3_Key_TripleDES_CBC  146\n#  define OBJ_pbe_WithSHA1And3_Key_TripleDES_CBC  OBJ_pkcs12_pbeids, 3L\n\n#  define SN_pbe_WithSHA1And2_Key_TripleDES_CBC   \"PBE-SHA1-2DES\"\n#  define LN_pbe_WithSHA1And2_Key_TripleDES_CBC   \"pbeWithSHA1And2-KeyTripleDES-CBC\"\n#  define NID_pbe_WithSHA1And2_Key_TripleDES_CBC  147\n#  define OBJ_pbe_WithSHA1And2_Key_TripleDES_CBC  OBJ_pkcs12_pbeids, 4L\n\n#  define SN_pbe_WithSHA1And128BitRC2_CBC         \"PBE-SHA1-RC2-128\"\n#  define LN_pbe_WithSHA1And128BitRC2_CBC         \"pbeWithSHA1And128BitRC2-CBC\"\n#  define NID_pbe_WithSHA1And128BitRC2_CBC        148\n#  define OBJ_pbe_WithSHA1And128BitRC2_CBC        OBJ_pkcs12_pbeids, 5L\n\n#  define SN_pbe_WithSHA1And40BitRC2_CBC  \"PBE-SHA1-RC2-40\"\n#  define LN_pbe_WithSHA1And40BitRC2_CBC  \"pbeWithSHA1And40BitRC2-CBC\"\n#  define NID_pbe_WithSHA1And40BitRC2_CBC 149\n#  define OBJ_pbe_WithSHA1And40BitRC2_CBC OBJ_pkcs12_pbeids, 6L\n\n#  define OBJ_pkcs12_Version1     OBJ_pkcs12, 10L\n\n#  define OBJ_pkcs12_BagIds       OBJ_pkcs12_Version1, 1L\n\n#  define LN_keyBag               \"keyBag\"\n#  define NID_keyBag              150\n#  define OBJ_keyBag              OBJ_pkcs12_BagIds, 1L\n\n#  define LN_pkcs8ShroudedKeyBag  \"pkcs8ShroudedKeyBag\"\n#  define NID_pkcs8ShroudedKeyBag 151\n#  define OBJ_pkcs8ShroudedKeyBag OBJ_pkcs12_BagIds, 2L\n\n#  define LN_certBag              \"certBag\"\n#  define NID_certBag             152\n#  define OBJ_certBag             OBJ_pkcs12_BagIds, 3L\n\n#  define LN_crlBag               \"crlBag\"\n#  define NID_crlBag              153\n#  define OBJ_crlBag              OBJ_pkcs12_BagIds, 4L\n\n#  define LN_secretBag            \"secretBag\"\n#  define NID_secretBag           154\n#  define OBJ_secretBag           OBJ_pkcs12_BagIds, 5L\n\n#  define LN_safeContentsBag      \"safeContentsBag\"\n#  define NID_safeContentsBag     155\n#  define OBJ_safeContentsBag     OBJ_pkcs12_BagIds, 6L\n\n#  define LN_friendlyName         \"friendlyName\"\n#  define NID_friendlyName        156\n#  define OBJ_friendlyName        OBJ_pkcs9, 20L\n\n#  define LN_localKeyID           \"localKeyID\"\n#  define NID_localKeyID          157\n#  define OBJ_localKeyID          OBJ_pkcs9, 21L\n\n#  define OBJ_certTypes           OBJ_pkcs9, 22L\n\n#  define LN_x509Certificate      \"x509Certificate\"\n#  define NID_x509Certificate     158\n#  define OBJ_x509Certificate     OBJ_certTypes, 1L\n\n#  define LN_sdsiCertificate      \"sdsiCertificate\"\n#  define NID_sdsiCertificate     159\n#  define OBJ_sdsiCertificate     OBJ_certTypes, 2L\n\n#  define OBJ_crlTypes            OBJ_pkcs9, 23L\n\n#  define LN_x509Crl              \"x509Crl\"\n#  define NID_x509Crl             160\n#  define OBJ_x509Crl             OBJ_crlTypes, 1L\n\n/* PKCS#5 v2 OIDs */\n\n#  define LN_pbes2                \"PBES2\"\n#  define NID_pbes2               161\n#  define OBJ_pbes2               OBJ_pkcs,5L,13L\n\n#  define LN_pbmac1               \"PBMAC1\"\n#  define NID_pbmac1              162\n#  define OBJ_pbmac1              OBJ_pkcs,5L,14L\n\n#  define LN_hmacWithSHA1         \"hmacWithSHA1\"\n#  define NID_hmacWithSHA1        163\n#  define OBJ_hmacWithSHA1        OBJ_rsadsi,2L,7L\n\n/* Policy Qualifier Ids */\n\n#  define LN_id_qt_cps            \"Policy Qualifier CPS\"\n#  define SN_id_qt_cps            \"id-qt-cps\"\n#  define NID_id_qt_cps           164\n#  define OBJ_id_qt_cps           OBJ_id_pkix,2L,1L\n\n#  define LN_id_qt_unotice        \"Policy Qualifier User Notice\"\n#  define SN_id_qt_unotice        \"id-qt-unotice\"\n#  define NID_id_qt_unotice       165\n#  define OBJ_id_qt_unotice       OBJ_id_pkix,2L,2L\n\n#  define SN_rc2_64_cbc                   \"RC2-64-CBC\"\n#  define LN_rc2_64_cbc                   \"rc2-64-cbc\"\n#  define NID_rc2_64_cbc                  166\n\n#  define SN_SMIMECapabilities            \"SMIME-CAPS\"\n#  define LN_SMIMECapabilities            \"S/MIME Capabilities\"\n#  define NID_SMIMECapabilities           167\n#  define OBJ_SMIMECapabilities           OBJ_pkcs9,15L\n\n#  define SN_pbeWithMD2AndRC2_CBC         \"PBE-MD2-RC2-64\"\n#  define LN_pbeWithMD2AndRC2_CBC         \"pbeWithMD2AndRC2-CBC\"\n#  define NID_pbeWithMD2AndRC2_CBC        168\n#  define OBJ_pbeWithMD2AndRC2_CBC        OBJ_pkcs,5L,4L\n\n#  define SN_pbeWithMD5AndRC2_CBC         \"PBE-MD5-RC2-64\"\n#  define LN_pbeWithMD5AndRC2_CBC         \"pbeWithMD5AndRC2-CBC\"\n#  define NID_pbeWithMD5AndRC2_CBC        169\n#  define OBJ_pbeWithMD5AndRC2_CBC        OBJ_pkcs,5L,6L\n\n#  define SN_pbeWithSHA1AndDES_CBC        \"PBE-SHA1-DES\"\n#  define LN_pbeWithSHA1AndDES_CBC        \"pbeWithSHA1AndDES-CBC\"\n#  define NID_pbeWithSHA1AndDES_CBC       170\n#  define OBJ_pbeWithSHA1AndDES_CBC       OBJ_pkcs,5L,10L\n\n/* Extension request OIDs */\n\n#  define LN_ms_ext_req                   \"Microsoft Extension Request\"\n#  define SN_ms_ext_req                   \"msExtReq\"\n#  define NID_ms_ext_req                  171\n#  define OBJ_ms_ext_req                  1L,3L,6L,1L,4L,1L,311L,2L,1L,14L\n\n#  define LN_ext_req                      \"Extension Request\"\n#  define SN_ext_req                      \"extReq\"\n#  define NID_ext_req                     172\n#  define OBJ_ext_req                     OBJ_pkcs9,14L\n\n#  define SN_name                         \"name\"\n#  define LN_name                         \"name\"\n#  define NID_name                        173\n#  define OBJ_name                        OBJ_X509,41L\n\n#  define SN_dnQualifier                  \"dnQualifier\"\n#  define LN_dnQualifier                  \"dnQualifier\"\n#  define NID_dnQualifier                 174\n#  define OBJ_dnQualifier                 OBJ_X509,46L\n\n#  define SN_id_pe                        \"id-pe\"\n#  define NID_id_pe                       175\n#  define OBJ_id_pe                       OBJ_id_pkix,1L\n\n#  define SN_id_ad                        \"id-ad\"\n#  define NID_id_ad                       176\n#  define OBJ_id_ad                       OBJ_id_pkix,48L\n\n#  define SN_info_access                  \"authorityInfoAccess\"\n#  define LN_info_access                  \"Authority Information Access\"\n#  define NID_info_access                 177\n#  define OBJ_info_access                 OBJ_id_pe,1L\n\n#  define SN_ad_OCSP                      \"OCSP\"\n#  define LN_ad_OCSP                      \"OCSP\"\n#  define NID_ad_OCSP                     178\n#  define OBJ_ad_OCSP                     OBJ_id_ad,1L\n\n#  define SN_ad_ca_issuers                \"caIssuers\"\n#  define LN_ad_ca_issuers                \"CA Issuers\"\n#  define NID_ad_ca_issuers               179\n#  define OBJ_ad_ca_issuers               OBJ_id_ad,2L\n\n#  define SN_OCSP_sign                    \"OCSPSigning\"\n#  define LN_OCSP_sign                    \"OCSP Signing\"\n#  define NID_OCSP_sign                   180\n#  define OBJ_OCSP_sign                   OBJ_id_kp,9L\n# endif                         /* USE_OBJ_MAC */\n\n# include <openssl/bio.h>\n# include <openssl/asn1.h>\n\n# define OBJ_NAME_TYPE_UNDEF             0x00\n# define OBJ_NAME_TYPE_MD_METH           0x01\n# define OBJ_NAME_TYPE_CIPHER_METH       0x02\n# define OBJ_NAME_TYPE_PKEY_METH         0x03\n# define OBJ_NAME_TYPE_COMP_METH         0x04\n# define OBJ_NAME_TYPE_NUM               0x05\n\n# define OBJ_NAME_ALIAS                  0x8000\n\n# define OBJ_BSEARCH_VALUE_ON_NOMATCH            0x01\n# define OBJ_BSEARCH_FIRST_VALUE_ON_MATCH        0x02\n\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\ntypedef struct obj_name_st {\n    int type;\n    int alias;\n    const char *name;\n    const char *data;\n} OBJ_NAME;\n\n# define         OBJ_create_and_add_object(a,b,c) OBJ_create(a,b,c)\n\nint OBJ_NAME_init(void);\nint OBJ_NAME_new_index(unsigned long (*hash_func) (const char *),\n                       int (*cmp_func) (const char *, const char *),\n                       void (*free_func) (const char *, int, const char *));\nconst char *OBJ_NAME_get(const char *name, int type);\nint OBJ_NAME_add(const char *name, int type, const char *data);\nint OBJ_NAME_remove(const char *name, int type);\nvoid OBJ_NAME_cleanup(int type); /* -1 for everything */\nvoid OBJ_NAME_do_all(int type, void (*fn) (const OBJ_NAME *, void *arg),\n                     void *arg);\nvoid OBJ_NAME_do_all_sorted(int type,\n                            void (*fn) (const OBJ_NAME *, void *arg),\n                            void *arg);\n\nASN1_OBJECT *OBJ_dup(const ASN1_OBJECT *o);\nASN1_OBJECT *OBJ_nid2obj(int n);\nconst char *OBJ_nid2ln(int n);\nconst char *OBJ_nid2sn(int n);\nint OBJ_obj2nid(const ASN1_OBJECT *o);\nASN1_OBJECT *OBJ_txt2obj(const char *s, int no_name);\nint OBJ_obj2txt(char *buf, int buf_len, const ASN1_OBJECT *a, int no_name);\nint OBJ_txt2nid(const char *s);\nint OBJ_ln2nid(const char *s);\nint OBJ_sn2nid(const char *s);\nint OBJ_cmp(const ASN1_OBJECT *a, const ASN1_OBJECT *b);\nconst void *OBJ_bsearch_(const void *key, const void *base, int num, int size,\n                         int (*cmp) (const void *, const void *));\nconst void *OBJ_bsearch_ex_(const void *key, const void *base, int num,\n                            int size,\n                            int (*cmp) (const void *, const void *),\n                            int flags);\n\n# define _DECLARE_OBJ_BSEARCH_CMP_FN(scope, type1, type2, nm)    \\\n  static int nm##_cmp_BSEARCH_CMP_FN(const void *, const void *); \\\n  static int nm##_cmp(type1 const *, type2 const *); \\\n  scope type2 * OBJ_bsearch_##nm(type1 *key, type2 const *base, int num)\n\n# define DECLARE_OBJ_BSEARCH_CMP_FN(type1, type2, cmp)   \\\n  _DECLARE_OBJ_BSEARCH_CMP_FN(static, type1, type2, cmp)\n# define DECLARE_OBJ_BSEARCH_GLOBAL_CMP_FN(type1, type2, nm)     \\\n  type2 * OBJ_bsearch_##nm(type1 *key, type2 const *base, int num)\n\n/*-\n * Unsolved problem: if a type is actually a pointer type, like\n * nid_triple is, then its impossible to get a const where you need\n * it. Consider:\n *\n * typedef int nid_triple[3];\n * const void *a_;\n * const nid_triple const *a = a_;\n *\n * The assignement discards a const because what you really want is:\n *\n * const int const * const *a = a_;\n *\n * But if you do that, you lose the fact that a is an array of 3 ints,\n * which breaks comparison functions.\n *\n * Thus we end up having to cast, sadly, or unpack the\n * declarations. Or, as I finally did in this case, delcare nid_triple\n * to be a struct, which it should have been in the first place.\n *\n * Ben, August 2008.\n *\n * Also, strictly speaking not all types need be const, but handling\n * the non-constness means a lot of complication, and in practice\n * comparison routines do always not touch their arguments.\n */\n\n# define IMPLEMENT_OBJ_BSEARCH_CMP_FN(type1, type2, nm)  \\\n  static int nm##_cmp_BSEARCH_CMP_FN(const void *a_, const void *b_)    \\\n      { \\\n      type1 const *a = a_; \\\n      type2 const *b = b_; \\\n      return nm##_cmp(a,b); \\\n      } \\\n  static type2 *OBJ_bsearch_##nm(type1 *key, type2 const *base, int num) \\\n      { \\\n      return (type2 *)OBJ_bsearch_(key, base, num, sizeof(type2), \\\n                                        nm##_cmp_BSEARCH_CMP_FN); \\\n      } \\\n      extern void dummy_prototype(void)\n\n# define IMPLEMENT_OBJ_BSEARCH_GLOBAL_CMP_FN(type1, type2, nm)   \\\n  static int nm##_cmp_BSEARCH_CMP_FN(const void *a_, const void *b_)    \\\n      { \\\n      type1 const *a = a_; \\\n      type2 const *b = b_; \\\n      return nm##_cmp(a,b); \\\n      } \\\n  type2 *OBJ_bsearch_##nm(type1 *key, type2 const *base, int num) \\\n      { \\\n      return (type2 *)OBJ_bsearch_(key, base, num, sizeof(type2), \\\n                                        nm##_cmp_BSEARCH_CMP_FN); \\\n      } \\\n      extern void dummy_prototype(void)\n\n# define OBJ_bsearch(type1,key,type2,base,num,cmp)                              \\\n  ((type2 *)OBJ_bsearch_(CHECKED_PTR_OF(type1,key),CHECKED_PTR_OF(type2,base), \\\n                         num,sizeof(type2),                             \\\n                         ((void)CHECKED_PTR_OF(type1,cmp##_type_1),     \\\n                          (void)CHECKED_PTR_OF(type2,cmp##_type_2),     \\\n                          cmp##_BSEARCH_CMP_FN)))\n\n# define OBJ_bsearch_ex(type1,key,type2,base,num,cmp,flags)                      \\\n  ((type2 *)OBJ_bsearch_ex_(CHECKED_PTR_OF(type1,key),CHECKED_PTR_OF(type2,base), \\\n                         num,sizeof(type2),                             \\\n                         ((void)CHECKED_PTR_OF(type1,cmp##_type_1),     \\\n                          (void)type_2=CHECKED_PTR_OF(type2,cmp##_type_2), \\\n                          cmp##_BSEARCH_CMP_FN)),flags)\n\nint OBJ_new_nid(int num);\nint OBJ_add_object(const ASN1_OBJECT *obj);\nint OBJ_create(const char *oid, const char *sn, const char *ln);\nvoid OBJ_cleanup(void);\nint OBJ_create_objects(BIO *in);\n\nint OBJ_find_sigid_algs(int signid, int *pdig_nid, int *ppkey_nid);\nint OBJ_find_sigid_by_algs(int *psignid, int dig_nid, int pkey_nid);\nint OBJ_add_sigid(int signid, int dig_id, int pkey_id);\nvoid OBJ_sigid_free(void);\n\nextern int obj_cleanup_defer;\nvoid check_defer(int nid);\n\n/* BEGIN ERROR CODES */\n/*\n * The following lines are auto generated by the script mkerr.pl. Any changes\n * made after this point may be overwritten when the script is next run.\n */\nvoid ERR_load_OBJ_strings(void);\n\n/* Error codes for the OBJ functions. */\n\n/* Function codes. */\n# define OBJ_F_OBJ_ADD_OBJECT                             105\n# define OBJ_F_OBJ_CREATE                                 100\n# define OBJ_F_OBJ_DUP                                    101\n# define OBJ_F_OBJ_NAME_NEW_INDEX                         106\n# define OBJ_F_OBJ_NID2LN                                 102\n# define OBJ_F_OBJ_NID2OBJ                                103\n# define OBJ_F_OBJ_NID2SN                                 104\n\n/* Reason codes. */\n# define OBJ_R_MALLOC_FAILURE                             100\n# define OBJ_R_UNKNOWN_NID                                101\n\n#ifdef  __cplusplus\n}\n#endif\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/arm64/include/openssl/ocsp.h",
    "content": "/* ocsp.h */\n/*\n * Written by Tom Titchener <Tom_Titchener@groove.net> for the OpenSSL\n * project.\n */\n\n/*\n * History: This file was transfered to Richard Levitte from CertCo by Kathy\n * Weinhold in mid-spring 2000 to be included in OpenSSL or released as a\n * patch kit.\n */\n\n/* ====================================================================\n * Copyright (c) 1998-2000 The OpenSSL Project.  All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n *\n * 1. Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n *\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in\n *    the documentation and/or other materials provided with the\n *    distribution.\n *\n * 3. All advertising materials mentioning features or use of this\n *    software must display the following acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit. (http://www.openssl.org/)\"\n *\n * 4. The names \"OpenSSL Toolkit\" and \"OpenSSL Project\" must not be used to\n *    endorse or promote products derived from this software without\n *    prior written permission. For written permission, please contact\n *    openssl-core@openssl.org.\n *\n * 5. Products derived from this software may not be called \"OpenSSL\"\n *    nor may \"OpenSSL\" appear in their names without prior written\n *    permission of the OpenSSL Project.\n *\n * 6. Redistributions of any form whatsoever must retain the following\n *    acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit (http://www.openssl.org/)\"\n *\n * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY\n * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\n * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR\n * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\n * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,\n * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED\n * OF THE POSSIBILITY OF SUCH DAMAGE.\n * ====================================================================\n *\n * This product includes cryptographic software written by Eric Young\n * (eay@cryptsoft.com).  This product includes software written by Tim\n * Hudson (tjh@cryptsoft.com).\n *\n */\n\n#ifndef HEADER_OCSP_H\n# define HEADER_OCSP_H\n\n# include <openssl/ossl_typ.h>\n# include <openssl/x509.h>\n# include <openssl/x509v3.h>\n# include <openssl/safestack.h>\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n/* Various flags and values */\n\n# define OCSP_DEFAULT_NONCE_LENGTH       16\n\n# define OCSP_NOCERTS                    0x1\n# define OCSP_NOINTERN                   0x2\n# define OCSP_NOSIGS                     0x4\n# define OCSP_NOCHAIN                    0x8\n# define OCSP_NOVERIFY                   0x10\n# define OCSP_NOEXPLICIT                 0x20\n# define OCSP_NOCASIGN                   0x40\n# define OCSP_NODELEGATED                0x80\n# define OCSP_NOCHECKS                   0x100\n# define OCSP_TRUSTOTHER                 0x200\n# define OCSP_RESPID_KEY                 0x400\n# define OCSP_NOTIME                     0x800\n\n/*-  CertID ::= SEQUENCE {\n *       hashAlgorithm            AlgorithmIdentifier,\n *       issuerNameHash     OCTET STRING, -- Hash of Issuer's DN\n *       issuerKeyHash      OCTET STRING, -- Hash of Issuers public key (excluding the tag & length fields)\n *       serialNumber       CertificateSerialNumber }\n */\ntypedef struct ocsp_cert_id_st {\n    X509_ALGOR *hashAlgorithm;\n    ASN1_OCTET_STRING *issuerNameHash;\n    ASN1_OCTET_STRING *issuerKeyHash;\n    ASN1_INTEGER *serialNumber;\n} OCSP_CERTID;\n\nDECLARE_STACK_OF(OCSP_CERTID)\n\n/*-  Request ::=     SEQUENCE {\n *       reqCert                    CertID,\n *       singleRequestExtensions    [0] EXPLICIT Extensions OPTIONAL }\n */\ntypedef struct ocsp_one_request_st {\n    OCSP_CERTID *reqCert;\n    STACK_OF(X509_EXTENSION) *singleRequestExtensions;\n} OCSP_ONEREQ;\n\nDECLARE_STACK_OF(OCSP_ONEREQ)\nDECLARE_ASN1_SET_OF(OCSP_ONEREQ)\n\n/*-  TBSRequest      ::=     SEQUENCE {\n *       version             [0] EXPLICIT Version DEFAULT v1,\n *       requestorName       [1] EXPLICIT GeneralName OPTIONAL,\n *       requestList             SEQUENCE OF Request,\n *       requestExtensions   [2] EXPLICIT Extensions OPTIONAL }\n */\ntypedef struct ocsp_req_info_st {\n    ASN1_INTEGER *version;\n    GENERAL_NAME *requestorName;\n    STACK_OF(OCSP_ONEREQ) *requestList;\n    STACK_OF(X509_EXTENSION) *requestExtensions;\n} OCSP_REQINFO;\n\n/*-  Signature       ::=     SEQUENCE {\n *       signatureAlgorithm   AlgorithmIdentifier,\n *       signature            BIT STRING,\n *       certs                [0] EXPLICIT SEQUENCE OF Certificate OPTIONAL }\n */\ntypedef struct ocsp_signature_st {\n    X509_ALGOR *signatureAlgorithm;\n    ASN1_BIT_STRING *signature;\n    STACK_OF(X509) *certs;\n} OCSP_SIGNATURE;\n\n/*-  OCSPRequest     ::=     SEQUENCE {\n *       tbsRequest                  TBSRequest,\n *       optionalSignature   [0]     EXPLICIT Signature OPTIONAL }\n */\ntypedef struct ocsp_request_st {\n    OCSP_REQINFO *tbsRequest;\n    OCSP_SIGNATURE *optionalSignature; /* OPTIONAL */\n} OCSP_REQUEST;\n\n/*-  OCSPResponseStatus ::= ENUMERATED {\n *       successful            (0),      --Response has valid confirmations\n *       malformedRequest      (1),      --Illegal confirmation request\n *       internalError         (2),      --Internal error in issuer\n *       tryLater              (3),      --Try again later\n *                                       --(4) is not used\n *       sigRequired           (5),      --Must sign the request\n *       unauthorized          (6)       --Request unauthorized\n *   }\n */\n# define OCSP_RESPONSE_STATUS_SUCCESSFUL          0\n# define OCSP_RESPONSE_STATUS_MALFORMEDREQUEST     1\n# define OCSP_RESPONSE_STATUS_INTERNALERROR        2\n# define OCSP_RESPONSE_STATUS_TRYLATER             3\n# define OCSP_RESPONSE_STATUS_SIGREQUIRED          5\n# define OCSP_RESPONSE_STATUS_UNAUTHORIZED         6\n\n/*-  ResponseBytes ::=       SEQUENCE {\n *       responseType   OBJECT IDENTIFIER,\n *       response       OCTET STRING }\n */\ntypedef struct ocsp_resp_bytes_st {\n    ASN1_OBJECT *responseType;\n    ASN1_OCTET_STRING *response;\n} OCSP_RESPBYTES;\n\n/*-  OCSPResponse ::= SEQUENCE {\n *      responseStatus         OCSPResponseStatus,\n *      responseBytes          [0] EXPLICIT ResponseBytes OPTIONAL }\n */\nstruct ocsp_response_st {\n    ASN1_ENUMERATED *responseStatus;\n    OCSP_RESPBYTES *responseBytes;\n};\n\n/*-  ResponderID ::= CHOICE {\n *      byName   [1] Name,\n *      byKey    [2] KeyHash }\n */\n# define V_OCSP_RESPID_NAME 0\n# define V_OCSP_RESPID_KEY  1\nstruct ocsp_responder_id_st {\n    int type;\n    union {\n        X509_NAME *byName;\n        ASN1_OCTET_STRING *byKey;\n    } value;\n};\n\nDECLARE_STACK_OF(OCSP_RESPID)\nDECLARE_ASN1_FUNCTIONS(OCSP_RESPID)\n\n/*-  KeyHash ::= OCTET STRING --SHA-1 hash of responder's public key\n *                            --(excluding the tag and length fields)\n */\n\n/*-  RevokedInfo ::= SEQUENCE {\n *       revocationTime              GeneralizedTime,\n *       revocationReason    [0]     EXPLICIT CRLReason OPTIONAL }\n */\ntypedef struct ocsp_revoked_info_st {\n    ASN1_GENERALIZEDTIME *revocationTime;\n    ASN1_ENUMERATED *revocationReason;\n} OCSP_REVOKEDINFO;\n\n/*-  CertStatus ::= CHOICE {\n *       good                [0]     IMPLICIT NULL,\n *       revoked             [1]     IMPLICIT RevokedInfo,\n *       unknown             [2]     IMPLICIT UnknownInfo }\n */\n# define V_OCSP_CERTSTATUS_GOOD    0\n# define V_OCSP_CERTSTATUS_REVOKED 1\n# define V_OCSP_CERTSTATUS_UNKNOWN 2\ntypedef struct ocsp_cert_status_st {\n    int type;\n    union {\n        ASN1_NULL *good;\n        OCSP_REVOKEDINFO *revoked;\n        ASN1_NULL *unknown;\n    } value;\n} OCSP_CERTSTATUS;\n\n/*-  SingleResponse ::= SEQUENCE {\n *      certID                       CertID,\n *      certStatus                   CertStatus,\n *      thisUpdate                   GeneralizedTime,\n *      nextUpdate           [0]     EXPLICIT GeneralizedTime OPTIONAL,\n *      singleExtensions     [1]     EXPLICIT Extensions OPTIONAL }\n */\ntypedef struct ocsp_single_response_st {\n    OCSP_CERTID *certId;\n    OCSP_CERTSTATUS *certStatus;\n    ASN1_GENERALIZEDTIME *thisUpdate;\n    ASN1_GENERALIZEDTIME *nextUpdate;\n    STACK_OF(X509_EXTENSION) *singleExtensions;\n} OCSP_SINGLERESP;\n\nDECLARE_STACK_OF(OCSP_SINGLERESP)\nDECLARE_ASN1_SET_OF(OCSP_SINGLERESP)\n\n/*-  ResponseData ::= SEQUENCE {\n *      version              [0] EXPLICIT Version DEFAULT v1,\n *      responderID              ResponderID,\n *      producedAt               GeneralizedTime,\n *      responses                SEQUENCE OF SingleResponse,\n *      responseExtensions   [1] EXPLICIT Extensions OPTIONAL }\n */\ntypedef struct ocsp_response_data_st {\n    ASN1_INTEGER *version;\n    OCSP_RESPID *responderId;\n    ASN1_GENERALIZEDTIME *producedAt;\n    STACK_OF(OCSP_SINGLERESP) *responses;\n    STACK_OF(X509_EXTENSION) *responseExtensions;\n} OCSP_RESPDATA;\n\n/*-  BasicOCSPResponse       ::= SEQUENCE {\n *      tbsResponseData      ResponseData,\n *      signatureAlgorithm   AlgorithmIdentifier,\n *      signature            BIT STRING,\n *      certs                [0] EXPLICIT SEQUENCE OF Certificate OPTIONAL }\n */\n  /*\n   * Note 1: The value for \"signature\" is specified in the OCSP rfc2560 as\n   * follows: \"The value for the signature SHALL be computed on the hash of\n   * the DER encoding ResponseData.\" This means that you must hash the\n   * DER-encoded tbsResponseData, and then run it through a crypto-signing\n   * function, which will (at least w/RSA) do a hash-'n'-private-encrypt\n   * operation.  This seems a bit odd, but that's the spec.  Also note that\n   * the data structures do not leave anywhere to independently specify the\n   * algorithm used for the initial hash. So, we look at the\n   * signature-specification algorithm, and try to do something intelligent.\n   * -- Kathy Weinhold, CertCo\n   */\n  /*\n   * Note 2: It seems that the mentioned passage from RFC 2560 (section\n   * 4.2.1) is open for interpretation.  I've done tests against another\n   * responder, and found that it doesn't do the double hashing that the RFC\n   * seems to say one should.  Therefore, all relevant functions take a flag\n   * saying which variant should be used.  -- Richard Levitte, OpenSSL team\n   * and CeloCom\n   */\ntypedef struct ocsp_basic_response_st {\n    OCSP_RESPDATA *tbsResponseData;\n    X509_ALGOR *signatureAlgorithm;\n    ASN1_BIT_STRING *signature;\n    STACK_OF(X509) *certs;\n} OCSP_BASICRESP;\n\n/*-\n *   CRLReason ::= ENUMERATED {\n *        unspecified             (0),\n *        keyCompromise           (1),\n *        cACompromise            (2),\n *        affiliationChanged      (3),\n *        superseded              (4),\n *        cessationOfOperation    (5),\n *        certificateHold         (6),\n *        removeFromCRL           (8) }\n */\n# define OCSP_REVOKED_STATUS_NOSTATUS               -1\n# define OCSP_REVOKED_STATUS_UNSPECIFIED             0\n# define OCSP_REVOKED_STATUS_KEYCOMPROMISE           1\n# define OCSP_REVOKED_STATUS_CACOMPROMISE            2\n# define OCSP_REVOKED_STATUS_AFFILIATIONCHANGED      3\n# define OCSP_REVOKED_STATUS_SUPERSEDED              4\n# define OCSP_REVOKED_STATUS_CESSATIONOFOPERATION    5\n# define OCSP_REVOKED_STATUS_CERTIFICATEHOLD         6\n# define OCSP_REVOKED_STATUS_REMOVEFROMCRL           8\n\n/*-\n * CrlID ::= SEQUENCE {\n *     crlUrl               [0]     EXPLICIT IA5String OPTIONAL,\n *     crlNum               [1]     EXPLICIT INTEGER OPTIONAL,\n *     crlTime              [2]     EXPLICIT GeneralizedTime OPTIONAL }\n */\ntypedef struct ocsp_crl_id_st {\n    ASN1_IA5STRING *crlUrl;\n    ASN1_INTEGER *crlNum;\n    ASN1_GENERALIZEDTIME *crlTime;\n} OCSP_CRLID;\n\n/*-\n * ServiceLocator ::= SEQUENCE {\n *      issuer    Name,\n *      locator   AuthorityInfoAccessSyntax OPTIONAL }\n */\ntypedef struct ocsp_service_locator_st {\n    X509_NAME *issuer;\n    STACK_OF(ACCESS_DESCRIPTION) *locator;\n} OCSP_SERVICELOC;\n\n# define PEM_STRING_OCSP_REQUEST \"OCSP REQUEST\"\n# define PEM_STRING_OCSP_RESPONSE \"OCSP RESPONSE\"\n\n# define d2i_OCSP_REQUEST_bio(bp,p) ASN1_d2i_bio_of(OCSP_REQUEST,OCSP_REQUEST_new,d2i_OCSP_REQUEST,bp,p)\n\n# define d2i_OCSP_RESPONSE_bio(bp,p) ASN1_d2i_bio_of(OCSP_RESPONSE,OCSP_RESPONSE_new,d2i_OCSP_RESPONSE,bp,p)\n\n# define PEM_read_bio_OCSP_REQUEST(bp,x,cb) (OCSP_REQUEST *)PEM_ASN1_read_bio( \\\n     (char *(*)())d2i_OCSP_REQUEST,PEM_STRING_OCSP_REQUEST,bp,(char **)x,cb,NULL)\n\n# define PEM_read_bio_OCSP_RESPONSE(bp,x,cb)(OCSP_RESPONSE *)PEM_ASN1_read_bio(\\\n     (char *(*)())d2i_OCSP_RESPONSE,PEM_STRING_OCSP_RESPONSE,bp,(char **)x,cb,NULL)\n\n# define PEM_write_bio_OCSP_REQUEST(bp,o) \\\n    PEM_ASN1_write_bio((int (*)())i2d_OCSP_REQUEST,PEM_STRING_OCSP_REQUEST,\\\n                        bp,(char *)o, NULL,NULL,0,NULL,NULL)\n\n# define PEM_write_bio_OCSP_RESPONSE(bp,o) \\\n    PEM_ASN1_write_bio((int (*)())i2d_OCSP_RESPONSE,PEM_STRING_OCSP_RESPONSE,\\\n                        bp,(char *)o, NULL,NULL,0,NULL,NULL)\n\n# define i2d_OCSP_RESPONSE_bio(bp,o) ASN1_i2d_bio_of(OCSP_RESPONSE,i2d_OCSP_RESPONSE,bp,o)\n\n# define i2d_OCSP_REQUEST_bio(bp,o) ASN1_i2d_bio_of(OCSP_REQUEST,i2d_OCSP_REQUEST,bp,o)\n\n# define OCSP_REQUEST_sign(o,pkey,md) \\\n        ASN1_item_sign(ASN1_ITEM_rptr(OCSP_REQINFO),\\\n                o->optionalSignature->signatureAlgorithm,NULL,\\\n                o->optionalSignature->signature,o->tbsRequest,pkey,md)\n\n# define OCSP_BASICRESP_sign(o,pkey,md,d) \\\n        ASN1_item_sign(ASN1_ITEM_rptr(OCSP_RESPDATA),o->signatureAlgorithm,NULL,\\\n                o->signature,o->tbsResponseData,pkey,md)\n\n# define OCSP_REQUEST_verify(a,r) ASN1_item_verify(ASN1_ITEM_rptr(OCSP_REQINFO),\\\n        a->optionalSignature->signatureAlgorithm,\\\n        a->optionalSignature->signature,a->tbsRequest,r)\n\n# define OCSP_BASICRESP_verify(a,r,d) ASN1_item_verify(ASN1_ITEM_rptr(OCSP_RESPDATA),\\\n        a->signatureAlgorithm,a->signature,a->tbsResponseData,r)\n\n# define ASN1_BIT_STRING_digest(data,type,md,len) \\\n        ASN1_item_digest(ASN1_ITEM_rptr(ASN1_BIT_STRING),type,data,md,len)\n\n# define OCSP_CERTSTATUS_dup(cs)\\\n                (OCSP_CERTSTATUS*)ASN1_dup((int(*)())i2d_OCSP_CERTSTATUS,\\\n                (char *(*)())d2i_OCSP_CERTSTATUS,(char *)(cs))\n\nOCSP_CERTID *OCSP_CERTID_dup(OCSP_CERTID *id);\n\nOCSP_RESPONSE *OCSP_sendreq_bio(BIO *b, const char *path, OCSP_REQUEST *req);\nOCSP_REQ_CTX *OCSP_sendreq_new(BIO *io, const char *path, OCSP_REQUEST *req,\n                               int maxline);\nint OCSP_REQ_CTX_nbio(OCSP_REQ_CTX *rctx);\nint OCSP_sendreq_nbio(OCSP_RESPONSE **presp, OCSP_REQ_CTX *rctx);\nOCSP_REQ_CTX *OCSP_REQ_CTX_new(BIO *io, int maxline);\nvoid OCSP_REQ_CTX_free(OCSP_REQ_CTX *rctx);\nvoid OCSP_set_max_response_length(OCSP_REQ_CTX *rctx, unsigned long len);\nint OCSP_REQ_CTX_i2d(OCSP_REQ_CTX *rctx, const ASN1_ITEM *it,\n                     ASN1_VALUE *val);\nint OCSP_REQ_CTX_nbio_d2i(OCSP_REQ_CTX *rctx, ASN1_VALUE **pval,\n                          const ASN1_ITEM *it);\nBIO *OCSP_REQ_CTX_get0_mem_bio(OCSP_REQ_CTX *rctx);\nint OCSP_REQ_CTX_i2d(OCSP_REQ_CTX *rctx, const ASN1_ITEM *it,\n                     ASN1_VALUE *val);\nint OCSP_REQ_CTX_http(OCSP_REQ_CTX *rctx, const char *op, const char *path);\nint OCSP_REQ_CTX_set1_req(OCSP_REQ_CTX *rctx, OCSP_REQUEST *req);\nint OCSP_REQ_CTX_add1_header(OCSP_REQ_CTX *rctx,\n                             const char *name, const char *value);\n\nOCSP_CERTID *OCSP_cert_to_id(const EVP_MD *dgst, X509 *subject, X509 *issuer);\n\nOCSP_CERTID *OCSP_cert_id_new(const EVP_MD *dgst,\n                              X509_NAME *issuerName,\n                              ASN1_BIT_STRING *issuerKey,\n                              ASN1_INTEGER *serialNumber);\n\nOCSP_ONEREQ *OCSP_request_add0_id(OCSP_REQUEST *req, OCSP_CERTID *cid);\n\nint OCSP_request_add1_nonce(OCSP_REQUEST *req, unsigned char *val, int len);\nint OCSP_basic_add1_nonce(OCSP_BASICRESP *resp, unsigned char *val, int len);\nint OCSP_check_nonce(OCSP_REQUEST *req, OCSP_BASICRESP *bs);\nint OCSP_copy_nonce(OCSP_BASICRESP *resp, OCSP_REQUEST *req);\n\nint OCSP_request_set1_name(OCSP_REQUEST *req, X509_NAME *nm);\nint OCSP_request_add1_cert(OCSP_REQUEST *req, X509 *cert);\n\nint OCSP_request_sign(OCSP_REQUEST *req,\n                      X509 *signer,\n                      EVP_PKEY *key,\n                      const EVP_MD *dgst,\n                      STACK_OF(X509) *certs, unsigned long flags);\n\nint OCSP_response_status(OCSP_RESPONSE *resp);\nOCSP_BASICRESP *OCSP_response_get1_basic(OCSP_RESPONSE *resp);\n\nint OCSP_resp_count(OCSP_BASICRESP *bs);\nOCSP_SINGLERESP *OCSP_resp_get0(OCSP_BASICRESP *bs, int idx);\nint OCSP_resp_find(OCSP_BASICRESP *bs, OCSP_CERTID *id, int last);\nint OCSP_single_get0_status(OCSP_SINGLERESP *single, int *reason,\n                            ASN1_GENERALIZEDTIME **revtime,\n                            ASN1_GENERALIZEDTIME **thisupd,\n                            ASN1_GENERALIZEDTIME **nextupd);\nint OCSP_resp_find_status(OCSP_BASICRESP *bs, OCSP_CERTID *id, int *status,\n                          int *reason,\n                          ASN1_GENERALIZEDTIME **revtime,\n                          ASN1_GENERALIZEDTIME **thisupd,\n                          ASN1_GENERALIZEDTIME **nextupd);\nint OCSP_check_validity(ASN1_GENERALIZEDTIME *thisupd,\n                        ASN1_GENERALIZEDTIME *nextupd, long sec, long maxsec);\n\nint OCSP_request_verify(OCSP_REQUEST *req, STACK_OF(X509) *certs,\n                        X509_STORE *store, unsigned long flags);\n\nint OCSP_parse_url(const char *url, char **phost, char **pport, char **ppath,\n                   int *pssl);\n\nint OCSP_id_issuer_cmp(OCSP_CERTID *a, OCSP_CERTID *b);\nint OCSP_id_cmp(OCSP_CERTID *a, OCSP_CERTID *b);\n\nint OCSP_request_onereq_count(OCSP_REQUEST *req);\nOCSP_ONEREQ *OCSP_request_onereq_get0(OCSP_REQUEST *req, int i);\nOCSP_CERTID *OCSP_onereq_get0_id(OCSP_ONEREQ *one);\nint OCSP_id_get0_info(ASN1_OCTET_STRING **piNameHash, ASN1_OBJECT **pmd,\n                      ASN1_OCTET_STRING **pikeyHash,\n                      ASN1_INTEGER **pserial, OCSP_CERTID *cid);\nint OCSP_request_is_signed(OCSP_REQUEST *req);\nOCSP_RESPONSE *OCSP_response_create(int status, OCSP_BASICRESP *bs);\nOCSP_SINGLERESP *OCSP_basic_add1_status(OCSP_BASICRESP *rsp,\n                                        OCSP_CERTID *cid,\n                                        int status, int reason,\n                                        ASN1_TIME *revtime,\n                                        ASN1_TIME *thisupd,\n                                        ASN1_TIME *nextupd);\nint OCSP_basic_add1_cert(OCSP_BASICRESP *resp, X509 *cert);\nint OCSP_basic_sign(OCSP_BASICRESP *brsp,\n                    X509 *signer, EVP_PKEY *key, const EVP_MD *dgst,\n                    STACK_OF(X509) *certs, unsigned long flags);\n\nX509_EXTENSION *OCSP_crlID_new(char *url, long *n, char *tim);\n\nX509_EXTENSION *OCSP_accept_responses_new(char **oids);\n\nX509_EXTENSION *OCSP_archive_cutoff_new(char *tim);\n\nX509_EXTENSION *OCSP_url_svcloc_new(X509_NAME *issuer, char **urls);\n\nint OCSP_REQUEST_get_ext_count(OCSP_REQUEST *x);\nint OCSP_REQUEST_get_ext_by_NID(OCSP_REQUEST *x, int nid, int lastpos);\nint OCSP_REQUEST_get_ext_by_OBJ(OCSP_REQUEST *x, ASN1_OBJECT *obj,\n                                int lastpos);\nint OCSP_REQUEST_get_ext_by_critical(OCSP_REQUEST *x, int crit, int lastpos);\nX509_EXTENSION *OCSP_REQUEST_get_ext(OCSP_REQUEST *x, int loc);\nX509_EXTENSION *OCSP_REQUEST_delete_ext(OCSP_REQUEST *x, int loc);\nvoid *OCSP_REQUEST_get1_ext_d2i(OCSP_REQUEST *x, int nid, int *crit,\n                                int *idx);\nint OCSP_REQUEST_add1_ext_i2d(OCSP_REQUEST *x, int nid, void *value, int crit,\n                              unsigned long flags);\nint OCSP_REQUEST_add_ext(OCSP_REQUEST *x, X509_EXTENSION *ex, int loc);\n\nint OCSP_ONEREQ_get_ext_count(OCSP_ONEREQ *x);\nint OCSP_ONEREQ_get_ext_by_NID(OCSP_ONEREQ *x, int nid, int lastpos);\nint OCSP_ONEREQ_get_ext_by_OBJ(OCSP_ONEREQ *x, ASN1_OBJECT *obj, int lastpos);\nint OCSP_ONEREQ_get_ext_by_critical(OCSP_ONEREQ *x, int crit, int lastpos);\nX509_EXTENSION *OCSP_ONEREQ_get_ext(OCSP_ONEREQ *x, int loc);\nX509_EXTENSION *OCSP_ONEREQ_delete_ext(OCSP_ONEREQ *x, int loc);\nvoid *OCSP_ONEREQ_get1_ext_d2i(OCSP_ONEREQ *x, int nid, int *crit, int *idx);\nint OCSP_ONEREQ_add1_ext_i2d(OCSP_ONEREQ *x, int nid, void *value, int crit,\n                             unsigned long flags);\nint OCSP_ONEREQ_add_ext(OCSP_ONEREQ *x, X509_EXTENSION *ex, int loc);\n\nint OCSP_BASICRESP_get_ext_count(OCSP_BASICRESP *x);\nint OCSP_BASICRESP_get_ext_by_NID(OCSP_BASICRESP *x, int nid, int lastpos);\nint OCSP_BASICRESP_get_ext_by_OBJ(OCSP_BASICRESP *x, ASN1_OBJECT *obj,\n                                  int lastpos);\nint OCSP_BASICRESP_get_ext_by_critical(OCSP_BASICRESP *x, int crit,\n                                       int lastpos);\nX509_EXTENSION *OCSP_BASICRESP_get_ext(OCSP_BASICRESP *x, int loc);\nX509_EXTENSION *OCSP_BASICRESP_delete_ext(OCSP_BASICRESP *x, int loc);\nvoid *OCSP_BASICRESP_get1_ext_d2i(OCSP_BASICRESP *x, int nid, int *crit,\n                                  int *idx);\nint OCSP_BASICRESP_add1_ext_i2d(OCSP_BASICRESP *x, int nid, void *value,\n                                int crit, unsigned long flags);\nint OCSP_BASICRESP_add_ext(OCSP_BASICRESP *x, X509_EXTENSION *ex, int loc);\n\nint OCSP_SINGLERESP_get_ext_count(OCSP_SINGLERESP *x);\nint OCSP_SINGLERESP_get_ext_by_NID(OCSP_SINGLERESP *x, int nid, int lastpos);\nint OCSP_SINGLERESP_get_ext_by_OBJ(OCSP_SINGLERESP *x, ASN1_OBJECT *obj,\n                                   int lastpos);\nint OCSP_SINGLERESP_get_ext_by_critical(OCSP_SINGLERESP *x, int crit,\n                                        int lastpos);\nX509_EXTENSION *OCSP_SINGLERESP_get_ext(OCSP_SINGLERESP *x, int loc);\nX509_EXTENSION *OCSP_SINGLERESP_delete_ext(OCSP_SINGLERESP *x, int loc);\nvoid *OCSP_SINGLERESP_get1_ext_d2i(OCSP_SINGLERESP *x, int nid, int *crit,\n                                   int *idx);\nint OCSP_SINGLERESP_add1_ext_i2d(OCSP_SINGLERESP *x, int nid, void *value,\n                                 int crit, unsigned long flags);\nint OCSP_SINGLERESP_add_ext(OCSP_SINGLERESP *x, X509_EXTENSION *ex, int loc);\n\nDECLARE_ASN1_FUNCTIONS(OCSP_SINGLERESP)\nDECLARE_ASN1_FUNCTIONS(OCSP_CERTSTATUS)\nDECLARE_ASN1_FUNCTIONS(OCSP_REVOKEDINFO)\nDECLARE_ASN1_FUNCTIONS(OCSP_BASICRESP)\nDECLARE_ASN1_FUNCTIONS(OCSP_RESPDATA)\nDECLARE_ASN1_FUNCTIONS(OCSP_RESPID)\nDECLARE_ASN1_FUNCTIONS(OCSP_RESPONSE)\nDECLARE_ASN1_FUNCTIONS(OCSP_RESPBYTES)\nDECLARE_ASN1_FUNCTIONS(OCSP_ONEREQ)\nDECLARE_ASN1_FUNCTIONS(OCSP_CERTID)\nDECLARE_ASN1_FUNCTIONS(OCSP_REQUEST)\nDECLARE_ASN1_FUNCTIONS(OCSP_SIGNATURE)\nDECLARE_ASN1_FUNCTIONS(OCSP_REQINFO)\nDECLARE_ASN1_FUNCTIONS(OCSP_CRLID)\nDECLARE_ASN1_FUNCTIONS(OCSP_SERVICELOC)\n\nconst char *OCSP_response_status_str(long s);\nconst char *OCSP_cert_status_str(long s);\nconst char *OCSP_crl_reason_str(long s);\n\nint OCSP_REQUEST_print(BIO *bp, OCSP_REQUEST *a, unsigned long flags);\nint OCSP_RESPONSE_print(BIO *bp, OCSP_RESPONSE *o, unsigned long flags);\n\nint OCSP_basic_verify(OCSP_BASICRESP *bs, STACK_OF(X509) *certs,\n                      X509_STORE *st, unsigned long flags);\n\n/* BEGIN ERROR CODES */\n/*\n * The following lines are auto generated by the script mkerr.pl. Any changes\n * made after this point may be overwritten when the script is next run.\n */\nvoid ERR_load_OCSP_strings(void);\n\n/* Error codes for the OCSP functions. */\n\n/* Function codes. */\n# define OCSP_F_ASN1_STRING_ENCODE                        100\n# define OCSP_F_D2I_OCSP_NONCE                            102\n# define OCSP_F_OCSP_BASIC_ADD1_STATUS                    103\n# define OCSP_F_OCSP_BASIC_SIGN                           104\n# define OCSP_F_OCSP_BASIC_VERIFY                         105\n# define OCSP_F_OCSP_CERT_ID_NEW                          101\n# define OCSP_F_OCSP_CHECK_DELEGATED                      106\n# define OCSP_F_OCSP_CHECK_IDS                            107\n# define OCSP_F_OCSP_CHECK_ISSUER                         108\n# define OCSP_F_OCSP_CHECK_VALIDITY                       115\n# define OCSP_F_OCSP_MATCH_ISSUERID                       109\n# define OCSP_F_OCSP_PARSE_URL                            114\n# define OCSP_F_OCSP_REQUEST_SIGN                         110\n# define OCSP_F_OCSP_REQUEST_VERIFY                       116\n# define OCSP_F_OCSP_RESPONSE_GET1_BASIC                  111\n# define OCSP_F_OCSP_SENDREQ_BIO                          112\n# define OCSP_F_OCSP_SENDREQ_NBIO                         117\n# define OCSP_F_PARSE_HTTP_LINE1                          118\n# define OCSP_F_REQUEST_VERIFY                            113\n\n/* Reason codes. */\n# define OCSP_R_BAD_DATA                                  100\n# define OCSP_R_CERTIFICATE_VERIFY_ERROR                  101\n# define OCSP_R_DIGEST_ERR                                102\n# define OCSP_R_ERROR_IN_NEXTUPDATE_FIELD                 122\n# define OCSP_R_ERROR_IN_THISUPDATE_FIELD                 123\n# define OCSP_R_ERROR_PARSING_URL                         121\n# define OCSP_R_MISSING_OCSPSIGNING_USAGE                 103\n# define OCSP_R_NEXTUPDATE_BEFORE_THISUPDATE              124\n# define OCSP_R_NOT_BASIC_RESPONSE                        104\n# define OCSP_R_NO_CERTIFICATES_IN_CHAIN                  105\n# define OCSP_R_NO_CONTENT                                106\n# define OCSP_R_NO_PUBLIC_KEY                             107\n# define OCSP_R_NO_RESPONSE_DATA                          108\n# define OCSP_R_NO_REVOKED_TIME                           109\n# define OCSP_R_PRIVATE_KEY_DOES_NOT_MATCH_CERTIFICATE    110\n# define OCSP_R_REQUEST_NOT_SIGNED                        128\n# define OCSP_R_RESPONSE_CONTAINS_NO_REVOCATION_DATA      111\n# define OCSP_R_ROOT_CA_NOT_TRUSTED                       112\n# define OCSP_R_SERVER_READ_ERROR                         113\n# define OCSP_R_SERVER_RESPONSE_ERROR                     114\n# define OCSP_R_SERVER_RESPONSE_PARSE_ERROR               115\n# define OCSP_R_SERVER_WRITE_ERROR                        116\n# define OCSP_R_SIGNATURE_FAILURE                         117\n# define OCSP_R_SIGNER_CERTIFICATE_NOT_FOUND              118\n# define OCSP_R_STATUS_EXPIRED                            125\n# define OCSP_R_STATUS_NOT_YET_VALID                      126\n# define OCSP_R_STATUS_TOO_OLD                            127\n# define OCSP_R_UNKNOWN_MESSAGE_DIGEST                    119\n# define OCSP_R_UNKNOWN_NID                               120\n# define OCSP_R_UNSUPPORTED_REQUESTORNAME_TYPE            129\n\n#ifdef  __cplusplus\n}\n#endif\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/arm64/include/openssl/opensslconf.h",
    "content": "/* opensslconf.h */\n/* WARNING: Generated automatically from opensslconf.h.in by Configure. */\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n/* OpenSSL was configured with the following options: */\n#ifndef OPENSSL_DOING_MAKEDEPEND\n\n\n#ifndef OPENSSL_NO_CAST\n# define OPENSSL_NO_CAST\n#endif\n#ifndef OPENSSL_NO_COMP\n# define OPENSSL_NO_COMP\n#endif\n#ifndef OPENSSL_NO_DH\n# define OPENSSL_NO_DH\n#endif\n#ifndef OPENSSL_NO_DSA\n# define OPENSSL_NO_DSA\n#endif\n#ifndef OPENSSL_NO_EC\n# define OPENSSL_NO_EC\n#endif\n#ifndef OPENSSL_NO_EC_NISTP_64_GCC_128\n# define OPENSSL_NO_EC_NISTP_64_GCC_128\n#endif\n#ifndef OPENSSL_NO_ECDH\n# define OPENSSL_NO_ECDH\n#endif\n#ifndef OPENSSL_NO_ECDSA\n# define OPENSSL_NO_ECDSA\n#endif\n#ifndef OPENSSL_NO_ENGINE\n# define OPENSSL_NO_ENGINE\n#endif\n#ifndef OPENSSL_NO_FIPS\n# define OPENSSL_NO_FIPS\n#endif\n#ifndef OPENSSL_NO_GMP\n# define OPENSSL_NO_GMP\n#endif\n#ifndef OPENSSL_NO_GOST\n# define OPENSSL_NO_GOST\n#endif\n#ifndef OPENSSL_NO_JPAKE\n# define OPENSSL_NO_JPAKE\n#endif\n#ifndef OPENSSL_NO_KRB5\n# define OPENSSL_NO_KRB5\n#endif\n#ifndef OPENSSL_NO_LIBUNBOUND\n# define OPENSSL_NO_LIBUNBOUND\n#endif\n#ifndef OPENSSL_NO_MD2\n# define OPENSSL_NO_MD2\n#endif\n#ifndef OPENSSL_NO_MD4\n# define OPENSSL_NO_MD4\n#endif\n#ifndef OPENSSL_NO_MD5\n# define OPENSSL_NO_MD5\n#endif\n#ifndef OPENSSL_NO_MDC2\n# define OPENSSL_NO_MDC2\n#endif\n#ifndef OPENSSL_NO_RC2\n# define OPENSSL_NO_RC2\n#endif\n#ifndef OPENSSL_NO_RC5\n# define OPENSSL_NO_RC5\n#endif\n#ifndef OPENSSL_NO_RFC3779\n# define OPENSSL_NO_RFC3779\n#endif\n#ifndef OPENSSL_NO_RIPEMD\n# define OPENSSL_NO_RIPEMD\n#endif\n#ifndef OPENSSL_NO_RSA\n# define OPENSSL_NO_RSA\n#endif\n#ifndef OPENSSL_NO_SCTP\n# define OPENSSL_NO_SCTP\n#endif\n#ifndef OPENSSL_NO_SOCK\n# define OPENSSL_NO_SOCK\n#endif\n#ifndef OPENSSL_NO_SSL_TRACE\n# define OPENSSL_NO_SSL_TRACE\n#endif\n#ifndef OPENSSL_NO_SSL2\n# define OPENSSL_NO_SSL2\n#endif\n#ifndef OPENSSL_NO_SSL3\n# define OPENSSL_NO_SSL3\n#endif\n#ifndef OPENSSL_NO_STORE\n# define OPENSSL_NO_STORE\n#endif\n#ifndef OPENSSL_NO_TLS1\n# define OPENSSL_NO_TLS1\n#endif\n#ifndef OPENSSL_NO_UNIT_TEST\n# define OPENSSL_NO_UNIT_TEST\n#endif\n#ifndef OPENSSL_NO_WEAK_SSL_CIPHERS\n# define OPENSSL_NO_WEAK_SSL_CIPHERS\n#endif\n\n#endif /* OPENSSL_DOING_MAKEDEPEND */\n\n#ifndef OPENSSL_THREADS\n# define OPENSSL_THREADS\n#endif\n#ifndef OPENSSL_NO_HW\n# define OPENSSL_NO_HW\n#endif\n#ifndef OPENSSL_NO_DYNAMIC_ENGINE\n# define OPENSSL_NO_DYNAMIC_ENGINE\n#endif\n\n/* The OPENSSL_NO_* macros are also defined as NO_* if the application\n   asks for it.  This is a transient feature that is provided for those\n   who haven't had the time to do the appropriate changes in their\n   applications.  */\n#ifdef OPENSSL_ALGORITHM_DEFINES\n# if defined(OPENSSL_NO_CAST) && !defined(NO_CAST)\n#  define NO_CAST\n# endif\n# if defined(OPENSSL_NO_COMP) && !defined(NO_COMP)\n#  define NO_COMP\n# endif\n# if defined(OPENSSL_NO_DH) && !defined(NO_DH)\n#  define NO_DH\n# endif\n# if defined(OPENSSL_NO_DSA) && !defined(NO_DSA)\n#  define NO_DSA\n# endif\n# if defined(OPENSSL_NO_EC) && !defined(NO_EC)\n#  define NO_EC\n# endif\n# if defined(OPENSSL_NO_EC_NISTP_64_GCC_128) && !defined(NO_EC_NISTP_64_GCC_128)\n#  define NO_EC_NISTP_64_GCC_128\n# endif\n# if defined(OPENSSL_NO_ECDH) && !defined(NO_ECDH)\n#  define NO_ECDH\n# endif\n# if defined(OPENSSL_NO_ECDSA) && !defined(NO_ECDSA)\n#  define NO_ECDSA\n# endif\n# if defined(OPENSSL_NO_ENGINE) && !defined(NO_ENGINE)\n#  define NO_ENGINE\n# endif\n# if defined(OPENSSL_NO_FIPS) && !defined(NO_FIPS)\n#  define NO_FIPS\n# endif\n# if defined(OPENSSL_NO_GMP) && !defined(NO_GMP)\n#  define NO_GMP\n# endif\n# if defined(OPENSSL_NO_GOST) && !defined(NO_GOST)\n#  define NO_GOST\n# endif\n# if defined(OPENSSL_NO_JPAKE) && !defined(NO_JPAKE)\n#  define NO_JPAKE\n# endif\n# if defined(OPENSSL_NO_KRB5) && !defined(NO_KRB5)\n#  define NO_KRB5\n# endif\n# if defined(OPENSSL_NO_LIBUNBOUND) && !defined(NO_LIBUNBOUND)\n#  define NO_LIBUNBOUND\n# endif\n# if defined(OPENSSL_NO_MD2) && !defined(NO_MD2)\n#  define NO_MD2\n# endif\n# if defined(OPENSSL_NO_MD4) && !defined(NO_MD4)\n#  define NO_MD4\n# endif\n# if defined(OPENSSL_NO_MD5) && !defined(NO_MD5)\n#  define NO_MD5\n# endif\n# if defined(OPENSSL_NO_MDC2) && !defined(NO_MDC2)\n#  define NO_MDC2\n# endif\n# if defined(OPENSSL_NO_RC2) && !defined(NO_RC2)\n#  define NO_RC2\n# endif\n# if defined(OPENSSL_NO_RC5) && !defined(NO_RC5)\n#  define NO_RC5\n# endif\n# if defined(OPENSSL_NO_RFC3779) && !defined(NO_RFC3779)\n#  define NO_RFC3779\n# endif\n# if defined(OPENSSL_NO_RIPEMD) && !defined(NO_RIPEMD)\n#  define NO_RIPEMD\n# endif\n# if defined(OPENSSL_NO_RSA) && !defined(NO_RSA)\n#  define NO_RSA\n# endif\n# if defined(OPENSSL_NO_SCTP) && !defined(NO_SCTP)\n#  define NO_SCTP\n# endif\n# if defined(OPENSSL_NO_SOCK) && !defined(NO_SOCK)\n#  define NO_SOCK\n# endif\n# if defined(OPENSSL_NO_SSL_TRACE) && !defined(NO_SSL_TRACE)\n#  define NO_SSL_TRACE\n# endif\n# if defined(OPENSSL_NO_SSL2) && !defined(NO_SSL2)\n#  define NO_SSL2\n# endif\n# if defined(OPENSSL_NO_SSL3) && !defined(NO_SSL3)\n#  define NO_SSL3\n# endif\n# if defined(OPENSSL_NO_STORE) && !defined(NO_STORE)\n#  define NO_STORE\n# endif\n# if defined(OPENSSL_NO_TLS1) && !defined(NO_TLS1)\n#  define NO_TLS1\n# endif\n# if defined(OPENSSL_NO_UNIT_TEST) && !defined(NO_UNIT_TEST)\n#  define NO_UNIT_TEST\n# endif\n# if defined(OPENSSL_NO_WEAK_SSL_CIPHERS) && !defined(NO_WEAK_SSL_CIPHERS)\n#  define NO_WEAK_SSL_CIPHERS\n# endif\n#endif\n\n#define OPENSSL_CPUID_OBJ\n\n/* crypto/opensslconf.h.in */\n\n/* Generate 80386 code? */\n#undef I386_ONLY\n\n#if !(defined(VMS) || defined(__VMS)) /* VMS uses logical names instead */\n#if defined(HEADER_CRYPTLIB_H) && !defined(OPENSSLDIR)\n#define ENGINESDIR \"/c/projects/wcdb/android/prebuilt/arm64/lib/engines\"\n#define OPENSSLDIR \"/c/projects/wcdb/android/prebuilt/arm64\"\n#endif\n#endif\n\n#undef OPENSSL_UNISTD\n#define OPENSSL_UNISTD <unistd.h>\n\n#undef OPENSSL_EXPORT_VAR_AS_FUNCTION\n\n#if defined(HEADER_IDEA_H) && !defined(IDEA_INT)\n#define IDEA_INT unsigned int\n#endif\n\n#if defined(HEADER_MD2_H) && !defined(MD2_INT)\n#define MD2_INT unsigned int\n#endif\n\n#if defined(HEADER_RC2_H) && !defined(RC2_INT)\n/* I need to put in a mod for the alpha - eay */\n#define RC2_INT unsigned int\n#endif\n\n#if defined(HEADER_RC4_H)\n#if !defined(RC4_INT)\n/* using int types make the structure larger but make the code faster\n * on most boxes I have tested - up to %20 faster. */\n/*\n * I don't know what does \"most\" mean, but declaring \"int\" is a must on:\n * - Intel P6 because partial register stalls are very expensive;\n * - elder Alpha because it lacks byte load/store instructions;\n */\n#define RC4_INT unsigned char\n#endif\n#if !defined(RC4_CHUNK)\n/*\n * This enables code handling data aligned at natural CPU word\n * boundary. See crypto/rc4/rc4_enc.c for further details.\n */\n#define RC4_CHUNK unsigned long\n#endif\n#endif\n\n#if (defined(HEADER_NEW_DES_H) || defined(HEADER_DES_H)) && !defined(DES_LONG)\n/* If this is set to 'unsigned int' on a DEC Alpha, this gives about a\n * %20 speed up (longs are 8 bytes, int's are 4). */\n#ifndef DES_LONG\n#define DES_LONG unsigned int\n#endif\n#endif\n\n#if defined(HEADER_BN_H) && !defined(CONFIG_HEADER_BN_H)\n#define CONFIG_HEADER_BN_H\n#undef BN_LLONG\n\n/* Should we define BN_DIV2W here? */\n\n/* Only one for the following should be defined */\n#define SIXTY_FOUR_BIT_LONG\n#undef SIXTY_FOUR_BIT\n#undef THIRTY_TWO_BIT\n#endif\n\n#if defined(HEADER_RC4_LOCL_H) && !defined(CONFIG_HEADER_RC4_LOCL_H)\n#define CONFIG_HEADER_RC4_LOCL_H\n/* if this is defined data[i] is used instead of *data, this is a %20\n * speedup on x86 */\n#undef RC4_INDEX\n#endif\n\n#if defined(HEADER_BF_LOCL_H) && !defined(CONFIG_HEADER_BF_LOCL_H)\n#define CONFIG_HEADER_BF_LOCL_H\n#define BF_PTR\n#endif /* HEADER_BF_LOCL_H */\n\n#if defined(HEADER_DES_LOCL_H) && !defined(CONFIG_HEADER_DES_LOCL_H)\n#define CONFIG_HEADER_DES_LOCL_H\n#ifndef DES_DEFAULT_OPTIONS\n/* the following is tweaked from a config script, that is why it is a\n * protected undef/define */\n#ifndef DES_PTR\n#undef DES_PTR\n#endif\n\n/* This helps C compiler generate the correct code for multiple functional\n * units.  It reduces register dependancies at the expense of 2 more\n * registers */\n#ifndef DES_RISC1\n#undef DES_RISC1\n#endif\n\n#ifndef DES_RISC2\n#undef DES_RISC2\n#endif\n\n#if defined(DES_RISC1) && defined(DES_RISC2)\n#error YOU SHOULD NOT HAVE BOTH DES_RISC1 AND DES_RISC2 DEFINED!!!!!\n#endif\n\n/* Unroll the inner loop, this sometimes helps, sometimes hinders.\n * Very mucy CPU dependant */\n#ifndef DES_UNROLL\n#define DES_UNROLL\n#endif\n\n/* These default values were supplied by\n * Peter Gutman <pgut001@cs.auckland.ac.nz>\n * They are only used if nothing else has been defined */\n#if !defined(DES_PTR) && !defined(DES_RISC1) && !defined(DES_RISC2) && !defined(DES_UNROLL)\n/* Special defines which change the way the code is built depending on the\n   CPU and OS.  For SGI machines you can use _MIPS_SZLONG (32 or 64) to find\n   even newer MIPS CPU's, but at the moment one size fits all for\n   optimization options.  Older Sparc's work better with only UNROLL, but\n   there's no way to tell at compile time what it is you're running on */\n \n#if defined( __sun ) || defined ( sun )\t\t/* Newer Sparc's */\n#  define DES_PTR\n#  define DES_RISC1\n#  define DES_UNROLL\n#elif defined( __ultrix )\t/* Older MIPS */\n#  define DES_PTR\n#  define DES_RISC2\n#  define DES_UNROLL\n#elif defined( __osf1__ )\t/* Alpha */\n#  define DES_PTR\n#  define DES_RISC2\n#elif defined ( _AIX )\t\t/* RS6000 */\n  /* Unknown */\n#elif defined( __hpux )\t\t/* HP-PA */\n  /* Unknown */\n#elif defined( __aux )\t\t/* 68K */\n  /* Unknown */\n#elif defined( __dgux )\t\t/* 88K (but P6 in latest boxes) */\n#  define DES_UNROLL\n#elif defined( __sgi )\t\t/* Newer MIPS */\n#  define DES_PTR\n#  define DES_RISC2\n#  define DES_UNROLL\n#elif defined(i386) || defined(__i386__)\t/* x86 boxes, should be gcc */\n#  define DES_PTR\n#  define DES_RISC1\n#  define DES_UNROLL\n#endif /* Systems-specific speed defines */\n#endif\n\n#endif /* DES_DEFAULT_OPTIONS */\n#endif /* HEADER_DES_LOCL_H */\n#ifdef  __cplusplus\n}\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/arm64/include/openssl/opensslv.h",
    "content": "#ifndef HEADER_OPENSSLV_H\n# define HEADER_OPENSSLV_H\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n/*-\n * Numeric release version identifier:\n * MNNFFPPS: major minor fix patch status\n * The status nibble has one of the values 0 for development, 1 to e for betas\n * 1 to 14, and f for release.  The patch level is exactly that.\n * For example:\n * 0.9.3-dev      0x00903000\n * 0.9.3-beta1    0x00903001\n * 0.9.3-beta2-dev 0x00903002\n * 0.9.3-beta2    0x00903002 (same as ...beta2-dev)\n * 0.9.3          0x0090300f\n * 0.9.3a         0x0090301f\n * 0.9.4          0x0090400f\n * 1.2.3z         0x102031af\n *\n * For continuity reasons (because 0.9.5 is already out, and is coded\n * 0x00905100), between 0.9.5 and 0.9.6 the coding of the patch level\n * part is slightly different, by setting the highest bit.  This means\n * that 0.9.5a looks like this: 0x0090581f.  At 0.9.6, we can start\n * with 0x0090600S...\n *\n * (Prior to 0.9.3-dev a different scheme was used: 0.9.2b is 0x0922.)\n * (Prior to 0.9.5a beta1, a different scheme was used: MMNNFFRBB for\n *  major minor fix final patch/beta)\n */\n# define OPENSSL_VERSION_NUMBER  0x100020bfL\n# ifdef OPENSSL_FIPS\n#  define OPENSSL_VERSION_TEXT    \"OpenSSL 1.0.2k-fips  26 Jan 2017\"\n# else\n#  define OPENSSL_VERSION_TEXT    \"OpenSSL 1.0.2k  26 Jan 2017\"\n# endif\n# define OPENSSL_VERSION_PTEXT   \" part of \" OPENSSL_VERSION_TEXT\n\n/*-\n * The macros below are to be used for shared library (.so, .dll, ...)\n * versioning.  That kind of versioning works a bit differently between\n * operating systems.  The most usual scheme is to set a major and a minor\n * number, and have the runtime loader check that the major number is equal\n * to what it was at application link time, while the minor number has to\n * be greater or equal to what it was at application link time.  With this\n * scheme, the version number is usually part of the file name, like this:\n *\n *      libcrypto.so.0.9\n *\n * Some unixen also make a softlink with the major verson number only:\n *\n *      libcrypto.so.0\n *\n * On Tru64 and IRIX 6.x it works a little bit differently.  There, the\n * shared library version is stored in the file, and is actually a series\n * of versions, separated by colons.  The rightmost version present in the\n * library when linking an application is stored in the application to be\n * matched at run time.  When the application is run, a check is done to\n * see if the library version stored in the application matches any of the\n * versions in the version string of the library itself.\n * This version string can be constructed in any way, depending on what\n * kind of matching is desired.  However, to implement the same scheme as\n * the one used in the other unixen, all compatible versions, from lowest\n * to highest, should be part of the string.  Consecutive builds would\n * give the following versions strings:\n *\n *      3.0\n *      3.0:3.1\n *      3.0:3.1:3.2\n *      4.0\n *      4.0:4.1\n *\n * Notice how version 4 is completely incompatible with version, and\n * therefore give the breach you can see.\n *\n * There may be other schemes as well that I haven't yet discovered.\n *\n * So, here's the way it works here: first of all, the library version\n * number doesn't need at all to match the overall OpenSSL version.\n * However, it's nice and more understandable if it actually does.\n * The current library version is stored in the macro SHLIB_VERSION_NUMBER,\n * which is just a piece of text in the format \"M.m.e\" (Major, minor, edit).\n * For the sake of Tru64, IRIX, and any other OS that behaves in similar ways,\n * we need to keep a history of version numbers, which is done in the\n * macro SHLIB_VERSION_HISTORY.  The numbers are separated by colons and\n * should only keep the versions that are binary compatible with the current.\n */\n# define SHLIB_VERSION_HISTORY \"\"\n# define SHLIB_VERSION_NUMBER \"1.0.0\"\n\n\n#ifdef  __cplusplus\n}\n#endif\n#endif                          /* HEADER_OPENSSLV_H */\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/arm64/include/openssl/ossl_typ.h",
    "content": "/* ====================================================================\n * Copyright (c) 1998-2001 The OpenSSL Project.  All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n *\n * 1. Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n *\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in\n *    the documentation and/or other materials provided with the\n *    distribution.\n *\n * 3. All advertising materials mentioning features or use of this\n *    software must display the following acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit. (http://www.openssl.org/)\"\n *\n * 4. The names \"OpenSSL Toolkit\" and \"OpenSSL Project\" must not be used to\n *    endorse or promote products derived from this software without\n *    prior written permission. For written permission, please contact\n *    openssl-core@openssl.org.\n *\n * 5. Products derived from this software may not be called \"OpenSSL\"\n *    nor may \"OpenSSL\" appear in their names without prior written\n *    permission of the OpenSSL Project.\n *\n * 6. Redistributions of any form whatsoever must retain the following\n *    acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit (http://www.openssl.org/)\"\n *\n * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY\n * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\n * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR\n * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\n * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,\n * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED\n * OF THE POSSIBILITY OF SUCH DAMAGE.\n * ====================================================================\n *\n * This product includes cryptographic software written by Eric Young\n * (eay@cryptsoft.com).  This product includes software written by Tim\n * Hudson (tjh@cryptsoft.com).\n *\n */\n\n#ifndef HEADER_OPENSSL_TYPES_H\n# define HEADER_OPENSSL_TYPES_H\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n# include <openssl/e_os2.h>\n\n# ifdef NO_ASN1_TYPEDEFS\n#  define ASN1_INTEGER            ASN1_STRING\n#  define ASN1_ENUMERATED         ASN1_STRING\n#  define ASN1_BIT_STRING         ASN1_STRING\n#  define ASN1_OCTET_STRING       ASN1_STRING\n#  define ASN1_PRINTABLESTRING    ASN1_STRING\n#  define ASN1_T61STRING          ASN1_STRING\n#  define ASN1_IA5STRING          ASN1_STRING\n#  define ASN1_UTCTIME            ASN1_STRING\n#  define ASN1_GENERALIZEDTIME    ASN1_STRING\n#  define ASN1_TIME               ASN1_STRING\n#  define ASN1_GENERALSTRING      ASN1_STRING\n#  define ASN1_UNIVERSALSTRING    ASN1_STRING\n#  define ASN1_BMPSTRING          ASN1_STRING\n#  define ASN1_VISIBLESTRING      ASN1_STRING\n#  define ASN1_UTF8STRING         ASN1_STRING\n#  define ASN1_BOOLEAN            int\n#  define ASN1_NULL               int\n# else\ntypedef struct asn1_string_st ASN1_INTEGER;\ntypedef struct asn1_string_st ASN1_ENUMERATED;\ntypedef struct asn1_string_st ASN1_BIT_STRING;\ntypedef struct asn1_string_st ASN1_OCTET_STRING;\ntypedef struct asn1_string_st ASN1_PRINTABLESTRING;\ntypedef struct asn1_string_st ASN1_T61STRING;\ntypedef struct asn1_string_st ASN1_IA5STRING;\ntypedef struct asn1_string_st ASN1_GENERALSTRING;\ntypedef struct asn1_string_st ASN1_UNIVERSALSTRING;\ntypedef struct asn1_string_st ASN1_BMPSTRING;\ntypedef struct asn1_string_st ASN1_UTCTIME;\ntypedef struct asn1_string_st ASN1_TIME;\ntypedef struct asn1_string_st ASN1_GENERALIZEDTIME;\ntypedef struct asn1_string_st ASN1_VISIBLESTRING;\ntypedef struct asn1_string_st ASN1_UTF8STRING;\ntypedef struct asn1_string_st ASN1_STRING;\ntypedef int ASN1_BOOLEAN;\ntypedef int ASN1_NULL;\n# endif\n\ntypedef struct asn1_object_st ASN1_OBJECT;\n\ntypedef struct ASN1_ITEM_st ASN1_ITEM;\ntypedef struct asn1_pctx_st ASN1_PCTX;\n\n# ifdef OPENSSL_SYS_WIN32\n#  undef X509_NAME\n#  undef X509_EXTENSIONS\n#  undef X509_CERT_PAIR\n#  undef PKCS7_ISSUER_AND_SERIAL\n#  undef OCSP_REQUEST\n#  undef OCSP_RESPONSE\n# endif\n\n# ifdef BIGNUM\n#  undef BIGNUM\n# endif\ntypedef struct bignum_st BIGNUM;\ntypedef struct bignum_ctx BN_CTX;\ntypedef struct bn_blinding_st BN_BLINDING;\ntypedef struct bn_mont_ctx_st BN_MONT_CTX;\ntypedef struct bn_recp_ctx_st BN_RECP_CTX;\ntypedef struct bn_gencb_st BN_GENCB;\n\ntypedef struct buf_mem_st BUF_MEM;\n\ntypedef struct evp_cipher_st EVP_CIPHER;\ntypedef struct evp_cipher_ctx_st EVP_CIPHER_CTX;\ntypedef struct env_md_st EVP_MD;\ntypedef struct env_md_ctx_st EVP_MD_CTX;\ntypedef struct evp_pkey_st EVP_PKEY;\n\ntypedef struct evp_pkey_asn1_method_st EVP_PKEY_ASN1_METHOD;\n\ntypedef struct evp_pkey_method_st EVP_PKEY_METHOD;\ntypedef struct evp_pkey_ctx_st EVP_PKEY_CTX;\n\ntypedef struct dh_st DH;\ntypedef struct dh_method DH_METHOD;\n\ntypedef struct dsa_st DSA;\ntypedef struct dsa_method DSA_METHOD;\n\ntypedef struct rsa_st RSA;\ntypedef struct rsa_meth_st RSA_METHOD;\n\ntypedef struct rand_meth_st RAND_METHOD;\n\ntypedef struct ecdh_method ECDH_METHOD;\ntypedef struct ecdsa_method ECDSA_METHOD;\n\ntypedef struct x509_st X509;\ntypedef struct X509_algor_st X509_ALGOR;\ntypedef struct X509_crl_st X509_CRL;\ntypedef struct x509_crl_method_st X509_CRL_METHOD;\ntypedef struct x509_revoked_st X509_REVOKED;\ntypedef struct X509_name_st X509_NAME;\ntypedef struct X509_pubkey_st X509_PUBKEY;\ntypedef struct x509_store_st X509_STORE;\ntypedef struct x509_store_ctx_st X509_STORE_CTX;\n\ntypedef struct pkcs8_priv_key_info_st PKCS8_PRIV_KEY_INFO;\n\ntypedef struct v3_ext_ctx X509V3_CTX;\ntypedef struct conf_st CONF;\n\ntypedef struct store_st STORE;\ntypedef struct store_method_st STORE_METHOD;\n\ntypedef struct ui_st UI;\ntypedef struct ui_method_st UI_METHOD;\n\ntypedef struct st_ERR_FNS ERR_FNS;\n\ntypedef struct engine_st ENGINE;\ntypedef struct ssl_st SSL;\ntypedef struct ssl_ctx_st SSL_CTX;\n\ntypedef struct comp_method_st COMP_METHOD;\n\ntypedef struct X509_POLICY_NODE_st X509_POLICY_NODE;\ntypedef struct X509_POLICY_LEVEL_st X509_POLICY_LEVEL;\ntypedef struct X509_POLICY_TREE_st X509_POLICY_TREE;\ntypedef struct X509_POLICY_CACHE_st X509_POLICY_CACHE;\n\ntypedef struct AUTHORITY_KEYID_st AUTHORITY_KEYID;\ntypedef struct DIST_POINT_st DIST_POINT;\ntypedef struct ISSUING_DIST_POINT_st ISSUING_DIST_POINT;\ntypedef struct NAME_CONSTRAINTS_st NAME_CONSTRAINTS;\n\n  /* If placed in pkcs12.h, we end up with a circular depency with pkcs7.h */\n# define DECLARE_PKCS12_STACK_OF(type)/* Nothing */\n# define IMPLEMENT_PKCS12_STACK_OF(type)/* Nothing */\n\ntypedef struct crypto_ex_data_st CRYPTO_EX_DATA;\n/* Callback types for crypto.h */\ntypedef int CRYPTO_EX_new (void *parent, void *ptr, CRYPTO_EX_DATA *ad,\n                           int idx, long argl, void *argp);\ntypedef void CRYPTO_EX_free (void *parent, void *ptr, CRYPTO_EX_DATA *ad,\n                             int idx, long argl, void *argp);\ntypedef int CRYPTO_EX_dup (CRYPTO_EX_DATA *to, CRYPTO_EX_DATA *from,\n                           void *from_d, int idx, long argl, void *argp);\n\ntypedef struct ocsp_req_ctx_st OCSP_REQ_CTX;\ntypedef struct ocsp_response_st OCSP_RESPONSE;\ntypedef struct ocsp_responder_id_st OCSP_RESPID;\n\n#ifdef  __cplusplus\n}\n#endif\n#endif                          /* def HEADER_OPENSSL_TYPES_H */\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/arm64/include/openssl/pem.h",
    "content": "/* crypto/pem/pem.h */\n/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)\n * All rights reserved.\n *\n * This package is an SSL implementation written\n * by Eric Young (eay@cryptsoft.com).\n * The implementation was written so as to conform with Netscapes SSL.\n *\n * This library is free for commercial and non-commercial use as long as\n * the following conditions are aheared to.  The following conditions\n * apply to all code found in this distribution, be it the RC4, RSA,\n * lhash, DES, etc., code; not just the SSL code.  The SSL documentation\n * included with this distribution is covered by the same copyright terms\n * except that the holder is Tim Hudson (tjh@cryptsoft.com).\n *\n * Copyright remains Eric Young's, and as such any Copyright notices in\n * the code are not to be removed.\n * If this package is used in a product, Eric Young should be given attribution\n * as the author of the parts of the library used.\n * This can be in the form of a textual message at program startup or\n * in documentation (online or textual) provided with the package.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the copyright\n *    notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in the\n *    documentation and/or other materials provided with the distribution.\n * 3. All advertising materials mentioning features or use of this software\n *    must display the following acknowledgement:\n *    \"This product includes cryptographic software written by\n *     Eric Young (eay@cryptsoft.com)\"\n *    The word 'cryptographic' can be left out if the rouines from the library\n *    being used are not cryptographic related :-).\n * 4. If you include any Windows specific code (or a derivative thereof) from\n *    the apps directory (application code) you must include an acknowledgement:\n *    \"This product includes software written by Tim Hudson (tjh@cryptsoft.com)\"\n *\n * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n * SUCH DAMAGE.\n *\n * The licence and distribution terms for any publically available version or\n * derivative of this code cannot be changed.  i.e. this code cannot simply be\n * copied and put under another distribution licence\n * [including the GNU Public Licence.]\n */\n\n#ifndef HEADER_PEM_H\n# define HEADER_PEM_H\n\n# include <openssl/e_os2.h>\n# ifndef OPENSSL_NO_BIO\n#  include <openssl/bio.h>\n# endif\n# ifndef OPENSSL_NO_STACK\n#  include <openssl/stack.h>\n# endif\n# include <openssl/evp.h>\n# include <openssl/x509.h>\n# include <openssl/pem2.h>\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n# define PEM_BUFSIZE             1024\n\n# define PEM_OBJ_UNDEF           0\n# define PEM_OBJ_X509            1\n# define PEM_OBJ_X509_REQ        2\n# define PEM_OBJ_CRL             3\n# define PEM_OBJ_SSL_SESSION     4\n# define PEM_OBJ_PRIV_KEY        10\n# define PEM_OBJ_PRIV_RSA        11\n# define PEM_OBJ_PRIV_DSA        12\n# define PEM_OBJ_PRIV_DH         13\n# define PEM_OBJ_PUB_RSA         14\n# define PEM_OBJ_PUB_DSA         15\n# define PEM_OBJ_PUB_DH          16\n# define PEM_OBJ_DHPARAMS        17\n# define PEM_OBJ_DSAPARAMS       18\n# define PEM_OBJ_PRIV_RSA_PUBLIC 19\n# define PEM_OBJ_PRIV_ECDSA      20\n# define PEM_OBJ_PUB_ECDSA       21\n# define PEM_OBJ_ECPARAMETERS    22\n\n# define PEM_ERROR               30\n# define PEM_DEK_DES_CBC         40\n# define PEM_DEK_IDEA_CBC        45\n# define PEM_DEK_DES_EDE         50\n# define PEM_DEK_DES_ECB         60\n# define PEM_DEK_RSA             70\n# define PEM_DEK_RSA_MD2         80\n# define PEM_DEK_RSA_MD5         90\n\n# define PEM_MD_MD2              NID_md2\n# define PEM_MD_MD5              NID_md5\n# define PEM_MD_SHA              NID_sha\n# define PEM_MD_MD2_RSA          NID_md2WithRSAEncryption\n# define PEM_MD_MD5_RSA          NID_md5WithRSAEncryption\n# define PEM_MD_SHA_RSA          NID_sha1WithRSAEncryption\n\n# define PEM_STRING_X509_OLD     \"X509 CERTIFICATE\"\n# define PEM_STRING_X509         \"CERTIFICATE\"\n# define PEM_STRING_X509_PAIR    \"CERTIFICATE PAIR\"\n# define PEM_STRING_X509_TRUSTED \"TRUSTED CERTIFICATE\"\n# define PEM_STRING_X509_REQ_OLD \"NEW CERTIFICATE REQUEST\"\n# define PEM_STRING_X509_REQ     \"CERTIFICATE REQUEST\"\n# define PEM_STRING_X509_CRL     \"X509 CRL\"\n# define PEM_STRING_EVP_PKEY     \"ANY PRIVATE KEY\"\n# define PEM_STRING_PUBLIC       \"PUBLIC KEY\"\n# define PEM_STRING_RSA          \"RSA PRIVATE KEY\"\n# define PEM_STRING_RSA_PUBLIC   \"RSA PUBLIC KEY\"\n# define PEM_STRING_DSA          \"DSA PRIVATE KEY\"\n# define PEM_STRING_DSA_PUBLIC   \"DSA PUBLIC KEY\"\n# define PEM_STRING_PKCS7        \"PKCS7\"\n# define PEM_STRING_PKCS7_SIGNED \"PKCS #7 SIGNED DATA\"\n# define PEM_STRING_PKCS8        \"ENCRYPTED PRIVATE KEY\"\n# define PEM_STRING_PKCS8INF     \"PRIVATE KEY\"\n# define PEM_STRING_DHPARAMS     \"DH PARAMETERS\"\n# define PEM_STRING_DHXPARAMS    \"X9.42 DH PARAMETERS\"\n# define PEM_STRING_SSL_SESSION  \"SSL SESSION PARAMETERS\"\n# define PEM_STRING_DSAPARAMS    \"DSA PARAMETERS\"\n# define PEM_STRING_ECDSA_PUBLIC \"ECDSA PUBLIC KEY\"\n# define PEM_STRING_ECPARAMETERS \"EC PARAMETERS\"\n# define PEM_STRING_ECPRIVATEKEY \"EC PRIVATE KEY\"\n# define PEM_STRING_PARAMETERS   \"PARAMETERS\"\n# define PEM_STRING_CMS          \"CMS\"\n\n  /*\n   * Note that this structure is initialised by PEM_SealInit and cleaned up\n   * by PEM_SealFinal (at least for now)\n   */\ntypedef struct PEM_Encode_Seal_st {\n    EVP_ENCODE_CTX encode;\n    EVP_MD_CTX md;\n    EVP_CIPHER_CTX cipher;\n} PEM_ENCODE_SEAL_CTX;\n\n/* enc_type is one off */\n# define PEM_TYPE_ENCRYPTED      10\n# define PEM_TYPE_MIC_ONLY       20\n# define PEM_TYPE_MIC_CLEAR      30\n# define PEM_TYPE_CLEAR          40\n\ntypedef struct pem_recip_st {\n    char *name;\n    X509_NAME *dn;\n    int cipher;\n    int key_enc;\n    /*      char iv[8]; unused and wrong size */\n} PEM_USER;\n\ntypedef struct pem_ctx_st {\n    int type;                   /* what type of object */\n    struct {\n        int version;\n        int mode;\n    } proc_type;\n\n    char *domain;\n\n    struct {\n        int cipher;\n        /*-\n        unused, and wrong size\n        unsigned char iv[8]; */\n    } DEK_info;\n\n    PEM_USER *originator;\n\n    int num_recipient;\n    PEM_USER **recipient;\n/*-\n    XXX(ben): don#t think this is used!\n        STACK *x509_chain;      / * certificate chain */\n    EVP_MD *md;                 /* signature type */\n\n    int md_enc;                 /* is the md encrypted or not? */\n    int md_len;                 /* length of md_data */\n    char *md_data;              /* message digest, could be pkey encrypted */\n\n    EVP_CIPHER *dec;            /* date encryption cipher */\n    int key_len;                /* key length */\n    unsigned char *key;         /* key */\n  /*-\n    unused, and wrong size\n    unsigned char iv[8]; */\n\n    int data_enc;               /* is the data encrypted */\n    int data_len;\n    unsigned char *data;\n} PEM_CTX;\n\n/*\n * These macros make the PEM_read/PEM_write functions easier to maintain and\n * write. Now they are all implemented with either: IMPLEMENT_PEM_rw(...) or\n * IMPLEMENT_PEM_rw_cb(...)\n */\n\n# ifdef OPENSSL_NO_FP_API\n\n#  define IMPLEMENT_PEM_read_fp(name, type, str, asn1) /**/\n#  define IMPLEMENT_PEM_write_fp(name, type, str, asn1) /**/\n#  define IMPLEMENT_PEM_write_fp_const(name, type, str, asn1) /**/\n#  define IMPLEMENT_PEM_write_cb_fp(name, type, str, asn1) /**/\n#  define IMPLEMENT_PEM_write_cb_fp_const(name, type, str, asn1) /**/\n# else\n\n#  define IMPLEMENT_PEM_read_fp(name, type, str, asn1) \\\ntype *PEM_read_##name(FILE *fp, type **x, pem_password_cb *cb, void *u)\\\n{ \\\nreturn PEM_ASN1_read((d2i_of_void *)d2i_##asn1, str,fp,(void **)x,cb,u); \\\n}\n\n#  define IMPLEMENT_PEM_write_fp(name, type, str, asn1) \\\nint PEM_write_##name(FILE *fp, type *x) \\\n{ \\\nreturn PEM_ASN1_write((i2d_of_void *)i2d_##asn1,str,fp,x,NULL,NULL,0,NULL,NULL); \\\n}\n\n#  define IMPLEMENT_PEM_write_fp_const(name, type, str, asn1) \\\nint PEM_write_##name(FILE *fp, const type *x) \\\n{ \\\nreturn PEM_ASN1_write((i2d_of_void *)i2d_##asn1,str,fp,(void *)x,NULL,NULL,0,NULL,NULL); \\\n}\n\n#  define IMPLEMENT_PEM_write_cb_fp(name, type, str, asn1) \\\nint PEM_write_##name(FILE *fp, type *x, const EVP_CIPHER *enc, \\\n             unsigned char *kstr, int klen, pem_password_cb *cb, \\\n                  void *u) \\\n        { \\\n        return PEM_ASN1_write((i2d_of_void *)i2d_##asn1,str,fp,x,enc,kstr,klen,cb,u); \\\n        }\n\n#  define IMPLEMENT_PEM_write_cb_fp_const(name, type, str, asn1) \\\nint PEM_write_##name(FILE *fp, type *x, const EVP_CIPHER *enc, \\\n             unsigned char *kstr, int klen, pem_password_cb *cb, \\\n                  void *u) \\\n        { \\\n        return PEM_ASN1_write((i2d_of_void *)i2d_##asn1,str,fp,x,enc,kstr,klen,cb,u); \\\n        }\n\n# endif\n\n# define IMPLEMENT_PEM_read_bio(name, type, str, asn1) \\\ntype *PEM_read_bio_##name(BIO *bp, type **x, pem_password_cb *cb, void *u)\\\n{ \\\nreturn PEM_ASN1_read_bio((d2i_of_void *)d2i_##asn1, str,bp,(void **)x,cb,u); \\\n}\n\n# define IMPLEMENT_PEM_write_bio(name, type, str, asn1) \\\nint PEM_write_bio_##name(BIO *bp, type *x) \\\n{ \\\nreturn PEM_ASN1_write_bio((i2d_of_void *)i2d_##asn1,str,bp,x,NULL,NULL,0,NULL,NULL); \\\n}\n\n# define IMPLEMENT_PEM_write_bio_const(name, type, str, asn1) \\\nint PEM_write_bio_##name(BIO *bp, const type *x) \\\n{ \\\nreturn PEM_ASN1_write_bio((i2d_of_void *)i2d_##asn1,str,bp,(void *)x,NULL,NULL,0,NULL,NULL); \\\n}\n\n# define IMPLEMENT_PEM_write_cb_bio(name, type, str, asn1) \\\nint PEM_write_bio_##name(BIO *bp, type *x, const EVP_CIPHER *enc, \\\n             unsigned char *kstr, int klen, pem_password_cb *cb, void *u) \\\n        { \\\n        return PEM_ASN1_write_bio((i2d_of_void *)i2d_##asn1,str,bp,x,enc,kstr,klen,cb,u); \\\n        }\n\n# define IMPLEMENT_PEM_write_cb_bio_const(name, type, str, asn1) \\\nint PEM_write_bio_##name(BIO *bp, type *x, const EVP_CIPHER *enc, \\\n             unsigned char *kstr, int klen, pem_password_cb *cb, void *u) \\\n        { \\\n        return PEM_ASN1_write_bio((i2d_of_void *)i2d_##asn1,str,bp,(void *)x,enc,kstr,klen,cb,u); \\\n        }\n\n# define IMPLEMENT_PEM_write(name, type, str, asn1) \\\n        IMPLEMENT_PEM_write_bio(name, type, str, asn1) \\\n        IMPLEMENT_PEM_write_fp(name, type, str, asn1)\n\n# define IMPLEMENT_PEM_write_const(name, type, str, asn1) \\\n        IMPLEMENT_PEM_write_bio_const(name, type, str, asn1) \\\n        IMPLEMENT_PEM_write_fp_const(name, type, str, asn1)\n\n# define IMPLEMENT_PEM_write_cb(name, type, str, asn1) \\\n        IMPLEMENT_PEM_write_cb_bio(name, type, str, asn1) \\\n        IMPLEMENT_PEM_write_cb_fp(name, type, str, asn1)\n\n# define IMPLEMENT_PEM_write_cb_const(name, type, str, asn1) \\\n        IMPLEMENT_PEM_write_cb_bio_const(name, type, str, asn1) \\\n        IMPLEMENT_PEM_write_cb_fp_const(name, type, str, asn1)\n\n# define IMPLEMENT_PEM_read(name, type, str, asn1) \\\n        IMPLEMENT_PEM_read_bio(name, type, str, asn1) \\\n        IMPLEMENT_PEM_read_fp(name, type, str, asn1)\n\n# define IMPLEMENT_PEM_rw(name, type, str, asn1) \\\n        IMPLEMENT_PEM_read(name, type, str, asn1) \\\n        IMPLEMENT_PEM_write(name, type, str, asn1)\n\n# define IMPLEMENT_PEM_rw_const(name, type, str, asn1) \\\n        IMPLEMENT_PEM_read(name, type, str, asn1) \\\n        IMPLEMENT_PEM_write_const(name, type, str, asn1)\n\n# define IMPLEMENT_PEM_rw_cb(name, type, str, asn1) \\\n        IMPLEMENT_PEM_read(name, type, str, asn1) \\\n        IMPLEMENT_PEM_write_cb(name, type, str, asn1)\n\n/* These are the same except they are for the declarations */\n\n# if defined(OPENSSL_NO_FP_API)\n\n#  define DECLARE_PEM_read_fp(name, type) /**/\n#  define DECLARE_PEM_write_fp(name, type) /**/\n#  define DECLARE_PEM_write_cb_fp(name, type) /**/\n# else\n\n#  define DECLARE_PEM_read_fp(name, type) \\\n        type *PEM_read_##name(FILE *fp, type **x, pem_password_cb *cb, void *u);\n\n#  define DECLARE_PEM_write_fp(name, type) \\\n        int PEM_write_##name(FILE *fp, type *x);\n\n#  define DECLARE_PEM_write_fp_const(name, type) \\\n        int PEM_write_##name(FILE *fp, const type *x);\n\n#  define DECLARE_PEM_write_cb_fp(name, type) \\\n        int PEM_write_##name(FILE *fp, type *x, const EVP_CIPHER *enc, \\\n             unsigned char *kstr, int klen, pem_password_cb *cb, void *u);\n\n# endif\n\n# ifndef OPENSSL_NO_BIO\n#  define DECLARE_PEM_read_bio(name, type) \\\n        type *PEM_read_bio_##name(BIO *bp, type **x, pem_password_cb *cb, void *u);\n\n#  define DECLARE_PEM_write_bio(name, type) \\\n        int PEM_write_bio_##name(BIO *bp, type *x);\n\n#  define DECLARE_PEM_write_bio_const(name, type) \\\n        int PEM_write_bio_##name(BIO *bp, const type *x);\n\n#  define DECLARE_PEM_write_cb_bio(name, type) \\\n        int PEM_write_bio_##name(BIO *bp, type *x, const EVP_CIPHER *enc, \\\n             unsigned char *kstr, int klen, pem_password_cb *cb, void *u);\n\n# else\n\n#  define DECLARE_PEM_read_bio(name, type) /**/\n#  define DECLARE_PEM_write_bio(name, type) /**/\n#  define DECLARE_PEM_write_bio_const(name, type) /**/\n#  define DECLARE_PEM_write_cb_bio(name, type) /**/\n# endif\n# define DECLARE_PEM_write(name, type) \\\n        DECLARE_PEM_write_bio(name, type) \\\n        DECLARE_PEM_write_fp(name, type)\n# define DECLARE_PEM_write_const(name, type) \\\n        DECLARE_PEM_write_bio_const(name, type) \\\n        DECLARE_PEM_write_fp_const(name, type)\n# define DECLARE_PEM_write_cb(name, type) \\\n        DECLARE_PEM_write_cb_bio(name, type) \\\n        DECLARE_PEM_write_cb_fp(name, type)\n# define DECLARE_PEM_read(name, type) \\\n        DECLARE_PEM_read_bio(name, type) \\\n        DECLARE_PEM_read_fp(name, type)\n# define DECLARE_PEM_rw(name, type) \\\n        DECLARE_PEM_read(name, type) \\\n        DECLARE_PEM_write(name, type)\n# define DECLARE_PEM_rw_const(name, type) \\\n        DECLARE_PEM_read(name, type) \\\n        DECLARE_PEM_write_const(name, type)\n# define DECLARE_PEM_rw_cb(name, type) \\\n        DECLARE_PEM_read(name, type) \\\n        DECLARE_PEM_write_cb(name, type)\n# if 1\n/* \"userdata\": new with OpenSSL 0.9.4 */\ntypedef int pem_password_cb (char *buf, int size, int rwflag, void *userdata);\n# else\n/* OpenSSL 0.9.3, 0.9.3a */\ntypedef int pem_password_cb (char *buf, int size, int rwflag);\n# endif\n\nint PEM_get_EVP_CIPHER_INFO(char *header, EVP_CIPHER_INFO *cipher);\nint PEM_do_header(EVP_CIPHER_INFO *cipher, unsigned char *data, long *len,\n                  pem_password_cb *callback, void *u);\n\n# ifndef OPENSSL_NO_BIO\nint PEM_read_bio(BIO *bp, char **name, char **header,\n                 unsigned char **data, long *len);\nint PEM_write_bio(BIO *bp, const char *name, const char *hdr,\n                  const unsigned char *data, long len);\nint PEM_bytes_read_bio(unsigned char **pdata, long *plen, char **pnm,\n                       const char *name, BIO *bp, pem_password_cb *cb,\n                       void *u);\nvoid *PEM_ASN1_read_bio(d2i_of_void *d2i, const char *name, BIO *bp, void **x,\n                        pem_password_cb *cb, void *u);\nint PEM_ASN1_write_bio(i2d_of_void *i2d, const char *name, BIO *bp, void *x,\n                       const EVP_CIPHER *enc, unsigned char *kstr, int klen,\n                       pem_password_cb *cb, void *u);\n\nSTACK_OF(X509_INFO) *PEM_X509_INFO_read_bio(BIO *bp, STACK_OF(X509_INFO) *sk,\n                                            pem_password_cb *cb, void *u);\nint PEM_X509_INFO_write_bio(BIO *bp, X509_INFO *xi, EVP_CIPHER *enc,\n                            unsigned char *kstr, int klen,\n                            pem_password_cb *cd, void *u);\n# endif\n\nint PEM_read(FILE *fp, char **name, char **header,\n             unsigned char **data, long *len);\nint PEM_write(FILE *fp, const char *name, const char *hdr,\n              const unsigned char *data, long len);\nvoid *PEM_ASN1_read(d2i_of_void *d2i, const char *name, FILE *fp, void **x,\n                    pem_password_cb *cb, void *u);\nint PEM_ASN1_write(i2d_of_void *i2d, const char *name, FILE *fp,\n                   void *x, const EVP_CIPHER *enc, unsigned char *kstr,\n                   int klen, pem_password_cb *callback, void *u);\nSTACK_OF(X509_INFO) *PEM_X509_INFO_read(FILE *fp, STACK_OF(X509_INFO) *sk,\n                                        pem_password_cb *cb, void *u);\n\nint PEM_SealInit(PEM_ENCODE_SEAL_CTX *ctx, EVP_CIPHER *type,\n                 EVP_MD *md_type, unsigned char **ek, int *ekl,\n                 unsigned char *iv, EVP_PKEY **pubk, int npubk);\nvoid PEM_SealUpdate(PEM_ENCODE_SEAL_CTX *ctx, unsigned char *out, int *outl,\n                    unsigned char *in, int inl);\nint PEM_SealFinal(PEM_ENCODE_SEAL_CTX *ctx, unsigned char *sig, int *sigl,\n                  unsigned char *out, int *outl, EVP_PKEY *priv);\n\nvoid PEM_SignInit(EVP_MD_CTX *ctx, EVP_MD *type);\nvoid PEM_SignUpdate(EVP_MD_CTX *ctx, unsigned char *d, unsigned int cnt);\nint PEM_SignFinal(EVP_MD_CTX *ctx, unsigned char *sigret,\n                  unsigned int *siglen, EVP_PKEY *pkey);\n\nint PEM_def_callback(char *buf, int num, int w, void *key);\nvoid PEM_proc_type(char *buf, int type);\nvoid PEM_dek_info(char *buf, const char *type, int len, char *str);\n\n# include <openssl/symhacks.h>\n\nDECLARE_PEM_rw(X509, X509)\nDECLARE_PEM_rw(X509_AUX, X509)\nDECLARE_PEM_rw(X509_CERT_PAIR, X509_CERT_PAIR)\nDECLARE_PEM_rw(X509_REQ, X509_REQ)\nDECLARE_PEM_write(X509_REQ_NEW, X509_REQ)\nDECLARE_PEM_rw(X509_CRL, X509_CRL)\nDECLARE_PEM_rw(PKCS7, PKCS7)\nDECLARE_PEM_rw(NETSCAPE_CERT_SEQUENCE, NETSCAPE_CERT_SEQUENCE)\nDECLARE_PEM_rw(PKCS8, X509_SIG)\nDECLARE_PEM_rw(PKCS8_PRIV_KEY_INFO, PKCS8_PRIV_KEY_INFO)\n# ifndef OPENSSL_NO_RSA\nDECLARE_PEM_rw_cb(RSAPrivateKey, RSA)\nDECLARE_PEM_rw_const(RSAPublicKey, RSA)\nDECLARE_PEM_rw(RSA_PUBKEY, RSA)\n# endif\n# ifndef OPENSSL_NO_DSA\nDECLARE_PEM_rw_cb(DSAPrivateKey, DSA)\nDECLARE_PEM_rw(DSA_PUBKEY, DSA)\nDECLARE_PEM_rw_const(DSAparams, DSA)\n# endif\n# ifndef OPENSSL_NO_EC\nDECLARE_PEM_rw_const(ECPKParameters, EC_GROUP)\nDECLARE_PEM_rw_cb(ECPrivateKey, EC_KEY)\nDECLARE_PEM_rw(EC_PUBKEY, EC_KEY)\n# endif\n# ifndef OPENSSL_NO_DH\nDECLARE_PEM_rw_const(DHparams, DH)\nDECLARE_PEM_write_const(DHxparams, DH)\n# endif\nDECLARE_PEM_rw_cb(PrivateKey, EVP_PKEY)\nDECLARE_PEM_rw(PUBKEY, EVP_PKEY)\n\nint PEM_write_bio_PKCS8PrivateKey_nid(BIO *bp, EVP_PKEY *x, int nid,\n                                      char *kstr, int klen,\n                                      pem_password_cb *cb, void *u);\nint PEM_write_bio_PKCS8PrivateKey(BIO *, EVP_PKEY *, const EVP_CIPHER *,\n                                  char *, int, pem_password_cb *, void *);\nint i2d_PKCS8PrivateKey_bio(BIO *bp, EVP_PKEY *x, const EVP_CIPHER *enc,\n                            char *kstr, int klen,\n                            pem_password_cb *cb, void *u);\nint i2d_PKCS8PrivateKey_nid_bio(BIO *bp, EVP_PKEY *x, int nid,\n                                char *kstr, int klen,\n                                pem_password_cb *cb, void *u);\nEVP_PKEY *d2i_PKCS8PrivateKey_bio(BIO *bp, EVP_PKEY **x, pem_password_cb *cb,\n                                  void *u);\n\nint i2d_PKCS8PrivateKey_fp(FILE *fp, EVP_PKEY *x, const EVP_CIPHER *enc,\n                           char *kstr, int klen,\n                           pem_password_cb *cb, void *u);\nint i2d_PKCS8PrivateKey_nid_fp(FILE *fp, EVP_PKEY *x, int nid,\n                               char *kstr, int klen,\n                               pem_password_cb *cb, void *u);\nint PEM_write_PKCS8PrivateKey_nid(FILE *fp, EVP_PKEY *x, int nid,\n                                  char *kstr, int klen,\n                                  pem_password_cb *cb, void *u);\n\nEVP_PKEY *d2i_PKCS8PrivateKey_fp(FILE *fp, EVP_PKEY **x, pem_password_cb *cb,\n                                 void *u);\n\nint PEM_write_PKCS8PrivateKey(FILE *fp, EVP_PKEY *x, const EVP_CIPHER *enc,\n                              char *kstr, int klen, pem_password_cb *cd,\n                              void *u);\n\nEVP_PKEY *PEM_read_bio_Parameters(BIO *bp, EVP_PKEY **x);\nint PEM_write_bio_Parameters(BIO *bp, EVP_PKEY *x);\n\nEVP_PKEY *b2i_PrivateKey(const unsigned char **in, long length);\nEVP_PKEY *b2i_PublicKey(const unsigned char **in, long length);\nEVP_PKEY *b2i_PrivateKey_bio(BIO *in);\nEVP_PKEY *b2i_PublicKey_bio(BIO *in);\nint i2b_PrivateKey_bio(BIO *out, EVP_PKEY *pk);\nint i2b_PublicKey_bio(BIO *out, EVP_PKEY *pk);\n# ifndef OPENSSL_NO_RC4\nEVP_PKEY *b2i_PVK_bio(BIO *in, pem_password_cb *cb, void *u);\nint i2b_PVK_bio(BIO *out, EVP_PKEY *pk, int enclevel,\n                pem_password_cb *cb, void *u);\n# endif\n\n/* BEGIN ERROR CODES */\n/*\n * The following lines are auto generated by the script mkerr.pl. Any changes\n * made after this point may be overwritten when the script is next run.\n */\n\nvoid ERR_load_PEM_strings(void);\n\n/* Error codes for the PEM functions. */\n\n/* Function codes. */\n# define PEM_F_B2I_DSS                                    127\n# define PEM_F_B2I_PVK_BIO                                128\n# define PEM_F_B2I_RSA                                    129\n# define PEM_F_CHECK_BITLEN_DSA                           130\n# define PEM_F_CHECK_BITLEN_RSA                           131\n# define PEM_F_D2I_PKCS8PRIVATEKEY_BIO                    120\n# define PEM_F_D2I_PKCS8PRIVATEKEY_FP                     121\n# define PEM_F_DO_B2I                                     132\n# define PEM_F_DO_B2I_BIO                                 133\n# define PEM_F_DO_BLOB_HEADER                             134\n# define PEM_F_DO_PK8PKEY                                 126\n# define PEM_F_DO_PK8PKEY_FP                              125\n# define PEM_F_DO_PVK_BODY                                135\n# define PEM_F_DO_PVK_HEADER                              136\n# define PEM_F_I2B_PVK                                    137\n# define PEM_F_I2B_PVK_BIO                                138\n# define PEM_F_LOAD_IV                                    101\n# define PEM_F_PEM_ASN1_READ                              102\n# define PEM_F_PEM_ASN1_READ_BIO                          103\n# define PEM_F_PEM_ASN1_WRITE                             104\n# define PEM_F_PEM_ASN1_WRITE_BIO                         105\n# define PEM_F_PEM_DEF_CALLBACK                           100\n# define PEM_F_PEM_DO_HEADER                              106\n# define PEM_F_PEM_F_PEM_WRITE_PKCS8PRIVATEKEY            118\n# define PEM_F_PEM_GET_EVP_CIPHER_INFO                    107\n# define PEM_F_PEM_PK8PKEY                                119\n# define PEM_F_PEM_READ                                   108\n# define PEM_F_PEM_READ_BIO                               109\n# define PEM_F_PEM_READ_BIO_DHPARAMS                      141\n# define PEM_F_PEM_READ_BIO_PARAMETERS                    140\n# define PEM_F_PEM_READ_BIO_PRIVATEKEY                    123\n# define PEM_F_PEM_READ_DHPARAMS                          142\n# define PEM_F_PEM_READ_PRIVATEKEY                        124\n# define PEM_F_PEM_SEALFINAL                              110\n# define PEM_F_PEM_SEALINIT                               111\n# define PEM_F_PEM_SIGNFINAL                              112\n# define PEM_F_PEM_WRITE                                  113\n# define PEM_F_PEM_WRITE_BIO                              114\n# define PEM_F_PEM_WRITE_PRIVATEKEY                       139\n# define PEM_F_PEM_X509_INFO_READ                         115\n# define PEM_F_PEM_X509_INFO_READ_BIO                     116\n# define PEM_F_PEM_X509_INFO_WRITE_BIO                    117\n\n/* Reason codes. */\n# define PEM_R_BAD_BASE64_DECODE                          100\n# define PEM_R_BAD_DECRYPT                                101\n# define PEM_R_BAD_END_LINE                               102\n# define PEM_R_BAD_IV_CHARS                               103\n# define PEM_R_BAD_MAGIC_NUMBER                           116\n# define PEM_R_BAD_PASSWORD_READ                          104\n# define PEM_R_BAD_VERSION_NUMBER                         117\n# define PEM_R_BIO_WRITE_FAILURE                          118\n# define PEM_R_CIPHER_IS_NULL                             127\n# define PEM_R_ERROR_CONVERTING_PRIVATE_KEY               115\n# define PEM_R_EXPECTING_PRIVATE_KEY_BLOB                 119\n# define PEM_R_EXPECTING_PUBLIC_KEY_BLOB                  120\n# define PEM_R_HEADER_TOO_LONG                            128\n# define PEM_R_INCONSISTENT_HEADER                        121\n# define PEM_R_KEYBLOB_HEADER_PARSE_ERROR                 122\n# define PEM_R_KEYBLOB_TOO_SHORT                          123\n# define PEM_R_NOT_DEK_INFO                               105\n# define PEM_R_NOT_ENCRYPTED                              106\n# define PEM_R_NOT_PROC_TYPE                              107\n# define PEM_R_NO_START_LINE                              108\n# define PEM_R_PROBLEMS_GETTING_PASSWORD                  109\n# define PEM_R_PUBLIC_KEY_NO_RSA                          110\n# define PEM_R_PVK_DATA_TOO_SHORT                         124\n# define PEM_R_PVK_TOO_SHORT                              125\n# define PEM_R_READ_KEY                                   111\n# define PEM_R_SHORT_HEADER                               112\n# define PEM_R_UNSUPPORTED_CIPHER                         113\n# define PEM_R_UNSUPPORTED_ENCRYPTION                     114\n# define PEM_R_UNSUPPORTED_KEY_COMPONENTS                 126\n\n# ifdef  __cplusplus\n}\n# endif\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/arm64/include/openssl/pem2.h",
    "content": "/* ====================================================================\n * Copyright (c) 1999 The OpenSSL Project.  All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n *\n * 1. Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n *\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in\n *    the documentation and/or other materials provided with the\n *    distribution.\n *\n * 3. All advertising materials mentioning features or use of this\n *    software must display the following acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)\"\n *\n * 4. The names \"OpenSSL Toolkit\" and \"OpenSSL Project\" must not be used to\n *    endorse or promote products derived from this software without\n *    prior written permission. For written permission, please contact\n *    licensing@OpenSSL.org.\n *\n * 5. Products derived from this software may not be called \"OpenSSL\"\n *    nor may \"OpenSSL\" appear in their names without prior written\n *    permission of the OpenSSL Project.\n *\n * 6. Redistributions of any form whatsoever must retain the following\n *    acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)\"\n *\n * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY\n * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\n * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR\n * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\n * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,\n * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED\n * OF THE POSSIBILITY OF SUCH DAMAGE.\n * ====================================================================\n *\n * This product includes cryptographic software written by Eric Young\n * (eay@cryptsoft.com).  This product includes software written by Tim\n * Hudson (tjh@cryptsoft.com).\n *\n */\n\n/*\n * This header only exists to break a circular dependency between pem and err\n * Ben 30 Jan 1999.\n */\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n#ifndef HEADER_PEM_H\nvoid ERR_load_PEM_strings(void);\n#endif\n\n#ifdef __cplusplus\n}\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/arm64/include/openssl/pkcs12.h",
    "content": "/* pkcs12.h */\n/*\n * Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL project\n * 1999.\n */\n/* ====================================================================\n * Copyright (c) 1999 The OpenSSL Project.  All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n *\n * 1. Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n *\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in\n *    the documentation and/or other materials provided with the\n *    distribution.\n *\n * 3. All advertising materials mentioning features or use of this\n *    software must display the following acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)\"\n *\n * 4. The names \"OpenSSL Toolkit\" and \"OpenSSL Project\" must not be used to\n *    endorse or promote products derived from this software without\n *    prior written permission. For written permission, please contact\n *    licensing@OpenSSL.org.\n *\n * 5. Products derived from this software may not be called \"OpenSSL\"\n *    nor may \"OpenSSL\" appear in their names without prior written\n *    permission of the OpenSSL Project.\n *\n * 6. Redistributions of any form whatsoever must retain the following\n *    acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)\"\n *\n * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY\n * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\n * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR\n * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\n * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,\n * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED\n * OF THE POSSIBILITY OF SUCH DAMAGE.\n * ====================================================================\n *\n * This product includes cryptographic software written by Eric Young\n * (eay@cryptsoft.com).  This product includes software written by Tim\n * Hudson (tjh@cryptsoft.com).\n *\n */\n\n#ifndef HEADER_PKCS12_H\n# define HEADER_PKCS12_H\n\n# include <openssl/bio.h>\n# include <openssl/x509.h>\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n# define PKCS12_KEY_ID   1\n# define PKCS12_IV_ID    2\n# define PKCS12_MAC_ID   3\n\n/* Default iteration count */\n# ifndef PKCS12_DEFAULT_ITER\n#  define PKCS12_DEFAULT_ITER     PKCS5_DEFAULT_ITER\n# endif\n\n# define PKCS12_MAC_KEY_LENGTH 20\n\n# define PKCS12_SALT_LEN 8\n\n/* Uncomment out next line for unicode password and names, otherwise ASCII */\n\n/*\n * #define PBE_UNICODE\n */\n\n# ifdef PBE_UNICODE\n#  define PKCS12_key_gen PKCS12_key_gen_uni\n#  define PKCS12_add_friendlyname PKCS12_add_friendlyname_uni\n# else\n#  define PKCS12_key_gen PKCS12_key_gen_asc\n#  define PKCS12_add_friendlyname PKCS12_add_friendlyname_asc\n# endif\n\n/* MS key usage constants */\n\n# define KEY_EX  0x10\n# define KEY_SIG 0x80\n\ntypedef struct {\n    X509_SIG *dinfo;\n    ASN1_OCTET_STRING *salt;\n    ASN1_INTEGER *iter;         /* defaults to 1 */\n} PKCS12_MAC_DATA;\n\ntypedef struct {\n    ASN1_INTEGER *version;\n    PKCS12_MAC_DATA *mac;\n    PKCS7 *authsafes;\n} PKCS12;\n\ntypedef struct {\n    ASN1_OBJECT *type;\n    union {\n        struct pkcs12_bag_st *bag; /* secret, crl and certbag */\n        struct pkcs8_priv_key_info_st *keybag; /* keybag */\n        X509_SIG *shkeybag;     /* shrouded key bag */\n        STACK_OF(PKCS12_SAFEBAG) *safes;\n        ASN1_TYPE *other;\n    } value;\n    STACK_OF(X509_ATTRIBUTE) *attrib;\n} PKCS12_SAFEBAG;\n\nDECLARE_STACK_OF(PKCS12_SAFEBAG)\nDECLARE_ASN1_SET_OF(PKCS12_SAFEBAG)\nDECLARE_PKCS12_STACK_OF(PKCS12_SAFEBAG)\n\ntypedef struct pkcs12_bag_st {\n    ASN1_OBJECT *type;\n    union {\n        ASN1_OCTET_STRING *x509cert;\n        ASN1_OCTET_STRING *x509crl;\n        ASN1_OCTET_STRING *octet;\n        ASN1_IA5STRING *sdsicert;\n        ASN1_TYPE *other;       /* Secret or other bag */\n    } value;\n} PKCS12_BAGS;\n\n# define PKCS12_ERROR    0\n# define PKCS12_OK       1\n\n/* Compatibility macros */\n\n# define M_PKCS12_x5092certbag PKCS12_x5092certbag\n# define M_PKCS12_x509crl2certbag PKCS12_x509crl2certbag\n\n# define M_PKCS12_certbag2x509 PKCS12_certbag2x509\n# define M_PKCS12_certbag2x509crl PKCS12_certbag2x509crl\n\n# define M_PKCS12_unpack_p7data PKCS12_unpack_p7data\n# define M_PKCS12_pack_authsafes PKCS12_pack_authsafes\n# define M_PKCS12_unpack_authsafes PKCS12_unpack_authsafes\n# define M_PKCS12_unpack_p7encdata PKCS12_unpack_p7encdata\n\n# define M_PKCS12_decrypt_skey PKCS12_decrypt_skey\n# define M_PKCS8_decrypt PKCS8_decrypt\n\n# define M_PKCS12_bag_type(bg) OBJ_obj2nid((bg)->type)\n# define M_PKCS12_cert_bag_type(bg) OBJ_obj2nid((bg)->value.bag->type)\n# define M_PKCS12_crl_bag_type M_PKCS12_cert_bag_type\n\n# define PKCS12_get_attr(bag, attr_nid) \\\n                         PKCS12_get_attr_gen(bag->attrib, attr_nid)\n\n# define PKCS8_get_attr(p8, attr_nid) \\\n                PKCS12_get_attr_gen(p8->attributes, attr_nid)\n\n# define PKCS12_mac_present(p12) ((p12)->mac ? 1 : 0)\n\nPKCS12_SAFEBAG *PKCS12_x5092certbag(X509 *x509);\nPKCS12_SAFEBAG *PKCS12_x509crl2certbag(X509_CRL *crl);\nX509 *PKCS12_certbag2x509(PKCS12_SAFEBAG *bag);\nX509_CRL *PKCS12_certbag2x509crl(PKCS12_SAFEBAG *bag);\n\nPKCS12_SAFEBAG *PKCS12_item_pack_safebag(void *obj, const ASN1_ITEM *it,\n                                         int nid1, int nid2);\nPKCS12_SAFEBAG *PKCS12_MAKE_KEYBAG(PKCS8_PRIV_KEY_INFO *p8);\nPKCS8_PRIV_KEY_INFO *PKCS8_decrypt(X509_SIG *p8, const char *pass,\n                                   int passlen);\nPKCS8_PRIV_KEY_INFO *PKCS12_decrypt_skey(PKCS12_SAFEBAG *bag,\n                                         const char *pass, int passlen);\nX509_SIG *PKCS8_encrypt(int pbe_nid, const EVP_CIPHER *cipher,\n                        const char *pass, int passlen, unsigned char *salt,\n                        int saltlen, int iter, PKCS8_PRIV_KEY_INFO *p8);\nPKCS12_SAFEBAG *PKCS12_MAKE_SHKEYBAG(int pbe_nid, const char *pass,\n                                     int passlen, unsigned char *salt,\n                                     int saltlen, int iter,\n                                     PKCS8_PRIV_KEY_INFO *p8);\nPKCS7 *PKCS12_pack_p7data(STACK_OF(PKCS12_SAFEBAG) *sk);\nSTACK_OF(PKCS12_SAFEBAG) *PKCS12_unpack_p7data(PKCS7 *p7);\nPKCS7 *PKCS12_pack_p7encdata(int pbe_nid, const char *pass, int passlen,\n                             unsigned char *salt, int saltlen, int iter,\n                             STACK_OF(PKCS12_SAFEBAG) *bags);\nSTACK_OF(PKCS12_SAFEBAG) *PKCS12_unpack_p7encdata(PKCS7 *p7, const char *pass,\n                                                  int passlen);\n\nint PKCS12_pack_authsafes(PKCS12 *p12, STACK_OF(PKCS7) *safes);\nSTACK_OF(PKCS7) *PKCS12_unpack_authsafes(PKCS12 *p12);\n\nint PKCS12_add_localkeyid(PKCS12_SAFEBAG *bag, unsigned char *name,\n                          int namelen);\nint PKCS12_add_friendlyname_asc(PKCS12_SAFEBAG *bag, const char *name,\n                                int namelen);\nint PKCS12_add_CSPName_asc(PKCS12_SAFEBAG *bag, const char *name,\n                           int namelen);\nint PKCS12_add_friendlyname_uni(PKCS12_SAFEBAG *bag,\n                                const unsigned char *name, int namelen);\nint PKCS8_add_keyusage(PKCS8_PRIV_KEY_INFO *p8, int usage);\nASN1_TYPE *PKCS12_get_attr_gen(STACK_OF(X509_ATTRIBUTE) *attrs, int attr_nid);\nchar *PKCS12_get_friendlyname(PKCS12_SAFEBAG *bag);\nunsigned char *PKCS12_pbe_crypt(X509_ALGOR *algor, const char *pass,\n                                int passlen, unsigned char *in, int inlen,\n                                unsigned char **data, int *datalen,\n                                int en_de);\nvoid *PKCS12_item_decrypt_d2i(X509_ALGOR *algor, const ASN1_ITEM *it,\n                              const char *pass, int passlen,\n                              ASN1_OCTET_STRING *oct, int zbuf);\nASN1_OCTET_STRING *PKCS12_item_i2d_encrypt(X509_ALGOR *algor,\n                                           const ASN1_ITEM *it,\n                                           const char *pass, int passlen,\n                                           void *obj, int zbuf);\nPKCS12 *PKCS12_init(int mode);\nint PKCS12_key_gen_asc(const char *pass, int passlen, unsigned char *salt,\n                       int saltlen, int id, int iter, int n,\n                       unsigned char *out, const EVP_MD *md_type);\nint PKCS12_key_gen_uni(unsigned char *pass, int passlen, unsigned char *salt,\n                       int saltlen, int id, int iter, int n,\n                       unsigned char *out, const EVP_MD *md_type);\nint PKCS12_PBE_keyivgen(EVP_CIPHER_CTX *ctx, const char *pass, int passlen,\n                        ASN1_TYPE *param, const EVP_CIPHER *cipher,\n                        const EVP_MD *md_type, int en_de);\nint PKCS12_gen_mac(PKCS12 *p12, const char *pass, int passlen,\n                   unsigned char *mac, unsigned int *maclen);\nint PKCS12_verify_mac(PKCS12 *p12, const char *pass, int passlen);\nint PKCS12_set_mac(PKCS12 *p12, const char *pass, int passlen,\n                   unsigned char *salt, int saltlen, int iter,\n                   const EVP_MD *md_type);\nint PKCS12_setup_mac(PKCS12 *p12, int iter, unsigned char *salt,\n                     int saltlen, const EVP_MD *md_type);\nunsigned char *OPENSSL_asc2uni(const char *asc, int asclen,\n                               unsigned char **uni, int *unilen);\nchar *OPENSSL_uni2asc(unsigned char *uni, int unilen);\n\nDECLARE_ASN1_FUNCTIONS(PKCS12)\nDECLARE_ASN1_FUNCTIONS(PKCS12_MAC_DATA)\nDECLARE_ASN1_FUNCTIONS(PKCS12_SAFEBAG)\nDECLARE_ASN1_FUNCTIONS(PKCS12_BAGS)\n\nDECLARE_ASN1_ITEM(PKCS12_SAFEBAGS)\nDECLARE_ASN1_ITEM(PKCS12_AUTHSAFES)\n\nvoid PKCS12_PBE_add(void);\nint PKCS12_parse(PKCS12 *p12, const char *pass, EVP_PKEY **pkey, X509 **cert,\n                 STACK_OF(X509) **ca);\nPKCS12 *PKCS12_create(char *pass, char *name, EVP_PKEY *pkey, X509 *cert,\n                      STACK_OF(X509) *ca, int nid_key, int nid_cert, int iter,\n                      int mac_iter, int keytype);\n\nPKCS12_SAFEBAG *PKCS12_add_cert(STACK_OF(PKCS12_SAFEBAG) **pbags, X509 *cert);\nPKCS12_SAFEBAG *PKCS12_add_key(STACK_OF(PKCS12_SAFEBAG) **pbags,\n                               EVP_PKEY *key, int key_usage, int iter,\n                               int key_nid, char *pass);\nint PKCS12_add_safe(STACK_OF(PKCS7) **psafes, STACK_OF(PKCS12_SAFEBAG) *bags,\n                    int safe_nid, int iter, char *pass);\nPKCS12 *PKCS12_add_safes(STACK_OF(PKCS7) *safes, int p7_nid);\n\nint i2d_PKCS12_bio(BIO *bp, PKCS12 *p12);\nint i2d_PKCS12_fp(FILE *fp, PKCS12 *p12);\nPKCS12 *d2i_PKCS12_bio(BIO *bp, PKCS12 **p12);\nPKCS12 *d2i_PKCS12_fp(FILE *fp, PKCS12 **p12);\nint PKCS12_newpass(PKCS12 *p12, const char *oldpass, const char *newpass);\n\n/* BEGIN ERROR CODES */\n/*\n * The following lines are auto generated by the script mkerr.pl. Any changes\n * made after this point may be overwritten when the script is next run.\n */\nvoid ERR_load_PKCS12_strings(void);\n\n/* Error codes for the PKCS12 functions. */\n\n/* Function codes. */\n# define PKCS12_F_PARSE_BAG                               129\n# define PKCS12_F_PARSE_BAGS                              103\n# define PKCS12_F_PKCS12_ADD_FRIENDLYNAME                 100\n# define PKCS12_F_PKCS12_ADD_FRIENDLYNAME_ASC             127\n# define PKCS12_F_PKCS12_ADD_FRIENDLYNAME_UNI             102\n# define PKCS12_F_PKCS12_ADD_LOCALKEYID                   104\n# define PKCS12_F_PKCS12_CREATE                           105\n# define PKCS12_F_PKCS12_GEN_MAC                          107\n# define PKCS12_F_PKCS12_INIT                             109\n# define PKCS12_F_PKCS12_ITEM_DECRYPT_D2I                 106\n# define PKCS12_F_PKCS12_ITEM_I2D_ENCRYPT                 108\n# define PKCS12_F_PKCS12_ITEM_PACK_SAFEBAG                117\n# define PKCS12_F_PKCS12_KEY_GEN_ASC                      110\n# define PKCS12_F_PKCS12_KEY_GEN_UNI                      111\n# define PKCS12_F_PKCS12_MAKE_KEYBAG                      112\n# define PKCS12_F_PKCS12_MAKE_SHKEYBAG                    113\n# define PKCS12_F_PKCS12_NEWPASS                          128\n# define PKCS12_F_PKCS12_PACK_P7DATA                      114\n# define PKCS12_F_PKCS12_PACK_P7ENCDATA                   115\n# define PKCS12_F_PKCS12_PARSE                            118\n# define PKCS12_F_PKCS12_PBE_CRYPT                        119\n# define PKCS12_F_PKCS12_PBE_KEYIVGEN                     120\n# define PKCS12_F_PKCS12_SETUP_MAC                        122\n# define PKCS12_F_PKCS12_SET_MAC                          123\n# define PKCS12_F_PKCS12_UNPACK_AUTHSAFES                 130\n# define PKCS12_F_PKCS12_UNPACK_P7DATA                    131\n# define PKCS12_F_PKCS12_VERIFY_MAC                       126\n# define PKCS12_F_PKCS8_ADD_KEYUSAGE                      124\n# define PKCS12_F_PKCS8_ENCRYPT                           125\n\n/* Reason codes. */\n# define PKCS12_R_CANT_PACK_STRUCTURE                     100\n# define PKCS12_R_CONTENT_TYPE_NOT_DATA                   121\n# define PKCS12_R_DECODE_ERROR                            101\n# define PKCS12_R_ENCODE_ERROR                            102\n# define PKCS12_R_ENCRYPT_ERROR                           103\n# define PKCS12_R_ERROR_SETTING_ENCRYPTED_DATA_TYPE       120\n# define PKCS12_R_INVALID_NULL_ARGUMENT                   104\n# define PKCS12_R_INVALID_NULL_PKCS12_POINTER             105\n# define PKCS12_R_IV_GEN_ERROR                            106\n# define PKCS12_R_KEY_GEN_ERROR                           107\n# define PKCS12_R_MAC_ABSENT                              108\n# define PKCS12_R_MAC_GENERATION_ERROR                    109\n# define PKCS12_R_MAC_SETUP_ERROR                         110\n# define PKCS12_R_MAC_STRING_SET_ERROR                    111\n# define PKCS12_R_MAC_VERIFY_ERROR                        112\n# define PKCS12_R_MAC_VERIFY_FAILURE                      113\n# define PKCS12_R_PARSE_ERROR                             114\n# define PKCS12_R_PKCS12_ALGOR_CIPHERINIT_ERROR           115\n# define PKCS12_R_PKCS12_CIPHERFINAL_ERROR                116\n# define PKCS12_R_PKCS12_PBE_CRYPT_ERROR                  117\n# define PKCS12_R_UNKNOWN_DIGEST_ALGORITHM                118\n# define PKCS12_R_UNSUPPORTED_PKCS12_MODE                 119\n\n#ifdef  __cplusplus\n}\n#endif\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/arm64/include/openssl/pkcs7.h",
    "content": "/* crypto/pkcs7/pkcs7.h */\n/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)\n * All rights reserved.\n *\n * This package is an SSL implementation written\n * by Eric Young (eay@cryptsoft.com).\n * The implementation was written so as to conform with Netscapes SSL.\n *\n * This library is free for commercial and non-commercial use as long as\n * the following conditions are aheared to.  The following conditions\n * apply to all code found in this distribution, be it the RC4, RSA,\n * lhash, DES, etc., code; not just the SSL code.  The SSL documentation\n * included with this distribution is covered by the same copyright terms\n * except that the holder is Tim Hudson (tjh@cryptsoft.com).\n *\n * Copyright remains Eric Young's, and as such any Copyright notices in\n * the code are not to be removed.\n * If this package is used in a product, Eric Young should be given attribution\n * as the author of the parts of the library used.\n * This can be in the form of a textual message at program startup or\n * in documentation (online or textual) provided with the package.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the copyright\n *    notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in the\n *    documentation and/or other materials provided with the distribution.\n * 3. All advertising materials mentioning features or use of this software\n *    must display the following acknowledgement:\n *    \"This product includes cryptographic software written by\n *     Eric Young (eay@cryptsoft.com)\"\n *    The word 'cryptographic' can be left out if the rouines from the library\n *    being used are not cryptographic related :-).\n * 4. If you include any Windows specific code (or a derivative thereof) from\n *    the apps directory (application code) you must include an acknowledgement:\n *    \"This product includes software written by Tim Hudson (tjh@cryptsoft.com)\"\n *\n * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n * SUCH DAMAGE.\n *\n * The licence and distribution terms for any publically available version or\n * derivative of this code cannot be changed.  i.e. this code cannot simply be\n * copied and put under another distribution licence\n * [including the GNU Public Licence.]\n */\n\n#ifndef HEADER_PKCS7_H\n# define HEADER_PKCS7_H\n\n# include <openssl/asn1.h>\n# include <openssl/bio.h>\n# include <openssl/e_os2.h>\n\n# include <openssl/symhacks.h>\n# include <openssl/ossl_typ.h>\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n# ifdef OPENSSL_SYS_WIN32\n/* Under Win32 thes are defined in wincrypt.h */\n#  undef PKCS7_ISSUER_AND_SERIAL\n#  undef PKCS7_SIGNER_INFO\n# endif\n\n/*-\nEncryption_ID           DES-CBC\nDigest_ID               MD5\nDigest_Encryption_ID    rsaEncryption\nKey_Encryption_ID       rsaEncryption\n*/\n\ntypedef struct pkcs7_issuer_and_serial_st {\n    X509_NAME *issuer;\n    ASN1_INTEGER *serial;\n} PKCS7_ISSUER_AND_SERIAL;\n\ntypedef struct pkcs7_signer_info_st {\n    ASN1_INTEGER *version;      /* version 1 */\n    PKCS7_ISSUER_AND_SERIAL *issuer_and_serial;\n    X509_ALGOR *digest_alg;\n    STACK_OF(X509_ATTRIBUTE) *auth_attr; /* [ 0 ] */\n    X509_ALGOR *digest_enc_alg;\n    ASN1_OCTET_STRING *enc_digest;\n    STACK_OF(X509_ATTRIBUTE) *unauth_attr; /* [ 1 ] */\n    /* The private key to sign with */\n    EVP_PKEY *pkey;\n} PKCS7_SIGNER_INFO;\n\nDECLARE_STACK_OF(PKCS7_SIGNER_INFO)\nDECLARE_ASN1_SET_OF(PKCS7_SIGNER_INFO)\n\ntypedef struct pkcs7_recip_info_st {\n    ASN1_INTEGER *version;      /* version 0 */\n    PKCS7_ISSUER_AND_SERIAL *issuer_and_serial;\n    X509_ALGOR *key_enc_algor;\n    ASN1_OCTET_STRING *enc_key;\n    X509 *cert;                 /* get the pub-key from this */\n} PKCS7_RECIP_INFO;\n\nDECLARE_STACK_OF(PKCS7_RECIP_INFO)\nDECLARE_ASN1_SET_OF(PKCS7_RECIP_INFO)\n\ntypedef struct pkcs7_signed_st {\n    ASN1_INTEGER *version;      /* version 1 */\n    STACK_OF(X509_ALGOR) *md_algs; /* md used */\n    STACK_OF(X509) *cert;       /* [ 0 ] */\n    STACK_OF(X509_CRL) *crl;    /* [ 1 ] */\n    STACK_OF(PKCS7_SIGNER_INFO) *signer_info;\n    struct pkcs7_st *contents;\n} PKCS7_SIGNED;\n/*\n * The above structure is very very similar to PKCS7_SIGN_ENVELOPE. How about\n * merging the two\n */\n\ntypedef struct pkcs7_enc_content_st {\n    ASN1_OBJECT *content_type;\n    X509_ALGOR *algorithm;\n    ASN1_OCTET_STRING *enc_data; /* [ 0 ] */\n    const EVP_CIPHER *cipher;\n} PKCS7_ENC_CONTENT;\n\ntypedef struct pkcs7_enveloped_st {\n    ASN1_INTEGER *version;      /* version 0 */\n    STACK_OF(PKCS7_RECIP_INFO) *recipientinfo;\n    PKCS7_ENC_CONTENT *enc_data;\n} PKCS7_ENVELOPE;\n\ntypedef struct pkcs7_signedandenveloped_st {\n    ASN1_INTEGER *version;      /* version 1 */\n    STACK_OF(X509_ALGOR) *md_algs; /* md used */\n    STACK_OF(X509) *cert;       /* [ 0 ] */\n    STACK_OF(X509_CRL) *crl;    /* [ 1 ] */\n    STACK_OF(PKCS7_SIGNER_INFO) *signer_info;\n    PKCS7_ENC_CONTENT *enc_data;\n    STACK_OF(PKCS7_RECIP_INFO) *recipientinfo;\n} PKCS7_SIGN_ENVELOPE;\n\ntypedef struct pkcs7_digest_st {\n    ASN1_INTEGER *version;      /* version 0 */\n    X509_ALGOR *md;             /* md used */\n    struct pkcs7_st *contents;\n    ASN1_OCTET_STRING *digest;\n} PKCS7_DIGEST;\n\ntypedef struct pkcs7_encrypted_st {\n    ASN1_INTEGER *version;      /* version 0 */\n    PKCS7_ENC_CONTENT *enc_data;\n} PKCS7_ENCRYPT;\n\ntypedef struct pkcs7_st {\n    /*\n     * The following is non NULL if it contains ASN1 encoding of this\n     * structure\n     */\n    unsigned char *asn1;\n    long length;\n# define PKCS7_S_HEADER  0\n# define PKCS7_S_BODY    1\n# define PKCS7_S_TAIL    2\n    int state;                  /* used during processing */\n    int detached;\n    ASN1_OBJECT *type;\n    /* content as defined by the type */\n    /*\n     * all encryption/message digests are applied to the 'contents', leaving\n     * out the 'type' field.\n     */\n    union {\n        char *ptr;\n        /* NID_pkcs7_data */\n        ASN1_OCTET_STRING *data;\n        /* NID_pkcs7_signed */\n        PKCS7_SIGNED *sign;\n        /* NID_pkcs7_enveloped */\n        PKCS7_ENVELOPE *enveloped;\n        /* NID_pkcs7_signedAndEnveloped */\n        PKCS7_SIGN_ENVELOPE *signed_and_enveloped;\n        /* NID_pkcs7_digest */\n        PKCS7_DIGEST *digest;\n        /* NID_pkcs7_encrypted */\n        PKCS7_ENCRYPT *encrypted;\n        /* Anything else */\n        ASN1_TYPE *other;\n    } d;\n} PKCS7;\n\nDECLARE_STACK_OF(PKCS7)\nDECLARE_ASN1_SET_OF(PKCS7)\nDECLARE_PKCS12_STACK_OF(PKCS7)\n\n# define PKCS7_OP_SET_DETACHED_SIGNATURE 1\n# define PKCS7_OP_GET_DETACHED_SIGNATURE 2\n\n# define PKCS7_get_signed_attributes(si) ((si)->auth_attr)\n# define PKCS7_get_attributes(si)        ((si)->unauth_attr)\n\n# define PKCS7_type_is_signed(a) (OBJ_obj2nid((a)->type) == NID_pkcs7_signed)\n# define PKCS7_type_is_encrypted(a) (OBJ_obj2nid((a)->type) == NID_pkcs7_encrypted)\n# define PKCS7_type_is_enveloped(a) (OBJ_obj2nid((a)->type) == NID_pkcs7_enveloped)\n# define PKCS7_type_is_signedAndEnveloped(a) \\\n                (OBJ_obj2nid((a)->type) == NID_pkcs7_signedAndEnveloped)\n# define PKCS7_type_is_data(a)   (OBJ_obj2nid((a)->type) == NID_pkcs7_data)\n# define PKCS7_type_is_digest(a)   (OBJ_obj2nid((a)->type) == NID_pkcs7_digest)\n\n# define PKCS7_set_detached(p,v) \\\n                PKCS7_ctrl(p,PKCS7_OP_SET_DETACHED_SIGNATURE,v,NULL)\n# define PKCS7_get_detached(p) \\\n                PKCS7_ctrl(p,PKCS7_OP_GET_DETACHED_SIGNATURE,0,NULL)\n\n# define PKCS7_is_detached(p7) (PKCS7_type_is_signed(p7) && PKCS7_get_detached(p7))\n\n/* S/MIME related flags */\n\n# define PKCS7_TEXT              0x1\n# define PKCS7_NOCERTS           0x2\n# define PKCS7_NOSIGS            0x4\n# define PKCS7_NOCHAIN           0x8\n# define PKCS7_NOINTERN          0x10\n# define PKCS7_NOVERIFY          0x20\n# define PKCS7_DETACHED          0x40\n# define PKCS7_BINARY            0x80\n# define PKCS7_NOATTR            0x100\n# define PKCS7_NOSMIMECAP        0x200\n# define PKCS7_NOOLDMIMETYPE     0x400\n# define PKCS7_CRLFEOL           0x800\n# define PKCS7_STREAM            0x1000\n# define PKCS7_NOCRL             0x2000\n# define PKCS7_PARTIAL           0x4000\n# define PKCS7_REUSE_DIGEST      0x8000\n\n/* Flags: for compatibility with older code */\n\n# define SMIME_TEXT      PKCS7_TEXT\n# define SMIME_NOCERTS   PKCS7_NOCERTS\n# define SMIME_NOSIGS    PKCS7_NOSIGS\n# define SMIME_NOCHAIN   PKCS7_NOCHAIN\n# define SMIME_NOINTERN  PKCS7_NOINTERN\n# define SMIME_NOVERIFY  PKCS7_NOVERIFY\n# define SMIME_DETACHED  PKCS7_DETACHED\n# define SMIME_BINARY    PKCS7_BINARY\n# define SMIME_NOATTR    PKCS7_NOATTR\n\nDECLARE_ASN1_FUNCTIONS(PKCS7_ISSUER_AND_SERIAL)\n\nint PKCS7_ISSUER_AND_SERIAL_digest(PKCS7_ISSUER_AND_SERIAL *data,\n                                   const EVP_MD *type, unsigned char *md,\n                                   unsigned int *len);\n# ifndef OPENSSL_NO_FP_API\nPKCS7 *d2i_PKCS7_fp(FILE *fp, PKCS7 **p7);\nint i2d_PKCS7_fp(FILE *fp, PKCS7 *p7);\n# endif\nPKCS7 *PKCS7_dup(PKCS7 *p7);\nPKCS7 *d2i_PKCS7_bio(BIO *bp, PKCS7 **p7);\nint i2d_PKCS7_bio(BIO *bp, PKCS7 *p7);\nint i2d_PKCS7_bio_stream(BIO *out, PKCS7 *p7, BIO *in, int flags);\nint PEM_write_bio_PKCS7_stream(BIO *out, PKCS7 *p7, BIO *in, int flags);\n\nDECLARE_ASN1_FUNCTIONS(PKCS7_SIGNER_INFO)\nDECLARE_ASN1_FUNCTIONS(PKCS7_RECIP_INFO)\nDECLARE_ASN1_FUNCTIONS(PKCS7_SIGNED)\nDECLARE_ASN1_FUNCTIONS(PKCS7_ENC_CONTENT)\nDECLARE_ASN1_FUNCTIONS(PKCS7_ENVELOPE)\nDECLARE_ASN1_FUNCTIONS(PKCS7_SIGN_ENVELOPE)\nDECLARE_ASN1_FUNCTIONS(PKCS7_DIGEST)\nDECLARE_ASN1_FUNCTIONS(PKCS7_ENCRYPT)\nDECLARE_ASN1_FUNCTIONS(PKCS7)\n\nDECLARE_ASN1_ITEM(PKCS7_ATTR_SIGN)\nDECLARE_ASN1_ITEM(PKCS7_ATTR_VERIFY)\n\nDECLARE_ASN1_NDEF_FUNCTION(PKCS7)\nDECLARE_ASN1_PRINT_FUNCTION(PKCS7)\n\nlong PKCS7_ctrl(PKCS7 *p7, int cmd, long larg, char *parg);\n\nint PKCS7_set_type(PKCS7 *p7, int type);\nint PKCS7_set0_type_other(PKCS7 *p7, int type, ASN1_TYPE *other);\nint PKCS7_set_content(PKCS7 *p7, PKCS7 *p7_data);\nint PKCS7_SIGNER_INFO_set(PKCS7_SIGNER_INFO *p7i, X509 *x509, EVP_PKEY *pkey,\n                          const EVP_MD *dgst);\nint PKCS7_SIGNER_INFO_sign(PKCS7_SIGNER_INFO *si);\nint PKCS7_add_signer(PKCS7 *p7, PKCS7_SIGNER_INFO *p7i);\nint PKCS7_add_certificate(PKCS7 *p7, X509 *x509);\nint PKCS7_add_crl(PKCS7 *p7, X509_CRL *x509);\nint PKCS7_content_new(PKCS7 *p7, int nid);\nint PKCS7_dataVerify(X509_STORE *cert_store, X509_STORE_CTX *ctx,\n                     BIO *bio, PKCS7 *p7, PKCS7_SIGNER_INFO *si);\nint PKCS7_signatureVerify(BIO *bio, PKCS7 *p7, PKCS7_SIGNER_INFO *si,\n                          X509 *x509);\n\nBIO *PKCS7_dataInit(PKCS7 *p7, BIO *bio);\nint PKCS7_dataFinal(PKCS7 *p7, BIO *bio);\nBIO *PKCS7_dataDecode(PKCS7 *p7, EVP_PKEY *pkey, BIO *in_bio, X509 *pcert);\n\nPKCS7_SIGNER_INFO *PKCS7_add_signature(PKCS7 *p7, X509 *x509,\n                                       EVP_PKEY *pkey, const EVP_MD *dgst);\nX509 *PKCS7_cert_from_signer_info(PKCS7 *p7, PKCS7_SIGNER_INFO *si);\nint PKCS7_set_digest(PKCS7 *p7, const EVP_MD *md);\nSTACK_OF(PKCS7_SIGNER_INFO) *PKCS7_get_signer_info(PKCS7 *p7);\n\nPKCS7_RECIP_INFO *PKCS7_add_recipient(PKCS7 *p7, X509 *x509);\nvoid PKCS7_SIGNER_INFO_get0_algs(PKCS7_SIGNER_INFO *si, EVP_PKEY **pk,\n                                 X509_ALGOR **pdig, X509_ALGOR **psig);\nvoid PKCS7_RECIP_INFO_get0_alg(PKCS7_RECIP_INFO *ri, X509_ALGOR **penc);\nint PKCS7_add_recipient_info(PKCS7 *p7, PKCS7_RECIP_INFO *ri);\nint PKCS7_RECIP_INFO_set(PKCS7_RECIP_INFO *p7i, X509 *x509);\nint PKCS7_set_cipher(PKCS7 *p7, const EVP_CIPHER *cipher);\nint PKCS7_stream(unsigned char ***boundary, PKCS7 *p7);\n\nPKCS7_ISSUER_AND_SERIAL *PKCS7_get_issuer_and_serial(PKCS7 *p7, int idx);\nASN1_OCTET_STRING *PKCS7_digest_from_attributes(STACK_OF(X509_ATTRIBUTE) *sk);\nint PKCS7_add_signed_attribute(PKCS7_SIGNER_INFO *p7si, int nid, int type,\n                               void *data);\nint PKCS7_add_attribute(PKCS7_SIGNER_INFO *p7si, int nid, int atrtype,\n                        void *value);\nASN1_TYPE *PKCS7_get_attribute(PKCS7_SIGNER_INFO *si, int nid);\nASN1_TYPE *PKCS7_get_signed_attribute(PKCS7_SIGNER_INFO *si, int nid);\nint PKCS7_set_signed_attributes(PKCS7_SIGNER_INFO *p7si,\n                                STACK_OF(X509_ATTRIBUTE) *sk);\nint PKCS7_set_attributes(PKCS7_SIGNER_INFO *p7si,\n                         STACK_OF(X509_ATTRIBUTE) *sk);\n\nPKCS7 *PKCS7_sign(X509 *signcert, EVP_PKEY *pkey, STACK_OF(X509) *certs,\n                  BIO *data, int flags);\n\nPKCS7_SIGNER_INFO *PKCS7_sign_add_signer(PKCS7 *p7,\n                                         X509 *signcert, EVP_PKEY *pkey,\n                                         const EVP_MD *md, int flags);\n\nint PKCS7_final(PKCS7 *p7, BIO *data, int flags);\nint PKCS7_verify(PKCS7 *p7, STACK_OF(X509) *certs, X509_STORE *store,\n                 BIO *indata, BIO *out, int flags);\nSTACK_OF(X509) *PKCS7_get0_signers(PKCS7 *p7, STACK_OF(X509) *certs,\n                                   int flags);\nPKCS7 *PKCS7_encrypt(STACK_OF(X509) *certs, BIO *in, const EVP_CIPHER *cipher,\n                     int flags);\nint PKCS7_decrypt(PKCS7 *p7, EVP_PKEY *pkey, X509 *cert, BIO *data,\n                  int flags);\n\nint PKCS7_add_attrib_smimecap(PKCS7_SIGNER_INFO *si,\n                              STACK_OF(X509_ALGOR) *cap);\nSTACK_OF(X509_ALGOR) *PKCS7_get_smimecap(PKCS7_SIGNER_INFO *si);\nint PKCS7_simple_smimecap(STACK_OF(X509_ALGOR) *sk, int nid, int arg);\n\nint PKCS7_add_attrib_content_type(PKCS7_SIGNER_INFO *si, ASN1_OBJECT *coid);\nint PKCS7_add0_attrib_signing_time(PKCS7_SIGNER_INFO *si, ASN1_TIME *t);\nint PKCS7_add1_attrib_digest(PKCS7_SIGNER_INFO *si,\n                             const unsigned char *md, int mdlen);\n\nint SMIME_write_PKCS7(BIO *bio, PKCS7 *p7, BIO *data, int flags);\nPKCS7 *SMIME_read_PKCS7(BIO *bio, BIO **bcont);\n\nBIO *BIO_new_PKCS7(BIO *out, PKCS7 *p7);\n\n/* BEGIN ERROR CODES */\n/*\n * The following lines are auto generated by the script mkerr.pl. Any changes\n * made after this point may be overwritten when the script is next run.\n */\nvoid ERR_load_PKCS7_strings(void);\n\n/* Error codes for the PKCS7 functions. */\n\n/* Function codes. */\n# define PKCS7_F_B64_READ_PKCS7                           120\n# define PKCS7_F_B64_WRITE_PKCS7                          121\n# define PKCS7_F_DO_PKCS7_SIGNED_ATTRIB                   136\n# define PKCS7_F_I2D_PKCS7_BIO_STREAM                     140\n# define PKCS7_F_PKCS7_ADD0_ATTRIB_SIGNING_TIME           135\n# define PKCS7_F_PKCS7_ADD_ATTRIB_SMIMECAP                118\n# define PKCS7_F_PKCS7_ADD_CERTIFICATE                    100\n# define PKCS7_F_PKCS7_ADD_CRL                            101\n# define PKCS7_F_PKCS7_ADD_RECIPIENT_INFO                 102\n# define PKCS7_F_PKCS7_ADD_SIGNATURE                      131\n# define PKCS7_F_PKCS7_ADD_SIGNER                         103\n# define PKCS7_F_PKCS7_BIO_ADD_DIGEST                     125\n# define PKCS7_F_PKCS7_COPY_EXISTING_DIGEST               138\n# define PKCS7_F_PKCS7_CTRL                               104\n# define PKCS7_F_PKCS7_DATADECODE                         112\n# define PKCS7_F_PKCS7_DATAFINAL                          128\n# define PKCS7_F_PKCS7_DATAINIT                           105\n# define PKCS7_F_PKCS7_DATASIGN                           106\n# define PKCS7_F_PKCS7_DATAVERIFY                         107\n# define PKCS7_F_PKCS7_DECRYPT                            114\n# define PKCS7_F_PKCS7_DECRYPT_RINFO                      133\n# define PKCS7_F_PKCS7_ENCODE_RINFO                       132\n# define PKCS7_F_PKCS7_ENCRYPT                            115\n# define PKCS7_F_PKCS7_FINAL                              134\n# define PKCS7_F_PKCS7_FIND_DIGEST                        127\n# define PKCS7_F_PKCS7_GET0_SIGNERS                       124\n# define PKCS7_F_PKCS7_RECIP_INFO_SET                     130\n# define PKCS7_F_PKCS7_SET_CIPHER                         108\n# define PKCS7_F_PKCS7_SET_CONTENT                        109\n# define PKCS7_F_PKCS7_SET_DIGEST                         126\n# define PKCS7_F_PKCS7_SET_TYPE                           110\n# define PKCS7_F_PKCS7_SIGN                               116\n# define PKCS7_F_PKCS7_SIGNATUREVERIFY                    113\n# define PKCS7_F_PKCS7_SIGNER_INFO_SET                    129\n# define PKCS7_F_PKCS7_SIGNER_INFO_SIGN                   139\n# define PKCS7_F_PKCS7_SIGN_ADD_SIGNER                    137\n# define PKCS7_F_PKCS7_SIMPLE_SMIMECAP                    119\n# define PKCS7_F_PKCS7_VERIFY                             117\n# define PKCS7_F_SMIME_READ_PKCS7                         122\n# define PKCS7_F_SMIME_TEXT                               123\n\n/* Reason codes. */\n# define PKCS7_R_CERTIFICATE_VERIFY_ERROR                 117\n# define PKCS7_R_CIPHER_HAS_NO_OBJECT_IDENTIFIER          144\n# define PKCS7_R_CIPHER_NOT_INITIALIZED                   116\n# define PKCS7_R_CONTENT_AND_DATA_PRESENT                 118\n# define PKCS7_R_CTRL_ERROR                               152\n# define PKCS7_R_DECODE_ERROR                             130\n# define PKCS7_R_DECRYPTED_KEY_IS_WRONG_LENGTH            100\n# define PKCS7_R_DECRYPT_ERROR                            119\n# define PKCS7_R_DIGEST_FAILURE                           101\n# define PKCS7_R_ENCRYPTION_CTRL_FAILURE                  149\n# define PKCS7_R_ENCRYPTION_NOT_SUPPORTED_FOR_THIS_KEY_TYPE 150\n# define PKCS7_R_ERROR_ADDING_RECIPIENT                   120\n# define PKCS7_R_ERROR_SETTING_CIPHER                     121\n# define PKCS7_R_INVALID_MIME_TYPE                        131\n# define PKCS7_R_INVALID_NULL_POINTER                     143\n# define PKCS7_R_INVALID_SIGNED_DATA_TYPE                 155\n# define PKCS7_R_MIME_NO_CONTENT_TYPE                     132\n# define PKCS7_R_MIME_PARSE_ERROR                         133\n# define PKCS7_R_MIME_SIG_PARSE_ERROR                     134\n# define PKCS7_R_MISSING_CERIPEND_INFO                    103\n# define PKCS7_R_NO_CONTENT                               122\n# define PKCS7_R_NO_CONTENT_TYPE                          135\n# define PKCS7_R_NO_DEFAULT_DIGEST                        151\n# define PKCS7_R_NO_MATCHING_DIGEST_TYPE_FOUND            154\n# define PKCS7_R_NO_MULTIPART_BODY_FAILURE                136\n# define PKCS7_R_NO_MULTIPART_BOUNDARY                    137\n# define PKCS7_R_NO_RECIPIENT_MATCHES_CERTIFICATE         115\n# define PKCS7_R_NO_RECIPIENT_MATCHES_KEY                 146\n# define PKCS7_R_NO_SIGNATURES_ON_DATA                    123\n# define PKCS7_R_NO_SIGNERS                               142\n# define PKCS7_R_NO_SIG_CONTENT_TYPE                      138\n# define PKCS7_R_OPERATION_NOT_SUPPORTED_ON_THIS_TYPE     104\n# define PKCS7_R_PKCS7_ADD_SIGNATURE_ERROR                124\n# define PKCS7_R_PKCS7_ADD_SIGNER_ERROR                   153\n# define PKCS7_R_PKCS7_DATAFINAL                          126\n# define PKCS7_R_PKCS7_DATAFINAL_ERROR                    125\n# define PKCS7_R_PKCS7_DATASIGN                           145\n# define PKCS7_R_PKCS7_PARSE_ERROR                        139\n# define PKCS7_R_PKCS7_SIG_PARSE_ERROR                    140\n# define PKCS7_R_PRIVATE_KEY_DOES_NOT_MATCH_CERTIFICATE   127\n# define PKCS7_R_SIGNATURE_FAILURE                        105\n# define PKCS7_R_SIGNER_CERTIFICATE_NOT_FOUND             128\n# define PKCS7_R_SIGNING_CTRL_FAILURE                     147\n# define PKCS7_R_SIGNING_NOT_SUPPORTED_FOR_THIS_KEY_TYPE  148\n# define PKCS7_R_SIG_INVALID_MIME_TYPE                    141\n# define PKCS7_R_SMIME_TEXT_ERROR                         129\n# define PKCS7_R_UNABLE_TO_FIND_CERTIFICATE               106\n# define PKCS7_R_UNABLE_TO_FIND_MEM_BIO                   107\n# define PKCS7_R_UNABLE_TO_FIND_MESSAGE_DIGEST            108\n# define PKCS7_R_UNKNOWN_DIGEST_TYPE                      109\n# define PKCS7_R_UNKNOWN_OPERATION                        110\n# define PKCS7_R_UNSUPPORTED_CIPHER_TYPE                  111\n# define PKCS7_R_UNSUPPORTED_CONTENT_TYPE                 112\n# define PKCS7_R_WRONG_CONTENT_TYPE                       113\n# define PKCS7_R_WRONG_PKCS7_TYPE                         114\n\n#ifdef  __cplusplus\n}\n#endif\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/arm64/include/openssl/pqueue.h",
    "content": "/* crypto/pqueue/pqueue.h */\n/*\n * DTLS implementation written by Nagendra Modadugu\n * (nagendra@cs.stanford.edu) for the OpenSSL project 2005.\n */\n/* ====================================================================\n * Copyright (c) 1999-2005 The OpenSSL Project.  All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n *\n * 1. Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n *\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in\n *    the documentation and/or other materials provided with the\n *    distribution.\n *\n * 3. All advertising materials mentioning features or use of this\n *    software must display the following acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)\"\n *\n * 4. The names \"OpenSSL Toolkit\" and \"OpenSSL Project\" must not be used to\n *    endorse or promote products derived from this software without\n *    prior written permission. For written permission, please contact\n *    openssl-core@OpenSSL.org.\n *\n * 5. Products derived from this software may not be called \"OpenSSL\"\n *    nor may \"OpenSSL\" appear in their names without prior written\n *    permission of the OpenSSL Project.\n *\n * 6. Redistributions of any form whatsoever must retain the following\n *    acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)\"\n *\n * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY\n * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\n * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR\n * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\n * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,\n * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED\n * OF THE POSSIBILITY OF SUCH DAMAGE.\n * ====================================================================\n *\n * This product includes cryptographic software written by Eric Young\n * (eay@cryptsoft.com).  This product includes software written by Tim\n * Hudson (tjh@cryptsoft.com).\n *\n */\n\n#ifndef HEADER_PQUEUE_H\n# define HEADER_PQUEUE_H\n\n# include <stdio.h>\n# include <stdlib.h>\n# include <string.h>\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\ntypedef struct _pqueue *pqueue;\n\ntypedef struct _pitem {\n    unsigned char priority[8];  /* 64-bit value in big-endian encoding */\n    void *data;\n    struct _pitem *next;\n} pitem;\n\ntypedef struct _pitem *piterator;\n\npitem *pitem_new(unsigned char *prio64be, void *data);\nvoid pitem_free(pitem *item);\n\npqueue pqueue_new(void);\nvoid pqueue_free(pqueue pq);\n\npitem *pqueue_insert(pqueue pq, pitem *item);\npitem *pqueue_peek(pqueue pq);\npitem *pqueue_pop(pqueue pq);\npitem *pqueue_find(pqueue pq, unsigned char *prio64be);\npitem *pqueue_iterator(pqueue pq);\npitem *pqueue_next(piterator *iter);\n\nvoid pqueue_print(pqueue pq);\nint pqueue_size(pqueue pq);\n\n#ifdef  __cplusplus\n}\n#endif\n#endif                          /* ! HEADER_PQUEUE_H */\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/arm64/include/openssl/rand.h",
    "content": "/* crypto/rand/rand.h */\n/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)\n * All rights reserved.\n *\n * This package is an SSL implementation written\n * by Eric Young (eay@cryptsoft.com).\n * The implementation was written so as to conform with Netscapes SSL.\n *\n * This library is free for commercial and non-commercial use as long as\n * the following conditions are aheared to.  The following conditions\n * apply to all code found in this distribution, be it the RC4, RSA,\n * lhash, DES, etc., code; not just the SSL code.  The SSL documentation\n * included with this distribution is covered by the same copyright terms\n * except that the holder is Tim Hudson (tjh@cryptsoft.com).\n *\n * Copyright remains Eric Young's, and as such any Copyright notices in\n * the code are not to be removed.\n * If this package is used in a product, Eric Young should be given attribution\n * as the author of the parts of the library used.\n * This can be in the form of a textual message at program startup or\n * in documentation (online or textual) provided with the package.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the copyright\n *    notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in the\n *    documentation and/or other materials provided with the distribution.\n * 3. All advertising materials mentioning features or use of this software\n *    must display the following acknowledgement:\n *    \"This product includes cryptographic software written by\n *     Eric Young (eay@cryptsoft.com)\"\n *    The word 'cryptographic' can be left out if the rouines from the library\n *    being used are not cryptographic related :-).\n * 4. If you include any Windows specific code (or a derivative thereof) from\n *    the apps directory (application code) you must include an acknowledgement:\n *    \"This product includes software written by Tim Hudson (tjh@cryptsoft.com)\"\n *\n * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n * SUCH DAMAGE.\n *\n * The licence and distribution terms for any publically available version or\n * derivative of this code cannot be changed.  i.e. this code cannot simply be\n * copied and put under another distribution licence\n * [including the GNU Public Licence.]\n */\n\n#ifndef HEADER_RAND_H\n# define HEADER_RAND_H\n\n# include <stdlib.h>\n# include <openssl/ossl_typ.h>\n# include <openssl/e_os2.h>\n\n# if defined(OPENSSL_SYS_WINDOWS)\n#  include <windows.h>\n# endif\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n# if defined(OPENSSL_FIPS)\n#  define FIPS_RAND_SIZE_T size_t\n# endif\n\n/* Already defined in ossl_typ.h */\n/* typedef struct rand_meth_st RAND_METHOD; */\n\nstruct rand_meth_st {\n    void (*seed) (const void *buf, int num);\n    int (*bytes) (unsigned char *buf, int num);\n    void (*cleanup) (void);\n    void (*add) (const void *buf, int num, double entropy);\n    int (*pseudorand) (unsigned char *buf, int num);\n    int (*status) (void);\n};\n\n# ifdef BN_DEBUG\nextern int rand_predictable;\n# endif\n\nint RAND_set_rand_method(const RAND_METHOD *meth);\nconst RAND_METHOD *RAND_get_rand_method(void);\n# ifndef OPENSSL_NO_ENGINE\nint RAND_set_rand_engine(ENGINE *engine);\n# endif\nRAND_METHOD *RAND_SSLeay(void);\nvoid RAND_cleanup(void);\nint RAND_bytes(unsigned char *buf, int num);\nint RAND_pseudo_bytes(unsigned char *buf, int num);\nvoid RAND_seed(const void *buf, int num);\nvoid RAND_add(const void *buf, int num, double entropy);\nint RAND_load_file(const char *file, long max_bytes);\nint RAND_write_file(const char *file);\nconst char *RAND_file_name(char *file, size_t num);\nint RAND_status(void);\nint RAND_query_egd_bytes(const char *path, unsigned char *buf, int bytes);\nint RAND_egd(const char *path);\nint RAND_egd_bytes(const char *path, int bytes);\nint RAND_poll(void);\n\n# if defined(OPENSSL_SYS_WINDOWS) || defined(OPENSSL_SYS_WIN32)\n\nvoid RAND_screen(void);\nint RAND_event(UINT, WPARAM, LPARAM);\n\n# endif\n\n# ifdef OPENSSL_FIPS\nvoid RAND_set_fips_drbg_type(int type, int flags);\nint RAND_init_fips(void);\n# endif\n\n/* BEGIN ERROR CODES */\n/*\n * The following lines are auto generated by the script mkerr.pl. Any changes\n * made after this point may be overwritten when the script is next run.\n */\nvoid ERR_load_RAND_strings(void);\n\n/* Error codes for the RAND functions. */\n\n/* Function codes. */\n# define RAND_F_RAND_GET_RAND_METHOD                      101\n# define RAND_F_RAND_INIT_FIPS                            102\n# define RAND_F_SSLEAY_RAND_BYTES                         100\n\n/* Reason codes. */\n# define RAND_R_DUAL_EC_DRBG_DISABLED                     104\n# define RAND_R_ERROR_INITIALISING_DRBG                   102\n# define RAND_R_ERROR_INSTANTIATING_DRBG                  103\n# define RAND_R_NO_FIPS_RANDOM_METHOD_SET                 101\n# define RAND_R_PRNG_NOT_SEEDED                           100\n\n#ifdef  __cplusplus\n}\n#endif\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/arm64/include/openssl/rc2.h",
    "content": "/* crypto/rc2/rc2.h */\n/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)\n * All rights reserved.\n *\n * This package is an SSL implementation written\n * by Eric Young (eay@cryptsoft.com).\n * The implementation was written so as to conform with Netscapes SSL.\n *\n * This library is free for commercial and non-commercial use as long as\n * the following conditions are aheared to.  The following conditions\n * apply to all code found in this distribution, be it the RC4, RSA,\n * lhash, DES, etc., code; not just the SSL code.  The SSL documentation\n * included with this distribution is covered by the same copyright terms\n * except that the holder is Tim Hudson (tjh@cryptsoft.com).\n *\n * Copyright remains Eric Young's, and as such any Copyright notices in\n * the code are not to be removed.\n * If this package is used in a product, Eric Young should be given attribution\n * as the author of the parts of the library used.\n * This can be in the form of a textual message at program startup or\n * in documentation (online or textual) provided with the package.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the copyright\n *    notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in the\n *    documentation and/or other materials provided with the distribution.\n * 3. All advertising materials mentioning features or use of this software\n *    must display the following acknowledgement:\n *    \"This product includes cryptographic software written by\n *     Eric Young (eay@cryptsoft.com)\"\n *    The word 'cryptographic' can be left out if the rouines from the library\n *    being used are not cryptographic related :-).\n * 4. If you include any Windows specific code (or a derivative thereof) from\n *    the apps directory (application code) you must include an acknowledgement:\n *    \"This product includes software written by Tim Hudson (tjh@cryptsoft.com)\"\n *\n * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n * SUCH DAMAGE.\n *\n * The licence and distribution terms for any publically available version or\n * derivative of this code cannot be changed.  i.e. this code cannot simply be\n * copied and put under another distribution licence\n * [including the GNU Public Licence.]\n */\n\n#ifndef HEADER_RC2_H\n# define HEADER_RC2_H\n\n# include <openssl/opensslconf.h>/* OPENSSL_NO_RC2, RC2_INT */\n# ifdef OPENSSL_NO_RC2\n#  error RC2 is disabled.\n# endif\n\n# define RC2_ENCRYPT     1\n# define RC2_DECRYPT     0\n\n# define RC2_BLOCK       8\n# define RC2_KEY_LENGTH  16\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\ntypedef struct rc2_key_st {\n    RC2_INT data[64];\n} RC2_KEY;\n\n# ifdef OPENSSL_FIPS\nvoid private_RC2_set_key(RC2_KEY *key, int len, const unsigned char *data,\n                         int bits);\n# endif\nvoid RC2_set_key(RC2_KEY *key, int len, const unsigned char *data, int bits);\nvoid RC2_ecb_encrypt(const unsigned char *in, unsigned char *out,\n                     RC2_KEY *key, int enc);\nvoid RC2_encrypt(unsigned long *data, RC2_KEY *key);\nvoid RC2_decrypt(unsigned long *data, RC2_KEY *key);\nvoid RC2_cbc_encrypt(const unsigned char *in, unsigned char *out, long length,\n                     RC2_KEY *ks, unsigned char *iv, int enc);\nvoid RC2_cfb64_encrypt(const unsigned char *in, unsigned char *out,\n                       long length, RC2_KEY *schedule, unsigned char *ivec,\n                       int *num, int enc);\nvoid RC2_ofb64_encrypt(const unsigned char *in, unsigned char *out,\n                       long length, RC2_KEY *schedule, unsigned char *ivec,\n                       int *num);\n\n#ifdef  __cplusplus\n}\n#endif\n\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/arm64/include/openssl/rc4.h",
    "content": "/* crypto/rc4/rc4.h */\n/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)\n * All rights reserved.\n *\n * This package is an SSL implementation written\n * by Eric Young (eay@cryptsoft.com).\n * The implementation was written so as to conform with Netscapes SSL.\n *\n * This library is free for commercial and non-commercial use as long as\n * the following conditions are aheared to.  The following conditions\n * apply to all code found in this distribution, be it the RC4, RSA,\n * lhash, DES, etc., code; not just the SSL code.  The SSL documentation\n * included with this distribution is covered by the same copyright terms\n * except that the holder is Tim Hudson (tjh@cryptsoft.com).\n *\n * Copyright remains Eric Young's, and as such any Copyright notices in\n * the code are not to be removed.\n * If this package is used in a product, Eric Young should be given attribution\n * as the author of the parts of the library used.\n * This can be in the form of a textual message at program startup or\n * in documentation (online or textual) provided with the package.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the copyright\n *    notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in the\n *    documentation and/or other materials provided with the distribution.\n * 3. All advertising materials mentioning features or use of this software\n *    must display the following acknowledgement:\n *    \"This product includes cryptographic software written by\n *     Eric Young (eay@cryptsoft.com)\"\n *    The word 'cryptographic' can be left out if the rouines from the library\n *    being used are not cryptographic related :-).\n * 4. If you include any Windows specific code (or a derivative thereof) from\n *    the apps directory (application code) you must include an acknowledgement:\n *    \"This product includes software written by Tim Hudson (tjh@cryptsoft.com)\"\n *\n * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n * SUCH DAMAGE.\n *\n * The licence and distribution terms for any publically available version or\n * derivative of this code cannot be changed.  i.e. this code cannot simply be\n * copied and put under another distribution licence\n * [including the GNU Public Licence.]\n */\n\n#ifndef HEADER_RC4_H\n# define HEADER_RC4_H\n\n# include <openssl/opensslconf.h>/* OPENSSL_NO_RC4, RC4_INT */\n# ifdef OPENSSL_NO_RC4\n#  error RC4 is disabled.\n# endif\n\n# include <stddef.h>\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\ntypedef struct rc4_key_st {\n    RC4_INT x, y;\n    RC4_INT data[256];\n} RC4_KEY;\n\nconst char *RC4_options(void);\nvoid RC4_set_key(RC4_KEY *key, int len, const unsigned char *data);\nvoid private_RC4_set_key(RC4_KEY *key, int len, const unsigned char *data);\nvoid RC4(RC4_KEY *key, size_t len, const unsigned char *indata,\n         unsigned char *outdata);\n\n#ifdef  __cplusplus\n}\n#endif\n\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/arm64/include/openssl/ripemd.h",
    "content": "/* crypto/ripemd/ripemd.h */\n/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)\n * All rights reserved.\n *\n * This package is an SSL implementation written\n * by Eric Young (eay@cryptsoft.com).\n * The implementation was written so as to conform with Netscapes SSL.\n *\n * This library is free for commercial and non-commercial use as long as\n * the following conditions are aheared to.  The following conditions\n * apply to all code found in this distribution, be it the RC4, RSA,\n * lhash, DES, etc., code; not just the SSL code.  The SSL documentation\n * included with this distribution is covered by the same copyright terms\n * except that the holder is Tim Hudson (tjh@cryptsoft.com).\n *\n * Copyright remains Eric Young's, and as such any Copyright notices in\n * the code are not to be removed.\n * If this package is used in a product, Eric Young should be given attribution\n * as the author of the parts of the library used.\n * This can be in the form of a textual message at program startup or\n * in documentation (online or textual) provided with the package.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the copyright\n *    notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in the\n *    documentation and/or other materials provided with the distribution.\n * 3. All advertising materials mentioning features or use of this software\n *    must display the following acknowledgement:\n *    \"This product includes cryptographic software written by\n *     Eric Young (eay@cryptsoft.com)\"\n *    The word 'cryptographic' can be left out if the rouines from the library\n *    being used are not cryptographic related :-).\n * 4. If you include any Windows specific code (or a derivative thereof) from\n *    the apps directory (application code) you must include an acknowledgement:\n *    \"This product includes software written by Tim Hudson (tjh@cryptsoft.com)\"\n *\n * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n * SUCH DAMAGE.\n *\n * The licence and distribution terms for any publically available version or\n * derivative of this code cannot be changed.  i.e. this code cannot simply be\n * copied and put under another distribution licence\n * [including the GNU Public Licence.]\n */\n\n#ifndef HEADER_RIPEMD_H\n# define HEADER_RIPEMD_H\n\n# include <openssl/e_os2.h>\n# include <stddef.h>\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n# ifdef OPENSSL_NO_RIPEMD\n#  error RIPEMD is disabled.\n# endif\n\n# if defined(__LP32__)\n#  define RIPEMD160_LONG unsigned long\n# elif defined(OPENSSL_SYS_CRAY) || defined(__ILP64__)\n#  define RIPEMD160_LONG unsigned long\n#  define RIPEMD160_LONG_LOG2 3\n# else\n#  define RIPEMD160_LONG unsigned int\n# endif\n\n# define RIPEMD160_CBLOCK        64\n# define RIPEMD160_LBLOCK        (RIPEMD160_CBLOCK/4)\n# define RIPEMD160_DIGEST_LENGTH 20\n\ntypedef struct RIPEMD160state_st {\n    RIPEMD160_LONG A, B, C, D, E;\n    RIPEMD160_LONG Nl, Nh;\n    RIPEMD160_LONG data[RIPEMD160_LBLOCK];\n    unsigned int num;\n} RIPEMD160_CTX;\n\n# ifdef OPENSSL_FIPS\nint private_RIPEMD160_Init(RIPEMD160_CTX *c);\n# endif\nint RIPEMD160_Init(RIPEMD160_CTX *c);\nint RIPEMD160_Update(RIPEMD160_CTX *c, const void *data, size_t len);\nint RIPEMD160_Final(unsigned char *md, RIPEMD160_CTX *c);\nunsigned char *RIPEMD160(const unsigned char *d, size_t n, unsigned char *md);\nvoid RIPEMD160_Transform(RIPEMD160_CTX *c, const unsigned char *b);\n#ifdef  __cplusplus\n}\n#endif\n\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/arm64/include/openssl/rsa.h",
    "content": "/* crypto/rsa/rsa.h */\n/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)\n * All rights reserved.\n *\n * This package is an SSL implementation written\n * by Eric Young (eay@cryptsoft.com).\n * The implementation was written so as to conform with Netscapes SSL.\n *\n * This library is free for commercial and non-commercial use as long as\n * the following conditions are aheared to.  The following conditions\n * apply to all code found in this distribution, be it the RC4, RSA,\n * lhash, DES, etc., code; not just the SSL code.  The SSL documentation\n * included with this distribution is covered by the same copyright terms\n * except that the holder is Tim Hudson (tjh@cryptsoft.com).\n *\n * Copyright remains Eric Young's, and as such any Copyright notices in\n * the code are not to be removed.\n * If this package is used in a product, Eric Young should be given attribution\n * as the author of the parts of the library used.\n * This can be in the form of a textual message at program startup or\n * in documentation (online or textual) provided with the package.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the copyright\n *    notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in the\n *    documentation and/or other materials provided with the distribution.\n * 3. All advertising materials mentioning features or use of this software\n *    must display the following acknowledgement:\n *    \"This product includes cryptographic software written by\n *     Eric Young (eay@cryptsoft.com)\"\n *    The word 'cryptographic' can be left out if the rouines from the library\n *    being used are not cryptographic related :-).\n * 4. If you include any Windows specific code (or a derivative thereof) from\n *    the apps directory (application code) you must include an acknowledgement:\n *    \"This product includes software written by Tim Hudson (tjh@cryptsoft.com)\"\n *\n * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n * SUCH DAMAGE.\n *\n * The licence and distribution terms for any publically available version or\n * derivative of this code cannot be changed.  i.e. this code cannot simply be\n * copied and put under another distribution licence\n * [including the GNU Public Licence.]\n */\n\n#ifndef HEADER_RSA_H\n# define HEADER_RSA_H\n\n# include <openssl/asn1.h>\n\n# ifndef OPENSSL_NO_BIO\n#  include <openssl/bio.h>\n# endif\n# include <openssl/crypto.h>\n# include <openssl/ossl_typ.h>\n# ifndef OPENSSL_NO_DEPRECATED\n#  include <openssl/bn.h>\n# endif\n\n# ifdef OPENSSL_NO_RSA\n#  error RSA is disabled.\n# endif\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n/* Declared already in ossl_typ.h */\n/* typedef struct rsa_st RSA; */\n/* typedef struct rsa_meth_st RSA_METHOD; */\n\nstruct rsa_meth_st {\n    const char *name;\n    int (*rsa_pub_enc) (int flen, const unsigned char *from,\n                        unsigned char *to, RSA *rsa, int padding);\n    int (*rsa_pub_dec) (int flen, const unsigned char *from,\n                        unsigned char *to, RSA *rsa, int padding);\n    int (*rsa_priv_enc) (int flen, const unsigned char *from,\n                         unsigned char *to, RSA *rsa, int padding);\n    int (*rsa_priv_dec) (int flen, const unsigned char *from,\n                         unsigned char *to, RSA *rsa, int padding);\n    /* Can be null */\n    int (*rsa_mod_exp) (BIGNUM *r0, const BIGNUM *I, RSA *rsa, BN_CTX *ctx);\n    /* Can be null */\n    int (*bn_mod_exp) (BIGNUM *r, const BIGNUM *a, const BIGNUM *p,\n                       const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx);\n    /* called at new */\n    int (*init) (RSA *rsa);\n    /* called at free */\n    int (*finish) (RSA *rsa);\n    /* RSA_METHOD_FLAG_* things */\n    int flags;\n    /* may be needed! */\n    char *app_data;\n    /*\n     * New sign and verify functions: some libraries don't allow arbitrary\n     * data to be signed/verified: this allows them to be used. Note: for\n     * this to work the RSA_public_decrypt() and RSA_private_encrypt() should\n     * *NOT* be used RSA_sign(), RSA_verify() should be used instead. Note:\n     * for backwards compatibility this functionality is only enabled if the\n     * RSA_FLAG_SIGN_VER option is set in 'flags'.\n     */\n    int (*rsa_sign) (int type,\n                     const unsigned char *m, unsigned int m_length,\n                     unsigned char *sigret, unsigned int *siglen,\n                     const RSA *rsa);\n    int (*rsa_verify) (int dtype, const unsigned char *m,\n                       unsigned int m_length, const unsigned char *sigbuf,\n                       unsigned int siglen, const RSA *rsa);\n    /*\n     * If this callback is NULL, the builtin software RSA key-gen will be\n     * used. This is for behavioural compatibility whilst the code gets\n     * rewired, but one day it would be nice to assume there are no such\n     * things as \"builtin software\" implementations.\n     */\n    int (*rsa_keygen) (RSA *rsa, int bits, BIGNUM *e, BN_GENCB *cb);\n};\n\nstruct rsa_st {\n    /*\n     * The first parameter is used to pickup errors where this is passed\n     * instead of aEVP_PKEY, it is set to 0\n     */\n    int pad;\n    long version;\n    const RSA_METHOD *meth;\n    /* functional reference if 'meth' is ENGINE-provided */\n    ENGINE *engine;\n    BIGNUM *n;\n    BIGNUM *e;\n    BIGNUM *d;\n    BIGNUM *p;\n    BIGNUM *q;\n    BIGNUM *dmp1;\n    BIGNUM *dmq1;\n    BIGNUM *iqmp;\n    /* be careful using this if the RSA structure is shared */\n    CRYPTO_EX_DATA ex_data;\n    int references;\n    int flags;\n    /* Used to cache montgomery values */\n    BN_MONT_CTX *_method_mod_n;\n    BN_MONT_CTX *_method_mod_p;\n    BN_MONT_CTX *_method_mod_q;\n    /*\n     * all BIGNUM values are actually in the following data, if it is not\n     * NULL\n     */\n    char *bignum_data;\n    BN_BLINDING *blinding;\n    BN_BLINDING *mt_blinding;\n};\n\n# ifndef OPENSSL_RSA_MAX_MODULUS_BITS\n#  define OPENSSL_RSA_MAX_MODULUS_BITS   16384\n# endif\n\n# ifndef OPENSSL_RSA_SMALL_MODULUS_BITS\n#  define OPENSSL_RSA_SMALL_MODULUS_BITS 3072\n# endif\n# ifndef OPENSSL_RSA_MAX_PUBEXP_BITS\n\n/* exponent limit enforced for \"large\" modulus only */\n#  define OPENSSL_RSA_MAX_PUBEXP_BITS    64\n# endif\n\n# define RSA_3   0x3L\n# define RSA_F4  0x10001L\n\n# define RSA_METHOD_FLAG_NO_CHECK        0x0001/* don't check pub/private\n                                                * match */\n\n# define RSA_FLAG_CACHE_PUBLIC           0x0002\n# define RSA_FLAG_CACHE_PRIVATE          0x0004\n# define RSA_FLAG_BLINDING               0x0008\n# define RSA_FLAG_THREAD_SAFE            0x0010\n/*\n * This flag means the private key operations will be handled by rsa_mod_exp\n * and that they do not depend on the private key components being present:\n * for example a key stored in external hardware. Without this flag\n * bn_mod_exp gets called when private key components are absent.\n */\n# define RSA_FLAG_EXT_PKEY               0x0020\n\n/*\n * This flag in the RSA_METHOD enables the new rsa_sign, rsa_verify\n * functions.\n */\n# define RSA_FLAG_SIGN_VER               0x0040\n\n/*\n * new with 0.9.6j and 0.9.7b; the built-in\n * RSA implementation now uses blinding by\n * default (ignoring RSA_FLAG_BLINDING),\n * but other engines might not need it\n */\n# define RSA_FLAG_NO_BLINDING            0x0080\n/*\n * new with 0.9.8f; the built-in RSA\n * implementation now uses constant time\n * operations by default in private key operations,\n * e.g., constant time modular exponentiation,\n * modular inverse without leaking branches,\n * division without leaking branches. This\n * flag disables these constant time\n * operations and results in faster RSA\n * private key operations.\n */\n# define RSA_FLAG_NO_CONSTTIME           0x0100\n# ifdef OPENSSL_USE_DEPRECATED\n/* deprecated name for the flag*/\n/*\n * new with 0.9.7h; the built-in RSA\n * implementation now uses constant time\n * modular exponentiation for secret exponents\n * by default. This flag causes the\n * faster variable sliding window method to\n * be used for all exponents.\n */\n#  define RSA_FLAG_NO_EXP_CONSTTIME RSA_FLAG_NO_CONSTTIME\n# endif\n\n# define EVP_PKEY_CTX_set_rsa_padding(ctx, pad) \\\n        EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_RSA, -1, EVP_PKEY_CTRL_RSA_PADDING, \\\n                                pad, NULL)\n\n# define EVP_PKEY_CTX_get_rsa_padding(ctx, ppad) \\\n        EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_RSA, -1, \\\n                                EVP_PKEY_CTRL_GET_RSA_PADDING, 0, ppad)\n\n# define EVP_PKEY_CTX_set_rsa_pss_saltlen(ctx, len) \\\n        EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_RSA, \\\n                                (EVP_PKEY_OP_SIGN|EVP_PKEY_OP_VERIFY), \\\n                                EVP_PKEY_CTRL_RSA_PSS_SALTLEN, \\\n                                len, NULL)\n\n# define EVP_PKEY_CTX_get_rsa_pss_saltlen(ctx, plen) \\\n        EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_RSA, \\\n                                (EVP_PKEY_OP_SIGN|EVP_PKEY_OP_VERIFY), \\\n                                EVP_PKEY_CTRL_GET_RSA_PSS_SALTLEN, \\\n                                0, plen)\n\n# define EVP_PKEY_CTX_set_rsa_keygen_bits(ctx, bits) \\\n        EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_RSA, EVP_PKEY_OP_KEYGEN, \\\n                                EVP_PKEY_CTRL_RSA_KEYGEN_BITS, bits, NULL)\n\n# define EVP_PKEY_CTX_set_rsa_keygen_pubexp(ctx, pubexp) \\\n        EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_RSA, EVP_PKEY_OP_KEYGEN, \\\n                                EVP_PKEY_CTRL_RSA_KEYGEN_PUBEXP, 0, pubexp)\n\n# define  EVP_PKEY_CTX_set_rsa_mgf1_md(ctx, md)  \\\n                EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_RSA, \\\n                        EVP_PKEY_OP_TYPE_SIG | EVP_PKEY_OP_TYPE_CRYPT, \\\n                                EVP_PKEY_CTRL_RSA_MGF1_MD, 0, (void *)md)\n\n# define  EVP_PKEY_CTX_set_rsa_oaep_md(ctx, md)  \\\n                EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_RSA, EVP_PKEY_OP_TYPE_CRYPT,  \\\n                                EVP_PKEY_CTRL_RSA_OAEP_MD, 0, (void *)md)\n\n# define  EVP_PKEY_CTX_get_rsa_mgf1_md(ctx, pmd) \\\n                EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_RSA, \\\n                        EVP_PKEY_OP_TYPE_SIG | EVP_PKEY_OP_TYPE_CRYPT, \\\n                                EVP_PKEY_CTRL_GET_RSA_MGF1_MD, 0, (void *)pmd)\n\n# define  EVP_PKEY_CTX_get_rsa_oaep_md(ctx, pmd) \\\n                EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_RSA, EVP_PKEY_OP_TYPE_CRYPT,  \\\n                                EVP_PKEY_CTRL_GET_RSA_OAEP_MD, 0, (void *)pmd)\n\n# define  EVP_PKEY_CTX_set0_rsa_oaep_label(ctx, l, llen) \\\n                EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_RSA, EVP_PKEY_OP_TYPE_CRYPT,  \\\n                                EVP_PKEY_CTRL_RSA_OAEP_LABEL, llen, (void *)l)\n\n# define  EVP_PKEY_CTX_get0_rsa_oaep_label(ctx, l)       \\\n                EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_RSA, EVP_PKEY_OP_TYPE_CRYPT,  \\\n                                EVP_PKEY_CTRL_GET_RSA_OAEP_LABEL, 0, (void *)l)\n\n# define EVP_PKEY_CTRL_RSA_PADDING       (EVP_PKEY_ALG_CTRL + 1)\n# define EVP_PKEY_CTRL_RSA_PSS_SALTLEN   (EVP_PKEY_ALG_CTRL + 2)\n\n# define EVP_PKEY_CTRL_RSA_KEYGEN_BITS   (EVP_PKEY_ALG_CTRL + 3)\n# define EVP_PKEY_CTRL_RSA_KEYGEN_PUBEXP (EVP_PKEY_ALG_CTRL + 4)\n# define EVP_PKEY_CTRL_RSA_MGF1_MD       (EVP_PKEY_ALG_CTRL + 5)\n\n# define EVP_PKEY_CTRL_GET_RSA_PADDING           (EVP_PKEY_ALG_CTRL + 6)\n# define EVP_PKEY_CTRL_GET_RSA_PSS_SALTLEN       (EVP_PKEY_ALG_CTRL + 7)\n# define EVP_PKEY_CTRL_GET_RSA_MGF1_MD           (EVP_PKEY_ALG_CTRL + 8)\n\n# define EVP_PKEY_CTRL_RSA_OAEP_MD       (EVP_PKEY_ALG_CTRL + 9)\n# define EVP_PKEY_CTRL_RSA_OAEP_LABEL    (EVP_PKEY_ALG_CTRL + 10)\n\n# define EVP_PKEY_CTRL_GET_RSA_OAEP_MD   (EVP_PKEY_ALG_CTRL + 11)\n# define EVP_PKEY_CTRL_GET_RSA_OAEP_LABEL (EVP_PKEY_ALG_CTRL + 12)\n\n# define RSA_PKCS1_PADDING       1\n# define RSA_SSLV23_PADDING      2\n# define RSA_NO_PADDING          3\n# define RSA_PKCS1_OAEP_PADDING  4\n# define RSA_X931_PADDING        5\n/* EVP_PKEY_ only */\n# define RSA_PKCS1_PSS_PADDING   6\n\n# define RSA_PKCS1_PADDING_SIZE  11\n\n# define RSA_set_app_data(s,arg)         RSA_set_ex_data(s,0,arg)\n# define RSA_get_app_data(s)             RSA_get_ex_data(s,0)\n\nRSA *RSA_new(void);\nRSA *RSA_new_method(ENGINE *engine);\nint RSA_size(const RSA *rsa);\n\n/* Deprecated version */\n# ifndef OPENSSL_NO_DEPRECATED\nRSA *RSA_generate_key(int bits, unsigned long e, void\n                       (*callback) (int, int, void *), void *cb_arg);\n# endif                         /* !defined(OPENSSL_NO_DEPRECATED) */\n\n/* New version */\nint RSA_generate_key_ex(RSA *rsa, int bits, BIGNUM *e, BN_GENCB *cb);\n\nint RSA_check_key(const RSA *);\n        /* next 4 return -1 on error */\nint RSA_public_encrypt(int flen, const unsigned char *from,\n                       unsigned char *to, RSA *rsa, int padding);\nint RSA_private_encrypt(int flen, const unsigned char *from,\n                        unsigned char *to, RSA *rsa, int padding);\nint RSA_public_decrypt(int flen, const unsigned char *from,\n                       unsigned char *to, RSA *rsa, int padding);\nint RSA_private_decrypt(int flen, const unsigned char *from,\n                        unsigned char *to, RSA *rsa, int padding);\nvoid RSA_free(RSA *r);\n/* \"up\" the RSA object's reference count */\nint RSA_up_ref(RSA *r);\n\nint RSA_flags(const RSA *r);\n\nvoid RSA_set_default_method(const RSA_METHOD *meth);\nconst RSA_METHOD *RSA_get_default_method(void);\nconst RSA_METHOD *RSA_get_method(const RSA *rsa);\nint RSA_set_method(RSA *rsa, const RSA_METHOD *meth);\n\n/* This function needs the memory locking malloc callbacks to be installed */\nint RSA_memory_lock(RSA *r);\n\n/* these are the actual SSLeay RSA functions */\nconst RSA_METHOD *RSA_PKCS1_SSLeay(void);\n\nconst RSA_METHOD *RSA_null_method(void);\n\nDECLARE_ASN1_ENCODE_FUNCTIONS_const(RSA, RSAPublicKey)\nDECLARE_ASN1_ENCODE_FUNCTIONS_const(RSA, RSAPrivateKey)\n\ntypedef struct rsa_pss_params_st {\n    X509_ALGOR *hashAlgorithm;\n    X509_ALGOR *maskGenAlgorithm;\n    ASN1_INTEGER *saltLength;\n    ASN1_INTEGER *trailerField;\n} RSA_PSS_PARAMS;\n\nDECLARE_ASN1_FUNCTIONS(RSA_PSS_PARAMS)\n\ntypedef struct rsa_oaep_params_st {\n    X509_ALGOR *hashFunc;\n    X509_ALGOR *maskGenFunc;\n    X509_ALGOR *pSourceFunc;\n} RSA_OAEP_PARAMS;\n\nDECLARE_ASN1_FUNCTIONS(RSA_OAEP_PARAMS)\n\n# ifndef OPENSSL_NO_FP_API\nint RSA_print_fp(FILE *fp, const RSA *r, int offset);\n# endif\n\n# ifndef OPENSSL_NO_BIO\nint RSA_print(BIO *bp, const RSA *r, int offset);\n# endif\n\n# ifndef OPENSSL_NO_RC4\nint i2d_RSA_NET(const RSA *a, unsigned char **pp,\n                int (*cb) (char *buf, int len, const char *prompt,\n                           int verify), int sgckey);\nRSA *d2i_RSA_NET(RSA **a, const unsigned char **pp, long length,\n                 int (*cb) (char *buf, int len, const char *prompt,\n                            int verify), int sgckey);\n\nint i2d_Netscape_RSA(const RSA *a, unsigned char **pp,\n                     int (*cb) (char *buf, int len, const char *prompt,\n                                int verify));\nRSA *d2i_Netscape_RSA(RSA **a, const unsigned char **pp, long length,\n                      int (*cb) (char *buf, int len, const char *prompt,\n                                 int verify));\n# endif\n\n/*\n * The following 2 functions sign and verify a X509_SIG ASN1 object inside\n * PKCS#1 padded RSA encryption\n */\nint RSA_sign(int type, const unsigned char *m, unsigned int m_length,\n             unsigned char *sigret, unsigned int *siglen, RSA *rsa);\nint RSA_verify(int type, const unsigned char *m, unsigned int m_length,\n               const unsigned char *sigbuf, unsigned int siglen, RSA *rsa);\n\n/*\n * The following 2 function sign and verify a ASN1_OCTET_STRING object inside\n * PKCS#1 padded RSA encryption\n */\nint RSA_sign_ASN1_OCTET_STRING(int type,\n                               const unsigned char *m, unsigned int m_length,\n                               unsigned char *sigret, unsigned int *siglen,\n                               RSA *rsa);\nint RSA_verify_ASN1_OCTET_STRING(int type, const unsigned char *m,\n                                 unsigned int m_length, unsigned char *sigbuf,\n                                 unsigned int siglen, RSA *rsa);\n\nint RSA_blinding_on(RSA *rsa, BN_CTX *ctx);\nvoid RSA_blinding_off(RSA *rsa);\nBN_BLINDING *RSA_setup_blinding(RSA *rsa, BN_CTX *ctx);\n\nint RSA_padding_add_PKCS1_type_1(unsigned char *to, int tlen,\n                                 const unsigned char *f, int fl);\nint RSA_padding_check_PKCS1_type_1(unsigned char *to, int tlen,\n                                   const unsigned char *f, int fl,\n                                   int rsa_len);\nint RSA_padding_add_PKCS1_type_2(unsigned char *to, int tlen,\n                                 const unsigned char *f, int fl);\nint RSA_padding_check_PKCS1_type_2(unsigned char *to, int tlen,\n                                   const unsigned char *f, int fl,\n                                   int rsa_len);\nint PKCS1_MGF1(unsigned char *mask, long len, const unsigned char *seed,\n               long seedlen, const EVP_MD *dgst);\nint RSA_padding_add_PKCS1_OAEP(unsigned char *to, int tlen,\n                               const unsigned char *f, int fl,\n                               const unsigned char *p, int pl);\nint RSA_padding_check_PKCS1_OAEP(unsigned char *to, int tlen,\n                                 const unsigned char *f, int fl, int rsa_len,\n                                 const unsigned char *p, int pl);\nint RSA_padding_add_PKCS1_OAEP_mgf1(unsigned char *to, int tlen,\n                                    const unsigned char *from, int flen,\n                                    const unsigned char *param, int plen,\n                                    const EVP_MD *md, const EVP_MD *mgf1md);\nint RSA_padding_check_PKCS1_OAEP_mgf1(unsigned char *to, int tlen,\n                                      const unsigned char *from, int flen,\n                                      int num, const unsigned char *param,\n                                      int plen, const EVP_MD *md,\n                                      const EVP_MD *mgf1md);\nint RSA_padding_add_SSLv23(unsigned char *to, int tlen,\n                           const unsigned char *f, int fl);\nint RSA_padding_check_SSLv23(unsigned char *to, int tlen,\n                             const unsigned char *f, int fl, int rsa_len);\nint RSA_padding_add_none(unsigned char *to, int tlen, const unsigned char *f,\n                         int fl);\nint RSA_padding_check_none(unsigned char *to, int tlen,\n                           const unsigned char *f, int fl, int rsa_len);\nint RSA_padding_add_X931(unsigned char *to, int tlen, const unsigned char *f,\n                         int fl);\nint RSA_padding_check_X931(unsigned char *to, int tlen,\n                           const unsigned char *f, int fl, int rsa_len);\nint RSA_X931_hash_id(int nid);\n\nint RSA_verify_PKCS1_PSS(RSA *rsa, const unsigned char *mHash,\n                         const EVP_MD *Hash, const unsigned char *EM,\n                         int sLen);\nint RSA_padding_add_PKCS1_PSS(RSA *rsa, unsigned char *EM,\n                              const unsigned char *mHash, const EVP_MD *Hash,\n                              int sLen);\n\nint RSA_verify_PKCS1_PSS_mgf1(RSA *rsa, const unsigned char *mHash,\n                              const EVP_MD *Hash, const EVP_MD *mgf1Hash,\n                              const unsigned char *EM, int sLen);\n\nint RSA_padding_add_PKCS1_PSS_mgf1(RSA *rsa, unsigned char *EM,\n                                   const unsigned char *mHash,\n                                   const EVP_MD *Hash, const EVP_MD *mgf1Hash,\n                                   int sLen);\n\nint RSA_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func,\n                         CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func);\nint RSA_set_ex_data(RSA *r, int idx, void *arg);\nvoid *RSA_get_ex_data(const RSA *r, int idx);\n\nRSA *RSAPublicKey_dup(RSA *rsa);\nRSA *RSAPrivateKey_dup(RSA *rsa);\n\n/*\n * If this flag is set the RSA method is FIPS compliant and can be used in\n * FIPS mode. This is set in the validated module method. If an application\n * sets this flag in its own methods it is its responsibility to ensure the\n * result is compliant.\n */\n\n# define RSA_FLAG_FIPS_METHOD                    0x0400\n\n/*\n * If this flag is set the operations normally disabled in FIPS mode are\n * permitted it is then the applications responsibility to ensure that the\n * usage is compliant.\n */\n\n# define RSA_FLAG_NON_FIPS_ALLOW                 0x0400\n/*\n * Application has decided PRNG is good enough to generate a key: don't\n * check.\n */\n# define RSA_FLAG_CHECKED                        0x0800\n\n/* BEGIN ERROR CODES */\n/*\n * The following lines are auto generated by the script mkerr.pl. Any changes\n * made after this point may be overwritten when the script is next run.\n */\nvoid ERR_load_RSA_strings(void);\n\n/* Error codes for the RSA functions. */\n\n/* Function codes. */\n# define RSA_F_CHECK_PADDING_MD                           140\n# define RSA_F_DO_RSA_PRINT                               146\n# define RSA_F_INT_RSA_VERIFY                             145\n# define RSA_F_MEMORY_LOCK                                100\n# define RSA_F_OLD_RSA_PRIV_DECODE                        147\n# define RSA_F_PKEY_RSA_CTRL                              143\n# define RSA_F_PKEY_RSA_CTRL_STR                          144\n# define RSA_F_PKEY_RSA_SIGN                              142\n# define RSA_F_PKEY_RSA_VERIFY                            154\n# define RSA_F_PKEY_RSA_VERIFYRECOVER                     141\n# define RSA_F_RSA_ALGOR_TO_MD                            157\n# define RSA_F_RSA_BUILTIN_KEYGEN                         129\n# define RSA_F_RSA_CHECK_KEY                              123\n# define RSA_F_RSA_CMS_DECRYPT                            158\n# define RSA_F_RSA_EAY_PRIVATE_DECRYPT                    101\n# define RSA_F_RSA_EAY_PRIVATE_ENCRYPT                    102\n# define RSA_F_RSA_EAY_PUBLIC_DECRYPT                     103\n# define RSA_F_RSA_EAY_PUBLIC_ENCRYPT                     104\n# define RSA_F_RSA_GENERATE_KEY                           105\n# define RSA_F_RSA_GENERATE_KEY_EX                        155\n# define RSA_F_RSA_ITEM_VERIFY                            156\n# define RSA_F_RSA_MEMORY_LOCK                            130\n# define RSA_F_RSA_MGF1_TO_MD                             159\n# define RSA_F_RSA_NEW_METHOD                             106\n# define RSA_F_RSA_NULL                                   124\n# define RSA_F_RSA_NULL_MOD_EXP                           131\n# define RSA_F_RSA_NULL_PRIVATE_DECRYPT                   132\n# define RSA_F_RSA_NULL_PRIVATE_ENCRYPT                   133\n# define RSA_F_RSA_NULL_PUBLIC_DECRYPT                    134\n# define RSA_F_RSA_NULL_PUBLIC_ENCRYPT                    135\n# define RSA_F_RSA_PADDING_ADD_NONE                       107\n# define RSA_F_RSA_PADDING_ADD_PKCS1_OAEP                 121\n# define RSA_F_RSA_PADDING_ADD_PKCS1_OAEP_MGF1            160\n# define RSA_F_RSA_PADDING_ADD_PKCS1_PSS                  125\n# define RSA_F_RSA_PADDING_ADD_PKCS1_PSS_MGF1             148\n# define RSA_F_RSA_PADDING_ADD_PKCS1_TYPE_1               108\n# define RSA_F_RSA_PADDING_ADD_PKCS1_TYPE_2               109\n# define RSA_F_RSA_PADDING_ADD_SSLV23                     110\n# define RSA_F_RSA_PADDING_ADD_X931                       127\n# define RSA_F_RSA_PADDING_CHECK_NONE                     111\n# define RSA_F_RSA_PADDING_CHECK_PKCS1_OAEP               122\n# define RSA_F_RSA_PADDING_CHECK_PKCS1_OAEP_MGF1          161\n# define RSA_F_RSA_PADDING_CHECK_PKCS1_TYPE_1             112\n# define RSA_F_RSA_PADDING_CHECK_PKCS1_TYPE_2             113\n# define RSA_F_RSA_PADDING_CHECK_SSLV23                   114\n# define RSA_F_RSA_PADDING_CHECK_X931                     128\n# define RSA_F_RSA_PRINT                                  115\n# define RSA_F_RSA_PRINT_FP                               116\n# define RSA_F_RSA_PRIVATE_DECRYPT                        150\n# define RSA_F_RSA_PRIVATE_ENCRYPT                        151\n# define RSA_F_RSA_PRIV_DECODE                            137\n# define RSA_F_RSA_PRIV_ENCODE                            138\n# define RSA_F_RSA_PSS_TO_CTX                             162\n# define RSA_F_RSA_PUBLIC_DECRYPT                         152\n# define RSA_F_RSA_PUBLIC_ENCRYPT                         153\n# define RSA_F_RSA_PUB_DECODE                             139\n# define RSA_F_RSA_SETUP_BLINDING                         136\n# define RSA_F_RSA_SIGN                                   117\n# define RSA_F_RSA_SIGN_ASN1_OCTET_STRING                 118\n# define RSA_F_RSA_VERIFY                                 119\n# define RSA_F_RSA_VERIFY_ASN1_OCTET_STRING               120\n# define RSA_F_RSA_VERIFY_PKCS1_PSS                       126\n# define RSA_F_RSA_VERIFY_PKCS1_PSS_MGF1                  149\n\n/* Reason codes. */\n# define RSA_R_ALGORITHM_MISMATCH                         100\n# define RSA_R_BAD_E_VALUE                                101\n# define RSA_R_BAD_FIXED_HEADER_DECRYPT                   102\n# define RSA_R_BAD_PAD_BYTE_COUNT                         103\n# define RSA_R_BAD_SIGNATURE                              104\n# define RSA_R_BLOCK_TYPE_IS_NOT_01                       106\n# define RSA_R_BLOCK_TYPE_IS_NOT_02                       107\n# define RSA_R_DATA_GREATER_THAN_MOD_LEN                  108\n# define RSA_R_DATA_TOO_LARGE                             109\n# define RSA_R_DATA_TOO_LARGE_FOR_KEY_SIZE                110\n# define RSA_R_DATA_TOO_LARGE_FOR_MODULUS                 132\n# define RSA_R_DATA_TOO_SMALL                             111\n# define RSA_R_DATA_TOO_SMALL_FOR_KEY_SIZE                122\n# define RSA_R_DIGEST_DOES_NOT_MATCH                      166\n# define RSA_R_DIGEST_TOO_BIG_FOR_RSA_KEY                 112\n# define RSA_R_DMP1_NOT_CONGRUENT_TO_D                    124\n# define RSA_R_DMQ1_NOT_CONGRUENT_TO_D                    125\n# define RSA_R_D_E_NOT_CONGRUENT_TO_1                     123\n# define RSA_R_FIRST_OCTET_INVALID                        133\n# define RSA_R_ILLEGAL_OR_UNSUPPORTED_PADDING_MODE        144\n# define RSA_R_INVALID_DIGEST                             160\n# define RSA_R_INVALID_DIGEST_LENGTH                      143\n# define RSA_R_INVALID_HEADER                             137\n# define RSA_R_INVALID_KEYBITS                            145\n# define RSA_R_INVALID_LABEL                              161\n# define RSA_R_INVALID_MESSAGE_LENGTH                     131\n# define RSA_R_INVALID_MGF1_MD                            156\n# define RSA_R_INVALID_OAEP_PARAMETERS                    162\n# define RSA_R_INVALID_PADDING                            138\n# define RSA_R_INVALID_PADDING_MODE                       141\n# define RSA_R_INVALID_PSS_PARAMETERS                     149\n# define RSA_R_INVALID_PSS_SALTLEN                        146\n# define RSA_R_INVALID_SALT_LENGTH                        150\n# define RSA_R_INVALID_TRAILER                            139\n# define RSA_R_INVALID_X931_DIGEST                        142\n# define RSA_R_IQMP_NOT_INVERSE_OF_Q                      126\n# define RSA_R_KEY_SIZE_TOO_SMALL                         120\n# define RSA_R_LAST_OCTET_INVALID                         134\n# define RSA_R_MODULUS_TOO_LARGE                          105\n# define RSA_R_NON_FIPS_RSA_METHOD                        157\n# define RSA_R_NO_PUBLIC_EXPONENT                         140\n# define RSA_R_NULL_BEFORE_BLOCK_MISSING                  113\n# define RSA_R_N_DOES_NOT_EQUAL_P_Q                       127\n# define RSA_R_OAEP_DECODING_ERROR                        121\n# define RSA_R_OPERATION_NOT_ALLOWED_IN_FIPS_MODE         158\n# define RSA_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE   148\n# define RSA_R_PADDING_CHECK_FAILED                       114\n# define RSA_R_PKCS_DECODING_ERROR                        159\n# define RSA_R_P_NOT_PRIME                                128\n# define RSA_R_Q_NOT_PRIME                                129\n# define RSA_R_RSA_OPERATIONS_NOT_SUPPORTED               130\n# define RSA_R_SLEN_CHECK_FAILED                          136\n# define RSA_R_SLEN_RECOVERY_FAILED                       135\n# define RSA_R_SSLV3_ROLLBACK_ATTACK                      115\n# define RSA_R_THE_ASN1_OBJECT_IDENTIFIER_IS_NOT_KNOWN_FOR_THIS_MD 116\n# define RSA_R_UNKNOWN_ALGORITHM_TYPE                     117\n# define RSA_R_UNKNOWN_DIGEST                             163\n# define RSA_R_UNKNOWN_MASK_DIGEST                        151\n# define RSA_R_UNKNOWN_PADDING_TYPE                       118\n# define RSA_R_UNKNOWN_PSS_DIGEST                         152\n# define RSA_R_UNSUPPORTED_ENCRYPTION_TYPE                164\n# define RSA_R_UNSUPPORTED_LABEL_SOURCE                   165\n# define RSA_R_UNSUPPORTED_MASK_ALGORITHM                 153\n# define RSA_R_UNSUPPORTED_MASK_PARAMETER                 154\n# define RSA_R_UNSUPPORTED_SIGNATURE_TYPE                 155\n# define RSA_R_VALUE_MISSING                              147\n# define RSA_R_WRONG_SIGNATURE_LENGTH                     119\n\n#ifdef  __cplusplus\n}\n#endif\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/arm64/include/openssl/safestack.h",
    "content": "/* ====================================================================\n * Copyright (c) 1999 The OpenSSL Project.  All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n *\n * 1. Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n *\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in\n *    the documentation and/or other materials provided with the\n *    distribution.\n *\n * 3. All advertising materials mentioning features or use of this\n *    software must display the following acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit. (http://www.openssl.org/)\"\n *\n * 4. The names \"OpenSSL Toolkit\" and \"OpenSSL Project\" must not be used to\n *    endorse or promote products derived from this software without\n *    prior written permission. For written permission, please contact\n *    openssl-core@openssl.org.\n *\n * 5. Products derived from this software may not be called \"OpenSSL\"\n *    nor may \"OpenSSL\" appear in their names without prior written\n *    permission of the OpenSSL Project.\n *\n * 6. Redistributions of any form whatsoever must retain the following\n *    acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit (http://www.openssl.org/)\"\n *\n * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY\n * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\n * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR\n * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\n * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,\n * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED\n * OF THE POSSIBILITY OF SUCH DAMAGE.\n * ====================================================================\n *\n * This product includes cryptographic software written by Eric Young\n * (eay@cryptsoft.com).  This product includes software written by Tim\n * Hudson (tjh@cryptsoft.com).\n *\n */\n\n#ifndef HEADER_SAFESTACK_H\n# define HEADER_SAFESTACK_H\n\n# include <openssl/stack.h>\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n# ifndef CHECKED_PTR_OF\n#  define CHECKED_PTR_OF(type, p) \\\n    ((void*) (1 ? p : (type*)0))\n# endif\n\n/*\n * In C++ we get problems because an explicit cast is needed from (void *) we\n * use CHECKED_STACK_OF to ensure the correct type is passed in the macros\n * below.\n */\n\n# define CHECKED_STACK_OF(type, p) \\\n    ((_STACK*) (1 ? p : (STACK_OF(type)*)0))\n\n# define CHECKED_SK_COPY_FUNC(type, p) \\\n    ((void *(*)(void *)) ((1 ? p : (type *(*)(const type *))0)))\n\n# define CHECKED_SK_FREE_FUNC(type, p) \\\n    ((void (*)(void *)) ((1 ? p : (void (*)(type *))0)))\n\n# define CHECKED_SK_CMP_FUNC(type, p) \\\n    ((int (*)(const void *, const void *)) \\\n        ((1 ? p : (int (*)(const type * const *, const type * const *))0)))\n\n# define STACK_OF(type) struct stack_st_##type\n# define PREDECLARE_STACK_OF(type) STACK_OF(type);\n\n# define DECLARE_STACK_OF(type) \\\nSTACK_OF(type) \\\n    { \\\n    _STACK stack; \\\n    };\n# define DECLARE_SPECIAL_STACK_OF(type, type2) \\\nSTACK_OF(type) \\\n    { \\\n    _STACK stack; \\\n    };\n\n/* nada (obsolete in new safestack approach)*/\n# define IMPLEMENT_STACK_OF(type)\n\n/*-\n * Strings are special: normally an lhash entry will point to a single\n * (somewhat) mutable object. In the case of strings:\n *\n * a) Instead of a single char, there is an array of chars, NUL-terminated.\n * b) The string may have be immutable.\n *\n * So, they need their own declarations. Especially important for\n * type-checking tools, such as Deputy.\n *\n * In practice, however, it appears to be hard to have a const\n * string. For now, I'm settling for dealing with the fact it is a\n * string at all.\n */\ntypedef char *OPENSSL_STRING;\n\ntypedef const char *OPENSSL_CSTRING;\n\n/*\n * Confusingly, LHASH_OF(STRING) deals with char ** throughout, but\n * STACK_OF(STRING) is really more like STACK_OF(char), only, as mentioned\n * above, instead of a single char each entry is a NUL-terminated array of\n * chars. So, we have to implement STRING specially for STACK_OF. This is\n * dealt with in the autogenerated macros below.\n */\n\nDECLARE_SPECIAL_STACK_OF(OPENSSL_STRING, char)\n\n/*\n * Similarly, we sometimes use a block of characters, NOT nul-terminated.\n * These should also be distinguished from \"normal\" stacks.\n */\ntypedef void *OPENSSL_BLOCK;\nDECLARE_SPECIAL_STACK_OF(OPENSSL_BLOCK, void)\n\n/*\n * SKM_sk_... stack macros are internal to safestack.h: never use them\n * directly, use sk_<type>_... instead\n */\n# define SKM_sk_new(type, cmp) \\\n        ((STACK_OF(type) *)sk_new(CHECKED_SK_CMP_FUNC(type, cmp)))\n# define SKM_sk_new_null(type) \\\n        ((STACK_OF(type) *)sk_new_null())\n# define SKM_sk_free(type, st) \\\n        sk_free(CHECKED_STACK_OF(type, st))\n# define SKM_sk_num(type, st) \\\n        sk_num(CHECKED_STACK_OF(type, st))\n# define SKM_sk_value(type, st,i) \\\n        ((type *)sk_value(CHECKED_STACK_OF(type, st), i))\n# define SKM_sk_set(type, st,i,val) \\\n        sk_set(CHECKED_STACK_OF(type, st), i, CHECKED_PTR_OF(type, val))\n# define SKM_sk_zero(type, st) \\\n        sk_zero(CHECKED_STACK_OF(type, st))\n# define SKM_sk_push(type, st, val) \\\n        sk_push(CHECKED_STACK_OF(type, st), CHECKED_PTR_OF(type, val))\n# define SKM_sk_unshift(type, st, val) \\\n        sk_unshift(CHECKED_STACK_OF(type, st), CHECKED_PTR_OF(type, val))\n# define SKM_sk_find(type, st, val) \\\n        sk_find(CHECKED_STACK_OF(type, st), CHECKED_PTR_OF(type, val))\n# define SKM_sk_find_ex(type, st, val) \\\n        sk_find_ex(CHECKED_STACK_OF(type, st), \\\n                   CHECKED_PTR_OF(type, val))\n# define SKM_sk_delete(type, st, i) \\\n        (type *)sk_delete(CHECKED_STACK_OF(type, st), i)\n# define SKM_sk_delete_ptr(type, st, ptr) \\\n        (type *)sk_delete_ptr(CHECKED_STACK_OF(type, st), CHECKED_PTR_OF(type, ptr))\n# define SKM_sk_insert(type, st,val, i) \\\n        sk_insert(CHECKED_STACK_OF(type, st), CHECKED_PTR_OF(type, val), i)\n# define SKM_sk_set_cmp_func(type, st, cmp) \\\n        ((int (*)(const type * const *,const type * const *)) \\\n        sk_set_cmp_func(CHECKED_STACK_OF(type, st), CHECKED_SK_CMP_FUNC(type, cmp)))\n# define SKM_sk_dup(type, st) \\\n        (STACK_OF(type) *)sk_dup(CHECKED_STACK_OF(type, st))\n# define SKM_sk_pop_free(type, st, free_func) \\\n        sk_pop_free(CHECKED_STACK_OF(type, st), CHECKED_SK_FREE_FUNC(type, free_func))\n# define SKM_sk_deep_copy(type, st, copy_func, free_func) \\\n        (STACK_OF(type) *)sk_deep_copy(CHECKED_STACK_OF(type, st), CHECKED_SK_COPY_FUNC(type, copy_func), CHECKED_SK_FREE_FUNC(type, free_func))\n# define SKM_sk_shift(type, st) \\\n        (type *)sk_shift(CHECKED_STACK_OF(type, st))\n# define SKM_sk_pop(type, st) \\\n        (type *)sk_pop(CHECKED_STACK_OF(type, st))\n# define SKM_sk_sort(type, st) \\\n        sk_sort(CHECKED_STACK_OF(type, st))\n# define SKM_sk_is_sorted(type, st) \\\n        sk_is_sorted(CHECKED_STACK_OF(type, st))\n# define SKM_ASN1_SET_OF_d2i(type, st, pp, length, d2i_func, free_func, ex_tag, ex_class) \\\n  (STACK_OF(type) *)d2i_ASN1_SET( \\\n                                (STACK_OF(OPENSSL_BLOCK) **)CHECKED_PTR_OF(STACK_OF(type)*, st), \\\n                                pp, length, \\\n                                CHECKED_D2I_OF(type, d2i_func), \\\n                                CHECKED_SK_FREE_FUNC(type, free_func), \\\n                                ex_tag, ex_class)\n# define SKM_ASN1_SET_OF_i2d(type, st, pp, i2d_func, ex_tag, ex_class, is_set) \\\n  i2d_ASN1_SET((STACK_OF(OPENSSL_BLOCK) *)CHECKED_STACK_OF(type, st), pp, \\\n                                CHECKED_I2D_OF(type, i2d_func), \\\n                                ex_tag, ex_class, is_set)\n# define SKM_ASN1_seq_pack(type, st, i2d_func, buf, len) \\\n        ASN1_seq_pack(CHECKED_PTR_OF(STACK_OF(type), st), \\\n                        CHECKED_I2D_OF(type, i2d_func), buf, len)\n# define SKM_ASN1_seq_unpack(type, buf, len, d2i_func, free_func) \\\n        (STACK_OF(type) *)ASN1_seq_unpack(buf, len, CHECKED_D2I_OF(type, d2i_func), CHECKED_SK_FREE_FUNC(type, free_func))\n# define SKM_PKCS12_decrypt_d2i(type, algor, d2i_func, free_func, pass, passlen, oct, seq) \\\n        (STACK_OF(type) *)PKCS12_decrypt_d2i(algor, \\\n                                CHECKED_D2I_OF(type, d2i_func), \\\n                                CHECKED_SK_FREE_FUNC(type, free_func), \\\n                                pass, passlen, oct, seq)\n/*\n * This block of defines is updated by util/mkstack.pl, please do not touch!\n */\n# define sk_ACCESS_DESCRIPTION_new(cmp) SKM_sk_new(ACCESS_DESCRIPTION, (cmp))\n# define sk_ACCESS_DESCRIPTION_new_null() SKM_sk_new_null(ACCESS_DESCRIPTION)\n# define sk_ACCESS_DESCRIPTION_free(st) SKM_sk_free(ACCESS_DESCRIPTION, (st))\n# define sk_ACCESS_DESCRIPTION_num(st) SKM_sk_num(ACCESS_DESCRIPTION, (st))\n# define sk_ACCESS_DESCRIPTION_value(st, i) SKM_sk_value(ACCESS_DESCRIPTION, (st), (i))\n# define sk_ACCESS_DESCRIPTION_set(st, i, val) SKM_sk_set(ACCESS_DESCRIPTION, (st), (i), (val))\n# define sk_ACCESS_DESCRIPTION_zero(st) SKM_sk_zero(ACCESS_DESCRIPTION, (st))\n# define sk_ACCESS_DESCRIPTION_push(st, val) SKM_sk_push(ACCESS_DESCRIPTION, (st), (val))\n# define sk_ACCESS_DESCRIPTION_unshift(st, val) SKM_sk_unshift(ACCESS_DESCRIPTION, (st), (val))\n# define sk_ACCESS_DESCRIPTION_find(st, val) SKM_sk_find(ACCESS_DESCRIPTION, (st), (val))\n# define sk_ACCESS_DESCRIPTION_find_ex(st, val) SKM_sk_find_ex(ACCESS_DESCRIPTION, (st), (val))\n# define sk_ACCESS_DESCRIPTION_delete(st, i) SKM_sk_delete(ACCESS_DESCRIPTION, (st), (i))\n# define sk_ACCESS_DESCRIPTION_delete_ptr(st, ptr) SKM_sk_delete_ptr(ACCESS_DESCRIPTION, (st), (ptr))\n# define sk_ACCESS_DESCRIPTION_insert(st, val, i) SKM_sk_insert(ACCESS_DESCRIPTION, (st), (val), (i))\n# define sk_ACCESS_DESCRIPTION_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(ACCESS_DESCRIPTION, (st), (cmp))\n# define sk_ACCESS_DESCRIPTION_dup(st) SKM_sk_dup(ACCESS_DESCRIPTION, st)\n# define sk_ACCESS_DESCRIPTION_pop_free(st, free_func) SKM_sk_pop_free(ACCESS_DESCRIPTION, (st), (free_func))\n# define sk_ACCESS_DESCRIPTION_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(ACCESS_DESCRIPTION, (st), (copy_func), (free_func))\n# define sk_ACCESS_DESCRIPTION_shift(st) SKM_sk_shift(ACCESS_DESCRIPTION, (st))\n# define sk_ACCESS_DESCRIPTION_pop(st) SKM_sk_pop(ACCESS_DESCRIPTION, (st))\n# define sk_ACCESS_DESCRIPTION_sort(st) SKM_sk_sort(ACCESS_DESCRIPTION, (st))\n# define sk_ACCESS_DESCRIPTION_is_sorted(st) SKM_sk_is_sorted(ACCESS_DESCRIPTION, (st))\n# define sk_ASIdOrRange_new(cmp) SKM_sk_new(ASIdOrRange, (cmp))\n# define sk_ASIdOrRange_new_null() SKM_sk_new_null(ASIdOrRange)\n# define sk_ASIdOrRange_free(st) SKM_sk_free(ASIdOrRange, (st))\n# define sk_ASIdOrRange_num(st) SKM_sk_num(ASIdOrRange, (st))\n# define sk_ASIdOrRange_value(st, i) SKM_sk_value(ASIdOrRange, (st), (i))\n# define sk_ASIdOrRange_set(st, i, val) SKM_sk_set(ASIdOrRange, (st), (i), (val))\n# define sk_ASIdOrRange_zero(st) SKM_sk_zero(ASIdOrRange, (st))\n# define sk_ASIdOrRange_push(st, val) SKM_sk_push(ASIdOrRange, (st), (val))\n# define sk_ASIdOrRange_unshift(st, val) SKM_sk_unshift(ASIdOrRange, (st), (val))\n# define sk_ASIdOrRange_find(st, val) SKM_sk_find(ASIdOrRange, (st), (val))\n# define sk_ASIdOrRange_find_ex(st, val) SKM_sk_find_ex(ASIdOrRange, (st), (val))\n# define sk_ASIdOrRange_delete(st, i) SKM_sk_delete(ASIdOrRange, (st), (i))\n# define sk_ASIdOrRange_delete_ptr(st, ptr) SKM_sk_delete_ptr(ASIdOrRange, (st), (ptr))\n# define sk_ASIdOrRange_insert(st, val, i) SKM_sk_insert(ASIdOrRange, (st), (val), (i))\n# define sk_ASIdOrRange_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(ASIdOrRange, (st), (cmp))\n# define sk_ASIdOrRange_dup(st) SKM_sk_dup(ASIdOrRange, st)\n# define sk_ASIdOrRange_pop_free(st, free_func) SKM_sk_pop_free(ASIdOrRange, (st), (free_func))\n# define sk_ASIdOrRange_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(ASIdOrRange, (st), (copy_func), (free_func))\n# define sk_ASIdOrRange_shift(st) SKM_sk_shift(ASIdOrRange, (st))\n# define sk_ASIdOrRange_pop(st) SKM_sk_pop(ASIdOrRange, (st))\n# define sk_ASIdOrRange_sort(st) SKM_sk_sort(ASIdOrRange, (st))\n# define sk_ASIdOrRange_is_sorted(st) SKM_sk_is_sorted(ASIdOrRange, (st))\n# define sk_ASN1_GENERALSTRING_new(cmp) SKM_sk_new(ASN1_GENERALSTRING, (cmp))\n# define sk_ASN1_GENERALSTRING_new_null() SKM_sk_new_null(ASN1_GENERALSTRING)\n# define sk_ASN1_GENERALSTRING_free(st) SKM_sk_free(ASN1_GENERALSTRING, (st))\n# define sk_ASN1_GENERALSTRING_num(st) SKM_sk_num(ASN1_GENERALSTRING, (st))\n# define sk_ASN1_GENERALSTRING_value(st, i) SKM_sk_value(ASN1_GENERALSTRING, (st), (i))\n# define sk_ASN1_GENERALSTRING_set(st, i, val) SKM_sk_set(ASN1_GENERALSTRING, (st), (i), (val))\n# define sk_ASN1_GENERALSTRING_zero(st) SKM_sk_zero(ASN1_GENERALSTRING, (st))\n# define sk_ASN1_GENERALSTRING_push(st, val) SKM_sk_push(ASN1_GENERALSTRING, (st), (val))\n# define sk_ASN1_GENERALSTRING_unshift(st, val) SKM_sk_unshift(ASN1_GENERALSTRING, (st), (val))\n# define sk_ASN1_GENERALSTRING_find(st, val) SKM_sk_find(ASN1_GENERALSTRING, (st), (val))\n# define sk_ASN1_GENERALSTRING_find_ex(st, val) SKM_sk_find_ex(ASN1_GENERALSTRING, (st), (val))\n# define sk_ASN1_GENERALSTRING_delete(st, i) SKM_sk_delete(ASN1_GENERALSTRING, (st), (i))\n# define sk_ASN1_GENERALSTRING_delete_ptr(st, ptr) SKM_sk_delete_ptr(ASN1_GENERALSTRING, (st), (ptr))\n# define sk_ASN1_GENERALSTRING_insert(st, val, i) SKM_sk_insert(ASN1_GENERALSTRING, (st), (val), (i))\n# define sk_ASN1_GENERALSTRING_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(ASN1_GENERALSTRING, (st), (cmp))\n# define sk_ASN1_GENERALSTRING_dup(st) SKM_sk_dup(ASN1_GENERALSTRING, st)\n# define sk_ASN1_GENERALSTRING_pop_free(st, free_func) SKM_sk_pop_free(ASN1_GENERALSTRING, (st), (free_func))\n# define sk_ASN1_GENERALSTRING_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(ASN1_GENERALSTRING, (st), (copy_func), (free_func))\n# define sk_ASN1_GENERALSTRING_shift(st) SKM_sk_shift(ASN1_GENERALSTRING, (st))\n# define sk_ASN1_GENERALSTRING_pop(st) SKM_sk_pop(ASN1_GENERALSTRING, (st))\n# define sk_ASN1_GENERALSTRING_sort(st) SKM_sk_sort(ASN1_GENERALSTRING, (st))\n# define sk_ASN1_GENERALSTRING_is_sorted(st) SKM_sk_is_sorted(ASN1_GENERALSTRING, (st))\n# define sk_ASN1_INTEGER_new(cmp) SKM_sk_new(ASN1_INTEGER, (cmp))\n# define sk_ASN1_INTEGER_new_null() SKM_sk_new_null(ASN1_INTEGER)\n# define sk_ASN1_INTEGER_free(st) SKM_sk_free(ASN1_INTEGER, (st))\n# define sk_ASN1_INTEGER_num(st) SKM_sk_num(ASN1_INTEGER, (st))\n# define sk_ASN1_INTEGER_value(st, i) SKM_sk_value(ASN1_INTEGER, (st), (i))\n# define sk_ASN1_INTEGER_set(st, i, val) SKM_sk_set(ASN1_INTEGER, (st), (i), (val))\n# define sk_ASN1_INTEGER_zero(st) SKM_sk_zero(ASN1_INTEGER, (st))\n# define sk_ASN1_INTEGER_push(st, val) SKM_sk_push(ASN1_INTEGER, (st), (val))\n# define sk_ASN1_INTEGER_unshift(st, val) SKM_sk_unshift(ASN1_INTEGER, (st), (val))\n# define sk_ASN1_INTEGER_find(st, val) SKM_sk_find(ASN1_INTEGER, (st), (val))\n# define sk_ASN1_INTEGER_find_ex(st, val) SKM_sk_find_ex(ASN1_INTEGER, (st), (val))\n# define sk_ASN1_INTEGER_delete(st, i) SKM_sk_delete(ASN1_INTEGER, (st), (i))\n# define sk_ASN1_INTEGER_delete_ptr(st, ptr) SKM_sk_delete_ptr(ASN1_INTEGER, (st), (ptr))\n# define sk_ASN1_INTEGER_insert(st, val, i) SKM_sk_insert(ASN1_INTEGER, (st), (val), (i))\n# define sk_ASN1_INTEGER_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(ASN1_INTEGER, (st), (cmp))\n# define sk_ASN1_INTEGER_dup(st) SKM_sk_dup(ASN1_INTEGER, st)\n# define sk_ASN1_INTEGER_pop_free(st, free_func) SKM_sk_pop_free(ASN1_INTEGER, (st), (free_func))\n# define sk_ASN1_INTEGER_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(ASN1_INTEGER, (st), (copy_func), (free_func))\n# define sk_ASN1_INTEGER_shift(st) SKM_sk_shift(ASN1_INTEGER, (st))\n# define sk_ASN1_INTEGER_pop(st) SKM_sk_pop(ASN1_INTEGER, (st))\n# define sk_ASN1_INTEGER_sort(st) SKM_sk_sort(ASN1_INTEGER, (st))\n# define sk_ASN1_INTEGER_is_sorted(st) SKM_sk_is_sorted(ASN1_INTEGER, (st))\n# define sk_ASN1_OBJECT_new(cmp) SKM_sk_new(ASN1_OBJECT, (cmp))\n# define sk_ASN1_OBJECT_new_null() SKM_sk_new_null(ASN1_OBJECT)\n# define sk_ASN1_OBJECT_free(st) SKM_sk_free(ASN1_OBJECT, (st))\n# define sk_ASN1_OBJECT_num(st) SKM_sk_num(ASN1_OBJECT, (st))\n# define sk_ASN1_OBJECT_value(st, i) SKM_sk_value(ASN1_OBJECT, (st), (i))\n# define sk_ASN1_OBJECT_set(st, i, val) SKM_sk_set(ASN1_OBJECT, (st), (i), (val))\n# define sk_ASN1_OBJECT_zero(st) SKM_sk_zero(ASN1_OBJECT, (st))\n# define sk_ASN1_OBJECT_push(st, val) SKM_sk_push(ASN1_OBJECT, (st), (val))\n# define sk_ASN1_OBJECT_unshift(st, val) SKM_sk_unshift(ASN1_OBJECT, (st), (val))\n# define sk_ASN1_OBJECT_find(st, val) SKM_sk_find(ASN1_OBJECT, (st), (val))\n# define sk_ASN1_OBJECT_find_ex(st, val) SKM_sk_find_ex(ASN1_OBJECT, (st), (val))\n# define sk_ASN1_OBJECT_delete(st, i) SKM_sk_delete(ASN1_OBJECT, (st), (i))\n# define sk_ASN1_OBJECT_delete_ptr(st, ptr) SKM_sk_delete_ptr(ASN1_OBJECT, (st), (ptr))\n# define sk_ASN1_OBJECT_insert(st, val, i) SKM_sk_insert(ASN1_OBJECT, (st), (val), (i))\n# define sk_ASN1_OBJECT_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(ASN1_OBJECT, (st), (cmp))\n# define sk_ASN1_OBJECT_dup(st) SKM_sk_dup(ASN1_OBJECT, st)\n# define sk_ASN1_OBJECT_pop_free(st, free_func) SKM_sk_pop_free(ASN1_OBJECT, (st), (free_func))\n# define sk_ASN1_OBJECT_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(ASN1_OBJECT, (st), (copy_func), (free_func))\n# define sk_ASN1_OBJECT_shift(st) SKM_sk_shift(ASN1_OBJECT, (st))\n# define sk_ASN1_OBJECT_pop(st) SKM_sk_pop(ASN1_OBJECT, (st))\n# define sk_ASN1_OBJECT_sort(st) SKM_sk_sort(ASN1_OBJECT, (st))\n# define sk_ASN1_OBJECT_is_sorted(st) SKM_sk_is_sorted(ASN1_OBJECT, (st))\n# define sk_ASN1_STRING_TABLE_new(cmp) SKM_sk_new(ASN1_STRING_TABLE, (cmp))\n# define sk_ASN1_STRING_TABLE_new_null() SKM_sk_new_null(ASN1_STRING_TABLE)\n# define sk_ASN1_STRING_TABLE_free(st) SKM_sk_free(ASN1_STRING_TABLE, (st))\n# define sk_ASN1_STRING_TABLE_num(st) SKM_sk_num(ASN1_STRING_TABLE, (st))\n# define sk_ASN1_STRING_TABLE_value(st, i) SKM_sk_value(ASN1_STRING_TABLE, (st), (i))\n# define sk_ASN1_STRING_TABLE_set(st, i, val) SKM_sk_set(ASN1_STRING_TABLE, (st), (i), (val))\n# define sk_ASN1_STRING_TABLE_zero(st) SKM_sk_zero(ASN1_STRING_TABLE, (st))\n# define sk_ASN1_STRING_TABLE_push(st, val) SKM_sk_push(ASN1_STRING_TABLE, (st), (val))\n# define sk_ASN1_STRING_TABLE_unshift(st, val) SKM_sk_unshift(ASN1_STRING_TABLE, (st), (val))\n# define sk_ASN1_STRING_TABLE_find(st, val) SKM_sk_find(ASN1_STRING_TABLE, (st), (val))\n# define sk_ASN1_STRING_TABLE_find_ex(st, val) SKM_sk_find_ex(ASN1_STRING_TABLE, (st), (val))\n# define sk_ASN1_STRING_TABLE_delete(st, i) SKM_sk_delete(ASN1_STRING_TABLE, (st), (i))\n# define sk_ASN1_STRING_TABLE_delete_ptr(st, ptr) SKM_sk_delete_ptr(ASN1_STRING_TABLE, (st), (ptr))\n# define sk_ASN1_STRING_TABLE_insert(st, val, i) SKM_sk_insert(ASN1_STRING_TABLE, (st), (val), (i))\n# define sk_ASN1_STRING_TABLE_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(ASN1_STRING_TABLE, (st), (cmp))\n# define sk_ASN1_STRING_TABLE_dup(st) SKM_sk_dup(ASN1_STRING_TABLE, st)\n# define sk_ASN1_STRING_TABLE_pop_free(st, free_func) SKM_sk_pop_free(ASN1_STRING_TABLE, (st), (free_func))\n# define sk_ASN1_STRING_TABLE_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(ASN1_STRING_TABLE, (st), (copy_func), (free_func))\n# define sk_ASN1_STRING_TABLE_shift(st) SKM_sk_shift(ASN1_STRING_TABLE, (st))\n# define sk_ASN1_STRING_TABLE_pop(st) SKM_sk_pop(ASN1_STRING_TABLE, (st))\n# define sk_ASN1_STRING_TABLE_sort(st) SKM_sk_sort(ASN1_STRING_TABLE, (st))\n# define sk_ASN1_STRING_TABLE_is_sorted(st) SKM_sk_is_sorted(ASN1_STRING_TABLE, (st))\n# define sk_ASN1_TYPE_new(cmp) SKM_sk_new(ASN1_TYPE, (cmp))\n# define sk_ASN1_TYPE_new_null() SKM_sk_new_null(ASN1_TYPE)\n# define sk_ASN1_TYPE_free(st) SKM_sk_free(ASN1_TYPE, (st))\n# define sk_ASN1_TYPE_num(st) SKM_sk_num(ASN1_TYPE, (st))\n# define sk_ASN1_TYPE_value(st, i) SKM_sk_value(ASN1_TYPE, (st), (i))\n# define sk_ASN1_TYPE_set(st, i, val) SKM_sk_set(ASN1_TYPE, (st), (i), (val))\n# define sk_ASN1_TYPE_zero(st) SKM_sk_zero(ASN1_TYPE, (st))\n# define sk_ASN1_TYPE_push(st, val) SKM_sk_push(ASN1_TYPE, (st), (val))\n# define sk_ASN1_TYPE_unshift(st, val) SKM_sk_unshift(ASN1_TYPE, (st), (val))\n# define sk_ASN1_TYPE_find(st, val) SKM_sk_find(ASN1_TYPE, (st), (val))\n# define sk_ASN1_TYPE_find_ex(st, val) SKM_sk_find_ex(ASN1_TYPE, (st), (val))\n# define sk_ASN1_TYPE_delete(st, i) SKM_sk_delete(ASN1_TYPE, (st), (i))\n# define sk_ASN1_TYPE_delete_ptr(st, ptr) SKM_sk_delete_ptr(ASN1_TYPE, (st), (ptr))\n# define sk_ASN1_TYPE_insert(st, val, i) SKM_sk_insert(ASN1_TYPE, (st), (val), (i))\n# define sk_ASN1_TYPE_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(ASN1_TYPE, (st), (cmp))\n# define sk_ASN1_TYPE_dup(st) SKM_sk_dup(ASN1_TYPE, st)\n# define sk_ASN1_TYPE_pop_free(st, free_func) SKM_sk_pop_free(ASN1_TYPE, (st), (free_func))\n# define sk_ASN1_TYPE_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(ASN1_TYPE, (st), (copy_func), (free_func))\n# define sk_ASN1_TYPE_shift(st) SKM_sk_shift(ASN1_TYPE, (st))\n# define sk_ASN1_TYPE_pop(st) SKM_sk_pop(ASN1_TYPE, (st))\n# define sk_ASN1_TYPE_sort(st) SKM_sk_sort(ASN1_TYPE, (st))\n# define sk_ASN1_TYPE_is_sorted(st) SKM_sk_is_sorted(ASN1_TYPE, (st))\n# define sk_ASN1_UTF8STRING_new(cmp) SKM_sk_new(ASN1_UTF8STRING, (cmp))\n# define sk_ASN1_UTF8STRING_new_null() SKM_sk_new_null(ASN1_UTF8STRING)\n# define sk_ASN1_UTF8STRING_free(st) SKM_sk_free(ASN1_UTF8STRING, (st))\n# define sk_ASN1_UTF8STRING_num(st) SKM_sk_num(ASN1_UTF8STRING, (st))\n# define sk_ASN1_UTF8STRING_value(st, i) SKM_sk_value(ASN1_UTF8STRING, (st), (i))\n# define sk_ASN1_UTF8STRING_set(st, i, val) SKM_sk_set(ASN1_UTF8STRING, (st), (i), (val))\n# define sk_ASN1_UTF8STRING_zero(st) SKM_sk_zero(ASN1_UTF8STRING, (st))\n# define sk_ASN1_UTF8STRING_push(st, val) SKM_sk_push(ASN1_UTF8STRING, (st), (val))\n# define sk_ASN1_UTF8STRING_unshift(st, val) SKM_sk_unshift(ASN1_UTF8STRING, (st), (val))\n# define sk_ASN1_UTF8STRING_find(st, val) SKM_sk_find(ASN1_UTF8STRING, (st), (val))\n# define sk_ASN1_UTF8STRING_find_ex(st, val) SKM_sk_find_ex(ASN1_UTF8STRING, (st), (val))\n# define sk_ASN1_UTF8STRING_delete(st, i) SKM_sk_delete(ASN1_UTF8STRING, (st), (i))\n# define sk_ASN1_UTF8STRING_delete_ptr(st, ptr) SKM_sk_delete_ptr(ASN1_UTF8STRING, (st), (ptr))\n# define sk_ASN1_UTF8STRING_insert(st, val, i) SKM_sk_insert(ASN1_UTF8STRING, (st), (val), (i))\n# define sk_ASN1_UTF8STRING_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(ASN1_UTF8STRING, (st), (cmp))\n# define sk_ASN1_UTF8STRING_dup(st) SKM_sk_dup(ASN1_UTF8STRING, st)\n# define sk_ASN1_UTF8STRING_pop_free(st, free_func) SKM_sk_pop_free(ASN1_UTF8STRING, (st), (free_func))\n# define sk_ASN1_UTF8STRING_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(ASN1_UTF8STRING, (st), (copy_func), (free_func))\n# define sk_ASN1_UTF8STRING_shift(st) SKM_sk_shift(ASN1_UTF8STRING, (st))\n# define sk_ASN1_UTF8STRING_pop(st) SKM_sk_pop(ASN1_UTF8STRING, (st))\n# define sk_ASN1_UTF8STRING_sort(st) SKM_sk_sort(ASN1_UTF8STRING, (st))\n# define sk_ASN1_UTF8STRING_is_sorted(st) SKM_sk_is_sorted(ASN1_UTF8STRING, (st))\n# define sk_ASN1_VALUE_new(cmp) SKM_sk_new(ASN1_VALUE, (cmp))\n# define sk_ASN1_VALUE_new_null() SKM_sk_new_null(ASN1_VALUE)\n# define sk_ASN1_VALUE_free(st) SKM_sk_free(ASN1_VALUE, (st))\n# define sk_ASN1_VALUE_num(st) SKM_sk_num(ASN1_VALUE, (st))\n# define sk_ASN1_VALUE_value(st, i) SKM_sk_value(ASN1_VALUE, (st), (i))\n# define sk_ASN1_VALUE_set(st, i, val) SKM_sk_set(ASN1_VALUE, (st), (i), (val))\n# define sk_ASN1_VALUE_zero(st) SKM_sk_zero(ASN1_VALUE, (st))\n# define sk_ASN1_VALUE_push(st, val) SKM_sk_push(ASN1_VALUE, (st), (val))\n# define sk_ASN1_VALUE_unshift(st, val) SKM_sk_unshift(ASN1_VALUE, (st), (val))\n# define sk_ASN1_VALUE_find(st, val) SKM_sk_find(ASN1_VALUE, (st), (val))\n# define sk_ASN1_VALUE_find_ex(st, val) SKM_sk_find_ex(ASN1_VALUE, (st), (val))\n# define sk_ASN1_VALUE_delete(st, i) SKM_sk_delete(ASN1_VALUE, (st), (i))\n# define sk_ASN1_VALUE_delete_ptr(st, ptr) SKM_sk_delete_ptr(ASN1_VALUE, (st), (ptr))\n# define sk_ASN1_VALUE_insert(st, val, i) SKM_sk_insert(ASN1_VALUE, (st), (val), (i))\n# define sk_ASN1_VALUE_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(ASN1_VALUE, (st), (cmp))\n# define sk_ASN1_VALUE_dup(st) SKM_sk_dup(ASN1_VALUE, st)\n# define sk_ASN1_VALUE_pop_free(st, free_func) SKM_sk_pop_free(ASN1_VALUE, (st), (free_func))\n# define sk_ASN1_VALUE_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(ASN1_VALUE, (st), (copy_func), (free_func))\n# define sk_ASN1_VALUE_shift(st) SKM_sk_shift(ASN1_VALUE, (st))\n# define sk_ASN1_VALUE_pop(st) SKM_sk_pop(ASN1_VALUE, (st))\n# define sk_ASN1_VALUE_sort(st) SKM_sk_sort(ASN1_VALUE, (st))\n# define sk_ASN1_VALUE_is_sorted(st) SKM_sk_is_sorted(ASN1_VALUE, (st))\n# define sk_BIO_new(cmp) SKM_sk_new(BIO, (cmp))\n# define sk_BIO_new_null() SKM_sk_new_null(BIO)\n# define sk_BIO_free(st) SKM_sk_free(BIO, (st))\n# define sk_BIO_num(st) SKM_sk_num(BIO, (st))\n# define sk_BIO_value(st, i) SKM_sk_value(BIO, (st), (i))\n# define sk_BIO_set(st, i, val) SKM_sk_set(BIO, (st), (i), (val))\n# define sk_BIO_zero(st) SKM_sk_zero(BIO, (st))\n# define sk_BIO_push(st, val) SKM_sk_push(BIO, (st), (val))\n# define sk_BIO_unshift(st, val) SKM_sk_unshift(BIO, (st), (val))\n# define sk_BIO_find(st, val) SKM_sk_find(BIO, (st), (val))\n# define sk_BIO_find_ex(st, val) SKM_sk_find_ex(BIO, (st), (val))\n# define sk_BIO_delete(st, i) SKM_sk_delete(BIO, (st), (i))\n# define sk_BIO_delete_ptr(st, ptr) SKM_sk_delete_ptr(BIO, (st), (ptr))\n# define sk_BIO_insert(st, val, i) SKM_sk_insert(BIO, (st), (val), (i))\n# define sk_BIO_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(BIO, (st), (cmp))\n# define sk_BIO_dup(st) SKM_sk_dup(BIO, st)\n# define sk_BIO_pop_free(st, free_func) SKM_sk_pop_free(BIO, (st), (free_func))\n# define sk_BIO_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(BIO, (st), (copy_func), (free_func))\n# define sk_BIO_shift(st) SKM_sk_shift(BIO, (st))\n# define sk_BIO_pop(st) SKM_sk_pop(BIO, (st))\n# define sk_BIO_sort(st) SKM_sk_sort(BIO, (st))\n# define sk_BIO_is_sorted(st) SKM_sk_is_sorted(BIO, (st))\n# define sk_BY_DIR_ENTRY_new(cmp) SKM_sk_new(BY_DIR_ENTRY, (cmp))\n# define sk_BY_DIR_ENTRY_new_null() SKM_sk_new_null(BY_DIR_ENTRY)\n# define sk_BY_DIR_ENTRY_free(st) SKM_sk_free(BY_DIR_ENTRY, (st))\n# define sk_BY_DIR_ENTRY_num(st) SKM_sk_num(BY_DIR_ENTRY, (st))\n# define sk_BY_DIR_ENTRY_value(st, i) SKM_sk_value(BY_DIR_ENTRY, (st), (i))\n# define sk_BY_DIR_ENTRY_set(st, i, val) SKM_sk_set(BY_DIR_ENTRY, (st), (i), (val))\n# define sk_BY_DIR_ENTRY_zero(st) SKM_sk_zero(BY_DIR_ENTRY, (st))\n# define sk_BY_DIR_ENTRY_push(st, val) SKM_sk_push(BY_DIR_ENTRY, (st), (val))\n# define sk_BY_DIR_ENTRY_unshift(st, val) SKM_sk_unshift(BY_DIR_ENTRY, (st), (val))\n# define sk_BY_DIR_ENTRY_find(st, val) SKM_sk_find(BY_DIR_ENTRY, (st), (val))\n# define sk_BY_DIR_ENTRY_find_ex(st, val) SKM_sk_find_ex(BY_DIR_ENTRY, (st), (val))\n# define sk_BY_DIR_ENTRY_delete(st, i) SKM_sk_delete(BY_DIR_ENTRY, (st), (i))\n# define sk_BY_DIR_ENTRY_delete_ptr(st, ptr) SKM_sk_delete_ptr(BY_DIR_ENTRY, (st), (ptr))\n# define sk_BY_DIR_ENTRY_insert(st, val, i) SKM_sk_insert(BY_DIR_ENTRY, (st), (val), (i))\n# define sk_BY_DIR_ENTRY_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(BY_DIR_ENTRY, (st), (cmp))\n# define sk_BY_DIR_ENTRY_dup(st) SKM_sk_dup(BY_DIR_ENTRY, st)\n# define sk_BY_DIR_ENTRY_pop_free(st, free_func) SKM_sk_pop_free(BY_DIR_ENTRY, (st), (free_func))\n# define sk_BY_DIR_ENTRY_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(BY_DIR_ENTRY, (st), (copy_func), (free_func))\n# define sk_BY_DIR_ENTRY_shift(st) SKM_sk_shift(BY_DIR_ENTRY, (st))\n# define sk_BY_DIR_ENTRY_pop(st) SKM_sk_pop(BY_DIR_ENTRY, (st))\n# define sk_BY_DIR_ENTRY_sort(st) SKM_sk_sort(BY_DIR_ENTRY, (st))\n# define sk_BY_DIR_ENTRY_is_sorted(st) SKM_sk_is_sorted(BY_DIR_ENTRY, (st))\n# define sk_BY_DIR_HASH_new(cmp) SKM_sk_new(BY_DIR_HASH, (cmp))\n# define sk_BY_DIR_HASH_new_null() SKM_sk_new_null(BY_DIR_HASH)\n# define sk_BY_DIR_HASH_free(st) SKM_sk_free(BY_DIR_HASH, (st))\n# define sk_BY_DIR_HASH_num(st) SKM_sk_num(BY_DIR_HASH, (st))\n# define sk_BY_DIR_HASH_value(st, i) SKM_sk_value(BY_DIR_HASH, (st), (i))\n# define sk_BY_DIR_HASH_set(st, i, val) SKM_sk_set(BY_DIR_HASH, (st), (i), (val))\n# define sk_BY_DIR_HASH_zero(st) SKM_sk_zero(BY_DIR_HASH, (st))\n# define sk_BY_DIR_HASH_push(st, val) SKM_sk_push(BY_DIR_HASH, (st), (val))\n# define sk_BY_DIR_HASH_unshift(st, val) SKM_sk_unshift(BY_DIR_HASH, (st), (val))\n# define sk_BY_DIR_HASH_find(st, val) SKM_sk_find(BY_DIR_HASH, (st), (val))\n# define sk_BY_DIR_HASH_find_ex(st, val) SKM_sk_find_ex(BY_DIR_HASH, (st), (val))\n# define sk_BY_DIR_HASH_delete(st, i) SKM_sk_delete(BY_DIR_HASH, (st), (i))\n# define sk_BY_DIR_HASH_delete_ptr(st, ptr) SKM_sk_delete_ptr(BY_DIR_HASH, (st), (ptr))\n# define sk_BY_DIR_HASH_insert(st, val, i) SKM_sk_insert(BY_DIR_HASH, (st), (val), (i))\n# define sk_BY_DIR_HASH_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(BY_DIR_HASH, (st), (cmp))\n# define sk_BY_DIR_HASH_dup(st) SKM_sk_dup(BY_DIR_HASH, st)\n# define sk_BY_DIR_HASH_pop_free(st, free_func) SKM_sk_pop_free(BY_DIR_HASH, (st), (free_func))\n# define sk_BY_DIR_HASH_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(BY_DIR_HASH, (st), (copy_func), (free_func))\n# define sk_BY_DIR_HASH_shift(st) SKM_sk_shift(BY_DIR_HASH, (st))\n# define sk_BY_DIR_HASH_pop(st) SKM_sk_pop(BY_DIR_HASH, (st))\n# define sk_BY_DIR_HASH_sort(st) SKM_sk_sort(BY_DIR_HASH, (st))\n# define sk_BY_DIR_HASH_is_sorted(st) SKM_sk_is_sorted(BY_DIR_HASH, (st))\n# define sk_CMS_CertificateChoices_new(cmp) SKM_sk_new(CMS_CertificateChoices, (cmp))\n# define sk_CMS_CertificateChoices_new_null() SKM_sk_new_null(CMS_CertificateChoices)\n# define sk_CMS_CertificateChoices_free(st) SKM_sk_free(CMS_CertificateChoices, (st))\n# define sk_CMS_CertificateChoices_num(st) SKM_sk_num(CMS_CertificateChoices, (st))\n# define sk_CMS_CertificateChoices_value(st, i) SKM_sk_value(CMS_CertificateChoices, (st), (i))\n# define sk_CMS_CertificateChoices_set(st, i, val) SKM_sk_set(CMS_CertificateChoices, (st), (i), (val))\n# define sk_CMS_CertificateChoices_zero(st) SKM_sk_zero(CMS_CertificateChoices, (st))\n# define sk_CMS_CertificateChoices_push(st, val) SKM_sk_push(CMS_CertificateChoices, (st), (val))\n# define sk_CMS_CertificateChoices_unshift(st, val) SKM_sk_unshift(CMS_CertificateChoices, (st), (val))\n# define sk_CMS_CertificateChoices_find(st, val) SKM_sk_find(CMS_CertificateChoices, (st), (val))\n# define sk_CMS_CertificateChoices_find_ex(st, val) SKM_sk_find_ex(CMS_CertificateChoices, (st), (val))\n# define sk_CMS_CertificateChoices_delete(st, i) SKM_sk_delete(CMS_CertificateChoices, (st), (i))\n# define sk_CMS_CertificateChoices_delete_ptr(st, ptr) SKM_sk_delete_ptr(CMS_CertificateChoices, (st), (ptr))\n# define sk_CMS_CertificateChoices_insert(st, val, i) SKM_sk_insert(CMS_CertificateChoices, (st), (val), (i))\n# define sk_CMS_CertificateChoices_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(CMS_CertificateChoices, (st), (cmp))\n# define sk_CMS_CertificateChoices_dup(st) SKM_sk_dup(CMS_CertificateChoices, st)\n# define sk_CMS_CertificateChoices_pop_free(st, free_func) SKM_sk_pop_free(CMS_CertificateChoices, (st), (free_func))\n# define sk_CMS_CertificateChoices_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(CMS_CertificateChoices, (st), (copy_func), (free_func))\n# define sk_CMS_CertificateChoices_shift(st) SKM_sk_shift(CMS_CertificateChoices, (st))\n# define sk_CMS_CertificateChoices_pop(st) SKM_sk_pop(CMS_CertificateChoices, (st))\n# define sk_CMS_CertificateChoices_sort(st) SKM_sk_sort(CMS_CertificateChoices, (st))\n# define sk_CMS_CertificateChoices_is_sorted(st) SKM_sk_is_sorted(CMS_CertificateChoices, (st))\n# define sk_CMS_RecipientEncryptedKey_new(cmp) SKM_sk_new(CMS_RecipientEncryptedKey, (cmp))\n# define sk_CMS_RecipientEncryptedKey_new_null() SKM_sk_new_null(CMS_RecipientEncryptedKey)\n# define sk_CMS_RecipientEncryptedKey_free(st) SKM_sk_free(CMS_RecipientEncryptedKey, (st))\n# define sk_CMS_RecipientEncryptedKey_num(st) SKM_sk_num(CMS_RecipientEncryptedKey, (st))\n# define sk_CMS_RecipientEncryptedKey_value(st, i) SKM_sk_value(CMS_RecipientEncryptedKey, (st), (i))\n# define sk_CMS_RecipientEncryptedKey_set(st, i, val) SKM_sk_set(CMS_RecipientEncryptedKey, (st), (i), (val))\n# define sk_CMS_RecipientEncryptedKey_zero(st) SKM_sk_zero(CMS_RecipientEncryptedKey, (st))\n# define sk_CMS_RecipientEncryptedKey_push(st, val) SKM_sk_push(CMS_RecipientEncryptedKey, (st), (val))\n# define sk_CMS_RecipientEncryptedKey_unshift(st, val) SKM_sk_unshift(CMS_RecipientEncryptedKey, (st), (val))\n# define sk_CMS_RecipientEncryptedKey_find(st, val) SKM_sk_find(CMS_RecipientEncryptedKey, (st), (val))\n# define sk_CMS_RecipientEncryptedKey_find_ex(st, val) SKM_sk_find_ex(CMS_RecipientEncryptedKey, (st), (val))\n# define sk_CMS_RecipientEncryptedKey_delete(st, i) SKM_sk_delete(CMS_RecipientEncryptedKey, (st), (i))\n# define sk_CMS_RecipientEncryptedKey_delete_ptr(st, ptr) SKM_sk_delete_ptr(CMS_RecipientEncryptedKey, (st), (ptr))\n# define sk_CMS_RecipientEncryptedKey_insert(st, val, i) SKM_sk_insert(CMS_RecipientEncryptedKey, (st), (val), (i))\n# define sk_CMS_RecipientEncryptedKey_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(CMS_RecipientEncryptedKey, (st), (cmp))\n# define sk_CMS_RecipientEncryptedKey_dup(st) SKM_sk_dup(CMS_RecipientEncryptedKey, st)\n# define sk_CMS_RecipientEncryptedKey_pop_free(st, free_func) SKM_sk_pop_free(CMS_RecipientEncryptedKey, (st), (free_func))\n# define sk_CMS_RecipientEncryptedKey_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(CMS_RecipientEncryptedKey, (st), (copy_func), (free_func))\n# define sk_CMS_RecipientEncryptedKey_shift(st) SKM_sk_shift(CMS_RecipientEncryptedKey, (st))\n# define sk_CMS_RecipientEncryptedKey_pop(st) SKM_sk_pop(CMS_RecipientEncryptedKey, (st))\n# define sk_CMS_RecipientEncryptedKey_sort(st) SKM_sk_sort(CMS_RecipientEncryptedKey, (st))\n# define sk_CMS_RecipientEncryptedKey_is_sorted(st) SKM_sk_is_sorted(CMS_RecipientEncryptedKey, (st))\n# define sk_CMS_RecipientInfo_new(cmp) SKM_sk_new(CMS_RecipientInfo, (cmp))\n# define sk_CMS_RecipientInfo_new_null() SKM_sk_new_null(CMS_RecipientInfo)\n# define sk_CMS_RecipientInfo_free(st) SKM_sk_free(CMS_RecipientInfo, (st))\n# define sk_CMS_RecipientInfo_num(st) SKM_sk_num(CMS_RecipientInfo, (st))\n# define sk_CMS_RecipientInfo_value(st, i) SKM_sk_value(CMS_RecipientInfo, (st), (i))\n# define sk_CMS_RecipientInfo_set(st, i, val) SKM_sk_set(CMS_RecipientInfo, (st), (i), (val))\n# define sk_CMS_RecipientInfo_zero(st) SKM_sk_zero(CMS_RecipientInfo, (st))\n# define sk_CMS_RecipientInfo_push(st, val) SKM_sk_push(CMS_RecipientInfo, (st), (val))\n# define sk_CMS_RecipientInfo_unshift(st, val) SKM_sk_unshift(CMS_RecipientInfo, (st), (val))\n# define sk_CMS_RecipientInfo_find(st, val) SKM_sk_find(CMS_RecipientInfo, (st), (val))\n# define sk_CMS_RecipientInfo_find_ex(st, val) SKM_sk_find_ex(CMS_RecipientInfo, (st), (val))\n# define sk_CMS_RecipientInfo_delete(st, i) SKM_sk_delete(CMS_RecipientInfo, (st), (i))\n# define sk_CMS_RecipientInfo_delete_ptr(st, ptr) SKM_sk_delete_ptr(CMS_RecipientInfo, (st), (ptr))\n# define sk_CMS_RecipientInfo_insert(st, val, i) SKM_sk_insert(CMS_RecipientInfo, (st), (val), (i))\n# define sk_CMS_RecipientInfo_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(CMS_RecipientInfo, (st), (cmp))\n# define sk_CMS_RecipientInfo_dup(st) SKM_sk_dup(CMS_RecipientInfo, st)\n# define sk_CMS_RecipientInfo_pop_free(st, free_func) SKM_sk_pop_free(CMS_RecipientInfo, (st), (free_func))\n# define sk_CMS_RecipientInfo_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(CMS_RecipientInfo, (st), (copy_func), (free_func))\n# define sk_CMS_RecipientInfo_shift(st) SKM_sk_shift(CMS_RecipientInfo, (st))\n# define sk_CMS_RecipientInfo_pop(st) SKM_sk_pop(CMS_RecipientInfo, (st))\n# define sk_CMS_RecipientInfo_sort(st) SKM_sk_sort(CMS_RecipientInfo, (st))\n# define sk_CMS_RecipientInfo_is_sorted(st) SKM_sk_is_sorted(CMS_RecipientInfo, (st))\n# define sk_CMS_RevocationInfoChoice_new(cmp) SKM_sk_new(CMS_RevocationInfoChoice, (cmp))\n# define sk_CMS_RevocationInfoChoice_new_null() SKM_sk_new_null(CMS_RevocationInfoChoice)\n# define sk_CMS_RevocationInfoChoice_free(st) SKM_sk_free(CMS_RevocationInfoChoice, (st))\n# define sk_CMS_RevocationInfoChoice_num(st) SKM_sk_num(CMS_RevocationInfoChoice, (st))\n# define sk_CMS_RevocationInfoChoice_value(st, i) SKM_sk_value(CMS_RevocationInfoChoice, (st), (i))\n# define sk_CMS_RevocationInfoChoice_set(st, i, val) SKM_sk_set(CMS_RevocationInfoChoice, (st), (i), (val))\n# define sk_CMS_RevocationInfoChoice_zero(st) SKM_sk_zero(CMS_RevocationInfoChoice, (st))\n# define sk_CMS_RevocationInfoChoice_push(st, val) SKM_sk_push(CMS_RevocationInfoChoice, (st), (val))\n# define sk_CMS_RevocationInfoChoice_unshift(st, val) SKM_sk_unshift(CMS_RevocationInfoChoice, (st), (val))\n# define sk_CMS_RevocationInfoChoice_find(st, val) SKM_sk_find(CMS_RevocationInfoChoice, (st), (val))\n# define sk_CMS_RevocationInfoChoice_find_ex(st, val) SKM_sk_find_ex(CMS_RevocationInfoChoice, (st), (val))\n# define sk_CMS_RevocationInfoChoice_delete(st, i) SKM_sk_delete(CMS_RevocationInfoChoice, (st), (i))\n# define sk_CMS_RevocationInfoChoice_delete_ptr(st, ptr) SKM_sk_delete_ptr(CMS_RevocationInfoChoice, (st), (ptr))\n# define sk_CMS_RevocationInfoChoice_insert(st, val, i) SKM_sk_insert(CMS_RevocationInfoChoice, (st), (val), (i))\n# define sk_CMS_RevocationInfoChoice_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(CMS_RevocationInfoChoice, (st), (cmp))\n# define sk_CMS_RevocationInfoChoice_dup(st) SKM_sk_dup(CMS_RevocationInfoChoice, st)\n# define sk_CMS_RevocationInfoChoice_pop_free(st, free_func) SKM_sk_pop_free(CMS_RevocationInfoChoice, (st), (free_func))\n# define sk_CMS_RevocationInfoChoice_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(CMS_RevocationInfoChoice, (st), (copy_func), (free_func))\n# define sk_CMS_RevocationInfoChoice_shift(st) SKM_sk_shift(CMS_RevocationInfoChoice, (st))\n# define sk_CMS_RevocationInfoChoice_pop(st) SKM_sk_pop(CMS_RevocationInfoChoice, (st))\n# define sk_CMS_RevocationInfoChoice_sort(st) SKM_sk_sort(CMS_RevocationInfoChoice, (st))\n# define sk_CMS_RevocationInfoChoice_is_sorted(st) SKM_sk_is_sorted(CMS_RevocationInfoChoice, (st))\n# define sk_CMS_SignerInfo_new(cmp) SKM_sk_new(CMS_SignerInfo, (cmp))\n# define sk_CMS_SignerInfo_new_null() SKM_sk_new_null(CMS_SignerInfo)\n# define sk_CMS_SignerInfo_free(st) SKM_sk_free(CMS_SignerInfo, (st))\n# define sk_CMS_SignerInfo_num(st) SKM_sk_num(CMS_SignerInfo, (st))\n# define sk_CMS_SignerInfo_value(st, i) SKM_sk_value(CMS_SignerInfo, (st), (i))\n# define sk_CMS_SignerInfo_set(st, i, val) SKM_sk_set(CMS_SignerInfo, (st), (i), (val))\n# define sk_CMS_SignerInfo_zero(st) SKM_sk_zero(CMS_SignerInfo, (st))\n# define sk_CMS_SignerInfo_push(st, val) SKM_sk_push(CMS_SignerInfo, (st), (val))\n# define sk_CMS_SignerInfo_unshift(st, val) SKM_sk_unshift(CMS_SignerInfo, (st), (val))\n# define sk_CMS_SignerInfo_find(st, val) SKM_sk_find(CMS_SignerInfo, (st), (val))\n# define sk_CMS_SignerInfo_find_ex(st, val) SKM_sk_find_ex(CMS_SignerInfo, (st), (val))\n# define sk_CMS_SignerInfo_delete(st, i) SKM_sk_delete(CMS_SignerInfo, (st), (i))\n# define sk_CMS_SignerInfo_delete_ptr(st, ptr) SKM_sk_delete_ptr(CMS_SignerInfo, (st), (ptr))\n# define sk_CMS_SignerInfo_insert(st, val, i) SKM_sk_insert(CMS_SignerInfo, (st), (val), (i))\n# define sk_CMS_SignerInfo_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(CMS_SignerInfo, (st), (cmp))\n# define sk_CMS_SignerInfo_dup(st) SKM_sk_dup(CMS_SignerInfo, st)\n# define sk_CMS_SignerInfo_pop_free(st, free_func) SKM_sk_pop_free(CMS_SignerInfo, (st), (free_func))\n# define sk_CMS_SignerInfo_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(CMS_SignerInfo, (st), (copy_func), (free_func))\n# define sk_CMS_SignerInfo_shift(st) SKM_sk_shift(CMS_SignerInfo, (st))\n# define sk_CMS_SignerInfo_pop(st) SKM_sk_pop(CMS_SignerInfo, (st))\n# define sk_CMS_SignerInfo_sort(st) SKM_sk_sort(CMS_SignerInfo, (st))\n# define sk_CMS_SignerInfo_is_sorted(st) SKM_sk_is_sorted(CMS_SignerInfo, (st))\n# define sk_CONF_IMODULE_new(cmp) SKM_sk_new(CONF_IMODULE, (cmp))\n# define sk_CONF_IMODULE_new_null() SKM_sk_new_null(CONF_IMODULE)\n# define sk_CONF_IMODULE_free(st) SKM_sk_free(CONF_IMODULE, (st))\n# define sk_CONF_IMODULE_num(st) SKM_sk_num(CONF_IMODULE, (st))\n# define sk_CONF_IMODULE_value(st, i) SKM_sk_value(CONF_IMODULE, (st), (i))\n# define sk_CONF_IMODULE_set(st, i, val) SKM_sk_set(CONF_IMODULE, (st), (i), (val))\n# define sk_CONF_IMODULE_zero(st) SKM_sk_zero(CONF_IMODULE, (st))\n# define sk_CONF_IMODULE_push(st, val) SKM_sk_push(CONF_IMODULE, (st), (val))\n# define sk_CONF_IMODULE_unshift(st, val) SKM_sk_unshift(CONF_IMODULE, (st), (val))\n# define sk_CONF_IMODULE_find(st, val) SKM_sk_find(CONF_IMODULE, (st), (val))\n# define sk_CONF_IMODULE_find_ex(st, val) SKM_sk_find_ex(CONF_IMODULE, (st), (val))\n# define sk_CONF_IMODULE_delete(st, i) SKM_sk_delete(CONF_IMODULE, (st), (i))\n# define sk_CONF_IMODULE_delete_ptr(st, ptr) SKM_sk_delete_ptr(CONF_IMODULE, (st), (ptr))\n# define sk_CONF_IMODULE_insert(st, val, i) SKM_sk_insert(CONF_IMODULE, (st), (val), (i))\n# define sk_CONF_IMODULE_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(CONF_IMODULE, (st), (cmp))\n# define sk_CONF_IMODULE_dup(st) SKM_sk_dup(CONF_IMODULE, st)\n# define sk_CONF_IMODULE_pop_free(st, free_func) SKM_sk_pop_free(CONF_IMODULE, (st), (free_func))\n# define sk_CONF_IMODULE_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(CONF_IMODULE, (st), (copy_func), (free_func))\n# define sk_CONF_IMODULE_shift(st) SKM_sk_shift(CONF_IMODULE, (st))\n# define sk_CONF_IMODULE_pop(st) SKM_sk_pop(CONF_IMODULE, (st))\n# define sk_CONF_IMODULE_sort(st) SKM_sk_sort(CONF_IMODULE, (st))\n# define sk_CONF_IMODULE_is_sorted(st) SKM_sk_is_sorted(CONF_IMODULE, (st))\n# define sk_CONF_MODULE_new(cmp) SKM_sk_new(CONF_MODULE, (cmp))\n# define sk_CONF_MODULE_new_null() SKM_sk_new_null(CONF_MODULE)\n# define sk_CONF_MODULE_free(st) SKM_sk_free(CONF_MODULE, (st))\n# define sk_CONF_MODULE_num(st) SKM_sk_num(CONF_MODULE, (st))\n# define sk_CONF_MODULE_value(st, i) SKM_sk_value(CONF_MODULE, (st), (i))\n# define sk_CONF_MODULE_set(st, i, val) SKM_sk_set(CONF_MODULE, (st), (i), (val))\n# define sk_CONF_MODULE_zero(st) SKM_sk_zero(CONF_MODULE, (st))\n# define sk_CONF_MODULE_push(st, val) SKM_sk_push(CONF_MODULE, (st), (val))\n# define sk_CONF_MODULE_unshift(st, val) SKM_sk_unshift(CONF_MODULE, (st), (val))\n# define sk_CONF_MODULE_find(st, val) SKM_sk_find(CONF_MODULE, (st), (val))\n# define sk_CONF_MODULE_find_ex(st, val) SKM_sk_find_ex(CONF_MODULE, (st), (val))\n# define sk_CONF_MODULE_delete(st, i) SKM_sk_delete(CONF_MODULE, (st), (i))\n# define sk_CONF_MODULE_delete_ptr(st, ptr) SKM_sk_delete_ptr(CONF_MODULE, (st), (ptr))\n# define sk_CONF_MODULE_insert(st, val, i) SKM_sk_insert(CONF_MODULE, (st), (val), (i))\n# define sk_CONF_MODULE_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(CONF_MODULE, (st), (cmp))\n# define sk_CONF_MODULE_dup(st) SKM_sk_dup(CONF_MODULE, st)\n# define sk_CONF_MODULE_pop_free(st, free_func) SKM_sk_pop_free(CONF_MODULE, (st), (free_func))\n# define sk_CONF_MODULE_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(CONF_MODULE, (st), (copy_func), (free_func))\n# define sk_CONF_MODULE_shift(st) SKM_sk_shift(CONF_MODULE, (st))\n# define sk_CONF_MODULE_pop(st) SKM_sk_pop(CONF_MODULE, (st))\n# define sk_CONF_MODULE_sort(st) SKM_sk_sort(CONF_MODULE, (st))\n# define sk_CONF_MODULE_is_sorted(st) SKM_sk_is_sorted(CONF_MODULE, (st))\n# define sk_CONF_VALUE_new(cmp) SKM_sk_new(CONF_VALUE, (cmp))\n# define sk_CONF_VALUE_new_null() SKM_sk_new_null(CONF_VALUE)\n# define sk_CONF_VALUE_free(st) SKM_sk_free(CONF_VALUE, (st))\n# define sk_CONF_VALUE_num(st) SKM_sk_num(CONF_VALUE, (st))\n# define sk_CONF_VALUE_value(st, i) SKM_sk_value(CONF_VALUE, (st), (i))\n# define sk_CONF_VALUE_set(st, i, val) SKM_sk_set(CONF_VALUE, (st), (i), (val))\n# define sk_CONF_VALUE_zero(st) SKM_sk_zero(CONF_VALUE, (st))\n# define sk_CONF_VALUE_push(st, val) SKM_sk_push(CONF_VALUE, (st), (val))\n# define sk_CONF_VALUE_unshift(st, val) SKM_sk_unshift(CONF_VALUE, (st), (val))\n# define sk_CONF_VALUE_find(st, val) SKM_sk_find(CONF_VALUE, (st), (val))\n# define sk_CONF_VALUE_find_ex(st, val) SKM_sk_find_ex(CONF_VALUE, (st), (val))\n# define sk_CONF_VALUE_delete(st, i) SKM_sk_delete(CONF_VALUE, (st), (i))\n# define sk_CONF_VALUE_delete_ptr(st, ptr) SKM_sk_delete_ptr(CONF_VALUE, (st), (ptr))\n# define sk_CONF_VALUE_insert(st, val, i) SKM_sk_insert(CONF_VALUE, (st), (val), (i))\n# define sk_CONF_VALUE_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(CONF_VALUE, (st), (cmp))\n# define sk_CONF_VALUE_dup(st) SKM_sk_dup(CONF_VALUE, st)\n# define sk_CONF_VALUE_pop_free(st, free_func) SKM_sk_pop_free(CONF_VALUE, (st), (free_func))\n# define sk_CONF_VALUE_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(CONF_VALUE, (st), (copy_func), (free_func))\n# define sk_CONF_VALUE_shift(st) SKM_sk_shift(CONF_VALUE, (st))\n# define sk_CONF_VALUE_pop(st) SKM_sk_pop(CONF_VALUE, (st))\n# define sk_CONF_VALUE_sort(st) SKM_sk_sort(CONF_VALUE, (st))\n# define sk_CONF_VALUE_is_sorted(st) SKM_sk_is_sorted(CONF_VALUE, (st))\n# define sk_CRYPTO_EX_DATA_FUNCS_new(cmp) SKM_sk_new(CRYPTO_EX_DATA_FUNCS, (cmp))\n# define sk_CRYPTO_EX_DATA_FUNCS_new_null() SKM_sk_new_null(CRYPTO_EX_DATA_FUNCS)\n# define sk_CRYPTO_EX_DATA_FUNCS_free(st) SKM_sk_free(CRYPTO_EX_DATA_FUNCS, (st))\n# define sk_CRYPTO_EX_DATA_FUNCS_num(st) SKM_sk_num(CRYPTO_EX_DATA_FUNCS, (st))\n# define sk_CRYPTO_EX_DATA_FUNCS_value(st, i) SKM_sk_value(CRYPTO_EX_DATA_FUNCS, (st), (i))\n# define sk_CRYPTO_EX_DATA_FUNCS_set(st, i, val) SKM_sk_set(CRYPTO_EX_DATA_FUNCS, (st), (i), (val))\n# define sk_CRYPTO_EX_DATA_FUNCS_zero(st) SKM_sk_zero(CRYPTO_EX_DATA_FUNCS, (st))\n# define sk_CRYPTO_EX_DATA_FUNCS_push(st, val) SKM_sk_push(CRYPTO_EX_DATA_FUNCS, (st), (val))\n# define sk_CRYPTO_EX_DATA_FUNCS_unshift(st, val) SKM_sk_unshift(CRYPTO_EX_DATA_FUNCS, (st), (val))\n# define sk_CRYPTO_EX_DATA_FUNCS_find(st, val) SKM_sk_find(CRYPTO_EX_DATA_FUNCS, (st), (val))\n# define sk_CRYPTO_EX_DATA_FUNCS_find_ex(st, val) SKM_sk_find_ex(CRYPTO_EX_DATA_FUNCS, (st), (val))\n# define sk_CRYPTO_EX_DATA_FUNCS_delete(st, i) SKM_sk_delete(CRYPTO_EX_DATA_FUNCS, (st), (i))\n# define sk_CRYPTO_EX_DATA_FUNCS_delete_ptr(st, ptr) SKM_sk_delete_ptr(CRYPTO_EX_DATA_FUNCS, (st), (ptr))\n# define sk_CRYPTO_EX_DATA_FUNCS_insert(st, val, i) SKM_sk_insert(CRYPTO_EX_DATA_FUNCS, (st), (val), (i))\n# define sk_CRYPTO_EX_DATA_FUNCS_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(CRYPTO_EX_DATA_FUNCS, (st), (cmp))\n# define sk_CRYPTO_EX_DATA_FUNCS_dup(st) SKM_sk_dup(CRYPTO_EX_DATA_FUNCS, st)\n# define sk_CRYPTO_EX_DATA_FUNCS_pop_free(st, free_func) SKM_sk_pop_free(CRYPTO_EX_DATA_FUNCS, (st), (free_func))\n# define sk_CRYPTO_EX_DATA_FUNCS_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(CRYPTO_EX_DATA_FUNCS, (st), (copy_func), (free_func))\n# define sk_CRYPTO_EX_DATA_FUNCS_shift(st) SKM_sk_shift(CRYPTO_EX_DATA_FUNCS, (st))\n# define sk_CRYPTO_EX_DATA_FUNCS_pop(st) SKM_sk_pop(CRYPTO_EX_DATA_FUNCS, (st))\n# define sk_CRYPTO_EX_DATA_FUNCS_sort(st) SKM_sk_sort(CRYPTO_EX_DATA_FUNCS, (st))\n# define sk_CRYPTO_EX_DATA_FUNCS_is_sorted(st) SKM_sk_is_sorted(CRYPTO_EX_DATA_FUNCS, (st))\n# define sk_CRYPTO_dynlock_new(cmp) SKM_sk_new(CRYPTO_dynlock, (cmp))\n# define sk_CRYPTO_dynlock_new_null() SKM_sk_new_null(CRYPTO_dynlock)\n# define sk_CRYPTO_dynlock_free(st) SKM_sk_free(CRYPTO_dynlock, (st))\n# define sk_CRYPTO_dynlock_num(st) SKM_sk_num(CRYPTO_dynlock, (st))\n# define sk_CRYPTO_dynlock_value(st, i) SKM_sk_value(CRYPTO_dynlock, (st), (i))\n# define sk_CRYPTO_dynlock_set(st, i, val) SKM_sk_set(CRYPTO_dynlock, (st), (i), (val))\n# define sk_CRYPTO_dynlock_zero(st) SKM_sk_zero(CRYPTO_dynlock, (st))\n# define sk_CRYPTO_dynlock_push(st, val) SKM_sk_push(CRYPTO_dynlock, (st), (val))\n# define sk_CRYPTO_dynlock_unshift(st, val) SKM_sk_unshift(CRYPTO_dynlock, (st), (val))\n# define sk_CRYPTO_dynlock_find(st, val) SKM_sk_find(CRYPTO_dynlock, (st), (val))\n# define sk_CRYPTO_dynlock_find_ex(st, val) SKM_sk_find_ex(CRYPTO_dynlock, (st), (val))\n# define sk_CRYPTO_dynlock_delete(st, i) SKM_sk_delete(CRYPTO_dynlock, (st), (i))\n# define sk_CRYPTO_dynlock_delete_ptr(st, ptr) SKM_sk_delete_ptr(CRYPTO_dynlock, (st), (ptr))\n# define sk_CRYPTO_dynlock_insert(st, val, i) SKM_sk_insert(CRYPTO_dynlock, (st), (val), (i))\n# define sk_CRYPTO_dynlock_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(CRYPTO_dynlock, (st), (cmp))\n# define sk_CRYPTO_dynlock_dup(st) SKM_sk_dup(CRYPTO_dynlock, st)\n# define sk_CRYPTO_dynlock_pop_free(st, free_func) SKM_sk_pop_free(CRYPTO_dynlock, (st), (free_func))\n# define sk_CRYPTO_dynlock_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(CRYPTO_dynlock, (st), (copy_func), (free_func))\n# define sk_CRYPTO_dynlock_shift(st) SKM_sk_shift(CRYPTO_dynlock, (st))\n# define sk_CRYPTO_dynlock_pop(st) SKM_sk_pop(CRYPTO_dynlock, (st))\n# define sk_CRYPTO_dynlock_sort(st) SKM_sk_sort(CRYPTO_dynlock, (st))\n# define sk_CRYPTO_dynlock_is_sorted(st) SKM_sk_is_sorted(CRYPTO_dynlock, (st))\n# define sk_DIST_POINT_new(cmp) SKM_sk_new(DIST_POINT, (cmp))\n# define sk_DIST_POINT_new_null() SKM_sk_new_null(DIST_POINT)\n# define sk_DIST_POINT_free(st) SKM_sk_free(DIST_POINT, (st))\n# define sk_DIST_POINT_num(st) SKM_sk_num(DIST_POINT, (st))\n# define sk_DIST_POINT_value(st, i) SKM_sk_value(DIST_POINT, (st), (i))\n# define sk_DIST_POINT_set(st, i, val) SKM_sk_set(DIST_POINT, (st), (i), (val))\n# define sk_DIST_POINT_zero(st) SKM_sk_zero(DIST_POINT, (st))\n# define sk_DIST_POINT_push(st, val) SKM_sk_push(DIST_POINT, (st), (val))\n# define sk_DIST_POINT_unshift(st, val) SKM_sk_unshift(DIST_POINT, (st), (val))\n# define sk_DIST_POINT_find(st, val) SKM_sk_find(DIST_POINT, (st), (val))\n# define sk_DIST_POINT_find_ex(st, val) SKM_sk_find_ex(DIST_POINT, (st), (val))\n# define sk_DIST_POINT_delete(st, i) SKM_sk_delete(DIST_POINT, (st), (i))\n# define sk_DIST_POINT_delete_ptr(st, ptr) SKM_sk_delete_ptr(DIST_POINT, (st), (ptr))\n# define sk_DIST_POINT_insert(st, val, i) SKM_sk_insert(DIST_POINT, (st), (val), (i))\n# define sk_DIST_POINT_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(DIST_POINT, (st), (cmp))\n# define sk_DIST_POINT_dup(st) SKM_sk_dup(DIST_POINT, st)\n# define sk_DIST_POINT_pop_free(st, free_func) SKM_sk_pop_free(DIST_POINT, (st), (free_func))\n# define sk_DIST_POINT_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(DIST_POINT, (st), (copy_func), (free_func))\n# define sk_DIST_POINT_shift(st) SKM_sk_shift(DIST_POINT, (st))\n# define sk_DIST_POINT_pop(st) SKM_sk_pop(DIST_POINT, (st))\n# define sk_DIST_POINT_sort(st) SKM_sk_sort(DIST_POINT, (st))\n# define sk_DIST_POINT_is_sorted(st) SKM_sk_is_sorted(DIST_POINT, (st))\n# define sk_ENGINE_new(cmp) SKM_sk_new(ENGINE, (cmp))\n# define sk_ENGINE_new_null() SKM_sk_new_null(ENGINE)\n# define sk_ENGINE_free(st) SKM_sk_free(ENGINE, (st))\n# define sk_ENGINE_num(st) SKM_sk_num(ENGINE, (st))\n# define sk_ENGINE_value(st, i) SKM_sk_value(ENGINE, (st), (i))\n# define sk_ENGINE_set(st, i, val) SKM_sk_set(ENGINE, (st), (i), (val))\n# define sk_ENGINE_zero(st) SKM_sk_zero(ENGINE, (st))\n# define sk_ENGINE_push(st, val) SKM_sk_push(ENGINE, (st), (val))\n# define sk_ENGINE_unshift(st, val) SKM_sk_unshift(ENGINE, (st), (val))\n# define sk_ENGINE_find(st, val) SKM_sk_find(ENGINE, (st), (val))\n# define sk_ENGINE_find_ex(st, val) SKM_sk_find_ex(ENGINE, (st), (val))\n# define sk_ENGINE_delete(st, i) SKM_sk_delete(ENGINE, (st), (i))\n# define sk_ENGINE_delete_ptr(st, ptr) SKM_sk_delete_ptr(ENGINE, (st), (ptr))\n# define sk_ENGINE_insert(st, val, i) SKM_sk_insert(ENGINE, (st), (val), (i))\n# define sk_ENGINE_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(ENGINE, (st), (cmp))\n# define sk_ENGINE_dup(st) SKM_sk_dup(ENGINE, st)\n# define sk_ENGINE_pop_free(st, free_func) SKM_sk_pop_free(ENGINE, (st), (free_func))\n# define sk_ENGINE_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(ENGINE, (st), (copy_func), (free_func))\n# define sk_ENGINE_shift(st) SKM_sk_shift(ENGINE, (st))\n# define sk_ENGINE_pop(st) SKM_sk_pop(ENGINE, (st))\n# define sk_ENGINE_sort(st) SKM_sk_sort(ENGINE, (st))\n# define sk_ENGINE_is_sorted(st) SKM_sk_is_sorted(ENGINE, (st))\n# define sk_ENGINE_CLEANUP_ITEM_new(cmp) SKM_sk_new(ENGINE_CLEANUP_ITEM, (cmp))\n# define sk_ENGINE_CLEANUP_ITEM_new_null() SKM_sk_new_null(ENGINE_CLEANUP_ITEM)\n# define sk_ENGINE_CLEANUP_ITEM_free(st) SKM_sk_free(ENGINE_CLEANUP_ITEM, (st))\n# define sk_ENGINE_CLEANUP_ITEM_num(st) SKM_sk_num(ENGINE_CLEANUP_ITEM, (st))\n# define sk_ENGINE_CLEANUP_ITEM_value(st, i) SKM_sk_value(ENGINE_CLEANUP_ITEM, (st), (i))\n# define sk_ENGINE_CLEANUP_ITEM_set(st, i, val) SKM_sk_set(ENGINE_CLEANUP_ITEM, (st), (i), (val))\n# define sk_ENGINE_CLEANUP_ITEM_zero(st) SKM_sk_zero(ENGINE_CLEANUP_ITEM, (st))\n# define sk_ENGINE_CLEANUP_ITEM_push(st, val) SKM_sk_push(ENGINE_CLEANUP_ITEM, (st), (val))\n# define sk_ENGINE_CLEANUP_ITEM_unshift(st, val) SKM_sk_unshift(ENGINE_CLEANUP_ITEM, (st), (val))\n# define sk_ENGINE_CLEANUP_ITEM_find(st, val) SKM_sk_find(ENGINE_CLEANUP_ITEM, (st), (val))\n# define sk_ENGINE_CLEANUP_ITEM_find_ex(st, val) SKM_sk_find_ex(ENGINE_CLEANUP_ITEM, (st), (val))\n# define sk_ENGINE_CLEANUP_ITEM_delete(st, i) SKM_sk_delete(ENGINE_CLEANUP_ITEM, (st), (i))\n# define sk_ENGINE_CLEANUP_ITEM_delete_ptr(st, ptr) SKM_sk_delete_ptr(ENGINE_CLEANUP_ITEM, (st), (ptr))\n# define sk_ENGINE_CLEANUP_ITEM_insert(st, val, i) SKM_sk_insert(ENGINE_CLEANUP_ITEM, (st), (val), (i))\n# define sk_ENGINE_CLEANUP_ITEM_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(ENGINE_CLEANUP_ITEM, (st), (cmp))\n# define sk_ENGINE_CLEANUP_ITEM_dup(st) SKM_sk_dup(ENGINE_CLEANUP_ITEM, st)\n# define sk_ENGINE_CLEANUP_ITEM_pop_free(st, free_func) SKM_sk_pop_free(ENGINE_CLEANUP_ITEM, (st), (free_func))\n# define sk_ENGINE_CLEANUP_ITEM_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(ENGINE_CLEANUP_ITEM, (st), (copy_func), (free_func))\n# define sk_ENGINE_CLEANUP_ITEM_shift(st) SKM_sk_shift(ENGINE_CLEANUP_ITEM, (st))\n# define sk_ENGINE_CLEANUP_ITEM_pop(st) SKM_sk_pop(ENGINE_CLEANUP_ITEM, (st))\n# define sk_ENGINE_CLEANUP_ITEM_sort(st) SKM_sk_sort(ENGINE_CLEANUP_ITEM, (st))\n# define sk_ENGINE_CLEANUP_ITEM_is_sorted(st) SKM_sk_is_sorted(ENGINE_CLEANUP_ITEM, (st))\n# define sk_ESS_CERT_ID_new(cmp) SKM_sk_new(ESS_CERT_ID, (cmp))\n# define sk_ESS_CERT_ID_new_null() SKM_sk_new_null(ESS_CERT_ID)\n# define sk_ESS_CERT_ID_free(st) SKM_sk_free(ESS_CERT_ID, (st))\n# define sk_ESS_CERT_ID_num(st) SKM_sk_num(ESS_CERT_ID, (st))\n# define sk_ESS_CERT_ID_value(st, i) SKM_sk_value(ESS_CERT_ID, (st), (i))\n# define sk_ESS_CERT_ID_set(st, i, val) SKM_sk_set(ESS_CERT_ID, (st), (i), (val))\n# define sk_ESS_CERT_ID_zero(st) SKM_sk_zero(ESS_CERT_ID, (st))\n# define sk_ESS_CERT_ID_push(st, val) SKM_sk_push(ESS_CERT_ID, (st), (val))\n# define sk_ESS_CERT_ID_unshift(st, val) SKM_sk_unshift(ESS_CERT_ID, (st), (val))\n# define sk_ESS_CERT_ID_find(st, val) SKM_sk_find(ESS_CERT_ID, (st), (val))\n# define sk_ESS_CERT_ID_find_ex(st, val) SKM_sk_find_ex(ESS_CERT_ID, (st), (val))\n# define sk_ESS_CERT_ID_delete(st, i) SKM_sk_delete(ESS_CERT_ID, (st), (i))\n# define sk_ESS_CERT_ID_delete_ptr(st, ptr) SKM_sk_delete_ptr(ESS_CERT_ID, (st), (ptr))\n# define sk_ESS_CERT_ID_insert(st, val, i) SKM_sk_insert(ESS_CERT_ID, (st), (val), (i))\n# define sk_ESS_CERT_ID_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(ESS_CERT_ID, (st), (cmp))\n# define sk_ESS_CERT_ID_dup(st) SKM_sk_dup(ESS_CERT_ID, st)\n# define sk_ESS_CERT_ID_pop_free(st, free_func) SKM_sk_pop_free(ESS_CERT_ID, (st), (free_func))\n# define sk_ESS_CERT_ID_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(ESS_CERT_ID, (st), (copy_func), (free_func))\n# define sk_ESS_CERT_ID_shift(st) SKM_sk_shift(ESS_CERT_ID, (st))\n# define sk_ESS_CERT_ID_pop(st) SKM_sk_pop(ESS_CERT_ID, (st))\n# define sk_ESS_CERT_ID_sort(st) SKM_sk_sort(ESS_CERT_ID, (st))\n# define sk_ESS_CERT_ID_is_sorted(st) SKM_sk_is_sorted(ESS_CERT_ID, (st))\n# define sk_EVP_MD_new(cmp) SKM_sk_new(EVP_MD, (cmp))\n# define sk_EVP_MD_new_null() SKM_sk_new_null(EVP_MD)\n# define sk_EVP_MD_free(st) SKM_sk_free(EVP_MD, (st))\n# define sk_EVP_MD_num(st) SKM_sk_num(EVP_MD, (st))\n# define sk_EVP_MD_value(st, i) SKM_sk_value(EVP_MD, (st), (i))\n# define sk_EVP_MD_set(st, i, val) SKM_sk_set(EVP_MD, (st), (i), (val))\n# define sk_EVP_MD_zero(st) SKM_sk_zero(EVP_MD, (st))\n# define sk_EVP_MD_push(st, val) SKM_sk_push(EVP_MD, (st), (val))\n# define sk_EVP_MD_unshift(st, val) SKM_sk_unshift(EVP_MD, (st), (val))\n# define sk_EVP_MD_find(st, val) SKM_sk_find(EVP_MD, (st), (val))\n# define sk_EVP_MD_find_ex(st, val) SKM_sk_find_ex(EVP_MD, (st), (val))\n# define sk_EVP_MD_delete(st, i) SKM_sk_delete(EVP_MD, (st), (i))\n# define sk_EVP_MD_delete_ptr(st, ptr) SKM_sk_delete_ptr(EVP_MD, (st), (ptr))\n# define sk_EVP_MD_insert(st, val, i) SKM_sk_insert(EVP_MD, (st), (val), (i))\n# define sk_EVP_MD_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(EVP_MD, (st), (cmp))\n# define sk_EVP_MD_dup(st) SKM_sk_dup(EVP_MD, st)\n# define sk_EVP_MD_pop_free(st, free_func) SKM_sk_pop_free(EVP_MD, (st), (free_func))\n# define sk_EVP_MD_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(EVP_MD, (st), (copy_func), (free_func))\n# define sk_EVP_MD_shift(st) SKM_sk_shift(EVP_MD, (st))\n# define sk_EVP_MD_pop(st) SKM_sk_pop(EVP_MD, (st))\n# define sk_EVP_MD_sort(st) SKM_sk_sort(EVP_MD, (st))\n# define sk_EVP_MD_is_sorted(st) SKM_sk_is_sorted(EVP_MD, (st))\n# define sk_EVP_PBE_CTL_new(cmp) SKM_sk_new(EVP_PBE_CTL, (cmp))\n# define sk_EVP_PBE_CTL_new_null() SKM_sk_new_null(EVP_PBE_CTL)\n# define sk_EVP_PBE_CTL_free(st) SKM_sk_free(EVP_PBE_CTL, (st))\n# define sk_EVP_PBE_CTL_num(st) SKM_sk_num(EVP_PBE_CTL, (st))\n# define sk_EVP_PBE_CTL_value(st, i) SKM_sk_value(EVP_PBE_CTL, (st), (i))\n# define sk_EVP_PBE_CTL_set(st, i, val) SKM_sk_set(EVP_PBE_CTL, (st), (i), (val))\n# define sk_EVP_PBE_CTL_zero(st) SKM_sk_zero(EVP_PBE_CTL, (st))\n# define sk_EVP_PBE_CTL_push(st, val) SKM_sk_push(EVP_PBE_CTL, (st), (val))\n# define sk_EVP_PBE_CTL_unshift(st, val) SKM_sk_unshift(EVP_PBE_CTL, (st), (val))\n# define sk_EVP_PBE_CTL_find(st, val) SKM_sk_find(EVP_PBE_CTL, (st), (val))\n# define sk_EVP_PBE_CTL_find_ex(st, val) SKM_sk_find_ex(EVP_PBE_CTL, (st), (val))\n# define sk_EVP_PBE_CTL_delete(st, i) SKM_sk_delete(EVP_PBE_CTL, (st), (i))\n# define sk_EVP_PBE_CTL_delete_ptr(st, ptr) SKM_sk_delete_ptr(EVP_PBE_CTL, (st), (ptr))\n# define sk_EVP_PBE_CTL_insert(st, val, i) SKM_sk_insert(EVP_PBE_CTL, (st), (val), (i))\n# define sk_EVP_PBE_CTL_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(EVP_PBE_CTL, (st), (cmp))\n# define sk_EVP_PBE_CTL_dup(st) SKM_sk_dup(EVP_PBE_CTL, st)\n# define sk_EVP_PBE_CTL_pop_free(st, free_func) SKM_sk_pop_free(EVP_PBE_CTL, (st), (free_func))\n# define sk_EVP_PBE_CTL_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(EVP_PBE_CTL, (st), (copy_func), (free_func))\n# define sk_EVP_PBE_CTL_shift(st) SKM_sk_shift(EVP_PBE_CTL, (st))\n# define sk_EVP_PBE_CTL_pop(st) SKM_sk_pop(EVP_PBE_CTL, (st))\n# define sk_EVP_PBE_CTL_sort(st) SKM_sk_sort(EVP_PBE_CTL, (st))\n# define sk_EVP_PBE_CTL_is_sorted(st) SKM_sk_is_sorted(EVP_PBE_CTL, (st))\n# define sk_EVP_PKEY_ASN1_METHOD_new(cmp) SKM_sk_new(EVP_PKEY_ASN1_METHOD, (cmp))\n# define sk_EVP_PKEY_ASN1_METHOD_new_null() SKM_sk_new_null(EVP_PKEY_ASN1_METHOD)\n# define sk_EVP_PKEY_ASN1_METHOD_free(st) SKM_sk_free(EVP_PKEY_ASN1_METHOD, (st))\n# define sk_EVP_PKEY_ASN1_METHOD_num(st) SKM_sk_num(EVP_PKEY_ASN1_METHOD, (st))\n# define sk_EVP_PKEY_ASN1_METHOD_value(st, i) SKM_sk_value(EVP_PKEY_ASN1_METHOD, (st), (i))\n# define sk_EVP_PKEY_ASN1_METHOD_set(st, i, val) SKM_sk_set(EVP_PKEY_ASN1_METHOD, (st), (i), (val))\n# define sk_EVP_PKEY_ASN1_METHOD_zero(st) SKM_sk_zero(EVP_PKEY_ASN1_METHOD, (st))\n# define sk_EVP_PKEY_ASN1_METHOD_push(st, val) SKM_sk_push(EVP_PKEY_ASN1_METHOD, (st), (val))\n# define sk_EVP_PKEY_ASN1_METHOD_unshift(st, val) SKM_sk_unshift(EVP_PKEY_ASN1_METHOD, (st), (val))\n# define sk_EVP_PKEY_ASN1_METHOD_find(st, val) SKM_sk_find(EVP_PKEY_ASN1_METHOD, (st), (val))\n# define sk_EVP_PKEY_ASN1_METHOD_find_ex(st, val) SKM_sk_find_ex(EVP_PKEY_ASN1_METHOD, (st), (val))\n# define sk_EVP_PKEY_ASN1_METHOD_delete(st, i) SKM_sk_delete(EVP_PKEY_ASN1_METHOD, (st), (i))\n# define sk_EVP_PKEY_ASN1_METHOD_delete_ptr(st, ptr) SKM_sk_delete_ptr(EVP_PKEY_ASN1_METHOD, (st), (ptr))\n# define sk_EVP_PKEY_ASN1_METHOD_insert(st, val, i) SKM_sk_insert(EVP_PKEY_ASN1_METHOD, (st), (val), (i))\n# define sk_EVP_PKEY_ASN1_METHOD_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(EVP_PKEY_ASN1_METHOD, (st), (cmp))\n# define sk_EVP_PKEY_ASN1_METHOD_dup(st) SKM_sk_dup(EVP_PKEY_ASN1_METHOD, st)\n# define sk_EVP_PKEY_ASN1_METHOD_pop_free(st, free_func) SKM_sk_pop_free(EVP_PKEY_ASN1_METHOD, (st), (free_func))\n# define sk_EVP_PKEY_ASN1_METHOD_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(EVP_PKEY_ASN1_METHOD, (st), (copy_func), (free_func))\n# define sk_EVP_PKEY_ASN1_METHOD_shift(st) SKM_sk_shift(EVP_PKEY_ASN1_METHOD, (st))\n# define sk_EVP_PKEY_ASN1_METHOD_pop(st) SKM_sk_pop(EVP_PKEY_ASN1_METHOD, (st))\n# define sk_EVP_PKEY_ASN1_METHOD_sort(st) SKM_sk_sort(EVP_PKEY_ASN1_METHOD, (st))\n# define sk_EVP_PKEY_ASN1_METHOD_is_sorted(st) SKM_sk_is_sorted(EVP_PKEY_ASN1_METHOD, (st))\n# define sk_EVP_PKEY_METHOD_new(cmp) SKM_sk_new(EVP_PKEY_METHOD, (cmp))\n# define sk_EVP_PKEY_METHOD_new_null() SKM_sk_new_null(EVP_PKEY_METHOD)\n# define sk_EVP_PKEY_METHOD_free(st) SKM_sk_free(EVP_PKEY_METHOD, (st))\n# define sk_EVP_PKEY_METHOD_num(st) SKM_sk_num(EVP_PKEY_METHOD, (st))\n# define sk_EVP_PKEY_METHOD_value(st, i) SKM_sk_value(EVP_PKEY_METHOD, (st), (i))\n# define sk_EVP_PKEY_METHOD_set(st, i, val) SKM_sk_set(EVP_PKEY_METHOD, (st), (i), (val))\n# define sk_EVP_PKEY_METHOD_zero(st) SKM_sk_zero(EVP_PKEY_METHOD, (st))\n# define sk_EVP_PKEY_METHOD_push(st, val) SKM_sk_push(EVP_PKEY_METHOD, (st), (val))\n# define sk_EVP_PKEY_METHOD_unshift(st, val) SKM_sk_unshift(EVP_PKEY_METHOD, (st), (val))\n# define sk_EVP_PKEY_METHOD_find(st, val) SKM_sk_find(EVP_PKEY_METHOD, (st), (val))\n# define sk_EVP_PKEY_METHOD_find_ex(st, val) SKM_sk_find_ex(EVP_PKEY_METHOD, (st), (val))\n# define sk_EVP_PKEY_METHOD_delete(st, i) SKM_sk_delete(EVP_PKEY_METHOD, (st), (i))\n# define sk_EVP_PKEY_METHOD_delete_ptr(st, ptr) SKM_sk_delete_ptr(EVP_PKEY_METHOD, (st), (ptr))\n# define sk_EVP_PKEY_METHOD_insert(st, val, i) SKM_sk_insert(EVP_PKEY_METHOD, (st), (val), (i))\n# define sk_EVP_PKEY_METHOD_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(EVP_PKEY_METHOD, (st), (cmp))\n# define sk_EVP_PKEY_METHOD_dup(st) SKM_sk_dup(EVP_PKEY_METHOD, st)\n# define sk_EVP_PKEY_METHOD_pop_free(st, free_func) SKM_sk_pop_free(EVP_PKEY_METHOD, (st), (free_func))\n# define sk_EVP_PKEY_METHOD_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(EVP_PKEY_METHOD, (st), (copy_func), (free_func))\n# define sk_EVP_PKEY_METHOD_shift(st) SKM_sk_shift(EVP_PKEY_METHOD, (st))\n# define sk_EVP_PKEY_METHOD_pop(st) SKM_sk_pop(EVP_PKEY_METHOD, (st))\n# define sk_EVP_PKEY_METHOD_sort(st) SKM_sk_sort(EVP_PKEY_METHOD, (st))\n# define sk_EVP_PKEY_METHOD_is_sorted(st) SKM_sk_is_sorted(EVP_PKEY_METHOD, (st))\n# define sk_GENERAL_NAME_new(cmp) SKM_sk_new(GENERAL_NAME, (cmp))\n# define sk_GENERAL_NAME_new_null() SKM_sk_new_null(GENERAL_NAME)\n# define sk_GENERAL_NAME_free(st) SKM_sk_free(GENERAL_NAME, (st))\n# define sk_GENERAL_NAME_num(st) SKM_sk_num(GENERAL_NAME, (st))\n# define sk_GENERAL_NAME_value(st, i) SKM_sk_value(GENERAL_NAME, (st), (i))\n# define sk_GENERAL_NAME_set(st, i, val) SKM_sk_set(GENERAL_NAME, (st), (i), (val))\n# define sk_GENERAL_NAME_zero(st) SKM_sk_zero(GENERAL_NAME, (st))\n# define sk_GENERAL_NAME_push(st, val) SKM_sk_push(GENERAL_NAME, (st), (val))\n# define sk_GENERAL_NAME_unshift(st, val) SKM_sk_unshift(GENERAL_NAME, (st), (val))\n# define sk_GENERAL_NAME_find(st, val) SKM_sk_find(GENERAL_NAME, (st), (val))\n# define sk_GENERAL_NAME_find_ex(st, val) SKM_sk_find_ex(GENERAL_NAME, (st), (val))\n# define sk_GENERAL_NAME_delete(st, i) SKM_sk_delete(GENERAL_NAME, (st), (i))\n# define sk_GENERAL_NAME_delete_ptr(st, ptr) SKM_sk_delete_ptr(GENERAL_NAME, (st), (ptr))\n# define sk_GENERAL_NAME_insert(st, val, i) SKM_sk_insert(GENERAL_NAME, (st), (val), (i))\n# define sk_GENERAL_NAME_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(GENERAL_NAME, (st), (cmp))\n# define sk_GENERAL_NAME_dup(st) SKM_sk_dup(GENERAL_NAME, st)\n# define sk_GENERAL_NAME_pop_free(st, free_func) SKM_sk_pop_free(GENERAL_NAME, (st), (free_func))\n# define sk_GENERAL_NAME_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(GENERAL_NAME, (st), (copy_func), (free_func))\n# define sk_GENERAL_NAME_shift(st) SKM_sk_shift(GENERAL_NAME, (st))\n# define sk_GENERAL_NAME_pop(st) SKM_sk_pop(GENERAL_NAME, (st))\n# define sk_GENERAL_NAME_sort(st) SKM_sk_sort(GENERAL_NAME, (st))\n# define sk_GENERAL_NAME_is_sorted(st) SKM_sk_is_sorted(GENERAL_NAME, (st))\n# define sk_GENERAL_NAMES_new(cmp) SKM_sk_new(GENERAL_NAMES, (cmp))\n# define sk_GENERAL_NAMES_new_null() SKM_sk_new_null(GENERAL_NAMES)\n# define sk_GENERAL_NAMES_free(st) SKM_sk_free(GENERAL_NAMES, (st))\n# define sk_GENERAL_NAMES_num(st) SKM_sk_num(GENERAL_NAMES, (st))\n# define sk_GENERAL_NAMES_value(st, i) SKM_sk_value(GENERAL_NAMES, (st), (i))\n# define sk_GENERAL_NAMES_set(st, i, val) SKM_sk_set(GENERAL_NAMES, (st), (i), (val))\n# define sk_GENERAL_NAMES_zero(st) SKM_sk_zero(GENERAL_NAMES, (st))\n# define sk_GENERAL_NAMES_push(st, val) SKM_sk_push(GENERAL_NAMES, (st), (val))\n# define sk_GENERAL_NAMES_unshift(st, val) SKM_sk_unshift(GENERAL_NAMES, (st), (val))\n# define sk_GENERAL_NAMES_find(st, val) SKM_sk_find(GENERAL_NAMES, (st), (val))\n# define sk_GENERAL_NAMES_find_ex(st, val) SKM_sk_find_ex(GENERAL_NAMES, (st), (val))\n# define sk_GENERAL_NAMES_delete(st, i) SKM_sk_delete(GENERAL_NAMES, (st), (i))\n# define sk_GENERAL_NAMES_delete_ptr(st, ptr) SKM_sk_delete_ptr(GENERAL_NAMES, (st), (ptr))\n# define sk_GENERAL_NAMES_insert(st, val, i) SKM_sk_insert(GENERAL_NAMES, (st), (val), (i))\n# define sk_GENERAL_NAMES_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(GENERAL_NAMES, (st), (cmp))\n# define sk_GENERAL_NAMES_dup(st) SKM_sk_dup(GENERAL_NAMES, st)\n# define sk_GENERAL_NAMES_pop_free(st, free_func) SKM_sk_pop_free(GENERAL_NAMES, (st), (free_func))\n# define sk_GENERAL_NAMES_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(GENERAL_NAMES, (st), (copy_func), (free_func))\n# define sk_GENERAL_NAMES_shift(st) SKM_sk_shift(GENERAL_NAMES, (st))\n# define sk_GENERAL_NAMES_pop(st) SKM_sk_pop(GENERAL_NAMES, (st))\n# define sk_GENERAL_NAMES_sort(st) SKM_sk_sort(GENERAL_NAMES, (st))\n# define sk_GENERAL_NAMES_is_sorted(st) SKM_sk_is_sorted(GENERAL_NAMES, (st))\n# define sk_GENERAL_SUBTREE_new(cmp) SKM_sk_new(GENERAL_SUBTREE, (cmp))\n# define sk_GENERAL_SUBTREE_new_null() SKM_sk_new_null(GENERAL_SUBTREE)\n# define sk_GENERAL_SUBTREE_free(st) SKM_sk_free(GENERAL_SUBTREE, (st))\n# define sk_GENERAL_SUBTREE_num(st) SKM_sk_num(GENERAL_SUBTREE, (st))\n# define sk_GENERAL_SUBTREE_value(st, i) SKM_sk_value(GENERAL_SUBTREE, (st), (i))\n# define sk_GENERAL_SUBTREE_set(st, i, val) SKM_sk_set(GENERAL_SUBTREE, (st), (i), (val))\n# define sk_GENERAL_SUBTREE_zero(st) SKM_sk_zero(GENERAL_SUBTREE, (st))\n# define sk_GENERAL_SUBTREE_push(st, val) SKM_sk_push(GENERAL_SUBTREE, (st), (val))\n# define sk_GENERAL_SUBTREE_unshift(st, val) SKM_sk_unshift(GENERAL_SUBTREE, (st), (val))\n# define sk_GENERAL_SUBTREE_find(st, val) SKM_sk_find(GENERAL_SUBTREE, (st), (val))\n# define sk_GENERAL_SUBTREE_find_ex(st, val) SKM_sk_find_ex(GENERAL_SUBTREE, (st), (val))\n# define sk_GENERAL_SUBTREE_delete(st, i) SKM_sk_delete(GENERAL_SUBTREE, (st), (i))\n# define sk_GENERAL_SUBTREE_delete_ptr(st, ptr) SKM_sk_delete_ptr(GENERAL_SUBTREE, (st), (ptr))\n# define sk_GENERAL_SUBTREE_insert(st, val, i) SKM_sk_insert(GENERAL_SUBTREE, (st), (val), (i))\n# define sk_GENERAL_SUBTREE_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(GENERAL_SUBTREE, (st), (cmp))\n# define sk_GENERAL_SUBTREE_dup(st) SKM_sk_dup(GENERAL_SUBTREE, st)\n# define sk_GENERAL_SUBTREE_pop_free(st, free_func) SKM_sk_pop_free(GENERAL_SUBTREE, (st), (free_func))\n# define sk_GENERAL_SUBTREE_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(GENERAL_SUBTREE, (st), (copy_func), (free_func))\n# define sk_GENERAL_SUBTREE_shift(st) SKM_sk_shift(GENERAL_SUBTREE, (st))\n# define sk_GENERAL_SUBTREE_pop(st) SKM_sk_pop(GENERAL_SUBTREE, (st))\n# define sk_GENERAL_SUBTREE_sort(st) SKM_sk_sort(GENERAL_SUBTREE, (st))\n# define sk_GENERAL_SUBTREE_is_sorted(st) SKM_sk_is_sorted(GENERAL_SUBTREE, (st))\n# define sk_IPAddressFamily_new(cmp) SKM_sk_new(IPAddressFamily, (cmp))\n# define sk_IPAddressFamily_new_null() SKM_sk_new_null(IPAddressFamily)\n# define sk_IPAddressFamily_free(st) SKM_sk_free(IPAddressFamily, (st))\n# define sk_IPAddressFamily_num(st) SKM_sk_num(IPAddressFamily, (st))\n# define sk_IPAddressFamily_value(st, i) SKM_sk_value(IPAddressFamily, (st), (i))\n# define sk_IPAddressFamily_set(st, i, val) SKM_sk_set(IPAddressFamily, (st), (i), (val))\n# define sk_IPAddressFamily_zero(st) SKM_sk_zero(IPAddressFamily, (st))\n# define sk_IPAddressFamily_push(st, val) SKM_sk_push(IPAddressFamily, (st), (val))\n# define sk_IPAddressFamily_unshift(st, val) SKM_sk_unshift(IPAddressFamily, (st), (val))\n# define sk_IPAddressFamily_find(st, val) SKM_sk_find(IPAddressFamily, (st), (val))\n# define sk_IPAddressFamily_find_ex(st, val) SKM_sk_find_ex(IPAddressFamily, (st), (val))\n# define sk_IPAddressFamily_delete(st, i) SKM_sk_delete(IPAddressFamily, (st), (i))\n# define sk_IPAddressFamily_delete_ptr(st, ptr) SKM_sk_delete_ptr(IPAddressFamily, (st), (ptr))\n# define sk_IPAddressFamily_insert(st, val, i) SKM_sk_insert(IPAddressFamily, (st), (val), (i))\n# define sk_IPAddressFamily_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(IPAddressFamily, (st), (cmp))\n# define sk_IPAddressFamily_dup(st) SKM_sk_dup(IPAddressFamily, st)\n# define sk_IPAddressFamily_pop_free(st, free_func) SKM_sk_pop_free(IPAddressFamily, (st), (free_func))\n# define sk_IPAddressFamily_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(IPAddressFamily, (st), (copy_func), (free_func))\n# define sk_IPAddressFamily_shift(st) SKM_sk_shift(IPAddressFamily, (st))\n# define sk_IPAddressFamily_pop(st) SKM_sk_pop(IPAddressFamily, (st))\n# define sk_IPAddressFamily_sort(st) SKM_sk_sort(IPAddressFamily, (st))\n# define sk_IPAddressFamily_is_sorted(st) SKM_sk_is_sorted(IPAddressFamily, (st))\n# define sk_IPAddressOrRange_new(cmp) SKM_sk_new(IPAddressOrRange, (cmp))\n# define sk_IPAddressOrRange_new_null() SKM_sk_new_null(IPAddressOrRange)\n# define sk_IPAddressOrRange_free(st) SKM_sk_free(IPAddressOrRange, (st))\n# define sk_IPAddressOrRange_num(st) SKM_sk_num(IPAddressOrRange, (st))\n# define sk_IPAddressOrRange_value(st, i) SKM_sk_value(IPAddressOrRange, (st), (i))\n# define sk_IPAddressOrRange_set(st, i, val) SKM_sk_set(IPAddressOrRange, (st), (i), (val))\n# define sk_IPAddressOrRange_zero(st) SKM_sk_zero(IPAddressOrRange, (st))\n# define sk_IPAddressOrRange_push(st, val) SKM_sk_push(IPAddressOrRange, (st), (val))\n# define sk_IPAddressOrRange_unshift(st, val) SKM_sk_unshift(IPAddressOrRange, (st), (val))\n# define sk_IPAddressOrRange_find(st, val) SKM_sk_find(IPAddressOrRange, (st), (val))\n# define sk_IPAddressOrRange_find_ex(st, val) SKM_sk_find_ex(IPAddressOrRange, (st), (val))\n# define sk_IPAddressOrRange_delete(st, i) SKM_sk_delete(IPAddressOrRange, (st), (i))\n# define sk_IPAddressOrRange_delete_ptr(st, ptr) SKM_sk_delete_ptr(IPAddressOrRange, (st), (ptr))\n# define sk_IPAddressOrRange_insert(st, val, i) SKM_sk_insert(IPAddressOrRange, (st), (val), (i))\n# define sk_IPAddressOrRange_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(IPAddressOrRange, (st), (cmp))\n# define sk_IPAddressOrRange_dup(st) SKM_sk_dup(IPAddressOrRange, st)\n# define sk_IPAddressOrRange_pop_free(st, free_func) SKM_sk_pop_free(IPAddressOrRange, (st), (free_func))\n# define sk_IPAddressOrRange_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(IPAddressOrRange, (st), (copy_func), (free_func))\n# define sk_IPAddressOrRange_shift(st) SKM_sk_shift(IPAddressOrRange, (st))\n# define sk_IPAddressOrRange_pop(st) SKM_sk_pop(IPAddressOrRange, (st))\n# define sk_IPAddressOrRange_sort(st) SKM_sk_sort(IPAddressOrRange, (st))\n# define sk_IPAddressOrRange_is_sorted(st) SKM_sk_is_sorted(IPAddressOrRange, (st))\n# define sk_KRB5_APREQBODY_new(cmp) SKM_sk_new(KRB5_APREQBODY, (cmp))\n# define sk_KRB5_APREQBODY_new_null() SKM_sk_new_null(KRB5_APREQBODY)\n# define sk_KRB5_APREQBODY_free(st) SKM_sk_free(KRB5_APREQBODY, (st))\n# define sk_KRB5_APREQBODY_num(st) SKM_sk_num(KRB5_APREQBODY, (st))\n# define sk_KRB5_APREQBODY_value(st, i) SKM_sk_value(KRB5_APREQBODY, (st), (i))\n# define sk_KRB5_APREQBODY_set(st, i, val) SKM_sk_set(KRB5_APREQBODY, (st), (i), (val))\n# define sk_KRB5_APREQBODY_zero(st) SKM_sk_zero(KRB5_APREQBODY, (st))\n# define sk_KRB5_APREQBODY_push(st, val) SKM_sk_push(KRB5_APREQBODY, (st), (val))\n# define sk_KRB5_APREQBODY_unshift(st, val) SKM_sk_unshift(KRB5_APREQBODY, (st), (val))\n# define sk_KRB5_APREQBODY_find(st, val) SKM_sk_find(KRB5_APREQBODY, (st), (val))\n# define sk_KRB5_APREQBODY_find_ex(st, val) SKM_sk_find_ex(KRB5_APREQBODY, (st), (val))\n# define sk_KRB5_APREQBODY_delete(st, i) SKM_sk_delete(KRB5_APREQBODY, (st), (i))\n# define sk_KRB5_APREQBODY_delete_ptr(st, ptr) SKM_sk_delete_ptr(KRB5_APREQBODY, (st), (ptr))\n# define sk_KRB5_APREQBODY_insert(st, val, i) SKM_sk_insert(KRB5_APREQBODY, (st), (val), (i))\n# define sk_KRB5_APREQBODY_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(KRB5_APREQBODY, (st), (cmp))\n# define sk_KRB5_APREQBODY_dup(st) SKM_sk_dup(KRB5_APREQBODY, st)\n# define sk_KRB5_APREQBODY_pop_free(st, free_func) SKM_sk_pop_free(KRB5_APREQBODY, (st), (free_func))\n# define sk_KRB5_APREQBODY_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(KRB5_APREQBODY, (st), (copy_func), (free_func))\n# define sk_KRB5_APREQBODY_shift(st) SKM_sk_shift(KRB5_APREQBODY, (st))\n# define sk_KRB5_APREQBODY_pop(st) SKM_sk_pop(KRB5_APREQBODY, (st))\n# define sk_KRB5_APREQBODY_sort(st) SKM_sk_sort(KRB5_APREQBODY, (st))\n# define sk_KRB5_APREQBODY_is_sorted(st) SKM_sk_is_sorted(KRB5_APREQBODY, (st))\n# define sk_KRB5_AUTHDATA_new(cmp) SKM_sk_new(KRB5_AUTHDATA, (cmp))\n# define sk_KRB5_AUTHDATA_new_null() SKM_sk_new_null(KRB5_AUTHDATA)\n# define sk_KRB5_AUTHDATA_free(st) SKM_sk_free(KRB5_AUTHDATA, (st))\n# define sk_KRB5_AUTHDATA_num(st) SKM_sk_num(KRB5_AUTHDATA, (st))\n# define sk_KRB5_AUTHDATA_value(st, i) SKM_sk_value(KRB5_AUTHDATA, (st), (i))\n# define sk_KRB5_AUTHDATA_set(st, i, val) SKM_sk_set(KRB5_AUTHDATA, (st), (i), (val))\n# define sk_KRB5_AUTHDATA_zero(st) SKM_sk_zero(KRB5_AUTHDATA, (st))\n# define sk_KRB5_AUTHDATA_push(st, val) SKM_sk_push(KRB5_AUTHDATA, (st), (val))\n# define sk_KRB5_AUTHDATA_unshift(st, val) SKM_sk_unshift(KRB5_AUTHDATA, (st), (val))\n# define sk_KRB5_AUTHDATA_find(st, val) SKM_sk_find(KRB5_AUTHDATA, (st), (val))\n# define sk_KRB5_AUTHDATA_find_ex(st, val) SKM_sk_find_ex(KRB5_AUTHDATA, (st), (val))\n# define sk_KRB5_AUTHDATA_delete(st, i) SKM_sk_delete(KRB5_AUTHDATA, (st), (i))\n# define sk_KRB5_AUTHDATA_delete_ptr(st, ptr) SKM_sk_delete_ptr(KRB5_AUTHDATA, (st), (ptr))\n# define sk_KRB5_AUTHDATA_insert(st, val, i) SKM_sk_insert(KRB5_AUTHDATA, (st), (val), (i))\n# define sk_KRB5_AUTHDATA_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(KRB5_AUTHDATA, (st), (cmp))\n# define sk_KRB5_AUTHDATA_dup(st) SKM_sk_dup(KRB5_AUTHDATA, st)\n# define sk_KRB5_AUTHDATA_pop_free(st, free_func) SKM_sk_pop_free(KRB5_AUTHDATA, (st), (free_func))\n# define sk_KRB5_AUTHDATA_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(KRB5_AUTHDATA, (st), (copy_func), (free_func))\n# define sk_KRB5_AUTHDATA_shift(st) SKM_sk_shift(KRB5_AUTHDATA, (st))\n# define sk_KRB5_AUTHDATA_pop(st) SKM_sk_pop(KRB5_AUTHDATA, (st))\n# define sk_KRB5_AUTHDATA_sort(st) SKM_sk_sort(KRB5_AUTHDATA, (st))\n# define sk_KRB5_AUTHDATA_is_sorted(st) SKM_sk_is_sorted(KRB5_AUTHDATA, (st))\n# define sk_KRB5_AUTHENTBODY_new(cmp) SKM_sk_new(KRB5_AUTHENTBODY, (cmp))\n# define sk_KRB5_AUTHENTBODY_new_null() SKM_sk_new_null(KRB5_AUTHENTBODY)\n# define sk_KRB5_AUTHENTBODY_free(st) SKM_sk_free(KRB5_AUTHENTBODY, (st))\n# define sk_KRB5_AUTHENTBODY_num(st) SKM_sk_num(KRB5_AUTHENTBODY, (st))\n# define sk_KRB5_AUTHENTBODY_value(st, i) SKM_sk_value(KRB5_AUTHENTBODY, (st), (i))\n# define sk_KRB5_AUTHENTBODY_set(st, i, val) SKM_sk_set(KRB5_AUTHENTBODY, (st), (i), (val))\n# define sk_KRB5_AUTHENTBODY_zero(st) SKM_sk_zero(KRB5_AUTHENTBODY, (st))\n# define sk_KRB5_AUTHENTBODY_push(st, val) SKM_sk_push(KRB5_AUTHENTBODY, (st), (val))\n# define sk_KRB5_AUTHENTBODY_unshift(st, val) SKM_sk_unshift(KRB5_AUTHENTBODY, (st), (val))\n# define sk_KRB5_AUTHENTBODY_find(st, val) SKM_sk_find(KRB5_AUTHENTBODY, (st), (val))\n# define sk_KRB5_AUTHENTBODY_find_ex(st, val) SKM_sk_find_ex(KRB5_AUTHENTBODY, (st), (val))\n# define sk_KRB5_AUTHENTBODY_delete(st, i) SKM_sk_delete(KRB5_AUTHENTBODY, (st), (i))\n# define sk_KRB5_AUTHENTBODY_delete_ptr(st, ptr) SKM_sk_delete_ptr(KRB5_AUTHENTBODY, (st), (ptr))\n# define sk_KRB5_AUTHENTBODY_insert(st, val, i) SKM_sk_insert(KRB5_AUTHENTBODY, (st), (val), (i))\n# define sk_KRB5_AUTHENTBODY_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(KRB5_AUTHENTBODY, (st), (cmp))\n# define sk_KRB5_AUTHENTBODY_dup(st) SKM_sk_dup(KRB5_AUTHENTBODY, st)\n# define sk_KRB5_AUTHENTBODY_pop_free(st, free_func) SKM_sk_pop_free(KRB5_AUTHENTBODY, (st), (free_func))\n# define sk_KRB5_AUTHENTBODY_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(KRB5_AUTHENTBODY, (st), (copy_func), (free_func))\n# define sk_KRB5_AUTHENTBODY_shift(st) SKM_sk_shift(KRB5_AUTHENTBODY, (st))\n# define sk_KRB5_AUTHENTBODY_pop(st) SKM_sk_pop(KRB5_AUTHENTBODY, (st))\n# define sk_KRB5_AUTHENTBODY_sort(st) SKM_sk_sort(KRB5_AUTHENTBODY, (st))\n# define sk_KRB5_AUTHENTBODY_is_sorted(st) SKM_sk_is_sorted(KRB5_AUTHENTBODY, (st))\n# define sk_KRB5_CHECKSUM_new(cmp) SKM_sk_new(KRB5_CHECKSUM, (cmp))\n# define sk_KRB5_CHECKSUM_new_null() SKM_sk_new_null(KRB5_CHECKSUM)\n# define sk_KRB5_CHECKSUM_free(st) SKM_sk_free(KRB5_CHECKSUM, (st))\n# define sk_KRB5_CHECKSUM_num(st) SKM_sk_num(KRB5_CHECKSUM, (st))\n# define sk_KRB5_CHECKSUM_value(st, i) SKM_sk_value(KRB5_CHECKSUM, (st), (i))\n# define sk_KRB5_CHECKSUM_set(st, i, val) SKM_sk_set(KRB5_CHECKSUM, (st), (i), (val))\n# define sk_KRB5_CHECKSUM_zero(st) SKM_sk_zero(KRB5_CHECKSUM, (st))\n# define sk_KRB5_CHECKSUM_push(st, val) SKM_sk_push(KRB5_CHECKSUM, (st), (val))\n# define sk_KRB5_CHECKSUM_unshift(st, val) SKM_sk_unshift(KRB5_CHECKSUM, (st), (val))\n# define sk_KRB5_CHECKSUM_find(st, val) SKM_sk_find(KRB5_CHECKSUM, (st), (val))\n# define sk_KRB5_CHECKSUM_find_ex(st, val) SKM_sk_find_ex(KRB5_CHECKSUM, (st), (val))\n# define sk_KRB5_CHECKSUM_delete(st, i) SKM_sk_delete(KRB5_CHECKSUM, (st), (i))\n# define sk_KRB5_CHECKSUM_delete_ptr(st, ptr) SKM_sk_delete_ptr(KRB5_CHECKSUM, (st), (ptr))\n# define sk_KRB5_CHECKSUM_insert(st, val, i) SKM_sk_insert(KRB5_CHECKSUM, (st), (val), (i))\n# define sk_KRB5_CHECKSUM_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(KRB5_CHECKSUM, (st), (cmp))\n# define sk_KRB5_CHECKSUM_dup(st) SKM_sk_dup(KRB5_CHECKSUM, st)\n# define sk_KRB5_CHECKSUM_pop_free(st, free_func) SKM_sk_pop_free(KRB5_CHECKSUM, (st), (free_func))\n# define sk_KRB5_CHECKSUM_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(KRB5_CHECKSUM, (st), (copy_func), (free_func))\n# define sk_KRB5_CHECKSUM_shift(st) SKM_sk_shift(KRB5_CHECKSUM, (st))\n# define sk_KRB5_CHECKSUM_pop(st) SKM_sk_pop(KRB5_CHECKSUM, (st))\n# define sk_KRB5_CHECKSUM_sort(st) SKM_sk_sort(KRB5_CHECKSUM, (st))\n# define sk_KRB5_CHECKSUM_is_sorted(st) SKM_sk_is_sorted(KRB5_CHECKSUM, (st))\n# define sk_KRB5_ENCDATA_new(cmp) SKM_sk_new(KRB5_ENCDATA, (cmp))\n# define sk_KRB5_ENCDATA_new_null() SKM_sk_new_null(KRB5_ENCDATA)\n# define sk_KRB5_ENCDATA_free(st) SKM_sk_free(KRB5_ENCDATA, (st))\n# define sk_KRB5_ENCDATA_num(st) SKM_sk_num(KRB5_ENCDATA, (st))\n# define sk_KRB5_ENCDATA_value(st, i) SKM_sk_value(KRB5_ENCDATA, (st), (i))\n# define sk_KRB5_ENCDATA_set(st, i, val) SKM_sk_set(KRB5_ENCDATA, (st), (i), (val))\n# define sk_KRB5_ENCDATA_zero(st) SKM_sk_zero(KRB5_ENCDATA, (st))\n# define sk_KRB5_ENCDATA_push(st, val) SKM_sk_push(KRB5_ENCDATA, (st), (val))\n# define sk_KRB5_ENCDATA_unshift(st, val) SKM_sk_unshift(KRB5_ENCDATA, (st), (val))\n# define sk_KRB5_ENCDATA_find(st, val) SKM_sk_find(KRB5_ENCDATA, (st), (val))\n# define sk_KRB5_ENCDATA_find_ex(st, val) SKM_sk_find_ex(KRB5_ENCDATA, (st), (val))\n# define sk_KRB5_ENCDATA_delete(st, i) SKM_sk_delete(KRB5_ENCDATA, (st), (i))\n# define sk_KRB5_ENCDATA_delete_ptr(st, ptr) SKM_sk_delete_ptr(KRB5_ENCDATA, (st), (ptr))\n# define sk_KRB5_ENCDATA_insert(st, val, i) SKM_sk_insert(KRB5_ENCDATA, (st), (val), (i))\n# define sk_KRB5_ENCDATA_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(KRB5_ENCDATA, (st), (cmp))\n# define sk_KRB5_ENCDATA_dup(st) SKM_sk_dup(KRB5_ENCDATA, st)\n# define sk_KRB5_ENCDATA_pop_free(st, free_func) SKM_sk_pop_free(KRB5_ENCDATA, (st), (free_func))\n# define sk_KRB5_ENCDATA_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(KRB5_ENCDATA, (st), (copy_func), (free_func))\n# define sk_KRB5_ENCDATA_shift(st) SKM_sk_shift(KRB5_ENCDATA, (st))\n# define sk_KRB5_ENCDATA_pop(st) SKM_sk_pop(KRB5_ENCDATA, (st))\n# define sk_KRB5_ENCDATA_sort(st) SKM_sk_sort(KRB5_ENCDATA, (st))\n# define sk_KRB5_ENCDATA_is_sorted(st) SKM_sk_is_sorted(KRB5_ENCDATA, (st))\n# define sk_KRB5_ENCKEY_new(cmp) SKM_sk_new(KRB5_ENCKEY, (cmp))\n# define sk_KRB5_ENCKEY_new_null() SKM_sk_new_null(KRB5_ENCKEY)\n# define sk_KRB5_ENCKEY_free(st) SKM_sk_free(KRB5_ENCKEY, (st))\n# define sk_KRB5_ENCKEY_num(st) SKM_sk_num(KRB5_ENCKEY, (st))\n# define sk_KRB5_ENCKEY_value(st, i) SKM_sk_value(KRB5_ENCKEY, (st), (i))\n# define sk_KRB5_ENCKEY_set(st, i, val) SKM_sk_set(KRB5_ENCKEY, (st), (i), (val))\n# define sk_KRB5_ENCKEY_zero(st) SKM_sk_zero(KRB5_ENCKEY, (st))\n# define sk_KRB5_ENCKEY_push(st, val) SKM_sk_push(KRB5_ENCKEY, (st), (val))\n# define sk_KRB5_ENCKEY_unshift(st, val) SKM_sk_unshift(KRB5_ENCKEY, (st), (val))\n# define sk_KRB5_ENCKEY_find(st, val) SKM_sk_find(KRB5_ENCKEY, (st), (val))\n# define sk_KRB5_ENCKEY_find_ex(st, val) SKM_sk_find_ex(KRB5_ENCKEY, (st), (val))\n# define sk_KRB5_ENCKEY_delete(st, i) SKM_sk_delete(KRB5_ENCKEY, (st), (i))\n# define sk_KRB5_ENCKEY_delete_ptr(st, ptr) SKM_sk_delete_ptr(KRB5_ENCKEY, (st), (ptr))\n# define sk_KRB5_ENCKEY_insert(st, val, i) SKM_sk_insert(KRB5_ENCKEY, (st), (val), (i))\n# define sk_KRB5_ENCKEY_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(KRB5_ENCKEY, (st), (cmp))\n# define sk_KRB5_ENCKEY_dup(st) SKM_sk_dup(KRB5_ENCKEY, st)\n# define sk_KRB5_ENCKEY_pop_free(st, free_func) SKM_sk_pop_free(KRB5_ENCKEY, (st), (free_func))\n# define sk_KRB5_ENCKEY_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(KRB5_ENCKEY, (st), (copy_func), (free_func))\n# define sk_KRB5_ENCKEY_shift(st) SKM_sk_shift(KRB5_ENCKEY, (st))\n# define sk_KRB5_ENCKEY_pop(st) SKM_sk_pop(KRB5_ENCKEY, (st))\n# define sk_KRB5_ENCKEY_sort(st) SKM_sk_sort(KRB5_ENCKEY, (st))\n# define sk_KRB5_ENCKEY_is_sorted(st) SKM_sk_is_sorted(KRB5_ENCKEY, (st))\n# define sk_KRB5_PRINCNAME_new(cmp) SKM_sk_new(KRB5_PRINCNAME, (cmp))\n# define sk_KRB5_PRINCNAME_new_null() SKM_sk_new_null(KRB5_PRINCNAME)\n# define sk_KRB5_PRINCNAME_free(st) SKM_sk_free(KRB5_PRINCNAME, (st))\n# define sk_KRB5_PRINCNAME_num(st) SKM_sk_num(KRB5_PRINCNAME, (st))\n# define sk_KRB5_PRINCNAME_value(st, i) SKM_sk_value(KRB5_PRINCNAME, (st), (i))\n# define sk_KRB5_PRINCNAME_set(st, i, val) SKM_sk_set(KRB5_PRINCNAME, (st), (i), (val))\n# define sk_KRB5_PRINCNAME_zero(st) SKM_sk_zero(KRB5_PRINCNAME, (st))\n# define sk_KRB5_PRINCNAME_push(st, val) SKM_sk_push(KRB5_PRINCNAME, (st), (val))\n# define sk_KRB5_PRINCNAME_unshift(st, val) SKM_sk_unshift(KRB5_PRINCNAME, (st), (val))\n# define sk_KRB5_PRINCNAME_find(st, val) SKM_sk_find(KRB5_PRINCNAME, (st), (val))\n# define sk_KRB5_PRINCNAME_find_ex(st, val) SKM_sk_find_ex(KRB5_PRINCNAME, (st), (val))\n# define sk_KRB5_PRINCNAME_delete(st, i) SKM_sk_delete(KRB5_PRINCNAME, (st), (i))\n# define sk_KRB5_PRINCNAME_delete_ptr(st, ptr) SKM_sk_delete_ptr(KRB5_PRINCNAME, (st), (ptr))\n# define sk_KRB5_PRINCNAME_insert(st, val, i) SKM_sk_insert(KRB5_PRINCNAME, (st), (val), (i))\n# define sk_KRB5_PRINCNAME_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(KRB5_PRINCNAME, (st), (cmp))\n# define sk_KRB5_PRINCNAME_dup(st) SKM_sk_dup(KRB5_PRINCNAME, st)\n# define sk_KRB5_PRINCNAME_pop_free(st, free_func) SKM_sk_pop_free(KRB5_PRINCNAME, (st), (free_func))\n# define sk_KRB5_PRINCNAME_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(KRB5_PRINCNAME, (st), (copy_func), (free_func))\n# define sk_KRB5_PRINCNAME_shift(st) SKM_sk_shift(KRB5_PRINCNAME, (st))\n# define sk_KRB5_PRINCNAME_pop(st) SKM_sk_pop(KRB5_PRINCNAME, (st))\n# define sk_KRB5_PRINCNAME_sort(st) SKM_sk_sort(KRB5_PRINCNAME, (st))\n# define sk_KRB5_PRINCNAME_is_sorted(st) SKM_sk_is_sorted(KRB5_PRINCNAME, (st))\n# define sk_KRB5_TKTBODY_new(cmp) SKM_sk_new(KRB5_TKTBODY, (cmp))\n# define sk_KRB5_TKTBODY_new_null() SKM_sk_new_null(KRB5_TKTBODY)\n# define sk_KRB5_TKTBODY_free(st) SKM_sk_free(KRB5_TKTBODY, (st))\n# define sk_KRB5_TKTBODY_num(st) SKM_sk_num(KRB5_TKTBODY, (st))\n# define sk_KRB5_TKTBODY_value(st, i) SKM_sk_value(KRB5_TKTBODY, (st), (i))\n# define sk_KRB5_TKTBODY_set(st, i, val) SKM_sk_set(KRB5_TKTBODY, (st), (i), (val))\n# define sk_KRB5_TKTBODY_zero(st) SKM_sk_zero(KRB5_TKTBODY, (st))\n# define sk_KRB5_TKTBODY_push(st, val) SKM_sk_push(KRB5_TKTBODY, (st), (val))\n# define sk_KRB5_TKTBODY_unshift(st, val) SKM_sk_unshift(KRB5_TKTBODY, (st), (val))\n# define sk_KRB5_TKTBODY_find(st, val) SKM_sk_find(KRB5_TKTBODY, (st), (val))\n# define sk_KRB5_TKTBODY_find_ex(st, val) SKM_sk_find_ex(KRB5_TKTBODY, (st), (val))\n# define sk_KRB5_TKTBODY_delete(st, i) SKM_sk_delete(KRB5_TKTBODY, (st), (i))\n# define sk_KRB5_TKTBODY_delete_ptr(st, ptr) SKM_sk_delete_ptr(KRB5_TKTBODY, (st), (ptr))\n# define sk_KRB5_TKTBODY_insert(st, val, i) SKM_sk_insert(KRB5_TKTBODY, (st), (val), (i))\n# define sk_KRB5_TKTBODY_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(KRB5_TKTBODY, (st), (cmp))\n# define sk_KRB5_TKTBODY_dup(st) SKM_sk_dup(KRB5_TKTBODY, st)\n# define sk_KRB5_TKTBODY_pop_free(st, free_func) SKM_sk_pop_free(KRB5_TKTBODY, (st), (free_func))\n# define sk_KRB5_TKTBODY_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(KRB5_TKTBODY, (st), (copy_func), (free_func))\n# define sk_KRB5_TKTBODY_shift(st) SKM_sk_shift(KRB5_TKTBODY, (st))\n# define sk_KRB5_TKTBODY_pop(st) SKM_sk_pop(KRB5_TKTBODY, (st))\n# define sk_KRB5_TKTBODY_sort(st) SKM_sk_sort(KRB5_TKTBODY, (st))\n# define sk_KRB5_TKTBODY_is_sorted(st) SKM_sk_is_sorted(KRB5_TKTBODY, (st))\n# define sk_MEM_OBJECT_DATA_new(cmp) SKM_sk_new(MEM_OBJECT_DATA, (cmp))\n# define sk_MEM_OBJECT_DATA_new_null() SKM_sk_new_null(MEM_OBJECT_DATA)\n# define sk_MEM_OBJECT_DATA_free(st) SKM_sk_free(MEM_OBJECT_DATA, (st))\n# define sk_MEM_OBJECT_DATA_num(st) SKM_sk_num(MEM_OBJECT_DATA, (st))\n# define sk_MEM_OBJECT_DATA_value(st, i) SKM_sk_value(MEM_OBJECT_DATA, (st), (i))\n# define sk_MEM_OBJECT_DATA_set(st, i, val) SKM_sk_set(MEM_OBJECT_DATA, (st), (i), (val))\n# define sk_MEM_OBJECT_DATA_zero(st) SKM_sk_zero(MEM_OBJECT_DATA, (st))\n# define sk_MEM_OBJECT_DATA_push(st, val) SKM_sk_push(MEM_OBJECT_DATA, (st), (val))\n# define sk_MEM_OBJECT_DATA_unshift(st, val) SKM_sk_unshift(MEM_OBJECT_DATA, (st), (val))\n# define sk_MEM_OBJECT_DATA_find(st, val) SKM_sk_find(MEM_OBJECT_DATA, (st), (val))\n# define sk_MEM_OBJECT_DATA_find_ex(st, val) SKM_sk_find_ex(MEM_OBJECT_DATA, (st), (val))\n# define sk_MEM_OBJECT_DATA_delete(st, i) SKM_sk_delete(MEM_OBJECT_DATA, (st), (i))\n# define sk_MEM_OBJECT_DATA_delete_ptr(st, ptr) SKM_sk_delete_ptr(MEM_OBJECT_DATA, (st), (ptr))\n# define sk_MEM_OBJECT_DATA_insert(st, val, i) SKM_sk_insert(MEM_OBJECT_DATA, (st), (val), (i))\n# define sk_MEM_OBJECT_DATA_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(MEM_OBJECT_DATA, (st), (cmp))\n# define sk_MEM_OBJECT_DATA_dup(st) SKM_sk_dup(MEM_OBJECT_DATA, st)\n# define sk_MEM_OBJECT_DATA_pop_free(st, free_func) SKM_sk_pop_free(MEM_OBJECT_DATA, (st), (free_func))\n# define sk_MEM_OBJECT_DATA_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(MEM_OBJECT_DATA, (st), (copy_func), (free_func))\n# define sk_MEM_OBJECT_DATA_shift(st) SKM_sk_shift(MEM_OBJECT_DATA, (st))\n# define sk_MEM_OBJECT_DATA_pop(st) SKM_sk_pop(MEM_OBJECT_DATA, (st))\n# define sk_MEM_OBJECT_DATA_sort(st) SKM_sk_sort(MEM_OBJECT_DATA, (st))\n# define sk_MEM_OBJECT_DATA_is_sorted(st) SKM_sk_is_sorted(MEM_OBJECT_DATA, (st))\n# define sk_MIME_HEADER_new(cmp) SKM_sk_new(MIME_HEADER, (cmp))\n# define sk_MIME_HEADER_new_null() SKM_sk_new_null(MIME_HEADER)\n# define sk_MIME_HEADER_free(st) SKM_sk_free(MIME_HEADER, (st))\n# define sk_MIME_HEADER_num(st) SKM_sk_num(MIME_HEADER, (st))\n# define sk_MIME_HEADER_value(st, i) SKM_sk_value(MIME_HEADER, (st), (i))\n# define sk_MIME_HEADER_set(st, i, val) SKM_sk_set(MIME_HEADER, (st), (i), (val))\n# define sk_MIME_HEADER_zero(st) SKM_sk_zero(MIME_HEADER, (st))\n# define sk_MIME_HEADER_push(st, val) SKM_sk_push(MIME_HEADER, (st), (val))\n# define sk_MIME_HEADER_unshift(st, val) SKM_sk_unshift(MIME_HEADER, (st), (val))\n# define sk_MIME_HEADER_find(st, val) SKM_sk_find(MIME_HEADER, (st), (val))\n# define sk_MIME_HEADER_find_ex(st, val) SKM_sk_find_ex(MIME_HEADER, (st), (val))\n# define sk_MIME_HEADER_delete(st, i) SKM_sk_delete(MIME_HEADER, (st), (i))\n# define sk_MIME_HEADER_delete_ptr(st, ptr) SKM_sk_delete_ptr(MIME_HEADER, (st), (ptr))\n# define sk_MIME_HEADER_insert(st, val, i) SKM_sk_insert(MIME_HEADER, (st), (val), (i))\n# define sk_MIME_HEADER_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(MIME_HEADER, (st), (cmp))\n# define sk_MIME_HEADER_dup(st) SKM_sk_dup(MIME_HEADER, st)\n# define sk_MIME_HEADER_pop_free(st, free_func) SKM_sk_pop_free(MIME_HEADER, (st), (free_func))\n# define sk_MIME_HEADER_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(MIME_HEADER, (st), (copy_func), (free_func))\n# define sk_MIME_HEADER_shift(st) SKM_sk_shift(MIME_HEADER, (st))\n# define sk_MIME_HEADER_pop(st) SKM_sk_pop(MIME_HEADER, (st))\n# define sk_MIME_HEADER_sort(st) SKM_sk_sort(MIME_HEADER, (st))\n# define sk_MIME_HEADER_is_sorted(st) SKM_sk_is_sorted(MIME_HEADER, (st))\n# define sk_MIME_PARAM_new(cmp) SKM_sk_new(MIME_PARAM, (cmp))\n# define sk_MIME_PARAM_new_null() SKM_sk_new_null(MIME_PARAM)\n# define sk_MIME_PARAM_free(st) SKM_sk_free(MIME_PARAM, (st))\n# define sk_MIME_PARAM_num(st) SKM_sk_num(MIME_PARAM, (st))\n# define sk_MIME_PARAM_value(st, i) SKM_sk_value(MIME_PARAM, (st), (i))\n# define sk_MIME_PARAM_set(st, i, val) SKM_sk_set(MIME_PARAM, (st), (i), (val))\n# define sk_MIME_PARAM_zero(st) SKM_sk_zero(MIME_PARAM, (st))\n# define sk_MIME_PARAM_push(st, val) SKM_sk_push(MIME_PARAM, (st), (val))\n# define sk_MIME_PARAM_unshift(st, val) SKM_sk_unshift(MIME_PARAM, (st), (val))\n# define sk_MIME_PARAM_find(st, val) SKM_sk_find(MIME_PARAM, (st), (val))\n# define sk_MIME_PARAM_find_ex(st, val) SKM_sk_find_ex(MIME_PARAM, (st), (val))\n# define sk_MIME_PARAM_delete(st, i) SKM_sk_delete(MIME_PARAM, (st), (i))\n# define sk_MIME_PARAM_delete_ptr(st, ptr) SKM_sk_delete_ptr(MIME_PARAM, (st), (ptr))\n# define sk_MIME_PARAM_insert(st, val, i) SKM_sk_insert(MIME_PARAM, (st), (val), (i))\n# define sk_MIME_PARAM_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(MIME_PARAM, (st), (cmp))\n# define sk_MIME_PARAM_dup(st) SKM_sk_dup(MIME_PARAM, st)\n# define sk_MIME_PARAM_pop_free(st, free_func) SKM_sk_pop_free(MIME_PARAM, (st), (free_func))\n# define sk_MIME_PARAM_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(MIME_PARAM, (st), (copy_func), (free_func))\n# define sk_MIME_PARAM_shift(st) SKM_sk_shift(MIME_PARAM, (st))\n# define sk_MIME_PARAM_pop(st) SKM_sk_pop(MIME_PARAM, (st))\n# define sk_MIME_PARAM_sort(st) SKM_sk_sort(MIME_PARAM, (st))\n# define sk_MIME_PARAM_is_sorted(st) SKM_sk_is_sorted(MIME_PARAM, (st))\n# define sk_NAME_FUNCS_new(cmp) SKM_sk_new(NAME_FUNCS, (cmp))\n# define sk_NAME_FUNCS_new_null() SKM_sk_new_null(NAME_FUNCS)\n# define sk_NAME_FUNCS_free(st) SKM_sk_free(NAME_FUNCS, (st))\n# define sk_NAME_FUNCS_num(st) SKM_sk_num(NAME_FUNCS, (st))\n# define sk_NAME_FUNCS_value(st, i) SKM_sk_value(NAME_FUNCS, (st), (i))\n# define sk_NAME_FUNCS_set(st, i, val) SKM_sk_set(NAME_FUNCS, (st), (i), (val))\n# define sk_NAME_FUNCS_zero(st) SKM_sk_zero(NAME_FUNCS, (st))\n# define sk_NAME_FUNCS_push(st, val) SKM_sk_push(NAME_FUNCS, (st), (val))\n# define sk_NAME_FUNCS_unshift(st, val) SKM_sk_unshift(NAME_FUNCS, (st), (val))\n# define sk_NAME_FUNCS_find(st, val) SKM_sk_find(NAME_FUNCS, (st), (val))\n# define sk_NAME_FUNCS_find_ex(st, val) SKM_sk_find_ex(NAME_FUNCS, (st), (val))\n# define sk_NAME_FUNCS_delete(st, i) SKM_sk_delete(NAME_FUNCS, (st), (i))\n# define sk_NAME_FUNCS_delete_ptr(st, ptr) SKM_sk_delete_ptr(NAME_FUNCS, (st), (ptr))\n# define sk_NAME_FUNCS_insert(st, val, i) SKM_sk_insert(NAME_FUNCS, (st), (val), (i))\n# define sk_NAME_FUNCS_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(NAME_FUNCS, (st), (cmp))\n# define sk_NAME_FUNCS_dup(st) SKM_sk_dup(NAME_FUNCS, st)\n# define sk_NAME_FUNCS_pop_free(st, free_func) SKM_sk_pop_free(NAME_FUNCS, (st), (free_func))\n# define sk_NAME_FUNCS_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(NAME_FUNCS, (st), (copy_func), (free_func))\n# define sk_NAME_FUNCS_shift(st) SKM_sk_shift(NAME_FUNCS, (st))\n# define sk_NAME_FUNCS_pop(st) SKM_sk_pop(NAME_FUNCS, (st))\n# define sk_NAME_FUNCS_sort(st) SKM_sk_sort(NAME_FUNCS, (st))\n# define sk_NAME_FUNCS_is_sorted(st) SKM_sk_is_sorted(NAME_FUNCS, (st))\n# define sk_OCSP_CERTID_new(cmp) SKM_sk_new(OCSP_CERTID, (cmp))\n# define sk_OCSP_CERTID_new_null() SKM_sk_new_null(OCSP_CERTID)\n# define sk_OCSP_CERTID_free(st) SKM_sk_free(OCSP_CERTID, (st))\n# define sk_OCSP_CERTID_num(st) SKM_sk_num(OCSP_CERTID, (st))\n# define sk_OCSP_CERTID_value(st, i) SKM_sk_value(OCSP_CERTID, (st), (i))\n# define sk_OCSP_CERTID_set(st, i, val) SKM_sk_set(OCSP_CERTID, (st), (i), (val))\n# define sk_OCSP_CERTID_zero(st) SKM_sk_zero(OCSP_CERTID, (st))\n# define sk_OCSP_CERTID_push(st, val) SKM_sk_push(OCSP_CERTID, (st), (val))\n# define sk_OCSP_CERTID_unshift(st, val) SKM_sk_unshift(OCSP_CERTID, (st), (val))\n# define sk_OCSP_CERTID_find(st, val) SKM_sk_find(OCSP_CERTID, (st), (val))\n# define sk_OCSP_CERTID_find_ex(st, val) SKM_sk_find_ex(OCSP_CERTID, (st), (val))\n# define sk_OCSP_CERTID_delete(st, i) SKM_sk_delete(OCSP_CERTID, (st), (i))\n# define sk_OCSP_CERTID_delete_ptr(st, ptr) SKM_sk_delete_ptr(OCSP_CERTID, (st), (ptr))\n# define sk_OCSP_CERTID_insert(st, val, i) SKM_sk_insert(OCSP_CERTID, (st), (val), (i))\n# define sk_OCSP_CERTID_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(OCSP_CERTID, (st), (cmp))\n# define sk_OCSP_CERTID_dup(st) SKM_sk_dup(OCSP_CERTID, st)\n# define sk_OCSP_CERTID_pop_free(st, free_func) SKM_sk_pop_free(OCSP_CERTID, (st), (free_func))\n# define sk_OCSP_CERTID_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(OCSP_CERTID, (st), (copy_func), (free_func))\n# define sk_OCSP_CERTID_shift(st) SKM_sk_shift(OCSP_CERTID, (st))\n# define sk_OCSP_CERTID_pop(st) SKM_sk_pop(OCSP_CERTID, (st))\n# define sk_OCSP_CERTID_sort(st) SKM_sk_sort(OCSP_CERTID, (st))\n# define sk_OCSP_CERTID_is_sorted(st) SKM_sk_is_sorted(OCSP_CERTID, (st))\n# define sk_OCSP_ONEREQ_new(cmp) SKM_sk_new(OCSP_ONEREQ, (cmp))\n# define sk_OCSP_ONEREQ_new_null() SKM_sk_new_null(OCSP_ONEREQ)\n# define sk_OCSP_ONEREQ_free(st) SKM_sk_free(OCSP_ONEREQ, (st))\n# define sk_OCSP_ONEREQ_num(st) SKM_sk_num(OCSP_ONEREQ, (st))\n# define sk_OCSP_ONEREQ_value(st, i) SKM_sk_value(OCSP_ONEREQ, (st), (i))\n# define sk_OCSP_ONEREQ_set(st, i, val) SKM_sk_set(OCSP_ONEREQ, (st), (i), (val))\n# define sk_OCSP_ONEREQ_zero(st) SKM_sk_zero(OCSP_ONEREQ, (st))\n# define sk_OCSP_ONEREQ_push(st, val) SKM_sk_push(OCSP_ONEREQ, (st), (val))\n# define sk_OCSP_ONEREQ_unshift(st, val) SKM_sk_unshift(OCSP_ONEREQ, (st), (val))\n# define sk_OCSP_ONEREQ_find(st, val) SKM_sk_find(OCSP_ONEREQ, (st), (val))\n# define sk_OCSP_ONEREQ_find_ex(st, val) SKM_sk_find_ex(OCSP_ONEREQ, (st), (val))\n# define sk_OCSP_ONEREQ_delete(st, i) SKM_sk_delete(OCSP_ONEREQ, (st), (i))\n# define sk_OCSP_ONEREQ_delete_ptr(st, ptr) SKM_sk_delete_ptr(OCSP_ONEREQ, (st), (ptr))\n# define sk_OCSP_ONEREQ_insert(st, val, i) SKM_sk_insert(OCSP_ONEREQ, (st), (val), (i))\n# define sk_OCSP_ONEREQ_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(OCSP_ONEREQ, (st), (cmp))\n# define sk_OCSP_ONEREQ_dup(st) SKM_sk_dup(OCSP_ONEREQ, st)\n# define sk_OCSP_ONEREQ_pop_free(st, free_func) SKM_sk_pop_free(OCSP_ONEREQ, (st), (free_func))\n# define sk_OCSP_ONEREQ_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(OCSP_ONEREQ, (st), (copy_func), (free_func))\n# define sk_OCSP_ONEREQ_shift(st) SKM_sk_shift(OCSP_ONEREQ, (st))\n# define sk_OCSP_ONEREQ_pop(st) SKM_sk_pop(OCSP_ONEREQ, (st))\n# define sk_OCSP_ONEREQ_sort(st) SKM_sk_sort(OCSP_ONEREQ, (st))\n# define sk_OCSP_ONEREQ_is_sorted(st) SKM_sk_is_sorted(OCSP_ONEREQ, (st))\n# define sk_OCSP_RESPID_new(cmp) SKM_sk_new(OCSP_RESPID, (cmp))\n# define sk_OCSP_RESPID_new_null() SKM_sk_new_null(OCSP_RESPID)\n# define sk_OCSP_RESPID_free(st) SKM_sk_free(OCSP_RESPID, (st))\n# define sk_OCSP_RESPID_num(st) SKM_sk_num(OCSP_RESPID, (st))\n# define sk_OCSP_RESPID_value(st, i) SKM_sk_value(OCSP_RESPID, (st), (i))\n# define sk_OCSP_RESPID_set(st, i, val) SKM_sk_set(OCSP_RESPID, (st), (i), (val))\n# define sk_OCSP_RESPID_zero(st) SKM_sk_zero(OCSP_RESPID, (st))\n# define sk_OCSP_RESPID_push(st, val) SKM_sk_push(OCSP_RESPID, (st), (val))\n# define sk_OCSP_RESPID_unshift(st, val) SKM_sk_unshift(OCSP_RESPID, (st), (val))\n# define sk_OCSP_RESPID_find(st, val) SKM_sk_find(OCSP_RESPID, (st), (val))\n# define sk_OCSP_RESPID_find_ex(st, val) SKM_sk_find_ex(OCSP_RESPID, (st), (val))\n# define sk_OCSP_RESPID_delete(st, i) SKM_sk_delete(OCSP_RESPID, (st), (i))\n# define sk_OCSP_RESPID_delete_ptr(st, ptr) SKM_sk_delete_ptr(OCSP_RESPID, (st), (ptr))\n# define sk_OCSP_RESPID_insert(st, val, i) SKM_sk_insert(OCSP_RESPID, (st), (val), (i))\n# define sk_OCSP_RESPID_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(OCSP_RESPID, (st), (cmp))\n# define sk_OCSP_RESPID_dup(st) SKM_sk_dup(OCSP_RESPID, st)\n# define sk_OCSP_RESPID_pop_free(st, free_func) SKM_sk_pop_free(OCSP_RESPID, (st), (free_func))\n# define sk_OCSP_RESPID_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(OCSP_RESPID, (st), (copy_func), (free_func))\n# define sk_OCSP_RESPID_shift(st) SKM_sk_shift(OCSP_RESPID, (st))\n# define sk_OCSP_RESPID_pop(st) SKM_sk_pop(OCSP_RESPID, (st))\n# define sk_OCSP_RESPID_sort(st) SKM_sk_sort(OCSP_RESPID, (st))\n# define sk_OCSP_RESPID_is_sorted(st) SKM_sk_is_sorted(OCSP_RESPID, (st))\n# define sk_OCSP_SINGLERESP_new(cmp) SKM_sk_new(OCSP_SINGLERESP, (cmp))\n# define sk_OCSP_SINGLERESP_new_null() SKM_sk_new_null(OCSP_SINGLERESP)\n# define sk_OCSP_SINGLERESP_free(st) SKM_sk_free(OCSP_SINGLERESP, (st))\n# define sk_OCSP_SINGLERESP_num(st) SKM_sk_num(OCSP_SINGLERESP, (st))\n# define sk_OCSP_SINGLERESP_value(st, i) SKM_sk_value(OCSP_SINGLERESP, (st), (i))\n# define sk_OCSP_SINGLERESP_set(st, i, val) SKM_sk_set(OCSP_SINGLERESP, (st), (i), (val))\n# define sk_OCSP_SINGLERESP_zero(st) SKM_sk_zero(OCSP_SINGLERESP, (st))\n# define sk_OCSP_SINGLERESP_push(st, val) SKM_sk_push(OCSP_SINGLERESP, (st), (val))\n# define sk_OCSP_SINGLERESP_unshift(st, val) SKM_sk_unshift(OCSP_SINGLERESP, (st), (val))\n# define sk_OCSP_SINGLERESP_find(st, val) SKM_sk_find(OCSP_SINGLERESP, (st), (val))\n# define sk_OCSP_SINGLERESP_find_ex(st, val) SKM_sk_find_ex(OCSP_SINGLERESP, (st), (val))\n# define sk_OCSP_SINGLERESP_delete(st, i) SKM_sk_delete(OCSP_SINGLERESP, (st), (i))\n# define sk_OCSP_SINGLERESP_delete_ptr(st, ptr) SKM_sk_delete_ptr(OCSP_SINGLERESP, (st), (ptr))\n# define sk_OCSP_SINGLERESP_insert(st, val, i) SKM_sk_insert(OCSP_SINGLERESP, (st), (val), (i))\n# define sk_OCSP_SINGLERESP_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(OCSP_SINGLERESP, (st), (cmp))\n# define sk_OCSP_SINGLERESP_dup(st) SKM_sk_dup(OCSP_SINGLERESP, st)\n# define sk_OCSP_SINGLERESP_pop_free(st, free_func) SKM_sk_pop_free(OCSP_SINGLERESP, (st), (free_func))\n# define sk_OCSP_SINGLERESP_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(OCSP_SINGLERESP, (st), (copy_func), (free_func))\n# define sk_OCSP_SINGLERESP_shift(st) SKM_sk_shift(OCSP_SINGLERESP, (st))\n# define sk_OCSP_SINGLERESP_pop(st) SKM_sk_pop(OCSP_SINGLERESP, (st))\n# define sk_OCSP_SINGLERESP_sort(st) SKM_sk_sort(OCSP_SINGLERESP, (st))\n# define sk_OCSP_SINGLERESP_is_sorted(st) SKM_sk_is_sorted(OCSP_SINGLERESP, (st))\n# define sk_PKCS12_SAFEBAG_new(cmp) SKM_sk_new(PKCS12_SAFEBAG, (cmp))\n# define sk_PKCS12_SAFEBAG_new_null() SKM_sk_new_null(PKCS12_SAFEBAG)\n# define sk_PKCS12_SAFEBAG_free(st) SKM_sk_free(PKCS12_SAFEBAG, (st))\n# define sk_PKCS12_SAFEBAG_num(st) SKM_sk_num(PKCS12_SAFEBAG, (st))\n# define sk_PKCS12_SAFEBAG_value(st, i) SKM_sk_value(PKCS12_SAFEBAG, (st), (i))\n# define sk_PKCS12_SAFEBAG_set(st, i, val) SKM_sk_set(PKCS12_SAFEBAG, (st), (i), (val))\n# define sk_PKCS12_SAFEBAG_zero(st) SKM_sk_zero(PKCS12_SAFEBAG, (st))\n# define sk_PKCS12_SAFEBAG_push(st, val) SKM_sk_push(PKCS12_SAFEBAG, (st), (val))\n# define sk_PKCS12_SAFEBAG_unshift(st, val) SKM_sk_unshift(PKCS12_SAFEBAG, (st), (val))\n# define sk_PKCS12_SAFEBAG_find(st, val) SKM_sk_find(PKCS12_SAFEBAG, (st), (val))\n# define sk_PKCS12_SAFEBAG_find_ex(st, val) SKM_sk_find_ex(PKCS12_SAFEBAG, (st), (val))\n# define sk_PKCS12_SAFEBAG_delete(st, i) SKM_sk_delete(PKCS12_SAFEBAG, (st), (i))\n# define sk_PKCS12_SAFEBAG_delete_ptr(st, ptr) SKM_sk_delete_ptr(PKCS12_SAFEBAG, (st), (ptr))\n# define sk_PKCS12_SAFEBAG_insert(st, val, i) SKM_sk_insert(PKCS12_SAFEBAG, (st), (val), (i))\n# define sk_PKCS12_SAFEBAG_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(PKCS12_SAFEBAG, (st), (cmp))\n# define sk_PKCS12_SAFEBAG_dup(st) SKM_sk_dup(PKCS12_SAFEBAG, st)\n# define sk_PKCS12_SAFEBAG_pop_free(st, free_func) SKM_sk_pop_free(PKCS12_SAFEBAG, (st), (free_func))\n# define sk_PKCS12_SAFEBAG_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(PKCS12_SAFEBAG, (st), (copy_func), (free_func))\n# define sk_PKCS12_SAFEBAG_shift(st) SKM_sk_shift(PKCS12_SAFEBAG, (st))\n# define sk_PKCS12_SAFEBAG_pop(st) SKM_sk_pop(PKCS12_SAFEBAG, (st))\n# define sk_PKCS12_SAFEBAG_sort(st) SKM_sk_sort(PKCS12_SAFEBAG, (st))\n# define sk_PKCS12_SAFEBAG_is_sorted(st) SKM_sk_is_sorted(PKCS12_SAFEBAG, (st))\n# define sk_PKCS7_new(cmp) SKM_sk_new(PKCS7, (cmp))\n# define sk_PKCS7_new_null() SKM_sk_new_null(PKCS7)\n# define sk_PKCS7_free(st) SKM_sk_free(PKCS7, (st))\n# define sk_PKCS7_num(st) SKM_sk_num(PKCS7, (st))\n# define sk_PKCS7_value(st, i) SKM_sk_value(PKCS7, (st), (i))\n# define sk_PKCS7_set(st, i, val) SKM_sk_set(PKCS7, (st), (i), (val))\n# define sk_PKCS7_zero(st) SKM_sk_zero(PKCS7, (st))\n# define sk_PKCS7_push(st, val) SKM_sk_push(PKCS7, (st), (val))\n# define sk_PKCS7_unshift(st, val) SKM_sk_unshift(PKCS7, (st), (val))\n# define sk_PKCS7_find(st, val) SKM_sk_find(PKCS7, (st), (val))\n# define sk_PKCS7_find_ex(st, val) SKM_sk_find_ex(PKCS7, (st), (val))\n# define sk_PKCS7_delete(st, i) SKM_sk_delete(PKCS7, (st), (i))\n# define sk_PKCS7_delete_ptr(st, ptr) SKM_sk_delete_ptr(PKCS7, (st), (ptr))\n# define sk_PKCS7_insert(st, val, i) SKM_sk_insert(PKCS7, (st), (val), (i))\n# define sk_PKCS7_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(PKCS7, (st), (cmp))\n# define sk_PKCS7_dup(st) SKM_sk_dup(PKCS7, st)\n# define sk_PKCS7_pop_free(st, free_func) SKM_sk_pop_free(PKCS7, (st), (free_func))\n# define sk_PKCS7_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(PKCS7, (st), (copy_func), (free_func))\n# define sk_PKCS7_shift(st) SKM_sk_shift(PKCS7, (st))\n# define sk_PKCS7_pop(st) SKM_sk_pop(PKCS7, (st))\n# define sk_PKCS7_sort(st) SKM_sk_sort(PKCS7, (st))\n# define sk_PKCS7_is_sorted(st) SKM_sk_is_sorted(PKCS7, (st))\n# define sk_PKCS7_RECIP_INFO_new(cmp) SKM_sk_new(PKCS7_RECIP_INFO, (cmp))\n# define sk_PKCS7_RECIP_INFO_new_null() SKM_sk_new_null(PKCS7_RECIP_INFO)\n# define sk_PKCS7_RECIP_INFO_free(st) SKM_sk_free(PKCS7_RECIP_INFO, (st))\n# define sk_PKCS7_RECIP_INFO_num(st) SKM_sk_num(PKCS7_RECIP_INFO, (st))\n# define sk_PKCS7_RECIP_INFO_value(st, i) SKM_sk_value(PKCS7_RECIP_INFO, (st), (i))\n# define sk_PKCS7_RECIP_INFO_set(st, i, val) SKM_sk_set(PKCS7_RECIP_INFO, (st), (i), (val))\n# define sk_PKCS7_RECIP_INFO_zero(st) SKM_sk_zero(PKCS7_RECIP_INFO, (st))\n# define sk_PKCS7_RECIP_INFO_push(st, val) SKM_sk_push(PKCS7_RECIP_INFO, (st), (val))\n# define sk_PKCS7_RECIP_INFO_unshift(st, val) SKM_sk_unshift(PKCS7_RECIP_INFO, (st), (val))\n# define sk_PKCS7_RECIP_INFO_find(st, val) SKM_sk_find(PKCS7_RECIP_INFO, (st), (val))\n# define sk_PKCS7_RECIP_INFO_find_ex(st, val) SKM_sk_find_ex(PKCS7_RECIP_INFO, (st), (val))\n# define sk_PKCS7_RECIP_INFO_delete(st, i) SKM_sk_delete(PKCS7_RECIP_INFO, (st), (i))\n# define sk_PKCS7_RECIP_INFO_delete_ptr(st, ptr) SKM_sk_delete_ptr(PKCS7_RECIP_INFO, (st), (ptr))\n# define sk_PKCS7_RECIP_INFO_insert(st, val, i) SKM_sk_insert(PKCS7_RECIP_INFO, (st), (val), (i))\n# define sk_PKCS7_RECIP_INFO_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(PKCS7_RECIP_INFO, (st), (cmp))\n# define sk_PKCS7_RECIP_INFO_dup(st) SKM_sk_dup(PKCS7_RECIP_INFO, st)\n# define sk_PKCS7_RECIP_INFO_pop_free(st, free_func) SKM_sk_pop_free(PKCS7_RECIP_INFO, (st), (free_func))\n# define sk_PKCS7_RECIP_INFO_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(PKCS7_RECIP_INFO, (st), (copy_func), (free_func))\n# define sk_PKCS7_RECIP_INFO_shift(st) SKM_sk_shift(PKCS7_RECIP_INFO, (st))\n# define sk_PKCS7_RECIP_INFO_pop(st) SKM_sk_pop(PKCS7_RECIP_INFO, (st))\n# define sk_PKCS7_RECIP_INFO_sort(st) SKM_sk_sort(PKCS7_RECIP_INFO, (st))\n# define sk_PKCS7_RECIP_INFO_is_sorted(st) SKM_sk_is_sorted(PKCS7_RECIP_INFO, (st))\n# define sk_PKCS7_SIGNER_INFO_new(cmp) SKM_sk_new(PKCS7_SIGNER_INFO, (cmp))\n# define sk_PKCS7_SIGNER_INFO_new_null() SKM_sk_new_null(PKCS7_SIGNER_INFO)\n# define sk_PKCS7_SIGNER_INFO_free(st) SKM_sk_free(PKCS7_SIGNER_INFO, (st))\n# define sk_PKCS7_SIGNER_INFO_num(st) SKM_sk_num(PKCS7_SIGNER_INFO, (st))\n# define sk_PKCS7_SIGNER_INFO_value(st, i) SKM_sk_value(PKCS7_SIGNER_INFO, (st), (i))\n# define sk_PKCS7_SIGNER_INFO_set(st, i, val) SKM_sk_set(PKCS7_SIGNER_INFO, (st), (i), (val))\n# define sk_PKCS7_SIGNER_INFO_zero(st) SKM_sk_zero(PKCS7_SIGNER_INFO, (st))\n# define sk_PKCS7_SIGNER_INFO_push(st, val) SKM_sk_push(PKCS7_SIGNER_INFO, (st), (val))\n# define sk_PKCS7_SIGNER_INFO_unshift(st, val) SKM_sk_unshift(PKCS7_SIGNER_INFO, (st), (val))\n# define sk_PKCS7_SIGNER_INFO_find(st, val) SKM_sk_find(PKCS7_SIGNER_INFO, (st), (val))\n# define sk_PKCS7_SIGNER_INFO_find_ex(st, val) SKM_sk_find_ex(PKCS7_SIGNER_INFO, (st), (val))\n# define sk_PKCS7_SIGNER_INFO_delete(st, i) SKM_sk_delete(PKCS7_SIGNER_INFO, (st), (i))\n# define sk_PKCS7_SIGNER_INFO_delete_ptr(st, ptr) SKM_sk_delete_ptr(PKCS7_SIGNER_INFO, (st), (ptr))\n# define sk_PKCS7_SIGNER_INFO_insert(st, val, i) SKM_sk_insert(PKCS7_SIGNER_INFO, (st), (val), (i))\n# define sk_PKCS7_SIGNER_INFO_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(PKCS7_SIGNER_INFO, (st), (cmp))\n# define sk_PKCS7_SIGNER_INFO_dup(st) SKM_sk_dup(PKCS7_SIGNER_INFO, st)\n# define sk_PKCS7_SIGNER_INFO_pop_free(st, free_func) SKM_sk_pop_free(PKCS7_SIGNER_INFO, (st), (free_func))\n# define sk_PKCS7_SIGNER_INFO_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(PKCS7_SIGNER_INFO, (st), (copy_func), (free_func))\n# define sk_PKCS7_SIGNER_INFO_shift(st) SKM_sk_shift(PKCS7_SIGNER_INFO, (st))\n# define sk_PKCS7_SIGNER_INFO_pop(st) SKM_sk_pop(PKCS7_SIGNER_INFO, (st))\n# define sk_PKCS7_SIGNER_INFO_sort(st) SKM_sk_sort(PKCS7_SIGNER_INFO, (st))\n# define sk_PKCS7_SIGNER_INFO_is_sorted(st) SKM_sk_is_sorted(PKCS7_SIGNER_INFO, (st))\n# define sk_POLICYINFO_new(cmp) SKM_sk_new(POLICYINFO, (cmp))\n# define sk_POLICYINFO_new_null() SKM_sk_new_null(POLICYINFO)\n# define sk_POLICYINFO_free(st) SKM_sk_free(POLICYINFO, (st))\n# define sk_POLICYINFO_num(st) SKM_sk_num(POLICYINFO, (st))\n# define sk_POLICYINFO_value(st, i) SKM_sk_value(POLICYINFO, (st), (i))\n# define sk_POLICYINFO_set(st, i, val) SKM_sk_set(POLICYINFO, (st), (i), (val))\n# define sk_POLICYINFO_zero(st) SKM_sk_zero(POLICYINFO, (st))\n# define sk_POLICYINFO_push(st, val) SKM_sk_push(POLICYINFO, (st), (val))\n# define sk_POLICYINFO_unshift(st, val) SKM_sk_unshift(POLICYINFO, (st), (val))\n# define sk_POLICYINFO_find(st, val) SKM_sk_find(POLICYINFO, (st), (val))\n# define sk_POLICYINFO_find_ex(st, val) SKM_sk_find_ex(POLICYINFO, (st), (val))\n# define sk_POLICYINFO_delete(st, i) SKM_sk_delete(POLICYINFO, (st), (i))\n# define sk_POLICYINFO_delete_ptr(st, ptr) SKM_sk_delete_ptr(POLICYINFO, (st), (ptr))\n# define sk_POLICYINFO_insert(st, val, i) SKM_sk_insert(POLICYINFO, (st), (val), (i))\n# define sk_POLICYINFO_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(POLICYINFO, (st), (cmp))\n# define sk_POLICYINFO_dup(st) SKM_sk_dup(POLICYINFO, st)\n# define sk_POLICYINFO_pop_free(st, free_func) SKM_sk_pop_free(POLICYINFO, (st), (free_func))\n# define sk_POLICYINFO_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(POLICYINFO, (st), (copy_func), (free_func))\n# define sk_POLICYINFO_shift(st) SKM_sk_shift(POLICYINFO, (st))\n# define sk_POLICYINFO_pop(st) SKM_sk_pop(POLICYINFO, (st))\n# define sk_POLICYINFO_sort(st) SKM_sk_sort(POLICYINFO, (st))\n# define sk_POLICYINFO_is_sorted(st) SKM_sk_is_sorted(POLICYINFO, (st))\n# define sk_POLICYQUALINFO_new(cmp) SKM_sk_new(POLICYQUALINFO, (cmp))\n# define sk_POLICYQUALINFO_new_null() SKM_sk_new_null(POLICYQUALINFO)\n# define sk_POLICYQUALINFO_free(st) SKM_sk_free(POLICYQUALINFO, (st))\n# define sk_POLICYQUALINFO_num(st) SKM_sk_num(POLICYQUALINFO, (st))\n# define sk_POLICYQUALINFO_value(st, i) SKM_sk_value(POLICYQUALINFO, (st), (i))\n# define sk_POLICYQUALINFO_set(st, i, val) SKM_sk_set(POLICYQUALINFO, (st), (i), (val))\n# define sk_POLICYQUALINFO_zero(st) SKM_sk_zero(POLICYQUALINFO, (st))\n# define sk_POLICYQUALINFO_push(st, val) SKM_sk_push(POLICYQUALINFO, (st), (val))\n# define sk_POLICYQUALINFO_unshift(st, val) SKM_sk_unshift(POLICYQUALINFO, (st), (val))\n# define sk_POLICYQUALINFO_find(st, val) SKM_sk_find(POLICYQUALINFO, (st), (val))\n# define sk_POLICYQUALINFO_find_ex(st, val) SKM_sk_find_ex(POLICYQUALINFO, (st), (val))\n# define sk_POLICYQUALINFO_delete(st, i) SKM_sk_delete(POLICYQUALINFO, (st), (i))\n# define sk_POLICYQUALINFO_delete_ptr(st, ptr) SKM_sk_delete_ptr(POLICYQUALINFO, (st), (ptr))\n# define sk_POLICYQUALINFO_insert(st, val, i) SKM_sk_insert(POLICYQUALINFO, (st), (val), (i))\n# define sk_POLICYQUALINFO_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(POLICYQUALINFO, (st), (cmp))\n# define sk_POLICYQUALINFO_dup(st) SKM_sk_dup(POLICYQUALINFO, st)\n# define sk_POLICYQUALINFO_pop_free(st, free_func) SKM_sk_pop_free(POLICYQUALINFO, (st), (free_func))\n# define sk_POLICYQUALINFO_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(POLICYQUALINFO, (st), (copy_func), (free_func))\n# define sk_POLICYQUALINFO_shift(st) SKM_sk_shift(POLICYQUALINFO, (st))\n# define sk_POLICYQUALINFO_pop(st) SKM_sk_pop(POLICYQUALINFO, (st))\n# define sk_POLICYQUALINFO_sort(st) SKM_sk_sort(POLICYQUALINFO, (st))\n# define sk_POLICYQUALINFO_is_sorted(st) SKM_sk_is_sorted(POLICYQUALINFO, (st))\n# define sk_POLICY_MAPPING_new(cmp) SKM_sk_new(POLICY_MAPPING, (cmp))\n# define sk_POLICY_MAPPING_new_null() SKM_sk_new_null(POLICY_MAPPING)\n# define sk_POLICY_MAPPING_free(st) SKM_sk_free(POLICY_MAPPING, (st))\n# define sk_POLICY_MAPPING_num(st) SKM_sk_num(POLICY_MAPPING, (st))\n# define sk_POLICY_MAPPING_value(st, i) SKM_sk_value(POLICY_MAPPING, (st), (i))\n# define sk_POLICY_MAPPING_set(st, i, val) SKM_sk_set(POLICY_MAPPING, (st), (i), (val))\n# define sk_POLICY_MAPPING_zero(st) SKM_sk_zero(POLICY_MAPPING, (st))\n# define sk_POLICY_MAPPING_push(st, val) SKM_sk_push(POLICY_MAPPING, (st), (val))\n# define sk_POLICY_MAPPING_unshift(st, val) SKM_sk_unshift(POLICY_MAPPING, (st), (val))\n# define sk_POLICY_MAPPING_find(st, val) SKM_sk_find(POLICY_MAPPING, (st), (val))\n# define sk_POLICY_MAPPING_find_ex(st, val) SKM_sk_find_ex(POLICY_MAPPING, (st), (val))\n# define sk_POLICY_MAPPING_delete(st, i) SKM_sk_delete(POLICY_MAPPING, (st), (i))\n# define sk_POLICY_MAPPING_delete_ptr(st, ptr) SKM_sk_delete_ptr(POLICY_MAPPING, (st), (ptr))\n# define sk_POLICY_MAPPING_insert(st, val, i) SKM_sk_insert(POLICY_MAPPING, (st), (val), (i))\n# define sk_POLICY_MAPPING_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(POLICY_MAPPING, (st), (cmp))\n# define sk_POLICY_MAPPING_dup(st) SKM_sk_dup(POLICY_MAPPING, st)\n# define sk_POLICY_MAPPING_pop_free(st, free_func) SKM_sk_pop_free(POLICY_MAPPING, (st), (free_func))\n# define sk_POLICY_MAPPING_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(POLICY_MAPPING, (st), (copy_func), (free_func))\n# define sk_POLICY_MAPPING_shift(st) SKM_sk_shift(POLICY_MAPPING, (st))\n# define sk_POLICY_MAPPING_pop(st) SKM_sk_pop(POLICY_MAPPING, (st))\n# define sk_POLICY_MAPPING_sort(st) SKM_sk_sort(POLICY_MAPPING, (st))\n# define sk_POLICY_MAPPING_is_sorted(st) SKM_sk_is_sorted(POLICY_MAPPING, (st))\n# define sk_SCT_new(cmp) SKM_sk_new(SCT, (cmp))\n# define sk_SCT_new_null() SKM_sk_new_null(SCT)\n# define sk_SCT_free(st) SKM_sk_free(SCT, (st))\n# define sk_SCT_num(st) SKM_sk_num(SCT, (st))\n# define sk_SCT_value(st, i) SKM_sk_value(SCT, (st), (i))\n# define sk_SCT_set(st, i, val) SKM_sk_set(SCT, (st), (i), (val))\n# define sk_SCT_zero(st) SKM_sk_zero(SCT, (st))\n# define sk_SCT_push(st, val) SKM_sk_push(SCT, (st), (val))\n# define sk_SCT_unshift(st, val) SKM_sk_unshift(SCT, (st), (val))\n# define sk_SCT_find(st, val) SKM_sk_find(SCT, (st), (val))\n# define sk_SCT_find_ex(st, val) SKM_sk_find_ex(SCT, (st), (val))\n# define sk_SCT_delete(st, i) SKM_sk_delete(SCT, (st), (i))\n# define sk_SCT_delete_ptr(st, ptr) SKM_sk_delete_ptr(SCT, (st), (ptr))\n# define sk_SCT_insert(st, val, i) SKM_sk_insert(SCT, (st), (val), (i))\n# define sk_SCT_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(SCT, (st), (cmp))\n# define sk_SCT_dup(st) SKM_sk_dup(SCT, st)\n# define sk_SCT_pop_free(st, free_func) SKM_sk_pop_free(SCT, (st), (free_func))\n# define sk_SCT_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(SCT, (st), (copy_func), (free_func))\n# define sk_SCT_shift(st) SKM_sk_shift(SCT, (st))\n# define sk_SCT_pop(st) SKM_sk_pop(SCT, (st))\n# define sk_SCT_sort(st) SKM_sk_sort(SCT, (st))\n# define sk_SCT_is_sorted(st) SKM_sk_is_sorted(SCT, (st))\n# define sk_SRP_gN_new(cmp) SKM_sk_new(SRP_gN, (cmp))\n# define sk_SRP_gN_new_null() SKM_sk_new_null(SRP_gN)\n# define sk_SRP_gN_free(st) SKM_sk_free(SRP_gN, (st))\n# define sk_SRP_gN_num(st) SKM_sk_num(SRP_gN, (st))\n# define sk_SRP_gN_value(st, i) SKM_sk_value(SRP_gN, (st), (i))\n# define sk_SRP_gN_set(st, i, val) SKM_sk_set(SRP_gN, (st), (i), (val))\n# define sk_SRP_gN_zero(st) SKM_sk_zero(SRP_gN, (st))\n# define sk_SRP_gN_push(st, val) SKM_sk_push(SRP_gN, (st), (val))\n# define sk_SRP_gN_unshift(st, val) SKM_sk_unshift(SRP_gN, (st), (val))\n# define sk_SRP_gN_find(st, val) SKM_sk_find(SRP_gN, (st), (val))\n# define sk_SRP_gN_find_ex(st, val) SKM_sk_find_ex(SRP_gN, (st), (val))\n# define sk_SRP_gN_delete(st, i) SKM_sk_delete(SRP_gN, (st), (i))\n# define sk_SRP_gN_delete_ptr(st, ptr) SKM_sk_delete_ptr(SRP_gN, (st), (ptr))\n# define sk_SRP_gN_insert(st, val, i) SKM_sk_insert(SRP_gN, (st), (val), (i))\n# define sk_SRP_gN_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(SRP_gN, (st), (cmp))\n# define sk_SRP_gN_dup(st) SKM_sk_dup(SRP_gN, st)\n# define sk_SRP_gN_pop_free(st, free_func) SKM_sk_pop_free(SRP_gN, (st), (free_func))\n# define sk_SRP_gN_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(SRP_gN, (st), (copy_func), (free_func))\n# define sk_SRP_gN_shift(st) SKM_sk_shift(SRP_gN, (st))\n# define sk_SRP_gN_pop(st) SKM_sk_pop(SRP_gN, (st))\n# define sk_SRP_gN_sort(st) SKM_sk_sort(SRP_gN, (st))\n# define sk_SRP_gN_is_sorted(st) SKM_sk_is_sorted(SRP_gN, (st))\n# define sk_SRP_gN_cache_new(cmp) SKM_sk_new(SRP_gN_cache, (cmp))\n# define sk_SRP_gN_cache_new_null() SKM_sk_new_null(SRP_gN_cache)\n# define sk_SRP_gN_cache_free(st) SKM_sk_free(SRP_gN_cache, (st))\n# define sk_SRP_gN_cache_num(st) SKM_sk_num(SRP_gN_cache, (st))\n# define sk_SRP_gN_cache_value(st, i) SKM_sk_value(SRP_gN_cache, (st), (i))\n# define sk_SRP_gN_cache_set(st, i, val) SKM_sk_set(SRP_gN_cache, (st), (i), (val))\n# define sk_SRP_gN_cache_zero(st) SKM_sk_zero(SRP_gN_cache, (st))\n# define sk_SRP_gN_cache_push(st, val) SKM_sk_push(SRP_gN_cache, (st), (val))\n# define sk_SRP_gN_cache_unshift(st, val) SKM_sk_unshift(SRP_gN_cache, (st), (val))\n# define sk_SRP_gN_cache_find(st, val) SKM_sk_find(SRP_gN_cache, (st), (val))\n# define sk_SRP_gN_cache_find_ex(st, val) SKM_sk_find_ex(SRP_gN_cache, (st), (val))\n# define sk_SRP_gN_cache_delete(st, i) SKM_sk_delete(SRP_gN_cache, (st), (i))\n# define sk_SRP_gN_cache_delete_ptr(st, ptr) SKM_sk_delete_ptr(SRP_gN_cache, (st), (ptr))\n# define sk_SRP_gN_cache_insert(st, val, i) SKM_sk_insert(SRP_gN_cache, (st), (val), (i))\n# define sk_SRP_gN_cache_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(SRP_gN_cache, (st), (cmp))\n# define sk_SRP_gN_cache_dup(st) SKM_sk_dup(SRP_gN_cache, st)\n# define sk_SRP_gN_cache_pop_free(st, free_func) SKM_sk_pop_free(SRP_gN_cache, (st), (free_func))\n# define sk_SRP_gN_cache_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(SRP_gN_cache, (st), (copy_func), (free_func))\n# define sk_SRP_gN_cache_shift(st) SKM_sk_shift(SRP_gN_cache, (st))\n# define sk_SRP_gN_cache_pop(st) SKM_sk_pop(SRP_gN_cache, (st))\n# define sk_SRP_gN_cache_sort(st) SKM_sk_sort(SRP_gN_cache, (st))\n# define sk_SRP_gN_cache_is_sorted(st) SKM_sk_is_sorted(SRP_gN_cache, (st))\n# define sk_SRP_user_pwd_new(cmp) SKM_sk_new(SRP_user_pwd, (cmp))\n# define sk_SRP_user_pwd_new_null() SKM_sk_new_null(SRP_user_pwd)\n# define sk_SRP_user_pwd_free(st) SKM_sk_free(SRP_user_pwd, (st))\n# define sk_SRP_user_pwd_num(st) SKM_sk_num(SRP_user_pwd, (st))\n# define sk_SRP_user_pwd_value(st, i) SKM_sk_value(SRP_user_pwd, (st), (i))\n# define sk_SRP_user_pwd_set(st, i, val) SKM_sk_set(SRP_user_pwd, (st), (i), (val))\n# define sk_SRP_user_pwd_zero(st) SKM_sk_zero(SRP_user_pwd, (st))\n# define sk_SRP_user_pwd_push(st, val) SKM_sk_push(SRP_user_pwd, (st), (val))\n# define sk_SRP_user_pwd_unshift(st, val) SKM_sk_unshift(SRP_user_pwd, (st), (val))\n# define sk_SRP_user_pwd_find(st, val) SKM_sk_find(SRP_user_pwd, (st), (val))\n# define sk_SRP_user_pwd_find_ex(st, val) SKM_sk_find_ex(SRP_user_pwd, (st), (val))\n# define sk_SRP_user_pwd_delete(st, i) SKM_sk_delete(SRP_user_pwd, (st), (i))\n# define sk_SRP_user_pwd_delete_ptr(st, ptr) SKM_sk_delete_ptr(SRP_user_pwd, (st), (ptr))\n# define sk_SRP_user_pwd_insert(st, val, i) SKM_sk_insert(SRP_user_pwd, (st), (val), (i))\n# define sk_SRP_user_pwd_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(SRP_user_pwd, (st), (cmp))\n# define sk_SRP_user_pwd_dup(st) SKM_sk_dup(SRP_user_pwd, st)\n# define sk_SRP_user_pwd_pop_free(st, free_func) SKM_sk_pop_free(SRP_user_pwd, (st), (free_func))\n# define sk_SRP_user_pwd_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(SRP_user_pwd, (st), (copy_func), (free_func))\n# define sk_SRP_user_pwd_shift(st) SKM_sk_shift(SRP_user_pwd, (st))\n# define sk_SRP_user_pwd_pop(st) SKM_sk_pop(SRP_user_pwd, (st))\n# define sk_SRP_user_pwd_sort(st) SKM_sk_sort(SRP_user_pwd, (st))\n# define sk_SRP_user_pwd_is_sorted(st) SKM_sk_is_sorted(SRP_user_pwd, (st))\n# define sk_SRTP_PROTECTION_PROFILE_new(cmp) SKM_sk_new(SRTP_PROTECTION_PROFILE, (cmp))\n# define sk_SRTP_PROTECTION_PROFILE_new_null() SKM_sk_new_null(SRTP_PROTECTION_PROFILE)\n# define sk_SRTP_PROTECTION_PROFILE_free(st) SKM_sk_free(SRTP_PROTECTION_PROFILE, (st))\n# define sk_SRTP_PROTECTION_PROFILE_num(st) SKM_sk_num(SRTP_PROTECTION_PROFILE, (st))\n# define sk_SRTP_PROTECTION_PROFILE_value(st, i) SKM_sk_value(SRTP_PROTECTION_PROFILE, (st), (i))\n# define sk_SRTP_PROTECTION_PROFILE_set(st, i, val) SKM_sk_set(SRTP_PROTECTION_PROFILE, (st), (i), (val))\n# define sk_SRTP_PROTECTION_PROFILE_zero(st) SKM_sk_zero(SRTP_PROTECTION_PROFILE, (st))\n# define sk_SRTP_PROTECTION_PROFILE_push(st, val) SKM_sk_push(SRTP_PROTECTION_PROFILE, (st), (val))\n# define sk_SRTP_PROTECTION_PROFILE_unshift(st, val) SKM_sk_unshift(SRTP_PROTECTION_PROFILE, (st), (val))\n# define sk_SRTP_PROTECTION_PROFILE_find(st, val) SKM_sk_find(SRTP_PROTECTION_PROFILE, (st), (val))\n# define sk_SRTP_PROTECTION_PROFILE_find_ex(st, val) SKM_sk_find_ex(SRTP_PROTECTION_PROFILE, (st), (val))\n# define sk_SRTP_PROTECTION_PROFILE_delete(st, i) SKM_sk_delete(SRTP_PROTECTION_PROFILE, (st), (i))\n# define sk_SRTP_PROTECTION_PROFILE_delete_ptr(st, ptr) SKM_sk_delete_ptr(SRTP_PROTECTION_PROFILE, (st), (ptr))\n# define sk_SRTP_PROTECTION_PROFILE_insert(st, val, i) SKM_sk_insert(SRTP_PROTECTION_PROFILE, (st), (val), (i))\n# define sk_SRTP_PROTECTION_PROFILE_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(SRTP_PROTECTION_PROFILE, (st), (cmp))\n# define sk_SRTP_PROTECTION_PROFILE_dup(st) SKM_sk_dup(SRTP_PROTECTION_PROFILE, st)\n# define sk_SRTP_PROTECTION_PROFILE_pop_free(st, free_func) SKM_sk_pop_free(SRTP_PROTECTION_PROFILE, (st), (free_func))\n# define sk_SRTP_PROTECTION_PROFILE_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(SRTP_PROTECTION_PROFILE, (st), (copy_func), (free_func))\n# define sk_SRTP_PROTECTION_PROFILE_shift(st) SKM_sk_shift(SRTP_PROTECTION_PROFILE, (st))\n# define sk_SRTP_PROTECTION_PROFILE_pop(st) SKM_sk_pop(SRTP_PROTECTION_PROFILE, (st))\n# define sk_SRTP_PROTECTION_PROFILE_sort(st) SKM_sk_sort(SRTP_PROTECTION_PROFILE, (st))\n# define sk_SRTP_PROTECTION_PROFILE_is_sorted(st) SKM_sk_is_sorted(SRTP_PROTECTION_PROFILE, (st))\n# define sk_SSL_CIPHER_new(cmp) SKM_sk_new(SSL_CIPHER, (cmp))\n# define sk_SSL_CIPHER_new_null() SKM_sk_new_null(SSL_CIPHER)\n# define sk_SSL_CIPHER_free(st) SKM_sk_free(SSL_CIPHER, (st))\n# define sk_SSL_CIPHER_num(st) SKM_sk_num(SSL_CIPHER, (st))\n# define sk_SSL_CIPHER_value(st, i) SKM_sk_value(SSL_CIPHER, (st), (i))\n# define sk_SSL_CIPHER_set(st, i, val) SKM_sk_set(SSL_CIPHER, (st), (i), (val))\n# define sk_SSL_CIPHER_zero(st) SKM_sk_zero(SSL_CIPHER, (st))\n# define sk_SSL_CIPHER_push(st, val) SKM_sk_push(SSL_CIPHER, (st), (val))\n# define sk_SSL_CIPHER_unshift(st, val) SKM_sk_unshift(SSL_CIPHER, (st), (val))\n# define sk_SSL_CIPHER_find(st, val) SKM_sk_find(SSL_CIPHER, (st), (val))\n# define sk_SSL_CIPHER_find_ex(st, val) SKM_sk_find_ex(SSL_CIPHER, (st), (val))\n# define sk_SSL_CIPHER_delete(st, i) SKM_sk_delete(SSL_CIPHER, (st), (i))\n# define sk_SSL_CIPHER_delete_ptr(st, ptr) SKM_sk_delete_ptr(SSL_CIPHER, (st), (ptr))\n# define sk_SSL_CIPHER_insert(st, val, i) SKM_sk_insert(SSL_CIPHER, (st), (val), (i))\n# define sk_SSL_CIPHER_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(SSL_CIPHER, (st), (cmp))\n# define sk_SSL_CIPHER_dup(st) SKM_sk_dup(SSL_CIPHER, st)\n# define sk_SSL_CIPHER_pop_free(st, free_func) SKM_sk_pop_free(SSL_CIPHER, (st), (free_func))\n# define sk_SSL_CIPHER_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(SSL_CIPHER, (st), (copy_func), (free_func))\n# define sk_SSL_CIPHER_shift(st) SKM_sk_shift(SSL_CIPHER, (st))\n# define sk_SSL_CIPHER_pop(st) SKM_sk_pop(SSL_CIPHER, (st))\n# define sk_SSL_CIPHER_sort(st) SKM_sk_sort(SSL_CIPHER, (st))\n# define sk_SSL_CIPHER_is_sorted(st) SKM_sk_is_sorted(SSL_CIPHER, (st))\n# define sk_SSL_COMP_new(cmp) SKM_sk_new(SSL_COMP, (cmp))\n# define sk_SSL_COMP_new_null() SKM_sk_new_null(SSL_COMP)\n# define sk_SSL_COMP_free(st) SKM_sk_free(SSL_COMP, (st))\n# define sk_SSL_COMP_num(st) SKM_sk_num(SSL_COMP, (st))\n# define sk_SSL_COMP_value(st, i) SKM_sk_value(SSL_COMP, (st), (i))\n# define sk_SSL_COMP_set(st, i, val) SKM_sk_set(SSL_COMP, (st), (i), (val))\n# define sk_SSL_COMP_zero(st) SKM_sk_zero(SSL_COMP, (st))\n# define sk_SSL_COMP_push(st, val) SKM_sk_push(SSL_COMP, (st), (val))\n# define sk_SSL_COMP_unshift(st, val) SKM_sk_unshift(SSL_COMP, (st), (val))\n# define sk_SSL_COMP_find(st, val) SKM_sk_find(SSL_COMP, (st), (val))\n# define sk_SSL_COMP_find_ex(st, val) SKM_sk_find_ex(SSL_COMP, (st), (val))\n# define sk_SSL_COMP_delete(st, i) SKM_sk_delete(SSL_COMP, (st), (i))\n# define sk_SSL_COMP_delete_ptr(st, ptr) SKM_sk_delete_ptr(SSL_COMP, (st), (ptr))\n# define sk_SSL_COMP_insert(st, val, i) SKM_sk_insert(SSL_COMP, (st), (val), (i))\n# define sk_SSL_COMP_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(SSL_COMP, (st), (cmp))\n# define sk_SSL_COMP_dup(st) SKM_sk_dup(SSL_COMP, st)\n# define sk_SSL_COMP_pop_free(st, free_func) SKM_sk_pop_free(SSL_COMP, (st), (free_func))\n# define sk_SSL_COMP_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(SSL_COMP, (st), (copy_func), (free_func))\n# define sk_SSL_COMP_shift(st) SKM_sk_shift(SSL_COMP, (st))\n# define sk_SSL_COMP_pop(st) SKM_sk_pop(SSL_COMP, (st))\n# define sk_SSL_COMP_sort(st) SKM_sk_sort(SSL_COMP, (st))\n# define sk_SSL_COMP_is_sorted(st) SKM_sk_is_sorted(SSL_COMP, (st))\n# define sk_STACK_OF_X509_NAME_ENTRY_new(cmp) SKM_sk_new(STACK_OF_X509_NAME_ENTRY, (cmp))\n# define sk_STACK_OF_X509_NAME_ENTRY_new_null() SKM_sk_new_null(STACK_OF_X509_NAME_ENTRY)\n# define sk_STACK_OF_X509_NAME_ENTRY_free(st) SKM_sk_free(STACK_OF_X509_NAME_ENTRY, (st))\n# define sk_STACK_OF_X509_NAME_ENTRY_num(st) SKM_sk_num(STACK_OF_X509_NAME_ENTRY, (st))\n# define sk_STACK_OF_X509_NAME_ENTRY_value(st, i) SKM_sk_value(STACK_OF_X509_NAME_ENTRY, (st), (i))\n# define sk_STACK_OF_X509_NAME_ENTRY_set(st, i, val) SKM_sk_set(STACK_OF_X509_NAME_ENTRY, (st), (i), (val))\n# define sk_STACK_OF_X509_NAME_ENTRY_zero(st) SKM_sk_zero(STACK_OF_X509_NAME_ENTRY, (st))\n# define sk_STACK_OF_X509_NAME_ENTRY_push(st, val) SKM_sk_push(STACK_OF_X509_NAME_ENTRY, (st), (val))\n# define sk_STACK_OF_X509_NAME_ENTRY_unshift(st, val) SKM_sk_unshift(STACK_OF_X509_NAME_ENTRY, (st), (val))\n# define sk_STACK_OF_X509_NAME_ENTRY_find(st, val) SKM_sk_find(STACK_OF_X509_NAME_ENTRY, (st), (val))\n# define sk_STACK_OF_X509_NAME_ENTRY_find_ex(st, val) SKM_sk_find_ex(STACK_OF_X509_NAME_ENTRY, (st), (val))\n# define sk_STACK_OF_X509_NAME_ENTRY_delete(st, i) SKM_sk_delete(STACK_OF_X509_NAME_ENTRY, (st), (i))\n# define sk_STACK_OF_X509_NAME_ENTRY_delete_ptr(st, ptr) SKM_sk_delete_ptr(STACK_OF_X509_NAME_ENTRY, (st), (ptr))\n# define sk_STACK_OF_X509_NAME_ENTRY_insert(st, val, i) SKM_sk_insert(STACK_OF_X509_NAME_ENTRY, (st), (val), (i))\n# define sk_STACK_OF_X509_NAME_ENTRY_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(STACK_OF_X509_NAME_ENTRY, (st), (cmp))\n# define sk_STACK_OF_X509_NAME_ENTRY_dup(st) SKM_sk_dup(STACK_OF_X509_NAME_ENTRY, st)\n# define sk_STACK_OF_X509_NAME_ENTRY_pop_free(st, free_func) SKM_sk_pop_free(STACK_OF_X509_NAME_ENTRY, (st), (free_func))\n# define sk_STACK_OF_X509_NAME_ENTRY_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(STACK_OF_X509_NAME_ENTRY, (st), (copy_func), (free_func))\n# define sk_STACK_OF_X509_NAME_ENTRY_shift(st) SKM_sk_shift(STACK_OF_X509_NAME_ENTRY, (st))\n# define sk_STACK_OF_X509_NAME_ENTRY_pop(st) SKM_sk_pop(STACK_OF_X509_NAME_ENTRY, (st))\n# define sk_STACK_OF_X509_NAME_ENTRY_sort(st) SKM_sk_sort(STACK_OF_X509_NAME_ENTRY, (st))\n# define sk_STACK_OF_X509_NAME_ENTRY_is_sorted(st) SKM_sk_is_sorted(STACK_OF_X509_NAME_ENTRY, (st))\n# define sk_STORE_ATTR_INFO_new(cmp) SKM_sk_new(STORE_ATTR_INFO, (cmp))\n# define sk_STORE_ATTR_INFO_new_null() SKM_sk_new_null(STORE_ATTR_INFO)\n# define sk_STORE_ATTR_INFO_free(st) SKM_sk_free(STORE_ATTR_INFO, (st))\n# define sk_STORE_ATTR_INFO_num(st) SKM_sk_num(STORE_ATTR_INFO, (st))\n# define sk_STORE_ATTR_INFO_value(st, i) SKM_sk_value(STORE_ATTR_INFO, (st), (i))\n# define sk_STORE_ATTR_INFO_set(st, i, val) SKM_sk_set(STORE_ATTR_INFO, (st), (i), (val))\n# define sk_STORE_ATTR_INFO_zero(st) SKM_sk_zero(STORE_ATTR_INFO, (st))\n# define sk_STORE_ATTR_INFO_push(st, val) SKM_sk_push(STORE_ATTR_INFO, (st), (val))\n# define sk_STORE_ATTR_INFO_unshift(st, val) SKM_sk_unshift(STORE_ATTR_INFO, (st), (val))\n# define sk_STORE_ATTR_INFO_find(st, val) SKM_sk_find(STORE_ATTR_INFO, (st), (val))\n# define sk_STORE_ATTR_INFO_find_ex(st, val) SKM_sk_find_ex(STORE_ATTR_INFO, (st), (val))\n# define sk_STORE_ATTR_INFO_delete(st, i) SKM_sk_delete(STORE_ATTR_INFO, (st), (i))\n# define sk_STORE_ATTR_INFO_delete_ptr(st, ptr) SKM_sk_delete_ptr(STORE_ATTR_INFO, (st), (ptr))\n# define sk_STORE_ATTR_INFO_insert(st, val, i) SKM_sk_insert(STORE_ATTR_INFO, (st), (val), (i))\n# define sk_STORE_ATTR_INFO_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(STORE_ATTR_INFO, (st), (cmp))\n# define sk_STORE_ATTR_INFO_dup(st) SKM_sk_dup(STORE_ATTR_INFO, st)\n# define sk_STORE_ATTR_INFO_pop_free(st, free_func) SKM_sk_pop_free(STORE_ATTR_INFO, (st), (free_func))\n# define sk_STORE_ATTR_INFO_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(STORE_ATTR_INFO, (st), (copy_func), (free_func))\n# define sk_STORE_ATTR_INFO_shift(st) SKM_sk_shift(STORE_ATTR_INFO, (st))\n# define sk_STORE_ATTR_INFO_pop(st) SKM_sk_pop(STORE_ATTR_INFO, (st))\n# define sk_STORE_ATTR_INFO_sort(st) SKM_sk_sort(STORE_ATTR_INFO, (st))\n# define sk_STORE_ATTR_INFO_is_sorted(st) SKM_sk_is_sorted(STORE_ATTR_INFO, (st))\n# define sk_STORE_OBJECT_new(cmp) SKM_sk_new(STORE_OBJECT, (cmp))\n# define sk_STORE_OBJECT_new_null() SKM_sk_new_null(STORE_OBJECT)\n# define sk_STORE_OBJECT_free(st) SKM_sk_free(STORE_OBJECT, (st))\n# define sk_STORE_OBJECT_num(st) SKM_sk_num(STORE_OBJECT, (st))\n# define sk_STORE_OBJECT_value(st, i) SKM_sk_value(STORE_OBJECT, (st), (i))\n# define sk_STORE_OBJECT_set(st, i, val) SKM_sk_set(STORE_OBJECT, (st), (i), (val))\n# define sk_STORE_OBJECT_zero(st) SKM_sk_zero(STORE_OBJECT, (st))\n# define sk_STORE_OBJECT_push(st, val) SKM_sk_push(STORE_OBJECT, (st), (val))\n# define sk_STORE_OBJECT_unshift(st, val) SKM_sk_unshift(STORE_OBJECT, (st), (val))\n# define sk_STORE_OBJECT_find(st, val) SKM_sk_find(STORE_OBJECT, (st), (val))\n# define sk_STORE_OBJECT_find_ex(st, val) SKM_sk_find_ex(STORE_OBJECT, (st), (val))\n# define sk_STORE_OBJECT_delete(st, i) SKM_sk_delete(STORE_OBJECT, (st), (i))\n# define sk_STORE_OBJECT_delete_ptr(st, ptr) SKM_sk_delete_ptr(STORE_OBJECT, (st), (ptr))\n# define sk_STORE_OBJECT_insert(st, val, i) SKM_sk_insert(STORE_OBJECT, (st), (val), (i))\n# define sk_STORE_OBJECT_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(STORE_OBJECT, (st), (cmp))\n# define sk_STORE_OBJECT_dup(st) SKM_sk_dup(STORE_OBJECT, st)\n# define sk_STORE_OBJECT_pop_free(st, free_func) SKM_sk_pop_free(STORE_OBJECT, (st), (free_func))\n# define sk_STORE_OBJECT_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(STORE_OBJECT, (st), (copy_func), (free_func))\n# define sk_STORE_OBJECT_shift(st) SKM_sk_shift(STORE_OBJECT, (st))\n# define sk_STORE_OBJECT_pop(st) SKM_sk_pop(STORE_OBJECT, (st))\n# define sk_STORE_OBJECT_sort(st) SKM_sk_sort(STORE_OBJECT, (st))\n# define sk_STORE_OBJECT_is_sorted(st) SKM_sk_is_sorted(STORE_OBJECT, (st))\n# define sk_SXNETID_new(cmp) SKM_sk_new(SXNETID, (cmp))\n# define sk_SXNETID_new_null() SKM_sk_new_null(SXNETID)\n# define sk_SXNETID_free(st) SKM_sk_free(SXNETID, (st))\n# define sk_SXNETID_num(st) SKM_sk_num(SXNETID, (st))\n# define sk_SXNETID_value(st, i) SKM_sk_value(SXNETID, (st), (i))\n# define sk_SXNETID_set(st, i, val) SKM_sk_set(SXNETID, (st), (i), (val))\n# define sk_SXNETID_zero(st) SKM_sk_zero(SXNETID, (st))\n# define sk_SXNETID_push(st, val) SKM_sk_push(SXNETID, (st), (val))\n# define sk_SXNETID_unshift(st, val) SKM_sk_unshift(SXNETID, (st), (val))\n# define sk_SXNETID_find(st, val) SKM_sk_find(SXNETID, (st), (val))\n# define sk_SXNETID_find_ex(st, val) SKM_sk_find_ex(SXNETID, (st), (val))\n# define sk_SXNETID_delete(st, i) SKM_sk_delete(SXNETID, (st), (i))\n# define sk_SXNETID_delete_ptr(st, ptr) SKM_sk_delete_ptr(SXNETID, (st), (ptr))\n# define sk_SXNETID_insert(st, val, i) SKM_sk_insert(SXNETID, (st), (val), (i))\n# define sk_SXNETID_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(SXNETID, (st), (cmp))\n# define sk_SXNETID_dup(st) SKM_sk_dup(SXNETID, st)\n# define sk_SXNETID_pop_free(st, free_func) SKM_sk_pop_free(SXNETID, (st), (free_func))\n# define sk_SXNETID_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(SXNETID, (st), (copy_func), (free_func))\n# define sk_SXNETID_shift(st) SKM_sk_shift(SXNETID, (st))\n# define sk_SXNETID_pop(st) SKM_sk_pop(SXNETID, (st))\n# define sk_SXNETID_sort(st) SKM_sk_sort(SXNETID, (st))\n# define sk_SXNETID_is_sorted(st) SKM_sk_is_sorted(SXNETID, (st))\n# define sk_UI_STRING_new(cmp) SKM_sk_new(UI_STRING, (cmp))\n# define sk_UI_STRING_new_null() SKM_sk_new_null(UI_STRING)\n# define sk_UI_STRING_free(st) SKM_sk_free(UI_STRING, (st))\n# define sk_UI_STRING_num(st) SKM_sk_num(UI_STRING, (st))\n# define sk_UI_STRING_value(st, i) SKM_sk_value(UI_STRING, (st), (i))\n# define sk_UI_STRING_set(st, i, val) SKM_sk_set(UI_STRING, (st), (i), (val))\n# define sk_UI_STRING_zero(st) SKM_sk_zero(UI_STRING, (st))\n# define sk_UI_STRING_push(st, val) SKM_sk_push(UI_STRING, (st), (val))\n# define sk_UI_STRING_unshift(st, val) SKM_sk_unshift(UI_STRING, (st), (val))\n# define sk_UI_STRING_find(st, val) SKM_sk_find(UI_STRING, (st), (val))\n# define sk_UI_STRING_find_ex(st, val) SKM_sk_find_ex(UI_STRING, (st), (val))\n# define sk_UI_STRING_delete(st, i) SKM_sk_delete(UI_STRING, (st), (i))\n# define sk_UI_STRING_delete_ptr(st, ptr) SKM_sk_delete_ptr(UI_STRING, (st), (ptr))\n# define sk_UI_STRING_insert(st, val, i) SKM_sk_insert(UI_STRING, (st), (val), (i))\n# define sk_UI_STRING_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(UI_STRING, (st), (cmp))\n# define sk_UI_STRING_dup(st) SKM_sk_dup(UI_STRING, st)\n# define sk_UI_STRING_pop_free(st, free_func) SKM_sk_pop_free(UI_STRING, (st), (free_func))\n# define sk_UI_STRING_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(UI_STRING, (st), (copy_func), (free_func))\n# define sk_UI_STRING_shift(st) SKM_sk_shift(UI_STRING, (st))\n# define sk_UI_STRING_pop(st) SKM_sk_pop(UI_STRING, (st))\n# define sk_UI_STRING_sort(st) SKM_sk_sort(UI_STRING, (st))\n# define sk_UI_STRING_is_sorted(st) SKM_sk_is_sorted(UI_STRING, (st))\n# define sk_X509_new(cmp) SKM_sk_new(X509, (cmp))\n# define sk_X509_new_null() SKM_sk_new_null(X509)\n# define sk_X509_free(st) SKM_sk_free(X509, (st))\n# define sk_X509_num(st) SKM_sk_num(X509, (st))\n# define sk_X509_value(st, i) SKM_sk_value(X509, (st), (i))\n# define sk_X509_set(st, i, val) SKM_sk_set(X509, (st), (i), (val))\n# define sk_X509_zero(st) SKM_sk_zero(X509, (st))\n# define sk_X509_push(st, val) SKM_sk_push(X509, (st), (val))\n# define sk_X509_unshift(st, val) SKM_sk_unshift(X509, (st), (val))\n# define sk_X509_find(st, val) SKM_sk_find(X509, (st), (val))\n# define sk_X509_find_ex(st, val) SKM_sk_find_ex(X509, (st), (val))\n# define sk_X509_delete(st, i) SKM_sk_delete(X509, (st), (i))\n# define sk_X509_delete_ptr(st, ptr) SKM_sk_delete_ptr(X509, (st), (ptr))\n# define sk_X509_insert(st, val, i) SKM_sk_insert(X509, (st), (val), (i))\n# define sk_X509_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(X509, (st), (cmp))\n# define sk_X509_dup(st) SKM_sk_dup(X509, st)\n# define sk_X509_pop_free(st, free_func) SKM_sk_pop_free(X509, (st), (free_func))\n# define sk_X509_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(X509, (st), (copy_func), (free_func))\n# define sk_X509_shift(st) SKM_sk_shift(X509, (st))\n# define sk_X509_pop(st) SKM_sk_pop(X509, (st))\n# define sk_X509_sort(st) SKM_sk_sort(X509, (st))\n# define sk_X509_is_sorted(st) SKM_sk_is_sorted(X509, (st))\n# define sk_X509V3_EXT_METHOD_new(cmp) SKM_sk_new(X509V3_EXT_METHOD, (cmp))\n# define sk_X509V3_EXT_METHOD_new_null() SKM_sk_new_null(X509V3_EXT_METHOD)\n# define sk_X509V3_EXT_METHOD_free(st) SKM_sk_free(X509V3_EXT_METHOD, (st))\n# define sk_X509V3_EXT_METHOD_num(st) SKM_sk_num(X509V3_EXT_METHOD, (st))\n# define sk_X509V3_EXT_METHOD_value(st, i) SKM_sk_value(X509V3_EXT_METHOD, (st), (i))\n# define sk_X509V3_EXT_METHOD_set(st, i, val) SKM_sk_set(X509V3_EXT_METHOD, (st), (i), (val))\n# define sk_X509V3_EXT_METHOD_zero(st) SKM_sk_zero(X509V3_EXT_METHOD, (st))\n# define sk_X509V3_EXT_METHOD_push(st, val) SKM_sk_push(X509V3_EXT_METHOD, (st), (val))\n# define sk_X509V3_EXT_METHOD_unshift(st, val) SKM_sk_unshift(X509V3_EXT_METHOD, (st), (val))\n# define sk_X509V3_EXT_METHOD_find(st, val) SKM_sk_find(X509V3_EXT_METHOD, (st), (val))\n# define sk_X509V3_EXT_METHOD_find_ex(st, val) SKM_sk_find_ex(X509V3_EXT_METHOD, (st), (val))\n# define sk_X509V3_EXT_METHOD_delete(st, i) SKM_sk_delete(X509V3_EXT_METHOD, (st), (i))\n# define sk_X509V3_EXT_METHOD_delete_ptr(st, ptr) SKM_sk_delete_ptr(X509V3_EXT_METHOD, (st), (ptr))\n# define sk_X509V3_EXT_METHOD_insert(st, val, i) SKM_sk_insert(X509V3_EXT_METHOD, (st), (val), (i))\n# define sk_X509V3_EXT_METHOD_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(X509V3_EXT_METHOD, (st), (cmp))\n# define sk_X509V3_EXT_METHOD_dup(st) SKM_sk_dup(X509V3_EXT_METHOD, st)\n# define sk_X509V3_EXT_METHOD_pop_free(st, free_func) SKM_sk_pop_free(X509V3_EXT_METHOD, (st), (free_func))\n# define sk_X509V3_EXT_METHOD_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(X509V3_EXT_METHOD, (st), (copy_func), (free_func))\n# define sk_X509V3_EXT_METHOD_shift(st) SKM_sk_shift(X509V3_EXT_METHOD, (st))\n# define sk_X509V3_EXT_METHOD_pop(st) SKM_sk_pop(X509V3_EXT_METHOD, (st))\n# define sk_X509V3_EXT_METHOD_sort(st) SKM_sk_sort(X509V3_EXT_METHOD, (st))\n# define sk_X509V3_EXT_METHOD_is_sorted(st) SKM_sk_is_sorted(X509V3_EXT_METHOD, (st))\n# define sk_X509_ALGOR_new(cmp) SKM_sk_new(X509_ALGOR, (cmp))\n# define sk_X509_ALGOR_new_null() SKM_sk_new_null(X509_ALGOR)\n# define sk_X509_ALGOR_free(st) SKM_sk_free(X509_ALGOR, (st))\n# define sk_X509_ALGOR_num(st) SKM_sk_num(X509_ALGOR, (st))\n# define sk_X509_ALGOR_value(st, i) SKM_sk_value(X509_ALGOR, (st), (i))\n# define sk_X509_ALGOR_set(st, i, val) SKM_sk_set(X509_ALGOR, (st), (i), (val))\n# define sk_X509_ALGOR_zero(st) SKM_sk_zero(X509_ALGOR, (st))\n# define sk_X509_ALGOR_push(st, val) SKM_sk_push(X509_ALGOR, (st), (val))\n# define sk_X509_ALGOR_unshift(st, val) SKM_sk_unshift(X509_ALGOR, (st), (val))\n# define sk_X509_ALGOR_find(st, val) SKM_sk_find(X509_ALGOR, (st), (val))\n# define sk_X509_ALGOR_find_ex(st, val) SKM_sk_find_ex(X509_ALGOR, (st), (val))\n# define sk_X509_ALGOR_delete(st, i) SKM_sk_delete(X509_ALGOR, (st), (i))\n# define sk_X509_ALGOR_delete_ptr(st, ptr) SKM_sk_delete_ptr(X509_ALGOR, (st), (ptr))\n# define sk_X509_ALGOR_insert(st, val, i) SKM_sk_insert(X509_ALGOR, (st), (val), (i))\n# define sk_X509_ALGOR_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(X509_ALGOR, (st), (cmp))\n# define sk_X509_ALGOR_dup(st) SKM_sk_dup(X509_ALGOR, st)\n# define sk_X509_ALGOR_pop_free(st, free_func) SKM_sk_pop_free(X509_ALGOR, (st), (free_func))\n# define sk_X509_ALGOR_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(X509_ALGOR, (st), (copy_func), (free_func))\n# define sk_X509_ALGOR_shift(st) SKM_sk_shift(X509_ALGOR, (st))\n# define sk_X509_ALGOR_pop(st) SKM_sk_pop(X509_ALGOR, (st))\n# define sk_X509_ALGOR_sort(st) SKM_sk_sort(X509_ALGOR, (st))\n# define sk_X509_ALGOR_is_sorted(st) SKM_sk_is_sorted(X509_ALGOR, (st))\n# define sk_X509_ATTRIBUTE_new(cmp) SKM_sk_new(X509_ATTRIBUTE, (cmp))\n# define sk_X509_ATTRIBUTE_new_null() SKM_sk_new_null(X509_ATTRIBUTE)\n# define sk_X509_ATTRIBUTE_free(st) SKM_sk_free(X509_ATTRIBUTE, (st))\n# define sk_X509_ATTRIBUTE_num(st) SKM_sk_num(X509_ATTRIBUTE, (st))\n# define sk_X509_ATTRIBUTE_value(st, i) SKM_sk_value(X509_ATTRIBUTE, (st), (i))\n# define sk_X509_ATTRIBUTE_set(st, i, val) SKM_sk_set(X509_ATTRIBUTE, (st), (i), (val))\n# define sk_X509_ATTRIBUTE_zero(st) SKM_sk_zero(X509_ATTRIBUTE, (st))\n# define sk_X509_ATTRIBUTE_push(st, val) SKM_sk_push(X509_ATTRIBUTE, (st), (val))\n# define sk_X509_ATTRIBUTE_unshift(st, val) SKM_sk_unshift(X509_ATTRIBUTE, (st), (val))\n# define sk_X509_ATTRIBUTE_find(st, val) SKM_sk_find(X509_ATTRIBUTE, (st), (val))\n# define sk_X509_ATTRIBUTE_find_ex(st, val) SKM_sk_find_ex(X509_ATTRIBUTE, (st), (val))\n# define sk_X509_ATTRIBUTE_delete(st, i) SKM_sk_delete(X509_ATTRIBUTE, (st), (i))\n# define sk_X509_ATTRIBUTE_delete_ptr(st, ptr) SKM_sk_delete_ptr(X509_ATTRIBUTE, (st), (ptr))\n# define sk_X509_ATTRIBUTE_insert(st, val, i) SKM_sk_insert(X509_ATTRIBUTE, (st), (val), (i))\n# define sk_X509_ATTRIBUTE_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(X509_ATTRIBUTE, (st), (cmp))\n# define sk_X509_ATTRIBUTE_dup(st) SKM_sk_dup(X509_ATTRIBUTE, st)\n# define sk_X509_ATTRIBUTE_pop_free(st, free_func) SKM_sk_pop_free(X509_ATTRIBUTE, (st), (free_func))\n# define sk_X509_ATTRIBUTE_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(X509_ATTRIBUTE, (st), (copy_func), (free_func))\n# define sk_X509_ATTRIBUTE_shift(st) SKM_sk_shift(X509_ATTRIBUTE, (st))\n# define sk_X509_ATTRIBUTE_pop(st) SKM_sk_pop(X509_ATTRIBUTE, (st))\n# define sk_X509_ATTRIBUTE_sort(st) SKM_sk_sort(X509_ATTRIBUTE, (st))\n# define sk_X509_ATTRIBUTE_is_sorted(st) SKM_sk_is_sorted(X509_ATTRIBUTE, (st))\n# define sk_X509_CRL_new(cmp) SKM_sk_new(X509_CRL, (cmp))\n# define sk_X509_CRL_new_null() SKM_sk_new_null(X509_CRL)\n# define sk_X509_CRL_free(st) SKM_sk_free(X509_CRL, (st))\n# define sk_X509_CRL_num(st) SKM_sk_num(X509_CRL, (st))\n# define sk_X509_CRL_value(st, i) SKM_sk_value(X509_CRL, (st), (i))\n# define sk_X509_CRL_set(st, i, val) SKM_sk_set(X509_CRL, (st), (i), (val))\n# define sk_X509_CRL_zero(st) SKM_sk_zero(X509_CRL, (st))\n# define sk_X509_CRL_push(st, val) SKM_sk_push(X509_CRL, (st), (val))\n# define sk_X509_CRL_unshift(st, val) SKM_sk_unshift(X509_CRL, (st), (val))\n# define sk_X509_CRL_find(st, val) SKM_sk_find(X509_CRL, (st), (val))\n# define sk_X509_CRL_find_ex(st, val) SKM_sk_find_ex(X509_CRL, (st), (val))\n# define sk_X509_CRL_delete(st, i) SKM_sk_delete(X509_CRL, (st), (i))\n# define sk_X509_CRL_delete_ptr(st, ptr) SKM_sk_delete_ptr(X509_CRL, (st), (ptr))\n# define sk_X509_CRL_insert(st, val, i) SKM_sk_insert(X509_CRL, (st), (val), (i))\n# define sk_X509_CRL_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(X509_CRL, (st), (cmp))\n# define sk_X509_CRL_dup(st) SKM_sk_dup(X509_CRL, st)\n# define sk_X509_CRL_pop_free(st, free_func) SKM_sk_pop_free(X509_CRL, (st), (free_func))\n# define sk_X509_CRL_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(X509_CRL, (st), (copy_func), (free_func))\n# define sk_X509_CRL_shift(st) SKM_sk_shift(X509_CRL, (st))\n# define sk_X509_CRL_pop(st) SKM_sk_pop(X509_CRL, (st))\n# define sk_X509_CRL_sort(st) SKM_sk_sort(X509_CRL, (st))\n# define sk_X509_CRL_is_sorted(st) SKM_sk_is_sorted(X509_CRL, (st))\n# define sk_X509_EXTENSION_new(cmp) SKM_sk_new(X509_EXTENSION, (cmp))\n# define sk_X509_EXTENSION_new_null() SKM_sk_new_null(X509_EXTENSION)\n# define sk_X509_EXTENSION_free(st) SKM_sk_free(X509_EXTENSION, (st))\n# define sk_X509_EXTENSION_num(st) SKM_sk_num(X509_EXTENSION, (st))\n# define sk_X509_EXTENSION_value(st, i) SKM_sk_value(X509_EXTENSION, (st), (i))\n# define sk_X509_EXTENSION_set(st, i, val) SKM_sk_set(X509_EXTENSION, (st), (i), (val))\n# define sk_X509_EXTENSION_zero(st) SKM_sk_zero(X509_EXTENSION, (st))\n# define sk_X509_EXTENSION_push(st, val) SKM_sk_push(X509_EXTENSION, (st), (val))\n# define sk_X509_EXTENSION_unshift(st, val) SKM_sk_unshift(X509_EXTENSION, (st), (val))\n# define sk_X509_EXTENSION_find(st, val) SKM_sk_find(X509_EXTENSION, (st), (val))\n# define sk_X509_EXTENSION_find_ex(st, val) SKM_sk_find_ex(X509_EXTENSION, (st), (val))\n# define sk_X509_EXTENSION_delete(st, i) SKM_sk_delete(X509_EXTENSION, (st), (i))\n# define sk_X509_EXTENSION_delete_ptr(st, ptr) SKM_sk_delete_ptr(X509_EXTENSION, (st), (ptr))\n# define sk_X509_EXTENSION_insert(st, val, i) SKM_sk_insert(X509_EXTENSION, (st), (val), (i))\n# define sk_X509_EXTENSION_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(X509_EXTENSION, (st), (cmp))\n# define sk_X509_EXTENSION_dup(st) SKM_sk_dup(X509_EXTENSION, st)\n# define sk_X509_EXTENSION_pop_free(st, free_func) SKM_sk_pop_free(X509_EXTENSION, (st), (free_func))\n# define sk_X509_EXTENSION_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(X509_EXTENSION, (st), (copy_func), (free_func))\n# define sk_X509_EXTENSION_shift(st) SKM_sk_shift(X509_EXTENSION, (st))\n# define sk_X509_EXTENSION_pop(st) SKM_sk_pop(X509_EXTENSION, (st))\n# define sk_X509_EXTENSION_sort(st) SKM_sk_sort(X509_EXTENSION, (st))\n# define sk_X509_EXTENSION_is_sorted(st) SKM_sk_is_sorted(X509_EXTENSION, (st))\n# define sk_X509_INFO_new(cmp) SKM_sk_new(X509_INFO, (cmp))\n# define sk_X509_INFO_new_null() SKM_sk_new_null(X509_INFO)\n# define sk_X509_INFO_free(st) SKM_sk_free(X509_INFO, (st))\n# define sk_X509_INFO_num(st) SKM_sk_num(X509_INFO, (st))\n# define sk_X509_INFO_value(st, i) SKM_sk_value(X509_INFO, (st), (i))\n# define sk_X509_INFO_set(st, i, val) SKM_sk_set(X509_INFO, (st), (i), (val))\n# define sk_X509_INFO_zero(st) SKM_sk_zero(X509_INFO, (st))\n# define sk_X509_INFO_push(st, val) SKM_sk_push(X509_INFO, (st), (val))\n# define sk_X509_INFO_unshift(st, val) SKM_sk_unshift(X509_INFO, (st), (val))\n# define sk_X509_INFO_find(st, val) SKM_sk_find(X509_INFO, (st), (val))\n# define sk_X509_INFO_find_ex(st, val) SKM_sk_find_ex(X509_INFO, (st), (val))\n# define sk_X509_INFO_delete(st, i) SKM_sk_delete(X509_INFO, (st), (i))\n# define sk_X509_INFO_delete_ptr(st, ptr) SKM_sk_delete_ptr(X509_INFO, (st), (ptr))\n# define sk_X509_INFO_insert(st, val, i) SKM_sk_insert(X509_INFO, (st), (val), (i))\n# define sk_X509_INFO_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(X509_INFO, (st), (cmp))\n# define sk_X509_INFO_dup(st) SKM_sk_dup(X509_INFO, st)\n# define sk_X509_INFO_pop_free(st, free_func) SKM_sk_pop_free(X509_INFO, (st), (free_func))\n# define sk_X509_INFO_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(X509_INFO, (st), (copy_func), (free_func))\n# define sk_X509_INFO_shift(st) SKM_sk_shift(X509_INFO, (st))\n# define sk_X509_INFO_pop(st) SKM_sk_pop(X509_INFO, (st))\n# define sk_X509_INFO_sort(st) SKM_sk_sort(X509_INFO, (st))\n# define sk_X509_INFO_is_sorted(st) SKM_sk_is_sorted(X509_INFO, (st))\n# define sk_X509_LOOKUP_new(cmp) SKM_sk_new(X509_LOOKUP, (cmp))\n# define sk_X509_LOOKUP_new_null() SKM_sk_new_null(X509_LOOKUP)\n# define sk_X509_LOOKUP_free(st) SKM_sk_free(X509_LOOKUP, (st))\n# define sk_X509_LOOKUP_num(st) SKM_sk_num(X509_LOOKUP, (st))\n# define sk_X509_LOOKUP_value(st, i) SKM_sk_value(X509_LOOKUP, (st), (i))\n# define sk_X509_LOOKUP_set(st, i, val) SKM_sk_set(X509_LOOKUP, (st), (i), (val))\n# define sk_X509_LOOKUP_zero(st) SKM_sk_zero(X509_LOOKUP, (st))\n# define sk_X509_LOOKUP_push(st, val) SKM_sk_push(X509_LOOKUP, (st), (val))\n# define sk_X509_LOOKUP_unshift(st, val) SKM_sk_unshift(X509_LOOKUP, (st), (val))\n# define sk_X509_LOOKUP_find(st, val) SKM_sk_find(X509_LOOKUP, (st), (val))\n# define sk_X509_LOOKUP_find_ex(st, val) SKM_sk_find_ex(X509_LOOKUP, (st), (val))\n# define sk_X509_LOOKUP_delete(st, i) SKM_sk_delete(X509_LOOKUP, (st), (i))\n# define sk_X509_LOOKUP_delete_ptr(st, ptr) SKM_sk_delete_ptr(X509_LOOKUP, (st), (ptr))\n# define sk_X509_LOOKUP_insert(st, val, i) SKM_sk_insert(X509_LOOKUP, (st), (val), (i))\n# define sk_X509_LOOKUP_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(X509_LOOKUP, (st), (cmp))\n# define sk_X509_LOOKUP_dup(st) SKM_sk_dup(X509_LOOKUP, st)\n# define sk_X509_LOOKUP_pop_free(st, free_func) SKM_sk_pop_free(X509_LOOKUP, (st), (free_func))\n# define sk_X509_LOOKUP_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(X509_LOOKUP, (st), (copy_func), (free_func))\n# define sk_X509_LOOKUP_shift(st) SKM_sk_shift(X509_LOOKUP, (st))\n# define sk_X509_LOOKUP_pop(st) SKM_sk_pop(X509_LOOKUP, (st))\n# define sk_X509_LOOKUP_sort(st) SKM_sk_sort(X509_LOOKUP, (st))\n# define sk_X509_LOOKUP_is_sorted(st) SKM_sk_is_sorted(X509_LOOKUP, (st))\n# define sk_X509_NAME_new(cmp) SKM_sk_new(X509_NAME, (cmp))\n# define sk_X509_NAME_new_null() SKM_sk_new_null(X509_NAME)\n# define sk_X509_NAME_free(st) SKM_sk_free(X509_NAME, (st))\n# define sk_X509_NAME_num(st) SKM_sk_num(X509_NAME, (st))\n# define sk_X509_NAME_value(st, i) SKM_sk_value(X509_NAME, (st), (i))\n# define sk_X509_NAME_set(st, i, val) SKM_sk_set(X509_NAME, (st), (i), (val))\n# define sk_X509_NAME_zero(st) SKM_sk_zero(X509_NAME, (st))\n# define sk_X509_NAME_push(st, val) SKM_sk_push(X509_NAME, (st), (val))\n# define sk_X509_NAME_unshift(st, val) SKM_sk_unshift(X509_NAME, (st), (val))\n# define sk_X509_NAME_find(st, val) SKM_sk_find(X509_NAME, (st), (val))\n# define sk_X509_NAME_find_ex(st, val) SKM_sk_find_ex(X509_NAME, (st), (val))\n# define sk_X509_NAME_delete(st, i) SKM_sk_delete(X509_NAME, (st), (i))\n# define sk_X509_NAME_delete_ptr(st, ptr) SKM_sk_delete_ptr(X509_NAME, (st), (ptr))\n# define sk_X509_NAME_insert(st, val, i) SKM_sk_insert(X509_NAME, (st), (val), (i))\n# define sk_X509_NAME_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(X509_NAME, (st), (cmp))\n# define sk_X509_NAME_dup(st) SKM_sk_dup(X509_NAME, st)\n# define sk_X509_NAME_pop_free(st, free_func) SKM_sk_pop_free(X509_NAME, (st), (free_func))\n# define sk_X509_NAME_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(X509_NAME, (st), (copy_func), (free_func))\n# define sk_X509_NAME_shift(st) SKM_sk_shift(X509_NAME, (st))\n# define sk_X509_NAME_pop(st) SKM_sk_pop(X509_NAME, (st))\n# define sk_X509_NAME_sort(st) SKM_sk_sort(X509_NAME, (st))\n# define sk_X509_NAME_is_sorted(st) SKM_sk_is_sorted(X509_NAME, (st))\n# define sk_X509_NAME_ENTRY_new(cmp) SKM_sk_new(X509_NAME_ENTRY, (cmp))\n# define sk_X509_NAME_ENTRY_new_null() SKM_sk_new_null(X509_NAME_ENTRY)\n# define sk_X509_NAME_ENTRY_free(st) SKM_sk_free(X509_NAME_ENTRY, (st))\n# define sk_X509_NAME_ENTRY_num(st) SKM_sk_num(X509_NAME_ENTRY, (st))\n# define sk_X509_NAME_ENTRY_value(st, i) SKM_sk_value(X509_NAME_ENTRY, (st), (i))\n# define sk_X509_NAME_ENTRY_set(st, i, val) SKM_sk_set(X509_NAME_ENTRY, (st), (i), (val))\n# define sk_X509_NAME_ENTRY_zero(st) SKM_sk_zero(X509_NAME_ENTRY, (st))\n# define sk_X509_NAME_ENTRY_push(st, val) SKM_sk_push(X509_NAME_ENTRY, (st), (val))\n# define sk_X509_NAME_ENTRY_unshift(st, val) SKM_sk_unshift(X509_NAME_ENTRY, (st), (val))\n# define sk_X509_NAME_ENTRY_find(st, val) SKM_sk_find(X509_NAME_ENTRY, (st), (val))\n# define sk_X509_NAME_ENTRY_find_ex(st, val) SKM_sk_find_ex(X509_NAME_ENTRY, (st), (val))\n# define sk_X509_NAME_ENTRY_delete(st, i) SKM_sk_delete(X509_NAME_ENTRY, (st), (i))\n# define sk_X509_NAME_ENTRY_delete_ptr(st, ptr) SKM_sk_delete_ptr(X509_NAME_ENTRY, (st), (ptr))\n# define sk_X509_NAME_ENTRY_insert(st, val, i) SKM_sk_insert(X509_NAME_ENTRY, (st), (val), (i))\n# define sk_X509_NAME_ENTRY_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(X509_NAME_ENTRY, (st), (cmp))\n# define sk_X509_NAME_ENTRY_dup(st) SKM_sk_dup(X509_NAME_ENTRY, st)\n# define sk_X509_NAME_ENTRY_pop_free(st, free_func) SKM_sk_pop_free(X509_NAME_ENTRY, (st), (free_func))\n# define sk_X509_NAME_ENTRY_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(X509_NAME_ENTRY, (st), (copy_func), (free_func))\n# define sk_X509_NAME_ENTRY_shift(st) SKM_sk_shift(X509_NAME_ENTRY, (st))\n# define sk_X509_NAME_ENTRY_pop(st) SKM_sk_pop(X509_NAME_ENTRY, (st))\n# define sk_X509_NAME_ENTRY_sort(st) SKM_sk_sort(X509_NAME_ENTRY, (st))\n# define sk_X509_NAME_ENTRY_is_sorted(st) SKM_sk_is_sorted(X509_NAME_ENTRY, (st))\n# define sk_X509_OBJECT_new(cmp) SKM_sk_new(X509_OBJECT, (cmp))\n# define sk_X509_OBJECT_new_null() SKM_sk_new_null(X509_OBJECT)\n# define sk_X509_OBJECT_free(st) SKM_sk_free(X509_OBJECT, (st))\n# define sk_X509_OBJECT_num(st) SKM_sk_num(X509_OBJECT, (st))\n# define sk_X509_OBJECT_value(st, i) SKM_sk_value(X509_OBJECT, (st), (i))\n# define sk_X509_OBJECT_set(st, i, val) SKM_sk_set(X509_OBJECT, (st), (i), (val))\n# define sk_X509_OBJECT_zero(st) SKM_sk_zero(X509_OBJECT, (st))\n# define sk_X509_OBJECT_push(st, val) SKM_sk_push(X509_OBJECT, (st), (val))\n# define sk_X509_OBJECT_unshift(st, val) SKM_sk_unshift(X509_OBJECT, (st), (val))\n# define sk_X509_OBJECT_find(st, val) SKM_sk_find(X509_OBJECT, (st), (val))\n# define sk_X509_OBJECT_find_ex(st, val) SKM_sk_find_ex(X509_OBJECT, (st), (val))\n# define sk_X509_OBJECT_delete(st, i) SKM_sk_delete(X509_OBJECT, (st), (i))\n# define sk_X509_OBJECT_delete_ptr(st, ptr) SKM_sk_delete_ptr(X509_OBJECT, (st), (ptr))\n# define sk_X509_OBJECT_insert(st, val, i) SKM_sk_insert(X509_OBJECT, (st), (val), (i))\n# define sk_X509_OBJECT_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(X509_OBJECT, (st), (cmp))\n# define sk_X509_OBJECT_dup(st) SKM_sk_dup(X509_OBJECT, st)\n# define sk_X509_OBJECT_pop_free(st, free_func) SKM_sk_pop_free(X509_OBJECT, (st), (free_func))\n# define sk_X509_OBJECT_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(X509_OBJECT, (st), (copy_func), (free_func))\n# define sk_X509_OBJECT_shift(st) SKM_sk_shift(X509_OBJECT, (st))\n# define sk_X509_OBJECT_pop(st) SKM_sk_pop(X509_OBJECT, (st))\n# define sk_X509_OBJECT_sort(st) SKM_sk_sort(X509_OBJECT, (st))\n# define sk_X509_OBJECT_is_sorted(st) SKM_sk_is_sorted(X509_OBJECT, (st))\n# define sk_X509_POLICY_DATA_new(cmp) SKM_sk_new(X509_POLICY_DATA, (cmp))\n# define sk_X509_POLICY_DATA_new_null() SKM_sk_new_null(X509_POLICY_DATA)\n# define sk_X509_POLICY_DATA_free(st) SKM_sk_free(X509_POLICY_DATA, (st))\n# define sk_X509_POLICY_DATA_num(st) SKM_sk_num(X509_POLICY_DATA, (st))\n# define sk_X509_POLICY_DATA_value(st, i) SKM_sk_value(X509_POLICY_DATA, (st), (i))\n# define sk_X509_POLICY_DATA_set(st, i, val) SKM_sk_set(X509_POLICY_DATA, (st), (i), (val))\n# define sk_X509_POLICY_DATA_zero(st) SKM_sk_zero(X509_POLICY_DATA, (st))\n# define sk_X509_POLICY_DATA_push(st, val) SKM_sk_push(X509_POLICY_DATA, (st), (val))\n# define sk_X509_POLICY_DATA_unshift(st, val) SKM_sk_unshift(X509_POLICY_DATA, (st), (val))\n# define sk_X509_POLICY_DATA_find(st, val) SKM_sk_find(X509_POLICY_DATA, (st), (val))\n# define sk_X509_POLICY_DATA_find_ex(st, val) SKM_sk_find_ex(X509_POLICY_DATA, (st), (val))\n# define sk_X509_POLICY_DATA_delete(st, i) SKM_sk_delete(X509_POLICY_DATA, (st), (i))\n# define sk_X509_POLICY_DATA_delete_ptr(st, ptr) SKM_sk_delete_ptr(X509_POLICY_DATA, (st), (ptr))\n# define sk_X509_POLICY_DATA_insert(st, val, i) SKM_sk_insert(X509_POLICY_DATA, (st), (val), (i))\n# define sk_X509_POLICY_DATA_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(X509_POLICY_DATA, (st), (cmp))\n# define sk_X509_POLICY_DATA_dup(st) SKM_sk_dup(X509_POLICY_DATA, st)\n# define sk_X509_POLICY_DATA_pop_free(st, free_func) SKM_sk_pop_free(X509_POLICY_DATA, (st), (free_func))\n# define sk_X509_POLICY_DATA_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(X509_POLICY_DATA, (st), (copy_func), (free_func))\n# define sk_X509_POLICY_DATA_shift(st) SKM_sk_shift(X509_POLICY_DATA, (st))\n# define sk_X509_POLICY_DATA_pop(st) SKM_sk_pop(X509_POLICY_DATA, (st))\n# define sk_X509_POLICY_DATA_sort(st) SKM_sk_sort(X509_POLICY_DATA, (st))\n# define sk_X509_POLICY_DATA_is_sorted(st) SKM_sk_is_sorted(X509_POLICY_DATA, (st))\n# define sk_X509_POLICY_NODE_new(cmp) SKM_sk_new(X509_POLICY_NODE, (cmp))\n# define sk_X509_POLICY_NODE_new_null() SKM_sk_new_null(X509_POLICY_NODE)\n# define sk_X509_POLICY_NODE_free(st) SKM_sk_free(X509_POLICY_NODE, (st))\n# define sk_X509_POLICY_NODE_num(st) SKM_sk_num(X509_POLICY_NODE, (st))\n# define sk_X509_POLICY_NODE_value(st, i) SKM_sk_value(X509_POLICY_NODE, (st), (i))\n# define sk_X509_POLICY_NODE_set(st, i, val) SKM_sk_set(X509_POLICY_NODE, (st), (i), (val))\n# define sk_X509_POLICY_NODE_zero(st) SKM_sk_zero(X509_POLICY_NODE, (st))\n# define sk_X509_POLICY_NODE_push(st, val) SKM_sk_push(X509_POLICY_NODE, (st), (val))\n# define sk_X509_POLICY_NODE_unshift(st, val) SKM_sk_unshift(X509_POLICY_NODE, (st), (val))\n# define sk_X509_POLICY_NODE_find(st, val) SKM_sk_find(X509_POLICY_NODE, (st), (val))\n# define sk_X509_POLICY_NODE_find_ex(st, val) SKM_sk_find_ex(X509_POLICY_NODE, (st), (val))\n# define sk_X509_POLICY_NODE_delete(st, i) SKM_sk_delete(X509_POLICY_NODE, (st), (i))\n# define sk_X509_POLICY_NODE_delete_ptr(st, ptr) SKM_sk_delete_ptr(X509_POLICY_NODE, (st), (ptr))\n# define sk_X509_POLICY_NODE_insert(st, val, i) SKM_sk_insert(X509_POLICY_NODE, (st), (val), (i))\n# define sk_X509_POLICY_NODE_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(X509_POLICY_NODE, (st), (cmp))\n# define sk_X509_POLICY_NODE_dup(st) SKM_sk_dup(X509_POLICY_NODE, st)\n# define sk_X509_POLICY_NODE_pop_free(st, free_func) SKM_sk_pop_free(X509_POLICY_NODE, (st), (free_func))\n# define sk_X509_POLICY_NODE_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(X509_POLICY_NODE, (st), (copy_func), (free_func))\n# define sk_X509_POLICY_NODE_shift(st) SKM_sk_shift(X509_POLICY_NODE, (st))\n# define sk_X509_POLICY_NODE_pop(st) SKM_sk_pop(X509_POLICY_NODE, (st))\n# define sk_X509_POLICY_NODE_sort(st) SKM_sk_sort(X509_POLICY_NODE, (st))\n# define sk_X509_POLICY_NODE_is_sorted(st) SKM_sk_is_sorted(X509_POLICY_NODE, (st))\n# define sk_X509_PURPOSE_new(cmp) SKM_sk_new(X509_PURPOSE, (cmp))\n# define sk_X509_PURPOSE_new_null() SKM_sk_new_null(X509_PURPOSE)\n# define sk_X509_PURPOSE_free(st) SKM_sk_free(X509_PURPOSE, (st))\n# define sk_X509_PURPOSE_num(st) SKM_sk_num(X509_PURPOSE, (st))\n# define sk_X509_PURPOSE_value(st, i) SKM_sk_value(X509_PURPOSE, (st), (i))\n# define sk_X509_PURPOSE_set(st, i, val) SKM_sk_set(X509_PURPOSE, (st), (i), (val))\n# define sk_X509_PURPOSE_zero(st) SKM_sk_zero(X509_PURPOSE, (st))\n# define sk_X509_PURPOSE_push(st, val) SKM_sk_push(X509_PURPOSE, (st), (val))\n# define sk_X509_PURPOSE_unshift(st, val) SKM_sk_unshift(X509_PURPOSE, (st), (val))\n# define sk_X509_PURPOSE_find(st, val) SKM_sk_find(X509_PURPOSE, (st), (val))\n# define sk_X509_PURPOSE_find_ex(st, val) SKM_sk_find_ex(X509_PURPOSE, (st), (val))\n# define sk_X509_PURPOSE_delete(st, i) SKM_sk_delete(X509_PURPOSE, (st), (i))\n# define sk_X509_PURPOSE_delete_ptr(st, ptr) SKM_sk_delete_ptr(X509_PURPOSE, (st), (ptr))\n# define sk_X509_PURPOSE_insert(st, val, i) SKM_sk_insert(X509_PURPOSE, (st), (val), (i))\n# define sk_X509_PURPOSE_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(X509_PURPOSE, (st), (cmp))\n# define sk_X509_PURPOSE_dup(st) SKM_sk_dup(X509_PURPOSE, st)\n# define sk_X509_PURPOSE_pop_free(st, free_func) SKM_sk_pop_free(X509_PURPOSE, (st), (free_func))\n# define sk_X509_PURPOSE_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(X509_PURPOSE, (st), (copy_func), (free_func))\n# define sk_X509_PURPOSE_shift(st) SKM_sk_shift(X509_PURPOSE, (st))\n# define sk_X509_PURPOSE_pop(st) SKM_sk_pop(X509_PURPOSE, (st))\n# define sk_X509_PURPOSE_sort(st) SKM_sk_sort(X509_PURPOSE, (st))\n# define sk_X509_PURPOSE_is_sorted(st) SKM_sk_is_sorted(X509_PURPOSE, (st))\n# define sk_X509_REVOKED_new(cmp) SKM_sk_new(X509_REVOKED, (cmp))\n# define sk_X509_REVOKED_new_null() SKM_sk_new_null(X509_REVOKED)\n# define sk_X509_REVOKED_free(st) SKM_sk_free(X509_REVOKED, (st))\n# define sk_X509_REVOKED_num(st) SKM_sk_num(X509_REVOKED, (st))\n# define sk_X509_REVOKED_value(st, i) SKM_sk_value(X509_REVOKED, (st), (i))\n# define sk_X509_REVOKED_set(st, i, val) SKM_sk_set(X509_REVOKED, (st), (i), (val))\n# define sk_X509_REVOKED_zero(st) SKM_sk_zero(X509_REVOKED, (st))\n# define sk_X509_REVOKED_push(st, val) SKM_sk_push(X509_REVOKED, (st), (val))\n# define sk_X509_REVOKED_unshift(st, val) SKM_sk_unshift(X509_REVOKED, (st), (val))\n# define sk_X509_REVOKED_find(st, val) SKM_sk_find(X509_REVOKED, (st), (val))\n# define sk_X509_REVOKED_find_ex(st, val) SKM_sk_find_ex(X509_REVOKED, (st), (val))\n# define sk_X509_REVOKED_delete(st, i) SKM_sk_delete(X509_REVOKED, (st), (i))\n# define sk_X509_REVOKED_delete_ptr(st, ptr) SKM_sk_delete_ptr(X509_REVOKED, (st), (ptr))\n# define sk_X509_REVOKED_insert(st, val, i) SKM_sk_insert(X509_REVOKED, (st), (val), (i))\n# define sk_X509_REVOKED_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(X509_REVOKED, (st), (cmp))\n# define sk_X509_REVOKED_dup(st) SKM_sk_dup(X509_REVOKED, st)\n# define sk_X509_REVOKED_pop_free(st, free_func) SKM_sk_pop_free(X509_REVOKED, (st), (free_func))\n# define sk_X509_REVOKED_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(X509_REVOKED, (st), (copy_func), (free_func))\n# define sk_X509_REVOKED_shift(st) SKM_sk_shift(X509_REVOKED, (st))\n# define sk_X509_REVOKED_pop(st) SKM_sk_pop(X509_REVOKED, (st))\n# define sk_X509_REVOKED_sort(st) SKM_sk_sort(X509_REVOKED, (st))\n# define sk_X509_REVOKED_is_sorted(st) SKM_sk_is_sorted(X509_REVOKED, (st))\n# define sk_X509_TRUST_new(cmp) SKM_sk_new(X509_TRUST, (cmp))\n# define sk_X509_TRUST_new_null() SKM_sk_new_null(X509_TRUST)\n# define sk_X509_TRUST_free(st) SKM_sk_free(X509_TRUST, (st))\n# define sk_X509_TRUST_num(st) SKM_sk_num(X509_TRUST, (st))\n# define sk_X509_TRUST_value(st, i) SKM_sk_value(X509_TRUST, (st), (i))\n# define sk_X509_TRUST_set(st, i, val) SKM_sk_set(X509_TRUST, (st), (i), (val))\n# define sk_X509_TRUST_zero(st) SKM_sk_zero(X509_TRUST, (st))\n# define sk_X509_TRUST_push(st, val) SKM_sk_push(X509_TRUST, (st), (val))\n# define sk_X509_TRUST_unshift(st, val) SKM_sk_unshift(X509_TRUST, (st), (val))\n# define sk_X509_TRUST_find(st, val) SKM_sk_find(X509_TRUST, (st), (val))\n# define sk_X509_TRUST_find_ex(st, val) SKM_sk_find_ex(X509_TRUST, (st), (val))\n# define sk_X509_TRUST_delete(st, i) SKM_sk_delete(X509_TRUST, (st), (i))\n# define sk_X509_TRUST_delete_ptr(st, ptr) SKM_sk_delete_ptr(X509_TRUST, (st), (ptr))\n# define sk_X509_TRUST_insert(st, val, i) SKM_sk_insert(X509_TRUST, (st), (val), (i))\n# define sk_X509_TRUST_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(X509_TRUST, (st), (cmp))\n# define sk_X509_TRUST_dup(st) SKM_sk_dup(X509_TRUST, st)\n# define sk_X509_TRUST_pop_free(st, free_func) SKM_sk_pop_free(X509_TRUST, (st), (free_func))\n# define sk_X509_TRUST_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(X509_TRUST, (st), (copy_func), (free_func))\n# define sk_X509_TRUST_shift(st) SKM_sk_shift(X509_TRUST, (st))\n# define sk_X509_TRUST_pop(st) SKM_sk_pop(X509_TRUST, (st))\n# define sk_X509_TRUST_sort(st) SKM_sk_sort(X509_TRUST, (st))\n# define sk_X509_TRUST_is_sorted(st) SKM_sk_is_sorted(X509_TRUST, (st))\n# define sk_X509_VERIFY_PARAM_new(cmp) SKM_sk_new(X509_VERIFY_PARAM, (cmp))\n# define sk_X509_VERIFY_PARAM_new_null() SKM_sk_new_null(X509_VERIFY_PARAM)\n# define sk_X509_VERIFY_PARAM_free(st) SKM_sk_free(X509_VERIFY_PARAM, (st))\n# define sk_X509_VERIFY_PARAM_num(st) SKM_sk_num(X509_VERIFY_PARAM, (st))\n# define sk_X509_VERIFY_PARAM_value(st, i) SKM_sk_value(X509_VERIFY_PARAM, (st), (i))\n# define sk_X509_VERIFY_PARAM_set(st, i, val) SKM_sk_set(X509_VERIFY_PARAM, (st), (i), (val))\n# define sk_X509_VERIFY_PARAM_zero(st) SKM_sk_zero(X509_VERIFY_PARAM, (st))\n# define sk_X509_VERIFY_PARAM_push(st, val) SKM_sk_push(X509_VERIFY_PARAM, (st), (val))\n# define sk_X509_VERIFY_PARAM_unshift(st, val) SKM_sk_unshift(X509_VERIFY_PARAM, (st), (val))\n# define sk_X509_VERIFY_PARAM_find(st, val) SKM_sk_find(X509_VERIFY_PARAM, (st), (val))\n# define sk_X509_VERIFY_PARAM_find_ex(st, val) SKM_sk_find_ex(X509_VERIFY_PARAM, (st), (val))\n# define sk_X509_VERIFY_PARAM_delete(st, i) SKM_sk_delete(X509_VERIFY_PARAM, (st), (i))\n# define sk_X509_VERIFY_PARAM_delete_ptr(st, ptr) SKM_sk_delete_ptr(X509_VERIFY_PARAM, (st), (ptr))\n# define sk_X509_VERIFY_PARAM_insert(st, val, i) SKM_sk_insert(X509_VERIFY_PARAM, (st), (val), (i))\n# define sk_X509_VERIFY_PARAM_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(X509_VERIFY_PARAM, (st), (cmp))\n# define sk_X509_VERIFY_PARAM_dup(st) SKM_sk_dup(X509_VERIFY_PARAM, st)\n# define sk_X509_VERIFY_PARAM_pop_free(st, free_func) SKM_sk_pop_free(X509_VERIFY_PARAM, (st), (free_func))\n# define sk_X509_VERIFY_PARAM_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(X509_VERIFY_PARAM, (st), (copy_func), (free_func))\n# define sk_X509_VERIFY_PARAM_shift(st) SKM_sk_shift(X509_VERIFY_PARAM, (st))\n# define sk_X509_VERIFY_PARAM_pop(st) SKM_sk_pop(X509_VERIFY_PARAM, (st))\n# define sk_X509_VERIFY_PARAM_sort(st) SKM_sk_sort(X509_VERIFY_PARAM, (st))\n# define sk_X509_VERIFY_PARAM_is_sorted(st) SKM_sk_is_sorted(X509_VERIFY_PARAM, (st))\n# define sk_nid_triple_new(cmp) SKM_sk_new(nid_triple, (cmp))\n# define sk_nid_triple_new_null() SKM_sk_new_null(nid_triple)\n# define sk_nid_triple_free(st) SKM_sk_free(nid_triple, (st))\n# define sk_nid_triple_num(st) SKM_sk_num(nid_triple, (st))\n# define sk_nid_triple_value(st, i) SKM_sk_value(nid_triple, (st), (i))\n# define sk_nid_triple_set(st, i, val) SKM_sk_set(nid_triple, (st), (i), (val))\n# define sk_nid_triple_zero(st) SKM_sk_zero(nid_triple, (st))\n# define sk_nid_triple_push(st, val) SKM_sk_push(nid_triple, (st), (val))\n# define sk_nid_triple_unshift(st, val) SKM_sk_unshift(nid_triple, (st), (val))\n# define sk_nid_triple_find(st, val) SKM_sk_find(nid_triple, (st), (val))\n# define sk_nid_triple_find_ex(st, val) SKM_sk_find_ex(nid_triple, (st), (val))\n# define sk_nid_triple_delete(st, i) SKM_sk_delete(nid_triple, (st), (i))\n# define sk_nid_triple_delete_ptr(st, ptr) SKM_sk_delete_ptr(nid_triple, (st), (ptr))\n# define sk_nid_triple_insert(st, val, i) SKM_sk_insert(nid_triple, (st), (val), (i))\n# define sk_nid_triple_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(nid_triple, (st), (cmp))\n# define sk_nid_triple_dup(st) SKM_sk_dup(nid_triple, st)\n# define sk_nid_triple_pop_free(st, free_func) SKM_sk_pop_free(nid_triple, (st), (free_func))\n# define sk_nid_triple_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(nid_triple, (st), (copy_func), (free_func))\n# define sk_nid_triple_shift(st) SKM_sk_shift(nid_triple, (st))\n# define sk_nid_triple_pop(st) SKM_sk_pop(nid_triple, (st))\n# define sk_nid_triple_sort(st) SKM_sk_sort(nid_triple, (st))\n# define sk_nid_triple_is_sorted(st) SKM_sk_is_sorted(nid_triple, (st))\n# define sk_void_new(cmp) SKM_sk_new(void, (cmp))\n# define sk_void_new_null() SKM_sk_new_null(void)\n# define sk_void_free(st) SKM_sk_free(void, (st))\n# define sk_void_num(st) SKM_sk_num(void, (st))\n# define sk_void_value(st, i) SKM_sk_value(void, (st), (i))\n# define sk_void_set(st, i, val) SKM_sk_set(void, (st), (i), (val))\n# define sk_void_zero(st) SKM_sk_zero(void, (st))\n# define sk_void_push(st, val) SKM_sk_push(void, (st), (val))\n# define sk_void_unshift(st, val) SKM_sk_unshift(void, (st), (val))\n# define sk_void_find(st, val) SKM_sk_find(void, (st), (val))\n# define sk_void_find_ex(st, val) SKM_sk_find_ex(void, (st), (val))\n# define sk_void_delete(st, i) SKM_sk_delete(void, (st), (i))\n# define sk_void_delete_ptr(st, ptr) SKM_sk_delete_ptr(void, (st), (ptr))\n# define sk_void_insert(st, val, i) SKM_sk_insert(void, (st), (val), (i))\n# define sk_void_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(void, (st), (cmp))\n# define sk_void_dup(st) SKM_sk_dup(void, st)\n# define sk_void_pop_free(st, free_func) SKM_sk_pop_free(void, (st), (free_func))\n# define sk_void_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(void, (st), (copy_func), (free_func))\n# define sk_void_shift(st) SKM_sk_shift(void, (st))\n# define sk_void_pop(st) SKM_sk_pop(void, (st))\n# define sk_void_sort(st) SKM_sk_sort(void, (st))\n# define sk_void_is_sorted(st) SKM_sk_is_sorted(void, (st))\n# define sk_OPENSSL_STRING_new(cmp) ((STACK_OF(OPENSSL_STRING) *)sk_new(CHECKED_SK_CMP_FUNC(char, cmp)))\n# define sk_OPENSSL_STRING_new_null() ((STACK_OF(OPENSSL_STRING) *)sk_new_null())\n# define sk_OPENSSL_STRING_push(st, val) sk_push(CHECKED_STACK_OF(OPENSSL_STRING, st), CHECKED_PTR_OF(char, val))\n# define sk_OPENSSL_STRING_find(st, val) sk_find(CHECKED_STACK_OF(OPENSSL_STRING, st), CHECKED_PTR_OF(char, val))\n# define sk_OPENSSL_STRING_value(st, i) ((OPENSSL_STRING)sk_value(CHECKED_STACK_OF(OPENSSL_STRING, st), i))\n# define sk_OPENSSL_STRING_num(st) SKM_sk_num(OPENSSL_STRING, st)\n# define sk_OPENSSL_STRING_pop_free(st, free_func) sk_pop_free(CHECKED_STACK_OF(OPENSSL_STRING, st), CHECKED_SK_FREE_FUNC(char, free_func))\n# define sk_OPENSSL_STRING_deep_copy(st, copy_func, free_func) ((STACK_OF(OPENSSL_STRING) *)sk_deep_copy(CHECKED_STACK_OF(OPENSSL_STRING, st), CHECKED_SK_COPY_FUNC(char, copy_func), CHECKED_SK_FREE_FUNC(char, free_func)))\n# define sk_OPENSSL_STRING_insert(st, val, i) sk_insert(CHECKED_STACK_OF(OPENSSL_STRING, st), CHECKED_PTR_OF(char, val), i)\n# define sk_OPENSSL_STRING_free(st) SKM_sk_free(OPENSSL_STRING, st)\n# define sk_OPENSSL_STRING_set(st, i, val) sk_set(CHECKED_STACK_OF(OPENSSL_STRING, st), i, CHECKED_PTR_OF(char, val))\n# define sk_OPENSSL_STRING_zero(st) SKM_sk_zero(OPENSSL_STRING, (st))\n# define sk_OPENSSL_STRING_unshift(st, val) sk_unshift(CHECKED_STACK_OF(OPENSSL_STRING, st), CHECKED_PTR_OF(char, val))\n# define sk_OPENSSL_STRING_find_ex(st, val) sk_find_ex((_STACK *)CHECKED_CONST_PTR_OF(STACK_OF(OPENSSL_STRING), st), CHECKED_CONST_PTR_OF(char, val))\n# define sk_OPENSSL_STRING_delete(st, i) SKM_sk_delete(OPENSSL_STRING, (st), (i))\n# define sk_OPENSSL_STRING_delete_ptr(st, ptr) (OPENSSL_STRING *)sk_delete_ptr(CHECKED_STACK_OF(OPENSSL_STRING, st), CHECKED_PTR_OF(char, ptr))\n# define sk_OPENSSL_STRING_set_cmp_func(st, cmp)  \\\n        ((int (*)(const char * const *,const char * const *)) \\\n        sk_set_cmp_func(CHECKED_STACK_OF(OPENSSL_STRING, st), CHECKED_SK_CMP_FUNC(char, cmp)))\n# define sk_OPENSSL_STRING_dup(st) SKM_sk_dup(OPENSSL_STRING, st)\n# define sk_OPENSSL_STRING_shift(st) SKM_sk_shift(OPENSSL_STRING, (st))\n# define sk_OPENSSL_STRING_pop(st) (char *)sk_pop(CHECKED_STACK_OF(OPENSSL_STRING, st))\n# define sk_OPENSSL_STRING_sort(st) SKM_sk_sort(OPENSSL_STRING, (st))\n# define sk_OPENSSL_STRING_is_sorted(st) SKM_sk_is_sorted(OPENSSL_STRING, (st))\n# define sk_OPENSSL_BLOCK_new(cmp) ((STACK_OF(OPENSSL_BLOCK) *)sk_new(CHECKED_SK_CMP_FUNC(void, cmp)))\n# define sk_OPENSSL_BLOCK_new_null() ((STACK_OF(OPENSSL_BLOCK) *)sk_new_null())\n# define sk_OPENSSL_BLOCK_push(st, val) sk_push(CHECKED_STACK_OF(OPENSSL_BLOCK, st), CHECKED_PTR_OF(void, val))\n# define sk_OPENSSL_BLOCK_find(st, val) sk_find(CHECKED_STACK_OF(OPENSSL_BLOCK, st), CHECKED_PTR_OF(void, val))\n# define sk_OPENSSL_BLOCK_value(st, i) ((OPENSSL_BLOCK)sk_value(CHECKED_STACK_OF(OPENSSL_BLOCK, st), i))\n# define sk_OPENSSL_BLOCK_num(st) SKM_sk_num(OPENSSL_BLOCK, st)\n# define sk_OPENSSL_BLOCK_pop_free(st, free_func) sk_pop_free(CHECKED_STACK_OF(OPENSSL_BLOCK, st), CHECKED_SK_FREE_FUNC(void, free_func))\n# define sk_OPENSSL_BLOCK_deep_copy(st, copy_func, free_func) ((STACK_OF(OPENSSL_BLOCK) *)sk_deep_copy(CHECKED_STACK_OF(OPENSSL_BLOCK, st), CHECKED_SK_COPY_FUNC(void, copy_func), CHECKED_SK_FREE_FUNC(void, free_func)))\n# define sk_OPENSSL_BLOCK_insert(st, val, i) sk_insert(CHECKED_STACK_OF(OPENSSL_BLOCK, st), CHECKED_PTR_OF(void, val), i)\n# define sk_OPENSSL_BLOCK_free(st) SKM_sk_free(OPENSSL_BLOCK, st)\n# define sk_OPENSSL_BLOCK_set(st, i, val) sk_set(CHECKED_STACK_OF(OPENSSL_BLOCK, st), i, CHECKED_PTR_OF(void, val))\n# define sk_OPENSSL_BLOCK_zero(st) SKM_sk_zero(OPENSSL_BLOCK, (st))\n# define sk_OPENSSL_BLOCK_unshift(st, val) sk_unshift(CHECKED_STACK_OF(OPENSSL_BLOCK, st), CHECKED_PTR_OF(void, val))\n# define sk_OPENSSL_BLOCK_find_ex(st, val) sk_find_ex((_STACK *)CHECKED_CONST_PTR_OF(STACK_OF(OPENSSL_BLOCK), st), CHECKED_CONST_PTR_OF(void, val))\n# define sk_OPENSSL_BLOCK_delete(st, i) SKM_sk_delete(OPENSSL_BLOCK, (st), (i))\n# define sk_OPENSSL_BLOCK_delete_ptr(st, ptr) (OPENSSL_BLOCK *)sk_delete_ptr(CHECKED_STACK_OF(OPENSSL_BLOCK, st), CHECKED_PTR_OF(void, ptr))\n# define sk_OPENSSL_BLOCK_set_cmp_func(st, cmp)  \\\n        ((int (*)(const void * const *,const void * const *)) \\\n        sk_set_cmp_func(CHECKED_STACK_OF(OPENSSL_BLOCK, st), CHECKED_SK_CMP_FUNC(void, cmp)))\n# define sk_OPENSSL_BLOCK_dup(st) SKM_sk_dup(OPENSSL_BLOCK, st)\n# define sk_OPENSSL_BLOCK_shift(st) SKM_sk_shift(OPENSSL_BLOCK, (st))\n# define sk_OPENSSL_BLOCK_pop(st) (void *)sk_pop(CHECKED_STACK_OF(OPENSSL_BLOCK, st))\n# define sk_OPENSSL_BLOCK_sort(st) SKM_sk_sort(OPENSSL_BLOCK, (st))\n# define sk_OPENSSL_BLOCK_is_sorted(st) SKM_sk_is_sorted(OPENSSL_BLOCK, (st))\n# define sk_OPENSSL_PSTRING_new(cmp) ((STACK_OF(OPENSSL_PSTRING) *)sk_new(CHECKED_SK_CMP_FUNC(OPENSSL_STRING, cmp)))\n# define sk_OPENSSL_PSTRING_new_null() ((STACK_OF(OPENSSL_PSTRING) *)sk_new_null())\n# define sk_OPENSSL_PSTRING_push(st, val) sk_push(CHECKED_STACK_OF(OPENSSL_PSTRING, st), CHECKED_PTR_OF(OPENSSL_STRING, val))\n# define sk_OPENSSL_PSTRING_find(st, val) sk_find(CHECKED_STACK_OF(OPENSSL_PSTRING, st), CHECKED_PTR_OF(OPENSSL_STRING, val))\n# define sk_OPENSSL_PSTRING_value(st, i) ((OPENSSL_PSTRING)sk_value(CHECKED_STACK_OF(OPENSSL_PSTRING, st), i))\n# define sk_OPENSSL_PSTRING_num(st) SKM_sk_num(OPENSSL_PSTRING, st)\n# define sk_OPENSSL_PSTRING_pop_free(st, free_func) sk_pop_free(CHECKED_STACK_OF(OPENSSL_PSTRING, st), CHECKED_SK_FREE_FUNC(OPENSSL_STRING, free_func))\n# define sk_OPENSSL_PSTRING_deep_copy(st, copy_func, free_func) ((STACK_OF(OPENSSL_PSTRING) *)sk_deep_copy(CHECKED_STACK_OF(OPENSSL_PSTRING, st), CHECKED_SK_COPY_FUNC(OPENSSL_STRING, copy_func), CHECKED_SK_FREE_FUNC(OPENSSL_STRING, free_func)))\n# define sk_OPENSSL_PSTRING_insert(st, val, i) sk_insert(CHECKED_STACK_OF(OPENSSL_PSTRING, st), CHECKED_PTR_OF(OPENSSL_STRING, val), i)\n# define sk_OPENSSL_PSTRING_free(st) SKM_sk_free(OPENSSL_PSTRING, st)\n# define sk_OPENSSL_PSTRING_set(st, i, val) sk_set(CHECKED_STACK_OF(OPENSSL_PSTRING, st), i, CHECKED_PTR_OF(OPENSSL_STRING, val))\n# define sk_OPENSSL_PSTRING_zero(st) SKM_sk_zero(OPENSSL_PSTRING, (st))\n# define sk_OPENSSL_PSTRING_unshift(st, val) sk_unshift(CHECKED_STACK_OF(OPENSSL_PSTRING, st), CHECKED_PTR_OF(OPENSSL_STRING, val))\n# define sk_OPENSSL_PSTRING_find_ex(st, val) sk_find_ex((_STACK *)CHECKED_CONST_PTR_OF(STACK_OF(OPENSSL_PSTRING), st), CHECKED_CONST_PTR_OF(OPENSSL_STRING, val))\n# define sk_OPENSSL_PSTRING_delete(st, i) SKM_sk_delete(OPENSSL_PSTRING, (st), (i))\n# define sk_OPENSSL_PSTRING_delete_ptr(st, ptr) (OPENSSL_PSTRING *)sk_delete_ptr(CHECKED_STACK_OF(OPENSSL_PSTRING, st), CHECKED_PTR_OF(OPENSSL_STRING, ptr))\n# define sk_OPENSSL_PSTRING_set_cmp_func(st, cmp)  \\\n        ((int (*)(const OPENSSL_STRING * const *,const OPENSSL_STRING * const *)) \\\n        sk_set_cmp_func(CHECKED_STACK_OF(OPENSSL_PSTRING, st), CHECKED_SK_CMP_FUNC(OPENSSL_STRING, cmp)))\n# define sk_OPENSSL_PSTRING_dup(st) SKM_sk_dup(OPENSSL_PSTRING, st)\n# define sk_OPENSSL_PSTRING_shift(st) SKM_sk_shift(OPENSSL_PSTRING, (st))\n# define sk_OPENSSL_PSTRING_pop(st) (OPENSSL_STRING *)sk_pop(CHECKED_STACK_OF(OPENSSL_PSTRING, st))\n# define sk_OPENSSL_PSTRING_sort(st) SKM_sk_sort(OPENSSL_PSTRING, (st))\n# define sk_OPENSSL_PSTRING_is_sorted(st) SKM_sk_is_sorted(OPENSSL_PSTRING, (st))\n# define d2i_ASN1_SET_OF_ACCESS_DESCRIPTION(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \\\n        SKM_ASN1_SET_OF_d2i(ACCESS_DESCRIPTION, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class))\n# define i2d_ASN1_SET_OF_ACCESS_DESCRIPTION(st, pp, i2d_func, ex_tag, ex_class, is_set) \\\n        SKM_ASN1_SET_OF_i2d(ACCESS_DESCRIPTION, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set))\n# define ASN1_seq_pack_ACCESS_DESCRIPTION(st, i2d_func, buf, len) \\\n        SKM_ASN1_seq_pack(ACCESS_DESCRIPTION, (st), (i2d_func), (buf), (len))\n# define ASN1_seq_unpack_ACCESS_DESCRIPTION(buf, len, d2i_func, free_func) \\\n        SKM_ASN1_seq_unpack(ACCESS_DESCRIPTION, (buf), (len), (d2i_func), (free_func))\n# define d2i_ASN1_SET_OF_ASN1_INTEGER(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \\\n        SKM_ASN1_SET_OF_d2i(ASN1_INTEGER, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class))\n# define i2d_ASN1_SET_OF_ASN1_INTEGER(st, pp, i2d_func, ex_tag, ex_class, is_set) \\\n        SKM_ASN1_SET_OF_i2d(ASN1_INTEGER, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set))\n# define ASN1_seq_pack_ASN1_INTEGER(st, i2d_func, buf, len) \\\n        SKM_ASN1_seq_pack(ASN1_INTEGER, (st), (i2d_func), (buf), (len))\n# define ASN1_seq_unpack_ASN1_INTEGER(buf, len, d2i_func, free_func) \\\n        SKM_ASN1_seq_unpack(ASN1_INTEGER, (buf), (len), (d2i_func), (free_func))\n# define d2i_ASN1_SET_OF_ASN1_OBJECT(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \\\n        SKM_ASN1_SET_OF_d2i(ASN1_OBJECT, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class))\n# define i2d_ASN1_SET_OF_ASN1_OBJECT(st, pp, i2d_func, ex_tag, ex_class, is_set) \\\n        SKM_ASN1_SET_OF_i2d(ASN1_OBJECT, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set))\n# define ASN1_seq_pack_ASN1_OBJECT(st, i2d_func, buf, len) \\\n        SKM_ASN1_seq_pack(ASN1_OBJECT, (st), (i2d_func), (buf), (len))\n# define ASN1_seq_unpack_ASN1_OBJECT(buf, len, d2i_func, free_func) \\\n        SKM_ASN1_seq_unpack(ASN1_OBJECT, (buf), (len), (d2i_func), (free_func))\n# define d2i_ASN1_SET_OF_ASN1_TYPE(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \\\n        SKM_ASN1_SET_OF_d2i(ASN1_TYPE, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class))\n# define i2d_ASN1_SET_OF_ASN1_TYPE(st, pp, i2d_func, ex_tag, ex_class, is_set) \\\n        SKM_ASN1_SET_OF_i2d(ASN1_TYPE, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set))\n# define ASN1_seq_pack_ASN1_TYPE(st, i2d_func, buf, len) \\\n        SKM_ASN1_seq_pack(ASN1_TYPE, (st), (i2d_func), (buf), (len))\n# define ASN1_seq_unpack_ASN1_TYPE(buf, len, d2i_func, free_func) \\\n        SKM_ASN1_seq_unpack(ASN1_TYPE, (buf), (len), (d2i_func), (free_func))\n# define d2i_ASN1_SET_OF_ASN1_UTF8STRING(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \\\n        SKM_ASN1_SET_OF_d2i(ASN1_UTF8STRING, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class))\n# define i2d_ASN1_SET_OF_ASN1_UTF8STRING(st, pp, i2d_func, ex_tag, ex_class, is_set) \\\n        SKM_ASN1_SET_OF_i2d(ASN1_UTF8STRING, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set))\n# define ASN1_seq_pack_ASN1_UTF8STRING(st, i2d_func, buf, len) \\\n        SKM_ASN1_seq_pack(ASN1_UTF8STRING, (st), (i2d_func), (buf), (len))\n# define ASN1_seq_unpack_ASN1_UTF8STRING(buf, len, d2i_func, free_func) \\\n        SKM_ASN1_seq_unpack(ASN1_UTF8STRING, (buf), (len), (d2i_func), (free_func))\n# define d2i_ASN1_SET_OF_DIST_POINT(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \\\n        SKM_ASN1_SET_OF_d2i(DIST_POINT, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class))\n# define i2d_ASN1_SET_OF_DIST_POINT(st, pp, i2d_func, ex_tag, ex_class, is_set) \\\n        SKM_ASN1_SET_OF_i2d(DIST_POINT, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set))\n# define ASN1_seq_pack_DIST_POINT(st, i2d_func, buf, len) \\\n        SKM_ASN1_seq_pack(DIST_POINT, (st), (i2d_func), (buf), (len))\n# define ASN1_seq_unpack_DIST_POINT(buf, len, d2i_func, free_func) \\\n        SKM_ASN1_seq_unpack(DIST_POINT, (buf), (len), (d2i_func), (free_func))\n# define d2i_ASN1_SET_OF_ESS_CERT_ID(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \\\n        SKM_ASN1_SET_OF_d2i(ESS_CERT_ID, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class))\n# define i2d_ASN1_SET_OF_ESS_CERT_ID(st, pp, i2d_func, ex_tag, ex_class, is_set) \\\n        SKM_ASN1_SET_OF_i2d(ESS_CERT_ID, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set))\n# define ASN1_seq_pack_ESS_CERT_ID(st, i2d_func, buf, len) \\\n        SKM_ASN1_seq_pack(ESS_CERT_ID, (st), (i2d_func), (buf), (len))\n# define ASN1_seq_unpack_ESS_CERT_ID(buf, len, d2i_func, free_func) \\\n        SKM_ASN1_seq_unpack(ESS_CERT_ID, (buf), (len), (d2i_func), (free_func))\n# define d2i_ASN1_SET_OF_EVP_MD(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \\\n        SKM_ASN1_SET_OF_d2i(EVP_MD, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class))\n# define i2d_ASN1_SET_OF_EVP_MD(st, pp, i2d_func, ex_tag, ex_class, is_set) \\\n        SKM_ASN1_SET_OF_i2d(EVP_MD, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set))\n# define ASN1_seq_pack_EVP_MD(st, i2d_func, buf, len) \\\n        SKM_ASN1_seq_pack(EVP_MD, (st), (i2d_func), (buf), (len))\n# define ASN1_seq_unpack_EVP_MD(buf, len, d2i_func, free_func) \\\n        SKM_ASN1_seq_unpack(EVP_MD, (buf), (len), (d2i_func), (free_func))\n# define d2i_ASN1_SET_OF_GENERAL_NAME(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \\\n        SKM_ASN1_SET_OF_d2i(GENERAL_NAME, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class))\n# define i2d_ASN1_SET_OF_GENERAL_NAME(st, pp, i2d_func, ex_tag, ex_class, is_set) \\\n        SKM_ASN1_SET_OF_i2d(GENERAL_NAME, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set))\n# define ASN1_seq_pack_GENERAL_NAME(st, i2d_func, buf, len) \\\n        SKM_ASN1_seq_pack(GENERAL_NAME, (st), (i2d_func), (buf), (len))\n# define ASN1_seq_unpack_GENERAL_NAME(buf, len, d2i_func, free_func) \\\n        SKM_ASN1_seq_unpack(GENERAL_NAME, (buf), (len), (d2i_func), (free_func))\n# define d2i_ASN1_SET_OF_OCSP_ONEREQ(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \\\n        SKM_ASN1_SET_OF_d2i(OCSP_ONEREQ, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class))\n# define i2d_ASN1_SET_OF_OCSP_ONEREQ(st, pp, i2d_func, ex_tag, ex_class, is_set) \\\n        SKM_ASN1_SET_OF_i2d(OCSP_ONEREQ, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set))\n# define ASN1_seq_pack_OCSP_ONEREQ(st, i2d_func, buf, len) \\\n        SKM_ASN1_seq_pack(OCSP_ONEREQ, (st), (i2d_func), (buf), (len))\n# define ASN1_seq_unpack_OCSP_ONEREQ(buf, len, d2i_func, free_func) \\\n        SKM_ASN1_seq_unpack(OCSP_ONEREQ, (buf), (len), (d2i_func), (free_func))\n# define d2i_ASN1_SET_OF_OCSP_SINGLERESP(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \\\n        SKM_ASN1_SET_OF_d2i(OCSP_SINGLERESP, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class))\n# define i2d_ASN1_SET_OF_OCSP_SINGLERESP(st, pp, i2d_func, ex_tag, ex_class, is_set) \\\n        SKM_ASN1_SET_OF_i2d(OCSP_SINGLERESP, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set))\n# define ASN1_seq_pack_OCSP_SINGLERESP(st, i2d_func, buf, len) \\\n        SKM_ASN1_seq_pack(OCSP_SINGLERESP, (st), (i2d_func), (buf), (len))\n# define ASN1_seq_unpack_OCSP_SINGLERESP(buf, len, d2i_func, free_func) \\\n        SKM_ASN1_seq_unpack(OCSP_SINGLERESP, (buf), (len), (d2i_func), (free_func))\n# define d2i_ASN1_SET_OF_PKCS12_SAFEBAG(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \\\n        SKM_ASN1_SET_OF_d2i(PKCS12_SAFEBAG, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class))\n# define i2d_ASN1_SET_OF_PKCS12_SAFEBAG(st, pp, i2d_func, ex_tag, ex_class, is_set) \\\n        SKM_ASN1_SET_OF_i2d(PKCS12_SAFEBAG, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set))\n# define ASN1_seq_pack_PKCS12_SAFEBAG(st, i2d_func, buf, len) \\\n        SKM_ASN1_seq_pack(PKCS12_SAFEBAG, (st), (i2d_func), (buf), (len))\n# define ASN1_seq_unpack_PKCS12_SAFEBAG(buf, len, d2i_func, free_func) \\\n        SKM_ASN1_seq_unpack(PKCS12_SAFEBAG, (buf), (len), (d2i_func), (free_func))\n# define d2i_ASN1_SET_OF_PKCS7(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \\\n        SKM_ASN1_SET_OF_d2i(PKCS7, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class))\n# define i2d_ASN1_SET_OF_PKCS7(st, pp, i2d_func, ex_tag, ex_class, is_set) \\\n        SKM_ASN1_SET_OF_i2d(PKCS7, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set))\n# define ASN1_seq_pack_PKCS7(st, i2d_func, buf, len) \\\n        SKM_ASN1_seq_pack(PKCS7, (st), (i2d_func), (buf), (len))\n# define ASN1_seq_unpack_PKCS7(buf, len, d2i_func, free_func) \\\n        SKM_ASN1_seq_unpack(PKCS7, (buf), (len), (d2i_func), (free_func))\n# define d2i_ASN1_SET_OF_PKCS7_RECIP_INFO(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \\\n        SKM_ASN1_SET_OF_d2i(PKCS7_RECIP_INFO, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class))\n# define i2d_ASN1_SET_OF_PKCS7_RECIP_INFO(st, pp, i2d_func, ex_tag, ex_class, is_set) \\\n        SKM_ASN1_SET_OF_i2d(PKCS7_RECIP_INFO, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set))\n# define ASN1_seq_pack_PKCS7_RECIP_INFO(st, i2d_func, buf, len) \\\n        SKM_ASN1_seq_pack(PKCS7_RECIP_INFO, (st), (i2d_func), (buf), (len))\n# define ASN1_seq_unpack_PKCS7_RECIP_INFO(buf, len, d2i_func, free_func) \\\n        SKM_ASN1_seq_unpack(PKCS7_RECIP_INFO, (buf), (len), (d2i_func), (free_func))\n# define d2i_ASN1_SET_OF_PKCS7_SIGNER_INFO(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \\\n        SKM_ASN1_SET_OF_d2i(PKCS7_SIGNER_INFO, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class))\n# define i2d_ASN1_SET_OF_PKCS7_SIGNER_INFO(st, pp, i2d_func, ex_tag, ex_class, is_set) \\\n        SKM_ASN1_SET_OF_i2d(PKCS7_SIGNER_INFO, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set))\n# define ASN1_seq_pack_PKCS7_SIGNER_INFO(st, i2d_func, buf, len) \\\n        SKM_ASN1_seq_pack(PKCS7_SIGNER_INFO, (st), (i2d_func), (buf), (len))\n# define ASN1_seq_unpack_PKCS7_SIGNER_INFO(buf, len, d2i_func, free_func) \\\n        SKM_ASN1_seq_unpack(PKCS7_SIGNER_INFO, (buf), (len), (d2i_func), (free_func))\n# define d2i_ASN1_SET_OF_POLICYINFO(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \\\n        SKM_ASN1_SET_OF_d2i(POLICYINFO, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class))\n# define i2d_ASN1_SET_OF_POLICYINFO(st, pp, i2d_func, ex_tag, ex_class, is_set) \\\n        SKM_ASN1_SET_OF_i2d(POLICYINFO, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set))\n# define ASN1_seq_pack_POLICYINFO(st, i2d_func, buf, len) \\\n        SKM_ASN1_seq_pack(POLICYINFO, (st), (i2d_func), (buf), (len))\n# define ASN1_seq_unpack_POLICYINFO(buf, len, d2i_func, free_func) \\\n        SKM_ASN1_seq_unpack(POLICYINFO, (buf), (len), (d2i_func), (free_func))\n# define d2i_ASN1_SET_OF_POLICYQUALINFO(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \\\n        SKM_ASN1_SET_OF_d2i(POLICYQUALINFO, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class))\n# define i2d_ASN1_SET_OF_POLICYQUALINFO(st, pp, i2d_func, ex_tag, ex_class, is_set) \\\n        SKM_ASN1_SET_OF_i2d(POLICYQUALINFO, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set))\n# define ASN1_seq_pack_POLICYQUALINFO(st, i2d_func, buf, len) \\\n        SKM_ASN1_seq_pack(POLICYQUALINFO, (st), (i2d_func), (buf), (len))\n# define ASN1_seq_unpack_POLICYQUALINFO(buf, len, d2i_func, free_func) \\\n        SKM_ASN1_seq_unpack(POLICYQUALINFO, (buf), (len), (d2i_func), (free_func))\n# define d2i_ASN1_SET_OF_SXNETID(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \\\n        SKM_ASN1_SET_OF_d2i(SXNETID, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class))\n# define i2d_ASN1_SET_OF_SXNETID(st, pp, i2d_func, ex_tag, ex_class, is_set) \\\n        SKM_ASN1_SET_OF_i2d(SXNETID, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set))\n# define ASN1_seq_pack_SXNETID(st, i2d_func, buf, len) \\\n        SKM_ASN1_seq_pack(SXNETID, (st), (i2d_func), (buf), (len))\n# define ASN1_seq_unpack_SXNETID(buf, len, d2i_func, free_func) \\\n        SKM_ASN1_seq_unpack(SXNETID, (buf), (len), (d2i_func), (free_func))\n# define d2i_ASN1_SET_OF_X509(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \\\n        SKM_ASN1_SET_OF_d2i(X509, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class))\n# define i2d_ASN1_SET_OF_X509(st, pp, i2d_func, ex_tag, ex_class, is_set) \\\n        SKM_ASN1_SET_OF_i2d(X509, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set))\n# define ASN1_seq_pack_X509(st, i2d_func, buf, len) \\\n        SKM_ASN1_seq_pack(X509, (st), (i2d_func), (buf), (len))\n# define ASN1_seq_unpack_X509(buf, len, d2i_func, free_func) \\\n        SKM_ASN1_seq_unpack(X509, (buf), (len), (d2i_func), (free_func))\n# define d2i_ASN1_SET_OF_X509_ALGOR(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \\\n        SKM_ASN1_SET_OF_d2i(X509_ALGOR, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class))\n# define i2d_ASN1_SET_OF_X509_ALGOR(st, pp, i2d_func, ex_tag, ex_class, is_set) \\\n        SKM_ASN1_SET_OF_i2d(X509_ALGOR, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set))\n# define ASN1_seq_pack_X509_ALGOR(st, i2d_func, buf, len) \\\n        SKM_ASN1_seq_pack(X509_ALGOR, (st), (i2d_func), (buf), (len))\n# define ASN1_seq_unpack_X509_ALGOR(buf, len, d2i_func, free_func) \\\n        SKM_ASN1_seq_unpack(X509_ALGOR, (buf), (len), (d2i_func), (free_func))\n# define d2i_ASN1_SET_OF_X509_ATTRIBUTE(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \\\n        SKM_ASN1_SET_OF_d2i(X509_ATTRIBUTE, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class))\n# define i2d_ASN1_SET_OF_X509_ATTRIBUTE(st, pp, i2d_func, ex_tag, ex_class, is_set) \\\n        SKM_ASN1_SET_OF_i2d(X509_ATTRIBUTE, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set))\n# define ASN1_seq_pack_X509_ATTRIBUTE(st, i2d_func, buf, len) \\\n        SKM_ASN1_seq_pack(X509_ATTRIBUTE, (st), (i2d_func), (buf), (len))\n# define ASN1_seq_unpack_X509_ATTRIBUTE(buf, len, d2i_func, free_func) \\\n        SKM_ASN1_seq_unpack(X509_ATTRIBUTE, (buf), (len), (d2i_func), (free_func))\n# define d2i_ASN1_SET_OF_X509_CRL(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \\\n        SKM_ASN1_SET_OF_d2i(X509_CRL, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class))\n# define i2d_ASN1_SET_OF_X509_CRL(st, pp, i2d_func, ex_tag, ex_class, is_set) \\\n        SKM_ASN1_SET_OF_i2d(X509_CRL, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set))\n# define ASN1_seq_pack_X509_CRL(st, i2d_func, buf, len) \\\n        SKM_ASN1_seq_pack(X509_CRL, (st), (i2d_func), (buf), (len))\n# define ASN1_seq_unpack_X509_CRL(buf, len, d2i_func, free_func) \\\n        SKM_ASN1_seq_unpack(X509_CRL, (buf), (len), (d2i_func), (free_func))\n# define d2i_ASN1_SET_OF_X509_EXTENSION(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \\\n        SKM_ASN1_SET_OF_d2i(X509_EXTENSION, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class))\n# define i2d_ASN1_SET_OF_X509_EXTENSION(st, pp, i2d_func, ex_tag, ex_class, is_set) \\\n        SKM_ASN1_SET_OF_i2d(X509_EXTENSION, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set))\n# define ASN1_seq_pack_X509_EXTENSION(st, i2d_func, buf, len) \\\n        SKM_ASN1_seq_pack(X509_EXTENSION, (st), (i2d_func), (buf), (len))\n# define ASN1_seq_unpack_X509_EXTENSION(buf, len, d2i_func, free_func) \\\n        SKM_ASN1_seq_unpack(X509_EXTENSION, (buf), (len), (d2i_func), (free_func))\n# define d2i_ASN1_SET_OF_X509_NAME_ENTRY(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \\\n        SKM_ASN1_SET_OF_d2i(X509_NAME_ENTRY, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class))\n# define i2d_ASN1_SET_OF_X509_NAME_ENTRY(st, pp, i2d_func, ex_tag, ex_class, is_set) \\\n        SKM_ASN1_SET_OF_i2d(X509_NAME_ENTRY, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set))\n# define ASN1_seq_pack_X509_NAME_ENTRY(st, i2d_func, buf, len) \\\n        SKM_ASN1_seq_pack(X509_NAME_ENTRY, (st), (i2d_func), (buf), (len))\n# define ASN1_seq_unpack_X509_NAME_ENTRY(buf, len, d2i_func, free_func) \\\n        SKM_ASN1_seq_unpack(X509_NAME_ENTRY, (buf), (len), (d2i_func), (free_func))\n# define d2i_ASN1_SET_OF_X509_REVOKED(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \\\n        SKM_ASN1_SET_OF_d2i(X509_REVOKED, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class))\n# define i2d_ASN1_SET_OF_X509_REVOKED(st, pp, i2d_func, ex_tag, ex_class, is_set) \\\n        SKM_ASN1_SET_OF_i2d(X509_REVOKED, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set))\n# define ASN1_seq_pack_X509_REVOKED(st, i2d_func, buf, len) \\\n        SKM_ASN1_seq_pack(X509_REVOKED, (st), (i2d_func), (buf), (len))\n# define ASN1_seq_unpack_X509_REVOKED(buf, len, d2i_func, free_func) \\\n        SKM_ASN1_seq_unpack(X509_REVOKED, (buf), (len), (d2i_func), (free_func))\n# define PKCS12_decrypt_d2i_PKCS12_SAFEBAG(algor, d2i_func, free_func, pass, passlen, oct, seq) \\\n        SKM_PKCS12_decrypt_d2i(PKCS12_SAFEBAG, (algor), (d2i_func), (free_func), (pass), (passlen), (oct), (seq))\n# define PKCS12_decrypt_d2i_PKCS7(algor, d2i_func, free_func, pass, passlen, oct, seq) \\\n        SKM_PKCS12_decrypt_d2i(PKCS7, (algor), (d2i_func), (free_func), (pass), (passlen), (oct), (seq))\n# define lh_ADDED_OBJ_new() LHM_lh_new(ADDED_OBJ,added_obj)\n# define lh_ADDED_OBJ_insert(lh,inst) LHM_lh_insert(ADDED_OBJ,lh,inst)\n# define lh_ADDED_OBJ_retrieve(lh,inst) LHM_lh_retrieve(ADDED_OBJ,lh,inst)\n# define lh_ADDED_OBJ_delete(lh,inst) LHM_lh_delete(ADDED_OBJ,lh,inst)\n# define lh_ADDED_OBJ_doall(lh,fn) LHM_lh_doall(ADDED_OBJ,lh,fn)\n# define lh_ADDED_OBJ_doall_arg(lh,fn,arg_type,arg) \\\n  LHM_lh_doall_arg(ADDED_OBJ,lh,fn,arg_type,arg)\n# define lh_ADDED_OBJ_error(lh) LHM_lh_error(ADDED_OBJ,lh)\n# define lh_ADDED_OBJ_num_items(lh) LHM_lh_num_items(ADDED_OBJ,lh)\n# define lh_ADDED_OBJ_down_load(lh) LHM_lh_down_load(ADDED_OBJ,lh)\n# define lh_ADDED_OBJ_node_stats_bio(lh,out) \\\n  LHM_lh_node_stats_bio(ADDED_OBJ,lh,out)\n# define lh_ADDED_OBJ_node_usage_stats_bio(lh,out) \\\n  LHM_lh_node_usage_stats_bio(ADDED_OBJ,lh,out)\n# define lh_ADDED_OBJ_stats_bio(lh,out) \\\n  LHM_lh_stats_bio(ADDED_OBJ,lh,out)\n# define lh_ADDED_OBJ_free(lh) LHM_lh_free(ADDED_OBJ,lh)\n# define lh_APP_INFO_new() LHM_lh_new(APP_INFO,app_info)\n# define lh_APP_INFO_insert(lh,inst) LHM_lh_insert(APP_INFO,lh,inst)\n# define lh_APP_INFO_retrieve(lh,inst) LHM_lh_retrieve(APP_INFO,lh,inst)\n# define lh_APP_INFO_delete(lh,inst) LHM_lh_delete(APP_INFO,lh,inst)\n# define lh_APP_INFO_doall(lh,fn) LHM_lh_doall(APP_INFO,lh,fn)\n# define lh_APP_INFO_doall_arg(lh,fn,arg_type,arg) \\\n  LHM_lh_doall_arg(APP_INFO,lh,fn,arg_type,arg)\n# define lh_APP_INFO_error(lh) LHM_lh_error(APP_INFO,lh)\n# define lh_APP_INFO_num_items(lh) LHM_lh_num_items(APP_INFO,lh)\n# define lh_APP_INFO_down_load(lh) LHM_lh_down_load(APP_INFO,lh)\n# define lh_APP_INFO_node_stats_bio(lh,out) \\\n  LHM_lh_node_stats_bio(APP_INFO,lh,out)\n# define lh_APP_INFO_node_usage_stats_bio(lh,out) \\\n  LHM_lh_node_usage_stats_bio(APP_INFO,lh,out)\n# define lh_APP_INFO_stats_bio(lh,out) \\\n  LHM_lh_stats_bio(APP_INFO,lh,out)\n# define lh_APP_INFO_free(lh) LHM_lh_free(APP_INFO,lh)\n# define lh_CONF_VALUE_new() LHM_lh_new(CONF_VALUE,conf_value)\n# define lh_CONF_VALUE_insert(lh,inst) LHM_lh_insert(CONF_VALUE,lh,inst)\n# define lh_CONF_VALUE_retrieve(lh,inst) LHM_lh_retrieve(CONF_VALUE,lh,inst)\n# define lh_CONF_VALUE_delete(lh,inst) LHM_lh_delete(CONF_VALUE,lh,inst)\n# define lh_CONF_VALUE_doall(lh,fn) LHM_lh_doall(CONF_VALUE,lh,fn)\n# define lh_CONF_VALUE_doall_arg(lh,fn,arg_type,arg) \\\n  LHM_lh_doall_arg(CONF_VALUE,lh,fn,arg_type,arg)\n# define lh_CONF_VALUE_error(lh) LHM_lh_error(CONF_VALUE,lh)\n# define lh_CONF_VALUE_num_items(lh) LHM_lh_num_items(CONF_VALUE,lh)\n# define lh_CONF_VALUE_down_load(lh) LHM_lh_down_load(CONF_VALUE,lh)\n# define lh_CONF_VALUE_node_stats_bio(lh,out) \\\n  LHM_lh_node_stats_bio(CONF_VALUE,lh,out)\n# define lh_CONF_VALUE_node_usage_stats_bio(lh,out) \\\n  LHM_lh_node_usage_stats_bio(CONF_VALUE,lh,out)\n# define lh_CONF_VALUE_stats_bio(lh,out) \\\n  LHM_lh_stats_bio(CONF_VALUE,lh,out)\n# define lh_CONF_VALUE_free(lh) LHM_lh_free(CONF_VALUE,lh)\n# define lh_ENGINE_PILE_new() LHM_lh_new(ENGINE_PILE,engine_pile)\n# define lh_ENGINE_PILE_insert(lh,inst) LHM_lh_insert(ENGINE_PILE,lh,inst)\n# define lh_ENGINE_PILE_retrieve(lh,inst) LHM_lh_retrieve(ENGINE_PILE,lh,inst)\n# define lh_ENGINE_PILE_delete(lh,inst) LHM_lh_delete(ENGINE_PILE,lh,inst)\n# define lh_ENGINE_PILE_doall(lh,fn) LHM_lh_doall(ENGINE_PILE,lh,fn)\n# define lh_ENGINE_PILE_doall_arg(lh,fn,arg_type,arg) \\\n  LHM_lh_doall_arg(ENGINE_PILE,lh,fn,arg_type,arg)\n# define lh_ENGINE_PILE_error(lh) LHM_lh_error(ENGINE_PILE,lh)\n# define lh_ENGINE_PILE_num_items(lh) LHM_lh_num_items(ENGINE_PILE,lh)\n# define lh_ENGINE_PILE_down_load(lh) LHM_lh_down_load(ENGINE_PILE,lh)\n# define lh_ENGINE_PILE_node_stats_bio(lh,out) \\\n  LHM_lh_node_stats_bio(ENGINE_PILE,lh,out)\n# define lh_ENGINE_PILE_node_usage_stats_bio(lh,out) \\\n  LHM_lh_node_usage_stats_bio(ENGINE_PILE,lh,out)\n# define lh_ENGINE_PILE_stats_bio(lh,out) \\\n  LHM_lh_stats_bio(ENGINE_PILE,lh,out)\n# define lh_ENGINE_PILE_free(lh) LHM_lh_free(ENGINE_PILE,lh)\n# define lh_ERR_STATE_new() LHM_lh_new(ERR_STATE,err_state)\n# define lh_ERR_STATE_insert(lh,inst) LHM_lh_insert(ERR_STATE,lh,inst)\n# define lh_ERR_STATE_retrieve(lh,inst) LHM_lh_retrieve(ERR_STATE,lh,inst)\n# define lh_ERR_STATE_delete(lh,inst) LHM_lh_delete(ERR_STATE,lh,inst)\n# define lh_ERR_STATE_doall(lh,fn) LHM_lh_doall(ERR_STATE,lh,fn)\n# define lh_ERR_STATE_doall_arg(lh,fn,arg_type,arg) \\\n  LHM_lh_doall_arg(ERR_STATE,lh,fn,arg_type,arg)\n# define lh_ERR_STATE_error(lh) LHM_lh_error(ERR_STATE,lh)\n# define lh_ERR_STATE_num_items(lh) LHM_lh_num_items(ERR_STATE,lh)\n# define lh_ERR_STATE_down_load(lh) LHM_lh_down_load(ERR_STATE,lh)\n# define lh_ERR_STATE_node_stats_bio(lh,out) \\\n  LHM_lh_node_stats_bio(ERR_STATE,lh,out)\n# define lh_ERR_STATE_node_usage_stats_bio(lh,out) \\\n  LHM_lh_node_usage_stats_bio(ERR_STATE,lh,out)\n# define lh_ERR_STATE_stats_bio(lh,out) \\\n  LHM_lh_stats_bio(ERR_STATE,lh,out)\n# define lh_ERR_STATE_free(lh) LHM_lh_free(ERR_STATE,lh)\n# define lh_ERR_STRING_DATA_new() LHM_lh_new(ERR_STRING_DATA,err_string_data)\n# define lh_ERR_STRING_DATA_insert(lh,inst) LHM_lh_insert(ERR_STRING_DATA,lh,inst)\n# define lh_ERR_STRING_DATA_retrieve(lh,inst) LHM_lh_retrieve(ERR_STRING_DATA,lh,inst)\n# define lh_ERR_STRING_DATA_delete(lh,inst) LHM_lh_delete(ERR_STRING_DATA,lh,inst)\n# define lh_ERR_STRING_DATA_doall(lh,fn) LHM_lh_doall(ERR_STRING_DATA,lh,fn)\n# define lh_ERR_STRING_DATA_doall_arg(lh,fn,arg_type,arg) \\\n  LHM_lh_doall_arg(ERR_STRING_DATA,lh,fn,arg_type,arg)\n# define lh_ERR_STRING_DATA_error(lh) LHM_lh_error(ERR_STRING_DATA,lh)\n# define lh_ERR_STRING_DATA_num_items(lh) LHM_lh_num_items(ERR_STRING_DATA,lh)\n# define lh_ERR_STRING_DATA_down_load(lh) LHM_lh_down_load(ERR_STRING_DATA,lh)\n# define lh_ERR_STRING_DATA_node_stats_bio(lh,out) \\\n  LHM_lh_node_stats_bio(ERR_STRING_DATA,lh,out)\n# define lh_ERR_STRING_DATA_node_usage_stats_bio(lh,out) \\\n  LHM_lh_node_usage_stats_bio(ERR_STRING_DATA,lh,out)\n# define lh_ERR_STRING_DATA_stats_bio(lh,out) \\\n  LHM_lh_stats_bio(ERR_STRING_DATA,lh,out)\n# define lh_ERR_STRING_DATA_free(lh) LHM_lh_free(ERR_STRING_DATA,lh)\n# define lh_EX_CLASS_ITEM_new() LHM_lh_new(EX_CLASS_ITEM,ex_class_item)\n# define lh_EX_CLASS_ITEM_insert(lh,inst) LHM_lh_insert(EX_CLASS_ITEM,lh,inst)\n# define lh_EX_CLASS_ITEM_retrieve(lh,inst) LHM_lh_retrieve(EX_CLASS_ITEM,lh,inst)\n# define lh_EX_CLASS_ITEM_delete(lh,inst) LHM_lh_delete(EX_CLASS_ITEM,lh,inst)\n# define lh_EX_CLASS_ITEM_doall(lh,fn) LHM_lh_doall(EX_CLASS_ITEM,lh,fn)\n# define lh_EX_CLASS_ITEM_doall_arg(lh,fn,arg_type,arg) \\\n  LHM_lh_doall_arg(EX_CLASS_ITEM,lh,fn,arg_type,arg)\n# define lh_EX_CLASS_ITEM_error(lh) LHM_lh_error(EX_CLASS_ITEM,lh)\n# define lh_EX_CLASS_ITEM_num_items(lh) LHM_lh_num_items(EX_CLASS_ITEM,lh)\n# define lh_EX_CLASS_ITEM_down_load(lh) LHM_lh_down_load(EX_CLASS_ITEM,lh)\n# define lh_EX_CLASS_ITEM_node_stats_bio(lh,out) \\\n  LHM_lh_node_stats_bio(EX_CLASS_ITEM,lh,out)\n# define lh_EX_CLASS_ITEM_node_usage_stats_bio(lh,out) \\\n  LHM_lh_node_usage_stats_bio(EX_CLASS_ITEM,lh,out)\n# define lh_EX_CLASS_ITEM_stats_bio(lh,out) \\\n  LHM_lh_stats_bio(EX_CLASS_ITEM,lh,out)\n# define lh_EX_CLASS_ITEM_free(lh) LHM_lh_free(EX_CLASS_ITEM,lh)\n# define lh_FUNCTION_new() LHM_lh_new(FUNCTION,function)\n# define lh_FUNCTION_insert(lh,inst) LHM_lh_insert(FUNCTION,lh,inst)\n# define lh_FUNCTION_retrieve(lh,inst) LHM_lh_retrieve(FUNCTION,lh,inst)\n# define lh_FUNCTION_delete(lh,inst) LHM_lh_delete(FUNCTION,lh,inst)\n# define lh_FUNCTION_doall(lh,fn) LHM_lh_doall(FUNCTION,lh,fn)\n# define lh_FUNCTION_doall_arg(lh,fn,arg_type,arg) \\\n  LHM_lh_doall_arg(FUNCTION,lh,fn,arg_type,arg)\n# define lh_FUNCTION_error(lh) LHM_lh_error(FUNCTION,lh)\n# define lh_FUNCTION_num_items(lh) LHM_lh_num_items(FUNCTION,lh)\n# define lh_FUNCTION_down_load(lh) LHM_lh_down_load(FUNCTION,lh)\n# define lh_FUNCTION_node_stats_bio(lh,out) \\\n  LHM_lh_node_stats_bio(FUNCTION,lh,out)\n# define lh_FUNCTION_node_usage_stats_bio(lh,out) \\\n  LHM_lh_node_usage_stats_bio(FUNCTION,lh,out)\n# define lh_FUNCTION_stats_bio(lh,out) \\\n  LHM_lh_stats_bio(FUNCTION,lh,out)\n# define lh_FUNCTION_free(lh) LHM_lh_free(FUNCTION,lh)\n# define lh_MEM_new() LHM_lh_new(MEM,mem)\n# define lh_MEM_insert(lh,inst) LHM_lh_insert(MEM,lh,inst)\n# define lh_MEM_retrieve(lh,inst) LHM_lh_retrieve(MEM,lh,inst)\n# define lh_MEM_delete(lh,inst) LHM_lh_delete(MEM,lh,inst)\n# define lh_MEM_doall(lh,fn) LHM_lh_doall(MEM,lh,fn)\n# define lh_MEM_doall_arg(lh,fn,arg_type,arg) \\\n  LHM_lh_doall_arg(MEM,lh,fn,arg_type,arg)\n# define lh_MEM_error(lh) LHM_lh_error(MEM,lh)\n# define lh_MEM_num_items(lh) LHM_lh_num_items(MEM,lh)\n# define lh_MEM_down_load(lh) LHM_lh_down_load(MEM,lh)\n# define lh_MEM_node_stats_bio(lh,out) \\\n  LHM_lh_node_stats_bio(MEM,lh,out)\n# define lh_MEM_node_usage_stats_bio(lh,out) \\\n  LHM_lh_node_usage_stats_bio(MEM,lh,out)\n# define lh_MEM_stats_bio(lh,out) \\\n  LHM_lh_stats_bio(MEM,lh,out)\n# define lh_MEM_free(lh) LHM_lh_free(MEM,lh)\n# define lh_OBJ_NAME_new() LHM_lh_new(OBJ_NAME,obj_name)\n# define lh_OBJ_NAME_insert(lh,inst) LHM_lh_insert(OBJ_NAME,lh,inst)\n# define lh_OBJ_NAME_retrieve(lh,inst) LHM_lh_retrieve(OBJ_NAME,lh,inst)\n# define lh_OBJ_NAME_delete(lh,inst) LHM_lh_delete(OBJ_NAME,lh,inst)\n# define lh_OBJ_NAME_doall(lh,fn) LHM_lh_doall(OBJ_NAME,lh,fn)\n# define lh_OBJ_NAME_doall_arg(lh,fn,arg_type,arg) \\\n  LHM_lh_doall_arg(OBJ_NAME,lh,fn,arg_type,arg)\n# define lh_OBJ_NAME_error(lh) LHM_lh_error(OBJ_NAME,lh)\n# define lh_OBJ_NAME_num_items(lh) LHM_lh_num_items(OBJ_NAME,lh)\n# define lh_OBJ_NAME_down_load(lh) LHM_lh_down_load(OBJ_NAME,lh)\n# define lh_OBJ_NAME_node_stats_bio(lh,out) \\\n  LHM_lh_node_stats_bio(OBJ_NAME,lh,out)\n# define lh_OBJ_NAME_node_usage_stats_bio(lh,out) \\\n  LHM_lh_node_usage_stats_bio(OBJ_NAME,lh,out)\n# define lh_OBJ_NAME_stats_bio(lh,out) \\\n  LHM_lh_stats_bio(OBJ_NAME,lh,out)\n# define lh_OBJ_NAME_free(lh) LHM_lh_free(OBJ_NAME,lh)\n# define lh_OPENSSL_CSTRING_new() LHM_lh_new(OPENSSL_CSTRING,openssl_cstring)\n# define lh_OPENSSL_CSTRING_insert(lh,inst) LHM_lh_insert(OPENSSL_CSTRING,lh,inst)\n# define lh_OPENSSL_CSTRING_retrieve(lh,inst) LHM_lh_retrieve(OPENSSL_CSTRING,lh,inst)\n# define lh_OPENSSL_CSTRING_delete(lh,inst) LHM_lh_delete(OPENSSL_CSTRING,lh,inst)\n# define lh_OPENSSL_CSTRING_doall(lh,fn) LHM_lh_doall(OPENSSL_CSTRING,lh,fn)\n# define lh_OPENSSL_CSTRING_doall_arg(lh,fn,arg_type,arg) \\\n  LHM_lh_doall_arg(OPENSSL_CSTRING,lh,fn,arg_type,arg)\n# define lh_OPENSSL_CSTRING_error(lh) LHM_lh_error(OPENSSL_CSTRING,lh)\n# define lh_OPENSSL_CSTRING_num_items(lh) LHM_lh_num_items(OPENSSL_CSTRING,lh)\n# define lh_OPENSSL_CSTRING_down_load(lh) LHM_lh_down_load(OPENSSL_CSTRING,lh)\n# define lh_OPENSSL_CSTRING_node_stats_bio(lh,out) \\\n  LHM_lh_node_stats_bio(OPENSSL_CSTRING,lh,out)\n# define lh_OPENSSL_CSTRING_node_usage_stats_bio(lh,out) \\\n  LHM_lh_node_usage_stats_bio(OPENSSL_CSTRING,lh,out)\n# define lh_OPENSSL_CSTRING_stats_bio(lh,out) \\\n  LHM_lh_stats_bio(OPENSSL_CSTRING,lh,out)\n# define lh_OPENSSL_CSTRING_free(lh) LHM_lh_free(OPENSSL_CSTRING,lh)\n# define lh_OPENSSL_STRING_new() LHM_lh_new(OPENSSL_STRING,openssl_string)\n# define lh_OPENSSL_STRING_insert(lh,inst) LHM_lh_insert(OPENSSL_STRING,lh,inst)\n# define lh_OPENSSL_STRING_retrieve(lh,inst) LHM_lh_retrieve(OPENSSL_STRING,lh,inst)\n# define lh_OPENSSL_STRING_delete(lh,inst) LHM_lh_delete(OPENSSL_STRING,lh,inst)\n# define lh_OPENSSL_STRING_doall(lh,fn) LHM_lh_doall(OPENSSL_STRING,lh,fn)\n# define lh_OPENSSL_STRING_doall_arg(lh,fn,arg_type,arg) \\\n  LHM_lh_doall_arg(OPENSSL_STRING,lh,fn,arg_type,arg)\n# define lh_OPENSSL_STRING_error(lh) LHM_lh_error(OPENSSL_STRING,lh)\n# define lh_OPENSSL_STRING_num_items(lh) LHM_lh_num_items(OPENSSL_STRING,lh)\n# define lh_OPENSSL_STRING_down_load(lh) LHM_lh_down_load(OPENSSL_STRING,lh)\n# define lh_OPENSSL_STRING_node_stats_bio(lh,out) \\\n  LHM_lh_node_stats_bio(OPENSSL_STRING,lh,out)\n# define lh_OPENSSL_STRING_node_usage_stats_bio(lh,out) \\\n  LHM_lh_node_usage_stats_bio(OPENSSL_STRING,lh,out)\n# define lh_OPENSSL_STRING_stats_bio(lh,out) \\\n  LHM_lh_stats_bio(OPENSSL_STRING,lh,out)\n# define lh_OPENSSL_STRING_free(lh) LHM_lh_free(OPENSSL_STRING,lh)\n# define lh_SSL_SESSION_new() LHM_lh_new(SSL_SESSION,ssl_session)\n# define lh_SSL_SESSION_insert(lh,inst) LHM_lh_insert(SSL_SESSION,lh,inst)\n# define lh_SSL_SESSION_retrieve(lh,inst) LHM_lh_retrieve(SSL_SESSION,lh,inst)\n# define lh_SSL_SESSION_delete(lh,inst) LHM_lh_delete(SSL_SESSION,lh,inst)\n# define lh_SSL_SESSION_doall(lh,fn) LHM_lh_doall(SSL_SESSION,lh,fn)\n# define lh_SSL_SESSION_doall_arg(lh,fn,arg_type,arg) \\\n  LHM_lh_doall_arg(SSL_SESSION,lh,fn,arg_type,arg)\n# define lh_SSL_SESSION_error(lh) LHM_lh_error(SSL_SESSION,lh)\n# define lh_SSL_SESSION_num_items(lh) LHM_lh_num_items(SSL_SESSION,lh)\n# define lh_SSL_SESSION_down_load(lh) LHM_lh_down_load(SSL_SESSION,lh)\n# define lh_SSL_SESSION_node_stats_bio(lh,out) \\\n  LHM_lh_node_stats_bio(SSL_SESSION,lh,out)\n# define lh_SSL_SESSION_node_usage_stats_bio(lh,out) \\\n  LHM_lh_node_usage_stats_bio(SSL_SESSION,lh,out)\n# define lh_SSL_SESSION_stats_bio(lh,out) \\\n  LHM_lh_stats_bio(SSL_SESSION,lh,out)\n# define lh_SSL_SESSION_free(lh) LHM_lh_free(SSL_SESSION,lh)\n#ifdef  __cplusplus\n}\n#endif\n#endif                          /* !defined HEADER_SAFESTACK_H */\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/arm64/include/openssl/seed.h",
    "content": "/*\n * Copyright (c) 2007 KISA(Korea Information Security Agency). All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n * 2. Neither the name of author nor the names of its contributors may\n *    be used to endorse or promote products derived from this software\n *    without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED.  IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n * SUCH DAMAGE.\n *\n */\n/* ====================================================================\n * Copyright (c) 1998-2007 The OpenSSL Project.  All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n *\n * 1. Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n *\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in\n *    the documentation and/or other materials provided with the\n *    distribution.\n *\n * 3. All advertising materials mentioning features or use of this\n *    software must display the following acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit. (http://www.openssl.org/)\"\n *\n * 4. The names \"OpenSSL Toolkit\" and \"OpenSSL Project\" must not be used to\n *    endorse or promote products derived from this software without\n *    prior written permission. For written permission, please contact\n *    openssl-core@openssl.org.\n *\n * 5. Products derived from this software may not be called \"OpenSSL\"\n *    nor may \"OpenSSL\" appear in their names without prior written\n *    permission of the OpenSSL Project.\n *\n * 6. Redistributions of any form whatsoever must retain the following\n *    acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit (http://www.openssl.org/)\"\n *\n * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY\n * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\n * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR\n * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\n * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,\n * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED\n * OF THE POSSIBILITY OF SUCH DAMAGE.\n * ====================================================================\n *\n * This product includes cryptographic software written by Eric Young\n * (eay@cryptsoft.com).  This product includes software written by Tim\n * Hudson (tjh@cryptsoft.com).\n *\n */\n\n#ifndef HEADER_SEED_H\n# define HEADER_SEED_H\n\n# include <openssl/opensslconf.h>\n# include <openssl/e_os2.h>\n# include <openssl/crypto.h>\n\n# ifdef OPENSSL_NO_SEED\n#  error SEED is disabled.\n# endif\n\n/* look whether we need 'long' to get 32 bits */\n# ifdef AES_LONG\n#  ifndef SEED_LONG\n#   define SEED_LONG 1\n#  endif\n# endif\n\n# if !defined(NO_SYS_TYPES_H)\n#  include <sys/types.h>\n# endif\n\n# define SEED_BLOCK_SIZE 16\n# define SEED_KEY_LENGTH 16\n\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\ntypedef struct seed_key_st {\n# ifdef SEED_LONG\n    unsigned long data[32];\n# else\n    unsigned int data[32];\n# endif\n} SEED_KEY_SCHEDULE;\n\n# ifdef OPENSSL_FIPS\nvoid private_SEED_set_key(const unsigned char rawkey[SEED_KEY_LENGTH],\n                          SEED_KEY_SCHEDULE *ks);\n# endif\nvoid SEED_set_key(const unsigned char rawkey[SEED_KEY_LENGTH],\n                  SEED_KEY_SCHEDULE *ks);\n\nvoid SEED_encrypt(const unsigned char s[SEED_BLOCK_SIZE],\n                  unsigned char d[SEED_BLOCK_SIZE],\n                  const SEED_KEY_SCHEDULE *ks);\nvoid SEED_decrypt(const unsigned char s[SEED_BLOCK_SIZE],\n                  unsigned char d[SEED_BLOCK_SIZE],\n                  const SEED_KEY_SCHEDULE *ks);\n\nvoid SEED_ecb_encrypt(const unsigned char *in, unsigned char *out,\n                      const SEED_KEY_SCHEDULE *ks, int enc);\nvoid SEED_cbc_encrypt(const unsigned char *in, unsigned char *out, size_t len,\n                      const SEED_KEY_SCHEDULE *ks,\n                      unsigned char ivec[SEED_BLOCK_SIZE], int enc);\nvoid SEED_cfb128_encrypt(const unsigned char *in, unsigned char *out,\n                         size_t len, const SEED_KEY_SCHEDULE *ks,\n                         unsigned char ivec[SEED_BLOCK_SIZE], int *num,\n                         int enc);\nvoid SEED_ofb128_encrypt(const unsigned char *in, unsigned char *out,\n                         size_t len, const SEED_KEY_SCHEDULE *ks,\n                         unsigned char ivec[SEED_BLOCK_SIZE], int *num);\n\n#ifdef  __cplusplus\n}\n#endif\n\n#endif                          /* HEADER_SEED_H */\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/arm64/include/openssl/sha.h",
    "content": "/* crypto/sha/sha.h */\n/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)\n * All rights reserved.\n *\n * This package is an SSL implementation written\n * by Eric Young (eay@cryptsoft.com).\n * The implementation was written so as to conform with Netscapes SSL.\n *\n * This library is free for commercial and non-commercial use as long as\n * the following conditions are aheared to.  The following conditions\n * apply to all code found in this distribution, be it the RC4, RSA,\n * lhash, DES, etc., code; not just the SSL code.  The SSL documentation\n * included with this distribution is covered by the same copyright terms\n * except that the holder is Tim Hudson (tjh@cryptsoft.com).\n *\n * Copyright remains Eric Young's, and as such any Copyright notices in\n * the code are not to be removed.\n * If this package is used in a product, Eric Young should be given attribution\n * as the author of the parts of the library used.\n * This can be in the form of a textual message at program startup or\n * in documentation (online or textual) provided with the package.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the copyright\n *    notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in the\n *    documentation and/or other materials provided with the distribution.\n * 3. All advertising materials mentioning features or use of this software\n *    must display the following acknowledgement:\n *    \"This product includes cryptographic software written by\n *     Eric Young (eay@cryptsoft.com)\"\n *    The word 'cryptographic' can be left out if the rouines from the library\n *    being used are not cryptographic related :-).\n * 4. If you include any Windows specific code (or a derivative thereof) from\n *    the apps directory (application code) you must include an acknowledgement:\n *    \"This product includes software written by Tim Hudson (tjh@cryptsoft.com)\"\n *\n * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n * SUCH DAMAGE.\n *\n * The licence and distribution terms for any publically available version or\n * derivative of this code cannot be changed.  i.e. this code cannot simply be\n * copied and put under another distribution licence\n * [including the GNU Public Licence.]\n */\n\n#ifndef HEADER_SHA_H\n# define HEADER_SHA_H\n\n# include <openssl/e_os2.h>\n# include <stddef.h>\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n# if defined(OPENSSL_NO_SHA) || (defined(OPENSSL_NO_SHA0) && defined(OPENSSL_NO_SHA1))\n#  error SHA is disabled.\n# endif\n\n# if defined(OPENSSL_FIPS)\n#  define FIPS_SHA_SIZE_T size_t\n# endif\n\n/*-\n * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n * ! SHA_LONG has to be at least 32 bits wide. If it's wider, then !\n * ! SHA_LONG_LOG2 has to be defined along.                        !\n * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n */\n\n# if defined(__LP32__)\n#  define SHA_LONG unsigned long\n# elif defined(OPENSSL_SYS_CRAY) || defined(__ILP64__)\n#  define SHA_LONG unsigned long\n#  define SHA_LONG_LOG2 3\n# else\n#  define SHA_LONG unsigned int\n# endif\n\n# define SHA_LBLOCK      16\n# define SHA_CBLOCK      (SHA_LBLOCK*4)/* SHA treats input data as a\n                                        * contiguous array of 32 bit wide\n                                        * big-endian values. */\n# define SHA_LAST_BLOCK  (SHA_CBLOCK-8)\n# define SHA_DIGEST_LENGTH 20\n\ntypedef struct SHAstate_st {\n    SHA_LONG h0, h1, h2, h3, h4;\n    SHA_LONG Nl, Nh;\n    SHA_LONG data[SHA_LBLOCK];\n    unsigned int num;\n} SHA_CTX;\n\n# ifndef OPENSSL_NO_SHA0\n#  ifdef OPENSSL_FIPS\nint private_SHA_Init(SHA_CTX *c);\n#  endif\nint SHA_Init(SHA_CTX *c);\nint SHA_Update(SHA_CTX *c, const void *data, size_t len);\nint SHA_Final(unsigned char *md, SHA_CTX *c);\nunsigned char *SHA(const unsigned char *d, size_t n, unsigned char *md);\nvoid SHA_Transform(SHA_CTX *c, const unsigned char *data);\n# endif\n# ifndef OPENSSL_NO_SHA1\n#  ifdef OPENSSL_FIPS\nint private_SHA1_Init(SHA_CTX *c);\n#  endif\nint SHA1_Init(SHA_CTX *c);\nint SHA1_Update(SHA_CTX *c, const void *data, size_t len);\nint SHA1_Final(unsigned char *md, SHA_CTX *c);\nunsigned char *SHA1(const unsigned char *d, size_t n, unsigned char *md);\nvoid SHA1_Transform(SHA_CTX *c, const unsigned char *data);\n# endif\n\n# define SHA256_CBLOCK   (SHA_LBLOCK*4)/* SHA-256 treats input data as a\n                                        * contiguous array of 32 bit wide\n                                        * big-endian values. */\n# define SHA224_DIGEST_LENGTH    28\n# define SHA256_DIGEST_LENGTH    32\n\ntypedef struct SHA256state_st {\n    SHA_LONG h[8];\n    SHA_LONG Nl, Nh;\n    SHA_LONG data[SHA_LBLOCK];\n    unsigned int num, md_len;\n} SHA256_CTX;\n\n# ifndef OPENSSL_NO_SHA256\n#  ifdef OPENSSL_FIPS\nint private_SHA224_Init(SHA256_CTX *c);\nint private_SHA256_Init(SHA256_CTX *c);\n#  endif\nint SHA224_Init(SHA256_CTX *c);\nint SHA224_Update(SHA256_CTX *c, const void *data, size_t len);\nint SHA224_Final(unsigned char *md, SHA256_CTX *c);\nunsigned char *SHA224(const unsigned char *d, size_t n, unsigned char *md);\nint SHA256_Init(SHA256_CTX *c);\nint SHA256_Update(SHA256_CTX *c, const void *data, size_t len);\nint SHA256_Final(unsigned char *md, SHA256_CTX *c);\nunsigned char *SHA256(const unsigned char *d, size_t n, unsigned char *md);\nvoid SHA256_Transform(SHA256_CTX *c, const unsigned char *data);\n# endif\n\n# define SHA384_DIGEST_LENGTH    48\n# define SHA512_DIGEST_LENGTH    64\n\n# ifndef OPENSSL_NO_SHA512\n/*\n * Unlike 32-bit digest algorithms, SHA-512 *relies* on SHA_LONG64\n * being exactly 64-bit wide. See Implementation Notes in sha512.c\n * for further details.\n */\n/*\n * SHA-512 treats input data as a\n * contiguous array of 64 bit\n * wide big-endian values.\n */\n#  define SHA512_CBLOCK   (SHA_LBLOCK*8)\n#  if (defined(_WIN32) || defined(_WIN64)) && !defined(__MINGW32__)\n#   define SHA_LONG64 unsigned __int64\n#   define U64(C)     C##UI64\n#  elif defined(__arch64__)\n#   define SHA_LONG64 unsigned long\n#   define U64(C)     C##UL\n#  else\n#   define SHA_LONG64 unsigned long long\n#   define U64(C)     C##ULL\n#  endif\n\ntypedef struct SHA512state_st {\n    SHA_LONG64 h[8];\n    SHA_LONG64 Nl, Nh;\n    union {\n        SHA_LONG64 d[SHA_LBLOCK];\n        unsigned char p[SHA512_CBLOCK];\n    } u;\n    unsigned int num, md_len;\n} SHA512_CTX;\n# endif\n\n# ifndef OPENSSL_NO_SHA512\n#  ifdef OPENSSL_FIPS\nint private_SHA384_Init(SHA512_CTX *c);\nint private_SHA512_Init(SHA512_CTX *c);\n#  endif\nint SHA384_Init(SHA512_CTX *c);\nint SHA384_Update(SHA512_CTX *c, const void *data, size_t len);\nint SHA384_Final(unsigned char *md, SHA512_CTX *c);\nunsigned char *SHA384(const unsigned char *d, size_t n, unsigned char *md);\nint SHA512_Init(SHA512_CTX *c);\nint SHA512_Update(SHA512_CTX *c, const void *data, size_t len);\nint SHA512_Final(unsigned char *md, SHA512_CTX *c);\nunsigned char *SHA512(const unsigned char *d, size_t n, unsigned char *md);\nvoid SHA512_Transform(SHA512_CTX *c, const unsigned char *data);\n# endif\n\n#ifdef  __cplusplus\n}\n#endif\n\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/arm64/include/openssl/srp.h",
    "content": "/* crypto/srp/srp.h */\n/*\n * Written by Christophe Renou (christophe.renou@edelweb.fr) with the\n * precious help of Peter Sylvester (peter.sylvester@edelweb.fr) for the\n * EdelKey project and contributed to the OpenSSL project 2004.\n */\n/* ====================================================================\n * Copyright (c) 2004 The OpenSSL Project.  All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n *\n * 1. Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n *\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in\n *    the documentation and/or other materials provided with the\n *    distribution.\n *\n * 3. All advertising materials mentioning features or use of this\n *    software must display the following acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)\"\n *\n * 4. The names \"OpenSSL Toolkit\" and \"OpenSSL Project\" must not be used to\n *    endorse or promote products derived from this software without\n *    prior written permission. For written permission, please contact\n *    licensing@OpenSSL.org.\n *\n * 5. Products derived from this software may not be called \"OpenSSL\"\n *    nor may \"OpenSSL\" appear in their names without prior written\n *    permission of the OpenSSL Project.\n *\n * 6. Redistributions of any form whatsoever must retain the following\n *    acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)\"\n *\n * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY\n * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\n * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR\n * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\n * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,\n * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED\n * OF THE POSSIBILITY OF SUCH DAMAGE.\n * ====================================================================\n *\n * This product includes cryptographic software written by Eric Young\n * (eay@cryptsoft.com).  This product includes software written by Tim\n * Hudson (tjh@cryptsoft.com).\n *\n */\n#ifndef __SRP_H__\n# define __SRP_H__\n\n# ifndef OPENSSL_NO_SRP\n\n#  include <stdio.h>\n#  include <string.h>\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n#  include <openssl/safestack.h>\n#  include <openssl/bn.h>\n#  include <openssl/crypto.h>\n\ntypedef struct SRP_gN_cache_st {\n    char *b64_bn;\n    BIGNUM *bn;\n} SRP_gN_cache;\n\n\nDECLARE_STACK_OF(SRP_gN_cache)\n\ntypedef struct SRP_user_pwd_st {\n    /* Owned by us. */\n    char *id;\n    BIGNUM *s;\n    BIGNUM *v;\n    /* Not owned by us. */\n    const BIGNUM *g;\n    const BIGNUM *N;\n    /* Owned by us. */\n    char *info;\n} SRP_user_pwd;\n\nDECLARE_STACK_OF(SRP_user_pwd)\n\nvoid SRP_user_pwd_free(SRP_user_pwd *user_pwd);\n\ntypedef struct SRP_VBASE_st {\n    STACK_OF(SRP_user_pwd) *users_pwd;\n    STACK_OF(SRP_gN_cache) *gN_cache;\n/* to simulate a user */\n    char *seed_key;\n    BIGNUM *default_g;\n    BIGNUM *default_N;\n} SRP_VBASE;\n\n/*\n * Structure interne pour retenir les couples N et g\n */\ntypedef struct SRP_gN_st {\n    char *id;\n    BIGNUM *g;\n    BIGNUM *N;\n} SRP_gN;\n\nDECLARE_STACK_OF(SRP_gN)\n\nSRP_VBASE *SRP_VBASE_new(char *seed_key);\nint SRP_VBASE_free(SRP_VBASE *vb);\nint SRP_VBASE_init(SRP_VBASE *vb, char *verifier_file);\n\n/* This method ignores the configured seed and fails for an unknown user. */\nSRP_user_pwd *SRP_VBASE_get_by_user(SRP_VBASE *vb, char *username);\n/* NOTE: unlike in SRP_VBASE_get_by_user, caller owns the returned pointer.*/\nSRP_user_pwd *SRP_VBASE_get1_by_user(SRP_VBASE *vb, char *username);\n\nchar *SRP_create_verifier(const char *user, const char *pass, char **salt,\n                          char **verifier, const char *N, const char *g);\nint SRP_create_verifier_BN(const char *user, const char *pass, BIGNUM **salt,\n                           BIGNUM **verifier, BIGNUM *N, BIGNUM *g);\n\n#  define SRP_NO_ERROR 0\n#  define SRP_ERR_VBASE_INCOMPLETE_FILE 1\n#  define SRP_ERR_VBASE_BN_LIB 2\n#  define SRP_ERR_OPEN_FILE 3\n#  define SRP_ERR_MEMORY 4\n\n#  define DB_srptype      0\n#  define DB_srpverifier  1\n#  define DB_srpsalt      2\n#  define DB_srpid        3\n#  define DB_srpgN        4\n#  define DB_srpinfo      5\n#  undef  DB_NUMBER\n#  define DB_NUMBER       6\n\n#  define DB_SRP_INDEX    'I'\n#  define DB_SRP_VALID    'V'\n#  define DB_SRP_REVOKED  'R'\n#  define DB_SRP_MODIF    'v'\n\n/* see srp.c */\nchar *SRP_check_known_gN_param(BIGNUM *g, BIGNUM *N);\nSRP_gN *SRP_get_default_gN(const char *id);\n\n/* server side .... */\nBIGNUM *SRP_Calc_server_key(BIGNUM *A, BIGNUM *v, BIGNUM *u, BIGNUM *b,\n                            BIGNUM *N);\nBIGNUM *SRP_Calc_B(BIGNUM *b, BIGNUM *N, BIGNUM *g, BIGNUM *v);\nint SRP_Verify_A_mod_N(BIGNUM *A, BIGNUM *N);\nBIGNUM *SRP_Calc_u(BIGNUM *A, BIGNUM *B, BIGNUM *N);\n\n/* client side .... */\nBIGNUM *SRP_Calc_x(BIGNUM *s, const char *user, const char *pass);\nBIGNUM *SRP_Calc_A(BIGNUM *a, BIGNUM *N, BIGNUM *g);\nBIGNUM *SRP_Calc_client_key(BIGNUM *N, BIGNUM *B, BIGNUM *g, BIGNUM *x,\n                            BIGNUM *a, BIGNUM *u);\nint SRP_Verify_B_mod_N(BIGNUM *B, BIGNUM *N);\n\n#  define SRP_MINIMAL_N 1024\n\n#ifdef  __cplusplus\n}\n#endif\n\n# endif\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/arm64/include/openssl/srtp.h",
    "content": "/* ssl/srtp.h */\n/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)\n * All rights reserved.\n *\n * This package is an SSL implementation written\n * by Eric Young (eay@cryptsoft.com).\n * The implementation was written so as to conform with Netscapes SSL.\n *\n * This library is free for commercial and non-commercial use as long as\n * the following conditions are aheared to.  The following conditions\n * apply to all code found in this distribution, be it the RC4, RSA,\n * lhash, DES, etc., code; not just the SSL code.  The SSL documentation\n * included with this distribution is covered by the same copyright terms\n * except that the holder is Tim Hudson (tjh@cryptsoft.com).\n *\n * Copyright remains Eric Young's, and as such any Copyright notices in\n * the code are not to be removed.\n * If this package is used in a product, Eric Young should be given attribution\n * as the author of the parts of the library used.\n * This can be in the form of a textual message at program startup or\n * in documentation (online or textual) provided with the package.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the copyright\n *    notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in the\n *    documentation and/or other materials provided with the distribution.\n * 3. All advertising materials mentioning features or use of this software\n *    must display the following acknowledgement:\n *    \"This product includes cryptographic software written by\n *     Eric Young (eay@cryptsoft.com)\"\n *    The word 'cryptographic' can be left out if the rouines from the library\n *    being used are not cryptographic related :-).\n * 4. If you include any Windows specific code (or a derivative thereof) from\n *    the apps directory (application code) you must include an acknowledgement:\n *    \"This product includes software written by Tim Hudson (tjh@cryptsoft.com)\"\n *\n * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n * SUCH DAMAGE.\n *\n * The licence and distribution terms for any publically available version or\n * derivative of this code cannot be changed.  i.e. this code cannot simply be\n * copied and put under another distribution licence\n * [including the GNU Public Licence.]\n */\n/* ====================================================================\n * Copyright (c) 1998-2006 The OpenSSL Project.  All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n *\n * 1. Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n *\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in\n *    the documentation and/or other materials provided with the\n *    distribution.\n *\n * 3. All advertising materials mentioning features or use of this\n *    software must display the following acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit. (http://www.openssl.org/)\"\n *\n * 4. The names \"OpenSSL Toolkit\" and \"OpenSSL Project\" must not be used to\n *    endorse or promote products derived from this software without\n *    prior written permission. For written permission, please contact\n *    openssl-core@openssl.org.\n *\n * 5. Products derived from this software may not be called \"OpenSSL\"\n *    nor may \"OpenSSL\" appear in their names without prior written\n *    permission of the OpenSSL Project.\n *\n * 6. Redistributions of any form whatsoever must retain the following\n *    acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit (http://www.openssl.org/)\"\n *\n * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY\n * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\n * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR\n * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\n * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,\n * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED\n * OF THE POSSIBILITY OF SUCH DAMAGE.\n * ====================================================================\n *\n * This product includes cryptographic software written by Eric Young\n * (eay@cryptsoft.com).  This product includes software written by Tim\n * Hudson (tjh@cryptsoft.com).\n *\n */\n/*\n * DTLS code by Eric Rescorla <ekr@rtfm.com>\n *\n * Copyright (C) 2006, Network Resonance, Inc. Copyright (C) 2011, RTFM, Inc.\n */\n\n#ifndef HEADER_D1_SRTP_H\n# define HEADER_D1_SRTP_H\n\n# include <openssl/ssl.h>\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n# define SRTP_AES128_CM_SHA1_80 0x0001\n# define SRTP_AES128_CM_SHA1_32 0x0002\n# define SRTP_AES128_F8_SHA1_80 0x0003\n# define SRTP_AES128_F8_SHA1_32 0x0004\n# define SRTP_NULL_SHA1_80      0x0005\n# define SRTP_NULL_SHA1_32      0x0006\n\n# ifndef OPENSSL_NO_SRTP\n\nint SSL_CTX_set_tlsext_use_srtp(SSL_CTX *ctx, const char *profiles);\nint SSL_set_tlsext_use_srtp(SSL *ctx, const char *profiles);\n\nSTACK_OF(SRTP_PROTECTION_PROFILE) *SSL_get_srtp_profiles(SSL *ssl);\nSRTP_PROTECTION_PROFILE *SSL_get_selected_srtp_profile(SSL *s);\n\n# endif\n\n#ifdef  __cplusplus\n}\n#endif\n\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/arm64/include/openssl/ssl.h",
    "content": "/* ssl/ssl.h */\n/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)\n * All rights reserved.\n *\n * This package is an SSL implementation written\n * by Eric Young (eay@cryptsoft.com).\n * The implementation was written so as to conform with Netscapes SSL.\n *\n * This library is free for commercial and non-commercial use as long as\n * the following conditions are aheared to.  The following conditions\n * apply to all code found in this distribution, be it the RC4, RSA,\n * lhash, DES, etc., code; not just the SSL code.  The SSL documentation\n * included with this distribution is covered by the same copyright terms\n * except that the holder is Tim Hudson (tjh@cryptsoft.com).\n *\n * Copyright remains Eric Young's, and as such any Copyright notices in\n * the code are not to be removed.\n * If this package is used in a product, Eric Young should be given attribution\n * as the author of the parts of the library used.\n * This can be in the form of a textual message at program startup or\n * in documentation (online or textual) provided with the package.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the copyright\n *    notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in the\n *    documentation and/or other materials provided with the distribution.\n * 3. All advertising materials mentioning features or use of this software\n *    must display the following acknowledgement:\n *    \"This product includes cryptographic software written by\n *     Eric Young (eay@cryptsoft.com)\"\n *    The word 'cryptographic' can be left out if the rouines from the library\n *    being used are not cryptographic related :-).\n * 4. If you include any Windows specific code (or a derivative thereof) from\n *    the apps directory (application code) you must include an acknowledgement:\n *    \"This product includes software written by Tim Hudson (tjh@cryptsoft.com)\"\n *\n * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n * SUCH DAMAGE.\n *\n * The licence and distribution terms for any publically available version or\n * derivative of this code cannot be changed.  i.e. this code cannot simply be\n * copied and put under another distribution licence\n * [including the GNU Public Licence.]\n */\n/* ====================================================================\n * Copyright (c) 1998-2007 The OpenSSL Project.  All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n *\n * 1. Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n *\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in\n *    the documentation and/or other materials provided with the\n *    distribution.\n *\n * 3. All advertising materials mentioning features or use of this\n *    software must display the following acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit. (http://www.openssl.org/)\"\n *\n * 4. The names \"OpenSSL Toolkit\" and \"OpenSSL Project\" must not be used to\n *    endorse or promote products derived from this software without\n *    prior written permission. For written permission, please contact\n *    openssl-core@openssl.org.\n *\n * 5. Products derived from this software may not be called \"OpenSSL\"\n *    nor may \"OpenSSL\" appear in their names without prior written\n *    permission of the OpenSSL Project.\n *\n * 6. Redistributions of any form whatsoever must retain the following\n *    acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit (http://www.openssl.org/)\"\n *\n * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY\n * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\n * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR\n * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\n * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,\n * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED\n * OF THE POSSIBILITY OF SUCH DAMAGE.\n * ====================================================================\n *\n * This product includes cryptographic software written by Eric Young\n * (eay@cryptsoft.com).  This product includes software written by Tim\n * Hudson (tjh@cryptsoft.com).\n *\n */\n/* ====================================================================\n * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED.\n * ECC cipher suite support in OpenSSL originally developed by\n * SUN MICROSYSTEMS, INC., and contributed to the OpenSSL project.\n */\n/* ====================================================================\n * Copyright 2005 Nokia. All rights reserved.\n *\n * The portions of the attached software (\"Contribution\") is developed by\n * Nokia Corporation and is licensed pursuant to the OpenSSL open source\n * license.\n *\n * The Contribution, originally written by Mika Kousa and Pasi Eronen of\n * Nokia Corporation, consists of the \"PSK\" (Pre-Shared Key) ciphersuites\n * support (see RFC 4279) to OpenSSL.\n *\n * No patent licenses or other rights except those expressly stated in\n * the OpenSSL open source license shall be deemed granted or received\n * expressly, by implication, estoppel, or otherwise.\n *\n * No assurances are provided by Nokia that the Contribution does not\n * infringe the patent or other intellectual property rights of any third\n * party or that the license provides you with all the necessary rights\n * to make use of the Contribution.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\" WITHOUT WARRANTY OF ANY KIND. IN\n * ADDITION TO THE DISCLAIMERS INCLUDED IN THE LICENSE, NOKIA\n * SPECIFICALLY DISCLAIMS ANY LIABILITY FOR CLAIMS BROUGHT BY YOU OR ANY\n * OTHER ENTITY BASED ON INFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS OR\n * OTHERWISE.\n */\n\n#ifndef HEADER_SSL_H\n# define HEADER_SSL_H\n\n# include <openssl/e_os2.h>\n\n# ifndef OPENSSL_NO_COMP\n#  include <openssl/comp.h>\n# endif\n# ifndef OPENSSL_NO_BIO\n#  include <openssl/bio.h>\n# endif\n# ifndef OPENSSL_NO_DEPRECATED\n#  ifndef OPENSSL_NO_X509\n#   include <openssl/x509.h>\n#  endif\n#  include <openssl/crypto.h>\n#  include <openssl/lhash.h>\n#  include <openssl/buffer.h>\n# endif\n# include <openssl/pem.h>\n# include <openssl/hmac.h>\n\n# include <openssl/kssl.h>\n# include <openssl/safestack.h>\n# include <openssl/symhacks.h>\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n/* SSLeay version number for ASN.1 encoding of the session information */\n/*-\n * Version 0 - initial version\n * Version 1 - added the optional peer certificate\n */\n# define SSL_SESSION_ASN1_VERSION 0x0001\n\n/* text strings for the ciphers */\n# define SSL_TXT_NULL_WITH_MD5           SSL2_TXT_NULL_WITH_MD5\n# define SSL_TXT_RC4_128_WITH_MD5        SSL2_TXT_RC4_128_WITH_MD5\n# define SSL_TXT_RC4_128_EXPORT40_WITH_MD5 SSL2_TXT_RC4_128_EXPORT40_WITH_MD5\n# define SSL_TXT_RC2_128_CBC_WITH_MD5    SSL2_TXT_RC2_128_CBC_WITH_MD5\n# define SSL_TXT_RC2_128_CBC_EXPORT40_WITH_MD5 SSL2_TXT_RC2_128_CBC_EXPORT40_WITH_MD5\n# define SSL_TXT_IDEA_128_CBC_WITH_MD5   SSL2_TXT_IDEA_128_CBC_WITH_MD5\n# define SSL_TXT_DES_64_CBC_WITH_MD5     SSL2_TXT_DES_64_CBC_WITH_MD5\n# define SSL_TXT_DES_64_CBC_WITH_SHA     SSL2_TXT_DES_64_CBC_WITH_SHA\n# define SSL_TXT_DES_192_EDE3_CBC_WITH_MD5 SSL2_TXT_DES_192_EDE3_CBC_WITH_MD5\n# define SSL_TXT_DES_192_EDE3_CBC_WITH_SHA SSL2_TXT_DES_192_EDE3_CBC_WITH_SHA\n\n/*\n * VRS Additional Kerberos5 entries\n */\n# define SSL_TXT_KRB5_DES_64_CBC_SHA   SSL3_TXT_KRB5_DES_64_CBC_SHA\n# define SSL_TXT_KRB5_DES_192_CBC3_SHA SSL3_TXT_KRB5_DES_192_CBC3_SHA\n# define SSL_TXT_KRB5_RC4_128_SHA      SSL3_TXT_KRB5_RC4_128_SHA\n# define SSL_TXT_KRB5_IDEA_128_CBC_SHA SSL3_TXT_KRB5_IDEA_128_CBC_SHA\n# define SSL_TXT_KRB5_DES_64_CBC_MD5   SSL3_TXT_KRB5_DES_64_CBC_MD5\n# define SSL_TXT_KRB5_DES_192_CBC3_MD5 SSL3_TXT_KRB5_DES_192_CBC3_MD5\n# define SSL_TXT_KRB5_RC4_128_MD5      SSL3_TXT_KRB5_RC4_128_MD5\n# define SSL_TXT_KRB5_IDEA_128_CBC_MD5 SSL3_TXT_KRB5_IDEA_128_CBC_MD5\n\n# define SSL_TXT_KRB5_DES_40_CBC_SHA   SSL3_TXT_KRB5_DES_40_CBC_SHA\n# define SSL_TXT_KRB5_RC2_40_CBC_SHA   SSL3_TXT_KRB5_RC2_40_CBC_SHA\n# define SSL_TXT_KRB5_RC4_40_SHA       SSL3_TXT_KRB5_RC4_40_SHA\n# define SSL_TXT_KRB5_DES_40_CBC_MD5   SSL3_TXT_KRB5_DES_40_CBC_MD5\n# define SSL_TXT_KRB5_RC2_40_CBC_MD5   SSL3_TXT_KRB5_RC2_40_CBC_MD5\n# define SSL_TXT_KRB5_RC4_40_MD5       SSL3_TXT_KRB5_RC4_40_MD5\n\n# define SSL_TXT_KRB5_DES_40_CBC_SHA   SSL3_TXT_KRB5_DES_40_CBC_SHA\n# define SSL_TXT_KRB5_DES_40_CBC_MD5   SSL3_TXT_KRB5_DES_40_CBC_MD5\n# define SSL_TXT_KRB5_DES_64_CBC_SHA   SSL3_TXT_KRB5_DES_64_CBC_SHA\n# define SSL_TXT_KRB5_DES_64_CBC_MD5   SSL3_TXT_KRB5_DES_64_CBC_MD5\n# define SSL_TXT_KRB5_DES_192_CBC3_SHA SSL3_TXT_KRB5_DES_192_CBC3_SHA\n# define SSL_TXT_KRB5_DES_192_CBC3_MD5 SSL3_TXT_KRB5_DES_192_CBC3_MD5\n# define SSL_MAX_KRB5_PRINCIPAL_LENGTH  256\n\n# define SSL_MAX_SSL_SESSION_ID_LENGTH           32\n# define SSL_MAX_SID_CTX_LENGTH                  32\n\n# define SSL_MIN_RSA_MODULUS_LENGTH_IN_BYTES     (512/8)\n# define SSL_MAX_KEY_ARG_LENGTH                  8\n# define SSL_MAX_MASTER_KEY_LENGTH               48\n\n/* These are used to specify which ciphers to use and not to use */\n\n# define SSL_TXT_EXP40           \"EXPORT40\"\n# define SSL_TXT_EXP56           \"EXPORT56\"\n# define SSL_TXT_LOW             \"LOW\"\n# define SSL_TXT_MEDIUM          \"MEDIUM\"\n# define SSL_TXT_HIGH            \"HIGH\"\n# define SSL_TXT_FIPS            \"FIPS\"\n\n# define SSL_TXT_kFZA            \"kFZA\"/* unused! */\n# define SSL_TXT_aFZA            \"aFZA\"/* unused! */\n# define SSL_TXT_eFZA            \"eFZA\"/* unused! */\n# define SSL_TXT_FZA             \"FZA\"/* unused! */\n\n# define SSL_TXT_aNULL           \"aNULL\"\n# define SSL_TXT_eNULL           \"eNULL\"\n# define SSL_TXT_NULL            \"NULL\"\n\n# define SSL_TXT_kRSA            \"kRSA\"\n# define SSL_TXT_kDHr            \"kDHr\"\n# define SSL_TXT_kDHd            \"kDHd\"\n# define SSL_TXT_kDH             \"kDH\"\n# define SSL_TXT_kEDH            \"kEDH\"\n# define SSL_TXT_kDHE            \"kDHE\"/* alias for kEDH */\n# define SSL_TXT_kKRB5           \"kKRB5\"\n# define SSL_TXT_kECDHr          \"kECDHr\"\n# define SSL_TXT_kECDHe          \"kECDHe\"\n# define SSL_TXT_kECDH           \"kECDH\"\n# define SSL_TXT_kEECDH          \"kEECDH\"\n# define SSL_TXT_kECDHE          \"kECDHE\"/* alias for kEECDH */\n# define SSL_TXT_kPSK            \"kPSK\"\n# define SSL_TXT_kGOST           \"kGOST\"\n# define SSL_TXT_kSRP            \"kSRP\"\n\n# define SSL_TXT_aRSA            \"aRSA\"\n# define SSL_TXT_aDSS            \"aDSS\"\n# define SSL_TXT_aDH             \"aDH\"\n# define SSL_TXT_aECDH           \"aECDH\"\n# define SSL_TXT_aKRB5           \"aKRB5\"\n# define SSL_TXT_aECDSA          \"aECDSA\"\n# define SSL_TXT_aPSK            \"aPSK\"\n# define SSL_TXT_aGOST94 \"aGOST94\"\n# define SSL_TXT_aGOST01 \"aGOST01\"\n# define SSL_TXT_aGOST  \"aGOST\"\n# define SSL_TXT_aSRP            \"aSRP\"\n\n# define SSL_TXT_DSS             \"DSS\"\n# define SSL_TXT_DH              \"DH\"\n# define SSL_TXT_EDH             \"EDH\"/* same as \"kEDH:-ADH\" */\n# define SSL_TXT_DHE             \"DHE\"/* alias for EDH */\n# define SSL_TXT_ADH             \"ADH\"\n# define SSL_TXT_RSA             \"RSA\"\n# define SSL_TXT_ECDH            \"ECDH\"\n# define SSL_TXT_EECDH           \"EECDH\"/* same as \"kEECDH:-AECDH\" */\n# define SSL_TXT_ECDHE           \"ECDHE\"/* alias for ECDHE\" */\n# define SSL_TXT_AECDH           \"AECDH\"\n# define SSL_TXT_ECDSA           \"ECDSA\"\n# define SSL_TXT_KRB5            \"KRB5\"\n# define SSL_TXT_PSK             \"PSK\"\n# define SSL_TXT_SRP             \"SRP\"\n\n# define SSL_TXT_DES             \"DES\"\n# define SSL_TXT_3DES            \"3DES\"\n# define SSL_TXT_RC4             \"RC4\"\n# define SSL_TXT_RC2             \"RC2\"\n# define SSL_TXT_IDEA            \"IDEA\"\n# define SSL_TXT_SEED            \"SEED\"\n# define SSL_TXT_AES128          \"AES128\"\n# define SSL_TXT_AES256          \"AES256\"\n# define SSL_TXT_AES             \"AES\"\n# define SSL_TXT_AES_GCM         \"AESGCM\"\n# define SSL_TXT_CAMELLIA128     \"CAMELLIA128\"\n# define SSL_TXT_CAMELLIA256     \"CAMELLIA256\"\n# define SSL_TXT_CAMELLIA        \"CAMELLIA\"\n\n# define SSL_TXT_MD5             \"MD5\"\n# define SSL_TXT_SHA1            \"SHA1\"\n# define SSL_TXT_SHA             \"SHA\"/* same as \"SHA1\" */\n# define SSL_TXT_GOST94          \"GOST94\"\n# define SSL_TXT_GOST89MAC               \"GOST89MAC\"\n# define SSL_TXT_SHA256          \"SHA256\"\n# define SSL_TXT_SHA384          \"SHA384\"\n\n# define SSL_TXT_SSLV2           \"SSLv2\"\n# define SSL_TXT_SSLV3           \"SSLv3\"\n# define SSL_TXT_TLSV1           \"TLSv1\"\n# define SSL_TXT_TLSV1_1         \"TLSv1.1\"\n# define SSL_TXT_TLSV1_2         \"TLSv1.2\"\n\n# define SSL_TXT_EXP             \"EXP\"\n# define SSL_TXT_EXPORT          \"EXPORT\"\n\n# define SSL_TXT_ALL             \"ALL\"\n\n/*-\n * COMPLEMENTOF* definitions. These identifiers are used to (de-select)\n * ciphers normally not being used.\n * Example: \"RC4\" will activate all ciphers using RC4 including ciphers\n * without authentication, which would normally disabled by DEFAULT (due\n * the \"!ADH\" being part of default). Therefore \"RC4:!COMPLEMENTOFDEFAULT\"\n * will make sure that it is also disabled in the specific selection.\n * COMPLEMENTOF* identifiers are portable between version, as adjustments\n * to the default cipher setup will also be included here.\n *\n * COMPLEMENTOFDEFAULT does not experience the same special treatment that\n * DEFAULT gets, as only selection is being done and no sorting as needed\n * for DEFAULT.\n */\n# define SSL_TXT_CMPALL          \"COMPLEMENTOFALL\"\n# define SSL_TXT_CMPDEF          \"COMPLEMENTOFDEFAULT\"\n\n/*\n * The following cipher list is used by default. It also is substituted when\n * an application-defined cipher list string starts with 'DEFAULT'.\n */\n# define SSL_DEFAULT_CIPHER_LIST \"ALL:!EXPORT:!LOW:!aNULL:!eNULL:!SSLv2\"\n/*\n * As of OpenSSL 1.0.0, ssl_create_cipher_list() in ssl/ssl_ciph.c always\n * starts with a reasonable order, and all we have to do for DEFAULT is\n * throwing out anonymous and unencrypted ciphersuites! (The latter are not\n * actually enabled by ALL, but \"ALL:RSA\" would enable some of them.)\n */\n\n/* Used in SSL_set_shutdown()/SSL_get_shutdown(); */\n# define SSL_SENT_SHUTDOWN       1\n# define SSL_RECEIVED_SHUTDOWN   2\n\n#ifdef __cplusplus\n}\n#endif\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n# if (defined(OPENSSL_NO_RSA) || defined(OPENSSL_NO_MD5)) && !defined(OPENSSL_NO_SSL2)\n#  define OPENSSL_NO_SSL2\n# endif\n\n# define SSL_FILETYPE_ASN1       X509_FILETYPE_ASN1\n# define SSL_FILETYPE_PEM        X509_FILETYPE_PEM\n\n/*\n * This is needed to stop compilers complaining about the 'struct ssl_st *'\n * function parameters used to prototype callbacks in SSL_CTX.\n */\ntypedef struct ssl_st *ssl_crock_st;\ntypedef struct tls_session_ticket_ext_st TLS_SESSION_TICKET_EXT;\ntypedef struct ssl_method_st SSL_METHOD;\ntypedef struct ssl_cipher_st SSL_CIPHER;\ntypedef struct ssl_session_st SSL_SESSION;\ntypedef struct tls_sigalgs_st TLS_SIGALGS;\ntypedef struct ssl_conf_ctx_st SSL_CONF_CTX;\n\nDECLARE_STACK_OF(SSL_CIPHER)\n\n/* SRTP protection profiles for use with the use_srtp extension (RFC 5764)*/\ntypedef struct srtp_protection_profile_st {\n    const char *name;\n    unsigned long id;\n} SRTP_PROTECTION_PROFILE;\n\nDECLARE_STACK_OF(SRTP_PROTECTION_PROFILE)\n\ntypedef int (*tls_session_ticket_ext_cb_fn) (SSL *s,\n                                             const unsigned char *data,\n                                             int len, void *arg);\ntypedef int (*tls_session_secret_cb_fn) (SSL *s, void *secret,\n                                         int *secret_len,\n                                         STACK_OF(SSL_CIPHER) *peer_ciphers,\n                                         SSL_CIPHER **cipher, void *arg);\n\n# ifndef OPENSSL_NO_TLSEXT\n\n/* Typedefs for handling custom extensions */\n\ntypedef int (*custom_ext_add_cb) (SSL *s, unsigned int ext_type,\n                                  const unsigned char **out,\n                                  size_t *outlen, int *al, void *add_arg);\n\ntypedef void (*custom_ext_free_cb) (SSL *s, unsigned int ext_type,\n                                    const unsigned char *out, void *add_arg);\n\ntypedef int (*custom_ext_parse_cb) (SSL *s, unsigned int ext_type,\n                                    const unsigned char *in,\n                                    size_t inlen, int *al, void *parse_arg);\n\n# endif\n\n# ifndef OPENSSL_NO_SSL_INTERN\n\n/* used to hold info on the particular ciphers used */\nstruct ssl_cipher_st {\n    int valid;\n    const char *name;           /* text name */\n    unsigned long id;           /* id, 4 bytes, first is version */\n    /*\n     * changed in 0.9.9: these four used to be portions of a single value\n     * 'algorithms'\n     */\n    unsigned long algorithm_mkey; /* key exchange algorithm */\n    unsigned long algorithm_auth; /* server authentication */\n    unsigned long algorithm_enc; /* symmetric encryption */\n    unsigned long algorithm_mac; /* symmetric authentication */\n    unsigned long algorithm_ssl; /* (major) protocol version */\n    unsigned long algo_strength; /* strength and export flags */\n    unsigned long algorithm2;   /* Extra flags */\n    int strength_bits;          /* Number of bits really used */\n    int alg_bits;               /* Number of bits for algorithm */\n};\n\n/* Used to hold functions for SSLv2 or SSLv3/TLSv1 functions */\nstruct ssl_method_st {\n    int version;\n    int (*ssl_new) (SSL *s);\n    void (*ssl_clear) (SSL *s);\n    void (*ssl_free) (SSL *s);\n    int (*ssl_accept) (SSL *s);\n    int (*ssl_connect) (SSL *s);\n    int (*ssl_read) (SSL *s, void *buf, int len);\n    int (*ssl_peek) (SSL *s, void *buf, int len);\n    int (*ssl_write) (SSL *s, const void *buf, int len);\n    int (*ssl_shutdown) (SSL *s);\n    int (*ssl_renegotiate) (SSL *s);\n    int (*ssl_renegotiate_check) (SSL *s);\n    long (*ssl_get_message) (SSL *s, int st1, int stn, int mt, long\n                             max, int *ok);\n    int (*ssl_read_bytes) (SSL *s, int type, unsigned char *buf, int len,\n                           int peek);\n    int (*ssl_write_bytes) (SSL *s, int type, const void *buf_, int len);\n    int (*ssl_dispatch_alert) (SSL *s);\n    long (*ssl_ctrl) (SSL *s, int cmd, long larg, void *parg);\n    long (*ssl_ctx_ctrl) (SSL_CTX *ctx, int cmd, long larg, void *parg);\n    const SSL_CIPHER *(*get_cipher_by_char) (const unsigned char *ptr);\n    int (*put_cipher_by_char) (const SSL_CIPHER *cipher, unsigned char *ptr);\n    int (*ssl_pending) (const SSL *s);\n    int (*num_ciphers) (void);\n    const SSL_CIPHER *(*get_cipher) (unsigned ncipher);\n    const struct ssl_method_st *(*get_ssl_method) (int version);\n    long (*get_timeout) (void);\n    struct ssl3_enc_method *ssl3_enc; /* Extra SSLv3/TLS stuff */\n    int (*ssl_version) (void);\n    long (*ssl_callback_ctrl) (SSL *s, int cb_id, void (*fp) (void));\n    long (*ssl_ctx_callback_ctrl) (SSL_CTX *s, int cb_id, void (*fp) (void));\n};\n\n/*-\n * Lets make this into an ASN.1 type structure as follows\n * SSL_SESSION_ID ::= SEQUENCE {\n *      version                 INTEGER,        -- structure version number\n *      SSLversion              INTEGER,        -- SSL version number\n *      Cipher                  OCTET STRING,   -- the 3 byte cipher ID\n *      Session_ID              OCTET STRING,   -- the Session ID\n *      Master_key              OCTET STRING,   -- the master key\n *      KRB5_principal          OCTET STRING    -- optional Kerberos principal\n *      Key_Arg [ 0 ] IMPLICIT  OCTET STRING,   -- the optional Key argument\n *      Time [ 1 ] EXPLICIT     INTEGER,        -- optional Start Time\n *      Timeout [ 2 ] EXPLICIT  INTEGER,        -- optional Timeout ins seconds\n *      Peer [ 3 ] EXPLICIT     X509,           -- optional Peer Certificate\n *      Session_ID_context [ 4 ] EXPLICIT OCTET STRING,   -- the Session ID context\n *      Verify_result [ 5 ] EXPLICIT INTEGER,   -- X509_V_... code for `Peer'\n *      HostName [ 6 ] EXPLICIT OCTET STRING,   -- optional HostName from servername TLS extension\n *      PSK_identity_hint [ 7 ] EXPLICIT OCTET STRING, -- optional PSK identity hint\n *      PSK_identity [ 8 ] EXPLICIT OCTET STRING,  -- optional PSK identity\n *      Ticket_lifetime_hint [9] EXPLICIT INTEGER, -- server's lifetime hint for session ticket\n *      Ticket [10]             EXPLICIT OCTET STRING, -- session ticket (clients only)\n *      Compression_meth [11]   EXPLICIT OCTET STRING, -- optional compression method\n *      SRP_username [ 12 ] EXPLICIT OCTET STRING -- optional SRP username\n *      }\n * Look in ssl/ssl_asn1.c for more details\n * I'm using EXPLICIT tags so I can read the damn things using asn1parse :-).\n */\nstruct ssl_session_st {\n    int ssl_version;            /* what ssl version session info is being\n                                 * kept in here? */\n    /* only really used in SSLv2 */\n    unsigned int key_arg_length;\n    unsigned char key_arg[SSL_MAX_KEY_ARG_LENGTH];\n    int master_key_length;\n    unsigned char master_key[SSL_MAX_MASTER_KEY_LENGTH];\n    /* session_id - valid? */\n    unsigned int session_id_length;\n    unsigned char session_id[SSL_MAX_SSL_SESSION_ID_LENGTH];\n    /*\n     * this is used to determine whether the session is being reused in the\n     * appropriate context. It is up to the application to set this, via\n     * SSL_new\n     */\n    unsigned int sid_ctx_length;\n    unsigned char sid_ctx[SSL_MAX_SID_CTX_LENGTH];\n#  ifndef OPENSSL_NO_KRB5\n    unsigned int krb5_client_princ_len;\n    unsigned char krb5_client_princ[SSL_MAX_KRB5_PRINCIPAL_LENGTH];\n#  endif                        /* OPENSSL_NO_KRB5 */\n#  ifndef OPENSSL_NO_PSK\n    char *psk_identity_hint;\n    char *psk_identity;\n#  endif\n    /*\n     * Used to indicate that session resumption is not allowed. Applications\n     * can also set this bit for a new session via not_resumable_session_cb\n     * to disable session caching and tickets.\n     */\n    int not_resumable;\n    /* The cert is the certificate used to establish this connection */\n    struct sess_cert_st /* SESS_CERT */ *sess_cert;\n    /*\n     * This is the cert for the other end. On clients, it will be the same as\n     * sess_cert->peer_key->x509 (the latter is not enough as sess_cert is\n     * not retained in the external representation of sessions, see\n     * ssl_asn1.c).\n     */\n    X509 *peer;\n    /*\n     * when app_verify_callback accepts a session where the peer's\n     * certificate is not ok, we must remember the error for session reuse:\n     */\n    long verify_result;         /* only for servers */\n    int references;\n    long timeout;\n    long time;\n    unsigned int compress_meth; /* Need to lookup the method */\n    const SSL_CIPHER *cipher;\n    unsigned long cipher_id;    /* when ASN.1 loaded, this needs to be used\n                                 * to load the 'cipher' structure */\n    STACK_OF(SSL_CIPHER) *ciphers; /* shared ciphers? */\n    CRYPTO_EX_DATA ex_data;     /* application specific data */\n    /*\n     * These are used to make removal of session-ids more efficient and to\n     * implement a maximum cache size.\n     */\n    struct ssl_session_st *prev, *next;\n#  ifndef OPENSSL_NO_TLSEXT\n    char *tlsext_hostname;\n#   ifndef OPENSSL_NO_EC\n    size_t tlsext_ecpointformatlist_length;\n    unsigned char *tlsext_ecpointformatlist; /* peer's list */\n    size_t tlsext_ellipticcurvelist_length;\n    unsigned char *tlsext_ellipticcurvelist; /* peer's list */\n#   endif                       /* OPENSSL_NO_EC */\n    /* RFC4507 info */\n    unsigned char *tlsext_tick; /* Session ticket */\n    size_t tlsext_ticklen;      /* Session ticket length */\n    long tlsext_tick_lifetime_hint; /* Session lifetime hint in seconds */\n#  endif\n#  ifndef OPENSSL_NO_SRP\n    char *srp_username;\n#  endif\n};\n\n# endif\n\n# define SSL_OP_MICROSOFT_SESS_ID_BUG                    0x00000001L\n# define SSL_OP_NETSCAPE_CHALLENGE_BUG                   0x00000002L\n/* Allow initial connection to servers that don't support RI */\n# define SSL_OP_LEGACY_SERVER_CONNECT                    0x00000004L\n# define SSL_OP_NETSCAPE_REUSE_CIPHER_CHANGE_BUG         0x00000008L\n# define SSL_OP_TLSEXT_PADDING                           0x00000010L\n# define SSL_OP_MICROSOFT_BIG_SSLV3_BUFFER               0x00000020L\n# define SSL_OP_SAFARI_ECDHE_ECDSA_BUG                   0x00000040L\n# define SSL_OP_SSLEAY_080_CLIENT_DH_BUG                 0x00000080L\n# define SSL_OP_TLS_D5_BUG                               0x00000100L\n# define SSL_OP_TLS_BLOCK_PADDING_BUG                    0x00000200L\n\n/* Hasn't done anything since OpenSSL 0.9.7h, retained for compatibility */\n# define SSL_OP_MSIE_SSLV2_RSA_PADDING                   0x0\n/* Refers to ancient SSLREF and SSLv2, retained for compatibility */\n# define SSL_OP_SSLREF2_REUSE_CERT_TYPE_BUG              0x0\n\n/*\n * Disable SSL 3.0/TLS 1.0 CBC vulnerability workaround that was added in\n * OpenSSL 0.9.6d.  Usually (depending on the application protocol) the\n * workaround is not needed.  Unfortunately some broken SSL/TLS\n * implementations cannot handle it at all, which is why we include it in\n * SSL_OP_ALL.\n */\n/* added in 0.9.6e */\n# define SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS              0x00000800L\n\n/*\n * SSL_OP_ALL: various bug workarounds that should be rather harmless.  This\n * used to be 0x000FFFFFL before 0.9.7.\n */\n# define SSL_OP_ALL                                      0x80000BFFL\n\n/* DTLS options */\n# define SSL_OP_NO_QUERY_MTU                 0x00001000L\n/* Turn on Cookie Exchange (on relevant for servers) */\n# define SSL_OP_COOKIE_EXCHANGE              0x00002000L\n/* Don't use RFC4507 ticket extension */\n# define SSL_OP_NO_TICKET                    0x00004000L\n/* Use Cisco's \"speshul\" version of DTLS_BAD_VER (as client)  */\n# define SSL_OP_CISCO_ANYCONNECT             0x00008000L\n\n/* As server, disallow session resumption on renegotiation */\n# define SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION   0x00010000L\n/* Don't use compression even if supported */\n# define SSL_OP_NO_COMPRESSION                           0x00020000L\n/* Permit unsafe legacy renegotiation */\n# define SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION        0x00040000L\n/* If set, always create a new key when using tmp_ecdh parameters */\n# define SSL_OP_SINGLE_ECDH_USE                          0x00080000L\n/* Does nothing: retained for compatibility */\n# define SSL_OP_SINGLE_DH_USE                            0x00100000L\n/* Does nothing: retained for compatibiity */\n# define SSL_OP_EPHEMERAL_RSA                            0x0\n/*\n * Set on servers to choose the cipher according to the server's preferences\n */\n# define SSL_OP_CIPHER_SERVER_PREFERENCE                 0x00400000L\n/*\n * If set, a server will allow a client to issue a SSLv3.0 version number as\n * latest version supported in the premaster secret, even when TLSv1.0\n * (version 3.1) was announced in the client hello. Normally this is\n * forbidden to prevent version rollback attacks.\n */\n# define SSL_OP_TLS_ROLLBACK_BUG                         0x00800000L\n\n# define SSL_OP_NO_SSLv2                                 0x01000000L\n# define SSL_OP_NO_SSLv3                                 0x02000000L\n# define SSL_OP_NO_TLSv1                                 0x04000000L\n# define SSL_OP_NO_TLSv1_2                               0x08000000L\n# define SSL_OP_NO_TLSv1_1                               0x10000000L\n\n# define SSL_OP_NO_DTLSv1                                0x04000000L\n# define SSL_OP_NO_DTLSv1_2                              0x08000000L\n\n# define SSL_OP_NO_SSL_MASK (SSL_OP_NO_SSLv2|SSL_OP_NO_SSLv3|\\\n        SSL_OP_NO_TLSv1|SSL_OP_NO_TLSv1_1|SSL_OP_NO_TLSv1_2)\n\n/*\n * These next two were never actually used for anything since SSLeay zap so\n * we have some more flags.\n */\n/*\n * The next flag deliberately changes the ciphertest, this is a check for the\n * PKCS#1 attack\n */\n# define SSL_OP_PKCS1_CHECK_1                            0x0\n# define SSL_OP_PKCS1_CHECK_2                            0x0\n\n# define SSL_OP_NETSCAPE_CA_DN_BUG                       0x20000000L\n# define SSL_OP_NETSCAPE_DEMO_CIPHER_CHANGE_BUG          0x40000000L\n/*\n * Make server add server-hello extension from early version of cryptopro\n * draft, when GOST ciphersuite is negotiated. Required for interoperability\n * with CryptoPro CSP 3.x\n */\n# define SSL_OP_CRYPTOPRO_TLSEXT_BUG                     0x80000000L\n\n/*\n * Allow SSL_write(..., n) to return r with 0 < r < n (i.e. report success\n * when just a single record has been written):\n */\n# define SSL_MODE_ENABLE_PARTIAL_WRITE       0x00000001L\n/*\n * Make it possible to retry SSL_write() with changed buffer location (buffer\n * contents must stay the same!); this is not the default to avoid the\n * misconception that non-blocking SSL_write() behaves like non-blocking\n * write():\n */\n# define SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER 0x00000002L\n/*\n * Never bother the application with retries if the transport is blocking:\n */\n# define SSL_MODE_AUTO_RETRY 0x00000004L\n/* Don't attempt to automatically build certificate chain */\n# define SSL_MODE_NO_AUTO_CHAIN 0x00000008L\n/*\n * Save RAM by releasing read and write buffers when they're empty. (SSL3 and\n * TLS only.) \"Released\" buffers are put onto a free-list in the context or\n * just freed (depending on the context's setting for freelist_max_len).\n */\n# define SSL_MODE_RELEASE_BUFFERS 0x00000010L\n/*\n * Send the current time in the Random fields of the ClientHello and\n * ServerHello records for compatibility with hypothetical implementations\n * that require it.\n */\n# define SSL_MODE_SEND_CLIENTHELLO_TIME 0x00000020L\n# define SSL_MODE_SEND_SERVERHELLO_TIME 0x00000040L\n/*\n * Send TLS_FALLBACK_SCSV in the ClientHello. To be set only by applications\n * that reconnect with a downgraded protocol version; see\n * draft-ietf-tls-downgrade-scsv-00 for details. DO NOT ENABLE THIS if your\n * application attempts a normal handshake. Only use this in explicit\n * fallback retries, following the guidance in\n * draft-ietf-tls-downgrade-scsv-00.\n */\n# define SSL_MODE_SEND_FALLBACK_SCSV 0x00000080L\n\n/* Cert related flags */\n/*\n * Many implementations ignore some aspects of the TLS standards such as\n * enforcing certifcate chain algorithms. When this is set we enforce them.\n */\n# define SSL_CERT_FLAG_TLS_STRICT                0x00000001L\n\n/* Suite B modes, takes same values as certificate verify flags */\n# define SSL_CERT_FLAG_SUITEB_128_LOS_ONLY       0x10000\n/* Suite B 192 bit only mode */\n# define SSL_CERT_FLAG_SUITEB_192_LOS            0x20000\n/* Suite B 128 bit mode allowing 192 bit algorithms */\n# define SSL_CERT_FLAG_SUITEB_128_LOS            0x30000\n\n/* Perform all sorts of protocol violations for testing purposes */\n# define SSL_CERT_FLAG_BROKEN_PROTOCOL           0x10000000\n\n/* Flags for building certificate chains */\n/* Treat any existing certificates as untrusted CAs */\n# define SSL_BUILD_CHAIN_FLAG_UNTRUSTED          0x1\n/* Don't include root CA in chain */\n# define SSL_BUILD_CHAIN_FLAG_NO_ROOT            0x2\n/* Just check certificates already there */\n# define SSL_BUILD_CHAIN_FLAG_CHECK              0x4\n/* Ignore verification errors */\n# define SSL_BUILD_CHAIN_FLAG_IGNORE_ERROR       0x8\n/* Clear verification errors from queue */\n# define SSL_BUILD_CHAIN_FLAG_CLEAR_ERROR        0x10\n\n/* Flags returned by SSL_check_chain */\n/* Certificate can be used with this session */\n# define CERT_PKEY_VALID         0x1\n/* Certificate can also be used for signing */\n# define CERT_PKEY_SIGN          0x2\n/* EE certificate signing algorithm OK */\n# define CERT_PKEY_EE_SIGNATURE  0x10\n/* CA signature algorithms OK */\n# define CERT_PKEY_CA_SIGNATURE  0x20\n/* EE certificate parameters OK */\n# define CERT_PKEY_EE_PARAM      0x40\n/* CA certificate parameters OK */\n# define CERT_PKEY_CA_PARAM      0x80\n/* Signing explicitly allowed as opposed to SHA1 fallback */\n# define CERT_PKEY_EXPLICIT_SIGN 0x100\n/* Client CA issuer names match (always set for server cert) */\n# define CERT_PKEY_ISSUER_NAME   0x200\n/* Cert type matches client types (always set for server cert) */\n# define CERT_PKEY_CERT_TYPE     0x400\n/* Cert chain suitable to Suite B */\n# define CERT_PKEY_SUITEB        0x800\n\n# define SSL_CONF_FLAG_CMDLINE           0x1\n# define SSL_CONF_FLAG_FILE              0x2\n# define SSL_CONF_FLAG_CLIENT            0x4\n# define SSL_CONF_FLAG_SERVER            0x8\n# define SSL_CONF_FLAG_SHOW_ERRORS       0x10\n# define SSL_CONF_FLAG_CERTIFICATE       0x20\n/* Configuration value types */\n# define SSL_CONF_TYPE_UNKNOWN           0x0\n# define SSL_CONF_TYPE_STRING            0x1\n# define SSL_CONF_TYPE_FILE              0x2\n# define SSL_CONF_TYPE_DIR               0x3\n\n/*\n * Note: SSL[_CTX]_set_{options,mode} use |= op on the previous value, they\n * cannot be used to clear bits.\n */\n\n# define SSL_CTX_set_options(ctx,op) \\\n        SSL_CTX_ctrl((ctx),SSL_CTRL_OPTIONS,(op),NULL)\n# define SSL_CTX_clear_options(ctx,op) \\\n        SSL_CTX_ctrl((ctx),SSL_CTRL_CLEAR_OPTIONS,(op),NULL)\n# define SSL_CTX_get_options(ctx) \\\n        SSL_CTX_ctrl((ctx),SSL_CTRL_OPTIONS,0,NULL)\n# define SSL_set_options(ssl,op) \\\n        SSL_ctrl((ssl),SSL_CTRL_OPTIONS,(op),NULL)\n# define SSL_clear_options(ssl,op) \\\n        SSL_ctrl((ssl),SSL_CTRL_CLEAR_OPTIONS,(op),NULL)\n# define SSL_get_options(ssl) \\\n        SSL_ctrl((ssl),SSL_CTRL_OPTIONS,0,NULL)\n\n# define SSL_CTX_set_mode(ctx,op) \\\n        SSL_CTX_ctrl((ctx),SSL_CTRL_MODE,(op),NULL)\n# define SSL_CTX_clear_mode(ctx,op) \\\n        SSL_CTX_ctrl((ctx),SSL_CTRL_CLEAR_MODE,(op),NULL)\n# define SSL_CTX_get_mode(ctx) \\\n        SSL_CTX_ctrl((ctx),SSL_CTRL_MODE,0,NULL)\n# define SSL_clear_mode(ssl,op) \\\n        SSL_ctrl((ssl),SSL_CTRL_CLEAR_MODE,(op),NULL)\n# define SSL_set_mode(ssl,op) \\\n        SSL_ctrl((ssl),SSL_CTRL_MODE,(op),NULL)\n# define SSL_get_mode(ssl) \\\n        SSL_ctrl((ssl),SSL_CTRL_MODE,0,NULL)\n# define SSL_set_mtu(ssl, mtu) \\\n        SSL_ctrl((ssl),SSL_CTRL_SET_MTU,(mtu),NULL)\n# define DTLS_set_link_mtu(ssl, mtu) \\\n        SSL_ctrl((ssl),DTLS_CTRL_SET_LINK_MTU,(mtu),NULL)\n# define DTLS_get_link_min_mtu(ssl) \\\n        SSL_ctrl((ssl),DTLS_CTRL_GET_LINK_MIN_MTU,0,NULL)\n\n# define SSL_get_secure_renegotiation_support(ssl) \\\n        SSL_ctrl((ssl), SSL_CTRL_GET_RI_SUPPORT, 0, NULL)\n\n# ifndef OPENSSL_NO_HEARTBEATS\n#  define SSL_heartbeat(ssl) \\\n        SSL_ctrl((ssl),SSL_CTRL_TLS_EXT_SEND_HEARTBEAT,0,NULL)\n# endif\n\n# define SSL_CTX_set_cert_flags(ctx,op) \\\n        SSL_CTX_ctrl((ctx),SSL_CTRL_CERT_FLAGS,(op),NULL)\n# define SSL_set_cert_flags(s,op) \\\n        SSL_ctrl((s),SSL_CTRL_CERT_FLAGS,(op),NULL)\n# define SSL_CTX_clear_cert_flags(ctx,op) \\\n        SSL_CTX_ctrl((ctx),SSL_CTRL_CLEAR_CERT_FLAGS,(op),NULL)\n# define SSL_clear_cert_flags(s,op) \\\n        SSL_ctrl((s),SSL_CTRL_CLEAR_CERT_FLAGS,(op),NULL)\n\nvoid SSL_CTX_set_msg_callback(SSL_CTX *ctx,\n                              void (*cb) (int write_p, int version,\n                                          int content_type, const void *buf,\n                                          size_t len, SSL *ssl, void *arg));\nvoid SSL_set_msg_callback(SSL *ssl,\n                          void (*cb) (int write_p, int version,\n                                      int content_type, const void *buf,\n                                      size_t len, SSL *ssl, void *arg));\n# define SSL_CTX_set_msg_callback_arg(ctx, arg) SSL_CTX_ctrl((ctx), SSL_CTRL_SET_MSG_CALLBACK_ARG, 0, (arg))\n# define SSL_set_msg_callback_arg(ssl, arg) SSL_ctrl((ssl), SSL_CTRL_SET_MSG_CALLBACK_ARG, 0, (arg))\n\n# ifndef OPENSSL_NO_SRP\n\n#  ifndef OPENSSL_NO_SSL_INTERN\n\ntypedef struct srp_ctx_st {\n    /* param for all the callbacks */\n    void *SRP_cb_arg;\n    /* set client Hello login callback */\n    int (*TLS_ext_srp_username_callback) (SSL *, int *, void *);\n    /* set SRP N/g param callback for verification */\n    int (*SRP_verify_param_callback) (SSL *, void *);\n    /* set SRP client passwd callback */\n    char *(*SRP_give_srp_client_pwd_callback) (SSL *, void *);\n    char *login;\n    BIGNUM *N, *g, *s, *B, *A;\n    BIGNUM *a, *b, *v;\n    char *info;\n    int strength;\n    unsigned long srp_Mask;\n} SRP_CTX;\n\n#  endif\n\n/* see tls_srp.c */\nint SSL_SRP_CTX_init(SSL *s);\nint SSL_CTX_SRP_CTX_init(SSL_CTX *ctx);\nint SSL_SRP_CTX_free(SSL *ctx);\nint SSL_CTX_SRP_CTX_free(SSL_CTX *ctx);\nint SSL_srp_server_param_with_username(SSL *s, int *ad);\nint SRP_generate_server_master_secret(SSL *s, unsigned char *master_key);\nint SRP_Calc_A_param(SSL *s);\nint SRP_generate_client_master_secret(SSL *s, unsigned char *master_key);\n\n# endif\n\n# if defined(OPENSSL_SYS_MSDOS) && !defined(OPENSSL_SYS_WIN32)\n#  define SSL_MAX_CERT_LIST_DEFAULT 1024*30\n                                          /* 30k max cert list :-) */\n# else\n#  define SSL_MAX_CERT_LIST_DEFAULT 1024*100\n                                           /* 100k max cert list :-) */\n# endif\n\n# define SSL_SESSION_CACHE_MAX_SIZE_DEFAULT      (1024*20)\n\n/*\n * This callback type is used inside SSL_CTX, SSL, and in the functions that\n * set them. It is used to override the generation of SSL/TLS session IDs in\n * a server. Return value should be zero on an error, non-zero to proceed.\n * Also, callbacks should themselves check if the id they generate is unique\n * otherwise the SSL handshake will fail with an error - callbacks can do\n * this using the 'ssl' value they're passed by;\n * SSL_has_matching_session_id(ssl, id, *id_len) The length value passed in\n * is set at the maximum size the session ID can be. In SSLv2 this is 16\n * bytes, whereas SSLv3/TLSv1 it is 32 bytes. The callback can alter this\n * length to be less if desired, but under SSLv2 session IDs are supposed to\n * be fixed at 16 bytes so the id will be padded after the callback returns\n * in this case. It is also an error for the callback to set the size to\n * zero.\n */\ntypedef int (*GEN_SESSION_CB) (const SSL *ssl, unsigned char *id,\n                               unsigned int *id_len);\n\ntypedef struct ssl_comp_st SSL_COMP;\n\n# ifndef OPENSSL_NO_SSL_INTERN\n\nstruct ssl_comp_st {\n    int id;\n    const char *name;\n#  ifndef OPENSSL_NO_COMP\n    COMP_METHOD *method;\n#  else\n    char *method;\n#  endif\n};\n\nDECLARE_STACK_OF(SSL_COMP)\nDECLARE_LHASH_OF(SSL_SESSION);\n\nstruct ssl_ctx_st {\n    const SSL_METHOD *method;\n    STACK_OF(SSL_CIPHER) *cipher_list;\n    /* same as above but sorted for lookup */\n    STACK_OF(SSL_CIPHER) *cipher_list_by_id;\n    struct x509_store_st /* X509_STORE */ *cert_store;\n    LHASH_OF(SSL_SESSION) *sessions;\n    /*\n     * Most session-ids that will be cached, default is\n     * SSL_SESSION_CACHE_MAX_SIZE_DEFAULT. 0 is unlimited.\n     */\n    unsigned long session_cache_size;\n    struct ssl_session_st *session_cache_head;\n    struct ssl_session_st *session_cache_tail;\n    /*\n     * This can have one of 2 values, ored together, SSL_SESS_CACHE_CLIENT,\n     * SSL_SESS_CACHE_SERVER, Default is SSL_SESSION_CACHE_SERVER, which\n     * means only SSL_accept which cache SSL_SESSIONS.\n     */\n    int session_cache_mode;\n    /*\n     * If timeout is not 0, it is the default timeout value set when\n     * SSL_new() is called.  This has been put in to make life easier to set\n     * things up\n     */\n    long session_timeout;\n    /*\n     * If this callback is not null, it will be called each time a session id\n     * is added to the cache.  If this function returns 1, it means that the\n     * callback will do a SSL_SESSION_free() when it has finished using it.\n     * Otherwise, on 0, it means the callback has finished with it. If\n     * remove_session_cb is not null, it will be called when a session-id is\n     * removed from the cache.  After the call, OpenSSL will\n     * SSL_SESSION_free() it.\n     */\n    int (*new_session_cb) (struct ssl_st *ssl, SSL_SESSION *sess);\n    void (*remove_session_cb) (struct ssl_ctx_st *ctx, SSL_SESSION *sess);\n    SSL_SESSION *(*get_session_cb) (struct ssl_st *ssl,\n                                    unsigned char *data, int len, int *copy);\n    struct {\n        int sess_connect;       /* SSL new conn - started */\n        int sess_connect_renegotiate; /* SSL reneg - requested */\n        int sess_connect_good;  /* SSL new conne/reneg - finished */\n        int sess_accept;        /* SSL new accept - started */\n        int sess_accept_renegotiate; /* SSL reneg - requested */\n        int sess_accept_good;   /* SSL accept/reneg - finished */\n        int sess_miss;          /* session lookup misses */\n        int sess_timeout;       /* reuse attempt on timeouted session */\n        int sess_cache_full;    /* session removed due to full cache */\n        int sess_hit;           /* session reuse actually done */\n        int sess_cb_hit;        /* session-id that was not in the cache was\n                                 * passed back via the callback.  This\n                                 * indicates that the application is\n                                 * supplying session-id's from other\n                                 * processes - spooky :-) */\n    } stats;\n\n    int references;\n\n    /* if defined, these override the X509_verify_cert() calls */\n    int (*app_verify_callback) (X509_STORE_CTX *, void *);\n    void *app_verify_arg;\n    /*\n     * before OpenSSL 0.9.7, 'app_verify_arg' was ignored\n     * ('app_verify_callback' was called with just one argument)\n     */\n\n    /* Default password callback. */\n    pem_password_cb *default_passwd_callback;\n\n    /* Default password callback user data. */\n    void *default_passwd_callback_userdata;\n\n    /* get client cert callback */\n    int (*client_cert_cb) (SSL *ssl, X509 **x509, EVP_PKEY **pkey);\n\n    /* cookie generate callback */\n    int (*app_gen_cookie_cb) (SSL *ssl, unsigned char *cookie,\n                              unsigned int *cookie_len);\n\n    /* verify cookie callback */\n    int (*app_verify_cookie_cb) (SSL *ssl, unsigned char *cookie,\n                                 unsigned int cookie_len);\n\n    CRYPTO_EX_DATA ex_data;\n\n    const EVP_MD *rsa_md5;      /* For SSLv2 - name is 'ssl2-md5' */\n    const EVP_MD *md5;          /* For SSLv3/TLSv1 'ssl3-md5' */\n    const EVP_MD *sha1;         /* For SSLv3/TLSv1 'ssl3->sha1' */\n\n    STACK_OF(X509) *extra_certs;\n    STACK_OF(SSL_COMP) *comp_methods; /* stack of SSL_COMP, SSLv3/TLSv1 */\n\n    /* Default values used when no per-SSL value is defined follow */\n\n    /* used if SSL's info_callback is NULL */\n    void (*info_callback) (const SSL *ssl, int type, int val);\n\n    /* what we put in client cert requests */\n    STACK_OF(X509_NAME) *client_CA;\n\n    /*\n     * Default values to use in SSL structures follow (these are copied by\n     * SSL_new)\n     */\n\n    unsigned long options;\n    unsigned long mode;\n    long max_cert_list;\n\n    struct cert_st /* CERT */ *cert;\n    int read_ahead;\n\n    /* callback that allows applications to peek at protocol messages */\n    void (*msg_callback) (int write_p, int version, int content_type,\n                          const void *buf, size_t len, SSL *ssl, void *arg);\n    void *msg_callback_arg;\n\n    int verify_mode;\n    unsigned int sid_ctx_length;\n    unsigned char sid_ctx[SSL_MAX_SID_CTX_LENGTH];\n    /* called 'verify_callback' in the SSL */\n    int (*default_verify_callback) (int ok, X509_STORE_CTX *ctx);\n\n    /* Default generate session ID callback. */\n    GEN_SESSION_CB generate_session_id;\n\n    X509_VERIFY_PARAM *param;\n\n#  if 0\n    int purpose;                /* Purpose setting */\n    int trust;                  /* Trust setting */\n#  endif\n\n    int quiet_shutdown;\n\n    /*\n     * Maximum amount of data to send in one fragment. actual record size can\n     * be more than this due to padding and MAC overheads.\n     */\n    unsigned int max_send_fragment;\n\n#  ifndef OPENSSL_NO_ENGINE\n    /*\n     * Engine to pass requests for client certs to\n     */\n    ENGINE *client_cert_engine;\n#  endif\n\n#  ifndef OPENSSL_NO_TLSEXT\n    /* TLS extensions servername callback */\n    int (*tlsext_servername_callback) (SSL *, int *, void *);\n    void *tlsext_servername_arg;\n    /* RFC 4507 session ticket keys */\n    unsigned char tlsext_tick_key_name[16];\n    unsigned char tlsext_tick_hmac_key[16];\n    unsigned char tlsext_tick_aes_key[16];\n    /* Callback to support customisation of ticket key setting */\n    int (*tlsext_ticket_key_cb) (SSL *ssl,\n                                 unsigned char *name, unsigned char *iv,\n                                 EVP_CIPHER_CTX *ectx,\n                                 HMAC_CTX *hctx, int enc);\n\n    /* certificate status request info */\n    /* Callback for status request */\n    int (*tlsext_status_cb) (SSL *ssl, void *arg);\n    void *tlsext_status_arg;\n\n    /* draft-rescorla-tls-opaque-prf-input-00.txt information */\n    int (*tlsext_opaque_prf_input_callback) (SSL *, void *peerinput,\n                                             size_t len, void *arg);\n    void *tlsext_opaque_prf_input_callback_arg;\n#  endif\n\n#  ifndef OPENSSL_NO_PSK\n    char *psk_identity_hint;\n    unsigned int (*psk_client_callback) (SSL *ssl, const char *hint,\n                                         char *identity,\n                                         unsigned int max_identity_len,\n                                         unsigned char *psk,\n                                         unsigned int max_psk_len);\n    unsigned int (*psk_server_callback) (SSL *ssl, const char *identity,\n                                         unsigned char *psk,\n                                         unsigned int max_psk_len);\n#  endif\n\n#  ifndef OPENSSL_NO_BUF_FREELISTS\n#   define SSL_MAX_BUF_FREELIST_LEN_DEFAULT 32\n    unsigned int freelist_max_len;\n    struct ssl3_buf_freelist_st *wbuf_freelist;\n    struct ssl3_buf_freelist_st *rbuf_freelist;\n#  endif\n#  ifndef OPENSSL_NO_SRP\n    SRP_CTX srp_ctx;            /* ctx for SRP authentication */\n#  endif\n\n#  ifndef OPENSSL_NO_TLSEXT\n\n#   ifndef OPENSSL_NO_NEXTPROTONEG\n    /* Next protocol negotiation information */\n    /* (for experimental NPN extension). */\n\n    /*\n     * For a server, this contains a callback function by which the set of\n     * advertised protocols can be provided.\n     */\n    int (*next_protos_advertised_cb) (SSL *s, const unsigned char **buf,\n                                      unsigned int *len, void *arg);\n    void *next_protos_advertised_cb_arg;\n    /*\n     * For a client, this contains a callback function that selects the next\n     * protocol from the list provided by the server.\n     */\n    int (*next_proto_select_cb) (SSL *s, unsigned char **out,\n                                 unsigned char *outlen,\n                                 const unsigned char *in,\n                                 unsigned int inlen, void *arg);\n    void *next_proto_select_cb_arg;\n#   endif\n    /* SRTP profiles we are willing to do from RFC 5764 */\n    STACK_OF(SRTP_PROTECTION_PROFILE) *srtp_profiles;\n\n    /*\n     * ALPN information (we are in the process of transitioning from NPN to\n     * ALPN.)\n     */\n\n    /*-\n     * For a server, this contains a callback function that allows the\n     * server to select the protocol for the connection.\n     *   out: on successful return, this must point to the raw protocol\n     *        name (without the length prefix).\n     *   outlen: on successful return, this contains the length of |*out|.\n     *   in: points to the client's list of supported protocols in\n     *       wire-format.\n     *   inlen: the length of |in|.\n     */\n    int (*alpn_select_cb) (SSL *s,\n                           const unsigned char **out,\n                           unsigned char *outlen,\n                           const unsigned char *in,\n                           unsigned int inlen, void *arg);\n    void *alpn_select_cb_arg;\n\n    /*\n     * For a client, this contains the list of supported protocols in wire\n     * format.\n     */\n    unsigned char *alpn_client_proto_list;\n    unsigned alpn_client_proto_list_len;\n\n#   ifndef OPENSSL_NO_EC\n    /* EC extension values inherited by SSL structure */\n    size_t tlsext_ecpointformatlist_length;\n    unsigned char *tlsext_ecpointformatlist;\n    size_t tlsext_ellipticcurvelist_length;\n    unsigned char *tlsext_ellipticcurvelist;\n#   endif                       /* OPENSSL_NO_EC */\n#  endif\n};\n\n# endif\n\n# define SSL_SESS_CACHE_OFF                      0x0000\n# define SSL_SESS_CACHE_CLIENT                   0x0001\n# define SSL_SESS_CACHE_SERVER                   0x0002\n# define SSL_SESS_CACHE_BOTH     (SSL_SESS_CACHE_CLIENT|SSL_SESS_CACHE_SERVER)\n# define SSL_SESS_CACHE_NO_AUTO_CLEAR            0x0080\n/* enough comments already ... see SSL_CTX_set_session_cache_mode(3) */\n# define SSL_SESS_CACHE_NO_INTERNAL_LOOKUP       0x0100\n# define SSL_SESS_CACHE_NO_INTERNAL_STORE        0x0200\n# define SSL_SESS_CACHE_NO_INTERNAL \\\n        (SSL_SESS_CACHE_NO_INTERNAL_LOOKUP|SSL_SESS_CACHE_NO_INTERNAL_STORE)\n\nLHASH_OF(SSL_SESSION) *SSL_CTX_sessions(SSL_CTX *ctx);\n# define SSL_CTX_sess_number(ctx) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_SESS_NUMBER,0,NULL)\n# define SSL_CTX_sess_connect(ctx) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_SESS_CONNECT,0,NULL)\n# define SSL_CTX_sess_connect_good(ctx) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_SESS_CONNECT_GOOD,0,NULL)\n# define SSL_CTX_sess_connect_renegotiate(ctx) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_SESS_CONNECT_RENEGOTIATE,0,NULL)\n# define SSL_CTX_sess_accept(ctx) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_SESS_ACCEPT,0,NULL)\n# define SSL_CTX_sess_accept_renegotiate(ctx) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_SESS_ACCEPT_RENEGOTIATE,0,NULL)\n# define SSL_CTX_sess_accept_good(ctx) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_SESS_ACCEPT_GOOD,0,NULL)\n# define SSL_CTX_sess_hits(ctx) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_SESS_HIT,0,NULL)\n# define SSL_CTX_sess_cb_hits(ctx) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_SESS_CB_HIT,0,NULL)\n# define SSL_CTX_sess_misses(ctx) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_SESS_MISSES,0,NULL)\n# define SSL_CTX_sess_timeouts(ctx) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_SESS_TIMEOUTS,0,NULL)\n# define SSL_CTX_sess_cache_full(ctx) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_SESS_CACHE_FULL,0,NULL)\n\nvoid SSL_CTX_sess_set_new_cb(SSL_CTX *ctx,\n                             int (*new_session_cb) (struct ssl_st *ssl,\n                                                    SSL_SESSION *sess));\nint (*SSL_CTX_sess_get_new_cb(SSL_CTX *ctx)) (struct ssl_st *ssl,\n                                              SSL_SESSION *sess);\nvoid SSL_CTX_sess_set_remove_cb(SSL_CTX *ctx,\n                                void (*remove_session_cb) (struct ssl_ctx_st\n                                                           *ctx,\n                                                           SSL_SESSION\n                                                           *sess));\nvoid (*SSL_CTX_sess_get_remove_cb(SSL_CTX *ctx)) (struct ssl_ctx_st *ctx,\n                                                  SSL_SESSION *sess);\nvoid SSL_CTX_sess_set_get_cb(SSL_CTX *ctx,\n                             SSL_SESSION *(*get_session_cb) (struct ssl_st\n                                                             *ssl,\n                                                             unsigned char\n                                                             *data, int len,\n                                                             int *copy));\nSSL_SESSION *(*SSL_CTX_sess_get_get_cb(SSL_CTX *ctx)) (struct ssl_st *ssl,\n                                                       unsigned char *Data,\n                                                       int len, int *copy);\nvoid SSL_CTX_set_info_callback(SSL_CTX *ctx,\n                               void (*cb) (const SSL *ssl, int type,\n                                           int val));\nvoid (*SSL_CTX_get_info_callback(SSL_CTX *ctx)) (const SSL *ssl, int type,\n                                                 int val);\nvoid SSL_CTX_set_client_cert_cb(SSL_CTX *ctx,\n                                int (*client_cert_cb) (SSL *ssl, X509 **x509,\n                                                       EVP_PKEY **pkey));\nint (*SSL_CTX_get_client_cert_cb(SSL_CTX *ctx)) (SSL *ssl, X509 **x509,\n                                                 EVP_PKEY **pkey);\n# ifndef OPENSSL_NO_ENGINE\nint SSL_CTX_set_client_cert_engine(SSL_CTX *ctx, ENGINE *e);\n# endif\nvoid SSL_CTX_set_cookie_generate_cb(SSL_CTX *ctx,\n                                    int (*app_gen_cookie_cb) (SSL *ssl,\n                                                              unsigned char\n                                                              *cookie,\n                                                              unsigned int\n                                                              *cookie_len));\nvoid SSL_CTX_set_cookie_verify_cb(SSL_CTX *ctx,\n                                  int (*app_verify_cookie_cb) (SSL *ssl,\n                                                               unsigned char\n                                                               *cookie,\n                                                               unsigned int\n                                                               cookie_len));\n# ifndef OPENSSL_NO_NEXTPROTONEG\nvoid SSL_CTX_set_next_protos_advertised_cb(SSL_CTX *s,\n                                           int (*cb) (SSL *ssl,\n                                                      const unsigned char\n                                                      **out,\n                                                      unsigned int *outlen,\n                                                      void *arg), void *arg);\nvoid SSL_CTX_set_next_proto_select_cb(SSL_CTX *s,\n                                      int (*cb) (SSL *ssl,\n                                                 unsigned char **out,\n                                                 unsigned char *outlen,\n                                                 const unsigned char *in,\n                                                 unsigned int inlen,\n                                                 void *arg), void *arg);\nvoid SSL_get0_next_proto_negotiated(const SSL *s, const unsigned char **data,\n                                    unsigned *len);\n# endif\n\n# ifndef OPENSSL_NO_TLSEXT\nint SSL_select_next_proto(unsigned char **out, unsigned char *outlen,\n                          const unsigned char *in, unsigned int inlen,\n                          const unsigned char *client,\n                          unsigned int client_len);\n# endif\n\n# define OPENSSL_NPN_UNSUPPORTED 0\n# define OPENSSL_NPN_NEGOTIATED  1\n# define OPENSSL_NPN_NO_OVERLAP  2\n\nint SSL_CTX_set_alpn_protos(SSL_CTX *ctx, const unsigned char *protos,\n                            unsigned protos_len);\nint SSL_set_alpn_protos(SSL *ssl, const unsigned char *protos,\n                        unsigned protos_len);\nvoid SSL_CTX_set_alpn_select_cb(SSL_CTX *ctx,\n                                int (*cb) (SSL *ssl,\n                                           const unsigned char **out,\n                                           unsigned char *outlen,\n                                           const unsigned char *in,\n                                           unsigned int inlen,\n                                           void *arg), void *arg);\nvoid SSL_get0_alpn_selected(const SSL *ssl, const unsigned char **data,\n                            unsigned *len);\n\n# ifndef OPENSSL_NO_PSK\n/*\n * the maximum length of the buffer given to callbacks containing the\n * resulting identity/psk\n */\n#  define PSK_MAX_IDENTITY_LEN 128\n#  define PSK_MAX_PSK_LEN 256\nvoid SSL_CTX_set_psk_client_callback(SSL_CTX *ctx,\n                                     unsigned int (*psk_client_callback) (SSL\n                                                                          *ssl,\n                                                                          const\n                                                                          char\n                                                                          *hint,\n                                                                          char\n                                                                          *identity,\n                                                                          unsigned\n                                                                          int\n                                                                          max_identity_len,\n                                                                          unsigned\n                                                                          char\n                                                                          *psk,\n                                                                          unsigned\n                                                                          int\n                                                                          max_psk_len));\nvoid SSL_set_psk_client_callback(SSL *ssl,\n                                 unsigned int (*psk_client_callback) (SSL\n                                                                      *ssl,\n                                                                      const\n                                                                      char\n                                                                      *hint,\n                                                                      char\n                                                                      *identity,\n                                                                      unsigned\n                                                                      int\n                                                                      max_identity_len,\n                                                                      unsigned\n                                                                      char\n                                                                      *psk,\n                                                                      unsigned\n                                                                      int\n                                                                      max_psk_len));\nvoid SSL_CTX_set_psk_server_callback(SSL_CTX *ctx,\n                                     unsigned int (*psk_server_callback) (SSL\n                                                                          *ssl,\n                                                                          const\n                                                                          char\n                                                                          *identity,\n                                                                          unsigned\n                                                                          char\n                                                                          *psk,\n                                                                          unsigned\n                                                                          int\n                                                                          max_psk_len));\nvoid SSL_set_psk_server_callback(SSL *ssl,\n                                 unsigned int (*psk_server_callback) (SSL\n                                                                      *ssl,\n                                                                      const\n                                                                      char\n                                                                      *identity,\n                                                                      unsigned\n                                                                      char\n                                                                      *psk,\n                                                                      unsigned\n                                                                      int\n                                                                      max_psk_len));\nint SSL_CTX_use_psk_identity_hint(SSL_CTX *ctx, const char *identity_hint);\nint SSL_use_psk_identity_hint(SSL *s, const char *identity_hint);\nconst char *SSL_get_psk_identity_hint(const SSL *s);\nconst char *SSL_get_psk_identity(const SSL *s);\n# endif\n\n# ifndef OPENSSL_NO_TLSEXT\n/* Register callbacks to handle custom TLS Extensions for client or server. */\n\nint SSL_CTX_add_client_custom_ext(SSL_CTX *ctx, unsigned int ext_type,\n                                  custom_ext_add_cb add_cb,\n                                  custom_ext_free_cb free_cb,\n                                  void *add_arg,\n                                  custom_ext_parse_cb parse_cb,\n                                  void *parse_arg);\n\nint SSL_CTX_add_server_custom_ext(SSL_CTX *ctx, unsigned int ext_type,\n                                  custom_ext_add_cb add_cb,\n                                  custom_ext_free_cb free_cb,\n                                  void *add_arg,\n                                  custom_ext_parse_cb parse_cb,\n                                  void *parse_arg);\n\nint SSL_extension_supported(unsigned int ext_type);\n\n# endif\n\n# define SSL_NOTHING     1\n# define SSL_WRITING     2\n# define SSL_READING     3\n# define SSL_X509_LOOKUP 4\n\n/* These will only be used when doing non-blocking IO */\n# define SSL_want_nothing(s)     (SSL_want(s) == SSL_NOTHING)\n# define SSL_want_read(s)        (SSL_want(s) == SSL_READING)\n# define SSL_want_write(s)       (SSL_want(s) == SSL_WRITING)\n# define SSL_want_x509_lookup(s) (SSL_want(s) == SSL_X509_LOOKUP)\n\n# define SSL_MAC_FLAG_READ_MAC_STREAM 1\n# define SSL_MAC_FLAG_WRITE_MAC_STREAM 2\n\n# ifndef OPENSSL_NO_SSL_INTERN\n\nstruct ssl_st {\n    /*\n     * protocol version (one of SSL2_VERSION, SSL3_VERSION, TLS1_VERSION,\n     * DTLS1_VERSION)\n     */\n    int version;\n    /* SSL_ST_CONNECT or SSL_ST_ACCEPT */\n    int type;\n    /* SSLv3 */\n    const SSL_METHOD *method;\n    /*\n     * There are 2 BIO's even though they are normally both the same.  This\n     * is so data can be read and written to different handlers\n     */\n#  ifndef OPENSSL_NO_BIO\n    /* used by SSL_read */\n    BIO *rbio;\n    /* used by SSL_write */\n    BIO *wbio;\n    /* used during session-id reuse to concatenate messages */\n    BIO *bbio;\n#  else\n    /* used by SSL_read */\n    char *rbio;\n    /* used by SSL_write */\n    char *wbio;\n    char *bbio;\n#  endif\n    /*\n     * This holds a variable that indicates what we were doing when a 0 or -1\n     * is returned.  This is needed for non-blocking IO so we know what\n     * request needs re-doing when in SSL_accept or SSL_connect\n     */\n    int rwstate;\n    /* true when we are actually in SSL_accept() or SSL_connect() */\n    int in_handshake;\n    int (*handshake_func) (SSL *);\n    /*\n     * Imagine that here's a boolean member \"init\" that is switched as soon\n     * as SSL_set_{accept/connect}_state is called for the first time, so\n     * that \"state\" and \"handshake_func\" are properly initialized.  But as\n     * handshake_func is == 0 until then, we use this test instead of an\n     * \"init\" member.\n     */\n    /* are we the server side? - mostly used by SSL_clear */\n    int server;\n    /*\n     * Generate a new session or reuse an old one.\n     * NB: For servers, the 'new' session may actually be a previously\n     * cached session or even the previous session unless\n     * SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION is set\n     */\n    int new_session;\n    /* don't send shutdown packets */\n    int quiet_shutdown;\n    /* we have shut things down, 0x01 sent, 0x02 for received */\n    int shutdown;\n    /* where we are */\n    int state;\n    /* where we are when reading */\n    int rstate;\n    BUF_MEM *init_buf;          /* buffer used during init */\n    void *init_msg;             /* pointer to handshake message body, set by\n                                 * ssl3_get_message() */\n    int init_num;               /* amount read/written */\n    int init_off;               /* amount read/written */\n    /* used internally to point at a raw packet */\n    unsigned char *packet;\n    unsigned int packet_length;\n    struct ssl2_state_st *s2;   /* SSLv2 variables */\n    struct ssl3_state_st *s3;   /* SSLv3 variables */\n    struct dtls1_state_st *d1;  /* DTLSv1 variables */\n    int read_ahead;             /* Read as many input bytes as possible (for\n                                 * non-blocking reads) */\n    /* callback that allows applications to peek at protocol messages */\n    void (*msg_callback) (int write_p, int version, int content_type,\n                          const void *buf, size_t len, SSL *ssl, void *arg);\n    void *msg_callback_arg;\n    int hit;                    /* reusing a previous session */\n    X509_VERIFY_PARAM *param;\n#  if 0\n    int purpose;                /* Purpose setting */\n    int trust;                  /* Trust setting */\n#  endif\n    /* crypto */\n    STACK_OF(SSL_CIPHER) *cipher_list;\n    STACK_OF(SSL_CIPHER) *cipher_list_by_id;\n    /*\n     * These are the ones being used, the ones in SSL_SESSION are the ones to\n     * be 'copied' into these ones\n     */\n    int mac_flags;\n    EVP_CIPHER_CTX *enc_read_ctx; /* cryptographic state */\n    EVP_MD_CTX *read_hash;      /* used for mac generation */\n#  ifndef OPENSSL_NO_COMP\n    COMP_CTX *expand;           /* uncompress */\n#  else\n    char *expand;\n#  endif\n    EVP_CIPHER_CTX *enc_write_ctx; /* cryptographic state */\n    EVP_MD_CTX *write_hash;     /* used for mac generation */\n#  ifndef OPENSSL_NO_COMP\n    COMP_CTX *compress;         /* compression */\n#  else\n    char *compress;\n#  endif\n    /* session info */\n    /* client cert? */\n    /* This is used to hold the server certificate used */\n    struct cert_st /* CERT */ *cert;\n    /*\n     * the session_id_context is used to ensure sessions are only reused in\n     * the appropriate context\n     */\n    unsigned int sid_ctx_length;\n    unsigned char sid_ctx[SSL_MAX_SID_CTX_LENGTH];\n    /* This can also be in the session once a session is established */\n    SSL_SESSION *session;\n    /* Default generate session ID callback. */\n    GEN_SESSION_CB generate_session_id;\n    /* Used in SSL2 and SSL3 */\n    /*\n     * 0 don't care about verify failure.\n     * 1 fail if verify fails\n     */\n    int verify_mode;\n    /* fail if callback returns 0 */\n    int (*verify_callback) (int ok, X509_STORE_CTX *ctx);\n    /* optional informational callback */\n    void (*info_callback) (const SSL *ssl, int type, int val);\n    /* error bytes to be written */\n    int error;\n    /* actual code */\n    int error_code;\n#  ifndef OPENSSL_NO_KRB5\n    /* Kerberos 5 context */\n    KSSL_CTX *kssl_ctx;\n#  endif                        /* OPENSSL_NO_KRB5 */\n#  ifndef OPENSSL_NO_PSK\n    unsigned int (*psk_client_callback) (SSL *ssl, const char *hint,\n                                         char *identity,\n                                         unsigned int max_identity_len,\n                                         unsigned char *psk,\n                                         unsigned int max_psk_len);\n    unsigned int (*psk_server_callback) (SSL *ssl, const char *identity,\n                                         unsigned char *psk,\n                                         unsigned int max_psk_len);\n#  endif\n    SSL_CTX *ctx;\n    /*\n     * set this flag to 1 and a sleep(1) is put into all SSL_read() and\n     * SSL_write() calls, good for nbio debuging :-)\n     */\n    int debug;\n    /* extra application data */\n    long verify_result;\n    CRYPTO_EX_DATA ex_data;\n    /* for server side, keep the list of CA_dn we can use */\n    STACK_OF(X509_NAME) *client_CA;\n    int references;\n    /* protocol behaviour */\n    unsigned long options;\n    /* API behaviour */\n    unsigned long mode;\n    long max_cert_list;\n    int first_packet;\n    /* what was passed, used for SSLv3/TLS rollback check */\n    int client_version;\n    unsigned int max_send_fragment;\n#  ifndef OPENSSL_NO_TLSEXT\n    /* TLS extension debug callback */\n    void (*tlsext_debug_cb) (SSL *s, int client_server, int type,\n                             unsigned char *data, int len, void *arg);\n    void *tlsext_debug_arg;\n    char *tlsext_hostname;\n    /*-\n     * no further mod of servername\n     * 0 : call the servername extension callback.\n     * 1 : prepare 2, allow last ack just after in server callback.\n     * 2 : don't call servername callback, no ack in server hello\n     */\n    int servername_done;\n    /* certificate status request info */\n    /* Status type or -1 if no status type */\n    int tlsext_status_type;\n    /* Expect OCSP CertificateStatus message */\n    int tlsext_status_expected;\n    /* OCSP status request only */\n    STACK_OF(OCSP_RESPID) *tlsext_ocsp_ids;\n    X509_EXTENSIONS *tlsext_ocsp_exts;\n    /* OCSP response received or to be sent */\n    unsigned char *tlsext_ocsp_resp;\n    int tlsext_ocsp_resplen;\n    /* RFC4507 session ticket expected to be received or sent */\n    int tlsext_ticket_expected;\n#   ifndef OPENSSL_NO_EC\n    size_t tlsext_ecpointformatlist_length;\n    /* our list */\n    unsigned char *tlsext_ecpointformatlist;\n    size_t tlsext_ellipticcurvelist_length;\n    /* our list */\n    unsigned char *tlsext_ellipticcurvelist;\n#   endif                       /* OPENSSL_NO_EC */\n    /*\n     * draft-rescorla-tls-opaque-prf-input-00.txt information to be used for\n     * handshakes\n     */\n    void *tlsext_opaque_prf_input;\n    size_t tlsext_opaque_prf_input_len;\n    /* TLS Session Ticket extension override */\n    TLS_SESSION_TICKET_EXT *tlsext_session_ticket;\n    /* TLS Session Ticket extension callback */\n    tls_session_ticket_ext_cb_fn tls_session_ticket_ext_cb;\n    void *tls_session_ticket_ext_cb_arg;\n    /* TLS pre-shared secret session resumption */\n    tls_session_secret_cb_fn tls_session_secret_cb;\n    void *tls_session_secret_cb_arg;\n    SSL_CTX *initial_ctx;       /* initial ctx, used to store sessions */\n#   ifndef OPENSSL_NO_NEXTPROTONEG\n    /*\n     * Next protocol negotiation. For the client, this is the protocol that\n     * we sent in NextProtocol and is set when handling ServerHello\n     * extensions. For a server, this is the client's selected_protocol from\n     * NextProtocol and is set when handling the NextProtocol message, before\n     * the Finished message.\n     */\n    unsigned char *next_proto_negotiated;\n    unsigned char next_proto_negotiated_len;\n#   endif\n#   define session_ctx initial_ctx\n    /* What we'll do */\n    STACK_OF(SRTP_PROTECTION_PROFILE) *srtp_profiles;\n    /* What's been chosen */\n    SRTP_PROTECTION_PROFILE *srtp_profile;\n        /*-\n         * Is use of the Heartbeat extension negotiated?\n         * 0: disabled\n         * 1: enabled\n         * 2: enabled, but not allowed to send Requests\n         */\n    unsigned int tlsext_heartbeat;\n    /* Indicates if a HeartbeatRequest is in flight */\n    unsigned int tlsext_hb_pending;\n    /* HeartbeatRequest sequence number */\n    unsigned int tlsext_hb_seq;\n#  else\n#   define session_ctx ctx\n#  endif                        /* OPENSSL_NO_TLSEXT */\n    /*-\n     * 1 if we are renegotiating.\n     * 2 if we are a server and are inside a handshake\n     * (i.e. not just sending a HelloRequest)\n     */\n    int renegotiate;\n#  ifndef OPENSSL_NO_SRP\n    /* ctx for SRP authentication */\n    SRP_CTX srp_ctx;\n#  endif\n#  ifndef OPENSSL_NO_TLSEXT\n    /*\n     * For a client, this contains the list of supported protocols in wire\n     * format.\n     */\n    unsigned char *alpn_client_proto_list;\n    unsigned alpn_client_proto_list_len;\n#  endif                        /* OPENSSL_NO_TLSEXT */\n};\n\n# endif\n\n#ifdef __cplusplus\n}\n#endif\n\n# include <openssl/ssl2.h>\n# include <openssl/ssl3.h>\n# include <openssl/tls1.h>      /* This is mostly sslv3 with a few tweaks */\n# include <openssl/dtls1.h>     /* Datagram TLS */\n# include <openssl/ssl23.h>\n# include <openssl/srtp.h>      /* Support for the use_srtp extension */\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n/* compatibility */\n# define SSL_set_app_data(s,arg)         (SSL_set_ex_data(s,0,(char *)arg))\n# define SSL_get_app_data(s)             (SSL_get_ex_data(s,0))\n# define SSL_SESSION_set_app_data(s,a)   (SSL_SESSION_set_ex_data(s,0,(char *)a))\n# define SSL_SESSION_get_app_data(s)     (SSL_SESSION_get_ex_data(s,0))\n# define SSL_CTX_get_app_data(ctx)       (SSL_CTX_get_ex_data(ctx,0))\n# define SSL_CTX_set_app_data(ctx,arg)   (SSL_CTX_set_ex_data(ctx,0,(char *)arg))\n\n/*\n * The following are the possible values for ssl->state are are used to\n * indicate where we are up to in the SSL connection establishment. The\n * macros that follow are about the only things you should need to use and\n * even then, only when using non-blocking IO. It can also be useful to work\n * out where you were when the connection failed\n */\n\n# define SSL_ST_CONNECT                  0x1000\n# define SSL_ST_ACCEPT                   0x2000\n# define SSL_ST_MASK                     0x0FFF\n# define SSL_ST_INIT                     (SSL_ST_CONNECT|SSL_ST_ACCEPT)\n# define SSL_ST_BEFORE                   0x4000\n# define SSL_ST_OK                       0x03\n# define SSL_ST_RENEGOTIATE              (0x04|SSL_ST_INIT)\n# define SSL_ST_ERR                      0x05\n\n# define SSL_CB_LOOP                     0x01\n# define SSL_CB_EXIT                     0x02\n# define SSL_CB_READ                     0x04\n# define SSL_CB_WRITE                    0x08\n# define SSL_CB_ALERT                    0x4000/* used in callback */\n# define SSL_CB_READ_ALERT               (SSL_CB_ALERT|SSL_CB_READ)\n# define SSL_CB_WRITE_ALERT              (SSL_CB_ALERT|SSL_CB_WRITE)\n# define SSL_CB_ACCEPT_LOOP              (SSL_ST_ACCEPT|SSL_CB_LOOP)\n# define SSL_CB_ACCEPT_EXIT              (SSL_ST_ACCEPT|SSL_CB_EXIT)\n# define SSL_CB_CONNECT_LOOP             (SSL_ST_CONNECT|SSL_CB_LOOP)\n# define SSL_CB_CONNECT_EXIT             (SSL_ST_CONNECT|SSL_CB_EXIT)\n# define SSL_CB_HANDSHAKE_START          0x10\n# define SSL_CB_HANDSHAKE_DONE           0x20\n\n/* Is the SSL_connection established? */\n# define SSL_get_state(a)                SSL_state(a)\n# define SSL_is_init_finished(a)         (SSL_state(a) == SSL_ST_OK)\n# define SSL_in_init(a)                  (SSL_state(a)&SSL_ST_INIT)\n# define SSL_in_before(a)                (SSL_state(a)&SSL_ST_BEFORE)\n# define SSL_in_connect_init(a)          (SSL_state(a)&SSL_ST_CONNECT)\n# define SSL_in_accept_init(a)           (SSL_state(a)&SSL_ST_ACCEPT)\n\n/*\n * The following 2 states are kept in ssl->rstate when reads fail, you should\n * not need these\n */\n# define SSL_ST_READ_HEADER                      0xF0\n# define SSL_ST_READ_BODY                        0xF1\n# define SSL_ST_READ_DONE                        0xF2\n\n/*-\n * Obtain latest Finished message\n *   -- that we sent (SSL_get_finished)\n *   -- that we expected from peer (SSL_get_peer_finished).\n * Returns length (0 == no Finished so far), copies up to 'count' bytes.\n */\nsize_t SSL_get_finished(const SSL *s, void *buf, size_t count);\nsize_t SSL_get_peer_finished(const SSL *s, void *buf, size_t count);\n\n/*\n * use either SSL_VERIFY_NONE or SSL_VERIFY_PEER, the last 2 options are\n * 'ored' with SSL_VERIFY_PEER if they are desired\n */\n# define SSL_VERIFY_NONE                 0x00\n# define SSL_VERIFY_PEER                 0x01\n# define SSL_VERIFY_FAIL_IF_NO_PEER_CERT 0x02\n# define SSL_VERIFY_CLIENT_ONCE          0x04\n\n# define OpenSSL_add_ssl_algorithms()    SSL_library_init()\n# define SSLeay_add_ssl_algorithms()     SSL_library_init()\n\n/* this is for backward compatibility */\n# if 0                          /* NEW_SSLEAY */\n#  define SSL_CTX_set_default_verify(a,b,c) SSL_CTX_set_verify(a,b,c)\n#  define SSL_set_pref_cipher(c,n)        SSL_set_cipher_list(c,n)\n#  define SSL_add_session(a,b)            SSL_CTX_add_session((a),(b))\n#  define SSL_remove_session(a,b)         SSL_CTX_remove_session((a),(b))\n#  define SSL_flush_sessions(a,b)         SSL_CTX_flush_sessions((a),(b))\n# endif\n/* More backward compatibility */\n# define SSL_get_cipher(s) \\\n                SSL_CIPHER_get_name(SSL_get_current_cipher(s))\n# define SSL_get_cipher_bits(s,np) \\\n                SSL_CIPHER_get_bits(SSL_get_current_cipher(s),np)\n# define SSL_get_cipher_version(s) \\\n                SSL_CIPHER_get_version(SSL_get_current_cipher(s))\n# define SSL_get_cipher_name(s) \\\n                SSL_CIPHER_get_name(SSL_get_current_cipher(s))\n# define SSL_get_time(a)         SSL_SESSION_get_time(a)\n# define SSL_set_time(a,b)       SSL_SESSION_set_time((a),(b))\n# define SSL_get_timeout(a)      SSL_SESSION_get_timeout(a)\n# define SSL_set_timeout(a,b)    SSL_SESSION_set_timeout((a),(b))\n\n# define d2i_SSL_SESSION_bio(bp,s_id) ASN1_d2i_bio_of(SSL_SESSION,SSL_SESSION_new,d2i_SSL_SESSION,bp,s_id)\n# define i2d_SSL_SESSION_bio(bp,s_id) ASN1_i2d_bio_of(SSL_SESSION,i2d_SSL_SESSION,bp,s_id)\n\nDECLARE_PEM_rw(SSL_SESSION, SSL_SESSION)\n# define SSL_AD_REASON_OFFSET            1000/* offset to get SSL_R_... value\n                                              * from SSL_AD_... */\n/* These alert types are for SSLv3 and TLSv1 */\n# define SSL_AD_CLOSE_NOTIFY             SSL3_AD_CLOSE_NOTIFY\n/* fatal */\n# define SSL_AD_UNEXPECTED_MESSAGE       SSL3_AD_UNEXPECTED_MESSAGE\n/* fatal */\n# define SSL_AD_BAD_RECORD_MAC           SSL3_AD_BAD_RECORD_MAC\n# define SSL_AD_DECRYPTION_FAILED        TLS1_AD_DECRYPTION_FAILED\n# define SSL_AD_RECORD_OVERFLOW          TLS1_AD_RECORD_OVERFLOW\n/* fatal */\n# define SSL_AD_DECOMPRESSION_FAILURE    SSL3_AD_DECOMPRESSION_FAILURE\n/* fatal */\n# define SSL_AD_HANDSHAKE_FAILURE        SSL3_AD_HANDSHAKE_FAILURE\n/* Not for TLS */\n# define SSL_AD_NO_CERTIFICATE           SSL3_AD_NO_CERTIFICATE\n# define SSL_AD_BAD_CERTIFICATE          SSL3_AD_BAD_CERTIFICATE\n# define SSL_AD_UNSUPPORTED_CERTIFICATE  SSL3_AD_UNSUPPORTED_CERTIFICATE\n# define SSL_AD_CERTIFICATE_REVOKED      SSL3_AD_CERTIFICATE_REVOKED\n# define SSL_AD_CERTIFICATE_EXPIRED      SSL3_AD_CERTIFICATE_EXPIRED\n# define SSL_AD_CERTIFICATE_UNKNOWN      SSL3_AD_CERTIFICATE_UNKNOWN\n/* fatal */\n# define SSL_AD_ILLEGAL_PARAMETER        SSL3_AD_ILLEGAL_PARAMETER\n/* fatal */\n# define SSL_AD_UNKNOWN_CA               TLS1_AD_UNKNOWN_CA\n/* fatal */\n# define SSL_AD_ACCESS_DENIED            TLS1_AD_ACCESS_DENIED\n/* fatal */\n# define SSL_AD_DECODE_ERROR             TLS1_AD_DECODE_ERROR\n# define SSL_AD_DECRYPT_ERROR            TLS1_AD_DECRYPT_ERROR\n/* fatal */\n# define SSL_AD_EXPORT_RESTRICTION       TLS1_AD_EXPORT_RESTRICTION\n/* fatal */\n# define SSL_AD_PROTOCOL_VERSION         TLS1_AD_PROTOCOL_VERSION\n/* fatal */\n# define SSL_AD_INSUFFICIENT_SECURITY    TLS1_AD_INSUFFICIENT_SECURITY\n/* fatal */\n# define SSL_AD_INTERNAL_ERROR           TLS1_AD_INTERNAL_ERROR\n# define SSL_AD_USER_CANCELLED           TLS1_AD_USER_CANCELLED\n# define SSL_AD_NO_RENEGOTIATION         TLS1_AD_NO_RENEGOTIATION\n# define SSL_AD_UNSUPPORTED_EXTENSION    TLS1_AD_UNSUPPORTED_EXTENSION\n# define SSL_AD_CERTIFICATE_UNOBTAINABLE TLS1_AD_CERTIFICATE_UNOBTAINABLE\n# define SSL_AD_UNRECOGNIZED_NAME        TLS1_AD_UNRECOGNIZED_NAME\n# define SSL_AD_BAD_CERTIFICATE_STATUS_RESPONSE TLS1_AD_BAD_CERTIFICATE_STATUS_RESPONSE\n# define SSL_AD_BAD_CERTIFICATE_HASH_VALUE TLS1_AD_BAD_CERTIFICATE_HASH_VALUE\n/* fatal */\n# define SSL_AD_UNKNOWN_PSK_IDENTITY     TLS1_AD_UNKNOWN_PSK_IDENTITY\n/* fatal */\n# define SSL_AD_INAPPROPRIATE_FALLBACK   TLS1_AD_INAPPROPRIATE_FALLBACK\n# define SSL_ERROR_NONE                  0\n# define SSL_ERROR_SSL                   1\n# define SSL_ERROR_WANT_READ             2\n# define SSL_ERROR_WANT_WRITE            3\n# define SSL_ERROR_WANT_X509_LOOKUP      4\n# define SSL_ERROR_SYSCALL               5/* look at error stack/return\n                                           * value/errno */\n# define SSL_ERROR_ZERO_RETURN           6\n# define SSL_ERROR_WANT_CONNECT          7\n# define SSL_ERROR_WANT_ACCEPT           8\n# define SSL_CTRL_NEED_TMP_RSA                   1\n# define SSL_CTRL_SET_TMP_RSA                    2\n# define SSL_CTRL_SET_TMP_DH                     3\n# define SSL_CTRL_SET_TMP_ECDH                   4\n# define SSL_CTRL_SET_TMP_RSA_CB                 5\n# define SSL_CTRL_SET_TMP_DH_CB                  6\n# define SSL_CTRL_SET_TMP_ECDH_CB                7\n# define SSL_CTRL_GET_SESSION_REUSED             8\n# define SSL_CTRL_GET_CLIENT_CERT_REQUEST        9\n# define SSL_CTRL_GET_NUM_RENEGOTIATIONS         10\n# define SSL_CTRL_CLEAR_NUM_RENEGOTIATIONS       11\n# define SSL_CTRL_GET_TOTAL_RENEGOTIATIONS       12\n# define SSL_CTRL_GET_FLAGS                      13\n# define SSL_CTRL_EXTRA_CHAIN_CERT               14\n# define SSL_CTRL_SET_MSG_CALLBACK               15\n# define SSL_CTRL_SET_MSG_CALLBACK_ARG           16\n/* only applies to datagram connections */\n# define SSL_CTRL_SET_MTU                17\n/* Stats */\n# define SSL_CTRL_SESS_NUMBER                    20\n# define SSL_CTRL_SESS_CONNECT                   21\n# define SSL_CTRL_SESS_CONNECT_GOOD              22\n# define SSL_CTRL_SESS_CONNECT_RENEGOTIATE       23\n# define SSL_CTRL_SESS_ACCEPT                    24\n# define SSL_CTRL_SESS_ACCEPT_GOOD               25\n# define SSL_CTRL_SESS_ACCEPT_RENEGOTIATE        26\n# define SSL_CTRL_SESS_HIT                       27\n# define SSL_CTRL_SESS_CB_HIT                    28\n# define SSL_CTRL_SESS_MISSES                    29\n# define SSL_CTRL_SESS_TIMEOUTS                  30\n# define SSL_CTRL_SESS_CACHE_FULL                31\n# define SSL_CTRL_OPTIONS                        32\n# define SSL_CTRL_MODE                           33\n# define SSL_CTRL_GET_READ_AHEAD                 40\n# define SSL_CTRL_SET_READ_AHEAD                 41\n# define SSL_CTRL_SET_SESS_CACHE_SIZE            42\n# define SSL_CTRL_GET_SESS_CACHE_SIZE            43\n# define SSL_CTRL_SET_SESS_CACHE_MODE            44\n# define SSL_CTRL_GET_SESS_CACHE_MODE            45\n# define SSL_CTRL_GET_MAX_CERT_LIST              50\n# define SSL_CTRL_SET_MAX_CERT_LIST              51\n# define SSL_CTRL_SET_MAX_SEND_FRAGMENT          52\n/* see tls1.h for macros based on these */\n# ifndef OPENSSL_NO_TLSEXT\n#  define SSL_CTRL_SET_TLSEXT_SERVERNAME_CB       53\n#  define SSL_CTRL_SET_TLSEXT_SERVERNAME_ARG      54\n#  define SSL_CTRL_SET_TLSEXT_HOSTNAME            55\n#  define SSL_CTRL_SET_TLSEXT_DEBUG_CB            56\n#  define SSL_CTRL_SET_TLSEXT_DEBUG_ARG           57\n#  define SSL_CTRL_GET_TLSEXT_TICKET_KEYS         58\n#  define SSL_CTRL_SET_TLSEXT_TICKET_KEYS         59\n#  define SSL_CTRL_SET_TLSEXT_OPAQUE_PRF_INPUT    60\n#  define SSL_CTRL_SET_TLSEXT_OPAQUE_PRF_INPUT_CB 61\n#  define SSL_CTRL_SET_TLSEXT_OPAQUE_PRF_INPUT_CB_ARG 62\n#  define SSL_CTRL_SET_TLSEXT_STATUS_REQ_CB       63\n#  define SSL_CTRL_SET_TLSEXT_STATUS_REQ_CB_ARG   64\n#  define SSL_CTRL_SET_TLSEXT_STATUS_REQ_TYPE     65\n#  define SSL_CTRL_GET_TLSEXT_STATUS_REQ_EXTS     66\n#  define SSL_CTRL_SET_TLSEXT_STATUS_REQ_EXTS     67\n#  define SSL_CTRL_GET_TLSEXT_STATUS_REQ_IDS      68\n#  define SSL_CTRL_SET_TLSEXT_STATUS_REQ_IDS      69\n#  define SSL_CTRL_GET_TLSEXT_STATUS_REQ_OCSP_RESP        70\n#  define SSL_CTRL_SET_TLSEXT_STATUS_REQ_OCSP_RESP        71\n#  define SSL_CTRL_SET_TLSEXT_TICKET_KEY_CB       72\n#  define SSL_CTRL_SET_TLS_EXT_SRP_USERNAME_CB    75\n#  define SSL_CTRL_SET_SRP_VERIFY_PARAM_CB                76\n#  define SSL_CTRL_SET_SRP_GIVE_CLIENT_PWD_CB             77\n#  define SSL_CTRL_SET_SRP_ARG            78\n#  define SSL_CTRL_SET_TLS_EXT_SRP_USERNAME               79\n#  define SSL_CTRL_SET_TLS_EXT_SRP_STRENGTH               80\n#  define SSL_CTRL_SET_TLS_EXT_SRP_PASSWORD               81\n#  ifndef OPENSSL_NO_HEARTBEATS\n#   define SSL_CTRL_TLS_EXT_SEND_HEARTBEAT                         85\n#   define SSL_CTRL_GET_TLS_EXT_HEARTBEAT_PENDING          86\n#   define SSL_CTRL_SET_TLS_EXT_HEARTBEAT_NO_REQUESTS      87\n#  endif\n# endif                         /* OPENSSL_NO_TLSEXT */\n# define DTLS_CTRL_GET_TIMEOUT           73\n# define DTLS_CTRL_HANDLE_TIMEOUT        74\n# define DTLS_CTRL_LISTEN                        75\n# define SSL_CTRL_GET_RI_SUPPORT                 76\n# define SSL_CTRL_CLEAR_OPTIONS                  77\n# define SSL_CTRL_CLEAR_MODE                     78\n# define SSL_CTRL_GET_EXTRA_CHAIN_CERTS          82\n# define SSL_CTRL_CLEAR_EXTRA_CHAIN_CERTS        83\n# define SSL_CTRL_CHAIN                          88\n# define SSL_CTRL_CHAIN_CERT                     89\n# define SSL_CTRL_GET_CURVES                     90\n# define SSL_CTRL_SET_CURVES                     91\n# define SSL_CTRL_SET_CURVES_LIST                92\n# define SSL_CTRL_GET_SHARED_CURVE               93\n# define SSL_CTRL_SET_ECDH_AUTO                  94\n# define SSL_CTRL_SET_SIGALGS                    97\n# define SSL_CTRL_SET_SIGALGS_LIST               98\n# define SSL_CTRL_CERT_FLAGS                     99\n# define SSL_CTRL_CLEAR_CERT_FLAGS               100\n# define SSL_CTRL_SET_CLIENT_SIGALGS             101\n# define SSL_CTRL_SET_CLIENT_SIGALGS_LIST        102\n# define SSL_CTRL_GET_CLIENT_CERT_TYPES          103\n# define SSL_CTRL_SET_CLIENT_CERT_TYPES          104\n# define SSL_CTRL_BUILD_CERT_CHAIN               105\n# define SSL_CTRL_SET_VERIFY_CERT_STORE          106\n# define SSL_CTRL_SET_CHAIN_CERT_STORE           107\n# define SSL_CTRL_GET_PEER_SIGNATURE_NID         108\n# define SSL_CTRL_GET_SERVER_TMP_KEY             109\n# define SSL_CTRL_GET_RAW_CIPHERLIST             110\n# define SSL_CTRL_GET_EC_POINT_FORMATS           111\n# define SSL_CTRL_GET_CHAIN_CERTS                115\n# define SSL_CTRL_SELECT_CURRENT_CERT            116\n# define SSL_CTRL_SET_CURRENT_CERT               117\n# define SSL_CTRL_CHECK_PROTO_VERSION            119\n# define DTLS_CTRL_SET_LINK_MTU                  120\n# define DTLS_CTRL_GET_LINK_MIN_MTU              121\n# define SSL_CERT_SET_FIRST                      1\n# define SSL_CERT_SET_NEXT                       2\n# define SSL_CERT_SET_SERVER                     3\n# define DTLSv1_get_timeout(ssl, arg) \\\n        SSL_ctrl(ssl,DTLS_CTRL_GET_TIMEOUT,0, (void *)arg)\n# define DTLSv1_handle_timeout(ssl) \\\n        SSL_ctrl(ssl,DTLS_CTRL_HANDLE_TIMEOUT,0, NULL)\n# define DTLSv1_listen(ssl, peer) \\\n        SSL_ctrl(ssl,DTLS_CTRL_LISTEN,0, (void *)peer)\n# define SSL_session_reused(ssl) \\\n        SSL_ctrl((ssl),SSL_CTRL_GET_SESSION_REUSED,0,NULL)\n# define SSL_num_renegotiations(ssl) \\\n        SSL_ctrl((ssl),SSL_CTRL_GET_NUM_RENEGOTIATIONS,0,NULL)\n# define SSL_clear_num_renegotiations(ssl) \\\n        SSL_ctrl((ssl),SSL_CTRL_CLEAR_NUM_RENEGOTIATIONS,0,NULL)\n# define SSL_total_renegotiations(ssl) \\\n        SSL_ctrl((ssl),SSL_CTRL_GET_TOTAL_RENEGOTIATIONS,0,NULL)\n# define SSL_CTX_need_tmp_RSA(ctx) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_NEED_TMP_RSA,0,NULL)\n# define SSL_CTX_set_tmp_rsa(ctx,rsa) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_SET_TMP_RSA,0,(char *)rsa)\n# define SSL_CTX_set_tmp_dh(ctx,dh) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_SET_TMP_DH,0,(char *)dh)\n# define SSL_CTX_set_tmp_ecdh(ctx,ecdh) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_SET_TMP_ECDH,0,(char *)ecdh)\n# define SSL_need_tmp_RSA(ssl) \\\n        SSL_ctrl(ssl,SSL_CTRL_NEED_TMP_RSA,0,NULL)\n# define SSL_set_tmp_rsa(ssl,rsa) \\\n        SSL_ctrl(ssl,SSL_CTRL_SET_TMP_RSA,0,(char *)rsa)\n# define SSL_set_tmp_dh(ssl,dh) \\\n        SSL_ctrl(ssl,SSL_CTRL_SET_TMP_DH,0,(char *)dh)\n# define SSL_set_tmp_ecdh(ssl,ecdh) \\\n        SSL_ctrl(ssl,SSL_CTRL_SET_TMP_ECDH,0,(char *)ecdh)\n# define SSL_CTX_add_extra_chain_cert(ctx,x509) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_EXTRA_CHAIN_CERT,0,(char *)x509)\n# define SSL_CTX_get_extra_chain_certs(ctx,px509) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_GET_EXTRA_CHAIN_CERTS,0,px509)\n# define SSL_CTX_get_extra_chain_certs_only(ctx,px509) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_GET_EXTRA_CHAIN_CERTS,1,px509)\n# define SSL_CTX_clear_extra_chain_certs(ctx) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_CLEAR_EXTRA_CHAIN_CERTS,0,NULL)\n# define SSL_CTX_set0_chain(ctx,sk) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_CHAIN,0,(char *)sk)\n# define SSL_CTX_set1_chain(ctx,sk) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_CHAIN,1,(char *)sk)\n# define SSL_CTX_add0_chain_cert(ctx,x509) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_CHAIN_CERT,0,(char *)x509)\n# define SSL_CTX_add1_chain_cert(ctx,x509) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_CHAIN_CERT,1,(char *)x509)\n# define SSL_CTX_get0_chain_certs(ctx,px509) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_GET_CHAIN_CERTS,0,px509)\n# define SSL_CTX_clear_chain_certs(ctx) \\\n        SSL_CTX_set0_chain(ctx,NULL)\n# define SSL_CTX_build_cert_chain(ctx, flags) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_BUILD_CERT_CHAIN, flags, NULL)\n# define SSL_CTX_select_current_cert(ctx,x509) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_SELECT_CURRENT_CERT,0,(char *)x509)\n# define SSL_CTX_set_current_cert(ctx, op) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_SET_CURRENT_CERT, op, NULL)\n# define SSL_CTX_set0_verify_cert_store(ctx,st) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_SET_VERIFY_CERT_STORE,0,(char *)st)\n# define SSL_CTX_set1_verify_cert_store(ctx,st) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_SET_VERIFY_CERT_STORE,1,(char *)st)\n# define SSL_CTX_set0_chain_cert_store(ctx,st) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_SET_CHAIN_CERT_STORE,0,(char *)st)\n# define SSL_CTX_set1_chain_cert_store(ctx,st) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_SET_CHAIN_CERT_STORE,1,(char *)st)\n# define SSL_set0_chain(ctx,sk) \\\n        SSL_ctrl(ctx,SSL_CTRL_CHAIN,0,(char *)sk)\n# define SSL_set1_chain(ctx,sk) \\\n        SSL_ctrl(ctx,SSL_CTRL_CHAIN,1,(char *)sk)\n# define SSL_add0_chain_cert(ctx,x509) \\\n        SSL_ctrl(ctx,SSL_CTRL_CHAIN_CERT,0,(char *)x509)\n# define SSL_add1_chain_cert(ctx,x509) \\\n        SSL_ctrl(ctx,SSL_CTRL_CHAIN_CERT,1,(char *)x509)\n# define SSL_get0_chain_certs(ctx,px509) \\\n        SSL_ctrl(ctx,SSL_CTRL_GET_CHAIN_CERTS,0,px509)\n# define SSL_clear_chain_certs(ctx) \\\n        SSL_set0_chain(ctx,NULL)\n# define SSL_build_cert_chain(s, flags) \\\n        SSL_ctrl(s,SSL_CTRL_BUILD_CERT_CHAIN, flags, NULL)\n# define SSL_select_current_cert(ctx,x509) \\\n        SSL_ctrl(ctx,SSL_CTRL_SELECT_CURRENT_CERT,0,(char *)x509)\n# define SSL_set_current_cert(ctx,op) \\\n        SSL_ctrl(ctx,SSL_CTRL_SET_CURRENT_CERT, op, NULL)\n# define SSL_set0_verify_cert_store(s,st) \\\n        SSL_ctrl(s,SSL_CTRL_SET_VERIFY_CERT_STORE,0,(char *)st)\n# define SSL_set1_verify_cert_store(s,st) \\\n        SSL_ctrl(s,SSL_CTRL_SET_VERIFY_CERT_STORE,1,(char *)st)\n# define SSL_set0_chain_cert_store(s,st) \\\n        SSL_ctrl(s,SSL_CTRL_SET_CHAIN_CERT_STORE,0,(char *)st)\n# define SSL_set1_chain_cert_store(s,st) \\\n        SSL_ctrl(s,SSL_CTRL_SET_CHAIN_CERT_STORE,1,(char *)st)\n# define SSL_get1_curves(ctx, s) \\\n        SSL_ctrl(ctx,SSL_CTRL_GET_CURVES,0,(char *)s)\n# define SSL_CTX_set1_curves(ctx, clist, clistlen) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_SET_CURVES,clistlen,(char *)clist)\n# define SSL_CTX_set1_curves_list(ctx, s) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_SET_CURVES_LIST,0,(char *)s)\n# define SSL_set1_curves(ctx, clist, clistlen) \\\n        SSL_ctrl(ctx,SSL_CTRL_SET_CURVES,clistlen,(char *)clist)\n# define SSL_set1_curves_list(ctx, s) \\\n        SSL_ctrl(ctx,SSL_CTRL_SET_CURVES_LIST,0,(char *)s)\n# define SSL_get_shared_curve(s, n) \\\n        SSL_ctrl(s,SSL_CTRL_GET_SHARED_CURVE,n,NULL)\n# define SSL_CTX_set_ecdh_auto(ctx, onoff) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_SET_ECDH_AUTO,onoff,NULL)\n# define SSL_set_ecdh_auto(s, onoff) \\\n        SSL_ctrl(s,SSL_CTRL_SET_ECDH_AUTO,onoff,NULL)\n# define SSL_CTX_set1_sigalgs(ctx, slist, slistlen) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_SET_SIGALGS,slistlen,(int *)slist)\n# define SSL_CTX_set1_sigalgs_list(ctx, s) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_SET_SIGALGS_LIST,0,(char *)s)\n# define SSL_set1_sigalgs(ctx, slist, slistlen) \\\n        SSL_ctrl(ctx,SSL_CTRL_SET_SIGALGS,slistlen,(int *)slist)\n# define SSL_set1_sigalgs_list(ctx, s) \\\n        SSL_ctrl(ctx,SSL_CTRL_SET_SIGALGS_LIST,0,(char *)s)\n# define SSL_CTX_set1_client_sigalgs(ctx, slist, slistlen) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_SET_CLIENT_SIGALGS,slistlen,(int *)slist)\n# define SSL_CTX_set1_client_sigalgs_list(ctx, s) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_SET_CLIENT_SIGALGS_LIST,0,(char *)s)\n# define SSL_set1_client_sigalgs(ctx, slist, slistlen) \\\n        SSL_ctrl(ctx,SSL_CTRL_SET_CLIENT_SIGALGS,clistlen,(int *)slist)\n# define SSL_set1_client_sigalgs_list(ctx, s) \\\n        SSL_ctrl(ctx,SSL_CTRL_SET_CLIENT_SIGALGS_LIST,0,(char *)s)\n# define SSL_get0_certificate_types(s, clist) \\\n        SSL_ctrl(s, SSL_CTRL_GET_CLIENT_CERT_TYPES, 0, (char *)clist)\n# define SSL_CTX_set1_client_certificate_types(ctx, clist, clistlen) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_SET_CLIENT_CERT_TYPES,clistlen,(char *)clist)\n# define SSL_set1_client_certificate_types(s, clist, clistlen) \\\n        SSL_ctrl(s,SSL_CTRL_SET_CLIENT_CERT_TYPES,clistlen,(char *)clist)\n# define SSL_get_peer_signature_nid(s, pn) \\\n        SSL_ctrl(s,SSL_CTRL_GET_PEER_SIGNATURE_NID,0,pn)\n# define SSL_get_server_tmp_key(s, pk) \\\n        SSL_ctrl(s,SSL_CTRL_GET_SERVER_TMP_KEY,0,pk)\n# define SSL_get0_raw_cipherlist(s, plst) \\\n        SSL_ctrl(s,SSL_CTRL_GET_RAW_CIPHERLIST,0,(char *)plst)\n# define SSL_get0_ec_point_formats(s, plst) \\\n        SSL_ctrl(s,SSL_CTRL_GET_EC_POINT_FORMATS,0,(char *)plst)\n# ifndef OPENSSL_NO_BIO\nBIO_METHOD *BIO_f_ssl(void);\nBIO *BIO_new_ssl(SSL_CTX *ctx, int client);\nBIO *BIO_new_ssl_connect(SSL_CTX *ctx);\nBIO *BIO_new_buffer_ssl_connect(SSL_CTX *ctx);\nint BIO_ssl_copy_session_id(BIO *to, BIO *from);\nvoid BIO_ssl_shutdown(BIO *ssl_bio);\n\n# endif\n\nint SSL_CTX_set_cipher_list(SSL_CTX *, const char *str);\nSSL_CTX *SSL_CTX_new(const SSL_METHOD *meth);\nvoid SSL_CTX_free(SSL_CTX *);\nlong SSL_CTX_set_timeout(SSL_CTX *ctx, long t);\nlong SSL_CTX_get_timeout(const SSL_CTX *ctx);\nX509_STORE *SSL_CTX_get_cert_store(const SSL_CTX *);\nvoid SSL_CTX_set_cert_store(SSL_CTX *, X509_STORE *);\nint SSL_want(const SSL *s);\nint SSL_clear(SSL *s);\n\nvoid SSL_CTX_flush_sessions(SSL_CTX *ctx, long tm);\n\nconst SSL_CIPHER *SSL_get_current_cipher(const SSL *s);\nint SSL_CIPHER_get_bits(const SSL_CIPHER *c, int *alg_bits);\nchar *SSL_CIPHER_get_version(const SSL_CIPHER *c);\nconst char *SSL_CIPHER_get_name(const SSL_CIPHER *c);\nunsigned long SSL_CIPHER_get_id(const SSL_CIPHER *c);\n\nint SSL_get_fd(const SSL *s);\nint SSL_get_rfd(const SSL *s);\nint SSL_get_wfd(const SSL *s);\nconst char *SSL_get_cipher_list(const SSL *s, int n);\nchar *SSL_get_shared_ciphers(const SSL *s, char *buf, int len);\nint SSL_get_read_ahead(const SSL *s);\nint SSL_pending(const SSL *s);\n# ifndef OPENSSL_NO_SOCK\nint SSL_set_fd(SSL *s, int fd);\nint SSL_set_rfd(SSL *s, int fd);\nint SSL_set_wfd(SSL *s, int fd);\n# endif\n# ifndef OPENSSL_NO_BIO\nvoid SSL_set_bio(SSL *s, BIO *rbio, BIO *wbio);\nBIO *SSL_get_rbio(const SSL *s);\nBIO *SSL_get_wbio(const SSL *s);\n# endif\nint SSL_set_cipher_list(SSL *s, const char *str);\nvoid SSL_set_read_ahead(SSL *s, int yes);\nint SSL_get_verify_mode(const SSL *s);\nint SSL_get_verify_depth(const SSL *s);\nint (*SSL_get_verify_callback(const SSL *s)) (int, X509_STORE_CTX *);\nvoid SSL_set_verify(SSL *s, int mode,\n                    int (*callback) (int ok, X509_STORE_CTX *ctx));\nvoid SSL_set_verify_depth(SSL *s, int depth);\nvoid SSL_set_cert_cb(SSL *s, int (*cb) (SSL *ssl, void *arg), void *arg);\n# ifndef OPENSSL_NO_RSA\nint SSL_use_RSAPrivateKey(SSL *ssl, RSA *rsa);\n# endif\nint SSL_use_RSAPrivateKey_ASN1(SSL *ssl, unsigned char *d, long len);\nint SSL_use_PrivateKey(SSL *ssl, EVP_PKEY *pkey);\nint SSL_use_PrivateKey_ASN1(int pk, SSL *ssl, const unsigned char *d,\n                            long len);\nint SSL_use_certificate(SSL *ssl, X509 *x);\nint SSL_use_certificate_ASN1(SSL *ssl, const unsigned char *d, int len);\n\n# ifndef OPENSSL_NO_TLSEXT\n/* Set serverinfo data for the current active cert. */\nint SSL_CTX_use_serverinfo(SSL_CTX *ctx, const unsigned char *serverinfo,\n                           size_t serverinfo_length);\n#  ifndef OPENSSL_NO_STDIO\nint SSL_CTX_use_serverinfo_file(SSL_CTX *ctx, const char *file);\n#  endif                        /* NO_STDIO */\n\n# endif\n\n# ifndef OPENSSL_NO_STDIO\nint SSL_use_RSAPrivateKey_file(SSL *ssl, const char *file, int type);\nint SSL_use_PrivateKey_file(SSL *ssl, const char *file, int type);\nint SSL_use_certificate_file(SSL *ssl, const char *file, int type);\nint SSL_CTX_use_RSAPrivateKey_file(SSL_CTX *ctx, const char *file, int type);\nint SSL_CTX_use_PrivateKey_file(SSL_CTX *ctx, const char *file, int type);\nint SSL_CTX_use_certificate_file(SSL_CTX *ctx, const char *file, int type);\n/* PEM type */\nint SSL_CTX_use_certificate_chain_file(SSL_CTX *ctx, const char *file);\nSTACK_OF(X509_NAME) *SSL_load_client_CA_file(const char *file);\nint SSL_add_file_cert_subjects_to_stack(STACK_OF(X509_NAME) *stackCAs,\n                                        const char *file);\n#  ifndef OPENSSL_SYS_VMS\n/* XXXXX: Better scheme needed! [was: #ifndef MAC_OS_pre_X] */\n#   ifndef OPENSSL_SYS_MACINTOSH_CLASSIC\nint SSL_add_dir_cert_subjects_to_stack(STACK_OF(X509_NAME) *stackCAs,\n                                       const char *dir);\n#   endif\n#  endif\n\n# endif\n\nvoid SSL_load_error_strings(void);\nconst char *SSL_state_string(const SSL *s);\nconst char *SSL_rstate_string(const SSL *s);\nconst char *SSL_state_string_long(const SSL *s);\nconst char *SSL_rstate_string_long(const SSL *s);\nlong SSL_SESSION_get_time(const SSL_SESSION *s);\nlong SSL_SESSION_set_time(SSL_SESSION *s, long t);\nlong SSL_SESSION_get_timeout(const SSL_SESSION *s);\nlong SSL_SESSION_set_timeout(SSL_SESSION *s, long t);\nvoid SSL_copy_session_id(SSL *to, const SSL *from);\nX509 *SSL_SESSION_get0_peer(SSL_SESSION *s);\nint SSL_SESSION_set1_id_context(SSL_SESSION *s, const unsigned char *sid_ctx,\n                                unsigned int sid_ctx_len);\n\nSSL_SESSION *SSL_SESSION_new(void);\nconst unsigned char *SSL_SESSION_get_id(const SSL_SESSION *s,\n                                        unsigned int *len);\nunsigned int SSL_SESSION_get_compress_id(const SSL_SESSION *s);\n# ifndef OPENSSL_NO_FP_API\nint SSL_SESSION_print_fp(FILE *fp, const SSL_SESSION *ses);\n# endif\n# ifndef OPENSSL_NO_BIO\nint SSL_SESSION_print(BIO *fp, const SSL_SESSION *ses);\n# endif\nvoid SSL_SESSION_free(SSL_SESSION *ses);\nint i2d_SSL_SESSION(SSL_SESSION *in, unsigned char **pp);\nint SSL_set_session(SSL *to, SSL_SESSION *session);\nint SSL_CTX_add_session(SSL_CTX *s, SSL_SESSION *c);\nint SSL_CTX_remove_session(SSL_CTX *, SSL_SESSION *c);\nint SSL_CTX_set_generate_session_id(SSL_CTX *, GEN_SESSION_CB);\nint SSL_set_generate_session_id(SSL *, GEN_SESSION_CB);\nint SSL_has_matching_session_id(const SSL *ssl, const unsigned char *id,\n                                unsigned int id_len);\nSSL_SESSION *d2i_SSL_SESSION(SSL_SESSION **a, const unsigned char **pp,\n                             long length);\n\n# ifdef HEADER_X509_H\nX509 *SSL_get_peer_certificate(const SSL *s);\n# endif\n\nSTACK_OF(X509) *SSL_get_peer_cert_chain(const SSL *s);\n\nint SSL_CTX_get_verify_mode(const SSL_CTX *ctx);\nint SSL_CTX_get_verify_depth(const SSL_CTX *ctx);\nint (*SSL_CTX_get_verify_callback(const SSL_CTX *ctx)) (int,\n                                                        X509_STORE_CTX *);\nvoid SSL_CTX_set_verify(SSL_CTX *ctx, int mode,\n                        int (*callback) (int, X509_STORE_CTX *));\nvoid SSL_CTX_set_verify_depth(SSL_CTX *ctx, int depth);\nvoid SSL_CTX_set_cert_verify_callback(SSL_CTX *ctx,\n                                      int (*cb) (X509_STORE_CTX *, void *),\n                                      void *arg);\nvoid SSL_CTX_set_cert_cb(SSL_CTX *c, int (*cb) (SSL *ssl, void *arg),\n                         void *arg);\n# ifndef OPENSSL_NO_RSA\nint SSL_CTX_use_RSAPrivateKey(SSL_CTX *ctx, RSA *rsa);\n# endif\nint SSL_CTX_use_RSAPrivateKey_ASN1(SSL_CTX *ctx, const unsigned char *d,\n                                   long len);\nint SSL_CTX_use_PrivateKey(SSL_CTX *ctx, EVP_PKEY *pkey);\nint SSL_CTX_use_PrivateKey_ASN1(int pk, SSL_CTX *ctx,\n                                const unsigned char *d, long len);\nint SSL_CTX_use_certificate(SSL_CTX *ctx, X509 *x);\nint SSL_CTX_use_certificate_ASN1(SSL_CTX *ctx, int len,\n                                 const unsigned char *d);\n\nvoid SSL_CTX_set_default_passwd_cb(SSL_CTX *ctx, pem_password_cb *cb);\nvoid SSL_CTX_set_default_passwd_cb_userdata(SSL_CTX *ctx, void *u);\n\nint SSL_CTX_check_private_key(const SSL_CTX *ctx);\nint SSL_check_private_key(const SSL *ctx);\n\nint SSL_CTX_set_session_id_context(SSL_CTX *ctx, const unsigned char *sid_ctx,\n                                   unsigned int sid_ctx_len);\n\nSSL *SSL_new(SSL_CTX *ctx);\nint SSL_set_session_id_context(SSL *ssl, const unsigned char *sid_ctx,\n                               unsigned int sid_ctx_len);\n\nint SSL_CTX_set_purpose(SSL_CTX *s, int purpose);\nint SSL_set_purpose(SSL *s, int purpose);\nint SSL_CTX_set_trust(SSL_CTX *s, int trust);\nint SSL_set_trust(SSL *s, int trust);\n\nint SSL_CTX_set1_param(SSL_CTX *ctx, X509_VERIFY_PARAM *vpm);\nint SSL_set1_param(SSL *ssl, X509_VERIFY_PARAM *vpm);\n\nX509_VERIFY_PARAM *SSL_CTX_get0_param(SSL_CTX *ctx);\nX509_VERIFY_PARAM *SSL_get0_param(SSL *ssl);\n\n# ifndef OPENSSL_NO_SRP\nint SSL_CTX_set_srp_username(SSL_CTX *ctx, char *name);\nint SSL_CTX_set_srp_password(SSL_CTX *ctx, char *password);\nint SSL_CTX_set_srp_strength(SSL_CTX *ctx, int strength);\nint SSL_CTX_set_srp_client_pwd_callback(SSL_CTX *ctx,\n                                        char *(*cb) (SSL *, void *));\nint SSL_CTX_set_srp_verify_param_callback(SSL_CTX *ctx,\n                                          int (*cb) (SSL *, void *));\nint SSL_CTX_set_srp_username_callback(SSL_CTX *ctx,\n                                      int (*cb) (SSL *, int *, void *));\nint SSL_CTX_set_srp_cb_arg(SSL_CTX *ctx, void *arg);\n\nint SSL_set_srp_server_param(SSL *s, const BIGNUM *N, const BIGNUM *g,\n                             BIGNUM *sa, BIGNUM *v, char *info);\nint SSL_set_srp_server_param_pw(SSL *s, const char *user, const char *pass,\n                                const char *grp);\n\nBIGNUM *SSL_get_srp_g(SSL *s);\nBIGNUM *SSL_get_srp_N(SSL *s);\n\nchar *SSL_get_srp_username(SSL *s);\nchar *SSL_get_srp_userinfo(SSL *s);\n# endif\n\nvoid SSL_certs_clear(SSL *s);\nvoid SSL_free(SSL *ssl);\nint SSL_accept(SSL *ssl);\nint SSL_connect(SSL *ssl);\nint SSL_read(SSL *ssl, void *buf, int num);\nint SSL_peek(SSL *ssl, void *buf, int num);\nint SSL_write(SSL *ssl, const void *buf, int num);\nlong SSL_ctrl(SSL *ssl, int cmd, long larg, void *parg);\nlong SSL_callback_ctrl(SSL *, int, void (*)(void));\nlong SSL_CTX_ctrl(SSL_CTX *ctx, int cmd, long larg, void *parg);\nlong SSL_CTX_callback_ctrl(SSL_CTX *, int, void (*)(void));\n\nint SSL_get_error(const SSL *s, int ret_code);\nconst char *SSL_get_version(const SSL *s);\n\n/* This sets the 'default' SSL version that SSL_new() will create */\nint SSL_CTX_set_ssl_version(SSL_CTX *ctx, const SSL_METHOD *meth);\n\n# ifndef OPENSSL_NO_SSL2_METHOD\nconst SSL_METHOD *SSLv2_method(void); /* SSLv2 */\nconst SSL_METHOD *SSLv2_server_method(void); /* SSLv2 */\nconst SSL_METHOD *SSLv2_client_method(void); /* SSLv2 */\n# endif\n\n# ifndef OPENSSL_NO_SSL3_METHOD\nconst SSL_METHOD *SSLv3_method(void); /* SSLv3 */\nconst SSL_METHOD *SSLv3_server_method(void); /* SSLv3 */\nconst SSL_METHOD *SSLv3_client_method(void); /* SSLv3 */\n# endif\n\nconst SSL_METHOD *SSLv23_method(void); /* Negotiate highest available SSL/TLS\n                                        * version */\nconst SSL_METHOD *SSLv23_server_method(void); /* Negotiate highest available\n                                               * SSL/TLS version */\nconst SSL_METHOD *SSLv23_client_method(void); /* Negotiate highest available\n                                               * SSL/TLS version */\n\nconst SSL_METHOD *TLSv1_method(void); /* TLSv1.0 */\nconst SSL_METHOD *TLSv1_server_method(void); /* TLSv1.0 */\nconst SSL_METHOD *TLSv1_client_method(void); /* TLSv1.0 */\n\nconst SSL_METHOD *TLSv1_1_method(void); /* TLSv1.1 */\nconst SSL_METHOD *TLSv1_1_server_method(void); /* TLSv1.1 */\nconst SSL_METHOD *TLSv1_1_client_method(void); /* TLSv1.1 */\n\nconst SSL_METHOD *TLSv1_2_method(void); /* TLSv1.2 */\nconst SSL_METHOD *TLSv1_2_server_method(void); /* TLSv1.2 */\nconst SSL_METHOD *TLSv1_2_client_method(void); /* TLSv1.2 */\n\nconst SSL_METHOD *DTLSv1_method(void); /* DTLSv1.0 */\nconst SSL_METHOD *DTLSv1_server_method(void); /* DTLSv1.0 */\nconst SSL_METHOD *DTLSv1_client_method(void); /* DTLSv1.0 */\n\nconst SSL_METHOD *DTLSv1_2_method(void); /* DTLSv1.2 */\nconst SSL_METHOD *DTLSv1_2_server_method(void); /* DTLSv1.2 */\nconst SSL_METHOD *DTLSv1_2_client_method(void); /* DTLSv1.2 */\n\nconst SSL_METHOD *DTLS_method(void); /* DTLS 1.0 and 1.2 */\nconst SSL_METHOD *DTLS_server_method(void); /* DTLS 1.0 and 1.2 */\nconst SSL_METHOD *DTLS_client_method(void); /* DTLS 1.0 and 1.2 */\n\nSTACK_OF(SSL_CIPHER) *SSL_get_ciphers(const SSL *s);\n\nint SSL_do_handshake(SSL *s);\nint SSL_renegotiate(SSL *s);\nint SSL_renegotiate_abbreviated(SSL *s);\nint SSL_renegotiate_pending(SSL *s);\nint SSL_shutdown(SSL *s);\n\nconst SSL_METHOD *SSL_CTX_get_ssl_method(SSL_CTX *ctx);\nconst SSL_METHOD *SSL_get_ssl_method(SSL *s);\nint SSL_set_ssl_method(SSL *s, const SSL_METHOD *method);\nconst char *SSL_alert_type_string_long(int value);\nconst char *SSL_alert_type_string(int value);\nconst char *SSL_alert_desc_string_long(int value);\nconst char *SSL_alert_desc_string(int value);\n\nvoid SSL_set_client_CA_list(SSL *s, STACK_OF(X509_NAME) *name_list);\nvoid SSL_CTX_set_client_CA_list(SSL_CTX *ctx, STACK_OF(X509_NAME) *name_list);\nSTACK_OF(X509_NAME) *SSL_get_client_CA_list(const SSL *s);\nSTACK_OF(X509_NAME) *SSL_CTX_get_client_CA_list(const SSL_CTX *s);\nint SSL_add_client_CA(SSL *ssl, X509 *x);\nint SSL_CTX_add_client_CA(SSL_CTX *ctx, X509 *x);\n\nvoid SSL_set_connect_state(SSL *s);\nvoid SSL_set_accept_state(SSL *s);\n\nlong SSL_get_default_timeout(const SSL *s);\n\nint SSL_library_init(void);\n\nchar *SSL_CIPHER_description(const SSL_CIPHER *, char *buf, int size);\nSTACK_OF(X509_NAME) *SSL_dup_CA_list(STACK_OF(X509_NAME) *sk);\n\nSSL *SSL_dup(SSL *ssl);\n\nX509 *SSL_get_certificate(const SSL *ssl);\n/*\n * EVP_PKEY\n */ struct evp_pkey_st *SSL_get_privatekey(const SSL *ssl);\n\nX509 *SSL_CTX_get0_certificate(const SSL_CTX *ctx);\nEVP_PKEY *SSL_CTX_get0_privatekey(const SSL_CTX *ctx);\n\nvoid SSL_CTX_set_quiet_shutdown(SSL_CTX *ctx, int mode);\nint SSL_CTX_get_quiet_shutdown(const SSL_CTX *ctx);\nvoid SSL_set_quiet_shutdown(SSL *ssl, int mode);\nint SSL_get_quiet_shutdown(const SSL *ssl);\nvoid SSL_set_shutdown(SSL *ssl, int mode);\nint SSL_get_shutdown(const SSL *ssl);\nint SSL_version(const SSL *ssl);\nint SSL_CTX_set_default_verify_paths(SSL_CTX *ctx);\nint SSL_CTX_load_verify_locations(SSL_CTX *ctx, const char *CAfile,\n                                  const char *CApath);\n# define SSL_get0_session SSL_get_session/* just peek at pointer */\nSSL_SESSION *SSL_get_session(const SSL *ssl);\nSSL_SESSION *SSL_get1_session(SSL *ssl); /* obtain a reference count */\nSSL_CTX *SSL_get_SSL_CTX(const SSL *ssl);\nSSL_CTX *SSL_set_SSL_CTX(SSL *ssl, SSL_CTX *ctx);\nvoid SSL_set_info_callback(SSL *ssl,\n                           void (*cb) (const SSL *ssl, int type, int val));\nvoid (*SSL_get_info_callback(const SSL *ssl)) (const SSL *ssl, int type,\n                                               int val);\nint SSL_state(const SSL *ssl);\nvoid SSL_set_state(SSL *ssl, int state);\n\nvoid SSL_set_verify_result(SSL *ssl, long v);\nlong SSL_get_verify_result(const SSL *ssl);\n\nint SSL_set_ex_data(SSL *ssl, int idx, void *data);\nvoid *SSL_get_ex_data(const SSL *ssl, int idx);\nint SSL_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func,\n                         CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func);\n\nint SSL_SESSION_set_ex_data(SSL_SESSION *ss, int idx, void *data);\nvoid *SSL_SESSION_get_ex_data(const SSL_SESSION *ss, int idx);\nint SSL_SESSION_get_ex_new_index(long argl, void *argp,\n                                 CRYPTO_EX_new *new_func,\n                                 CRYPTO_EX_dup *dup_func,\n                                 CRYPTO_EX_free *free_func);\n\nint SSL_CTX_set_ex_data(SSL_CTX *ssl, int idx, void *data);\nvoid *SSL_CTX_get_ex_data(const SSL_CTX *ssl, int idx);\nint SSL_CTX_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func,\n                             CRYPTO_EX_dup *dup_func,\n                             CRYPTO_EX_free *free_func);\n\nint SSL_get_ex_data_X509_STORE_CTX_idx(void);\n\n# define SSL_CTX_sess_set_cache_size(ctx,t) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_SET_SESS_CACHE_SIZE,t,NULL)\n# define SSL_CTX_sess_get_cache_size(ctx) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_GET_SESS_CACHE_SIZE,0,NULL)\n# define SSL_CTX_set_session_cache_mode(ctx,m) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_SET_SESS_CACHE_MODE,m,NULL)\n# define SSL_CTX_get_session_cache_mode(ctx) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_GET_SESS_CACHE_MODE,0,NULL)\n\n# define SSL_CTX_get_default_read_ahead(ctx) SSL_CTX_get_read_ahead(ctx)\n# define SSL_CTX_set_default_read_ahead(ctx,m) SSL_CTX_set_read_ahead(ctx,m)\n# define SSL_CTX_get_read_ahead(ctx) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_GET_READ_AHEAD,0,NULL)\n# define SSL_CTX_set_read_ahead(ctx,m) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_SET_READ_AHEAD,m,NULL)\n# define SSL_CTX_get_max_cert_list(ctx) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_GET_MAX_CERT_LIST,0,NULL)\n# define SSL_CTX_set_max_cert_list(ctx,m) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_SET_MAX_CERT_LIST,m,NULL)\n# define SSL_get_max_cert_list(ssl) \\\n        SSL_ctrl(ssl,SSL_CTRL_GET_MAX_CERT_LIST,0,NULL)\n# define SSL_set_max_cert_list(ssl,m) \\\n        SSL_ctrl(ssl,SSL_CTRL_SET_MAX_CERT_LIST,m,NULL)\n\n# define SSL_CTX_set_max_send_fragment(ctx,m) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_SET_MAX_SEND_FRAGMENT,m,NULL)\n# define SSL_set_max_send_fragment(ssl,m) \\\n        SSL_ctrl(ssl,SSL_CTRL_SET_MAX_SEND_FRAGMENT,m,NULL)\n\n     /* NB: the keylength is only applicable when is_export is true */\n# ifndef OPENSSL_NO_RSA\nvoid SSL_CTX_set_tmp_rsa_callback(SSL_CTX *ctx,\n                                  RSA *(*cb) (SSL *ssl, int is_export,\n                                              int keylength));\n\nvoid SSL_set_tmp_rsa_callback(SSL *ssl,\n                              RSA *(*cb) (SSL *ssl, int is_export,\n                                          int keylength));\n# endif\n# ifndef OPENSSL_NO_DH\nvoid SSL_CTX_set_tmp_dh_callback(SSL_CTX *ctx,\n                                 DH *(*dh) (SSL *ssl, int is_export,\n                                            int keylength));\nvoid SSL_set_tmp_dh_callback(SSL *ssl,\n                             DH *(*dh) (SSL *ssl, int is_export,\n                                        int keylength));\n# endif\n# ifndef OPENSSL_NO_ECDH\nvoid SSL_CTX_set_tmp_ecdh_callback(SSL_CTX *ctx,\n                                   EC_KEY *(*ecdh) (SSL *ssl, int is_export,\n                                                    int keylength));\nvoid SSL_set_tmp_ecdh_callback(SSL *ssl,\n                               EC_KEY *(*ecdh) (SSL *ssl, int is_export,\n                                                int keylength));\n# endif\n\n# ifndef OPENSSL_NO_COMP\nconst COMP_METHOD *SSL_get_current_compression(SSL *s);\nconst COMP_METHOD *SSL_get_current_expansion(SSL *s);\nconst char *SSL_COMP_get_name(const COMP_METHOD *comp);\nSTACK_OF(SSL_COMP) *SSL_COMP_get_compression_methods(void);\nSTACK_OF(SSL_COMP) *SSL_COMP_set0_compression_methods(STACK_OF(SSL_COMP)\n                                                      *meths);\nvoid SSL_COMP_free_compression_methods(void);\nint SSL_COMP_add_compression_method(int id, COMP_METHOD *cm);\n# else\nconst void *SSL_get_current_compression(SSL *s);\nconst void *SSL_get_current_expansion(SSL *s);\nconst char *SSL_COMP_get_name(const void *comp);\nvoid *SSL_COMP_get_compression_methods(void);\nint SSL_COMP_add_compression_method(int id, void *cm);\n# endif\n\nconst SSL_CIPHER *SSL_CIPHER_find(SSL *ssl, const unsigned char *ptr);\n\n/* TLS extensions functions */\nint SSL_set_session_ticket_ext(SSL *s, void *ext_data, int ext_len);\n\nint SSL_set_session_ticket_ext_cb(SSL *s, tls_session_ticket_ext_cb_fn cb,\n                                  void *arg);\n\n/* Pre-shared secret session resumption functions */\nint SSL_set_session_secret_cb(SSL *s,\n                              tls_session_secret_cb_fn tls_session_secret_cb,\n                              void *arg);\n\nvoid SSL_set_debug(SSL *s, int debug);\nint SSL_cache_hit(SSL *s);\nint SSL_is_server(SSL *s);\n\nSSL_CONF_CTX *SSL_CONF_CTX_new(void);\nint SSL_CONF_CTX_finish(SSL_CONF_CTX *cctx);\nvoid SSL_CONF_CTX_free(SSL_CONF_CTX *cctx);\nunsigned int SSL_CONF_CTX_set_flags(SSL_CONF_CTX *cctx, unsigned int flags);\nunsigned int SSL_CONF_CTX_clear_flags(SSL_CONF_CTX *cctx, unsigned int flags);\nint SSL_CONF_CTX_set1_prefix(SSL_CONF_CTX *cctx, const char *pre);\n\nvoid SSL_CONF_CTX_set_ssl(SSL_CONF_CTX *cctx, SSL *ssl);\nvoid SSL_CONF_CTX_set_ssl_ctx(SSL_CONF_CTX *cctx, SSL_CTX *ctx);\n\nint SSL_CONF_cmd(SSL_CONF_CTX *cctx, const char *cmd, const char *value);\nint SSL_CONF_cmd_argv(SSL_CONF_CTX *cctx, int *pargc, char ***pargv);\nint SSL_CONF_cmd_value_type(SSL_CONF_CTX *cctx, const char *cmd);\n\n# ifndef OPENSSL_NO_SSL_TRACE\nvoid SSL_trace(int write_p, int version, int content_type,\n               const void *buf, size_t len, SSL *ssl, void *arg);\nconst char *SSL_CIPHER_standard_name(const SSL_CIPHER *c);\n# endif\n\n# ifndef OPENSSL_NO_UNIT_TEST\nconst struct openssl_ssl_test_functions *SSL_test_functions(void);\n# endif\n\n/* BEGIN ERROR CODES */\n/*\n * The following lines are auto generated by the script mkerr.pl. Any changes\n * made after this point may be overwritten when the script is next run.\n */\nvoid ERR_load_SSL_strings(void);\n\n/* Error codes for the SSL functions. */\n\n/* Function codes. */\n# define SSL_F_CHECK_SUITEB_CIPHER_LIST                   331\n# define SSL_F_CLIENT_CERTIFICATE                         100\n# define SSL_F_CLIENT_FINISHED                            167\n# define SSL_F_CLIENT_HELLO                               101\n# define SSL_F_CLIENT_MASTER_KEY                          102\n# define SSL_F_D2I_SSL_SESSION                            103\n# define SSL_F_DO_DTLS1_WRITE                             245\n# define SSL_F_DO_SSL3_WRITE                              104\n# define SSL_F_DTLS1_ACCEPT                               246\n# define SSL_F_DTLS1_ADD_CERT_TO_BUF                      295\n# define SSL_F_DTLS1_BUFFER_RECORD                        247\n# define SSL_F_DTLS1_CHECK_TIMEOUT_NUM                    316\n# define SSL_F_DTLS1_CLIENT_HELLO                         248\n# define SSL_F_DTLS1_CONNECT                              249\n# define SSL_F_DTLS1_ENC                                  250\n# define SSL_F_DTLS1_GET_HELLO_VERIFY                     251\n# define SSL_F_DTLS1_GET_MESSAGE                          252\n# define SSL_F_DTLS1_GET_MESSAGE_FRAGMENT                 253\n# define SSL_F_DTLS1_GET_RECORD                           254\n# define SSL_F_DTLS1_HANDLE_TIMEOUT                       297\n# define SSL_F_DTLS1_HEARTBEAT                            305\n# define SSL_F_DTLS1_OUTPUT_CERT_CHAIN                    255\n# define SSL_F_DTLS1_PREPROCESS_FRAGMENT                  288\n# define SSL_F_DTLS1_PROCESS_OUT_OF_SEQ_MESSAGE           256\n# define SSL_F_DTLS1_PROCESS_RECORD                       257\n# define SSL_F_DTLS1_READ_BYTES                           258\n# define SSL_F_DTLS1_READ_FAILED                          259\n# define SSL_F_DTLS1_SEND_CERTIFICATE_REQUEST             260\n# define SSL_F_DTLS1_SEND_CLIENT_CERTIFICATE              261\n# define SSL_F_DTLS1_SEND_CLIENT_KEY_EXCHANGE             262\n# define SSL_F_DTLS1_SEND_CLIENT_VERIFY                   263\n# define SSL_F_DTLS1_SEND_HELLO_VERIFY_REQUEST            264\n# define SSL_F_DTLS1_SEND_SERVER_CERTIFICATE              265\n# define SSL_F_DTLS1_SEND_SERVER_HELLO                    266\n# define SSL_F_DTLS1_SEND_SERVER_KEY_EXCHANGE             267\n# define SSL_F_DTLS1_WRITE_APP_DATA_BYTES                 268\n# define SSL_F_GET_CLIENT_FINISHED                        105\n# define SSL_F_GET_CLIENT_HELLO                           106\n# define SSL_F_GET_CLIENT_MASTER_KEY                      107\n# define SSL_F_GET_SERVER_FINISHED                        108\n# define SSL_F_GET_SERVER_HELLO                           109\n# define SSL_F_GET_SERVER_STATIC_DH_KEY                   340\n# define SSL_F_GET_SERVER_VERIFY                          110\n# define SSL_F_I2D_SSL_SESSION                            111\n# define SSL_F_READ_N                                     112\n# define SSL_F_REQUEST_CERTIFICATE                        113\n# define SSL_F_SERVER_FINISH                              239\n# define SSL_F_SERVER_HELLO                               114\n# define SSL_F_SERVER_VERIFY                              240\n# define SSL_F_SSL23_ACCEPT                               115\n# define SSL_F_SSL23_CLIENT_HELLO                         116\n# define SSL_F_SSL23_CONNECT                              117\n# define SSL_F_SSL23_GET_CLIENT_HELLO                     118\n# define SSL_F_SSL23_GET_SERVER_HELLO                     119\n# define SSL_F_SSL23_PEEK                                 237\n# define SSL_F_SSL23_READ                                 120\n# define SSL_F_SSL23_WRITE                                121\n# define SSL_F_SSL2_ACCEPT                                122\n# define SSL_F_SSL2_CONNECT                               123\n# define SSL_F_SSL2_ENC_INIT                              124\n# define SSL_F_SSL2_GENERATE_KEY_MATERIAL                 241\n# define SSL_F_SSL2_PEEK                                  234\n# define SSL_F_SSL2_READ                                  125\n# define SSL_F_SSL2_READ_INTERNAL                         236\n# define SSL_F_SSL2_SET_CERTIFICATE                       126\n# define SSL_F_SSL2_WRITE                                 127\n# define SSL_F_SSL3_ACCEPT                                128\n# define SSL_F_SSL3_ADD_CERT_TO_BUF                       296\n# define SSL_F_SSL3_CALLBACK_CTRL                         233\n# define SSL_F_SSL3_CHANGE_CIPHER_STATE                   129\n# define SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM              130\n# define SSL_F_SSL3_CHECK_CLIENT_HELLO                    304\n# define SSL_F_SSL3_CHECK_FINISHED                        339\n# define SSL_F_SSL3_CLIENT_HELLO                          131\n# define SSL_F_SSL3_CONNECT                               132\n# define SSL_F_SSL3_CTRL                                  213\n# define SSL_F_SSL3_CTX_CTRL                              133\n# define SSL_F_SSL3_DIGEST_CACHED_RECORDS                 293\n# define SSL_F_SSL3_DO_CHANGE_CIPHER_SPEC                 292\n# define SSL_F_SSL3_ENC                                   134\n# define SSL_F_SSL3_GENERATE_KEY_BLOCK                    238\n# define SSL_F_SSL3_GENERATE_MASTER_SECRET                388\n# define SSL_F_SSL3_GET_CERTIFICATE_REQUEST               135\n# define SSL_F_SSL3_GET_CERT_STATUS                       289\n# define SSL_F_SSL3_GET_CERT_VERIFY                       136\n# define SSL_F_SSL3_GET_CLIENT_CERTIFICATE                137\n# define SSL_F_SSL3_GET_CLIENT_HELLO                      138\n# define SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE               139\n# define SSL_F_SSL3_GET_FINISHED                          140\n# define SSL_F_SSL3_GET_KEY_EXCHANGE                      141\n# define SSL_F_SSL3_GET_MESSAGE                           142\n# define SSL_F_SSL3_GET_NEW_SESSION_TICKET                283\n# define SSL_F_SSL3_GET_NEXT_PROTO                        306\n# define SSL_F_SSL3_GET_RECORD                            143\n# define SSL_F_SSL3_GET_SERVER_CERTIFICATE                144\n# define SSL_F_SSL3_GET_SERVER_DONE                       145\n# define SSL_F_SSL3_GET_SERVER_HELLO                      146\n# define SSL_F_SSL3_HANDSHAKE_MAC                         285\n# define SSL_F_SSL3_NEW_SESSION_TICKET                    287\n# define SSL_F_SSL3_OUTPUT_CERT_CHAIN                     147\n# define SSL_F_SSL3_PEEK                                  235\n# define SSL_F_SSL3_READ_BYTES                            148\n# define SSL_F_SSL3_READ_N                                149\n# define SSL_F_SSL3_SEND_CERTIFICATE_REQUEST              150\n# define SSL_F_SSL3_SEND_CLIENT_CERTIFICATE               151\n# define SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE              152\n# define SSL_F_SSL3_SEND_CLIENT_VERIFY                    153\n# define SSL_F_SSL3_SEND_SERVER_CERTIFICATE               154\n# define SSL_F_SSL3_SEND_SERVER_HELLO                     242\n# define SSL_F_SSL3_SEND_SERVER_KEY_EXCHANGE              155\n# define SSL_F_SSL3_SETUP_KEY_BLOCK                       157\n# define SSL_F_SSL3_SETUP_READ_BUFFER                     156\n# define SSL_F_SSL3_SETUP_WRITE_BUFFER                    291\n# define SSL_F_SSL3_WRITE_BYTES                           158\n# define SSL_F_SSL3_WRITE_PENDING                         159\n# define SSL_F_SSL_ADD_CERT_CHAIN                         318\n# define SSL_F_SSL_ADD_CERT_TO_BUF                        319\n# define SSL_F_SSL_ADD_CLIENTHELLO_RENEGOTIATE_EXT        298\n# define SSL_F_SSL_ADD_CLIENTHELLO_TLSEXT                 277\n# define SSL_F_SSL_ADD_CLIENTHELLO_USE_SRTP_EXT           307\n# define SSL_F_SSL_ADD_DIR_CERT_SUBJECTS_TO_STACK         215\n# define SSL_F_SSL_ADD_FILE_CERT_SUBJECTS_TO_STACK        216\n# define SSL_F_SSL_ADD_SERVERHELLO_RENEGOTIATE_EXT        299\n# define SSL_F_SSL_ADD_SERVERHELLO_TLSEXT                 278\n# define SSL_F_SSL_ADD_SERVERHELLO_USE_SRTP_EXT           308\n# define SSL_F_SSL_BAD_METHOD                             160\n# define SSL_F_SSL_BUILD_CERT_CHAIN                       332\n# define SSL_F_SSL_BYTES_TO_CIPHER_LIST                   161\n# define SSL_F_SSL_CERT_DUP                               221\n# define SSL_F_SSL_CERT_INST                              222\n# define SSL_F_SSL_CERT_INSTANTIATE                       214\n# define SSL_F_SSL_CERT_NEW                               162\n# define SSL_F_SSL_CHECK_PRIVATE_KEY                      163\n# define SSL_F_SSL_CHECK_SERVERHELLO_TLSEXT               280\n# define SSL_F_SSL_CHECK_SRVR_ECC_CERT_AND_ALG            279\n# define SSL_F_SSL_CIPHER_PROCESS_RULESTR                 230\n# define SSL_F_SSL_CIPHER_STRENGTH_SORT                   231\n# define SSL_F_SSL_CLEAR                                  164\n# define SSL_F_SSL_COMP_ADD_COMPRESSION_METHOD            165\n# define SSL_F_SSL_CONF_CMD                               334\n# define SSL_F_SSL_CREATE_CIPHER_LIST                     166\n# define SSL_F_SSL_CTRL                                   232\n# define SSL_F_SSL_CTX_CHECK_PRIVATE_KEY                  168\n# define SSL_F_SSL_CTX_MAKE_PROFILES                      309\n# define SSL_F_SSL_CTX_NEW                                169\n# define SSL_F_SSL_CTX_SET_CIPHER_LIST                    269\n# define SSL_F_SSL_CTX_SET_CLIENT_CERT_ENGINE             290\n# define SSL_F_SSL_CTX_SET_PURPOSE                        226\n# define SSL_F_SSL_CTX_SET_SESSION_ID_CONTEXT             219\n# define SSL_F_SSL_CTX_SET_SSL_VERSION                    170\n# define SSL_F_SSL_CTX_SET_TRUST                          229\n# define SSL_F_SSL_CTX_USE_CERTIFICATE                    171\n# define SSL_F_SSL_CTX_USE_CERTIFICATE_ASN1               172\n# define SSL_F_SSL_CTX_USE_CERTIFICATE_CHAIN_FILE         220\n# define SSL_F_SSL_CTX_USE_CERTIFICATE_FILE               173\n# define SSL_F_SSL_CTX_USE_PRIVATEKEY                     174\n# define SSL_F_SSL_CTX_USE_PRIVATEKEY_ASN1                175\n# define SSL_F_SSL_CTX_USE_PRIVATEKEY_FILE                176\n# define SSL_F_SSL_CTX_USE_PSK_IDENTITY_HINT              272\n# define SSL_F_SSL_CTX_USE_RSAPRIVATEKEY                  177\n# define SSL_F_SSL_CTX_USE_RSAPRIVATEKEY_ASN1             178\n# define SSL_F_SSL_CTX_USE_RSAPRIVATEKEY_FILE             179\n# define SSL_F_SSL_CTX_USE_SERVERINFO                     336\n# define SSL_F_SSL_CTX_USE_SERVERINFO_FILE                337\n# define SSL_F_SSL_DO_HANDSHAKE                           180\n# define SSL_F_SSL_GET_NEW_SESSION                        181\n# define SSL_F_SSL_GET_PREV_SESSION                       217\n# define SSL_F_SSL_GET_SERVER_CERT_INDEX                  322\n# define SSL_F_SSL_GET_SERVER_SEND_CERT                   182\n# define SSL_F_SSL_GET_SERVER_SEND_PKEY                   317\n# define SSL_F_SSL_GET_SIGN_PKEY                          183\n# define SSL_F_SSL_INIT_WBIO_BUFFER                       184\n# define SSL_F_SSL_LOAD_CLIENT_CA_FILE                    185\n# define SSL_F_SSL_NEW                                    186\n# define SSL_F_SSL_PARSE_CLIENTHELLO_RENEGOTIATE_EXT      300\n# define SSL_F_SSL_PARSE_CLIENTHELLO_TLSEXT               302\n# define SSL_F_SSL_PARSE_CLIENTHELLO_USE_SRTP_EXT         310\n# define SSL_F_SSL_PARSE_SERVERHELLO_RENEGOTIATE_EXT      301\n# define SSL_F_SSL_PARSE_SERVERHELLO_TLSEXT               303\n# define SSL_F_SSL_PARSE_SERVERHELLO_USE_SRTP_EXT         311\n# define SSL_F_SSL_PEEK                                   270\n# define SSL_F_SSL_PREPARE_CLIENTHELLO_TLSEXT             281\n# define SSL_F_SSL_PREPARE_SERVERHELLO_TLSEXT             282\n# define SSL_F_SSL_READ                                   223\n# define SSL_F_SSL_RSA_PRIVATE_DECRYPT                    187\n# define SSL_F_SSL_RSA_PUBLIC_ENCRYPT                     188\n# define SSL_F_SSL_SCAN_CLIENTHELLO_TLSEXT                320\n# define SSL_F_SSL_SCAN_SERVERHELLO_TLSEXT                321\n# define SSL_F_SSL_SESSION_DUP                            348\n# define SSL_F_SSL_SESSION_NEW                            189\n# define SSL_F_SSL_SESSION_PRINT_FP                       190\n# define SSL_F_SSL_SESSION_SET1_ID_CONTEXT                312\n# define SSL_F_SSL_SESS_CERT_NEW                          225\n# define SSL_F_SSL_SET_CERT                               191\n# define SSL_F_SSL_SET_CIPHER_LIST                        271\n# define SSL_F_SSL_SET_FD                                 192\n# define SSL_F_SSL_SET_PKEY                               193\n# define SSL_F_SSL_SET_PURPOSE                            227\n# define SSL_F_SSL_SET_RFD                                194\n# define SSL_F_SSL_SET_SESSION                            195\n# define SSL_F_SSL_SET_SESSION_ID_CONTEXT                 218\n# define SSL_F_SSL_SET_SESSION_TICKET_EXT                 294\n# define SSL_F_SSL_SET_TRUST                              228\n# define SSL_F_SSL_SET_WFD                                196\n# define SSL_F_SSL_SHUTDOWN                               224\n# define SSL_F_SSL_SRP_CTX_INIT                           313\n# define SSL_F_SSL_UNDEFINED_CONST_FUNCTION               243\n# define SSL_F_SSL_UNDEFINED_FUNCTION                     197\n# define SSL_F_SSL_UNDEFINED_VOID_FUNCTION                244\n# define SSL_F_SSL_USE_CERTIFICATE                        198\n# define SSL_F_SSL_USE_CERTIFICATE_ASN1                   199\n# define SSL_F_SSL_USE_CERTIFICATE_FILE                   200\n# define SSL_F_SSL_USE_PRIVATEKEY                         201\n# define SSL_F_SSL_USE_PRIVATEKEY_ASN1                    202\n# define SSL_F_SSL_USE_PRIVATEKEY_FILE                    203\n# define SSL_F_SSL_USE_PSK_IDENTITY_HINT                  273\n# define SSL_F_SSL_USE_RSAPRIVATEKEY                      204\n# define SSL_F_SSL_USE_RSAPRIVATEKEY_ASN1                 205\n# define SSL_F_SSL_USE_RSAPRIVATEKEY_FILE                 206\n# define SSL_F_SSL_VERIFY_CERT_CHAIN                      207\n# define SSL_F_SSL_WRITE                                  208\n# define SSL_F_TLS12_CHECK_PEER_SIGALG                    333\n# define SSL_F_TLS1_CERT_VERIFY_MAC                       286\n# define SSL_F_TLS1_CHANGE_CIPHER_STATE                   209\n# define SSL_F_TLS1_CHECK_SERVERHELLO_TLSEXT              274\n# define SSL_F_TLS1_ENC                                   210\n# define SSL_F_TLS1_EXPORT_KEYING_MATERIAL                314\n# define SSL_F_TLS1_GET_CURVELIST                         338\n# define SSL_F_TLS1_HEARTBEAT                             315\n# define SSL_F_TLS1_PREPARE_CLIENTHELLO_TLSEXT            275\n# define SSL_F_TLS1_PREPARE_SERVERHELLO_TLSEXT            276\n# define SSL_F_TLS1_PRF                                   284\n# define SSL_F_TLS1_SETUP_KEY_BLOCK                       211\n# define SSL_F_TLS1_SET_SERVER_SIGALGS                    335\n# define SSL_F_WRITE_PENDING                              212\n\n/* Reason codes. */\n# define SSL_R_APP_DATA_IN_HANDSHAKE                      100\n# define SSL_R_ATTEMPT_TO_REUSE_SESSION_IN_DIFFERENT_CONTEXT 272\n# define SSL_R_BAD_ALERT_RECORD                           101\n# define SSL_R_BAD_AUTHENTICATION_TYPE                    102\n# define SSL_R_BAD_CHANGE_CIPHER_SPEC                     103\n# define SSL_R_BAD_CHECKSUM                               104\n# define SSL_R_BAD_DATA                                   390\n# define SSL_R_BAD_DATA_RETURNED_BY_CALLBACK              106\n# define SSL_R_BAD_DECOMPRESSION                          107\n# define SSL_R_BAD_DH_G_LENGTH                            108\n# define SSL_R_BAD_DH_G_VALUE                             375\n# define SSL_R_BAD_DH_PUB_KEY_LENGTH                      109\n# define SSL_R_BAD_DH_PUB_KEY_VALUE                       393\n# define SSL_R_BAD_DH_P_LENGTH                            110\n# define SSL_R_BAD_DH_P_VALUE                             395\n# define SSL_R_BAD_DIGEST_LENGTH                          111\n# define SSL_R_BAD_DSA_SIGNATURE                          112\n# define SSL_R_BAD_ECC_CERT                               304\n# define SSL_R_BAD_ECDSA_SIGNATURE                        305\n# define SSL_R_BAD_ECPOINT                                306\n# define SSL_R_BAD_HANDSHAKE_LENGTH                       332\n# define SSL_R_BAD_HELLO_REQUEST                          105\n# define SSL_R_BAD_LENGTH                                 271\n# define SSL_R_BAD_MAC_DECODE                             113\n# define SSL_R_BAD_MAC_LENGTH                             333\n# define SSL_R_BAD_MESSAGE_TYPE                           114\n# define SSL_R_BAD_PACKET_LENGTH                          115\n# define SSL_R_BAD_PROTOCOL_VERSION_NUMBER                116\n# define SSL_R_BAD_PSK_IDENTITY_HINT_LENGTH               316\n# define SSL_R_BAD_RESPONSE_ARGUMENT                      117\n# define SSL_R_BAD_RSA_DECRYPT                            118\n# define SSL_R_BAD_RSA_ENCRYPT                            119\n# define SSL_R_BAD_RSA_E_LENGTH                           120\n# define SSL_R_BAD_RSA_MODULUS_LENGTH                     121\n# define SSL_R_BAD_RSA_SIGNATURE                          122\n# define SSL_R_BAD_SIGNATURE                              123\n# define SSL_R_BAD_SRP_A_LENGTH                           347\n# define SSL_R_BAD_SRP_B_LENGTH                           348\n# define SSL_R_BAD_SRP_G_LENGTH                           349\n# define SSL_R_BAD_SRP_N_LENGTH                           350\n# define SSL_R_BAD_SRP_PARAMETERS                         371\n# define SSL_R_BAD_SRP_S_LENGTH                           351\n# define SSL_R_BAD_SRTP_MKI_VALUE                         352\n# define SSL_R_BAD_SRTP_PROTECTION_PROFILE_LIST           353\n# define SSL_R_BAD_SSL_FILETYPE                           124\n# define SSL_R_BAD_SSL_SESSION_ID_LENGTH                  125\n# define SSL_R_BAD_STATE                                  126\n# define SSL_R_BAD_VALUE                                  384\n# define SSL_R_BAD_WRITE_RETRY                            127\n# define SSL_R_BIO_NOT_SET                                128\n# define SSL_R_BLOCK_CIPHER_PAD_IS_WRONG                  129\n# define SSL_R_BN_LIB                                     130\n# define SSL_R_CA_DN_LENGTH_MISMATCH                      131\n# define SSL_R_CA_DN_TOO_LONG                             132\n# define SSL_R_CCS_RECEIVED_EARLY                         133\n# define SSL_R_CERTIFICATE_VERIFY_FAILED                  134\n# define SSL_R_CERT_CB_ERROR                              377\n# define SSL_R_CERT_LENGTH_MISMATCH                       135\n# define SSL_R_CHALLENGE_IS_DIFFERENT                     136\n# define SSL_R_CIPHER_CODE_WRONG_LENGTH                   137\n# define SSL_R_CIPHER_OR_HASH_UNAVAILABLE                 138\n# define SSL_R_CIPHER_TABLE_SRC_ERROR                     139\n# define SSL_R_CLIENTHELLO_TLSEXT                         226\n# define SSL_R_COMPRESSED_LENGTH_TOO_LONG                 140\n# define SSL_R_COMPRESSION_DISABLED                       343\n# define SSL_R_COMPRESSION_FAILURE                        141\n# define SSL_R_COMPRESSION_ID_NOT_WITHIN_PRIVATE_RANGE    307\n# define SSL_R_COMPRESSION_LIBRARY_ERROR                  142\n# define SSL_R_CONNECTION_ID_IS_DIFFERENT                 143\n# define SSL_R_CONNECTION_TYPE_NOT_SET                    144\n# define SSL_R_COOKIE_MISMATCH                            308\n# define SSL_R_DATA_BETWEEN_CCS_AND_FINISHED              145\n# define SSL_R_DATA_LENGTH_TOO_LONG                       146\n# define SSL_R_DECRYPTION_FAILED                          147\n# define SSL_R_DECRYPTION_FAILED_OR_BAD_RECORD_MAC        281\n# define SSL_R_DH_KEY_TOO_SMALL                           372\n# define SSL_R_DH_PUBLIC_VALUE_LENGTH_IS_WRONG            148\n# define SSL_R_DIGEST_CHECK_FAILED                        149\n# define SSL_R_DTLS_MESSAGE_TOO_BIG                       334\n# define SSL_R_DUPLICATE_COMPRESSION_ID                   309\n# define SSL_R_ECC_CERT_NOT_FOR_KEY_AGREEMENT             317\n# define SSL_R_ECC_CERT_NOT_FOR_SIGNING                   318\n# define SSL_R_ECC_CERT_SHOULD_HAVE_RSA_SIGNATURE         322\n# define SSL_R_ECC_CERT_SHOULD_HAVE_SHA1_SIGNATURE        323\n# define SSL_R_ECDH_REQUIRED_FOR_SUITEB_MODE              374\n# define SSL_R_ECGROUP_TOO_LARGE_FOR_CIPHER               310\n# define SSL_R_EMPTY_SRTP_PROTECTION_PROFILE_LIST         354\n# define SSL_R_ENCRYPTED_LENGTH_TOO_LONG                  150\n# define SSL_R_ERROR_GENERATING_TMP_RSA_KEY               282\n# define SSL_R_ERROR_IN_RECEIVED_CIPHER_LIST              151\n# define SSL_R_EXCESSIVE_MESSAGE_SIZE                     152\n# define SSL_R_EXTRA_DATA_IN_MESSAGE                      153\n# define SSL_R_GOT_A_FIN_BEFORE_A_CCS                     154\n# define SSL_R_GOT_NEXT_PROTO_BEFORE_A_CCS                355\n# define SSL_R_GOT_NEXT_PROTO_WITHOUT_EXTENSION           356\n# define SSL_R_HTTPS_PROXY_REQUEST                        155\n# define SSL_R_HTTP_REQUEST                               156\n# define SSL_R_ILLEGAL_PADDING                            283\n# define SSL_R_ILLEGAL_SUITEB_DIGEST                      380\n# define SSL_R_INAPPROPRIATE_FALLBACK                     373\n# define SSL_R_INCONSISTENT_COMPRESSION                   340\n# define SSL_R_INVALID_CHALLENGE_LENGTH                   158\n# define SSL_R_INVALID_COMMAND                            280\n# define SSL_R_INVALID_COMPRESSION_ALGORITHM              341\n# define SSL_R_INVALID_NULL_CMD_NAME                      385\n# define SSL_R_INVALID_PURPOSE                            278\n# define SSL_R_INVALID_SERVERINFO_DATA                    388\n# define SSL_R_INVALID_SRP_USERNAME                       357\n# define SSL_R_INVALID_STATUS_RESPONSE                    328\n# define SSL_R_INVALID_TICKET_KEYS_LENGTH                 325\n# define SSL_R_INVALID_TRUST                              279\n# define SSL_R_KEY_ARG_TOO_LONG                           284\n# define SSL_R_KRB5                                       285\n# define SSL_R_KRB5_C_CC_PRINC                            286\n# define SSL_R_KRB5_C_GET_CRED                            287\n# define SSL_R_KRB5_C_INIT                                288\n# define SSL_R_KRB5_C_MK_REQ                              289\n# define SSL_R_KRB5_S_BAD_TICKET                          290\n# define SSL_R_KRB5_S_INIT                                291\n# define SSL_R_KRB5_S_RD_REQ                              292\n# define SSL_R_KRB5_S_TKT_EXPIRED                         293\n# define SSL_R_KRB5_S_TKT_NYV                             294\n# define SSL_R_KRB5_S_TKT_SKEW                            295\n# define SSL_R_LENGTH_MISMATCH                            159\n# define SSL_R_LENGTH_TOO_SHORT                           160\n# define SSL_R_LIBRARY_BUG                                274\n# define SSL_R_LIBRARY_HAS_NO_CIPHERS                     161\n# define SSL_R_MESSAGE_TOO_LONG                           296\n# define SSL_R_MISSING_DH_DSA_CERT                        162\n# define SSL_R_MISSING_DH_KEY                             163\n# define SSL_R_MISSING_DH_RSA_CERT                        164\n# define SSL_R_MISSING_DSA_SIGNING_CERT                   165\n# define SSL_R_MISSING_ECDH_CERT                          382\n# define SSL_R_MISSING_ECDSA_SIGNING_CERT                 381\n# define SSL_R_MISSING_EXPORT_TMP_DH_KEY                  166\n# define SSL_R_MISSING_EXPORT_TMP_RSA_KEY                 167\n# define SSL_R_MISSING_RSA_CERTIFICATE                    168\n# define SSL_R_MISSING_RSA_ENCRYPTING_CERT                169\n# define SSL_R_MISSING_RSA_SIGNING_CERT                   170\n# define SSL_R_MISSING_SRP_PARAM                          358\n# define SSL_R_MISSING_TMP_DH_KEY                         171\n# define SSL_R_MISSING_TMP_ECDH_KEY                       311\n# define SSL_R_MISSING_TMP_RSA_KEY                        172\n# define SSL_R_MISSING_TMP_RSA_PKEY                       173\n# define SSL_R_MISSING_VERIFY_MESSAGE                     174\n# define SSL_R_MULTIPLE_SGC_RESTARTS                      346\n# define SSL_R_NON_SSLV2_INITIAL_PACKET                   175\n# define SSL_R_NO_CERTIFICATES_RETURNED                   176\n# define SSL_R_NO_CERTIFICATE_ASSIGNED                    177\n# define SSL_R_NO_CERTIFICATE_RETURNED                    178\n# define SSL_R_NO_CERTIFICATE_SET                         179\n# define SSL_R_NO_CERTIFICATE_SPECIFIED                   180\n# define SSL_R_NO_CIPHERS_AVAILABLE                       181\n# define SSL_R_NO_CIPHERS_PASSED                          182\n# define SSL_R_NO_CIPHERS_SPECIFIED                       183\n# define SSL_R_NO_CIPHER_LIST                             184\n# define SSL_R_NO_CIPHER_MATCH                            185\n# define SSL_R_NO_CLIENT_CERT_METHOD                      331\n# define SSL_R_NO_CLIENT_CERT_RECEIVED                    186\n# define SSL_R_NO_COMPRESSION_SPECIFIED                   187\n# define SSL_R_NO_GOST_CERTIFICATE_SENT_BY_PEER           330\n# define SSL_R_NO_METHOD_SPECIFIED                        188\n# define SSL_R_NO_PEM_EXTENSIONS                          389\n# define SSL_R_NO_PRIVATEKEY                              189\n# define SSL_R_NO_PRIVATE_KEY_ASSIGNED                    190\n# define SSL_R_NO_PROTOCOLS_AVAILABLE                     191\n# define SSL_R_NO_PUBLICKEY                               192\n# define SSL_R_NO_RENEGOTIATION                           339\n# define SSL_R_NO_REQUIRED_DIGEST                         324\n# define SSL_R_NO_SHARED_CIPHER                           193\n# define SSL_R_NO_SHARED_SIGATURE_ALGORITHMS              376\n# define SSL_R_NO_SRTP_PROFILES                           359\n# define SSL_R_NO_VERIFY_CALLBACK                         194\n# define SSL_R_NULL_SSL_CTX                               195\n# define SSL_R_NULL_SSL_METHOD_PASSED                     196\n# define SSL_R_OLD_SESSION_CIPHER_NOT_RETURNED            197\n# define SSL_R_OLD_SESSION_COMPRESSION_ALGORITHM_NOT_RETURNED 344\n# define SSL_R_ONLY_DTLS_1_2_ALLOWED_IN_SUITEB_MODE       387\n# define SSL_R_ONLY_TLS_1_2_ALLOWED_IN_SUITEB_MODE        379\n# define SSL_R_ONLY_TLS_ALLOWED_IN_FIPS_MODE              297\n# define SSL_R_OPAQUE_PRF_INPUT_TOO_LONG                  327\n# define SSL_R_PACKET_LENGTH_TOO_LONG                     198\n# define SSL_R_PARSE_TLSEXT                               227\n# define SSL_R_PATH_TOO_LONG                              270\n# define SSL_R_PEER_DID_NOT_RETURN_A_CERTIFICATE          199\n# define SSL_R_PEER_ERROR                                 200\n# define SSL_R_PEER_ERROR_CERTIFICATE                     201\n# define SSL_R_PEER_ERROR_NO_CERTIFICATE                  202\n# define SSL_R_PEER_ERROR_NO_CIPHER                       203\n# define SSL_R_PEER_ERROR_UNSUPPORTED_CERTIFICATE_TYPE    204\n# define SSL_R_PEM_NAME_BAD_PREFIX                        391\n# define SSL_R_PEM_NAME_TOO_SHORT                         392\n# define SSL_R_PRE_MAC_LENGTH_TOO_LONG                    205\n# define SSL_R_PROBLEMS_MAPPING_CIPHER_FUNCTIONS          206\n# define SSL_R_PROTOCOL_IS_SHUTDOWN                       207\n# define SSL_R_PSK_IDENTITY_NOT_FOUND                     223\n# define SSL_R_PSK_NO_CLIENT_CB                           224\n# define SSL_R_PSK_NO_SERVER_CB                           225\n# define SSL_R_PUBLIC_KEY_ENCRYPT_ERROR                   208\n# define SSL_R_PUBLIC_KEY_IS_NOT_RSA                      209\n# define SSL_R_PUBLIC_KEY_NOT_RSA                         210\n# define SSL_R_READ_BIO_NOT_SET                           211\n# define SSL_R_READ_TIMEOUT_EXPIRED                       312\n# define SSL_R_READ_WRONG_PACKET_TYPE                     212\n# define SSL_R_RECORD_LENGTH_MISMATCH                     213\n# define SSL_R_RECORD_TOO_LARGE                           214\n# define SSL_R_RECORD_TOO_SMALL                           298\n# define SSL_R_RENEGOTIATE_EXT_TOO_LONG                   335\n# define SSL_R_RENEGOTIATION_ENCODING_ERR                 336\n# define SSL_R_RENEGOTIATION_MISMATCH                     337\n# define SSL_R_REQUIRED_CIPHER_MISSING                    215\n# define SSL_R_REQUIRED_COMPRESSSION_ALGORITHM_MISSING    342\n# define SSL_R_REUSE_CERT_LENGTH_NOT_ZERO                 216\n# define SSL_R_REUSE_CERT_TYPE_NOT_ZERO                   217\n# define SSL_R_REUSE_CIPHER_LIST_NOT_ZERO                 218\n# define SSL_R_SCSV_RECEIVED_WHEN_RENEGOTIATING           345\n# define SSL_R_SERVERHELLO_TLSEXT                         275\n# define SSL_R_SESSION_ID_CONTEXT_UNINITIALIZED           277\n# define SSL_R_SHORT_READ                                 219\n# define SSL_R_SHUTDOWN_WHILE_IN_INIT                     407\n# define SSL_R_SIGNATURE_ALGORITHMS_ERROR                 360\n# define SSL_R_SIGNATURE_FOR_NON_SIGNING_CERTIFICATE      220\n# define SSL_R_SRP_A_CALC                                 361\n# define SSL_R_SRTP_COULD_NOT_ALLOCATE_PROFILES           362\n# define SSL_R_SRTP_PROTECTION_PROFILE_LIST_TOO_LONG      363\n# define SSL_R_SRTP_UNKNOWN_PROTECTION_PROFILE            364\n# define SSL_R_SSL23_DOING_SESSION_ID_REUSE               221\n# define SSL_R_SSL2_CONNECTION_ID_TOO_LONG                299\n# define SSL_R_SSL3_EXT_INVALID_ECPOINTFORMAT             321\n# define SSL_R_SSL3_EXT_INVALID_SERVERNAME                319\n# define SSL_R_SSL3_EXT_INVALID_SERVERNAME_TYPE           320\n# define SSL_R_SSL3_SESSION_ID_TOO_LONG                   300\n# define SSL_R_SSL3_SESSION_ID_TOO_SHORT                  222\n# define SSL_R_SSLV3_ALERT_BAD_CERTIFICATE                1042\n# define SSL_R_SSLV3_ALERT_BAD_RECORD_MAC                 1020\n# define SSL_R_SSLV3_ALERT_CERTIFICATE_EXPIRED            1045\n# define SSL_R_SSLV3_ALERT_CERTIFICATE_REVOKED            1044\n# define SSL_R_SSLV3_ALERT_CERTIFICATE_UNKNOWN            1046\n# define SSL_R_SSLV3_ALERT_DECOMPRESSION_FAILURE          1030\n# define SSL_R_SSLV3_ALERT_HANDSHAKE_FAILURE              1040\n# define SSL_R_SSLV3_ALERT_ILLEGAL_PARAMETER              1047\n# define SSL_R_SSLV3_ALERT_NO_CERTIFICATE                 1041\n# define SSL_R_SSLV3_ALERT_UNEXPECTED_MESSAGE             1010\n# define SSL_R_SSLV3_ALERT_UNSUPPORTED_CERTIFICATE        1043\n# define SSL_R_SSL_CTX_HAS_NO_DEFAULT_SSL_VERSION         228\n# define SSL_R_SSL_HANDSHAKE_FAILURE                      229\n# define SSL_R_SSL_LIBRARY_HAS_NO_CIPHERS                 230\n# define SSL_R_SSL_SESSION_ID_CALLBACK_FAILED             301\n# define SSL_R_SSL_SESSION_ID_CONFLICT                    302\n# define SSL_R_SSL_SESSION_ID_CONTEXT_TOO_LONG            273\n# define SSL_R_SSL_SESSION_ID_HAS_BAD_LENGTH              303\n# define SSL_R_SSL_SESSION_ID_IS_DIFFERENT                231\n# define SSL_R_TLSV1_ALERT_ACCESS_DENIED                  1049\n# define SSL_R_TLSV1_ALERT_DECODE_ERROR                   1050\n# define SSL_R_TLSV1_ALERT_DECRYPTION_FAILED              1021\n# define SSL_R_TLSV1_ALERT_DECRYPT_ERROR                  1051\n# define SSL_R_TLSV1_ALERT_EXPORT_RESTRICTION             1060\n# define SSL_R_TLSV1_ALERT_INAPPROPRIATE_FALLBACK         1086\n# define SSL_R_TLSV1_ALERT_INSUFFICIENT_SECURITY          1071\n# define SSL_R_TLSV1_ALERT_INTERNAL_ERROR                 1080\n# define SSL_R_TLSV1_ALERT_NO_RENEGOTIATION               1100\n# define SSL_R_TLSV1_ALERT_PROTOCOL_VERSION               1070\n# define SSL_R_TLSV1_ALERT_RECORD_OVERFLOW                1022\n# define SSL_R_TLSV1_ALERT_UNKNOWN_CA                     1048\n# define SSL_R_TLSV1_ALERT_USER_CANCELLED                 1090\n# define SSL_R_TLSV1_BAD_CERTIFICATE_HASH_VALUE           1114\n# define SSL_R_TLSV1_BAD_CERTIFICATE_STATUS_RESPONSE      1113\n# define SSL_R_TLSV1_CERTIFICATE_UNOBTAINABLE             1111\n# define SSL_R_TLSV1_UNRECOGNIZED_NAME                    1112\n# define SSL_R_TLSV1_UNSUPPORTED_EXTENSION                1110\n# define SSL_R_TLS_CLIENT_CERT_REQ_WITH_ANON_CIPHER       232\n# define SSL_R_TLS_HEARTBEAT_PEER_DOESNT_ACCEPT           365\n# define SSL_R_TLS_HEARTBEAT_PENDING                      366\n# define SSL_R_TLS_ILLEGAL_EXPORTER_LABEL                 367\n# define SSL_R_TLS_INVALID_ECPOINTFORMAT_LIST             157\n# define SSL_R_TLS_PEER_DID_NOT_RESPOND_WITH_CERTIFICATE_LIST 233\n# define SSL_R_TLS_RSA_ENCRYPTED_VALUE_LENGTH_IS_WRONG    234\n# define SSL_R_TRIED_TO_USE_UNSUPPORTED_CIPHER            235\n# define SSL_R_UNABLE_TO_DECODE_DH_CERTS                  236\n# define SSL_R_UNABLE_TO_DECODE_ECDH_CERTS                313\n# define SSL_R_UNABLE_TO_EXTRACT_PUBLIC_KEY               237\n# define SSL_R_UNABLE_TO_FIND_DH_PARAMETERS               238\n# define SSL_R_UNABLE_TO_FIND_ECDH_PARAMETERS             314\n# define SSL_R_UNABLE_TO_FIND_PUBLIC_KEY_PARAMETERS       239\n# define SSL_R_UNABLE_TO_FIND_SSL_METHOD                  240\n# define SSL_R_UNABLE_TO_LOAD_SSL2_MD5_ROUTINES           241\n# define SSL_R_UNABLE_TO_LOAD_SSL3_MD5_ROUTINES           242\n# define SSL_R_UNABLE_TO_LOAD_SSL3_SHA1_ROUTINES          243\n# define SSL_R_UNEXPECTED_MESSAGE                         244\n# define SSL_R_UNEXPECTED_RECORD                          245\n# define SSL_R_UNINITIALIZED                              276\n# define SSL_R_UNKNOWN_ALERT_TYPE                         246\n# define SSL_R_UNKNOWN_CERTIFICATE_TYPE                   247\n# define SSL_R_UNKNOWN_CIPHER_RETURNED                    248\n# define SSL_R_UNKNOWN_CIPHER_TYPE                        249\n# define SSL_R_UNKNOWN_CMD_NAME                           386\n# define SSL_R_UNKNOWN_DIGEST                             368\n# define SSL_R_UNKNOWN_KEY_EXCHANGE_TYPE                  250\n# define SSL_R_UNKNOWN_PKEY_TYPE                          251\n# define SSL_R_UNKNOWN_PROTOCOL                           252\n# define SSL_R_UNKNOWN_REMOTE_ERROR_TYPE                  253\n# define SSL_R_UNKNOWN_SSL_VERSION                        254\n# define SSL_R_UNKNOWN_STATE                              255\n# define SSL_R_UNSAFE_LEGACY_RENEGOTIATION_DISABLED       338\n# define SSL_R_UNSUPPORTED_CIPHER                         256\n# define SSL_R_UNSUPPORTED_COMPRESSION_ALGORITHM          257\n# define SSL_R_UNSUPPORTED_DIGEST_TYPE                    326\n# define SSL_R_UNSUPPORTED_ELLIPTIC_CURVE                 315\n# define SSL_R_UNSUPPORTED_PROTOCOL                       258\n# define SSL_R_UNSUPPORTED_SSL_VERSION                    259\n# define SSL_R_UNSUPPORTED_STATUS_TYPE                    329\n# define SSL_R_USE_SRTP_NOT_NEGOTIATED                    369\n# define SSL_R_WRITE_BIO_NOT_SET                          260\n# define SSL_R_WRONG_CERTIFICATE_TYPE                     383\n# define SSL_R_WRONG_CIPHER_RETURNED                      261\n# define SSL_R_WRONG_CURVE                                378\n# define SSL_R_WRONG_MESSAGE_TYPE                         262\n# define SSL_R_WRONG_NUMBER_OF_KEY_BITS                   263\n# define SSL_R_WRONG_SIGNATURE_LENGTH                     264\n# define SSL_R_WRONG_SIGNATURE_SIZE                       265\n# define SSL_R_WRONG_SIGNATURE_TYPE                       370\n# define SSL_R_WRONG_SSL_VERSION                          266\n# define SSL_R_WRONG_VERSION_NUMBER                       267\n# define SSL_R_X509_LIB                                   268\n# define SSL_R_X509_VERIFICATION_SETUP_PROBLEMS           269\n\n#ifdef  __cplusplus\n}\n#endif\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/arm64/include/openssl/ssl2.h",
    "content": "/* ssl/ssl2.h */\n/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)\n * All rights reserved.\n *\n * This package is an SSL implementation written\n * by Eric Young (eay@cryptsoft.com).\n * The implementation was written so as to conform with Netscapes SSL.\n *\n * This library is free for commercial and non-commercial use as long as\n * the following conditions are aheared to.  The following conditions\n * apply to all code found in this distribution, be it the RC4, RSA,\n * lhash, DES, etc., code; not just the SSL code.  The SSL documentation\n * included with this distribution is covered by the same copyright terms\n * except that the holder is Tim Hudson (tjh@cryptsoft.com).\n *\n * Copyright remains Eric Young's, and as such any Copyright notices in\n * the code are not to be removed.\n * If this package is used in a product, Eric Young should be given attribution\n * as the author of the parts of the library used.\n * This can be in the form of a textual message at program startup or\n * in documentation (online or textual) provided with the package.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the copyright\n *    notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in the\n *    documentation and/or other materials provided with the distribution.\n * 3. All advertising materials mentioning features or use of this software\n *    must display the following acknowledgement:\n *    \"This product includes cryptographic software written by\n *     Eric Young (eay@cryptsoft.com)\"\n *    The word 'cryptographic' can be left out if the rouines from the library\n *    being used are not cryptographic related :-).\n * 4. If you include any Windows specific code (or a derivative thereof) from\n *    the apps directory (application code) you must include an acknowledgement:\n *    \"This product includes software written by Tim Hudson (tjh@cryptsoft.com)\"\n *\n * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n * SUCH DAMAGE.\n *\n * The licence and distribution terms for any publically available version or\n * derivative of this code cannot be changed.  i.e. this code cannot simply be\n * copied and put under another distribution licence\n * [including the GNU Public Licence.]\n */\n\n#ifndef HEADER_SSL2_H\n# define HEADER_SSL2_H\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n/* Protocol Version Codes */\n# define SSL2_VERSION            0x0002\n# define SSL2_VERSION_MAJOR      0x00\n# define SSL2_VERSION_MINOR      0x02\n/* #define SSL2_CLIENT_VERSION  0x0002 */\n/* #define SSL2_SERVER_VERSION  0x0002 */\n\n/* Protocol Message Codes */\n# define SSL2_MT_ERROR                   0\n# define SSL2_MT_CLIENT_HELLO            1\n# define SSL2_MT_CLIENT_MASTER_KEY       2\n# define SSL2_MT_CLIENT_FINISHED         3\n# define SSL2_MT_SERVER_HELLO            4\n# define SSL2_MT_SERVER_VERIFY           5\n# define SSL2_MT_SERVER_FINISHED         6\n# define SSL2_MT_REQUEST_CERTIFICATE     7\n# define SSL2_MT_CLIENT_CERTIFICATE      8\n\n/* Error Message Codes */\n# define SSL2_PE_UNDEFINED_ERROR         0x0000\n# define SSL2_PE_NO_CIPHER               0x0001\n# define SSL2_PE_NO_CERTIFICATE          0x0002\n# define SSL2_PE_BAD_CERTIFICATE         0x0004\n# define SSL2_PE_UNSUPPORTED_CERTIFICATE_TYPE 0x0006\n\n/* Cipher Kind Values */\n# define SSL2_CK_NULL_WITH_MD5                   0x02000000/* v3 */\n# define SSL2_CK_RC4_128_WITH_MD5                0x02010080\n# define SSL2_CK_RC4_128_EXPORT40_WITH_MD5       0x02020080\n# define SSL2_CK_RC2_128_CBC_WITH_MD5            0x02030080\n# define SSL2_CK_RC2_128_CBC_EXPORT40_WITH_MD5   0x02040080\n# define SSL2_CK_IDEA_128_CBC_WITH_MD5           0x02050080\n# define SSL2_CK_DES_64_CBC_WITH_MD5             0x02060040\n# define SSL2_CK_DES_64_CBC_WITH_SHA             0x02060140/* v3 */\n# define SSL2_CK_DES_192_EDE3_CBC_WITH_MD5       0x020700c0\n# define SSL2_CK_DES_192_EDE3_CBC_WITH_SHA       0x020701c0/* v3 */\n# define SSL2_CK_RC4_64_WITH_MD5                 0x02080080/* MS hack */\n\n# define SSL2_CK_DES_64_CFB64_WITH_MD5_1         0x02ff0800/* SSLeay */\n# define SSL2_CK_NULL                            0x02ff0810/* SSLeay */\n\n# define SSL2_TXT_DES_64_CFB64_WITH_MD5_1        \"DES-CFB-M1\"\n# define SSL2_TXT_NULL_WITH_MD5                  \"NULL-MD5\"\n# define SSL2_TXT_RC4_128_WITH_MD5               \"RC4-MD5\"\n# define SSL2_TXT_RC4_128_EXPORT40_WITH_MD5      \"EXP-RC4-MD5\"\n# define SSL2_TXT_RC2_128_CBC_WITH_MD5           \"RC2-CBC-MD5\"\n# define SSL2_TXT_RC2_128_CBC_EXPORT40_WITH_MD5  \"EXP-RC2-CBC-MD5\"\n# define SSL2_TXT_IDEA_128_CBC_WITH_MD5          \"IDEA-CBC-MD5\"\n# define SSL2_TXT_DES_64_CBC_WITH_MD5            \"DES-CBC-MD5\"\n# define SSL2_TXT_DES_64_CBC_WITH_SHA            \"DES-CBC-SHA\"\n# define SSL2_TXT_DES_192_EDE3_CBC_WITH_MD5      \"DES-CBC3-MD5\"\n# define SSL2_TXT_DES_192_EDE3_CBC_WITH_SHA      \"DES-CBC3-SHA\"\n# define SSL2_TXT_RC4_64_WITH_MD5                \"RC4-64-MD5\"\n\n# define SSL2_TXT_NULL                           \"NULL\"\n\n/* Flags for the SSL_CIPHER.algorithm2 field */\n# define SSL2_CF_5_BYTE_ENC                      0x01\n# define SSL2_CF_8_BYTE_ENC                      0x02\n\n/* Certificate Type Codes */\n# define SSL2_CT_X509_CERTIFICATE                0x01\n\n/* Authentication Type Code */\n# define SSL2_AT_MD5_WITH_RSA_ENCRYPTION         0x01\n\n# define SSL2_MAX_SSL_SESSION_ID_LENGTH          32\n\n/* Upper/Lower Bounds */\n# define SSL2_MAX_MASTER_KEY_LENGTH_IN_BITS      256\n# ifdef OPENSSL_SYS_MPE\n#  define SSL2_MAX_RECORD_LENGTH_2_BYTE_HEADER    29998u\n# else\n#  define SSL2_MAX_RECORD_LENGTH_2_BYTE_HEADER    32767u\n                                                       /* 2^15-1 */\n# endif\n# define SSL2_MAX_RECORD_LENGTH_3_BYTE_HEADER    16383/* 2^14-1 */\n\n# define SSL2_CHALLENGE_LENGTH   16\n/*\n * #define SSL2_CHALLENGE_LENGTH 32\n */\n# define SSL2_MIN_CHALLENGE_LENGTH       16\n# define SSL2_MAX_CHALLENGE_LENGTH       32\n# define SSL2_CONNECTION_ID_LENGTH       16\n# define SSL2_MAX_CONNECTION_ID_LENGTH   16\n# define SSL2_SSL_SESSION_ID_LENGTH      16\n# define SSL2_MAX_CERT_CHALLENGE_LENGTH  32\n# define SSL2_MIN_CERT_CHALLENGE_LENGTH  16\n# define SSL2_MAX_KEY_MATERIAL_LENGTH    24\n\n# ifndef HEADER_SSL_LOCL_H\n#  define  CERT           char\n# endif\n\n# ifndef OPENSSL_NO_SSL_INTERN\n\ntypedef struct ssl2_state_st {\n    int three_byte_header;\n    int clear_text;             /* clear text */\n    int escape;                 /* not used in SSLv2 */\n    int ssl2_rollback;          /* used if SSLv23 rolled back to SSLv2 */\n    /*\n     * non-blocking io info, used to make sure the same args were passwd\n     */\n    unsigned int wnum;          /* number of bytes sent so far */\n    int wpend_tot;\n    const unsigned char *wpend_buf;\n    int wpend_off;              /* offset to data to write */\n    int wpend_len;              /* number of bytes passwd to write */\n    int wpend_ret;              /* number of bytes to return to caller */\n    /* buffer raw data */\n    int rbuf_left;\n    int rbuf_offs;\n    unsigned char *rbuf;\n    unsigned char *wbuf;\n    unsigned char *write_ptr;   /* used to point to the start due to 2/3 byte\n                                 * header. */\n    unsigned int padding;\n    unsigned int rlength;       /* passed to ssl2_enc */\n    int ract_data_length;       /* Set when things are encrypted. */\n    unsigned int wlength;       /* passed to ssl2_enc */\n    int wact_data_length;       /* Set when things are decrypted. */\n    unsigned char *ract_data;\n    unsigned char *wact_data;\n    unsigned char *mac_data;\n    unsigned char *read_key;\n    unsigned char *write_key;\n    /* Stuff specifically to do with this SSL session */\n    unsigned int challenge_length;\n    unsigned char challenge[SSL2_MAX_CHALLENGE_LENGTH];\n    unsigned int conn_id_length;\n    unsigned char conn_id[SSL2_MAX_CONNECTION_ID_LENGTH];\n    unsigned int key_material_length;\n    unsigned char key_material[SSL2_MAX_KEY_MATERIAL_LENGTH * 2];\n    unsigned long read_sequence;\n    unsigned long write_sequence;\n    struct {\n        unsigned int conn_id_length;\n        unsigned int cert_type;\n        unsigned int cert_length;\n        unsigned int csl;\n        unsigned int clear;\n        unsigned int enc;\n        unsigned char ccl[SSL2_MAX_CERT_CHALLENGE_LENGTH];\n        unsigned int cipher_spec_length;\n        unsigned int session_id_length;\n        unsigned int clen;\n        unsigned int rlen;\n    } tmp;\n} SSL2_STATE;\n\n# endif\n\n/* SSLv2 */\n/* client */\n# define SSL2_ST_SEND_CLIENT_HELLO_A             (0x10|SSL_ST_CONNECT)\n# define SSL2_ST_SEND_CLIENT_HELLO_B             (0x11|SSL_ST_CONNECT)\n# define SSL2_ST_GET_SERVER_HELLO_A              (0x20|SSL_ST_CONNECT)\n# define SSL2_ST_GET_SERVER_HELLO_B              (0x21|SSL_ST_CONNECT)\n# define SSL2_ST_SEND_CLIENT_MASTER_KEY_A        (0x30|SSL_ST_CONNECT)\n# define SSL2_ST_SEND_CLIENT_MASTER_KEY_B        (0x31|SSL_ST_CONNECT)\n# define SSL2_ST_SEND_CLIENT_FINISHED_A          (0x40|SSL_ST_CONNECT)\n# define SSL2_ST_SEND_CLIENT_FINISHED_B          (0x41|SSL_ST_CONNECT)\n# define SSL2_ST_SEND_CLIENT_CERTIFICATE_A       (0x50|SSL_ST_CONNECT)\n# define SSL2_ST_SEND_CLIENT_CERTIFICATE_B       (0x51|SSL_ST_CONNECT)\n# define SSL2_ST_SEND_CLIENT_CERTIFICATE_C       (0x52|SSL_ST_CONNECT)\n# define SSL2_ST_SEND_CLIENT_CERTIFICATE_D       (0x53|SSL_ST_CONNECT)\n# define SSL2_ST_GET_SERVER_VERIFY_A             (0x60|SSL_ST_CONNECT)\n# define SSL2_ST_GET_SERVER_VERIFY_B             (0x61|SSL_ST_CONNECT)\n# define SSL2_ST_GET_SERVER_FINISHED_A           (0x70|SSL_ST_CONNECT)\n# define SSL2_ST_GET_SERVER_FINISHED_B           (0x71|SSL_ST_CONNECT)\n# define SSL2_ST_CLIENT_START_ENCRYPTION         (0x80|SSL_ST_CONNECT)\n# define SSL2_ST_X509_GET_CLIENT_CERTIFICATE     (0x90|SSL_ST_CONNECT)\n/* server */\n# define SSL2_ST_GET_CLIENT_HELLO_A              (0x10|SSL_ST_ACCEPT)\n# define SSL2_ST_GET_CLIENT_HELLO_B              (0x11|SSL_ST_ACCEPT)\n# define SSL2_ST_GET_CLIENT_HELLO_C              (0x12|SSL_ST_ACCEPT)\n# define SSL2_ST_SEND_SERVER_HELLO_A             (0x20|SSL_ST_ACCEPT)\n# define SSL2_ST_SEND_SERVER_HELLO_B             (0x21|SSL_ST_ACCEPT)\n# define SSL2_ST_GET_CLIENT_MASTER_KEY_A         (0x30|SSL_ST_ACCEPT)\n# define SSL2_ST_GET_CLIENT_MASTER_KEY_B         (0x31|SSL_ST_ACCEPT)\n# define SSL2_ST_SEND_SERVER_VERIFY_A            (0x40|SSL_ST_ACCEPT)\n# define SSL2_ST_SEND_SERVER_VERIFY_B            (0x41|SSL_ST_ACCEPT)\n# define SSL2_ST_SEND_SERVER_VERIFY_C            (0x42|SSL_ST_ACCEPT)\n# define SSL2_ST_GET_CLIENT_FINISHED_A           (0x50|SSL_ST_ACCEPT)\n# define SSL2_ST_GET_CLIENT_FINISHED_B           (0x51|SSL_ST_ACCEPT)\n# define SSL2_ST_SEND_SERVER_FINISHED_A          (0x60|SSL_ST_ACCEPT)\n# define SSL2_ST_SEND_SERVER_FINISHED_B          (0x61|SSL_ST_ACCEPT)\n# define SSL2_ST_SEND_REQUEST_CERTIFICATE_A      (0x70|SSL_ST_ACCEPT)\n# define SSL2_ST_SEND_REQUEST_CERTIFICATE_B      (0x71|SSL_ST_ACCEPT)\n# define SSL2_ST_SEND_REQUEST_CERTIFICATE_C      (0x72|SSL_ST_ACCEPT)\n# define SSL2_ST_SEND_REQUEST_CERTIFICATE_D      (0x73|SSL_ST_ACCEPT)\n# define SSL2_ST_SERVER_START_ENCRYPTION         (0x80|SSL_ST_ACCEPT)\n# define SSL2_ST_X509_GET_SERVER_CERTIFICATE     (0x90|SSL_ST_ACCEPT)\n\n#ifdef  __cplusplus\n}\n#endif\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/arm64/include/openssl/ssl23.h",
    "content": "/* ssl/ssl23.h */\n/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)\n * All rights reserved.\n *\n * This package is an SSL implementation written\n * by Eric Young (eay@cryptsoft.com).\n * The implementation was written so as to conform with Netscapes SSL.\n *\n * This library is free for commercial and non-commercial use as long as\n * the following conditions are aheared to.  The following conditions\n * apply to all code found in this distribution, be it the RC4, RSA,\n * lhash, DES, etc., code; not just the SSL code.  The SSL documentation\n * included with this distribution is covered by the same copyright terms\n * except that the holder is Tim Hudson (tjh@cryptsoft.com).\n *\n * Copyright remains Eric Young's, and as such any Copyright notices in\n * the code are not to be removed.\n * If this package is used in a product, Eric Young should be given attribution\n * as the author of the parts of the library used.\n * This can be in the form of a textual message at program startup or\n * in documentation (online or textual) provided with the package.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the copyright\n *    notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in the\n *    documentation and/or other materials provided with the distribution.\n * 3. All advertising materials mentioning features or use of this software\n *    must display the following acknowledgement:\n *    \"This product includes cryptographic software written by\n *     Eric Young (eay@cryptsoft.com)\"\n *    The word 'cryptographic' can be left out if the rouines from the library\n *    being used are not cryptographic related :-).\n * 4. If you include any Windows specific code (or a derivative thereof) from\n *    the apps directory (application code) you must include an acknowledgement:\n *    \"This product includes software written by Tim Hudson (tjh@cryptsoft.com)\"\n *\n * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n * SUCH DAMAGE.\n *\n * The licence and distribution terms for any publically available version or\n * derivative of this code cannot be changed.  i.e. this code cannot simply be\n * copied and put under another distribution licence\n * [including the GNU Public Licence.]\n */\n\n#ifndef HEADER_SSL23_H\n# define HEADER_SSL23_H\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n/*\n * client\n */\n/* write to server */\n# define SSL23_ST_CW_CLNT_HELLO_A        (0x210|SSL_ST_CONNECT)\n# define SSL23_ST_CW_CLNT_HELLO_B        (0x211|SSL_ST_CONNECT)\n/* read from server */\n# define SSL23_ST_CR_SRVR_HELLO_A        (0x220|SSL_ST_CONNECT)\n# define SSL23_ST_CR_SRVR_HELLO_B        (0x221|SSL_ST_CONNECT)\n\n/* server */\n/* read from client */\n# define SSL23_ST_SR_CLNT_HELLO_A        (0x210|SSL_ST_ACCEPT)\n# define SSL23_ST_SR_CLNT_HELLO_B        (0x211|SSL_ST_ACCEPT)\n\n#ifdef  __cplusplus\n}\n#endif\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/arm64/include/openssl/ssl3.h",
    "content": "/* ssl/ssl3.h */\n/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)\n * All rights reserved.\n *\n * This package is an SSL implementation written\n * by Eric Young (eay@cryptsoft.com).\n * The implementation was written so as to conform with Netscapes SSL.\n *\n * This library is free for commercial and non-commercial use as long as\n * the following conditions are aheared to.  The following conditions\n * apply to all code found in this distribution, be it the RC4, RSA,\n * lhash, DES, etc., code; not just the SSL code.  The SSL documentation\n * included with this distribution is covered by the same copyright terms\n * except that the holder is Tim Hudson (tjh@cryptsoft.com).\n *\n * Copyright remains Eric Young's, and as such any Copyright notices in\n * the code are not to be removed.\n * If this package is used in a product, Eric Young should be given attribution\n * as the author of the parts of the library used.\n * This can be in the form of a textual message at program startup or\n * in documentation (online or textual) provided with the package.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the copyright\n *    notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in the\n *    documentation and/or other materials provided with the distribution.\n * 3. All advertising materials mentioning features or use of this software\n *    must display the following acknowledgement:\n *    \"This product includes cryptographic software written by\n *     Eric Young (eay@cryptsoft.com)\"\n *    The word 'cryptographic' can be left out if the rouines from the library\n *    being used are not cryptographic related :-).\n * 4. If you include any Windows specific code (or a derivative thereof) from\n *    the apps directory (application code) you must include an acknowledgement:\n *    \"This product includes software written by Tim Hudson (tjh@cryptsoft.com)\"\n *\n * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n * SUCH DAMAGE.\n *\n * The licence and distribution terms for any publically available version or\n * derivative of this code cannot be changed.  i.e. this code cannot simply be\n * copied and put under another distribution licence\n * [including the GNU Public Licence.]\n */\n/* ====================================================================\n * Copyright (c) 1998-2002 The OpenSSL Project.  All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n *\n * 1. Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n *\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in\n *    the documentation and/or other materials provided with the\n *    distribution.\n *\n * 3. All advertising materials mentioning features or use of this\n *    software must display the following acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit. (http://www.openssl.org/)\"\n *\n * 4. The names \"OpenSSL Toolkit\" and \"OpenSSL Project\" must not be used to\n *    endorse or promote products derived from this software without\n *    prior written permission. For written permission, please contact\n *    openssl-core@openssl.org.\n *\n * 5. Products derived from this software may not be called \"OpenSSL\"\n *    nor may \"OpenSSL\" appear in their names without prior written\n *    permission of the OpenSSL Project.\n *\n * 6. Redistributions of any form whatsoever must retain the following\n *    acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit (http://www.openssl.org/)\"\n *\n * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY\n * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\n * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR\n * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\n * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,\n * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED\n * OF THE POSSIBILITY OF SUCH DAMAGE.\n * ====================================================================\n *\n * This product includes cryptographic software written by Eric Young\n * (eay@cryptsoft.com).  This product includes software written by Tim\n * Hudson (tjh@cryptsoft.com).\n *\n */\n/* ====================================================================\n * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED.\n * ECC cipher suite support in OpenSSL originally developed by\n * SUN MICROSYSTEMS, INC., and contributed to the OpenSSL project.\n */\n\n#ifndef HEADER_SSL3_H\n# define HEADER_SSL3_H\n\n# ifndef OPENSSL_NO_COMP\n#  include <openssl/comp.h>\n# endif\n# include <openssl/buffer.h>\n# include <openssl/evp.h>\n# include <openssl/ssl.h>\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n/*\n * Signalling cipher suite value from RFC 5746\n * (TLS_EMPTY_RENEGOTIATION_INFO_SCSV)\n */\n# define SSL3_CK_SCSV                            0x030000FF\n\n/*\n * Signalling cipher suite value from draft-ietf-tls-downgrade-scsv-00\n * (TLS_FALLBACK_SCSV)\n */\n# define SSL3_CK_FALLBACK_SCSV                   0x03005600\n\n# define SSL3_CK_RSA_NULL_MD5                    0x03000001\n# define SSL3_CK_RSA_NULL_SHA                    0x03000002\n# define SSL3_CK_RSA_RC4_40_MD5                  0x03000003\n# define SSL3_CK_RSA_RC4_128_MD5                 0x03000004\n# define SSL3_CK_RSA_RC4_128_SHA                 0x03000005\n# define SSL3_CK_RSA_RC2_40_MD5                  0x03000006\n# define SSL3_CK_RSA_IDEA_128_SHA                0x03000007\n# define SSL3_CK_RSA_DES_40_CBC_SHA              0x03000008\n# define SSL3_CK_RSA_DES_64_CBC_SHA              0x03000009\n# define SSL3_CK_RSA_DES_192_CBC3_SHA            0x0300000A\n\n# define SSL3_CK_DH_DSS_DES_40_CBC_SHA           0x0300000B\n# define SSL3_CK_DH_DSS_DES_64_CBC_SHA           0x0300000C\n# define SSL3_CK_DH_DSS_DES_192_CBC3_SHA         0x0300000D\n# define SSL3_CK_DH_RSA_DES_40_CBC_SHA           0x0300000E\n# define SSL3_CK_DH_RSA_DES_64_CBC_SHA           0x0300000F\n# define SSL3_CK_DH_RSA_DES_192_CBC3_SHA         0x03000010\n\n# define SSL3_CK_EDH_DSS_DES_40_CBC_SHA          0x03000011\n# define SSL3_CK_DHE_DSS_DES_40_CBC_SHA          SSL3_CK_EDH_DSS_DES_40_CBC_SHA\n# define SSL3_CK_EDH_DSS_DES_64_CBC_SHA          0x03000012\n# define SSL3_CK_DHE_DSS_DES_64_CBC_SHA          SSL3_CK_EDH_DSS_DES_64_CBC_SHA\n# define SSL3_CK_EDH_DSS_DES_192_CBC3_SHA        0x03000013\n# define SSL3_CK_DHE_DSS_DES_192_CBC3_SHA        SSL3_CK_EDH_DSS_DES_192_CBC3_SHA\n# define SSL3_CK_EDH_RSA_DES_40_CBC_SHA          0x03000014\n# define SSL3_CK_DHE_RSA_DES_40_CBC_SHA          SSL3_CK_EDH_RSA_DES_40_CBC_SHA\n# define SSL3_CK_EDH_RSA_DES_64_CBC_SHA          0x03000015\n# define SSL3_CK_DHE_RSA_DES_64_CBC_SHA          SSL3_CK_EDH_RSA_DES_64_CBC_SHA\n# define SSL3_CK_EDH_RSA_DES_192_CBC3_SHA        0x03000016\n# define SSL3_CK_DHE_RSA_DES_192_CBC3_SHA        SSL3_CK_EDH_RSA_DES_192_CBC3_SHA\n\n# define SSL3_CK_ADH_RC4_40_MD5                  0x03000017\n# define SSL3_CK_ADH_RC4_128_MD5                 0x03000018\n# define SSL3_CK_ADH_DES_40_CBC_SHA              0x03000019\n# define SSL3_CK_ADH_DES_64_CBC_SHA              0x0300001A\n# define SSL3_CK_ADH_DES_192_CBC_SHA             0x0300001B\n\n# if 0\n#  define SSL3_CK_FZA_DMS_NULL_SHA                0x0300001C\n#  define SSL3_CK_FZA_DMS_FZA_SHA                 0x0300001D\n#  if 0                         /* Because it clashes with KRB5, is never\n                                 * used any more, and is safe to remove\n                                 * according to David Hopwood\n                                 * <david.hopwood@zetnet.co.uk> of the\n                                 * ietf-tls list */\n#   define SSL3_CK_FZA_DMS_RC4_SHA                 0x0300001E\n#  endif\n# endif\n\n/*\n * VRS Additional Kerberos5 entries\n */\n# define SSL3_CK_KRB5_DES_64_CBC_SHA             0x0300001E\n# define SSL3_CK_KRB5_DES_192_CBC3_SHA           0x0300001F\n# define SSL3_CK_KRB5_RC4_128_SHA                0x03000020\n# define SSL3_CK_KRB5_IDEA_128_CBC_SHA           0x03000021\n# define SSL3_CK_KRB5_DES_64_CBC_MD5             0x03000022\n# define SSL3_CK_KRB5_DES_192_CBC3_MD5           0x03000023\n# define SSL3_CK_KRB5_RC4_128_MD5                0x03000024\n# define SSL3_CK_KRB5_IDEA_128_CBC_MD5           0x03000025\n\n# define SSL3_CK_KRB5_DES_40_CBC_SHA             0x03000026\n# define SSL3_CK_KRB5_RC2_40_CBC_SHA             0x03000027\n# define SSL3_CK_KRB5_RC4_40_SHA                 0x03000028\n# define SSL3_CK_KRB5_DES_40_CBC_MD5             0x03000029\n# define SSL3_CK_KRB5_RC2_40_CBC_MD5             0x0300002A\n# define SSL3_CK_KRB5_RC4_40_MD5                 0x0300002B\n\n# define SSL3_TXT_RSA_NULL_MD5                   \"NULL-MD5\"\n# define SSL3_TXT_RSA_NULL_SHA                   \"NULL-SHA\"\n# define SSL3_TXT_RSA_RC4_40_MD5                 \"EXP-RC4-MD5\"\n# define SSL3_TXT_RSA_RC4_128_MD5                \"RC4-MD5\"\n# define SSL3_TXT_RSA_RC4_128_SHA                \"RC4-SHA\"\n# define SSL3_TXT_RSA_RC2_40_MD5                 \"EXP-RC2-CBC-MD5\"\n# define SSL3_TXT_RSA_IDEA_128_SHA               \"IDEA-CBC-SHA\"\n# define SSL3_TXT_RSA_DES_40_CBC_SHA             \"EXP-DES-CBC-SHA\"\n# define SSL3_TXT_RSA_DES_64_CBC_SHA             \"DES-CBC-SHA\"\n# define SSL3_TXT_RSA_DES_192_CBC3_SHA           \"DES-CBC3-SHA\"\n\n# define SSL3_TXT_DH_DSS_DES_40_CBC_SHA          \"EXP-DH-DSS-DES-CBC-SHA\"\n# define SSL3_TXT_DH_DSS_DES_64_CBC_SHA          \"DH-DSS-DES-CBC-SHA\"\n# define SSL3_TXT_DH_DSS_DES_192_CBC3_SHA        \"DH-DSS-DES-CBC3-SHA\"\n# define SSL3_TXT_DH_RSA_DES_40_CBC_SHA          \"EXP-DH-RSA-DES-CBC-SHA\"\n# define SSL3_TXT_DH_RSA_DES_64_CBC_SHA          \"DH-RSA-DES-CBC-SHA\"\n# define SSL3_TXT_DH_RSA_DES_192_CBC3_SHA        \"DH-RSA-DES-CBC3-SHA\"\n\n# define SSL3_TXT_DHE_DSS_DES_40_CBC_SHA         \"EXP-DHE-DSS-DES-CBC-SHA\"\n# define SSL3_TXT_DHE_DSS_DES_64_CBC_SHA         \"DHE-DSS-DES-CBC-SHA\"\n# define SSL3_TXT_DHE_DSS_DES_192_CBC3_SHA       \"DHE-DSS-DES-CBC3-SHA\"\n# define SSL3_TXT_DHE_RSA_DES_40_CBC_SHA         \"EXP-DHE-RSA-DES-CBC-SHA\"\n# define SSL3_TXT_DHE_RSA_DES_64_CBC_SHA         \"DHE-RSA-DES-CBC-SHA\"\n# define SSL3_TXT_DHE_RSA_DES_192_CBC3_SHA       \"DHE-RSA-DES-CBC3-SHA\"\n\n/*\n * This next block of six \"EDH\" labels is for backward compatibility with\n * older versions of OpenSSL.  New code should use the six \"DHE\" labels above\n * instead:\n */\n# define SSL3_TXT_EDH_DSS_DES_40_CBC_SHA         \"EXP-EDH-DSS-DES-CBC-SHA\"\n# define SSL3_TXT_EDH_DSS_DES_64_CBC_SHA         \"EDH-DSS-DES-CBC-SHA\"\n# define SSL3_TXT_EDH_DSS_DES_192_CBC3_SHA       \"EDH-DSS-DES-CBC3-SHA\"\n# define SSL3_TXT_EDH_RSA_DES_40_CBC_SHA         \"EXP-EDH-RSA-DES-CBC-SHA\"\n# define SSL3_TXT_EDH_RSA_DES_64_CBC_SHA         \"EDH-RSA-DES-CBC-SHA\"\n# define SSL3_TXT_EDH_RSA_DES_192_CBC3_SHA       \"EDH-RSA-DES-CBC3-SHA\"\n\n# define SSL3_TXT_ADH_RC4_40_MD5                 \"EXP-ADH-RC4-MD5\"\n# define SSL3_TXT_ADH_RC4_128_MD5                \"ADH-RC4-MD5\"\n# define SSL3_TXT_ADH_DES_40_CBC_SHA             \"EXP-ADH-DES-CBC-SHA\"\n# define SSL3_TXT_ADH_DES_64_CBC_SHA             \"ADH-DES-CBC-SHA\"\n# define SSL3_TXT_ADH_DES_192_CBC_SHA            \"ADH-DES-CBC3-SHA\"\n\n# if 0\n#  define SSL3_TXT_FZA_DMS_NULL_SHA               \"FZA-NULL-SHA\"\n#  define SSL3_TXT_FZA_DMS_FZA_SHA                \"FZA-FZA-CBC-SHA\"\n#  define SSL3_TXT_FZA_DMS_RC4_SHA                \"FZA-RC4-SHA\"\n# endif\n\n# define SSL3_TXT_KRB5_DES_64_CBC_SHA            \"KRB5-DES-CBC-SHA\"\n# define SSL3_TXT_KRB5_DES_192_CBC3_SHA          \"KRB5-DES-CBC3-SHA\"\n# define SSL3_TXT_KRB5_RC4_128_SHA               \"KRB5-RC4-SHA\"\n# define SSL3_TXT_KRB5_IDEA_128_CBC_SHA          \"KRB5-IDEA-CBC-SHA\"\n# define SSL3_TXT_KRB5_DES_64_CBC_MD5            \"KRB5-DES-CBC-MD5\"\n# define SSL3_TXT_KRB5_DES_192_CBC3_MD5          \"KRB5-DES-CBC3-MD5\"\n# define SSL3_TXT_KRB5_RC4_128_MD5               \"KRB5-RC4-MD5\"\n# define SSL3_TXT_KRB5_IDEA_128_CBC_MD5          \"KRB5-IDEA-CBC-MD5\"\n\n# define SSL3_TXT_KRB5_DES_40_CBC_SHA            \"EXP-KRB5-DES-CBC-SHA\"\n# define SSL3_TXT_KRB5_RC2_40_CBC_SHA            \"EXP-KRB5-RC2-CBC-SHA\"\n# define SSL3_TXT_KRB5_RC4_40_SHA                \"EXP-KRB5-RC4-SHA\"\n# define SSL3_TXT_KRB5_DES_40_CBC_MD5            \"EXP-KRB5-DES-CBC-MD5\"\n# define SSL3_TXT_KRB5_RC2_40_CBC_MD5            \"EXP-KRB5-RC2-CBC-MD5\"\n# define SSL3_TXT_KRB5_RC4_40_MD5                \"EXP-KRB5-RC4-MD5\"\n\n# define SSL3_SSL_SESSION_ID_LENGTH              32\n# define SSL3_MAX_SSL_SESSION_ID_LENGTH          32\n\n# define SSL3_MASTER_SECRET_SIZE                 48\n# define SSL3_RANDOM_SIZE                        32\n# define SSL3_SESSION_ID_SIZE                    32\n# define SSL3_RT_HEADER_LENGTH                   5\n\n# define SSL3_HM_HEADER_LENGTH                  4\n\n# ifndef SSL3_ALIGN_PAYLOAD\n /*\n  * Some will argue that this increases memory footprint, but it's not\n  * actually true. Point is that malloc has to return at least 64-bit aligned\n  * pointers, meaning that allocating 5 bytes wastes 3 bytes in either case.\n  * Suggested pre-gaping simply moves these wasted bytes from the end of\n  * allocated region to its front, but makes data payload aligned, which\n  * improves performance:-)\n  */\n#  define SSL3_ALIGN_PAYLOAD                     8\n# else\n#  if (SSL3_ALIGN_PAYLOAD&(SSL3_ALIGN_PAYLOAD-1))!=0\n#   error \"insane SSL3_ALIGN_PAYLOAD\"\n#   undef SSL3_ALIGN_PAYLOAD\n#  endif\n# endif\n\n/*\n * This is the maximum MAC (digest) size used by the SSL library. Currently\n * maximum of 20 is used by SHA1, but we reserve for future extension for\n * 512-bit hashes.\n */\n\n# define SSL3_RT_MAX_MD_SIZE                     64\n\n/*\n * Maximum block size used in all ciphersuites. Currently 16 for AES.\n */\n\n# define SSL_RT_MAX_CIPHER_BLOCK_SIZE            16\n\n# define SSL3_RT_MAX_EXTRA                       (16384)\n\n/* Maximum plaintext length: defined by SSL/TLS standards */\n# define SSL3_RT_MAX_PLAIN_LENGTH                16384\n/* Maximum compression overhead: defined by SSL/TLS standards */\n# define SSL3_RT_MAX_COMPRESSED_OVERHEAD         1024\n\n/*\n * The standards give a maximum encryption overhead of 1024 bytes. In\n * practice the value is lower than this. The overhead is the maximum number\n * of padding bytes (256) plus the mac size.\n */\n# define SSL3_RT_MAX_ENCRYPTED_OVERHEAD  (256 + SSL3_RT_MAX_MD_SIZE)\n\n/*\n * OpenSSL currently only uses a padding length of at most one block so the\n * send overhead is smaller.\n */\n\n# define SSL3_RT_SEND_MAX_ENCRYPTED_OVERHEAD \\\n                        (SSL_RT_MAX_CIPHER_BLOCK_SIZE + SSL3_RT_MAX_MD_SIZE)\n\n/* If compression isn't used don't include the compression overhead */\n\n# ifdef OPENSSL_NO_COMP\n#  define SSL3_RT_MAX_COMPRESSED_LENGTH           SSL3_RT_MAX_PLAIN_LENGTH\n# else\n#  define SSL3_RT_MAX_COMPRESSED_LENGTH   \\\n                (SSL3_RT_MAX_PLAIN_LENGTH+SSL3_RT_MAX_COMPRESSED_OVERHEAD)\n# endif\n# define SSL3_RT_MAX_ENCRYPTED_LENGTH    \\\n                (SSL3_RT_MAX_ENCRYPTED_OVERHEAD+SSL3_RT_MAX_COMPRESSED_LENGTH)\n# define SSL3_RT_MAX_PACKET_SIZE         \\\n                (SSL3_RT_MAX_ENCRYPTED_LENGTH+SSL3_RT_HEADER_LENGTH)\n\n# define SSL3_MD_CLIENT_FINISHED_CONST   \"\\x43\\x4C\\x4E\\x54\"\n# define SSL3_MD_SERVER_FINISHED_CONST   \"\\x53\\x52\\x56\\x52\"\n\n# define SSL3_VERSION                    0x0300\n# define SSL3_VERSION_MAJOR              0x03\n# define SSL3_VERSION_MINOR              0x00\n\n# define SSL3_RT_CHANGE_CIPHER_SPEC      20\n# define SSL3_RT_ALERT                   21\n# define SSL3_RT_HANDSHAKE               22\n# define SSL3_RT_APPLICATION_DATA        23\n# define TLS1_RT_HEARTBEAT               24\n\n/* Pseudo content types to indicate additional parameters */\n# define TLS1_RT_CRYPTO                  0x1000\n# define TLS1_RT_CRYPTO_PREMASTER        (TLS1_RT_CRYPTO | 0x1)\n# define TLS1_RT_CRYPTO_CLIENT_RANDOM    (TLS1_RT_CRYPTO | 0x2)\n# define TLS1_RT_CRYPTO_SERVER_RANDOM    (TLS1_RT_CRYPTO | 0x3)\n# define TLS1_RT_CRYPTO_MASTER           (TLS1_RT_CRYPTO | 0x4)\n\n# define TLS1_RT_CRYPTO_READ             0x0000\n# define TLS1_RT_CRYPTO_WRITE            0x0100\n# define TLS1_RT_CRYPTO_MAC              (TLS1_RT_CRYPTO | 0x5)\n# define TLS1_RT_CRYPTO_KEY              (TLS1_RT_CRYPTO | 0x6)\n# define TLS1_RT_CRYPTO_IV               (TLS1_RT_CRYPTO | 0x7)\n# define TLS1_RT_CRYPTO_FIXED_IV         (TLS1_RT_CRYPTO | 0x8)\n\n/* Pseudo content type for SSL/TLS header info */\n# define SSL3_RT_HEADER                  0x100\n\n# define SSL3_AL_WARNING                 1\n# define SSL3_AL_FATAL                   2\n\n# define SSL3_AD_CLOSE_NOTIFY             0\n# define SSL3_AD_UNEXPECTED_MESSAGE      10/* fatal */\n# define SSL3_AD_BAD_RECORD_MAC          20/* fatal */\n# define SSL3_AD_DECOMPRESSION_FAILURE   30/* fatal */\n# define SSL3_AD_HANDSHAKE_FAILURE       40/* fatal */\n# define SSL3_AD_NO_CERTIFICATE          41\n# define SSL3_AD_BAD_CERTIFICATE         42\n# define SSL3_AD_UNSUPPORTED_CERTIFICATE 43\n# define SSL3_AD_CERTIFICATE_REVOKED     44\n# define SSL3_AD_CERTIFICATE_EXPIRED     45\n# define SSL3_AD_CERTIFICATE_UNKNOWN     46\n# define SSL3_AD_ILLEGAL_PARAMETER       47/* fatal */\n\n# define TLS1_HB_REQUEST         1\n# define TLS1_HB_RESPONSE        2\n\n# ifndef OPENSSL_NO_SSL_INTERN\n\ntypedef struct ssl3_record_st {\n    /* type of record */\n    /*\n     * r\n     */ int type;\n    /* How many bytes available */\n    /*\n     * rw\n     */ unsigned int length;\n    /* read/write offset into 'buf' */\n    /*\n     * r\n     */ unsigned int off;\n    /* pointer to the record data */\n    /*\n     * rw\n     */ unsigned char *data;\n    /* where the decode bytes are */\n    /*\n     * rw\n     */ unsigned char *input;\n    /* only used with decompression - malloc()ed */\n    /*\n     * r\n     */ unsigned char *comp;\n    /* epoch number, needed by DTLS1 */\n    /*\n     * r\n     */ unsigned long epoch;\n    /* sequence number, needed by DTLS1 */\n    /*\n     * r\n     */ unsigned char seq_num[8];\n} SSL3_RECORD;\n\ntypedef struct ssl3_buffer_st {\n    /* at least SSL3_RT_MAX_PACKET_SIZE bytes, see ssl3_setup_buffers() */\n    unsigned char *buf;\n    /* buffer size */\n    size_t len;\n    /* where to 'copy from' */\n    int offset;\n    /* how many bytes left */\n    int left;\n} SSL3_BUFFER;\n\n# endif\n\n# define SSL3_CT_RSA_SIGN                        1\n# define SSL3_CT_DSS_SIGN                        2\n# define SSL3_CT_RSA_FIXED_DH                    3\n# define SSL3_CT_DSS_FIXED_DH                    4\n# define SSL3_CT_RSA_EPHEMERAL_DH                5\n# define SSL3_CT_DSS_EPHEMERAL_DH                6\n# define SSL3_CT_FORTEZZA_DMS                    20\n/*\n * SSL3_CT_NUMBER is used to size arrays and it must be large enough to\n * contain all of the cert types defined either for SSLv3 and TLSv1.\n */\n# define SSL3_CT_NUMBER                  9\n\n# define SSL3_FLAGS_NO_RENEGOTIATE_CIPHERS       0x0001\n# define SSL3_FLAGS_DELAY_CLIENT_FINISHED        0x0002\n# define SSL3_FLAGS_POP_BUFFER                   0x0004\n# define TLS1_FLAGS_TLS_PADDING_BUG              0x0008\n# define TLS1_FLAGS_SKIP_CERT_VERIFY             0x0010\n# define TLS1_FLAGS_KEEP_HANDSHAKE               0x0020\n/*\n * Set when the handshake is ready to process peer's ChangeCipherSpec message.\n * Cleared after the message has been processed.\n */\n# define SSL3_FLAGS_CCS_OK                       0x0080\n\n/* SSL3_FLAGS_SGC_RESTART_DONE is no longer used */\n# define SSL3_FLAGS_SGC_RESTART_DONE             0x0040\n\n# ifndef OPENSSL_NO_SSL_INTERN\n\ntypedef struct ssl3_state_st {\n    long flags;\n    int delay_buf_pop_ret;\n    unsigned char read_sequence[8];\n    int read_mac_secret_size;\n    unsigned char read_mac_secret[EVP_MAX_MD_SIZE];\n    unsigned char write_sequence[8];\n    int write_mac_secret_size;\n    unsigned char write_mac_secret[EVP_MAX_MD_SIZE];\n    unsigned char server_random[SSL3_RANDOM_SIZE];\n    unsigned char client_random[SSL3_RANDOM_SIZE];\n    /* flags for countermeasure against known-IV weakness */\n    int need_empty_fragments;\n    int empty_fragment_done;\n    /* The value of 'extra' when the buffers were initialized */\n    int init_extra;\n    SSL3_BUFFER rbuf;           /* read IO goes into here */\n    SSL3_BUFFER wbuf;           /* write IO goes into here */\n    SSL3_RECORD rrec;           /* each decoded record goes in here */\n    SSL3_RECORD wrec;           /* goes out from here */\n    /*\n     * storage for Alert/Handshake protocol data received but not yet\n     * processed by ssl3_read_bytes:\n     */\n    unsigned char alert_fragment[2];\n    unsigned int alert_fragment_len;\n    unsigned char handshake_fragment[4];\n    unsigned int handshake_fragment_len;\n    /* partial write - check the numbers match */\n    unsigned int wnum;          /* number of bytes sent so far */\n    int wpend_tot;              /* number bytes written */\n    int wpend_type;\n    int wpend_ret;              /* number of bytes submitted */\n    const unsigned char *wpend_buf;\n    /* used during startup, digest all incoming/outgoing packets */\n    BIO *handshake_buffer;\n    /*\n     * When set of handshake digests is determined, buffer is hashed and\n     * freed and MD_CTX-es for all required digests are stored in this array\n     */\n    EVP_MD_CTX **handshake_dgst;\n    /*\n     * Set whenever an expected ChangeCipherSpec message is processed.\n     * Unset when the peer's Finished message is received.\n     * Unexpected ChangeCipherSpec messages trigger a fatal alert.\n     */\n    int change_cipher_spec;\n    int warn_alert;\n    int fatal_alert;\n    /*\n     * we allow one fatal and one warning alert to be outstanding, send close\n     * alert via the warning alert\n     */\n    int alert_dispatch;\n    unsigned char send_alert[2];\n    /*\n     * This flag is set when we should renegotiate ASAP, basically when there\n     * is no more data in the read or write buffers\n     */\n    int renegotiate;\n    int total_renegotiations;\n    int num_renegotiations;\n    int in_read_app_data;\n    /*\n     * Opaque PRF input as used for the current handshake. These fields are\n     * used only if TLSEXT_TYPE_opaque_prf_input is defined (otherwise, they\n     * are merely present to improve binary compatibility)\n     */\n    void *client_opaque_prf_input;\n    size_t client_opaque_prf_input_len;\n    void *server_opaque_prf_input;\n    size_t server_opaque_prf_input_len;\n    struct {\n        /* actually only needs to be 16+20 */\n        unsigned char cert_verify_md[EVP_MAX_MD_SIZE * 2];\n        /* actually only need to be 16+20 for SSLv3 and 12 for TLS */\n        unsigned char finish_md[EVP_MAX_MD_SIZE * 2];\n        int finish_md_len;\n        unsigned char peer_finish_md[EVP_MAX_MD_SIZE * 2];\n        int peer_finish_md_len;\n        unsigned long message_size;\n        int message_type;\n        /* used to hold the new cipher we are going to use */\n        const SSL_CIPHER *new_cipher;\n#  ifndef OPENSSL_NO_DH\n        DH *dh;\n#  endif\n#  ifndef OPENSSL_NO_ECDH\n        EC_KEY *ecdh;           /* holds short lived ECDH key */\n#  endif\n        /* used when SSL_ST_FLUSH_DATA is entered */\n        int next_state;\n        int reuse_message;\n        /* used for certificate requests */\n        int cert_req;\n        int ctype_num;\n        char ctype[SSL3_CT_NUMBER];\n        STACK_OF(X509_NAME) *ca_names;\n        int use_rsa_tmp;\n        int key_block_length;\n        unsigned char *key_block;\n        const EVP_CIPHER *new_sym_enc;\n        const EVP_MD *new_hash;\n        int new_mac_pkey_type;\n        int new_mac_secret_size;\n#  ifndef OPENSSL_NO_COMP\n        const SSL_COMP *new_compression;\n#  else\n        char *new_compression;\n#  endif\n        int cert_request;\n    } tmp;\n\n    /* Connection binding to prevent renegotiation attacks */\n    unsigned char previous_client_finished[EVP_MAX_MD_SIZE];\n    unsigned char previous_client_finished_len;\n    unsigned char previous_server_finished[EVP_MAX_MD_SIZE];\n    unsigned char previous_server_finished_len;\n    int send_connection_binding; /* TODOEKR */\n\n#  ifndef OPENSSL_NO_NEXTPROTONEG\n    /*\n     * Set if we saw the Next Protocol Negotiation extension from our peer.\n     */\n    int next_proto_neg_seen;\n#  endif\n\n#  ifndef OPENSSL_NO_TLSEXT\n#   ifndef OPENSSL_NO_EC\n    /*\n     * This is set to true if we believe that this is a version of Safari\n     * running on OS X 10.6 or newer. We wish to know this because Safari on\n     * 10.8 .. 10.8.3 has broken ECDHE-ECDSA support.\n     */\n    char is_probably_safari;\n#   endif                       /* !OPENSSL_NO_EC */\n\n    /*\n     * ALPN information (we are in the process of transitioning from NPN to\n     * ALPN.)\n     */\n\n    /*\n     * In a server these point to the selected ALPN protocol after the\n     * ClientHello has been processed. In a client these contain the protocol\n     * that the server selected once the ServerHello has been processed.\n     */\n    unsigned char *alpn_selected;\n    unsigned alpn_selected_len;\n#  endif                        /* OPENSSL_NO_TLSEXT */\n} SSL3_STATE;\n\n# endif\n\n/* SSLv3 */\n/*\n * client\n */\n/* extra state */\n# define SSL3_ST_CW_FLUSH                (0x100|SSL_ST_CONNECT)\n# ifndef OPENSSL_NO_SCTP\n#  define DTLS1_SCTP_ST_CW_WRITE_SOCK                     (0x310|SSL_ST_CONNECT)\n#  define DTLS1_SCTP_ST_CR_READ_SOCK                      (0x320|SSL_ST_CONNECT)\n# endif\n/* write to server */\n# define SSL3_ST_CW_CLNT_HELLO_A         (0x110|SSL_ST_CONNECT)\n# define SSL3_ST_CW_CLNT_HELLO_B         (0x111|SSL_ST_CONNECT)\n/* read from server */\n# define SSL3_ST_CR_SRVR_HELLO_A         (0x120|SSL_ST_CONNECT)\n# define SSL3_ST_CR_SRVR_HELLO_B         (0x121|SSL_ST_CONNECT)\n# define DTLS1_ST_CR_HELLO_VERIFY_REQUEST_A (0x126|SSL_ST_CONNECT)\n# define DTLS1_ST_CR_HELLO_VERIFY_REQUEST_B (0x127|SSL_ST_CONNECT)\n# define SSL3_ST_CR_CERT_A               (0x130|SSL_ST_CONNECT)\n# define SSL3_ST_CR_CERT_B               (0x131|SSL_ST_CONNECT)\n# define SSL3_ST_CR_KEY_EXCH_A           (0x140|SSL_ST_CONNECT)\n# define SSL3_ST_CR_KEY_EXCH_B           (0x141|SSL_ST_CONNECT)\n# define SSL3_ST_CR_CERT_REQ_A           (0x150|SSL_ST_CONNECT)\n# define SSL3_ST_CR_CERT_REQ_B           (0x151|SSL_ST_CONNECT)\n# define SSL3_ST_CR_SRVR_DONE_A          (0x160|SSL_ST_CONNECT)\n# define SSL3_ST_CR_SRVR_DONE_B          (0x161|SSL_ST_CONNECT)\n/* write to server */\n# define SSL3_ST_CW_CERT_A               (0x170|SSL_ST_CONNECT)\n# define SSL3_ST_CW_CERT_B               (0x171|SSL_ST_CONNECT)\n# define SSL3_ST_CW_CERT_C               (0x172|SSL_ST_CONNECT)\n# define SSL3_ST_CW_CERT_D               (0x173|SSL_ST_CONNECT)\n# define SSL3_ST_CW_KEY_EXCH_A           (0x180|SSL_ST_CONNECT)\n# define SSL3_ST_CW_KEY_EXCH_B           (0x181|SSL_ST_CONNECT)\n# define SSL3_ST_CW_CERT_VRFY_A          (0x190|SSL_ST_CONNECT)\n# define SSL3_ST_CW_CERT_VRFY_B          (0x191|SSL_ST_CONNECT)\n# define SSL3_ST_CW_CHANGE_A             (0x1A0|SSL_ST_CONNECT)\n# define SSL3_ST_CW_CHANGE_B             (0x1A1|SSL_ST_CONNECT)\n# ifndef OPENSSL_NO_NEXTPROTONEG\n#  define SSL3_ST_CW_NEXT_PROTO_A         (0x200|SSL_ST_CONNECT)\n#  define SSL3_ST_CW_NEXT_PROTO_B         (0x201|SSL_ST_CONNECT)\n# endif\n# define SSL3_ST_CW_FINISHED_A           (0x1B0|SSL_ST_CONNECT)\n# define SSL3_ST_CW_FINISHED_B           (0x1B1|SSL_ST_CONNECT)\n/* read from server */\n# define SSL3_ST_CR_CHANGE_A             (0x1C0|SSL_ST_CONNECT)\n# define SSL3_ST_CR_CHANGE_B             (0x1C1|SSL_ST_CONNECT)\n# define SSL3_ST_CR_FINISHED_A           (0x1D0|SSL_ST_CONNECT)\n# define SSL3_ST_CR_FINISHED_B           (0x1D1|SSL_ST_CONNECT)\n# define SSL3_ST_CR_SESSION_TICKET_A     (0x1E0|SSL_ST_CONNECT)\n# define SSL3_ST_CR_SESSION_TICKET_B     (0x1E1|SSL_ST_CONNECT)\n# define SSL3_ST_CR_CERT_STATUS_A        (0x1F0|SSL_ST_CONNECT)\n# define SSL3_ST_CR_CERT_STATUS_B        (0x1F1|SSL_ST_CONNECT)\n\n/* server */\n/* extra state */\n# define SSL3_ST_SW_FLUSH                (0x100|SSL_ST_ACCEPT)\n# ifndef OPENSSL_NO_SCTP\n#  define DTLS1_SCTP_ST_SW_WRITE_SOCK                     (0x310|SSL_ST_ACCEPT)\n#  define DTLS1_SCTP_ST_SR_READ_SOCK                      (0x320|SSL_ST_ACCEPT)\n# endif\n/* read from client */\n/* Do not change the number values, they do matter */\n# define SSL3_ST_SR_CLNT_HELLO_A         (0x110|SSL_ST_ACCEPT)\n# define SSL3_ST_SR_CLNT_HELLO_B         (0x111|SSL_ST_ACCEPT)\n# define SSL3_ST_SR_CLNT_HELLO_C         (0x112|SSL_ST_ACCEPT)\n# define SSL3_ST_SR_CLNT_HELLO_D         (0x115|SSL_ST_ACCEPT)\n/* write to client */\n# define DTLS1_ST_SW_HELLO_VERIFY_REQUEST_A (0x113|SSL_ST_ACCEPT)\n# define DTLS1_ST_SW_HELLO_VERIFY_REQUEST_B (0x114|SSL_ST_ACCEPT)\n# define SSL3_ST_SW_HELLO_REQ_A          (0x120|SSL_ST_ACCEPT)\n# define SSL3_ST_SW_HELLO_REQ_B          (0x121|SSL_ST_ACCEPT)\n# define SSL3_ST_SW_HELLO_REQ_C          (0x122|SSL_ST_ACCEPT)\n# define SSL3_ST_SW_SRVR_HELLO_A         (0x130|SSL_ST_ACCEPT)\n# define SSL3_ST_SW_SRVR_HELLO_B         (0x131|SSL_ST_ACCEPT)\n# define SSL3_ST_SW_CERT_A               (0x140|SSL_ST_ACCEPT)\n# define SSL3_ST_SW_CERT_B               (0x141|SSL_ST_ACCEPT)\n# define SSL3_ST_SW_KEY_EXCH_A           (0x150|SSL_ST_ACCEPT)\n# define SSL3_ST_SW_KEY_EXCH_B           (0x151|SSL_ST_ACCEPT)\n# define SSL3_ST_SW_CERT_REQ_A           (0x160|SSL_ST_ACCEPT)\n# define SSL3_ST_SW_CERT_REQ_B           (0x161|SSL_ST_ACCEPT)\n# define SSL3_ST_SW_SRVR_DONE_A          (0x170|SSL_ST_ACCEPT)\n# define SSL3_ST_SW_SRVR_DONE_B          (0x171|SSL_ST_ACCEPT)\n/* read from client */\n# define SSL3_ST_SR_CERT_A               (0x180|SSL_ST_ACCEPT)\n# define SSL3_ST_SR_CERT_B               (0x181|SSL_ST_ACCEPT)\n# define SSL3_ST_SR_KEY_EXCH_A           (0x190|SSL_ST_ACCEPT)\n# define SSL3_ST_SR_KEY_EXCH_B           (0x191|SSL_ST_ACCEPT)\n# define SSL3_ST_SR_CERT_VRFY_A          (0x1A0|SSL_ST_ACCEPT)\n# define SSL3_ST_SR_CERT_VRFY_B          (0x1A1|SSL_ST_ACCEPT)\n# define SSL3_ST_SR_CHANGE_A             (0x1B0|SSL_ST_ACCEPT)\n# define SSL3_ST_SR_CHANGE_B             (0x1B1|SSL_ST_ACCEPT)\n# ifndef OPENSSL_NO_NEXTPROTONEG\n#  define SSL3_ST_SR_NEXT_PROTO_A         (0x210|SSL_ST_ACCEPT)\n#  define SSL3_ST_SR_NEXT_PROTO_B         (0x211|SSL_ST_ACCEPT)\n# endif\n# define SSL3_ST_SR_FINISHED_A           (0x1C0|SSL_ST_ACCEPT)\n# define SSL3_ST_SR_FINISHED_B           (0x1C1|SSL_ST_ACCEPT)\n/* write to client */\n# define SSL3_ST_SW_CHANGE_A             (0x1D0|SSL_ST_ACCEPT)\n# define SSL3_ST_SW_CHANGE_B             (0x1D1|SSL_ST_ACCEPT)\n# define SSL3_ST_SW_FINISHED_A           (0x1E0|SSL_ST_ACCEPT)\n# define SSL3_ST_SW_FINISHED_B           (0x1E1|SSL_ST_ACCEPT)\n# define SSL3_ST_SW_SESSION_TICKET_A     (0x1F0|SSL_ST_ACCEPT)\n# define SSL3_ST_SW_SESSION_TICKET_B     (0x1F1|SSL_ST_ACCEPT)\n# define SSL3_ST_SW_CERT_STATUS_A        (0x200|SSL_ST_ACCEPT)\n# define SSL3_ST_SW_CERT_STATUS_B        (0x201|SSL_ST_ACCEPT)\n\n# define SSL3_MT_HELLO_REQUEST                   0\n# define SSL3_MT_CLIENT_HELLO                    1\n# define SSL3_MT_SERVER_HELLO                    2\n# define SSL3_MT_NEWSESSION_TICKET               4\n# define SSL3_MT_CERTIFICATE                     11\n# define SSL3_MT_SERVER_KEY_EXCHANGE             12\n# define SSL3_MT_CERTIFICATE_REQUEST             13\n# define SSL3_MT_SERVER_DONE                     14\n# define SSL3_MT_CERTIFICATE_VERIFY              15\n# define SSL3_MT_CLIENT_KEY_EXCHANGE             16\n# define SSL3_MT_FINISHED                        20\n# define SSL3_MT_CERTIFICATE_STATUS              22\n# ifndef OPENSSL_NO_NEXTPROTONEG\n#  define SSL3_MT_NEXT_PROTO                      67\n# endif\n# define DTLS1_MT_HELLO_VERIFY_REQUEST    3\n\n# define SSL3_MT_CCS                             1\n\n/* These are used when changing over to a new cipher */\n# define SSL3_CC_READ            0x01\n# define SSL3_CC_WRITE           0x02\n# define SSL3_CC_CLIENT          0x10\n# define SSL3_CC_SERVER          0x20\n# define SSL3_CHANGE_CIPHER_CLIENT_WRITE (SSL3_CC_CLIENT|SSL3_CC_WRITE)\n# define SSL3_CHANGE_CIPHER_SERVER_READ  (SSL3_CC_SERVER|SSL3_CC_READ)\n# define SSL3_CHANGE_CIPHER_CLIENT_READ  (SSL3_CC_CLIENT|SSL3_CC_READ)\n# define SSL3_CHANGE_CIPHER_SERVER_WRITE (SSL3_CC_SERVER|SSL3_CC_WRITE)\n\n#ifdef  __cplusplus\n}\n#endif\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/arm64/include/openssl/stack.h",
    "content": "/* crypto/stack/stack.h */\n/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)\n * All rights reserved.\n *\n * This package is an SSL implementation written\n * by Eric Young (eay@cryptsoft.com).\n * The implementation was written so as to conform with Netscapes SSL.\n *\n * This library is free for commercial and non-commercial use as long as\n * the following conditions are aheared to.  The following conditions\n * apply to all code found in this distribution, be it the RC4, RSA,\n * lhash, DES, etc., code; not just the SSL code.  The SSL documentation\n * included with this distribution is covered by the same copyright terms\n * except that the holder is Tim Hudson (tjh@cryptsoft.com).\n *\n * Copyright remains Eric Young's, and as such any Copyright notices in\n * the code are not to be removed.\n * If this package is used in a product, Eric Young should be given attribution\n * as the author of the parts of the library used.\n * This can be in the form of a textual message at program startup or\n * in documentation (online or textual) provided with the package.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the copyright\n *    notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in the\n *    documentation and/or other materials provided with the distribution.\n * 3. All advertising materials mentioning features or use of this software\n *    must display the following acknowledgement:\n *    \"This product includes cryptographic software written by\n *     Eric Young (eay@cryptsoft.com)\"\n *    The word 'cryptographic' can be left out if the rouines from the library\n *    being used are not cryptographic related :-).\n * 4. If you include any Windows specific code (or a derivative thereof) from\n *    the apps directory (application code) you must include an acknowledgement:\n *    \"This product includes software written by Tim Hudson (tjh@cryptsoft.com)\"\n *\n * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n * SUCH DAMAGE.\n *\n * The licence and distribution terms for any publically available version or\n * derivative of this code cannot be changed.  i.e. this code cannot simply be\n * copied and put under another distribution licence\n * [including the GNU Public Licence.]\n */\n\n#ifndef HEADER_STACK_H\n# define HEADER_STACK_H\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\ntypedef struct stack_st {\n    int num;\n    char **data;\n    int sorted;\n    int num_alloc;\n    int (*comp) (const void *, const void *);\n} _STACK;                       /* Use STACK_OF(...) instead */\n\n# define M_sk_num(sk)            ((sk) ? (sk)->num:-1)\n# define M_sk_value(sk,n)        ((sk) ? (sk)->data[n] : NULL)\n\nint sk_num(const _STACK *);\nvoid *sk_value(const _STACK *, int);\n\nvoid *sk_set(_STACK *, int, void *);\n\n_STACK *sk_new(int (*cmp) (const void *, const void *));\n_STACK *sk_new_null(void);\nvoid sk_free(_STACK *);\nvoid sk_pop_free(_STACK *st, void (*func) (void *));\n_STACK *sk_deep_copy(_STACK *, void *(*)(void *), void (*)(void *));\nint sk_insert(_STACK *sk, void *data, int where);\nvoid *sk_delete(_STACK *st, int loc);\nvoid *sk_delete_ptr(_STACK *st, void *p);\nint sk_find(_STACK *st, void *data);\nint sk_find_ex(_STACK *st, void *data);\nint sk_push(_STACK *st, void *data);\nint sk_unshift(_STACK *st, void *data);\nvoid *sk_shift(_STACK *st);\nvoid *sk_pop(_STACK *st);\nvoid sk_zero(_STACK *st);\nint (*sk_set_cmp_func(_STACK *sk, int (*c) (const void *, const void *)))\n (const void *, const void *);\n_STACK *sk_dup(_STACK *st);\nvoid sk_sort(_STACK *st);\nint sk_is_sorted(const _STACK *st);\n\n#ifdef  __cplusplus\n}\n#endif\n\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/arm64/include/openssl/symhacks.h",
    "content": "/* ====================================================================\n * Copyright (c) 1999 The OpenSSL Project.  All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n *\n * 1. Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n *\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in\n *    the documentation and/or other materials provided with the\n *    distribution.\n *\n * 3. All advertising materials mentioning features or use of this\n *    software must display the following acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit. (http://www.openssl.org/)\"\n *\n * 4. The names \"OpenSSL Toolkit\" and \"OpenSSL Project\" must not be used to\n *    endorse or promote products derived from this software without\n *    prior written permission. For written permission, please contact\n *    openssl-core@openssl.org.\n *\n * 5. Products derived from this software may not be called \"OpenSSL\"\n *    nor may \"OpenSSL\" appear in their names without prior written\n *    permission of the OpenSSL Project.\n *\n * 6. Redistributions of any form whatsoever must retain the following\n *    acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit (http://www.openssl.org/)\"\n *\n * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY\n * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\n * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR\n * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\n * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,\n * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED\n * OF THE POSSIBILITY OF SUCH DAMAGE.\n * ====================================================================\n *\n * This product includes cryptographic software written by Eric Young\n * (eay@cryptsoft.com).  This product includes software written by Tim\n * Hudson (tjh@cryptsoft.com).\n *\n */\n\n#ifndef HEADER_SYMHACKS_H\n# define HEADER_SYMHACKS_H\n\n# include <openssl/e_os2.h>\n\n/*\n * Hacks to solve the problem with linkers incapable of handling very long\n * symbol names.  In the case of VMS, the limit is 31 characters on VMS for\n * VAX.\n */\n/*\n * Note that this affects util/libeay.num and util/ssleay.num...  you may\n * change those manually, but that's not recommended, as those files are\n * controlled centrally and updated on Unix, and the central definition may\n * disagree with yours, which in turn may come with shareable library\n * incompatibilities.\n */\n# ifdef OPENSSL_SYS_VMS\n\n/* Hack a long name in crypto/ex_data.c */\n#  undef CRYPTO_get_ex_data_implementation\n#  define CRYPTO_get_ex_data_implementation       CRYPTO_get_ex_data_impl\n#  undef CRYPTO_set_ex_data_implementation\n#  define CRYPTO_set_ex_data_implementation       CRYPTO_set_ex_data_impl\n\n/* Hack a long name in crypto/asn1/a_mbstr.c */\n#  undef ASN1_STRING_set_default_mask_asc\n#  define ASN1_STRING_set_default_mask_asc        ASN1_STRING_set_def_mask_asc\n\n#  if 0                         /* No longer needed, since safestack macro\n                                 * magic does the job */\n/* Hack the names created with DECLARE_ASN1_SET_OF(PKCS7_SIGNER_INFO) */\n#   undef i2d_ASN1_SET_OF_PKCS7_SIGNER_INFO\n#   define i2d_ASN1_SET_OF_PKCS7_SIGNER_INFO       i2d_ASN1_SET_OF_PKCS7_SIGINF\n#   undef d2i_ASN1_SET_OF_PKCS7_SIGNER_INFO\n#   define d2i_ASN1_SET_OF_PKCS7_SIGNER_INFO       d2i_ASN1_SET_OF_PKCS7_SIGINF\n#  endif\n\n#  if 0                         /* No longer needed, since safestack macro\n                                 * magic does the job */\n/* Hack the names created with DECLARE_ASN1_SET_OF(PKCS7_RECIP_INFO) */\n#   undef i2d_ASN1_SET_OF_PKCS7_RECIP_INFO\n#   define i2d_ASN1_SET_OF_PKCS7_RECIP_INFO        i2d_ASN1_SET_OF_PKCS7_RECINF\n#   undef d2i_ASN1_SET_OF_PKCS7_RECIP_INFO\n#   define d2i_ASN1_SET_OF_PKCS7_RECIP_INFO        d2i_ASN1_SET_OF_PKCS7_RECINF\n#  endif\n\n#  if 0                         /* No longer needed, since safestack macro\n                                 * magic does the job */\n/* Hack the names created with DECLARE_ASN1_SET_OF(ACCESS_DESCRIPTION) */\n#   undef i2d_ASN1_SET_OF_ACCESS_DESCRIPTION\n#   define i2d_ASN1_SET_OF_ACCESS_DESCRIPTION      i2d_ASN1_SET_OF_ACC_DESC\n#   undef d2i_ASN1_SET_OF_ACCESS_DESCRIPTION\n#   define d2i_ASN1_SET_OF_ACCESS_DESCRIPTION      d2i_ASN1_SET_OF_ACC_DESC\n#  endif\n\n/* Hack the names created with DECLARE_PEM_rw(NETSCAPE_CERT_SEQUENCE) */\n#  undef PEM_read_NETSCAPE_CERT_SEQUENCE\n#  define PEM_read_NETSCAPE_CERT_SEQUENCE         PEM_read_NS_CERT_SEQ\n#  undef PEM_write_NETSCAPE_CERT_SEQUENCE\n#  define PEM_write_NETSCAPE_CERT_SEQUENCE        PEM_write_NS_CERT_SEQ\n#  undef PEM_read_bio_NETSCAPE_CERT_SEQUENCE\n#  define PEM_read_bio_NETSCAPE_CERT_SEQUENCE     PEM_read_bio_NS_CERT_SEQ\n#  undef PEM_write_bio_NETSCAPE_CERT_SEQUENCE\n#  define PEM_write_bio_NETSCAPE_CERT_SEQUENCE    PEM_write_bio_NS_CERT_SEQ\n#  undef PEM_write_cb_bio_NETSCAPE_CERT_SEQUENCE\n#  define PEM_write_cb_bio_NETSCAPE_CERT_SEQUENCE PEM_write_cb_bio_NS_CERT_SEQ\n\n/* Hack the names created with DECLARE_PEM_rw(PKCS8_PRIV_KEY_INFO) */\n#  undef PEM_read_PKCS8_PRIV_KEY_INFO\n#  define PEM_read_PKCS8_PRIV_KEY_INFO            PEM_read_P8_PRIV_KEY_INFO\n#  undef PEM_write_PKCS8_PRIV_KEY_INFO\n#  define PEM_write_PKCS8_PRIV_KEY_INFO           PEM_write_P8_PRIV_KEY_INFO\n#  undef PEM_read_bio_PKCS8_PRIV_KEY_INFO\n#  define PEM_read_bio_PKCS8_PRIV_KEY_INFO        PEM_read_bio_P8_PRIV_KEY_INFO\n#  undef PEM_write_bio_PKCS8_PRIV_KEY_INFO\n#  define PEM_write_bio_PKCS8_PRIV_KEY_INFO       PEM_write_bio_P8_PRIV_KEY_INFO\n#  undef PEM_write_cb_bio_PKCS8_PRIV_KEY_INFO\n#  define PEM_write_cb_bio_PKCS8_PRIV_KEY_INFO    PEM_wrt_cb_bio_P8_PRIV_KEY_INFO\n\n/* Hack other PEM names */\n#  undef PEM_write_bio_PKCS8PrivateKey_nid\n#  define PEM_write_bio_PKCS8PrivateKey_nid       PEM_write_bio_PKCS8PrivKey_nid\n\n/* Hack some long X509 names */\n#  undef X509_REVOKED_get_ext_by_critical\n#  define X509_REVOKED_get_ext_by_critical        X509_REVOKED_get_ext_by_critic\n#  undef X509_policy_tree_get0_user_policies\n#  define X509_policy_tree_get0_user_policies     X509_pcy_tree_get0_usr_policies\n#  undef X509_policy_node_get0_qualifiers\n#  define X509_policy_node_get0_qualifiers        X509_pcy_node_get0_qualifiers\n#  undef X509_STORE_CTX_get_explicit_policy\n#  define X509_STORE_CTX_get_explicit_policy      X509_STORE_CTX_get_expl_policy\n#  undef X509_STORE_CTX_get0_current_issuer\n#  define X509_STORE_CTX_get0_current_issuer      X509_STORE_CTX_get0_cur_issuer\n\n/* Hack some long CRYPTO names */\n#  undef CRYPTO_set_dynlock_destroy_callback\n#  define CRYPTO_set_dynlock_destroy_callback     CRYPTO_set_dynlock_destroy_cb\n#  undef CRYPTO_set_dynlock_create_callback\n#  define CRYPTO_set_dynlock_create_callback      CRYPTO_set_dynlock_create_cb\n#  undef CRYPTO_set_dynlock_lock_callback\n#  define CRYPTO_set_dynlock_lock_callback        CRYPTO_set_dynlock_lock_cb\n#  undef CRYPTO_get_dynlock_lock_callback\n#  define CRYPTO_get_dynlock_lock_callback        CRYPTO_get_dynlock_lock_cb\n#  undef CRYPTO_get_dynlock_destroy_callback\n#  define CRYPTO_get_dynlock_destroy_callback     CRYPTO_get_dynlock_destroy_cb\n#  undef CRYPTO_get_dynlock_create_callback\n#  define CRYPTO_get_dynlock_create_callback      CRYPTO_get_dynlock_create_cb\n#  undef CRYPTO_set_locked_mem_ex_functions\n#  define CRYPTO_set_locked_mem_ex_functions      CRYPTO_set_locked_mem_ex_funcs\n#  undef CRYPTO_get_locked_mem_ex_functions\n#  define CRYPTO_get_locked_mem_ex_functions      CRYPTO_get_locked_mem_ex_funcs\n\n/* Hack some long SSL/TLS names */\n#  undef SSL_CTX_set_default_verify_paths\n#  define SSL_CTX_set_default_verify_paths        SSL_CTX_set_def_verify_paths\n#  undef SSL_get_ex_data_X509_STORE_CTX_idx\n#  define SSL_get_ex_data_X509_STORE_CTX_idx      SSL_get_ex_d_X509_STORE_CTX_idx\n#  undef SSL_add_file_cert_subjects_to_stack\n#  define SSL_add_file_cert_subjects_to_stack     SSL_add_file_cert_subjs_to_stk\n#  undef SSL_add_dir_cert_subjects_to_stack\n#  define SSL_add_dir_cert_subjects_to_stack      SSL_add_dir_cert_subjs_to_stk\n#  undef SSL_CTX_use_certificate_chain_file\n#  define SSL_CTX_use_certificate_chain_file      SSL_CTX_use_cert_chain_file\n#  undef SSL_CTX_set_cert_verify_callback\n#  define SSL_CTX_set_cert_verify_callback        SSL_CTX_set_cert_verify_cb\n#  undef SSL_CTX_set_default_passwd_cb_userdata\n#  define SSL_CTX_set_default_passwd_cb_userdata  SSL_CTX_set_def_passwd_cb_ud\n#  undef SSL_COMP_get_compression_methods\n#  define SSL_COMP_get_compression_methods        SSL_COMP_get_compress_methods\n#  undef SSL_COMP_set0_compression_methods\n#  define SSL_COMP_set0_compression_methods       SSL_COMP_set0_compress_methods\n#  undef SSL_COMP_free_compression_methods\n#  define SSL_COMP_free_compression_methods       SSL_COMP_free_compress_methods\n#  undef ssl_add_clienthello_renegotiate_ext\n#  define ssl_add_clienthello_renegotiate_ext     ssl_add_clienthello_reneg_ext\n#  undef ssl_add_serverhello_renegotiate_ext\n#  define ssl_add_serverhello_renegotiate_ext     ssl_add_serverhello_reneg_ext\n#  undef ssl_parse_clienthello_renegotiate_ext\n#  define ssl_parse_clienthello_renegotiate_ext   ssl_parse_clienthello_reneg_ext\n#  undef ssl_parse_serverhello_renegotiate_ext\n#  define ssl_parse_serverhello_renegotiate_ext   ssl_parse_serverhello_reneg_ext\n#  undef SSL_srp_server_param_with_username\n#  define SSL_srp_server_param_with_username      SSL_srp_server_param_with_un\n#  undef SSL_CTX_set_srp_client_pwd_callback\n#  define SSL_CTX_set_srp_client_pwd_callback     SSL_CTX_set_srp_client_pwd_cb\n#  undef SSL_CTX_set_srp_verify_param_callback\n#  define SSL_CTX_set_srp_verify_param_callback   SSL_CTX_set_srp_vfy_param_cb\n#  undef SSL_CTX_set_srp_username_callback\n#  define SSL_CTX_set_srp_username_callback       SSL_CTX_set_srp_un_cb\n#  undef ssl_add_clienthello_use_srtp_ext\n#  define ssl_add_clienthello_use_srtp_ext        ssl_add_clihello_use_srtp_ext\n#  undef ssl_add_serverhello_use_srtp_ext\n#  define ssl_add_serverhello_use_srtp_ext        ssl_add_serhello_use_srtp_ext\n#  undef ssl_parse_clienthello_use_srtp_ext\n#  define ssl_parse_clienthello_use_srtp_ext      ssl_parse_clihello_use_srtp_ext\n#  undef ssl_parse_serverhello_use_srtp_ext\n#  define ssl_parse_serverhello_use_srtp_ext      ssl_parse_serhello_use_srtp_ext\n#  undef SSL_CTX_set_next_protos_advertised_cb\n#  define SSL_CTX_set_next_protos_advertised_cb   SSL_CTX_set_next_protos_adv_cb\n#  undef SSL_CTX_set_next_proto_select_cb\n#  define SSL_CTX_set_next_proto_select_cb        SSL_CTX_set_next_proto_sel_cb\n\n#  undef tls1_send_server_supplemental_data\n#  define tls1_send_server_supplemental_data      tls1_send_server_suppl_data\n#  undef tls1_send_client_supplemental_data\n#  define tls1_send_client_supplemental_data      tls1_send_client_suppl_data\n#  undef tls1_get_server_supplemental_data\n#  define tls1_get_server_supplemental_data       tls1_get_server_suppl_data\n#  undef tls1_get_client_supplemental_data\n#  define tls1_get_client_supplemental_data       tls1_get_client_suppl_data\n\n#  undef ssl3_cbc_record_digest_supported\n#  define ssl3_cbc_record_digest_supported        ssl3_cbc_record_digest_support\n#  undef ssl_check_clienthello_tlsext_late\n#  define ssl_check_clienthello_tlsext_late       ssl_check_clihello_tlsext_late\n#  undef ssl_check_clienthello_tlsext_early\n#  define ssl_check_clienthello_tlsext_early      ssl_check_clihello_tlsext_early\n\n/* Hack some RSA long names */\n#  undef RSA_padding_check_PKCS1_OAEP_mgf1\n#  define RSA_padding_check_PKCS1_OAEP_mgf1       RSA_pad_check_PKCS1_OAEP_mgf1\n\n/* Hack some ENGINE long names */\n#  undef ENGINE_get_default_BN_mod_exp_crt\n#  define ENGINE_get_default_BN_mod_exp_crt       ENGINE_get_def_BN_mod_exp_crt\n#  undef ENGINE_set_default_BN_mod_exp_crt\n#  define ENGINE_set_default_BN_mod_exp_crt       ENGINE_set_def_BN_mod_exp_crt\n#  undef ENGINE_set_load_privkey_function\n#  define ENGINE_set_load_privkey_function        ENGINE_set_load_privkey_fn\n#  undef ENGINE_get_load_privkey_function\n#  define ENGINE_get_load_privkey_function        ENGINE_get_load_privkey_fn\n#  undef ENGINE_unregister_pkey_asn1_meths\n#  define ENGINE_unregister_pkey_asn1_meths       ENGINE_unreg_pkey_asn1_meths\n#  undef ENGINE_register_all_pkey_asn1_meths\n#  define ENGINE_register_all_pkey_asn1_meths     ENGINE_reg_all_pkey_asn1_meths\n#  undef ENGINE_set_default_pkey_asn1_meths\n#  define ENGINE_set_default_pkey_asn1_meths      ENGINE_set_def_pkey_asn1_meths\n#  undef ENGINE_get_pkey_asn1_meth_engine\n#  define ENGINE_get_pkey_asn1_meth_engine        ENGINE_get_pkey_asn1_meth_eng\n#  undef ENGINE_set_load_ssl_client_cert_function\n#  define ENGINE_set_load_ssl_client_cert_function \\\n                                                ENGINE_set_ld_ssl_clnt_cert_fn\n#  undef ENGINE_get_ssl_client_cert_function\n#  define ENGINE_get_ssl_client_cert_function     ENGINE_get_ssl_client_cert_fn\n\n/* Hack some long OCSP names */\n#  undef OCSP_REQUEST_get_ext_by_critical\n#  define OCSP_REQUEST_get_ext_by_critical        OCSP_REQUEST_get_ext_by_crit\n#  undef OCSP_BASICRESP_get_ext_by_critical\n#  define OCSP_BASICRESP_get_ext_by_critical      OCSP_BASICRESP_get_ext_by_crit\n#  undef OCSP_SINGLERESP_get_ext_by_critical\n#  define OCSP_SINGLERESP_get_ext_by_critical     OCSP_SINGLERESP_get_ext_by_crit\n\n/* Hack some long DES names */\n#  undef _ossl_old_des_ede3_cfb64_encrypt\n#  define _ossl_old_des_ede3_cfb64_encrypt        _ossl_odes_ede3_cfb64_encrypt\n#  undef _ossl_old_des_ede3_ofb64_encrypt\n#  define _ossl_old_des_ede3_ofb64_encrypt        _ossl_odes_ede3_ofb64_encrypt\n\n/* Hack some long EVP names */\n#  undef OPENSSL_add_all_algorithms_noconf\n#  define OPENSSL_add_all_algorithms_noconf       OPENSSL_add_all_algo_noconf\n#  undef OPENSSL_add_all_algorithms_conf\n#  define OPENSSL_add_all_algorithms_conf         OPENSSL_add_all_algo_conf\n#  undef EVP_PKEY_meth_set_verify_recover\n#  define EVP_PKEY_meth_set_verify_recover        EVP_PKEY_meth_set_vrfy_recover\n\n/* Hack some long EC names */\n#  undef EC_GROUP_set_point_conversion_form\n#  define EC_GROUP_set_point_conversion_form      EC_GROUP_set_point_conv_form\n#  undef EC_GROUP_get_point_conversion_form\n#  define EC_GROUP_get_point_conversion_form      EC_GROUP_get_point_conv_form\n#  undef EC_GROUP_clear_free_all_extra_data\n#  define EC_GROUP_clear_free_all_extra_data      EC_GROUP_clr_free_all_xtra_data\n#  undef EC_KEY_set_public_key_affine_coordinates\n#  define EC_KEY_set_public_key_affine_coordinates \\\n                                                EC_KEY_set_pub_key_aff_coords\n#  undef EC_POINT_set_Jprojective_coordinates_GFp\n#  define EC_POINT_set_Jprojective_coordinates_GFp \\\n                                                EC_POINT_set_Jproj_coords_GFp\n#  undef EC_POINT_get_Jprojective_coordinates_GFp\n#  define EC_POINT_get_Jprojective_coordinates_GFp \\\n                                                EC_POINT_get_Jproj_coords_GFp\n#  undef EC_POINT_set_affine_coordinates_GFp\n#  define EC_POINT_set_affine_coordinates_GFp     EC_POINT_set_affine_coords_GFp\n#  undef EC_POINT_get_affine_coordinates_GFp\n#  define EC_POINT_get_affine_coordinates_GFp     EC_POINT_get_affine_coords_GFp\n#  undef EC_POINT_set_compressed_coordinates_GFp\n#  define EC_POINT_set_compressed_coordinates_GFp EC_POINT_set_compr_coords_GFp\n#  undef EC_POINT_set_affine_coordinates_GF2m\n#  define EC_POINT_set_affine_coordinates_GF2m    EC_POINT_set_affine_coords_GF2m\n#  undef EC_POINT_get_affine_coordinates_GF2m\n#  define EC_POINT_get_affine_coordinates_GF2m    EC_POINT_get_affine_coords_GF2m\n#  undef EC_POINT_set_compressed_coordinates_GF2m\n#  define EC_POINT_set_compressed_coordinates_GF2m \\\n                                                EC_POINT_set_compr_coords_GF2m\n#  undef ec_GF2m_simple_group_clear_finish\n#  define ec_GF2m_simple_group_clear_finish       ec_GF2m_simple_grp_clr_finish\n#  undef ec_GF2m_simple_group_check_discriminant\n#  define ec_GF2m_simple_group_check_discriminant ec_GF2m_simple_grp_chk_discrim\n#  undef ec_GF2m_simple_point_clear_finish\n#  define ec_GF2m_simple_point_clear_finish       ec_GF2m_simple_pt_clr_finish\n#  undef ec_GF2m_simple_point_set_to_infinity\n#  define ec_GF2m_simple_point_set_to_infinity    ec_GF2m_simple_pt_set_to_inf\n#  undef ec_GF2m_simple_points_make_affine\n#  define ec_GF2m_simple_points_make_affine       ec_GF2m_simple_pts_make_affine\n#  undef ec_GF2m_simple_point_set_affine_coordinates\n#  define ec_GF2m_simple_point_set_affine_coordinates \\\n                                                ec_GF2m_smp_pt_set_af_coords\n#  undef ec_GF2m_simple_point_get_affine_coordinates\n#  define ec_GF2m_simple_point_get_affine_coordinates \\\n                                                ec_GF2m_smp_pt_get_af_coords\n#  undef ec_GF2m_simple_set_compressed_coordinates\n#  define ec_GF2m_simple_set_compressed_coordinates \\\n                                                ec_GF2m_smp_set_compr_coords\n#  undef ec_GFp_simple_group_set_curve_GFp\n#  define ec_GFp_simple_group_set_curve_GFp       ec_GFp_simple_grp_set_curve_GFp\n#  undef ec_GFp_simple_group_get_curve_GFp\n#  define ec_GFp_simple_group_get_curve_GFp       ec_GFp_simple_grp_get_curve_GFp\n#  undef ec_GFp_simple_group_clear_finish\n#  define ec_GFp_simple_group_clear_finish        ec_GFp_simple_grp_clear_finish\n#  undef ec_GFp_simple_group_set_generator\n#  define ec_GFp_simple_group_set_generator       ec_GFp_simple_grp_set_generator\n#  undef ec_GFp_simple_group_get0_generator\n#  define ec_GFp_simple_group_get0_generator      ec_GFp_simple_grp_gt0_generator\n#  undef ec_GFp_simple_group_get_cofactor\n#  define ec_GFp_simple_group_get_cofactor        ec_GFp_simple_grp_get_cofactor\n#  undef ec_GFp_simple_point_clear_finish\n#  define ec_GFp_simple_point_clear_finish        ec_GFp_simple_pt_clear_finish\n#  undef ec_GFp_simple_point_set_to_infinity\n#  define ec_GFp_simple_point_set_to_infinity     ec_GFp_simple_pt_set_to_inf\n#  undef ec_GFp_simple_points_make_affine\n#  define ec_GFp_simple_points_make_affine        ec_GFp_simple_pts_make_affine\n#  undef ec_GFp_simple_set_Jprojective_coordinates_GFp\n#  define ec_GFp_simple_set_Jprojective_coordinates_GFp \\\n                                                ec_GFp_smp_set_Jproj_coords_GFp\n#  undef ec_GFp_simple_get_Jprojective_coordinates_GFp\n#  define ec_GFp_simple_get_Jprojective_coordinates_GFp \\\n                                                ec_GFp_smp_get_Jproj_coords_GFp\n#  undef ec_GFp_simple_point_set_affine_coordinates_GFp\n#  define ec_GFp_simple_point_set_affine_coordinates_GFp \\\n                                                ec_GFp_smp_pt_set_af_coords_GFp\n#  undef ec_GFp_simple_point_get_affine_coordinates_GFp\n#  define ec_GFp_simple_point_get_affine_coordinates_GFp \\\n                                                ec_GFp_smp_pt_get_af_coords_GFp\n#  undef ec_GFp_simple_set_compressed_coordinates_GFp\n#  define ec_GFp_simple_set_compressed_coordinates_GFp \\\n                                                ec_GFp_smp_set_compr_coords_GFp\n#  undef ec_GFp_simple_point_set_affine_coordinates\n#  define ec_GFp_simple_point_set_affine_coordinates \\\n                                                ec_GFp_smp_pt_set_af_coords\n#  undef ec_GFp_simple_point_get_affine_coordinates\n#  define ec_GFp_simple_point_get_affine_coordinates \\\n                                                ec_GFp_smp_pt_get_af_coords\n#  undef ec_GFp_simple_set_compressed_coordinates\n#  define ec_GFp_simple_set_compressed_coordinates \\\n                                                ec_GFp_smp_set_compr_coords\n#  undef ec_GFp_simple_group_check_discriminant\n#  define ec_GFp_simple_group_check_discriminant  ec_GFp_simple_grp_chk_discrim\n\n/* Hack som long STORE names */\n#  undef STORE_method_set_initialise_function\n#  define STORE_method_set_initialise_function    STORE_meth_set_initialise_fn\n#  undef STORE_method_set_cleanup_function\n#  define STORE_method_set_cleanup_function       STORE_meth_set_cleanup_fn\n#  undef STORE_method_set_generate_function\n#  define STORE_method_set_generate_function      STORE_meth_set_generate_fn\n#  undef STORE_method_set_modify_function\n#  define STORE_method_set_modify_function        STORE_meth_set_modify_fn\n#  undef STORE_method_set_revoke_function\n#  define STORE_method_set_revoke_function        STORE_meth_set_revoke_fn\n#  undef STORE_method_set_delete_function\n#  define STORE_method_set_delete_function        STORE_meth_set_delete_fn\n#  undef STORE_method_set_list_start_function\n#  define STORE_method_set_list_start_function    STORE_meth_set_list_start_fn\n#  undef STORE_method_set_list_next_function\n#  define STORE_method_set_list_next_function     STORE_meth_set_list_next_fn\n#  undef STORE_method_set_list_end_function\n#  define STORE_method_set_list_end_function      STORE_meth_set_list_end_fn\n#  undef STORE_method_set_update_store_function\n#  define STORE_method_set_update_store_function  STORE_meth_set_update_store_fn\n#  undef STORE_method_set_lock_store_function\n#  define STORE_method_set_lock_store_function    STORE_meth_set_lock_store_fn\n#  undef STORE_method_set_unlock_store_function\n#  define STORE_method_set_unlock_store_function  STORE_meth_set_unlock_store_fn\n#  undef STORE_method_get_initialise_function\n#  define STORE_method_get_initialise_function    STORE_meth_get_initialise_fn\n#  undef STORE_method_get_cleanup_function\n#  define STORE_method_get_cleanup_function       STORE_meth_get_cleanup_fn\n#  undef STORE_method_get_generate_function\n#  define STORE_method_get_generate_function      STORE_meth_get_generate_fn\n#  undef STORE_method_get_modify_function\n#  define STORE_method_get_modify_function        STORE_meth_get_modify_fn\n#  undef STORE_method_get_revoke_function\n#  define STORE_method_get_revoke_function        STORE_meth_get_revoke_fn\n#  undef STORE_method_get_delete_function\n#  define STORE_method_get_delete_function        STORE_meth_get_delete_fn\n#  undef STORE_method_get_list_start_function\n#  define STORE_method_get_list_start_function    STORE_meth_get_list_start_fn\n#  undef STORE_method_get_list_next_function\n#  define STORE_method_get_list_next_function     STORE_meth_get_list_next_fn\n#  undef STORE_method_get_list_end_function\n#  define STORE_method_get_list_end_function      STORE_meth_get_list_end_fn\n#  undef STORE_method_get_update_store_function\n#  define STORE_method_get_update_store_function  STORE_meth_get_update_store_fn\n#  undef STORE_method_get_lock_store_function\n#  define STORE_method_get_lock_store_function    STORE_meth_get_lock_store_fn\n#  undef STORE_method_get_unlock_store_function\n#  define STORE_method_get_unlock_store_function  STORE_meth_get_unlock_store_fn\n\n/* Hack some long TS names */\n#  undef TS_RESP_CTX_set_status_info_cond\n#  define TS_RESP_CTX_set_status_info_cond        TS_RESP_CTX_set_stat_info_cond\n#  undef TS_RESP_CTX_set_clock_precision_digits\n#  define TS_RESP_CTX_set_clock_precision_digits  TS_RESP_CTX_set_clk_prec_digits\n#  undef TS_CONF_set_clock_precision_digits\n#  define TS_CONF_set_clock_precision_digits      TS_CONF_set_clk_prec_digits\n\n/* Hack some long CMS names */\n#  undef CMS_RecipientInfo_ktri_get0_algs\n#  define CMS_RecipientInfo_ktri_get0_algs        CMS_RecipInfo_ktri_get0_algs\n#  undef CMS_RecipientInfo_ktri_get0_signer_id\n#  define CMS_RecipientInfo_ktri_get0_signer_id   CMS_RecipInfo_ktri_get0_sigr_id\n#  undef CMS_OtherRevocationInfoFormat_it\n#  define CMS_OtherRevocationInfoFormat_it        CMS_OtherRevocInfoFormat_it\n#  undef CMS_KeyAgreeRecipientIdentifier_it\n#  define CMS_KeyAgreeRecipientIdentifier_it      CMS_KeyAgreeRecipIdentifier_it\n#  undef CMS_OriginatorIdentifierOrKey_it\n#  define CMS_OriginatorIdentifierOrKey_it        CMS_OriginatorIdOrKey_it\n#  undef cms_SignerIdentifier_get0_signer_id\n#  define cms_SignerIdentifier_get0_signer_id     cms_SignerId_get0_signer_id\n#  undef CMS_RecipientInfo_kari_get0_orig_id\n#  define CMS_RecipientInfo_kari_get0_orig_id     CMS_RecipInfo_kari_get0_orig_id\n#  undef CMS_RecipientInfo_kari_get0_reks\n#  define CMS_RecipientInfo_kari_get0_reks        CMS_RecipInfo_kari_get0_reks\n#  undef CMS_RecipientEncryptedKey_cert_cmp\n#  define CMS_RecipientEncryptedKey_cert_cmp      CMS_RecipEncryptedKey_cert_cmp\n#  undef CMS_RecipientInfo_kari_set0_pkey\n#  define CMS_RecipientInfo_kari_set0_pkey        CMS_RecipInfo_kari_set0_pkey\n#  undef CMS_RecipientEncryptedKey_get0_id\n#  define CMS_RecipientEncryptedKey_get0_id       CMS_RecipEncryptedKey_get0_id\n#  undef CMS_RecipientInfo_kari_orig_id_cmp\n#  define CMS_RecipientInfo_kari_orig_id_cmp      CMS_RecipInfo_kari_orig_id_cmp\n\n/* Hack some long DTLS1 names */\n#  undef dtls1_retransmit_buffered_messages\n#  define dtls1_retransmit_buffered_messages      dtls1_retransmit_buffered_msgs\n\n/* Hack some long SRP names */\n#  undef SRP_generate_server_master_secret\n#  define SRP_generate_server_master_secret       SRP_gen_server_master_secret\n#  undef SRP_generate_client_master_secret\n#  define SRP_generate_client_master_secret       SRP_gen_client_master_secret\n\n/* Hack some long UI names */\n#  undef UI_method_get_prompt_constructor\n#  define UI_method_get_prompt_constructor        UI_method_get_prompt_constructr\n#  undef UI_method_set_prompt_constructor\n#  define UI_method_set_prompt_constructor        UI_method_set_prompt_constructr\n\n# endif                         /* defined OPENSSL_SYS_VMS */\n\n/* Case insensitive linking causes problems.... */\n# if defined(OPENSSL_SYS_VMS) || defined(OPENSSL_SYS_OS2)\n#  undef ERR_load_CRYPTO_strings\n#  define ERR_load_CRYPTO_strings                 ERR_load_CRYPTOlib_strings\n#  undef OCSP_crlID_new\n#  define OCSP_crlID_new                          OCSP_crlID2_new\n\n#  undef d2i_ECPARAMETERS\n#  define d2i_ECPARAMETERS                        d2i_UC_ECPARAMETERS\n#  undef i2d_ECPARAMETERS\n#  define i2d_ECPARAMETERS                        i2d_UC_ECPARAMETERS\n#  undef d2i_ECPKPARAMETERS\n#  define d2i_ECPKPARAMETERS                      d2i_UC_ECPKPARAMETERS\n#  undef i2d_ECPKPARAMETERS\n#  define i2d_ECPKPARAMETERS                      i2d_UC_ECPKPARAMETERS\n\n/*\n * These functions do not seem to exist! However, I'm paranoid... Original\n * command in x509v3.h: These functions are being redefined in another\n * directory, and clash when the linker is case-insensitive, so let's hide\n * them a little, by giving them an extra 'o' at the beginning of the name...\n */\n#  undef X509v3_cleanup_extensions\n#  define X509v3_cleanup_extensions               oX509v3_cleanup_extensions\n#  undef X509v3_add_extension\n#  define X509v3_add_extension                    oX509v3_add_extension\n#  undef X509v3_add_netscape_extensions\n#  define X509v3_add_netscape_extensions          oX509v3_add_netscape_extensions\n#  undef X509v3_add_standard_extensions\n#  define X509v3_add_standard_extensions          oX509v3_add_standard_extensions\n\n/* This one clashes with CMS_data_create */\n#  undef cms_Data_create\n#  define cms_Data_create                         priv_cms_Data_create\n\n# endif\n\n#endif                          /* ! defined HEADER_VMS_IDHACKS_H */\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/arm64/include/openssl/tls1.h",
    "content": "/* ssl/tls1.h */\n/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)\n * All rights reserved.\n *\n * This package is an SSL implementation written\n * by Eric Young (eay@cryptsoft.com).\n * The implementation was written so as to conform with Netscapes SSL.\n *\n * This library is free for commercial and non-commercial use as long as\n * the following conditions are aheared to.  The following conditions\n * apply to all code found in this distribution, be it the RC4, RSA,\n * lhash, DES, etc., code; not just the SSL code.  The SSL documentation\n * included with this distribution is covered by the same copyright terms\n * except that the holder is Tim Hudson (tjh@cryptsoft.com).\n *\n * Copyright remains Eric Young's, and as such any Copyright notices in\n * the code are not to be removed.\n * If this package is used in a product, Eric Young should be given attribution\n * as the author of the parts of the library used.\n * This can be in the form of a textual message at program startup or\n * in documentation (online or textual) provided with the package.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the copyright\n *    notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in the\n *    documentation and/or other materials provided with the distribution.\n * 3. All advertising materials mentioning features or use of this software\n *    must display the following acknowledgement:\n *    \"This product includes cryptographic software written by\n *     Eric Young (eay@cryptsoft.com)\"\n *    The word 'cryptographic' can be left out if the rouines from the library\n *    being used are not cryptographic related :-).\n * 4. If you include any Windows specific code (or a derivative thereof) from\n *    the apps directory (application code) you must include an acknowledgement:\n *    \"This product includes software written by Tim Hudson (tjh@cryptsoft.com)\"\n *\n * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n * SUCH DAMAGE.\n *\n * The licence and distribution terms for any publically available version or\n * derivative of this code cannot be changed.  i.e. this code cannot simply be\n * copied and put under another distribution licence\n * [including the GNU Public Licence.]\n */\n/* ====================================================================\n * Copyright (c) 1998-2006 The OpenSSL Project.  All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n *\n * 1. Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n *\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in\n *    the documentation and/or other materials provided with the\n *    distribution.\n *\n * 3. All advertising materials mentioning features or use of this\n *    software must display the following acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit. (http://www.openssl.org/)\"\n *\n * 4. The names \"OpenSSL Toolkit\" and \"OpenSSL Project\" must not be used to\n *    endorse or promote products derived from this software without\n *    prior written permission. For written permission, please contact\n *    openssl-core@openssl.org.\n *\n * 5. Products derived from this software may not be called \"OpenSSL\"\n *    nor may \"OpenSSL\" appear in their names without prior written\n *    permission of the OpenSSL Project.\n *\n * 6. Redistributions of any form whatsoever must retain the following\n *    acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit (http://www.openssl.org/)\"\n *\n * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY\n * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\n * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR\n * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\n * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,\n * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED\n * OF THE POSSIBILITY OF SUCH DAMAGE.\n * ====================================================================\n *\n * This product includes cryptographic software written by Eric Young\n * (eay@cryptsoft.com).  This product includes software written by Tim\n * Hudson (tjh@cryptsoft.com).\n *\n */\n/* ====================================================================\n * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED.\n *\n * Portions of the attached software (\"Contribution\") are developed by\n * SUN MICROSYSTEMS, INC., and are contributed to the OpenSSL project.\n *\n * The Contribution is licensed pursuant to the OpenSSL open source\n * license provided above.\n *\n * ECC cipher suite support in OpenSSL originally written by\n * Vipul Gupta and Sumit Gupta of Sun Microsystems Laboratories.\n *\n */\n/* ====================================================================\n * Copyright 2005 Nokia. All rights reserved.\n *\n * The portions of the attached software (\"Contribution\") is developed by\n * Nokia Corporation and is licensed pursuant to the OpenSSL open source\n * license.\n *\n * The Contribution, originally written by Mika Kousa and Pasi Eronen of\n * Nokia Corporation, consists of the \"PSK\" (Pre-Shared Key) ciphersuites\n * support (see RFC 4279) to OpenSSL.\n *\n * No patent licenses or other rights except those expressly stated in\n * the OpenSSL open source license shall be deemed granted or received\n * expressly, by implication, estoppel, or otherwise.\n *\n * No assurances are provided by Nokia that the Contribution does not\n * infringe the patent or other intellectual property rights of any third\n * party or that the license provides you with all the necessary rights\n * to make use of the Contribution.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\" WITHOUT WARRANTY OF ANY KIND. IN\n * ADDITION TO THE DISCLAIMERS INCLUDED IN THE LICENSE, NOKIA\n * SPECIFICALLY DISCLAIMS ANY LIABILITY FOR CLAIMS BROUGHT BY YOU OR ANY\n * OTHER ENTITY BASED ON INFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS OR\n * OTHERWISE.\n */\n\n#ifndef HEADER_TLS1_H\n# define HEADER_TLS1_H\n\n# include <openssl/buffer.h>\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n# define TLS1_ALLOW_EXPERIMENTAL_CIPHERSUITES    0\n\n# define TLS1_VERSION                    0x0301\n# define TLS1_1_VERSION                  0x0302\n# define TLS1_2_VERSION                  0x0303\n# define TLS_MAX_VERSION                 TLS1_2_VERSION\n\n# define TLS1_VERSION_MAJOR              0x03\n# define TLS1_VERSION_MINOR              0x01\n\n# define TLS1_1_VERSION_MAJOR            0x03\n# define TLS1_1_VERSION_MINOR            0x02\n\n# define TLS1_2_VERSION_MAJOR            0x03\n# define TLS1_2_VERSION_MINOR            0x03\n\n# define TLS1_get_version(s) \\\n                ((s->version >> 8) == TLS1_VERSION_MAJOR ? s->version : 0)\n\n# define TLS1_get_client_version(s) \\\n                ((s->client_version >> 8) == TLS1_VERSION_MAJOR ? s->client_version : 0)\n\n# define TLS1_AD_DECRYPTION_FAILED       21\n# define TLS1_AD_RECORD_OVERFLOW         22\n# define TLS1_AD_UNKNOWN_CA              48/* fatal */\n# define TLS1_AD_ACCESS_DENIED           49/* fatal */\n# define TLS1_AD_DECODE_ERROR            50/* fatal */\n# define TLS1_AD_DECRYPT_ERROR           51\n# define TLS1_AD_EXPORT_RESTRICTION      60/* fatal */\n# define TLS1_AD_PROTOCOL_VERSION        70/* fatal */\n# define TLS1_AD_INSUFFICIENT_SECURITY   71/* fatal */\n# define TLS1_AD_INTERNAL_ERROR          80/* fatal */\n# define TLS1_AD_INAPPROPRIATE_FALLBACK  86/* fatal */\n# define TLS1_AD_USER_CANCELLED          90\n# define TLS1_AD_NO_RENEGOTIATION        100\n/* codes 110-114 are from RFC3546 */\n# define TLS1_AD_UNSUPPORTED_EXTENSION   110\n# define TLS1_AD_CERTIFICATE_UNOBTAINABLE 111\n# define TLS1_AD_UNRECOGNIZED_NAME       112\n# define TLS1_AD_BAD_CERTIFICATE_STATUS_RESPONSE 113\n# define TLS1_AD_BAD_CERTIFICATE_HASH_VALUE 114\n# define TLS1_AD_UNKNOWN_PSK_IDENTITY    115/* fatal */\n\n/* ExtensionType values from RFC3546 / RFC4366 / RFC6066 */\n# define TLSEXT_TYPE_server_name                 0\n# define TLSEXT_TYPE_max_fragment_length         1\n# define TLSEXT_TYPE_client_certificate_url      2\n# define TLSEXT_TYPE_trusted_ca_keys             3\n# define TLSEXT_TYPE_truncated_hmac              4\n# define TLSEXT_TYPE_status_request              5\n/* ExtensionType values from RFC4681 */\n# define TLSEXT_TYPE_user_mapping                6\n/* ExtensionType values from RFC5878 */\n# define TLSEXT_TYPE_client_authz                7\n# define TLSEXT_TYPE_server_authz                8\n/* ExtensionType values from RFC6091 */\n# define TLSEXT_TYPE_cert_type           9\n\n/* ExtensionType values from RFC4492 */\n# define TLSEXT_TYPE_elliptic_curves             10\n# define TLSEXT_TYPE_ec_point_formats            11\n\n/* ExtensionType value from RFC5054 */\n# define TLSEXT_TYPE_srp                         12\n\n/* ExtensionType values from RFC5246 */\n# define TLSEXT_TYPE_signature_algorithms        13\n\n/* ExtensionType value from RFC5764 */\n# define TLSEXT_TYPE_use_srtp    14\n\n/* ExtensionType value from RFC5620 */\n# define TLSEXT_TYPE_heartbeat   15\n\n/* ExtensionType value from RFC7301 */\n# define TLSEXT_TYPE_application_layer_protocol_negotiation 16\n\n/*\n * ExtensionType value for TLS padding extension.\n * http://tools.ietf.org/html/draft-agl-tls-padding\n */\n# define TLSEXT_TYPE_padding     21\n\n/* ExtensionType value from RFC4507 */\n# define TLSEXT_TYPE_session_ticket              35\n\n/* ExtensionType value from draft-rescorla-tls-opaque-prf-input-00.txt */\n# if 0\n/*\n * will have to be provided externally for now ,\n * i.e. build with -DTLSEXT_TYPE_opaque_prf_input=38183\n * using whatever extension number you'd like to try\n */\n#  define TLSEXT_TYPE_opaque_prf_input           ??\n# endif\n\n/* Temporary extension type */\n# define TLSEXT_TYPE_renegotiate                 0xff01\n\n# ifndef OPENSSL_NO_NEXTPROTONEG\n/* This is not an IANA defined extension number */\n#  define TLSEXT_TYPE_next_proto_neg              13172\n# endif\n\n/* NameType value from RFC3546 */\n# define TLSEXT_NAMETYPE_host_name 0\n/* status request value from RFC3546 */\n# define TLSEXT_STATUSTYPE_ocsp 1\n\n/* ECPointFormat values from RFC4492 */\n# define TLSEXT_ECPOINTFORMAT_first                      0\n# define TLSEXT_ECPOINTFORMAT_uncompressed               0\n# define TLSEXT_ECPOINTFORMAT_ansiX962_compressed_prime  1\n# define TLSEXT_ECPOINTFORMAT_ansiX962_compressed_char2  2\n# define TLSEXT_ECPOINTFORMAT_last                       2\n\n/* Signature and hash algorithms from RFC5246 */\n# define TLSEXT_signature_anonymous                      0\n# define TLSEXT_signature_rsa                            1\n# define TLSEXT_signature_dsa                            2\n# define TLSEXT_signature_ecdsa                          3\n\n/* Total number of different signature algorithms */\n# define TLSEXT_signature_num                            4\n\n# define TLSEXT_hash_none                                0\n# define TLSEXT_hash_md5                                 1\n# define TLSEXT_hash_sha1                                2\n# define TLSEXT_hash_sha224                              3\n# define TLSEXT_hash_sha256                              4\n# define TLSEXT_hash_sha384                              5\n# define TLSEXT_hash_sha512                              6\n\n/* Total number of different digest algorithms */\n\n# define TLSEXT_hash_num                                 7\n\n/* Flag set for unrecognised algorithms */\n# define TLSEXT_nid_unknown                              0x1000000\n\n/* ECC curves */\n\n# define TLSEXT_curve_P_256                              23\n# define TLSEXT_curve_P_384                              24\n\n# ifndef OPENSSL_NO_TLSEXT\n\n#  define TLSEXT_MAXLEN_host_name 255\n\nconst char *SSL_get_servername(const SSL *s, const int type);\nint SSL_get_servername_type(const SSL *s);\n/*\n * SSL_export_keying_material exports a value derived from the master secret,\n * as specified in RFC 5705. It writes |olen| bytes to |out| given a label and\n * optional context. (Since a zero length context is allowed, the |use_context|\n * flag controls whether a context is included.) It returns 1 on success and\n * zero otherwise.\n */\nint SSL_export_keying_material(SSL *s, unsigned char *out, size_t olen,\n                               const char *label, size_t llen,\n                               const unsigned char *p, size_t plen,\n                               int use_context);\n\nint SSL_get_sigalgs(SSL *s, int idx,\n                    int *psign, int *phash, int *psignandhash,\n                    unsigned char *rsig, unsigned char *rhash);\n\nint SSL_get_shared_sigalgs(SSL *s, int idx,\n                           int *psign, int *phash, int *psignandhash,\n                           unsigned char *rsig, unsigned char *rhash);\n\nint SSL_check_chain(SSL *s, X509 *x, EVP_PKEY *pk, STACK_OF(X509) *chain);\n\n#  define SSL_set_tlsext_host_name(s,name) \\\nSSL_ctrl(s,SSL_CTRL_SET_TLSEXT_HOSTNAME,TLSEXT_NAMETYPE_host_name,(char *)name)\n\n#  define SSL_set_tlsext_debug_callback(ssl, cb) \\\nSSL_callback_ctrl(ssl,SSL_CTRL_SET_TLSEXT_DEBUG_CB,(void (*)(void))cb)\n\n#  define SSL_set_tlsext_debug_arg(ssl, arg) \\\nSSL_ctrl(ssl,SSL_CTRL_SET_TLSEXT_DEBUG_ARG,0, (void *)arg)\n\n#  define SSL_set_tlsext_status_type(ssl, type) \\\nSSL_ctrl(ssl,SSL_CTRL_SET_TLSEXT_STATUS_REQ_TYPE,type, NULL)\n\n#  define SSL_get_tlsext_status_exts(ssl, arg) \\\nSSL_ctrl(ssl,SSL_CTRL_GET_TLSEXT_STATUS_REQ_EXTS,0, (void *)arg)\n\n#  define SSL_set_tlsext_status_exts(ssl, arg) \\\nSSL_ctrl(ssl,SSL_CTRL_SET_TLSEXT_STATUS_REQ_EXTS,0, (void *)arg)\n\n#  define SSL_get_tlsext_status_ids(ssl, arg) \\\nSSL_ctrl(ssl,SSL_CTRL_GET_TLSEXT_STATUS_REQ_IDS,0, (void *)arg)\n\n#  define SSL_set_tlsext_status_ids(ssl, arg) \\\nSSL_ctrl(ssl,SSL_CTRL_SET_TLSEXT_STATUS_REQ_IDS,0, (void *)arg)\n\n#  define SSL_get_tlsext_status_ocsp_resp(ssl, arg) \\\nSSL_ctrl(ssl,SSL_CTRL_GET_TLSEXT_STATUS_REQ_OCSP_RESP,0, (void *)arg)\n\n#  define SSL_set_tlsext_status_ocsp_resp(ssl, arg, arglen) \\\nSSL_ctrl(ssl,SSL_CTRL_SET_TLSEXT_STATUS_REQ_OCSP_RESP,arglen, (void *)arg)\n\n#  define SSL_CTX_set_tlsext_servername_callback(ctx, cb) \\\nSSL_CTX_callback_ctrl(ctx,SSL_CTRL_SET_TLSEXT_SERVERNAME_CB,(void (*)(void))cb)\n\n#  define SSL_TLSEXT_ERR_OK 0\n#  define SSL_TLSEXT_ERR_ALERT_WARNING 1\n#  define SSL_TLSEXT_ERR_ALERT_FATAL 2\n#  define SSL_TLSEXT_ERR_NOACK 3\n\n#  define SSL_CTX_set_tlsext_servername_arg(ctx, arg) \\\nSSL_CTX_ctrl(ctx,SSL_CTRL_SET_TLSEXT_SERVERNAME_ARG,0, (void *)arg)\n\n#  define SSL_CTX_get_tlsext_ticket_keys(ctx, keys, keylen) \\\n        SSL_CTX_ctrl((ctx),SSL_CTRL_GET_TLSEXT_TICKET_KEYS,(keylen),(keys))\n#  define SSL_CTX_set_tlsext_ticket_keys(ctx, keys, keylen) \\\n        SSL_CTX_ctrl((ctx),SSL_CTRL_SET_TLSEXT_TICKET_KEYS,(keylen),(keys))\n\n#  define SSL_CTX_set_tlsext_status_cb(ssl, cb) \\\nSSL_CTX_callback_ctrl(ssl,SSL_CTRL_SET_TLSEXT_STATUS_REQ_CB,(void (*)(void))cb)\n\n#  define SSL_CTX_set_tlsext_status_arg(ssl, arg) \\\nSSL_CTX_ctrl(ssl,SSL_CTRL_SET_TLSEXT_STATUS_REQ_CB_ARG,0, (void *)arg)\n\n#  define SSL_set_tlsext_opaque_prf_input(s, src, len) \\\nSSL_ctrl(s,SSL_CTRL_SET_TLSEXT_OPAQUE_PRF_INPUT, len, src)\n#  define SSL_CTX_set_tlsext_opaque_prf_input_callback(ctx, cb) \\\nSSL_CTX_callback_ctrl(ctx,SSL_CTRL_SET_TLSEXT_OPAQUE_PRF_INPUT_CB, (void (*)(void))cb)\n#  define SSL_CTX_set_tlsext_opaque_prf_input_callback_arg(ctx, arg) \\\nSSL_CTX_ctrl(ctx,SSL_CTRL_SET_TLSEXT_OPAQUE_PRF_INPUT_CB_ARG, 0, arg)\n\n#  define SSL_CTX_set_tlsext_ticket_key_cb(ssl, cb) \\\nSSL_CTX_callback_ctrl(ssl,SSL_CTRL_SET_TLSEXT_TICKET_KEY_CB,(void (*)(void))cb)\n\n#  ifndef OPENSSL_NO_HEARTBEATS\n#   define SSL_TLSEXT_HB_ENABLED                           0x01\n#   define SSL_TLSEXT_HB_DONT_SEND_REQUESTS        0x02\n#   define SSL_TLSEXT_HB_DONT_RECV_REQUESTS        0x04\n\n#   define SSL_get_tlsext_heartbeat_pending(ssl) \\\n        SSL_ctrl((ssl),SSL_CTRL_GET_TLS_EXT_HEARTBEAT_PENDING,0,NULL)\n#   define SSL_set_tlsext_heartbeat_no_requests(ssl, arg) \\\n        SSL_ctrl((ssl),SSL_CTRL_SET_TLS_EXT_HEARTBEAT_NO_REQUESTS,arg,NULL)\n#  endif\n# endif\n\n/* PSK ciphersuites from 4279 */\n# define TLS1_CK_PSK_WITH_RC4_128_SHA                    0x0300008A\n# define TLS1_CK_PSK_WITH_3DES_EDE_CBC_SHA               0x0300008B\n# define TLS1_CK_PSK_WITH_AES_128_CBC_SHA                0x0300008C\n# define TLS1_CK_PSK_WITH_AES_256_CBC_SHA                0x0300008D\n\n/*\n * Additional TLS ciphersuites from expired Internet Draft\n * draft-ietf-tls-56-bit-ciphersuites-01.txt (available if\n * TLS1_ALLOW_EXPERIMENTAL_CIPHERSUITES is defined, see s3_lib.c).  We\n * actually treat them like SSL 3.0 ciphers, which we probably shouldn't.\n * Note that the first two are actually not in the IDs.\n */\n# define TLS1_CK_RSA_EXPORT1024_WITH_RC4_56_MD5          0x03000060/* not in\n                                                                    * ID */\n# define TLS1_CK_RSA_EXPORT1024_WITH_RC2_CBC_56_MD5      0x03000061/* not in\n                                                                    * ID */\n# define TLS1_CK_RSA_EXPORT1024_WITH_DES_CBC_SHA         0x03000062\n# define TLS1_CK_DHE_DSS_EXPORT1024_WITH_DES_CBC_SHA     0x03000063\n# define TLS1_CK_RSA_EXPORT1024_WITH_RC4_56_SHA          0x03000064\n# define TLS1_CK_DHE_DSS_EXPORT1024_WITH_RC4_56_SHA      0x03000065\n# define TLS1_CK_DHE_DSS_WITH_RC4_128_SHA                0x03000066\n\n/* AES ciphersuites from RFC3268 */\n# define TLS1_CK_RSA_WITH_AES_128_SHA                    0x0300002F\n# define TLS1_CK_DH_DSS_WITH_AES_128_SHA                 0x03000030\n# define TLS1_CK_DH_RSA_WITH_AES_128_SHA                 0x03000031\n# define TLS1_CK_DHE_DSS_WITH_AES_128_SHA                0x03000032\n# define TLS1_CK_DHE_RSA_WITH_AES_128_SHA                0x03000033\n# define TLS1_CK_ADH_WITH_AES_128_SHA                    0x03000034\n\n# define TLS1_CK_RSA_WITH_AES_256_SHA                    0x03000035\n# define TLS1_CK_DH_DSS_WITH_AES_256_SHA                 0x03000036\n# define TLS1_CK_DH_RSA_WITH_AES_256_SHA                 0x03000037\n# define TLS1_CK_DHE_DSS_WITH_AES_256_SHA                0x03000038\n# define TLS1_CK_DHE_RSA_WITH_AES_256_SHA                0x03000039\n# define TLS1_CK_ADH_WITH_AES_256_SHA                    0x0300003A\n\n/* TLS v1.2 ciphersuites */\n# define TLS1_CK_RSA_WITH_NULL_SHA256                    0x0300003B\n# define TLS1_CK_RSA_WITH_AES_128_SHA256                 0x0300003C\n# define TLS1_CK_RSA_WITH_AES_256_SHA256                 0x0300003D\n# define TLS1_CK_DH_DSS_WITH_AES_128_SHA256              0x0300003E\n# define TLS1_CK_DH_RSA_WITH_AES_128_SHA256              0x0300003F\n# define TLS1_CK_DHE_DSS_WITH_AES_128_SHA256             0x03000040\n\n/* Camellia ciphersuites from RFC4132 */\n# define TLS1_CK_RSA_WITH_CAMELLIA_128_CBC_SHA           0x03000041\n# define TLS1_CK_DH_DSS_WITH_CAMELLIA_128_CBC_SHA        0x03000042\n# define TLS1_CK_DH_RSA_WITH_CAMELLIA_128_CBC_SHA        0x03000043\n# define TLS1_CK_DHE_DSS_WITH_CAMELLIA_128_CBC_SHA       0x03000044\n# define TLS1_CK_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA       0x03000045\n# define TLS1_CK_ADH_WITH_CAMELLIA_128_CBC_SHA           0x03000046\n\n/* TLS v1.2 ciphersuites */\n# define TLS1_CK_DHE_RSA_WITH_AES_128_SHA256             0x03000067\n# define TLS1_CK_DH_DSS_WITH_AES_256_SHA256              0x03000068\n# define TLS1_CK_DH_RSA_WITH_AES_256_SHA256              0x03000069\n# define TLS1_CK_DHE_DSS_WITH_AES_256_SHA256             0x0300006A\n# define TLS1_CK_DHE_RSA_WITH_AES_256_SHA256             0x0300006B\n# define TLS1_CK_ADH_WITH_AES_128_SHA256                 0x0300006C\n# define TLS1_CK_ADH_WITH_AES_256_SHA256                 0x0300006D\n\n/* Camellia ciphersuites from RFC4132 */\n# define TLS1_CK_RSA_WITH_CAMELLIA_256_CBC_SHA           0x03000084\n# define TLS1_CK_DH_DSS_WITH_CAMELLIA_256_CBC_SHA        0x03000085\n# define TLS1_CK_DH_RSA_WITH_CAMELLIA_256_CBC_SHA        0x03000086\n# define TLS1_CK_DHE_DSS_WITH_CAMELLIA_256_CBC_SHA       0x03000087\n# define TLS1_CK_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA       0x03000088\n# define TLS1_CK_ADH_WITH_CAMELLIA_256_CBC_SHA           0x03000089\n\n/* SEED ciphersuites from RFC4162 */\n# define TLS1_CK_RSA_WITH_SEED_SHA                       0x03000096\n# define TLS1_CK_DH_DSS_WITH_SEED_SHA                    0x03000097\n# define TLS1_CK_DH_RSA_WITH_SEED_SHA                    0x03000098\n# define TLS1_CK_DHE_DSS_WITH_SEED_SHA                   0x03000099\n# define TLS1_CK_DHE_RSA_WITH_SEED_SHA                   0x0300009A\n# define TLS1_CK_ADH_WITH_SEED_SHA                       0x0300009B\n\n/* TLS v1.2 GCM ciphersuites from RFC5288 */\n# define TLS1_CK_RSA_WITH_AES_128_GCM_SHA256             0x0300009C\n# define TLS1_CK_RSA_WITH_AES_256_GCM_SHA384             0x0300009D\n# define TLS1_CK_DHE_RSA_WITH_AES_128_GCM_SHA256         0x0300009E\n# define TLS1_CK_DHE_RSA_WITH_AES_256_GCM_SHA384         0x0300009F\n# define TLS1_CK_DH_RSA_WITH_AES_128_GCM_SHA256          0x030000A0\n# define TLS1_CK_DH_RSA_WITH_AES_256_GCM_SHA384          0x030000A1\n# define TLS1_CK_DHE_DSS_WITH_AES_128_GCM_SHA256         0x030000A2\n# define TLS1_CK_DHE_DSS_WITH_AES_256_GCM_SHA384         0x030000A3\n# define TLS1_CK_DH_DSS_WITH_AES_128_GCM_SHA256          0x030000A4\n# define TLS1_CK_DH_DSS_WITH_AES_256_GCM_SHA384          0x030000A5\n# define TLS1_CK_ADH_WITH_AES_128_GCM_SHA256             0x030000A6\n# define TLS1_CK_ADH_WITH_AES_256_GCM_SHA384             0x030000A7\n\n/*\n * ECC ciphersuites from draft-ietf-tls-ecc-12.txt with changes soon to be in\n * draft 13\n */\n# define TLS1_CK_ECDH_ECDSA_WITH_NULL_SHA                0x0300C001\n# define TLS1_CK_ECDH_ECDSA_WITH_RC4_128_SHA             0x0300C002\n# define TLS1_CK_ECDH_ECDSA_WITH_DES_192_CBC3_SHA        0x0300C003\n# define TLS1_CK_ECDH_ECDSA_WITH_AES_128_CBC_SHA         0x0300C004\n# define TLS1_CK_ECDH_ECDSA_WITH_AES_256_CBC_SHA         0x0300C005\n\n# define TLS1_CK_ECDHE_ECDSA_WITH_NULL_SHA               0x0300C006\n# define TLS1_CK_ECDHE_ECDSA_WITH_RC4_128_SHA            0x0300C007\n# define TLS1_CK_ECDHE_ECDSA_WITH_DES_192_CBC3_SHA       0x0300C008\n# define TLS1_CK_ECDHE_ECDSA_WITH_AES_128_CBC_SHA        0x0300C009\n# define TLS1_CK_ECDHE_ECDSA_WITH_AES_256_CBC_SHA        0x0300C00A\n\n# define TLS1_CK_ECDH_RSA_WITH_NULL_SHA                  0x0300C00B\n# define TLS1_CK_ECDH_RSA_WITH_RC4_128_SHA               0x0300C00C\n# define TLS1_CK_ECDH_RSA_WITH_DES_192_CBC3_SHA          0x0300C00D\n# define TLS1_CK_ECDH_RSA_WITH_AES_128_CBC_SHA           0x0300C00E\n# define TLS1_CK_ECDH_RSA_WITH_AES_256_CBC_SHA           0x0300C00F\n\n# define TLS1_CK_ECDHE_RSA_WITH_NULL_SHA                 0x0300C010\n# define TLS1_CK_ECDHE_RSA_WITH_RC4_128_SHA              0x0300C011\n# define TLS1_CK_ECDHE_RSA_WITH_DES_192_CBC3_SHA         0x0300C012\n# define TLS1_CK_ECDHE_RSA_WITH_AES_128_CBC_SHA          0x0300C013\n# define TLS1_CK_ECDHE_RSA_WITH_AES_256_CBC_SHA          0x0300C014\n\n# define TLS1_CK_ECDH_anon_WITH_NULL_SHA                 0x0300C015\n# define TLS1_CK_ECDH_anon_WITH_RC4_128_SHA              0x0300C016\n# define TLS1_CK_ECDH_anon_WITH_DES_192_CBC3_SHA         0x0300C017\n# define TLS1_CK_ECDH_anon_WITH_AES_128_CBC_SHA          0x0300C018\n# define TLS1_CK_ECDH_anon_WITH_AES_256_CBC_SHA          0x0300C019\n\n/* SRP ciphersuites from RFC 5054 */\n# define TLS1_CK_SRP_SHA_WITH_3DES_EDE_CBC_SHA           0x0300C01A\n# define TLS1_CK_SRP_SHA_RSA_WITH_3DES_EDE_CBC_SHA       0x0300C01B\n# define TLS1_CK_SRP_SHA_DSS_WITH_3DES_EDE_CBC_SHA       0x0300C01C\n# define TLS1_CK_SRP_SHA_WITH_AES_128_CBC_SHA            0x0300C01D\n# define TLS1_CK_SRP_SHA_RSA_WITH_AES_128_CBC_SHA        0x0300C01E\n# define TLS1_CK_SRP_SHA_DSS_WITH_AES_128_CBC_SHA        0x0300C01F\n# define TLS1_CK_SRP_SHA_WITH_AES_256_CBC_SHA            0x0300C020\n# define TLS1_CK_SRP_SHA_RSA_WITH_AES_256_CBC_SHA        0x0300C021\n# define TLS1_CK_SRP_SHA_DSS_WITH_AES_256_CBC_SHA        0x0300C022\n\n/* ECDH HMAC based ciphersuites from RFC5289 */\n\n# define TLS1_CK_ECDHE_ECDSA_WITH_AES_128_SHA256         0x0300C023\n# define TLS1_CK_ECDHE_ECDSA_WITH_AES_256_SHA384         0x0300C024\n# define TLS1_CK_ECDH_ECDSA_WITH_AES_128_SHA256          0x0300C025\n# define TLS1_CK_ECDH_ECDSA_WITH_AES_256_SHA384          0x0300C026\n# define TLS1_CK_ECDHE_RSA_WITH_AES_128_SHA256           0x0300C027\n# define TLS1_CK_ECDHE_RSA_WITH_AES_256_SHA384           0x0300C028\n# define TLS1_CK_ECDH_RSA_WITH_AES_128_SHA256            0x0300C029\n# define TLS1_CK_ECDH_RSA_WITH_AES_256_SHA384            0x0300C02A\n\n/* ECDH GCM based ciphersuites from RFC5289 */\n# define TLS1_CK_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256     0x0300C02B\n# define TLS1_CK_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384     0x0300C02C\n# define TLS1_CK_ECDH_ECDSA_WITH_AES_128_GCM_SHA256      0x0300C02D\n# define TLS1_CK_ECDH_ECDSA_WITH_AES_256_GCM_SHA384      0x0300C02E\n# define TLS1_CK_ECDHE_RSA_WITH_AES_128_GCM_SHA256       0x0300C02F\n# define TLS1_CK_ECDHE_RSA_WITH_AES_256_GCM_SHA384       0x0300C030\n# define TLS1_CK_ECDH_RSA_WITH_AES_128_GCM_SHA256        0x0300C031\n# define TLS1_CK_ECDH_RSA_WITH_AES_256_GCM_SHA384        0x0300C032\n\n/*\n * XXX * Backward compatibility alert: + * Older versions of OpenSSL gave\n * some DHE ciphers names with \"EDH\" + * instead of \"DHE\".  Going forward, we\n * should be using DHE + * everywhere, though we may indefinitely maintain\n * aliases for users + * or configurations that used \"EDH\" +\n */\n# define TLS1_TXT_RSA_EXPORT1024_WITH_RC4_56_MD5         \"EXP1024-RC4-MD5\"\n# define TLS1_TXT_RSA_EXPORT1024_WITH_RC2_CBC_56_MD5     \"EXP1024-RC2-CBC-MD5\"\n# define TLS1_TXT_RSA_EXPORT1024_WITH_DES_CBC_SHA        \"EXP1024-DES-CBC-SHA\"\n# define TLS1_TXT_DHE_DSS_EXPORT1024_WITH_DES_CBC_SHA    \"EXP1024-DHE-DSS-DES-CBC-SHA\"\n# define TLS1_TXT_RSA_EXPORT1024_WITH_RC4_56_SHA         \"EXP1024-RC4-SHA\"\n# define TLS1_TXT_DHE_DSS_EXPORT1024_WITH_RC4_56_SHA     \"EXP1024-DHE-DSS-RC4-SHA\"\n# define TLS1_TXT_DHE_DSS_WITH_RC4_128_SHA               \"DHE-DSS-RC4-SHA\"\n\n/* AES ciphersuites from RFC3268 */\n# define TLS1_TXT_RSA_WITH_AES_128_SHA                   \"AES128-SHA\"\n# define TLS1_TXT_DH_DSS_WITH_AES_128_SHA                \"DH-DSS-AES128-SHA\"\n# define TLS1_TXT_DH_RSA_WITH_AES_128_SHA                \"DH-RSA-AES128-SHA\"\n# define TLS1_TXT_DHE_DSS_WITH_AES_128_SHA               \"DHE-DSS-AES128-SHA\"\n# define TLS1_TXT_DHE_RSA_WITH_AES_128_SHA               \"DHE-RSA-AES128-SHA\"\n# define TLS1_TXT_ADH_WITH_AES_128_SHA                   \"ADH-AES128-SHA\"\n\n# define TLS1_TXT_RSA_WITH_AES_256_SHA                   \"AES256-SHA\"\n# define TLS1_TXT_DH_DSS_WITH_AES_256_SHA                \"DH-DSS-AES256-SHA\"\n# define TLS1_TXT_DH_RSA_WITH_AES_256_SHA                \"DH-RSA-AES256-SHA\"\n# define TLS1_TXT_DHE_DSS_WITH_AES_256_SHA               \"DHE-DSS-AES256-SHA\"\n# define TLS1_TXT_DHE_RSA_WITH_AES_256_SHA               \"DHE-RSA-AES256-SHA\"\n# define TLS1_TXT_ADH_WITH_AES_256_SHA                   \"ADH-AES256-SHA\"\n\n/* ECC ciphersuites from RFC4492 */\n# define TLS1_TXT_ECDH_ECDSA_WITH_NULL_SHA               \"ECDH-ECDSA-NULL-SHA\"\n# define TLS1_TXT_ECDH_ECDSA_WITH_RC4_128_SHA            \"ECDH-ECDSA-RC4-SHA\"\n# define TLS1_TXT_ECDH_ECDSA_WITH_DES_192_CBC3_SHA       \"ECDH-ECDSA-DES-CBC3-SHA\"\n# define TLS1_TXT_ECDH_ECDSA_WITH_AES_128_CBC_SHA        \"ECDH-ECDSA-AES128-SHA\"\n# define TLS1_TXT_ECDH_ECDSA_WITH_AES_256_CBC_SHA        \"ECDH-ECDSA-AES256-SHA\"\n\n# define TLS1_TXT_ECDHE_ECDSA_WITH_NULL_SHA              \"ECDHE-ECDSA-NULL-SHA\"\n# define TLS1_TXT_ECDHE_ECDSA_WITH_RC4_128_SHA           \"ECDHE-ECDSA-RC4-SHA\"\n# define TLS1_TXT_ECDHE_ECDSA_WITH_DES_192_CBC3_SHA      \"ECDHE-ECDSA-DES-CBC3-SHA\"\n# define TLS1_TXT_ECDHE_ECDSA_WITH_AES_128_CBC_SHA       \"ECDHE-ECDSA-AES128-SHA\"\n# define TLS1_TXT_ECDHE_ECDSA_WITH_AES_256_CBC_SHA       \"ECDHE-ECDSA-AES256-SHA\"\n\n# define TLS1_TXT_ECDH_RSA_WITH_NULL_SHA                 \"ECDH-RSA-NULL-SHA\"\n# define TLS1_TXT_ECDH_RSA_WITH_RC4_128_SHA              \"ECDH-RSA-RC4-SHA\"\n# define TLS1_TXT_ECDH_RSA_WITH_DES_192_CBC3_SHA         \"ECDH-RSA-DES-CBC3-SHA\"\n# define TLS1_TXT_ECDH_RSA_WITH_AES_128_CBC_SHA          \"ECDH-RSA-AES128-SHA\"\n# define TLS1_TXT_ECDH_RSA_WITH_AES_256_CBC_SHA          \"ECDH-RSA-AES256-SHA\"\n\n# define TLS1_TXT_ECDHE_RSA_WITH_NULL_SHA                \"ECDHE-RSA-NULL-SHA\"\n# define TLS1_TXT_ECDHE_RSA_WITH_RC4_128_SHA             \"ECDHE-RSA-RC4-SHA\"\n# define TLS1_TXT_ECDHE_RSA_WITH_DES_192_CBC3_SHA        \"ECDHE-RSA-DES-CBC3-SHA\"\n# define TLS1_TXT_ECDHE_RSA_WITH_AES_128_CBC_SHA         \"ECDHE-RSA-AES128-SHA\"\n# define TLS1_TXT_ECDHE_RSA_WITH_AES_256_CBC_SHA         \"ECDHE-RSA-AES256-SHA\"\n\n# define TLS1_TXT_ECDH_anon_WITH_NULL_SHA                \"AECDH-NULL-SHA\"\n# define TLS1_TXT_ECDH_anon_WITH_RC4_128_SHA             \"AECDH-RC4-SHA\"\n# define TLS1_TXT_ECDH_anon_WITH_DES_192_CBC3_SHA        \"AECDH-DES-CBC3-SHA\"\n# define TLS1_TXT_ECDH_anon_WITH_AES_128_CBC_SHA         \"AECDH-AES128-SHA\"\n# define TLS1_TXT_ECDH_anon_WITH_AES_256_CBC_SHA         \"AECDH-AES256-SHA\"\n\n/* PSK ciphersuites from RFC 4279 */\n# define TLS1_TXT_PSK_WITH_RC4_128_SHA                   \"PSK-RC4-SHA\"\n# define TLS1_TXT_PSK_WITH_3DES_EDE_CBC_SHA              \"PSK-3DES-EDE-CBC-SHA\"\n# define TLS1_TXT_PSK_WITH_AES_128_CBC_SHA               \"PSK-AES128-CBC-SHA\"\n# define TLS1_TXT_PSK_WITH_AES_256_CBC_SHA               \"PSK-AES256-CBC-SHA\"\n\n/* SRP ciphersuite from RFC 5054 */\n# define TLS1_TXT_SRP_SHA_WITH_3DES_EDE_CBC_SHA          \"SRP-3DES-EDE-CBC-SHA\"\n# define TLS1_TXT_SRP_SHA_RSA_WITH_3DES_EDE_CBC_SHA      \"SRP-RSA-3DES-EDE-CBC-SHA\"\n# define TLS1_TXT_SRP_SHA_DSS_WITH_3DES_EDE_CBC_SHA      \"SRP-DSS-3DES-EDE-CBC-SHA\"\n# define TLS1_TXT_SRP_SHA_WITH_AES_128_CBC_SHA           \"SRP-AES-128-CBC-SHA\"\n# define TLS1_TXT_SRP_SHA_RSA_WITH_AES_128_CBC_SHA       \"SRP-RSA-AES-128-CBC-SHA\"\n# define TLS1_TXT_SRP_SHA_DSS_WITH_AES_128_CBC_SHA       \"SRP-DSS-AES-128-CBC-SHA\"\n# define TLS1_TXT_SRP_SHA_WITH_AES_256_CBC_SHA           \"SRP-AES-256-CBC-SHA\"\n# define TLS1_TXT_SRP_SHA_RSA_WITH_AES_256_CBC_SHA       \"SRP-RSA-AES-256-CBC-SHA\"\n# define TLS1_TXT_SRP_SHA_DSS_WITH_AES_256_CBC_SHA       \"SRP-DSS-AES-256-CBC-SHA\"\n\n/* Camellia ciphersuites from RFC4132 */\n# define TLS1_TXT_RSA_WITH_CAMELLIA_128_CBC_SHA          \"CAMELLIA128-SHA\"\n# define TLS1_TXT_DH_DSS_WITH_CAMELLIA_128_CBC_SHA       \"DH-DSS-CAMELLIA128-SHA\"\n# define TLS1_TXT_DH_RSA_WITH_CAMELLIA_128_CBC_SHA       \"DH-RSA-CAMELLIA128-SHA\"\n# define TLS1_TXT_DHE_DSS_WITH_CAMELLIA_128_CBC_SHA      \"DHE-DSS-CAMELLIA128-SHA\"\n# define TLS1_TXT_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA      \"DHE-RSA-CAMELLIA128-SHA\"\n# define TLS1_TXT_ADH_WITH_CAMELLIA_128_CBC_SHA          \"ADH-CAMELLIA128-SHA\"\n\n# define TLS1_TXT_RSA_WITH_CAMELLIA_256_CBC_SHA          \"CAMELLIA256-SHA\"\n# define TLS1_TXT_DH_DSS_WITH_CAMELLIA_256_CBC_SHA       \"DH-DSS-CAMELLIA256-SHA\"\n# define TLS1_TXT_DH_RSA_WITH_CAMELLIA_256_CBC_SHA       \"DH-RSA-CAMELLIA256-SHA\"\n# define TLS1_TXT_DHE_DSS_WITH_CAMELLIA_256_CBC_SHA      \"DHE-DSS-CAMELLIA256-SHA\"\n# define TLS1_TXT_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA      \"DHE-RSA-CAMELLIA256-SHA\"\n# define TLS1_TXT_ADH_WITH_CAMELLIA_256_CBC_SHA          \"ADH-CAMELLIA256-SHA\"\n\n/* SEED ciphersuites from RFC4162 */\n# define TLS1_TXT_RSA_WITH_SEED_SHA                      \"SEED-SHA\"\n# define TLS1_TXT_DH_DSS_WITH_SEED_SHA                   \"DH-DSS-SEED-SHA\"\n# define TLS1_TXT_DH_RSA_WITH_SEED_SHA                   \"DH-RSA-SEED-SHA\"\n# define TLS1_TXT_DHE_DSS_WITH_SEED_SHA                  \"DHE-DSS-SEED-SHA\"\n# define TLS1_TXT_DHE_RSA_WITH_SEED_SHA                  \"DHE-RSA-SEED-SHA\"\n# define TLS1_TXT_ADH_WITH_SEED_SHA                      \"ADH-SEED-SHA\"\n\n/* TLS v1.2 ciphersuites */\n# define TLS1_TXT_RSA_WITH_NULL_SHA256                   \"NULL-SHA256\"\n# define TLS1_TXT_RSA_WITH_AES_128_SHA256                \"AES128-SHA256\"\n# define TLS1_TXT_RSA_WITH_AES_256_SHA256                \"AES256-SHA256\"\n# define TLS1_TXT_DH_DSS_WITH_AES_128_SHA256             \"DH-DSS-AES128-SHA256\"\n# define TLS1_TXT_DH_RSA_WITH_AES_128_SHA256             \"DH-RSA-AES128-SHA256\"\n# define TLS1_TXT_DHE_DSS_WITH_AES_128_SHA256            \"DHE-DSS-AES128-SHA256\"\n# define TLS1_TXT_DHE_RSA_WITH_AES_128_SHA256            \"DHE-RSA-AES128-SHA256\"\n# define TLS1_TXT_DH_DSS_WITH_AES_256_SHA256             \"DH-DSS-AES256-SHA256\"\n# define TLS1_TXT_DH_RSA_WITH_AES_256_SHA256             \"DH-RSA-AES256-SHA256\"\n# define TLS1_TXT_DHE_DSS_WITH_AES_256_SHA256            \"DHE-DSS-AES256-SHA256\"\n# define TLS1_TXT_DHE_RSA_WITH_AES_256_SHA256            \"DHE-RSA-AES256-SHA256\"\n# define TLS1_TXT_ADH_WITH_AES_128_SHA256                \"ADH-AES128-SHA256\"\n# define TLS1_TXT_ADH_WITH_AES_256_SHA256                \"ADH-AES256-SHA256\"\n\n/* TLS v1.2 GCM ciphersuites from RFC5288 */\n# define TLS1_TXT_RSA_WITH_AES_128_GCM_SHA256            \"AES128-GCM-SHA256\"\n# define TLS1_TXT_RSA_WITH_AES_256_GCM_SHA384            \"AES256-GCM-SHA384\"\n# define TLS1_TXT_DHE_RSA_WITH_AES_128_GCM_SHA256        \"DHE-RSA-AES128-GCM-SHA256\"\n# define TLS1_TXT_DHE_RSA_WITH_AES_256_GCM_SHA384        \"DHE-RSA-AES256-GCM-SHA384\"\n# define TLS1_TXT_DH_RSA_WITH_AES_128_GCM_SHA256         \"DH-RSA-AES128-GCM-SHA256\"\n# define TLS1_TXT_DH_RSA_WITH_AES_256_GCM_SHA384         \"DH-RSA-AES256-GCM-SHA384\"\n# define TLS1_TXT_DHE_DSS_WITH_AES_128_GCM_SHA256        \"DHE-DSS-AES128-GCM-SHA256\"\n# define TLS1_TXT_DHE_DSS_WITH_AES_256_GCM_SHA384        \"DHE-DSS-AES256-GCM-SHA384\"\n# define TLS1_TXT_DH_DSS_WITH_AES_128_GCM_SHA256         \"DH-DSS-AES128-GCM-SHA256\"\n# define TLS1_TXT_DH_DSS_WITH_AES_256_GCM_SHA384         \"DH-DSS-AES256-GCM-SHA384\"\n# define TLS1_TXT_ADH_WITH_AES_128_GCM_SHA256            \"ADH-AES128-GCM-SHA256\"\n# define TLS1_TXT_ADH_WITH_AES_256_GCM_SHA384            \"ADH-AES256-GCM-SHA384\"\n\n/* ECDH HMAC based ciphersuites from RFC5289 */\n\n# define TLS1_TXT_ECDHE_ECDSA_WITH_AES_128_SHA256    \"ECDHE-ECDSA-AES128-SHA256\"\n# define TLS1_TXT_ECDHE_ECDSA_WITH_AES_256_SHA384    \"ECDHE-ECDSA-AES256-SHA384\"\n# define TLS1_TXT_ECDH_ECDSA_WITH_AES_128_SHA256     \"ECDH-ECDSA-AES128-SHA256\"\n# define TLS1_TXT_ECDH_ECDSA_WITH_AES_256_SHA384     \"ECDH-ECDSA-AES256-SHA384\"\n# define TLS1_TXT_ECDHE_RSA_WITH_AES_128_SHA256      \"ECDHE-RSA-AES128-SHA256\"\n# define TLS1_TXT_ECDHE_RSA_WITH_AES_256_SHA384      \"ECDHE-RSA-AES256-SHA384\"\n# define TLS1_TXT_ECDH_RSA_WITH_AES_128_SHA256       \"ECDH-RSA-AES128-SHA256\"\n# define TLS1_TXT_ECDH_RSA_WITH_AES_256_SHA384       \"ECDH-RSA-AES256-SHA384\"\n\n/* ECDH GCM based ciphersuites from RFC5289 */\n# define TLS1_TXT_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256    \"ECDHE-ECDSA-AES128-GCM-SHA256\"\n# define TLS1_TXT_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384    \"ECDHE-ECDSA-AES256-GCM-SHA384\"\n# define TLS1_TXT_ECDH_ECDSA_WITH_AES_128_GCM_SHA256     \"ECDH-ECDSA-AES128-GCM-SHA256\"\n# define TLS1_TXT_ECDH_ECDSA_WITH_AES_256_GCM_SHA384     \"ECDH-ECDSA-AES256-GCM-SHA384\"\n# define TLS1_TXT_ECDHE_RSA_WITH_AES_128_GCM_SHA256      \"ECDHE-RSA-AES128-GCM-SHA256\"\n# define TLS1_TXT_ECDHE_RSA_WITH_AES_256_GCM_SHA384      \"ECDHE-RSA-AES256-GCM-SHA384\"\n# define TLS1_TXT_ECDH_RSA_WITH_AES_128_GCM_SHA256       \"ECDH-RSA-AES128-GCM-SHA256\"\n# define TLS1_TXT_ECDH_RSA_WITH_AES_256_GCM_SHA384       \"ECDH-RSA-AES256-GCM-SHA384\"\n\n# define TLS_CT_RSA_SIGN                 1\n# define TLS_CT_DSS_SIGN                 2\n# define TLS_CT_RSA_FIXED_DH             3\n# define TLS_CT_DSS_FIXED_DH             4\n# define TLS_CT_ECDSA_SIGN               64\n# define TLS_CT_RSA_FIXED_ECDH           65\n# define TLS_CT_ECDSA_FIXED_ECDH         66\n# define TLS_CT_GOST94_SIGN              21\n# define TLS_CT_GOST01_SIGN              22\n/*\n * when correcting this number, correct also SSL3_CT_NUMBER in ssl3.h (see\n * comment there)\n */\n# define TLS_CT_NUMBER                   9\n\n# define TLS1_FINISH_MAC_LENGTH          12\n\n# define TLS_MD_MAX_CONST_SIZE                   20\n# define TLS_MD_CLIENT_FINISH_CONST              \"client finished\"\n# define TLS_MD_CLIENT_FINISH_CONST_SIZE         15\n# define TLS_MD_SERVER_FINISH_CONST              \"server finished\"\n# define TLS_MD_SERVER_FINISH_CONST_SIZE         15\n# define TLS_MD_SERVER_WRITE_KEY_CONST           \"server write key\"\n# define TLS_MD_SERVER_WRITE_KEY_CONST_SIZE      16\n# define TLS_MD_KEY_EXPANSION_CONST              \"key expansion\"\n# define TLS_MD_KEY_EXPANSION_CONST_SIZE         13\n# define TLS_MD_CLIENT_WRITE_KEY_CONST           \"client write key\"\n# define TLS_MD_CLIENT_WRITE_KEY_CONST_SIZE      16\n# define TLS_MD_SERVER_WRITE_KEY_CONST           \"server write key\"\n# define TLS_MD_SERVER_WRITE_KEY_CONST_SIZE      16\n# define TLS_MD_IV_BLOCK_CONST                   \"IV block\"\n# define TLS_MD_IV_BLOCK_CONST_SIZE              8\n# define TLS_MD_MASTER_SECRET_CONST              \"master secret\"\n# define TLS_MD_MASTER_SECRET_CONST_SIZE         13\n\n# ifdef CHARSET_EBCDIC\n#  undef TLS_MD_CLIENT_FINISH_CONST\n/*\n * client finished\n */\n#  define TLS_MD_CLIENT_FINISH_CONST    \"\\x63\\x6c\\x69\\x65\\x6e\\x74\\x20\\x66\\x69\\x6e\\x69\\x73\\x68\\x65\\x64\"\n\n#  undef TLS_MD_SERVER_FINISH_CONST\n/*\n * server finished\n */\n#  define TLS_MD_SERVER_FINISH_CONST    \"\\x73\\x65\\x72\\x76\\x65\\x72\\x20\\x66\\x69\\x6e\\x69\\x73\\x68\\x65\\x64\"\n\n#  undef TLS_MD_SERVER_WRITE_KEY_CONST\n/*\n * server write key\n */\n#  define TLS_MD_SERVER_WRITE_KEY_CONST \"\\x73\\x65\\x72\\x76\\x65\\x72\\x20\\x77\\x72\\x69\\x74\\x65\\x20\\x6b\\x65\\x79\"\n\n#  undef TLS_MD_KEY_EXPANSION_CONST\n/*\n * key expansion\n */\n#  define TLS_MD_KEY_EXPANSION_CONST    \"\\x6b\\x65\\x79\\x20\\x65\\x78\\x70\\x61\\x6e\\x73\\x69\\x6f\\x6e\"\n\n#  undef TLS_MD_CLIENT_WRITE_KEY_CONST\n/*\n * client write key\n */\n#  define TLS_MD_CLIENT_WRITE_KEY_CONST \"\\x63\\x6c\\x69\\x65\\x6e\\x74\\x20\\x77\\x72\\x69\\x74\\x65\\x20\\x6b\\x65\\x79\"\n\n#  undef TLS_MD_SERVER_WRITE_KEY_CONST\n/*\n * server write key\n */\n#  define TLS_MD_SERVER_WRITE_KEY_CONST \"\\x73\\x65\\x72\\x76\\x65\\x72\\x20\\x77\\x72\\x69\\x74\\x65\\x20\\x6b\\x65\\x79\"\n\n#  undef TLS_MD_IV_BLOCK_CONST\n/*\n * IV block\n */\n#  define TLS_MD_IV_BLOCK_CONST         \"\\x49\\x56\\x20\\x62\\x6c\\x6f\\x63\\x6b\"\n\n#  undef TLS_MD_MASTER_SECRET_CONST\n/*\n * master secret\n */\n#  define TLS_MD_MASTER_SECRET_CONST    \"\\x6d\\x61\\x73\\x74\\x65\\x72\\x20\\x73\\x65\\x63\\x72\\x65\\x74\"\n# endif\n\n/* TLS Session Ticket extension struct */\nstruct tls_session_ticket_ext_st {\n    unsigned short length;\n    void *data;\n};\n\n#ifdef  __cplusplus\n}\n#endif\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/arm64/include/openssl/ts.h",
    "content": "/* crypto/ts/ts.h */\n/*\n * Written by Zoltan Glozik (zglozik@opentsa.org) for the OpenSSL project\n * 2002, 2003, 2004.\n */\n/* ====================================================================\n * Copyright (c) 2006 The OpenSSL Project.  All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n *\n * 1. Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n *\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in\n *    the documentation and/or other materials provided with the\n *    distribution.\n *\n * 3. All advertising materials mentioning features or use of this\n *    software must display the following acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)\"\n *\n * 4. The names \"OpenSSL Toolkit\" and \"OpenSSL Project\" must not be used to\n *    endorse or promote products derived from this software without\n *    prior written permission. For written permission, please contact\n *    licensing@OpenSSL.org.\n *\n * 5. Products derived from this software may not be called \"OpenSSL\"\n *    nor may \"OpenSSL\" appear in their names without prior written\n *    permission of the OpenSSL Project.\n *\n * 6. Redistributions of any form whatsoever must retain the following\n *    acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)\"\n *\n * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY\n * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\n * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR\n * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\n * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,\n * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED\n * OF THE POSSIBILITY OF SUCH DAMAGE.\n * ====================================================================\n *\n * This product includes cryptographic software written by Eric Young\n * (eay@cryptsoft.com).  This product includes software written by Tim\n * Hudson (tjh@cryptsoft.com).\n *\n */\n\n#ifndef HEADER_TS_H\n# define HEADER_TS_H\n\n# include <openssl/opensslconf.h>\n# include <openssl/symhacks.h>\n# ifndef OPENSSL_NO_BUFFER\n#  include <openssl/buffer.h>\n# endif\n# ifndef OPENSSL_NO_EVP\n#  include <openssl/evp.h>\n# endif\n# ifndef OPENSSL_NO_BIO\n#  include <openssl/bio.h>\n# endif\n# include <openssl/stack.h>\n# include <openssl/asn1.h>\n# include <openssl/safestack.h>\n\n# ifndef OPENSSL_NO_RSA\n#  include <openssl/rsa.h>\n# endif\n\n# ifndef OPENSSL_NO_DSA\n#  include <openssl/dsa.h>\n# endif\n\n# ifndef OPENSSL_NO_DH\n#  include <openssl/dh.h>\n# endif\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n# ifdef WIN32\n/* Under Win32 this is defined in wincrypt.h */\n#  undef X509_NAME\n# endif\n\n# include <openssl/x509.h>\n# include <openssl/x509v3.h>\n\n/*-\nMessageImprint ::= SEQUENCE  {\n     hashAlgorithm                AlgorithmIdentifier,\n     hashedMessage                OCTET STRING  }\n*/\n\ntypedef struct TS_msg_imprint_st {\n    X509_ALGOR *hash_algo;\n    ASN1_OCTET_STRING *hashed_msg;\n} TS_MSG_IMPRINT;\n\n/*-\nTimeStampReq ::= SEQUENCE  {\n   version                  INTEGER  { v1(1) },\n   messageImprint           MessageImprint,\n     --a hash algorithm OID and the hash value of the data to be\n     --time-stamped\n   reqPolicy                TSAPolicyId                OPTIONAL,\n   nonce                    INTEGER                    OPTIONAL,\n   certReq                  BOOLEAN                    DEFAULT FALSE,\n   extensions               [0] IMPLICIT Extensions    OPTIONAL  }\n*/\n\ntypedef struct TS_req_st {\n    ASN1_INTEGER *version;\n    TS_MSG_IMPRINT *msg_imprint;\n    ASN1_OBJECT *policy_id;     /* OPTIONAL */\n    ASN1_INTEGER *nonce;        /* OPTIONAL */\n    ASN1_BOOLEAN cert_req;      /* DEFAULT FALSE */\n    STACK_OF(X509_EXTENSION) *extensions; /* [0] OPTIONAL */\n} TS_REQ;\n\n/*-\nAccuracy ::= SEQUENCE {\n                seconds        INTEGER           OPTIONAL,\n                millis     [0] INTEGER  (1..999) OPTIONAL,\n                micros     [1] INTEGER  (1..999) OPTIONAL  }\n*/\n\ntypedef struct TS_accuracy_st {\n    ASN1_INTEGER *seconds;\n    ASN1_INTEGER *millis;\n    ASN1_INTEGER *micros;\n} TS_ACCURACY;\n\n/*-\nTSTInfo ::= SEQUENCE  {\n    version                      INTEGER  { v1(1) },\n    policy                       TSAPolicyId,\n    messageImprint               MessageImprint,\n      -- MUST have the same value as the similar field in\n      -- TimeStampReq\n    serialNumber                 INTEGER,\n     -- Time-Stamping users MUST be ready to accommodate integers\n     -- up to 160 bits.\n    genTime                      GeneralizedTime,\n    accuracy                     Accuracy                 OPTIONAL,\n    ordering                     BOOLEAN             DEFAULT FALSE,\n    nonce                        INTEGER                  OPTIONAL,\n      -- MUST be present if the similar field was present\n      -- in TimeStampReq.  In that case it MUST have the same value.\n    tsa                          [0] GeneralName          OPTIONAL,\n    extensions                   [1] IMPLICIT Extensions  OPTIONAL   }\n*/\n\ntypedef struct TS_tst_info_st {\n    ASN1_INTEGER *version;\n    ASN1_OBJECT *policy_id;\n    TS_MSG_IMPRINT *msg_imprint;\n    ASN1_INTEGER *serial;\n    ASN1_GENERALIZEDTIME *time;\n    TS_ACCURACY *accuracy;\n    ASN1_BOOLEAN ordering;\n    ASN1_INTEGER *nonce;\n    GENERAL_NAME *tsa;\n    STACK_OF(X509_EXTENSION) *extensions;\n} TS_TST_INFO;\n\n/*-\nPKIStatusInfo ::= SEQUENCE {\n    status        PKIStatus,\n    statusString  PKIFreeText     OPTIONAL,\n    failInfo      PKIFailureInfo  OPTIONAL  }\n\nFrom RFC 1510 - section 3.1.1:\nPKIFreeText ::= SEQUENCE SIZE (1..MAX) OF UTF8String\n        -- text encoded as UTF-8 String (note:  each UTF8String SHOULD\n        -- include an RFC 1766 language tag to indicate the language\n        -- of the contained text)\n*/\n\n/* Possible values for status. See ts_resp_print.c && ts_resp_verify.c. */\n\n# define TS_STATUS_GRANTED                       0\n# define TS_STATUS_GRANTED_WITH_MODS             1\n# define TS_STATUS_REJECTION                     2\n# define TS_STATUS_WAITING                       3\n# define TS_STATUS_REVOCATION_WARNING            4\n# define TS_STATUS_REVOCATION_NOTIFICATION       5\n\n/*\n * Possible values for failure_info. See ts_resp_print.c && ts_resp_verify.c\n */\n\n# define TS_INFO_BAD_ALG                 0\n# define TS_INFO_BAD_REQUEST             2\n# define TS_INFO_BAD_DATA_FORMAT         5\n# define TS_INFO_TIME_NOT_AVAILABLE      14\n# define TS_INFO_UNACCEPTED_POLICY       15\n# define TS_INFO_UNACCEPTED_EXTENSION    16\n# define TS_INFO_ADD_INFO_NOT_AVAILABLE  17\n# define TS_INFO_SYSTEM_FAILURE          25\n\ntypedef struct TS_status_info_st {\n    ASN1_INTEGER *status;\n    STACK_OF(ASN1_UTF8STRING) *text;\n    ASN1_BIT_STRING *failure_info;\n} TS_STATUS_INFO;\n\nDECLARE_STACK_OF(ASN1_UTF8STRING)\nDECLARE_ASN1_SET_OF(ASN1_UTF8STRING)\n\n/*-\nTimeStampResp ::= SEQUENCE  {\n     status                  PKIStatusInfo,\n     timeStampToken          TimeStampToken     OPTIONAL }\n*/\n\ntypedef struct TS_resp_st {\n    TS_STATUS_INFO *status_info;\n    PKCS7 *token;\n    TS_TST_INFO *tst_info;\n} TS_RESP;\n\n/* The structure below would belong to the ESS component. */\n\n/*-\nIssuerSerial ::= SEQUENCE {\n        issuer                   GeneralNames,\n        serialNumber             CertificateSerialNumber\n        }\n*/\n\ntypedef struct ESS_issuer_serial {\n    STACK_OF(GENERAL_NAME) *issuer;\n    ASN1_INTEGER *serial;\n} ESS_ISSUER_SERIAL;\n\n/*-\nESSCertID ::=  SEQUENCE {\n        certHash                 Hash,\n        issuerSerial             IssuerSerial OPTIONAL\n}\n*/\n\ntypedef struct ESS_cert_id {\n    ASN1_OCTET_STRING *hash;    /* Always SHA-1 digest. */\n    ESS_ISSUER_SERIAL *issuer_serial;\n} ESS_CERT_ID;\n\nDECLARE_STACK_OF(ESS_CERT_ID)\nDECLARE_ASN1_SET_OF(ESS_CERT_ID)\n\n/*-\nSigningCertificate ::=  SEQUENCE {\n       certs        SEQUENCE OF ESSCertID,\n       policies     SEQUENCE OF PolicyInformation OPTIONAL\n}\n*/\n\ntypedef struct ESS_signing_cert {\n    STACK_OF(ESS_CERT_ID) *cert_ids;\n    STACK_OF(POLICYINFO) *policy_info;\n} ESS_SIGNING_CERT;\n\nTS_REQ *TS_REQ_new(void);\nvoid TS_REQ_free(TS_REQ *a);\nint i2d_TS_REQ(const TS_REQ *a, unsigned char **pp);\nTS_REQ *d2i_TS_REQ(TS_REQ **a, const unsigned char **pp, long length);\n\nTS_REQ *TS_REQ_dup(TS_REQ *a);\n\nTS_REQ *d2i_TS_REQ_fp(FILE *fp, TS_REQ **a);\nint i2d_TS_REQ_fp(FILE *fp, TS_REQ *a);\nTS_REQ *d2i_TS_REQ_bio(BIO *fp, TS_REQ **a);\nint i2d_TS_REQ_bio(BIO *fp, TS_REQ *a);\n\nTS_MSG_IMPRINT *TS_MSG_IMPRINT_new(void);\nvoid TS_MSG_IMPRINT_free(TS_MSG_IMPRINT *a);\nint i2d_TS_MSG_IMPRINT(const TS_MSG_IMPRINT *a, unsigned char **pp);\nTS_MSG_IMPRINT *d2i_TS_MSG_IMPRINT(TS_MSG_IMPRINT **a,\n                                   const unsigned char **pp, long length);\n\nTS_MSG_IMPRINT *TS_MSG_IMPRINT_dup(TS_MSG_IMPRINT *a);\n\nTS_MSG_IMPRINT *d2i_TS_MSG_IMPRINT_fp(FILE *fp, TS_MSG_IMPRINT **a);\nint i2d_TS_MSG_IMPRINT_fp(FILE *fp, TS_MSG_IMPRINT *a);\nTS_MSG_IMPRINT *d2i_TS_MSG_IMPRINT_bio(BIO *fp, TS_MSG_IMPRINT **a);\nint i2d_TS_MSG_IMPRINT_bio(BIO *fp, TS_MSG_IMPRINT *a);\n\nTS_RESP *TS_RESP_new(void);\nvoid TS_RESP_free(TS_RESP *a);\nint i2d_TS_RESP(const TS_RESP *a, unsigned char **pp);\nTS_RESP *d2i_TS_RESP(TS_RESP **a, const unsigned char **pp, long length);\nTS_TST_INFO *PKCS7_to_TS_TST_INFO(PKCS7 *token);\nTS_RESP *TS_RESP_dup(TS_RESP *a);\n\nTS_RESP *d2i_TS_RESP_fp(FILE *fp, TS_RESP **a);\nint i2d_TS_RESP_fp(FILE *fp, TS_RESP *a);\nTS_RESP *d2i_TS_RESP_bio(BIO *fp, TS_RESP **a);\nint i2d_TS_RESP_bio(BIO *fp, TS_RESP *a);\n\nTS_STATUS_INFO *TS_STATUS_INFO_new(void);\nvoid TS_STATUS_INFO_free(TS_STATUS_INFO *a);\nint i2d_TS_STATUS_INFO(const TS_STATUS_INFO *a, unsigned char **pp);\nTS_STATUS_INFO *d2i_TS_STATUS_INFO(TS_STATUS_INFO **a,\n                                   const unsigned char **pp, long length);\nTS_STATUS_INFO *TS_STATUS_INFO_dup(TS_STATUS_INFO *a);\n\nTS_TST_INFO *TS_TST_INFO_new(void);\nvoid TS_TST_INFO_free(TS_TST_INFO *a);\nint i2d_TS_TST_INFO(const TS_TST_INFO *a, unsigned char **pp);\nTS_TST_INFO *d2i_TS_TST_INFO(TS_TST_INFO **a, const unsigned char **pp,\n                             long length);\nTS_TST_INFO *TS_TST_INFO_dup(TS_TST_INFO *a);\n\nTS_TST_INFO *d2i_TS_TST_INFO_fp(FILE *fp, TS_TST_INFO **a);\nint i2d_TS_TST_INFO_fp(FILE *fp, TS_TST_INFO *a);\nTS_TST_INFO *d2i_TS_TST_INFO_bio(BIO *fp, TS_TST_INFO **a);\nint i2d_TS_TST_INFO_bio(BIO *fp, TS_TST_INFO *a);\n\nTS_ACCURACY *TS_ACCURACY_new(void);\nvoid TS_ACCURACY_free(TS_ACCURACY *a);\nint i2d_TS_ACCURACY(const TS_ACCURACY *a, unsigned char **pp);\nTS_ACCURACY *d2i_TS_ACCURACY(TS_ACCURACY **a, const unsigned char **pp,\n                             long length);\nTS_ACCURACY *TS_ACCURACY_dup(TS_ACCURACY *a);\n\nESS_ISSUER_SERIAL *ESS_ISSUER_SERIAL_new(void);\nvoid ESS_ISSUER_SERIAL_free(ESS_ISSUER_SERIAL *a);\nint i2d_ESS_ISSUER_SERIAL(const ESS_ISSUER_SERIAL *a, unsigned char **pp);\nESS_ISSUER_SERIAL *d2i_ESS_ISSUER_SERIAL(ESS_ISSUER_SERIAL **a,\n                                         const unsigned char **pp,\n                                         long length);\nESS_ISSUER_SERIAL *ESS_ISSUER_SERIAL_dup(ESS_ISSUER_SERIAL *a);\n\nESS_CERT_ID *ESS_CERT_ID_new(void);\nvoid ESS_CERT_ID_free(ESS_CERT_ID *a);\nint i2d_ESS_CERT_ID(const ESS_CERT_ID *a, unsigned char **pp);\nESS_CERT_ID *d2i_ESS_CERT_ID(ESS_CERT_ID **a, const unsigned char **pp,\n                             long length);\nESS_CERT_ID *ESS_CERT_ID_dup(ESS_CERT_ID *a);\n\nESS_SIGNING_CERT *ESS_SIGNING_CERT_new(void);\nvoid ESS_SIGNING_CERT_free(ESS_SIGNING_CERT *a);\nint i2d_ESS_SIGNING_CERT(const ESS_SIGNING_CERT *a, unsigned char **pp);\nESS_SIGNING_CERT *d2i_ESS_SIGNING_CERT(ESS_SIGNING_CERT **a,\n                                       const unsigned char **pp, long length);\nESS_SIGNING_CERT *ESS_SIGNING_CERT_dup(ESS_SIGNING_CERT *a);\n\nvoid ERR_load_TS_strings(void);\n\nint TS_REQ_set_version(TS_REQ *a, long version);\nlong TS_REQ_get_version(const TS_REQ *a);\n\nint TS_REQ_set_msg_imprint(TS_REQ *a, TS_MSG_IMPRINT *msg_imprint);\nTS_MSG_IMPRINT *TS_REQ_get_msg_imprint(TS_REQ *a);\n\nint TS_MSG_IMPRINT_set_algo(TS_MSG_IMPRINT *a, X509_ALGOR *alg);\nX509_ALGOR *TS_MSG_IMPRINT_get_algo(TS_MSG_IMPRINT *a);\n\nint TS_MSG_IMPRINT_set_msg(TS_MSG_IMPRINT *a, unsigned char *d, int len);\nASN1_OCTET_STRING *TS_MSG_IMPRINT_get_msg(TS_MSG_IMPRINT *a);\n\nint TS_REQ_set_policy_id(TS_REQ *a, ASN1_OBJECT *policy);\nASN1_OBJECT *TS_REQ_get_policy_id(TS_REQ *a);\n\nint TS_REQ_set_nonce(TS_REQ *a, const ASN1_INTEGER *nonce);\nconst ASN1_INTEGER *TS_REQ_get_nonce(const TS_REQ *a);\n\nint TS_REQ_set_cert_req(TS_REQ *a, int cert_req);\nint TS_REQ_get_cert_req(const TS_REQ *a);\n\nSTACK_OF(X509_EXTENSION) *TS_REQ_get_exts(TS_REQ *a);\nvoid TS_REQ_ext_free(TS_REQ *a);\nint TS_REQ_get_ext_count(TS_REQ *a);\nint TS_REQ_get_ext_by_NID(TS_REQ *a, int nid, int lastpos);\nint TS_REQ_get_ext_by_OBJ(TS_REQ *a, ASN1_OBJECT *obj, int lastpos);\nint TS_REQ_get_ext_by_critical(TS_REQ *a, int crit, int lastpos);\nX509_EXTENSION *TS_REQ_get_ext(TS_REQ *a, int loc);\nX509_EXTENSION *TS_REQ_delete_ext(TS_REQ *a, int loc);\nint TS_REQ_add_ext(TS_REQ *a, X509_EXTENSION *ex, int loc);\nvoid *TS_REQ_get_ext_d2i(TS_REQ *a, int nid, int *crit, int *idx);\n\n/* Function declarations for TS_REQ defined in ts/ts_req_print.c */\n\nint TS_REQ_print_bio(BIO *bio, TS_REQ *a);\n\n/* Function declarations for TS_RESP defined in ts/ts_resp_utils.c */\n\nint TS_RESP_set_status_info(TS_RESP *a, TS_STATUS_INFO *info);\nTS_STATUS_INFO *TS_RESP_get_status_info(TS_RESP *a);\n\n/* Caller loses ownership of PKCS7 and TS_TST_INFO objects. */\nvoid TS_RESP_set_tst_info(TS_RESP *a, PKCS7 *p7, TS_TST_INFO *tst_info);\nPKCS7 *TS_RESP_get_token(TS_RESP *a);\nTS_TST_INFO *TS_RESP_get_tst_info(TS_RESP *a);\n\nint TS_TST_INFO_set_version(TS_TST_INFO *a, long version);\nlong TS_TST_INFO_get_version(const TS_TST_INFO *a);\n\nint TS_TST_INFO_set_policy_id(TS_TST_INFO *a, ASN1_OBJECT *policy_id);\nASN1_OBJECT *TS_TST_INFO_get_policy_id(TS_TST_INFO *a);\n\nint TS_TST_INFO_set_msg_imprint(TS_TST_INFO *a, TS_MSG_IMPRINT *msg_imprint);\nTS_MSG_IMPRINT *TS_TST_INFO_get_msg_imprint(TS_TST_INFO *a);\n\nint TS_TST_INFO_set_serial(TS_TST_INFO *a, const ASN1_INTEGER *serial);\nconst ASN1_INTEGER *TS_TST_INFO_get_serial(const TS_TST_INFO *a);\n\nint TS_TST_INFO_set_time(TS_TST_INFO *a, const ASN1_GENERALIZEDTIME *gtime);\nconst ASN1_GENERALIZEDTIME *TS_TST_INFO_get_time(const TS_TST_INFO *a);\n\nint TS_TST_INFO_set_accuracy(TS_TST_INFO *a, TS_ACCURACY *accuracy);\nTS_ACCURACY *TS_TST_INFO_get_accuracy(TS_TST_INFO *a);\n\nint TS_ACCURACY_set_seconds(TS_ACCURACY *a, const ASN1_INTEGER *seconds);\nconst ASN1_INTEGER *TS_ACCURACY_get_seconds(const TS_ACCURACY *a);\n\nint TS_ACCURACY_set_millis(TS_ACCURACY *a, const ASN1_INTEGER *millis);\nconst ASN1_INTEGER *TS_ACCURACY_get_millis(const TS_ACCURACY *a);\n\nint TS_ACCURACY_set_micros(TS_ACCURACY *a, const ASN1_INTEGER *micros);\nconst ASN1_INTEGER *TS_ACCURACY_get_micros(const TS_ACCURACY *a);\n\nint TS_TST_INFO_set_ordering(TS_TST_INFO *a, int ordering);\nint TS_TST_INFO_get_ordering(const TS_TST_INFO *a);\n\nint TS_TST_INFO_set_nonce(TS_TST_INFO *a, const ASN1_INTEGER *nonce);\nconst ASN1_INTEGER *TS_TST_INFO_get_nonce(const TS_TST_INFO *a);\n\nint TS_TST_INFO_set_tsa(TS_TST_INFO *a, GENERAL_NAME *tsa);\nGENERAL_NAME *TS_TST_INFO_get_tsa(TS_TST_INFO *a);\n\nSTACK_OF(X509_EXTENSION) *TS_TST_INFO_get_exts(TS_TST_INFO *a);\nvoid TS_TST_INFO_ext_free(TS_TST_INFO *a);\nint TS_TST_INFO_get_ext_count(TS_TST_INFO *a);\nint TS_TST_INFO_get_ext_by_NID(TS_TST_INFO *a, int nid, int lastpos);\nint TS_TST_INFO_get_ext_by_OBJ(TS_TST_INFO *a, ASN1_OBJECT *obj, int lastpos);\nint TS_TST_INFO_get_ext_by_critical(TS_TST_INFO *a, int crit, int lastpos);\nX509_EXTENSION *TS_TST_INFO_get_ext(TS_TST_INFO *a, int loc);\nX509_EXTENSION *TS_TST_INFO_delete_ext(TS_TST_INFO *a, int loc);\nint TS_TST_INFO_add_ext(TS_TST_INFO *a, X509_EXTENSION *ex, int loc);\nvoid *TS_TST_INFO_get_ext_d2i(TS_TST_INFO *a, int nid, int *crit, int *idx);\n\n/*\n * Declarations related to response generation, defined in ts/ts_resp_sign.c.\n */\n\n/* Optional flags for response generation. */\n\n/* Don't include the TSA name in response. */\n# define TS_TSA_NAME             0x01\n\n/* Set ordering to true in response. */\n# define TS_ORDERING             0x02\n\n/*\n * Include the signer certificate and the other specified certificates in\n * the ESS signing certificate attribute beside the PKCS7 signed data.\n * Only the signer certificates is included by default.\n */\n# define TS_ESS_CERT_ID_CHAIN    0x04\n\n/* Forward declaration. */\nstruct TS_resp_ctx;\n\n/* This must return a unique number less than 160 bits long. */\ntypedef ASN1_INTEGER *(*TS_serial_cb) (struct TS_resp_ctx *, void *);\n\n/*\n * This must return the seconds and microseconds since Jan 1, 1970 in the sec\n * and usec variables allocated by the caller. Return non-zero for success\n * and zero for failure.\n */\ntypedef int (*TS_time_cb) (struct TS_resp_ctx *, void *, long *sec,\n                           long *usec);\n\n/*\n * This must process the given extension. It can modify the TS_TST_INFO\n * object of the context. Return values: !0 (processed), 0 (error, it must\n * set the status info/failure info of the response).\n */\ntypedef int (*TS_extension_cb) (struct TS_resp_ctx *, X509_EXTENSION *,\n                                void *);\n\ntypedef struct TS_resp_ctx {\n    X509 *signer_cert;\n    EVP_PKEY *signer_key;\n    STACK_OF(X509) *certs;      /* Certs to include in signed data. */\n    STACK_OF(ASN1_OBJECT) *policies; /* Acceptable policies. */\n    ASN1_OBJECT *default_policy; /* It may appear in policies, too. */\n    STACK_OF(EVP_MD) *mds;      /* Acceptable message digests. */\n    ASN1_INTEGER *seconds;      /* accuracy, 0 means not specified. */\n    ASN1_INTEGER *millis;       /* accuracy, 0 means not specified. */\n    ASN1_INTEGER *micros;       /* accuracy, 0 means not specified. */\n    unsigned clock_precision_digits; /* fraction of seconds in time stamp\n                                      * token. */\n    unsigned flags;             /* Optional info, see values above. */\n    /* Callback functions. */\n    TS_serial_cb serial_cb;\n    void *serial_cb_data;       /* User data for serial_cb. */\n    TS_time_cb time_cb;\n    void *time_cb_data;         /* User data for time_cb. */\n    TS_extension_cb extension_cb;\n    void *extension_cb_data;    /* User data for extension_cb. */\n    /* These members are used only while creating the response. */\n    TS_REQ *request;\n    TS_RESP *response;\n    TS_TST_INFO *tst_info;\n} TS_RESP_CTX;\n\nDECLARE_STACK_OF(EVP_MD)\nDECLARE_ASN1_SET_OF(EVP_MD)\n\n/* Creates a response context that can be used for generating responses. */\nTS_RESP_CTX *TS_RESP_CTX_new(void);\nvoid TS_RESP_CTX_free(TS_RESP_CTX *ctx);\n\n/* This parameter must be set. */\nint TS_RESP_CTX_set_signer_cert(TS_RESP_CTX *ctx, X509 *signer);\n\n/* This parameter must be set. */\nint TS_RESP_CTX_set_signer_key(TS_RESP_CTX *ctx, EVP_PKEY *key);\n\n/* This parameter must be set. */\nint TS_RESP_CTX_set_def_policy(TS_RESP_CTX *ctx, ASN1_OBJECT *def_policy);\n\n/* No additional certs are included in the response by default. */\nint TS_RESP_CTX_set_certs(TS_RESP_CTX *ctx, STACK_OF(X509) *certs);\n\n/*\n * Adds a new acceptable policy, only the default policy is accepted by\n * default.\n */\nint TS_RESP_CTX_add_policy(TS_RESP_CTX *ctx, ASN1_OBJECT *policy);\n\n/*\n * Adds a new acceptable message digest. Note that no message digests are\n * accepted by default. The md argument is shared with the caller.\n */\nint TS_RESP_CTX_add_md(TS_RESP_CTX *ctx, const EVP_MD *md);\n\n/* Accuracy is not included by default. */\nint TS_RESP_CTX_set_accuracy(TS_RESP_CTX *ctx,\n                             int secs, int millis, int micros);\n\n/*\n * Clock precision digits, i.e. the number of decimal digits: '0' means sec,\n * '3' msec, '6' usec, and so on. Default is 0.\n */\nint TS_RESP_CTX_set_clock_precision_digits(TS_RESP_CTX *ctx,\n                                           unsigned clock_precision_digits);\n/* At most we accept usec precision. */\n# define TS_MAX_CLOCK_PRECISION_DIGITS   6\n\n/* Maximum status message length */\n# define TS_MAX_STATUS_LENGTH   (1024 * 1024)\n\n/* No flags are set by default. */\nvoid TS_RESP_CTX_add_flags(TS_RESP_CTX *ctx, int flags);\n\n/* Default callback always returns a constant. */\nvoid TS_RESP_CTX_set_serial_cb(TS_RESP_CTX *ctx, TS_serial_cb cb, void *data);\n\n/* Default callback uses the gettimeofday() and gmtime() system calls. */\nvoid TS_RESP_CTX_set_time_cb(TS_RESP_CTX *ctx, TS_time_cb cb, void *data);\n\n/*\n * Default callback rejects all extensions. The extension callback is called\n * when the TS_TST_INFO object is already set up and not signed yet.\n */\n/* FIXME: extension handling is not tested yet. */\nvoid TS_RESP_CTX_set_extension_cb(TS_RESP_CTX *ctx,\n                                  TS_extension_cb cb, void *data);\n\n/* The following methods can be used in the callbacks. */\nint TS_RESP_CTX_set_status_info(TS_RESP_CTX *ctx,\n                                int status, const char *text);\n\n/* Sets the status info only if it is still TS_STATUS_GRANTED. */\nint TS_RESP_CTX_set_status_info_cond(TS_RESP_CTX *ctx,\n                                     int status, const char *text);\n\nint TS_RESP_CTX_add_failure_info(TS_RESP_CTX *ctx, int failure);\n\n/* The get methods below can be used in the extension callback. */\nTS_REQ *TS_RESP_CTX_get_request(TS_RESP_CTX *ctx);\n\nTS_TST_INFO *TS_RESP_CTX_get_tst_info(TS_RESP_CTX *ctx);\n\n/*\n * Creates the signed TS_TST_INFO and puts it in TS_RESP.\n * In case of errors it sets the status info properly.\n * Returns NULL only in case of memory allocation/fatal error.\n */\nTS_RESP *TS_RESP_create_response(TS_RESP_CTX *ctx, BIO *req_bio);\n\n/*\n * Declarations related to response verification,\n * they are defined in ts/ts_resp_verify.c.\n */\n\nint TS_RESP_verify_signature(PKCS7 *token, STACK_OF(X509) *certs,\n                             X509_STORE *store, X509 **signer_out);\n\n/* Context structure for the generic verify method. */\n\n/* Verify the signer's certificate and the signature of the response. */\n# define TS_VFY_SIGNATURE        (1u << 0)\n/* Verify the version number of the response. */\n# define TS_VFY_VERSION          (1u << 1)\n/* Verify if the policy supplied by the user matches the policy of the TSA. */\n# define TS_VFY_POLICY           (1u << 2)\n/*\n * Verify the message imprint provided by the user. This flag should not be\n * specified with TS_VFY_DATA.\n */\n# define TS_VFY_IMPRINT          (1u << 3)\n/*\n * Verify the message imprint computed by the verify method from the user\n * provided data and the MD algorithm of the response. This flag should not\n * be specified with TS_VFY_IMPRINT.\n */\n# define TS_VFY_DATA             (1u << 4)\n/* Verify the nonce value. */\n# define TS_VFY_NONCE            (1u << 5)\n/* Verify if the TSA name field matches the signer certificate. */\n# define TS_VFY_SIGNER           (1u << 6)\n/* Verify if the TSA name field equals to the user provided name. */\n# define TS_VFY_TSA_NAME         (1u << 7)\n\n/* You can use the following convenience constants. */\n# define TS_VFY_ALL_IMPRINT      (TS_VFY_SIGNATURE       \\\n                                 | TS_VFY_VERSION       \\\n                                 | TS_VFY_POLICY        \\\n                                 | TS_VFY_IMPRINT       \\\n                                 | TS_VFY_NONCE         \\\n                                 | TS_VFY_SIGNER        \\\n                                 | TS_VFY_TSA_NAME)\n# define TS_VFY_ALL_DATA         (TS_VFY_SIGNATURE       \\\n                                 | TS_VFY_VERSION       \\\n                                 | TS_VFY_POLICY        \\\n                                 | TS_VFY_DATA          \\\n                                 | TS_VFY_NONCE         \\\n                                 | TS_VFY_SIGNER        \\\n                                 | TS_VFY_TSA_NAME)\n\ntypedef struct TS_verify_ctx {\n    /* Set this to the union of TS_VFY_... flags you want to carry out. */\n    unsigned flags;\n    /* Must be set only with TS_VFY_SIGNATURE. certs is optional. */\n    X509_STORE *store;\n    STACK_OF(X509) *certs;\n    /* Must be set only with TS_VFY_POLICY. */\n    ASN1_OBJECT *policy;\n    /*\n     * Must be set only with TS_VFY_IMPRINT. If md_alg is NULL, the\n     * algorithm from the response is used.\n     */\n    X509_ALGOR *md_alg;\n    unsigned char *imprint;\n    unsigned imprint_len;\n    /* Must be set only with TS_VFY_DATA. */\n    BIO *data;\n    /* Must be set only with TS_VFY_TSA_NAME. */\n    ASN1_INTEGER *nonce;\n    /* Must be set only with TS_VFY_TSA_NAME. */\n    GENERAL_NAME *tsa_name;\n} TS_VERIFY_CTX;\n\nint TS_RESP_verify_response(TS_VERIFY_CTX *ctx, TS_RESP *response);\nint TS_RESP_verify_token(TS_VERIFY_CTX *ctx, PKCS7 *token);\n\n/*\n * Declarations related to response verification context,\n * they are defined in ts/ts_verify_ctx.c.\n */\n\n/* Set all fields to zero. */\nTS_VERIFY_CTX *TS_VERIFY_CTX_new(void);\nvoid TS_VERIFY_CTX_init(TS_VERIFY_CTX *ctx);\nvoid TS_VERIFY_CTX_free(TS_VERIFY_CTX *ctx);\nvoid TS_VERIFY_CTX_cleanup(TS_VERIFY_CTX *ctx);\n\n/*-\n * If ctx is NULL, it allocates and returns a new object, otherwise\n * it returns ctx. It initialises all the members as follows:\n * flags = TS_VFY_ALL_IMPRINT & ~(TS_VFY_TSA_NAME | TS_VFY_SIGNATURE)\n * certs = NULL\n * store = NULL\n * policy = policy from the request or NULL if absent (in this case\n *      TS_VFY_POLICY is cleared from flags as well)\n * md_alg = MD algorithm from request\n * imprint, imprint_len = imprint from request\n * data = NULL\n * nonce, nonce_len = nonce from the request or NULL if absent (in this case\n *      TS_VFY_NONCE is cleared from flags as well)\n * tsa_name = NULL\n * Important: after calling this method TS_VFY_SIGNATURE should be added!\n */\nTS_VERIFY_CTX *TS_REQ_to_TS_VERIFY_CTX(TS_REQ *req, TS_VERIFY_CTX *ctx);\n\n/* Function declarations for TS_RESP defined in ts/ts_resp_print.c */\n\nint TS_RESP_print_bio(BIO *bio, TS_RESP *a);\nint TS_STATUS_INFO_print_bio(BIO *bio, TS_STATUS_INFO *a);\nint TS_TST_INFO_print_bio(BIO *bio, TS_TST_INFO *a);\n\n/* Common utility functions defined in ts/ts_lib.c */\n\nint TS_ASN1_INTEGER_print_bio(BIO *bio, const ASN1_INTEGER *num);\nint TS_OBJ_print_bio(BIO *bio, const ASN1_OBJECT *obj);\nint TS_ext_print_bio(BIO *bio, const STACK_OF(X509_EXTENSION) *extensions);\nint TS_X509_ALGOR_print_bio(BIO *bio, const X509_ALGOR *alg);\nint TS_MSG_IMPRINT_print_bio(BIO *bio, TS_MSG_IMPRINT *msg);\n\n/*\n * Function declarations for handling configuration options, defined in\n * ts/ts_conf.c\n */\n\nX509 *TS_CONF_load_cert(const char *file);\nSTACK_OF(X509) *TS_CONF_load_certs(const char *file);\nEVP_PKEY *TS_CONF_load_key(const char *file, const char *pass);\nconst char *TS_CONF_get_tsa_section(CONF *conf, const char *section);\nint TS_CONF_set_serial(CONF *conf, const char *section, TS_serial_cb cb,\n                       TS_RESP_CTX *ctx);\nint TS_CONF_set_crypto_device(CONF *conf, const char *section,\n                              const char *device);\nint TS_CONF_set_default_engine(const char *name);\nint TS_CONF_set_signer_cert(CONF *conf, const char *section,\n                            const char *cert, TS_RESP_CTX *ctx);\nint TS_CONF_set_certs(CONF *conf, const char *section, const char *certs,\n                      TS_RESP_CTX *ctx);\nint TS_CONF_set_signer_key(CONF *conf, const char *section,\n                           const char *key, const char *pass,\n                           TS_RESP_CTX *ctx);\nint TS_CONF_set_def_policy(CONF *conf, const char *section,\n                           const char *policy, TS_RESP_CTX *ctx);\nint TS_CONF_set_policies(CONF *conf, const char *section, TS_RESP_CTX *ctx);\nint TS_CONF_set_digests(CONF *conf, const char *section, TS_RESP_CTX *ctx);\nint TS_CONF_set_accuracy(CONF *conf, const char *section, TS_RESP_CTX *ctx);\nint TS_CONF_set_clock_precision_digits(CONF *conf, const char *section,\n                                       TS_RESP_CTX *ctx);\nint TS_CONF_set_ordering(CONF *conf, const char *section, TS_RESP_CTX *ctx);\nint TS_CONF_set_tsa_name(CONF *conf, const char *section, TS_RESP_CTX *ctx);\nint TS_CONF_set_ess_cert_id_chain(CONF *conf, const char *section,\n                                  TS_RESP_CTX *ctx);\n\n/* -------------------------------------------------- */\n/* BEGIN ERROR CODES */\n/*\n * The following lines are auto generated by the script mkerr.pl. Any changes\n * made after this point may be overwritten when the script is next run.\n */\nvoid ERR_load_TS_strings(void);\n\n/* Error codes for the TS functions. */\n\n/* Function codes. */\n# define TS_F_D2I_TS_RESP                                 147\n# define TS_F_DEF_SERIAL_CB                               110\n# define TS_F_DEF_TIME_CB                                 111\n# define TS_F_ESS_ADD_SIGNING_CERT                        112\n# define TS_F_ESS_CERT_ID_NEW_INIT                        113\n# define TS_F_ESS_SIGNING_CERT_NEW_INIT                   114\n# define TS_F_INT_TS_RESP_VERIFY_TOKEN                    149\n# define TS_F_PKCS7_TO_TS_TST_INFO                        148\n# define TS_F_TS_ACCURACY_SET_MICROS                      115\n# define TS_F_TS_ACCURACY_SET_MILLIS                      116\n# define TS_F_TS_ACCURACY_SET_SECONDS                     117\n# define TS_F_TS_CHECK_IMPRINTS                           100\n# define TS_F_TS_CHECK_NONCES                             101\n# define TS_F_TS_CHECK_POLICY                             102\n# define TS_F_TS_CHECK_SIGNING_CERTS                      103\n# define TS_F_TS_CHECK_STATUS_INFO                        104\n# define TS_F_TS_COMPUTE_IMPRINT                          145\n# define TS_F_TS_CONF_SET_DEFAULT_ENGINE                  146\n# define TS_F_TS_GET_STATUS_TEXT                          105\n# define TS_F_TS_MSG_IMPRINT_SET_ALGO                     118\n# define TS_F_TS_REQ_SET_MSG_IMPRINT                      119\n# define TS_F_TS_REQ_SET_NONCE                            120\n# define TS_F_TS_REQ_SET_POLICY_ID                        121\n# define TS_F_TS_RESP_CREATE_RESPONSE                     122\n# define TS_F_TS_RESP_CREATE_TST_INFO                     123\n# define TS_F_TS_RESP_CTX_ADD_FAILURE_INFO                124\n# define TS_F_TS_RESP_CTX_ADD_MD                          125\n# define TS_F_TS_RESP_CTX_ADD_POLICY                      126\n# define TS_F_TS_RESP_CTX_NEW                             127\n# define TS_F_TS_RESP_CTX_SET_ACCURACY                    128\n# define TS_F_TS_RESP_CTX_SET_CERTS                       129\n# define TS_F_TS_RESP_CTX_SET_DEF_POLICY                  130\n# define TS_F_TS_RESP_CTX_SET_SIGNER_CERT                 131\n# define TS_F_TS_RESP_CTX_SET_STATUS_INFO                 132\n# define TS_F_TS_RESP_GET_POLICY                          133\n# define TS_F_TS_RESP_SET_GENTIME_WITH_PRECISION          134\n# define TS_F_TS_RESP_SET_STATUS_INFO                     135\n# define TS_F_TS_RESP_SET_TST_INFO                        150\n# define TS_F_TS_RESP_SIGN                                136\n# define TS_F_TS_RESP_VERIFY_SIGNATURE                    106\n# define TS_F_TS_RESP_VERIFY_TOKEN                        107\n# define TS_F_TS_TST_INFO_SET_ACCURACY                    137\n# define TS_F_TS_TST_INFO_SET_MSG_IMPRINT                 138\n# define TS_F_TS_TST_INFO_SET_NONCE                       139\n# define TS_F_TS_TST_INFO_SET_POLICY_ID                   140\n# define TS_F_TS_TST_INFO_SET_SERIAL                      141\n# define TS_F_TS_TST_INFO_SET_TIME                        142\n# define TS_F_TS_TST_INFO_SET_TSA                         143\n# define TS_F_TS_VERIFY                                   108\n# define TS_F_TS_VERIFY_CERT                              109\n# define TS_F_TS_VERIFY_CTX_NEW                           144\n\n/* Reason codes. */\n# define TS_R_BAD_PKCS7_TYPE                              132\n# define TS_R_BAD_TYPE                                    133\n# define TS_R_CERTIFICATE_VERIFY_ERROR                    100\n# define TS_R_COULD_NOT_SET_ENGINE                        127\n# define TS_R_COULD_NOT_SET_TIME                          115\n# define TS_R_D2I_TS_RESP_INT_FAILED                      128\n# define TS_R_DETACHED_CONTENT                            134\n# define TS_R_ESS_ADD_SIGNING_CERT_ERROR                  116\n# define TS_R_ESS_SIGNING_CERTIFICATE_ERROR               101\n# define TS_R_INVALID_NULL_POINTER                        102\n# define TS_R_INVALID_SIGNER_CERTIFICATE_PURPOSE          117\n# define TS_R_MESSAGE_IMPRINT_MISMATCH                    103\n# define TS_R_NONCE_MISMATCH                              104\n# define TS_R_NONCE_NOT_RETURNED                          105\n# define TS_R_NO_CONTENT                                  106\n# define TS_R_NO_TIME_STAMP_TOKEN                         107\n# define TS_R_PKCS7_ADD_SIGNATURE_ERROR                   118\n# define TS_R_PKCS7_ADD_SIGNED_ATTR_ERROR                 119\n# define TS_R_PKCS7_TO_TS_TST_INFO_FAILED                 129\n# define TS_R_POLICY_MISMATCH                             108\n# define TS_R_PRIVATE_KEY_DOES_NOT_MATCH_CERTIFICATE      120\n# define TS_R_RESPONSE_SETUP_ERROR                        121\n# define TS_R_SIGNATURE_FAILURE                           109\n# define TS_R_THERE_MUST_BE_ONE_SIGNER                    110\n# define TS_R_TIME_SYSCALL_ERROR                          122\n# define TS_R_TOKEN_NOT_PRESENT                           130\n# define TS_R_TOKEN_PRESENT                               131\n# define TS_R_TSA_NAME_MISMATCH                           111\n# define TS_R_TSA_UNTRUSTED                               112\n# define TS_R_TST_INFO_SETUP_ERROR                        123\n# define TS_R_TS_DATASIGN                                 124\n# define TS_R_UNACCEPTABLE_POLICY                         125\n# define TS_R_UNSUPPORTED_MD_ALGORITHM                    126\n# define TS_R_UNSUPPORTED_VERSION                         113\n# define TS_R_WRONG_CONTENT_TYPE                          114\n\n#ifdef  __cplusplus\n}\n#endif\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/arm64/include/openssl/txt_db.h",
    "content": "/* crypto/txt_db/txt_db.h */\n/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)\n * All rights reserved.\n *\n * This package is an SSL implementation written\n * by Eric Young (eay@cryptsoft.com).\n * The implementation was written so as to conform with Netscapes SSL.\n *\n * This library is free for commercial and non-commercial use as long as\n * the following conditions are aheared to.  The following conditions\n * apply to all code found in this distribution, be it the RC4, RSA,\n * lhash, DES, etc., code; not just the SSL code.  The SSL documentation\n * included with this distribution is covered by the same copyright terms\n * except that the holder is Tim Hudson (tjh@cryptsoft.com).\n *\n * Copyright remains Eric Young's, and as such any Copyright notices in\n * the code are not to be removed.\n * If this package is used in a product, Eric Young should be given attribution\n * as the author of the parts of the library used.\n * This can be in the form of a textual message at program startup or\n * in documentation (online or textual) provided with the package.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the copyright\n *    notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in the\n *    documentation and/or other materials provided with the distribution.\n * 3. All advertising materials mentioning features or use of this software\n *    must display the following acknowledgement:\n *    \"This product includes cryptographic software written by\n *     Eric Young (eay@cryptsoft.com)\"\n *    The word 'cryptographic' can be left out if the rouines from the library\n *    being used are not cryptographic related :-).\n * 4. If you include any Windows specific code (or a derivative thereof) from\n *    the apps directory (application code) you must include an acknowledgement:\n *    \"This product includes software written by Tim Hudson (tjh@cryptsoft.com)\"\n *\n * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n * SUCH DAMAGE.\n *\n * The licence and distribution terms for any publically available version or\n * derivative of this code cannot be changed.  i.e. this code cannot simply be\n * copied and put under another distribution licence\n * [including the GNU Public Licence.]\n */\n\n#ifndef HEADER_TXT_DB_H\n# define HEADER_TXT_DB_H\n\n# include <openssl/opensslconf.h>\n# ifndef OPENSSL_NO_BIO\n#  include <openssl/bio.h>\n# endif\n# include <openssl/stack.h>\n# include <openssl/lhash.h>\n\n# define DB_ERROR_OK                     0\n# define DB_ERROR_MALLOC                 1\n# define DB_ERROR_INDEX_CLASH            2\n# define DB_ERROR_INDEX_OUT_OF_RANGE     3\n# define DB_ERROR_NO_INDEX               4\n# define DB_ERROR_INSERT_INDEX_CLASH     5\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\ntypedef OPENSSL_STRING *OPENSSL_PSTRING;\nDECLARE_SPECIAL_STACK_OF(OPENSSL_PSTRING, OPENSSL_STRING)\n\ntypedef struct txt_db_st {\n    int num_fields;\n    STACK_OF(OPENSSL_PSTRING) *data;\n    LHASH_OF(OPENSSL_STRING) **index;\n    int (**qual) (OPENSSL_STRING *);\n    long error;\n    long arg1;\n    long arg2;\n    OPENSSL_STRING *arg_row;\n} TXT_DB;\n\n# ifndef OPENSSL_NO_BIO\nTXT_DB *TXT_DB_read(BIO *in, int num);\nlong TXT_DB_write(BIO *out, TXT_DB *db);\n# else\nTXT_DB *TXT_DB_read(char *in, int num);\nlong TXT_DB_write(char *out, TXT_DB *db);\n# endif\nint TXT_DB_create_index(TXT_DB *db, int field, int (*qual) (OPENSSL_STRING *),\n                        LHASH_HASH_FN_TYPE hash, LHASH_COMP_FN_TYPE cmp);\nvoid TXT_DB_free(TXT_DB *db);\nOPENSSL_STRING *TXT_DB_get_by_index(TXT_DB *db, int idx,\n                                    OPENSSL_STRING *value);\nint TXT_DB_insert(TXT_DB *db, OPENSSL_STRING *value);\n\n#ifdef  __cplusplus\n}\n#endif\n\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/arm64/include/openssl/ui.h",
    "content": "/* crypto/ui/ui.h */\n/*\n * Written by Richard Levitte (richard@levitte.org) for the OpenSSL project\n * 2001.\n */\n/* ====================================================================\n * Copyright (c) 2001 The OpenSSL Project.  All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n *\n * 1. Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n *\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in\n *    the documentation and/or other materials provided with the\n *    distribution.\n *\n * 3. All advertising materials mentioning features or use of this\n *    software must display the following acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit. (http://www.openssl.org/)\"\n *\n * 4. The names \"OpenSSL Toolkit\" and \"OpenSSL Project\" must not be used to\n *    endorse or promote products derived from this software without\n *    prior written permission. For written permission, please contact\n *    openssl-core@openssl.org.\n *\n * 5. Products derived from this software may not be called \"OpenSSL\"\n *    nor may \"OpenSSL\" appear in their names without prior written\n *    permission of the OpenSSL Project.\n *\n * 6. Redistributions of any form whatsoever must retain the following\n *    acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit (http://www.openssl.org/)\"\n *\n * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY\n * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\n * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR\n * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\n * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,\n * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED\n * OF THE POSSIBILITY OF SUCH DAMAGE.\n * ====================================================================\n *\n * This product includes cryptographic software written by Eric Young\n * (eay@cryptsoft.com).  This product includes software written by Tim\n * Hudson (tjh@cryptsoft.com).\n *\n */\n\n#ifndef HEADER_UI_H\n# define HEADER_UI_H\n\n# ifndef OPENSSL_NO_DEPRECATED\n#  include <openssl/crypto.h>\n# endif\n# include <openssl/safestack.h>\n# include <openssl/ossl_typ.h>\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n/* Declared already in ossl_typ.h */\n/* typedef struct ui_st UI; */\n/* typedef struct ui_method_st UI_METHOD; */\n\n/*\n * All the following functions return -1 or NULL on error and in some cases\n * (UI_process()) -2 if interrupted or in some other way cancelled. When\n * everything is fine, they return 0, a positive value or a non-NULL pointer,\n * all depending on their purpose.\n */\n\n/* Creators and destructor.   */\nUI *UI_new(void);\nUI *UI_new_method(const UI_METHOD *method);\nvoid UI_free(UI *ui);\n\n/*-\n   The following functions are used to add strings to be printed and prompt\n   strings to prompt for data.  The names are UI_{add,dup}_<function>_string\n   and UI_{add,dup}_input_boolean.\n\n   UI_{add,dup}_<function>_string have the following meanings:\n        add     add a text or prompt string.  The pointers given to these\n                functions are used verbatim, no copying is done.\n        dup     make a copy of the text or prompt string, then add the copy\n                to the collection of strings in the user interface.\n        <function>\n                The function is a name for the functionality that the given\n                string shall be used for.  It can be one of:\n                        input   use the string as data prompt.\n                        verify  use the string as verification prompt.  This\n                                is used to verify a previous input.\n                        info    use the string for informational output.\n                        error   use the string for error output.\n   Honestly, there's currently no difference between info and error for the\n   moment.\n\n   UI_{add,dup}_input_boolean have the same semantics for \"add\" and \"dup\",\n   and are typically used when one wants to prompt for a yes/no response.\n\n   All of the functions in this group take a UI and a prompt string.\n   The string input and verify addition functions also take a flag argument,\n   a buffer for the result to end up with, a minimum input size and a maximum\n   input size (the result buffer MUST be large enough to be able to contain\n   the maximum number of characters).  Additionally, the verify addition\n   functions takes another buffer to compare the result against.\n   The boolean input functions take an action description string (which should\n   be safe to ignore if the expected user action is obvious, for example with\n   a dialog box with an OK button and a Cancel button), a string of acceptable\n   characters to mean OK and to mean Cancel.  The two last strings are checked\n   to make sure they don't have common characters.  Additionally, the same\n   flag argument as for the string input is taken, as well as a result buffer.\n   The result buffer is required to be at least one byte long.  Depending on\n   the answer, the first character from the OK or the Cancel character strings\n   will be stored in the first byte of the result buffer.  No NUL will be\n   added, so the result is *not* a string.\n\n   On success, the all return an index of the added information.  That index\n   is usefull when retrieving results with UI_get0_result(). */\nint UI_add_input_string(UI *ui, const char *prompt, int flags,\n                        char *result_buf, int minsize, int maxsize);\nint UI_dup_input_string(UI *ui, const char *prompt, int flags,\n                        char *result_buf, int minsize, int maxsize);\nint UI_add_verify_string(UI *ui, const char *prompt, int flags,\n                         char *result_buf, int minsize, int maxsize,\n                         const char *test_buf);\nint UI_dup_verify_string(UI *ui, const char *prompt, int flags,\n                         char *result_buf, int minsize, int maxsize,\n                         const char *test_buf);\nint UI_add_input_boolean(UI *ui, const char *prompt, const char *action_desc,\n                         const char *ok_chars, const char *cancel_chars,\n                         int flags, char *result_buf);\nint UI_dup_input_boolean(UI *ui, const char *prompt, const char *action_desc,\n                         const char *ok_chars, const char *cancel_chars,\n                         int flags, char *result_buf);\nint UI_add_info_string(UI *ui, const char *text);\nint UI_dup_info_string(UI *ui, const char *text);\nint UI_add_error_string(UI *ui, const char *text);\nint UI_dup_error_string(UI *ui, const char *text);\n\n/* These are the possible flags.  They can be or'ed together. */\n/* Use to have echoing of input */\n# define UI_INPUT_FLAG_ECHO              0x01\n/*\n * Use a default password.  Where that password is found is completely up to\n * the application, it might for example be in the user data set with\n * UI_add_user_data().  It is not recommended to have more than one input in\n * each UI being marked with this flag, or the application might get\n * confused.\n */\n# define UI_INPUT_FLAG_DEFAULT_PWD       0x02\n\n/*-\n * The user of these routines may want to define flags of their own.  The core\n * UI won't look at those, but will pass them on to the method routines.  They\n * must use higher bits so they don't get confused with the UI bits above.\n * UI_INPUT_FLAG_USER_BASE tells which is the lowest bit to use.  A good\n * example of use is this:\n *\n *    #define MY_UI_FLAG1       (0x01 << UI_INPUT_FLAG_USER_BASE)\n *\n*/\n# define UI_INPUT_FLAG_USER_BASE 16\n\n/*-\n * The following function helps construct a prompt.  object_desc is a\n * textual short description of the object, for example \"pass phrase\",\n * and object_name is the name of the object (might be a card name or\n * a file name.\n * The returned string shall always be allocated on the heap with\n * OPENSSL_malloc(), and need to be free'd with OPENSSL_free().\n *\n * If the ui_method doesn't contain a pointer to a user-defined prompt\n * constructor, a default string is built, looking like this:\n *\n *       \"Enter {object_desc} for {object_name}:\"\n *\n * So, if object_desc has the value \"pass phrase\" and object_name has\n * the value \"foo.key\", the resulting string is:\n *\n *       \"Enter pass phrase for foo.key:\"\n*/\nchar *UI_construct_prompt(UI *ui_method,\n                          const char *object_desc, const char *object_name);\n\n/*\n * The following function is used to store a pointer to user-specific data.\n * Any previous such pointer will be returned and replaced.\n *\n * For callback purposes, this function makes a lot more sense than using\n * ex_data, since the latter requires that different parts of OpenSSL or\n * applications share the same ex_data index.\n *\n * Note that the UI_OpenSSL() method completely ignores the user data. Other\n * methods may not, however.\n */\nvoid *UI_add_user_data(UI *ui, void *user_data);\n/* We need a user data retrieving function as well.  */\nvoid *UI_get0_user_data(UI *ui);\n\n/* Return the result associated with a prompt given with the index i. */\nconst char *UI_get0_result(UI *ui, int i);\n\n/* When all strings have been added, process the whole thing. */\nint UI_process(UI *ui);\n\n/*\n * Give a user interface parametrised control commands.  This can be used to\n * send down an integer, a data pointer or a function pointer, as well as be\n * used to get information from a UI.\n */\nint UI_ctrl(UI *ui, int cmd, long i, void *p, void (*f) (void));\n\n/* The commands */\n/*\n * Use UI_CONTROL_PRINT_ERRORS with the value 1 to have UI_process print the\n * OpenSSL error stack before printing any info or added error messages and\n * before any prompting.\n */\n# define UI_CTRL_PRINT_ERRORS            1\n/*\n * Check if a UI_process() is possible to do again with the same instance of\n * a user interface.  This makes UI_ctrl() return 1 if it is redoable, and 0\n * if not.\n */\n# define UI_CTRL_IS_REDOABLE             2\n\n/* Some methods may use extra data */\n# define UI_set_app_data(s,arg)         UI_set_ex_data(s,0,arg)\n# define UI_get_app_data(s)             UI_get_ex_data(s,0)\nint UI_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func,\n                        CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func);\nint UI_set_ex_data(UI *r, int idx, void *arg);\nvoid *UI_get_ex_data(UI *r, int idx);\n\n/* Use specific methods instead of the built-in one */\nvoid UI_set_default_method(const UI_METHOD *meth);\nconst UI_METHOD *UI_get_default_method(void);\nconst UI_METHOD *UI_get_method(UI *ui);\nconst UI_METHOD *UI_set_method(UI *ui, const UI_METHOD *meth);\n\n/* The method with all the built-in thingies */\nUI_METHOD *UI_OpenSSL(void);\n\n/* ---------- For method writers ---------- */\n/*-\n   A method contains a number of functions that implement the low level\n   of the User Interface.  The functions are:\n\n        an opener       This function starts a session, maybe by opening\n                        a channel to a tty, or by opening a window.\n        a writer        This function is called to write a given string,\n                        maybe to the tty, maybe as a field label in a\n                        window.\n        a flusher       This function is called to flush everything that\n                        has been output so far.  It can be used to actually\n                        display a dialog box after it has been built.\n        a reader        This function is called to read a given prompt,\n                        maybe from the tty, maybe from a field in a\n                        window.  Note that it's called wth all string\n                        structures, not only the prompt ones, so it must\n                        check such things itself.\n        a closer        This function closes the session, maybe by closing\n                        the channel to the tty, or closing the window.\n\n   All these functions are expected to return:\n\n        0       on error.\n        1       on success.\n        -1      on out-of-band events, for example if some prompting has\n                been canceled (by pressing Ctrl-C, for example).  This is\n                only checked when returned by the flusher or the reader.\n\n   The way this is used, the opener is first called, then the writer for all\n   strings, then the flusher, then the reader for all strings and finally the\n   closer.  Note that if you want to prompt from a terminal or other command\n   line interface, the best is to have the reader also write the prompts\n   instead of having the writer do it.  If you want to prompt from a dialog\n   box, the writer can be used to build up the contents of the box, and the\n   flusher to actually display the box and run the event loop until all data\n   has been given, after which the reader only grabs the given data and puts\n   them back into the UI strings.\n\n   All method functions take a UI as argument.  Additionally, the writer and\n   the reader take a UI_STRING.\n*/\n\n/*\n * The UI_STRING type is the data structure that contains all the needed info\n * about a string or a prompt, including test data for a verification prompt.\n */\ntypedef struct ui_string_st UI_STRING;\nDECLARE_STACK_OF(UI_STRING)\n\n/*\n * The different types of strings that are currently supported. This is only\n * needed by method authors.\n */\nenum UI_string_types {\n    UIT_NONE = 0,\n    UIT_PROMPT,                 /* Prompt for a string */\n    UIT_VERIFY,                 /* Prompt for a string and verify */\n    UIT_BOOLEAN,                /* Prompt for a yes/no response */\n    UIT_INFO,                   /* Send info to the user */\n    UIT_ERROR                   /* Send an error message to the user */\n};\n\n/* Create and manipulate methods */\nUI_METHOD *UI_create_method(char *name);\nvoid UI_destroy_method(UI_METHOD *ui_method);\nint UI_method_set_opener(UI_METHOD *method, int (*opener) (UI *ui));\nint UI_method_set_writer(UI_METHOD *method,\n                         int (*writer) (UI *ui, UI_STRING *uis));\nint UI_method_set_flusher(UI_METHOD *method, int (*flusher) (UI *ui));\nint UI_method_set_reader(UI_METHOD *method,\n                         int (*reader) (UI *ui, UI_STRING *uis));\nint UI_method_set_closer(UI_METHOD *method, int (*closer) (UI *ui));\nint UI_method_set_prompt_constructor(UI_METHOD *method,\n                                     char *(*prompt_constructor) (UI *ui,\n                                                                  const char\n                                                                  *object_desc,\n                                                                  const char\n                                                                  *object_name));\nint (*UI_method_get_opener(UI_METHOD *method)) (UI *);\nint (*UI_method_get_writer(UI_METHOD *method)) (UI *, UI_STRING *);\nint (*UI_method_get_flusher(UI_METHOD *method)) (UI *);\nint (*UI_method_get_reader(UI_METHOD *method)) (UI *, UI_STRING *);\nint (*UI_method_get_closer(UI_METHOD *method)) (UI *);\nchar *(*UI_method_get_prompt_constructor(UI_METHOD *method)) (UI *,\n                                                              const char *,\n                                                              const char *);\n\n/*\n * The following functions are helpers for method writers to access relevant\n * data from a UI_STRING.\n */\n\n/* Return type of the UI_STRING */\nenum UI_string_types UI_get_string_type(UI_STRING *uis);\n/* Return input flags of the UI_STRING */\nint UI_get_input_flags(UI_STRING *uis);\n/* Return the actual string to output (the prompt, info or error) */\nconst char *UI_get0_output_string(UI_STRING *uis);\n/*\n * Return the optional action string to output (the boolean promtp\n * instruction)\n */\nconst char *UI_get0_action_string(UI_STRING *uis);\n/* Return the result of a prompt */\nconst char *UI_get0_result_string(UI_STRING *uis);\n/*\n * Return the string to test the result against.  Only useful with verifies.\n */\nconst char *UI_get0_test_string(UI_STRING *uis);\n/* Return the required minimum size of the result */\nint UI_get_result_minsize(UI_STRING *uis);\n/* Return the required maximum size of the result */\nint UI_get_result_maxsize(UI_STRING *uis);\n/* Set the result of a UI_STRING. */\nint UI_set_result(UI *ui, UI_STRING *uis, const char *result);\n\n/* A couple of popular utility functions */\nint UI_UTIL_read_pw_string(char *buf, int length, const char *prompt,\n                           int verify);\nint UI_UTIL_read_pw(char *buf, char *buff, int size, const char *prompt,\n                    int verify);\n\n/* BEGIN ERROR CODES */\n/*\n * The following lines are auto generated by the script mkerr.pl. Any changes\n * made after this point may be overwritten when the script is next run.\n */\nvoid ERR_load_UI_strings(void);\n\n/* Error codes for the UI functions. */\n\n/* Function codes. */\n# define UI_F_GENERAL_ALLOCATE_BOOLEAN                    108\n# define UI_F_GENERAL_ALLOCATE_PROMPT                     109\n# define UI_F_GENERAL_ALLOCATE_STRING                     100\n# define UI_F_UI_CTRL                                     111\n# define UI_F_UI_DUP_ERROR_STRING                         101\n# define UI_F_UI_DUP_INFO_STRING                          102\n# define UI_F_UI_DUP_INPUT_BOOLEAN                        110\n# define UI_F_UI_DUP_INPUT_STRING                         103\n# define UI_F_UI_DUP_VERIFY_STRING                        106\n# define UI_F_UI_GET0_RESULT                              107\n# define UI_F_UI_NEW_METHOD                               104\n# define UI_F_UI_SET_RESULT                               105\n\n/* Reason codes. */\n# define UI_R_COMMON_OK_AND_CANCEL_CHARACTERS             104\n# define UI_R_INDEX_TOO_LARGE                             102\n# define UI_R_INDEX_TOO_SMALL                             103\n# define UI_R_NO_RESULT_BUFFER                            105\n# define UI_R_RESULT_TOO_LARGE                            100\n# define UI_R_RESULT_TOO_SMALL                            101\n# define UI_R_UNKNOWN_CONTROL_COMMAND                     106\n\n#ifdef  __cplusplus\n}\n#endif\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/arm64/include/openssl/ui_compat.h",
    "content": "/* crypto/ui/ui.h */\n/*\n * Written by Richard Levitte (richard@levitte.org) for the OpenSSL project\n * 2001.\n */\n/* ====================================================================\n * Copyright (c) 2001 The OpenSSL Project.  All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n *\n * 1. Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n *\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in\n *    the documentation and/or other materials provided with the\n *    distribution.\n *\n * 3. All advertising materials mentioning features or use of this\n *    software must display the following acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit. (http://www.openssl.org/)\"\n *\n * 4. The names \"OpenSSL Toolkit\" and \"OpenSSL Project\" must not be used to\n *    endorse or promote products derived from this software without\n *    prior written permission. For written permission, please contact\n *    openssl-core@openssl.org.\n *\n * 5. Products derived from this software may not be called \"OpenSSL\"\n *    nor may \"OpenSSL\" appear in their names without prior written\n *    permission of the OpenSSL Project.\n *\n * 6. Redistributions of any form whatsoever must retain the following\n *    acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit (http://www.openssl.org/)\"\n *\n * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY\n * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\n * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR\n * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\n * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,\n * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED\n * OF THE POSSIBILITY OF SUCH DAMAGE.\n * ====================================================================\n *\n * This product includes cryptographic software written by Eric Young\n * (eay@cryptsoft.com).  This product includes software written by Tim\n * Hudson (tjh@cryptsoft.com).\n *\n */\n\n#ifndef HEADER_UI_COMPAT_H\n# define HEADER_UI_COMPAT_H\n\n# include <openssl/opensslconf.h>\n# include <openssl/ui.h>\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n/*\n * The following functions were previously part of the DES section, and are\n * provided here for backward compatibility reasons.\n */\n\n# define des_read_pw_string(b,l,p,v) \\\n        _ossl_old_des_read_pw_string((b),(l),(p),(v))\n# define des_read_pw(b,bf,s,p,v) \\\n        _ossl_old_des_read_pw((b),(bf),(s),(p),(v))\n\nint _ossl_old_des_read_pw_string(char *buf, int length, const char *prompt,\n                                 int verify);\nint _ossl_old_des_read_pw(char *buf, char *buff, int size, const char *prompt,\n                          int verify);\n\n#ifdef  __cplusplus\n}\n#endif\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/arm64/include/openssl/whrlpool.h",
    "content": "#ifndef HEADER_WHRLPOOL_H\n# define HEADER_WHRLPOOL_H\n\n# include <openssl/e_os2.h>\n# include <stddef.h>\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n# define WHIRLPOOL_DIGEST_LENGTH (512/8)\n# define WHIRLPOOL_BBLOCK        512\n# define WHIRLPOOL_COUNTER       (256/8)\n\ntypedef struct {\n    union {\n        unsigned char c[WHIRLPOOL_DIGEST_LENGTH];\n        /* double q is here to ensure 64-bit alignment */\n        double q[WHIRLPOOL_DIGEST_LENGTH / sizeof(double)];\n    } H;\n    unsigned char data[WHIRLPOOL_BBLOCK / 8];\n    unsigned int bitoff;\n    size_t bitlen[WHIRLPOOL_COUNTER / sizeof(size_t)];\n} WHIRLPOOL_CTX;\n\n# ifndef OPENSSL_NO_WHIRLPOOL\n#  ifdef OPENSSL_FIPS\nint private_WHIRLPOOL_Init(WHIRLPOOL_CTX *c);\n#  endif\nint WHIRLPOOL_Init(WHIRLPOOL_CTX *c);\nint WHIRLPOOL_Update(WHIRLPOOL_CTX *c, const void *inp, size_t bytes);\nvoid WHIRLPOOL_BitUpdate(WHIRLPOOL_CTX *c, const void *inp, size_t bits);\nint WHIRLPOOL_Final(unsigned char *md, WHIRLPOOL_CTX *c);\nunsigned char *WHIRLPOOL(const void *inp, size_t bytes, unsigned char *md);\n# endif\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/arm64/include/openssl/x509.h",
    "content": "/* crypto/x509/x509.h */\n/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)\n * All rights reserved.\n *\n * This package is an SSL implementation written\n * by Eric Young (eay@cryptsoft.com).\n * The implementation was written so as to conform with Netscapes SSL.\n *\n * This library is free for commercial and non-commercial use as long as\n * the following conditions are aheared to.  The following conditions\n * apply to all code found in this distribution, be it the RC4, RSA,\n * lhash, DES, etc., code; not just the SSL code.  The SSL documentation\n * included with this distribution is covered by the same copyright terms\n * except that the holder is Tim Hudson (tjh@cryptsoft.com).\n *\n * Copyright remains Eric Young's, and as such any Copyright notices in\n * the code are not to be removed.\n * If this package is used in a product, Eric Young should be given attribution\n * as the author of the parts of the library used.\n * This can be in the form of a textual message at program startup or\n * in documentation (online or textual) provided with the package.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the copyright\n *    notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in the\n *    documentation and/or other materials provided with the distribution.\n * 3. All advertising materials mentioning features or use of this software\n *    must display the following acknowledgement:\n *    \"This product includes cryptographic software written by\n *     Eric Young (eay@cryptsoft.com)\"\n *    The word 'cryptographic' can be left out if the rouines from the library\n *    being used are not cryptographic related :-).\n * 4. If you include any Windows specific code (or a derivative thereof) from\n *    the apps directory (application code) you must include an acknowledgement:\n *    \"This product includes software written by Tim Hudson (tjh@cryptsoft.com)\"\n *\n * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n * SUCH DAMAGE.\n *\n * The licence and distribution terms for any publically available version or\n * derivative of this code cannot be changed.  i.e. this code cannot simply be\n * copied and put under another distribution licence\n * [including the GNU Public Licence.]\n */\n/* ====================================================================\n * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED.\n * ECDH support in OpenSSL originally developed by\n * SUN MICROSYSTEMS, INC., and contributed to the OpenSSL project.\n */\n\n#ifndef HEADER_X509_H\n# define HEADER_X509_H\n\n# include <openssl/e_os2.h>\n# include <openssl/symhacks.h>\n# ifndef OPENSSL_NO_BUFFER\n#  include <openssl/buffer.h>\n# endif\n# ifndef OPENSSL_NO_EVP\n#  include <openssl/evp.h>\n# endif\n# ifndef OPENSSL_NO_BIO\n#  include <openssl/bio.h>\n# endif\n# include <openssl/stack.h>\n# include <openssl/asn1.h>\n# include <openssl/safestack.h>\n\n# ifndef OPENSSL_NO_EC\n#  include <openssl/ec.h>\n# endif\n\n# ifndef OPENSSL_NO_ECDSA\n#  include <openssl/ecdsa.h>\n# endif\n\n# ifndef OPENSSL_NO_ECDH\n#  include <openssl/ecdh.h>\n# endif\n\n# ifndef OPENSSL_NO_DEPRECATED\n#  ifndef OPENSSL_NO_RSA\n#   include <openssl/rsa.h>\n#  endif\n#  ifndef OPENSSL_NO_DSA\n#   include <openssl/dsa.h>\n#  endif\n#  ifndef OPENSSL_NO_DH\n#   include <openssl/dh.h>\n#  endif\n# endif\n\n# ifndef OPENSSL_NO_SHA\n#  include <openssl/sha.h>\n# endif\n# include <openssl/ossl_typ.h>\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n# ifdef OPENSSL_SYS_WIN32\n/* Under Win32 these are defined in wincrypt.h */\n#  undef X509_NAME\n#  undef X509_CERT_PAIR\n#  undef X509_EXTENSIONS\n# endif\n\n# define X509_FILETYPE_PEM       1\n# define X509_FILETYPE_ASN1      2\n# define X509_FILETYPE_DEFAULT   3\n\n# define X509v3_KU_DIGITAL_SIGNATURE     0x0080\n# define X509v3_KU_NON_REPUDIATION       0x0040\n# define X509v3_KU_KEY_ENCIPHERMENT      0x0020\n# define X509v3_KU_DATA_ENCIPHERMENT     0x0010\n# define X509v3_KU_KEY_AGREEMENT         0x0008\n# define X509v3_KU_KEY_CERT_SIGN         0x0004\n# define X509v3_KU_CRL_SIGN              0x0002\n# define X509v3_KU_ENCIPHER_ONLY         0x0001\n# define X509v3_KU_DECIPHER_ONLY         0x8000\n# define X509v3_KU_UNDEF                 0xffff\n\ntypedef struct X509_objects_st {\n    int nid;\n    int (*a2i) (void);\n    int (*i2a) (void);\n} X509_OBJECTS;\n\nstruct X509_algor_st {\n    ASN1_OBJECT *algorithm;\n    ASN1_TYPE *parameter;\n} /* X509_ALGOR */ ;\n\nDECLARE_ASN1_SET_OF(X509_ALGOR)\n\ntypedef STACK_OF(X509_ALGOR) X509_ALGORS;\n\ntypedef struct X509_val_st {\n    ASN1_TIME *notBefore;\n    ASN1_TIME *notAfter;\n} X509_VAL;\n\nstruct X509_pubkey_st {\n    X509_ALGOR *algor;\n    ASN1_BIT_STRING *public_key;\n    EVP_PKEY *pkey;\n};\n\ntypedef struct X509_sig_st {\n    X509_ALGOR *algor;\n    ASN1_OCTET_STRING *digest;\n} X509_SIG;\n\ntypedef struct X509_name_entry_st {\n    ASN1_OBJECT *object;\n    ASN1_STRING *value;\n    int set;\n    int size;                   /* temp variable */\n} X509_NAME_ENTRY;\n\nDECLARE_STACK_OF(X509_NAME_ENTRY)\nDECLARE_ASN1_SET_OF(X509_NAME_ENTRY)\n\n/* we always keep X509_NAMEs in 2 forms. */\nstruct X509_name_st {\n    STACK_OF(X509_NAME_ENTRY) *entries;\n    int modified;               /* true if 'bytes' needs to be built */\n# ifndef OPENSSL_NO_BUFFER\n    BUF_MEM *bytes;\n# else\n    char *bytes;\n# endif\n/*      unsigned long hash; Keep the hash around for lookups */\n    unsigned char *canon_enc;\n    int canon_enclen;\n} /* X509_NAME */ ;\n\nDECLARE_STACK_OF(X509_NAME)\n\n# define X509_EX_V_NETSCAPE_HACK         0x8000\n# define X509_EX_V_INIT                  0x0001\ntypedef struct X509_extension_st {\n    ASN1_OBJECT *object;\n    ASN1_BOOLEAN critical;\n    ASN1_OCTET_STRING *value;\n} X509_EXTENSION;\n\ntypedef STACK_OF(X509_EXTENSION) X509_EXTENSIONS;\n\nDECLARE_STACK_OF(X509_EXTENSION)\nDECLARE_ASN1_SET_OF(X509_EXTENSION)\n\n/* a sequence of these are used */\ntypedef struct x509_attributes_st {\n    ASN1_OBJECT *object;\n    int single;                 /* 0 for a set, 1 for a single item (which is\n                                 * wrong) */\n    union {\n        char *ptr;\n        /*\n         * 0\n         */ STACK_OF(ASN1_TYPE) *set;\n        /*\n         * 1\n         */ ASN1_TYPE *single;\n    } value;\n} X509_ATTRIBUTE;\n\nDECLARE_STACK_OF(X509_ATTRIBUTE)\nDECLARE_ASN1_SET_OF(X509_ATTRIBUTE)\n\ntypedef struct X509_req_info_st {\n    ASN1_ENCODING enc;\n    ASN1_INTEGER *version;\n    X509_NAME *subject;\n    X509_PUBKEY *pubkey;\n    /*  d=2 hl=2 l=  0 cons: cont: 00 */\n    STACK_OF(X509_ATTRIBUTE) *attributes; /* [ 0 ] */\n} X509_REQ_INFO;\n\ntypedef struct X509_req_st {\n    X509_REQ_INFO *req_info;\n    X509_ALGOR *sig_alg;\n    ASN1_BIT_STRING *signature;\n    int references;\n} X509_REQ;\n\ntypedef struct x509_cinf_st {\n    ASN1_INTEGER *version;      /* [ 0 ] default of v1 */\n    ASN1_INTEGER *serialNumber;\n    X509_ALGOR *signature;\n    X509_NAME *issuer;\n    X509_VAL *validity;\n    X509_NAME *subject;\n    X509_PUBKEY *key;\n    ASN1_BIT_STRING *issuerUID; /* [ 1 ] optional in v2 */\n    ASN1_BIT_STRING *subjectUID; /* [ 2 ] optional in v2 */\n    STACK_OF(X509_EXTENSION) *extensions; /* [ 3 ] optional in v3 */\n    ASN1_ENCODING enc;\n} X509_CINF;\n\n/*\n * This stuff is certificate \"auxiliary info\" it contains details which are\n * useful in certificate stores and databases. When used this is tagged onto\n * the end of the certificate itself\n */\n\ntypedef struct x509_cert_aux_st {\n    STACK_OF(ASN1_OBJECT) *trust; /* trusted uses */\n    STACK_OF(ASN1_OBJECT) *reject; /* rejected uses */\n    ASN1_UTF8STRING *alias;     /* \"friendly name\" */\n    ASN1_OCTET_STRING *keyid;   /* key id of private key */\n    STACK_OF(X509_ALGOR) *other; /* other unspecified info */\n} X509_CERT_AUX;\n\nstruct x509_st {\n    X509_CINF *cert_info;\n    X509_ALGOR *sig_alg;\n    ASN1_BIT_STRING *signature;\n    int valid;\n    int references;\n    char *name;\n    CRYPTO_EX_DATA ex_data;\n    /* These contain copies of various extension values */\n    long ex_pathlen;\n    long ex_pcpathlen;\n    unsigned long ex_flags;\n    unsigned long ex_kusage;\n    unsigned long ex_xkusage;\n    unsigned long ex_nscert;\n    ASN1_OCTET_STRING *skid;\n    AUTHORITY_KEYID *akid;\n    X509_POLICY_CACHE *policy_cache;\n    STACK_OF(DIST_POINT) *crldp;\n    STACK_OF(GENERAL_NAME) *altname;\n    NAME_CONSTRAINTS *nc;\n# ifndef OPENSSL_NO_RFC3779\n    STACK_OF(IPAddressFamily) *rfc3779_addr;\n    struct ASIdentifiers_st *rfc3779_asid;\n# endif\n# ifndef OPENSSL_NO_SHA\n    unsigned char sha1_hash[SHA_DIGEST_LENGTH];\n# endif\n    X509_CERT_AUX *aux;\n} /* X509 */ ;\n\nDECLARE_STACK_OF(X509)\nDECLARE_ASN1_SET_OF(X509)\n\n/* This is used for a table of trust checking functions */\n\ntypedef struct x509_trust_st {\n    int trust;\n    int flags;\n    int (*check_trust) (struct x509_trust_st *, X509 *, int);\n    char *name;\n    int arg1;\n    void *arg2;\n} X509_TRUST;\n\nDECLARE_STACK_OF(X509_TRUST)\n\ntypedef struct x509_cert_pair_st {\n    X509 *forward;\n    X509 *reverse;\n} X509_CERT_PAIR;\n\n/* standard trust ids */\n\n# define X509_TRUST_DEFAULT      -1/* Only valid in purpose settings */\n\n# define X509_TRUST_COMPAT       1\n# define X509_TRUST_SSL_CLIENT   2\n# define X509_TRUST_SSL_SERVER   3\n# define X509_TRUST_EMAIL        4\n# define X509_TRUST_OBJECT_SIGN  5\n# define X509_TRUST_OCSP_SIGN    6\n# define X509_TRUST_OCSP_REQUEST 7\n# define X509_TRUST_TSA          8\n\n/* Keep these up to date! */\n# define X509_TRUST_MIN          1\n# define X509_TRUST_MAX          8\n\n/* trust_flags values */\n# define X509_TRUST_DYNAMIC      1\n# define X509_TRUST_DYNAMIC_NAME 2\n\n/* check_trust return codes */\n\n# define X509_TRUST_TRUSTED      1\n# define X509_TRUST_REJECTED     2\n# define X509_TRUST_UNTRUSTED    3\n\n/* Flags for X509_print_ex() */\n\n# define X509_FLAG_COMPAT                0\n# define X509_FLAG_NO_HEADER             1L\n# define X509_FLAG_NO_VERSION            (1L << 1)\n# define X509_FLAG_NO_SERIAL             (1L << 2)\n# define X509_FLAG_NO_SIGNAME            (1L << 3)\n# define X509_FLAG_NO_ISSUER             (1L << 4)\n# define X509_FLAG_NO_VALIDITY           (1L << 5)\n# define X509_FLAG_NO_SUBJECT            (1L << 6)\n# define X509_FLAG_NO_PUBKEY             (1L << 7)\n# define X509_FLAG_NO_EXTENSIONS         (1L << 8)\n# define X509_FLAG_NO_SIGDUMP            (1L << 9)\n# define X509_FLAG_NO_AUX                (1L << 10)\n# define X509_FLAG_NO_ATTRIBUTES         (1L << 11)\n# define X509_FLAG_NO_IDS                (1L << 12)\n\n/* Flags specific to X509_NAME_print_ex() */\n\n/* The field separator information */\n\n# define XN_FLAG_SEP_MASK        (0xf << 16)\n\n# define XN_FLAG_COMPAT          0/* Traditional SSLeay: use old\n                                   * X509_NAME_print */\n# define XN_FLAG_SEP_COMMA_PLUS  (1 << 16)/* RFC2253 ,+ */\n# define XN_FLAG_SEP_CPLUS_SPC   (2 << 16)/* ,+ spaced: more readable */\n# define XN_FLAG_SEP_SPLUS_SPC   (3 << 16)/* ;+ spaced */\n# define XN_FLAG_SEP_MULTILINE   (4 << 16)/* One line per field */\n\n# define XN_FLAG_DN_REV          (1 << 20)/* Reverse DN order */\n\n/* How the field name is shown */\n\n# define XN_FLAG_FN_MASK         (0x3 << 21)\n\n# define XN_FLAG_FN_SN           0/* Object short name */\n# define XN_FLAG_FN_LN           (1 << 21)/* Object long name */\n# define XN_FLAG_FN_OID          (2 << 21)/* Always use OIDs */\n# define XN_FLAG_FN_NONE         (3 << 21)/* No field names */\n\n# define XN_FLAG_SPC_EQ          (1 << 23)/* Put spaces round '=' */\n\n/*\n * This determines if we dump fields we don't recognise: RFC2253 requires\n * this.\n */\n\n# define XN_FLAG_DUMP_UNKNOWN_FIELDS (1 << 24)\n\n# define XN_FLAG_FN_ALIGN        (1 << 25)/* Align field names to 20\n                                           * characters */\n\n/* Complete set of RFC2253 flags */\n\n# define XN_FLAG_RFC2253 (ASN1_STRFLGS_RFC2253 | \\\n                        XN_FLAG_SEP_COMMA_PLUS | \\\n                        XN_FLAG_DN_REV | \\\n                        XN_FLAG_FN_SN | \\\n                        XN_FLAG_DUMP_UNKNOWN_FIELDS)\n\n/* readable oneline form */\n\n# define XN_FLAG_ONELINE (ASN1_STRFLGS_RFC2253 | \\\n                        ASN1_STRFLGS_ESC_QUOTE | \\\n                        XN_FLAG_SEP_CPLUS_SPC | \\\n                        XN_FLAG_SPC_EQ | \\\n                        XN_FLAG_FN_SN)\n\n/* readable multiline form */\n\n# define XN_FLAG_MULTILINE (ASN1_STRFLGS_ESC_CTRL | \\\n                        ASN1_STRFLGS_ESC_MSB | \\\n                        XN_FLAG_SEP_MULTILINE | \\\n                        XN_FLAG_SPC_EQ | \\\n                        XN_FLAG_FN_LN | \\\n                        XN_FLAG_FN_ALIGN)\n\nstruct x509_revoked_st {\n    ASN1_INTEGER *serialNumber;\n    ASN1_TIME *revocationDate;\n    STACK_OF(X509_EXTENSION) /* optional */ *extensions;\n    /* Set up if indirect CRL */\n    STACK_OF(GENERAL_NAME) *issuer;\n    /* Revocation reason */\n    int reason;\n    int sequence;               /* load sequence */\n};\n\nDECLARE_STACK_OF(X509_REVOKED)\nDECLARE_ASN1_SET_OF(X509_REVOKED)\n\ntypedef struct X509_crl_info_st {\n    ASN1_INTEGER *version;\n    X509_ALGOR *sig_alg;\n    X509_NAME *issuer;\n    ASN1_TIME *lastUpdate;\n    ASN1_TIME *nextUpdate;\n    STACK_OF(X509_REVOKED) *revoked;\n    STACK_OF(X509_EXTENSION) /* [0] */ *extensions;\n    ASN1_ENCODING enc;\n} X509_CRL_INFO;\n\nstruct X509_crl_st {\n    /* actual signature */\n    X509_CRL_INFO *crl;\n    X509_ALGOR *sig_alg;\n    ASN1_BIT_STRING *signature;\n    int references;\n    int flags;\n    /* Copies of various extensions */\n    AUTHORITY_KEYID *akid;\n    ISSUING_DIST_POINT *idp;\n    /* Convenient breakdown of IDP */\n    int idp_flags;\n    int idp_reasons;\n    /* CRL and base CRL numbers for delta processing */\n    ASN1_INTEGER *crl_number;\n    ASN1_INTEGER *base_crl_number;\n# ifndef OPENSSL_NO_SHA\n    unsigned char sha1_hash[SHA_DIGEST_LENGTH];\n# endif\n    STACK_OF(GENERAL_NAMES) *issuers;\n    const X509_CRL_METHOD *meth;\n    void *meth_data;\n} /* X509_CRL */ ;\n\nDECLARE_STACK_OF(X509_CRL)\nDECLARE_ASN1_SET_OF(X509_CRL)\n\ntypedef struct private_key_st {\n    int version;\n    /* The PKCS#8 data types */\n    X509_ALGOR *enc_algor;\n    ASN1_OCTET_STRING *enc_pkey; /* encrypted pub key */\n    /* When decrypted, the following will not be NULL */\n    EVP_PKEY *dec_pkey;\n    /* used to encrypt and decrypt */\n    int key_length;\n    char *key_data;\n    int key_free;               /* true if we should auto free key_data */\n    /* expanded version of 'enc_algor' */\n    EVP_CIPHER_INFO cipher;\n    int references;\n} X509_PKEY;\n\n# ifndef OPENSSL_NO_EVP\ntypedef struct X509_info_st {\n    X509 *x509;\n    X509_CRL *crl;\n    X509_PKEY *x_pkey;\n    EVP_CIPHER_INFO enc_cipher;\n    int enc_len;\n    char *enc_data;\n    int references;\n} X509_INFO;\n\nDECLARE_STACK_OF(X509_INFO)\n# endif\n\n/*\n * The next 2 structures and their 8 routines were sent to me by Pat Richard\n * <patr@x509.com> and are used to manipulate Netscapes spki structures -\n * useful if you are writing a CA web page\n */\ntypedef struct Netscape_spkac_st {\n    X509_PUBKEY *pubkey;\n    ASN1_IA5STRING *challenge;  /* challenge sent in atlas >= PR2 */\n} NETSCAPE_SPKAC;\n\ntypedef struct Netscape_spki_st {\n    NETSCAPE_SPKAC *spkac;      /* signed public key and challenge */\n    X509_ALGOR *sig_algor;\n    ASN1_BIT_STRING *signature;\n} NETSCAPE_SPKI;\n\n/* Netscape certificate sequence structure */\ntypedef struct Netscape_certificate_sequence {\n    ASN1_OBJECT *type;\n    STACK_OF(X509) *certs;\n} NETSCAPE_CERT_SEQUENCE;\n\n/*- Unused (and iv length is wrong)\ntypedef struct CBCParameter_st\n        {\n        unsigned char iv[8];\n        } CBC_PARAM;\n*/\n\n/* Password based encryption structure */\n\ntypedef struct PBEPARAM_st {\n    ASN1_OCTET_STRING *salt;\n    ASN1_INTEGER *iter;\n} PBEPARAM;\n\n/* Password based encryption V2 structures */\n\ntypedef struct PBE2PARAM_st {\n    X509_ALGOR *keyfunc;\n    X509_ALGOR *encryption;\n} PBE2PARAM;\n\ntypedef struct PBKDF2PARAM_st {\n/* Usually OCTET STRING but could be anything */\n    ASN1_TYPE *salt;\n    ASN1_INTEGER *iter;\n    ASN1_INTEGER *keylength;\n    X509_ALGOR *prf;\n} PBKDF2PARAM;\n\n/* PKCS#8 private key info structure */\n\nstruct pkcs8_priv_key_info_st {\n    /* Flag for various broken formats */\n    int broken;\n# define PKCS8_OK                0\n# define PKCS8_NO_OCTET          1\n# define PKCS8_EMBEDDED_PARAM    2\n# define PKCS8_NS_DB             3\n# define PKCS8_NEG_PRIVKEY       4\n    ASN1_INTEGER *version;\n    X509_ALGOR *pkeyalg;\n    /* Should be OCTET STRING but some are broken */\n    ASN1_TYPE *pkey;\n    STACK_OF(X509_ATTRIBUTE) *attributes;\n};\n\n#ifdef  __cplusplus\n}\n#endif\n\n# include <openssl/x509_vfy.h>\n# include <openssl/pkcs7.h>\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n# define X509_EXT_PACK_UNKNOWN   1\n# define X509_EXT_PACK_STRING    2\n\n# define         X509_get_version(x) ASN1_INTEGER_get((x)->cert_info->version)\n/* #define      X509_get_serialNumber(x) ((x)->cert_info->serialNumber) */\n# define         X509_get_notBefore(x) ((x)->cert_info->validity->notBefore)\n# define         X509_get_notAfter(x) ((x)->cert_info->validity->notAfter)\n# define         X509_extract_key(x)     X509_get_pubkey(x)/*****/\n# define         X509_REQ_get_version(x) ASN1_INTEGER_get((x)->req_info->version)\n# define         X509_REQ_get_subject_name(x) ((x)->req_info->subject)\n# define         X509_REQ_extract_key(a) X509_REQ_get_pubkey(a)\n# define         X509_name_cmp(a,b)      X509_NAME_cmp((a),(b))\n# define         X509_get_signature_type(x) EVP_PKEY_type(OBJ_obj2nid((x)->sig_alg->algorithm))\n\n# define         X509_CRL_get_version(x) ASN1_INTEGER_get((x)->crl->version)\n# define         X509_CRL_get_lastUpdate(x) ((x)->crl->lastUpdate)\n# define         X509_CRL_get_nextUpdate(x) ((x)->crl->nextUpdate)\n# define         X509_CRL_get_issuer(x) ((x)->crl->issuer)\n# define         X509_CRL_get_REVOKED(x) ((x)->crl->revoked)\n\nvoid X509_CRL_set_default_method(const X509_CRL_METHOD *meth);\nX509_CRL_METHOD *X509_CRL_METHOD_new(int (*crl_init) (X509_CRL *crl),\n                                     int (*crl_free) (X509_CRL *crl),\n                                     int (*crl_lookup) (X509_CRL *crl,\n                                                        X509_REVOKED **ret,\n                                                        ASN1_INTEGER *ser,\n                                                        X509_NAME *issuer),\n                                     int (*crl_verify) (X509_CRL *crl,\n                                                        EVP_PKEY *pk));\nvoid X509_CRL_METHOD_free(X509_CRL_METHOD *m);\n\nvoid X509_CRL_set_meth_data(X509_CRL *crl, void *dat);\nvoid *X509_CRL_get_meth_data(X509_CRL *crl);\n\n/*\n * This one is only used so that a binary form can output, as in\n * i2d_X509_NAME(X509_get_X509_PUBKEY(x),&buf)\n */\n# define         X509_get_X509_PUBKEY(x) ((x)->cert_info->key)\n\nconst char *X509_verify_cert_error_string(long n);\n\n# ifndef OPENSSL_NO_EVP\nint X509_verify(X509 *a, EVP_PKEY *r);\n\nint X509_REQ_verify(X509_REQ *a, EVP_PKEY *r);\nint X509_CRL_verify(X509_CRL *a, EVP_PKEY *r);\nint NETSCAPE_SPKI_verify(NETSCAPE_SPKI *a, EVP_PKEY *r);\n\nNETSCAPE_SPKI *NETSCAPE_SPKI_b64_decode(const char *str, int len);\nchar *NETSCAPE_SPKI_b64_encode(NETSCAPE_SPKI *x);\nEVP_PKEY *NETSCAPE_SPKI_get_pubkey(NETSCAPE_SPKI *x);\nint NETSCAPE_SPKI_set_pubkey(NETSCAPE_SPKI *x, EVP_PKEY *pkey);\n\nint NETSCAPE_SPKI_print(BIO *out, NETSCAPE_SPKI *spki);\n\nint X509_signature_dump(BIO *bp, const ASN1_STRING *sig, int indent);\nint X509_signature_print(BIO *bp, X509_ALGOR *alg, ASN1_STRING *sig);\n\nint X509_sign(X509 *x, EVP_PKEY *pkey, const EVP_MD *md);\nint X509_sign_ctx(X509 *x, EVP_MD_CTX *ctx);\nint X509_http_nbio(OCSP_REQ_CTX *rctx, X509 **pcert);\nint X509_REQ_sign(X509_REQ *x, EVP_PKEY *pkey, const EVP_MD *md);\nint X509_REQ_sign_ctx(X509_REQ *x, EVP_MD_CTX *ctx);\nint X509_CRL_sign(X509_CRL *x, EVP_PKEY *pkey, const EVP_MD *md);\nint X509_CRL_sign_ctx(X509_CRL *x, EVP_MD_CTX *ctx);\nint X509_CRL_http_nbio(OCSP_REQ_CTX *rctx, X509_CRL **pcrl);\nint NETSCAPE_SPKI_sign(NETSCAPE_SPKI *x, EVP_PKEY *pkey, const EVP_MD *md);\n\nint X509_pubkey_digest(const X509 *data, const EVP_MD *type,\n                       unsigned char *md, unsigned int *len);\nint X509_digest(const X509 *data, const EVP_MD *type,\n                unsigned char *md, unsigned int *len);\nint X509_CRL_digest(const X509_CRL *data, const EVP_MD *type,\n                    unsigned char *md, unsigned int *len);\nint X509_REQ_digest(const X509_REQ *data, const EVP_MD *type,\n                    unsigned char *md, unsigned int *len);\nint X509_NAME_digest(const X509_NAME *data, const EVP_MD *type,\n                     unsigned char *md, unsigned int *len);\n# endif\n\n# ifndef OPENSSL_NO_FP_API\nX509 *d2i_X509_fp(FILE *fp, X509 **x509);\nint i2d_X509_fp(FILE *fp, X509 *x509);\nX509_CRL *d2i_X509_CRL_fp(FILE *fp, X509_CRL **crl);\nint i2d_X509_CRL_fp(FILE *fp, X509_CRL *crl);\nX509_REQ *d2i_X509_REQ_fp(FILE *fp, X509_REQ **req);\nint i2d_X509_REQ_fp(FILE *fp, X509_REQ *req);\n#  ifndef OPENSSL_NO_RSA\nRSA *d2i_RSAPrivateKey_fp(FILE *fp, RSA **rsa);\nint i2d_RSAPrivateKey_fp(FILE *fp, RSA *rsa);\nRSA *d2i_RSAPublicKey_fp(FILE *fp, RSA **rsa);\nint i2d_RSAPublicKey_fp(FILE *fp, RSA *rsa);\nRSA *d2i_RSA_PUBKEY_fp(FILE *fp, RSA **rsa);\nint i2d_RSA_PUBKEY_fp(FILE *fp, RSA *rsa);\n#  endif\n#  ifndef OPENSSL_NO_DSA\nDSA *d2i_DSA_PUBKEY_fp(FILE *fp, DSA **dsa);\nint i2d_DSA_PUBKEY_fp(FILE *fp, DSA *dsa);\nDSA *d2i_DSAPrivateKey_fp(FILE *fp, DSA **dsa);\nint i2d_DSAPrivateKey_fp(FILE *fp, DSA *dsa);\n#  endif\n#  ifndef OPENSSL_NO_EC\nEC_KEY *d2i_EC_PUBKEY_fp(FILE *fp, EC_KEY **eckey);\nint i2d_EC_PUBKEY_fp(FILE *fp, EC_KEY *eckey);\nEC_KEY *d2i_ECPrivateKey_fp(FILE *fp, EC_KEY **eckey);\nint i2d_ECPrivateKey_fp(FILE *fp, EC_KEY *eckey);\n#  endif\nX509_SIG *d2i_PKCS8_fp(FILE *fp, X509_SIG **p8);\nint i2d_PKCS8_fp(FILE *fp, X509_SIG *p8);\nPKCS8_PRIV_KEY_INFO *d2i_PKCS8_PRIV_KEY_INFO_fp(FILE *fp,\n                                                PKCS8_PRIV_KEY_INFO **p8inf);\nint i2d_PKCS8_PRIV_KEY_INFO_fp(FILE *fp, PKCS8_PRIV_KEY_INFO *p8inf);\nint i2d_PKCS8PrivateKeyInfo_fp(FILE *fp, EVP_PKEY *key);\nint i2d_PrivateKey_fp(FILE *fp, EVP_PKEY *pkey);\nEVP_PKEY *d2i_PrivateKey_fp(FILE *fp, EVP_PKEY **a);\nint i2d_PUBKEY_fp(FILE *fp, EVP_PKEY *pkey);\nEVP_PKEY *d2i_PUBKEY_fp(FILE *fp, EVP_PKEY **a);\n# endif\n\n# ifndef OPENSSL_NO_BIO\nX509 *d2i_X509_bio(BIO *bp, X509 **x509);\nint i2d_X509_bio(BIO *bp, X509 *x509);\nX509_CRL *d2i_X509_CRL_bio(BIO *bp, X509_CRL **crl);\nint i2d_X509_CRL_bio(BIO *bp, X509_CRL *crl);\nX509_REQ *d2i_X509_REQ_bio(BIO *bp, X509_REQ **req);\nint i2d_X509_REQ_bio(BIO *bp, X509_REQ *req);\n#  ifndef OPENSSL_NO_RSA\nRSA *d2i_RSAPrivateKey_bio(BIO *bp, RSA **rsa);\nint i2d_RSAPrivateKey_bio(BIO *bp, RSA *rsa);\nRSA *d2i_RSAPublicKey_bio(BIO *bp, RSA **rsa);\nint i2d_RSAPublicKey_bio(BIO *bp, RSA *rsa);\nRSA *d2i_RSA_PUBKEY_bio(BIO *bp, RSA **rsa);\nint i2d_RSA_PUBKEY_bio(BIO *bp, RSA *rsa);\n#  endif\n#  ifndef OPENSSL_NO_DSA\nDSA *d2i_DSA_PUBKEY_bio(BIO *bp, DSA **dsa);\nint i2d_DSA_PUBKEY_bio(BIO *bp, DSA *dsa);\nDSA *d2i_DSAPrivateKey_bio(BIO *bp, DSA **dsa);\nint i2d_DSAPrivateKey_bio(BIO *bp, DSA *dsa);\n#  endif\n#  ifndef OPENSSL_NO_EC\nEC_KEY *d2i_EC_PUBKEY_bio(BIO *bp, EC_KEY **eckey);\nint i2d_EC_PUBKEY_bio(BIO *bp, EC_KEY *eckey);\nEC_KEY *d2i_ECPrivateKey_bio(BIO *bp, EC_KEY **eckey);\nint i2d_ECPrivateKey_bio(BIO *bp, EC_KEY *eckey);\n#  endif\nX509_SIG *d2i_PKCS8_bio(BIO *bp, X509_SIG **p8);\nint i2d_PKCS8_bio(BIO *bp, X509_SIG *p8);\nPKCS8_PRIV_KEY_INFO *d2i_PKCS8_PRIV_KEY_INFO_bio(BIO *bp,\n                                                 PKCS8_PRIV_KEY_INFO **p8inf);\nint i2d_PKCS8_PRIV_KEY_INFO_bio(BIO *bp, PKCS8_PRIV_KEY_INFO *p8inf);\nint i2d_PKCS8PrivateKeyInfo_bio(BIO *bp, EVP_PKEY *key);\nint i2d_PrivateKey_bio(BIO *bp, EVP_PKEY *pkey);\nEVP_PKEY *d2i_PrivateKey_bio(BIO *bp, EVP_PKEY **a);\nint i2d_PUBKEY_bio(BIO *bp, EVP_PKEY *pkey);\nEVP_PKEY *d2i_PUBKEY_bio(BIO *bp, EVP_PKEY **a);\n# endif\n\nX509 *X509_dup(X509 *x509);\nX509_ATTRIBUTE *X509_ATTRIBUTE_dup(X509_ATTRIBUTE *xa);\nX509_EXTENSION *X509_EXTENSION_dup(X509_EXTENSION *ex);\nX509_CRL *X509_CRL_dup(X509_CRL *crl);\nX509_REVOKED *X509_REVOKED_dup(X509_REVOKED *rev);\nX509_REQ *X509_REQ_dup(X509_REQ *req);\nX509_ALGOR *X509_ALGOR_dup(X509_ALGOR *xn);\nint X509_ALGOR_set0(X509_ALGOR *alg, ASN1_OBJECT *aobj, int ptype,\n                    void *pval);\nvoid X509_ALGOR_get0(ASN1_OBJECT **paobj, int *pptype, void **ppval,\n                     X509_ALGOR *algor);\nvoid X509_ALGOR_set_md(X509_ALGOR *alg, const EVP_MD *md);\nint X509_ALGOR_cmp(const X509_ALGOR *a, const X509_ALGOR *b);\n\nX509_NAME *X509_NAME_dup(X509_NAME *xn);\nX509_NAME_ENTRY *X509_NAME_ENTRY_dup(X509_NAME_ENTRY *ne);\n\nint X509_cmp_time(const ASN1_TIME *s, time_t *t);\nint X509_cmp_current_time(const ASN1_TIME *s);\nASN1_TIME *X509_time_adj(ASN1_TIME *s, long adj, time_t *t);\nASN1_TIME *X509_time_adj_ex(ASN1_TIME *s,\n                            int offset_day, long offset_sec, time_t *t);\nASN1_TIME *X509_gmtime_adj(ASN1_TIME *s, long adj);\n\nconst char *X509_get_default_cert_area(void);\nconst char *X509_get_default_cert_dir(void);\nconst char *X509_get_default_cert_file(void);\nconst char *X509_get_default_cert_dir_env(void);\nconst char *X509_get_default_cert_file_env(void);\nconst char *X509_get_default_private_dir(void);\n\nX509_REQ *X509_to_X509_REQ(X509 *x, EVP_PKEY *pkey, const EVP_MD *md);\nX509 *X509_REQ_to_X509(X509_REQ *r, int days, EVP_PKEY *pkey);\n\nDECLARE_ASN1_FUNCTIONS(X509_ALGOR)\nDECLARE_ASN1_ENCODE_FUNCTIONS(X509_ALGORS, X509_ALGORS, X509_ALGORS)\nDECLARE_ASN1_FUNCTIONS(X509_VAL)\n\nDECLARE_ASN1_FUNCTIONS(X509_PUBKEY)\n\nint X509_PUBKEY_set(X509_PUBKEY **x, EVP_PKEY *pkey);\nEVP_PKEY *X509_PUBKEY_get(X509_PUBKEY *key);\nint X509_get_pubkey_parameters(EVP_PKEY *pkey, STACK_OF(X509) *chain);\nint i2d_PUBKEY(EVP_PKEY *a, unsigned char **pp);\nEVP_PKEY *d2i_PUBKEY(EVP_PKEY **a, const unsigned char **pp, long length);\n# ifndef OPENSSL_NO_RSA\nint i2d_RSA_PUBKEY(RSA *a, unsigned char **pp);\nRSA *d2i_RSA_PUBKEY(RSA **a, const unsigned char **pp, long length);\n# endif\n# ifndef OPENSSL_NO_DSA\nint i2d_DSA_PUBKEY(DSA *a, unsigned char **pp);\nDSA *d2i_DSA_PUBKEY(DSA **a, const unsigned char **pp, long length);\n# endif\n# ifndef OPENSSL_NO_EC\nint i2d_EC_PUBKEY(EC_KEY *a, unsigned char **pp);\nEC_KEY *d2i_EC_PUBKEY(EC_KEY **a, const unsigned char **pp, long length);\n# endif\n\nDECLARE_ASN1_FUNCTIONS(X509_SIG)\nDECLARE_ASN1_FUNCTIONS(X509_REQ_INFO)\nDECLARE_ASN1_FUNCTIONS(X509_REQ)\n\nDECLARE_ASN1_FUNCTIONS(X509_ATTRIBUTE)\nX509_ATTRIBUTE *X509_ATTRIBUTE_create(int nid, int atrtype, void *value);\n\nDECLARE_ASN1_FUNCTIONS(X509_EXTENSION)\nDECLARE_ASN1_ENCODE_FUNCTIONS(X509_EXTENSIONS, X509_EXTENSIONS, X509_EXTENSIONS)\n\nDECLARE_ASN1_FUNCTIONS(X509_NAME_ENTRY)\n\nDECLARE_ASN1_FUNCTIONS(X509_NAME)\n\nint X509_NAME_set(X509_NAME **xn, X509_NAME *name);\n\nDECLARE_ASN1_FUNCTIONS(X509_CINF)\n\nDECLARE_ASN1_FUNCTIONS(X509)\nDECLARE_ASN1_FUNCTIONS(X509_CERT_AUX)\n\nDECLARE_ASN1_FUNCTIONS(X509_CERT_PAIR)\n\nint X509_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func,\n                          CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func);\nint X509_set_ex_data(X509 *r, int idx, void *arg);\nvoid *X509_get_ex_data(X509 *r, int idx);\nint i2d_X509_AUX(X509 *a, unsigned char **pp);\nX509 *d2i_X509_AUX(X509 **a, const unsigned char **pp, long length);\n\nint i2d_re_X509_tbs(X509 *x, unsigned char **pp);\n\nvoid X509_get0_signature(ASN1_BIT_STRING **psig, X509_ALGOR **palg,\n                         const X509 *x);\nint X509_get_signature_nid(const X509 *x);\n\nint X509_alias_set1(X509 *x, unsigned char *name, int len);\nint X509_keyid_set1(X509 *x, unsigned char *id, int len);\nunsigned char *X509_alias_get0(X509 *x, int *len);\nunsigned char *X509_keyid_get0(X509 *x, int *len);\nint (*X509_TRUST_set_default(int (*trust) (int, X509 *, int))) (int, X509 *,\n                                                                int);\nint X509_TRUST_set(int *t, int trust);\nint X509_add1_trust_object(X509 *x, ASN1_OBJECT *obj);\nint X509_add1_reject_object(X509 *x, ASN1_OBJECT *obj);\nvoid X509_trust_clear(X509 *x);\nvoid X509_reject_clear(X509 *x);\n\nDECLARE_ASN1_FUNCTIONS(X509_REVOKED)\nDECLARE_ASN1_FUNCTIONS(X509_CRL_INFO)\nDECLARE_ASN1_FUNCTIONS(X509_CRL)\n\nint X509_CRL_add0_revoked(X509_CRL *crl, X509_REVOKED *rev);\nint X509_CRL_get0_by_serial(X509_CRL *crl,\n                            X509_REVOKED **ret, ASN1_INTEGER *serial);\nint X509_CRL_get0_by_cert(X509_CRL *crl, X509_REVOKED **ret, X509 *x);\n\nX509_PKEY *X509_PKEY_new(void);\nvoid X509_PKEY_free(X509_PKEY *a);\nint i2d_X509_PKEY(X509_PKEY *a, unsigned char **pp);\nX509_PKEY *d2i_X509_PKEY(X509_PKEY **a, const unsigned char **pp,\n                         long length);\n\nDECLARE_ASN1_FUNCTIONS(NETSCAPE_SPKI)\nDECLARE_ASN1_FUNCTIONS(NETSCAPE_SPKAC)\nDECLARE_ASN1_FUNCTIONS(NETSCAPE_CERT_SEQUENCE)\n\n# ifndef OPENSSL_NO_EVP\nX509_INFO *X509_INFO_new(void);\nvoid X509_INFO_free(X509_INFO *a);\nchar *X509_NAME_oneline(X509_NAME *a, char *buf, int size);\n\nint ASN1_verify(i2d_of_void *i2d, X509_ALGOR *algor1,\n                ASN1_BIT_STRING *signature, char *data, EVP_PKEY *pkey);\n\nint ASN1_digest(i2d_of_void *i2d, const EVP_MD *type, char *data,\n                unsigned char *md, unsigned int *len);\n\nint ASN1_sign(i2d_of_void *i2d, X509_ALGOR *algor1,\n              X509_ALGOR *algor2, ASN1_BIT_STRING *signature,\n              char *data, EVP_PKEY *pkey, const EVP_MD *type);\n\nint ASN1_item_digest(const ASN1_ITEM *it, const EVP_MD *type, void *data,\n                     unsigned char *md, unsigned int *len);\n\nint ASN1_item_verify(const ASN1_ITEM *it, X509_ALGOR *algor1,\n                     ASN1_BIT_STRING *signature, void *data, EVP_PKEY *pkey);\n\nint ASN1_item_sign(const ASN1_ITEM *it, X509_ALGOR *algor1,\n                   X509_ALGOR *algor2, ASN1_BIT_STRING *signature, void *data,\n                   EVP_PKEY *pkey, const EVP_MD *type);\nint ASN1_item_sign_ctx(const ASN1_ITEM *it, X509_ALGOR *algor1,\n                       X509_ALGOR *algor2, ASN1_BIT_STRING *signature,\n                       void *asn, EVP_MD_CTX *ctx);\n# endif\n\nint X509_set_version(X509 *x, long version);\nint X509_set_serialNumber(X509 *x, ASN1_INTEGER *serial);\nASN1_INTEGER *X509_get_serialNumber(X509 *x);\nint X509_set_issuer_name(X509 *x, X509_NAME *name);\nX509_NAME *X509_get_issuer_name(X509 *a);\nint X509_set_subject_name(X509 *x, X509_NAME *name);\nX509_NAME *X509_get_subject_name(X509 *a);\nint X509_set_notBefore(X509 *x, const ASN1_TIME *tm);\nint X509_set_notAfter(X509 *x, const ASN1_TIME *tm);\nint X509_set_pubkey(X509 *x, EVP_PKEY *pkey);\nEVP_PKEY *X509_get_pubkey(X509 *x);\nASN1_BIT_STRING *X509_get0_pubkey_bitstr(const X509 *x);\nint X509_certificate_type(X509 *x, EVP_PKEY *pubkey /* optional */ );\n\nint X509_REQ_set_version(X509_REQ *x, long version);\nint X509_REQ_set_subject_name(X509_REQ *req, X509_NAME *name);\nint X509_REQ_set_pubkey(X509_REQ *x, EVP_PKEY *pkey);\nEVP_PKEY *X509_REQ_get_pubkey(X509_REQ *req);\nint X509_REQ_extension_nid(int nid);\nint *X509_REQ_get_extension_nids(void);\nvoid X509_REQ_set_extension_nids(int *nids);\nSTACK_OF(X509_EXTENSION) *X509_REQ_get_extensions(X509_REQ *req);\nint X509_REQ_add_extensions_nid(X509_REQ *req, STACK_OF(X509_EXTENSION) *exts,\n                                int nid);\nint X509_REQ_add_extensions(X509_REQ *req, STACK_OF(X509_EXTENSION) *exts);\nint X509_REQ_get_attr_count(const X509_REQ *req);\nint X509_REQ_get_attr_by_NID(const X509_REQ *req, int nid, int lastpos);\nint X509_REQ_get_attr_by_OBJ(const X509_REQ *req, ASN1_OBJECT *obj,\n                             int lastpos);\nX509_ATTRIBUTE *X509_REQ_get_attr(const X509_REQ *req, int loc);\nX509_ATTRIBUTE *X509_REQ_delete_attr(X509_REQ *req, int loc);\nint X509_REQ_add1_attr(X509_REQ *req, X509_ATTRIBUTE *attr);\nint X509_REQ_add1_attr_by_OBJ(X509_REQ *req,\n                              const ASN1_OBJECT *obj, int type,\n                              const unsigned char *bytes, int len);\nint X509_REQ_add1_attr_by_NID(X509_REQ *req,\n                              int nid, int type,\n                              const unsigned char *bytes, int len);\nint X509_REQ_add1_attr_by_txt(X509_REQ *req,\n                              const char *attrname, int type,\n                              const unsigned char *bytes, int len);\n\nint X509_CRL_set_version(X509_CRL *x, long version);\nint X509_CRL_set_issuer_name(X509_CRL *x, X509_NAME *name);\nint X509_CRL_set_lastUpdate(X509_CRL *x, const ASN1_TIME *tm);\nint X509_CRL_set_nextUpdate(X509_CRL *x, const ASN1_TIME *tm);\nint X509_CRL_sort(X509_CRL *crl);\n\nint X509_REVOKED_set_serialNumber(X509_REVOKED *x, ASN1_INTEGER *serial);\nint X509_REVOKED_set_revocationDate(X509_REVOKED *r, ASN1_TIME *tm);\n\nX509_CRL *X509_CRL_diff(X509_CRL *base, X509_CRL *newer,\n                        EVP_PKEY *skey, const EVP_MD *md, unsigned int flags);\n\nint X509_REQ_check_private_key(X509_REQ *x509, EVP_PKEY *pkey);\n\nint X509_check_private_key(X509 *x509, EVP_PKEY *pkey);\nint X509_chain_check_suiteb(int *perror_depth,\n                            X509 *x, STACK_OF(X509) *chain,\n                            unsigned long flags);\nint X509_CRL_check_suiteb(X509_CRL *crl, EVP_PKEY *pk, unsigned long flags);\nSTACK_OF(X509) *X509_chain_up_ref(STACK_OF(X509) *chain);\n\nint X509_issuer_and_serial_cmp(const X509 *a, const X509 *b);\nunsigned long X509_issuer_and_serial_hash(X509 *a);\n\nint X509_issuer_name_cmp(const X509 *a, const X509 *b);\nunsigned long X509_issuer_name_hash(X509 *a);\n\nint X509_subject_name_cmp(const X509 *a, const X509 *b);\nunsigned long X509_subject_name_hash(X509 *x);\n\n# ifndef OPENSSL_NO_MD5\nunsigned long X509_issuer_name_hash_old(X509 *a);\nunsigned long X509_subject_name_hash_old(X509 *x);\n# endif\n\nint X509_cmp(const X509 *a, const X509 *b);\nint X509_NAME_cmp(const X509_NAME *a, const X509_NAME *b);\nunsigned long X509_NAME_hash(X509_NAME *x);\nunsigned long X509_NAME_hash_old(X509_NAME *x);\n\nint X509_CRL_cmp(const X509_CRL *a, const X509_CRL *b);\nint X509_CRL_match(const X509_CRL *a, const X509_CRL *b);\n# ifndef OPENSSL_NO_FP_API\nint X509_print_ex_fp(FILE *bp, X509 *x, unsigned long nmflag,\n                     unsigned long cflag);\nint X509_print_fp(FILE *bp, X509 *x);\nint X509_CRL_print_fp(FILE *bp, X509_CRL *x);\nint X509_REQ_print_fp(FILE *bp, X509_REQ *req);\nint X509_NAME_print_ex_fp(FILE *fp, X509_NAME *nm, int indent,\n                          unsigned long flags);\n# endif\n\n# ifndef OPENSSL_NO_BIO\nint X509_NAME_print(BIO *bp, X509_NAME *name, int obase);\nint X509_NAME_print_ex(BIO *out, X509_NAME *nm, int indent,\n                       unsigned long flags);\nint X509_print_ex(BIO *bp, X509 *x, unsigned long nmflag,\n                  unsigned long cflag);\nint X509_print(BIO *bp, X509 *x);\nint X509_ocspid_print(BIO *bp, X509 *x);\nint X509_CERT_AUX_print(BIO *bp, X509_CERT_AUX *x, int indent);\nint X509_CRL_print(BIO *bp, X509_CRL *x);\nint X509_REQ_print_ex(BIO *bp, X509_REQ *x, unsigned long nmflag,\n                      unsigned long cflag);\nint X509_REQ_print(BIO *bp, X509_REQ *req);\n# endif\n\nint X509_NAME_entry_count(X509_NAME *name);\nint X509_NAME_get_text_by_NID(X509_NAME *name, int nid, char *buf, int len);\nint X509_NAME_get_text_by_OBJ(X509_NAME *name, ASN1_OBJECT *obj,\n                              char *buf, int len);\n\n/*\n * NOTE: you should be passsing -1, not 0 as lastpos.  The functions that use\n * lastpos, search after that position on.\n */\nint X509_NAME_get_index_by_NID(X509_NAME *name, int nid, int lastpos);\nint X509_NAME_get_index_by_OBJ(X509_NAME *name, ASN1_OBJECT *obj,\n                               int lastpos);\nX509_NAME_ENTRY *X509_NAME_get_entry(X509_NAME *name, int loc);\nX509_NAME_ENTRY *X509_NAME_delete_entry(X509_NAME *name, int loc);\nint X509_NAME_add_entry(X509_NAME *name, X509_NAME_ENTRY *ne,\n                        int loc, int set);\nint X509_NAME_add_entry_by_OBJ(X509_NAME *name, ASN1_OBJECT *obj, int type,\n                               unsigned char *bytes, int len, int loc,\n                               int set);\nint X509_NAME_add_entry_by_NID(X509_NAME *name, int nid, int type,\n                               unsigned char *bytes, int len, int loc,\n                               int set);\nX509_NAME_ENTRY *X509_NAME_ENTRY_create_by_txt(X509_NAME_ENTRY **ne,\n                                               const char *field, int type,\n                                               const unsigned char *bytes,\n                                               int len);\nX509_NAME_ENTRY *X509_NAME_ENTRY_create_by_NID(X509_NAME_ENTRY **ne, int nid,\n                                               int type, unsigned char *bytes,\n                                               int len);\nint X509_NAME_add_entry_by_txt(X509_NAME *name, const char *field, int type,\n                               const unsigned char *bytes, int len, int loc,\n                               int set);\nX509_NAME_ENTRY *X509_NAME_ENTRY_create_by_OBJ(X509_NAME_ENTRY **ne,\n                                               ASN1_OBJECT *obj, int type,\n                                               const unsigned char *bytes,\n                                               int len);\nint X509_NAME_ENTRY_set_object(X509_NAME_ENTRY *ne, ASN1_OBJECT *obj);\nint X509_NAME_ENTRY_set_data(X509_NAME_ENTRY *ne, int type,\n                             const unsigned char *bytes, int len);\nASN1_OBJECT *X509_NAME_ENTRY_get_object(X509_NAME_ENTRY *ne);\nASN1_STRING *X509_NAME_ENTRY_get_data(X509_NAME_ENTRY *ne);\n\nint X509v3_get_ext_count(const STACK_OF(X509_EXTENSION) *x);\nint X509v3_get_ext_by_NID(const STACK_OF(X509_EXTENSION) *x,\n                          int nid, int lastpos);\nint X509v3_get_ext_by_OBJ(const STACK_OF(X509_EXTENSION) *x,\n                          ASN1_OBJECT *obj, int lastpos);\nint X509v3_get_ext_by_critical(const STACK_OF(X509_EXTENSION) *x,\n                               int crit, int lastpos);\nX509_EXTENSION *X509v3_get_ext(const STACK_OF(X509_EXTENSION) *x, int loc);\nX509_EXTENSION *X509v3_delete_ext(STACK_OF(X509_EXTENSION) *x, int loc);\nSTACK_OF(X509_EXTENSION) *X509v3_add_ext(STACK_OF(X509_EXTENSION) **x,\n                                         X509_EXTENSION *ex, int loc);\n\nint X509_get_ext_count(X509 *x);\nint X509_get_ext_by_NID(X509 *x, int nid, int lastpos);\nint X509_get_ext_by_OBJ(X509 *x, ASN1_OBJECT *obj, int lastpos);\nint X509_get_ext_by_critical(X509 *x, int crit, int lastpos);\nX509_EXTENSION *X509_get_ext(X509 *x, int loc);\nX509_EXTENSION *X509_delete_ext(X509 *x, int loc);\nint X509_add_ext(X509 *x, X509_EXTENSION *ex, int loc);\nvoid *X509_get_ext_d2i(X509 *x, int nid, int *crit, int *idx);\nint X509_add1_ext_i2d(X509 *x, int nid, void *value, int crit,\n                      unsigned long flags);\n\nint X509_CRL_get_ext_count(X509_CRL *x);\nint X509_CRL_get_ext_by_NID(X509_CRL *x, int nid, int lastpos);\nint X509_CRL_get_ext_by_OBJ(X509_CRL *x, ASN1_OBJECT *obj, int lastpos);\nint X509_CRL_get_ext_by_critical(X509_CRL *x, int crit, int lastpos);\nX509_EXTENSION *X509_CRL_get_ext(X509_CRL *x, int loc);\nX509_EXTENSION *X509_CRL_delete_ext(X509_CRL *x, int loc);\nint X509_CRL_add_ext(X509_CRL *x, X509_EXTENSION *ex, int loc);\nvoid *X509_CRL_get_ext_d2i(X509_CRL *x, int nid, int *crit, int *idx);\nint X509_CRL_add1_ext_i2d(X509_CRL *x, int nid, void *value, int crit,\n                          unsigned long flags);\n\nint X509_REVOKED_get_ext_count(X509_REVOKED *x);\nint X509_REVOKED_get_ext_by_NID(X509_REVOKED *x, int nid, int lastpos);\nint X509_REVOKED_get_ext_by_OBJ(X509_REVOKED *x, ASN1_OBJECT *obj,\n                                int lastpos);\nint X509_REVOKED_get_ext_by_critical(X509_REVOKED *x, int crit, int lastpos);\nX509_EXTENSION *X509_REVOKED_get_ext(X509_REVOKED *x, int loc);\nX509_EXTENSION *X509_REVOKED_delete_ext(X509_REVOKED *x, int loc);\nint X509_REVOKED_add_ext(X509_REVOKED *x, X509_EXTENSION *ex, int loc);\nvoid *X509_REVOKED_get_ext_d2i(X509_REVOKED *x, int nid, int *crit, int *idx);\nint X509_REVOKED_add1_ext_i2d(X509_REVOKED *x, int nid, void *value, int crit,\n                              unsigned long flags);\n\nX509_EXTENSION *X509_EXTENSION_create_by_NID(X509_EXTENSION **ex,\n                                             int nid, int crit,\n                                             ASN1_OCTET_STRING *data);\nX509_EXTENSION *X509_EXTENSION_create_by_OBJ(X509_EXTENSION **ex,\n                                             ASN1_OBJECT *obj, int crit,\n                                             ASN1_OCTET_STRING *data);\nint X509_EXTENSION_set_object(X509_EXTENSION *ex, ASN1_OBJECT *obj);\nint X509_EXTENSION_set_critical(X509_EXTENSION *ex, int crit);\nint X509_EXTENSION_set_data(X509_EXTENSION *ex, ASN1_OCTET_STRING *data);\nASN1_OBJECT *X509_EXTENSION_get_object(X509_EXTENSION *ex);\nASN1_OCTET_STRING *X509_EXTENSION_get_data(X509_EXTENSION *ne);\nint X509_EXTENSION_get_critical(X509_EXTENSION *ex);\n\nint X509at_get_attr_count(const STACK_OF(X509_ATTRIBUTE) *x);\nint X509at_get_attr_by_NID(const STACK_OF(X509_ATTRIBUTE) *x, int nid,\n                           int lastpos);\nint X509at_get_attr_by_OBJ(const STACK_OF(X509_ATTRIBUTE) *sk,\n                           ASN1_OBJECT *obj, int lastpos);\nX509_ATTRIBUTE *X509at_get_attr(const STACK_OF(X509_ATTRIBUTE) *x, int loc);\nX509_ATTRIBUTE *X509at_delete_attr(STACK_OF(X509_ATTRIBUTE) *x, int loc);\nSTACK_OF(X509_ATTRIBUTE) *X509at_add1_attr(STACK_OF(X509_ATTRIBUTE) **x,\n                                           X509_ATTRIBUTE *attr);\nSTACK_OF(X509_ATTRIBUTE) *X509at_add1_attr_by_OBJ(STACK_OF(X509_ATTRIBUTE)\n                                                  **x, const ASN1_OBJECT *obj,\n                                                  int type,\n                                                  const unsigned char *bytes,\n                                                  int len);\nSTACK_OF(X509_ATTRIBUTE) *X509at_add1_attr_by_NID(STACK_OF(X509_ATTRIBUTE)\n                                                  **x, int nid, int type,\n                                                  const unsigned char *bytes,\n                                                  int len);\nSTACK_OF(X509_ATTRIBUTE) *X509at_add1_attr_by_txt(STACK_OF(X509_ATTRIBUTE)\n                                                  **x, const char *attrname,\n                                                  int type,\n                                                  const unsigned char *bytes,\n                                                  int len);\nvoid *X509at_get0_data_by_OBJ(STACK_OF(X509_ATTRIBUTE) *x, ASN1_OBJECT *obj,\n                              int lastpos, int type);\nX509_ATTRIBUTE *X509_ATTRIBUTE_create_by_NID(X509_ATTRIBUTE **attr, int nid,\n                                             int atrtype, const void *data,\n                                             int len);\nX509_ATTRIBUTE *X509_ATTRIBUTE_create_by_OBJ(X509_ATTRIBUTE **attr,\n                                             const ASN1_OBJECT *obj,\n                                             int atrtype, const void *data,\n                                             int len);\nX509_ATTRIBUTE *X509_ATTRIBUTE_create_by_txt(X509_ATTRIBUTE **attr,\n                                             const char *atrname, int type,\n                                             const unsigned char *bytes,\n                                             int len);\nint X509_ATTRIBUTE_set1_object(X509_ATTRIBUTE *attr, const ASN1_OBJECT *obj);\nint X509_ATTRIBUTE_set1_data(X509_ATTRIBUTE *attr, int attrtype,\n                             const void *data, int len);\nvoid *X509_ATTRIBUTE_get0_data(X509_ATTRIBUTE *attr, int idx, int atrtype,\n                               void *data);\nint X509_ATTRIBUTE_count(X509_ATTRIBUTE *attr);\nASN1_OBJECT *X509_ATTRIBUTE_get0_object(X509_ATTRIBUTE *attr);\nASN1_TYPE *X509_ATTRIBUTE_get0_type(X509_ATTRIBUTE *attr, int idx);\n\nint EVP_PKEY_get_attr_count(const EVP_PKEY *key);\nint EVP_PKEY_get_attr_by_NID(const EVP_PKEY *key, int nid, int lastpos);\nint EVP_PKEY_get_attr_by_OBJ(const EVP_PKEY *key, ASN1_OBJECT *obj,\n                             int lastpos);\nX509_ATTRIBUTE *EVP_PKEY_get_attr(const EVP_PKEY *key, int loc);\nX509_ATTRIBUTE *EVP_PKEY_delete_attr(EVP_PKEY *key, int loc);\nint EVP_PKEY_add1_attr(EVP_PKEY *key, X509_ATTRIBUTE *attr);\nint EVP_PKEY_add1_attr_by_OBJ(EVP_PKEY *key,\n                              const ASN1_OBJECT *obj, int type,\n                              const unsigned char *bytes, int len);\nint EVP_PKEY_add1_attr_by_NID(EVP_PKEY *key,\n                              int nid, int type,\n                              const unsigned char *bytes, int len);\nint EVP_PKEY_add1_attr_by_txt(EVP_PKEY *key,\n                              const char *attrname, int type,\n                              const unsigned char *bytes, int len);\n\nint X509_verify_cert(X509_STORE_CTX *ctx);\n\n/* lookup a cert from a X509 STACK */\nX509 *X509_find_by_issuer_and_serial(STACK_OF(X509) *sk, X509_NAME *name,\n                                     ASN1_INTEGER *serial);\nX509 *X509_find_by_subject(STACK_OF(X509) *sk, X509_NAME *name);\n\nDECLARE_ASN1_FUNCTIONS(PBEPARAM)\nDECLARE_ASN1_FUNCTIONS(PBE2PARAM)\nDECLARE_ASN1_FUNCTIONS(PBKDF2PARAM)\n\nint PKCS5_pbe_set0_algor(X509_ALGOR *algor, int alg, int iter,\n                         const unsigned char *salt, int saltlen);\n\nX509_ALGOR *PKCS5_pbe_set(int alg, int iter,\n                          const unsigned char *salt, int saltlen);\nX509_ALGOR *PKCS5_pbe2_set(const EVP_CIPHER *cipher, int iter,\n                           unsigned char *salt, int saltlen);\nX509_ALGOR *PKCS5_pbe2_set_iv(const EVP_CIPHER *cipher, int iter,\n                              unsigned char *salt, int saltlen,\n                              unsigned char *aiv, int prf_nid);\n\nX509_ALGOR *PKCS5_pbkdf2_set(int iter, unsigned char *salt, int saltlen,\n                             int prf_nid, int keylen);\n\n/* PKCS#8 utilities */\n\nDECLARE_ASN1_FUNCTIONS(PKCS8_PRIV_KEY_INFO)\n\nEVP_PKEY *EVP_PKCS82PKEY(PKCS8_PRIV_KEY_INFO *p8);\nPKCS8_PRIV_KEY_INFO *EVP_PKEY2PKCS8(EVP_PKEY *pkey);\nPKCS8_PRIV_KEY_INFO *EVP_PKEY2PKCS8_broken(EVP_PKEY *pkey, int broken);\nPKCS8_PRIV_KEY_INFO *PKCS8_set_broken(PKCS8_PRIV_KEY_INFO *p8, int broken);\n\nint PKCS8_pkey_set0(PKCS8_PRIV_KEY_INFO *priv, ASN1_OBJECT *aobj,\n                    int version, int ptype, void *pval,\n                    unsigned char *penc, int penclen);\nint PKCS8_pkey_get0(ASN1_OBJECT **ppkalg,\n                    const unsigned char **pk, int *ppklen,\n                    X509_ALGOR **pa, PKCS8_PRIV_KEY_INFO *p8);\n\nint X509_PUBKEY_set0_param(X509_PUBKEY *pub, ASN1_OBJECT *aobj,\n                           int ptype, void *pval,\n                           unsigned char *penc, int penclen);\nint X509_PUBKEY_get0_param(ASN1_OBJECT **ppkalg,\n                           const unsigned char **pk, int *ppklen,\n                           X509_ALGOR **pa, X509_PUBKEY *pub);\n\nint X509_check_trust(X509 *x, int id, int flags);\nint X509_TRUST_get_count(void);\nX509_TRUST *X509_TRUST_get0(int idx);\nint X509_TRUST_get_by_id(int id);\nint X509_TRUST_add(int id, int flags, int (*ck) (X509_TRUST *, X509 *, int),\n                   char *name, int arg1, void *arg2);\nvoid X509_TRUST_cleanup(void);\nint X509_TRUST_get_flags(X509_TRUST *xp);\nchar *X509_TRUST_get0_name(X509_TRUST *xp);\nint X509_TRUST_get_trust(X509_TRUST *xp);\n\n/* BEGIN ERROR CODES */\n/*\n * The following lines are auto generated by the script mkerr.pl. Any changes\n * made after this point may be overwritten when the script is next run.\n */\n\nvoid ERR_load_X509_strings(void);\n\n/* Error codes for the X509 functions. */\n\n/* Function codes. */\n# define X509_F_ADD_CERT_DIR                              100\n# define X509_F_BY_FILE_CTRL                              101\n# define X509_F_CHECK_NAME_CONSTRAINTS                    106\n# define X509_F_CHECK_POLICY                              145\n# define X509_F_DIR_CTRL                                  102\n# define X509_F_GET_CERT_BY_SUBJECT                       103\n# define X509_F_NETSCAPE_SPKI_B64_DECODE                  129\n# define X509_F_NETSCAPE_SPKI_B64_ENCODE                  130\n# define X509_F_X509AT_ADD1_ATTR                          135\n# define X509_F_X509V3_ADD_EXT                            104\n# define X509_F_X509_ATTRIBUTE_CREATE_BY_NID              136\n# define X509_F_X509_ATTRIBUTE_CREATE_BY_OBJ              137\n# define X509_F_X509_ATTRIBUTE_CREATE_BY_TXT              140\n# define X509_F_X509_ATTRIBUTE_GET0_DATA                  139\n# define X509_F_X509_ATTRIBUTE_SET1_DATA                  138\n# define X509_F_X509_CHECK_PRIVATE_KEY                    128\n# define X509_F_X509_CRL_DIFF                             105\n# define X509_F_X509_CRL_PRINT_FP                         147\n# define X509_F_X509_EXTENSION_CREATE_BY_NID              108\n# define X509_F_X509_EXTENSION_CREATE_BY_OBJ              109\n# define X509_F_X509_GET_PUBKEY_PARAMETERS                110\n# define X509_F_X509_LOAD_CERT_CRL_FILE                   132\n# define X509_F_X509_LOAD_CERT_FILE                       111\n# define X509_F_X509_LOAD_CRL_FILE                        112\n# define X509_F_X509_NAME_ADD_ENTRY                       113\n# define X509_F_X509_NAME_ENTRY_CREATE_BY_NID             114\n# define X509_F_X509_NAME_ENTRY_CREATE_BY_TXT             131\n# define X509_F_X509_NAME_ENTRY_SET_OBJECT                115\n# define X509_F_X509_NAME_ONELINE                         116\n# define X509_F_X509_NAME_PRINT                           117\n# define X509_F_X509_PRINT_EX_FP                          118\n# define X509_F_X509_PUBKEY_GET                           119\n# define X509_F_X509_PUBKEY_SET                           120\n# define X509_F_X509_REQ_CHECK_PRIVATE_KEY                144\n# define X509_F_X509_REQ_PRINT_EX                         121\n# define X509_F_X509_REQ_PRINT_FP                         122\n# define X509_F_X509_REQ_TO_X509                          123\n# define X509_F_X509_STORE_ADD_CERT                       124\n# define X509_F_X509_STORE_ADD_CRL                        125\n# define X509_F_X509_STORE_CTX_GET1_ISSUER                146\n# define X509_F_X509_STORE_CTX_INIT                       143\n# define X509_F_X509_STORE_CTX_NEW                        142\n# define X509_F_X509_STORE_CTX_PURPOSE_INHERIT            134\n# define X509_F_X509_TO_X509_REQ                          126\n# define X509_F_X509_TRUST_ADD                            133\n# define X509_F_X509_TRUST_SET                            141\n# define X509_F_X509_VERIFY_CERT                          127\n\n/* Reason codes. */\n# define X509_R_AKID_MISMATCH                             110\n# define X509_R_BAD_X509_FILETYPE                         100\n# define X509_R_BASE64_DECODE_ERROR                       118\n# define X509_R_CANT_CHECK_DH_KEY                         114\n# define X509_R_CERT_ALREADY_IN_HASH_TABLE                101\n# define X509_R_CRL_ALREADY_DELTA                         127\n# define X509_R_CRL_VERIFY_FAILURE                        131\n# define X509_R_ERR_ASN1_LIB                              102\n# define X509_R_IDP_MISMATCH                              128\n# define X509_R_INVALID_DIRECTORY                         113\n# define X509_R_INVALID_FIELD_NAME                        119\n# define X509_R_INVALID_TRUST                             123\n# define X509_R_ISSUER_MISMATCH                           129\n# define X509_R_KEY_TYPE_MISMATCH                         115\n# define X509_R_KEY_VALUES_MISMATCH                       116\n# define X509_R_LOADING_CERT_DIR                          103\n# define X509_R_LOADING_DEFAULTS                          104\n# define X509_R_METHOD_NOT_SUPPORTED                      124\n# define X509_R_NAME_TOO_LONG                             134\n# define X509_R_NEWER_CRL_NOT_NEWER                       132\n# define X509_R_NO_CERT_SET_FOR_US_TO_VERIFY              105\n# define X509_R_NO_CRL_NUMBER                             130\n# define X509_R_PUBLIC_KEY_DECODE_ERROR                   125\n# define X509_R_PUBLIC_KEY_ENCODE_ERROR                   126\n# define X509_R_SHOULD_RETRY                              106\n# define X509_R_UNABLE_TO_FIND_PARAMETERS_IN_CHAIN        107\n# define X509_R_UNABLE_TO_GET_CERTS_PUBLIC_KEY            108\n# define X509_R_UNKNOWN_KEY_TYPE                          117\n# define X509_R_UNKNOWN_NID                               109\n# define X509_R_UNKNOWN_PURPOSE_ID                        121\n# define X509_R_UNKNOWN_TRUST_ID                          120\n# define X509_R_UNSUPPORTED_ALGORITHM                     111\n# define X509_R_WRONG_LOOKUP_TYPE                         112\n# define X509_R_WRONG_TYPE                                122\n\n# ifdef  __cplusplus\n}\n# endif\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/arm64/include/openssl/x509_vfy.h",
    "content": "/* crypto/x509/x509_vfy.h */\n/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)\n * All rights reserved.\n *\n * This package is an SSL implementation written\n * by Eric Young (eay@cryptsoft.com).\n * The implementation was written so as to conform with Netscapes SSL.\n *\n * This library is free for commercial and non-commercial use as long as\n * the following conditions are aheared to.  The following conditions\n * apply to all code found in this distribution, be it the RC4, RSA,\n * lhash, DES, etc., code; not just the SSL code.  The SSL documentation\n * included with this distribution is covered by the same copyright terms\n * except that the holder is Tim Hudson (tjh@cryptsoft.com).\n *\n * Copyright remains Eric Young's, and as such any Copyright notices in\n * the code are not to be removed.\n * If this package is used in a product, Eric Young should be given attribution\n * as the author of the parts of the library used.\n * This can be in the form of a textual message at program startup or\n * in documentation (online or textual) provided with the package.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the copyright\n *    notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in the\n *    documentation and/or other materials provided with the distribution.\n * 3. All advertising materials mentioning features or use of this software\n *    must display the following acknowledgement:\n *    \"This product includes cryptographic software written by\n *     Eric Young (eay@cryptsoft.com)\"\n *    The word 'cryptographic' can be left out if the rouines from the library\n *    being used are not cryptographic related :-).\n * 4. If you include any Windows specific code (or a derivative thereof) from\n *    the apps directory (application code) you must include an acknowledgement:\n *    \"This product includes software written by Tim Hudson (tjh@cryptsoft.com)\"\n *\n * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n * SUCH DAMAGE.\n *\n * The licence and distribution terms for any publically available version or\n * derivative of this code cannot be changed.  i.e. this code cannot simply be\n * copied and put under another distribution licence\n * [including the GNU Public Licence.]\n */\n\n#ifndef HEADER_X509_H\n# include <openssl/x509.h>\n/*\n * openssl/x509.h ends up #include-ing this file at about the only\n * appropriate moment.\n */\n#endif\n\n#ifndef HEADER_X509_VFY_H\n# define HEADER_X509_VFY_H\n\n# include <openssl/opensslconf.h>\n# ifndef OPENSSL_NO_LHASH\n#  include <openssl/lhash.h>\n# endif\n# include <openssl/bio.h>\n# include <openssl/crypto.h>\n# include <openssl/symhacks.h>\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n# if 0\n/* Outer object */\ntypedef struct x509_hash_dir_st {\n    int num_dirs;\n    char **dirs;\n    int *dirs_type;\n    int num_dirs_alloced;\n} X509_HASH_DIR_CTX;\n# endif\n\ntypedef struct x509_file_st {\n    int num_paths;              /* number of paths to files or directories */\n    int num_alloced;\n    char **paths;               /* the list of paths or directories */\n    int *path_type;\n} X509_CERT_FILE_CTX;\n\n/*******************************/\n/*-\nSSL_CTX -> X509_STORE\n                -> X509_LOOKUP\n                        ->X509_LOOKUP_METHOD\n                -> X509_LOOKUP\n                        ->X509_LOOKUP_METHOD\n\nSSL     -> X509_STORE_CTX\n                ->X509_STORE\n\nThe X509_STORE holds the tables etc for verification stuff.\nA X509_STORE_CTX is used while validating a single certificate.\nThe X509_STORE has X509_LOOKUPs for looking up certs.\nThe X509_STORE then calls a function to actually verify the\ncertificate chain.\n*/\n\n# define X509_LU_RETRY           -1\n# define X509_LU_FAIL            0\n# define X509_LU_X509            1\n# define X509_LU_CRL             2\n# define X509_LU_PKEY            3\n\ntypedef struct x509_object_st {\n    /* one of the above types */\n    int type;\n    union {\n        char *ptr;\n        X509 *x509;\n        X509_CRL *crl;\n        EVP_PKEY *pkey;\n    } data;\n} X509_OBJECT;\n\ntypedef struct x509_lookup_st X509_LOOKUP;\n\nDECLARE_STACK_OF(X509_LOOKUP)\nDECLARE_STACK_OF(X509_OBJECT)\n\n/* This is a static that defines the function interface */\ntypedef struct x509_lookup_method_st {\n    const char *name;\n    int (*new_item) (X509_LOOKUP *ctx);\n    void (*free) (X509_LOOKUP *ctx);\n    int (*init) (X509_LOOKUP *ctx);\n    int (*shutdown) (X509_LOOKUP *ctx);\n    int (*ctrl) (X509_LOOKUP *ctx, int cmd, const char *argc, long argl,\n                 char **ret);\n    int (*get_by_subject) (X509_LOOKUP *ctx, int type, X509_NAME *name,\n                           X509_OBJECT *ret);\n    int (*get_by_issuer_serial) (X509_LOOKUP *ctx, int type, X509_NAME *name,\n                                 ASN1_INTEGER *serial, X509_OBJECT *ret);\n    int (*get_by_fingerprint) (X509_LOOKUP *ctx, int type,\n                               unsigned char *bytes, int len,\n                               X509_OBJECT *ret);\n    int (*get_by_alias) (X509_LOOKUP *ctx, int type, char *str, int len,\n                         X509_OBJECT *ret);\n} X509_LOOKUP_METHOD;\n\ntypedef struct X509_VERIFY_PARAM_ID_st X509_VERIFY_PARAM_ID;\n\n/*\n * This structure hold all parameters associated with a verify operation by\n * including an X509_VERIFY_PARAM structure in related structures the\n * parameters used can be customized\n */\n\ntypedef struct X509_VERIFY_PARAM_st {\n    char *name;\n    time_t check_time;          /* Time to use */\n    unsigned long inh_flags;    /* Inheritance flags */\n    unsigned long flags;        /* Various verify flags */\n    int purpose;                /* purpose to check untrusted certificates */\n    int trust;                  /* trust setting to check */\n    int depth;                  /* Verify depth */\n    STACK_OF(ASN1_OBJECT) *policies; /* Permissible policies */\n    X509_VERIFY_PARAM_ID *id;   /* opaque ID data */\n} X509_VERIFY_PARAM;\n\nDECLARE_STACK_OF(X509_VERIFY_PARAM)\n\n/*\n * This is used to hold everything.  It is used for all certificate\n * validation.  Once we have a certificate chain, the 'verify' function is\n * then called to actually check the cert chain.\n */\nstruct x509_store_st {\n    /* The following is a cache of trusted certs */\n    int cache;                  /* if true, stash any hits */\n    STACK_OF(X509_OBJECT) *objs; /* Cache of all objects */\n    /* These are external lookup methods */\n    STACK_OF(X509_LOOKUP) *get_cert_methods;\n    X509_VERIFY_PARAM *param;\n    /* Callbacks for various operations */\n    /* called to verify a certificate */\n    int (*verify) (X509_STORE_CTX *ctx);\n    /* error callback */\n    int (*verify_cb) (int ok, X509_STORE_CTX *ctx);\n    /* get issuers cert from ctx */\n    int (*get_issuer) (X509 **issuer, X509_STORE_CTX *ctx, X509 *x);\n    /* check issued */\n    int (*check_issued) (X509_STORE_CTX *ctx, X509 *x, X509 *issuer);\n    /* Check revocation status of chain */\n    int (*check_revocation) (X509_STORE_CTX *ctx);\n    /* retrieve CRL */\n    int (*get_crl) (X509_STORE_CTX *ctx, X509_CRL **crl, X509 *x);\n    /* Check CRL validity */\n    int (*check_crl) (X509_STORE_CTX *ctx, X509_CRL *crl);\n    /* Check certificate against CRL */\n    int (*cert_crl) (X509_STORE_CTX *ctx, X509_CRL *crl, X509 *x);\n    STACK_OF(X509) *(*lookup_certs) (X509_STORE_CTX *ctx, X509_NAME *nm);\n    STACK_OF(X509_CRL) *(*lookup_crls) (X509_STORE_CTX *ctx, X509_NAME *nm);\n    int (*cleanup) (X509_STORE_CTX *ctx);\n    CRYPTO_EX_DATA ex_data;\n    int references;\n} /* X509_STORE */ ;\n\nint X509_STORE_set_depth(X509_STORE *store, int depth);\n\n# define X509_STORE_set_verify_cb_func(ctx,func) ((ctx)->verify_cb=(func))\n# define X509_STORE_set_verify_func(ctx,func)    ((ctx)->verify=(func))\n\n/* This is the functions plus an instance of the local variables. */\nstruct x509_lookup_st {\n    int init;                   /* have we been started */\n    int skip;                   /* don't use us. */\n    X509_LOOKUP_METHOD *method; /* the functions */\n    char *method_data;          /* method data */\n    X509_STORE *store_ctx;      /* who owns us */\n} /* X509_LOOKUP */ ;\n\n/*\n * This is a used when verifying cert chains.  Since the gathering of the\n * cert chain can take some time (and have to be 'retried', this needs to be\n * kept and passed around.\n */\nstruct x509_store_ctx_st {      /* X509_STORE_CTX */\n    X509_STORE *ctx;\n    /* used when looking up certs */\n    int current_method;\n    /* The following are set by the caller */\n    /* The cert to check */\n    X509 *cert;\n    /* chain of X509s - untrusted - passed in */\n    STACK_OF(X509) *untrusted;\n    /* set of CRLs passed in */\n    STACK_OF(X509_CRL) *crls;\n    X509_VERIFY_PARAM *param;\n    /* Other info for use with get_issuer() */\n    void *other_ctx;\n    /* Callbacks for various operations */\n    /* called to verify a certificate */\n    int (*verify) (X509_STORE_CTX *ctx);\n    /* error callback */\n    int (*verify_cb) (int ok, X509_STORE_CTX *ctx);\n    /* get issuers cert from ctx */\n    int (*get_issuer) (X509 **issuer, X509_STORE_CTX *ctx, X509 *x);\n    /* check issued */\n    int (*check_issued) (X509_STORE_CTX *ctx, X509 *x, X509 *issuer);\n    /* Check revocation status of chain */\n    int (*check_revocation) (X509_STORE_CTX *ctx);\n    /* retrieve CRL */\n    int (*get_crl) (X509_STORE_CTX *ctx, X509_CRL **crl, X509 *x);\n    /* Check CRL validity */\n    int (*check_crl) (X509_STORE_CTX *ctx, X509_CRL *crl);\n    /* Check certificate against CRL */\n    int (*cert_crl) (X509_STORE_CTX *ctx, X509_CRL *crl, X509 *x);\n    int (*check_policy) (X509_STORE_CTX *ctx);\n    STACK_OF(X509) *(*lookup_certs) (X509_STORE_CTX *ctx, X509_NAME *nm);\n    STACK_OF(X509_CRL) *(*lookup_crls) (X509_STORE_CTX *ctx, X509_NAME *nm);\n    int (*cleanup) (X509_STORE_CTX *ctx);\n    /* The following is built up */\n    /* if 0, rebuild chain */\n    int valid;\n    /* index of last untrusted cert */\n    int last_untrusted;\n    /* chain of X509s - built up and trusted */\n    STACK_OF(X509) *chain;\n    /* Valid policy tree */\n    X509_POLICY_TREE *tree;\n    /* Require explicit policy value */\n    int explicit_policy;\n    /* When something goes wrong, this is why */\n    int error_depth;\n    int error;\n    X509 *current_cert;\n    /* cert currently being tested as valid issuer */\n    X509 *current_issuer;\n    /* current CRL */\n    X509_CRL *current_crl;\n    /* score of current CRL */\n    int current_crl_score;\n    /* Reason mask */\n    unsigned int current_reasons;\n    /* For CRL path validation: parent context */\n    X509_STORE_CTX *parent;\n    CRYPTO_EX_DATA ex_data;\n} /* X509_STORE_CTX */ ;\n\nvoid X509_STORE_CTX_set_depth(X509_STORE_CTX *ctx, int depth);\n\n# define X509_STORE_CTX_set_app_data(ctx,data) \\\n        X509_STORE_CTX_set_ex_data(ctx,0,data)\n# define X509_STORE_CTX_get_app_data(ctx) \\\n        X509_STORE_CTX_get_ex_data(ctx,0)\n\n# define X509_L_FILE_LOAD        1\n# define X509_L_ADD_DIR          2\n\n# define X509_LOOKUP_load_file(x,name,type) \\\n                X509_LOOKUP_ctrl((x),X509_L_FILE_LOAD,(name),(long)(type),NULL)\n\n# define X509_LOOKUP_add_dir(x,name,type) \\\n                X509_LOOKUP_ctrl((x),X509_L_ADD_DIR,(name),(long)(type),NULL)\n\n# define         X509_V_OK                                       0\n# define         X509_V_ERR_UNSPECIFIED                          1\n\n# define         X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT            2\n# define         X509_V_ERR_UNABLE_TO_GET_CRL                    3\n# define         X509_V_ERR_UNABLE_TO_DECRYPT_CERT_SIGNATURE     4\n# define         X509_V_ERR_UNABLE_TO_DECRYPT_CRL_SIGNATURE      5\n# define         X509_V_ERR_UNABLE_TO_DECODE_ISSUER_PUBLIC_KEY   6\n# define         X509_V_ERR_CERT_SIGNATURE_FAILURE               7\n# define         X509_V_ERR_CRL_SIGNATURE_FAILURE                8\n# define         X509_V_ERR_CERT_NOT_YET_VALID                   9\n# define         X509_V_ERR_CERT_HAS_EXPIRED                     10\n# define         X509_V_ERR_CRL_NOT_YET_VALID                    11\n# define         X509_V_ERR_CRL_HAS_EXPIRED                      12\n# define         X509_V_ERR_ERROR_IN_CERT_NOT_BEFORE_FIELD       13\n# define         X509_V_ERR_ERROR_IN_CERT_NOT_AFTER_FIELD        14\n# define         X509_V_ERR_ERROR_IN_CRL_LAST_UPDATE_FIELD       15\n# define         X509_V_ERR_ERROR_IN_CRL_NEXT_UPDATE_FIELD       16\n# define         X509_V_ERR_OUT_OF_MEM                           17\n# define         X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT          18\n# define         X509_V_ERR_SELF_SIGNED_CERT_IN_CHAIN            19\n# define         X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY    20\n# define         X509_V_ERR_UNABLE_TO_VERIFY_LEAF_SIGNATURE      21\n# define         X509_V_ERR_CERT_CHAIN_TOO_LONG                  22\n# define         X509_V_ERR_CERT_REVOKED                         23\n# define         X509_V_ERR_INVALID_CA                           24\n# define         X509_V_ERR_PATH_LENGTH_EXCEEDED                 25\n# define         X509_V_ERR_INVALID_PURPOSE                      26\n# define         X509_V_ERR_CERT_UNTRUSTED                       27\n# define         X509_V_ERR_CERT_REJECTED                        28\n/* These are 'informational' when looking for issuer cert */\n# define         X509_V_ERR_SUBJECT_ISSUER_MISMATCH              29\n# define         X509_V_ERR_AKID_SKID_MISMATCH                   30\n# define         X509_V_ERR_AKID_ISSUER_SERIAL_MISMATCH          31\n# define         X509_V_ERR_KEYUSAGE_NO_CERTSIGN                 32\n\n# define         X509_V_ERR_UNABLE_TO_GET_CRL_ISSUER             33\n# define         X509_V_ERR_UNHANDLED_CRITICAL_EXTENSION         34\n# define         X509_V_ERR_KEYUSAGE_NO_CRL_SIGN                 35\n# define         X509_V_ERR_UNHANDLED_CRITICAL_CRL_EXTENSION     36\n# define         X509_V_ERR_INVALID_NON_CA                       37\n# define         X509_V_ERR_PROXY_PATH_LENGTH_EXCEEDED           38\n# define         X509_V_ERR_KEYUSAGE_NO_DIGITAL_SIGNATURE        39\n# define         X509_V_ERR_PROXY_CERTIFICATES_NOT_ALLOWED       40\n\n# define         X509_V_ERR_INVALID_EXTENSION                    41\n# define         X509_V_ERR_INVALID_POLICY_EXTENSION             42\n# define         X509_V_ERR_NO_EXPLICIT_POLICY                   43\n# define         X509_V_ERR_DIFFERENT_CRL_SCOPE                  44\n# define         X509_V_ERR_UNSUPPORTED_EXTENSION_FEATURE        45\n\n# define         X509_V_ERR_UNNESTED_RESOURCE                    46\n\n# define         X509_V_ERR_PERMITTED_VIOLATION                  47\n# define         X509_V_ERR_EXCLUDED_VIOLATION                   48\n# define         X509_V_ERR_SUBTREE_MINMAX                       49\n# define         X509_V_ERR_APPLICATION_VERIFICATION             50\n# define         X509_V_ERR_UNSUPPORTED_CONSTRAINT_TYPE          51\n# define         X509_V_ERR_UNSUPPORTED_CONSTRAINT_SYNTAX        52\n# define         X509_V_ERR_UNSUPPORTED_NAME_SYNTAX              53\n# define         X509_V_ERR_CRL_PATH_VALIDATION_ERROR            54\n\n/* Suite B mode algorithm violation */\n# define         X509_V_ERR_SUITE_B_INVALID_VERSION              56\n# define         X509_V_ERR_SUITE_B_INVALID_ALGORITHM            57\n# define         X509_V_ERR_SUITE_B_INVALID_CURVE                58\n# define         X509_V_ERR_SUITE_B_INVALID_SIGNATURE_ALGORITHM  59\n# define         X509_V_ERR_SUITE_B_LOS_NOT_ALLOWED              60\n# define         X509_V_ERR_SUITE_B_CANNOT_SIGN_P_384_WITH_P_256 61\n\n/* Host, email and IP check errors */\n# define         X509_V_ERR_HOSTNAME_MISMATCH                    62\n# define         X509_V_ERR_EMAIL_MISMATCH                       63\n# define         X509_V_ERR_IP_ADDRESS_MISMATCH                  64\n\n/* Caller error */\n# define         X509_V_ERR_INVALID_CALL                         65\n/* Issuer lookup error */\n# define         X509_V_ERR_STORE_LOOKUP                         66\n\n# define         X509_V_ERR_PROXY_SUBJECT_NAME_VIOLATION         67\n\n/* Certificate verify flags */\n\n/* Send issuer+subject checks to verify_cb */\n# define X509_V_FLAG_CB_ISSUER_CHECK             0x1\n/* Use check time instead of current time */\n# define X509_V_FLAG_USE_CHECK_TIME              0x2\n/* Lookup CRLs */\n# define X509_V_FLAG_CRL_CHECK                   0x4\n/* Lookup CRLs for whole chain */\n# define X509_V_FLAG_CRL_CHECK_ALL               0x8\n/* Ignore unhandled critical extensions */\n# define X509_V_FLAG_IGNORE_CRITICAL             0x10\n/* Disable workarounds for broken certificates */\n# define X509_V_FLAG_X509_STRICT                 0x20\n/* Enable proxy certificate validation */\n# define X509_V_FLAG_ALLOW_PROXY_CERTS           0x40\n/* Enable policy checking */\n# define X509_V_FLAG_POLICY_CHECK                0x80\n/* Policy variable require-explicit-policy */\n# define X509_V_FLAG_EXPLICIT_POLICY             0x100\n/* Policy variable inhibit-any-policy */\n# define X509_V_FLAG_INHIBIT_ANY                 0x200\n/* Policy variable inhibit-policy-mapping */\n# define X509_V_FLAG_INHIBIT_MAP                 0x400\n/* Notify callback that policy is OK */\n# define X509_V_FLAG_NOTIFY_POLICY               0x800\n/* Extended CRL features such as indirect CRLs, alternate CRL signing keys */\n# define X509_V_FLAG_EXTENDED_CRL_SUPPORT        0x1000\n/* Delta CRL support */\n# define X509_V_FLAG_USE_DELTAS                  0x2000\n/* Check selfsigned CA signature */\n# define X509_V_FLAG_CHECK_SS_SIGNATURE          0x4000\n/* Use trusted store first */\n# define X509_V_FLAG_TRUSTED_FIRST               0x8000\n/* Suite B 128 bit only mode: not normally used */\n# define X509_V_FLAG_SUITEB_128_LOS_ONLY         0x10000\n/* Suite B 192 bit only mode */\n# define X509_V_FLAG_SUITEB_192_LOS              0x20000\n/* Suite B 128 bit mode allowing 192 bit algorithms */\n# define X509_V_FLAG_SUITEB_128_LOS              0x30000\n\n/* Allow partial chains if at least one certificate is in trusted store */\n# define X509_V_FLAG_PARTIAL_CHAIN               0x80000\n/*\n * If the initial chain is not trusted, do not attempt to build an alternative\n * chain. Alternate chain checking was introduced in 1.0.2b. Setting this flag\n * will force the behaviour to match that of previous versions.\n */\n# define X509_V_FLAG_NO_ALT_CHAINS               0x100000\n\n# define X509_VP_FLAG_DEFAULT                    0x1\n# define X509_VP_FLAG_OVERWRITE                  0x2\n# define X509_VP_FLAG_RESET_FLAGS                0x4\n# define X509_VP_FLAG_LOCKED                     0x8\n# define X509_VP_FLAG_ONCE                       0x10\n\n/* Internal use: mask of policy related options */\n# define X509_V_FLAG_POLICY_MASK (X509_V_FLAG_POLICY_CHECK \\\n                                | X509_V_FLAG_EXPLICIT_POLICY \\\n                                | X509_V_FLAG_INHIBIT_ANY \\\n                                | X509_V_FLAG_INHIBIT_MAP)\n\nint X509_OBJECT_idx_by_subject(STACK_OF(X509_OBJECT) *h, int type,\n                               X509_NAME *name);\nX509_OBJECT *X509_OBJECT_retrieve_by_subject(STACK_OF(X509_OBJECT) *h,\n                                             int type, X509_NAME *name);\nX509_OBJECT *X509_OBJECT_retrieve_match(STACK_OF(X509_OBJECT) *h,\n                                        X509_OBJECT *x);\nvoid X509_OBJECT_up_ref_count(X509_OBJECT *a);\nvoid X509_OBJECT_free_contents(X509_OBJECT *a);\nX509_STORE *X509_STORE_new(void);\nvoid X509_STORE_free(X509_STORE *v);\n\nSTACK_OF(X509) *X509_STORE_get1_certs(X509_STORE_CTX *st, X509_NAME *nm);\nSTACK_OF(X509_CRL) *X509_STORE_get1_crls(X509_STORE_CTX *st, X509_NAME *nm);\nint X509_STORE_set_flags(X509_STORE *ctx, unsigned long flags);\nint X509_STORE_set_purpose(X509_STORE *ctx, int purpose);\nint X509_STORE_set_trust(X509_STORE *ctx, int trust);\nint X509_STORE_set1_param(X509_STORE *ctx, X509_VERIFY_PARAM *pm);\n\nvoid X509_STORE_set_verify_cb(X509_STORE *ctx,\n                              int (*verify_cb) (int, X509_STORE_CTX *));\n\nvoid X509_STORE_set_lookup_crls_cb(X509_STORE *ctx,\n                                   STACK_OF(X509_CRL) *(*cb) (X509_STORE_CTX\n                                                              *ctx,\n                                                              X509_NAME *nm));\n\nX509_STORE_CTX *X509_STORE_CTX_new(void);\n\nint X509_STORE_CTX_get1_issuer(X509 **issuer, X509_STORE_CTX *ctx, X509 *x);\n\nvoid X509_STORE_CTX_free(X509_STORE_CTX *ctx);\nint X509_STORE_CTX_init(X509_STORE_CTX *ctx, X509_STORE *store,\n                        X509 *x509, STACK_OF(X509) *chain);\nvoid X509_STORE_CTX_trusted_stack(X509_STORE_CTX *ctx, STACK_OF(X509) *sk);\nvoid X509_STORE_CTX_cleanup(X509_STORE_CTX *ctx);\n\nX509_STORE *X509_STORE_CTX_get0_store(X509_STORE_CTX *ctx);\n\nX509_LOOKUP *X509_STORE_add_lookup(X509_STORE *v, X509_LOOKUP_METHOD *m);\n\nX509_LOOKUP_METHOD *X509_LOOKUP_hash_dir(void);\nX509_LOOKUP_METHOD *X509_LOOKUP_file(void);\n\nint X509_STORE_add_cert(X509_STORE *ctx, X509 *x);\nint X509_STORE_add_crl(X509_STORE *ctx, X509_CRL *x);\n\nint X509_STORE_get_by_subject(X509_STORE_CTX *vs, int type, X509_NAME *name,\n                              X509_OBJECT *ret);\n\nint X509_LOOKUP_ctrl(X509_LOOKUP *ctx, int cmd, const char *argc,\n                     long argl, char **ret);\n\n# ifndef OPENSSL_NO_STDIO\nint X509_load_cert_file(X509_LOOKUP *ctx, const char *file, int type);\nint X509_load_crl_file(X509_LOOKUP *ctx, const char *file, int type);\nint X509_load_cert_crl_file(X509_LOOKUP *ctx, const char *file, int type);\n# endif\n\nX509_LOOKUP *X509_LOOKUP_new(X509_LOOKUP_METHOD *method);\nvoid X509_LOOKUP_free(X509_LOOKUP *ctx);\nint X509_LOOKUP_init(X509_LOOKUP *ctx);\nint X509_LOOKUP_by_subject(X509_LOOKUP *ctx, int type, X509_NAME *name,\n                           X509_OBJECT *ret);\nint X509_LOOKUP_by_issuer_serial(X509_LOOKUP *ctx, int type, X509_NAME *name,\n                                 ASN1_INTEGER *serial, X509_OBJECT *ret);\nint X509_LOOKUP_by_fingerprint(X509_LOOKUP *ctx, int type,\n                               unsigned char *bytes, int len,\n                               X509_OBJECT *ret);\nint X509_LOOKUP_by_alias(X509_LOOKUP *ctx, int type, char *str, int len,\n                         X509_OBJECT *ret);\nint X509_LOOKUP_shutdown(X509_LOOKUP *ctx);\n\n# ifndef OPENSSL_NO_STDIO\nint X509_STORE_load_locations(X509_STORE *ctx,\n                              const char *file, const char *dir);\nint X509_STORE_set_default_paths(X509_STORE *ctx);\n# endif\n\nint X509_STORE_CTX_get_ex_new_index(long argl, void *argp,\n                                    CRYPTO_EX_new *new_func,\n                                    CRYPTO_EX_dup *dup_func,\n                                    CRYPTO_EX_free *free_func);\nint X509_STORE_CTX_set_ex_data(X509_STORE_CTX *ctx, int idx, void *data);\nvoid *X509_STORE_CTX_get_ex_data(X509_STORE_CTX *ctx, int idx);\nint X509_STORE_CTX_get_error(X509_STORE_CTX *ctx);\nvoid X509_STORE_CTX_set_error(X509_STORE_CTX *ctx, int s);\nint X509_STORE_CTX_get_error_depth(X509_STORE_CTX *ctx);\nX509 *X509_STORE_CTX_get_current_cert(X509_STORE_CTX *ctx);\nX509 *X509_STORE_CTX_get0_current_issuer(X509_STORE_CTX *ctx);\nX509_CRL *X509_STORE_CTX_get0_current_crl(X509_STORE_CTX *ctx);\nX509_STORE_CTX *X509_STORE_CTX_get0_parent_ctx(X509_STORE_CTX *ctx);\nSTACK_OF(X509) *X509_STORE_CTX_get_chain(X509_STORE_CTX *ctx);\nSTACK_OF(X509) *X509_STORE_CTX_get1_chain(X509_STORE_CTX *ctx);\nvoid X509_STORE_CTX_set_cert(X509_STORE_CTX *c, X509 *x);\nvoid X509_STORE_CTX_set_chain(X509_STORE_CTX *c, STACK_OF(X509) *sk);\nvoid X509_STORE_CTX_set0_crls(X509_STORE_CTX *c, STACK_OF(X509_CRL) *sk);\nint X509_STORE_CTX_set_purpose(X509_STORE_CTX *ctx, int purpose);\nint X509_STORE_CTX_set_trust(X509_STORE_CTX *ctx, int trust);\nint X509_STORE_CTX_purpose_inherit(X509_STORE_CTX *ctx, int def_purpose,\n                                   int purpose, int trust);\nvoid X509_STORE_CTX_set_flags(X509_STORE_CTX *ctx, unsigned long flags);\nvoid X509_STORE_CTX_set_time(X509_STORE_CTX *ctx, unsigned long flags,\n                             time_t t);\nvoid X509_STORE_CTX_set_verify_cb(X509_STORE_CTX *ctx,\n                                  int (*verify_cb) (int, X509_STORE_CTX *));\n\nX509_POLICY_TREE *X509_STORE_CTX_get0_policy_tree(X509_STORE_CTX *ctx);\nint X509_STORE_CTX_get_explicit_policy(X509_STORE_CTX *ctx);\n\nX509_VERIFY_PARAM *X509_STORE_CTX_get0_param(X509_STORE_CTX *ctx);\nvoid X509_STORE_CTX_set0_param(X509_STORE_CTX *ctx, X509_VERIFY_PARAM *param);\nint X509_STORE_CTX_set_default(X509_STORE_CTX *ctx, const char *name);\n\n/* X509_VERIFY_PARAM functions */\n\nX509_VERIFY_PARAM *X509_VERIFY_PARAM_new(void);\nvoid X509_VERIFY_PARAM_free(X509_VERIFY_PARAM *param);\nint X509_VERIFY_PARAM_inherit(X509_VERIFY_PARAM *to,\n                              const X509_VERIFY_PARAM *from);\nint X509_VERIFY_PARAM_set1(X509_VERIFY_PARAM *to,\n                           const X509_VERIFY_PARAM *from);\nint X509_VERIFY_PARAM_set1_name(X509_VERIFY_PARAM *param, const char *name);\nint X509_VERIFY_PARAM_set_flags(X509_VERIFY_PARAM *param,\n                                unsigned long flags);\nint X509_VERIFY_PARAM_clear_flags(X509_VERIFY_PARAM *param,\n                                  unsigned long flags);\nunsigned long X509_VERIFY_PARAM_get_flags(X509_VERIFY_PARAM *param);\nint X509_VERIFY_PARAM_set_purpose(X509_VERIFY_PARAM *param, int purpose);\nint X509_VERIFY_PARAM_set_trust(X509_VERIFY_PARAM *param, int trust);\nvoid X509_VERIFY_PARAM_set_depth(X509_VERIFY_PARAM *param, int depth);\nvoid X509_VERIFY_PARAM_set_time(X509_VERIFY_PARAM *param, time_t t);\nint X509_VERIFY_PARAM_add0_policy(X509_VERIFY_PARAM *param,\n                                  ASN1_OBJECT *policy);\nint X509_VERIFY_PARAM_set1_policies(X509_VERIFY_PARAM *param,\n                                    STACK_OF(ASN1_OBJECT) *policies);\n\nint X509_VERIFY_PARAM_set1_host(X509_VERIFY_PARAM *param,\n                                const char *name, size_t namelen);\nint X509_VERIFY_PARAM_add1_host(X509_VERIFY_PARAM *param,\n                                const char *name, size_t namelen);\nvoid X509_VERIFY_PARAM_set_hostflags(X509_VERIFY_PARAM *param,\n                                     unsigned int flags);\nchar *X509_VERIFY_PARAM_get0_peername(X509_VERIFY_PARAM *);\nint X509_VERIFY_PARAM_set1_email(X509_VERIFY_PARAM *param,\n                                 const char *email, size_t emaillen);\nint X509_VERIFY_PARAM_set1_ip(X509_VERIFY_PARAM *param,\n                              const unsigned char *ip, size_t iplen);\nint X509_VERIFY_PARAM_set1_ip_asc(X509_VERIFY_PARAM *param,\n                                  const char *ipasc);\n\nint X509_VERIFY_PARAM_get_depth(const X509_VERIFY_PARAM *param);\nconst char *X509_VERIFY_PARAM_get0_name(const X509_VERIFY_PARAM *param);\n\nint X509_VERIFY_PARAM_add0_table(X509_VERIFY_PARAM *param);\nint X509_VERIFY_PARAM_get_count(void);\nconst X509_VERIFY_PARAM *X509_VERIFY_PARAM_get0(int id);\nconst X509_VERIFY_PARAM *X509_VERIFY_PARAM_lookup(const char *name);\nvoid X509_VERIFY_PARAM_table_cleanup(void);\n\nint X509_policy_check(X509_POLICY_TREE **ptree, int *pexplicit_policy,\n                      STACK_OF(X509) *certs,\n                      STACK_OF(ASN1_OBJECT) *policy_oids, unsigned int flags);\n\nvoid X509_policy_tree_free(X509_POLICY_TREE *tree);\n\nint X509_policy_tree_level_count(const X509_POLICY_TREE *tree);\nX509_POLICY_LEVEL *X509_policy_tree_get0_level(const X509_POLICY_TREE *tree,\n                                               int i);\n\nSTACK_OF(X509_POLICY_NODE) *X509_policy_tree_get0_policies(const\n                                                           X509_POLICY_TREE\n                                                           *tree);\n\nSTACK_OF(X509_POLICY_NODE) *X509_policy_tree_get0_user_policies(const\n                                                                X509_POLICY_TREE\n                                                                *tree);\n\nint X509_policy_level_node_count(X509_POLICY_LEVEL *level);\n\nX509_POLICY_NODE *X509_policy_level_get0_node(X509_POLICY_LEVEL *level,\n                                              int i);\n\nconst ASN1_OBJECT *X509_policy_node_get0_policy(const X509_POLICY_NODE *node);\n\nSTACK_OF(POLICYQUALINFO) *X509_policy_node_get0_qualifiers(const\n                                                           X509_POLICY_NODE\n                                                           *node);\nconst X509_POLICY_NODE *X509_policy_node_get0_parent(const X509_POLICY_NODE\n                                                     *node);\n\n#ifdef  __cplusplus\n}\n#endif\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/arm64/include/openssl/x509v3.h",
    "content": "/* x509v3.h */\n/*\n * Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL project\n * 1999.\n */\n/* ====================================================================\n * Copyright (c) 1999-2004 The OpenSSL Project.  All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n *\n * 1. Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n *\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in\n *    the documentation and/or other materials provided with the\n *    distribution.\n *\n * 3. All advertising materials mentioning features or use of this\n *    software must display the following acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)\"\n *\n * 4. The names \"OpenSSL Toolkit\" and \"OpenSSL Project\" must not be used to\n *    endorse or promote products derived from this software without\n *    prior written permission. For written permission, please contact\n *    licensing@OpenSSL.org.\n *\n * 5. Products derived from this software may not be called \"OpenSSL\"\n *    nor may \"OpenSSL\" appear in their names without prior written\n *    permission of the OpenSSL Project.\n *\n * 6. Redistributions of any form whatsoever must retain the following\n *    acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)\"\n *\n * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY\n * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\n * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR\n * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\n * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,\n * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED\n * OF THE POSSIBILITY OF SUCH DAMAGE.\n * ====================================================================\n *\n * This product includes cryptographic software written by Eric Young\n * (eay@cryptsoft.com).  This product includes software written by Tim\n * Hudson (tjh@cryptsoft.com).\n *\n */\n#ifndef HEADER_X509V3_H\n# define HEADER_X509V3_H\n\n# include <openssl/bio.h>\n# include <openssl/x509.h>\n# include <openssl/conf.h>\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n# ifdef OPENSSL_SYS_WIN32\n/* Under Win32 these are defined in wincrypt.h */\n#  undef X509_NAME\n#  undef X509_CERT_PAIR\n#  undef X509_EXTENSIONS\n# endif\n\n/* Forward reference */\nstruct v3_ext_method;\nstruct v3_ext_ctx;\n\n/* Useful typedefs */\n\ntypedef void *(*X509V3_EXT_NEW)(void);\ntypedef void (*X509V3_EXT_FREE) (void *);\ntypedef void *(*X509V3_EXT_D2I)(void *, const unsigned char **, long);\ntypedef int (*X509V3_EXT_I2D) (void *, unsigned char **);\ntypedef STACK_OF(CONF_VALUE) *\n    (*X509V3_EXT_I2V) (const struct v3_ext_method *method, void *ext,\n                       STACK_OF(CONF_VALUE) *extlist);\ntypedef void *(*X509V3_EXT_V2I)(const struct v3_ext_method *method,\n                                struct v3_ext_ctx *ctx,\n                                STACK_OF(CONF_VALUE) *values);\ntypedef char *(*X509V3_EXT_I2S)(const struct v3_ext_method *method,\n                                void *ext);\ntypedef void *(*X509V3_EXT_S2I)(const struct v3_ext_method *method,\n                                struct v3_ext_ctx *ctx, const char *str);\ntypedef int (*X509V3_EXT_I2R) (const struct v3_ext_method *method, void *ext,\n                               BIO *out, int indent);\ntypedef void *(*X509V3_EXT_R2I)(const struct v3_ext_method *method,\n                                struct v3_ext_ctx *ctx, const char *str);\n\n/* V3 extension structure */\n\nstruct v3_ext_method {\n    int ext_nid;\n    int ext_flags;\n/* If this is set the following four fields are ignored */\n    ASN1_ITEM_EXP *it;\n/* Old style ASN1 calls */\n    X509V3_EXT_NEW ext_new;\n    X509V3_EXT_FREE ext_free;\n    X509V3_EXT_D2I d2i;\n    X509V3_EXT_I2D i2d;\n/* The following pair is used for string extensions */\n    X509V3_EXT_I2S i2s;\n    X509V3_EXT_S2I s2i;\n/* The following pair is used for multi-valued extensions */\n    X509V3_EXT_I2V i2v;\n    X509V3_EXT_V2I v2i;\n/* The following are used for raw extensions */\n    X509V3_EXT_I2R i2r;\n    X509V3_EXT_R2I r2i;\n    void *usr_data;             /* Any extension specific data */\n};\n\ntypedef struct X509V3_CONF_METHOD_st {\n    char *(*get_string) (void *db, char *section, char *value);\n    STACK_OF(CONF_VALUE) *(*get_section) (void *db, char *section);\n    void (*free_string) (void *db, char *string);\n    void (*free_section) (void *db, STACK_OF(CONF_VALUE) *section);\n} X509V3_CONF_METHOD;\n\n/* Context specific info */\nstruct v3_ext_ctx {\n# define CTX_TEST 0x1\n    int flags;\n    X509 *issuer_cert;\n    X509 *subject_cert;\n    X509_REQ *subject_req;\n    X509_CRL *crl;\n    X509V3_CONF_METHOD *db_meth;\n    void *db;\n/* Maybe more here */\n};\n\ntypedef struct v3_ext_method X509V3_EXT_METHOD;\n\nDECLARE_STACK_OF(X509V3_EXT_METHOD)\n\n/* ext_flags values */\n# define X509V3_EXT_DYNAMIC      0x1\n# define X509V3_EXT_CTX_DEP      0x2\n# define X509V3_EXT_MULTILINE    0x4\n\ntypedef BIT_STRING_BITNAME ENUMERATED_NAMES;\n\ntypedef struct BASIC_CONSTRAINTS_st {\n    int ca;\n    ASN1_INTEGER *pathlen;\n} BASIC_CONSTRAINTS;\n\ntypedef struct PKEY_USAGE_PERIOD_st {\n    ASN1_GENERALIZEDTIME *notBefore;\n    ASN1_GENERALIZEDTIME *notAfter;\n} PKEY_USAGE_PERIOD;\n\ntypedef struct otherName_st {\n    ASN1_OBJECT *type_id;\n    ASN1_TYPE *value;\n} OTHERNAME;\n\ntypedef struct EDIPartyName_st {\n    ASN1_STRING *nameAssigner;\n    ASN1_STRING *partyName;\n} EDIPARTYNAME;\n\ntypedef struct GENERAL_NAME_st {\n# define GEN_OTHERNAME   0\n# define GEN_EMAIL       1\n# define GEN_DNS         2\n# define GEN_X400        3\n# define GEN_DIRNAME     4\n# define GEN_EDIPARTY    5\n# define GEN_URI         6\n# define GEN_IPADD       7\n# define GEN_RID         8\n    int type;\n    union {\n        char *ptr;\n        OTHERNAME *otherName;   /* otherName */\n        ASN1_IA5STRING *rfc822Name;\n        ASN1_IA5STRING *dNSName;\n        ASN1_TYPE *x400Address;\n        X509_NAME *directoryName;\n        EDIPARTYNAME *ediPartyName;\n        ASN1_IA5STRING *uniformResourceIdentifier;\n        ASN1_OCTET_STRING *iPAddress;\n        ASN1_OBJECT *registeredID;\n        /* Old names */\n        ASN1_OCTET_STRING *ip;  /* iPAddress */\n        X509_NAME *dirn;        /* dirn */\n        ASN1_IA5STRING *ia5;    /* rfc822Name, dNSName,\n                                 * uniformResourceIdentifier */\n        ASN1_OBJECT *rid;       /* registeredID */\n        ASN1_TYPE *other;       /* x400Address */\n    } d;\n} GENERAL_NAME;\n\ntypedef STACK_OF(GENERAL_NAME) GENERAL_NAMES;\n\ntypedef struct ACCESS_DESCRIPTION_st {\n    ASN1_OBJECT *method;\n    GENERAL_NAME *location;\n} ACCESS_DESCRIPTION;\n\ntypedef STACK_OF(ACCESS_DESCRIPTION) AUTHORITY_INFO_ACCESS;\n\ntypedef STACK_OF(ASN1_OBJECT) EXTENDED_KEY_USAGE;\n\nDECLARE_STACK_OF(GENERAL_NAME)\nDECLARE_ASN1_SET_OF(GENERAL_NAME)\n\nDECLARE_STACK_OF(ACCESS_DESCRIPTION)\nDECLARE_ASN1_SET_OF(ACCESS_DESCRIPTION)\n\ntypedef struct DIST_POINT_NAME_st {\n    int type;\n    union {\n        GENERAL_NAMES *fullname;\n        STACK_OF(X509_NAME_ENTRY) *relativename;\n    } name;\n/* If relativename then this contains the full distribution point name */\n    X509_NAME *dpname;\n} DIST_POINT_NAME;\n/* All existing reasons */\n# define CRLDP_ALL_REASONS       0x807f\n\n# define CRL_REASON_NONE                         -1\n# define CRL_REASON_UNSPECIFIED                  0\n# define CRL_REASON_KEY_COMPROMISE               1\n# define CRL_REASON_CA_COMPROMISE                2\n# define CRL_REASON_AFFILIATION_CHANGED          3\n# define CRL_REASON_SUPERSEDED                   4\n# define CRL_REASON_CESSATION_OF_OPERATION       5\n# define CRL_REASON_CERTIFICATE_HOLD             6\n# define CRL_REASON_REMOVE_FROM_CRL              8\n# define CRL_REASON_PRIVILEGE_WITHDRAWN          9\n# define CRL_REASON_AA_COMPROMISE                10\n\nstruct DIST_POINT_st {\n    DIST_POINT_NAME *distpoint;\n    ASN1_BIT_STRING *reasons;\n    GENERAL_NAMES *CRLissuer;\n    int dp_reasons;\n};\n\ntypedef STACK_OF(DIST_POINT) CRL_DIST_POINTS;\n\nDECLARE_STACK_OF(DIST_POINT)\nDECLARE_ASN1_SET_OF(DIST_POINT)\n\nstruct AUTHORITY_KEYID_st {\n    ASN1_OCTET_STRING *keyid;\n    GENERAL_NAMES *issuer;\n    ASN1_INTEGER *serial;\n};\n\n/* Strong extranet structures */\n\ntypedef struct SXNET_ID_st {\n    ASN1_INTEGER *zone;\n    ASN1_OCTET_STRING *user;\n} SXNETID;\n\nDECLARE_STACK_OF(SXNETID)\nDECLARE_ASN1_SET_OF(SXNETID)\n\ntypedef struct SXNET_st {\n    ASN1_INTEGER *version;\n    STACK_OF(SXNETID) *ids;\n} SXNET;\n\ntypedef struct NOTICEREF_st {\n    ASN1_STRING *organization;\n    STACK_OF(ASN1_INTEGER) *noticenos;\n} NOTICEREF;\n\ntypedef struct USERNOTICE_st {\n    NOTICEREF *noticeref;\n    ASN1_STRING *exptext;\n} USERNOTICE;\n\ntypedef struct POLICYQUALINFO_st {\n    ASN1_OBJECT *pqualid;\n    union {\n        ASN1_IA5STRING *cpsuri;\n        USERNOTICE *usernotice;\n        ASN1_TYPE *other;\n    } d;\n} POLICYQUALINFO;\n\nDECLARE_STACK_OF(POLICYQUALINFO)\nDECLARE_ASN1_SET_OF(POLICYQUALINFO)\n\ntypedef struct POLICYINFO_st {\n    ASN1_OBJECT *policyid;\n    STACK_OF(POLICYQUALINFO) *qualifiers;\n} POLICYINFO;\n\ntypedef STACK_OF(POLICYINFO) CERTIFICATEPOLICIES;\n\nDECLARE_STACK_OF(POLICYINFO)\nDECLARE_ASN1_SET_OF(POLICYINFO)\n\ntypedef struct POLICY_MAPPING_st {\n    ASN1_OBJECT *issuerDomainPolicy;\n    ASN1_OBJECT *subjectDomainPolicy;\n} POLICY_MAPPING;\n\nDECLARE_STACK_OF(POLICY_MAPPING)\n\ntypedef STACK_OF(POLICY_MAPPING) POLICY_MAPPINGS;\n\ntypedef struct GENERAL_SUBTREE_st {\n    GENERAL_NAME *base;\n    ASN1_INTEGER *minimum;\n    ASN1_INTEGER *maximum;\n} GENERAL_SUBTREE;\n\nDECLARE_STACK_OF(GENERAL_SUBTREE)\n\nstruct NAME_CONSTRAINTS_st {\n    STACK_OF(GENERAL_SUBTREE) *permittedSubtrees;\n    STACK_OF(GENERAL_SUBTREE) *excludedSubtrees;\n};\n\ntypedef struct POLICY_CONSTRAINTS_st {\n    ASN1_INTEGER *requireExplicitPolicy;\n    ASN1_INTEGER *inhibitPolicyMapping;\n} POLICY_CONSTRAINTS;\n\n/* Proxy certificate structures, see RFC 3820 */\ntypedef struct PROXY_POLICY_st {\n    ASN1_OBJECT *policyLanguage;\n    ASN1_OCTET_STRING *policy;\n} PROXY_POLICY;\n\ntypedef struct PROXY_CERT_INFO_EXTENSION_st {\n    ASN1_INTEGER *pcPathLengthConstraint;\n    PROXY_POLICY *proxyPolicy;\n} PROXY_CERT_INFO_EXTENSION;\n\nDECLARE_ASN1_FUNCTIONS(PROXY_POLICY)\nDECLARE_ASN1_FUNCTIONS(PROXY_CERT_INFO_EXTENSION)\n\nstruct ISSUING_DIST_POINT_st {\n    DIST_POINT_NAME *distpoint;\n    int onlyuser;\n    int onlyCA;\n    ASN1_BIT_STRING *onlysomereasons;\n    int indirectCRL;\n    int onlyattr;\n};\n\n/* Values in idp_flags field */\n/* IDP present */\n# define IDP_PRESENT     0x1\n/* IDP values inconsistent */\n# define IDP_INVALID     0x2\n/* onlyuser true */\n# define IDP_ONLYUSER    0x4\n/* onlyCA true */\n# define IDP_ONLYCA      0x8\n/* onlyattr true */\n# define IDP_ONLYATTR    0x10\n/* indirectCRL true */\n# define IDP_INDIRECT    0x20\n/* onlysomereasons present */\n# define IDP_REASONS     0x40\n\n# define X509V3_conf_err(val) ERR_add_error_data(6, \"section:\", val->section, \\\n\",name:\", val->name, \",value:\", val->value);\n\n# define X509V3_set_ctx_test(ctx) \\\n                        X509V3_set_ctx(ctx, NULL, NULL, NULL, NULL, CTX_TEST)\n# define X509V3_set_ctx_nodb(ctx) (ctx)->db = NULL;\n\n# define EXT_BITSTRING(nid, table) { nid, 0, ASN1_ITEM_ref(ASN1_BIT_STRING), \\\n                        0,0,0,0, \\\n                        0,0, \\\n                        (X509V3_EXT_I2V)i2v_ASN1_BIT_STRING, \\\n                        (X509V3_EXT_V2I)v2i_ASN1_BIT_STRING, \\\n                        NULL, NULL, \\\n                        table}\n\n# define EXT_IA5STRING(nid) { nid, 0, ASN1_ITEM_ref(ASN1_IA5STRING), \\\n                        0,0,0,0, \\\n                        (X509V3_EXT_I2S)i2s_ASN1_IA5STRING, \\\n                        (X509V3_EXT_S2I)s2i_ASN1_IA5STRING, \\\n                        0,0,0,0, \\\n                        NULL}\n\n# define EXT_END { -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}\n\n/* X509_PURPOSE stuff */\n\n# define EXFLAG_BCONS            0x1\n# define EXFLAG_KUSAGE           0x2\n# define EXFLAG_XKUSAGE          0x4\n# define EXFLAG_NSCERT           0x8\n\n# define EXFLAG_CA               0x10\n/* Really self issued not necessarily self signed */\n# define EXFLAG_SI               0x20\n# define EXFLAG_V1               0x40\n# define EXFLAG_INVALID          0x80\n# define EXFLAG_SET              0x100\n# define EXFLAG_CRITICAL         0x200\n# define EXFLAG_PROXY            0x400\n\n# define EXFLAG_INVALID_POLICY   0x800\n# define EXFLAG_FRESHEST         0x1000\n/* Self signed */\n# define EXFLAG_SS               0x2000\n\n# define KU_DIGITAL_SIGNATURE    0x0080\n# define KU_NON_REPUDIATION      0x0040\n# define KU_KEY_ENCIPHERMENT     0x0020\n# define KU_DATA_ENCIPHERMENT    0x0010\n# define KU_KEY_AGREEMENT        0x0008\n# define KU_KEY_CERT_SIGN        0x0004\n# define KU_CRL_SIGN             0x0002\n# define KU_ENCIPHER_ONLY        0x0001\n# define KU_DECIPHER_ONLY        0x8000\n\n# define NS_SSL_CLIENT           0x80\n# define NS_SSL_SERVER           0x40\n# define NS_SMIME                0x20\n# define NS_OBJSIGN              0x10\n# define NS_SSL_CA               0x04\n# define NS_SMIME_CA             0x02\n# define NS_OBJSIGN_CA           0x01\n# define NS_ANY_CA               (NS_SSL_CA|NS_SMIME_CA|NS_OBJSIGN_CA)\n\n# define XKU_SSL_SERVER          0x1\n# define XKU_SSL_CLIENT          0x2\n# define XKU_SMIME               0x4\n# define XKU_CODE_SIGN           0x8\n# define XKU_SGC                 0x10\n# define XKU_OCSP_SIGN           0x20\n# define XKU_TIMESTAMP           0x40\n# define XKU_DVCS                0x80\n# define XKU_ANYEKU              0x100\n\n# define X509_PURPOSE_DYNAMIC    0x1\n# define X509_PURPOSE_DYNAMIC_NAME       0x2\n\ntypedef struct x509_purpose_st {\n    int purpose;\n    int trust;                  /* Default trust ID */\n    int flags;\n    int (*check_purpose) (const struct x509_purpose_st *, const X509 *, int);\n    char *name;\n    char *sname;\n    void *usr_data;\n} X509_PURPOSE;\n\n# define X509_PURPOSE_SSL_CLIENT         1\n# define X509_PURPOSE_SSL_SERVER         2\n# define X509_PURPOSE_NS_SSL_SERVER      3\n# define X509_PURPOSE_SMIME_SIGN         4\n# define X509_PURPOSE_SMIME_ENCRYPT      5\n# define X509_PURPOSE_CRL_SIGN           6\n# define X509_PURPOSE_ANY                7\n# define X509_PURPOSE_OCSP_HELPER        8\n# define X509_PURPOSE_TIMESTAMP_SIGN     9\n\n# define X509_PURPOSE_MIN                1\n# define X509_PURPOSE_MAX                9\n\n/* Flags for X509V3_EXT_print() */\n\n# define X509V3_EXT_UNKNOWN_MASK         (0xfL << 16)\n/* Return error for unknown extensions */\n# define X509V3_EXT_DEFAULT              0\n/* Print error for unknown extensions */\n# define X509V3_EXT_ERROR_UNKNOWN        (1L << 16)\n/* ASN1 parse unknown extensions */\n# define X509V3_EXT_PARSE_UNKNOWN        (2L << 16)\n/* BIO_dump unknown extensions */\n# define X509V3_EXT_DUMP_UNKNOWN         (3L << 16)\n\n/* Flags for X509V3_add1_i2d */\n\n# define X509V3_ADD_OP_MASK              0xfL\n# define X509V3_ADD_DEFAULT              0L\n# define X509V3_ADD_APPEND               1L\n# define X509V3_ADD_REPLACE              2L\n# define X509V3_ADD_REPLACE_EXISTING     3L\n# define X509V3_ADD_KEEP_EXISTING        4L\n# define X509V3_ADD_DELETE               5L\n# define X509V3_ADD_SILENT               0x10\n\nDECLARE_STACK_OF(X509_PURPOSE)\n\nDECLARE_ASN1_FUNCTIONS(BASIC_CONSTRAINTS)\n\nDECLARE_ASN1_FUNCTIONS(SXNET)\nDECLARE_ASN1_FUNCTIONS(SXNETID)\n\nint SXNET_add_id_asc(SXNET **psx, char *zone, char *user, int userlen);\nint SXNET_add_id_ulong(SXNET **psx, unsigned long lzone, char *user,\n                       int userlen);\nint SXNET_add_id_INTEGER(SXNET **psx, ASN1_INTEGER *izone, char *user,\n                         int userlen);\n\nASN1_OCTET_STRING *SXNET_get_id_asc(SXNET *sx, char *zone);\nASN1_OCTET_STRING *SXNET_get_id_ulong(SXNET *sx, unsigned long lzone);\nASN1_OCTET_STRING *SXNET_get_id_INTEGER(SXNET *sx, ASN1_INTEGER *zone);\n\nDECLARE_ASN1_FUNCTIONS(AUTHORITY_KEYID)\n\nDECLARE_ASN1_FUNCTIONS(PKEY_USAGE_PERIOD)\n\nDECLARE_ASN1_FUNCTIONS(GENERAL_NAME)\nGENERAL_NAME *GENERAL_NAME_dup(GENERAL_NAME *a);\nint GENERAL_NAME_cmp(GENERAL_NAME *a, GENERAL_NAME *b);\n\nASN1_BIT_STRING *v2i_ASN1_BIT_STRING(X509V3_EXT_METHOD *method,\n                                     X509V3_CTX *ctx,\n                                     STACK_OF(CONF_VALUE) *nval);\nSTACK_OF(CONF_VALUE) *i2v_ASN1_BIT_STRING(X509V3_EXT_METHOD *method,\n                                          ASN1_BIT_STRING *bits,\n                                          STACK_OF(CONF_VALUE) *extlist);\n\nSTACK_OF(CONF_VALUE) *i2v_GENERAL_NAME(X509V3_EXT_METHOD *method,\n                                       GENERAL_NAME *gen,\n                                       STACK_OF(CONF_VALUE) *ret);\nint GENERAL_NAME_print(BIO *out, GENERAL_NAME *gen);\n\nDECLARE_ASN1_FUNCTIONS(GENERAL_NAMES)\n\nSTACK_OF(CONF_VALUE) *i2v_GENERAL_NAMES(X509V3_EXT_METHOD *method,\n                                        GENERAL_NAMES *gen,\n                                        STACK_OF(CONF_VALUE) *extlist);\nGENERAL_NAMES *v2i_GENERAL_NAMES(const X509V3_EXT_METHOD *method,\n                                 X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *nval);\n\nDECLARE_ASN1_FUNCTIONS(OTHERNAME)\nDECLARE_ASN1_FUNCTIONS(EDIPARTYNAME)\nint OTHERNAME_cmp(OTHERNAME *a, OTHERNAME *b);\nvoid GENERAL_NAME_set0_value(GENERAL_NAME *a, int type, void *value);\nvoid *GENERAL_NAME_get0_value(GENERAL_NAME *a, int *ptype);\nint GENERAL_NAME_set0_othername(GENERAL_NAME *gen,\n                                ASN1_OBJECT *oid, ASN1_TYPE *value);\nint GENERAL_NAME_get0_otherName(GENERAL_NAME *gen,\n                                ASN1_OBJECT **poid, ASN1_TYPE **pvalue);\n\nchar *i2s_ASN1_OCTET_STRING(X509V3_EXT_METHOD *method,\n                            ASN1_OCTET_STRING *ia5);\nASN1_OCTET_STRING *s2i_ASN1_OCTET_STRING(X509V3_EXT_METHOD *method,\n                                         X509V3_CTX *ctx, char *str);\n\nDECLARE_ASN1_FUNCTIONS(EXTENDED_KEY_USAGE)\nint i2a_ACCESS_DESCRIPTION(BIO *bp, ACCESS_DESCRIPTION *a);\n\nDECLARE_ASN1_FUNCTIONS(CERTIFICATEPOLICIES)\nDECLARE_ASN1_FUNCTIONS(POLICYINFO)\nDECLARE_ASN1_FUNCTIONS(POLICYQUALINFO)\nDECLARE_ASN1_FUNCTIONS(USERNOTICE)\nDECLARE_ASN1_FUNCTIONS(NOTICEREF)\n\nDECLARE_ASN1_FUNCTIONS(CRL_DIST_POINTS)\nDECLARE_ASN1_FUNCTIONS(DIST_POINT)\nDECLARE_ASN1_FUNCTIONS(DIST_POINT_NAME)\nDECLARE_ASN1_FUNCTIONS(ISSUING_DIST_POINT)\n\nint DIST_POINT_set_dpname(DIST_POINT_NAME *dpn, X509_NAME *iname);\n\nint NAME_CONSTRAINTS_check(X509 *x, NAME_CONSTRAINTS *nc);\n\nDECLARE_ASN1_FUNCTIONS(ACCESS_DESCRIPTION)\nDECLARE_ASN1_FUNCTIONS(AUTHORITY_INFO_ACCESS)\n\nDECLARE_ASN1_ITEM(POLICY_MAPPING)\nDECLARE_ASN1_ALLOC_FUNCTIONS(POLICY_MAPPING)\nDECLARE_ASN1_ITEM(POLICY_MAPPINGS)\n\nDECLARE_ASN1_ITEM(GENERAL_SUBTREE)\nDECLARE_ASN1_ALLOC_FUNCTIONS(GENERAL_SUBTREE)\n\nDECLARE_ASN1_ITEM(NAME_CONSTRAINTS)\nDECLARE_ASN1_ALLOC_FUNCTIONS(NAME_CONSTRAINTS)\n\nDECLARE_ASN1_ALLOC_FUNCTIONS(POLICY_CONSTRAINTS)\nDECLARE_ASN1_ITEM(POLICY_CONSTRAINTS)\n\nGENERAL_NAME *a2i_GENERAL_NAME(GENERAL_NAME *out,\n                               const X509V3_EXT_METHOD *method,\n                               X509V3_CTX *ctx, int gen_type, char *value,\n                               int is_nc);\n\n# ifdef HEADER_CONF_H\nGENERAL_NAME *v2i_GENERAL_NAME(const X509V3_EXT_METHOD *method,\n                               X509V3_CTX *ctx, CONF_VALUE *cnf);\nGENERAL_NAME *v2i_GENERAL_NAME_ex(GENERAL_NAME *out,\n                                  const X509V3_EXT_METHOD *method,\n                                  X509V3_CTX *ctx, CONF_VALUE *cnf,\n                                  int is_nc);\nvoid X509V3_conf_free(CONF_VALUE *val);\n\nX509_EXTENSION *X509V3_EXT_nconf_nid(CONF *conf, X509V3_CTX *ctx, int ext_nid,\n                                     char *value);\nX509_EXTENSION *X509V3_EXT_nconf(CONF *conf, X509V3_CTX *ctx, char *name,\n                                 char *value);\nint X509V3_EXT_add_nconf_sk(CONF *conf, X509V3_CTX *ctx, char *section,\n                            STACK_OF(X509_EXTENSION) **sk);\nint X509V3_EXT_add_nconf(CONF *conf, X509V3_CTX *ctx, char *section,\n                         X509 *cert);\nint X509V3_EXT_REQ_add_nconf(CONF *conf, X509V3_CTX *ctx, char *section,\n                             X509_REQ *req);\nint X509V3_EXT_CRL_add_nconf(CONF *conf, X509V3_CTX *ctx, char *section,\n                             X509_CRL *crl);\n\nX509_EXTENSION *X509V3_EXT_conf_nid(LHASH_OF(CONF_VALUE) *conf,\n                                    X509V3_CTX *ctx, int ext_nid,\n                                    char *value);\nX509_EXTENSION *X509V3_EXT_conf(LHASH_OF(CONF_VALUE) *conf, X509V3_CTX *ctx,\n                                char *name, char *value);\nint X509V3_EXT_add_conf(LHASH_OF(CONF_VALUE) *conf, X509V3_CTX *ctx,\n                        char *section, X509 *cert);\nint X509V3_EXT_REQ_add_conf(LHASH_OF(CONF_VALUE) *conf, X509V3_CTX *ctx,\n                            char *section, X509_REQ *req);\nint X509V3_EXT_CRL_add_conf(LHASH_OF(CONF_VALUE) *conf, X509V3_CTX *ctx,\n                            char *section, X509_CRL *crl);\n\nint X509V3_add_value_bool_nf(char *name, int asn1_bool,\n                             STACK_OF(CONF_VALUE) **extlist);\nint X509V3_get_value_bool(CONF_VALUE *value, int *asn1_bool);\nint X509V3_get_value_int(CONF_VALUE *value, ASN1_INTEGER **aint);\nvoid X509V3_set_nconf(X509V3_CTX *ctx, CONF *conf);\nvoid X509V3_set_conf_lhash(X509V3_CTX *ctx, LHASH_OF(CONF_VALUE) *lhash);\n# endif\n\nchar *X509V3_get_string(X509V3_CTX *ctx, char *name, char *section);\nSTACK_OF(CONF_VALUE) *X509V3_get_section(X509V3_CTX *ctx, char *section);\nvoid X509V3_string_free(X509V3_CTX *ctx, char *str);\nvoid X509V3_section_free(X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *section);\nvoid X509V3_set_ctx(X509V3_CTX *ctx, X509 *issuer, X509 *subject,\n                    X509_REQ *req, X509_CRL *crl, int flags);\n\nint X509V3_add_value(const char *name, const char *value,\n                     STACK_OF(CONF_VALUE) **extlist);\nint X509V3_add_value_uchar(const char *name, const unsigned char *value,\n                           STACK_OF(CONF_VALUE) **extlist);\nint X509V3_add_value_bool(const char *name, int asn1_bool,\n                          STACK_OF(CONF_VALUE) **extlist);\nint X509V3_add_value_int(const char *name, ASN1_INTEGER *aint,\n                         STACK_OF(CONF_VALUE) **extlist);\nchar *i2s_ASN1_INTEGER(X509V3_EXT_METHOD *meth, ASN1_INTEGER *aint);\nASN1_INTEGER *s2i_ASN1_INTEGER(X509V3_EXT_METHOD *meth, char *value);\nchar *i2s_ASN1_ENUMERATED(X509V3_EXT_METHOD *meth, ASN1_ENUMERATED *aint);\nchar *i2s_ASN1_ENUMERATED_TABLE(X509V3_EXT_METHOD *meth,\n                                ASN1_ENUMERATED *aint);\nint X509V3_EXT_add(X509V3_EXT_METHOD *ext);\nint X509V3_EXT_add_list(X509V3_EXT_METHOD *extlist);\nint X509V3_EXT_add_alias(int nid_to, int nid_from);\nvoid X509V3_EXT_cleanup(void);\n\nconst X509V3_EXT_METHOD *X509V3_EXT_get(X509_EXTENSION *ext);\nconst X509V3_EXT_METHOD *X509V3_EXT_get_nid(int nid);\nint X509V3_add_standard_extensions(void);\nSTACK_OF(CONF_VALUE) *X509V3_parse_list(const char *line);\nvoid *X509V3_EXT_d2i(X509_EXTENSION *ext);\nvoid *X509V3_get_d2i(STACK_OF(X509_EXTENSION) *x, int nid, int *crit,\n                     int *idx);\nint X509V3_EXT_free(int nid, void *ext_data);\n\nX509_EXTENSION *X509V3_EXT_i2d(int ext_nid, int crit, void *ext_struc);\nint X509V3_add1_i2d(STACK_OF(X509_EXTENSION) **x, int nid, void *value,\n                    int crit, unsigned long flags);\n\nchar *hex_to_string(const unsigned char *buffer, long len);\nunsigned char *string_to_hex(const char *str, long *len);\nint name_cmp(const char *name, const char *cmp);\n\nvoid X509V3_EXT_val_prn(BIO *out, STACK_OF(CONF_VALUE) *val, int indent,\n                        int ml);\nint X509V3_EXT_print(BIO *out, X509_EXTENSION *ext, unsigned long flag,\n                     int indent);\nint X509V3_EXT_print_fp(FILE *out, X509_EXTENSION *ext, int flag, int indent);\n\nint X509V3_extensions_print(BIO *out, char *title,\n                            STACK_OF(X509_EXTENSION) *exts,\n                            unsigned long flag, int indent);\n\nint X509_check_ca(X509 *x);\nint X509_check_purpose(X509 *x, int id, int ca);\nint X509_supported_extension(X509_EXTENSION *ex);\nint X509_PURPOSE_set(int *p, int purpose);\nint X509_check_issued(X509 *issuer, X509 *subject);\nint X509_check_akid(X509 *issuer, AUTHORITY_KEYID *akid);\nint X509_PURPOSE_get_count(void);\nX509_PURPOSE *X509_PURPOSE_get0(int idx);\nint X509_PURPOSE_get_by_sname(char *sname);\nint X509_PURPOSE_get_by_id(int id);\nint X509_PURPOSE_add(int id, int trust, int flags,\n                     int (*ck) (const X509_PURPOSE *, const X509 *, int),\n                     char *name, char *sname, void *arg);\nchar *X509_PURPOSE_get0_name(X509_PURPOSE *xp);\nchar *X509_PURPOSE_get0_sname(X509_PURPOSE *xp);\nint X509_PURPOSE_get_trust(X509_PURPOSE *xp);\nvoid X509_PURPOSE_cleanup(void);\nint X509_PURPOSE_get_id(X509_PURPOSE *);\n\nSTACK_OF(OPENSSL_STRING) *X509_get1_email(X509 *x);\nSTACK_OF(OPENSSL_STRING) *X509_REQ_get1_email(X509_REQ *x);\nvoid X509_email_free(STACK_OF(OPENSSL_STRING) *sk);\nSTACK_OF(OPENSSL_STRING) *X509_get1_ocsp(X509 *x);\n/* Flags for X509_check_* functions */\n\n/*\n * Always check subject name for host match even if subject alt names present\n */\n# define X509_CHECK_FLAG_ALWAYS_CHECK_SUBJECT    0x1\n/* Disable wildcard matching for dnsName fields and common name. */\n# define X509_CHECK_FLAG_NO_WILDCARDS    0x2\n/* Wildcards must not match a partial label. */\n# define X509_CHECK_FLAG_NO_PARTIAL_WILDCARDS 0x4\n/* Allow (non-partial) wildcards to match multiple labels. */\n# define X509_CHECK_FLAG_MULTI_LABEL_WILDCARDS 0x8\n/* Constraint verifier subdomain patterns to match a single labels. */\n# define X509_CHECK_FLAG_SINGLE_LABEL_SUBDOMAINS 0x10\n/*\n * Match reference identifiers starting with \".\" to any sub-domain.\n * This is a non-public flag, turned on implicitly when the subject\n * reference identity is a DNS name.\n */\n# define _X509_CHECK_FLAG_DOT_SUBDOMAINS 0x8000\n\nint X509_check_host(X509 *x, const char *chk, size_t chklen,\n                    unsigned int flags, char **peername);\nint X509_check_email(X509 *x, const char *chk, size_t chklen,\n                     unsigned int flags);\nint X509_check_ip(X509 *x, const unsigned char *chk, size_t chklen,\n                  unsigned int flags);\nint X509_check_ip_asc(X509 *x, const char *ipasc, unsigned int flags);\n\nASN1_OCTET_STRING *a2i_IPADDRESS(const char *ipasc);\nASN1_OCTET_STRING *a2i_IPADDRESS_NC(const char *ipasc);\nint a2i_ipadd(unsigned char *ipout, const char *ipasc);\nint X509V3_NAME_from_section(X509_NAME *nm, STACK_OF(CONF_VALUE) *dn_sk,\n                             unsigned long chtype);\n\nvoid X509_POLICY_NODE_print(BIO *out, X509_POLICY_NODE *node, int indent);\nDECLARE_STACK_OF(X509_POLICY_NODE)\n\n# ifndef OPENSSL_NO_RFC3779\n\ntypedef struct ASRange_st {\n    ASN1_INTEGER *min, *max;\n} ASRange;\n\n#  define ASIdOrRange_id          0\n#  define ASIdOrRange_range       1\n\ntypedef struct ASIdOrRange_st {\n    int type;\n    union {\n        ASN1_INTEGER *id;\n        ASRange *range;\n    } u;\n} ASIdOrRange;\n\ntypedef STACK_OF(ASIdOrRange) ASIdOrRanges;\nDECLARE_STACK_OF(ASIdOrRange)\n\n#  define ASIdentifierChoice_inherit              0\n#  define ASIdentifierChoice_asIdsOrRanges        1\n\ntypedef struct ASIdentifierChoice_st {\n    int type;\n    union {\n        ASN1_NULL *inherit;\n        ASIdOrRanges *asIdsOrRanges;\n    } u;\n} ASIdentifierChoice;\n\ntypedef struct ASIdentifiers_st {\n    ASIdentifierChoice *asnum, *rdi;\n} ASIdentifiers;\n\nDECLARE_ASN1_FUNCTIONS(ASRange)\nDECLARE_ASN1_FUNCTIONS(ASIdOrRange)\nDECLARE_ASN1_FUNCTIONS(ASIdentifierChoice)\nDECLARE_ASN1_FUNCTIONS(ASIdentifiers)\n\ntypedef struct IPAddressRange_st {\n    ASN1_BIT_STRING *min, *max;\n} IPAddressRange;\n\n#  define IPAddressOrRange_addressPrefix  0\n#  define IPAddressOrRange_addressRange   1\n\ntypedef struct IPAddressOrRange_st {\n    int type;\n    union {\n        ASN1_BIT_STRING *addressPrefix;\n        IPAddressRange *addressRange;\n    } u;\n} IPAddressOrRange;\n\ntypedef STACK_OF(IPAddressOrRange) IPAddressOrRanges;\nDECLARE_STACK_OF(IPAddressOrRange)\n\n#  define IPAddressChoice_inherit                 0\n#  define IPAddressChoice_addressesOrRanges       1\n\ntypedef struct IPAddressChoice_st {\n    int type;\n    union {\n        ASN1_NULL *inherit;\n        IPAddressOrRanges *addressesOrRanges;\n    } u;\n} IPAddressChoice;\n\ntypedef struct IPAddressFamily_st {\n    ASN1_OCTET_STRING *addressFamily;\n    IPAddressChoice *ipAddressChoice;\n} IPAddressFamily;\n\ntypedef STACK_OF(IPAddressFamily) IPAddrBlocks;\nDECLARE_STACK_OF(IPAddressFamily)\n\nDECLARE_ASN1_FUNCTIONS(IPAddressRange)\nDECLARE_ASN1_FUNCTIONS(IPAddressOrRange)\nDECLARE_ASN1_FUNCTIONS(IPAddressChoice)\nDECLARE_ASN1_FUNCTIONS(IPAddressFamily)\n\n/*\n * API tag for elements of the ASIdentifer SEQUENCE.\n */\n#  define V3_ASID_ASNUM   0\n#  define V3_ASID_RDI     1\n\n/*\n * AFI values, assigned by IANA.  It'd be nice to make the AFI\n * handling code totally generic, but there are too many little things\n * that would need to be defined for other address families for it to\n * be worth the trouble.\n */\n#  define IANA_AFI_IPV4   1\n#  define IANA_AFI_IPV6   2\n\n/*\n * Utilities to construct and extract values from RFC3779 extensions,\n * since some of the encodings (particularly for IP address prefixes\n * and ranges) are a bit tedious to work with directly.\n */\nint v3_asid_add_inherit(ASIdentifiers *asid, int which);\nint v3_asid_add_id_or_range(ASIdentifiers *asid, int which,\n                            ASN1_INTEGER *min, ASN1_INTEGER *max);\nint v3_addr_add_inherit(IPAddrBlocks *addr,\n                        const unsigned afi, const unsigned *safi);\nint v3_addr_add_prefix(IPAddrBlocks *addr,\n                       const unsigned afi, const unsigned *safi,\n                       unsigned char *a, const int prefixlen);\nint v3_addr_add_range(IPAddrBlocks *addr,\n                      const unsigned afi, const unsigned *safi,\n                      unsigned char *min, unsigned char *max);\nunsigned v3_addr_get_afi(const IPAddressFamily *f);\nint v3_addr_get_range(IPAddressOrRange *aor, const unsigned afi,\n                      unsigned char *min, unsigned char *max,\n                      const int length);\n\n/*\n * Canonical forms.\n */\nint v3_asid_is_canonical(ASIdentifiers *asid);\nint v3_addr_is_canonical(IPAddrBlocks *addr);\nint v3_asid_canonize(ASIdentifiers *asid);\nint v3_addr_canonize(IPAddrBlocks *addr);\n\n/*\n * Tests for inheritance and containment.\n */\nint v3_asid_inherits(ASIdentifiers *asid);\nint v3_addr_inherits(IPAddrBlocks *addr);\nint v3_asid_subset(ASIdentifiers *a, ASIdentifiers *b);\nint v3_addr_subset(IPAddrBlocks *a, IPAddrBlocks *b);\n\n/*\n * Check whether RFC 3779 extensions nest properly in chains.\n */\nint v3_asid_validate_path(X509_STORE_CTX *);\nint v3_addr_validate_path(X509_STORE_CTX *);\nint v3_asid_validate_resource_set(STACK_OF(X509) *chain,\n                                  ASIdentifiers *ext, int allow_inheritance);\nint v3_addr_validate_resource_set(STACK_OF(X509) *chain,\n                                  IPAddrBlocks *ext, int allow_inheritance);\n\n# endif                         /* OPENSSL_NO_RFC3779 */\n\n/* BEGIN ERROR CODES */\n/*\n * The following lines are auto generated by the script mkerr.pl. Any changes\n * made after this point may be overwritten when the script is next run.\n */\nvoid ERR_load_X509V3_strings(void);\n\n/* Error codes for the X509V3 functions. */\n\n/* Function codes. */\n# define X509V3_F_A2I_GENERAL_NAME                        164\n# define X509V3_F_ASIDENTIFIERCHOICE_CANONIZE             161\n# define X509V3_F_ASIDENTIFIERCHOICE_IS_CANONICAL         162\n# define X509V3_F_COPY_EMAIL                              122\n# define X509V3_F_COPY_ISSUER                             123\n# define X509V3_F_DO_DIRNAME                              144\n# define X509V3_F_DO_EXT_CONF                             124\n# define X509V3_F_DO_EXT_I2D                              135\n# define X509V3_F_DO_EXT_NCONF                            151\n# define X509V3_F_DO_I2V_NAME_CONSTRAINTS                 148\n# define X509V3_F_GNAMES_FROM_SECTNAME                    156\n# define X509V3_F_HEX_TO_STRING                           111\n# define X509V3_F_I2S_ASN1_ENUMERATED                     121\n# define X509V3_F_I2S_ASN1_IA5STRING                      149\n# define X509V3_F_I2S_ASN1_INTEGER                        120\n# define X509V3_F_I2V_AUTHORITY_INFO_ACCESS               138\n# define X509V3_F_NOTICE_SECTION                          132\n# define X509V3_F_NREF_NOS                                133\n# define X509V3_F_POLICY_SECTION                          131\n# define X509V3_F_PROCESS_PCI_VALUE                       150\n# define X509V3_F_R2I_CERTPOL                             130\n# define X509V3_F_R2I_PCI                                 155\n# define X509V3_F_S2I_ASN1_IA5STRING                      100\n# define X509V3_F_S2I_ASN1_INTEGER                        108\n# define X509V3_F_S2I_ASN1_OCTET_STRING                   112\n# define X509V3_F_S2I_ASN1_SKEY_ID                        114\n# define X509V3_F_S2I_SKEY_ID                             115\n# define X509V3_F_SET_DIST_POINT_NAME                     158\n# define X509V3_F_STRING_TO_HEX                           113\n# define X509V3_F_SXNET_ADD_ID_ASC                        125\n# define X509V3_F_SXNET_ADD_ID_INTEGER                    126\n# define X509V3_F_SXNET_ADD_ID_ULONG                      127\n# define X509V3_F_SXNET_GET_ID_ASC                        128\n# define X509V3_F_SXNET_GET_ID_ULONG                      129\n# define X509V3_F_V2I_ASIDENTIFIERS                       163\n# define X509V3_F_V2I_ASN1_BIT_STRING                     101\n# define X509V3_F_V2I_AUTHORITY_INFO_ACCESS               139\n# define X509V3_F_V2I_AUTHORITY_KEYID                     119\n# define X509V3_F_V2I_BASIC_CONSTRAINTS                   102\n# define X509V3_F_V2I_CRLD                                134\n# define X509V3_F_V2I_EXTENDED_KEY_USAGE                  103\n# define X509V3_F_V2I_GENERAL_NAMES                       118\n# define X509V3_F_V2I_GENERAL_NAME_EX                     117\n# define X509V3_F_V2I_IDP                                 157\n# define X509V3_F_V2I_IPADDRBLOCKS                        159\n# define X509V3_F_V2I_ISSUER_ALT                          153\n# define X509V3_F_V2I_NAME_CONSTRAINTS                    147\n# define X509V3_F_V2I_POLICY_CONSTRAINTS                  146\n# define X509V3_F_V2I_POLICY_MAPPINGS                     145\n# define X509V3_F_V2I_SUBJECT_ALT                         154\n# define X509V3_F_V3_ADDR_VALIDATE_PATH_INTERNAL          160\n# define X509V3_F_V3_GENERIC_EXTENSION                    116\n# define X509V3_F_X509V3_ADD1_I2D                         140\n# define X509V3_F_X509V3_ADD_VALUE                        105\n# define X509V3_F_X509V3_EXT_ADD                          104\n# define X509V3_F_X509V3_EXT_ADD_ALIAS                    106\n# define X509V3_F_X509V3_EXT_CONF                         107\n# define X509V3_F_X509V3_EXT_FREE                         165\n# define X509V3_F_X509V3_EXT_I2D                          136\n# define X509V3_F_X509V3_EXT_NCONF                        152\n# define X509V3_F_X509V3_GET_SECTION                      142\n# define X509V3_F_X509V3_GET_STRING                       143\n# define X509V3_F_X509V3_GET_VALUE_BOOL                   110\n# define X509V3_F_X509V3_PARSE_LIST                       109\n# define X509V3_F_X509_PURPOSE_ADD                        137\n# define X509V3_F_X509_PURPOSE_SET                        141\n\n/* Reason codes. */\n# define X509V3_R_BAD_IP_ADDRESS                          118\n# define X509V3_R_BAD_OBJECT                              119\n# define X509V3_R_BN_DEC2BN_ERROR                         100\n# define X509V3_R_BN_TO_ASN1_INTEGER_ERROR                101\n# define X509V3_R_CANNOT_FIND_FREE_FUNCTION               168\n# define X509V3_R_DIRNAME_ERROR                           149\n# define X509V3_R_DISTPOINT_ALREADY_SET                   160\n# define X509V3_R_DUPLICATE_ZONE_ID                       133\n# define X509V3_R_ERROR_CONVERTING_ZONE                   131\n# define X509V3_R_ERROR_CREATING_EXTENSION                144\n# define X509V3_R_ERROR_IN_EXTENSION                      128\n# define X509V3_R_EXPECTED_A_SECTION_NAME                 137\n# define X509V3_R_EXTENSION_EXISTS                        145\n# define X509V3_R_EXTENSION_NAME_ERROR                    115\n# define X509V3_R_EXTENSION_NOT_FOUND                     102\n# define X509V3_R_EXTENSION_SETTING_NOT_SUPPORTED         103\n# define X509V3_R_EXTENSION_VALUE_ERROR                   116\n# define X509V3_R_ILLEGAL_EMPTY_EXTENSION                 151\n# define X509V3_R_ILLEGAL_HEX_DIGIT                       113\n# define X509V3_R_INCORRECT_POLICY_SYNTAX_TAG             152\n# define X509V3_R_INVALID_ASNUMBER                        162\n# define X509V3_R_INVALID_ASRANGE                         163\n# define X509V3_R_INVALID_BOOLEAN_STRING                  104\n# define X509V3_R_INVALID_EXTENSION_STRING                105\n# define X509V3_R_INVALID_INHERITANCE                     165\n# define X509V3_R_INVALID_IPADDRESS                       166\n# define X509V3_R_INVALID_MULTIPLE_RDNS                   161\n# define X509V3_R_INVALID_NAME                            106\n# define X509V3_R_INVALID_NULL_ARGUMENT                   107\n# define X509V3_R_INVALID_NULL_NAME                       108\n# define X509V3_R_INVALID_NULL_VALUE                      109\n# define X509V3_R_INVALID_NUMBER                          140\n# define X509V3_R_INVALID_NUMBERS                         141\n# define X509V3_R_INVALID_OBJECT_IDENTIFIER               110\n# define X509V3_R_INVALID_OPTION                          138\n# define X509V3_R_INVALID_POLICY_IDENTIFIER               134\n# define X509V3_R_INVALID_PROXY_POLICY_SETTING            153\n# define X509V3_R_INVALID_PURPOSE                         146\n# define X509V3_R_INVALID_SAFI                            164\n# define X509V3_R_INVALID_SECTION                         135\n# define X509V3_R_INVALID_SYNTAX                          143\n# define X509V3_R_ISSUER_DECODE_ERROR                     126\n# define X509V3_R_MISSING_VALUE                           124\n# define X509V3_R_NEED_ORGANIZATION_AND_NUMBERS           142\n# define X509V3_R_NO_CONFIG_DATABASE                      136\n# define X509V3_R_NO_ISSUER_CERTIFICATE                   121\n# define X509V3_R_NO_ISSUER_DETAILS                       127\n# define X509V3_R_NO_POLICY_IDENTIFIER                    139\n# define X509V3_R_NO_PROXY_CERT_POLICY_LANGUAGE_DEFINED   154\n# define X509V3_R_NO_PUBLIC_KEY                           114\n# define X509V3_R_NO_SUBJECT_DETAILS                      125\n# define X509V3_R_ODD_NUMBER_OF_DIGITS                    112\n# define X509V3_R_OPERATION_NOT_DEFINED                   148\n# define X509V3_R_OTHERNAME_ERROR                         147\n# define X509V3_R_POLICY_LANGUAGE_ALREADY_DEFINED         155\n# define X509V3_R_POLICY_PATH_LENGTH                      156\n# define X509V3_R_POLICY_PATH_LENGTH_ALREADY_DEFINED      157\n# define X509V3_R_POLICY_SYNTAX_NOT_CURRENTLY_SUPPORTED   158\n# define X509V3_R_POLICY_WHEN_PROXY_LANGUAGE_REQUIRES_NO_POLICY 159\n# define X509V3_R_SECTION_NOT_FOUND                       150\n# define X509V3_R_UNABLE_TO_GET_ISSUER_DETAILS            122\n# define X509V3_R_UNABLE_TO_GET_ISSUER_KEYID              123\n# define X509V3_R_UNKNOWN_BIT_STRING_ARGUMENT             111\n# define X509V3_R_UNKNOWN_EXTENSION                       129\n# define X509V3_R_UNKNOWN_EXTENSION_NAME                  130\n# define X509V3_R_UNKNOWN_OPTION                          120\n# define X509V3_R_UNSUPPORTED_OPTION                      117\n# define X509V3_R_UNSUPPORTED_TYPE                        167\n# define X509V3_R_USER_TOO_LONG                           132\n\n#ifdef  __cplusplus\n}\n#endif\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/x86/include/openssl/aes.h",
    "content": "/* crypto/aes/aes.h */\n/* ====================================================================\n * Copyright (c) 1998-2002 The OpenSSL Project.  All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n *\n * 1. Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n *\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in\n *    the documentation and/or other materials provided with the\n *    distribution.\n *\n * 3. All advertising materials mentioning features or use of this\n *    software must display the following acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit. (http://www.openssl.org/)\"\n *\n * 4. The names \"OpenSSL Toolkit\" and \"OpenSSL Project\" must not be used to\n *    endorse or promote products derived from this software without\n *    prior written permission. For written permission, please contact\n *    openssl-core@openssl.org.\n *\n * 5. Products derived from this software may not be called \"OpenSSL\"\n *    nor may \"OpenSSL\" appear in their names without prior written\n *    permission of the OpenSSL Project.\n *\n * 6. Redistributions of any form whatsoever must retain the following\n *    acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit (http://www.openssl.org/)\"\n *\n * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY\n * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\n * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR\n * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\n * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,\n * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED\n * OF THE POSSIBILITY OF SUCH DAMAGE.\n * ====================================================================\n *\n */\n\n#ifndef HEADER_AES_H\n# define HEADER_AES_H\n\n# include <openssl/opensslconf.h>\n\n# ifdef OPENSSL_NO_AES\n#  error AES is disabled.\n# endif\n\n# include <stddef.h>\n\n# define AES_ENCRYPT     1\n# define AES_DECRYPT     0\n\n/*\n * Because array size can't be a const in C, the following two are macros.\n * Both sizes are in bytes.\n */\n# define AES_MAXNR 14\n# define AES_BLOCK_SIZE 16\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n/* This should be a hidden type, but EVP requires that the size be known */\nstruct aes_key_st {\n# ifdef AES_LONG\n    unsigned long rd_key[4 * (AES_MAXNR + 1)];\n# else\n    unsigned int rd_key[4 * (AES_MAXNR + 1)];\n# endif\n    int rounds;\n};\ntypedef struct aes_key_st AES_KEY;\n\nconst char *AES_options(void);\n\nint AES_set_encrypt_key(const unsigned char *userKey, const int bits,\n                        AES_KEY *key);\nint AES_set_decrypt_key(const unsigned char *userKey, const int bits,\n                        AES_KEY *key);\n\nint private_AES_set_encrypt_key(const unsigned char *userKey, const int bits,\n                                AES_KEY *key);\nint private_AES_set_decrypt_key(const unsigned char *userKey, const int bits,\n                                AES_KEY *key);\n\nvoid AES_encrypt(const unsigned char *in, unsigned char *out,\n                 const AES_KEY *key);\nvoid AES_decrypt(const unsigned char *in, unsigned char *out,\n                 const AES_KEY *key);\n\nvoid AES_ecb_encrypt(const unsigned char *in, unsigned char *out,\n                     const AES_KEY *key, const int enc);\nvoid AES_cbc_encrypt(const unsigned char *in, unsigned char *out,\n                     size_t length, const AES_KEY *key,\n                     unsigned char *ivec, const int enc);\nvoid AES_cfb128_encrypt(const unsigned char *in, unsigned char *out,\n                        size_t length, const AES_KEY *key,\n                        unsigned char *ivec, int *num, const int enc);\nvoid AES_cfb1_encrypt(const unsigned char *in, unsigned char *out,\n                      size_t length, const AES_KEY *key,\n                      unsigned char *ivec, int *num, const int enc);\nvoid AES_cfb8_encrypt(const unsigned char *in, unsigned char *out,\n                      size_t length, const AES_KEY *key,\n                      unsigned char *ivec, int *num, const int enc);\nvoid AES_ofb128_encrypt(const unsigned char *in, unsigned char *out,\n                        size_t length, const AES_KEY *key,\n                        unsigned char *ivec, int *num);\nvoid AES_ctr128_encrypt(const unsigned char *in, unsigned char *out,\n                        size_t length, const AES_KEY *key,\n                        unsigned char ivec[AES_BLOCK_SIZE],\n                        unsigned char ecount_buf[AES_BLOCK_SIZE],\n                        unsigned int *num);\n/* NB: the IV is _two_ blocks long */\nvoid AES_ige_encrypt(const unsigned char *in, unsigned char *out,\n                     size_t length, const AES_KEY *key,\n                     unsigned char *ivec, const int enc);\n/* NB: the IV is _four_ blocks long */\nvoid AES_bi_ige_encrypt(const unsigned char *in, unsigned char *out,\n                        size_t length, const AES_KEY *key,\n                        const AES_KEY *key2, const unsigned char *ivec,\n                        const int enc);\n\nint AES_wrap_key(AES_KEY *key, const unsigned char *iv,\n                 unsigned char *out,\n                 const unsigned char *in, unsigned int inlen);\nint AES_unwrap_key(AES_KEY *key, const unsigned char *iv,\n                   unsigned char *out,\n                   const unsigned char *in, unsigned int inlen);\n\n\n#ifdef  __cplusplus\n}\n#endif\n\n#endif                          /* !HEADER_AES_H */\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/x86/include/openssl/asn1.h",
    "content": "/* crypto/asn1/asn1.h */\n/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)\n * All rights reserved.\n *\n * This package is an SSL implementation written\n * by Eric Young (eay@cryptsoft.com).\n * The implementation was written so as to conform with Netscapes SSL.\n *\n * This library is free for commercial and non-commercial use as long as\n * the following conditions are aheared to.  The following conditions\n * apply to all code found in this distribution, be it the RC4, RSA,\n * lhash, DES, etc., code; not just the SSL code.  The SSL documentation\n * included with this distribution is covered by the same copyright terms\n * except that the holder is Tim Hudson (tjh@cryptsoft.com).\n *\n * Copyright remains Eric Young's, and as such any Copyright notices in\n * the code are not to be removed.\n * If this package is used in a product, Eric Young should be given attribution\n * as the author of the parts of the library used.\n * This can be in the form of a textual message at program startup or\n * in documentation (online or textual) provided with the package.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the copyright\n *    notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in the\n *    documentation and/or other materials provided with the distribution.\n * 3. All advertising materials mentioning features or use of this software\n *    must display the following acknowledgement:\n *    \"This product includes cryptographic software written by\n *     Eric Young (eay@cryptsoft.com)\"\n *    The word 'cryptographic' can be left out if the rouines from the library\n *    being used are not cryptographic related :-).\n * 4. If you include any Windows specific code (or a derivative thereof) from\n *    the apps directory (application code) you must include an acknowledgement:\n *    \"This product includes software written by Tim Hudson (tjh@cryptsoft.com)\"\n *\n * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n * SUCH DAMAGE.\n *\n * The licence and distribution terms for any publically available version or\n * derivative of this code cannot be changed.  i.e. this code cannot simply be\n * copied and put under another distribution licence\n * [including the GNU Public Licence.]\n */\n\n#ifndef HEADER_ASN1_H\n# define HEADER_ASN1_H\n\n# include <time.h>\n# include <openssl/e_os2.h>\n# ifndef OPENSSL_NO_BIO\n#  include <openssl/bio.h>\n# endif\n# include <openssl/stack.h>\n# include <openssl/safestack.h>\n\n# include <openssl/symhacks.h>\n\n# include <openssl/ossl_typ.h>\n# ifndef OPENSSL_NO_DEPRECATED\n#  include <openssl/bn.h>\n# endif\n\n# ifdef OPENSSL_BUILD_SHLIBCRYPTO\n#  undef OPENSSL_EXTERN\n#  define OPENSSL_EXTERN OPENSSL_EXPORT\n# endif\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n# define V_ASN1_UNIVERSAL                0x00\n# define V_ASN1_APPLICATION              0x40\n# define V_ASN1_CONTEXT_SPECIFIC         0x80\n# define V_ASN1_PRIVATE                  0xc0\n\n# define V_ASN1_CONSTRUCTED              0x20\n# define V_ASN1_PRIMITIVE_TAG            0x1f\n# define V_ASN1_PRIMATIVE_TAG            0x1f\n\n# define V_ASN1_APP_CHOOSE               -2/* let the recipient choose */\n# define V_ASN1_OTHER                    -3/* used in ASN1_TYPE */\n# define V_ASN1_ANY                      -4/* used in ASN1 template code */\n\n# define V_ASN1_NEG                      0x100/* negative flag */\n\n# define V_ASN1_UNDEF                    -1\n# define V_ASN1_EOC                      0\n# define V_ASN1_BOOLEAN                  1 /**/\n# define V_ASN1_INTEGER                  2\n# define V_ASN1_NEG_INTEGER              (2 | V_ASN1_NEG)\n# define V_ASN1_BIT_STRING               3\n# define V_ASN1_OCTET_STRING             4\n# define V_ASN1_NULL                     5\n# define V_ASN1_OBJECT                   6\n# define V_ASN1_OBJECT_DESCRIPTOR        7\n# define V_ASN1_EXTERNAL                 8\n# define V_ASN1_REAL                     9\n# define V_ASN1_ENUMERATED               10\n# define V_ASN1_NEG_ENUMERATED           (10 | V_ASN1_NEG)\n# define V_ASN1_UTF8STRING               12\n# define V_ASN1_SEQUENCE                 16\n# define V_ASN1_SET                      17\n# define V_ASN1_NUMERICSTRING            18 /**/\n# define V_ASN1_PRINTABLESTRING          19\n# define V_ASN1_T61STRING                20\n# define V_ASN1_TELETEXSTRING            20/* alias */\n# define V_ASN1_VIDEOTEXSTRING           21 /**/\n# define V_ASN1_IA5STRING                22\n# define V_ASN1_UTCTIME                  23\n# define V_ASN1_GENERALIZEDTIME          24 /**/\n# define V_ASN1_GRAPHICSTRING            25 /**/\n# define V_ASN1_ISO64STRING              26 /**/\n# define V_ASN1_VISIBLESTRING            26/* alias */\n# define V_ASN1_GENERALSTRING            27 /**/\n# define V_ASN1_UNIVERSALSTRING          28 /**/\n# define V_ASN1_BMPSTRING                30\n/* For use with d2i_ASN1_type_bytes() */\n# define B_ASN1_NUMERICSTRING    0x0001\n# define B_ASN1_PRINTABLESTRING  0x0002\n# define B_ASN1_T61STRING        0x0004\n# define B_ASN1_TELETEXSTRING    0x0004\n# define B_ASN1_VIDEOTEXSTRING   0x0008\n# define B_ASN1_IA5STRING        0x0010\n# define B_ASN1_GRAPHICSTRING    0x0020\n# define B_ASN1_ISO64STRING      0x0040\n# define B_ASN1_VISIBLESTRING    0x0040\n# define B_ASN1_GENERALSTRING    0x0080\n# define B_ASN1_UNIVERSALSTRING  0x0100\n# define B_ASN1_OCTET_STRING     0x0200\n# define B_ASN1_BIT_STRING       0x0400\n# define B_ASN1_BMPSTRING        0x0800\n# define B_ASN1_UNKNOWN          0x1000\n# define B_ASN1_UTF8STRING       0x2000\n# define B_ASN1_UTCTIME          0x4000\n# define B_ASN1_GENERALIZEDTIME  0x8000\n# define B_ASN1_SEQUENCE         0x10000\n/* For use with ASN1_mbstring_copy() */\n# define MBSTRING_FLAG           0x1000\n# define MBSTRING_UTF8           (MBSTRING_FLAG)\n# define MBSTRING_ASC            (MBSTRING_FLAG|1)\n# define MBSTRING_BMP            (MBSTRING_FLAG|2)\n# define MBSTRING_UNIV           (MBSTRING_FLAG|4)\n# define SMIME_OLDMIME           0x400\n# define SMIME_CRLFEOL           0x800\n# define SMIME_STREAM            0x1000\n    struct X509_algor_st;\nDECLARE_STACK_OF(X509_ALGOR)\n\n# define DECLARE_ASN1_SET_OF(type)/* filled in by mkstack.pl */\n# define IMPLEMENT_ASN1_SET_OF(type)/* nothing, no longer needed */\n\n/*\n * We MUST make sure that, except for constness, asn1_ctx_st and\n * asn1_const_ctx are exactly the same.  Fortunately, as soon as the old ASN1\n * parsing macros are gone, we can throw this away as well...\n */\ntypedef struct asn1_ctx_st {\n    unsigned char *p;           /* work char pointer */\n    int eos;                    /* end of sequence read for indefinite\n                                 * encoding */\n    int error;                  /* error code to use when returning an error */\n    int inf;                    /* constructed if 0x20, indefinite is 0x21 */\n    int tag;                    /* tag from last 'get object' */\n    int xclass;                 /* class from last 'get object' */\n    long slen;                  /* length of last 'get object' */\n    unsigned char *max;         /* largest value of p allowed */\n    unsigned char *q;           /* temporary variable */\n    unsigned char **pp;         /* variable */\n    int line;                   /* used in error processing */\n} ASN1_CTX;\n\ntypedef struct asn1_const_ctx_st {\n    const unsigned char *p;     /* work char pointer */\n    int eos;                    /* end of sequence read for indefinite\n                                 * encoding */\n    int error;                  /* error code to use when returning an error */\n    int inf;                    /* constructed if 0x20, indefinite is 0x21 */\n    int tag;                    /* tag from last 'get object' */\n    int xclass;                 /* class from last 'get object' */\n    long slen;                  /* length of last 'get object' */\n    const unsigned char *max;   /* largest value of p allowed */\n    const unsigned char *q;     /* temporary variable */\n    const unsigned char **pp;   /* variable */\n    int line;                   /* used in error processing */\n} ASN1_const_CTX;\n\n/*\n * These are used internally in the ASN1_OBJECT to keep track of whether the\n * names and data need to be free()ed\n */\n# define ASN1_OBJECT_FLAG_DYNAMIC         0x01/* internal use */\n# define ASN1_OBJECT_FLAG_CRITICAL        0x02/* critical x509v3 object id */\n# define ASN1_OBJECT_FLAG_DYNAMIC_STRINGS 0x04/* internal use */\n# define ASN1_OBJECT_FLAG_DYNAMIC_DATA    0x08/* internal use */\nstruct asn1_object_st {\n    const char *sn, *ln;\n    int nid;\n    int length;\n    const unsigned char *data;  /* data remains const after init */\n    int flags;                  /* Should we free this one */\n};\n\n# define ASN1_STRING_FLAG_BITS_LEFT 0x08/* Set if 0x07 has bits left value */\n/*\n * This indicates that the ASN1_STRING is not a real value but just a place\n * holder for the location where indefinite length constructed data should be\n * inserted in the memory buffer\n */\n# define ASN1_STRING_FLAG_NDEF 0x010\n\n/*\n * This flag is used by the CMS code to indicate that a string is not\n * complete and is a place holder for content when it had all been accessed.\n * The flag will be reset when content has been written to it.\n */\n\n# define ASN1_STRING_FLAG_CONT 0x020\n/*\n * This flag is used by ASN1 code to indicate an ASN1_STRING is an MSTRING\n * type.\n */\n# define ASN1_STRING_FLAG_MSTRING 0x040\n/* This is the base type that holds just about everything :-) */\nstruct asn1_string_st {\n    int length;\n    int type;\n    unsigned char *data;\n    /*\n     * The value of the following field depends on the type being held.  It\n     * is mostly being used for BIT_STRING so if the input data has a\n     * non-zero 'unused bits' value, it will be handled correctly\n     */\n    long flags;\n};\n\n/*\n * ASN1_ENCODING structure: this is used to save the received encoding of an\n * ASN1 type. This is useful to get round problems with invalid encodings\n * which can break signatures.\n */\n\ntypedef struct ASN1_ENCODING_st {\n    unsigned char *enc;         /* DER encoding */\n    long len;                   /* Length of encoding */\n    int modified;               /* set to 1 if 'enc' is invalid */\n} ASN1_ENCODING;\n\n/* Used with ASN1 LONG type: if a long is set to this it is omitted */\n# define ASN1_LONG_UNDEF 0x7fffffffL\n\n# define STABLE_FLAGS_MALLOC     0x01\n# define STABLE_NO_MASK          0x02\n# define DIRSTRING_TYPE  \\\n (B_ASN1_PRINTABLESTRING|B_ASN1_T61STRING|B_ASN1_BMPSTRING|B_ASN1_UTF8STRING)\n# define PKCS9STRING_TYPE (DIRSTRING_TYPE|B_ASN1_IA5STRING)\n\ntypedef struct asn1_string_table_st {\n    int nid;\n    long minsize;\n    long maxsize;\n    unsigned long mask;\n    unsigned long flags;\n} ASN1_STRING_TABLE;\n\nDECLARE_STACK_OF(ASN1_STRING_TABLE)\n\n/* size limits: this stuff is taken straight from RFC2459 */\n\n# define ub_name                         32768\n# define ub_common_name                  64\n# define ub_locality_name                128\n# define ub_state_name                   128\n# define ub_organization_name            64\n# define ub_organization_unit_name       64\n# define ub_title                        64\n# define ub_email_address                128\n\n/*\n * Declarations for template structures: for full definitions see asn1t.h\n */\ntypedef struct ASN1_TEMPLATE_st ASN1_TEMPLATE;\ntypedef struct ASN1_TLC_st ASN1_TLC;\n/* This is just an opaque pointer */\ntypedef struct ASN1_VALUE_st ASN1_VALUE;\n\n/* Declare ASN1 functions: the implement macro in in asn1t.h */\n\n# define DECLARE_ASN1_FUNCTIONS(type) DECLARE_ASN1_FUNCTIONS_name(type, type)\n\n# define DECLARE_ASN1_ALLOC_FUNCTIONS(type) \\\n        DECLARE_ASN1_ALLOC_FUNCTIONS_name(type, type)\n\n# define DECLARE_ASN1_FUNCTIONS_name(type, name) \\\n        DECLARE_ASN1_ALLOC_FUNCTIONS_name(type, name) \\\n        DECLARE_ASN1_ENCODE_FUNCTIONS(type, name, name)\n\n# define DECLARE_ASN1_FUNCTIONS_fname(type, itname, name) \\\n        DECLARE_ASN1_ALLOC_FUNCTIONS_name(type, name) \\\n        DECLARE_ASN1_ENCODE_FUNCTIONS(type, itname, name)\n\n# define DECLARE_ASN1_ENCODE_FUNCTIONS(type, itname, name) \\\n        type *d2i_##name(type **a, const unsigned char **in, long len); \\\n        int i2d_##name(type *a, unsigned char **out); \\\n        DECLARE_ASN1_ITEM(itname)\n\n# define DECLARE_ASN1_ENCODE_FUNCTIONS_const(type, name) \\\n        type *d2i_##name(type **a, const unsigned char **in, long len); \\\n        int i2d_##name(const type *a, unsigned char **out); \\\n        DECLARE_ASN1_ITEM(name)\n\n# define DECLARE_ASN1_NDEF_FUNCTION(name) \\\n        int i2d_##name##_NDEF(name *a, unsigned char **out);\n\n# define DECLARE_ASN1_FUNCTIONS_const(name) \\\n        DECLARE_ASN1_ALLOC_FUNCTIONS(name) \\\n        DECLARE_ASN1_ENCODE_FUNCTIONS_const(name, name)\n\n# define DECLARE_ASN1_ALLOC_FUNCTIONS_name(type, name) \\\n        type *name##_new(void); \\\n        void name##_free(type *a);\n\n# define DECLARE_ASN1_PRINT_FUNCTION(stname) \\\n        DECLARE_ASN1_PRINT_FUNCTION_fname(stname, stname)\n\n# define DECLARE_ASN1_PRINT_FUNCTION_fname(stname, fname) \\\n        int fname##_print_ctx(BIO *out, stname *x, int indent, \\\n                                         const ASN1_PCTX *pctx);\n\n# define D2I_OF(type) type *(*)(type **,const unsigned char **,long)\n# define I2D_OF(type) int (*)(type *,unsigned char **)\n# define I2D_OF_const(type) int (*)(const type *,unsigned char **)\n\n# define CHECKED_D2I_OF(type, d2i) \\\n    ((d2i_of_void*) (1 ? d2i : ((D2I_OF(type))0)))\n# define CHECKED_I2D_OF(type, i2d) \\\n    ((i2d_of_void*) (1 ? i2d : ((I2D_OF(type))0)))\n# define CHECKED_NEW_OF(type, xnew) \\\n    ((void *(*)(void)) (1 ? xnew : ((type *(*)(void))0)))\n# define CHECKED_PTR_OF(type, p) \\\n    ((void*) (1 ? p : (type*)0))\n# define CHECKED_PPTR_OF(type, p) \\\n    ((void**) (1 ? p : (type**)0))\n\n# define TYPEDEF_D2I_OF(type) typedef type *d2i_of_##type(type **,const unsigned char **,long)\n# define TYPEDEF_I2D_OF(type) typedef int i2d_of_##type(type *,unsigned char **)\n# define TYPEDEF_D2I2D_OF(type) TYPEDEF_D2I_OF(type); TYPEDEF_I2D_OF(type)\n\nTYPEDEF_D2I2D_OF(void);\n\n/*-\n * The following macros and typedefs allow an ASN1_ITEM\n * to be embedded in a structure and referenced. Since\n * the ASN1_ITEM pointers need to be globally accessible\n * (possibly from shared libraries) they may exist in\n * different forms. On platforms that support it the\n * ASN1_ITEM structure itself will be globally exported.\n * Other platforms will export a function that returns\n * an ASN1_ITEM pointer.\n *\n * To handle both cases transparently the macros below\n * should be used instead of hard coding an ASN1_ITEM\n * pointer in a structure.\n *\n * The structure will look like this:\n *\n * typedef struct SOMETHING_st {\n *      ...\n *      ASN1_ITEM_EXP *iptr;\n *      ...\n * } SOMETHING;\n *\n * It would be initialised as e.g.:\n *\n * SOMETHING somevar = {...,ASN1_ITEM_ref(X509),...};\n *\n * and the actual pointer extracted with:\n *\n * const ASN1_ITEM *it = ASN1_ITEM_ptr(somevar.iptr);\n *\n * Finally an ASN1_ITEM pointer can be extracted from an\n * appropriate reference with: ASN1_ITEM_rptr(X509). This\n * would be used when a function takes an ASN1_ITEM * argument.\n *\n */\n\n# ifndef OPENSSL_EXPORT_VAR_AS_FUNCTION\n\n/* ASN1_ITEM pointer exported type */\ntypedef const ASN1_ITEM ASN1_ITEM_EXP;\n\n/* Macro to obtain ASN1_ITEM pointer from exported type */\n#  define ASN1_ITEM_ptr(iptr) (iptr)\n\n/* Macro to include ASN1_ITEM pointer from base type */\n#  define ASN1_ITEM_ref(iptr) (&(iptr##_it))\n\n#  define ASN1_ITEM_rptr(ref) (&(ref##_it))\n\n#  define DECLARE_ASN1_ITEM(name) \\\n        OPENSSL_EXTERN const ASN1_ITEM name##_it;\n\n# else\n\n/*\n * Platforms that can't easily handle shared global variables are declared as\n * functions returning ASN1_ITEM pointers.\n */\n\n/* ASN1_ITEM pointer exported type */\ntypedef const ASN1_ITEM *ASN1_ITEM_EXP (void);\n\n/* Macro to obtain ASN1_ITEM pointer from exported type */\n#  define ASN1_ITEM_ptr(iptr) (iptr())\n\n/* Macro to include ASN1_ITEM pointer from base type */\n#  define ASN1_ITEM_ref(iptr) (iptr##_it)\n\n#  define ASN1_ITEM_rptr(ref) (ref##_it())\n\n#  define DECLARE_ASN1_ITEM(name) \\\n        const ASN1_ITEM * name##_it(void);\n\n# endif\n\n/* Parameters used by ASN1_STRING_print_ex() */\n\n/*\n * These determine which characters to escape: RFC2253 special characters,\n * control characters and MSB set characters\n */\n\n# define ASN1_STRFLGS_ESC_2253           1\n# define ASN1_STRFLGS_ESC_CTRL           2\n# define ASN1_STRFLGS_ESC_MSB            4\n\n/*\n * This flag determines how we do escaping: normally RC2253 backslash only,\n * set this to use backslash and quote.\n */\n\n# define ASN1_STRFLGS_ESC_QUOTE          8\n\n/* These three flags are internal use only. */\n\n/* Character is a valid PrintableString character */\n# define CHARTYPE_PRINTABLESTRING        0x10\n/* Character needs escaping if it is the first character */\n# define CHARTYPE_FIRST_ESC_2253         0x20\n/* Character needs escaping if it is the last character */\n# define CHARTYPE_LAST_ESC_2253          0x40\n\n/*\n * NB the internal flags are safely reused below by flags handled at the top\n * level.\n */\n\n/*\n * If this is set we convert all character strings to UTF8 first\n */\n\n# define ASN1_STRFLGS_UTF8_CONVERT       0x10\n\n/*\n * If this is set we don't attempt to interpret content: just assume all\n * strings are 1 byte per character. This will produce some pretty odd\n * looking output!\n */\n\n# define ASN1_STRFLGS_IGNORE_TYPE        0x20\n\n/* If this is set we include the string type in the output */\n# define ASN1_STRFLGS_SHOW_TYPE          0x40\n\n/*\n * This determines which strings to display and which to 'dump' (hex dump of\n * content octets or DER encoding). We can only dump non character strings or\n * everything. If we don't dump 'unknown' they are interpreted as character\n * strings with 1 octet per character and are subject to the usual escaping\n * options.\n */\n\n# define ASN1_STRFLGS_DUMP_ALL           0x80\n# define ASN1_STRFLGS_DUMP_UNKNOWN       0x100\n\n/*\n * These determine what 'dumping' does, we can dump the content octets or the\n * DER encoding: both use the RFC2253 #XXXXX notation.\n */\n\n# define ASN1_STRFLGS_DUMP_DER           0x200\n\n/*\n * All the string flags consistent with RFC2253, escaping control characters\n * isn't essential in RFC2253 but it is advisable anyway.\n */\n\n# define ASN1_STRFLGS_RFC2253    (ASN1_STRFLGS_ESC_2253 | \\\n                                ASN1_STRFLGS_ESC_CTRL | \\\n                                ASN1_STRFLGS_ESC_MSB | \\\n                                ASN1_STRFLGS_UTF8_CONVERT | \\\n                                ASN1_STRFLGS_DUMP_UNKNOWN | \\\n                                ASN1_STRFLGS_DUMP_DER)\n\nDECLARE_STACK_OF(ASN1_INTEGER)\nDECLARE_ASN1_SET_OF(ASN1_INTEGER)\n\nDECLARE_STACK_OF(ASN1_GENERALSTRING)\n\ntypedef struct asn1_type_st {\n    int type;\n    union {\n        char *ptr;\n        ASN1_BOOLEAN boolean;\n        ASN1_STRING *asn1_string;\n        ASN1_OBJECT *object;\n        ASN1_INTEGER *integer;\n        ASN1_ENUMERATED *enumerated;\n        ASN1_BIT_STRING *bit_string;\n        ASN1_OCTET_STRING *octet_string;\n        ASN1_PRINTABLESTRING *printablestring;\n        ASN1_T61STRING *t61string;\n        ASN1_IA5STRING *ia5string;\n        ASN1_GENERALSTRING *generalstring;\n        ASN1_BMPSTRING *bmpstring;\n        ASN1_UNIVERSALSTRING *universalstring;\n        ASN1_UTCTIME *utctime;\n        ASN1_GENERALIZEDTIME *generalizedtime;\n        ASN1_VISIBLESTRING *visiblestring;\n        ASN1_UTF8STRING *utf8string;\n        /*\n         * set and sequence are left complete and still contain the set or\n         * sequence bytes\n         */\n        ASN1_STRING *set;\n        ASN1_STRING *sequence;\n        ASN1_VALUE *asn1_value;\n    } value;\n} ASN1_TYPE;\n\nDECLARE_STACK_OF(ASN1_TYPE)\nDECLARE_ASN1_SET_OF(ASN1_TYPE)\n\ntypedef STACK_OF(ASN1_TYPE) ASN1_SEQUENCE_ANY;\n\nDECLARE_ASN1_ENCODE_FUNCTIONS_const(ASN1_SEQUENCE_ANY, ASN1_SEQUENCE_ANY)\nDECLARE_ASN1_ENCODE_FUNCTIONS_const(ASN1_SEQUENCE_ANY, ASN1_SET_ANY)\n\ntypedef struct NETSCAPE_X509_st {\n    ASN1_OCTET_STRING *header;\n    X509 *cert;\n} NETSCAPE_X509;\n\n/* This is used to contain a list of bit names */\ntypedef struct BIT_STRING_BITNAME_st {\n    int bitnum;\n    const char *lname;\n    const char *sname;\n} BIT_STRING_BITNAME;\n\n# define M_ASN1_STRING_length(x) ((x)->length)\n# define M_ASN1_STRING_length_set(x, n)  ((x)->length = (n))\n# define M_ASN1_STRING_type(x)   ((x)->type)\n# define M_ASN1_STRING_data(x)   ((x)->data)\n\n/* Macros for string operations */\n# define M_ASN1_BIT_STRING_new() (ASN1_BIT_STRING *)\\\n                ASN1_STRING_type_new(V_ASN1_BIT_STRING)\n# define M_ASN1_BIT_STRING_free(a)       ASN1_STRING_free((ASN1_STRING *)a)\n# define M_ASN1_BIT_STRING_dup(a) (ASN1_BIT_STRING *)\\\n                ASN1_STRING_dup((const ASN1_STRING *)a)\n# define M_ASN1_BIT_STRING_cmp(a,b) ASN1_STRING_cmp(\\\n                (const ASN1_STRING *)a,(const ASN1_STRING *)b)\n# define M_ASN1_BIT_STRING_set(a,b,c) ASN1_STRING_set((ASN1_STRING *)a,b,c)\n\n# define M_ASN1_INTEGER_new()    (ASN1_INTEGER *)\\\n                ASN1_STRING_type_new(V_ASN1_INTEGER)\n# define M_ASN1_INTEGER_free(a)          ASN1_STRING_free((ASN1_STRING *)a)\n# define M_ASN1_INTEGER_dup(a) (ASN1_INTEGER *)\\\n                ASN1_STRING_dup((const ASN1_STRING *)a)\n# define M_ASN1_INTEGER_cmp(a,b) ASN1_STRING_cmp(\\\n                (const ASN1_STRING *)a,(const ASN1_STRING *)b)\n\n# define M_ASN1_ENUMERATED_new() (ASN1_ENUMERATED *)\\\n                ASN1_STRING_type_new(V_ASN1_ENUMERATED)\n# define M_ASN1_ENUMERATED_free(a)       ASN1_STRING_free((ASN1_STRING *)a)\n# define M_ASN1_ENUMERATED_dup(a) (ASN1_ENUMERATED *)\\\n                ASN1_STRING_dup((const ASN1_STRING *)a)\n# define M_ASN1_ENUMERATED_cmp(a,b)      ASN1_STRING_cmp(\\\n                (const ASN1_STRING *)a,(const ASN1_STRING *)b)\n\n# define M_ASN1_OCTET_STRING_new()       (ASN1_OCTET_STRING *)\\\n                ASN1_STRING_type_new(V_ASN1_OCTET_STRING)\n# define M_ASN1_OCTET_STRING_free(a)     ASN1_STRING_free((ASN1_STRING *)a)\n# define M_ASN1_OCTET_STRING_dup(a) (ASN1_OCTET_STRING *)\\\n                ASN1_STRING_dup((const ASN1_STRING *)a)\n# define M_ASN1_OCTET_STRING_cmp(a,b) ASN1_STRING_cmp(\\\n                (const ASN1_STRING *)a,(const ASN1_STRING *)b)\n# define M_ASN1_OCTET_STRING_set(a,b,c)  ASN1_STRING_set((ASN1_STRING *)a,b,c)\n# define M_ASN1_OCTET_STRING_print(a,b)  ASN1_STRING_print(a,(ASN1_STRING *)b)\n# define M_i2d_ASN1_OCTET_STRING(a,pp) \\\n                i2d_ASN1_bytes((ASN1_STRING *)a,pp,V_ASN1_OCTET_STRING,\\\n                V_ASN1_UNIVERSAL)\n\n# define B_ASN1_TIME \\\n                        B_ASN1_UTCTIME | \\\n                        B_ASN1_GENERALIZEDTIME\n\n# define B_ASN1_PRINTABLE \\\n                        B_ASN1_NUMERICSTRING| \\\n                        B_ASN1_PRINTABLESTRING| \\\n                        B_ASN1_T61STRING| \\\n                        B_ASN1_IA5STRING| \\\n                        B_ASN1_BIT_STRING| \\\n                        B_ASN1_UNIVERSALSTRING|\\\n                        B_ASN1_BMPSTRING|\\\n                        B_ASN1_UTF8STRING|\\\n                        B_ASN1_SEQUENCE|\\\n                        B_ASN1_UNKNOWN\n\n# define B_ASN1_DIRECTORYSTRING \\\n                        B_ASN1_PRINTABLESTRING| \\\n                        B_ASN1_TELETEXSTRING|\\\n                        B_ASN1_BMPSTRING|\\\n                        B_ASN1_UNIVERSALSTRING|\\\n                        B_ASN1_UTF8STRING\n\n# define B_ASN1_DISPLAYTEXT \\\n                        B_ASN1_IA5STRING| \\\n                        B_ASN1_VISIBLESTRING| \\\n                        B_ASN1_BMPSTRING|\\\n                        B_ASN1_UTF8STRING\n\n# define M_ASN1_PRINTABLE_new()  ASN1_STRING_type_new(V_ASN1_T61STRING)\n# define M_ASN1_PRINTABLE_free(a)        ASN1_STRING_free((ASN1_STRING *)a)\n# define M_i2d_ASN1_PRINTABLE(a,pp) i2d_ASN1_bytes((ASN1_STRING *)a,\\\n                pp,a->type,V_ASN1_UNIVERSAL)\n# define M_d2i_ASN1_PRINTABLE(a,pp,l) \\\n                d2i_ASN1_type_bytes((ASN1_STRING **)a,pp,l, \\\n                        B_ASN1_PRINTABLE)\n\n# define M_DIRECTORYSTRING_new() ASN1_STRING_type_new(V_ASN1_PRINTABLESTRING)\n# define M_DIRECTORYSTRING_free(a)       ASN1_STRING_free((ASN1_STRING *)a)\n# define M_i2d_DIRECTORYSTRING(a,pp) i2d_ASN1_bytes((ASN1_STRING *)a,\\\n                                                pp,a->type,V_ASN1_UNIVERSAL)\n# define M_d2i_DIRECTORYSTRING(a,pp,l) \\\n                d2i_ASN1_type_bytes((ASN1_STRING **)a,pp,l, \\\n                        B_ASN1_DIRECTORYSTRING)\n\n# define M_DISPLAYTEXT_new() ASN1_STRING_type_new(V_ASN1_VISIBLESTRING)\n# define M_DISPLAYTEXT_free(a) ASN1_STRING_free((ASN1_STRING *)a)\n# define M_i2d_DISPLAYTEXT(a,pp) i2d_ASN1_bytes((ASN1_STRING *)a,\\\n                                                pp,a->type,V_ASN1_UNIVERSAL)\n# define M_d2i_DISPLAYTEXT(a,pp,l) \\\n                d2i_ASN1_type_bytes((ASN1_STRING **)a,pp,l, \\\n                        B_ASN1_DISPLAYTEXT)\n\n# define M_ASN1_PRINTABLESTRING_new() (ASN1_PRINTABLESTRING *)\\\n                ASN1_STRING_type_new(V_ASN1_PRINTABLESTRING)\n# define M_ASN1_PRINTABLESTRING_free(a)  ASN1_STRING_free((ASN1_STRING *)a)\n# define M_i2d_ASN1_PRINTABLESTRING(a,pp) \\\n                i2d_ASN1_bytes((ASN1_STRING *)a,pp,V_ASN1_PRINTABLESTRING,\\\n                V_ASN1_UNIVERSAL)\n# define M_d2i_ASN1_PRINTABLESTRING(a,pp,l) \\\n                (ASN1_PRINTABLESTRING *)d2i_ASN1_type_bytes\\\n                ((ASN1_STRING **)a,pp,l,B_ASN1_PRINTABLESTRING)\n\n# define M_ASN1_T61STRING_new()  (ASN1_T61STRING *)\\\n                ASN1_STRING_type_new(V_ASN1_T61STRING)\n# define M_ASN1_T61STRING_free(a)        ASN1_STRING_free((ASN1_STRING *)a)\n# define M_i2d_ASN1_T61STRING(a,pp) \\\n                i2d_ASN1_bytes((ASN1_STRING *)a,pp,V_ASN1_T61STRING,\\\n                V_ASN1_UNIVERSAL)\n# define M_d2i_ASN1_T61STRING(a,pp,l) \\\n                (ASN1_T61STRING *)d2i_ASN1_type_bytes\\\n                ((ASN1_STRING **)a,pp,l,B_ASN1_T61STRING)\n\n# define M_ASN1_IA5STRING_new()  (ASN1_IA5STRING *)\\\n                ASN1_STRING_type_new(V_ASN1_IA5STRING)\n# define M_ASN1_IA5STRING_free(a)        ASN1_STRING_free((ASN1_STRING *)a)\n# define M_ASN1_IA5STRING_dup(a) \\\n                (ASN1_IA5STRING *)ASN1_STRING_dup((const ASN1_STRING *)a)\n# define M_i2d_ASN1_IA5STRING(a,pp) \\\n                i2d_ASN1_bytes((ASN1_STRING *)a,pp,V_ASN1_IA5STRING,\\\n                        V_ASN1_UNIVERSAL)\n# define M_d2i_ASN1_IA5STRING(a,pp,l) \\\n                (ASN1_IA5STRING *)d2i_ASN1_type_bytes((ASN1_STRING **)a,pp,l,\\\n                        B_ASN1_IA5STRING)\n\n# define M_ASN1_UTCTIME_new()    (ASN1_UTCTIME *)\\\n                ASN1_STRING_type_new(V_ASN1_UTCTIME)\n# define M_ASN1_UTCTIME_free(a)  ASN1_STRING_free((ASN1_STRING *)a)\n# define M_ASN1_UTCTIME_dup(a) (ASN1_UTCTIME *)\\\n                ASN1_STRING_dup((const ASN1_STRING *)a)\n\n# define M_ASN1_GENERALIZEDTIME_new()    (ASN1_GENERALIZEDTIME *)\\\n                ASN1_STRING_type_new(V_ASN1_GENERALIZEDTIME)\n# define M_ASN1_GENERALIZEDTIME_free(a)  ASN1_STRING_free((ASN1_STRING *)a)\n# define M_ASN1_GENERALIZEDTIME_dup(a) (ASN1_GENERALIZEDTIME *)ASN1_STRING_dup(\\\n        (const ASN1_STRING *)a)\n\n# define M_ASN1_TIME_new()       (ASN1_TIME *)\\\n                ASN1_STRING_type_new(V_ASN1_UTCTIME)\n# define M_ASN1_TIME_free(a)     ASN1_STRING_free((ASN1_STRING *)a)\n# define M_ASN1_TIME_dup(a) (ASN1_TIME *)\\\n        ASN1_STRING_dup((const ASN1_STRING *)a)\n\n# define M_ASN1_GENERALSTRING_new()      (ASN1_GENERALSTRING *)\\\n                ASN1_STRING_type_new(V_ASN1_GENERALSTRING)\n# define M_ASN1_GENERALSTRING_free(a)    ASN1_STRING_free((ASN1_STRING *)a)\n# define M_i2d_ASN1_GENERALSTRING(a,pp) \\\n                i2d_ASN1_bytes((ASN1_STRING *)a,pp,V_ASN1_GENERALSTRING,\\\n                        V_ASN1_UNIVERSAL)\n# define M_d2i_ASN1_GENERALSTRING(a,pp,l) \\\n                (ASN1_GENERALSTRING *)d2i_ASN1_type_bytes\\\n                ((ASN1_STRING **)a,pp,l,B_ASN1_GENERALSTRING)\n\n# define M_ASN1_UNIVERSALSTRING_new()    (ASN1_UNIVERSALSTRING *)\\\n                ASN1_STRING_type_new(V_ASN1_UNIVERSALSTRING)\n# define M_ASN1_UNIVERSALSTRING_free(a)  ASN1_STRING_free((ASN1_STRING *)a)\n# define M_i2d_ASN1_UNIVERSALSTRING(a,pp) \\\n                i2d_ASN1_bytes((ASN1_STRING *)a,pp,V_ASN1_UNIVERSALSTRING,\\\n                        V_ASN1_UNIVERSAL)\n# define M_d2i_ASN1_UNIVERSALSTRING(a,pp,l) \\\n                (ASN1_UNIVERSALSTRING *)d2i_ASN1_type_bytes\\\n                ((ASN1_STRING **)a,pp,l,B_ASN1_UNIVERSALSTRING)\n\n# define M_ASN1_BMPSTRING_new()  (ASN1_BMPSTRING *)\\\n                ASN1_STRING_type_new(V_ASN1_BMPSTRING)\n# define M_ASN1_BMPSTRING_free(a)        ASN1_STRING_free((ASN1_STRING *)a)\n# define M_i2d_ASN1_BMPSTRING(a,pp) \\\n                i2d_ASN1_bytes((ASN1_STRING *)a,pp,V_ASN1_BMPSTRING,\\\n                        V_ASN1_UNIVERSAL)\n# define M_d2i_ASN1_BMPSTRING(a,pp,l) \\\n                (ASN1_BMPSTRING *)d2i_ASN1_type_bytes\\\n                ((ASN1_STRING **)a,pp,l,B_ASN1_BMPSTRING)\n\n# define M_ASN1_VISIBLESTRING_new()      (ASN1_VISIBLESTRING *)\\\n                ASN1_STRING_type_new(V_ASN1_VISIBLESTRING)\n# define M_ASN1_VISIBLESTRING_free(a)    ASN1_STRING_free((ASN1_STRING *)a)\n# define M_i2d_ASN1_VISIBLESTRING(a,pp) \\\n                i2d_ASN1_bytes((ASN1_STRING *)a,pp,V_ASN1_VISIBLESTRING,\\\n                        V_ASN1_UNIVERSAL)\n# define M_d2i_ASN1_VISIBLESTRING(a,pp,l) \\\n                (ASN1_VISIBLESTRING *)d2i_ASN1_type_bytes\\\n                ((ASN1_STRING **)a,pp,l,B_ASN1_VISIBLESTRING)\n\n# define M_ASN1_UTF8STRING_new() (ASN1_UTF8STRING *)\\\n                ASN1_STRING_type_new(V_ASN1_UTF8STRING)\n# define M_ASN1_UTF8STRING_free(a)       ASN1_STRING_free((ASN1_STRING *)a)\n# define M_i2d_ASN1_UTF8STRING(a,pp) \\\n                i2d_ASN1_bytes((ASN1_STRING *)a,pp,V_ASN1_UTF8STRING,\\\n                        V_ASN1_UNIVERSAL)\n# define M_d2i_ASN1_UTF8STRING(a,pp,l) \\\n                (ASN1_UTF8STRING *)d2i_ASN1_type_bytes\\\n                ((ASN1_STRING **)a,pp,l,B_ASN1_UTF8STRING)\n\n  /* for the is_set parameter to i2d_ASN1_SET */\n# define IS_SEQUENCE     0\n# define IS_SET          1\n\nDECLARE_ASN1_FUNCTIONS_fname(ASN1_TYPE, ASN1_ANY, ASN1_TYPE)\n\nint ASN1_TYPE_get(ASN1_TYPE *a);\nvoid ASN1_TYPE_set(ASN1_TYPE *a, int type, void *value);\nint ASN1_TYPE_set1(ASN1_TYPE *a, int type, const void *value);\nint ASN1_TYPE_cmp(const ASN1_TYPE *a, const ASN1_TYPE *b);\n\nASN1_OBJECT *ASN1_OBJECT_new(void);\nvoid ASN1_OBJECT_free(ASN1_OBJECT *a);\nint i2d_ASN1_OBJECT(ASN1_OBJECT *a, unsigned char **pp);\nASN1_OBJECT *c2i_ASN1_OBJECT(ASN1_OBJECT **a, const unsigned char **pp,\n                             long length);\nASN1_OBJECT *d2i_ASN1_OBJECT(ASN1_OBJECT **a, const unsigned char **pp,\n                             long length);\n\nDECLARE_ASN1_ITEM(ASN1_OBJECT)\n\nDECLARE_STACK_OF(ASN1_OBJECT)\nDECLARE_ASN1_SET_OF(ASN1_OBJECT)\n\nASN1_STRING *ASN1_STRING_new(void);\nvoid ASN1_STRING_free(ASN1_STRING *a);\nvoid ASN1_STRING_clear_free(ASN1_STRING *a);\nint ASN1_STRING_copy(ASN1_STRING *dst, const ASN1_STRING *str);\nASN1_STRING *ASN1_STRING_dup(const ASN1_STRING *a);\nASN1_STRING *ASN1_STRING_type_new(int type);\nint ASN1_STRING_cmp(const ASN1_STRING *a, const ASN1_STRING *b);\n  /*\n   * Since this is used to store all sorts of things, via macros, for now,\n   * make its data void *\n   */\nint ASN1_STRING_set(ASN1_STRING *str, const void *data, int len);\nvoid ASN1_STRING_set0(ASN1_STRING *str, void *data, int len);\nint ASN1_STRING_length(const ASN1_STRING *x);\nvoid ASN1_STRING_length_set(ASN1_STRING *x, int n);\nint ASN1_STRING_type(ASN1_STRING *x);\nunsigned char *ASN1_STRING_data(ASN1_STRING *x);\n\nDECLARE_ASN1_FUNCTIONS(ASN1_BIT_STRING)\nint i2c_ASN1_BIT_STRING(ASN1_BIT_STRING *a, unsigned char **pp);\nASN1_BIT_STRING *c2i_ASN1_BIT_STRING(ASN1_BIT_STRING **a,\n                                     const unsigned char **pp, long length);\nint ASN1_BIT_STRING_set(ASN1_BIT_STRING *a, unsigned char *d, int length);\nint ASN1_BIT_STRING_set_bit(ASN1_BIT_STRING *a, int n, int value);\nint ASN1_BIT_STRING_get_bit(ASN1_BIT_STRING *a, int n);\nint ASN1_BIT_STRING_check(ASN1_BIT_STRING *a,\n                          unsigned char *flags, int flags_len);\n\n# ifndef OPENSSL_NO_BIO\nint ASN1_BIT_STRING_name_print(BIO *out, ASN1_BIT_STRING *bs,\n                               BIT_STRING_BITNAME *tbl, int indent);\n# endif\nint ASN1_BIT_STRING_num_asc(char *name, BIT_STRING_BITNAME *tbl);\nint ASN1_BIT_STRING_set_asc(ASN1_BIT_STRING *bs, char *name, int value,\n                            BIT_STRING_BITNAME *tbl);\n\nint i2d_ASN1_BOOLEAN(int a, unsigned char **pp);\nint d2i_ASN1_BOOLEAN(int *a, const unsigned char **pp, long length);\n\nDECLARE_ASN1_FUNCTIONS(ASN1_INTEGER)\nint i2c_ASN1_INTEGER(ASN1_INTEGER *a, unsigned char **pp);\nASN1_INTEGER *c2i_ASN1_INTEGER(ASN1_INTEGER **a, const unsigned char **pp,\n                               long length);\nASN1_INTEGER *d2i_ASN1_UINTEGER(ASN1_INTEGER **a, const unsigned char **pp,\n                                long length);\nASN1_INTEGER *ASN1_INTEGER_dup(const ASN1_INTEGER *x);\nint ASN1_INTEGER_cmp(const ASN1_INTEGER *x, const ASN1_INTEGER *y);\n\nDECLARE_ASN1_FUNCTIONS(ASN1_ENUMERATED)\n\nint ASN1_UTCTIME_check(const ASN1_UTCTIME *a);\nASN1_UTCTIME *ASN1_UTCTIME_set(ASN1_UTCTIME *s, time_t t);\nASN1_UTCTIME *ASN1_UTCTIME_adj(ASN1_UTCTIME *s, time_t t,\n                               int offset_day, long offset_sec);\nint ASN1_UTCTIME_set_string(ASN1_UTCTIME *s, const char *str);\nint ASN1_UTCTIME_cmp_time_t(const ASN1_UTCTIME *s, time_t t);\n# if 0\ntime_t ASN1_UTCTIME_get(const ASN1_UTCTIME *s);\n# endif\n\nint ASN1_GENERALIZEDTIME_check(const ASN1_GENERALIZEDTIME *a);\nASN1_GENERALIZEDTIME *ASN1_GENERALIZEDTIME_set(ASN1_GENERALIZEDTIME *s,\n                                               time_t t);\nASN1_GENERALIZEDTIME *ASN1_GENERALIZEDTIME_adj(ASN1_GENERALIZEDTIME *s,\n                                               time_t t, int offset_day,\n                                               long offset_sec);\nint ASN1_GENERALIZEDTIME_set_string(ASN1_GENERALIZEDTIME *s, const char *str);\nint ASN1_TIME_diff(int *pday, int *psec,\n                   const ASN1_TIME *from, const ASN1_TIME *to);\n\nDECLARE_ASN1_FUNCTIONS(ASN1_OCTET_STRING)\nASN1_OCTET_STRING *ASN1_OCTET_STRING_dup(const ASN1_OCTET_STRING *a);\nint ASN1_OCTET_STRING_cmp(const ASN1_OCTET_STRING *a,\n                          const ASN1_OCTET_STRING *b);\nint ASN1_OCTET_STRING_set(ASN1_OCTET_STRING *str, const unsigned char *data,\n                          int len);\n\nDECLARE_ASN1_FUNCTIONS(ASN1_VISIBLESTRING)\nDECLARE_ASN1_FUNCTIONS(ASN1_UNIVERSALSTRING)\nDECLARE_ASN1_FUNCTIONS(ASN1_UTF8STRING)\nDECLARE_ASN1_FUNCTIONS(ASN1_NULL)\nDECLARE_ASN1_FUNCTIONS(ASN1_BMPSTRING)\n\nint UTF8_getc(const unsigned char *str, int len, unsigned long *val);\nint UTF8_putc(unsigned char *str, int len, unsigned long value);\n\nDECLARE_ASN1_FUNCTIONS_name(ASN1_STRING, ASN1_PRINTABLE)\n\nDECLARE_ASN1_FUNCTIONS_name(ASN1_STRING, DIRECTORYSTRING)\nDECLARE_ASN1_FUNCTIONS_name(ASN1_STRING, DISPLAYTEXT)\nDECLARE_ASN1_FUNCTIONS(ASN1_PRINTABLESTRING)\nDECLARE_ASN1_FUNCTIONS(ASN1_T61STRING)\nDECLARE_ASN1_FUNCTIONS(ASN1_IA5STRING)\nDECLARE_ASN1_FUNCTIONS(ASN1_GENERALSTRING)\nDECLARE_ASN1_FUNCTIONS(ASN1_UTCTIME)\nDECLARE_ASN1_FUNCTIONS(ASN1_GENERALIZEDTIME)\nDECLARE_ASN1_FUNCTIONS(ASN1_TIME)\n\nDECLARE_ASN1_ITEM(ASN1_OCTET_STRING_NDEF)\n\nASN1_TIME *ASN1_TIME_set(ASN1_TIME *s, time_t t);\nASN1_TIME *ASN1_TIME_adj(ASN1_TIME *s, time_t t,\n                         int offset_day, long offset_sec);\nint ASN1_TIME_check(ASN1_TIME *t);\nASN1_GENERALIZEDTIME *ASN1_TIME_to_generalizedtime(ASN1_TIME *t, ASN1_GENERALIZEDTIME\n                                                   **out);\nint ASN1_TIME_set_string(ASN1_TIME *s, const char *str);\n\nint i2d_ASN1_SET(STACK_OF(OPENSSL_BLOCK) *a, unsigned char **pp,\n                 i2d_of_void *i2d, int ex_tag, int ex_class, int is_set);\nSTACK_OF(OPENSSL_BLOCK) *d2i_ASN1_SET(STACK_OF(OPENSSL_BLOCK) **a,\n                                      const unsigned char **pp,\n                                      long length, d2i_of_void *d2i,\n                                      void (*free_func) (OPENSSL_BLOCK),\n                                      int ex_tag, int ex_class);\n\n# ifndef OPENSSL_NO_BIO\nint i2a_ASN1_INTEGER(BIO *bp, ASN1_INTEGER *a);\nint a2i_ASN1_INTEGER(BIO *bp, ASN1_INTEGER *bs, char *buf, int size);\nint i2a_ASN1_ENUMERATED(BIO *bp, ASN1_ENUMERATED *a);\nint a2i_ASN1_ENUMERATED(BIO *bp, ASN1_ENUMERATED *bs, char *buf, int size);\nint i2a_ASN1_OBJECT(BIO *bp, ASN1_OBJECT *a);\nint a2i_ASN1_STRING(BIO *bp, ASN1_STRING *bs, char *buf, int size);\nint i2a_ASN1_STRING(BIO *bp, ASN1_STRING *a, int type);\n# endif\nint i2t_ASN1_OBJECT(char *buf, int buf_len, ASN1_OBJECT *a);\n\nint a2d_ASN1_OBJECT(unsigned char *out, int olen, const char *buf, int num);\nASN1_OBJECT *ASN1_OBJECT_create(int nid, unsigned char *data, int len,\n                                const char *sn, const char *ln);\n\nint ASN1_INTEGER_set(ASN1_INTEGER *a, long v);\nlong ASN1_INTEGER_get(const ASN1_INTEGER *a);\nASN1_INTEGER *BN_to_ASN1_INTEGER(const BIGNUM *bn, ASN1_INTEGER *ai);\nBIGNUM *ASN1_INTEGER_to_BN(const ASN1_INTEGER *ai, BIGNUM *bn);\n\nint ASN1_ENUMERATED_set(ASN1_ENUMERATED *a, long v);\nlong ASN1_ENUMERATED_get(ASN1_ENUMERATED *a);\nASN1_ENUMERATED *BN_to_ASN1_ENUMERATED(BIGNUM *bn, ASN1_ENUMERATED *ai);\nBIGNUM *ASN1_ENUMERATED_to_BN(ASN1_ENUMERATED *ai, BIGNUM *bn);\n\n/* General */\n/* given a string, return the correct type, max is the maximum length */\nint ASN1_PRINTABLE_type(const unsigned char *s, int max);\n\nint i2d_ASN1_bytes(ASN1_STRING *a, unsigned char **pp, int tag, int xclass);\nASN1_STRING *d2i_ASN1_bytes(ASN1_STRING **a, const unsigned char **pp,\n                            long length, int Ptag, int Pclass);\nunsigned long ASN1_tag2bit(int tag);\n/* type is one or more of the B_ASN1_ values. */\nASN1_STRING *d2i_ASN1_type_bytes(ASN1_STRING **a, const unsigned char **pp,\n                                 long length, int type);\n\n/* PARSING */\nint asn1_Finish(ASN1_CTX *c);\nint asn1_const_Finish(ASN1_const_CTX *c);\n\n/* SPECIALS */\nint ASN1_get_object(const unsigned char **pp, long *plength, int *ptag,\n                    int *pclass, long omax);\nint ASN1_check_infinite_end(unsigned char **p, long len);\nint ASN1_const_check_infinite_end(const unsigned char **p, long len);\nvoid ASN1_put_object(unsigned char **pp, int constructed, int length,\n                     int tag, int xclass);\nint ASN1_put_eoc(unsigned char **pp);\nint ASN1_object_size(int constructed, int length, int tag);\n\n/* Used to implement other functions */\nvoid *ASN1_dup(i2d_of_void *i2d, d2i_of_void *d2i, void *x);\n\n# define ASN1_dup_of(type,i2d,d2i,x) \\\n    ((type*)ASN1_dup(CHECKED_I2D_OF(type, i2d), \\\n                     CHECKED_D2I_OF(type, d2i), \\\n                     CHECKED_PTR_OF(type, x)))\n\n# define ASN1_dup_of_const(type,i2d,d2i,x) \\\n    ((type*)ASN1_dup(CHECKED_I2D_OF(const type, i2d), \\\n                     CHECKED_D2I_OF(type, d2i), \\\n                     CHECKED_PTR_OF(const type, x)))\n\nvoid *ASN1_item_dup(const ASN1_ITEM *it, void *x);\n\n/* ASN1 alloc/free macros for when a type is only used internally */\n\n# define M_ASN1_new_of(type) (type *)ASN1_item_new(ASN1_ITEM_rptr(type))\n# define M_ASN1_free_of(x, type) \\\n                ASN1_item_free(CHECKED_PTR_OF(type, x), ASN1_ITEM_rptr(type))\n\n# ifndef OPENSSL_NO_FP_API\nvoid *ASN1_d2i_fp(void *(*xnew) (void), d2i_of_void *d2i, FILE *in, void **x);\n\n#  define ASN1_d2i_fp_of(type,xnew,d2i,in,x) \\\n    ((type*)ASN1_d2i_fp(CHECKED_NEW_OF(type, xnew), \\\n                        CHECKED_D2I_OF(type, d2i), \\\n                        in, \\\n                        CHECKED_PPTR_OF(type, x)))\n\nvoid *ASN1_item_d2i_fp(const ASN1_ITEM *it, FILE *in, void *x);\nint ASN1_i2d_fp(i2d_of_void *i2d, FILE *out, void *x);\n\n#  define ASN1_i2d_fp_of(type,i2d,out,x) \\\n    (ASN1_i2d_fp(CHECKED_I2D_OF(type, i2d), \\\n                 out, \\\n                 CHECKED_PTR_OF(type, x)))\n\n#  define ASN1_i2d_fp_of_const(type,i2d,out,x) \\\n    (ASN1_i2d_fp(CHECKED_I2D_OF(const type, i2d), \\\n                 out, \\\n                 CHECKED_PTR_OF(const type, x)))\n\nint ASN1_item_i2d_fp(const ASN1_ITEM *it, FILE *out, void *x);\nint ASN1_STRING_print_ex_fp(FILE *fp, ASN1_STRING *str, unsigned long flags);\n# endif\n\nint ASN1_STRING_to_UTF8(unsigned char **out, ASN1_STRING *in);\n\n# ifndef OPENSSL_NO_BIO\nvoid *ASN1_d2i_bio(void *(*xnew) (void), d2i_of_void *d2i, BIO *in, void **x);\n\n#  define ASN1_d2i_bio_of(type,xnew,d2i,in,x) \\\n    ((type*)ASN1_d2i_bio( CHECKED_NEW_OF(type, xnew), \\\n                          CHECKED_D2I_OF(type, d2i), \\\n                          in, \\\n                          CHECKED_PPTR_OF(type, x)))\n\nvoid *ASN1_item_d2i_bio(const ASN1_ITEM *it, BIO *in, void *x);\nint ASN1_i2d_bio(i2d_of_void *i2d, BIO *out, unsigned char *x);\n\n#  define ASN1_i2d_bio_of(type,i2d,out,x) \\\n    (ASN1_i2d_bio(CHECKED_I2D_OF(type, i2d), \\\n                  out, \\\n                  CHECKED_PTR_OF(type, x)))\n\n#  define ASN1_i2d_bio_of_const(type,i2d,out,x) \\\n    (ASN1_i2d_bio(CHECKED_I2D_OF(const type, i2d), \\\n                  out, \\\n                  CHECKED_PTR_OF(const type, x)))\n\nint ASN1_item_i2d_bio(const ASN1_ITEM *it, BIO *out, void *x);\nint ASN1_UTCTIME_print(BIO *fp, const ASN1_UTCTIME *a);\nint ASN1_GENERALIZEDTIME_print(BIO *fp, const ASN1_GENERALIZEDTIME *a);\nint ASN1_TIME_print(BIO *fp, const ASN1_TIME *a);\nint ASN1_STRING_print(BIO *bp, const ASN1_STRING *v);\nint ASN1_STRING_print_ex(BIO *out, ASN1_STRING *str, unsigned long flags);\nint ASN1_bn_print(BIO *bp, const char *number, const BIGNUM *num,\n                  unsigned char *buf, int off);\nint ASN1_parse(BIO *bp, const unsigned char *pp, long len, int indent);\nint ASN1_parse_dump(BIO *bp, const unsigned char *pp, long len, int indent,\n                    int dump);\n# endif\nconst char *ASN1_tag2str(int tag);\n\n/* Used to load and write netscape format cert */\n\nDECLARE_ASN1_FUNCTIONS(NETSCAPE_X509)\n\nint ASN1_UNIVERSALSTRING_to_string(ASN1_UNIVERSALSTRING *s);\n\nint ASN1_TYPE_set_octetstring(ASN1_TYPE *a, unsigned char *data, int len);\nint ASN1_TYPE_get_octetstring(ASN1_TYPE *a, unsigned char *data, int max_len);\nint ASN1_TYPE_set_int_octetstring(ASN1_TYPE *a, long num,\n                                  unsigned char *data, int len);\nint ASN1_TYPE_get_int_octetstring(ASN1_TYPE *a, long *num,\n                                  unsigned char *data, int max_len);\n\nSTACK_OF(OPENSSL_BLOCK) *ASN1_seq_unpack(const unsigned char *buf, int len,\n                                         d2i_of_void *d2i,\n                                         void (*free_func) (OPENSSL_BLOCK));\nunsigned char *ASN1_seq_pack(STACK_OF(OPENSSL_BLOCK) *safes, i2d_of_void *i2d,\n                             unsigned char **buf, int *len);\nvoid *ASN1_unpack_string(ASN1_STRING *oct, d2i_of_void *d2i);\nvoid *ASN1_item_unpack(ASN1_STRING *oct, const ASN1_ITEM *it);\nASN1_STRING *ASN1_pack_string(void *obj, i2d_of_void *i2d,\n                              ASN1_OCTET_STRING **oct);\n\n# define ASN1_pack_string_of(type,obj,i2d,oct) \\\n    (ASN1_pack_string(CHECKED_PTR_OF(type, obj), \\\n                      CHECKED_I2D_OF(type, i2d), \\\n                      oct))\n\nASN1_STRING *ASN1_item_pack(void *obj, const ASN1_ITEM *it,\n                            ASN1_OCTET_STRING **oct);\n\nvoid ASN1_STRING_set_default_mask(unsigned long mask);\nint ASN1_STRING_set_default_mask_asc(const char *p);\nunsigned long ASN1_STRING_get_default_mask(void);\nint ASN1_mbstring_copy(ASN1_STRING **out, const unsigned char *in, int len,\n                       int inform, unsigned long mask);\nint ASN1_mbstring_ncopy(ASN1_STRING **out, const unsigned char *in, int len,\n                        int inform, unsigned long mask,\n                        long minsize, long maxsize);\n\nASN1_STRING *ASN1_STRING_set_by_NID(ASN1_STRING **out,\n                                    const unsigned char *in, int inlen,\n                                    int inform, int nid);\nASN1_STRING_TABLE *ASN1_STRING_TABLE_get(int nid);\nint ASN1_STRING_TABLE_add(int, long, long, unsigned long, unsigned long);\nvoid ASN1_STRING_TABLE_cleanup(void);\n\n/* ASN1 template functions */\n\n/* Old API compatible functions */\nASN1_VALUE *ASN1_item_new(const ASN1_ITEM *it);\nvoid ASN1_item_free(ASN1_VALUE *val, const ASN1_ITEM *it);\nASN1_VALUE *ASN1_item_d2i(ASN1_VALUE **val, const unsigned char **in,\n                          long len, const ASN1_ITEM *it);\nint ASN1_item_i2d(ASN1_VALUE *val, unsigned char **out, const ASN1_ITEM *it);\nint ASN1_item_ndef_i2d(ASN1_VALUE *val, unsigned char **out,\n                       const ASN1_ITEM *it);\n\nvoid ASN1_add_oid_module(void);\n\nASN1_TYPE *ASN1_generate_nconf(char *str, CONF *nconf);\nASN1_TYPE *ASN1_generate_v3(char *str, X509V3_CTX *cnf);\n\n/* ASN1 Print flags */\n\n/* Indicate missing OPTIONAL fields */\n# define ASN1_PCTX_FLAGS_SHOW_ABSENT             0x001\n/* Mark start and end of SEQUENCE */\n# define ASN1_PCTX_FLAGS_SHOW_SEQUENCE           0x002\n/* Mark start and end of SEQUENCE/SET OF */\n# define ASN1_PCTX_FLAGS_SHOW_SSOF               0x004\n/* Show the ASN1 type of primitives */\n# define ASN1_PCTX_FLAGS_SHOW_TYPE               0x008\n/* Don't show ASN1 type of ANY */\n# define ASN1_PCTX_FLAGS_NO_ANY_TYPE             0x010\n/* Don't show ASN1 type of MSTRINGs */\n# define ASN1_PCTX_FLAGS_NO_MSTRING_TYPE         0x020\n/* Don't show field names in SEQUENCE */\n# define ASN1_PCTX_FLAGS_NO_FIELD_NAME           0x040\n/* Show structure names of each SEQUENCE field */\n# define ASN1_PCTX_FLAGS_SHOW_FIELD_STRUCT_NAME  0x080\n/* Don't show structure name even at top level */\n# define ASN1_PCTX_FLAGS_NO_STRUCT_NAME          0x100\n\nint ASN1_item_print(BIO *out, ASN1_VALUE *ifld, int indent,\n                    const ASN1_ITEM *it, const ASN1_PCTX *pctx);\nASN1_PCTX *ASN1_PCTX_new(void);\nvoid ASN1_PCTX_free(ASN1_PCTX *p);\nunsigned long ASN1_PCTX_get_flags(ASN1_PCTX *p);\nvoid ASN1_PCTX_set_flags(ASN1_PCTX *p, unsigned long flags);\nunsigned long ASN1_PCTX_get_nm_flags(ASN1_PCTX *p);\nvoid ASN1_PCTX_set_nm_flags(ASN1_PCTX *p, unsigned long flags);\nunsigned long ASN1_PCTX_get_cert_flags(ASN1_PCTX *p);\nvoid ASN1_PCTX_set_cert_flags(ASN1_PCTX *p, unsigned long flags);\nunsigned long ASN1_PCTX_get_oid_flags(ASN1_PCTX *p);\nvoid ASN1_PCTX_set_oid_flags(ASN1_PCTX *p, unsigned long flags);\nunsigned long ASN1_PCTX_get_str_flags(ASN1_PCTX *p);\nvoid ASN1_PCTX_set_str_flags(ASN1_PCTX *p, unsigned long flags);\n\nBIO_METHOD *BIO_f_asn1(void);\n\nBIO *BIO_new_NDEF(BIO *out, ASN1_VALUE *val, const ASN1_ITEM *it);\n\nint i2d_ASN1_bio_stream(BIO *out, ASN1_VALUE *val, BIO *in, int flags,\n                        const ASN1_ITEM *it);\nint PEM_write_bio_ASN1_stream(BIO *out, ASN1_VALUE *val, BIO *in, int flags,\n                              const char *hdr, const ASN1_ITEM *it);\nint SMIME_write_ASN1(BIO *bio, ASN1_VALUE *val, BIO *data, int flags,\n                     int ctype_nid, int econt_nid,\n                     STACK_OF(X509_ALGOR) *mdalgs, const ASN1_ITEM *it);\nASN1_VALUE *SMIME_read_ASN1(BIO *bio, BIO **bcont, const ASN1_ITEM *it);\nint SMIME_crlf_copy(BIO *in, BIO *out, int flags);\nint SMIME_text(BIO *in, BIO *out);\n\n/* BEGIN ERROR CODES */\n/*\n * The following lines are auto generated by the script mkerr.pl. Any changes\n * made after this point may be overwritten when the script is next run.\n */\nvoid ERR_load_ASN1_strings(void);\n\n/* Error codes for the ASN1 functions. */\n\n/* Function codes. */\n# define ASN1_F_A2D_ASN1_OBJECT                           100\n# define ASN1_F_A2I_ASN1_ENUMERATED                       101\n# define ASN1_F_A2I_ASN1_INTEGER                          102\n# define ASN1_F_A2I_ASN1_STRING                           103\n# define ASN1_F_APPEND_EXP                                176\n# define ASN1_F_ASN1_BIT_STRING_SET_BIT                   183\n# define ASN1_F_ASN1_CB                                   177\n# define ASN1_F_ASN1_CHECK_TLEN                           104\n# define ASN1_F_ASN1_COLLATE_PRIMITIVE                    105\n# define ASN1_F_ASN1_COLLECT                              106\n# define ASN1_F_ASN1_D2I_EX_PRIMITIVE                     108\n# define ASN1_F_ASN1_D2I_FP                               109\n# define ASN1_F_ASN1_D2I_READ_BIO                         107\n# define ASN1_F_ASN1_DIGEST                               184\n# define ASN1_F_ASN1_DO_ADB                               110\n# define ASN1_F_ASN1_DUP                                  111\n# define ASN1_F_ASN1_ENUMERATED_SET                       112\n# define ASN1_F_ASN1_ENUMERATED_TO_BN                     113\n# define ASN1_F_ASN1_EX_C2I                               204\n# define ASN1_F_ASN1_FIND_END                             190\n# define ASN1_F_ASN1_GENERALIZEDTIME_ADJ                  216\n# define ASN1_F_ASN1_GENERALIZEDTIME_SET                  185\n# define ASN1_F_ASN1_GENERATE_V3                          178\n# define ASN1_F_ASN1_GET_OBJECT                           114\n# define ASN1_F_ASN1_HEADER_NEW                           115\n# define ASN1_F_ASN1_I2D_BIO                              116\n# define ASN1_F_ASN1_I2D_FP                               117\n# define ASN1_F_ASN1_INTEGER_SET                          118\n# define ASN1_F_ASN1_INTEGER_TO_BN                        119\n# define ASN1_F_ASN1_ITEM_D2I_FP                          206\n# define ASN1_F_ASN1_ITEM_DUP                             191\n# define ASN1_F_ASN1_ITEM_EX_COMBINE_NEW                  121\n# define ASN1_F_ASN1_ITEM_EX_D2I                          120\n# define ASN1_F_ASN1_ITEM_I2D_BIO                         192\n# define ASN1_F_ASN1_ITEM_I2D_FP                          193\n# define ASN1_F_ASN1_ITEM_PACK                            198\n# define ASN1_F_ASN1_ITEM_SIGN                            195\n# define ASN1_F_ASN1_ITEM_SIGN_CTX                        220\n# define ASN1_F_ASN1_ITEM_UNPACK                          199\n# define ASN1_F_ASN1_ITEM_VERIFY                          197\n# define ASN1_F_ASN1_MBSTRING_NCOPY                       122\n# define ASN1_F_ASN1_OBJECT_NEW                           123\n# define ASN1_F_ASN1_OUTPUT_DATA                          214\n# define ASN1_F_ASN1_PACK_STRING                          124\n# define ASN1_F_ASN1_PCTX_NEW                             205\n# define ASN1_F_ASN1_PKCS5_PBE_SET                        125\n# define ASN1_F_ASN1_SEQ_PACK                             126\n# define ASN1_F_ASN1_SEQ_UNPACK                           127\n# define ASN1_F_ASN1_SIGN                                 128\n# define ASN1_F_ASN1_STR2TYPE                             179\n# define ASN1_F_ASN1_STRING_SET                           186\n# define ASN1_F_ASN1_STRING_TABLE_ADD                     129\n# define ASN1_F_ASN1_STRING_TYPE_NEW                      130\n# define ASN1_F_ASN1_TEMPLATE_EX_D2I                      132\n# define ASN1_F_ASN1_TEMPLATE_NEW                         133\n# define ASN1_F_ASN1_TEMPLATE_NOEXP_D2I                   131\n# define ASN1_F_ASN1_TIME_ADJ                             217\n# define ASN1_F_ASN1_TIME_SET                             175\n# define ASN1_F_ASN1_TYPE_GET_INT_OCTETSTRING             134\n# define ASN1_F_ASN1_TYPE_GET_OCTETSTRING                 135\n# define ASN1_F_ASN1_UNPACK_STRING                        136\n# define ASN1_F_ASN1_UTCTIME_ADJ                          218\n# define ASN1_F_ASN1_UTCTIME_SET                          187\n# define ASN1_F_ASN1_VERIFY                               137\n# define ASN1_F_B64_READ_ASN1                             209\n# define ASN1_F_B64_WRITE_ASN1                            210\n# define ASN1_F_BIO_NEW_NDEF                              208\n# define ASN1_F_BITSTR_CB                                 180\n# define ASN1_F_BN_TO_ASN1_ENUMERATED                     138\n# define ASN1_F_BN_TO_ASN1_INTEGER                        139\n# define ASN1_F_C2I_ASN1_BIT_STRING                       189\n# define ASN1_F_C2I_ASN1_INTEGER                          194\n# define ASN1_F_C2I_ASN1_OBJECT                           196\n# define ASN1_F_COLLECT_DATA                              140\n# define ASN1_F_D2I_ASN1_BIT_STRING                       141\n# define ASN1_F_D2I_ASN1_BOOLEAN                          142\n# define ASN1_F_D2I_ASN1_BYTES                            143\n# define ASN1_F_D2I_ASN1_GENERALIZEDTIME                  144\n# define ASN1_F_D2I_ASN1_HEADER                           145\n# define ASN1_F_D2I_ASN1_INTEGER                          146\n# define ASN1_F_D2I_ASN1_OBJECT                           147\n# define ASN1_F_D2I_ASN1_SET                              148\n# define ASN1_F_D2I_ASN1_TYPE_BYTES                       149\n# define ASN1_F_D2I_ASN1_UINTEGER                         150\n# define ASN1_F_D2I_ASN1_UTCTIME                          151\n# define ASN1_F_D2I_AUTOPRIVATEKEY                        207\n# define ASN1_F_D2I_NETSCAPE_RSA                          152\n# define ASN1_F_D2I_NETSCAPE_RSA_2                        153\n# define ASN1_F_D2I_PRIVATEKEY                            154\n# define ASN1_F_D2I_PUBLICKEY                             155\n# define ASN1_F_D2I_RSA_NET                               200\n# define ASN1_F_D2I_RSA_NET_2                             201\n# define ASN1_F_D2I_X509                                  156\n# define ASN1_F_D2I_X509_CINF                             157\n# define ASN1_F_D2I_X509_PKEY                             159\n# define ASN1_F_I2D_ASN1_BIO_STREAM                       211\n# define ASN1_F_I2D_ASN1_SET                              188\n# define ASN1_F_I2D_ASN1_TIME                             160\n# define ASN1_F_I2D_DSA_PUBKEY                            161\n# define ASN1_F_I2D_EC_PUBKEY                             181\n# define ASN1_F_I2D_PRIVATEKEY                            163\n# define ASN1_F_I2D_PUBLICKEY                             164\n# define ASN1_F_I2D_RSA_NET                               162\n# define ASN1_F_I2D_RSA_PUBKEY                            165\n# define ASN1_F_LONG_C2I                                  166\n# define ASN1_F_OID_MODULE_INIT                           174\n# define ASN1_F_PARSE_TAGGING                             182\n# define ASN1_F_PKCS5_PBE2_SET_IV                         167\n# define ASN1_F_PKCS5_PBE_SET                             202\n# define ASN1_F_PKCS5_PBE_SET0_ALGOR                      215\n# define ASN1_F_PKCS5_PBKDF2_SET                          219\n# define ASN1_F_SMIME_READ_ASN1                           212\n# define ASN1_F_SMIME_TEXT                                213\n# define ASN1_F_X509_CINF_NEW                             168\n# define ASN1_F_X509_CRL_ADD0_REVOKED                     169\n# define ASN1_F_X509_INFO_NEW                             170\n# define ASN1_F_X509_NAME_ENCODE                          203\n# define ASN1_F_X509_NAME_EX_D2I                          158\n# define ASN1_F_X509_NAME_EX_NEW                          171\n# define ASN1_F_X509_NEW                                  172\n# define ASN1_F_X509_PKEY_NEW                             173\n\n/* Reason codes. */\n# define ASN1_R_ADDING_OBJECT                             171\n# define ASN1_R_ASN1_PARSE_ERROR                          203\n# define ASN1_R_ASN1_SIG_PARSE_ERROR                      204\n# define ASN1_R_AUX_ERROR                                 100\n# define ASN1_R_BAD_CLASS                                 101\n# define ASN1_R_BAD_OBJECT_HEADER                         102\n# define ASN1_R_BAD_PASSWORD_READ                         103\n# define ASN1_R_BAD_TAG                                   104\n# define ASN1_R_BMPSTRING_IS_WRONG_LENGTH                 214\n# define ASN1_R_BN_LIB                                    105\n# define ASN1_R_BOOLEAN_IS_WRONG_LENGTH                   106\n# define ASN1_R_BUFFER_TOO_SMALL                          107\n# define ASN1_R_CIPHER_HAS_NO_OBJECT_IDENTIFIER           108\n# define ASN1_R_CONTEXT_NOT_INITIALISED                   217\n# define ASN1_R_DATA_IS_WRONG                             109\n# define ASN1_R_DECODE_ERROR                              110\n# define ASN1_R_DECODING_ERROR                            111\n# define ASN1_R_DEPTH_EXCEEDED                            174\n# define ASN1_R_DIGEST_AND_KEY_TYPE_NOT_SUPPORTED         198\n# define ASN1_R_ENCODE_ERROR                              112\n# define ASN1_R_ERROR_GETTING_TIME                        173\n# define ASN1_R_ERROR_LOADING_SECTION                     172\n# define ASN1_R_ERROR_PARSING_SET_ELEMENT                 113\n# define ASN1_R_ERROR_SETTING_CIPHER_PARAMS               114\n# define ASN1_R_EXPECTING_AN_INTEGER                      115\n# define ASN1_R_EXPECTING_AN_OBJECT                       116\n# define ASN1_R_EXPECTING_A_BOOLEAN                       117\n# define ASN1_R_EXPECTING_A_TIME                          118\n# define ASN1_R_EXPLICIT_LENGTH_MISMATCH                  119\n# define ASN1_R_EXPLICIT_TAG_NOT_CONSTRUCTED              120\n# define ASN1_R_FIELD_MISSING                             121\n# define ASN1_R_FIRST_NUM_TOO_LARGE                       122\n# define ASN1_R_HEADER_TOO_LONG                           123\n# define ASN1_R_ILLEGAL_BITSTRING_FORMAT                  175\n# define ASN1_R_ILLEGAL_BOOLEAN                           176\n# define ASN1_R_ILLEGAL_CHARACTERS                        124\n# define ASN1_R_ILLEGAL_FORMAT                            177\n# define ASN1_R_ILLEGAL_HEX                               178\n# define ASN1_R_ILLEGAL_IMPLICIT_TAG                      179\n# define ASN1_R_ILLEGAL_INTEGER                           180\n# define ASN1_R_ILLEGAL_NESTED_TAGGING                    181\n# define ASN1_R_ILLEGAL_NULL                              125\n# define ASN1_R_ILLEGAL_NULL_VALUE                        182\n# define ASN1_R_ILLEGAL_OBJECT                            183\n# define ASN1_R_ILLEGAL_OPTIONAL_ANY                      126\n# define ASN1_R_ILLEGAL_OPTIONS_ON_ITEM_TEMPLATE          170\n# define ASN1_R_ILLEGAL_TAGGED_ANY                        127\n# define ASN1_R_ILLEGAL_TIME_VALUE                        184\n# define ASN1_R_INTEGER_NOT_ASCII_FORMAT                  185\n# define ASN1_R_INTEGER_TOO_LARGE_FOR_LONG                128\n# define ASN1_R_INVALID_BIT_STRING_BITS_LEFT              220\n# define ASN1_R_INVALID_BMPSTRING_LENGTH                  129\n# define ASN1_R_INVALID_DIGIT                             130\n# define ASN1_R_INVALID_MIME_TYPE                         205\n# define ASN1_R_INVALID_MODIFIER                          186\n# define ASN1_R_INVALID_NUMBER                            187\n# define ASN1_R_INVALID_OBJECT_ENCODING                   216\n# define ASN1_R_INVALID_SEPARATOR                         131\n# define ASN1_R_INVALID_TIME_FORMAT                       132\n# define ASN1_R_INVALID_UNIVERSALSTRING_LENGTH            133\n# define ASN1_R_INVALID_UTF8STRING                        134\n# define ASN1_R_IV_TOO_LARGE                              135\n# define ASN1_R_LENGTH_ERROR                              136\n# define ASN1_R_LIST_ERROR                                188\n# define ASN1_R_MIME_NO_CONTENT_TYPE                      206\n# define ASN1_R_MIME_PARSE_ERROR                          207\n# define ASN1_R_MIME_SIG_PARSE_ERROR                      208\n# define ASN1_R_MISSING_EOC                               137\n# define ASN1_R_MISSING_SECOND_NUMBER                     138\n# define ASN1_R_MISSING_VALUE                             189\n# define ASN1_R_MSTRING_NOT_UNIVERSAL                     139\n# define ASN1_R_MSTRING_WRONG_TAG                         140\n# define ASN1_R_NESTED_ASN1_STRING                        197\n# define ASN1_R_NON_HEX_CHARACTERS                        141\n# define ASN1_R_NOT_ASCII_FORMAT                          190\n# define ASN1_R_NOT_ENOUGH_DATA                           142\n# define ASN1_R_NO_CONTENT_TYPE                           209\n# define ASN1_R_NO_DEFAULT_DIGEST                         201\n# define ASN1_R_NO_MATCHING_CHOICE_TYPE                   143\n# define ASN1_R_NO_MULTIPART_BODY_FAILURE                 210\n# define ASN1_R_NO_MULTIPART_BOUNDARY                     211\n# define ASN1_R_NO_SIG_CONTENT_TYPE                       212\n# define ASN1_R_NULL_IS_WRONG_LENGTH                      144\n# define ASN1_R_OBJECT_NOT_ASCII_FORMAT                   191\n# define ASN1_R_ODD_NUMBER_OF_CHARS                       145\n# define ASN1_R_PRIVATE_KEY_HEADER_MISSING                146\n# define ASN1_R_SECOND_NUMBER_TOO_LARGE                   147\n# define ASN1_R_SEQUENCE_LENGTH_MISMATCH                  148\n# define ASN1_R_SEQUENCE_NOT_CONSTRUCTED                  149\n# define ASN1_R_SEQUENCE_OR_SET_NEEDS_CONFIG              192\n# define ASN1_R_SHORT_LINE                                150\n# define ASN1_R_SIG_INVALID_MIME_TYPE                     213\n# define ASN1_R_STREAMING_NOT_SUPPORTED                   202\n# define ASN1_R_STRING_TOO_LONG                           151\n# define ASN1_R_STRING_TOO_SHORT                          152\n# define ASN1_R_TAG_VALUE_TOO_HIGH                        153\n# define ASN1_R_THE_ASN1_OBJECT_IDENTIFIER_IS_NOT_KNOWN_FOR_THIS_MD 154\n# define ASN1_R_TIME_NOT_ASCII_FORMAT                     193\n# define ASN1_R_TOO_LONG                                  155\n# define ASN1_R_TYPE_NOT_CONSTRUCTED                      156\n# define ASN1_R_TYPE_NOT_PRIMITIVE                        218\n# define ASN1_R_UNABLE_TO_DECODE_RSA_KEY                  157\n# define ASN1_R_UNABLE_TO_DECODE_RSA_PRIVATE_KEY          158\n# define ASN1_R_UNEXPECTED_EOC                            159\n# define ASN1_R_UNIVERSALSTRING_IS_WRONG_LENGTH           215\n# define ASN1_R_UNKNOWN_FORMAT                            160\n# define ASN1_R_UNKNOWN_MESSAGE_DIGEST_ALGORITHM          161\n# define ASN1_R_UNKNOWN_OBJECT_TYPE                       162\n# define ASN1_R_UNKNOWN_PUBLIC_KEY_TYPE                   163\n# define ASN1_R_UNKNOWN_SIGNATURE_ALGORITHM               199\n# define ASN1_R_UNKNOWN_TAG                               194\n# define ASN1_R_UNKOWN_FORMAT                             195\n# define ASN1_R_UNSUPPORTED_ANY_DEFINED_BY_TYPE           164\n# define ASN1_R_UNSUPPORTED_CIPHER                        165\n# define ASN1_R_UNSUPPORTED_ENCRYPTION_ALGORITHM          166\n# define ASN1_R_UNSUPPORTED_PUBLIC_KEY_TYPE               167\n# define ASN1_R_UNSUPPORTED_TYPE                          196\n# define ASN1_R_WRONG_PUBLIC_KEY_TYPE                     200\n# define ASN1_R_WRONG_TAG                                 168\n# define ASN1_R_WRONG_TYPE                                169\n\n#ifdef  __cplusplus\n}\n#endif\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/x86/include/openssl/asn1_mac.h",
    "content": "/* crypto/asn1/asn1_mac.h */\n/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)\n * All rights reserved.\n *\n * This package is an SSL implementation written\n * by Eric Young (eay@cryptsoft.com).\n * The implementation was written so as to conform with Netscapes SSL.\n *\n * This library is free for commercial and non-commercial use as long as\n * the following conditions are aheared to.  The following conditions\n * apply to all code found in this distribution, be it the RC4, RSA,\n * lhash, DES, etc., code; not just the SSL code.  The SSL documentation\n * included with this distribution is covered by the same copyright terms\n * except that the holder is Tim Hudson (tjh@cryptsoft.com).\n *\n * Copyright remains Eric Young's, and as such any Copyright notices in\n * the code are not to be removed.\n * If this package is used in a product, Eric Young should be given attribution\n * as the author of the parts of the library used.\n * This can be in the form of a textual message at program startup or\n * in documentation (online or textual) provided with the package.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the copyright\n *    notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in the\n *    documentation and/or other materials provided with the distribution.\n * 3. All advertising materials mentioning features or use of this software\n *    must display the following acknowledgement:\n *    \"This product includes cryptographic software written by\n *     Eric Young (eay@cryptsoft.com)\"\n *    The word 'cryptographic' can be left out if the rouines from the library\n *    being used are not cryptographic related :-).\n * 4. If you include any Windows specific code (or a derivative thereof) from\n *    the apps directory (application code) you must include an acknowledgement:\n *    \"This product includes software written by Tim Hudson (tjh@cryptsoft.com)\"\n *\n * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n * SUCH DAMAGE.\n *\n * The licence and distribution terms for any publically available version or\n * derivative of this code cannot be changed.  i.e. this code cannot simply be\n * copied and put under another distribution licence\n * [including the GNU Public Licence.]\n */\n\n#ifndef HEADER_ASN1_MAC_H\n# define HEADER_ASN1_MAC_H\n\n# include <openssl/asn1.h>\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n# ifndef ASN1_MAC_ERR_LIB\n#  define ASN1_MAC_ERR_LIB        ERR_LIB_ASN1\n# endif\n\n# define ASN1_MAC_H_err(f,r,line) \\\n        ERR_PUT_error(ASN1_MAC_ERR_LIB,(f),(r),__FILE__,(line))\n\n# define M_ASN1_D2I_vars(a,type,func) \\\n        ASN1_const_CTX c; \\\n        type ret=NULL; \\\n        \\\n        c.pp=(const unsigned char **)pp; \\\n        c.q= *(const unsigned char **)pp; \\\n        c.error=ERR_R_NESTED_ASN1_ERROR; \\\n        if ((a == NULL) || ((*a) == NULL)) \\\n                { if ((ret=(type)func()) == NULL) \\\n                        { c.line=__LINE__; goto err; } } \\\n        else    ret=(*a);\n\n# define M_ASN1_D2I_Init() \\\n        c.p= *(const unsigned char **)pp; \\\n        c.max=(length == 0)?0:(c.p+length);\n\n# define M_ASN1_D2I_Finish_2(a) \\\n        if (!asn1_const_Finish(&c)) \\\n                { c.line=__LINE__; goto err; } \\\n        *(const unsigned char **)pp=c.p; \\\n        if (a != NULL) (*a)=ret; \\\n        return(ret);\n\n# define M_ASN1_D2I_Finish(a,func,e) \\\n        M_ASN1_D2I_Finish_2(a); \\\nerr:\\\n        ASN1_MAC_H_err((e),c.error,c.line); \\\n        asn1_add_error(*(const unsigned char **)pp,(int)(c.q- *pp)); \\\n        if ((ret != NULL) && ((a == NULL) || (*a != ret))) func(ret); \\\n        return(NULL)\n\n# define M_ASN1_D2I_start_sequence() \\\n        if (!asn1_GetSequence(&c,&length)) \\\n                { c.line=__LINE__; goto err; }\n/* Begin reading ASN1 without a surrounding sequence */\n# define M_ASN1_D2I_begin() \\\n        c.slen = length;\n\n/* End reading ASN1 with no check on length */\n# define M_ASN1_D2I_Finish_nolen(a, func, e) \\\n        *pp=c.p; \\\n        if (a != NULL) (*a)=ret; \\\n        return(ret); \\\nerr:\\\n        ASN1_MAC_H_err((e),c.error,c.line); \\\n        asn1_add_error(*pp,(int)(c.q- *pp)); \\\n        if ((ret != NULL) && ((a == NULL) || (*a != ret))) func(ret); \\\n        return(NULL)\n\n# define M_ASN1_D2I_end_sequence() \\\n        (((c.inf&1) == 0)?(c.slen <= 0): \\\n                (c.eos=ASN1_const_check_infinite_end(&c.p,c.slen)))\n\n/* Don't use this with d2i_ASN1_BOOLEAN() */\n# define M_ASN1_D2I_get(b, func) \\\n        c.q=c.p; \\\n        if (func(&(b),&c.p,c.slen) == NULL) \\\n                {c.line=__LINE__; goto err; } \\\n        c.slen-=(c.p-c.q);\n\n/* Don't use this with d2i_ASN1_BOOLEAN() */\n# define M_ASN1_D2I_get_x(type,b,func) \\\n        c.q=c.p; \\\n        if (((D2I_OF(type))func)(&(b),&c.p,c.slen) == NULL) \\\n                {c.line=__LINE__; goto err; } \\\n        c.slen-=(c.p-c.q);\n\n/* use this instead () */\n# define M_ASN1_D2I_get_int(b,func) \\\n        c.q=c.p; \\\n        if (func(&(b),&c.p,c.slen) < 0) \\\n                {c.line=__LINE__; goto err; } \\\n        c.slen-=(c.p-c.q);\n\n# define M_ASN1_D2I_get_opt(b,func,type) \\\n        if ((c.slen != 0) && ((M_ASN1_next & (~V_ASN1_CONSTRUCTED)) \\\n                == (V_ASN1_UNIVERSAL|(type)))) \\\n                { \\\n                M_ASN1_D2I_get(b,func); \\\n                }\n\n# define M_ASN1_D2I_get_int_opt(b,func,type) \\\n        if ((c.slen != 0) && ((M_ASN1_next & (~V_ASN1_CONSTRUCTED)) \\\n                == (V_ASN1_UNIVERSAL|(type)))) \\\n                { \\\n                M_ASN1_D2I_get_int(b,func); \\\n                }\n\n# define M_ASN1_D2I_get_imp(b,func, type) \\\n        M_ASN1_next=(_tmp& V_ASN1_CONSTRUCTED)|type; \\\n        c.q=c.p; \\\n        if (func(&(b),&c.p,c.slen) == NULL) \\\n                {c.line=__LINE__; M_ASN1_next_prev = _tmp; goto err; } \\\n        c.slen-=(c.p-c.q);\\\n        M_ASN1_next_prev=_tmp;\n\n# define M_ASN1_D2I_get_IMP_opt(b,func,tag,type) \\\n        if ((c.slen != 0) && ((M_ASN1_next & (~V_ASN1_CONSTRUCTED)) == \\\n                (V_ASN1_CONTEXT_SPECIFIC|(tag)))) \\\n                { \\\n                unsigned char _tmp = M_ASN1_next; \\\n                M_ASN1_D2I_get_imp(b,func, type);\\\n                }\n\n# define M_ASN1_D2I_get_set(r,func,free_func) \\\n                M_ASN1_D2I_get_imp_set(r,func,free_func, \\\n                        V_ASN1_SET,V_ASN1_UNIVERSAL);\n\n# define M_ASN1_D2I_get_set_type(type,r,func,free_func) \\\n                M_ASN1_D2I_get_imp_set_type(type,r,func,free_func, \\\n                        V_ASN1_SET,V_ASN1_UNIVERSAL);\n\n# define M_ASN1_D2I_get_set_opt(r,func,free_func) \\\n        if ((c.slen != 0) && (M_ASN1_next == (V_ASN1_UNIVERSAL| \\\n                V_ASN1_CONSTRUCTED|V_ASN1_SET)))\\\n                { M_ASN1_D2I_get_set(r,func,free_func); }\n\n# define M_ASN1_D2I_get_set_opt_type(type,r,func,free_func) \\\n        if ((c.slen != 0) && (M_ASN1_next == (V_ASN1_UNIVERSAL| \\\n                V_ASN1_CONSTRUCTED|V_ASN1_SET)))\\\n                { M_ASN1_D2I_get_set_type(type,r,func,free_func); }\n\n# define M_ASN1_I2D_len_SET_opt(a,f) \\\n        if ((a != NULL) && (sk_num(a) != 0)) \\\n                M_ASN1_I2D_len_SET(a,f);\n\n# define M_ASN1_I2D_put_SET_opt(a,f) \\\n        if ((a != NULL) && (sk_num(a) != 0)) \\\n                M_ASN1_I2D_put_SET(a,f);\n\n# define M_ASN1_I2D_put_SEQUENCE_opt(a,f) \\\n        if ((a != NULL) && (sk_num(a) != 0)) \\\n                M_ASN1_I2D_put_SEQUENCE(a,f);\n\n# define M_ASN1_I2D_put_SEQUENCE_opt_type(type,a,f) \\\n        if ((a != NULL) && (sk_##type##_num(a) != 0)) \\\n                M_ASN1_I2D_put_SEQUENCE_type(type,a,f);\n\n# define M_ASN1_D2I_get_IMP_set_opt(b,func,free_func,tag) \\\n        if ((c.slen != 0) && \\\n                (M_ASN1_next == \\\n                (V_ASN1_CONTEXT_SPECIFIC|V_ASN1_CONSTRUCTED|(tag))))\\\n                { \\\n                M_ASN1_D2I_get_imp_set(b,func,free_func,\\\n                        tag,V_ASN1_CONTEXT_SPECIFIC); \\\n                }\n\n# define M_ASN1_D2I_get_IMP_set_opt_type(type,b,func,free_func,tag) \\\n        if ((c.slen != 0) && \\\n                (M_ASN1_next == \\\n                (V_ASN1_CONTEXT_SPECIFIC|V_ASN1_CONSTRUCTED|(tag))))\\\n                { \\\n                M_ASN1_D2I_get_imp_set_type(type,b,func,free_func,\\\n                        tag,V_ASN1_CONTEXT_SPECIFIC); \\\n                }\n\n# define M_ASN1_D2I_get_seq(r,func,free_func) \\\n                M_ASN1_D2I_get_imp_set(r,func,free_func,\\\n                        V_ASN1_SEQUENCE,V_ASN1_UNIVERSAL);\n\n# define M_ASN1_D2I_get_seq_type(type,r,func,free_func) \\\n                M_ASN1_D2I_get_imp_set_type(type,r,func,free_func,\\\n                                            V_ASN1_SEQUENCE,V_ASN1_UNIVERSAL)\n\n# define M_ASN1_D2I_get_seq_opt(r,func,free_func) \\\n        if ((c.slen != 0) && (M_ASN1_next == (V_ASN1_UNIVERSAL| \\\n                V_ASN1_CONSTRUCTED|V_ASN1_SEQUENCE)))\\\n                { M_ASN1_D2I_get_seq(r,func,free_func); }\n\n# define M_ASN1_D2I_get_seq_opt_type(type,r,func,free_func) \\\n        if ((c.slen != 0) && (M_ASN1_next == (V_ASN1_UNIVERSAL| \\\n                V_ASN1_CONSTRUCTED|V_ASN1_SEQUENCE)))\\\n                { M_ASN1_D2I_get_seq_type(type,r,func,free_func); }\n\n# define M_ASN1_D2I_get_IMP_set(r,func,free_func,x) \\\n                M_ASN1_D2I_get_imp_set(r,func,free_func,\\\n                        x,V_ASN1_CONTEXT_SPECIFIC);\n\n# define M_ASN1_D2I_get_IMP_set_type(type,r,func,free_func,x) \\\n                M_ASN1_D2I_get_imp_set_type(type,r,func,free_func,\\\n                        x,V_ASN1_CONTEXT_SPECIFIC);\n\n# define M_ASN1_D2I_get_imp_set(r,func,free_func,a,b) \\\n        c.q=c.p; \\\n        if (d2i_ASN1_SET(&(r),&c.p,c.slen,(char *(*)())func,\\\n                (void (*)())free_func,a,b) == NULL) \\\n                { c.line=__LINE__; goto err; } \\\n        c.slen-=(c.p-c.q);\n\n# define M_ASN1_D2I_get_imp_set_type(type,r,func,free_func,a,b) \\\n        c.q=c.p; \\\n        if (d2i_ASN1_SET_OF_##type(&(r),&c.p,c.slen,func,\\\n                                   free_func,a,b) == NULL) \\\n                { c.line=__LINE__; goto err; } \\\n        c.slen-=(c.p-c.q);\n\n# define M_ASN1_D2I_get_set_strings(r,func,a,b) \\\n        c.q=c.p; \\\n        if (d2i_ASN1_STRING_SET(&(r),&c.p,c.slen,a,b) == NULL) \\\n                { c.line=__LINE__; goto err; } \\\n        c.slen-=(c.p-c.q);\n\n# define M_ASN1_D2I_get_EXP_opt(r,func,tag) \\\n        if ((c.slen != 0L) && (M_ASN1_next == \\\n                (V_ASN1_CONSTRUCTED|V_ASN1_CONTEXT_SPECIFIC|tag))) \\\n                { \\\n                int Tinf,Ttag,Tclass; \\\n                long Tlen; \\\n                \\\n                c.q=c.p; \\\n                Tinf=ASN1_get_object(&c.p,&Tlen,&Ttag,&Tclass,c.slen); \\\n                if (Tinf & 0x80) \\\n                        { c.error=ERR_R_BAD_ASN1_OBJECT_HEADER; \\\n                        c.line=__LINE__; goto err; } \\\n                if (Tinf == (V_ASN1_CONSTRUCTED+1)) \\\n                                        Tlen = c.slen - (c.p - c.q) - 2; \\\n                if (func(&(r),&c.p,Tlen) == NULL) \\\n                        { c.line=__LINE__; goto err; } \\\n                if (Tinf == (V_ASN1_CONSTRUCTED+1)) { \\\n                        Tlen = c.slen - (c.p - c.q); \\\n                        if(!ASN1_const_check_infinite_end(&c.p, Tlen)) \\\n                                { c.error=ERR_R_MISSING_ASN1_EOS; \\\n                                c.line=__LINE__; goto err; } \\\n                }\\\n                c.slen-=(c.p-c.q); \\\n                }\n\n# define M_ASN1_D2I_get_EXP_set_opt(r,func,free_func,tag,b) \\\n        if ((c.slen != 0) && (M_ASN1_next == \\\n                (V_ASN1_CONSTRUCTED|V_ASN1_CONTEXT_SPECIFIC|tag))) \\\n                { \\\n                int Tinf,Ttag,Tclass; \\\n                long Tlen; \\\n                \\\n                c.q=c.p; \\\n                Tinf=ASN1_get_object(&c.p,&Tlen,&Ttag,&Tclass,c.slen); \\\n                if (Tinf & 0x80) \\\n                        { c.error=ERR_R_BAD_ASN1_OBJECT_HEADER; \\\n                        c.line=__LINE__; goto err; } \\\n                if (Tinf == (V_ASN1_CONSTRUCTED+1)) \\\n                                        Tlen = c.slen - (c.p - c.q) - 2; \\\n                if (d2i_ASN1_SET(&(r),&c.p,Tlen,(char *(*)())func, \\\n                        (void (*)())free_func, \\\n                        b,V_ASN1_UNIVERSAL) == NULL) \\\n                        { c.line=__LINE__; goto err; } \\\n                if (Tinf == (V_ASN1_CONSTRUCTED+1)) { \\\n                        Tlen = c.slen - (c.p - c.q); \\\n                        if(!ASN1_check_infinite_end(&c.p, Tlen)) \\\n                                { c.error=ERR_R_MISSING_ASN1_EOS; \\\n                                c.line=__LINE__; goto err; } \\\n                }\\\n                c.slen-=(c.p-c.q); \\\n                }\n\n# define M_ASN1_D2I_get_EXP_set_opt_type(type,r,func,free_func,tag,b) \\\n        if ((c.slen != 0) && (M_ASN1_next == \\\n                (V_ASN1_CONSTRUCTED|V_ASN1_CONTEXT_SPECIFIC|tag))) \\\n                { \\\n                int Tinf,Ttag,Tclass; \\\n                long Tlen; \\\n                \\\n                c.q=c.p; \\\n                Tinf=ASN1_get_object(&c.p,&Tlen,&Ttag,&Tclass,c.slen); \\\n                if (Tinf & 0x80) \\\n                        { c.error=ERR_R_BAD_ASN1_OBJECT_HEADER; \\\n                        c.line=__LINE__; goto err; } \\\n                if (Tinf == (V_ASN1_CONSTRUCTED+1)) \\\n                                        Tlen = c.slen - (c.p - c.q) - 2; \\\n                if (d2i_ASN1_SET_OF_##type(&(r),&c.p,Tlen,func, \\\n                        free_func,b,V_ASN1_UNIVERSAL) == NULL) \\\n                        { c.line=__LINE__; goto err; } \\\n                if (Tinf == (V_ASN1_CONSTRUCTED+1)) { \\\n                        Tlen = c.slen - (c.p - c.q); \\\n                        if(!ASN1_check_infinite_end(&c.p, Tlen)) \\\n                                { c.error=ERR_R_MISSING_ASN1_EOS; \\\n                                c.line=__LINE__; goto err; } \\\n                }\\\n                c.slen-=(c.p-c.q); \\\n                }\n\n/* New macros */\n# define M_ASN1_New_Malloc(ret,type) \\\n        if ((ret=(type *)OPENSSL_malloc(sizeof(type))) == NULL) \\\n                { c.line=__LINE__; goto err2; }\n\n# define M_ASN1_New(arg,func) \\\n        if (((arg)=func()) == NULL) return(NULL)\n\n# define M_ASN1_New_Error(a) \\\n/*-     err:    ASN1_MAC_H_err((a),ERR_R_NESTED_ASN1_ERROR,c.line); \\\n                return(NULL);*/ \\\n        err2:   ASN1_MAC_H_err((a),ERR_R_MALLOC_FAILURE,c.line); \\\n                return(NULL)\n\n/*\n * BIG UGLY WARNING! This is so damn ugly I wanna puke.  Unfortunately, some\n * macros that use ASN1_const_CTX still insist on writing in the input\n * stream.  ARGH! ARGH! ARGH! Let's get rid of this macro package. Please? --\n * Richard Levitte\n */\n# define M_ASN1_next             (*((unsigned char *)(c.p)))\n# define M_ASN1_next_prev        (*((unsigned char *)(c.q)))\n\n/*************************************************/\n\n# define M_ASN1_I2D_vars(a)      int r=0,ret=0; \\\n                                unsigned char *p; \\\n                                if (a == NULL) return(0)\n\n/* Length Macros */\n# define M_ASN1_I2D_len(a,f)     ret+=f(a,NULL)\n# define M_ASN1_I2D_len_IMP_opt(a,f)     if (a != NULL) M_ASN1_I2D_len(a,f)\n\n# define M_ASN1_I2D_len_SET(a,f) \\\n                ret+=i2d_ASN1_SET(a,NULL,f,V_ASN1_SET,V_ASN1_UNIVERSAL,IS_SET);\n\n# define M_ASN1_I2D_len_SET_type(type,a,f) \\\n                ret+=i2d_ASN1_SET_OF_##type(a,NULL,f,V_ASN1_SET, \\\n                                            V_ASN1_UNIVERSAL,IS_SET);\n\n# define M_ASN1_I2D_len_SEQUENCE(a,f) \\\n                ret+=i2d_ASN1_SET(a,NULL,f,V_ASN1_SEQUENCE,V_ASN1_UNIVERSAL, \\\n                                  IS_SEQUENCE);\n\n# define M_ASN1_I2D_len_SEQUENCE_type(type,a,f) \\\n                ret+=i2d_ASN1_SET_OF_##type(a,NULL,f,V_ASN1_SEQUENCE, \\\n                                            V_ASN1_UNIVERSAL,IS_SEQUENCE)\n\n# define M_ASN1_I2D_len_SEQUENCE_opt(a,f) \\\n                if ((a != NULL) && (sk_num(a) != 0)) \\\n                        M_ASN1_I2D_len_SEQUENCE(a,f);\n\n# define M_ASN1_I2D_len_SEQUENCE_opt_type(type,a,f) \\\n                if ((a != NULL) && (sk_##type##_num(a) != 0)) \\\n                        M_ASN1_I2D_len_SEQUENCE_type(type,a,f);\n\n# define M_ASN1_I2D_len_IMP_SET(a,f,x) \\\n                ret+=i2d_ASN1_SET(a,NULL,f,x,V_ASN1_CONTEXT_SPECIFIC,IS_SET);\n\n# define M_ASN1_I2D_len_IMP_SET_type(type,a,f,x) \\\n                ret+=i2d_ASN1_SET_OF_##type(a,NULL,f,x, \\\n                                            V_ASN1_CONTEXT_SPECIFIC,IS_SET);\n\n# define M_ASN1_I2D_len_IMP_SET_opt(a,f,x) \\\n                if ((a != NULL) && (sk_num(a) != 0)) \\\n                        ret+=i2d_ASN1_SET(a,NULL,f,x,V_ASN1_CONTEXT_SPECIFIC, \\\n                                          IS_SET);\n\n# define M_ASN1_I2D_len_IMP_SET_opt_type(type,a,f,x) \\\n                if ((a != NULL) && (sk_##type##_num(a) != 0)) \\\n                        ret+=i2d_ASN1_SET_OF_##type(a,NULL,f,x, \\\n                                               V_ASN1_CONTEXT_SPECIFIC,IS_SET);\n\n# define M_ASN1_I2D_len_IMP_SEQUENCE(a,f,x) \\\n                ret+=i2d_ASN1_SET(a,NULL,f,x,V_ASN1_CONTEXT_SPECIFIC, \\\n                                  IS_SEQUENCE);\n\n# define M_ASN1_I2D_len_IMP_SEQUENCE_opt(a,f,x) \\\n                if ((a != NULL) && (sk_num(a) != 0)) \\\n                        ret+=i2d_ASN1_SET(a,NULL,f,x,V_ASN1_CONTEXT_SPECIFIC, \\\n                                          IS_SEQUENCE);\n\n# define M_ASN1_I2D_len_IMP_SEQUENCE_opt_type(type,a,f,x) \\\n                if ((a != NULL) && (sk_##type##_num(a) != 0)) \\\n                        ret+=i2d_ASN1_SET_OF_##type(a,NULL,f,x, \\\n                                                    V_ASN1_CONTEXT_SPECIFIC, \\\n                                                    IS_SEQUENCE);\n\n# define M_ASN1_I2D_len_EXP_opt(a,f,mtag,v) \\\n                if (a != NULL)\\\n                        { \\\n                        v=f(a,NULL); \\\n                        ret+=ASN1_object_size(1,v,mtag); \\\n                        }\n\n# define M_ASN1_I2D_len_EXP_SET_opt(a,f,mtag,tag,v) \\\n                if ((a != NULL) && (sk_num(a) != 0))\\\n                        { \\\n                        v=i2d_ASN1_SET(a,NULL,f,tag,V_ASN1_UNIVERSAL,IS_SET); \\\n                        ret+=ASN1_object_size(1,v,mtag); \\\n                        }\n\n# define M_ASN1_I2D_len_EXP_SEQUENCE_opt(a,f,mtag,tag,v) \\\n                if ((a != NULL) && (sk_num(a) != 0))\\\n                        { \\\n                        v=i2d_ASN1_SET(a,NULL,f,tag,V_ASN1_UNIVERSAL, \\\n                                       IS_SEQUENCE); \\\n                        ret+=ASN1_object_size(1,v,mtag); \\\n                        }\n\n# define M_ASN1_I2D_len_EXP_SEQUENCE_opt_type(type,a,f,mtag,tag,v) \\\n                if ((a != NULL) && (sk_##type##_num(a) != 0))\\\n                        { \\\n                        v=i2d_ASN1_SET_OF_##type(a,NULL,f,tag, \\\n                                                 V_ASN1_UNIVERSAL, \\\n                                                 IS_SEQUENCE); \\\n                        ret+=ASN1_object_size(1,v,mtag); \\\n                        }\n\n/* Put Macros */\n# define M_ASN1_I2D_put(a,f)     f(a,&p)\n\n# define M_ASN1_I2D_put_IMP_opt(a,f,t)   \\\n                if (a != NULL) \\\n                        { \\\n                        unsigned char *q=p; \\\n                        f(a,&p); \\\n                        *q=(V_ASN1_CONTEXT_SPECIFIC|t|(*q&V_ASN1_CONSTRUCTED));\\\n                        }\n\n# define M_ASN1_I2D_put_SET(a,f) i2d_ASN1_SET(a,&p,f,V_ASN1_SET,\\\n                        V_ASN1_UNIVERSAL,IS_SET)\n# define M_ASN1_I2D_put_SET_type(type,a,f) \\\n     i2d_ASN1_SET_OF_##type(a,&p,f,V_ASN1_SET,V_ASN1_UNIVERSAL,IS_SET)\n# define M_ASN1_I2D_put_IMP_SET(a,f,x) i2d_ASN1_SET(a,&p,f,x,\\\n                        V_ASN1_CONTEXT_SPECIFIC,IS_SET)\n# define M_ASN1_I2D_put_IMP_SET_type(type,a,f,x) \\\n     i2d_ASN1_SET_OF_##type(a,&p,f,x,V_ASN1_CONTEXT_SPECIFIC,IS_SET)\n# define M_ASN1_I2D_put_IMP_SEQUENCE(a,f,x) i2d_ASN1_SET(a,&p,f,x,\\\n                        V_ASN1_CONTEXT_SPECIFIC,IS_SEQUENCE)\n\n# define M_ASN1_I2D_put_SEQUENCE(a,f) i2d_ASN1_SET(a,&p,f,V_ASN1_SEQUENCE,\\\n                                             V_ASN1_UNIVERSAL,IS_SEQUENCE)\n\n# define M_ASN1_I2D_put_SEQUENCE_type(type,a,f) \\\n     i2d_ASN1_SET_OF_##type(a,&p,f,V_ASN1_SEQUENCE,V_ASN1_UNIVERSAL, \\\n                            IS_SEQUENCE)\n\n# define M_ASN1_I2D_put_SEQUENCE_opt(a,f) \\\n                if ((a != NULL) && (sk_num(a) != 0)) \\\n                        M_ASN1_I2D_put_SEQUENCE(a,f);\n\n# define M_ASN1_I2D_put_IMP_SET_opt(a,f,x) \\\n                if ((a != NULL) && (sk_num(a) != 0)) \\\n                        { i2d_ASN1_SET(a,&p,f,x,V_ASN1_CONTEXT_SPECIFIC, \\\n                                       IS_SET); }\n\n# define M_ASN1_I2D_put_IMP_SET_opt_type(type,a,f,x) \\\n                if ((a != NULL) && (sk_##type##_num(a) != 0)) \\\n                        { i2d_ASN1_SET_OF_##type(a,&p,f,x, \\\n                                                 V_ASN1_CONTEXT_SPECIFIC, \\\n                                                 IS_SET); }\n\n# define M_ASN1_I2D_put_IMP_SEQUENCE_opt(a,f,x) \\\n                if ((a != NULL) && (sk_num(a) != 0)) \\\n                        { i2d_ASN1_SET(a,&p,f,x,V_ASN1_CONTEXT_SPECIFIC, \\\n                                       IS_SEQUENCE); }\n\n# define M_ASN1_I2D_put_IMP_SEQUENCE_opt_type(type,a,f,x) \\\n                if ((a != NULL) && (sk_##type##_num(a) != 0)) \\\n                        { i2d_ASN1_SET_OF_##type(a,&p,f,x, \\\n                                                 V_ASN1_CONTEXT_SPECIFIC, \\\n                                                 IS_SEQUENCE); }\n\n# define M_ASN1_I2D_put_EXP_opt(a,f,tag,v) \\\n                if (a != NULL) \\\n                        { \\\n                        ASN1_put_object(&p,1,v,tag,V_ASN1_CONTEXT_SPECIFIC); \\\n                        f(a,&p); \\\n                        }\n\n# define M_ASN1_I2D_put_EXP_SET_opt(a,f,mtag,tag,v) \\\n                if ((a != NULL) && (sk_num(a) != 0)) \\\n                        { \\\n                        ASN1_put_object(&p,1,v,mtag,V_ASN1_CONTEXT_SPECIFIC); \\\n                        i2d_ASN1_SET(a,&p,f,tag,V_ASN1_UNIVERSAL,IS_SET); \\\n                        }\n\n# define M_ASN1_I2D_put_EXP_SEQUENCE_opt(a,f,mtag,tag,v) \\\n                if ((a != NULL) && (sk_num(a) != 0)) \\\n                        { \\\n                        ASN1_put_object(&p,1,v,mtag,V_ASN1_CONTEXT_SPECIFIC); \\\n                        i2d_ASN1_SET(a,&p,f,tag,V_ASN1_UNIVERSAL,IS_SEQUENCE); \\\n                        }\n\n# define M_ASN1_I2D_put_EXP_SEQUENCE_opt_type(type,a,f,mtag,tag,v) \\\n                if ((a != NULL) && (sk_##type##_num(a) != 0)) \\\n                        { \\\n                        ASN1_put_object(&p,1,v,mtag,V_ASN1_CONTEXT_SPECIFIC); \\\n                        i2d_ASN1_SET_OF_##type(a,&p,f,tag,V_ASN1_UNIVERSAL, \\\n                                               IS_SEQUENCE); \\\n                        }\n\n# define M_ASN1_I2D_seq_total() \\\n                r=ASN1_object_size(1,ret,V_ASN1_SEQUENCE); \\\n                if (pp == NULL) return(r); \\\n                p= *pp; \\\n                ASN1_put_object(&p,1,ret,V_ASN1_SEQUENCE,V_ASN1_UNIVERSAL)\n\n# define M_ASN1_I2D_INF_seq_start(tag,ctx) \\\n                *(p++)=(V_ASN1_CONSTRUCTED|(tag)|(ctx)); \\\n                *(p++)=0x80\n\n# define M_ASN1_I2D_INF_seq_end() *(p++)=0x00; *(p++)=0x00\n\n# define M_ASN1_I2D_finish()     *pp=p; \\\n                                return(r);\n\nint asn1_GetSequence(ASN1_const_CTX *c, long *length);\nvoid asn1_add_error(const unsigned char *address, int offset);\n#ifdef  __cplusplus\n}\n#endif\n\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/x86/include/openssl/asn1t.h",
    "content": "/* asn1t.h */\n/*\n * Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL project\n * 2000.\n */\n/* ====================================================================\n * Copyright (c) 2000-2005 The OpenSSL Project.  All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n *\n * 1. Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n *\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in\n *    the documentation and/or other materials provided with the\n *    distribution.\n *\n * 3. All advertising materials mentioning features or use of this\n *    software must display the following acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)\"\n *\n * 4. The names \"OpenSSL Toolkit\" and \"OpenSSL Project\" must not be used to\n *    endorse or promote products derived from this software without\n *    prior written permission. For written permission, please contact\n *    licensing@OpenSSL.org.\n *\n * 5. Products derived from this software may not be called \"OpenSSL\"\n *    nor may \"OpenSSL\" appear in their names without prior written\n *    permission of the OpenSSL Project.\n *\n * 6. Redistributions of any form whatsoever must retain the following\n *    acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)\"\n *\n * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY\n * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\n * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR\n * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\n * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,\n * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED\n * OF THE POSSIBILITY OF SUCH DAMAGE.\n * ====================================================================\n *\n * This product includes cryptographic software written by Eric Young\n * (eay@cryptsoft.com).  This product includes software written by Tim\n * Hudson (tjh@cryptsoft.com).\n *\n */\n#ifndef HEADER_ASN1T_H\n# define HEADER_ASN1T_H\n\n# include <stddef.h>\n# include <openssl/e_os2.h>\n# include <openssl/asn1.h>\n\n# ifdef OPENSSL_BUILD_SHLIBCRYPTO\n#  undef OPENSSL_EXTERN\n#  define OPENSSL_EXTERN OPENSSL_EXPORT\n# endif\n\n/* ASN1 template defines, structures and functions */\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n# ifndef OPENSSL_EXPORT_VAR_AS_FUNCTION\n\n/* Macro to obtain ASN1_ADB pointer from a type (only used internally) */\n#  define ASN1_ADB_ptr(iptr) ((const ASN1_ADB *)(iptr))\n\n/* Macros for start and end of ASN1_ITEM definition */\n\n#  define ASN1_ITEM_start(itname) \\\n        OPENSSL_GLOBAL const ASN1_ITEM itname##_it = {\n\n#  define ASN1_ITEM_end(itname) \\\n                };\n\n# else\n\n/* Macro to obtain ASN1_ADB pointer from a type (only used internally) */\n#  define ASN1_ADB_ptr(iptr) ((const ASN1_ADB *)(iptr()))\n\n/* Macros for start and end of ASN1_ITEM definition */\n\n#  define ASN1_ITEM_start(itname) \\\n        const ASN1_ITEM * itname##_it(void) \\\n        { \\\n                static const ASN1_ITEM local_it = {\n\n#  define ASN1_ITEM_end(itname) \\\n                }; \\\n        return &local_it; \\\n        }\n\n# endif\n\n/* Macros to aid ASN1 template writing */\n\n# define ASN1_ITEM_TEMPLATE(tname) \\\n        static const ASN1_TEMPLATE tname##_item_tt\n\n# define ASN1_ITEM_TEMPLATE_END(tname) \\\n        ;\\\n        ASN1_ITEM_start(tname) \\\n                ASN1_ITYPE_PRIMITIVE,\\\n                -1,\\\n                &tname##_item_tt,\\\n                0,\\\n                NULL,\\\n                0,\\\n                #tname \\\n        ASN1_ITEM_end(tname)\n\n/* This is a ASN1 type which just embeds a template */\n\n/*-\n * This pair helps declare a SEQUENCE. We can do:\n *\n *      ASN1_SEQUENCE(stname) = {\n *              ... SEQUENCE components ...\n *      } ASN1_SEQUENCE_END(stname)\n *\n *      This will produce an ASN1_ITEM called stname_it\n *      for a structure called stname.\n *\n *      If you want the same structure but a different\n *      name then use:\n *\n *      ASN1_SEQUENCE(itname) = {\n *              ... SEQUENCE components ...\n *      } ASN1_SEQUENCE_END_name(stname, itname)\n *\n *      This will create an item called itname_it using\n *      a structure called stname.\n */\n\n# define ASN1_SEQUENCE(tname) \\\n        static const ASN1_TEMPLATE tname##_seq_tt[]\n\n# define ASN1_SEQUENCE_END(stname) ASN1_SEQUENCE_END_name(stname, stname)\n\n# define ASN1_SEQUENCE_END_name(stname, tname) \\\n        ;\\\n        ASN1_ITEM_start(tname) \\\n                ASN1_ITYPE_SEQUENCE,\\\n                V_ASN1_SEQUENCE,\\\n                tname##_seq_tt,\\\n                sizeof(tname##_seq_tt) / sizeof(ASN1_TEMPLATE),\\\n                NULL,\\\n                sizeof(stname),\\\n                #stname \\\n        ASN1_ITEM_end(tname)\n\n# define ASN1_NDEF_SEQUENCE(tname) \\\n        ASN1_SEQUENCE(tname)\n\n# define ASN1_NDEF_SEQUENCE_cb(tname, cb) \\\n        ASN1_SEQUENCE_cb(tname, cb)\n\n# define ASN1_SEQUENCE_cb(tname, cb) \\\n        static const ASN1_AUX tname##_aux = {NULL, 0, 0, 0, cb, 0}; \\\n        ASN1_SEQUENCE(tname)\n\n# define ASN1_BROKEN_SEQUENCE(tname) \\\n        static const ASN1_AUX tname##_aux = {NULL, ASN1_AFLG_BROKEN, 0, 0, 0, 0}; \\\n        ASN1_SEQUENCE(tname)\n\n# define ASN1_SEQUENCE_ref(tname, cb, lck) \\\n        static const ASN1_AUX tname##_aux = {NULL, ASN1_AFLG_REFCOUNT, offsetof(tname, references), lck, cb, 0}; \\\n        ASN1_SEQUENCE(tname)\n\n# define ASN1_SEQUENCE_enc(tname, enc, cb) \\\n        static const ASN1_AUX tname##_aux = {NULL, ASN1_AFLG_ENCODING, 0, 0, cb, offsetof(tname, enc)}; \\\n        ASN1_SEQUENCE(tname)\n\n# define ASN1_NDEF_SEQUENCE_END(tname) \\\n        ;\\\n        ASN1_ITEM_start(tname) \\\n                ASN1_ITYPE_NDEF_SEQUENCE,\\\n                V_ASN1_SEQUENCE,\\\n                tname##_seq_tt,\\\n                sizeof(tname##_seq_tt) / sizeof(ASN1_TEMPLATE),\\\n                NULL,\\\n                sizeof(tname),\\\n                #tname \\\n        ASN1_ITEM_end(tname)\n\n# define ASN1_BROKEN_SEQUENCE_END(stname) ASN1_SEQUENCE_END_ref(stname, stname)\n\n# define ASN1_SEQUENCE_END_enc(stname, tname) ASN1_SEQUENCE_END_ref(stname, tname)\n\n# define ASN1_SEQUENCE_END_cb(stname, tname) ASN1_SEQUENCE_END_ref(stname, tname)\n\n# define ASN1_SEQUENCE_END_ref(stname, tname) \\\n        ;\\\n        ASN1_ITEM_start(tname) \\\n                ASN1_ITYPE_SEQUENCE,\\\n                V_ASN1_SEQUENCE,\\\n                tname##_seq_tt,\\\n                sizeof(tname##_seq_tt) / sizeof(ASN1_TEMPLATE),\\\n                &tname##_aux,\\\n                sizeof(stname),\\\n                #stname \\\n        ASN1_ITEM_end(tname)\n\n# define ASN1_NDEF_SEQUENCE_END_cb(stname, tname) \\\n        ;\\\n        ASN1_ITEM_start(tname) \\\n                ASN1_ITYPE_NDEF_SEQUENCE,\\\n                V_ASN1_SEQUENCE,\\\n                tname##_seq_tt,\\\n                sizeof(tname##_seq_tt) / sizeof(ASN1_TEMPLATE),\\\n                &tname##_aux,\\\n                sizeof(stname),\\\n                #stname \\\n        ASN1_ITEM_end(tname)\n\n/*-\n * This pair helps declare a CHOICE type. We can do:\n *\n *      ASN1_CHOICE(chname) = {\n *              ... CHOICE options ...\n *      ASN1_CHOICE_END(chname)\n *\n *      This will produce an ASN1_ITEM called chname_it\n *      for a structure called chname. The structure\n *      definition must look like this:\n *      typedef struct {\n *              int type;\n *              union {\n *                      ASN1_SOMETHING *opt1;\n *                      ASN1_SOMEOTHER *opt2;\n *              } value;\n *      } chname;\n *\n *      the name of the selector must be 'type'.\n *      to use an alternative selector name use the\n *      ASN1_CHOICE_END_selector() version.\n */\n\n# define ASN1_CHOICE(tname) \\\n        static const ASN1_TEMPLATE tname##_ch_tt[]\n\n# define ASN1_CHOICE_cb(tname, cb) \\\n        static const ASN1_AUX tname##_aux = {NULL, 0, 0, 0, cb, 0}; \\\n        ASN1_CHOICE(tname)\n\n# define ASN1_CHOICE_END(stname) ASN1_CHOICE_END_name(stname, stname)\n\n# define ASN1_CHOICE_END_name(stname, tname) ASN1_CHOICE_END_selector(stname, tname, type)\n\n# define ASN1_CHOICE_END_selector(stname, tname, selname) \\\n        ;\\\n        ASN1_ITEM_start(tname) \\\n                ASN1_ITYPE_CHOICE,\\\n                offsetof(stname,selname) ,\\\n                tname##_ch_tt,\\\n                sizeof(tname##_ch_tt) / sizeof(ASN1_TEMPLATE),\\\n                NULL,\\\n                sizeof(stname),\\\n                #stname \\\n        ASN1_ITEM_end(tname)\n\n# define ASN1_CHOICE_END_cb(stname, tname, selname) \\\n        ;\\\n        ASN1_ITEM_start(tname) \\\n                ASN1_ITYPE_CHOICE,\\\n                offsetof(stname,selname) ,\\\n                tname##_ch_tt,\\\n                sizeof(tname##_ch_tt) / sizeof(ASN1_TEMPLATE),\\\n                &tname##_aux,\\\n                sizeof(stname),\\\n                #stname \\\n        ASN1_ITEM_end(tname)\n\n/* This helps with the template wrapper form of ASN1_ITEM */\n\n# define ASN1_EX_TEMPLATE_TYPE(flags, tag, name, type) { \\\n        (flags), (tag), 0,\\\n        #name, ASN1_ITEM_ref(type) }\n\n/* These help with SEQUENCE or CHOICE components */\n\n/* used to declare other types */\n\n# define ASN1_EX_TYPE(flags, tag, stname, field, type) { \\\n        (flags), (tag), offsetof(stname, field),\\\n        #field, ASN1_ITEM_ref(type) }\n\n/* used when the structure is combined with the parent */\n\n# define ASN1_EX_COMBINE(flags, tag, type) { \\\n        (flags)|ASN1_TFLG_COMBINE, (tag), 0, NULL, ASN1_ITEM_ref(type) }\n\n/* implicit and explicit helper macros */\n\n# define ASN1_IMP_EX(stname, field, type, tag, ex) \\\n                ASN1_EX_TYPE(ASN1_TFLG_IMPLICIT | ex, tag, stname, field, type)\n\n# define ASN1_EXP_EX(stname, field, type, tag, ex) \\\n                ASN1_EX_TYPE(ASN1_TFLG_EXPLICIT | ex, tag, stname, field, type)\n\n/* Any defined by macros: the field used is in the table itself */\n\n# ifndef OPENSSL_EXPORT_VAR_AS_FUNCTION\n#  define ASN1_ADB_OBJECT(tblname) { ASN1_TFLG_ADB_OID, -1, 0, #tblname, (const ASN1_ITEM *)&(tblname##_adb) }\n#  define ASN1_ADB_INTEGER(tblname) { ASN1_TFLG_ADB_INT, -1, 0, #tblname, (const ASN1_ITEM *)&(tblname##_adb) }\n# else\n#  define ASN1_ADB_OBJECT(tblname) { ASN1_TFLG_ADB_OID, -1, 0, #tblname, tblname##_adb }\n#  define ASN1_ADB_INTEGER(tblname) { ASN1_TFLG_ADB_INT, -1, 0, #tblname, tblname##_adb }\n# endif\n/* Plain simple type */\n# define ASN1_SIMPLE(stname, field, type) ASN1_EX_TYPE(0,0, stname, field, type)\n\n/* OPTIONAL simple type */\n# define ASN1_OPT(stname, field, type) ASN1_EX_TYPE(ASN1_TFLG_OPTIONAL, 0, stname, field, type)\n\n/* IMPLICIT tagged simple type */\n# define ASN1_IMP(stname, field, type, tag) ASN1_IMP_EX(stname, field, type, tag, 0)\n\n/* IMPLICIT tagged OPTIONAL simple type */\n# define ASN1_IMP_OPT(stname, field, type, tag) ASN1_IMP_EX(stname, field, type, tag, ASN1_TFLG_OPTIONAL)\n\n/* Same as above but EXPLICIT */\n\n# define ASN1_EXP(stname, field, type, tag) ASN1_EXP_EX(stname, field, type, tag, 0)\n# define ASN1_EXP_OPT(stname, field, type, tag) ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_OPTIONAL)\n\n/* SEQUENCE OF type */\n# define ASN1_SEQUENCE_OF(stname, field, type) \\\n                ASN1_EX_TYPE(ASN1_TFLG_SEQUENCE_OF, 0, stname, field, type)\n\n/* OPTIONAL SEQUENCE OF */\n# define ASN1_SEQUENCE_OF_OPT(stname, field, type) \\\n                ASN1_EX_TYPE(ASN1_TFLG_SEQUENCE_OF|ASN1_TFLG_OPTIONAL, 0, stname, field, type)\n\n/* Same as above but for SET OF */\n\n# define ASN1_SET_OF(stname, field, type) \\\n                ASN1_EX_TYPE(ASN1_TFLG_SET_OF, 0, stname, field, type)\n\n# define ASN1_SET_OF_OPT(stname, field, type) \\\n                ASN1_EX_TYPE(ASN1_TFLG_SET_OF|ASN1_TFLG_OPTIONAL, 0, stname, field, type)\n\n/* Finally compound types of SEQUENCE, SET, IMPLICIT, EXPLICIT and OPTIONAL */\n\n# define ASN1_IMP_SET_OF(stname, field, type, tag) \\\n                        ASN1_IMP_EX(stname, field, type, tag, ASN1_TFLG_SET_OF)\n\n# define ASN1_EXP_SET_OF(stname, field, type, tag) \\\n                        ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_SET_OF)\n\n# define ASN1_IMP_SET_OF_OPT(stname, field, type, tag) \\\n                        ASN1_IMP_EX(stname, field, type, tag, ASN1_TFLG_SET_OF|ASN1_TFLG_OPTIONAL)\n\n# define ASN1_EXP_SET_OF_OPT(stname, field, type, tag) \\\n                        ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_SET_OF|ASN1_TFLG_OPTIONAL)\n\n# define ASN1_IMP_SEQUENCE_OF(stname, field, type, tag) \\\n                        ASN1_IMP_EX(stname, field, type, tag, ASN1_TFLG_SEQUENCE_OF)\n\n# define ASN1_IMP_SEQUENCE_OF_OPT(stname, field, type, tag) \\\n                        ASN1_IMP_EX(stname, field, type, tag, ASN1_TFLG_SEQUENCE_OF|ASN1_TFLG_OPTIONAL)\n\n# define ASN1_EXP_SEQUENCE_OF(stname, field, type, tag) \\\n                        ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_SEQUENCE_OF)\n\n# define ASN1_EXP_SEQUENCE_OF_OPT(stname, field, type, tag) \\\n                        ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_SEQUENCE_OF|ASN1_TFLG_OPTIONAL)\n\n/* EXPLICIT using indefinite length constructed form */\n# define ASN1_NDEF_EXP(stname, field, type, tag) \\\n                        ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_NDEF)\n\n/* EXPLICIT OPTIONAL using indefinite length constructed form */\n# define ASN1_NDEF_EXP_OPT(stname, field, type, tag) \\\n                        ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_OPTIONAL|ASN1_TFLG_NDEF)\n\n/* Macros for the ASN1_ADB structure */\n\n# define ASN1_ADB(name) \\\n        static const ASN1_ADB_TABLE name##_adbtbl[]\n\n# ifndef OPENSSL_EXPORT_VAR_AS_FUNCTION\n\n#  define ASN1_ADB_END(name, flags, field, app_table, def, none) \\\n        ;\\\n        static const ASN1_ADB name##_adb = {\\\n                flags,\\\n                offsetof(name, field),\\\n                app_table,\\\n                name##_adbtbl,\\\n                sizeof(name##_adbtbl) / sizeof(ASN1_ADB_TABLE),\\\n                def,\\\n                none\\\n        }\n\n# else\n\n#  define ASN1_ADB_END(name, flags, field, app_table, def, none) \\\n        ;\\\n        static const ASN1_ITEM *name##_adb(void) \\\n        { \\\n        static const ASN1_ADB internal_adb = \\\n                {\\\n                flags,\\\n                offsetof(name, field),\\\n                app_table,\\\n                name##_adbtbl,\\\n                sizeof(name##_adbtbl) / sizeof(ASN1_ADB_TABLE),\\\n                def,\\\n                none\\\n                }; \\\n                return (const ASN1_ITEM *) &internal_adb; \\\n        } \\\n        void dummy_function(void)\n\n# endif\n\n# define ADB_ENTRY(val, template) {val, template}\n\n# define ASN1_ADB_TEMPLATE(name) \\\n        static const ASN1_TEMPLATE name##_tt\n\n/*\n * This is the ASN1 template structure that defines a wrapper round the\n * actual type. It determines the actual position of the field in the value\n * structure, various flags such as OPTIONAL and the field name.\n */\n\nstruct ASN1_TEMPLATE_st {\n    unsigned long flags;        /* Various flags */\n    long tag;                   /* tag, not used if no tagging */\n    unsigned long offset;       /* Offset of this field in structure */\n# ifndef NO_ASN1_FIELD_NAMES\n    const char *field_name;     /* Field name */\n# endif\n    ASN1_ITEM_EXP *item;        /* Relevant ASN1_ITEM or ASN1_ADB */\n};\n\n/* Macro to extract ASN1_ITEM and ASN1_ADB pointer from ASN1_TEMPLATE */\n\n# define ASN1_TEMPLATE_item(t) (t->item_ptr)\n# define ASN1_TEMPLATE_adb(t) (t->item_ptr)\n\ntypedef struct ASN1_ADB_TABLE_st ASN1_ADB_TABLE;\ntypedef struct ASN1_ADB_st ASN1_ADB;\n\nstruct ASN1_ADB_st {\n    unsigned long flags;        /* Various flags */\n    unsigned long offset;       /* Offset of selector field */\n    STACK_OF(ASN1_ADB_TABLE) **app_items; /* Application defined items */\n    const ASN1_ADB_TABLE *tbl;  /* Table of possible types */\n    long tblcount;              /* Number of entries in tbl */\n    const ASN1_TEMPLATE *default_tt; /* Type to use if no match */\n    const ASN1_TEMPLATE *null_tt; /* Type to use if selector is NULL */\n};\n\nstruct ASN1_ADB_TABLE_st {\n    long value;                 /* NID for an object or value for an int */\n    const ASN1_TEMPLATE tt;     /* item for this value */\n};\n\n/* template flags */\n\n/* Field is optional */\n# define ASN1_TFLG_OPTIONAL      (0x1)\n\n/* Field is a SET OF */\n# define ASN1_TFLG_SET_OF        (0x1 << 1)\n\n/* Field is a SEQUENCE OF */\n# define ASN1_TFLG_SEQUENCE_OF   (0x2 << 1)\n\n/*\n * Special case: this refers to a SET OF that will be sorted into DER order\n * when encoded *and* the corresponding STACK will be modified to match the\n * new order.\n */\n# define ASN1_TFLG_SET_ORDER     (0x3 << 1)\n\n/* Mask for SET OF or SEQUENCE OF */\n# define ASN1_TFLG_SK_MASK       (0x3 << 1)\n\n/*\n * These flags mean the tag should be taken from the tag field. If EXPLICIT\n * then the underlying type is used for the inner tag.\n */\n\n/* IMPLICIT tagging */\n# define ASN1_TFLG_IMPTAG        (0x1 << 3)\n\n/* EXPLICIT tagging, inner tag from underlying type */\n# define ASN1_TFLG_EXPTAG        (0x2 << 3)\n\n# define ASN1_TFLG_TAG_MASK      (0x3 << 3)\n\n/* context specific IMPLICIT */\n# define ASN1_TFLG_IMPLICIT      ASN1_TFLG_IMPTAG|ASN1_TFLG_CONTEXT\n\n/* context specific EXPLICIT */\n# define ASN1_TFLG_EXPLICIT      ASN1_TFLG_EXPTAG|ASN1_TFLG_CONTEXT\n\n/*\n * If tagging is in force these determine the type of tag to use. Otherwise\n * the tag is determined by the underlying type. These values reflect the\n * actual octet format.\n */\n\n/* Universal tag */\n# define ASN1_TFLG_UNIVERSAL     (0x0<<6)\n/* Application tag */\n# define ASN1_TFLG_APPLICATION   (0x1<<6)\n/* Context specific tag */\n# define ASN1_TFLG_CONTEXT       (0x2<<6)\n/* Private tag */\n# define ASN1_TFLG_PRIVATE       (0x3<<6)\n\n# define ASN1_TFLG_TAG_CLASS     (0x3<<6)\n\n/*\n * These are for ANY DEFINED BY type. In this case the 'item' field points to\n * an ASN1_ADB structure which contains a table of values to decode the\n * relevant type\n */\n\n# define ASN1_TFLG_ADB_MASK      (0x3<<8)\n\n# define ASN1_TFLG_ADB_OID       (0x1<<8)\n\n# define ASN1_TFLG_ADB_INT       (0x1<<9)\n\n/*\n * This flag means a parent structure is passed instead of the field: this is\n * useful is a SEQUENCE is being combined with a CHOICE for example. Since\n * this means the structure and item name will differ we need to use the\n * ASN1_CHOICE_END_name() macro for example.\n */\n\n# define ASN1_TFLG_COMBINE       (0x1<<10)\n\n/*\n * This flag when present in a SEQUENCE OF, SET OF or EXPLICIT causes\n * indefinite length constructed encoding to be used if required.\n */\n\n# define ASN1_TFLG_NDEF          (0x1<<11)\n\n/* This is the actual ASN1 item itself */\n\nstruct ASN1_ITEM_st {\n    char itype;                 /* The item type, primitive, SEQUENCE, CHOICE\n                                 * or extern */\n    long utype;                 /* underlying type */\n    const ASN1_TEMPLATE *templates; /* If SEQUENCE or CHOICE this contains\n                                     * the contents */\n    long tcount;                /* Number of templates if SEQUENCE or CHOICE */\n    const void *funcs;          /* functions that handle this type */\n    long size;                  /* Structure size (usually) */\n# ifndef NO_ASN1_FIELD_NAMES\n    const char *sname;          /* Structure name */\n# endif\n};\n\n/*-\n * These are values for the itype field and\n * determine how the type is interpreted.\n *\n * For PRIMITIVE types the underlying type\n * determines the behaviour if items is NULL.\n *\n * Otherwise templates must contain a single\n * template and the type is treated in the\n * same way as the type specified in the template.\n *\n * For SEQUENCE types the templates field points\n * to the members, the size field is the\n * structure size.\n *\n * For CHOICE types the templates field points\n * to each possible member (typically a union)\n * and the 'size' field is the offset of the\n * selector.\n *\n * The 'funcs' field is used for application\n * specific functions.\n *\n * For COMPAT types the funcs field gives a\n * set of functions that handle this type, this\n * supports the old d2i, i2d convention.\n *\n * The EXTERN type uses a new style d2i/i2d.\n * The new style should be used where possible\n * because it avoids things like the d2i IMPLICIT\n * hack.\n *\n * MSTRING is a multiple string type, it is used\n * for a CHOICE of character strings where the\n * actual strings all occupy an ASN1_STRING\n * structure. In this case the 'utype' field\n * has a special meaning, it is used as a mask\n * of acceptable types using the B_ASN1 constants.\n *\n * NDEF_SEQUENCE is the same as SEQUENCE except\n * that it will use indefinite length constructed\n * encoding if requested.\n *\n */\n\n# define ASN1_ITYPE_PRIMITIVE            0x0\n\n# define ASN1_ITYPE_SEQUENCE             0x1\n\n# define ASN1_ITYPE_CHOICE               0x2\n\n# define ASN1_ITYPE_COMPAT               0x3\n\n# define ASN1_ITYPE_EXTERN               0x4\n\n# define ASN1_ITYPE_MSTRING              0x5\n\n# define ASN1_ITYPE_NDEF_SEQUENCE        0x6\n\n/*\n * Cache for ASN1 tag and length, so we don't keep re-reading it for things\n * like CHOICE\n */\n\nstruct ASN1_TLC_st {\n    char valid;                 /* Values below are valid */\n    int ret;                    /* return value */\n    long plen;                  /* length */\n    int ptag;                   /* class value */\n    int pclass;                 /* class value */\n    int hdrlen;                 /* header length */\n};\n\n/* Typedefs for ASN1 function pointers */\n\ntypedef ASN1_VALUE *ASN1_new_func(void);\ntypedef void ASN1_free_func(ASN1_VALUE *a);\ntypedef ASN1_VALUE *ASN1_d2i_func(ASN1_VALUE **a, const unsigned char **in,\n                                  long length);\ntypedef int ASN1_i2d_func(ASN1_VALUE *a, unsigned char **in);\n\ntypedef int ASN1_ex_d2i(ASN1_VALUE **pval, const unsigned char **in, long len,\n                        const ASN1_ITEM *it, int tag, int aclass, char opt,\n                        ASN1_TLC *ctx);\n\ntypedef int ASN1_ex_i2d(ASN1_VALUE **pval, unsigned char **out,\n                        const ASN1_ITEM *it, int tag, int aclass);\ntypedef int ASN1_ex_new_func(ASN1_VALUE **pval, const ASN1_ITEM *it);\ntypedef void ASN1_ex_free_func(ASN1_VALUE **pval, const ASN1_ITEM *it);\n\ntypedef int ASN1_ex_print_func(BIO *out, ASN1_VALUE **pval,\n                               int indent, const char *fname,\n                               const ASN1_PCTX *pctx);\n\ntypedef int ASN1_primitive_i2c(ASN1_VALUE **pval, unsigned char *cont,\n                               int *putype, const ASN1_ITEM *it);\ntypedef int ASN1_primitive_c2i(ASN1_VALUE **pval, const unsigned char *cont,\n                               int len, int utype, char *free_cont,\n                               const ASN1_ITEM *it);\ntypedef int ASN1_primitive_print(BIO *out, ASN1_VALUE **pval,\n                                 const ASN1_ITEM *it, int indent,\n                                 const ASN1_PCTX *pctx);\n\ntypedef struct ASN1_COMPAT_FUNCS_st {\n    ASN1_new_func *asn1_new;\n    ASN1_free_func *asn1_free;\n    ASN1_d2i_func *asn1_d2i;\n    ASN1_i2d_func *asn1_i2d;\n} ASN1_COMPAT_FUNCS;\n\ntypedef struct ASN1_EXTERN_FUNCS_st {\n    void *app_data;\n    ASN1_ex_new_func *asn1_ex_new;\n    ASN1_ex_free_func *asn1_ex_free;\n    ASN1_ex_free_func *asn1_ex_clear;\n    ASN1_ex_d2i *asn1_ex_d2i;\n    ASN1_ex_i2d *asn1_ex_i2d;\n    ASN1_ex_print_func *asn1_ex_print;\n} ASN1_EXTERN_FUNCS;\n\ntypedef struct ASN1_PRIMITIVE_FUNCS_st {\n    void *app_data;\n    unsigned long flags;\n    ASN1_ex_new_func *prim_new;\n    ASN1_ex_free_func *prim_free;\n    ASN1_ex_free_func *prim_clear;\n    ASN1_primitive_c2i *prim_c2i;\n    ASN1_primitive_i2c *prim_i2c;\n    ASN1_primitive_print *prim_print;\n} ASN1_PRIMITIVE_FUNCS;\n\n/*\n * This is the ASN1_AUX structure: it handles various miscellaneous\n * requirements. For example the use of reference counts and an informational\n * callback. The \"informational callback\" is called at various points during\n * the ASN1 encoding and decoding. It can be used to provide minor\n * customisation of the structures used. This is most useful where the\n * supplied routines *almost* do the right thing but need some extra help at\n * a few points. If the callback returns zero then it is assumed a fatal\n * error has occurred and the main operation should be abandoned. If major\n * changes in the default behaviour are required then an external type is\n * more appropriate.\n */\n\ntypedef int ASN1_aux_cb(int operation, ASN1_VALUE **in, const ASN1_ITEM *it,\n                        void *exarg);\n\ntypedef struct ASN1_AUX_st {\n    void *app_data;\n    int flags;\n    int ref_offset;             /* Offset of reference value */\n    int ref_lock;               /* Lock type to use */\n    ASN1_aux_cb *asn1_cb;\n    int enc_offset;             /* Offset of ASN1_ENCODING structure */\n} ASN1_AUX;\n\n/* For print related callbacks exarg points to this structure */\ntypedef struct ASN1_PRINT_ARG_st {\n    BIO *out;\n    int indent;\n    const ASN1_PCTX *pctx;\n} ASN1_PRINT_ARG;\n\n/* For streaming related callbacks exarg points to this structure */\ntypedef struct ASN1_STREAM_ARG_st {\n    /* BIO to stream through */\n    BIO *out;\n    /* BIO with filters appended */\n    BIO *ndef_bio;\n    /* Streaming I/O boundary */\n    unsigned char **boundary;\n} ASN1_STREAM_ARG;\n\n/* Flags in ASN1_AUX */\n\n/* Use a reference count */\n# define ASN1_AFLG_REFCOUNT      1\n/* Save the encoding of structure (useful for signatures) */\n# define ASN1_AFLG_ENCODING      2\n/* The Sequence length is invalid */\n# define ASN1_AFLG_BROKEN        4\n\n/* operation values for asn1_cb */\n\n# define ASN1_OP_NEW_PRE         0\n# define ASN1_OP_NEW_POST        1\n# define ASN1_OP_FREE_PRE        2\n# define ASN1_OP_FREE_POST       3\n# define ASN1_OP_D2I_PRE         4\n# define ASN1_OP_D2I_POST        5\n# define ASN1_OP_I2D_PRE         6\n# define ASN1_OP_I2D_POST        7\n# define ASN1_OP_PRINT_PRE       8\n# define ASN1_OP_PRINT_POST      9\n# define ASN1_OP_STREAM_PRE      10\n# define ASN1_OP_STREAM_POST     11\n# define ASN1_OP_DETACHED_PRE    12\n# define ASN1_OP_DETACHED_POST   13\n\n/* Macro to implement a primitive type */\n# define IMPLEMENT_ASN1_TYPE(stname) IMPLEMENT_ASN1_TYPE_ex(stname, stname, 0)\n# define IMPLEMENT_ASN1_TYPE_ex(itname, vname, ex) \\\n                                ASN1_ITEM_start(itname) \\\n                                        ASN1_ITYPE_PRIMITIVE, V_##vname, NULL, 0, NULL, ex, #itname \\\n                                ASN1_ITEM_end(itname)\n\n/* Macro to implement a multi string type */\n# define IMPLEMENT_ASN1_MSTRING(itname, mask) \\\n                                ASN1_ITEM_start(itname) \\\n                                        ASN1_ITYPE_MSTRING, mask, NULL, 0, NULL, sizeof(ASN1_STRING), #itname \\\n                                ASN1_ITEM_end(itname)\n\n/* Macro to implement an ASN1_ITEM in terms of old style funcs */\n\n# define IMPLEMENT_COMPAT_ASN1(sname) IMPLEMENT_COMPAT_ASN1_type(sname, V_ASN1_SEQUENCE)\n\n# define IMPLEMENT_COMPAT_ASN1_type(sname, tag) \\\n        static const ASN1_COMPAT_FUNCS sname##_ff = { \\\n                (ASN1_new_func *)sname##_new, \\\n                (ASN1_free_func *)sname##_free, \\\n                (ASN1_d2i_func *)d2i_##sname, \\\n                (ASN1_i2d_func *)i2d_##sname, \\\n        }; \\\n        ASN1_ITEM_start(sname) \\\n                ASN1_ITYPE_COMPAT, \\\n                tag, \\\n                NULL, \\\n                0, \\\n                &sname##_ff, \\\n                0, \\\n                #sname \\\n        ASN1_ITEM_end(sname)\n\n# define IMPLEMENT_EXTERN_ASN1(sname, tag, fptrs) \\\n        ASN1_ITEM_start(sname) \\\n                ASN1_ITYPE_EXTERN, \\\n                tag, \\\n                NULL, \\\n                0, \\\n                &fptrs, \\\n                0, \\\n                #sname \\\n        ASN1_ITEM_end(sname)\n\n/* Macro to implement standard functions in terms of ASN1_ITEM structures */\n\n# define IMPLEMENT_ASN1_FUNCTIONS(stname) IMPLEMENT_ASN1_FUNCTIONS_fname(stname, stname, stname)\n\n# define IMPLEMENT_ASN1_FUNCTIONS_name(stname, itname) IMPLEMENT_ASN1_FUNCTIONS_fname(stname, itname, itname)\n\n# define IMPLEMENT_ASN1_FUNCTIONS_ENCODE_name(stname, itname) \\\n                        IMPLEMENT_ASN1_FUNCTIONS_ENCODE_fname(stname, itname, itname)\n\n# define IMPLEMENT_STATIC_ASN1_ALLOC_FUNCTIONS(stname) \\\n                IMPLEMENT_ASN1_ALLOC_FUNCTIONS_pfname(static, stname, stname, stname)\n\n# define IMPLEMENT_ASN1_ALLOC_FUNCTIONS(stname) \\\n                IMPLEMENT_ASN1_ALLOC_FUNCTIONS_fname(stname, stname, stname)\n\n# define IMPLEMENT_ASN1_ALLOC_FUNCTIONS_pfname(pre, stname, itname, fname) \\\n        pre stname *fname##_new(void) \\\n        { \\\n                return (stname *)ASN1_item_new(ASN1_ITEM_rptr(itname)); \\\n        } \\\n        pre void fname##_free(stname *a) \\\n        { \\\n                ASN1_item_free((ASN1_VALUE *)a, ASN1_ITEM_rptr(itname)); \\\n        }\n\n# define IMPLEMENT_ASN1_ALLOC_FUNCTIONS_fname(stname, itname, fname) \\\n        stname *fname##_new(void) \\\n        { \\\n                return (stname *)ASN1_item_new(ASN1_ITEM_rptr(itname)); \\\n        } \\\n        void fname##_free(stname *a) \\\n        { \\\n                ASN1_item_free((ASN1_VALUE *)a, ASN1_ITEM_rptr(itname)); \\\n        }\n\n# define IMPLEMENT_ASN1_FUNCTIONS_fname(stname, itname, fname) \\\n        IMPLEMENT_ASN1_ENCODE_FUNCTIONS_fname(stname, itname, fname) \\\n        IMPLEMENT_ASN1_ALLOC_FUNCTIONS_fname(stname, itname, fname)\n\n# define IMPLEMENT_ASN1_ENCODE_FUNCTIONS_fname(stname, itname, fname) \\\n        stname *d2i_##fname(stname **a, const unsigned char **in, long len) \\\n        { \\\n                return (stname *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, ASN1_ITEM_rptr(itname));\\\n        } \\\n        int i2d_##fname(stname *a, unsigned char **out) \\\n        { \\\n                return ASN1_item_i2d((ASN1_VALUE *)a, out, ASN1_ITEM_rptr(itname));\\\n        }\n\n# define IMPLEMENT_ASN1_NDEF_FUNCTION(stname) \\\n        int i2d_##stname##_NDEF(stname *a, unsigned char **out) \\\n        { \\\n                return ASN1_item_ndef_i2d((ASN1_VALUE *)a, out, ASN1_ITEM_rptr(stname));\\\n        }\n\n/*\n * This includes evil casts to remove const: they will go away when full ASN1\n * constification is done.\n */\n# define IMPLEMENT_ASN1_ENCODE_FUNCTIONS_const_fname(stname, itname, fname) \\\n        stname *d2i_##fname(stname **a, const unsigned char **in, long len) \\\n        { \\\n                return (stname *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, ASN1_ITEM_rptr(itname));\\\n        } \\\n        int i2d_##fname(const stname *a, unsigned char **out) \\\n        { \\\n                return ASN1_item_i2d((ASN1_VALUE *)a, out, ASN1_ITEM_rptr(itname));\\\n        }\n\n# define IMPLEMENT_ASN1_DUP_FUNCTION(stname) \\\n        stname * stname##_dup(stname *x) \\\n        { \\\n        return ASN1_item_dup(ASN1_ITEM_rptr(stname), x); \\\n        }\n\n# define IMPLEMENT_ASN1_PRINT_FUNCTION(stname) \\\n        IMPLEMENT_ASN1_PRINT_FUNCTION_fname(stname, stname, stname)\n\n# define IMPLEMENT_ASN1_PRINT_FUNCTION_fname(stname, itname, fname) \\\n        int fname##_print_ctx(BIO *out, stname *x, int indent, \\\n                                                const ASN1_PCTX *pctx) \\\n        { \\\n                return ASN1_item_print(out, (ASN1_VALUE *)x, indent, \\\n                        ASN1_ITEM_rptr(itname), pctx); \\\n        }\n\n# define IMPLEMENT_ASN1_FUNCTIONS_const(name) \\\n                IMPLEMENT_ASN1_FUNCTIONS_const_fname(name, name, name)\n\n# define IMPLEMENT_ASN1_FUNCTIONS_const_fname(stname, itname, fname) \\\n        IMPLEMENT_ASN1_ENCODE_FUNCTIONS_const_fname(stname, itname, fname) \\\n        IMPLEMENT_ASN1_ALLOC_FUNCTIONS_fname(stname, itname, fname)\n\n/* external definitions for primitive types */\n\nDECLARE_ASN1_ITEM(ASN1_BOOLEAN)\nDECLARE_ASN1_ITEM(ASN1_TBOOLEAN)\nDECLARE_ASN1_ITEM(ASN1_FBOOLEAN)\nDECLARE_ASN1_ITEM(ASN1_SEQUENCE)\nDECLARE_ASN1_ITEM(CBIGNUM)\nDECLARE_ASN1_ITEM(BIGNUM)\nDECLARE_ASN1_ITEM(LONG)\nDECLARE_ASN1_ITEM(ZLONG)\n\nDECLARE_STACK_OF(ASN1_VALUE)\n\n/* Functions used internally by the ASN1 code */\n\nint ASN1_item_ex_new(ASN1_VALUE **pval, const ASN1_ITEM *it);\nvoid ASN1_item_ex_free(ASN1_VALUE **pval, const ASN1_ITEM *it);\nint ASN1_template_new(ASN1_VALUE **pval, const ASN1_TEMPLATE *tt);\nint ASN1_primitive_new(ASN1_VALUE **pval, const ASN1_ITEM *it);\n\nvoid ASN1_template_free(ASN1_VALUE **pval, const ASN1_TEMPLATE *tt);\nint ASN1_template_d2i(ASN1_VALUE **pval, const unsigned char **in, long len,\n                      const ASN1_TEMPLATE *tt);\nint ASN1_item_ex_d2i(ASN1_VALUE **pval, const unsigned char **in, long len,\n                     const ASN1_ITEM *it, int tag, int aclass, char opt,\n                     ASN1_TLC *ctx);\n\nint ASN1_item_ex_i2d(ASN1_VALUE **pval, unsigned char **out,\n                     const ASN1_ITEM *it, int tag, int aclass);\nint ASN1_template_i2d(ASN1_VALUE **pval, unsigned char **out,\n                      const ASN1_TEMPLATE *tt);\nvoid ASN1_primitive_free(ASN1_VALUE **pval, const ASN1_ITEM *it);\n\nint asn1_ex_i2c(ASN1_VALUE **pval, unsigned char *cont, int *putype,\n                const ASN1_ITEM *it);\nint asn1_ex_c2i(ASN1_VALUE **pval, const unsigned char *cont, int len,\n                int utype, char *free_cont, const ASN1_ITEM *it);\n\nint asn1_get_choice_selector(ASN1_VALUE **pval, const ASN1_ITEM *it);\nint asn1_set_choice_selector(ASN1_VALUE **pval, int value,\n                             const ASN1_ITEM *it);\n\nASN1_VALUE **asn1_get_field_ptr(ASN1_VALUE **pval, const ASN1_TEMPLATE *tt);\n\nconst ASN1_TEMPLATE *asn1_do_adb(ASN1_VALUE **pval, const ASN1_TEMPLATE *tt,\n                                 int nullerr);\n\nint asn1_do_lock(ASN1_VALUE **pval, int op, const ASN1_ITEM *it);\n\nvoid asn1_enc_init(ASN1_VALUE **pval, const ASN1_ITEM *it);\nvoid asn1_enc_free(ASN1_VALUE **pval, const ASN1_ITEM *it);\nint asn1_enc_restore(int *len, unsigned char **out, ASN1_VALUE **pval,\n                     const ASN1_ITEM *it);\nint asn1_enc_save(ASN1_VALUE **pval, const unsigned char *in, int inlen,\n                  const ASN1_ITEM *it);\n\n#ifdef  __cplusplus\n}\n#endif\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/x86/include/openssl/bio.h",
    "content": "/* crypto/bio/bio.h */\n/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)\n * All rights reserved.\n *\n * This package is an SSL implementation written\n * by Eric Young (eay@cryptsoft.com).\n * The implementation was written so as to conform with Netscapes SSL.\n *\n * This library is free for commercial and non-commercial use as long as\n * the following conditions are aheared to.  The following conditions\n * apply to all code found in this distribution, be it the RC4, RSA,\n * lhash, DES, etc., code; not just the SSL code.  The SSL documentation\n * included with this distribution is covered by the same copyright terms\n * except that the holder is Tim Hudson (tjh@cryptsoft.com).\n *\n * Copyright remains Eric Young's, and as such any Copyright notices in\n * the code are not to be removed.\n * If this package is used in a product, Eric Young should be given attribution\n * as the author of the parts of the library used.\n * This can be in the form of a textual message at program startup or\n * in documentation (online or textual) provided with the package.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the copyright\n *    notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in the\n *    documentation and/or other materials provided with the distribution.\n * 3. All advertising materials mentioning features or use of this software\n *    must display the following acknowledgement:\n *    \"This product includes cryptographic software written by\n *     Eric Young (eay@cryptsoft.com)\"\n *    The word 'cryptographic' can be left out if the rouines from the library\n *    being used are not cryptographic related :-).\n * 4. If you include any Windows specific code (or a derivative thereof) from\n *    the apps directory (application code) you must include an acknowledgement:\n *    \"This product includes software written by Tim Hudson (tjh@cryptsoft.com)\"\n *\n * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n * SUCH DAMAGE.\n *\n * The licence and distribution terms for any publically available version or\n * derivative of this code cannot be changed.  i.e. this code cannot simply be\n * copied and put under another distribution licence\n * [including the GNU Public Licence.]\n */\n\n#ifndef HEADER_BIO_H\n# define HEADER_BIO_H\n\n# include <openssl/e_os2.h>\n\n# ifndef OPENSSL_NO_FP_API\n#  include <stdio.h>\n# endif\n# include <stdarg.h>\n\n# include <openssl/crypto.h>\n\n# ifndef OPENSSL_NO_SCTP\n#  ifndef OPENSSL_SYS_VMS\n#   include <stdint.h>\n#  else\n#   include <inttypes.h>\n#  endif\n# endif\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n/* These are the 'types' of BIOs */\n# define BIO_TYPE_NONE           0\n# define BIO_TYPE_MEM            (1|0x0400)\n# define BIO_TYPE_FILE           (2|0x0400)\n\n# define BIO_TYPE_FD             (4|0x0400|0x0100)\n# define BIO_TYPE_SOCKET         (5|0x0400|0x0100)\n# define BIO_TYPE_NULL           (6|0x0400)\n# define BIO_TYPE_SSL            (7|0x0200)\n# define BIO_TYPE_MD             (8|0x0200)/* passive filter */\n# define BIO_TYPE_BUFFER         (9|0x0200)/* filter */\n# define BIO_TYPE_CIPHER         (10|0x0200)/* filter */\n# define BIO_TYPE_BASE64         (11|0x0200)/* filter */\n# define BIO_TYPE_CONNECT        (12|0x0400|0x0100)/* socket - connect */\n# define BIO_TYPE_ACCEPT         (13|0x0400|0x0100)/* socket for accept */\n# define BIO_TYPE_PROXY_CLIENT   (14|0x0200)/* client proxy BIO */\n# define BIO_TYPE_PROXY_SERVER   (15|0x0200)/* server proxy BIO */\n# define BIO_TYPE_NBIO_TEST      (16|0x0200)/* server proxy BIO */\n# define BIO_TYPE_NULL_FILTER    (17|0x0200)\n# define BIO_TYPE_BER            (18|0x0200)/* BER -> bin filter */\n# define BIO_TYPE_BIO            (19|0x0400)/* (half a) BIO pair */\n# define BIO_TYPE_LINEBUFFER     (20|0x0200)/* filter */\n# define BIO_TYPE_DGRAM          (21|0x0400|0x0100)\n# ifndef OPENSSL_NO_SCTP\n#  define BIO_TYPE_DGRAM_SCTP     (24|0x0400|0x0100)\n# endif\n# define BIO_TYPE_ASN1           (22|0x0200)/* filter */\n# define BIO_TYPE_COMP           (23|0x0200)/* filter */\n\n# define BIO_TYPE_DESCRIPTOR     0x0100/* socket, fd, connect or accept */\n# define BIO_TYPE_FILTER         0x0200\n# define BIO_TYPE_SOURCE_SINK    0x0400\n\n/*\n * BIO_FILENAME_READ|BIO_CLOSE to open or close on free.\n * BIO_set_fp(in,stdin,BIO_NOCLOSE);\n */\n# define BIO_NOCLOSE             0x00\n# define BIO_CLOSE               0x01\n\n/*\n * These are used in the following macros and are passed to BIO_ctrl()\n */\n# define BIO_CTRL_RESET          1/* opt - rewind/zero etc */\n# define BIO_CTRL_EOF            2/* opt - are we at the eof */\n# define BIO_CTRL_INFO           3/* opt - extra tit-bits */\n# define BIO_CTRL_SET            4/* man - set the 'IO' type */\n# define BIO_CTRL_GET            5/* man - get the 'IO' type */\n# define BIO_CTRL_PUSH           6/* opt - internal, used to signify change */\n# define BIO_CTRL_POP            7/* opt - internal, used to signify change */\n# define BIO_CTRL_GET_CLOSE      8/* man - set the 'close' on free */\n# define BIO_CTRL_SET_CLOSE      9/* man - set the 'close' on free */\n# define BIO_CTRL_PENDING        10/* opt - is their more data buffered */\n# define BIO_CTRL_FLUSH          11/* opt - 'flush' buffered output */\n# define BIO_CTRL_DUP            12/* man - extra stuff for 'duped' BIO */\n# define BIO_CTRL_WPENDING       13/* opt - number of bytes still to write */\n/* callback is int cb(BIO *bio,state,ret); */\n# define BIO_CTRL_SET_CALLBACK   14/* opt - set callback function */\n# define BIO_CTRL_GET_CALLBACK   15/* opt - set callback function */\n\n# define BIO_CTRL_SET_FILENAME   30/* BIO_s_file special */\n\n/* dgram BIO stuff */\n# define BIO_CTRL_DGRAM_CONNECT       31/* BIO dgram special */\n# define BIO_CTRL_DGRAM_SET_CONNECTED 32/* allow for an externally connected\n                                         * socket to be passed in */\n# define BIO_CTRL_DGRAM_SET_RECV_TIMEOUT 33/* setsockopt, essentially */\n# define BIO_CTRL_DGRAM_GET_RECV_TIMEOUT 34/* getsockopt, essentially */\n# define BIO_CTRL_DGRAM_SET_SEND_TIMEOUT 35/* setsockopt, essentially */\n# define BIO_CTRL_DGRAM_GET_SEND_TIMEOUT 36/* getsockopt, essentially */\n\n# define BIO_CTRL_DGRAM_GET_RECV_TIMER_EXP 37/* flag whether the last */\n# define BIO_CTRL_DGRAM_GET_SEND_TIMER_EXP 38/* I/O operation tiemd out */\n\n/* #ifdef IP_MTU_DISCOVER */\n# define BIO_CTRL_DGRAM_MTU_DISCOVER       39/* set DF bit on egress packets */\n/* #endif */\n\n# define BIO_CTRL_DGRAM_QUERY_MTU          40/* as kernel for current MTU */\n# define BIO_CTRL_DGRAM_GET_FALLBACK_MTU   47\n# define BIO_CTRL_DGRAM_GET_MTU            41/* get cached value for MTU */\n# define BIO_CTRL_DGRAM_SET_MTU            42/* set cached value for MTU.\n                                              * want to use this if asking\n                                              * the kernel fails */\n\n# define BIO_CTRL_DGRAM_MTU_EXCEEDED       43/* check whether the MTU was\n                                              * exceed in the previous write\n                                              * operation */\n\n# define BIO_CTRL_DGRAM_GET_PEER           46\n# define BIO_CTRL_DGRAM_SET_PEER           44/* Destination for the data */\n\n# define BIO_CTRL_DGRAM_SET_NEXT_TIMEOUT   45/* Next DTLS handshake timeout\n                                              * to adjust socket timeouts */\n# define BIO_CTRL_DGRAM_SET_DONT_FRAG      48\n\n# define BIO_CTRL_DGRAM_GET_MTU_OVERHEAD   49\n\n# ifndef OPENSSL_NO_SCTP\n/* SCTP stuff */\n#  define BIO_CTRL_DGRAM_SCTP_SET_IN_HANDSHAKE    50\n#  define BIO_CTRL_DGRAM_SCTP_ADD_AUTH_KEY                51\n#  define BIO_CTRL_DGRAM_SCTP_NEXT_AUTH_KEY               52\n#  define BIO_CTRL_DGRAM_SCTP_AUTH_CCS_RCVD               53\n#  define BIO_CTRL_DGRAM_SCTP_GET_SNDINFO         60\n#  define BIO_CTRL_DGRAM_SCTP_SET_SNDINFO         61\n#  define BIO_CTRL_DGRAM_SCTP_GET_RCVINFO         62\n#  define BIO_CTRL_DGRAM_SCTP_SET_RCVINFO         63\n#  define BIO_CTRL_DGRAM_SCTP_GET_PRINFO                  64\n#  define BIO_CTRL_DGRAM_SCTP_SET_PRINFO                  65\n#  define BIO_CTRL_DGRAM_SCTP_SAVE_SHUTDOWN               70\n# endif\n\n/* modifiers */\n# define BIO_FP_READ             0x02\n# define BIO_FP_WRITE            0x04\n# define BIO_FP_APPEND           0x08\n# define BIO_FP_TEXT             0x10\n\n# define BIO_FLAGS_READ          0x01\n# define BIO_FLAGS_WRITE         0x02\n# define BIO_FLAGS_IO_SPECIAL    0x04\n# define BIO_FLAGS_RWS (BIO_FLAGS_READ|BIO_FLAGS_WRITE|BIO_FLAGS_IO_SPECIAL)\n# define BIO_FLAGS_SHOULD_RETRY  0x08\n# ifndef BIO_FLAGS_UPLINK\n/*\n * \"UPLINK\" flag denotes file descriptors provided by application. It\n * defaults to 0, as most platforms don't require UPLINK interface.\n */\n#  define BIO_FLAGS_UPLINK        0\n# endif\n\n/* Used in BIO_gethostbyname() */\n# define BIO_GHBN_CTRL_HITS              1\n# define BIO_GHBN_CTRL_MISSES            2\n# define BIO_GHBN_CTRL_CACHE_SIZE        3\n# define BIO_GHBN_CTRL_GET_ENTRY         4\n# define BIO_GHBN_CTRL_FLUSH             5\n\n/* Mostly used in the SSL BIO */\n/*-\n * Not used anymore\n * #define BIO_FLAGS_PROTOCOL_DELAYED_READ 0x10\n * #define BIO_FLAGS_PROTOCOL_DELAYED_WRITE 0x20\n * #define BIO_FLAGS_PROTOCOL_STARTUP   0x40\n */\n\n# define BIO_FLAGS_BASE64_NO_NL  0x100\n\n/*\n * This is used with memory BIOs: it means we shouldn't free up or change the\n * data in any way.\n */\n# define BIO_FLAGS_MEM_RDONLY    0x200\n\ntypedef struct bio_st BIO;\n\nvoid BIO_set_flags(BIO *b, int flags);\nint BIO_test_flags(const BIO *b, int flags);\nvoid BIO_clear_flags(BIO *b, int flags);\n\n# define BIO_get_flags(b) BIO_test_flags(b, ~(0x0))\n# define BIO_set_retry_special(b) \\\n                BIO_set_flags(b, (BIO_FLAGS_IO_SPECIAL|BIO_FLAGS_SHOULD_RETRY))\n# define BIO_set_retry_read(b) \\\n                BIO_set_flags(b, (BIO_FLAGS_READ|BIO_FLAGS_SHOULD_RETRY))\n# define BIO_set_retry_write(b) \\\n                BIO_set_flags(b, (BIO_FLAGS_WRITE|BIO_FLAGS_SHOULD_RETRY))\n\n/* These are normally used internally in BIOs */\n# define BIO_clear_retry_flags(b) \\\n                BIO_clear_flags(b, (BIO_FLAGS_RWS|BIO_FLAGS_SHOULD_RETRY))\n# define BIO_get_retry_flags(b) \\\n                BIO_test_flags(b, (BIO_FLAGS_RWS|BIO_FLAGS_SHOULD_RETRY))\n\n/* These should be used by the application to tell why we should retry */\n# define BIO_should_read(a)              BIO_test_flags(a, BIO_FLAGS_READ)\n# define BIO_should_write(a)             BIO_test_flags(a, BIO_FLAGS_WRITE)\n# define BIO_should_io_special(a)        BIO_test_flags(a, BIO_FLAGS_IO_SPECIAL)\n# define BIO_retry_type(a)               BIO_test_flags(a, BIO_FLAGS_RWS)\n# define BIO_should_retry(a)             BIO_test_flags(a, BIO_FLAGS_SHOULD_RETRY)\n\n/*\n * The next three are used in conjunction with the BIO_should_io_special()\n * condition.  After this returns true, BIO *BIO_get_retry_BIO(BIO *bio, int\n * *reason); will walk the BIO stack and return the 'reason' for the special\n * and the offending BIO. Given a BIO, BIO_get_retry_reason(bio) will return\n * the code.\n */\n/*\n * Returned from the SSL bio when the certificate retrieval code had an error\n */\n# define BIO_RR_SSL_X509_LOOKUP          0x01\n/* Returned from the connect BIO when a connect would have blocked */\n# define BIO_RR_CONNECT                  0x02\n/* Returned from the accept BIO when an accept would have blocked */\n# define BIO_RR_ACCEPT                   0x03\n\n/* These are passed by the BIO callback */\n# define BIO_CB_FREE     0x01\n# define BIO_CB_READ     0x02\n# define BIO_CB_WRITE    0x03\n# define BIO_CB_PUTS     0x04\n# define BIO_CB_GETS     0x05\n# define BIO_CB_CTRL     0x06\n\n/*\n * The callback is called before and after the underling operation, The\n * BIO_CB_RETURN flag indicates if it is after the call\n */\n# define BIO_CB_RETURN   0x80\n# define BIO_CB_return(a) ((a)|BIO_CB_RETURN)\n# define BIO_cb_pre(a)   (!((a)&BIO_CB_RETURN))\n# define BIO_cb_post(a)  ((a)&BIO_CB_RETURN)\n\nlong (*BIO_get_callback(const BIO *b)) (struct bio_st *, int, const char *,\n                                        int, long, long);\nvoid BIO_set_callback(BIO *b,\n                      long (*callback) (struct bio_st *, int, const char *,\n                                        int, long, long));\nchar *BIO_get_callback_arg(const BIO *b);\nvoid BIO_set_callback_arg(BIO *b, char *arg);\n\nconst char *BIO_method_name(const BIO *b);\nint BIO_method_type(const BIO *b);\n\ntypedef void bio_info_cb (struct bio_st *, int, const char *, int, long,\n                          long);\n\ntypedef struct bio_method_st {\n    int type;\n    const char *name;\n    int (*bwrite) (BIO *, const char *, int);\n    int (*bread) (BIO *, char *, int);\n    int (*bputs) (BIO *, const char *);\n    int (*bgets) (BIO *, char *, int);\n    long (*ctrl) (BIO *, int, long, void *);\n    int (*create) (BIO *);\n    int (*destroy) (BIO *);\n    long (*callback_ctrl) (BIO *, int, bio_info_cb *);\n} BIO_METHOD;\n\nstruct bio_st {\n    BIO_METHOD *method;\n    /* bio, mode, argp, argi, argl, ret */\n    long (*callback) (struct bio_st *, int, const char *, int, long, long);\n    char *cb_arg;               /* first argument for the callback */\n    int init;\n    int shutdown;\n    int flags;                  /* extra storage */\n    int retry_reason;\n    int num;\n    void *ptr;\n    struct bio_st *next_bio;    /* used by filter BIOs */\n    struct bio_st *prev_bio;    /* used by filter BIOs */\n    int references;\n    unsigned long num_read;\n    unsigned long num_write;\n    CRYPTO_EX_DATA ex_data;\n};\n\nDECLARE_STACK_OF(BIO)\n\ntypedef struct bio_f_buffer_ctx_struct {\n    /*-\n     * Buffers are setup like this:\n     *\n     * <---------------------- size ----------------------->\n     * +---------------------------------------------------+\n     * | consumed | remaining          | free space        |\n     * +---------------------------------------------------+\n     * <-- off --><------- len ------->\n     */\n    /*- BIO *bio; *//*\n     * this is now in the BIO struct\n     */\n    int ibuf_size;              /* how big is the input buffer */\n    int obuf_size;              /* how big is the output buffer */\n    char *ibuf;                 /* the char array */\n    int ibuf_len;               /* how many bytes are in it */\n    int ibuf_off;               /* write/read offset */\n    char *obuf;                 /* the char array */\n    int obuf_len;               /* how many bytes are in it */\n    int obuf_off;               /* write/read offset */\n} BIO_F_BUFFER_CTX;\n\n/* Prefix and suffix callback in ASN1 BIO */\ntypedef int asn1_ps_func (BIO *b, unsigned char **pbuf, int *plen,\n                          void *parg);\n\n# ifndef OPENSSL_NO_SCTP\n/* SCTP parameter structs */\nstruct bio_dgram_sctp_sndinfo {\n    uint16_t snd_sid;\n    uint16_t snd_flags;\n    uint32_t snd_ppid;\n    uint32_t snd_context;\n};\n\nstruct bio_dgram_sctp_rcvinfo {\n    uint16_t rcv_sid;\n    uint16_t rcv_ssn;\n    uint16_t rcv_flags;\n    uint32_t rcv_ppid;\n    uint32_t rcv_tsn;\n    uint32_t rcv_cumtsn;\n    uint32_t rcv_context;\n};\n\nstruct bio_dgram_sctp_prinfo {\n    uint16_t pr_policy;\n    uint32_t pr_value;\n};\n# endif\n\n/* connect BIO stuff */\n# define BIO_CONN_S_BEFORE               1\n# define BIO_CONN_S_GET_IP               2\n# define BIO_CONN_S_GET_PORT             3\n# define BIO_CONN_S_CREATE_SOCKET        4\n# define BIO_CONN_S_CONNECT              5\n# define BIO_CONN_S_OK                   6\n# define BIO_CONN_S_BLOCKED_CONNECT      7\n# define BIO_CONN_S_NBIO                 8\n/*\n * #define BIO_CONN_get_param_hostname BIO_ctrl\n */\n\n# define BIO_C_SET_CONNECT                       100\n# define BIO_C_DO_STATE_MACHINE                  101\n# define BIO_C_SET_NBIO                          102\n# define BIO_C_SET_PROXY_PARAM                   103\n# define BIO_C_SET_FD                            104\n# define BIO_C_GET_FD                            105\n# define BIO_C_SET_FILE_PTR                      106\n# define BIO_C_GET_FILE_PTR                      107\n# define BIO_C_SET_FILENAME                      108\n# define BIO_C_SET_SSL                           109\n# define BIO_C_GET_SSL                           110\n# define BIO_C_SET_MD                            111\n# define BIO_C_GET_MD                            112\n# define BIO_C_GET_CIPHER_STATUS                 113\n# define BIO_C_SET_BUF_MEM                       114\n# define BIO_C_GET_BUF_MEM_PTR                   115\n# define BIO_C_GET_BUFF_NUM_LINES                116\n# define BIO_C_SET_BUFF_SIZE                     117\n# define BIO_C_SET_ACCEPT                        118\n# define BIO_C_SSL_MODE                          119\n# define BIO_C_GET_MD_CTX                        120\n# define BIO_C_GET_PROXY_PARAM                   121\n# define BIO_C_SET_BUFF_READ_DATA                122/* data to read first */\n# define BIO_C_GET_CONNECT                       123\n# define BIO_C_GET_ACCEPT                        124\n# define BIO_C_SET_SSL_RENEGOTIATE_BYTES         125\n# define BIO_C_GET_SSL_NUM_RENEGOTIATES          126\n# define BIO_C_SET_SSL_RENEGOTIATE_TIMEOUT       127\n# define BIO_C_FILE_SEEK                         128\n# define BIO_C_GET_CIPHER_CTX                    129\n# define BIO_C_SET_BUF_MEM_EOF_RETURN            130/* return end of input\n                                                     * value */\n# define BIO_C_SET_BIND_MODE                     131\n# define BIO_C_GET_BIND_MODE                     132\n# define BIO_C_FILE_TELL                         133\n# define BIO_C_GET_SOCKS                         134\n# define BIO_C_SET_SOCKS                         135\n\n# define BIO_C_SET_WRITE_BUF_SIZE                136/* for BIO_s_bio */\n# define BIO_C_GET_WRITE_BUF_SIZE                137\n# define BIO_C_MAKE_BIO_PAIR                     138\n# define BIO_C_DESTROY_BIO_PAIR                  139\n# define BIO_C_GET_WRITE_GUARANTEE               140\n# define BIO_C_GET_READ_REQUEST                  141\n# define BIO_C_SHUTDOWN_WR                       142\n# define BIO_C_NREAD0                            143\n# define BIO_C_NREAD                             144\n# define BIO_C_NWRITE0                           145\n# define BIO_C_NWRITE                            146\n# define BIO_C_RESET_READ_REQUEST                147\n# define BIO_C_SET_MD_CTX                        148\n\n# define BIO_C_SET_PREFIX                        149\n# define BIO_C_GET_PREFIX                        150\n# define BIO_C_SET_SUFFIX                        151\n# define BIO_C_GET_SUFFIX                        152\n\n# define BIO_C_SET_EX_ARG                        153\n# define BIO_C_GET_EX_ARG                        154\n\n# define BIO_set_app_data(s,arg)         BIO_set_ex_data(s,0,arg)\n# define BIO_get_app_data(s)             BIO_get_ex_data(s,0)\n\n/* BIO_s_connect() and BIO_s_socks4a_connect() */\n# define BIO_set_conn_hostname(b,name) BIO_ctrl(b,BIO_C_SET_CONNECT,0,(char *)name)\n# define BIO_set_conn_port(b,port) BIO_ctrl(b,BIO_C_SET_CONNECT,1,(char *)port)\n# define BIO_set_conn_ip(b,ip)     BIO_ctrl(b,BIO_C_SET_CONNECT,2,(char *)ip)\n# define BIO_set_conn_int_port(b,port) BIO_ctrl(b,BIO_C_SET_CONNECT,3,(char *)port)\n# define BIO_get_conn_hostname(b)  BIO_ptr_ctrl(b,BIO_C_GET_CONNECT,0)\n# define BIO_get_conn_port(b)      BIO_ptr_ctrl(b,BIO_C_GET_CONNECT,1)\n# define BIO_get_conn_ip(b)               BIO_ptr_ctrl(b,BIO_C_GET_CONNECT,2)\n# define BIO_get_conn_int_port(b) BIO_ctrl(b,BIO_C_GET_CONNECT,3,NULL)\n\n# define BIO_set_nbio(b,n)       BIO_ctrl(b,BIO_C_SET_NBIO,(n),NULL)\n\n/* BIO_s_accept() */\n# define BIO_set_accept_port(b,name) BIO_ctrl(b,BIO_C_SET_ACCEPT,0,(char *)name)\n# define BIO_get_accept_port(b)  BIO_ptr_ctrl(b,BIO_C_GET_ACCEPT,0)\n/* #define BIO_set_nbio(b,n)    BIO_ctrl(b,BIO_C_SET_NBIO,(n),NULL) */\n# define BIO_set_nbio_accept(b,n) BIO_ctrl(b,BIO_C_SET_ACCEPT,1,(n)?(void *)\"a\":NULL)\n# define BIO_set_accept_bios(b,bio) BIO_ctrl(b,BIO_C_SET_ACCEPT,2,(char *)bio)\n\n# define BIO_BIND_NORMAL                 0\n# define BIO_BIND_REUSEADDR_IF_UNUSED    1\n# define BIO_BIND_REUSEADDR              2\n# define BIO_set_bind_mode(b,mode) BIO_ctrl(b,BIO_C_SET_BIND_MODE,mode,NULL)\n# define BIO_get_bind_mode(b,mode) BIO_ctrl(b,BIO_C_GET_BIND_MODE,0,NULL)\n\n/* BIO_s_accept() and BIO_s_connect() */\n# define BIO_do_connect(b)       BIO_do_handshake(b)\n# define BIO_do_accept(b)        BIO_do_handshake(b)\n# define BIO_do_handshake(b)     BIO_ctrl(b,BIO_C_DO_STATE_MACHINE,0,NULL)\n\n/* BIO_s_proxy_client() */\n# define BIO_set_url(b,url)      BIO_ctrl(b,BIO_C_SET_PROXY_PARAM,0,(char *)(url))\n# define BIO_set_proxies(b,p)    BIO_ctrl(b,BIO_C_SET_PROXY_PARAM,1,(char *)(p))\n/* BIO_set_nbio(b,n) */\n# define BIO_set_filter_bio(b,s) BIO_ctrl(b,BIO_C_SET_PROXY_PARAM,2,(char *)(s))\n/* BIO *BIO_get_filter_bio(BIO *bio); */\n# define BIO_set_proxy_cb(b,cb) BIO_callback_ctrl(b,BIO_C_SET_PROXY_PARAM,3,(void *(*cb)()))\n# define BIO_set_proxy_header(b,sk) BIO_ctrl(b,BIO_C_SET_PROXY_PARAM,4,(char *)sk)\n# define BIO_set_no_connect_return(b,bool) BIO_int_ctrl(b,BIO_C_SET_PROXY_PARAM,5,bool)\n\n# define BIO_get_proxy_header(b,skp) BIO_ctrl(b,BIO_C_GET_PROXY_PARAM,0,(char *)skp)\n# define BIO_get_proxies(b,pxy_p) BIO_ctrl(b,BIO_C_GET_PROXY_PARAM,1,(char *)(pxy_p))\n# define BIO_get_url(b,url)      BIO_ctrl(b,BIO_C_GET_PROXY_PARAM,2,(char *)(url))\n# define BIO_get_no_connect_return(b)    BIO_ctrl(b,BIO_C_GET_PROXY_PARAM,5,NULL)\n\n/* BIO_s_datagram(), BIO_s_fd(), BIO_s_socket(), BIO_s_accept() and BIO_s_connect() */\n# define BIO_set_fd(b,fd,c)      BIO_int_ctrl(b,BIO_C_SET_FD,c,fd)\n# define BIO_get_fd(b,c)         BIO_ctrl(b,BIO_C_GET_FD,0,(char *)c)\n\n/* BIO_s_file() */\n# define BIO_set_fp(b,fp,c)      BIO_ctrl(b,BIO_C_SET_FILE_PTR,c,(char *)fp)\n# define BIO_get_fp(b,fpp)       BIO_ctrl(b,BIO_C_GET_FILE_PTR,0,(char *)fpp)\n\n/* BIO_s_fd() and BIO_s_file() */\n# define BIO_seek(b,ofs) (int)BIO_ctrl(b,BIO_C_FILE_SEEK,ofs,NULL)\n# define BIO_tell(b)     (int)BIO_ctrl(b,BIO_C_FILE_TELL,0,NULL)\n\n/*\n * name is cast to lose const, but might be better to route through a\n * function so we can do it safely\n */\n# ifdef CONST_STRICT\n/*\n * If you are wondering why this isn't defined, its because CONST_STRICT is\n * purely a compile-time kludge to allow const to be checked.\n */\nint BIO_read_filename(BIO *b, const char *name);\n# else\n#  define BIO_read_filename(b,name) BIO_ctrl(b,BIO_C_SET_FILENAME, \\\n                BIO_CLOSE|BIO_FP_READ,(char *)name)\n# endif\n# define BIO_write_filename(b,name) BIO_ctrl(b,BIO_C_SET_FILENAME, \\\n                BIO_CLOSE|BIO_FP_WRITE,name)\n# define BIO_append_filename(b,name) BIO_ctrl(b,BIO_C_SET_FILENAME, \\\n                BIO_CLOSE|BIO_FP_APPEND,name)\n# define BIO_rw_filename(b,name) BIO_ctrl(b,BIO_C_SET_FILENAME, \\\n                BIO_CLOSE|BIO_FP_READ|BIO_FP_WRITE,name)\n\n/*\n * WARNING WARNING, this ups the reference count on the read bio of the SSL\n * structure.  This is because the ssl read BIO is now pointed to by the\n * next_bio field in the bio.  So when you free the BIO, make sure you are\n * doing a BIO_free_all() to catch the underlying BIO.\n */\n# define BIO_set_ssl(b,ssl,c)    BIO_ctrl(b,BIO_C_SET_SSL,c,(char *)ssl)\n# define BIO_get_ssl(b,sslp)     BIO_ctrl(b,BIO_C_GET_SSL,0,(char *)sslp)\n# define BIO_set_ssl_mode(b,client)      BIO_ctrl(b,BIO_C_SSL_MODE,client,NULL)\n# define BIO_set_ssl_renegotiate_bytes(b,num) \\\n        BIO_ctrl(b,BIO_C_SET_SSL_RENEGOTIATE_BYTES,num,NULL)\n# define BIO_get_num_renegotiates(b) \\\n        BIO_ctrl(b,BIO_C_GET_SSL_NUM_RENEGOTIATES,0,NULL)\n# define BIO_set_ssl_renegotiate_timeout(b,seconds) \\\n        BIO_ctrl(b,BIO_C_SET_SSL_RENEGOTIATE_TIMEOUT,seconds,NULL)\n\n/* defined in evp.h */\n/* #define BIO_set_md(b,md)     BIO_ctrl(b,BIO_C_SET_MD,1,(char *)md) */\n\n# define BIO_get_mem_data(b,pp)  BIO_ctrl(b,BIO_CTRL_INFO,0,(char *)pp)\n# define BIO_set_mem_buf(b,bm,c) BIO_ctrl(b,BIO_C_SET_BUF_MEM,c,(char *)bm)\n# define BIO_get_mem_ptr(b,pp)   BIO_ctrl(b,BIO_C_GET_BUF_MEM_PTR,0,(char *)pp)\n# define BIO_set_mem_eof_return(b,v) \\\n                                BIO_ctrl(b,BIO_C_SET_BUF_MEM_EOF_RETURN,v,NULL)\n\n/* For the BIO_f_buffer() type */\n# define BIO_get_buffer_num_lines(b)     BIO_ctrl(b,BIO_C_GET_BUFF_NUM_LINES,0,NULL)\n# define BIO_set_buffer_size(b,size)     BIO_ctrl(b,BIO_C_SET_BUFF_SIZE,size,NULL)\n# define BIO_set_read_buffer_size(b,size) BIO_int_ctrl(b,BIO_C_SET_BUFF_SIZE,size,0)\n# define BIO_set_write_buffer_size(b,size) BIO_int_ctrl(b,BIO_C_SET_BUFF_SIZE,size,1)\n# define BIO_set_buffer_read_data(b,buf,num) BIO_ctrl(b,BIO_C_SET_BUFF_READ_DATA,num,buf)\n\n/* Don't use the next one unless you know what you are doing :-) */\n# define BIO_dup_state(b,ret)    BIO_ctrl(b,BIO_CTRL_DUP,0,(char *)(ret))\n\n# define BIO_reset(b)            (int)BIO_ctrl(b,BIO_CTRL_RESET,0,NULL)\n# define BIO_eof(b)              (int)BIO_ctrl(b,BIO_CTRL_EOF,0,NULL)\n# define BIO_set_close(b,c)      (int)BIO_ctrl(b,BIO_CTRL_SET_CLOSE,(c),NULL)\n# define BIO_get_close(b)        (int)BIO_ctrl(b,BIO_CTRL_GET_CLOSE,0,NULL)\n# define BIO_pending(b)          (int)BIO_ctrl(b,BIO_CTRL_PENDING,0,NULL)\n# define BIO_wpending(b)         (int)BIO_ctrl(b,BIO_CTRL_WPENDING,0,NULL)\n/* ...pending macros have inappropriate return type */\nsize_t BIO_ctrl_pending(BIO *b);\nsize_t BIO_ctrl_wpending(BIO *b);\n# define BIO_flush(b)            (int)BIO_ctrl(b,BIO_CTRL_FLUSH,0,NULL)\n# define BIO_get_info_callback(b,cbp) (int)BIO_ctrl(b,BIO_CTRL_GET_CALLBACK,0, \\\n                                                   cbp)\n# define BIO_set_info_callback(b,cb) (int)BIO_callback_ctrl(b,BIO_CTRL_SET_CALLBACK,cb)\n\n/* For the BIO_f_buffer() type */\n# define BIO_buffer_get_num_lines(b) BIO_ctrl(b,BIO_CTRL_GET,0,NULL)\n\n/* For BIO_s_bio() */\n# define BIO_set_write_buf_size(b,size) (int)BIO_ctrl(b,BIO_C_SET_WRITE_BUF_SIZE,size,NULL)\n# define BIO_get_write_buf_size(b,size) (size_t)BIO_ctrl(b,BIO_C_GET_WRITE_BUF_SIZE,size,NULL)\n# define BIO_make_bio_pair(b1,b2)   (int)BIO_ctrl(b1,BIO_C_MAKE_BIO_PAIR,0,b2)\n# define BIO_destroy_bio_pair(b)    (int)BIO_ctrl(b,BIO_C_DESTROY_BIO_PAIR,0,NULL)\n# define BIO_shutdown_wr(b) (int)BIO_ctrl(b, BIO_C_SHUTDOWN_WR, 0, NULL)\n/* macros with inappropriate type -- but ...pending macros use int too: */\n# define BIO_get_write_guarantee(b) (int)BIO_ctrl(b,BIO_C_GET_WRITE_GUARANTEE,0,NULL)\n# define BIO_get_read_request(b)    (int)BIO_ctrl(b,BIO_C_GET_READ_REQUEST,0,NULL)\nsize_t BIO_ctrl_get_write_guarantee(BIO *b);\nsize_t BIO_ctrl_get_read_request(BIO *b);\nint BIO_ctrl_reset_read_request(BIO *b);\n\n/* ctrl macros for dgram */\n# define BIO_ctrl_dgram_connect(b,peer)  \\\n                     (int)BIO_ctrl(b,BIO_CTRL_DGRAM_CONNECT,0, (char *)peer)\n# define BIO_ctrl_set_connected(b, state, peer) \\\n         (int)BIO_ctrl(b, BIO_CTRL_DGRAM_SET_CONNECTED, state, (char *)peer)\n# define BIO_dgram_recv_timedout(b) \\\n         (int)BIO_ctrl(b, BIO_CTRL_DGRAM_GET_RECV_TIMER_EXP, 0, NULL)\n# define BIO_dgram_send_timedout(b) \\\n         (int)BIO_ctrl(b, BIO_CTRL_DGRAM_GET_SEND_TIMER_EXP, 0, NULL)\n# define BIO_dgram_get_peer(b,peer) \\\n         (int)BIO_ctrl(b, BIO_CTRL_DGRAM_GET_PEER, 0, (char *)peer)\n# define BIO_dgram_set_peer(b,peer) \\\n         (int)BIO_ctrl(b, BIO_CTRL_DGRAM_SET_PEER, 0, (char *)peer)\n# define BIO_dgram_get_mtu_overhead(b) \\\n         (unsigned int)BIO_ctrl((b), BIO_CTRL_DGRAM_GET_MTU_OVERHEAD, 0, NULL)\n\n/* These two aren't currently implemented */\n/* int BIO_get_ex_num(BIO *bio); */\n/* void BIO_set_ex_free_func(BIO *bio,int idx,void (*cb)()); */\nint BIO_set_ex_data(BIO *bio, int idx, void *data);\nvoid *BIO_get_ex_data(BIO *bio, int idx);\nint BIO_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func,\n                         CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func);\nunsigned long BIO_number_read(BIO *bio);\nunsigned long BIO_number_written(BIO *bio);\n\n/* For BIO_f_asn1() */\nint BIO_asn1_set_prefix(BIO *b, asn1_ps_func *prefix,\n                        asn1_ps_func *prefix_free);\nint BIO_asn1_get_prefix(BIO *b, asn1_ps_func **pprefix,\n                        asn1_ps_func **pprefix_free);\nint BIO_asn1_set_suffix(BIO *b, asn1_ps_func *suffix,\n                        asn1_ps_func *suffix_free);\nint BIO_asn1_get_suffix(BIO *b, asn1_ps_func **psuffix,\n                        asn1_ps_func **psuffix_free);\n\n# ifndef OPENSSL_NO_FP_API\nBIO_METHOD *BIO_s_file(void);\nBIO *BIO_new_file(const char *filename, const char *mode);\nBIO *BIO_new_fp(FILE *stream, int close_flag);\n#  define BIO_s_file_internal    BIO_s_file\n# endif\nBIO *BIO_new(BIO_METHOD *type);\nint BIO_set(BIO *a, BIO_METHOD *type);\nint BIO_free(BIO *a);\nvoid BIO_vfree(BIO *a);\nint BIO_read(BIO *b, void *data, int len);\nint BIO_gets(BIO *bp, char *buf, int size);\nint BIO_write(BIO *b, const void *data, int len);\nint BIO_puts(BIO *bp, const char *buf);\nint BIO_indent(BIO *b, int indent, int max);\nlong BIO_ctrl(BIO *bp, int cmd, long larg, void *parg);\nlong BIO_callback_ctrl(BIO *b, int cmd,\n                       void (*fp) (struct bio_st *, int, const char *, int,\n                                   long, long));\nchar *BIO_ptr_ctrl(BIO *bp, int cmd, long larg);\nlong BIO_int_ctrl(BIO *bp, int cmd, long larg, int iarg);\nBIO *BIO_push(BIO *b, BIO *append);\nBIO *BIO_pop(BIO *b);\nvoid BIO_free_all(BIO *a);\nBIO *BIO_find_type(BIO *b, int bio_type);\nBIO *BIO_next(BIO *b);\nBIO *BIO_get_retry_BIO(BIO *bio, int *reason);\nint BIO_get_retry_reason(BIO *bio);\nBIO *BIO_dup_chain(BIO *in);\n\nint BIO_nread0(BIO *bio, char **buf);\nint BIO_nread(BIO *bio, char **buf, int num);\nint BIO_nwrite0(BIO *bio, char **buf);\nint BIO_nwrite(BIO *bio, char **buf, int num);\n\nlong BIO_debug_callback(BIO *bio, int cmd, const char *argp, int argi,\n                        long argl, long ret);\n\nBIO_METHOD *BIO_s_mem(void);\nBIO *BIO_new_mem_buf(const void *buf, int len);\nBIO_METHOD *BIO_s_socket(void);\nBIO_METHOD *BIO_s_connect(void);\nBIO_METHOD *BIO_s_accept(void);\nBIO_METHOD *BIO_s_fd(void);\n# ifndef OPENSSL_SYS_OS2\nBIO_METHOD *BIO_s_log(void);\n# endif\nBIO_METHOD *BIO_s_bio(void);\nBIO_METHOD *BIO_s_null(void);\nBIO_METHOD *BIO_f_null(void);\nBIO_METHOD *BIO_f_buffer(void);\n# ifdef OPENSSL_SYS_VMS\nBIO_METHOD *BIO_f_linebuffer(void);\n# endif\nBIO_METHOD *BIO_f_nbio_test(void);\n# ifndef OPENSSL_NO_DGRAM\nBIO_METHOD *BIO_s_datagram(void);\n#  ifndef OPENSSL_NO_SCTP\nBIO_METHOD *BIO_s_datagram_sctp(void);\n#  endif\n# endif\n\n/* BIO_METHOD *BIO_f_ber(void); */\n\nint BIO_sock_should_retry(int i);\nint BIO_sock_non_fatal_error(int error);\nint BIO_dgram_non_fatal_error(int error);\n\nint BIO_fd_should_retry(int i);\nint BIO_fd_non_fatal_error(int error);\nint BIO_dump_cb(int (*cb) (const void *data, size_t len, void *u),\n                void *u, const char *s, int len);\nint BIO_dump_indent_cb(int (*cb) (const void *data, size_t len, void *u),\n                       void *u, const char *s, int len, int indent);\nint BIO_dump(BIO *b, const char *bytes, int len);\nint BIO_dump_indent(BIO *b, const char *bytes, int len, int indent);\n# ifndef OPENSSL_NO_FP_API\nint BIO_dump_fp(FILE *fp, const char *s, int len);\nint BIO_dump_indent_fp(FILE *fp, const char *s, int len, int indent);\n# endif\nint BIO_hex_string(BIO *out, int indent, int width, unsigned char *data,\n                   int datalen);\n\nstruct hostent *BIO_gethostbyname(const char *name);\n/*-\n * We might want a thread-safe interface too:\n * struct hostent *BIO_gethostbyname_r(const char *name,\n *     struct hostent *result, void *buffer, size_t buflen);\n * or something similar (caller allocates a struct hostent,\n * pointed to by \"result\", and additional buffer space for the various\n * substructures; if the buffer does not suffice, NULL is returned\n * and an appropriate error code is set).\n */\nint BIO_sock_error(int sock);\nint BIO_socket_ioctl(int fd, long type, void *arg);\nint BIO_socket_nbio(int fd, int mode);\nint BIO_get_port(const char *str, unsigned short *port_ptr);\nint BIO_get_host_ip(const char *str, unsigned char *ip);\nint BIO_get_accept_socket(char *host_port, int mode);\nint BIO_accept(int sock, char **ip_port);\nint BIO_sock_init(void);\nvoid BIO_sock_cleanup(void);\nint BIO_set_tcp_ndelay(int sock, int turn_on);\n\nBIO *BIO_new_socket(int sock, int close_flag);\nBIO *BIO_new_dgram(int fd, int close_flag);\n# ifndef OPENSSL_NO_SCTP\nBIO *BIO_new_dgram_sctp(int fd, int close_flag);\nint BIO_dgram_is_sctp(BIO *bio);\nint BIO_dgram_sctp_notification_cb(BIO *b,\n                                   void (*handle_notifications) (BIO *bio,\n                                                                 void\n                                                                 *context,\n                                                                 void *buf),\n                                   void *context);\nint BIO_dgram_sctp_wait_for_dry(BIO *b);\nint BIO_dgram_sctp_msg_waiting(BIO *b);\n# endif\nBIO *BIO_new_fd(int fd, int close_flag);\nBIO *BIO_new_connect(const char *host_port);\nBIO *BIO_new_accept(const char *host_port);\n\nint BIO_new_bio_pair(BIO **bio1, size_t writebuf1,\n                     BIO **bio2, size_t writebuf2);\n/*\n * If successful, returns 1 and in *bio1, *bio2 two BIO pair endpoints.\n * Otherwise returns 0 and sets *bio1 and *bio2 to NULL. Size 0 uses default\n * value.\n */\n\nvoid BIO_copy_next_retry(BIO *b);\n\n/*\n * long BIO_ghbn_ctrl(int cmd,int iarg,char *parg);\n */\n\n# ifdef __GNUC__\n#  define __bio_h__attr__ __attribute__\n# else\n#  define __bio_h__attr__(x)\n# endif\nint BIO_printf(BIO *bio, const char *format, ...)\n__bio_h__attr__((__format__(__printf__, 2, 3)));\nint BIO_vprintf(BIO *bio, const char *format, va_list args)\n__bio_h__attr__((__format__(__printf__, 2, 0)));\nint BIO_snprintf(char *buf, size_t n, const char *format, ...)\n__bio_h__attr__((__format__(__printf__, 3, 4)));\nint BIO_vsnprintf(char *buf, size_t n, const char *format, va_list args)\n__bio_h__attr__((__format__(__printf__, 3, 0)));\n# undef __bio_h__attr__\n\n/* BEGIN ERROR CODES */\n/*\n * The following lines are auto generated by the script mkerr.pl. Any changes\n * made after this point may be overwritten when the script is next run.\n */\nvoid ERR_load_BIO_strings(void);\n\n/* Error codes for the BIO functions. */\n\n/* Function codes. */\n# define BIO_F_ACPT_STATE                                 100\n# define BIO_F_BIO_ACCEPT                                 101\n# define BIO_F_BIO_BER_GET_HEADER                         102\n# define BIO_F_BIO_CALLBACK_CTRL                          131\n# define BIO_F_BIO_CTRL                                   103\n# define BIO_F_BIO_GETHOSTBYNAME                          120\n# define BIO_F_BIO_GETS                                   104\n# define BIO_F_BIO_GET_ACCEPT_SOCKET                      105\n# define BIO_F_BIO_GET_HOST_IP                            106\n# define BIO_F_BIO_GET_PORT                               107\n# define BIO_F_BIO_MAKE_PAIR                              121\n# define BIO_F_BIO_NEW                                    108\n# define BIO_F_BIO_NEW_FILE                               109\n# define BIO_F_BIO_NEW_MEM_BUF                            126\n# define BIO_F_BIO_NREAD                                  123\n# define BIO_F_BIO_NREAD0                                 124\n# define BIO_F_BIO_NWRITE                                 125\n# define BIO_F_BIO_NWRITE0                                122\n# define BIO_F_BIO_PUTS                                   110\n# define BIO_F_BIO_READ                                   111\n# define BIO_F_BIO_SOCK_INIT                              112\n# define BIO_F_BIO_WRITE                                  113\n# define BIO_F_BUFFER_CTRL                                114\n# define BIO_F_CONN_CTRL                                  127\n# define BIO_F_CONN_STATE                                 115\n# define BIO_F_DGRAM_SCTP_READ                            132\n# define BIO_F_DGRAM_SCTP_WRITE                           133\n# define BIO_F_FILE_CTRL                                  116\n# define BIO_F_FILE_READ                                  130\n# define BIO_F_LINEBUFFER_CTRL                            129\n# define BIO_F_MEM_READ                                   128\n# define BIO_F_MEM_WRITE                                  117\n# define BIO_F_SSL_NEW                                    118\n# define BIO_F_WSASTARTUP                                 119\n\n/* Reason codes. */\n# define BIO_R_ACCEPT_ERROR                               100\n# define BIO_R_BAD_FOPEN_MODE                             101\n# define BIO_R_BAD_HOSTNAME_LOOKUP                        102\n# define BIO_R_BROKEN_PIPE                                124\n# define BIO_R_CONNECT_ERROR                              103\n# define BIO_R_EOF_ON_MEMORY_BIO                          127\n# define BIO_R_ERROR_SETTING_NBIO                         104\n# define BIO_R_ERROR_SETTING_NBIO_ON_ACCEPTED_SOCKET      105\n# define BIO_R_ERROR_SETTING_NBIO_ON_ACCEPT_SOCKET        106\n# define BIO_R_GETHOSTBYNAME_ADDR_IS_NOT_AF_INET          107\n# define BIO_R_INVALID_ARGUMENT                           125\n# define BIO_R_INVALID_IP_ADDRESS                         108\n# define BIO_R_IN_USE                                     123\n# define BIO_R_KEEPALIVE                                  109\n# define BIO_R_NBIO_CONNECT_ERROR                         110\n# define BIO_R_NO_ACCEPT_PORT_SPECIFIED                   111\n# define BIO_R_NO_HOSTNAME_SPECIFIED                      112\n# define BIO_R_NO_PORT_DEFINED                            113\n# define BIO_R_NO_PORT_SPECIFIED                          114\n# define BIO_R_NO_SUCH_FILE                               128\n# define BIO_R_NULL_PARAMETER                             115\n# define BIO_R_TAG_MISMATCH                               116\n# define BIO_R_UNABLE_TO_BIND_SOCKET                      117\n# define BIO_R_UNABLE_TO_CREATE_SOCKET                    118\n# define BIO_R_UNABLE_TO_LISTEN_SOCKET                    119\n# define BIO_R_UNINITIALIZED                              120\n# define BIO_R_UNSUPPORTED_METHOD                         121\n# define BIO_R_WRITE_TO_READ_ONLY_BIO                     126\n# define BIO_R_WSASTARTUP                                 122\n\n#ifdef  __cplusplus\n}\n#endif\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/x86/include/openssl/blowfish.h",
    "content": "/* crypto/bf/blowfish.h */\n/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)\n * All rights reserved.\n *\n * This package is an SSL implementation written\n * by Eric Young (eay@cryptsoft.com).\n * The implementation was written so as to conform with Netscapes SSL.\n *\n * This library is free for commercial and non-commercial use as long as\n * the following conditions are aheared to.  The following conditions\n * apply to all code found in this distribution, be it the RC4, RSA,\n * lhash, DES, etc., code; not just the SSL code.  The SSL documentation\n * included with this distribution is covered by the same copyright terms\n * except that the holder is Tim Hudson (tjh@cryptsoft.com).\n *\n * Copyright remains Eric Young's, and as such any Copyright notices in\n * the code are not to be removed.\n * If this package is used in a product, Eric Young should be given attribution\n * as the author of the parts of the library used.\n * This can be in the form of a textual message at program startup or\n * in documentation (online or textual) provided with the package.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the copyright\n *    notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in the\n *    documentation and/or other materials provided with the distribution.\n * 3. All advertising materials mentioning features or use of this software\n *    must display the following acknowledgement:\n *    \"This product includes cryptographic software written by\n *     Eric Young (eay@cryptsoft.com)\"\n *    The word 'cryptographic' can be left out if the rouines from the library\n *    being used are not cryptographic related :-).\n * 4. If you include any Windows specific code (or a derivative thereof) from\n *    the apps directory (application code) you must include an acknowledgement:\n *    \"This product includes software written by Tim Hudson (tjh@cryptsoft.com)\"\n *\n * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n * SUCH DAMAGE.\n *\n * The licence and distribution terms for any publically available version or\n * derivative of this code cannot be changed.  i.e. this code cannot simply be\n * copied and put under another distribution licence\n * [including the GNU Public Licence.]\n */\n\n#ifndef HEADER_BLOWFISH_H\n# define HEADER_BLOWFISH_H\n\n# include <openssl/e_os2.h>\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n# ifdef OPENSSL_NO_BF\n#  error BF is disabled.\n# endif\n\n# define BF_ENCRYPT      1\n# define BF_DECRYPT      0\n\n/*-\n * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n * ! BF_LONG has to be at least 32 bits wide. If it's wider, then !\n * ! BF_LONG_LOG2 has to be defined along.                        !\n * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n */\n\n# if defined(__LP32__)\n#  define BF_LONG unsigned long\n# elif defined(OPENSSL_SYS_CRAY) || defined(__ILP64__)\n#  define BF_LONG unsigned long\n#  define BF_LONG_LOG2 3\n/*\n * _CRAY note. I could declare short, but I have no idea what impact\n * does it have on performance on none-T3E machines. I could declare\n * int, but at least on C90 sizeof(int) can be chosen at compile time.\n * So I've chosen long...\n *                                      <appro@fy.chalmers.se>\n */\n# else\n#  define BF_LONG unsigned int\n# endif\n\n# define BF_ROUNDS       16\n# define BF_BLOCK        8\n\ntypedef struct bf_key_st {\n    BF_LONG P[BF_ROUNDS + 2];\n    BF_LONG S[4 * 256];\n} BF_KEY;\n\n# ifdef OPENSSL_FIPS\nvoid private_BF_set_key(BF_KEY *key, int len, const unsigned char *data);\n# endif\nvoid BF_set_key(BF_KEY *key, int len, const unsigned char *data);\n\nvoid BF_encrypt(BF_LONG *data, const BF_KEY *key);\nvoid BF_decrypt(BF_LONG *data, const BF_KEY *key);\n\nvoid BF_ecb_encrypt(const unsigned char *in, unsigned char *out,\n                    const BF_KEY *key, int enc);\nvoid BF_cbc_encrypt(const unsigned char *in, unsigned char *out, long length,\n                    const BF_KEY *schedule, unsigned char *ivec, int enc);\nvoid BF_cfb64_encrypt(const unsigned char *in, unsigned char *out,\n                      long length, const BF_KEY *schedule,\n                      unsigned char *ivec, int *num, int enc);\nvoid BF_ofb64_encrypt(const unsigned char *in, unsigned char *out,\n                      long length, const BF_KEY *schedule,\n                      unsigned char *ivec, int *num);\nconst char *BF_options(void);\n\n#ifdef  __cplusplus\n}\n#endif\n\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/x86/include/openssl/bn.h",
    "content": "/* crypto/bn/bn.h */\n/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)\n * All rights reserved.\n *\n * This package is an SSL implementation written\n * by Eric Young (eay@cryptsoft.com).\n * The implementation was written so as to conform with Netscapes SSL.\n *\n * This library is free for commercial and non-commercial use as long as\n * the following conditions are aheared to.  The following conditions\n * apply to all code found in this distribution, be it the RC4, RSA,\n * lhash, DES, etc., code; not just the SSL code.  The SSL documentation\n * included with this distribution is covered by the same copyright terms\n * except that the holder is Tim Hudson (tjh@cryptsoft.com).\n *\n * Copyright remains Eric Young's, and as such any Copyright notices in\n * the code are not to be removed.\n * If this package is used in a product, Eric Young should be given attribution\n * as the author of the parts of the library used.\n * This can be in the form of a textual message at program startup or\n * in documentation (online or textual) provided with the package.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the copyright\n *    notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in the\n *    documentation and/or other materials provided with the distribution.\n * 3. All advertising materials mentioning features or use of this software\n *    must display the following acknowledgement:\n *    \"This product includes cryptographic software written by\n *     Eric Young (eay@cryptsoft.com)\"\n *    The word 'cryptographic' can be left out if the rouines from the library\n *    being used are not cryptographic related :-).\n * 4. If you include any Windows specific code (or a derivative thereof) from\n *    the apps directory (application code) you must include an acknowledgement:\n *    \"This product includes software written by Tim Hudson (tjh@cryptsoft.com)\"\n *\n * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n * SUCH DAMAGE.\n *\n * The licence and distribution terms for any publically available version or\n * derivative of this code cannot be changed.  i.e. this code cannot simply be\n * copied and put under another distribution licence\n * [including the GNU Public Licence.]\n */\n/* ====================================================================\n * Copyright (c) 1998-2006 The OpenSSL Project.  All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n *\n * 1. Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n *\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in\n *    the documentation and/or other materials provided with the\n *    distribution.\n *\n * 3. All advertising materials mentioning features or use of this\n *    software must display the following acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit. (http://www.openssl.org/)\"\n *\n * 4. The names \"OpenSSL Toolkit\" and \"OpenSSL Project\" must not be used to\n *    endorse or promote products derived from this software without\n *    prior written permission. For written permission, please contact\n *    openssl-core@openssl.org.\n *\n * 5. Products derived from this software may not be called \"OpenSSL\"\n *    nor may \"OpenSSL\" appear in their names without prior written\n *    permission of the OpenSSL Project.\n *\n * 6. Redistributions of any form whatsoever must retain the following\n *    acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit (http://www.openssl.org/)\"\n *\n * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY\n * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\n * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR\n * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\n * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,\n * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED\n * OF THE POSSIBILITY OF SUCH DAMAGE.\n * ====================================================================\n *\n * This product includes cryptographic software written by Eric Young\n * (eay@cryptsoft.com).  This product includes software written by Tim\n * Hudson (tjh@cryptsoft.com).\n *\n */\n/* ====================================================================\n * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED.\n *\n * Portions of the attached software (\"Contribution\") are developed by\n * SUN MICROSYSTEMS, INC., and are contributed to the OpenSSL project.\n *\n * The Contribution is licensed pursuant to the Eric Young open source\n * license provided above.\n *\n * The binary polynomial arithmetic software is originally written by\n * Sheueling Chang Shantz and Douglas Stebila of Sun Microsystems Laboratories.\n *\n */\n\n#ifndef HEADER_BN_H\n# define HEADER_BN_H\n\n# include <limits.h>\n# include <openssl/e_os2.h>\n# ifndef OPENSSL_NO_FP_API\n#  include <stdio.h>            /* FILE */\n# endif\n# include <openssl/ossl_typ.h>\n# include <openssl/crypto.h>\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n/*\n * These preprocessor symbols control various aspects of the bignum headers\n * and library code. They're not defined by any \"normal\" configuration, as\n * they are intended for development and testing purposes. NB: defining all\n * three can be useful for debugging application code as well as openssl\n * itself. BN_DEBUG - turn on various debugging alterations to the bignum\n * code BN_DEBUG_RAND - uses random poisoning of unused words to trip up\n * mismanagement of bignum internals. You must also define BN_DEBUG.\n */\n/* #define BN_DEBUG */\n/* #define BN_DEBUG_RAND */\n\n# ifndef OPENSSL_SMALL_FOOTPRINT\n#  define BN_MUL_COMBA\n#  define BN_SQR_COMBA\n#  define BN_RECURSION\n# endif\n\n/*\n * This next option uses the C libraries (2 word)/(1 word) function. If it is\n * not defined, I use my C version (which is slower). The reason for this\n * flag is that when the particular C compiler library routine is used, and\n * the library is linked with a different compiler, the library is missing.\n * This mostly happens when the library is built with gcc and then linked\n * using normal cc.  This would be a common occurrence because gcc normally\n * produces code that is 2 times faster than system compilers for the big\n * number stuff. For machines with only one compiler (or shared libraries),\n * this should be on.  Again this in only really a problem on machines using\n * \"long long's\", are 32bit, and are not using my assembler code.\n */\n# if defined(OPENSSL_SYS_MSDOS) || defined(OPENSSL_SYS_WINDOWS) || \\\n    defined(OPENSSL_SYS_WIN32) || defined(linux)\n#  ifndef BN_DIV2W\n#   define BN_DIV2W\n#  endif\n# endif\n\n/*\n * assuming long is 64bit - this is the DEC Alpha unsigned long long is only\n * 64 bits :-(, don't define BN_LLONG for the DEC Alpha\n */\n# ifdef SIXTY_FOUR_BIT_LONG\n#  define BN_ULLONG       unsigned long long\n#  define BN_ULONG        unsigned long\n#  define BN_LONG         long\n#  define BN_BITS         128\n#  define BN_BYTES        8\n#  define BN_BITS2        64\n#  define BN_BITS4        32\n#  define BN_MASK         (0xffffffffffffffffffffffffffffffffLL)\n#  define BN_MASK2        (0xffffffffffffffffL)\n#  define BN_MASK2l       (0xffffffffL)\n#  define BN_MASK2h       (0xffffffff00000000L)\n#  define BN_MASK2h1      (0xffffffff80000000L)\n#  define BN_TBIT         (0x8000000000000000L)\n#  define BN_DEC_CONV     (10000000000000000000UL)\n#  define BN_DEC_FMT1     \"%lu\"\n#  define BN_DEC_FMT2     \"%019lu\"\n#  define BN_DEC_NUM      19\n#  define BN_HEX_FMT1     \"%lX\"\n#  define BN_HEX_FMT2     \"%016lX\"\n# endif\n\n/*\n * This is where the long long data type is 64 bits, but long is 32. For\n * machines where there are 64bit registers, this is the mode to use. IRIX,\n * on R4000 and above should use this mode, along with the relevant assembler\n * code :-).  Do NOT define BN_LLONG.\n */\n# ifdef SIXTY_FOUR_BIT\n#  undef BN_LLONG\n#  undef BN_ULLONG\n#  define BN_ULONG        unsigned long long\n#  define BN_LONG         long long\n#  define BN_BITS         128\n#  define BN_BYTES        8\n#  define BN_BITS2        64\n#  define BN_BITS4        32\n#  define BN_MASK2        (0xffffffffffffffffLL)\n#  define BN_MASK2l       (0xffffffffL)\n#  define BN_MASK2h       (0xffffffff00000000LL)\n#  define BN_MASK2h1      (0xffffffff80000000LL)\n#  define BN_TBIT         (0x8000000000000000LL)\n#  define BN_DEC_CONV     (10000000000000000000ULL)\n#  define BN_DEC_FMT1     \"%llu\"\n#  define BN_DEC_FMT2     \"%019llu\"\n#  define BN_DEC_NUM      19\n#  define BN_HEX_FMT1     \"%llX\"\n#  define BN_HEX_FMT2     \"%016llX\"\n# endif\n\n# ifdef THIRTY_TWO_BIT\n#  ifdef BN_LLONG\n#   if defined(_WIN32) && !defined(__GNUC__)\n#    define BN_ULLONG     unsigned __int64\n#    define BN_MASK       (0xffffffffffffffffI64)\n#   else\n#    define BN_ULLONG     unsigned long long\n#    define BN_MASK       (0xffffffffffffffffLL)\n#   endif\n#  endif\n#  define BN_ULONG        unsigned int\n#  define BN_LONG         int\n#  define BN_BITS         64\n#  define BN_BYTES        4\n#  define BN_BITS2        32\n#  define BN_BITS4        16\n#  define BN_MASK2        (0xffffffffL)\n#  define BN_MASK2l       (0xffff)\n#  define BN_MASK2h1      (0xffff8000L)\n#  define BN_MASK2h       (0xffff0000L)\n#  define BN_TBIT         (0x80000000L)\n#  define BN_DEC_CONV     (1000000000L)\n#  define BN_DEC_FMT1     \"%u\"\n#  define BN_DEC_FMT2     \"%09u\"\n#  define BN_DEC_NUM      9\n#  define BN_HEX_FMT1     \"%X\"\n#  define BN_HEX_FMT2     \"%08X\"\n# endif\n\n# define BN_DEFAULT_BITS 1280\n\n# define BN_FLG_MALLOCED         0x01\n# define BN_FLG_STATIC_DATA      0x02\n\n/*\n * avoid leaking exponent information through timing,\n * BN_mod_exp_mont() will call BN_mod_exp_mont_consttime,\n * BN_div() will call BN_div_no_branch,\n * BN_mod_inverse() will call BN_mod_inverse_no_branch.\n */\n# define BN_FLG_CONSTTIME        0x04\n\n# ifdef OPENSSL_NO_DEPRECATED\n/* deprecated name for the flag */\n#  define BN_FLG_EXP_CONSTTIME BN_FLG_CONSTTIME\n/*\n * avoid leaking exponent information through timings\n * (BN_mod_exp_mont() will call BN_mod_exp_mont_consttime)\n */\n# endif\n\n# ifndef OPENSSL_NO_DEPRECATED\n#  define BN_FLG_FREE             0x8000\n                                       /* used for debuging */\n# endif\n# define BN_set_flags(b,n)       ((b)->flags|=(n))\n# define BN_get_flags(b,n)       ((b)->flags&(n))\n\n/*\n * get a clone of a BIGNUM with changed flags, for *temporary* use only (the\n * two BIGNUMs cannot not be used in parallel!)\n */\n# define BN_with_flags(dest,b,n)  ((dest)->d=(b)->d, \\\n                                  (dest)->top=(b)->top, \\\n                                  (dest)->dmax=(b)->dmax, \\\n                                  (dest)->neg=(b)->neg, \\\n                                  (dest)->flags=(((dest)->flags & BN_FLG_MALLOCED) \\\n                                                 |  ((b)->flags & ~BN_FLG_MALLOCED) \\\n                                                 |  BN_FLG_STATIC_DATA \\\n                                                 |  (n)))\n\n/* Already declared in ossl_typ.h */\n# if 0\ntypedef struct bignum_st BIGNUM;\n/* Used for temp variables (declaration hidden in bn_lcl.h) */\ntypedef struct bignum_ctx BN_CTX;\ntypedef struct bn_blinding_st BN_BLINDING;\ntypedef struct bn_mont_ctx_st BN_MONT_CTX;\ntypedef struct bn_recp_ctx_st BN_RECP_CTX;\ntypedef struct bn_gencb_st BN_GENCB;\n# endif\n\nstruct bignum_st {\n    BN_ULONG *d;                /* Pointer to an array of 'BN_BITS2' bit\n                                 * chunks. */\n    int top;                    /* Index of last used d +1. */\n    /* The next are internal book keeping for bn_expand. */\n    int dmax;                   /* Size of the d array. */\n    int neg;                    /* one if the number is negative */\n    int flags;\n};\n\n/* Used for montgomery multiplication */\nstruct bn_mont_ctx_st {\n    int ri;                     /* number of bits in R */\n    BIGNUM RR;                  /* used to convert to montgomery form */\n    BIGNUM N;                   /* The modulus */\n    BIGNUM Ni;                  /* R*(1/R mod N) - N*Ni = 1 (Ni is only\n                                 * stored for bignum algorithm) */\n    BN_ULONG n0[2];             /* least significant word(s) of Ni; (type\n                                 * changed with 0.9.9, was \"BN_ULONG n0;\"\n                                 * before) */\n    int flags;\n};\n\n/*\n * Used for reciprocal division/mod functions It cannot be shared between\n * threads\n */\nstruct bn_recp_ctx_st {\n    BIGNUM N;                   /* the divisor */\n    BIGNUM Nr;                  /* the reciprocal */\n    int num_bits;\n    int shift;\n    int flags;\n};\n\n/* Used for slow \"generation\" functions. */\nstruct bn_gencb_st {\n    unsigned int ver;           /* To handle binary (in)compatibility */\n    void *arg;                  /* callback-specific data */\n    union {\n        /* if(ver==1) - handles old style callbacks */\n        void (*cb_1) (int, int, void *);\n        /* if(ver==2) - new callback style */\n        int (*cb_2) (int, int, BN_GENCB *);\n    } cb;\n};\n/* Wrapper function to make using BN_GENCB easier,  */\nint BN_GENCB_call(BN_GENCB *cb, int a, int b);\n/* Macro to populate a BN_GENCB structure with an \"old\"-style callback */\n# define BN_GENCB_set_old(gencb, callback, cb_arg) { \\\n                BN_GENCB *tmp_gencb = (gencb); \\\n                tmp_gencb->ver = 1; \\\n                tmp_gencb->arg = (cb_arg); \\\n                tmp_gencb->cb.cb_1 = (callback); }\n/* Macro to populate a BN_GENCB structure with a \"new\"-style callback */\n# define BN_GENCB_set(gencb, callback, cb_arg) { \\\n                BN_GENCB *tmp_gencb = (gencb); \\\n                tmp_gencb->ver = 2; \\\n                tmp_gencb->arg = (cb_arg); \\\n                tmp_gencb->cb.cb_2 = (callback); }\n\n# define BN_prime_checks 0      /* default: select number of iterations based\n                                 * on the size of the number */\n\n/*\n * number of Miller-Rabin iterations for an error rate of less than 2^-80 for\n * random 'b'-bit input, b >= 100 (taken from table 4.4 in the Handbook of\n * Applied Cryptography [Menezes, van Oorschot, Vanstone; CRC Press 1996];\n * original paper: Damgaard, Landrock, Pomerance: Average case error\n * estimates for the strong probable prime test. -- Math. Comp. 61 (1993)\n * 177-194)\n */\n# define BN_prime_checks_for_size(b) ((b) >= 1300 ?  2 : \\\n                                (b) >=  850 ?  3 : \\\n                                (b) >=  650 ?  4 : \\\n                                (b) >=  550 ?  5 : \\\n                                (b) >=  450 ?  6 : \\\n                                (b) >=  400 ?  7 : \\\n                                (b) >=  350 ?  8 : \\\n                                (b) >=  300 ?  9 : \\\n                                (b) >=  250 ? 12 : \\\n                                (b) >=  200 ? 15 : \\\n                                (b) >=  150 ? 18 : \\\n                                /* b >= 100 */ 27)\n\n# define BN_num_bytes(a) ((BN_num_bits(a)+7)/8)\n\n/* Note that BN_abs_is_word didn't work reliably for w == 0 until 0.9.8 */\n# define BN_abs_is_word(a,w) ((((a)->top == 1) && ((a)->d[0] == (BN_ULONG)(w))) || \\\n                                (((w) == 0) && ((a)->top == 0)))\n# define BN_is_zero(a)       ((a)->top == 0)\n# define BN_is_one(a)        (BN_abs_is_word((a),1) && !(a)->neg)\n# define BN_is_word(a,w)     (BN_abs_is_word((a),(w)) && (!(w) || !(a)->neg))\n# define BN_is_odd(a)        (((a)->top > 0) && ((a)->d[0] & 1))\n\n# define BN_one(a)       (BN_set_word((a),1))\n# define BN_zero_ex(a) \\\n        do { \\\n                BIGNUM *_tmp_bn = (a); \\\n                _tmp_bn->top = 0; \\\n                _tmp_bn->neg = 0; \\\n        } while(0)\n# ifdef OPENSSL_NO_DEPRECATED\n#  define BN_zero(a)      BN_zero_ex(a)\n# else\n#  define BN_zero(a)      (BN_set_word((a),0))\n# endif\n\nconst BIGNUM *BN_value_one(void);\nchar *BN_options(void);\nBN_CTX *BN_CTX_new(void);\n# ifndef OPENSSL_NO_DEPRECATED\nvoid BN_CTX_init(BN_CTX *c);\n# endif\nvoid BN_CTX_free(BN_CTX *c);\nvoid BN_CTX_start(BN_CTX *ctx);\nBIGNUM *BN_CTX_get(BN_CTX *ctx);\nvoid BN_CTX_end(BN_CTX *ctx);\nint BN_rand(BIGNUM *rnd, int bits, int top, int bottom);\nint BN_pseudo_rand(BIGNUM *rnd, int bits, int top, int bottom);\nint BN_rand_range(BIGNUM *rnd, const BIGNUM *range);\nint BN_pseudo_rand_range(BIGNUM *rnd, const BIGNUM *range);\nint BN_num_bits(const BIGNUM *a);\nint BN_num_bits_word(BN_ULONG);\nBIGNUM *BN_new(void);\nvoid BN_init(BIGNUM *);\nvoid BN_clear_free(BIGNUM *a);\nBIGNUM *BN_copy(BIGNUM *a, const BIGNUM *b);\nvoid BN_swap(BIGNUM *a, BIGNUM *b);\nBIGNUM *BN_bin2bn(const unsigned char *s, int len, BIGNUM *ret);\nint BN_bn2bin(const BIGNUM *a, unsigned char *to);\nBIGNUM *BN_mpi2bn(const unsigned char *s, int len, BIGNUM *ret);\nint BN_bn2mpi(const BIGNUM *a, unsigned char *to);\nint BN_sub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b);\nint BN_usub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b);\nint BN_uadd(BIGNUM *r, const BIGNUM *a, const BIGNUM *b);\nint BN_add(BIGNUM *r, const BIGNUM *a, const BIGNUM *b);\nint BN_mul(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx);\nint BN_sqr(BIGNUM *r, const BIGNUM *a, BN_CTX *ctx);\n/** BN_set_negative sets sign of a BIGNUM\n * \\param  b  pointer to the BIGNUM object\n * \\param  n  0 if the BIGNUM b should be positive and a value != 0 otherwise\n */\nvoid BN_set_negative(BIGNUM *b, int n);\n/** BN_is_negative returns 1 if the BIGNUM is negative\n * \\param  a  pointer to the BIGNUM object\n * \\return 1 if a < 0 and 0 otherwise\n */\n# define BN_is_negative(a) ((a)->neg != 0)\n\nint BN_div(BIGNUM *dv, BIGNUM *rem, const BIGNUM *m, const BIGNUM *d,\n           BN_CTX *ctx);\n# define BN_mod(rem,m,d,ctx) BN_div(NULL,(rem),(m),(d),(ctx))\nint BN_nnmod(BIGNUM *r, const BIGNUM *m, const BIGNUM *d, BN_CTX *ctx);\nint BN_mod_add(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *m,\n               BN_CTX *ctx);\nint BN_mod_add_quick(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,\n                     const BIGNUM *m);\nint BN_mod_sub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *m,\n               BN_CTX *ctx);\nint BN_mod_sub_quick(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,\n                     const BIGNUM *m);\nint BN_mod_mul(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *m,\n               BN_CTX *ctx);\nint BN_mod_sqr(BIGNUM *r, const BIGNUM *a, const BIGNUM *m, BN_CTX *ctx);\nint BN_mod_lshift1(BIGNUM *r, const BIGNUM *a, const BIGNUM *m, BN_CTX *ctx);\nint BN_mod_lshift1_quick(BIGNUM *r, const BIGNUM *a, const BIGNUM *m);\nint BN_mod_lshift(BIGNUM *r, const BIGNUM *a, int n, const BIGNUM *m,\n                  BN_CTX *ctx);\nint BN_mod_lshift_quick(BIGNUM *r, const BIGNUM *a, int n, const BIGNUM *m);\n\nBN_ULONG BN_mod_word(const BIGNUM *a, BN_ULONG w);\nBN_ULONG BN_div_word(BIGNUM *a, BN_ULONG w);\nint BN_mul_word(BIGNUM *a, BN_ULONG w);\nint BN_add_word(BIGNUM *a, BN_ULONG w);\nint BN_sub_word(BIGNUM *a, BN_ULONG w);\nint BN_set_word(BIGNUM *a, BN_ULONG w);\nBN_ULONG BN_get_word(const BIGNUM *a);\n\nint BN_cmp(const BIGNUM *a, const BIGNUM *b);\nvoid BN_free(BIGNUM *a);\nint BN_is_bit_set(const BIGNUM *a, int n);\nint BN_lshift(BIGNUM *r, const BIGNUM *a, int n);\nint BN_lshift1(BIGNUM *r, const BIGNUM *a);\nint BN_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx);\n\nint BN_mod_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,\n               const BIGNUM *m, BN_CTX *ctx);\nint BN_mod_exp_mont(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,\n                    const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx);\nint BN_mod_exp_mont_consttime(BIGNUM *rr, const BIGNUM *a, const BIGNUM *p,\n                              const BIGNUM *m, BN_CTX *ctx,\n                              BN_MONT_CTX *in_mont);\nint BN_mod_exp_mont_word(BIGNUM *r, BN_ULONG a, const BIGNUM *p,\n                         const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx);\nint BN_mod_exp2_mont(BIGNUM *r, const BIGNUM *a1, const BIGNUM *p1,\n                     const BIGNUM *a2, const BIGNUM *p2, const BIGNUM *m,\n                     BN_CTX *ctx, BN_MONT_CTX *m_ctx);\nint BN_mod_exp_simple(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,\n                      const BIGNUM *m, BN_CTX *ctx);\n\nint BN_mask_bits(BIGNUM *a, int n);\n# ifndef OPENSSL_NO_FP_API\nint BN_print_fp(FILE *fp, const BIGNUM *a);\n# endif\n# ifdef HEADER_BIO_H\nint BN_print(BIO *fp, const BIGNUM *a);\n# else\nint BN_print(void *fp, const BIGNUM *a);\n# endif\nint BN_reciprocal(BIGNUM *r, const BIGNUM *m, int len, BN_CTX *ctx);\nint BN_rshift(BIGNUM *r, const BIGNUM *a, int n);\nint BN_rshift1(BIGNUM *r, const BIGNUM *a);\nvoid BN_clear(BIGNUM *a);\nBIGNUM *BN_dup(const BIGNUM *a);\nint BN_ucmp(const BIGNUM *a, const BIGNUM *b);\nint BN_set_bit(BIGNUM *a, int n);\nint BN_clear_bit(BIGNUM *a, int n);\nchar *BN_bn2hex(const BIGNUM *a);\nchar *BN_bn2dec(const BIGNUM *a);\nint BN_hex2bn(BIGNUM **a, const char *str);\nint BN_dec2bn(BIGNUM **a, const char *str);\nint BN_asc2bn(BIGNUM **a, const char *str);\nint BN_gcd(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx);\nint BN_kronecker(const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx); /* returns\n                                                                  * -2 for\n                                                                  * error */\nBIGNUM *BN_mod_inverse(BIGNUM *ret,\n                       const BIGNUM *a, const BIGNUM *n, BN_CTX *ctx);\nBIGNUM *BN_mod_sqrt(BIGNUM *ret,\n                    const BIGNUM *a, const BIGNUM *n, BN_CTX *ctx);\n\nvoid BN_consttime_swap(BN_ULONG swap, BIGNUM *a, BIGNUM *b, int nwords);\n\n/* Deprecated versions */\n# ifndef OPENSSL_NO_DEPRECATED\nBIGNUM *BN_generate_prime(BIGNUM *ret, int bits, int safe,\n                          const BIGNUM *add, const BIGNUM *rem,\n                          void (*callback) (int, int, void *), void *cb_arg);\nint BN_is_prime(const BIGNUM *p, int nchecks,\n                void (*callback) (int, int, void *),\n                BN_CTX *ctx, void *cb_arg);\nint BN_is_prime_fasttest(const BIGNUM *p, int nchecks,\n                         void (*callback) (int, int, void *), BN_CTX *ctx,\n                         void *cb_arg, int do_trial_division);\n# endif                         /* !defined(OPENSSL_NO_DEPRECATED) */\n\n/* Newer versions */\nint BN_generate_prime_ex(BIGNUM *ret, int bits, int safe, const BIGNUM *add,\n                         const BIGNUM *rem, BN_GENCB *cb);\nint BN_is_prime_ex(const BIGNUM *p, int nchecks, BN_CTX *ctx, BN_GENCB *cb);\nint BN_is_prime_fasttest_ex(const BIGNUM *p, int nchecks, BN_CTX *ctx,\n                            int do_trial_division, BN_GENCB *cb);\n\nint BN_X931_generate_Xpq(BIGNUM *Xp, BIGNUM *Xq, int nbits, BN_CTX *ctx);\n\nint BN_X931_derive_prime_ex(BIGNUM *p, BIGNUM *p1, BIGNUM *p2,\n                            const BIGNUM *Xp, const BIGNUM *Xp1,\n                            const BIGNUM *Xp2, const BIGNUM *e, BN_CTX *ctx,\n                            BN_GENCB *cb);\nint BN_X931_generate_prime_ex(BIGNUM *p, BIGNUM *p1, BIGNUM *p2, BIGNUM *Xp1,\n                              BIGNUM *Xp2, const BIGNUM *Xp, const BIGNUM *e,\n                              BN_CTX *ctx, BN_GENCB *cb);\n\nBN_MONT_CTX *BN_MONT_CTX_new(void);\nvoid BN_MONT_CTX_init(BN_MONT_CTX *ctx);\nint BN_mod_mul_montgomery(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,\n                          BN_MONT_CTX *mont, BN_CTX *ctx);\n# define BN_to_montgomery(r,a,mont,ctx)  BN_mod_mul_montgomery(\\\n        (r),(a),&((mont)->RR),(mont),(ctx))\nint BN_from_montgomery(BIGNUM *r, const BIGNUM *a,\n                       BN_MONT_CTX *mont, BN_CTX *ctx);\nvoid BN_MONT_CTX_free(BN_MONT_CTX *mont);\nint BN_MONT_CTX_set(BN_MONT_CTX *mont, const BIGNUM *mod, BN_CTX *ctx);\nBN_MONT_CTX *BN_MONT_CTX_copy(BN_MONT_CTX *to, BN_MONT_CTX *from);\nBN_MONT_CTX *BN_MONT_CTX_set_locked(BN_MONT_CTX **pmont, int lock,\n                                    const BIGNUM *mod, BN_CTX *ctx);\n\n/* BN_BLINDING flags */\n# define BN_BLINDING_NO_UPDATE   0x00000001\n# define BN_BLINDING_NO_RECREATE 0x00000002\n\nBN_BLINDING *BN_BLINDING_new(const BIGNUM *A, const BIGNUM *Ai, BIGNUM *mod);\nvoid BN_BLINDING_free(BN_BLINDING *b);\nint BN_BLINDING_update(BN_BLINDING *b, BN_CTX *ctx);\nint BN_BLINDING_convert(BIGNUM *n, BN_BLINDING *b, BN_CTX *ctx);\nint BN_BLINDING_invert(BIGNUM *n, BN_BLINDING *b, BN_CTX *ctx);\nint BN_BLINDING_convert_ex(BIGNUM *n, BIGNUM *r, BN_BLINDING *b, BN_CTX *);\nint BN_BLINDING_invert_ex(BIGNUM *n, const BIGNUM *r, BN_BLINDING *b,\n                          BN_CTX *);\n# ifndef OPENSSL_NO_DEPRECATED\nunsigned long BN_BLINDING_get_thread_id(const BN_BLINDING *);\nvoid BN_BLINDING_set_thread_id(BN_BLINDING *, unsigned long);\n# endif\nCRYPTO_THREADID *BN_BLINDING_thread_id(BN_BLINDING *);\nunsigned long BN_BLINDING_get_flags(const BN_BLINDING *);\nvoid BN_BLINDING_set_flags(BN_BLINDING *, unsigned long);\nBN_BLINDING *BN_BLINDING_create_param(BN_BLINDING *b,\n                                      const BIGNUM *e, BIGNUM *m, BN_CTX *ctx,\n                                      int (*bn_mod_exp) (BIGNUM *r,\n                                                         const BIGNUM *a,\n                                                         const BIGNUM *p,\n                                                         const BIGNUM *m,\n                                                         BN_CTX *ctx,\n                                                         BN_MONT_CTX *m_ctx),\n                                      BN_MONT_CTX *m_ctx);\n\n# ifndef OPENSSL_NO_DEPRECATED\nvoid BN_set_params(int mul, int high, int low, int mont);\nint BN_get_params(int which);   /* 0, mul, 1 high, 2 low, 3 mont */\n# endif\n\nvoid BN_RECP_CTX_init(BN_RECP_CTX *recp);\nBN_RECP_CTX *BN_RECP_CTX_new(void);\nvoid BN_RECP_CTX_free(BN_RECP_CTX *recp);\nint BN_RECP_CTX_set(BN_RECP_CTX *recp, const BIGNUM *rdiv, BN_CTX *ctx);\nint BN_mod_mul_reciprocal(BIGNUM *r, const BIGNUM *x, const BIGNUM *y,\n                          BN_RECP_CTX *recp, BN_CTX *ctx);\nint BN_mod_exp_recp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,\n                    const BIGNUM *m, BN_CTX *ctx);\nint BN_div_recp(BIGNUM *dv, BIGNUM *rem, const BIGNUM *m,\n                BN_RECP_CTX *recp, BN_CTX *ctx);\n\n# ifndef OPENSSL_NO_EC2M\n\n/*\n * Functions for arithmetic over binary polynomials represented by BIGNUMs.\n * The BIGNUM::neg property of BIGNUMs representing binary polynomials is\n * ignored. Note that input arguments are not const so that their bit arrays\n * can be expanded to the appropriate size if needed.\n */\n\n/*\n * r = a + b\n */\nint BN_GF2m_add(BIGNUM *r, const BIGNUM *a, const BIGNUM *b);\n#  define BN_GF2m_sub(r, a, b) BN_GF2m_add(r, a, b)\n/*\n * r=a mod p\n */\nint BN_GF2m_mod(BIGNUM *r, const BIGNUM *a, const BIGNUM *p);\n/* r = (a * b) mod p */\nint BN_GF2m_mod_mul(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,\n                    const BIGNUM *p, BN_CTX *ctx);\n/* r = (a * a) mod p */\nint BN_GF2m_mod_sqr(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx);\n/* r = (1 / b) mod p */\nint BN_GF2m_mod_inv(BIGNUM *r, const BIGNUM *b, const BIGNUM *p, BN_CTX *ctx);\n/* r = (a / b) mod p */\nint BN_GF2m_mod_div(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,\n                    const BIGNUM *p, BN_CTX *ctx);\n/* r = (a ^ b) mod p */\nint BN_GF2m_mod_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,\n                    const BIGNUM *p, BN_CTX *ctx);\n/* r = sqrt(a) mod p */\nint BN_GF2m_mod_sqrt(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,\n                     BN_CTX *ctx);\n/* r^2 + r = a mod p */\nint BN_GF2m_mod_solve_quad(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,\n                           BN_CTX *ctx);\n#  define BN_GF2m_cmp(a, b) BN_ucmp((a), (b))\n/*-\n * Some functions allow for representation of the irreducible polynomials\n * as an unsigned int[], say p.  The irreducible f(t) is then of the form:\n *     t^p[0] + t^p[1] + ... + t^p[k]\n * where m = p[0] > p[1] > ... > p[k] = 0.\n */\n/* r = a mod p */\nint BN_GF2m_mod_arr(BIGNUM *r, const BIGNUM *a, const int p[]);\n/* r = (a * b) mod p */\nint BN_GF2m_mod_mul_arr(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,\n                        const int p[], BN_CTX *ctx);\n/* r = (a * a) mod p */\nint BN_GF2m_mod_sqr_arr(BIGNUM *r, const BIGNUM *a, const int p[],\n                        BN_CTX *ctx);\n/* r = (1 / b) mod p */\nint BN_GF2m_mod_inv_arr(BIGNUM *r, const BIGNUM *b, const int p[],\n                        BN_CTX *ctx);\n/* r = (a / b) mod p */\nint BN_GF2m_mod_div_arr(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,\n                        const int p[], BN_CTX *ctx);\n/* r = (a ^ b) mod p */\nint BN_GF2m_mod_exp_arr(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,\n                        const int p[], BN_CTX *ctx);\n/* r = sqrt(a) mod p */\nint BN_GF2m_mod_sqrt_arr(BIGNUM *r, const BIGNUM *a,\n                         const int p[], BN_CTX *ctx);\n/* r^2 + r = a mod p */\nint BN_GF2m_mod_solve_quad_arr(BIGNUM *r, const BIGNUM *a,\n                               const int p[], BN_CTX *ctx);\nint BN_GF2m_poly2arr(const BIGNUM *a, int p[], int max);\nint BN_GF2m_arr2poly(const int p[], BIGNUM *a);\n\n# endif\n\n/*\n * faster mod functions for the 'NIST primes' 0 <= a < p^2\n */\nint BN_nist_mod_192(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx);\nint BN_nist_mod_224(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx);\nint BN_nist_mod_256(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx);\nint BN_nist_mod_384(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx);\nint BN_nist_mod_521(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx);\n\nconst BIGNUM *BN_get0_nist_prime_192(void);\nconst BIGNUM *BN_get0_nist_prime_224(void);\nconst BIGNUM *BN_get0_nist_prime_256(void);\nconst BIGNUM *BN_get0_nist_prime_384(void);\nconst BIGNUM *BN_get0_nist_prime_521(void);\n\n/* library internal functions */\n\n# define bn_expand(a,bits) \\\n    ( \\\n        bits > (INT_MAX - BN_BITS2 + 1) ? \\\n            NULL \\\n        : \\\n            (((bits+BN_BITS2-1)/BN_BITS2) <= (a)->dmax) ? \\\n                (a) \\\n            : \\\n                bn_expand2((a),(bits+BN_BITS2-1)/BN_BITS2) \\\n    )\n\n# define bn_wexpand(a,words) (((words) <= (a)->dmax)?(a):bn_expand2((a),(words)))\nBIGNUM *bn_expand2(BIGNUM *a, int words);\n# ifndef OPENSSL_NO_DEPRECATED\nBIGNUM *bn_dup_expand(const BIGNUM *a, int words); /* unused */\n# endif\n\n/*-\n * Bignum consistency macros\n * There is one \"API\" macro, bn_fix_top(), for stripping leading zeroes from\n * bignum data after direct manipulations on the data. There is also an\n * \"internal\" macro, bn_check_top(), for verifying that there are no leading\n * zeroes. Unfortunately, some auditing is required due to the fact that\n * bn_fix_top() has become an overabused duct-tape because bignum data is\n * occasionally passed around in an inconsistent state. So the following\n * changes have been made to sort this out;\n * - bn_fix_top()s implementation has been moved to bn_correct_top()\n * - if BN_DEBUG isn't defined, bn_fix_top() maps to bn_correct_top(), and\n *   bn_check_top() is as before.\n * - if BN_DEBUG *is* defined;\n *   - bn_check_top() tries to pollute unused words even if the bignum 'top' is\n *     consistent. (ed: only if BN_DEBUG_RAND is defined)\n *   - bn_fix_top() maps to bn_check_top() rather than \"fixing\" anything.\n * The idea is to have debug builds flag up inconsistent bignums when they\n * occur. If that occurs in a bn_fix_top(), we examine the code in question; if\n * the use of bn_fix_top() was appropriate (ie. it follows directly after code\n * that manipulates the bignum) it is converted to bn_correct_top(), and if it\n * was not appropriate, we convert it permanently to bn_check_top() and track\n * down the cause of the bug. Eventually, no internal code should be using the\n * bn_fix_top() macro. External applications and libraries should try this with\n * their own code too, both in terms of building against the openssl headers\n * with BN_DEBUG defined *and* linking with a version of OpenSSL built with it\n * defined. This not only improves external code, it provides more test\n * coverage for openssl's own code.\n */\n\n# ifdef BN_DEBUG\n\n/* We only need assert() when debugging */\n#  include <assert.h>\n\n#  ifdef BN_DEBUG_RAND\n/* To avoid \"make update\" cvs wars due to BN_DEBUG, use some tricks */\n#   ifndef RAND_pseudo_bytes\nint RAND_pseudo_bytes(unsigned char *buf, int num);\n#    define BN_DEBUG_TRIX\n#   endif\n#   define bn_pollute(a) \\\n        do { \\\n                const BIGNUM *_bnum1 = (a); \\\n                if(_bnum1->top < _bnum1->dmax) { \\\n                        unsigned char _tmp_char; \\\n                        /* We cast away const without the compiler knowing, any \\\n                         * *genuinely* constant variables that aren't mutable \\\n                         * wouldn't be constructed with top!=dmax. */ \\\n                        BN_ULONG *_not_const; \\\n                        memcpy(&_not_const, &_bnum1->d, sizeof(BN_ULONG*)); \\\n                        /* Debug only - safe to ignore error return */ \\\n                        RAND_pseudo_bytes(&_tmp_char, 1); \\\n                        memset((unsigned char *)(_not_const + _bnum1->top), _tmp_char, \\\n                                (_bnum1->dmax - _bnum1->top) * sizeof(BN_ULONG)); \\\n                } \\\n        } while(0)\n#   ifdef BN_DEBUG_TRIX\n#    undef RAND_pseudo_bytes\n#   endif\n#  else\n#   define bn_pollute(a)\n#  endif\n#  define bn_check_top(a) \\\n        do { \\\n                const BIGNUM *_bnum2 = (a); \\\n                if (_bnum2 != NULL) { \\\n                        assert((_bnum2->top == 0) || \\\n                                (_bnum2->d[_bnum2->top - 1] != 0)); \\\n                        bn_pollute(_bnum2); \\\n                } \\\n        } while(0)\n\n#  define bn_fix_top(a)           bn_check_top(a)\n\n#  define bn_check_size(bn, bits) bn_wcheck_size(bn, ((bits+BN_BITS2-1))/BN_BITS2)\n#  define bn_wcheck_size(bn, words) \\\n        do { \\\n                const BIGNUM *_bnum2 = (bn); \\\n                assert((words) <= (_bnum2)->dmax && (words) >= (_bnum2)->top); \\\n                /* avoid unused variable warning with NDEBUG */ \\\n                (void)(_bnum2); \\\n        } while(0)\n\n# else                          /* !BN_DEBUG */\n\n#  define bn_pollute(a)\n#  define bn_check_top(a)\n#  define bn_fix_top(a)           bn_correct_top(a)\n#  define bn_check_size(bn, bits)\n#  define bn_wcheck_size(bn, words)\n\n# endif\n\n# define bn_correct_top(a) \\\n        { \\\n        BN_ULONG *ftl; \\\n        int tmp_top = (a)->top; \\\n        if (tmp_top > 0) \\\n                { \\\n                for (ftl= &((a)->d[tmp_top-1]); tmp_top > 0; tmp_top--) \\\n                        if (*(ftl--)) break; \\\n                (a)->top = tmp_top; \\\n                } \\\n        if ((a)->top == 0) \\\n            (a)->neg = 0; \\\n        bn_pollute(a); \\\n        }\n\nBN_ULONG bn_mul_add_words(BN_ULONG *rp, const BN_ULONG *ap, int num,\n                          BN_ULONG w);\nBN_ULONG bn_mul_words(BN_ULONG *rp, const BN_ULONG *ap, int num, BN_ULONG w);\nvoid bn_sqr_words(BN_ULONG *rp, const BN_ULONG *ap, int num);\nBN_ULONG bn_div_words(BN_ULONG h, BN_ULONG l, BN_ULONG d);\nBN_ULONG bn_add_words(BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp,\n                      int num);\nBN_ULONG bn_sub_words(BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp,\n                      int num);\n\n/* Primes from RFC 2409 */\nBIGNUM *get_rfc2409_prime_768(BIGNUM *bn);\nBIGNUM *get_rfc2409_prime_1024(BIGNUM *bn);\n\n/* Primes from RFC 3526 */\nBIGNUM *get_rfc3526_prime_1536(BIGNUM *bn);\nBIGNUM *get_rfc3526_prime_2048(BIGNUM *bn);\nBIGNUM *get_rfc3526_prime_3072(BIGNUM *bn);\nBIGNUM *get_rfc3526_prime_4096(BIGNUM *bn);\nBIGNUM *get_rfc3526_prime_6144(BIGNUM *bn);\nBIGNUM *get_rfc3526_prime_8192(BIGNUM *bn);\n\nint BN_bntest_rand(BIGNUM *rnd, int bits, int top, int bottom);\n\n/* BEGIN ERROR CODES */\n/*\n * The following lines are auto generated by the script mkerr.pl. Any changes\n * made after this point may be overwritten when the script is next run.\n */\nvoid ERR_load_BN_strings(void);\n\n/* Error codes for the BN functions. */\n\n/* Function codes. */\n# define BN_F_BNRAND                                      127\n# define BN_F_BN_BLINDING_CONVERT_EX                      100\n# define BN_F_BN_BLINDING_CREATE_PARAM                    128\n# define BN_F_BN_BLINDING_INVERT_EX                       101\n# define BN_F_BN_BLINDING_NEW                             102\n# define BN_F_BN_BLINDING_UPDATE                          103\n# define BN_F_BN_BN2DEC                                   104\n# define BN_F_BN_BN2HEX                                   105\n# define BN_F_BN_CTX_GET                                  116\n# define BN_F_BN_CTX_NEW                                  106\n# define BN_F_BN_CTX_START                                129\n# define BN_F_BN_DIV                                      107\n# define BN_F_BN_DIV_NO_BRANCH                            138\n# define BN_F_BN_DIV_RECP                                 130\n# define BN_F_BN_EXP                                      123\n# define BN_F_BN_EXPAND2                                  108\n# define BN_F_BN_EXPAND_INTERNAL                          120\n# define BN_F_BN_GF2M_MOD                                 131\n# define BN_F_BN_GF2M_MOD_EXP                             132\n# define BN_F_BN_GF2M_MOD_MUL                             133\n# define BN_F_BN_GF2M_MOD_SOLVE_QUAD                      134\n# define BN_F_BN_GF2M_MOD_SOLVE_QUAD_ARR                  135\n# define BN_F_BN_GF2M_MOD_SQR                             136\n# define BN_F_BN_GF2M_MOD_SQRT                            137\n# define BN_F_BN_LSHIFT                                   145\n# define BN_F_BN_MOD_EXP2_MONT                            118\n# define BN_F_BN_MOD_EXP_MONT                             109\n# define BN_F_BN_MOD_EXP_MONT_CONSTTIME                   124\n# define BN_F_BN_MOD_EXP_MONT_WORD                        117\n# define BN_F_BN_MOD_EXP_RECP                             125\n# define BN_F_BN_MOD_EXP_SIMPLE                           126\n# define BN_F_BN_MOD_INVERSE                              110\n# define BN_F_BN_MOD_INVERSE_NO_BRANCH                    139\n# define BN_F_BN_MOD_LSHIFT_QUICK                         119\n# define BN_F_BN_MOD_MUL_RECIPROCAL                       111\n# define BN_F_BN_MOD_SQRT                                 121\n# define BN_F_BN_MPI2BN                                   112\n# define BN_F_BN_NEW                                      113\n# define BN_F_BN_RAND                                     114\n# define BN_F_BN_RAND_RANGE                               122\n# define BN_F_BN_RSHIFT                                   146\n# define BN_F_BN_USUB                                     115\n\n/* Reason codes. */\n# define BN_R_ARG2_LT_ARG3                                100\n# define BN_R_BAD_RECIPROCAL                              101\n# define BN_R_BIGNUM_TOO_LONG                             114\n# define BN_R_BITS_TOO_SMALL                              118\n# define BN_R_CALLED_WITH_EVEN_MODULUS                    102\n# define BN_R_DIV_BY_ZERO                                 103\n# define BN_R_ENCODING_ERROR                              104\n# define BN_R_EXPAND_ON_STATIC_BIGNUM_DATA                105\n# define BN_R_INPUT_NOT_REDUCED                           110\n# define BN_R_INVALID_LENGTH                              106\n# define BN_R_INVALID_RANGE                               115\n# define BN_R_INVALID_SHIFT                               119\n# define BN_R_NOT_A_SQUARE                                111\n# define BN_R_NOT_INITIALIZED                             107\n# define BN_R_NO_INVERSE                                  108\n# define BN_R_NO_SOLUTION                                 116\n# define BN_R_P_IS_NOT_PRIME                              112\n# define BN_R_TOO_MANY_ITERATIONS                         113\n# define BN_R_TOO_MANY_TEMPORARY_VARIABLES                109\n\n#ifdef  __cplusplus\n}\n#endif\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/x86/include/openssl/buffer.h",
    "content": "/* crypto/buffer/buffer.h */\n/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)\n * All rights reserved.\n *\n * This package is an SSL implementation written\n * by Eric Young (eay@cryptsoft.com).\n * The implementation was written so as to conform with Netscapes SSL.\n *\n * This library is free for commercial and non-commercial use as long as\n * the following conditions are aheared to.  The following conditions\n * apply to all code found in this distribution, be it the RC4, RSA,\n * lhash, DES, etc., code; not just the SSL code.  The SSL documentation\n * included with this distribution is covered by the same copyright terms\n * except that the holder is Tim Hudson (tjh@cryptsoft.com).\n *\n * Copyright remains Eric Young's, and as such any Copyright notices in\n * the code are not to be removed.\n * If this package is used in a product, Eric Young should be given attribution\n * as the author of the parts of the library used.\n * This can be in the form of a textual message at program startup or\n * in documentation (online or textual) provided with the package.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the copyright\n *    notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in the\n *    documentation and/or other materials provided with the distribution.\n * 3. All advertising materials mentioning features or use of this software\n *    must display the following acknowledgement:\n *    \"This product includes cryptographic software written by\n *     Eric Young (eay@cryptsoft.com)\"\n *    The word 'cryptographic' can be left out if the rouines from the library\n *    being used are not cryptographic related :-).\n * 4. If you include any Windows specific code (or a derivative thereof) from\n *    the apps directory (application code) you must include an acknowledgement:\n *    \"This product includes software written by Tim Hudson (tjh@cryptsoft.com)\"\n *\n * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n * SUCH DAMAGE.\n *\n * The licence and distribution terms for any publically available version or\n * derivative of this code cannot be changed.  i.e. this code cannot simply be\n * copied and put under another distribution licence\n * [including the GNU Public Licence.]\n */\n\n#ifndef HEADER_BUFFER_H\n# define HEADER_BUFFER_H\n\n# include <openssl/ossl_typ.h>\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n# include <stddef.h>\n\n# if !defined(NO_SYS_TYPES_H)\n#  include <sys/types.h>\n# endif\n\n/* Already declared in ossl_typ.h */\n/* typedef struct buf_mem_st BUF_MEM; */\n\nstruct buf_mem_st {\n    size_t length;              /* current number of bytes */\n    char *data;\n    size_t max;                 /* size of buffer */\n};\n\nBUF_MEM *BUF_MEM_new(void);\nvoid BUF_MEM_free(BUF_MEM *a);\nint BUF_MEM_grow(BUF_MEM *str, size_t len);\nint BUF_MEM_grow_clean(BUF_MEM *str, size_t len);\nsize_t BUF_strnlen(const char *str, size_t maxlen);\nchar *BUF_strdup(const char *str);\n\n/*\n * Like strndup, but in addition, explicitly guarantees to never read past the\n * first |siz| bytes of |str|.\n */\nchar *BUF_strndup(const char *str, size_t siz);\n\nvoid *BUF_memdup(const void *data, size_t siz);\nvoid BUF_reverse(unsigned char *out, const unsigned char *in, size_t siz);\n\n/* safe string functions */\nsize_t BUF_strlcpy(char *dst, const char *src, size_t siz);\nsize_t BUF_strlcat(char *dst, const char *src, size_t siz);\n\n/* BEGIN ERROR CODES */\n/*\n * The following lines are auto generated by the script mkerr.pl. Any changes\n * made after this point may be overwritten when the script is next run.\n */\nvoid ERR_load_BUF_strings(void);\n\n/* Error codes for the BUF functions. */\n\n/* Function codes. */\n# define BUF_F_BUF_MEMDUP                                 103\n# define BUF_F_BUF_MEM_GROW                               100\n# define BUF_F_BUF_MEM_GROW_CLEAN                         105\n# define BUF_F_BUF_MEM_NEW                                101\n# define BUF_F_BUF_STRDUP                                 102\n# define BUF_F_BUF_STRNDUP                                104\n\n/* Reason codes. */\n\n#ifdef  __cplusplus\n}\n#endif\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/x86/include/openssl/camellia.h",
    "content": "/* crypto/camellia/camellia.h */\n/* ====================================================================\n * Copyright (c) 2006 The OpenSSL Project.  All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n *\n * 1. Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n *\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in\n *    the documentation and/or other materials provided with the\n *    distribution.\n *\n * 3. All advertising materials mentioning features or use of this\n *    software must display the following acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit. (http://www.openssl.org/)\"\n *\n * 4. The names \"OpenSSL Toolkit\" and \"OpenSSL Project\" must not be used to\n *    endorse or promote products derived from this software without\n *    prior written permission. For written permission, please contact\n *    openssl-core@openssl.org.\n *\n * 5. Products derived from this software may not be called \"OpenSSL\"\n *    nor may \"OpenSSL\" appear in their names without prior written\n *    permission of the OpenSSL Project.\n *\n * 6. Redistributions of any form whatsoever must retain the following\n *    acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit (http://www.openssl.org/)\"\n *\n * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY\n * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\n * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR\n * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\n * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,\n * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED\n * OF THE POSSIBILITY OF SUCH DAMAGE.\n * ====================================================================\n *\n */\n\n#ifndef HEADER_CAMELLIA_H\n# define HEADER_CAMELLIA_H\n\n# include <openssl/opensslconf.h>\n\n# ifdef OPENSSL_NO_CAMELLIA\n#  error CAMELLIA is disabled.\n# endif\n\n# include <stddef.h>\n\n# define CAMELLIA_ENCRYPT        1\n# define CAMELLIA_DECRYPT        0\n\n/*\n * Because array size can't be a const in C, the following two are macros.\n * Both sizes are in bytes.\n */\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n/* This should be a hidden type, but EVP requires that the size be known */\n\n# define CAMELLIA_BLOCK_SIZE 16\n# define CAMELLIA_TABLE_BYTE_LEN 272\n# define CAMELLIA_TABLE_WORD_LEN (CAMELLIA_TABLE_BYTE_LEN / 4)\n\ntypedef unsigned int KEY_TABLE_TYPE[CAMELLIA_TABLE_WORD_LEN]; /* to match\n                                                               * with WORD */\n\nstruct camellia_key_st {\n    union {\n        double d;               /* ensures 64-bit align */\n        KEY_TABLE_TYPE rd_key;\n    } u;\n    int grand_rounds;\n};\ntypedef struct camellia_key_st CAMELLIA_KEY;\n\n# ifdef OPENSSL_FIPS\nint private_Camellia_set_key(const unsigned char *userKey, const int bits,\n                             CAMELLIA_KEY *key);\n# endif\nint Camellia_set_key(const unsigned char *userKey, const int bits,\n                     CAMELLIA_KEY *key);\n\nvoid Camellia_encrypt(const unsigned char *in, unsigned char *out,\n                      const CAMELLIA_KEY *key);\nvoid Camellia_decrypt(const unsigned char *in, unsigned char *out,\n                      const CAMELLIA_KEY *key);\n\nvoid Camellia_ecb_encrypt(const unsigned char *in, unsigned char *out,\n                          const CAMELLIA_KEY *key, const int enc);\nvoid Camellia_cbc_encrypt(const unsigned char *in, unsigned char *out,\n                          size_t length, const CAMELLIA_KEY *key,\n                          unsigned char *ivec, const int enc);\nvoid Camellia_cfb128_encrypt(const unsigned char *in, unsigned char *out,\n                             size_t length, const CAMELLIA_KEY *key,\n                             unsigned char *ivec, int *num, const int enc);\nvoid Camellia_cfb1_encrypt(const unsigned char *in, unsigned char *out,\n                           size_t length, const CAMELLIA_KEY *key,\n                           unsigned char *ivec, int *num, const int enc);\nvoid Camellia_cfb8_encrypt(const unsigned char *in, unsigned char *out,\n                           size_t length, const CAMELLIA_KEY *key,\n                           unsigned char *ivec, int *num, const int enc);\nvoid Camellia_ofb128_encrypt(const unsigned char *in, unsigned char *out,\n                             size_t length, const CAMELLIA_KEY *key,\n                             unsigned char *ivec, int *num);\nvoid Camellia_ctr128_encrypt(const unsigned char *in, unsigned char *out,\n                             size_t length, const CAMELLIA_KEY *key,\n                             unsigned char ivec[CAMELLIA_BLOCK_SIZE],\n                             unsigned char ecount_buf[CAMELLIA_BLOCK_SIZE],\n                             unsigned int *num);\n\n#ifdef  __cplusplus\n}\n#endif\n\n#endif                          /* !HEADER_Camellia_H */\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/x86/include/openssl/cast.h",
    "content": "/* crypto/cast/cast.h */\n/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)\n * All rights reserved.\n *\n * This package is an SSL implementation written\n * by Eric Young (eay@cryptsoft.com).\n * The implementation was written so as to conform with Netscapes SSL.\n *\n * This library is free for commercial and non-commercial use as long as\n * the following conditions are aheared to.  The following conditions\n * apply to all code found in this distribution, be it the RC4, RSA,\n * lhash, DES, etc., code; not just the SSL code.  The SSL documentation\n * included with this distribution is covered by the same copyright terms\n * except that the holder is Tim Hudson (tjh@cryptsoft.com).\n *\n * Copyright remains Eric Young's, and as such any Copyright notices in\n * the code are not to be removed.\n * If this package is used in a product, Eric Young should be given attribution\n * as the author of the parts of the library used.\n * This can be in the form of a textual message at program startup or\n * in documentation (online or textual) provided with the package.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the copyright\n *    notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in the\n *    documentation and/or other materials provided with the distribution.\n * 3. All advertising materials mentioning features or use of this software\n *    must display the following acknowledgement:\n *    \"This product includes cryptographic software written by\n *     Eric Young (eay@cryptsoft.com)\"\n *    The word 'cryptographic' can be left out if the rouines from the library\n *    being used are not cryptographic related :-).\n * 4. If you include any Windows specific code (or a derivative thereof) from\n *    the apps directory (application code) you must include an acknowledgement:\n *    \"This product includes software written by Tim Hudson (tjh@cryptsoft.com)\"\n *\n * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n * SUCH DAMAGE.\n *\n * The licence and distribution terms for any publically available version or\n * derivative of this code cannot be changed.  i.e. this code cannot simply be\n * copied and put under another distribution licence\n * [including the GNU Public Licence.]\n */\n\n#ifndef HEADER_CAST_H\n# define HEADER_CAST_H\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n# include <openssl/opensslconf.h>\n\n# ifdef OPENSSL_NO_CAST\n#  error CAST is disabled.\n# endif\n\n# define CAST_ENCRYPT    1\n# define CAST_DECRYPT    0\n\n# define CAST_LONG unsigned int\n\n# define CAST_BLOCK      8\n# define CAST_KEY_LENGTH 16\n\ntypedef struct cast_key_st {\n    CAST_LONG data[32];\n    int short_key;              /* Use reduced rounds for short key */\n} CAST_KEY;\n\n# ifdef OPENSSL_FIPS\nvoid private_CAST_set_key(CAST_KEY *key, int len, const unsigned char *data);\n# endif\nvoid CAST_set_key(CAST_KEY *key, int len, const unsigned char *data);\nvoid CAST_ecb_encrypt(const unsigned char *in, unsigned char *out,\n                      const CAST_KEY *key, int enc);\nvoid CAST_encrypt(CAST_LONG *data, const CAST_KEY *key);\nvoid CAST_decrypt(CAST_LONG *data, const CAST_KEY *key);\nvoid CAST_cbc_encrypt(const unsigned char *in, unsigned char *out,\n                      long length, const CAST_KEY *ks, unsigned char *iv,\n                      int enc);\nvoid CAST_cfb64_encrypt(const unsigned char *in, unsigned char *out,\n                        long length, const CAST_KEY *schedule,\n                        unsigned char *ivec, int *num, int enc);\nvoid CAST_ofb64_encrypt(const unsigned char *in, unsigned char *out,\n                        long length, const CAST_KEY *schedule,\n                        unsigned char *ivec, int *num);\n\n#ifdef  __cplusplus\n}\n#endif\n\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/x86/include/openssl/cmac.h",
    "content": "/* crypto/cmac/cmac.h */\n/*\n * Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL\n * project.\n */\n/* ====================================================================\n * Copyright (c) 2010 The OpenSSL Project.  All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n *\n * 1. Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n *\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in\n *    the documentation and/or other materials provided with the\n *    distribution.\n *\n * 3. All advertising materials mentioning features or use of this\n *    software must display the following acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)\"\n *\n * 4. The names \"OpenSSL Toolkit\" and \"OpenSSL Project\" must not be used to\n *    endorse or promote products derived from this software without\n *    prior written permission. For written permission, please contact\n *    licensing@OpenSSL.org.\n *\n * 5. Products derived from this software may not be called \"OpenSSL\"\n *    nor may \"OpenSSL\" appear in their names without prior written\n *    permission of the OpenSSL Project.\n *\n * 6. Redistributions of any form whatsoever must retain the following\n *    acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)\"\n *\n * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY\n * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\n * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR\n * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\n * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,\n * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED\n * OF THE POSSIBILITY OF SUCH DAMAGE.\n * ====================================================================\n */\n\n#ifndef HEADER_CMAC_H\n# define HEADER_CMAC_H\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n# include <openssl/evp.h>\n\n/* Opaque */\ntypedef struct CMAC_CTX_st CMAC_CTX;\n\nCMAC_CTX *CMAC_CTX_new(void);\nvoid CMAC_CTX_cleanup(CMAC_CTX *ctx);\nvoid CMAC_CTX_free(CMAC_CTX *ctx);\nEVP_CIPHER_CTX *CMAC_CTX_get0_cipher_ctx(CMAC_CTX *ctx);\nint CMAC_CTX_copy(CMAC_CTX *out, const CMAC_CTX *in);\n\nint CMAC_Init(CMAC_CTX *ctx, const void *key, size_t keylen,\n              const EVP_CIPHER *cipher, ENGINE *impl);\nint CMAC_Update(CMAC_CTX *ctx, const void *data, size_t dlen);\nint CMAC_Final(CMAC_CTX *ctx, unsigned char *out, size_t *poutlen);\nint CMAC_resume(CMAC_CTX *ctx);\n\n#ifdef  __cplusplus\n}\n#endif\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/x86/include/openssl/cms.h",
    "content": "/* crypto/cms/cms.h */\n/*\n * Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL\n * project.\n */\n/* ====================================================================\n * Copyright (c) 2008 The OpenSSL Project.  All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n *\n * 1. Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n *\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in\n *    the documentation and/or other materials provided with the\n *    distribution.\n *\n * 3. All advertising materials mentioning features or use of this\n *    software must display the following acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)\"\n *\n * 4. The names \"OpenSSL Toolkit\" and \"OpenSSL Project\" must not be used to\n *    endorse or promote products derived from this software without\n *    prior written permission. For written permission, please contact\n *    licensing@OpenSSL.org.\n *\n * 5. Products derived from this software may not be called \"OpenSSL\"\n *    nor may \"OpenSSL\" appear in their names without prior written\n *    permission of the OpenSSL Project.\n *\n * 6. Redistributions of any form whatsoever must retain the following\n *    acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)\"\n *\n * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY\n * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\n * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR\n * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\n * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,\n * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED\n * OF THE POSSIBILITY OF SUCH DAMAGE.\n * ====================================================================\n */\n\n#ifndef HEADER_CMS_H\n# define HEADER_CMS_H\n\n# include <openssl/x509.h>\n\n# ifdef OPENSSL_NO_CMS\n#  error CMS is disabled.\n# endif\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\ntypedef struct CMS_ContentInfo_st CMS_ContentInfo;\ntypedef struct CMS_SignerInfo_st CMS_SignerInfo;\ntypedef struct CMS_CertificateChoices CMS_CertificateChoices;\ntypedef struct CMS_RevocationInfoChoice_st CMS_RevocationInfoChoice;\ntypedef struct CMS_RecipientInfo_st CMS_RecipientInfo;\ntypedef struct CMS_ReceiptRequest_st CMS_ReceiptRequest;\ntypedef struct CMS_Receipt_st CMS_Receipt;\ntypedef struct CMS_RecipientEncryptedKey_st CMS_RecipientEncryptedKey;\ntypedef struct CMS_OtherKeyAttribute_st CMS_OtherKeyAttribute;\n\nDECLARE_STACK_OF(CMS_SignerInfo)\nDECLARE_STACK_OF(GENERAL_NAMES)\nDECLARE_STACK_OF(CMS_RecipientEncryptedKey)\nDECLARE_ASN1_FUNCTIONS(CMS_ContentInfo)\nDECLARE_ASN1_FUNCTIONS(CMS_ReceiptRequest)\nDECLARE_ASN1_PRINT_FUNCTION(CMS_ContentInfo)\n\n# define CMS_SIGNERINFO_ISSUER_SERIAL    0\n# define CMS_SIGNERINFO_KEYIDENTIFIER    1\n\n# define CMS_RECIPINFO_NONE              -1\n# define CMS_RECIPINFO_TRANS             0\n# define CMS_RECIPINFO_AGREE             1\n# define CMS_RECIPINFO_KEK               2\n# define CMS_RECIPINFO_PASS              3\n# define CMS_RECIPINFO_OTHER             4\n\n/* S/MIME related flags */\n\n# define CMS_TEXT                        0x1\n# define CMS_NOCERTS                     0x2\n# define CMS_NO_CONTENT_VERIFY           0x4\n# define CMS_NO_ATTR_VERIFY              0x8\n# define CMS_NOSIGS                      \\\n                        (CMS_NO_CONTENT_VERIFY|CMS_NO_ATTR_VERIFY)\n# define CMS_NOINTERN                    0x10\n# define CMS_NO_SIGNER_CERT_VERIFY       0x20\n# define CMS_NOVERIFY                    0x20\n# define CMS_DETACHED                    0x40\n# define CMS_BINARY                      0x80\n# define CMS_NOATTR                      0x100\n# define CMS_NOSMIMECAP                  0x200\n# define CMS_NOOLDMIMETYPE               0x400\n# define CMS_CRLFEOL                     0x800\n# define CMS_STREAM                      0x1000\n# define CMS_NOCRL                       0x2000\n# define CMS_PARTIAL                     0x4000\n# define CMS_REUSE_DIGEST                0x8000\n# define CMS_USE_KEYID                   0x10000\n# define CMS_DEBUG_DECRYPT               0x20000\n# define CMS_KEY_PARAM                   0x40000\n\nconst ASN1_OBJECT *CMS_get0_type(CMS_ContentInfo *cms);\n\nBIO *CMS_dataInit(CMS_ContentInfo *cms, BIO *icont);\nint CMS_dataFinal(CMS_ContentInfo *cms, BIO *bio);\n\nASN1_OCTET_STRING **CMS_get0_content(CMS_ContentInfo *cms);\nint CMS_is_detached(CMS_ContentInfo *cms);\nint CMS_set_detached(CMS_ContentInfo *cms, int detached);\n\n# ifdef HEADER_PEM_H\nDECLARE_PEM_rw_const(CMS, CMS_ContentInfo)\n# endif\nint CMS_stream(unsigned char ***boundary, CMS_ContentInfo *cms);\nCMS_ContentInfo *d2i_CMS_bio(BIO *bp, CMS_ContentInfo **cms);\nint i2d_CMS_bio(BIO *bp, CMS_ContentInfo *cms);\n\nBIO *BIO_new_CMS(BIO *out, CMS_ContentInfo *cms);\nint i2d_CMS_bio_stream(BIO *out, CMS_ContentInfo *cms, BIO *in, int flags);\nint PEM_write_bio_CMS_stream(BIO *out, CMS_ContentInfo *cms, BIO *in,\n                             int flags);\nCMS_ContentInfo *SMIME_read_CMS(BIO *bio, BIO **bcont);\nint SMIME_write_CMS(BIO *bio, CMS_ContentInfo *cms, BIO *data, int flags);\n\nint CMS_final(CMS_ContentInfo *cms, BIO *data, BIO *dcont,\n              unsigned int flags);\n\nCMS_ContentInfo *CMS_sign(X509 *signcert, EVP_PKEY *pkey,\n                          STACK_OF(X509) *certs, BIO *data,\n                          unsigned int flags);\n\nCMS_ContentInfo *CMS_sign_receipt(CMS_SignerInfo *si,\n                                  X509 *signcert, EVP_PKEY *pkey,\n                                  STACK_OF(X509) *certs, unsigned int flags);\n\nint CMS_data(CMS_ContentInfo *cms, BIO *out, unsigned int flags);\nCMS_ContentInfo *CMS_data_create(BIO *in, unsigned int flags);\n\nint CMS_digest_verify(CMS_ContentInfo *cms, BIO *dcont, BIO *out,\n                      unsigned int flags);\nCMS_ContentInfo *CMS_digest_create(BIO *in, const EVP_MD *md,\n                                   unsigned int flags);\n\nint CMS_EncryptedData_decrypt(CMS_ContentInfo *cms,\n                              const unsigned char *key, size_t keylen,\n                              BIO *dcont, BIO *out, unsigned int flags);\n\nCMS_ContentInfo *CMS_EncryptedData_encrypt(BIO *in, const EVP_CIPHER *cipher,\n                                           const unsigned char *key,\n                                           size_t keylen, unsigned int flags);\n\nint CMS_EncryptedData_set1_key(CMS_ContentInfo *cms, const EVP_CIPHER *ciph,\n                               const unsigned char *key, size_t keylen);\n\nint CMS_verify(CMS_ContentInfo *cms, STACK_OF(X509) *certs,\n               X509_STORE *store, BIO *dcont, BIO *out, unsigned int flags);\n\nint CMS_verify_receipt(CMS_ContentInfo *rcms, CMS_ContentInfo *ocms,\n                       STACK_OF(X509) *certs,\n                       X509_STORE *store, unsigned int flags);\n\nSTACK_OF(X509) *CMS_get0_signers(CMS_ContentInfo *cms);\n\nCMS_ContentInfo *CMS_encrypt(STACK_OF(X509) *certs, BIO *in,\n                             const EVP_CIPHER *cipher, unsigned int flags);\n\nint CMS_decrypt(CMS_ContentInfo *cms, EVP_PKEY *pkey, X509 *cert,\n                BIO *dcont, BIO *out, unsigned int flags);\n\nint CMS_decrypt_set1_pkey(CMS_ContentInfo *cms, EVP_PKEY *pk, X509 *cert);\nint CMS_decrypt_set1_key(CMS_ContentInfo *cms,\n                         unsigned char *key, size_t keylen,\n                         unsigned char *id, size_t idlen);\nint CMS_decrypt_set1_password(CMS_ContentInfo *cms,\n                              unsigned char *pass, ossl_ssize_t passlen);\n\nSTACK_OF(CMS_RecipientInfo) *CMS_get0_RecipientInfos(CMS_ContentInfo *cms);\nint CMS_RecipientInfo_type(CMS_RecipientInfo *ri);\nEVP_PKEY_CTX *CMS_RecipientInfo_get0_pkey_ctx(CMS_RecipientInfo *ri);\nCMS_ContentInfo *CMS_EnvelopedData_create(const EVP_CIPHER *cipher);\nCMS_RecipientInfo *CMS_add1_recipient_cert(CMS_ContentInfo *cms,\n                                           X509 *recip, unsigned int flags);\nint CMS_RecipientInfo_set0_pkey(CMS_RecipientInfo *ri, EVP_PKEY *pkey);\nint CMS_RecipientInfo_ktri_cert_cmp(CMS_RecipientInfo *ri, X509 *cert);\nint CMS_RecipientInfo_ktri_get0_algs(CMS_RecipientInfo *ri,\n                                     EVP_PKEY **pk, X509 **recip,\n                                     X509_ALGOR **palg);\nint CMS_RecipientInfo_ktri_get0_signer_id(CMS_RecipientInfo *ri,\n                                          ASN1_OCTET_STRING **keyid,\n                                          X509_NAME **issuer,\n                                          ASN1_INTEGER **sno);\n\nCMS_RecipientInfo *CMS_add0_recipient_key(CMS_ContentInfo *cms, int nid,\n                                          unsigned char *key, size_t keylen,\n                                          unsigned char *id, size_t idlen,\n                                          ASN1_GENERALIZEDTIME *date,\n                                          ASN1_OBJECT *otherTypeId,\n                                          ASN1_TYPE *otherType);\n\nint CMS_RecipientInfo_kekri_get0_id(CMS_RecipientInfo *ri,\n                                    X509_ALGOR **palg,\n                                    ASN1_OCTET_STRING **pid,\n                                    ASN1_GENERALIZEDTIME **pdate,\n                                    ASN1_OBJECT **potherid,\n                                    ASN1_TYPE **pothertype);\n\nint CMS_RecipientInfo_set0_key(CMS_RecipientInfo *ri,\n                               unsigned char *key, size_t keylen);\n\nint CMS_RecipientInfo_kekri_id_cmp(CMS_RecipientInfo *ri,\n                                   const unsigned char *id, size_t idlen);\n\nint CMS_RecipientInfo_set0_password(CMS_RecipientInfo *ri,\n                                    unsigned char *pass,\n                                    ossl_ssize_t passlen);\n\nCMS_RecipientInfo *CMS_add0_recipient_password(CMS_ContentInfo *cms,\n                                               int iter, int wrap_nid,\n                                               int pbe_nid,\n                                               unsigned char *pass,\n                                               ossl_ssize_t passlen,\n                                               const EVP_CIPHER *kekciph);\n\nint CMS_RecipientInfo_decrypt(CMS_ContentInfo *cms, CMS_RecipientInfo *ri);\nint CMS_RecipientInfo_encrypt(CMS_ContentInfo *cms, CMS_RecipientInfo *ri);\n\nint CMS_uncompress(CMS_ContentInfo *cms, BIO *dcont, BIO *out,\n                   unsigned int flags);\nCMS_ContentInfo *CMS_compress(BIO *in, int comp_nid, unsigned int flags);\n\nint CMS_set1_eContentType(CMS_ContentInfo *cms, const ASN1_OBJECT *oid);\nconst ASN1_OBJECT *CMS_get0_eContentType(CMS_ContentInfo *cms);\n\nCMS_CertificateChoices *CMS_add0_CertificateChoices(CMS_ContentInfo *cms);\nint CMS_add0_cert(CMS_ContentInfo *cms, X509 *cert);\nint CMS_add1_cert(CMS_ContentInfo *cms, X509 *cert);\nSTACK_OF(X509) *CMS_get1_certs(CMS_ContentInfo *cms);\n\nCMS_RevocationInfoChoice *CMS_add0_RevocationInfoChoice(CMS_ContentInfo *cms);\nint CMS_add0_crl(CMS_ContentInfo *cms, X509_CRL *crl);\nint CMS_add1_crl(CMS_ContentInfo *cms, X509_CRL *crl);\nSTACK_OF(X509_CRL) *CMS_get1_crls(CMS_ContentInfo *cms);\n\nint CMS_SignedData_init(CMS_ContentInfo *cms);\nCMS_SignerInfo *CMS_add1_signer(CMS_ContentInfo *cms,\n                                X509 *signer, EVP_PKEY *pk, const EVP_MD *md,\n                                unsigned int flags);\nEVP_PKEY_CTX *CMS_SignerInfo_get0_pkey_ctx(CMS_SignerInfo *si);\nEVP_MD_CTX *CMS_SignerInfo_get0_md_ctx(CMS_SignerInfo *si);\nSTACK_OF(CMS_SignerInfo) *CMS_get0_SignerInfos(CMS_ContentInfo *cms);\n\nvoid CMS_SignerInfo_set1_signer_cert(CMS_SignerInfo *si, X509 *signer);\nint CMS_SignerInfo_get0_signer_id(CMS_SignerInfo *si,\n                                  ASN1_OCTET_STRING **keyid,\n                                  X509_NAME **issuer, ASN1_INTEGER **sno);\nint CMS_SignerInfo_cert_cmp(CMS_SignerInfo *si, X509 *cert);\nint CMS_set1_signers_certs(CMS_ContentInfo *cms, STACK_OF(X509) *certs,\n                           unsigned int flags);\nvoid CMS_SignerInfo_get0_algs(CMS_SignerInfo *si, EVP_PKEY **pk,\n                              X509 **signer, X509_ALGOR **pdig,\n                              X509_ALGOR **psig);\nASN1_OCTET_STRING *CMS_SignerInfo_get0_signature(CMS_SignerInfo *si);\nint CMS_SignerInfo_sign(CMS_SignerInfo *si);\nint CMS_SignerInfo_verify(CMS_SignerInfo *si);\nint CMS_SignerInfo_verify_content(CMS_SignerInfo *si, BIO *chain);\n\nint CMS_add_smimecap(CMS_SignerInfo *si, STACK_OF(X509_ALGOR) *algs);\nint CMS_add_simple_smimecap(STACK_OF(X509_ALGOR) **algs,\n                            int algnid, int keysize);\nint CMS_add_standard_smimecap(STACK_OF(X509_ALGOR) **smcap);\n\nint CMS_signed_get_attr_count(const CMS_SignerInfo *si);\nint CMS_signed_get_attr_by_NID(const CMS_SignerInfo *si, int nid,\n                               int lastpos);\nint CMS_signed_get_attr_by_OBJ(const CMS_SignerInfo *si, ASN1_OBJECT *obj,\n                               int lastpos);\nX509_ATTRIBUTE *CMS_signed_get_attr(const CMS_SignerInfo *si, int loc);\nX509_ATTRIBUTE *CMS_signed_delete_attr(CMS_SignerInfo *si, int loc);\nint CMS_signed_add1_attr(CMS_SignerInfo *si, X509_ATTRIBUTE *attr);\nint CMS_signed_add1_attr_by_OBJ(CMS_SignerInfo *si,\n                                const ASN1_OBJECT *obj, int type,\n                                const void *bytes, int len);\nint CMS_signed_add1_attr_by_NID(CMS_SignerInfo *si,\n                                int nid, int type,\n                                const void *bytes, int len);\nint CMS_signed_add1_attr_by_txt(CMS_SignerInfo *si,\n                                const char *attrname, int type,\n                                const void *bytes, int len);\nvoid *CMS_signed_get0_data_by_OBJ(CMS_SignerInfo *si, ASN1_OBJECT *oid,\n                                  int lastpos, int type);\n\nint CMS_unsigned_get_attr_count(const CMS_SignerInfo *si);\nint CMS_unsigned_get_attr_by_NID(const CMS_SignerInfo *si, int nid,\n                                 int lastpos);\nint CMS_unsigned_get_attr_by_OBJ(const CMS_SignerInfo *si, ASN1_OBJECT *obj,\n                                 int lastpos);\nX509_ATTRIBUTE *CMS_unsigned_get_attr(const CMS_SignerInfo *si, int loc);\nX509_ATTRIBUTE *CMS_unsigned_delete_attr(CMS_SignerInfo *si, int loc);\nint CMS_unsigned_add1_attr(CMS_SignerInfo *si, X509_ATTRIBUTE *attr);\nint CMS_unsigned_add1_attr_by_OBJ(CMS_SignerInfo *si,\n                                  const ASN1_OBJECT *obj, int type,\n                                  const void *bytes, int len);\nint CMS_unsigned_add1_attr_by_NID(CMS_SignerInfo *si,\n                                  int nid, int type,\n                                  const void *bytes, int len);\nint CMS_unsigned_add1_attr_by_txt(CMS_SignerInfo *si,\n                                  const char *attrname, int type,\n                                  const void *bytes, int len);\nvoid *CMS_unsigned_get0_data_by_OBJ(CMS_SignerInfo *si, ASN1_OBJECT *oid,\n                                    int lastpos, int type);\n\n# ifdef HEADER_X509V3_H\n\nint CMS_get1_ReceiptRequest(CMS_SignerInfo *si, CMS_ReceiptRequest **prr);\nCMS_ReceiptRequest *CMS_ReceiptRequest_create0(unsigned char *id, int idlen,\n                                               int allorfirst,\n                                               STACK_OF(GENERAL_NAMES)\n                                               *receiptList, STACK_OF(GENERAL_NAMES)\n                                               *receiptsTo);\nint CMS_add1_ReceiptRequest(CMS_SignerInfo *si, CMS_ReceiptRequest *rr);\nvoid CMS_ReceiptRequest_get0_values(CMS_ReceiptRequest *rr,\n                                    ASN1_STRING **pcid,\n                                    int *pallorfirst,\n                                    STACK_OF(GENERAL_NAMES) **plist,\n                                    STACK_OF(GENERAL_NAMES) **prto);\n# endif\nint CMS_RecipientInfo_kari_get0_alg(CMS_RecipientInfo *ri,\n                                    X509_ALGOR **palg,\n                                    ASN1_OCTET_STRING **pukm);\nSTACK_OF(CMS_RecipientEncryptedKey)\n*CMS_RecipientInfo_kari_get0_reks(CMS_RecipientInfo *ri);\n\nint CMS_RecipientInfo_kari_get0_orig_id(CMS_RecipientInfo *ri,\n                                        X509_ALGOR **pubalg,\n                                        ASN1_BIT_STRING **pubkey,\n                                        ASN1_OCTET_STRING **keyid,\n                                        X509_NAME **issuer,\n                                        ASN1_INTEGER **sno);\n\nint CMS_RecipientInfo_kari_orig_id_cmp(CMS_RecipientInfo *ri, X509 *cert);\n\nint CMS_RecipientEncryptedKey_get0_id(CMS_RecipientEncryptedKey *rek,\n                                      ASN1_OCTET_STRING **keyid,\n                                      ASN1_GENERALIZEDTIME **tm,\n                                      CMS_OtherKeyAttribute **other,\n                                      X509_NAME **issuer, ASN1_INTEGER **sno);\nint CMS_RecipientEncryptedKey_cert_cmp(CMS_RecipientEncryptedKey *rek,\n                                       X509 *cert);\nint CMS_RecipientInfo_kari_set0_pkey(CMS_RecipientInfo *ri, EVP_PKEY *pk);\nEVP_CIPHER_CTX *CMS_RecipientInfo_kari_get0_ctx(CMS_RecipientInfo *ri);\nint CMS_RecipientInfo_kari_decrypt(CMS_ContentInfo *cms,\n                                   CMS_RecipientInfo *ri,\n                                   CMS_RecipientEncryptedKey *rek);\n\nint CMS_SharedInfo_encode(unsigned char **pder, X509_ALGOR *kekalg,\n                          ASN1_OCTET_STRING *ukm, int keylen);\n\n/* BEGIN ERROR CODES */\n/*\n * The following lines are auto generated by the script mkerr.pl. Any changes\n * made after this point may be overwritten when the script is next run.\n */\nvoid ERR_load_CMS_strings(void);\n\n/* Error codes for the CMS functions. */\n\n/* Function codes. */\n# define CMS_F_CHECK_CONTENT                              99\n# define CMS_F_CMS_ADD0_CERT                              164\n# define CMS_F_CMS_ADD0_RECIPIENT_KEY                     100\n# define CMS_F_CMS_ADD0_RECIPIENT_PASSWORD                165\n# define CMS_F_CMS_ADD1_RECEIPTREQUEST                    158\n# define CMS_F_CMS_ADD1_RECIPIENT_CERT                    101\n# define CMS_F_CMS_ADD1_SIGNER                            102\n# define CMS_F_CMS_ADD1_SIGNINGTIME                       103\n# define CMS_F_CMS_COMPRESS                               104\n# define CMS_F_CMS_COMPRESSEDDATA_CREATE                  105\n# define CMS_F_CMS_COMPRESSEDDATA_INIT_BIO                106\n# define CMS_F_CMS_COPY_CONTENT                           107\n# define CMS_F_CMS_COPY_MESSAGEDIGEST                     108\n# define CMS_F_CMS_DATA                                   109\n# define CMS_F_CMS_DATAFINAL                              110\n# define CMS_F_CMS_DATAINIT                               111\n# define CMS_F_CMS_DECRYPT                                112\n# define CMS_F_CMS_DECRYPT_SET1_KEY                       113\n# define CMS_F_CMS_DECRYPT_SET1_PASSWORD                  166\n# define CMS_F_CMS_DECRYPT_SET1_PKEY                      114\n# define CMS_F_CMS_DIGESTALGORITHM_FIND_CTX               115\n# define CMS_F_CMS_DIGESTALGORITHM_INIT_BIO               116\n# define CMS_F_CMS_DIGESTEDDATA_DO_FINAL                  117\n# define CMS_F_CMS_DIGEST_VERIFY                          118\n# define CMS_F_CMS_ENCODE_RECEIPT                         161\n# define CMS_F_CMS_ENCRYPT                                119\n# define CMS_F_CMS_ENCRYPTEDCONTENT_INIT_BIO              120\n# define CMS_F_CMS_ENCRYPTEDDATA_DECRYPT                  121\n# define CMS_F_CMS_ENCRYPTEDDATA_ENCRYPT                  122\n# define CMS_F_CMS_ENCRYPTEDDATA_SET1_KEY                 123\n# define CMS_F_CMS_ENVELOPEDDATA_CREATE                   124\n# define CMS_F_CMS_ENVELOPEDDATA_INIT_BIO                 125\n# define CMS_F_CMS_ENVELOPED_DATA_INIT                    126\n# define CMS_F_CMS_ENV_ASN1_CTRL                          171\n# define CMS_F_CMS_FINAL                                  127\n# define CMS_F_CMS_GET0_CERTIFICATE_CHOICES               128\n# define CMS_F_CMS_GET0_CONTENT                           129\n# define CMS_F_CMS_GET0_ECONTENT_TYPE                     130\n# define CMS_F_CMS_GET0_ENVELOPED                         131\n# define CMS_F_CMS_GET0_REVOCATION_CHOICES                132\n# define CMS_F_CMS_GET0_SIGNED                            133\n# define CMS_F_CMS_MSGSIGDIGEST_ADD1                      162\n# define CMS_F_CMS_RECEIPTREQUEST_CREATE0                 159\n# define CMS_F_CMS_RECEIPT_VERIFY                         160\n# define CMS_F_CMS_RECIPIENTINFO_DECRYPT                  134\n# define CMS_F_CMS_RECIPIENTINFO_ENCRYPT                  169\n# define CMS_F_CMS_RECIPIENTINFO_KARI_ENCRYPT             178\n# define CMS_F_CMS_RECIPIENTINFO_KARI_GET0_ALG            175\n# define CMS_F_CMS_RECIPIENTINFO_KARI_GET0_ORIG_ID        173\n# define CMS_F_CMS_RECIPIENTINFO_KARI_GET0_REKS           172\n# define CMS_F_CMS_RECIPIENTINFO_KARI_ORIG_ID_CMP         174\n# define CMS_F_CMS_RECIPIENTINFO_KEKRI_DECRYPT            135\n# define CMS_F_CMS_RECIPIENTINFO_KEKRI_ENCRYPT            136\n# define CMS_F_CMS_RECIPIENTINFO_KEKRI_GET0_ID            137\n# define CMS_F_CMS_RECIPIENTINFO_KEKRI_ID_CMP             138\n# define CMS_F_CMS_RECIPIENTINFO_KTRI_CERT_CMP            139\n# define CMS_F_CMS_RECIPIENTINFO_KTRI_DECRYPT             140\n# define CMS_F_CMS_RECIPIENTINFO_KTRI_ENCRYPT             141\n# define CMS_F_CMS_RECIPIENTINFO_KTRI_GET0_ALGS           142\n# define CMS_F_CMS_RECIPIENTINFO_KTRI_GET0_SIGNER_ID      143\n# define CMS_F_CMS_RECIPIENTINFO_PWRI_CRYPT               167\n# define CMS_F_CMS_RECIPIENTINFO_SET0_KEY                 144\n# define CMS_F_CMS_RECIPIENTINFO_SET0_PASSWORD            168\n# define CMS_F_CMS_RECIPIENTINFO_SET0_PKEY                145\n# define CMS_F_CMS_SD_ASN1_CTRL                           170\n# define CMS_F_CMS_SET1_IAS                               176\n# define CMS_F_CMS_SET1_KEYID                             177\n# define CMS_F_CMS_SET1_SIGNERIDENTIFIER                  146\n# define CMS_F_CMS_SET_DETACHED                           147\n# define CMS_F_CMS_SIGN                                   148\n# define CMS_F_CMS_SIGNED_DATA_INIT                       149\n# define CMS_F_CMS_SIGNERINFO_CONTENT_SIGN                150\n# define CMS_F_CMS_SIGNERINFO_SIGN                        151\n# define CMS_F_CMS_SIGNERINFO_VERIFY                      152\n# define CMS_F_CMS_SIGNERINFO_VERIFY_CERT                 153\n# define CMS_F_CMS_SIGNERINFO_VERIFY_CONTENT              154\n# define CMS_F_CMS_SIGN_RECEIPT                           163\n# define CMS_F_CMS_STREAM                                 155\n# define CMS_F_CMS_UNCOMPRESS                             156\n# define CMS_F_CMS_VERIFY                                 157\n\n/* Reason codes. */\n# define CMS_R_ADD_SIGNER_ERROR                           99\n# define CMS_R_CERTIFICATE_ALREADY_PRESENT                175\n# define CMS_R_CERTIFICATE_HAS_NO_KEYID                   160\n# define CMS_R_CERTIFICATE_VERIFY_ERROR                   100\n# define CMS_R_CIPHER_INITIALISATION_ERROR                101\n# define CMS_R_CIPHER_PARAMETER_INITIALISATION_ERROR      102\n# define CMS_R_CMS_DATAFINAL_ERROR                        103\n# define CMS_R_CMS_LIB                                    104\n# define CMS_R_CONTENTIDENTIFIER_MISMATCH                 170\n# define CMS_R_CONTENT_NOT_FOUND                          105\n# define CMS_R_CONTENT_TYPE_MISMATCH                      171\n# define CMS_R_CONTENT_TYPE_NOT_COMPRESSED_DATA           106\n# define CMS_R_CONTENT_TYPE_NOT_ENVELOPED_DATA            107\n# define CMS_R_CONTENT_TYPE_NOT_SIGNED_DATA               108\n# define CMS_R_CONTENT_VERIFY_ERROR                       109\n# define CMS_R_CTRL_ERROR                                 110\n# define CMS_R_CTRL_FAILURE                               111\n# define CMS_R_DECRYPT_ERROR                              112\n# define CMS_R_DIGEST_ERROR                               161\n# define CMS_R_ERROR_GETTING_PUBLIC_KEY                   113\n# define CMS_R_ERROR_READING_MESSAGEDIGEST_ATTRIBUTE      114\n# define CMS_R_ERROR_SETTING_KEY                          115\n# define CMS_R_ERROR_SETTING_RECIPIENTINFO                116\n# define CMS_R_INVALID_ENCRYPTED_KEY_LENGTH               117\n# define CMS_R_INVALID_KEY_ENCRYPTION_PARAMETER           176\n# define CMS_R_INVALID_KEY_LENGTH                         118\n# define CMS_R_MD_BIO_INIT_ERROR                          119\n# define CMS_R_MESSAGEDIGEST_ATTRIBUTE_WRONG_LENGTH       120\n# define CMS_R_MESSAGEDIGEST_WRONG_LENGTH                 121\n# define CMS_R_MSGSIGDIGEST_ERROR                         172\n# define CMS_R_MSGSIGDIGEST_VERIFICATION_FAILURE          162\n# define CMS_R_MSGSIGDIGEST_WRONG_LENGTH                  163\n# define CMS_R_NEED_ONE_SIGNER                            164\n# define CMS_R_NOT_A_SIGNED_RECEIPT                       165\n# define CMS_R_NOT_ENCRYPTED_DATA                         122\n# define CMS_R_NOT_KEK                                    123\n# define CMS_R_NOT_KEY_AGREEMENT                          181\n# define CMS_R_NOT_KEY_TRANSPORT                          124\n# define CMS_R_NOT_PWRI                                   177\n# define CMS_R_NOT_SUPPORTED_FOR_THIS_KEY_TYPE            125\n# define CMS_R_NO_CIPHER                                  126\n# define CMS_R_NO_CONTENT                                 127\n# define CMS_R_NO_CONTENT_TYPE                            173\n# define CMS_R_NO_DEFAULT_DIGEST                          128\n# define CMS_R_NO_DIGEST_SET                              129\n# define CMS_R_NO_KEY                                     130\n# define CMS_R_NO_KEY_OR_CERT                             174\n# define CMS_R_NO_MATCHING_DIGEST                         131\n# define CMS_R_NO_MATCHING_RECIPIENT                      132\n# define CMS_R_NO_MATCHING_SIGNATURE                      166\n# define CMS_R_NO_MSGSIGDIGEST                            167\n# define CMS_R_NO_PASSWORD                                178\n# define CMS_R_NO_PRIVATE_KEY                             133\n# define CMS_R_NO_PUBLIC_KEY                              134\n# define CMS_R_NO_RECEIPT_REQUEST                         168\n# define CMS_R_NO_SIGNERS                                 135\n# define CMS_R_PRIVATE_KEY_DOES_NOT_MATCH_CERTIFICATE     136\n# define CMS_R_RECEIPT_DECODE_ERROR                       169\n# define CMS_R_RECIPIENT_ERROR                            137\n# define CMS_R_SIGNER_CERTIFICATE_NOT_FOUND               138\n# define CMS_R_SIGNFINAL_ERROR                            139\n# define CMS_R_SMIME_TEXT_ERROR                           140\n# define CMS_R_STORE_INIT_ERROR                           141\n# define CMS_R_TYPE_NOT_COMPRESSED_DATA                   142\n# define CMS_R_TYPE_NOT_DATA                              143\n# define CMS_R_TYPE_NOT_DIGESTED_DATA                     144\n# define CMS_R_TYPE_NOT_ENCRYPTED_DATA                    145\n# define CMS_R_TYPE_NOT_ENVELOPED_DATA                    146\n# define CMS_R_UNABLE_TO_FINALIZE_CONTEXT                 147\n# define CMS_R_UNKNOWN_CIPHER                             148\n# define CMS_R_UNKNOWN_DIGEST_ALGORIHM                    149\n# define CMS_R_UNKNOWN_ID                                 150\n# define CMS_R_UNSUPPORTED_COMPRESSION_ALGORITHM          151\n# define CMS_R_UNSUPPORTED_CONTENT_TYPE                   152\n# define CMS_R_UNSUPPORTED_KEK_ALGORITHM                  153\n# define CMS_R_UNSUPPORTED_KEY_ENCRYPTION_ALGORITHM       179\n# define CMS_R_UNSUPPORTED_RECIPIENT_TYPE                 154\n# define CMS_R_UNSUPPORTED_RECPIENTINFO_TYPE              155\n# define CMS_R_UNSUPPORTED_TYPE                           156\n# define CMS_R_UNWRAP_ERROR                               157\n# define CMS_R_UNWRAP_FAILURE                             180\n# define CMS_R_VERIFICATION_FAILURE                       158\n# define CMS_R_WRAP_ERROR                                 159\n\n#ifdef  __cplusplus\n}\n#endif\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/x86/include/openssl/conf.h",
    "content": "/* crypto/conf/conf.h */\n/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)\n * All rights reserved.\n *\n * This package is an SSL implementation written\n * by Eric Young (eay@cryptsoft.com).\n * The implementation was written so as to conform with Netscapes SSL.\n *\n * This library is free for commercial and non-commercial use as long as\n * the following conditions are aheared to.  The following conditions\n * apply to all code found in this distribution, be it the RC4, RSA,\n * lhash, DES, etc., code; not just the SSL code.  The SSL documentation\n * included with this distribution is covered by the same copyright terms\n * except that the holder is Tim Hudson (tjh@cryptsoft.com).\n *\n * Copyright remains Eric Young's, and as such any Copyright notices in\n * the code are not to be removed.\n * If this package is used in a product, Eric Young should be given attribution\n * as the author of the parts of the library used.\n * This can be in the form of a textual message at program startup or\n * in documentation (online or textual) provided with the package.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the copyright\n *    notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in the\n *    documentation and/or other materials provided with the distribution.\n * 3. All advertising materials mentioning features or use of this software\n *    must display the following acknowledgement:\n *    \"This product includes cryptographic software written by\n *     Eric Young (eay@cryptsoft.com)\"\n *    The word 'cryptographic' can be left out if the rouines from the library\n *    being used are not cryptographic related :-).\n * 4. If you include any Windows specific code (or a derivative thereof) from\n *    the apps directory (application code) you must include an acknowledgement:\n *    \"This product includes software written by Tim Hudson (tjh@cryptsoft.com)\"\n *\n * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n * SUCH DAMAGE.\n *\n * The licence and distribution terms for any publically available version or\n * derivative of this code cannot be changed.  i.e. this code cannot simply be\n * copied and put under another distribution licence\n * [including the GNU Public Licence.]\n */\n\n#ifndef  HEADER_CONF_H\n# define HEADER_CONF_H\n\n# include <openssl/bio.h>\n# include <openssl/lhash.h>\n# include <openssl/stack.h>\n# include <openssl/safestack.h>\n# include <openssl/e_os2.h>\n\n# include <openssl/ossl_typ.h>\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\ntypedef struct {\n    char *section;\n    char *name;\n    char *value;\n} CONF_VALUE;\n\nDECLARE_STACK_OF(CONF_VALUE)\nDECLARE_LHASH_OF(CONF_VALUE);\n\nstruct conf_st;\nstruct conf_method_st;\ntypedef struct conf_method_st CONF_METHOD;\n\nstruct conf_method_st {\n    const char *name;\n    CONF *(*create) (CONF_METHOD *meth);\n    int (*init) (CONF *conf);\n    int (*destroy) (CONF *conf);\n    int (*destroy_data) (CONF *conf);\n    int (*load_bio) (CONF *conf, BIO *bp, long *eline);\n    int (*dump) (const CONF *conf, BIO *bp);\n    int (*is_number) (const CONF *conf, char c);\n    int (*to_int) (const CONF *conf, char c);\n    int (*load) (CONF *conf, const char *name, long *eline);\n};\n\n/* Module definitions */\n\ntypedef struct conf_imodule_st CONF_IMODULE;\ntypedef struct conf_module_st CONF_MODULE;\n\nDECLARE_STACK_OF(CONF_MODULE)\nDECLARE_STACK_OF(CONF_IMODULE)\n\n/* DSO module function typedefs */\ntypedef int conf_init_func (CONF_IMODULE *md, const CONF *cnf);\ntypedef void conf_finish_func (CONF_IMODULE *md);\n\n# define CONF_MFLAGS_IGNORE_ERRORS       0x1\n# define CONF_MFLAGS_IGNORE_RETURN_CODES 0x2\n# define CONF_MFLAGS_SILENT              0x4\n# define CONF_MFLAGS_NO_DSO              0x8\n# define CONF_MFLAGS_IGNORE_MISSING_FILE 0x10\n# define CONF_MFLAGS_DEFAULT_SECTION     0x20\n\nint CONF_set_default_method(CONF_METHOD *meth);\nvoid CONF_set_nconf(CONF *conf, LHASH_OF(CONF_VALUE) *hash);\nLHASH_OF(CONF_VALUE) *CONF_load(LHASH_OF(CONF_VALUE) *conf, const char *file,\n                                long *eline);\n# ifndef OPENSSL_NO_FP_API\nLHASH_OF(CONF_VALUE) *CONF_load_fp(LHASH_OF(CONF_VALUE) *conf, FILE *fp,\n                                   long *eline);\n# endif\nLHASH_OF(CONF_VALUE) *CONF_load_bio(LHASH_OF(CONF_VALUE) *conf, BIO *bp,\n                                    long *eline);\nSTACK_OF(CONF_VALUE) *CONF_get_section(LHASH_OF(CONF_VALUE) *conf,\n                                       const char *section);\nchar *CONF_get_string(LHASH_OF(CONF_VALUE) *conf, const char *group,\n                      const char *name);\nlong CONF_get_number(LHASH_OF(CONF_VALUE) *conf, const char *group,\n                     const char *name);\nvoid CONF_free(LHASH_OF(CONF_VALUE) *conf);\nint CONF_dump_fp(LHASH_OF(CONF_VALUE) *conf, FILE *out);\nint CONF_dump_bio(LHASH_OF(CONF_VALUE) *conf, BIO *out);\n\nvoid OPENSSL_config(const char *config_name);\nvoid OPENSSL_no_config(void);\n\n/*\n * New conf code.  The semantics are different from the functions above. If\n * that wasn't the case, the above functions would have been replaced\n */\n\nstruct conf_st {\n    CONF_METHOD *meth;\n    void *meth_data;\n    LHASH_OF(CONF_VALUE) *data;\n};\n\nCONF *NCONF_new(CONF_METHOD *meth);\nCONF_METHOD *NCONF_default(void);\nCONF_METHOD *NCONF_WIN32(void);\n# if 0                          /* Just to give you an idea of what I have in\n                                 * mind */\nCONF_METHOD *NCONF_XML(void);\n# endif\nvoid NCONF_free(CONF *conf);\nvoid NCONF_free_data(CONF *conf);\n\nint NCONF_load(CONF *conf, const char *file, long *eline);\n# ifndef OPENSSL_NO_FP_API\nint NCONF_load_fp(CONF *conf, FILE *fp, long *eline);\n# endif\nint NCONF_load_bio(CONF *conf, BIO *bp, long *eline);\nSTACK_OF(CONF_VALUE) *NCONF_get_section(const CONF *conf,\n                                        const char *section);\nchar *NCONF_get_string(const CONF *conf, const char *group, const char *name);\nint NCONF_get_number_e(const CONF *conf, const char *group, const char *name,\n                       long *result);\nint NCONF_dump_fp(const CONF *conf, FILE *out);\nint NCONF_dump_bio(const CONF *conf, BIO *out);\n\n# if 0                          /* The following function has no error\n                                 * checking, and should therefore be avoided */\nlong NCONF_get_number(CONF *conf, char *group, char *name);\n# else\n#  define NCONF_get_number(c,g,n,r) NCONF_get_number_e(c,g,n,r)\n# endif\n\n/* Module functions */\n\nint CONF_modules_load(const CONF *cnf, const char *appname,\n                      unsigned long flags);\nint CONF_modules_load_file(const char *filename, const char *appname,\n                           unsigned long flags);\nvoid CONF_modules_unload(int all);\nvoid CONF_modules_finish(void);\nvoid CONF_modules_free(void);\nint CONF_module_add(const char *name, conf_init_func *ifunc,\n                    conf_finish_func *ffunc);\n\nconst char *CONF_imodule_get_name(const CONF_IMODULE *md);\nconst char *CONF_imodule_get_value(const CONF_IMODULE *md);\nvoid *CONF_imodule_get_usr_data(const CONF_IMODULE *md);\nvoid CONF_imodule_set_usr_data(CONF_IMODULE *md, void *usr_data);\nCONF_MODULE *CONF_imodule_get_module(const CONF_IMODULE *md);\nunsigned long CONF_imodule_get_flags(const CONF_IMODULE *md);\nvoid CONF_imodule_set_flags(CONF_IMODULE *md, unsigned long flags);\nvoid *CONF_module_get_usr_data(CONF_MODULE *pmod);\nvoid CONF_module_set_usr_data(CONF_MODULE *pmod, void *usr_data);\n\nchar *CONF_get1_default_config_file(void);\n\nint CONF_parse_list(const char *list, int sep, int nospc,\n                    int (*list_cb) (const char *elem, int len, void *usr),\n                    void *arg);\n\nvoid OPENSSL_load_builtin_modules(void);\n\n/* BEGIN ERROR CODES */\n/*\n * The following lines are auto generated by the script mkerr.pl. Any changes\n * made after this point may be overwritten when the script is next run.\n */\nvoid ERR_load_CONF_strings(void);\n\n/* Error codes for the CONF functions. */\n\n/* Function codes. */\n# define CONF_F_CONF_DUMP_FP                              104\n# define CONF_F_CONF_LOAD                                 100\n# define CONF_F_CONF_LOAD_BIO                             102\n# define CONF_F_CONF_LOAD_FP                              103\n# define CONF_F_CONF_MODULES_LOAD                         116\n# define CONF_F_CONF_PARSE_LIST                           119\n# define CONF_F_DEF_LOAD                                  120\n# define CONF_F_DEF_LOAD_BIO                              121\n# define CONF_F_MODULE_INIT                               115\n# define CONF_F_MODULE_LOAD_DSO                           117\n# define CONF_F_MODULE_RUN                                118\n# define CONF_F_NCONF_DUMP_BIO                            105\n# define CONF_F_NCONF_DUMP_FP                             106\n# define CONF_F_NCONF_GET_NUMBER                          107\n# define CONF_F_NCONF_GET_NUMBER_E                        112\n# define CONF_F_NCONF_GET_SECTION                         108\n# define CONF_F_NCONF_GET_STRING                          109\n# define CONF_F_NCONF_LOAD                                113\n# define CONF_F_NCONF_LOAD_BIO                            110\n# define CONF_F_NCONF_LOAD_FP                             114\n# define CONF_F_NCONF_NEW                                 111\n# define CONF_F_STR_COPY                                  101\n\n/* Reason codes. */\n# define CONF_R_ERROR_LOADING_DSO                         110\n# define CONF_R_LIST_CANNOT_BE_NULL                       115\n# define CONF_R_MISSING_CLOSE_SQUARE_BRACKET              100\n# define CONF_R_MISSING_EQUAL_SIGN                        101\n# define CONF_R_MISSING_FINISH_FUNCTION                   111\n# define CONF_R_MISSING_INIT_FUNCTION                     112\n# define CONF_R_MODULE_INITIALIZATION_ERROR               109\n# define CONF_R_NO_CLOSE_BRACE                            102\n# define CONF_R_NO_CONF                                   105\n# define CONF_R_NO_CONF_OR_ENVIRONMENT_VARIABLE           106\n# define CONF_R_NO_SECTION                                107\n# define CONF_R_NO_SUCH_FILE                              114\n# define CONF_R_NO_VALUE                                  108\n# define CONF_R_UNABLE_TO_CREATE_NEW_SECTION              103\n# define CONF_R_UNKNOWN_MODULE_NAME                       113\n# define CONF_R_VARIABLE_HAS_NO_VALUE                     104\n\n#ifdef  __cplusplus\n}\n#endif\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/x86/include/openssl/conf_api.h",
    "content": "/* conf_api.h */\n/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)\n * All rights reserved.\n *\n * This package is an SSL implementation written\n * by Eric Young (eay@cryptsoft.com).\n * The implementation was written so as to conform with Netscapes SSL.\n *\n * This library is free for commercial and non-commercial use as long as\n * the following conditions are aheared to.  The following conditions\n * apply to all code found in this distribution, be it the RC4, RSA,\n * lhash, DES, etc., code; not just the SSL code.  The SSL documentation\n * included with this distribution is covered by the same copyright terms\n * except that the holder is Tim Hudson (tjh@cryptsoft.com).\n *\n * Copyright remains Eric Young's, and as such any Copyright notices in\n * the code are not to be removed.\n * If this package is used in a product, Eric Young should be given attribution\n * as the author of the parts of the library used.\n * This can be in the form of a textual message at program startup or\n * in documentation (online or textual) provided with the package.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the copyright\n *    notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in the\n *    documentation and/or other materials provided with the distribution.\n * 3. All advertising materials mentioning features or use of this software\n *    must display the following acknowledgement:\n *    \"This product includes cryptographic software written by\n *     Eric Young (eay@cryptsoft.com)\"\n *    The word 'cryptographic' can be left out if the rouines from the library\n *    being used are not cryptographic related :-).\n * 4. If you include any Windows specific code (or a derivative thereof) from\n *    the apps directory (application code) you must include an acknowledgement:\n *    \"This product includes software written by Tim Hudson (tjh@cryptsoft.com)\"\n *\n * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n * SUCH DAMAGE.\n *\n * The licence and distribution terms for any publically available version or\n * derivative of this code cannot be changed.  i.e. this code cannot simply be\n * copied and put under another distribution licence\n * [including the GNU Public Licence.]\n */\n\n#ifndef  HEADER_CONF_API_H\n# define HEADER_CONF_API_H\n\n# include <openssl/lhash.h>\n# include <openssl/conf.h>\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n/* Up until OpenSSL 0.9.5a, this was new_section */\nCONF_VALUE *_CONF_new_section(CONF *conf, const char *section);\n/* Up until OpenSSL 0.9.5a, this was get_section */\nCONF_VALUE *_CONF_get_section(const CONF *conf, const char *section);\n/* Up until OpenSSL 0.9.5a, this was CONF_get_section */\nSTACK_OF(CONF_VALUE) *_CONF_get_section_values(const CONF *conf,\n                                               const char *section);\n\nint _CONF_add_string(CONF *conf, CONF_VALUE *section, CONF_VALUE *value);\nchar *_CONF_get_string(const CONF *conf, const char *section,\n                       const char *name);\nlong _CONF_get_number(const CONF *conf, const char *section,\n                      const char *name);\n\nint _CONF_new_data(CONF *conf);\nvoid _CONF_free_data(CONF *conf);\n\n#ifdef  __cplusplus\n}\n#endif\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/x86/include/openssl/crypto.h",
    "content": "/* crypto/crypto.h */\n/* ====================================================================\n * Copyright (c) 1998-2006 The OpenSSL Project.  All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n *\n * 1. Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n *\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in\n *    the documentation and/or other materials provided with the\n *    distribution.\n *\n * 3. All advertising materials mentioning features or use of this\n *    software must display the following acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit. (http://www.openssl.org/)\"\n *\n * 4. The names \"OpenSSL Toolkit\" and \"OpenSSL Project\" must not be used to\n *    endorse or promote products derived from this software without\n *    prior written permission. For written permission, please contact\n *    openssl-core@openssl.org.\n *\n * 5. Products derived from this software may not be called \"OpenSSL\"\n *    nor may \"OpenSSL\" appear in their names without prior written\n *    permission of the OpenSSL Project.\n *\n * 6. Redistributions of any form whatsoever must retain the following\n *    acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit (http://www.openssl.org/)\"\n *\n * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY\n * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\n * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR\n * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\n * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,\n * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED\n * OF THE POSSIBILITY OF SUCH DAMAGE.\n * ====================================================================\n *\n * This product includes cryptographic software written by Eric Young\n * (eay@cryptsoft.com).  This product includes software written by Tim\n * Hudson (tjh@cryptsoft.com).\n *\n */\n/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)\n * All rights reserved.\n *\n * This package is an SSL implementation written\n * by Eric Young (eay@cryptsoft.com).\n * The implementation was written so as to conform with Netscapes SSL.\n *\n * This library is free for commercial and non-commercial use as long as\n * the following conditions are aheared to.  The following conditions\n * apply to all code found in this distribution, be it the RC4, RSA,\n * lhash, DES, etc., code; not just the SSL code.  The SSL documentation\n * included with this distribution is covered by the same copyright terms\n * except that the holder is Tim Hudson (tjh@cryptsoft.com).\n *\n * Copyright remains Eric Young's, and as such any Copyright notices in\n * the code are not to be removed.\n * If this package is used in a product, Eric Young should be given attribution\n * as the author of the parts of the library used.\n * This can be in the form of a textual message at program startup or\n * in documentation (online or textual) provided with the package.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the copyright\n *    notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in the\n *    documentation and/or other materials provided with the distribution.\n * 3. All advertising materials mentioning features or use of this software\n *    must display the following acknowledgement:\n *    \"This product includes cryptographic software written by\n *     Eric Young (eay@cryptsoft.com)\"\n *    The word 'cryptographic' can be left out if the rouines from the library\n *    being used are not cryptographic related :-).\n * 4. If you include any Windows specific code (or a derivative thereof) from\n *    the apps directory (application code) you must include an acknowledgement:\n *    \"This product includes software written by Tim Hudson (tjh@cryptsoft.com)\"\n *\n * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n * SUCH DAMAGE.\n *\n * The licence and distribution terms for any publically available version or\n * derivative of this code cannot be changed.  i.e. this code cannot simply be\n * copied and put under another distribution licence\n * [including the GNU Public Licence.]\n */\n/* ====================================================================\n * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED.\n * ECDH support in OpenSSL originally developed by\n * SUN MICROSYSTEMS, INC., and contributed to the OpenSSL project.\n */\n\n#ifndef HEADER_CRYPTO_H\n# define HEADER_CRYPTO_H\n\n# include <stdlib.h>\n\n# include <openssl/e_os2.h>\n\n# ifndef OPENSSL_NO_FP_API\n#  include <stdio.h>\n# endif\n\n# include <openssl/stack.h>\n# include <openssl/safestack.h>\n# include <openssl/opensslv.h>\n# include <openssl/ossl_typ.h>\n\n# ifdef CHARSET_EBCDIC\n#  include <openssl/ebcdic.h>\n# endif\n\n/*\n * Resolve problems on some operating systems with symbol names that clash\n * one way or another\n */\n# include <openssl/symhacks.h>\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n/* Backward compatibility to SSLeay */\n/*\n * This is more to be used to check the correct DLL is being used in the MS\n * world.\n */\n# define SSLEAY_VERSION_NUMBER   OPENSSL_VERSION_NUMBER\n# define SSLEAY_VERSION          0\n/* #define SSLEAY_OPTIONS       1 no longer supported */\n# define SSLEAY_CFLAGS           2\n# define SSLEAY_BUILT_ON         3\n# define SSLEAY_PLATFORM         4\n# define SSLEAY_DIR              5\n\n/* Already declared in ossl_typ.h */\n# if 0\ntypedef struct crypto_ex_data_st CRYPTO_EX_DATA;\n/* Called when a new object is created */\ntypedef int CRYPTO_EX_new (void *parent, void *ptr, CRYPTO_EX_DATA *ad,\n                           int idx, long argl, void *argp);\n/* Called when an object is free()ed */\ntypedef void CRYPTO_EX_free (void *parent, void *ptr, CRYPTO_EX_DATA *ad,\n                             int idx, long argl, void *argp);\n/* Called when we need to dup an object */\ntypedef int CRYPTO_EX_dup (CRYPTO_EX_DATA *to, CRYPTO_EX_DATA *from,\n                           void *from_d, int idx, long argl, void *argp);\n# endif\n\n/* A generic structure to pass assorted data in a expandable way */\ntypedef struct openssl_item_st {\n    int code;\n    void *value;                /* Not used for flag attributes */\n    size_t value_size;          /* Max size of value for output, length for\n                                 * input */\n    size_t *value_length;       /* Returned length of value for output */\n} OPENSSL_ITEM;\n\n/*\n * When changing the CRYPTO_LOCK_* list, be sure to maintin the text lock\n * names in cryptlib.c\n */\n\n# define CRYPTO_LOCK_ERR                 1\n# define CRYPTO_LOCK_EX_DATA             2\n# define CRYPTO_LOCK_X509                3\n# define CRYPTO_LOCK_X509_INFO           4\n# define CRYPTO_LOCK_X509_PKEY           5\n# define CRYPTO_LOCK_X509_CRL            6\n# define CRYPTO_LOCK_X509_REQ            7\n# define CRYPTO_LOCK_DSA                 8\n# define CRYPTO_LOCK_RSA                 9\n# define CRYPTO_LOCK_EVP_PKEY            10\n# define CRYPTO_LOCK_X509_STORE          11\n# define CRYPTO_LOCK_SSL_CTX             12\n# define CRYPTO_LOCK_SSL_CERT            13\n# define CRYPTO_LOCK_SSL_SESSION         14\n# define CRYPTO_LOCK_SSL_SESS_CERT       15\n# define CRYPTO_LOCK_SSL                 16\n# define CRYPTO_LOCK_SSL_METHOD          17\n# define CRYPTO_LOCK_RAND                18\n# define CRYPTO_LOCK_RAND2               19\n# define CRYPTO_LOCK_MALLOC              20\n# define CRYPTO_LOCK_BIO                 21\n# define CRYPTO_LOCK_GETHOSTBYNAME       22\n# define CRYPTO_LOCK_GETSERVBYNAME       23\n# define CRYPTO_LOCK_READDIR             24\n# define CRYPTO_LOCK_RSA_BLINDING        25\n# define CRYPTO_LOCK_DH                  26\n# define CRYPTO_LOCK_MALLOC2             27\n# define CRYPTO_LOCK_DSO                 28\n# define CRYPTO_LOCK_DYNLOCK             29\n# define CRYPTO_LOCK_ENGINE              30\n# define CRYPTO_LOCK_UI                  31\n# define CRYPTO_LOCK_ECDSA               32\n# define CRYPTO_LOCK_EC                  33\n# define CRYPTO_LOCK_ECDH                34\n# define CRYPTO_LOCK_BN                  35\n# define CRYPTO_LOCK_EC_PRE_COMP         36\n# define CRYPTO_LOCK_STORE               37\n# define CRYPTO_LOCK_COMP                38\n# define CRYPTO_LOCK_FIPS                39\n# define CRYPTO_LOCK_FIPS2               40\n# define CRYPTO_NUM_LOCKS                41\n\n# define CRYPTO_LOCK             1\n# define CRYPTO_UNLOCK           2\n# define CRYPTO_READ             4\n# define CRYPTO_WRITE            8\n\n# ifndef OPENSSL_NO_LOCKING\n#  ifndef CRYPTO_w_lock\n#   define CRYPTO_w_lock(type)     \\\n        CRYPTO_lock(CRYPTO_LOCK|CRYPTO_WRITE,type,__FILE__,__LINE__)\n#   define CRYPTO_w_unlock(type)   \\\n        CRYPTO_lock(CRYPTO_UNLOCK|CRYPTO_WRITE,type,__FILE__,__LINE__)\n#   define CRYPTO_r_lock(type)     \\\n        CRYPTO_lock(CRYPTO_LOCK|CRYPTO_READ,type,__FILE__,__LINE__)\n#   define CRYPTO_r_unlock(type)   \\\n        CRYPTO_lock(CRYPTO_UNLOCK|CRYPTO_READ,type,__FILE__,__LINE__)\n#   define CRYPTO_add(addr,amount,type)    \\\n        CRYPTO_add_lock(addr,amount,type,__FILE__,__LINE__)\n#  endif\n# else\n#  define CRYPTO_w_lock(a)\n#  define CRYPTO_w_unlock(a)\n#  define CRYPTO_r_lock(a)\n#  define CRYPTO_r_unlock(a)\n#  define CRYPTO_add(a,b,c)       ((*(a))+=(b))\n# endif\n\n/*\n * Some applications as well as some parts of OpenSSL need to allocate and\n * deallocate locks in a dynamic fashion.  The following typedef makes this\n * possible in a type-safe manner.\n */\n/* struct CRYPTO_dynlock_value has to be defined by the application. */\ntypedef struct {\n    int references;\n    struct CRYPTO_dynlock_value *data;\n} CRYPTO_dynlock;\n\n/*\n * The following can be used to detect memory leaks in the SSLeay library. It\n * used, it turns on malloc checking\n */\n\n# define CRYPTO_MEM_CHECK_OFF    0x0/* an enume */\n# define CRYPTO_MEM_CHECK_ON     0x1/* a bit */\n# define CRYPTO_MEM_CHECK_ENABLE 0x2/* a bit */\n# define CRYPTO_MEM_CHECK_DISABLE 0x3/* an enume */\n\n/*\n * The following are bit values to turn on or off options connected to the\n * malloc checking functionality\n */\n\n/* Adds time to the memory checking information */\n# define V_CRYPTO_MDEBUG_TIME    0x1/* a bit */\n/* Adds thread number to the memory checking information */\n# define V_CRYPTO_MDEBUG_THREAD  0x2/* a bit */\n\n# define V_CRYPTO_MDEBUG_ALL (V_CRYPTO_MDEBUG_TIME | V_CRYPTO_MDEBUG_THREAD)\n\n/* predec of the BIO type */\ntypedef struct bio_st BIO_dummy;\n\nstruct crypto_ex_data_st {\n    STACK_OF(void) *sk;\n    /* gcc is screwing up this data structure :-( */\n    int dummy;\n};\nDECLARE_STACK_OF(void)\n\n/*\n * This stuff is basically class callback functions The current classes are\n * SSL_CTX, SSL, SSL_SESSION, and a few more\n */\n\ntypedef struct crypto_ex_data_func_st {\n    long argl;                  /* Arbitary long */\n    void *argp;                 /* Arbitary void * */\n    CRYPTO_EX_new *new_func;\n    CRYPTO_EX_free *free_func;\n    CRYPTO_EX_dup *dup_func;\n} CRYPTO_EX_DATA_FUNCS;\n\nDECLARE_STACK_OF(CRYPTO_EX_DATA_FUNCS)\n\n/*\n * Per class, we have a STACK of CRYPTO_EX_DATA_FUNCS for each CRYPTO_EX_DATA\n * entry.\n */\n\n# define CRYPTO_EX_INDEX_BIO             0\n# define CRYPTO_EX_INDEX_SSL             1\n# define CRYPTO_EX_INDEX_SSL_CTX         2\n# define CRYPTO_EX_INDEX_SSL_SESSION     3\n# define CRYPTO_EX_INDEX_X509_STORE      4\n# define CRYPTO_EX_INDEX_X509_STORE_CTX  5\n# define CRYPTO_EX_INDEX_RSA             6\n# define CRYPTO_EX_INDEX_DSA             7\n# define CRYPTO_EX_INDEX_DH              8\n# define CRYPTO_EX_INDEX_ENGINE          9\n# define CRYPTO_EX_INDEX_X509            10\n# define CRYPTO_EX_INDEX_UI              11\n# define CRYPTO_EX_INDEX_ECDSA           12\n# define CRYPTO_EX_INDEX_ECDH            13\n# define CRYPTO_EX_INDEX_COMP            14\n# define CRYPTO_EX_INDEX_STORE           15\n\n/*\n * Dynamically assigned indexes start from this value (don't use directly,\n * use via CRYPTO_ex_data_new_class).\n */\n# define CRYPTO_EX_INDEX_USER            100\n\n/*\n * This is the default callbacks, but we can have others as well: this is\n * needed in Win32 where the application malloc and the library malloc may\n * not be the same.\n */\n# define CRYPTO_malloc_init()    CRYPTO_set_mem_functions(\\\n        malloc, realloc, free)\n\n# if defined CRYPTO_MDEBUG_ALL || defined CRYPTO_MDEBUG_TIME || defined CRYPTO_MDEBUG_THREAD\n#  ifndef CRYPTO_MDEBUG         /* avoid duplicate #define */\n#   define CRYPTO_MDEBUG\n#  endif\n# endif\n\n/*\n * Set standard debugging functions (not done by default unless CRYPTO_MDEBUG\n * is defined)\n */\n# define CRYPTO_malloc_debug_init()      do {\\\n        CRYPTO_set_mem_debug_functions(\\\n                CRYPTO_dbg_malloc,\\\n                CRYPTO_dbg_realloc,\\\n                CRYPTO_dbg_free,\\\n                CRYPTO_dbg_set_options,\\\n                CRYPTO_dbg_get_options);\\\n        } while(0)\n\nint CRYPTO_mem_ctrl(int mode);\nint CRYPTO_is_mem_check_on(void);\n\n/* for applications */\n# define MemCheck_start() CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON)\n# define MemCheck_stop() CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_OFF)\n\n/* for library-internal use */\n# define MemCheck_on()   CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ENABLE)\n# define MemCheck_off()  CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_DISABLE)\n# define is_MemCheck_on() CRYPTO_is_mem_check_on()\n\n# define OPENSSL_malloc(num)     CRYPTO_malloc((int)num,__FILE__,__LINE__)\n# define OPENSSL_strdup(str)     CRYPTO_strdup((str),__FILE__,__LINE__)\n# define OPENSSL_realloc(addr,num) \\\n        CRYPTO_realloc((char *)addr,(int)num,__FILE__,__LINE__)\n# define OPENSSL_realloc_clean(addr,old_num,num) \\\n        CRYPTO_realloc_clean(addr,old_num,num,__FILE__,__LINE__)\n# define OPENSSL_remalloc(addr,num) \\\n        CRYPTO_remalloc((char **)addr,(int)num,__FILE__,__LINE__)\n# define OPENSSL_freeFunc        CRYPTO_free\n# define OPENSSL_free(addr)      CRYPTO_free(addr)\n\n# define OPENSSL_malloc_locked(num) \\\n        CRYPTO_malloc_locked((int)num,__FILE__,__LINE__)\n# define OPENSSL_free_locked(addr) CRYPTO_free_locked(addr)\n\nconst char *SSLeay_version(int type);\nunsigned long SSLeay(void);\n\nint OPENSSL_issetugid(void);\n\n/* An opaque type representing an implementation of \"ex_data\" support */\ntypedef struct st_CRYPTO_EX_DATA_IMPL CRYPTO_EX_DATA_IMPL;\n/* Return an opaque pointer to the current \"ex_data\" implementation */\nconst CRYPTO_EX_DATA_IMPL *CRYPTO_get_ex_data_implementation(void);\n/* Sets the \"ex_data\" implementation to be used (if it's not too late) */\nint CRYPTO_set_ex_data_implementation(const CRYPTO_EX_DATA_IMPL *i);\n/* Get a new \"ex_data\" class, and return the corresponding \"class_index\" */\nint CRYPTO_ex_data_new_class(void);\n/* Within a given class, get/register a new index */\nint CRYPTO_get_ex_new_index(int class_index, long argl, void *argp,\n                            CRYPTO_EX_new *new_func, CRYPTO_EX_dup *dup_func,\n                            CRYPTO_EX_free *free_func);\n/*\n * Initialise/duplicate/free CRYPTO_EX_DATA variables corresponding to a\n * given class (invokes whatever per-class callbacks are applicable)\n */\nint CRYPTO_new_ex_data(int class_index, void *obj, CRYPTO_EX_DATA *ad);\nint CRYPTO_dup_ex_data(int class_index, CRYPTO_EX_DATA *to,\n                       CRYPTO_EX_DATA *from);\nvoid CRYPTO_free_ex_data(int class_index, void *obj, CRYPTO_EX_DATA *ad);\n/*\n * Get/set data in a CRYPTO_EX_DATA variable corresponding to a particular\n * index (relative to the class type involved)\n */\nint CRYPTO_set_ex_data(CRYPTO_EX_DATA *ad, int idx, void *val);\nvoid *CRYPTO_get_ex_data(const CRYPTO_EX_DATA *ad, int idx);\n/*\n * This function cleans up all \"ex_data\" state. It mustn't be called under\n * potential race-conditions.\n */\nvoid CRYPTO_cleanup_all_ex_data(void);\n\nint CRYPTO_get_new_lockid(char *name);\n\nint CRYPTO_num_locks(void);     /* return CRYPTO_NUM_LOCKS (shared libs!) */\nvoid CRYPTO_lock(int mode, int type, const char *file, int line);\nvoid CRYPTO_set_locking_callback(void (*func) (int mode, int type,\n                                               const char *file, int line));\nvoid (*CRYPTO_get_locking_callback(void)) (int mode, int type,\n                                           const char *file, int line);\nvoid CRYPTO_set_add_lock_callback(int (*func)\n                                   (int *num, int mount, int type,\n                                    const char *file, int line));\nint (*CRYPTO_get_add_lock_callback(void)) (int *num, int mount, int type,\n                                           const char *file, int line);\n\n/* Don't use this structure directly. */\ntypedef struct crypto_threadid_st {\n    void *ptr;\n    unsigned long val;\n} CRYPTO_THREADID;\n/* Only use CRYPTO_THREADID_set_[numeric|pointer]() within callbacks */\nvoid CRYPTO_THREADID_set_numeric(CRYPTO_THREADID *id, unsigned long val);\nvoid CRYPTO_THREADID_set_pointer(CRYPTO_THREADID *id, void *ptr);\nint CRYPTO_THREADID_set_callback(void (*threadid_func) (CRYPTO_THREADID *));\nvoid (*CRYPTO_THREADID_get_callback(void)) (CRYPTO_THREADID *);\nvoid CRYPTO_THREADID_current(CRYPTO_THREADID *id);\nint CRYPTO_THREADID_cmp(const CRYPTO_THREADID *a, const CRYPTO_THREADID *b);\nvoid CRYPTO_THREADID_cpy(CRYPTO_THREADID *dest, const CRYPTO_THREADID *src);\nunsigned long CRYPTO_THREADID_hash(const CRYPTO_THREADID *id);\n# ifndef OPENSSL_NO_DEPRECATED\nvoid CRYPTO_set_id_callback(unsigned long (*func) (void));\nunsigned long (*CRYPTO_get_id_callback(void)) (void);\nunsigned long CRYPTO_thread_id(void);\n# endif\n\nconst char *CRYPTO_get_lock_name(int type);\nint CRYPTO_add_lock(int *pointer, int amount, int type, const char *file,\n                    int line);\n\nint CRYPTO_get_new_dynlockid(void);\nvoid CRYPTO_destroy_dynlockid(int i);\nstruct CRYPTO_dynlock_value *CRYPTO_get_dynlock_value(int i);\nvoid CRYPTO_set_dynlock_create_callback(struct CRYPTO_dynlock_value\n                                        *(*dyn_create_function) (const char\n                                                                 *file,\n                                                                 int line));\nvoid CRYPTO_set_dynlock_lock_callback(void (*dyn_lock_function)\n                                       (int mode,\n                                        struct CRYPTO_dynlock_value *l,\n                                        const char *file, int line));\nvoid CRYPTO_set_dynlock_destroy_callback(void (*dyn_destroy_function)\n                                          (struct CRYPTO_dynlock_value *l,\n                                           const char *file, int line));\nstruct CRYPTO_dynlock_value\n*(*CRYPTO_get_dynlock_create_callback(void)) (const char *file, int line);\nvoid (*CRYPTO_get_dynlock_lock_callback(void)) (int mode,\n                                                struct CRYPTO_dynlock_value\n                                                *l, const char *file,\n                                                int line);\nvoid (*CRYPTO_get_dynlock_destroy_callback(void)) (struct CRYPTO_dynlock_value\n                                                   *l, const char *file,\n                                                   int line);\n\n/*\n * CRYPTO_set_mem_functions includes CRYPTO_set_locked_mem_functions -- call\n * the latter last if you need different functions\n */\nint CRYPTO_set_mem_functions(void *(*m) (size_t), void *(*r) (void *, size_t),\n                             void (*f) (void *));\nint CRYPTO_set_locked_mem_functions(void *(*m) (size_t),\n                                    void (*free_func) (void *));\nint CRYPTO_set_mem_ex_functions(void *(*m) (size_t, const char *, int),\n                                void *(*r) (void *, size_t, const char *,\n                                            int), void (*f) (void *));\nint CRYPTO_set_locked_mem_ex_functions(void *(*m) (size_t, const char *, int),\n                                       void (*free_func) (void *));\nint CRYPTO_set_mem_debug_functions(void (*m)\n                                    (void *, int, const char *, int, int),\n                                   void (*r) (void *, void *, int,\n                                              const char *, int, int),\n                                   void (*f) (void *, int), void (*so) (long),\n                                   long (*go) (void));\nvoid CRYPTO_get_mem_functions(void *(**m) (size_t),\n                              void *(**r) (void *, size_t),\n                              void (**f) (void *));\nvoid CRYPTO_get_locked_mem_functions(void *(**m) (size_t),\n                                     void (**f) (void *));\nvoid CRYPTO_get_mem_ex_functions(void *(**m) (size_t, const char *, int),\n                                 void *(**r) (void *, size_t, const char *,\n                                              int), void (**f) (void *));\nvoid CRYPTO_get_locked_mem_ex_functions(void\n                                        *(**m) (size_t, const char *, int),\n                                        void (**f) (void *));\nvoid CRYPTO_get_mem_debug_functions(void (**m)\n                                     (void *, int, const char *, int, int),\n                                    void (**r) (void *, void *, int,\n                                                const char *, int, int),\n                                    void (**f) (void *, int),\n                                    void (**so) (long), long (**go) (void));\n\nvoid *CRYPTO_malloc_locked(int num, const char *file, int line);\nvoid CRYPTO_free_locked(void *ptr);\nvoid *CRYPTO_malloc(int num, const char *file, int line);\nchar *CRYPTO_strdup(const char *str, const char *file, int line);\nvoid CRYPTO_free(void *ptr);\nvoid *CRYPTO_realloc(void *addr, int num, const char *file, int line);\nvoid *CRYPTO_realloc_clean(void *addr, int old_num, int num, const char *file,\n                           int line);\nvoid *CRYPTO_remalloc(void *addr, int num, const char *file, int line);\n\nvoid OPENSSL_cleanse(void *ptr, size_t len);\n\nvoid CRYPTO_set_mem_debug_options(long bits);\nlong CRYPTO_get_mem_debug_options(void);\n\n# define CRYPTO_push_info(info) \\\n        CRYPTO_push_info_(info, __FILE__, __LINE__);\nint CRYPTO_push_info_(const char *info, const char *file, int line);\nint CRYPTO_pop_info(void);\nint CRYPTO_remove_all_info(void);\n\n/*\n * Default debugging functions (enabled by CRYPTO_malloc_debug_init() macro;\n * used as default in CRYPTO_MDEBUG compilations):\n */\n/*-\n * The last argument has the following significance:\n *\n * 0:   called before the actual memory allocation has taken place\n * 1:   called after the actual memory allocation has taken place\n */\nvoid CRYPTO_dbg_malloc(void *addr, int num, const char *file, int line,\n                       int before_p);\nvoid CRYPTO_dbg_realloc(void *addr1, void *addr2, int num, const char *file,\n                        int line, int before_p);\nvoid CRYPTO_dbg_free(void *addr, int before_p);\n/*-\n * Tell the debugging code about options.  By default, the following values\n * apply:\n *\n * 0:                           Clear all options.\n * V_CRYPTO_MDEBUG_TIME (1):    Set the \"Show Time\" option.\n * V_CRYPTO_MDEBUG_THREAD (2):  Set the \"Show Thread Number\" option.\n * V_CRYPTO_MDEBUG_ALL (3):     1 + 2\n */\nvoid CRYPTO_dbg_set_options(long bits);\nlong CRYPTO_dbg_get_options(void);\n\n# ifndef OPENSSL_NO_FP_API\nvoid CRYPTO_mem_leaks_fp(FILE *);\n# endif\nvoid CRYPTO_mem_leaks(struct bio_st *bio);\n/* unsigned long order, char *file, int line, int num_bytes, char *addr */\ntypedef void *CRYPTO_MEM_LEAK_CB (unsigned long, const char *, int, int,\n                                  void *);\nvoid CRYPTO_mem_leaks_cb(CRYPTO_MEM_LEAK_CB *cb);\n\n/* die if we have to */\nvoid OpenSSLDie(const char *file, int line, const char *assertion);\n# define OPENSSL_assert(e)       (void)((e) ? 0 : (OpenSSLDie(__FILE__, __LINE__, #e),1))\n\nunsigned long *OPENSSL_ia32cap_loc(void);\n# define OPENSSL_ia32cap (*(OPENSSL_ia32cap_loc()))\nint OPENSSL_isservice(void);\n\nint FIPS_mode(void);\nint FIPS_mode_set(int r);\n\nvoid OPENSSL_init(void);\n\n# define fips_md_init(alg) fips_md_init_ctx(alg, alg)\n\n# ifdef OPENSSL_FIPS\n#  define fips_md_init_ctx(alg, cx) \\\n        int alg##_Init(cx##_CTX *c) \\\n        { \\\n        if (FIPS_mode()) OpenSSLDie(__FILE__, __LINE__, \\\n                \"Low level API call to digest \" #alg \" forbidden in FIPS mode!\"); \\\n        return private_##alg##_Init(c); \\\n        } \\\n        int private_##alg##_Init(cx##_CTX *c)\n\n#  define fips_cipher_abort(alg) \\\n        if (FIPS_mode()) OpenSSLDie(__FILE__, __LINE__, \\\n                \"Low level API call to cipher \" #alg \" forbidden in FIPS mode!\")\n\n# else\n#  define fips_md_init_ctx(alg, cx) \\\n        int alg##_Init(cx##_CTX *c)\n#  define fips_cipher_abort(alg) while(0)\n# endif\n\n/*\n * CRYPTO_memcmp returns zero iff the |len| bytes at |a| and |b| are equal.\n * It takes an amount of time dependent on |len|, but independent of the\n * contents of |a| and |b|. Unlike memcmp, it cannot be used to put elements\n * into a defined order as the return value when a != b is undefined, other\n * than to be non-zero.\n */\nint CRYPTO_memcmp(const volatile void *a, const volatile void *b, size_t len);\n\n/* BEGIN ERROR CODES */\n/*\n * The following lines are auto generated by the script mkerr.pl. Any changes\n * made after this point may be overwritten when the script is next run.\n */\nvoid ERR_load_CRYPTO_strings(void);\n\n/* Error codes for the CRYPTO functions. */\n\n/* Function codes. */\n# define CRYPTO_F_CRYPTO_GET_EX_NEW_INDEX                 100\n# define CRYPTO_F_CRYPTO_GET_NEW_DYNLOCKID                103\n# define CRYPTO_F_CRYPTO_GET_NEW_LOCKID                   101\n# define CRYPTO_F_CRYPTO_SET_EX_DATA                      102\n# define CRYPTO_F_DEF_ADD_INDEX                           104\n# define CRYPTO_F_DEF_GET_CLASS                           105\n# define CRYPTO_F_FIPS_MODE_SET                           109\n# define CRYPTO_F_INT_DUP_EX_DATA                         106\n# define CRYPTO_F_INT_FREE_EX_DATA                        107\n# define CRYPTO_F_INT_NEW_EX_DATA                         108\n\n/* Reason codes. */\n# define CRYPTO_R_FIPS_MODE_NOT_SUPPORTED                 101\n# define CRYPTO_R_NO_DYNLOCK_CREATE_CALLBACK              100\n\n#ifdef  __cplusplus\n}\n#endif\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/x86/include/openssl/des.h",
    "content": "/* crypto/des/des.h */\n/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)\n * All rights reserved.\n *\n * This package is an SSL implementation written\n * by Eric Young (eay@cryptsoft.com).\n * The implementation was written so as to conform with Netscapes SSL.\n *\n * This library is free for commercial and non-commercial use as long as\n * the following conditions are aheared to.  The following conditions\n * apply to all code found in this distribution, be it the RC4, RSA,\n * lhash, DES, etc., code; not just the SSL code.  The SSL documentation\n * included with this distribution is covered by the same copyright terms\n * except that the holder is Tim Hudson (tjh@cryptsoft.com).\n *\n * Copyright remains Eric Young's, and as such any Copyright notices in\n * the code are not to be removed.\n * If this package is used in a product, Eric Young should be given attribution\n * as the author of the parts of the library used.\n * This can be in the form of a textual message at program startup or\n * in documentation (online or textual) provided with the package.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the copyright\n *    notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in the\n *    documentation and/or other materials provided with the distribution.\n * 3. All advertising materials mentioning features or use of this software\n *    must display the following acknowledgement:\n *    \"This product includes cryptographic software written by\n *     Eric Young (eay@cryptsoft.com)\"\n *    The word 'cryptographic' can be left out if the rouines from the library\n *    being used are not cryptographic related :-).\n * 4. If you include any Windows specific code (or a derivative thereof) from\n *    the apps directory (application code) you must include an acknowledgement:\n *    \"This product includes software written by Tim Hudson (tjh@cryptsoft.com)\"\n *\n * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n * SUCH DAMAGE.\n *\n * The licence and distribution terms for any publically available version or\n * derivative of this code cannot be changed.  i.e. this code cannot simply be\n * copied and put under another distribution licence\n * [including the GNU Public Licence.]\n */\n\n#ifndef HEADER_NEW_DES_H\n# define HEADER_NEW_DES_H\n\n# include <openssl/e_os2.h>     /* OPENSSL_EXTERN, OPENSSL_NO_DES, DES_LONG\n                                 * (via openssl/opensslconf.h */\n\n# ifdef OPENSSL_NO_DES\n#  error DES is disabled.\n# endif\n\n# ifdef OPENSSL_BUILD_SHLIBCRYPTO\n#  undef OPENSSL_EXTERN\n#  define OPENSSL_EXTERN OPENSSL_EXPORT\n# endif\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\ntypedef unsigned char DES_cblock[8];\ntypedef /* const */ unsigned char const_DES_cblock[8];\n/*\n * With \"const\", gcc 2.8.1 on Solaris thinks that DES_cblock * and\n * const_DES_cblock * are incompatible pointer types.\n */\n\ntypedef struct DES_ks {\n    union {\n        DES_cblock cblock;\n        /*\n         * make sure things are correct size on machines with 8 byte longs\n         */\n        DES_LONG deslong[2];\n    } ks[16];\n} DES_key_schedule;\n\n# ifndef OPENSSL_DISABLE_OLD_DES_SUPPORT\n#  ifndef OPENSSL_ENABLE_OLD_DES_SUPPORT\n#   define OPENSSL_ENABLE_OLD_DES_SUPPORT\n#  endif\n# endif\n\n# ifdef OPENSSL_ENABLE_OLD_DES_SUPPORT\n#  include <openssl/des_old.h>\n# endif\n\n# define DES_KEY_SZ      (sizeof(DES_cblock))\n# define DES_SCHEDULE_SZ (sizeof(DES_key_schedule))\n\n# define DES_ENCRYPT     1\n# define DES_DECRYPT     0\n\n# define DES_CBC_MODE    0\n# define DES_PCBC_MODE   1\n\n# define DES_ecb2_encrypt(i,o,k1,k2,e) \\\n        DES_ecb3_encrypt((i),(o),(k1),(k2),(k1),(e))\n\n# define DES_ede2_cbc_encrypt(i,o,l,k1,k2,iv,e) \\\n        DES_ede3_cbc_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(e))\n\n# define DES_ede2_cfb64_encrypt(i,o,l,k1,k2,iv,n,e) \\\n        DES_ede3_cfb64_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(n),(e))\n\n# define DES_ede2_ofb64_encrypt(i,o,l,k1,k2,iv,n) \\\n        DES_ede3_ofb64_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(n))\n\nOPENSSL_DECLARE_GLOBAL(int, DES_check_key); /* defaults to false */\n# define DES_check_key OPENSSL_GLOBAL_REF(DES_check_key)\nOPENSSL_DECLARE_GLOBAL(int, DES_rw_mode); /* defaults to DES_PCBC_MODE */\n# define DES_rw_mode OPENSSL_GLOBAL_REF(DES_rw_mode)\n\nconst char *DES_options(void);\nvoid DES_ecb3_encrypt(const_DES_cblock *input, DES_cblock *output,\n                      DES_key_schedule *ks1, DES_key_schedule *ks2,\n                      DES_key_schedule *ks3, int enc);\nDES_LONG DES_cbc_cksum(const unsigned char *input, DES_cblock *output,\n                       long length, DES_key_schedule *schedule,\n                       const_DES_cblock *ivec);\n/* DES_cbc_encrypt does not update the IV!  Use DES_ncbc_encrypt instead. */\nvoid DES_cbc_encrypt(const unsigned char *input, unsigned char *output,\n                     long length, DES_key_schedule *schedule,\n                     DES_cblock *ivec, int enc);\nvoid DES_ncbc_encrypt(const unsigned char *input, unsigned char *output,\n                      long length, DES_key_schedule *schedule,\n                      DES_cblock *ivec, int enc);\nvoid DES_xcbc_encrypt(const unsigned char *input, unsigned char *output,\n                      long length, DES_key_schedule *schedule,\n                      DES_cblock *ivec, const_DES_cblock *inw,\n                      const_DES_cblock *outw, int enc);\nvoid DES_cfb_encrypt(const unsigned char *in, unsigned char *out, int numbits,\n                     long length, DES_key_schedule *schedule,\n                     DES_cblock *ivec, int enc);\nvoid DES_ecb_encrypt(const_DES_cblock *input, DES_cblock *output,\n                     DES_key_schedule *ks, int enc);\n\n/*\n * This is the DES encryption function that gets called by just about every\n * other DES routine in the library.  You should not use this function except\n * to implement 'modes' of DES.  I say this because the functions that call\n * this routine do the conversion from 'char *' to long, and this needs to be\n * done to make sure 'non-aligned' memory access do not occur.  The\n * characters are loaded 'little endian'. Data is a pointer to 2 unsigned\n * long's and ks is the DES_key_schedule to use.  enc, is non zero specifies\n * encryption, zero if decryption.\n */\nvoid DES_encrypt1(DES_LONG *data, DES_key_schedule *ks, int enc);\n\n/*\n * This functions is the same as DES_encrypt1() except that the DES initial\n * permutation (IP) and final permutation (FP) have been left out.  As for\n * DES_encrypt1(), you should not use this function. It is used by the\n * routines in the library that implement triple DES. IP() DES_encrypt2()\n * DES_encrypt2() DES_encrypt2() FP() is the same as DES_encrypt1()\n * DES_encrypt1() DES_encrypt1() except faster :-).\n */\nvoid DES_encrypt2(DES_LONG *data, DES_key_schedule *ks, int enc);\n\nvoid DES_encrypt3(DES_LONG *data, DES_key_schedule *ks1,\n                  DES_key_schedule *ks2, DES_key_schedule *ks3);\nvoid DES_decrypt3(DES_LONG *data, DES_key_schedule *ks1,\n                  DES_key_schedule *ks2, DES_key_schedule *ks3);\nvoid DES_ede3_cbc_encrypt(const unsigned char *input, unsigned char *output,\n                          long length,\n                          DES_key_schedule *ks1, DES_key_schedule *ks2,\n                          DES_key_schedule *ks3, DES_cblock *ivec, int enc);\nvoid DES_ede3_cbcm_encrypt(const unsigned char *in, unsigned char *out,\n                           long length,\n                           DES_key_schedule *ks1, DES_key_schedule *ks2,\n                           DES_key_schedule *ks3,\n                           DES_cblock *ivec1, DES_cblock *ivec2, int enc);\nvoid DES_ede3_cfb64_encrypt(const unsigned char *in, unsigned char *out,\n                            long length, DES_key_schedule *ks1,\n                            DES_key_schedule *ks2, DES_key_schedule *ks3,\n                            DES_cblock *ivec, int *num, int enc);\nvoid DES_ede3_cfb_encrypt(const unsigned char *in, unsigned char *out,\n                          int numbits, long length, DES_key_schedule *ks1,\n                          DES_key_schedule *ks2, DES_key_schedule *ks3,\n                          DES_cblock *ivec, int enc);\nvoid DES_ede3_ofb64_encrypt(const unsigned char *in, unsigned char *out,\n                            long length, DES_key_schedule *ks1,\n                            DES_key_schedule *ks2, DES_key_schedule *ks3,\n                            DES_cblock *ivec, int *num);\n# if 0\nvoid DES_xwhite_in2out(const_DES_cblock *DES_key, const_DES_cblock *in_white,\n                       DES_cblock *out_white);\n# endif\n\nint DES_enc_read(int fd, void *buf, int len, DES_key_schedule *sched,\n                 DES_cblock *iv);\nint DES_enc_write(int fd, const void *buf, int len, DES_key_schedule *sched,\n                  DES_cblock *iv);\nchar *DES_fcrypt(const char *buf, const char *salt, char *ret);\nchar *DES_crypt(const char *buf, const char *salt);\nvoid DES_ofb_encrypt(const unsigned char *in, unsigned char *out, int numbits,\n                     long length, DES_key_schedule *schedule,\n                     DES_cblock *ivec);\nvoid DES_pcbc_encrypt(const unsigned char *input, unsigned char *output,\n                      long length, DES_key_schedule *schedule,\n                      DES_cblock *ivec, int enc);\nDES_LONG DES_quad_cksum(const unsigned char *input, DES_cblock output[],\n                        long length, int out_count, DES_cblock *seed);\nint DES_random_key(DES_cblock *ret);\nvoid DES_set_odd_parity(DES_cblock *key);\nint DES_check_key_parity(const_DES_cblock *key);\nint DES_is_weak_key(const_DES_cblock *key);\n/*\n * DES_set_key (= set_key = DES_key_sched = key_sched) calls\n * DES_set_key_checked if global variable DES_check_key is set,\n * DES_set_key_unchecked otherwise.\n */\nint DES_set_key(const_DES_cblock *key, DES_key_schedule *schedule);\nint DES_key_sched(const_DES_cblock *key, DES_key_schedule *schedule);\nint DES_set_key_checked(const_DES_cblock *key, DES_key_schedule *schedule);\nvoid DES_set_key_unchecked(const_DES_cblock *key, DES_key_schedule *schedule);\n# ifdef OPENSSL_FIPS\nvoid private_DES_set_key_unchecked(const_DES_cblock *key,\n                                   DES_key_schedule *schedule);\n# endif\nvoid DES_string_to_key(const char *str, DES_cblock *key);\nvoid DES_string_to_2keys(const char *str, DES_cblock *key1, DES_cblock *key2);\nvoid DES_cfb64_encrypt(const unsigned char *in, unsigned char *out,\n                       long length, DES_key_schedule *schedule,\n                       DES_cblock *ivec, int *num, int enc);\nvoid DES_ofb64_encrypt(const unsigned char *in, unsigned char *out,\n                       long length, DES_key_schedule *schedule,\n                       DES_cblock *ivec, int *num);\n\nint DES_read_password(DES_cblock *key, const char *prompt, int verify);\nint DES_read_2passwords(DES_cblock *key1, DES_cblock *key2,\n                        const char *prompt, int verify);\n\n# define DES_fixup_key_parity DES_set_odd_parity\n\n#ifdef  __cplusplus\n}\n#endif\n\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/x86/include/openssl/des_old.h",
    "content": "/* crypto/des/des_old.h */\n\n/*-\n * WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING\n *\n * The function names in here are deprecated and are only present to\n * provide an interface compatible with openssl 0.9.6 and older as\n * well as libdes.  OpenSSL now provides functions where \"des_\" has\n * been replaced with \"DES_\" in the names, to make it possible to\n * make incompatible changes that are needed for C type security and\n * other stuff.\n *\n * This include files has two compatibility modes:\n *\n *   - If OPENSSL_DES_LIBDES_COMPATIBILITY is defined, you get an API\n *     that is compatible with libdes and SSLeay.\n *   - If OPENSSL_DES_LIBDES_COMPATIBILITY isn't defined, you get an\n *     API that is compatible with OpenSSL 0.9.5x to 0.9.6x.\n *\n * Note that these modes break earlier snapshots of OpenSSL, where\n * libdes compatibility was the only available mode or (later on) the\n * prefered compatibility mode.  However, after much consideration\n * (and more or less violent discussions with external parties), it\n * was concluded that OpenSSL should be compatible with earlier versions\n * of itself before anything else.  Also, in all honesty, libdes is\n * an old beast that shouldn't really be used any more.\n *\n * Please consider starting to use the DES_ functions rather than the\n * des_ ones.  The des_ functions will disappear completely before\n * OpenSSL 1.0!\n *\n * WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING\n */\n\n/*\n * Written by Richard Levitte (richard@levitte.org) for the OpenSSL project\n * 2001.\n */\n/* ====================================================================\n * Copyright (c) 1998-2002 The OpenSSL Project.  All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n *\n * 1. Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n *\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in\n *    the documentation and/or other materials provided with the\n *    distribution.\n *\n * 3. All advertising materials mentioning features or use of this\n *    software must display the following acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit. (http://www.openssl.org/)\"\n *\n * 4. The names \"OpenSSL Toolkit\" and \"OpenSSL Project\" must not be used to\n *    endorse or promote products derived from this software without\n *    prior written permission. For written permission, please contact\n *    openssl-core@openssl.org.\n *\n * 5. Products derived from this software may not be called \"OpenSSL\"\n *    nor may \"OpenSSL\" appear in their names without prior written\n *    permission of the OpenSSL Project.\n *\n * 6. Redistributions of any form whatsoever must retain the following\n *    acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit (http://www.openssl.org/)\"\n *\n * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY\n * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\n * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR\n * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\n * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,\n * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED\n * OF THE POSSIBILITY OF SUCH DAMAGE.\n * ====================================================================\n *\n * This product includes cryptographic software written by Eric Young\n * (eay@cryptsoft.com).  This product includes software written by Tim\n * Hudson (tjh@cryptsoft.com).\n *\n */\n\n#ifndef HEADER_DES_H\n# define HEADER_DES_H\n\n# include <openssl/e_os2.h>     /* OPENSSL_EXTERN, OPENSSL_NO_DES, DES_LONG */\n\n# ifdef OPENSSL_NO_DES\n#  error DES is disabled.\n# endif\n\n# ifndef HEADER_NEW_DES_H\n#  error You must include des.h, not des_old.h directly.\n# endif\n\n# ifdef _KERBEROS_DES_H\n#  error <openssl/des_old.h> replaces <kerberos/des.h>.\n# endif\n\n# include <openssl/symhacks.h>\n\n# ifdef OPENSSL_BUILD_SHLIBCRYPTO\n#  undef OPENSSL_EXTERN\n#  define OPENSSL_EXTERN OPENSSL_EXPORT\n# endif\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n# ifdef _\n#  undef _\n# endif\n\ntypedef unsigned char _ossl_old_des_cblock[8];\ntypedef struct _ossl_old_des_ks_struct {\n    union {\n        _ossl_old_des_cblock _;\n        /*\n         * make sure things are correct size on machines with 8 byte longs\n         */\n        DES_LONG pad[2];\n    } ks;\n} _ossl_old_des_key_schedule[16];\n\n# ifndef OPENSSL_DES_LIBDES_COMPATIBILITY\n#  define des_cblock DES_cblock\n#  define const_des_cblock const_DES_cblock\n#  define des_key_schedule DES_key_schedule\n#  define des_ecb3_encrypt(i,o,k1,k2,k3,e)\\\n        DES_ecb3_encrypt((i),(o),&(k1),&(k2),&(k3),(e))\n#  define des_ede3_cbc_encrypt(i,o,l,k1,k2,k3,iv,e)\\\n        DES_ede3_cbc_encrypt((i),(o),(l),&(k1),&(k2),&(k3),(iv),(e))\n#  define des_ede3_cbcm_encrypt(i,o,l,k1,k2,k3,iv1,iv2,e)\\\n        DES_ede3_cbcm_encrypt((i),(o),(l),&(k1),&(k2),&(k3),(iv1),(iv2),(e))\n#  define des_ede3_cfb64_encrypt(i,o,l,k1,k2,k3,iv,n,e)\\\n        DES_ede3_cfb64_encrypt((i),(o),(l),&(k1),&(k2),&(k3),(iv),(n),(e))\n#  define des_ede3_ofb64_encrypt(i,o,l,k1,k2,k3,iv,n)\\\n        DES_ede3_ofb64_encrypt((i),(o),(l),&(k1),&(k2),&(k3),(iv),(n))\n#  define des_options()\\\n        DES_options()\n#  define des_cbc_cksum(i,o,l,k,iv)\\\n        DES_cbc_cksum((i),(o),(l),&(k),(iv))\n#  define des_cbc_encrypt(i,o,l,k,iv,e)\\\n        DES_cbc_encrypt((i),(o),(l),&(k),(iv),(e))\n#  define des_ncbc_encrypt(i,o,l,k,iv,e)\\\n        DES_ncbc_encrypt((i),(o),(l),&(k),(iv),(e))\n#  define des_xcbc_encrypt(i,o,l,k,iv,inw,outw,e)\\\n        DES_xcbc_encrypt((i),(o),(l),&(k),(iv),(inw),(outw),(e))\n#  define des_cfb_encrypt(i,o,n,l,k,iv,e)\\\n        DES_cfb_encrypt((i),(o),(n),(l),&(k),(iv),(e))\n#  define des_ecb_encrypt(i,o,k,e)\\\n        DES_ecb_encrypt((i),(o),&(k),(e))\n#  define des_encrypt1(d,k,e)\\\n        DES_encrypt1((d),&(k),(e))\n#  define des_encrypt2(d,k,e)\\\n        DES_encrypt2((d),&(k),(e))\n#  define des_encrypt3(d,k1,k2,k3)\\\n        DES_encrypt3((d),&(k1),&(k2),&(k3))\n#  define des_decrypt3(d,k1,k2,k3)\\\n        DES_decrypt3((d),&(k1),&(k2),&(k3))\n#  define des_xwhite_in2out(k,i,o)\\\n        DES_xwhite_in2out((k),(i),(o))\n#  define des_enc_read(f,b,l,k,iv)\\\n        DES_enc_read((f),(b),(l),&(k),(iv))\n#  define des_enc_write(f,b,l,k,iv)\\\n        DES_enc_write((f),(b),(l),&(k),(iv))\n#  define des_fcrypt(b,s,r)\\\n        DES_fcrypt((b),(s),(r))\n#  if 0\n#   define des_crypt(b,s)\\\n        DES_crypt((b),(s))\n#   if !defined(PERL5) && !defined(__FreeBSD__) && !defined(NeXT) && !defined(__OpenBSD__)\n#    define crypt(b,s)\\\n        DES_crypt((b),(s))\n#   endif\n#  endif\n#  define des_ofb_encrypt(i,o,n,l,k,iv)\\\n        DES_ofb_encrypt((i),(o),(n),(l),&(k),(iv))\n#  define des_pcbc_encrypt(i,o,l,k,iv,e)\\\n        DES_pcbc_encrypt((i),(o),(l),&(k),(iv),(e))\n#  define des_quad_cksum(i,o,l,c,s)\\\n        DES_quad_cksum((i),(o),(l),(c),(s))\n#  define des_random_seed(k)\\\n        _ossl_096_des_random_seed((k))\n#  define des_random_key(r)\\\n        DES_random_key((r))\n#  define des_read_password(k,p,v) \\\n        DES_read_password((k),(p),(v))\n#  define des_read_2passwords(k1,k2,p,v) \\\n        DES_read_2passwords((k1),(k2),(p),(v))\n#  define des_set_odd_parity(k)\\\n        DES_set_odd_parity((k))\n#  define des_check_key_parity(k)\\\n        DES_check_key_parity((k))\n#  define des_is_weak_key(k)\\\n        DES_is_weak_key((k))\n#  define des_set_key(k,ks)\\\n        DES_set_key((k),&(ks))\n#  define des_key_sched(k,ks)\\\n        DES_key_sched((k),&(ks))\n#  define des_set_key_checked(k,ks)\\\n        DES_set_key_checked((k),&(ks))\n#  define des_set_key_unchecked(k,ks)\\\n        DES_set_key_unchecked((k),&(ks))\n#  define des_string_to_key(s,k)\\\n        DES_string_to_key((s),(k))\n#  define des_string_to_2keys(s,k1,k2)\\\n        DES_string_to_2keys((s),(k1),(k2))\n#  define des_cfb64_encrypt(i,o,l,ks,iv,n,e)\\\n        DES_cfb64_encrypt((i),(o),(l),&(ks),(iv),(n),(e))\n#  define des_ofb64_encrypt(i,o,l,ks,iv,n)\\\n        DES_ofb64_encrypt((i),(o),(l),&(ks),(iv),(n))\n\n#  define des_ecb2_encrypt(i,o,k1,k2,e) \\\n        des_ecb3_encrypt((i),(o),(k1),(k2),(k1),(e))\n\n#  define des_ede2_cbc_encrypt(i,o,l,k1,k2,iv,e) \\\n        des_ede3_cbc_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(e))\n\n#  define des_ede2_cfb64_encrypt(i,o,l,k1,k2,iv,n,e) \\\n        des_ede3_cfb64_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(n),(e))\n\n#  define des_ede2_ofb64_encrypt(i,o,l,k1,k2,iv,n) \\\n        des_ede3_ofb64_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(n))\n\n#  define des_check_key DES_check_key\n#  define des_rw_mode DES_rw_mode\n# else                          /* libdes compatibility */\n/*\n * Map all symbol names to _ossl_old_des_* form, so we avoid all clashes with\n * libdes\n */\n#  define des_cblock _ossl_old_des_cblock\n#  define des_key_schedule _ossl_old_des_key_schedule\n#  define des_ecb3_encrypt(i,o,k1,k2,k3,e)\\\n        _ossl_old_des_ecb3_encrypt((i),(o),(k1),(k2),(k3),(e))\n#  define des_ede3_cbc_encrypt(i,o,l,k1,k2,k3,iv,e)\\\n        _ossl_old_des_ede3_cbc_encrypt((i),(o),(l),(k1),(k2),(k3),(iv),(e))\n#  define des_ede3_cfb64_encrypt(i,o,l,k1,k2,k3,iv,n,e)\\\n        _ossl_old_des_ede3_cfb64_encrypt((i),(o),(l),(k1),(k2),(k3),(iv),(n),(e))\n#  define des_ede3_ofb64_encrypt(i,o,l,k1,k2,k3,iv,n)\\\n        _ossl_old_des_ede3_ofb64_encrypt((i),(o),(l),(k1),(k2),(k3),(iv),(n))\n#  define des_options()\\\n        _ossl_old_des_options()\n#  define des_cbc_cksum(i,o,l,k,iv)\\\n        _ossl_old_des_cbc_cksum((i),(o),(l),(k),(iv))\n#  define des_cbc_encrypt(i,o,l,k,iv,e)\\\n        _ossl_old_des_cbc_encrypt((i),(o),(l),(k),(iv),(e))\n#  define des_ncbc_encrypt(i,o,l,k,iv,e)\\\n        _ossl_old_des_ncbc_encrypt((i),(o),(l),(k),(iv),(e))\n#  define des_xcbc_encrypt(i,o,l,k,iv,inw,outw,e)\\\n        _ossl_old_des_xcbc_encrypt((i),(o),(l),(k),(iv),(inw),(outw),(e))\n#  define des_cfb_encrypt(i,o,n,l,k,iv,e)\\\n        _ossl_old_des_cfb_encrypt((i),(o),(n),(l),(k),(iv),(e))\n#  define des_ecb_encrypt(i,o,k,e)\\\n        _ossl_old_des_ecb_encrypt((i),(o),(k),(e))\n#  define des_encrypt(d,k,e)\\\n        _ossl_old_des_encrypt((d),(k),(e))\n#  define des_encrypt2(d,k,e)\\\n        _ossl_old_des_encrypt2((d),(k),(e))\n#  define des_encrypt3(d,k1,k2,k3)\\\n        _ossl_old_des_encrypt3((d),(k1),(k2),(k3))\n#  define des_decrypt3(d,k1,k2,k3)\\\n        _ossl_old_des_decrypt3((d),(k1),(k2),(k3))\n#  define des_xwhite_in2out(k,i,o)\\\n        _ossl_old_des_xwhite_in2out((k),(i),(o))\n#  define des_enc_read(f,b,l,k,iv)\\\n        _ossl_old_des_enc_read((f),(b),(l),(k),(iv))\n#  define des_enc_write(f,b,l,k,iv)\\\n        _ossl_old_des_enc_write((f),(b),(l),(k),(iv))\n#  define des_fcrypt(b,s,r)\\\n        _ossl_old_des_fcrypt((b),(s),(r))\n#  define des_crypt(b,s)\\\n        _ossl_old_des_crypt((b),(s))\n#  if 0\n#   define crypt(b,s)\\\n        _ossl_old_crypt((b),(s))\n#  endif\n#  define des_ofb_encrypt(i,o,n,l,k,iv)\\\n        _ossl_old_des_ofb_encrypt((i),(o),(n),(l),(k),(iv))\n#  define des_pcbc_encrypt(i,o,l,k,iv,e)\\\n        _ossl_old_des_pcbc_encrypt((i),(o),(l),(k),(iv),(e))\n#  define des_quad_cksum(i,o,l,c,s)\\\n        _ossl_old_des_quad_cksum((i),(o),(l),(c),(s))\n#  define des_random_seed(k)\\\n        _ossl_old_des_random_seed((k))\n#  define des_random_key(r)\\\n        _ossl_old_des_random_key((r))\n#  define des_read_password(k,p,v) \\\n        _ossl_old_des_read_password((k),(p),(v))\n#  define des_read_2passwords(k1,k2,p,v) \\\n        _ossl_old_des_read_2passwords((k1),(k2),(p),(v))\n#  define des_set_odd_parity(k)\\\n        _ossl_old_des_set_odd_parity((k))\n#  define des_is_weak_key(k)\\\n        _ossl_old_des_is_weak_key((k))\n#  define des_set_key(k,ks)\\\n        _ossl_old_des_set_key((k),(ks))\n#  define des_key_sched(k,ks)\\\n        _ossl_old_des_key_sched((k),(ks))\n#  define des_string_to_key(s,k)\\\n        _ossl_old_des_string_to_key((s),(k))\n#  define des_string_to_2keys(s,k1,k2)\\\n        _ossl_old_des_string_to_2keys((s),(k1),(k2))\n#  define des_cfb64_encrypt(i,o,l,ks,iv,n,e)\\\n        _ossl_old_des_cfb64_encrypt((i),(o),(l),(ks),(iv),(n),(e))\n#  define des_ofb64_encrypt(i,o,l,ks,iv,n)\\\n        _ossl_old_des_ofb64_encrypt((i),(o),(l),(ks),(iv),(n))\n\n#  define des_ecb2_encrypt(i,o,k1,k2,e) \\\n        des_ecb3_encrypt((i),(o),(k1),(k2),(k1),(e))\n\n#  define des_ede2_cbc_encrypt(i,o,l,k1,k2,iv,e) \\\n        des_ede3_cbc_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(e))\n\n#  define des_ede2_cfb64_encrypt(i,o,l,k1,k2,iv,n,e) \\\n        des_ede3_cfb64_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(n),(e))\n\n#  define des_ede2_ofb64_encrypt(i,o,l,k1,k2,iv,n) \\\n        des_ede3_ofb64_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(n))\n\n#  define des_check_key DES_check_key\n#  define des_rw_mode DES_rw_mode\n# endif\n\nconst char *_ossl_old_des_options(void);\nvoid _ossl_old_des_ecb3_encrypt(_ossl_old_des_cblock *input,\n                                _ossl_old_des_cblock *output,\n                                _ossl_old_des_key_schedule ks1,\n                                _ossl_old_des_key_schedule ks2,\n                                _ossl_old_des_key_schedule ks3, int enc);\nDES_LONG _ossl_old_des_cbc_cksum(_ossl_old_des_cblock *input,\n                                 _ossl_old_des_cblock *output, long length,\n                                 _ossl_old_des_key_schedule schedule,\n                                 _ossl_old_des_cblock *ivec);\nvoid _ossl_old_des_cbc_encrypt(_ossl_old_des_cblock *input,\n                               _ossl_old_des_cblock *output, long length,\n                               _ossl_old_des_key_schedule schedule,\n                               _ossl_old_des_cblock *ivec, int enc);\nvoid _ossl_old_des_ncbc_encrypt(_ossl_old_des_cblock *input,\n                                _ossl_old_des_cblock *output, long length,\n                                _ossl_old_des_key_schedule schedule,\n                                _ossl_old_des_cblock *ivec, int enc);\nvoid _ossl_old_des_xcbc_encrypt(_ossl_old_des_cblock *input,\n                                _ossl_old_des_cblock *output, long length,\n                                _ossl_old_des_key_schedule schedule,\n                                _ossl_old_des_cblock *ivec,\n                                _ossl_old_des_cblock *inw,\n                                _ossl_old_des_cblock *outw, int enc);\nvoid _ossl_old_des_cfb_encrypt(unsigned char *in, unsigned char *out,\n                               int numbits, long length,\n                               _ossl_old_des_key_schedule schedule,\n                               _ossl_old_des_cblock *ivec, int enc);\nvoid _ossl_old_des_ecb_encrypt(_ossl_old_des_cblock *input,\n                               _ossl_old_des_cblock *output,\n                               _ossl_old_des_key_schedule ks, int enc);\nvoid _ossl_old_des_encrypt(DES_LONG *data, _ossl_old_des_key_schedule ks,\n                           int enc);\nvoid _ossl_old_des_encrypt2(DES_LONG *data, _ossl_old_des_key_schedule ks,\n                            int enc);\nvoid _ossl_old_des_encrypt3(DES_LONG *data, _ossl_old_des_key_schedule ks1,\n                            _ossl_old_des_key_schedule ks2,\n                            _ossl_old_des_key_schedule ks3);\nvoid _ossl_old_des_decrypt3(DES_LONG *data, _ossl_old_des_key_schedule ks1,\n                            _ossl_old_des_key_schedule ks2,\n                            _ossl_old_des_key_schedule ks3);\nvoid _ossl_old_des_ede3_cbc_encrypt(_ossl_old_des_cblock *input,\n                                    _ossl_old_des_cblock *output, long length,\n                                    _ossl_old_des_key_schedule ks1,\n                                    _ossl_old_des_key_schedule ks2,\n                                    _ossl_old_des_key_schedule ks3,\n                                    _ossl_old_des_cblock *ivec, int enc);\nvoid _ossl_old_des_ede3_cfb64_encrypt(unsigned char *in, unsigned char *out,\n                                      long length,\n                                      _ossl_old_des_key_schedule ks1,\n                                      _ossl_old_des_key_schedule ks2,\n                                      _ossl_old_des_key_schedule ks3,\n                                      _ossl_old_des_cblock *ivec, int *num,\n                                      int enc);\nvoid _ossl_old_des_ede3_ofb64_encrypt(unsigned char *in, unsigned char *out,\n                                      long length,\n                                      _ossl_old_des_key_schedule ks1,\n                                      _ossl_old_des_key_schedule ks2,\n                                      _ossl_old_des_key_schedule ks3,\n                                      _ossl_old_des_cblock *ivec, int *num);\n# if 0\nvoid _ossl_old_des_xwhite_in2out(_ossl_old_des_cblock (*des_key),\n                                 _ossl_old_des_cblock (*in_white),\n                                 _ossl_old_des_cblock (*out_white));\n# endif\n\nint _ossl_old_des_enc_read(int fd, char *buf, int len,\n                           _ossl_old_des_key_schedule sched,\n                           _ossl_old_des_cblock *iv);\nint _ossl_old_des_enc_write(int fd, char *buf, int len,\n                            _ossl_old_des_key_schedule sched,\n                            _ossl_old_des_cblock *iv);\nchar *_ossl_old_des_fcrypt(const char *buf, const char *salt, char *ret);\nchar *_ossl_old_des_crypt(const char *buf, const char *salt);\n# if !defined(PERL5) && !defined(NeXT)\nchar *_ossl_old_crypt(const char *buf, const char *salt);\n# endif\nvoid _ossl_old_des_ofb_encrypt(unsigned char *in, unsigned char *out,\n                               int numbits, long length,\n                               _ossl_old_des_key_schedule schedule,\n                               _ossl_old_des_cblock *ivec);\nvoid _ossl_old_des_pcbc_encrypt(_ossl_old_des_cblock *input,\n                                _ossl_old_des_cblock *output, long length,\n                                _ossl_old_des_key_schedule schedule,\n                                _ossl_old_des_cblock *ivec, int enc);\nDES_LONG _ossl_old_des_quad_cksum(_ossl_old_des_cblock *input,\n                                  _ossl_old_des_cblock *output, long length,\n                                  int out_count, _ossl_old_des_cblock *seed);\nvoid _ossl_old_des_random_seed(_ossl_old_des_cblock key);\nvoid _ossl_old_des_random_key(_ossl_old_des_cblock ret);\nint _ossl_old_des_read_password(_ossl_old_des_cblock *key, const char *prompt,\n                                int verify);\nint _ossl_old_des_read_2passwords(_ossl_old_des_cblock *key1,\n                                  _ossl_old_des_cblock *key2,\n                                  const char *prompt, int verify);\nvoid _ossl_old_des_set_odd_parity(_ossl_old_des_cblock *key);\nint _ossl_old_des_is_weak_key(_ossl_old_des_cblock *key);\nint _ossl_old_des_set_key(_ossl_old_des_cblock *key,\n                          _ossl_old_des_key_schedule schedule);\nint _ossl_old_des_key_sched(_ossl_old_des_cblock *key,\n                            _ossl_old_des_key_schedule schedule);\nvoid _ossl_old_des_string_to_key(char *str, _ossl_old_des_cblock *key);\nvoid _ossl_old_des_string_to_2keys(char *str, _ossl_old_des_cblock *key1,\n                                   _ossl_old_des_cblock *key2);\nvoid _ossl_old_des_cfb64_encrypt(unsigned char *in, unsigned char *out,\n                                 long length,\n                                 _ossl_old_des_key_schedule schedule,\n                                 _ossl_old_des_cblock *ivec, int *num,\n                                 int enc);\nvoid _ossl_old_des_ofb64_encrypt(unsigned char *in, unsigned char *out,\n                                 long length,\n                                 _ossl_old_des_key_schedule schedule,\n                                 _ossl_old_des_cblock *ivec, int *num);\n\nvoid _ossl_096_des_random_seed(des_cblock *key);\n\n/*\n * The following definitions provide compatibility with the MIT Kerberos\n * library. The _ossl_old_des_key_schedule structure is not binary\n * compatible.\n */\n\n# define _KERBEROS_DES_H\n\n# define KRBDES_ENCRYPT DES_ENCRYPT\n# define KRBDES_DECRYPT DES_DECRYPT\n\n# ifdef KERBEROS\n#  define ENCRYPT DES_ENCRYPT\n#  define DECRYPT DES_DECRYPT\n# endif\n\n# ifndef NCOMPAT\n#  define C_Block des_cblock\n#  define Key_schedule des_key_schedule\n#  define KEY_SZ DES_KEY_SZ\n#  define string_to_key des_string_to_key\n#  define read_pw_string des_read_pw_string\n#  define random_key des_random_key\n#  define pcbc_encrypt des_pcbc_encrypt\n#  define set_key des_set_key\n#  define key_sched des_key_sched\n#  define ecb_encrypt des_ecb_encrypt\n#  define cbc_encrypt des_cbc_encrypt\n#  define ncbc_encrypt des_ncbc_encrypt\n#  define xcbc_encrypt des_xcbc_encrypt\n#  define cbc_cksum des_cbc_cksum\n#  define quad_cksum des_quad_cksum\n#  define check_parity des_check_key_parity\n# endif\n\n# define des_fixup_key_parity DES_fixup_key_parity\n\n#ifdef  __cplusplus\n}\n#endif\n\n/* for DES_read_pw_string et al */\n# include <openssl/ui_compat.h>\n\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/x86/include/openssl/dh.h",
    "content": "/* crypto/dh/dh.h */\n/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)\n * All rights reserved.\n *\n * This package is an SSL implementation written\n * by Eric Young (eay@cryptsoft.com).\n * The implementation was written so as to conform with Netscapes SSL.\n *\n * This library is free for commercial and non-commercial use as long as\n * the following conditions are aheared to.  The following conditions\n * apply to all code found in this distribution, be it the RC4, RSA,\n * lhash, DES, etc., code; not just the SSL code.  The SSL documentation\n * included with this distribution is covered by the same copyright terms\n * except that the holder is Tim Hudson (tjh@cryptsoft.com).\n *\n * Copyright remains Eric Young's, and as such any Copyright notices in\n * the code are not to be removed.\n * If this package is used in a product, Eric Young should be given attribution\n * as the author of the parts of the library used.\n * This can be in the form of a textual message at program startup or\n * in documentation (online or textual) provided with the package.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the copyright\n *    notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in the\n *    documentation and/or other materials provided with the distribution.\n * 3. All advertising materials mentioning features or use of this software\n *    must display the following acknowledgement:\n *    \"This product includes cryptographic software written by\n *     Eric Young (eay@cryptsoft.com)\"\n *    The word 'cryptographic' can be left out if the rouines from the library\n *    being used are not cryptographic related :-).\n * 4. If you include any Windows specific code (or a derivative thereof) from\n *    the apps directory (application code) you must include an acknowledgement:\n *    \"This product includes software written by Tim Hudson (tjh@cryptsoft.com)\"\n *\n * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n * SUCH DAMAGE.\n *\n * The licence and distribution terms for any publically available version or\n * derivative of this code cannot be changed.  i.e. this code cannot simply be\n * copied and put under another distribution licence\n * [including the GNU Public Licence.]\n */\n\n#ifndef HEADER_DH_H\n# define HEADER_DH_H\n\n# include <openssl/e_os2.h>\n\n# ifdef OPENSSL_NO_DH\n#  error DH is disabled.\n# endif\n\n# ifndef OPENSSL_NO_BIO\n#  include <openssl/bio.h>\n# endif\n# include <openssl/ossl_typ.h>\n# ifndef OPENSSL_NO_DEPRECATED\n#  include <openssl/bn.h>\n# endif\n\n# ifndef OPENSSL_DH_MAX_MODULUS_BITS\n#  define OPENSSL_DH_MAX_MODULUS_BITS    10000\n# endif\n\n# define DH_FLAG_CACHE_MONT_P     0x01\n\n/*\n * new with 0.9.7h; the built-in DH\n * implementation now uses constant time\n * modular exponentiation for secret exponents\n * by default. This flag causes the\n * faster variable sliding window method to\n * be used for all exponents.\n */\n# define DH_FLAG_NO_EXP_CONSTTIME 0x02\n\n/*\n * If this flag is set the DH method is FIPS compliant and can be used in\n * FIPS mode. This is set in the validated module method. If an application\n * sets this flag in its own methods it is its reposibility to ensure the\n * result is compliant.\n */\n\n# define DH_FLAG_FIPS_METHOD                     0x0400\n\n/*\n * If this flag is set the operations normally disabled in FIPS mode are\n * permitted it is then the applications responsibility to ensure that the\n * usage is compliant.\n */\n\n# define DH_FLAG_NON_FIPS_ALLOW                  0x0400\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n/* Already defined in ossl_typ.h */\n/* typedef struct dh_st DH; */\n/* typedef struct dh_method DH_METHOD; */\n\nstruct dh_method {\n    const char *name;\n    /* Methods here */\n    int (*generate_key) (DH *dh);\n    int (*compute_key) (unsigned char *key, const BIGNUM *pub_key, DH *dh);\n    /* Can be null */\n    int (*bn_mod_exp) (const DH *dh, BIGNUM *r, const BIGNUM *a,\n                       const BIGNUM *p, const BIGNUM *m, BN_CTX *ctx,\n                       BN_MONT_CTX *m_ctx);\n    int (*init) (DH *dh);\n    int (*finish) (DH *dh);\n    int flags;\n    char *app_data;\n    /* If this is non-NULL, it will be used to generate parameters */\n    int (*generate_params) (DH *dh, int prime_len, int generator,\n                            BN_GENCB *cb);\n};\n\nstruct dh_st {\n    /*\n     * This first argument is used to pick up errors when a DH is passed\n     * instead of a EVP_PKEY\n     */\n    int pad;\n    int version;\n    BIGNUM *p;\n    BIGNUM *g;\n    long length;                /* optional */\n    BIGNUM *pub_key;            /* g^x % p */\n    BIGNUM *priv_key;           /* x */\n    int flags;\n    BN_MONT_CTX *method_mont_p;\n    /* Place holders if we want to do X9.42 DH */\n    BIGNUM *q;\n    BIGNUM *j;\n    unsigned char *seed;\n    int seedlen;\n    BIGNUM *counter;\n    int references;\n    CRYPTO_EX_DATA ex_data;\n    const DH_METHOD *meth;\n    ENGINE *engine;\n};\n\n# define DH_GENERATOR_2          2\n/* #define DH_GENERATOR_3       3 */\n# define DH_GENERATOR_5          5\n\n/* DH_check error codes */\n# define DH_CHECK_P_NOT_PRIME            0x01\n# define DH_CHECK_P_NOT_SAFE_PRIME       0x02\n# define DH_UNABLE_TO_CHECK_GENERATOR    0x04\n# define DH_NOT_SUITABLE_GENERATOR       0x08\n# define DH_CHECK_Q_NOT_PRIME            0x10\n# define DH_CHECK_INVALID_Q_VALUE        0x20\n# define DH_CHECK_INVALID_J_VALUE        0x40\n\n/* DH_check_pub_key error codes */\n# define DH_CHECK_PUBKEY_TOO_SMALL       0x01\n# define DH_CHECK_PUBKEY_TOO_LARGE       0x02\n# define DH_CHECK_PUBKEY_INVALID         0x04\n\n/*\n * primes p where (p-1)/2 is prime too are called \"safe\"; we define this for\n * backward compatibility:\n */\n# define DH_CHECK_P_NOT_STRONG_PRIME     DH_CHECK_P_NOT_SAFE_PRIME\n\n# define d2i_DHparams_fp(fp,x) (DH *)ASN1_d2i_fp((char *(*)())DH_new, \\\n                (char *(*)())d2i_DHparams,(fp),(unsigned char **)(x))\n# define i2d_DHparams_fp(fp,x) ASN1_i2d_fp(i2d_DHparams,(fp), \\\n                (unsigned char *)(x))\n# define d2i_DHparams_bio(bp,x) ASN1_d2i_bio_of(DH,DH_new,d2i_DHparams,bp,x)\n# define i2d_DHparams_bio(bp,x) ASN1_i2d_bio_of_const(DH,i2d_DHparams,bp,x)\n\nDH *DHparams_dup(DH *);\n\nconst DH_METHOD *DH_OpenSSL(void);\n\nvoid DH_set_default_method(const DH_METHOD *meth);\nconst DH_METHOD *DH_get_default_method(void);\nint DH_set_method(DH *dh, const DH_METHOD *meth);\nDH *DH_new_method(ENGINE *engine);\n\nDH *DH_new(void);\nvoid DH_free(DH *dh);\nint DH_up_ref(DH *dh);\nint DH_size(const DH *dh);\nint DH_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func,\n                        CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func);\nint DH_set_ex_data(DH *d, int idx, void *arg);\nvoid *DH_get_ex_data(DH *d, int idx);\n\n/* Deprecated version */\n# ifndef OPENSSL_NO_DEPRECATED\nDH *DH_generate_parameters(int prime_len, int generator,\n                           void (*callback) (int, int, void *), void *cb_arg);\n# endif                         /* !defined(OPENSSL_NO_DEPRECATED) */\n\n/* New version */\nint DH_generate_parameters_ex(DH *dh, int prime_len, int generator,\n                              BN_GENCB *cb);\n\nint DH_check(const DH *dh, int *codes);\nint DH_check_pub_key(const DH *dh, const BIGNUM *pub_key, int *codes);\nint DH_generate_key(DH *dh);\nint DH_compute_key(unsigned char *key, const BIGNUM *pub_key, DH *dh);\nint DH_compute_key_padded(unsigned char *key, const BIGNUM *pub_key, DH *dh);\nDH *d2i_DHparams(DH **a, const unsigned char **pp, long length);\nint i2d_DHparams(const DH *a, unsigned char **pp);\nDH *d2i_DHxparams(DH **a, const unsigned char **pp, long length);\nint i2d_DHxparams(const DH *a, unsigned char **pp);\n# ifndef OPENSSL_NO_FP_API\nint DHparams_print_fp(FILE *fp, const DH *x);\n# endif\n# ifndef OPENSSL_NO_BIO\nint DHparams_print(BIO *bp, const DH *x);\n# else\nint DHparams_print(char *bp, const DH *x);\n# endif\n\n/* RFC 5114 parameters */\nDH *DH_get_1024_160(void);\nDH *DH_get_2048_224(void);\nDH *DH_get_2048_256(void);\n\n/* RFC2631 KDF */\nint DH_KDF_X9_42(unsigned char *out, size_t outlen,\n                 const unsigned char *Z, size_t Zlen,\n                 ASN1_OBJECT *key_oid,\n                 const unsigned char *ukm, size_t ukmlen, const EVP_MD *md);\n\n# define EVP_PKEY_CTX_set_dh_paramgen_prime_len(ctx, len) \\\n        EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DH, EVP_PKEY_OP_PARAMGEN, \\\n                        EVP_PKEY_CTRL_DH_PARAMGEN_PRIME_LEN, len, NULL)\n\n# define EVP_PKEY_CTX_set_dh_paramgen_subprime_len(ctx, len) \\\n        EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DH, EVP_PKEY_OP_PARAMGEN, \\\n                        EVP_PKEY_CTRL_DH_PARAMGEN_SUBPRIME_LEN, len, NULL)\n\n# define EVP_PKEY_CTX_set_dh_paramgen_type(ctx, typ) \\\n        EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DH, EVP_PKEY_OP_PARAMGEN, \\\n                        EVP_PKEY_CTRL_DH_PARAMGEN_TYPE, typ, NULL)\n\n# define EVP_PKEY_CTX_set_dh_paramgen_generator(ctx, gen) \\\n        EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DH, EVP_PKEY_OP_PARAMGEN, \\\n                        EVP_PKEY_CTRL_DH_PARAMGEN_GENERATOR, gen, NULL)\n\n# define EVP_PKEY_CTX_set_dh_rfc5114(ctx, gen) \\\n        EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DHX, EVP_PKEY_OP_PARAMGEN, \\\n                        EVP_PKEY_CTRL_DH_RFC5114, gen, NULL)\n\n# define EVP_PKEY_CTX_set_dhx_rfc5114(ctx, gen) \\\n        EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DHX, EVP_PKEY_OP_PARAMGEN, \\\n                        EVP_PKEY_CTRL_DH_RFC5114, gen, NULL)\n\n# define EVP_PKEY_CTX_set_dh_kdf_type(ctx, kdf) \\\n        EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DHX, \\\n                                EVP_PKEY_OP_DERIVE, \\\n                                EVP_PKEY_CTRL_DH_KDF_TYPE, kdf, NULL)\n\n# define EVP_PKEY_CTX_get_dh_kdf_type(ctx) \\\n        EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DHX, \\\n                                EVP_PKEY_OP_DERIVE, \\\n                                EVP_PKEY_CTRL_DH_KDF_TYPE, -2, NULL)\n\n# define EVP_PKEY_CTX_set0_dh_kdf_oid(ctx, oid) \\\n        EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DHX, \\\n                                EVP_PKEY_OP_DERIVE, \\\n                                EVP_PKEY_CTRL_DH_KDF_OID, 0, (void *)oid)\n\n# define EVP_PKEY_CTX_get0_dh_kdf_oid(ctx, poid) \\\n        EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DHX, \\\n                                EVP_PKEY_OP_DERIVE, \\\n                                EVP_PKEY_CTRL_GET_DH_KDF_OID, 0, (void *)poid)\n\n# define EVP_PKEY_CTX_set_dh_kdf_md(ctx, md) \\\n        EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DHX, \\\n                                EVP_PKEY_OP_DERIVE, \\\n                                EVP_PKEY_CTRL_DH_KDF_MD, 0, (void *)md)\n\n# define EVP_PKEY_CTX_get_dh_kdf_md(ctx, pmd) \\\n        EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DHX, \\\n                                EVP_PKEY_OP_DERIVE, \\\n                                EVP_PKEY_CTRL_GET_DH_KDF_MD, 0, (void *)pmd)\n\n# define EVP_PKEY_CTX_set_dh_kdf_outlen(ctx, len) \\\n        EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DHX, \\\n                                EVP_PKEY_OP_DERIVE, \\\n                                EVP_PKEY_CTRL_DH_KDF_OUTLEN, len, NULL)\n\n# define EVP_PKEY_CTX_get_dh_kdf_outlen(ctx, plen) \\\n        EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DHX, \\\n                                EVP_PKEY_OP_DERIVE, \\\n                        EVP_PKEY_CTRL_GET_DH_KDF_OUTLEN, 0, (void *)plen)\n\n# define EVP_PKEY_CTX_set0_dh_kdf_ukm(ctx, p, plen) \\\n        EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DHX, \\\n                                EVP_PKEY_OP_DERIVE, \\\n                                EVP_PKEY_CTRL_DH_KDF_UKM, plen, (void *)p)\n\n# define EVP_PKEY_CTX_get0_dh_kdf_ukm(ctx, p) \\\n        EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DHX, \\\n                                EVP_PKEY_OP_DERIVE, \\\n                                EVP_PKEY_CTRL_GET_DH_KDF_UKM, 0, (void *)p)\n\n# define EVP_PKEY_CTRL_DH_PARAMGEN_PRIME_LEN     (EVP_PKEY_ALG_CTRL + 1)\n# define EVP_PKEY_CTRL_DH_PARAMGEN_GENERATOR     (EVP_PKEY_ALG_CTRL + 2)\n# define EVP_PKEY_CTRL_DH_RFC5114                (EVP_PKEY_ALG_CTRL + 3)\n# define EVP_PKEY_CTRL_DH_PARAMGEN_SUBPRIME_LEN  (EVP_PKEY_ALG_CTRL + 4)\n# define EVP_PKEY_CTRL_DH_PARAMGEN_TYPE          (EVP_PKEY_ALG_CTRL + 5)\n# define EVP_PKEY_CTRL_DH_KDF_TYPE               (EVP_PKEY_ALG_CTRL + 6)\n# define EVP_PKEY_CTRL_DH_KDF_MD                 (EVP_PKEY_ALG_CTRL + 7)\n# define EVP_PKEY_CTRL_GET_DH_KDF_MD             (EVP_PKEY_ALG_CTRL + 8)\n# define EVP_PKEY_CTRL_DH_KDF_OUTLEN             (EVP_PKEY_ALG_CTRL + 9)\n# define EVP_PKEY_CTRL_GET_DH_KDF_OUTLEN         (EVP_PKEY_ALG_CTRL + 10)\n# define EVP_PKEY_CTRL_DH_KDF_UKM                (EVP_PKEY_ALG_CTRL + 11)\n# define EVP_PKEY_CTRL_GET_DH_KDF_UKM            (EVP_PKEY_ALG_CTRL + 12)\n# define EVP_PKEY_CTRL_DH_KDF_OID                (EVP_PKEY_ALG_CTRL + 13)\n# define EVP_PKEY_CTRL_GET_DH_KDF_OID            (EVP_PKEY_ALG_CTRL + 14)\n\n/* KDF types */\n# define EVP_PKEY_DH_KDF_NONE                            1\n# define EVP_PKEY_DH_KDF_X9_42                           2\n\n/* BEGIN ERROR CODES */\n/*\n * The following lines are auto generated by the script mkerr.pl. Any changes\n * made after this point may be overwritten when the script is next run.\n */\nvoid ERR_load_DH_strings(void);\n\n/* Error codes for the DH functions. */\n\n/* Function codes. */\n# define DH_F_COMPUTE_KEY                                 102\n# define DH_F_DHPARAMS_PRINT_FP                           101\n# define DH_F_DH_BUILTIN_GENPARAMS                        106\n# define DH_F_DH_CMS_DECRYPT                              117\n# define DH_F_DH_CMS_SET_PEERKEY                          118\n# define DH_F_DH_CMS_SET_SHARED_INFO                      119\n# define DH_F_DH_COMPUTE_KEY                              114\n# define DH_F_DH_GENERATE_KEY                             115\n# define DH_F_DH_GENERATE_PARAMETERS_EX                   116\n# define DH_F_DH_NEW_METHOD                               105\n# define DH_F_DH_PARAM_DECODE                             107\n# define DH_F_DH_PRIV_DECODE                              110\n# define DH_F_DH_PRIV_ENCODE                              111\n# define DH_F_DH_PUB_DECODE                               108\n# define DH_F_DH_PUB_ENCODE                               109\n# define DH_F_DO_DH_PRINT                                 100\n# define DH_F_GENERATE_KEY                                103\n# define DH_F_GENERATE_PARAMETERS                         104\n# define DH_F_PKEY_DH_DERIVE                              112\n# define DH_F_PKEY_DH_KEYGEN                              113\n\n/* Reason codes. */\n# define DH_R_BAD_GENERATOR                               101\n# define DH_R_BN_DECODE_ERROR                             109\n# define DH_R_BN_ERROR                                    106\n# define DH_R_DECODE_ERROR                                104\n# define DH_R_INVALID_PUBKEY                              102\n# define DH_R_KDF_PARAMETER_ERROR                         112\n# define DH_R_KEYS_NOT_SET                                108\n# define DH_R_KEY_SIZE_TOO_SMALL                          110\n# define DH_R_MODULUS_TOO_LARGE                           103\n# define DH_R_NON_FIPS_METHOD                             111\n# define DH_R_NO_PARAMETERS_SET                           107\n# define DH_R_NO_PRIVATE_VALUE                            100\n# define DH_R_PARAMETER_ENCODING_ERROR                    105\n# define DH_R_PEER_KEY_ERROR                              113\n# define DH_R_SHARED_INFO_ERROR                           114\n\n#ifdef  __cplusplus\n}\n#endif\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/x86/include/openssl/dsa.h",
    "content": "/* crypto/dsa/dsa.h */\n/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)\n * All rights reserved.\n *\n * This package is an SSL implementation written\n * by Eric Young (eay@cryptsoft.com).\n * The implementation was written so as to conform with Netscapes SSL.\n *\n * This library is free for commercial and non-commercial use as long as\n * the following conditions are aheared to.  The following conditions\n * apply to all code found in this distribution, be it the RC4, RSA,\n * lhash, DES, etc., code; not just the SSL code.  The SSL documentation\n * included with this distribution is covered by the same copyright terms\n * except that the holder is Tim Hudson (tjh@cryptsoft.com).\n *\n * Copyright remains Eric Young's, and as such any Copyright notices in\n * the code are not to be removed.\n * If this package is used in a product, Eric Young should be given attribution\n * as the author of the parts of the library used.\n * This can be in the form of a textual message at program startup or\n * in documentation (online or textual) provided with the package.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the copyright\n *    notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in the\n *    documentation and/or other materials provided with the distribution.\n * 3. All advertising materials mentioning features or use of this software\n *    must display the following acknowledgement:\n *    \"This product includes cryptographic software written by\n *     Eric Young (eay@cryptsoft.com)\"\n *    The word 'cryptographic' can be left out if the rouines from the library\n *    being used are not cryptographic related :-).\n * 4. If you include any Windows specific code (or a derivative thereof) from\n *    the apps directory (application code) you must include an acknowledgement:\n *    \"This product includes software written by Tim Hudson (tjh@cryptsoft.com)\"\n *\n * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n * SUCH DAMAGE.\n *\n * The licence and distribution terms for any publically available version or\n * derivative of this code cannot be changed.  i.e. this code cannot simply be\n * copied and put under another distribution licence\n * [including the GNU Public Licence.]\n */\n\n/*\n * The DSS routines are based on patches supplied by\n * Steven Schoch <schoch@sheba.arc.nasa.gov>.  He basically did the\n * work and I have just tweaked them a little to fit into my\n * stylistic vision for SSLeay :-) */\n\n#ifndef HEADER_DSA_H\n# define HEADER_DSA_H\n\n# include <openssl/e_os2.h>\n\n# ifdef OPENSSL_NO_DSA\n#  error DSA is disabled.\n# endif\n\n# ifndef OPENSSL_NO_BIO\n#  include <openssl/bio.h>\n# endif\n# include <openssl/crypto.h>\n# include <openssl/ossl_typ.h>\n\n# ifndef OPENSSL_NO_DEPRECATED\n#  include <openssl/bn.h>\n#  ifndef OPENSSL_NO_DH\n#   include <openssl/dh.h>\n#  endif\n# endif\n\n# ifndef OPENSSL_DSA_MAX_MODULUS_BITS\n#  define OPENSSL_DSA_MAX_MODULUS_BITS   10000\n# endif\n\n# define DSA_FLAG_CACHE_MONT_P   0x01\n/*\n * new with 0.9.7h; the built-in DSA implementation now uses constant time\n * modular exponentiation for secret exponents by default. This flag causes\n * the faster variable sliding window method to be used for all exponents.\n */\n# define DSA_FLAG_NO_EXP_CONSTTIME       0x02\n\n/*\n * If this flag is set the DSA method is FIPS compliant and can be used in\n * FIPS mode. This is set in the validated module method. If an application\n * sets this flag in its own methods it is its reposibility to ensure the\n * result is compliant.\n */\n\n# define DSA_FLAG_FIPS_METHOD                    0x0400\n\n/*\n * If this flag is set the operations normally disabled in FIPS mode are\n * permitted it is then the applications responsibility to ensure that the\n * usage is compliant.\n */\n\n# define DSA_FLAG_NON_FIPS_ALLOW                 0x0400\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n/* Already defined in ossl_typ.h */\n/* typedef struct dsa_st DSA; */\n/* typedef struct dsa_method DSA_METHOD; */\n\ntypedef struct DSA_SIG_st {\n    BIGNUM *r;\n    BIGNUM *s;\n} DSA_SIG;\n\nstruct dsa_method {\n    const char *name;\n    DSA_SIG *(*dsa_do_sign) (const unsigned char *dgst, int dlen, DSA *dsa);\n    int (*dsa_sign_setup) (DSA *dsa, BN_CTX *ctx_in, BIGNUM **kinvp,\n                           BIGNUM **rp);\n    int (*dsa_do_verify) (const unsigned char *dgst, int dgst_len,\n                          DSA_SIG *sig, DSA *dsa);\n    int (*dsa_mod_exp) (DSA *dsa, BIGNUM *rr, BIGNUM *a1, BIGNUM *p1,\n                        BIGNUM *a2, BIGNUM *p2, BIGNUM *m, BN_CTX *ctx,\n                        BN_MONT_CTX *in_mont);\n    /* Can be null */\n    int (*bn_mod_exp) (DSA *dsa, BIGNUM *r, BIGNUM *a, const BIGNUM *p,\n                       const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx);\n    int (*init) (DSA *dsa);\n    int (*finish) (DSA *dsa);\n    int flags;\n    char *app_data;\n    /* If this is non-NULL, it is used to generate DSA parameters */\n    int (*dsa_paramgen) (DSA *dsa, int bits,\n                         const unsigned char *seed, int seed_len,\n                         int *counter_ret, unsigned long *h_ret,\n                         BN_GENCB *cb);\n    /* If this is non-NULL, it is used to generate DSA keys */\n    int (*dsa_keygen) (DSA *dsa);\n};\n\nstruct dsa_st {\n    /*\n     * This first variable is used to pick up errors where a DSA is passed\n     * instead of of a EVP_PKEY\n     */\n    int pad;\n    long version;\n    int write_params;\n    BIGNUM *p;\n    BIGNUM *q;                  /* == 20 */\n    BIGNUM *g;\n    BIGNUM *pub_key;            /* y public key */\n    BIGNUM *priv_key;           /* x private key */\n    BIGNUM *kinv;               /* Signing pre-calc */\n    BIGNUM *r;                  /* Signing pre-calc */\n    int flags;\n    /* Normally used to cache montgomery values */\n    BN_MONT_CTX *method_mont_p;\n    int references;\n    CRYPTO_EX_DATA ex_data;\n    const DSA_METHOD *meth;\n    /* functional reference if 'meth' is ENGINE-provided */\n    ENGINE *engine;\n};\n\n# define d2i_DSAparams_fp(fp,x) (DSA *)ASN1_d2i_fp((char *(*)())DSA_new, \\\n                (char *(*)())d2i_DSAparams,(fp),(unsigned char **)(x))\n# define i2d_DSAparams_fp(fp,x) ASN1_i2d_fp(i2d_DSAparams,(fp), \\\n                (unsigned char *)(x))\n# define d2i_DSAparams_bio(bp,x) ASN1_d2i_bio_of(DSA,DSA_new,d2i_DSAparams,bp,x)\n# define i2d_DSAparams_bio(bp,x) ASN1_i2d_bio_of_const(DSA,i2d_DSAparams,bp,x)\n\nDSA *DSAparams_dup(DSA *x);\nDSA_SIG *DSA_SIG_new(void);\nvoid DSA_SIG_free(DSA_SIG *a);\nint i2d_DSA_SIG(const DSA_SIG *a, unsigned char **pp);\nDSA_SIG *d2i_DSA_SIG(DSA_SIG **v, const unsigned char **pp, long length);\n\nDSA_SIG *DSA_do_sign(const unsigned char *dgst, int dlen, DSA *dsa);\nint DSA_do_verify(const unsigned char *dgst, int dgst_len,\n                  DSA_SIG *sig, DSA *dsa);\n\nconst DSA_METHOD *DSA_OpenSSL(void);\n\nvoid DSA_set_default_method(const DSA_METHOD *);\nconst DSA_METHOD *DSA_get_default_method(void);\nint DSA_set_method(DSA *dsa, const DSA_METHOD *);\n\nDSA *DSA_new(void);\nDSA *DSA_new_method(ENGINE *engine);\nvoid DSA_free(DSA *r);\n/* \"up\" the DSA object's reference count */\nint DSA_up_ref(DSA *r);\nint DSA_size(const DSA *);\n        /* next 4 return -1 on error */\nint DSA_sign_setup(DSA *dsa, BN_CTX *ctx_in, BIGNUM **kinvp, BIGNUM **rp);\nint DSA_sign(int type, const unsigned char *dgst, int dlen,\n             unsigned char *sig, unsigned int *siglen, DSA *dsa);\nint DSA_verify(int type, const unsigned char *dgst, int dgst_len,\n               const unsigned char *sigbuf, int siglen, DSA *dsa);\nint DSA_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func,\n                         CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func);\nint DSA_set_ex_data(DSA *d, int idx, void *arg);\nvoid *DSA_get_ex_data(DSA *d, int idx);\n\nDSA *d2i_DSAPublicKey(DSA **a, const unsigned char **pp, long length);\nDSA *d2i_DSAPrivateKey(DSA **a, const unsigned char **pp, long length);\nDSA *d2i_DSAparams(DSA **a, const unsigned char **pp, long length);\n\n/* Deprecated version */\n# ifndef OPENSSL_NO_DEPRECATED\nDSA *DSA_generate_parameters(int bits,\n                             unsigned char *seed, int seed_len,\n                             int *counter_ret, unsigned long *h_ret, void\n                              (*callback) (int, int, void *), void *cb_arg);\n# endif                         /* !defined(OPENSSL_NO_DEPRECATED) */\n\n/* New version */\nint DSA_generate_parameters_ex(DSA *dsa, int bits,\n                               const unsigned char *seed, int seed_len,\n                               int *counter_ret, unsigned long *h_ret,\n                               BN_GENCB *cb);\n\nint DSA_generate_key(DSA *a);\nint i2d_DSAPublicKey(const DSA *a, unsigned char **pp);\nint i2d_DSAPrivateKey(const DSA *a, unsigned char **pp);\nint i2d_DSAparams(const DSA *a, unsigned char **pp);\n\n# ifndef OPENSSL_NO_BIO\nint DSAparams_print(BIO *bp, const DSA *x);\nint DSA_print(BIO *bp, const DSA *x, int off);\n# endif\n# ifndef OPENSSL_NO_FP_API\nint DSAparams_print_fp(FILE *fp, const DSA *x);\nint DSA_print_fp(FILE *bp, const DSA *x, int off);\n# endif\n\n# define DSS_prime_checks 50\n/*\n * Primality test according to FIPS PUB 186[-1], Appendix 2.1: 50 rounds of\n * Rabin-Miller\n */\n# define DSA_is_prime(n, callback, cb_arg) \\\n        BN_is_prime(n, DSS_prime_checks, callback, NULL, cb_arg)\n\n# ifndef OPENSSL_NO_DH\n/*\n * Convert DSA structure (key or just parameters) into DH structure (be\n * careful to avoid small subgroup attacks when using this!)\n */\nDH *DSA_dup_DH(const DSA *r);\n# endif\n\n# define EVP_PKEY_CTX_set_dsa_paramgen_bits(ctx, nbits) \\\n        EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DSA, EVP_PKEY_OP_PARAMGEN, \\\n                                EVP_PKEY_CTRL_DSA_PARAMGEN_BITS, nbits, NULL)\n\n# define EVP_PKEY_CTRL_DSA_PARAMGEN_BITS         (EVP_PKEY_ALG_CTRL + 1)\n# define EVP_PKEY_CTRL_DSA_PARAMGEN_Q_BITS       (EVP_PKEY_ALG_CTRL + 2)\n# define EVP_PKEY_CTRL_DSA_PARAMGEN_MD           (EVP_PKEY_ALG_CTRL + 3)\n\n/* BEGIN ERROR CODES */\n/*\n * The following lines are auto generated by the script mkerr.pl. Any changes\n * made after this point may be overwritten when the script is next run.\n */\nvoid ERR_load_DSA_strings(void);\n\n/* Error codes for the DSA functions. */\n\n/* Function codes. */\n# define DSA_F_D2I_DSA_SIG                                110\n# define DSA_F_DO_DSA_PRINT                               104\n# define DSA_F_DSAPARAMS_PRINT                            100\n# define DSA_F_DSAPARAMS_PRINT_FP                         101\n# define DSA_F_DSA_BUILTIN_PARAMGEN2                      126\n# define DSA_F_DSA_DO_SIGN                                112\n# define DSA_F_DSA_DO_VERIFY                              113\n# define DSA_F_DSA_GENERATE_KEY                           124\n# define DSA_F_DSA_GENERATE_PARAMETERS_EX                 123\n# define DSA_F_DSA_NEW_METHOD                             103\n# define DSA_F_DSA_PARAM_DECODE                           119\n# define DSA_F_DSA_PRINT_FP                               105\n# define DSA_F_DSA_PRIV_DECODE                            115\n# define DSA_F_DSA_PRIV_ENCODE                            116\n# define DSA_F_DSA_PUB_DECODE                             117\n# define DSA_F_DSA_PUB_ENCODE                             118\n# define DSA_F_DSA_SIGN                                   106\n# define DSA_F_DSA_SIGN_SETUP                             107\n# define DSA_F_DSA_SIG_NEW                                109\n# define DSA_F_DSA_SIG_PRINT                              125\n# define DSA_F_DSA_VERIFY                                 108\n# define DSA_F_I2D_DSA_SIG                                111\n# define DSA_F_OLD_DSA_PRIV_DECODE                        122\n# define DSA_F_PKEY_DSA_CTRL                              120\n# define DSA_F_PKEY_DSA_KEYGEN                            121\n# define DSA_F_SIG_CB                                     114\n\n/* Reason codes. */\n# define DSA_R_BAD_Q_VALUE                                102\n# define DSA_R_BN_DECODE_ERROR                            108\n# define DSA_R_BN_ERROR                                   109\n# define DSA_R_DATA_TOO_LARGE_FOR_KEY_SIZE                100\n# define DSA_R_DECODE_ERROR                               104\n# define DSA_R_INVALID_DIGEST_TYPE                        106\n# define DSA_R_INVALID_PARAMETERS                         112\n# define DSA_R_MISSING_PARAMETERS                         101\n# define DSA_R_MODULUS_TOO_LARGE                          103\n# define DSA_R_NEED_NEW_SETUP_VALUES                      110\n# define DSA_R_NON_FIPS_DSA_METHOD                        111\n# define DSA_R_NO_PARAMETERS_SET                          107\n# define DSA_R_PARAMETER_ENCODING_ERROR                   105\n# define DSA_R_Q_NOT_PRIME                                113\n\n#ifdef  __cplusplus\n}\n#endif\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/x86/include/openssl/dso.h",
    "content": "/* dso.h */\n/*\n * Written by Geoff Thorpe (geoff@geoffthorpe.net) for the OpenSSL project\n * 2000.\n */\n/* ====================================================================\n * Copyright (c) 2000 The OpenSSL Project.  All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n *\n * 1. Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n *\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in\n *    the documentation and/or other materials provided with the\n *    distribution.\n *\n * 3. All advertising materials mentioning features or use of this\n *    software must display the following acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)\"\n *\n * 4. The names \"OpenSSL Toolkit\" and \"OpenSSL Project\" must not be used to\n *    endorse or promote products derived from this software without\n *    prior written permission. For written permission, please contact\n *    licensing@OpenSSL.org.\n *\n * 5. Products derived from this software may not be called \"OpenSSL\"\n *    nor may \"OpenSSL\" appear in their names without prior written\n *    permission of the OpenSSL Project.\n *\n * 6. Redistributions of any form whatsoever must retain the following\n *    acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)\"\n *\n * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY\n * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\n * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR\n * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\n * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,\n * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED\n * OF THE POSSIBILITY OF SUCH DAMAGE.\n * ====================================================================\n *\n * This product includes cryptographic software written by Eric Young\n * (eay@cryptsoft.com).  This product includes software written by Tim\n * Hudson (tjh@cryptsoft.com).\n *\n */\n\n#ifndef HEADER_DSO_H\n# define HEADER_DSO_H\n\n# include <openssl/crypto.h>\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/* These values are used as commands to DSO_ctrl() */\n# define DSO_CTRL_GET_FLAGS      1\n# define DSO_CTRL_SET_FLAGS      2\n# define DSO_CTRL_OR_FLAGS       3\n\n/*\n * By default, DSO_load() will translate the provided filename into a form\n * typical for the platform (more specifically the DSO_METHOD) using the\n * dso_name_converter function of the method. Eg. win32 will transform \"blah\"\n * into \"blah.dll\", and dlfcn will transform it into \"libblah.so\". The\n * behaviour can be overriden by setting the name_converter callback in the\n * DSO object (using DSO_set_name_converter()). This callback could even\n * utilise the DSO_METHOD's converter too if it only wants to override\n * behaviour for one or two possible DSO methods. However, the following flag\n * can be set in a DSO to prevent *any* native name-translation at all - eg.\n * if the caller has prompted the user for a path to a driver library so the\n * filename should be interpreted as-is.\n */\n# define DSO_FLAG_NO_NAME_TRANSLATION            0x01\n/*\n * An extra flag to give if only the extension should be added as\n * translation.  This is obviously only of importance on Unix and other\n * operating systems where the translation also may prefix the name with\n * something, like 'lib', and ignored everywhere else. This flag is also\n * ignored if DSO_FLAG_NO_NAME_TRANSLATION is used at the same time.\n */\n# define DSO_FLAG_NAME_TRANSLATION_EXT_ONLY      0x02\n\n/*\n * The following flag controls the translation of symbol names to upper case.\n * This is currently only being implemented for OpenVMS.\n */\n# define DSO_FLAG_UPCASE_SYMBOL                  0x10\n\n/*\n * This flag loads the library with public symbols. Meaning: The exported\n * symbols of this library are public to all libraries loaded after this\n * library. At the moment only implemented in unix.\n */\n# define DSO_FLAG_GLOBAL_SYMBOLS                 0x20\n\ntypedef void (*DSO_FUNC_TYPE) (void);\n\ntypedef struct dso_st DSO;\n\n/*\n * The function prototype used for method functions (or caller-provided\n * callbacks) that transform filenames. They are passed a DSO structure\n * pointer (or NULL if they are to be used independantly of a DSO object) and\n * a filename to transform. They should either return NULL (if there is an\n * error condition) or a newly allocated string containing the transformed\n * form that the caller will need to free with OPENSSL_free() when done.\n */\ntypedef char *(*DSO_NAME_CONVERTER_FUNC)(DSO *, const char *);\n/*\n * The function prototype used for method functions (or caller-provided\n * callbacks) that merge two file specifications. They are passed a DSO\n * structure pointer (or NULL if they are to be used independantly of a DSO\n * object) and two file specifications to merge. They should either return\n * NULL (if there is an error condition) or a newly allocated string\n * containing the result of merging that the caller will need to free with\n * OPENSSL_free() when done. Here, merging means that bits and pieces are\n * taken from each of the file specifications and added together in whatever\n * fashion that is sensible for the DSO method in question.  The only rule\n * that really applies is that if the two specification contain pieces of the\n * same type, the copy from the first string takes priority.  One could see\n * it as the first specification is the one given by the user and the second\n * being a bunch of defaults to add on if they're missing in the first.\n */\ntypedef char *(*DSO_MERGER_FUNC)(DSO *, const char *, const char *);\n\ntypedef struct dso_meth_st {\n    const char *name;\n    /*\n     * Loads a shared library, NB: new DSO_METHODs must ensure that a\n     * successful load populates the loaded_filename field, and likewise a\n     * successful unload OPENSSL_frees and NULLs it out.\n     */\n    int (*dso_load) (DSO *dso);\n    /* Unloads a shared library */\n    int (*dso_unload) (DSO *dso);\n    /* Binds a variable */\n    void *(*dso_bind_var) (DSO *dso, const char *symname);\n    /*\n     * Binds a function - assumes a return type of DSO_FUNC_TYPE. This should\n     * be cast to the real function prototype by the caller. Platforms that\n     * don't have compatible representations for different prototypes (this\n     * is possible within ANSI C) are highly unlikely to have shared\n     * libraries at all, let alone a DSO_METHOD implemented for them.\n     */\n    DSO_FUNC_TYPE (*dso_bind_func) (DSO *dso, const char *symname);\n/* I don't think this would actually be used in any circumstances. */\n# if 0\n    /* Unbinds a variable */\n    int (*dso_unbind_var) (DSO *dso, char *symname, void *symptr);\n    /* Unbinds a function */\n    int (*dso_unbind_func) (DSO *dso, char *symname, DSO_FUNC_TYPE symptr);\n# endif\n    /*\n     * The generic (yuck) \"ctrl()\" function. NB: Negative return values\n     * (rather than zero) indicate errors.\n     */\n    long (*dso_ctrl) (DSO *dso, int cmd, long larg, void *parg);\n    /*\n     * The default DSO_METHOD-specific function for converting filenames to a\n     * canonical native form.\n     */\n    DSO_NAME_CONVERTER_FUNC dso_name_converter;\n    /*\n     * The default DSO_METHOD-specific function for converting filenames to a\n     * canonical native form.\n     */\n    DSO_MERGER_FUNC dso_merger;\n    /* [De]Initialisation handlers. */\n    int (*init) (DSO *dso);\n    int (*finish) (DSO *dso);\n    /* Return pathname of the module containing location */\n    int (*pathbyaddr) (void *addr, char *path, int sz);\n    /* Perform global symbol lookup, i.e. among *all* modules */\n    void *(*globallookup) (const char *symname);\n} DSO_METHOD;\n\n/**********************************************************************/\n/* The low-level handle type used to refer to a loaded shared library */\n\nstruct dso_st {\n    DSO_METHOD *meth;\n    /*\n     * Standard dlopen uses a (void *). Win32 uses a HANDLE. VMS doesn't use\n     * anything but will need to cache the filename for use in the dso_bind\n     * handler. All in all, let each method control its own destiny.\n     * \"Handles\" and such go in a STACK.\n     */\n    STACK_OF(void) *meth_data;\n    int references;\n    int flags;\n    /*\n     * For use by applications etc ... use this for your bits'n'pieces, don't\n     * touch meth_data!\n     */\n    CRYPTO_EX_DATA ex_data;\n    /*\n     * If this callback function pointer is set to non-NULL, then it will be\n     * used in DSO_load() in place of meth->dso_name_converter. NB: This\n     * should normally set using DSO_set_name_converter().\n     */\n    DSO_NAME_CONVERTER_FUNC name_converter;\n    /*\n     * If this callback function pointer is set to non-NULL, then it will be\n     * used in DSO_load() in place of meth->dso_merger. NB: This should\n     * normally set using DSO_set_merger().\n     */\n    DSO_MERGER_FUNC merger;\n    /*\n     * This is populated with (a copy of) the platform-independant filename\n     * used for this DSO.\n     */\n    char *filename;\n    /*\n     * This is populated with (a copy of) the translated filename by which\n     * the DSO was actually loaded. It is NULL iff the DSO is not currently\n     * loaded. NB: This is here because the filename translation process may\n     * involve a callback being invoked more than once not only to convert to\n     * a platform-specific form, but also to try different filenames in the\n     * process of trying to perform a load. As such, this variable can be\n     * used to indicate (a) whether this DSO structure corresponds to a\n     * loaded library or not, and (b) the filename with which it was actually\n     * loaded.\n     */\n    char *loaded_filename;\n};\n\nDSO *DSO_new(void);\nDSO *DSO_new_method(DSO_METHOD *method);\nint DSO_free(DSO *dso);\nint DSO_flags(DSO *dso);\nint DSO_up_ref(DSO *dso);\nlong DSO_ctrl(DSO *dso, int cmd, long larg, void *parg);\n\n/*\n * This function sets the DSO's name_converter callback. If it is non-NULL,\n * then it will be used instead of the associated DSO_METHOD's function. If\n * oldcb is non-NULL then it is set to the function pointer value being\n * replaced. Return value is non-zero for success.\n */\nint DSO_set_name_converter(DSO *dso, DSO_NAME_CONVERTER_FUNC cb,\n                           DSO_NAME_CONVERTER_FUNC *oldcb);\n/*\n * These functions can be used to get/set the platform-independant filename\n * used for a DSO. NB: set will fail if the DSO is already loaded.\n */\nconst char *DSO_get_filename(DSO *dso);\nint DSO_set_filename(DSO *dso, const char *filename);\n/*\n * This function will invoke the DSO's name_converter callback to translate a\n * filename, or if the callback isn't set it will instead use the DSO_METHOD's\n * converter. If \"filename\" is NULL, the \"filename\" in the DSO itself will be\n * used. If the DSO_FLAG_NO_NAME_TRANSLATION flag is set, then the filename is\n * simply duplicated. NB: This function is usually called from within a\n * DSO_METHOD during the processing of a DSO_load() call, and is exposed so\n * that caller-created DSO_METHODs can do the same thing. A non-NULL return\n * value will need to be OPENSSL_free()'d.\n */\nchar *DSO_convert_filename(DSO *dso, const char *filename);\n/*\n * This function will invoke the DSO's merger callback to merge two file\n * specifications, or if the callback isn't set it will instead use the\n * DSO_METHOD's merger.  A non-NULL return value will need to be\n * OPENSSL_free()'d.\n */\nchar *DSO_merge(DSO *dso, const char *filespec1, const char *filespec2);\n/*\n * If the DSO is currently loaded, this returns the filename that it was\n * loaded under, otherwise it returns NULL. So it is also useful as a test as\n * to whether the DSO is currently loaded. NB: This will not necessarily\n * return the same value as DSO_convert_filename(dso, dso->filename), because\n * the DSO_METHOD's load function may have tried a variety of filenames (with\n * and/or without the aid of the converters) before settling on the one it\n * actually loaded.\n */\nconst char *DSO_get_loaded_filename(DSO *dso);\n\nvoid DSO_set_default_method(DSO_METHOD *meth);\nDSO_METHOD *DSO_get_default_method(void);\nDSO_METHOD *DSO_get_method(DSO *dso);\nDSO_METHOD *DSO_set_method(DSO *dso, DSO_METHOD *meth);\n\n/*\n * The all-singing all-dancing load function, you normally pass NULL for the\n * first and third parameters. Use DSO_up and DSO_free for subsequent\n * reference count handling. Any flags passed in will be set in the\n * constructed DSO after its init() function but before the load operation.\n * If 'dso' is non-NULL, 'flags' is ignored.\n */\nDSO *DSO_load(DSO *dso, const char *filename, DSO_METHOD *meth, int flags);\n\n/* This function binds to a variable inside a shared library. */\nvoid *DSO_bind_var(DSO *dso, const char *symname);\n\n/* This function binds to a function inside a shared library. */\nDSO_FUNC_TYPE DSO_bind_func(DSO *dso, const char *symname);\n\n/*\n * This method is the default, but will beg, borrow, or steal whatever method\n * should be the default on any particular platform (including\n * DSO_METH_null() if necessary).\n */\nDSO_METHOD *DSO_METHOD_openssl(void);\n\n/*\n * This method is defined for all platforms - if a platform has no DSO\n * support then this will be the only method!\n */\nDSO_METHOD *DSO_METHOD_null(void);\n\n/*\n * If DSO_DLFCN is defined, the standard dlfcn.h-style functions (dlopen,\n * dlclose, dlsym, etc) will be used and incorporated into this method. If\n * not, this method will return NULL.\n */\nDSO_METHOD *DSO_METHOD_dlfcn(void);\n\n/*\n * If DSO_DL is defined, the standard dl.h-style functions (shl_load,\n * shl_unload, shl_findsym, etc) will be used and incorporated into this\n * method. If not, this method will return NULL.\n */\nDSO_METHOD *DSO_METHOD_dl(void);\n\n/* If WIN32 is defined, use DLLs. If not, return NULL. */\nDSO_METHOD *DSO_METHOD_win32(void);\n\n/* If VMS is defined, use shared images. If not, return NULL. */\nDSO_METHOD *DSO_METHOD_vms(void);\n\n/*\n * This function writes null-terminated pathname of DSO module containing\n * 'addr' into 'sz' large caller-provided 'path' and returns the number of\n * characters [including trailing zero] written to it. If 'sz' is 0 or\n * negative, 'path' is ignored and required amount of charachers [including\n * trailing zero] to accomodate pathname is returned. If 'addr' is NULL, then\n * pathname of cryptolib itself is returned. Negative or zero return value\n * denotes error.\n */\nint DSO_pathbyaddr(void *addr, char *path, int sz);\n\n/*\n * This function should be used with caution! It looks up symbols in *all*\n * loaded modules and if module gets unloaded by somebody else attempt to\n * dereference the pointer is doomed to have fatal consequences. Primary\n * usage for this function is to probe *core* system functionality, e.g.\n * check if getnameinfo(3) is available at run-time without bothering about\n * OS-specific details such as libc.so.versioning or where does it actually\n * reside: in libc itself or libsocket.\n */\nvoid *DSO_global_lookup(const char *name);\n\n/* If BeOS is defined, use shared images. If not, return NULL. */\nDSO_METHOD *DSO_METHOD_beos(void);\n\n/* BEGIN ERROR CODES */\n/*\n * The following lines are auto generated by the script mkerr.pl. Any changes\n * made after this point may be overwritten when the script is next run.\n */\nvoid ERR_load_DSO_strings(void);\n\n/* Error codes for the DSO functions. */\n\n/* Function codes. */\n# define DSO_F_BEOS_BIND_FUNC                             144\n# define DSO_F_BEOS_BIND_VAR                              145\n# define DSO_F_BEOS_LOAD                                  146\n# define DSO_F_BEOS_NAME_CONVERTER                        147\n# define DSO_F_BEOS_UNLOAD                                148\n# define DSO_F_DLFCN_BIND_FUNC                            100\n# define DSO_F_DLFCN_BIND_VAR                             101\n# define DSO_F_DLFCN_LOAD                                 102\n# define DSO_F_DLFCN_MERGER                               130\n# define DSO_F_DLFCN_NAME_CONVERTER                       123\n# define DSO_F_DLFCN_UNLOAD                               103\n# define DSO_F_DL_BIND_FUNC                               104\n# define DSO_F_DL_BIND_VAR                                105\n# define DSO_F_DL_LOAD                                    106\n# define DSO_F_DL_MERGER                                  131\n# define DSO_F_DL_NAME_CONVERTER                          124\n# define DSO_F_DL_UNLOAD                                  107\n# define DSO_F_DSO_BIND_FUNC                              108\n# define DSO_F_DSO_BIND_VAR                               109\n# define DSO_F_DSO_CONVERT_FILENAME                       126\n# define DSO_F_DSO_CTRL                                   110\n# define DSO_F_DSO_FREE                                   111\n# define DSO_F_DSO_GET_FILENAME                           127\n# define DSO_F_DSO_GET_LOADED_FILENAME                    128\n# define DSO_F_DSO_GLOBAL_LOOKUP                          139\n# define DSO_F_DSO_LOAD                                   112\n# define DSO_F_DSO_MERGE                                  132\n# define DSO_F_DSO_NEW_METHOD                             113\n# define DSO_F_DSO_PATHBYADDR                             140\n# define DSO_F_DSO_SET_FILENAME                           129\n# define DSO_F_DSO_SET_NAME_CONVERTER                     122\n# define DSO_F_DSO_UP_REF                                 114\n# define DSO_F_GLOBAL_LOOKUP_FUNC                         138\n# define DSO_F_PATHBYADDR                                 137\n# define DSO_F_VMS_BIND_SYM                               115\n# define DSO_F_VMS_LOAD                                   116\n# define DSO_F_VMS_MERGER                                 133\n# define DSO_F_VMS_UNLOAD                                 117\n# define DSO_F_WIN32_BIND_FUNC                            118\n# define DSO_F_WIN32_BIND_VAR                             119\n# define DSO_F_WIN32_GLOBALLOOKUP                         142\n# define DSO_F_WIN32_GLOBALLOOKUP_FUNC                    143\n# define DSO_F_WIN32_JOINER                               135\n# define DSO_F_WIN32_LOAD                                 120\n# define DSO_F_WIN32_MERGER                               134\n# define DSO_F_WIN32_NAME_CONVERTER                       125\n# define DSO_F_WIN32_PATHBYADDR                           141\n# define DSO_F_WIN32_SPLITTER                             136\n# define DSO_F_WIN32_UNLOAD                               121\n\n/* Reason codes. */\n# define DSO_R_CTRL_FAILED                                100\n# define DSO_R_DSO_ALREADY_LOADED                         110\n# define DSO_R_EMPTY_FILE_STRUCTURE                       113\n# define DSO_R_FAILURE                                    114\n# define DSO_R_FILENAME_TOO_BIG                           101\n# define DSO_R_FINISH_FAILED                              102\n# define DSO_R_INCORRECT_FILE_SYNTAX                      115\n# define DSO_R_LOAD_FAILED                                103\n# define DSO_R_NAME_TRANSLATION_FAILED                    109\n# define DSO_R_NO_FILENAME                                111\n# define DSO_R_NO_FILE_SPECIFICATION                      116\n# define DSO_R_NULL_HANDLE                                104\n# define DSO_R_SET_FILENAME_FAILED                        112\n# define DSO_R_STACK_ERROR                                105\n# define DSO_R_SYM_FAILURE                                106\n# define DSO_R_UNLOAD_FAILED                              107\n# define DSO_R_UNSUPPORTED                                108\n\n#ifdef  __cplusplus\n}\n#endif\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/x86/include/openssl/dtls1.h",
    "content": "/* ssl/dtls1.h */\n/*\n * DTLS implementation written by Nagendra Modadugu\n * (nagendra@cs.stanford.edu) for the OpenSSL project 2005.\n */\n/* ====================================================================\n * Copyright (c) 1999-2005 The OpenSSL Project.  All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n *\n * 1. Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n *\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in\n *    the documentation and/or other materials provided with the\n *    distribution.\n *\n * 3. All advertising materials mentioning features or use of this\n *    software must display the following acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)\"\n *\n * 4. The names \"OpenSSL Toolkit\" and \"OpenSSL Project\" must not be used to\n *    endorse or promote products derived from this software without\n *    prior written permission. For written permission, please contact\n *    openssl-core@OpenSSL.org.\n *\n * 5. Products derived from this software may not be called \"OpenSSL\"\n *    nor may \"OpenSSL\" appear in their names without prior written\n *    permission of the OpenSSL Project.\n *\n * 6. Redistributions of any form whatsoever must retain the following\n *    acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)\"\n *\n * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY\n * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\n * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR\n * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\n * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,\n * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED\n * OF THE POSSIBILITY OF SUCH DAMAGE.\n * ====================================================================\n *\n * This product includes cryptographic software written by Eric Young\n * (eay@cryptsoft.com).  This product includes software written by Tim\n * Hudson (tjh@cryptsoft.com).\n *\n */\n\n#ifndef HEADER_DTLS1_H\n# define HEADER_DTLS1_H\n\n# include <openssl/buffer.h>\n# include <openssl/pqueue.h>\n# ifdef OPENSSL_SYS_VMS\n#  include <resource.h>\n#  include <sys/timeb.h>\n# endif\n# ifdef OPENSSL_SYS_WIN32\n/* Needed for struct timeval */\n#  include <winsock.h>\n# elif defined(OPENSSL_SYS_NETWARE) && !defined(_WINSOCK2API_)\n#  include <sys/timeval.h>\n# else\n#  if defined(OPENSSL_SYS_VXWORKS)\n#   include <sys/times.h>\n#  else\n#   include <sys/time.h>\n#  endif\n# endif\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n# define DTLS1_VERSION                   0xFEFF\n# define DTLS1_2_VERSION                 0xFEFD\n# define DTLS_MAX_VERSION                DTLS1_2_VERSION\n# define DTLS1_VERSION_MAJOR             0xFE\n\n# define DTLS1_BAD_VER                   0x0100\n\n/* Special value for method supporting multiple versions */\n# define DTLS_ANY_VERSION                0x1FFFF\n\n# if 0\n/* this alert description is not specified anywhere... */\n#  define DTLS1_AD_MISSING_HANDSHAKE_MESSAGE    110\n# endif\n\n/* lengths of messages */\n# define DTLS1_COOKIE_LENGTH                     256\n\n# define DTLS1_RT_HEADER_LENGTH                  13\n\n# define DTLS1_HM_HEADER_LENGTH                  12\n\n# define DTLS1_HM_BAD_FRAGMENT                   -2\n# define DTLS1_HM_FRAGMENT_RETRY                 -3\n\n# define DTLS1_CCS_HEADER_LENGTH                  1\n\n# ifdef DTLS1_AD_MISSING_HANDSHAKE_MESSAGE\n#  define DTLS1_AL_HEADER_LENGTH                   7\n# else\n#  define DTLS1_AL_HEADER_LENGTH                   2\n# endif\n\n# ifndef OPENSSL_NO_SSL_INTERN\n\n#  ifndef OPENSSL_NO_SCTP\n#   define DTLS1_SCTP_AUTH_LABEL   \"EXPORTER_DTLS_OVER_SCTP\"\n#  endif\n\n/* Max MTU overhead we know about so far is 40 for IPv6 + 8 for UDP */\n#  define DTLS1_MAX_MTU_OVERHEAD                   48\n\ntypedef struct dtls1_bitmap_st {\n    unsigned long map;          /* track 32 packets on 32-bit systems and 64\n                                 * - on 64-bit systems */\n    unsigned char max_seq_num[8]; /* max record number seen so far, 64-bit\n                                   * value in big-endian encoding */\n} DTLS1_BITMAP;\n\nstruct dtls1_retransmit_state {\n    EVP_CIPHER_CTX *enc_write_ctx; /* cryptographic state */\n    EVP_MD_CTX *write_hash;     /* used for mac generation */\n#  ifndef OPENSSL_NO_COMP\n    COMP_CTX *compress;         /* compression */\n#  else\n    char *compress;\n#  endif\n    SSL_SESSION *session;\n    unsigned short epoch;\n};\n\nstruct hm_header_st {\n    unsigned char type;\n    unsigned long msg_len;\n    unsigned short seq;\n    unsigned long frag_off;\n    unsigned long frag_len;\n    unsigned int is_ccs;\n    struct dtls1_retransmit_state saved_retransmit_state;\n};\n\nstruct ccs_header_st {\n    unsigned char type;\n    unsigned short seq;\n};\n\nstruct dtls1_timeout_st {\n    /* Number of read timeouts so far */\n    unsigned int read_timeouts;\n    /* Number of write timeouts so far */\n    unsigned int write_timeouts;\n    /* Number of alerts received so far */\n    unsigned int num_alerts;\n};\n\ntypedef struct record_pqueue_st {\n    unsigned short epoch;\n    pqueue q;\n} record_pqueue;\n\ntypedef struct hm_fragment_st {\n    struct hm_header_st msg_header;\n    unsigned char *fragment;\n    unsigned char *reassembly;\n} hm_fragment;\n\ntypedef struct dtls1_state_st {\n    unsigned int send_cookie;\n    unsigned char cookie[DTLS1_COOKIE_LENGTH];\n    unsigned char rcvd_cookie[DTLS1_COOKIE_LENGTH];\n    unsigned int cookie_len;\n    /*\n     * The current data and handshake epoch.  This is initially\n     * undefined, and starts at zero once the initial handshake is\n     * completed\n     */\n    unsigned short r_epoch;\n    unsigned short w_epoch;\n    /* records being received in the current epoch */\n    DTLS1_BITMAP bitmap;\n    /* renegotiation starts a new set of sequence numbers */\n    DTLS1_BITMAP next_bitmap;\n    /* handshake message numbers */\n    unsigned short handshake_write_seq;\n    unsigned short next_handshake_write_seq;\n    unsigned short handshake_read_seq;\n    /* save last sequence number for retransmissions */\n    unsigned char last_write_sequence[8];\n    /* Received handshake records (processed and unprocessed) */\n    record_pqueue unprocessed_rcds;\n    record_pqueue processed_rcds;\n    /* Buffered handshake messages */\n    pqueue buffered_messages;\n    /* Buffered (sent) handshake records */\n    pqueue sent_messages;\n    /*\n     * Buffered application records. Only for records between CCS and\n     * Finished to prevent either protocol violation or unnecessary message\n     * loss.\n     */\n    record_pqueue buffered_app_data;\n    /* Is set when listening for new connections with dtls1_listen() */\n    unsigned int listen;\n    unsigned int link_mtu;      /* max on-the-wire DTLS packet size */\n    unsigned int mtu;           /* max DTLS packet size */\n    struct hm_header_st w_msg_hdr;\n    struct hm_header_st r_msg_hdr;\n    struct dtls1_timeout_st timeout;\n    /*\n     * Indicates when the last handshake msg or heartbeat sent will timeout\n     */\n    struct timeval next_timeout;\n    /* Timeout duration */\n    unsigned short timeout_duration;\n    /*\n     * storage for Alert/Handshake protocol data received but not yet\n     * processed by ssl3_read_bytes:\n     */\n    unsigned char alert_fragment[DTLS1_AL_HEADER_LENGTH];\n    unsigned int alert_fragment_len;\n    unsigned char handshake_fragment[DTLS1_HM_HEADER_LENGTH];\n    unsigned int handshake_fragment_len;\n    unsigned int retransmitting;\n    /*\n     * Set when the handshake is ready to process peer's ChangeCipherSpec message.\n     * Cleared after the message has been processed.\n     */\n    unsigned int change_cipher_spec_ok;\n#  ifndef OPENSSL_NO_SCTP\n    /* used when SSL_ST_XX_FLUSH is entered */\n    int next_state;\n    int shutdown_received;\n#  endif\n} DTLS1_STATE;\n\ntypedef struct dtls1_record_data_st {\n    unsigned char *packet;\n    unsigned int packet_length;\n    SSL3_BUFFER rbuf;\n    SSL3_RECORD rrec;\n#  ifndef OPENSSL_NO_SCTP\n    struct bio_dgram_sctp_rcvinfo recordinfo;\n#  endif\n} DTLS1_RECORD_DATA;\n\n# endif\n\n/* Timeout multipliers (timeout slice is defined in apps/timeouts.h */\n# define DTLS1_TMO_READ_COUNT                      2\n# define DTLS1_TMO_WRITE_COUNT                     2\n\n# define DTLS1_TMO_ALERT_COUNT                     12\n\n#ifdef  __cplusplus\n}\n#endif\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/x86/include/openssl/e_os2.h",
    "content": "/* e_os2.h */\n/* ====================================================================\n * Copyright (c) 1998-2000 The OpenSSL Project.  All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n *\n * 1. Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n *\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in\n *    the documentation and/or other materials provided with the\n *    distribution.\n *\n * 3. All advertising materials mentioning features or use of this\n *    software must display the following acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit. (http://www.openssl.org/)\"\n *\n * 4. The names \"OpenSSL Toolkit\" and \"OpenSSL Project\" must not be used to\n *    endorse or promote products derived from this software without\n *    prior written permission. For written permission, please contact\n *    openssl-core@openssl.org.\n *\n * 5. Products derived from this software may not be called \"OpenSSL\"\n *    nor may \"OpenSSL\" appear in their names without prior written\n *    permission of the OpenSSL Project.\n *\n * 6. Redistributions of any form whatsoever must retain the following\n *    acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit (http://www.openssl.org/)\"\n *\n * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY\n * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\n * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR\n * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\n * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,\n * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED\n * OF THE POSSIBILITY OF SUCH DAMAGE.\n * ====================================================================\n *\n * This product includes cryptographic software written by Eric Young\n * (eay@cryptsoft.com).  This product includes software written by Tim\n * Hudson (tjh@cryptsoft.com).\n *\n */\n\n#include <openssl/opensslconf.h>\n\n#ifndef HEADER_E_OS2_H\n# define HEADER_E_OS2_H\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n/******************************************************************************\n * Detect operating systems.  This probably needs completing.\n * The result is that at least one OPENSSL_SYS_os macro should be defined.\n * However, if none is defined, Unix is assumed.\n **/\n\n# define OPENSSL_SYS_UNIX\n\n/* ---------------------- Macintosh, before MacOS X ----------------------- */\n# if defined(__MWERKS__) && defined(macintosh) || defined(OPENSSL_SYSNAME_MAC)\n#  undef OPENSSL_SYS_UNIX\n#  define OPENSSL_SYS_MACINTOSH_CLASSIC\n# endif\n\n/* ---------------------- NetWare ----------------------------------------- */\n# if defined(NETWARE) || defined(OPENSSL_SYSNAME_NETWARE)\n#  undef OPENSSL_SYS_UNIX\n#  define OPENSSL_SYS_NETWARE\n# endif\n\n/* --------------------- Microsoft operating systems ---------------------- */\n\n/*\n * Note that MSDOS actually denotes 32-bit environments running on top of\n * MS-DOS, such as DJGPP one.\n */\n# if defined(OPENSSL_SYSNAME_MSDOS)\n#  undef OPENSSL_SYS_UNIX\n#  define OPENSSL_SYS_MSDOS\n# endif\n\n/*\n * For 32 bit environment, there seems to be the CygWin environment and then\n * all the others that try to do the same thing Microsoft does...\n */\n# if defined(OPENSSL_SYSNAME_UWIN)\n#  undef OPENSSL_SYS_UNIX\n#  define OPENSSL_SYS_WIN32_UWIN\n# else\n#  if defined(__CYGWIN__) || defined(OPENSSL_SYSNAME_CYGWIN)\n#   undef OPENSSL_SYS_UNIX\n#   define OPENSSL_SYS_WIN32_CYGWIN\n#  else\n#   if defined(_WIN32) || defined(OPENSSL_SYSNAME_WIN32)\n#    undef OPENSSL_SYS_UNIX\n#    define OPENSSL_SYS_WIN32\n#   endif\n#   if defined(_WIN64) || defined(OPENSSL_SYSNAME_WIN64)\n#    undef OPENSSL_SYS_UNIX\n#    if !defined(OPENSSL_SYS_WIN64)\n#     define OPENSSL_SYS_WIN64\n#    endif\n#   endif\n#   if defined(OPENSSL_SYSNAME_WINNT)\n#    undef OPENSSL_SYS_UNIX\n#    define OPENSSL_SYS_WINNT\n#   endif\n#   if defined(OPENSSL_SYSNAME_WINCE)\n#    undef OPENSSL_SYS_UNIX\n#    define OPENSSL_SYS_WINCE\n#   endif\n#  endif\n# endif\n\n/* Anything that tries to look like Microsoft is \"Windows\" */\n# if defined(OPENSSL_SYS_WIN32) || defined(OPENSSL_SYS_WIN64) || defined(OPENSSL_SYS_WINNT) || defined(OPENSSL_SYS_WINCE)\n#  undef OPENSSL_SYS_UNIX\n#  define OPENSSL_SYS_WINDOWS\n#  ifndef OPENSSL_SYS_MSDOS\n#   define OPENSSL_SYS_MSDOS\n#  endif\n# endif\n\n/*\n * DLL settings.  This part is a bit tough, because it's up to the\n * application implementor how he or she will link the application, so it\n * requires some macro to be used.\n */\n# ifdef OPENSSL_SYS_WINDOWS\n#  ifndef OPENSSL_OPT_WINDLL\n#   if defined(_WINDLL)         /* This is used when building OpenSSL to\n                                 * indicate that DLL linkage should be used */\n#    define OPENSSL_OPT_WINDLL\n#   endif\n#  endif\n# endif\n\n/* ------------------------------- OpenVMS -------------------------------- */\n# if defined(__VMS) || defined(VMS) || defined(OPENSSL_SYSNAME_VMS)\n#  undef OPENSSL_SYS_UNIX\n#  define OPENSSL_SYS_VMS\n#  if defined(__DECC)\n#   define OPENSSL_SYS_VMS_DECC\n#  elif defined(__DECCXX)\n#   define OPENSSL_SYS_VMS_DECC\n#   define OPENSSL_SYS_VMS_DECCXX\n#  else\n#   define OPENSSL_SYS_VMS_NODECC\n#  endif\n# endif\n\n/* -------------------------------- OS/2 ---------------------------------- */\n# if defined(__EMX__) || defined(__OS2__)\n#  undef OPENSSL_SYS_UNIX\n#  define OPENSSL_SYS_OS2\n# endif\n\n/* -------------------------------- Unix ---------------------------------- */\n# ifdef OPENSSL_SYS_UNIX\n#  if defined(linux) || defined(__linux__) || defined(OPENSSL_SYSNAME_LINUX)\n#   define OPENSSL_SYS_LINUX\n#  endif\n#  ifdef OPENSSL_SYSNAME_MPE\n#   define OPENSSL_SYS_MPE\n#  endif\n#  ifdef OPENSSL_SYSNAME_SNI\n#   define OPENSSL_SYS_SNI\n#  endif\n#  ifdef OPENSSL_SYSNAME_ULTRASPARC\n#   define OPENSSL_SYS_ULTRASPARC\n#  endif\n#  ifdef OPENSSL_SYSNAME_NEWS4\n#   define OPENSSL_SYS_NEWS4\n#  endif\n#  ifdef OPENSSL_SYSNAME_MACOSX\n#   define OPENSSL_SYS_MACOSX\n#  endif\n#  ifdef OPENSSL_SYSNAME_MACOSX_RHAPSODY\n#   define OPENSSL_SYS_MACOSX_RHAPSODY\n#   define OPENSSL_SYS_MACOSX\n#  endif\n#  ifdef OPENSSL_SYSNAME_SUNOS\n#   define OPENSSL_SYS_SUNOS\n#  endif\n#  if defined(_CRAY) || defined(OPENSSL_SYSNAME_CRAY)\n#   define OPENSSL_SYS_CRAY\n#  endif\n#  if defined(_AIX) || defined(OPENSSL_SYSNAME_AIX)\n#   define OPENSSL_SYS_AIX\n#  endif\n# endif\n\n/* -------------------------------- VOS ----------------------------------- */\n# if defined(__VOS__) || defined(OPENSSL_SYSNAME_VOS)\n#  define OPENSSL_SYS_VOS\n#  ifdef __HPPA__\n#   define OPENSSL_SYS_VOS_HPPA\n#  endif\n#  ifdef __IA32__\n#   define OPENSSL_SYS_VOS_IA32\n#  endif\n# endif\n\n/* ------------------------------ VxWorks --------------------------------- */\n# ifdef OPENSSL_SYSNAME_VXWORKS\n#  define OPENSSL_SYS_VXWORKS\n# endif\n\n/* -------------------------------- BeOS ---------------------------------- */\n# if defined(__BEOS__)\n#  define OPENSSL_SYS_BEOS\n#  include <sys/socket.h>\n#  if defined(BONE_VERSION)\n#   define OPENSSL_SYS_BEOS_BONE\n#  else\n#   define OPENSSL_SYS_BEOS_R5\n#  endif\n# endif\n\n/**\n * That's it for OS-specific stuff\n *****************************************************************************/\n\n/* Specials for I/O an exit */\n# ifdef OPENSSL_SYS_MSDOS\n#  define OPENSSL_UNISTD_IO <io.h>\n#  define OPENSSL_DECLARE_EXIT extern void exit(int);\n# else\n#  define OPENSSL_UNISTD_IO OPENSSL_UNISTD\n#  define OPENSSL_DECLARE_EXIT  /* declared in unistd.h */\n# endif\n\n/*-\n * Definitions of OPENSSL_GLOBAL and OPENSSL_EXTERN, to define and declare\n * certain global symbols that, with some compilers under VMS, have to be\n * defined and declared explicitely with globaldef and globalref.\n * Definitions of OPENSSL_EXPORT and OPENSSL_IMPORT, to define and declare\n * DLL exports and imports for compilers under Win32.  These are a little\n * more complicated to use.  Basically, for any library that exports some\n * global variables, the following code must be present in the header file\n * that declares them, before OPENSSL_EXTERN is used:\n *\n * #ifdef SOME_BUILD_FLAG_MACRO\n * # undef OPENSSL_EXTERN\n * # define OPENSSL_EXTERN OPENSSL_EXPORT\n * #endif\n *\n * The default is to have OPENSSL_EXPORT, OPENSSL_IMPORT and OPENSSL_GLOBAL\n * have some generally sensible values, and for OPENSSL_EXTERN to have the\n * value OPENSSL_IMPORT.\n */\n\n# if defined(OPENSSL_SYS_VMS_NODECC)\n#  define OPENSSL_EXPORT globalref\n#  define OPENSSL_IMPORT globalref\n#  define OPENSSL_GLOBAL globaldef\n# elif defined(OPENSSL_SYS_WINDOWS) && defined(OPENSSL_OPT_WINDLL)\n#  define OPENSSL_EXPORT extern __declspec(dllexport)\n#  define OPENSSL_IMPORT extern __declspec(dllimport)\n#  define OPENSSL_GLOBAL\n# else\n#  define OPENSSL_EXPORT extern\n#  define OPENSSL_IMPORT extern\n#  define OPENSSL_GLOBAL\n# endif\n# define OPENSSL_EXTERN OPENSSL_IMPORT\n\n/*-\n * Macros to allow global variables to be reached through function calls when\n * required (if a shared library version requires it, for example.\n * The way it's done allows definitions like this:\n *\n *      // in foobar.c\n *      OPENSSL_IMPLEMENT_GLOBAL(int,foobar,0)\n *      // in foobar.h\n *      OPENSSL_DECLARE_GLOBAL(int,foobar);\n *      #define foobar OPENSSL_GLOBAL_REF(foobar)\n */\n# ifdef OPENSSL_EXPORT_VAR_AS_FUNCTION\n#  define OPENSSL_IMPLEMENT_GLOBAL(type,name,value)                      \\\n        type *_shadow_##name(void)                                      \\\n        { static type _hide_##name=value; return &_hide_##name; }\n#  define OPENSSL_DECLARE_GLOBAL(type,name) type *_shadow_##name(void)\n#  define OPENSSL_GLOBAL_REF(name) (*(_shadow_##name()))\n# else\n#  define OPENSSL_IMPLEMENT_GLOBAL(type,name,value) OPENSSL_GLOBAL type _shadow_##name=value;\n#  define OPENSSL_DECLARE_GLOBAL(type,name) OPENSSL_EXPORT type _shadow_##name\n#  define OPENSSL_GLOBAL_REF(name) _shadow_##name\n# endif\n\n# if defined(OPENSSL_SYS_MACINTOSH_CLASSIC) && macintosh==1 && !defined(MAC_OS_GUSI_SOURCE)\n#  define ossl_ssize_t long\n# endif\n\n# ifdef OPENSSL_SYS_MSDOS\n#  define ossl_ssize_t long\n# endif\n\n# if defined(NeXT) || defined(OPENSSL_SYS_NEWS4) || defined(OPENSSL_SYS_SUNOS)\n#  define ssize_t int\n# endif\n\n# if defined(__ultrix) && !defined(ssize_t)\n#  define ossl_ssize_t int\n# endif\n\n# ifndef ossl_ssize_t\n#  define ossl_ssize_t ssize_t\n# endif\n\n#ifdef  __cplusplus\n}\n#endif\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/x86/include/openssl/ebcdic.h",
    "content": "/* crypto/ebcdic.h */\n\n#ifndef HEADER_EBCDIC_H\n# define HEADER_EBCDIC_H\n\n# include <sys/types.h>\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n/* Avoid name clashes with other applications */\n# define os_toascii   _openssl_os_toascii\n# define os_toebcdic  _openssl_os_toebcdic\n# define ebcdic2ascii _openssl_ebcdic2ascii\n# define ascii2ebcdic _openssl_ascii2ebcdic\n\nextern const unsigned char os_toascii[256];\nextern const unsigned char os_toebcdic[256];\nvoid *ebcdic2ascii(void *dest, const void *srce, size_t count);\nvoid *ascii2ebcdic(void *dest, const void *srce, size_t count);\n\n#ifdef  __cplusplus\n}\n#endif\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/x86/include/openssl/ec.h",
    "content": "/* crypto/ec/ec.h */\n/*\n * Originally written by Bodo Moeller for the OpenSSL project.\n */\n/**\n * \\file crypto/ec/ec.h Include file for the OpenSSL EC functions\n * \\author Originally written by Bodo Moeller for the OpenSSL project\n */\n/* ====================================================================\n * Copyright (c) 1998-2005 The OpenSSL Project.  All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n *\n * 1. Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n *\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in\n *    the documentation and/or other materials provided with the\n *    distribution.\n *\n * 3. All advertising materials mentioning features or use of this\n *    software must display the following acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit. (http://www.openssl.org/)\"\n *\n * 4. The names \"OpenSSL Toolkit\" and \"OpenSSL Project\" must not be used to\n *    endorse or promote products derived from this software without\n *    prior written permission. For written permission, please contact\n *    openssl-core@openssl.org.\n *\n * 5. Products derived from this software may not be called \"OpenSSL\"\n *    nor may \"OpenSSL\" appear in their names without prior written\n *    permission of the OpenSSL Project.\n *\n * 6. Redistributions of any form whatsoever must retain the following\n *    acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit (http://www.openssl.org/)\"\n *\n * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY\n * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\n * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR\n * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\n * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,\n * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED\n * OF THE POSSIBILITY OF SUCH DAMAGE.\n * ====================================================================\n *\n * This product includes cryptographic software written by Eric Young\n * (eay@cryptsoft.com).  This product includes software written by Tim\n * Hudson (tjh@cryptsoft.com).\n *\n */\n/* ====================================================================\n * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED.\n *\n * Portions of the attached software (\"Contribution\") are developed by\n * SUN MICROSYSTEMS, INC., and are contributed to the OpenSSL project.\n *\n * The Contribution is licensed pursuant to the OpenSSL open source\n * license provided above.\n *\n * The elliptic curve binary polynomial software is originally written by\n * Sheueling Chang Shantz and Douglas Stebila of Sun Microsystems Laboratories.\n *\n */\n\n#ifndef HEADER_EC_H\n# define HEADER_EC_H\n\n# include <openssl/opensslconf.h>\n\n# ifdef OPENSSL_NO_EC\n#  error EC is disabled.\n# endif\n\n# include <openssl/asn1.h>\n# include <openssl/symhacks.h>\n# ifndef OPENSSL_NO_DEPRECATED\n#  include <openssl/bn.h>\n# endif\n\n# ifdef  __cplusplus\nextern \"C\" {\n# elif defined(__SUNPRO_C)\n#  if __SUNPRO_C >= 0x520\n#   pragma error_messages (off,E_ARRAY_OF_INCOMPLETE_NONAME,E_ARRAY_OF_INCOMPLETE)\n#  endif\n# endif\n\n# ifndef OPENSSL_ECC_MAX_FIELD_BITS\n#  define OPENSSL_ECC_MAX_FIELD_BITS 661\n# endif\n\n/** Enum for the point conversion form as defined in X9.62 (ECDSA)\n *  for the encoding of a elliptic curve point (x,y) */\ntypedef enum {\n        /** the point is encoded as z||x, where the octet z specifies\n         *  which solution of the quadratic equation y is  */\n    POINT_CONVERSION_COMPRESSED = 2,\n        /** the point is encoded as z||x||y, where z is the octet 0x04  */\n    POINT_CONVERSION_UNCOMPRESSED = 4,\n        /** the point is encoded as z||x||y, where the octet z specifies\n         *  which solution of the quadratic equation y is  */\n    POINT_CONVERSION_HYBRID = 6\n} point_conversion_form_t;\n\ntypedef struct ec_method_st EC_METHOD;\n\ntypedef struct ec_group_st\n    /*-\n     EC_METHOD *meth;\n     -- field definition\n     -- curve coefficients\n     -- optional generator with associated information (order, cofactor)\n     -- optional extra data (precomputed table for fast computation of multiples of generator)\n     -- ASN1 stuff\n    */\n    EC_GROUP;\n\ntypedef struct ec_point_st EC_POINT;\n\n/********************************************************************/\n/*               EC_METHODs for curves over GF(p)                   */\n/********************************************************************/\n\n/** Returns the basic GFp ec methods which provides the basis for the\n *  optimized methods.\n *  \\return  EC_METHOD object\n */\nconst EC_METHOD *EC_GFp_simple_method(void);\n\n/** Returns GFp methods using montgomery multiplication.\n *  \\return  EC_METHOD object\n */\nconst EC_METHOD *EC_GFp_mont_method(void);\n\n/** Returns GFp methods using optimized methods for NIST recommended curves\n *  \\return  EC_METHOD object\n */\nconst EC_METHOD *EC_GFp_nist_method(void);\n\n# ifndef OPENSSL_NO_EC_NISTP_64_GCC_128\n/** Returns 64-bit optimized methods for nistp224\n *  \\return  EC_METHOD object\n */\nconst EC_METHOD *EC_GFp_nistp224_method(void);\n\n/** Returns 64-bit optimized methods for nistp256\n *  \\return  EC_METHOD object\n */\nconst EC_METHOD *EC_GFp_nistp256_method(void);\n\n/** Returns 64-bit optimized methods for nistp521\n *  \\return  EC_METHOD object\n */\nconst EC_METHOD *EC_GFp_nistp521_method(void);\n# endif\n\n# ifndef OPENSSL_NO_EC2M\n/********************************************************************/\n/*           EC_METHOD for curves over GF(2^m)                      */\n/********************************************************************/\n\n/** Returns the basic GF2m ec method\n *  \\return  EC_METHOD object\n */\nconst EC_METHOD *EC_GF2m_simple_method(void);\n\n# endif\n\n/********************************************************************/\n/*                   EC_GROUP functions                             */\n/********************************************************************/\n\n/** Creates a new EC_GROUP object\n *  \\param   meth  EC_METHOD to use\n *  \\return  newly created EC_GROUP object or NULL in case of an error.\n */\nEC_GROUP *EC_GROUP_new(const EC_METHOD *meth);\n\n/** Frees a EC_GROUP object\n *  \\param  group  EC_GROUP object to be freed.\n */\nvoid EC_GROUP_free(EC_GROUP *group);\n\n/** Clears and frees a EC_GROUP object\n *  \\param  group  EC_GROUP object to be cleared and freed.\n */\nvoid EC_GROUP_clear_free(EC_GROUP *group);\n\n/** Copies EC_GROUP objects. Note: both EC_GROUPs must use the same EC_METHOD.\n *  \\param  dst  destination EC_GROUP object\n *  \\param  src  source EC_GROUP object\n *  \\return 1 on success and 0 if an error occurred.\n */\nint EC_GROUP_copy(EC_GROUP *dst, const EC_GROUP *src);\n\n/** Creates a new EC_GROUP object and copies the copies the content\n *  form src to the newly created EC_KEY object\n *  \\param  src  source EC_GROUP object\n *  \\return newly created EC_GROUP object or NULL in case of an error.\n */\nEC_GROUP *EC_GROUP_dup(const EC_GROUP *src);\n\n/** Returns the EC_METHOD of the EC_GROUP object.\n *  \\param  group  EC_GROUP object\n *  \\return EC_METHOD used in this EC_GROUP object.\n */\nconst EC_METHOD *EC_GROUP_method_of(const EC_GROUP *group);\n\n/** Returns the field type of the EC_METHOD.\n *  \\param  meth  EC_METHOD object\n *  \\return NID of the underlying field type OID.\n */\nint EC_METHOD_get_field_type(const EC_METHOD *meth);\n\n/** Sets the generator and it's order/cofactor of a EC_GROUP object.\n *  \\param  group      EC_GROUP object\n *  \\param  generator  EC_POINT object with the generator.\n *  \\param  order      the order of the group generated by the generator.\n *  \\param  cofactor   the index of the sub-group generated by the generator\n *                     in the group of all points on the elliptic curve.\n *  \\return 1 on success and 0 if an error occured\n */\nint EC_GROUP_set_generator(EC_GROUP *group, const EC_POINT *generator,\n                           const BIGNUM *order, const BIGNUM *cofactor);\n\n/** Returns the generator of a EC_GROUP object.\n *  \\param  group  EC_GROUP object\n *  \\return the currently used generator (possibly NULL).\n */\nconst EC_POINT *EC_GROUP_get0_generator(const EC_GROUP *group);\n\n/** Returns the montgomery data for order(Generator)\n *  \\param  group  EC_GROUP object\n *  \\return the currently used generator (possibly NULL).\n*/\nBN_MONT_CTX *EC_GROUP_get_mont_data(const EC_GROUP *group);\n\n/** Gets the order of a EC_GROUP\n *  \\param  group  EC_GROUP object\n *  \\param  order  BIGNUM to which the order is copied\n *  \\param  ctx    BN_CTX object (optional)\n *  \\return 1 on success and 0 if an error occured\n */\nint EC_GROUP_get_order(const EC_GROUP *group, BIGNUM *order, BN_CTX *ctx);\n\n/** Gets the cofactor of a EC_GROUP\n *  \\param  group     EC_GROUP object\n *  \\param  cofactor  BIGNUM to which the cofactor is copied\n *  \\param  ctx       BN_CTX object (optional)\n *  \\return 1 on success and 0 if an error occured\n */\nint EC_GROUP_get_cofactor(const EC_GROUP *group, BIGNUM *cofactor,\n                          BN_CTX *ctx);\n\n/** Sets the name of a EC_GROUP object\n *  \\param  group  EC_GROUP object\n *  \\param  nid    NID of the curve name OID\n */\nvoid EC_GROUP_set_curve_name(EC_GROUP *group, int nid);\n\n/** Returns the curve name of a EC_GROUP object\n *  \\param  group  EC_GROUP object\n *  \\return NID of the curve name OID or 0 if not set.\n */\nint EC_GROUP_get_curve_name(const EC_GROUP *group);\n\nvoid EC_GROUP_set_asn1_flag(EC_GROUP *group, int flag);\nint EC_GROUP_get_asn1_flag(const EC_GROUP *group);\n\nvoid EC_GROUP_set_point_conversion_form(EC_GROUP *group,\n                                        point_conversion_form_t form);\npoint_conversion_form_t EC_GROUP_get_point_conversion_form(const EC_GROUP *);\n\nunsigned char *EC_GROUP_get0_seed(const EC_GROUP *x);\nsize_t EC_GROUP_get_seed_len(const EC_GROUP *);\nsize_t EC_GROUP_set_seed(EC_GROUP *, const unsigned char *, size_t len);\n\n/** Sets the parameter of a ec over GFp defined by y^2 = x^3 + a*x + b\n *  \\param  group  EC_GROUP object\n *  \\param  p      BIGNUM with the prime number\n *  \\param  a      BIGNUM with parameter a of the equation\n *  \\param  b      BIGNUM with parameter b of the equation\n *  \\param  ctx    BN_CTX object (optional)\n *  \\return 1 on success and 0 if an error occured\n */\nint EC_GROUP_set_curve_GFp(EC_GROUP *group, const BIGNUM *p, const BIGNUM *a,\n                           const BIGNUM *b, BN_CTX *ctx);\n\n/** Gets the parameter of the ec over GFp defined by y^2 = x^3 + a*x + b\n *  \\param  group  EC_GROUP object\n *  \\param  p      BIGNUM for the prime number\n *  \\param  a      BIGNUM for parameter a of the equation\n *  \\param  b      BIGNUM for parameter b of the equation\n *  \\param  ctx    BN_CTX object (optional)\n *  \\return 1 on success and 0 if an error occured\n */\nint EC_GROUP_get_curve_GFp(const EC_GROUP *group, BIGNUM *p, BIGNUM *a,\n                           BIGNUM *b, BN_CTX *ctx);\n\n# ifndef OPENSSL_NO_EC2M\n/** Sets the parameter of a ec over GF2m defined by y^2 + x*y = x^3 + a*x^2 + b\n *  \\param  group  EC_GROUP object\n *  \\param  p      BIGNUM with the polynomial defining the underlying field\n *  \\param  a      BIGNUM with parameter a of the equation\n *  \\param  b      BIGNUM with parameter b of the equation\n *  \\param  ctx    BN_CTX object (optional)\n *  \\return 1 on success and 0 if an error occured\n */\nint EC_GROUP_set_curve_GF2m(EC_GROUP *group, const BIGNUM *p, const BIGNUM *a,\n                            const BIGNUM *b, BN_CTX *ctx);\n\n/** Gets the parameter of the ec over GF2m defined by y^2 + x*y = x^3 + a*x^2 + b\n *  \\param  group  EC_GROUP object\n *  \\param  p      BIGNUM for the polynomial defining the underlying field\n *  \\param  a      BIGNUM for parameter a of the equation\n *  \\param  b      BIGNUM for parameter b of the equation\n *  \\param  ctx    BN_CTX object (optional)\n *  \\return 1 on success and 0 if an error occured\n */\nint EC_GROUP_get_curve_GF2m(const EC_GROUP *group, BIGNUM *p, BIGNUM *a,\n                            BIGNUM *b, BN_CTX *ctx);\n# endif\n/** Returns the number of bits needed to represent a field element\n *  \\param  group  EC_GROUP object\n *  \\return number of bits needed to represent a field element\n */\nint EC_GROUP_get_degree(const EC_GROUP *group);\n\n/** Checks whether the parameter in the EC_GROUP define a valid ec group\n *  \\param  group  EC_GROUP object\n *  \\param  ctx    BN_CTX object (optional)\n *  \\return 1 if group is a valid ec group and 0 otherwise\n */\nint EC_GROUP_check(const EC_GROUP *group, BN_CTX *ctx);\n\n/** Checks whether the discriminant of the elliptic curve is zero or not\n *  \\param  group  EC_GROUP object\n *  \\param  ctx    BN_CTX object (optional)\n *  \\return 1 if the discriminant is not zero and 0 otherwise\n */\nint EC_GROUP_check_discriminant(const EC_GROUP *group, BN_CTX *ctx);\n\n/** Compares two EC_GROUP objects\n *  \\param  a    first EC_GROUP object\n *  \\param  b    second EC_GROUP object\n *  \\param  ctx  BN_CTX object (optional)\n *  \\return 0 if both groups are equal and 1 otherwise\n */\nint EC_GROUP_cmp(const EC_GROUP *a, const EC_GROUP *b, BN_CTX *ctx);\n\n/*\n * EC_GROUP_new_GF*() calls EC_GROUP_new() and EC_GROUP_set_GF*() after\n * choosing an appropriate EC_METHOD\n */\n\n/** Creates a new EC_GROUP object with the specified parameters defined\n *  over GFp (defined by the equation y^2 = x^3 + a*x + b)\n *  \\param  p    BIGNUM with the prime number\n *  \\param  a    BIGNUM with the parameter a of the equation\n *  \\param  b    BIGNUM with the parameter b of the equation\n *  \\param  ctx  BN_CTX object (optional)\n *  \\return newly created EC_GROUP object with the specified parameters\n */\nEC_GROUP *EC_GROUP_new_curve_GFp(const BIGNUM *p, const BIGNUM *a,\n                                 const BIGNUM *b, BN_CTX *ctx);\n# ifndef OPENSSL_NO_EC2M\n/** Creates a new EC_GROUP object with the specified parameters defined\n *  over GF2m (defined by the equation y^2 + x*y = x^3 + a*x^2 + b)\n *  \\param  p    BIGNUM with the polynomial defining the underlying field\n *  \\param  a    BIGNUM with the parameter a of the equation\n *  \\param  b    BIGNUM with the parameter b of the equation\n *  \\param  ctx  BN_CTX object (optional)\n *  \\return newly created EC_GROUP object with the specified parameters\n */\nEC_GROUP *EC_GROUP_new_curve_GF2m(const BIGNUM *p, const BIGNUM *a,\n                                  const BIGNUM *b, BN_CTX *ctx);\n# endif\n/** Creates a EC_GROUP object with a curve specified by a NID\n *  \\param  nid  NID of the OID of the curve name\n *  \\return newly created EC_GROUP object with specified curve or NULL\n *          if an error occurred\n */\nEC_GROUP *EC_GROUP_new_by_curve_name(int nid);\n\n/********************************************************************/\n/*               handling of internal curves                        */\n/********************************************************************/\n\ntypedef struct {\n    int nid;\n    const char *comment;\n} EC_builtin_curve;\n\n/*\n * EC_builtin_curves(EC_builtin_curve *r, size_t size) returns number of all\n * available curves or zero if a error occurred. In case r ist not zero\n * nitems EC_builtin_curve structures are filled with the data of the first\n * nitems internal groups\n */\nsize_t EC_get_builtin_curves(EC_builtin_curve *r, size_t nitems);\n\nconst char *EC_curve_nid2nist(int nid);\nint EC_curve_nist2nid(const char *name);\n\n/********************************************************************/\n/*                    EC_POINT functions                            */\n/********************************************************************/\n\n/** Creates a new EC_POINT object for the specified EC_GROUP\n *  \\param  group  EC_GROUP the underlying EC_GROUP object\n *  \\return newly created EC_POINT object or NULL if an error occurred\n */\nEC_POINT *EC_POINT_new(const EC_GROUP *group);\n\n/** Frees a EC_POINT object\n *  \\param  point  EC_POINT object to be freed\n */\nvoid EC_POINT_free(EC_POINT *point);\n\n/** Clears and frees a EC_POINT object\n *  \\param  point  EC_POINT object to be cleared and freed\n */\nvoid EC_POINT_clear_free(EC_POINT *point);\n\n/** Copies EC_POINT object\n *  \\param  dst  destination EC_POINT object\n *  \\param  src  source EC_POINT object\n *  \\return 1 on success and 0 if an error occured\n */\nint EC_POINT_copy(EC_POINT *dst, const EC_POINT *src);\n\n/** Creates a new EC_POINT object and copies the content of the supplied\n *  EC_POINT\n *  \\param  src    source EC_POINT object\n *  \\param  group  underlying the EC_GROUP object\n *  \\return newly created EC_POINT object or NULL if an error occurred\n */\nEC_POINT *EC_POINT_dup(const EC_POINT *src, const EC_GROUP *group);\n\n/** Returns the EC_METHOD used in EC_POINT object\n *  \\param  point  EC_POINT object\n *  \\return the EC_METHOD used\n */\nconst EC_METHOD *EC_POINT_method_of(const EC_POINT *point);\n\n/** Sets a point to infinity (neutral element)\n *  \\param  group  underlying EC_GROUP object\n *  \\param  point  EC_POINT to set to infinity\n *  \\return 1 on success and 0 if an error occured\n */\nint EC_POINT_set_to_infinity(const EC_GROUP *group, EC_POINT *point);\n\n/** Sets the jacobian projective coordinates of a EC_POINT over GFp\n *  \\param  group  underlying EC_GROUP object\n *  \\param  p      EC_POINT object\n *  \\param  x      BIGNUM with the x-coordinate\n *  \\param  y      BIGNUM with the y-coordinate\n *  \\param  z      BIGNUM with the z-coordinate\n *  \\param  ctx    BN_CTX object (optional)\n *  \\return 1 on success and 0 if an error occured\n */\nint EC_POINT_set_Jprojective_coordinates_GFp(const EC_GROUP *group,\n                                             EC_POINT *p, const BIGNUM *x,\n                                             const BIGNUM *y, const BIGNUM *z,\n                                             BN_CTX *ctx);\n\n/** Gets the jacobian projective coordinates of a EC_POINT over GFp\n *  \\param  group  underlying EC_GROUP object\n *  \\param  p      EC_POINT object\n *  \\param  x      BIGNUM for the x-coordinate\n *  \\param  y      BIGNUM for the y-coordinate\n *  \\param  z      BIGNUM for the z-coordinate\n *  \\param  ctx    BN_CTX object (optional)\n *  \\return 1 on success and 0 if an error occured\n */\nint EC_POINT_get_Jprojective_coordinates_GFp(const EC_GROUP *group,\n                                             const EC_POINT *p, BIGNUM *x,\n                                             BIGNUM *y, BIGNUM *z,\n                                             BN_CTX *ctx);\n\n/** Sets the affine coordinates of a EC_POINT over GFp\n *  \\param  group  underlying EC_GROUP object\n *  \\param  p      EC_POINT object\n *  \\param  x      BIGNUM with the x-coordinate\n *  \\param  y      BIGNUM with the y-coordinate\n *  \\param  ctx    BN_CTX object (optional)\n *  \\return 1 on success and 0 if an error occured\n */\nint EC_POINT_set_affine_coordinates_GFp(const EC_GROUP *group, EC_POINT *p,\n                                        const BIGNUM *x, const BIGNUM *y,\n                                        BN_CTX *ctx);\n\n/** Gets the affine coordinates of a EC_POINT over GFp\n *  \\param  group  underlying EC_GROUP object\n *  \\param  p      EC_POINT object\n *  \\param  x      BIGNUM for the x-coordinate\n *  \\param  y      BIGNUM for the y-coordinate\n *  \\param  ctx    BN_CTX object (optional)\n *  \\return 1 on success and 0 if an error occured\n */\nint EC_POINT_get_affine_coordinates_GFp(const EC_GROUP *group,\n                                        const EC_POINT *p, BIGNUM *x,\n                                        BIGNUM *y, BN_CTX *ctx);\n\n/** Sets the x9.62 compressed coordinates of a EC_POINT over GFp\n *  \\param  group  underlying EC_GROUP object\n *  \\param  p      EC_POINT object\n *  \\param  x      BIGNUM with x-coordinate\n *  \\param  y_bit  integer with the y-Bit (either 0 or 1)\n *  \\param  ctx    BN_CTX object (optional)\n *  \\return 1 on success and 0 if an error occured\n */\nint EC_POINT_set_compressed_coordinates_GFp(const EC_GROUP *group,\n                                            EC_POINT *p, const BIGNUM *x,\n                                            int y_bit, BN_CTX *ctx);\n# ifndef OPENSSL_NO_EC2M\n/** Sets the affine coordinates of a EC_POINT over GF2m\n *  \\param  group  underlying EC_GROUP object\n *  \\param  p      EC_POINT object\n *  \\param  x      BIGNUM with the x-coordinate\n *  \\param  y      BIGNUM with the y-coordinate\n *  \\param  ctx    BN_CTX object (optional)\n *  \\return 1 on success and 0 if an error occured\n */\nint EC_POINT_set_affine_coordinates_GF2m(const EC_GROUP *group, EC_POINT *p,\n                                         const BIGNUM *x, const BIGNUM *y,\n                                         BN_CTX *ctx);\n\n/** Gets the affine coordinates of a EC_POINT over GF2m\n *  \\param  group  underlying EC_GROUP object\n *  \\param  p      EC_POINT object\n *  \\param  x      BIGNUM for the x-coordinate\n *  \\param  y      BIGNUM for the y-coordinate\n *  \\param  ctx    BN_CTX object (optional)\n *  \\return 1 on success and 0 if an error occured\n */\nint EC_POINT_get_affine_coordinates_GF2m(const EC_GROUP *group,\n                                         const EC_POINT *p, BIGNUM *x,\n                                         BIGNUM *y, BN_CTX *ctx);\n\n/** Sets the x9.62 compressed coordinates of a EC_POINT over GF2m\n *  \\param  group  underlying EC_GROUP object\n *  \\param  p      EC_POINT object\n *  \\param  x      BIGNUM with x-coordinate\n *  \\param  y_bit  integer with the y-Bit (either 0 or 1)\n *  \\param  ctx    BN_CTX object (optional)\n *  \\return 1 on success and 0 if an error occured\n */\nint EC_POINT_set_compressed_coordinates_GF2m(const EC_GROUP *group,\n                                             EC_POINT *p, const BIGNUM *x,\n                                             int y_bit, BN_CTX *ctx);\n# endif\n/** Encodes a EC_POINT object to a octet string\n *  \\param  group  underlying EC_GROUP object\n *  \\param  p      EC_POINT object\n *  \\param  form   point conversion form\n *  \\param  buf    memory buffer for the result. If NULL the function returns\n *                 required buffer size.\n *  \\param  len    length of the memory buffer\n *  \\param  ctx    BN_CTX object (optional)\n *  \\return the length of the encoded octet string or 0 if an error occurred\n */\nsize_t EC_POINT_point2oct(const EC_GROUP *group, const EC_POINT *p,\n                          point_conversion_form_t form,\n                          unsigned char *buf, size_t len, BN_CTX *ctx);\n\n/** Decodes a EC_POINT from a octet string\n *  \\param  group  underlying EC_GROUP object\n *  \\param  p      EC_POINT object\n *  \\param  buf    memory buffer with the encoded ec point\n *  \\param  len    length of the encoded ec point\n *  \\param  ctx    BN_CTX object (optional)\n *  \\return 1 on success and 0 if an error occured\n */\nint EC_POINT_oct2point(const EC_GROUP *group, EC_POINT *p,\n                       const unsigned char *buf, size_t len, BN_CTX *ctx);\n\n/* other interfaces to point2oct/oct2point: */\nBIGNUM *EC_POINT_point2bn(const EC_GROUP *, const EC_POINT *,\n                          point_conversion_form_t form, BIGNUM *, BN_CTX *);\nEC_POINT *EC_POINT_bn2point(const EC_GROUP *, const BIGNUM *,\n                            EC_POINT *, BN_CTX *);\nchar *EC_POINT_point2hex(const EC_GROUP *, const EC_POINT *,\n                         point_conversion_form_t form, BN_CTX *);\nEC_POINT *EC_POINT_hex2point(const EC_GROUP *, const char *,\n                             EC_POINT *, BN_CTX *);\n\n/********************************************************************/\n/*         functions for doing EC_POINT arithmetic                  */\n/********************************************************************/\n\n/** Computes the sum of two EC_POINT\n *  \\param  group  underlying EC_GROUP object\n *  \\param  r      EC_POINT object for the result (r = a + b)\n *  \\param  a      EC_POINT object with the first summand\n *  \\param  b      EC_POINT object with the second summand\n *  \\param  ctx    BN_CTX object (optional)\n *  \\return 1 on success and 0 if an error occured\n */\nint EC_POINT_add(const EC_GROUP *group, EC_POINT *r, const EC_POINT *a,\n                 const EC_POINT *b, BN_CTX *ctx);\n\n/** Computes the double of a EC_POINT\n *  \\param  group  underlying EC_GROUP object\n *  \\param  r      EC_POINT object for the result (r = 2 * a)\n *  \\param  a      EC_POINT object\n *  \\param  ctx    BN_CTX object (optional)\n *  \\return 1 on success and 0 if an error occured\n */\nint EC_POINT_dbl(const EC_GROUP *group, EC_POINT *r, const EC_POINT *a,\n                 BN_CTX *ctx);\n\n/** Computes the inverse of a EC_POINT\n *  \\param  group  underlying EC_GROUP object\n *  \\param  a      EC_POINT object to be inverted (it's used for the result as well)\n *  \\param  ctx    BN_CTX object (optional)\n *  \\return 1 on success and 0 if an error occured\n */\nint EC_POINT_invert(const EC_GROUP *group, EC_POINT *a, BN_CTX *ctx);\n\n/** Checks whether the point is the neutral element of the group\n *  \\param  group  the underlying EC_GROUP object\n *  \\param  p      EC_POINT object\n *  \\return 1 if the point is the neutral element and 0 otherwise\n */\nint EC_POINT_is_at_infinity(const EC_GROUP *group, const EC_POINT *p);\n\n/** Checks whether the point is on the curve\n *  \\param  group  underlying EC_GROUP object\n *  \\param  point  EC_POINT object to check\n *  \\param  ctx    BN_CTX object (optional)\n *  \\return 1 if point if on the curve and 0 otherwise\n */\nint EC_POINT_is_on_curve(const EC_GROUP *group, const EC_POINT *point,\n                         BN_CTX *ctx);\n\n/** Compares two EC_POINTs\n *  \\param  group  underlying EC_GROUP object\n *  \\param  a      first EC_POINT object\n *  \\param  b      second EC_POINT object\n *  \\param  ctx    BN_CTX object (optional)\n *  \\return 0 if both points are equal and a value != 0 otherwise\n */\nint EC_POINT_cmp(const EC_GROUP *group, const EC_POINT *a, const EC_POINT *b,\n                 BN_CTX *ctx);\n\nint EC_POINT_make_affine(const EC_GROUP *group, EC_POINT *point, BN_CTX *ctx);\nint EC_POINTs_make_affine(const EC_GROUP *group, size_t num,\n                          EC_POINT *points[], BN_CTX *ctx);\n\n/** Computes r = generator * n sum_{i=0}^{num-1} p[i] * m[i]\n *  \\param  group  underlying EC_GROUP object\n *  \\param  r      EC_POINT object for the result\n *  \\param  n      BIGNUM with the multiplier for the group generator (optional)\n *  \\param  num    number futher summands\n *  \\param  p      array of size num of EC_POINT objects\n *  \\param  m      array of size num of BIGNUM objects\n *  \\param  ctx    BN_CTX object (optional)\n *  \\return 1 on success and 0 if an error occured\n */\nint EC_POINTs_mul(const EC_GROUP *group, EC_POINT *r, const BIGNUM *n,\n                  size_t num, const EC_POINT *p[], const BIGNUM *m[],\n                  BN_CTX *ctx);\n\n/** Computes r = generator * n + q * m\n *  \\param  group  underlying EC_GROUP object\n *  \\param  r      EC_POINT object for the result\n *  \\param  n      BIGNUM with the multiplier for the group generator (optional)\n *  \\param  q      EC_POINT object with the first factor of the second summand\n *  \\param  m      BIGNUM with the second factor of the second summand\n *  \\param  ctx    BN_CTX object (optional)\n *  \\return 1 on success and 0 if an error occured\n */\nint EC_POINT_mul(const EC_GROUP *group, EC_POINT *r, const BIGNUM *n,\n                 const EC_POINT *q, const BIGNUM *m, BN_CTX *ctx);\n\n/** Stores multiples of generator for faster point multiplication\n *  \\param  group  EC_GROUP object\n *  \\param  ctx    BN_CTX object (optional)\n *  \\return 1 on success and 0 if an error occured\n */\nint EC_GROUP_precompute_mult(EC_GROUP *group, BN_CTX *ctx);\n\n/** Reports whether a precomputation has been done\n *  \\param  group  EC_GROUP object\n *  \\return 1 if a pre-computation has been done and 0 otherwise\n */\nint EC_GROUP_have_precompute_mult(const EC_GROUP *group);\n\n/********************************************************************/\n/*                       ASN1 stuff                                 */\n/********************************************************************/\n\n/*\n * EC_GROUP_get_basis_type() returns the NID of the basis type used to\n * represent the field elements\n */\nint EC_GROUP_get_basis_type(const EC_GROUP *);\n# ifndef OPENSSL_NO_EC2M\nint EC_GROUP_get_trinomial_basis(const EC_GROUP *, unsigned int *k);\nint EC_GROUP_get_pentanomial_basis(const EC_GROUP *, unsigned int *k1,\n                                   unsigned int *k2, unsigned int *k3);\n# endif\n\n# define OPENSSL_EC_NAMED_CURVE  0x001\n\ntypedef struct ecpk_parameters_st ECPKPARAMETERS;\n\nEC_GROUP *d2i_ECPKParameters(EC_GROUP **, const unsigned char **in, long len);\nint i2d_ECPKParameters(const EC_GROUP *, unsigned char **out);\n\n# define d2i_ECPKParameters_bio(bp,x) ASN1_d2i_bio_of(EC_GROUP,NULL,d2i_ECPKParameters,bp,x)\n# define i2d_ECPKParameters_bio(bp,x) ASN1_i2d_bio_of_const(EC_GROUP,i2d_ECPKParameters,bp,x)\n# define d2i_ECPKParameters_fp(fp,x) (EC_GROUP *)ASN1_d2i_fp(NULL, \\\n                (char *(*)())d2i_ECPKParameters,(fp),(unsigned char **)(x))\n# define i2d_ECPKParameters_fp(fp,x) ASN1_i2d_fp(i2d_ECPKParameters,(fp), \\\n                (unsigned char *)(x))\n\n# ifndef OPENSSL_NO_BIO\nint ECPKParameters_print(BIO *bp, const EC_GROUP *x, int off);\n# endif\n# ifndef OPENSSL_NO_FP_API\nint ECPKParameters_print_fp(FILE *fp, const EC_GROUP *x, int off);\n# endif\n\n/********************************************************************/\n/*                      EC_KEY functions                            */\n/********************************************************************/\n\ntypedef struct ec_key_st EC_KEY;\n\n/* some values for the encoding_flag */\n# define EC_PKEY_NO_PARAMETERS   0x001\n# define EC_PKEY_NO_PUBKEY       0x002\n\n/* some values for the flags field */\n# define EC_FLAG_NON_FIPS_ALLOW  0x1\n# define EC_FLAG_FIPS_CHECKED    0x2\n\n/** Creates a new EC_KEY object.\n *  \\return EC_KEY object or NULL if an error occurred.\n */\nEC_KEY *EC_KEY_new(void);\n\nint EC_KEY_get_flags(const EC_KEY *key);\n\nvoid EC_KEY_set_flags(EC_KEY *key, int flags);\n\nvoid EC_KEY_clear_flags(EC_KEY *key, int flags);\n\n/** Creates a new EC_KEY object using a named curve as underlying\n *  EC_GROUP object.\n *  \\param  nid  NID of the named curve.\n *  \\return EC_KEY object or NULL if an error occurred.\n */\nEC_KEY *EC_KEY_new_by_curve_name(int nid);\n\n/** Frees a EC_KEY object.\n *  \\param  key  EC_KEY object to be freed.\n */\nvoid EC_KEY_free(EC_KEY *key);\n\n/** Copies a EC_KEY object.\n *  \\param  dst  destination EC_KEY object\n *  \\param  src  src EC_KEY object\n *  \\return dst or NULL if an error occurred.\n */\nEC_KEY *EC_KEY_copy(EC_KEY *dst, const EC_KEY *src);\n\n/** Creates a new EC_KEY object and copies the content from src to it.\n *  \\param  src  the source EC_KEY object\n *  \\return newly created EC_KEY object or NULL if an error occurred.\n */\nEC_KEY *EC_KEY_dup(const EC_KEY *src);\n\n/** Increases the internal reference count of a EC_KEY object.\n *  \\param  key  EC_KEY object\n *  \\return 1 on success and 0 if an error occurred.\n */\nint EC_KEY_up_ref(EC_KEY *key);\n\n/** Returns the EC_GROUP object of a EC_KEY object\n *  \\param  key  EC_KEY object\n *  \\return the EC_GROUP object (possibly NULL).\n */\nconst EC_GROUP *EC_KEY_get0_group(const EC_KEY *key);\n\n/** Sets the EC_GROUP of a EC_KEY object.\n *  \\param  key    EC_KEY object\n *  \\param  group  EC_GROUP to use in the EC_KEY object (note: the EC_KEY\n *                 object will use an own copy of the EC_GROUP).\n *  \\return 1 on success and 0 if an error occurred.\n */\nint EC_KEY_set_group(EC_KEY *key, const EC_GROUP *group);\n\n/** Returns the private key of a EC_KEY object.\n *  \\param  key  EC_KEY object\n *  \\return a BIGNUM with the private key (possibly NULL).\n */\nconst BIGNUM *EC_KEY_get0_private_key(const EC_KEY *key);\n\n/** Sets the private key of a EC_KEY object.\n *  \\param  key  EC_KEY object\n *  \\param  prv  BIGNUM with the private key (note: the EC_KEY object\n *               will use an own copy of the BIGNUM).\n *  \\return 1 on success and 0 if an error occurred.\n */\nint EC_KEY_set_private_key(EC_KEY *key, const BIGNUM *prv);\n\n/** Returns the public key of a EC_KEY object.\n *  \\param  key  the EC_KEY object\n *  \\return a EC_POINT object with the public key (possibly NULL)\n */\nconst EC_POINT *EC_KEY_get0_public_key(const EC_KEY *key);\n\n/** Sets the public key of a EC_KEY object.\n *  \\param  key  EC_KEY object\n *  \\param  pub  EC_POINT object with the public key (note: the EC_KEY object\n *               will use an own copy of the EC_POINT object).\n *  \\return 1 on success and 0 if an error occurred.\n */\nint EC_KEY_set_public_key(EC_KEY *key, const EC_POINT *pub);\n\nunsigned EC_KEY_get_enc_flags(const EC_KEY *key);\nvoid EC_KEY_set_enc_flags(EC_KEY *eckey, unsigned int flags);\npoint_conversion_form_t EC_KEY_get_conv_form(const EC_KEY *key);\nvoid EC_KEY_set_conv_form(EC_KEY *eckey, point_conversion_form_t cform);\n/* functions to set/get method specific data  */\nvoid *EC_KEY_get_key_method_data(EC_KEY *key,\n                                 void *(*dup_func) (void *),\n                                 void (*free_func) (void *),\n                                 void (*clear_free_func) (void *));\n/** Sets the key method data of an EC_KEY object, if none has yet been set.\n *  \\param  key              EC_KEY object\n *  \\param  data             opaque data to install.\n *  \\param  dup_func         a function that duplicates |data|.\n *  \\param  free_func        a function that frees |data|.\n *  \\param  clear_free_func  a function that wipes and frees |data|.\n *  \\return the previously set data pointer, or NULL if |data| was inserted.\n */\nvoid *EC_KEY_insert_key_method_data(EC_KEY *key, void *data,\n                                    void *(*dup_func) (void *),\n                                    void (*free_func) (void *),\n                                    void (*clear_free_func) (void *));\n/* wrapper functions for the underlying EC_GROUP object */\nvoid EC_KEY_set_asn1_flag(EC_KEY *eckey, int asn1_flag);\n\n/** Creates a table of pre-computed multiples of the generator to\n *  accelerate further EC_KEY operations.\n *  \\param  key  EC_KEY object\n *  \\param  ctx  BN_CTX object (optional)\n *  \\return 1 on success and 0 if an error occurred.\n */\nint EC_KEY_precompute_mult(EC_KEY *key, BN_CTX *ctx);\n\n/** Creates a new ec private (and optional a new public) key.\n *  \\param  key  EC_KEY object\n *  \\return 1 on success and 0 if an error occurred.\n */\nint EC_KEY_generate_key(EC_KEY *key);\n\n/** Verifies that a private and/or public key is valid.\n *  \\param  key  the EC_KEY object\n *  \\return 1 on success and 0 otherwise.\n */\nint EC_KEY_check_key(const EC_KEY *key);\n\n/** Sets a public key from affine coordindates performing\n *  neccessary NIST PKV tests.\n *  \\param  key  the EC_KEY object\n *  \\param  x    public key x coordinate\n *  \\param  y    public key y coordinate\n *  \\return 1 on success and 0 otherwise.\n */\nint EC_KEY_set_public_key_affine_coordinates(EC_KEY *key, BIGNUM *x,\n                                             BIGNUM *y);\n\n/********************************************************************/\n/*        de- and encoding functions for SEC1 ECPrivateKey          */\n/********************************************************************/\n\n/** Decodes a private key from a memory buffer.\n *  \\param  key  a pointer to a EC_KEY object which should be used (or NULL)\n *  \\param  in   pointer to memory with the DER encoded private key\n *  \\param  len  length of the DER encoded private key\n *  \\return the decoded private key or NULL if an error occurred.\n */\nEC_KEY *d2i_ECPrivateKey(EC_KEY **key, const unsigned char **in, long len);\n\n/** Encodes a private key object and stores the result in a buffer.\n *  \\param  key  the EC_KEY object to encode\n *  \\param  out  the buffer for the result (if NULL the function returns number\n *               of bytes needed).\n *  \\return 1 on success and 0 if an error occurred.\n */\nint i2d_ECPrivateKey(EC_KEY *key, unsigned char **out);\n\n/********************************************************************/\n/*        de- and encoding functions for EC parameters              */\n/********************************************************************/\n\n/** Decodes ec parameter from a memory buffer.\n *  \\param  key  a pointer to a EC_KEY object which should be used (or NULL)\n *  \\param  in   pointer to memory with the DER encoded ec parameters\n *  \\param  len  length of the DER encoded ec parameters\n *  \\return a EC_KEY object with the decoded parameters or NULL if an error\n *          occurred.\n */\nEC_KEY *d2i_ECParameters(EC_KEY **key, const unsigned char **in, long len);\n\n/** Encodes ec parameter and stores the result in a buffer.\n *  \\param  key  the EC_KEY object with ec paramters to encode\n *  \\param  out  the buffer for the result (if NULL the function returns number\n *               of bytes needed).\n *  \\return 1 on success and 0 if an error occurred.\n */\nint i2d_ECParameters(EC_KEY *key, unsigned char **out);\n\n/********************************************************************/\n/*         de- and encoding functions for EC public key             */\n/*         (octet string, not DER -- hence 'o2i' and 'i2o')         */\n/********************************************************************/\n\n/** Decodes a ec public key from a octet string.\n *  \\param  key  a pointer to a EC_KEY object which should be used\n *  \\param  in   memory buffer with the encoded public key\n *  \\param  len  length of the encoded public key\n *  \\return EC_KEY object with decoded public key or NULL if an error\n *          occurred.\n */\nEC_KEY *o2i_ECPublicKey(EC_KEY **key, const unsigned char **in, long len);\n\n/** Encodes a ec public key in an octet string.\n *  \\param  key  the EC_KEY object with the public key\n *  \\param  out  the buffer for the result (if NULL the function returns number\n *               of bytes needed).\n *  \\return 1 on success and 0 if an error occurred\n */\nint i2o_ECPublicKey(EC_KEY *key, unsigned char **out);\n\n# ifndef OPENSSL_NO_BIO\n/** Prints out the ec parameters on human readable form.\n *  \\param  bp   BIO object to which the information is printed\n *  \\param  key  EC_KEY object\n *  \\return 1 on success and 0 if an error occurred\n */\nint ECParameters_print(BIO *bp, const EC_KEY *key);\n\n/** Prints out the contents of a EC_KEY object\n *  \\param  bp   BIO object to which the information is printed\n *  \\param  key  EC_KEY object\n *  \\param  off  line offset\n *  \\return 1 on success and 0 if an error occurred\n */\nint EC_KEY_print(BIO *bp, const EC_KEY *key, int off);\n\n# endif\n# ifndef OPENSSL_NO_FP_API\n/** Prints out the ec parameters on human readable form.\n *  \\param  fp   file descriptor to which the information is printed\n *  \\param  key  EC_KEY object\n *  \\return 1 on success and 0 if an error occurred\n */\nint ECParameters_print_fp(FILE *fp, const EC_KEY *key);\n\n/** Prints out the contents of a EC_KEY object\n *  \\param  fp   file descriptor to which the information is printed\n *  \\param  key  EC_KEY object\n *  \\param  off  line offset\n *  \\return 1 on success and 0 if an error occurred\n */\nint EC_KEY_print_fp(FILE *fp, const EC_KEY *key, int off);\n\n# endif\n\n# define ECParameters_dup(x) ASN1_dup_of(EC_KEY,i2d_ECParameters,d2i_ECParameters,x)\n\n# ifndef __cplusplus\n#  if defined(__SUNPRO_C)\n#   if __SUNPRO_C >= 0x520\n#    pragma error_messages (default,E_ARRAY_OF_INCOMPLETE_NONAME,E_ARRAY_OF_INCOMPLETE)\n#   endif\n#  endif\n# endif\n\n# define EVP_PKEY_CTX_set_ec_paramgen_curve_nid(ctx, nid) \\\n        EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_EC, \\\n                                EVP_PKEY_OP_PARAMGEN|EVP_PKEY_OP_KEYGEN, \\\n                                EVP_PKEY_CTRL_EC_PARAMGEN_CURVE_NID, nid, NULL)\n\n# define EVP_PKEY_CTX_set_ec_param_enc(ctx, flag) \\\n        EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_EC, \\\n                                EVP_PKEY_OP_PARAMGEN|EVP_PKEY_OP_KEYGEN, \\\n                                EVP_PKEY_CTRL_EC_PARAM_ENC, flag, NULL)\n\n# define EVP_PKEY_CTX_set_ecdh_cofactor_mode(ctx, flag) \\\n        EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_EC, \\\n                                EVP_PKEY_OP_DERIVE, \\\n                                EVP_PKEY_CTRL_EC_ECDH_COFACTOR, flag, NULL)\n\n# define EVP_PKEY_CTX_get_ecdh_cofactor_mode(ctx) \\\n        EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_EC, \\\n                                EVP_PKEY_OP_DERIVE, \\\n                                EVP_PKEY_CTRL_EC_ECDH_COFACTOR, -2, NULL)\n\n# define EVP_PKEY_CTX_set_ecdh_kdf_type(ctx, kdf) \\\n        EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_EC, \\\n                                EVP_PKEY_OP_DERIVE, \\\n                                EVP_PKEY_CTRL_EC_KDF_TYPE, kdf, NULL)\n\n# define EVP_PKEY_CTX_get_ecdh_kdf_type(ctx) \\\n        EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_EC, \\\n                                EVP_PKEY_OP_DERIVE, \\\n                                EVP_PKEY_CTRL_EC_KDF_TYPE, -2, NULL)\n\n# define EVP_PKEY_CTX_set_ecdh_kdf_md(ctx, md) \\\n        EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_EC, \\\n                                EVP_PKEY_OP_DERIVE, \\\n                                EVP_PKEY_CTRL_EC_KDF_MD, 0, (void *)md)\n\n# define EVP_PKEY_CTX_get_ecdh_kdf_md(ctx, pmd) \\\n        EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_EC, \\\n                                EVP_PKEY_OP_DERIVE, \\\n                                EVP_PKEY_CTRL_GET_EC_KDF_MD, 0, (void *)pmd)\n\n# define EVP_PKEY_CTX_set_ecdh_kdf_outlen(ctx, len) \\\n        EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_EC, \\\n                                EVP_PKEY_OP_DERIVE, \\\n                                EVP_PKEY_CTRL_EC_KDF_OUTLEN, len, NULL)\n\n# define EVP_PKEY_CTX_get_ecdh_kdf_outlen(ctx, plen) \\\n        EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_EC, \\\n                                EVP_PKEY_OP_DERIVE, \\\n                        EVP_PKEY_CTRL_GET_EC_KDF_OUTLEN, 0, (void *)plen)\n\n# define EVP_PKEY_CTX_set0_ecdh_kdf_ukm(ctx, p, plen) \\\n        EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_EC, \\\n                                EVP_PKEY_OP_DERIVE, \\\n                                EVP_PKEY_CTRL_EC_KDF_UKM, plen, (void *)p)\n\n# define EVP_PKEY_CTX_get0_ecdh_kdf_ukm(ctx, p) \\\n        EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_EC, \\\n                                EVP_PKEY_OP_DERIVE, \\\n                                EVP_PKEY_CTRL_GET_EC_KDF_UKM, 0, (void *)p)\n\n# define EVP_PKEY_CTRL_EC_PARAMGEN_CURVE_NID             (EVP_PKEY_ALG_CTRL + 1)\n# define EVP_PKEY_CTRL_EC_PARAM_ENC                      (EVP_PKEY_ALG_CTRL + 2)\n# define EVP_PKEY_CTRL_EC_ECDH_COFACTOR                  (EVP_PKEY_ALG_CTRL + 3)\n# define EVP_PKEY_CTRL_EC_KDF_TYPE                       (EVP_PKEY_ALG_CTRL + 4)\n# define EVP_PKEY_CTRL_EC_KDF_MD                         (EVP_PKEY_ALG_CTRL + 5)\n# define EVP_PKEY_CTRL_GET_EC_KDF_MD                     (EVP_PKEY_ALG_CTRL + 6)\n# define EVP_PKEY_CTRL_EC_KDF_OUTLEN                     (EVP_PKEY_ALG_CTRL + 7)\n# define EVP_PKEY_CTRL_GET_EC_KDF_OUTLEN                 (EVP_PKEY_ALG_CTRL + 8)\n# define EVP_PKEY_CTRL_EC_KDF_UKM                        (EVP_PKEY_ALG_CTRL + 9)\n# define EVP_PKEY_CTRL_GET_EC_KDF_UKM                    (EVP_PKEY_ALG_CTRL + 10)\n/* KDF types */\n# define EVP_PKEY_ECDH_KDF_NONE                          1\n# define EVP_PKEY_ECDH_KDF_X9_62                         2\n\n/* BEGIN ERROR CODES */\n/*\n * The following lines are auto generated by the script mkerr.pl. Any changes\n * made after this point may be overwritten when the script is next run.\n */\nvoid ERR_load_EC_strings(void);\n\n/* Error codes for the EC functions. */\n\n/* Function codes. */\n# define EC_F_BN_TO_FELEM                                 224\n# define EC_F_COMPUTE_WNAF                                143\n# define EC_F_D2I_ECPARAMETERS                            144\n# define EC_F_D2I_ECPKPARAMETERS                          145\n# define EC_F_D2I_ECPRIVATEKEY                            146\n# define EC_F_DO_EC_KEY_PRINT                             221\n# define EC_F_ECDH_CMS_DECRYPT                            238\n# define EC_F_ECDH_CMS_SET_SHARED_INFO                    239\n# define EC_F_ECKEY_PARAM2TYPE                            223\n# define EC_F_ECKEY_PARAM_DECODE                          212\n# define EC_F_ECKEY_PRIV_DECODE                           213\n# define EC_F_ECKEY_PRIV_ENCODE                           214\n# define EC_F_ECKEY_PUB_DECODE                            215\n# define EC_F_ECKEY_PUB_ENCODE                            216\n# define EC_F_ECKEY_TYPE2PARAM                            220\n# define EC_F_ECPARAMETERS_PRINT                          147\n# define EC_F_ECPARAMETERS_PRINT_FP                       148\n# define EC_F_ECPKPARAMETERS_PRINT                        149\n# define EC_F_ECPKPARAMETERS_PRINT_FP                     150\n# define EC_F_ECP_NISTZ256_GET_AFFINE                     240\n# define EC_F_ECP_NISTZ256_MULT_PRECOMPUTE                243\n# define EC_F_ECP_NISTZ256_POINTS_MUL                     241\n# define EC_F_ECP_NISTZ256_PRE_COMP_NEW                   244\n# define EC_F_ECP_NISTZ256_SET_WORDS                      245\n# define EC_F_ECP_NISTZ256_WINDOWED_MUL                   242\n# define EC_F_ECP_NIST_MOD_192                            203\n# define EC_F_ECP_NIST_MOD_224                            204\n# define EC_F_ECP_NIST_MOD_256                            205\n# define EC_F_ECP_NIST_MOD_521                            206\n# define EC_F_EC_ASN1_GROUP2CURVE                         153\n# define EC_F_EC_ASN1_GROUP2FIELDID                       154\n# define EC_F_EC_ASN1_GROUP2PARAMETERS                    155\n# define EC_F_EC_ASN1_GROUP2PKPARAMETERS                  156\n# define EC_F_EC_ASN1_PARAMETERS2GROUP                    157\n# define EC_F_EC_ASN1_PKPARAMETERS2GROUP                  158\n# define EC_F_EC_EX_DATA_SET_DATA                         211\n# define EC_F_EC_GF2M_MONTGOMERY_POINT_MULTIPLY           208\n# define EC_F_EC_GF2M_SIMPLE_GROUP_CHECK_DISCRIMINANT     159\n# define EC_F_EC_GF2M_SIMPLE_GROUP_SET_CURVE              195\n# define EC_F_EC_GF2M_SIMPLE_OCT2POINT                    160\n# define EC_F_EC_GF2M_SIMPLE_POINT2OCT                    161\n# define EC_F_EC_GF2M_SIMPLE_POINT_GET_AFFINE_COORDINATES 162\n# define EC_F_EC_GF2M_SIMPLE_POINT_SET_AFFINE_COORDINATES 163\n# define EC_F_EC_GF2M_SIMPLE_SET_COMPRESSED_COORDINATES   164\n# define EC_F_EC_GFP_MONT_FIELD_DECODE                    133\n# define EC_F_EC_GFP_MONT_FIELD_ENCODE                    134\n# define EC_F_EC_GFP_MONT_FIELD_MUL                       131\n# define EC_F_EC_GFP_MONT_FIELD_SET_TO_ONE                209\n# define EC_F_EC_GFP_MONT_FIELD_SQR                       132\n# define EC_F_EC_GFP_MONT_GROUP_SET_CURVE                 189\n# define EC_F_EC_GFP_MONT_GROUP_SET_CURVE_GFP             135\n# define EC_F_EC_GFP_NISTP224_GROUP_SET_CURVE             225\n# define EC_F_EC_GFP_NISTP224_POINTS_MUL                  228\n# define EC_F_EC_GFP_NISTP224_POINT_GET_AFFINE_COORDINATES 226\n# define EC_F_EC_GFP_NISTP256_GROUP_SET_CURVE             230\n# define EC_F_EC_GFP_NISTP256_POINTS_MUL                  231\n# define EC_F_EC_GFP_NISTP256_POINT_GET_AFFINE_COORDINATES 232\n# define EC_F_EC_GFP_NISTP521_GROUP_SET_CURVE             233\n# define EC_F_EC_GFP_NISTP521_POINTS_MUL                  234\n# define EC_F_EC_GFP_NISTP521_POINT_GET_AFFINE_COORDINATES 235\n# define EC_F_EC_GFP_NIST_FIELD_MUL                       200\n# define EC_F_EC_GFP_NIST_FIELD_SQR                       201\n# define EC_F_EC_GFP_NIST_GROUP_SET_CURVE                 202\n# define EC_F_EC_GFP_SIMPLE_GROUP_CHECK_DISCRIMINANT      165\n# define EC_F_EC_GFP_SIMPLE_GROUP_SET_CURVE               166\n# define EC_F_EC_GFP_SIMPLE_GROUP_SET_CURVE_GFP           100\n# define EC_F_EC_GFP_SIMPLE_GROUP_SET_GENERATOR           101\n# define EC_F_EC_GFP_SIMPLE_MAKE_AFFINE                   102\n# define EC_F_EC_GFP_SIMPLE_OCT2POINT                     103\n# define EC_F_EC_GFP_SIMPLE_POINT2OCT                     104\n# define EC_F_EC_GFP_SIMPLE_POINTS_MAKE_AFFINE            137\n# define EC_F_EC_GFP_SIMPLE_POINT_GET_AFFINE_COORDINATES  167\n# define EC_F_EC_GFP_SIMPLE_POINT_GET_AFFINE_COORDINATES_GFP 105\n# define EC_F_EC_GFP_SIMPLE_POINT_SET_AFFINE_COORDINATES  168\n# define EC_F_EC_GFP_SIMPLE_POINT_SET_AFFINE_COORDINATES_GFP 128\n# define EC_F_EC_GFP_SIMPLE_SET_COMPRESSED_COORDINATES    169\n# define EC_F_EC_GFP_SIMPLE_SET_COMPRESSED_COORDINATES_GFP 129\n# define EC_F_EC_GROUP_CHECK                              170\n# define EC_F_EC_GROUP_CHECK_DISCRIMINANT                 171\n# define EC_F_EC_GROUP_COPY                               106\n# define EC_F_EC_GROUP_GET0_GENERATOR                     139\n# define EC_F_EC_GROUP_GET_COFACTOR                       140\n# define EC_F_EC_GROUP_GET_CURVE_GF2M                     172\n# define EC_F_EC_GROUP_GET_CURVE_GFP                      130\n# define EC_F_EC_GROUP_GET_DEGREE                         173\n# define EC_F_EC_GROUP_GET_ORDER                          141\n# define EC_F_EC_GROUP_GET_PENTANOMIAL_BASIS              193\n# define EC_F_EC_GROUP_GET_TRINOMIAL_BASIS                194\n# define EC_F_EC_GROUP_NEW                                108\n# define EC_F_EC_GROUP_NEW_BY_CURVE_NAME                  174\n# define EC_F_EC_GROUP_NEW_FROM_DATA                      175\n# define EC_F_EC_GROUP_PRECOMPUTE_MULT                    142\n# define EC_F_EC_GROUP_SET_CURVE_GF2M                     176\n# define EC_F_EC_GROUP_SET_CURVE_GFP                      109\n# define EC_F_EC_GROUP_SET_EXTRA_DATA                     110\n# define EC_F_EC_GROUP_SET_GENERATOR                      111\n# define EC_F_EC_KEY_CHECK_KEY                            177\n# define EC_F_EC_KEY_COPY                                 178\n# define EC_F_EC_KEY_GENERATE_KEY                         179\n# define EC_F_EC_KEY_NEW                                  182\n# define EC_F_EC_KEY_PRINT                                180\n# define EC_F_EC_KEY_PRINT_FP                             181\n# define EC_F_EC_KEY_SET_PUBLIC_KEY_AFFINE_COORDINATES    229\n# define EC_F_EC_POINTS_MAKE_AFFINE                       136\n# define EC_F_EC_POINT_ADD                                112\n# define EC_F_EC_POINT_CMP                                113\n# define EC_F_EC_POINT_COPY                               114\n# define EC_F_EC_POINT_DBL                                115\n# define EC_F_EC_POINT_GET_AFFINE_COORDINATES_GF2M        183\n# define EC_F_EC_POINT_GET_AFFINE_COORDINATES_GFP         116\n# define EC_F_EC_POINT_GET_JPROJECTIVE_COORDINATES_GFP    117\n# define EC_F_EC_POINT_INVERT                             210\n# define EC_F_EC_POINT_IS_AT_INFINITY                     118\n# define EC_F_EC_POINT_IS_ON_CURVE                        119\n# define EC_F_EC_POINT_MAKE_AFFINE                        120\n# define EC_F_EC_POINT_MUL                                184\n# define EC_F_EC_POINT_NEW                                121\n# define EC_F_EC_POINT_OCT2POINT                          122\n# define EC_F_EC_POINT_POINT2OCT                          123\n# define EC_F_EC_POINT_SET_AFFINE_COORDINATES_GF2M        185\n# define EC_F_EC_POINT_SET_AFFINE_COORDINATES_GFP         124\n# define EC_F_EC_POINT_SET_COMPRESSED_COORDINATES_GF2M    186\n# define EC_F_EC_POINT_SET_COMPRESSED_COORDINATES_GFP     125\n# define EC_F_EC_POINT_SET_JPROJECTIVE_COORDINATES_GFP    126\n# define EC_F_EC_POINT_SET_TO_INFINITY                    127\n# define EC_F_EC_PRE_COMP_DUP                             207\n# define EC_F_EC_PRE_COMP_NEW                             196\n# define EC_F_EC_WNAF_MUL                                 187\n# define EC_F_EC_WNAF_PRECOMPUTE_MULT                     188\n# define EC_F_I2D_ECPARAMETERS                            190\n# define EC_F_I2D_ECPKPARAMETERS                          191\n# define EC_F_I2D_ECPRIVATEKEY                            192\n# define EC_F_I2O_ECPUBLICKEY                             151\n# define EC_F_NISTP224_PRE_COMP_NEW                       227\n# define EC_F_NISTP256_PRE_COMP_NEW                       236\n# define EC_F_NISTP521_PRE_COMP_NEW                       237\n# define EC_F_O2I_ECPUBLICKEY                             152\n# define EC_F_OLD_EC_PRIV_DECODE                          222\n# define EC_F_PKEY_EC_CTRL                                197\n# define EC_F_PKEY_EC_CTRL_STR                            198\n# define EC_F_PKEY_EC_DERIVE                              217\n# define EC_F_PKEY_EC_KEYGEN                              199\n# define EC_F_PKEY_EC_PARAMGEN                            219\n# define EC_F_PKEY_EC_SIGN                                218\n\n/* Reason codes. */\n# define EC_R_ASN1_ERROR                                  115\n# define EC_R_ASN1_UNKNOWN_FIELD                          116\n# define EC_R_BIGNUM_OUT_OF_RANGE                         144\n# define EC_R_BUFFER_TOO_SMALL                            100\n# define EC_R_COORDINATES_OUT_OF_RANGE                    146\n# define EC_R_D2I_ECPKPARAMETERS_FAILURE                  117\n# define EC_R_DECODE_ERROR                                142\n# define EC_R_DISCRIMINANT_IS_ZERO                        118\n# define EC_R_EC_GROUP_NEW_BY_NAME_FAILURE                119\n# define EC_R_FIELD_TOO_LARGE                             143\n# define EC_R_GF2M_NOT_SUPPORTED                          147\n# define EC_R_GROUP2PKPARAMETERS_FAILURE                  120\n# define EC_R_I2D_ECPKPARAMETERS_FAILURE                  121\n# define EC_R_INCOMPATIBLE_OBJECTS                        101\n# define EC_R_INVALID_ARGUMENT                            112\n# define EC_R_INVALID_COMPRESSED_POINT                    110\n# define EC_R_INVALID_COMPRESSION_BIT                     109\n# define EC_R_INVALID_CURVE                               141\n# define EC_R_INVALID_DIGEST                              151\n# define EC_R_INVALID_DIGEST_TYPE                         138\n# define EC_R_INVALID_ENCODING                            102\n# define EC_R_INVALID_FIELD                               103\n# define EC_R_INVALID_FORM                                104\n# define EC_R_INVALID_GROUP_ORDER                         122\n# define EC_R_INVALID_PENTANOMIAL_BASIS                   132\n# define EC_R_INVALID_PRIVATE_KEY                         123\n# define EC_R_INVALID_TRINOMIAL_BASIS                     137\n# define EC_R_KDF_PARAMETER_ERROR                         148\n# define EC_R_KEYS_NOT_SET                                140\n# define EC_R_MISSING_PARAMETERS                          124\n# define EC_R_MISSING_PRIVATE_KEY                         125\n# define EC_R_NOT_A_NIST_PRIME                            135\n# define EC_R_NOT_A_SUPPORTED_NIST_PRIME                  136\n# define EC_R_NOT_IMPLEMENTED                             126\n# define EC_R_NOT_INITIALIZED                             111\n# define EC_R_NO_FIELD_MOD                                133\n# define EC_R_NO_PARAMETERS_SET                           139\n# define EC_R_PASSED_NULL_PARAMETER                       134\n# define EC_R_PEER_KEY_ERROR                              149\n# define EC_R_PKPARAMETERS2GROUP_FAILURE                  127\n# define EC_R_POINT_AT_INFINITY                           106\n# define EC_R_POINT_IS_NOT_ON_CURVE                       107\n# define EC_R_SHARED_INFO_ERROR                           150\n# define EC_R_SLOT_FULL                                   108\n# define EC_R_UNDEFINED_GENERATOR                         113\n# define EC_R_UNDEFINED_ORDER                             128\n# define EC_R_UNKNOWN_GROUP                               129\n# define EC_R_UNKNOWN_ORDER                               114\n# define EC_R_UNSUPPORTED_FIELD                           131\n# define EC_R_WRONG_CURVE_PARAMETERS                      145\n# define EC_R_WRONG_ORDER                                 130\n\n#ifdef  __cplusplus\n}\n#endif\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/x86/include/openssl/ecdh.h",
    "content": "/* crypto/ecdh/ecdh.h */\n/* ====================================================================\n * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED.\n *\n * The Elliptic Curve Public-Key Crypto Library (ECC Code) included\n * herein is developed by SUN MICROSYSTEMS, INC., and is contributed\n * to the OpenSSL project.\n *\n * The ECC Code is licensed pursuant to the OpenSSL open source\n * license provided below.\n *\n * The ECDH software is originally written by Douglas Stebila of\n * Sun Microsystems Laboratories.\n *\n */\n/* ====================================================================\n * Copyright (c) 2000-2002 The OpenSSL Project.  All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n *\n * 1. Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n *\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in\n *    the documentation and/or other materials provided with the\n *    distribution.\n *\n * 3. All advertising materials mentioning features or use of this\n *    software must display the following acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)\"\n *\n * 4. The names \"OpenSSL Toolkit\" and \"OpenSSL Project\" must not be used to\n *    endorse or promote products derived from this software without\n *    prior written permission. For written permission, please contact\n *    licensing@OpenSSL.org.\n *\n * 5. Products derived from this software may not be called \"OpenSSL\"\n *    nor may \"OpenSSL\" appear in their names without prior written\n *    permission of the OpenSSL Project.\n *\n * 6. Redistributions of any form whatsoever must retain the following\n *    acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)\"\n *\n * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY\n * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\n * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR\n * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\n * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,\n * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED\n * OF THE POSSIBILITY OF SUCH DAMAGE.\n * ====================================================================\n *\n * This product includes cryptographic software written by Eric Young\n * (eay@cryptsoft.com).  This product includes software written by Tim\n * Hudson (tjh@cryptsoft.com).\n *\n */\n#ifndef HEADER_ECDH_H\n# define HEADER_ECDH_H\n\n# include <openssl/opensslconf.h>\n\n# ifdef OPENSSL_NO_ECDH\n#  error ECDH is disabled.\n# endif\n\n# include <openssl/ec.h>\n# include <openssl/ossl_typ.h>\n# ifndef OPENSSL_NO_DEPRECATED\n#  include <openssl/bn.h>\n# endif\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n# define EC_FLAG_COFACTOR_ECDH   0x1000\n\nconst ECDH_METHOD *ECDH_OpenSSL(void);\n\nvoid ECDH_set_default_method(const ECDH_METHOD *);\nconst ECDH_METHOD *ECDH_get_default_method(void);\nint ECDH_set_method(EC_KEY *, const ECDH_METHOD *);\n\nint ECDH_compute_key(void *out, size_t outlen, const EC_POINT *pub_key,\n                     EC_KEY *ecdh, void *(*KDF) (const void *in, size_t inlen,\n                                                 void *out, size_t *outlen));\n\nint ECDH_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new\n                          *new_func, CRYPTO_EX_dup *dup_func,\n                          CRYPTO_EX_free *free_func);\nint ECDH_set_ex_data(EC_KEY *d, int idx, void *arg);\nvoid *ECDH_get_ex_data(EC_KEY *d, int idx);\n\nint ECDH_KDF_X9_62(unsigned char *out, size_t outlen,\n                   const unsigned char *Z, size_t Zlen,\n                   const unsigned char *sinfo, size_t sinfolen,\n                   const EVP_MD *md);\n\n/* BEGIN ERROR CODES */\n/*\n * The following lines are auto generated by the script mkerr.pl. Any changes\n * made after this point may be overwritten when the script is next run.\n */\nvoid ERR_load_ECDH_strings(void);\n\n/* Error codes for the ECDH functions. */\n\n/* Function codes. */\n# define ECDH_F_ECDH_CHECK                                102\n# define ECDH_F_ECDH_COMPUTE_KEY                          100\n# define ECDH_F_ECDH_DATA_NEW_METHOD                      101\n\n/* Reason codes. */\n# define ECDH_R_KDF_FAILED                                102\n# define ECDH_R_NON_FIPS_METHOD                           103\n# define ECDH_R_NO_PRIVATE_VALUE                          100\n# define ECDH_R_POINT_ARITHMETIC_FAILURE                  101\n\n#ifdef  __cplusplus\n}\n#endif\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/x86/include/openssl/ecdsa.h",
    "content": "/* crypto/ecdsa/ecdsa.h */\n/**\n * \\file   crypto/ecdsa/ecdsa.h Include file for the OpenSSL ECDSA functions\n * \\author Written by Nils Larsch for the OpenSSL project\n */\n/* ====================================================================\n * Copyright (c) 2000-2005 The OpenSSL Project.  All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n *\n * 1. Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n *\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in\n *    the documentation and/or other materials provided with the\n *    distribution.\n *\n * 3. All advertising materials mentioning features or use of this\n *    software must display the following acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)\"\n *\n * 4. The names \"OpenSSL Toolkit\" and \"OpenSSL Project\" must not be used to\n *    endorse or promote products derived from this software without\n *    prior written permission. For written permission, please contact\n *    licensing@OpenSSL.org.\n *\n * 5. Products derived from this software may not be called \"OpenSSL\"\n *    nor may \"OpenSSL\" appear in their names without prior written\n *    permission of the OpenSSL Project.\n *\n * 6. Redistributions of any form whatsoever must retain the following\n *    acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)\"\n *\n * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY\n * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\n * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR\n * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\n * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,\n * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED\n * OF THE POSSIBILITY OF SUCH DAMAGE.\n * ====================================================================\n *\n * This product includes cryptographic software written by Eric Young\n * (eay@cryptsoft.com).  This product includes software written by Tim\n * Hudson (tjh@cryptsoft.com).\n *\n */\n#ifndef HEADER_ECDSA_H\n# define HEADER_ECDSA_H\n\n# include <openssl/opensslconf.h>\n\n# ifdef OPENSSL_NO_ECDSA\n#  error ECDSA is disabled.\n# endif\n\n# include <openssl/ec.h>\n# include <openssl/ossl_typ.h>\n# ifndef OPENSSL_NO_DEPRECATED\n#  include <openssl/bn.h>\n# endif\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\ntypedef struct ECDSA_SIG_st {\n    BIGNUM *r;\n    BIGNUM *s;\n} ECDSA_SIG;\n\n/** Allocates and initialize a ECDSA_SIG structure\n *  \\return pointer to a ECDSA_SIG structure or NULL if an error occurred\n */\nECDSA_SIG *ECDSA_SIG_new(void);\n\n/** frees a ECDSA_SIG structure\n *  \\param  sig  pointer to the ECDSA_SIG structure\n */\nvoid ECDSA_SIG_free(ECDSA_SIG *sig);\n\n/** DER encode content of ECDSA_SIG object (note: this function modifies *pp\n *  (*pp += length of the DER encoded signature)).\n *  \\param  sig  pointer to the ECDSA_SIG object\n *  \\param  pp   pointer to a unsigned char pointer for the output or NULL\n *  \\return the length of the DER encoded ECDSA_SIG object or 0\n */\nint i2d_ECDSA_SIG(const ECDSA_SIG *sig, unsigned char **pp);\n\n/** Decodes a DER encoded ECDSA signature (note: this function changes *pp\n *  (*pp += len)).\n *  \\param  sig  pointer to ECDSA_SIG pointer (may be NULL)\n *  \\param  pp   memory buffer with the DER encoded signature\n *  \\param  len  length of the buffer\n *  \\return pointer to the decoded ECDSA_SIG structure (or NULL)\n */\nECDSA_SIG *d2i_ECDSA_SIG(ECDSA_SIG **sig, const unsigned char **pp, long len);\n\n/** Computes the ECDSA signature of the given hash value using\n *  the supplied private key and returns the created signature.\n *  \\param  dgst      pointer to the hash value\n *  \\param  dgst_len  length of the hash value\n *  \\param  eckey     EC_KEY object containing a private EC key\n *  \\return pointer to a ECDSA_SIG structure or NULL if an error occurred\n */\nECDSA_SIG *ECDSA_do_sign(const unsigned char *dgst, int dgst_len,\n                         EC_KEY *eckey);\n\n/** Computes ECDSA signature of a given hash value using the supplied\n *  private key (note: sig must point to ECDSA_size(eckey) bytes of memory).\n *  \\param  dgst     pointer to the hash value to sign\n *  \\param  dgstlen  length of the hash value\n *  \\param  kinv     BIGNUM with a pre-computed inverse k (optional)\n *  \\param  rp       BIGNUM with a pre-computed rp value (optioanl),\n *                   see ECDSA_sign_setup\n *  \\param  eckey    EC_KEY object containing a private EC key\n *  \\return pointer to a ECDSA_SIG structure or NULL if an error occurred\n */\nECDSA_SIG *ECDSA_do_sign_ex(const unsigned char *dgst, int dgstlen,\n                            const BIGNUM *kinv, const BIGNUM *rp,\n                            EC_KEY *eckey);\n\n/** Verifies that the supplied signature is a valid ECDSA\n *  signature of the supplied hash value using the supplied public key.\n *  \\param  dgst      pointer to the hash value\n *  \\param  dgst_len  length of the hash value\n *  \\param  sig       ECDSA_SIG structure\n *  \\param  eckey     EC_KEY object containing a public EC key\n *  \\return 1 if the signature is valid, 0 if the signature is invalid\n *          and -1 on error\n */\nint ECDSA_do_verify(const unsigned char *dgst, int dgst_len,\n                    const ECDSA_SIG *sig, EC_KEY *eckey);\n\nconst ECDSA_METHOD *ECDSA_OpenSSL(void);\n\n/** Sets the default ECDSA method\n *  \\param  meth  new default ECDSA_METHOD\n */\nvoid ECDSA_set_default_method(const ECDSA_METHOD *meth);\n\n/** Returns the default ECDSA method\n *  \\return pointer to ECDSA_METHOD structure containing the default method\n */\nconst ECDSA_METHOD *ECDSA_get_default_method(void);\n\n/** Sets method to be used for the ECDSA operations\n *  \\param  eckey  EC_KEY object\n *  \\param  meth   new method\n *  \\return 1 on success and 0 otherwise\n */\nint ECDSA_set_method(EC_KEY *eckey, const ECDSA_METHOD *meth);\n\n/** Returns the maximum length of the DER encoded signature\n *  \\param  eckey  EC_KEY object\n *  \\return numbers of bytes required for the DER encoded signature\n */\nint ECDSA_size(const EC_KEY *eckey);\n\n/** Precompute parts of the signing operation\n *  \\param  eckey  EC_KEY object containing a private EC key\n *  \\param  ctx    BN_CTX object (optional)\n *  \\param  kinv   BIGNUM pointer for the inverse of k\n *  \\param  rp     BIGNUM pointer for x coordinate of k * generator\n *  \\return 1 on success and 0 otherwise\n */\nint ECDSA_sign_setup(EC_KEY *eckey, BN_CTX *ctx, BIGNUM **kinv, BIGNUM **rp);\n\n/** Computes ECDSA signature of a given hash value using the supplied\n *  private key (note: sig must point to ECDSA_size(eckey) bytes of memory).\n *  \\param  type     this parameter is ignored\n *  \\param  dgst     pointer to the hash value to sign\n *  \\param  dgstlen  length of the hash value\n *  \\param  sig      memory for the DER encoded created signature\n *  \\param  siglen   pointer to the length of the returned signature\n *  \\param  eckey    EC_KEY object containing a private EC key\n *  \\return 1 on success and 0 otherwise\n */\nint ECDSA_sign(int type, const unsigned char *dgst, int dgstlen,\n               unsigned char *sig, unsigned int *siglen, EC_KEY *eckey);\n\n/** Computes ECDSA signature of a given hash value using the supplied\n *  private key (note: sig must point to ECDSA_size(eckey) bytes of memory).\n *  \\param  type     this parameter is ignored\n *  \\param  dgst     pointer to the hash value to sign\n *  \\param  dgstlen  length of the hash value\n *  \\param  sig      buffer to hold the DER encoded signature\n *  \\param  siglen   pointer to the length of the returned signature\n *  \\param  kinv     BIGNUM with a pre-computed inverse k (optional)\n *  \\param  rp       BIGNUM with a pre-computed rp value (optioanl),\n *                   see ECDSA_sign_setup\n *  \\param  eckey    EC_KEY object containing a private EC key\n *  \\return 1 on success and 0 otherwise\n */\nint ECDSA_sign_ex(int type, const unsigned char *dgst, int dgstlen,\n                  unsigned char *sig, unsigned int *siglen,\n                  const BIGNUM *kinv, const BIGNUM *rp, EC_KEY *eckey);\n\n/** Verifies that the given signature is valid ECDSA signature\n *  of the supplied hash value using the specified public key.\n *  \\param  type     this parameter is ignored\n *  \\param  dgst     pointer to the hash value\n *  \\param  dgstlen  length of the hash value\n *  \\param  sig      pointer to the DER encoded signature\n *  \\param  siglen   length of the DER encoded signature\n *  \\param  eckey    EC_KEY object containing a public EC key\n *  \\return 1 if the signature is valid, 0 if the signature is invalid\n *          and -1 on error\n */\nint ECDSA_verify(int type, const unsigned char *dgst, int dgstlen,\n                 const unsigned char *sig, int siglen, EC_KEY *eckey);\n\n/* the standard ex_data functions */\nint ECDSA_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new\n                           *new_func, CRYPTO_EX_dup *dup_func,\n                           CRYPTO_EX_free *free_func);\nint ECDSA_set_ex_data(EC_KEY *d, int idx, void *arg);\nvoid *ECDSA_get_ex_data(EC_KEY *d, int idx);\n\n/** Allocates and initialize a ECDSA_METHOD structure\n *  \\param ecdsa_method pointer to ECDSA_METHOD to copy.  (May be NULL)\n *  \\return pointer to a ECDSA_METHOD structure or NULL if an error occurred\n */\n\nECDSA_METHOD *ECDSA_METHOD_new(const ECDSA_METHOD *ecdsa_method);\n\n/** frees a ECDSA_METHOD structure\n *  \\param  ecdsa_method  pointer to the ECDSA_METHOD structure\n */\nvoid ECDSA_METHOD_free(ECDSA_METHOD *ecdsa_method);\n\n/**  Sets application specific data in the ECDSA_METHOD\n *   \\param  ecdsa_method pointer to existing ECDSA_METHOD\n *   \\param  app application specific data to set\n */\n\nvoid ECDSA_METHOD_set_app_data(ECDSA_METHOD *ecdsa_method, void *app);\n\n/** Returns application specific data from a ECDSA_METHOD structure\n *  \\param ecdsa_method pointer to ECDSA_METHOD structure\n *  \\return pointer to application specific data.\n */\n\nvoid *ECDSA_METHOD_get_app_data(ECDSA_METHOD *ecdsa_method);\n\n/**  Set the ECDSA_do_sign function in the ECDSA_METHOD\n *   \\param  ecdsa_method  pointer to existing ECDSA_METHOD\n *   \\param  ecdsa_do_sign a funtion of type ECDSA_do_sign\n */\n\nvoid ECDSA_METHOD_set_sign(ECDSA_METHOD *ecdsa_method,\n                           ECDSA_SIG *(*ecdsa_do_sign) (const unsigned char\n                                                        *dgst, int dgst_len,\n                                                        const BIGNUM *inv,\n                                                        const BIGNUM *rp,\n                                                        EC_KEY *eckey));\n\n/**  Set the  ECDSA_sign_setup function in the ECDSA_METHOD\n *   \\param  ecdsa_method  pointer to existing ECDSA_METHOD\n *   \\param  ecdsa_sign_setup a funtion of type ECDSA_sign_setup\n */\n\nvoid ECDSA_METHOD_set_sign_setup(ECDSA_METHOD *ecdsa_method,\n                                 int (*ecdsa_sign_setup) (EC_KEY *eckey,\n                                                          BN_CTX *ctx,\n                                                          BIGNUM **kinv,\n                                                          BIGNUM **r));\n\n/**  Set the ECDSA_do_verify function in the ECDSA_METHOD\n *   \\param  ecdsa_method  pointer to existing ECDSA_METHOD\n *   \\param  ecdsa_do_verify a funtion of type ECDSA_do_verify\n */\n\nvoid ECDSA_METHOD_set_verify(ECDSA_METHOD *ecdsa_method,\n                             int (*ecdsa_do_verify) (const unsigned char\n                                                     *dgst, int dgst_len,\n                                                     const ECDSA_SIG *sig,\n                                                     EC_KEY *eckey));\n\nvoid ECDSA_METHOD_set_flags(ECDSA_METHOD *ecdsa_method, int flags);\n\n/**  Set the flags field in the ECDSA_METHOD\n *   \\param  ecdsa_method  pointer to existing ECDSA_METHOD\n *   \\param  flags flags value to set\n */\n\nvoid ECDSA_METHOD_set_name(ECDSA_METHOD *ecdsa_method, char *name);\n\n/**  Set the name field in the ECDSA_METHOD\n *   \\param  ecdsa_method  pointer to existing ECDSA_METHOD\n *   \\param  name name to set\n */\n\n/* BEGIN ERROR CODES */\n/*\n * The following lines are auto generated by the script mkerr.pl. Any changes\n * made after this point may be overwritten when the script is next run.\n */\nvoid ERR_load_ECDSA_strings(void);\n\n/* Error codes for the ECDSA functions. */\n\n/* Function codes. */\n# define ECDSA_F_ECDSA_CHECK                              104\n# define ECDSA_F_ECDSA_DATA_NEW_METHOD                    100\n# define ECDSA_F_ECDSA_DO_SIGN                            101\n# define ECDSA_F_ECDSA_DO_VERIFY                          102\n# define ECDSA_F_ECDSA_METHOD_NEW                         105\n# define ECDSA_F_ECDSA_SIGN_SETUP                         103\n\n/* Reason codes. */\n# define ECDSA_R_BAD_SIGNATURE                            100\n# define ECDSA_R_DATA_TOO_LARGE_FOR_KEY_SIZE              101\n# define ECDSA_R_ERR_EC_LIB                               102\n# define ECDSA_R_MISSING_PARAMETERS                       103\n# define ECDSA_R_NEED_NEW_SETUP_VALUES                    106\n# define ECDSA_R_NON_FIPS_METHOD                          107\n# define ECDSA_R_RANDOM_NUMBER_GENERATION_FAILED          104\n# define ECDSA_R_SIGNATURE_MALLOC_FAILED                  105\n\n#ifdef  __cplusplus\n}\n#endif\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/x86/include/openssl/err.h",
    "content": "/* crypto/err/err.h */\n/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)\n * All rights reserved.\n *\n * This package is an SSL implementation written\n * by Eric Young (eay@cryptsoft.com).\n * The implementation was written so as to conform with Netscapes SSL.\n *\n * This library is free for commercial and non-commercial use as long as\n * the following conditions are aheared to.  The following conditions\n * apply to all code found in this distribution, be it the RC4, RSA,\n * lhash, DES, etc., code; not just the SSL code.  The SSL documentation\n * included with this distribution is covered by the same copyright terms\n * except that the holder is Tim Hudson (tjh@cryptsoft.com).\n *\n * Copyright remains Eric Young's, and as such any Copyright notices in\n * the code are not to be removed.\n * If this package is used in a product, Eric Young should be given attribution\n * as the author of the parts of the library used.\n * This can be in the form of a textual message at program startup or\n * in documentation (online or textual) provided with the package.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the copyright\n *    notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in the\n *    documentation and/or other materials provided with the distribution.\n * 3. All advertising materials mentioning features or use of this software\n *    must display the following acknowledgement:\n *    \"This product includes cryptographic software written by\n *     Eric Young (eay@cryptsoft.com)\"\n *    The word 'cryptographic' can be left out if the rouines from the library\n *    being used are not cryptographic related :-).\n * 4. If you include any Windows specific code (or a derivative thereof) from\n *    the apps directory (application code) you must include an acknowledgement:\n *    \"This product includes software written by Tim Hudson (tjh@cryptsoft.com)\"\n *\n * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n * SUCH DAMAGE.\n *\n * The licence and distribution terms for any publically available version or\n * derivative of this code cannot be changed.  i.e. this code cannot simply be\n * copied and put under another distribution licence\n * [including the GNU Public Licence.]\n */\n/* ====================================================================\n * Copyright (c) 1998-2006 The OpenSSL Project.  All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n *\n * 1. Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n *\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in\n *    the documentation and/or other materials provided with the\n *    distribution.\n *\n * 3. All advertising materials mentioning features or use of this\n *    software must display the following acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit. (http://www.openssl.org/)\"\n *\n * 4. The names \"OpenSSL Toolkit\" and \"OpenSSL Project\" must not be used to\n *    endorse or promote products derived from this software without\n *    prior written permission. For written permission, please contact\n *    openssl-core@openssl.org.\n *\n * 5. Products derived from this software may not be called \"OpenSSL\"\n *    nor may \"OpenSSL\" appear in their names without prior written\n *    permission of the OpenSSL Project.\n *\n * 6. Redistributions of any form whatsoever must retain the following\n *    acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit (http://www.openssl.org/)\"\n *\n * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY\n * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\n * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR\n * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\n * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,\n * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED\n * OF THE POSSIBILITY OF SUCH DAMAGE.\n * ====================================================================\n *\n * This product includes cryptographic software written by Eric Young\n * (eay@cryptsoft.com).  This product includes software written by Tim\n * Hudson (tjh@cryptsoft.com).\n *\n */\n\n#ifndef HEADER_ERR_H\n# define HEADER_ERR_H\n\n# include <openssl/e_os2.h>\n\n# ifndef OPENSSL_NO_FP_API\n#  include <stdio.h>\n#  include <stdlib.h>\n# endif\n\n# include <openssl/ossl_typ.h>\n# ifndef OPENSSL_NO_BIO\n#  include <openssl/bio.h>\n# endif\n# ifndef OPENSSL_NO_LHASH\n#  include <openssl/lhash.h>\n# endif\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n# ifndef OPENSSL_NO_ERR\n#  define ERR_PUT_error(a,b,c,d,e)        ERR_put_error(a,b,c,d,e)\n# else\n#  define ERR_PUT_error(a,b,c,d,e)        ERR_put_error(a,b,c,NULL,0)\n# endif\n\n# include <errno.h>\n\n# define ERR_TXT_MALLOCED        0x01\n# define ERR_TXT_STRING          0x02\n\n# define ERR_FLAG_MARK           0x01\n\n# define ERR_NUM_ERRORS  16\ntypedef struct err_state_st {\n    CRYPTO_THREADID tid;\n    int err_flags[ERR_NUM_ERRORS];\n    unsigned long err_buffer[ERR_NUM_ERRORS];\n    char *err_data[ERR_NUM_ERRORS];\n    int err_data_flags[ERR_NUM_ERRORS];\n    const char *err_file[ERR_NUM_ERRORS];\n    int err_line[ERR_NUM_ERRORS];\n    int top, bottom;\n} ERR_STATE;\n\n/* library */\n# define ERR_LIB_NONE            1\n# define ERR_LIB_SYS             2\n# define ERR_LIB_BN              3\n# define ERR_LIB_RSA             4\n# define ERR_LIB_DH              5\n# define ERR_LIB_EVP             6\n# define ERR_LIB_BUF             7\n# define ERR_LIB_OBJ             8\n# define ERR_LIB_PEM             9\n# define ERR_LIB_DSA             10\n# define ERR_LIB_X509            11\n/* #define ERR_LIB_METH         12 */\n# define ERR_LIB_ASN1            13\n# define ERR_LIB_CONF            14\n# define ERR_LIB_CRYPTO          15\n# define ERR_LIB_EC              16\n# define ERR_LIB_SSL             20\n/* #define ERR_LIB_SSL23        21 */\n/* #define ERR_LIB_SSL2         22 */\n/* #define ERR_LIB_SSL3         23 */\n/* #define ERR_LIB_RSAREF       30 */\n/* #define ERR_LIB_PROXY        31 */\n# define ERR_LIB_BIO             32\n# define ERR_LIB_PKCS7           33\n# define ERR_LIB_X509V3          34\n# define ERR_LIB_PKCS12          35\n# define ERR_LIB_RAND            36\n# define ERR_LIB_DSO             37\n# define ERR_LIB_ENGINE          38\n# define ERR_LIB_OCSP            39\n# define ERR_LIB_UI              40\n# define ERR_LIB_COMP            41\n# define ERR_LIB_ECDSA           42\n# define ERR_LIB_ECDH            43\n# define ERR_LIB_STORE           44\n# define ERR_LIB_FIPS            45\n# define ERR_LIB_CMS             46\n# define ERR_LIB_TS              47\n# define ERR_LIB_HMAC            48\n# define ERR_LIB_JPAKE           49\n\n# define ERR_LIB_USER            128\n\n# define SYSerr(f,r)  ERR_PUT_error(ERR_LIB_SYS,(f),(r),__FILE__,__LINE__)\n# define BNerr(f,r)   ERR_PUT_error(ERR_LIB_BN,(f),(r),__FILE__,__LINE__)\n# define RSAerr(f,r)  ERR_PUT_error(ERR_LIB_RSA,(f),(r),__FILE__,__LINE__)\n# define DHerr(f,r)   ERR_PUT_error(ERR_LIB_DH,(f),(r),__FILE__,__LINE__)\n# define EVPerr(f,r)  ERR_PUT_error(ERR_LIB_EVP,(f),(r),__FILE__,__LINE__)\n# define BUFerr(f,r)  ERR_PUT_error(ERR_LIB_BUF,(f),(r),__FILE__,__LINE__)\n# define OBJerr(f,r)  ERR_PUT_error(ERR_LIB_OBJ,(f),(r),__FILE__,__LINE__)\n# define PEMerr(f,r)  ERR_PUT_error(ERR_LIB_PEM,(f),(r),__FILE__,__LINE__)\n# define DSAerr(f,r)  ERR_PUT_error(ERR_LIB_DSA,(f),(r),__FILE__,__LINE__)\n# define X509err(f,r) ERR_PUT_error(ERR_LIB_X509,(f),(r),__FILE__,__LINE__)\n# define ASN1err(f,r) ERR_PUT_error(ERR_LIB_ASN1,(f),(r),__FILE__,__LINE__)\n# define CONFerr(f,r) ERR_PUT_error(ERR_LIB_CONF,(f),(r),__FILE__,__LINE__)\n# define CRYPTOerr(f,r) ERR_PUT_error(ERR_LIB_CRYPTO,(f),(r),__FILE__,__LINE__)\n# define ECerr(f,r)   ERR_PUT_error(ERR_LIB_EC,(f),(r),__FILE__,__LINE__)\n# define SSLerr(f,r)  ERR_PUT_error(ERR_LIB_SSL,(f),(r),__FILE__,__LINE__)\n# define BIOerr(f,r)  ERR_PUT_error(ERR_LIB_BIO,(f),(r),__FILE__,__LINE__)\n# define PKCS7err(f,r) ERR_PUT_error(ERR_LIB_PKCS7,(f),(r),__FILE__,__LINE__)\n# define X509V3err(f,r) ERR_PUT_error(ERR_LIB_X509V3,(f),(r),__FILE__,__LINE__)\n# define PKCS12err(f,r) ERR_PUT_error(ERR_LIB_PKCS12,(f),(r),__FILE__,__LINE__)\n# define RANDerr(f,r) ERR_PUT_error(ERR_LIB_RAND,(f),(r),__FILE__,__LINE__)\n# define DSOerr(f,r) ERR_PUT_error(ERR_LIB_DSO,(f),(r),__FILE__,__LINE__)\n# define ENGINEerr(f,r) ERR_PUT_error(ERR_LIB_ENGINE,(f),(r),__FILE__,__LINE__)\n# define OCSPerr(f,r) ERR_PUT_error(ERR_LIB_OCSP,(f),(r),__FILE__,__LINE__)\n# define UIerr(f,r) ERR_PUT_error(ERR_LIB_UI,(f),(r),__FILE__,__LINE__)\n# define COMPerr(f,r) ERR_PUT_error(ERR_LIB_COMP,(f),(r),__FILE__,__LINE__)\n# define ECDSAerr(f,r)  ERR_PUT_error(ERR_LIB_ECDSA,(f),(r),__FILE__,__LINE__)\n# define ECDHerr(f,r)  ERR_PUT_error(ERR_LIB_ECDH,(f),(r),__FILE__,__LINE__)\n# define STOREerr(f,r) ERR_PUT_error(ERR_LIB_STORE,(f),(r),__FILE__,__LINE__)\n# define FIPSerr(f,r) ERR_PUT_error(ERR_LIB_FIPS,(f),(r),__FILE__,__LINE__)\n# define CMSerr(f,r) ERR_PUT_error(ERR_LIB_CMS,(f),(r),__FILE__,__LINE__)\n# define TSerr(f,r) ERR_PUT_error(ERR_LIB_TS,(f),(r),__FILE__,__LINE__)\n# define HMACerr(f,r) ERR_PUT_error(ERR_LIB_HMAC,(f),(r),__FILE__,__LINE__)\n# define JPAKEerr(f,r) ERR_PUT_error(ERR_LIB_JPAKE,(f),(r),__FILE__,__LINE__)\n\n/*\n * Borland C seems too stupid to be able to shift and do longs in the\n * pre-processor :-(\n */\n# define ERR_PACK(l,f,r)         (((((unsigned long)l)&0xffL)*0x1000000)| \\\n                                ((((unsigned long)f)&0xfffL)*0x1000)| \\\n                                ((((unsigned long)r)&0xfffL)))\n# define ERR_GET_LIB(l)          (int)((((unsigned long)l)>>24L)&0xffL)\n# define ERR_GET_FUNC(l)         (int)((((unsigned long)l)>>12L)&0xfffL)\n# define ERR_GET_REASON(l)       (int)((l)&0xfffL)\n# define ERR_FATAL_ERROR(l)      (int)((l)&ERR_R_FATAL)\n\n/* OS functions */\n# define SYS_F_FOPEN             1\n# define SYS_F_CONNECT           2\n# define SYS_F_GETSERVBYNAME     3\n# define SYS_F_SOCKET            4\n# define SYS_F_IOCTLSOCKET       5\n# define SYS_F_BIND              6\n# define SYS_F_LISTEN            7\n# define SYS_F_ACCEPT            8\n# define SYS_F_WSASTARTUP        9/* Winsock stuff */\n# define SYS_F_OPENDIR           10\n# define SYS_F_FREAD             11\n\n/* reasons */\n# define ERR_R_SYS_LIB   ERR_LIB_SYS/* 2 */\n# define ERR_R_BN_LIB    ERR_LIB_BN/* 3 */\n# define ERR_R_RSA_LIB   ERR_LIB_RSA/* 4 */\n# define ERR_R_DH_LIB    ERR_LIB_DH/* 5 */\n# define ERR_R_EVP_LIB   ERR_LIB_EVP/* 6 */\n# define ERR_R_BUF_LIB   ERR_LIB_BUF/* 7 */\n# define ERR_R_OBJ_LIB   ERR_LIB_OBJ/* 8 */\n# define ERR_R_PEM_LIB   ERR_LIB_PEM/* 9 */\n# define ERR_R_DSA_LIB   ERR_LIB_DSA/* 10 */\n# define ERR_R_X509_LIB  ERR_LIB_X509/* 11 */\n# define ERR_R_ASN1_LIB  ERR_LIB_ASN1/* 13 */\n# define ERR_R_CONF_LIB  ERR_LIB_CONF/* 14 */\n# define ERR_R_CRYPTO_LIB ERR_LIB_CRYPTO/* 15 */\n# define ERR_R_EC_LIB    ERR_LIB_EC/* 16 */\n# define ERR_R_SSL_LIB   ERR_LIB_SSL/* 20 */\n# define ERR_R_BIO_LIB   ERR_LIB_BIO/* 32 */\n# define ERR_R_PKCS7_LIB ERR_LIB_PKCS7/* 33 */\n# define ERR_R_X509V3_LIB ERR_LIB_X509V3/* 34 */\n# define ERR_R_PKCS12_LIB ERR_LIB_PKCS12/* 35 */\n# define ERR_R_RAND_LIB  ERR_LIB_RAND/* 36 */\n# define ERR_R_DSO_LIB   ERR_LIB_DSO/* 37 */\n# define ERR_R_ENGINE_LIB ERR_LIB_ENGINE/* 38 */\n# define ERR_R_OCSP_LIB  ERR_LIB_OCSP/* 39 */\n# define ERR_R_UI_LIB    ERR_LIB_UI/* 40 */\n# define ERR_R_COMP_LIB  ERR_LIB_COMP/* 41 */\n# define ERR_R_ECDSA_LIB ERR_LIB_ECDSA/* 42 */\n# define ERR_R_ECDH_LIB  ERR_LIB_ECDH/* 43 */\n# define ERR_R_STORE_LIB ERR_LIB_STORE/* 44 */\n# define ERR_R_TS_LIB    ERR_LIB_TS/* 45 */\n\n# define ERR_R_NESTED_ASN1_ERROR                 58\n# define ERR_R_BAD_ASN1_OBJECT_HEADER            59\n# define ERR_R_BAD_GET_ASN1_OBJECT_CALL          60\n# define ERR_R_EXPECTING_AN_ASN1_SEQUENCE        61\n# define ERR_R_ASN1_LENGTH_MISMATCH              62\n# define ERR_R_MISSING_ASN1_EOS                  63\n\n/* fatal error */\n# define ERR_R_FATAL                             64\n# define ERR_R_MALLOC_FAILURE                    (1|ERR_R_FATAL)\n# define ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED       (2|ERR_R_FATAL)\n# define ERR_R_PASSED_NULL_PARAMETER             (3|ERR_R_FATAL)\n# define ERR_R_INTERNAL_ERROR                    (4|ERR_R_FATAL)\n# define ERR_R_DISABLED                          (5|ERR_R_FATAL)\n\n/*\n * 99 is the maximum possible ERR_R_... code, higher values are reserved for\n * the individual libraries\n */\n\ntypedef struct ERR_string_data_st {\n    unsigned long error;\n    const char *string;\n} ERR_STRING_DATA;\n\nvoid ERR_put_error(int lib, int func, int reason, const char *file, int line);\nvoid ERR_set_error_data(char *data, int flags);\n\nunsigned long ERR_get_error(void);\nunsigned long ERR_get_error_line(const char **file, int *line);\nunsigned long ERR_get_error_line_data(const char **file, int *line,\n                                      const char **data, int *flags);\nunsigned long ERR_peek_error(void);\nunsigned long ERR_peek_error_line(const char **file, int *line);\nunsigned long ERR_peek_error_line_data(const char **file, int *line,\n                                       const char **data, int *flags);\nunsigned long ERR_peek_last_error(void);\nunsigned long ERR_peek_last_error_line(const char **file, int *line);\nunsigned long ERR_peek_last_error_line_data(const char **file, int *line,\n                                            const char **data, int *flags);\nvoid ERR_clear_error(void);\nchar *ERR_error_string(unsigned long e, char *buf);\nvoid ERR_error_string_n(unsigned long e, char *buf, size_t len);\nconst char *ERR_lib_error_string(unsigned long e);\nconst char *ERR_func_error_string(unsigned long e);\nconst char *ERR_reason_error_string(unsigned long e);\nvoid ERR_print_errors_cb(int (*cb) (const char *str, size_t len, void *u),\n                         void *u);\n# ifndef OPENSSL_NO_FP_API\nvoid ERR_print_errors_fp(FILE *fp);\n# endif\n# ifndef OPENSSL_NO_BIO\nvoid ERR_print_errors(BIO *bp);\n# endif\nvoid ERR_add_error_data(int num, ...);\nvoid ERR_add_error_vdata(int num, va_list args);\nvoid ERR_load_strings(int lib, ERR_STRING_DATA str[]);\nvoid ERR_unload_strings(int lib, ERR_STRING_DATA str[]);\nvoid ERR_load_ERR_strings(void);\nvoid ERR_load_crypto_strings(void);\nvoid ERR_free_strings(void);\n\nvoid ERR_remove_thread_state(const CRYPTO_THREADID *tid);\n# ifndef OPENSSL_NO_DEPRECATED\nvoid ERR_remove_state(unsigned long pid); /* if zero we look it up */\n# endif\nERR_STATE *ERR_get_state(void);\n\n# ifndef OPENSSL_NO_LHASH\nLHASH_OF(ERR_STRING_DATA) *ERR_get_string_table(void);\nLHASH_OF(ERR_STATE) *ERR_get_err_state_table(void);\nvoid ERR_release_err_state_table(LHASH_OF(ERR_STATE) **hash);\n# endif\n\nint ERR_get_next_error_library(void);\n\nint ERR_set_mark(void);\nint ERR_pop_to_mark(void);\n\n/* Already defined in ossl_typ.h */\n/* typedef struct st_ERR_FNS ERR_FNS; */\n/*\n * An application can use this function and provide the return value to\n * loaded modules that should use the application's ERR state/functionality\n */\nconst ERR_FNS *ERR_get_implementation(void);\n/*\n * A loaded module should call this function prior to any ERR operations\n * using the application's \"ERR_FNS\".\n */\nint ERR_set_implementation(const ERR_FNS *fns);\n\n#ifdef  __cplusplus\n}\n#endif\n\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/x86/include/openssl/evp.h",
    "content": "/* crypto/evp/evp.h */\n/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)\n * All rights reserved.\n *\n * This package is an SSL implementation written\n * by Eric Young (eay@cryptsoft.com).\n * The implementation was written so as to conform with Netscapes SSL.\n *\n * This library is free for commercial and non-commercial use as long as\n * the following conditions are aheared to.  The following conditions\n * apply to all code found in this distribution, be it the RC4, RSA,\n * lhash, DES, etc., code; not just the SSL code.  The SSL documentation\n * included with this distribution is covered by the same copyright terms\n * except that the holder is Tim Hudson (tjh@cryptsoft.com).\n *\n * Copyright remains Eric Young's, and as such any Copyright notices in\n * the code are not to be removed.\n * If this package is used in a product, Eric Young should be given attribution\n * as the author of the parts of the library used.\n * This can be in the form of a textual message at program startup or\n * in documentation (online or textual) provided with the package.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the copyright\n *    notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in the\n *    documentation and/or other materials provided with the distribution.\n * 3. All advertising materials mentioning features or use of this software\n *    must display the following acknowledgement:\n *    \"This product includes cryptographic software written by\n *     Eric Young (eay@cryptsoft.com)\"\n *    The word 'cryptographic' can be left out if the rouines from the library\n *    being used are not cryptographic related :-).\n * 4. If you include any Windows specific code (or a derivative thereof) from\n *    the apps directory (application code) you must include an acknowledgement:\n *    \"This product includes software written by Tim Hudson (tjh@cryptsoft.com)\"\n *\n * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n * SUCH DAMAGE.\n *\n * The licence and distribution terms for any publically available version or\n * derivative of this code cannot be changed.  i.e. this code cannot simply be\n * copied and put under another distribution licence\n * [including the GNU Public Licence.]\n */\n\n#ifndef HEADER_ENVELOPE_H\n# define HEADER_ENVELOPE_H\n\n# ifdef OPENSSL_ALGORITHM_DEFINES\n#  include <openssl/opensslconf.h>\n# else\n#  define OPENSSL_ALGORITHM_DEFINES\n#  include <openssl/opensslconf.h>\n#  undef OPENSSL_ALGORITHM_DEFINES\n# endif\n\n# include <openssl/ossl_typ.h>\n\n# include <openssl/symhacks.h>\n\n# ifndef OPENSSL_NO_BIO\n#  include <openssl/bio.h>\n# endif\n\n/*-\n#define EVP_RC2_KEY_SIZE                16\n#define EVP_RC4_KEY_SIZE                16\n#define EVP_BLOWFISH_KEY_SIZE           16\n#define EVP_CAST5_KEY_SIZE              16\n#define EVP_RC5_32_12_16_KEY_SIZE       16\n*/\n# define EVP_MAX_MD_SIZE                 64/* longest known is SHA512 */\n# define EVP_MAX_KEY_LENGTH              64\n# define EVP_MAX_IV_LENGTH               16\n# define EVP_MAX_BLOCK_LENGTH            32\n\n# define PKCS5_SALT_LEN                  8\n/* Default PKCS#5 iteration count */\n# define PKCS5_DEFAULT_ITER              2048\n\n# include <openssl/objects.h>\n\n# define EVP_PK_RSA      0x0001\n# define EVP_PK_DSA      0x0002\n# define EVP_PK_DH       0x0004\n# define EVP_PK_EC       0x0008\n# define EVP_PKT_SIGN    0x0010\n# define EVP_PKT_ENC     0x0020\n# define EVP_PKT_EXCH    0x0040\n# define EVP_PKS_RSA     0x0100\n# define EVP_PKS_DSA     0x0200\n# define EVP_PKS_EC      0x0400\n\n# define EVP_PKEY_NONE   NID_undef\n# define EVP_PKEY_RSA    NID_rsaEncryption\n# define EVP_PKEY_RSA2   NID_rsa\n# define EVP_PKEY_DSA    NID_dsa\n# define EVP_PKEY_DSA1   NID_dsa_2\n# define EVP_PKEY_DSA2   NID_dsaWithSHA\n# define EVP_PKEY_DSA3   NID_dsaWithSHA1\n# define EVP_PKEY_DSA4   NID_dsaWithSHA1_2\n# define EVP_PKEY_DH     NID_dhKeyAgreement\n# define EVP_PKEY_DHX    NID_dhpublicnumber\n# define EVP_PKEY_EC     NID_X9_62_id_ecPublicKey\n# define EVP_PKEY_HMAC   NID_hmac\n# define EVP_PKEY_CMAC   NID_cmac\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n/*\n * Type needs to be a bit field Sub-type needs to be for variations on the\n * method, as in, can it do arbitrary encryption....\n */\nstruct evp_pkey_st {\n    int type;\n    int save_type;\n    int references;\n    const EVP_PKEY_ASN1_METHOD *ameth;\n    ENGINE *engine;\n    union {\n        char *ptr;\n# ifndef OPENSSL_NO_RSA\n        struct rsa_st *rsa;     /* RSA */\n# endif\n# ifndef OPENSSL_NO_DSA\n        struct dsa_st *dsa;     /* DSA */\n# endif\n# ifndef OPENSSL_NO_DH\n        struct dh_st *dh;       /* DH */\n# endif\n# ifndef OPENSSL_NO_EC\n        struct ec_key_st *ec;   /* ECC */\n# endif\n    } pkey;\n    int save_parameters;\n    STACK_OF(X509_ATTRIBUTE) *attributes; /* [ 0 ] */\n} /* EVP_PKEY */ ;\n\n# define EVP_PKEY_MO_SIGN        0x0001\n# define EVP_PKEY_MO_VERIFY      0x0002\n# define EVP_PKEY_MO_ENCRYPT     0x0004\n# define EVP_PKEY_MO_DECRYPT     0x0008\n\n# ifndef EVP_MD\nstruct env_md_st {\n    int type;\n    int pkey_type;\n    int md_size;\n    unsigned long flags;\n    int (*init) (EVP_MD_CTX *ctx);\n    int (*update) (EVP_MD_CTX *ctx, const void *data, size_t count);\n    int (*final) (EVP_MD_CTX *ctx, unsigned char *md);\n    int (*copy) (EVP_MD_CTX *to, const EVP_MD_CTX *from);\n    int (*cleanup) (EVP_MD_CTX *ctx);\n    /* FIXME: prototype these some day */\n    int (*sign) (int type, const unsigned char *m, unsigned int m_length,\n                 unsigned char *sigret, unsigned int *siglen, void *key);\n    int (*verify) (int type, const unsigned char *m, unsigned int m_length,\n                   const unsigned char *sigbuf, unsigned int siglen,\n                   void *key);\n    int required_pkey_type[5];  /* EVP_PKEY_xxx */\n    int block_size;\n    int ctx_size;               /* how big does the ctx->md_data need to be */\n    /* control function */\n    int (*md_ctrl) (EVP_MD_CTX *ctx, int cmd, int p1, void *p2);\n} /* EVP_MD */ ;\n\ntypedef int evp_sign_method(int type, const unsigned char *m,\n                            unsigned int m_length, unsigned char *sigret,\n                            unsigned int *siglen, void *key);\ntypedef int evp_verify_method(int type, const unsigned char *m,\n                              unsigned int m_length,\n                              const unsigned char *sigbuf,\n                              unsigned int siglen, void *key);\n\n/* digest can only handle a single block */\n#  define EVP_MD_FLAG_ONESHOT     0x0001\n\n/*\n * digest is a \"clone\" digest used\n * which is a copy of an existing\n * one for a specific public key type.\n * EVP_dss1() etc\n */\n#  define EVP_MD_FLAG_PKEY_DIGEST 0x0002\n\n/* Digest uses EVP_PKEY_METHOD for signing instead of MD specific signing */\n\n#  define EVP_MD_FLAG_PKEY_METHOD_SIGNATURE       0x0004\n\n/* DigestAlgorithmIdentifier flags... */\n\n#  define EVP_MD_FLAG_DIGALGID_MASK               0x0018\n\n/* NULL or absent parameter accepted. Use NULL */\n\n#  define EVP_MD_FLAG_DIGALGID_NULL               0x0000\n\n/* NULL or absent parameter accepted. Use NULL for PKCS#1 otherwise absent */\n\n#  define EVP_MD_FLAG_DIGALGID_ABSENT             0x0008\n\n/* Custom handling via ctrl */\n\n#  define EVP_MD_FLAG_DIGALGID_CUSTOM             0x0018\n\n/* Note if suitable for use in FIPS mode */\n#  define EVP_MD_FLAG_FIPS        0x0400\n\n/* Digest ctrls */\n\n#  define EVP_MD_CTRL_DIGALGID                    0x1\n#  define EVP_MD_CTRL_MICALG                      0x2\n\n/* Minimum Algorithm specific ctrl value */\n\n#  define EVP_MD_CTRL_ALG_CTRL                    0x1000\n\n#  define EVP_PKEY_NULL_method    NULL,NULL,{0,0,0,0}\n\n#  ifndef OPENSSL_NO_DSA\n#   define EVP_PKEY_DSA_method     (evp_sign_method *)DSA_sign, \\\n                                (evp_verify_method *)DSA_verify, \\\n                                {EVP_PKEY_DSA,EVP_PKEY_DSA2,EVP_PKEY_DSA3, \\\n                                        EVP_PKEY_DSA4,0}\n#  else\n#   define EVP_PKEY_DSA_method     EVP_PKEY_NULL_method\n#  endif\n\n#  ifndef OPENSSL_NO_ECDSA\n#   define EVP_PKEY_ECDSA_method   (evp_sign_method *)ECDSA_sign, \\\n                                (evp_verify_method *)ECDSA_verify, \\\n                                 {EVP_PKEY_EC,0,0,0}\n#  else\n#   define EVP_PKEY_ECDSA_method   EVP_PKEY_NULL_method\n#  endif\n\n#  ifndef OPENSSL_NO_RSA\n#   define EVP_PKEY_RSA_method     (evp_sign_method *)RSA_sign, \\\n                                (evp_verify_method *)RSA_verify, \\\n                                {EVP_PKEY_RSA,EVP_PKEY_RSA2,0,0}\n#   define EVP_PKEY_RSA_ASN1_OCTET_STRING_method \\\n                                (evp_sign_method *)RSA_sign_ASN1_OCTET_STRING, \\\n                                (evp_verify_method *)RSA_verify_ASN1_OCTET_STRING, \\\n                                {EVP_PKEY_RSA,EVP_PKEY_RSA2,0,0}\n#  else\n#   define EVP_PKEY_RSA_method     EVP_PKEY_NULL_method\n#   define EVP_PKEY_RSA_ASN1_OCTET_STRING_method EVP_PKEY_NULL_method\n#  endif\n\n# endif                         /* !EVP_MD */\n\nstruct env_md_ctx_st {\n    const EVP_MD *digest;\n    ENGINE *engine;             /* functional reference if 'digest' is\n                                 * ENGINE-provided */\n    unsigned long flags;\n    void *md_data;\n    /* Public key context for sign/verify */\n    EVP_PKEY_CTX *pctx;\n    /* Update function: usually copied from EVP_MD */\n    int (*update) (EVP_MD_CTX *ctx, const void *data, size_t count);\n} /* EVP_MD_CTX */ ;\n\n/* values for EVP_MD_CTX flags */\n\n# define EVP_MD_CTX_FLAG_ONESHOT         0x0001/* digest update will be\n                                                * called once only */\n# define EVP_MD_CTX_FLAG_CLEANED         0x0002/* context has already been\n                                                * cleaned */\n# define EVP_MD_CTX_FLAG_REUSE           0x0004/* Don't free up ctx->md_data\n                                                * in EVP_MD_CTX_cleanup */\n/*\n * FIPS and pad options are ignored in 1.0.0, definitions are here so we\n * don't accidentally reuse the values for other purposes.\n */\n\n# define EVP_MD_CTX_FLAG_NON_FIPS_ALLOW  0x0008/* Allow use of non FIPS\n                                                * digest in FIPS mode */\n\n/*\n * The following PAD options are also currently ignored in 1.0.0, digest\n * parameters are handled through EVP_DigestSign*() and EVP_DigestVerify*()\n * instead.\n */\n# define EVP_MD_CTX_FLAG_PAD_MASK        0xF0/* RSA mode to use */\n# define EVP_MD_CTX_FLAG_PAD_PKCS1       0x00/* PKCS#1 v1.5 mode */\n# define EVP_MD_CTX_FLAG_PAD_X931        0x10/* X9.31 mode */\n# define EVP_MD_CTX_FLAG_PAD_PSS         0x20/* PSS mode */\n\n# define EVP_MD_CTX_FLAG_NO_INIT         0x0100/* Don't initialize md_data */\n\nstruct evp_cipher_st {\n    int nid;\n    int block_size;\n    /* Default value for variable length ciphers */\n    int key_len;\n    int iv_len;\n    /* Various flags */\n    unsigned long flags;\n    /* init key */\n    int (*init) (EVP_CIPHER_CTX *ctx, const unsigned char *key,\n                 const unsigned char *iv, int enc);\n    /* encrypt/decrypt data */\n    int (*do_cipher) (EVP_CIPHER_CTX *ctx, unsigned char *out,\n                      const unsigned char *in, size_t inl);\n    /* cleanup ctx */\n    int (*cleanup) (EVP_CIPHER_CTX *);\n    /* how big ctx->cipher_data needs to be */\n    int ctx_size;\n    /* Populate a ASN1_TYPE with parameters */\n    int (*set_asn1_parameters) (EVP_CIPHER_CTX *, ASN1_TYPE *);\n    /* Get parameters from a ASN1_TYPE */\n    int (*get_asn1_parameters) (EVP_CIPHER_CTX *, ASN1_TYPE *);\n    /* Miscellaneous operations */\n    int (*ctrl) (EVP_CIPHER_CTX *, int type, int arg, void *ptr);\n    /* Application data */\n    void *app_data;\n} /* EVP_CIPHER */ ;\n\n/* Values for cipher flags */\n\n/* Modes for ciphers */\n\n# define         EVP_CIPH_STREAM_CIPHER          0x0\n# define         EVP_CIPH_ECB_MODE               0x1\n# define         EVP_CIPH_CBC_MODE               0x2\n# define         EVP_CIPH_CFB_MODE               0x3\n# define         EVP_CIPH_OFB_MODE               0x4\n# define         EVP_CIPH_CTR_MODE               0x5\n# define         EVP_CIPH_GCM_MODE               0x6\n# define         EVP_CIPH_CCM_MODE               0x7\n# define         EVP_CIPH_XTS_MODE               0x10001\n# define         EVP_CIPH_WRAP_MODE              0x10002\n# define         EVP_CIPH_MODE                   0xF0007\n/* Set if variable length cipher */\n# define         EVP_CIPH_VARIABLE_LENGTH        0x8\n/* Set if the iv handling should be done by the cipher itself */\n# define         EVP_CIPH_CUSTOM_IV              0x10\n/* Set if the cipher's init() function should be called if key is NULL */\n# define         EVP_CIPH_ALWAYS_CALL_INIT       0x20\n/* Call ctrl() to init cipher parameters */\n# define         EVP_CIPH_CTRL_INIT              0x40\n/* Don't use standard key length function */\n# define         EVP_CIPH_CUSTOM_KEY_LENGTH      0x80\n/* Don't use standard block padding */\n# define         EVP_CIPH_NO_PADDING             0x100\n/* cipher handles random key generation */\n# define         EVP_CIPH_RAND_KEY               0x200\n/* cipher has its own additional copying logic */\n# define         EVP_CIPH_CUSTOM_COPY            0x400\n/* Allow use default ASN1 get/set iv */\n# define         EVP_CIPH_FLAG_DEFAULT_ASN1      0x1000\n/* Buffer length in bits not bytes: CFB1 mode only */\n# define         EVP_CIPH_FLAG_LENGTH_BITS       0x2000\n/* Note if suitable for use in FIPS mode */\n# define         EVP_CIPH_FLAG_FIPS              0x4000\n/* Allow non FIPS cipher in FIPS mode */\n# define         EVP_CIPH_FLAG_NON_FIPS_ALLOW    0x8000\n/*\n * Cipher handles any and all padding logic as well as finalisation.\n */\n# define         EVP_CIPH_FLAG_CUSTOM_CIPHER     0x100000\n# define         EVP_CIPH_FLAG_AEAD_CIPHER       0x200000\n# define         EVP_CIPH_FLAG_TLS1_1_MULTIBLOCK 0x400000\n\n/*\n * Cipher context flag to indicate we can handle wrap mode: if allowed in\n * older applications it could overflow buffers.\n */\n\n# define         EVP_CIPHER_CTX_FLAG_WRAP_ALLOW  0x1\n\n/* ctrl() values */\n\n# define         EVP_CTRL_INIT                   0x0\n# define         EVP_CTRL_SET_KEY_LENGTH         0x1\n# define         EVP_CTRL_GET_RC2_KEY_BITS       0x2\n# define         EVP_CTRL_SET_RC2_KEY_BITS       0x3\n# define         EVP_CTRL_GET_RC5_ROUNDS         0x4\n# define         EVP_CTRL_SET_RC5_ROUNDS         0x5\n# define         EVP_CTRL_RAND_KEY               0x6\n# define         EVP_CTRL_PBE_PRF_NID            0x7\n# define         EVP_CTRL_COPY                   0x8\n# define         EVP_CTRL_GCM_SET_IVLEN          0x9\n# define         EVP_CTRL_GCM_GET_TAG            0x10\n# define         EVP_CTRL_GCM_SET_TAG            0x11\n# define         EVP_CTRL_GCM_SET_IV_FIXED       0x12\n# define         EVP_CTRL_GCM_IV_GEN             0x13\n# define         EVP_CTRL_CCM_SET_IVLEN          EVP_CTRL_GCM_SET_IVLEN\n# define         EVP_CTRL_CCM_GET_TAG            EVP_CTRL_GCM_GET_TAG\n# define         EVP_CTRL_CCM_SET_TAG            EVP_CTRL_GCM_SET_TAG\n# define         EVP_CTRL_CCM_SET_L              0x14\n# define         EVP_CTRL_CCM_SET_MSGLEN         0x15\n/*\n * AEAD cipher deduces payload length and returns number of bytes required to\n * store MAC and eventual padding. Subsequent call to EVP_Cipher even\n * appends/verifies MAC.\n */\n# define         EVP_CTRL_AEAD_TLS1_AAD          0x16\n/* Used by composite AEAD ciphers, no-op in GCM, CCM... */\n# define         EVP_CTRL_AEAD_SET_MAC_KEY       0x17\n/* Set the GCM invocation field, decrypt only */\n# define         EVP_CTRL_GCM_SET_IV_INV         0x18\n\n# define         EVP_CTRL_TLS1_1_MULTIBLOCK_AAD  0x19\n# define         EVP_CTRL_TLS1_1_MULTIBLOCK_ENCRYPT      0x1a\n# define         EVP_CTRL_TLS1_1_MULTIBLOCK_DECRYPT      0x1b\n# define         EVP_CTRL_TLS1_1_MULTIBLOCK_MAX_BUFSIZE  0x1c\n\n/* RFC 5246 defines additional data to be 13 bytes in length */\n# define         EVP_AEAD_TLS1_AAD_LEN           13\n\ntypedef struct {\n    unsigned char *out;\n    const unsigned char *inp;\n    size_t len;\n    unsigned int interleave;\n} EVP_CTRL_TLS1_1_MULTIBLOCK_PARAM;\n\n/* GCM TLS constants */\n/* Length of fixed part of IV derived from PRF */\n# define EVP_GCM_TLS_FIXED_IV_LEN                        4\n/* Length of explicit part of IV part of TLS records */\n# define EVP_GCM_TLS_EXPLICIT_IV_LEN                     8\n/* Length of tag for TLS */\n# define EVP_GCM_TLS_TAG_LEN                             16\n\ntypedef struct evp_cipher_info_st {\n    const EVP_CIPHER *cipher;\n    unsigned char iv[EVP_MAX_IV_LENGTH];\n} EVP_CIPHER_INFO;\n\nstruct evp_cipher_ctx_st {\n    const EVP_CIPHER *cipher;\n    ENGINE *engine;             /* functional reference if 'cipher' is\n                                 * ENGINE-provided */\n    int encrypt;                /* encrypt or decrypt */\n    int buf_len;                /* number we have left */\n    unsigned char oiv[EVP_MAX_IV_LENGTH]; /* original iv */\n    unsigned char iv[EVP_MAX_IV_LENGTH]; /* working iv */\n    unsigned char buf[EVP_MAX_BLOCK_LENGTH]; /* saved partial block */\n    int num;                    /* used by cfb/ofb/ctr mode */\n    void *app_data;             /* application stuff */\n    int key_len;                /* May change for variable length cipher */\n    unsigned long flags;        /* Various flags */\n    void *cipher_data;          /* per EVP data */\n    int final_used;\n    int block_mask;\n    unsigned char final[EVP_MAX_BLOCK_LENGTH]; /* possible final block */\n} /* EVP_CIPHER_CTX */ ;\n\ntypedef struct evp_Encode_Ctx_st {\n    /* number saved in a partial encode/decode */\n    int num;\n    /*\n     * The length is either the output line length (in input bytes) or the\n     * shortest input line length that is ok.  Once decoding begins, the\n     * length is adjusted up each time a longer line is decoded\n     */\n    int length;\n    /* data to encode */\n    unsigned char enc_data[80];\n    /* number read on current line */\n    int line_num;\n    int expect_nl;\n} EVP_ENCODE_CTX;\n\n/* Password based encryption function */\ntypedef int (EVP_PBE_KEYGEN) (EVP_CIPHER_CTX *ctx, const char *pass,\n                              int passlen, ASN1_TYPE *param,\n                              const EVP_CIPHER *cipher, const EVP_MD *md,\n                              int en_de);\n\n# ifndef OPENSSL_NO_RSA\n#  define EVP_PKEY_assign_RSA(pkey,rsa) EVP_PKEY_assign((pkey),EVP_PKEY_RSA,\\\n                                        (char *)(rsa))\n# endif\n\n# ifndef OPENSSL_NO_DSA\n#  define EVP_PKEY_assign_DSA(pkey,dsa) EVP_PKEY_assign((pkey),EVP_PKEY_DSA,\\\n                                        (char *)(dsa))\n# endif\n\n# ifndef OPENSSL_NO_DH\n#  define EVP_PKEY_assign_DH(pkey,dh) EVP_PKEY_assign((pkey),EVP_PKEY_DH,\\\n                                        (char *)(dh))\n# endif\n\n# ifndef OPENSSL_NO_EC\n#  define EVP_PKEY_assign_EC_KEY(pkey,eckey) EVP_PKEY_assign((pkey),EVP_PKEY_EC,\\\n                                        (char *)(eckey))\n# endif\n\n/* Add some extra combinations */\n# define EVP_get_digestbynid(a) EVP_get_digestbyname(OBJ_nid2sn(a))\n# define EVP_get_digestbyobj(a) EVP_get_digestbynid(OBJ_obj2nid(a))\n# define EVP_get_cipherbynid(a) EVP_get_cipherbyname(OBJ_nid2sn(a))\n# define EVP_get_cipherbyobj(a) EVP_get_cipherbynid(OBJ_obj2nid(a))\n\nint EVP_MD_type(const EVP_MD *md);\n# define EVP_MD_nid(e)                   EVP_MD_type(e)\n# define EVP_MD_name(e)                  OBJ_nid2sn(EVP_MD_nid(e))\nint EVP_MD_pkey_type(const EVP_MD *md);\nint EVP_MD_size(const EVP_MD *md);\nint EVP_MD_block_size(const EVP_MD *md);\nunsigned long EVP_MD_flags(const EVP_MD *md);\n\nconst EVP_MD *EVP_MD_CTX_md(const EVP_MD_CTX *ctx);\n# define EVP_MD_CTX_size(e)              EVP_MD_size(EVP_MD_CTX_md(e))\n# define EVP_MD_CTX_block_size(e)        EVP_MD_block_size(EVP_MD_CTX_md(e))\n# define EVP_MD_CTX_type(e)              EVP_MD_type(EVP_MD_CTX_md(e))\n\nint EVP_CIPHER_nid(const EVP_CIPHER *cipher);\n# define EVP_CIPHER_name(e)              OBJ_nid2sn(EVP_CIPHER_nid(e))\nint EVP_CIPHER_block_size(const EVP_CIPHER *cipher);\nint EVP_CIPHER_key_length(const EVP_CIPHER *cipher);\nint EVP_CIPHER_iv_length(const EVP_CIPHER *cipher);\nunsigned long EVP_CIPHER_flags(const EVP_CIPHER *cipher);\n# define EVP_CIPHER_mode(e)              (EVP_CIPHER_flags(e) & EVP_CIPH_MODE)\n\nconst EVP_CIPHER *EVP_CIPHER_CTX_cipher(const EVP_CIPHER_CTX *ctx);\nint EVP_CIPHER_CTX_nid(const EVP_CIPHER_CTX *ctx);\nint EVP_CIPHER_CTX_block_size(const EVP_CIPHER_CTX *ctx);\nint EVP_CIPHER_CTX_key_length(const EVP_CIPHER_CTX *ctx);\nint EVP_CIPHER_CTX_iv_length(const EVP_CIPHER_CTX *ctx);\nint EVP_CIPHER_CTX_copy(EVP_CIPHER_CTX *out, const EVP_CIPHER_CTX *in);\nvoid *EVP_CIPHER_CTX_get_app_data(const EVP_CIPHER_CTX *ctx);\nvoid EVP_CIPHER_CTX_set_app_data(EVP_CIPHER_CTX *ctx, void *data);\n# define EVP_CIPHER_CTX_type(c)         EVP_CIPHER_type(EVP_CIPHER_CTX_cipher(c))\nunsigned long EVP_CIPHER_CTX_flags(const EVP_CIPHER_CTX *ctx);\n# define EVP_CIPHER_CTX_mode(e)          (EVP_CIPHER_CTX_flags(e) & EVP_CIPH_MODE)\n\n# define EVP_ENCODE_LENGTH(l)    (((l+2)/3*4)+(l/48+1)*2+80)\n# define EVP_DECODE_LENGTH(l)    ((l+3)/4*3+80)\n\n# define EVP_SignInit_ex(a,b,c)          EVP_DigestInit_ex(a,b,c)\n# define EVP_SignInit(a,b)               EVP_DigestInit(a,b)\n# define EVP_SignUpdate(a,b,c)           EVP_DigestUpdate(a,b,c)\n# define EVP_VerifyInit_ex(a,b,c)        EVP_DigestInit_ex(a,b,c)\n# define EVP_VerifyInit(a,b)             EVP_DigestInit(a,b)\n# define EVP_VerifyUpdate(a,b,c)         EVP_DigestUpdate(a,b,c)\n# define EVP_OpenUpdate(a,b,c,d,e)       EVP_DecryptUpdate(a,b,c,d,e)\n# define EVP_SealUpdate(a,b,c,d,e)       EVP_EncryptUpdate(a,b,c,d,e)\n# define EVP_DigestSignUpdate(a,b,c)     EVP_DigestUpdate(a,b,c)\n# define EVP_DigestVerifyUpdate(a,b,c)   EVP_DigestUpdate(a,b,c)\n\n# ifdef CONST_STRICT\nvoid BIO_set_md(BIO *, const EVP_MD *md);\n# else\n#  define BIO_set_md(b,md)               BIO_ctrl(b,BIO_C_SET_MD,0,(char *)md)\n# endif\n# define BIO_get_md(b,mdp)               BIO_ctrl(b,BIO_C_GET_MD,0,(char *)mdp)\n# define BIO_get_md_ctx(b,mdcp)     BIO_ctrl(b,BIO_C_GET_MD_CTX,0,(char *)mdcp)\n# define BIO_set_md_ctx(b,mdcp)     BIO_ctrl(b,BIO_C_SET_MD_CTX,0,(char *)mdcp)\n# define BIO_get_cipher_status(b)        BIO_ctrl(b,BIO_C_GET_CIPHER_STATUS,0,NULL)\n# define BIO_get_cipher_ctx(b,c_pp)      BIO_ctrl(b,BIO_C_GET_CIPHER_CTX,0,(char *)c_pp)\n\nint EVP_Cipher(EVP_CIPHER_CTX *c,\n               unsigned char *out, const unsigned char *in, unsigned int inl);\n\n# define EVP_add_cipher_alias(n,alias) \\\n        OBJ_NAME_add((alias),OBJ_NAME_TYPE_CIPHER_METH|OBJ_NAME_ALIAS,(n))\n# define EVP_add_digest_alias(n,alias) \\\n        OBJ_NAME_add((alias),OBJ_NAME_TYPE_MD_METH|OBJ_NAME_ALIAS,(n))\n# define EVP_delete_cipher_alias(alias) \\\n        OBJ_NAME_remove(alias,OBJ_NAME_TYPE_CIPHER_METH|OBJ_NAME_ALIAS);\n# define EVP_delete_digest_alias(alias) \\\n        OBJ_NAME_remove(alias,OBJ_NAME_TYPE_MD_METH|OBJ_NAME_ALIAS);\n\nvoid EVP_MD_CTX_init(EVP_MD_CTX *ctx);\nint EVP_MD_CTX_cleanup(EVP_MD_CTX *ctx);\nEVP_MD_CTX *EVP_MD_CTX_create(void);\nvoid EVP_MD_CTX_destroy(EVP_MD_CTX *ctx);\nint EVP_MD_CTX_copy_ex(EVP_MD_CTX *out, const EVP_MD_CTX *in);\nvoid EVP_MD_CTX_set_flags(EVP_MD_CTX *ctx, int flags);\nvoid EVP_MD_CTX_clear_flags(EVP_MD_CTX *ctx, int flags);\nint EVP_MD_CTX_test_flags(const EVP_MD_CTX *ctx, int flags);\nint EVP_DigestInit_ex(EVP_MD_CTX *ctx, const EVP_MD *type, ENGINE *impl);\nint EVP_DigestUpdate(EVP_MD_CTX *ctx, const void *d, size_t cnt);\nint EVP_DigestFinal_ex(EVP_MD_CTX *ctx, unsigned char *md, unsigned int *s);\nint EVP_Digest(const void *data, size_t count,\n               unsigned char *md, unsigned int *size, const EVP_MD *type,\n               ENGINE *impl);\n\nint EVP_MD_CTX_copy(EVP_MD_CTX *out, const EVP_MD_CTX *in);\nint EVP_DigestInit(EVP_MD_CTX *ctx, const EVP_MD *type);\nint EVP_DigestFinal(EVP_MD_CTX *ctx, unsigned char *md, unsigned int *s);\n\nint EVP_read_pw_string(char *buf, int length, const char *prompt, int verify);\nint EVP_read_pw_string_min(char *buf, int minlen, int maxlen,\n                           const char *prompt, int verify);\nvoid EVP_set_pw_prompt(const char *prompt);\nchar *EVP_get_pw_prompt(void);\n\nint EVP_BytesToKey(const EVP_CIPHER *type, const EVP_MD *md,\n                   const unsigned char *salt, const unsigned char *data,\n                   int datal, int count, unsigned char *key,\n                   unsigned char *iv);\n\nvoid EVP_CIPHER_CTX_set_flags(EVP_CIPHER_CTX *ctx, int flags);\nvoid EVP_CIPHER_CTX_clear_flags(EVP_CIPHER_CTX *ctx, int flags);\nint EVP_CIPHER_CTX_test_flags(const EVP_CIPHER_CTX *ctx, int flags);\n\nint EVP_EncryptInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher,\n                    const unsigned char *key, const unsigned char *iv);\nint EVP_EncryptInit_ex(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher,\n                       ENGINE *impl, const unsigned char *key,\n                       const unsigned char *iv);\nint EVP_EncryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl,\n                      const unsigned char *in, int inl);\nint EVP_EncryptFinal_ex(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl);\nint EVP_EncryptFinal(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl);\n\nint EVP_DecryptInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher,\n                    const unsigned char *key, const unsigned char *iv);\nint EVP_DecryptInit_ex(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher,\n                       ENGINE *impl, const unsigned char *key,\n                       const unsigned char *iv);\nint EVP_DecryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl,\n                      const unsigned char *in, int inl);\nint EVP_DecryptFinal(EVP_CIPHER_CTX *ctx, unsigned char *outm, int *outl);\nint EVP_DecryptFinal_ex(EVP_CIPHER_CTX *ctx, unsigned char *outm, int *outl);\n\nint EVP_CipherInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher,\n                   const unsigned char *key, const unsigned char *iv,\n                   int enc);\nint EVP_CipherInit_ex(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher,\n                      ENGINE *impl, const unsigned char *key,\n                      const unsigned char *iv, int enc);\nint EVP_CipherUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl,\n                     const unsigned char *in, int inl);\nint EVP_CipherFinal(EVP_CIPHER_CTX *ctx, unsigned char *outm, int *outl);\nint EVP_CipherFinal_ex(EVP_CIPHER_CTX *ctx, unsigned char *outm, int *outl);\n\nint EVP_SignFinal(EVP_MD_CTX *ctx, unsigned char *md, unsigned int *s,\n                  EVP_PKEY *pkey);\n\nint EVP_VerifyFinal(EVP_MD_CTX *ctx, const unsigned char *sigbuf,\n                    unsigned int siglen, EVP_PKEY *pkey);\n\nint EVP_DigestSignInit(EVP_MD_CTX *ctx, EVP_PKEY_CTX **pctx,\n                       const EVP_MD *type, ENGINE *e, EVP_PKEY *pkey);\nint EVP_DigestSignFinal(EVP_MD_CTX *ctx,\n                        unsigned char *sigret, size_t *siglen);\n\nint EVP_DigestVerifyInit(EVP_MD_CTX *ctx, EVP_PKEY_CTX **pctx,\n                         const EVP_MD *type, ENGINE *e, EVP_PKEY *pkey);\nint EVP_DigestVerifyFinal(EVP_MD_CTX *ctx,\n                          const unsigned char *sig, size_t siglen);\n\nint EVP_OpenInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *type,\n                 const unsigned char *ek, int ekl, const unsigned char *iv,\n                 EVP_PKEY *priv);\nint EVP_OpenFinal(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl);\n\nint EVP_SealInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *type,\n                 unsigned char **ek, int *ekl, unsigned char *iv,\n                 EVP_PKEY **pubk, int npubk);\nint EVP_SealFinal(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl);\n\nvoid EVP_EncodeInit(EVP_ENCODE_CTX *ctx);\nvoid EVP_EncodeUpdate(EVP_ENCODE_CTX *ctx, unsigned char *out, int *outl,\n                      const unsigned char *in, int inl);\nvoid EVP_EncodeFinal(EVP_ENCODE_CTX *ctx, unsigned char *out, int *outl);\nint EVP_EncodeBlock(unsigned char *t, const unsigned char *f, int n);\n\nvoid EVP_DecodeInit(EVP_ENCODE_CTX *ctx);\nint EVP_DecodeUpdate(EVP_ENCODE_CTX *ctx, unsigned char *out, int *outl,\n                     const unsigned char *in, int inl);\nint EVP_DecodeFinal(EVP_ENCODE_CTX *ctx, unsigned\n                    char *out, int *outl);\nint EVP_DecodeBlock(unsigned char *t, const unsigned char *f, int n);\n\nvoid EVP_CIPHER_CTX_init(EVP_CIPHER_CTX *a);\nint EVP_CIPHER_CTX_cleanup(EVP_CIPHER_CTX *a);\nEVP_CIPHER_CTX *EVP_CIPHER_CTX_new(void);\nvoid EVP_CIPHER_CTX_free(EVP_CIPHER_CTX *a);\nint EVP_CIPHER_CTX_set_key_length(EVP_CIPHER_CTX *x, int keylen);\nint EVP_CIPHER_CTX_set_padding(EVP_CIPHER_CTX *c, int pad);\nint EVP_CIPHER_CTX_ctrl(EVP_CIPHER_CTX *ctx, int type, int arg, void *ptr);\nint EVP_CIPHER_CTX_rand_key(EVP_CIPHER_CTX *ctx, unsigned char *key);\n\n# ifndef OPENSSL_NO_BIO\nBIO_METHOD *BIO_f_md(void);\nBIO_METHOD *BIO_f_base64(void);\nBIO_METHOD *BIO_f_cipher(void);\nBIO_METHOD *BIO_f_reliable(void);\nvoid BIO_set_cipher(BIO *b, const EVP_CIPHER *c, const unsigned char *k,\n                    const unsigned char *i, int enc);\n# endif\n\nconst EVP_MD *EVP_md_null(void);\n# ifndef OPENSSL_NO_MD2\nconst EVP_MD *EVP_md2(void);\n# endif\n# ifndef OPENSSL_NO_MD4\nconst EVP_MD *EVP_md4(void);\n# endif\n# ifndef OPENSSL_NO_MD5\nconst EVP_MD *EVP_md5(void);\n# endif\n# ifndef OPENSSL_NO_SHA\nconst EVP_MD *EVP_sha(void);\nconst EVP_MD *EVP_sha1(void);\nconst EVP_MD *EVP_dss(void);\nconst EVP_MD *EVP_dss1(void);\nconst EVP_MD *EVP_ecdsa(void);\n# endif\n# ifndef OPENSSL_NO_SHA256\nconst EVP_MD *EVP_sha224(void);\nconst EVP_MD *EVP_sha256(void);\n# endif\n# ifndef OPENSSL_NO_SHA512\nconst EVP_MD *EVP_sha384(void);\nconst EVP_MD *EVP_sha512(void);\n# endif\n# ifndef OPENSSL_NO_MDC2\nconst EVP_MD *EVP_mdc2(void);\n# endif\n# ifndef OPENSSL_NO_RIPEMD\nconst EVP_MD *EVP_ripemd160(void);\n# endif\n# ifndef OPENSSL_NO_WHIRLPOOL\nconst EVP_MD *EVP_whirlpool(void);\n# endif\nconst EVP_CIPHER *EVP_enc_null(void); /* does nothing :-) */\n# ifndef OPENSSL_NO_DES\nconst EVP_CIPHER *EVP_des_ecb(void);\nconst EVP_CIPHER *EVP_des_ede(void);\nconst EVP_CIPHER *EVP_des_ede3(void);\nconst EVP_CIPHER *EVP_des_ede_ecb(void);\nconst EVP_CIPHER *EVP_des_ede3_ecb(void);\nconst EVP_CIPHER *EVP_des_cfb64(void);\n#  define EVP_des_cfb EVP_des_cfb64\nconst EVP_CIPHER *EVP_des_cfb1(void);\nconst EVP_CIPHER *EVP_des_cfb8(void);\nconst EVP_CIPHER *EVP_des_ede_cfb64(void);\n#  define EVP_des_ede_cfb EVP_des_ede_cfb64\n#  if 0\nconst EVP_CIPHER *EVP_des_ede_cfb1(void);\nconst EVP_CIPHER *EVP_des_ede_cfb8(void);\n#  endif\nconst EVP_CIPHER *EVP_des_ede3_cfb64(void);\n#  define EVP_des_ede3_cfb EVP_des_ede3_cfb64\nconst EVP_CIPHER *EVP_des_ede3_cfb1(void);\nconst EVP_CIPHER *EVP_des_ede3_cfb8(void);\nconst EVP_CIPHER *EVP_des_ofb(void);\nconst EVP_CIPHER *EVP_des_ede_ofb(void);\nconst EVP_CIPHER *EVP_des_ede3_ofb(void);\nconst EVP_CIPHER *EVP_des_cbc(void);\nconst EVP_CIPHER *EVP_des_ede_cbc(void);\nconst EVP_CIPHER *EVP_des_ede3_cbc(void);\nconst EVP_CIPHER *EVP_desx_cbc(void);\nconst EVP_CIPHER *EVP_des_ede3_wrap(void);\n/*\n * This should now be supported through the dev_crypto ENGINE. But also, why\n * are rc4 and md5 declarations made here inside a \"NO_DES\" precompiler\n * branch?\n */\n#  if 0\n#   ifdef OPENSSL_OPENBSD_DEV_CRYPTO\nconst EVP_CIPHER *EVP_dev_crypto_des_ede3_cbc(void);\nconst EVP_CIPHER *EVP_dev_crypto_rc4(void);\nconst EVP_MD *EVP_dev_crypto_md5(void);\n#   endif\n#  endif\n# endif\n# ifndef OPENSSL_NO_RC4\nconst EVP_CIPHER *EVP_rc4(void);\nconst EVP_CIPHER *EVP_rc4_40(void);\n#  ifndef OPENSSL_NO_MD5\nconst EVP_CIPHER *EVP_rc4_hmac_md5(void);\n#  endif\n# endif\n# ifndef OPENSSL_NO_IDEA\nconst EVP_CIPHER *EVP_idea_ecb(void);\nconst EVP_CIPHER *EVP_idea_cfb64(void);\n#  define EVP_idea_cfb EVP_idea_cfb64\nconst EVP_CIPHER *EVP_idea_ofb(void);\nconst EVP_CIPHER *EVP_idea_cbc(void);\n# endif\n# ifndef OPENSSL_NO_RC2\nconst EVP_CIPHER *EVP_rc2_ecb(void);\nconst EVP_CIPHER *EVP_rc2_cbc(void);\nconst EVP_CIPHER *EVP_rc2_40_cbc(void);\nconst EVP_CIPHER *EVP_rc2_64_cbc(void);\nconst EVP_CIPHER *EVP_rc2_cfb64(void);\n#  define EVP_rc2_cfb EVP_rc2_cfb64\nconst EVP_CIPHER *EVP_rc2_ofb(void);\n# endif\n# ifndef OPENSSL_NO_BF\nconst EVP_CIPHER *EVP_bf_ecb(void);\nconst EVP_CIPHER *EVP_bf_cbc(void);\nconst EVP_CIPHER *EVP_bf_cfb64(void);\n#  define EVP_bf_cfb EVP_bf_cfb64\nconst EVP_CIPHER *EVP_bf_ofb(void);\n# endif\n# ifndef OPENSSL_NO_CAST\nconst EVP_CIPHER *EVP_cast5_ecb(void);\nconst EVP_CIPHER *EVP_cast5_cbc(void);\nconst EVP_CIPHER *EVP_cast5_cfb64(void);\n#  define EVP_cast5_cfb EVP_cast5_cfb64\nconst EVP_CIPHER *EVP_cast5_ofb(void);\n# endif\n# ifndef OPENSSL_NO_RC5\nconst EVP_CIPHER *EVP_rc5_32_12_16_cbc(void);\nconst EVP_CIPHER *EVP_rc5_32_12_16_ecb(void);\nconst EVP_CIPHER *EVP_rc5_32_12_16_cfb64(void);\n#  define EVP_rc5_32_12_16_cfb EVP_rc5_32_12_16_cfb64\nconst EVP_CIPHER *EVP_rc5_32_12_16_ofb(void);\n# endif\n# ifndef OPENSSL_NO_AES\nconst EVP_CIPHER *EVP_aes_128_ecb(void);\nconst EVP_CIPHER *EVP_aes_128_cbc(void);\nconst EVP_CIPHER *EVP_aes_128_cfb1(void);\nconst EVP_CIPHER *EVP_aes_128_cfb8(void);\nconst EVP_CIPHER *EVP_aes_128_cfb128(void);\n#  define EVP_aes_128_cfb EVP_aes_128_cfb128\nconst EVP_CIPHER *EVP_aes_128_ofb(void);\nconst EVP_CIPHER *EVP_aes_128_ctr(void);\nconst EVP_CIPHER *EVP_aes_128_ccm(void);\nconst EVP_CIPHER *EVP_aes_128_gcm(void);\nconst EVP_CIPHER *EVP_aes_128_xts(void);\nconst EVP_CIPHER *EVP_aes_128_wrap(void);\nconst EVP_CIPHER *EVP_aes_192_ecb(void);\nconst EVP_CIPHER *EVP_aes_192_cbc(void);\nconst EVP_CIPHER *EVP_aes_192_cfb1(void);\nconst EVP_CIPHER *EVP_aes_192_cfb8(void);\nconst EVP_CIPHER *EVP_aes_192_cfb128(void);\n#  define EVP_aes_192_cfb EVP_aes_192_cfb128\nconst EVP_CIPHER *EVP_aes_192_ofb(void);\nconst EVP_CIPHER *EVP_aes_192_ctr(void);\nconst EVP_CIPHER *EVP_aes_192_ccm(void);\nconst EVP_CIPHER *EVP_aes_192_gcm(void);\nconst EVP_CIPHER *EVP_aes_192_wrap(void);\nconst EVP_CIPHER *EVP_aes_256_ecb(void);\nconst EVP_CIPHER *EVP_aes_256_cbc(void);\nconst EVP_CIPHER *EVP_aes_256_cfb1(void);\nconst EVP_CIPHER *EVP_aes_256_cfb8(void);\nconst EVP_CIPHER *EVP_aes_256_cfb128(void);\n#  define EVP_aes_256_cfb EVP_aes_256_cfb128\nconst EVP_CIPHER *EVP_aes_256_ofb(void);\nconst EVP_CIPHER *EVP_aes_256_ctr(void);\nconst EVP_CIPHER *EVP_aes_256_ccm(void);\nconst EVP_CIPHER *EVP_aes_256_gcm(void);\nconst EVP_CIPHER *EVP_aes_256_xts(void);\nconst EVP_CIPHER *EVP_aes_256_wrap(void);\n#  if !defined(OPENSSL_NO_SHA) && !defined(OPENSSL_NO_SHA1)\nconst EVP_CIPHER *EVP_aes_128_cbc_hmac_sha1(void);\nconst EVP_CIPHER *EVP_aes_256_cbc_hmac_sha1(void);\n#  endif\n#  ifndef OPENSSL_NO_SHA256\nconst EVP_CIPHER *EVP_aes_128_cbc_hmac_sha256(void);\nconst EVP_CIPHER *EVP_aes_256_cbc_hmac_sha256(void);\n#  endif\n# endif\n# ifndef OPENSSL_NO_CAMELLIA\nconst EVP_CIPHER *EVP_camellia_128_ecb(void);\nconst EVP_CIPHER *EVP_camellia_128_cbc(void);\nconst EVP_CIPHER *EVP_camellia_128_cfb1(void);\nconst EVP_CIPHER *EVP_camellia_128_cfb8(void);\nconst EVP_CIPHER *EVP_camellia_128_cfb128(void);\n#  define EVP_camellia_128_cfb EVP_camellia_128_cfb128\nconst EVP_CIPHER *EVP_camellia_128_ofb(void);\nconst EVP_CIPHER *EVP_camellia_192_ecb(void);\nconst EVP_CIPHER *EVP_camellia_192_cbc(void);\nconst EVP_CIPHER *EVP_camellia_192_cfb1(void);\nconst EVP_CIPHER *EVP_camellia_192_cfb8(void);\nconst EVP_CIPHER *EVP_camellia_192_cfb128(void);\n#  define EVP_camellia_192_cfb EVP_camellia_192_cfb128\nconst EVP_CIPHER *EVP_camellia_192_ofb(void);\nconst EVP_CIPHER *EVP_camellia_256_ecb(void);\nconst EVP_CIPHER *EVP_camellia_256_cbc(void);\nconst EVP_CIPHER *EVP_camellia_256_cfb1(void);\nconst EVP_CIPHER *EVP_camellia_256_cfb8(void);\nconst EVP_CIPHER *EVP_camellia_256_cfb128(void);\n#  define EVP_camellia_256_cfb EVP_camellia_256_cfb128\nconst EVP_CIPHER *EVP_camellia_256_ofb(void);\n# endif\n\n# ifndef OPENSSL_NO_SEED\nconst EVP_CIPHER *EVP_seed_ecb(void);\nconst EVP_CIPHER *EVP_seed_cbc(void);\nconst EVP_CIPHER *EVP_seed_cfb128(void);\n#  define EVP_seed_cfb EVP_seed_cfb128\nconst EVP_CIPHER *EVP_seed_ofb(void);\n# endif\n\nvoid OPENSSL_add_all_algorithms_noconf(void);\nvoid OPENSSL_add_all_algorithms_conf(void);\n\n# ifdef OPENSSL_LOAD_CONF\n#  define OpenSSL_add_all_algorithms() \\\n                OPENSSL_add_all_algorithms_conf()\n# else\n#  define OpenSSL_add_all_algorithms() \\\n                OPENSSL_add_all_algorithms_noconf()\n# endif\n\nvoid OpenSSL_add_all_ciphers(void);\nvoid OpenSSL_add_all_digests(void);\n# define SSLeay_add_all_algorithms() OpenSSL_add_all_algorithms()\n# define SSLeay_add_all_ciphers() OpenSSL_add_all_ciphers()\n# define SSLeay_add_all_digests() OpenSSL_add_all_digests()\n\nint EVP_add_cipher(const EVP_CIPHER *cipher);\nint EVP_add_digest(const EVP_MD *digest);\n\nconst EVP_CIPHER *EVP_get_cipherbyname(const char *name);\nconst EVP_MD *EVP_get_digestbyname(const char *name);\nvoid EVP_cleanup(void);\n\nvoid EVP_CIPHER_do_all(void (*fn) (const EVP_CIPHER *ciph,\n                                   const char *from, const char *to, void *x),\n                       void *arg);\nvoid EVP_CIPHER_do_all_sorted(void (*fn)\n                               (const EVP_CIPHER *ciph, const char *from,\n                                const char *to, void *x), void *arg);\n\nvoid EVP_MD_do_all(void (*fn) (const EVP_MD *ciph,\n                               const char *from, const char *to, void *x),\n                   void *arg);\nvoid EVP_MD_do_all_sorted(void (*fn)\n                           (const EVP_MD *ciph, const char *from,\n                            const char *to, void *x), void *arg);\n\nint EVP_PKEY_decrypt_old(unsigned char *dec_key,\n                         const unsigned char *enc_key, int enc_key_len,\n                         EVP_PKEY *private_key);\nint EVP_PKEY_encrypt_old(unsigned char *enc_key,\n                         const unsigned char *key, int key_len,\n                         EVP_PKEY *pub_key);\nint EVP_PKEY_type(int type);\nint EVP_PKEY_id(const EVP_PKEY *pkey);\nint EVP_PKEY_base_id(const EVP_PKEY *pkey);\nint EVP_PKEY_bits(EVP_PKEY *pkey);\nint EVP_PKEY_size(EVP_PKEY *pkey);\nint EVP_PKEY_set_type(EVP_PKEY *pkey, int type);\nint EVP_PKEY_set_type_str(EVP_PKEY *pkey, const char *str, int len);\nint EVP_PKEY_assign(EVP_PKEY *pkey, int type, void *key);\nvoid *EVP_PKEY_get0(EVP_PKEY *pkey);\n\n# ifndef OPENSSL_NO_RSA\nstruct rsa_st;\nint EVP_PKEY_set1_RSA(EVP_PKEY *pkey, struct rsa_st *key);\nstruct rsa_st *EVP_PKEY_get1_RSA(EVP_PKEY *pkey);\n# endif\n# ifndef OPENSSL_NO_DSA\nstruct dsa_st;\nint EVP_PKEY_set1_DSA(EVP_PKEY *pkey, struct dsa_st *key);\nstruct dsa_st *EVP_PKEY_get1_DSA(EVP_PKEY *pkey);\n# endif\n# ifndef OPENSSL_NO_DH\nstruct dh_st;\nint EVP_PKEY_set1_DH(EVP_PKEY *pkey, struct dh_st *key);\nstruct dh_st *EVP_PKEY_get1_DH(EVP_PKEY *pkey);\n# endif\n# ifndef OPENSSL_NO_EC\nstruct ec_key_st;\nint EVP_PKEY_set1_EC_KEY(EVP_PKEY *pkey, struct ec_key_st *key);\nstruct ec_key_st *EVP_PKEY_get1_EC_KEY(EVP_PKEY *pkey);\n# endif\n\nEVP_PKEY *EVP_PKEY_new(void);\nvoid EVP_PKEY_free(EVP_PKEY *pkey);\n\nEVP_PKEY *d2i_PublicKey(int type, EVP_PKEY **a, const unsigned char **pp,\n                        long length);\nint i2d_PublicKey(EVP_PKEY *a, unsigned char **pp);\n\nEVP_PKEY *d2i_PrivateKey(int type, EVP_PKEY **a, const unsigned char **pp,\n                         long length);\nEVP_PKEY *d2i_AutoPrivateKey(EVP_PKEY **a, const unsigned char **pp,\n                             long length);\nint i2d_PrivateKey(EVP_PKEY *a, unsigned char **pp);\n\nint EVP_PKEY_copy_parameters(EVP_PKEY *to, const EVP_PKEY *from);\nint EVP_PKEY_missing_parameters(const EVP_PKEY *pkey);\nint EVP_PKEY_save_parameters(EVP_PKEY *pkey, int mode);\nint EVP_PKEY_cmp_parameters(const EVP_PKEY *a, const EVP_PKEY *b);\n\nint EVP_PKEY_cmp(const EVP_PKEY *a, const EVP_PKEY *b);\n\nint EVP_PKEY_print_public(BIO *out, const EVP_PKEY *pkey,\n                          int indent, ASN1_PCTX *pctx);\nint EVP_PKEY_print_private(BIO *out, const EVP_PKEY *pkey,\n                           int indent, ASN1_PCTX *pctx);\nint EVP_PKEY_print_params(BIO *out, const EVP_PKEY *pkey,\n                          int indent, ASN1_PCTX *pctx);\n\nint EVP_PKEY_get_default_digest_nid(EVP_PKEY *pkey, int *pnid);\n\nint EVP_CIPHER_type(const EVP_CIPHER *ctx);\n\n/* calls methods */\nint EVP_CIPHER_param_to_asn1(EVP_CIPHER_CTX *c, ASN1_TYPE *type);\nint EVP_CIPHER_asn1_to_param(EVP_CIPHER_CTX *c, ASN1_TYPE *type);\n\n/* These are used by EVP_CIPHER methods */\nint EVP_CIPHER_set_asn1_iv(EVP_CIPHER_CTX *c, ASN1_TYPE *type);\nint EVP_CIPHER_get_asn1_iv(EVP_CIPHER_CTX *c, ASN1_TYPE *type);\n\n/* PKCS5 password based encryption */\nint PKCS5_PBE_keyivgen(EVP_CIPHER_CTX *ctx, const char *pass, int passlen,\n                       ASN1_TYPE *param, const EVP_CIPHER *cipher,\n                       const EVP_MD *md, int en_de);\nint PKCS5_PBKDF2_HMAC_SHA1(const char *pass, int passlen,\n                           const unsigned char *salt, int saltlen, int iter,\n                           int keylen, unsigned char *out);\nint PKCS5_PBKDF2_HMAC(const char *pass, int passlen,\n                      const unsigned char *salt, int saltlen, int iter,\n                      const EVP_MD *digest, int keylen, unsigned char *out);\nint PKCS5_v2_PBE_keyivgen(EVP_CIPHER_CTX *ctx, const char *pass, int passlen,\n                          ASN1_TYPE *param, const EVP_CIPHER *cipher,\n                          const EVP_MD *md, int en_de);\n\nvoid PKCS5_PBE_add(void);\n\nint EVP_PBE_CipherInit(ASN1_OBJECT *pbe_obj, const char *pass, int passlen,\n                       ASN1_TYPE *param, EVP_CIPHER_CTX *ctx, int en_de);\n\n/* PBE type */\n\n/* Can appear as the outermost AlgorithmIdentifier */\n# define EVP_PBE_TYPE_OUTER      0x0\n/* Is an PRF type OID */\n# define EVP_PBE_TYPE_PRF        0x1\n\nint EVP_PBE_alg_add_type(int pbe_type, int pbe_nid, int cipher_nid,\n                         int md_nid, EVP_PBE_KEYGEN *keygen);\nint EVP_PBE_alg_add(int nid, const EVP_CIPHER *cipher, const EVP_MD *md,\n                    EVP_PBE_KEYGEN *keygen);\nint EVP_PBE_find(int type, int pbe_nid, int *pcnid, int *pmnid,\n                 EVP_PBE_KEYGEN **pkeygen);\nvoid EVP_PBE_cleanup(void);\n\n# define ASN1_PKEY_ALIAS         0x1\n# define ASN1_PKEY_DYNAMIC       0x2\n# define ASN1_PKEY_SIGPARAM_NULL 0x4\n\n# define ASN1_PKEY_CTRL_PKCS7_SIGN       0x1\n# define ASN1_PKEY_CTRL_PKCS7_ENCRYPT    0x2\n# define ASN1_PKEY_CTRL_DEFAULT_MD_NID   0x3\n# define ASN1_PKEY_CTRL_CMS_SIGN         0x5\n# define ASN1_PKEY_CTRL_CMS_ENVELOPE     0x7\n# define ASN1_PKEY_CTRL_CMS_RI_TYPE      0x8\n\nint EVP_PKEY_asn1_get_count(void);\nconst EVP_PKEY_ASN1_METHOD *EVP_PKEY_asn1_get0(int idx);\nconst EVP_PKEY_ASN1_METHOD *EVP_PKEY_asn1_find(ENGINE **pe, int type);\nconst EVP_PKEY_ASN1_METHOD *EVP_PKEY_asn1_find_str(ENGINE **pe,\n                                                   const char *str, int len);\nint EVP_PKEY_asn1_add0(const EVP_PKEY_ASN1_METHOD *ameth);\nint EVP_PKEY_asn1_add_alias(int to, int from);\nint EVP_PKEY_asn1_get0_info(int *ppkey_id, int *pkey_base_id,\n                            int *ppkey_flags, const char **pinfo,\n                            const char **ppem_str,\n                            const EVP_PKEY_ASN1_METHOD *ameth);\n\nconst EVP_PKEY_ASN1_METHOD *EVP_PKEY_get0_asn1(EVP_PKEY *pkey);\nEVP_PKEY_ASN1_METHOD *EVP_PKEY_asn1_new(int id, int flags,\n                                        const char *pem_str,\n                                        const char *info);\nvoid EVP_PKEY_asn1_copy(EVP_PKEY_ASN1_METHOD *dst,\n                        const EVP_PKEY_ASN1_METHOD *src);\nvoid EVP_PKEY_asn1_free(EVP_PKEY_ASN1_METHOD *ameth);\nvoid EVP_PKEY_asn1_set_public(EVP_PKEY_ASN1_METHOD *ameth,\n                              int (*pub_decode) (EVP_PKEY *pk,\n                                                 X509_PUBKEY *pub),\n                              int (*pub_encode) (X509_PUBKEY *pub,\n                                                 const EVP_PKEY *pk),\n                              int (*pub_cmp) (const EVP_PKEY *a,\n                                              const EVP_PKEY *b),\n                              int (*pub_print) (BIO *out,\n                                                const EVP_PKEY *pkey,\n                                                int indent, ASN1_PCTX *pctx),\n                              int (*pkey_size) (const EVP_PKEY *pk),\n                              int (*pkey_bits) (const EVP_PKEY *pk));\nvoid EVP_PKEY_asn1_set_private(EVP_PKEY_ASN1_METHOD *ameth,\n                               int (*priv_decode) (EVP_PKEY *pk,\n                                                   PKCS8_PRIV_KEY_INFO\n                                                   *p8inf),\n                               int (*priv_encode) (PKCS8_PRIV_KEY_INFO *p8,\n                                                   const EVP_PKEY *pk),\n                               int (*priv_print) (BIO *out,\n                                                  const EVP_PKEY *pkey,\n                                                  int indent,\n                                                  ASN1_PCTX *pctx));\nvoid EVP_PKEY_asn1_set_param(EVP_PKEY_ASN1_METHOD *ameth,\n                             int (*param_decode) (EVP_PKEY *pkey,\n                                                  const unsigned char **pder,\n                                                  int derlen),\n                             int (*param_encode) (const EVP_PKEY *pkey,\n                                                  unsigned char **pder),\n                             int (*param_missing) (const EVP_PKEY *pk),\n                             int (*param_copy) (EVP_PKEY *to,\n                                                const EVP_PKEY *from),\n                             int (*param_cmp) (const EVP_PKEY *a,\n                                               const EVP_PKEY *b),\n                             int (*param_print) (BIO *out,\n                                                 const EVP_PKEY *pkey,\n                                                 int indent,\n                                                 ASN1_PCTX *pctx));\n\nvoid EVP_PKEY_asn1_set_free(EVP_PKEY_ASN1_METHOD *ameth,\n                            void (*pkey_free) (EVP_PKEY *pkey));\nvoid EVP_PKEY_asn1_set_ctrl(EVP_PKEY_ASN1_METHOD *ameth,\n                            int (*pkey_ctrl) (EVP_PKEY *pkey, int op,\n                                              long arg1, void *arg2));\nvoid EVP_PKEY_asn1_set_item(EVP_PKEY_ASN1_METHOD *ameth,\n                            int (*item_verify) (EVP_MD_CTX *ctx,\n                                                const ASN1_ITEM *it,\n                                                void *asn,\n                                                X509_ALGOR *a,\n                                                ASN1_BIT_STRING *sig,\n                                                EVP_PKEY *pkey),\n                            int (*item_sign) (EVP_MD_CTX *ctx,\n                                              const ASN1_ITEM *it,\n                                              void *asn,\n                                              X509_ALGOR *alg1,\n                                              X509_ALGOR *alg2,\n                                              ASN1_BIT_STRING *sig));\n\n# define EVP_PKEY_OP_UNDEFINED           0\n# define EVP_PKEY_OP_PARAMGEN            (1<<1)\n# define EVP_PKEY_OP_KEYGEN              (1<<2)\n# define EVP_PKEY_OP_SIGN                (1<<3)\n# define EVP_PKEY_OP_VERIFY              (1<<4)\n# define EVP_PKEY_OP_VERIFYRECOVER       (1<<5)\n# define EVP_PKEY_OP_SIGNCTX             (1<<6)\n# define EVP_PKEY_OP_VERIFYCTX           (1<<7)\n# define EVP_PKEY_OP_ENCRYPT             (1<<8)\n# define EVP_PKEY_OP_DECRYPT             (1<<9)\n# define EVP_PKEY_OP_DERIVE              (1<<10)\n\n# define EVP_PKEY_OP_TYPE_SIG    \\\n        (EVP_PKEY_OP_SIGN | EVP_PKEY_OP_VERIFY | EVP_PKEY_OP_VERIFYRECOVER \\\n                | EVP_PKEY_OP_SIGNCTX | EVP_PKEY_OP_VERIFYCTX)\n\n# define EVP_PKEY_OP_TYPE_CRYPT \\\n        (EVP_PKEY_OP_ENCRYPT | EVP_PKEY_OP_DECRYPT)\n\n# define EVP_PKEY_OP_TYPE_NOGEN \\\n        (EVP_PKEY_OP_SIG | EVP_PKEY_OP_CRYPT | EVP_PKEY_OP_DERIVE)\n\n# define EVP_PKEY_OP_TYPE_GEN \\\n                (EVP_PKEY_OP_PARAMGEN | EVP_PKEY_OP_KEYGEN)\n\n# define  EVP_PKEY_CTX_set_signature_md(ctx, md) \\\n                EVP_PKEY_CTX_ctrl(ctx, -1, EVP_PKEY_OP_TYPE_SIG,  \\\n                                        EVP_PKEY_CTRL_MD, 0, (void *)md)\n\n# define  EVP_PKEY_CTX_get_signature_md(ctx, pmd)        \\\n                EVP_PKEY_CTX_ctrl(ctx, -1, EVP_PKEY_OP_TYPE_SIG,  \\\n                                        EVP_PKEY_CTRL_GET_MD, 0, (void *)pmd)\n\n# define EVP_PKEY_CTRL_MD                1\n# define EVP_PKEY_CTRL_PEER_KEY          2\n\n# define EVP_PKEY_CTRL_PKCS7_ENCRYPT     3\n# define EVP_PKEY_CTRL_PKCS7_DECRYPT     4\n\n# define EVP_PKEY_CTRL_PKCS7_SIGN        5\n\n# define EVP_PKEY_CTRL_SET_MAC_KEY       6\n\n# define EVP_PKEY_CTRL_DIGESTINIT        7\n\n/* Used by GOST key encryption in TLS */\n# define EVP_PKEY_CTRL_SET_IV            8\n\n# define EVP_PKEY_CTRL_CMS_ENCRYPT       9\n# define EVP_PKEY_CTRL_CMS_DECRYPT       10\n# define EVP_PKEY_CTRL_CMS_SIGN          11\n\n# define EVP_PKEY_CTRL_CIPHER            12\n\n# define EVP_PKEY_CTRL_GET_MD            13\n\n# define EVP_PKEY_ALG_CTRL               0x1000\n\n# define EVP_PKEY_FLAG_AUTOARGLEN        2\n/*\n * Method handles all operations: don't assume any digest related defaults.\n */\n# define EVP_PKEY_FLAG_SIGCTX_CUSTOM     4\n\nconst EVP_PKEY_METHOD *EVP_PKEY_meth_find(int type);\nEVP_PKEY_METHOD *EVP_PKEY_meth_new(int id, int flags);\nvoid EVP_PKEY_meth_get0_info(int *ppkey_id, int *pflags,\n                             const EVP_PKEY_METHOD *meth);\nvoid EVP_PKEY_meth_copy(EVP_PKEY_METHOD *dst, const EVP_PKEY_METHOD *src);\nvoid EVP_PKEY_meth_free(EVP_PKEY_METHOD *pmeth);\nint EVP_PKEY_meth_add0(const EVP_PKEY_METHOD *pmeth);\n\nEVP_PKEY_CTX *EVP_PKEY_CTX_new(EVP_PKEY *pkey, ENGINE *e);\nEVP_PKEY_CTX *EVP_PKEY_CTX_new_id(int id, ENGINE *e);\nEVP_PKEY_CTX *EVP_PKEY_CTX_dup(EVP_PKEY_CTX *ctx);\nvoid EVP_PKEY_CTX_free(EVP_PKEY_CTX *ctx);\n\nint EVP_PKEY_CTX_ctrl(EVP_PKEY_CTX *ctx, int keytype, int optype,\n                      int cmd, int p1, void *p2);\nint EVP_PKEY_CTX_ctrl_str(EVP_PKEY_CTX *ctx, const char *type,\n                          const char *value);\n\nint EVP_PKEY_CTX_get_operation(EVP_PKEY_CTX *ctx);\nvoid EVP_PKEY_CTX_set0_keygen_info(EVP_PKEY_CTX *ctx, int *dat, int datlen);\n\nEVP_PKEY *EVP_PKEY_new_mac_key(int type, ENGINE *e,\n                               const unsigned char *key, int keylen);\n\nvoid EVP_PKEY_CTX_set_data(EVP_PKEY_CTX *ctx, void *data);\nvoid *EVP_PKEY_CTX_get_data(EVP_PKEY_CTX *ctx);\nEVP_PKEY *EVP_PKEY_CTX_get0_pkey(EVP_PKEY_CTX *ctx);\n\nEVP_PKEY *EVP_PKEY_CTX_get0_peerkey(EVP_PKEY_CTX *ctx);\n\nvoid EVP_PKEY_CTX_set_app_data(EVP_PKEY_CTX *ctx, void *data);\nvoid *EVP_PKEY_CTX_get_app_data(EVP_PKEY_CTX *ctx);\n\nint EVP_PKEY_sign_init(EVP_PKEY_CTX *ctx);\nint EVP_PKEY_sign(EVP_PKEY_CTX *ctx,\n                  unsigned char *sig, size_t *siglen,\n                  const unsigned char *tbs, size_t tbslen);\nint EVP_PKEY_verify_init(EVP_PKEY_CTX *ctx);\nint EVP_PKEY_verify(EVP_PKEY_CTX *ctx,\n                    const unsigned char *sig, size_t siglen,\n                    const unsigned char *tbs, size_t tbslen);\nint EVP_PKEY_verify_recover_init(EVP_PKEY_CTX *ctx);\nint EVP_PKEY_verify_recover(EVP_PKEY_CTX *ctx,\n                            unsigned char *rout, size_t *routlen,\n                            const unsigned char *sig, size_t siglen);\nint EVP_PKEY_encrypt_init(EVP_PKEY_CTX *ctx);\nint EVP_PKEY_encrypt(EVP_PKEY_CTX *ctx,\n                     unsigned char *out, size_t *outlen,\n                     const unsigned char *in, size_t inlen);\nint EVP_PKEY_decrypt_init(EVP_PKEY_CTX *ctx);\nint EVP_PKEY_decrypt(EVP_PKEY_CTX *ctx,\n                     unsigned char *out, size_t *outlen,\n                     const unsigned char *in, size_t inlen);\n\nint EVP_PKEY_derive_init(EVP_PKEY_CTX *ctx);\nint EVP_PKEY_derive_set_peer(EVP_PKEY_CTX *ctx, EVP_PKEY *peer);\nint EVP_PKEY_derive(EVP_PKEY_CTX *ctx, unsigned char *key, size_t *keylen);\n\ntypedef int EVP_PKEY_gen_cb (EVP_PKEY_CTX *ctx);\n\nint EVP_PKEY_paramgen_init(EVP_PKEY_CTX *ctx);\nint EVP_PKEY_paramgen(EVP_PKEY_CTX *ctx, EVP_PKEY **ppkey);\nint EVP_PKEY_keygen_init(EVP_PKEY_CTX *ctx);\nint EVP_PKEY_keygen(EVP_PKEY_CTX *ctx, EVP_PKEY **ppkey);\n\nvoid EVP_PKEY_CTX_set_cb(EVP_PKEY_CTX *ctx, EVP_PKEY_gen_cb *cb);\nEVP_PKEY_gen_cb *EVP_PKEY_CTX_get_cb(EVP_PKEY_CTX *ctx);\n\nint EVP_PKEY_CTX_get_keygen_info(EVP_PKEY_CTX *ctx, int idx);\n\nvoid EVP_PKEY_meth_set_init(EVP_PKEY_METHOD *pmeth,\n                            int (*init) (EVP_PKEY_CTX *ctx));\n\nvoid EVP_PKEY_meth_set_copy(EVP_PKEY_METHOD *pmeth,\n                            int (*copy) (EVP_PKEY_CTX *dst,\n                                         EVP_PKEY_CTX *src));\n\nvoid EVP_PKEY_meth_set_cleanup(EVP_PKEY_METHOD *pmeth,\n                               void (*cleanup) (EVP_PKEY_CTX *ctx));\n\nvoid EVP_PKEY_meth_set_paramgen(EVP_PKEY_METHOD *pmeth,\n                                int (*paramgen_init) (EVP_PKEY_CTX *ctx),\n                                int (*paramgen) (EVP_PKEY_CTX *ctx,\n                                                 EVP_PKEY *pkey));\n\nvoid EVP_PKEY_meth_set_keygen(EVP_PKEY_METHOD *pmeth,\n                              int (*keygen_init) (EVP_PKEY_CTX *ctx),\n                              int (*keygen) (EVP_PKEY_CTX *ctx,\n                                             EVP_PKEY *pkey));\n\nvoid EVP_PKEY_meth_set_sign(EVP_PKEY_METHOD *pmeth,\n                            int (*sign_init) (EVP_PKEY_CTX *ctx),\n                            int (*sign) (EVP_PKEY_CTX *ctx,\n                                         unsigned char *sig, size_t *siglen,\n                                         const unsigned char *tbs,\n                                         size_t tbslen));\n\nvoid EVP_PKEY_meth_set_verify(EVP_PKEY_METHOD *pmeth,\n                              int (*verify_init) (EVP_PKEY_CTX *ctx),\n                              int (*verify) (EVP_PKEY_CTX *ctx,\n                                             const unsigned char *sig,\n                                             size_t siglen,\n                                             const unsigned char *tbs,\n                                             size_t tbslen));\n\nvoid EVP_PKEY_meth_set_verify_recover(EVP_PKEY_METHOD *pmeth,\n                                      int (*verify_recover_init) (EVP_PKEY_CTX\n                                                                  *ctx),\n                                      int (*verify_recover) (EVP_PKEY_CTX\n                                                             *ctx,\n                                                             unsigned char\n                                                             *sig,\n                                                             size_t *siglen,\n                                                             const unsigned\n                                                             char *tbs,\n                                                             size_t tbslen));\n\nvoid EVP_PKEY_meth_set_signctx(EVP_PKEY_METHOD *pmeth,\n                               int (*signctx_init) (EVP_PKEY_CTX *ctx,\n                                                    EVP_MD_CTX *mctx),\n                               int (*signctx) (EVP_PKEY_CTX *ctx,\n                                               unsigned char *sig,\n                                               size_t *siglen,\n                                               EVP_MD_CTX *mctx));\n\nvoid EVP_PKEY_meth_set_verifyctx(EVP_PKEY_METHOD *pmeth,\n                                 int (*verifyctx_init) (EVP_PKEY_CTX *ctx,\n                                                        EVP_MD_CTX *mctx),\n                                 int (*verifyctx) (EVP_PKEY_CTX *ctx,\n                                                   const unsigned char *sig,\n                                                   int siglen,\n                                                   EVP_MD_CTX *mctx));\n\nvoid EVP_PKEY_meth_set_encrypt(EVP_PKEY_METHOD *pmeth,\n                               int (*encrypt_init) (EVP_PKEY_CTX *ctx),\n                               int (*encryptfn) (EVP_PKEY_CTX *ctx,\n                                                 unsigned char *out,\n                                                 size_t *outlen,\n                                                 const unsigned char *in,\n                                                 size_t inlen));\n\nvoid EVP_PKEY_meth_set_decrypt(EVP_PKEY_METHOD *pmeth,\n                               int (*decrypt_init) (EVP_PKEY_CTX *ctx),\n                               int (*decrypt) (EVP_PKEY_CTX *ctx,\n                                               unsigned char *out,\n                                               size_t *outlen,\n                                               const unsigned char *in,\n                                               size_t inlen));\n\nvoid EVP_PKEY_meth_set_derive(EVP_PKEY_METHOD *pmeth,\n                              int (*derive_init) (EVP_PKEY_CTX *ctx),\n                              int (*derive) (EVP_PKEY_CTX *ctx,\n                                             unsigned char *key,\n                                             size_t *keylen));\n\nvoid EVP_PKEY_meth_set_ctrl(EVP_PKEY_METHOD *pmeth,\n                            int (*ctrl) (EVP_PKEY_CTX *ctx, int type, int p1,\n                                         void *p2),\n                            int (*ctrl_str) (EVP_PKEY_CTX *ctx,\n                                             const char *type,\n                                             const char *value));\n\nvoid EVP_add_alg_module(void);\n\n/* BEGIN ERROR CODES */\n/*\n * The following lines are auto generated by the script mkerr.pl. Any changes\n * made after this point may be overwritten when the script is next run.\n */\n\nvoid ERR_load_EVP_strings(void);\n\n/* Error codes for the EVP functions. */\n\n/* Function codes. */\n# define EVP_F_AESNI_INIT_KEY                             165\n# define EVP_F_AESNI_XTS_CIPHER                           176\n# define EVP_F_AES_INIT_KEY                               133\n# define EVP_F_AES_T4_INIT_KEY                            178\n# define EVP_F_AES_XTS                                    172\n# define EVP_F_AES_XTS_CIPHER                             175\n# define EVP_F_ALG_MODULE_INIT                            177\n# define EVP_F_CAMELLIA_INIT_KEY                          159\n# define EVP_F_CMAC_INIT                                  173\n# define EVP_F_CMLL_T4_INIT_KEY                           179\n# define EVP_F_D2I_PKEY                                   100\n# define EVP_F_DO_SIGVER_INIT                             161\n# define EVP_F_DSAPKEY2PKCS8                              134\n# define EVP_F_DSA_PKEY2PKCS8                             135\n# define EVP_F_ECDSA_PKEY2PKCS8                           129\n# define EVP_F_ECKEY_PKEY2PKCS8                           132\n# define EVP_F_EVP_CIPHERINIT_EX                          123\n# define EVP_F_EVP_CIPHER_CTX_COPY                        163\n# define EVP_F_EVP_CIPHER_CTX_CTRL                        124\n# define EVP_F_EVP_CIPHER_CTX_SET_KEY_LENGTH              122\n# define EVP_F_EVP_DECRYPTFINAL_EX                        101\n# define EVP_F_EVP_DIGESTINIT_EX                          128\n# define EVP_F_EVP_ENCRYPTFINAL_EX                        127\n# define EVP_F_EVP_MD_CTX_COPY_EX                         110\n# define EVP_F_EVP_MD_SIZE                                162\n# define EVP_F_EVP_OPENINIT                               102\n# define EVP_F_EVP_PBE_ALG_ADD                            115\n# define EVP_F_EVP_PBE_ALG_ADD_TYPE                       160\n# define EVP_F_EVP_PBE_CIPHERINIT                         116\n# define EVP_F_EVP_PKCS82PKEY                             111\n# define EVP_F_EVP_PKCS82PKEY_BROKEN                      136\n# define EVP_F_EVP_PKEY2PKCS8_BROKEN                      113\n# define EVP_F_EVP_PKEY_COPY_PARAMETERS                   103\n# define EVP_F_EVP_PKEY_CTX_CTRL                          137\n# define EVP_F_EVP_PKEY_CTX_CTRL_STR                      150\n# define EVP_F_EVP_PKEY_CTX_DUP                           156\n# define EVP_F_EVP_PKEY_DECRYPT                           104\n# define EVP_F_EVP_PKEY_DECRYPT_INIT                      138\n# define EVP_F_EVP_PKEY_DECRYPT_OLD                       151\n# define EVP_F_EVP_PKEY_DERIVE                            153\n# define EVP_F_EVP_PKEY_DERIVE_INIT                       154\n# define EVP_F_EVP_PKEY_DERIVE_SET_PEER                   155\n# define EVP_F_EVP_PKEY_ENCRYPT                           105\n# define EVP_F_EVP_PKEY_ENCRYPT_INIT                      139\n# define EVP_F_EVP_PKEY_ENCRYPT_OLD                       152\n# define EVP_F_EVP_PKEY_GET1_DH                           119\n# define EVP_F_EVP_PKEY_GET1_DSA                          120\n# define EVP_F_EVP_PKEY_GET1_ECDSA                        130\n# define EVP_F_EVP_PKEY_GET1_EC_KEY                       131\n# define EVP_F_EVP_PKEY_GET1_RSA                          121\n# define EVP_F_EVP_PKEY_KEYGEN                            146\n# define EVP_F_EVP_PKEY_KEYGEN_INIT                       147\n# define EVP_F_EVP_PKEY_NEW                               106\n# define EVP_F_EVP_PKEY_PARAMGEN                          148\n# define EVP_F_EVP_PKEY_PARAMGEN_INIT                     149\n# define EVP_F_EVP_PKEY_SIGN                              140\n# define EVP_F_EVP_PKEY_SIGN_INIT                         141\n# define EVP_F_EVP_PKEY_VERIFY                            142\n# define EVP_F_EVP_PKEY_VERIFY_INIT                       143\n# define EVP_F_EVP_PKEY_VERIFY_RECOVER                    144\n# define EVP_F_EVP_PKEY_VERIFY_RECOVER_INIT               145\n# define EVP_F_EVP_RIJNDAEL                               126\n# define EVP_F_EVP_SIGNFINAL                              107\n# define EVP_F_EVP_VERIFYFINAL                            108\n# define EVP_F_FIPS_CIPHERINIT                            166\n# define EVP_F_FIPS_CIPHER_CTX_COPY                       170\n# define EVP_F_FIPS_CIPHER_CTX_CTRL                       167\n# define EVP_F_FIPS_CIPHER_CTX_SET_KEY_LENGTH             171\n# define EVP_F_FIPS_DIGESTINIT                            168\n# define EVP_F_FIPS_MD_CTX_COPY                           169\n# define EVP_F_HMAC_INIT_EX                               174\n# define EVP_F_INT_CTX_NEW                                157\n# define EVP_F_PKCS5_PBE_KEYIVGEN                         117\n# define EVP_F_PKCS5_V2_PBE_KEYIVGEN                      118\n# define EVP_F_PKCS5_V2_PBKDF2_KEYIVGEN                   164\n# define EVP_F_PKCS8_SET_BROKEN                           112\n# define EVP_F_PKEY_SET_TYPE                              158\n# define EVP_F_RC2_MAGIC_TO_METH                          109\n# define EVP_F_RC5_CTRL                                   125\n\n/* Reason codes. */\n# define EVP_R_AES_IV_SETUP_FAILED                        162\n# define EVP_R_AES_KEY_SETUP_FAILED                       143\n# define EVP_R_ASN1_LIB                                   140\n# define EVP_R_BAD_BLOCK_LENGTH                           136\n# define EVP_R_BAD_DECRYPT                                100\n# define EVP_R_BAD_KEY_LENGTH                             137\n# define EVP_R_BN_DECODE_ERROR                            112\n# define EVP_R_BN_PUBKEY_ERROR                            113\n# define EVP_R_BUFFER_TOO_SMALL                           155\n# define EVP_R_CAMELLIA_KEY_SETUP_FAILED                  157\n# define EVP_R_CIPHER_PARAMETER_ERROR                     122\n# define EVP_R_COMMAND_NOT_SUPPORTED                      147\n# define EVP_R_CTRL_NOT_IMPLEMENTED                       132\n# define EVP_R_CTRL_OPERATION_NOT_IMPLEMENTED             133\n# define EVP_R_DATA_NOT_MULTIPLE_OF_BLOCK_LENGTH          138\n# define EVP_R_DECODE_ERROR                               114\n# define EVP_R_DIFFERENT_KEY_TYPES                        101\n# define EVP_R_DIFFERENT_PARAMETERS                       153\n# define EVP_R_DISABLED_FOR_FIPS                          163\n# define EVP_R_ENCODE_ERROR                               115\n# define EVP_R_ERROR_LOADING_SECTION                      165\n# define EVP_R_ERROR_SETTING_FIPS_MODE                    166\n# define EVP_R_EVP_PBE_CIPHERINIT_ERROR                   119\n# define EVP_R_EXPECTING_AN_RSA_KEY                       127\n# define EVP_R_EXPECTING_A_DH_KEY                         128\n# define EVP_R_EXPECTING_A_DSA_KEY                        129\n# define EVP_R_EXPECTING_A_ECDSA_KEY                      141\n# define EVP_R_EXPECTING_A_EC_KEY                         142\n# define EVP_R_FIPS_MODE_NOT_SUPPORTED                    167\n# define EVP_R_INITIALIZATION_ERROR                       134\n# define EVP_R_INPUT_NOT_INITIALIZED                      111\n# define EVP_R_INVALID_DIGEST                             152\n# define EVP_R_INVALID_FIPS_MODE                          168\n# define EVP_R_INVALID_KEY                                171\n# define EVP_R_INVALID_KEY_LENGTH                         130\n# define EVP_R_INVALID_OPERATION                          148\n# define EVP_R_IV_TOO_LARGE                               102\n# define EVP_R_KEYGEN_FAILURE                             120\n# define EVP_R_MESSAGE_DIGEST_IS_NULL                     159\n# define EVP_R_METHOD_NOT_SUPPORTED                       144\n# define EVP_R_MISSING_PARAMETERS                         103\n# define EVP_R_NO_CIPHER_SET                              131\n# define EVP_R_NO_DEFAULT_DIGEST                          158\n# define EVP_R_NO_DIGEST_SET                              139\n# define EVP_R_NO_DSA_PARAMETERS                          116\n# define EVP_R_NO_KEY_SET                                 154\n# define EVP_R_NO_OPERATION_SET                           149\n# define EVP_R_NO_SIGN_FUNCTION_CONFIGURED                104\n# define EVP_R_NO_VERIFY_FUNCTION_CONFIGURED              105\n# define EVP_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE   150\n# define EVP_R_OPERATON_NOT_INITIALIZED                   151\n# define EVP_R_PKCS8_UNKNOWN_BROKEN_TYPE                  117\n# define EVP_R_PRIVATE_KEY_DECODE_ERROR                   145\n# define EVP_R_PRIVATE_KEY_ENCODE_ERROR                   146\n# define EVP_R_PUBLIC_KEY_NOT_RSA                         106\n# define EVP_R_TOO_LARGE                                  164\n# define EVP_R_UNKNOWN_CIPHER                             160\n# define EVP_R_UNKNOWN_DIGEST                             161\n# define EVP_R_UNKNOWN_OPTION                             169\n# define EVP_R_UNKNOWN_PBE_ALGORITHM                      121\n# define EVP_R_UNSUPORTED_NUMBER_OF_ROUNDS                135\n# define EVP_R_UNSUPPORTED_ALGORITHM                      156\n# define EVP_R_UNSUPPORTED_CIPHER                         107\n# define EVP_R_UNSUPPORTED_KEYLENGTH                      123\n# define EVP_R_UNSUPPORTED_KEY_DERIVATION_FUNCTION        124\n# define EVP_R_UNSUPPORTED_KEY_SIZE                       108\n# define EVP_R_UNSUPPORTED_PRF                            125\n# define EVP_R_UNSUPPORTED_PRIVATE_KEY_ALGORITHM          118\n# define EVP_R_UNSUPPORTED_SALT_TYPE                      126\n# define EVP_R_WRAP_MODE_NOT_ALLOWED                      170\n# define EVP_R_WRONG_FINAL_BLOCK_LENGTH                   109\n# define EVP_R_WRONG_PUBLIC_KEY_TYPE                      110\n\n# ifdef  __cplusplus\n}\n# endif\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/x86/include/openssl/hmac.h",
    "content": "/* crypto/hmac/hmac.h */\n/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)\n * All rights reserved.\n *\n * This package is an SSL implementation written\n * by Eric Young (eay@cryptsoft.com).\n * The implementation was written so as to conform with Netscapes SSL.\n *\n * This library is free for commercial and non-commercial use as long as\n * the following conditions are aheared to.  The following conditions\n * apply to all code found in this distribution, be it the RC4, RSA,\n * lhash, DES, etc., code; not just the SSL code.  The SSL documentation\n * included with this distribution is covered by the same copyright terms\n * except that the holder is Tim Hudson (tjh@cryptsoft.com).\n *\n * Copyright remains Eric Young's, and as such any Copyright notices in\n * the code are not to be removed.\n * If this package is used in a product, Eric Young should be given attribution\n * as the author of the parts of the library used.\n * This can be in the form of a textual message at program startup or\n * in documentation (online or textual) provided with the package.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the copyright\n *    notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in the\n *    documentation and/or other materials provided with the distribution.\n * 3. All advertising materials mentioning features or use of this software\n *    must display the following acknowledgement:\n *    \"This product includes cryptographic software written by\n *     Eric Young (eay@cryptsoft.com)\"\n *    The word 'cryptographic' can be left out if the rouines from the library\n *    being used are not cryptographic related :-).\n * 4. If you include any Windows specific code (or a derivative thereof) from\n *    the apps directory (application code) you must include an acknowledgement:\n *    \"This product includes software written by Tim Hudson (tjh@cryptsoft.com)\"\n *\n * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n * SUCH DAMAGE.\n *\n * The licence and distribution terms for any publically available version or\n * derivative of this code cannot be changed.  i.e. this code cannot simply be\n * copied and put under another distribution licence\n * [including the GNU Public Licence.]\n */\n#ifndef HEADER_HMAC_H\n# define HEADER_HMAC_H\n\n# include <openssl/opensslconf.h>\n\n# ifdef OPENSSL_NO_HMAC\n#  error HMAC is disabled.\n# endif\n\n# include <openssl/evp.h>\n\n# define HMAC_MAX_MD_CBLOCK      128/* largest known is SHA512 */\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\ntypedef struct hmac_ctx_st {\n    const EVP_MD *md;\n    EVP_MD_CTX md_ctx;\n    EVP_MD_CTX i_ctx;\n    EVP_MD_CTX o_ctx;\n    unsigned int key_length;\n    unsigned char key[HMAC_MAX_MD_CBLOCK];\n} HMAC_CTX;\n\n# define HMAC_size(e)    (EVP_MD_size((e)->md))\n\nvoid HMAC_CTX_init(HMAC_CTX *ctx);\nvoid HMAC_CTX_cleanup(HMAC_CTX *ctx);\n\n/* deprecated */\n# define HMAC_cleanup(ctx) HMAC_CTX_cleanup(ctx)\n\n/* deprecated */\nint HMAC_Init(HMAC_CTX *ctx, const void *key, int len, const EVP_MD *md);\nint HMAC_Init_ex(HMAC_CTX *ctx, const void *key, int len,\n                 const EVP_MD *md, ENGINE *impl);\nint HMAC_Update(HMAC_CTX *ctx, const unsigned char *data, size_t len);\nint HMAC_Final(HMAC_CTX *ctx, unsigned char *md, unsigned int *len);\nunsigned char *HMAC(const EVP_MD *evp_md, const void *key, int key_len,\n                    const unsigned char *d, size_t n, unsigned char *md,\n                    unsigned int *md_len);\nint HMAC_CTX_copy(HMAC_CTX *dctx, HMAC_CTX *sctx);\n\nvoid HMAC_CTX_set_flags(HMAC_CTX *ctx, unsigned long flags);\n\n#ifdef  __cplusplus\n}\n#endif\n\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/x86/include/openssl/idea.h",
    "content": "/* crypto/idea/idea.h */\n/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)\n * All rights reserved.\n *\n * This package is an SSL implementation written\n * by Eric Young (eay@cryptsoft.com).\n * The implementation was written so as to conform with Netscapes SSL.\n *\n * This library is free for commercial and non-commercial use as long as\n * the following conditions are aheared to.  The following conditions\n * apply to all code found in this distribution, be it the RC4, RSA,\n * lhash, DES, etc., code; not just the SSL code.  The SSL documentation\n * included with this distribution is covered by the same copyright terms\n * except that the holder is Tim Hudson (tjh@cryptsoft.com).\n *\n * Copyright remains Eric Young's, and as such any Copyright notices in\n * the code are not to be removed.\n * If this package is used in a product, Eric Young should be given attribution\n * as the author of the parts of the library used.\n * This can be in the form of a textual message at program startup or\n * in documentation (online or textual) provided with the package.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the copyright\n *    notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in the\n *    documentation and/or other materials provided with the distribution.\n * 3. All advertising materials mentioning features or use of this software\n *    must display the following acknowledgement:\n *    \"This product includes cryptographic software written by\n *     Eric Young (eay@cryptsoft.com)\"\n *    The word 'cryptographic' can be left out if the rouines from the library\n *    being used are not cryptographic related :-).\n * 4. If you include any Windows specific code (or a derivative thereof) from\n *    the apps directory (application code) you must include an acknowledgement:\n *    \"This product includes software written by Tim Hudson (tjh@cryptsoft.com)\"\n *\n * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n * SUCH DAMAGE.\n *\n * The licence and distribution terms for any publically available version or\n * derivative of this code cannot be changed.  i.e. this code cannot simply be\n * copied and put under another distribution licence\n * [including the GNU Public Licence.]\n */\n\n#ifndef HEADER_IDEA_H\n# define HEADER_IDEA_H\n\n# include <openssl/opensslconf.h>/* IDEA_INT, OPENSSL_NO_IDEA */\n\n# ifdef OPENSSL_NO_IDEA\n#  error IDEA is disabled.\n# endif\n\n# define IDEA_ENCRYPT    1\n# define IDEA_DECRYPT    0\n\n# define IDEA_BLOCK      8\n# define IDEA_KEY_LENGTH 16\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\ntypedef struct idea_key_st {\n    IDEA_INT data[9][6];\n} IDEA_KEY_SCHEDULE;\n\nconst char *idea_options(void);\nvoid idea_ecb_encrypt(const unsigned char *in, unsigned char *out,\n                      IDEA_KEY_SCHEDULE *ks);\n# ifdef OPENSSL_FIPS\nvoid private_idea_set_encrypt_key(const unsigned char *key,\n                                  IDEA_KEY_SCHEDULE *ks);\n# endif\nvoid idea_set_encrypt_key(const unsigned char *key, IDEA_KEY_SCHEDULE *ks);\nvoid idea_set_decrypt_key(IDEA_KEY_SCHEDULE *ek, IDEA_KEY_SCHEDULE *dk);\nvoid idea_cbc_encrypt(const unsigned char *in, unsigned char *out,\n                      long length, IDEA_KEY_SCHEDULE *ks, unsigned char *iv,\n                      int enc);\nvoid idea_cfb64_encrypt(const unsigned char *in, unsigned char *out,\n                        long length, IDEA_KEY_SCHEDULE *ks, unsigned char *iv,\n                        int *num, int enc);\nvoid idea_ofb64_encrypt(const unsigned char *in, unsigned char *out,\n                        long length, IDEA_KEY_SCHEDULE *ks, unsigned char *iv,\n                        int *num);\nvoid idea_encrypt(unsigned long *in, IDEA_KEY_SCHEDULE *ks);\n#ifdef  __cplusplus\n}\n#endif\n\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/x86/include/openssl/krb5_asn.h",
    "content": "/* krb5_asn.h */\n/*\n * Written by Vern Staats <staatsvr@asc.hpc.mil> for the OpenSSL project, **\n * using ocsp/{*.h,*asn*.c} as a starting point\n */\n\n/* ====================================================================\n * Copyright (c) 1998-2000 The OpenSSL Project.  All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n *\n * 1. Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n *\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in\n *    the documentation and/or other materials provided with the\n *    distribution.\n *\n * 3. All advertising materials mentioning features or use of this\n *    software must display the following acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit. (http://www.openssl.org/)\"\n *\n * 4. The names \"OpenSSL Toolkit\" and \"OpenSSL Project\" must not be used to\n *    endorse or promote products derived from this software without\n *    prior written permission. For written permission, please contact\n *    openssl-core@openssl.org.\n *\n * 5. Products derived from this software may not be called \"OpenSSL\"\n *    nor may \"OpenSSL\" appear in their names without prior written\n *    permission of the OpenSSL Project.\n *\n * 6. Redistributions of any form whatsoever must retain the following\n *    acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit (http://www.openssl.org/)\"\n *\n * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY\n * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\n * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR\n * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\n * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,\n * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED\n * OF THE POSSIBILITY OF SUCH DAMAGE.\n * ====================================================================\n *\n * This product includes cryptographic software written by Eric Young\n * (eay@cryptsoft.com).  This product includes software written by Tim\n * Hudson (tjh@cryptsoft.com).\n *\n */\n\n#ifndef HEADER_KRB5_ASN_H\n# define HEADER_KRB5_ASN_H\n\n/*\n * #include <krb5.h>\n */\n# include <openssl/safestack.h>\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n/*\n * ASN.1 from Kerberos RFC 1510\n */\n\n/*-     EncryptedData ::=   SEQUENCE {\n *              etype[0]                      INTEGER, -- EncryptionType\n *              kvno[1]                       INTEGER OPTIONAL,\n *              cipher[2]                     OCTET STRING -- ciphertext\n *      }\n */\ntypedef struct krb5_encdata_st {\n    ASN1_INTEGER *etype;\n    ASN1_INTEGER *kvno;\n    ASN1_OCTET_STRING *cipher;\n} KRB5_ENCDATA;\n\nDECLARE_STACK_OF(KRB5_ENCDATA)\n\n/*-     PrincipalName ::=   SEQUENCE {\n *              name-type[0]                  INTEGER,\n *              name-string[1]                SEQUENCE OF GeneralString\n *      }\n */\ntypedef struct krb5_princname_st {\n    ASN1_INTEGER *nametype;\n    STACK_OF(ASN1_GENERALSTRING) *namestring;\n} KRB5_PRINCNAME;\n\nDECLARE_STACK_OF(KRB5_PRINCNAME)\n\n/*-     Ticket ::=      [APPLICATION 1] SEQUENCE {\n *              tkt-vno[0]                    INTEGER,\n *              realm[1]                      Realm,\n *              sname[2]                      PrincipalName,\n *              enc-part[3]                   EncryptedData\n *      }\n */\ntypedef struct krb5_tktbody_st {\n    ASN1_INTEGER *tktvno;\n    ASN1_GENERALSTRING *realm;\n    KRB5_PRINCNAME *sname;\n    KRB5_ENCDATA *encdata;\n} KRB5_TKTBODY;\n\ntypedef STACK_OF(KRB5_TKTBODY) KRB5_TICKET;\nDECLARE_STACK_OF(KRB5_TKTBODY)\n\n/*-     AP-REQ ::=      [APPLICATION 14] SEQUENCE {\n *              pvno[0]                       INTEGER,\n *              msg-type[1]                   INTEGER,\n *              ap-options[2]                 APOptions,\n *              ticket[3]                     Ticket,\n *              authenticator[4]              EncryptedData\n *      }\n *\n *      APOptions ::=   BIT STRING {\n *              reserved(0), use-session-key(1), mutual-required(2) }\n */\ntypedef struct krb5_ap_req_st {\n    ASN1_INTEGER *pvno;\n    ASN1_INTEGER *msgtype;\n    ASN1_BIT_STRING *apoptions;\n    KRB5_TICKET *ticket;\n    KRB5_ENCDATA *authenticator;\n} KRB5_APREQBODY;\n\ntypedef STACK_OF(KRB5_APREQBODY) KRB5_APREQ;\nDECLARE_STACK_OF(KRB5_APREQBODY)\n\n/*      Authenticator Stuff     */\n\n/*-     Checksum ::=   SEQUENCE {\n *              cksumtype[0]                  INTEGER,\n *              checksum[1]                   OCTET STRING\n *      }\n */\ntypedef struct krb5_checksum_st {\n    ASN1_INTEGER *ctype;\n    ASN1_OCTET_STRING *checksum;\n} KRB5_CHECKSUM;\n\nDECLARE_STACK_OF(KRB5_CHECKSUM)\n\n/*-     EncryptionKey ::=   SEQUENCE {\n *              keytype[0]                    INTEGER,\n *              keyvalue[1]                   OCTET STRING\n *      }\n */\ntypedef struct krb5_encryptionkey_st {\n    ASN1_INTEGER *ktype;\n    ASN1_OCTET_STRING *keyvalue;\n} KRB5_ENCKEY;\n\nDECLARE_STACK_OF(KRB5_ENCKEY)\n\n/*-     AuthorizationData ::=   SEQUENCE OF SEQUENCE {\n *              ad-type[0]                    INTEGER,\n *              ad-data[1]                    OCTET STRING\n *      }\n */\ntypedef struct krb5_authorization_st {\n    ASN1_INTEGER *adtype;\n    ASN1_OCTET_STRING *addata;\n} KRB5_AUTHDATA;\n\nDECLARE_STACK_OF(KRB5_AUTHDATA)\n\n/*-     -- Unencrypted authenticator\n *      Authenticator ::=    [APPLICATION 2] SEQUENCE    {\n *              authenticator-vno[0]          INTEGER,\n *              crealm[1]                     Realm,\n *              cname[2]                      PrincipalName,\n *              cksum[3]                      Checksum OPTIONAL,\n *              cusec[4]                      INTEGER,\n *              ctime[5]                      KerberosTime,\n *              subkey[6]                     EncryptionKey OPTIONAL,\n *              seq-number[7]                 INTEGER OPTIONAL,\n *              authorization-data[8]         AuthorizationData OPTIONAL\n *      }\n */\ntypedef struct krb5_authenticator_st {\n    ASN1_INTEGER *avno;\n    ASN1_GENERALSTRING *crealm;\n    KRB5_PRINCNAME *cname;\n    KRB5_CHECKSUM *cksum;\n    ASN1_INTEGER *cusec;\n    ASN1_GENERALIZEDTIME *ctime;\n    KRB5_ENCKEY *subkey;\n    ASN1_INTEGER *seqnum;\n    KRB5_AUTHDATA *authorization;\n} KRB5_AUTHENTBODY;\n\ntypedef STACK_OF(KRB5_AUTHENTBODY) KRB5_AUTHENT;\nDECLARE_STACK_OF(KRB5_AUTHENTBODY)\n\n/*-  DECLARE_ASN1_FUNCTIONS(type) = DECLARE_ASN1_FUNCTIONS_name(type, type) =\n *      type *name##_new(void);\n *      void name##_free(type *a);\n *      DECLARE_ASN1_ENCODE_FUNCTIONS(type, name, name) =\n *       DECLARE_ASN1_ENCODE_FUNCTIONS(type, itname, name) =\n *        type *d2i_##name(type **a, const unsigned char **in, long len);\n *        int i2d_##name(type *a, unsigned char **out);\n *        DECLARE_ASN1_ITEM(itname) = OPENSSL_EXTERN const ASN1_ITEM itname##_it\n */\n\nDECLARE_ASN1_FUNCTIONS(KRB5_ENCDATA)\nDECLARE_ASN1_FUNCTIONS(KRB5_PRINCNAME)\nDECLARE_ASN1_FUNCTIONS(KRB5_TKTBODY)\nDECLARE_ASN1_FUNCTIONS(KRB5_APREQBODY)\nDECLARE_ASN1_FUNCTIONS(KRB5_TICKET)\nDECLARE_ASN1_FUNCTIONS(KRB5_APREQ)\n\nDECLARE_ASN1_FUNCTIONS(KRB5_CHECKSUM)\nDECLARE_ASN1_FUNCTIONS(KRB5_ENCKEY)\nDECLARE_ASN1_FUNCTIONS(KRB5_AUTHDATA)\nDECLARE_ASN1_FUNCTIONS(KRB5_AUTHENTBODY)\nDECLARE_ASN1_FUNCTIONS(KRB5_AUTHENT)\n\n/* BEGIN ERROR CODES */\n/*\n * The following lines are auto generated by the script mkerr.pl. Any changes\n * made after this point may be overwritten when the script is next run.\n */\n\n#ifdef  __cplusplus\n}\n#endif\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/x86/include/openssl/kssl.h",
    "content": "/* ssl/kssl.h */\n/*\n * Written by Vern Staats <staatsvr@asc.hpc.mil> for the OpenSSL project\n * 2000. project 2000.\n */\n/* ====================================================================\n * Copyright (c) 2000 The OpenSSL Project.  All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n *\n * 1. Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n *\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in\n *    the documentation and/or other materials provided with the\n *    distribution.\n *\n * 3. All advertising materials mentioning features or use of this\n *    software must display the following acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)\"\n *\n * 4. The names \"OpenSSL Toolkit\" and \"OpenSSL Project\" must not be used to\n *    endorse or promote products derived from this software without\n *    prior written permission. For written permission, please contact\n *    licensing@OpenSSL.org.\n *\n * 5. Products derived from this software may not be called \"OpenSSL\"\n *    nor may \"OpenSSL\" appear in their names without prior written\n *    permission of the OpenSSL Project.\n *\n * 6. Redistributions of any form whatsoever must retain the following\n *    acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)\"\n *\n * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY\n * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\n * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR\n * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\n * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,\n * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED\n * OF THE POSSIBILITY OF SUCH DAMAGE.\n * ====================================================================\n *\n * This product includes cryptographic software written by Eric Young\n * (eay@cryptsoft.com).  This product includes software written by Tim\n * Hudson (tjh@cryptsoft.com).\n *\n */\n\n/*\n **      19990701        VRS     Started.\n */\n\n#ifndef KSSL_H\n# define KSSL_H\n\n# include <openssl/opensslconf.h>\n\n# ifndef OPENSSL_NO_KRB5\n\n#  include <stdio.h>\n#  include <ctype.h>\n#  include <krb5.h>\n#  ifdef OPENSSL_SYS_WIN32\n/*\n * These can sometimes get redefined indirectly by krb5 header files after\n * they get undefed in ossl_typ.h\n */\n#   undef X509_NAME\n#   undef X509_EXTENSIONS\n#   undef OCSP_REQUEST\n#   undef OCSP_RESPONSE\n#  endif\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n/*\n *      Depending on which KRB5 implementation used, some types from\n *      the other may be missing.  Resolve that here and now\n */\n#  ifdef KRB5_HEIMDAL\ntypedef unsigned char krb5_octet;\n#   define FAR\n#  else\n\n#   ifndef FAR\n#    define FAR\n#   endif\n\n#  endif\n\n/*-\n *      Uncomment this to debug kssl problems or\n *      to trace usage of the Kerberos session key\n *\n *      #define         KSSL_DEBUG\n */\n\n#  ifndef KRB5SVC\n#   define KRB5SVC \"host\"\n#  endif\n\n#  ifndef KRB5KEYTAB\n#   define KRB5KEYTAB      \"/etc/krb5.keytab\"\n#  endif\n\n#  ifndef KRB5SENDAUTH\n#   define KRB5SENDAUTH    1\n#  endif\n\n#  ifndef KRB5CHECKAUTH\n#   define KRB5CHECKAUTH   1\n#  endif\n\n#  ifndef KSSL_CLOCKSKEW\n#   define KSSL_CLOCKSKEW  300;\n#  endif\n\n#  define KSSL_ERR_MAX    255\ntypedef struct kssl_err_st {\n    int reason;\n    char text[KSSL_ERR_MAX + 1];\n} KSSL_ERR;\n\n/*-     Context for passing\n *              (1) Kerberos session key to SSL, and\n *              (2)     Config data between application and SSL lib\n */\ntypedef struct kssl_ctx_st {\n    /*      used by:    disposition:            */\n    char *service_name;         /* C,S default ok (kssl) */\n    char *service_host;         /* C input, REQUIRED */\n    char *client_princ;         /* S output from krb5 ticket */\n    char *keytab_file;          /* S NULL (/etc/krb5.keytab) */\n    char *cred_cache;           /* C NULL (default) */\n    krb5_enctype enctype;\n    int length;\n    krb5_octet FAR *key;\n} KSSL_CTX;\n\n#  define KSSL_CLIENT     1\n#  define KSSL_SERVER     2\n#  define KSSL_SERVICE    3\n#  define KSSL_KEYTAB     4\n\n#  define KSSL_CTX_OK     0\n#  define KSSL_CTX_ERR    1\n#  define KSSL_NOMEM      2\n\n/* Public (for use by applications that use OpenSSL with Kerberos 5 support */\nkrb5_error_code kssl_ctx_setstring(KSSL_CTX *kssl_ctx, int which, char *text);\nKSSL_CTX *kssl_ctx_new(void);\nKSSL_CTX *kssl_ctx_free(KSSL_CTX *kssl_ctx);\nvoid kssl_ctx_show(KSSL_CTX *kssl_ctx);\nkrb5_error_code kssl_ctx_setprinc(KSSL_CTX *kssl_ctx, int which,\n                                  krb5_data *realm, krb5_data *entity,\n                                  int nentities);\nkrb5_error_code kssl_cget_tkt(KSSL_CTX *kssl_ctx, krb5_data **enc_tktp,\n                              krb5_data *authenp, KSSL_ERR *kssl_err);\nkrb5_error_code kssl_sget_tkt(KSSL_CTX *kssl_ctx, krb5_data *indata,\n                              krb5_ticket_times *ttimes, KSSL_ERR *kssl_err);\nkrb5_error_code kssl_ctx_setkey(KSSL_CTX *kssl_ctx, krb5_keyblock *session);\nvoid kssl_err_set(KSSL_ERR *kssl_err, int reason, char *text);\nvoid kssl_krb5_free_data_contents(krb5_context context, krb5_data *data);\nkrb5_error_code kssl_build_principal_2(krb5_context context,\n                                       krb5_principal *princ, int rlen,\n                                       const char *realm, int slen,\n                                       const char *svc, int hlen,\n                                       const char *host);\nkrb5_error_code kssl_validate_times(krb5_timestamp atime,\n                                    krb5_ticket_times *ttimes);\nkrb5_error_code kssl_check_authent(KSSL_CTX *kssl_ctx, krb5_data *authentp,\n                                   krb5_timestamp *atimep,\n                                   KSSL_ERR *kssl_err);\nunsigned char *kssl_skip_confound(krb5_enctype enctype, unsigned char *authn);\n\nvoid SSL_set0_kssl_ctx(SSL *s, KSSL_CTX *kctx);\nKSSL_CTX *SSL_get0_kssl_ctx(SSL *s);\nchar *kssl_ctx_get0_client_princ(KSSL_CTX *kctx);\n\n#ifdef  __cplusplus\n}\n#endif\n# endif                         /* OPENSSL_NO_KRB5 */\n#endif                          /* KSSL_H */\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/x86/include/openssl/lhash.h",
    "content": "/* crypto/lhash/lhash.h */\n/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)\n * All rights reserved.\n *\n * This package is an SSL implementation written\n * by Eric Young (eay@cryptsoft.com).\n * The implementation was written so as to conform with Netscapes SSL.\n *\n * This library is free for commercial and non-commercial use as long as\n * the following conditions are aheared to.  The following conditions\n * apply to all code found in this distribution, be it the RC4, RSA,\n * lhash, DES, etc., code; not just the SSL code.  The SSL documentation\n * included with this distribution is covered by the same copyright terms\n * except that the holder is Tim Hudson (tjh@cryptsoft.com).\n *\n * Copyright remains Eric Young's, and as such any Copyright notices in\n * the code are not to be removed.\n * If this package is used in a product, Eric Young should be given attribution\n * as the author of the parts of the library used.\n * This can be in the form of a textual message at program startup or\n * in documentation (online or textual) provided with the package.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the copyright\n *    notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in the\n *    documentation and/or other materials provided with the distribution.\n * 3. All advertising materials mentioning features or use of this software\n *    must display the following acknowledgement:\n *    \"This product includes cryptographic software written by\n *     Eric Young (eay@cryptsoft.com)\"\n *    The word 'cryptographic' can be left out if the rouines from the library\n *    being used are not cryptographic related :-).\n * 4. If you include any Windows specific code (or a derivative thereof) from\n *    the apps directory (application code) you must include an acknowledgement:\n *    \"This product includes software written by Tim Hudson (tjh@cryptsoft.com)\"\n *\n * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n * SUCH DAMAGE.\n *\n * The licence and distribution terms for any publically available version or\n * derivative of this code cannot be changed.  i.e. this code cannot simply be\n * copied and put under another distribution licence\n * [including the GNU Public Licence.]\n */\n\n/*\n * Header for dynamic hash table routines Author - Eric Young\n */\n\n#ifndef HEADER_LHASH_H\n# define HEADER_LHASH_H\n\n# include <openssl/e_os2.h>\n# ifndef OPENSSL_NO_FP_API\n#  include <stdio.h>\n# endif\n\n# ifndef OPENSSL_NO_BIO\n#  include <openssl/bio.h>\n# endif\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\ntypedef struct lhash_node_st {\n    void *data;\n    struct lhash_node_st *next;\n# ifndef OPENSSL_NO_HASH_COMP\n    unsigned long hash;\n# endif\n} LHASH_NODE;\n\ntypedef int (*LHASH_COMP_FN_TYPE) (const void *, const void *);\ntypedef unsigned long (*LHASH_HASH_FN_TYPE) (const void *);\ntypedef void (*LHASH_DOALL_FN_TYPE) (void *);\ntypedef void (*LHASH_DOALL_ARG_FN_TYPE) (void *, void *);\n\n/*\n * Macros for declaring and implementing type-safe wrappers for LHASH\n * callbacks. This way, callbacks can be provided to LHASH structures without\n * function pointer casting and the macro-defined callbacks provide\n * per-variable casting before deferring to the underlying type-specific\n * callbacks. NB: It is possible to place a \"static\" in front of both the\n * DECLARE and IMPLEMENT macros if the functions are strictly internal.\n */\n\n/* First: \"hash\" functions */\n# define DECLARE_LHASH_HASH_FN(name, o_type) \\\n        unsigned long name##_LHASH_HASH(const void *);\n# define IMPLEMENT_LHASH_HASH_FN(name, o_type) \\\n        unsigned long name##_LHASH_HASH(const void *arg) { \\\n                const o_type *a = arg; \\\n                return name##_hash(a); }\n# define LHASH_HASH_FN(name) name##_LHASH_HASH\n\n/* Second: \"compare\" functions */\n# define DECLARE_LHASH_COMP_FN(name, o_type) \\\n        int name##_LHASH_COMP(const void *, const void *);\n# define IMPLEMENT_LHASH_COMP_FN(name, o_type) \\\n        int name##_LHASH_COMP(const void *arg1, const void *arg2) { \\\n                const o_type *a = arg1;             \\\n                const o_type *b = arg2; \\\n                return name##_cmp(a,b); }\n# define LHASH_COMP_FN(name) name##_LHASH_COMP\n\n/* Third: \"doall\" functions */\n# define DECLARE_LHASH_DOALL_FN(name, o_type) \\\n        void name##_LHASH_DOALL(void *);\n# define IMPLEMENT_LHASH_DOALL_FN(name, o_type) \\\n        void name##_LHASH_DOALL(void *arg) { \\\n                o_type *a = arg; \\\n                name##_doall(a); }\n# define LHASH_DOALL_FN(name) name##_LHASH_DOALL\n\n/* Fourth: \"doall_arg\" functions */\n# define DECLARE_LHASH_DOALL_ARG_FN(name, o_type, a_type) \\\n        void name##_LHASH_DOALL_ARG(void *, void *);\n# define IMPLEMENT_LHASH_DOALL_ARG_FN(name, o_type, a_type) \\\n        void name##_LHASH_DOALL_ARG(void *arg1, void *arg2) { \\\n                o_type *a = arg1; \\\n                a_type *b = arg2; \\\n                name##_doall_arg(a, b); }\n# define LHASH_DOALL_ARG_FN(name) name##_LHASH_DOALL_ARG\n\ntypedef struct lhash_st {\n    LHASH_NODE **b;\n    LHASH_COMP_FN_TYPE comp;\n    LHASH_HASH_FN_TYPE hash;\n    unsigned int num_nodes;\n    unsigned int num_alloc_nodes;\n    unsigned int p;\n    unsigned int pmax;\n    unsigned long up_load;      /* load times 256 */\n    unsigned long down_load;    /* load times 256 */\n    unsigned long num_items;\n    unsigned long num_expands;\n    unsigned long num_expand_reallocs;\n    unsigned long num_contracts;\n    unsigned long num_contract_reallocs;\n    unsigned long num_hash_calls;\n    unsigned long num_comp_calls;\n    unsigned long num_insert;\n    unsigned long num_replace;\n    unsigned long num_delete;\n    unsigned long num_no_delete;\n    unsigned long num_retrieve;\n    unsigned long num_retrieve_miss;\n    unsigned long num_hash_comps;\n    int error;\n} _LHASH;                       /* Do not use _LHASH directly, use LHASH_OF\n                                 * and friends */\n\n# define LH_LOAD_MULT    256\n\n/*\n * Indicates a malloc() error in the last call, this is only bad in\n * lh_insert().\n */\n# define lh_error(lh)    ((lh)->error)\n\n_LHASH *lh_new(LHASH_HASH_FN_TYPE h, LHASH_COMP_FN_TYPE c);\nvoid lh_free(_LHASH *lh);\nvoid *lh_insert(_LHASH *lh, void *data);\nvoid *lh_delete(_LHASH *lh, const void *data);\nvoid *lh_retrieve(_LHASH *lh, const void *data);\nvoid lh_doall(_LHASH *lh, LHASH_DOALL_FN_TYPE func);\nvoid lh_doall_arg(_LHASH *lh, LHASH_DOALL_ARG_FN_TYPE func, void *arg);\nunsigned long lh_strhash(const char *c);\nunsigned long lh_num_items(const _LHASH *lh);\n\n# ifndef OPENSSL_NO_FP_API\nvoid lh_stats(const _LHASH *lh, FILE *out);\nvoid lh_node_stats(const _LHASH *lh, FILE *out);\nvoid lh_node_usage_stats(const _LHASH *lh, FILE *out);\n# endif\n\n# ifndef OPENSSL_NO_BIO\nvoid lh_stats_bio(const _LHASH *lh, BIO *out);\nvoid lh_node_stats_bio(const _LHASH *lh, BIO *out);\nvoid lh_node_usage_stats_bio(const _LHASH *lh, BIO *out);\n# endif\n\n/* Type checking... */\n\n# define LHASH_OF(type) struct lhash_st_##type\n\n# define DECLARE_LHASH_OF(type) LHASH_OF(type) { int dummy; }\n\n# define CHECKED_LHASH_OF(type,lh) \\\n  ((_LHASH *)CHECKED_PTR_OF(LHASH_OF(type),lh))\n\n/* Define wrapper functions. */\n# define LHM_lh_new(type, name) \\\n  ((LHASH_OF(type) *)lh_new(LHASH_HASH_FN(name), LHASH_COMP_FN(name)))\n# define LHM_lh_error(type, lh) \\\n  lh_error(CHECKED_LHASH_OF(type,lh))\n# define LHM_lh_insert(type, lh, inst) \\\n  ((type *)lh_insert(CHECKED_LHASH_OF(type, lh), \\\n                     CHECKED_PTR_OF(type, inst)))\n# define LHM_lh_retrieve(type, lh, inst) \\\n  ((type *)lh_retrieve(CHECKED_LHASH_OF(type, lh), \\\n                       CHECKED_PTR_OF(type, inst)))\n# define LHM_lh_delete(type, lh, inst) \\\n  ((type *)lh_delete(CHECKED_LHASH_OF(type, lh),                        \\\n                     CHECKED_PTR_OF(type, inst)))\n# define LHM_lh_doall(type, lh,fn) lh_doall(CHECKED_LHASH_OF(type, lh), fn)\n# define LHM_lh_doall_arg(type, lh, fn, arg_type, arg) \\\n  lh_doall_arg(CHECKED_LHASH_OF(type, lh), fn, CHECKED_PTR_OF(arg_type, arg))\n# define LHM_lh_num_items(type, lh) lh_num_items(CHECKED_LHASH_OF(type, lh))\n# define LHM_lh_down_load(type, lh) (CHECKED_LHASH_OF(type, lh)->down_load)\n# define LHM_lh_node_stats_bio(type, lh, out) \\\n  lh_node_stats_bio(CHECKED_LHASH_OF(type, lh), out)\n# define LHM_lh_node_usage_stats_bio(type, lh, out) \\\n  lh_node_usage_stats_bio(CHECKED_LHASH_OF(type, lh), out)\n# define LHM_lh_stats_bio(type, lh, out) \\\n  lh_stats_bio(CHECKED_LHASH_OF(type, lh), out)\n# define LHM_lh_free(type, lh) lh_free(CHECKED_LHASH_OF(type, lh))\n\nDECLARE_LHASH_OF(OPENSSL_STRING);\nDECLARE_LHASH_OF(OPENSSL_CSTRING);\n\n#ifdef  __cplusplus\n}\n#endif\n\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/x86/include/openssl/md4.h",
    "content": "/* crypto/md4/md4.h */\n/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)\n * All rights reserved.\n *\n * This package is an SSL implementation written\n * by Eric Young (eay@cryptsoft.com).\n * The implementation was written so as to conform with Netscapes SSL.\n *\n * This library is free for commercial and non-commercial use as long as\n * the following conditions are aheared to.  The following conditions\n * apply to all code found in this distribution, be it the RC4, RSA,\n * lhash, DES, etc., code; not just the SSL code.  The SSL documentation\n * included with this distribution is covered by the same copyright terms\n * except that the holder is Tim Hudson (tjh@cryptsoft.com).\n *\n * Copyright remains Eric Young's, and as such any Copyright notices in\n * the code are not to be removed.\n * If this package is used in a product, Eric Young should be given attribution\n * as the author of the parts of the library used.\n * This can be in the form of a textual message at program startup or\n * in documentation (online or textual) provided with the package.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the copyright\n *    notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in the\n *    documentation and/or other materials provided with the distribution.\n * 3. All advertising materials mentioning features or use of this software\n *    must display the following acknowledgement:\n *    \"This product includes cryptographic software written by\n *     Eric Young (eay@cryptsoft.com)\"\n *    The word 'cryptographic' can be left out if the rouines from the library\n *    being used are not cryptographic related :-).\n * 4. If you include any Windows specific code (or a derivative thereof) from\n *    the apps directory (application code) you must include an acknowledgement:\n *    \"This product includes software written by Tim Hudson (tjh@cryptsoft.com)\"\n *\n * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n * SUCH DAMAGE.\n *\n * The licence and distribution terms for any publically available version or\n * derivative of this code cannot be changed.  i.e. this code cannot simply be\n * copied and put under another distribution licence\n * [including the GNU Public Licence.]\n */\n\n#ifndef HEADER_MD4_H\n# define HEADER_MD4_H\n\n# include <openssl/e_os2.h>\n# include <stddef.h>\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n# ifdef OPENSSL_NO_MD4\n#  error MD4 is disabled.\n# endif\n\n/*-\n * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n * ! MD4_LONG has to be at least 32 bits wide. If it's wider, then !\n * ! MD4_LONG_LOG2 has to be defined along.                        !\n * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n */\n\n# if defined(__LP32__)\n#  define MD4_LONG unsigned long\n# elif defined(OPENSSL_SYS_CRAY) || defined(__ILP64__)\n#  define MD4_LONG unsigned long\n#  define MD4_LONG_LOG2 3\n/*\n * _CRAY note. I could declare short, but I have no idea what impact\n * does it have on performance on none-T3E machines. I could declare\n * int, but at least on C90 sizeof(int) can be chosen at compile time.\n * So I've chosen long...\n *                                      <appro@fy.chalmers.se>\n */\n# else\n#  define MD4_LONG unsigned int\n# endif\n\n# define MD4_CBLOCK      64\n# define MD4_LBLOCK      (MD4_CBLOCK/4)\n# define MD4_DIGEST_LENGTH 16\n\ntypedef struct MD4state_st {\n    MD4_LONG A, B, C, D;\n    MD4_LONG Nl, Nh;\n    MD4_LONG data[MD4_LBLOCK];\n    unsigned int num;\n} MD4_CTX;\n\n# ifdef OPENSSL_FIPS\nint private_MD4_Init(MD4_CTX *c);\n# endif\nint MD4_Init(MD4_CTX *c);\nint MD4_Update(MD4_CTX *c, const void *data, size_t len);\nint MD4_Final(unsigned char *md, MD4_CTX *c);\nunsigned char *MD4(const unsigned char *d, size_t n, unsigned char *md);\nvoid MD4_Transform(MD4_CTX *c, const unsigned char *b);\n#ifdef  __cplusplus\n}\n#endif\n\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/x86/include/openssl/md5.h",
    "content": "/* crypto/md5/md5.h */\n/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)\n * All rights reserved.\n *\n * This package is an SSL implementation written\n * by Eric Young (eay@cryptsoft.com).\n * The implementation was written so as to conform with Netscapes SSL.\n *\n * This library is free for commercial and non-commercial use as long as\n * the following conditions are aheared to.  The following conditions\n * apply to all code found in this distribution, be it the RC4, RSA,\n * lhash, DES, etc., code; not just the SSL code.  The SSL documentation\n * included with this distribution is covered by the same copyright terms\n * except that the holder is Tim Hudson (tjh@cryptsoft.com).\n *\n * Copyright remains Eric Young's, and as such any Copyright notices in\n * the code are not to be removed.\n * If this package is used in a product, Eric Young should be given attribution\n * as the author of the parts of the library used.\n * This can be in the form of a textual message at program startup or\n * in documentation (online or textual) provided with the package.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the copyright\n *    notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in the\n *    documentation and/or other materials provided with the distribution.\n * 3. All advertising materials mentioning features or use of this software\n *    must display the following acknowledgement:\n *    \"This product includes cryptographic software written by\n *     Eric Young (eay@cryptsoft.com)\"\n *    The word 'cryptographic' can be left out if the rouines from the library\n *    being used are not cryptographic related :-).\n * 4. If you include any Windows specific code (or a derivative thereof) from\n *    the apps directory (application code) you must include an acknowledgement:\n *    \"This product includes software written by Tim Hudson (tjh@cryptsoft.com)\"\n *\n * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n * SUCH DAMAGE.\n *\n * The licence and distribution terms for any publically available version or\n * derivative of this code cannot be changed.  i.e. this code cannot simply be\n * copied and put under another distribution licence\n * [including the GNU Public Licence.]\n */\n\n#ifndef HEADER_MD5_H\n# define HEADER_MD5_H\n\n# include <openssl/e_os2.h>\n# include <stddef.h>\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n# ifdef OPENSSL_NO_MD5\n#  error MD5 is disabled.\n# endif\n\n/*\n * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n * ! MD5_LONG has to be at least 32 bits wide. If it's wider, then !\n * ! MD5_LONG_LOG2 has to be defined along.                        !\n * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n */\n\n# if defined(__LP32__)\n#  define MD5_LONG unsigned long\n# elif defined(OPENSSL_SYS_CRAY) || defined(__ILP64__)\n#  define MD5_LONG unsigned long\n#  define MD5_LONG_LOG2 3\n/*\n * _CRAY note. I could declare short, but I have no idea what impact\n * does it have on performance on none-T3E machines. I could declare\n * int, but at least on C90 sizeof(int) can be chosen at compile time.\n * So I've chosen long...\n *                                      <appro@fy.chalmers.se>\n */\n# else\n#  define MD5_LONG unsigned int\n# endif\n\n# define MD5_CBLOCK      64\n# define MD5_LBLOCK      (MD5_CBLOCK/4)\n# define MD5_DIGEST_LENGTH 16\n\ntypedef struct MD5state_st {\n    MD5_LONG A, B, C, D;\n    MD5_LONG Nl, Nh;\n    MD5_LONG data[MD5_LBLOCK];\n    unsigned int num;\n} MD5_CTX;\n\n# ifdef OPENSSL_FIPS\nint private_MD5_Init(MD5_CTX *c);\n# endif\nint MD5_Init(MD5_CTX *c);\nint MD5_Update(MD5_CTX *c, const void *data, size_t len);\nint MD5_Final(unsigned char *md, MD5_CTX *c);\nunsigned char *MD5(const unsigned char *d, size_t n, unsigned char *md);\nvoid MD5_Transform(MD5_CTX *c, const unsigned char *b);\n#ifdef  __cplusplus\n}\n#endif\n\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/x86/include/openssl/mdc2.h",
    "content": "/* crypto/mdc2/mdc2.h */\n/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)\n * All rights reserved.\n *\n * This package is an SSL implementation written\n * by Eric Young (eay@cryptsoft.com).\n * The implementation was written so as to conform with Netscapes SSL.\n *\n * This library is free for commercial and non-commercial use as long as\n * the following conditions are aheared to.  The following conditions\n * apply to all code found in this distribution, be it the RC4, RSA,\n * lhash, DES, etc., code; not just the SSL code.  The SSL documentation\n * included with this distribution is covered by the same copyright terms\n * except that the holder is Tim Hudson (tjh@cryptsoft.com).\n *\n * Copyright remains Eric Young's, and as such any Copyright notices in\n * the code are not to be removed.\n * If this package is used in a product, Eric Young should be given attribution\n * as the author of the parts of the library used.\n * This can be in the form of a textual message at program startup or\n * in documentation (online or textual) provided with the package.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the copyright\n *    notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in the\n *    documentation and/or other materials provided with the distribution.\n * 3. All advertising materials mentioning features or use of this software\n *    must display the following acknowledgement:\n *    \"This product includes cryptographic software written by\n *     Eric Young (eay@cryptsoft.com)\"\n *    The word 'cryptographic' can be left out if the rouines from the library\n *    being used are not cryptographic related :-).\n * 4. If you include any Windows specific code (or a derivative thereof) from\n *    the apps directory (application code) you must include an acknowledgement:\n *    \"This product includes software written by Tim Hudson (tjh@cryptsoft.com)\"\n *\n * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n * SUCH DAMAGE.\n *\n * The licence and distribution terms for any publically available version or\n * derivative of this code cannot be changed.  i.e. this code cannot simply be\n * copied and put under another distribution licence\n * [including the GNU Public Licence.]\n */\n\n#ifndef HEADER_MDC2_H\n# define HEADER_MDC2_H\n\n# include <openssl/des.h>\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n# ifdef OPENSSL_NO_MDC2\n#  error MDC2 is disabled.\n# endif\n\n# define MDC2_BLOCK              8\n# define MDC2_DIGEST_LENGTH      16\n\ntypedef struct mdc2_ctx_st {\n    unsigned int num;\n    unsigned char data[MDC2_BLOCK];\n    DES_cblock h, hh;\n    int pad_type;               /* either 1 or 2, default 1 */\n} MDC2_CTX;\n\n# ifdef OPENSSL_FIPS\nint private_MDC2_Init(MDC2_CTX *c);\n# endif\nint MDC2_Init(MDC2_CTX *c);\nint MDC2_Update(MDC2_CTX *c, const unsigned char *data, size_t len);\nint MDC2_Final(unsigned char *md, MDC2_CTX *c);\nunsigned char *MDC2(const unsigned char *d, size_t n, unsigned char *md);\n\n#ifdef  __cplusplus\n}\n#endif\n\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/x86/include/openssl/modes.h",
    "content": "/* ====================================================================\n * Copyright (c) 2008 The OpenSSL Project. All rights reserved.\n *\n * Rights for redistribution and usage in source and binary\n * forms are granted according to the OpenSSL license.\n */\n\n#include <stddef.h>\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\ntypedef void (*block128_f) (const unsigned char in[16],\n                            unsigned char out[16], const void *key);\n\ntypedef void (*cbc128_f) (const unsigned char *in, unsigned char *out,\n                          size_t len, const void *key,\n                          unsigned char ivec[16], int enc);\n\ntypedef void (*ctr128_f) (const unsigned char *in, unsigned char *out,\n                          size_t blocks, const void *key,\n                          const unsigned char ivec[16]);\n\ntypedef void (*ccm128_f) (const unsigned char *in, unsigned char *out,\n                          size_t blocks, const void *key,\n                          const unsigned char ivec[16],\n                          unsigned char cmac[16]);\n\nvoid CRYPTO_cbc128_encrypt(const unsigned char *in, unsigned char *out,\n                           size_t len, const void *key,\n                           unsigned char ivec[16], block128_f block);\nvoid CRYPTO_cbc128_decrypt(const unsigned char *in, unsigned char *out,\n                           size_t len, const void *key,\n                           unsigned char ivec[16], block128_f block);\n\nvoid CRYPTO_ctr128_encrypt(const unsigned char *in, unsigned char *out,\n                           size_t len, const void *key,\n                           unsigned char ivec[16],\n                           unsigned char ecount_buf[16], unsigned int *num,\n                           block128_f block);\n\nvoid CRYPTO_ctr128_encrypt_ctr32(const unsigned char *in, unsigned char *out,\n                                 size_t len, const void *key,\n                                 unsigned char ivec[16],\n                                 unsigned char ecount_buf[16],\n                                 unsigned int *num, ctr128_f ctr);\n\nvoid CRYPTO_ofb128_encrypt(const unsigned char *in, unsigned char *out,\n                           size_t len, const void *key,\n                           unsigned char ivec[16], int *num,\n                           block128_f block);\n\nvoid CRYPTO_cfb128_encrypt(const unsigned char *in, unsigned char *out,\n                           size_t len, const void *key,\n                           unsigned char ivec[16], int *num,\n                           int enc, block128_f block);\nvoid CRYPTO_cfb128_8_encrypt(const unsigned char *in, unsigned char *out,\n                             size_t length, const void *key,\n                             unsigned char ivec[16], int *num,\n                             int enc, block128_f block);\nvoid CRYPTO_cfb128_1_encrypt(const unsigned char *in, unsigned char *out,\n                             size_t bits, const void *key,\n                             unsigned char ivec[16], int *num,\n                             int enc, block128_f block);\n\nsize_t CRYPTO_cts128_encrypt_block(const unsigned char *in,\n                                   unsigned char *out, size_t len,\n                                   const void *key, unsigned char ivec[16],\n                                   block128_f block);\nsize_t CRYPTO_cts128_encrypt(const unsigned char *in, unsigned char *out,\n                             size_t len, const void *key,\n                             unsigned char ivec[16], cbc128_f cbc);\nsize_t CRYPTO_cts128_decrypt_block(const unsigned char *in,\n                                   unsigned char *out, size_t len,\n                                   const void *key, unsigned char ivec[16],\n                                   block128_f block);\nsize_t CRYPTO_cts128_decrypt(const unsigned char *in, unsigned char *out,\n                             size_t len, const void *key,\n                             unsigned char ivec[16], cbc128_f cbc);\n\nsize_t CRYPTO_nistcts128_encrypt_block(const unsigned char *in,\n                                       unsigned char *out, size_t len,\n                                       const void *key,\n                                       unsigned char ivec[16],\n                                       block128_f block);\nsize_t CRYPTO_nistcts128_encrypt(const unsigned char *in, unsigned char *out,\n                                 size_t len, const void *key,\n                                 unsigned char ivec[16], cbc128_f cbc);\nsize_t CRYPTO_nistcts128_decrypt_block(const unsigned char *in,\n                                       unsigned char *out, size_t len,\n                                       const void *key,\n                                       unsigned char ivec[16],\n                                       block128_f block);\nsize_t CRYPTO_nistcts128_decrypt(const unsigned char *in, unsigned char *out,\n                                 size_t len, const void *key,\n                                 unsigned char ivec[16], cbc128_f cbc);\n\ntypedef struct gcm128_context GCM128_CONTEXT;\n\nGCM128_CONTEXT *CRYPTO_gcm128_new(void *key, block128_f block);\nvoid CRYPTO_gcm128_init(GCM128_CONTEXT *ctx, void *key, block128_f block);\nvoid CRYPTO_gcm128_setiv(GCM128_CONTEXT *ctx, const unsigned char *iv,\n                         size_t len);\nint CRYPTO_gcm128_aad(GCM128_CONTEXT *ctx, const unsigned char *aad,\n                      size_t len);\nint CRYPTO_gcm128_encrypt(GCM128_CONTEXT *ctx,\n                          const unsigned char *in, unsigned char *out,\n                          size_t len);\nint CRYPTO_gcm128_decrypt(GCM128_CONTEXT *ctx,\n                          const unsigned char *in, unsigned char *out,\n                          size_t len);\nint CRYPTO_gcm128_encrypt_ctr32(GCM128_CONTEXT *ctx,\n                                const unsigned char *in, unsigned char *out,\n                                size_t len, ctr128_f stream);\nint CRYPTO_gcm128_decrypt_ctr32(GCM128_CONTEXT *ctx,\n                                const unsigned char *in, unsigned char *out,\n                                size_t len, ctr128_f stream);\nint CRYPTO_gcm128_finish(GCM128_CONTEXT *ctx, const unsigned char *tag,\n                         size_t len);\nvoid CRYPTO_gcm128_tag(GCM128_CONTEXT *ctx, unsigned char *tag, size_t len);\nvoid CRYPTO_gcm128_release(GCM128_CONTEXT *ctx);\n\ntypedef struct ccm128_context CCM128_CONTEXT;\n\nvoid CRYPTO_ccm128_init(CCM128_CONTEXT *ctx,\n                        unsigned int M, unsigned int L, void *key,\n                        block128_f block);\nint CRYPTO_ccm128_setiv(CCM128_CONTEXT *ctx, const unsigned char *nonce,\n                        size_t nlen, size_t mlen);\nvoid CRYPTO_ccm128_aad(CCM128_CONTEXT *ctx, const unsigned char *aad,\n                       size_t alen);\nint CRYPTO_ccm128_encrypt(CCM128_CONTEXT *ctx, const unsigned char *inp,\n                          unsigned char *out, size_t len);\nint CRYPTO_ccm128_decrypt(CCM128_CONTEXT *ctx, const unsigned char *inp,\n                          unsigned char *out, size_t len);\nint CRYPTO_ccm128_encrypt_ccm64(CCM128_CONTEXT *ctx, const unsigned char *inp,\n                                unsigned char *out, size_t len,\n                                ccm128_f stream);\nint CRYPTO_ccm128_decrypt_ccm64(CCM128_CONTEXT *ctx, const unsigned char *inp,\n                                unsigned char *out, size_t len,\n                                ccm128_f stream);\nsize_t CRYPTO_ccm128_tag(CCM128_CONTEXT *ctx, unsigned char *tag, size_t len);\n\ntypedef struct xts128_context XTS128_CONTEXT;\n\nint CRYPTO_xts128_encrypt(const XTS128_CONTEXT *ctx,\n                          const unsigned char iv[16],\n                          const unsigned char *inp, unsigned char *out,\n                          size_t len, int enc);\n\nsize_t CRYPTO_128_wrap(void *key, const unsigned char *iv,\n                       unsigned char *out,\n                       const unsigned char *in, size_t inlen,\n                       block128_f block);\n\nsize_t CRYPTO_128_unwrap(void *key, const unsigned char *iv,\n                         unsigned char *out,\n                         const unsigned char *in, size_t inlen,\n                         block128_f block);\n\n#ifdef  __cplusplus\n}\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/x86/include/openssl/obj_mac.h",
    "content": "/* crypto/objects/obj_mac.h */\n\n/*\n * THIS FILE IS GENERATED FROM objects.txt by objects.pl via the following\n * command: perl objects.pl objects.txt obj_mac.num obj_mac.h\n */\n\n/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)\n * All rights reserved.\n *\n * This package is an SSL implementation written\n * by Eric Young (eay@cryptsoft.com).\n * The implementation was written so as to conform with Netscapes SSL.\n *\n * This library is free for commercial and non-commercial use as long as\n * the following conditions are aheared to.  The following conditions\n * apply to all code found in this distribution, be it the RC4, RSA,\n * lhash, DES, etc., code; not just the SSL code.  The SSL documentation\n * included with this distribution is covered by the same copyright terms\n * except that the holder is Tim Hudson (tjh@cryptsoft.com).\n *\n * Copyright remains Eric Young's, and as such any Copyright notices in\n * the code are not to be removed.\n * If this package is used in a product, Eric Young should be given attribution\n * as the author of the parts of the library used.\n * This can be in the form of a textual message at program startup or\n * in documentation (online or textual) provided with the package.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the copyright\n *    notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in the\n *    documentation and/or other materials provided with the distribution.\n * 3. All advertising materials mentioning features or use of this software\n *    must display the following acknowledgement:\n *    \"This product includes cryptographic software written by\n *     Eric Young (eay@cryptsoft.com)\"\n *    The word 'cryptographic' can be left out if the rouines from the library\n *    being used are not cryptographic related :-).\n * 4. If you include any Windows specific code (or a derivative thereof) from\n *    the apps directory (application code) you must include an acknowledgement:\n *    \"This product includes software written by Tim Hudson (tjh@cryptsoft.com)\"\n *\n * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n * SUCH DAMAGE.\n *\n * The licence and distribution terms for any publically available version or\n * derivative of this code cannot be changed.  i.e. this code cannot simply be\n * copied and put under another distribution licence\n * [including the GNU Public Licence.]\n */\n\n#define SN_undef                        \"UNDEF\"\n#define LN_undef                        \"undefined\"\n#define NID_undef                       0\n#define OBJ_undef                       0L\n\n#define SN_itu_t                \"ITU-T\"\n#define LN_itu_t                \"itu-t\"\n#define NID_itu_t               645\n#define OBJ_itu_t               0L\n\n#define NID_ccitt               404\n#define OBJ_ccitt               OBJ_itu_t\n\n#define SN_iso          \"ISO\"\n#define LN_iso          \"iso\"\n#define NID_iso         181\n#define OBJ_iso         1L\n\n#define SN_joint_iso_itu_t              \"JOINT-ISO-ITU-T\"\n#define LN_joint_iso_itu_t              \"joint-iso-itu-t\"\n#define NID_joint_iso_itu_t             646\n#define OBJ_joint_iso_itu_t             2L\n\n#define NID_joint_iso_ccitt             393\n#define OBJ_joint_iso_ccitt             OBJ_joint_iso_itu_t\n\n#define SN_member_body          \"member-body\"\n#define LN_member_body          \"ISO Member Body\"\n#define NID_member_body         182\n#define OBJ_member_body         OBJ_iso,2L\n\n#define SN_identified_organization              \"identified-organization\"\n#define NID_identified_organization             676\n#define OBJ_identified_organization             OBJ_iso,3L\n\n#define SN_hmac_md5             \"HMAC-MD5\"\n#define LN_hmac_md5             \"hmac-md5\"\n#define NID_hmac_md5            780\n#define OBJ_hmac_md5            OBJ_identified_organization,6L,1L,5L,5L,8L,1L,1L\n\n#define SN_hmac_sha1            \"HMAC-SHA1\"\n#define LN_hmac_sha1            \"hmac-sha1\"\n#define NID_hmac_sha1           781\n#define OBJ_hmac_sha1           OBJ_identified_organization,6L,1L,5L,5L,8L,1L,2L\n\n#define SN_certicom_arc         \"certicom-arc\"\n#define NID_certicom_arc                677\n#define OBJ_certicom_arc                OBJ_identified_organization,132L\n\n#define SN_international_organizations          \"international-organizations\"\n#define LN_international_organizations          \"International Organizations\"\n#define NID_international_organizations         647\n#define OBJ_international_organizations         OBJ_joint_iso_itu_t,23L\n\n#define SN_wap          \"wap\"\n#define NID_wap         678\n#define OBJ_wap         OBJ_international_organizations,43L\n\n#define SN_wap_wsg              \"wap-wsg\"\n#define NID_wap_wsg             679\n#define OBJ_wap_wsg             OBJ_wap,1L\n\n#define SN_selected_attribute_types             \"selected-attribute-types\"\n#define LN_selected_attribute_types             \"Selected Attribute Types\"\n#define NID_selected_attribute_types            394\n#define OBJ_selected_attribute_types            OBJ_joint_iso_itu_t,5L,1L,5L\n\n#define SN_clearance            \"clearance\"\n#define NID_clearance           395\n#define OBJ_clearance           OBJ_selected_attribute_types,55L\n\n#define SN_ISO_US               \"ISO-US\"\n#define LN_ISO_US               \"ISO US Member Body\"\n#define NID_ISO_US              183\n#define OBJ_ISO_US              OBJ_member_body,840L\n\n#define SN_X9_57                \"X9-57\"\n#define LN_X9_57                \"X9.57\"\n#define NID_X9_57               184\n#define OBJ_X9_57               OBJ_ISO_US,10040L\n\n#define SN_X9cm         \"X9cm\"\n#define LN_X9cm         \"X9.57 CM ?\"\n#define NID_X9cm                185\n#define OBJ_X9cm                OBJ_X9_57,4L\n\n#define SN_dsa          \"DSA\"\n#define LN_dsa          \"dsaEncryption\"\n#define NID_dsa         116\n#define OBJ_dsa         OBJ_X9cm,1L\n\n#define SN_dsaWithSHA1          \"DSA-SHA1\"\n#define LN_dsaWithSHA1          \"dsaWithSHA1\"\n#define NID_dsaWithSHA1         113\n#define OBJ_dsaWithSHA1         OBJ_X9cm,3L\n\n#define SN_ansi_X9_62           \"ansi-X9-62\"\n#define LN_ansi_X9_62           \"ANSI X9.62\"\n#define NID_ansi_X9_62          405\n#define OBJ_ansi_X9_62          OBJ_ISO_US,10045L\n\n#define OBJ_X9_62_id_fieldType          OBJ_ansi_X9_62,1L\n\n#define SN_X9_62_prime_field            \"prime-field\"\n#define NID_X9_62_prime_field           406\n#define OBJ_X9_62_prime_field           OBJ_X9_62_id_fieldType,1L\n\n#define SN_X9_62_characteristic_two_field               \"characteristic-two-field\"\n#define NID_X9_62_characteristic_two_field              407\n#define OBJ_X9_62_characteristic_two_field              OBJ_X9_62_id_fieldType,2L\n\n#define SN_X9_62_id_characteristic_two_basis            \"id-characteristic-two-basis\"\n#define NID_X9_62_id_characteristic_two_basis           680\n#define OBJ_X9_62_id_characteristic_two_basis           OBJ_X9_62_characteristic_two_field,3L\n\n#define SN_X9_62_onBasis                \"onBasis\"\n#define NID_X9_62_onBasis               681\n#define OBJ_X9_62_onBasis               OBJ_X9_62_id_characteristic_two_basis,1L\n\n#define SN_X9_62_tpBasis                \"tpBasis\"\n#define NID_X9_62_tpBasis               682\n#define OBJ_X9_62_tpBasis               OBJ_X9_62_id_characteristic_two_basis,2L\n\n#define SN_X9_62_ppBasis                \"ppBasis\"\n#define NID_X9_62_ppBasis               683\n#define OBJ_X9_62_ppBasis               OBJ_X9_62_id_characteristic_two_basis,3L\n\n#define OBJ_X9_62_id_publicKeyType              OBJ_ansi_X9_62,2L\n\n#define SN_X9_62_id_ecPublicKey         \"id-ecPublicKey\"\n#define NID_X9_62_id_ecPublicKey                408\n#define OBJ_X9_62_id_ecPublicKey                OBJ_X9_62_id_publicKeyType,1L\n\n#define OBJ_X9_62_ellipticCurve         OBJ_ansi_X9_62,3L\n\n#define OBJ_X9_62_c_TwoCurve            OBJ_X9_62_ellipticCurve,0L\n\n#define SN_X9_62_c2pnb163v1             \"c2pnb163v1\"\n#define NID_X9_62_c2pnb163v1            684\n#define OBJ_X9_62_c2pnb163v1            OBJ_X9_62_c_TwoCurve,1L\n\n#define SN_X9_62_c2pnb163v2             \"c2pnb163v2\"\n#define NID_X9_62_c2pnb163v2            685\n#define OBJ_X9_62_c2pnb163v2            OBJ_X9_62_c_TwoCurve,2L\n\n#define SN_X9_62_c2pnb163v3             \"c2pnb163v3\"\n#define NID_X9_62_c2pnb163v3            686\n#define OBJ_X9_62_c2pnb163v3            OBJ_X9_62_c_TwoCurve,3L\n\n#define SN_X9_62_c2pnb176v1             \"c2pnb176v1\"\n#define NID_X9_62_c2pnb176v1            687\n#define OBJ_X9_62_c2pnb176v1            OBJ_X9_62_c_TwoCurve,4L\n\n#define SN_X9_62_c2tnb191v1             \"c2tnb191v1\"\n#define NID_X9_62_c2tnb191v1            688\n#define OBJ_X9_62_c2tnb191v1            OBJ_X9_62_c_TwoCurve,5L\n\n#define SN_X9_62_c2tnb191v2             \"c2tnb191v2\"\n#define NID_X9_62_c2tnb191v2            689\n#define OBJ_X9_62_c2tnb191v2            OBJ_X9_62_c_TwoCurve,6L\n\n#define SN_X9_62_c2tnb191v3             \"c2tnb191v3\"\n#define NID_X9_62_c2tnb191v3            690\n#define OBJ_X9_62_c2tnb191v3            OBJ_X9_62_c_TwoCurve,7L\n\n#define SN_X9_62_c2onb191v4             \"c2onb191v4\"\n#define NID_X9_62_c2onb191v4            691\n#define OBJ_X9_62_c2onb191v4            OBJ_X9_62_c_TwoCurve,8L\n\n#define SN_X9_62_c2onb191v5             \"c2onb191v5\"\n#define NID_X9_62_c2onb191v5            692\n#define OBJ_X9_62_c2onb191v5            OBJ_X9_62_c_TwoCurve,9L\n\n#define SN_X9_62_c2pnb208w1             \"c2pnb208w1\"\n#define NID_X9_62_c2pnb208w1            693\n#define OBJ_X9_62_c2pnb208w1            OBJ_X9_62_c_TwoCurve,10L\n\n#define SN_X9_62_c2tnb239v1             \"c2tnb239v1\"\n#define NID_X9_62_c2tnb239v1            694\n#define OBJ_X9_62_c2tnb239v1            OBJ_X9_62_c_TwoCurve,11L\n\n#define SN_X9_62_c2tnb239v2             \"c2tnb239v2\"\n#define NID_X9_62_c2tnb239v2            695\n#define OBJ_X9_62_c2tnb239v2            OBJ_X9_62_c_TwoCurve,12L\n\n#define SN_X9_62_c2tnb239v3             \"c2tnb239v3\"\n#define NID_X9_62_c2tnb239v3            696\n#define OBJ_X9_62_c2tnb239v3            OBJ_X9_62_c_TwoCurve,13L\n\n#define SN_X9_62_c2onb239v4             \"c2onb239v4\"\n#define NID_X9_62_c2onb239v4            697\n#define OBJ_X9_62_c2onb239v4            OBJ_X9_62_c_TwoCurve,14L\n\n#define SN_X9_62_c2onb239v5             \"c2onb239v5\"\n#define NID_X9_62_c2onb239v5            698\n#define OBJ_X9_62_c2onb239v5            OBJ_X9_62_c_TwoCurve,15L\n\n#define SN_X9_62_c2pnb272w1             \"c2pnb272w1\"\n#define NID_X9_62_c2pnb272w1            699\n#define OBJ_X9_62_c2pnb272w1            OBJ_X9_62_c_TwoCurve,16L\n\n#define SN_X9_62_c2pnb304w1             \"c2pnb304w1\"\n#define NID_X9_62_c2pnb304w1            700\n#define OBJ_X9_62_c2pnb304w1            OBJ_X9_62_c_TwoCurve,17L\n\n#define SN_X9_62_c2tnb359v1             \"c2tnb359v1\"\n#define NID_X9_62_c2tnb359v1            701\n#define OBJ_X9_62_c2tnb359v1            OBJ_X9_62_c_TwoCurve,18L\n\n#define SN_X9_62_c2pnb368w1             \"c2pnb368w1\"\n#define NID_X9_62_c2pnb368w1            702\n#define OBJ_X9_62_c2pnb368w1            OBJ_X9_62_c_TwoCurve,19L\n\n#define SN_X9_62_c2tnb431r1             \"c2tnb431r1\"\n#define NID_X9_62_c2tnb431r1            703\n#define OBJ_X9_62_c2tnb431r1            OBJ_X9_62_c_TwoCurve,20L\n\n#define OBJ_X9_62_primeCurve            OBJ_X9_62_ellipticCurve,1L\n\n#define SN_X9_62_prime192v1             \"prime192v1\"\n#define NID_X9_62_prime192v1            409\n#define OBJ_X9_62_prime192v1            OBJ_X9_62_primeCurve,1L\n\n#define SN_X9_62_prime192v2             \"prime192v2\"\n#define NID_X9_62_prime192v2            410\n#define OBJ_X9_62_prime192v2            OBJ_X9_62_primeCurve,2L\n\n#define SN_X9_62_prime192v3             \"prime192v3\"\n#define NID_X9_62_prime192v3            411\n#define OBJ_X9_62_prime192v3            OBJ_X9_62_primeCurve,3L\n\n#define SN_X9_62_prime239v1             \"prime239v1\"\n#define NID_X9_62_prime239v1            412\n#define OBJ_X9_62_prime239v1            OBJ_X9_62_primeCurve,4L\n\n#define SN_X9_62_prime239v2             \"prime239v2\"\n#define NID_X9_62_prime239v2            413\n#define OBJ_X9_62_prime239v2            OBJ_X9_62_primeCurve,5L\n\n#define SN_X9_62_prime239v3             \"prime239v3\"\n#define NID_X9_62_prime239v3            414\n#define OBJ_X9_62_prime239v3            OBJ_X9_62_primeCurve,6L\n\n#define SN_X9_62_prime256v1             \"prime256v1\"\n#define NID_X9_62_prime256v1            415\n#define OBJ_X9_62_prime256v1            OBJ_X9_62_primeCurve,7L\n\n#define OBJ_X9_62_id_ecSigType          OBJ_ansi_X9_62,4L\n\n#define SN_ecdsa_with_SHA1              \"ecdsa-with-SHA1\"\n#define NID_ecdsa_with_SHA1             416\n#define OBJ_ecdsa_with_SHA1             OBJ_X9_62_id_ecSigType,1L\n\n#define SN_ecdsa_with_Recommended               \"ecdsa-with-Recommended\"\n#define NID_ecdsa_with_Recommended              791\n#define OBJ_ecdsa_with_Recommended              OBJ_X9_62_id_ecSigType,2L\n\n#define SN_ecdsa_with_Specified         \"ecdsa-with-Specified\"\n#define NID_ecdsa_with_Specified                792\n#define OBJ_ecdsa_with_Specified                OBJ_X9_62_id_ecSigType,3L\n\n#define SN_ecdsa_with_SHA224            \"ecdsa-with-SHA224\"\n#define NID_ecdsa_with_SHA224           793\n#define OBJ_ecdsa_with_SHA224           OBJ_ecdsa_with_Specified,1L\n\n#define SN_ecdsa_with_SHA256            \"ecdsa-with-SHA256\"\n#define NID_ecdsa_with_SHA256           794\n#define OBJ_ecdsa_with_SHA256           OBJ_ecdsa_with_Specified,2L\n\n#define SN_ecdsa_with_SHA384            \"ecdsa-with-SHA384\"\n#define NID_ecdsa_with_SHA384           795\n#define OBJ_ecdsa_with_SHA384           OBJ_ecdsa_with_Specified,3L\n\n#define SN_ecdsa_with_SHA512            \"ecdsa-with-SHA512\"\n#define NID_ecdsa_with_SHA512           796\n#define OBJ_ecdsa_with_SHA512           OBJ_ecdsa_with_Specified,4L\n\n#define OBJ_secg_ellipticCurve          OBJ_certicom_arc,0L\n\n#define SN_secp112r1            \"secp112r1\"\n#define NID_secp112r1           704\n#define OBJ_secp112r1           OBJ_secg_ellipticCurve,6L\n\n#define SN_secp112r2            \"secp112r2\"\n#define NID_secp112r2           705\n#define OBJ_secp112r2           OBJ_secg_ellipticCurve,7L\n\n#define SN_secp128r1            \"secp128r1\"\n#define NID_secp128r1           706\n#define OBJ_secp128r1           OBJ_secg_ellipticCurve,28L\n\n#define SN_secp128r2            \"secp128r2\"\n#define NID_secp128r2           707\n#define OBJ_secp128r2           OBJ_secg_ellipticCurve,29L\n\n#define SN_secp160k1            \"secp160k1\"\n#define NID_secp160k1           708\n#define OBJ_secp160k1           OBJ_secg_ellipticCurve,9L\n\n#define SN_secp160r1            \"secp160r1\"\n#define NID_secp160r1           709\n#define OBJ_secp160r1           OBJ_secg_ellipticCurve,8L\n\n#define SN_secp160r2            \"secp160r2\"\n#define NID_secp160r2           710\n#define OBJ_secp160r2           OBJ_secg_ellipticCurve,30L\n\n#define SN_secp192k1            \"secp192k1\"\n#define NID_secp192k1           711\n#define OBJ_secp192k1           OBJ_secg_ellipticCurve,31L\n\n#define SN_secp224k1            \"secp224k1\"\n#define NID_secp224k1           712\n#define OBJ_secp224k1           OBJ_secg_ellipticCurve,32L\n\n#define SN_secp224r1            \"secp224r1\"\n#define NID_secp224r1           713\n#define OBJ_secp224r1           OBJ_secg_ellipticCurve,33L\n\n#define SN_secp256k1            \"secp256k1\"\n#define NID_secp256k1           714\n#define OBJ_secp256k1           OBJ_secg_ellipticCurve,10L\n\n#define SN_secp384r1            \"secp384r1\"\n#define NID_secp384r1           715\n#define OBJ_secp384r1           OBJ_secg_ellipticCurve,34L\n\n#define SN_secp521r1            \"secp521r1\"\n#define NID_secp521r1           716\n#define OBJ_secp521r1           OBJ_secg_ellipticCurve,35L\n\n#define SN_sect113r1            \"sect113r1\"\n#define NID_sect113r1           717\n#define OBJ_sect113r1           OBJ_secg_ellipticCurve,4L\n\n#define SN_sect113r2            \"sect113r2\"\n#define NID_sect113r2           718\n#define OBJ_sect113r2           OBJ_secg_ellipticCurve,5L\n\n#define SN_sect131r1            \"sect131r1\"\n#define NID_sect131r1           719\n#define OBJ_sect131r1           OBJ_secg_ellipticCurve,22L\n\n#define SN_sect131r2            \"sect131r2\"\n#define NID_sect131r2           720\n#define OBJ_sect131r2           OBJ_secg_ellipticCurve,23L\n\n#define SN_sect163k1            \"sect163k1\"\n#define NID_sect163k1           721\n#define OBJ_sect163k1           OBJ_secg_ellipticCurve,1L\n\n#define SN_sect163r1            \"sect163r1\"\n#define NID_sect163r1           722\n#define OBJ_sect163r1           OBJ_secg_ellipticCurve,2L\n\n#define SN_sect163r2            \"sect163r2\"\n#define NID_sect163r2           723\n#define OBJ_sect163r2           OBJ_secg_ellipticCurve,15L\n\n#define SN_sect193r1            \"sect193r1\"\n#define NID_sect193r1           724\n#define OBJ_sect193r1           OBJ_secg_ellipticCurve,24L\n\n#define SN_sect193r2            \"sect193r2\"\n#define NID_sect193r2           725\n#define OBJ_sect193r2           OBJ_secg_ellipticCurve,25L\n\n#define SN_sect233k1            \"sect233k1\"\n#define NID_sect233k1           726\n#define OBJ_sect233k1           OBJ_secg_ellipticCurve,26L\n\n#define SN_sect233r1            \"sect233r1\"\n#define NID_sect233r1           727\n#define OBJ_sect233r1           OBJ_secg_ellipticCurve,27L\n\n#define SN_sect239k1            \"sect239k1\"\n#define NID_sect239k1           728\n#define OBJ_sect239k1           OBJ_secg_ellipticCurve,3L\n\n#define SN_sect283k1            \"sect283k1\"\n#define NID_sect283k1           729\n#define OBJ_sect283k1           OBJ_secg_ellipticCurve,16L\n\n#define SN_sect283r1            \"sect283r1\"\n#define NID_sect283r1           730\n#define OBJ_sect283r1           OBJ_secg_ellipticCurve,17L\n\n#define SN_sect409k1            \"sect409k1\"\n#define NID_sect409k1           731\n#define OBJ_sect409k1           OBJ_secg_ellipticCurve,36L\n\n#define SN_sect409r1            \"sect409r1\"\n#define NID_sect409r1           732\n#define OBJ_sect409r1           OBJ_secg_ellipticCurve,37L\n\n#define SN_sect571k1            \"sect571k1\"\n#define NID_sect571k1           733\n#define OBJ_sect571k1           OBJ_secg_ellipticCurve,38L\n\n#define SN_sect571r1            \"sect571r1\"\n#define NID_sect571r1           734\n#define OBJ_sect571r1           OBJ_secg_ellipticCurve,39L\n\n#define OBJ_wap_wsg_idm_ecid            OBJ_wap_wsg,4L\n\n#define SN_wap_wsg_idm_ecid_wtls1               \"wap-wsg-idm-ecid-wtls1\"\n#define NID_wap_wsg_idm_ecid_wtls1              735\n#define OBJ_wap_wsg_idm_ecid_wtls1              OBJ_wap_wsg_idm_ecid,1L\n\n#define SN_wap_wsg_idm_ecid_wtls3               \"wap-wsg-idm-ecid-wtls3\"\n#define NID_wap_wsg_idm_ecid_wtls3              736\n#define OBJ_wap_wsg_idm_ecid_wtls3              OBJ_wap_wsg_idm_ecid,3L\n\n#define SN_wap_wsg_idm_ecid_wtls4               \"wap-wsg-idm-ecid-wtls4\"\n#define NID_wap_wsg_idm_ecid_wtls4              737\n#define OBJ_wap_wsg_idm_ecid_wtls4              OBJ_wap_wsg_idm_ecid,4L\n\n#define SN_wap_wsg_idm_ecid_wtls5               \"wap-wsg-idm-ecid-wtls5\"\n#define NID_wap_wsg_idm_ecid_wtls5              738\n#define OBJ_wap_wsg_idm_ecid_wtls5              OBJ_wap_wsg_idm_ecid,5L\n\n#define SN_wap_wsg_idm_ecid_wtls6               \"wap-wsg-idm-ecid-wtls6\"\n#define NID_wap_wsg_idm_ecid_wtls6              739\n#define OBJ_wap_wsg_idm_ecid_wtls6              OBJ_wap_wsg_idm_ecid,6L\n\n#define SN_wap_wsg_idm_ecid_wtls7               \"wap-wsg-idm-ecid-wtls7\"\n#define NID_wap_wsg_idm_ecid_wtls7              740\n#define OBJ_wap_wsg_idm_ecid_wtls7              OBJ_wap_wsg_idm_ecid,7L\n\n#define SN_wap_wsg_idm_ecid_wtls8               \"wap-wsg-idm-ecid-wtls8\"\n#define NID_wap_wsg_idm_ecid_wtls8              741\n#define OBJ_wap_wsg_idm_ecid_wtls8              OBJ_wap_wsg_idm_ecid,8L\n\n#define SN_wap_wsg_idm_ecid_wtls9               \"wap-wsg-idm-ecid-wtls9\"\n#define NID_wap_wsg_idm_ecid_wtls9              742\n#define OBJ_wap_wsg_idm_ecid_wtls9              OBJ_wap_wsg_idm_ecid,9L\n\n#define SN_wap_wsg_idm_ecid_wtls10              \"wap-wsg-idm-ecid-wtls10\"\n#define NID_wap_wsg_idm_ecid_wtls10             743\n#define OBJ_wap_wsg_idm_ecid_wtls10             OBJ_wap_wsg_idm_ecid,10L\n\n#define SN_wap_wsg_idm_ecid_wtls11              \"wap-wsg-idm-ecid-wtls11\"\n#define NID_wap_wsg_idm_ecid_wtls11             744\n#define OBJ_wap_wsg_idm_ecid_wtls11             OBJ_wap_wsg_idm_ecid,11L\n\n#define SN_wap_wsg_idm_ecid_wtls12              \"wap-wsg-idm-ecid-wtls12\"\n#define NID_wap_wsg_idm_ecid_wtls12             745\n#define OBJ_wap_wsg_idm_ecid_wtls12             OBJ_wap_wsg_idm_ecid,12L\n\n#define SN_cast5_cbc            \"CAST5-CBC\"\n#define LN_cast5_cbc            \"cast5-cbc\"\n#define NID_cast5_cbc           108\n#define OBJ_cast5_cbc           OBJ_ISO_US,113533L,7L,66L,10L\n\n#define SN_cast5_ecb            \"CAST5-ECB\"\n#define LN_cast5_ecb            \"cast5-ecb\"\n#define NID_cast5_ecb           109\n\n#define SN_cast5_cfb64          \"CAST5-CFB\"\n#define LN_cast5_cfb64          \"cast5-cfb\"\n#define NID_cast5_cfb64         110\n\n#define SN_cast5_ofb64          \"CAST5-OFB\"\n#define LN_cast5_ofb64          \"cast5-ofb\"\n#define NID_cast5_ofb64         111\n\n#define LN_pbeWithMD5AndCast5_CBC               \"pbeWithMD5AndCast5CBC\"\n#define NID_pbeWithMD5AndCast5_CBC              112\n#define OBJ_pbeWithMD5AndCast5_CBC              OBJ_ISO_US,113533L,7L,66L,12L\n\n#define SN_id_PasswordBasedMAC          \"id-PasswordBasedMAC\"\n#define LN_id_PasswordBasedMAC          \"password based MAC\"\n#define NID_id_PasswordBasedMAC         782\n#define OBJ_id_PasswordBasedMAC         OBJ_ISO_US,113533L,7L,66L,13L\n\n#define SN_id_DHBasedMac                \"id-DHBasedMac\"\n#define LN_id_DHBasedMac                \"Diffie-Hellman based MAC\"\n#define NID_id_DHBasedMac               783\n#define OBJ_id_DHBasedMac               OBJ_ISO_US,113533L,7L,66L,30L\n\n#define SN_rsadsi               \"rsadsi\"\n#define LN_rsadsi               \"RSA Data Security, Inc.\"\n#define NID_rsadsi              1\n#define OBJ_rsadsi              OBJ_ISO_US,113549L\n\n#define SN_pkcs         \"pkcs\"\n#define LN_pkcs         \"RSA Data Security, Inc. PKCS\"\n#define NID_pkcs                2\n#define OBJ_pkcs                OBJ_rsadsi,1L\n\n#define SN_pkcs1                \"pkcs1\"\n#define NID_pkcs1               186\n#define OBJ_pkcs1               OBJ_pkcs,1L\n\n#define LN_rsaEncryption                \"rsaEncryption\"\n#define NID_rsaEncryption               6\n#define OBJ_rsaEncryption               OBJ_pkcs1,1L\n\n#define SN_md2WithRSAEncryption         \"RSA-MD2\"\n#define LN_md2WithRSAEncryption         \"md2WithRSAEncryption\"\n#define NID_md2WithRSAEncryption                7\n#define OBJ_md2WithRSAEncryption                OBJ_pkcs1,2L\n\n#define SN_md4WithRSAEncryption         \"RSA-MD4\"\n#define LN_md4WithRSAEncryption         \"md4WithRSAEncryption\"\n#define NID_md4WithRSAEncryption                396\n#define OBJ_md4WithRSAEncryption                OBJ_pkcs1,3L\n\n#define SN_md5WithRSAEncryption         \"RSA-MD5\"\n#define LN_md5WithRSAEncryption         \"md5WithRSAEncryption\"\n#define NID_md5WithRSAEncryption                8\n#define OBJ_md5WithRSAEncryption                OBJ_pkcs1,4L\n\n#define SN_sha1WithRSAEncryption                \"RSA-SHA1\"\n#define LN_sha1WithRSAEncryption                \"sha1WithRSAEncryption\"\n#define NID_sha1WithRSAEncryption               65\n#define OBJ_sha1WithRSAEncryption               OBJ_pkcs1,5L\n\n#define SN_rsaesOaep            \"RSAES-OAEP\"\n#define LN_rsaesOaep            \"rsaesOaep\"\n#define NID_rsaesOaep           919\n#define OBJ_rsaesOaep           OBJ_pkcs1,7L\n\n#define SN_mgf1         \"MGF1\"\n#define LN_mgf1         \"mgf1\"\n#define NID_mgf1                911\n#define OBJ_mgf1                OBJ_pkcs1,8L\n\n#define SN_pSpecified           \"PSPECIFIED\"\n#define LN_pSpecified           \"pSpecified\"\n#define NID_pSpecified          935\n#define OBJ_pSpecified          OBJ_pkcs1,9L\n\n#define SN_rsassaPss            \"RSASSA-PSS\"\n#define LN_rsassaPss            \"rsassaPss\"\n#define NID_rsassaPss           912\n#define OBJ_rsassaPss           OBJ_pkcs1,10L\n\n#define SN_sha256WithRSAEncryption              \"RSA-SHA256\"\n#define LN_sha256WithRSAEncryption              \"sha256WithRSAEncryption\"\n#define NID_sha256WithRSAEncryption             668\n#define OBJ_sha256WithRSAEncryption             OBJ_pkcs1,11L\n\n#define SN_sha384WithRSAEncryption              \"RSA-SHA384\"\n#define LN_sha384WithRSAEncryption              \"sha384WithRSAEncryption\"\n#define NID_sha384WithRSAEncryption             669\n#define OBJ_sha384WithRSAEncryption             OBJ_pkcs1,12L\n\n#define SN_sha512WithRSAEncryption              \"RSA-SHA512\"\n#define LN_sha512WithRSAEncryption              \"sha512WithRSAEncryption\"\n#define NID_sha512WithRSAEncryption             670\n#define OBJ_sha512WithRSAEncryption             OBJ_pkcs1,13L\n\n#define SN_sha224WithRSAEncryption              \"RSA-SHA224\"\n#define LN_sha224WithRSAEncryption              \"sha224WithRSAEncryption\"\n#define NID_sha224WithRSAEncryption             671\n#define OBJ_sha224WithRSAEncryption             OBJ_pkcs1,14L\n\n#define SN_pkcs3                \"pkcs3\"\n#define NID_pkcs3               27\n#define OBJ_pkcs3               OBJ_pkcs,3L\n\n#define LN_dhKeyAgreement               \"dhKeyAgreement\"\n#define NID_dhKeyAgreement              28\n#define OBJ_dhKeyAgreement              OBJ_pkcs3,1L\n\n#define SN_pkcs5                \"pkcs5\"\n#define NID_pkcs5               187\n#define OBJ_pkcs5               OBJ_pkcs,5L\n\n#define SN_pbeWithMD2AndDES_CBC         \"PBE-MD2-DES\"\n#define LN_pbeWithMD2AndDES_CBC         \"pbeWithMD2AndDES-CBC\"\n#define NID_pbeWithMD2AndDES_CBC                9\n#define OBJ_pbeWithMD2AndDES_CBC                OBJ_pkcs5,1L\n\n#define SN_pbeWithMD5AndDES_CBC         \"PBE-MD5-DES\"\n#define LN_pbeWithMD5AndDES_CBC         \"pbeWithMD5AndDES-CBC\"\n#define NID_pbeWithMD5AndDES_CBC                10\n#define OBJ_pbeWithMD5AndDES_CBC                OBJ_pkcs5,3L\n\n#define SN_pbeWithMD2AndRC2_CBC         \"PBE-MD2-RC2-64\"\n#define LN_pbeWithMD2AndRC2_CBC         \"pbeWithMD2AndRC2-CBC\"\n#define NID_pbeWithMD2AndRC2_CBC                168\n#define OBJ_pbeWithMD2AndRC2_CBC                OBJ_pkcs5,4L\n\n#define SN_pbeWithMD5AndRC2_CBC         \"PBE-MD5-RC2-64\"\n#define LN_pbeWithMD5AndRC2_CBC         \"pbeWithMD5AndRC2-CBC\"\n#define NID_pbeWithMD5AndRC2_CBC                169\n#define OBJ_pbeWithMD5AndRC2_CBC                OBJ_pkcs5,6L\n\n#define SN_pbeWithSHA1AndDES_CBC                \"PBE-SHA1-DES\"\n#define LN_pbeWithSHA1AndDES_CBC                \"pbeWithSHA1AndDES-CBC\"\n#define NID_pbeWithSHA1AndDES_CBC               170\n#define OBJ_pbeWithSHA1AndDES_CBC               OBJ_pkcs5,10L\n\n#define SN_pbeWithSHA1AndRC2_CBC                \"PBE-SHA1-RC2-64\"\n#define LN_pbeWithSHA1AndRC2_CBC                \"pbeWithSHA1AndRC2-CBC\"\n#define NID_pbeWithSHA1AndRC2_CBC               68\n#define OBJ_pbeWithSHA1AndRC2_CBC               OBJ_pkcs5,11L\n\n#define LN_id_pbkdf2            \"PBKDF2\"\n#define NID_id_pbkdf2           69\n#define OBJ_id_pbkdf2           OBJ_pkcs5,12L\n\n#define LN_pbes2                \"PBES2\"\n#define NID_pbes2               161\n#define OBJ_pbes2               OBJ_pkcs5,13L\n\n#define LN_pbmac1               \"PBMAC1\"\n#define NID_pbmac1              162\n#define OBJ_pbmac1              OBJ_pkcs5,14L\n\n#define SN_pkcs7                \"pkcs7\"\n#define NID_pkcs7               20\n#define OBJ_pkcs7               OBJ_pkcs,7L\n\n#define LN_pkcs7_data           \"pkcs7-data\"\n#define NID_pkcs7_data          21\n#define OBJ_pkcs7_data          OBJ_pkcs7,1L\n\n#define LN_pkcs7_signed         \"pkcs7-signedData\"\n#define NID_pkcs7_signed                22\n#define OBJ_pkcs7_signed                OBJ_pkcs7,2L\n\n#define LN_pkcs7_enveloped              \"pkcs7-envelopedData\"\n#define NID_pkcs7_enveloped             23\n#define OBJ_pkcs7_enveloped             OBJ_pkcs7,3L\n\n#define LN_pkcs7_signedAndEnveloped             \"pkcs7-signedAndEnvelopedData\"\n#define NID_pkcs7_signedAndEnveloped            24\n#define OBJ_pkcs7_signedAndEnveloped            OBJ_pkcs7,4L\n\n#define LN_pkcs7_digest         \"pkcs7-digestData\"\n#define NID_pkcs7_digest                25\n#define OBJ_pkcs7_digest                OBJ_pkcs7,5L\n\n#define LN_pkcs7_encrypted              \"pkcs7-encryptedData\"\n#define NID_pkcs7_encrypted             26\n#define OBJ_pkcs7_encrypted             OBJ_pkcs7,6L\n\n#define SN_pkcs9                \"pkcs9\"\n#define NID_pkcs9               47\n#define OBJ_pkcs9               OBJ_pkcs,9L\n\n#define LN_pkcs9_emailAddress           \"emailAddress\"\n#define NID_pkcs9_emailAddress          48\n#define OBJ_pkcs9_emailAddress          OBJ_pkcs9,1L\n\n#define LN_pkcs9_unstructuredName               \"unstructuredName\"\n#define NID_pkcs9_unstructuredName              49\n#define OBJ_pkcs9_unstructuredName              OBJ_pkcs9,2L\n\n#define LN_pkcs9_contentType            \"contentType\"\n#define NID_pkcs9_contentType           50\n#define OBJ_pkcs9_contentType           OBJ_pkcs9,3L\n\n#define LN_pkcs9_messageDigest          \"messageDigest\"\n#define NID_pkcs9_messageDigest         51\n#define OBJ_pkcs9_messageDigest         OBJ_pkcs9,4L\n\n#define LN_pkcs9_signingTime            \"signingTime\"\n#define NID_pkcs9_signingTime           52\n#define OBJ_pkcs9_signingTime           OBJ_pkcs9,5L\n\n#define LN_pkcs9_countersignature               \"countersignature\"\n#define NID_pkcs9_countersignature              53\n#define OBJ_pkcs9_countersignature              OBJ_pkcs9,6L\n\n#define LN_pkcs9_challengePassword              \"challengePassword\"\n#define NID_pkcs9_challengePassword             54\n#define OBJ_pkcs9_challengePassword             OBJ_pkcs9,7L\n\n#define LN_pkcs9_unstructuredAddress            \"unstructuredAddress\"\n#define NID_pkcs9_unstructuredAddress           55\n#define OBJ_pkcs9_unstructuredAddress           OBJ_pkcs9,8L\n\n#define LN_pkcs9_extCertAttributes              \"extendedCertificateAttributes\"\n#define NID_pkcs9_extCertAttributes             56\n#define OBJ_pkcs9_extCertAttributes             OBJ_pkcs9,9L\n\n#define SN_ext_req              \"extReq\"\n#define LN_ext_req              \"Extension Request\"\n#define NID_ext_req             172\n#define OBJ_ext_req             OBJ_pkcs9,14L\n\n#define SN_SMIMECapabilities            \"SMIME-CAPS\"\n#define LN_SMIMECapabilities            \"S/MIME Capabilities\"\n#define NID_SMIMECapabilities           167\n#define OBJ_SMIMECapabilities           OBJ_pkcs9,15L\n\n#define SN_SMIME                \"SMIME\"\n#define LN_SMIME                \"S/MIME\"\n#define NID_SMIME               188\n#define OBJ_SMIME               OBJ_pkcs9,16L\n\n#define SN_id_smime_mod         \"id-smime-mod\"\n#define NID_id_smime_mod                189\n#define OBJ_id_smime_mod                OBJ_SMIME,0L\n\n#define SN_id_smime_ct          \"id-smime-ct\"\n#define NID_id_smime_ct         190\n#define OBJ_id_smime_ct         OBJ_SMIME,1L\n\n#define SN_id_smime_aa          \"id-smime-aa\"\n#define NID_id_smime_aa         191\n#define OBJ_id_smime_aa         OBJ_SMIME,2L\n\n#define SN_id_smime_alg         \"id-smime-alg\"\n#define NID_id_smime_alg                192\n#define OBJ_id_smime_alg                OBJ_SMIME,3L\n\n#define SN_id_smime_cd          \"id-smime-cd\"\n#define NID_id_smime_cd         193\n#define OBJ_id_smime_cd         OBJ_SMIME,4L\n\n#define SN_id_smime_spq         \"id-smime-spq\"\n#define NID_id_smime_spq                194\n#define OBJ_id_smime_spq                OBJ_SMIME,5L\n\n#define SN_id_smime_cti         \"id-smime-cti\"\n#define NID_id_smime_cti                195\n#define OBJ_id_smime_cti                OBJ_SMIME,6L\n\n#define SN_id_smime_mod_cms             \"id-smime-mod-cms\"\n#define NID_id_smime_mod_cms            196\n#define OBJ_id_smime_mod_cms            OBJ_id_smime_mod,1L\n\n#define SN_id_smime_mod_ess             \"id-smime-mod-ess\"\n#define NID_id_smime_mod_ess            197\n#define OBJ_id_smime_mod_ess            OBJ_id_smime_mod,2L\n\n#define SN_id_smime_mod_oid             \"id-smime-mod-oid\"\n#define NID_id_smime_mod_oid            198\n#define OBJ_id_smime_mod_oid            OBJ_id_smime_mod,3L\n\n#define SN_id_smime_mod_msg_v3          \"id-smime-mod-msg-v3\"\n#define NID_id_smime_mod_msg_v3         199\n#define OBJ_id_smime_mod_msg_v3         OBJ_id_smime_mod,4L\n\n#define SN_id_smime_mod_ets_eSignature_88               \"id-smime-mod-ets-eSignature-88\"\n#define NID_id_smime_mod_ets_eSignature_88              200\n#define OBJ_id_smime_mod_ets_eSignature_88              OBJ_id_smime_mod,5L\n\n#define SN_id_smime_mod_ets_eSignature_97               \"id-smime-mod-ets-eSignature-97\"\n#define NID_id_smime_mod_ets_eSignature_97              201\n#define OBJ_id_smime_mod_ets_eSignature_97              OBJ_id_smime_mod,6L\n\n#define SN_id_smime_mod_ets_eSigPolicy_88               \"id-smime-mod-ets-eSigPolicy-88\"\n#define NID_id_smime_mod_ets_eSigPolicy_88              202\n#define OBJ_id_smime_mod_ets_eSigPolicy_88              OBJ_id_smime_mod,7L\n\n#define SN_id_smime_mod_ets_eSigPolicy_97               \"id-smime-mod-ets-eSigPolicy-97\"\n#define NID_id_smime_mod_ets_eSigPolicy_97              203\n#define OBJ_id_smime_mod_ets_eSigPolicy_97              OBJ_id_smime_mod,8L\n\n#define SN_id_smime_ct_receipt          \"id-smime-ct-receipt\"\n#define NID_id_smime_ct_receipt         204\n#define OBJ_id_smime_ct_receipt         OBJ_id_smime_ct,1L\n\n#define SN_id_smime_ct_authData         \"id-smime-ct-authData\"\n#define NID_id_smime_ct_authData                205\n#define OBJ_id_smime_ct_authData                OBJ_id_smime_ct,2L\n\n#define SN_id_smime_ct_publishCert              \"id-smime-ct-publishCert\"\n#define NID_id_smime_ct_publishCert             206\n#define OBJ_id_smime_ct_publishCert             OBJ_id_smime_ct,3L\n\n#define SN_id_smime_ct_TSTInfo          \"id-smime-ct-TSTInfo\"\n#define NID_id_smime_ct_TSTInfo         207\n#define OBJ_id_smime_ct_TSTInfo         OBJ_id_smime_ct,4L\n\n#define SN_id_smime_ct_TDTInfo          \"id-smime-ct-TDTInfo\"\n#define NID_id_smime_ct_TDTInfo         208\n#define OBJ_id_smime_ct_TDTInfo         OBJ_id_smime_ct,5L\n\n#define SN_id_smime_ct_contentInfo              \"id-smime-ct-contentInfo\"\n#define NID_id_smime_ct_contentInfo             209\n#define OBJ_id_smime_ct_contentInfo             OBJ_id_smime_ct,6L\n\n#define SN_id_smime_ct_DVCSRequestData          \"id-smime-ct-DVCSRequestData\"\n#define NID_id_smime_ct_DVCSRequestData         210\n#define OBJ_id_smime_ct_DVCSRequestData         OBJ_id_smime_ct,7L\n\n#define SN_id_smime_ct_DVCSResponseData         \"id-smime-ct-DVCSResponseData\"\n#define NID_id_smime_ct_DVCSResponseData                211\n#define OBJ_id_smime_ct_DVCSResponseData                OBJ_id_smime_ct,8L\n\n#define SN_id_smime_ct_compressedData           \"id-smime-ct-compressedData\"\n#define NID_id_smime_ct_compressedData          786\n#define OBJ_id_smime_ct_compressedData          OBJ_id_smime_ct,9L\n\n#define SN_id_ct_asciiTextWithCRLF              \"id-ct-asciiTextWithCRLF\"\n#define NID_id_ct_asciiTextWithCRLF             787\n#define OBJ_id_ct_asciiTextWithCRLF             OBJ_id_smime_ct,27L\n\n#define SN_id_smime_aa_receiptRequest           \"id-smime-aa-receiptRequest\"\n#define NID_id_smime_aa_receiptRequest          212\n#define OBJ_id_smime_aa_receiptRequest          OBJ_id_smime_aa,1L\n\n#define SN_id_smime_aa_securityLabel            \"id-smime-aa-securityLabel\"\n#define NID_id_smime_aa_securityLabel           213\n#define OBJ_id_smime_aa_securityLabel           OBJ_id_smime_aa,2L\n\n#define SN_id_smime_aa_mlExpandHistory          \"id-smime-aa-mlExpandHistory\"\n#define NID_id_smime_aa_mlExpandHistory         214\n#define OBJ_id_smime_aa_mlExpandHistory         OBJ_id_smime_aa,3L\n\n#define SN_id_smime_aa_contentHint              \"id-smime-aa-contentHint\"\n#define NID_id_smime_aa_contentHint             215\n#define OBJ_id_smime_aa_contentHint             OBJ_id_smime_aa,4L\n\n#define SN_id_smime_aa_msgSigDigest             \"id-smime-aa-msgSigDigest\"\n#define NID_id_smime_aa_msgSigDigest            216\n#define OBJ_id_smime_aa_msgSigDigest            OBJ_id_smime_aa,5L\n\n#define SN_id_smime_aa_encapContentType         \"id-smime-aa-encapContentType\"\n#define NID_id_smime_aa_encapContentType                217\n#define OBJ_id_smime_aa_encapContentType                OBJ_id_smime_aa,6L\n\n#define SN_id_smime_aa_contentIdentifier                \"id-smime-aa-contentIdentifier\"\n#define NID_id_smime_aa_contentIdentifier               218\n#define OBJ_id_smime_aa_contentIdentifier               OBJ_id_smime_aa,7L\n\n#define SN_id_smime_aa_macValue         \"id-smime-aa-macValue\"\n#define NID_id_smime_aa_macValue                219\n#define OBJ_id_smime_aa_macValue                OBJ_id_smime_aa,8L\n\n#define SN_id_smime_aa_equivalentLabels         \"id-smime-aa-equivalentLabels\"\n#define NID_id_smime_aa_equivalentLabels                220\n#define OBJ_id_smime_aa_equivalentLabels                OBJ_id_smime_aa,9L\n\n#define SN_id_smime_aa_contentReference         \"id-smime-aa-contentReference\"\n#define NID_id_smime_aa_contentReference                221\n#define OBJ_id_smime_aa_contentReference                OBJ_id_smime_aa,10L\n\n#define SN_id_smime_aa_encrypKeyPref            \"id-smime-aa-encrypKeyPref\"\n#define NID_id_smime_aa_encrypKeyPref           222\n#define OBJ_id_smime_aa_encrypKeyPref           OBJ_id_smime_aa,11L\n\n#define SN_id_smime_aa_signingCertificate               \"id-smime-aa-signingCertificate\"\n#define NID_id_smime_aa_signingCertificate              223\n#define OBJ_id_smime_aa_signingCertificate              OBJ_id_smime_aa,12L\n\n#define SN_id_smime_aa_smimeEncryptCerts                \"id-smime-aa-smimeEncryptCerts\"\n#define NID_id_smime_aa_smimeEncryptCerts               224\n#define OBJ_id_smime_aa_smimeEncryptCerts               OBJ_id_smime_aa,13L\n\n#define SN_id_smime_aa_timeStampToken           \"id-smime-aa-timeStampToken\"\n#define NID_id_smime_aa_timeStampToken          225\n#define OBJ_id_smime_aa_timeStampToken          OBJ_id_smime_aa,14L\n\n#define SN_id_smime_aa_ets_sigPolicyId          \"id-smime-aa-ets-sigPolicyId\"\n#define NID_id_smime_aa_ets_sigPolicyId         226\n#define OBJ_id_smime_aa_ets_sigPolicyId         OBJ_id_smime_aa,15L\n\n#define SN_id_smime_aa_ets_commitmentType               \"id-smime-aa-ets-commitmentType\"\n#define NID_id_smime_aa_ets_commitmentType              227\n#define OBJ_id_smime_aa_ets_commitmentType              OBJ_id_smime_aa,16L\n\n#define SN_id_smime_aa_ets_signerLocation               \"id-smime-aa-ets-signerLocation\"\n#define NID_id_smime_aa_ets_signerLocation              228\n#define OBJ_id_smime_aa_ets_signerLocation              OBJ_id_smime_aa,17L\n\n#define SN_id_smime_aa_ets_signerAttr           \"id-smime-aa-ets-signerAttr\"\n#define NID_id_smime_aa_ets_signerAttr          229\n#define OBJ_id_smime_aa_ets_signerAttr          OBJ_id_smime_aa,18L\n\n#define SN_id_smime_aa_ets_otherSigCert         \"id-smime-aa-ets-otherSigCert\"\n#define NID_id_smime_aa_ets_otherSigCert                230\n#define OBJ_id_smime_aa_ets_otherSigCert                OBJ_id_smime_aa,19L\n\n#define SN_id_smime_aa_ets_contentTimestamp             \"id-smime-aa-ets-contentTimestamp\"\n#define NID_id_smime_aa_ets_contentTimestamp            231\n#define OBJ_id_smime_aa_ets_contentTimestamp            OBJ_id_smime_aa,20L\n\n#define SN_id_smime_aa_ets_CertificateRefs              \"id-smime-aa-ets-CertificateRefs\"\n#define NID_id_smime_aa_ets_CertificateRefs             232\n#define OBJ_id_smime_aa_ets_CertificateRefs             OBJ_id_smime_aa,21L\n\n#define SN_id_smime_aa_ets_RevocationRefs               \"id-smime-aa-ets-RevocationRefs\"\n#define NID_id_smime_aa_ets_RevocationRefs              233\n#define OBJ_id_smime_aa_ets_RevocationRefs              OBJ_id_smime_aa,22L\n\n#define SN_id_smime_aa_ets_certValues           \"id-smime-aa-ets-certValues\"\n#define NID_id_smime_aa_ets_certValues          234\n#define OBJ_id_smime_aa_ets_certValues          OBJ_id_smime_aa,23L\n\n#define SN_id_smime_aa_ets_revocationValues             \"id-smime-aa-ets-revocationValues\"\n#define NID_id_smime_aa_ets_revocationValues            235\n#define OBJ_id_smime_aa_ets_revocationValues            OBJ_id_smime_aa,24L\n\n#define SN_id_smime_aa_ets_escTimeStamp         \"id-smime-aa-ets-escTimeStamp\"\n#define NID_id_smime_aa_ets_escTimeStamp                236\n#define OBJ_id_smime_aa_ets_escTimeStamp                OBJ_id_smime_aa,25L\n\n#define SN_id_smime_aa_ets_certCRLTimestamp             \"id-smime-aa-ets-certCRLTimestamp\"\n#define NID_id_smime_aa_ets_certCRLTimestamp            237\n#define OBJ_id_smime_aa_ets_certCRLTimestamp            OBJ_id_smime_aa,26L\n\n#define SN_id_smime_aa_ets_archiveTimeStamp             \"id-smime-aa-ets-archiveTimeStamp\"\n#define NID_id_smime_aa_ets_archiveTimeStamp            238\n#define OBJ_id_smime_aa_ets_archiveTimeStamp            OBJ_id_smime_aa,27L\n\n#define SN_id_smime_aa_signatureType            \"id-smime-aa-signatureType\"\n#define NID_id_smime_aa_signatureType           239\n#define OBJ_id_smime_aa_signatureType           OBJ_id_smime_aa,28L\n\n#define SN_id_smime_aa_dvcs_dvc         \"id-smime-aa-dvcs-dvc\"\n#define NID_id_smime_aa_dvcs_dvc                240\n#define OBJ_id_smime_aa_dvcs_dvc                OBJ_id_smime_aa,29L\n\n#define SN_id_smime_alg_ESDHwith3DES            \"id-smime-alg-ESDHwith3DES\"\n#define NID_id_smime_alg_ESDHwith3DES           241\n#define OBJ_id_smime_alg_ESDHwith3DES           OBJ_id_smime_alg,1L\n\n#define SN_id_smime_alg_ESDHwithRC2             \"id-smime-alg-ESDHwithRC2\"\n#define NID_id_smime_alg_ESDHwithRC2            242\n#define OBJ_id_smime_alg_ESDHwithRC2            OBJ_id_smime_alg,2L\n\n#define SN_id_smime_alg_3DESwrap                \"id-smime-alg-3DESwrap\"\n#define NID_id_smime_alg_3DESwrap               243\n#define OBJ_id_smime_alg_3DESwrap               OBJ_id_smime_alg,3L\n\n#define SN_id_smime_alg_RC2wrap         \"id-smime-alg-RC2wrap\"\n#define NID_id_smime_alg_RC2wrap                244\n#define OBJ_id_smime_alg_RC2wrap                OBJ_id_smime_alg,4L\n\n#define SN_id_smime_alg_ESDH            \"id-smime-alg-ESDH\"\n#define NID_id_smime_alg_ESDH           245\n#define OBJ_id_smime_alg_ESDH           OBJ_id_smime_alg,5L\n\n#define SN_id_smime_alg_CMS3DESwrap             \"id-smime-alg-CMS3DESwrap\"\n#define NID_id_smime_alg_CMS3DESwrap            246\n#define OBJ_id_smime_alg_CMS3DESwrap            OBJ_id_smime_alg,6L\n\n#define SN_id_smime_alg_CMSRC2wrap              \"id-smime-alg-CMSRC2wrap\"\n#define NID_id_smime_alg_CMSRC2wrap             247\n#define OBJ_id_smime_alg_CMSRC2wrap             OBJ_id_smime_alg,7L\n\n#define SN_id_alg_PWRI_KEK              \"id-alg-PWRI-KEK\"\n#define NID_id_alg_PWRI_KEK             893\n#define OBJ_id_alg_PWRI_KEK             OBJ_id_smime_alg,9L\n\n#define SN_id_smime_cd_ldap             \"id-smime-cd-ldap\"\n#define NID_id_smime_cd_ldap            248\n#define OBJ_id_smime_cd_ldap            OBJ_id_smime_cd,1L\n\n#define SN_id_smime_spq_ets_sqt_uri             \"id-smime-spq-ets-sqt-uri\"\n#define NID_id_smime_spq_ets_sqt_uri            249\n#define OBJ_id_smime_spq_ets_sqt_uri            OBJ_id_smime_spq,1L\n\n#define SN_id_smime_spq_ets_sqt_unotice         \"id-smime-spq-ets-sqt-unotice\"\n#define NID_id_smime_spq_ets_sqt_unotice                250\n#define OBJ_id_smime_spq_ets_sqt_unotice                OBJ_id_smime_spq,2L\n\n#define SN_id_smime_cti_ets_proofOfOrigin               \"id-smime-cti-ets-proofOfOrigin\"\n#define NID_id_smime_cti_ets_proofOfOrigin              251\n#define OBJ_id_smime_cti_ets_proofOfOrigin              OBJ_id_smime_cti,1L\n\n#define SN_id_smime_cti_ets_proofOfReceipt              \"id-smime-cti-ets-proofOfReceipt\"\n#define NID_id_smime_cti_ets_proofOfReceipt             252\n#define OBJ_id_smime_cti_ets_proofOfReceipt             OBJ_id_smime_cti,2L\n\n#define SN_id_smime_cti_ets_proofOfDelivery             \"id-smime-cti-ets-proofOfDelivery\"\n#define NID_id_smime_cti_ets_proofOfDelivery            253\n#define OBJ_id_smime_cti_ets_proofOfDelivery            OBJ_id_smime_cti,3L\n\n#define SN_id_smime_cti_ets_proofOfSender               \"id-smime-cti-ets-proofOfSender\"\n#define NID_id_smime_cti_ets_proofOfSender              254\n#define OBJ_id_smime_cti_ets_proofOfSender              OBJ_id_smime_cti,4L\n\n#define SN_id_smime_cti_ets_proofOfApproval             \"id-smime-cti-ets-proofOfApproval\"\n#define NID_id_smime_cti_ets_proofOfApproval            255\n#define OBJ_id_smime_cti_ets_proofOfApproval            OBJ_id_smime_cti,5L\n\n#define SN_id_smime_cti_ets_proofOfCreation             \"id-smime-cti-ets-proofOfCreation\"\n#define NID_id_smime_cti_ets_proofOfCreation            256\n#define OBJ_id_smime_cti_ets_proofOfCreation            OBJ_id_smime_cti,6L\n\n#define LN_friendlyName         \"friendlyName\"\n#define NID_friendlyName                156\n#define OBJ_friendlyName                OBJ_pkcs9,20L\n\n#define LN_localKeyID           \"localKeyID\"\n#define NID_localKeyID          157\n#define OBJ_localKeyID          OBJ_pkcs9,21L\n\n#define SN_ms_csp_name          \"CSPName\"\n#define LN_ms_csp_name          \"Microsoft CSP Name\"\n#define NID_ms_csp_name         417\n#define OBJ_ms_csp_name         1L,3L,6L,1L,4L,1L,311L,17L,1L\n\n#define SN_LocalKeySet          \"LocalKeySet\"\n#define LN_LocalKeySet          \"Microsoft Local Key set\"\n#define NID_LocalKeySet         856\n#define OBJ_LocalKeySet         1L,3L,6L,1L,4L,1L,311L,17L,2L\n\n#define OBJ_certTypes           OBJ_pkcs9,22L\n\n#define LN_x509Certificate              \"x509Certificate\"\n#define NID_x509Certificate             158\n#define OBJ_x509Certificate             OBJ_certTypes,1L\n\n#define LN_sdsiCertificate              \"sdsiCertificate\"\n#define NID_sdsiCertificate             159\n#define OBJ_sdsiCertificate             OBJ_certTypes,2L\n\n#define OBJ_crlTypes            OBJ_pkcs9,23L\n\n#define LN_x509Crl              \"x509Crl\"\n#define NID_x509Crl             160\n#define OBJ_x509Crl             OBJ_crlTypes,1L\n\n#define OBJ_pkcs12              OBJ_pkcs,12L\n\n#define OBJ_pkcs12_pbeids               OBJ_pkcs12,1L\n\n#define SN_pbe_WithSHA1And128BitRC4             \"PBE-SHA1-RC4-128\"\n#define LN_pbe_WithSHA1And128BitRC4             \"pbeWithSHA1And128BitRC4\"\n#define NID_pbe_WithSHA1And128BitRC4            144\n#define OBJ_pbe_WithSHA1And128BitRC4            OBJ_pkcs12_pbeids,1L\n\n#define SN_pbe_WithSHA1And40BitRC4              \"PBE-SHA1-RC4-40\"\n#define LN_pbe_WithSHA1And40BitRC4              \"pbeWithSHA1And40BitRC4\"\n#define NID_pbe_WithSHA1And40BitRC4             145\n#define OBJ_pbe_WithSHA1And40BitRC4             OBJ_pkcs12_pbeids,2L\n\n#define SN_pbe_WithSHA1And3_Key_TripleDES_CBC           \"PBE-SHA1-3DES\"\n#define LN_pbe_WithSHA1And3_Key_TripleDES_CBC           \"pbeWithSHA1And3-KeyTripleDES-CBC\"\n#define NID_pbe_WithSHA1And3_Key_TripleDES_CBC          146\n#define OBJ_pbe_WithSHA1And3_Key_TripleDES_CBC          OBJ_pkcs12_pbeids,3L\n\n#define SN_pbe_WithSHA1And2_Key_TripleDES_CBC           \"PBE-SHA1-2DES\"\n#define LN_pbe_WithSHA1And2_Key_TripleDES_CBC           \"pbeWithSHA1And2-KeyTripleDES-CBC\"\n#define NID_pbe_WithSHA1And2_Key_TripleDES_CBC          147\n#define OBJ_pbe_WithSHA1And2_Key_TripleDES_CBC          OBJ_pkcs12_pbeids,4L\n\n#define SN_pbe_WithSHA1And128BitRC2_CBC         \"PBE-SHA1-RC2-128\"\n#define LN_pbe_WithSHA1And128BitRC2_CBC         \"pbeWithSHA1And128BitRC2-CBC\"\n#define NID_pbe_WithSHA1And128BitRC2_CBC                148\n#define OBJ_pbe_WithSHA1And128BitRC2_CBC                OBJ_pkcs12_pbeids,5L\n\n#define SN_pbe_WithSHA1And40BitRC2_CBC          \"PBE-SHA1-RC2-40\"\n#define LN_pbe_WithSHA1And40BitRC2_CBC          \"pbeWithSHA1And40BitRC2-CBC\"\n#define NID_pbe_WithSHA1And40BitRC2_CBC         149\n#define OBJ_pbe_WithSHA1And40BitRC2_CBC         OBJ_pkcs12_pbeids,6L\n\n#define OBJ_pkcs12_Version1             OBJ_pkcs12,10L\n\n#define OBJ_pkcs12_BagIds               OBJ_pkcs12_Version1,1L\n\n#define LN_keyBag               \"keyBag\"\n#define NID_keyBag              150\n#define OBJ_keyBag              OBJ_pkcs12_BagIds,1L\n\n#define LN_pkcs8ShroudedKeyBag          \"pkcs8ShroudedKeyBag\"\n#define NID_pkcs8ShroudedKeyBag         151\n#define OBJ_pkcs8ShroudedKeyBag         OBJ_pkcs12_BagIds,2L\n\n#define LN_certBag              \"certBag\"\n#define NID_certBag             152\n#define OBJ_certBag             OBJ_pkcs12_BagIds,3L\n\n#define LN_crlBag               \"crlBag\"\n#define NID_crlBag              153\n#define OBJ_crlBag              OBJ_pkcs12_BagIds,4L\n\n#define LN_secretBag            \"secretBag\"\n#define NID_secretBag           154\n#define OBJ_secretBag           OBJ_pkcs12_BagIds,5L\n\n#define LN_safeContentsBag              \"safeContentsBag\"\n#define NID_safeContentsBag             155\n#define OBJ_safeContentsBag             OBJ_pkcs12_BagIds,6L\n\n#define SN_md2          \"MD2\"\n#define LN_md2          \"md2\"\n#define NID_md2         3\n#define OBJ_md2         OBJ_rsadsi,2L,2L\n\n#define SN_md4          \"MD4\"\n#define LN_md4          \"md4\"\n#define NID_md4         257\n#define OBJ_md4         OBJ_rsadsi,2L,4L\n\n#define SN_md5          \"MD5\"\n#define LN_md5          \"md5\"\n#define NID_md5         4\n#define OBJ_md5         OBJ_rsadsi,2L,5L\n\n#define SN_md5_sha1             \"MD5-SHA1\"\n#define LN_md5_sha1             \"md5-sha1\"\n#define NID_md5_sha1            114\n\n#define LN_hmacWithMD5          \"hmacWithMD5\"\n#define NID_hmacWithMD5         797\n#define OBJ_hmacWithMD5         OBJ_rsadsi,2L,6L\n\n#define LN_hmacWithSHA1         \"hmacWithSHA1\"\n#define NID_hmacWithSHA1                163\n#define OBJ_hmacWithSHA1                OBJ_rsadsi,2L,7L\n\n#define LN_hmacWithSHA224               \"hmacWithSHA224\"\n#define NID_hmacWithSHA224              798\n#define OBJ_hmacWithSHA224              OBJ_rsadsi,2L,8L\n\n#define LN_hmacWithSHA256               \"hmacWithSHA256\"\n#define NID_hmacWithSHA256              799\n#define OBJ_hmacWithSHA256              OBJ_rsadsi,2L,9L\n\n#define LN_hmacWithSHA384               \"hmacWithSHA384\"\n#define NID_hmacWithSHA384              800\n#define OBJ_hmacWithSHA384              OBJ_rsadsi,2L,10L\n\n#define LN_hmacWithSHA512               \"hmacWithSHA512\"\n#define NID_hmacWithSHA512              801\n#define OBJ_hmacWithSHA512              OBJ_rsadsi,2L,11L\n\n#define SN_rc2_cbc              \"RC2-CBC\"\n#define LN_rc2_cbc              \"rc2-cbc\"\n#define NID_rc2_cbc             37\n#define OBJ_rc2_cbc             OBJ_rsadsi,3L,2L\n\n#define SN_rc2_ecb              \"RC2-ECB\"\n#define LN_rc2_ecb              \"rc2-ecb\"\n#define NID_rc2_ecb             38\n\n#define SN_rc2_cfb64            \"RC2-CFB\"\n#define LN_rc2_cfb64            \"rc2-cfb\"\n#define NID_rc2_cfb64           39\n\n#define SN_rc2_ofb64            \"RC2-OFB\"\n#define LN_rc2_ofb64            \"rc2-ofb\"\n#define NID_rc2_ofb64           40\n\n#define SN_rc2_40_cbc           \"RC2-40-CBC\"\n#define LN_rc2_40_cbc           \"rc2-40-cbc\"\n#define NID_rc2_40_cbc          98\n\n#define SN_rc2_64_cbc           \"RC2-64-CBC\"\n#define LN_rc2_64_cbc           \"rc2-64-cbc\"\n#define NID_rc2_64_cbc          166\n\n#define SN_rc4          \"RC4\"\n#define LN_rc4          \"rc4\"\n#define NID_rc4         5\n#define OBJ_rc4         OBJ_rsadsi,3L,4L\n\n#define SN_rc4_40               \"RC4-40\"\n#define LN_rc4_40               \"rc4-40\"\n#define NID_rc4_40              97\n\n#define SN_des_ede3_cbc         \"DES-EDE3-CBC\"\n#define LN_des_ede3_cbc         \"des-ede3-cbc\"\n#define NID_des_ede3_cbc                44\n#define OBJ_des_ede3_cbc                OBJ_rsadsi,3L,7L\n\n#define SN_rc5_cbc              \"RC5-CBC\"\n#define LN_rc5_cbc              \"rc5-cbc\"\n#define NID_rc5_cbc             120\n#define OBJ_rc5_cbc             OBJ_rsadsi,3L,8L\n\n#define SN_rc5_ecb              \"RC5-ECB\"\n#define LN_rc5_ecb              \"rc5-ecb\"\n#define NID_rc5_ecb             121\n\n#define SN_rc5_cfb64            \"RC5-CFB\"\n#define LN_rc5_cfb64            \"rc5-cfb\"\n#define NID_rc5_cfb64           122\n\n#define SN_rc5_ofb64            \"RC5-OFB\"\n#define LN_rc5_ofb64            \"rc5-ofb\"\n#define NID_rc5_ofb64           123\n\n#define SN_ms_ext_req           \"msExtReq\"\n#define LN_ms_ext_req           \"Microsoft Extension Request\"\n#define NID_ms_ext_req          171\n#define OBJ_ms_ext_req          1L,3L,6L,1L,4L,1L,311L,2L,1L,14L\n\n#define SN_ms_code_ind          \"msCodeInd\"\n#define LN_ms_code_ind          \"Microsoft Individual Code Signing\"\n#define NID_ms_code_ind         134\n#define OBJ_ms_code_ind         1L,3L,6L,1L,4L,1L,311L,2L,1L,21L\n\n#define SN_ms_code_com          \"msCodeCom\"\n#define LN_ms_code_com          \"Microsoft Commercial Code Signing\"\n#define NID_ms_code_com         135\n#define OBJ_ms_code_com         1L,3L,6L,1L,4L,1L,311L,2L,1L,22L\n\n#define SN_ms_ctl_sign          \"msCTLSign\"\n#define LN_ms_ctl_sign          \"Microsoft Trust List Signing\"\n#define NID_ms_ctl_sign         136\n#define OBJ_ms_ctl_sign         1L,3L,6L,1L,4L,1L,311L,10L,3L,1L\n\n#define SN_ms_sgc               \"msSGC\"\n#define LN_ms_sgc               \"Microsoft Server Gated Crypto\"\n#define NID_ms_sgc              137\n#define OBJ_ms_sgc              1L,3L,6L,1L,4L,1L,311L,10L,3L,3L\n\n#define SN_ms_efs               \"msEFS\"\n#define LN_ms_efs               \"Microsoft Encrypted File System\"\n#define NID_ms_efs              138\n#define OBJ_ms_efs              1L,3L,6L,1L,4L,1L,311L,10L,3L,4L\n\n#define SN_ms_smartcard_login           \"msSmartcardLogin\"\n#define LN_ms_smartcard_login           \"Microsoft Smartcardlogin\"\n#define NID_ms_smartcard_login          648\n#define OBJ_ms_smartcard_login          1L,3L,6L,1L,4L,1L,311L,20L,2L,2L\n\n#define SN_ms_upn               \"msUPN\"\n#define LN_ms_upn               \"Microsoft Universal Principal Name\"\n#define NID_ms_upn              649\n#define OBJ_ms_upn              1L,3L,6L,1L,4L,1L,311L,20L,2L,3L\n\n#define SN_idea_cbc             \"IDEA-CBC\"\n#define LN_idea_cbc             \"idea-cbc\"\n#define NID_idea_cbc            34\n#define OBJ_idea_cbc            1L,3L,6L,1L,4L,1L,188L,7L,1L,1L,2L\n\n#define SN_idea_ecb             \"IDEA-ECB\"\n#define LN_idea_ecb             \"idea-ecb\"\n#define NID_idea_ecb            36\n\n#define SN_idea_cfb64           \"IDEA-CFB\"\n#define LN_idea_cfb64           \"idea-cfb\"\n#define NID_idea_cfb64          35\n\n#define SN_idea_ofb64           \"IDEA-OFB\"\n#define LN_idea_ofb64           \"idea-ofb\"\n#define NID_idea_ofb64          46\n\n#define SN_bf_cbc               \"BF-CBC\"\n#define LN_bf_cbc               \"bf-cbc\"\n#define NID_bf_cbc              91\n#define OBJ_bf_cbc              1L,3L,6L,1L,4L,1L,3029L,1L,2L\n\n#define SN_bf_ecb               \"BF-ECB\"\n#define LN_bf_ecb               \"bf-ecb\"\n#define NID_bf_ecb              92\n\n#define SN_bf_cfb64             \"BF-CFB\"\n#define LN_bf_cfb64             \"bf-cfb\"\n#define NID_bf_cfb64            93\n\n#define SN_bf_ofb64             \"BF-OFB\"\n#define LN_bf_ofb64             \"bf-ofb\"\n#define NID_bf_ofb64            94\n\n#define SN_id_pkix              \"PKIX\"\n#define NID_id_pkix             127\n#define OBJ_id_pkix             1L,3L,6L,1L,5L,5L,7L\n\n#define SN_id_pkix_mod          \"id-pkix-mod\"\n#define NID_id_pkix_mod         258\n#define OBJ_id_pkix_mod         OBJ_id_pkix,0L\n\n#define SN_id_pe                \"id-pe\"\n#define NID_id_pe               175\n#define OBJ_id_pe               OBJ_id_pkix,1L\n\n#define SN_id_qt                \"id-qt\"\n#define NID_id_qt               259\n#define OBJ_id_qt               OBJ_id_pkix,2L\n\n#define SN_id_kp                \"id-kp\"\n#define NID_id_kp               128\n#define OBJ_id_kp               OBJ_id_pkix,3L\n\n#define SN_id_it                \"id-it\"\n#define NID_id_it               260\n#define OBJ_id_it               OBJ_id_pkix,4L\n\n#define SN_id_pkip              \"id-pkip\"\n#define NID_id_pkip             261\n#define OBJ_id_pkip             OBJ_id_pkix,5L\n\n#define SN_id_alg               \"id-alg\"\n#define NID_id_alg              262\n#define OBJ_id_alg              OBJ_id_pkix,6L\n\n#define SN_id_cmc               \"id-cmc\"\n#define NID_id_cmc              263\n#define OBJ_id_cmc              OBJ_id_pkix,7L\n\n#define SN_id_on                \"id-on\"\n#define NID_id_on               264\n#define OBJ_id_on               OBJ_id_pkix,8L\n\n#define SN_id_pda               \"id-pda\"\n#define NID_id_pda              265\n#define OBJ_id_pda              OBJ_id_pkix,9L\n\n#define SN_id_aca               \"id-aca\"\n#define NID_id_aca              266\n#define OBJ_id_aca              OBJ_id_pkix,10L\n\n#define SN_id_qcs               \"id-qcs\"\n#define NID_id_qcs              267\n#define OBJ_id_qcs              OBJ_id_pkix,11L\n\n#define SN_id_cct               \"id-cct\"\n#define NID_id_cct              268\n#define OBJ_id_cct              OBJ_id_pkix,12L\n\n#define SN_id_ppl               \"id-ppl\"\n#define NID_id_ppl              662\n#define OBJ_id_ppl              OBJ_id_pkix,21L\n\n#define SN_id_ad                \"id-ad\"\n#define NID_id_ad               176\n#define OBJ_id_ad               OBJ_id_pkix,48L\n\n#define SN_id_pkix1_explicit_88         \"id-pkix1-explicit-88\"\n#define NID_id_pkix1_explicit_88                269\n#define OBJ_id_pkix1_explicit_88                OBJ_id_pkix_mod,1L\n\n#define SN_id_pkix1_implicit_88         \"id-pkix1-implicit-88\"\n#define NID_id_pkix1_implicit_88                270\n#define OBJ_id_pkix1_implicit_88                OBJ_id_pkix_mod,2L\n\n#define SN_id_pkix1_explicit_93         \"id-pkix1-explicit-93\"\n#define NID_id_pkix1_explicit_93                271\n#define OBJ_id_pkix1_explicit_93                OBJ_id_pkix_mod,3L\n\n#define SN_id_pkix1_implicit_93         \"id-pkix1-implicit-93\"\n#define NID_id_pkix1_implicit_93                272\n#define OBJ_id_pkix1_implicit_93                OBJ_id_pkix_mod,4L\n\n#define SN_id_mod_crmf          \"id-mod-crmf\"\n#define NID_id_mod_crmf         273\n#define OBJ_id_mod_crmf         OBJ_id_pkix_mod,5L\n\n#define SN_id_mod_cmc           \"id-mod-cmc\"\n#define NID_id_mod_cmc          274\n#define OBJ_id_mod_cmc          OBJ_id_pkix_mod,6L\n\n#define SN_id_mod_kea_profile_88                \"id-mod-kea-profile-88\"\n#define NID_id_mod_kea_profile_88               275\n#define OBJ_id_mod_kea_profile_88               OBJ_id_pkix_mod,7L\n\n#define SN_id_mod_kea_profile_93                \"id-mod-kea-profile-93\"\n#define NID_id_mod_kea_profile_93               276\n#define OBJ_id_mod_kea_profile_93               OBJ_id_pkix_mod,8L\n\n#define SN_id_mod_cmp           \"id-mod-cmp\"\n#define NID_id_mod_cmp          277\n#define OBJ_id_mod_cmp          OBJ_id_pkix_mod,9L\n\n#define SN_id_mod_qualified_cert_88             \"id-mod-qualified-cert-88\"\n#define NID_id_mod_qualified_cert_88            278\n#define OBJ_id_mod_qualified_cert_88            OBJ_id_pkix_mod,10L\n\n#define SN_id_mod_qualified_cert_93             \"id-mod-qualified-cert-93\"\n#define NID_id_mod_qualified_cert_93            279\n#define OBJ_id_mod_qualified_cert_93            OBJ_id_pkix_mod,11L\n\n#define SN_id_mod_attribute_cert                \"id-mod-attribute-cert\"\n#define NID_id_mod_attribute_cert               280\n#define OBJ_id_mod_attribute_cert               OBJ_id_pkix_mod,12L\n\n#define SN_id_mod_timestamp_protocol            \"id-mod-timestamp-protocol\"\n#define NID_id_mod_timestamp_protocol           281\n#define OBJ_id_mod_timestamp_protocol           OBJ_id_pkix_mod,13L\n\n#define SN_id_mod_ocsp          \"id-mod-ocsp\"\n#define NID_id_mod_ocsp         282\n#define OBJ_id_mod_ocsp         OBJ_id_pkix_mod,14L\n\n#define SN_id_mod_dvcs          \"id-mod-dvcs\"\n#define NID_id_mod_dvcs         283\n#define OBJ_id_mod_dvcs         OBJ_id_pkix_mod,15L\n\n#define SN_id_mod_cmp2000               \"id-mod-cmp2000\"\n#define NID_id_mod_cmp2000              284\n#define OBJ_id_mod_cmp2000              OBJ_id_pkix_mod,16L\n\n#define SN_info_access          \"authorityInfoAccess\"\n#define LN_info_access          \"Authority Information Access\"\n#define NID_info_access         177\n#define OBJ_info_access         OBJ_id_pe,1L\n\n#define SN_biometricInfo                \"biometricInfo\"\n#define LN_biometricInfo                \"Biometric Info\"\n#define NID_biometricInfo               285\n#define OBJ_biometricInfo               OBJ_id_pe,2L\n\n#define SN_qcStatements         \"qcStatements\"\n#define NID_qcStatements                286\n#define OBJ_qcStatements                OBJ_id_pe,3L\n\n#define SN_ac_auditEntity               \"ac-auditEntity\"\n#define NID_ac_auditEntity              287\n#define OBJ_ac_auditEntity              OBJ_id_pe,4L\n\n#define SN_ac_targeting         \"ac-targeting\"\n#define NID_ac_targeting                288\n#define OBJ_ac_targeting                OBJ_id_pe,5L\n\n#define SN_aaControls           \"aaControls\"\n#define NID_aaControls          289\n#define OBJ_aaControls          OBJ_id_pe,6L\n\n#define SN_sbgp_ipAddrBlock             \"sbgp-ipAddrBlock\"\n#define NID_sbgp_ipAddrBlock            290\n#define OBJ_sbgp_ipAddrBlock            OBJ_id_pe,7L\n\n#define SN_sbgp_autonomousSysNum                \"sbgp-autonomousSysNum\"\n#define NID_sbgp_autonomousSysNum               291\n#define OBJ_sbgp_autonomousSysNum               OBJ_id_pe,8L\n\n#define SN_sbgp_routerIdentifier                \"sbgp-routerIdentifier\"\n#define NID_sbgp_routerIdentifier               292\n#define OBJ_sbgp_routerIdentifier               OBJ_id_pe,9L\n\n#define SN_ac_proxying          \"ac-proxying\"\n#define NID_ac_proxying         397\n#define OBJ_ac_proxying         OBJ_id_pe,10L\n\n#define SN_sinfo_access         \"subjectInfoAccess\"\n#define LN_sinfo_access         \"Subject Information Access\"\n#define NID_sinfo_access                398\n#define OBJ_sinfo_access                OBJ_id_pe,11L\n\n#define SN_proxyCertInfo                \"proxyCertInfo\"\n#define LN_proxyCertInfo                \"Proxy Certificate Information\"\n#define NID_proxyCertInfo               663\n#define OBJ_proxyCertInfo               OBJ_id_pe,14L\n\n#define SN_id_qt_cps            \"id-qt-cps\"\n#define LN_id_qt_cps            \"Policy Qualifier CPS\"\n#define NID_id_qt_cps           164\n#define OBJ_id_qt_cps           OBJ_id_qt,1L\n\n#define SN_id_qt_unotice                \"id-qt-unotice\"\n#define LN_id_qt_unotice                \"Policy Qualifier User Notice\"\n#define NID_id_qt_unotice               165\n#define OBJ_id_qt_unotice               OBJ_id_qt,2L\n\n#define SN_textNotice           \"textNotice\"\n#define NID_textNotice          293\n#define OBJ_textNotice          OBJ_id_qt,3L\n\n#define SN_server_auth          \"serverAuth\"\n#define LN_server_auth          \"TLS Web Server Authentication\"\n#define NID_server_auth         129\n#define OBJ_server_auth         OBJ_id_kp,1L\n\n#define SN_client_auth          \"clientAuth\"\n#define LN_client_auth          \"TLS Web Client Authentication\"\n#define NID_client_auth         130\n#define OBJ_client_auth         OBJ_id_kp,2L\n\n#define SN_code_sign            \"codeSigning\"\n#define LN_code_sign            \"Code Signing\"\n#define NID_code_sign           131\n#define OBJ_code_sign           OBJ_id_kp,3L\n\n#define SN_email_protect                \"emailProtection\"\n#define LN_email_protect                \"E-mail Protection\"\n#define NID_email_protect               132\n#define OBJ_email_protect               OBJ_id_kp,4L\n\n#define SN_ipsecEndSystem               \"ipsecEndSystem\"\n#define LN_ipsecEndSystem               \"IPSec End System\"\n#define NID_ipsecEndSystem              294\n#define OBJ_ipsecEndSystem              OBJ_id_kp,5L\n\n#define SN_ipsecTunnel          \"ipsecTunnel\"\n#define LN_ipsecTunnel          \"IPSec Tunnel\"\n#define NID_ipsecTunnel         295\n#define OBJ_ipsecTunnel         OBJ_id_kp,6L\n\n#define SN_ipsecUser            \"ipsecUser\"\n#define LN_ipsecUser            \"IPSec User\"\n#define NID_ipsecUser           296\n#define OBJ_ipsecUser           OBJ_id_kp,7L\n\n#define SN_time_stamp           \"timeStamping\"\n#define LN_time_stamp           \"Time Stamping\"\n#define NID_time_stamp          133\n#define OBJ_time_stamp          OBJ_id_kp,8L\n\n#define SN_OCSP_sign            \"OCSPSigning\"\n#define LN_OCSP_sign            \"OCSP Signing\"\n#define NID_OCSP_sign           180\n#define OBJ_OCSP_sign           OBJ_id_kp,9L\n\n#define SN_dvcs         \"DVCS\"\n#define LN_dvcs         \"dvcs\"\n#define NID_dvcs                297\n#define OBJ_dvcs                OBJ_id_kp,10L\n\n#define SN_id_it_caProtEncCert          \"id-it-caProtEncCert\"\n#define NID_id_it_caProtEncCert         298\n#define OBJ_id_it_caProtEncCert         OBJ_id_it,1L\n\n#define SN_id_it_signKeyPairTypes               \"id-it-signKeyPairTypes\"\n#define NID_id_it_signKeyPairTypes              299\n#define OBJ_id_it_signKeyPairTypes              OBJ_id_it,2L\n\n#define SN_id_it_encKeyPairTypes                \"id-it-encKeyPairTypes\"\n#define NID_id_it_encKeyPairTypes               300\n#define OBJ_id_it_encKeyPairTypes               OBJ_id_it,3L\n\n#define SN_id_it_preferredSymmAlg               \"id-it-preferredSymmAlg\"\n#define NID_id_it_preferredSymmAlg              301\n#define OBJ_id_it_preferredSymmAlg              OBJ_id_it,4L\n\n#define SN_id_it_caKeyUpdateInfo                \"id-it-caKeyUpdateInfo\"\n#define NID_id_it_caKeyUpdateInfo               302\n#define OBJ_id_it_caKeyUpdateInfo               OBJ_id_it,5L\n\n#define SN_id_it_currentCRL             \"id-it-currentCRL\"\n#define NID_id_it_currentCRL            303\n#define OBJ_id_it_currentCRL            OBJ_id_it,6L\n\n#define SN_id_it_unsupportedOIDs                \"id-it-unsupportedOIDs\"\n#define NID_id_it_unsupportedOIDs               304\n#define OBJ_id_it_unsupportedOIDs               OBJ_id_it,7L\n\n#define SN_id_it_subscriptionRequest            \"id-it-subscriptionRequest\"\n#define NID_id_it_subscriptionRequest           305\n#define OBJ_id_it_subscriptionRequest           OBJ_id_it,8L\n\n#define SN_id_it_subscriptionResponse           \"id-it-subscriptionResponse\"\n#define NID_id_it_subscriptionResponse          306\n#define OBJ_id_it_subscriptionResponse          OBJ_id_it,9L\n\n#define SN_id_it_keyPairParamReq                \"id-it-keyPairParamReq\"\n#define NID_id_it_keyPairParamReq               307\n#define OBJ_id_it_keyPairParamReq               OBJ_id_it,10L\n\n#define SN_id_it_keyPairParamRep                \"id-it-keyPairParamRep\"\n#define NID_id_it_keyPairParamRep               308\n#define OBJ_id_it_keyPairParamRep               OBJ_id_it,11L\n\n#define SN_id_it_revPassphrase          \"id-it-revPassphrase\"\n#define NID_id_it_revPassphrase         309\n#define OBJ_id_it_revPassphrase         OBJ_id_it,12L\n\n#define SN_id_it_implicitConfirm                \"id-it-implicitConfirm\"\n#define NID_id_it_implicitConfirm               310\n#define OBJ_id_it_implicitConfirm               OBJ_id_it,13L\n\n#define SN_id_it_confirmWaitTime                \"id-it-confirmWaitTime\"\n#define NID_id_it_confirmWaitTime               311\n#define OBJ_id_it_confirmWaitTime               OBJ_id_it,14L\n\n#define SN_id_it_origPKIMessage         \"id-it-origPKIMessage\"\n#define NID_id_it_origPKIMessage                312\n#define OBJ_id_it_origPKIMessage                OBJ_id_it,15L\n\n#define SN_id_it_suppLangTags           \"id-it-suppLangTags\"\n#define NID_id_it_suppLangTags          784\n#define OBJ_id_it_suppLangTags          OBJ_id_it,16L\n\n#define SN_id_regCtrl           \"id-regCtrl\"\n#define NID_id_regCtrl          313\n#define OBJ_id_regCtrl          OBJ_id_pkip,1L\n\n#define SN_id_regInfo           \"id-regInfo\"\n#define NID_id_regInfo          314\n#define OBJ_id_regInfo          OBJ_id_pkip,2L\n\n#define SN_id_regCtrl_regToken          \"id-regCtrl-regToken\"\n#define NID_id_regCtrl_regToken         315\n#define OBJ_id_regCtrl_regToken         OBJ_id_regCtrl,1L\n\n#define SN_id_regCtrl_authenticator             \"id-regCtrl-authenticator\"\n#define NID_id_regCtrl_authenticator            316\n#define OBJ_id_regCtrl_authenticator            OBJ_id_regCtrl,2L\n\n#define SN_id_regCtrl_pkiPublicationInfo                \"id-regCtrl-pkiPublicationInfo\"\n#define NID_id_regCtrl_pkiPublicationInfo               317\n#define OBJ_id_regCtrl_pkiPublicationInfo               OBJ_id_regCtrl,3L\n\n#define SN_id_regCtrl_pkiArchiveOptions         \"id-regCtrl-pkiArchiveOptions\"\n#define NID_id_regCtrl_pkiArchiveOptions                318\n#define OBJ_id_regCtrl_pkiArchiveOptions                OBJ_id_regCtrl,4L\n\n#define SN_id_regCtrl_oldCertID         \"id-regCtrl-oldCertID\"\n#define NID_id_regCtrl_oldCertID                319\n#define OBJ_id_regCtrl_oldCertID                OBJ_id_regCtrl,5L\n\n#define SN_id_regCtrl_protocolEncrKey           \"id-regCtrl-protocolEncrKey\"\n#define NID_id_regCtrl_protocolEncrKey          320\n#define OBJ_id_regCtrl_protocolEncrKey          OBJ_id_regCtrl,6L\n\n#define SN_id_regInfo_utf8Pairs         \"id-regInfo-utf8Pairs\"\n#define NID_id_regInfo_utf8Pairs                321\n#define OBJ_id_regInfo_utf8Pairs                OBJ_id_regInfo,1L\n\n#define SN_id_regInfo_certReq           \"id-regInfo-certReq\"\n#define NID_id_regInfo_certReq          322\n#define OBJ_id_regInfo_certReq          OBJ_id_regInfo,2L\n\n#define SN_id_alg_des40         \"id-alg-des40\"\n#define NID_id_alg_des40                323\n#define OBJ_id_alg_des40                OBJ_id_alg,1L\n\n#define SN_id_alg_noSignature           \"id-alg-noSignature\"\n#define NID_id_alg_noSignature          324\n#define OBJ_id_alg_noSignature          OBJ_id_alg,2L\n\n#define SN_id_alg_dh_sig_hmac_sha1              \"id-alg-dh-sig-hmac-sha1\"\n#define NID_id_alg_dh_sig_hmac_sha1             325\n#define OBJ_id_alg_dh_sig_hmac_sha1             OBJ_id_alg,3L\n\n#define SN_id_alg_dh_pop                \"id-alg-dh-pop\"\n#define NID_id_alg_dh_pop               326\n#define OBJ_id_alg_dh_pop               OBJ_id_alg,4L\n\n#define SN_id_cmc_statusInfo            \"id-cmc-statusInfo\"\n#define NID_id_cmc_statusInfo           327\n#define OBJ_id_cmc_statusInfo           OBJ_id_cmc,1L\n\n#define SN_id_cmc_identification                \"id-cmc-identification\"\n#define NID_id_cmc_identification               328\n#define OBJ_id_cmc_identification               OBJ_id_cmc,2L\n\n#define SN_id_cmc_identityProof         \"id-cmc-identityProof\"\n#define NID_id_cmc_identityProof                329\n#define OBJ_id_cmc_identityProof                OBJ_id_cmc,3L\n\n#define SN_id_cmc_dataReturn            \"id-cmc-dataReturn\"\n#define NID_id_cmc_dataReturn           330\n#define OBJ_id_cmc_dataReturn           OBJ_id_cmc,4L\n\n#define SN_id_cmc_transactionId         \"id-cmc-transactionId\"\n#define NID_id_cmc_transactionId                331\n#define OBJ_id_cmc_transactionId                OBJ_id_cmc,5L\n\n#define SN_id_cmc_senderNonce           \"id-cmc-senderNonce\"\n#define NID_id_cmc_senderNonce          332\n#define OBJ_id_cmc_senderNonce          OBJ_id_cmc,6L\n\n#define SN_id_cmc_recipientNonce                \"id-cmc-recipientNonce\"\n#define NID_id_cmc_recipientNonce               333\n#define OBJ_id_cmc_recipientNonce               OBJ_id_cmc,7L\n\n#define SN_id_cmc_addExtensions         \"id-cmc-addExtensions\"\n#define NID_id_cmc_addExtensions                334\n#define OBJ_id_cmc_addExtensions                OBJ_id_cmc,8L\n\n#define SN_id_cmc_encryptedPOP          \"id-cmc-encryptedPOP\"\n#define NID_id_cmc_encryptedPOP         335\n#define OBJ_id_cmc_encryptedPOP         OBJ_id_cmc,9L\n\n#define SN_id_cmc_decryptedPOP          \"id-cmc-decryptedPOP\"\n#define NID_id_cmc_decryptedPOP         336\n#define OBJ_id_cmc_decryptedPOP         OBJ_id_cmc,10L\n\n#define SN_id_cmc_lraPOPWitness         \"id-cmc-lraPOPWitness\"\n#define NID_id_cmc_lraPOPWitness                337\n#define OBJ_id_cmc_lraPOPWitness                OBJ_id_cmc,11L\n\n#define SN_id_cmc_getCert               \"id-cmc-getCert\"\n#define NID_id_cmc_getCert              338\n#define OBJ_id_cmc_getCert              OBJ_id_cmc,15L\n\n#define SN_id_cmc_getCRL                \"id-cmc-getCRL\"\n#define NID_id_cmc_getCRL               339\n#define OBJ_id_cmc_getCRL               OBJ_id_cmc,16L\n\n#define SN_id_cmc_revokeRequest         \"id-cmc-revokeRequest\"\n#define NID_id_cmc_revokeRequest                340\n#define OBJ_id_cmc_revokeRequest                OBJ_id_cmc,17L\n\n#define SN_id_cmc_regInfo               \"id-cmc-regInfo\"\n#define NID_id_cmc_regInfo              341\n#define OBJ_id_cmc_regInfo              OBJ_id_cmc,18L\n\n#define SN_id_cmc_responseInfo          \"id-cmc-responseInfo\"\n#define NID_id_cmc_responseInfo         342\n#define OBJ_id_cmc_responseInfo         OBJ_id_cmc,19L\n\n#define SN_id_cmc_queryPending          \"id-cmc-queryPending\"\n#define NID_id_cmc_queryPending         343\n#define OBJ_id_cmc_queryPending         OBJ_id_cmc,21L\n\n#define SN_id_cmc_popLinkRandom         \"id-cmc-popLinkRandom\"\n#define NID_id_cmc_popLinkRandom                344\n#define OBJ_id_cmc_popLinkRandom                OBJ_id_cmc,22L\n\n#define SN_id_cmc_popLinkWitness                \"id-cmc-popLinkWitness\"\n#define NID_id_cmc_popLinkWitness               345\n#define OBJ_id_cmc_popLinkWitness               OBJ_id_cmc,23L\n\n#define SN_id_cmc_confirmCertAcceptance         \"id-cmc-confirmCertAcceptance\"\n#define NID_id_cmc_confirmCertAcceptance                346\n#define OBJ_id_cmc_confirmCertAcceptance                OBJ_id_cmc,24L\n\n#define SN_id_on_personalData           \"id-on-personalData\"\n#define NID_id_on_personalData          347\n#define OBJ_id_on_personalData          OBJ_id_on,1L\n\n#define SN_id_on_permanentIdentifier            \"id-on-permanentIdentifier\"\n#define LN_id_on_permanentIdentifier            \"Permanent Identifier\"\n#define NID_id_on_permanentIdentifier           858\n#define OBJ_id_on_permanentIdentifier           OBJ_id_on,3L\n\n#define SN_id_pda_dateOfBirth           \"id-pda-dateOfBirth\"\n#define NID_id_pda_dateOfBirth          348\n#define OBJ_id_pda_dateOfBirth          OBJ_id_pda,1L\n\n#define SN_id_pda_placeOfBirth          \"id-pda-placeOfBirth\"\n#define NID_id_pda_placeOfBirth         349\n#define OBJ_id_pda_placeOfBirth         OBJ_id_pda,2L\n\n#define SN_id_pda_gender                \"id-pda-gender\"\n#define NID_id_pda_gender               351\n#define OBJ_id_pda_gender               OBJ_id_pda,3L\n\n#define SN_id_pda_countryOfCitizenship          \"id-pda-countryOfCitizenship\"\n#define NID_id_pda_countryOfCitizenship         352\n#define OBJ_id_pda_countryOfCitizenship         OBJ_id_pda,4L\n\n#define SN_id_pda_countryOfResidence            \"id-pda-countryOfResidence\"\n#define NID_id_pda_countryOfResidence           353\n#define OBJ_id_pda_countryOfResidence           OBJ_id_pda,5L\n\n#define SN_id_aca_authenticationInfo            \"id-aca-authenticationInfo\"\n#define NID_id_aca_authenticationInfo           354\n#define OBJ_id_aca_authenticationInfo           OBJ_id_aca,1L\n\n#define SN_id_aca_accessIdentity                \"id-aca-accessIdentity\"\n#define NID_id_aca_accessIdentity               355\n#define OBJ_id_aca_accessIdentity               OBJ_id_aca,2L\n\n#define SN_id_aca_chargingIdentity              \"id-aca-chargingIdentity\"\n#define NID_id_aca_chargingIdentity             356\n#define OBJ_id_aca_chargingIdentity             OBJ_id_aca,3L\n\n#define SN_id_aca_group         \"id-aca-group\"\n#define NID_id_aca_group                357\n#define OBJ_id_aca_group                OBJ_id_aca,4L\n\n#define SN_id_aca_role          \"id-aca-role\"\n#define NID_id_aca_role         358\n#define OBJ_id_aca_role         OBJ_id_aca,5L\n\n#define SN_id_aca_encAttrs              \"id-aca-encAttrs\"\n#define NID_id_aca_encAttrs             399\n#define OBJ_id_aca_encAttrs             OBJ_id_aca,6L\n\n#define SN_id_qcs_pkixQCSyntax_v1               \"id-qcs-pkixQCSyntax-v1\"\n#define NID_id_qcs_pkixQCSyntax_v1              359\n#define OBJ_id_qcs_pkixQCSyntax_v1              OBJ_id_qcs,1L\n\n#define SN_id_cct_crs           \"id-cct-crs\"\n#define NID_id_cct_crs          360\n#define OBJ_id_cct_crs          OBJ_id_cct,1L\n\n#define SN_id_cct_PKIData               \"id-cct-PKIData\"\n#define NID_id_cct_PKIData              361\n#define OBJ_id_cct_PKIData              OBJ_id_cct,2L\n\n#define SN_id_cct_PKIResponse           \"id-cct-PKIResponse\"\n#define NID_id_cct_PKIResponse          362\n#define OBJ_id_cct_PKIResponse          OBJ_id_cct,3L\n\n#define SN_id_ppl_anyLanguage           \"id-ppl-anyLanguage\"\n#define LN_id_ppl_anyLanguage           \"Any language\"\n#define NID_id_ppl_anyLanguage          664\n#define OBJ_id_ppl_anyLanguage          OBJ_id_ppl,0L\n\n#define SN_id_ppl_inheritAll            \"id-ppl-inheritAll\"\n#define LN_id_ppl_inheritAll            \"Inherit all\"\n#define NID_id_ppl_inheritAll           665\n#define OBJ_id_ppl_inheritAll           OBJ_id_ppl,1L\n\n#define SN_Independent          \"id-ppl-independent\"\n#define LN_Independent          \"Independent\"\n#define NID_Independent         667\n#define OBJ_Independent         OBJ_id_ppl,2L\n\n#define SN_ad_OCSP              \"OCSP\"\n#define LN_ad_OCSP              \"OCSP\"\n#define NID_ad_OCSP             178\n#define OBJ_ad_OCSP             OBJ_id_ad,1L\n\n#define SN_ad_ca_issuers                \"caIssuers\"\n#define LN_ad_ca_issuers                \"CA Issuers\"\n#define NID_ad_ca_issuers               179\n#define OBJ_ad_ca_issuers               OBJ_id_ad,2L\n\n#define SN_ad_timeStamping              \"ad_timestamping\"\n#define LN_ad_timeStamping              \"AD Time Stamping\"\n#define NID_ad_timeStamping             363\n#define OBJ_ad_timeStamping             OBJ_id_ad,3L\n\n#define SN_ad_dvcs              \"AD_DVCS\"\n#define LN_ad_dvcs              \"ad dvcs\"\n#define NID_ad_dvcs             364\n#define OBJ_ad_dvcs             OBJ_id_ad,4L\n\n#define SN_caRepository         \"caRepository\"\n#define LN_caRepository         \"CA Repository\"\n#define NID_caRepository                785\n#define OBJ_caRepository                OBJ_id_ad,5L\n\n#define OBJ_id_pkix_OCSP                OBJ_ad_OCSP\n\n#define SN_id_pkix_OCSP_basic           \"basicOCSPResponse\"\n#define LN_id_pkix_OCSP_basic           \"Basic OCSP Response\"\n#define NID_id_pkix_OCSP_basic          365\n#define OBJ_id_pkix_OCSP_basic          OBJ_id_pkix_OCSP,1L\n\n#define SN_id_pkix_OCSP_Nonce           \"Nonce\"\n#define LN_id_pkix_OCSP_Nonce           \"OCSP Nonce\"\n#define NID_id_pkix_OCSP_Nonce          366\n#define OBJ_id_pkix_OCSP_Nonce          OBJ_id_pkix_OCSP,2L\n\n#define SN_id_pkix_OCSP_CrlID           \"CrlID\"\n#define LN_id_pkix_OCSP_CrlID           \"OCSP CRL ID\"\n#define NID_id_pkix_OCSP_CrlID          367\n#define OBJ_id_pkix_OCSP_CrlID          OBJ_id_pkix_OCSP,3L\n\n#define SN_id_pkix_OCSP_acceptableResponses             \"acceptableResponses\"\n#define LN_id_pkix_OCSP_acceptableResponses             \"Acceptable OCSP Responses\"\n#define NID_id_pkix_OCSP_acceptableResponses            368\n#define OBJ_id_pkix_OCSP_acceptableResponses            OBJ_id_pkix_OCSP,4L\n\n#define SN_id_pkix_OCSP_noCheck         \"noCheck\"\n#define LN_id_pkix_OCSP_noCheck         \"OCSP No Check\"\n#define NID_id_pkix_OCSP_noCheck                369\n#define OBJ_id_pkix_OCSP_noCheck                OBJ_id_pkix_OCSP,5L\n\n#define SN_id_pkix_OCSP_archiveCutoff           \"archiveCutoff\"\n#define LN_id_pkix_OCSP_archiveCutoff           \"OCSP Archive Cutoff\"\n#define NID_id_pkix_OCSP_archiveCutoff          370\n#define OBJ_id_pkix_OCSP_archiveCutoff          OBJ_id_pkix_OCSP,6L\n\n#define SN_id_pkix_OCSP_serviceLocator          \"serviceLocator\"\n#define LN_id_pkix_OCSP_serviceLocator          \"OCSP Service Locator\"\n#define NID_id_pkix_OCSP_serviceLocator         371\n#define OBJ_id_pkix_OCSP_serviceLocator         OBJ_id_pkix_OCSP,7L\n\n#define SN_id_pkix_OCSP_extendedStatus          \"extendedStatus\"\n#define LN_id_pkix_OCSP_extendedStatus          \"Extended OCSP Status\"\n#define NID_id_pkix_OCSP_extendedStatus         372\n#define OBJ_id_pkix_OCSP_extendedStatus         OBJ_id_pkix_OCSP,8L\n\n#define SN_id_pkix_OCSP_valid           \"valid\"\n#define NID_id_pkix_OCSP_valid          373\n#define OBJ_id_pkix_OCSP_valid          OBJ_id_pkix_OCSP,9L\n\n#define SN_id_pkix_OCSP_path            \"path\"\n#define NID_id_pkix_OCSP_path           374\n#define OBJ_id_pkix_OCSP_path           OBJ_id_pkix_OCSP,10L\n\n#define SN_id_pkix_OCSP_trustRoot               \"trustRoot\"\n#define LN_id_pkix_OCSP_trustRoot               \"Trust Root\"\n#define NID_id_pkix_OCSP_trustRoot              375\n#define OBJ_id_pkix_OCSP_trustRoot              OBJ_id_pkix_OCSP,11L\n\n#define SN_algorithm            \"algorithm\"\n#define LN_algorithm            \"algorithm\"\n#define NID_algorithm           376\n#define OBJ_algorithm           1L,3L,14L,3L,2L\n\n#define SN_md5WithRSA           \"RSA-NP-MD5\"\n#define LN_md5WithRSA           \"md5WithRSA\"\n#define NID_md5WithRSA          104\n#define OBJ_md5WithRSA          OBJ_algorithm,3L\n\n#define SN_des_ecb              \"DES-ECB\"\n#define LN_des_ecb              \"des-ecb\"\n#define NID_des_ecb             29\n#define OBJ_des_ecb             OBJ_algorithm,6L\n\n#define SN_des_cbc              \"DES-CBC\"\n#define LN_des_cbc              \"des-cbc\"\n#define NID_des_cbc             31\n#define OBJ_des_cbc             OBJ_algorithm,7L\n\n#define SN_des_ofb64            \"DES-OFB\"\n#define LN_des_ofb64            \"des-ofb\"\n#define NID_des_ofb64           45\n#define OBJ_des_ofb64           OBJ_algorithm,8L\n\n#define SN_des_cfb64            \"DES-CFB\"\n#define LN_des_cfb64            \"des-cfb\"\n#define NID_des_cfb64           30\n#define OBJ_des_cfb64           OBJ_algorithm,9L\n\n#define SN_rsaSignature         \"rsaSignature\"\n#define NID_rsaSignature                377\n#define OBJ_rsaSignature                OBJ_algorithm,11L\n\n#define SN_dsa_2                \"DSA-old\"\n#define LN_dsa_2                \"dsaEncryption-old\"\n#define NID_dsa_2               67\n#define OBJ_dsa_2               OBJ_algorithm,12L\n\n#define SN_dsaWithSHA           \"DSA-SHA\"\n#define LN_dsaWithSHA           \"dsaWithSHA\"\n#define NID_dsaWithSHA          66\n#define OBJ_dsaWithSHA          OBJ_algorithm,13L\n\n#define SN_shaWithRSAEncryption         \"RSA-SHA\"\n#define LN_shaWithRSAEncryption         \"shaWithRSAEncryption\"\n#define NID_shaWithRSAEncryption                42\n#define OBJ_shaWithRSAEncryption                OBJ_algorithm,15L\n\n#define SN_des_ede_ecb          \"DES-EDE\"\n#define LN_des_ede_ecb          \"des-ede\"\n#define NID_des_ede_ecb         32\n#define OBJ_des_ede_ecb         OBJ_algorithm,17L\n\n#define SN_des_ede3_ecb         \"DES-EDE3\"\n#define LN_des_ede3_ecb         \"des-ede3\"\n#define NID_des_ede3_ecb                33\n\n#define SN_des_ede_cbc          \"DES-EDE-CBC\"\n#define LN_des_ede_cbc          \"des-ede-cbc\"\n#define NID_des_ede_cbc         43\n\n#define SN_des_ede_cfb64                \"DES-EDE-CFB\"\n#define LN_des_ede_cfb64                \"des-ede-cfb\"\n#define NID_des_ede_cfb64               60\n\n#define SN_des_ede3_cfb64               \"DES-EDE3-CFB\"\n#define LN_des_ede3_cfb64               \"des-ede3-cfb\"\n#define NID_des_ede3_cfb64              61\n\n#define SN_des_ede_ofb64                \"DES-EDE-OFB\"\n#define LN_des_ede_ofb64                \"des-ede-ofb\"\n#define NID_des_ede_ofb64               62\n\n#define SN_des_ede3_ofb64               \"DES-EDE3-OFB\"\n#define LN_des_ede3_ofb64               \"des-ede3-ofb\"\n#define NID_des_ede3_ofb64              63\n\n#define SN_desx_cbc             \"DESX-CBC\"\n#define LN_desx_cbc             \"desx-cbc\"\n#define NID_desx_cbc            80\n\n#define SN_sha          \"SHA\"\n#define LN_sha          \"sha\"\n#define NID_sha         41\n#define OBJ_sha         OBJ_algorithm,18L\n\n#define SN_sha1         \"SHA1\"\n#define LN_sha1         \"sha1\"\n#define NID_sha1                64\n#define OBJ_sha1                OBJ_algorithm,26L\n\n#define SN_dsaWithSHA1_2                \"DSA-SHA1-old\"\n#define LN_dsaWithSHA1_2                \"dsaWithSHA1-old\"\n#define NID_dsaWithSHA1_2               70\n#define OBJ_dsaWithSHA1_2               OBJ_algorithm,27L\n\n#define SN_sha1WithRSA          \"RSA-SHA1-2\"\n#define LN_sha1WithRSA          \"sha1WithRSA\"\n#define NID_sha1WithRSA         115\n#define OBJ_sha1WithRSA         OBJ_algorithm,29L\n\n#define SN_ripemd160            \"RIPEMD160\"\n#define LN_ripemd160            \"ripemd160\"\n#define NID_ripemd160           117\n#define OBJ_ripemd160           1L,3L,36L,3L,2L,1L\n\n#define SN_ripemd160WithRSA             \"RSA-RIPEMD160\"\n#define LN_ripemd160WithRSA             \"ripemd160WithRSA\"\n#define NID_ripemd160WithRSA            119\n#define OBJ_ripemd160WithRSA            1L,3L,36L,3L,3L,1L,2L\n\n#define SN_sxnet                \"SXNetID\"\n#define LN_sxnet                \"Strong Extranet ID\"\n#define NID_sxnet               143\n#define OBJ_sxnet               1L,3L,101L,1L,4L,1L\n\n#define SN_X500         \"X500\"\n#define LN_X500         \"directory services (X.500)\"\n#define NID_X500                11\n#define OBJ_X500                2L,5L\n\n#define SN_X509         \"X509\"\n#define NID_X509                12\n#define OBJ_X509                OBJ_X500,4L\n\n#define SN_commonName           \"CN\"\n#define LN_commonName           \"commonName\"\n#define NID_commonName          13\n#define OBJ_commonName          OBJ_X509,3L\n\n#define SN_surname              \"SN\"\n#define LN_surname              \"surname\"\n#define NID_surname             100\n#define OBJ_surname             OBJ_X509,4L\n\n#define LN_serialNumber         \"serialNumber\"\n#define NID_serialNumber                105\n#define OBJ_serialNumber                OBJ_X509,5L\n\n#define SN_countryName          \"C\"\n#define LN_countryName          \"countryName\"\n#define NID_countryName         14\n#define OBJ_countryName         OBJ_X509,6L\n\n#define SN_localityName         \"L\"\n#define LN_localityName         \"localityName\"\n#define NID_localityName                15\n#define OBJ_localityName                OBJ_X509,7L\n\n#define SN_stateOrProvinceName          \"ST\"\n#define LN_stateOrProvinceName          \"stateOrProvinceName\"\n#define NID_stateOrProvinceName         16\n#define OBJ_stateOrProvinceName         OBJ_X509,8L\n\n#define SN_streetAddress                \"street\"\n#define LN_streetAddress                \"streetAddress\"\n#define NID_streetAddress               660\n#define OBJ_streetAddress               OBJ_X509,9L\n\n#define SN_organizationName             \"O\"\n#define LN_organizationName             \"organizationName\"\n#define NID_organizationName            17\n#define OBJ_organizationName            OBJ_X509,10L\n\n#define SN_organizationalUnitName               \"OU\"\n#define LN_organizationalUnitName               \"organizationalUnitName\"\n#define NID_organizationalUnitName              18\n#define OBJ_organizationalUnitName              OBJ_X509,11L\n\n#define SN_title                \"title\"\n#define LN_title                \"title\"\n#define NID_title               106\n#define OBJ_title               OBJ_X509,12L\n\n#define LN_description          \"description\"\n#define NID_description         107\n#define OBJ_description         OBJ_X509,13L\n\n#define LN_searchGuide          \"searchGuide\"\n#define NID_searchGuide         859\n#define OBJ_searchGuide         OBJ_X509,14L\n\n#define LN_businessCategory             \"businessCategory\"\n#define NID_businessCategory            860\n#define OBJ_businessCategory            OBJ_X509,15L\n\n#define LN_postalAddress                \"postalAddress\"\n#define NID_postalAddress               861\n#define OBJ_postalAddress               OBJ_X509,16L\n\n#define LN_postalCode           \"postalCode\"\n#define NID_postalCode          661\n#define OBJ_postalCode          OBJ_X509,17L\n\n#define LN_postOfficeBox                \"postOfficeBox\"\n#define NID_postOfficeBox               862\n#define OBJ_postOfficeBox               OBJ_X509,18L\n\n#define LN_physicalDeliveryOfficeName           \"physicalDeliveryOfficeName\"\n#define NID_physicalDeliveryOfficeName          863\n#define OBJ_physicalDeliveryOfficeName          OBJ_X509,19L\n\n#define LN_telephoneNumber              \"telephoneNumber\"\n#define NID_telephoneNumber             864\n#define OBJ_telephoneNumber             OBJ_X509,20L\n\n#define LN_telexNumber          \"telexNumber\"\n#define NID_telexNumber         865\n#define OBJ_telexNumber         OBJ_X509,21L\n\n#define LN_teletexTerminalIdentifier            \"teletexTerminalIdentifier\"\n#define NID_teletexTerminalIdentifier           866\n#define OBJ_teletexTerminalIdentifier           OBJ_X509,22L\n\n#define LN_facsimileTelephoneNumber             \"facsimileTelephoneNumber\"\n#define NID_facsimileTelephoneNumber            867\n#define OBJ_facsimileTelephoneNumber            OBJ_X509,23L\n\n#define LN_x121Address          \"x121Address\"\n#define NID_x121Address         868\n#define OBJ_x121Address         OBJ_X509,24L\n\n#define LN_internationaliSDNNumber              \"internationaliSDNNumber\"\n#define NID_internationaliSDNNumber             869\n#define OBJ_internationaliSDNNumber             OBJ_X509,25L\n\n#define LN_registeredAddress            \"registeredAddress\"\n#define NID_registeredAddress           870\n#define OBJ_registeredAddress           OBJ_X509,26L\n\n#define LN_destinationIndicator         \"destinationIndicator\"\n#define NID_destinationIndicator                871\n#define OBJ_destinationIndicator                OBJ_X509,27L\n\n#define LN_preferredDeliveryMethod              \"preferredDeliveryMethod\"\n#define NID_preferredDeliveryMethod             872\n#define OBJ_preferredDeliveryMethod             OBJ_X509,28L\n\n#define LN_presentationAddress          \"presentationAddress\"\n#define NID_presentationAddress         873\n#define OBJ_presentationAddress         OBJ_X509,29L\n\n#define LN_supportedApplicationContext          \"supportedApplicationContext\"\n#define NID_supportedApplicationContext         874\n#define OBJ_supportedApplicationContext         OBJ_X509,30L\n\n#define SN_member               \"member\"\n#define NID_member              875\n#define OBJ_member              OBJ_X509,31L\n\n#define SN_owner                \"owner\"\n#define NID_owner               876\n#define OBJ_owner               OBJ_X509,32L\n\n#define LN_roleOccupant         \"roleOccupant\"\n#define NID_roleOccupant                877\n#define OBJ_roleOccupant                OBJ_X509,33L\n\n#define SN_seeAlso              \"seeAlso\"\n#define NID_seeAlso             878\n#define OBJ_seeAlso             OBJ_X509,34L\n\n#define LN_userPassword         \"userPassword\"\n#define NID_userPassword                879\n#define OBJ_userPassword                OBJ_X509,35L\n\n#define LN_userCertificate              \"userCertificate\"\n#define NID_userCertificate             880\n#define OBJ_userCertificate             OBJ_X509,36L\n\n#define LN_cACertificate                \"cACertificate\"\n#define NID_cACertificate               881\n#define OBJ_cACertificate               OBJ_X509,37L\n\n#define LN_authorityRevocationList              \"authorityRevocationList\"\n#define NID_authorityRevocationList             882\n#define OBJ_authorityRevocationList             OBJ_X509,38L\n\n#define LN_certificateRevocationList            \"certificateRevocationList\"\n#define NID_certificateRevocationList           883\n#define OBJ_certificateRevocationList           OBJ_X509,39L\n\n#define LN_crossCertificatePair         \"crossCertificatePair\"\n#define NID_crossCertificatePair                884\n#define OBJ_crossCertificatePair                OBJ_X509,40L\n\n#define SN_name         \"name\"\n#define LN_name         \"name\"\n#define NID_name                173\n#define OBJ_name                OBJ_X509,41L\n\n#define SN_givenName            \"GN\"\n#define LN_givenName            \"givenName\"\n#define NID_givenName           99\n#define OBJ_givenName           OBJ_X509,42L\n\n#define SN_initials             \"initials\"\n#define LN_initials             \"initials\"\n#define NID_initials            101\n#define OBJ_initials            OBJ_X509,43L\n\n#define LN_generationQualifier          \"generationQualifier\"\n#define NID_generationQualifier         509\n#define OBJ_generationQualifier         OBJ_X509,44L\n\n#define LN_x500UniqueIdentifier         \"x500UniqueIdentifier\"\n#define NID_x500UniqueIdentifier                503\n#define OBJ_x500UniqueIdentifier                OBJ_X509,45L\n\n#define SN_dnQualifier          \"dnQualifier\"\n#define LN_dnQualifier          \"dnQualifier\"\n#define NID_dnQualifier         174\n#define OBJ_dnQualifier         OBJ_X509,46L\n\n#define LN_enhancedSearchGuide          \"enhancedSearchGuide\"\n#define NID_enhancedSearchGuide         885\n#define OBJ_enhancedSearchGuide         OBJ_X509,47L\n\n#define LN_protocolInformation          \"protocolInformation\"\n#define NID_protocolInformation         886\n#define OBJ_protocolInformation         OBJ_X509,48L\n\n#define LN_distinguishedName            \"distinguishedName\"\n#define NID_distinguishedName           887\n#define OBJ_distinguishedName           OBJ_X509,49L\n\n#define LN_uniqueMember         \"uniqueMember\"\n#define NID_uniqueMember                888\n#define OBJ_uniqueMember                OBJ_X509,50L\n\n#define LN_houseIdentifier              \"houseIdentifier\"\n#define NID_houseIdentifier             889\n#define OBJ_houseIdentifier             OBJ_X509,51L\n\n#define LN_supportedAlgorithms          \"supportedAlgorithms\"\n#define NID_supportedAlgorithms         890\n#define OBJ_supportedAlgorithms         OBJ_X509,52L\n\n#define LN_deltaRevocationList          \"deltaRevocationList\"\n#define NID_deltaRevocationList         891\n#define OBJ_deltaRevocationList         OBJ_X509,53L\n\n#define SN_dmdName              \"dmdName\"\n#define NID_dmdName             892\n#define OBJ_dmdName             OBJ_X509,54L\n\n#define LN_pseudonym            \"pseudonym\"\n#define NID_pseudonym           510\n#define OBJ_pseudonym           OBJ_X509,65L\n\n#define SN_role         \"role\"\n#define LN_role         \"role\"\n#define NID_role                400\n#define OBJ_role                OBJ_X509,72L\n\n#define SN_X500algorithms               \"X500algorithms\"\n#define LN_X500algorithms               \"directory services - algorithms\"\n#define NID_X500algorithms              378\n#define OBJ_X500algorithms              OBJ_X500,8L\n\n#define SN_rsa          \"RSA\"\n#define LN_rsa          \"rsa\"\n#define NID_rsa         19\n#define OBJ_rsa         OBJ_X500algorithms,1L,1L\n\n#define SN_mdc2WithRSA          \"RSA-MDC2\"\n#define LN_mdc2WithRSA          \"mdc2WithRSA\"\n#define NID_mdc2WithRSA         96\n#define OBJ_mdc2WithRSA         OBJ_X500algorithms,3L,100L\n\n#define SN_mdc2         \"MDC2\"\n#define LN_mdc2         \"mdc2\"\n#define NID_mdc2                95\n#define OBJ_mdc2                OBJ_X500algorithms,3L,101L\n\n#define SN_id_ce                \"id-ce\"\n#define NID_id_ce               81\n#define OBJ_id_ce               OBJ_X500,29L\n\n#define SN_subject_directory_attributes         \"subjectDirectoryAttributes\"\n#define LN_subject_directory_attributes         \"X509v3 Subject Directory Attributes\"\n#define NID_subject_directory_attributes                769\n#define OBJ_subject_directory_attributes                OBJ_id_ce,9L\n\n#define SN_subject_key_identifier               \"subjectKeyIdentifier\"\n#define LN_subject_key_identifier               \"X509v3 Subject Key Identifier\"\n#define NID_subject_key_identifier              82\n#define OBJ_subject_key_identifier              OBJ_id_ce,14L\n\n#define SN_key_usage            \"keyUsage\"\n#define LN_key_usage            \"X509v3 Key Usage\"\n#define NID_key_usage           83\n#define OBJ_key_usage           OBJ_id_ce,15L\n\n#define SN_private_key_usage_period             \"privateKeyUsagePeriod\"\n#define LN_private_key_usage_period             \"X509v3 Private Key Usage Period\"\n#define NID_private_key_usage_period            84\n#define OBJ_private_key_usage_period            OBJ_id_ce,16L\n\n#define SN_subject_alt_name             \"subjectAltName\"\n#define LN_subject_alt_name             \"X509v3 Subject Alternative Name\"\n#define NID_subject_alt_name            85\n#define OBJ_subject_alt_name            OBJ_id_ce,17L\n\n#define SN_issuer_alt_name              \"issuerAltName\"\n#define LN_issuer_alt_name              \"X509v3 Issuer Alternative Name\"\n#define NID_issuer_alt_name             86\n#define OBJ_issuer_alt_name             OBJ_id_ce,18L\n\n#define SN_basic_constraints            \"basicConstraints\"\n#define LN_basic_constraints            \"X509v3 Basic Constraints\"\n#define NID_basic_constraints           87\n#define OBJ_basic_constraints           OBJ_id_ce,19L\n\n#define SN_crl_number           \"crlNumber\"\n#define LN_crl_number           \"X509v3 CRL Number\"\n#define NID_crl_number          88\n#define OBJ_crl_number          OBJ_id_ce,20L\n\n#define SN_crl_reason           \"CRLReason\"\n#define LN_crl_reason           \"X509v3 CRL Reason Code\"\n#define NID_crl_reason          141\n#define OBJ_crl_reason          OBJ_id_ce,21L\n\n#define SN_invalidity_date              \"invalidityDate\"\n#define LN_invalidity_date              \"Invalidity Date\"\n#define NID_invalidity_date             142\n#define OBJ_invalidity_date             OBJ_id_ce,24L\n\n#define SN_delta_crl            \"deltaCRL\"\n#define LN_delta_crl            \"X509v3 Delta CRL Indicator\"\n#define NID_delta_crl           140\n#define OBJ_delta_crl           OBJ_id_ce,27L\n\n#define SN_issuing_distribution_point           \"issuingDistributionPoint\"\n#define LN_issuing_distribution_point           \"X509v3 Issuing Distrubution Point\"\n#define NID_issuing_distribution_point          770\n#define OBJ_issuing_distribution_point          OBJ_id_ce,28L\n\n#define SN_certificate_issuer           \"certificateIssuer\"\n#define LN_certificate_issuer           \"X509v3 Certificate Issuer\"\n#define NID_certificate_issuer          771\n#define OBJ_certificate_issuer          OBJ_id_ce,29L\n\n#define SN_name_constraints             \"nameConstraints\"\n#define LN_name_constraints             \"X509v3 Name Constraints\"\n#define NID_name_constraints            666\n#define OBJ_name_constraints            OBJ_id_ce,30L\n\n#define SN_crl_distribution_points              \"crlDistributionPoints\"\n#define LN_crl_distribution_points              \"X509v3 CRL Distribution Points\"\n#define NID_crl_distribution_points             103\n#define OBJ_crl_distribution_points             OBJ_id_ce,31L\n\n#define SN_certificate_policies         \"certificatePolicies\"\n#define LN_certificate_policies         \"X509v3 Certificate Policies\"\n#define NID_certificate_policies                89\n#define OBJ_certificate_policies                OBJ_id_ce,32L\n\n#define SN_any_policy           \"anyPolicy\"\n#define LN_any_policy           \"X509v3 Any Policy\"\n#define NID_any_policy          746\n#define OBJ_any_policy          OBJ_certificate_policies,0L\n\n#define SN_policy_mappings              \"policyMappings\"\n#define LN_policy_mappings              \"X509v3 Policy Mappings\"\n#define NID_policy_mappings             747\n#define OBJ_policy_mappings             OBJ_id_ce,33L\n\n#define SN_authority_key_identifier             \"authorityKeyIdentifier\"\n#define LN_authority_key_identifier             \"X509v3 Authority Key Identifier\"\n#define NID_authority_key_identifier            90\n#define OBJ_authority_key_identifier            OBJ_id_ce,35L\n\n#define SN_policy_constraints           \"policyConstraints\"\n#define LN_policy_constraints           \"X509v3 Policy Constraints\"\n#define NID_policy_constraints          401\n#define OBJ_policy_constraints          OBJ_id_ce,36L\n\n#define SN_ext_key_usage                \"extendedKeyUsage\"\n#define LN_ext_key_usage                \"X509v3 Extended Key Usage\"\n#define NID_ext_key_usage               126\n#define OBJ_ext_key_usage               OBJ_id_ce,37L\n\n#define SN_freshest_crl         \"freshestCRL\"\n#define LN_freshest_crl         \"X509v3 Freshest CRL\"\n#define NID_freshest_crl                857\n#define OBJ_freshest_crl                OBJ_id_ce,46L\n\n#define SN_inhibit_any_policy           \"inhibitAnyPolicy\"\n#define LN_inhibit_any_policy           \"X509v3 Inhibit Any Policy\"\n#define NID_inhibit_any_policy          748\n#define OBJ_inhibit_any_policy          OBJ_id_ce,54L\n\n#define SN_target_information           \"targetInformation\"\n#define LN_target_information           \"X509v3 AC Targeting\"\n#define NID_target_information          402\n#define OBJ_target_information          OBJ_id_ce,55L\n\n#define SN_no_rev_avail         \"noRevAvail\"\n#define LN_no_rev_avail         \"X509v3 No Revocation Available\"\n#define NID_no_rev_avail                403\n#define OBJ_no_rev_avail                OBJ_id_ce,56L\n\n#define SN_anyExtendedKeyUsage          \"anyExtendedKeyUsage\"\n#define LN_anyExtendedKeyUsage          \"Any Extended Key Usage\"\n#define NID_anyExtendedKeyUsage         910\n#define OBJ_anyExtendedKeyUsage         OBJ_ext_key_usage,0L\n\n#define SN_netscape             \"Netscape\"\n#define LN_netscape             \"Netscape Communications Corp.\"\n#define NID_netscape            57\n#define OBJ_netscape            2L,16L,840L,1L,113730L\n\n#define SN_netscape_cert_extension              \"nsCertExt\"\n#define LN_netscape_cert_extension              \"Netscape Certificate Extension\"\n#define NID_netscape_cert_extension             58\n#define OBJ_netscape_cert_extension             OBJ_netscape,1L\n\n#define SN_netscape_data_type           \"nsDataType\"\n#define LN_netscape_data_type           \"Netscape Data Type\"\n#define NID_netscape_data_type          59\n#define OBJ_netscape_data_type          OBJ_netscape,2L\n\n#define SN_netscape_cert_type           \"nsCertType\"\n#define LN_netscape_cert_type           \"Netscape Cert Type\"\n#define NID_netscape_cert_type          71\n#define OBJ_netscape_cert_type          OBJ_netscape_cert_extension,1L\n\n#define SN_netscape_base_url            \"nsBaseUrl\"\n#define LN_netscape_base_url            \"Netscape Base Url\"\n#define NID_netscape_base_url           72\n#define OBJ_netscape_base_url           OBJ_netscape_cert_extension,2L\n\n#define SN_netscape_revocation_url              \"nsRevocationUrl\"\n#define LN_netscape_revocation_url              \"Netscape Revocation Url\"\n#define NID_netscape_revocation_url             73\n#define OBJ_netscape_revocation_url             OBJ_netscape_cert_extension,3L\n\n#define SN_netscape_ca_revocation_url           \"nsCaRevocationUrl\"\n#define LN_netscape_ca_revocation_url           \"Netscape CA Revocation Url\"\n#define NID_netscape_ca_revocation_url          74\n#define OBJ_netscape_ca_revocation_url          OBJ_netscape_cert_extension,4L\n\n#define SN_netscape_renewal_url         \"nsRenewalUrl\"\n#define LN_netscape_renewal_url         \"Netscape Renewal Url\"\n#define NID_netscape_renewal_url                75\n#define OBJ_netscape_renewal_url                OBJ_netscape_cert_extension,7L\n\n#define SN_netscape_ca_policy_url               \"nsCaPolicyUrl\"\n#define LN_netscape_ca_policy_url               \"Netscape CA Policy Url\"\n#define NID_netscape_ca_policy_url              76\n#define OBJ_netscape_ca_policy_url              OBJ_netscape_cert_extension,8L\n\n#define SN_netscape_ssl_server_name             \"nsSslServerName\"\n#define LN_netscape_ssl_server_name             \"Netscape SSL Server Name\"\n#define NID_netscape_ssl_server_name            77\n#define OBJ_netscape_ssl_server_name            OBJ_netscape_cert_extension,12L\n\n#define SN_netscape_comment             \"nsComment\"\n#define LN_netscape_comment             \"Netscape Comment\"\n#define NID_netscape_comment            78\n#define OBJ_netscape_comment            OBJ_netscape_cert_extension,13L\n\n#define SN_netscape_cert_sequence               \"nsCertSequence\"\n#define LN_netscape_cert_sequence               \"Netscape Certificate Sequence\"\n#define NID_netscape_cert_sequence              79\n#define OBJ_netscape_cert_sequence              OBJ_netscape_data_type,5L\n\n#define SN_ns_sgc               \"nsSGC\"\n#define LN_ns_sgc               \"Netscape Server Gated Crypto\"\n#define NID_ns_sgc              139\n#define OBJ_ns_sgc              OBJ_netscape,4L,1L\n\n#define SN_org          \"ORG\"\n#define LN_org          \"org\"\n#define NID_org         379\n#define OBJ_org         OBJ_iso,3L\n\n#define SN_dod          \"DOD\"\n#define LN_dod          \"dod\"\n#define NID_dod         380\n#define OBJ_dod         OBJ_org,6L\n\n#define SN_iana         \"IANA\"\n#define LN_iana         \"iana\"\n#define NID_iana                381\n#define OBJ_iana                OBJ_dod,1L\n\n#define OBJ_internet            OBJ_iana\n\n#define SN_Directory            \"directory\"\n#define LN_Directory            \"Directory\"\n#define NID_Directory           382\n#define OBJ_Directory           OBJ_internet,1L\n\n#define SN_Management           \"mgmt\"\n#define LN_Management           \"Management\"\n#define NID_Management          383\n#define OBJ_Management          OBJ_internet,2L\n\n#define SN_Experimental         \"experimental\"\n#define LN_Experimental         \"Experimental\"\n#define NID_Experimental                384\n#define OBJ_Experimental                OBJ_internet,3L\n\n#define SN_Private              \"private\"\n#define LN_Private              \"Private\"\n#define NID_Private             385\n#define OBJ_Private             OBJ_internet,4L\n\n#define SN_Security             \"security\"\n#define LN_Security             \"Security\"\n#define NID_Security            386\n#define OBJ_Security            OBJ_internet,5L\n\n#define SN_SNMPv2               \"snmpv2\"\n#define LN_SNMPv2               \"SNMPv2\"\n#define NID_SNMPv2              387\n#define OBJ_SNMPv2              OBJ_internet,6L\n\n#define LN_Mail         \"Mail\"\n#define NID_Mail                388\n#define OBJ_Mail                OBJ_internet,7L\n\n#define SN_Enterprises          \"enterprises\"\n#define LN_Enterprises          \"Enterprises\"\n#define NID_Enterprises         389\n#define OBJ_Enterprises         OBJ_Private,1L\n\n#define SN_dcObject             \"dcobject\"\n#define LN_dcObject             \"dcObject\"\n#define NID_dcObject            390\n#define OBJ_dcObject            OBJ_Enterprises,1466L,344L\n\n#define SN_mime_mhs             \"mime-mhs\"\n#define LN_mime_mhs             \"MIME MHS\"\n#define NID_mime_mhs            504\n#define OBJ_mime_mhs            OBJ_Mail,1L\n\n#define SN_mime_mhs_headings            \"mime-mhs-headings\"\n#define LN_mime_mhs_headings            \"mime-mhs-headings\"\n#define NID_mime_mhs_headings           505\n#define OBJ_mime_mhs_headings           OBJ_mime_mhs,1L\n\n#define SN_mime_mhs_bodies              \"mime-mhs-bodies\"\n#define LN_mime_mhs_bodies              \"mime-mhs-bodies\"\n#define NID_mime_mhs_bodies             506\n#define OBJ_mime_mhs_bodies             OBJ_mime_mhs,2L\n\n#define SN_id_hex_partial_message               \"id-hex-partial-message\"\n#define LN_id_hex_partial_message               \"id-hex-partial-message\"\n#define NID_id_hex_partial_message              507\n#define OBJ_id_hex_partial_message              OBJ_mime_mhs_headings,1L\n\n#define SN_id_hex_multipart_message             \"id-hex-multipart-message\"\n#define LN_id_hex_multipart_message             \"id-hex-multipart-message\"\n#define NID_id_hex_multipart_message            508\n#define OBJ_id_hex_multipart_message            OBJ_mime_mhs_headings,2L\n\n#define SN_rle_compression              \"RLE\"\n#define LN_rle_compression              \"run length compression\"\n#define NID_rle_compression             124\n#define OBJ_rle_compression             1L,1L,1L,1L,666L,1L\n\n#define SN_zlib_compression             \"ZLIB\"\n#define LN_zlib_compression             \"zlib compression\"\n#define NID_zlib_compression            125\n#define OBJ_zlib_compression            OBJ_id_smime_alg,8L\n\n#define OBJ_csor                2L,16L,840L,1L,101L,3L\n\n#define OBJ_nistAlgorithms              OBJ_csor,4L\n\n#define OBJ_aes         OBJ_nistAlgorithms,1L\n\n#define SN_aes_128_ecb          \"AES-128-ECB\"\n#define LN_aes_128_ecb          \"aes-128-ecb\"\n#define NID_aes_128_ecb         418\n#define OBJ_aes_128_ecb         OBJ_aes,1L\n\n#define SN_aes_128_cbc          \"AES-128-CBC\"\n#define LN_aes_128_cbc          \"aes-128-cbc\"\n#define NID_aes_128_cbc         419\n#define OBJ_aes_128_cbc         OBJ_aes,2L\n\n#define SN_aes_128_ofb128               \"AES-128-OFB\"\n#define LN_aes_128_ofb128               \"aes-128-ofb\"\n#define NID_aes_128_ofb128              420\n#define OBJ_aes_128_ofb128              OBJ_aes,3L\n\n#define SN_aes_128_cfb128               \"AES-128-CFB\"\n#define LN_aes_128_cfb128               \"aes-128-cfb\"\n#define NID_aes_128_cfb128              421\n#define OBJ_aes_128_cfb128              OBJ_aes,4L\n\n#define SN_id_aes128_wrap               \"id-aes128-wrap\"\n#define NID_id_aes128_wrap              788\n#define OBJ_id_aes128_wrap              OBJ_aes,5L\n\n#define SN_aes_128_gcm          \"id-aes128-GCM\"\n#define LN_aes_128_gcm          \"aes-128-gcm\"\n#define NID_aes_128_gcm         895\n#define OBJ_aes_128_gcm         OBJ_aes,6L\n\n#define SN_aes_128_ccm          \"id-aes128-CCM\"\n#define LN_aes_128_ccm          \"aes-128-ccm\"\n#define NID_aes_128_ccm         896\n#define OBJ_aes_128_ccm         OBJ_aes,7L\n\n#define SN_id_aes128_wrap_pad           \"id-aes128-wrap-pad\"\n#define NID_id_aes128_wrap_pad          897\n#define OBJ_id_aes128_wrap_pad          OBJ_aes,8L\n\n#define SN_aes_192_ecb          \"AES-192-ECB\"\n#define LN_aes_192_ecb          \"aes-192-ecb\"\n#define NID_aes_192_ecb         422\n#define OBJ_aes_192_ecb         OBJ_aes,21L\n\n#define SN_aes_192_cbc          \"AES-192-CBC\"\n#define LN_aes_192_cbc          \"aes-192-cbc\"\n#define NID_aes_192_cbc         423\n#define OBJ_aes_192_cbc         OBJ_aes,22L\n\n#define SN_aes_192_ofb128               \"AES-192-OFB\"\n#define LN_aes_192_ofb128               \"aes-192-ofb\"\n#define NID_aes_192_ofb128              424\n#define OBJ_aes_192_ofb128              OBJ_aes,23L\n\n#define SN_aes_192_cfb128               \"AES-192-CFB\"\n#define LN_aes_192_cfb128               \"aes-192-cfb\"\n#define NID_aes_192_cfb128              425\n#define OBJ_aes_192_cfb128              OBJ_aes,24L\n\n#define SN_id_aes192_wrap               \"id-aes192-wrap\"\n#define NID_id_aes192_wrap              789\n#define OBJ_id_aes192_wrap              OBJ_aes,25L\n\n#define SN_aes_192_gcm          \"id-aes192-GCM\"\n#define LN_aes_192_gcm          \"aes-192-gcm\"\n#define NID_aes_192_gcm         898\n#define OBJ_aes_192_gcm         OBJ_aes,26L\n\n#define SN_aes_192_ccm          \"id-aes192-CCM\"\n#define LN_aes_192_ccm          \"aes-192-ccm\"\n#define NID_aes_192_ccm         899\n#define OBJ_aes_192_ccm         OBJ_aes,27L\n\n#define SN_id_aes192_wrap_pad           \"id-aes192-wrap-pad\"\n#define NID_id_aes192_wrap_pad          900\n#define OBJ_id_aes192_wrap_pad          OBJ_aes,28L\n\n#define SN_aes_256_ecb          \"AES-256-ECB\"\n#define LN_aes_256_ecb          \"aes-256-ecb\"\n#define NID_aes_256_ecb         426\n#define OBJ_aes_256_ecb         OBJ_aes,41L\n\n#define SN_aes_256_cbc          \"AES-256-CBC\"\n#define LN_aes_256_cbc          \"aes-256-cbc\"\n#define NID_aes_256_cbc         427\n#define OBJ_aes_256_cbc         OBJ_aes,42L\n\n#define SN_aes_256_ofb128               \"AES-256-OFB\"\n#define LN_aes_256_ofb128               \"aes-256-ofb\"\n#define NID_aes_256_ofb128              428\n#define OBJ_aes_256_ofb128              OBJ_aes,43L\n\n#define SN_aes_256_cfb128               \"AES-256-CFB\"\n#define LN_aes_256_cfb128               \"aes-256-cfb\"\n#define NID_aes_256_cfb128              429\n#define OBJ_aes_256_cfb128              OBJ_aes,44L\n\n#define SN_id_aes256_wrap               \"id-aes256-wrap\"\n#define NID_id_aes256_wrap              790\n#define OBJ_id_aes256_wrap              OBJ_aes,45L\n\n#define SN_aes_256_gcm          \"id-aes256-GCM\"\n#define LN_aes_256_gcm          \"aes-256-gcm\"\n#define NID_aes_256_gcm         901\n#define OBJ_aes_256_gcm         OBJ_aes,46L\n\n#define SN_aes_256_ccm          \"id-aes256-CCM\"\n#define LN_aes_256_ccm          \"aes-256-ccm\"\n#define NID_aes_256_ccm         902\n#define OBJ_aes_256_ccm         OBJ_aes,47L\n\n#define SN_id_aes256_wrap_pad           \"id-aes256-wrap-pad\"\n#define NID_id_aes256_wrap_pad          903\n#define OBJ_id_aes256_wrap_pad          OBJ_aes,48L\n\n#define SN_aes_128_cfb1         \"AES-128-CFB1\"\n#define LN_aes_128_cfb1         \"aes-128-cfb1\"\n#define NID_aes_128_cfb1                650\n\n#define SN_aes_192_cfb1         \"AES-192-CFB1\"\n#define LN_aes_192_cfb1         \"aes-192-cfb1\"\n#define NID_aes_192_cfb1                651\n\n#define SN_aes_256_cfb1         \"AES-256-CFB1\"\n#define LN_aes_256_cfb1         \"aes-256-cfb1\"\n#define NID_aes_256_cfb1                652\n\n#define SN_aes_128_cfb8         \"AES-128-CFB8\"\n#define LN_aes_128_cfb8         \"aes-128-cfb8\"\n#define NID_aes_128_cfb8                653\n\n#define SN_aes_192_cfb8         \"AES-192-CFB8\"\n#define LN_aes_192_cfb8         \"aes-192-cfb8\"\n#define NID_aes_192_cfb8                654\n\n#define SN_aes_256_cfb8         \"AES-256-CFB8\"\n#define LN_aes_256_cfb8         \"aes-256-cfb8\"\n#define NID_aes_256_cfb8                655\n\n#define SN_aes_128_ctr          \"AES-128-CTR\"\n#define LN_aes_128_ctr          \"aes-128-ctr\"\n#define NID_aes_128_ctr         904\n\n#define SN_aes_192_ctr          \"AES-192-CTR\"\n#define LN_aes_192_ctr          \"aes-192-ctr\"\n#define NID_aes_192_ctr         905\n\n#define SN_aes_256_ctr          \"AES-256-CTR\"\n#define LN_aes_256_ctr          \"aes-256-ctr\"\n#define NID_aes_256_ctr         906\n\n#define SN_aes_128_xts          \"AES-128-XTS\"\n#define LN_aes_128_xts          \"aes-128-xts\"\n#define NID_aes_128_xts         913\n\n#define SN_aes_256_xts          \"AES-256-XTS\"\n#define LN_aes_256_xts          \"aes-256-xts\"\n#define NID_aes_256_xts         914\n\n#define SN_des_cfb1             \"DES-CFB1\"\n#define LN_des_cfb1             \"des-cfb1\"\n#define NID_des_cfb1            656\n\n#define SN_des_cfb8             \"DES-CFB8\"\n#define LN_des_cfb8             \"des-cfb8\"\n#define NID_des_cfb8            657\n\n#define SN_des_ede3_cfb1                \"DES-EDE3-CFB1\"\n#define LN_des_ede3_cfb1                \"des-ede3-cfb1\"\n#define NID_des_ede3_cfb1               658\n\n#define SN_des_ede3_cfb8                \"DES-EDE3-CFB8\"\n#define LN_des_ede3_cfb8                \"des-ede3-cfb8\"\n#define NID_des_ede3_cfb8               659\n\n#define OBJ_nist_hashalgs               OBJ_nistAlgorithms,2L\n\n#define SN_sha256               \"SHA256\"\n#define LN_sha256               \"sha256\"\n#define NID_sha256              672\n#define OBJ_sha256              OBJ_nist_hashalgs,1L\n\n#define SN_sha384               \"SHA384\"\n#define LN_sha384               \"sha384\"\n#define NID_sha384              673\n#define OBJ_sha384              OBJ_nist_hashalgs,2L\n\n#define SN_sha512               \"SHA512\"\n#define LN_sha512               \"sha512\"\n#define NID_sha512              674\n#define OBJ_sha512              OBJ_nist_hashalgs,3L\n\n#define SN_sha224               \"SHA224\"\n#define LN_sha224               \"sha224\"\n#define NID_sha224              675\n#define OBJ_sha224              OBJ_nist_hashalgs,4L\n\n#define OBJ_dsa_with_sha2               OBJ_nistAlgorithms,3L\n\n#define SN_dsa_with_SHA224              \"dsa_with_SHA224\"\n#define NID_dsa_with_SHA224             802\n#define OBJ_dsa_with_SHA224             OBJ_dsa_with_sha2,1L\n\n#define SN_dsa_with_SHA256              \"dsa_with_SHA256\"\n#define NID_dsa_with_SHA256             803\n#define OBJ_dsa_with_SHA256             OBJ_dsa_with_sha2,2L\n\n#define SN_hold_instruction_code                \"holdInstructionCode\"\n#define LN_hold_instruction_code                \"Hold Instruction Code\"\n#define NID_hold_instruction_code               430\n#define OBJ_hold_instruction_code               OBJ_id_ce,23L\n\n#define OBJ_holdInstruction             OBJ_X9_57,2L\n\n#define SN_hold_instruction_none                \"holdInstructionNone\"\n#define LN_hold_instruction_none                \"Hold Instruction None\"\n#define NID_hold_instruction_none               431\n#define OBJ_hold_instruction_none               OBJ_holdInstruction,1L\n\n#define SN_hold_instruction_call_issuer         \"holdInstructionCallIssuer\"\n#define LN_hold_instruction_call_issuer         \"Hold Instruction Call Issuer\"\n#define NID_hold_instruction_call_issuer                432\n#define OBJ_hold_instruction_call_issuer                OBJ_holdInstruction,2L\n\n#define SN_hold_instruction_reject              \"holdInstructionReject\"\n#define LN_hold_instruction_reject              \"Hold Instruction Reject\"\n#define NID_hold_instruction_reject             433\n#define OBJ_hold_instruction_reject             OBJ_holdInstruction,3L\n\n#define SN_data         \"data\"\n#define NID_data                434\n#define OBJ_data                OBJ_itu_t,9L\n\n#define SN_pss          \"pss\"\n#define NID_pss         435\n#define OBJ_pss         OBJ_data,2342L\n\n#define SN_ucl          \"ucl\"\n#define NID_ucl         436\n#define OBJ_ucl         OBJ_pss,19200300L\n\n#define SN_pilot                \"pilot\"\n#define NID_pilot               437\n#define OBJ_pilot               OBJ_ucl,100L\n\n#define LN_pilotAttributeType           \"pilotAttributeType\"\n#define NID_pilotAttributeType          438\n#define OBJ_pilotAttributeType          OBJ_pilot,1L\n\n#define LN_pilotAttributeSyntax         \"pilotAttributeSyntax\"\n#define NID_pilotAttributeSyntax                439\n#define OBJ_pilotAttributeSyntax                OBJ_pilot,3L\n\n#define LN_pilotObjectClass             \"pilotObjectClass\"\n#define NID_pilotObjectClass            440\n#define OBJ_pilotObjectClass            OBJ_pilot,4L\n\n#define LN_pilotGroups          \"pilotGroups\"\n#define NID_pilotGroups         441\n#define OBJ_pilotGroups         OBJ_pilot,10L\n\n#define LN_iA5StringSyntax              \"iA5StringSyntax\"\n#define NID_iA5StringSyntax             442\n#define OBJ_iA5StringSyntax             OBJ_pilotAttributeSyntax,4L\n\n#define LN_caseIgnoreIA5StringSyntax            \"caseIgnoreIA5StringSyntax\"\n#define NID_caseIgnoreIA5StringSyntax           443\n#define OBJ_caseIgnoreIA5StringSyntax           OBJ_pilotAttributeSyntax,5L\n\n#define LN_pilotObject          \"pilotObject\"\n#define NID_pilotObject         444\n#define OBJ_pilotObject         OBJ_pilotObjectClass,3L\n\n#define LN_pilotPerson          \"pilotPerson\"\n#define NID_pilotPerson         445\n#define OBJ_pilotPerson         OBJ_pilotObjectClass,4L\n\n#define SN_account              \"account\"\n#define NID_account             446\n#define OBJ_account             OBJ_pilotObjectClass,5L\n\n#define SN_document             \"document\"\n#define NID_document            447\n#define OBJ_document            OBJ_pilotObjectClass,6L\n\n#define SN_room         \"room\"\n#define NID_room                448\n#define OBJ_room                OBJ_pilotObjectClass,7L\n\n#define LN_documentSeries               \"documentSeries\"\n#define NID_documentSeries              449\n#define OBJ_documentSeries              OBJ_pilotObjectClass,9L\n\n#define SN_Domain               \"domain\"\n#define LN_Domain               \"Domain\"\n#define NID_Domain              392\n#define OBJ_Domain              OBJ_pilotObjectClass,13L\n\n#define LN_rFC822localPart              \"rFC822localPart\"\n#define NID_rFC822localPart             450\n#define OBJ_rFC822localPart             OBJ_pilotObjectClass,14L\n\n#define LN_dNSDomain            \"dNSDomain\"\n#define NID_dNSDomain           451\n#define OBJ_dNSDomain           OBJ_pilotObjectClass,15L\n\n#define LN_domainRelatedObject          \"domainRelatedObject\"\n#define NID_domainRelatedObject         452\n#define OBJ_domainRelatedObject         OBJ_pilotObjectClass,17L\n\n#define LN_friendlyCountry              \"friendlyCountry\"\n#define NID_friendlyCountry             453\n#define OBJ_friendlyCountry             OBJ_pilotObjectClass,18L\n\n#define LN_simpleSecurityObject         \"simpleSecurityObject\"\n#define NID_simpleSecurityObject                454\n#define OBJ_simpleSecurityObject                OBJ_pilotObjectClass,19L\n\n#define LN_pilotOrganization            \"pilotOrganization\"\n#define NID_pilotOrganization           455\n#define OBJ_pilotOrganization           OBJ_pilotObjectClass,20L\n\n#define LN_pilotDSA             \"pilotDSA\"\n#define NID_pilotDSA            456\n#define OBJ_pilotDSA            OBJ_pilotObjectClass,21L\n\n#define LN_qualityLabelledData          \"qualityLabelledData\"\n#define NID_qualityLabelledData         457\n#define OBJ_qualityLabelledData         OBJ_pilotObjectClass,22L\n\n#define SN_userId               \"UID\"\n#define LN_userId               \"userId\"\n#define NID_userId              458\n#define OBJ_userId              OBJ_pilotAttributeType,1L\n\n#define LN_textEncodedORAddress         \"textEncodedORAddress\"\n#define NID_textEncodedORAddress                459\n#define OBJ_textEncodedORAddress                OBJ_pilotAttributeType,2L\n\n#define SN_rfc822Mailbox                \"mail\"\n#define LN_rfc822Mailbox                \"rfc822Mailbox\"\n#define NID_rfc822Mailbox               460\n#define OBJ_rfc822Mailbox               OBJ_pilotAttributeType,3L\n\n#define SN_info         \"info\"\n#define NID_info                461\n#define OBJ_info                OBJ_pilotAttributeType,4L\n\n#define LN_favouriteDrink               \"favouriteDrink\"\n#define NID_favouriteDrink              462\n#define OBJ_favouriteDrink              OBJ_pilotAttributeType,5L\n\n#define LN_roomNumber           \"roomNumber\"\n#define NID_roomNumber          463\n#define OBJ_roomNumber          OBJ_pilotAttributeType,6L\n\n#define SN_photo                \"photo\"\n#define NID_photo               464\n#define OBJ_photo               OBJ_pilotAttributeType,7L\n\n#define LN_userClass            \"userClass\"\n#define NID_userClass           465\n#define OBJ_userClass           OBJ_pilotAttributeType,8L\n\n#define SN_host         \"host\"\n#define NID_host                466\n#define OBJ_host                OBJ_pilotAttributeType,9L\n\n#define SN_manager              \"manager\"\n#define NID_manager             467\n#define OBJ_manager             OBJ_pilotAttributeType,10L\n\n#define LN_documentIdentifier           \"documentIdentifier\"\n#define NID_documentIdentifier          468\n#define OBJ_documentIdentifier          OBJ_pilotAttributeType,11L\n\n#define LN_documentTitle                \"documentTitle\"\n#define NID_documentTitle               469\n#define OBJ_documentTitle               OBJ_pilotAttributeType,12L\n\n#define LN_documentVersion              \"documentVersion\"\n#define NID_documentVersion             470\n#define OBJ_documentVersion             OBJ_pilotAttributeType,13L\n\n#define LN_documentAuthor               \"documentAuthor\"\n#define NID_documentAuthor              471\n#define OBJ_documentAuthor              OBJ_pilotAttributeType,14L\n\n#define LN_documentLocation             \"documentLocation\"\n#define NID_documentLocation            472\n#define OBJ_documentLocation            OBJ_pilotAttributeType,15L\n\n#define LN_homeTelephoneNumber          \"homeTelephoneNumber\"\n#define NID_homeTelephoneNumber         473\n#define OBJ_homeTelephoneNumber         OBJ_pilotAttributeType,20L\n\n#define SN_secretary            \"secretary\"\n#define NID_secretary           474\n#define OBJ_secretary           OBJ_pilotAttributeType,21L\n\n#define LN_otherMailbox         \"otherMailbox\"\n#define NID_otherMailbox                475\n#define OBJ_otherMailbox                OBJ_pilotAttributeType,22L\n\n#define LN_lastModifiedTime             \"lastModifiedTime\"\n#define NID_lastModifiedTime            476\n#define OBJ_lastModifiedTime            OBJ_pilotAttributeType,23L\n\n#define LN_lastModifiedBy               \"lastModifiedBy\"\n#define NID_lastModifiedBy              477\n#define OBJ_lastModifiedBy              OBJ_pilotAttributeType,24L\n\n#define SN_domainComponent              \"DC\"\n#define LN_domainComponent              \"domainComponent\"\n#define NID_domainComponent             391\n#define OBJ_domainComponent             OBJ_pilotAttributeType,25L\n\n#define LN_aRecord              \"aRecord\"\n#define NID_aRecord             478\n#define OBJ_aRecord             OBJ_pilotAttributeType,26L\n\n#define LN_pilotAttributeType27         \"pilotAttributeType27\"\n#define NID_pilotAttributeType27                479\n#define OBJ_pilotAttributeType27                OBJ_pilotAttributeType,27L\n\n#define LN_mXRecord             \"mXRecord\"\n#define NID_mXRecord            480\n#define OBJ_mXRecord            OBJ_pilotAttributeType,28L\n\n#define LN_nSRecord             \"nSRecord\"\n#define NID_nSRecord            481\n#define OBJ_nSRecord            OBJ_pilotAttributeType,29L\n\n#define LN_sOARecord            \"sOARecord\"\n#define NID_sOARecord           482\n#define OBJ_sOARecord           OBJ_pilotAttributeType,30L\n\n#define LN_cNAMERecord          \"cNAMERecord\"\n#define NID_cNAMERecord         483\n#define OBJ_cNAMERecord         OBJ_pilotAttributeType,31L\n\n#define LN_associatedDomain             \"associatedDomain\"\n#define NID_associatedDomain            484\n#define OBJ_associatedDomain            OBJ_pilotAttributeType,37L\n\n#define LN_associatedName               \"associatedName\"\n#define NID_associatedName              485\n#define OBJ_associatedName              OBJ_pilotAttributeType,38L\n\n#define LN_homePostalAddress            \"homePostalAddress\"\n#define NID_homePostalAddress           486\n#define OBJ_homePostalAddress           OBJ_pilotAttributeType,39L\n\n#define LN_personalTitle                \"personalTitle\"\n#define NID_personalTitle               487\n#define OBJ_personalTitle               OBJ_pilotAttributeType,40L\n\n#define LN_mobileTelephoneNumber                \"mobileTelephoneNumber\"\n#define NID_mobileTelephoneNumber               488\n#define OBJ_mobileTelephoneNumber               OBJ_pilotAttributeType,41L\n\n#define LN_pagerTelephoneNumber         \"pagerTelephoneNumber\"\n#define NID_pagerTelephoneNumber                489\n#define OBJ_pagerTelephoneNumber                OBJ_pilotAttributeType,42L\n\n#define LN_friendlyCountryName          \"friendlyCountryName\"\n#define NID_friendlyCountryName         490\n#define OBJ_friendlyCountryName         OBJ_pilotAttributeType,43L\n\n#define LN_organizationalStatus         \"organizationalStatus\"\n#define NID_organizationalStatus                491\n#define OBJ_organizationalStatus                OBJ_pilotAttributeType,45L\n\n#define LN_janetMailbox         \"janetMailbox\"\n#define NID_janetMailbox                492\n#define OBJ_janetMailbox                OBJ_pilotAttributeType,46L\n\n#define LN_mailPreferenceOption         \"mailPreferenceOption\"\n#define NID_mailPreferenceOption                493\n#define OBJ_mailPreferenceOption                OBJ_pilotAttributeType,47L\n\n#define LN_buildingName         \"buildingName\"\n#define NID_buildingName                494\n#define OBJ_buildingName                OBJ_pilotAttributeType,48L\n\n#define LN_dSAQuality           \"dSAQuality\"\n#define NID_dSAQuality          495\n#define OBJ_dSAQuality          OBJ_pilotAttributeType,49L\n\n#define LN_singleLevelQuality           \"singleLevelQuality\"\n#define NID_singleLevelQuality          496\n#define OBJ_singleLevelQuality          OBJ_pilotAttributeType,50L\n\n#define LN_subtreeMinimumQuality                \"subtreeMinimumQuality\"\n#define NID_subtreeMinimumQuality               497\n#define OBJ_subtreeMinimumQuality               OBJ_pilotAttributeType,51L\n\n#define LN_subtreeMaximumQuality                \"subtreeMaximumQuality\"\n#define NID_subtreeMaximumQuality               498\n#define OBJ_subtreeMaximumQuality               OBJ_pilotAttributeType,52L\n\n#define LN_personalSignature            \"personalSignature\"\n#define NID_personalSignature           499\n#define OBJ_personalSignature           OBJ_pilotAttributeType,53L\n\n#define LN_dITRedirect          \"dITRedirect\"\n#define NID_dITRedirect         500\n#define OBJ_dITRedirect         OBJ_pilotAttributeType,54L\n\n#define SN_audio                \"audio\"\n#define NID_audio               501\n#define OBJ_audio               OBJ_pilotAttributeType,55L\n\n#define LN_documentPublisher            \"documentPublisher\"\n#define NID_documentPublisher           502\n#define OBJ_documentPublisher           OBJ_pilotAttributeType,56L\n\n#define SN_id_set               \"id-set\"\n#define LN_id_set               \"Secure Electronic Transactions\"\n#define NID_id_set              512\n#define OBJ_id_set              OBJ_international_organizations,42L\n\n#define SN_set_ctype            \"set-ctype\"\n#define LN_set_ctype            \"content types\"\n#define NID_set_ctype           513\n#define OBJ_set_ctype           OBJ_id_set,0L\n\n#define SN_set_msgExt           \"set-msgExt\"\n#define LN_set_msgExt           \"message extensions\"\n#define NID_set_msgExt          514\n#define OBJ_set_msgExt          OBJ_id_set,1L\n\n#define SN_set_attr             \"set-attr\"\n#define NID_set_attr            515\n#define OBJ_set_attr            OBJ_id_set,3L\n\n#define SN_set_policy           \"set-policy\"\n#define NID_set_policy          516\n#define OBJ_set_policy          OBJ_id_set,5L\n\n#define SN_set_certExt          \"set-certExt\"\n#define LN_set_certExt          \"certificate extensions\"\n#define NID_set_certExt         517\n#define OBJ_set_certExt         OBJ_id_set,7L\n\n#define SN_set_brand            \"set-brand\"\n#define NID_set_brand           518\n#define OBJ_set_brand           OBJ_id_set,8L\n\n#define SN_setct_PANData                \"setct-PANData\"\n#define NID_setct_PANData               519\n#define OBJ_setct_PANData               OBJ_set_ctype,0L\n\n#define SN_setct_PANToken               \"setct-PANToken\"\n#define NID_setct_PANToken              520\n#define OBJ_setct_PANToken              OBJ_set_ctype,1L\n\n#define SN_setct_PANOnly                \"setct-PANOnly\"\n#define NID_setct_PANOnly               521\n#define OBJ_setct_PANOnly               OBJ_set_ctype,2L\n\n#define SN_setct_OIData         \"setct-OIData\"\n#define NID_setct_OIData                522\n#define OBJ_setct_OIData                OBJ_set_ctype,3L\n\n#define SN_setct_PI             \"setct-PI\"\n#define NID_setct_PI            523\n#define OBJ_setct_PI            OBJ_set_ctype,4L\n\n#define SN_setct_PIData         \"setct-PIData\"\n#define NID_setct_PIData                524\n#define OBJ_setct_PIData                OBJ_set_ctype,5L\n\n#define SN_setct_PIDataUnsigned         \"setct-PIDataUnsigned\"\n#define NID_setct_PIDataUnsigned                525\n#define OBJ_setct_PIDataUnsigned                OBJ_set_ctype,6L\n\n#define SN_setct_HODInput               \"setct-HODInput\"\n#define NID_setct_HODInput              526\n#define OBJ_setct_HODInput              OBJ_set_ctype,7L\n\n#define SN_setct_AuthResBaggage         \"setct-AuthResBaggage\"\n#define NID_setct_AuthResBaggage                527\n#define OBJ_setct_AuthResBaggage                OBJ_set_ctype,8L\n\n#define SN_setct_AuthRevReqBaggage              \"setct-AuthRevReqBaggage\"\n#define NID_setct_AuthRevReqBaggage             528\n#define OBJ_setct_AuthRevReqBaggage             OBJ_set_ctype,9L\n\n#define SN_setct_AuthRevResBaggage              \"setct-AuthRevResBaggage\"\n#define NID_setct_AuthRevResBaggage             529\n#define OBJ_setct_AuthRevResBaggage             OBJ_set_ctype,10L\n\n#define SN_setct_CapTokenSeq            \"setct-CapTokenSeq\"\n#define NID_setct_CapTokenSeq           530\n#define OBJ_setct_CapTokenSeq           OBJ_set_ctype,11L\n\n#define SN_setct_PInitResData           \"setct-PInitResData\"\n#define NID_setct_PInitResData          531\n#define OBJ_setct_PInitResData          OBJ_set_ctype,12L\n\n#define SN_setct_PI_TBS         \"setct-PI-TBS\"\n#define NID_setct_PI_TBS                532\n#define OBJ_setct_PI_TBS                OBJ_set_ctype,13L\n\n#define SN_setct_PResData               \"setct-PResData\"\n#define NID_setct_PResData              533\n#define OBJ_setct_PResData              OBJ_set_ctype,14L\n\n#define SN_setct_AuthReqTBS             \"setct-AuthReqTBS\"\n#define NID_setct_AuthReqTBS            534\n#define OBJ_setct_AuthReqTBS            OBJ_set_ctype,16L\n\n#define SN_setct_AuthResTBS             \"setct-AuthResTBS\"\n#define NID_setct_AuthResTBS            535\n#define OBJ_setct_AuthResTBS            OBJ_set_ctype,17L\n\n#define SN_setct_AuthResTBSX            \"setct-AuthResTBSX\"\n#define NID_setct_AuthResTBSX           536\n#define OBJ_setct_AuthResTBSX           OBJ_set_ctype,18L\n\n#define SN_setct_AuthTokenTBS           \"setct-AuthTokenTBS\"\n#define NID_setct_AuthTokenTBS          537\n#define OBJ_setct_AuthTokenTBS          OBJ_set_ctype,19L\n\n#define SN_setct_CapTokenData           \"setct-CapTokenData\"\n#define NID_setct_CapTokenData          538\n#define OBJ_setct_CapTokenData          OBJ_set_ctype,20L\n\n#define SN_setct_CapTokenTBS            \"setct-CapTokenTBS\"\n#define NID_setct_CapTokenTBS           539\n#define OBJ_setct_CapTokenTBS           OBJ_set_ctype,21L\n\n#define SN_setct_AcqCardCodeMsg         \"setct-AcqCardCodeMsg\"\n#define NID_setct_AcqCardCodeMsg                540\n#define OBJ_setct_AcqCardCodeMsg                OBJ_set_ctype,22L\n\n#define SN_setct_AuthRevReqTBS          \"setct-AuthRevReqTBS\"\n#define NID_setct_AuthRevReqTBS         541\n#define OBJ_setct_AuthRevReqTBS         OBJ_set_ctype,23L\n\n#define SN_setct_AuthRevResData         \"setct-AuthRevResData\"\n#define NID_setct_AuthRevResData                542\n#define OBJ_setct_AuthRevResData                OBJ_set_ctype,24L\n\n#define SN_setct_AuthRevResTBS          \"setct-AuthRevResTBS\"\n#define NID_setct_AuthRevResTBS         543\n#define OBJ_setct_AuthRevResTBS         OBJ_set_ctype,25L\n\n#define SN_setct_CapReqTBS              \"setct-CapReqTBS\"\n#define NID_setct_CapReqTBS             544\n#define OBJ_setct_CapReqTBS             OBJ_set_ctype,26L\n\n#define SN_setct_CapReqTBSX             \"setct-CapReqTBSX\"\n#define NID_setct_CapReqTBSX            545\n#define OBJ_setct_CapReqTBSX            OBJ_set_ctype,27L\n\n#define SN_setct_CapResData             \"setct-CapResData\"\n#define NID_setct_CapResData            546\n#define OBJ_setct_CapResData            OBJ_set_ctype,28L\n\n#define SN_setct_CapRevReqTBS           \"setct-CapRevReqTBS\"\n#define NID_setct_CapRevReqTBS          547\n#define OBJ_setct_CapRevReqTBS          OBJ_set_ctype,29L\n\n#define SN_setct_CapRevReqTBSX          \"setct-CapRevReqTBSX\"\n#define NID_setct_CapRevReqTBSX         548\n#define OBJ_setct_CapRevReqTBSX         OBJ_set_ctype,30L\n\n#define SN_setct_CapRevResData          \"setct-CapRevResData\"\n#define NID_setct_CapRevResData         549\n#define OBJ_setct_CapRevResData         OBJ_set_ctype,31L\n\n#define SN_setct_CredReqTBS             \"setct-CredReqTBS\"\n#define NID_setct_CredReqTBS            550\n#define OBJ_setct_CredReqTBS            OBJ_set_ctype,32L\n\n#define SN_setct_CredReqTBSX            \"setct-CredReqTBSX\"\n#define NID_setct_CredReqTBSX           551\n#define OBJ_setct_CredReqTBSX           OBJ_set_ctype,33L\n\n#define SN_setct_CredResData            \"setct-CredResData\"\n#define NID_setct_CredResData           552\n#define OBJ_setct_CredResData           OBJ_set_ctype,34L\n\n#define SN_setct_CredRevReqTBS          \"setct-CredRevReqTBS\"\n#define NID_setct_CredRevReqTBS         553\n#define OBJ_setct_CredRevReqTBS         OBJ_set_ctype,35L\n\n#define SN_setct_CredRevReqTBSX         \"setct-CredRevReqTBSX\"\n#define NID_setct_CredRevReqTBSX                554\n#define OBJ_setct_CredRevReqTBSX                OBJ_set_ctype,36L\n\n#define SN_setct_CredRevResData         \"setct-CredRevResData\"\n#define NID_setct_CredRevResData                555\n#define OBJ_setct_CredRevResData                OBJ_set_ctype,37L\n\n#define SN_setct_PCertReqData           \"setct-PCertReqData\"\n#define NID_setct_PCertReqData          556\n#define OBJ_setct_PCertReqData          OBJ_set_ctype,38L\n\n#define SN_setct_PCertResTBS            \"setct-PCertResTBS\"\n#define NID_setct_PCertResTBS           557\n#define OBJ_setct_PCertResTBS           OBJ_set_ctype,39L\n\n#define SN_setct_BatchAdminReqData              \"setct-BatchAdminReqData\"\n#define NID_setct_BatchAdminReqData             558\n#define OBJ_setct_BatchAdminReqData             OBJ_set_ctype,40L\n\n#define SN_setct_BatchAdminResData              \"setct-BatchAdminResData\"\n#define NID_setct_BatchAdminResData             559\n#define OBJ_setct_BatchAdminResData             OBJ_set_ctype,41L\n\n#define SN_setct_CardCInitResTBS                \"setct-CardCInitResTBS\"\n#define NID_setct_CardCInitResTBS               560\n#define OBJ_setct_CardCInitResTBS               OBJ_set_ctype,42L\n\n#define SN_setct_MeAqCInitResTBS                \"setct-MeAqCInitResTBS\"\n#define NID_setct_MeAqCInitResTBS               561\n#define OBJ_setct_MeAqCInitResTBS               OBJ_set_ctype,43L\n\n#define SN_setct_RegFormResTBS          \"setct-RegFormResTBS\"\n#define NID_setct_RegFormResTBS         562\n#define OBJ_setct_RegFormResTBS         OBJ_set_ctype,44L\n\n#define SN_setct_CertReqData            \"setct-CertReqData\"\n#define NID_setct_CertReqData           563\n#define OBJ_setct_CertReqData           OBJ_set_ctype,45L\n\n#define SN_setct_CertReqTBS             \"setct-CertReqTBS\"\n#define NID_setct_CertReqTBS            564\n#define OBJ_setct_CertReqTBS            OBJ_set_ctype,46L\n\n#define SN_setct_CertResData            \"setct-CertResData\"\n#define NID_setct_CertResData           565\n#define OBJ_setct_CertResData           OBJ_set_ctype,47L\n\n#define SN_setct_CertInqReqTBS          \"setct-CertInqReqTBS\"\n#define NID_setct_CertInqReqTBS         566\n#define OBJ_setct_CertInqReqTBS         OBJ_set_ctype,48L\n\n#define SN_setct_ErrorTBS               \"setct-ErrorTBS\"\n#define NID_setct_ErrorTBS              567\n#define OBJ_setct_ErrorTBS              OBJ_set_ctype,49L\n\n#define SN_setct_PIDualSignedTBE                \"setct-PIDualSignedTBE\"\n#define NID_setct_PIDualSignedTBE               568\n#define OBJ_setct_PIDualSignedTBE               OBJ_set_ctype,50L\n\n#define SN_setct_PIUnsignedTBE          \"setct-PIUnsignedTBE\"\n#define NID_setct_PIUnsignedTBE         569\n#define OBJ_setct_PIUnsignedTBE         OBJ_set_ctype,51L\n\n#define SN_setct_AuthReqTBE             \"setct-AuthReqTBE\"\n#define NID_setct_AuthReqTBE            570\n#define OBJ_setct_AuthReqTBE            OBJ_set_ctype,52L\n\n#define SN_setct_AuthResTBE             \"setct-AuthResTBE\"\n#define NID_setct_AuthResTBE            571\n#define OBJ_setct_AuthResTBE            OBJ_set_ctype,53L\n\n#define SN_setct_AuthResTBEX            \"setct-AuthResTBEX\"\n#define NID_setct_AuthResTBEX           572\n#define OBJ_setct_AuthResTBEX           OBJ_set_ctype,54L\n\n#define SN_setct_AuthTokenTBE           \"setct-AuthTokenTBE\"\n#define NID_setct_AuthTokenTBE          573\n#define OBJ_setct_AuthTokenTBE          OBJ_set_ctype,55L\n\n#define SN_setct_CapTokenTBE            \"setct-CapTokenTBE\"\n#define NID_setct_CapTokenTBE           574\n#define OBJ_setct_CapTokenTBE           OBJ_set_ctype,56L\n\n#define SN_setct_CapTokenTBEX           \"setct-CapTokenTBEX\"\n#define NID_setct_CapTokenTBEX          575\n#define OBJ_setct_CapTokenTBEX          OBJ_set_ctype,57L\n\n#define SN_setct_AcqCardCodeMsgTBE              \"setct-AcqCardCodeMsgTBE\"\n#define NID_setct_AcqCardCodeMsgTBE             576\n#define OBJ_setct_AcqCardCodeMsgTBE             OBJ_set_ctype,58L\n\n#define SN_setct_AuthRevReqTBE          \"setct-AuthRevReqTBE\"\n#define NID_setct_AuthRevReqTBE         577\n#define OBJ_setct_AuthRevReqTBE         OBJ_set_ctype,59L\n\n#define SN_setct_AuthRevResTBE          \"setct-AuthRevResTBE\"\n#define NID_setct_AuthRevResTBE         578\n#define OBJ_setct_AuthRevResTBE         OBJ_set_ctype,60L\n\n#define SN_setct_AuthRevResTBEB         \"setct-AuthRevResTBEB\"\n#define NID_setct_AuthRevResTBEB                579\n#define OBJ_setct_AuthRevResTBEB                OBJ_set_ctype,61L\n\n#define SN_setct_CapReqTBE              \"setct-CapReqTBE\"\n#define NID_setct_CapReqTBE             580\n#define OBJ_setct_CapReqTBE             OBJ_set_ctype,62L\n\n#define SN_setct_CapReqTBEX             \"setct-CapReqTBEX\"\n#define NID_setct_CapReqTBEX            581\n#define OBJ_setct_CapReqTBEX            OBJ_set_ctype,63L\n\n#define SN_setct_CapResTBE              \"setct-CapResTBE\"\n#define NID_setct_CapResTBE             582\n#define OBJ_setct_CapResTBE             OBJ_set_ctype,64L\n\n#define SN_setct_CapRevReqTBE           \"setct-CapRevReqTBE\"\n#define NID_setct_CapRevReqTBE          583\n#define OBJ_setct_CapRevReqTBE          OBJ_set_ctype,65L\n\n#define SN_setct_CapRevReqTBEX          \"setct-CapRevReqTBEX\"\n#define NID_setct_CapRevReqTBEX         584\n#define OBJ_setct_CapRevReqTBEX         OBJ_set_ctype,66L\n\n#define SN_setct_CapRevResTBE           \"setct-CapRevResTBE\"\n#define NID_setct_CapRevResTBE          585\n#define OBJ_setct_CapRevResTBE          OBJ_set_ctype,67L\n\n#define SN_setct_CredReqTBE             \"setct-CredReqTBE\"\n#define NID_setct_CredReqTBE            586\n#define OBJ_setct_CredReqTBE            OBJ_set_ctype,68L\n\n#define SN_setct_CredReqTBEX            \"setct-CredReqTBEX\"\n#define NID_setct_CredReqTBEX           587\n#define OBJ_setct_CredReqTBEX           OBJ_set_ctype,69L\n\n#define SN_setct_CredResTBE             \"setct-CredResTBE\"\n#define NID_setct_CredResTBE            588\n#define OBJ_setct_CredResTBE            OBJ_set_ctype,70L\n\n#define SN_setct_CredRevReqTBE          \"setct-CredRevReqTBE\"\n#define NID_setct_CredRevReqTBE         589\n#define OBJ_setct_CredRevReqTBE         OBJ_set_ctype,71L\n\n#define SN_setct_CredRevReqTBEX         \"setct-CredRevReqTBEX\"\n#define NID_setct_CredRevReqTBEX                590\n#define OBJ_setct_CredRevReqTBEX                OBJ_set_ctype,72L\n\n#define SN_setct_CredRevResTBE          \"setct-CredRevResTBE\"\n#define NID_setct_CredRevResTBE         591\n#define OBJ_setct_CredRevResTBE         OBJ_set_ctype,73L\n\n#define SN_setct_BatchAdminReqTBE               \"setct-BatchAdminReqTBE\"\n#define NID_setct_BatchAdminReqTBE              592\n#define OBJ_setct_BatchAdminReqTBE              OBJ_set_ctype,74L\n\n#define SN_setct_BatchAdminResTBE               \"setct-BatchAdminResTBE\"\n#define NID_setct_BatchAdminResTBE              593\n#define OBJ_setct_BatchAdminResTBE              OBJ_set_ctype,75L\n\n#define SN_setct_RegFormReqTBE          \"setct-RegFormReqTBE\"\n#define NID_setct_RegFormReqTBE         594\n#define OBJ_setct_RegFormReqTBE         OBJ_set_ctype,76L\n\n#define SN_setct_CertReqTBE             \"setct-CertReqTBE\"\n#define NID_setct_CertReqTBE            595\n#define OBJ_setct_CertReqTBE            OBJ_set_ctype,77L\n\n#define SN_setct_CertReqTBEX            \"setct-CertReqTBEX\"\n#define NID_setct_CertReqTBEX           596\n#define OBJ_setct_CertReqTBEX           OBJ_set_ctype,78L\n\n#define SN_setct_CertResTBE             \"setct-CertResTBE\"\n#define NID_setct_CertResTBE            597\n#define OBJ_setct_CertResTBE            OBJ_set_ctype,79L\n\n#define SN_setct_CRLNotificationTBS             \"setct-CRLNotificationTBS\"\n#define NID_setct_CRLNotificationTBS            598\n#define OBJ_setct_CRLNotificationTBS            OBJ_set_ctype,80L\n\n#define SN_setct_CRLNotificationResTBS          \"setct-CRLNotificationResTBS\"\n#define NID_setct_CRLNotificationResTBS         599\n#define OBJ_setct_CRLNotificationResTBS         OBJ_set_ctype,81L\n\n#define SN_setct_BCIDistributionTBS             \"setct-BCIDistributionTBS\"\n#define NID_setct_BCIDistributionTBS            600\n#define OBJ_setct_BCIDistributionTBS            OBJ_set_ctype,82L\n\n#define SN_setext_genCrypt              \"setext-genCrypt\"\n#define LN_setext_genCrypt              \"generic cryptogram\"\n#define NID_setext_genCrypt             601\n#define OBJ_setext_genCrypt             OBJ_set_msgExt,1L\n\n#define SN_setext_miAuth                \"setext-miAuth\"\n#define LN_setext_miAuth                \"merchant initiated auth\"\n#define NID_setext_miAuth               602\n#define OBJ_setext_miAuth               OBJ_set_msgExt,3L\n\n#define SN_setext_pinSecure             \"setext-pinSecure\"\n#define NID_setext_pinSecure            603\n#define OBJ_setext_pinSecure            OBJ_set_msgExt,4L\n\n#define SN_setext_pinAny                \"setext-pinAny\"\n#define NID_setext_pinAny               604\n#define OBJ_setext_pinAny               OBJ_set_msgExt,5L\n\n#define SN_setext_track2                \"setext-track2\"\n#define NID_setext_track2               605\n#define OBJ_setext_track2               OBJ_set_msgExt,7L\n\n#define SN_setext_cv            \"setext-cv\"\n#define LN_setext_cv            \"additional verification\"\n#define NID_setext_cv           606\n#define OBJ_setext_cv           OBJ_set_msgExt,8L\n\n#define SN_set_policy_root              \"set-policy-root\"\n#define NID_set_policy_root             607\n#define OBJ_set_policy_root             OBJ_set_policy,0L\n\n#define SN_setCext_hashedRoot           \"setCext-hashedRoot\"\n#define NID_setCext_hashedRoot          608\n#define OBJ_setCext_hashedRoot          OBJ_set_certExt,0L\n\n#define SN_setCext_certType             \"setCext-certType\"\n#define NID_setCext_certType            609\n#define OBJ_setCext_certType            OBJ_set_certExt,1L\n\n#define SN_setCext_merchData            \"setCext-merchData\"\n#define NID_setCext_merchData           610\n#define OBJ_setCext_merchData           OBJ_set_certExt,2L\n\n#define SN_setCext_cCertRequired                \"setCext-cCertRequired\"\n#define NID_setCext_cCertRequired               611\n#define OBJ_setCext_cCertRequired               OBJ_set_certExt,3L\n\n#define SN_setCext_tunneling            \"setCext-tunneling\"\n#define NID_setCext_tunneling           612\n#define OBJ_setCext_tunneling           OBJ_set_certExt,4L\n\n#define SN_setCext_setExt               \"setCext-setExt\"\n#define NID_setCext_setExt              613\n#define OBJ_setCext_setExt              OBJ_set_certExt,5L\n\n#define SN_setCext_setQualf             \"setCext-setQualf\"\n#define NID_setCext_setQualf            614\n#define OBJ_setCext_setQualf            OBJ_set_certExt,6L\n\n#define SN_setCext_PGWYcapabilities             \"setCext-PGWYcapabilities\"\n#define NID_setCext_PGWYcapabilities            615\n#define OBJ_setCext_PGWYcapabilities            OBJ_set_certExt,7L\n\n#define SN_setCext_TokenIdentifier              \"setCext-TokenIdentifier\"\n#define NID_setCext_TokenIdentifier             616\n#define OBJ_setCext_TokenIdentifier             OBJ_set_certExt,8L\n\n#define SN_setCext_Track2Data           \"setCext-Track2Data\"\n#define NID_setCext_Track2Data          617\n#define OBJ_setCext_Track2Data          OBJ_set_certExt,9L\n\n#define SN_setCext_TokenType            \"setCext-TokenType\"\n#define NID_setCext_TokenType           618\n#define OBJ_setCext_TokenType           OBJ_set_certExt,10L\n\n#define SN_setCext_IssuerCapabilities           \"setCext-IssuerCapabilities\"\n#define NID_setCext_IssuerCapabilities          619\n#define OBJ_setCext_IssuerCapabilities          OBJ_set_certExt,11L\n\n#define SN_setAttr_Cert         \"setAttr-Cert\"\n#define NID_setAttr_Cert                620\n#define OBJ_setAttr_Cert                OBJ_set_attr,0L\n\n#define SN_setAttr_PGWYcap              \"setAttr-PGWYcap\"\n#define LN_setAttr_PGWYcap              \"payment gateway capabilities\"\n#define NID_setAttr_PGWYcap             621\n#define OBJ_setAttr_PGWYcap             OBJ_set_attr,1L\n\n#define SN_setAttr_TokenType            \"setAttr-TokenType\"\n#define NID_setAttr_TokenType           622\n#define OBJ_setAttr_TokenType           OBJ_set_attr,2L\n\n#define SN_setAttr_IssCap               \"setAttr-IssCap\"\n#define LN_setAttr_IssCap               \"issuer capabilities\"\n#define NID_setAttr_IssCap              623\n#define OBJ_setAttr_IssCap              OBJ_set_attr,3L\n\n#define SN_set_rootKeyThumb             \"set-rootKeyThumb\"\n#define NID_set_rootKeyThumb            624\n#define OBJ_set_rootKeyThumb            OBJ_setAttr_Cert,0L\n\n#define SN_set_addPolicy                \"set-addPolicy\"\n#define NID_set_addPolicy               625\n#define OBJ_set_addPolicy               OBJ_setAttr_Cert,1L\n\n#define SN_setAttr_Token_EMV            \"setAttr-Token-EMV\"\n#define NID_setAttr_Token_EMV           626\n#define OBJ_setAttr_Token_EMV           OBJ_setAttr_TokenType,1L\n\n#define SN_setAttr_Token_B0Prime                \"setAttr-Token-B0Prime\"\n#define NID_setAttr_Token_B0Prime               627\n#define OBJ_setAttr_Token_B0Prime               OBJ_setAttr_TokenType,2L\n\n#define SN_setAttr_IssCap_CVM           \"setAttr-IssCap-CVM\"\n#define NID_setAttr_IssCap_CVM          628\n#define OBJ_setAttr_IssCap_CVM          OBJ_setAttr_IssCap,3L\n\n#define SN_setAttr_IssCap_T2            \"setAttr-IssCap-T2\"\n#define NID_setAttr_IssCap_T2           629\n#define OBJ_setAttr_IssCap_T2           OBJ_setAttr_IssCap,4L\n\n#define SN_setAttr_IssCap_Sig           \"setAttr-IssCap-Sig\"\n#define NID_setAttr_IssCap_Sig          630\n#define OBJ_setAttr_IssCap_Sig          OBJ_setAttr_IssCap,5L\n\n#define SN_setAttr_GenCryptgrm          \"setAttr-GenCryptgrm\"\n#define LN_setAttr_GenCryptgrm          \"generate cryptogram\"\n#define NID_setAttr_GenCryptgrm         631\n#define OBJ_setAttr_GenCryptgrm         OBJ_setAttr_IssCap_CVM,1L\n\n#define SN_setAttr_T2Enc                \"setAttr-T2Enc\"\n#define LN_setAttr_T2Enc                \"encrypted track 2\"\n#define NID_setAttr_T2Enc               632\n#define OBJ_setAttr_T2Enc               OBJ_setAttr_IssCap_T2,1L\n\n#define SN_setAttr_T2cleartxt           \"setAttr-T2cleartxt\"\n#define LN_setAttr_T2cleartxt           \"cleartext track 2\"\n#define NID_setAttr_T2cleartxt          633\n#define OBJ_setAttr_T2cleartxt          OBJ_setAttr_IssCap_T2,2L\n\n#define SN_setAttr_TokICCsig            \"setAttr-TokICCsig\"\n#define LN_setAttr_TokICCsig            \"ICC or token signature\"\n#define NID_setAttr_TokICCsig           634\n#define OBJ_setAttr_TokICCsig           OBJ_setAttr_IssCap_Sig,1L\n\n#define SN_setAttr_SecDevSig            \"setAttr-SecDevSig\"\n#define LN_setAttr_SecDevSig            \"secure device signature\"\n#define NID_setAttr_SecDevSig           635\n#define OBJ_setAttr_SecDevSig           OBJ_setAttr_IssCap_Sig,2L\n\n#define SN_set_brand_IATA_ATA           \"set-brand-IATA-ATA\"\n#define NID_set_brand_IATA_ATA          636\n#define OBJ_set_brand_IATA_ATA          OBJ_set_brand,1L\n\n#define SN_set_brand_Diners             \"set-brand-Diners\"\n#define NID_set_brand_Diners            637\n#define OBJ_set_brand_Diners            OBJ_set_brand,30L\n\n#define SN_set_brand_AmericanExpress            \"set-brand-AmericanExpress\"\n#define NID_set_brand_AmericanExpress           638\n#define OBJ_set_brand_AmericanExpress           OBJ_set_brand,34L\n\n#define SN_set_brand_JCB                \"set-brand-JCB\"\n#define NID_set_brand_JCB               639\n#define OBJ_set_brand_JCB               OBJ_set_brand,35L\n\n#define SN_set_brand_Visa               \"set-brand-Visa\"\n#define NID_set_brand_Visa              640\n#define OBJ_set_brand_Visa              OBJ_set_brand,4L\n\n#define SN_set_brand_MasterCard         \"set-brand-MasterCard\"\n#define NID_set_brand_MasterCard                641\n#define OBJ_set_brand_MasterCard                OBJ_set_brand,5L\n\n#define SN_set_brand_Novus              \"set-brand-Novus\"\n#define NID_set_brand_Novus             642\n#define OBJ_set_brand_Novus             OBJ_set_brand,6011L\n\n#define SN_des_cdmf             \"DES-CDMF\"\n#define LN_des_cdmf             \"des-cdmf\"\n#define NID_des_cdmf            643\n#define OBJ_des_cdmf            OBJ_rsadsi,3L,10L\n\n#define SN_rsaOAEPEncryptionSET         \"rsaOAEPEncryptionSET\"\n#define NID_rsaOAEPEncryptionSET                644\n#define OBJ_rsaOAEPEncryptionSET                OBJ_rsadsi,1L,1L,6L\n\n#define SN_ipsec3               \"Oakley-EC2N-3\"\n#define LN_ipsec3               \"ipsec3\"\n#define NID_ipsec3              749\n\n#define SN_ipsec4               \"Oakley-EC2N-4\"\n#define LN_ipsec4               \"ipsec4\"\n#define NID_ipsec4              750\n\n#define SN_whirlpool            \"whirlpool\"\n#define NID_whirlpool           804\n#define OBJ_whirlpool           OBJ_iso,0L,10118L,3L,0L,55L\n\n#define SN_cryptopro            \"cryptopro\"\n#define NID_cryptopro           805\n#define OBJ_cryptopro           OBJ_member_body,643L,2L,2L\n\n#define SN_cryptocom            \"cryptocom\"\n#define NID_cryptocom           806\n#define OBJ_cryptocom           OBJ_member_body,643L,2L,9L\n\n#define SN_id_GostR3411_94_with_GostR3410_2001          \"id-GostR3411-94-with-GostR3410-2001\"\n#define LN_id_GostR3411_94_with_GostR3410_2001          \"GOST R 34.11-94 with GOST R 34.10-2001\"\n#define NID_id_GostR3411_94_with_GostR3410_2001         807\n#define OBJ_id_GostR3411_94_with_GostR3410_2001         OBJ_cryptopro,3L\n\n#define SN_id_GostR3411_94_with_GostR3410_94            \"id-GostR3411-94-with-GostR3410-94\"\n#define LN_id_GostR3411_94_with_GostR3410_94            \"GOST R 34.11-94 with GOST R 34.10-94\"\n#define NID_id_GostR3411_94_with_GostR3410_94           808\n#define OBJ_id_GostR3411_94_with_GostR3410_94           OBJ_cryptopro,4L\n\n#define SN_id_GostR3411_94              \"md_gost94\"\n#define LN_id_GostR3411_94              \"GOST R 34.11-94\"\n#define NID_id_GostR3411_94             809\n#define OBJ_id_GostR3411_94             OBJ_cryptopro,9L\n\n#define SN_id_HMACGostR3411_94          \"id-HMACGostR3411-94\"\n#define LN_id_HMACGostR3411_94          \"HMAC GOST 34.11-94\"\n#define NID_id_HMACGostR3411_94         810\n#define OBJ_id_HMACGostR3411_94         OBJ_cryptopro,10L\n\n#define SN_id_GostR3410_2001            \"gost2001\"\n#define LN_id_GostR3410_2001            \"GOST R 34.10-2001\"\n#define NID_id_GostR3410_2001           811\n#define OBJ_id_GostR3410_2001           OBJ_cryptopro,19L\n\n#define SN_id_GostR3410_94              \"gost94\"\n#define LN_id_GostR3410_94              \"GOST R 34.10-94\"\n#define NID_id_GostR3410_94             812\n#define OBJ_id_GostR3410_94             OBJ_cryptopro,20L\n\n#define SN_id_Gost28147_89              \"gost89\"\n#define LN_id_Gost28147_89              \"GOST 28147-89\"\n#define NID_id_Gost28147_89             813\n#define OBJ_id_Gost28147_89             OBJ_cryptopro,21L\n\n#define SN_gost89_cnt           \"gost89-cnt\"\n#define NID_gost89_cnt          814\n\n#define SN_id_Gost28147_89_MAC          \"gost-mac\"\n#define LN_id_Gost28147_89_MAC          \"GOST 28147-89 MAC\"\n#define NID_id_Gost28147_89_MAC         815\n#define OBJ_id_Gost28147_89_MAC         OBJ_cryptopro,22L\n\n#define SN_id_GostR3411_94_prf          \"prf-gostr3411-94\"\n#define LN_id_GostR3411_94_prf          \"GOST R 34.11-94 PRF\"\n#define NID_id_GostR3411_94_prf         816\n#define OBJ_id_GostR3411_94_prf         OBJ_cryptopro,23L\n\n#define SN_id_GostR3410_2001DH          \"id-GostR3410-2001DH\"\n#define LN_id_GostR3410_2001DH          \"GOST R 34.10-2001 DH\"\n#define NID_id_GostR3410_2001DH         817\n#define OBJ_id_GostR3410_2001DH         OBJ_cryptopro,98L\n\n#define SN_id_GostR3410_94DH            \"id-GostR3410-94DH\"\n#define LN_id_GostR3410_94DH            \"GOST R 34.10-94 DH\"\n#define NID_id_GostR3410_94DH           818\n#define OBJ_id_GostR3410_94DH           OBJ_cryptopro,99L\n\n#define SN_id_Gost28147_89_CryptoPro_KeyMeshing         \"id-Gost28147-89-CryptoPro-KeyMeshing\"\n#define NID_id_Gost28147_89_CryptoPro_KeyMeshing                819\n#define OBJ_id_Gost28147_89_CryptoPro_KeyMeshing                OBJ_cryptopro,14L,1L\n\n#define SN_id_Gost28147_89_None_KeyMeshing              \"id-Gost28147-89-None-KeyMeshing\"\n#define NID_id_Gost28147_89_None_KeyMeshing             820\n#define OBJ_id_Gost28147_89_None_KeyMeshing             OBJ_cryptopro,14L,0L\n\n#define SN_id_GostR3411_94_TestParamSet         \"id-GostR3411-94-TestParamSet\"\n#define NID_id_GostR3411_94_TestParamSet                821\n#define OBJ_id_GostR3411_94_TestParamSet                OBJ_cryptopro,30L,0L\n\n#define SN_id_GostR3411_94_CryptoProParamSet            \"id-GostR3411-94-CryptoProParamSet\"\n#define NID_id_GostR3411_94_CryptoProParamSet           822\n#define OBJ_id_GostR3411_94_CryptoProParamSet           OBJ_cryptopro,30L,1L\n\n#define SN_id_Gost28147_89_TestParamSet         \"id-Gost28147-89-TestParamSet\"\n#define NID_id_Gost28147_89_TestParamSet                823\n#define OBJ_id_Gost28147_89_TestParamSet                OBJ_cryptopro,31L,0L\n\n#define SN_id_Gost28147_89_CryptoPro_A_ParamSet         \"id-Gost28147-89-CryptoPro-A-ParamSet\"\n#define NID_id_Gost28147_89_CryptoPro_A_ParamSet                824\n#define OBJ_id_Gost28147_89_CryptoPro_A_ParamSet                OBJ_cryptopro,31L,1L\n\n#define SN_id_Gost28147_89_CryptoPro_B_ParamSet         \"id-Gost28147-89-CryptoPro-B-ParamSet\"\n#define NID_id_Gost28147_89_CryptoPro_B_ParamSet                825\n#define OBJ_id_Gost28147_89_CryptoPro_B_ParamSet                OBJ_cryptopro,31L,2L\n\n#define SN_id_Gost28147_89_CryptoPro_C_ParamSet         \"id-Gost28147-89-CryptoPro-C-ParamSet\"\n#define NID_id_Gost28147_89_CryptoPro_C_ParamSet                826\n#define OBJ_id_Gost28147_89_CryptoPro_C_ParamSet                OBJ_cryptopro,31L,3L\n\n#define SN_id_Gost28147_89_CryptoPro_D_ParamSet         \"id-Gost28147-89-CryptoPro-D-ParamSet\"\n#define NID_id_Gost28147_89_CryptoPro_D_ParamSet                827\n#define OBJ_id_Gost28147_89_CryptoPro_D_ParamSet                OBJ_cryptopro,31L,4L\n\n#define SN_id_Gost28147_89_CryptoPro_Oscar_1_1_ParamSet         \"id-Gost28147-89-CryptoPro-Oscar-1-1-ParamSet\"\n#define NID_id_Gost28147_89_CryptoPro_Oscar_1_1_ParamSet                828\n#define OBJ_id_Gost28147_89_CryptoPro_Oscar_1_1_ParamSet                OBJ_cryptopro,31L,5L\n\n#define SN_id_Gost28147_89_CryptoPro_Oscar_1_0_ParamSet         \"id-Gost28147-89-CryptoPro-Oscar-1-0-ParamSet\"\n#define NID_id_Gost28147_89_CryptoPro_Oscar_1_0_ParamSet                829\n#define OBJ_id_Gost28147_89_CryptoPro_Oscar_1_0_ParamSet                OBJ_cryptopro,31L,6L\n\n#define SN_id_Gost28147_89_CryptoPro_RIC_1_ParamSet             \"id-Gost28147-89-CryptoPro-RIC-1-ParamSet\"\n#define NID_id_Gost28147_89_CryptoPro_RIC_1_ParamSet            830\n#define OBJ_id_Gost28147_89_CryptoPro_RIC_1_ParamSet            OBJ_cryptopro,31L,7L\n\n#define SN_id_GostR3410_94_TestParamSet         \"id-GostR3410-94-TestParamSet\"\n#define NID_id_GostR3410_94_TestParamSet                831\n#define OBJ_id_GostR3410_94_TestParamSet                OBJ_cryptopro,32L,0L\n\n#define SN_id_GostR3410_94_CryptoPro_A_ParamSet         \"id-GostR3410-94-CryptoPro-A-ParamSet\"\n#define NID_id_GostR3410_94_CryptoPro_A_ParamSet                832\n#define OBJ_id_GostR3410_94_CryptoPro_A_ParamSet                OBJ_cryptopro,32L,2L\n\n#define SN_id_GostR3410_94_CryptoPro_B_ParamSet         \"id-GostR3410-94-CryptoPro-B-ParamSet\"\n#define NID_id_GostR3410_94_CryptoPro_B_ParamSet                833\n#define OBJ_id_GostR3410_94_CryptoPro_B_ParamSet                OBJ_cryptopro,32L,3L\n\n#define SN_id_GostR3410_94_CryptoPro_C_ParamSet         \"id-GostR3410-94-CryptoPro-C-ParamSet\"\n#define NID_id_GostR3410_94_CryptoPro_C_ParamSet                834\n#define OBJ_id_GostR3410_94_CryptoPro_C_ParamSet                OBJ_cryptopro,32L,4L\n\n#define SN_id_GostR3410_94_CryptoPro_D_ParamSet         \"id-GostR3410-94-CryptoPro-D-ParamSet\"\n#define NID_id_GostR3410_94_CryptoPro_D_ParamSet                835\n#define OBJ_id_GostR3410_94_CryptoPro_D_ParamSet                OBJ_cryptopro,32L,5L\n\n#define SN_id_GostR3410_94_CryptoPro_XchA_ParamSet              \"id-GostR3410-94-CryptoPro-XchA-ParamSet\"\n#define NID_id_GostR3410_94_CryptoPro_XchA_ParamSet             836\n#define OBJ_id_GostR3410_94_CryptoPro_XchA_ParamSet             OBJ_cryptopro,33L,1L\n\n#define SN_id_GostR3410_94_CryptoPro_XchB_ParamSet              \"id-GostR3410-94-CryptoPro-XchB-ParamSet\"\n#define NID_id_GostR3410_94_CryptoPro_XchB_ParamSet             837\n#define OBJ_id_GostR3410_94_CryptoPro_XchB_ParamSet             OBJ_cryptopro,33L,2L\n\n#define SN_id_GostR3410_94_CryptoPro_XchC_ParamSet              \"id-GostR3410-94-CryptoPro-XchC-ParamSet\"\n#define NID_id_GostR3410_94_CryptoPro_XchC_ParamSet             838\n#define OBJ_id_GostR3410_94_CryptoPro_XchC_ParamSet             OBJ_cryptopro,33L,3L\n\n#define SN_id_GostR3410_2001_TestParamSet               \"id-GostR3410-2001-TestParamSet\"\n#define NID_id_GostR3410_2001_TestParamSet              839\n#define OBJ_id_GostR3410_2001_TestParamSet              OBJ_cryptopro,35L,0L\n\n#define SN_id_GostR3410_2001_CryptoPro_A_ParamSet               \"id-GostR3410-2001-CryptoPro-A-ParamSet\"\n#define NID_id_GostR3410_2001_CryptoPro_A_ParamSet              840\n#define OBJ_id_GostR3410_2001_CryptoPro_A_ParamSet              OBJ_cryptopro,35L,1L\n\n#define SN_id_GostR3410_2001_CryptoPro_B_ParamSet               \"id-GostR3410-2001-CryptoPro-B-ParamSet\"\n#define NID_id_GostR3410_2001_CryptoPro_B_ParamSet              841\n#define OBJ_id_GostR3410_2001_CryptoPro_B_ParamSet              OBJ_cryptopro,35L,2L\n\n#define SN_id_GostR3410_2001_CryptoPro_C_ParamSet               \"id-GostR3410-2001-CryptoPro-C-ParamSet\"\n#define NID_id_GostR3410_2001_CryptoPro_C_ParamSet              842\n#define OBJ_id_GostR3410_2001_CryptoPro_C_ParamSet              OBJ_cryptopro,35L,3L\n\n#define SN_id_GostR3410_2001_CryptoPro_XchA_ParamSet            \"id-GostR3410-2001-CryptoPro-XchA-ParamSet\"\n#define NID_id_GostR3410_2001_CryptoPro_XchA_ParamSet           843\n#define OBJ_id_GostR3410_2001_CryptoPro_XchA_ParamSet           OBJ_cryptopro,36L,0L\n\n#define SN_id_GostR3410_2001_CryptoPro_XchB_ParamSet            \"id-GostR3410-2001-CryptoPro-XchB-ParamSet\"\n#define NID_id_GostR3410_2001_CryptoPro_XchB_ParamSet           844\n#define OBJ_id_GostR3410_2001_CryptoPro_XchB_ParamSet           OBJ_cryptopro,36L,1L\n\n#define SN_id_GostR3410_94_a            \"id-GostR3410-94-a\"\n#define NID_id_GostR3410_94_a           845\n#define OBJ_id_GostR3410_94_a           OBJ_id_GostR3410_94,1L\n\n#define SN_id_GostR3410_94_aBis         \"id-GostR3410-94-aBis\"\n#define NID_id_GostR3410_94_aBis                846\n#define OBJ_id_GostR3410_94_aBis                OBJ_id_GostR3410_94,2L\n\n#define SN_id_GostR3410_94_b            \"id-GostR3410-94-b\"\n#define NID_id_GostR3410_94_b           847\n#define OBJ_id_GostR3410_94_b           OBJ_id_GostR3410_94,3L\n\n#define SN_id_GostR3410_94_bBis         \"id-GostR3410-94-bBis\"\n#define NID_id_GostR3410_94_bBis                848\n#define OBJ_id_GostR3410_94_bBis                OBJ_id_GostR3410_94,4L\n\n#define SN_id_Gost28147_89_cc           \"id-Gost28147-89-cc\"\n#define LN_id_Gost28147_89_cc           \"GOST 28147-89 Cryptocom ParamSet\"\n#define NID_id_Gost28147_89_cc          849\n#define OBJ_id_Gost28147_89_cc          OBJ_cryptocom,1L,6L,1L\n\n#define SN_id_GostR3410_94_cc           \"gost94cc\"\n#define LN_id_GostR3410_94_cc           \"GOST 34.10-94 Cryptocom\"\n#define NID_id_GostR3410_94_cc          850\n#define OBJ_id_GostR3410_94_cc          OBJ_cryptocom,1L,5L,3L\n\n#define SN_id_GostR3410_2001_cc         \"gost2001cc\"\n#define LN_id_GostR3410_2001_cc         \"GOST 34.10-2001 Cryptocom\"\n#define NID_id_GostR3410_2001_cc                851\n#define OBJ_id_GostR3410_2001_cc                OBJ_cryptocom,1L,5L,4L\n\n#define SN_id_GostR3411_94_with_GostR3410_94_cc         \"id-GostR3411-94-with-GostR3410-94-cc\"\n#define LN_id_GostR3411_94_with_GostR3410_94_cc         \"GOST R 34.11-94 with GOST R 34.10-94 Cryptocom\"\n#define NID_id_GostR3411_94_with_GostR3410_94_cc                852\n#define OBJ_id_GostR3411_94_with_GostR3410_94_cc                OBJ_cryptocom,1L,3L,3L\n\n#define SN_id_GostR3411_94_with_GostR3410_2001_cc               \"id-GostR3411-94-with-GostR3410-2001-cc\"\n#define LN_id_GostR3411_94_with_GostR3410_2001_cc               \"GOST R 34.11-94 with GOST R 34.10-2001 Cryptocom\"\n#define NID_id_GostR3411_94_with_GostR3410_2001_cc              853\n#define OBJ_id_GostR3411_94_with_GostR3410_2001_cc              OBJ_cryptocom,1L,3L,4L\n\n#define SN_id_GostR3410_2001_ParamSet_cc                \"id-GostR3410-2001-ParamSet-cc\"\n#define LN_id_GostR3410_2001_ParamSet_cc                \"GOST R 3410-2001 Parameter Set Cryptocom\"\n#define NID_id_GostR3410_2001_ParamSet_cc               854\n#define OBJ_id_GostR3410_2001_ParamSet_cc               OBJ_cryptocom,1L,8L,1L\n\n#define SN_camellia_128_cbc             \"CAMELLIA-128-CBC\"\n#define LN_camellia_128_cbc             \"camellia-128-cbc\"\n#define NID_camellia_128_cbc            751\n#define OBJ_camellia_128_cbc            1L,2L,392L,200011L,61L,1L,1L,1L,2L\n\n#define SN_camellia_192_cbc             \"CAMELLIA-192-CBC\"\n#define LN_camellia_192_cbc             \"camellia-192-cbc\"\n#define NID_camellia_192_cbc            752\n#define OBJ_camellia_192_cbc            1L,2L,392L,200011L,61L,1L,1L,1L,3L\n\n#define SN_camellia_256_cbc             \"CAMELLIA-256-CBC\"\n#define LN_camellia_256_cbc             \"camellia-256-cbc\"\n#define NID_camellia_256_cbc            753\n#define OBJ_camellia_256_cbc            1L,2L,392L,200011L,61L,1L,1L,1L,4L\n\n#define SN_id_camellia128_wrap          \"id-camellia128-wrap\"\n#define NID_id_camellia128_wrap         907\n#define OBJ_id_camellia128_wrap         1L,2L,392L,200011L,61L,1L,1L,3L,2L\n\n#define SN_id_camellia192_wrap          \"id-camellia192-wrap\"\n#define NID_id_camellia192_wrap         908\n#define OBJ_id_camellia192_wrap         1L,2L,392L,200011L,61L,1L,1L,3L,3L\n\n#define SN_id_camellia256_wrap          \"id-camellia256-wrap\"\n#define NID_id_camellia256_wrap         909\n#define OBJ_id_camellia256_wrap         1L,2L,392L,200011L,61L,1L,1L,3L,4L\n\n#define OBJ_ntt_ds              0L,3L,4401L,5L\n\n#define OBJ_camellia            OBJ_ntt_ds,3L,1L,9L\n\n#define SN_camellia_128_ecb             \"CAMELLIA-128-ECB\"\n#define LN_camellia_128_ecb             \"camellia-128-ecb\"\n#define NID_camellia_128_ecb            754\n#define OBJ_camellia_128_ecb            OBJ_camellia,1L\n\n#define SN_camellia_128_ofb128          \"CAMELLIA-128-OFB\"\n#define LN_camellia_128_ofb128          \"camellia-128-ofb\"\n#define NID_camellia_128_ofb128         766\n#define OBJ_camellia_128_ofb128         OBJ_camellia,3L\n\n#define SN_camellia_128_cfb128          \"CAMELLIA-128-CFB\"\n#define LN_camellia_128_cfb128          \"camellia-128-cfb\"\n#define NID_camellia_128_cfb128         757\n#define OBJ_camellia_128_cfb128         OBJ_camellia,4L\n\n#define SN_camellia_192_ecb             \"CAMELLIA-192-ECB\"\n#define LN_camellia_192_ecb             \"camellia-192-ecb\"\n#define NID_camellia_192_ecb            755\n#define OBJ_camellia_192_ecb            OBJ_camellia,21L\n\n#define SN_camellia_192_ofb128          \"CAMELLIA-192-OFB\"\n#define LN_camellia_192_ofb128          \"camellia-192-ofb\"\n#define NID_camellia_192_ofb128         767\n#define OBJ_camellia_192_ofb128         OBJ_camellia,23L\n\n#define SN_camellia_192_cfb128          \"CAMELLIA-192-CFB\"\n#define LN_camellia_192_cfb128          \"camellia-192-cfb\"\n#define NID_camellia_192_cfb128         758\n#define OBJ_camellia_192_cfb128         OBJ_camellia,24L\n\n#define SN_camellia_256_ecb             \"CAMELLIA-256-ECB\"\n#define LN_camellia_256_ecb             \"camellia-256-ecb\"\n#define NID_camellia_256_ecb            756\n#define OBJ_camellia_256_ecb            OBJ_camellia,41L\n\n#define SN_camellia_256_ofb128          \"CAMELLIA-256-OFB\"\n#define LN_camellia_256_ofb128          \"camellia-256-ofb\"\n#define NID_camellia_256_ofb128         768\n#define OBJ_camellia_256_ofb128         OBJ_camellia,43L\n\n#define SN_camellia_256_cfb128          \"CAMELLIA-256-CFB\"\n#define LN_camellia_256_cfb128          \"camellia-256-cfb\"\n#define NID_camellia_256_cfb128         759\n#define OBJ_camellia_256_cfb128         OBJ_camellia,44L\n\n#define SN_camellia_128_cfb1            \"CAMELLIA-128-CFB1\"\n#define LN_camellia_128_cfb1            \"camellia-128-cfb1\"\n#define NID_camellia_128_cfb1           760\n\n#define SN_camellia_192_cfb1            \"CAMELLIA-192-CFB1\"\n#define LN_camellia_192_cfb1            \"camellia-192-cfb1\"\n#define NID_camellia_192_cfb1           761\n\n#define SN_camellia_256_cfb1            \"CAMELLIA-256-CFB1\"\n#define LN_camellia_256_cfb1            \"camellia-256-cfb1\"\n#define NID_camellia_256_cfb1           762\n\n#define SN_camellia_128_cfb8            \"CAMELLIA-128-CFB8\"\n#define LN_camellia_128_cfb8            \"camellia-128-cfb8\"\n#define NID_camellia_128_cfb8           763\n\n#define SN_camellia_192_cfb8            \"CAMELLIA-192-CFB8\"\n#define LN_camellia_192_cfb8            \"camellia-192-cfb8\"\n#define NID_camellia_192_cfb8           764\n\n#define SN_camellia_256_cfb8            \"CAMELLIA-256-CFB8\"\n#define LN_camellia_256_cfb8            \"camellia-256-cfb8\"\n#define NID_camellia_256_cfb8           765\n\n#define SN_kisa         \"KISA\"\n#define LN_kisa         \"kisa\"\n#define NID_kisa                773\n#define OBJ_kisa                OBJ_member_body,410L,200004L\n\n#define SN_seed_ecb             \"SEED-ECB\"\n#define LN_seed_ecb             \"seed-ecb\"\n#define NID_seed_ecb            776\n#define OBJ_seed_ecb            OBJ_kisa,1L,3L\n\n#define SN_seed_cbc             \"SEED-CBC\"\n#define LN_seed_cbc             \"seed-cbc\"\n#define NID_seed_cbc            777\n#define OBJ_seed_cbc            OBJ_kisa,1L,4L\n\n#define SN_seed_cfb128          \"SEED-CFB\"\n#define LN_seed_cfb128          \"seed-cfb\"\n#define NID_seed_cfb128         779\n#define OBJ_seed_cfb128         OBJ_kisa,1L,5L\n\n#define SN_seed_ofb128          \"SEED-OFB\"\n#define LN_seed_ofb128          \"seed-ofb\"\n#define NID_seed_ofb128         778\n#define OBJ_seed_ofb128         OBJ_kisa,1L,6L\n\n#define SN_hmac         \"HMAC\"\n#define LN_hmac         \"hmac\"\n#define NID_hmac                855\n\n#define SN_cmac         \"CMAC\"\n#define LN_cmac         \"cmac\"\n#define NID_cmac                894\n\n#define SN_rc4_hmac_md5         \"RC4-HMAC-MD5\"\n#define LN_rc4_hmac_md5         \"rc4-hmac-md5\"\n#define NID_rc4_hmac_md5                915\n\n#define SN_aes_128_cbc_hmac_sha1                \"AES-128-CBC-HMAC-SHA1\"\n#define LN_aes_128_cbc_hmac_sha1                \"aes-128-cbc-hmac-sha1\"\n#define NID_aes_128_cbc_hmac_sha1               916\n\n#define SN_aes_192_cbc_hmac_sha1                \"AES-192-CBC-HMAC-SHA1\"\n#define LN_aes_192_cbc_hmac_sha1                \"aes-192-cbc-hmac-sha1\"\n#define NID_aes_192_cbc_hmac_sha1               917\n\n#define SN_aes_256_cbc_hmac_sha1                \"AES-256-CBC-HMAC-SHA1\"\n#define LN_aes_256_cbc_hmac_sha1                \"aes-256-cbc-hmac-sha1\"\n#define NID_aes_256_cbc_hmac_sha1               918\n\n#define SN_aes_128_cbc_hmac_sha256              \"AES-128-CBC-HMAC-SHA256\"\n#define LN_aes_128_cbc_hmac_sha256              \"aes-128-cbc-hmac-sha256\"\n#define NID_aes_128_cbc_hmac_sha256             948\n\n#define SN_aes_192_cbc_hmac_sha256              \"AES-192-CBC-HMAC-SHA256\"\n#define LN_aes_192_cbc_hmac_sha256              \"aes-192-cbc-hmac-sha256\"\n#define NID_aes_192_cbc_hmac_sha256             949\n\n#define SN_aes_256_cbc_hmac_sha256              \"AES-256-CBC-HMAC-SHA256\"\n#define LN_aes_256_cbc_hmac_sha256              \"aes-256-cbc-hmac-sha256\"\n#define NID_aes_256_cbc_hmac_sha256             950\n\n#define SN_dhpublicnumber               \"dhpublicnumber\"\n#define LN_dhpublicnumber               \"X9.42 DH\"\n#define NID_dhpublicnumber              920\n#define OBJ_dhpublicnumber              OBJ_ISO_US,10046L,2L,1L\n\n#define SN_brainpoolP160r1              \"brainpoolP160r1\"\n#define NID_brainpoolP160r1             921\n#define OBJ_brainpoolP160r1             1L,3L,36L,3L,3L,2L,8L,1L,1L,1L\n\n#define SN_brainpoolP160t1              \"brainpoolP160t1\"\n#define NID_brainpoolP160t1             922\n#define OBJ_brainpoolP160t1             1L,3L,36L,3L,3L,2L,8L,1L,1L,2L\n\n#define SN_brainpoolP192r1              \"brainpoolP192r1\"\n#define NID_brainpoolP192r1             923\n#define OBJ_brainpoolP192r1             1L,3L,36L,3L,3L,2L,8L,1L,1L,3L\n\n#define SN_brainpoolP192t1              \"brainpoolP192t1\"\n#define NID_brainpoolP192t1             924\n#define OBJ_brainpoolP192t1             1L,3L,36L,3L,3L,2L,8L,1L,1L,4L\n\n#define SN_brainpoolP224r1              \"brainpoolP224r1\"\n#define NID_brainpoolP224r1             925\n#define OBJ_brainpoolP224r1             1L,3L,36L,3L,3L,2L,8L,1L,1L,5L\n\n#define SN_brainpoolP224t1              \"brainpoolP224t1\"\n#define NID_brainpoolP224t1             926\n#define OBJ_brainpoolP224t1             1L,3L,36L,3L,3L,2L,8L,1L,1L,6L\n\n#define SN_brainpoolP256r1              \"brainpoolP256r1\"\n#define NID_brainpoolP256r1             927\n#define OBJ_brainpoolP256r1             1L,3L,36L,3L,3L,2L,8L,1L,1L,7L\n\n#define SN_brainpoolP256t1              \"brainpoolP256t1\"\n#define NID_brainpoolP256t1             928\n#define OBJ_brainpoolP256t1             1L,3L,36L,3L,3L,2L,8L,1L,1L,8L\n\n#define SN_brainpoolP320r1              \"brainpoolP320r1\"\n#define NID_brainpoolP320r1             929\n#define OBJ_brainpoolP320r1             1L,3L,36L,3L,3L,2L,8L,1L,1L,9L\n\n#define SN_brainpoolP320t1              \"brainpoolP320t1\"\n#define NID_brainpoolP320t1             930\n#define OBJ_brainpoolP320t1             1L,3L,36L,3L,3L,2L,8L,1L,1L,10L\n\n#define SN_brainpoolP384r1              \"brainpoolP384r1\"\n#define NID_brainpoolP384r1             931\n#define OBJ_brainpoolP384r1             1L,3L,36L,3L,3L,2L,8L,1L,1L,11L\n\n#define SN_brainpoolP384t1              \"brainpoolP384t1\"\n#define NID_brainpoolP384t1             932\n#define OBJ_brainpoolP384t1             1L,3L,36L,3L,3L,2L,8L,1L,1L,12L\n\n#define SN_brainpoolP512r1              \"brainpoolP512r1\"\n#define NID_brainpoolP512r1             933\n#define OBJ_brainpoolP512r1             1L,3L,36L,3L,3L,2L,8L,1L,1L,13L\n\n#define SN_brainpoolP512t1              \"brainpoolP512t1\"\n#define NID_brainpoolP512t1             934\n#define OBJ_brainpoolP512t1             1L,3L,36L,3L,3L,2L,8L,1L,1L,14L\n\n#define OBJ_x9_63_scheme                1L,3L,133L,16L,840L,63L,0L\n\n#define OBJ_secg_scheme         OBJ_certicom_arc,1L\n\n#define SN_dhSinglePass_stdDH_sha1kdf_scheme            \"dhSinglePass-stdDH-sha1kdf-scheme\"\n#define NID_dhSinglePass_stdDH_sha1kdf_scheme           936\n#define OBJ_dhSinglePass_stdDH_sha1kdf_scheme           OBJ_x9_63_scheme,2L\n\n#define SN_dhSinglePass_stdDH_sha224kdf_scheme          \"dhSinglePass-stdDH-sha224kdf-scheme\"\n#define NID_dhSinglePass_stdDH_sha224kdf_scheme         937\n#define OBJ_dhSinglePass_stdDH_sha224kdf_scheme         OBJ_secg_scheme,11L,0L\n\n#define SN_dhSinglePass_stdDH_sha256kdf_scheme          \"dhSinglePass-stdDH-sha256kdf-scheme\"\n#define NID_dhSinglePass_stdDH_sha256kdf_scheme         938\n#define OBJ_dhSinglePass_stdDH_sha256kdf_scheme         OBJ_secg_scheme,11L,1L\n\n#define SN_dhSinglePass_stdDH_sha384kdf_scheme          \"dhSinglePass-stdDH-sha384kdf-scheme\"\n#define NID_dhSinglePass_stdDH_sha384kdf_scheme         939\n#define OBJ_dhSinglePass_stdDH_sha384kdf_scheme         OBJ_secg_scheme,11L,2L\n\n#define SN_dhSinglePass_stdDH_sha512kdf_scheme          \"dhSinglePass-stdDH-sha512kdf-scheme\"\n#define NID_dhSinglePass_stdDH_sha512kdf_scheme         940\n#define OBJ_dhSinglePass_stdDH_sha512kdf_scheme         OBJ_secg_scheme,11L,3L\n\n#define SN_dhSinglePass_cofactorDH_sha1kdf_scheme               \"dhSinglePass-cofactorDH-sha1kdf-scheme\"\n#define NID_dhSinglePass_cofactorDH_sha1kdf_scheme              941\n#define OBJ_dhSinglePass_cofactorDH_sha1kdf_scheme              OBJ_x9_63_scheme,3L\n\n#define SN_dhSinglePass_cofactorDH_sha224kdf_scheme             \"dhSinglePass-cofactorDH-sha224kdf-scheme\"\n#define NID_dhSinglePass_cofactorDH_sha224kdf_scheme            942\n#define OBJ_dhSinglePass_cofactorDH_sha224kdf_scheme            OBJ_secg_scheme,14L,0L\n\n#define SN_dhSinglePass_cofactorDH_sha256kdf_scheme             \"dhSinglePass-cofactorDH-sha256kdf-scheme\"\n#define NID_dhSinglePass_cofactorDH_sha256kdf_scheme            943\n#define OBJ_dhSinglePass_cofactorDH_sha256kdf_scheme            OBJ_secg_scheme,14L,1L\n\n#define SN_dhSinglePass_cofactorDH_sha384kdf_scheme             \"dhSinglePass-cofactorDH-sha384kdf-scheme\"\n#define NID_dhSinglePass_cofactorDH_sha384kdf_scheme            944\n#define OBJ_dhSinglePass_cofactorDH_sha384kdf_scheme            OBJ_secg_scheme,14L,2L\n\n#define SN_dhSinglePass_cofactorDH_sha512kdf_scheme             \"dhSinglePass-cofactorDH-sha512kdf-scheme\"\n#define NID_dhSinglePass_cofactorDH_sha512kdf_scheme            945\n#define OBJ_dhSinglePass_cofactorDH_sha512kdf_scheme            OBJ_secg_scheme,14L,3L\n\n#define SN_dh_std_kdf           \"dh-std-kdf\"\n#define NID_dh_std_kdf          946\n\n#define SN_dh_cofactor_kdf              \"dh-cofactor-kdf\"\n#define NID_dh_cofactor_kdf             947\n\n#define SN_ct_precert_scts              \"ct_precert_scts\"\n#define LN_ct_precert_scts              \"CT Precertificate SCTs\"\n#define NID_ct_precert_scts             951\n#define OBJ_ct_precert_scts             1L,3L,6L,1L,4L,1L,11129L,2L,4L,2L\n\n#define SN_ct_precert_poison            \"ct_precert_poison\"\n#define LN_ct_precert_poison            \"CT Precertificate Poison\"\n#define NID_ct_precert_poison           952\n#define OBJ_ct_precert_poison           1L,3L,6L,1L,4L,1L,11129L,2L,4L,3L\n\n#define SN_ct_precert_signer            \"ct_precert_signer\"\n#define LN_ct_precert_signer            \"CT Precertificate Signer\"\n#define NID_ct_precert_signer           953\n#define OBJ_ct_precert_signer           1L,3L,6L,1L,4L,1L,11129L,2L,4L,4L\n\n#define SN_ct_cert_scts         \"ct_cert_scts\"\n#define LN_ct_cert_scts         \"CT Certificate SCTs\"\n#define NID_ct_cert_scts                954\n#define OBJ_ct_cert_scts                1L,3L,6L,1L,4L,1L,11129L,2L,4L,5L\n\n#define SN_jurisdictionLocalityName             \"jurisdictionL\"\n#define LN_jurisdictionLocalityName             \"jurisdictionLocalityName\"\n#define NID_jurisdictionLocalityName            955\n#define OBJ_jurisdictionLocalityName            1L,3L,6L,1L,4L,1L,311L,60L,2L,1L,1L\n\n#define SN_jurisdictionStateOrProvinceName              \"jurisdictionST\"\n#define LN_jurisdictionStateOrProvinceName              \"jurisdictionStateOrProvinceName\"\n#define NID_jurisdictionStateOrProvinceName             956\n#define OBJ_jurisdictionStateOrProvinceName             1L,3L,6L,1L,4L,1L,311L,60L,2L,1L,2L\n\n#define SN_jurisdictionCountryName              \"jurisdictionC\"\n#define LN_jurisdictionCountryName              \"jurisdictionCountryName\"\n#define NID_jurisdictionCountryName             957\n#define OBJ_jurisdictionCountryName             1L,3L,6L,1L,4L,1L,311L,60L,2L,1L,3L\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/x86/include/openssl/objects.h",
    "content": "/* crypto/objects/objects.h */\n/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)\n * All rights reserved.\n *\n * This package is an SSL implementation written\n * by Eric Young (eay@cryptsoft.com).\n * The implementation was written so as to conform with Netscapes SSL.\n *\n * This library is free for commercial and non-commercial use as long as\n * the following conditions are aheared to.  The following conditions\n * apply to all code found in this distribution, be it the RC4, RSA,\n * lhash, DES, etc., code; not just the SSL code.  The SSL documentation\n * included with this distribution is covered by the same copyright terms\n * except that the holder is Tim Hudson (tjh@cryptsoft.com).\n *\n * Copyright remains Eric Young's, and as such any Copyright notices in\n * the code are not to be removed.\n * If this package is used in a product, Eric Young should be given attribution\n * as the author of the parts of the library used.\n * This can be in the form of a textual message at program startup or\n * in documentation (online or textual) provided with the package.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the copyright\n *    notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in the\n *    documentation and/or other materials provided with the distribution.\n * 3. All advertising materials mentioning features or use of this software\n *    must display the following acknowledgement:\n *    \"This product includes cryptographic software written by\n *     Eric Young (eay@cryptsoft.com)\"\n *    The word 'cryptographic' can be left out if the rouines from the library\n *    being used are not cryptographic related :-).\n * 4. If you include any Windows specific code (or a derivative thereof) from\n *    the apps directory (application code) you must include an acknowledgement:\n *    \"This product includes software written by Tim Hudson (tjh@cryptsoft.com)\"\n *\n * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n * SUCH DAMAGE.\n *\n * The licence and distribution terms for any publically available version or\n * derivative of this code cannot be changed.  i.e. this code cannot simply be\n * copied and put under another distribution licence\n * [including the GNU Public Licence.]\n */\n\n#ifndef HEADER_OBJECTS_H\n# define HEADER_OBJECTS_H\n\n# define USE_OBJ_MAC\n\n# ifdef USE_OBJ_MAC\n#  include <openssl/obj_mac.h>\n# else\n#  define SN_undef                        \"UNDEF\"\n#  define LN_undef                        \"undefined\"\n#  define NID_undef                       0\n#  define OBJ_undef                       0L\n\n#  define SN_Algorithm                    \"Algorithm\"\n#  define LN_algorithm                    \"algorithm\"\n#  define NID_algorithm                   38\n#  define OBJ_algorithm                   1L,3L,14L,3L,2L\n\n#  define LN_rsadsi                       \"rsadsi\"\n#  define NID_rsadsi                      1\n#  define OBJ_rsadsi                      1L,2L,840L,113549L\n\n#  define LN_pkcs                         \"pkcs\"\n#  define NID_pkcs                        2\n#  define OBJ_pkcs                        OBJ_rsadsi,1L\n\n#  define SN_md2                          \"MD2\"\n#  define LN_md2                          \"md2\"\n#  define NID_md2                         3\n#  define OBJ_md2                         OBJ_rsadsi,2L,2L\n\n#  define SN_md5                          \"MD5\"\n#  define LN_md5                          \"md5\"\n#  define NID_md5                         4\n#  define OBJ_md5                         OBJ_rsadsi,2L,5L\n\n#  define SN_rc4                          \"RC4\"\n#  define LN_rc4                          \"rc4\"\n#  define NID_rc4                         5\n#  define OBJ_rc4                         OBJ_rsadsi,3L,4L\n\n#  define LN_rsaEncryption                \"rsaEncryption\"\n#  define NID_rsaEncryption               6\n#  define OBJ_rsaEncryption               OBJ_pkcs,1L,1L\n\n#  define SN_md2WithRSAEncryption         \"RSA-MD2\"\n#  define LN_md2WithRSAEncryption         \"md2WithRSAEncryption\"\n#  define NID_md2WithRSAEncryption        7\n#  define OBJ_md2WithRSAEncryption        OBJ_pkcs,1L,2L\n\n#  define SN_md5WithRSAEncryption         \"RSA-MD5\"\n#  define LN_md5WithRSAEncryption         \"md5WithRSAEncryption\"\n#  define NID_md5WithRSAEncryption        8\n#  define OBJ_md5WithRSAEncryption        OBJ_pkcs,1L,4L\n\n#  define SN_pbeWithMD2AndDES_CBC         \"PBE-MD2-DES\"\n#  define LN_pbeWithMD2AndDES_CBC         \"pbeWithMD2AndDES-CBC\"\n#  define NID_pbeWithMD2AndDES_CBC        9\n#  define OBJ_pbeWithMD2AndDES_CBC        OBJ_pkcs,5L,1L\n\n#  define SN_pbeWithMD5AndDES_CBC         \"PBE-MD5-DES\"\n#  define LN_pbeWithMD5AndDES_CBC         \"pbeWithMD5AndDES-CBC\"\n#  define NID_pbeWithMD5AndDES_CBC        10\n#  define OBJ_pbeWithMD5AndDES_CBC        OBJ_pkcs,5L,3L\n\n#  define LN_X500                         \"X500\"\n#  define NID_X500                        11\n#  define OBJ_X500                        2L,5L\n\n#  define LN_X509                         \"X509\"\n#  define NID_X509                        12\n#  define OBJ_X509                        OBJ_X500,4L\n\n#  define SN_commonName                   \"CN\"\n#  define LN_commonName                   \"commonName\"\n#  define NID_commonName                  13\n#  define OBJ_commonName                  OBJ_X509,3L\n\n#  define SN_countryName                  \"C\"\n#  define LN_countryName                  \"countryName\"\n#  define NID_countryName                 14\n#  define OBJ_countryName                 OBJ_X509,6L\n\n#  define SN_localityName                 \"L\"\n#  define LN_localityName                 \"localityName\"\n#  define NID_localityName                15\n#  define OBJ_localityName                OBJ_X509,7L\n\n/* Postal Address? PA */\n\n/* should be \"ST\" (rfc1327) but MS uses 'S' */\n#  define SN_stateOrProvinceName          \"ST\"\n#  define LN_stateOrProvinceName          \"stateOrProvinceName\"\n#  define NID_stateOrProvinceName         16\n#  define OBJ_stateOrProvinceName         OBJ_X509,8L\n\n#  define SN_organizationName             \"O\"\n#  define LN_organizationName             \"organizationName\"\n#  define NID_organizationName            17\n#  define OBJ_organizationName            OBJ_X509,10L\n\n#  define SN_organizationalUnitName       \"OU\"\n#  define LN_organizationalUnitName       \"organizationalUnitName\"\n#  define NID_organizationalUnitName      18\n#  define OBJ_organizationalUnitName      OBJ_X509,11L\n\n#  define SN_rsa                          \"RSA\"\n#  define LN_rsa                          \"rsa\"\n#  define NID_rsa                         19\n#  define OBJ_rsa                         OBJ_X500,8L,1L,1L\n\n#  define LN_pkcs7                        \"pkcs7\"\n#  define NID_pkcs7                       20\n#  define OBJ_pkcs7                       OBJ_pkcs,7L\n\n#  define LN_pkcs7_data                   \"pkcs7-data\"\n#  define NID_pkcs7_data                  21\n#  define OBJ_pkcs7_data                  OBJ_pkcs7,1L\n\n#  define LN_pkcs7_signed                 \"pkcs7-signedData\"\n#  define NID_pkcs7_signed                22\n#  define OBJ_pkcs7_signed                OBJ_pkcs7,2L\n\n#  define LN_pkcs7_enveloped              \"pkcs7-envelopedData\"\n#  define NID_pkcs7_enveloped             23\n#  define OBJ_pkcs7_enveloped             OBJ_pkcs7,3L\n\n#  define LN_pkcs7_signedAndEnveloped     \"pkcs7-signedAndEnvelopedData\"\n#  define NID_pkcs7_signedAndEnveloped    24\n#  define OBJ_pkcs7_signedAndEnveloped    OBJ_pkcs7,4L\n\n#  define LN_pkcs7_digest                 \"pkcs7-digestData\"\n#  define NID_pkcs7_digest                25\n#  define OBJ_pkcs7_digest                OBJ_pkcs7,5L\n\n#  define LN_pkcs7_encrypted              \"pkcs7-encryptedData\"\n#  define NID_pkcs7_encrypted             26\n#  define OBJ_pkcs7_encrypted             OBJ_pkcs7,6L\n\n#  define LN_pkcs3                        \"pkcs3\"\n#  define NID_pkcs3                       27\n#  define OBJ_pkcs3                       OBJ_pkcs,3L\n\n#  define LN_dhKeyAgreement               \"dhKeyAgreement\"\n#  define NID_dhKeyAgreement              28\n#  define OBJ_dhKeyAgreement              OBJ_pkcs3,1L\n\n#  define SN_des_ecb                      \"DES-ECB\"\n#  define LN_des_ecb                      \"des-ecb\"\n#  define NID_des_ecb                     29\n#  define OBJ_des_ecb                     OBJ_algorithm,6L\n\n#  define SN_des_cfb64                    \"DES-CFB\"\n#  define LN_des_cfb64                    \"des-cfb\"\n#  define NID_des_cfb64                   30\n/* IV + num */\n#  define OBJ_des_cfb64                   OBJ_algorithm,9L\n\n#  define SN_des_cbc                      \"DES-CBC\"\n#  define LN_des_cbc                      \"des-cbc\"\n#  define NID_des_cbc                     31\n/* IV */\n#  define OBJ_des_cbc                     OBJ_algorithm,7L\n\n#  define SN_des_ede                      \"DES-EDE\"\n#  define LN_des_ede                      \"des-ede\"\n#  define NID_des_ede                     32\n/* ?? */\n#  define OBJ_des_ede                     OBJ_algorithm,17L\n\n#  define SN_des_ede3                     \"DES-EDE3\"\n#  define LN_des_ede3                     \"des-ede3\"\n#  define NID_des_ede3                    33\n\n#  define SN_idea_cbc                     \"IDEA-CBC\"\n#  define LN_idea_cbc                     \"idea-cbc\"\n#  define NID_idea_cbc                    34\n#  define OBJ_idea_cbc                    1L,3L,6L,1L,4L,1L,188L,7L,1L,1L,2L\n\n#  define SN_idea_cfb64                   \"IDEA-CFB\"\n#  define LN_idea_cfb64                   \"idea-cfb\"\n#  define NID_idea_cfb64                  35\n\n#  define SN_idea_ecb                     \"IDEA-ECB\"\n#  define LN_idea_ecb                     \"idea-ecb\"\n#  define NID_idea_ecb                    36\n\n#  define SN_rc2_cbc                      \"RC2-CBC\"\n#  define LN_rc2_cbc                      \"rc2-cbc\"\n#  define NID_rc2_cbc                     37\n#  define OBJ_rc2_cbc                     OBJ_rsadsi,3L,2L\n\n#  define SN_rc2_ecb                      \"RC2-ECB\"\n#  define LN_rc2_ecb                      \"rc2-ecb\"\n#  define NID_rc2_ecb                     38\n\n#  define SN_rc2_cfb64                    \"RC2-CFB\"\n#  define LN_rc2_cfb64                    \"rc2-cfb\"\n#  define NID_rc2_cfb64                   39\n\n#  define SN_rc2_ofb64                    \"RC2-OFB\"\n#  define LN_rc2_ofb64                    \"rc2-ofb\"\n#  define NID_rc2_ofb64                   40\n\n#  define SN_sha                          \"SHA\"\n#  define LN_sha                          \"sha\"\n#  define NID_sha                         41\n#  define OBJ_sha                         OBJ_algorithm,18L\n\n#  define SN_shaWithRSAEncryption         \"RSA-SHA\"\n#  define LN_shaWithRSAEncryption         \"shaWithRSAEncryption\"\n#  define NID_shaWithRSAEncryption        42\n#  define OBJ_shaWithRSAEncryption        OBJ_algorithm,15L\n\n#  define SN_des_ede_cbc                  \"DES-EDE-CBC\"\n#  define LN_des_ede_cbc                  \"des-ede-cbc\"\n#  define NID_des_ede_cbc                 43\n\n#  define SN_des_ede3_cbc                 \"DES-EDE3-CBC\"\n#  define LN_des_ede3_cbc                 \"des-ede3-cbc\"\n#  define NID_des_ede3_cbc                44\n#  define OBJ_des_ede3_cbc                OBJ_rsadsi,3L,7L\n\n#  define SN_des_ofb64                    \"DES-OFB\"\n#  define LN_des_ofb64                    \"des-ofb\"\n#  define NID_des_ofb64                   45\n#  define OBJ_des_ofb64                   OBJ_algorithm,8L\n\n#  define SN_idea_ofb64                   \"IDEA-OFB\"\n#  define LN_idea_ofb64                   \"idea-ofb\"\n#  define NID_idea_ofb64                  46\n\n#  define LN_pkcs9                        \"pkcs9\"\n#  define NID_pkcs9                       47\n#  define OBJ_pkcs9                       OBJ_pkcs,9L\n\n#  define SN_pkcs9_emailAddress           \"Email\"\n#  define LN_pkcs9_emailAddress           \"emailAddress\"\n#  define NID_pkcs9_emailAddress          48\n#  define OBJ_pkcs9_emailAddress          OBJ_pkcs9,1L\n\n#  define LN_pkcs9_unstructuredName       \"unstructuredName\"\n#  define NID_pkcs9_unstructuredName      49\n#  define OBJ_pkcs9_unstructuredName      OBJ_pkcs9,2L\n\n#  define LN_pkcs9_contentType            \"contentType\"\n#  define NID_pkcs9_contentType           50\n#  define OBJ_pkcs9_contentType           OBJ_pkcs9,3L\n\n#  define LN_pkcs9_messageDigest          \"messageDigest\"\n#  define NID_pkcs9_messageDigest         51\n#  define OBJ_pkcs9_messageDigest         OBJ_pkcs9,4L\n\n#  define LN_pkcs9_signingTime            \"signingTime\"\n#  define NID_pkcs9_signingTime           52\n#  define OBJ_pkcs9_signingTime           OBJ_pkcs9,5L\n\n#  define LN_pkcs9_countersignature       \"countersignature\"\n#  define NID_pkcs9_countersignature      53\n#  define OBJ_pkcs9_countersignature      OBJ_pkcs9,6L\n\n#  define LN_pkcs9_challengePassword      \"challengePassword\"\n#  define NID_pkcs9_challengePassword     54\n#  define OBJ_pkcs9_challengePassword     OBJ_pkcs9,7L\n\n#  define LN_pkcs9_unstructuredAddress    \"unstructuredAddress\"\n#  define NID_pkcs9_unstructuredAddress   55\n#  define OBJ_pkcs9_unstructuredAddress   OBJ_pkcs9,8L\n\n#  define LN_pkcs9_extCertAttributes      \"extendedCertificateAttributes\"\n#  define NID_pkcs9_extCertAttributes     56\n#  define OBJ_pkcs9_extCertAttributes     OBJ_pkcs9,9L\n\n#  define SN_netscape                     \"Netscape\"\n#  define LN_netscape                     \"Netscape Communications Corp.\"\n#  define NID_netscape                    57\n#  define OBJ_netscape                    2L,16L,840L,1L,113730L\n\n#  define SN_netscape_cert_extension      \"nsCertExt\"\n#  define LN_netscape_cert_extension      \"Netscape Certificate Extension\"\n#  define NID_netscape_cert_extension     58\n#  define OBJ_netscape_cert_extension     OBJ_netscape,1L\n\n#  define SN_netscape_data_type           \"nsDataType\"\n#  define LN_netscape_data_type           \"Netscape Data Type\"\n#  define NID_netscape_data_type          59\n#  define OBJ_netscape_data_type          OBJ_netscape,2L\n\n#  define SN_des_ede_cfb64                \"DES-EDE-CFB\"\n#  define LN_des_ede_cfb64                \"des-ede-cfb\"\n#  define NID_des_ede_cfb64               60\n\n#  define SN_des_ede3_cfb64               \"DES-EDE3-CFB\"\n#  define LN_des_ede3_cfb64               \"des-ede3-cfb\"\n#  define NID_des_ede3_cfb64              61\n\n#  define SN_des_ede_ofb64                \"DES-EDE-OFB\"\n#  define LN_des_ede_ofb64                \"des-ede-ofb\"\n#  define NID_des_ede_ofb64               62\n\n#  define SN_des_ede3_ofb64               \"DES-EDE3-OFB\"\n#  define LN_des_ede3_ofb64               \"des-ede3-ofb\"\n#  define NID_des_ede3_ofb64              63\n\n/* I'm not sure about the object ID */\n#  define SN_sha1                         \"SHA1\"\n#  define LN_sha1                         \"sha1\"\n#  define NID_sha1                        64\n#  define OBJ_sha1                        OBJ_algorithm,26L\n/* 28 Jun 1996 - eay */\n/* #define OBJ_sha1                     1L,3L,14L,2L,26L,05L <- wrong */\n\n#  define SN_sha1WithRSAEncryption        \"RSA-SHA1\"\n#  define LN_sha1WithRSAEncryption        \"sha1WithRSAEncryption\"\n#  define NID_sha1WithRSAEncryption       65\n#  define OBJ_sha1WithRSAEncryption       OBJ_pkcs,1L,5L\n\n#  define SN_dsaWithSHA                   \"DSA-SHA\"\n#  define LN_dsaWithSHA                   \"dsaWithSHA\"\n#  define NID_dsaWithSHA                  66\n#  define OBJ_dsaWithSHA                  OBJ_algorithm,13L\n\n#  define SN_dsa_2                        \"DSA-old\"\n#  define LN_dsa_2                        \"dsaEncryption-old\"\n#  define NID_dsa_2                       67\n#  define OBJ_dsa_2                       OBJ_algorithm,12L\n\n/* proposed by microsoft to RSA */\n#  define SN_pbeWithSHA1AndRC2_CBC        \"PBE-SHA1-RC2-64\"\n#  define LN_pbeWithSHA1AndRC2_CBC        \"pbeWithSHA1AndRC2-CBC\"\n#  define NID_pbeWithSHA1AndRC2_CBC       68\n#  define OBJ_pbeWithSHA1AndRC2_CBC       OBJ_pkcs,5L,11L\n\n/*\n * proposed by microsoft to RSA as pbeWithSHA1AndRC4: it is now defined\n * explicitly in PKCS#5 v2.0 as id-PBKDF2 which is something completely\n * different.\n */\n#  define LN_id_pbkdf2                    \"PBKDF2\"\n#  define NID_id_pbkdf2                   69\n#  define OBJ_id_pbkdf2                   OBJ_pkcs,5L,12L\n\n#  define SN_dsaWithSHA1_2                \"DSA-SHA1-old\"\n#  define LN_dsaWithSHA1_2                \"dsaWithSHA1-old\"\n#  define NID_dsaWithSHA1_2               70\n/* Got this one from 'sdn706r20.pdf' which is actually an NSA document :-) */\n#  define OBJ_dsaWithSHA1_2               OBJ_algorithm,27L\n\n#  define SN_netscape_cert_type           \"nsCertType\"\n#  define LN_netscape_cert_type           \"Netscape Cert Type\"\n#  define NID_netscape_cert_type          71\n#  define OBJ_netscape_cert_type          OBJ_netscape_cert_extension,1L\n\n#  define SN_netscape_base_url            \"nsBaseUrl\"\n#  define LN_netscape_base_url            \"Netscape Base Url\"\n#  define NID_netscape_base_url           72\n#  define OBJ_netscape_base_url           OBJ_netscape_cert_extension,2L\n\n#  define SN_netscape_revocation_url      \"nsRevocationUrl\"\n#  define LN_netscape_revocation_url      \"Netscape Revocation Url\"\n#  define NID_netscape_revocation_url     73\n#  define OBJ_netscape_revocation_url     OBJ_netscape_cert_extension,3L\n\n#  define SN_netscape_ca_revocation_url   \"nsCaRevocationUrl\"\n#  define LN_netscape_ca_revocation_url   \"Netscape CA Revocation Url\"\n#  define NID_netscape_ca_revocation_url  74\n#  define OBJ_netscape_ca_revocation_url  OBJ_netscape_cert_extension,4L\n\n#  define SN_netscape_renewal_url         \"nsRenewalUrl\"\n#  define LN_netscape_renewal_url         \"Netscape Renewal Url\"\n#  define NID_netscape_renewal_url        75\n#  define OBJ_netscape_renewal_url        OBJ_netscape_cert_extension,7L\n\n#  define SN_netscape_ca_policy_url       \"nsCaPolicyUrl\"\n#  define LN_netscape_ca_policy_url       \"Netscape CA Policy Url\"\n#  define NID_netscape_ca_policy_url      76\n#  define OBJ_netscape_ca_policy_url      OBJ_netscape_cert_extension,8L\n\n#  define SN_netscape_ssl_server_name     \"nsSslServerName\"\n#  define LN_netscape_ssl_server_name     \"Netscape SSL Server Name\"\n#  define NID_netscape_ssl_server_name    77\n#  define OBJ_netscape_ssl_server_name    OBJ_netscape_cert_extension,12L\n\n#  define SN_netscape_comment             \"nsComment\"\n#  define LN_netscape_comment             \"Netscape Comment\"\n#  define NID_netscape_comment            78\n#  define OBJ_netscape_comment            OBJ_netscape_cert_extension,13L\n\n#  define SN_netscape_cert_sequence       \"nsCertSequence\"\n#  define LN_netscape_cert_sequence       \"Netscape Certificate Sequence\"\n#  define NID_netscape_cert_sequence      79\n#  define OBJ_netscape_cert_sequence      OBJ_netscape_data_type,5L\n\n#  define SN_desx_cbc                     \"DESX-CBC\"\n#  define LN_desx_cbc                     \"desx-cbc\"\n#  define NID_desx_cbc                    80\n\n#  define SN_id_ce                        \"id-ce\"\n#  define NID_id_ce                       81\n#  define OBJ_id_ce                       2L,5L,29L\n\n#  define SN_subject_key_identifier       \"subjectKeyIdentifier\"\n#  define LN_subject_key_identifier       \"X509v3 Subject Key Identifier\"\n#  define NID_subject_key_identifier      82\n#  define OBJ_subject_key_identifier      OBJ_id_ce,14L\n\n#  define SN_key_usage                    \"keyUsage\"\n#  define LN_key_usage                    \"X509v3 Key Usage\"\n#  define NID_key_usage                   83\n#  define OBJ_key_usage                   OBJ_id_ce,15L\n\n#  define SN_private_key_usage_period     \"privateKeyUsagePeriod\"\n#  define LN_private_key_usage_period     \"X509v3 Private Key Usage Period\"\n#  define NID_private_key_usage_period    84\n#  define OBJ_private_key_usage_period    OBJ_id_ce,16L\n\n#  define SN_subject_alt_name             \"subjectAltName\"\n#  define LN_subject_alt_name             \"X509v3 Subject Alternative Name\"\n#  define NID_subject_alt_name            85\n#  define OBJ_subject_alt_name            OBJ_id_ce,17L\n\n#  define SN_issuer_alt_name              \"issuerAltName\"\n#  define LN_issuer_alt_name              \"X509v3 Issuer Alternative Name\"\n#  define NID_issuer_alt_name             86\n#  define OBJ_issuer_alt_name             OBJ_id_ce,18L\n\n#  define SN_basic_constraints            \"basicConstraints\"\n#  define LN_basic_constraints            \"X509v3 Basic Constraints\"\n#  define NID_basic_constraints           87\n#  define OBJ_basic_constraints           OBJ_id_ce,19L\n\n#  define SN_crl_number                   \"crlNumber\"\n#  define LN_crl_number                   \"X509v3 CRL Number\"\n#  define NID_crl_number                  88\n#  define OBJ_crl_number                  OBJ_id_ce,20L\n\n#  define SN_certificate_policies         \"certificatePolicies\"\n#  define LN_certificate_policies         \"X509v3 Certificate Policies\"\n#  define NID_certificate_policies        89\n#  define OBJ_certificate_policies        OBJ_id_ce,32L\n\n#  define SN_authority_key_identifier     \"authorityKeyIdentifier\"\n#  define LN_authority_key_identifier     \"X509v3 Authority Key Identifier\"\n#  define NID_authority_key_identifier    90\n#  define OBJ_authority_key_identifier    OBJ_id_ce,35L\n\n#  define SN_bf_cbc                       \"BF-CBC\"\n#  define LN_bf_cbc                       \"bf-cbc\"\n#  define NID_bf_cbc                      91\n#  define OBJ_bf_cbc                      1L,3L,6L,1L,4L,1L,3029L,1L,2L\n\n#  define SN_bf_ecb                       \"BF-ECB\"\n#  define LN_bf_ecb                       \"bf-ecb\"\n#  define NID_bf_ecb                      92\n\n#  define SN_bf_cfb64                     \"BF-CFB\"\n#  define LN_bf_cfb64                     \"bf-cfb\"\n#  define NID_bf_cfb64                    93\n\n#  define SN_bf_ofb64                     \"BF-OFB\"\n#  define LN_bf_ofb64                     \"bf-ofb\"\n#  define NID_bf_ofb64                    94\n\n#  define SN_mdc2                         \"MDC2\"\n#  define LN_mdc2                         \"mdc2\"\n#  define NID_mdc2                        95\n#  define OBJ_mdc2                        2L,5L,8L,3L,101L\n/* An alternative?                      1L,3L,14L,3L,2L,19L */\n\n#  define SN_mdc2WithRSA                  \"RSA-MDC2\"\n#  define LN_mdc2WithRSA                  \"mdc2withRSA\"\n#  define NID_mdc2WithRSA                 96\n#  define OBJ_mdc2WithRSA                 2L,5L,8L,3L,100L\n\n#  define SN_rc4_40                       \"RC4-40\"\n#  define LN_rc4_40                       \"rc4-40\"\n#  define NID_rc4_40                      97\n\n#  define SN_rc2_40_cbc                   \"RC2-40-CBC\"\n#  define LN_rc2_40_cbc                   \"rc2-40-cbc\"\n#  define NID_rc2_40_cbc                  98\n\n#  define SN_givenName                    \"G\"\n#  define LN_givenName                    \"givenName\"\n#  define NID_givenName                   99\n#  define OBJ_givenName                   OBJ_X509,42L\n\n#  define SN_surname                      \"S\"\n#  define LN_surname                      \"surname\"\n#  define NID_surname                     100\n#  define OBJ_surname                     OBJ_X509,4L\n\n#  define SN_initials                     \"I\"\n#  define LN_initials                     \"initials\"\n#  define NID_initials                    101\n#  define OBJ_initials                    OBJ_X509,43L\n\n#  define SN_uniqueIdentifier             \"UID\"\n#  define LN_uniqueIdentifier             \"uniqueIdentifier\"\n#  define NID_uniqueIdentifier            102\n#  define OBJ_uniqueIdentifier            OBJ_X509,45L\n\n#  define SN_crl_distribution_points      \"crlDistributionPoints\"\n#  define LN_crl_distribution_points      \"X509v3 CRL Distribution Points\"\n#  define NID_crl_distribution_points     103\n#  define OBJ_crl_distribution_points     OBJ_id_ce,31L\n\n#  define SN_md5WithRSA                   \"RSA-NP-MD5\"\n#  define LN_md5WithRSA                   \"md5WithRSA\"\n#  define NID_md5WithRSA                  104\n#  define OBJ_md5WithRSA                  OBJ_algorithm,3L\n\n#  define SN_serialNumber                 \"SN\"\n#  define LN_serialNumber                 \"serialNumber\"\n#  define NID_serialNumber                105\n#  define OBJ_serialNumber                OBJ_X509,5L\n\n#  define SN_title                        \"T\"\n#  define LN_title                        \"title\"\n#  define NID_title                       106\n#  define OBJ_title                       OBJ_X509,12L\n\n#  define SN_description                  \"D\"\n#  define LN_description                  \"description\"\n#  define NID_description                 107\n#  define OBJ_description                 OBJ_X509,13L\n\n/* CAST5 is CAST-128, I'm just sticking with the documentation */\n#  define SN_cast5_cbc                    \"CAST5-CBC\"\n#  define LN_cast5_cbc                    \"cast5-cbc\"\n#  define NID_cast5_cbc                   108\n#  define OBJ_cast5_cbc                   1L,2L,840L,113533L,7L,66L,10L\n\n#  define SN_cast5_ecb                    \"CAST5-ECB\"\n#  define LN_cast5_ecb                    \"cast5-ecb\"\n#  define NID_cast5_ecb                   109\n\n#  define SN_cast5_cfb64                  \"CAST5-CFB\"\n#  define LN_cast5_cfb64                  \"cast5-cfb\"\n#  define NID_cast5_cfb64                 110\n\n#  define SN_cast5_ofb64                  \"CAST5-OFB\"\n#  define LN_cast5_ofb64                  \"cast5-ofb\"\n#  define NID_cast5_ofb64                 111\n\n#  define LN_pbeWithMD5AndCast5_CBC       \"pbeWithMD5AndCast5CBC\"\n#  define NID_pbeWithMD5AndCast5_CBC      112\n#  define OBJ_pbeWithMD5AndCast5_CBC      1L,2L,840L,113533L,7L,66L,12L\n\n/*-\n * This is one sun will soon be using :-(\n * id-dsa-with-sha1 ID  ::= {\n *   iso(1) member-body(2) us(840) x9-57 (10040) x9cm(4) 3 }\n */\n#  define SN_dsaWithSHA1                  \"DSA-SHA1\"\n#  define LN_dsaWithSHA1                  \"dsaWithSHA1\"\n#  define NID_dsaWithSHA1                 113\n#  define OBJ_dsaWithSHA1                 1L,2L,840L,10040L,4L,3L\n\n#  define NID_md5_sha1                    114\n#  define SN_md5_sha1                     \"MD5-SHA1\"\n#  define LN_md5_sha1                     \"md5-sha1\"\n\n#  define SN_sha1WithRSA                  \"RSA-SHA1-2\"\n#  define LN_sha1WithRSA                  \"sha1WithRSA\"\n#  define NID_sha1WithRSA                 115\n#  define OBJ_sha1WithRSA                 OBJ_algorithm,29L\n\n#  define SN_dsa                          \"DSA\"\n#  define LN_dsa                          \"dsaEncryption\"\n#  define NID_dsa                         116\n#  define OBJ_dsa                         1L,2L,840L,10040L,4L,1L\n\n#  define SN_ripemd160                    \"RIPEMD160\"\n#  define LN_ripemd160                    \"ripemd160\"\n#  define NID_ripemd160                   117\n#  define OBJ_ripemd160                   1L,3L,36L,3L,2L,1L\n\n/*\n * The name should actually be rsaSignatureWithripemd160, but I'm going to\n * continue using the convention I'm using with the other ciphers\n */\n#  define SN_ripemd160WithRSA             \"RSA-RIPEMD160\"\n#  define LN_ripemd160WithRSA             \"ripemd160WithRSA\"\n#  define NID_ripemd160WithRSA            119\n#  define OBJ_ripemd160WithRSA            1L,3L,36L,3L,3L,1L,2L\n\n/*-\n * Taken from rfc2040\n *  RC5_CBC_Parameters ::= SEQUENCE {\n *      version           INTEGER (v1_0(16)),\n *      rounds            INTEGER (8..127),\n *      blockSizeInBits   INTEGER (64, 128),\n *      iv                OCTET STRING OPTIONAL\n *      }\n */\n#  define SN_rc5_cbc                      \"RC5-CBC\"\n#  define LN_rc5_cbc                      \"rc5-cbc\"\n#  define NID_rc5_cbc                     120\n#  define OBJ_rc5_cbc                     OBJ_rsadsi,3L,8L\n\n#  define SN_rc5_ecb                      \"RC5-ECB\"\n#  define LN_rc5_ecb                      \"rc5-ecb\"\n#  define NID_rc5_ecb                     121\n\n#  define SN_rc5_cfb64                    \"RC5-CFB\"\n#  define LN_rc5_cfb64                    \"rc5-cfb\"\n#  define NID_rc5_cfb64                   122\n\n#  define SN_rc5_ofb64                    \"RC5-OFB\"\n#  define LN_rc5_ofb64                    \"rc5-ofb\"\n#  define NID_rc5_ofb64                   123\n\n#  define SN_rle_compression              \"RLE\"\n#  define LN_rle_compression              \"run length compression\"\n#  define NID_rle_compression             124\n#  define OBJ_rle_compression             1L,1L,1L,1L,666L,1L\n\n#  define SN_zlib_compression             \"ZLIB\"\n#  define LN_zlib_compression             \"zlib compression\"\n#  define NID_zlib_compression            125\n#  define OBJ_zlib_compression            1L,1L,1L,1L,666L,2L\n\n#  define SN_ext_key_usage                \"extendedKeyUsage\"\n#  define LN_ext_key_usage                \"X509v3 Extended Key Usage\"\n#  define NID_ext_key_usage               126\n#  define OBJ_ext_key_usage               OBJ_id_ce,37\n\n#  define SN_id_pkix                      \"PKIX\"\n#  define NID_id_pkix                     127\n#  define OBJ_id_pkix                     1L,3L,6L,1L,5L,5L,7L\n\n#  define SN_id_kp                        \"id-kp\"\n#  define NID_id_kp                       128\n#  define OBJ_id_kp                       OBJ_id_pkix,3L\n\n/* PKIX extended key usage OIDs */\n\n#  define SN_server_auth                  \"serverAuth\"\n#  define LN_server_auth                  \"TLS Web Server Authentication\"\n#  define NID_server_auth                 129\n#  define OBJ_server_auth                 OBJ_id_kp,1L\n\n#  define SN_client_auth                  \"clientAuth\"\n#  define LN_client_auth                  \"TLS Web Client Authentication\"\n#  define NID_client_auth                 130\n#  define OBJ_client_auth                 OBJ_id_kp,2L\n\n#  define SN_code_sign                    \"codeSigning\"\n#  define LN_code_sign                    \"Code Signing\"\n#  define NID_code_sign                   131\n#  define OBJ_code_sign                   OBJ_id_kp,3L\n\n#  define SN_email_protect                \"emailProtection\"\n#  define LN_email_protect                \"E-mail Protection\"\n#  define NID_email_protect               132\n#  define OBJ_email_protect               OBJ_id_kp,4L\n\n#  define SN_time_stamp                   \"timeStamping\"\n#  define LN_time_stamp                   \"Time Stamping\"\n#  define NID_time_stamp                  133\n#  define OBJ_time_stamp                  OBJ_id_kp,8L\n\n/* Additional extended key usage OIDs: Microsoft */\n\n#  define SN_ms_code_ind                  \"msCodeInd\"\n#  define LN_ms_code_ind                  \"Microsoft Individual Code Signing\"\n#  define NID_ms_code_ind                 134\n#  define OBJ_ms_code_ind                 1L,3L,6L,1L,4L,1L,311L,2L,1L,21L\n\n#  define SN_ms_code_com                  \"msCodeCom\"\n#  define LN_ms_code_com                  \"Microsoft Commercial Code Signing\"\n#  define NID_ms_code_com                 135\n#  define OBJ_ms_code_com                 1L,3L,6L,1L,4L,1L,311L,2L,1L,22L\n\n#  define SN_ms_ctl_sign                  \"msCTLSign\"\n#  define LN_ms_ctl_sign                  \"Microsoft Trust List Signing\"\n#  define NID_ms_ctl_sign                 136\n#  define OBJ_ms_ctl_sign                 1L,3L,6L,1L,4L,1L,311L,10L,3L,1L\n\n#  define SN_ms_sgc                       \"msSGC\"\n#  define LN_ms_sgc                       \"Microsoft Server Gated Crypto\"\n#  define NID_ms_sgc                      137\n#  define OBJ_ms_sgc                      1L,3L,6L,1L,4L,1L,311L,10L,3L,3L\n\n#  define SN_ms_efs                       \"msEFS\"\n#  define LN_ms_efs                       \"Microsoft Encrypted File System\"\n#  define NID_ms_efs                      138\n#  define OBJ_ms_efs                      1L,3L,6L,1L,4L,1L,311L,10L,3L,4L\n\n/* Additional usage: Netscape */\n\n#  define SN_ns_sgc                       \"nsSGC\"\n#  define LN_ns_sgc                       \"Netscape Server Gated Crypto\"\n#  define NID_ns_sgc                      139\n#  define OBJ_ns_sgc                      OBJ_netscape,4L,1L\n\n#  define SN_delta_crl                    \"deltaCRL\"\n#  define LN_delta_crl                    \"X509v3 Delta CRL Indicator\"\n#  define NID_delta_crl                   140\n#  define OBJ_delta_crl                   OBJ_id_ce,27L\n\n#  define SN_crl_reason                   \"CRLReason\"\n#  define LN_crl_reason                   \"CRL Reason Code\"\n#  define NID_crl_reason                  141\n#  define OBJ_crl_reason                  OBJ_id_ce,21L\n\n#  define SN_invalidity_date              \"invalidityDate\"\n#  define LN_invalidity_date              \"Invalidity Date\"\n#  define NID_invalidity_date             142\n#  define OBJ_invalidity_date             OBJ_id_ce,24L\n\n#  define SN_sxnet                        \"SXNetID\"\n#  define LN_sxnet                        \"Strong Extranet ID\"\n#  define NID_sxnet                       143\n#  define OBJ_sxnet                       1L,3L,101L,1L,4L,1L\n\n/* PKCS12 and related OBJECT IDENTIFIERS */\n\n#  define OBJ_pkcs12                      OBJ_pkcs,12L\n#  define OBJ_pkcs12_pbeids               OBJ_pkcs12, 1\n\n#  define SN_pbe_WithSHA1And128BitRC4     \"PBE-SHA1-RC4-128\"\n#  define LN_pbe_WithSHA1And128BitRC4     \"pbeWithSHA1And128BitRC4\"\n#  define NID_pbe_WithSHA1And128BitRC4    144\n#  define OBJ_pbe_WithSHA1And128BitRC4    OBJ_pkcs12_pbeids, 1L\n\n#  define SN_pbe_WithSHA1And40BitRC4      \"PBE-SHA1-RC4-40\"\n#  define LN_pbe_WithSHA1And40BitRC4      \"pbeWithSHA1And40BitRC4\"\n#  define NID_pbe_WithSHA1And40BitRC4     145\n#  define OBJ_pbe_WithSHA1And40BitRC4     OBJ_pkcs12_pbeids, 2L\n\n#  define SN_pbe_WithSHA1And3_Key_TripleDES_CBC   \"PBE-SHA1-3DES\"\n#  define LN_pbe_WithSHA1And3_Key_TripleDES_CBC   \"pbeWithSHA1And3-KeyTripleDES-CBC\"\n#  define NID_pbe_WithSHA1And3_Key_TripleDES_CBC  146\n#  define OBJ_pbe_WithSHA1And3_Key_TripleDES_CBC  OBJ_pkcs12_pbeids, 3L\n\n#  define SN_pbe_WithSHA1And2_Key_TripleDES_CBC   \"PBE-SHA1-2DES\"\n#  define LN_pbe_WithSHA1And2_Key_TripleDES_CBC   \"pbeWithSHA1And2-KeyTripleDES-CBC\"\n#  define NID_pbe_WithSHA1And2_Key_TripleDES_CBC  147\n#  define OBJ_pbe_WithSHA1And2_Key_TripleDES_CBC  OBJ_pkcs12_pbeids, 4L\n\n#  define SN_pbe_WithSHA1And128BitRC2_CBC         \"PBE-SHA1-RC2-128\"\n#  define LN_pbe_WithSHA1And128BitRC2_CBC         \"pbeWithSHA1And128BitRC2-CBC\"\n#  define NID_pbe_WithSHA1And128BitRC2_CBC        148\n#  define OBJ_pbe_WithSHA1And128BitRC2_CBC        OBJ_pkcs12_pbeids, 5L\n\n#  define SN_pbe_WithSHA1And40BitRC2_CBC  \"PBE-SHA1-RC2-40\"\n#  define LN_pbe_WithSHA1And40BitRC2_CBC  \"pbeWithSHA1And40BitRC2-CBC\"\n#  define NID_pbe_WithSHA1And40BitRC2_CBC 149\n#  define OBJ_pbe_WithSHA1And40BitRC2_CBC OBJ_pkcs12_pbeids, 6L\n\n#  define OBJ_pkcs12_Version1     OBJ_pkcs12, 10L\n\n#  define OBJ_pkcs12_BagIds       OBJ_pkcs12_Version1, 1L\n\n#  define LN_keyBag               \"keyBag\"\n#  define NID_keyBag              150\n#  define OBJ_keyBag              OBJ_pkcs12_BagIds, 1L\n\n#  define LN_pkcs8ShroudedKeyBag  \"pkcs8ShroudedKeyBag\"\n#  define NID_pkcs8ShroudedKeyBag 151\n#  define OBJ_pkcs8ShroudedKeyBag OBJ_pkcs12_BagIds, 2L\n\n#  define LN_certBag              \"certBag\"\n#  define NID_certBag             152\n#  define OBJ_certBag             OBJ_pkcs12_BagIds, 3L\n\n#  define LN_crlBag               \"crlBag\"\n#  define NID_crlBag              153\n#  define OBJ_crlBag              OBJ_pkcs12_BagIds, 4L\n\n#  define LN_secretBag            \"secretBag\"\n#  define NID_secretBag           154\n#  define OBJ_secretBag           OBJ_pkcs12_BagIds, 5L\n\n#  define LN_safeContentsBag      \"safeContentsBag\"\n#  define NID_safeContentsBag     155\n#  define OBJ_safeContentsBag     OBJ_pkcs12_BagIds, 6L\n\n#  define LN_friendlyName         \"friendlyName\"\n#  define NID_friendlyName        156\n#  define OBJ_friendlyName        OBJ_pkcs9, 20L\n\n#  define LN_localKeyID           \"localKeyID\"\n#  define NID_localKeyID          157\n#  define OBJ_localKeyID          OBJ_pkcs9, 21L\n\n#  define OBJ_certTypes           OBJ_pkcs9, 22L\n\n#  define LN_x509Certificate      \"x509Certificate\"\n#  define NID_x509Certificate     158\n#  define OBJ_x509Certificate     OBJ_certTypes, 1L\n\n#  define LN_sdsiCertificate      \"sdsiCertificate\"\n#  define NID_sdsiCertificate     159\n#  define OBJ_sdsiCertificate     OBJ_certTypes, 2L\n\n#  define OBJ_crlTypes            OBJ_pkcs9, 23L\n\n#  define LN_x509Crl              \"x509Crl\"\n#  define NID_x509Crl             160\n#  define OBJ_x509Crl             OBJ_crlTypes, 1L\n\n/* PKCS#5 v2 OIDs */\n\n#  define LN_pbes2                \"PBES2\"\n#  define NID_pbes2               161\n#  define OBJ_pbes2               OBJ_pkcs,5L,13L\n\n#  define LN_pbmac1               \"PBMAC1\"\n#  define NID_pbmac1              162\n#  define OBJ_pbmac1              OBJ_pkcs,5L,14L\n\n#  define LN_hmacWithSHA1         \"hmacWithSHA1\"\n#  define NID_hmacWithSHA1        163\n#  define OBJ_hmacWithSHA1        OBJ_rsadsi,2L,7L\n\n/* Policy Qualifier Ids */\n\n#  define LN_id_qt_cps            \"Policy Qualifier CPS\"\n#  define SN_id_qt_cps            \"id-qt-cps\"\n#  define NID_id_qt_cps           164\n#  define OBJ_id_qt_cps           OBJ_id_pkix,2L,1L\n\n#  define LN_id_qt_unotice        \"Policy Qualifier User Notice\"\n#  define SN_id_qt_unotice        \"id-qt-unotice\"\n#  define NID_id_qt_unotice       165\n#  define OBJ_id_qt_unotice       OBJ_id_pkix,2L,2L\n\n#  define SN_rc2_64_cbc                   \"RC2-64-CBC\"\n#  define LN_rc2_64_cbc                   \"rc2-64-cbc\"\n#  define NID_rc2_64_cbc                  166\n\n#  define SN_SMIMECapabilities            \"SMIME-CAPS\"\n#  define LN_SMIMECapabilities            \"S/MIME Capabilities\"\n#  define NID_SMIMECapabilities           167\n#  define OBJ_SMIMECapabilities           OBJ_pkcs9,15L\n\n#  define SN_pbeWithMD2AndRC2_CBC         \"PBE-MD2-RC2-64\"\n#  define LN_pbeWithMD2AndRC2_CBC         \"pbeWithMD2AndRC2-CBC\"\n#  define NID_pbeWithMD2AndRC2_CBC        168\n#  define OBJ_pbeWithMD2AndRC2_CBC        OBJ_pkcs,5L,4L\n\n#  define SN_pbeWithMD5AndRC2_CBC         \"PBE-MD5-RC2-64\"\n#  define LN_pbeWithMD5AndRC2_CBC         \"pbeWithMD5AndRC2-CBC\"\n#  define NID_pbeWithMD5AndRC2_CBC        169\n#  define OBJ_pbeWithMD5AndRC2_CBC        OBJ_pkcs,5L,6L\n\n#  define SN_pbeWithSHA1AndDES_CBC        \"PBE-SHA1-DES\"\n#  define LN_pbeWithSHA1AndDES_CBC        \"pbeWithSHA1AndDES-CBC\"\n#  define NID_pbeWithSHA1AndDES_CBC       170\n#  define OBJ_pbeWithSHA1AndDES_CBC       OBJ_pkcs,5L,10L\n\n/* Extension request OIDs */\n\n#  define LN_ms_ext_req                   \"Microsoft Extension Request\"\n#  define SN_ms_ext_req                   \"msExtReq\"\n#  define NID_ms_ext_req                  171\n#  define OBJ_ms_ext_req                  1L,3L,6L,1L,4L,1L,311L,2L,1L,14L\n\n#  define LN_ext_req                      \"Extension Request\"\n#  define SN_ext_req                      \"extReq\"\n#  define NID_ext_req                     172\n#  define OBJ_ext_req                     OBJ_pkcs9,14L\n\n#  define SN_name                         \"name\"\n#  define LN_name                         \"name\"\n#  define NID_name                        173\n#  define OBJ_name                        OBJ_X509,41L\n\n#  define SN_dnQualifier                  \"dnQualifier\"\n#  define LN_dnQualifier                  \"dnQualifier\"\n#  define NID_dnQualifier                 174\n#  define OBJ_dnQualifier                 OBJ_X509,46L\n\n#  define SN_id_pe                        \"id-pe\"\n#  define NID_id_pe                       175\n#  define OBJ_id_pe                       OBJ_id_pkix,1L\n\n#  define SN_id_ad                        \"id-ad\"\n#  define NID_id_ad                       176\n#  define OBJ_id_ad                       OBJ_id_pkix,48L\n\n#  define SN_info_access                  \"authorityInfoAccess\"\n#  define LN_info_access                  \"Authority Information Access\"\n#  define NID_info_access                 177\n#  define OBJ_info_access                 OBJ_id_pe,1L\n\n#  define SN_ad_OCSP                      \"OCSP\"\n#  define LN_ad_OCSP                      \"OCSP\"\n#  define NID_ad_OCSP                     178\n#  define OBJ_ad_OCSP                     OBJ_id_ad,1L\n\n#  define SN_ad_ca_issuers                \"caIssuers\"\n#  define LN_ad_ca_issuers                \"CA Issuers\"\n#  define NID_ad_ca_issuers               179\n#  define OBJ_ad_ca_issuers               OBJ_id_ad,2L\n\n#  define SN_OCSP_sign                    \"OCSPSigning\"\n#  define LN_OCSP_sign                    \"OCSP Signing\"\n#  define NID_OCSP_sign                   180\n#  define OBJ_OCSP_sign                   OBJ_id_kp,9L\n# endif                         /* USE_OBJ_MAC */\n\n# include <openssl/bio.h>\n# include <openssl/asn1.h>\n\n# define OBJ_NAME_TYPE_UNDEF             0x00\n# define OBJ_NAME_TYPE_MD_METH           0x01\n# define OBJ_NAME_TYPE_CIPHER_METH       0x02\n# define OBJ_NAME_TYPE_PKEY_METH         0x03\n# define OBJ_NAME_TYPE_COMP_METH         0x04\n# define OBJ_NAME_TYPE_NUM               0x05\n\n# define OBJ_NAME_ALIAS                  0x8000\n\n# define OBJ_BSEARCH_VALUE_ON_NOMATCH            0x01\n# define OBJ_BSEARCH_FIRST_VALUE_ON_MATCH        0x02\n\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\ntypedef struct obj_name_st {\n    int type;\n    int alias;\n    const char *name;\n    const char *data;\n} OBJ_NAME;\n\n# define         OBJ_create_and_add_object(a,b,c) OBJ_create(a,b,c)\n\nint OBJ_NAME_init(void);\nint OBJ_NAME_new_index(unsigned long (*hash_func) (const char *),\n                       int (*cmp_func) (const char *, const char *),\n                       void (*free_func) (const char *, int, const char *));\nconst char *OBJ_NAME_get(const char *name, int type);\nint OBJ_NAME_add(const char *name, int type, const char *data);\nint OBJ_NAME_remove(const char *name, int type);\nvoid OBJ_NAME_cleanup(int type); /* -1 for everything */\nvoid OBJ_NAME_do_all(int type, void (*fn) (const OBJ_NAME *, void *arg),\n                     void *arg);\nvoid OBJ_NAME_do_all_sorted(int type,\n                            void (*fn) (const OBJ_NAME *, void *arg),\n                            void *arg);\n\nASN1_OBJECT *OBJ_dup(const ASN1_OBJECT *o);\nASN1_OBJECT *OBJ_nid2obj(int n);\nconst char *OBJ_nid2ln(int n);\nconst char *OBJ_nid2sn(int n);\nint OBJ_obj2nid(const ASN1_OBJECT *o);\nASN1_OBJECT *OBJ_txt2obj(const char *s, int no_name);\nint OBJ_obj2txt(char *buf, int buf_len, const ASN1_OBJECT *a, int no_name);\nint OBJ_txt2nid(const char *s);\nint OBJ_ln2nid(const char *s);\nint OBJ_sn2nid(const char *s);\nint OBJ_cmp(const ASN1_OBJECT *a, const ASN1_OBJECT *b);\nconst void *OBJ_bsearch_(const void *key, const void *base, int num, int size,\n                         int (*cmp) (const void *, const void *));\nconst void *OBJ_bsearch_ex_(const void *key, const void *base, int num,\n                            int size,\n                            int (*cmp) (const void *, const void *),\n                            int flags);\n\n# define _DECLARE_OBJ_BSEARCH_CMP_FN(scope, type1, type2, nm)    \\\n  static int nm##_cmp_BSEARCH_CMP_FN(const void *, const void *); \\\n  static int nm##_cmp(type1 const *, type2 const *); \\\n  scope type2 * OBJ_bsearch_##nm(type1 *key, type2 const *base, int num)\n\n# define DECLARE_OBJ_BSEARCH_CMP_FN(type1, type2, cmp)   \\\n  _DECLARE_OBJ_BSEARCH_CMP_FN(static, type1, type2, cmp)\n# define DECLARE_OBJ_BSEARCH_GLOBAL_CMP_FN(type1, type2, nm)     \\\n  type2 * OBJ_bsearch_##nm(type1 *key, type2 const *base, int num)\n\n/*-\n * Unsolved problem: if a type is actually a pointer type, like\n * nid_triple is, then its impossible to get a const where you need\n * it. Consider:\n *\n * typedef int nid_triple[3];\n * const void *a_;\n * const nid_triple const *a = a_;\n *\n * The assignement discards a const because what you really want is:\n *\n * const int const * const *a = a_;\n *\n * But if you do that, you lose the fact that a is an array of 3 ints,\n * which breaks comparison functions.\n *\n * Thus we end up having to cast, sadly, or unpack the\n * declarations. Or, as I finally did in this case, delcare nid_triple\n * to be a struct, which it should have been in the first place.\n *\n * Ben, August 2008.\n *\n * Also, strictly speaking not all types need be const, but handling\n * the non-constness means a lot of complication, and in practice\n * comparison routines do always not touch their arguments.\n */\n\n# define IMPLEMENT_OBJ_BSEARCH_CMP_FN(type1, type2, nm)  \\\n  static int nm##_cmp_BSEARCH_CMP_FN(const void *a_, const void *b_)    \\\n      { \\\n      type1 const *a = a_; \\\n      type2 const *b = b_; \\\n      return nm##_cmp(a,b); \\\n      } \\\n  static type2 *OBJ_bsearch_##nm(type1 *key, type2 const *base, int num) \\\n      { \\\n      return (type2 *)OBJ_bsearch_(key, base, num, sizeof(type2), \\\n                                        nm##_cmp_BSEARCH_CMP_FN); \\\n      } \\\n      extern void dummy_prototype(void)\n\n# define IMPLEMENT_OBJ_BSEARCH_GLOBAL_CMP_FN(type1, type2, nm)   \\\n  static int nm##_cmp_BSEARCH_CMP_FN(const void *a_, const void *b_)    \\\n      { \\\n      type1 const *a = a_; \\\n      type2 const *b = b_; \\\n      return nm##_cmp(a,b); \\\n      } \\\n  type2 *OBJ_bsearch_##nm(type1 *key, type2 const *base, int num) \\\n      { \\\n      return (type2 *)OBJ_bsearch_(key, base, num, sizeof(type2), \\\n                                        nm##_cmp_BSEARCH_CMP_FN); \\\n      } \\\n      extern void dummy_prototype(void)\n\n# define OBJ_bsearch(type1,key,type2,base,num,cmp)                              \\\n  ((type2 *)OBJ_bsearch_(CHECKED_PTR_OF(type1,key),CHECKED_PTR_OF(type2,base), \\\n                         num,sizeof(type2),                             \\\n                         ((void)CHECKED_PTR_OF(type1,cmp##_type_1),     \\\n                          (void)CHECKED_PTR_OF(type2,cmp##_type_2),     \\\n                          cmp##_BSEARCH_CMP_FN)))\n\n# define OBJ_bsearch_ex(type1,key,type2,base,num,cmp,flags)                      \\\n  ((type2 *)OBJ_bsearch_ex_(CHECKED_PTR_OF(type1,key),CHECKED_PTR_OF(type2,base), \\\n                         num,sizeof(type2),                             \\\n                         ((void)CHECKED_PTR_OF(type1,cmp##_type_1),     \\\n                          (void)type_2=CHECKED_PTR_OF(type2,cmp##_type_2), \\\n                          cmp##_BSEARCH_CMP_FN)),flags)\n\nint OBJ_new_nid(int num);\nint OBJ_add_object(const ASN1_OBJECT *obj);\nint OBJ_create(const char *oid, const char *sn, const char *ln);\nvoid OBJ_cleanup(void);\nint OBJ_create_objects(BIO *in);\n\nint OBJ_find_sigid_algs(int signid, int *pdig_nid, int *ppkey_nid);\nint OBJ_find_sigid_by_algs(int *psignid, int dig_nid, int pkey_nid);\nint OBJ_add_sigid(int signid, int dig_id, int pkey_id);\nvoid OBJ_sigid_free(void);\n\nextern int obj_cleanup_defer;\nvoid check_defer(int nid);\n\n/* BEGIN ERROR CODES */\n/*\n * The following lines are auto generated by the script mkerr.pl. Any changes\n * made after this point may be overwritten when the script is next run.\n */\nvoid ERR_load_OBJ_strings(void);\n\n/* Error codes for the OBJ functions. */\n\n/* Function codes. */\n# define OBJ_F_OBJ_ADD_OBJECT                             105\n# define OBJ_F_OBJ_CREATE                                 100\n# define OBJ_F_OBJ_DUP                                    101\n# define OBJ_F_OBJ_NAME_NEW_INDEX                         106\n# define OBJ_F_OBJ_NID2LN                                 102\n# define OBJ_F_OBJ_NID2OBJ                                103\n# define OBJ_F_OBJ_NID2SN                                 104\n\n/* Reason codes. */\n# define OBJ_R_MALLOC_FAILURE                             100\n# define OBJ_R_UNKNOWN_NID                                101\n\n#ifdef  __cplusplus\n}\n#endif\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/x86/include/openssl/ocsp.h",
    "content": "/* ocsp.h */\n/*\n * Written by Tom Titchener <Tom_Titchener@groove.net> for the OpenSSL\n * project.\n */\n\n/*\n * History: This file was transfered to Richard Levitte from CertCo by Kathy\n * Weinhold in mid-spring 2000 to be included in OpenSSL or released as a\n * patch kit.\n */\n\n/* ====================================================================\n * Copyright (c) 1998-2000 The OpenSSL Project.  All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n *\n * 1. Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n *\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in\n *    the documentation and/or other materials provided with the\n *    distribution.\n *\n * 3. All advertising materials mentioning features or use of this\n *    software must display the following acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit. (http://www.openssl.org/)\"\n *\n * 4. The names \"OpenSSL Toolkit\" and \"OpenSSL Project\" must not be used to\n *    endorse or promote products derived from this software without\n *    prior written permission. For written permission, please contact\n *    openssl-core@openssl.org.\n *\n * 5. Products derived from this software may not be called \"OpenSSL\"\n *    nor may \"OpenSSL\" appear in their names without prior written\n *    permission of the OpenSSL Project.\n *\n * 6. Redistributions of any form whatsoever must retain the following\n *    acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit (http://www.openssl.org/)\"\n *\n * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY\n * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\n * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR\n * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\n * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,\n * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED\n * OF THE POSSIBILITY OF SUCH DAMAGE.\n * ====================================================================\n *\n * This product includes cryptographic software written by Eric Young\n * (eay@cryptsoft.com).  This product includes software written by Tim\n * Hudson (tjh@cryptsoft.com).\n *\n */\n\n#ifndef HEADER_OCSP_H\n# define HEADER_OCSP_H\n\n# include <openssl/ossl_typ.h>\n# include <openssl/x509.h>\n# include <openssl/x509v3.h>\n# include <openssl/safestack.h>\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n/* Various flags and values */\n\n# define OCSP_DEFAULT_NONCE_LENGTH       16\n\n# define OCSP_NOCERTS                    0x1\n# define OCSP_NOINTERN                   0x2\n# define OCSP_NOSIGS                     0x4\n# define OCSP_NOCHAIN                    0x8\n# define OCSP_NOVERIFY                   0x10\n# define OCSP_NOEXPLICIT                 0x20\n# define OCSP_NOCASIGN                   0x40\n# define OCSP_NODELEGATED                0x80\n# define OCSP_NOCHECKS                   0x100\n# define OCSP_TRUSTOTHER                 0x200\n# define OCSP_RESPID_KEY                 0x400\n# define OCSP_NOTIME                     0x800\n\n/*-  CertID ::= SEQUENCE {\n *       hashAlgorithm            AlgorithmIdentifier,\n *       issuerNameHash     OCTET STRING, -- Hash of Issuer's DN\n *       issuerKeyHash      OCTET STRING, -- Hash of Issuers public key (excluding the tag & length fields)\n *       serialNumber       CertificateSerialNumber }\n */\ntypedef struct ocsp_cert_id_st {\n    X509_ALGOR *hashAlgorithm;\n    ASN1_OCTET_STRING *issuerNameHash;\n    ASN1_OCTET_STRING *issuerKeyHash;\n    ASN1_INTEGER *serialNumber;\n} OCSP_CERTID;\n\nDECLARE_STACK_OF(OCSP_CERTID)\n\n/*-  Request ::=     SEQUENCE {\n *       reqCert                    CertID,\n *       singleRequestExtensions    [0] EXPLICIT Extensions OPTIONAL }\n */\ntypedef struct ocsp_one_request_st {\n    OCSP_CERTID *reqCert;\n    STACK_OF(X509_EXTENSION) *singleRequestExtensions;\n} OCSP_ONEREQ;\n\nDECLARE_STACK_OF(OCSP_ONEREQ)\nDECLARE_ASN1_SET_OF(OCSP_ONEREQ)\n\n/*-  TBSRequest      ::=     SEQUENCE {\n *       version             [0] EXPLICIT Version DEFAULT v1,\n *       requestorName       [1] EXPLICIT GeneralName OPTIONAL,\n *       requestList             SEQUENCE OF Request,\n *       requestExtensions   [2] EXPLICIT Extensions OPTIONAL }\n */\ntypedef struct ocsp_req_info_st {\n    ASN1_INTEGER *version;\n    GENERAL_NAME *requestorName;\n    STACK_OF(OCSP_ONEREQ) *requestList;\n    STACK_OF(X509_EXTENSION) *requestExtensions;\n} OCSP_REQINFO;\n\n/*-  Signature       ::=     SEQUENCE {\n *       signatureAlgorithm   AlgorithmIdentifier,\n *       signature            BIT STRING,\n *       certs                [0] EXPLICIT SEQUENCE OF Certificate OPTIONAL }\n */\ntypedef struct ocsp_signature_st {\n    X509_ALGOR *signatureAlgorithm;\n    ASN1_BIT_STRING *signature;\n    STACK_OF(X509) *certs;\n} OCSP_SIGNATURE;\n\n/*-  OCSPRequest     ::=     SEQUENCE {\n *       tbsRequest                  TBSRequest,\n *       optionalSignature   [0]     EXPLICIT Signature OPTIONAL }\n */\ntypedef struct ocsp_request_st {\n    OCSP_REQINFO *tbsRequest;\n    OCSP_SIGNATURE *optionalSignature; /* OPTIONAL */\n} OCSP_REQUEST;\n\n/*-  OCSPResponseStatus ::= ENUMERATED {\n *       successful            (0),      --Response has valid confirmations\n *       malformedRequest      (1),      --Illegal confirmation request\n *       internalError         (2),      --Internal error in issuer\n *       tryLater              (3),      --Try again later\n *                                       --(4) is not used\n *       sigRequired           (5),      --Must sign the request\n *       unauthorized          (6)       --Request unauthorized\n *   }\n */\n# define OCSP_RESPONSE_STATUS_SUCCESSFUL          0\n# define OCSP_RESPONSE_STATUS_MALFORMEDREQUEST     1\n# define OCSP_RESPONSE_STATUS_INTERNALERROR        2\n# define OCSP_RESPONSE_STATUS_TRYLATER             3\n# define OCSP_RESPONSE_STATUS_SIGREQUIRED          5\n# define OCSP_RESPONSE_STATUS_UNAUTHORIZED         6\n\n/*-  ResponseBytes ::=       SEQUENCE {\n *       responseType   OBJECT IDENTIFIER,\n *       response       OCTET STRING }\n */\ntypedef struct ocsp_resp_bytes_st {\n    ASN1_OBJECT *responseType;\n    ASN1_OCTET_STRING *response;\n} OCSP_RESPBYTES;\n\n/*-  OCSPResponse ::= SEQUENCE {\n *      responseStatus         OCSPResponseStatus,\n *      responseBytes          [0] EXPLICIT ResponseBytes OPTIONAL }\n */\nstruct ocsp_response_st {\n    ASN1_ENUMERATED *responseStatus;\n    OCSP_RESPBYTES *responseBytes;\n};\n\n/*-  ResponderID ::= CHOICE {\n *      byName   [1] Name,\n *      byKey    [2] KeyHash }\n */\n# define V_OCSP_RESPID_NAME 0\n# define V_OCSP_RESPID_KEY  1\nstruct ocsp_responder_id_st {\n    int type;\n    union {\n        X509_NAME *byName;\n        ASN1_OCTET_STRING *byKey;\n    } value;\n};\n\nDECLARE_STACK_OF(OCSP_RESPID)\nDECLARE_ASN1_FUNCTIONS(OCSP_RESPID)\n\n/*-  KeyHash ::= OCTET STRING --SHA-1 hash of responder's public key\n *                            --(excluding the tag and length fields)\n */\n\n/*-  RevokedInfo ::= SEQUENCE {\n *       revocationTime              GeneralizedTime,\n *       revocationReason    [0]     EXPLICIT CRLReason OPTIONAL }\n */\ntypedef struct ocsp_revoked_info_st {\n    ASN1_GENERALIZEDTIME *revocationTime;\n    ASN1_ENUMERATED *revocationReason;\n} OCSP_REVOKEDINFO;\n\n/*-  CertStatus ::= CHOICE {\n *       good                [0]     IMPLICIT NULL,\n *       revoked             [1]     IMPLICIT RevokedInfo,\n *       unknown             [2]     IMPLICIT UnknownInfo }\n */\n# define V_OCSP_CERTSTATUS_GOOD    0\n# define V_OCSP_CERTSTATUS_REVOKED 1\n# define V_OCSP_CERTSTATUS_UNKNOWN 2\ntypedef struct ocsp_cert_status_st {\n    int type;\n    union {\n        ASN1_NULL *good;\n        OCSP_REVOKEDINFO *revoked;\n        ASN1_NULL *unknown;\n    } value;\n} OCSP_CERTSTATUS;\n\n/*-  SingleResponse ::= SEQUENCE {\n *      certID                       CertID,\n *      certStatus                   CertStatus,\n *      thisUpdate                   GeneralizedTime,\n *      nextUpdate           [0]     EXPLICIT GeneralizedTime OPTIONAL,\n *      singleExtensions     [1]     EXPLICIT Extensions OPTIONAL }\n */\ntypedef struct ocsp_single_response_st {\n    OCSP_CERTID *certId;\n    OCSP_CERTSTATUS *certStatus;\n    ASN1_GENERALIZEDTIME *thisUpdate;\n    ASN1_GENERALIZEDTIME *nextUpdate;\n    STACK_OF(X509_EXTENSION) *singleExtensions;\n} OCSP_SINGLERESP;\n\nDECLARE_STACK_OF(OCSP_SINGLERESP)\nDECLARE_ASN1_SET_OF(OCSP_SINGLERESP)\n\n/*-  ResponseData ::= SEQUENCE {\n *      version              [0] EXPLICIT Version DEFAULT v1,\n *      responderID              ResponderID,\n *      producedAt               GeneralizedTime,\n *      responses                SEQUENCE OF SingleResponse,\n *      responseExtensions   [1] EXPLICIT Extensions OPTIONAL }\n */\ntypedef struct ocsp_response_data_st {\n    ASN1_INTEGER *version;\n    OCSP_RESPID *responderId;\n    ASN1_GENERALIZEDTIME *producedAt;\n    STACK_OF(OCSP_SINGLERESP) *responses;\n    STACK_OF(X509_EXTENSION) *responseExtensions;\n} OCSP_RESPDATA;\n\n/*-  BasicOCSPResponse       ::= SEQUENCE {\n *      tbsResponseData      ResponseData,\n *      signatureAlgorithm   AlgorithmIdentifier,\n *      signature            BIT STRING,\n *      certs                [0] EXPLICIT SEQUENCE OF Certificate OPTIONAL }\n */\n  /*\n   * Note 1: The value for \"signature\" is specified in the OCSP rfc2560 as\n   * follows: \"The value for the signature SHALL be computed on the hash of\n   * the DER encoding ResponseData.\" This means that you must hash the\n   * DER-encoded tbsResponseData, and then run it through a crypto-signing\n   * function, which will (at least w/RSA) do a hash-'n'-private-encrypt\n   * operation.  This seems a bit odd, but that's the spec.  Also note that\n   * the data structures do not leave anywhere to independently specify the\n   * algorithm used for the initial hash. So, we look at the\n   * signature-specification algorithm, and try to do something intelligent.\n   * -- Kathy Weinhold, CertCo\n   */\n  /*\n   * Note 2: It seems that the mentioned passage from RFC 2560 (section\n   * 4.2.1) is open for interpretation.  I've done tests against another\n   * responder, and found that it doesn't do the double hashing that the RFC\n   * seems to say one should.  Therefore, all relevant functions take a flag\n   * saying which variant should be used.  -- Richard Levitte, OpenSSL team\n   * and CeloCom\n   */\ntypedef struct ocsp_basic_response_st {\n    OCSP_RESPDATA *tbsResponseData;\n    X509_ALGOR *signatureAlgorithm;\n    ASN1_BIT_STRING *signature;\n    STACK_OF(X509) *certs;\n} OCSP_BASICRESP;\n\n/*-\n *   CRLReason ::= ENUMERATED {\n *        unspecified             (0),\n *        keyCompromise           (1),\n *        cACompromise            (2),\n *        affiliationChanged      (3),\n *        superseded              (4),\n *        cessationOfOperation    (5),\n *        certificateHold         (6),\n *        removeFromCRL           (8) }\n */\n# define OCSP_REVOKED_STATUS_NOSTATUS               -1\n# define OCSP_REVOKED_STATUS_UNSPECIFIED             0\n# define OCSP_REVOKED_STATUS_KEYCOMPROMISE           1\n# define OCSP_REVOKED_STATUS_CACOMPROMISE            2\n# define OCSP_REVOKED_STATUS_AFFILIATIONCHANGED      3\n# define OCSP_REVOKED_STATUS_SUPERSEDED              4\n# define OCSP_REVOKED_STATUS_CESSATIONOFOPERATION    5\n# define OCSP_REVOKED_STATUS_CERTIFICATEHOLD         6\n# define OCSP_REVOKED_STATUS_REMOVEFROMCRL           8\n\n/*-\n * CrlID ::= SEQUENCE {\n *     crlUrl               [0]     EXPLICIT IA5String OPTIONAL,\n *     crlNum               [1]     EXPLICIT INTEGER OPTIONAL,\n *     crlTime              [2]     EXPLICIT GeneralizedTime OPTIONAL }\n */\ntypedef struct ocsp_crl_id_st {\n    ASN1_IA5STRING *crlUrl;\n    ASN1_INTEGER *crlNum;\n    ASN1_GENERALIZEDTIME *crlTime;\n} OCSP_CRLID;\n\n/*-\n * ServiceLocator ::= SEQUENCE {\n *      issuer    Name,\n *      locator   AuthorityInfoAccessSyntax OPTIONAL }\n */\ntypedef struct ocsp_service_locator_st {\n    X509_NAME *issuer;\n    STACK_OF(ACCESS_DESCRIPTION) *locator;\n} OCSP_SERVICELOC;\n\n# define PEM_STRING_OCSP_REQUEST \"OCSP REQUEST\"\n# define PEM_STRING_OCSP_RESPONSE \"OCSP RESPONSE\"\n\n# define d2i_OCSP_REQUEST_bio(bp,p) ASN1_d2i_bio_of(OCSP_REQUEST,OCSP_REQUEST_new,d2i_OCSP_REQUEST,bp,p)\n\n# define d2i_OCSP_RESPONSE_bio(bp,p) ASN1_d2i_bio_of(OCSP_RESPONSE,OCSP_RESPONSE_new,d2i_OCSP_RESPONSE,bp,p)\n\n# define PEM_read_bio_OCSP_REQUEST(bp,x,cb) (OCSP_REQUEST *)PEM_ASN1_read_bio( \\\n     (char *(*)())d2i_OCSP_REQUEST,PEM_STRING_OCSP_REQUEST,bp,(char **)x,cb,NULL)\n\n# define PEM_read_bio_OCSP_RESPONSE(bp,x,cb)(OCSP_RESPONSE *)PEM_ASN1_read_bio(\\\n     (char *(*)())d2i_OCSP_RESPONSE,PEM_STRING_OCSP_RESPONSE,bp,(char **)x,cb,NULL)\n\n# define PEM_write_bio_OCSP_REQUEST(bp,o) \\\n    PEM_ASN1_write_bio((int (*)())i2d_OCSP_REQUEST,PEM_STRING_OCSP_REQUEST,\\\n                        bp,(char *)o, NULL,NULL,0,NULL,NULL)\n\n# define PEM_write_bio_OCSP_RESPONSE(bp,o) \\\n    PEM_ASN1_write_bio((int (*)())i2d_OCSP_RESPONSE,PEM_STRING_OCSP_RESPONSE,\\\n                        bp,(char *)o, NULL,NULL,0,NULL,NULL)\n\n# define i2d_OCSP_RESPONSE_bio(bp,o) ASN1_i2d_bio_of(OCSP_RESPONSE,i2d_OCSP_RESPONSE,bp,o)\n\n# define i2d_OCSP_REQUEST_bio(bp,o) ASN1_i2d_bio_of(OCSP_REQUEST,i2d_OCSP_REQUEST,bp,o)\n\n# define OCSP_REQUEST_sign(o,pkey,md) \\\n        ASN1_item_sign(ASN1_ITEM_rptr(OCSP_REQINFO),\\\n                o->optionalSignature->signatureAlgorithm,NULL,\\\n                o->optionalSignature->signature,o->tbsRequest,pkey,md)\n\n# define OCSP_BASICRESP_sign(o,pkey,md,d) \\\n        ASN1_item_sign(ASN1_ITEM_rptr(OCSP_RESPDATA),o->signatureAlgorithm,NULL,\\\n                o->signature,o->tbsResponseData,pkey,md)\n\n# define OCSP_REQUEST_verify(a,r) ASN1_item_verify(ASN1_ITEM_rptr(OCSP_REQINFO),\\\n        a->optionalSignature->signatureAlgorithm,\\\n        a->optionalSignature->signature,a->tbsRequest,r)\n\n# define OCSP_BASICRESP_verify(a,r,d) ASN1_item_verify(ASN1_ITEM_rptr(OCSP_RESPDATA),\\\n        a->signatureAlgorithm,a->signature,a->tbsResponseData,r)\n\n# define ASN1_BIT_STRING_digest(data,type,md,len) \\\n        ASN1_item_digest(ASN1_ITEM_rptr(ASN1_BIT_STRING),type,data,md,len)\n\n# define OCSP_CERTSTATUS_dup(cs)\\\n                (OCSP_CERTSTATUS*)ASN1_dup((int(*)())i2d_OCSP_CERTSTATUS,\\\n                (char *(*)())d2i_OCSP_CERTSTATUS,(char *)(cs))\n\nOCSP_CERTID *OCSP_CERTID_dup(OCSP_CERTID *id);\n\nOCSP_RESPONSE *OCSP_sendreq_bio(BIO *b, const char *path, OCSP_REQUEST *req);\nOCSP_REQ_CTX *OCSP_sendreq_new(BIO *io, const char *path, OCSP_REQUEST *req,\n                               int maxline);\nint OCSP_REQ_CTX_nbio(OCSP_REQ_CTX *rctx);\nint OCSP_sendreq_nbio(OCSP_RESPONSE **presp, OCSP_REQ_CTX *rctx);\nOCSP_REQ_CTX *OCSP_REQ_CTX_new(BIO *io, int maxline);\nvoid OCSP_REQ_CTX_free(OCSP_REQ_CTX *rctx);\nvoid OCSP_set_max_response_length(OCSP_REQ_CTX *rctx, unsigned long len);\nint OCSP_REQ_CTX_i2d(OCSP_REQ_CTX *rctx, const ASN1_ITEM *it,\n                     ASN1_VALUE *val);\nint OCSP_REQ_CTX_nbio_d2i(OCSP_REQ_CTX *rctx, ASN1_VALUE **pval,\n                          const ASN1_ITEM *it);\nBIO *OCSP_REQ_CTX_get0_mem_bio(OCSP_REQ_CTX *rctx);\nint OCSP_REQ_CTX_i2d(OCSP_REQ_CTX *rctx, const ASN1_ITEM *it,\n                     ASN1_VALUE *val);\nint OCSP_REQ_CTX_http(OCSP_REQ_CTX *rctx, const char *op, const char *path);\nint OCSP_REQ_CTX_set1_req(OCSP_REQ_CTX *rctx, OCSP_REQUEST *req);\nint OCSP_REQ_CTX_add1_header(OCSP_REQ_CTX *rctx,\n                             const char *name, const char *value);\n\nOCSP_CERTID *OCSP_cert_to_id(const EVP_MD *dgst, X509 *subject, X509 *issuer);\n\nOCSP_CERTID *OCSP_cert_id_new(const EVP_MD *dgst,\n                              X509_NAME *issuerName,\n                              ASN1_BIT_STRING *issuerKey,\n                              ASN1_INTEGER *serialNumber);\n\nOCSP_ONEREQ *OCSP_request_add0_id(OCSP_REQUEST *req, OCSP_CERTID *cid);\n\nint OCSP_request_add1_nonce(OCSP_REQUEST *req, unsigned char *val, int len);\nint OCSP_basic_add1_nonce(OCSP_BASICRESP *resp, unsigned char *val, int len);\nint OCSP_check_nonce(OCSP_REQUEST *req, OCSP_BASICRESP *bs);\nint OCSP_copy_nonce(OCSP_BASICRESP *resp, OCSP_REQUEST *req);\n\nint OCSP_request_set1_name(OCSP_REQUEST *req, X509_NAME *nm);\nint OCSP_request_add1_cert(OCSP_REQUEST *req, X509 *cert);\n\nint OCSP_request_sign(OCSP_REQUEST *req,\n                      X509 *signer,\n                      EVP_PKEY *key,\n                      const EVP_MD *dgst,\n                      STACK_OF(X509) *certs, unsigned long flags);\n\nint OCSP_response_status(OCSP_RESPONSE *resp);\nOCSP_BASICRESP *OCSP_response_get1_basic(OCSP_RESPONSE *resp);\n\nint OCSP_resp_count(OCSP_BASICRESP *bs);\nOCSP_SINGLERESP *OCSP_resp_get0(OCSP_BASICRESP *bs, int idx);\nint OCSP_resp_find(OCSP_BASICRESP *bs, OCSP_CERTID *id, int last);\nint OCSP_single_get0_status(OCSP_SINGLERESP *single, int *reason,\n                            ASN1_GENERALIZEDTIME **revtime,\n                            ASN1_GENERALIZEDTIME **thisupd,\n                            ASN1_GENERALIZEDTIME **nextupd);\nint OCSP_resp_find_status(OCSP_BASICRESP *bs, OCSP_CERTID *id, int *status,\n                          int *reason,\n                          ASN1_GENERALIZEDTIME **revtime,\n                          ASN1_GENERALIZEDTIME **thisupd,\n                          ASN1_GENERALIZEDTIME **nextupd);\nint OCSP_check_validity(ASN1_GENERALIZEDTIME *thisupd,\n                        ASN1_GENERALIZEDTIME *nextupd, long sec, long maxsec);\n\nint OCSP_request_verify(OCSP_REQUEST *req, STACK_OF(X509) *certs,\n                        X509_STORE *store, unsigned long flags);\n\nint OCSP_parse_url(const char *url, char **phost, char **pport, char **ppath,\n                   int *pssl);\n\nint OCSP_id_issuer_cmp(OCSP_CERTID *a, OCSP_CERTID *b);\nint OCSP_id_cmp(OCSP_CERTID *a, OCSP_CERTID *b);\n\nint OCSP_request_onereq_count(OCSP_REQUEST *req);\nOCSP_ONEREQ *OCSP_request_onereq_get0(OCSP_REQUEST *req, int i);\nOCSP_CERTID *OCSP_onereq_get0_id(OCSP_ONEREQ *one);\nint OCSP_id_get0_info(ASN1_OCTET_STRING **piNameHash, ASN1_OBJECT **pmd,\n                      ASN1_OCTET_STRING **pikeyHash,\n                      ASN1_INTEGER **pserial, OCSP_CERTID *cid);\nint OCSP_request_is_signed(OCSP_REQUEST *req);\nOCSP_RESPONSE *OCSP_response_create(int status, OCSP_BASICRESP *bs);\nOCSP_SINGLERESP *OCSP_basic_add1_status(OCSP_BASICRESP *rsp,\n                                        OCSP_CERTID *cid,\n                                        int status, int reason,\n                                        ASN1_TIME *revtime,\n                                        ASN1_TIME *thisupd,\n                                        ASN1_TIME *nextupd);\nint OCSP_basic_add1_cert(OCSP_BASICRESP *resp, X509 *cert);\nint OCSP_basic_sign(OCSP_BASICRESP *brsp,\n                    X509 *signer, EVP_PKEY *key, const EVP_MD *dgst,\n                    STACK_OF(X509) *certs, unsigned long flags);\n\nX509_EXTENSION *OCSP_crlID_new(char *url, long *n, char *tim);\n\nX509_EXTENSION *OCSP_accept_responses_new(char **oids);\n\nX509_EXTENSION *OCSP_archive_cutoff_new(char *tim);\n\nX509_EXTENSION *OCSP_url_svcloc_new(X509_NAME *issuer, char **urls);\n\nint OCSP_REQUEST_get_ext_count(OCSP_REQUEST *x);\nint OCSP_REQUEST_get_ext_by_NID(OCSP_REQUEST *x, int nid, int lastpos);\nint OCSP_REQUEST_get_ext_by_OBJ(OCSP_REQUEST *x, ASN1_OBJECT *obj,\n                                int lastpos);\nint OCSP_REQUEST_get_ext_by_critical(OCSP_REQUEST *x, int crit, int lastpos);\nX509_EXTENSION *OCSP_REQUEST_get_ext(OCSP_REQUEST *x, int loc);\nX509_EXTENSION *OCSP_REQUEST_delete_ext(OCSP_REQUEST *x, int loc);\nvoid *OCSP_REQUEST_get1_ext_d2i(OCSP_REQUEST *x, int nid, int *crit,\n                                int *idx);\nint OCSP_REQUEST_add1_ext_i2d(OCSP_REQUEST *x, int nid, void *value, int crit,\n                              unsigned long flags);\nint OCSP_REQUEST_add_ext(OCSP_REQUEST *x, X509_EXTENSION *ex, int loc);\n\nint OCSP_ONEREQ_get_ext_count(OCSP_ONEREQ *x);\nint OCSP_ONEREQ_get_ext_by_NID(OCSP_ONEREQ *x, int nid, int lastpos);\nint OCSP_ONEREQ_get_ext_by_OBJ(OCSP_ONEREQ *x, ASN1_OBJECT *obj, int lastpos);\nint OCSP_ONEREQ_get_ext_by_critical(OCSP_ONEREQ *x, int crit, int lastpos);\nX509_EXTENSION *OCSP_ONEREQ_get_ext(OCSP_ONEREQ *x, int loc);\nX509_EXTENSION *OCSP_ONEREQ_delete_ext(OCSP_ONEREQ *x, int loc);\nvoid *OCSP_ONEREQ_get1_ext_d2i(OCSP_ONEREQ *x, int nid, int *crit, int *idx);\nint OCSP_ONEREQ_add1_ext_i2d(OCSP_ONEREQ *x, int nid, void *value, int crit,\n                             unsigned long flags);\nint OCSP_ONEREQ_add_ext(OCSP_ONEREQ *x, X509_EXTENSION *ex, int loc);\n\nint OCSP_BASICRESP_get_ext_count(OCSP_BASICRESP *x);\nint OCSP_BASICRESP_get_ext_by_NID(OCSP_BASICRESP *x, int nid, int lastpos);\nint OCSP_BASICRESP_get_ext_by_OBJ(OCSP_BASICRESP *x, ASN1_OBJECT *obj,\n                                  int lastpos);\nint OCSP_BASICRESP_get_ext_by_critical(OCSP_BASICRESP *x, int crit,\n                                       int lastpos);\nX509_EXTENSION *OCSP_BASICRESP_get_ext(OCSP_BASICRESP *x, int loc);\nX509_EXTENSION *OCSP_BASICRESP_delete_ext(OCSP_BASICRESP *x, int loc);\nvoid *OCSP_BASICRESP_get1_ext_d2i(OCSP_BASICRESP *x, int nid, int *crit,\n                                  int *idx);\nint OCSP_BASICRESP_add1_ext_i2d(OCSP_BASICRESP *x, int nid, void *value,\n                                int crit, unsigned long flags);\nint OCSP_BASICRESP_add_ext(OCSP_BASICRESP *x, X509_EXTENSION *ex, int loc);\n\nint OCSP_SINGLERESP_get_ext_count(OCSP_SINGLERESP *x);\nint OCSP_SINGLERESP_get_ext_by_NID(OCSP_SINGLERESP *x, int nid, int lastpos);\nint OCSP_SINGLERESP_get_ext_by_OBJ(OCSP_SINGLERESP *x, ASN1_OBJECT *obj,\n                                   int lastpos);\nint OCSP_SINGLERESP_get_ext_by_critical(OCSP_SINGLERESP *x, int crit,\n                                        int lastpos);\nX509_EXTENSION *OCSP_SINGLERESP_get_ext(OCSP_SINGLERESP *x, int loc);\nX509_EXTENSION *OCSP_SINGLERESP_delete_ext(OCSP_SINGLERESP *x, int loc);\nvoid *OCSP_SINGLERESP_get1_ext_d2i(OCSP_SINGLERESP *x, int nid, int *crit,\n                                   int *idx);\nint OCSP_SINGLERESP_add1_ext_i2d(OCSP_SINGLERESP *x, int nid, void *value,\n                                 int crit, unsigned long flags);\nint OCSP_SINGLERESP_add_ext(OCSP_SINGLERESP *x, X509_EXTENSION *ex, int loc);\n\nDECLARE_ASN1_FUNCTIONS(OCSP_SINGLERESP)\nDECLARE_ASN1_FUNCTIONS(OCSP_CERTSTATUS)\nDECLARE_ASN1_FUNCTIONS(OCSP_REVOKEDINFO)\nDECLARE_ASN1_FUNCTIONS(OCSP_BASICRESP)\nDECLARE_ASN1_FUNCTIONS(OCSP_RESPDATA)\nDECLARE_ASN1_FUNCTIONS(OCSP_RESPID)\nDECLARE_ASN1_FUNCTIONS(OCSP_RESPONSE)\nDECLARE_ASN1_FUNCTIONS(OCSP_RESPBYTES)\nDECLARE_ASN1_FUNCTIONS(OCSP_ONEREQ)\nDECLARE_ASN1_FUNCTIONS(OCSP_CERTID)\nDECLARE_ASN1_FUNCTIONS(OCSP_REQUEST)\nDECLARE_ASN1_FUNCTIONS(OCSP_SIGNATURE)\nDECLARE_ASN1_FUNCTIONS(OCSP_REQINFO)\nDECLARE_ASN1_FUNCTIONS(OCSP_CRLID)\nDECLARE_ASN1_FUNCTIONS(OCSP_SERVICELOC)\n\nconst char *OCSP_response_status_str(long s);\nconst char *OCSP_cert_status_str(long s);\nconst char *OCSP_crl_reason_str(long s);\n\nint OCSP_REQUEST_print(BIO *bp, OCSP_REQUEST *a, unsigned long flags);\nint OCSP_RESPONSE_print(BIO *bp, OCSP_RESPONSE *o, unsigned long flags);\n\nint OCSP_basic_verify(OCSP_BASICRESP *bs, STACK_OF(X509) *certs,\n                      X509_STORE *st, unsigned long flags);\n\n/* BEGIN ERROR CODES */\n/*\n * The following lines are auto generated by the script mkerr.pl. Any changes\n * made after this point may be overwritten when the script is next run.\n */\nvoid ERR_load_OCSP_strings(void);\n\n/* Error codes for the OCSP functions. */\n\n/* Function codes. */\n# define OCSP_F_ASN1_STRING_ENCODE                        100\n# define OCSP_F_D2I_OCSP_NONCE                            102\n# define OCSP_F_OCSP_BASIC_ADD1_STATUS                    103\n# define OCSP_F_OCSP_BASIC_SIGN                           104\n# define OCSP_F_OCSP_BASIC_VERIFY                         105\n# define OCSP_F_OCSP_CERT_ID_NEW                          101\n# define OCSP_F_OCSP_CHECK_DELEGATED                      106\n# define OCSP_F_OCSP_CHECK_IDS                            107\n# define OCSP_F_OCSP_CHECK_ISSUER                         108\n# define OCSP_F_OCSP_CHECK_VALIDITY                       115\n# define OCSP_F_OCSP_MATCH_ISSUERID                       109\n# define OCSP_F_OCSP_PARSE_URL                            114\n# define OCSP_F_OCSP_REQUEST_SIGN                         110\n# define OCSP_F_OCSP_REQUEST_VERIFY                       116\n# define OCSP_F_OCSP_RESPONSE_GET1_BASIC                  111\n# define OCSP_F_OCSP_SENDREQ_BIO                          112\n# define OCSP_F_OCSP_SENDREQ_NBIO                         117\n# define OCSP_F_PARSE_HTTP_LINE1                          118\n# define OCSP_F_REQUEST_VERIFY                            113\n\n/* Reason codes. */\n# define OCSP_R_BAD_DATA                                  100\n# define OCSP_R_CERTIFICATE_VERIFY_ERROR                  101\n# define OCSP_R_DIGEST_ERR                                102\n# define OCSP_R_ERROR_IN_NEXTUPDATE_FIELD                 122\n# define OCSP_R_ERROR_IN_THISUPDATE_FIELD                 123\n# define OCSP_R_ERROR_PARSING_URL                         121\n# define OCSP_R_MISSING_OCSPSIGNING_USAGE                 103\n# define OCSP_R_NEXTUPDATE_BEFORE_THISUPDATE              124\n# define OCSP_R_NOT_BASIC_RESPONSE                        104\n# define OCSP_R_NO_CERTIFICATES_IN_CHAIN                  105\n# define OCSP_R_NO_CONTENT                                106\n# define OCSP_R_NO_PUBLIC_KEY                             107\n# define OCSP_R_NO_RESPONSE_DATA                          108\n# define OCSP_R_NO_REVOKED_TIME                           109\n# define OCSP_R_PRIVATE_KEY_DOES_NOT_MATCH_CERTIFICATE    110\n# define OCSP_R_REQUEST_NOT_SIGNED                        128\n# define OCSP_R_RESPONSE_CONTAINS_NO_REVOCATION_DATA      111\n# define OCSP_R_ROOT_CA_NOT_TRUSTED                       112\n# define OCSP_R_SERVER_READ_ERROR                         113\n# define OCSP_R_SERVER_RESPONSE_ERROR                     114\n# define OCSP_R_SERVER_RESPONSE_PARSE_ERROR               115\n# define OCSP_R_SERVER_WRITE_ERROR                        116\n# define OCSP_R_SIGNATURE_FAILURE                         117\n# define OCSP_R_SIGNER_CERTIFICATE_NOT_FOUND              118\n# define OCSP_R_STATUS_EXPIRED                            125\n# define OCSP_R_STATUS_NOT_YET_VALID                      126\n# define OCSP_R_STATUS_TOO_OLD                            127\n# define OCSP_R_UNKNOWN_MESSAGE_DIGEST                    119\n# define OCSP_R_UNKNOWN_NID                               120\n# define OCSP_R_UNSUPPORTED_REQUESTORNAME_TYPE            129\n\n#ifdef  __cplusplus\n}\n#endif\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/x86/include/openssl/opensslconf.h",
    "content": "/* opensslconf.h */\n/* WARNING: Generated automatically from opensslconf.h.in by Configure. */\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n/* OpenSSL was configured with the following options: */\n#ifndef OPENSSL_DOING_MAKEDEPEND\n\n\n#ifndef OPENSSL_NO_CAST\n# define OPENSSL_NO_CAST\n#endif\n#ifndef OPENSSL_NO_COMP\n# define OPENSSL_NO_COMP\n#endif\n#ifndef OPENSSL_NO_DH\n# define OPENSSL_NO_DH\n#endif\n#ifndef OPENSSL_NO_DSA\n# define OPENSSL_NO_DSA\n#endif\n#ifndef OPENSSL_NO_EC\n# define OPENSSL_NO_EC\n#endif\n#ifndef OPENSSL_NO_EC_NISTP_64_GCC_128\n# define OPENSSL_NO_EC_NISTP_64_GCC_128\n#endif\n#ifndef OPENSSL_NO_ECDH\n# define OPENSSL_NO_ECDH\n#endif\n#ifndef OPENSSL_NO_ECDSA\n# define OPENSSL_NO_ECDSA\n#endif\n#ifndef OPENSSL_NO_ENGINE\n# define OPENSSL_NO_ENGINE\n#endif\n#ifndef OPENSSL_NO_FIPS\n# define OPENSSL_NO_FIPS\n#endif\n#ifndef OPENSSL_NO_GMP\n# define OPENSSL_NO_GMP\n#endif\n#ifndef OPENSSL_NO_GOST\n# define OPENSSL_NO_GOST\n#endif\n#ifndef OPENSSL_NO_JPAKE\n# define OPENSSL_NO_JPAKE\n#endif\n#ifndef OPENSSL_NO_KRB5\n# define OPENSSL_NO_KRB5\n#endif\n#ifndef OPENSSL_NO_LIBUNBOUND\n# define OPENSSL_NO_LIBUNBOUND\n#endif\n#ifndef OPENSSL_NO_MD2\n# define OPENSSL_NO_MD2\n#endif\n#ifndef OPENSSL_NO_MD4\n# define OPENSSL_NO_MD4\n#endif\n#ifndef OPENSSL_NO_MD5\n# define OPENSSL_NO_MD5\n#endif\n#ifndef OPENSSL_NO_MDC2\n# define OPENSSL_NO_MDC2\n#endif\n#ifndef OPENSSL_NO_RC2\n# define OPENSSL_NO_RC2\n#endif\n#ifndef OPENSSL_NO_RC5\n# define OPENSSL_NO_RC5\n#endif\n#ifndef OPENSSL_NO_RFC3779\n# define OPENSSL_NO_RFC3779\n#endif\n#ifndef OPENSSL_NO_RIPEMD\n# define OPENSSL_NO_RIPEMD\n#endif\n#ifndef OPENSSL_NO_RSA\n# define OPENSSL_NO_RSA\n#endif\n#ifndef OPENSSL_NO_SCTP\n# define OPENSSL_NO_SCTP\n#endif\n#ifndef OPENSSL_NO_SOCK\n# define OPENSSL_NO_SOCK\n#endif\n#ifndef OPENSSL_NO_SSL_TRACE\n# define OPENSSL_NO_SSL_TRACE\n#endif\n#ifndef OPENSSL_NO_SSL2\n# define OPENSSL_NO_SSL2\n#endif\n#ifndef OPENSSL_NO_SSL3\n# define OPENSSL_NO_SSL3\n#endif\n#ifndef OPENSSL_NO_STORE\n# define OPENSSL_NO_STORE\n#endif\n#ifndef OPENSSL_NO_TLS1\n# define OPENSSL_NO_TLS1\n#endif\n#ifndef OPENSSL_NO_UNIT_TEST\n# define OPENSSL_NO_UNIT_TEST\n#endif\n#ifndef OPENSSL_NO_WEAK_SSL_CIPHERS\n# define OPENSSL_NO_WEAK_SSL_CIPHERS\n#endif\n\n#endif /* OPENSSL_DOING_MAKEDEPEND */\n\n#ifndef OPENSSL_THREADS\n# define OPENSSL_THREADS\n#endif\n#ifndef OPENSSL_NO_HW\n# define OPENSSL_NO_HW\n#endif\n#ifndef OPENSSL_NO_DYNAMIC_ENGINE\n# define OPENSSL_NO_DYNAMIC_ENGINE\n#endif\n\n/* The OPENSSL_NO_* macros are also defined as NO_* if the application\n   asks for it.  This is a transient feature that is provided for those\n   who haven't had the time to do the appropriate changes in their\n   applications.  */\n#ifdef OPENSSL_ALGORITHM_DEFINES\n# if defined(OPENSSL_NO_CAST) && !defined(NO_CAST)\n#  define NO_CAST\n# endif\n# if defined(OPENSSL_NO_COMP) && !defined(NO_COMP)\n#  define NO_COMP\n# endif\n# if defined(OPENSSL_NO_DH) && !defined(NO_DH)\n#  define NO_DH\n# endif\n# if defined(OPENSSL_NO_DSA) && !defined(NO_DSA)\n#  define NO_DSA\n# endif\n# if defined(OPENSSL_NO_EC) && !defined(NO_EC)\n#  define NO_EC\n# endif\n# if defined(OPENSSL_NO_EC_NISTP_64_GCC_128) && !defined(NO_EC_NISTP_64_GCC_128)\n#  define NO_EC_NISTP_64_GCC_128\n# endif\n# if defined(OPENSSL_NO_ECDH) && !defined(NO_ECDH)\n#  define NO_ECDH\n# endif\n# if defined(OPENSSL_NO_ECDSA) && !defined(NO_ECDSA)\n#  define NO_ECDSA\n# endif\n# if defined(OPENSSL_NO_ENGINE) && !defined(NO_ENGINE)\n#  define NO_ENGINE\n# endif\n# if defined(OPENSSL_NO_FIPS) && !defined(NO_FIPS)\n#  define NO_FIPS\n# endif\n# if defined(OPENSSL_NO_GMP) && !defined(NO_GMP)\n#  define NO_GMP\n# endif\n# if defined(OPENSSL_NO_GOST) && !defined(NO_GOST)\n#  define NO_GOST\n# endif\n# if defined(OPENSSL_NO_JPAKE) && !defined(NO_JPAKE)\n#  define NO_JPAKE\n# endif\n# if defined(OPENSSL_NO_KRB5) && !defined(NO_KRB5)\n#  define NO_KRB5\n# endif\n# if defined(OPENSSL_NO_LIBUNBOUND) && !defined(NO_LIBUNBOUND)\n#  define NO_LIBUNBOUND\n# endif\n# if defined(OPENSSL_NO_MD2) && !defined(NO_MD2)\n#  define NO_MD2\n# endif\n# if defined(OPENSSL_NO_MD4) && !defined(NO_MD4)\n#  define NO_MD4\n# endif\n# if defined(OPENSSL_NO_MD5) && !defined(NO_MD5)\n#  define NO_MD5\n# endif\n# if defined(OPENSSL_NO_MDC2) && !defined(NO_MDC2)\n#  define NO_MDC2\n# endif\n# if defined(OPENSSL_NO_RC2) && !defined(NO_RC2)\n#  define NO_RC2\n# endif\n# if defined(OPENSSL_NO_RC5) && !defined(NO_RC5)\n#  define NO_RC5\n# endif\n# if defined(OPENSSL_NO_RFC3779) && !defined(NO_RFC3779)\n#  define NO_RFC3779\n# endif\n# if defined(OPENSSL_NO_RIPEMD) && !defined(NO_RIPEMD)\n#  define NO_RIPEMD\n# endif\n# if defined(OPENSSL_NO_RSA) && !defined(NO_RSA)\n#  define NO_RSA\n# endif\n# if defined(OPENSSL_NO_SCTP) && !defined(NO_SCTP)\n#  define NO_SCTP\n# endif\n# if defined(OPENSSL_NO_SOCK) && !defined(NO_SOCK)\n#  define NO_SOCK\n# endif\n# if defined(OPENSSL_NO_SSL_TRACE) && !defined(NO_SSL_TRACE)\n#  define NO_SSL_TRACE\n# endif\n# if defined(OPENSSL_NO_SSL2) && !defined(NO_SSL2)\n#  define NO_SSL2\n# endif\n# if defined(OPENSSL_NO_SSL3) && !defined(NO_SSL3)\n#  define NO_SSL3\n# endif\n# if defined(OPENSSL_NO_STORE) && !defined(NO_STORE)\n#  define NO_STORE\n# endif\n# if defined(OPENSSL_NO_TLS1) && !defined(NO_TLS1)\n#  define NO_TLS1\n# endif\n# if defined(OPENSSL_NO_UNIT_TEST) && !defined(NO_UNIT_TEST)\n#  define NO_UNIT_TEST\n# endif\n# if defined(OPENSSL_NO_WEAK_SSL_CIPHERS) && !defined(NO_WEAK_SSL_CIPHERS)\n#  define NO_WEAK_SSL_CIPHERS\n# endif\n#endif\n\n#define OPENSSL_CPUID_OBJ\n\n/* crypto/opensslconf.h.in */\n\n/* Generate 80386 code? */\n#undef I386_ONLY\n\n#if !(defined(VMS) || defined(__VMS)) /* VMS uses logical names instead */\n#if defined(HEADER_CRYPTLIB_H) && !defined(OPENSSLDIR)\n#define ENGINESDIR \"/c/projects/wcdb/android/prebuilt/x86/lib/engines\"\n#define OPENSSLDIR \"/c/projects/wcdb/android/prebuilt/x86\"\n#endif\n#endif\n\n#undef OPENSSL_UNISTD\n#define OPENSSL_UNISTD <unistd.h>\n\n#undef OPENSSL_EXPORT_VAR_AS_FUNCTION\n\n#if defined(HEADER_IDEA_H) && !defined(IDEA_INT)\n#define IDEA_INT unsigned int\n#endif\n\n#if defined(HEADER_MD2_H) && !defined(MD2_INT)\n#define MD2_INT unsigned int\n#endif\n\n#if defined(HEADER_RC2_H) && !defined(RC2_INT)\n/* I need to put in a mod for the alpha - eay */\n#define RC2_INT unsigned int\n#endif\n\n#if defined(HEADER_RC4_H)\n#if !defined(RC4_INT)\n/* using int types make the structure larger but make the code faster\n * on most boxes I have tested - up to %20 faster. */\n/*\n * I don't know what does \"most\" mean, but declaring \"int\" is a must on:\n * - Intel P6 because partial register stalls are very expensive;\n * - elder Alpha because it lacks byte load/store instructions;\n */\n#define RC4_INT unsigned int\n#endif\n#if !defined(RC4_CHUNK)\n/*\n * This enables code handling data aligned at natural CPU word\n * boundary. See crypto/rc4/rc4_enc.c for further details.\n */\n#undef RC4_CHUNK\n#endif\n#endif\n\n#if (defined(HEADER_NEW_DES_H) || defined(HEADER_DES_H)) && !defined(DES_LONG)\n/* If this is set to 'unsigned int' on a DEC Alpha, this gives about a\n * %20 speed up (longs are 8 bytes, int's are 4). */\n#ifndef DES_LONG\n#define DES_LONG unsigned long\n#endif\n#endif\n\n#if defined(HEADER_BN_H) && !defined(CONFIG_HEADER_BN_H)\n#define CONFIG_HEADER_BN_H\n#define BN_LLONG\n\n/* Should we define BN_DIV2W here? */\n\n/* Only one for the following should be defined */\n#undef SIXTY_FOUR_BIT_LONG\n#undef SIXTY_FOUR_BIT\n#define THIRTY_TWO_BIT\n#endif\n\n#if defined(HEADER_RC4_LOCL_H) && !defined(CONFIG_HEADER_RC4_LOCL_H)\n#define CONFIG_HEADER_RC4_LOCL_H\n/* if this is defined data[i] is used instead of *data, this is a %20\n * speedup on x86 */\n#define RC4_INDEX\n#endif\n\n#if defined(HEADER_BF_LOCL_H) && !defined(CONFIG_HEADER_BF_LOCL_H)\n#define CONFIG_HEADER_BF_LOCL_H\n#undef BF_PTR\n#endif /* HEADER_BF_LOCL_H */\n\n#if defined(HEADER_DES_LOCL_H) && !defined(CONFIG_HEADER_DES_LOCL_H)\n#define CONFIG_HEADER_DES_LOCL_H\n#ifndef DES_DEFAULT_OPTIONS\n/* the following is tweaked from a config script, that is why it is a\n * protected undef/define */\n#ifndef DES_PTR\n#define DES_PTR\n#endif\n\n/* This helps C compiler generate the correct code for multiple functional\n * units.  It reduces register dependancies at the expense of 2 more\n * registers */\n#ifndef DES_RISC1\n#define DES_RISC1\n#endif\n\n#ifndef DES_RISC2\n#undef DES_RISC2\n#endif\n\n#if defined(DES_RISC1) && defined(DES_RISC2)\n#error YOU SHOULD NOT HAVE BOTH DES_RISC1 AND DES_RISC2 DEFINED!!!!!\n#endif\n\n/* Unroll the inner loop, this sometimes helps, sometimes hinders.\n * Very mucy CPU dependant */\n#ifndef DES_UNROLL\n#define DES_UNROLL\n#endif\n\n/* These default values were supplied by\n * Peter Gutman <pgut001@cs.auckland.ac.nz>\n * They are only used if nothing else has been defined */\n#if !defined(DES_PTR) && !defined(DES_RISC1) && !defined(DES_RISC2) && !defined(DES_UNROLL)\n/* Special defines which change the way the code is built depending on the\n   CPU and OS.  For SGI machines you can use _MIPS_SZLONG (32 or 64) to find\n   even newer MIPS CPU's, but at the moment one size fits all for\n   optimization options.  Older Sparc's work better with only UNROLL, but\n   there's no way to tell at compile time what it is you're running on */\n \n#if defined( __sun ) || defined ( sun )\t\t/* Newer Sparc's */\n#  define DES_PTR\n#  define DES_RISC1\n#  define DES_UNROLL\n#elif defined( __ultrix )\t/* Older MIPS */\n#  define DES_PTR\n#  define DES_RISC2\n#  define DES_UNROLL\n#elif defined( __osf1__ )\t/* Alpha */\n#  define DES_PTR\n#  define DES_RISC2\n#elif defined ( _AIX )\t\t/* RS6000 */\n  /* Unknown */\n#elif defined( __hpux )\t\t/* HP-PA */\n  /* Unknown */\n#elif defined( __aux )\t\t/* 68K */\n  /* Unknown */\n#elif defined( __dgux )\t\t/* 88K (but P6 in latest boxes) */\n#  define DES_UNROLL\n#elif defined( __sgi )\t\t/* Newer MIPS */\n#  define DES_PTR\n#  define DES_RISC2\n#  define DES_UNROLL\n#elif defined(i386) || defined(__i386__)\t/* x86 boxes, should be gcc */\n#  define DES_PTR\n#  define DES_RISC1\n#  define DES_UNROLL\n#endif /* Systems-specific speed defines */\n#endif\n\n#endif /* DES_DEFAULT_OPTIONS */\n#endif /* HEADER_DES_LOCL_H */\n#ifdef  __cplusplus\n}\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/x86/include/openssl/opensslv.h",
    "content": "#ifndef HEADER_OPENSSLV_H\n# define HEADER_OPENSSLV_H\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n/*-\n * Numeric release version identifier:\n * MNNFFPPS: major minor fix patch status\n * The status nibble has one of the values 0 for development, 1 to e for betas\n * 1 to 14, and f for release.  The patch level is exactly that.\n * For example:\n * 0.9.3-dev      0x00903000\n * 0.9.3-beta1    0x00903001\n * 0.9.3-beta2-dev 0x00903002\n * 0.9.3-beta2    0x00903002 (same as ...beta2-dev)\n * 0.9.3          0x0090300f\n * 0.9.3a         0x0090301f\n * 0.9.4          0x0090400f\n * 1.2.3z         0x102031af\n *\n * For continuity reasons (because 0.9.5 is already out, and is coded\n * 0x00905100), between 0.9.5 and 0.9.6 the coding of the patch level\n * part is slightly different, by setting the highest bit.  This means\n * that 0.9.5a looks like this: 0x0090581f.  At 0.9.6, we can start\n * with 0x0090600S...\n *\n * (Prior to 0.9.3-dev a different scheme was used: 0.9.2b is 0x0922.)\n * (Prior to 0.9.5a beta1, a different scheme was used: MMNNFFRBB for\n *  major minor fix final patch/beta)\n */\n# define OPENSSL_VERSION_NUMBER  0x100020bfL\n# ifdef OPENSSL_FIPS\n#  define OPENSSL_VERSION_TEXT    \"OpenSSL 1.0.2k-fips  26 Jan 2017\"\n# else\n#  define OPENSSL_VERSION_TEXT    \"OpenSSL 1.0.2k  26 Jan 2017\"\n# endif\n# define OPENSSL_VERSION_PTEXT   \" part of \" OPENSSL_VERSION_TEXT\n\n/*-\n * The macros below are to be used for shared library (.so, .dll, ...)\n * versioning.  That kind of versioning works a bit differently between\n * operating systems.  The most usual scheme is to set a major and a minor\n * number, and have the runtime loader check that the major number is equal\n * to what it was at application link time, while the minor number has to\n * be greater or equal to what it was at application link time.  With this\n * scheme, the version number is usually part of the file name, like this:\n *\n *      libcrypto.so.0.9\n *\n * Some unixen also make a softlink with the major verson number only:\n *\n *      libcrypto.so.0\n *\n * On Tru64 and IRIX 6.x it works a little bit differently.  There, the\n * shared library version is stored in the file, and is actually a series\n * of versions, separated by colons.  The rightmost version present in the\n * library when linking an application is stored in the application to be\n * matched at run time.  When the application is run, a check is done to\n * see if the library version stored in the application matches any of the\n * versions in the version string of the library itself.\n * This version string can be constructed in any way, depending on what\n * kind of matching is desired.  However, to implement the same scheme as\n * the one used in the other unixen, all compatible versions, from lowest\n * to highest, should be part of the string.  Consecutive builds would\n * give the following versions strings:\n *\n *      3.0\n *      3.0:3.1\n *      3.0:3.1:3.2\n *      4.0\n *      4.0:4.1\n *\n * Notice how version 4 is completely incompatible with version, and\n * therefore give the breach you can see.\n *\n * There may be other schemes as well that I haven't yet discovered.\n *\n * So, here's the way it works here: first of all, the library version\n * number doesn't need at all to match the overall OpenSSL version.\n * However, it's nice and more understandable if it actually does.\n * The current library version is stored in the macro SHLIB_VERSION_NUMBER,\n * which is just a piece of text in the format \"M.m.e\" (Major, minor, edit).\n * For the sake of Tru64, IRIX, and any other OS that behaves in similar ways,\n * we need to keep a history of version numbers, which is done in the\n * macro SHLIB_VERSION_HISTORY.  The numbers are separated by colons and\n * should only keep the versions that are binary compatible with the current.\n */\n# define SHLIB_VERSION_HISTORY \"\"\n# define SHLIB_VERSION_NUMBER \"1.0.0\"\n\n\n#ifdef  __cplusplus\n}\n#endif\n#endif                          /* HEADER_OPENSSLV_H */\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/x86/include/openssl/ossl_typ.h",
    "content": "/* ====================================================================\n * Copyright (c) 1998-2001 The OpenSSL Project.  All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n *\n * 1. Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n *\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in\n *    the documentation and/or other materials provided with the\n *    distribution.\n *\n * 3. All advertising materials mentioning features or use of this\n *    software must display the following acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit. (http://www.openssl.org/)\"\n *\n * 4. The names \"OpenSSL Toolkit\" and \"OpenSSL Project\" must not be used to\n *    endorse or promote products derived from this software without\n *    prior written permission. For written permission, please contact\n *    openssl-core@openssl.org.\n *\n * 5. Products derived from this software may not be called \"OpenSSL\"\n *    nor may \"OpenSSL\" appear in their names without prior written\n *    permission of the OpenSSL Project.\n *\n * 6. Redistributions of any form whatsoever must retain the following\n *    acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit (http://www.openssl.org/)\"\n *\n * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY\n * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\n * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR\n * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\n * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,\n * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED\n * OF THE POSSIBILITY OF SUCH DAMAGE.\n * ====================================================================\n *\n * This product includes cryptographic software written by Eric Young\n * (eay@cryptsoft.com).  This product includes software written by Tim\n * Hudson (tjh@cryptsoft.com).\n *\n */\n\n#ifndef HEADER_OPENSSL_TYPES_H\n# define HEADER_OPENSSL_TYPES_H\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n# include <openssl/e_os2.h>\n\n# ifdef NO_ASN1_TYPEDEFS\n#  define ASN1_INTEGER            ASN1_STRING\n#  define ASN1_ENUMERATED         ASN1_STRING\n#  define ASN1_BIT_STRING         ASN1_STRING\n#  define ASN1_OCTET_STRING       ASN1_STRING\n#  define ASN1_PRINTABLESTRING    ASN1_STRING\n#  define ASN1_T61STRING          ASN1_STRING\n#  define ASN1_IA5STRING          ASN1_STRING\n#  define ASN1_UTCTIME            ASN1_STRING\n#  define ASN1_GENERALIZEDTIME    ASN1_STRING\n#  define ASN1_TIME               ASN1_STRING\n#  define ASN1_GENERALSTRING      ASN1_STRING\n#  define ASN1_UNIVERSALSTRING    ASN1_STRING\n#  define ASN1_BMPSTRING          ASN1_STRING\n#  define ASN1_VISIBLESTRING      ASN1_STRING\n#  define ASN1_UTF8STRING         ASN1_STRING\n#  define ASN1_BOOLEAN            int\n#  define ASN1_NULL               int\n# else\ntypedef struct asn1_string_st ASN1_INTEGER;\ntypedef struct asn1_string_st ASN1_ENUMERATED;\ntypedef struct asn1_string_st ASN1_BIT_STRING;\ntypedef struct asn1_string_st ASN1_OCTET_STRING;\ntypedef struct asn1_string_st ASN1_PRINTABLESTRING;\ntypedef struct asn1_string_st ASN1_T61STRING;\ntypedef struct asn1_string_st ASN1_IA5STRING;\ntypedef struct asn1_string_st ASN1_GENERALSTRING;\ntypedef struct asn1_string_st ASN1_UNIVERSALSTRING;\ntypedef struct asn1_string_st ASN1_BMPSTRING;\ntypedef struct asn1_string_st ASN1_UTCTIME;\ntypedef struct asn1_string_st ASN1_TIME;\ntypedef struct asn1_string_st ASN1_GENERALIZEDTIME;\ntypedef struct asn1_string_st ASN1_VISIBLESTRING;\ntypedef struct asn1_string_st ASN1_UTF8STRING;\ntypedef struct asn1_string_st ASN1_STRING;\ntypedef int ASN1_BOOLEAN;\ntypedef int ASN1_NULL;\n# endif\n\ntypedef struct asn1_object_st ASN1_OBJECT;\n\ntypedef struct ASN1_ITEM_st ASN1_ITEM;\ntypedef struct asn1_pctx_st ASN1_PCTX;\n\n# ifdef OPENSSL_SYS_WIN32\n#  undef X509_NAME\n#  undef X509_EXTENSIONS\n#  undef X509_CERT_PAIR\n#  undef PKCS7_ISSUER_AND_SERIAL\n#  undef OCSP_REQUEST\n#  undef OCSP_RESPONSE\n# endif\n\n# ifdef BIGNUM\n#  undef BIGNUM\n# endif\ntypedef struct bignum_st BIGNUM;\ntypedef struct bignum_ctx BN_CTX;\ntypedef struct bn_blinding_st BN_BLINDING;\ntypedef struct bn_mont_ctx_st BN_MONT_CTX;\ntypedef struct bn_recp_ctx_st BN_RECP_CTX;\ntypedef struct bn_gencb_st BN_GENCB;\n\ntypedef struct buf_mem_st BUF_MEM;\n\ntypedef struct evp_cipher_st EVP_CIPHER;\ntypedef struct evp_cipher_ctx_st EVP_CIPHER_CTX;\ntypedef struct env_md_st EVP_MD;\ntypedef struct env_md_ctx_st EVP_MD_CTX;\ntypedef struct evp_pkey_st EVP_PKEY;\n\ntypedef struct evp_pkey_asn1_method_st EVP_PKEY_ASN1_METHOD;\n\ntypedef struct evp_pkey_method_st EVP_PKEY_METHOD;\ntypedef struct evp_pkey_ctx_st EVP_PKEY_CTX;\n\ntypedef struct dh_st DH;\ntypedef struct dh_method DH_METHOD;\n\ntypedef struct dsa_st DSA;\ntypedef struct dsa_method DSA_METHOD;\n\ntypedef struct rsa_st RSA;\ntypedef struct rsa_meth_st RSA_METHOD;\n\ntypedef struct rand_meth_st RAND_METHOD;\n\ntypedef struct ecdh_method ECDH_METHOD;\ntypedef struct ecdsa_method ECDSA_METHOD;\n\ntypedef struct x509_st X509;\ntypedef struct X509_algor_st X509_ALGOR;\ntypedef struct X509_crl_st X509_CRL;\ntypedef struct x509_crl_method_st X509_CRL_METHOD;\ntypedef struct x509_revoked_st X509_REVOKED;\ntypedef struct X509_name_st X509_NAME;\ntypedef struct X509_pubkey_st X509_PUBKEY;\ntypedef struct x509_store_st X509_STORE;\ntypedef struct x509_store_ctx_st X509_STORE_CTX;\n\ntypedef struct pkcs8_priv_key_info_st PKCS8_PRIV_KEY_INFO;\n\ntypedef struct v3_ext_ctx X509V3_CTX;\ntypedef struct conf_st CONF;\n\ntypedef struct store_st STORE;\ntypedef struct store_method_st STORE_METHOD;\n\ntypedef struct ui_st UI;\ntypedef struct ui_method_st UI_METHOD;\n\ntypedef struct st_ERR_FNS ERR_FNS;\n\ntypedef struct engine_st ENGINE;\ntypedef struct ssl_st SSL;\ntypedef struct ssl_ctx_st SSL_CTX;\n\ntypedef struct comp_method_st COMP_METHOD;\n\ntypedef struct X509_POLICY_NODE_st X509_POLICY_NODE;\ntypedef struct X509_POLICY_LEVEL_st X509_POLICY_LEVEL;\ntypedef struct X509_POLICY_TREE_st X509_POLICY_TREE;\ntypedef struct X509_POLICY_CACHE_st X509_POLICY_CACHE;\n\ntypedef struct AUTHORITY_KEYID_st AUTHORITY_KEYID;\ntypedef struct DIST_POINT_st DIST_POINT;\ntypedef struct ISSUING_DIST_POINT_st ISSUING_DIST_POINT;\ntypedef struct NAME_CONSTRAINTS_st NAME_CONSTRAINTS;\n\n  /* If placed in pkcs12.h, we end up with a circular depency with pkcs7.h */\n# define DECLARE_PKCS12_STACK_OF(type)/* Nothing */\n# define IMPLEMENT_PKCS12_STACK_OF(type)/* Nothing */\n\ntypedef struct crypto_ex_data_st CRYPTO_EX_DATA;\n/* Callback types for crypto.h */\ntypedef int CRYPTO_EX_new (void *parent, void *ptr, CRYPTO_EX_DATA *ad,\n                           int idx, long argl, void *argp);\ntypedef void CRYPTO_EX_free (void *parent, void *ptr, CRYPTO_EX_DATA *ad,\n                             int idx, long argl, void *argp);\ntypedef int CRYPTO_EX_dup (CRYPTO_EX_DATA *to, CRYPTO_EX_DATA *from,\n                           void *from_d, int idx, long argl, void *argp);\n\ntypedef struct ocsp_req_ctx_st OCSP_REQ_CTX;\ntypedef struct ocsp_response_st OCSP_RESPONSE;\ntypedef struct ocsp_responder_id_st OCSP_RESPID;\n\n#ifdef  __cplusplus\n}\n#endif\n#endif                          /* def HEADER_OPENSSL_TYPES_H */\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/x86/include/openssl/pem.h",
    "content": "/* crypto/pem/pem.h */\n/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)\n * All rights reserved.\n *\n * This package is an SSL implementation written\n * by Eric Young (eay@cryptsoft.com).\n * The implementation was written so as to conform with Netscapes SSL.\n *\n * This library is free for commercial and non-commercial use as long as\n * the following conditions are aheared to.  The following conditions\n * apply to all code found in this distribution, be it the RC4, RSA,\n * lhash, DES, etc., code; not just the SSL code.  The SSL documentation\n * included with this distribution is covered by the same copyright terms\n * except that the holder is Tim Hudson (tjh@cryptsoft.com).\n *\n * Copyright remains Eric Young's, and as such any Copyright notices in\n * the code are not to be removed.\n * If this package is used in a product, Eric Young should be given attribution\n * as the author of the parts of the library used.\n * This can be in the form of a textual message at program startup or\n * in documentation (online or textual) provided with the package.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the copyright\n *    notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in the\n *    documentation and/or other materials provided with the distribution.\n * 3. All advertising materials mentioning features or use of this software\n *    must display the following acknowledgement:\n *    \"This product includes cryptographic software written by\n *     Eric Young (eay@cryptsoft.com)\"\n *    The word 'cryptographic' can be left out if the rouines from the library\n *    being used are not cryptographic related :-).\n * 4. If you include any Windows specific code (or a derivative thereof) from\n *    the apps directory (application code) you must include an acknowledgement:\n *    \"This product includes software written by Tim Hudson (tjh@cryptsoft.com)\"\n *\n * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n * SUCH DAMAGE.\n *\n * The licence and distribution terms for any publically available version or\n * derivative of this code cannot be changed.  i.e. this code cannot simply be\n * copied and put under another distribution licence\n * [including the GNU Public Licence.]\n */\n\n#ifndef HEADER_PEM_H\n# define HEADER_PEM_H\n\n# include <openssl/e_os2.h>\n# ifndef OPENSSL_NO_BIO\n#  include <openssl/bio.h>\n# endif\n# ifndef OPENSSL_NO_STACK\n#  include <openssl/stack.h>\n# endif\n# include <openssl/evp.h>\n# include <openssl/x509.h>\n# include <openssl/pem2.h>\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n# define PEM_BUFSIZE             1024\n\n# define PEM_OBJ_UNDEF           0\n# define PEM_OBJ_X509            1\n# define PEM_OBJ_X509_REQ        2\n# define PEM_OBJ_CRL             3\n# define PEM_OBJ_SSL_SESSION     4\n# define PEM_OBJ_PRIV_KEY        10\n# define PEM_OBJ_PRIV_RSA        11\n# define PEM_OBJ_PRIV_DSA        12\n# define PEM_OBJ_PRIV_DH         13\n# define PEM_OBJ_PUB_RSA         14\n# define PEM_OBJ_PUB_DSA         15\n# define PEM_OBJ_PUB_DH          16\n# define PEM_OBJ_DHPARAMS        17\n# define PEM_OBJ_DSAPARAMS       18\n# define PEM_OBJ_PRIV_RSA_PUBLIC 19\n# define PEM_OBJ_PRIV_ECDSA      20\n# define PEM_OBJ_PUB_ECDSA       21\n# define PEM_OBJ_ECPARAMETERS    22\n\n# define PEM_ERROR               30\n# define PEM_DEK_DES_CBC         40\n# define PEM_DEK_IDEA_CBC        45\n# define PEM_DEK_DES_EDE         50\n# define PEM_DEK_DES_ECB         60\n# define PEM_DEK_RSA             70\n# define PEM_DEK_RSA_MD2         80\n# define PEM_DEK_RSA_MD5         90\n\n# define PEM_MD_MD2              NID_md2\n# define PEM_MD_MD5              NID_md5\n# define PEM_MD_SHA              NID_sha\n# define PEM_MD_MD2_RSA          NID_md2WithRSAEncryption\n# define PEM_MD_MD5_RSA          NID_md5WithRSAEncryption\n# define PEM_MD_SHA_RSA          NID_sha1WithRSAEncryption\n\n# define PEM_STRING_X509_OLD     \"X509 CERTIFICATE\"\n# define PEM_STRING_X509         \"CERTIFICATE\"\n# define PEM_STRING_X509_PAIR    \"CERTIFICATE PAIR\"\n# define PEM_STRING_X509_TRUSTED \"TRUSTED CERTIFICATE\"\n# define PEM_STRING_X509_REQ_OLD \"NEW CERTIFICATE REQUEST\"\n# define PEM_STRING_X509_REQ     \"CERTIFICATE REQUEST\"\n# define PEM_STRING_X509_CRL     \"X509 CRL\"\n# define PEM_STRING_EVP_PKEY     \"ANY PRIVATE KEY\"\n# define PEM_STRING_PUBLIC       \"PUBLIC KEY\"\n# define PEM_STRING_RSA          \"RSA PRIVATE KEY\"\n# define PEM_STRING_RSA_PUBLIC   \"RSA PUBLIC KEY\"\n# define PEM_STRING_DSA          \"DSA PRIVATE KEY\"\n# define PEM_STRING_DSA_PUBLIC   \"DSA PUBLIC KEY\"\n# define PEM_STRING_PKCS7        \"PKCS7\"\n# define PEM_STRING_PKCS7_SIGNED \"PKCS #7 SIGNED DATA\"\n# define PEM_STRING_PKCS8        \"ENCRYPTED PRIVATE KEY\"\n# define PEM_STRING_PKCS8INF     \"PRIVATE KEY\"\n# define PEM_STRING_DHPARAMS     \"DH PARAMETERS\"\n# define PEM_STRING_DHXPARAMS    \"X9.42 DH PARAMETERS\"\n# define PEM_STRING_SSL_SESSION  \"SSL SESSION PARAMETERS\"\n# define PEM_STRING_DSAPARAMS    \"DSA PARAMETERS\"\n# define PEM_STRING_ECDSA_PUBLIC \"ECDSA PUBLIC KEY\"\n# define PEM_STRING_ECPARAMETERS \"EC PARAMETERS\"\n# define PEM_STRING_ECPRIVATEKEY \"EC PRIVATE KEY\"\n# define PEM_STRING_PARAMETERS   \"PARAMETERS\"\n# define PEM_STRING_CMS          \"CMS\"\n\n  /*\n   * Note that this structure is initialised by PEM_SealInit and cleaned up\n   * by PEM_SealFinal (at least for now)\n   */\ntypedef struct PEM_Encode_Seal_st {\n    EVP_ENCODE_CTX encode;\n    EVP_MD_CTX md;\n    EVP_CIPHER_CTX cipher;\n} PEM_ENCODE_SEAL_CTX;\n\n/* enc_type is one off */\n# define PEM_TYPE_ENCRYPTED      10\n# define PEM_TYPE_MIC_ONLY       20\n# define PEM_TYPE_MIC_CLEAR      30\n# define PEM_TYPE_CLEAR          40\n\ntypedef struct pem_recip_st {\n    char *name;\n    X509_NAME *dn;\n    int cipher;\n    int key_enc;\n    /*      char iv[8]; unused and wrong size */\n} PEM_USER;\n\ntypedef struct pem_ctx_st {\n    int type;                   /* what type of object */\n    struct {\n        int version;\n        int mode;\n    } proc_type;\n\n    char *domain;\n\n    struct {\n        int cipher;\n        /*-\n        unused, and wrong size\n        unsigned char iv[8]; */\n    } DEK_info;\n\n    PEM_USER *originator;\n\n    int num_recipient;\n    PEM_USER **recipient;\n/*-\n    XXX(ben): don#t think this is used!\n        STACK *x509_chain;      / * certificate chain */\n    EVP_MD *md;                 /* signature type */\n\n    int md_enc;                 /* is the md encrypted or not? */\n    int md_len;                 /* length of md_data */\n    char *md_data;              /* message digest, could be pkey encrypted */\n\n    EVP_CIPHER *dec;            /* date encryption cipher */\n    int key_len;                /* key length */\n    unsigned char *key;         /* key */\n  /*-\n    unused, and wrong size\n    unsigned char iv[8]; */\n\n    int data_enc;               /* is the data encrypted */\n    int data_len;\n    unsigned char *data;\n} PEM_CTX;\n\n/*\n * These macros make the PEM_read/PEM_write functions easier to maintain and\n * write. Now they are all implemented with either: IMPLEMENT_PEM_rw(...) or\n * IMPLEMENT_PEM_rw_cb(...)\n */\n\n# ifdef OPENSSL_NO_FP_API\n\n#  define IMPLEMENT_PEM_read_fp(name, type, str, asn1) /**/\n#  define IMPLEMENT_PEM_write_fp(name, type, str, asn1) /**/\n#  define IMPLEMENT_PEM_write_fp_const(name, type, str, asn1) /**/\n#  define IMPLEMENT_PEM_write_cb_fp(name, type, str, asn1) /**/\n#  define IMPLEMENT_PEM_write_cb_fp_const(name, type, str, asn1) /**/\n# else\n\n#  define IMPLEMENT_PEM_read_fp(name, type, str, asn1) \\\ntype *PEM_read_##name(FILE *fp, type **x, pem_password_cb *cb, void *u)\\\n{ \\\nreturn PEM_ASN1_read((d2i_of_void *)d2i_##asn1, str,fp,(void **)x,cb,u); \\\n}\n\n#  define IMPLEMENT_PEM_write_fp(name, type, str, asn1) \\\nint PEM_write_##name(FILE *fp, type *x) \\\n{ \\\nreturn PEM_ASN1_write((i2d_of_void *)i2d_##asn1,str,fp,x,NULL,NULL,0,NULL,NULL); \\\n}\n\n#  define IMPLEMENT_PEM_write_fp_const(name, type, str, asn1) \\\nint PEM_write_##name(FILE *fp, const type *x) \\\n{ \\\nreturn PEM_ASN1_write((i2d_of_void *)i2d_##asn1,str,fp,(void *)x,NULL,NULL,0,NULL,NULL); \\\n}\n\n#  define IMPLEMENT_PEM_write_cb_fp(name, type, str, asn1) \\\nint PEM_write_##name(FILE *fp, type *x, const EVP_CIPHER *enc, \\\n             unsigned char *kstr, int klen, pem_password_cb *cb, \\\n                  void *u) \\\n        { \\\n        return PEM_ASN1_write((i2d_of_void *)i2d_##asn1,str,fp,x,enc,kstr,klen,cb,u); \\\n        }\n\n#  define IMPLEMENT_PEM_write_cb_fp_const(name, type, str, asn1) \\\nint PEM_write_##name(FILE *fp, type *x, const EVP_CIPHER *enc, \\\n             unsigned char *kstr, int klen, pem_password_cb *cb, \\\n                  void *u) \\\n        { \\\n        return PEM_ASN1_write((i2d_of_void *)i2d_##asn1,str,fp,x,enc,kstr,klen,cb,u); \\\n        }\n\n# endif\n\n# define IMPLEMENT_PEM_read_bio(name, type, str, asn1) \\\ntype *PEM_read_bio_##name(BIO *bp, type **x, pem_password_cb *cb, void *u)\\\n{ \\\nreturn PEM_ASN1_read_bio((d2i_of_void *)d2i_##asn1, str,bp,(void **)x,cb,u); \\\n}\n\n# define IMPLEMENT_PEM_write_bio(name, type, str, asn1) \\\nint PEM_write_bio_##name(BIO *bp, type *x) \\\n{ \\\nreturn PEM_ASN1_write_bio((i2d_of_void *)i2d_##asn1,str,bp,x,NULL,NULL,0,NULL,NULL); \\\n}\n\n# define IMPLEMENT_PEM_write_bio_const(name, type, str, asn1) \\\nint PEM_write_bio_##name(BIO *bp, const type *x) \\\n{ \\\nreturn PEM_ASN1_write_bio((i2d_of_void *)i2d_##asn1,str,bp,(void *)x,NULL,NULL,0,NULL,NULL); \\\n}\n\n# define IMPLEMENT_PEM_write_cb_bio(name, type, str, asn1) \\\nint PEM_write_bio_##name(BIO *bp, type *x, const EVP_CIPHER *enc, \\\n             unsigned char *kstr, int klen, pem_password_cb *cb, void *u) \\\n        { \\\n        return PEM_ASN1_write_bio((i2d_of_void *)i2d_##asn1,str,bp,x,enc,kstr,klen,cb,u); \\\n        }\n\n# define IMPLEMENT_PEM_write_cb_bio_const(name, type, str, asn1) \\\nint PEM_write_bio_##name(BIO *bp, type *x, const EVP_CIPHER *enc, \\\n             unsigned char *kstr, int klen, pem_password_cb *cb, void *u) \\\n        { \\\n        return PEM_ASN1_write_bio((i2d_of_void *)i2d_##asn1,str,bp,(void *)x,enc,kstr,klen,cb,u); \\\n        }\n\n# define IMPLEMENT_PEM_write(name, type, str, asn1) \\\n        IMPLEMENT_PEM_write_bio(name, type, str, asn1) \\\n        IMPLEMENT_PEM_write_fp(name, type, str, asn1)\n\n# define IMPLEMENT_PEM_write_const(name, type, str, asn1) \\\n        IMPLEMENT_PEM_write_bio_const(name, type, str, asn1) \\\n        IMPLEMENT_PEM_write_fp_const(name, type, str, asn1)\n\n# define IMPLEMENT_PEM_write_cb(name, type, str, asn1) \\\n        IMPLEMENT_PEM_write_cb_bio(name, type, str, asn1) \\\n        IMPLEMENT_PEM_write_cb_fp(name, type, str, asn1)\n\n# define IMPLEMENT_PEM_write_cb_const(name, type, str, asn1) \\\n        IMPLEMENT_PEM_write_cb_bio_const(name, type, str, asn1) \\\n        IMPLEMENT_PEM_write_cb_fp_const(name, type, str, asn1)\n\n# define IMPLEMENT_PEM_read(name, type, str, asn1) \\\n        IMPLEMENT_PEM_read_bio(name, type, str, asn1) \\\n        IMPLEMENT_PEM_read_fp(name, type, str, asn1)\n\n# define IMPLEMENT_PEM_rw(name, type, str, asn1) \\\n        IMPLEMENT_PEM_read(name, type, str, asn1) \\\n        IMPLEMENT_PEM_write(name, type, str, asn1)\n\n# define IMPLEMENT_PEM_rw_const(name, type, str, asn1) \\\n        IMPLEMENT_PEM_read(name, type, str, asn1) \\\n        IMPLEMENT_PEM_write_const(name, type, str, asn1)\n\n# define IMPLEMENT_PEM_rw_cb(name, type, str, asn1) \\\n        IMPLEMENT_PEM_read(name, type, str, asn1) \\\n        IMPLEMENT_PEM_write_cb(name, type, str, asn1)\n\n/* These are the same except they are for the declarations */\n\n# if defined(OPENSSL_NO_FP_API)\n\n#  define DECLARE_PEM_read_fp(name, type) /**/\n#  define DECLARE_PEM_write_fp(name, type) /**/\n#  define DECLARE_PEM_write_cb_fp(name, type) /**/\n# else\n\n#  define DECLARE_PEM_read_fp(name, type) \\\n        type *PEM_read_##name(FILE *fp, type **x, pem_password_cb *cb, void *u);\n\n#  define DECLARE_PEM_write_fp(name, type) \\\n        int PEM_write_##name(FILE *fp, type *x);\n\n#  define DECLARE_PEM_write_fp_const(name, type) \\\n        int PEM_write_##name(FILE *fp, const type *x);\n\n#  define DECLARE_PEM_write_cb_fp(name, type) \\\n        int PEM_write_##name(FILE *fp, type *x, const EVP_CIPHER *enc, \\\n             unsigned char *kstr, int klen, pem_password_cb *cb, void *u);\n\n# endif\n\n# ifndef OPENSSL_NO_BIO\n#  define DECLARE_PEM_read_bio(name, type) \\\n        type *PEM_read_bio_##name(BIO *bp, type **x, pem_password_cb *cb, void *u);\n\n#  define DECLARE_PEM_write_bio(name, type) \\\n        int PEM_write_bio_##name(BIO *bp, type *x);\n\n#  define DECLARE_PEM_write_bio_const(name, type) \\\n        int PEM_write_bio_##name(BIO *bp, const type *x);\n\n#  define DECLARE_PEM_write_cb_bio(name, type) \\\n        int PEM_write_bio_##name(BIO *bp, type *x, const EVP_CIPHER *enc, \\\n             unsigned char *kstr, int klen, pem_password_cb *cb, void *u);\n\n# else\n\n#  define DECLARE_PEM_read_bio(name, type) /**/\n#  define DECLARE_PEM_write_bio(name, type) /**/\n#  define DECLARE_PEM_write_bio_const(name, type) /**/\n#  define DECLARE_PEM_write_cb_bio(name, type) /**/\n# endif\n# define DECLARE_PEM_write(name, type) \\\n        DECLARE_PEM_write_bio(name, type) \\\n        DECLARE_PEM_write_fp(name, type)\n# define DECLARE_PEM_write_const(name, type) \\\n        DECLARE_PEM_write_bio_const(name, type) \\\n        DECLARE_PEM_write_fp_const(name, type)\n# define DECLARE_PEM_write_cb(name, type) \\\n        DECLARE_PEM_write_cb_bio(name, type) \\\n        DECLARE_PEM_write_cb_fp(name, type)\n# define DECLARE_PEM_read(name, type) \\\n        DECLARE_PEM_read_bio(name, type) \\\n        DECLARE_PEM_read_fp(name, type)\n# define DECLARE_PEM_rw(name, type) \\\n        DECLARE_PEM_read(name, type) \\\n        DECLARE_PEM_write(name, type)\n# define DECLARE_PEM_rw_const(name, type) \\\n        DECLARE_PEM_read(name, type) \\\n        DECLARE_PEM_write_const(name, type)\n# define DECLARE_PEM_rw_cb(name, type) \\\n        DECLARE_PEM_read(name, type) \\\n        DECLARE_PEM_write_cb(name, type)\n# if 1\n/* \"userdata\": new with OpenSSL 0.9.4 */\ntypedef int pem_password_cb (char *buf, int size, int rwflag, void *userdata);\n# else\n/* OpenSSL 0.9.3, 0.9.3a */\ntypedef int pem_password_cb (char *buf, int size, int rwflag);\n# endif\n\nint PEM_get_EVP_CIPHER_INFO(char *header, EVP_CIPHER_INFO *cipher);\nint PEM_do_header(EVP_CIPHER_INFO *cipher, unsigned char *data, long *len,\n                  pem_password_cb *callback, void *u);\n\n# ifndef OPENSSL_NO_BIO\nint PEM_read_bio(BIO *bp, char **name, char **header,\n                 unsigned char **data, long *len);\nint PEM_write_bio(BIO *bp, const char *name, const char *hdr,\n                  const unsigned char *data, long len);\nint PEM_bytes_read_bio(unsigned char **pdata, long *plen, char **pnm,\n                       const char *name, BIO *bp, pem_password_cb *cb,\n                       void *u);\nvoid *PEM_ASN1_read_bio(d2i_of_void *d2i, const char *name, BIO *bp, void **x,\n                        pem_password_cb *cb, void *u);\nint PEM_ASN1_write_bio(i2d_of_void *i2d, const char *name, BIO *bp, void *x,\n                       const EVP_CIPHER *enc, unsigned char *kstr, int klen,\n                       pem_password_cb *cb, void *u);\n\nSTACK_OF(X509_INFO) *PEM_X509_INFO_read_bio(BIO *bp, STACK_OF(X509_INFO) *sk,\n                                            pem_password_cb *cb, void *u);\nint PEM_X509_INFO_write_bio(BIO *bp, X509_INFO *xi, EVP_CIPHER *enc,\n                            unsigned char *kstr, int klen,\n                            pem_password_cb *cd, void *u);\n# endif\n\nint PEM_read(FILE *fp, char **name, char **header,\n             unsigned char **data, long *len);\nint PEM_write(FILE *fp, const char *name, const char *hdr,\n              const unsigned char *data, long len);\nvoid *PEM_ASN1_read(d2i_of_void *d2i, const char *name, FILE *fp, void **x,\n                    pem_password_cb *cb, void *u);\nint PEM_ASN1_write(i2d_of_void *i2d, const char *name, FILE *fp,\n                   void *x, const EVP_CIPHER *enc, unsigned char *kstr,\n                   int klen, pem_password_cb *callback, void *u);\nSTACK_OF(X509_INFO) *PEM_X509_INFO_read(FILE *fp, STACK_OF(X509_INFO) *sk,\n                                        pem_password_cb *cb, void *u);\n\nint PEM_SealInit(PEM_ENCODE_SEAL_CTX *ctx, EVP_CIPHER *type,\n                 EVP_MD *md_type, unsigned char **ek, int *ekl,\n                 unsigned char *iv, EVP_PKEY **pubk, int npubk);\nvoid PEM_SealUpdate(PEM_ENCODE_SEAL_CTX *ctx, unsigned char *out, int *outl,\n                    unsigned char *in, int inl);\nint PEM_SealFinal(PEM_ENCODE_SEAL_CTX *ctx, unsigned char *sig, int *sigl,\n                  unsigned char *out, int *outl, EVP_PKEY *priv);\n\nvoid PEM_SignInit(EVP_MD_CTX *ctx, EVP_MD *type);\nvoid PEM_SignUpdate(EVP_MD_CTX *ctx, unsigned char *d, unsigned int cnt);\nint PEM_SignFinal(EVP_MD_CTX *ctx, unsigned char *sigret,\n                  unsigned int *siglen, EVP_PKEY *pkey);\n\nint PEM_def_callback(char *buf, int num, int w, void *key);\nvoid PEM_proc_type(char *buf, int type);\nvoid PEM_dek_info(char *buf, const char *type, int len, char *str);\n\n# include <openssl/symhacks.h>\n\nDECLARE_PEM_rw(X509, X509)\nDECLARE_PEM_rw(X509_AUX, X509)\nDECLARE_PEM_rw(X509_CERT_PAIR, X509_CERT_PAIR)\nDECLARE_PEM_rw(X509_REQ, X509_REQ)\nDECLARE_PEM_write(X509_REQ_NEW, X509_REQ)\nDECLARE_PEM_rw(X509_CRL, X509_CRL)\nDECLARE_PEM_rw(PKCS7, PKCS7)\nDECLARE_PEM_rw(NETSCAPE_CERT_SEQUENCE, NETSCAPE_CERT_SEQUENCE)\nDECLARE_PEM_rw(PKCS8, X509_SIG)\nDECLARE_PEM_rw(PKCS8_PRIV_KEY_INFO, PKCS8_PRIV_KEY_INFO)\n# ifndef OPENSSL_NO_RSA\nDECLARE_PEM_rw_cb(RSAPrivateKey, RSA)\nDECLARE_PEM_rw_const(RSAPublicKey, RSA)\nDECLARE_PEM_rw(RSA_PUBKEY, RSA)\n# endif\n# ifndef OPENSSL_NO_DSA\nDECLARE_PEM_rw_cb(DSAPrivateKey, DSA)\nDECLARE_PEM_rw(DSA_PUBKEY, DSA)\nDECLARE_PEM_rw_const(DSAparams, DSA)\n# endif\n# ifndef OPENSSL_NO_EC\nDECLARE_PEM_rw_const(ECPKParameters, EC_GROUP)\nDECLARE_PEM_rw_cb(ECPrivateKey, EC_KEY)\nDECLARE_PEM_rw(EC_PUBKEY, EC_KEY)\n# endif\n# ifndef OPENSSL_NO_DH\nDECLARE_PEM_rw_const(DHparams, DH)\nDECLARE_PEM_write_const(DHxparams, DH)\n# endif\nDECLARE_PEM_rw_cb(PrivateKey, EVP_PKEY)\nDECLARE_PEM_rw(PUBKEY, EVP_PKEY)\n\nint PEM_write_bio_PKCS8PrivateKey_nid(BIO *bp, EVP_PKEY *x, int nid,\n                                      char *kstr, int klen,\n                                      pem_password_cb *cb, void *u);\nint PEM_write_bio_PKCS8PrivateKey(BIO *, EVP_PKEY *, const EVP_CIPHER *,\n                                  char *, int, pem_password_cb *, void *);\nint i2d_PKCS8PrivateKey_bio(BIO *bp, EVP_PKEY *x, const EVP_CIPHER *enc,\n                            char *kstr, int klen,\n                            pem_password_cb *cb, void *u);\nint i2d_PKCS8PrivateKey_nid_bio(BIO *bp, EVP_PKEY *x, int nid,\n                                char *kstr, int klen,\n                                pem_password_cb *cb, void *u);\nEVP_PKEY *d2i_PKCS8PrivateKey_bio(BIO *bp, EVP_PKEY **x, pem_password_cb *cb,\n                                  void *u);\n\nint i2d_PKCS8PrivateKey_fp(FILE *fp, EVP_PKEY *x, const EVP_CIPHER *enc,\n                           char *kstr, int klen,\n                           pem_password_cb *cb, void *u);\nint i2d_PKCS8PrivateKey_nid_fp(FILE *fp, EVP_PKEY *x, int nid,\n                               char *kstr, int klen,\n                               pem_password_cb *cb, void *u);\nint PEM_write_PKCS8PrivateKey_nid(FILE *fp, EVP_PKEY *x, int nid,\n                                  char *kstr, int klen,\n                                  pem_password_cb *cb, void *u);\n\nEVP_PKEY *d2i_PKCS8PrivateKey_fp(FILE *fp, EVP_PKEY **x, pem_password_cb *cb,\n                                 void *u);\n\nint PEM_write_PKCS8PrivateKey(FILE *fp, EVP_PKEY *x, const EVP_CIPHER *enc,\n                              char *kstr, int klen, pem_password_cb *cd,\n                              void *u);\n\nEVP_PKEY *PEM_read_bio_Parameters(BIO *bp, EVP_PKEY **x);\nint PEM_write_bio_Parameters(BIO *bp, EVP_PKEY *x);\n\nEVP_PKEY *b2i_PrivateKey(const unsigned char **in, long length);\nEVP_PKEY *b2i_PublicKey(const unsigned char **in, long length);\nEVP_PKEY *b2i_PrivateKey_bio(BIO *in);\nEVP_PKEY *b2i_PublicKey_bio(BIO *in);\nint i2b_PrivateKey_bio(BIO *out, EVP_PKEY *pk);\nint i2b_PublicKey_bio(BIO *out, EVP_PKEY *pk);\n# ifndef OPENSSL_NO_RC4\nEVP_PKEY *b2i_PVK_bio(BIO *in, pem_password_cb *cb, void *u);\nint i2b_PVK_bio(BIO *out, EVP_PKEY *pk, int enclevel,\n                pem_password_cb *cb, void *u);\n# endif\n\n/* BEGIN ERROR CODES */\n/*\n * The following lines are auto generated by the script mkerr.pl. Any changes\n * made after this point may be overwritten when the script is next run.\n */\n\nvoid ERR_load_PEM_strings(void);\n\n/* Error codes for the PEM functions. */\n\n/* Function codes. */\n# define PEM_F_B2I_DSS                                    127\n# define PEM_F_B2I_PVK_BIO                                128\n# define PEM_F_B2I_RSA                                    129\n# define PEM_F_CHECK_BITLEN_DSA                           130\n# define PEM_F_CHECK_BITLEN_RSA                           131\n# define PEM_F_D2I_PKCS8PRIVATEKEY_BIO                    120\n# define PEM_F_D2I_PKCS8PRIVATEKEY_FP                     121\n# define PEM_F_DO_B2I                                     132\n# define PEM_F_DO_B2I_BIO                                 133\n# define PEM_F_DO_BLOB_HEADER                             134\n# define PEM_F_DO_PK8PKEY                                 126\n# define PEM_F_DO_PK8PKEY_FP                              125\n# define PEM_F_DO_PVK_BODY                                135\n# define PEM_F_DO_PVK_HEADER                              136\n# define PEM_F_I2B_PVK                                    137\n# define PEM_F_I2B_PVK_BIO                                138\n# define PEM_F_LOAD_IV                                    101\n# define PEM_F_PEM_ASN1_READ                              102\n# define PEM_F_PEM_ASN1_READ_BIO                          103\n# define PEM_F_PEM_ASN1_WRITE                             104\n# define PEM_F_PEM_ASN1_WRITE_BIO                         105\n# define PEM_F_PEM_DEF_CALLBACK                           100\n# define PEM_F_PEM_DO_HEADER                              106\n# define PEM_F_PEM_F_PEM_WRITE_PKCS8PRIVATEKEY            118\n# define PEM_F_PEM_GET_EVP_CIPHER_INFO                    107\n# define PEM_F_PEM_PK8PKEY                                119\n# define PEM_F_PEM_READ                                   108\n# define PEM_F_PEM_READ_BIO                               109\n# define PEM_F_PEM_READ_BIO_DHPARAMS                      141\n# define PEM_F_PEM_READ_BIO_PARAMETERS                    140\n# define PEM_F_PEM_READ_BIO_PRIVATEKEY                    123\n# define PEM_F_PEM_READ_DHPARAMS                          142\n# define PEM_F_PEM_READ_PRIVATEKEY                        124\n# define PEM_F_PEM_SEALFINAL                              110\n# define PEM_F_PEM_SEALINIT                               111\n# define PEM_F_PEM_SIGNFINAL                              112\n# define PEM_F_PEM_WRITE                                  113\n# define PEM_F_PEM_WRITE_BIO                              114\n# define PEM_F_PEM_WRITE_PRIVATEKEY                       139\n# define PEM_F_PEM_X509_INFO_READ                         115\n# define PEM_F_PEM_X509_INFO_READ_BIO                     116\n# define PEM_F_PEM_X509_INFO_WRITE_BIO                    117\n\n/* Reason codes. */\n# define PEM_R_BAD_BASE64_DECODE                          100\n# define PEM_R_BAD_DECRYPT                                101\n# define PEM_R_BAD_END_LINE                               102\n# define PEM_R_BAD_IV_CHARS                               103\n# define PEM_R_BAD_MAGIC_NUMBER                           116\n# define PEM_R_BAD_PASSWORD_READ                          104\n# define PEM_R_BAD_VERSION_NUMBER                         117\n# define PEM_R_BIO_WRITE_FAILURE                          118\n# define PEM_R_CIPHER_IS_NULL                             127\n# define PEM_R_ERROR_CONVERTING_PRIVATE_KEY               115\n# define PEM_R_EXPECTING_PRIVATE_KEY_BLOB                 119\n# define PEM_R_EXPECTING_PUBLIC_KEY_BLOB                  120\n# define PEM_R_HEADER_TOO_LONG                            128\n# define PEM_R_INCONSISTENT_HEADER                        121\n# define PEM_R_KEYBLOB_HEADER_PARSE_ERROR                 122\n# define PEM_R_KEYBLOB_TOO_SHORT                          123\n# define PEM_R_NOT_DEK_INFO                               105\n# define PEM_R_NOT_ENCRYPTED                              106\n# define PEM_R_NOT_PROC_TYPE                              107\n# define PEM_R_NO_START_LINE                              108\n# define PEM_R_PROBLEMS_GETTING_PASSWORD                  109\n# define PEM_R_PUBLIC_KEY_NO_RSA                          110\n# define PEM_R_PVK_DATA_TOO_SHORT                         124\n# define PEM_R_PVK_TOO_SHORT                              125\n# define PEM_R_READ_KEY                                   111\n# define PEM_R_SHORT_HEADER                               112\n# define PEM_R_UNSUPPORTED_CIPHER                         113\n# define PEM_R_UNSUPPORTED_ENCRYPTION                     114\n# define PEM_R_UNSUPPORTED_KEY_COMPONENTS                 126\n\n# ifdef  __cplusplus\n}\n# endif\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/x86/include/openssl/pem2.h",
    "content": "/* ====================================================================\n * Copyright (c) 1999 The OpenSSL Project.  All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n *\n * 1. Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n *\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in\n *    the documentation and/or other materials provided with the\n *    distribution.\n *\n * 3. All advertising materials mentioning features or use of this\n *    software must display the following acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)\"\n *\n * 4. The names \"OpenSSL Toolkit\" and \"OpenSSL Project\" must not be used to\n *    endorse or promote products derived from this software without\n *    prior written permission. For written permission, please contact\n *    licensing@OpenSSL.org.\n *\n * 5. Products derived from this software may not be called \"OpenSSL\"\n *    nor may \"OpenSSL\" appear in their names without prior written\n *    permission of the OpenSSL Project.\n *\n * 6. Redistributions of any form whatsoever must retain the following\n *    acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)\"\n *\n * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY\n * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\n * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR\n * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\n * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,\n * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED\n * OF THE POSSIBILITY OF SUCH DAMAGE.\n * ====================================================================\n *\n * This product includes cryptographic software written by Eric Young\n * (eay@cryptsoft.com).  This product includes software written by Tim\n * Hudson (tjh@cryptsoft.com).\n *\n */\n\n/*\n * This header only exists to break a circular dependency between pem and err\n * Ben 30 Jan 1999.\n */\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n#ifndef HEADER_PEM_H\nvoid ERR_load_PEM_strings(void);\n#endif\n\n#ifdef __cplusplus\n}\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/x86/include/openssl/pkcs12.h",
    "content": "/* pkcs12.h */\n/*\n * Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL project\n * 1999.\n */\n/* ====================================================================\n * Copyright (c) 1999 The OpenSSL Project.  All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n *\n * 1. Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n *\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in\n *    the documentation and/or other materials provided with the\n *    distribution.\n *\n * 3. All advertising materials mentioning features or use of this\n *    software must display the following acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)\"\n *\n * 4. The names \"OpenSSL Toolkit\" and \"OpenSSL Project\" must not be used to\n *    endorse or promote products derived from this software without\n *    prior written permission. For written permission, please contact\n *    licensing@OpenSSL.org.\n *\n * 5. Products derived from this software may not be called \"OpenSSL\"\n *    nor may \"OpenSSL\" appear in their names without prior written\n *    permission of the OpenSSL Project.\n *\n * 6. Redistributions of any form whatsoever must retain the following\n *    acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)\"\n *\n * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY\n * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\n * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR\n * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\n * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,\n * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED\n * OF THE POSSIBILITY OF SUCH DAMAGE.\n * ====================================================================\n *\n * This product includes cryptographic software written by Eric Young\n * (eay@cryptsoft.com).  This product includes software written by Tim\n * Hudson (tjh@cryptsoft.com).\n *\n */\n\n#ifndef HEADER_PKCS12_H\n# define HEADER_PKCS12_H\n\n# include <openssl/bio.h>\n# include <openssl/x509.h>\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n# define PKCS12_KEY_ID   1\n# define PKCS12_IV_ID    2\n# define PKCS12_MAC_ID   3\n\n/* Default iteration count */\n# ifndef PKCS12_DEFAULT_ITER\n#  define PKCS12_DEFAULT_ITER     PKCS5_DEFAULT_ITER\n# endif\n\n# define PKCS12_MAC_KEY_LENGTH 20\n\n# define PKCS12_SALT_LEN 8\n\n/* Uncomment out next line for unicode password and names, otherwise ASCII */\n\n/*\n * #define PBE_UNICODE\n */\n\n# ifdef PBE_UNICODE\n#  define PKCS12_key_gen PKCS12_key_gen_uni\n#  define PKCS12_add_friendlyname PKCS12_add_friendlyname_uni\n# else\n#  define PKCS12_key_gen PKCS12_key_gen_asc\n#  define PKCS12_add_friendlyname PKCS12_add_friendlyname_asc\n# endif\n\n/* MS key usage constants */\n\n# define KEY_EX  0x10\n# define KEY_SIG 0x80\n\ntypedef struct {\n    X509_SIG *dinfo;\n    ASN1_OCTET_STRING *salt;\n    ASN1_INTEGER *iter;         /* defaults to 1 */\n} PKCS12_MAC_DATA;\n\ntypedef struct {\n    ASN1_INTEGER *version;\n    PKCS12_MAC_DATA *mac;\n    PKCS7 *authsafes;\n} PKCS12;\n\ntypedef struct {\n    ASN1_OBJECT *type;\n    union {\n        struct pkcs12_bag_st *bag; /* secret, crl and certbag */\n        struct pkcs8_priv_key_info_st *keybag; /* keybag */\n        X509_SIG *shkeybag;     /* shrouded key bag */\n        STACK_OF(PKCS12_SAFEBAG) *safes;\n        ASN1_TYPE *other;\n    } value;\n    STACK_OF(X509_ATTRIBUTE) *attrib;\n} PKCS12_SAFEBAG;\n\nDECLARE_STACK_OF(PKCS12_SAFEBAG)\nDECLARE_ASN1_SET_OF(PKCS12_SAFEBAG)\nDECLARE_PKCS12_STACK_OF(PKCS12_SAFEBAG)\n\ntypedef struct pkcs12_bag_st {\n    ASN1_OBJECT *type;\n    union {\n        ASN1_OCTET_STRING *x509cert;\n        ASN1_OCTET_STRING *x509crl;\n        ASN1_OCTET_STRING *octet;\n        ASN1_IA5STRING *sdsicert;\n        ASN1_TYPE *other;       /* Secret or other bag */\n    } value;\n} PKCS12_BAGS;\n\n# define PKCS12_ERROR    0\n# define PKCS12_OK       1\n\n/* Compatibility macros */\n\n# define M_PKCS12_x5092certbag PKCS12_x5092certbag\n# define M_PKCS12_x509crl2certbag PKCS12_x509crl2certbag\n\n# define M_PKCS12_certbag2x509 PKCS12_certbag2x509\n# define M_PKCS12_certbag2x509crl PKCS12_certbag2x509crl\n\n# define M_PKCS12_unpack_p7data PKCS12_unpack_p7data\n# define M_PKCS12_pack_authsafes PKCS12_pack_authsafes\n# define M_PKCS12_unpack_authsafes PKCS12_unpack_authsafes\n# define M_PKCS12_unpack_p7encdata PKCS12_unpack_p7encdata\n\n# define M_PKCS12_decrypt_skey PKCS12_decrypt_skey\n# define M_PKCS8_decrypt PKCS8_decrypt\n\n# define M_PKCS12_bag_type(bg) OBJ_obj2nid((bg)->type)\n# define M_PKCS12_cert_bag_type(bg) OBJ_obj2nid((bg)->value.bag->type)\n# define M_PKCS12_crl_bag_type M_PKCS12_cert_bag_type\n\n# define PKCS12_get_attr(bag, attr_nid) \\\n                         PKCS12_get_attr_gen(bag->attrib, attr_nid)\n\n# define PKCS8_get_attr(p8, attr_nid) \\\n                PKCS12_get_attr_gen(p8->attributes, attr_nid)\n\n# define PKCS12_mac_present(p12) ((p12)->mac ? 1 : 0)\n\nPKCS12_SAFEBAG *PKCS12_x5092certbag(X509 *x509);\nPKCS12_SAFEBAG *PKCS12_x509crl2certbag(X509_CRL *crl);\nX509 *PKCS12_certbag2x509(PKCS12_SAFEBAG *bag);\nX509_CRL *PKCS12_certbag2x509crl(PKCS12_SAFEBAG *bag);\n\nPKCS12_SAFEBAG *PKCS12_item_pack_safebag(void *obj, const ASN1_ITEM *it,\n                                         int nid1, int nid2);\nPKCS12_SAFEBAG *PKCS12_MAKE_KEYBAG(PKCS8_PRIV_KEY_INFO *p8);\nPKCS8_PRIV_KEY_INFO *PKCS8_decrypt(X509_SIG *p8, const char *pass,\n                                   int passlen);\nPKCS8_PRIV_KEY_INFO *PKCS12_decrypt_skey(PKCS12_SAFEBAG *bag,\n                                         const char *pass, int passlen);\nX509_SIG *PKCS8_encrypt(int pbe_nid, const EVP_CIPHER *cipher,\n                        const char *pass, int passlen, unsigned char *salt,\n                        int saltlen, int iter, PKCS8_PRIV_KEY_INFO *p8);\nPKCS12_SAFEBAG *PKCS12_MAKE_SHKEYBAG(int pbe_nid, const char *pass,\n                                     int passlen, unsigned char *salt,\n                                     int saltlen, int iter,\n                                     PKCS8_PRIV_KEY_INFO *p8);\nPKCS7 *PKCS12_pack_p7data(STACK_OF(PKCS12_SAFEBAG) *sk);\nSTACK_OF(PKCS12_SAFEBAG) *PKCS12_unpack_p7data(PKCS7 *p7);\nPKCS7 *PKCS12_pack_p7encdata(int pbe_nid, const char *pass, int passlen,\n                             unsigned char *salt, int saltlen, int iter,\n                             STACK_OF(PKCS12_SAFEBAG) *bags);\nSTACK_OF(PKCS12_SAFEBAG) *PKCS12_unpack_p7encdata(PKCS7 *p7, const char *pass,\n                                                  int passlen);\n\nint PKCS12_pack_authsafes(PKCS12 *p12, STACK_OF(PKCS7) *safes);\nSTACK_OF(PKCS7) *PKCS12_unpack_authsafes(PKCS12 *p12);\n\nint PKCS12_add_localkeyid(PKCS12_SAFEBAG *bag, unsigned char *name,\n                          int namelen);\nint PKCS12_add_friendlyname_asc(PKCS12_SAFEBAG *bag, const char *name,\n                                int namelen);\nint PKCS12_add_CSPName_asc(PKCS12_SAFEBAG *bag, const char *name,\n                           int namelen);\nint PKCS12_add_friendlyname_uni(PKCS12_SAFEBAG *bag,\n                                const unsigned char *name, int namelen);\nint PKCS8_add_keyusage(PKCS8_PRIV_KEY_INFO *p8, int usage);\nASN1_TYPE *PKCS12_get_attr_gen(STACK_OF(X509_ATTRIBUTE) *attrs, int attr_nid);\nchar *PKCS12_get_friendlyname(PKCS12_SAFEBAG *bag);\nunsigned char *PKCS12_pbe_crypt(X509_ALGOR *algor, const char *pass,\n                                int passlen, unsigned char *in, int inlen,\n                                unsigned char **data, int *datalen,\n                                int en_de);\nvoid *PKCS12_item_decrypt_d2i(X509_ALGOR *algor, const ASN1_ITEM *it,\n                              const char *pass, int passlen,\n                              ASN1_OCTET_STRING *oct, int zbuf);\nASN1_OCTET_STRING *PKCS12_item_i2d_encrypt(X509_ALGOR *algor,\n                                           const ASN1_ITEM *it,\n                                           const char *pass, int passlen,\n                                           void *obj, int zbuf);\nPKCS12 *PKCS12_init(int mode);\nint PKCS12_key_gen_asc(const char *pass, int passlen, unsigned char *salt,\n                       int saltlen, int id, int iter, int n,\n                       unsigned char *out, const EVP_MD *md_type);\nint PKCS12_key_gen_uni(unsigned char *pass, int passlen, unsigned char *salt,\n                       int saltlen, int id, int iter, int n,\n                       unsigned char *out, const EVP_MD *md_type);\nint PKCS12_PBE_keyivgen(EVP_CIPHER_CTX *ctx, const char *pass, int passlen,\n                        ASN1_TYPE *param, const EVP_CIPHER *cipher,\n                        const EVP_MD *md_type, int en_de);\nint PKCS12_gen_mac(PKCS12 *p12, const char *pass, int passlen,\n                   unsigned char *mac, unsigned int *maclen);\nint PKCS12_verify_mac(PKCS12 *p12, const char *pass, int passlen);\nint PKCS12_set_mac(PKCS12 *p12, const char *pass, int passlen,\n                   unsigned char *salt, int saltlen, int iter,\n                   const EVP_MD *md_type);\nint PKCS12_setup_mac(PKCS12 *p12, int iter, unsigned char *salt,\n                     int saltlen, const EVP_MD *md_type);\nunsigned char *OPENSSL_asc2uni(const char *asc, int asclen,\n                               unsigned char **uni, int *unilen);\nchar *OPENSSL_uni2asc(unsigned char *uni, int unilen);\n\nDECLARE_ASN1_FUNCTIONS(PKCS12)\nDECLARE_ASN1_FUNCTIONS(PKCS12_MAC_DATA)\nDECLARE_ASN1_FUNCTIONS(PKCS12_SAFEBAG)\nDECLARE_ASN1_FUNCTIONS(PKCS12_BAGS)\n\nDECLARE_ASN1_ITEM(PKCS12_SAFEBAGS)\nDECLARE_ASN1_ITEM(PKCS12_AUTHSAFES)\n\nvoid PKCS12_PBE_add(void);\nint PKCS12_parse(PKCS12 *p12, const char *pass, EVP_PKEY **pkey, X509 **cert,\n                 STACK_OF(X509) **ca);\nPKCS12 *PKCS12_create(char *pass, char *name, EVP_PKEY *pkey, X509 *cert,\n                      STACK_OF(X509) *ca, int nid_key, int nid_cert, int iter,\n                      int mac_iter, int keytype);\n\nPKCS12_SAFEBAG *PKCS12_add_cert(STACK_OF(PKCS12_SAFEBAG) **pbags, X509 *cert);\nPKCS12_SAFEBAG *PKCS12_add_key(STACK_OF(PKCS12_SAFEBAG) **pbags,\n                               EVP_PKEY *key, int key_usage, int iter,\n                               int key_nid, char *pass);\nint PKCS12_add_safe(STACK_OF(PKCS7) **psafes, STACK_OF(PKCS12_SAFEBAG) *bags,\n                    int safe_nid, int iter, char *pass);\nPKCS12 *PKCS12_add_safes(STACK_OF(PKCS7) *safes, int p7_nid);\n\nint i2d_PKCS12_bio(BIO *bp, PKCS12 *p12);\nint i2d_PKCS12_fp(FILE *fp, PKCS12 *p12);\nPKCS12 *d2i_PKCS12_bio(BIO *bp, PKCS12 **p12);\nPKCS12 *d2i_PKCS12_fp(FILE *fp, PKCS12 **p12);\nint PKCS12_newpass(PKCS12 *p12, const char *oldpass, const char *newpass);\n\n/* BEGIN ERROR CODES */\n/*\n * The following lines are auto generated by the script mkerr.pl. Any changes\n * made after this point may be overwritten when the script is next run.\n */\nvoid ERR_load_PKCS12_strings(void);\n\n/* Error codes for the PKCS12 functions. */\n\n/* Function codes. */\n# define PKCS12_F_PARSE_BAG                               129\n# define PKCS12_F_PARSE_BAGS                              103\n# define PKCS12_F_PKCS12_ADD_FRIENDLYNAME                 100\n# define PKCS12_F_PKCS12_ADD_FRIENDLYNAME_ASC             127\n# define PKCS12_F_PKCS12_ADD_FRIENDLYNAME_UNI             102\n# define PKCS12_F_PKCS12_ADD_LOCALKEYID                   104\n# define PKCS12_F_PKCS12_CREATE                           105\n# define PKCS12_F_PKCS12_GEN_MAC                          107\n# define PKCS12_F_PKCS12_INIT                             109\n# define PKCS12_F_PKCS12_ITEM_DECRYPT_D2I                 106\n# define PKCS12_F_PKCS12_ITEM_I2D_ENCRYPT                 108\n# define PKCS12_F_PKCS12_ITEM_PACK_SAFEBAG                117\n# define PKCS12_F_PKCS12_KEY_GEN_ASC                      110\n# define PKCS12_F_PKCS12_KEY_GEN_UNI                      111\n# define PKCS12_F_PKCS12_MAKE_KEYBAG                      112\n# define PKCS12_F_PKCS12_MAKE_SHKEYBAG                    113\n# define PKCS12_F_PKCS12_NEWPASS                          128\n# define PKCS12_F_PKCS12_PACK_P7DATA                      114\n# define PKCS12_F_PKCS12_PACK_P7ENCDATA                   115\n# define PKCS12_F_PKCS12_PARSE                            118\n# define PKCS12_F_PKCS12_PBE_CRYPT                        119\n# define PKCS12_F_PKCS12_PBE_KEYIVGEN                     120\n# define PKCS12_F_PKCS12_SETUP_MAC                        122\n# define PKCS12_F_PKCS12_SET_MAC                          123\n# define PKCS12_F_PKCS12_UNPACK_AUTHSAFES                 130\n# define PKCS12_F_PKCS12_UNPACK_P7DATA                    131\n# define PKCS12_F_PKCS12_VERIFY_MAC                       126\n# define PKCS12_F_PKCS8_ADD_KEYUSAGE                      124\n# define PKCS12_F_PKCS8_ENCRYPT                           125\n\n/* Reason codes. */\n# define PKCS12_R_CANT_PACK_STRUCTURE                     100\n# define PKCS12_R_CONTENT_TYPE_NOT_DATA                   121\n# define PKCS12_R_DECODE_ERROR                            101\n# define PKCS12_R_ENCODE_ERROR                            102\n# define PKCS12_R_ENCRYPT_ERROR                           103\n# define PKCS12_R_ERROR_SETTING_ENCRYPTED_DATA_TYPE       120\n# define PKCS12_R_INVALID_NULL_ARGUMENT                   104\n# define PKCS12_R_INVALID_NULL_PKCS12_POINTER             105\n# define PKCS12_R_IV_GEN_ERROR                            106\n# define PKCS12_R_KEY_GEN_ERROR                           107\n# define PKCS12_R_MAC_ABSENT                              108\n# define PKCS12_R_MAC_GENERATION_ERROR                    109\n# define PKCS12_R_MAC_SETUP_ERROR                         110\n# define PKCS12_R_MAC_STRING_SET_ERROR                    111\n# define PKCS12_R_MAC_VERIFY_ERROR                        112\n# define PKCS12_R_MAC_VERIFY_FAILURE                      113\n# define PKCS12_R_PARSE_ERROR                             114\n# define PKCS12_R_PKCS12_ALGOR_CIPHERINIT_ERROR           115\n# define PKCS12_R_PKCS12_CIPHERFINAL_ERROR                116\n# define PKCS12_R_PKCS12_PBE_CRYPT_ERROR                  117\n# define PKCS12_R_UNKNOWN_DIGEST_ALGORITHM                118\n# define PKCS12_R_UNSUPPORTED_PKCS12_MODE                 119\n\n#ifdef  __cplusplus\n}\n#endif\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/x86/include/openssl/pkcs7.h",
    "content": "/* crypto/pkcs7/pkcs7.h */\n/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)\n * All rights reserved.\n *\n * This package is an SSL implementation written\n * by Eric Young (eay@cryptsoft.com).\n * The implementation was written so as to conform with Netscapes SSL.\n *\n * This library is free for commercial and non-commercial use as long as\n * the following conditions are aheared to.  The following conditions\n * apply to all code found in this distribution, be it the RC4, RSA,\n * lhash, DES, etc., code; not just the SSL code.  The SSL documentation\n * included with this distribution is covered by the same copyright terms\n * except that the holder is Tim Hudson (tjh@cryptsoft.com).\n *\n * Copyright remains Eric Young's, and as such any Copyright notices in\n * the code are not to be removed.\n * If this package is used in a product, Eric Young should be given attribution\n * as the author of the parts of the library used.\n * This can be in the form of a textual message at program startup or\n * in documentation (online or textual) provided with the package.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the copyright\n *    notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in the\n *    documentation and/or other materials provided with the distribution.\n * 3. All advertising materials mentioning features or use of this software\n *    must display the following acknowledgement:\n *    \"This product includes cryptographic software written by\n *     Eric Young (eay@cryptsoft.com)\"\n *    The word 'cryptographic' can be left out if the rouines from the library\n *    being used are not cryptographic related :-).\n * 4. If you include any Windows specific code (or a derivative thereof) from\n *    the apps directory (application code) you must include an acknowledgement:\n *    \"This product includes software written by Tim Hudson (tjh@cryptsoft.com)\"\n *\n * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n * SUCH DAMAGE.\n *\n * The licence and distribution terms for any publically available version or\n * derivative of this code cannot be changed.  i.e. this code cannot simply be\n * copied and put under another distribution licence\n * [including the GNU Public Licence.]\n */\n\n#ifndef HEADER_PKCS7_H\n# define HEADER_PKCS7_H\n\n# include <openssl/asn1.h>\n# include <openssl/bio.h>\n# include <openssl/e_os2.h>\n\n# include <openssl/symhacks.h>\n# include <openssl/ossl_typ.h>\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n# ifdef OPENSSL_SYS_WIN32\n/* Under Win32 thes are defined in wincrypt.h */\n#  undef PKCS7_ISSUER_AND_SERIAL\n#  undef PKCS7_SIGNER_INFO\n# endif\n\n/*-\nEncryption_ID           DES-CBC\nDigest_ID               MD5\nDigest_Encryption_ID    rsaEncryption\nKey_Encryption_ID       rsaEncryption\n*/\n\ntypedef struct pkcs7_issuer_and_serial_st {\n    X509_NAME *issuer;\n    ASN1_INTEGER *serial;\n} PKCS7_ISSUER_AND_SERIAL;\n\ntypedef struct pkcs7_signer_info_st {\n    ASN1_INTEGER *version;      /* version 1 */\n    PKCS7_ISSUER_AND_SERIAL *issuer_and_serial;\n    X509_ALGOR *digest_alg;\n    STACK_OF(X509_ATTRIBUTE) *auth_attr; /* [ 0 ] */\n    X509_ALGOR *digest_enc_alg;\n    ASN1_OCTET_STRING *enc_digest;\n    STACK_OF(X509_ATTRIBUTE) *unauth_attr; /* [ 1 ] */\n    /* The private key to sign with */\n    EVP_PKEY *pkey;\n} PKCS7_SIGNER_INFO;\n\nDECLARE_STACK_OF(PKCS7_SIGNER_INFO)\nDECLARE_ASN1_SET_OF(PKCS7_SIGNER_INFO)\n\ntypedef struct pkcs7_recip_info_st {\n    ASN1_INTEGER *version;      /* version 0 */\n    PKCS7_ISSUER_AND_SERIAL *issuer_and_serial;\n    X509_ALGOR *key_enc_algor;\n    ASN1_OCTET_STRING *enc_key;\n    X509 *cert;                 /* get the pub-key from this */\n} PKCS7_RECIP_INFO;\n\nDECLARE_STACK_OF(PKCS7_RECIP_INFO)\nDECLARE_ASN1_SET_OF(PKCS7_RECIP_INFO)\n\ntypedef struct pkcs7_signed_st {\n    ASN1_INTEGER *version;      /* version 1 */\n    STACK_OF(X509_ALGOR) *md_algs; /* md used */\n    STACK_OF(X509) *cert;       /* [ 0 ] */\n    STACK_OF(X509_CRL) *crl;    /* [ 1 ] */\n    STACK_OF(PKCS7_SIGNER_INFO) *signer_info;\n    struct pkcs7_st *contents;\n} PKCS7_SIGNED;\n/*\n * The above structure is very very similar to PKCS7_SIGN_ENVELOPE. How about\n * merging the two\n */\n\ntypedef struct pkcs7_enc_content_st {\n    ASN1_OBJECT *content_type;\n    X509_ALGOR *algorithm;\n    ASN1_OCTET_STRING *enc_data; /* [ 0 ] */\n    const EVP_CIPHER *cipher;\n} PKCS7_ENC_CONTENT;\n\ntypedef struct pkcs7_enveloped_st {\n    ASN1_INTEGER *version;      /* version 0 */\n    STACK_OF(PKCS7_RECIP_INFO) *recipientinfo;\n    PKCS7_ENC_CONTENT *enc_data;\n} PKCS7_ENVELOPE;\n\ntypedef struct pkcs7_signedandenveloped_st {\n    ASN1_INTEGER *version;      /* version 1 */\n    STACK_OF(X509_ALGOR) *md_algs; /* md used */\n    STACK_OF(X509) *cert;       /* [ 0 ] */\n    STACK_OF(X509_CRL) *crl;    /* [ 1 ] */\n    STACK_OF(PKCS7_SIGNER_INFO) *signer_info;\n    PKCS7_ENC_CONTENT *enc_data;\n    STACK_OF(PKCS7_RECIP_INFO) *recipientinfo;\n} PKCS7_SIGN_ENVELOPE;\n\ntypedef struct pkcs7_digest_st {\n    ASN1_INTEGER *version;      /* version 0 */\n    X509_ALGOR *md;             /* md used */\n    struct pkcs7_st *contents;\n    ASN1_OCTET_STRING *digest;\n} PKCS7_DIGEST;\n\ntypedef struct pkcs7_encrypted_st {\n    ASN1_INTEGER *version;      /* version 0 */\n    PKCS7_ENC_CONTENT *enc_data;\n} PKCS7_ENCRYPT;\n\ntypedef struct pkcs7_st {\n    /*\n     * The following is non NULL if it contains ASN1 encoding of this\n     * structure\n     */\n    unsigned char *asn1;\n    long length;\n# define PKCS7_S_HEADER  0\n# define PKCS7_S_BODY    1\n# define PKCS7_S_TAIL    2\n    int state;                  /* used during processing */\n    int detached;\n    ASN1_OBJECT *type;\n    /* content as defined by the type */\n    /*\n     * all encryption/message digests are applied to the 'contents', leaving\n     * out the 'type' field.\n     */\n    union {\n        char *ptr;\n        /* NID_pkcs7_data */\n        ASN1_OCTET_STRING *data;\n        /* NID_pkcs7_signed */\n        PKCS7_SIGNED *sign;\n        /* NID_pkcs7_enveloped */\n        PKCS7_ENVELOPE *enveloped;\n        /* NID_pkcs7_signedAndEnveloped */\n        PKCS7_SIGN_ENVELOPE *signed_and_enveloped;\n        /* NID_pkcs7_digest */\n        PKCS7_DIGEST *digest;\n        /* NID_pkcs7_encrypted */\n        PKCS7_ENCRYPT *encrypted;\n        /* Anything else */\n        ASN1_TYPE *other;\n    } d;\n} PKCS7;\n\nDECLARE_STACK_OF(PKCS7)\nDECLARE_ASN1_SET_OF(PKCS7)\nDECLARE_PKCS12_STACK_OF(PKCS7)\n\n# define PKCS7_OP_SET_DETACHED_SIGNATURE 1\n# define PKCS7_OP_GET_DETACHED_SIGNATURE 2\n\n# define PKCS7_get_signed_attributes(si) ((si)->auth_attr)\n# define PKCS7_get_attributes(si)        ((si)->unauth_attr)\n\n# define PKCS7_type_is_signed(a) (OBJ_obj2nid((a)->type) == NID_pkcs7_signed)\n# define PKCS7_type_is_encrypted(a) (OBJ_obj2nid((a)->type) == NID_pkcs7_encrypted)\n# define PKCS7_type_is_enveloped(a) (OBJ_obj2nid((a)->type) == NID_pkcs7_enveloped)\n# define PKCS7_type_is_signedAndEnveloped(a) \\\n                (OBJ_obj2nid((a)->type) == NID_pkcs7_signedAndEnveloped)\n# define PKCS7_type_is_data(a)   (OBJ_obj2nid((a)->type) == NID_pkcs7_data)\n# define PKCS7_type_is_digest(a)   (OBJ_obj2nid((a)->type) == NID_pkcs7_digest)\n\n# define PKCS7_set_detached(p,v) \\\n                PKCS7_ctrl(p,PKCS7_OP_SET_DETACHED_SIGNATURE,v,NULL)\n# define PKCS7_get_detached(p) \\\n                PKCS7_ctrl(p,PKCS7_OP_GET_DETACHED_SIGNATURE,0,NULL)\n\n# define PKCS7_is_detached(p7) (PKCS7_type_is_signed(p7) && PKCS7_get_detached(p7))\n\n/* S/MIME related flags */\n\n# define PKCS7_TEXT              0x1\n# define PKCS7_NOCERTS           0x2\n# define PKCS7_NOSIGS            0x4\n# define PKCS7_NOCHAIN           0x8\n# define PKCS7_NOINTERN          0x10\n# define PKCS7_NOVERIFY          0x20\n# define PKCS7_DETACHED          0x40\n# define PKCS7_BINARY            0x80\n# define PKCS7_NOATTR            0x100\n# define PKCS7_NOSMIMECAP        0x200\n# define PKCS7_NOOLDMIMETYPE     0x400\n# define PKCS7_CRLFEOL           0x800\n# define PKCS7_STREAM            0x1000\n# define PKCS7_NOCRL             0x2000\n# define PKCS7_PARTIAL           0x4000\n# define PKCS7_REUSE_DIGEST      0x8000\n\n/* Flags: for compatibility with older code */\n\n# define SMIME_TEXT      PKCS7_TEXT\n# define SMIME_NOCERTS   PKCS7_NOCERTS\n# define SMIME_NOSIGS    PKCS7_NOSIGS\n# define SMIME_NOCHAIN   PKCS7_NOCHAIN\n# define SMIME_NOINTERN  PKCS7_NOINTERN\n# define SMIME_NOVERIFY  PKCS7_NOVERIFY\n# define SMIME_DETACHED  PKCS7_DETACHED\n# define SMIME_BINARY    PKCS7_BINARY\n# define SMIME_NOATTR    PKCS7_NOATTR\n\nDECLARE_ASN1_FUNCTIONS(PKCS7_ISSUER_AND_SERIAL)\n\nint PKCS7_ISSUER_AND_SERIAL_digest(PKCS7_ISSUER_AND_SERIAL *data,\n                                   const EVP_MD *type, unsigned char *md,\n                                   unsigned int *len);\n# ifndef OPENSSL_NO_FP_API\nPKCS7 *d2i_PKCS7_fp(FILE *fp, PKCS7 **p7);\nint i2d_PKCS7_fp(FILE *fp, PKCS7 *p7);\n# endif\nPKCS7 *PKCS7_dup(PKCS7 *p7);\nPKCS7 *d2i_PKCS7_bio(BIO *bp, PKCS7 **p7);\nint i2d_PKCS7_bio(BIO *bp, PKCS7 *p7);\nint i2d_PKCS7_bio_stream(BIO *out, PKCS7 *p7, BIO *in, int flags);\nint PEM_write_bio_PKCS7_stream(BIO *out, PKCS7 *p7, BIO *in, int flags);\n\nDECLARE_ASN1_FUNCTIONS(PKCS7_SIGNER_INFO)\nDECLARE_ASN1_FUNCTIONS(PKCS7_RECIP_INFO)\nDECLARE_ASN1_FUNCTIONS(PKCS7_SIGNED)\nDECLARE_ASN1_FUNCTIONS(PKCS7_ENC_CONTENT)\nDECLARE_ASN1_FUNCTIONS(PKCS7_ENVELOPE)\nDECLARE_ASN1_FUNCTIONS(PKCS7_SIGN_ENVELOPE)\nDECLARE_ASN1_FUNCTIONS(PKCS7_DIGEST)\nDECLARE_ASN1_FUNCTIONS(PKCS7_ENCRYPT)\nDECLARE_ASN1_FUNCTIONS(PKCS7)\n\nDECLARE_ASN1_ITEM(PKCS7_ATTR_SIGN)\nDECLARE_ASN1_ITEM(PKCS7_ATTR_VERIFY)\n\nDECLARE_ASN1_NDEF_FUNCTION(PKCS7)\nDECLARE_ASN1_PRINT_FUNCTION(PKCS7)\n\nlong PKCS7_ctrl(PKCS7 *p7, int cmd, long larg, char *parg);\n\nint PKCS7_set_type(PKCS7 *p7, int type);\nint PKCS7_set0_type_other(PKCS7 *p7, int type, ASN1_TYPE *other);\nint PKCS7_set_content(PKCS7 *p7, PKCS7 *p7_data);\nint PKCS7_SIGNER_INFO_set(PKCS7_SIGNER_INFO *p7i, X509 *x509, EVP_PKEY *pkey,\n                          const EVP_MD *dgst);\nint PKCS7_SIGNER_INFO_sign(PKCS7_SIGNER_INFO *si);\nint PKCS7_add_signer(PKCS7 *p7, PKCS7_SIGNER_INFO *p7i);\nint PKCS7_add_certificate(PKCS7 *p7, X509 *x509);\nint PKCS7_add_crl(PKCS7 *p7, X509_CRL *x509);\nint PKCS7_content_new(PKCS7 *p7, int nid);\nint PKCS7_dataVerify(X509_STORE *cert_store, X509_STORE_CTX *ctx,\n                     BIO *bio, PKCS7 *p7, PKCS7_SIGNER_INFO *si);\nint PKCS7_signatureVerify(BIO *bio, PKCS7 *p7, PKCS7_SIGNER_INFO *si,\n                          X509 *x509);\n\nBIO *PKCS7_dataInit(PKCS7 *p7, BIO *bio);\nint PKCS7_dataFinal(PKCS7 *p7, BIO *bio);\nBIO *PKCS7_dataDecode(PKCS7 *p7, EVP_PKEY *pkey, BIO *in_bio, X509 *pcert);\n\nPKCS7_SIGNER_INFO *PKCS7_add_signature(PKCS7 *p7, X509 *x509,\n                                       EVP_PKEY *pkey, const EVP_MD *dgst);\nX509 *PKCS7_cert_from_signer_info(PKCS7 *p7, PKCS7_SIGNER_INFO *si);\nint PKCS7_set_digest(PKCS7 *p7, const EVP_MD *md);\nSTACK_OF(PKCS7_SIGNER_INFO) *PKCS7_get_signer_info(PKCS7 *p7);\n\nPKCS7_RECIP_INFO *PKCS7_add_recipient(PKCS7 *p7, X509 *x509);\nvoid PKCS7_SIGNER_INFO_get0_algs(PKCS7_SIGNER_INFO *si, EVP_PKEY **pk,\n                                 X509_ALGOR **pdig, X509_ALGOR **psig);\nvoid PKCS7_RECIP_INFO_get0_alg(PKCS7_RECIP_INFO *ri, X509_ALGOR **penc);\nint PKCS7_add_recipient_info(PKCS7 *p7, PKCS7_RECIP_INFO *ri);\nint PKCS7_RECIP_INFO_set(PKCS7_RECIP_INFO *p7i, X509 *x509);\nint PKCS7_set_cipher(PKCS7 *p7, const EVP_CIPHER *cipher);\nint PKCS7_stream(unsigned char ***boundary, PKCS7 *p7);\n\nPKCS7_ISSUER_AND_SERIAL *PKCS7_get_issuer_and_serial(PKCS7 *p7, int idx);\nASN1_OCTET_STRING *PKCS7_digest_from_attributes(STACK_OF(X509_ATTRIBUTE) *sk);\nint PKCS7_add_signed_attribute(PKCS7_SIGNER_INFO *p7si, int nid, int type,\n                               void *data);\nint PKCS7_add_attribute(PKCS7_SIGNER_INFO *p7si, int nid, int atrtype,\n                        void *value);\nASN1_TYPE *PKCS7_get_attribute(PKCS7_SIGNER_INFO *si, int nid);\nASN1_TYPE *PKCS7_get_signed_attribute(PKCS7_SIGNER_INFO *si, int nid);\nint PKCS7_set_signed_attributes(PKCS7_SIGNER_INFO *p7si,\n                                STACK_OF(X509_ATTRIBUTE) *sk);\nint PKCS7_set_attributes(PKCS7_SIGNER_INFO *p7si,\n                         STACK_OF(X509_ATTRIBUTE) *sk);\n\nPKCS7 *PKCS7_sign(X509 *signcert, EVP_PKEY *pkey, STACK_OF(X509) *certs,\n                  BIO *data, int flags);\n\nPKCS7_SIGNER_INFO *PKCS7_sign_add_signer(PKCS7 *p7,\n                                         X509 *signcert, EVP_PKEY *pkey,\n                                         const EVP_MD *md, int flags);\n\nint PKCS7_final(PKCS7 *p7, BIO *data, int flags);\nint PKCS7_verify(PKCS7 *p7, STACK_OF(X509) *certs, X509_STORE *store,\n                 BIO *indata, BIO *out, int flags);\nSTACK_OF(X509) *PKCS7_get0_signers(PKCS7 *p7, STACK_OF(X509) *certs,\n                                   int flags);\nPKCS7 *PKCS7_encrypt(STACK_OF(X509) *certs, BIO *in, const EVP_CIPHER *cipher,\n                     int flags);\nint PKCS7_decrypt(PKCS7 *p7, EVP_PKEY *pkey, X509 *cert, BIO *data,\n                  int flags);\n\nint PKCS7_add_attrib_smimecap(PKCS7_SIGNER_INFO *si,\n                              STACK_OF(X509_ALGOR) *cap);\nSTACK_OF(X509_ALGOR) *PKCS7_get_smimecap(PKCS7_SIGNER_INFO *si);\nint PKCS7_simple_smimecap(STACK_OF(X509_ALGOR) *sk, int nid, int arg);\n\nint PKCS7_add_attrib_content_type(PKCS7_SIGNER_INFO *si, ASN1_OBJECT *coid);\nint PKCS7_add0_attrib_signing_time(PKCS7_SIGNER_INFO *si, ASN1_TIME *t);\nint PKCS7_add1_attrib_digest(PKCS7_SIGNER_INFO *si,\n                             const unsigned char *md, int mdlen);\n\nint SMIME_write_PKCS7(BIO *bio, PKCS7 *p7, BIO *data, int flags);\nPKCS7 *SMIME_read_PKCS7(BIO *bio, BIO **bcont);\n\nBIO *BIO_new_PKCS7(BIO *out, PKCS7 *p7);\n\n/* BEGIN ERROR CODES */\n/*\n * The following lines are auto generated by the script mkerr.pl. Any changes\n * made after this point may be overwritten when the script is next run.\n */\nvoid ERR_load_PKCS7_strings(void);\n\n/* Error codes for the PKCS7 functions. */\n\n/* Function codes. */\n# define PKCS7_F_B64_READ_PKCS7                           120\n# define PKCS7_F_B64_WRITE_PKCS7                          121\n# define PKCS7_F_DO_PKCS7_SIGNED_ATTRIB                   136\n# define PKCS7_F_I2D_PKCS7_BIO_STREAM                     140\n# define PKCS7_F_PKCS7_ADD0_ATTRIB_SIGNING_TIME           135\n# define PKCS7_F_PKCS7_ADD_ATTRIB_SMIMECAP                118\n# define PKCS7_F_PKCS7_ADD_CERTIFICATE                    100\n# define PKCS7_F_PKCS7_ADD_CRL                            101\n# define PKCS7_F_PKCS7_ADD_RECIPIENT_INFO                 102\n# define PKCS7_F_PKCS7_ADD_SIGNATURE                      131\n# define PKCS7_F_PKCS7_ADD_SIGNER                         103\n# define PKCS7_F_PKCS7_BIO_ADD_DIGEST                     125\n# define PKCS7_F_PKCS7_COPY_EXISTING_DIGEST               138\n# define PKCS7_F_PKCS7_CTRL                               104\n# define PKCS7_F_PKCS7_DATADECODE                         112\n# define PKCS7_F_PKCS7_DATAFINAL                          128\n# define PKCS7_F_PKCS7_DATAINIT                           105\n# define PKCS7_F_PKCS7_DATASIGN                           106\n# define PKCS7_F_PKCS7_DATAVERIFY                         107\n# define PKCS7_F_PKCS7_DECRYPT                            114\n# define PKCS7_F_PKCS7_DECRYPT_RINFO                      133\n# define PKCS7_F_PKCS7_ENCODE_RINFO                       132\n# define PKCS7_F_PKCS7_ENCRYPT                            115\n# define PKCS7_F_PKCS7_FINAL                              134\n# define PKCS7_F_PKCS7_FIND_DIGEST                        127\n# define PKCS7_F_PKCS7_GET0_SIGNERS                       124\n# define PKCS7_F_PKCS7_RECIP_INFO_SET                     130\n# define PKCS7_F_PKCS7_SET_CIPHER                         108\n# define PKCS7_F_PKCS7_SET_CONTENT                        109\n# define PKCS7_F_PKCS7_SET_DIGEST                         126\n# define PKCS7_F_PKCS7_SET_TYPE                           110\n# define PKCS7_F_PKCS7_SIGN                               116\n# define PKCS7_F_PKCS7_SIGNATUREVERIFY                    113\n# define PKCS7_F_PKCS7_SIGNER_INFO_SET                    129\n# define PKCS7_F_PKCS7_SIGNER_INFO_SIGN                   139\n# define PKCS7_F_PKCS7_SIGN_ADD_SIGNER                    137\n# define PKCS7_F_PKCS7_SIMPLE_SMIMECAP                    119\n# define PKCS7_F_PKCS7_VERIFY                             117\n# define PKCS7_F_SMIME_READ_PKCS7                         122\n# define PKCS7_F_SMIME_TEXT                               123\n\n/* Reason codes. */\n# define PKCS7_R_CERTIFICATE_VERIFY_ERROR                 117\n# define PKCS7_R_CIPHER_HAS_NO_OBJECT_IDENTIFIER          144\n# define PKCS7_R_CIPHER_NOT_INITIALIZED                   116\n# define PKCS7_R_CONTENT_AND_DATA_PRESENT                 118\n# define PKCS7_R_CTRL_ERROR                               152\n# define PKCS7_R_DECODE_ERROR                             130\n# define PKCS7_R_DECRYPTED_KEY_IS_WRONG_LENGTH            100\n# define PKCS7_R_DECRYPT_ERROR                            119\n# define PKCS7_R_DIGEST_FAILURE                           101\n# define PKCS7_R_ENCRYPTION_CTRL_FAILURE                  149\n# define PKCS7_R_ENCRYPTION_NOT_SUPPORTED_FOR_THIS_KEY_TYPE 150\n# define PKCS7_R_ERROR_ADDING_RECIPIENT                   120\n# define PKCS7_R_ERROR_SETTING_CIPHER                     121\n# define PKCS7_R_INVALID_MIME_TYPE                        131\n# define PKCS7_R_INVALID_NULL_POINTER                     143\n# define PKCS7_R_INVALID_SIGNED_DATA_TYPE                 155\n# define PKCS7_R_MIME_NO_CONTENT_TYPE                     132\n# define PKCS7_R_MIME_PARSE_ERROR                         133\n# define PKCS7_R_MIME_SIG_PARSE_ERROR                     134\n# define PKCS7_R_MISSING_CERIPEND_INFO                    103\n# define PKCS7_R_NO_CONTENT                               122\n# define PKCS7_R_NO_CONTENT_TYPE                          135\n# define PKCS7_R_NO_DEFAULT_DIGEST                        151\n# define PKCS7_R_NO_MATCHING_DIGEST_TYPE_FOUND            154\n# define PKCS7_R_NO_MULTIPART_BODY_FAILURE                136\n# define PKCS7_R_NO_MULTIPART_BOUNDARY                    137\n# define PKCS7_R_NO_RECIPIENT_MATCHES_CERTIFICATE         115\n# define PKCS7_R_NO_RECIPIENT_MATCHES_KEY                 146\n# define PKCS7_R_NO_SIGNATURES_ON_DATA                    123\n# define PKCS7_R_NO_SIGNERS                               142\n# define PKCS7_R_NO_SIG_CONTENT_TYPE                      138\n# define PKCS7_R_OPERATION_NOT_SUPPORTED_ON_THIS_TYPE     104\n# define PKCS7_R_PKCS7_ADD_SIGNATURE_ERROR                124\n# define PKCS7_R_PKCS7_ADD_SIGNER_ERROR                   153\n# define PKCS7_R_PKCS7_DATAFINAL                          126\n# define PKCS7_R_PKCS7_DATAFINAL_ERROR                    125\n# define PKCS7_R_PKCS7_DATASIGN                           145\n# define PKCS7_R_PKCS7_PARSE_ERROR                        139\n# define PKCS7_R_PKCS7_SIG_PARSE_ERROR                    140\n# define PKCS7_R_PRIVATE_KEY_DOES_NOT_MATCH_CERTIFICATE   127\n# define PKCS7_R_SIGNATURE_FAILURE                        105\n# define PKCS7_R_SIGNER_CERTIFICATE_NOT_FOUND             128\n# define PKCS7_R_SIGNING_CTRL_FAILURE                     147\n# define PKCS7_R_SIGNING_NOT_SUPPORTED_FOR_THIS_KEY_TYPE  148\n# define PKCS7_R_SIG_INVALID_MIME_TYPE                    141\n# define PKCS7_R_SMIME_TEXT_ERROR                         129\n# define PKCS7_R_UNABLE_TO_FIND_CERTIFICATE               106\n# define PKCS7_R_UNABLE_TO_FIND_MEM_BIO                   107\n# define PKCS7_R_UNABLE_TO_FIND_MESSAGE_DIGEST            108\n# define PKCS7_R_UNKNOWN_DIGEST_TYPE                      109\n# define PKCS7_R_UNKNOWN_OPERATION                        110\n# define PKCS7_R_UNSUPPORTED_CIPHER_TYPE                  111\n# define PKCS7_R_UNSUPPORTED_CONTENT_TYPE                 112\n# define PKCS7_R_WRONG_CONTENT_TYPE                       113\n# define PKCS7_R_WRONG_PKCS7_TYPE                         114\n\n#ifdef  __cplusplus\n}\n#endif\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/x86/include/openssl/pqueue.h",
    "content": "/* crypto/pqueue/pqueue.h */\n/*\n * DTLS implementation written by Nagendra Modadugu\n * (nagendra@cs.stanford.edu) for the OpenSSL project 2005.\n */\n/* ====================================================================\n * Copyright (c) 1999-2005 The OpenSSL Project.  All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n *\n * 1. Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n *\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in\n *    the documentation and/or other materials provided with the\n *    distribution.\n *\n * 3. All advertising materials mentioning features or use of this\n *    software must display the following acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)\"\n *\n * 4. The names \"OpenSSL Toolkit\" and \"OpenSSL Project\" must not be used to\n *    endorse or promote products derived from this software without\n *    prior written permission. For written permission, please contact\n *    openssl-core@OpenSSL.org.\n *\n * 5. Products derived from this software may not be called \"OpenSSL\"\n *    nor may \"OpenSSL\" appear in their names without prior written\n *    permission of the OpenSSL Project.\n *\n * 6. Redistributions of any form whatsoever must retain the following\n *    acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)\"\n *\n * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY\n * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\n * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR\n * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\n * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,\n * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED\n * OF THE POSSIBILITY OF SUCH DAMAGE.\n * ====================================================================\n *\n * This product includes cryptographic software written by Eric Young\n * (eay@cryptsoft.com).  This product includes software written by Tim\n * Hudson (tjh@cryptsoft.com).\n *\n */\n\n#ifndef HEADER_PQUEUE_H\n# define HEADER_PQUEUE_H\n\n# include <stdio.h>\n# include <stdlib.h>\n# include <string.h>\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\ntypedef struct _pqueue *pqueue;\n\ntypedef struct _pitem {\n    unsigned char priority[8];  /* 64-bit value in big-endian encoding */\n    void *data;\n    struct _pitem *next;\n} pitem;\n\ntypedef struct _pitem *piterator;\n\npitem *pitem_new(unsigned char *prio64be, void *data);\nvoid pitem_free(pitem *item);\n\npqueue pqueue_new(void);\nvoid pqueue_free(pqueue pq);\n\npitem *pqueue_insert(pqueue pq, pitem *item);\npitem *pqueue_peek(pqueue pq);\npitem *pqueue_pop(pqueue pq);\npitem *pqueue_find(pqueue pq, unsigned char *prio64be);\npitem *pqueue_iterator(pqueue pq);\npitem *pqueue_next(piterator *iter);\n\nvoid pqueue_print(pqueue pq);\nint pqueue_size(pqueue pq);\n\n#ifdef  __cplusplus\n}\n#endif\n#endif                          /* ! HEADER_PQUEUE_H */\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/x86/include/openssl/rand.h",
    "content": "/* crypto/rand/rand.h */\n/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)\n * All rights reserved.\n *\n * This package is an SSL implementation written\n * by Eric Young (eay@cryptsoft.com).\n * The implementation was written so as to conform with Netscapes SSL.\n *\n * This library is free for commercial and non-commercial use as long as\n * the following conditions are aheared to.  The following conditions\n * apply to all code found in this distribution, be it the RC4, RSA,\n * lhash, DES, etc., code; not just the SSL code.  The SSL documentation\n * included with this distribution is covered by the same copyright terms\n * except that the holder is Tim Hudson (tjh@cryptsoft.com).\n *\n * Copyright remains Eric Young's, and as such any Copyright notices in\n * the code are not to be removed.\n * If this package is used in a product, Eric Young should be given attribution\n * as the author of the parts of the library used.\n * This can be in the form of a textual message at program startup or\n * in documentation (online or textual) provided with the package.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the copyright\n *    notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in the\n *    documentation and/or other materials provided with the distribution.\n * 3. All advertising materials mentioning features or use of this software\n *    must display the following acknowledgement:\n *    \"This product includes cryptographic software written by\n *     Eric Young (eay@cryptsoft.com)\"\n *    The word 'cryptographic' can be left out if the rouines from the library\n *    being used are not cryptographic related :-).\n * 4. If you include any Windows specific code (or a derivative thereof) from\n *    the apps directory (application code) you must include an acknowledgement:\n *    \"This product includes software written by Tim Hudson (tjh@cryptsoft.com)\"\n *\n * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n * SUCH DAMAGE.\n *\n * The licence and distribution terms for any publically available version or\n * derivative of this code cannot be changed.  i.e. this code cannot simply be\n * copied and put under another distribution licence\n * [including the GNU Public Licence.]\n */\n\n#ifndef HEADER_RAND_H\n# define HEADER_RAND_H\n\n# include <stdlib.h>\n# include <openssl/ossl_typ.h>\n# include <openssl/e_os2.h>\n\n# if defined(OPENSSL_SYS_WINDOWS)\n#  include <windows.h>\n# endif\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n# if defined(OPENSSL_FIPS)\n#  define FIPS_RAND_SIZE_T size_t\n# endif\n\n/* Already defined in ossl_typ.h */\n/* typedef struct rand_meth_st RAND_METHOD; */\n\nstruct rand_meth_st {\n    void (*seed) (const void *buf, int num);\n    int (*bytes) (unsigned char *buf, int num);\n    void (*cleanup) (void);\n    void (*add) (const void *buf, int num, double entropy);\n    int (*pseudorand) (unsigned char *buf, int num);\n    int (*status) (void);\n};\n\n# ifdef BN_DEBUG\nextern int rand_predictable;\n# endif\n\nint RAND_set_rand_method(const RAND_METHOD *meth);\nconst RAND_METHOD *RAND_get_rand_method(void);\n# ifndef OPENSSL_NO_ENGINE\nint RAND_set_rand_engine(ENGINE *engine);\n# endif\nRAND_METHOD *RAND_SSLeay(void);\nvoid RAND_cleanup(void);\nint RAND_bytes(unsigned char *buf, int num);\nint RAND_pseudo_bytes(unsigned char *buf, int num);\nvoid RAND_seed(const void *buf, int num);\nvoid RAND_add(const void *buf, int num, double entropy);\nint RAND_load_file(const char *file, long max_bytes);\nint RAND_write_file(const char *file);\nconst char *RAND_file_name(char *file, size_t num);\nint RAND_status(void);\nint RAND_query_egd_bytes(const char *path, unsigned char *buf, int bytes);\nint RAND_egd(const char *path);\nint RAND_egd_bytes(const char *path, int bytes);\nint RAND_poll(void);\n\n# if defined(OPENSSL_SYS_WINDOWS) || defined(OPENSSL_SYS_WIN32)\n\nvoid RAND_screen(void);\nint RAND_event(UINT, WPARAM, LPARAM);\n\n# endif\n\n# ifdef OPENSSL_FIPS\nvoid RAND_set_fips_drbg_type(int type, int flags);\nint RAND_init_fips(void);\n# endif\n\n/* BEGIN ERROR CODES */\n/*\n * The following lines are auto generated by the script mkerr.pl. Any changes\n * made after this point may be overwritten when the script is next run.\n */\nvoid ERR_load_RAND_strings(void);\n\n/* Error codes for the RAND functions. */\n\n/* Function codes. */\n# define RAND_F_RAND_GET_RAND_METHOD                      101\n# define RAND_F_RAND_INIT_FIPS                            102\n# define RAND_F_SSLEAY_RAND_BYTES                         100\n\n/* Reason codes. */\n# define RAND_R_DUAL_EC_DRBG_DISABLED                     104\n# define RAND_R_ERROR_INITIALISING_DRBG                   102\n# define RAND_R_ERROR_INSTANTIATING_DRBG                  103\n# define RAND_R_NO_FIPS_RANDOM_METHOD_SET                 101\n# define RAND_R_PRNG_NOT_SEEDED                           100\n\n#ifdef  __cplusplus\n}\n#endif\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/x86/include/openssl/rc4.h",
    "content": "/* crypto/rc4/rc4.h */\n/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)\n * All rights reserved.\n *\n * This package is an SSL implementation written\n * by Eric Young (eay@cryptsoft.com).\n * The implementation was written so as to conform with Netscapes SSL.\n *\n * This library is free for commercial and non-commercial use as long as\n * the following conditions are aheared to.  The following conditions\n * apply to all code found in this distribution, be it the RC4, RSA,\n * lhash, DES, etc., code; not just the SSL code.  The SSL documentation\n * included with this distribution is covered by the same copyright terms\n * except that the holder is Tim Hudson (tjh@cryptsoft.com).\n *\n * Copyright remains Eric Young's, and as such any Copyright notices in\n * the code are not to be removed.\n * If this package is used in a product, Eric Young should be given attribution\n * as the author of the parts of the library used.\n * This can be in the form of a textual message at program startup or\n * in documentation (online or textual) provided with the package.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the copyright\n *    notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in the\n *    documentation and/or other materials provided with the distribution.\n * 3. All advertising materials mentioning features or use of this software\n *    must display the following acknowledgement:\n *    \"This product includes cryptographic software written by\n *     Eric Young (eay@cryptsoft.com)\"\n *    The word 'cryptographic' can be left out if the rouines from the library\n *    being used are not cryptographic related :-).\n * 4. If you include any Windows specific code (or a derivative thereof) from\n *    the apps directory (application code) you must include an acknowledgement:\n *    \"This product includes software written by Tim Hudson (tjh@cryptsoft.com)\"\n *\n * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n * SUCH DAMAGE.\n *\n * The licence and distribution terms for any publically available version or\n * derivative of this code cannot be changed.  i.e. this code cannot simply be\n * copied and put under another distribution licence\n * [including the GNU Public Licence.]\n */\n\n#ifndef HEADER_RC4_H\n# define HEADER_RC4_H\n\n# include <openssl/opensslconf.h>/* OPENSSL_NO_RC4, RC4_INT */\n# ifdef OPENSSL_NO_RC4\n#  error RC4 is disabled.\n# endif\n\n# include <stddef.h>\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\ntypedef struct rc4_key_st {\n    RC4_INT x, y;\n    RC4_INT data[256];\n} RC4_KEY;\n\nconst char *RC4_options(void);\nvoid RC4_set_key(RC4_KEY *key, int len, const unsigned char *data);\nvoid private_RC4_set_key(RC4_KEY *key, int len, const unsigned char *data);\nvoid RC4(RC4_KEY *key, size_t len, const unsigned char *indata,\n         unsigned char *outdata);\n\n#ifdef  __cplusplus\n}\n#endif\n\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/x86/include/openssl/ripemd.h",
    "content": "/* crypto/ripemd/ripemd.h */\n/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)\n * All rights reserved.\n *\n * This package is an SSL implementation written\n * by Eric Young (eay@cryptsoft.com).\n * The implementation was written so as to conform with Netscapes SSL.\n *\n * This library is free for commercial and non-commercial use as long as\n * the following conditions are aheared to.  The following conditions\n * apply to all code found in this distribution, be it the RC4, RSA,\n * lhash, DES, etc., code; not just the SSL code.  The SSL documentation\n * included with this distribution is covered by the same copyright terms\n * except that the holder is Tim Hudson (tjh@cryptsoft.com).\n *\n * Copyright remains Eric Young's, and as such any Copyright notices in\n * the code are not to be removed.\n * If this package is used in a product, Eric Young should be given attribution\n * as the author of the parts of the library used.\n * This can be in the form of a textual message at program startup or\n * in documentation (online or textual) provided with the package.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the copyright\n *    notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in the\n *    documentation and/or other materials provided with the distribution.\n * 3. All advertising materials mentioning features or use of this software\n *    must display the following acknowledgement:\n *    \"This product includes cryptographic software written by\n *     Eric Young (eay@cryptsoft.com)\"\n *    The word 'cryptographic' can be left out if the rouines from the library\n *    being used are not cryptographic related :-).\n * 4. If you include any Windows specific code (or a derivative thereof) from\n *    the apps directory (application code) you must include an acknowledgement:\n *    \"This product includes software written by Tim Hudson (tjh@cryptsoft.com)\"\n *\n * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n * SUCH DAMAGE.\n *\n * The licence and distribution terms for any publically available version or\n * derivative of this code cannot be changed.  i.e. this code cannot simply be\n * copied and put under another distribution licence\n * [including the GNU Public Licence.]\n */\n\n#ifndef HEADER_RIPEMD_H\n# define HEADER_RIPEMD_H\n\n# include <openssl/e_os2.h>\n# include <stddef.h>\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n# ifdef OPENSSL_NO_RIPEMD\n#  error RIPEMD is disabled.\n# endif\n\n# if defined(__LP32__)\n#  define RIPEMD160_LONG unsigned long\n# elif defined(OPENSSL_SYS_CRAY) || defined(__ILP64__)\n#  define RIPEMD160_LONG unsigned long\n#  define RIPEMD160_LONG_LOG2 3\n# else\n#  define RIPEMD160_LONG unsigned int\n# endif\n\n# define RIPEMD160_CBLOCK        64\n# define RIPEMD160_LBLOCK        (RIPEMD160_CBLOCK/4)\n# define RIPEMD160_DIGEST_LENGTH 20\n\ntypedef struct RIPEMD160state_st {\n    RIPEMD160_LONG A, B, C, D, E;\n    RIPEMD160_LONG Nl, Nh;\n    RIPEMD160_LONG data[RIPEMD160_LBLOCK];\n    unsigned int num;\n} RIPEMD160_CTX;\n\n# ifdef OPENSSL_FIPS\nint private_RIPEMD160_Init(RIPEMD160_CTX *c);\n# endif\nint RIPEMD160_Init(RIPEMD160_CTX *c);\nint RIPEMD160_Update(RIPEMD160_CTX *c, const void *data, size_t len);\nint RIPEMD160_Final(unsigned char *md, RIPEMD160_CTX *c);\nunsigned char *RIPEMD160(const unsigned char *d, size_t n, unsigned char *md);\nvoid RIPEMD160_Transform(RIPEMD160_CTX *c, const unsigned char *b);\n#ifdef  __cplusplus\n}\n#endif\n\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/x86/include/openssl/rsa.h",
    "content": "/* crypto/rsa/rsa.h */\n/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)\n * All rights reserved.\n *\n * This package is an SSL implementation written\n * by Eric Young (eay@cryptsoft.com).\n * The implementation was written so as to conform with Netscapes SSL.\n *\n * This library is free for commercial and non-commercial use as long as\n * the following conditions are aheared to.  The following conditions\n * apply to all code found in this distribution, be it the RC4, RSA,\n * lhash, DES, etc., code; not just the SSL code.  The SSL documentation\n * included with this distribution is covered by the same copyright terms\n * except that the holder is Tim Hudson (tjh@cryptsoft.com).\n *\n * Copyright remains Eric Young's, and as such any Copyright notices in\n * the code are not to be removed.\n * If this package is used in a product, Eric Young should be given attribution\n * as the author of the parts of the library used.\n * This can be in the form of a textual message at program startup or\n * in documentation (online or textual) provided with the package.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the copyright\n *    notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in the\n *    documentation and/or other materials provided with the distribution.\n * 3. All advertising materials mentioning features or use of this software\n *    must display the following acknowledgement:\n *    \"This product includes cryptographic software written by\n *     Eric Young (eay@cryptsoft.com)\"\n *    The word 'cryptographic' can be left out if the rouines from the library\n *    being used are not cryptographic related :-).\n * 4. If you include any Windows specific code (or a derivative thereof) from\n *    the apps directory (application code) you must include an acknowledgement:\n *    \"This product includes software written by Tim Hudson (tjh@cryptsoft.com)\"\n *\n * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n * SUCH DAMAGE.\n *\n * The licence and distribution terms for any publically available version or\n * derivative of this code cannot be changed.  i.e. this code cannot simply be\n * copied and put under another distribution licence\n * [including the GNU Public Licence.]\n */\n\n#ifndef HEADER_RSA_H\n# define HEADER_RSA_H\n\n# include <openssl/asn1.h>\n\n# ifndef OPENSSL_NO_BIO\n#  include <openssl/bio.h>\n# endif\n# include <openssl/crypto.h>\n# include <openssl/ossl_typ.h>\n# ifndef OPENSSL_NO_DEPRECATED\n#  include <openssl/bn.h>\n# endif\n\n# ifdef OPENSSL_NO_RSA\n#  error RSA is disabled.\n# endif\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n/* Declared already in ossl_typ.h */\n/* typedef struct rsa_st RSA; */\n/* typedef struct rsa_meth_st RSA_METHOD; */\n\nstruct rsa_meth_st {\n    const char *name;\n    int (*rsa_pub_enc) (int flen, const unsigned char *from,\n                        unsigned char *to, RSA *rsa, int padding);\n    int (*rsa_pub_dec) (int flen, const unsigned char *from,\n                        unsigned char *to, RSA *rsa, int padding);\n    int (*rsa_priv_enc) (int flen, const unsigned char *from,\n                         unsigned char *to, RSA *rsa, int padding);\n    int (*rsa_priv_dec) (int flen, const unsigned char *from,\n                         unsigned char *to, RSA *rsa, int padding);\n    /* Can be null */\n    int (*rsa_mod_exp) (BIGNUM *r0, const BIGNUM *I, RSA *rsa, BN_CTX *ctx);\n    /* Can be null */\n    int (*bn_mod_exp) (BIGNUM *r, const BIGNUM *a, const BIGNUM *p,\n                       const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx);\n    /* called at new */\n    int (*init) (RSA *rsa);\n    /* called at free */\n    int (*finish) (RSA *rsa);\n    /* RSA_METHOD_FLAG_* things */\n    int flags;\n    /* may be needed! */\n    char *app_data;\n    /*\n     * New sign and verify functions: some libraries don't allow arbitrary\n     * data to be signed/verified: this allows them to be used. Note: for\n     * this to work the RSA_public_decrypt() and RSA_private_encrypt() should\n     * *NOT* be used RSA_sign(), RSA_verify() should be used instead. Note:\n     * for backwards compatibility this functionality is only enabled if the\n     * RSA_FLAG_SIGN_VER option is set in 'flags'.\n     */\n    int (*rsa_sign) (int type,\n                     const unsigned char *m, unsigned int m_length,\n                     unsigned char *sigret, unsigned int *siglen,\n                     const RSA *rsa);\n    int (*rsa_verify) (int dtype, const unsigned char *m,\n                       unsigned int m_length, const unsigned char *sigbuf,\n                       unsigned int siglen, const RSA *rsa);\n    /*\n     * If this callback is NULL, the builtin software RSA key-gen will be\n     * used. This is for behavioural compatibility whilst the code gets\n     * rewired, but one day it would be nice to assume there are no such\n     * things as \"builtin software\" implementations.\n     */\n    int (*rsa_keygen) (RSA *rsa, int bits, BIGNUM *e, BN_GENCB *cb);\n};\n\nstruct rsa_st {\n    /*\n     * The first parameter is used to pickup errors where this is passed\n     * instead of aEVP_PKEY, it is set to 0\n     */\n    int pad;\n    long version;\n    const RSA_METHOD *meth;\n    /* functional reference if 'meth' is ENGINE-provided */\n    ENGINE *engine;\n    BIGNUM *n;\n    BIGNUM *e;\n    BIGNUM *d;\n    BIGNUM *p;\n    BIGNUM *q;\n    BIGNUM *dmp1;\n    BIGNUM *dmq1;\n    BIGNUM *iqmp;\n    /* be careful using this if the RSA structure is shared */\n    CRYPTO_EX_DATA ex_data;\n    int references;\n    int flags;\n    /* Used to cache montgomery values */\n    BN_MONT_CTX *_method_mod_n;\n    BN_MONT_CTX *_method_mod_p;\n    BN_MONT_CTX *_method_mod_q;\n    /*\n     * all BIGNUM values are actually in the following data, if it is not\n     * NULL\n     */\n    char *bignum_data;\n    BN_BLINDING *blinding;\n    BN_BLINDING *mt_blinding;\n};\n\n# ifndef OPENSSL_RSA_MAX_MODULUS_BITS\n#  define OPENSSL_RSA_MAX_MODULUS_BITS   16384\n# endif\n\n# ifndef OPENSSL_RSA_SMALL_MODULUS_BITS\n#  define OPENSSL_RSA_SMALL_MODULUS_BITS 3072\n# endif\n# ifndef OPENSSL_RSA_MAX_PUBEXP_BITS\n\n/* exponent limit enforced for \"large\" modulus only */\n#  define OPENSSL_RSA_MAX_PUBEXP_BITS    64\n# endif\n\n# define RSA_3   0x3L\n# define RSA_F4  0x10001L\n\n# define RSA_METHOD_FLAG_NO_CHECK        0x0001/* don't check pub/private\n                                                * match */\n\n# define RSA_FLAG_CACHE_PUBLIC           0x0002\n# define RSA_FLAG_CACHE_PRIVATE          0x0004\n# define RSA_FLAG_BLINDING               0x0008\n# define RSA_FLAG_THREAD_SAFE            0x0010\n/*\n * This flag means the private key operations will be handled by rsa_mod_exp\n * and that they do not depend on the private key components being present:\n * for example a key stored in external hardware. Without this flag\n * bn_mod_exp gets called when private key components are absent.\n */\n# define RSA_FLAG_EXT_PKEY               0x0020\n\n/*\n * This flag in the RSA_METHOD enables the new rsa_sign, rsa_verify\n * functions.\n */\n# define RSA_FLAG_SIGN_VER               0x0040\n\n/*\n * new with 0.9.6j and 0.9.7b; the built-in\n * RSA implementation now uses blinding by\n * default (ignoring RSA_FLAG_BLINDING),\n * but other engines might not need it\n */\n# define RSA_FLAG_NO_BLINDING            0x0080\n/*\n * new with 0.9.8f; the built-in RSA\n * implementation now uses constant time\n * operations by default in private key operations,\n * e.g., constant time modular exponentiation,\n * modular inverse without leaking branches,\n * division without leaking branches. This\n * flag disables these constant time\n * operations and results in faster RSA\n * private key operations.\n */\n# define RSA_FLAG_NO_CONSTTIME           0x0100\n# ifdef OPENSSL_USE_DEPRECATED\n/* deprecated name for the flag*/\n/*\n * new with 0.9.7h; the built-in RSA\n * implementation now uses constant time\n * modular exponentiation for secret exponents\n * by default. This flag causes the\n * faster variable sliding window method to\n * be used for all exponents.\n */\n#  define RSA_FLAG_NO_EXP_CONSTTIME RSA_FLAG_NO_CONSTTIME\n# endif\n\n# define EVP_PKEY_CTX_set_rsa_padding(ctx, pad) \\\n        EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_RSA, -1, EVP_PKEY_CTRL_RSA_PADDING, \\\n                                pad, NULL)\n\n# define EVP_PKEY_CTX_get_rsa_padding(ctx, ppad) \\\n        EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_RSA, -1, \\\n                                EVP_PKEY_CTRL_GET_RSA_PADDING, 0, ppad)\n\n# define EVP_PKEY_CTX_set_rsa_pss_saltlen(ctx, len) \\\n        EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_RSA, \\\n                                (EVP_PKEY_OP_SIGN|EVP_PKEY_OP_VERIFY), \\\n                                EVP_PKEY_CTRL_RSA_PSS_SALTLEN, \\\n                                len, NULL)\n\n# define EVP_PKEY_CTX_get_rsa_pss_saltlen(ctx, plen) \\\n        EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_RSA, \\\n                                (EVP_PKEY_OP_SIGN|EVP_PKEY_OP_VERIFY), \\\n                                EVP_PKEY_CTRL_GET_RSA_PSS_SALTLEN, \\\n                                0, plen)\n\n# define EVP_PKEY_CTX_set_rsa_keygen_bits(ctx, bits) \\\n        EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_RSA, EVP_PKEY_OP_KEYGEN, \\\n                                EVP_PKEY_CTRL_RSA_KEYGEN_BITS, bits, NULL)\n\n# define EVP_PKEY_CTX_set_rsa_keygen_pubexp(ctx, pubexp) \\\n        EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_RSA, EVP_PKEY_OP_KEYGEN, \\\n                                EVP_PKEY_CTRL_RSA_KEYGEN_PUBEXP, 0, pubexp)\n\n# define  EVP_PKEY_CTX_set_rsa_mgf1_md(ctx, md)  \\\n                EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_RSA, \\\n                        EVP_PKEY_OP_TYPE_SIG | EVP_PKEY_OP_TYPE_CRYPT, \\\n                                EVP_PKEY_CTRL_RSA_MGF1_MD, 0, (void *)md)\n\n# define  EVP_PKEY_CTX_set_rsa_oaep_md(ctx, md)  \\\n                EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_RSA, EVP_PKEY_OP_TYPE_CRYPT,  \\\n                                EVP_PKEY_CTRL_RSA_OAEP_MD, 0, (void *)md)\n\n# define  EVP_PKEY_CTX_get_rsa_mgf1_md(ctx, pmd) \\\n                EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_RSA, \\\n                        EVP_PKEY_OP_TYPE_SIG | EVP_PKEY_OP_TYPE_CRYPT, \\\n                                EVP_PKEY_CTRL_GET_RSA_MGF1_MD, 0, (void *)pmd)\n\n# define  EVP_PKEY_CTX_get_rsa_oaep_md(ctx, pmd) \\\n                EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_RSA, EVP_PKEY_OP_TYPE_CRYPT,  \\\n                                EVP_PKEY_CTRL_GET_RSA_OAEP_MD, 0, (void *)pmd)\n\n# define  EVP_PKEY_CTX_set0_rsa_oaep_label(ctx, l, llen) \\\n                EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_RSA, EVP_PKEY_OP_TYPE_CRYPT,  \\\n                                EVP_PKEY_CTRL_RSA_OAEP_LABEL, llen, (void *)l)\n\n# define  EVP_PKEY_CTX_get0_rsa_oaep_label(ctx, l)       \\\n                EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_RSA, EVP_PKEY_OP_TYPE_CRYPT,  \\\n                                EVP_PKEY_CTRL_GET_RSA_OAEP_LABEL, 0, (void *)l)\n\n# define EVP_PKEY_CTRL_RSA_PADDING       (EVP_PKEY_ALG_CTRL + 1)\n# define EVP_PKEY_CTRL_RSA_PSS_SALTLEN   (EVP_PKEY_ALG_CTRL + 2)\n\n# define EVP_PKEY_CTRL_RSA_KEYGEN_BITS   (EVP_PKEY_ALG_CTRL + 3)\n# define EVP_PKEY_CTRL_RSA_KEYGEN_PUBEXP (EVP_PKEY_ALG_CTRL + 4)\n# define EVP_PKEY_CTRL_RSA_MGF1_MD       (EVP_PKEY_ALG_CTRL + 5)\n\n# define EVP_PKEY_CTRL_GET_RSA_PADDING           (EVP_PKEY_ALG_CTRL + 6)\n# define EVP_PKEY_CTRL_GET_RSA_PSS_SALTLEN       (EVP_PKEY_ALG_CTRL + 7)\n# define EVP_PKEY_CTRL_GET_RSA_MGF1_MD           (EVP_PKEY_ALG_CTRL + 8)\n\n# define EVP_PKEY_CTRL_RSA_OAEP_MD       (EVP_PKEY_ALG_CTRL + 9)\n# define EVP_PKEY_CTRL_RSA_OAEP_LABEL    (EVP_PKEY_ALG_CTRL + 10)\n\n# define EVP_PKEY_CTRL_GET_RSA_OAEP_MD   (EVP_PKEY_ALG_CTRL + 11)\n# define EVP_PKEY_CTRL_GET_RSA_OAEP_LABEL (EVP_PKEY_ALG_CTRL + 12)\n\n# define RSA_PKCS1_PADDING       1\n# define RSA_SSLV23_PADDING      2\n# define RSA_NO_PADDING          3\n# define RSA_PKCS1_OAEP_PADDING  4\n# define RSA_X931_PADDING        5\n/* EVP_PKEY_ only */\n# define RSA_PKCS1_PSS_PADDING   6\n\n# define RSA_PKCS1_PADDING_SIZE  11\n\n# define RSA_set_app_data(s,arg)         RSA_set_ex_data(s,0,arg)\n# define RSA_get_app_data(s)             RSA_get_ex_data(s,0)\n\nRSA *RSA_new(void);\nRSA *RSA_new_method(ENGINE *engine);\nint RSA_size(const RSA *rsa);\n\n/* Deprecated version */\n# ifndef OPENSSL_NO_DEPRECATED\nRSA *RSA_generate_key(int bits, unsigned long e, void\n                       (*callback) (int, int, void *), void *cb_arg);\n# endif                         /* !defined(OPENSSL_NO_DEPRECATED) */\n\n/* New version */\nint RSA_generate_key_ex(RSA *rsa, int bits, BIGNUM *e, BN_GENCB *cb);\n\nint RSA_check_key(const RSA *);\n        /* next 4 return -1 on error */\nint RSA_public_encrypt(int flen, const unsigned char *from,\n                       unsigned char *to, RSA *rsa, int padding);\nint RSA_private_encrypt(int flen, const unsigned char *from,\n                        unsigned char *to, RSA *rsa, int padding);\nint RSA_public_decrypt(int flen, const unsigned char *from,\n                       unsigned char *to, RSA *rsa, int padding);\nint RSA_private_decrypt(int flen, const unsigned char *from,\n                        unsigned char *to, RSA *rsa, int padding);\nvoid RSA_free(RSA *r);\n/* \"up\" the RSA object's reference count */\nint RSA_up_ref(RSA *r);\n\nint RSA_flags(const RSA *r);\n\nvoid RSA_set_default_method(const RSA_METHOD *meth);\nconst RSA_METHOD *RSA_get_default_method(void);\nconst RSA_METHOD *RSA_get_method(const RSA *rsa);\nint RSA_set_method(RSA *rsa, const RSA_METHOD *meth);\n\n/* This function needs the memory locking malloc callbacks to be installed */\nint RSA_memory_lock(RSA *r);\n\n/* these are the actual SSLeay RSA functions */\nconst RSA_METHOD *RSA_PKCS1_SSLeay(void);\n\nconst RSA_METHOD *RSA_null_method(void);\n\nDECLARE_ASN1_ENCODE_FUNCTIONS_const(RSA, RSAPublicKey)\nDECLARE_ASN1_ENCODE_FUNCTIONS_const(RSA, RSAPrivateKey)\n\ntypedef struct rsa_pss_params_st {\n    X509_ALGOR *hashAlgorithm;\n    X509_ALGOR *maskGenAlgorithm;\n    ASN1_INTEGER *saltLength;\n    ASN1_INTEGER *trailerField;\n} RSA_PSS_PARAMS;\n\nDECLARE_ASN1_FUNCTIONS(RSA_PSS_PARAMS)\n\ntypedef struct rsa_oaep_params_st {\n    X509_ALGOR *hashFunc;\n    X509_ALGOR *maskGenFunc;\n    X509_ALGOR *pSourceFunc;\n} RSA_OAEP_PARAMS;\n\nDECLARE_ASN1_FUNCTIONS(RSA_OAEP_PARAMS)\n\n# ifndef OPENSSL_NO_FP_API\nint RSA_print_fp(FILE *fp, const RSA *r, int offset);\n# endif\n\n# ifndef OPENSSL_NO_BIO\nint RSA_print(BIO *bp, const RSA *r, int offset);\n# endif\n\n# ifndef OPENSSL_NO_RC4\nint i2d_RSA_NET(const RSA *a, unsigned char **pp,\n                int (*cb) (char *buf, int len, const char *prompt,\n                           int verify), int sgckey);\nRSA *d2i_RSA_NET(RSA **a, const unsigned char **pp, long length,\n                 int (*cb) (char *buf, int len, const char *prompt,\n                            int verify), int sgckey);\n\nint i2d_Netscape_RSA(const RSA *a, unsigned char **pp,\n                     int (*cb) (char *buf, int len, const char *prompt,\n                                int verify));\nRSA *d2i_Netscape_RSA(RSA **a, const unsigned char **pp, long length,\n                      int (*cb) (char *buf, int len, const char *prompt,\n                                 int verify));\n# endif\n\n/*\n * The following 2 functions sign and verify a X509_SIG ASN1 object inside\n * PKCS#1 padded RSA encryption\n */\nint RSA_sign(int type, const unsigned char *m, unsigned int m_length,\n             unsigned char *sigret, unsigned int *siglen, RSA *rsa);\nint RSA_verify(int type, const unsigned char *m, unsigned int m_length,\n               const unsigned char *sigbuf, unsigned int siglen, RSA *rsa);\n\n/*\n * The following 2 function sign and verify a ASN1_OCTET_STRING object inside\n * PKCS#1 padded RSA encryption\n */\nint RSA_sign_ASN1_OCTET_STRING(int type,\n                               const unsigned char *m, unsigned int m_length,\n                               unsigned char *sigret, unsigned int *siglen,\n                               RSA *rsa);\nint RSA_verify_ASN1_OCTET_STRING(int type, const unsigned char *m,\n                                 unsigned int m_length, unsigned char *sigbuf,\n                                 unsigned int siglen, RSA *rsa);\n\nint RSA_blinding_on(RSA *rsa, BN_CTX *ctx);\nvoid RSA_blinding_off(RSA *rsa);\nBN_BLINDING *RSA_setup_blinding(RSA *rsa, BN_CTX *ctx);\n\nint RSA_padding_add_PKCS1_type_1(unsigned char *to, int tlen,\n                                 const unsigned char *f, int fl);\nint RSA_padding_check_PKCS1_type_1(unsigned char *to, int tlen,\n                                   const unsigned char *f, int fl,\n                                   int rsa_len);\nint RSA_padding_add_PKCS1_type_2(unsigned char *to, int tlen,\n                                 const unsigned char *f, int fl);\nint RSA_padding_check_PKCS1_type_2(unsigned char *to, int tlen,\n                                   const unsigned char *f, int fl,\n                                   int rsa_len);\nint PKCS1_MGF1(unsigned char *mask, long len, const unsigned char *seed,\n               long seedlen, const EVP_MD *dgst);\nint RSA_padding_add_PKCS1_OAEP(unsigned char *to, int tlen,\n                               const unsigned char *f, int fl,\n                               const unsigned char *p, int pl);\nint RSA_padding_check_PKCS1_OAEP(unsigned char *to, int tlen,\n                                 const unsigned char *f, int fl, int rsa_len,\n                                 const unsigned char *p, int pl);\nint RSA_padding_add_PKCS1_OAEP_mgf1(unsigned char *to, int tlen,\n                                    const unsigned char *from, int flen,\n                                    const unsigned char *param, int plen,\n                                    const EVP_MD *md, const EVP_MD *mgf1md);\nint RSA_padding_check_PKCS1_OAEP_mgf1(unsigned char *to, int tlen,\n                                      const unsigned char *from, int flen,\n                                      int num, const unsigned char *param,\n                                      int plen, const EVP_MD *md,\n                                      const EVP_MD *mgf1md);\nint RSA_padding_add_SSLv23(unsigned char *to, int tlen,\n                           const unsigned char *f, int fl);\nint RSA_padding_check_SSLv23(unsigned char *to, int tlen,\n                             const unsigned char *f, int fl, int rsa_len);\nint RSA_padding_add_none(unsigned char *to, int tlen, const unsigned char *f,\n                         int fl);\nint RSA_padding_check_none(unsigned char *to, int tlen,\n                           const unsigned char *f, int fl, int rsa_len);\nint RSA_padding_add_X931(unsigned char *to, int tlen, const unsigned char *f,\n                         int fl);\nint RSA_padding_check_X931(unsigned char *to, int tlen,\n                           const unsigned char *f, int fl, int rsa_len);\nint RSA_X931_hash_id(int nid);\n\nint RSA_verify_PKCS1_PSS(RSA *rsa, const unsigned char *mHash,\n                         const EVP_MD *Hash, const unsigned char *EM,\n                         int sLen);\nint RSA_padding_add_PKCS1_PSS(RSA *rsa, unsigned char *EM,\n                              const unsigned char *mHash, const EVP_MD *Hash,\n                              int sLen);\n\nint RSA_verify_PKCS1_PSS_mgf1(RSA *rsa, const unsigned char *mHash,\n                              const EVP_MD *Hash, const EVP_MD *mgf1Hash,\n                              const unsigned char *EM, int sLen);\n\nint RSA_padding_add_PKCS1_PSS_mgf1(RSA *rsa, unsigned char *EM,\n                                   const unsigned char *mHash,\n                                   const EVP_MD *Hash, const EVP_MD *mgf1Hash,\n                                   int sLen);\n\nint RSA_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func,\n                         CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func);\nint RSA_set_ex_data(RSA *r, int idx, void *arg);\nvoid *RSA_get_ex_data(const RSA *r, int idx);\n\nRSA *RSAPublicKey_dup(RSA *rsa);\nRSA *RSAPrivateKey_dup(RSA *rsa);\n\n/*\n * If this flag is set the RSA method is FIPS compliant and can be used in\n * FIPS mode. This is set in the validated module method. If an application\n * sets this flag in its own methods it is its responsibility to ensure the\n * result is compliant.\n */\n\n# define RSA_FLAG_FIPS_METHOD                    0x0400\n\n/*\n * If this flag is set the operations normally disabled in FIPS mode are\n * permitted it is then the applications responsibility to ensure that the\n * usage is compliant.\n */\n\n# define RSA_FLAG_NON_FIPS_ALLOW                 0x0400\n/*\n * Application has decided PRNG is good enough to generate a key: don't\n * check.\n */\n# define RSA_FLAG_CHECKED                        0x0800\n\n/* BEGIN ERROR CODES */\n/*\n * The following lines are auto generated by the script mkerr.pl. Any changes\n * made after this point may be overwritten when the script is next run.\n */\nvoid ERR_load_RSA_strings(void);\n\n/* Error codes for the RSA functions. */\n\n/* Function codes. */\n# define RSA_F_CHECK_PADDING_MD                           140\n# define RSA_F_DO_RSA_PRINT                               146\n# define RSA_F_INT_RSA_VERIFY                             145\n# define RSA_F_MEMORY_LOCK                                100\n# define RSA_F_OLD_RSA_PRIV_DECODE                        147\n# define RSA_F_PKEY_RSA_CTRL                              143\n# define RSA_F_PKEY_RSA_CTRL_STR                          144\n# define RSA_F_PKEY_RSA_SIGN                              142\n# define RSA_F_PKEY_RSA_VERIFY                            154\n# define RSA_F_PKEY_RSA_VERIFYRECOVER                     141\n# define RSA_F_RSA_ALGOR_TO_MD                            157\n# define RSA_F_RSA_BUILTIN_KEYGEN                         129\n# define RSA_F_RSA_CHECK_KEY                              123\n# define RSA_F_RSA_CMS_DECRYPT                            158\n# define RSA_F_RSA_EAY_PRIVATE_DECRYPT                    101\n# define RSA_F_RSA_EAY_PRIVATE_ENCRYPT                    102\n# define RSA_F_RSA_EAY_PUBLIC_DECRYPT                     103\n# define RSA_F_RSA_EAY_PUBLIC_ENCRYPT                     104\n# define RSA_F_RSA_GENERATE_KEY                           105\n# define RSA_F_RSA_GENERATE_KEY_EX                        155\n# define RSA_F_RSA_ITEM_VERIFY                            156\n# define RSA_F_RSA_MEMORY_LOCK                            130\n# define RSA_F_RSA_MGF1_TO_MD                             159\n# define RSA_F_RSA_NEW_METHOD                             106\n# define RSA_F_RSA_NULL                                   124\n# define RSA_F_RSA_NULL_MOD_EXP                           131\n# define RSA_F_RSA_NULL_PRIVATE_DECRYPT                   132\n# define RSA_F_RSA_NULL_PRIVATE_ENCRYPT                   133\n# define RSA_F_RSA_NULL_PUBLIC_DECRYPT                    134\n# define RSA_F_RSA_NULL_PUBLIC_ENCRYPT                    135\n# define RSA_F_RSA_PADDING_ADD_NONE                       107\n# define RSA_F_RSA_PADDING_ADD_PKCS1_OAEP                 121\n# define RSA_F_RSA_PADDING_ADD_PKCS1_OAEP_MGF1            160\n# define RSA_F_RSA_PADDING_ADD_PKCS1_PSS                  125\n# define RSA_F_RSA_PADDING_ADD_PKCS1_PSS_MGF1             148\n# define RSA_F_RSA_PADDING_ADD_PKCS1_TYPE_1               108\n# define RSA_F_RSA_PADDING_ADD_PKCS1_TYPE_2               109\n# define RSA_F_RSA_PADDING_ADD_SSLV23                     110\n# define RSA_F_RSA_PADDING_ADD_X931                       127\n# define RSA_F_RSA_PADDING_CHECK_NONE                     111\n# define RSA_F_RSA_PADDING_CHECK_PKCS1_OAEP               122\n# define RSA_F_RSA_PADDING_CHECK_PKCS1_OAEP_MGF1          161\n# define RSA_F_RSA_PADDING_CHECK_PKCS1_TYPE_1             112\n# define RSA_F_RSA_PADDING_CHECK_PKCS1_TYPE_2             113\n# define RSA_F_RSA_PADDING_CHECK_SSLV23                   114\n# define RSA_F_RSA_PADDING_CHECK_X931                     128\n# define RSA_F_RSA_PRINT                                  115\n# define RSA_F_RSA_PRINT_FP                               116\n# define RSA_F_RSA_PRIVATE_DECRYPT                        150\n# define RSA_F_RSA_PRIVATE_ENCRYPT                        151\n# define RSA_F_RSA_PRIV_DECODE                            137\n# define RSA_F_RSA_PRIV_ENCODE                            138\n# define RSA_F_RSA_PSS_TO_CTX                             162\n# define RSA_F_RSA_PUBLIC_DECRYPT                         152\n# define RSA_F_RSA_PUBLIC_ENCRYPT                         153\n# define RSA_F_RSA_PUB_DECODE                             139\n# define RSA_F_RSA_SETUP_BLINDING                         136\n# define RSA_F_RSA_SIGN                                   117\n# define RSA_F_RSA_SIGN_ASN1_OCTET_STRING                 118\n# define RSA_F_RSA_VERIFY                                 119\n# define RSA_F_RSA_VERIFY_ASN1_OCTET_STRING               120\n# define RSA_F_RSA_VERIFY_PKCS1_PSS                       126\n# define RSA_F_RSA_VERIFY_PKCS1_PSS_MGF1                  149\n\n/* Reason codes. */\n# define RSA_R_ALGORITHM_MISMATCH                         100\n# define RSA_R_BAD_E_VALUE                                101\n# define RSA_R_BAD_FIXED_HEADER_DECRYPT                   102\n# define RSA_R_BAD_PAD_BYTE_COUNT                         103\n# define RSA_R_BAD_SIGNATURE                              104\n# define RSA_R_BLOCK_TYPE_IS_NOT_01                       106\n# define RSA_R_BLOCK_TYPE_IS_NOT_02                       107\n# define RSA_R_DATA_GREATER_THAN_MOD_LEN                  108\n# define RSA_R_DATA_TOO_LARGE                             109\n# define RSA_R_DATA_TOO_LARGE_FOR_KEY_SIZE                110\n# define RSA_R_DATA_TOO_LARGE_FOR_MODULUS                 132\n# define RSA_R_DATA_TOO_SMALL                             111\n# define RSA_R_DATA_TOO_SMALL_FOR_KEY_SIZE                122\n# define RSA_R_DIGEST_DOES_NOT_MATCH                      166\n# define RSA_R_DIGEST_TOO_BIG_FOR_RSA_KEY                 112\n# define RSA_R_DMP1_NOT_CONGRUENT_TO_D                    124\n# define RSA_R_DMQ1_NOT_CONGRUENT_TO_D                    125\n# define RSA_R_D_E_NOT_CONGRUENT_TO_1                     123\n# define RSA_R_FIRST_OCTET_INVALID                        133\n# define RSA_R_ILLEGAL_OR_UNSUPPORTED_PADDING_MODE        144\n# define RSA_R_INVALID_DIGEST                             160\n# define RSA_R_INVALID_DIGEST_LENGTH                      143\n# define RSA_R_INVALID_HEADER                             137\n# define RSA_R_INVALID_KEYBITS                            145\n# define RSA_R_INVALID_LABEL                              161\n# define RSA_R_INVALID_MESSAGE_LENGTH                     131\n# define RSA_R_INVALID_MGF1_MD                            156\n# define RSA_R_INVALID_OAEP_PARAMETERS                    162\n# define RSA_R_INVALID_PADDING                            138\n# define RSA_R_INVALID_PADDING_MODE                       141\n# define RSA_R_INVALID_PSS_PARAMETERS                     149\n# define RSA_R_INVALID_PSS_SALTLEN                        146\n# define RSA_R_INVALID_SALT_LENGTH                        150\n# define RSA_R_INVALID_TRAILER                            139\n# define RSA_R_INVALID_X931_DIGEST                        142\n# define RSA_R_IQMP_NOT_INVERSE_OF_Q                      126\n# define RSA_R_KEY_SIZE_TOO_SMALL                         120\n# define RSA_R_LAST_OCTET_INVALID                         134\n# define RSA_R_MODULUS_TOO_LARGE                          105\n# define RSA_R_NON_FIPS_RSA_METHOD                        157\n# define RSA_R_NO_PUBLIC_EXPONENT                         140\n# define RSA_R_NULL_BEFORE_BLOCK_MISSING                  113\n# define RSA_R_N_DOES_NOT_EQUAL_P_Q                       127\n# define RSA_R_OAEP_DECODING_ERROR                        121\n# define RSA_R_OPERATION_NOT_ALLOWED_IN_FIPS_MODE         158\n# define RSA_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE   148\n# define RSA_R_PADDING_CHECK_FAILED                       114\n# define RSA_R_PKCS_DECODING_ERROR                        159\n# define RSA_R_P_NOT_PRIME                                128\n# define RSA_R_Q_NOT_PRIME                                129\n# define RSA_R_RSA_OPERATIONS_NOT_SUPPORTED               130\n# define RSA_R_SLEN_CHECK_FAILED                          136\n# define RSA_R_SLEN_RECOVERY_FAILED                       135\n# define RSA_R_SSLV3_ROLLBACK_ATTACK                      115\n# define RSA_R_THE_ASN1_OBJECT_IDENTIFIER_IS_NOT_KNOWN_FOR_THIS_MD 116\n# define RSA_R_UNKNOWN_ALGORITHM_TYPE                     117\n# define RSA_R_UNKNOWN_DIGEST                             163\n# define RSA_R_UNKNOWN_MASK_DIGEST                        151\n# define RSA_R_UNKNOWN_PADDING_TYPE                       118\n# define RSA_R_UNKNOWN_PSS_DIGEST                         152\n# define RSA_R_UNSUPPORTED_ENCRYPTION_TYPE                164\n# define RSA_R_UNSUPPORTED_LABEL_SOURCE                   165\n# define RSA_R_UNSUPPORTED_MASK_ALGORITHM                 153\n# define RSA_R_UNSUPPORTED_MASK_PARAMETER                 154\n# define RSA_R_UNSUPPORTED_SIGNATURE_TYPE                 155\n# define RSA_R_VALUE_MISSING                              147\n# define RSA_R_WRONG_SIGNATURE_LENGTH                     119\n\n#ifdef  __cplusplus\n}\n#endif\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/x86/include/openssl/safestack.h",
    "content": "/* ====================================================================\n * Copyright (c) 1999 The OpenSSL Project.  All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n *\n * 1. Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n *\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in\n *    the documentation and/or other materials provided with the\n *    distribution.\n *\n * 3. All advertising materials mentioning features or use of this\n *    software must display the following acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit. (http://www.openssl.org/)\"\n *\n * 4. The names \"OpenSSL Toolkit\" and \"OpenSSL Project\" must not be used to\n *    endorse or promote products derived from this software without\n *    prior written permission. For written permission, please contact\n *    openssl-core@openssl.org.\n *\n * 5. Products derived from this software may not be called \"OpenSSL\"\n *    nor may \"OpenSSL\" appear in their names without prior written\n *    permission of the OpenSSL Project.\n *\n * 6. Redistributions of any form whatsoever must retain the following\n *    acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit (http://www.openssl.org/)\"\n *\n * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY\n * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\n * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR\n * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\n * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,\n * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED\n * OF THE POSSIBILITY OF SUCH DAMAGE.\n * ====================================================================\n *\n * This product includes cryptographic software written by Eric Young\n * (eay@cryptsoft.com).  This product includes software written by Tim\n * Hudson (tjh@cryptsoft.com).\n *\n */\n\n#ifndef HEADER_SAFESTACK_H\n# define HEADER_SAFESTACK_H\n\n# include <openssl/stack.h>\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n# ifndef CHECKED_PTR_OF\n#  define CHECKED_PTR_OF(type, p) \\\n    ((void*) (1 ? p : (type*)0))\n# endif\n\n/*\n * In C++ we get problems because an explicit cast is needed from (void *) we\n * use CHECKED_STACK_OF to ensure the correct type is passed in the macros\n * below.\n */\n\n# define CHECKED_STACK_OF(type, p) \\\n    ((_STACK*) (1 ? p : (STACK_OF(type)*)0))\n\n# define CHECKED_SK_COPY_FUNC(type, p) \\\n    ((void *(*)(void *)) ((1 ? p : (type *(*)(const type *))0)))\n\n# define CHECKED_SK_FREE_FUNC(type, p) \\\n    ((void (*)(void *)) ((1 ? p : (void (*)(type *))0)))\n\n# define CHECKED_SK_CMP_FUNC(type, p) \\\n    ((int (*)(const void *, const void *)) \\\n        ((1 ? p : (int (*)(const type * const *, const type * const *))0)))\n\n# define STACK_OF(type) struct stack_st_##type\n# define PREDECLARE_STACK_OF(type) STACK_OF(type);\n\n# define DECLARE_STACK_OF(type) \\\nSTACK_OF(type) \\\n    { \\\n    _STACK stack; \\\n    };\n# define DECLARE_SPECIAL_STACK_OF(type, type2) \\\nSTACK_OF(type) \\\n    { \\\n    _STACK stack; \\\n    };\n\n/* nada (obsolete in new safestack approach)*/\n# define IMPLEMENT_STACK_OF(type)\n\n/*-\n * Strings are special: normally an lhash entry will point to a single\n * (somewhat) mutable object. In the case of strings:\n *\n * a) Instead of a single char, there is an array of chars, NUL-terminated.\n * b) The string may have be immutable.\n *\n * So, they need their own declarations. Especially important for\n * type-checking tools, such as Deputy.\n *\n * In practice, however, it appears to be hard to have a const\n * string. For now, I'm settling for dealing with the fact it is a\n * string at all.\n */\ntypedef char *OPENSSL_STRING;\n\ntypedef const char *OPENSSL_CSTRING;\n\n/*\n * Confusingly, LHASH_OF(STRING) deals with char ** throughout, but\n * STACK_OF(STRING) is really more like STACK_OF(char), only, as mentioned\n * above, instead of a single char each entry is a NUL-terminated array of\n * chars. So, we have to implement STRING specially for STACK_OF. This is\n * dealt with in the autogenerated macros below.\n */\n\nDECLARE_SPECIAL_STACK_OF(OPENSSL_STRING, char)\n\n/*\n * Similarly, we sometimes use a block of characters, NOT nul-terminated.\n * These should also be distinguished from \"normal\" stacks.\n */\ntypedef void *OPENSSL_BLOCK;\nDECLARE_SPECIAL_STACK_OF(OPENSSL_BLOCK, void)\n\n/*\n * SKM_sk_... stack macros are internal to safestack.h: never use them\n * directly, use sk_<type>_... instead\n */\n# define SKM_sk_new(type, cmp) \\\n        ((STACK_OF(type) *)sk_new(CHECKED_SK_CMP_FUNC(type, cmp)))\n# define SKM_sk_new_null(type) \\\n        ((STACK_OF(type) *)sk_new_null())\n# define SKM_sk_free(type, st) \\\n        sk_free(CHECKED_STACK_OF(type, st))\n# define SKM_sk_num(type, st) \\\n        sk_num(CHECKED_STACK_OF(type, st))\n# define SKM_sk_value(type, st,i) \\\n        ((type *)sk_value(CHECKED_STACK_OF(type, st), i))\n# define SKM_sk_set(type, st,i,val) \\\n        sk_set(CHECKED_STACK_OF(type, st), i, CHECKED_PTR_OF(type, val))\n# define SKM_sk_zero(type, st) \\\n        sk_zero(CHECKED_STACK_OF(type, st))\n# define SKM_sk_push(type, st, val) \\\n        sk_push(CHECKED_STACK_OF(type, st), CHECKED_PTR_OF(type, val))\n# define SKM_sk_unshift(type, st, val) \\\n        sk_unshift(CHECKED_STACK_OF(type, st), CHECKED_PTR_OF(type, val))\n# define SKM_sk_find(type, st, val) \\\n        sk_find(CHECKED_STACK_OF(type, st), CHECKED_PTR_OF(type, val))\n# define SKM_sk_find_ex(type, st, val) \\\n        sk_find_ex(CHECKED_STACK_OF(type, st), \\\n                   CHECKED_PTR_OF(type, val))\n# define SKM_sk_delete(type, st, i) \\\n        (type *)sk_delete(CHECKED_STACK_OF(type, st), i)\n# define SKM_sk_delete_ptr(type, st, ptr) \\\n        (type *)sk_delete_ptr(CHECKED_STACK_OF(type, st), CHECKED_PTR_OF(type, ptr))\n# define SKM_sk_insert(type, st,val, i) \\\n        sk_insert(CHECKED_STACK_OF(type, st), CHECKED_PTR_OF(type, val), i)\n# define SKM_sk_set_cmp_func(type, st, cmp) \\\n        ((int (*)(const type * const *,const type * const *)) \\\n        sk_set_cmp_func(CHECKED_STACK_OF(type, st), CHECKED_SK_CMP_FUNC(type, cmp)))\n# define SKM_sk_dup(type, st) \\\n        (STACK_OF(type) *)sk_dup(CHECKED_STACK_OF(type, st))\n# define SKM_sk_pop_free(type, st, free_func) \\\n        sk_pop_free(CHECKED_STACK_OF(type, st), CHECKED_SK_FREE_FUNC(type, free_func))\n# define SKM_sk_deep_copy(type, st, copy_func, free_func) \\\n        (STACK_OF(type) *)sk_deep_copy(CHECKED_STACK_OF(type, st), CHECKED_SK_COPY_FUNC(type, copy_func), CHECKED_SK_FREE_FUNC(type, free_func))\n# define SKM_sk_shift(type, st) \\\n        (type *)sk_shift(CHECKED_STACK_OF(type, st))\n# define SKM_sk_pop(type, st) \\\n        (type *)sk_pop(CHECKED_STACK_OF(type, st))\n# define SKM_sk_sort(type, st) \\\n        sk_sort(CHECKED_STACK_OF(type, st))\n# define SKM_sk_is_sorted(type, st) \\\n        sk_is_sorted(CHECKED_STACK_OF(type, st))\n# define SKM_ASN1_SET_OF_d2i(type, st, pp, length, d2i_func, free_func, ex_tag, ex_class) \\\n  (STACK_OF(type) *)d2i_ASN1_SET( \\\n                                (STACK_OF(OPENSSL_BLOCK) **)CHECKED_PTR_OF(STACK_OF(type)*, st), \\\n                                pp, length, \\\n                                CHECKED_D2I_OF(type, d2i_func), \\\n                                CHECKED_SK_FREE_FUNC(type, free_func), \\\n                                ex_tag, ex_class)\n# define SKM_ASN1_SET_OF_i2d(type, st, pp, i2d_func, ex_tag, ex_class, is_set) \\\n  i2d_ASN1_SET((STACK_OF(OPENSSL_BLOCK) *)CHECKED_STACK_OF(type, st), pp, \\\n                                CHECKED_I2D_OF(type, i2d_func), \\\n                                ex_tag, ex_class, is_set)\n# define SKM_ASN1_seq_pack(type, st, i2d_func, buf, len) \\\n        ASN1_seq_pack(CHECKED_PTR_OF(STACK_OF(type), st), \\\n                        CHECKED_I2D_OF(type, i2d_func), buf, len)\n# define SKM_ASN1_seq_unpack(type, buf, len, d2i_func, free_func) \\\n        (STACK_OF(type) *)ASN1_seq_unpack(buf, len, CHECKED_D2I_OF(type, d2i_func), CHECKED_SK_FREE_FUNC(type, free_func))\n# define SKM_PKCS12_decrypt_d2i(type, algor, d2i_func, free_func, pass, passlen, oct, seq) \\\n        (STACK_OF(type) *)PKCS12_decrypt_d2i(algor, \\\n                                CHECKED_D2I_OF(type, d2i_func), \\\n                                CHECKED_SK_FREE_FUNC(type, free_func), \\\n                                pass, passlen, oct, seq)\n/*\n * This block of defines is updated by util/mkstack.pl, please do not touch!\n */\n# define sk_ACCESS_DESCRIPTION_new(cmp) SKM_sk_new(ACCESS_DESCRIPTION, (cmp))\n# define sk_ACCESS_DESCRIPTION_new_null() SKM_sk_new_null(ACCESS_DESCRIPTION)\n# define sk_ACCESS_DESCRIPTION_free(st) SKM_sk_free(ACCESS_DESCRIPTION, (st))\n# define sk_ACCESS_DESCRIPTION_num(st) SKM_sk_num(ACCESS_DESCRIPTION, (st))\n# define sk_ACCESS_DESCRIPTION_value(st, i) SKM_sk_value(ACCESS_DESCRIPTION, (st), (i))\n# define sk_ACCESS_DESCRIPTION_set(st, i, val) SKM_sk_set(ACCESS_DESCRIPTION, (st), (i), (val))\n# define sk_ACCESS_DESCRIPTION_zero(st) SKM_sk_zero(ACCESS_DESCRIPTION, (st))\n# define sk_ACCESS_DESCRIPTION_push(st, val) SKM_sk_push(ACCESS_DESCRIPTION, (st), (val))\n# define sk_ACCESS_DESCRIPTION_unshift(st, val) SKM_sk_unshift(ACCESS_DESCRIPTION, (st), (val))\n# define sk_ACCESS_DESCRIPTION_find(st, val) SKM_sk_find(ACCESS_DESCRIPTION, (st), (val))\n# define sk_ACCESS_DESCRIPTION_find_ex(st, val) SKM_sk_find_ex(ACCESS_DESCRIPTION, (st), (val))\n# define sk_ACCESS_DESCRIPTION_delete(st, i) SKM_sk_delete(ACCESS_DESCRIPTION, (st), (i))\n# define sk_ACCESS_DESCRIPTION_delete_ptr(st, ptr) SKM_sk_delete_ptr(ACCESS_DESCRIPTION, (st), (ptr))\n# define sk_ACCESS_DESCRIPTION_insert(st, val, i) SKM_sk_insert(ACCESS_DESCRIPTION, (st), (val), (i))\n# define sk_ACCESS_DESCRIPTION_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(ACCESS_DESCRIPTION, (st), (cmp))\n# define sk_ACCESS_DESCRIPTION_dup(st) SKM_sk_dup(ACCESS_DESCRIPTION, st)\n# define sk_ACCESS_DESCRIPTION_pop_free(st, free_func) SKM_sk_pop_free(ACCESS_DESCRIPTION, (st), (free_func))\n# define sk_ACCESS_DESCRIPTION_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(ACCESS_DESCRIPTION, (st), (copy_func), (free_func))\n# define sk_ACCESS_DESCRIPTION_shift(st) SKM_sk_shift(ACCESS_DESCRIPTION, (st))\n# define sk_ACCESS_DESCRIPTION_pop(st) SKM_sk_pop(ACCESS_DESCRIPTION, (st))\n# define sk_ACCESS_DESCRIPTION_sort(st) SKM_sk_sort(ACCESS_DESCRIPTION, (st))\n# define sk_ACCESS_DESCRIPTION_is_sorted(st) SKM_sk_is_sorted(ACCESS_DESCRIPTION, (st))\n# define sk_ASIdOrRange_new(cmp) SKM_sk_new(ASIdOrRange, (cmp))\n# define sk_ASIdOrRange_new_null() SKM_sk_new_null(ASIdOrRange)\n# define sk_ASIdOrRange_free(st) SKM_sk_free(ASIdOrRange, (st))\n# define sk_ASIdOrRange_num(st) SKM_sk_num(ASIdOrRange, (st))\n# define sk_ASIdOrRange_value(st, i) SKM_sk_value(ASIdOrRange, (st), (i))\n# define sk_ASIdOrRange_set(st, i, val) SKM_sk_set(ASIdOrRange, (st), (i), (val))\n# define sk_ASIdOrRange_zero(st) SKM_sk_zero(ASIdOrRange, (st))\n# define sk_ASIdOrRange_push(st, val) SKM_sk_push(ASIdOrRange, (st), (val))\n# define sk_ASIdOrRange_unshift(st, val) SKM_sk_unshift(ASIdOrRange, (st), (val))\n# define sk_ASIdOrRange_find(st, val) SKM_sk_find(ASIdOrRange, (st), (val))\n# define sk_ASIdOrRange_find_ex(st, val) SKM_sk_find_ex(ASIdOrRange, (st), (val))\n# define sk_ASIdOrRange_delete(st, i) SKM_sk_delete(ASIdOrRange, (st), (i))\n# define sk_ASIdOrRange_delete_ptr(st, ptr) SKM_sk_delete_ptr(ASIdOrRange, (st), (ptr))\n# define sk_ASIdOrRange_insert(st, val, i) SKM_sk_insert(ASIdOrRange, (st), (val), (i))\n# define sk_ASIdOrRange_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(ASIdOrRange, (st), (cmp))\n# define sk_ASIdOrRange_dup(st) SKM_sk_dup(ASIdOrRange, st)\n# define sk_ASIdOrRange_pop_free(st, free_func) SKM_sk_pop_free(ASIdOrRange, (st), (free_func))\n# define sk_ASIdOrRange_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(ASIdOrRange, (st), (copy_func), (free_func))\n# define sk_ASIdOrRange_shift(st) SKM_sk_shift(ASIdOrRange, (st))\n# define sk_ASIdOrRange_pop(st) SKM_sk_pop(ASIdOrRange, (st))\n# define sk_ASIdOrRange_sort(st) SKM_sk_sort(ASIdOrRange, (st))\n# define sk_ASIdOrRange_is_sorted(st) SKM_sk_is_sorted(ASIdOrRange, (st))\n# define sk_ASN1_GENERALSTRING_new(cmp) SKM_sk_new(ASN1_GENERALSTRING, (cmp))\n# define sk_ASN1_GENERALSTRING_new_null() SKM_sk_new_null(ASN1_GENERALSTRING)\n# define sk_ASN1_GENERALSTRING_free(st) SKM_sk_free(ASN1_GENERALSTRING, (st))\n# define sk_ASN1_GENERALSTRING_num(st) SKM_sk_num(ASN1_GENERALSTRING, (st))\n# define sk_ASN1_GENERALSTRING_value(st, i) SKM_sk_value(ASN1_GENERALSTRING, (st), (i))\n# define sk_ASN1_GENERALSTRING_set(st, i, val) SKM_sk_set(ASN1_GENERALSTRING, (st), (i), (val))\n# define sk_ASN1_GENERALSTRING_zero(st) SKM_sk_zero(ASN1_GENERALSTRING, (st))\n# define sk_ASN1_GENERALSTRING_push(st, val) SKM_sk_push(ASN1_GENERALSTRING, (st), (val))\n# define sk_ASN1_GENERALSTRING_unshift(st, val) SKM_sk_unshift(ASN1_GENERALSTRING, (st), (val))\n# define sk_ASN1_GENERALSTRING_find(st, val) SKM_sk_find(ASN1_GENERALSTRING, (st), (val))\n# define sk_ASN1_GENERALSTRING_find_ex(st, val) SKM_sk_find_ex(ASN1_GENERALSTRING, (st), (val))\n# define sk_ASN1_GENERALSTRING_delete(st, i) SKM_sk_delete(ASN1_GENERALSTRING, (st), (i))\n# define sk_ASN1_GENERALSTRING_delete_ptr(st, ptr) SKM_sk_delete_ptr(ASN1_GENERALSTRING, (st), (ptr))\n# define sk_ASN1_GENERALSTRING_insert(st, val, i) SKM_sk_insert(ASN1_GENERALSTRING, (st), (val), (i))\n# define sk_ASN1_GENERALSTRING_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(ASN1_GENERALSTRING, (st), (cmp))\n# define sk_ASN1_GENERALSTRING_dup(st) SKM_sk_dup(ASN1_GENERALSTRING, st)\n# define sk_ASN1_GENERALSTRING_pop_free(st, free_func) SKM_sk_pop_free(ASN1_GENERALSTRING, (st), (free_func))\n# define sk_ASN1_GENERALSTRING_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(ASN1_GENERALSTRING, (st), (copy_func), (free_func))\n# define sk_ASN1_GENERALSTRING_shift(st) SKM_sk_shift(ASN1_GENERALSTRING, (st))\n# define sk_ASN1_GENERALSTRING_pop(st) SKM_sk_pop(ASN1_GENERALSTRING, (st))\n# define sk_ASN1_GENERALSTRING_sort(st) SKM_sk_sort(ASN1_GENERALSTRING, (st))\n# define sk_ASN1_GENERALSTRING_is_sorted(st) SKM_sk_is_sorted(ASN1_GENERALSTRING, (st))\n# define sk_ASN1_INTEGER_new(cmp) SKM_sk_new(ASN1_INTEGER, (cmp))\n# define sk_ASN1_INTEGER_new_null() SKM_sk_new_null(ASN1_INTEGER)\n# define sk_ASN1_INTEGER_free(st) SKM_sk_free(ASN1_INTEGER, (st))\n# define sk_ASN1_INTEGER_num(st) SKM_sk_num(ASN1_INTEGER, (st))\n# define sk_ASN1_INTEGER_value(st, i) SKM_sk_value(ASN1_INTEGER, (st), (i))\n# define sk_ASN1_INTEGER_set(st, i, val) SKM_sk_set(ASN1_INTEGER, (st), (i), (val))\n# define sk_ASN1_INTEGER_zero(st) SKM_sk_zero(ASN1_INTEGER, (st))\n# define sk_ASN1_INTEGER_push(st, val) SKM_sk_push(ASN1_INTEGER, (st), (val))\n# define sk_ASN1_INTEGER_unshift(st, val) SKM_sk_unshift(ASN1_INTEGER, (st), (val))\n# define sk_ASN1_INTEGER_find(st, val) SKM_sk_find(ASN1_INTEGER, (st), (val))\n# define sk_ASN1_INTEGER_find_ex(st, val) SKM_sk_find_ex(ASN1_INTEGER, (st), (val))\n# define sk_ASN1_INTEGER_delete(st, i) SKM_sk_delete(ASN1_INTEGER, (st), (i))\n# define sk_ASN1_INTEGER_delete_ptr(st, ptr) SKM_sk_delete_ptr(ASN1_INTEGER, (st), (ptr))\n# define sk_ASN1_INTEGER_insert(st, val, i) SKM_sk_insert(ASN1_INTEGER, (st), (val), (i))\n# define sk_ASN1_INTEGER_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(ASN1_INTEGER, (st), (cmp))\n# define sk_ASN1_INTEGER_dup(st) SKM_sk_dup(ASN1_INTEGER, st)\n# define sk_ASN1_INTEGER_pop_free(st, free_func) SKM_sk_pop_free(ASN1_INTEGER, (st), (free_func))\n# define sk_ASN1_INTEGER_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(ASN1_INTEGER, (st), (copy_func), (free_func))\n# define sk_ASN1_INTEGER_shift(st) SKM_sk_shift(ASN1_INTEGER, (st))\n# define sk_ASN1_INTEGER_pop(st) SKM_sk_pop(ASN1_INTEGER, (st))\n# define sk_ASN1_INTEGER_sort(st) SKM_sk_sort(ASN1_INTEGER, (st))\n# define sk_ASN1_INTEGER_is_sorted(st) SKM_sk_is_sorted(ASN1_INTEGER, (st))\n# define sk_ASN1_OBJECT_new(cmp) SKM_sk_new(ASN1_OBJECT, (cmp))\n# define sk_ASN1_OBJECT_new_null() SKM_sk_new_null(ASN1_OBJECT)\n# define sk_ASN1_OBJECT_free(st) SKM_sk_free(ASN1_OBJECT, (st))\n# define sk_ASN1_OBJECT_num(st) SKM_sk_num(ASN1_OBJECT, (st))\n# define sk_ASN1_OBJECT_value(st, i) SKM_sk_value(ASN1_OBJECT, (st), (i))\n# define sk_ASN1_OBJECT_set(st, i, val) SKM_sk_set(ASN1_OBJECT, (st), (i), (val))\n# define sk_ASN1_OBJECT_zero(st) SKM_sk_zero(ASN1_OBJECT, (st))\n# define sk_ASN1_OBJECT_push(st, val) SKM_sk_push(ASN1_OBJECT, (st), (val))\n# define sk_ASN1_OBJECT_unshift(st, val) SKM_sk_unshift(ASN1_OBJECT, (st), (val))\n# define sk_ASN1_OBJECT_find(st, val) SKM_sk_find(ASN1_OBJECT, (st), (val))\n# define sk_ASN1_OBJECT_find_ex(st, val) SKM_sk_find_ex(ASN1_OBJECT, (st), (val))\n# define sk_ASN1_OBJECT_delete(st, i) SKM_sk_delete(ASN1_OBJECT, (st), (i))\n# define sk_ASN1_OBJECT_delete_ptr(st, ptr) SKM_sk_delete_ptr(ASN1_OBJECT, (st), (ptr))\n# define sk_ASN1_OBJECT_insert(st, val, i) SKM_sk_insert(ASN1_OBJECT, (st), (val), (i))\n# define sk_ASN1_OBJECT_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(ASN1_OBJECT, (st), (cmp))\n# define sk_ASN1_OBJECT_dup(st) SKM_sk_dup(ASN1_OBJECT, st)\n# define sk_ASN1_OBJECT_pop_free(st, free_func) SKM_sk_pop_free(ASN1_OBJECT, (st), (free_func))\n# define sk_ASN1_OBJECT_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(ASN1_OBJECT, (st), (copy_func), (free_func))\n# define sk_ASN1_OBJECT_shift(st) SKM_sk_shift(ASN1_OBJECT, (st))\n# define sk_ASN1_OBJECT_pop(st) SKM_sk_pop(ASN1_OBJECT, (st))\n# define sk_ASN1_OBJECT_sort(st) SKM_sk_sort(ASN1_OBJECT, (st))\n# define sk_ASN1_OBJECT_is_sorted(st) SKM_sk_is_sorted(ASN1_OBJECT, (st))\n# define sk_ASN1_STRING_TABLE_new(cmp) SKM_sk_new(ASN1_STRING_TABLE, (cmp))\n# define sk_ASN1_STRING_TABLE_new_null() SKM_sk_new_null(ASN1_STRING_TABLE)\n# define sk_ASN1_STRING_TABLE_free(st) SKM_sk_free(ASN1_STRING_TABLE, (st))\n# define sk_ASN1_STRING_TABLE_num(st) SKM_sk_num(ASN1_STRING_TABLE, (st))\n# define sk_ASN1_STRING_TABLE_value(st, i) SKM_sk_value(ASN1_STRING_TABLE, (st), (i))\n# define sk_ASN1_STRING_TABLE_set(st, i, val) SKM_sk_set(ASN1_STRING_TABLE, (st), (i), (val))\n# define sk_ASN1_STRING_TABLE_zero(st) SKM_sk_zero(ASN1_STRING_TABLE, (st))\n# define sk_ASN1_STRING_TABLE_push(st, val) SKM_sk_push(ASN1_STRING_TABLE, (st), (val))\n# define sk_ASN1_STRING_TABLE_unshift(st, val) SKM_sk_unshift(ASN1_STRING_TABLE, (st), (val))\n# define sk_ASN1_STRING_TABLE_find(st, val) SKM_sk_find(ASN1_STRING_TABLE, (st), (val))\n# define sk_ASN1_STRING_TABLE_find_ex(st, val) SKM_sk_find_ex(ASN1_STRING_TABLE, (st), (val))\n# define sk_ASN1_STRING_TABLE_delete(st, i) SKM_sk_delete(ASN1_STRING_TABLE, (st), (i))\n# define sk_ASN1_STRING_TABLE_delete_ptr(st, ptr) SKM_sk_delete_ptr(ASN1_STRING_TABLE, (st), (ptr))\n# define sk_ASN1_STRING_TABLE_insert(st, val, i) SKM_sk_insert(ASN1_STRING_TABLE, (st), (val), (i))\n# define sk_ASN1_STRING_TABLE_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(ASN1_STRING_TABLE, (st), (cmp))\n# define sk_ASN1_STRING_TABLE_dup(st) SKM_sk_dup(ASN1_STRING_TABLE, st)\n# define sk_ASN1_STRING_TABLE_pop_free(st, free_func) SKM_sk_pop_free(ASN1_STRING_TABLE, (st), (free_func))\n# define sk_ASN1_STRING_TABLE_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(ASN1_STRING_TABLE, (st), (copy_func), (free_func))\n# define sk_ASN1_STRING_TABLE_shift(st) SKM_sk_shift(ASN1_STRING_TABLE, (st))\n# define sk_ASN1_STRING_TABLE_pop(st) SKM_sk_pop(ASN1_STRING_TABLE, (st))\n# define sk_ASN1_STRING_TABLE_sort(st) SKM_sk_sort(ASN1_STRING_TABLE, (st))\n# define sk_ASN1_STRING_TABLE_is_sorted(st) SKM_sk_is_sorted(ASN1_STRING_TABLE, (st))\n# define sk_ASN1_TYPE_new(cmp) SKM_sk_new(ASN1_TYPE, (cmp))\n# define sk_ASN1_TYPE_new_null() SKM_sk_new_null(ASN1_TYPE)\n# define sk_ASN1_TYPE_free(st) SKM_sk_free(ASN1_TYPE, (st))\n# define sk_ASN1_TYPE_num(st) SKM_sk_num(ASN1_TYPE, (st))\n# define sk_ASN1_TYPE_value(st, i) SKM_sk_value(ASN1_TYPE, (st), (i))\n# define sk_ASN1_TYPE_set(st, i, val) SKM_sk_set(ASN1_TYPE, (st), (i), (val))\n# define sk_ASN1_TYPE_zero(st) SKM_sk_zero(ASN1_TYPE, (st))\n# define sk_ASN1_TYPE_push(st, val) SKM_sk_push(ASN1_TYPE, (st), (val))\n# define sk_ASN1_TYPE_unshift(st, val) SKM_sk_unshift(ASN1_TYPE, (st), (val))\n# define sk_ASN1_TYPE_find(st, val) SKM_sk_find(ASN1_TYPE, (st), (val))\n# define sk_ASN1_TYPE_find_ex(st, val) SKM_sk_find_ex(ASN1_TYPE, (st), (val))\n# define sk_ASN1_TYPE_delete(st, i) SKM_sk_delete(ASN1_TYPE, (st), (i))\n# define sk_ASN1_TYPE_delete_ptr(st, ptr) SKM_sk_delete_ptr(ASN1_TYPE, (st), (ptr))\n# define sk_ASN1_TYPE_insert(st, val, i) SKM_sk_insert(ASN1_TYPE, (st), (val), (i))\n# define sk_ASN1_TYPE_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(ASN1_TYPE, (st), (cmp))\n# define sk_ASN1_TYPE_dup(st) SKM_sk_dup(ASN1_TYPE, st)\n# define sk_ASN1_TYPE_pop_free(st, free_func) SKM_sk_pop_free(ASN1_TYPE, (st), (free_func))\n# define sk_ASN1_TYPE_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(ASN1_TYPE, (st), (copy_func), (free_func))\n# define sk_ASN1_TYPE_shift(st) SKM_sk_shift(ASN1_TYPE, (st))\n# define sk_ASN1_TYPE_pop(st) SKM_sk_pop(ASN1_TYPE, (st))\n# define sk_ASN1_TYPE_sort(st) SKM_sk_sort(ASN1_TYPE, (st))\n# define sk_ASN1_TYPE_is_sorted(st) SKM_sk_is_sorted(ASN1_TYPE, (st))\n# define sk_ASN1_UTF8STRING_new(cmp) SKM_sk_new(ASN1_UTF8STRING, (cmp))\n# define sk_ASN1_UTF8STRING_new_null() SKM_sk_new_null(ASN1_UTF8STRING)\n# define sk_ASN1_UTF8STRING_free(st) SKM_sk_free(ASN1_UTF8STRING, (st))\n# define sk_ASN1_UTF8STRING_num(st) SKM_sk_num(ASN1_UTF8STRING, (st))\n# define sk_ASN1_UTF8STRING_value(st, i) SKM_sk_value(ASN1_UTF8STRING, (st), (i))\n# define sk_ASN1_UTF8STRING_set(st, i, val) SKM_sk_set(ASN1_UTF8STRING, (st), (i), (val))\n# define sk_ASN1_UTF8STRING_zero(st) SKM_sk_zero(ASN1_UTF8STRING, (st))\n# define sk_ASN1_UTF8STRING_push(st, val) SKM_sk_push(ASN1_UTF8STRING, (st), (val))\n# define sk_ASN1_UTF8STRING_unshift(st, val) SKM_sk_unshift(ASN1_UTF8STRING, (st), (val))\n# define sk_ASN1_UTF8STRING_find(st, val) SKM_sk_find(ASN1_UTF8STRING, (st), (val))\n# define sk_ASN1_UTF8STRING_find_ex(st, val) SKM_sk_find_ex(ASN1_UTF8STRING, (st), (val))\n# define sk_ASN1_UTF8STRING_delete(st, i) SKM_sk_delete(ASN1_UTF8STRING, (st), (i))\n# define sk_ASN1_UTF8STRING_delete_ptr(st, ptr) SKM_sk_delete_ptr(ASN1_UTF8STRING, (st), (ptr))\n# define sk_ASN1_UTF8STRING_insert(st, val, i) SKM_sk_insert(ASN1_UTF8STRING, (st), (val), (i))\n# define sk_ASN1_UTF8STRING_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(ASN1_UTF8STRING, (st), (cmp))\n# define sk_ASN1_UTF8STRING_dup(st) SKM_sk_dup(ASN1_UTF8STRING, st)\n# define sk_ASN1_UTF8STRING_pop_free(st, free_func) SKM_sk_pop_free(ASN1_UTF8STRING, (st), (free_func))\n# define sk_ASN1_UTF8STRING_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(ASN1_UTF8STRING, (st), (copy_func), (free_func))\n# define sk_ASN1_UTF8STRING_shift(st) SKM_sk_shift(ASN1_UTF8STRING, (st))\n# define sk_ASN1_UTF8STRING_pop(st) SKM_sk_pop(ASN1_UTF8STRING, (st))\n# define sk_ASN1_UTF8STRING_sort(st) SKM_sk_sort(ASN1_UTF8STRING, (st))\n# define sk_ASN1_UTF8STRING_is_sorted(st) SKM_sk_is_sorted(ASN1_UTF8STRING, (st))\n# define sk_ASN1_VALUE_new(cmp) SKM_sk_new(ASN1_VALUE, (cmp))\n# define sk_ASN1_VALUE_new_null() SKM_sk_new_null(ASN1_VALUE)\n# define sk_ASN1_VALUE_free(st) SKM_sk_free(ASN1_VALUE, (st))\n# define sk_ASN1_VALUE_num(st) SKM_sk_num(ASN1_VALUE, (st))\n# define sk_ASN1_VALUE_value(st, i) SKM_sk_value(ASN1_VALUE, (st), (i))\n# define sk_ASN1_VALUE_set(st, i, val) SKM_sk_set(ASN1_VALUE, (st), (i), (val))\n# define sk_ASN1_VALUE_zero(st) SKM_sk_zero(ASN1_VALUE, (st))\n# define sk_ASN1_VALUE_push(st, val) SKM_sk_push(ASN1_VALUE, (st), (val))\n# define sk_ASN1_VALUE_unshift(st, val) SKM_sk_unshift(ASN1_VALUE, (st), (val))\n# define sk_ASN1_VALUE_find(st, val) SKM_sk_find(ASN1_VALUE, (st), (val))\n# define sk_ASN1_VALUE_find_ex(st, val) SKM_sk_find_ex(ASN1_VALUE, (st), (val))\n# define sk_ASN1_VALUE_delete(st, i) SKM_sk_delete(ASN1_VALUE, (st), (i))\n# define sk_ASN1_VALUE_delete_ptr(st, ptr) SKM_sk_delete_ptr(ASN1_VALUE, (st), (ptr))\n# define sk_ASN1_VALUE_insert(st, val, i) SKM_sk_insert(ASN1_VALUE, (st), (val), (i))\n# define sk_ASN1_VALUE_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(ASN1_VALUE, (st), (cmp))\n# define sk_ASN1_VALUE_dup(st) SKM_sk_dup(ASN1_VALUE, st)\n# define sk_ASN1_VALUE_pop_free(st, free_func) SKM_sk_pop_free(ASN1_VALUE, (st), (free_func))\n# define sk_ASN1_VALUE_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(ASN1_VALUE, (st), (copy_func), (free_func))\n# define sk_ASN1_VALUE_shift(st) SKM_sk_shift(ASN1_VALUE, (st))\n# define sk_ASN1_VALUE_pop(st) SKM_sk_pop(ASN1_VALUE, (st))\n# define sk_ASN1_VALUE_sort(st) SKM_sk_sort(ASN1_VALUE, (st))\n# define sk_ASN1_VALUE_is_sorted(st) SKM_sk_is_sorted(ASN1_VALUE, (st))\n# define sk_BIO_new(cmp) SKM_sk_new(BIO, (cmp))\n# define sk_BIO_new_null() SKM_sk_new_null(BIO)\n# define sk_BIO_free(st) SKM_sk_free(BIO, (st))\n# define sk_BIO_num(st) SKM_sk_num(BIO, (st))\n# define sk_BIO_value(st, i) SKM_sk_value(BIO, (st), (i))\n# define sk_BIO_set(st, i, val) SKM_sk_set(BIO, (st), (i), (val))\n# define sk_BIO_zero(st) SKM_sk_zero(BIO, (st))\n# define sk_BIO_push(st, val) SKM_sk_push(BIO, (st), (val))\n# define sk_BIO_unshift(st, val) SKM_sk_unshift(BIO, (st), (val))\n# define sk_BIO_find(st, val) SKM_sk_find(BIO, (st), (val))\n# define sk_BIO_find_ex(st, val) SKM_sk_find_ex(BIO, (st), (val))\n# define sk_BIO_delete(st, i) SKM_sk_delete(BIO, (st), (i))\n# define sk_BIO_delete_ptr(st, ptr) SKM_sk_delete_ptr(BIO, (st), (ptr))\n# define sk_BIO_insert(st, val, i) SKM_sk_insert(BIO, (st), (val), (i))\n# define sk_BIO_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(BIO, (st), (cmp))\n# define sk_BIO_dup(st) SKM_sk_dup(BIO, st)\n# define sk_BIO_pop_free(st, free_func) SKM_sk_pop_free(BIO, (st), (free_func))\n# define sk_BIO_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(BIO, (st), (copy_func), (free_func))\n# define sk_BIO_shift(st) SKM_sk_shift(BIO, (st))\n# define sk_BIO_pop(st) SKM_sk_pop(BIO, (st))\n# define sk_BIO_sort(st) SKM_sk_sort(BIO, (st))\n# define sk_BIO_is_sorted(st) SKM_sk_is_sorted(BIO, (st))\n# define sk_BY_DIR_ENTRY_new(cmp) SKM_sk_new(BY_DIR_ENTRY, (cmp))\n# define sk_BY_DIR_ENTRY_new_null() SKM_sk_new_null(BY_DIR_ENTRY)\n# define sk_BY_DIR_ENTRY_free(st) SKM_sk_free(BY_DIR_ENTRY, (st))\n# define sk_BY_DIR_ENTRY_num(st) SKM_sk_num(BY_DIR_ENTRY, (st))\n# define sk_BY_DIR_ENTRY_value(st, i) SKM_sk_value(BY_DIR_ENTRY, (st), (i))\n# define sk_BY_DIR_ENTRY_set(st, i, val) SKM_sk_set(BY_DIR_ENTRY, (st), (i), (val))\n# define sk_BY_DIR_ENTRY_zero(st) SKM_sk_zero(BY_DIR_ENTRY, (st))\n# define sk_BY_DIR_ENTRY_push(st, val) SKM_sk_push(BY_DIR_ENTRY, (st), (val))\n# define sk_BY_DIR_ENTRY_unshift(st, val) SKM_sk_unshift(BY_DIR_ENTRY, (st), (val))\n# define sk_BY_DIR_ENTRY_find(st, val) SKM_sk_find(BY_DIR_ENTRY, (st), (val))\n# define sk_BY_DIR_ENTRY_find_ex(st, val) SKM_sk_find_ex(BY_DIR_ENTRY, (st), (val))\n# define sk_BY_DIR_ENTRY_delete(st, i) SKM_sk_delete(BY_DIR_ENTRY, (st), (i))\n# define sk_BY_DIR_ENTRY_delete_ptr(st, ptr) SKM_sk_delete_ptr(BY_DIR_ENTRY, (st), (ptr))\n# define sk_BY_DIR_ENTRY_insert(st, val, i) SKM_sk_insert(BY_DIR_ENTRY, (st), (val), (i))\n# define sk_BY_DIR_ENTRY_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(BY_DIR_ENTRY, (st), (cmp))\n# define sk_BY_DIR_ENTRY_dup(st) SKM_sk_dup(BY_DIR_ENTRY, st)\n# define sk_BY_DIR_ENTRY_pop_free(st, free_func) SKM_sk_pop_free(BY_DIR_ENTRY, (st), (free_func))\n# define sk_BY_DIR_ENTRY_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(BY_DIR_ENTRY, (st), (copy_func), (free_func))\n# define sk_BY_DIR_ENTRY_shift(st) SKM_sk_shift(BY_DIR_ENTRY, (st))\n# define sk_BY_DIR_ENTRY_pop(st) SKM_sk_pop(BY_DIR_ENTRY, (st))\n# define sk_BY_DIR_ENTRY_sort(st) SKM_sk_sort(BY_DIR_ENTRY, (st))\n# define sk_BY_DIR_ENTRY_is_sorted(st) SKM_sk_is_sorted(BY_DIR_ENTRY, (st))\n# define sk_BY_DIR_HASH_new(cmp) SKM_sk_new(BY_DIR_HASH, (cmp))\n# define sk_BY_DIR_HASH_new_null() SKM_sk_new_null(BY_DIR_HASH)\n# define sk_BY_DIR_HASH_free(st) SKM_sk_free(BY_DIR_HASH, (st))\n# define sk_BY_DIR_HASH_num(st) SKM_sk_num(BY_DIR_HASH, (st))\n# define sk_BY_DIR_HASH_value(st, i) SKM_sk_value(BY_DIR_HASH, (st), (i))\n# define sk_BY_DIR_HASH_set(st, i, val) SKM_sk_set(BY_DIR_HASH, (st), (i), (val))\n# define sk_BY_DIR_HASH_zero(st) SKM_sk_zero(BY_DIR_HASH, (st))\n# define sk_BY_DIR_HASH_push(st, val) SKM_sk_push(BY_DIR_HASH, (st), (val))\n# define sk_BY_DIR_HASH_unshift(st, val) SKM_sk_unshift(BY_DIR_HASH, (st), (val))\n# define sk_BY_DIR_HASH_find(st, val) SKM_sk_find(BY_DIR_HASH, (st), (val))\n# define sk_BY_DIR_HASH_find_ex(st, val) SKM_sk_find_ex(BY_DIR_HASH, (st), (val))\n# define sk_BY_DIR_HASH_delete(st, i) SKM_sk_delete(BY_DIR_HASH, (st), (i))\n# define sk_BY_DIR_HASH_delete_ptr(st, ptr) SKM_sk_delete_ptr(BY_DIR_HASH, (st), (ptr))\n# define sk_BY_DIR_HASH_insert(st, val, i) SKM_sk_insert(BY_DIR_HASH, (st), (val), (i))\n# define sk_BY_DIR_HASH_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(BY_DIR_HASH, (st), (cmp))\n# define sk_BY_DIR_HASH_dup(st) SKM_sk_dup(BY_DIR_HASH, st)\n# define sk_BY_DIR_HASH_pop_free(st, free_func) SKM_sk_pop_free(BY_DIR_HASH, (st), (free_func))\n# define sk_BY_DIR_HASH_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(BY_DIR_HASH, (st), (copy_func), (free_func))\n# define sk_BY_DIR_HASH_shift(st) SKM_sk_shift(BY_DIR_HASH, (st))\n# define sk_BY_DIR_HASH_pop(st) SKM_sk_pop(BY_DIR_HASH, (st))\n# define sk_BY_DIR_HASH_sort(st) SKM_sk_sort(BY_DIR_HASH, (st))\n# define sk_BY_DIR_HASH_is_sorted(st) SKM_sk_is_sorted(BY_DIR_HASH, (st))\n# define sk_CMS_CertificateChoices_new(cmp) SKM_sk_new(CMS_CertificateChoices, (cmp))\n# define sk_CMS_CertificateChoices_new_null() SKM_sk_new_null(CMS_CertificateChoices)\n# define sk_CMS_CertificateChoices_free(st) SKM_sk_free(CMS_CertificateChoices, (st))\n# define sk_CMS_CertificateChoices_num(st) SKM_sk_num(CMS_CertificateChoices, (st))\n# define sk_CMS_CertificateChoices_value(st, i) SKM_sk_value(CMS_CertificateChoices, (st), (i))\n# define sk_CMS_CertificateChoices_set(st, i, val) SKM_sk_set(CMS_CertificateChoices, (st), (i), (val))\n# define sk_CMS_CertificateChoices_zero(st) SKM_sk_zero(CMS_CertificateChoices, (st))\n# define sk_CMS_CertificateChoices_push(st, val) SKM_sk_push(CMS_CertificateChoices, (st), (val))\n# define sk_CMS_CertificateChoices_unshift(st, val) SKM_sk_unshift(CMS_CertificateChoices, (st), (val))\n# define sk_CMS_CertificateChoices_find(st, val) SKM_sk_find(CMS_CertificateChoices, (st), (val))\n# define sk_CMS_CertificateChoices_find_ex(st, val) SKM_sk_find_ex(CMS_CertificateChoices, (st), (val))\n# define sk_CMS_CertificateChoices_delete(st, i) SKM_sk_delete(CMS_CertificateChoices, (st), (i))\n# define sk_CMS_CertificateChoices_delete_ptr(st, ptr) SKM_sk_delete_ptr(CMS_CertificateChoices, (st), (ptr))\n# define sk_CMS_CertificateChoices_insert(st, val, i) SKM_sk_insert(CMS_CertificateChoices, (st), (val), (i))\n# define sk_CMS_CertificateChoices_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(CMS_CertificateChoices, (st), (cmp))\n# define sk_CMS_CertificateChoices_dup(st) SKM_sk_dup(CMS_CertificateChoices, st)\n# define sk_CMS_CertificateChoices_pop_free(st, free_func) SKM_sk_pop_free(CMS_CertificateChoices, (st), (free_func))\n# define sk_CMS_CertificateChoices_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(CMS_CertificateChoices, (st), (copy_func), (free_func))\n# define sk_CMS_CertificateChoices_shift(st) SKM_sk_shift(CMS_CertificateChoices, (st))\n# define sk_CMS_CertificateChoices_pop(st) SKM_sk_pop(CMS_CertificateChoices, (st))\n# define sk_CMS_CertificateChoices_sort(st) SKM_sk_sort(CMS_CertificateChoices, (st))\n# define sk_CMS_CertificateChoices_is_sorted(st) SKM_sk_is_sorted(CMS_CertificateChoices, (st))\n# define sk_CMS_RecipientEncryptedKey_new(cmp) SKM_sk_new(CMS_RecipientEncryptedKey, (cmp))\n# define sk_CMS_RecipientEncryptedKey_new_null() SKM_sk_new_null(CMS_RecipientEncryptedKey)\n# define sk_CMS_RecipientEncryptedKey_free(st) SKM_sk_free(CMS_RecipientEncryptedKey, (st))\n# define sk_CMS_RecipientEncryptedKey_num(st) SKM_sk_num(CMS_RecipientEncryptedKey, (st))\n# define sk_CMS_RecipientEncryptedKey_value(st, i) SKM_sk_value(CMS_RecipientEncryptedKey, (st), (i))\n# define sk_CMS_RecipientEncryptedKey_set(st, i, val) SKM_sk_set(CMS_RecipientEncryptedKey, (st), (i), (val))\n# define sk_CMS_RecipientEncryptedKey_zero(st) SKM_sk_zero(CMS_RecipientEncryptedKey, (st))\n# define sk_CMS_RecipientEncryptedKey_push(st, val) SKM_sk_push(CMS_RecipientEncryptedKey, (st), (val))\n# define sk_CMS_RecipientEncryptedKey_unshift(st, val) SKM_sk_unshift(CMS_RecipientEncryptedKey, (st), (val))\n# define sk_CMS_RecipientEncryptedKey_find(st, val) SKM_sk_find(CMS_RecipientEncryptedKey, (st), (val))\n# define sk_CMS_RecipientEncryptedKey_find_ex(st, val) SKM_sk_find_ex(CMS_RecipientEncryptedKey, (st), (val))\n# define sk_CMS_RecipientEncryptedKey_delete(st, i) SKM_sk_delete(CMS_RecipientEncryptedKey, (st), (i))\n# define sk_CMS_RecipientEncryptedKey_delete_ptr(st, ptr) SKM_sk_delete_ptr(CMS_RecipientEncryptedKey, (st), (ptr))\n# define sk_CMS_RecipientEncryptedKey_insert(st, val, i) SKM_sk_insert(CMS_RecipientEncryptedKey, (st), (val), (i))\n# define sk_CMS_RecipientEncryptedKey_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(CMS_RecipientEncryptedKey, (st), (cmp))\n# define sk_CMS_RecipientEncryptedKey_dup(st) SKM_sk_dup(CMS_RecipientEncryptedKey, st)\n# define sk_CMS_RecipientEncryptedKey_pop_free(st, free_func) SKM_sk_pop_free(CMS_RecipientEncryptedKey, (st), (free_func))\n# define sk_CMS_RecipientEncryptedKey_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(CMS_RecipientEncryptedKey, (st), (copy_func), (free_func))\n# define sk_CMS_RecipientEncryptedKey_shift(st) SKM_sk_shift(CMS_RecipientEncryptedKey, (st))\n# define sk_CMS_RecipientEncryptedKey_pop(st) SKM_sk_pop(CMS_RecipientEncryptedKey, (st))\n# define sk_CMS_RecipientEncryptedKey_sort(st) SKM_sk_sort(CMS_RecipientEncryptedKey, (st))\n# define sk_CMS_RecipientEncryptedKey_is_sorted(st) SKM_sk_is_sorted(CMS_RecipientEncryptedKey, (st))\n# define sk_CMS_RecipientInfo_new(cmp) SKM_sk_new(CMS_RecipientInfo, (cmp))\n# define sk_CMS_RecipientInfo_new_null() SKM_sk_new_null(CMS_RecipientInfo)\n# define sk_CMS_RecipientInfo_free(st) SKM_sk_free(CMS_RecipientInfo, (st))\n# define sk_CMS_RecipientInfo_num(st) SKM_sk_num(CMS_RecipientInfo, (st))\n# define sk_CMS_RecipientInfo_value(st, i) SKM_sk_value(CMS_RecipientInfo, (st), (i))\n# define sk_CMS_RecipientInfo_set(st, i, val) SKM_sk_set(CMS_RecipientInfo, (st), (i), (val))\n# define sk_CMS_RecipientInfo_zero(st) SKM_sk_zero(CMS_RecipientInfo, (st))\n# define sk_CMS_RecipientInfo_push(st, val) SKM_sk_push(CMS_RecipientInfo, (st), (val))\n# define sk_CMS_RecipientInfo_unshift(st, val) SKM_sk_unshift(CMS_RecipientInfo, (st), (val))\n# define sk_CMS_RecipientInfo_find(st, val) SKM_sk_find(CMS_RecipientInfo, (st), (val))\n# define sk_CMS_RecipientInfo_find_ex(st, val) SKM_sk_find_ex(CMS_RecipientInfo, (st), (val))\n# define sk_CMS_RecipientInfo_delete(st, i) SKM_sk_delete(CMS_RecipientInfo, (st), (i))\n# define sk_CMS_RecipientInfo_delete_ptr(st, ptr) SKM_sk_delete_ptr(CMS_RecipientInfo, (st), (ptr))\n# define sk_CMS_RecipientInfo_insert(st, val, i) SKM_sk_insert(CMS_RecipientInfo, (st), (val), (i))\n# define sk_CMS_RecipientInfo_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(CMS_RecipientInfo, (st), (cmp))\n# define sk_CMS_RecipientInfo_dup(st) SKM_sk_dup(CMS_RecipientInfo, st)\n# define sk_CMS_RecipientInfo_pop_free(st, free_func) SKM_sk_pop_free(CMS_RecipientInfo, (st), (free_func))\n# define sk_CMS_RecipientInfo_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(CMS_RecipientInfo, (st), (copy_func), (free_func))\n# define sk_CMS_RecipientInfo_shift(st) SKM_sk_shift(CMS_RecipientInfo, (st))\n# define sk_CMS_RecipientInfo_pop(st) SKM_sk_pop(CMS_RecipientInfo, (st))\n# define sk_CMS_RecipientInfo_sort(st) SKM_sk_sort(CMS_RecipientInfo, (st))\n# define sk_CMS_RecipientInfo_is_sorted(st) SKM_sk_is_sorted(CMS_RecipientInfo, (st))\n# define sk_CMS_RevocationInfoChoice_new(cmp) SKM_sk_new(CMS_RevocationInfoChoice, (cmp))\n# define sk_CMS_RevocationInfoChoice_new_null() SKM_sk_new_null(CMS_RevocationInfoChoice)\n# define sk_CMS_RevocationInfoChoice_free(st) SKM_sk_free(CMS_RevocationInfoChoice, (st))\n# define sk_CMS_RevocationInfoChoice_num(st) SKM_sk_num(CMS_RevocationInfoChoice, (st))\n# define sk_CMS_RevocationInfoChoice_value(st, i) SKM_sk_value(CMS_RevocationInfoChoice, (st), (i))\n# define sk_CMS_RevocationInfoChoice_set(st, i, val) SKM_sk_set(CMS_RevocationInfoChoice, (st), (i), (val))\n# define sk_CMS_RevocationInfoChoice_zero(st) SKM_sk_zero(CMS_RevocationInfoChoice, (st))\n# define sk_CMS_RevocationInfoChoice_push(st, val) SKM_sk_push(CMS_RevocationInfoChoice, (st), (val))\n# define sk_CMS_RevocationInfoChoice_unshift(st, val) SKM_sk_unshift(CMS_RevocationInfoChoice, (st), (val))\n# define sk_CMS_RevocationInfoChoice_find(st, val) SKM_sk_find(CMS_RevocationInfoChoice, (st), (val))\n# define sk_CMS_RevocationInfoChoice_find_ex(st, val) SKM_sk_find_ex(CMS_RevocationInfoChoice, (st), (val))\n# define sk_CMS_RevocationInfoChoice_delete(st, i) SKM_sk_delete(CMS_RevocationInfoChoice, (st), (i))\n# define sk_CMS_RevocationInfoChoice_delete_ptr(st, ptr) SKM_sk_delete_ptr(CMS_RevocationInfoChoice, (st), (ptr))\n# define sk_CMS_RevocationInfoChoice_insert(st, val, i) SKM_sk_insert(CMS_RevocationInfoChoice, (st), (val), (i))\n# define sk_CMS_RevocationInfoChoice_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(CMS_RevocationInfoChoice, (st), (cmp))\n# define sk_CMS_RevocationInfoChoice_dup(st) SKM_sk_dup(CMS_RevocationInfoChoice, st)\n# define sk_CMS_RevocationInfoChoice_pop_free(st, free_func) SKM_sk_pop_free(CMS_RevocationInfoChoice, (st), (free_func))\n# define sk_CMS_RevocationInfoChoice_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(CMS_RevocationInfoChoice, (st), (copy_func), (free_func))\n# define sk_CMS_RevocationInfoChoice_shift(st) SKM_sk_shift(CMS_RevocationInfoChoice, (st))\n# define sk_CMS_RevocationInfoChoice_pop(st) SKM_sk_pop(CMS_RevocationInfoChoice, (st))\n# define sk_CMS_RevocationInfoChoice_sort(st) SKM_sk_sort(CMS_RevocationInfoChoice, (st))\n# define sk_CMS_RevocationInfoChoice_is_sorted(st) SKM_sk_is_sorted(CMS_RevocationInfoChoice, (st))\n# define sk_CMS_SignerInfo_new(cmp) SKM_sk_new(CMS_SignerInfo, (cmp))\n# define sk_CMS_SignerInfo_new_null() SKM_sk_new_null(CMS_SignerInfo)\n# define sk_CMS_SignerInfo_free(st) SKM_sk_free(CMS_SignerInfo, (st))\n# define sk_CMS_SignerInfo_num(st) SKM_sk_num(CMS_SignerInfo, (st))\n# define sk_CMS_SignerInfo_value(st, i) SKM_sk_value(CMS_SignerInfo, (st), (i))\n# define sk_CMS_SignerInfo_set(st, i, val) SKM_sk_set(CMS_SignerInfo, (st), (i), (val))\n# define sk_CMS_SignerInfo_zero(st) SKM_sk_zero(CMS_SignerInfo, (st))\n# define sk_CMS_SignerInfo_push(st, val) SKM_sk_push(CMS_SignerInfo, (st), (val))\n# define sk_CMS_SignerInfo_unshift(st, val) SKM_sk_unshift(CMS_SignerInfo, (st), (val))\n# define sk_CMS_SignerInfo_find(st, val) SKM_sk_find(CMS_SignerInfo, (st), (val))\n# define sk_CMS_SignerInfo_find_ex(st, val) SKM_sk_find_ex(CMS_SignerInfo, (st), (val))\n# define sk_CMS_SignerInfo_delete(st, i) SKM_sk_delete(CMS_SignerInfo, (st), (i))\n# define sk_CMS_SignerInfo_delete_ptr(st, ptr) SKM_sk_delete_ptr(CMS_SignerInfo, (st), (ptr))\n# define sk_CMS_SignerInfo_insert(st, val, i) SKM_sk_insert(CMS_SignerInfo, (st), (val), (i))\n# define sk_CMS_SignerInfo_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(CMS_SignerInfo, (st), (cmp))\n# define sk_CMS_SignerInfo_dup(st) SKM_sk_dup(CMS_SignerInfo, st)\n# define sk_CMS_SignerInfo_pop_free(st, free_func) SKM_sk_pop_free(CMS_SignerInfo, (st), (free_func))\n# define sk_CMS_SignerInfo_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(CMS_SignerInfo, (st), (copy_func), (free_func))\n# define sk_CMS_SignerInfo_shift(st) SKM_sk_shift(CMS_SignerInfo, (st))\n# define sk_CMS_SignerInfo_pop(st) SKM_sk_pop(CMS_SignerInfo, (st))\n# define sk_CMS_SignerInfo_sort(st) SKM_sk_sort(CMS_SignerInfo, (st))\n# define sk_CMS_SignerInfo_is_sorted(st) SKM_sk_is_sorted(CMS_SignerInfo, (st))\n# define sk_CONF_IMODULE_new(cmp) SKM_sk_new(CONF_IMODULE, (cmp))\n# define sk_CONF_IMODULE_new_null() SKM_sk_new_null(CONF_IMODULE)\n# define sk_CONF_IMODULE_free(st) SKM_sk_free(CONF_IMODULE, (st))\n# define sk_CONF_IMODULE_num(st) SKM_sk_num(CONF_IMODULE, (st))\n# define sk_CONF_IMODULE_value(st, i) SKM_sk_value(CONF_IMODULE, (st), (i))\n# define sk_CONF_IMODULE_set(st, i, val) SKM_sk_set(CONF_IMODULE, (st), (i), (val))\n# define sk_CONF_IMODULE_zero(st) SKM_sk_zero(CONF_IMODULE, (st))\n# define sk_CONF_IMODULE_push(st, val) SKM_sk_push(CONF_IMODULE, (st), (val))\n# define sk_CONF_IMODULE_unshift(st, val) SKM_sk_unshift(CONF_IMODULE, (st), (val))\n# define sk_CONF_IMODULE_find(st, val) SKM_sk_find(CONF_IMODULE, (st), (val))\n# define sk_CONF_IMODULE_find_ex(st, val) SKM_sk_find_ex(CONF_IMODULE, (st), (val))\n# define sk_CONF_IMODULE_delete(st, i) SKM_sk_delete(CONF_IMODULE, (st), (i))\n# define sk_CONF_IMODULE_delete_ptr(st, ptr) SKM_sk_delete_ptr(CONF_IMODULE, (st), (ptr))\n# define sk_CONF_IMODULE_insert(st, val, i) SKM_sk_insert(CONF_IMODULE, (st), (val), (i))\n# define sk_CONF_IMODULE_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(CONF_IMODULE, (st), (cmp))\n# define sk_CONF_IMODULE_dup(st) SKM_sk_dup(CONF_IMODULE, st)\n# define sk_CONF_IMODULE_pop_free(st, free_func) SKM_sk_pop_free(CONF_IMODULE, (st), (free_func))\n# define sk_CONF_IMODULE_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(CONF_IMODULE, (st), (copy_func), (free_func))\n# define sk_CONF_IMODULE_shift(st) SKM_sk_shift(CONF_IMODULE, (st))\n# define sk_CONF_IMODULE_pop(st) SKM_sk_pop(CONF_IMODULE, (st))\n# define sk_CONF_IMODULE_sort(st) SKM_sk_sort(CONF_IMODULE, (st))\n# define sk_CONF_IMODULE_is_sorted(st) SKM_sk_is_sorted(CONF_IMODULE, (st))\n# define sk_CONF_MODULE_new(cmp) SKM_sk_new(CONF_MODULE, (cmp))\n# define sk_CONF_MODULE_new_null() SKM_sk_new_null(CONF_MODULE)\n# define sk_CONF_MODULE_free(st) SKM_sk_free(CONF_MODULE, (st))\n# define sk_CONF_MODULE_num(st) SKM_sk_num(CONF_MODULE, (st))\n# define sk_CONF_MODULE_value(st, i) SKM_sk_value(CONF_MODULE, (st), (i))\n# define sk_CONF_MODULE_set(st, i, val) SKM_sk_set(CONF_MODULE, (st), (i), (val))\n# define sk_CONF_MODULE_zero(st) SKM_sk_zero(CONF_MODULE, (st))\n# define sk_CONF_MODULE_push(st, val) SKM_sk_push(CONF_MODULE, (st), (val))\n# define sk_CONF_MODULE_unshift(st, val) SKM_sk_unshift(CONF_MODULE, (st), (val))\n# define sk_CONF_MODULE_find(st, val) SKM_sk_find(CONF_MODULE, (st), (val))\n# define sk_CONF_MODULE_find_ex(st, val) SKM_sk_find_ex(CONF_MODULE, (st), (val))\n# define sk_CONF_MODULE_delete(st, i) SKM_sk_delete(CONF_MODULE, (st), (i))\n# define sk_CONF_MODULE_delete_ptr(st, ptr) SKM_sk_delete_ptr(CONF_MODULE, (st), (ptr))\n# define sk_CONF_MODULE_insert(st, val, i) SKM_sk_insert(CONF_MODULE, (st), (val), (i))\n# define sk_CONF_MODULE_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(CONF_MODULE, (st), (cmp))\n# define sk_CONF_MODULE_dup(st) SKM_sk_dup(CONF_MODULE, st)\n# define sk_CONF_MODULE_pop_free(st, free_func) SKM_sk_pop_free(CONF_MODULE, (st), (free_func))\n# define sk_CONF_MODULE_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(CONF_MODULE, (st), (copy_func), (free_func))\n# define sk_CONF_MODULE_shift(st) SKM_sk_shift(CONF_MODULE, (st))\n# define sk_CONF_MODULE_pop(st) SKM_sk_pop(CONF_MODULE, (st))\n# define sk_CONF_MODULE_sort(st) SKM_sk_sort(CONF_MODULE, (st))\n# define sk_CONF_MODULE_is_sorted(st) SKM_sk_is_sorted(CONF_MODULE, (st))\n# define sk_CONF_VALUE_new(cmp) SKM_sk_new(CONF_VALUE, (cmp))\n# define sk_CONF_VALUE_new_null() SKM_sk_new_null(CONF_VALUE)\n# define sk_CONF_VALUE_free(st) SKM_sk_free(CONF_VALUE, (st))\n# define sk_CONF_VALUE_num(st) SKM_sk_num(CONF_VALUE, (st))\n# define sk_CONF_VALUE_value(st, i) SKM_sk_value(CONF_VALUE, (st), (i))\n# define sk_CONF_VALUE_set(st, i, val) SKM_sk_set(CONF_VALUE, (st), (i), (val))\n# define sk_CONF_VALUE_zero(st) SKM_sk_zero(CONF_VALUE, (st))\n# define sk_CONF_VALUE_push(st, val) SKM_sk_push(CONF_VALUE, (st), (val))\n# define sk_CONF_VALUE_unshift(st, val) SKM_sk_unshift(CONF_VALUE, (st), (val))\n# define sk_CONF_VALUE_find(st, val) SKM_sk_find(CONF_VALUE, (st), (val))\n# define sk_CONF_VALUE_find_ex(st, val) SKM_sk_find_ex(CONF_VALUE, (st), (val))\n# define sk_CONF_VALUE_delete(st, i) SKM_sk_delete(CONF_VALUE, (st), (i))\n# define sk_CONF_VALUE_delete_ptr(st, ptr) SKM_sk_delete_ptr(CONF_VALUE, (st), (ptr))\n# define sk_CONF_VALUE_insert(st, val, i) SKM_sk_insert(CONF_VALUE, (st), (val), (i))\n# define sk_CONF_VALUE_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(CONF_VALUE, (st), (cmp))\n# define sk_CONF_VALUE_dup(st) SKM_sk_dup(CONF_VALUE, st)\n# define sk_CONF_VALUE_pop_free(st, free_func) SKM_sk_pop_free(CONF_VALUE, (st), (free_func))\n# define sk_CONF_VALUE_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(CONF_VALUE, (st), (copy_func), (free_func))\n# define sk_CONF_VALUE_shift(st) SKM_sk_shift(CONF_VALUE, (st))\n# define sk_CONF_VALUE_pop(st) SKM_sk_pop(CONF_VALUE, (st))\n# define sk_CONF_VALUE_sort(st) SKM_sk_sort(CONF_VALUE, (st))\n# define sk_CONF_VALUE_is_sorted(st) SKM_sk_is_sorted(CONF_VALUE, (st))\n# define sk_CRYPTO_EX_DATA_FUNCS_new(cmp) SKM_sk_new(CRYPTO_EX_DATA_FUNCS, (cmp))\n# define sk_CRYPTO_EX_DATA_FUNCS_new_null() SKM_sk_new_null(CRYPTO_EX_DATA_FUNCS)\n# define sk_CRYPTO_EX_DATA_FUNCS_free(st) SKM_sk_free(CRYPTO_EX_DATA_FUNCS, (st))\n# define sk_CRYPTO_EX_DATA_FUNCS_num(st) SKM_sk_num(CRYPTO_EX_DATA_FUNCS, (st))\n# define sk_CRYPTO_EX_DATA_FUNCS_value(st, i) SKM_sk_value(CRYPTO_EX_DATA_FUNCS, (st), (i))\n# define sk_CRYPTO_EX_DATA_FUNCS_set(st, i, val) SKM_sk_set(CRYPTO_EX_DATA_FUNCS, (st), (i), (val))\n# define sk_CRYPTO_EX_DATA_FUNCS_zero(st) SKM_sk_zero(CRYPTO_EX_DATA_FUNCS, (st))\n# define sk_CRYPTO_EX_DATA_FUNCS_push(st, val) SKM_sk_push(CRYPTO_EX_DATA_FUNCS, (st), (val))\n# define sk_CRYPTO_EX_DATA_FUNCS_unshift(st, val) SKM_sk_unshift(CRYPTO_EX_DATA_FUNCS, (st), (val))\n# define sk_CRYPTO_EX_DATA_FUNCS_find(st, val) SKM_sk_find(CRYPTO_EX_DATA_FUNCS, (st), (val))\n# define sk_CRYPTO_EX_DATA_FUNCS_find_ex(st, val) SKM_sk_find_ex(CRYPTO_EX_DATA_FUNCS, (st), (val))\n# define sk_CRYPTO_EX_DATA_FUNCS_delete(st, i) SKM_sk_delete(CRYPTO_EX_DATA_FUNCS, (st), (i))\n# define sk_CRYPTO_EX_DATA_FUNCS_delete_ptr(st, ptr) SKM_sk_delete_ptr(CRYPTO_EX_DATA_FUNCS, (st), (ptr))\n# define sk_CRYPTO_EX_DATA_FUNCS_insert(st, val, i) SKM_sk_insert(CRYPTO_EX_DATA_FUNCS, (st), (val), (i))\n# define sk_CRYPTO_EX_DATA_FUNCS_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(CRYPTO_EX_DATA_FUNCS, (st), (cmp))\n# define sk_CRYPTO_EX_DATA_FUNCS_dup(st) SKM_sk_dup(CRYPTO_EX_DATA_FUNCS, st)\n# define sk_CRYPTO_EX_DATA_FUNCS_pop_free(st, free_func) SKM_sk_pop_free(CRYPTO_EX_DATA_FUNCS, (st), (free_func))\n# define sk_CRYPTO_EX_DATA_FUNCS_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(CRYPTO_EX_DATA_FUNCS, (st), (copy_func), (free_func))\n# define sk_CRYPTO_EX_DATA_FUNCS_shift(st) SKM_sk_shift(CRYPTO_EX_DATA_FUNCS, (st))\n# define sk_CRYPTO_EX_DATA_FUNCS_pop(st) SKM_sk_pop(CRYPTO_EX_DATA_FUNCS, (st))\n# define sk_CRYPTO_EX_DATA_FUNCS_sort(st) SKM_sk_sort(CRYPTO_EX_DATA_FUNCS, (st))\n# define sk_CRYPTO_EX_DATA_FUNCS_is_sorted(st) SKM_sk_is_sorted(CRYPTO_EX_DATA_FUNCS, (st))\n# define sk_CRYPTO_dynlock_new(cmp) SKM_sk_new(CRYPTO_dynlock, (cmp))\n# define sk_CRYPTO_dynlock_new_null() SKM_sk_new_null(CRYPTO_dynlock)\n# define sk_CRYPTO_dynlock_free(st) SKM_sk_free(CRYPTO_dynlock, (st))\n# define sk_CRYPTO_dynlock_num(st) SKM_sk_num(CRYPTO_dynlock, (st))\n# define sk_CRYPTO_dynlock_value(st, i) SKM_sk_value(CRYPTO_dynlock, (st), (i))\n# define sk_CRYPTO_dynlock_set(st, i, val) SKM_sk_set(CRYPTO_dynlock, (st), (i), (val))\n# define sk_CRYPTO_dynlock_zero(st) SKM_sk_zero(CRYPTO_dynlock, (st))\n# define sk_CRYPTO_dynlock_push(st, val) SKM_sk_push(CRYPTO_dynlock, (st), (val))\n# define sk_CRYPTO_dynlock_unshift(st, val) SKM_sk_unshift(CRYPTO_dynlock, (st), (val))\n# define sk_CRYPTO_dynlock_find(st, val) SKM_sk_find(CRYPTO_dynlock, (st), (val))\n# define sk_CRYPTO_dynlock_find_ex(st, val) SKM_sk_find_ex(CRYPTO_dynlock, (st), (val))\n# define sk_CRYPTO_dynlock_delete(st, i) SKM_sk_delete(CRYPTO_dynlock, (st), (i))\n# define sk_CRYPTO_dynlock_delete_ptr(st, ptr) SKM_sk_delete_ptr(CRYPTO_dynlock, (st), (ptr))\n# define sk_CRYPTO_dynlock_insert(st, val, i) SKM_sk_insert(CRYPTO_dynlock, (st), (val), (i))\n# define sk_CRYPTO_dynlock_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(CRYPTO_dynlock, (st), (cmp))\n# define sk_CRYPTO_dynlock_dup(st) SKM_sk_dup(CRYPTO_dynlock, st)\n# define sk_CRYPTO_dynlock_pop_free(st, free_func) SKM_sk_pop_free(CRYPTO_dynlock, (st), (free_func))\n# define sk_CRYPTO_dynlock_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(CRYPTO_dynlock, (st), (copy_func), (free_func))\n# define sk_CRYPTO_dynlock_shift(st) SKM_sk_shift(CRYPTO_dynlock, (st))\n# define sk_CRYPTO_dynlock_pop(st) SKM_sk_pop(CRYPTO_dynlock, (st))\n# define sk_CRYPTO_dynlock_sort(st) SKM_sk_sort(CRYPTO_dynlock, (st))\n# define sk_CRYPTO_dynlock_is_sorted(st) SKM_sk_is_sorted(CRYPTO_dynlock, (st))\n# define sk_DIST_POINT_new(cmp) SKM_sk_new(DIST_POINT, (cmp))\n# define sk_DIST_POINT_new_null() SKM_sk_new_null(DIST_POINT)\n# define sk_DIST_POINT_free(st) SKM_sk_free(DIST_POINT, (st))\n# define sk_DIST_POINT_num(st) SKM_sk_num(DIST_POINT, (st))\n# define sk_DIST_POINT_value(st, i) SKM_sk_value(DIST_POINT, (st), (i))\n# define sk_DIST_POINT_set(st, i, val) SKM_sk_set(DIST_POINT, (st), (i), (val))\n# define sk_DIST_POINT_zero(st) SKM_sk_zero(DIST_POINT, (st))\n# define sk_DIST_POINT_push(st, val) SKM_sk_push(DIST_POINT, (st), (val))\n# define sk_DIST_POINT_unshift(st, val) SKM_sk_unshift(DIST_POINT, (st), (val))\n# define sk_DIST_POINT_find(st, val) SKM_sk_find(DIST_POINT, (st), (val))\n# define sk_DIST_POINT_find_ex(st, val) SKM_sk_find_ex(DIST_POINT, (st), (val))\n# define sk_DIST_POINT_delete(st, i) SKM_sk_delete(DIST_POINT, (st), (i))\n# define sk_DIST_POINT_delete_ptr(st, ptr) SKM_sk_delete_ptr(DIST_POINT, (st), (ptr))\n# define sk_DIST_POINT_insert(st, val, i) SKM_sk_insert(DIST_POINT, (st), (val), (i))\n# define sk_DIST_POINT_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(DIST_POINT, (st), (cmp))\n# define sk_DIST_POINT_dup(st) SKM_sk_dup(DIST_POINT, st)\n# define sk_DIST_POINT_pop_free(st, free_func) SKM_sk_pop_free(DIST_POINT, (st), (free_func))\n# define sk_DIST_POINT_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(DIST_POINT, (st), (copy_func), (free_func))\n# define sk_DIST_POINT_shift(st) SKM_sk_shift(DIST_POINT, (st))\n# define sk_DIST_POINT_pop(st) SKM_sk_pop(DIST_POINT, (st))\n# define sk_DIST_POINT_sort(st) SKM_sk_sort(DIST_POINT, (st))\n# define sk_DIST_POINT_is_sorted(st) SKM_sk_is_sorted(DIST_POINT, (st))\n# define sk_ENGINE_new(cmp) SKM_sk_new(ENGINE, (cmp))\n# define sk_ENGINE_new_null() SKM_sk_new_null(ENGINE)\n# define sk_ENGINE_free(st) SKM_sk_free(ENGINE, (st))\n# define sk_ENGINE_num(st) SKM_sk_num(ENGINE, (st))\n# define sk_ENGINE_value(st, i) SKM_sk_value(ENGINE, (st), (i))\n# define sk_ENGINE_set(st, i, val) SKM_sk_set(ENGINE, (st), (i), (val))\n# define sk_ENGINE_zero(st) SKM_sk_zero(ENGINE, (st))\n# define sk_ENGINE_push(st, val) SKM_sk_push(ENGINE, (st), (val))\n# define sk_ENGINE_unshift(st, val) SKM_sk_unshift(ENGINE, (st), (val))\n# define sk_ENGINE_find(st, val) SKM_sk_find(ENGINE, (st), (val))\n# define sk_ENGINE_find_ex(st, val) SKM_sk_find_ex(ENGINE, (st), (val))\n# define sk_ENGINE_delete(st, i) SKM_sk_delete(ENGINE, (st), (i))\n# define sk_ENGINE_delete_ptr(st, ptr) SKM_sk_delete_ptr(ENGINE, (st), (ptr))\n# define sk_ENGINE_insert(st, val, i) SKM_sk_insert(ENGINE, (st), (val), (i))\n# define sk_ENGINE_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(ENGINE, (st), (cmp))\n# define sk_ENGINE_dup(st) SKM_sk_dup(ENGINE, st)\n# define sk_ENGINE_pop_free(st, free_func) SKM_sk_pop_free(ENGINE, (st), (free_func))\n# define sk_ENGINE_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(ENGINE, (st), (copy_func), (free_func))\n# define sk_ENGINE_shift(st) SKM_sk_shift(ENGINE, (st))\n# define sk_ENGINE_pop(st) SKM_sk_pop(ENGINE, (st))\n# define sk_ENGINE_sort(st) SKM_sk_sort(ENGINE, (st))\n# define sk_ENGINE_is_sorted(st) SKM_sk_is_sorted(ENGINE, (st))\n# define sk_ENGINE_CLEANUP_ITEM_new(cmp) SKM_sk_new(ENGINE_CLEANUP_ITEM, (cmp))\n# define sk_ENGINE_CLEANUP_ITEM_new_null() SKM_sk_new_null(ENGINE_CLEANUP_ITEM)\n# define sk_ENGINE_CLEANUP_ITEM_free(st) SKM_sk_free(ENGINE_CLEANUP_ITEM, (st))\n# define sk_ENGINE_CLEANUP_ITEM_num(st) SKM_sk_num(ENGINE_CLEANUP_ITEM, (st))\n# define sk_ENGINE_CLEANUP_ITEM_value(st, i) SKM_sk_value(ENGINE_CLEANUP_ITEM, (st), (i))\n# define sk_ENGINE_CLEANUP_ITEM_set(st, i, val) SKM_sk_set(ENGINE_CLEANUP_ITEM, (st), (i), (val))\n# define sk_ENGINE_CLEANUP_ITEM_zero(st) SKM_sk_zero(ENGINE_CLEANUP_ITEM, (st))\n# define sk_ENGINE_CLEANUP_ITEM_push(st, val) SKM_sk_push(ENGINE_CLEANUP_ITEM, (st), (val))\n# define sk_ENGINE_CLEANUP_ITEM_unshift(st, val) SKM_sk_unshift(ENGINE_CLEANUP_ITEM, (st), (val))\n# define sk_ENGINE_CLEANUP_ITEM_find(st, val) SKM_sk_find(ENGINE_CLEANUP_ITEM, (st), (val))\n# define sk_ENGINE_CLEANUP_ITEM_find_ex(st, val) SKM_sk_find_ex(ENGINE_CLEANUP_ITEM, (st), (val))\n# define sk_ENGINE_CLEANUP_ITEM_delete(st, i) SKM_sk_delete(ENGINE_CLEANUP_ITEM, (st), (i))\n# define sk_ENGINE_CLEANUP_ITEM_delete_ptr(st, ptr) SKM_sk_delete_ptr(ENGINE_CLEANUP_ITEM, (st), (ptr))\n# define sk_ENGINE_CLEANUP_ITEM_insert(st, val, i) SKM_sk_insert(ENGINE_CLEANUP_ITEM, (st), (val), (i))\n# define sk_ENGINE_CLEANUP_ITEM_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(ENGINE_CLEANUP_ITEM, (st), (cmp))\n# define sk_ENGINE_CLEANUP_ITEM_dup(st) SKM_sk_dup(ENGINE_CLEANUP_ITEM, st)\n# define sk_ENGINE_CLEANUP_ITEM_pop_free(st, free_func) SKM_sk_pop_free(ENGINE_CLEANUP_ITEM, (st), (free_func))\n# define sk_ENGINE_CLEANUP_ITEM_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(ENGINE_CLEANUP_ITEM, (st), (copy_func), (free_func))\n# define sk_ENGINE_CLEANUP_ITEM_shift(st) SKM_sk_shift(ENGINE_CLEANUP_ITEM, (st))\n# define sk_ENGINE_CLEANUP_ITEM_pop(st) SKM_sk_pop(ENGINE_CLEANUP_ITEM, (st))\n# define sk_ENGINE_CLEANUP_ITEM_sort(st) SKM_sk_sort(ENGINE_CLEANUP_ITEM, (st))\n# define sk_ENGINE_CLEANUP_ITEM_is_sorted(st) SKM_sk_is_sorted(ENGINE_CLEANUP_ITEM, (st))\n# define sk_ESS_CERT_ID_new(cmp) SKM_sk_new(ESS_CERT_ID, (cmp))\n# define sk_ESS_CERT_ID_new_null() SKM_sk_new_null(ESS_CERT_ID)\n# define sk_ESS_CERT_ID_free(st) SKM_sk_free(ESS_CERT_ID, (st))\n# define sk_ESS_CERT_ID_num(st) SKM_sk_num(ESS_CERT_ID, (st))\n# define sk_ESS_CERT_ID_value(st, i) SKM_sk_value(ESS_CERT_ID, (st), (i))\n# define sk_ESS_CERT_ID_set(st, i, val) SKM_sk_set(ESS_CERT_ID, (st), (i), (val))\n# define sk_ESS_CERT_ID_zero(st) SKM_sk_zero(ESS_CERT_ID, (st))\n# define sk_ESS_CERT_ID_push(st, val) SKM_sk_push(ESS_CERT_ID, (st), (val))\n# define sk_ESS_CERT_ID_unshift(st, val) SKM_sk_unshift(ESS_CERT_ID, (st), (val))\n# define sk_ESS_CERT_ID_find(st, val) SKM_sk_find(ESS_CERT_ID, (st), (val))\n# define sk_ESS_CERT_ID_find_ex(st, val) SKM_sk_find_ex(ESS_CERT_ID, (st), (val))\n# define sk_ESS_CERT_ID_delete(st, i) SKM_sk_delete(ESS_CERT_ID, (st), (i))\n# define sk_ESS_CERT_ID_delete_ptr(st, ptr) SKM_sk_delete_ptr(ESS_CERT_ID, (st), (ptr))\n# define sk_ESS_CERT_ID_insert(st, val, i) SKM_sk_insert(ESS_CERT_ID, (st), (val), (i))\n# define sk_ESS_CERT_ID_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(ESS_CERT_ID, (st), (cmp))\n# define sk_ESS_CERT_ID_dup(st) SKM_sk_dup(ESS_CERT_ID, st)\n# define sk_ESS_CERT_ID_pop_free(st, free_func) SKM_sk_pop_free(ESS_CERT_ID, (st), (free_func))\n# define sk_ESS_CERT_ID_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(ESS_CERT_ID, (st), (copy_func), (free_func))\n# define sk_ESS_CERT_ID_shift(st) SKM_sk_shift(ESS_CERT_ID, (st))\n# define sk_ESS_CERT_ID_pop(st) SKM_sk_pop(ESS_CERT_ID, (st))\n# define sk_ESS_CERT_ID_sort(st) SKM_sk_sort(ESS_CERT_ID, (st))\n# define sk_ESS_CERT_ID_is_sorted(st) SKM_sk_is_sorted(ESS_CERT_ID, (st))\n# define sk_EVP_MD_new(cmp) SKM_sk_new(EVP_MD, (cmp))\n# define sk_EVP_MD_new_null() SKM_sk_new_null(EVP_MD)\n# define sk_EVP_MD_free(st) SKM_sk_free(EVP_MD, (st))\n# define sk_EVP_MD_num(st) SKM_sk_num(EVP_MD, (st))\n# define sk_EVP_MD_value(st, i) SKM_sk_value(EVP_MD, (st), (i))\n# define sk_EVP_MD_set(st, i, val) SKM_sk_set(EVP_MD, (st), (i), (val))\n# define sk_EVP_MD_zero(st) SKM_sk_zero(EVP_MD, (st))\n# define sk_EVP_MD_push(st, val) SKM_sk_push(EVP_MD, (st), (val))\n# define sk_EVP_MD_unshift(st, val) SKM_sk_unshift(EVP_MD, (st), (val))\n# define sk_EVP_MD_find(st, val) SKM_sk_find(EVP_MD, (st), (val))\n# define sk_EVP_MD_find_ex(st, val) SKM_sk_find_ex(EVP_MD, (st), (val))\n# define sk_EVP_MD_delete(st, i) SKM_sk_delete(EVP_MD, (st), (i))\n# define sk_EVP_MD_delete_ptr(st, ptr) SKM_sk_delete_ptr(EVP_MD, (st), (ptr))\n# define sk_EVP_MD_insert(st, val, i) SKM_sk_insert(EVP_MD, (st), (val), (i))\n# define sk_EVP_MD_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(EVP_MD, (st), (cmp))\n# define sk_EVP_MD_dup(st) SKM_sk_dup(EVP_MD, st)\n# define sk_EVP_MD_pop_free(st, free_func) SKM_sk_pop_free(EVP_MD, (st), (free_func))\n# define sk_EVP_MD_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(EVP_MD, (st), (copy_func), (free_func))\n# define sk_EVP_MD_shift(st) SKM_sk_shift(EVP_MD, (st))\n# define sk_EVP_MD_pop(st) SKM_sk_pop(EVP_MD, (st))\n# define sk_EVP_MD_sort(st) SKM_sk_sort(EVP_MD, (st))\n# define sk_EVP_MD_is_sorted(st) SKM_sk_is_sorted(EVP_MD, (st))\n# define sk_EVP_PBE_CTL_new(cmp) SKM_sk_new(EVP_PBE_CTL, (cmp))\n# define sk_EVP_PBE_CTL_new_null() SKM_sk_new_null(EVP_PBE_CTL)\n# define sk_EVP_PBE_CTL_free(st) SKM_sk_free(EVP_PBE_CTL, (st))\n# define sk_EVP_PBE_CTL_num(st) SKM_sk_num(EVP_PBE_CTL, (st))\n# define sk_EVP_PBE_CTL_value(st, i) SKM_sk_value(EVP_PBE_CTL, (st), (i))\n# define sk_EVP_PBE_CTL_set(st, i, val) SKM_sk_set(EVP_PBE_CTL, (st), (i), (val))\n# define sk_EVP_PBE_CTL_zero(st) SKM_sk_zero(EVP_PBE_CTL, (st))\n# define sk_EVP_PBE_CTL_push(st, val) SKM_sk_push(EVP_PBE_CTL, (st), (val))\n# define sk_EVP_PBE_CTL_unshift(st, val) SKM_sk_unshift(EVP_PBE_CTL, (st), (val))\n# define sk_EVP_PBE_CTL_find(st, val) SKM_sk_find(EVP_PBE_CTL, (st), (val))\n# define sk_EVP_PBE_CTL_find_ex(st, val) SKM_sk_find_ex(EVP_PBE_CTL, (st), (val))\n# define sk_EVP_PBE_CTL_delete(st, i) SKM_sk_delete(EVP_PBE_CTL, (st), (i))\n# define sk_EVP_PBE_CTL_delete_ptr(st, ptr) SKM_sk_delete_ptr(EVP_PBE_CTL, (st), (ptr))\n# define sk_EVP_PBE_CTL_insert(st, val, i) SKM_sk_insert(EVP_PBE_CTL, (st), (val), (i))\n# define sk_EVP_PBE_CTL_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(EVP_PBE_CTL, (st), (cmp))\n# define sk_EVP_PBE_CTL_dup(st) SKM_sk_dup(EVP_PBE_CTL, st)\n# define sk_EVP_PBE_CTL_pop_free(st, free_func) SKM_sk_pop_free(EVP_PBE_CTL, (st), (free_func))\n# define sk_EVP_PBE_CTL_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(EVP_PBE_CTL, (st), (copy_func), (free_func))\n# define sk_EVP_PBE_CTL_shift(st) SKM_sk_shift(EVP_PBE_CTL, (st))\n# define sk_EVP_PBE_CTL_pop(st) SKM_sk_pop(EVP_PBE_CTL, (st))\n# define sk_EVP_PBE_CTL_sort(st) SKM_sk_sort(EVP_PBE_CTL, (st))\n# define sk_EVP_PBE_CTL_is_sorted(st) SKM_sk_is_sorted(EVP_PBE_CTL, (st))\n# define sk_EVP_PKEY_ASN1_METHOD_new(cmp) SKM_sk_new(EVP_PKEY_ASN1_METHOD, (cmp))\n# define sk_EVP_PKEY_ASN1_METHOD_new_null() SKM_sk_new_null(EVP_PKEY_ASN1_METHOD)\n# define sk_EVP_PKEY_ASN1_METHOD_free(st) SKM_sk_free(EVP_PKEY_ASN1_METHOD, (st))\n# define sk_EVP_PKEY_ASN1_METHOD_num(st) SKM_sk_num(EVP_PKEY_ASN1_METHOD, (st))\n# define sk_EVP_PKEY_ASN1_METHOD_value(st, i) SKM_sk_value(EVP_PKEY_ASN1_METHOD, (st), (i))\n# define sk_EVP_PKEY_ASN1_METHOD_set(st, i, val) SKM_sk_set(EVP_PKEY_ASN1_METHOD, (st), (i), (val))\n# define sk_EVP_PKEY_ASN1_METHOD_zero(st) SKM_sk_zero(EVP_PKEY_ASN1_METHOD, (st))\n# define sk_EVP_PKEY_ASN1_METHOD_push(st, val) SKM_sk_push(EVP_PKEY_ASN1_METHOD, (st), (val))\n# define sk_EVP_PKEY_ASN1_METHOD_unshift(st, val) SKM_sk_unshift(EVP_PKEY_ASN1_METHOD, (st), (val))\n# define sk_EVP_PKEY_ASN1_METHOD_find(st, val) SKM_sk_find(EVP_PKEY_ASN1_METHOD, (st), (val))\n# define sk_EVP_PKEY_ASN1_METHOD_find_ex(st, val) SKM_sk_find_ex(EVP_PKEY_ASN1_METHOD, (st), (val))\n# define sk_EVP_PKEY_ASN1_METHOD_delete(st, i) SKM_sk_delete(EVP_PKEY_ASN1_METHOD, (st), (i))\n# define sk_EVP_PKEY_ASN1_METHOD_delete_ptr(st, ptr) SKM_sk_delete_ptr(EVP_PKEY_ASN1_METHOD, (st), (ptr))\n# define sk_EVP_PKEY_ASN1_METHOD_insert(st, val, i) SKM_sk_insert(EVP_PKEY_ASN1_METHOD, (st), (val), (i))\n# define sk_EVP_PKEY_ASN1_METHOD_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(EVP_PKEY_ASN1_METHOD, (st), (cmp))\n# define sk_EVP_PKEY_ASN1_METHOD_dup(st) SKM_sk_dup(EVP_PKEY_ASN1_METHOD, st)\n# define sk_EVP_PKEY_ASN1_METHOD_pop_free(st, free_func) SKM_sk_pop_free(EVP_PKEY_ASN1_METHOD, (st), (free_func))\n# define sk_EVP_PKEY_ASN1_METHOD_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(EVP_PKEY_ASN1_METHOD, (st), (copy_func), (free_func))\n# define sk_EVP_PKEY_ASN1_METHOD_shift(st) SKM_sk_shift(EVP_PKEY_ASN1_METHOD, (st))\n# define sk_EVP_PKEY_ASN1_METHOD_pop(st) SKM_sk_pop(EVP_PKEY_ASN1_METHOD, (st))\n# define sk_EVP_PKEY_ASN1_METHOD_sort(st) SKM_sk_sort(EVP_PKEY_ASN1_METHOD, (st))\n# define sk_EVP_PKEY_ASN1_METHOD_is_sorted(st) SKM_sk_is_sorted(EVP_PKEY_ASN1_METHOD, (st))\n# define sk_EVP_PKEY_METHOD_new(cmp) SKM_sk_new(EVP_PKEY_METHOD, (cmp))\n# define sk_EVP_PKEY_METHOD_new_null() SKM_sk_new_null(EVP_PKEY_METHOD)\n# define sk_EVP_PKEY_METHOD_free(st) SKM_sk_free(EVP_PKEY_METHOD, (st))\n# define sk_EVP_PKEY_METHOD_num(st) SKM_sk_num(EVP_PKEY_METHOD, (st))\n# define sk_EVP_PKEY_METHOD_value(st, i) SKM_sk_value(EVP_PKEY_METHOD, (st), (i))\n# define sk_EVP_PKEY_METHOD_set(st, i, val) SKM_sk_set(EVP_PKEY_METHOD, (st), (i), (val))\n# define sk_EVP_PKEY_METHOD_zero(st) SKM_sk_zero(EVP_PKEY_METHOD, (st))\n# define sk_EVP_PKEY_METHOD_push(st, val) SKM_sk_push(EVP_PKEY_METHOD, (st), (val))\n# define sk_EVP_PKEY_METHOD_unshift(st, val) SKM_sk_unshift(EVP_PKEY_METHOD, (st), (val))\n# define sk_EVP_PKEY_METHOD_find(st, val) SKM_sk_find(EVP_PKEY_METHOD, (st), (val))\n# define sk_EVP_PKEY_METHOD_find_ex(st, val) SKM_sk_find_ex(EVP_PKEY_METHOD, (st), (val))\n# define sk_EVP_PKEY_METHOD_delete(st, i) SKM_sk_delete(EVP_PKEY_METHOD, (st), (i))\n# define sk_EVP_PKEY_METHOD_delete_ptr(st, ptr) SKM_sk_delete_ptr(EVP_PKEY_METHOD, (st), (ptr))\n# define sk_EVP_PKEY_METHOD_insert(st, val, i) SKM_sk_insert(EVP_PKEY_METHOD, (st), (val), (i))\n# define sk_EVP_PKEY_METHOD_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(EVP_PKEY_METHOD, (st), (cmp))\n# define sk_EVP_PKEY_METHOD_dup(st) SKM_sk_dup(EVP_PKEY_METHOD, st)\n# define sk_EVP_PKEY_METHOD_pop_free(st, free_func) SKM_sk_pop_free(EVP_PKEY_METHOD, (st), (free_func))\n# define sk_EVP_PKEY_METHOD_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(EVP_PKEY_METHOD, (st), (copy_func), (free_func))\n# define sk_EVP_PKEY_METHOD_shift(st) SKM_sk_shift(EVP_PKEY_METHOD, (st))\n# define sk_EVP_PKEY_METHOD_pop(st) SKM_sk_pop(EVP_PKEY_METHOD, (st))\n# define sk_EVP_PKEY_METHOD_sort(st) SKM_sk_sort(EVP_PKEY_METHOD, (st))\n# define sk_EVP_PKEY_METHOD_is_sorted(st) SKM_sk_is_sorted(EVP_PKEY_METHOD, (st))\n# define sk_GENERAL_NAME_new(cmp) SKM_sk_new(GENERAL_NAME, (cmp))\n# define sk_GENERAL_NAME_new_null() SKM_sk_new_null(GENERAL_NAME)\n# define sk_GENERAL_NAME_free(st) SKM_sk_free(GENERAL_NAME, (st))\n# define sk_GENERAL_NAME_num(st) SKM_sk_num(GENERAL_NAME, (st))\n# define sk_GENERAL_NAME_value(st, i) SKM_sk_value(GENERAL_NAME, (st), (i))\n# define sk_GENERAL_NAME_set(st, i, val) SKM_sk_set(GENERAL_NAME, (st), (i), (val))\n# define sk_GENERAL_NAME_zero(st) SKM_sk_zero(GENERAL_NAME, (st))\n# define sk_GENERAL_NAME_push(st, val) SKM_sk_push(GENERAL_NAME, (st), (val))\n# define sk_GENERAL_NAME_unshift(st, val) SKM_sk_unshift(GENERAL_NAME, (st), (val))\n# define sk_GENERAL_NAME_find(st, val) SKM_sk_find(GENERAL_NAME, (st), (val))\n# define sk_GENERAL_NAME_find_ex(st, val) SKM_sk_find_ex(GENERAL_NAME, (st), (val))\n# define sk_GENERAL_NAME_delete(st, i) SKM_sk_delete(GENERAL_NAME, (st), (i))\n# define sk_GENERAL_NAME_delete_ptr(st, ptr) SKM_sk_delete_ptr(GENERAL_NAME, (st), (ptr))\n# define sk_GENERAL_NAME_insert(st, val, i) SKM_sk_insert(GENERAL_NAME, (st), (val), (i))\n# define sk_GENERAL_NAME_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(GENERAL_NAME, (st), (cmp))\n# define sk_GENERAL_NAME_dup(st) SKM_sk_dup(GENERAL_NAME, st)\n# define sk_GENERAL_NAME_pop_free(st, free_func) SKM_sk_pop_free(GENERAL_NAME, (st), (free_func))\n# define sk_GENERAL_NAME_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(GENERAL_NAME, (st), (copy_func), (free_func))\n# define sk_GENERAL_NAME_shift(st) SKM_sk_shift(GENERAL_NAME, (st))\n# define sk_GENERAL_NAME_pop(st) SKM_sk_pop(GENERAL_NAME, (st))\n# define sk_GENERAL_NAME_sort(st) SKM_sk_sort(GENERAL_NAME, (st))\n# define sk_GENERAL_NAME_is_sorted(st) SKM_sk_is_sorted(GENERAL_NAME, (st))\n# define sk_GENERAL_NAMES_new(cmp) SKM_sk_new(GENERAL_NAMES, (cmp))\n# define sk_GENERAL_NAMES_new_null() SKM_sk_new_null(GENERAL_NAMES)\n# define sk_GENERAL_NAMES_free(st) SKM_sk_free(GENERAL_NAMES, (st))\n# define sk_GENERAL_NAMES_num(st) SKM_sk_num(GENERAL_NAMES, (st))\n# define sk_GENERAL_NAMES_value(st, i) SKM_sk_value(GENERAL_NAMES, (st), (i))\n# define sk_GENERAL_NAMES_set(st, i, val) SKM_sk_set(GENERAL_NAMES, (st), (i), (val))\n# define sk_GENERAL_NAMES_zero(st) SKM_sk_zero(GENERAL_NAMES, (st))\n# define sk_GENERAL_NAMES_push(st, val) SKM_sk_push(GENERAL_NAMES, (st), (val))\n# define sk_GENERAL_NAMES_unshift(st, val) SKM_sk_unshift(GENERAL_NAMES, (st), (val))\n# define sk_GENERAL_NAMES_find(st, val) SKM_sk_find(GENERAL_NAMES, (st), (val))\n# define sk_GENERAL_NAMES_find_ex(st, val) SKM_sk_find_ex(GENERAL_NAMES, (st), (val))\n# define sk_GENERAL_NAMES_delete(st, i) SKM_sk_delete(GENERAL_NAMES, (st), (i))\n# define sk_GENERAL_NAMES_delete_ptr(st, ptr) SKM_sk_delete_ptr(GENERAL_NAMES, (st), (ptr))\n# define sk_GENERAL_NAMES_insert(st, val, i) SKM_sk_insert(GENERAL_NAMES, (st), (val), (i))\n# define sk_GENERAL_NAMES_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(GENERAL_NAMES, (st), (cmp))\n# define sk_GENERAL_NAMES_dup(st) SKM_sk_dup(GENERAL_NAMES, st)\n# define sk_GENERAL_NAMES_pop_free(st, free_func) SKM_sk_pop_free(GENERAL_NAMES, (st), (free_func))\n# define sk_GENERAL_NAMES_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(GENERAL_NAMES, (st), (copy_func), (free_func))\n# define sk_GENERAL_NAMES_shift(st) SKM_sk_shift(GENERAL_NAMES, (st))\n# define sk_GENERAL_NAMES_pop(st) SKM_sk_pop(GENERAL_NAMES, (st))\n# define sk_GENERAL_NAMES_sort(st) SKM_sk_sort(GENERAL_NAMES, (st))\n# define sk_GENERAL_NAMES_is_sorted(st) SKM_sk_is_sorted(GENERAL_NAMES, (st))\n# define sk_GENERAL_SUBTREE_new(cmp) SKM_sk_new(GENERAL_SUBTREE, (cmp))\n# define sk_GENERAL_SUBTREE_new_null() SKM_sk_new_null(GENERAL_SUBTREE)\n# define sk_GENERAL_SUBTREE_free(st) SKM_sk_free(GENERAL_SUBTREE, (st))\n# define sk_GENERAL_SUBTREE_num(st) SKM_sk_num(GENERAL_SUBTREE, (st))\n# define sk_GENERAL_SUBTREE_value(st, i) SKM_sk_value(GENERAL_SUBTREE, (st), (i))\n# define sk_GENERAL_SUBTREE_set(st, i, val) SKM_sk_set(GENERAL_SUBTREE, (st), (i), (val))\n# define sk_GENERAL_SUBTREE_zero(st) SKM_sk_zero(GENERAL_SUBTREE, (st))\n# define sk_GENERAL_SUBTREE_push(st, val) SKM_sk_push(GENERAL_SUBTREE, (st), (val))\n# define sk_GENERAL_SUBTREE_unshift(st, val) SKM_sk_unshift(GENERAL_SUBTREE, (st), (val))\n# define sk_GENERAL_SUBTREE_find(st, val) SKM_sk_find(GENERAL_SUBTREE, (st), (val))\n# define sk_GENERAL_SUBTREE_find_ex(st, val) SKM_sk_find_ex(GENERAL_SUBTREE, (st), (val))\n# define sk_GENERAL_SUBTREE_delete(st, i) SKM_sk_delete(GENERAL_SUBTREE, (st), (i))\n# define sk_GENERAL_SUBTREE_delete_ptr(st, ptr) SKM_sk_delete_ptr(GENERAL_SUBTREE, (st), (ptr))\n# define sk_GENERAL_SUBTREE_insert(st, val, i) SKM_sk_insert(GENERAL_SUBTREE, (st), (val), (i))\n# define sk_GENERAL_SUBTREE_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(GENERAL_SUBTREE, (st), (cmp))\n# define sk_GENERAL_SUBTREE_dup(st) SKM_sk_dup(GENERAL_SUBTREE, st)\n# define sk_GENERAL_SUBTREE_pop_free(st, free_func) SKM_sk_pop_free(GENERAL_SUBTREE, (st), (free_func))\n# define sk_GENERAL_SUBTREE_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(GENERAL_SUBTREE, (st), (copy_func), (free_func))\n# define sk_GENERAL_SUBTREE_shift(st) SKM_sk_shift(GENERAL_SUBTREE, (st))\n# define sk_GENERAL_SUBTREE_pop(st) SKM_sk_pop(GENERAL_SUBTREE, (st))\n# define sk_GENERAL_SUBTREE_sort(st) SKM_sk_sort(GENERAL_SUBTREE, (st))\n# define sk_GENERAL_SUBTREE_is_sorted(st) SKM_sk_is_sorted(GENERAL_SUBTREE, (st))\n# define sk_IPAddressFamily_new(cmp) SKM_sk_new(IPAddressFamily, (cmp))\n# define sk_IPAddressFamily_new_null() SKM_sk_new_null(IPAddressFamily)\n# define sk_IPAddressFamily_free(st) SKM_sk_free(IPAddressFamily, (st))\n# define sk_IPAddressFamily_num(st) SKM_sk_num(IPAddressFamily, (st))\n# define sk_IPAddressFamily_value(st, i) SKM_sk_value(IPAddressFamily, (st), (i))\n# define sk_IPAddressFamily_set(st, i, val) SKM_sk_set(IPAddressFamily, (st), (i), (val))\n# define sk_IPAddressFamily_zero(st) SKM_sk_zero(IPAddressFamily, (st))\n# define sk_IPAddressFamily_push(st, val) SKM_sk_push(IPAddressFamily, (st), (val))\n# define sk_IPAddressFamily_unshift(st, val) SKM_sk_unshift(IPAddressFamily, (st), (val))\n# define sk_IPAddressFamily_find(st, val) SKM_sk_find(IPAddressFamily, (st), (val))\n# define sk_IPAddressFamily_find_ex(st, val) SKM_sk_find_ex(IPAddressFamily, (st), (val))\n# define sk_IPAddressFamily_delete(st, i) SKM_sk_delete(IPAddressFamily, (st), (i))\n# define sk_IPAddressFamily_delete_ptr(st, ptr) SKM_sk_delete_ptr(IPAddressFamily, (st), (ptr))\n# define sk_IPAddressFamily_insert(st, val, i) SKM_sk_insert(IPAddressFamily, (st), (val), (i))\n# define sk_IPAddressFamily_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(IPAddressFamily, (st), (cmp))\n# define sk_IPAddressFamily_dup(st) SKM_sk_dup(IPAddressFamily, st)\n# define sk_IPAddressFamily_pop_free(st, free_func) SKM_sk_pop_free(IPAddressFamily, (st), (free_func))\n# define sk_IPAddressFamily_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(IPAddressFamily, (st), (copy_func), (free_func))\n# define sk_IPAddressFamily_shift(st) SKM_sk_shift(IPAddressFamily, (st))\n# define sk_IPAddressFamily_pop(st) SKM_sk_pop(IPAddressFamily, (st))\n# define sk_IPAddressFamily_sort(st) SKM_sk_sort(IPAddressFamily, (st))\n# define sk_IPAddressFamily_is_sorted(st) SKM_sk_is_sorted(IPAddressFamily, (st))\n# define sk_IPAddressOrRange_new(cmp) SKM_sk_new(IPAddressOrRange, (cmp))\n# define sk_IPAddressOrRange_new_null() SKM_sk_new_null(IPAddressOrRange)\n# define sk_IPAddressOrRange_free(st) SKM_sk_free(IPAddressOrRange, (st))\n# define sk_IPAddressOrRange_num(st) SKM_sk_num(IPAddressOrRange, (st))\n# define sk_IPAddressOrRange_value(st, i) SKM_sk_value(IPAddressOrRange, (st), (i))\n# define sk_IPAddressOrRange_set(st, i, val) SKM_sk_set(IPAddressOrRange, (st), (i), (val))\n# define sk_IPAddressOrRange_zero(st) SKM_sk_zero(IPAddressOrRange, (st))\n# define sk_IPAddressOrRange_push(st, val) SKM_sk_push(IPAddressOrRange, (st), (val))\n# define sk_IPAddressOrRange_unshift(st, val) SKM_sk_unshift(IPAddressOrRange, (st), (val))\n# define sk_IPAddressOrRange_find(st, val) SKM_sk_find(IPAddressOrRange, (st), (val))\n# define sk_IPAddressOrRange_find_ex(st, val) SKM_sk_find_ex(IPAddressOrRange, (st), (val))\n# define sk_IPAddressOrRange_delete(st, i) SKM_sk_delete(IPAddressOrRange, (st), (i))\n# define sk_IPAddressOrRange_delete_ptr(st, ptr) SKM_sk_delete_ptr(IPAddressOrRange, (st), (ptr))\n# define sk_IPAddressOrRange_insert(st, val, i) SKM_sk_insert(IPAddressOrRange, (st), (val), (i))\n# define sk_IPAddressOrRange_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(IPAddressOrRange, (st), (cmp))\n# define sk_IPAddressOrRange_dup(st) SKM_sk_dup(IPAddressOrRange, st)\n# define sk_IPAddressOrRange_pop_free(st, free_func) SKM_sk_pop_free(IPAddressOrRange, (st), (free_func))\n# define sk_IPAddressOrRange_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(IPAddressOrRange, (st), (copy_func), (free_func))\n# define sk_IPAddressOrRange_shift(st) SKM_sk_shift(IPAddressOrRange, (st))\n# define sk_IPAddressOrRange_pop(st) SKM_sk_pop(IPAddressOrRange, (st))\n# define sk_IPAddressOrRange_sort(st) SKM_sk_sort(IPAddressOrRange, (st))\n# define sk_IPAddressOrRange_is_sorted(st) SKM_sk_is_sorted(IPAddressOrRange, (st))\n# define sk_KRB5_APREQBODY_new(cmp) SKM_sk_new(KRB5_APREQBODY, (cmp))\n# define sk_KRB5_APREQBODY_new_null() SKM_sk_new_null(KRB5_APREQBODY)\n# define sk_KRB5_APREQBODY_free(st) SKM_sk_free(KRB5_APREQBODY, (st))\n# define sk_KRB5_APREQBODY_num(st) SKM_sk_num(KRB5_APREQBODY, (st))\n# define sk_KRB5_APREQBODY_value(st, i) SKM_sk_value(KRB5_APREQBODY, (st), (i))\n# define sk_KRB5_APREQBODY_set(st, i, val) SKM_sk_set(KRB5_APREQBODY, (st), (i), (val))\n# define sk_KRB5_APREQBODY_zero(st) SKM_sk_zero(KRB5_APREQBODY, (st))\n# define sk_KRB5_APREQBODY_push(st, val) SKM_sk_push(KRB5_APREQBODY, (st), (val))\n# define sk_KRB5_APREQBODY_unshift(st, val) SKM_sk_unshift(KRB5_APREQBODY, (st), (val))\n# define sk_KRB5_APREQBODY_find(st, val) SKM_sk_find(KRB5_APREQBODY, (st), (val))\n# define sk_KRB5_APREQBODY_find_ex(st, val) SKM_sk_find_ex(KRB5_APREQBODY, (st), (val))\n# define sk_KRB5_APREQBODY_delete(st, i) SKM_sk_delete(KRB5_APREQBODY, (st), (i))\n# define sk_KRB5_APREQBODY_delete_ptr(st, ptr) SKM_sk_delete_ptr(KRB5_APREQBODY, (st), (ptr))\n# define sk_KRB5_APREQBODY_insert(st, val, i) SKM_sk_insert(KRB5_APREQBODY, (st), (val), (i))\n# define sk_KRB5_APREQBODY_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(KRB5_APREQBODY, (st), (cmp))\n# define sk_KRB5_APREQBODY_dup(st) SKM_sk_dup(KRB5_APREQBODY, st)\n# define sk_KRB5_APREQBODY_pop_free(st, free_func) SKM_sk_pop_free(KRB5_APREQBODY, (st), (free_func))\n# define sk_KRB5_APREQBODY_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(KRB5_APREQBODY, (st), (copy_func), (free_func))\n# define sk_KRB5_APREQBODY_shift(st) SKM_sk_shift(KRB5_APREQBODY, (st))\n# define sk_KRB5_APREQBODY_pop(st) SKM_sk_pop(KRB5_APREQBODY, (st))\n# define sk_KRB5_APREQBODY_sort(st) SKM_sk_sort(KRB5_APREQBODY, (st))\n# define sk_KRB5_APREQBODY_is_sorted(st) SKM_sk_is_sorted(KRB5_APREQBODY, (st))\n# define sk_KRB5_AUTHDATA_new(cmp) SKM_sk_new(KRB5_AUTHDATA, (cmp))\n# define sk_KRB5_AUTHDATA_new_null() SKM_sk_new_null(KRB5_AUTHDATA)\n# define sk_KRB5_AUTHDATA_free(st) SKM_sk_free(KRB5_AUTHDATA, (st))\n# define sk_KRB5_AUTHDATA_num(st) SKM_sk_num(KRB5_AUTHDATA, (st))\n# define sk_KRB5_AUTHDATA_value(st, i) SKM_sk_value(KRB5_AUTHDATA, (st), (i))\n# define sk_KRB5_AUTHDATA_set(st, i, val) SKM_sk_set(KRB5_AUTHDATA, (st), (i), (val))\n# define sk_KRB5_AUTHDATA_zero(st) SKM_sk_zero(KRB5_AUTHDATA, (st))\n# define sk_KRB5_AUTHDATA_push(st, val) SKM_sk_push(KRB5_AUTHDATA, (st), (val))\n# define sk_KRB5_AUTHDATA_unshift(st, val) SKM_sk_unshift(KRB5_AUTHDATA, (st), (val))\n# define sk_KRB5_AUTHDATA_find(st, val) SKM_sk_find(KRB5_AUTHDATA, (st), (val))\n# define sk_KRB5_AUTHDATA_find_ex(st, val) SKM_sk_find_ex(KRB5_AUTHDATA, (st), (val))\n# define sk_KRB5_AUTHDATA_delete(st, i) SKM_sk_delete(KRB5_AUTHDATA, (st), (i))\n# define sk_KRB5_AUTHDATA_delete_ptr(st, ptr) SKM_sk_delete_ptr(KRB5_AUTHDATA, (st), (ptr))\n# define sk_KRB5_AUTHDATA_insert(st, val, i) SKM_sk_insert(KRB5_AUTHDATA, (st), (val), (i))\n# define sk_KRB5_AUTHDATA_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(KRB5_AUTHDATA, (st), (cmp))\n# define sk_KRB5_AUTHDATA_dup(st) SKM_sk_dup(KRB5_AUTHDATA, st)\n# define sk_KRB5_AUTHDATA_pop_free(st, free_func) SKM_sk_pop_free(KRB5_AUTHDATA, (st), (free_func))\n# define sk_KRB5_AUTHDATA_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(KRB5_AUTHDATA, (st), (copy_func), (free_func))\n# define sk_KRB5_AUTHDATA_shift(st) SKM_sk_shift(KRB5_AUTHDATA, (st))\n# define sk_KRB5_AUTHDATA_pop(st) SKM_sk_pop(KRB5_AUTHDATA, (st))\n# define sk_KRB5_AUTHDATA_sort(st) SKM_sk_sort(KRB5_AUTHDATA, (st))\n# define sk_KRB5_AUTHDATA_is_sorted(st) SKM_sk_is_sorted(KRB5_AUTHDATA, (st))\n# define sk_KRB5_AUTHENTBODY_new(cmp) SKM_sk_new(KRB5_AUTHENTBODY, (cmp))\n# define sk_KRB5_AUTHENTBODY_new_null() SKM_sk_new_null(KRB5_AUTHENTBODY)\n# define sk_KRB5_AUTHENTBODY_free(st) SKM_sk_free(KRB5_AUTHENTBODY, (st))\n# define sk_KRB5_AUTHENTBODY_num(st) SKM_sk_num(KRB5_AUTHENTBODY, (st))\n# define sk_KRB5_AUTHENTBODY_value(st, i) SKM_sk_value(KRB5_AUTHENTBODY, (st), (i))\n# define sk_KRB5_AUTHENTBODY_set(st, i, val) SKM_sk_set(KRB5_AUTHENTBODY, (st), (i), (val))\n# define sk_KRB5_AUTHENTBODY_zero(st) SKM_sk_zero(KRB5_AUTHENTBODY, (st))\n# define sk_KRB5_AUTHENTBODY_push(st, val) SKM_sk_push(KRB5_AUTHENTBODY, (st), (val))\n# define sk_KRB5_AUTHENTBODY_unshift(st, val) SKM_sk_unshift(KRB5_AUTHENTBODY, (st), (val))\n# define sk_KRB5_AUTHENTBODY_find(st, val) SKM_sk_find(KRB5_AUTHENTBODY, (st), (val))\n# define sk_KRB5_AUTHENTBODY_find_ex(st, val) SKM_sk_find_ex(KRB5_AUTHENTBODY, (st), (val))\n# define sk_KRB5_AUTHENTBODY_delete(st, i) SKM_sk_delete(KRB5_AUTHENTBODY, (st), (i))\n# define sk_KRB5_AUTHENTBODY_delete_ptr(st, ptr) SKM_sk_delete_ptr(KRB5_AUTHENTBODY, (st), (ptr))\n# define sk_KRB5_AUTHENTBODY_insert(st, val, i) SKM_sk_insert(KRB5_AUTHENTBODY, (st), (val), (i))\n# define sk_KRB5_AUTHENTBODY_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(KRB5_AUTHENTBODY, (st), (cmp))\n# define sk_KRB5_AUTHENTBODY_dup(st) SKM_sk_dup(KRB5_AUTHENTBODY, st)\n# define sk_KRB5_AUTHENTBODY_pop_free(st, free_func) SKM_sk_pop_free(KRB5_AUTHENTBODY, (st), (free_func))\n# define sk_KRB5_AUTHENTBODY_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(KRB5_AUTHENTBODY, (st), (copy_func), (free_func))\n# define sk_KRB5_AUTHENTBODY_shift(st) SKM_sk_shift(KRB5_AUTHENTBODY, (st))\n# define sk_KRB5_AUTHENTBODY_pop(st) SKM_sk_pop(KRB5_AUTHENTBODY, (st))\n# define sk_KRB5_AUTHENTBODY_sort(st) SKM_sk_sort(KRB5_AUTHENTBODY, (st))\n# define sk_KRB5_AUTHENTBODY_is_sorted(st) SKM_sk_is_sorted(KRB5_AUTHENTBODY, (st))\n# define sk_KRB5_CHECKSUM_new(cmp) SKM_sk_new(KRB5_CHECKSUM, (cmp))\n# define sk_KRB5_CHECKSUM_new_null() SKM_sk_new_null(KRB5_CHECKSUM)\n# define sk_KRB5_CHECKSUM_free(st) SKM_sk_free(KRB5_CHECKSUM, (st))\n# define sk_KRB5_CHECKSUM_num(st) SKM_sk_num(KRB5_CHECKSUM, (st))\n# define sk_KRB5_CHECKSUM_value(st, i) SKM_sk_value(KRB5_CHECKSUM, (st), (i))\n# define sk_KRB5_CHECKSUM_set(st, i, val) SKM_sk_set(KRB5_CHECKSUM, (st), (i), (val))\n# define sk_KRB5_CHECKSUM_zero(st) SKM_sk_zero(KRB5_CHECKSUM, (st))\n# define sk_KRB5_CHECKSUM_push(st, val) SKM_sk_push(KRB5_CHECKSUM, (st), (val))\n# define sk_KRB5_CHECKSUM_unshift(st, val) SKM_sk_unshift(KRB5_CHECKSUM, (st), (val))\n# define sk_KRB5_CHECKSUM_find(st, val) SKM_sk_find(KRB5_CHECKSUM, (st), (val))\n# define sk_KRB5_CHECKSUM_find_ex(st, val) SKM_sk_find_ex(KRB5_CHECKSUM, (st), (val))\n# define sk_KRB5_CHECKSUM_delete(st, i) SKM_sk_delete(KRB5_CHECKSUM, (st), (i))\n# define sk_KRB5_CHECKSUM_delete_ptr(st, ptr) SKM_sk_delete_ptr(KRB5_CHECKSUM, (st), (ptr))\n# define sk_KRB5_CHECKSUM_insert(st, val, i) SKM_sk_insert(KRB5_CHECKSUM, (st), (val), (i))\n# define sk_KRB5_CHECKSUM_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(KRB5_CHECKSUM, (st), (cmp))\n# define sk_KRB5_CHECKSUM_dup(st) SKM_sk_dup(KRB5_CHECKSUM, st)\n# define sk_KRB5_CHECKSUM_pop_free(st, free_func) SKM_sk_pop_free(KRB5_CHECKSUM, (st), (free_func))\n# define sk_KRB5_CHECKSUM_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(KRB5_CHECKSUM, (st), (copy_func), (free_func))\n# define sk_KRB5_CHECKSUM_shift(st) SKM_sk_shift(KRB5_CHECKSUM, (st))\n# define sk_KRB5_CHECKSUM_pop(st) SKM_sk_pop(KRB5_CHECKSUM, (st))\n# define sk_KRB5_CHECKSUM_sort(st) SKM_sk_sort(KRB5_CHECKSUM, (st))\n# define sk_KRB5_CHECKSUM_is_sorted(st) SKM_sk_is_sorted(KRB5_CHECKSUM, (st))\n# define sk_KRB5_ENCDATA_new(cmp) SKM_sk_new(KRB5_ENCDATA, (cmp))\n# define sk_KRB5_ENCDATA_new_null() SKM_sk_new_null(KRB5_ENCDATA)\n# define sk_KRB5_ENCDATA_free(st) SKM_sk_free(KRB5_ENCDATA, (st))\n# define sk_KRB5_ENCDATA_num(st) SKM_sk_num(KRB5_ENCDATA, (st))\n# define sk_KRB5_ENCDATA_value(st, i) SKM_sk_value(KRB5_ENCDATA, (st), (i))\n# define sk_KRB5_ENCDATA_set(st, i, val) SKM_sk_set(KRB5_ENCDATA, (st), (i), (val))\n# define sk_KRB5_ENCDATA_zero(st) SKM_sk_zero(KRB5_ENCDATA, (st))\n# define sk_KRB5_ENCDATA_push(st, val) SKM_sk_push(KRB5_ENCDATA, (st), (val))\n# define sk_KRB5_ENCDATA_unshift(st, val) SKM_sk_unshift(KRB5_ENCDATA, (st), (val))\n# define sk_KRB5_ENCDATA_find(st, val) SKM_sk_find(KRB5_ENCDATA, (st), (val))\n# define sk_KRB5_ENCDATA_find_ex(st, val) SKM_sk_find_ex(KRB5_ENCDATA, (st), (val))\n# define sk_KRB5_ENCDATA_delete(st, i) SKM_sk_delete(KRB5_ENCDATA, (st), (i))\n# define sk_KRB5_ENCDATA_delete_ptr(st, ptr) SKM_sk_delete_ptr(KRB5_ENCDATA, (st), (ptr))\n# define sk_KRB5_ENCDATA_insert(st, val, i) SKM_sk_insert(KRB5_ENCDATA, (st), (val), (i))\n# define sk_KRB5_ENCDATA_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(KRB5_ENCDATA, (st), (cmp))\n# define sk_KRB5_ENCDATA_dup(st) SKM_sk_dup(KRB5_ENCDATA, st)\n# define sk_KRB5_ENCDATA_pop_free(st, free_func) SKM_sk_pop_free(KRB5_ENCDATA, (st), (free_func))\n# define sk_KRB5_ENCDATA_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(KRB5_ENCDATA, (st), (copy_func), (free_func))\n# define sk_KRB5_ENCDATA_shift(st) SKM_sk_shift(KRB5_ENCDATA, (st))\n# define sk_KRB5_ENCDATA_pop(st) SKM_sk_pop(KRB5_ENCDATA, (st))\n# define sk_KRB5_ENCDATA_sort(st) SKM_sk_sort(KRB5_ENCDATA, (st))\n# define sk_KRB5_ENCDATA_is_sorted(st) SKM_sk_is_sorted(KRB5_ENCDATA, (st))\n# define sk_KRB5_ENCKEY_new(cmp) SKM_sk_new(KRB5_ENCKEY, (cmp))\n# define sk_KRB5_ENCKEY_new_null() SKM_sk_new_null(KRB5_ENCKEY)\n# define sk_KRB5_ENCKEY_free(st) SKM_sk_free(KRB5_ENCKEY, (st))\n# define sk_KRB5_ENCKEY_num(st) SKM_sk_num(KRB5_ENCKEY, (st))\n# define sk_KRB5_ENCKEY_value(st, i) SKM_sk_value(KRB5_ENCKEY, (st), (i))\n# define sk_KRB5_ENCKEY_set(st, i, val) SKM_sk_set(KRB5_ENCKEY, (st), (i), (val))\n# define sk_KRB5_ENCKEY_zero(st) SKM_sk_zero(KRB5_ENCKEY, (st))\n# define sk_KRB5_ENCKEY_push(st, val) SKM_sk_push(KRB5_ENCKEY, (st), (val))\n# define sk_KRB5_ENCKEY_unshift(st, val) SKM_sk_unshift(KRB5_ENCKEY, (st), (val))\n# define sk_KRB5_ENCKEY_find(st, val) SKM_sk_find(KRB5_ENCKEY, (st), (val))\n# define sk_KRB5_ENCKEY_find_ex(st, val) SKM_sk_find_ex(KRB5_ENCKEY, (st), (val))\n# define sk_KRB5_ENCKEY_delete(st, i) SKM_sk_delete(KRB5_ENCKEY, (st), (i))\n# define sk_KRB5_ENCKEY_delete_ptr(st, ptr) SKM_sk_delete_ptr(KRB5_ENCKEY, (st), (ptr))\n# define sk_KRB5_ENCKEY_insert(st, val, i) SKM_sk_insert(KRB5_ENCKEY, (st), (val), (i))\n# define sk_KRB5_ENCKEY_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(KRB5_ENCKEY, (st), (cmp))\n# define sk_KRB5_ENCKEY_dup(st) SKM_sk_dup(KRB5_ENCKEY, st)\n# define sk_KRB5_ENCKEY_pop_free(st, free_func) SKM_sk_pop_free(KRB5_ENCKEY, (st), (free_func))\n# define sk_KRB5_ENCKEY_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(KRB5_ENCKEY, (st), (copy_func), (free_func))\n# define sk_KRB5_ENCKEY_shift(st) SKM_sk_shift(KRB5_ENCKEY, (st))\n# define sk_KRB5_ENCKEY_pop(st) SKM_sk_pop(KRB5_ENCKEY, (st))\n# define sk_KRB5_ENCKEY_sort(st) SKM_sk_sort(KRB5_ENCKEY, (st))\n# define sk_KRB5_ENCKEY_is_sorted(st) SKM_sk_is_sorted(KRB5_ENCKEY, (st))\n# define sk_KRB5_PRINCNAME_new(cmp) SKM_sk_new(KRB5_PRINCNAME, (cmp))\n# define sk_KRB5_PRINCNAME_new_null() SKM_sk_new_null(KRB5_PRINCNAME)\n# define sk_KRB5_PRINCNAME_free(st) SKM_sk_free(KRB5_PRINCNAME, (st))\n# define sk_KRB5_PRINCNAME_num(st) SKM_sk_num(KRB5_PRINCNAME, (st))\n# define sk_KRB5_PRINCNAME_value(st, i) SKM_sk_value(KRB5_PRINCNAME, (st), (i))\n# define sk_KRB5_PRINCNAME_set(st, i, val) SKM_sk_set(KRB5_PRINCNAME, (st), (i), (val))\n# define sk_KRB5_PRINCNAME_zero(st) SKM_sk_zero(KRB5_PRINCNAME, (st))\n# define sk_KRB5_PRINCNAME_push(st, val) SKM_sk_push(KRB5_PRINCNAME, (st), (val))\n# define sk_KRB5_PRINCNAME_unshift(st, val) SKM_sk_unshift(KRB5_PRINCNAME, (st), (val))\n# define sk_KRB5_PRINCNAME_find(st, val) SKM_sk_find(KRB5_PRINCNAME, (st), (val))\n# define sk_KRB5_PRINCNAME_find_ex(st, val) SKM_sk_find_ex(KRB5_PRINCNAME, (st), (val))\n# define sk_KRB5_PRINCNAME_delete(st, i) SKM_sk_delete(KRB5_PRINCNAME, (st), (i))\n# define sk_KRB5_PRINCNAME_delete_ptr(st, ptr) SKM_sk_delete_ptr(KRB5_PRINCNAME, (st), (ptr))\n# define sk_KRB5_PRINCNAME_insert(st, val, i) SKM_sk_insert(KRB5_PRINCNAME, (st), (val), (i))\n# define sk_KRB5_PRINCNAME_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(KRB5_PRINCNAME, (st), (cmp))\n# define sk_KRB5_PRINCNAME_dup(st) SKM_sk_dup(KRB5_PRINCNAME, st)\n# define sk_KRB5_PRINCNAME_pop_free(st, free_func) SKM_sk_pop_free(KRB5_PRINCNAME, (st), (free_func))\n# define sk_KRB5_PRINCNAME_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(KRB5_PRINCNAME, (st), (copy_func), (free_func))\n# define sk_KRB5_PRINCNAME_shift(st) SKM_sk_shift(KRB5_PRINCNAME, (st))\n# define sk_KRB5_PRINCNAME_pop(st) SKM_sk_pop(KRB5_PRINCNAME, (st))\n# define sk_KRB5_PRINCNAME_sort(st) SKM_sk_sort(KRB5_PRINCNAME, (st))\n# define sk_KRB5_PRINCNAME_is_sorted(st) SKM_sk_is_sorted(KRB5_PRINCNAME, (st))\n# define sk_KRB5_TKTBODY_new(cmp) SKM_sk_new(KRB5_TKTBODY, (cmp))\n# define sk_KRB5_TKTBODY_new_null() SKM_sk_new_null(KRB5_TKTBODY)\n# define sk_KRB5_TKTBODY_free(st) SKM_sk_free(KRB5_TKTBODY, (st))\n# define sk_KRB5_TKTBODY_num(st) SKM_sk_num(KRB5_TKTBODY, (st))\n# define sk_KRB5_TKTBODY_value(st, i) SKM_sk_value(KRB5_TKTBODY, (st), (i))\n# define sk_KRB5_TKTBODY_set(st, i, val) SKM_sk_set(KRB5_TKTBODY, (st), (i), (val))\n# define sk_KRB5_TKTBODY_zero(st) SKM_sk_zero(KRB5_TKTBODY, (st))\n# define sk_KRB5_TKTBODY_push(st, val) SKM_sk_push(KRB5_TKTBODY, (st), (val))\n# define sk_KRB5_TKTBODY_unshift(st, val) SKM_sk_unshift(KRB5_TKTBODY, (st), (val))\n# define sk_KRB5_TKTBODY_find(st, val) SKM_sk_find(KRB5_TKTBODY, (st), (val))\n# define sk_KRB5_TKTBODY_find_ex(st, val) SKM_sk_find_ex(KRB5_TKTBODY, (st), (val))\n# define sk_KRB5_TKTBODY_delete(st, i) SKM_sk_delete(KRB5_TKTBODY, (st), (i))\n# define sk_KRB5_TKTBODY_delete_ptr(st, ptr) SKM_sk_delete_ptr(KRB5_TKTBODY, (st), (ptr))\n# define sk_KRB5_TKTBODY_insert(st, val, i) SKM_sk_insert(KRB5_TKTBODY, (st), (val), (i))\n# define sk_KRB5_TKTBODY_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(KRB5_TKTBODY, (st), (cmp))\n# define sk_KRB5_TKTBODY_dup(st) SKM_sk_dup(KRB5_TKTBODY, st)\n# define sk_KRB5_TKTBODY_pop_free(st, free_func) SKM_sk_pop_free(KRB5_TKTBODY, (st), (free_func))\n# define sk_KRB5_TKTBODY_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(KRB5_TKTBODY, (st), (copy_func), (free_func))\n# define sk_KRB5_TKTBODY_shift(st) SKM_sk_shift(KRB5_TKTBODY, (st))\n# define sk_KRB5_TKTBODY_pop(st) SKM_sk_pop(KRB5_TKTBODY, (st))\n# define sk_KRB5_TKTBODY_sort(st) SKM_sk_sort(KRB5_TKTBODY, (st))\n# define sk_KRB5_TKTBODY_is_sorted(st) SKM_sk_is_sorted(KRB5_TKTBODY, (st))\n# define sk_MEM_OBJECT_DATA_new(cmp) SKM_sk_new(MEM_OBJECT_DATA, (cmp))\n# define sk_MEM_OBJECT_DATA_new_null() SKM_sk_new_null(MEM_OBJECT_DATA)\n# define sk_MEM_OBJECT_DATA_free(st) SKM_sk_free(MEM_OBJECT_DATA, (st))\n# define sk_MEM_OBJECT_DATA_num(st) SKM_sk_num(MEM_OBJECT_DATA, (st))\n# define sk_MEM_OBJECT_DATA_value(st, i) SKM_sk_value(MEM_OBJECT_DATA, (st), (i))\n# define sk_MEM_OBJECT_DATA_set(st, i, val) SKM_sk_set(MEM_OBJECT_DATA, (st), (i), (val))\n# define sk_MEM_OBJECT_DATA_zero(st) SKM_sk_zero(MEM_OBJECT_DATA, (st))\n# define sk_MEM_OBJECT_DATA_push(st, val) SKM_sk_push(MEM_OBJECT_DATA, (st), (val))\n# define sk_MEM_OBJECT_DATA_unshift(st, val) SKM_sk_unshift(MEM_OBJECT_DATA, (st), (val))\n# define sk_MEM_OBJECT_DATA_find(st, val) SKM_sk_find(MEM_OBJECT_DATA, (st), (val))\n# define sk_MEM_OBJECT_DATA_find_ex(st, val) SKM_sk_find_ex(MEM_OBJECT_DATA, (st), (val))\n# define sk_MEM_OBJECT_DATA_delete(st, i) SKM_sk_delete(MEM_OBJECT_DATA, (st), (i))\n# define sk_MEM_OBJECT_DATA_delete_ptr(st, ptr) SKM_sk_delete_ptr(MEM_OBJECT_DATA, (st), (ptr))\n# define sk_MEM_OBJECT_DATA_insert(st, val, i) SKM_sk_insert(MEM_OBJECT_DATA, (st), (val), (i))\n# define sk_MEM_OBJECT_DATA_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(MEM_OBJECT_DATA, (st), (cmp))\n# define sk_MEM_OBJECT_DATA_dup(st) SKM_sk_dup(MEM_OBJECT_DATA, st)\n# define sk_MEM_OBJECT_DATA_pop_free(st, free_func) SKM_sk_pop_free(MEM_OBJECT_DATA, (st), (free_func))\n# define sk_MEM_OBJECT_DATA_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(MEM_OBJECT_DATA, (st), (copy_func), (free_func))\n# define sk_MEM_OBJECT_DATA_shift(st) SKM_sk_shift(MEM_OBJECT_DATA, (st))\n# define sk_MEM_OBJECT_DATA_pop(st) SKM_sk_pop(MEM_OBJECT_DATA, (st))\n# define sk_MEM_OBJECT_DATA_sort(st) SKM_sk_sort(MEM_OBJECT_DATA, (st))\n# define sk_MEM_OBJECT_DATA_is_sorted(st) SKM_sk_is_sorted(MEM_OBJECT_DATA, (st))\n# define sk_MIME_HEADER_new(cmp) SKM_sk_new(MIME_HEADER, (cmp))\n# define sk_MIME_HEADER_new_null() SKM_sk_new_null(MIME_HEADER)\n# define sk_MIME_HEADER_free(st) SKM_sk_free(MIME_HEADER, (st))\n# define sk_MIME_HEADER_num(st) SKM_sk_num(MIME_HEADER, (st))\n# define sk_MIME_HEADER_value(st, i) SKM_sk_value(MIME_HEADER, (st), (i))\n# define sk_MIME_HEADER_set(st, i, val) SKM_sk_set(MIME_HEADER, (st), (i), (val))\n# define sk_MIME_HEADER_zero(st) SKM_sk_zero(MIME_HEADER, (st))\n# define sk_MIME_HEADER_push(st, val) SKM_sk_push(MIME_HEADER, (st), (val))\n# define sk_MIME_HEADER_unshift(st, val) SKM_sk_unshift(MIME_HEADER, (st), (val))\n# define sk_MIME_HEADER_find(st, val) SKM_sk_find(MIME_HEADER, (st), (val))\n# define sk_MIME_HEADER_find_ex(st, val) SKM_sk_find_ex(MIME_HEADER, (st), (val))\n# define sk_MIME_HEADER_delete(st, i) SKM_sk_delete(MIME_HEADER, (st), (i))\n# define sk_MIME_HEADER_delete_ptr(st, ptr) SKM_sk_delete_ptr(MIME_HEADER, (st), (ptr))\n# define sk_MIME_HEADER_insert(st, val, i) SKM_sk_insert(MIME_HEADER, (st), (val), (i))\n# define sk_MIME_HEADER_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(MIME_HEADER, (st), (cmp))\n# define sk_MIME_HEADER_dup(st) SKM_sk_dup(MIME_HEADER, st)\n# define sk_MIME_HEADER_pop_free(st, free_func) SKM_sk_pop_free(MIME_HEADER, (st), (free_func))\n# define sk_MIME_HEADER_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(MIME_HEADER, (st), (copy_func), (free_func))\n# define sk_MIME_HEADER_shift(st) SKM_sk_shift(MIME_HEADER, (st))\n# define sk_MIME_HEADER_pop(st) SKM_sk_pop(MIME_HEADER, (st))\n# define sk_MIME_HEADER_sort(st) SKM_sk_sort(MIME_HEADER, (st))\n# define sk_MIME_HEADER_is_sorted(st) SKM_sk_is_sorted(MIME_HEADER, (st))\n# define sk_MIME_PARAM_new(cmp) SKM_sk_new(MIME_PARAM, (cmp))\n# define sk_MIME_PARAM_new_null() SKM_sk_new_null(MIME_PARAM)\n# define sk_MIME_PARAM_free(st) SKM_sk_free(MIME_PARAM, (st))\n# define sk_MIME_PARAM_num(st) SKM_sk_num(MIME_PARAM, (st))\n# define sk_MIME_PARAM_value(st, i) SKM_sk_value(MIME_PARAM, (st), (i))\n# define sk_MIME_PARAM_set(st, i, val) SKM_sk_set(MIME_PARAM, (st), (i), (val))\n# define sk_MIME_PARAM_zero(st) SKM_sk_zero(MIME_PARAM, (st))\n# define sk_MIME_PARAM_push(st, val) SKM_sk_push(MIME_PARAM, (st), (val))\n# define sk_MIME_PARAM_unshift(st, val) SKM_sk_unshift(MIME_PARAM, (st), (val))\n# define sk_MIME_PARAM_find(st, val) SKM_sk_find(MIME_PARAM, (st), (val))\n# define sk_MIME_PARAM_find_ex(st, val) SKM_sk_find_ex(MIME_PARAM, (st), (val))\n# define sk_MIME_PARAM_delete(st, i) SKM_sk_delete(MIME_PARAM, (st), (i))\n# define sk_MIME_PARAM_delete_ptr(st, ptr) SKM_sk_delete_ptr(MIME_PARAM, (st), (ptr))\n# define sk_MIME_PARAM_insert(st, val, i) SKM_sk_insert(MIME_PARAM, (st), (val), (i))\n# define sk_MIME_PARAM_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(MIME_PARAM, (st), (cmp))\n# define sk_MIME_PARAM_dup(st) SKM_sk_dup(MIME_PARAM, st)\n# define sk_MIME_PARAM_pop_free(st, free_func) SKM_sk_pop_free(MIME_PARAM, (st), (free_func))\n# define sk_MIME_PARAM_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(MIME_PARAM, (st), (copy_func), (free_func))\n# define sk_MIME_PARAM_shift(st) SKM_sk_shift(MIME_PARAM, (st))\n# define sk_MIME_PARAM_pop(st) SKM_sk_pop(MIME_PARAM, (st))\n# define sk_MIME_PARAM_sort(st) SKM_sk_sort(MIME_PARAM, (st))\n# define sk_MIME_PARAM_is_sorted(st) SKM_sk_is_sorted(MIME_PARAM, (st))\n# define sk_NAME_FUNCS_new(cmp) SKM_sk_new(NAME_FUNCS, (cmp))\n# define sk_NAME_FUNCS_new_null() SKM_sk_new_null(NAME_FUNCS)\n# define sk_NAME_FUNCS_free(st) SKM_sk_free(NAME_FUNCS, (st))\n# define sk_NAME_FUNCS_num(st) SKM_sk_num(NAME_FUNCS, (st))\n# define sk_NAME_FUNCS_value(st, i) SKM_sk_value(NAME_FUNCS, (st), (i))\n# define sk_NAME_FUNCS_set(st, i, val) SKM_sk_set(NAME_FUNCS, (st), (i), (val))\n# define sk_NAME_FUNCS_zero(st) SKM_sk_zero(NAME_FUNCS, (st))\n# define sk_NAME_FUNCS_push(st, val) SKM_sk_push(NAME_FUNCS, (st), (val))\n# define sk_NAME_FUNCS_unshift(st, val) SKM_sk_unshift(NAME_FUNCS, (st), (val))\n# define sk_NAME_FUNCS_find(st, val) SKM_sk_find(NAME_FUNCS, (st), (val))\n# define sk_NAME_FUNCS_find_ex(st, val) SKM_sk_find_ex(NAME_FUNCS, (st), (val))\n# define sk_NAME_FUNCS_delete(st, i) SKM_sk_delete(NAME_FUNCS, (st), (i))\n# define sk_NAME_FUNCS_delete_ptr(st, ptr) SKM_sk_delete_ptr(NAME_FUNCS, (st), (ptr))\n# define sk_NAME_FUNCS_insert(st, val, i) SKM_sk_insert(NAME_FUNCS, (st), (val), (i))\n# define sk_NAME_FUNCS_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(NAME_FUNCS, (st), (cmp))\n# define sk_NAME_FUNCS_dup(st) SKM_sk_dup(NAME_FUNCS, st)\n# define sk_NAME_FUNCS_pop_free(st, free_func) SKM_sk_pop_free(NAME_FUNCS, (st), (free_func))\n# define sk_NAME_FUNCS_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(NAME_FUNCS, (st), (copy_func), (free_func))\n# define sk_NAME_FUNCS_shift(st) SKM_sk_shift(NAME_FUNCS, (st))\n# define sk_NAME_FUNCS_pop(st) SKM_sk_pop(NAME_FUNCS, (st))\n# define sk_NAME_FUNCS_sort(st) SKM_sk_sort(NAME_FUNCS, (st))\n# define sk_NAME_FUNCS_is_sorted(st) SKM_sk_is_sorted(NAME_FUNCS, (st))\n# define sk_OCSP_CERTID_new(cmp) SKM_sk_new(OCSP_CERTID, (cmp))\n# define sk_OCSP_CERTID_new_null() SKM_sk_new_null(OCSP_CERTID)\n# define sk_OCSP_CERTID_free(st) SKM_sk_free(OCSP_CERTID, (st))\n# define sk_OCSP_CERTID_num(st) SKM_sk_num(OCSP_CERTID, (st))\n# define sk_OCSP_CERTID_value(st, i) SKM_sk_value(OCSP_CERTID, (st), (i))\n# define sk_OCSP_CERTID_set(st, i, val) SKM_sk_set(OCSP_CERTID, (st), (i), (val))\n# define sk_OCSP_CERTID_zero(st) SKM_sk_zero(OCSP_CERTID, (st))\n# define sk_OCSP_CERTID_push(st, val) SKM_sk_push(OCSP_CERTID, (st), (val))\n# define sk_OCSP_CERTID_unshift(st, val) SKM_sk_unshift(OCSP_CERTID, (st), (val))\n# define sk_OCSP_CERTID_find(st, val) SKM_sk_find(OCSP_CERTID, (st), (val))\n# define sk_OCSP_CERTID_find_ex(st, val) SKM_sk_find_ex(OCSP_CERTID, (st), (val))\n# define sk_OCSP_CERTID_delete(st, i) SKM_sk_delete(OCSP_CERTID, (st), (i))\n# define sk_OCSP_CERTID_delete_ptr(st, ptr) SKM_sk_delete_ptr(OCSP_CERTID, (st), (ptr))\n# define sk_OCSP_CERTID_insert(st, val, i) SKM_sk_insert(OCSP_CERTID, (st), (val), (i))\n# define sk_OCSP_CERTID_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(OCSP_CERTID, (st), (cmp))\n# define sk_OCSP_CERTID_dup(st) SKM_sk_dup(OCSP_CERTID, st)\n# define sk_OCSP_CERTID_pop_free(st, free_func) SKM_sk_pop_free(OCSP_CERTID, (st), (free_func))\n# define sk_OCSP_CERTID_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(OCSP_CERTID, (st), (copy_func), (free_func))\n# define sk_OCSP_CERTID_shift(st) SKM_sk_shift(OCSP_CERTID, (st))\n# define sk_OCSP_CERTID_pop(st) SKM_sk_pop(OCSP_CERTID, (st))\n# define sk_OCSP_CERTID_sort(st) SKM_sk_sort(OCSP_CERTID, (st))\n# define sk_OCSP_CERTID_is_sorted(st) SKM_sk_is_sorted(OCSP_CERTID, (st))\n# define sk_OCSP_ONEREQ_new(cmp) SKM_sk_new(OCSP_ONEREQ, (cmp))\n# define sk_OCSP_ONEREQ_new_null() SKM_sk_new_null(OCSP_ONEREQ)\n# define sk_OCSP_ONEREQ_free(st) SKM_sk_free(OCSP_ONEREQ, (st))\n# define sk_OCSP_ONEREQ_num(st) SKM_sk_num(OCSP_ONEREQ, (st))\n# define sk_OCSP_ONEREQ_value(st, i) SKM_sk_value(OCSP_ONEREQ, (st), (i))\n# define sk_OCSP_ONEREQ_set(st, i, val) SKM_sk_set(OCSP_ONEREQ, (st), (i), (val))\n# define sk_OCSP_ONEREQ_zero(st) SKM_sk_zero(OCSP_ONEREQ, (st))\n# define sk_OCSP_ONEREQ_push(st, val) SKM_sk_push(OCSP_ONEREQ, (st), (val))\n# define sk_OCSP_ONEREQ_unshift(st, val) SKM_sk_unshift(OCSP_ONEREQ, (st), (val))\n# define sk_OCSP_ONEREQ_find(st, val) SKM_sk_find(OCSP_ONEREQ, (st), (val))\n# define sk_OCSP_ONEREQ_find_ex(st, val) SKM_sk_find_ex(OCSP_ONEREQ, (st), (val))\n# define sk_OCSP_ONEREQ_delete(st, i) SKM_sk_delete(OCSP_ONEREQ, (st), (i))\n# define sk_OCSP_ONEREQ_delete_ptr(st, ptr) SKM_sk_delete_ptr(OCSP_ONEREQ, (st), (ptr))\n# define sk_OCSP_ONEREQ_insert(st, val, i) SKM_sk_insert(OCSP_ONEREQ, (st), (val), (i))\n# define sk_OCSP_ONEREQ_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(OCSP_ONEREQ, (st), (cmp))\n# define sk_OCSP_ONEREQ_dup(st) SKM_sk_dup(OCSP_ONEREQ, st)\n# define sk_OCSP_ONEREQ_pop_free(st, free_func) SKM_sk_pop_free(OCSP_ONEREQ, (st), (free_func))\n# define sk_OCSP_ONEREQ_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(OCSP_ONEREQ, (st), (copy_func), (free_func))\n# define sk_OCSP_ONEREQ_shift(st) SKM_sk_shift(OCSP_ONEREQ, (st))\n# define sk_OCSP_ONEREQ_pop(st) SKM_sk_pop(OCSP_ONEREQ, (st))\n# define sk_OCSP_ONEREQ_sort(st) SKM_sk_sort(OCSP_ONEREQ, (st))\n# define sk_OCSP_ONEREQ_is_sorted(st) SKM_sk_is_sorted(OCSP_ONEREQ, (st))\n# define sk_OCSP_RESPID_new(cmp) SKM_sk_new(OCSP_RESPID, (cmp))\n# define sk_OCSP_RESPID_new_null() SKM_sk_new_null(OCSP_RESPID)\n# define sk_OCSP_RESPID_free(st) SKM_sk_free(OCSP_RESPID, (st))\n# define sk_OCSP_RESPID_num(st) SKM_sk_num(OCSP_RESPID, (st))\n# define sk_OCSP_RESPID_value(st, i) SKM_sk_value(OCSP_RESPID, (st), (i))\n# define sk_OCSP_RESPID_set(st, i, val) SKM_sk_set(OCSP_RESPID, (st), (i), (val))\n# define sk_OCSP_RESPID_zero(st) SKM_sk_zero(OCSP_RESPID, (st))\n# define sk_OCSP_RESPID_push(st, val) SKM_sk_push(OCSP_RESPID, (st), (val))\n# define sk_OCSP_RESPID_unshift(st, val) SKM_sk_unshift(OCSP_RESPID, (st), (val))\n# define sk_OCSP_RESPID_find(st, val) SKM_sk_find(OCSP_RESPID, (st), (val))\n# define sk_OCSP_RESPID_find_ex(st, val) SKM_sk_find_ex(OCSP_RESPID, (st), (val))\n# define sk_OCSP_RESPID_delete(st, i) SKM_sk_delete(OCSP_RESPID, (st), (i))\n# define sk_OCSP_RESPID_delete_ptr(st, ptr) SKM_sk_delete_ptr(OCSP_RESPID, (st), (ptr))\n# define sk_OCSP_RESPID_insert(st, val, i) SKM_sk_insert(OCSP_RESPID, (st), (val), (i))\n# define sk_OCSP_RESPID_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(OCSP_RESPID, (st), (cmp))\n# define sk_OCSP_RESPID_dup(st) SKM_sk_dup(OCSP_RESPID, st)\n# define sk_OCSP_RESPID_pop_free(st, free_func) SKM_sk_pop_free(OCSP_RESPID, (st), (free_func))\n# define sk_OCSP_RESPID_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(OCSP_RESPID, (st), (copy_func), (free_func))\n# define sk_OCSP_RESPID_shift(st) SKM_sk_shift(OCSP_RESPID, (st))\n# define sk_OCSP_RESPID_pop(st) SKM_sk_pop(OCSP_RESPID, (st))\n# define sk_OCSP_RESPID_sort(st) SKM_sk_sort(OCSP_RESPID, (st))\n# define sk_OCSP_RESPID_is_sorted(st) SKM_sk_is_sorted(OCSP_RESPID, (st))\n# define sk_OCSP_SINGLERESP_new(cmp) SKM_sk_new(OCSP_SINGLERESP, (cmp))\n# define sk_OCSP_SINGLERESP_new_null() SKM_sk_new_null(OCSP_SINGLERESP)\n# define sk_OCSP_SINGLERESP_free(st) SKM_sk_free(OCSP_SINGLERESP, (st))\n# define sk_OCSP_SINGLERESP_num(st) SKM_sk_num(OCSP_SINGLERESP, (st))\n# define sk_OCSP_SINGLERESP_value(st, i) SKM_sk_value(OCSP_SINGLERESP, (st), (i))\n# define sk_OCSP_SINGLERESP_set(st, i, val) SKM_sk_set(OCSP_SINGLERESP, (st), (i), (val))\n# define sk_OCSP_SINGLERESP_zero(st) SKM_sk_zero(OCSP_SINGLERESP, (st))\n# define sk_OCSP_SINGLERESP_push(st, val) SKM_sk_push(OCSP_SINGLERESP, (st), (val))\n# define sk_OCSP_SINGLERESP_unshift(st, val) SKM_sk_unshift(OCSP_SINGLERESP, (st), (val))\n# define sk_OCSP_SINGLERESP_find(st, val) SKM_sk_find(OCSP_SINGLERESP, (st), (val))\n# define sk_OCSP_SINGLERESP_find_ex(st, val) SKM_sk_find_ex(OCSP_SINGLERESP, (st), (val))\n# define sk_OCSP_SINGLERESP_delete(st, i) SKM_sk_delete(OCSP_SINGLERESP, (st), (i))\n# define sk_OCSP_SINGLERESP_delete_ptr(st, ptr) SKM_sk_delete_ptr(OCSP_SINGLERESP, (st), (ptr))\n# define sk_OCSP_SINGLERESP_insert(st, val, i) SKM_sk_insert(OCSP_SINGLERESP, (st), (val), (i))\n# define sk_OCSP_SINGLERESP_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(OCSP_SINGLERESP, (st), (cmp))\n# define sk_OCSP_SINGLERESP_dup(st) SKM_sk_dup(OCSP_SINGLERESP, st)\n# define sk_OCSP_SINGLERESP_pop_free(st, free_func) SKM_sk_pop_free(OCSP_SINGLERESP, (st), (free_func))\n# define sk_OCSP_SINGLERESP_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(OCSP_SINGLERESP, (st), (copy_func), (free_func))\n# define sk_OCSP_SINGLERESP_shift(st) SKM_sk_shift(OCSP_SINGLERESP, (st))\n# define sk_OCSP_SINGLERESP_pop(st) SKM_sk_pop(OCSP_SINGLERESP, (st))\n# define sk_OCSP_SINGLERESP_sort(st) SKM_sk_sort(OCSP_SINGLERESP, (st))\n# define sk_OCSP_SINGLERESP_is_sorted(st) SKM_sk_is_sorted(OCSP_SINGLERESP, (st))\n# define sk_PKCS12_SAFEBAG_new(cmp) SKM_sk_new(PKCS12_SAFEBAG, (cmp))\n# define sk_PKCS12_SAFEBAG_new_null() SKM_sk_new_null(PKCS12_SAFEBAG)\n# define sk_PKCS12_SAFEBAG_free(st) SKM_sk_free(PKCS12_SAFEBAG, (st))\n# define sk_PKCS12_SAFEBAG_num(st) SKM_sk_num(PKCS12_SAFEBAG, (st))\n# define sk_PKCS12_SAFEBAG_value(st, i) SKM_sk_value(PKCS12_SAFEBAG, (st), (i))\n# define sk_PKCS12_SAFEBAG_set(st, i, val) SKM_sk_set(PKCS12_SAFEBAG, (st), (i), (val))\n# define sk_PKCS12_SAFEBAG_zero(st) SKM_sk_zero(PKCS12_SAFEBAG, (st))\n# define sk_PKCS12_SAFEBAG_push(st, val) SKM_sk_push(PKCS12_SAFEBAG, (st), (val))\n# define sk_PKCS12_SAFEBAG_unshift(st, val) SKM_sk_unshift(PKCS12_SAFEBAG, (st), (val))\n# define sk_PKCS12_SAFEBAG_find(st, val) SKM_sk_find(PKCS12_SAFEBAG, (st), (val))\n# define sk_PKCS12_SAFEBAG_find_ex(st, val) SKM_sk_find_ex(PKCS12_SAFEBAG, (st), (val))\n# define sk_PKCS12_SAFEBAG_delete(st, i) SKM_sk_delete(PKCS12_SAFEBAG, (st), (i))\n# define sk_PKCS12_SAFEBAG_delete_ptr(st, ptr) SKM_sk_delete_ptr(PKCS12_SAFEBAG, (st), (ptr))\n# define sk_PKCS12_SAFEBAG_insert(st, val, i) SKM_sk_insert(PKCS12_SAFEBAG, (st), (val), (i))\n# define sk_PKCS12_SAFEBAG_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(PKCS12_SAFEBAG, (st), (cmp))\n# define sk_PKCS12_SAFEBAG_dup(st) SKM_sk_dup(PKCS12_SAFEBAG, st)\n# define sk_PKCS12_SAFEBAG_pop_free(st, free_func) SKM_sk_pop_free(PKCS12_SAFEBAG, (st), (free_func))\n# define sk_PKCS12_SAFEBAG_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(PKCS12_SAFEBAG, (st), (copy_func), (free_func))\n# define sk_PKCS12_SAFEBAG_shift(st) SKM_sk_shift(PKCS12_SAFEBAG, (st))\n# define sk_PKCS12_SAFEBAG_pop(st) SKM_sk_pop(PKCS12_SAFEBAG, (st))\n# define sk_PKCS12_SAFEBAG_sort(st) SKM_sk_sort(PKCS12_SAFEBAG, (st))\n# define sk_PKCS12_SAFEBAG_is_sorted(st) SKM_sk_is_sorted(PKCS12_SAFEBAG, (st))\n# define sk_PKCS7_new(cmp) SKM_sk_new(PKCS7, (cmp))\n# define sk_PKCS7_new_null() SKM_sk_new_null(PKCS7)\n# define sk_PKCS7_free(st) SKM_sk_free(PKCS7, (st))\n# define sk_PKCS7_num(st) SKM_sk_num(PKCS7, (st))\n# define sk_PKCS7_value(st, i) SKM_sk_value(PKCS7, (st), (i))\n# define sk_PKCS7_set(st, i, val) SKM_sk_set(PKCS7, (st), (i), (val))\n# define sk_PKCS7_zero(st) SKM_sk_zero(PKCS7, (st))\n# define sk_PKCS7_push(st, val) SKM_sk_push(PKCS7, (st), (val))\n# define sk_PKCS7_unshift(st, val) SKM_sk_unshift(PKCS7, (st), (val))\n# define sk_PKCS7_find(st, val) SKM_sk_find(PKCS7, (st), (val))\n# define sk_PKCS7_find_ex(st, val) SKM_sk_find_ex(PKCS7, (st), (val))\n# define sk_PKCS7_delete(st, i) SKM_sk_delete(PKCS7, (st), (i))\n# define sk_PKCS7_delete_ptr(st, ptr) SKM_sk_delete_ptr(PKCS7, (st), (ptr))\n# define sk_PKCS7_insert(st, val, i) SKM_sk_insert(PKCS7, (st), (val), (i))\n# define sk_PKCS7_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(PKCS7, (st), (cmp))\n# define sk_PKCS7_dup(st) SKM_sk_dup(PKCS7, st)\n# define sk_PKCS7_pop_free(st, free_func) SKM_sk_pop_free(PKCS7, (st), (free_func))\n# define sk_PKCS7_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(PKCS7, (st), (copy_func), (free_func))\n# define sk_PKCS7_shift(st) SKM_sk_shift(PKCS7, (st))\n# define sk_PKCS7_pop(st) SKM_sk_pop(PKCS7, (st))\n# define sk_PKCS7_sort(st) SKM_sk_sort(PKCS7, (st))\n# define sk_PKCS7_is_sorted(st) SKM_sk_is_sorted(PKCS7, (st))\n# define sk_PKCS7_RECIP_INFO_new(cmp) SKM_sk_new(PKCS7_RECIP_INFO, (cmp))\n# define sk_PKCS7_RECIP_INFO_new_null() SKM_sk_new_null(PKCS7_RECIP_INFO)\n# define sk_PKCS7_RECIP_INFO_free(st) SKM_sk_free(PKCS7_RECIP_INFO, (st))\n# define sk_PKCS7_RECIP_INFO_num(st) SKM_sk_num(PKCS7_RECIP_INFO, (st))\n# define sk_PKCS7_RECIP_INFO_value(st, i) SKM_sk_value(PKCS7_RECIP_INFO, (st), (i))\n# define sk_PKCS7_RECIP_INFO_set(st, i, val) SKM_sk_set(PKCS7_RECIP_INFO, (st), (i), (val))\n# define sk_PKCS7_RECIP_INFO_zero(st) SKM_sk_zero(PKCS7_RECIP_INFO, (st))\n# define sk_PKCS7_RECIP_INFO_push(st, val) SKM_sk_push(PKCS7_RECIP_INFO, (st), (val))\n# define sk_PKCS7_RECIP_INFO_unshift(st, val) SKM_sk_unshift(PKCS7_RECIP_INFO, (st), (val))\n# define sk_PKCS7_RECIP_INFO_find(st, val) SKM_sk_find(PKCS7_RECIP_INFO, (st), (val))\n# define sk_PKCS7_RECIP_INFO_find_ex(st, val) SKM_sk_find_ex(PKCS7_RECIP_INFO, (st), (val))\n# define sk_PKCS7_RECIP_INFO_delete(st, i) SKM_sk_delete(PKCS7_RECIP_INFO, (st), (i))\n# define sk_PKCS7_RECIP_INFO_delete_ptr(st, ptr) SKM_sk_delete_ptr(PKCS7_RECIP_INFO, (st), (ptr))\n# define sk_PKCS7_RECIP_INFO_insert(st, val, i) SKM_sk_insert(PKCS7_RECIP_INFO, (st), (val), (i))\n# define sk_PKCS7_RECIP_INFO_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(PKCS7_RECIP_INFO, (st), (cmp))\n# define sk_PKCS7_RECIP_INFO_dup(st) SKM_sk_dup(PKCS7_RECIP_INFO, st)\n# define sk_PKCS7_RECIP_INFO_pop_free(st, free_func) SKM_sk_pop_free(PKCS7_RECIP_INFO, (st), (free_func))\n# define sk_PKCS7_RECIP_INFO_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(PKCS7_RECIP_INFO, (st), (copy_func), (free_func))\n# define sk_PKCS7_RECIP_INFO_shift(st) SKM_sk_shift(PKCS7_RECIP_INFO, (st))\n# define sk_PKCS7_RECIP_INFO_pop(st) SKM_sk_pop(PKCS7_RECIP_INFO, (st))\n# define sk_PKCS7_RECIP_INFO_sort(st) SKM_sk_sort(PKCS7_RECIP_INFO, (st))\n# define sk_PKCS7_RECIP_INFO_is_sorted(st) SKM_sk_is_sorted(PKCS7_RECIP_INFO, (st))\n# define sk_PKCS7_SIGNER_INFO_new(cmp) SKM_sk_new(PKCS7_SIGNER_INFO, (cmp))\n# define sk_PKCS7_SIGNER_INFO_new_null() SKM_sk_new_null(PKCS7_SIGNER_INFO)\n# define sk_PKCS7_SIGNER_INFO_free(st) SKM_sk_free(PKCS7_SIGNER_INFO, (st))\n# define sk_PKCS7_SIGNER_INFO_num(st) SKM_sk_num(PKCS7_SIGNER_INFO, (st))\n# define sk_PKCS7_SIGNER_INFO_value(st, i) SKM_sk_value(PKCS7_SIGNER_INFO, (st), (i))\n# define sk_PKCS7_SIGNER_INFO_set(st, i, val) SKM_sk_set(PKCS7_SIGNER_INFO, (st), (i), (val))\n# define sk_PKCS7_SIGNER_INFO_zero(st) SKM_sk_zero(PKCS7_SIGNER_INFO, (st))\n# define sk_PKCS7_SIGNER_INFO_push(st, val) SKM_sk_push(PKCS7_SIGNER_INFO, (st), (val))\n# define sk_PKCS7_SIGNER_INFO_unshift(st, val) SKM_sk_unshift(PKCS7_SIGNER_INFO, (st), (val))\n# define sk_PKCS7_SIGNER_INFO_find(st, val) SKM_sk_find(PKCS7_SIGNER_INFO, (st), (val))\n# define sk_PKCS7_SIGNER_INFO_find_ex(st, val) SKM_sk_find_ex(PKCS7_SIGNER_INFO, (st), (val))\n# define sk_PKCS7_SIGNER_INFO_delete(st, i) SKM_sk_delete(PKCS7_SIGNER_INFO, (st), (i))\n# define sk_PKCS7_SIGNER_INFO_delete_ptr(st, ptr) SKM_sk_delete_ptr(PKCS7_SIGNER_INFO, (st), (ptr))\n# define sk_PKCS7_SIGNER_INFO_insert(st, val, i) SKM_sk_insert(PKCS7_SIGNER_INFO, (st), (val), (i))\n# define sk_PKCS7_SIGNER_INFO_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(PKCS7_SIGNER_INFO, (st), (cmp))\n# define sk_PKCS7_SIGNER_INFO_dup(st) SKM_sk_dup(PKCS7_SIGNER_INFO, st)\n# define sk_PKCS7_SIGNER_INFO_pop_free(st, free_func) SKM_sk_pop_free(PKCS7_SIGNER_INFO, (st), (free_func))\n# define sk_PKCS7_SIGNER_INFO_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(PKCS7_SIGNER_INFO, (st), (copy_func), (free_func))\n# define sk_PKCS7_SIGNER_INFO_shift(st) SKM_sk_shift(PKCS7_SIGNER_INFO, (st))\n# define sk_PKCS7_SIGNER_INFO_pop(st) SKM_sk_pop(PKCS7_SIGNER_INFO, (st))\n# define sk_PKCS7_SIGNER_INFO_sort(st) SKM_sk_sort(PKCS7_SIGNER_INFO, (st))\n# define sk_PKCS7_SIGNER_INFO_is_sorted(st) SKM_sk_is_sorted(PKCS7_SIGNER_INFO, (st))\n# define sk_POLICYINFO_new(cmp) SKM_sk_new(POLICYINFO, (cmp))\n# define sk_POLICYINFO_new_null() SKM_sk_new_null(POLICYINFO)\n# define sk_POLICYINFO_free(st) SKM_sk_free(POLICYINFO, (st))\n# define sk_POLICYINFO_num(st) SKM_sk_num(POLICYINFO, (st))\n# define sk_POLICYINFO_value(st, i) SKM_sk_value(POLICYINFO, (st), (i))\n# define sk_POLICYINFO_set(st, i, val) SKM_sk_set(POLICYINFO, (st), (i), (val))\n# define sk_POLICYINFO_zero(st) SKM_sk_zero(POLICYINFO, (st))\n# define sk_POLICYINFO_push(st, val) SKM_sk_push(POLICYINFO, (st), (val))\n# define sk_POLICYINFO_unshift(st, val) SKM_sk_unshift(POLICYINFO, (st), (val))\n# define sk_POLICYINFO_find(st, val) SKM_sk_find(POLICYINFO, (st), (val))\n# define sk_POLICYINFO_find_ex(st, val) SKM_sk_find_ex(POLICYINFO, (st), (val))\n# define sk_POLICYINFO_delete(st, i) SKM_sk_delete(POLICYINFO, (st), (i))\n# define sk_POLICYINFO_delete_ptr(st, ptr) SKM_sk_delete_ptr(POLICYINFO, (st), (ptr))\n# define sk_POLICYINFO_insert(st, val, i) SKM_sk_insert(POLICYINFO, (st), (val), (i))\n# define sk_POLICYINFO_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(POLICYINFO, (st), (cmp))\n# define sk_POLICYINFO_dup(st) SKM_sk_dup(POLICYINFO, st)\n# define sk_POLICYINFO_pop_free(st, free_func) SKM_sk_pop_free(POLICYINFO, (st), (free_func))\n# define sk_POLICYINFO_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(POLICYINFO, (st), (copy_func), (free_func))\n# define sk_POLICYINFO_shift(st) SKM_sk_shift(POLICYINFO, (st))\n# define sk_POLICYINFO_pop(st) SKM_sk_pop(POLICYINFO, (st))\n# define sk_POLICYINFO_sort(st) SKM_sk_sort(POLICYINFO, (st))\n# define sk_POLICYINFO_is_sorted(st) SKM_sk_is_sorted(POLICYINFO, (st))\n# define sk_POLICYQUALINFO_new(cmp) SKM_sk_new(POLICYQUALINFO, (cmp))\n# define sk_POLICYQUALINFO_new_null() SKM_sk_new_null(POLICYQUALINFO)\n# define sk_POLICYQUALINFO_free(st) SKM_sk_free(POLICYQUALINFO, (st))\n# define sk_POLICYQUALINFO_num(st) SKM_sk_num(POLICYQUALINFO, (st))\n# define sk_POLICYQUALINFO_value(st, i) SKM_sk_value(POLICYQUALINFO, (st), (i))\n# define sk_POLICYQUALINFO_set(st, i, val) SKM_sk_set(POLICYQUALINFO, (st), (i), (val))\n# define sk_POLICYQUALINFO_zero(st) SKM_sk_zero(POLICYQUALINFO, (st))\n# define sk_POLICYQUALINFO_push(st, val) SKM_sk_push(POLICYQUALINFO, (st), (val))\n# define sk_POLICYQUALINFO_unshift(st, val) SKM_sk_unshift(POLICYQUALINFO, (st), (val))\n# define sk_POLICYQUALINFO_find(st, val) SKM_sk_find(POLICYQUALINFO, (st), (val))\n# define sk_POLICYQUALINFO_find_ex(st, val) SKM_sk_find_ex(POLICYQUALINFO, (st), (val))\n# define sk_POLICYQUALINFO_delete(st, i) SKM_sk_delete(POLICYQUALINFO, (st), (i))\n# define sk_POLICYQUALINFO_delete_ptr(st, ptr) SKM_sk_delete_ptr(POLICYQUALINFO, (st), (ptr))\n# define sk_POLICYQUALINFO_insert(st, val, i) SKM_sk_insert(POLICYQUALINFO, (st), (val), (i))\n# define sk_POLICYQUALINFO_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(POLICYQUALINFO, (st), (cmp))\n# define sk_POLICYQUALINFO_dup(st) SKM_sk_dup(POLICYQUALINFO, st)\n# define sk_POLICYQUALINFO_pop_free(st, free_func) SKM_sk_pop_free(POLICYQUALINFO, (st), (free_func))\n# define sk_POLICYQUALINFO_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(POLICYQUALINFO, (st), (copy_func), (free_func))\n# define sk_POLICYQUALINFO_shift(st) SKM_sk_shift(POLICYQUALINFO, (st))\n# define sk_POLICYQUALINFO_pop(st) SKM_sk_pop(POLICYQUALINFO, (st))\n# define sk_POLICYQUALINFO_sort(st) SKM_sk_sort(POLICYQUALINFO, (st))\n# define sk_POLICYQUALINFO_is_sorted(st) SKM_sk_is_sorted(POLICYQUALINFO, (st))\n# define sk_POLICY_MAPPING_new(cmp) SKM_sk_new(POLICY_MAPPING, (cmp))\n# define sk_POLICY_MAPPING_new_null() SKM_sk_new_null(POLICY_MAPPING)\n# define sk_POLICY_MAPPING_free(st) SKM_sk_free(POLICY_MAPPING, (st))\n# define sk_POLICY_MAPPING_num(st) SKM_sk_num(POLICY_MAPPING, (st))\n# define sk_POLICY_MAPPING_value(st, i) SKM_sk_value(POLICY_MAPPING, (st), (i))\n# define sk_POLICY_MAPPING_set(st, i, val) SKM_sk_set(POLICY_MAPPING, (st), (i), (val))\n# define sk_POLICY_MAPPING_zero(st) SKM_sk_zero(POLICY_MAPPING, (st))\n# define sk_POLICY_MAPPING_push(st, val) SKM_sk_push(POLICY_MAPPING, (st), (val))\n# define sk_POLICY_MAPPING_unshift(st, val) SKM_sk_unshift(POLICY_MAPPING, (st), (val))\n# define sk_POLICY_MAPPING_find(st, val) SKM_sk_find(POLICY_MAPPING, (st), (val))\n# define sk_POLICY_MAPPING_find_ex(st, val) SKM_sk_find_ex(POLICY_MAPPING, (st), (val))\n# define sk_POLICY_MAPPING_delete(st, i) SKM_sk_delete(POLICY_MAPPING, (st), (i))\n# define sk_POLICY_MAPPING_delete_ptr(st, ptr) SKM_sk_delete_ptr(POLICY_MAPPING, (st), (ptr))\n# define sk_POLICY_MAPPING_insert(st, val, i) SKM_sk_insert(POLICY_MAPPING, (st), (val), (i))\n# define sk_POLICY_MAPPING_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(POLICY_MAPPING, (st), (cmp))\n# define sk_POLICY_MAPPING_dup(st) SKM_sk_dup(POLICY_MAPPING, st)\n# define sk_POLICY_MAPPING_pop_free(st, free_func) SKM_sk_pop_free(POLICY_MAPPING, (st), (free_func))\n# define sk_POLICY_MAPPING_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(POLICY_MAPPING, (st), (copy_func), (free_func))\n# define sk_POLICY_MAPPING_shift(st) SKM_sk_shift(POLICY_MAPPING, (st))\n# define sk_POLICY_MAPPING_pop(st) SKM_sk_pop(POLICY_MAPPING, (st))\n# define sk_POLICY_MAPPING_sort(st) SKM_sk_sort(POLICY_MAPPING, (st))\n# define sk_POLICY_MAPPING_is_sorted(st) SKM_sk_is_sorted(POLICY_MAPPING, (st))\n# define sk_SCT_new(cmp) SKM_sk_new(SCT, (cmp))\n# define sk_SCT_new_null() SKM_sk_new_null(SCT)\n# define sk_SCT_free(st) SKM_sk_free(SCT, (st))\n# define sk_SCT_num(st) SKM_sk_num(SCT, (st))\n# define sk_SCT_value(st, i) SKM_sk_value(SCT, (st), (i))\n# define sk_SCT_set(st, i, val) SKM_sk_set(SCT, (st), (i), (val))\n# define sk_SCT_zero(st) SKM_sk_zero(SCT, (st))\n# define sk_SCT_push(st, val) SKM_sk_push(SCT, (st), (val))\n# define sk_SCT_unshift(st, val) SKM_sk_unshift(SCT, (st), (val))\n# define sk_SCT_find(st, val) SKM_sk_find(SCT, (st), (val))\n# define sk_SCT_find_ex(st, val) SKM_sk_find_ex(SCT, (st), (val))\n# define sk_SCT_delete(st, i) SKM_sk_delete(SCT, (st), (i))\n# define sk_SCT_delete_ptr(st, ptr) SKM_sk_delete_ptr(SCT, (st), (ptr))\n# define sk_SCT_insert(st, val, i) SKM_sk_insert(SCT, (st), (val), (i))\n# define sk_SCT_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(SCT, (st), (cmp))\n# define sk_SCT_dup(st) SKM_sk_dup(SCT, st)\n# define sk_SCT_pop_free(st, free_func) SKM_sk_pop_free(SCT, (st), (free_func))\n# define sk_SCT_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(SCT, (st), (copy_func), (free_func))\n# define sk_SCT_shift(st) SKM_sk_shift(SCT, (st))\n# define sk_SCT_pop(st) SKM_sk_pop(SCT, (st))\n# define sk_SCT_sort(st) SKM_sk_sort(SCT, (st))\n# define sk_SCT_is_sorted(st) SKM_sk_is_sorted(SCT, (st))\n# define sk_SRP_gN_new(cmp) SKM_sk_new(SRP_gN, (cmp))\n# define sk_SRP_gN_new_null() SKM_sk_new_null(SRP_gN)\n# define sk_SRP_gN_free(st) SKM_sk_free(SRP_gN, (st))\n# define sk_SRP_gN_num(st) SKM_sk_num(SRP_gN, (st))\n# define sk_SRP_gN_value(st, i) SKM_sk_value(SRP_gN, (st), (i))\n# define sk_SRP_gN_set(st, i, val) SKM_sk_set(SRP_gN, (st), (i), (val))\n# define sk_SRP_gN_zero(st) SKM_sk_zero(SRP_gN, (st))\n# define sk_SRP_gN_push(st, val) SKM_sk_push(SRP_gN, (st), (val))\n# define sk_SRP_gN_unshift(st, val) SKM_sk_unshift(SRP_gN, (st), (val))\n# define sk_SRP_gN_find(st, val) SKM_sk_find(SRP_gN, (st), (val))\n# define sk_SRP_gN_find_ex(st, val) SKM_sk_find_ex(SRP_gN, (st), (val))\n# define sk_SRP_gN_delete(st, i) SKM_sk_delete(SRP_gN, (st), (i))\n# define sk_SRP_gN_delete_ptr(st, ptr) SKM_sk_delete_ptr(SRP_gN, (st), (ptr))\n# define sk_SRP_gN_insert(st, val, i) SKM_sk_insert(SRP_gN, (st), (val), (i))\n# define sk_SRP_gN_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(SRP_gN, (st), (cmp))\n# define sk_SRP_gN_dup(st) SKM_sk_dup(SRP_gN, st)\n# define sk_SRP_gN_pop_free(st, free_func) SKM_sk_pop_free(SRP_gN, (st), (free_func))\n# define sk_SRP_gN_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(SRP_gN, (st), (copy_func), (free_func))\n# define sk_SRP_gN_shift(st) SKM_sk_shift(SRP_gN, (st))\n# define sk_SRP_gN_pop(st) SKM_sk_pop(SRP_gN, (st))\n# define sk_SRP_gN_sort(st) SKM_sk_sort(SRP_gN, (st))\n# define sk_SRP_gN_is_sorted(st) SKM_sk_is_sorted(SRP_gN, (st))\n# define sk_SRP_gN_cache_new(cmp) SKM_sk_new(SRP_gN_cache, (cmp))\n# define sk_SRP_gN_cache_new_null() SKM_sk_new_null(SRP_gN_cache)\n# define sk_SRP_gN_cache_free(st) SKM_sk_free(SRP_gN_cache, (st))\n# define sk_SRP_gN_cache_num(st) SKM_sk_num(SRP_gN_cache, (st))\n# define sk_SRP_gN_cache_value(st, i) SKM_sk_value(SRP_gN_cache, (st), (i))\n# define sk_SRP_gN_cache_set(st, i, val) SKM_sk_set(SRP_gN_cache, (st), (i), (val))\n# define sk_SRP_gN_cache_zero(st) SKM_sk_zero(SRP_gN_cache, (st))\n# define sk_SRP_gN_cache_push(st, val) SKM_sk_push(SRP_gN_cache, (st), (val))\n# define sk_SRP_gN_cache_unshift(st, val) SKM_sk_unshift(SRP_gN_cache, (st), (val))\n# define sk_SRP_gN_cache_find(st, val) SKM_sk_find(SRP_gN_cache, (st), (val))\n# define sk_SRP_gN_cache_find_ex(st, val) SKM_sk_find_ex(SRP_gN_cache, (st), (val))\n# define sk_SRP_gN_cache_delete(st, i) SKM_sk_delete(SRP_gN_cache, (st), (i))\n# define sk_SRP_gN_cache_delete_ptr(st, ptr) SKM_sk_delete_ptr(SRP_gN_cache, (st), (ptr))\n# define sk_SRP_gN_cache_insert(st, val, i) SKM_sk_insert(SRP_gN_cache, (st), (val), (i))\n# define sk_SRP_gN_cache_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(SRP_gN_cache, (st), (cmp))\n# define sk_SRP_gN_cache_dup(st) SKM_sk_dup(SRP_gN_cache, st)\n# define sk_SRP_gN_cache_pop_free(st, free_func) SKM_sk_pop_free(SRP_gN_cache, (st), (free_func))\n# define sk_SRP_gN_cache_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(SRP_gN_cache, (st), (copy_func), (free_func))\n# define sk_SRP_gN_cache_shift(st) SKM_sk_shift(SRP_gN_cache, (st))\n# define sk_SRP_gN_cache_pop(st) SKM_sk_pop(SRP_gN_cache, (st))\n# define sk_SRP_gN_cache_sort(st) SKM_sk_sort(SRP_gN_cache, (st))\n# define sk_SRP_gN_cache_is_sorted(st) SKM_sk_is_sorted(SRP_gN_cache, (st))\n# define sk_SRP_user_pwd_new(cmp) SKM_sk_new(SRP_user_pwd, (cmp))\n# define sk_SRP_user_pwd_new_null() SKM_sk_new_null(SRP_user_pwd)\n# define sk_SRP_user_pwd_free(st) SKM_sk_free(SRP_user_pwd, (st))\n# define sk_SRP_user_pwd_num(st) SKM_sk_num(SRP_user_pwd, (st))\n# define sk_SRP_user_pwd_value(st, i) SKM_sk_value(SRP_user_pwd, (st), (i))\n# define sk_SRP_user_pwd_set(st, i, val) SKM_sk_set(SRP_user_pwd, (st), (i), (val))\n# define sk_SRP_user_pwd_zero(st) SKM_sk_zero(SRP_user_pwd, (st))\n# define sk_SRP_user_pwd_push(st, val) SKM_sk_push(SRP_user_pwd, (st), (val))\n# define sk_SRP_user_pwd_unshift(st, val) SKM_sk_unshift(SRP_user_pwd, (st), (val))\n# define sk_SRP_user_pwd_find(st, val) SKM_sk_find(SRP_user_pwd, (st), (val))\n# define sk_SRP_user_pwd_find_ex(st, val) SKM_sk_find_ex(SRP_user_pwd, (st), (val))\n# define sk_SRP_user_pwd_delete(st, i) SKM_sk_delete(SRP_user_pwd, (st), (i))\n# define sk_SRP_user_pwd_delete_ptr(st, ptr) SKM_sk_delete_ptr(SRP_user_pwd, (st), (ptr))\n# define sk_SRP_user_pwd_insert(st, val, i) SKM_sk_insert(SRP_user_pwd, (st), (val), (i))\n# define sk_SRP_user_pwd_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(SRP_user_pwd, (st), (cmp))\n# define sk_SRP_user_pwd_dup(st) SKM_sk_dup(SRP_user_pwd, st)\n# define sk_SRP_user_pwd_pop_free(st, free_func) SKM_sk_pop_free(SRP_user_pwd, (st), (free_func))\n# define sk_SRP_user_pwd_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(SRP_user_pwd, (st), (copy_func), (free_func))\n# define sk_SRP_user_pwd_shift(st) SKM_sk_shift(SRP_user_pwd, (st))\n# define sk_SRP_user_pwd_pop(st) SKM_sk_pop(SRP_user_pwd, (st))\n# define sk_SRP_user_pwd_sort(st) SKM_sk_sort(SRP_user_pwd, (st))\n# define sk_SRP_user_pwd_is_sorted(st) SKM_sk_is_sorted(SRP_user_pwd, (st))\n# define sk_SRTP_PROTECTION_PROFILE_new(cmp) SKM_sk_new(SRTP_PROTECTION_PROFILE, (cmp))\n# define sk_SRTP_PROTECTION_PROFILE_new_null() SKM_sk_new_null(SRTP_PROTECTION_PROFILE)\n# define sk_SRTP_PROTECTION_PROFILE_free(st) SKM_sk_free(SRTP_PROTECTION_PROFILE, (st))\n# define sk_SRTP_PROTECTION_PROFILE_num(st) SKM_sk_num(SRTP_PROTECTION_PROFILE, (st))\n# define sk_SRTP_PROTECTION_PROFILE_value(st, i) SKM_sk_value(SRTP_PROTECTION_PROFILE, (st), (i))\n# define sk_SRTP_PROTECTION_PROFILE_set(st, i, val) SKM_sk_set(SRTP_PROTECTION_PROFILE, (st), (i), (val))\n# define sk_SRTP_PROTECTION_PROFILE_zero(st) SKM_sk_zero(SRTP_PROTECTION_PROFILE, (st))\n# define sk_SRTP_PROTECTION_PROFILE_push(st, val) SKM_sk_push(SRTP_PROTECTION_PROFILE, (st), (val))\n# define sk_SRTP_PROTECTION_PROFILE_unshift(st, val) SKM_sk_unshift(SRTP_PROTECTION_PROFILE, (st), (val))\n# define sk_SRTP_PROTECTION_PROFILE_find(st, val) SKM_sk_find(SRTP_PROTECTION_PROFILE, (st), (val))\n# define sk_SRTP_PROTECTION_PROFILE_find_ex(st, val) SKM_sk_find_ex(SRTP_PROTECTION_PROFILE, (st), (val))\n# define sk_SRTP_PROTECTION_PROFILE_delete(st, i) SKM_sk_delete(SRTP_PROTECTION_PROFILE, (st), (i))\n# define sk_SRTP_PROTECTION_PROFILE_delete_ptr(st, ptr) SKM_sk_delete_ptr(SRTP_PROTECTION_PROFILE, (st), (ptr))\n# define sk_SRTP_PROTECTION_PROFILE_insert(st, val, i) SKM_sk_insert(SRTP_PROTECTION_PROFILE, (st), (val), (i))\n# define sk_SRTP_PROTECTION_PROFILE_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(SRTP_PROTECTION_PROFILE, (st), (cmp))\n# define sk_SRTP_PROTECTION_PROFILE_dup(st) SKM_sk_dup(SRTP_PROTECTION_PROFILE, st)\n# define sk_SRTP_PROTECTION_PROFILE_pop_free(st, free_func) SKM_sk_pop_free(SRTP_PROTECTION_PROFILE, (st), (free_func))\n# define sk_SRTP_PROTECTION_PROFILE_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(SRTP_PROTECTION_PROFILE, (st), (copy_func), (free_func))\n# define sk_SRTP_PROTECTION_PROFILE_shift(st) SKM_sk_shift(SRTP_PROTECTION_PROFILE, (st))\n# define sk_SRTP_PROTECTION_PROFILE_pop(st) SKM_sk_pop(SRTP_PROTECTION_PROFILE, (st))\n# define sk_SRTP_PROTECTION_PROFILE_sort(st) SKM_sk_sort(SRTP_PROTECTION_PROFILE, (st))\n# define sk_SRTP_PROTECTION_PROFILE_is_sorted(st) SKM_sk_is_sorted(SRTP_PROTECTION_PROFILE, (st))\n# define sk_SSL_CIPHER_new(cmp) SKM_sk_new(SSL_CIPHER, (cmp))\n# define sk_SSL_CIPHER_new_null() SKM_sk_new_null(SSL_CIPHER)\n# define sk_SSL_CIPHER_free(st) SKM_sk_free(SSL_CIPHER, (st))\n# define sk_SSL_CIPHER_num(st) SKM_sk_num(SSL_CIPHER, (st))\n# define sk_SSL_CIPHER_value(st, i) SKM_sk_value(SSL_CIPHER, (st), (i))\n# define sk_SSL_CIPHER_set(st, i, val) SKM_sk_set(SSL_CIPHER, (st), (i), (val))\n# define sk_SSL_CIPHER_zero(st) SKM_sk_zero(SSL_CIPHER, (st))\n# define sk_SSL_CIPHER_push(st, val) SKM_sk_push(SSL_CIPHER, (st), (val))\n# define sk_SSL_CIPHER_unshift(st, val) SKM_sk_unshift(SSL_CIPHER, (st), (val))\n# define sk_SSL_CIPHER_find(st, val) SKM_sk_find(SSL_CIPHER, (st), (val))\n# define sk_SSL_CIPHER_find_ex(st, val) SKM_sk_find_ex(SSL_CIPHER, (st), (val))\n# define sk_SSL_CIPHER_delete(st, i) SKM_sk_delete(SSL_CIPHER, (st), (i))\n# define sk_SSL_CIPHER_delete_ptr(st, ptr) SKM_sk_delete_ptr(SSL_CIPHER, (st), (ptr))\n# define sk_SSL_CIPHER_insert(st, val, i) SKM_sk_insert(SSL_CIPHER, (st), (val), (i))\n# define sk_SSL_CIPHER_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(SSL_CIPHER, (st), (cmp))\n# define sk_SSL_CIPHER_dup(st) SKM_sk_dup(SSL_CIPHER, st)\n# define sk_SSL_CIPHER_pop_free(st, free_func) SKM_sk_pop_free(SSL_CIPHER, (st), (free_func))\n# define sk_SSL_CIPHER_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(SSL_CIPHER, (st), (copy_func), (free_func))\n# define sk_SSL_CIPHER_shift(st) SKM_sk_shift(SSL_CIPHER, (st))\n# define sk_SSL_CIPHER_pop(st) SKM_sk_pop(SSL_CIPHER, (st))\n# define sk_SSL_CIPHER_sort(st) SKM_sk_sort(SSL_CIPHER, (st))\n# define sk_SSL_CIPHER_is_sorted(st) SKM_sk_is_sorted(SSL_CIPHER, (st))\n# define sk_SSL_COMP_new(cmp) SKM_sk_new(SSL_COMP, (cmp))\n# define sk_SSL_COMP_new_null() SKM_sk_new_null(SSL_COMP)\n# define sk_SSL_COMP_free(st) SKM_sk_free(SSL_COMP, (st))\n# define sk_SSL_COMP_num(st) SKM_sk_num(SSL_COMP, (st))\n# define sk_SSL_COMP_value(st, i) SKM_sk_value(SSL_COMP, (st), (i))\n# define sk_SSL_COMP_set(st, i, val) SKM_sk_set(SSL_COMP, (st), (i), (val))\n# define sk_SSL_COMP_zero(st) SKM_sk_zero(SSL_COMP, (st))\n# define sk_SSL_COMP_push(st, val) SKM_sk_push(SSL_COMP, (st), (val))\n# define sk_SSL_COMP_unshift(st, val) SKM_sk_unshift(SSL_COMP, (st), (val))\n# define sk_SSL_COMP_find(st, val) SKM_sk_find(SSL_COMP, (st), (val))\n# define sk_SSL_COMP_find_ex(st, val) SKM_sk_find_ex(SSL_COMP, (st), (val))\n# define sk_SSL_COMP_delete(st, i) SKM_sk_delete(SSL_COMP, (st), (i))\n# define sk_SSL_COMP_delete_ptr(st, ptr) SKM_sk_delete_ptr(SSL_COMP, (st), (ptr))\n# define sk_SSL_COMP_insert(st, val, i) SKM_sk_insert(SSL_COMP, (st), (val), (i))\n# define sk_SSL_COMP_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(SSL_COMP, (st), (cmp))\n# define sk_SSL_COMP_dup(st) SKM_sk_dup(SSL_COMP, st)\n# define sk_SSL_COMP_pop_free(st, free_func) SKM_sk_pop_free(SSL_COMP, (st), (free_func))\n# define sk_SSL_COMP_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(SSL_COMP, (st), (copy_func), (free_func))\n# define sk_SSL_COMP_shift(st) SKM_sk_shift(SSL_COMP, (st))\n# define sk_SSL_COMP_pop(st) SKM_sk_pop(SSL_COMP, (st))\n# define sk_SSL_COMP_sort(st) SKM_sk_sort(SSL_COMP, (st))\n# define sk_SSL_COMP_is_sorted(st) SKM_sk_is_sorted(SSL_COMP, (st))\n# define sk_STACK_OF_X509_NAME_ENTRY_new(cmp) SKM_sk_new(STACK_OF_X509_NAME_ENTRY, (cmp))\n# define sk_STACK_OF_X509_NAME_ENTRY_new_null() SKM_sk_new_null(STACK_OF_X509_NAME_ENTRY)\n# define sk_STACK_OF_X509_NAME_ENTRY_free(st) SKM_sk_free(STACK_OF_X509_NAME_ENTRY, (st))\n# define sk_STACK_OF_X509_NAME_ENTRY_num(st) SKM_sk_num(STACK_OF_X509_NAME_ENTRY, (st))\n# define sk_STACK_OF_X509_NAME_ENTRY_value(st, i) SKM_sk_value(STACK_OF_X509_NAME_ENTRY, (st), (i))\n# define sk_STACK_OF_X509_NAME_ENTRY_set(st, i, val) SKM_sk_set(STACK_OF_X509_NAME_ENTRY, (st), (i), (val))\n# define sk_STACK_OF_X509_NAME_ENTRY_zero(st) SKM_sk_zero(STACK_OF_X509_NAME_ENTRY, (st))\n# define sk_STACK_OF_X509_NAME_ENTRY_push(st, val) SKM_sk_push(STACK_OF_X509_NAME_ENTRY, (st), (val))\n# define sk_STACK_OF_X509_NAME_ENTRY_unshift(st, val) SKM_sk_unshift(STACK_OF_X509_NAME_ENTRY, (st), (val))\n# define sk_STACK_OF_X509_NAME_ENTRY_find(st, val) SKM_sk_find(STACK_OF_X509_NAME_ENTRY, (st), (val))\n# define sk_STACK_OF_X509_NAME_ENTRY_find_ex(st, val) SKM_sk_find_ex(STACK_OF_X509_NAME_ENTRY, (st), (val))\n# define sk_STACK_OF_X509_NAME_ENTRY_delete(st, i) SKM_sk_delete(STACK_OF_X509_NAME_ENTRY, (st), (i))\n# define sk_STACK_OF_X509_NAME_ENTRY_delete_ptr(st, ptr) SKM_sk_delete_ptr(STACK_OF_X509_NAME_ENTRY, (st), (ptr))\n# define sk_STACK_OF_X509_NAME_ENTRY_insert(st, val, i) SKM_sk_insert(STACK_OF_X509_NAME_ENTRY, (st), (val), (i))\n# define sk_STACK_OF_X509_NAME_ENTRY_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(STACK_OF_X509_NAME_ENTRY, (st), (cmp))\n# define sk_STACK_OF_X509_NAME_ENTRY_dup(st) SKM_sk_dup(STACK_OF_X509_NAME_ENTRY, st)\n# define sk_STACK_OF_X509_NAME_ENTRY_pop_free(st, free_func) SKM_sk_pop_free(STACK_OF_X509_NAME_ENTRY, (st), (free_func))\n# define sk_STACK_OF_X509_NAME_ENTRY_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(STACK_OF_X509_NAME_ENTRY, (st), (copy_func), (free_func))\n# define sk_STACK_OF_X509_NAME_ENTRY_shift(st) SKM_sk_shift(STACK_OF_X509_NAME_ENTRY, (st))\n# define sk_STACK_OF_X509_NAME_ENTRY_pop(st) SKM_sk_pop(STACK_OF_X509_NAME_ENTRY, (st))\n# define sk_STACK_OF_X509_NAME_ENTRY_sort(st) SKM_sk_sort(STACK_OF_X509_NAME_ENTRY, (st))\n# define sk_STACK_OF_X509_NAME_ENTRY_is_sorted(st) SKM_sk_is_sorted(STACK_OF_X509_NAME_ENTRY, (st))\n# define sk_STORE_ATTR_INFO_new(cmp) SKM_sk_new(STORE_ATTR_INFO, (cmp))\n# define sk_STORE_ATTR_INFO_new_null() SKM_sk_new_null(STORE_ATTR_INFO)\n# define sk_STORE_ATTR_INFO_free(st) SKM_sk_free(STORE_ATTR_INFO, (st))\n# define sk_STORE_ATTR_INFO_num(st) SKM_sk_num(STORE_ATTR_INFO, (st))\n# define sk_STORE_ATTR_INFO_value(st, i) SKM_sk_value(STORE_ATTR_INFO, (st), (i))\n# define sk_STORE_ATTR_INFO_set(st, i, val) SKM_sk_set(STORE_ATTR_INFO, (st), (i), (val))\n# define sk_STORE_ATTR_INFO_zero(st) SKM_sk_zero(STORE_ATTR_INFO, (st))\n# define sk_STORE_ATTR_INFO_push(st, val) SKM_sk_push(STORE_ATTR_INFO, (st), (val))\n# define sk_STORE_ATTR_INFO_unshift(st, val) SKM_sk_unshift(STORE_ATTR_INFO, (st), (val))\n# define sk_STORE_ATTR_INFO_find(st, val) SKM_sk_find(STORE_ATTR_INFO, (st), (val))\n# define sk_STORE_ATTR_INFO_find_ex(st, val) SKM_sk_find_ex(STORE_ATTR_INFO, (st), (val))\n# define sk_STORE_ATTR_INFO_delete(st, i) SKM_sk_delete(STORE_ATTR_INFO, (st), (i))\n# define sk_STORE_ATTR_INFO_delete_ptr(st, ptr) SKM_sk_delete_ptr(STORE_ATTR_INFO, (st), (ptr))\n# define sk_STORE_ATTR_INFO_insert(st, val, i) SKM_sk_insert(STORE_ATTR_INFO, (st), (val), (i))\n# define sk_STORE_ATTR_INFO_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(STORE_ATTR_INFO, (st), (cmp))\n# define sk_STORE_ATTR_INFO_dup(st) SKM_sk_dup(STORE_ATTR_INFO, st)\n# define sk_STORE_ATTR_INFO_pop_free(st, free_func) SKM_sk_pop_free(STORE_ATTR_INFO, (st), (free_func))\n# define sk_STORE_ATTR_INFO_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(STORE_ATTR_INFO, (st), (copy_func), (free_func))\n# define sk_STORE_ATTR_INFO_shift(st) SKM_sk_shift(STORE_ATTR_INFO, (st))\n# define sk_STORE_ATTR_INFO_pop(st) SKM_sk_pop(STORE_ATTR_INFO, (st))\n# define sk_STORE_ATTR_INFO_sort(st) SKM_sk_sort(STORE_ATTR_INFO, (st))\n# define sk_STORE_ATTR_INFO_is_sorted(st) SKM_sk_is_sorted(STORE_ATTR_INFO, (st))\n# define sk_STORE_OBJECT_new(cmp) SKM_sk_new(STORE_OBJECT, (cmp))\n# define sk_STORE_OBJECT_new_null() SKM_sk_new_null(STORE_OBJECT)\n# define sk_STORE_OBJECT_free(st) SKM_sk_free(STORE_OBJECT, (st))\n# define sk_STORE_OBJECT_num(st) SKM_sk_num(STORE_OBJECT, (st))\n# define sk_STORE_OBJECT_value(st, i) SKM_sk_value(STORE_OBJECT, (st), (i))\n# define sk_STORE_OBJECT_set(st, i, val) SKM_sk_set(STORE_OBJECT, (st), (i), (val))\n# define sk_STORE_OBJECT_zero(st) SKM_sk_zero(STORE_OBJECT, (st))\n# define sk_STORE_OBJECT_push(st, val) SKM_sk_push(STORE_OBJECT, (st), (val))\n# define sk_STORE_OBJECT_unshift(st, val) SKM_sk_unshift(STORE_OBJECT, (st), (val))\n# define sk_STORE_OBJECT_find(st, val) SKM_sk_find(STORE_OBJECT, (st), (val))\n# define sk_STORE_OBJECT_find_ex(st, val) SKM_sk_find_ex(STORE_OBJECT, (st), (val))\n# define sk_STORE_OBJECT_delete(st, i) SKM_sk_delete(STORE_OBJECT, (st), (i))\n# define sk_STORE_OBJECT_delete_ptr(st, ptr) SKM_sk_delete_ptr(STORE_OBJECT, (st), (ptr))\n# define sk_STORE_OBJECT_insert(st, val, i) SKM_sk_insert(STORE_OBJECT, (st), (val), (i))\n# define sk_STORE_OBJECT_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(STORE_OBJECT, (st), (cmp))\n# define sk_STORE_OBJECT_dup(st) SKM_sk_dup(STORE_OBJECT, st)\n# define sk_STORE_OBJECT_pop_free(st, free_func) SKM_sk_pop_free(STORE_OBJECT, (st), (free_func))\n# define sk_STORE_OBJECT_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(STORE_OBJECT, (st), (copy_func), (free_func))\n# define sk_STORE_OBJECT_shift(st) SKM_sk_shift(STORE_OBJECT, (st))\n# define sk_STORE_OBJECT_pop(st) SKM_sk_pop(STORE_OBJECT, (st))\n# define sk_STORE_OBJECT_sort(st) SKM_sk_sort(STORE_OBJECT, (st))\n# define sk_STORE_OBJECT_is_sorted(st) SKM_sk_is_sorted(STORE_OBJECT, (st))\n# define sk_SXNETID_new(cmp) SKM_sk_new(SXNETID, (cmp))\n# define sk_SXNETID_new_null() SKM_sk_new_null(SXNETID)\n# define sk_SXNETID_free(st) SKM_sk_free(SXNETID, (st))\n# define sk_SXNETID_num(st) SKM_sk_num(SXNETID, (st))\n# define sk_SXNETID_value(st, i) SKM_sk_value(SXNETID, (st), (i))\n# define sk_SXNETID_set(st, i, val) SKM_sk_set(SXNETID, (st), (i), (val))\n# define sk_SXNETID_zero(st) SKM_sk_zero(SXNETID, (st))\n# define sk_SXNETID_push(st, val) SKM_sk_push(SXNETID, (st), (val))\n# define sk_SXNETID_unshift(st, val) SKM_sk_unshift(SXNETID, (st), (val))\n# define sk_SXNETID_find(st, val) SKM_sk_find(SXNETID, (st), (val))\n# define sk_SXNETID_find_ex(st, val) SKM_sk_find_ex(SXNETID, (st), (val))\n# define sk_SXNETID_delete(st, i) SKM_sk_delete(SXNETID, (st), (i))\n# define sk_SXNETID_delete_ptr(st, ptr) SKM_sk_delete_ptr(SXNETID, (st), (ptr))\n# define sk_SXNETID_insert(st, val, i) SKM_sk_insert(SXNETID, (st), (val), (i))\n# define sk_SXNETID_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(SXNETID, (st), (cmp))\n# define sk_SXNETID_dup(st) SKM_sk_dup(SXNETID, st)\n# define sk_SXNETID_pop_free(st, free_func) SKM_sk_pop_free(SXNETID, (st), (free_func))\n# define sk_SXNETID_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(SXNETID, (st), (copy_func), (free_func))\n# define sk_SXNETID_shift(st) SKM_sk_shift(SXNETID, (st))\n# define sk_SXNETID_pop(st) SKM_sk_pop(SXNETID, (st))\n# define sk_SXNETID_sort(st) SKM_sk_sort(SXNETID, (st))\n# define sk_SXNETID_is_sorted(st) SKM_sk_is_sorted(SXNETID, (st))\n# define sk_UI_STRING_new(cmp) SKM_sk_new(UI_STRING, (cmp))\n# define sk_UI_STRING_new_null() SKM_sk_new_null(UI_STRING)\n# define sk_UI_STRING_free(st) SKM_sk_free(UI_STRING, (st))\n# define sk_UI_STRING_num(st) SKM_sk_num(UI_STRING, (st))\n# define sk_UI_STRING_value(st, i) SKM_sk_value(UI_STRING, (st), (i))\n# define sk_UI_STRING_set(st, i, val) SKM_sk_set(UI_STRING, (st), (i), (val))\n# define sk_UI_STRING_zero(st) SKM_sk_zero(UI_STRING, (st))\n# define sk_UI_STRING_push(st, val) SKM_sk_push(UI_STRING, (st), (val))\n# define sk_UI_STRING_unshift(st, val) SKM_sk_unshift(UI_STRING, (st), (val))\n# define sk_UI_STRING_find(st, val) SKM_sk_find(UI_STRING, (st), (val))\n# define sk_UI_STRING_find_ex(st, val) SKM_sk_find_ex(UI_STRING, (st), (val))\n# define sk_UI_STRING_delete(st, i) SKM_sk_delete(UI_STRING, (st), (i))\n# define sk_UI_STRING_delete_ptr(st, ptr) SKM_sk_delete_ptr(UI_STRING, (st), (ptr))\n# define sk_UI_STRING_insert(st, val, i) SKM_sk_insert(UI_STRING, (st), (val), (i))\n# define sk_UI_STRING_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(UI_STRING, (st), (cmp))\n# define sk_UI_STRING_dup(st) SKM_sk_dup(UI_STRING, st)\n# define sk_UI_STRING_pop_free(st, free_func) SKM_sk_pop_free(UI_STRING, (st), (free_func))\n# define sk_UI_STRING_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(UI_STRING, (st), (copy_func), (free_func))\n# define sk_UI_STRING_shift(st) SKM_sk_shift(UI_STRING, (st))\n# define sk_UI_STRING_pop(st) SKM_sk_pop(UI_STRING, (st))\n# define sk_UI_STRING_sort(st) SKM_sk_sort(UI_STRING, (st))\n# define sk_UI_STRING_is_sorted(st) SKM_sk_is_sorted(UI_STRING, (st))\n# define sk_X509_new(cmp) SKM_sk_new(X509, (cmp))\n# define sk_X509_new_null() SKM_sk_new_null(X509)\n# define sk_X509_free(st) SKM_sk_free(X509, (st))\n# define sk_X509_num(st) SKM_sk_num(X509, (st))\n# define sk_X509_value(st, i) SKM_sk_value(X509, (st), (i))\n# define sk_X509_set(st, i, val) SKM_sk_set(X509, (st), (i), (val))\n# define sk_X509_zero(st) SKM_sk_zero(X509, (st))\n# define sk_X509_push(st, val) SKM_sk_push(X509, (st), (val))\n# define sk_X509_unshift(st, val) SKM_sk_unshift(X509, (st), (val))\n# define sk_X509_find(st, val) SKM_sk_find(X509, (st), (val))\n# define sk_X509_find_ex(st, val) SKM_sk_find_ex(X509, (st), (val))\n# define sk_X509_delete(st, i) SKM_sk_delete(X509, (st), (i))\n# define sk_X509_delete_ptr(st, ptr) SKM_sk_delete_ptr(X509, (st), (ptr))\n# define sk_X509_insert(st, val, i) SKM_sk_insert(X509, (st), (val), (i))\n# define sk_X509_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(X509, (st), (cmp))\n# define sk_X509_dup(st) SKM_sk_dup(X509, st)\n# define sk_X509_pop_free(st, free_func) SKM_sk_pop_free(X509, (st), (free_func))\n# define sk_X509_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(X509, (st), (copy_func), (free_func))\n# define sk_X509_shift(st) SKM_sk_shift(X509, (st))\n# define sk_X509_pop(st) SKM_sk_pop(X509, (st))\n# define sk_X509_sort(st) SKM_sk_sort(X509, (st))\n# define sk_X509_is_sorted(st) SKM_sk_is_sorted(X509, (st))\n# define sk_X509V3_EXT_METHOD_new(cmp) SKM_sk_new(X509V3_EXT_METHOD, (cmp))\n# define sk_X509V3_EXT_METHOD_new_null() SKM_sk_new_null(X509V3_EXT_METHOD)\n# define sk_X509V3_EXT_METHOD_free(st) SKM_sk_free(X509V3_EXT_METHOD, (st))\n# define sk_X509V3_EXT_METHOD_num(st) SKM_sk_num(X509V3_EXT_METHOD, (st))\n# define sk_X509V3_EXT_METHOD_value(st, i) SKM_sk_value(X509V3_EXT_METHOD, (st), (i))\n# define sk_X509V3_EXT_METHOD_set(st, i, val) SKM_sk_set(X509V3_EXT_METHOD, (st), (i), (val))\n# define sk_X509V3_EXT_METHOD_zero(st) SKM_sk_zero(X509V3_EXT_METHOD, (st))\n# define sk_X509V3_EXT_METHOD_push(st, val) SKM_sk_push(X509V3_EXT_METHOD, (st), (val))\n# define sk_X509V3_EXT_METHOD_unshift(st, val) SKM_sk_unshift(X509V3_EXT_METHOD, (st), (val))\n# define sk_X509V3_EXT_METHOD_find(st, val) SKM_sk_find(X509V3_EXT_METHOD, (st), (val))\n# define sk_X509V3_EXT_METHOD_find_ex(st, val) SKM_sk_find_ex(X509V3_EXT_METHOD, (st), (val))\n# define sk_X509V3_EXT_METHOD_delete(st, i) SKM_sk_delete(X509V3_EXT_METHOD, (st), (i))\n# define sk_X509V3_EXT_METHOD_delete_ptr(st, ptr) SKM_sk_delete_ptr(X509V3_EXT_METHOD, (st), (ptr))\n# define sk_X509V3_EXT_METHOD_insert(st, val, i) SKM_sk_insert(X509V3_EXT_METHOD, (st), (val), (i))\n# define sk_X509V3_EXT_METHOD_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(X509V3_EXT_METHOD, (st), (cmp))\n# define sk_X509V3_EXT_METHOD_dup(st) SKM_sk_dup(X509V3_EXT_METHOD, st)\n# define sk_X509V3_EXT_METHOD_pop_free(st, free_func) SKM_sk_pop_free(X509V3_EXT_METHOD, (st), (free_func))\n# define sk_X509V3_EXT_METHOD_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(X509V3_EXT_METHOD, (st), (copy_func), (free_func))\n# define sk_X509V3_EXT_METHOD_shift(st) SKM_sk_shift(X509V3_EXT_METHOD, (st))\n# define sk_X509V3_EXT_METHOD_pop(st) SKM_sk_pop(X509V3_EXT_METHOD, (st))\n# define sk_X509V3_EXT_METHOD_sort(st) SKM_sk_sort(X509V3_EXT_METHOD, (st))\n# define sk_X509V3_EXT_METHOD_is_sorted(st) SKM_sk_is_sorted(X509V3_EXT_METHOD, (st))\n# define sk_X509_ALGOR_new(cmp) SKM_sk_new(X509_ALGOR, (cmp))\n# define sk_X509_ALGOR_new_null() SKM_sk_new_null(X509_ALGOR)\n# define sk_X509_ALGOR_free(st) SKM_sk_free(X509_ALGOR, (st))\n# define sk_X509_ALGOR_num(st) SKM_sk_num(X509_ALGOR, (st))\n# define sk_X509_ALGOR_value(st, i) SKM_sk_value(X509_ALGOR, (st), (i))\n# define sk_X509_ALGOR_set(st, i, val) SKM_sk_set(X509_ALGOR, (st), (i), (val))\n# define sk_X509_ALGOR_zero(st) SKM_sk_zero(X509_ALGOR, (st))\n# define sk_X509_ALGOR_push(st, val) SKM_sk_push(X509_ALGOR, (st), (val))\n# define sk_X509_ALGOR_unshift(st, val) SKM_sk_unshift(X509_ALGOR, (st), (val))\n# define sk_X509_ALGOR_find(st, val) SKM_sk_find(X509_ALGOR, (st), (val))\n# define sk_X509_ALGOR_find_ex(st, val) SKM_sk_find_ex(X509_ALGOR, (st), (val))\n# define sk_X509_ALGOR_delete(st, i) SKM_sk_delete(X509_ALGOR, (st), (i))\n# define sk_X509_ALGOR_delete_ptr(st, ptr) SKM_sk_delete_ptr(X509_ALGOR, (st), (ptr))\n# define sk_X509_ALGOR_insert(st, val, i) SKM_sk_insert(X509_ALGOR, (st), (val), (i))\n# define sk_X509_ALGOR_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(X509_ALGOR, (st), (cmp))\n# define sk_X509_ALGOR_dup(st) SKM_sk_dup(X509_ALGOR, st)\n# define sk_X509_ALGOR_pop_free(st, free_func) SKM_sk_pop_free(X509_ALGOR, (st), (free_func))\n# define sk_X509_ALGOR_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(X509_ALGOR, (st), (copy_func), (free_func))\n# define sk_X509_ALGOR_shift(st) SKM_sk_shift(X509_ALGOR, (st))\n# define sk_X509_ALGOR_pop(st) SKM_sk_pop(X509_ALGOR, (st))\n# define sk_X509_ALGOR_sort(st) SKM_sk_sort(X509_ALGOR, (st))\n# define sk_X509_ALGOR_is_sorted(st) SKM_sk_is_sorted(X509_ALGOR, (st))\n# define sk_X509_ATTRIBUTE_new(cmp) SKM_sk_new(X509_ATTRIBUTE, (cmp))\n# define sk_X509_ATTRIBUTE_new_null() SKM_sk_new_null(X509_ATTRIBUTE)\n# define sk_X509_ATTRIBUTE_free(st) SKM_sk_free(X509_ATTRIBUTE, (st))\n# define sk_X509_ATTRIBUTE_num(st) SKM_sk_num(X509_ATTRIBUTE, (st))\n# define sk_X509_ATTRIBUTE_value(st, i) SKM_sk_value(X509_ATTRIBUTE, (st), (i))\n# define sk_X509_ATTRIBUTE_set(st, i, val) SKM_sk_set(X509_ATTRIBUTE, (st), (i), (val))\n# define sk_X509_ATTRIBUTE_zero(st) SKM_sk_zero(X509_ATTRIBUTE, (st))\n# define sk_X509_ATTRIBUTE_push(st, val) SKM_sk_push(X509_ATTRIBUTE, (st), (val))\n# define sk_X509_ATTRIBUTE_unshift(st, val) SKM_sk_unshift(X509_ATTRIBUTE, (st), (val))\n# define sk_X509_ATTRIBUTE_find(st, val) SKM_sk_find(X509_ATTRIBUTE, (st), (val))\n# define sk_X509_ATTRIBUTE_find_ex(st, val) SKM_sk_find_ex(X509_ATTRIBUTE, (st), (val))\n# define sk_X509_ATTRIBUTE_delete(st, i) SKM_sk_delete(X509_ATTRIBUTE, (st), (i))\n# define sk_X509_ATTRIBUTE_delete_ptr(st, ptr) SKM_sk_delete_ptr(X509_ATTRIBUTE, (st), (ptr))\n# define sk_X509_ATTRIBUTE_insert(st, val, i) SKM_sk_insert(X509_ATTRIBUTE, (st), (val), (i))\n# define sk_X509_ATTRIBUTE_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(X509_ATTRIBUTE, (st), (cmp))\n# define sk_X509_ATTRIBUTE_dup(st) SKM_sk_dup(X509_ATTRIBUTE, st)\n# define sk_X509_ATTRIBUTE_pop_free(st, free_func) SKM_sk_pop_free(X509_ATTRIBUTE, (st), (free_func))\n# define sk_X509_ATTRIBUTE_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(X509_ATTRIBUTE, (st), (copy_func), (free_func))\n# define sk_X509_ATTRIBUTE_shift(st) SKM_sk_shift(X509_ATTRIBUTE, (st))\n# define sk_X509_ATTRIBUTE_pop(st) SKM_sk_pop(X509_ATTRIBUTE, (st))\n# define sk_X509_ATTRIBUTE_sort(st) SKM_sk_sort(X509_ATTRIBUTE, (st))\n# define sk_X509_ATTRIBUTE_is_sorted(st) SKM_sk_is_sorted(X509_ATTRIBUTE, (st))\n# define sk_X509_CRL_new(cmp) SKM_sk_new(X509_CRL, (cmp))\n# define sk_X509_CRL_new_null() SKM_sk_new_null(X509_CRL)\n# define sk_X509_CRL_free(st) SKM_sk_free(X509_CRL, (st))\n# define sk_X509_CRL_num(st) SKM_sk_num(X509_CRL, (st))\n# define sk_X509_CRL_value(st, i) SKM_sk_value(X509_CRL, (st), (i))\n# define sk_X509_CRL_set(st, i, val) SKM_sk_set(X509_CRL, (st), (i), (val))\n# define sk_X509_CRL_zero(st) SKM_sk_zero(X509_CRL, (st))\n# define sk_X509_CRL_push(st, val) SKM_sk_push(X509_CRL, (st), (val))\n# define sk_X509_CRL_unshift(st, val) SKM_sk_unshift(X509_CRL, (st), (val))\n# define sk_X509_CRL_find(st, val) SKM_sk_find(X509_CRL, (st), (val))\n# define sk_X509_CRL_find_ex(st, val) SKM_sk_find_ex(X509_CRL, (st), (val))\n# define sk_X509_CRL_delete(st, i) SKM_sk_delete(X509_CRL, (st), (i))\n# define sk_X509_CRL_delete_ptr(st, ptr) SKM_sk_delete_ptr(X509_CRL, (st), (ptr))\n# define sk_X509_CRL_insert(st, val, i) SKM_sk_insert(X509_CRL, (st), (val), (i))\n# define sk_X509_CRL_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(X509_CRL, (st), (cmp))\n# define sk_X509_CRL_dup(st) SKM_sk_dup(X509_CRL, st)\n# define sk_X509_CRL_pop_free(st, free_func) SKM_sk_pop_free(X509_CRL, (st), (free_func))\n# define sk_X509_CRL_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(X509_CRL, (st), (copy_func), (free_func))\n# define sk_X509_CRL_shift(st) SKM_sk_shift(X509_CRL, (st))\n# define sk_X509_CRL_pop(st) SKM_sk_pop(X509_CRL, (st))\n# define sk_X509_CRL_sort(st) SKM_sk_sort(X509_CRL, (st))\n# define sk_X509_CRL_is_sorted(st) SKM_sk_is_sorted(X509_CRL, (st))\n# define sk_X509_EXTENSION_new(cmp) SKM_sk_new(X509_EXTENSION, (cmp))\n# define sk_X509_EXTENSION_new_null() SKM_sk_new_null(X509_EXTENSION)\n# define sk_X509_EXTENSION_free(st) SKM_sk_free(X509_EXTENSION, (st))\n# define sk_X509_EXTENSION_num(st) SKM_sk_num(X509_EXTENSION, (st))\n# define sk_X509_EXTENSION_value(st, i) SKM_sk_value(X509_EXTENSION, (st), (i))\n# define sk_X509_EXTENSION_set(st, i, val) SKM_sk_set(X509_EXTENSION, (st), (i), (val))\n# define sk_X509_EXTENSION_zero(st) SKM_sk_zero(X509_EXTENSION, (st))\n# define sk_X509_EXTENSION_push(st, val) SKM_sk_push(X509_EXTENSION, (st), (val))\n# define sk_X509_EXTENSION_unshift(st, val) SKM_sk_unshift(X509_EXTENSION, (st), (val))\n# define sk_X509_EXTENSION_find(st, val) SKM_sk_find(X509_EXTENSION, (st), (val))\n# define sk_X509_EXTENSION_find_ex(st, val) SKM_sk_find_ex(X509_EXTENSION, (st), (val))\n# define sk_X509_EXTENSION_delete(st, i) SKM_sk_delete(X509_EXTENSION, (st), (i))\n# define sk_X509_EXTENSION_delete_ptr(st, ptr) SKM_sk_delete_ptr(X509_EXTENSION, (st), (ptr))\n# define sk_X509_EXTENSION_insert(st, val, i) SKM_sk_insert(X509_EXTENSION, (st), (val), (i))\n# define sk_X509_EXTENSION_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(X509_EXTENSION, (st), (cmp))\n# define sk_X509_EXTENSION_dup(st) SKM_sk_dup(X509_EXTENSION, st)\n# define sk_X509_EXTENSION_pop_free(st, free_func) SKM_sk_pop_free(X509_EXTENSION, (st), (free_func))\n# define sk_X509_EXTENSION_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(X509_EXTENSION, (st), (copy_func), (free_func))\n# define sk_X509_EXTENSION_shift(st) SKM_sk_shift(X509_EXTENSION, (st))\n# define sk_X509_EXTENSION_pop(st) SKM_sk_pop(X509_EXTENSION, (st))\n# define sk_X509_EXTENSION_sort(st) SKM_sk_sort(X509_EXTENSION, (st))\n# define sk_X509_EXTENSION_is_sorted(st) SKM_sk_is_sorted(X509_EXTENSION, (st))\n# define sk_X509_INFO_new(cmp) SKM_sk_new(X509_INFO, (cmp))\n# define sk_X509_INFO_new_null() SKM_sk_new_null(X509_INFO)\n# define sk_X509_INFO_free(st) SKM_sk_free(X509_INFO, (st))\n# define sk_X509_INFO_num(st) SKM_sk_num(X509_INFO, (st))\n# define sk_X509_INFO_value(st, i) SKM_sk_value(X509_INFO, (st), (i))\n# define sk_X509_INFO_set(st, i, val) SKM_sk_set(X509_INFO, (st), (i), (val))\n# define sk_X509_INFO_zero(st) SKM_sk_zero(X509_INFO, (st))\n# define sk_X509_INFO_push(st, val) SKM_sk_push(X509_INFO, (st), (val))\n# define sk_X509_INFO_unshift(st, val) SKM_sk_unshift(X509_INFO, (st), (val))\n# define sk_X509_INFO_find(st, val) SKM_sk_find(X509_INFO, (st), (val))\n# define sk_X509_INFO_find_ex(st, val) SKM_sk_find_ex(X509_INFO, (st), (val))\n# define sk_X509_INFO_delete(st, i) SKM_sk_delete(X509_INFO, (st), (i))\n# define sk_X509_INFO_delete_ptr(st, ptr) SKM_sk_delete_ptr(X509_INFO, (st), (ptr))\n# define sk_X509_INFO_insert(st, val, i) SKM_sk_insert(X509_INFO, (st), (val), (i))\n# define sk_X509_INFO_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(X509_INFO, (st), (cmp))\n# define sk_X509_INFO_dup(st) SKM_sk_dup(X509_INFO, st)\n# define sk_X509_INFO_pop_free(st, free_func) SKM_sk_pop_free(X509_INFO, (st), (free_func))\n# define sk_X509_INFO_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(X509_INFO, (st), (copy_func), (free_func))\n# define sk_X509_INFO_shift(st) SKM_sk_shift(X509_INFO, (st))\n# define sk_X509_INFO_pop(st) SKM_sk_pop(X509_INFO, (st))\n# define sk_X509_INFO_sort(st) SKM_sk_sort(X509_INFO, (st))\n# define sk_X509_INFO_is_sorted(st) SKM_sk_is_sorted(X509_INFO, (st))\n# define sk_X509_LOOKUP_new(cmp) SKM_sk_new(X509_LOOKUP, (cmp))\n# define sk_X509_LOOKUP_new_null() SKM_sk_new_null(X509_LOOKUP)\n# define sk_X509_LOOKUP_free(st) SKM_sk_free(X509_LOOKUP, (st))\n# define sk_X509_LOOKUP_num(st) SKM_sk_num(X509_LOOKUP, (st))\n# define sk_X509_LOOKUP_value(st, i) SKM_sk_value(X509_LOOKUP, (st), (i))\n# define sk_X509_LOOKUP_set(st, i, val) SKM_sk_set(X509_LOOKUP, (st), (i), (val))\n# define sk_X509_LOOKUP_zero(st) SKM_sk_zero(X509_LOOKUP, (st))\n# define sk_X509_LOOKUP_push(st, val) SKM_sk_push(X509_LOOKUP, (st), (val))\n# define sk_X509_LOOKUP_unshift(st, val) SKM_sk_unshift(X509_LOOKUP, (st), (val))\n# define sk_X509_LOOKUP_find(st, val) SKM_sk_find(X509_LOOKUP, (st), (val))\n# define sk_X509_LOOKUP_find_ex(st, val) SKM_sk_find_ex(X509_LOOKUP, (st), (val))\n# define sk_X509_LOOKUP_delete(st, i) SKM_sk_delete(X509_LOOKUP, (st), (i))\n# define sk_X509_LOOKUP_delete_ptr(st, ptr) SKM_sk_delete_ptr(X509_LOOKUP, (st), (ptr))\n# define sk_X509_LOOKUP_insert(st, val, i) SKM_sk_insert(X509_LOOKUP, (st), (val), (i))\n# define sk_X509_LOOKUP_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(X509_LOOKUP, (st), (cmp))\n# define sk_X509_LOOKUP_dup(st) SKM_sk_dup(X509_LOOKUP, st)\n# define sk_X509_LOOKUP_pop_free(st, free_func) SKM_sk_pop_free(X509_LOOKUP, (st), (free_func))\n# define sk_X509_LOOKUP_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(X509_LOOKUP, (st), (copy_func), (free_func))\n# define sk_X509_LOOKUP_shift(st) SKM_sk_shift(X509_LOOKUP, (st))\n# define sk_X509_LOOKUP_pop(st) SKM_sk_pop(X509_LOOKUP, (st))\n# define sk_X509_LOOKUP_sort(st) SKM_sk_sort(X509_LOOKUP, (st))\n# define sk_X509_LOOKUP_is_sorted(st) SKM_sk_is_sorted(X509_LOOKUP, (st))\n# define sk_X509_NAME_new(cmp) SKM_sk_new(X509_NAME, (cmp))\n# define sk_X509_NAME_new_null() SKM_sk_new_null(X509_NAME)\n# define sk_X509_NAME_free(st) SKM_sk_free(X509_NAME, (st))\n# define sk_X509_NAME_num(st) SKM_sk_num(X509_NAME, (st))\n# define sk_X509_NAME_value(st, i) SKM_sk_value(X509_NAME, (st), (i))\n# define sk_X509_NAME_set(st, i, val) SKM_sk_set(X509_NAME, (st), (i), (val))\n# define sk_X509_NAME_zero(st) SKM_sk_zero(X509_NAME, (st))\n# define sk_X509_NAME_push(st, val) SKM_sk_push(X509_NAME, (st), (val))\n# define sk_X509_NAME_unshift(st, val) SKM_sk_unshift(X509_NAME, (st), (val))\n# define sk_X509_NAME_find(st, val) SKM_sk_find(X509_NAME, (st), (val))\n# define sk_X509_NAME_find_ex(st, val) SKM_sk_find_ex(X509_NAME, (st), (val))\n# define sk_X509_NAME_delete(st, i) SKM_sk_delete(X509_NAME, (st), (i))\n# define sk_X509_NAME_delete_ptr(st, ptr) SKM_sk_delete_ptr(X509_NAME, (st), (ptr))\n# define sk_X509_NAME_insert(st, val, i) SKM_sk_insert(X509_NAME, (st), (val), (i))\n# define sk_X509_NAME_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(X509_NAME, (st), (cmp))\n# define sk_X509_NAME_dup(st) SKM_sk_dup(X509_NAME, st)\n# define sk_X509_NAME_pop_free(st, free_func) SKM_sk_pop_free(X509_NAME, (st), (free_func))\n# define sk_X509_NAME_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(X509_NAME, (st), (copy_func), (free_func))\n# define sk_X509_NAME_shift(st) SKM_sk_shift(X509_NAME, (st))\n# define sk_X509_NAME_pop(st) SKM_sk_pop(X509_NAME, (st))\n# define sk_X509_NAME_sort(st) SKM_sk_sort(X509_NAME, (st))\n# define sk_X509_NAME_is_sorted(st) SKM_sk_is_sorted(X509_NAME, (st))\n# define sk_X509_NAME_ENTRY_new(cmp) SKM_sk_new(X509_NAME_ENTRY, (cmp))\n# define sk_X509_NAME_ENTRY_new_null() SKM_sk_new_null(X509_NAME_ENTRY)\n# define sk_X509_NAME_ENTRY_free(st) SKM_sk_free(X509_NAME_ENTRY, (st))\n# define sk_X509_NAME_ENTRY_num(st) SKM_sk_num(X509_NAME_ENTRY, (st))\n# define sk_X509_NAME_ENTRY_value(st, i) SKM_sk_value(X509_NAME_ENTRY, (st), (i))\n# define sk_X509_NAME_ENTRY_set(st, i, val) SKM_sk_set(X509_NAME_ENTRY, (st), (i), (val))\n# define sk_X509_NAME_ENTRY_zero(st) SKM_sk_zero(X509_NAME_ENTRY, (st))\n# define sk_X509_NAME_ENTRY_push(st, val) SKM_sk_push(X509_NAME_ENTRY, (st), (val))\n# define sk_X509_NAME_ENTRY_unshift(st, val) SKM_sk_unshift(X509_NAME_ENTRY, (st), (val))\n# define sk_X509_NAME_ENTRY_find(st, val) SKM_sk_find(X509_NAME_ENTRY, (st), (val))\n# define sk_X509_NAME_ENTRY_find_ex(st, val) SKM_sk_find_ex(X509_NAME_ENTRY, (st), (val))\n# define sk_X509_NAME_ENTRY_delete(st, i) SKM_sk_delete(X509_NAME_ENTRY, (st), (i))\n# define sk_X509_NAME_ENTRY_delete_ptr(st, ptr) SKM_sk_delete_ptr(X509_NAME_ENTRY, (st), (ptr))\n# define sk_X509_NAME_ENTRY_insert(st, val, i) SKM_sk_insert(X509_NAME_ENTRY, (st), (val), (i))\n# define sk_X509_NAME_ENTRY_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(X509_NAME_ENTRY, (st), (cmp))\n# define sk_X509_NAME_ENTRY_dup(st) SKM_sk_dup(X509_NAME_ENTRY, st)\n# define sk_X509_NAME_ENTRY_pop_free(st, free_func) SKM_sk_pop_free(X509_NAME_ENTRY, (st), (free_func))\n# define sk_X509_NAME_ENTRY_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(X509_NAME_ENTRY, (st), (copy_func), (free_func))\n# define sk_X509_NAME_ENTRY_shift(st) SKM_sk_shift(X509_NAME_ENTRY, (st))\n# define sk_X509_NAME_ENTRY_pop(st) SKM_sk_pop(X509_NAME_ENTRY, (st))\n# define sk_X509_NAME_ENTRY_sort(st) SKM_sk_sort(X509_NAME_ENTRY, (st))\n# define sk_X509_NAME_ENTRY_is_sorted(st) SKM_sk_is_sorted(X509_NAME_ENTRY, (st))\n# define sk_X509_OBJECT_new(cmp) SKM_sk_new(X509_OBJECT, (cmp))\n# define sk_X509_OBJECT_new_null() SKM_sk_new_null(X509_OBJECT)\n# define sk_X509_OBJECT_free(st) SKM_sk_free(X509_OBJECT, (st))\n# define sk_X509_OBJECT_num(st) SKM_sk_num(X509_OBJECT, (st))\n# define sk_X509_OBJECT_value(st, i) SKM_sk_value(X509_OBJECT, (st), (i))\n# define sk_X509_OBJECT_set(st, i, val) SKM_sk_set(X509_OBJECT, (st), (i), (val))\n# define sk_X509_OBJECT_zero(st) SKM_sk_zero(X509_OBJECT, (st))\n# define sk_X509_OBJECT_push(st, val) SKM_sk_push(X509_OBJECT, (st), (val))\n# define sk_X509_OBJECT_unshift(st, val) SKM_sk_unshift(X509_OBJECT, (st), (val))\n# define sk_X509_OBJECT_find(st, val) SKM_sk_find(X509_OBJECT, (st), (val))\n# define sk_X509_OBJECT_find_ex(st, val) SKM_sk_find_ex(X509_OBJECT, (st), (val))\n# define sk_X509_OBJECT_delete(st, i) SKM_sk_delete(X509_OBJECT, (st), (i))\n# define sk_X509_OBJECT_delete_ptr(st, ptr) SKM_sk_delete_ptr(X509_OBJECT, (st), (ptr))\n# define sk_X509_OBJECT_insert(st, val, i) SKM_sk_insert(X509_OBJECT, (st), (val), (i))\n# define sk_X509_OBJECT_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(X509_OBJECT, (st), (cmp))\n# define sk_X509_OBJECT_dup(st) SKM_sk_dup(X509_OBJECT, st)\n# define sk_X509_OBJECT_pop_free(st, free_func) SKM_sk_pop_free(X509_OBJECT, (st), (free_func))\n# define sk_X509_OBJECT_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(X509_OBJECT, (st), (copy_func), (free_func))\n# define sk_X509_OBJECT_shift(st) SKM_sk_shift(X509_OBJECT, (st))\n# define sk_X509_OBJECT_pop(st) SKM_sk_pop(X509_OBJECT, (st))\n# define sk_X509_OBJECT_sort(st) SKM_sk_sort(X509_OBJECT, (st))\n# define sk_X509_OBJECT_is_sorted(st) SKM_sk_is_sorted(X509_OBJECT, (st))\n# define sk_X509_POLICY_DATA_new(cmp) SKM_sk_new(X509_POLICY_DATA, (cmp))\n# define sk_X509_POLICY_DATA_new_null() SKM_sk_new_null(X509_POLICY_DATA)\n# define sk_X509_POLICY_DATA_free(st) SKM_sk_free(X509_POLICY_DATA, (st))\n# define sk_X509_POLICY_DATA_num(st) SKM_sk_num(X509_POLICY_DATA, (st))\n# define sk_X509_POLICY_DATA_value(st, i) SKM_sk_value(X509_POLICY_DATA, (st), (i))\n# define sk_X509_POLICY_DATA_set(st, i, val) SKM_sk_set(X509_POLICY_DATA, (st), (i), (val))\n# define sk_X509_POLICY_DATA_zero(st) SKM_sk_zero(X509_POLICY_DATA, (st))\n# define sk_X509_POLICY_DATA_push(st, val) SKM_sk_push(X509_POLICY_DATA, (st), (val))\n# define sk_X509_POLICY_DATA_unshift(st, val) SKM_sk_unshift(X509_POLICY_DATA, (st), (val))\n# define sk_X509_POLICY_DATA_find(st, val) SKM_sk_find(X509_POLICY_DATA, (st), (val))\n# define sk_X509_POLICY_DATA_find_ex(st, val) SKM_sk_find_ex(X509_POLICY_DATA, (st), (val))\n# define sk_X509_POLICY_DATA_delete(st, i) SKM_sk_delete(X509_POLICY_DATA, (st), (i))\n# define sk_X509_POLICY_DATA_delete_ptr(st, ptr) SKM_sk_delete_ptr(X509_POLICY_DATA, (st), (ptr))\n# define sk_X509_POLICY_DATA_insert(st, val, i) SKM_sk_insert(X509_POLICY_DATA, (st), (val), (i))\n# define sk_X509_POLICY_DATA_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(X509_POLICY_DATA, (st), (cmp))\n# define sk_X509_POLICY_DATA_dup(st) SKM_sk_dup(X509_POLICY_DATA, st)\n# define sk_X509_POLICY_DATA_pop_free(st, free_func) SKM_sk_pop_free(X509_POLICY_DATA, (st), (free_func))\n# define sk_X509_POLICY_DATA_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(X509_POLICY_DATA, (st), (copy_func), (free_func))\n# define sk_X509_POLICY_DATA_shift(st) SKM_sk_shift(X509_POLICY_DATA, (st))\n# define sk_X509_POLICY_DATA_pop(st) SKM_sk_pop(X509_POLICY_DATA, (st))\n# define sk_X509_POLICY_DATA_sort(st) SKM_sk_sort(X509_POLICY_DATA, (st))\n# define sk_X509_POLICY_DATA_is_sorted(st) SKM_sk_is_sorted(X509_POLICY_DATA, (st))\n# define sk_X509_POLICY_NODE_new(cmp) SKM_sk_new(X509_POLICY_NODE, (cmp))\n# define sk_X509_POLICY_NODE_new_null() SKM_sk_new_null(X509_POLICY_NODE)\n# define sk_X509_POLICY_NODE_free(st) SKM_sk_free(X509_POLICY_NODE, (st))\n# define sk_X509_POLICY_NODE_num(st) SKM_sk_num(X509_POLICY_NODE, (st))\n# define sk_X509_POLICY_NODE_value(st, i) SKM_sk_value(X509_POLICY_NODE, (st), (i))\n# define sk_X509_POLICY_NODE_set(st, i, val) SKM_sk_set(X509_POLICY_NODE, (st), (i), (val))\n# define sk_X509_POLICY_NODE_zero(st) SKM_sk_zero(X509_POLICY_NODE, (st))\n# define sk_X509_POLICY_NODE_push(st, val) SKM_sk_push(X509_POLICY_NODE, (st), (val))\n# define sk_X509_POLICY_NODE_unshift(st, val) SKM_sk_unshift(X509_POLICY_NODE, (st), (val))\n# define sk_X509_POLICY_NODE_find(st, val) SKM_sk_find(X509_POLICY_NODE, (st), (val))\n# define sk_X509_POLICY_NODE_find_ex(st, val) SKM_sk_find_ex(X509_POLICY_NODE, (st), (val))\n# define sk_X509_POLICY_NODE_delete(st, i) SKM_sk_delete(X509_POLICY_NODE, (st), (i))\n# define sk_X509_POLICY_NODE_delete_ptr(st, ptr) SKM_sk_delete_ptr(X509_POLICY_NODE, (st), (ptr))\n# define sk_X509_POLICY_NODE_insert(st, val, i) SKM_sk_insert(X509_POLICY_NODE, (st), (val), (i))\n# define sk_X509_POLICY_NODE_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(X509_POLICY_NODE, (st), (cmp))\n# define sk_X509_POLICY_NODE_dup(st) SKM_sk_dup(X509_POLICY_NODE, st)\n# define sk_X509_POLICY_NODE_pop_free(st, free_func) SKM_sk_pop_free(X509_POLICY_NODE, (st), (free_func))\n# define sk_X509_POLICY_NODE_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(X509_POLICY_NODE, (st), (copy_func), (free_func))\n# define sk_X509_POLICY_NODE_shift(st) SKM_sk_shift(X509_POLICY_NODE, (st))\n# define sk_X509_POLICY_NODE_pop(st) SKM_sk_pop(X509_POLICY_NODE, (st))\n# define sk_X509_POLICY_NODE_sort(st) SKM_sk_sort(X509_POLICY_NODE, (st))\n# define sk_X509_POLICY_NODE_is_sorted(st) SKM_sk_is_sorted(X509_POLICY_NODE, (st))\n# define sk_X509_PURPOSE_new(cmp) SKM_sk_new(X509_PURPOSE, (cmp))\n# define sk_X509_PURPOSE_new_null() SKM_sk_new_null(X509_PURPOSE)\n# define sk_X509_PURPOSE_free(st) SKM_sk_free(X509_PURPOSE, (st))\n# define sk_X509_PURPOSE_num(st) SKM_sk_num(X509_PURPOSE, (st))\n# define sk_X509_PURPOSE_value(st, i) SKM_sk_value(X509_PURPOSE, (st), (i))\n# define sk_X509_PURPOSE_set(st, i, val) SKM_sk_set(X509_PURPOSE, (st), (i), (val))\n# define sk_X509_PURPOSE_zero(st) SKM_sk_zero(X509_PURPOSE, (st))\n# define sk_X509_PURPOSE_push(st, val) SKM_sk_push(X509_PURPOSE, (st), (val))\n# define sk_X509_PURPOSE_unshift(st, val) SKM_sk_unshift(X509_PURPOSE, (st), (val))\n# define sk_X509_PURPOSE_find(st, val) SKM_sk_find(X509_PURPOSE, (st), (val))\n# define sk_X509_PURPOSE_find_ex(st, val) SKM_sk_find_ex(X509_PURPOSE, (st), (val))\n# define sk_X509_PURPOSE_delete(st, i) SKM_sk_delete(X509_PURPOSE, (st), (i))\n# define sk_X509_PURPOSE_delete_ptr(st, ptr) SKM_sk_delete_ptr(X509_PURPOSE, (st), (ptr))\n# define sk_X509_PURPOSE_insert(st, val, i) SKM_sk_insert(X509_PURPOSE, (st), (val), (i))\n# define sk_X509_PURPOSE_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(X509_PURPOSE, (st), (cmp))\n# define sk_X509_PURPOSE_dup(st) SKM_sk_dup(X509_PURPOSE, st)\n# define sk_X509_PURPOSE_pop_free(st, free_func) SKM_sk_pop_free(X509_PURPOSE, (st), (free_func))\n# define sk_X509_PURPOSE_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(X509_PURPOSE, (st), (copy_func), (free_func))\n# define sk_X509_PURPOSE_shift(st) SKM_sk_shift(X509_PURPOSE, (st))\n# define sk_X509_PURPOSE_pop(st) SKM_sk_pop(X509_PURPOSE, (st))\n# define sk_X509_PURPOSE_sort(st) SKM_sk_sort(X509_PURPOSE, (st))\n# define sk_X509_PURPOSE_is_sorted(st) SKM_sk_is_sorted(X509_PURPOSE, (st))\n# define sk_X509_REVOKED_new(cmp) SKM_sk_new(X509_REVOKED, (cmp))\n# define sk_X509_REVOKED_new_null() SKM_sk_new_null(X509_REVOKED)\n# define sk_X509_REVOKED_free(st) SKM_sk_free(X509_REVOKED, (st))\n# define sk_X509_REVOKED_num(st) SKM_sk_num(X509_REVOKED, (st))\n# define sk_X509_REVOKED_value(st, i) SKM_sk_value(X509_REVOKED, (st), (i))\n# define sk_X509_REVOKED_set(st, i, val) SKM_sk_set(X509_REVOKED, (st), (i), (val))\n# define sk_X509_REVOKED_zero(st) SKM_sk_zero(X509_REVOKED, (st))\n# define sk_X509_REVOKED_push(st, val) SKM_sk_push(X509_REVOKED, (st), (val))\n# define sk_X509_REVOKED_unshift(st, val) SKM_sk_unshift(X509_REVOKED, (st), (val))\n# define sk_X509_REVOKED_find(st, val) SKM_sk_find(X509_REVOKED, (st), (val))\n# define sk_X509_REVOKED_find_ex(st, val) SKM_sk_find_ex(X509_REVOKED, (st), (val))\n# define sk_X509_REVOKED_delete(st, i) SKM_sk_delete(X509_REVOKED, (st), (i))\n# define sk_X509_REVOKED_delete_ptr(st, ptr) SKM_sk_delete_ptr(X509_REVOKED, (st), (ptr))\n# define sk_X509_REVOKED_insert(st, val, i) SKM_sk_insert(X509_REVOKED, (st), (val), (i))\n# define sk_X509_REVOKED_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(X509_REVOKED, (st), (cmp))\n# define sk_X509_REVOKED_dup(st) SKM_sk_dup(X509_REVOKED, st)\n# define sk_X509_REVOKED_pop_free(st, free_func) SKM_sk_pop_free(X509_REVOKED, (st), (free_func))\n# define sk_X509_REVOKED_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(X509_REVOKED, (st), (copy_func), (free_func))\n# define sk_X509_REVOKED_shift(st) SKM_sk_shift(X509_REVOKED, (st))\n# define sk_X509_REVOKED_pop(st) SKM_sk_pop(X509_REVOKED, (st))\n# define sk_X509_REVOKED_sort(st) SKM_sk_sort(X509_REVOKED, (st))\n# define sk_X509_REVOKED_is_sorted(st) SKM_sk_is_sorted(X509_REVOKED, (st))\n# define sk_X509_TRUST_new(cmp) SKM_sk_new(X509_TRUST, (cmp))\n# define sk_X509_TRUST_new_null() SKM_sk_new_null(X509_TRUST)\n# define sk_X509_TRUST_free(st) SKM_sk_free(X509_TRUST, (st))\n# define sk_X509_TRUST_num(st) SKM_sk_num(X509_TRUST, (st))\n# define sk_X509_TRUST_value(st, i) SKM_sk_value(X509_TRUST, (st), (i))\n# define sk_X509_TRUST_set(st, i, val) SKM_sk_set(X509_TRUST, (st), (i), (val))\n# define sk_X509_TRUST_zero(st) SKM_sk_zero(X509_TRUST, (st))\n# define sk_X509_TRUST_push(st, val) SKM_sk_push(X509_TRUST, (st), (val))\n# define sk_X509_TRUST_unshift(st, val) SKM_sk_unshift(X509_TRUST, (st), (val))\n# define sk_X509_TRUST_find(st, val) SKM_sk_find(X509_TRUST, (st), (val))\n# define sk_X509_TRUST_find_ex(st, val) SKM_sk_find_ex(X509_TRUST, (st), (val))\n# define sk_X509_TRUST_delete(st, i) SKM_sk_delete(X509_TRUST, (st), (i))\n# define sk_X509_TRUST_delete_ptr(st, ptr) SKM_sk_delete_ptr(X509_TRUST, (st), (ptr))\n# define sk_X509_TRUST_insert(st, val, i) SKM_sk_insert(X509_TRUST, (st), (val), (i))\n# define sk_X509_TRUST_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(X509_TRUST, (st), (cmp))\n# define sk_X509_TRUST_dup(st) SKM_sk_dup(X509_TRUST, st)\n# define sk_X509_TRUST_pop_free(st, free_func) SKM_sk_pop_free(X509_TRUST, (st), (free_func))\n# define sk_X509_TRUST_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(X509_TRUST, (st), (copy_func), (free_func))\n# define sk_X509_TRUST_shift(st) SKM_sk_shift(X509_TRUST, (st))\n# define sk_X509_TRUST_pop(st) SKM_sk_pop(X509_TRUST, (st))\n# define sk_X509_TRUST_sort(st) SKM_sk_sort(X509_TRUST, (st))\n# define sk_X509_TRUST_is_sorted(st) SKM_sk_is_sorted(X509_TRUST, (st))\n# define sk_X509_VERIFY_PARAM_new(cmp) SKM_sk_new(X509_VERIFY_PARAM, (cmp))\n# define sk_X509_VERIFY_PARAM_new_null() SKM_sk_new_null(X509_VERIFY_PARAM)\n# define sk_X509_VERIFY_PARAM_free(st) SKM_sk_free(X509_VERIFY_PARAM, (st))\n# define sk_X509_VERIFY_PARAM_num(st) SKM_sk_num(X509_VERIFY_PARAM, (st))\n# define sk_X509_VERIFY_PARAM_value(st, i) SKM_sk_value(X509_VERIFY_PARAM, (st), (i))\n# define sk_X509_VERIFY_PARAM_set(st, i, val) SKM_sk_set(X509_VERIFY_PARAM, (st), (i), (val))\n# define sk_X509_VERIFY_PARAM_zero(st) SKM_sk_zero(X509_VERIFY_PARAM, (st))\n# define sk_X509_VERIFY_PARAM_push(st, val) SKM_sk_push(X509_VERIFY_PARAM, (st), (val))\n# define sk_X509_VERIFY_PARAM_unshift(st, val) SKM_sk_unshift(X509_VERIFY_PARAM, (st), (val))\n# define sk_X509_VERIFY_PARAM_find(st, val) SKM_sk_find(X509_VERIFY_PARAM, (st), (val))\n# define sk_X509_VERIFY_PARAM_find_ex(st, val) SKM_sk_find_ex(X509_VERIFY_PARAM, (st), (val))\n# define sk_X509_VERIFY_PARAM_delete(st, i) SKM_sk_delete(X509_VERIFY_PARAM, (st), (i))\n# define sk_X509_VERIFY_PARAM_delete_ptr(st, ptr) SKM_sk_delete_ptr(X509_VERIFY_PARAM, (st), (ptr))\n# define sk_X509_VERIFY_PARAM_insert(st, val, i) SKM_sk_insert(X509_VERIFY_PARAM, (st), (val), (i))\n# define sk_X509_VERIFY_PARAM_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(X509_VERIFY_PARAM, (st), (cmp))\n# define sk_X509_VERIFY_PARAM_dup(st) SKM_sk_dup(X509_VERIFY_PARAM, st)\n# define sk_X509_VERIFY_PARAM_pop_free(st, free_func) SKM_sk_pop_free(X509_VERIFY_PARAM, (st), (free_func))\n# define sk_X509_VERIFY_PARAM_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(X509_VERIFY_PARAM, (st), (copy_func), (free_func))\n# define sk_X509_VERIFY_PARAM_shift(st) SKM_sk_shift(X509_VERIFY_PARAM, (st))\n# define sk_X509_VERIFY_PARAM_pop(st) SKM_sk_pop(X509_VERIFY_PARAM, (st))\n# define sk_X509_VERIFY_PARAM_sort(st) SKM_sk_sort(X509_VERIFY_PARAM, (st))\n# define sk_X509_VERIFY_PARAM_is_sorted(st) SKM_sk_is_sorted(X509_VERIFY_PARAM, (st))\n# define sk_nid_triple_new(cmp) SKM_sk_new(nid_triple, (cmp))\n# define sk_nid_triple_new_null() SKM_sk_new_null(nid_triple)\n# define sk_nid_triple_free(st) SKM_sk_free(nid_triple, (st))\n# define sk_nid_triple_num(st) SKM_sk_num(nid_triple, (st))\n# define sk_nid_triple_value(st, i) SKM_sk_value(nid_triple, (st), (i))\n# define sk_nid_triple_set(st, i, val) SKM_sk_set(nid_triple, (st), (i), (val))\n# define sk_nid_triple_zero(st) SKM_sk_zero(nid_triple, (st))\n# define sk_nid_triple_push(st, val) SKM_sk_push(nid_triple, (st), (val))\n# define sk_nid_triple_unshift(st, val) SKM_sk_unshift(nid_triple, (st), (val))\n# define sk_nid_triple_find(st, val) SKM_sk_find(nid_triple, (st), (val))\n# define sk_nid_triple_find_ex(st, val) SKM_sk_find_ex(nid_triple, (st), (val))\n# define sk_nid_triple_delete(st, i) SKM_sk_delete(nid_triple, (st), (i))\n# define sk_nid_triple_delete_ptr(st, ptr) SKM_sk_delete_ptr(nid_triple, (st), (ptr))\n# define sk_nid_triple_insert(st, val, i) SKM_sk_insert(nid_triple, (st), (val), (i))\n# define sk_nid_triple_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(nid_triple, (st), (cmp))\n# define sk_nid_triple_dup(st) SKM_sk_dup(nid_triple, st)\n# define sk_nid_triple_pop_free(st, free_func) SKM_sk_pop_free(nid_triple, (st), (free_func))\n# define sk_nid_triple_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(nid_triple, (st), (copy_func), (free_func))\n# define sk_nid_triple_shift(st) SKM_sk_shift(nid_triple, (st))\n# define sk_nid_triple_pop(st) SKM_sk_pop(nid_triple, (st))\n# define sk_nid_triple_sort(st) SKM_sk_sort(nid_triple, (st))\n# define sk_nid_triple_is_sorted(st) SKM_sk_is_sorted(nid_triple, (st))\n# define sk_void_new(cmp) SKM_sk_new(void, (cmp))\n# define sk_void_new_null() SKM_sk_new_null(void)\n# define sk_void_free(st) SKM_sk_free(void, (st))\n# define sk_void_num(st) SKM_sk_num(void, (st))\n# define sk_void_value(st, i) SKM_sk_value(void, (st), (i))\n# define sk_void_set(st, i, val) SKM_sk_set(void, (st), (i), (val))\n# define sk_void_zero(st) SKM_sk_zero(void, (st))\n# define sk_void_push(st, val) SKM_sk_push(void, (st), (val))\n# define sk_void_unshift(st, val) SKM_sk_unshift(void, (st), (val))\n# define sk_void_find(st, val) SKM_sk_find(void, (st), (val))\n# define sk_void_find_ex(st, val) SKM_sk_find_ex(void, (st), (val))\n# define sk_void_delete(st, i) SKM_sk_delete(void, (st), (i))\n# define sk_void_delete_ptr(st, ptr) SKM_sk_delete_ptr(void, (st), (ptr))\n# define sk_void_insert(st, val, i) SKM_sk_insert(void, (st), (val), (i))\n# define sk_void_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(void, (st), (cmp))\n# define sk_void_dup(st) SKM_sk_dup(void, st)\n# define sk_void_pop_free(st, free_func) SKM_sk_pop_free(void, (st), (free_func))\n# define sk_void_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(void, (st), (copy_func), (free_func))\n# define sk_void_shift(st) SKM_sk_shift(void, (st))\n# define sk_void_pop(st) SKM_sk_pop(void, (st))\n# define sk_void_sort(st) SKM_sk_sort(void, (st))\n# define sk_void_is_sorted(st) SKM_sk_is_sorted(void, (st))\n# define sk_OPENSSL_STRING_new(cmp) ((STACK_OF(OPENSSL_STRING) *)sk_new(CHECKED_SK_CMP_FUNC(char, cmp)))\n# define sk_OPENSSL_STRING_new_null() ((STACK_OF(OPENSSL_STRING) *)sk_new_null())\n# define sk_OPENSSL_STRING_push(st, val) sk_push(CHECKED_STACK_OF(OPENSSL_STRING, st), CHECKED_PTR_OF(char, val))\n# define sk_OPENSSL_STRING_find(st, val) sk_find(CHECKED_STACK_OF(OPENSSL_STRING, st), CHECKED_PTR_OF(char, val))\n# define sk_OPENSSL_STRING_value(st, i) ((OPENSSL_STRING)sk_value(CHECKED_STACK_OF(OPENSSL_STRING, st), i))\n# define sk_OPENSSL_STRING_num(st) SKM_sk_num(OPENSSL_STRING, st)\n# define sk_OPENSSL_STRING_pop_free(st, free_func) sk_pop_free(CHECKED_STACK_OF(OPENSSL_STRING, st), CHECKED_SK_FREE_FUNC(char, free_func))\n# define sk_OPENSSL_STRING_deep_copy(st, copy_func, free_func) ((STACK_OF(OPENSSL_STRING) *)sk_deep_copy(CHECKED_STACK_OF(OPENSSL_STRING, st), CHECKED_SK_COPY_FUNC(char, copy_func), CHECKED_SK_FREE_FUNC(char, free_func)))\n# define sk_OPENSSL_STRING_insert(st, val, i) sk_insert(CHECKED_STACK_OF(OPENSSL_STRING, st), CHECKED_PTR_OF(char, val), i)\n# define sk_OPENSSL_STRING_free(st) SKM_sk_free(OPENSSL_STRING, st)\n# define sk_OPENSSL_STRING_set(st, i, val) sk_set(CHECKED_STACK_OF(OPENSSL_STRING, st), i, CHECKED_PTR_OF(char, val))\n# define sk_OPENSSL_STRING_zero(st) SKM_sk_zero(OPENSSL_STRING, (st))\n# define sk_OPENSSL_STRING_unshift(st, val) sk_unshift(CHECKED_STACK_OF(OPENSSL_STRING, st), CHECKED_PTR_OF(char, val))\n# define sk_OPENSSL_STRING_find_ex(st, val) sk_find_ex((_STACK *)CHECKED_CONST_PTR_OF(STACK_OF(OPENSSL_STRING), st), CHECKED_CONST_PTR_OF(char, val))\n# define sk_OPENSSL_STRING_delete(st, i) SKM_sk_delete(OPENSSL_STRING, (st), (i))\n# define sk_OPENSSL_STRING_delete_ptr(st, ptr) (OPENSSL_STRING *)sk_delete_ptr(CHECKED_STACK_OF(OPENSSL_STRING, st), CHECKED_PTR_OF(char, ptr))\n# define sk_OPENSSL_STRING_set_cmp_func(st, cmp)  \\\n        ((int (*)(const char * const *,const char * const *)) \\\n        sk_set_cmp_func(CHECKED_STACK_OF(OPENSSL_STRING, st), CHECKED_SK_CMP_FUNC(char, cmp)))\n# define sk_OPENSSL_STRING_dup(st) SKM_sk_dup(OPENSSL_STRING, st)\n# define sk_OPENSSL_STRING_shift(st) SKM_sk_shift(OPENSSL_STRING, (st))\n# define sk_OPENSSL_STRING_pop(st) (char *)sk_pop(CHECKED_STACK_OF(OPENSSL_STRING, st))\n# define sk_OPENSSL_STRING_sort(st) SKM_sk_sort(OPENSSL_STRING, (st))\n# define sk_OPENSSL_STRING_is_sorted(st) SKM_sk_is_sorted(OPENSSL_STRING, (st))\n# define sk_OPENSSL_BLOCK_new(cmp) ((STACK_OF(OPENSSL_BLOCK) *)sk_new(CHECKED_SK_CMP_FUNC(void, cmp)))\n# define sk_OPENSSL_BLOCK_new_null() ((STACK_OF(OPENSSL_BLOCK) *)sk_new_null())\n# define sk_OPENSSL_BLOCK_push(st, val) sk_push(CHECKED_STACK_OF(OPENSSL_BLOCK, st), CHECKED_PTR_OF(void, val))\n# define sk_OPENSSL_BLOCK_find(st, val) sk_find(CHECKED_STACK_OF(OPENSSL_BLOCK, st), CHECKED_PTR_OF(void, val))\n# define sk_OPENSSL_BLOCK_value(st, i) ((OPENSSL_BLOCK)sk_value(CHECKED_STACK_OF(OPENSSL_BLOCK, st), i))\n# define sk_OPENSSL_BLOCK_num(st) SKM_sk_num(OPENSSL_BLOCK, st)\n# define sk_OPENSSL_BLOCK_pop_free(st, free_func) sk_pop_free(CHECKED_STACK_OF(OPENSSL_BLOCK, st), CHECKED_SK_FREE_FUNC(void, free_func))\n# define sk_OPENSSL_BLOCK_deep_copy(st, copy_func, free_func) ((STACK_OF(OPENSSL_BLOCK) *)sk_deep_copy(CHECKED_STACK_OF(OPENSSL_BLOCK, st), CHECKED_SK_COPY_FUNC(void, copy_func), CHECKED_SK_FREE_FUNC(void, free_func)))\n# define sk_OPENSSL_BLOCK_insert(st, val, i) sk_insert(CHECKED_STACK_OF(OPENSSL_BLOCK, st), CHECKED_PTR_OF(void, val), i)\n# define sk_OPENSSL_BLOCK_free(st) SKM_sk_free(OPENSSL_BLOCK, st)\n# define sk_OPENSSL_BLOCK_set(st, i, val) sk_set(CHECKED_STACK_OF(OPENSSL_BLOCK, st), i, CHECKED_PTR_OF(void, val))\n# define sk_OPENSSL_BLOCK_zero(st) SKM_sk_zero(OPENSSL_BLOCK, (st))\n# define sk_OPENSSL_BLOCK_unshift(st, val) sk_unshift(CHECKED_STACK_OF(OPENSSL_BLOCK, st), CHECKED_PTR_OF(void, val))\n# define sk_OPENSSL_BLOCK_find_ex(st, val) sk_find_ex((_STACK *)CHECKED_CONST_PTR_OF(STACK_OF(OPENSSL_BLOCK), st), CHECKED_CONST_PTR_OF(void, val))\n# define sk_OPENSSL_BLOCK_delete(st, i) SKM_sk_delete(OPENSSL_BLOCK, (st), (i))\n# define sk_OPENSSL_BLOCK_delete_ptr(st, ptr) (OPENSSL_BLOCK *)sk_delete_ptr(CHECKED_STACK_OF(OPENSSL_BLOCK, st), CHECKED_PTR_OF(void, ptr))\n# define sk_OPENSSL_BLOCK_set_cmp_func(st, cmp)  \\\n        ((int (*)(const void * const *,const void * const *)) \\\n        sk_set_cmp_func(CHECKED_STACK_OF(OPENSSL_BLOCK, st), CHECKED_SK_CMP_FUNC(void, cmp)))\n# define sk_OPENSSL_BLOCK_dup(st) SKM_sk_dup(OPENSSL_BLOCK, st)\n# define sk_OPENSSL_BLOCK_shift(st) SKM_sk_shift(OPENSSL_BLOCK, (st))\n# define sk_OPENSSL_BLOCK_pop(st) (void *)sk_pop(CHECKED_STACK_OF(OPENSSL_BLOCK, st))\n# define sk_OPENSSL_BLOCK_sort(st) SKM_sk_sort(OPENSSL_BLOCK, (st))\n# define sk_OPENSSL_BLOCK_is_sorted(st) SKM_sk_is_sorted(OPENSSL_BLOCK, (st))\n# define sk_OPENSSL_PSTRING_new(cmp) ((STACK_OF(OPENSSL_PSTRING) *)sk_new(CHECKED_SK_CMP_FUNC(OPENSSL_STRING, cmp)))\n# define sk_OPENSSL_PSTRING_new_null() ((STACK_OF(OPENSSL_PSTRING) *)sk_new_null())\n# define sk_OPENSSL_PSTRING_push(st, val) sk_push(CHECKED_STACK_OF(OPENSSL_PSTRING, st), CHECKED_PTR_OF(OPENSSL_STRING, val))\n# define sk_OPENSSL_PSTRING_find(st, val) sk_find(CHECKED_STACK_OF(OPENSSL_PSTRING, st), CHECKED_PTR_OF(OPENSSL_STRING, val))\n# define sk_OPENSSL_PSTRING_value(st, i) ((OPENSSL_PSTRING)sk_value(CHECKED_STACK_OF(OPENSSL_PSTRING, st), i))\n# define sk_OPENSSL_PSTRING_num(st) SKM_sk_num(OPENSSL_PSTRING, st)\n# define sk_OPENSSL_PSTRING_pop_free(st, free_func) sk_pop_free(CHECKED_STACK_OF(OPENSSL_PSTRING, st), CHECKED_SK_FREE_FUNC(OPENSSL_STRING, free_func))\n# define sk_OPENSSL_PSTRING_deep_copy(st, copy_func, free_func) ((STACK_OF(OPENSSL_PSTRING) *)sk_deep_copy(CHECKED_STACK_OF(OPENSSL_PSTRING, st), CHECKED_SK_COPY_FUNC(OPENSSL_STRING, copy_func), CHECKED_SK_FREE_FUNC(OPENSSL_STRING, free_func)))\n# define sk_OPENSSL_PSTRING_insert(st, val, i) sk_insert(CHECKED_STACK_OF(OPENSSL_PSTRING, st), CHECKED_PTR_OF(OPENSSL_STRING, val), i)\n# define sk_OPENSSL_PSTRING_free(st) SKM_sk_free(OPENSSL_PSTRING, st)\n# define sk_OPENSSL_PSTRING_set(st, i, val) sk_set(CHECKED_STACK_OF(OPENSSL_PSTRING, st), i, CHECKED_PTR_OF(OPENSSL_STRING, val))\n# define sk_OPENSSL_PSTRING_zero(st) SKM_sk_zero(OPENSSL_PSTRING, (st))\n# define sk_OPENSSL_PSTRING_unshift(st, val) sk_unshift(CHECKED_STACK_OF(OPENSSL_PSTRING, st), CHECKED_PTR_OF(OPENSSL_STRING, val))\n# define sk_OPENSSL_PSTRING_find_ex(st, val) sk_find_ex((_STACK *)CHECKED_CONST_PTR_OF(STACK_OF(OPENSSL_PSTRING), st), CHECKED_CONST_PTR_OF(OPENSSL_STRING, val))\n# define sk_OPENSSL_PSTRING_delete(st, i) SKM_sk_delete(OPENSSL_PSTRING, (st), (i))\n# define sk_OPENSSL_PSTRING_delete_ptr(st, ptr) (OPENSSL_PSTRING *)sk_delete_ptr(CHECKED_STACK_OF(OPENSSL_PSTRING, st), CHECKED_PTR_OF(OPENSSL_STRING, ptr))\n# define sk_OPENSSL_PSTRING_set_cmp_func(st, cmp)  \\\n        ((int (*)(const OPENSSL_STRING * const *,const OPENSSL_STRING * const *)) \\\n        sk_set_cmp_func(CHECKED_STACK_OF(OPENSSL_PSTRING, st), CHECKED_SK_CMP_FUNC(OPENSSL_STRING, cmp)))\n# define sk_OPENSSL_PSTRING_dup(st) SKM_sk_dup(OPENSSL_PSTRING, st)\n# define sk_OPENSSL_PSTRING_shift(st) SKM_sk_shift(OPENSSL_PSTRING, (st))\n# define sk_OPENSSL_PSTRING_pop(st) (OPENSSL_STRING *)sk_pop(CHECKED_STACK_OF(OPENSSL_PSTRING, st))\n# define sk_OPENSSL_PSTRING_sort(st) SKM_sk_sort(OPENSSL_PSTRING, (st))\n# define sk_OPENSSL_PSTRING_is_sorted(st) SKM_sk_is_sorted(OPENSSL_PSTRING, (st))\n# define d2i_ASN1_SET_OF_ACCESS_DESCRIPTION(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \\\n        SKM_ASN1_SET_OF_d2i(ACCESS_DESCRIPTION, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class))\n# define i2d_ASN1_SET_OF_ACCESS_DESCRIPTION(st, pp, i2d_func, ex_tag, ex_class, is_set) \\\n        SKM_ASN1_SET_OF_i2d(ACCESS_DESCRIPTION, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set))\n# define ASN1_seq_pack_ACCESS_DESCRIPTION(st, i2d_func, buf, len) \\\n        SKM_ASN1_seq_pack(ACCESS_DESCRIPTION, (st), (i2d_func), (buf), (len))\n# define ASN1_seq_unpack_ACCESS_DESCRIPTION(buf, len, d2i_func, free_func) \\\n        SKM_ASN1_seq_unpack(ACCESS_DESCRIPTION, (buf), (len), (d2i_func), (free_func))\n# define d2i_ASN1_SET_OF_ASN1_INTEGER(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \\\n        SKM_ASN1_SET_OF_d2i(ASN1_INTEGER, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class))\n# define i2d_ASN1_SET_OF_ASN1_INTEGER(st, pp, i2d_func, ex_tag, ex_class, is_set) \\\n        SKM_ASN1_SET_OF_i2d(ASN1_INTEGER, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set))\n# define ASN1_seq_pack_ASN1_INTEGER(st, i2d_func, buf, len) \\\n        SKM_ASN1_seq_pack(ASN1_INTEGER, (st), (i2d_func), (buf), (len))\n# define ASN1_seq_unpack_ASN1_INTEGER(buf, len, d2i_func, free_func) \\\n        SKM_ASN1_seq_unpack(ASN1_INTEGER, (buf), (len), (d2i_func), (free_func))\n# define d2i_ASN1_SET_OF_ASN1_OBJECT(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \\\n        SKM_ASN1_SET_OF_d2i(ASN1_OBJECT, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class))\n# define i2d_ASN1_SET_OF_ASN1_OBJECT(st, pp, i2d_func, ex_tag, ex_class, is_set) \\\n        SKM_ASN1_SET_OF_i2d(ASN1_OBJECT, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set))\n# define ASN1_seq_pack_ASN1_OBJECT(st, i2d_func, buf, len) \\\n        SKM_ASN1_seq_pack(ASN1_OBJECT, (st), (i2d_func), (buf), (len))\n# define ASN1_seq_unpack_ASN1_OBJECT(buf, len, d2i_func, free_func) \\\n        SKM_ASN1_seq_unpack(ASN1_OBJECT, (buf), (len), (d2i_func), (free_func))\n# define d2i_ASN1_SET_OF_ASN1_TYPE(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \\\n        SKM_ASN1_SET_OF_d2i(ASN1_TYPE, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class))\n# define i2d_ASN1_SET_OF_ASN1_TYPE(st, pp, i2d_func, ex_tag, ex_class, is_set) \\\n        SKM_ASN1_SET_OF_i2d(ASN1_TYPE, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set))\n# define ASN1_seq_pack_ASN1_TYPE(st, i2d_func, buf, len) \\\n        SKM_ASN1_seq_pack(ASN1_TYPE, (st), (i2d_func), (buf), (len))\n# define ASN1_seq_unpack_ASN1_TYPE(buf, len, d2i_func, free_func) \\\n        SKM_ASN1_seq_unpack(ASN1_TYPE, (buf), (len), (d2i_func), (free_func))\n# define d2i_ASN1_SET_OF_ASN1_UTF8STRING(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \\\n        SKM_ASN1_SET_OF_d2i(ASN1_UTF8STRING, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class))\n# define i2d_ASN1_SET_OF_ASN1_UTF8STRING(st, pp, i2d_func, ex_tag, ex_class, is_set) \\\n        SKM_ASN1_SET_OF_i2d(ASN1_UTF8STRING, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set))\n# define ASN1_seq_pack_ASN1_UTF8STRING(st, i2d_func, buf, len) \\\n        SKM_ASN1_seq_pack(ASN1_UTF8STRING, (st), (i2d_func), (buf), (len))\n# define ASN1_seq_unpack_ASN1_UTF8STRING(buf, len, d2i_func, free_func) \\\n        SKM_ASN1_seq_unpack(ASN1_UTF8STRING, (buf), (len), (d2i_func), (free_func))\n# define d2i_ASN1_SET_OF_DIST_POINT(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \\\n        SKM_ASN1_SET_OF_d2i(DIST_POINT, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class))\n# define i2d_ASN1_SET_OF_DIST_POINT(st, pp, i2d_func, ex_tag, ex_class, is_set) \\\n        SKM_ASN1_SET_OF_i2d(DIST_POINT, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set))\n# define ASN1_seq_pack_DIST_POINT(st, i2d_func, buf, len) \\\n        SKM_ASN1_seq_pack(DIST_POINT, (st), (i2d_func), (buf), (len))\n# define ASN1_seq_unpack_DIST_POINT(buf, len, d2i_func, free_func) \\\n        SKM_ASN1_seq_unpack(DIST_POINT, (buf), (len), (d2i_func), (free_func))\n# define d2i_ASN1_SET_OF_ESS_CERT_ID(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \\\n        SKM_ASN1_SET_OF_d2i(ESS_CERT_ID, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class))\n# define i2d_ASN1_SET_OF_ESS_CERT_ID(st, pp, i2d_func, ex_tag, ex_class, is_set) \\\n        SKM_ASN1_SET_OF_i2d(ESS_CERT_ID, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set))\n# define ASN1_seq_pack_ESS_CERT_ID(st, i2d_func, buf, len) \\\n        SKM_ASN1_seq_pack(ESS_CERT_ID, (st), (i2d_func), (buf), (len))\n# define ASN1_seq_unpack_ESS_CERT_ID(buf, len, d2i_func, free_func) \\\n        SKM_ASN1_seq_unpack(ESS_CERT_ID, (buf), (len), (d2i_func), (free_func))\n# define d2i_ASN1_SET_OF_EVP_MD(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \\\n        SKM_ASN1_SET_OF_d2i(EVP_MD, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class))\n# define i2d_ASN1_SET_OF_EVP_MD(st, pp, i2d_func, ex_tag, ex_class, is_set) \\\n        SKM_ASN1_SET_OF_i2d(EVP_MD, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set))\n# define ASN1_seq_pack_EVP_MD(st, i2d_func, buf, len) \\\n        SKM_ASN1_seq_pack(EVP_MD, (st), (i2d_func), (buf), (len))\n# define ASN1_seq_unpack_EVP_MD(buf, len, d2i_func, free_func) \\\n        SKM_ASN1_seq_unpack(EVP_MD, (buf), (len), (d2i_func), (free_func))\n# define d2i_ASN1_SET_OF_GENERAL_NAME(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \\\n        SKM_ASN1_SET_OF_d2i(GENERAL_NAME, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class))\n# define i2d_ASN1_SET_OF_GENERAL_NAME(st, pp, i2d_func, ex_tag, ex_class, is_set) \\\n        SKM_ASN1_SET_OF_i2d(GENERAL_NAME, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set))\n# define ASN1_seq_pack_GENERAL_NAME(st, i2d_func, buf, len) \\\n        SKM_ASN1_seq_pack(GENERAL_NAME, (st), (i2d_func), (buf), (len))\n# define ASN1_seq_unpack_GENERAL_NAME(buf, len, d2i_func, free_func) \\\n        SKM_ASN1_seq_unpack(GENERAL_NAME, (buf), (len), (d2i_func), (free_func))\n# define d2i_ASN1_SET_OF_OCSP_ONEREQ(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \\\n        SKM_ASN1_SET_OF_d2i(OCSP_ONEREQ, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class))\n# define i2d_ASN1_SET_OF_OCSP_ONEREQ(st, pp, i2d_func, ex_tag, ex_class, is_set) \\\n        SKM_ASN1_SET_OF_i2d(OCSP_ONEREQ, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set))\n# define ASN1_seq_pack_OCSP_ONEREQ(st, i2d_func, buf, len) \\\n        SKM_ASN1_seq_pack(OCSP_ONEREQ, (st), (i2d_func), (buf), (len))\n# define ASN1_seq_unpack_OCSP_ONEREQ(buf, len, d2i_func, free_func) \\\n        SKM_ASN1_seq_unpack(OCSP_ONEREQ, (buf), (len), (d2i_func), (free_func))\n# define d2i_ASN1_SET_OF_OCSP_SINGLERESP(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \\\n        SKM_ASN1_SET_OF_d2i(OCSP_SINGLERESP, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class))\n# define i2d_ASN1_SET_OF_OCSP_SINGLERESP(st, pp, i2d_func, ex_tag, ex_class, is_set) \\\n        SKM_ASN1_SET_OF_i2d(OCSP_SINGLERESP, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set))\n# define ASN1_seq_pack_OCSP_SINGLERESP(st, i2d_func, buf, len) \\\n        SKM_ASN1_seq_pack(OCSP_SINGLERESP, (st), (i2d_func), (buf), (len))\n# define ASN1_seq_unpack_OCSP_SINGLERESP(buf, len, d2i_func, free_func) \\\n        SKM_ASN1_seq_unpack(OCSP_SINGLERESP, (buf), (len), (d2i_func), (free_func))\n# define d2i_ASN1_SET_OF_PKCS12_SAFEBAG(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \\\n        SKM_ASN1_SET_OF_d2i(PKCS12_SAFEBAG, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class))\n# define i2d_ASN1_SET_OF_PKCS12_SAFEBAG(st, pp, i2d_func, ex_tag, ex_class, is_set) \\\n        SKM_ASN1_SET_OF_i2d(PKCS12_SAFEBAG, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set))\n# define ASN1_seq_pack_PKCS12_SAFEBAG(st, i2d_func, buf, len) \\\n        SKM_ASN1_seq_pack(PKCS12_SAFEBAG, (st), (i2d_func), (buf), (len))\n# define ASN1_seq_unpack_PKCS12_SAFEBAG(buf, len, d2i_func, free_func) \\\n        SKM_ASN1_seq_unpack(PKCS12_SAFEBAG, (buf), (len), (d2i_func), (free_func))\n# define d2i_ASN1_SET_OF_PKCS7(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \\\n        SKM_ASN1_SET_OF_d2i(PKCS7, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class))\n# define i2d_ASN1_SET_OF_PKCS7(st, pp, i2d_func, ex_tag, ex_class, is_set) \\\n        SKM_ASN1_SET_OF_i2d(PKCS7, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set))\n# define ASN1_seq_pack_PKCS7(st, i2d_func, buf, len) \\\n        SKM_ASN1_seq_pack(PKCS7, (st), (i2d_func), (buf), (len))\n# define ASN1_seq_unpack_PKCS7(buf, len, d2i_func, free_func) \\\n        SKM_ASN1_seq_unpack(PKCS7, (buf), (len), (d2i_func), (free_func))\n# define d2i_ASN1_SET_OF_PKCS7_RECIP_INFO(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \\\n        SKM_ASN1_SET_OF_d2i(PKCS7_RECIP_INFO, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class))\n# define i2d_ASN1_SET_OF_PKCS7_RECIP_INFO(st, pp, i2d_func, ex_tag, ex_class, is_set) \\\n        SKM_ASN1_SET_OF_i2d(PKCS7_RECIP_INFO, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set))\n# define ASN1_seq_pack_PKCS7_RECIP_INFO(st, i2d_func, buf, len) \\\n        SKM_ASN1_seq_pack(PKCS7_RECIP_INFO, (st), (i2d_func), (buf), (len))\n# define ASN1_seq_unpack_PKCS7_RECIP_INFO(buf, len, d2i_func, free_func) \\\n        SKM_ASN1_seq_unpack(PKCS7_RECIP_INFO, (buf), (len), (d2i_func), (free_func))\n# define d2i_ASN1_SET_OF_PKCS7_SIGNER_INFO(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \\\n        SKM_ASN1_SET_OF_d2i(PKCS7_SIGNER_INFO, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class))\n# define i2d_ASN1_SET_OF_PKCS7_SIGNER_INFO(st, pp, i2d_func, ex_tag, ex_class, is_set) \\\n        SKM_ASN1_SET_OF_i2d(PKCS7_SIGNER_INFO, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set))\n# define ASN1_seq_pack_PKCS7_SIGNER_INFO(st, i2d_func, buf, len) \\\n        SKM_ASN1_seq_pack(PKCS7_SIGNER_INFO, (st), (i2d_func), (buf), (len))\n# define ASN1_seq_unpack_PKCS7_SIGNER_INFO(buf, len, d2i_func, free_func) \\\n        SKM_ASN1_seq_unpack(PKCS7_SIGNER_INFO, (buf), (len), (d2i_func), (free_func))\n# define d2i_ASN1_SET_OF_POLICYINFO(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \\\n        SKM_ASN1_SET_OF_d2i(POLICYINFO, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class))\n# define i2d_ASN1_SET_OF_POLICYINFO(st, pp, i2d_func, ex_tag, ex_class, is_set) \\\n        SKM_ASN1_SET_OF_i2d(POLICYINFO, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set))\n# define ASN1_seq_pack_POLICYINFO(st, i2d_func, buf, len) \\\n        SKM_ASN1_seq_pack(POLICYINFO, (st), (i2d_func), (buf), (len))\n# define ASN1_seq_unpack_POLICYINFO(buf, len, d2i_func, free_func) \\\n        SKM_ASN1_seq_unpack(POLICYINFO, (buf), (len), (d2i_func), (free_func))\n# define d2i_ASN1_SET_OF_POLICYQUALINFO(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \\\n        SKM_ASN1_SET_OF_d2i(POLICYQUALINFO, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class))\n# define i2d_ASN1_SET_OF_POLICYQUALINFO(st, pp, i2d_func, ex_tag, ex_class, is_set) \\\n        SKM_ASN1_SET_OF_i2d(POLICYQUALINFO, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set))\n# define ASN1_seq_pack_POLICYQUALINFO(st, i2d_func, buf, len) \\\n        SKM_ASN1_seq_pack(POLICYQUALINFO, (st), (i2d_func), (buf), (len))\n# define ASN1_seq_unpack_POLICYQUALINFO(buf, len, d2i_func, free_func) \\\n        SKM_ASN1_seq_unpack(POLICYQUALINFO, (buf), (len), (d2i_func), (free_func))\n# define d2i_ASN1_SET_OF_SXNETID(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \\\n        SKM_ASN1_SET_OF_d2i(SXNETID, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class))\n# define i2d_ASN1_SET_OF_SXNETID(st, pp, i2d_func, ex_tag, ex_class, is_set) \\\n        SKM_ASN1_SET_OF_i2d(SXNETID, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set))\n# define ASN1_seq_pack_SXNETID(st, i2d_func, buf, len) \\\n        SKM_ASN1_seq_pack(SXNETID, (st), (i2d_func), (buf), (len))\n# define ASN1_seq_unpack_SXNETID(buf, len, d2i_func, free_func) \\\n        SKM_ASN1_seq_unpack(SXNETID, (buf), (len), (d2i_func), (free_func))\n# define d2i_ASN1_SET_OF_X509(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \\\n        SKM_ASN1_SET_OF_d2i(X509, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class))\n# define i2d_ASN1_SET_OF_X509(st, pp, i2d_func, ex_tag, ex_class, is_set) \\\n        SKM_ASN1_SET_OF_i2d(X509, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set))\n# define ASN1_seq_pack_X509(st, i2d_func, buf, len) \\\n        SKM_ASN1_seq_pack(X509, (st), (i2d_func), (buf), (len))\n# define ASN1_seq_unpack_X509(buf, len, d2i_func, free_func) \\\n        SKM_ASN1_seq_unpack(X509, (buf), (len), (d2i_func), (free_func))\n# define d2i_ASN1_SET_OF_X509_ALGOR(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \\\n        SKM_ASN1_SET_OF_d2i(X509_ALGOR, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class))\n# define i2d_ASN1_SET_OF_X509_ALGOR(st, pp, i2d_func, ex_tag, ex_class, is_set) \\\n        SKM_ASN1_SET_OF_i2d(X509_ALGOR, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set))\n# define ASN1_seq_pack_X509_ALGOR(st, i2d_func, buf, len) \\\n        SKM_ASN1_seq_pack(X509_ALGOR, (st), (i2d_func), (buf), (len))\n# define ASN1_seq_unpack_X509_ALGOR(buf, len, d2i_func, free_func) \\\n        SKM_ASN1_seq_unpack(X509_ALGOR, (buf), (len), (d2i_func), (free_func))\n# define d2i_ASN1_SET_OF_X509_ATTRIBUTE(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \\\n        SKM_ASN1_SET_OF_d2i(X509_ATTRIBUTE, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class))\n# define i2d_ASN1_SET_OF_X509_ATTRIBUTE(st, pp, i2d_func, ex_tag, ex_class, is_set) \\\n        SKM_ASN1_SET_OF_i2d(X509_ATTRIBUTE, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set))\n# define ASN1_seq_pack_X509_ATTRIBUTE(st, i2d_func, buf, len) \\\n        SKM_ASN1_seq_pack(X509_ATTRIBUTE, (st), (i2d_func), (buf), (len))\n# define ASN1_seq_unpack_X509_ATTRIBUTE(buf, len, d2i_func, free_func) \\\n        SKM_ASN1_seq_unpack(X509_ATTRIBUTE, (buf), (len), (d2i_func), (free_func))\n# define d2i_ASN1_SET_OF_X509_CRL(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \\\n        SKM_ASN1_SET_OF_d2i(X509_CRL, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class))\n# define i2d_ASN1_SET_OF_X509_CRL(st, pp, i2d_func, ex_tag, ex_class, is_set) \\\n        SKM_ASN1_SET_OF_i2d(X509_CRL, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set))\n# define ASN1_seq_pack_X509_CRL(st, i2d_func, buf, len) \\\n        SKM_ASN1_seq_pack(X509_CRL, (st), (i2d_func), (buf), (len))\n# define ASN1_seq_unpack_X509_CRL(buf, len, d2i_func, free_func) \\\n        SKM_ASN1_seq_unpack(X509_CRL, (buf), (len), (d2i_func), (free_func))\n# define d2i_ASN1_SET_OF_X509_EXTENSION(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \\\n        SKM_ASN1_SET_OF_d2i(X509_EXTENSION, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class))\n# define i2d_ASN1_SET_OF_X509_EXTENSION(st, pp, i2d_func, ex_tag, ex_class, is_set) \\\n        SKM_ASN1_SET_OF_i2d(X509_EXTENSION, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set))\n# define ASN1_seq_pack_X509_EXTENSION(st, i2d_func, buf, len) \\\n        SKM_ASN1_seq_pack(X509_EXTENSION, (st), (i2d_func), (buf), (len))\n# define ASN1_seq_unpack_X509_EXTENSION(buf, len, d2i_func, free_func) \\\n        SKM_ASN1_seq_unpack(X509_EXTENSION, (buf), (len), (d2i_func), (free_func))\n# define d2i_ASN1_SET_OF_X509_NAME_ENTRY(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \\\n        SKM_ASN1_SET_OF_d2i(X509_NAME_ENTRY, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class))\n# define i2d_ASN1_SET_OF_X509_NAME_ENTRY(st, pp, i2d_func, ex_tag, ex_class, is_set) \\\n        SKM_ASN1_SET_OF_i2d(X509_NAME_ENTRY, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set))\n# define ASN1_seq_pack_X509_NAME_ENTRY(st, i2d_func, buf, len) \\\n        SKM_ASN1_seq_pack(X509_NAME_ENTRY, (st), (i2d_func), (buf), (len))\n# define ASN1_seq_unpack_X509_NAME_ENTRY(buf, len, d2i_func, free_func) \\\n        SKM_ASN1_seq_unpack(X509_NAME_ENTRY, (buf), (len), (d2i_func), (free_func))\n# define d2i_ASN1_SET_OF_X509_REVOKED(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \\\n        SKM_ASN1_SET_OF_d2i(X509_REVOKED, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class))\n# define i2d_ASN1_SET_OF_X509_REVOKED(st, pp, i2d_func, ex_tag, ex_class, is_set) \\\n        SKM_ASN1_SET_OF_i2d(X509_REVOKED, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set))\n# define ASN1_seq_pack_X509_REVOKED(st, i2d_func, buf, len) \\\n        SKM_ASN1_seq_pack(X509_REVOKED, (st), (i2d_func), (buf), (len))\n# define ASN1_seq_unpack_X509_REVOKED(buf, len, d2i_func, free_func) \\\n        SKM_ASN1_seq_unpack(X509_REVOKED, (buf), (len), (d2i_func), (free_func))\n# define PKCS12_decrypt_d2i_PKCS12_SAFEBAG(algor, d2i_func, free_func, pass, passlen, oct, seq) \\\n        SKM_PKCS12_decrypt_d2i(PKCS12_SAFEBAG, (algor), (d2i_func), (free_func), (pass), (passlen), (oct), (seq))\n# define PKCS12_decrypt_d2i_PKCS7(algor, d2i_func, free_func, pass, passlen, oct, seq) \\\n        SKM_PKCS12_decrypt_d2i(PKCS7, (algor), (d2i_func), (free_func), (pass), (passlen), (oct), (seq))\n# define lh_ADDED_OBJ_new() LHM_lh_new(ADDED_OBJ,added_obj)\n# define lh_ADDED_OBJ_insert(lh,inst) LHM_lh_insert(ADDED_OBJ,lh,inst)\n# define lh_ADDED_OBJ_retrieve(lh,inst) LHM_lh_retrieve(ADDED_OBJ,lh,inst)\n# define lh_ADDED_OBJ_delete(lh,inst) LHM_lh_delete(ADDED_OBJ,lh,inst)\n# define lh_ADDED_OBJ_doall(lh,fn) LHM_lh_doall(ADDED_OBJ,lh,fn)\n# define lh_ADDED_OBJ_doall_arg(lh,fn,arg_type,arg) \\\n  LHM_lh_doall_arg(ADDED_OBJ,lh,fn,arg_type,arg)\n# define lh_ADDED_OBJ_error(lh) LHM_lh_error(ADDED_OBJ,lh)\n# define lh_ADDED_OBJ_num_items(lh) LHM_lh_num_items(ADDED_OBJ,lh)\n# define lh_ADDED_OBJ_down_load(lh) LHM_lh_down_load(ADDED_OBJ,lh)\n# define lh_ADDED_OBJ_node_stats_bio(lh,out) \\\n  LHM_lh_node_stats_bio(ADDED_OBJ,lh,out)\n# define lh_ADDED_OBJ_node_usage_stats_bio(lh,out) \\\n  LHM_lh_node_usage_stats_bio(ADDED_OBJ,lh,out)\n# define lh_ADDED_OBJ_stats_bio(lh,out) \\\n  LHM_lh_stats_bio(ADDED_OBJ,lh,out)\n# define lh_ADDED_OBJ_free(lh) LHM_lh_free(ADDED_OBJ,lh)\n# define lh_APP_INFO_new() LHM_lh_new(APP_INFO,app_info)\n# define lh_APP_INFO_insert(lh,inst) LHM_lh_insert(APP_INFO,lh,inst)\n# define lh_APP_INFO_retrieve(lh,inst) LHM_lh_retrieve(APP_INFO,lh,inst)\n# define lh_APP_INFO_delete(lh,inst) LHM_lh_delete(APP_INFO,lh,inst)\n# define lh_APP_INFO_doall(lh,fn) LHM_lh_doall(APP_INFO,lh,fn)\n# define lh_APP_INFO_doall_arg(lh,fn,arg_type,arg) \\\n  LHM_lh_doall_arg(APP_INFO,lh,fn,arg_type,arg)\n# define lh_APP_INFO_error(lh) LHM_lh_error(APP_INFO,lh)\n# define lh_APP_INFO_num_items(lh) LHM_lh_num_items(APP_INFO,lh)\n# define lh_APP_INFO_down_load(lh) LHM_lh_down_load(APP_INFO,lh)\n# define lh_APP_INFO_node_stats_bio(lh,out) \\\n  LHM_lh_node_stats_bio(APP_INFO,lh,out)\n# define lh_APP_INFO_node_usage_stats_bio(lh,out) \\\n  LHM_lh_node_usage_stats_bio(APP_INFO,lh,out)\n# define lh_APP_INFO_stats_bio(lh,out) \\\n  LHM_lh_stats_bio(APP_INFO,lh,out)\n# define lh_APP_INFO_free(lh) LHM_lh_free(APP_INFO,lh)\n# define lh_CONF_VALUE_new() LHM_lh_new(CONF_VALUE,conf_value)\n# define lh_CONF_VALUE_insert(lh,inst) LHM_lh_insert(CONF_VALUE,lh,inst)\n# define lh_CONF_VALUE_retrieve(lh,inst) LHM_lh_retrieve(CONF_VALUE,lh,inst)\n# define lh_CONF_VALUE_delete(lh,inst) LHM_lh_delete(CONF_VALUE,lh,inst)\n# define lh_CONF_VALUE_doall(lh,fn) LHM_lh_doall(CONF_VALUE,lh,fn)\n# define lh_CONF_VALUE_doall_arg(lh,fn,arg_type,arg) \\\n  LHM_lh_doall_arg(CONF_VALUE,lh,fn,arg_type,arg)\n# define lh_CONF_VALUE_error(lh) LHM_lh_error(CONF_VALUE,lh)\n# define lh_CONF_VALUE_num_items(lh) LHM_lh_num_items(CONF_VALUE,lh)\n# define lh_CONF_VALUE_down_load(lh) LHM_lh_down_load(CONF_VALUE,lh)\n# define lh_CONF_VALUE_node_stats_bio(lh,out) \\\n  LHM_lh_node_stats_bio(CONF_VALUE,lh,out)\n# define lh_CONF_VALUE_node_usage_stats_bio(lh,out) \\\n  LHM_lh_node_usage_stats_bio(CONF_VALUE,lh,out)\n# define lh_CONF_VALUE_stats_bio(lh,out) \\\n  LHM_lh_stats_bio(CONF_VALUE,lh,out)\n# define lh_CONF_VALUE_free(lh) LHM_lh_free(CONF_VALUE,lh)\n# define lh_ENGINE_PILE_new() LHM_lh_new(ENGINE_PILE,engine_pile)\n# define lh_ENGINE_PILE_insert(lh,inst) LHM_lh_insert(ENGINE_PILE,lh,inst)\n# define lh_ENGINE_PILE_retrieve(lh,inst) LHM_lh_retrieve(ENGINE_PILE,lh,inst)\n# define lh_ENGINE_PILE_delete(lh,inst) LHM_lh_delete(ENGINE_PILE,lh,inst)\n# define lh_ENGINE_PILE_doall(lh,fn) LHM_lh_doall(ENGINE_PILE,lh,fn)\n# define lh_ENGINE_PILE_doall_arg(lh,fn,arg_type,arg) \\\n  LHM_lh_doall_arg(ENGINE_PILE,lh,fn,arg_type,arg)\n# define lh_ENGINE_PILE_error(lh) LHM_lh_error(ENGINE_PILE,lh)\n# define lh_ENGINE_PILE_num_items(lh) LHM_lh_num_items(ENGINE_PILE,lh)\n# define lh_ENGINE_PILE_down_load(lh) LHM_lh_down_load(ENGINE_PILE,lh)\n# define lh_ENGINE_PILE_node_stats_bio(lh,out) \\\n  LHM_lh_node_stats_bio(ENGINE_PILE,lh,out)\n# define lh_ENGINE_PILE_node_usage_stats_bio(lh,out) \\\n  LHM_lh_node_usage_stats_bio(ENGINE_PILE,lh,out)\n# define lh_ENGINE_PILE_stats_bio(lh,out) \\\n  LHM_lh_stats_bio(ENGINE_PILE,lh,out)\n# define lh_ENGINE_PILE_free(lh) LHM_lh_free(ENGINE_PILE,lh)\n# define lh_ERR_STATE_new() LHM_lh_new(ERR_STATE,err_state)\n# define lh_ERR_STATE_insert(lh,inst) LHM_lh_insert(ERR_STATE,lh,inst)\n# define lh_ERR_STATE_retrieve(lh,inst) LHM_lh_retrieve(ERR_STATE,lh,inst)\n# define lh_ERR_STATE_delete(lh,inst) LHM_lh_delete(ERR_STATE,lh,inst)\n# define lh_ERR_STATE_doall(lh,fn) LHM_lh_doall(ERR_STATE,lh,fn)\n# define lh_ERR_STATE_doall_arg(lh,fn,arg_type,arg) \\\n  LHM_lh_doall_arg(ERR_STATE,lh,fn,arg_type,arg)\n# define lh_ERR_STATE_error(lh) LHM_lh_error(ERR_STATE,lh)\n# define lh_ERR_STATE_num_items(lh) LHM_lh_num_items(ERR_STATE,lh)\n# define lh_ERR_STATE_down_load(lh) LHM_lh_down_load(ERR_STATE,lh)\n# define lh_ERR_STATE_node_stats_bio(lh,out) \\\n  LHM_lh_node_stats_bio(ERR_STATE,lh,out)\n# define lh_ERR_STATE_node_usage_stats_bio(lh,out) \\\n  LHM_lh_node_usage_stats_bio(ERR_STATE,lh,out)\n# define lh_ERR_STATE_stats_bio(lh,out) \\\n  LHM_lh_stats_bio(ERR_STATE,lh,out)\n# define lh_ERR_STATE_free(lh) LHM_lh_free(ERR_STATE,lh)\n# define lh_ERR_STRING_DATA_new() LHM_lh_new(ERR_STRING_DATA,err_string_data)\n# define lh_ERR_STRING_DATA_insert(lh,inst) LHM_lh_insert(ERR_STRING_DATA,lh,inst)\n# define lh_ERR_STRING_DATA_retrieve(lh,inst) LHM_lh_retrieve(ERR_STRING_DATA,lh,inst)\n# define lh_ERR_STRING_DATA_delete(lh,inst) LHM_lh_delete(ERR_STRING_DATA,lh,inst)\n# define lh_ERR_STRING_DATA_doall(lh,fn) LHM_lh_doall(ERR_STRING_DATA,lh,fn)\n# define lh_ERR_STRING_DATA_doall_arg(lh,fn,arg_type,arg) \\\n  LHM_lh_doall_arg(ERR_STRING_DATA,lh,fn,arg_type,arg)\n# define lh_ERR_STRING_DATA_error(lh) LHM_lh_error(ERR_STRING_DATA,lh)\n# define lh_ERR_STRING_DATA_num_items(lh) LHM_lh_num_items(ERR_STRING_DATA,lh)\n# define lh_ERR_STRING_DATA_down_load(lh) LHM_lh_down_load(ERR_STRING_DATA,lh)\n# define lh_ERR_STRING_DATA_node_stats_bio(lh,out) \\\n  LHM_lh_node_stats_bio(ERR_STRING_DATA,lh,out)\n# define lh_ERR_STRING_DATA_node_usage_stats_bio(lh,out) \\\n  LHM_lh_node_usage_stats_bio(ERR_STRING_DATA,lh,out)\n# define lh_ERR_STRING_DATA_stats_bio(lh,out) \\\n  LHM_lh_stats_bio(ERR_STRING_DATA,lh,out)\n# define lh_ERR_STRING_DATA_free(lh) LHM_lh_free(ERR_STRING_DATA,lh)\n# define lh_EX_CLASS_ITEM_new() LHM_lh_new(EX_CLASS_ITEM,ex_class_item)\n# define lh_EX_CLASS_ITEM_insert(lh,inst) LHM_lh_insert(EX_CLASS_ITEM,lh,inst)\n# define lh_EX_CLASS_ITEM_retrieve(lh,inst) LHM_lh_retrieve(EX_CLASS_ITEM,lh,inst)\n# define lh_EX_CLASS_ITEM_delete(lh,inst) LHM_lh_delete(EX_CLASS_ITEM,lh,inst)\n# define lh_EX_CLASS_ITEM_doall(lh,fn) LHM_lh_doall(EX_CLASS_ITEM,lh,fn)\n# define lh_EX_CLASS_ITEM_doall_arg(lh,fn,arg_type,arg) \\\n  LHM_lh_doall_arg(EX_CLASS_ITEM,lh,fn,arg_type,arg)\n# define lh_EX_CLASS_ITEM_error(lh) LHM_lh_error(EX_CLASS_ITEM,lh)\n# define lh_EX_CLASS_ITEM_num_items(lh) LHM_lh_num_items(EX_CLASS_ITEM,lh)\n# define lh_EX_CLASS_ITEM_down_load(lh) LHM_lh_down_load(EX_CLASS_ITEM,lh)\n# define lh_EX_CLASS_ITEM_node_stats_bio(lh,out) \\\n  LHM_lh_node_stats_bio(EX_CLASS_ITEM,lh,out)\n# define lh_EX_CLASS_ITEM_node_usage_stats_bio(lh,out) \\\n  LHM_lh_node_usage_stats_bio(EX_CLASS_ITEM,lh,out)\n# define lh_EX_CLASS_ITEM_stats_bio(lh,out) \\\n  LHM_lh_stats_bio(EX_CLASS_ITEM,lh,out)\n# define lh_EX_CLASS_ITEM_free(lh) LHM_lh_free(EX_CLASS_ITEM,lh)\n# define lh_FUNCTION_new() LHM_lh_new(FUNCTION,function)\n# define lh_FUNCTION_insert(lh,inst) LHM_lh_insert(FUNCTION,lh,inst)\n# define lh_FUNCTION_retrieve(lh,inst) LHM_lh_retrieve(FUNCTION,lh,inst)\n# define lh_FUNCTION_delete(lh,inst) LHM_lh_delete(FUNCTION,lh,inst)\n# define lh_FUNCTION_doall(lh,fn) LHM_lh_doall(FUNCTION,lh,fn)\n# define lh_FUNCTION_doall_arg(lh,fn,arg_type,arg) \\\n  LHM_lh_doall_arg(FUNCTION,lh,fn,arg_type,arg)\n# define lh_FUNCTION_error(lh) LHM_lh_error(FUNCTION,lh)\n# define lh_FUNCTION_num_items(lh) LHM_lh_num_items(FUNCTION,lh)\n# define lh_FUNCTION_down_load(lh) LHM_lh_down_load(FUNCTION,lh)\n# define lh_FUNCTION_node_stats_bio(lh,out) \\\n  LHM_lh_node_stats_bio(FUNCTION,lh,out)\n# define lh_FUNCTION_node_usage_stats_bio(lh,out) \\\n  LHM_lh_node_usage_stats_bio(FUNCTION,lh,out)\n# define lh_FUNCTION_stats_bio(lh,out) \\\n  LHM_lh_stats_bio(FUNCTION,lh,out)\n# define lh_FUNCTION_free(lh) LHM_lh_free(FUNCTION,lh)\n# define lh_MEM_new() LHM_lh_new(MEM,mem)\n# define lh_MEM_insert(lh,inst) LHM_lh_insert(MEM,lh,inst)\n# define lh_MEM_retrieve(lh,inst) LHM_lh_retrieve(MEM,lh,inst)\n# define lh_MEM_delete(lh,inst) LHM_lh_delete(MEM,lh,inst)\n# define lh_MEM_doall(lh,fn) LHM_lh_doall(MEM,lh,fn)\n# define lh_MEM_doall_arg(lh,fn,arg_type,arg) \\\n  LHM_lh_doall_arg(MEM,lh,fn,arg_type,arg)\n# define lh_MEM_error(lh) LHM_lh_error(MEM,lh)\n# define lh_MEM_num_items(lh) LHM_lh_num_items(MEM,lh)\n# define lh_MEM_down_load(lh) LHM_lh_down_load(MEM,lh)\n# define lh_MEM_node_stats_bio(lh,out) \\\n  LHM_lh_node_stats_bio(MEM,lh,out)\n# define lh_MEM_node_usage_stats_bio(lh,out) \\\n  LHM_lh_node_usage_stats_bio(MEM,lh,out)\n# define lh_MEM_stats_bio(lh,out) \\\n  LHM_lh_stats_bio(MEM,lh,out)\n# define lh_MEM_free(lh) LHM_lh_free(MEM,lh)\n# define lh_OBJ_NAME_new() LHM_lh_new(OBJ_NAME,obj_name)\n# define lh_OBJ_NAME_insert(lh,inst) LHM_lh_insert(OBJ_NAME,lh,inst)\n# define lh_OBJ_NAME_retrieve(lh,inst) LHM_lh_retrieve(OBJ_NAME,lh,inst)\n# define lh_OBJ_NAME_delete(lh,inst) LHM_lh_delete(OBJ_NAME,lh,inst)\n# define lh_OBJ_NAME_doall(lh,fn) LHM_lh_doall(OBJ_NAME,lh,fn)\n# define lh_OBJ_NAME_doall_arg(lh,fn,arg_type,arg) \\\n  LHM_lh_doall_arg(OBJ_NAME,lh,fn,arg_type,arg)\n# define lh_OBJ_NAME_error(lh) LHM_lh_error(OBJ_NAME,lh)\n# define lh_OBJ_NAME_num_items(lh) LHM_lh_num_items(OBJ_NAME,lh)\n# define lh_OBJ_NAME_down_load(lh) LHM_lh_down_load(OBJ_NAME,lh)\n# define lh_OBJ_NAME_node_stats_bio(lh,out) \\\n  LHM_lh_node_stats_bio(OBJ_NAME,lh,out)\n# define lh_OBJ_NAME_node_usage_stats_bio(lh,out) \\\n  LHM_lh_node_usage_stats_bio(OBJ_NAME,lh,out)\n# define lh_OBJ_NAME_stats_bio(lh,out) \\\n  LHM_lh_stats_bio(OBJ_NAME,lh,out)\n# define lh_OBJ_NAME_free(lh) LHM_lh_free(OBJ_NAME,lh)\n# define lh_OPENSSL_CSTRING_new() LHM_lh_new(OPENSSL_CSTRING,openssl_cstring)\n# define lh_OPENSSL_CSTRING_insert(lh,inst) LHM_lh_insert(OPENSSL_CSTRING,lh,inst)\n# define lh_OPENSSL_CSTRING_retrieve(lh,inst) LHM_lh_retrieve(OPENSSL_CSTRING,lh,inst)\n# define lh_OPENSSL_CSTRING_delete(lh,inst) LHM_lh_delete(OPENSSL_CSTRING,lh,inst)\n# define lh_OPENSSL_CSTRING_doall(lh,fn) LHM_lh_doall(OPENSSL_CSTRING,lh,fn)\n# define lh_OPENSSL_CSTRING_doall_arg(lh,fn,arg_type,arg) \\\n  LHM_lh_doall_arg(OPENSSL_CSTRING,lh,fn,arg_type,arg)\n# define lh_OPENSSL_CSTRING_error(lh) LHM_lh_error(OPENSSL_CSTRING,lh)\n# define lh_OPENSSL_CSTRING_num_items(lh) LHM_lh_num_items(OPENSSL_CSTRING,lh)\n# define lh_OPENSSL_CSTRING_down_load(lh) LHM_lh_down_load(OPENSSL_CSTRING,lh)\n# define lh_OPENSSL_CSTRING_node_stats_bio(lh,out) \\\n  LHM_lh_node_stats_bio(OPENSSL_CSTRING,lh,out)\n# define lh_OPENSSL_CSTRING_node_usage_stats_bio(lh,out) \\\n  LHM_lh_node_usage_stats_bio(OPENSSL_CSTRING,lh,out)\n# define lh_OPENSSL_CSTRING_stats_bio(lh,out) \\\n  LHM_lh_stats_bio(OPENSSL_CSTRING,lh,out)\n# define lh_OPENSSL_CSTRING_free(lh) LHM_lh_free(OPENSSL_CSTRING,lh)\n# define lh_OPENSSL_STRING_new() LHM_lh_new(OPENSSL_STRING,openssl_string)\n# define lh_OPENSSL_STRING_insert(lh,inst) LHM_lh_insert(OPENSSL_STRING,lh,inst)\n# define lh_OPENSSL_STRING_retrieve(lh,inst) LHM_lh_retrieve(OPENSSL_STRING,lh,inst)\n# define lh_OPENSSL_STRING_delete(lh,inst) LHM_lh_delete(OPENSSL_STRING,lh,inst)\n# define lh_OPENSSL_STRING_doall(lh,fn) LHM_lh_doall(OPENSSL_STRING,lh,fn)\n# define lh_OPENSSL_STRING_doall_arg(lh,fn,arg_type,arg) \\\n  LHM_lh_doall_arg(OPENSSL_STRING,lh,fn,arg_type,arg)\n# define lh_OPENSSL_STRING_error(lh) LHM_lh_error(OPENSSL_STRING,lh)\n# define lh_OPENSSL_STRING_num_items(lh) LHM_lh_num_items(OPENSSL_STRING,lh)\n# define lh_OPENSSL_STRING_down_load(lh) LHM_lh_down_load(OPENSSL_STRING,lh)\n# define lh_OPENSSL_STRING_node_stats_bio(lh,out) \\\n  LHM_lh_node_stats_bio(OPENSSL_STRING,lh,out)\n# define lh_OPENSSL_STRING_node_usage_stats_bio(lh,out) \\\n  LHM_lh_node_usage_stats_bio(OPENSSL_STRING,lh,out)\n# define lh_OPENSSL_STRING_stats_bio(lh,out) \\\n  LHM_lh_stats_bio(OPENSSL_STRING,lh,out)\n# define lh_OPENSSL_STRING_free(lh) LHM_lh_free(OPENSSL_STRING,lh)\n# define lh_SSL_SESSION_new() LHM_lh_new(SSL_SESSION,ssl_session)\n# define lh_SSL_SESSION_insert(lh,inst) LHM_lh_insert(SSL_SESSION,lh,inst)\n# define lh_SSL_SESSION_retrieve(lh,inst) LHM_lh_retrieve(SSL_SESSION,lh,inst)\n# define lh_SSL_SESSION_delete(lh,inst) LHM_lh_delete(SSL_SESSION,lh,inst)\n# define lh_SSL_SESSION_doall(lh,fn) LHM_lh_doall(SSL_SESSION,lh,fn)\n# define lh_SSL_SESSION_doall_arg(lh,fn,arg_type,arg) \\\n  LHM_lh_doall_arg(SSL_SESSION,lh,fn,arg_type,arg)\n# define lh_SSL_SESSION_error(lh) LHM_lh_error(SSL_SESSION,lh)\n# define lh_SSL_SESSION_num_items(lh) LHM_lh_num_items(SSL_SESSION,lh)\n# define lh_SSL_SESSION_down_load(lh) LHM_lh_down_load(SSL_SESSION,lh)\n# define lh_SSL_SESSION_node_stats_bio(lh,out) \\\n  LHM_lh_node_stats_bio(SSL_SESSION,lh,out)\n# define lh_SSL_SESSION_node_usage_stats_bio(lh,out) \\\n  LHM_lh_node_usage_stats_bio(SSL_SESSION,lh,out)\n# define lh_SSL_SESSION_stats_bio(lh,out) \\\n  LHM_lh_stats_bio(SSL_SESSION,lh,out)\n# define lh_SSL_SESSION_free(lh) LHM_lh_free(SSL_SESSION,lh)\n#ifdef  __cplusplus\n}\n#endif\n#endif                          /* !defined HEADER_SAFESTACK_H */\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/x86/include/openssl/seed.h",
    "content": "/*\n * Copyright (c) 2007 KISA(Korea Information Security Agency). All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n * 2. Neither the name of author nor the names of its contributors may\n *    be used to endorse or promote products derived from this software\n *    without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED.  IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n * SUCH DAMAGE.\n *\n */\n/* ====================================================================\n * Copyright (c) 1998-2007 The OpenSSL Project.  All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n *\n * 1. Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n *\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in\n *    the documentation and/or other materials provided with the\n *    distribution.\n *\n * 3. All advertising materials mentioning features or use of this\n *    software must display the following acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit. (http://www.openssl.org/)\"\n *\n * 4. The names \"OpenSSL Toolkit\" and \"OpenSSL Project\" must not be used to\n *    endorse or promote products derived from this software without\n *    prior written permission. For written permission, please contact\n *    openssl-core@openssl.org.\n *\n * 5. Products derived from this software may not be called \"OpenSSL\"\n *    nor may \"OpenSSL\" appear in their names without prior written\n *    permission of the OpenSSL Project.\n *\n * 6. Redistributions of any form whatsoever must retain the following\n *    acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit (http://www.openssl.org/)\"\n *\n * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY\n * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\n * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR\n * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\n * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,\n * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED\n * OF THE POSSIBILITY OF SUCH DAMAGE.\n * ====================================================================\n *\n * This product includes cryptographic software written by Eric Young\n * (eay@cryptsoft.com).  This product includes software written by Tim\n * Hudson (tjh@cryptsoft.com).\n *\n */\n\n#ifndef HEADER_SEED_H\n# define HEADER_SEED_H\n\n# include <openssl/opensslconf.h>\n# include <openssl/e_os2.h>\n# include <openssl/crypto.h>\n\n# ifdef OPENSSL_NO_SEED\n#  error SEED is disabled.\n# endif\n\n/* look whether we need 'long' to get 32 bits */\n# ifdef AES_LONG\n#  ifndef SEED_LONG\n#   define SEED_LONG 1\n#  endif\n# endif\n\n# if !defined(NO_SYS_TYPES_H)\n#  include <sys/types.h>\n# endif\n\n# define SEED_BLOCK_SIZE 16\n# define SEED_KEY_LENGTH 16\n\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\ntypedef struct seed_key_st {\n# ifdef SEED_LONG\n    unsigned long data[32];\n# else\n    unsigned int data[32];\n# endif\n} SEED_KEY_SCHEDULE;\n\n# ifdef OPENSSL_FIPS\nvoid private_SEED_set_key(const unsigned char rawkey[SEED_KEY_LENGTH],\n                          SEED_KEY_SCHEDULE *ks);\n# endif\nvoid SEED_set_key(const unsigned char rawkey[SEED_KEY_LENGTH],\n                  SEED_KEY_SCHEDULE *ks);\n\nvoid SEED_encrypt(const unsigned char s[SEED_BLOCK_SIZE],\n                  unsigned char d[SEED_BLOCK_SIZE],\n                  const SEED_KEY_SCHEDULE *ks);\nvoid SEED_decrypt(const unsigned char s[SEED_BLOCK_SIZE],\n                  unsigned char d[SEED_BLOCK_SIZE],\n                  const SEED_KEY_SCHEDULE *ks);\n\nvoid SEED_ecb_encrypt(const unsigned char *in, unsigned char *out,\n                      const SEED_KEY_SCHEDULE *ks, int enc);\nvoid SEED_cbc_encrypt(const unsigned char *in, unsigned char *out, size_t len,\n                      const SEED_KEY_SCHEDULE *ks,\n                      unsigned char ivec[SEED_BLOCK_SIZE], int enc);\nvoid SEED_cfb128_encrypt(const unsigned char *in, unsigned char *out,\n                         size_t len, const SEED_KEY_SCHEDULE *ks,\n                         unsigned char ivec[SEED_BLOCK_SIZE], int *num,\n                         int enc);\nvoid SEED_ofb128_encrypt(const unsigned char *in, unsigned char *out,\n                         size_t len, const SEED_KEY_SCHEDULE *ks,\n                         unsigned char ivec[SEED_BLOCK_SIZE], int *num);\n\n#ifdef  __cplusplus\n}\n#endif\n\n#endif                          /* HEADER_SEED_H */\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/x86/include/openssl/sha.h",
    "content": "/* crypto/sha/sha.h */\n/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)\n * All rights reserved.\n *\n * This package is an SSL implementation written\n * by Eric Young (eay@cryptsoft.com).\n * The implementation was written so as to conform with Netscapes SSL.\n *\n * This library is free for commercial and non-commercial use as long as\n * the following conditions are aheared to.  The following conditions\n * apply to all code found in this distribution, be it the RC4, RSA,\n * lhash, DES, etc., code; not just the SSL code.  The SSL documentation\n * included with this distribution is covered by the same copyright terms\n * except that the holder is Tim Hudson (tjh@cryptsoft.com).\n *\n * Copyright remains Eric Young's, and as such any Copyright notices in\n * the code are not to be removed.\n * If this package is used in a product, Eric Young should be given attribution\n * as the author of the parts of the library used.\n * This can be in the form of a textual message at program startup or\n * in documentation (online or textual) provided with the package.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the copyright\n *    notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in the\n *    documentation and/or other materials provided with the distribution.\n * 3. All advertising materials mentioning features or use of this software\n *    must display the following acknowledgement:\n *    \"This product includes cryptographic software written by\n *     Eric Young (eay@cryptsoft.com)\"\n *    The word 'cryptographic' can be left out if the rouines from the library\n *    being used are not cryptographic related :-).\n * 4. If you include any Windows specific code (or a derivative thereof) from\n *    the apps directory (application code) you must include an acknowledgement:\n *    \"This product includes software written by Tim Hudson (tjh@cryptsoft.com)\"\n *\n * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n * SUCH DAMAGE.\n *\n * The licence and distribution terms for any publically available version or\n * derivative of this code cannot be changed.  i.e. this code cannot simply be\n * copied and put under another distribution licence\n * [including the GNU Public Licence.]\n */\n\n#ifndef HEADER_SHA_H\n# define HEADER_SHA_H\n\n# include <openssl/e_os2.h>\n# include <stddef.h>\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n# if defined(OPENSSL_NO_SHA) || (defined(OPENSSL_NO_SHA0) && defined(OPENSSL_NO_SHA1))\n#  error SHA is disabled.\n# endif\n\n# if defined(OPENSSL_FIPS)\n#  define FIPS_SHA_SIZE_T size_t\n# endif\n\n/*-\n * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n * ! SHA_LONG has to be at least 32 bits wide. If it's wider, then !\n * ! SHA_LONG_LOG2 has to be defined along.                        !\n * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n */\n\n# if defined(__LP32__)\n#  define SHA_LONG unsigned long\n# elif defined(OPENSSL_SYS_CRAY) || defined(__ILP64__)\n#  define SHA_LONG unsigned long\n#  define SHA_LONG_LOG2 3\n# else\n#  define SHA_LONG unsigned int\n# endif\n\n# define SHA_LBLOCK      16\n# define SHA_CBLOCK      (SHA_LBLOCK*4)/* SHA treats input data as a\n                                        * contiguous array of 32 bit wide\n                                        * big-endian values. */\n# define SHA_LAST_BLOCK  (SHA_CBLOCK-8)\n# define SHA_DIGEST_LENGTH 20\n\ntypedef struct SHAstate_st {\n    SHA_LONG h0, h1, h2, h3, h4;\n    SHA_LONG Nl, Nh;\n    SHA_LONG data[SHA_LBLOCK];\n    unsigned int num;\n} SHA_CTX;\n\n# ifndef OPENSSL_NO_SHA0\n#  ifdef OPENSSL_FIPS\nint private_SHA_Init(SHA_CTX *c);\n#  endif\nint SHA_Init(SHA_CTX *c);\nint SHA_Update(SHA_CTX *c, const void *data, size_t len);\nint SHA_Final(unsigned char *md, SHA_CTX *c);\nunsigned char *SHA(const unsigned char *d, size_t n, unsigned char *md);\nvoid SHA_Transform(SHA_CTX *c, const unsigned char *data);\n# endif\n# ifndef OPENSSL_NO_SHA1\n#  ifdef OPENSSL_FIPS\nint private_SHA1_Init(SHA_CTX *c);\n#  endif\nint SHA1_Init(SHA_CTX *c);\nint SHA1_Update(SHA_CTX *c, const void *data, size_t len);\nint SHA1_Final(unsigned char *md, SHA_CTX *c);\nunsigned char *SHA1(const unsigned char *d, size_t n, unsigned char *md);\nvoid SHA1_Transform(SHA_CTX *c, const unsigned char *data);\n# endif\n\n# define SHA256_CBLOCK   (SHA_LBLOCK*4)/* SHA-256 treats input data as a\n                                        * contiguous array of 32 bit wide\n                                        * big-endian values. */\n# define SHA224_DIGEST_LENGTH    28\n# define SHA256_DIGEST_LENGTH    32\n\ntypedef struct SHA256state_st {\n    SHA_LONG h[8];\n    SHA_LONG Nl, Nh;\n    SHA_LONG data[SHA_LBLOCK];\n    unsigned int num, md_len;\n} SHA256_CTX;\n\n# ifndef OPENSSL_NO_SHA256\n#  ifdef OPENSSL_FIPS\nint private_SHA224_Init(SHA256_CTX *c);\nint private_SHA256_Init(SHA256_CTX *c);\n#  endif\nint SHA224_Init(SHA256_CTX *c);\nint SHA224_Update(SHA256_CTX *c, const void *data, size_t len);\nint SHA224_Final(unsigned char *md, SHA256_CTX *c);\nunsigned char *SHA224(const unsigned char *d, size_t n, unsigned char *md);\nint SHA256_Init(SHA256_CTX *c);\nint SHA256_Update(SHA256_CTX *c, const void *data, size_t len);\nint SHA256_Final(unsigned char *md, SHA256_CTX *c);\nunsigned char *SHA256(const unsigned char *d, size_t n, unsigned char *md);\nvoid SHA256_Transform(SHA256_CTX *c, const unsigned char *data);\n# endif\n\n# define SHA384_DIGEST_LENGTH    48\n# define SHA512_DIGEST_LENGTH    64\n\n# ifndef OPENSSL_NO_SHA512\n/*\n * Unlike 32-bit digest algorithms, SHA-512 *relies* on SHA_LONG64\n * being exactly 64-bit wide. See Implementation Notes in sha512.c\n * for further details.\n */\n/*\n * SHA-512 treats input data as a\n * contiguous array of 64 bit\n * wide big-endian values.\n */\n#  define SHA512_CBLOCK   (SHA_LBLOCK*8)\n#  if (defined(_WIN32) || defined(_WIN64)) && !defined(__MINGW32__)\n#   define SHA_LONG64 unsigned __int64\n#   define U64(C)     C##UI64\n#  elif defined(__arch64__)\n#   define SHA_LONG64 unsigned long\n#   define U64(C)     C##UL\n#  else\n#   define SHA_LONG64 unsigned long long\n#   define U64(C)     C##ULL\n#  endif\n\ntypedef struct SHA512state_st {\n    SHA_LONG64 h[8];\n    SHA_LONG64 Nl, Nh;\n    union {\n        SHA_LONG64 d[SHA_LBLOCK];\n        unsigned char p[SHA512_CBLOCK];\n    } u;\n    unsigned int num, md_len;\n} SHA512_CTX;\n# endif\n\n# ifndef OPENSSL_NO_SHA512\n#  ifdef OPENSSL_FIPS\nint private_SHA384_Init(SHA512_CTX *c);\nint private_SHA512_Init(SHA512_CTX *c);\n#  endif\nint SHA384_Init(SHA512_CTX *c);\nint SHA384_Update(SHA512_CTX *c, const void *data, size_t len);\nint SHA384_Final(unsigned char *md, SHA512_CTX *c);\nunsigned char *SHA384(const unsigned char *d, size_t n, unsigned char *md);\nint SHA512_Init(SHA512_CTX *c);\nint SHA512_Update(SHA512_CTX *c, const void *data, size_t len);\nint SHA512_Final(unsigned char *md, SHA512_CTX *c);\nunsigned char *SHA512(const unsigned char *d, size_t n, unsigned char *md);\nvoid SHA512_Transform(SHA512_CTX *c, const unsigned char *data);\n# endif\n\n#ifdef  __cplusplus\n}\n#endif\n\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/x86/include/openssl/srp.h",
    "content": "/* crypto/srp/srp.h */\n/*\n * Written by Christophe Renou (christophe.renou@edelweb.fr) with the\n * precious help of Peter Sylvester (peter.sylvester@edelweb.fr) for the\n * EdelKey project and contributed to the OpenSSL project 2004.\n */\n/* ====================================================================\n * Copyright (c) 2004 The OpenSSL Project.  All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n *\n * 1. Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n *\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in\n *    the documentation and/or other materials provided with the\n *    distribution.\n *\n * 3. All advertising materials mentioning features or use of this\n *    software must display the following acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)\"\n *\n * 4. The names \"OpenSSL Toolkit\" and \"OpenSSL Project\" must not be used to\n *    endorse or promote products derived from this software without\n *    prior written permission. For written permission, please contact\n *    licensing@OpenSSL.org.\n *\n * 5. Products derived from this software may not be called \"OpenSSL\"\n *    nor may \"OpenSSL\" appear in their names without prior written\n *    permission of the OpenSSL Project.\n *\n * 6. Redistributions of any form whatsoever must retain the following\n *    acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)\"\n *\n * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY\n * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\n * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR\n * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\n * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,\n * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED\n * OF THE POSSIBILITY OF SUCH DAMAGE.\n * ====================================================================\n *\n * This product includes cryptographic software written by Eric Young\n * (eay@cryptsoft.com).  This product includes software written by Tim\n * Hudson (tjh@cryptsoft.com).\n *\n */\n#ifndef __SRP_H__\n# define __SRP_H__\n\n# ifndef OPENSSL_NO_SRP\n\n#  include <stdio.h>\n#  include <string.h>\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n#  include <openssl/safestack.h>\n#  include <openssl/bn.h>\n#  include <openssl/crypto.h>\n\ntypedef struct SRP_gN_cache_st {\n    char *b64_bn;\n    BIGNUM *bn;\n} SRP_gN_cache;\n\n\nDECLARE_STACK_OF(SRP_gN_cache)\n\ntypedef struct SRP_user_pwd_st {\n    /* Owned by us. */\n    char *id;\n    BIGNUM *s;\n    BIGNUM *v;\n    /* Not owned by us. */\n    const BIGNUM *g;\n    const BIGNUM *N;\n    /* Owned by us. */\n    char *info;\n} SRP_user_pwd;\n\nDECLARE_STACK_OF(SRP_user_pwd)\n\nvoid SRP_user_pwd_free(SRP_user_pwd *user_pwd);\n\ntypedef struct SRP_VBASE_st {\n    STACK_OF(SRP_user_pwd) *users_pwd;\n    STACK_OF(SRP_gN_cache) *gN_cache;\n/* to simulate a user */\n    char *seed_key;\n    BIGNUM *default_g;\n    BIGNUM *default_N;\n} SRP_VBASE;\n\n/*\n * Structure interne pour retenir les couples N et g\n */\ntypedef struct SRP_gN_st {\n    char *id;\n    BIGNUM *g;\n    BIGNUM *N;\n} SRP_gN;\n\nDECLARE_STACK_OF(SRP_gN)\n\nSRP_VBASE *SRP_VBASE_new(char *seed_key);\nint SRP_VBASE_free(SRP_VBASE *vb);\nint SRP_VBASE_init(SRP_VBASE *vb, char *verifier_file);\n\n/* This method ignores the configured seed and fails for an unknown user. */\nSRP_user_pwd *SRP_VBASE_get_by_user(SRP_VBASE *vb, char *username);\n/* NOTE: unlike in SRP_VBASE_get_by_user, caller owns the returned pointer.*/\nSRP_user_pwd *SRP_VBASE_get1_by_user(SRP_VBASE *vb, char *username);\n\nchar *SRP_create_verifier(const char *user, const char *pass, char **salt,\n                          char **verifier, const char *N, const char *g);\nint SRP_create_verifier_BN(const char *user, const char *pass, BIGNUM **salt,\n                           BIGNUM **verifier, BIGNUM *N, BIGNUM *g);\n\n#  define SRP_NO_ERROR 0\n#  define SRP_ERR_VBASE_INCOMPLETE_FILE 1\n#  define SRP_ERR_VBASE_BN_LIB 2\n#  define SRP_ERR_OPEN_FILE 3\n#  define SRP_ERR_MEMORY 4\n\n#  define DB_srptype      0\n#  define DB_srpverifier  1\n#  define DB_srpsalt      2\n#  define DB_srpid        3\n#  define DB_srpgN        4\n#  define DB_srpinfo      5\n#  undef  DB_NUMBER\n#  define DB_NUMBER       6\n\n#  define DB_SRP_INDEX    'I'\n#  define DB_SRP_VALID    'V'\n#  define DB_SRP_REVOKED  'R'\n#  define DB_SRP_MODIF    'v'\n\n/* see srp.c */\nchar *SRP_check_known_gN_param(BIGNUM *g, BIGNUM *N);\nSRP_gN *SRP_get_default_gN(const char *id);\n\n/* server side .... */\nBIGNUM *SRP_Calc_server_key(BIGNUM *A, BIGNUM *v, BIGNUM *u, BIGNUM *b,\n                            BIGNUM *N);\nBIGNUM *SRP_Calc_B(BIGNUM *b, BIGNUM *N, BIGNUM *g, BIGNUM *v);\nint SRP_Verify_A_mod_N(BIGNUM *A, BIGNUM *N);\nBIGNUM *SRP_Calc_u(BIGNUM *A, BIGNUM *B, BIGNUM *N);\n\n/* client side .... */\nBIGNUM *SRP_Calc_x(BIGNUM *s, const char *user, const char *pass);\nBIGNUM *SRP_Calc_A(BIGNUM *a, BIGNUM *N, BIGNUM *g);\nBIGNUM *SRP_Calc_client_key(BIGNUM *N, BIGNUM *B, BIGNUM *g, BIGNUM *x,\n                            BIGNUM *a, BIGNUM *u);\nint SRP_Verify_B_mod_N(BIGNUM *B, BIGNUM *N);\n\n#  define SRP_MINIMAL_N 1024\n\n#ifdef  __cplusplus\n}\n#endif\n\n# endif\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/x86/include/openssl/srtp.h",
    "content": "/* ssl/srtp.h */\n/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)\n * All rights reserved.\n *\n * This package is an SSL implementation written\n * by Eric Young (eay@cryptsoft.com).\n * The implementation was written so as to conform with Netscapes SSL.\n *\n * This library is free for commercial and non-commercial use as long as\n * the following conditions are aheared to.  The following conditions\n * apply to all code found in this distribution, be it the RC4, RSA,\n * lhash, DES, etc., code; not just the SSL code.  The SSL documentation\n * included with this distribution is covered by the same copyright terms\n * except that the holder is Tim Hudson (tjh@cryptsoft.com).\n *\n * Copyright remains Eric Young's, and as such any Copyright notices in\n * the code are not to be removed.\n * If this package is used in a product, Eric Young should be given attribution\n * as the author of the parts of the library used.\n * This can be in the form of a textual message at program startup or\n * in documentation (online or textual) provided with the package.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the copyright\n *    notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in the\n *    documentation and/or other materials provided with the distribution.\n * 3. All advertising materials mentioning features or use of this software\n *    must display the following acknowledgement:\n *    \"This product includes cryptographic software written by\n *     Eric Young (eay@cryptsoft.com)\"\n *    The word 'cryptographic' can be left out if the rouines from the library\n *    being used are not cryptographic related :-).\n * 4. If you include any Windows specific code (or a derivative thereof) from\n *    the apps directory (application code) you must include an acknowledgement:\n *    \"This product includes software written by Tim Hudson (tjh@cryptsoft.com)\"\n *\n * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n * SUCH DAMAGE.\n *\n * The licence and distribution terms for any publically available version or\n * derivative of this code cannot be changed.  i.e. this code cannot simply be\n * copied and put under another distribution licence\n * [including the GNU Public Licence.]\n */\n/* ====================================================================\n * Copyright (c) 1998-2006 The OpenSSL Project.  All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n *\n * 1. Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n *\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in\n *    the documentation and/or other materials provided with the\n *    distribution.\n *\n * 3. All advertising materials mentioning features or use of this\n *    software must display the following acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit. (http://www.openssl.org/)\"\n *\n * 4. The names \"OpenSSL Toolkit\" and \"OpenSSL Project\" must not be used to\n *    endorse or promote products derived from this software without\n *    prior written permission. For written permission, please contact\n *    openssl-core@openssl.org.\n *\n * 5. Products derived from this software may not be called \"OpenSSL\"\n *    nor may \"OpenSSL\" appear in their names without prior written\n *    permission of the OpenSSL Project.\n *\n * 6. Redistributions of any form whatsoever must retain the following\n *    acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit (http://www.openssl.org/)\"\n *\n * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY\n * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\n * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR\n * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\n * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,\n * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED\n * OF THE POSSIBILITY OF SUCH DAMAGE.\n * ====================================================================\n *\n * This product includes cryptographic software written by Eric Young\n * (eay@cryptsoft.com).  This product includes software written by Tim\n * Hudson (tjh@cryptsoft.com).\n *\n */\n/*\n * DTLS code by Eric Rescorla <ekr@rtfm.com>\n *\n * Copyright (C) 2006, Network Resonance, Inc. Copyright (C) 2011, RTFM, Inc.\n */\n\n#ifndef HEADER_D1_SRTP_H\n# define HEADER_D1_SRTP_H\n\n# include <openssl/ssl.h>\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n# define SRTP_AES128_CM_SHA1_80 0x0001\n# define SRTP_AES128_CM_SHA1_32 0x0002\n# define SRTP_AES128_F8_SHA1_80 0x0003\n# define SRTP_AES128_F8_SHA1_32 0x0004\n# define SRTP_NULL_SHA1_80      0x0005\n# define SRTP_NULL_SHA1_32      0x0006\n\n# ifndef OPENSSL_NO_SRTP\n\nint SSL_CTX_set_tlsext_use_srtp(SSL_CTX *ctx, const char *profiles);\nint SSL_set_tlsext_use_srtp(SSL *ctx, const char *profiles);\n\nSTACK_OF(SRTP_PROTECTION_PROFILE) *SSL_get_srtp_profiles(SSL *ssl);\nSRTP_PROTECTION_PROFILE *SSL_get_selected_srtp_profile(SSL *s);\n\n# endif\n\n#ifdef  __cplusplus\n}\n#endif\n\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/x86/include/openssl/ssl.h",
    "content": "/* ssl/ssl.h */\n/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)\n * All rights reserved.\n *\n * This package is an SSL implementation written\n * by Eric Young (eay@cryptsoft.com).\n * The implementation was written so as to conform with Netscapes SSL.\n *\n * This library is free for commercial and non-commercial use as long as\n * the following conditions are aheared to.  The following conditions\n * apply to all code found in this distribution, be it the RC4, RSA,\n * lhash, DES, etc., code; not just the SSL code.  The SSL documentation\n * included with this distribution is covered by the same copyright terms\n * except that the holder is Tim Hudson (tjh@cryptsoft.com).\n *\n * Copyright remains Eric Young's, and as such any Copyright notices in\n * the code are not to be removed.\n * If this package is used in a product, Eric Young should be given attribution\n * as the author of the parts of the library used.\n * This can be in the form of a textual message at program startup or\n * in documentation (online or textual) provided with the package.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the copyright\n *    notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in the\n *    documentation and/or other materials provided with the distribution.\n * 3. All advertising materials mentioning features or use of this software\n *    must display the following acknowledgement:\n *    \"This product includes cryptographic software written by\n *     Eric Young (eay@cryptsoft.com)\"\n *    The word 'cryptographic' can be left out if the rouines from the library\n *    being used are not cryptographic related :-).\n * 4. If you include any Windows specific code (or a derivative thereof) from\n *    the apps directory (application code) you must include an acknowledgement:\n *    \"This product includes software written by Tim Hudson (tjh@cryptsoft.com)\"\n *\n * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n * SUCH DAMAGE.\n *\n * The licence and distribution terms for any publically available version or\n * derivative of this code cannot be changed.  i.e. this code cannot simply be\n * copied and put under another distribution licence\n * [including the GNU Public Licence.]\n */\n/* ====================================================================\n * Copyright (c) 1998-2007 The OpenSSL Project.  All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n *\n * 1. Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n *\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in\n *    the documentation and/or other materials provided with the\n *    distribution.\n *\n * 3. All advertising materials mentioning features or use of this\n *    software must display the following acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit. (http://www.openssl.org/)\"\n *\n * 4. The names \"OpenSSL Toolkit\" and \"OpenSSL Project\" must not be used to\n *    endorse or promote products derived from this software without\n *    prior written permission. For written permission, please contact\n *    openssl-core@openssl.org.\n *\n * 5. Products derived from this software may not be called \"OpenSSL\"\n *    nor may \"OpenSSL\" appear in their names without prior written\n *    permission of the OpenSSL Project.\n *\n * 6. Redistributions of any form whatsoever must retain the following\n *    acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit (http://www.openssl.org/)\"\n *\n * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY\n * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\n * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR\n * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\n * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,\n * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED\n * OF THE POSSIBILITY OF SUCH DAMAGE.\n * ====================================================================\n *\n * This product includes cryptographic software written by Eric Young\n * (eay@cryptsoft.com).  This product includes software written by Tim\n * Hudson (tjh@cryptsoft.com).\n *\n */\n/* ====================================================================\n * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED.\n * ECC cipher suite support in OpenSSL originally developed by\n * SUN MICROSYSTEMS, INC., and contributed to the OpenSSL project.\n */\n/* ====================================================================\n * Copyright 2005 Nokia. All rights reserved.\n *\n * The portions of the attached software (\"Contribution\") is developed by\n * Nokia Corporation and is licensed pursuant to the OpenSSL open source\n * license.\n *\n * The Contribution, originally written by Mika Kousa and Pasi Eronen of\n * Nokia Corporation, consists of the \"PSK\" (Pre-Shared Key) ciphersuites\n * support (see RFC 4279) to OpenSSL.\n *\n * No patent licenses or other rights except those expressly stated in\n * the OpenSSL open source license shall be deemed granted or received\n * expressly, by implication, estoppel, or otherwise.\n *\n * No assurances are provided by Nokia that the Contribution does not\n * infringe the patent or other intellectual property rights of any third\n * party or that the license provides you with all the necessary rights\n * to make use of the Contribution.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\" WITHOUT WARRANTY OF ANY KIND. IN\n * ADDITION TO THE DISCLAIMERS INCLUDED IN THE LICENSE, NOKIA\n * SPECIFICALLY DISCLAIMS ANY LIABILITY FOR CLAIMS BROUGHT BY YOU OR ANY\n * OTHER ENTITY BASED ON INFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS OR\n * OTHERWISE.\n */\n\n#ifndef HEADER_SSL_H\n# define HEADER_SSL_H\n\n# include <openssl/e_os2.h>\n\n# ifndef OPENSSL_NO_COMP\n#  include <openssl/comp.h>\n# endif\n# ifndef OPENSSL_NO_BIO\n#  include <openssl/bio.h>\n# endif\n# ifndef OPENSSL_NO_DEPRECATED\n#  ifndef OPENSSL_NO_X509\n#   include <openssl/x509.h>\n#  endif\n#  include <openssl/crypto.h>\n#  include <openssl/lhash.h>\n#  include <openssl/buffer.h>\n# endif\n# include <openssl/pem.h>\n# include <openssl/hmac.h>\n\n# include <openssl/kssl.h>\n# include <openssl/safestack.h>\n# include <openssl/symhacks.h>\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n/* SSLeay version number for ASN.1 encoding of the session information */\n/*-\n * Version 0 - initial version\n * Version 1 - added the optional peer certificate\n */\n# define SSL_SESSION_ASN1_VERSION 0x0001\n\n/* text strings for the ciphers */\n# define SSL_TXT_NULL_WITH_MD5           SSL2_TXT_NULL_WITH_MD5\n# define SSL_TXT_RC4_128_WITH_MD5        SSL2_TXT_RC4_128_WITH_MD5\n# define SSL_TXT_RC4_128_EXPORT40_WITH_MD5 SSL2_TXT_RC4_128_EXPORT40_WITH_MD5\n# define SSL_TXT_RC2_128_CBC_WITH_MD5    SSL2_TXT_RC2_128_CBC_WITH_MD5\n# define SSL_TXT_RC2_128_CBC_EXPORT40_WITH_MD5 SSL2_TXT_RC2_128_CBC_EXPORT40_WITH_MD5\n# define SSL_TXT_IDEA_128_CBC_WITH_MD5   SSL2_TXT_IDEA_128_CBC_WITH_MD5\n# define SSL_TXT_DES_64_CBC_WITH_MD5     SSL2_TXT_DES_64_CBC_WITH_MD5\n# define SSL_TXT_DES_64_CBC_WITH_SHA     SSL2_TXT_DES_64_CBC_WITH_SHA\n# define SSL_TXT_DES_192_EDE3_CBC_WITH_MD5 SSL2_TXT_DES_192_EDE3_CBC_WITH_MD5\n# define SSL_TXT_DES_192_EDE3_CBC_WITH_SHA SSL2_TXT_DES_192_EDE3_CBC_WITH_SHA\n\n/*\n * VRS Additional Kerberos5 entries\n */\n# define SSL_TXT_KRB5_DES_64_CBC_SHA   SSL3_TXT_KRB5_DES_64_CBC_SHA\n# define SSL_TXT_KRB5_DES_192_CBC3_SHA SSL3_TXT_KRB5_DES_192_CBC3_SHA\n# define SSL_TXT_KRB5_RC4_128_SHA      SSL3_TXT_KRB5_RC4_128_SHA\n# define SSL_TXT_KRB5_IDEA_128_CBC_SHA SSL3_TXT_KRB5_IDEA_128_CBC_SHA\n# define SSL_TXT_KRB5_DES_64_CBC_MD5   SSL3_TXT_KRB5_DES_64_CBC_MD5\n# define SSL_TXT_KRB5_DES_192_CBC3_MD5 SSL3_TXT_KRB5_DES_192_CBC3_MD5\n# define SSL_TXT_KRB5_RC4_128_MD5      SSL3_TXT_KRB5_RC4_128_MD5\n# define SSL_TXT_KRB5_IDEA_128_CBC_MD5 SSL3_TXT_KRB5_IDEA_128_CBC_MD5\n\n# define SSL_TXT_KRB5_DES_40_CBC_SHA   SSL3_TXT_KRB5_DES_40_CBC_SHA\n# define SSL_TXT_KRB5_RC2_40_CBC_SHA   SSL3_TXT_KRB5_RC2_40_CBC_SHA\n# define SSL_TXT_KRB5_RC4_40_SHA       SSL3_TXT_KRB5_RC4_40_SHA\n# define SSL_TXT_KRB5_DES_40_CBC_MD5   SSL3_TXT_KRB5_DES_40_CBC_MD5\n# define SSL_TXT_KRB5_RC2_40_CBC_MD5   SSL3_TXT_KRB5_RC2_40_CBC_MD5\n# define SSL_TXT_KRB5_RC4_40_MD5       SSL3_TXT_KRB5_RC4_40_MD5\n\n# define SSL_TXT_KRB5_DES_40_CBC_SHA   SSL3_TXT_KRB5_DES_40_CBC_SHA\n# define SSL_TXT_KRB5_DES_40_CBC_MD5   SSL3_TXT_KRB5_DES_40_CBC_MD5\n# define SSL_TXT_KRB5_DES_64_CBC_SHA   SSL3_TXT_KRB5_DES_64_CBC_SHA\n# define SSL_TXT_KRB5_DES_64_CBC_MD5   SSL3_TXT_KRB5_DES_64_CBC_MD5\n# define SSL_TXT_KRB5_DES_192_CBC3_SHA SSL3_TXT_KRB5_DES_192_CBC3_SHA\n# define SSL_TXT_KRB5_DES_192_CBC3_MD5 SSL3_TXT_KRB5_DES_192_CBC3_MD5\n# define SSL_MAX_KRB5_PRINCIPAL_LENGTH  256\n\n# define SSL_MAX_SSL_SESSION_ID_LENGTH           32\n# define SSL_MAX_SID_CTX_LENGTH                  32\n\n# define SSL_MIN_RSA_MODULUS_LENGTH_IN_BYTES     (512/8)\n# define SSL_MAX_KEY_ARG_LENGTH                  8\n# define SSL_MAX_MASTER_KEY_LENGTH               48\n\n/* These are used to specify which ciphers to use and not to use */\n\n# define SSL_TXT_EXP40           \"EXPORT40\"\n# define SSL_TXT_EXP56           \"EXPORT56\"\n# define SSL_TXT_LOW             \"LOW\"\n# define SSL_TXT_MEDIUM          \"MEDIUM\"\n# define SSL_TXT_HIGH            \"HIGH\"\n# define SSL_TXT_FIPS            \"FIPS\"\n\n# define SSL_TXT_kFZA            \"kFZA\"/* unused! */\n# define SSL_TXT_aFZA            \"aFZA\"/* unused! */\n# define SSL_TXT_eFZA            \"eFZA\"/* unused! */\n# define SSL_TXT_FZA             \"FZA\"/* unused! */\n\n# define SSL_TXT_aNULL           \"aNULL\"\n# define SSL_TXT_eNULL           \"eNULL\"\n# define SSL_TXT_NULL            \"NULL\"\n\n# define SSL_TXT_kRSA            \"kRSA\"\n# define SSL_TXT_kDHr            \"kDHr\"\n# define SSL_TXT_kDHd            \"kDHd\"\n# define SSL_TXT_kDH             \"kDH\"\n# define SSL_TXT_kEDH            \"kEDH\"\n# define SSL_TXT_kDHE            \"kDHE\"/* alias for kEDH */\n# define SSL_TXT_kKRB5           \"kKRB5\"\n# define SSL_TXT_kECDHr          \"kECDHr\"\n# define SSL_TXT_kECDHe          \"kECDHe\"\n# define SSL_TXT_kECDH           \"kECDH\"\n# define SSL_TXT_kEECDH          \"kEECDH\"\n# define SSL_TXT_kECDHE          \"kECDHE\"/* alias for kEECDH */\n# define SSL_TXT_kPSK            \"kPSK\"\n# define SSL_TXT_kGOST           \"kGOST\"\n# define SSL_TXT_kSRP            \"kSRP\"\n\n# define SSL_TXT_aRSA            \"aRSA\"\n# define SSL_TXT_aDSS            \"aDSS\"\n# define SSL_TXT_aDH             \"aDH\"\n# define SSL_TXT_aECDH           \"aECDH\"\n# define SSL_TXT_aKRB5           \"aKRB5\"\n# define SSL_TXT_aECDSA          \"aECDSA\"\n# define SSL_TXT_aPSK            \"aPSK\"\n# define SSL_TXT_aGOST94 \"aGOST94\"\n# define SSL_TXT_aGOST01 \"aGOST01\"\n# define SSL_TXT_aGOST  \"aGOST\"\n# define SSL_TXT_aSRP            \"aSRP\"\n\n# define SSL_TXT_DSS             \"DSS\"\n# define SSL_TXT_DH              \"DH\"\n# define SSL_TXT_EDH             \"EDH\"/* same as \"kEDH:-ADH\" */\n# define SSL_TXT_DHE             \"DHE\"/* alias for EDH */\n# define SSL_TXT_ADH             \"ADH\"\n# define SSL_TXT_RSA             \"RSA\"\n# define SSL_TXT_ECDH            \"ECDH\"\n# define SSL_TXT_EECDH           \"EECDH\"/* same as \"kEECDH:-AECDH\" */\n# define SSL_TXT_ECDHE           \"ECDHE\"/* alias for ECDHE\" */\n# define SSL_TXT_AECDH           \"AECDH\"\n# define SSL_TXT_ECDSA           \"ECDSA\"\n# define SSL_TXT_KRB5            \"KRB5\"\n# define SSL_TXT_PSK             \"PSK\"\n# define SSL_TXT_SRP             \"SRP\"\n\n# define SSL_TXT_DES             \"DES\"\n# define SSL_TXT_3DES            \"3DES\"\n# define SSL_TXT_RC4             \"RC4\"\n# define SSL_TXT_RC2             \"RC2\"\n# define SSL_TXT_IDEA            \"IDEA\"\n# define SSL_TXT_SEED            \"SEED\"\n# define SSL_TXT_AES128          \"AES128\"\n# define SSL_TXT_AES256          \"AES256\"\n# define SSL_TXT_AES             \"AES\"\n# define SSL_TXT_AES_GCM         \"AESGCM\"\n# define SSL_TXT_CAMELLIA128     \"CAMELLIA128\"\n# define SSL_TXT_CAMELLIA256     \"CAMELLIA256\"\n# define SSL_TXT_CAMELLIA        \"CAMELLIA\"\n\n# define SSL_TXT_MD5             \"MD5\"\n# define SSL_TXT_SHA1            \"SHA1\"\n# define SSL_TXT_SHA             \"SHA\"/* same as \"SHA1\" */\n# define SSL_TXT_GOST94          \"GOST94\"\n# define SSL_TXT_GOST89MAC               \"GOST89MAC\"\n# define SSL_TXT_SHA256          \"SHA256\"\n# define SSL_TXT_SHA384          \"SHA384\"\n\n# define SSL_TXT_SSLV2           \"SSLv2\"\n# define SSL_TXT_SSLV3           \"SSLv3\"\n# define SSL_TXT_TLSV1           \"TLSv1\"\n# define SSL_TXT_TLSV1_1         \"TLSv1.1\"\n# define SSL_TXT_TLSV1_2         \"TLSv1.2\"\n\n# define SSL_TXT_EXP             \"EXP\"\n# define SSL_TXT_EXPORT          \"EXPORT\"\n\n# define SSL_TXT_ALL             \"ALL\"\n\n/*-\n * COMPLEMENTOF* definitions. These identifiers are used to (de-select)\n * ciphers normally not being used.\n * Example: \"RC4\" will activate all ciphers using RC4 including ciphers\n * without authentication, which would normally disabled by DEFAULT (due\n * the \"!ADH\" being part of default). Therefore \"RC4:!COMPLEMENTOFDEFAULT\"\n * will make sure that it is also disabled in the specific selection.\n * COMPLEMENTOF* identifiers are portable between version, as adjustments\n * to the default cipher setup will also be included here.\n *\n * COMPLEMENTOFDEFAULT does not experience the same special treatment that\n * DEFAULT gets, as only selection is being done and no sorting as needed\n * for DEFAULT.\n */\n# define SSL_TXT_CMPALL          \"COMPLEMENTOFALL\"\n# define SSL_TXT_CMPDEF          \"COMPLEMENTOFDEFAULT\"\n\n/*\n * The following cipher list is used by default. It also is substituted when\n * an application-defined cipher list string starts with 'DEFAULT'.\n */\n# define SSL_DEFAULT_CIPHER_LIST \"ALL:!EXPORT:!LOW:!aNULL:!eNULL:!SSLv2\"\n/*\n * As of OpenSSL 1.0.0, ssl_create_cipher_list() in ssl/ssl_ciph.c always\n * starts with a reasonable order, and all we have to do for DEFAULT is\n * throwing out anonymous and unencrypted ciphersuites! (The latter are not\n * actually enabled by ALL, but \"ALL:RSA\" would enable some of them.)\n */\n\n/* Used in SSL_set_shutdown()/SSL_get_shutdown(); */\n# define SSL_SENT_SHUTDOWN       1\n# define SSL_RECEIVED_SHUTDOWN   2\n\n#ifdef __cplusplus\n}\n#endif\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n# if (defined(OPENSSL_NO_RSA) || defined(OPENSSL_NO_MD5)) && !defined(OPENSSL_NO_SSL2)\n#  define OPENSSL_NO_SSL2\n# endif\n\n# define SSL_FILETYPE_ASN1       X509_FILETYPE_ASN1\n# define SSL_FILETYPE_PEM        X509_FILETYPE_PEM\n\n/*\n * This is needed to stop compilers complaining about the 'struct ssl_st *'\n * function parameters used to prototype callbacks in SSL_CTX.\n */\ntypedef struct ssl_st *ssl_crock_st;\ntypedef struct tls_session_ticket_ext_st TLS_SESSION_TICKET_EXT;\ntypedef struct ssl_method_st SSL_METHOD;\ntypedef struct ssl_cipher_st SSL_CIPHER;\ntypedef struct ssl_session_st SSL_SESSION;\ntypedef struct tls_sigalgs_st TLS_SIGALGS;\ntypedef struct ssl_conf_ctx_st SSL_CONF_CTX;\n\nDECLARE_STACK_OF(SSL_CIPHER)\n\n/* SRTP protection profiles for use with the use_srtp extension (RFC 5764)*/\ntypedef struct srtp_protection_profile_st {\n    const char *name;\n    unsigned long id;\n} SRTP_PROTECTION_PROFILE;\n\nDECLARE_STACK_OF(SRTP_PROTECTION_PROFILE)\n\ntypedef int (*tls_session_ticket_ext_cb_fn) (SSL *s,\n                                             const unsigned char *data,\n                                             int len, void *arg);\ntypedef int (*tls_session_secret_cb_fn) (SSL *s, void *secret,\n                                         int *secret_len,\n                                         STACK_OF(SSL_CIPHER) *peer_ciphers,\n                                         SSL_CIPHER **cipher, void *arg);\n\n# ifndef OPENSSL_NO_TLSEXT\n\n/* Typedefs for handling custom extensions */\n\ntypedef int (*custom_ext_add_cb) (SSL *s, unsigned int ext_type,\n                                  const unsigned char **out,\n                                  size_t *outlen, int *al, void *add_arg);\n\ntypedef void (*custom_ext_free_cb) (SSL *s, unsigned int ext_type,\n                                    const unsigned char *out, void *add_arg);\n\ntypedef int (*custom_ext_parse_cb) (SSL *s, unsigned int ext_type,\n                                    const unsigned char *in,\n                                    size_t inlen, int *al, void *parse_arg);\n\n# endif\n\n# ifndef OPENSSL_NO_SSL_INTERN\n\n/* used to hold info on the particular ciphers used */\nstruct ssl_cipher_st {\n    int valid;\n    const char *name;           /* text name */\n    unsigned long id;           /* id, 4 bytes, first is version */\n    /*\n     * changed in 0.9.9: these four used to be portions of a single value\n     * 'algorithms'\n     */\n    unsigned long algorithm_mkey; /* key exchange algorithm */\n    unsigned long algorithm_auth; /* server authentication */\n    unsigned long algorithm_enc; /* symmetric encryption */\n    unsigned long algorithm_mac; /* symmetric authentication */\n    unsigned long algorithm_ssl; /* (major) protocol version */\n    unsigned long algo_strength; /* strength and export flags */\n    unsigned long algorithm2;   /* Extra flags */\n    int strength_bits;          /* Number of bits really used */\n    int alg_bits;               /* Number of bits for algorithm */\n};\n\n/* Used to hold functions for SSLv2 or SSLv3/TLSv1 functions */\nstruct ssl_method_st {\n    int version;\n    int (*ssl_new) (SSL *s);\n    void (*ssl_clear) (SSL *s);\n    void (*ssl_free) (SSL *s);\n    int (*ssl_accept) (SSL *s);\n    int (*ssl_connect) (SSL *s);\n    int (*ssl_read) (SSL *s, void *buf, int len);\n    int (*ssl_peek) (SSL *s, void *buf, int len);\n    int (*ssl_write) (SSL *s, const void *buf, int len);\n    int (*ssl_shutdown) (SSL *s);\n    int (*ssl_renegotiate) (SSL *s);\n    int (*ssl_renegotiate_check) (SSL *s);\n    long (*ssl_get_message) (SSL *s, int st1, int stn, int mt, long\n                             max, int *ok);\n    int (*ssl_read_bytes) (SSL *s, int type, unsigned char *buf, int len,\n                           int peek);\n    int (*ssl_write_bytes) (SSL *s, int type, const void *buf_, int len);\n    int (*ssl_dispatch_alert) (SSL *s);\n    long (*ssl_ctrl) (SSL *s, int cmd, long larg, void *parg);\n    long (*ssl_ctx_ctrl) (SSL_CTX *ctx, int cmd, long larg, void *parg);\n    const SSL_CIPHER *(*get_cipher_by_char) (const unsigned char *ptr);\n    int (*put_cipher_by_char) (const SSL_CIPHER *cipher, unsigned char *ptr);\n    int (*ssl_pending) (const SSL *s);\n    int (*num_ciphers) (void);\n    const SSL_CIPHER *(*get_cipher) (unsigned ncipher);\n    const struct ssl_method_st *(*get_ssl_method) (int version);\n    long (*get_timeout) (void);\n    struct ssl3_enc_method *ssl3_enc; /* Extra SSLv3/TLS stuff */\n    int (*ssl_version) (void);\n    long (*ssl_callback_ctrl) (SSL *s, int cb_id, void (*fp) (void));\n    long (*ssl_ctx_callback_ctrl) (SSL_CTX *s, int cb_id, void (*fp) (void));\n};\n\n/*-\n * Lets make this into an ASN.1 type structure as follows\n * SSL_SESSION_ID ::= SEQUENCE {\n *      version                 INTEGER,        -- structure version number\n *      SSLversion              INTEGER,        -- SSL version number\n *      Cipher                  OCTET STRING,   -- the 3 byte cipher ID\n *      Session_ID              OCTET STRING,   -- the Session ID\n *      Master_key              OCTET STRING,   -- the master key\n *      KRB5_principal          OCTET STRING    -- optional Kerberos principal\n *      Key_Arg [ 0 ] IMPLICIT  OCTET STRING,   -- the optional Key argument\n *      Time [ 1 ] EXPLICIT     INTEGER,        -- optional Start Time\n *      Timeout [ 2 ] EXPLICIT  INTEGER,        -- optional Timeout ins seconds\n *      Peer [ 3 ] EXPLICIT     X509,           -- optional Peer Certificate\n *      Session_ID_context [ 4 ] EXPLICIT OCTET STRING,   -- the Session ID context\n *      Verify_result [ 5 ] EXPLICIT INTEGER,   -- X509_V_... code for `Peer'\n *      HostName [ 6 ] EXPLICIT OCTET STRING,   -- optional HostName from servername TLS extension\n *      PSK_identity_hint [ 7 ] EXPLICIT OCTET STRING, -- optional PSK identity hint\n *      PSK_identity [ 8 ] EXPLICIT OCTET STRING,  -- optional PSK identity\n *      Ticket_lifetime_hint [9] EXPLICIT INTEGER, -- server's lifetime hint for session ticket\n *      Ticket [10]             EXPLICIT OCTET STRING, -- session ticket (clients only)\n *      Compression_meth [11]   EXPLICIT OCTET STRING, -- optional compression method\n *      SRP_username [ 12 ] EXPLICIT OCTET STRING -- optional SRP username\n *      }\n * Look in ssl/ssl_asn1.c for more details\n * I'm using EXPLICIT tags so I can read the damn things using asn1parse :-).\n */\nstruct ssl_session_st {\n    int ssl_version;            /* what ssl version session info is being\n                                 * kept in here? */\n    /* only really used in SSLv2 */\n    unsigned int key_arg_length;\n    unsigned char key_arg[SSL_MAX_KEY_ARG_LENGTH];\n    int master_key_length;\n    unsigned char master_key[SSL_MAX_MASTER_KEY_LENGTH];\n    /* session_id - valid? */\n    unsigned int session_id_length;\n    unsigned char session_id[SSL_MAX_SSL_SESSION_ID_LENGTH];\n    /*\n     * this is used to determine whether the session is being reused in the\n     * appropriate context. It is up to the application to set this, via\n     * SSL_new\n     */\n    unsigned int sid_ctx_length;\n    unsigned char sid_ctx[SSL_MAX_SID_CTX_LENGTH];\n#  ifndef OPENSSL_NO_KRB5\n    unsigned int krb5_client_princ_len;\n    unsigned char krb5_client_princ[SSL_MAX_KRB5_PRINCIPAL_LENGTH];\n#  endif                        /* OPENSSL_NO_KRB5 */\n#  ifndef OPENSSL_NO_PSK\n    char *psk_identity_hint;\n    char *psk_identity;\n#  endif\n    /*\n     * Used to indicate that session resumption is not allowed. Applications\n     * can also set this bit for a new session via not_resumable_session_cb\n     * to disable session caching and tickets.\n     */\n    int not_resumable;\n    /* The cert is the certificate used to establish this connection */\n    struct sess_cert_st /* SESS_CERT */ *sess_cert;\n    /*\n     * This is the cert for the other end. On clients, it will be the same as\n     * sess_cert->peer_key->x509 (the latter is not enough as sess_cert is\n     * not retained in the external representation of sessions, see\n     * ssl_asn1.c).\n     */\n    X509 *peer;\n    /*\n     * when app_verify_callback accepts a session where the peer's\n     * certificate is not ok, we must remember the error for session reuse:\n     */\n    long verify_result;         /* only for servers */\n    int references;\n    long timeout;\n    long time;\n    unsigned int compress_meth; /* Need to lookup the method */\n    const SSL_CIPHER *cipher;\n    unsigned long cipher_id;    /* when ASN.1 loaded, this needs to be used\n                                 * to load the 'cipher' structure */\n    STACK_OF(SSL_CIPHER) *ciphers; /* shared ciphers? */\n    CRYPTO_EX_DATA ex_data;     /* application specific data */\n    /*\n     * These are used to make removal of session-ids more efficient and to\n     * implement a maximum cache size.\n     */\n    struct ssl_session_st *prev, *next;\n#  ifndef OPENSSL_NO_TLSEXT\n    char *tlsext_hostname;\n#   ifndef OPENSSL_NO_EC\n    size_t tlsext_ecpointformatlist_length;\n    unsigned char *tlsext_ecpointformatlist; /* peer's list */\n    size_t tlsext_ellipticcurvelist_length;\n    unsigned char *tlsext_ellipticcurvelist; /* peer's list */\n#   endif                       /* OPENSSL_NO_EC */\n    /* RFC4507 info */\n    unsigned char *tlsext_tick; /* Session ticket */\n    size_t tlsext_ticklen;      /* Session ticket length */\n    long tlsext_tick_lifetime_hint; /* Session lifetime hint in seconds */\n#  endif\n#  ifndef OPENSSL_NO_SRP\n    char *srp_username;\n#  endif\n};\n\n# endif\n\n# define SSL_OP_MICROSOFT_SESS_ID_BUG                    0x00000001L\n# define SSL_OP_NETSCAPE_CHALLENGE_BUG                   0x00000002L\n/* Allow initial connection to servers that don't support RI */\n# define SSL_OP_LEGACY_SERVER_CONNECT                    0x00000004L\n# define SSL_OP_NETSCAPE_REUSE_CIPHER_CHANGE_BUG         0x00000008L\n# define SSL_OP_TLSEXT_PADDING                           0x00000010L\n# define SSL_OP_MICROSOFT_BIG_SSLV3_BUFFER               0x00000020L\n# define SSL_OP_SAFARI_ECDHE_ECDSA_BUG                   0x00000040L\n# define SSL_OP_SSLEAY_080_CLIENT_DH_BUG                 0x00000080L\n# define SSL_OP_TLS_D5_BUG                               0x00000100L\n# define SSL_OP_TLS_BLOCK_PADDING_BUG                    0x00000200L\n\n/* Hasn't done anything since OpenSSL 0.9.7h, retained for compatibility */\n# define SSL_OP_MSIE_SSLV2_RSA_PADDING                   0x0\n/* Refers to ancient SSLREF and SSLv2, retained for compatibility */\n# define SSL_OP_SSLREF2_REUSE_CERT_TYPE_BUG              0x0\n\n/*\n * Disable SSL 3.0/TLS 1.0 CBC vulnerability workaround that was added in\n * OpenSSL 0.9.6d.  Usually (depending on the application protocol) the\n * workaround is not needed.  Unfortunately some broken SSL/TLS\n * implementations cannot handle it at all, which is why we include it in\n * SSL_OP_ALL.\n */\n/* added in 0.9.6e */\n# define SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS              0x00000800L\n\n/*\n * SSL_OP_ALL: various bug workarounds that should be rather harmless.  This\n * used to be 0x000FFFFFL before 0.9.7.\n */\n# define SSL_OP_ALL                                      0x80000BFFL\n\n/* DTLS options */\n# define SSL_OP_NO_QUERY_MTU                 0x00001000L\n/* Turn on Cookie Exchange (on relevant for servers) */\n# define SSL_OP_COOKIE_EXCHANGE              0x00002000L\n/* Don't use RFC4507 ticket extension */\n# define SSL_OP_NO_TICKET                    0x00004000L\n/* Use Cisco's \"speshul\" version of DTLS_BAD_VER (as client)  */\n# define SSL_OP_CISCO_ANYCONNECT             0x00008000L\n\n/* As server, disallow session resumption on renegotiation */\n# define SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION   0x00010000L\n/* Don't use compression even if supported */\n# define SSL_OP_NO_COMPRESSION                           0x00020000L\n/* Permit unsafe legacy renegotiation */\n# define SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION        0x00040000L\n/* If set, always create a new key when using tmp_ecdh parameters */\n# define SSL_OP_SINGLE_ECDH_USE                          0x00080000L\n/* Does nothing: retained for compatibility */\n# define SSL_OP_SINGLE_DH_USE                            0x00100000L\n/* Does nothing: retained for compatibiity */\n# define SSL_OP_EPHEMERAL_RSA                            0x0\n/*\n * Set on servers to choose the cipher according to the server's preferences\n */\n# define SSL_OP_CIPHER_SERVER_PREFERENCE                 0x00400000L\n/*\n * If set, a server will allow a client to issue a SSLv3.0 version number as\n * latest version supported in the premaster secret, even when TLSv1.0\n * (version 3.1) was announced in the client hello. Normally this is\n * forbidden to prevent version rollback attacks.\n */\n# define SSL_OP_TLS_ROLLBACK_BUG                         0x00800000L\n\n# define SSL_OP_NO_SSLv2                                 0x01000000L\n# define SSL_OP_NO_SSLv3                                 0x02000000L\n# define SSL_OP_NO_TLSv1                                 0x04000000L\n# define SSL_OP_NO_TLSv1_2                               0x08000000L\n# define SSL_OP_NO_TLSv1_1                               0x10000000L\n\n# define SSL_OP_NO_DTLSv1                                0x04000000L\n# define SSL_OP_NO_DTLSv1_2                              0x08000000L\n\n# define SSL_OP_NO_SSL_MASK (SSL_OP_NO_SSLv2|SSL_OP_NO_SSLv3|\\\n        SSL_OP_NO_TLSv1|SSL_OP_NO_TLSv1_1|SSL_OP_NO_TLSv1_2)\n\n/*\n * These next two were never actually used for anything since SSLeay zap so\n * we have some more flags.\n */\n/*\n * The next flag deliberately changes the ciphertest, this is a check for the\n * PKCS#1 attack\n */\n# define SSL_OP_PKCS1_CHECK_1                            0x0\n# define SSL_OP_PKCS1_CHECK_2                            0x0\n\n# define SSL_OP_NETSCAPE_CA_DN_BUG                       0x20000000L\n# define SSL_OP_NETSCAPE_DEMO_CIPHER_CHANGE_BUG          0x40000000L\n/*\n * Make server add server-hello extension from early version of cryptopro\n * draft, when GOST ciphersuite is negotiated. Required for interoperability\n * with CryptoPro CSP 3.x\n */\n# define SSL_OP_CRYPTOPRO_TLSEXT_BUG                     0x80000000L\n\n/*\n * Allow SSL_write(..., n) to return r with 0 < r < n (i.e. report success\n * when just a single record has been written):\n */\n# define SSL_MODE_ENABLE_PARTIAL_WRITE       0x00000001L\n/*\n * Make it possible to retry SSL_write() with changed buffer location (buffer\n * contents must stay the same!); this is not the default to avoid the\n * misconception that non-blocking SSL_write() behaves like non-blocking\n * write():\n */\n# define SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER 0x00000002L\n/*\n * Never bother the application with retries if the transport is blocking:\n */\n# define SSL_MODE_AUTO_RETRY 0x00000004L\n/* Don't attempt to automatically build certificate chain */\n# define SSL_MODE_NO_AUTO_CHAIN 0x00000008L\n/*\n * Save RAM by releasing read and write buffers when they're empty. (SSL3 and\n * TLS only.) \"Released\" buffers are put onto a free-list in the context or\n * just freed (depending on the context's setting for freelist_max_len).\n */\n# define SSL_MODE_RELEASE_BUFFERS 0x00000010L\n/*\n * Send the current time in the Random fields of the ClientHello and\n * ServerHello records for compatibility with hypothetical implementations\n * that require it.\n */\n# define SSL_MODE_SEND_CLIENTHELLO_TIME 0x00000020L\n# define SSL_MODE_SEND_SERVERHELLO_TIME 0x00000040L\n/*\n * Send TLS_FALLBACK_SCSV in the ClientHello. To be set only by applications\n * that reconnect with a downgraded protocol version; see\n * draft-ietf-tls-downgrade-scsv-00 for details. DO NOT ENABLE THIS if your\n * application attempts a normal handshake. Only use this in explicit\n * fallback retries, following the guidance in\n * draft-ietf-tls-downgrade-scsv-00.\n */\n# define SSL_MODE_SEND_FALLBACK_SCSV 0x00000080L\n\n/* Cert related flags */\n/*\n * Many implementations ignore some aspects of the TLS standards such as\n * enforcing certifcate chain algorithms. When this is set we enforce them.\n */\n# define SSL_CERT_FLAG_TLS_STRICT                0x00000001L\n\n/* Suite B modes, takes same values as certificate verify flags */\n# define SSL_CERT_FLAG_SUITEB_128_LOS_ONLY       0x10000\n/* Suite B 192 bit only mode */\n# define SSL_CERT_FLAG_SUITEB_192_LOS            0x20000\n/* Suite B 128 bit mode allowing 192 bit algorithms */\n# define SSL_CERT_FLAG_SUITEB_128_LOS            0x30000\n\n/* Perform all sorts of protocol violations for testing purposes */\n# define SSL_CERT_FLAG_BROKEN_PROTOCOL           0x10000000\n\n/* Flags for building certificate chains */\n/* Treat any existing certificates as untrusted CAs */\n# define SSL_BUILD_CHAIN_FLAG_UNTRUSTED          0x1\n/* Don't include root CA in chain */\n# define SSL_BUILD_CHAIN_FLAG_NO_ROOT            0x2\n/* Just check certificates already there */\n# define SSL_BUILD_CHAIN_FLAG_CHECK              0x4\n/* Ignore verification errors */\n# define SSL_BUILD_CHAIN_FLAG_IGNORE_ERROR       0x8\n/* Clear verification errors from queue */\n# define SSL_BUILD_CHAIN_FLAG_CLEAR_ERROR        0x10\n\n/* Flags returned by SSL_check_chain */\n/* Certificate can be used with this session */\n# define CERT_PKEY_VALID         0x1\n/* Certificate can also be used for signing */\n# define CERT_PKEY_SIGN          0x2\n/* EE certificate signing algorithm OK */\n# define CERT_PKEY_EE_SIGNATURE  0x10\n/* CA signature algorithms OK */\n# define CERT_PKEY_CA_SIGNATURE  0x20\n/* EE certificate parameters OK */\n# define CERT_PKEY_EE_PARAM      0x40\n/* CA certificate parameters OK */\n# define CERT_PKEY_CA_PARAM      0x80\n/* Signing explicitly allowed as opposed to SHA1 fallback */\n# define CERT_PKEY_EXPLICIT_SIGN 0x100\n/* Client CA issuer names match (always set for server cert) */\n# define CERT_PKEY_ISSUER_NAME   0x200\n/* Cert type matches client types (always set for server cert) */\n# define CERT_PKEY_CERT_TYPE     0x400\n/* Cert chain suitable to Suite B */\n# define CERT_PKEY_SUITEB        0x800\n\n# define SSL_CONF_FLAG_CMDLINE           0x1\n# define SSL_CONF_FLAG_FILE              0x2\n# define SSL_CONF_FLAG_CLIENT            0x4\n# define SSL_CONF_FLAG_SERVER            0x8\n# define SSL_CONF_FLAG_SHOW_ERRORS       0x10\n# define SSL_CONF_FLAG_CERTIFICATE       0x20\n/* Configuration value types */\n# define SSL_CONF_TYPE_UNKNOWN           0x0\n# define SSL_CONF_TYPE_STRING            0x1\n# define SSL_CONF_TYPE_FILE              0x2\n# define SSL_CONF_TYPE_DIR               0x3\n\n/*\n * Note: SSL[_CTX]_set_{options,mode} use |= op on the previous value, they\n * cannot be used to clear bits.\n */\n\n# define SSL_CTX_set_options(ctx,op) \\\n        SSL_CTX_ctrl((ctx),SSL_CTRL_OPTIONS,(op),NULL)\n# define SSL_CTX_clear_options(ctx,op) \\\n        SSL_CTX_ctrl((ctx),SSL_CTRL_CLEAR_OPTIONS,(op),NULL)\n# define SSL_CTX_get_options(ctx) \\\n        SSL_CTX_ctrl((ctx),SSL_CTRL_OPTIONS,0,NULL)\n# define SSL_set_options(ssl,op) \\\n        SSL_ctrl((ssl),SSL_CTRL_OPTIONS,(op),NULL)\n# define SSL_clear_options(ssl,op) \\\n        SSL_ctrl((ssl),SSL_CTRL_CLEAR_OPTIONS,(op),NULL)\n# define SSL_get_options(ssl) \\\n        SSL_ctrl((ssl),SSL_CTRL_OPTIONS,0,NULL)\n\n# define SSL_CTX_set_mode(ctx,op) \\\n        SSL_CTX_ctrl((ctx),SSL_CTRL_MODE,(op),NULL)\n# define SSL_CTX_clear_mode(ctx,op) \\\n        SSL_CTX_ctrl((ctx),SSL_CTRL_CLEAR_MODE,(op),NULL)\n# define SSL_CTX_get_mode(ctx) \\\n        SSL_CTX_ctrl((ctx),SSL_CTRL_MODE,0,NULL)\n# define SSL_clear_mode(ssl,op) \\\n        SSL_ctrl((ssl),SSL_CTRL_CLEAR_MODE,(op),NULL)\n# define SSL_set_mode(ssl,op) \\\n        SSL_ctrl((ssl),SSL_CTRL_MODE,(op),NULL)\n# define SSL_get_mode(ssl) \\\n        SSL_ctrl((ssl),SSL_CTRL_MODE,0,NULL)\n# define SSL_set_mtu(ssl, mtu) \\\n        SSL_ctrl((ssl),SSL_CTRL_SET_MTU,(mtu),NULL)\n# define DTLS_set_link_mtu(ssl, mtu) \\\n        SSL_ctrl((ssl),DTLS_CTRL_SET_LINK_MTU,(mtu),NULL)\n# define DTLS_get_link_min_mtu(ssl) \\\n        SSL_ctrl((ssl),DTLS_CTRL_GET_LINK_MIN_MTU,0,NULL)\n\n# define SSL_get_secure_renegotiation_support(ssl) \\\n        SSL_ctrl((ssl), SSL_CTRL_GET_RI_SUPPORT, 0, NULL)\n\n# ifndef OPENSSL_NO_HEARTBEATS\n#  define SSL_heartbeat(ssl) \\\n        SSL_ctrl((ssl),SSL_CTRL_TLS_EXT_SEND_HEARTBEAT,0,NULL)\n# endif\n\n# define SSL_CTX_set_cert_flags(ctx,op) \\\n        SSL_CTX_ctrl((ctx),SSL_CTRL_CERT_FLAGS,(op),NULL)\n# define SSL_set_cert_flags(s,op) \\\n        SSL_ctrl((s),SSL_CTRL_CERT_FLAGS,(op),NULL)\n# define SSL_CTX_clear_cert_flags(ctx,op) \\\n        SSL_CTX_ctrl((ctx),SSL_CTRL_CLEAR_CERT_FLAGS,(op),NULL)\n# define SSL_clear_cert_flags(s,op) \\\n        SSL_ctrl((s),SSL_CTRL_CLEAR_CERT_FLAGS,(op),NULL)\n\nvoid SSL_CTX_set_msg_callback(SSL_CTX *ctx,\n                              void (*cb) (int write_p, int version,\n                                          int content_type, const void *buf,\n                                          size_t len, SSL *ssl, void *arg));\nvoid SSL_set_msg_callback(SSL *ssl,\n                          void (*cb) (int write_p, int version,\n                                      int content_type, const void *buf,\n                                      size_t len, SSL *ssl, void *arg));\n# define SSL_CTX_set_msg_callback_arg(ctx, arg) SSL_CTX_ctrl((ctx), SSL_CTRL_SET_MSG_CALLBACK_ARG, 0, (arg))\n# define SSL_set_msg_callback_arg(ssl, arg) SSL_ctrl((ssl), SSL_CTRL_SET_MSG_CALLBACK_ARG, 0, (arg))\n\n# ifndef OPENSSL_NO_SRP\n\n#  ifndef OPENSSL_NO_SSL_INTERN\n\ntypedef struct srp_ctx_st {\n    /* param for all the callbacks */\n    void *SRP_cb_arg;\n    /* set client Hello login callback */\n    int (*TLS_ext_srp_username_callback) (SSL *, int *, void *);\n    /* set SRP N/g param callback for verification */\n    int (*SRP_verify_param_callback) (SSL *, void *);\n    /* set SRP client passwd callback */\n    char *(*SRP_give_srp_client_pwd_callback) (SSL *, void *);\n    char *login;\n    BIGNUM *N, *g, *s, *B, *A;\n    BIGNUM *a, *b, *v;\n    char *info;\n    int strength;\n    unsigned long srp_Mask;\n} SRP_CTX;\n\n#  endif\n\n/* see tls_srp.c */\nint SSL_SRP_CTX_init(SSL *s);\nint SSL_CTX_SRP_CTX_init(SSL_CTX *ctx);\nint SSL_SRP_CTX_free(SSL *ctx);\nint SSL_CTX_SRP_CTX_free(SSL_CTX *ctx);\nint SSL_srp_server_param_with_username(SSL *s, int *ad);\nint SRP_generate_server_master_secret(SSL *s, unsigned char *master_key);\nint SRP_Calc_A_param(SSL *s);\nint SRP_generate_client_master_secret(SSL *s, unsigned char *master_key);\n\n# endif\n\n# if defined(OPENSSL_SYS_MSDOS) && !defined(OPENSSL_SYS_WIN32)\n#  define SSL_MAX_CERT_LIST_DEFAULT 1024*30\n                                          /* 30k max cert list :-) */\n# else\n#  define SSL_MAX_CERT_LIST_DEFAULT 1024*100\n                                           /* 100k max cert list :-) */\n# endif\n\n# define SSL_SESSION_CACHE_MAX_SIZE_DEFAULT      (1024*20)\n\n/*\n * This callback type is used inside SSL_CTX, SSL, and in the functions that\n * set them. It is used to override the generation of SSL/TLS session IDs in\n * a server. Return value should be zero on an error, non-zero to proceed.\n * Also, callbacks should themselves check if the id they generate is unique\n * otherwise the SSL handshake will fail with an error - callbacks can do\n * this using the 'ssl' value they're passed by;\n * SSL_has_matching_session_id(ssl, id, *id_len) The length value passed in\n * is set at the maximum size the session ID can be. In SSLv2 this is 16\n * bytes, whereas SSLv3/TLSv1 it is 32 bytes. The callback can alter this\n * length to be less if desired, but under SSLv2 session IDs are supposed to\n * be fixed at 16 bytes so the id will be padded after the callback returns\n * in this case. It is also an error for the callback to set the size to\n * zero.\n */\ntypedef int (*GEN_SESSION_CB) (const SSL *ssl, unsigned char *id,\n                               unsigned int *id_len);\n\ntypedef struct ssl_comp_st SSL_COMP;\n\n# ifndef OPENSSL_NO_SSL_INTERN\n\nstruct ssl_comp_st {\n    int id;\n    const char *name;\n#  ifndef OPENSSL_NO_COMP\n    COMP_METHOD *method;\n#  else\n    char *method;\n#  endif\n};\n\nDECLARE_STACK_OF(SSL_COMP)\nDECLARE_LHASH_OF(SSL_SESSION);\n\nstruct ssl_ctx_st {\n    const SSL_METHOD *method;\n    STACK_OF(SSL_CIPHER) *cipher_list;\n    /* same as above but sorted for lookup */\n    STACK_OF(SSL_CIPHER) *cipher_list_by_id;\n    struct x509_store_st /* X509_STORE */ *cert_store;\n    LHASH_OF(SSL_SESSION) *sessions;\n    /*\n     * Most session-ids that will be cached, default is\n     * SSL_SESSION_CACHE_MAX_SIZE_DEFAULT. 0 is unlimited.\n     */\n    unsigned long session_cache_size;\n    struct ssl_session_st *session_cache_head;\n    struct ssl_session_st *session_cache_tail;\n    /*\n     * This can have one of 2 values, ored together, SSL_SESS_CACHE_CLIENT,\n     * SSL_SESS_CACHE_SERVER, Default is SSL_SESSION_CACHE_SERVER, which\n     * means only SSL_accept which cache SSL_SESSIONS.\n     */\n    int session_cache_mode;\n    /*\n     * If timeout is not 0, it is the default timeout value set when\n     * SSL_new() is called.  This has been put in to make life easier to set\n     * things up\n     */\n    long session_timeout;\n    /*\n     * If this callback is not null, it will be called each time a session id\n     * is added to the cache.  If this function returns 1, it means that the\n     * callback will do a SSL_SESSION_free() when it has finished using it.\n     * Otherwise, on 0, it means the callback has finished with it. If\n     * remove_session_cb is not null, it will be called when a session-id is\n     * removed from the cache.  After the call, OpenSSL will\n     * SSL_SESSION_free() it.\n     */\n    int (*new_session_cb) (struct ssl_st *ssl, SSL_SESSION *sess);\n    void (*remove_session_cb) (struct ssl_ctx_st *ctx, SSL_SESSION *sess);\n    SSL_SESSION *(*get_session_cb) (struct ssl_st *ssl,\n                                    unsigned char *data, int len, int *copy);\n    struct {\n        int sess_connect;       /* SSL new conn - started */\n        int sess_connect_renegotiate; /* SSL reneg - requested */\n        int sess_connect_good;  /* SSL new conne/reneg - finished */\n        int sess_accept;        /* SSL new accept - started */\n        int sess_accept_renegotiate; /* SSL reneg - requested */\n        int sess_accept_good;   /* SSL accept/reneg - finished */\n        int sess_miss;          /* session lookup misses */\n        int sess_timeout;       /* reuse attempt on timeouted session */\n        int sess_cache_full;    /* session removed due to full cache */\n        int sess_hit;           /* session reuse actually done */\n        int sess_cb_hit;        /* session-id that was not in the cache was\n                                 * passed back via the callback.  This\n                                 * indicates that the application is\n                                 * supplying session-id's from other\n                                 * processes - spooky :-) */\n    } stats;\n\n    int references;\n\n    /* if defined, these override the X509_verify_cert() calls */\n    int (*app_verify_callback) (X509_STORE_CTX *, void *);\n    void *app_verify_arg;\n    /*\n     * before OpenSSL 0.9.7, 'app_verify_arg' was ignored\n     * ('app_verify_callback' was called with just one argument)\n     */\n\n    /* Default password callback. */\n    pem_password_cb *default_passwd_callback;\n\n    /* Default password callback user data. */\n    void *default_passwd_callback_userdata;\n\n    /* get client cert callback */\n    int (*client_cert_cb) (SSL *ssl, X509 **x509, EVP_PKEY **pkey);\n\n    /* cookie generate callback */\n    int (*app_gen_cookie_cb) (SSL *ssl, unsigned char *cookie,\n                              unsigned int *cookie_len);\n\n    /* verify cookie callback */\n    int (*app_verify_cookie_cb) (SSL *ssl, unsigned char *cookie,\n                                 unsigned int cookie_len);\n\n    CRYPTO_EX_DATA ex_data;\n\n    const EVP_MD *rsa_md5;      /* For SSLv2 - name is 'ssl2-md5' */\n    const EVP_MD *md5;          /* For SSLv3/TLSv1 'ssl3-md5' */\n    const EVP_MD *sha1;         /* For SSLv3/TLSv1 'ssl3->sha1' */\n\n    STACK_OF(X509) *extra_certs;\n    STACK_OF(SSL_COMP) *comp_methods; /* stack of SSL_COMP, SSLv3/TLSv1 */\n\n    /* Default values used when no per-SSL value is defined follow */\n\n    /* used if SSL's info_callback is NULL */\n    void (*info_callback) (const SSL *ssl, int type, int val);\n\n    /* what we put in client cert requests */\n    STACK_OF(X509_NAME) *client_CA;\n\n    /*\n     * Default values to use in SSL structures follow (these are copied by\n     * SSL_new)\n     */\n\n    unsigned long options;\n    unsigned long mode;\n    long max_cert_list;\n\n    struct cert_st /* CERT */ *cert;\n    int read_ahead;\n\n    /* callback that allows applications to peek at protocol messages */\n    void (*msg_callback) (int write_p, int version, int content_type,\n                          const void *buf, size_t len, SSL *ssl, void *arg);\n    void *msg_callback_arg;\n\n    int verify_mode;\n    unsigned int sid_ctx_length;\n    unsigned char sid_ctx[SSL_MAX_SID_CTX_LENGTH];\n    /* called 'verify_callback' in the SSL */\n    int (*default_verify_callback) (int ok, X509_STORE_CTX *ctx);\n\n    /* Default generate session ID callback. */\n    GEN_SESSION_CB generate_session_id;\n\n    X509_VERIFY_PARAM *param;\n\n#  if 0\n    int purpose;                /* Purpose setting */\n    int trust;                  /* Trust setting */\n#  endif\n\n    int quiet_shutdown;\n\n    /*\n     * Maximum amount of data to send in one fragment. actual record size can\n     * be more than this due to padding and MAC overheads.\n     */\n    unsigned int max_send_fragment;\n\n#  ifndef OPENSSL_NO_ENGINE\n    /*\n     * Engine to pass requests for client certs to\n     */\n    ENGINE *client_cert_engine;\n#  endif\n\n#  ifndef OPENSSL_NO_TLSEXT\n    /* TLS extensions servername callback */\n    int (*tlsext_servername_callback) (SSL *, int *, void *);\n    void *tlsext_servername_arg;\n    /* RFC 4507 session ticket keys */\n    unsigned char tlsext_tick_key_name[16];\n    unsigned char tlsext_tick_hmac_key[16];\n    unsigned char tlsext_tick_aes_key[16];\n    /* Callback to support customisation of ticket key setting */\n    int (*tlsext_ticket_key_cb) (SSL *ssl,\n                                 unsigned char *name, unsigned char *iv,\n                                 EVP_CIPHER_CTX *ectx,\n                                 HMAC_CTX *hctx, int enc);\n\n    /* certificate status request info */\n    /* Callback for status request */\n    int (*tlsext_status_cb) (SSL *ssl, void *arg);\n    void *tlsext_status_arg;\n\n    /* draft-rescorla-tls-opaque-prf-input-00.txt information */\n    int (*tlsext_opaque_prf_input_callback) (SSL *, void *peerinput,\n                                             size_t len, void *arg);\n    void *tlsext_opaque_prf_input_callback_arg;\n#  endif\n\n#  ifndef OPENSSL_NO_PSK\n    char *psk_identity_hint;\n    unsigned int (*psk_client_callback) (SSL *ssl, const char *hint,\n                                         char *identity,\n                                         unsigned int max_identity_len,\n                                         unsigned char *psk,\n                                         unsigned int max_psk_len);\n    unsigned int (*psk_server_callback) (SSL *ssl, const char *identity,\n                                         unsigned char *psk,\n                                         unsigned int max_psk_len);\n#  endif\n\n#  ifndef OPENSSL_NO_BUF_FREELISTS\n#   define SSL_MAX_BUF_FREELIST_LEN_DEFAULT 32\n    unsigned int freelist_max_len;\n    struct ssl3_buf_freelist_st *wbuf_freelist;\n    struct ssl3_buf_freelist_st *rbuf_freelist;\n#  endif\n#  ifndef OPENSSL_NO_SRP\n    SRP_CTX srp_ctx;            /* ctx for SRP authentication */\n#  endif\n\n#  ifndef OPENSSL_NO_TLSEXT\n\n#   ifndef OPENSSL_NO_NEXTPROTONEG\n    /* Next protocol negotiation information */\n    /* (for experimental NPN extension). */\n\n    /*\n     * For a server, this contains a callback function by which the set of\n     * advertised protocols can be provided.\n     */\n    int (*next_protos_advertised_cb) (SSL *s, const unsigned char **buf,\n                                      unsigned int *len, void *arg);\n    void *next_protos_advertised_cb_arg;\n    /*\n     * For a client, this contains a callback function that selects the next\n     * protocol from the list provided by the server.\n     */\n    int (*next_proto_select_cb) (SSL *s, unsigned char **out,\n                                 unsigned char *outlen,\n                                 const unsigned char *in,\n                                 unsigned int inlen, void *arg);\n    void *next_proto_select_cb_arg;\n#   endif\n    /* SRTP profiles we are willing to do from RFC 5764 */\n    STACK_OF(SRTP_PROTECTION_PROFILE) *srtp_profiles;\n\n    /*\n     * ALPN information (we are in the process of transitioning from NPN to\n     * ALPN.)\n     */\n\n    /*-\n     * For a server, this contains a callback function that allows the\n     * server to select the protocol for the connection.\n     *   out: on successful return, this must point to the raw protocol\n     *        name (without the length prefix).\n     *   outlen: on successful return, this contains the length of |*out|.\n     *   in: points to the client's list of supported protocols in\n     *       wire-format.\n     *   inlen: the length of |in|.\n     */\n    int (*alpn_select_cb) (SSL *s,\n                           const unsigned char **out,\n                           unsigned char *outlen,\n                           const unsigned char *in,\n                           unsigned int inlen, void *arg);\n    void *alpn_select_cb_arg;\n\n    /*\n     * For a client, this contains the list of supported protocols in wire\n     * format.\n     */\n    unsigned char *alpn_client_proto_list;\n    unsigned alpn_client_proto_list_len;\n\n#   ifndef OPENSSL_NO_EC\n    /* EC extension values inherited by SSL structure */\n    size_t tlsext_ecpointformatlist_length;\n    unsigned char *tlsext_ecpointformatlist;\n    size_t tlsext_ellipticcurvelist_length;\n    unsigned char *tlsext_ellipticcurvelist;\n#   endif                       /* OPENSSL_NO_EC */\n#  endif\n};\n\n# endif\n\n# define SSL_SESS_CACHE_OFF                      0x0000\n# define SSL_SESS_CACHE_CLIENT                   0x0001\n# define SSL_SESS_CACHE_SERVER                   0x0002\n# define SSL_SESS_CACHE_BOTH     (SSL_SESS_CACHE_CLIENT|SSL_SESS_CACHE_SERVER)\n# define SSL_SESS_CACHE_NO_AUTO_CLEAR            0x0080\n/* enough comments already ... see SSL_CTX_set_session_cache_mode(3) */\n# define SSL_SESS_CACHE_NO_INTERNAL_LOOKUP       0x0100\n# define SSL_SESS_CACHE_NO_INTERNAL_STORE        0x0200\n# define SSL_SESS_CACHE_NO_INTERNAL \\\n        (SSL_SESS_CACHE_NO_INTERNAL_LOOKUP|SSL_SESS_CACHE_NO_INTERNAL_STORE)\n\nLHASH_OF(SSL_SESSION) *SSL_CTX_sessions(SSL_CTX *ctx);\n# define SSL_CTX_sess_number(ctx) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_SESS_NUMBER,0,NULL)\n# define SSL_CTX_sess_connect(ctx) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_SESS_CONNECT,0,NULL)\n# define SSL_CTX_sess_connect_good(ctx) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_SESS_CONNECT_GOOD,0,NULL)\n# define SSL_CTX_sess_connect_renegotiate(ctx) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_SESS_CONNECT_RENEGOTIATE,0,NULL)\n# define SSL_CTX_sess_accept(ctx) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_SESS_ACCEPT,0,NULL)\n# define SSL_CTX_sess_accept_renegotiate(ctx) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_SESS_ACCEPT_RENEGOTIATE,0,NULL)\n# define SSL_CTX_sess_accept_good(ctx) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_SESS_ACCEPT_GOOD,0,NULL)\n# define SSL_CTX_sess_hits(ctx) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_SESS_HIT,0,NULL)\n# define SSL_CTX_sess_cb_hits(ctx) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_SESS_CB_HIT,0,NULL)\n# define SSL_CTX_sess_misses(ctx) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_SESS_MISSES,0,NULL)\n# define SSL_CTX_sess_timeouts(ctx) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_SESS_TIMEOUTS,0,NULL)\n# define SSL_CTX_sess_cache_full(ctx) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_SESS_CACHE_FULL,0,NULL)\n\nvoid SSL_CTX_sess_set_new_cb(SSL_CTX *ctx,\n                             int (*new_session_cb) (struct ssl_st *ssl,\n                                                    SSL_SESSION *sess));\nint (*SSL_CTX_sess_get_new_cb(SSL_CTX *ctx)) (struct ssl_st *ssl,\n                                              SSL_SESSION *sess);\nvoid SSL_CTX_sess_set_remove_cb(SSL_CTX *ctx,\n                                void (*remove_session_cb) (struct ssl_ctx_st\n                                                           *ctx,\n                                                           SSL_SESSION\n                                                           *sess));\nvoid (*SSL_CTX_sess_get_remove_cb(SSL_CTX *ctx)) (struct ssl_ctx_st *ctx,\n                                                  SSL_SESSION *sess);\nvoid SSL_CTX_sess_set_get_cb(SSL_CTX *ctx,\n                             SSL_SESSION *(*get_session_cb) (struct ssl_st\n                                                             *ssl,\n                                                             unsigned char\n                                                             *data, int len,\n                                                             int *copy));\nSSL_SESSION *(*SSL_CTX_sess_get_get_cb(SSL_CTX *ctx)) (struct ssl_st *ssl,\n                                                       unsigned char *Data,\n                                                       int len, int *copy);\nvoid SSL_CTX_set_info_callback(SSL_CTX *ctx,\n                               void (*cb) (const SSL *ssl, int type,\n                                           int val));\nvoid (*SSL_CTX_get_info_callback(SSL_CTX *ctx)) (const SSL *ssl, int type,\n                                                 int val);\nvoid SSL_CTX_set_client_cert_cb(SSL_CTX *ctx,\n                                int (*client_cert_cb) (SSL *ssl, X509 **x509,\n                                                       EVP_PKEY **pkey));\nint (*SSL_CTX_get_client_cert_cb(SSL_CTX *ctx)) (SSL *ssl, X509 **x509,\n                                                 EVP_PKEY **pkey);\n# ifndef OPENSSL_NO_ENGINE\nint SSL_CTX_set_client_cert_engine(SSL_CTX *ctx, ENGINE *e);\n# endif\nvoid SSL_CTX_set_cookie_generate_cb(SSL_CTX *ctx,\n                                    int (*app_gen_cookie_cb) (SSL *ssl,\n                                                              unsigned char\n                                                              *cookie,\n                                                              unsigned int\n                                                              *cookie_len));\nvoid SSL_CTX_set_cookie_verify_cb(SSL_CTX *ctx,\n                                  int (*app_verify_cookie_cb) (SSL *ssl,\n                                                               unsigned char\n                                                               *cookie,\n                                                               unsigned int\n                                                               cookie_len));\n# ifndef OPENSSL_NO_NEXTPROTONEG\nvoid SSL_CTX_set_next_protos_advertised_cb(SSL_CTX *s,\n                                           int (*cb) (SSL *ssl,\n                                                      const unsigned char\n                                                      **out,\n                                                      unsigned int *outlen,\n                                                      void *arg), void *arg);\nvoid SSL_CTX_set_next_proto_select_cb(SSL_CTX *s,\n                                      int (*cb) (SSL *ssl,\n                                                 unsigned char **out,\n                                                 unsigned char *outlen,\n                                                 const unsigned char *in,\n                                                 unsigned int inlen,\n                                                 void *arg), void *arg);\nvoid SSL_get0_next_proto_negotiated(const SSL *s, const unsigned char **data,\n                                    unsigned *len);\n# endif\n\n# ifndef OPENSSL_NO_TLSEXT\nint SSL_select_next_proto(unsigned char **out, unsigned char *outlen,\n                          const unsigned char *in, unsigned int inlen,\n                          const unsigned char *client,\n                          unsigned int client_len);\n# endif\n\n# define OPENSSL_NPN_UNSUPPORTED 0\n# define OPENSSL_NPN_NEGOTIATED  1\n# define OPENSSL_NPN_NO_OVERLAP  2\n\nint SSL_CTX_set_alpn_protos(SSL_CTX *ctx, const unsigned char *protos,\n                            unsigned protos_len);\nint SSL_set_alpn_protos(SSL *ssl, const unsigned char *protos,\n                        unsigned protos_len);\nvoid SSL_CTX_set_alpn_select_cb(SSL_CTX *ctx,\n                                int (*cb) (SSL *ssl,\n                                           const unsigned char **out,\n                                           unsigned char *outlen,\n                                           const unsigned char *in,\n                                           unsigned int inlen,\n                                           void *arg), void *arg);\nvoid SSL_get0_alpn_selected(const SSL *ssl, const unsigned char **data,\n                            unsigned *len);\n\n# ifndef OPENSSL_NO_PSK\n/*\n * the maximum length of the buffer given to callbacks containing the\n * resulting identity/psk\n */\n#  define PSK_MAX_IDENTITY_LEN 128\n#  define PSK_MAX_PSK_LEN 256\nvoid SSL_CTX_set_psk_client_callback(SSL_CTX *ctx,\n                                     unsigned int (*psk_client_callback) (SSL\n                                                                          *ssl,\n                                                                          const\n                                                                          char\n                                                                          *hint,\n                                                                          char\n                                                                          *identity,\n                                                                          unsigned\n                                                                          int\n                                                                          max_identity_len,\n                                                                          unsigned\n                                                                          char\n                                                                          *psk,\n                                                                          unsigned\n                                                                          int\n                                                                          max_psk_len));\nvoid SSL_set_psk_client_callback(SSL *ssl,\n                                 unsigned int (*psk_client_callback) (SSL\n                                                                      *ssl,\n                                                                      const\n                                                                      char\n                                                                      *hint,\n                                                                      char\n                                                                      *identity,\n                                                                      unsigned\n                                                                      int\n                                                                      max_identity_len,\n                                                                      unsigned\n                                                                      char\n                                                                      *psk,\n                                                                      unsigned\n                                                                      int\n                                                                      max_psk_len));\nvoid SSL_CTX_set_psk_server_callback(SSL_CTX *ctx,\n                                     unsigned int (*psk_server_callback) (SSL\n                                                                          *ssl,\n                                                                          const\n                                                                          char\n                                                                          *identity,\n                                                                          unsigned\n                                                                          char\n                                                                          *psk,\n                                                                          unsigned\n                                                                          int\n                                                                          max_psk_len));\nvoid SSL_set_psk_server_callback(SSL *ssl,\n                                 unsigned int (*psk_server_callback) (SSL\n                                                                      *ssl,\n                                                                      const\n                                                                      char\n                                                                      *identity,\n                                                                      unsigned\n                                                                      char\n                                                                      *psk,\n                                                                      unsigned\n                                                                      int\n                                                                      max_psk_len));\nint SSL_CTX_use_psk_identity_hint(SSL_CTX *ctx, const char *identity_hint);\nint SSL_use_psk_identity_hint(SSL *s, const char *identity_hint);\nconst char *SSL_get_psk_identity_hint(const SSL *s);\nconst char *SSL_get_psk_identity(const SSL *s);\n# endif\n\n# ifndef OPENSSL_NO_TLSEXT\n/* Register callbacks to handle custom TLS Extensions for client or server. */\n\nint SSL_CTX_add_client_custom_ext(SSL_CTX *ctx, unsigned int ext_type,\n                                  custom_ext_add_cb add_cb,\n                                  custom_ext_free_cb free_cb,\n                                  void *add_arg,\n                                  custom_ext_parse_cb parse_cb,\n                                  void *parse_arg);\n\nint SSL_CTX_add_server_custom_ext(SSL_CTX *ctx, unsigned int ext_type,\n                                  custom_ext_add_cb add_cb,\n                                  custom_ext_free_cb free_cb,\n                                  void *add_arg,\n                                  custom_ext_parse_cb parse_cb,\n                                  void *parse_arg);\n\nint SSL_extension_supported(unsigned int ext_type);\n\n# endif\n\n# define SSL_NOTHING     1\n# define SSL_WRITING     2\n# define SSL_READING     3\n# define SSL_X509_LOOKUP 4\n\n/* These will only be used when doing non-blocking IO */\n# define SSL_want_nothing(s)     (SSL_want(s) == SSL_NOTHING)\n# define SSL_want_read(s)        (SSL_want(s) == SSL_READING)\n# define SSL_want_write(s)       (SSL_want(s) == SSL_WRITING)\n# define SSL_want_x509_lookup(s) (SSL_want(s) == SSL_X509_LOOKUP)\n\n# define SSL_MAC_FLAG_READ_MAC_STREAM 1\n# define SSL_MAC_FLAG_WRITE_MAC_STREAM 2\n\n# ifndef OPENSSL_NO_SSL_INTERN\n\nstruct ssl_st {\n    /*\n     * protocol version (one of SSL2_VERSION, SSL3_VERSION, TLS1_VERSION,\n     * DTLS1_VERSION)\n     */\n    int version;\n    /* SSL_ST_CONNECT or SSL_ST_ACCEPT */\n    int type;\n    /* SSLv3 */\n    const SSL_METHOD *method;\n    /*\n     * There are 2 BIO's even though they are normally both the same.  This\n     * is so data can be read and written to different handlers\n     */\n#  ifndef OPENSSL_NO_BIO\n    /* used by SSL_read */\n    BIO *rbio;\n    /* used by SSL_write */\n    BIO *wbio;\n    /* used during session-id reuse to concatenate messages */\n    BIO *bbio;\n#  else\n    /* used by SSL_read */\n    char *rbio;\n    /* used by SSL_write */\n    char *wbio;\n    char *bbio;\n#  endif\n    /*\n     * This holds a variable that indicates what we were doing when a 0 or -1\n     * is returned.  This is needed for non-blocking IO so we know what\n     * request needs re-doing when in SSL_accept or SSL_connect\n     */\n    int rwstate;\n    /* true when we are actually in SSL_accept() or SSL_connect() */\n    int in_handshake;\n    int (*handshake_func) (SSL *);\n    /*\n     * Imagine that here's a boolean member \"init\" that is switched as soon\n     * as SSL_set_{accept/connect}_state is called for the first time, so\n     * that \"state\" and \"handshake_func\" are properly initialized.  But as\n     * handshake_func is == 0 until then, we use this test instead of an\n     * \"init\" member.\n     */\n    /* are we the server side? - mostly used by SSL_clear */\n    int server;\n    /*\n     * Generate a new session or reuse an old one.\n     * NB: For servers, the 'new' session may actually be a previously\n     * cached session or even the previous session unless\n     * SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION is set\n     */\n    int new_session;\n    /* don't send shutdown packets */\n    int quiet_shutdown;\n    /* we have shut things down, 0x01 sent, 0x02 for received */\n    int shutdown;\n    /* where we are */\n    int state;\n    /* where we are when reading */\n    int rstate;\n    BUF_MEM *init_buf;          /* buffer used during init */\n    void *init_msg;             /* pointer to handshake message body, set by\n                                 * ssl3_get_message() */\n    int init_num;               /* amount read/written */\n    int init_off;               /* amount read/written */\n    /* used internally to point at a raw packet */\n    unsigned char *packet;\n    unsigned int packet_length;\n    struct ssl2_state_st *s2;   /* SSLv2 variables */\n    struct ssl3_state_st *s3;   /* SSLv3 variables */\n    struct dtls1_state_st *d1;  /* DTLSv1 variables */\n    int read_ahead;             /* Read as many input bytes as possible (for\n                                 * non-blocking reads) */\n    /* callback that allows applications to peek at protocol messages */\n    void (*msg_callback) (int write_p, int version, int content_type,\n                          const void *buf, size_t len, SSL *ssl, void *arg);\n    void *msg_callback_arg;\n    int hit;                    /* reusing a previous session */\n    X509_VERIFY_PARAM *param;\n#  if 0\n    int purpose;                /* Purpose setting */\n    int trust;                  /* Trust setting */\n#  endif\n    /* crypto */\n    STACK_OF(SSL_CIPHER) *cipher_list;\n    STACK_OF(SSL_CIPHER) *cipher_list_by_id;\n    /*\n     * These are the ones being used, the ones in SSL_SESSION are the ones to\n     * be 'copied' into these ones\n     */\n    int mac_flags;\n    EVP_CIPHER_CTX *enc_read_ctx; /* cryptographic state */\n    EVP_MD_CTX *read_hash;      /* used for mac generation */\n#  ifndef OPENSSL_NO_COMP\n    COMP_CTX *expand;           /* uncompress */\n#  else\n    char *expand;\n#  endif\n    EVP_CIPHER_CTX *enc_write_ctx; /* cryptographic state */\n    EVP_MD_CTX *write_hash;     /* used for mac generation */\n#  ifndef OPENSSL_NO_COMP\n    COMP_CTX *compress;         /* compression */\n#  else\n    char *compress;\n#  endif\n    /* session info */\n    /* client cert? */\n    /* This is used to hold the server certificate used */\n    struct cert_st /* CERT */ *cert;\n    /*\n     * the session_id_context is used to ensure sessions are only reused in\n     * the appropriate context\n     */\n    unsigned int sid_ctx_length;\n    unsigned char sid_ctx[SSL_MAX_SID_CTX_LENGTH];\n    /* This can also be in the session once a session is established */\n    SSL_SESSION *session;\n    /* Default generate session ID callback. */\n    GEN_SESSION_CB generate_session_id;\n    /* Used in SSL2 and SSL3 */\n    /*\n     * 0 don't care about verify failure.\n     * 1 fail if verify fails\n     */\n    int verify_mode;\n    /* fail if callback returns 0 */\n    int (*verify_callback) (int ok, X509_STORE_CTX *ctx);\n    /* optional informational callback */\n    void (*info_callback) (const SSL *ssl, int type, int val);\n    /* error bytes to be written */\n    int error;\n    /* actual code */\n    int error_code;\n#  ifndef OPENSSL_NO_KRB5\n    /* Kerberos 5 context */\n    KSSL_CTX *kssl_ctx;\n#  endif                        /* OPENSSL_NO_KRB5 */\n#  ifndef OPENSSL_NO_PSK\n    unsigned int (*psk_client_callback) (SSL *ssl, const char *hint,\n                                         char *identity,\n                                         unsigned int max_identity_len,\n                                         unsigned char *psk,\n                                         unsigned int max_psk_len);\n    unsigned int (*psk_server_callback) (SSL *ssl, const char *identity,\n                                         unsigned char *psk,\n                                         unsigned int max_psk_len);\n#  endif\n    SSL_CTX *ctx;\n    /*\n     * set this flag to 1 and a sleep(1) is put into all SSL_read() and\n     * SSL_write() calls, good for nbio debuging :-)\n     */\n    int debug;\n    /* extra application data */\n    long verify_result;\n    CRYPTO_EX_DATA ex_data;\n    /* for server side, keep the list of CA_dn we can use */\n    STACK_OF(X509_NAME) *client_CA;\n    int references;\n    /* protocol behaviour */\n    unsigned long options;\n    /* API behaviour */\n    unsigned long mode;\n    long max_cert_list;\n    int first_packet;\n    /* what was passed, used for SSLv3/TLS rollback check */\n    int client_version;\n    unsigned int max_send_fragment;\n#  ifndef OPENSSL_NO_TLSEXT\n    /* TLS extension debug callback */\n    void (*tlsext_debug_cb) (SSL *s, int client_server, int type,\n                             unsigned char *data, int len, void *arg);\n    void *tlsext_debug_arg;\n    char *tlsext_hostname;\n    /*-\n     * no further mod of servername\n     * 0 : call the servername extension callback.\n     * 1 : prepare 2, allow last ack just after in server callback.\n     * 2 : don't call servername callback, no ack in server hello\n     */\n    int servername_done;\n    /* certificate status request info */\n    /* Status type or -1 if no status type */\n    int tlsext_status_type;\n    /* Expect OCSP CertificateStatus message */\n    int tlsext_status_expected;\n    /* OCSP status request only */\n    STACK_OF(OCSP_RESPID) *tlsext_ocsp_ids;\n    X509_EXTENSIONS *tlsext_ocsp_exts;\n    /* OCSP response received or to be sent */\n    unsigned char *tlsext_ocsp_resp;\n    int tlsext_ocsp_resplen;\n    /* RFC4507 session ticket expected to be received or sent */\n    int tlsext_ticket_expected;\n#   ifndef OPENSSL_NO_EC\n    size_t tlsext_ecpointformatlist_length;\n    /* our list */\n    unsigned char *tlsext_ecpointformatlist;\n    size_t tlsext_ellipticcurvelist_length;\n    /* our list */\n    unsigned char *tlsext_ellipticcurvelist;\n#   endif                       /* OPENSSL_NO_EC */\n    /*\n     * draft-rescorla-tls-opaque-prf-input-00.txt information to be used for\n     * handshakes\n     */\n    void *tlsext_opaque_prf_input;\n    size_t tlsext_opaque_prf_input_len;\n    /* TLS Session Ticket extension override */\n    TLS_SESSION_TICKET_EXT *tlsext_session_ticket;\n    /* TLS Session Ticket extension callback */\n    tls_session_ticket_ext_cb_fn tls_session_ticket_ext_cb;\n    void *tls_session_ticket_ext_cb_arg;\n    /* TLS pre-shared secret session resumption */\n    tls_session_secret_cb_fn tls_session_secret_cb;\n    void *tls_session_secret_cb_arg;\n    SSL_CTX *initial_ctx;       /* initial ctx, used to store sessions */\n#   ifndef OPENSSL_NO_NEXTPROTONEG\n    /*\n     * Next protocol negotiation. For the client, this is the protocol that\n     * we sent in NextProtocol and is set when handling ServerHello\n     * extensions. For a server, this is the client's selected_protocol from\n     * NextProtocol and is set when handling the NextProtocol message, before\n     * the Finished message.\n     */\n    unsigned char *next_proto_negotiated;\n    unsigned char next_proto_negotiated_len;\n#   endif\n#   define session_ctx initial_ctx\n    /* What we'll do */\n    STACK_OF(SRTP_PROTECTION_PROFILE) *srtp_profiles;\n    /* What's been chosen */\n    SRTP_PROTECTION_PROFILE *srtp_profile;\n        /*-\n         * Is use of the Heartbeat extension negotiated?\n         * 0: disabled\n         * 1: enabled\n         * 2: enabled, but not allowed to send Requests\n         */\n    unsigned int tlsext_heartbeat;\n    /* Indicates if a HeartbeatRequest is in flight */\n    unsigned int tlsext_hb_pending;\n    /* HeartbeatRequest sequence number */\n    unsigned int tlsext_hb_seq;\n#  else\n#   define session_ctx ctx\n#  endif                        /* OPENSSL_NO_TLSEXT */\n    /*-\n     * 1 if we are renegotiating.\n     * 2 if we are a server and are inside a handshake\n     * (i.e. not just sending a HelloRequest)\n     */\n    int renegotiate;\n#  ifndef OPENSSL_NO_SRP\n    /* ctx for SRP authentication */\n    SRP_CTX srp_ctx;\n#  endif\n#  ifndef OPENSSL_NO_TLSEXT\n    /*\n     * For a client, this contains the list of supported protocols in wire\n     * format.\n     */\n    unsigned char *alpn_client_proto_list;\n    unsigned alpn_client_proto_list_len;\n#  endif                        /* OPENSSL_NO_TLSEXT */\n};\n\n# endif\n\n#ifdef __cplusplus\n}\n#endif\n\n# include <openssl/ssl2.h>\n# include <openssl/ssl3.h>\n# include <openssl/tls1.h>      /* This is mostly sslv3 with a few tweaks */\n# include <openssl/dtls1.h>     /* Datagram TLS */\n# include <openssl/ssl23.h>\n# include <openssl/srtp.h>      /* Support for the use_srtp extension */\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n/* compatibility */\n# define SSL_set_app_data(s,arg)         (SSL_set_ex_data(s,0,(char *)arg))\n# define SSL_get_app_data(s)             (SSL_get_ex_data(s,0))\n# define SSL_SESSION_set_app_data(s,a)   (SSL_SESSION_set_ex_data(s,0,(char *)a))\n# define SSL_SESSION_get_app_data(s)     (SSL_SESSION_get_ex_data(s,0))\n# define SSL_CTX_get_app_data(ctx)       (SSL_CTX_get_ex_data(ctx,0))\n# define SSL_CTX_set_app_data(ctx,arg)   (SSL_CTX_set_ex_data(ctx,0,(char *)arg))\n\n/*\n * The following are the possible values for ssl->state are are used to\n * indicate where we are up to in the SSL connection establishment. The\n * macros that follow are about the only things you should need to use and\n * even then, only when using non-blocking IO. It can also be useful to work\n * out where you were when the connection failed\n */\n\n# define SSL_ST_CONNECT                  0x1000\n# define SSL_ST_ACCEPT                   0x2000\n# define SSL_ST_MASK                     0x0FFF\n# define SSL_ST_INIT                     (SSL_ST_CONNECT|SSL_ST_ACCEPT)\n# define SSL_ST_BEFORE                   0x4000\n# define SSL_ST_OK                       0x03\n# define SSL_ST_RENEGOTIATE              (0x04|SSL_ST_INIT)\n# define SSL_ST_ERR                      0x05\n\n# define SSL_CB_LOOP                     0x01\n# define SSL_CB_EXIT                     0x02\n# define SSL_CB_READ                     0x04\n# define SSL_CB_WRITE                    0x08\n# define SSL_CB_ALERT                    0x4000/* used in callback */\n# define SSL_CB_READ_ALERT               (SSL_CB_ALERT|SSL_CB_READ)\n# define SSL_CB_WRITE_ALERT              (SSL_CB_ALERT|SSL_CB_WRITE)\n# define SSL_CB_ACCEPT_LOOP              (SSL_ST_ACCEPT|SSL_CB_LOOP)\n# define SSL_CB_ACCEPT_EXIT              (SSL_ST_ACCEPT|SSL_CB_EXIT)\n# define SSL_CB_CONNECT_LOOP             (SSL_ST_CONNECT|SSL_CB_LOOP)\n# define SSL_CB_CONNECT_EXIT             (SSL_ST_CONNECT|SSL_CB_EXIT)\n# define SSL_CB_HANDSHAKE_START          0x10\n# define SSL_CB_HANDSHAKE_DONE           0x20\n\n/* Is the SSL_connection established? */\n# define SSL_get_state(a)                SSL_state(a)\n# define SSL_is_init_finished(a)         (SSL_state(a) == SSL_ST_OK)\n# define SSL_in_init(a)                  (SSL_state(a)&SSL_ST_INIT)\n# define SSL_in_before(a)                (SSL_state(a)&SSL_ST_BEFORE)\n# define SSL_in_connect_init(a)          (SSL_state(a)&SSL_ST_CONNECT)\n# define SSL_in_accept_init(a)           (SSL_state(a)&SSL_ST_ACCEPT)\n\n/*\n * The following 2 states are kept in ssl->rstate when reads fail, you should\n * not need these\n */\n# define SSL_ST_READ_HEADER                      0xF0\n# define SSL_ST_READ_BODY                        0xF1\n# define SSL_ST_READ_DONE                        0xF2\n\n/*-\n * Obtain latest Finished message\n *   -- that we sent (SSL_get_finished)\n *   -- that we expected from peer (SSL_get_peer_finished).\n * Returns length (0 == no Finished so far), copies up to 'count' bytes.\n */\nsize_t SSL_get_finished(const SSL *s, void *buf, size_t count);\nsize_t SSL_get_peer_finished(const SSL *s, void *buf, size_t count);\n\n/*\n * use either SSL_VERIFY_NONE or SSL_VERIFY_PEER, the last 2 options are\n * 'ored' with SSL_VERIFY_PEER if they are desired\n */\n# define SSL_VERIFY_NONE                 0x00\n# define SSL_VERIFY_PEER                 0x01\n# define SSL_VERIFY_FAIL_IF_NO_PEER_CERT 0x02\n# define SSL_VERIFY_CLIENT_ONCE          0x04\n\n# define OpenSSL_add_ssl_algorithms()    SSL_library_init()\n# define SSLeay_add_ssl_algorithms()     SSL_library_init()\n\n/* this is for backward compatibility */\n# if 0                          /* NEW_SSLEAY */\n#  define SSL_CTX_set_default_verify(a,b,c) SSL_CTX_set_verify(a,b,c)\n#  define SSL_set_pref_cipher(c,n)        SSL_set_cipher_list(c,n)\n#  define SSL_add_session(a,b)            SSL_CTX_add_session((a),(b))\n#  define SSL_remove_session(a,b)         SSL_CTX_remove_session((a),(b))\n#  define SSL_flush_sessions(a,b)         SSL_CTX_flush_sessions((a),(b))\n# endif\n/* More backward compatibility */\n# define SSL_get_cipher(s) \\\n                SSL_CIPHER_get_name(SSL_get_current_cipher(s))\n# define SSL_get_cipher_bits(s,np) \\\n                SSL_CIPHER_get_bits(SSL_get_current_cipher(s),np)\n# define SSL_get_cipher_version(s) \\\n                SSL_CIPHER_get_version(SSL_get_current_cipher(s))\n# define SSL_get_cipher_name(s) \\\n                SSL_CIPHER_get_name(SSL_get_current_cipher(s))\n# define SSL_get_time(a)         SSL_SESSION_get_time(a)\n# define SSL_set_time(a,b)       SSL_SESSION_set_time((a),(b))\n# define SSL_get_timeout(a)      SSL_SESSION_get_timeout(a)\n# define SSL_set_timeout(a,b)    SSL_SESSION_set_timeout((a),(b))\n\n# define d2i_SSL_SESSION_bio(bp,s_id) ASN1_d2i_bio_of(SSL_SESSION,SSL_SESSION_new,d2i_SSL_SESSION,bp,s_id)\n# define i2d_SSL_SESSION_bio(bp,s_id) ASN1_i2d_bio_of(SSL_SESSION,i2d_SSL_SESSION,bp,s_id)\n\nDECLARE_PEM_rw(SSL_SESSION, SSL_SESSION)\n# define SSL_AD_REASON_OFFSET            1000/* offset to get SSL_R_... value\n                                              * from SSL_AD_... */\n/* These alert types are for SSLv3 and TLSv1 */\n# define SSL_AD_CLOSE_NOTIFY             SSL3_AD_CLOSE_NOTIFY\n/* fatal */\n# define SSL_AD_UNEXPECTED_MESSAGE       SSL3_AD_UNEXPECTED_MESSAGE\n/* fatal */\n# define SSL_AD_BAD_RECORD_MAC           SSL3_AD_BAD_RECORD_MAC\n# define SSL_AD_DECRYPTION_FAILED        TLS1_AD_DECRYPTION_FAILED\n# define SSL_AD_RECORD_OVERFLOW          TLS1_AD_RECORD_OVERFLOW\n/* fatal */\n# define SSL_AD_DECOMPRESSION_FAILURE    SSL3_AD_DECOMPRESSION_FAILURE\n/* fatal */\n# define SSL_AD_HANDSHAKE_FAILURE        SSL3_AD_HANDSHAKE_FAILURE\n/* Not for TLS */\n# define SSL_AD_NO_CERTIFICATE           SSL3_AD_NO_CERTIFICATE\n# define SSL_AD_BAD_CERTIFICATE          SSL3_AD_BAD_CERTIFICATE\n# define SSL_AD_UNSUPPORTED_CERTIFICATE  SSL3_AD_UNSUPPORTED_CERTIFICATE\n# define SSL_AD_CERTIFICATE_REVOKED      SSL3_AD_CERTIFICATE_REVOKED\n# define SSL_AD_CERTIFICATE_EXPIRED      SSL3_AD_CERTIFICATE_EXPIRED\n# define SSL_AD_CERTIFICATE_UNKNOWN      SSL3_AD_CERTIFICATE_UNKNOWN\n/* fatal */\n# define SSL_AD_ILLEGAL_PARAMETER        SSL3_AD_ILLEGAL_PARAMETER\n/* fatal */\n# define SSL_AD_UNKNOWN_CA               TLS1_AD_UNKNOWN_CA\n/* fatal */\n# define SSL_AD_ACCESS_DENIED            TLS1_AD_ACCESS_DENIED\n/* fatal */\n# define SSL_AD_DECODE_ERROR             TLS1_AD_DECODE_ERROR\n# define SSL_AD_DECRYPT_ERROR            TLS1_AD_DECRYPT_ERROR\n/* fatal */\n# define SSL_AD_EXPORT_RESTRICTION       TLS1_AD_EXPORT_RESTRICTION\n/* fatal */\n# define SSL_AD_PROTOCOL_VERSION         TLS1_AD_PROTOCOL_VERSION\n/* fatal */\n# define SSL_AD_INSUFFICIENT_SECURITY    TLS1_AD_INSUFFICIENT_SECURITY\n/* fatal */\n# define SSL_AD_INTERNAL_ERROR           TLS1_AD_INTERNAL_ERROR\n# define SSL_AD_USER_CANCELLED           TLS1_AD_USER_CANCELLED\n# define SSL_AD_NO_RENEGOTIATION         TLS1_AD_NO_RENEGOTIATION\n# define SSL_AD_UNSUPPORTED_EXTENSION    TLS1_AD_UNSUPPORTED_EXTENSION\n# define SSL_AD_CERTIFICATE_UNOBTAINABLE TLS1_AD_CERTIFICATE_UNOBTAINABLE\n# define SSL_AD_UNRECOGNIZED_NAME        TLS1_AD_UNRECOGNIZED_NAME\n# define SSL_AD_BAD_CERTIFICATE_STATUS_RESPONSE TLS1_AD_BAD_CERTIFICATE_STATUS_RESPONSE\n# define SSL_AD_BAD_CERTIFICATE_HASH_VALUE TLS1_AD_BAD_CERTIFICATE_HASH_VALUE\n/* fatal */\n# define SSL_AD_UNKNOWN_PSK_IDENTITY     TLS1_AD_UNKNOWN_PSK_IDENTITY\n/* fatal */\n# define SSL_AD_INAPPROPRIATE_FALLBACK   TLS1_AD_INAPPROPRIATE_FALLBACK\n# define SSL_ERROR_NONE                  0\n# define SSL_ERROR_SSL                   1\n# define SSL_ERROR_WANT_READ             2\n# define SSL_ERROR_WANT_WRITE            3\n# define SSL_ERROR_WANT_X509_LOOKUP      4\n# define SSL_ERROR_SYSCALL               5/* look at error stack/return\n                                           * value/errno */\n# define SSL_ERROR_ZERO_RETURN           6\n# define SSL_ERROR_WANT_CONNECT          7\n# define SSL_ERROR_WANT_ACCEPT           8\n# define SSL_CTRL_NEED_TMP_RSA                   1\n# define SSL_CTRL_SET_TMP_RSA                    2\n# define SSL_CTRL_SET_TMP_DH                     3\n# define SSL_CTRL_SET_TMP_ECDH                   4\n# define SSL_CTRL_SET_TMP_RSA_CB                 5\n# define SSL_CTRL_SET_TMP_DH_CB                  6\n# define SSL_CTRL_SET_TMP_ECDH_CB                7\n# define SSL_CTRL_GET_SESSION_REUSED             8\n# define SSL_CTRL_GET_CLIENT_CERT_REQUEST        9\n# define SSL_CTRL_GET_NUM_RENEGOTIATIONS         10\n# define SSL_CTRL_CLEAR_NUM_RENEGOTIATIONS       11\n# define SSL_CTRL_GET_TOTAL_RENEGOTIATIONS       12\n# define SSL_CTRL_GET_FLAGS                      13\n# define SSL_CTRL_EXTRA_CHAIN_CERT               14\n# define SSL_CTRL_SET_MSG_CALLBACK               15\n# define SSL_CTRL_SET_MSG_CALLBACK_ARG           16\n/* only applies to datagram connections */\n# define SSL_CTRL_SET_MTU                17\n/* Stats */\n# define SSL_CTRL_SESS_NUMBER                    20\n# define SSL_CTRL_SESS_CONNECT                   21\n# define SSL_CTRL_SESS_CONNECT_GOOD              22\n# define SSL_CTRL_SESS_CONNECT_RENEGOTIATE       23\n# define SSL_CTRL_SESS_ACCEPT                    24\n# define SSL_CTRL_SESS_ACCEPT_GOOD               25\n# define SSL_CTRL_SESS_ACCEPT_RENEGOTIATE        26\n# define SSL_CTRL_SESS_HIT                       27\n# define SSL_CTRL_SESS_CB_HIT                    28\n# define SSL_CTRL_SESS_MISSES                    29\n# define SSL_CTRL_SESS_TIMEOUTS                  30\n# define SSL_CTRL_SESS_CACHE_FULL                31\n# define SSL_CTRL_OPTIONS                        32\n# define SSL_CTRL_MODE                           33\n# define SSL_CTRL_GET_READ_AHEAD                 40\n# define SSL_CTRL_SET_READ_AHEAD                 41\n# define SSL_CTRL_SET_SESS_CACHE_SIZE            42\n# define SSL_CTRL_GET_SESS_CACHE_SIZE            43\n# define SSL_CTRL_SET_SESS_CACHE_MODE            44\n# define SSL_CTRL_GET_SESS_CACHE_MODE            45\n# define SSL_CTRL_GET_MAX_CERT_LIST              50\n# define SSL_CTRL_SET_MAX_CERT_LIST              51\n# define SSL_CTRL_SET_MAX_SEND_FRAGMENT          52\n/* see tls1.h for macros based on these */\n# ifndef OPENSSL_NO_TLSEXT\n#  define SSL_CTRL_SET_TLSEXT_SERVERNAME_CB       53\n#  define SSL_CTRL_SET_TLSEXT_SERVERNAME_ARG      54\n#  define SSL_CTRL_SET_TLSEXT_HOSTNAME            55\n#  define SSL_CTRL_SET_TLSEXT_DEBUG_CB            56\n#  define SSL_CTRL_SET_TLSEXT_DEBUG_ARG           57\n#  define SSL_CTRL_GET_TLSEXT_TICKET_KEYS         58\n#  define SSL_CTRL_SET_TLSEXT_TICKET_KEYS         59\n#  define SSL_CTRL_SET_TLSEXT_OPAQUE_PRF_INPUT    60\n#  define SSL_CTRL_SET_TLSEXT_OPAQUE_PRF_INPUT_CB 61\n#  define SSL_CTRL_SET_TLSEXT_OPAQUE_PRF_INPUT_CB_ARG 62\n#  define SSL_CTRL_SET_TLSEXT_STATUS_REQ_CB       63\n#  define SSL_CTRL_SET_TLSEXT_STATUS_REQ_CB_ARG   64\n#  define SSL_CTRL_SET_TLSEXT_STATUS_REQ_TYPE     65\n#  define SSL_CTRL_GET_TLSEXT_STATUS_REQ_EXTS     66\n#  define SSL_CTRL_SET_TLSEXT_STATUS_REQ_EXTS     67\n#  define SSL_CTRL_GET_TLSEXT_STATUS_REQ_IDS      68\n#  define SSL_CTRL_SET_TLSEXT_STATUS_REQ_IDS      69\n#  define SSL_CTRL_GET_TLSEXT_STATUS_REQ_OCSP_RESP        70\n#  define SSL_CTRL_SET_TLSEXT_STATUS_REQ_OCSP_RESP        71\n#  define SSL_CTRL_SET_TLSEXT_TICKET_KEY_CB       72\n#  define SSL_CTRL_SET_TLS_EXT_SRP_USERNAME_CB    75\n#  define SSL_CTRL_SET_SRP_VERIFY_PARAM_CB                76\n#  define SSL_CTRL_SET_SRP_GIVE_CLIENT_PWD_CB             77\n#  define SSL_CTRL_SET_SRP_ARG            78\n#  define SSL_CTRL_SET_TLS_EXT_SRP_USERNAME               79\n#  define SSL_CTRL_SET_TLS_EXT_SRP_STRENGTH               80\n#  define SSL_CTRL_SET_TLS_EXT_SRP_PASSWORD               81\n#  ifndef OPENSSL_NO_HEARTBEATS\n#   define SSL_CTRL_TLS_EXT_SEND_HEARTBEAT                         85\n#   define SSL_CTRL_GET_TLS_EXT_HEARTBEAT_PENDING          86\n#   define SSL_CTRL_SET_TLS_EXT_HEARTBEAT_NO_REQUESTS      87\n#  endif\n# endif                         /* OPENSSL_NO_TLSEXT */\n# define DTLS_CTRL_GET_TIMEOUT           73\n# define DTLS_CTRL_HANDLE_TIMEOUT        74\n# define DTLS_CTRL_LISTEN                        75\n# define SSL_CTRL_GET_RI_SUPPORT                 76\n# define SSL_CTRL_CLEAR_OPTIONS                  77\n# define SSL_CTRL_CLEAR_MODE                     78\n# define SSL_CTRL_GET_EXTRA_CHAIN_CERTS          82\n# define SSL_CTRL_CLEAR_EXTRA_CHAIN_CERTS        83\n# define SSL_CTRL_CHAIN                          88\n# define SSL_CTRL_CHAIN_CERT                     89\n# define SSL_CTRL_GET_CURVES                     90\n# define SSL_CTRL_SET_CURVES                     91\n# define SSL_CTRL_SET_CURVES_LIST                92\n# define SSL_CTRL_GET_SHARED_CURVE               93\n# define SSL_CTRL_SET_ECDH_AUTO                  94\n# define SSL_CTRL_SET_SIGALGS                    97\n# define SSL_CTRL_SET_SIGALGS_LIST               98\n# define SSL_CTRL_CERT_FLAGS                     99\n# define SSL_CTRL_CLEAR_CERT_FLAGS               100\n# define SSL_CTRL_SET_CLIENT_SIGALGS             101\n# define SSL_CTRL_SET_CLIENT_SIGALGS_LIST        102\n# define SSL_CTRL_GET_CLIENT_CERT_TYPES          103\n# define SSL_CTRL_SET_CLIENT_CERT_TYPES          104\n# define SSL_CTRL_BUILD_CERT_CHAIN               105\n# define SSL_CTRL_SET_VERIFY_CERT_STORE          106\n# define SSL_CTRL_SET_CHAIN_CERT_STORE           107\n# define SSL_CTRL_GET_PEER_SIGNATURE_NID         108\n# define SSL_CTRL_GET_SERVER_TMP_KEY             109\n# define SSL_CTRL_GET_RAW_CIPHERLIST             110\n# define SSL_CTRL_GET_EC_POINT_FORMATS           111\n# define SSL_CTRL_GET_CHAIN_CERTS                115\n# define SSL_CTRL_SELECT_CURRENT_CERT            116\n# define SSL_CTRL_SET_CURRENT_CERT               117\n# define SSL_CTRL_CHECK_PROTO_VERSION            119\n# define DTLS_CTRL_SET_LINK_MTU                  120\n# define DTLS_CTRL_GET_LINK_MIN_MTU              121\n# define SSL_CERT_SET_FIRST                      1\n# define SSL_CERT_SET_NEXT                       2\n# define SSL_CERT_SET_SERVER                     3\n# define DTLSv1_get_timeout(ssl, arg) \\\n        SSL_ctrl(ssl,DTLS_CTRL_GET_TIMEOUT,0, (void *)arg)\n# define DTLSv1_handle_timeout(ssl) \\\n        SSL_ctrl(ssl,DTLS_CTRL_HANDLE_TIMEOUT,0, NULL)\n# define DTLSv1_listen(ssl, peer) \\\n        SSL_ctrl(ssl,DTLS_CTRL_LISTEN,0, (void *)peer)\n# define SSL_session_reused(ssl) \\\n        SSL_ctrl((ssl),SSL_CTRL_GET_SESSION_REUSED,0,NULL)\n# define SSL_num_renegotiations(ssl) \\\n        SSL_ctrl((ssl),SSL_CTRL_GET_NUM_RENEGOTIATIONS,0,NULL)\n# define SSL_clear_num_renegotiations(ssl) \\\n        SSL_ctrl((ssl),SSL_CTRL_CLEAR_NUM_RENEGOTIATIONS,0,NULL)\n# define SSL_total_renegotiations(ssl) \\\n        SSL_ctrl((ssl),SSL_CTRL_GET_TOTAL_RENEGOTIATIONS,0,NULL)\n# define SSL_CTX_need_tmp_RSA(ctx) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_NEED_TMP_RSA,0,NULL)\n# define SSL_CTX_set_tmp_rsa(ctx,rsa) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_SET_TMP_RSA,0,(char *)rsa)\n# define SSL_CTX_set_tmp_dh(ctx,dh) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_SET_TMP_DH,0,(char *)dh)\n# define SSL_CTX_set_tmp_ecdh(ctx,ecdh) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_SET_TMP_ECDH,0,(char *)ecdh)\n# define SSL_need_tmp_RSA(ssl) \\\n        SSL_ctrl(ssl,SSL_CTRL_NEED_TMP_RSA,0,NULL)\n# define SSL_set_tmp_rsa(ssl,rsa) \\\n        SSL_ctrl(ssl,SSL_CTRL_SET_TMP_RSA,0,(char *)rsa)\n# define SSL_set_tmp_dh(ssl,dh) \\\n        SSL_ctrl(ssl,SSL_CTRL_SET_TMP_DH,0,(char *)dh)\n# define SSL_set_tmp_ecdh(ssl,ecdh) \\\n        SSL_ctrl(ssl,SSL_CTRL_SET_TMP_ECDH,0,(char *)ecdh)\n# define SSL_CTX_add_extra_chain_cert(ctx,x509) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_EXTRA_CHAIN_CERT,0,(char *)x509)\n# define SSL_CTX_get_extra_chain_certs(ctx,px509) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_GET_EXTRA_CHAIN_CERTS,0,px509)\n# define SSL_CTX_get_extra_chain_certs_only(ctx,px509) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_GET_EXTRA_CHAIN_CERTS,1,px509)\n# define SSL_CTX_clear_extra_chain_certs(ctx) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_CLEAR_EXTRA_CHAIN_CERTS,0,NULL)\n# define SSL_CTX_set0_chain(ctx,sk) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_CHAIN,0,(char *)sk)\n# define SSL_CTX_set1_chain(ctx,sk) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_CHAIN,1,(char *)sk)\n# define SSL_CTX_add0_chain_cert(ctx,x509) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_CHAIN_CERT,0,(char *)x509)\n# define SSL_CTX_add1_chain_cert(ctx,x509) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_CHAIN_CERT,1,(char *)x509)\n# define SSL_CTX_get0_chain_certs(ctx,px509) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_GET_CHAIN_CERTS,0,px509)\n# define SSL_CTX_clear_chain_certs(ctx) \\\n        SSL_CTX_set0_chain(ctx,NULL)\n# define SSL_CTX_build_cert_chain(ctx, flags) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_BUILD_CERT_CHAIN, flags, NULL)\n# define SSL_CTX_select_current_cert(ctx,x509) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_SELECT_CURRENT_CERT,0,(char *)x509)\n# define SSL_CTX_set_current_cert(ctx, op) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_SET_CURRENT_CERT, op, NULL)\n# define SSL_CTX_set0_verify_cert_store(ctx,st) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_SET_VERIFY_CERT_STORE,0,(char *)st)\n# define SSL_CTX_set1_verify_cert_store(ctx,st) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_SET_VERIFY_CERT_STORE,1,(char *)st)\n# define SSL_CTX_set0_chain_cert_store(ctx,st) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_SET_CHAIN_CERT_STORE,0,(char *)st)\n# define SSL_CTX_set1_chain_cert_store(ctx,st) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_SET_CHAIN_CERT_STORE,1,(char *)st)\n# define SSL_set0_chain(ctx,sk) \\\n        SSL_ctrl(ctx,SSL_CTRL_CHAIN,0,(char *)sk)\n# define SSL_set1_chain(ctx,sk) \\\n        SSL_ctrl(ctx,SSL_CTRL_CHAIN,1,(char *)sk)\n# define SSL_add0_chain_cert(ctx,x509) \\\n        SSL_ctrl(ctx,SSL_CTRL_CHAIN_CERT,0,(char *)x509)\n# define SSL_add1_chain_cert(ctx,x509) \\\n        SSL_ctrl(ctx,SSL_CTRL_CHAIN_CERT,1,(char *)x509)\n# define SSL_get0_chain_certs(ctx,px509) \\\n        SSL_ctrl(ctx,SSL_CTRL_GET_CHAIN_CERTS,0,px509)\n# define SSL_clear_chain_certs(ctx) \\\n        SSL_set0_chain(ctx,NULL)\n# define SSL_build_cert_chain(s, flags) \\\n        SSL_ctrl(s,SSL_CTRL_BUILD_CERT_CHAIN, flags, NULL)\n# define SSL_select_current_cert(ctx,x509) \\\n        SSL_ctrl(ctx,SSL_CTRL_SELECT_CURRENT_CERT,0,(char *)x509)\n# define SSL_set_current_cert(ctx,op) \\\n        SSL_ctrl(ctx,SSL_CTRL_SET_CURRENT_CERT, op, NULL)\n# define SSL_set0_verify_cert_store(s,st) \\\n        SSL_ctrl(s,SSL_CTRL_SET_VERIFY_CERT_STORE,0,(char *)st)\n# define SSL_set1_verify_cert_store(s,st) \\\n        SSL_ctrl(s,SSL_CTRL_SET_VERIFY_CERT_STORE,1,(char *)st)\n# define SSL_set0_chain_cert_store(s,st) \\\n        SSL_ctrl(s,SSL_CTRL_SET_CHAIN_CERT_STORE,0,(char *)st)\n# define SSL_set1_chain_cert_store(s,st) \\\n        SSL_ctrl(s,SSL_CTRL_SET_CHAIN_CERT_STORE,1,(char *)st)\n# define SSL_get1_curves(ctx, s) \\\n        SSL_ctrl(ctx,SSL_CTRL_GET_CURVES,0,(char *)s)\n# define SSL_CTX_set1_curves(ctx, clist, clistlen) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_SET_CURVES,clistlen,(char *)clist)\n# define SSL_CTX_set1_curves_list(ctx, s) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_SET_CURVES_LIST,0,(char *)s)\n# define SSL_set1_curves(ctx, clist, clistlen) \\\n        SSL_ctrl(ctx,SSL_CTRL_SET_CURVES,clistlen,(char *)clist)\n# define SSL_set1_curves_list(ctx, s) \\\n        SSL_ctrl(ctx,SSL_CTRL_SET_CURVES_LIST,0,(char *)s)\n# define SSL_get_shared_curve(s, n) \\\n        SSL_ctrl(s,SSL_CTRL_GET_SHARED_CURVE,n,NULL)\n# define SSL_CTX_set_ecdh_auto(ctx, onoff) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_SET_ECDH_AUTO,onoff,NULL)\n# define SSL_set_ecdh_auto(s, onoff) \\\n        SSL_ctrl(s,SSL_CTRL_SET_ECDH_AUTO,onoff,NULL)\n# define SSL_CTX_set1_sigalgs(ctx, slist, slistlen) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_SET_SIGALGS,slistlen,(int *)slist)\n# define SSL_CTX_set1_sigalgs_list(ctx, s) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_SET_SIGALGS_LIST,0,(char *)s)\n# define SSL_set1_sigalgs(ctx, slist, slistlen) \\\n        SSL_ctrl(ctx,SSL_CTRL_SET_SIGALGS,slistlen,(int *)slist)\n# define SSL_set1_sigalgs_list(ctx, s) \\\n        SSL_ctrl(ctx,SSL_CTRL_SET_SIGALGS_LIST,0,(char *)s)\n# define SSL_CTX_set1_client_sigalgs(ctx, slist, slistlen) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_SET_CLIENT_SIGALGS,slistlen,(int *)slist)\n# define SSL_CTX_set1_client_sigalgs_list(ctx, s) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_SET_CLIENT_SIGALGS_LIST,0,(char *)s)\n# define SSL_set1_client_sigalgs(ctx, slist, slistlen) \\\n        SSL_ctrl(ctx,SSL_CTRL_SET_CLIENT_SIGALGS,clistlen,(int *)slist)\n# define SSL_set1_client_sigalgs_list(ctx, s) \\\n        SSL_ctrl(ctx,SSL_CTRL_SET_CLIENT_SIGALGS_LIST,0,(char *)s)\n# define SSL_get0_certificate_types(s, clist) \\\n        SSL_ctrl(s, SSL_CTRL_GET_CLIENT_CERT_TYPES, 0, (char *)clist)\n# define SSL_CTX_set1_client_certificate_types(ctx, clist, clistlen) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_SET_CLIENT_CERT_TYPES,clistlen,(char *)clist)\n# define SSL_set1_client_certificate_types(s, clist, clistlen) \\\n        SSL_ctrl(s,SSL_CTRL_SET_CLIENT_CERT_TYPES,clistlen,(char *)clist)\n# define SSL_get_peer_signature_nid(s, pn) \\\n        SSL_ctrl(s,SSL_CTRL_GET_PEER_SIGNATURE_NID,0,pn)\n# define SSL_get_server_tmp_key(s, pk) \\\n        SSL_ctrl(s,SSL_CTRL_GET_SERVER_TMP_KEY,0,pk)\n# define SSL_get0_raw_cipherlist(s, plst) \\\n        SSL_ctrl(s,SSL_CTRL_GET_RAW_CIPHERLIST,0,(char *)plst)\n# define SSL_get0_ec_point_formats(s, plst) \\\n        SSL_ctrl(s,SSL_CTRL_GET_EC_POINT_FORMATS,0,(char *)plst)\n# ifndef OPENSSL_NO_BIO\nBIO_METHOD *BIO_f_ssl(void);\nBIO *BIO_new_ssl(SSL_CTX *ctx, int client);\nBIO *BIO_new_ssl_connect(SSL_CTX *ctx);\nBIO *BIO_new_buffer_ssl_connect(SSL_CTX *ctx);\nint BIO_ssl_copy_session_id(BIO *to, BIO *from);\nvoid BIO_ssl_shutdown(BIO *ssl_bio);\n\n# endif\n\nint SSL_CTX_set_cipher_list(SSL_CTX *, const char *str);\nSSL_CTX *SSL_CTX_new(const SSL_METHOD *meth);\nvoid SSL_CTX_free(SSL_CTX *);\nlong SSL_CTX_set_timeout(SSL_CTX *ctx, long t);\nlong SSL_CTX_get_timeout(const SSL_CTX *ctx);\nX509_STORE *SSL_CTX_get_cert_store(const SSL_CTX *);\nvoid SSL_CTX_set_cert_store(SSL_CTX *, X509_STORE *);\nint SSL_want(const SSL *s);\nint SSL_clear(SSL *s);\n\nvoid SSL_CTX_flush_sessions(SSL_CTX *ctx, long tm);\n\nconst SSL_CIPHER *SSL_get_current_cipher(const SSL *s);\nint SSL_CIPHER_get_bits(const SSL_CIPHER *c, int *alg_bits);\nchar *SSL_CIPHER_get_version(const SSL_CIPHER *c);\nconst char *SSL_CIPHER_get_name(const SSL_CIPHER *c);\nunsigned long SSL_CIPHER_get_id(const SSL_CIPHER *c);\n\nint SSL_get_fd(const SSL *s);\nint SSL_get_rfd(const SSL *s);\nint SSL_get_wfd(const SSL *s);\nconst char *SSL_get_cipher_list(const SSL *s, int n);\nchar *SSL_get_shared_ciphers(const SSL *s, char *buf, int len);\nint SSL_get_read_ahead(const SSL *s);\nint SSL_pending(const SSL *s);\n# ifndef OPENSSL_NO_SOCK\nint SSL_set_fd(SSL *s, int fd);\nint SSL_set_rfd(SSL *s, int fd);\nint SSL_set_wfd(SSL *s, int fd);\n# endif\n# ifndef OPENSSL_NO_BIO\nvoid SSL_set_bio(SSL *s, BIO *rbio, BIO *wbio);\nBIO *SSL_get_rbio(const SSL *s);\nBIO *SSL_get_wbio(const SSL *s);\n# endif\nint SSL_set_cipher_list(SSL *s, const char *str);\nvoid SSL_set_read_ahead(SSL *s, int yes);\nint SSL_get_verify_mode(const SSL *s);\nint SSL_get_verify_depth(const SSL *s);\nint (*SSL_get_verify_callback(const SSL *s)) (int, X509_STORE_CTX *);\nvoid SSL_set_verify(SSL *s, int mode,\n                    int (*callback) (int ok, X509_STORE_CTX *ctx));\nvoid SSL_set_verify_depth(SSL *s, int depth);\nvoid SSL_set_cert_cb(SSL *s, int (*cb) (SSL *ssl, void *arg), void *arg);\n# ifndef OPENSSL_NO_RSA\nint SSL_use_RSAPrivateKey(SSL *ssl, RSA *rsa);\n# endif\nint SSL_use_RSAPrivateKey_ASN1(SSL *ssl, unsigned char *d, long len);\nint SSL_use_PrivateKey(SSL *ssl, EVP_PKEY *pkey);\nint SSL_use_PrivateKey_ASN1(int pk, SSL *ssl, const unsigned char *d,\n                            long len);\nint SSL_use_certificate(SSL *ssl, X509 *x);\nint SSL_use_certificate_ASN1(SSL *ssl, const unsigned char *d, int len);\n\n# ifndef OPENSSL_NO_TLSEXT\n/* Set serverinfo data for the current active cert. */\nint SSL_CTX_use_serverinfo(SSL_CTX *ctx, const unsigned char *serverinfo,\n                           size_t serverinfo_length);\n#  ifndef OPENSSL_NO_STDIO\nint SSL_CTX_use_serverinfo_file(SSL_CTX *ctx, const char *file);\n#  endif                        /* NO_STDIO */\n\n# endif\n\n# ifndef OPENSSL_NO_STDIO\nint SSL_use_RSAPrivateKey_file(SSL *ssl, const char *file, int type);\nint SSL_use_PrivateKey_file(SSL *ssl, const char *file, int type);\nint SSL_use_certificate_file(SSL *ssl, const char *file, int type);\nint SSL_CTX_use_RSAPrivateKey_file(SSL_CTX *ctx, const char *file, int type);\nint SSL_CTX_use_PrivateKey_file(SSL_CTX *ctx, const char *file, int type);\nint SSL_CTX_use_certificate_file(SSL_CTX *ctx, const char *file, int type);\n/* PEM type */\nint SSL_CTX_use_certificate_chain_file(SSL_CTX *ctx, const char *file);\nSTACK_OF(X509_NAME) *SSL_load_client_CA_file(const char *file);\nint SSL_add_file_cert_subjects_to_stack(STACK_OF(X509_NAME) *stackCAs,\n                                        const char *file);\n#  ifndef OPENSSL_SYS_VMS\n/* XXXXX: Better scheme needed! [was: #ifndef MAC_OS_pre_X] */\n#   ifndef OPENSSL_SYS_MACINTOSH_CLASSIC\nint SSL_add_dir_cert_subjects_to_stack(STACK_OF(X509_NAME) *stackCAs,\n                                       const char *dir);\n#   endif\n#  endif\n\n# endif\n\nvoid SSL_load_error_strings(void);\nconst char *SSL_state_string(const SSL *s);\nconst char *SSL_rstate_string(const SSL *s);\nconst char *SSL_state_string_long(const SSL *s);\nconst char *SSL_rstate_string_long(const SSL *s);\nlong SSL_SESSION_get_time(const SSL_SESSION *s);\nlong SSL_SESSION_set_time(SSL_SESSION *s, long t);\nlong SSL_SESSION_get_timeout(const SSL_SESSION *s);\nlong SSL_SESSION_set_timeout(SSL_SESSION *s, long t);\nvoid SSL_copy_session_id(SSL *to, const SSL *from);\nX509 *SSL_SESSION_get0_peer(SSL_SESSION *s);\nint SSL_SESSION_set1_id_context(SSL_SESSION *s, const unsigned char *sid_ctx,\n                                unsigned int sid_ctx_len);\n\nSSL_SESSION *SSL_SESSION_new(void);\nconst unsigned char *SSL_SESSION_get_id(const SSL_SESSION *s,\n                                        unsigned int *len);\nunsigned int SSL_SESSION_get_compress_id(const SSL_SESSION *s);\n# ifndef OPENSSL_NO_FP_API\nint SSL_SESSION_print_fp(FILE *fp, const SSL_SESSION *ses);\n# endif\n# ifndef OPENSSL_NO_BIO\nint SSL_SESSION_print(BIO *fp, const SSL_SESSION *ses);\n# endif\nvoid SSL_SESSION_free(SSL_SESSION *ses);\nint i2d_SSL_SESSION(SSL_SESSION *in, unsigned char **pp);\nint SSL_set_session(SSL *to, SSL_SESSION *session);\nint SSL_CTX_add_session(SSL_CTX *s, SSL_SESSION *c);\nint SSL_CTX_remove_session(SSL_CTX *, SSL_SESSION *c);\nint SSL_CTX_set_generate_session_id(SSL_CTX *, GEN_SESSION_CB);\nint SSL_set_generate_session_id(SSL *, GEN_SESSION_CB);\nint SSL_has_matching_session_id(const SSL *ssl, const unsigned char *id,\n                                unsigned int id_len);\nSSL_SESSION *d2i_SSL_SESSION(SSL_SESSION **a, const unsigned char **pp,\n                             long length);\n\n# ifdef HEADER_X509_H\nX509 *SSL_get_peer_certificate(const SSL *s);\n# endif\n\nSTACK_OF(X509) *SSL_get_peer_cert_chain(const SSL *s);\n\nint SSL_CTX_get_verify_mode(const SSL_CTX *ctx);\nint SSL_CTX_get_verify_depth(const SSL_CTX *ctx);\nint (*SSL_CTX_get_verify_callback(const SSL_CTX *ctx)) (int,\n                                                        X509_STORE_CTX *);\nvoid SSL_CTX_set_verify(SSL_CTX *ctx, int mode,\n                        int (*callback) (int, X509_STORE_CTX *));\nvoid SSL_CTX_set_verify_depth(SSL_CTX *ctx, int depth);\nvoid SSL_CTX_set_cert_verify_callback(SSL_CTX *ctx,\n                                      int (*cb) (X509_STORE_CTX *, void *),\n                                      void *arg);\nvoid SSL_CTX_set_cert_cb(SSL_CTX *c, int (*cb) (SSL *ssl, void *arg),\n                         void *arg);\n# ifndef OPENSSL_NO_RSA\nint SSL_CTX_use_RSAPrivateKey(SSL_CTX *ctx, RSA *rsa);\n# endif\nint SSL_CTX_use_RSAPrivateKey_ASN1(SSL_CTX *ctx, const unsigned char *d,\n                                   long len);\nint SSL_CTX_use_PrivateKey(SSL_CTX *ctx, EVP_PKEY *pkey);\nint SSL_CTX_use_PrivateKey_ASN1(int pk, SSL_CTX *ctx,\n                                const unsigned char *d, long len);\nint SSL_CTX_use_certificate(SSL_CTX *ctx, X509 *x);\nint SSL_CTX_use_certificate_ASN1(SSL_CTX *ctx, int len,\n                                 const unsigned char *d);\n\nvoid SSL_CTX_set_default_passwd_cb(SSL_CTX *ctx, pem_password_cb *cb);\nvoid SSL_CTX_set_default_passwd_cb_userdata(SSL_CTX *ctx, void *u);\n\nint SSL_CTX_check_private_key(const SSL_CTX *ctx);\nint SSL_check_private_key(const SSL *ctx);\n\nint SSL_CTX_set_session_id_context(SSL_CTX *ctx, const unsigned char *sid_ctx,\n                                   unsigned int sid_ctx_len);\n\nSSL *SSL_new(SSL_CTX *ctx);\nint SSL_set_session_id_context(SSL *ssl, const unsigned char *sid_ctx,\n                               unsigned int sid_ctx_len);\n\nint SSL_CTX_set_purpose(SSL_CTX *s, int purpose);\nint SSL_set_purpose(SSL *s, int purpose);\nint SSL_CTX_set_trust(SSL_CTX *s, int trust);\nint SSL_set_trust(SSL *s, int trust);\n\nint SSL_CTX_set1_param(SSL_CTX *ctx, X509_VERIFY_PARAM *vpm);\nint SSL_set1_param(SSL *ssl, X509_VERIFY_PARAM *vpm);\n\nX509_VERIFY_PARAM *SSL_CTX_get0_param(SSL_CTX *ctx);\nX509_VERIFY_PARAM *SSL_get0_param(SSL *ssl);\n\n# ifndef OPENSSL_NO_SRP\nint SSL_CTX_set_srp_username(SSL_CTX *ctx, char *name);\nint SSL_CTX_set_srp_password(SSL_CTX *ctx, char *password);\nint SSL_CTX_set_srp_strength(SSL_CTX *ctx, int strength);\nint SSL_CTX_set_srp_client_pwd_callback(SSL_CTX *ctx,\n                                        char *(*cb) (SSL *, void *));\nint SSL_CTX_set_srp_verify_param_callback(SSL_CTX *ctx,\n                                          int (*cb) (SSL *, void *));\nint SSL_CTX_set_srp_username_callback(SSL_CTX *ctx,\n                                      int (*cb) (SSL *, int *, void *));\nint SSL_CTX_set_srp_cb_arg(SSL_CTX *ctx, void *arg);\n\nint SSL_set_srp_server_param(SSL *s, const BIGNUM *N, const BIGNUM *g,\n                             BIGNUM *sa, BIGNUM *v, char *info);\nint SSL_set_srp_server_param_pw(SSL *s, const char *user, const char *pass,\n                                const char *grp);\n\nBIGNUM *SSL_get_srp_g(SSL *s);\nBIGNUM *SSL_get_srp_N(SSL *s);\n\nchar *SSL_get_srp_username(SSL *s);\nchar *SSL_get_srp_userinfo(SSL *s);\n# endif\n\nvoid SSL_certs_clear(SSL *s);\nvoid SSL_free(SSL *ssl);\nint SSL_accept(SSL *ssl);\nint SSL_connect(SSL *ssl);\nint SSL_read(SSL *ssl, void *buf, int num);\nint SSL_peek(SSL *ssl, void *buf, int num);\nint SSL_write(SSL *ssl, const void *buf, int num);\nlong SSL_ctrl(SSL *ssl, int cmd, long larg, void *parg);\nlong SSL_callback_ctrl(SSL *, int, void (*)(void));\nlong SSL_CTX_ctrl(SSL_CTX *ctx, int cmd, long larg, void *parg);\nlong SSL_CTX_callback_ctrl(SSL_CTX *, int, void (*)(void));\n\nint SSL_get_error(const SSL *s, int ret_code);\nconst char *SSL_get_version(const SSL *s);\n\n/* This sets the 'default' SSL version that SSL_new() will create */\nint SSL_CTX_set_ssl_version(SSL_CTX *ctx, const SSL_METHOD *meth);\n\n# ifndef OPENSSL_NO_SSL2_METHOD\nconst SSL_METHOD *SSLv2_method(void); /* SSLv2 */\nconst SSL_METHOD *SSLv2_server_method(void); /* SSLv2 */\nconst SSL_METHOD *SSLv2_client_method(void); /* SSLv2 */\n# endif\n\n# ifndef OPENSSL_NO_SSL3_METHOD\nconst SSL_METHOD *SSLv3_method(void); /* SSLv3 */\nconst SSL_METHOD *SSLv3_server_method(void); /* SSLv3 */\nconst SSL_METHOD *SSLv3_client_method(void); /* SSLv3 */\n# endif\n\nconst SSL_METHOD *SSLv23_method(void); /* Negotiate highest available SSL/TLS\n                                        * version */\nconst SSL_METHOD *SSLv23_server_method(void); /* Negotiate highest available\n                                               * SSL/TLS version */\nconst SSL_METHOD *SSLv23_client_method(void); /* Negotiate highest available\n                                               * SSL/TLS version */\n\nconst SSL_METHOD *TLSv1_method(void); /* TLSv1.0 */\nconst SSL_METHOD *TLSv1_server_method(void); /* TLSv1.0 */\nconst SSL_METHOD *TLSv1_client_method(void); /* TLSv1.0 */\n\nconst SSL_METHOD *TLSv1_1_method(void); /* TLSv1.1 */\nconst SSL_METHOD *TLSv1_1_server_method(void); /* TLSv1.1 */\nconst SSL_METHOD *TLSv1_1_client_method(void); /* TLSv1.1 */\n\nconst SSL_METHOD *TLSv1_2_method(void); /* TLSv1.2 */\nconst SSL_METHOD *TLSv1_2_server_method(void); /* TLSv1.2 */\nconst SSL_METHOD *TLSv1_2_client_method(void); /* TLSv1.2 */\n\nconst SSL_METHOD *DTLSv1_method(void); /* DTLSv1.0 */\nconst SSL_METHOD *DTLSv1_server_method(void); /* DTLSv1.0 */\nconst SSL_METHOD *DTLSv1_client_method(void); /* DTLSv1.0 */\n\nconst SSL_METHOD *DTLSv1_2_method(void); /* DTLSv1.2 */\nconst SSL_METHOD *DTLSv1_2_server_method(void); /* DTLSv1.2 */\nconst SSL_METHOD *DTLSv1_2_client_method(void); /* DTLSv1.2 */\n\nconst SSL_METHOD *DTLS_method(void); /* DTLS 1.0 and 1.2 */\nconst SSL_METHOD *DTLS_server_method(void); /* DTLS 1.0 and 1.2 */\nconst SSL_METHOD *DTLS_client_method(void); /* DTLS 1.0 and 1.2 */\n\nSTACK_OF(SSL_CIPHER) *SSL_get_ciphers(const SSL *s);\n\nint SSL_do_handshake(SSL *s);\nint SSL_renegotiate(SSL *s);\nint SSL_renegotiate_abbreviated(SSL *s);\nint SSL_renegotiate_pending(SSL *s);\nint SSL_shutdown(SSL *s);\n\nconst SSL_METHOD *SSL_CTX_get_ssl_method(SSL_CTX *ctx);\nconst SSL_METHOD *SSL_get_ssl_method(SSL *s);\nint SSL_set_ssl_method(SSL *s, const SSL_METHOD *method);\nconst char *SSL_alert_type_string_long(int value);\nconst char *SSL_alert_type_string(int value);\nconst char *SSL_alert_desc_string_long(int value);\nconst char *SSL_alert_desc_string(int value);\n\nvoid SSL_set_client_CA_list(SSL *s, STACK_OF(X509_NAME) *name_list);\nvoid SSL_CTX_set_client_CA_list(SSL_CTX *ctx, STACK_OF(X509_NAME) *name_list);\nSTACK_OF(X509_NAME) *SSL_get_client_CA_list(const SSL *s);\nSTACK_OF(X509_NAME) *SSL_CTX_get_client_CA_list(const SSL_CTX *s);\nint SSL_add_client_CA(SSL *ssl, X509 *x);\nint SSL_CTX_add_client_CA(SSL_CTX *ctx, X509 *x);\n\nvoid SSL_set_connect_state(SSL *s);\nvoid SSL_set_accept_state(SSL *s);\n\nlong SSL_get_default_timeout(const SSL *s);\n\nint SSL_library_init(void);\n\nchar *SSL_CIPHER_description(const SSL_CIPHER *, char *buf, int size);\nSTACK_OF(X509_NAME) *SSL_dup_CA_list(STACK_OF(X509_NAME) *sk);\n\nSSL *SSL_dup(SSL *ssl);\n\nX509 *SSL_get_certificate(const SSL *ssl);\n/*\n * EVP_PKEY\n */ struct evp_pkey_st *SSL_get_privatekey(const SSL *ssl);\n\nX509 *SSL_CTX_get0_certificate(const SSL_CTX *ctx);\nEVP_PKEY *SSL_CTX_get0_privatekey(const SSL_CTX *ctx);\n\nvoid SSL_CTX_set_quiet_shutdown(SSL_CTX *ctx, int mode);\nint SSL_CTX_get_quiet_shutdown(const SSL_CTX *ctx);\nvoid SSL_set_quiet_shutdown(SSL *ssl, int mode);\nint SSL_get_quiet_shutdown(const SSL *ssl);\nvoid SSL_set_shutdown(SSL *ssl, int mode);\nint SSL_get_shutdown(const SSL *ssl);\nint SSL_version(const SSL *ssl);\nint SSL_CTX_set_default_verify_paths(SSL_CTX *ctx);\nint SSL_CTX_load_verify_locations(SSL_CTX *ctx, const char *CAfile,\n                                  const char *CApath);\n# define SSL_get0_session SSL_get_session/* just peek at pointer */\nSSL_SESSION *SSL_get_session(const SSL *ssl);\nSSL_SESSION *SSL_get1_session(SSL *ssl); /* obtain a reference count */\nSSL_CTX *SSL_get_SSL_CTX(const SSL *ssl);\nSSL_CTX *SSL_set_SSL_CTX(SSL *ssl, SSL_CTX *ctx);\nvoid SSL_set_info_callback(SSL *ssl,\n                           void (*cb) (const SSL *ssl, int type, int val));\nvoid (*SSL_get_info_callback(const SSL *ssl)) (const SSL *ssl, int type,\n                                               int val);\nint SSL_state(const SSL *ssl);\nvoid SSL_set_state(SSL *ssl, int state);\n\nvoid SSL_set_verify_result(SSL *ssl, long v);\nlong SSL_get_verify_result(const SSL *ssl);\n\nint SSL_set_ex_data(SSL *ssl, int idx, void *data);\nvoid *SSL_get_ex_data(const SSL *ssl, int idx);\nint SSL_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func,\n                         CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func);\n\nint SSL_SESSION_set_ex_data(SSL_SESSION *ss, int idx, void *data);\nvoid *SSL_SESSION_get_ex_data(const SSL_SESSION *ss, int idx);\nint SSL_SESSION_get_ex_new_index(long argl, void *argp,\n                                 CRYPTO_EX_new *new_func,\n                                 CRYPTO_EX_dup *dup_func,\n                                 CRYPTO_EX_free *free_func);\n\nint SSL_CTX_set_ex_data(SSL_CTX *ssl, int idx, void *data);\nvoid *SSL_CTX_get_ex_data(const SSL_CTX *ssl, int idx);\nint SSL_CTX_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func,\n                             CRYPTO_EX_dup *dup_func,\n                             CRYPTO_EX_free *free_func);\n\nint SSL_get_ex_data_X509_STORE_CTX_idx(void);\n\n# define SSL_CTX_sess_set_cache_size(ctx,t) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_SET_SESS_CACHE_SIZE,t,NULL)\n# define SSL_CTX_sess_get_cache_size(ctx) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_GET_SESS_CACHE_SIZE,0,NULL)\n# define SSL_CTX_set_session_cache_mode(ctx,m) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_SET_SESS_CACHE_MODE,m,NULL)\n# define SSL_CTX_get_session_cache_mode(ctx) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_GET_SESS_CACHE_MODE,0,NULL)\n\n# define SSL_CTX_get_default_read_ahead(ctx) SSL_CTX_get_read_ahead(ctx)\n# define SSL_CTX_set_default_read_ahead(ctx,m) SSL_CTX_set_read_ahead(ctx,m)\n# define SSL_CTX_get_read_ahead(ctx) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_GET_READ_AHEAD,0,NULL)\n# define SSL_CTX_set_read_ahead(ctx,m) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_SET_READ_AHEAD,m,NULL)\n# define SSL_CTX_get_max_cert_list(ctx) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_GET_MAX_CERT_LIST,0,NULL)\n# define SSL_CTX_set_max_cert_list(ctx,m) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_SET_MAX_CERT_LIST,m,NULL)\n# define SSL_get_max_cert_list(ssl) \\\n        SSL_ctrl(ssl,SSL_CTRL_GET_MAX_CERT_LIST,0,NULL)\n# define SSL_set_max_cert_list(ssl,m) \\\n        SSL_ctrl(ssl,SSL_CTRL_SET_MAX_CERT_LIST,m,NULL)\n\n# define SSL_CTX_set_max_send_fragment(ctx,m) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_SET_MAX_SEND_FRAGMENT,m,NULL)\n# define SSL_set_max_send_fragment(ssl,m) \\\n        SSL_ctrl(ssl,SSL_CTRL_SET_MAX_SEND_FRAGMENT,m,NULL)\n\n     /* NB: the keylength is only applicable when is_export is true */\n# ifndef OPENSSL_NO_RSA\nvoid SSL_CTX_set_tmp_rsa_callback(SSL_CTX *ctx,\n                                  RSA *(*cb) (SSL *ssl, int is_export,\n                                              int keylength));\n\nvoid SSL_set_tmp_rsa_callback(SSL *ssl,\n                              RSA *(*cb) (SSL *ssl, int is_export,\n                                          int keylength));\n# endif\n# ifndef OPENSSL_NO_DH\nvoid SSL_CTX_set_tmp_dh_callback(SSL_CTX *ctx,\n                                 DH *(*dh) (SSL *ssl, int is_export,\n                                            int keylength));\nvoid SSL_set_tmp_dh_callback(SSL *ssl,\n                             DH *(*dh) (SSL *ssl, int is_export,\n                                        int keylength));\n# endif\n# ifndef OPENSSL_NO_ECDH\nvoid SSL_CTX_set_tmp_ecdh_callback(SSL_CTX *ctx,\n                                   EC_KEY *(*ecdh) (SSL *ssl, int is_export,\n                                                    int keylength));\nvoid SSL_set_tmp_ecdh_callback(SSL *ssl,\n                               EC_KEY *(*ecdh) (SSL *ssl, int is_export,\n                                                int keylength));\n# endif\n\n# ifndef OPENSSL_NO_COMP\nconst COMP_METHOD *SSL_get_current_compression(SSL *s);\nconst COMP_METHOD *SSL_get_current_expansion(SSL *s);\nconst char *SSL_COMP_get_name(const COMP_METHOD *comp);\nSTACK_OF(SSL_COMP) *SSL_COMP_get_compression_methods(void);\nSTACK_OF(SSL_COMP) *SSL_COMP_set0_compression_methods(STACK_OF(SSL_COMP)\n                                                      *meths);\nvoid SSL_COMP_free_compression_methods(void);\nint SSL_COMP_add_compression_method(int id, COMP_METHOD *cm);\n# else\nconst void *SSL_get_current_compression(SSL *s);\nconst void *SSL_get_current_expansion(SSL *s);\nconst char *SSL_COMP_get_name(const void *comp);\nvoid *SSL_COMP_get_compression_methods(void);\nint SSL_COMP_add_compression_method(int id, void *cm);\n# endif\n\nconst SSL_CIPHER *SSL_CIPHER_find(SSL *ssl, const unsigned char *ptr);\n\n/* TLS extensions functions */\nint SSL_set_session_ticket_ext(SSL *s, void *ext_data, int ext_len);\n\nint SSL_set_session_ticket_ext_cb(SSL *s, tls_session_ticket_ext_cb_fn cb,\n                                  void *arg);\n\n/* Pre-shared secret session resumption functions */\nint SSL_set_session_secret_cb(SSL *s,\n                              tls_session_secret_cb_fn tls_session_secret_cb,\n                              void *arg);\n\nvoid SSL_set_debug(SSL *s, int debug);\nint SSL_cache_hit(SSL *s);\nint SSL_is_server(SSL *s);\n\nSSL_CONF_CTX *SSL_CONF_CTX_new(void);\nint SSL_CONF_CTX_finish(SSL_CONF_CTX *cctx);\nvoid SSL_CONF_CTX_free(SSL_CONF_CTX *cctx);\nunsigned int SSL_CONF_CTX_set_flags(SSL_CONF_CTX *cctx, unsigned int flags);\nunsigned int SSL_CONF_CTX_clear_flags(SSL_CONF_CTX *cctx, unsigned int flags);\nint SSL_CONF_CTX_set1_prefix(SSL_CONF_CTX *cctx, const char *pre);\n\nvoid SSL_CONF_CTX_set_ssl(SSL_CONF_CTX *cctx, SSL *ssl);\nvoid SSL_CONF_CTX_set_ssl_ctx(SSL_CONF_CTX *cctx, SSL_CTX *ctx);\n\nint SSL_CONF_cmd(SSL_CONF_CTX *cctx, const char *cmd, const char *value);\nint SSL_CONF_cmd_argv(SSL_CONF_CTX *cctx, int *pargc, char ***pargv);\nint SSL_CONF_cmd_value_type(SSL_CONF_CTX *cctx, const char *cmd);\n\n# ifndef OPENSSL_NO_SSL_TRACE\nvoid SSL_trace(int write_p, int version, int content_type,\n               const void *buf, size_t len, SSL *ssl, void *arg);\nconst char *SSL_CIPHER_standard_name(const SSL_CIPHER *c);\n# endif\n\n# ifndef OPENSSL_NO_UNIT_TEST\nconst struct openssl_ssl_test_functions *SSL_test_functions(void);\n# endif\n\n/* BEGIN ERROR CODES */\n/*\n * The following lines are auto generated by the script mkerr.pl. Any changes\n * made after this point may be overwritten when the script is next run.\n */\nvoid ERR_load_SSL_strings(void);\n\n/* Error codes for the SSL functions. */\n\n/* Function codes. */\n# define SSL_F_CHECK_SUITEB_CIPHER_LIST                   331\n# define SSL_F_CLIENT_CERTIFICATE                         100\n# define SSL_F_CLIENT_FINISHED                            167\n# define SSL_F_CLIENT_HELLO                               101\n# define SSL_F_CLIENT_MASTER_KEY                          102\n# define SSL_F_D2I_SSL_SESSION                            103\n# define SSL_F_DO_DTLS1_WRITE                             245\n# define SSL_F_DO_SSL3_WRITE                              104\n# define SSL_F_DTLS1_ACCEPT                               246\n# define SSL_F_DTLS1_ADD_CERT_TO_BUF                      295\n# define SSL_F_DTLS1_BUFFER_RECORD                        247\n# define SSL_F_DTLS1_CHECK_TIMEOUT_NUM                    316\n# define SSL_F_DTLS1_CLIENT_HELLO                         248\n# define SSL_F_DTLS1_CONNECT                              249\n# define SSL_F_DTLS1_ENC                                  250\n# define SSL_F_DTLS1_GET_HELLO_VERIFY                     251\n# define SSL_F_DTLS1_GET_MESSAGE                          252\n# define SSL_F_DTLS1_GET_MESSAGE_FRAGMENT                 253\n# define SSL_F_DTLS1_GET_RECORD                           254\n# define SSL_F_DTLS1_HANDLE_TIMEOUT                       297\n# define SSL_F_DTLS1_HEARTBEAT                            305\n# define SSL_F_DTLS1_OUTPUT_CERT_CHAIN                    255\n# define SSL_F_DTLS1_PREPROCESS_FRAGMENT                  288\n# define SSL_F_DTLS1_PROCESS_OUT_OF_SEQ_MESSAGE           256\n# define SSL_F_DTLS1_PROCESS_RECORD                       257\n# define SSL_F_DTLS1_READ_BYTES                           258\n# define SSL_F_DTLS1_READ_FAILED                          259\n# define SSL_F_DTLS1_SEND_CERTIFICATE_REQUEST             260\n# define SSL_F_DTLS1_SEND_CLIENT_CERTIFICATE              261\n# define SSL_F_DTLS1_SEND_CLIENT_KEY_EXCHANGE             262\n# define SSL_F_DTLS1_SEND_CLIENT_VERIFY                   263\n# define SSL_F_DTLS1_SEND_HELLO_VERIFY_REQUEST            264\n# define SSL_F_DTLS1_SEND_SERVER_CERTIFICATE              265\n# define SSL_F_DTLS1_SEND_SERVER_HELLO                    266\n# define SSL_F_DTLS1_SEND_SERVER_KEY_EXCHANGE             267\n# define SSL_F_DTLS1_WRITE_APP_DATA_BYTES                 268\n# define SSL_F_GET_CLIENT_FINISHED                        105\n# define SSL_F_GET_CLIENT_HELLO                           106\n# define SSL_F_GET_CLIENT_MASTER_KEY                      107\n# define SSL_F_GET_SERVER_FINISHED                        108\n# define SSL_F_GET_SERVER_HELLO                           109\n# define SSL_F_GET_SERVER_STATIC_DH_KEY                   340\n# define SSL_F_GET_SERVER_VERIFY                          110\n# define SSL_F_I2D_SSL_SESSION                            111\n# define SSL_F_READ_N                                     112\n# define SSL_F_REQUEST_CERTIFICATE                        113\n# define SSL_F_SERVER_FINISH                              239\n# define SSL_F_SERVER_HELLO                               114\n# define SSL_F_SERVER_VERIFY                              240\n# define SSL_F_SSL23_ACCEPT                               115\n# define SSL_F_SSL23_CLIENT_HELLO                         116\n# define SSL_F_SSL23_CONNECT                              117\n# define SSL_F_SSL23_GET_CLIENT_HELLO                     118\n# define SSL_F_SSL23_GET_SERVER_HELLO                     119\n# define SSL_F_SSL23_PEEK                                 237\n# define SSL_F_SSL23_READ                                 120\n# define SSL_F_SSL23_WRITE                                121\n# define SSL_F_SSL2_ACCEPT                                122\n# define SSL_F_SSL2_CONNECT                               123\n# define SSL_F_SSL2_ENC_INIT                              124\n# define SSL_F_SSL2_GENERATE_KEY_MATERIAL                 241\n# define SSL_F_SSL2_PEEK                                  234\n# define SSL_F_SSL2_READ                                  125\n# define SSL_F_SSL2_READ_INTERNAL                         236\n# define SSL_F_SSL2_SET_CERTIFICATE                       126\n# define SSL_F_SSL2_WRITE                                 127\n# define SSL_F_SSL3_ACCEPT                                128\n# define SSL_F_SSL3_ADD_CERT_TO_BUF                       296\n# define SSL_F_SSL3_CALLBACK_CTRL                         233\n# define SSL_F_SSL3_CHANGE_CIPHER_STATE                   129\n# define SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM              130\n# define SSL_F_SSL3_CHECK_CLIENT_HELLO                    304\n# define SSL_F_SSL3_CHECK_FINISHED                        339\n# define SSL_F_SSL3_CLIENT_HELLO                          131\n# define SSL_F_SSL3_CONNECT                               132\n# define SSL_F_SSL3_CTRL                                  213\n# define SSL_F_SSL3_CTX_CTRL                              133\n# define SSL_F_SSL3_DIGEST_CACHED_RECORDS                 293\n# define SSL_F_SSL3_DO_CHANGE_CIPHER_SPEC                 292\n# define SSL_F_SSL3_ENC                                   134\n# define SSL_F_SSL3_GENERATE_KEY_BLOCK                    238\n# define SSL_F_SSL3_GENERATE_MASTER_SECRET                388\n# define SSL_F_SSL3_GET_CERTIFICATE_REQUEST               135\n# define SSL_F_SSL3_GET_CERT_STATUS                       289\n# define SSL_F_SSL3_GET_CERT_VERIFY                       136\n# define SSL_F_SSL3_GET_CLIENT_CERTIFICATE                137\n# define SSL_F_SSL3_GET_CLIENT_HELLO                      138\n# define SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE               139\n# define SSL_F_SSL3_GET_FINISHED                          140\n# define SSL_F_SSL3_GET_KEY_EXCHANGE                      141\n# define SSL_F_SSL3_GET_MESSAGE                           142\n# define SSL_F_SSL3_GET_NEW_SESSION_TICKET                283\n# define SSL_F_SSL3_GET_NEXT_PROTO                        306\n# define SSL_F_SSL3_GET_RECORD                            143\n# define SSL_F_SSL3_GET_SERVER_CERTIFICATE                144\n# define SSL_F_SSL3_GET_SERVER_DONE                       145\n# define SSL_F_SSL3_GET_SERVER_HELLO                      146\n# define SSL_F_SSL3_HANDSHAKE_MAC                         285\n# define SSL_F_SSL3_NEW_SESSION_TICKET                    287\n# define SSL_F_SSL3_OUTPUT_CERT_CHAIN                     147\n# define SSL_F_SSL3_PEEK                                  235\n# define SSL_F_SSL3_READ_BYTES                            148\n# define SSL_F_SSL3_READ_N                                149\n# define SSL_F_SSL3_SEND_CERTIFICATE_REQUEST              150\n# define SSL_F_SSL3_SEND_CLIENT_CERTIFICATE               151\n# define SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE              152\n# define SSL_F_SSL3_SEND_CLIENT_VERIFY                    153\n# define SSL_F_SSL3_SEND_SERVER_CERTIFICATE               154\n# define SSL_F_SSL3_SEND_SERVER_HELLO                     242\n# define SSL_F_SSL3_SEND_SERVER_KEY_EXCHANGE              155\n# define SSL_F_SSL3_SETUP_KEY_BLOCK                       157\n# define SSL_F_SSL3_SETUP_READ_BUFFER                     156\n# define SSL_F_SSL3_SETUP_WRITE_BUFFER                    291\n# define SSL_F_SSL3_WRITE_BYTES                           158\n# define SSL_F_SSL3_WRITE_PENDING                         159\n# define SSL_F_SSL_ADD_CERT_CHAIN                         318\n# define SSL_F_SSL_ADD_CERT_TO_BUF                        319\n# define SSL_F_SSL_ADD_CLIENTHELLO_RENEGOTIATE_EXT        298\n# define SSL_F_SSL_ADD_CLIENTHELLO_TLSEXT                 277\n# define SSL_F_SSL_ADD_CLIENTHELLO_USE_SRTP_EXT           307\n# define SSL_F_SSL_ADD_DIR_CERT_SUBJECTS_TO_STACK         215\n# define SSL_F_SSL_ADD_FILE_CERT_SUBJECTS_TO_STACK        216\n# define SSL_F_SSL_ADD_SERVERHELLO_RENEGOTIATE_EXT        299\n# define SSL_F_SSL_ADD_SERVERHELLO_TLSEXT                 278\n# define SSL_F_SSL_ADD_SERVERHELLO_USE_SRTP_EXT           308\n# define SSL_F_SSL_BAD_METHOD                             160\n# define SSL_F_SSL_BUILD_CERT_CHAIN                       332\n# define SSL_F_SSL_BYTES_TO_CIPHER_LIST                   161\n# define SSL_F_SSL_CERT_DUP                               221\n# define SSL_F_SSL_CERT_INST                              222\n# define SSL_F_SSL_CERT_INSTANTIATE                       214\n# define SSL_F_SSL_CERT_NEW                               162\n# define SSL_F_SSL_CHECK_PRIVATE_KEY                      163\n# define SSL_F_SSL_CHECK_SERVERHELLO_TLSEXT               280\n# define SSL_F_SSL_CHECK_SRVR_ECC_CERT_AND_ALG            279\n# define SSL_F_SSL_CIPHER_PROCESS_RULESTR                 230\n# define SSL_F_SSL_CIPHER_STRENGTH_SORT                   231\n# define SSL_F_SSL_CLEAR                                  164\n# define SSL_F_SSL_COMP_ADD_COMPRESSION_METHOD            165\n# define SSL_F_SSL_CONF_CMD                               334\n# define SSL_F_SSL_CREATE_CIPHER_LIST                     166\n# define SSL_F_SSL_CTRL                                   232\n# define SSL_F_SSL_CTX_CHECK_PRIVATE_KEY                  168\n# define SSL_F_SSL_CTX_MAKE_PROFILES                      309\n# define SSL_F_SSL_CTX_NEW                                169\n# define SSL_F_SSL_CTX_SET_CIPHER_LIST                    269\n# define SSL_F_SSL_CTX_SET_CLIENT_CERT_ENGINE             290\n# define SSL_F_SSL_CTX_SET_PURPOSE                        226\n# define SSL_F_SSL_CTX_SET_SESSION_ID_CONTEXT             219\n# define SSL_F_SSL_CTX_SET_SSL_VERSION                    170\n# define SSL_F_SSL_CTX_SET_TRUST                          229\n# define SSL_F_SSL_CTX_USE_CERTIFICATE                    171\n# define SSL_F_SSL_CTX_USE_CERTIFICATE_ASN1               172\n# define SSL_F_SSL_CTX_USE_CERTIFICATE_CHAIN_FILE         220\n# define SSL_F_SSL_CTX_USE_CERTIFICATE_FILE               173\n# define SSL_F_SSL_CTX_USE_PRIVATEKEY                     174\n# define SSL_F_SSL_CTX_USE_PRIVATEKEY_ASN1                175\n# define SSL_F_SSL_CTX_USE_PRIVATEKEY_FILE                176\n# define SSL_F_SSL_CTX_USE_PSK_IDENTITY_HINT              272\n# define SSL_F_SSL_CTX_USE_RSAPRIVATEKEY                  177\n# define SSL_F_SSL_CTX_USE_RSAPRIVATEKEY_ASN1             178\n# define SSL_F_SSL_CTX_USE_RSAPRIVATEKEY_FILE             179\n# define SSL_F_SSL_CTX_USE_SERVERINFO                     336\n# define SSL_F_SSL_CTX_USE_SERVERINFO_FILE                337\n# define SSL_F_SSL_DO_HANDSHAKE                           180\n# define SSL_F_SSL_GET_NEW_SESSION                        181\n# define SSL_F_SSL_GET_PREV_SESSION                       217\n# define SSL_F_SSL_GET_SERVER_CERT_INDEX                  322\n# define SSL_F_SSL_GET_SERVER_SEND_CERT                   182\n# define SSL_F_SSL_GET_SERVER_SEND_PKEY                   317\n# define SSL_F_SSL_GET_SIGN_PKEY                          183\n# define SSL_F_SSL_INIT_WBIO_BUFFER                       184\n# define SSL_F_SSL_LOAD_CLIENT_CA_FILE                    185\n# define SSL_F_SSL_NEW                                    186\n# define SSL_F_SSL_PARSE_CLIENTHELLO_RENEGOTIATE_EXT      300\n# define SSL_F_SSL_PARSE_CLIENTHELLO_TLSEXT               302\n# define SSL_F_SSL_PARSE_CLIENTHELLO_USE_SRTP_EXT         310\n# define SSL_F_SSL_PARSE_SERVERHELLO_RENEGOTIATE_EXT      301\n# define SSL_F_SSL_PARSE_SERVERHELLO_TLSEXT               303\n# define SSL_F_SSL_PARSE_SERVERHELLO_USE_SRTP_EXT         311\n# define SSL_F_SSL_PEEK                                   270\n# define SSL_F_SSL_PREPARE_CLIENTHELLO_TLSEXT             281\n# define SSL_F_SSL_PREPARE_SERVERHELLO_TLSEXT             282\n# define SSL_F_SSL_READ                                   223\n# define SSL_F_SSL_RSA_PRIVATE_DECRYPT                    187\n# define SSL_F_SSL_RSA_PUBLIC_ENCRYPT                     188\n# define SSL_F_SSL_SCAN_CLIENTHELLO_TLSEXT                320\n# define SSL_F_SSL_SCAN_SERVERHELLO_TLSEXT                321\n# define SSL_F_SSL_SESSION_DUP                            348\n# define SSL_F_SSL_SESSION_NEW                            189\n# define SSL_F_SSL_SESSION_PRINT_FP                       190\n# define SSL_F_SSL_SESSION_SET1_ID_CONTEXT                312\n# define SSL_F_SSL_SESS_CERT_NEW                          225\n# define SSL_F_SSL_SET_CERT                               191\n# define SSL_F_SSL_SET_CIPHER_LIST                        271\n# define SSL_F_SSL_SET_FD                                 192\n# define SSL_F_SSL_SET_PKEY                               193\n# define SSL_F_SSL_SET_PURPOSE                            227\n# define SSL_F_SSL_SET_RFD                                194\n# define SSL_F_SSL_SET_SESSION                            195\n# define SSL_F_SSL_SET_SESSION_ID_CONTEXT                 218\n# define SSL_F_SSL_SET_SESSION_TICKET_EXT                 294\n# define SSL_F_SSL_SET_TRUST                              228\n# define SSL_F_SSL_SET_WFD                                196\n# define SSL_F_SSL_SHUTDOWN                               224\n# define SSL_F_SSL_SRP_CTX_INIT                           313\n# define SSL_F_SSL_UNDEFINED_CONST_FUNCTION               243\n# define SSL_F_SSL_UNDEFINED_FUNCTION                     197\n# define SSL_F_SSL_UNDEFINED_VOID_FUNCTION                244\n# define SSL_F_SSL_USE_CERTIFICATE                        198\n# define SSL_F_SSL_USE_CERTIFICATE_ASN1                   199\n# define SSL_F_SSL_USE_CERTIFICATE_FILE                   200\n# define SSL_F_SSL_USE_PRIVATEKEY                         201\n# define SSL_F_SSL_USE_PRIVATEKEY_ASN1                    202\n# define SSL_F_SSL_USE_PRIVATEKEY_FILE                    203\n# define SSL_F_SSL_USE_PSK_IDENTITY_HINT                  273\n# define SSL_F_SSL_USE_RSAPRIVATEKEY                      204\n# define SSL_F_SSL_USE_RSAPRIVATEKEY_ASN1                 205\n# define SSL_F_SSL_USE_RSAPRIVATEKEY_FILE                 206\n# define SSL_F_SSL_VERIFY_CERT_CHAIN                      207\n# define SSL_F_SSL_WRITE                                  208\n# define SSL_F_TLS12_CHECK_PEER_SIGALG                    333\n# define SSL_F_TLS1_CERT_VERIFY_MAC                       286\n# define SSL_F_TLS1_CHANGE_CIPHER_STATE                   209\n# define SSL_F_TLS1_CHECK_SERVERHELLO_TLSEXT              274\n# define SSL_F_TLS1_ENC                                   210\n# define SSL_F_TLS1_EXPORT_KEYING_MATERIAL                314\n# define SSL_F_TLS1_GET_CURVELIST                         338\n# define SSL_F_TLS1_HEARTBEAT                             315\n# define SSL_F_TLS1_PREPARE_CLIENTHELLO_TLSEXT            275\n# define SSL_F_TLS1_PREPARE_SERVERHELLO_TLSEXT            276\n# define SSL_F_TLS1_PRF                                   284\n# define SSL_F_TLS1_SETUP_KEY_BLOCK                       211\n# define SSL_F_TLS1_SET_SERVER_SIGALGS                    335\n# define SSL_F_WRITE_PENDING                              212\n\n/* Reason codes. */\n# define SSL_R_APP_DATA_IN_HANDSHAKE                      100\n# define SSL_R_ATTEMPT_TO_REUSE_SESSION_IN_DIFFERENT_CONTEXT 272\n# define SSL_R_BAD_ALERT_RECORD                           101\n# define SSL_R_BAD_AUTHENTICATION_TYPE                    102\n# define SSL_R_BAD_CHANGE_CIPHER_SPEC                     103\n# define SSL_R_BAD_CHECKSUM                               104\n# define SSL_R_BAD_DATA                                   390\n# define SSL_R_BAD_DATA_RETURNED_BY_CALLBACK              106\n# define SSL_R_BAD_DECOMPRESSION                          107\n# define SSL_R_BAD_DH_G_LENGTH                            108\n# define SSL_R_BAD_DH_G_VALUE                             375\n# define SSL_R_BAD_DH_PUB_KEY_LENGTH                      109\n# define SSL_R_BAD_DH_PUB_KEY_VALUE                       393\n# define SSL_R_BAD_DH_P_LENGTH                            110\n# define SSL_R_BAD_DH_P_VALUE                             395\n# define SSL_R_BAD_DIGEST_LENGTH                          111\n# define SSL_R_BAD_DSA_SIGNATURE                          112\n# define SSL_R_BAD_ECC_CERT                               304\n# define SSL_R_BAD_ECDSA_SIGNATURE                        305\n# define SSL_R_BAD_ECPOINT                                306\n# define SSL_R_BAD_HANDSHAKE_LENGTH                       332\n# define SSL_R_BAD_HELLO_REQUEST                          105\n# define SSL_R_BAD_LENGTH                                 271\n# define SSL_R_BAD_MAC_DECODE                             113\n# define SSL_R_BAD_MAC_LENGTH                             333\n# define SSL_R_BAD_MESSAGE_TYPE                           114\n# define SSL_R_BAD_PACKET_LENGTH                          115\n# define SSL_R_BAD_PROTOCOL_VERSION_NUMBER                116\n# define SSL_R_BAD_PSK_IDENTITY_HINT_LENGTH               316\n# define SSL_R_BAD_RESPONSE_ARGUMENT                      117\n# define SSL_R_BAD_RSA_DECRYPT                            118\n# define SSL_R_BAD_RSA_ENCRYPT                            119\n# define SSL_R_BAD_RSA_E_LENGTH                           120\n# define SSL_R_BAD_RSA_MODULUS_LENGTH                     121\n# define SSL_R_BAD_RSA_SIGNATURE                          122\n# define SSL_R_BAD_SIGNATURE                              123\n# define SSL_R_BAD_SRP_A_LENGTH                           347\n# define SSL_R_BAD_SRP_B_LENGTH                           348\n# define SSL_R_BAD_SRP_G_LENGTH                           349\n# define SSL_R_BAD_SRP_N_LENGTH                           350\n# define SSL_R_BAD_SRP_PARAMETERS                         371\n# define SSL_R_BAD_SRP_S_LENGTH                           351\n# define SSL_R_BAD_SRTP_MKI_VALUE                         352\n# define SSL_R_BAD_SRTP_PROTECTION_PROFILE_LIST           353\n# define SSL_R_BAD_SSL_FILETYPE                           124\n# define SSL_R_BAD_SSL_SESSION_ID_LENGTH                  125\n# define SSL_R_BAD_STATE                                  126\n# define SSL_R_BAD_VALUE                                  384\n# define SSL_R_BAD_WRITE_RETRY                            127\n# define SSL_R_BIO_NOT_SET                                128\n# define SSL_R_BLOCK_CIPHER_PAD_IS_WRONG                  129\n# define SSL_R_BN_LIB                                     130\n# define SSL_R_CA_DN_LENGTH_MISMATCH                      131\n# define SSL_R_CA_DN_TOO_LONG                             132\n# define SSL_R_CCS_RECEIVED_EARLY                         133\n# define SSL_R_CERTIFICATE_VERIFY_FAILED                  134\n# define SSL_R_CERT_CB_ERROR                              377\n# define SSL_R_CERT_LENGTH_MISMATCH                       135\n# define SSL_R_CHALLENGE_IS_DIFFERENT                     136\n# define SSL_R_CIPHER_CODE_WRONG_LENGTH                   137\n# define SSL_R_CIPHER_OR_HASH_UNAVAILABLE                 138\n# define SSL_R_CIPHER_TABLE_SRC_ERROR                     139\n# define SSL_R_CLIENTHELLO_TLSEXT                         226\n# define SSL_R_COMPRESSED_LENGTH_TOO_LONG                 140\n# define SSL_R_COMPRESSION_DISABLED                       343\n# define SSL_R_COMPRESSION_FAILURE                        141\n# define SSL_R_COMPRESSION_ID_NOT_WITHIN_PRIVATE_RANGE    307\n# define SSL_R_COMPRESSION_LIBRARY_ERROR                  142\n# define SSL_R_CONNECTION_ID_IS_DIFFERENT                 143\n# define SSL_R_CONNECTION_TYPE_NOT_SET                    144\n# define SSL_R_COOKIE_MISMATCH                            308\n# define SSL_R_DATA_BETWEEN_CCS_AND_FINISHED              145\n# define SSL_R_DATA_LENGTH_TOO_LONG                       146\n# define SSL_R_DECRYPTION_FAILED                          147\n# define SSL_R_DECRYPTION_FAILED_OR_BAD_RECORD_MAC        281\n# define SSL_R_DH_KEY_TOO_SMALL                           372\n# define SSL_R_DH_PUBLIC_VALUE_LENGTH_IS_WRONG            148\n# define SSL_R_DIGEST_CHECK_FAILED                        149\n# define SSL_R_DTLS_MESSAGE_TOO_BIG                       334\n# define SSL_R_DUPLICATE_COMPRESSION_ID                   309\n# define SSL_R_ECC_CERT_NOT_FOR_KEY_AGREEMENT             317\n# define SSL_R_ECC_CERT_NOT_FOR_SIGNING                   318\n# define SSL_R_ECC_CERT_SHOULD_HAVE_RSA_SIGNATURE         322\n# define SSL_R_ECC_CERT_SHOULD_HAVE_SHA1_SIGNATURE        323\n# define SSL_R_ECDH_REQUIRED_FOR_SUITEB_MODE              374\n# define SSL_R_ECGROUP_TOO_LARGE_FOR_CIPHER               310\n# define SSL_R_EMPTY_SRTP_PROTECTION_PROFILE_LIST         354\n# define SSL_R_ENCRYPTED_LENGTH_TOO_LONG                  150\n# define SSL_R_ERROR_GENERATING_TMP_RSA_KEY               282\n# define SSL_R_ERROR_IN_RECEIVED_CIPHER_LIST              151\n# define SSL_R_EXCESSIVE_MESSAGE_SIZE                     152\n# define SSL_R_EXTRA_DATA_IN_MESSAGE                      153\n# define SSL_R_GOT_A_FIN_BEFORE_A_CCS                     154\n# define SSL_R_GOT_NEXT_PROTO_BEFORE_A_CCS                355\n# define SSL_R_GOT_NEXT_PROTO_WITHOUT_EXTENSION           356\n# define SSL_R_HTTPS_PROXY_REQUEST                        155\n# define SSL_R_HTTP_REQUEST                               156\n# define SSL_R_ILLEGAL_PADDING                            283\n# define SSL_R_ILLEGAL_SUITEB_DIGEST                      380\n# define SSL_R_INAPPROPRIATE_FALLBACK                     373\n# define SSL_R_INCONSISTENT_COMPRESSION                   340\n# define SSL_R_INVALID_CHALLENGE_LENGTH                   158\n# define SSL_R_INVALID_COMMAND                            280\n# define SSL_R_INVALID_COMPRESSION_ALGORITHM              341\n# define SSL_R_INVALID_NULL_CMD_NAME                      385\n# define SSL_R_INVALID_PURPOSE                            278\n# define SSL_R_INVALID_SERVERINFO_DATA                    388\n# define SSL_R_INVALID_SRP_USERNAME                       357\n# define SSL_R_INVALID_STATUS_RESPONSE                    328\n# define SSL_R_INVALID_TICKET_KEYS_LENGTH                 325\n# define SSL_R_INVALID_TRUST                              279\n# define SSL_R_KEY_ARG_TOO_LONG                           284\n# define SSL_R_KRB5                                       285\n# define SSL_R_KRB5_C_CC_PRINC                            286\n# define SSL_R_KRB5_C_GET_CRED                            287\n# define SSL_R_KRB5_C_INIT                                288\n# define SSL_R_KRB5_C_MK_REQ                              289\n# define SSL_R_KRB5_S_BAD_TICKET                          290\n# define SSL_R_KRB5_S_INIT                                291\n# define SSL_R_KRB5_S_RD_REQ                              292\n# define SSL_R_KRB5_S_TKT_EXPIRED                         293\n# define SSL_R_KRB5_S_TKT_NYV                             294\n# define SSL_R_KRB5_S_TKT_SKEW                            295\n# define SSL_R_LENGTH_MISMATCH                            159\n# define SSL_R_LENGTH_TOO_SHORT                           160\n# define SSL_R_LIBRARY_BUG                                274\n# define SSL_R_LIBRARY_HAS_NO_CIPHERS                     161\n# define SSL_R_MESSAGE_TOO_LONG                           296\n# define SSL_R_MISSING_DH_DSA_CERT                        162\n# define SSL_R_MISSING_DH_KEY                             163\n# define SSL_R_MISSING_DH_RSA_CERT                        164\n# define SSL_R_MISSING_DSA_SIGNING_CERT                   165\n# define SSL_R_MISSING_ECDH_CERT                          382\n# define SSL_R_MISSING_ECDSA_SIGNING_CERT                 381\n# define SSL_R_MISSING_EXPORT_TMP_DH_KEY                  166\n# define SSL_R_MISSING_EXPORT_TMP_RSA_KEY                 167\n# define SSL_R_MISSING_RSA_CERTIFICATE                    168\n# define SSL_R_MISSING_RSA_ENCRYPTING_CERT                169\n# define SSL_R_MISSING_RSA_SIGNING_CERT                   170\n# define SSL_R_MISSING_SRP_PARAM                          358\n# define SSL_R_MISSING_TMP_DH_KEY                         171\n# define SSL_R_MISSING_TMP_ECDH_KEY                       311\n# define SSL_R_MISSING_TMP_RSA_KEY                        172\n# define SSL_R_MISSING_TMP_RSA_PKEY                       173\n# define SSL_R_MISSING_VERIFY_MESSAGE                     174\n# define SSL_R_MULTIPLE_SGC_RESTARTS                      346\n# define SSL_R_NON_SSLV2_INITIAL_PACKET                   175\n# define SSL_R_NO_CERTIFICATES_RETURNED                   176\n# define SSL_R_NO_CERTIFICATE_ASSIGNED                    177\n# define SSL_R_NO_CERTIFICATE_RETURNED                    178\n# define SSL_R_NO_CERTIFICATE_SET                         179\n# define SSL_R_NO_CERTIFICATE_SPECIFIED                   180\n# define SSL_R_NO_CIPHERS_AVAILABLE                       181\n# define SSL_R_NO_CIPHERS_PASSED                          182\n# define SSL_R_NO_CIPHERS_SPECIFIED                       183\n# define SSL_R_NO_CIPHER_LIST                             184\n# define SSL_R_NO_CIPHER_MATCH                            185\n# define SSL_R_NO_CLIENT_CERT_METHOD                      331\n# define SSL_R_NO_CLIENT_CERT_RECEIVED                    186\n# define SSL_R_NO_COMPRESSION_SPECIFIED                   187\n# define SSL_R_NO_GOST_CERTIFICATE_SENT_BY_PEER           330\n# define SSL_R_NO_METHOD_SPECIFIED                        188\n# define SSL_R_NO_PEM_EXTENSIONS                          389\n# define SSL_R_NO_PRIVATEKEY                              189\n# define SSL_R_NO_PRIVATE_KEY_ASSIGNED                    190\n# define SSL_R_NO_PROTOCOLS_AVAILABLE                     191\n# define SSL_R_NO_PUBLICKEY                               192\n# define SSL_R_NO_RENEGOTIATION                           339\n# define SSL_R_NO_REQUIRED_DIGEST                         324\n# define SSL_R_NO_SHARED_CIPHER                           193\n# define SSL_R_NO_SHARED_SIGATURE_ALGORITHMS              376\n# define SSL_R_NO_SRTP_PROFILES                           359\n# define SSL_R_NO_VERIFY_CALLBACK                         194\n# define SSL_R_NULL_SSL_CTX                               195\n# define SSL_R_NULL_SSL_METHOD_PASSED                     196\n# define SSL_R_OLD_SESSION_CIPHER_NOT_RETURNED            197\n# define SSL_R_OLD_SESSION_COMPRESSION_ALGORITHM_NOT_RETURNED 344\n# define SSL_R_ONLY_DTLS_1_2_ALLOWED_IN_SUITEB_MODE       387\n# define SSL_R_ONLY_TLS_1_2_ALLOWED_IN_SUITEB_MODE        379\n# define SSL_R_ONLY_TLS_ALLOWED_IN_FIPS_MODE              297\n# define SSL_R_OPAQUE_PRF_INPUT_TOO_LONG                  327\n# define SSL_R_PACKET_LENGTH_TOO_LONG                     198\n# define SSL_R_PARSE_TLSEXT                               227\n# define SSL_R_PATH_TOO_LONG                              270\n# define SSL_R_PEER_DID_NOT_RETURN_A_CERTIFICATE          199\n# define SSL_R_PEER_ERROR                                 200\n# define SSL_R_PEER_ERROR_CERTIFICATE                     201\n# define SSL_R_PEER_ERROR_NO_CERTIFICATE                  202\n# define SSL_R_PEER_ERROR_NO_CIPHER                       203\n# define SSL_R_PEER_ERROR_UNSUPPORTED_CERTIFICATE_TYPE    204\n# define SSL_R_PEM_NAME_BAD_PREFIX                        391\n# define SSL_R_PEM_NAME_TOO_SHORT                         392\n# define SSL_R_PRE_MAC_LENGTH_TOO_LONG                    205\n# define SSL_R_PROBLEMS_MAPPING_CIPHER_FUNCTIONS          206\n# define SSL_R_PROTOCOL_IS_SHUTDOWN                       207\n# define SSL_R_PSK_IDENTITY_NOT_FOUND                     223\n# define SSL_R_PSK_NO_CLIENT_CB                           224\n# define SSL_R_PSK_NO_SERVER_CB                           225\n# define SSL_R_PUBLIC_KEY_ENCRYPT_ERROR                   208\n# define SSL_R_PUBLIC_KEY_IS_NOT_RSA                      209\n# define SSL_R_PUBLIC_KEY_NOT_RSA                         210\n# define SSL_R_READ_BIO_NOT_SET                           211\n# define SSL_R_READ_TIMEOUT_EXPIRED                       312\n# define SSL_R_READ_WRONG_PACKET_TYPE                     212\n# define SSL_R_RECORD_LENGTH_MISMATCH                     213\n# define SSL_R_RECORD_TOO_LARGE                           214\n# define SSL_R_RECORD_TOO_SMALL                           298\n# define SSL_R_RENEGOTIATE_EXT_TOO_LONG                   335\n# define SSL_R_RENEGOTIATION_ENCODING_ERR                 336\n# define SSL_R_RENEGOTIATION_MISMATCH                     337\n# define SSL_R_REQUIRED_CIPHER_MISSING                    215\n# define SSL_R_REQUIRED_COMPRESSSION_ALGORITHM_MISSING    342\n# define SSL_R_REUSE_CERT_LENGTH_NOT_ZERO                 216\n# define SSL_R_REUSE_CERT_TYPE_NOT_ZERO                   217\n# define SSL_R_REUSE_CIPHER_LIST_NOT_ZERO                 218\n# define SSL_R_SCSV_RECEIVED_WHEN_RENEGOTIATING           345\n# define SSL_R_SERVERHELLO_TLSEXT                         275\n# define SSL_R_SESSION_ID_CONTEXT_UNINITIALIZED           277\n# define SSL_R_SHORT_READ                                 219\n# define SSL_R_SHUTDOWN_WHILE_IN_INIT                     407\n# define SSL_R_SIGNATURE_ALGORITHMS_ERROR                 360\n# define SSL_R_SIGNATURE_FOR_NON_SIGNING_CERTIFICATE      220\n# define SSL_R_SRP_A_CALC                                 361\n# define SSL_R_SRTP_COULD_NOT_ALLOCATE_PROFILES           362\n# define SSL_R_SRTP_PROTECTION_PROFILE_LIST_TOO_LONG      363\n# define SSL_R_SRTP_UNKNOWN_PROTECTION_PROFILE            364\n# define SSL_R_SSL23_DOING_SESSION_ID_REUSE               221\n# define SSL_R_SSL2_CONNECTION_ID_TOO_LONG                299\n# define SSL_R_SSL3_EXT_INVALID_ECPOINTFORMAT             321\n# define SSL_R_SSL3_EXT_INVALID_SERVERNAME                319\n# define SSL_R_SSL3_EXT_INVALID_SERVERNAME_TYPE           320\n# define SSL_R_SSL3_SESSION_ID_TOO_LONG                   300\n# define SSL_R_SSL3_SESSION_ID_TOO_SHORT                  222\n# define SSL_R_SSLV3_ALERT_BAD_CERTIFICATE                1042\n# define SSL_R_SSLV3_ALERT_BAD_RECORD_MAC                 1020\n# define SSL_R_SSLV3_ALERT_CERTIFICATE_EXPIRED            1045\n# define SSL_R_SSLV3_ALERT_CERTIFICATE_REVOKED            1044\n# define SSL_R_SSLV3_ALERT_CERTIFICATE_UNKNOWN            1046\n# define SSL_R_SSLV3_ALERT_DECOMPRESSION_FAILURE          1030\n# define SSL_R_SSLV3_ALERT_HANDSHAKE_FAILURE              1040\n# define SSL_R_SSLV3_ALERT_ILLEGAL_PARAMETER              1047\n# define SSL_R_SSLV3_ALERT_NO_CERTIFICATE                 1041\n# define SSL_R_SSLV3_ALERT_UNEXPECTED_MESSAGE             1010\n# define SSL_R_SSLV3_ALERT_UNSUPPORTED_CERTIFICATE        1043\n# define SSL_R_SSL_CTX_HAS_NO_DEFAULT_SSL_VERSION         228\n# define SSL_R_SSL_HANDSHAKE_FAILURE                      229\n# define SSL_R_SSL_LIBRARY_HAS_NO_CIPHERS                 230\n# define SSL_R_SSL_SESSION_ID_CALLBACK_FAILED             301\n# define SSL_R_SSL_SESSION_ID_CONFLICT                    302\n# define SSL_R_SSL_SESSION_ID_CONTEXT_TOO_LONG            273\n# define SSL_R_SSL_SESSION_ID_HAS_BAD_LENGTH              303\n# define SSL_R_SSL_SESSION_ID_IS_DIFFERENT                231\n# define SSL_R_TLSV1_ALERT_ACCESS_DENIED                  1049\n# define SSL_R_TLSV1_ALERT_DECODE_ERROR                   1050\n# define SSL_R_TLSV1_ALERT_DECRYPTION_FAILED              1021\n# define SSL_R_TLSV1_ALERT_DECRYPT_ERROR                  1051\n# define SSL_R_TLSV1_ALERT_EXPORT_RESTRICTION             1060\n# define SSL_R_TLSV1_ALERT_INAPPROPRIATE_FALLBACK         1086\n# define SSL_R_TLSV1_ALERT_INSUFFICIENT_SECURITY          1071\n# define SSL_R_TLSV1_ALERT_INTERNAL_ERROR                 1080\n# define SSL_R_TLSV1_ALERT_NO_RENEGOTIATION               1100\n# define SSL_R_TLSV1_ALERT_PROTOCOL_VERSION               1070\n# define SSL_R_TLSV1_ALERT_RECORD_OVERFLOW                1022\n# define SSL_R_TLSV1_ALERT_UNKNOWN_CA                     1048\n# define SSL_R_TLSV1_ALERT_USER_CANCELLED                 1090\n# define SSL_R_TLSV1_BAD_CERTIFICATE_HASH_VALUE           1114\n# define SSL_R_TLSV1_BAD_CERTIFICATE_STATUS_RESPONSE      1113\n# define SSL_R_TLSV1_CERTIFICATE_UNOBTAINABLE             1111\n# define SSL_R_TLSV1_UNRECOGNIZED_NAME                    1112\n# define SSL_R_TLSV1_UNSUPPORTED_EXTENSION                1110\n# define SSL_R_TLS_CLIENT_CERT_REQ_WITH_ANON_CIPHER       232\n# define SSL_R_TLS_HEARTBEAT_PEER_DOESNT_ACCEPT           365\n# define SSL_R_TLS_HEARTBEAT_PENDING                      366\n# define SSL_R_TLS_ILLEGAL_EXPORTER_LABEL                 367\n# define SSL_R_TLS_INVALID_ECPOINTFORMAT_LIST             157\n# define SSL_R_TLS_PEER_DID_NOT_RESPOND_WITH_CERTIFICATE_LIST 233\n# define SSL_R_TLS_RSA_ENCRYPTED_VALUE_LENGTH_IS_WRONG    234\n# define SSL_R_TRIED_TO_USE_UNSUPPORTED_CIPHER            235\n# define SSL_R_UNABLE_TO_DECODE_DH_CERTS                  236\n# define SSL_R_UNABLE_TO_DECODE_ECDH_CERTS                313\n# define SSL_R_UNABLE_TO_EXTRACT_PUBLIC_KEY               237\n# define SSL_R_UNABLE_TO_FIND_DH_PARAMETERS               238\n# define SSL_R_UNABLE_TO_FIND_ECDH_PARAMETERS             314\n# define SSL_R_UNABLE_TO_FIND_PUBLIC_KEY_PARAMETERS       239\n# define SSL_R_UNABLE_TO_FIND_SSL_METHOD                  240\n# define SSL_R_UNABLE_TO_LOAD_SSL2_MD5_ROUTINES           241\n# define SSL_R_UNABLE_TO_LOAD_SSL3_MD5_ROUTINES           242\n# define SSL_R_UNABLE_TO_LOAD_SSL3_SHA1_ROUTINES          243\n# define SSL_R_UNEXPECTED_MESSAGE                         244\n# define SSL_R_UNEXPECTED_RECORD                          245\n# define SSL_R_UNINITIALIZED                              276\n# define SSL_R_UNKNOWN_ALERT_TYPE                         246\n# define SSL_R_UNKNOWN_CERTIFICATE_TYPE                   247\n# define SSL_R_UNKNOWN_CIPHER_RETURNED                    248\n# define SSL_R_UNKNOWN_CIPHER_TYPE                        249\n# define SSL_R_UNKNOWN_CMD_NAME                           386\n# define SSL_R_UNKNOWN_DIGEST                             368\n# define SSL_R_UNKNOWN_KEY_EXCHANGE_TYPE                  250\n# define SSL_R_UNKNOWN_PKEY_TYPE                          251\n# define SSL_R_UNKNOWN_PROTOCOL                           252\n# define SSL_R_UNKNOWN_REMOTE_ERROR_TYPE                  253\n# define SSL_R_UNKNOWN_SSL_VERSION                        254\n# define SSL_R_UNKNOWN_STATE                              255\n# define SSL_R_UNSAFE_LEGACY_RENEGOTIATION_DISABLED       338\n# define SSL_R_UNSUPPORTED_CIPHER                         256\n# define SSL_R_UNSUPPORTED_COMPRESSION_ALGORITHM          257\n# define SSL_R_UNSUPPORTED_DIGEST_TYPE                    326\n# define SSL_R_UNSUPPORTED_ELLIPTIC_CURVE                 315\n# define SSL_R_UNSUPPORTED_PROTOCOL                       258\n# define SSL_R_UNSUPPORTED_SSL_VERSION                    259\n# define SSL_R_UNSUPPORTED_STATUS_TYPE                    329\n# define SSL_R_USE_SRTP_NOT_NEGOTIATED                    369\n# define SSL_R_WRITE_BIO_NOT_SET                          260\n# define SSL_R_WRONG_CERTIFICATE_TYPE                     383\n# define SSL_R_WRONG_CIPHER_RETURNED                      261\n# define SSL_R_WRONG_CURVE                                378\n# define SSL_R_WRONG_MESSAGE_TYPE                         262\n# define SSL_R_WRONG_NUMBER_OF_KEY_BITS                   263\n# define SSL_R_WRONG_SIGNATURE_LENGTH                     264\n# define SSL_R_WRONG_SIGNATURE_SIZE                       265\n# define SSL_R_WRONG_SIGNATURE_TYPE                       370\n# define SSL_R_WRONG_SSL_VERSION                          266\n# define SSL_R_WRONG_VERSION_NUMBER                       267\n# define SSL_R_X509_LIB                                   268\n# define SSL_R_X509_VERIFICATION_SETUP_PROBLEMS           269\n\n#ifdef  __cplusplus\n}\n#endif\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/x86/include/openssl/ssl2.h",
    "content": "/* ssl/ssl2.h */\n/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)\n * All rights reserved.\n *\n * This package is an SSL implementation written\n * by Eric Young (eay@cryptsoft.com).\n * The implementation was written so as to conform with Netscapes SSL.\n *\n * This library is free for commercial and non-commercial use as long as\n * the following conditions are aheared to.  The following conditions\n * apply to all code found in this distribution, be it the RC4, RSA,\n * lhash, DES, etc., code; not just the SSL code.  The SSL documentation\n * included with this distribution is covered by the same copyright terms\n * except that the holder is Tim Hudson (tjh@cryptsoft.com).\n *\n * Copyright remains Eric Young's, and as such any Copyright notices in\n * the code are not to be removed.\n * If this package is used in a product, Eric Young should be given attribution\n * as the author of the parts of the library used.\n * This can be in the form of a textual message at program startup or\n * in documentation (online or textual) provided with the package.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the copyright\n *    notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in the\n *    documentation and/or other materials provided with the distribution.\n * 3. All advertising materials mentioning features or use of this software\n *    must display the following acknowledgement:\n *    \"This product includes cryptographic software written by\n *     Eric Young (eay@cryptsoft.com)\"\n *    The word 'cryptographic' can be left out if the rouines from the library\n *    being used are not cryptographic related :-).\n * 4. If you include any Windows specific code (or a derivative thereof) from\n *    the apps directory (application code) you must include an acknowledgement:\n *    \"This product includes software written by Tim Hudson (tjh@cryptsoft.com)\"\n *\n * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n * SUCH DAMAGE.\n *\n * The licence and distribution terms for any publically available version or\n * derivative of this code cannot be changed.  i.e. this code cannot simply be\n * copied and put under another distribution licence\n * [including the GNU Public Licence.]\n */\n\n#ifndef HEADER_SSL2_H\n# define HEADER_SSL2_H\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n/* Protocol Version Codes */\n# define SSL2_VERSION            0x0002\n# define SSL2_VERSION_MAJOR      0x00\n# define SSL2_VERSION_MINOR      0x02\n/* #define SSL2_CLIENT_VERSION  0x0002 */\n/* #define SSL2_SERVER_VERSION  0x0002 */\n\n/* Protocol Message Codes */\n# define SSL2_MT_ERROR                   0\n# define SSL2_MT_CLIENT_HELLO            1\n# define SSL2_MT_CLIENT_MASTER_KEY       2\n# define SSL2_MT_CLIENT_FINISHED         3\n# define SSL2_MT_SERVER_HELLO            4\n# define SSL2_MT_SERVER_VERIFY           5\n# define SSL2_MT_SERVER_FINISHED         6\n# define SSL2_MT_REQUEST_CERTIFICATE     7\n# define SSL2_MT_CLIENT_CERTIFICATE      8\n\n/* Error Message Codes */\n# define SSL2_PE_UNDEFINED_ERROR         0x0000\n# define SSL2_PE_NO_CIPHER               0x0001\n# define SSL2_PE_NO_CERTIFICATE          0x0002\n# define SSL2_PE_BAD_CERTIFICATE         0x0004\n# define SSL2_PE_UNSUPPORTED_CERTIFICATE_TYPE 0x0006\n\n/* Cipher Kind Values */\n# define SSL2_CK_NULL_WITH_MD5                   0x02000000/* v3 */\n# define SSL2_CK_RC4_128_WITH_MD5                0x02010080\n# define SSL2_CK_RC4_128_EXPORT40_WITH_MD5       0x02020080\n# define SSL2_CK_RC2_128_CBC_WITH_MD5            0x02030080\n# define SSL2_CK_RC2_128_CBC_EXPORT40_WITH_MD5   0x02040080\n# define SSL2_CK_IDEA_128_CBC_WITH_MD5           0x02050080\n# define SSL2_CK_DES_64_CBC_WITH_MD5             0x02060040\n# define SSL2_CK_DES_64_CBC_WITH_SHA             0x02060140/* v3 */\n# define SSL2_CK_DES_192_EDE3_CBC_WITH_MD5       0x020700c0\n# define SSL2_CK_DES_192_EDE3_CBC_WITH_SHA       0x020701c0/* v3 */\n# define SSL2_CK_RC4_64_WITH_MD5                 0x02080080/* MS hack */\n\n# define SSL2_CK_DES_64_CFB64_WITH_MD5_1         0x02ff0800/* SSLeay */\n# define SSL2_CK_NULL                            0x02ff0810/* SSLeay */\n\n# define SSL2_TXT_DES_64_CFB64_WITH_MD5_1        \"DES-CFB-M1\"\n# define SSL2_TXT_NULL_WITH_MD5                  \"NULL-MD5\"\n# define SSL2_TXT_RC4_128_WITH_MD5               \"RC4-MD5\"\n# define SSL2_TXT_RC4_128_EXPORT40_WITH_MD5      \"EXP-RC4-MD5\"\n# define SSL2_TXT_RC2_128_CBC_WITH_MD5           \"RC2-CBC-MD5\"\n# define SSL2_TXT_RC2_128_CBC_EXPORT40_WITH_MD5  \"EXP-RC2-CBC-MD5\"\n# define SSL2_TXT_IDEA_128_CBC_WITH_MD5          \"IDEA-CBC-MD5\"\n# define SSL2_TXT_DES_64_CBC_WITH_MD5            \"DES-CBC-MD5\"\n# define SSL2_TXT_DES_64_CBC_WITH_SHA            \"DES-CBC-SHA\"\n# define SSL2_TXT_DES_192_EDE3_CBC_WITH_MD5      \"DES-CBC3-MD5\"\n# define SSL2_TXT_DES_192_EDE3_CBC_WITH_SHA      \"DES-CBC3-SHA\"\n# define SSL2_TXT_RC4_64_WITH_MD5                \"RC4-64-MD5\"\n\n# define SSL2_TXT_NULL                           \"NULL\"\n\n/* Flags for the SSL_CIPHER.algorithm2 field */\n# define SSL2_CF_5_BYTE_ENC                      0x01\n# define SSL2_CF_8_BYTE_ENC                      0x02\n\n/* Certificate Type Codes */\n# define SSL2_CT_X509_CERTIFICATE                0x01\n\n/* Authentication Type Code */\n# define SSL2_AT_MD5_WITH_RSA_ENCRYPTION         0x01\n\n# define SSL2_MAX_SSL_SESSION_ID_LENGTH          32\n\n/* Upper/Lower Bounds */\n# define SSL2_MAX_MASTER_KEY_LENGTH_IN_BITS      256\n# ifdef OPENSSL_SYS_MPE\n#  define SSL2_MAX_RECORD_LENGTH_2_BYTE_HEADER    29998u\n# else\n#  define SSL2_MAX_RECORD_LENGTH_2_BYTE_HEADER    32767u\n                                                       /* 2^15-1 */\n# endif\n# define SSL2_MAX_RECORD_LENGTH_3_BYTE_HEADER    16383/* 2^14-1 */\n\n# define SSL2_CHALLENGE_LENGTH   16\n/*\n * #define SSL2_CHALLENGE_LENGTH 32\n */\n# define SSL2_MIN_CHALLENGE_LENGTH       16\n# define SSL2_MAX_CHALLENGE_LENGTH       32\n# define SSL2_CONNECTION_ID_LENGTH       16\n# define SSL2_MAX_CONNECTION_ID_LENGTH   16\n# define SSL2_SSL_SESSION_ID_LENGTH      16\n# define SSL2_MAX_CERT_CHALLENGE_LENGTH  32\n# define SSL2_MIN_CERT_CHALLENGE_LENGTH  16\n# define SSL2_MAX_KEY_MATERIAL_LENGTH    24\n\n# ifndef HEADER_SSL_LOCL_H\n#  define  CERT           char\n# endif\n\n# ifndef OPENSSL_NO_SSL_INTERN\n\ntypedef struct ssl2_state_st {\n    int three_byte_header;\n    int clear_text;             /* clear text */\n    int escape;                 /* not used in SSLv2 */\n    int ssl2_rollback;          /* used if SSLv23 rolled back to SSLv2 */\n    /*\n     * non-blocking io info, used to make sure the same args were passwd\n     */\n    unsigned int wnum;          /* number of bytes sent so far */\n    int wpend_tot;\n    const unsigned char *wpend_buf;\n    int wpend_off;              /* offset to data to write */\n    int wpend_len;              /* number of bytes passwd to write */\n    int wpend_ret;              /* number of bytes to return to caller */\n    /* buffer raw data */\n    int rbuf_left;\n    int rbuf_offs;\n    unsigned char *rbuf;\n    unsigned char *wbuf;\n    unsigned char *write_ptr;   /* used to point to the start due to 2/3 byte\n                                 * header. */\n    unsigned int padding;\n    unsigned int rlength;       /* passed to ssl2_enc */\n    int ract_data_length;       /* Set when things are encrypted. */\n    unsigned int wlength;       /* passed to ssl2_enc */\n    int wact_data_length;       /* Set when things are decrypted. */\n    unsigned char *ract_data;\n    unsigned char *wact_data;\n    unsigned char *mac_data;\n    unsigned char *read_key;\n    unsigned char *write_key;\n    /* Stuff specifically to do with this SSL session */\n    unsigned int challenge_length;\n    unsigned char challenge[SSL2_MAX_CHALLENGE_LENGTH];\n    unsigned int conn_id_length;\n    unsigned char conn_id[SSL2_MAX_CONNECTION_ID_LENGTH];\n    unsigned int key_material_length;\n    unsigned char key_material[SSL2_MAX_KEY_MATERIAL_LENGTH * 2];\n    unsigned long read_sequence;\n    unsigned long write_sequence;\n    struct {\n        unsigned int conn_id_length;\n        unsigned int cert_type;\n        unsigned int cert_length;\n        unsigned int csl;\n        unsigned int clear;\n        unsigned int enc;\n        unsigned char ccl[SSL2_MAX_CERT_CHALLENGE_LENGTH];\n        unsigned int cipher_spec_length;\n        unsigned int session_id_length;\n        unsigned int clen;\n        unsigned int rlen;\n    } tmp;\n} SSL2_STATE;\n\n# endif\n\n/* SSLv2 */\n/* client */\n# define SSL2_ST_SEND_CLIENT_HELLO_A             (0x10|SSL_ST_CONNECT)\n# define SSL2_ST_SEND_CLIENT_HELLO_B             (0x11|SSL_ST_CONNECT)\n# define SSL2_ST_GET_SERVER_HELLO_A              (0x20|SSL_ST_CONNECT)\n# define SSL2_ST_GET_SERVER_HELLO_B              (0x21|SSL_ST_CONNECT)\n# define SSL2_ST_SEND_CLIENT_MASTER_KEY_A        (0x30|SSL_ST_CONNECT)\n# define SSL2_ST_SEND_CLIENT_MASTER_KEY_B        (0x31|SSL_ST_CONNECT)\n# define SSL2_ST_SEND_CLIENT_FINISHED_A          (0x40|SSL_ST_CONNECT)\n# define SSL2_ST_SEND_CLIENT_FINISHED_B          (0x41|SSL_ST_CONNECT)\n# define SSL2_ST_SEND_CLIENT_CERTIFICATE_A       (0x50|SSL_ST_CONNECT)\n# define SSL2_ST_SEND_CLIENT_CERTIFICATE_B       (0x51|SSL_ST_CONNECT)\n# define SSL2_ST_SEND_CLIENT_CERTIFICATE_C       (0x52|SSL_ST_CONNECT)\n# define SSL2_ST_SEND_CLIENT_CERTIFICATE_D       (0x53|SSL_ST_CONNECT)\n# define SSL2_ST_GET_SERVER_VERIFY_A             (0x60|SSL_ST_CONNECT)\n# define SSL2_ST_GET_SERVER_VERIFY_B             (0x61|SSL_ST_CONNECT)\n# define SSL2_ST_GET_SERVER_FINISHED_A           (0x70|SSL_ST_CONNECT)\n# define SSL2_ST_GET_SERVER_FINISHED_B           (0x71|SSL_ST_CONNECT)\n# define SSL2_ST_CLIENT_START_ENCRYPTION         (0x80|SSL_ST_CONNECT)\n# define SSL2_ST_X509_GET_CLIENT_CERTIFICATE     (0x90|SSL_ST_CONNECT)\n/* server */\n# define SSL2_ST_GET_CLIENT_HELLO_A              (0x10|SSL_ST_ACCEPT)\n# define SSL2_ST_GET_CLIENT_HELLO_B              (0x11|SSL_ST_ACCEPT)\n# define SSL2_ST_GET_CLIENT_HELLO_C              (0x12|SSL_ST_ACCEPT)\n# define SSL2_ST_SEND_SERVER_HELLO_A             (0x20|SSL_ST_ACCEPT)\n# define SSL2_ST_SEND_SERVER_HELLO_B             (0x21|SSL_ST_ACCEPT)\n# define SSL2_ST_GET_CLIENT_MASTER_KEY_A         (0x30|SSL_ST_ACCEPT)\n# define SSL2_ST_GET_CLIENT_MASTER_KEY_B         (0x31|SSL_ST_ACCEPT)\n# define SSL2_ST_SEND_SERVER_VERIFY_A            (0x40|SSL_ST_ACCEPT)\n# define SSL2_ST_SEND_SERVER_VERIFY_B            (0x41|SSL_ST_ACCEPT)\n# define SSL2_ST_SEND_SERVER_VERIFY_C            (0x42|SSL_ST_ACCEPT)\n# define SSL2_ST_GET_CLIENT_FINISHED_A           (0x50|SSL_ST_ACCEPT)\n# define SSL2_ST_GET_CLIENT_FINISHED_B           (0x51|SSL_ST_ACCEPT)\n# define SSL2_ST_SEND_SERVER_FINISHED_A          (0x60|SSL_ST_ACCEPT)\n# define SSL2_ST_SEND_SERVER_FINISHED_B          (0x61|SSL_ST_ACCEPT)\n# define SSL2_ST_SEND_REQUEST_CERTIFICATE_A      (0x70|SSL_ST_ACCEPT)\n# define SSL2_ST_SEND_REQUEST_CERTIFICATE_B      (0x71|SSL_ST_ACCEPT)\n# define SSL2_ST_SEND_REQUEST_CERTIFICATE_C      (0x72|SSL_ST_ACCEPT)\n# define SSL2_ST_SEND_REQUEST_CERTIFICATE_D      (0x73|SSL_ST_ACCEPT)\n# define SSL2_ST_SERVER_START_ENCRYPTION         (0x80|SSL_ST_ACCEPT)\n# define SSL2_ST_X509_GET_SERVER_CERTIFICATE     (0x90|SSL_ST_ACCEPT)\n\n#ifdef  __cplusplus\n}\n#endif\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/x86/include/openssl/ssl23.h",
    "content": "/* ssl/ssl23.h */\n/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)\n * All rights reserved.\n *\n * This package is an SSL implementation written\n * by Eric Young (eay@cryptsoft.com).\n * The implementation was written so as to conform with Netscapes SSL.\n *\n * This library is free for commercial and non-commercial use as long as\n * the following conditions are aheared to.  The following conditions\n * apply to all code found in this distribution, be it the RC4, RSA,\n * lhash, DES, etc., code; not just the SSL code.  The SSL documentation\n * included with this distribution is covered by the same copyright terms\n * except that the holder is Tim Hudson (tjh@cryptsoft.com).\n *\n * Copyright remains Eric Young's, and as such any Copyright notices in\n * the code are not to be removed.\n * If this package is used in a product, Eric Young should be given attribution\n * as the author of the parts of the library used.\n * This can be in the form of a textual message at program startup or\n * in documentation (online or textual) provided with the package.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the copyright\n *    notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in the\n *    documentation and/or other materials provided with the distribution.\n * 3. All advertising materials mentioning features or use of this software\n *    must display the following acknowledgement:\n *    \"This product includes cryptographic software written by\n *     Eric Young (eay@cryptsoft.com)\"\n *    The word 'cryptographic' can be left out if the rouines from the library\n *    being used are not cryptographic related :-).\n * 4. If you include any Windows specific code (or a derivative thereof) from\n *    the apps directory (application code) you must include an acknowledgement:\n *    \"This product includes software written by Tim Hudson (tjh@cryptsoft.com)\"\n *\n * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n * SUCH DAMAGE.\n *\n * The licence and distribution terms for any publically available version or\n * derivative of this code cannot be changed.  i.e. this code cannot simply be\n * copied and put under another distribution licence\n * [including the GNU Public Licence.]\n */\n\n#ifndef HEADER_SSL23_H\n# define HEADER_SSL23_H\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n/*\n * client\n */\n/* write to server */\n# define SSL23_ST_CW_CLNT_HELLO_A        (0x210|SSL_ST_CONNECT)\n# define SSL23_ST_CW_CLNT_HELLO_B        (0x211|SSL_ST_CONNECT)\n/* read from server */\n# define SSL23_ST_CR_SRVR_HELLO_A        (0x220|SSL_ST_CONNECT)\n# define SSL23_ST_CR_SRVR_HELLO_B        (0x221|SSL_ST_CONNECT)\n\n/* server */\n/* read from client */\n# define SSL23_ST_SR_CLNT_HELLO_A        (0x210|SSL_ST_ACCEPT)\n# define SSL23_ST_SR_CLNT_HELLO_B        (0x211|SSL_ST_ACCEPT)\n\n#ifdef  __cplusplus\n}\n#endif\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/x86/include/openssl/ssl3.h",
    "content": "/* ssl/ssl3.h */\n/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)\n * All rights reserved.\n *\n * This package is an SSL implementation written\n * by Eric Young (eay@cryptsoft.com).\n * The implementation was written so as to conform with Netscapes SSL.\n *\n * This library is free for commercial and non-commercial use as long as\n * the following conditions are aheared to.  The following conditions\n * apply to all code found in this distribution, be it the RC4, RSA,\n * lhash, DES, etc., code; not just the SSL code.  The SSL documentation\n * included with this distribution is covered by the same copyright terms\n * except that the holder is Tim Hudson (tjh@cryptsoft.com).\n *\n * Copyright remains Eric Young's, and as such any Copyright notices in\n * the code are not to be removed.\n * If this package is used in a product, Eric Young should be given attribution\n * as the author of the parts of the library used.\n * This can be in the form of a textual message at program startup or\n * in documentation (online or textual) provided with the package.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the copyright\n *    notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in the\n *    documentation and/or other materials provided with the distribution.\n * 3. All advertising materials mentioning features or use of this software\n *    must display the following acknowledgement:\n *    \"This product includes cryptographic software written by\n *     Eric Young (eay@cryptsoft.com)\"\n *    The word 'cryptographic' can be left out if the rouines from the library\n *    being used are not cryptographic related :-).\n * 4. If you include any Windows specific code (or a derivative thereof) from\n *    the apps directory (application code) you must include an acknowledgement:\n *    \"This product includes software written by Tim Hudson (tjh@cryptsoft.com)\"\n *\n * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n * SUCH DAMAGE.\n *\n * The licence and distribution terms for any publically available version or\n * derivative of this code cannot be changed.  i.e. this code cannot simply be\n * copied and put under another distribution licence\n * [including the GNU Public Licence.]\n */\n/* ====================================================================\n * Copyright (c) 1998-2002 The OpenSSL Project.  All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n *\n * 1. Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n *\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in\n *    the documentation and/or other materials provided with the\n *    distribution.\n *\n * 3. All advertising materials mentioning features or use of this\n *    software must display the following acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit. (http://www.openssl.org/)\"\n *\n * 4. The names \"OpenSSL Toolkit\" and \"OpenSSL Project\" must not be used to\n *    endorse or promote products derived from this software without\n *    prior written permission. For written permission, please contact\n *    openssl-core@openssl.org.\n *\n * 5. Products derived from this software may not be called \"OpenSSL\"\n *    nor may \"OpenSSL\" appear in their names without prior written\n *    permission of the OpenSSL Project.\n *\n * 6. Redistributions of any form whatsoever must retain the following\n *    acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit (http://www.openssl.org/)\"\n *\n * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY\n * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\n * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR\n * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\n * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,\n * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED\n * OF THE POSSIBILITY OF SUCH DAMAGE.\n * ====================================================================\n *\n * This product includes cryptographic software written by Eric Young\n * (eay@cryptsoft.com).  This product includes software written by Tim\n * Hudson (tjh@cryptsoft.com).\n *\n */\n/* ====================================================================\n * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED.\n * ECC cipher suite support in OpenSSL originally developed by\n * SUN MICROSYSTEMS, INC., and contributed to the OpenSSL project.\n */\n\n#ifndef HEADER_SSL3_H\n# define HEADER_SSL3_H\n\n# ifndef OPENSSL_NO_COMP\n#  include <openssl/comp.h>\n# endif\n# include <openssl/buffer.h>\n# include <openssl/evp.h>\n# include <openssl/ssl.h>\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n/*\n * Signalling cipher suite value from RFC 5746\n * (TLS_EMPTY_RENEGOTIATION_INFO_SCSV)\n */\n# define SSL3_CK_SCSV                            0x030000FF\n\n/*\n * Signalling cipher suite value from draft-ietf-tls-downgrade-scsv-00\n * (TLS_FALLBACK_SCSV)\n */\n# define SSL3_CK_FALLBACK_SCSV                   0x03005600\n\n# define SSL3_CK_RSA_NULL_MD5                    0x03000001\n# define SSL3_CK_RSA_NULL_SHA                    0x03000002\n# define SSL3_CK_RSA_RC4_40_MD5                  0x03000003\n# define SSL3_CK_RSA_RC4_128_MD5                 0x03000004\n# define SSL3_CK_RSA_RC4_128_SHA                 0x03000005\n# define SSL3_CK_RSA_RC2_40_MD5                  0x03000006\n# define SSL3_CK_RSA_IDEA_128_SHA                0x03000007\n# define SSL3_CK_RSA_DES_40_CBC_SHA              0x03000008\n# define SSL3_CK_RSA_DES_64_CBC_SHA              0x03000009\n# define SSL3_CK_RSA_DES_192_CBC3_SHA            0x0300000A\n\n# define SSL3_CK_DH_DSS_DES_40_CBC_SHA           0x0300000B\n# define SSL3_CK_DH_DSS_DES_64_CBC_SHA           0x0300000C\n# define SSL3_CK_DH_DSS_DES_192_CBC3_SHA         0x0300000D\n# define SSL3_CK_DH_RSA_DES_40_CBC_SHA           0x0300000E\n# define SSL3_CK_DH_RSA_DES_64_CBC_SHA           0x0300000F\n# define SSL3_CK_DH_RSA_DES_192_CBC3_SHA         0x03000010\n\n# define SSL3_CK_EDH_DSS_DES_40_CBC_SHA          0x03000011\n# define SSL3_CK_DHE_DSS_DES_40_CBC_SHA          SSL3_CK_EDH_DSS_DES_40_CBC_SHA\n# define SSL3_CK_EDH_DSS_DES_64_CBC_SHA          0x03000012\n# define SSL3_CK_DHE_DSS_DES_64_CBC_SHA          SSL3_CK_EDH_DSS_DES_64_CBC_SHA\n# define SSL3_CK_EDH_DSS_DES_192_CBC3_SHA        0x03000013\n# define SSL3_CK_DHE_DSS_DES_192_CBC3_SHA        SSL3_CK_EDH_DSS_DES_192_CBC3_SHA\n# define SSL3_CK_EDH_RSA_DES_40_CBC_SHA          0x03000014\n# define SSL3_CK_DHE_RSA_DES_40_CBC_SHA          SSL3_CK_EDH_RSA_DES_40_CBC_SHA\n# define SSL3_CK_EDH_RSA_DES_64_CBC_SHA          0x03000015\n# define SSL3_CK_DHE_RSA_DES_64_CBC_SHA          SSL3_CK_EDH_RSA_DES_64_CBC_SHA\n# define SSL3_CK_EDH_RSA_DES_192_CBC3_SHA        0x03000016\n# define SSL3_CK_DHE_RSA_DES_192_CBC3_SHA        SSL3_CK_EDH_RSA_DES_192_CBC3_SHA\n\n# define SSL3_CK_ADH_RC4_40_MD5                  0x03000017\n# define SSL3_CK_ADH_RC4_128_MD5                 0x03000018\n# define SSL3_CK_ADH_DES_40_CBC_SHA              0x03000019\n# define SSL3_CK_ADH_DES_64_CBC_SHA              0x0300001A\n# define SSL3_CK_ADH_DES_192_CBC_SHA             0x0300001B\n\n# if 0\n#  define SSL3_CK_FZA_DMS_NULL_SHA                0x0300001C\n#  define SSL3_CK_FZA_DMS_FZA_SHA                 0x0300001D\n#  if 0                         /* Because it clashes with KRB5, is never\n                                 * used any more, and is safe to remove\n                                 * according to David Hopwood\n                                 * <david.hopwood@zetnet.co.uk> of the\n                                 * ietf-tls list */\n#   define SSL3_CK_FZA_DMS_RC4_SHA                 0x0300001E\n#  endif\n# endif\n\n/*\n * VRS Additional Kerberos5 entries\n */\n# define SSL3_CK_KRB5_DES_64_CBC_SHA             0x0300001E\n# define SSL3_CK_KRB5_DES_192_CBC3_SHA           0x0300001F\n# define SSL3_CK_KRB5_RC4_128_SHA                0x03000020\n# define SSL3_CK_KRB5_IDEA_128_CBC_SHA           0x03000021\n# define SSL3_CK_KRB5_DES_64_CBC_MD5             0x03000022\n# define SSL3_CK_KRB5_DES_192_CBC3_MD5           0x03000023\n# define SSL3_CK_KRB5_RC4_128_MD5                0x03000024\n# define SSL3_CK_KRB5_IDEA_128_CBC_MD5           0x03000025\n\n# define SSL3_CK_KRB5_DES_40_CBC_SHA             0x03000026\n# define SSL3_CK_KRB5_RC2_40_CBC_SHA             0x03000027\n# define SSL3_CK_KRB5_RC4_40_SHA                 0x03000028\n# define SSL3_CK_KRB5_DES_40_CBC_MD5             0x03000029\n# define SSL3_CK_KRB5_RC2_40_CBC_MD5             0x0300002A\n# define SSL3_CK_KRB5_RC4_40_MD5                 0x0300002B\n\n# define SSL3_TXT_RSA_NULL_MD5                   \"NULL-MD5\"\n# define SSL3_TXT_RSA_NULL_SHA                   \"NULL-SHA\"\n# define SSL3_TXT_RSA_RC4_40_MD5                 \"EXP-RC4-MD5\"\n# define SSL3_TXT_RSA_RC4_128_MD5                \"RC4-MD5\"\n# define SSL3_TXT_RSA_RC4_128_SHA                \"RC4-SHA\"\n# define SSL3_TXT_RSA_RC2_40_MD5                 \"EXP-RC2-CBC-MD5\"\n# define SSL3_TXT_RSA_IDEA_128_SHA               \"IDEA-CBC-SHA\"\n# define SSL3_TXT_RSA_DES_40_CBC_SHA             \"EXP-DES-CBC-SHA\"\n# define SSL3_TXT_RSA_DES_64_CBC_SHA             \"DES-CBC-SHA\"\n# define SSL3_TXT_RSA_DES_192_CBC3_SHA           \"DES-CBC3-SHA\"\n\n# define SSL3_TXT_DH_DSS_DES_40_CBC_SHA          \"EXP-DH-DSS-DES-CBC-SHA\"\n# define SSL3_TXT_DH_DSS_DES_64_CBC_SHA          \"DH-DSS-DES-CBC-SHA\"\n# define SSL3_TXT_DH_DSS_DES_192_CBC3_SHA        \"DH-DSS-DES-CBC3-SHA\"\n# define SSL3_TXT_DH_RSA_DES_40_CBC_SHA          \"EXP-DH-RSA-DES-CBC-SHA\"\n# define SSL3_TXT_DH_RSA_DES_64_CBC_SHA          \"DH-RSA-DES-CBC-SHA\"\n# define SSL3_TXT_DH_RSA_DES_192_CBC3_SHA        \"DH-RSA-DES-CBC3-SHA\"\n\n# define SSL3_TXT_DHE_DSS_DES_40_CBC_SHA         \"EXP-DHE-DSS-DES-CBC-SHA\"\n# define SSL3_TXT_DHE_DSS_DES_64_CBC_SHA         \"DHE-DSS-DES-CBC-SHA\"\n# define SSL3_TXT_DHE_DSS_DES_192_CBC3_SHA       \"DHE-DSS-DES-CBC3-SHA\"\n# define SSL3_TXT_DHE_RSA_DES_40_CBC_SHA         \"EXP-DHE-RSA-DES-CBC-SHA\"\n# define SSL3_TXT_DHE_RSA_DES_64_CBC_SHA         \"DHE-RSA-DES-CBC-SHA\"\n# define SSL3_TXT_DHE_RSA_DES_192_CBC3_SHA       \"DHE-RSA-DES-CBC3-SHA\"\n\n/*\n * This next block of six \"EDH\" labels is for backward compatibility with\n * older versions of OpenSSL.  New code should use the six \"DHE\" labels above\n * instead:\n */\n# define SSL3_TXT_EDH_DSS_DES_40_CBC_SHA         \"EXP-EDH-DSS-DES-CBC-SHA\"\n# define SSL3_TXT_EDH_DSS_DES_64_CBC_SHA         \"EDH-DSS-DES-CBC-SHA\"\n# define SSL3_TXT_EDH_DSS_DES_192_CBC3_SHA       \"EDH-DSS-DES-CBC3-SHA\"\n# define SSL3_TXT_EDH_RSA_DES_40_CBC_SHA         \"EXP-EDH-RSA-DES-CBC-SHA\"\n# define SSL3_TXT_EDH_RSA_DES_64_CBC_SHA         \"EDH-RSA-DES-CBC-SHA\"\n# define SSL3_TXT_EDH_RSA_DES_192_CBC3_SHA       \"EDH-RSA-DES-CBC3-SHA\"\n\n# define SSL3_TXT_ADH_RC4_40_MD5                 \"EXP-ADH-RC4-MD5\"\n# define SSL3_TXT_ADH_RC4_128_MD5                \"ADH-RC4-MD5\"\n# define SSL3_TXT_ADH_DES_40_CBC_SHA             \"EXP-ADH-DES-CBC-SHA\"\n# define SSL3_TXT_ADH_DES_64_CBC_SHA             \"ADH-DES-CBC-SHA\"\n# define SSL3_TXT_ADH_DES_192_CBC_SHA            \"ADH-DES-CBC3-SHA\"\n\n# if 0\n#  define SSL3_TXT_FZA_DMS_NULL_SHA               \"FZA-NULL-SHA\"\n#  define SSL3_TXT_FZA_DMS_FZA_SHA                \"FZA-FZA-CBC-SHA\"\n#  define SSL3_TXT_FZA_DMS_RC4_SHA                \"FZA-RC4-SHA\"\n# endif\n\n# define SSL3_TXT_KRB5_DES_64_CBC_SHA            \"KRB5-DES-CBC-SHA\"\n# define SSL3_TXT_KRB5_DES_192_CBC3_SHA          \"KRB5-DES-CBC3-SHA\"\n# define SSL3_TXT_KRB5_RC4_128_SHA               \"KRB5-RC4-SHA\"\n# define SSL3_TXT_KRB5_IDEA_128_CBC_SHA          \"KRB5-IDEA-CBC-SHA\"\n# define SSL3_TXT_KRB5_DES_64_CBC_MD5            \"KRB5-DES-CBC-MD5\"\n# define SSL3_TXT_KRB5_DES_192_CBC3_MD5          \"KRB5-DES-CBC3-MD5\"\n# define SSL3_TXT_KRB5_RC4_128_MD5               \"KRB5-RC4-MD5\"\n# define SSL3_TXT_KRB5_IDEA_128_CBC_MD5          \"KRB5-IDEA-CBC-MD5\"\n\n# define SSL3_TXT_KRB5_DES_40_CBC_SHA            \"EXP-KRB5-DES-CBC-SHA\"\n# define SSL3_TXT_KRB5_RC2_40_CBC_SHA            \"EXP-KRB5-RC2-CBC-SHA\"\n# define SSL3_TXT_KRB5_RC4_40_SHA                \"EXP-KRB5-RC4-SHA\"\n# define SSL3_TXT_KRB5_DES_40_CBC_MD5            \"EXP-KRB5-DES-CBC-MD5\"\n# define SSL3_TXT_KRB5_RC2_40_CBC_MD5            \"EXP-KRB5-RC2-CBC-MD5\"\n# define SSL3_TXT_KRB5_RC4_40_MD5                \"EXP-KRB5-RC4-MD5\"\n\n# define SSL3_SSL_SESSION_ID_LENGTH              32\n# define SSL3_MAX_SSL_SESSION_ID_LENGTH          32\n\n# define SSL3_MASTER_SECRET_SIZE                 48\n# define SSL3_RANDOM_SIZE                        32\n# define SSL3_SESSION_ID_SIZE                    32\n# define SSL3_RT_HEADER_LENGTH                   5\n\n# define SSL3_HM_HEADER_LENGTH                  4\n\n# ifndef SSL3_ALIGN_PAYLOAD\n /*\n  * Some will argue that this increases memory footprint, but it's not\n  * actually true. Point is that malloc has to return at least 64-bit aligned\n  * pointers, meaning that allocating 5 bytes wastes 3 bytes in either case.\n  * Suggested pre-gaping simply moves these wasted bytes from the end of\n  * allocated region to its front, but makes data payload aligned, which\n  * improves performance:-)\n  */\n#  define SSL3_ALIGN_PAYLOAD                     8\n# else\n#  if (SSL3_ALIGN_PAYLOAD&(SSL3_ALIGN_PAYLOAD-1))!=0\n#   error \"insane SSL3_ALIGN_PAYLOAD\"\n#   undef SSL3_ALIGN_PAYLOAD\n#  endif\n# endif\n\n/*\n * This is the maximum MAC (digest) size used by the SSL library. Currently\n * maximum of 20 is used by SHA1, but we reserve for future extension for\n * 512-bit hashes.\n */\n\n# define SSL3_RT_MAX_MD_SIZE                     64\n\n/*\n * Maximum block size used in all ciphersuites. Currently 16 for AES.\n */\n\n# define SSL_RT_MAX_CIPHER_BLOCK_SIZE            16\n\n# define SSL3_RT_MAX_EXTRA                       (16384)\n\n/* Maximum plaintext length: defined by SSL/TLS standards */\n# define SSL3_RT_MAX_PLAIN_LENGTH                16384\n/* Maximum compression overhead: defined by SSL/TLS standards */\n# define SSL3_RT_MAX_COMPRESSED_OVERHEAD         1024\n\n/*\n * The standards give a maximum encryption overhead of 1024 bytes. In\n * practice the value is lower than this. The overhead is the maximum number\n * of padding bytes (256) plus the mac size.\n */\n# define SSL3_RT_MAX_ENCRYPTED_OVERHEAD  (256 + SSL3_RT_MAX_MD_SIZE)\n\n/*\n * OpenSSL currently only uses a padding length of at most one block so the\n * send overhead is smaller.\n */\n\n# define SSL3_RT_SEND_MAX_ENCRYPTED_OVERHEAD \\\n                        (SSL_RT_MAX_CIPHER_BLOCK_SIZE + SSL3_RT_MAX_MD_SIZE)\n\n/* If compression isn't used don't include the compression overhead */\n\n# ifdef OPENSSL_NO_COMP\n#  define SSL3_RT_MAX_COMPRESSED_LENGTH           SSL3_RT_MAX_PLAIN_LENGTH\n# else\n#  define SSL3_RT_MAX_COMPRESSED_LENGTH   \\\n                (SSL3_RT_MAX_PLAIN_LENGTH+SSL3_RT_MAX_COMPRESSED_OVERHEAD)\n# endif\n# define SSL3_RT_MAX_ENCRYPTED_LENGTH    \\\n                (SSL3_RT_MAX_ENCRYPTED_OVERHEAD+SSL3_RT_MAX_COMPRESSED_LENGTH)\n# define SSL3_RT_MAX_PACKET_SIZE         \\\n                (SSL3_RT_MAX_ENCRYPTED_LENGTH+SSL3_RT_HEADER_LENGTH)\n\n# define SSL3_MD_CLIENT_FINISHED_CONST   \"\\x43\\x4C\\x4E\\x54\"\n# define SSL3_MD_SERVER_FINISHED_CONST   \"\\x53\\x52\\x56\\x52\"\n\n# define SSL3_VERSION                    0x0300\n# define SSL3_VERSION_MAJOR              0x03\n# define SSL3_VERSION_MINOR              0x00\n\n# define SSL3_RT_CHANGE_CIPHER_SPEC      20\n# define SSL3_RT_ALERT                   21\n# define SSL3_RT_HANDSHAKE               22\n# define SSL3_RT_APPLICATION_DATA        23\n# define TLS1_RT_HEARTBEAT               24\n\n/* Pseudo content types to indicate additional parameters */\n# define TLS1_RT_CRYPTO                  0x1000\n# define TLS1_RT_CRYPTO_PREMASTER        (TLS1_RT_CRYPTO | 0x1)\n# define TLS1_RT_CRYPTO_CLIENT_RANDOM    (TLS1_RT_CRYPTO | 0x2)\n# define TLS1_RT_CRYPTO_SERVER_RANDOM    (TLS1_RT_CRYPTO | 0x3)\n# define TLS1_RT_CRYPTO_MASTER           (TLS1_RT_CRYPTO | 0x4)\n\n# define TLS1_RT_CRYPTO_READ             0x0000\n# define TLS1_RT_CRYPTO_WRITE            0x0100\n# define TLS1_RT_CRYPTO_MAC              (TLS1_RT_CRYPTO | 0x5)\n# define TLS1_RT_CRYPTO_KEY              (TLS1_RT_CRYPTO | 0x6)\n# define TLS1_RT_CRYPTO_IV               (TLS1_RT_CRYPTO | 0x7)\n# define TLS1_RT_CRYPTO_FIXED_IV         (TLS1_RT_CRYPTO | 0x8)\n\n/* Pseudo content type for SSL/TLS header info */\n# define SSL3_RT_HEADER                  0x100\n\n# define SSL3_AL_WARNING                 1\n# define SSL3_AL_FATAL                   2\n\n# define SSL3_AD_CLOSE_NOTIFY             0\n# define SSL3_AD_UNEXPECTED_MESSAGE      10/* fatal */\n# define SSL3_AD_BAD_RECORD_MAC          20/* fatal */\n# define SSL3_AD_DECOMPRESSION_FAILURE   30/* fatal */\n# define SSL3_AD_HANDSHAKE_FAILURE       40/* fatal */\n# define SSL3_AD_NO_CERTIFICATE          41\n# define SSL3_AD_BAD_CERTIFICATE         42\n# define SSL3_AD_UNSUPPORTED_CERTIFICATE 43\n# define SSL3_AD_CERTIFICATE_REVOKED     44\n# define SSL3_AD_CERTIFICATE_EXPIRED     45\n# define SSL3_AD_CERTIFICATE_UNKNOWN     46\n# define SSL3_AD_ILLEGAL_PARAMETER       47/* fatal */\n\n# define TLS1_HB_REQUEST         1\n# define TLS1_HB_RESPONSE        2\n\n# ifndef OPENSSL_NO_SSL_INTERN\n\ntypedef struct ssl3_record_st {\n    /* type of record */\n    /*\n     * r\n     */ int type;\n    /* How many bytes available */\n    /*\n     * rw\n     */ unsigned int length;\n    /* read/write offset into 'buf' */\n    /*\n     * r\n     */ unsigned int off;\n    /* pointer to the record data */\n    /*\n     * rw\n     */ unsigned char *data;\n    /* where the decode bytes are */\n    /*\n     * rw\n     */ unsigned char *input;\n    /* only used with decompression - malloc()ed */\n    /*\n     * r\n     */ unsigned char *comp;\n    /* epoch number, needed by DTLS1 */\n    /*\n     * r\n     */ unsigned long epoch;\n    /* sequence number, needed by DTLS1 */\n    /*\n     * r\n     */ unsigned char seq_num[8];\n} SSL3_RECORD;\n\ntypedef struct ssl3_buffer_st {\n    /* at least SSL3_RT_MAX_PACKET_SIZE bytes, see ssl3_setup_buffers() */\n    unsigned char *buf;\n    /* buffer size */\n    size_t len;\n    /* where to 'copy from' */\n    int offset;\n    /* how many bytes left */\n    int left;\n} SSL3_BUFFER;\n\n# endif\n\n# define SSL3_CT_RSA_SIGN                        1\n# define SSL3_CT_DSS_SIGN                        2\n# define SSL3_CT_RSA_FIXED_DH                    3\n# define SSL3_CT_DSS_FIXED_DH                    4\n# define SSL3_CT_RSA_EPHEMERAL_DH                5\n# define SSL3_CT_DSS_EPHEMERAL_DH                6\n# define SSL3_CT_FORTEZZA_DMS                    20\n/*\n * SSL3_CT_NUMBER is used to size arrays and it must be large enough to\n * contain all of the cert types defined either for SSLv3 and TLSv1.\n */\n# define SSL3_CT_NUMBER                  9\n\n# define SSL3_FLAGS_NO_RENEGOTIATE_CIPHERS       0x0001\n# define SSL3_FLAGS_DELAY_CLIENT_FINISHED        0x0002\n# define SSL3_FLAGS_POP_BUFFER                   0x0004\n# define TLS1_FLAGS_TLS_PADDING_BUG              0x0008\n# define TLS1_FLAGS_SKIP_CERT_VERIFY             0x0010\n# define TLS1_FLAGS_KEEP_HANDSHAKE               0x0020\n/*\n * Set when the handshake is ready to process peer's ChangeCipherSpec message.\n * Cleared after the message has been processed.\n */\n# define SSL3_FLAGS_CCS_OK                       0x0080\n\n/* SSL3_FLAGS_SGC_RESTART_DONE is no longer used */\n# define SSL3_FLAGS_SGC_RESTART_DONE             0x0040\n\n# ifndef OPENSSL_NO_SSL_INTERN\n\ntypedef struct ssl3_state_st {\n    long flags;\n    int delay_buf_pop_ret;\n    unsigned char read_sequence[8];\n    int read_mac_secret_size;\n    unsigned char read_mac_secret[EVP_MAX_MD_SIZE];\n    unsigned char write_sequence[8];\n    int write_mac_secret_size;\n    unsigned char write_mac_secret[EVP_MAX_MD_SIZE];\n    unsigned char server_random[SSL3_RANDOM_SIZE];\n    unsigned char client_random[SSL3_RANDOM_SIZE];\n    /* flags for countermeasure against known-IV weakness */\n    int need_empty_fragments;\n    int empty_fragment_done;\n    /* The value of 'extra' when the buffers were initialized */\n    int init_extra;\n    SSL3_BUFFER rbuf;           /* read IO goes into here */\n    SSL3_BUFFER wbuf;           /* write IO goes into here */\n    SSL3_RECORD rrec;           /* each decoded record goes in here */\n    SSL3_RECORD wrec;           /* goes out from here */\n    /*\n     * storage for Alert/Handshake protocol data received but not yet\n     * processed by ssl3_read_bytes:\n     */\n    unsigned char alert_fragment[2];\n    unsigned int alert_fragment_len;\n    unsigned char handshake_fragment[4];\n    unsigned int handshake_fragment_len;\n    /* partial write - check the numbers match */\n    unsigned int wnum;          /* number of bytes sent so far */\n    int wpend_tot;              /* number bytes written */\n    int wpend_type;\n    int wpend_ret;              /* number of bytes submitted */\n    const unsigned char *wpend_buf;\n    /* used during startup, digest all incoming/outgoing packets */\n    BIO *handshake_buffer;\n    /*\n     * When set of handshake digests is determined, buffer is hashed and\n     * freed and MD_CTX-es for all required digests are stored in this array\n     */\n    EVP_MD_CTX **handshake_dgst;\n    /*\n     * Set whenever an expected ChangeCipherSpec message is processed.\n     * Unset when the peer's Finished message is received.\n     * Unexpected ChangeCipherSpec messages trigger a fatal alert.\n     */\n    int change_cipher_spec;\n    int warn_alert;\n    int fatal_alert;\n    /*\n     * we allow one fatal and one warning alert to be outstanding, send close\n     * alert via the warning alert\n     */\n    int alert_dispatch;\n    unsigned char send_alert[2];\n    /*\n     * This flag is set when we should renegotiate ASAP, basically when there\n     * is no more data in the read or write buffers\n     */\n    int renegotiate;\n    int total_renegotiations;\n    int num_renegotiations;\n    int in_read_app_data;\n    /*\n     * Opaque PRF input as used for the current handshake. These fields are\n     * used only if TLSEXT_TYPE_opaque_prf_input is defined (otherwise, they\n     * are merely present to improve binary compatibility)\n     */\n    void *client_opaque_prf_input;\n    size_t client_opaque_prf_input_len;\n    void *server_opaque_prf_input;\n    size_t server_opaque_prf_input_len;\n    struct {\n        /* actually only needs to be 16+20 */\n        unsigned char cert_verify_md[EVP_MAX_MD_SIZE * 2];\n        /* actually only need to be 16+20 for SSLv3 and 12 for TLS */\n        unsigned char finish_md[EVP_MAX_MD_SIZE * 2];\n        int finish_md_len;\n        unsigned char peer_finish_md[EVP_MAX_MD_SIZE * 2];\n        int peer_finish_md_len;\n        unsigned long message_size;\n        int message_type;\n        /* used to hold the new cipher we are going to use */\n        const SSL_CIPHER *new_cipher;\n#  ifndef OPENSSL_NO_DH\n        DH *dh;\n#  endif\n#  ifndef OPENSSL_NO_ECDH\n        EC_KEY *ecdh;           /* holds short lived ECDH key */\n#  endif\n        /* used when SSL_ST_FLUSH_DATA is entered */\n        int next_state;\n        int reuse_message;\n        /* used for certificate requests */\n        int cert_req;\n        int ctype_num;\n        char ctype[SSL3_CT_NUMBER];\n        STACK_OF(X509_NAME) *ca_names;\n        int use_rsa_tmp;\n        int key_block_length;\n        unsigned char *key_block;\n        const EVP_CIPHER *new_sym_enc;\n        const EVP_MD *new_hash;\n        int new_mac_pkey_type;\n        int new_mac_secret_size;\n#  ifndef OPENSSL_NO_COMP\n        const SSL_COMP *new_compression;\n#  else\n        char *new_compression;\n#  endif\n        int cert_request;\n    } tmp;\n\n    /* Connection binding to prevent renegotiation attacks */\n    unsigned char previous_client_finished[EVP_MAX_MD_SIZE];\n    unsigned char previous_client_finished_len;\n    unsigned char previous_server_finished[EVP_MAX_MD_SIZE];\n    unsigned char previous_server_finished_len;\n    int send_connection_binding; /* TODOEKR */\n\n#  ifndef OPENSSL_NO_NEXTPROTONEG\n    /*\n     * Set if we saw the Next Protocol Negotiation extension from our peer.\n     */\n    int next_proto_neg_seen;\n#  endif\n\n#  ifndef OPENSSL_NO_TLSEXT\n#   ifndef OPENSSL_NO_EC\n    /*\n     * This is set to true if we believe that this is a version of Safari\n     * running on OS X 10.6 or newer. We wish to know this because Safari on\n     * 10.8 .. 10.8.3 has broken ECDHE-ECDSA support.\n     */\n    char is_probably_safari;\n#   endif                       /* !OPENSSL_NO_EC */\n\n    /*\n     * ALPN information (we are in the process of transitioning from NPN to\n     * ALPN.)\n     */\n\n    /*\n     * In a server these point to the selected ALPN protocol after the\n     * ClientHello has been processed. In a client these contain the protocol\n     * that the server selected once the ServerHello has been processed.\n     */\n    unsigned char *alpn_selected;\n    unsigned alpn_selected_len;\n#  endif                        /* OPENSSL_NO_TLSEXT */\n} SSL3_STATE;\n\n# endif\n\n/* SSLv3 */\n/*\n * client\n */\n/* extra state */\n# define SSL3_ST_CW_FLUSH                (0x100|SSL_ST_CONNECT)\n# ifndef OPENSSL_NO_SCTP\n#  define DTLS1_SCTP_ST_CW_WRITE_SOCK                     (0x310|SSL_ST_CONNECT)\n#  define DTLS1_SCTP_ST_CR_READ_SOCK                      (0x320|SSL_ST_CONNECT)\n# endif\n/* write to server */\n# define SSL3_ST_CW_CLNT_HELLO_A         (0x110|SSL_ST_CONNECT)\n# define SSL3_ST_CW_CLNT_HELLO_B         (0x111|SSL_ST_CONNECT)\n/* read from server */\n# define SSL3_ST_CR_SRVR_HELLO_A         (0x120|SSL_ST_CONNECT)\n# define SSL3_ST_CR_SRVR_HELLO_B         (0x121|SSL_ST_CONNECT)\n# define DTLS1_ST_CR_HELLO_VERIFY_REQUEST_A (0x126|SSL_ST_CONNECT)\n# define DTLS1_ST_CR_HELLO_VERIFY_REQUEST_B (0x127|SSL_ST_CONNECT)\n# define SSL3_ST_CR_CERT_A               (0x130|SSL_ST_CONNECT)\n# define SSL3_ST_CR_CERT_B               (0x131|SSL_ST_CONNECT)\n# define SSL3_ST_CR_KEY_EXCH_A           (0x140|SSL_ST_CONNECT)\n# define SSL3_ST_CR_KEY_EXCH_B           (0x141|SSL_ST_CONNECT)\n# define SSL3_ST_CR_CERT_REQ_A           (0x150|SSL_ST_CONNECT)\n# define SSL3_ST_CR_CERT_REQ_B           (0x151|SSL_ST_CONNECT)\n# define SSL3_ST_CR_SRVR_DONE_A          (0x160|SSL_ST_CONNECT)\n# define SSL3_ST_CR_SRVR_DONE_B          (0x161|SSL_ST_CONNECT)\n/* write to server */\n# define SSL3_ST_CW_CERT_A               (0x170|SSL_ST_CONNECT)\n# define SSL3_ST_CW_CERT_B               (0x171|SSL_ST_CONNECT)\n# define SSL3_ST_CW_CERT_C               (0x172|SSL_ST_CONNECT)\n# define SSL3_ST_CW_CERT_D               (0x173|SSL_ST_CONNECT)\n# define SSL3_ST_CW_KEY_EXCH_A           (0x180|SSL_ST_CONNECT)\n# define SSL3_ST_CW_KEY_EXCH_B           (0x181|SSL_ST_CONNECT)\n# define SSL3_ST_CW_CERT_VRFY_A          (0x190|SSL_ST_CONNECT)\n# define SSL3_ST_CW_CERT_VRFY_B          (0x191|SSL_ST_CONNECT)\n# define SSL3_ST_CW_CHANGE_A             (0x1A0|SSL_ST_CONNECT)\n# define SSL3_ST_CW_CHANGE_B             (0x1A1|SSL_ST_CONNECT)\n# ifndef OPENSSL_NO_NEXTPROTONEG\n#  define SSL3_ST_CW_NEXT_PROTO_A         (0x200|SSL_ST_CONNECT)\n#  define SSL3_ST_CW_NEXT_PROTO_B         (0x201|SSL_ST_CONNECT)\n# endif\n# define SSL3_ST_CW_FINISHED_A           (0x1B0|SSL_ST_CONNECT)\n# define SSL3_ST_CW_FINISHED_B           (0x1B1|SSL_ST_CONNECT)\n/* read from server */\n# define SSL3_ST_CR_CHANGE_A             (0x1C0|SSL_ST_CONNECT)\n# define SSL3_ST_CR_CHANGE_B             (0x1C1|SSL_ST_CONNECT)\n# define SSL3_ST_CR_FINISHED_A           (0x1D0|SSL_ST_CONNECT)\n# define SSL3_ST_CR_FINISHED_B           (0x1D1|SSL_ST_CONNECT)\n# define SSL3_ST_CR_SESSION_TICKET_A     (0x1E0|SSL_ST_CONNECT)\n# define SSL3_ST_CR_SESSION_TICKET_B     (0x1E1|SSL_ST_CONNECT)\n# define SSL3_ST_CR_CERT_STATUS_A        (0x1F0|SSL_ST_CONNECT)\n# define SSL3_ST_CR_CERT_STATUS_B        (0x1F1|SSL_ST_CONNECT)\n\n/* server */\n/* extra state */\n# define SSL3_ST_SW_FLUSH                (0x100|SSL_ST_ACCEPT)\n# ifndef OPENSSL_NO_SCTP\n#  define DTLS1_SCTP_ST_SW_WRITE_SOCK                     (0x310|SSL_ST_ACCEPT)\n#  define DTLS1_SCTP_ST_SR_READ_SOCK                      (0x320|SSL_ST_ACCEPT)\n# endif\n/* read from client */\n/* Do not change the number values, they do matter */\n# define SSL3_ST_SR_CLNT_HELLO_A         (0x110|SSL_ST_ACCEPT)\n# define SSL3_ST_SR_CLNT_HELLO_B         (0x111|SSL_ST_ACCEPT)\n# define SSL3_ST_SR_CLNT_HELLO_C         (0x112|SSL_ST_ACCEPT)\n# define SSL3_ST_SR_CLNT_HELLO_D         (0x115|SSL_ST_ACCEPT)\n/* write to client */\n# define DTLS1_ST_SW_HELLO_VERIFY_REQUEST_A (0x113|SSL_ST_ACCEPT)\n# define DTLS1_ST_SW_HELLO_VERIFY_REQUEST_B (0x114|SSL_ST_ACCEPT)\n# define SSL3_ST_SW_HELLO_REQ_A          (0x120|SSL_ST_ACCEPT)\n# define SSL3_ST_SW_HELLO_REQ_B          (0x121|SSL_ST_ACCEPT)\n# define SSL3_ST_SW_HELLO_REQ_C          (0x122|SSL_ST_ACCEPT)\n# define SSL3_ST_SW_SRVR_HELLO_A         (0x130|SSL_ST_ACCEPT)\n# define SSL3_ST_SW_SRVR_HELLO_B         (0x131|SSL_ST_ACCEPT)\n# define SSL3_ST_SW_CERT_A               (0x140|SSL_ST_ACCEPT)\n# define SSL3_ST_SW_CERT_B               (0x141|SSL_ST_ACCEPT)\n# define SSL3_ST_SW_KEY_EXCH_A           (0x150|SSL_ST_ACCEPT)\n# define SSL3_ST_SW_KEY_EXCH_B           (0x151|SSL_ST_ACCEPT)\n# define SSL3_ST_SW_CERT_REQ_A           (0x160|SSL_ST_ACCEPT)\n# define SSL3_ST_SW_CERT_REQ_B           (0x161|SSL_ST_ACCEPT)\n# define SSL3_ST_SW_SRVR_DONE_A          (0x170|SSL_ST_ACCEPT)\n# define SSL3_ST_SW_SRVR_DONE_B          (0x171|SSL_ST_ACCEPT)\n/* read from client */\n# define SSL3_ST_SR_CERT_A               (0x180|SSL_ST_ACCEPT)\n# define SSL3_ST_SR_CERT_B               (0x181|SSL_ST_ACCEPT)\n# define SSL3_ST_SR_KEY_EXCH_A           (0x190|SSL_ST_ACCEPT)\n# define SSL3_ST_SR_KEY_EXCH_B           (0x191|SSL_ST_ACCEPT)\n# define SSL3_ST_SR_CERT_VRFY_A          (0x1A0|SSL_ST_ACCEPT)\n# define SSL3_ST_SR_CERT_VRFY_B          (0x1A1|SSL_ST_ACCEPT)\n# define SSL3_ST_SR_CHANGE_A             (0x1B0|SSL_ST_ACCEPT)\n# define SSL3_ST_SR_CHANGE_B             (0x1B1|SSL_ST_ACCEPT)\n# ifndef OPENSSL_NO_NEXTPROTONEG\n#  define SSL3_ST_SR_NEXT_PROTO_A         (0x210|SSL_ST_ACCEPT)\n#  define SSL3_ST_SR_NEXT_PROTO_B         (0x211|SSL_ST_ACCEPT)\n# endif\n# define SSL3_ST_SR_FINISHED_A           (0x1C0|SSL_ST_ACCEPT)\n# define SSL3_ST_SR_FINISHED_B           (0x1C1|SSL_ST_ACCEPT)\n/* write to client */\n# define SSL3_ST_SW_CHANGE_A             (0x1D0|SSL_ST_ACCEPT)\n# define SSL3_ST_SW_CHANGE_B             (0x1D1|SSL_ST_ACCEPT)\n# define SSL3_ST_SW_FINISHED_A           (0x1E0|SSL_ST_ACCEPT)\n# define SSL3_ST_SW_FINISHED_B           (0x1E1|SSL_ST_ACCEPT)\n# define SSL3_ST_SW_SESSION_TICKET_A     (0x1F0|SSL_ST_ACCEPT)\n# define SSL3_ST_SW_SESSION_TICKET_B     (0x1F1|SSL_ST_ACCEPT)\n# define SSL3_ST_SW_CERT_STATUS_A        (0x200|SSL_ST_ACCEPT)\n# define SSL3_ST_SW_CERT_STATUS_B        (0x201|SSL_ST_ACCEPT)\n\n# define SSL3_MT_HELLO_REQUEST                   0\n# define SSL3_MT_CLIENT_HELLO                    1\n# define SSL3_MT_SERVER_HELLO                    2\n# define SSL3_MT_NEWSESSION_TICKET               4\n# define SSL3_MT_CERTIFICATE                     11\n# define SSL3_MT_SERVER_KEY_EXCHANGE             12\n# define SSL3_MT_CERTIFICATE_REQUEST             13\n# define SSL3_MT_SERVER_DONE                     14\n# define SSL3_MT_CERTIFICATE_VERIFY              15\n# define SSL3_MT_CLIENT_KEY_EXCHANGE             16\n# define SSL3_MT_FINISHED                        20\n# define SSL3_MT_CERTIFICATE_STATUS              22\n# ifndef OPENSSL_NO_NEXTPROTONEG\n#  define SSL3_MT_NEXT_PROTO                      67\n# endif\n# define DTLS1_MT_HELLO_VERIFY_REQUEST    3\n\n# define SSL3_MT_CCS                             1\n\n/* These are used when changing over to a new cipher */\n# define SSL3_CC_READ            0x01\n# define SSL3_CC_WRITE           0x02\n# define SSL3_CC_CLIENT          0x10\n# define SSL3_CC_SERVER          0x20\n# define SSL3_CHANGE_CIPHER_CLIENT_WRITE (SSL3_CC_CLIENT|SSL3_CC_WRITE)\n# define SSL3_CHANGE_CIPHER_SERVER_READ  (SSL3_CC_SERVER|SSL3_CC_READ)\n# define SSL3_CHANGE_CIPHER_CLIENT_READ  (SSL3_CC_CLIENT|SSL3_CC_READ)\n# define SSL3_CHANGE_CIPHER_SERVER_WRITE (SSL3_CC_SERVER|SSL3_CC_WRITE)\n\n#ifdef  __cplusplus\n}\n#endif\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/x86/include/openssl/stack.h",
    "content": "/* crypto/stack/stack.h */\n/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)\n * All rights reserved.\n *\n * This package is an SSL implementation written\n * by Eric Young (eay@cryptsoft.com).\n * The implementation was written so as to conform with Netscapes SSL.\n *\n * This library is free for commercial and non-commercial use as long as\n * the following conditions are aheared to.  The following conditions\n * apply to all code found in this distribution, be it the RC4, RSA,\n * lhash, DES, etc., code; not just the SSL code.  The SSL documentation\n * included with this distribution is covered by the same copyright terms\n * except that the holder is Tim Hudson (tjh@cryptsoft.com).\n *\n * Copyright remains Eric Young's, and as such any Copyright notices in\n * the code are not to be removed.\n * If this package is used in a product, Eric Young should be given attribution\n * as the author of the parts of the library used.\n * This can be in the form of a textual message at program startup or\n * in documentation (online or textual) provided with the package.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the copyright\n *    notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in the\n *    documentation and/or other materials provided with the distribution.\n * 3. All advertising materials mentioning features or use of this software\n *    must display the following acknowledgement:\n *    \"This product includes cryptographic software written by\n *     Eric Young (eay@cryptsoft.com)\"\n *    The word 'cryptographic' can be left out if the rouines from the library\n *    being used are not cryptographic related :-).\n * 4. If you include any Windows specific code (or a derivative thereof) from\n *    the apps directory (application code) you must include an acknowledgement:\n *    \"This product includes software written by Tim Hudson (tjh@cryptsoft.com)\"\n *\n * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n * SUCH DAMAGE.\n *\n * The licence and distribution terms for any publically available version or\n * derivative of this code cannot be changed.  i.e. this code cannot simply be\n * copied and put under another distribution licence\n * [including the GNU Public Licence.]\n */\n\n#ifndef HEADER_STACK_H\n# define HEADER_STACK_H\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\ntypedef struct stack_st {\n    int num;\n    char **data;\n    int sorted;\n    int num_alloc;\n    int (*comp) (const void *, const void *);\n} _STACK;                       /* Use STACK_OF(...) instead */\n\n# define M_sk_num(sk)            ((sk) ? (sk)->num:-1)\n# define M_sk_value(sk,n)        ((sk) ? (sk)->data[n] : NULL)\n\nint sk_num(const _STACK *);\nvoid *sk_value(const _STACK *, int);\n\nvoid *sk_set(_STACK *, int, void *);\n\n_STACK *sk_new(int (*cmp) (const void *, const void *));\n_STACK *sk_new_null(void);\nvoid sk_free(_STACK *);\nvoid sk_pop_free(_STACK *st, void (*func) (void *));\n_STACK *sk_deep_copy(_STACK *, void *(*)(void *), void (*)(void *));\nint sk_insert(_STACK *sk, void *data, int where);\nvoid *sk_delete(_STACK *st, int loc);\nvoid *sk_delete_ptr(_STACK *st, void *p);\nint sk_find(_STACK *st, void *data);\nint sk_find_ex(_STACK *st, void *data);\nint sk_push(_STACK *st, void *data);\nint sk_unshift(_STACK *st, void *data);\nvoid *sk_shift(_STACK *st);\nvoid *sk_pop(_STACK *st);\nvoid sk_zero(_STACK *st);\nint (*sk_set_cmp_func(_STACK *sk, int (*c) (const void *, const void *)))\n (const void *, const void *);\n_STACK *sk_dup(_STACK *st);\nvoid sk_sort(_STACK *st);\nint sk_is_sorted(const _STACK *st);\n\n#ifdef  __cplusplus\n}\n#endif\n\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/x86/include/openssl/symhacks.h",
    "content": "/* ====================================================================\n * Copyright (c) 1999 The OpenSSL Project.  All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n *\n * 1. Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n *\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in\n *    the documentation and/or other materials provided with the\n *    distribution.\n *\n * 3. All advertising materials mentioning features or use of this\n *    software must display the following acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit. (http://www.openssl.org/)\"\n *\n * 4. The names \"OpenSSL Toolkit\" and \"OpenSSL Project\" must not be used to\n *    endorse or promote products derived from this software without\n *    prior written permission. For written permission, please contact\n *    openssl-core@openssl.org.\n *\n * 5. Products derived from this software may not be called \"OpenSSL\"\n *    nor may \"OpenSSL\" appear in their names without prior written\n *    permission of the OpenSSL Project.\n *\n * 6. Redistributions of any form whatsoever must retain the following\n *    acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit (http://www.openssl.org/)\"\n *\n * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY\n * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\n * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR\n * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\n * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,\n * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED\n * OF THE POSSIBILITY OF SUCH DAMAGE.\n * ====================================================================\n *\n * This product includes cryptographic software written by Eric Young\n * (eay@cryptsoft.com).  This product includes software written by Tim\n * Hudson (tjh@cryptsoft.com).\n *\n */\n\n#ifndef HEADER_SYMHACKS_H\n# define HEADER_SYMHACKS_H\n\n# include <openssl/e_os2.h>\n\n/*\n * Hacks to solve the problem with linkers incapable of handling very long\n * symbol names.  In the case of VMS, the limit is 31 characters on VMS for\n * VAX.\n */\n/*\n * Note that this affects util/libeay.num and util/ssleay.num...  you may\n * change those manually, but that's not recommended, as those files are\n * controlled centrally and updated on Unix, and the central definition may\n * disagree with yours, which in turn may come with shareable library\n * incompatibilities.\n */\n# ifdef OPENSSL_SYS_VMS\n\n/* Hack a long name in crypto/ex_data.c */\n#  undef CRYPTO_get_ex_data_implementation\n#  define CRYPTO_get_ex_data_implementation       CRYPTO_get_ex_data_impl\n#  undef CRYPTO_set_ex_data_implementation\n#  define CRYPTO_set_ex_data_implementation       CRYPTO_set_ex_data_impl\n\n/* Hack a long name in crypto/asn1/a_mbstr.c */\n#  undef ASN1_STRING_set_default_mask_asc\n#  define ASN1_STRING_set_default_mask_asc        ASN1_STRING_set_def_mask_asc\n\n#  if 0                         /* No longer needed, since safestack macro\n                                 * magic does the job */\n/* Hack the names created with DECLARE_ASN1_SET_OF(PKCS7_SIGNER_INFO) */\n#   undef i2d_ASN1_SET_OF_PKCS7_SIGNER_INFO\n#   define i2d_ASN1_SET_OF_PKCS7_SIGNER_INFO       i2d_ASN1_SET_OF_PKCS7_SIGINF\n#   undef d2i_ASN1_SET_OF_PKCS7_SIGNER_INFO\n#   define d2i_ASN1_SET_OF_PKCS7_SIGNER_INFO       d2i_ASN1_SET_OF_PKCS7_SIGINF\n#  endif\n\n#  if 0                         /* No longer needed, since safestack macro\n                                 * magic does the job */\n/* Hack the names created with DECLARE_ASN1_SET_OF(PKCS7_RECIP_INFO) */\n#   undef i2d_ASN1_SET_OF_PKCS7_RECIP_INFO\n#   define i2d_ASN1_SET_OF_PKCS7_RECIP_INFO        i2d_ASN1_SET_OF_PKCS7_RECINF\n#   undef d2i_ASN1_SET_OF_PKCS7_RECIP_INFO\n#   define d2i_ASN1_SET_OF_PKCS7_RECIP_INFO        d2i_ASN1_SET_OF_PKCS7_RECINF\n#  endif\n\n#  if 0                         /* No longer needed, since safestack macro\n                                 * magic does the job */\n/* Hack the names created with DECLARE_ASN1_SET_OF(ACCESS_DESCRIPTION) */\n#   undef i2d_ASN1_SET_OF_ACCESS_DESCRIPTION\n#   define i2d_ASN1_SET_OF_ACCESS_DESCRIPTION      i2d_ASN1_SET_OF_ACC_DESC\n#   undef d2i_ASN1_SET_OF_ACCESS_DESCRIPTION\n#   define d2i_ASN1_SET_OF_ACCESS_DESCRIPTION      d2i_ASN1_SET_OF_ACC_DESC\n#  endif\n\n/* Hack the names created with DECLARE_PEM_rw(NETSCAPE_CERT_SEQUENCE) */\n#  undef PEM_read_NETSCAPE_CERT_SEQUENCE\n#  define PEM_read_NETSCAPE_CERT_SEQUENCE         PEM_read_NS_CERT_SEQ\n#  undef PEM_write_NETSCAPE_CERT_SEQUENCE\n#  define PEM_write_NETSCAPE_CERT_SEQUENCE        PEM_write_NS_CERT_SEQ\n#  undef PEM_read_bio_NETSCAPE_CERT_SEQUENCE\n#  define PEM_read_bio_NETSCAPE_CERT_SEQUENCE     PEM_read_bio_NS_CERT_SEQ\n#  undef PEM_write_bio_NETSCAPE_CERT_SEQUENCE\n#  define PEM_write_bio_NETSCAPE_CERT_SEQUENCE    PEM_write_bio_NS_CERT_SEQ\n#  undef PEM_write_cb_bio_NETSCAPE_CERT_SEQUENCE\n#  define PEM_write_cb_bio_NETSCAPE_CERT_SEQUENCE PEM_write_cb_bio_NS_CERT_SEQ\n\n/* Hack the names created with DECLARE_PEM_rw(PKCS8_PRIV_KEY_INFO) */\n#  undef PEM_read_PKCS8_PRIV_KEY_INFO\n#  define PEM_read_PKCS8_PRIV_KEY_INFO            PEM_read_P8_PRIV_KEY_INFO\n#  undef PEM_write_PKCS8_PRIV_KEY_INFO\n#  define PEM_write_PKCS8_PRIV_KEY_INFO           PEM_write_P8_PRIV_KEY_INFO\n#  undef PEM_read_bio_PKCS8_PRIV_KEY_INFO\n#  define PEM_read_bio_PKCS8_PRIV_KEY_INFO        PEM_read_bio_P8_PRIV_KEY_INFO\n#  undef PEM_write_bio_PKCS8_PRIV_KEY_INFO\n#  define PEM_write_bio_PKCS8_PRIV_KEY_INFO       PEM_write_bio_P8_PRIV_KEY_INFO\n#  undef PEM_write_cb_bio_PKCS8_PRIV_KEY_INFO\n#  define PEM_write_cb_bio_PKCS8_PRIV_KEY_INFO    PEM_wrt_cb_bio_P8_PRIV_KEY_INFO\n\n/* Hack other PEM names */\n#  undef PEM_write_bio_PKCS8PrivateKey_nid\n#  define PEM_write_bio_PKCS8PrivateKey_nid       PEM_write_bio_PKCS8PrivKey_nid\n\n/* Hack some long X509 names */\n#  undef X509_REVOKED_get_ext_by_critical\n#  define X509_REVOKED_get_ext_by_critical        X509_REVOKED_get_ext_by_critic\n#  undef X509_policy_tree_get0_user_policies\n#  define X509_policy_tree_get0_user_policies     X509_pcy_tree_get0_usr_policies\n#  undef X509_policy_node_get0_qualifiers\n#  define X509_policy_node_get0_qualifiers        X509_pcy_node_get0_qualifiers\n#  undef X509_STORE_CTX_get_explicit_policy\n#  define X509_STORE_CTX_get_explicit_policy      X509_STORE_CTX_get_expl_policy\n#  undef X509_STORE_CTX_get0_current_issuer\n#  define X509_STORE_CTX_get0_current_issuer      X509_STORE_CTX_get0_cur_issuer\n\n/* Hack some long CRYPTO names */\n#  undef CRYPTO_set_dynlock_destroy_callback\n#  define CRYPTO_set_dynlock_destroy_callback     CRYPTO_set_dynlock_destroy_cb\n#  undef CRYPTO_set_dynlock_create_callback\n#  define CRYPTO_set_dynlock_create_callback      CRYPTO_set_dynlock_create_cb\n#  undef CRYPTO_set_dynlock_lock_callback\n#  define CRYPTO_set_dynlock_lock_callback        CRYPTO_set_dynlock_lock_cb\n#  undef CRYPTO_get_dynlock_lock_callback\n#  define CRYPTO_get_dynlock_lock_callback        CRYPTO_get_dynlock_lock_cb\n#  undef CRYPTO_get_dynlock_destroy_callback\n#  define CRYPTO_get_dynlock_destroy_callback     CRYPTO_get_dynlock_destroy_cb\n#  undef CRYPTO_get_dynlock_create_callback\n#  define CRYPTO_get_dynlock_create_callback      CRYPTO_get_dynlock_create_cb\n#  undef CRYPTO_set_locked_mem_ex_functions\n#  define CRYPTO_set_locked_mem_ex_functions      CRYPTO_set_locked_mem_ex_funcs\n#  undef CRYPTO_get_locked_mem_ex_functions\n#  define CRYPTO_get_locked_mem_ex_functions      CRYPTO_get_locked_mem_ex_funcs\n\n/* Hack some long SSL/TLS names */\n#  undef SSL_CTX_set_default_verify_paths\n#  define SSL_CTX_set_default_verify_paths        SSL_CTX_set_def_verify_paths\n#  undef SSL_get_ex_data_X509_STORE_CTX_idx\n#  define SSL_get_ex_data_X509_STORE_CTX_idx      SSL_get_ex_d_X509_STORE_CTX_idx\n#  undef SSL_add_file_cert_subjects_to_stack\n#  define SSL_add_file_cert_subjects_to_stack     SSL_add_file_cert_subjs_to_stk\n#  undef SSL_add_dir_cert_subjects_to_stack\n#  define SSL_add_dir_cert_subjects_to_stack      SSL_add_dir_cert_subjs_to_stk\n#  undef SSL_CTX_use_certificate_chain_file\n#  define SSL_CTX_use_certificate_chain_file      SSL_CTX_use_cert_chain_file\n#  undef SSL_CTX_set_cert_verify_callback\n#  define SSL_CTX_set_cert_verify_callback        SSL_CTX_set_cert_verify_cb\n#  undef SSL_CTX_set_default_passwd_cb_userdata\n#  define SSL_CTX_set_default_passwd_cb_userdata  SSL_CTX_set_def_passwd_cb_ud\n#  undef SSL_COMP_get_compression_methods\n#  define SSL_COMP_get_compression_methods        SSL_COMP_get_compress_methods\n#  undef SSL_COMP_set0_compression_methods\n#  define SSL_COMP_set0_compression_methods       SSL_COMP_set0_compress_methods\n#  undef SSL_COMP_free_compression_methods\n#  define SSL_COMP_free_compression_methods       SSL_COMP_free_compress_methods\n#  undef ssl_add_clienthello_renegotiate_ext\n#  define ssl_add_clienthello_renegotiate_ext     ssl_add_clienthello_reneg_ext\n#  undef ssl_add_serverhello_renegotiate_ext\n#  define ssl_add_serverhello_renegotiate_ext     ssl_add_serverhello_reneg_ext\n#  undef ssl_parse_clienthello_renegotiate_ext\n#  define ssl_parse_clienthello_renegotiate_ext   ssl_parse_clienthello_reneg_ext\n#  undef ssl_parse_serverhello_renegotiate_ext\n#  define ssl_parse_serverhello_renegotiate_ext   ssl_parse_serverhello_reneg_ext\n#  undef SSL_srp_server_param_with_username\n#  define SSL_srp_server_param_with_username      SSL_srp_server_param_with_un\n#  undef SSL_CTX_set_srp_client_pwd_callback\n#  define SSL_CTX_set_srp_client_pwd_callback     SSL_CTX_set_srp_client_pwd_cb\n#  undef SSL_CTX_set_srp_verify_param_callback\n#  define SSL_CTX_set_srp_verify_param_callback   SSL_CTX_set_srp_vfy_param_cb\n#  undef SSL_CTX_set_srp_username_callback\n#  define SSL_CTX_set_srp_username_callback       SSL_CTX_set_srp_un_cb\n#  undef ssl_add_clienthello_use_srtp_ext\n#  define ssl_add_clienthello_use_srtp_ext        ssl_add_clihello_use_srtp_ext\n#  undef ssl_add_serverhello_use_srtp_ext\n#  define ssl_add_serverhello_use_srtp_ext        ssl_add_serhello_use_srtp_ext\n#  undef ssl_parse_clienthello_use_srtp_ext\n#  define ssl_parse_clienthello_use_srtp_ext      ssl_parse_clihello_use_srtp_ext\n#  undef ssl_parse_serverhello_use_srtp_ext\n#  define ssl_parse_serverhello_use_srtp_ext      ssl_parse_serhello_use_srtp_ext\n#  undef SSL_CTX_set_next_protos_advertised_cb\n#  define SSL_CTX_set_next_protos_advertised_cb   SSL_CTX_set_next_protos_adv_cb\n#  undef SSL_CTX_set_next_proto_select_cb\n#  define SSL_CTX_set_next_proto_select_cb        SSL_CTX_set_next_proto_sel_cb\n\n#  undef tls1_send_server_supplemental_data\n#  define tls1_send_server_supplemental_data      tls1_send_server_suppl_data\n#  undef tls1_send_client_supplemental_data\n#  define tls1_send_client_supplemental_data      tls1_send_client_suppl_data\n#  undef tls1_get_server_supplemental_data\n#  define tls1_get_server_supplemental_data       tls1_get_server_suppl_data\n#  undef tls1_get_client_supplemental_data\n#  define tls1_get_client_supplemental_data       tls1_get_client_suppl_data\n\n#  undef ssl3_cbc_record_digest_supported\n#  define ssl3_cbc_record_digest_supported        ssl3_cbc_record_digest_support\n#  undef ssl_check_clienthello_tlsext_late\n#  define ssl_check_clienthello_tlsext_late       ssl_check_clihello_tlsext_late\n#  undef ssl_check_clienthello_tlsext_early\n#  define ssl_check_clienthello_tlsext_early      ssl_check_clihello_tlsext_early\n\n/* Hack some RSA long names */\n#  undef RSA_padding_check_PKCS1_OAEP_mgf1\n#  define RSA_padding_check_PKCS1_OAEP_mgf1       RSA_pad_check_PKCS1_OAEP_mgf1\n\n/* Hack some ENGINE long names */\n#  undef ENGINE_get_default_BN_mod_exp_crt\n#  define ENGINE_get_default_BN_mod_exp_crt       ENGINE_get_def_BN_mod_exp_crt\n#  undef ENGINE_set_default_BN_mod_exp_crt\n#  define ENGINE_set_default_BN_mod_exp_crt       ENGINE_set_def_BN_mod_exp_crt\n#  undef ENGINE_set_load_privkey_function\n#  define ENGINE_set_load_privkey_function        ENGINE_set_load_privkey_fn\n#  undef ENGINE_get_load_privkey_function\n#  define ENGINE_get_load_privkey_function        ENGINE_get_load_privkey_fn\n#  undef ENGINE_unregister_pkey_asn1_meths\n#  define ENGINE_unregister_pkey_asn1_meths       ENGINE_unreg_pkey_asn1_meths\n#  undef ENGINE_register_all_pkey_asn1_meths\n#  define ENGINE_register_all_pkey_asn1_meths     ENGINE_reg_all_pkey_asn1_meths\n#  undef ENGINE_set_default_pkey_asn1_meths\n#  define ENGINE_set_default_pkey_asn1_meths      ENGINE_set_def_pkey_asn1_meths\n#  undef ENGINE_get_pkey_asn1_meth_engine\n#  define ENGINE_get_pkey_asn1_meth_engine        ENGINE_get_pkey_asn1_meth_eng\n#  undef ENGINE_set_load_ssl_client_cert_function\n#  define ENGINE_set_load_ssl_client_cert_function \\\n                                                ENGINE_set_ld_ssl_clnt_cert_fn\n#  undef ENGINE_get_ssl_client_cert_function\n#  define ENGINE_get_ssl_client_cert_function     ENGINE_get_ssl_client_cert_fn\n\n/* Hack some long OCSP names */\n#  undef OCSP_REQUEST_get_ext_by_critical\n#  define OCSP_REQUEST_get_ext_by_critical        OCSP_REQUEST_get_ext_by_crit\n#  undef OCSP_BASICRESP_get_ext_by_critical\n#  define OCSP_BASICRESP_get_ext_by_critical      OCSP_BASICRESP_get_ext_by_crit\n#  undef OCSP_SINGLERESP_get_ext_by_critical\n#  define OCSP_SINGLERESP_get_ext_by_critical     OCSP_SINGLERESP_get_ext_by_crit\n\n/* Hack some long DES names */\n#  undef _ossl_old_des_ede3_cfb64_encrypt\n#  define _ossl_old_des_ede3_cfb64_encrypt        _ossl_odes_ede3_cfb64_encrypt\n#  undef _ossl_old_des_ede3_ofb64_encrypt\n#  define _ossl_old_des_ede3_ofb64_encrypt        _ossl_odes_ede3_ofb64_encrypt\n\n/* Hack some long EVP names */\n#  undef OPENSSL_add_all_algorithms_noconf\n#  define OPENSSL_add_all_algorithms_noconf       OPENSSL_add_all_algo_noconf\n#  undef OPENSSL_add_all_algorithms_conf\n#  define OPENSSL_add_all_algorithms_conf         OPENSSL_add_all_algo_conf\n#  undef EVP_PKEY_meth_set_verify_recover\n#  define EVP_PKEY_meth_set_verify_recover        EVP_PKEY_meth_set_vrfy_recover\n\n/* Hack some long EC names */\n#  undef EC_GROUP_set_point_conversion_form\n#  define EC_GROUP_set_point_conversion_form      EC_GROUP_set_point_conv_form\n#  undef EC_GROUP_get_point_conversion_form\n#  define EC_GROUP_get_point_conversion_form      EC_GROUP_get_point_conv_form\n#  undef EC_GROUP_clear_free_all_extra_data\n#  define EC_GROUP_clear_free_all_extra_data      EC_GROUP_clr_free_all_xtra_data\n#  undef EC_KEY_set_public_key_affine_coordinates\n#  define EC_KEY_set_public_key_affine_coordinates \\\n                                                EC_KEY_set_pub_key_aff_coords\n#  undef EC_POINT_set_Jprojective_coordinates_GFp\n#  define EC_POINT_set_Jprojective_coordinates_GFp \\\n                                                EC_POINT_set_Jproj_coords_GFp\n#  undef EC_POINT_get_Jprojective_coordinates_GFp\n#  define EC_POINT_get_Jprojective_coordinates_GFp \\\n                                                EC_POINT_get_Jproj_coords_GFp\n#  undef EC_POINT_set_affine_coordinates_GFp\n#  define EC_POINT_set_affine_coordinates_GFp     EC_POINT_set_affine_coords_GFp\n#  undef EC_POINT_get_affine_coordinates_GFp\n#  define EC_POINT_get_affine_coordinates_GFp     EC_POINT_get_affine_coords_GFp\n#  undef EC_POINT_set_compressed_coordinates_GFp\n#  define EC_POINT_set_compressed_coordinates_GFp EC_POINT_set_compr_coords_GFp\n#  undef EC_POINT_set_affine_coordinates_GF2m\n#  define EC_POINT_set_affine_coordinates_GF2m    EC_POINT_set_affine_coords_GF2m\n#  undef EC_POINT_get_affine_coordinates_GF2m\n#  define EC_POINT_get_affine_coordinates_GF2m    EC_POINT_get_affine_coords_GF2m\n#  undef EC_POINT_set_compressed_coordinates_GF2m\n#  define EC_POINT_set_compressed_coordinates_GF2m \\\n                                                EC_POINT_set_compr_coords_GF2m\n#  undef ec_GF2m_simple_group_clear_finish\n#  define ec_GF2m_simple_group_clear_finish       ec_GF2m_simple_grp_clr_finish\n#  undef ec_GF2m_simple_group_check_discriminant\n#  define ec_GF2m_simple_group_check_discriminant ec_GF2m_simple_grp_chk_discrim\n#  undef ec_GF2m_simple_point_clear_finish\n#  define ec_GF2m_simple_point_clear_finish       ec_GF2m_simple_pt_clr_finish\n#  undef ec_GF2m_simple_point_set_to_infinity\n#  define ec_GF2m_simple_point_set_to_infinity    ec_GF2m_simple_pt_set_to_inf\n#  undef ec_GF2m_simple_points_make_affine\n#  define ec_GF2m_simple_points_make_affine       ec_GF2m_simple_pts_make_affine\n#  undef ec_GF2m_simple_point_set_affine_coordinates\n#  define ec_GF2m_simple_point_set_affine_coordinates \\\n                                                ec_GF2m_smp_pt_set_af_coords\n#  undef ec_GF2m_simple_point_get_affine_coordinates\n#  define ec_GF2m_simple_point_get_affine_coordinates \\\n                                                ec_GF2m_smp_pt_get_af_coords\n#  undef ec_GF2m_simple_set_compressed_coordinates\n#  define ec_GF2m_simple_set_compressed_coordinates \\\n                                                ec_GF2m_smp_set_compr_coords\n#  undef ec_GFp_simple_group_set_curve_GFp\n#  define ec_GFp_simple_group_set_curve_GFp       ec_GFp_simple_grp_set_curve_GFp\n#  undef ec_GFp_simple_group_get_curve_GFp\n#  define ec_GFp_simple_group_get_curve_GFp       ec_GFp_simple_grp_get_curve_GFp\n#  undef ec_GFp_simple_group_clear_finish\n#  define ec_GFp_simple_group_clear_finish        ec_GFp_simple_grp_clear_finish\n#  undef ec_GFp_simple_group_set_generator\n#  define ec_GFp_simple_group_set_generator       ec_GFp_simple_grp_set_generator\n#  undef ec_GFp_simple_group_get0_generator\n#  define ec_GFp_simple_group_get0_generator      ec_GFp_simple_grp_gt0_generator\n#  undef ec_GFp_simple_group_get_cofactor\n#  define ec_GFp_simple_group_get_cofactor        ec_GFp_simple_grp_get_cofactor\n#  undef ec_GFp_simple_point_clear_finish\n#  define ec_GFp_simple_point_clear_finish        ec_GFp_simple_pt_clear_finish\n#  undef ec_GFp_simple_point_set_to_infinity\n#  define ec_GFp_simple_point_set_to_infinity     ec_GFp_simple_pt_set_to_inf\n#  undef ec_GFp_simple_points_make_affine\n#  define ec_GFp_simple_points_make_affine        ec_GFp_simple_pts_make_affine\n#  undef ec_GFp_simple_set_Jprojective_coordinates_GFp\n#  define ec_GFp_simple_set_Jprojective_coordinates_GFp \\\n                                                ec_GFp_smp_set_Jproj_coords_GFp\n#  undef ec_GFp_simple_get_Jprojective_coordinates_GFp\n#  define ec_GFp_simple_get_Jprojective_coordinates_GFp \\\n                                                ec_GFp_smp_get_Jproj_coords_GFp\n#  undef ec_GFp_simple_point_set_affine_coordinates_GFp\n#  define ec_GFp_simple_point_set_affine_coordinates_GFp \\\n                                                ec_GFp_smp_pt_set_af_coords_GFp\n#  undef ec_GFp_simple_point_get_affine_coordinates_GFp\n#  define ec_GFp_simple_point_get_affine_coordinates_GFp \\\n                                                ec_GFp_smp_pt_get_af_coords_GFp\n#  undef ec_GFp_simple_set_compressed_coordinates_GFp\n#  define ec_GFp_simple_set_compressed_coordinates_GFp \\\n                                                ec_GFp_smp_set_compr_coords_GFp\n#  undef ec_GFp_simple_point_set_affine_coordinates\n#  define ec_GFp_simple_point_set_affine_coordinates \\\n                                                ec_GFp_smp_pt_set_af_coords\n#  undef ec_GFp_simple_point_get_affine_coordinates\n#  define ec_GFp_simple_point_get_affine_coordinates \\\n                                                ec_GFp_smp_pt_get_af_coords\n#  undef ec_GFp_simple_set_compressed_coordinates\n#  define ec_GFp_simple_set_compressed_coordinates \\\n                                                ec_GFp_smp_set_compr_coords\n#  undef ec_GFp_simple_group_check_discriminant\n#  define ec_GFp_simple_group_check_discriminant  ec_GFp_simple_grp_chk_discrim\n\n/* Hack som long STORE names */\n#  undef STORE_method_set_initialise_function\n#  define STORE_method_set_initialise_function    STORE_meth_set_initialise_fn\n#  undef STORE_method_set_cleanup_function\n#  define STORE_method_set_cleanup_function       STORE_meth_set_cleanup_fn\n#  undef STORE_method_set_generate_function\n#  define STORE_method_set_generate_function      STORE_meth_set_generate_fn\n#  undef STORE_method_set_modify_function\n#  define STORE_method_set_modify_function        STORE_meth_set_modify_fn\n#  undef STORE_method_set_revoke_function\n#  define STORE_method_set_revoke_function        STORE_meth_set_revoke_fn\n#  undef STORE_method_set_delete_function\n#  define STORE_method_set_delete_function        STORE_meth_set_delete_fn\n#  undef STORE_method_set_list_start_function\n#  define STORE_method_set_list_start_function    STORE_meth_set_list_start_fn\n#  undef STORE_method_set_list_next_function\n#  define STORE_method_set_list_next_function     STORE_meth_set_list_next_fn\n#  undef STORE_method_set_list_end_function\n#  define STORE_method_set_list_end_function      STORE_meth_set_list_end_fn\n#  undef STORE_method_set_update_store_function\n#  define STORE_method_set_update_store_function  STORE_meth_set_update_store_fn\n#  undef STORE_method_set_lock_store_function\n#  define STORE_method_set_lock_store_function    STORE_meth_set_lock_store_fn\n#  undef STORE_method_set_unlock_store_function\n#  define STORE_method_set_unlock_store_function  STORE_meth_set_unlock_store_fn\n#  undef STORE_method_get_initialise_function\n#  define STORE_method_get_initialise_function    STORE_meth_get_initialise_fn\n#  undef STORE_method_get_cleanup_function\n#  define STORE_method_get_cleanup_function       STORE_meth_get_cleanup_fn\n#  undef STORE_method_get_generate_function\n#  define STORE_method_get_generate_function      STORE_meth_get_generate_fn\n#  undef STORE_method_get_modify_function\n#  define STORE_method_get_modify_function        STORE_meth_get_modify_fn\n#  undef STORE_method_get_revoke_function\n#  define STORE_method_get_revoke_function        STORE_meth_get_revoke_fn\n#  undef STORE_method_get_delete_function\n#  define STORE_method_get_delete_function        STORE_meth_get_delete_fn\n#  undef STORE_method_get_list_start_function\n#  define STORE_method_get_list_start_function    STORE_meth_get_list_start_fn\n#  undef STORE_method_get_list_next_function\n#  define STORE_method_get_list_next_function     STORE_meth_get_list_next_fn\n#  undef STORE_method_get_list_end_function\n#  define STORE_method_get_list_end_function      STORE_meth_get_list_end_fn\n#  undef STORE_method_get_update_store_function\n#  define STORE_method_get_update_store_function  STORE_meth_get_update_store_fn\n#  undef STORE_method_get_lock_store_function\n#  define STORE_method_get_lock_store_function    STORE_meth_get_lock_store_fn\n#  undef STORE_method_get_unlock_store_function\n#  define STORE_method_get_unlock_store_function  STORE_meth_get_unlock_store_fn\n\n/* Hack some long TS names */\n#  undef TS_RESP_CTX_set_status_info_cond\n#  define TS_RESP_CTX_set_status_info_cond        TS_RESP_CTX_set_stat_info_cond\n#  undef TS_RESP_CTX_set_clock_precision_digits\n#  define TS_RESP_CTX_set_clock_precision_digits  TS_RESP_CTX_set_clk_prec_digits\n#  undef TS_CONF_set_clock_precision_digits\n#  define TS_CONF_set_clock_precision_digits      TS_CONF_set_clk_prec_digits\n\n/* Hack some long CMS names */\n#  undef CMS_RecipientInfo_ktri_get0_algs\n#  define CMS_RecipientInfo_ktri_get0_algs        CMS_RecipInfo_ktri_get0_algs\n#  undef CMS_RecipientInfo_ktri_get0_signer_id\n#  define CMS_RecipientInfo_ktri_get0_signer_id   CMS_RecipInfo_ktri_get0_sigr_id\n#  undef CMS_OtherRevocationInfoFormat_it\n#  define CMS_OtherRevocationInfoFormat_it        CMS_OtherRevocInfoFormat_it\n#  undef CMS_KeyAgreeRecipientIdentifier_it\n#  define CMS_KeyAgreeRecipientIdentifier_it      CMS_KeyAgreeRecipIdentifier_it\n#  undef CMS_OriginatorIdentifierOrKey_it\n#  define CMS_OriginatorIdentifierOrKey_it        CMS_OriginatorIdOrKey_it\n#  undef cms_SignerIdentifier_get0_signer_id\n#  define cms_SignerIdentifier_get0_signer_id     cms_SignerId_get0_signer_id\n#  undef CMS_RecipientInfo_kari_get0_orig_id\n#  define CMS_RecipientInfo_kari_get0_orig_id     CMS_RecipInfo_kari_get0_orig_id\n#  undef CMS_RecipientInfo_kari_get0_reks\n#  define CMS_RecipientInfo_kari_get0_reks        CMS_RecipInfo_kari_get0_reks\n#  undef CMS_RecipientEncryptedKey_cert_cmp\n#  define CMS_RecipientEncryptedKey_cert_cmp      CMS_RecipEncryptedKey_cert_cmp\n#  undef CMS_RecipientInfo_kari_set0_pkey\n#  define CMS_RecipientInfo_kari_set0_pkey        CMS_RecipInfo_kari_set0_pkey\n#  undef CMS_RecipientEncryptedKey_get0_id\n#  define CMS_RecipientEncryptedKey_get0_id       CMS_RecipEncryptedKey_get0_id\n#  undef CMS_RecipientInfo_kari_orig_id_cmp\n#  define CMS_RecipientInfo_kari_orig_id_cmp      CMS_RecipInfo_kari_orig_id_cmp\n\n/* Hack some long DTLS1 names */\n#  undef dtls1_retransmit_buffered_messages\n#  define dtls1_retransmit_buffered_messages      dtls1_retransmit_buffered_msgs\n\n/* Hack some long SRP names */\n#  undef SRP_generate_server_master_secret\n#  define SRP_generate_server_master_secret       SRP_gen_server_master_secret\n#  undef SRP_generate_client_master_secret\n#  define SRP_generate_client_master_secret       SRP_gen_client_master_secret\n\n/* Hack some long UI names */\n#  undef UI_method_get_prompt_constructor\n#  define UI_method_get_prompt_constructor        UI_method_get_prompt_constructr\n#  undef UI_method_set_prompt_constructor\n#  define UI_method_set_prompt_constructor        UI_method_set_prompt_constructr\n\n# endif                         /* defined OPENSSL_SYS_VMS */\n\n/* Case insensitive linking causes problems.... */\n# if defined(OPENSSL_SYS_VMS) || defined(OPENSSL_SYS_OS2)\n#  undef ERR_load_CRYPTO_strings\n#  define ERR_load_CRYPTO_strings                 ERR_load_CRYPTOlib_strings\n#  undef OCSP_crlID_new\n#  define OCSP_crlID_new                          OCSP_crlID2_new\n\n#  undef d2i_ECPARAMETERS\n#  define d2i_ECPARAMETERS                        d2i_UC_ECPARAMETERS\n#  undef i2d_ECPARAMETERS\n#  define i2d_ECPARAMETERS                        i2d_UC_ECPARAMETERS\n#  undef d2i_ECPKPARAMETERS\n#  define d2i_ECPKPARAMETERS                      d2i_UC_ECPKPARAMETERS\n#  undef i2d_ECPKPARAMETERS\n#  define i2d_ECPKPARAMETERS                      i2d_UC_ECPKPARAMETERS\n\n/*\n * These functions do not seem to exist! However, I'm paranoid... Original\n * command in x509v3.h: These functions are being redefined in another\n * directory, and clash when the linker is case-insensitive, so let's hide\n * them a little, by giving them an extra 'o' at the beginning of the name...\n */\n#  undef X509v3_cleanup_extensions\n#  define X509v3_cleanup_extensions               oX509v3_cleanup_extensions\n#  undef X509v3_add_extension\n#  define X509v3_add_extension                    oX509v3_add_extension\n#  undef X509v3_add_netscape_extensions\n#  define X509v3_add_netscape_extensions          oX509v3_add_netscape_extensions\n#  undef X509v3_add_standard_extensions\n#  define X509v3_add_standard_extensions          oX509v3_add_standard_extensions\n\n/* This one clashes with CMS_data_create */\n#  undef cms_Data_create\n#  define cms_Data_create                         priv_cms_Data_create\n\n# endif\n\n#endif                          /* ! defined HEADER_VMS_IDHACKS_H */\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/x86/include/openssl/tls1.h",
    "content": "/* ssl/tls1.h */\n/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)\n * All rights reserved.\n *\n * This package is an SSL implementation written\n * by Eric Young (eay@cryptsoft.com).\n * The implementation was written so as to conform with Netscapes SSL.\n *\n * This library is free for commercial and non-commercial use as long as\n * the following conditions are aheared to.  The following conditions\n * apply to all code found in this distribution, be it the RC4, RSA,\n * lhash, DES, etc., code; not just the SSL code.  The SSL documentation\n * included with this distribution is covered by the same copyright terms\n * except that the holder is Tim Hudson (tjh@cryptsoft.com).\n *\n * Copyright remains Eric Young's, and as such any Copyright notices in\n * the code are not to be removed.\n * If this package is used in a product, Eric Young should be given attribution\n * as the author of the parts of the library used.\n * This can be in the form of a textual message at program startup or\n * in documentation (online or textual) provided with the package.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the copyright\n *    notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in the\n *    documentation and/or other materials provided with the distribution.\n * 3. All advertising materials mentioning features or use of this software\n *    must display the following acknowledgement:\n *    \"This product includes cryptographic software written by\n *     Eric Young (eay@cryptsoft.com)\"\n *    The word 'cryptographic' can be left out if the rouines from the library\n *    being used are not cryptographic related :-).\n * 4. If you include any Windows specific code (or a derivative thereof) from\n *    the apps directory (application code) you must include an acknowledgement:\n *    \"This product includes software written by Tim Hudson (tjh@cryptsoft.com)\"\n *\n * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n * SUCH DAMAGE.\n *\n * The licence and distribution terms for any publically available version or\n * derivative of this code cannot be changed.  i.e. this code cannot simply be\n * copied and put under another distribution licence\n * [including the GNU Public Licence.]\n */\n/* ====================================================================\n * Copyright (c) 1998-2006 The OpenSSL Project.  All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n *\n * 1. Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n *\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in\n *    the documentation and/or other materials provided with the\n *    distribution.\n *\n * 3. All advertising materials mentioning features or use of this\n *    software must display the following acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit. (http://www.openssl.org/)\"\n *\n * 4. The names \"OpenSSL Toolkit\" and \"OpenSSL Project\" must not be used to\n *    endorse or promote products derived from this software without\n *    prior written permission. For written permission, please contact\n *    openssl-core@openssl.org.\n *\n * 5. Products derived from this software may not be called \"OpenSSL\"\n *    nor may \"OpenSSL\" appear in their names without prior written\n *    permission of the OpenSSL Project.\n *\n * 6. Redistributions of any form whatsoever must retain the following\n *    acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit (http://www.openssl.org/)\"\n *\n * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY\n * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\n * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR\n * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\n * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,\n * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED\n * OF THE POSSIBILITY OF SUCH DAMAGE.\n * ====================================================================\n *\n * This product includes cryptographic software written by Eric Young\n * (eay@cryptsoft.com).  This product includes software written by Tim\n * Hudson (tjh@cryptsoft.com).\n *\n */\n/* ====================================================================\n * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED.\n *\n * Portions of the attached software (\"Contribution\") are developed by\n * SUN MICROSYSTEMS, INC., and are contributed to the OpenSSL project.\n *\n * The Contribution is licensed pursuant to the OpenSSL open source\n * license provided above.\n *\n * ECC cipher suite support in OpenSSL originally written by\n * Vipul Gupta and Sumit Gupta of Sun Microsystems Laboratories.\n *\n */\n/* ====================================================================\n * Copyright 2005 Nokia. All rights reserved.\n *\n * The portions of the attached software (\"Contribution\") is developed by\n * Nokia Corporation and is licensed pursuant to the OpenSSL open source\n * license.\n *\n * The Contribution, originally written by Mika Kousa and Pasi Eronen of\n * Nokia Corporation, consists of the \"PSK\" (Pre-Shared Key) ciphersuites\n * support (see RFC 4279) to OpenSSL.\n *\n * No patent licenses or other rights except those expressly stated in\n * the OpenSSL open source license shall be deemed granted or received\n * expressly, by implication, estoppel, or otherwise.\n *\n * No assurances are provided by Nokia that the Contribution does not\n * infringe the patent or other intellectual property rights of any third\n * party or that the license provides you with all the necessary rights\n * to make use of the Contribution.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\" WITHOUT WARRANTY OF ANY KIND. IN\n * ADDITION TO THE DISCLAIMERS INCLUDED IN THE LICENSE, NOKIA\n * SPECIFICALLY DISCLAIMS ANY LIABILITY FOR CLAIMS BROUGHT BY YOU OR ANY\n * OTHER ENTITY BASED ON INFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS OR\n * OTHERWISE.\n */\n\n#ifndef HEADER_TLS1_H\n# define HEADER_TLS1_H\n\n# include <openssl/buffer.h>\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n# define TLS1_ALLOW_EXPERIMENTAL_CIPHERSUITES    0\n\n# define TLS1_VERSION                    0x0301\n# define TLS1_1_VERSION                  0x0302\n# define TLS1_2_VERSION                  0x0303\n# define TLS_MAX_VERSION                 TLS1_2_VERSION\n\n# define TLS1_VERSION_MAJOR              0x03\n# define TLS1_VERSION_MINOR              0x01\n\n# define TLS1_1_VERSION_MAJOR            0x03\n# define TLS1_1_VERSION_MINOR            0x02\n\n# define TLS1_2_VERSION_MAJOR            0x03\n# define TLS1_2_VERSION_MINOR            0x03\n\n# define TLS1_get_version(s) \\\n                ((s->version >> 8) == TLS1_VERSION_MAJOR ? s->version : 0)\n\n# define TLS1_get_client_version(s) \\\n                ((s->client_version >> 8) == TLS1_VERSION_MAJOR ? s->client_version : 0)\n\n# define TLS1_AD_DECRYPTION_FAILED       21\n# define TLS1_AD_RECORD_OVERFLOW         22\n# define TLS1_AD_UNKNOWN_CA              48/* fatal */\n# define TLS1_AD_ACCESS_DENIED           49/* fatal */\n# define TLS1_AD_DECODE_ERROR            50/* fatal */\n# define TLS1_AD_DECRYPT_ERROR           51\n# define TLS1_AD_EXPORT_RESTRICTION      60/* fatal */\n# define TLS1_AD_PROTOCOL_VERSION        70/* fatal */\n# define TLS1_AD_INSUFFICIENT_SECURITY   71/* fatal */\n# define TLS1_AD_INTERNAL_ERROR          80/* fatal */\n# define TLS1_AD_INAPPROPRIATE_FALLBACK  86/* fatal */\n# define TLS1_AD_USER_CANCELLED          90\n# define TLS1_AD_NO_RENEGOTIATION        100\n/* codes 110-114 are from RFC3546 */\n# define TLS1_AD_UNSUPPORTED_EXTENSION   110\n# define TLS1_AD_CERTIFICATE_UNOBTAINABLE 111\n# define TLS1_AD_UNRECOGNIZED_NAME       112\n# define TLS1_AD_BAD_CERTIFICATE_STATUS_RESPONSE 113\n# define TLS1_AD_BAD_CERTIFICATE_HASH_VALUE 114\n# define TLS1_AD_UNKNOWN_PSK_IDENTITY    115/* fatal */\n\n/* ExtensionType values from RFC3546 / RFC4366 / RFC6066 */\n# define TLSEXT_TYPE_server_name                 0\n# define TLSEXT_TYPE_max_fragment_length         1\n# define TLSEXT_TYPE_client_certificate_url      2\n# define TLSEXT_TYPE_trusted_ca_keys             3\n# define TLSEXT_TYPE_truncated_hmac              4\n# define TLSEXT_TYPE_status_request              5\n/* ExtensionType values from RFC4681 */\n# define TLSEXT_TYPE_user_mapping                6\n/* ExtensionType values from RFC5878 */\n# define TLSEXT_TYPE_client_authz                7\n# define TLSEXT_TYPE_server_authz                8\n/* ExtensionType values from RFC6091 */\n# define TLSEXT_TYPE_cert_type           9\n\n/* ExtensionType values from RFC4492 */\n# define TLSEXT_TYPE_elliptic_curves             10\n# define TLSEXT_TYPE_ec_point_formats            11\n\n/* ExtensionType value from RFC5054 */\n# define TLSEXT_TYPE_srp                         12\n\n/* ExtensionType values from RFC5246 */\n# define TLSEXT_TYPE_signature_algorithms        13\n\n/* ExtensionType value from RFC5764 */\n# define TLSEXT_TYPE_use_srtp    14\n\n/* ExtensionType value from RFC5620 */\n# define TLSEXT_TYPE_heartbeat   15\n\n/* ExtensionType value from RFC7301 */\n# define TLSEXT_TYPE_application_layer_protocol_negotiation 16\n\n/*\n * ExtensionType value for TLS padding extension.\n * http://tools.ietf.org/html/draft-agl-tls-padding\n */\n# define TLSEXT_TYPE_padding     21\n\n/* ExtensionType value from RFC4507 */\n# define TLSEXT_TYPE_session_ticket              35\n\n/* ExtensionType value from draft-rescorla-tls-opaque-prf-input-00.txt */\n# if 0\n/*\n * will have to be provided externally for now ,\n * i.e. build with -DTLSEXT_TYPE_opaque_prf_input=38183\n * using whatever extension number you'd like to try\n */\n#  define TLSEXT_TYPE_opaque_prf_input           ??\n# endif\n\n/* Temporary extension type */\n# define TLSEXT_TYPE_renegotiate                 0xff01\n\n# ifndef OPENSSL_NO_NEXTPROTONEG\n/* This is not an IANA defined extension number */\n#  define TLSEXT_TYPE_next_proto_neg              13172\n# endif\n\n/* NameType value from RFC3546 */\n# define TLSEXT_NAMETYPE_host_name 0\n/* status request value from RFC3546 */\n# define TLSEXT_STATUSTYPE_ocsp 1\n\n/* ECPointFormat values from RFC4492 */\n# define TLSEXT_ECPOINTFORMAT_first                      0\n# define TLSEXT_ECPOINTFORMAT_uncompressed               0\n# define TLSEXT_ECPOINTFORMAT_ansiX962_compressed_prime  1\n# define TLSEXT_ECPOINTFORMAT_ansiX962_compressed_char2  2\n# define TLSEXT_ECPOINTFORMAT_last                       2\n\n/* Signature and hash algorithms from RFC5246 */\n# define TLSEXT_signature_anonymous                      0\n# define TLSEXT_signature_rsa                            1\n# define TLSEXT_signature_dsa                            2\n# define TLSEXT_signature_ecdsa                          3\n\n/* Total number of different signature algorithms */\n# define TLSEXT_signature_num                            4\n\n# define TLSEXT_hash_none                                0\n# define TLSEXT_hash_md5                                 1\n# define TLSEXT_hash_sha1                                2\n# define TLSEXT_hash_sha224                              3\n# define TLSEXT_hash_sha256                              4\n# define TLSEXT_hash_sha384                              5\n# define TLSEXT_hash_sha512                              6\n\n/* Total number of different digest algorithms */\n\n# define TLSEXT_hash_num                                 7\n\n/* Flag set for unrecognised algorithms */\n# define TLSEXT_nid_unknown                              0x1000000\n\n/* ECC curves */\n\n# define TLSEXT_curve_P_256                              23\n# define TLSEXT_curve_P_384                              24\n\n# ifndef OPENSSL_NO_TLSEXT\n\n#  define TLSEXT_MAXLEN_host_name 255\n\nconst char *SSL_get_servername(const SSL *s, const int type);\nint SSL_get_servername_type(const SSL *s);\n/*\n * SSL_export_keying_material exports a value derived from the master secret,\n * as specified in RFC 5705. It writes |olen| bytes to |out| given a label and\n * optional context. (Since a zero length context is allowed, the |use_context|\n * flag controls whether a context is included.) It returns 1 on success and\n * zero otherwise.\n */\nint SSL_export_keying_material(SSL *s, unsigned char *out, size_t olen,\n                               const char *label, size_t llen,\n                               const unsigned char *p, size_t plen,\n                               int use_context);\n\nint SSL_get_sigalgs(SSL *s, int idx,\n                    int *psign, int *phash, int *psignandhash,\n                    unsigned char *rsig, unsigned char *rhash);\n\nint SSL_get_shared_sigalgs(SSL *s, int idx,\n                           int *psign, int *phash, int *psignandhash,\n                           unsigned char *rsig, unsigned char *rhash);\n\nint SSL_check_chain(SSL *s, X509 *x, EVP_PKEY *pk, STACK_OF(X509) *chain);\n\n#  define SSL_set_tlsext_host_name(s,name) \\\nSSL_ctrl(s,SSL_CTRL_SET_TLSEXT_HOSTNAME,TLSEXT_NAMETYPE_host_name,(char *)name)\n\n#  define SSL_set_tlsext_debug_callback(ssl, cb) \\\nSSL_callback_ctrl(ssl,SSL_CTRL_SET_TLSEXT_DEBUG_CB,(void (*)(void))cb)\n\n#  define SSL_set_tlsext_debug_arg(ssl, arg) \\\nSSL_ctrl(ssl,SSL_CTRL_SET_TLSEXT_DEBUG_ARG,0, (void *)arg)\n\n#  define SSL_set_tlsext_status_type(ssl, type) \\\nSSL_ctrl(ssl,SSL_CTRL_SET_TLSEXT_STATUS_REQ_TYPE,type, NULL)\n\n#  define SSL_get_tlsext_status_exts(ssl, arg) \\\nSSL_ctrl(ssl,SSL_CTRL_GET_TLSEXT_STATUS_REQ_EXTS,0, (void *)arg)\n\n#  define SSL_set_tlsext_status_exts(ssl, arg) \\\nSSL_ctrl(ssl,SSL_CTRL_SET_TLSEXT_STATUS_REQ_EXTS,0, (void *)arg)\n\n#  define SSL_get_tlsext_status_ids(ssl, arg) \\\nSSL_ctrl(ssl,SSL_CTRL_GET_TLSEXT_STATUS_REQ_IDS,0, (void *)arg)\n\n#  define SSL_set_tlsext_status_ids(ssl, arg) \\\nSSL_ctrl(ssl,SSL_CTRL_SET_TLSEXT_STATUS_REQ_IDS,0, (void *)arg)\n\n#  define SSL_get_tlsext_status_ocsp_resp(ssl, arg) \\\nSSL_ctrl(ssl,SSL_CTRL_GET_TLSEXT_STATUS_REQ_OCSP_RESP,0, (void *)arg)\n\n#  define SSL_set_tlsext_status_ocsp_resp(ssl, arg, arglen) \\\nSSL_ctrl(ssl,SSL_CTRL_SET_TLSEXT_STATUS_REQ_OCSP_RESP,arglen, (void *)arg)\n\n#  define SSL_CTX_set_tlsext_servername_callback(ctx, cb) \\\nSSL_CTX_callback_ctrl(ctx,SSL_CTRL_SET_TLSEXT_SERVERNAME_CB,(void (*)(void))cb)\n\n#  define SSL_TLSEXT_ERR_OK 0\n#  define SSL_TLSEXT_ERR_ALERT_WARNING 1\n#  define SSL_TLSEXT_ERR_ALERT_FATAL 2\n#  define SSL_TLSEXT_ERR_NOACK 3\n\n#  define SSL_CTX_set_tlsext_servername_arg(ctx, arg) \\\nSSL_CTX_ctrl(ctx,SSL_CTRL_SET_TLSEXT_SERVERNAME_ARG,0, (void *)arg)\n\n#  define SSL_CTX_get_tlsext_ticket_keys(ctx, keys, keylen) \\\n        SSL_CTX_ctrl((ctx),SSL_CTRL_GET_TLSEXT_TICKET_KEYS,(keylen),(keys))\n#  define SSL_CTX_set_tlsext_ticket_keys(ctx, keys, keylen) \\\n        SSL_CTX_ctrl((ctx),SSL_CTRL_SET_TLSEXT_TICKET_KEYS,(keylen),(keys))\n\n#  define SSL_CTX_set_tlsext_status_cb(ssl, cb) \\\nSSL_CTX_callback_ctrl(ssl,SSL_CTRL_SET_TLSEXT_STATUS_REQ_CB,(void (*)(void))cb)\n\n#  define SSL_CTX_set_tlsext_status_arg(ssl, arg) \\\nSSL_CTX_ctrl(ssl,SSL_CTRL_SET_TLSEXT_STATUS_REQ_CB_ARG,0, (void *)arg)\n\n#  define SSL_set_tlsext_opaque_prf_input(s, src, len) \\\nSSL_ctrl(s,SSL_CTRL_SET_TLSEXT_OPAQUE_PRF_INPUT, len, src)\n#  define SSL_CTX_set_tlsext_opaque_prf_input_callback(ctx, cb) \\\nSSL_CTX_callback_ctrl(ctx,SSL_CTRL_SET_TLSEXT_OPAQUE_PRF_INPUT_CB, (void (*)(void))cb)\n#  define SSL_CTX_set_tlsext_opaque_prf_input_callback_arg(ctx, arg) \\\nSSL_CTX_ctrl(ctx,SSL_CTRL_SET_TLSEXT_OPAQUE_PRF_INPUT_CB_ARG, 0, arg)\n\n#  define SSL_CTX_set_tlsext_ticket_key_cb(ssl, cb) \\\nSSL_CTX_callback_ctrl(ssl,SSL_CTRL_SET_TLSEXT_TICKET_KEY_CB,(void (*)(void))cb)\n\n#  ifndef OPENSSL_NO_HEARTBEATS\n#   define SSL_TLSEXT_HB_ENABLED                           0x01\n#   define SSL_TLSEXT_HB_DONT_SEND_REQUESTS        0x02\n#   define SSL_TLSEXT_HB_DONT_RECV_REQUESTS        0x04\n\n#   define SSL_get_tlsext_heartbeat_pending(ssl) \\\n        SSL_ctrl((ssl),SSL_CTRL_GET_TLS_EXT_HEARTBEAT_PENDING,0,NULL)\n#   define SSL_set_tlsext_heartbeat_no_requests(ssl, arg) \\\n        SSL_ctrl((ssl),SSL_CTRL_SET_TLS_EXT_HEARTBEAT_NO_REQUESTS,arg,NULL)\n#  endif\n# endif\n\n/* PSK ciphersuites from 4279 */\n# define TLS1_CK_PSK_WITH_RC4_128_SHA                    0x0300008A\n# define TLS1_CK_PSK_WITH_3DES_EDE_CBC_SHA               0x0300008B\n# define TLS1_CK_PSK_WITH_AES_128_CBC_SHA                0x0300008C\n# define TLS1_CK_PSK_WITH_AES_256_CBC_SHA                0x0300008D\n\n/*\n * Additional TLS ciphersuites from expired Internet Draft\n * draft-ietf-tls-56-bit-ciphersuites-01.txt (available if\n * TLS1_ALLOW_EXPERIMENTAL_CIPHERSUITES is defined, see s3_lib.c).  We\n * actually treat them like SSL 3.0 ciphers, which we probably shouldn't.\n * Note that the first two are actually not in the IDs.\n */\n# define TLS1_CK_RSA_EXPORT1024_WITH_RC4_56_MD5          0x03000060/* not in\n                                                                    * ID */\n# define TLS1_CK_RSA_EXPORT1024_WITH_RC2_CBC_56_MD5      0x03000061/* not in\n                                                                    * ID */\n# define TLS1_CK_RSA_EXPORT1024_WITH_DES_CBC_SHA         0x03000062\n# define TLS1_CK_DHE_DSS_EXPORT1024_WITH_DES_CBC_SHA     0x03000063\n# define TLS1_CK_RSA_EXPORT1024_WITH_RC4_56_SHA          0x03000064\n# define TLS1_CK_DHE_DSS_EXPORT1024_WITH_RC4_56_SHA      0x03000065\n# define TLS1_CK_DHE_DSS_WITH_RC4_128_SHA                0x03000066\n\n/* AES ciphersuites from RFC3268 */\n# define TLS1_CK_RSA_WITH_AES_128_SHA                    0x0300002F\n# define TLS1_CK_DH_DSS_WITH_AES_128_SHA                 0x03000030\n# define TLS1_CK_DH_RSA_WITH_AES_128_SHA                 0x03000031\n# define TLS1_CK_DHE_DSS_WITH_AES_128_SHA                0x03000032\n# define TLS1_CK_DHE_RSA_WITH_AES_128_SHA                0x03000033\n# define TLS1_CK_ADH_WITH_AES_128_SHA                    0x03000034\n\n# define TLS1_CK_RSA_WITH_AES_256_SHA                    0x03000035\n# define TLS1_CK_DH_DSS_WITH_AES_256_SHA                 0x03000036\n# define TLS1_CK_DH_RSA_WITH_AES_256_SHA                 0x03000037\n# define TLS1_CK_DHE_DSS_WITH_AES_256_SHA                0x03000038\n# define TLS1_CK_DHE_RSA_WITH_AES_256_SHA                0x03000039\n# define TLS1_CK_ADH_WITH_AES_256_SHA                    0x0300003A\n\n/* TLS v1.2 ciphersuites */\n# define TLS1_CK_RSA_WITH_NULL_SHA256                    0x0300003B\n# define TLS1_CK_RSA_WITH_AES_128_SHA256                 0x0300003C\n# define TLS1_CK_RSA_WITH_AES_256_SHA256                 0x0300003D\n# define TLS1_CK_DH_DSS_WITH_AES_128_SHA256              0x0300003E\n# define TLS1_CK_DH_RSA_WITH_AES_128_SHA256              0x0300003F\n# define TLS1_CK_DHE_DSS_WITH_AES_128_SHA256             0x03000040\n\n/* Camellia ciphersuites from RFC4132 */\n# define TLS1_CK_RSA_WITH_CAMELLIA_128_CBC_SHA           0x03000041\n# define TLS1_CK_DH_DSS_WITH_CAMELLIA_128_CBC_SHA        0x03000042\n# define TLS1_CK_DH_RSA_WITH_CAMELLIA_128_CBC_SHA        0x03000043\n# define TLS1_CK_DHE_DSS_WITH_CAMELLIA_128_CBC_SHA       0x03000044\n# define TLS1_CK_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA       0x03000045\n# define TLS1_CK_ADH_WITH_CAMELLIA_128_CBC_SHA           0x03000046\n\n/* TLS v1.2 ciphersuites */\n# define TLS1_CK_DHE_RSA_WITH_AES_128_SHA256             0x03000067\n# define TLS1_CK_DH_DSS_WITH_AES_256_SHA256              0x03000068\n# define TLS1_CK_DH_RSA_WITH_AES_256_SHA256              0x03000069\n# define TLS1_CK_DHE_DSS_WITH_AES_256_SHA256             0x0300006A\n# define TLS1_CK_DHE_RSA_WITH_AES_256_SHA256             0x0300006B\n# define TLS1_CK_ADH_WITH_AES_128_SHA256                 0x0300006C\n# define TLS1_CK_ADH_WITH_AES_256_SHA256                 0x0300006D\n\n/* Camellia ciphersuites from RFC4132 */\n# define TLS1_CK_RSA_WITH_CAMELLIA_256_CBC_SHA           0x03000084\n# define TLS1_CK_DH_DSS_WITH_CAMELLIA_256_CBC_SHA        0x03000085\n# define TLS1_CK_DH_RSA_WITH_CAMELLIA_256_CBC_SHA        0x03000086\n# define TLS1_CK_DHE_DSS_WITH_CAMELLIA_256_CBC_SHA       0x03000087\n# define TLS1_CK_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA       0x03000088\n# define TLS1_CK_ADH_WITH_CAMELLIA_256_CBC_SHA           0x03000089\n\n/* SEED ciphersuites from RFC4162 */\n# define TLS1_CK_RSA_WITH_SEED_SHA                       0x03000096\n# define TLS1_CK_DH_DSS_WITH_SEED_SHA                    0x03000097\n# define TLS1_CK_DH_RSA_WITH_SEED_SHA                    0x03000098\n# define TLS1_CK_DHE_DSS_WITH_SEED_SHA                   0x03000099\n# define TLS1_CK_DHE_RSA_WITH_SEED_SHA                   0x0300009A\n# define TLS1_CK_ADH_WITH_SEED_SHA                       0x0300009B\n\n/* TLS v1.2 GCM ciphersuites from RFC5288 */\n# define TLS1_CK_RSA_WITH_AES_128_GCM_SHA256             0x0300009C\n# define TLS1_CK_RSA_WITH_AES_256_GCM_SHA384             0x0300009D\n# define TLS1_CK_DHE_RSA_WITH_AES_128_GCM_SHA256         0x0300009E\n# define TLS1_CK_DHE_RSA_WITH_AES_256_GCM_SHA384         0x0300009F\n# define TLS1_CK_DH_RSA_WITH_AES_128_GCM_SHA256          0x030000A0\n# define TLS1_CK_DH_RSA_WITH_AES_256_GCM_SHA384          0x030000A1\n# define TLS1_CK_DHE_DSS_WITH_AES_128_GCM_SHA256         0x030000A2\n# define TLS1_CK_DHE_DSS_WITH_AES_256_GCM_SHA384         0x030000A3\n# define TLS1_CK_DH_DSS_WITH_AES_128_GCM_SHA256          0x030000A4\n# define TLS1_CK_DH_DSS_WITH_AES_256_GCM_SHA384          0x030000A5\n# define TLS1_CK_ADH_WITH_AES_128_GCM_SHA256             0x030000A6\n# define TLS1_CK_ADH_WITH_AES_256_GCM_SHA384             0x030000A7\n\n/*\n * ECC ciphersuites from draft-ietf-tls-ecc-12.txt with changes soon to be in\n * draft 13\n */\n# define TLS1_CK_ECDH_ECDSA_WITH_NULL_SHA                0x0300C001\n# define TLS1_CK_ECDH_ECDSA_WITH_RC4_128_SHA             0x0300C002\n# define TLS1_CK_ECDH_ECDSA_WITH_DES_192_CBC3_SHA        0x0300C003\n# define TLS1_CK_ECDH_ECDSA_WITH_AES_128_CBC_SHA         0x0300C004\n# define TLS1_CK_ECDH_ECDSA_WITH_AES_256_CBC_SHA         0x0300C005\n\n# define TLS1_CK_ECDHE_ECDSA_WITH_NULL_SHA               0x0300C006\n# define TLS1_CK_ECDHE_ECDSA_WITH_RC4_128_SHA            0x0300C007\n# define TLS1_CK_ECDHE_ECDSA_WITH_DES_192_CBC3_SHA       0x0300C008\n# define TLS1_CK_ECDHE_ECDSA_WITH_AES_128_CBC_SHA        0x0300C009\n# define TLS1_CK_ECDHE_ECDSA_WITH_AES_256_CBC_SHA        0x0300C00A\n\n# define TLS1_CK_ECDH_RSA_WITH_NULL_SHA                  0x0300C00B\n# define TLS1_CK_ECDH_RSA_WITH_RC4_128_SHA               0x0300C00C\n# define TLS1_CK_ECDH_RSA_WITH_DES_192_CBC3_SHA          0x0300C00D\n# define TLS1_CK_ECDH_RSA_WITH_AES_128_CBC_SHA           0x0300C00E\n# define TLS1_CK_ECDH_RSA_WITH_AES_256_CBC_SHA           0x0300C00F\n\n# define TLS1_CK_ECDHE_RSA_WITH_NULL_SHA                 0x0300C010\n# define TLS1_CK_ECDHE_RSA_WITH_RC4_128_SHA              0x0300C011\n# define TLS1_CK_ECDHE_RSA_WITH_DES_192_CBC3_SHA         0x0300C012\n# define TLS1_CK_ECDHE_RSA_WITH_AES_128_CBC_SHA          0x0300C013\n# define TLS1_CK_ECDHE_RSA_WITH_AES_256_CBC_SHA          0x0300C014\n\n# define TLS1_CK_ECDH_anon_WITH_NULL_SHA                 0x0300C015\n# define TLS1_CK_ECDH_anon_WITH_RC4_128_SHA              0x0300C016\n# define TLS1_CK_ECDH_anon_WITH_DES_192_CBC3_SHA         0x0300C017\n# define TLS1_CK_ECDH_anon_WITH_AES_128_CBC_SHA          0x0300C018\n# define TLS1_CK_ECDH_anon_WITH_AES_256_CBC_SHA          0x0300C019\n\n/* SRP ciphersuites from RFC 5054 */\n# define TLS1_CK_SRP_SHA_WITH_3DES_EDE_CBC_SHA           0x0300C01A\n# define TLS1_CK_SRP_SHA_RSA_WITH_3DES_EDE_CBC_SHA       0x0300C01B\n# define TLS1_CK_SRP_SHA_DSS_WITH_3DES_EDE_CBC_SHA       0x0300C01C\n# define TLS1_CK_SRP_SHA_WITH_AES_128_CBC_SHA            0x0300C01D\n# define TLS1_CK_SRP_SHA_RSA_WITH_AES_128_CBC_SHA        0x0300C01E\n# define TLS1_CK_SRP_SHA_DSS_WITH_AES_128_CBC_SHA        0x0300C01F\n# define TLS1_CK_SRP_SHA_WITH_AES_256_CBC_SHA            0x0300C020\n# define TLS1_CK_SRP_SHA_RSA_WITH_AES_256_CBC_SHA        0x0300C021\n# define TLS1_CK_SRP_SHA_DSS_WITH_AES_256_CBC_SHA        0x0300C022\n\n/* ECDH HMAC based ciphersuites from RFC5289 */\n\n# define TLS1_CK_ECDHE_ECDSA_WITH_AES_128_SHA256         0x0300C023\n# define TLS1_CK_ECDHE_ECDSA_WITH_AES_256_SHA384         0x0300C024\n# define TLS1_CK_ECDH_ECDSA_WITH_AES_128_SHA256          0x0300C025\n# define TLS1_CK_ECDH_ECDSA_WITH_AES_256_SHA384          0x0300C026\n# define TLS1_CK_ECDHE_RSA_WITH_AES_128_SHA256           0x0300C027\n# define TLS1_CK_ECDHE_RSA_WITH_AES_256_SHA384           0x0300C028\n# define TLS1_CK_ECDH_RSA_WITH_AES_128_SHA256            0x0300C029\n# define TLS1_CK_ECDH_RSA_WITH_AES_256_SHA384            0x0300C02A\n\n/* ECDH GCM based ciphersuites from RFC5289 */\n# define TLS1_CK_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256     0x0300C02B\n# define TLS1_CK_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384     0x0300C02C\n# define TLS1_CK_ECDH_ECDSA_WITH_AES_128_GCM_SHA256      0x0300C02D\n# define TLS1_CK_ECDH_ECDSA_WITH_AES_256_GCM_SHA384      0x0300C02E\n# define TLS1_CK_ECDHE_RSA_WITH_AES_128_GCM_SHA256       0x0300C02F\n# define TLS1_CK_ECDHE_RSA_WITH_AES_256_GCM_SHA384       0x0300C030\n# define TLS1_CK_ECDH_RSA_WITH_AES_128_GCM_SHA256        0x0300C031\n# define TLS1_CK_ECDH_RSA_WITH_AES_256_GCM_SHA384        0x0300C032\n\n/*\n * XXX * Backward compatibility alert: + * Older versions of OpenSSL gave\n * some DHE ciphers names with \"EDH\" + * instead of \"DHE\".  Going forward, we\n * should be using DHE + * everywhere, though we may indefinitely maintain\n * aliases for users + * or configurations that used \"EDH\" +\n */\n# define TLS1_TXT_RSA_EXPORT1024_WITH_RC4_56_MD5         \"EXP1024-RC4-MD5\"\n# define TLS1_TXT_RSA_EXPORT1024_WITH_RC2_CBC_56_MD5     \"EXP1024-RC2-CBC-MD5\"\n# define TLS1_TXT_RSA_EXPORT1024_WITH_DES_CBC_SHA        \"EXP1024-DES-CBC-SHA\"\n# define TLS1_TXT_DHE_DSS_EXPORT1024_WITH_DES_CBC_SHA    \"EXP1024-DHE-DSS-DES-CBC-SHA\"\n# define TLS1_TXT_RSA_EXPORT1024_WITH_RC4_56_SHA         \"EXP1024-RC4-SHA\"\n# define TLS1_TXT_DHE_DSS_EXPORT1024_WITH_RC4_56_SHA     \"EXP1024-DHE-DSS-RC4-SHA\"\n# define TLS1_TXT_DHE_DSS_WITH_RC4_128_SHA               \"DHE-DSS-RC4-SHA\"\n\n/* AES ciphersuites from RFC3268 */\n# define TLS1_TXT_RSA_WITH_AES_128_SHA                   \"AES128-SHA\"\n# define TLS1_TXT_DH_DSS_WITH_AES_128_SHA                \"DH-DSS-AES128-SHA\"\n# define TLS1_TXT_DH_RSA_WITH_AES_128_SHA                \"DH-RSA-AES128-SHA\"\n# define TLS1_TXT_DHE_DSS_WITH_AES_128_SHA               \"DHE-DSS-AES128-SHA\"\n# define TLS1_TXT_DHE_RSA_WITH_AES_128_SHA               \"DHE-RSA-AES128-SHA\"\n# define TLS1_TXT_ADH_WITH_AES_128_SHA                   \"ADH-AES128-SHA\"\n\n# define TLS1_TXT_RSA_WITH_AES_256_SHA                   \"AES256-SHA\"\n# define TLS1_TXT_DH_DSS_WITH_AES_256_SHA                \"DH-DSS-AES256-SHA\"\n# define TLS1_TXT_DH_RSA_WITH_AES_256_SHA                \"DH-RSA-AES256-SHA\"\n# define TLS1_TXT_DHE_DSS_WITH_AES_256_SHA               \"DHE-DSS-AES256-SHA\"\n# define TLS1_TXT_DHE_RSA_WITH_AES_256_SHA               \"DHE-RSA-AES256-SHA\"\n# define TLS1_TXT_ADH_WITH_AES_256_SHA                   \"ADH-AES256-SHA\"\n\n/* ECC ciphersuites from RFC4492 */\n# define TLS1_TXT_ECDH_ECDSA_WITH_NULL_SHA               \"ECDH-ECDSA-NULL-SHA\"\n# define TLS1_TXT_ECDH_ECDSA_WITH_RC4_128_SHA            \"ECDH-ECDSA-RC4-SHA\"\n# define TLS1_TXT_ECDH_ECDSA_WITH_DES_192_CBC3_SHA       \"ECDH-ECDSA-DES-CBC3-SHA\"\n# define TLS1_TXT_ECDH_ECDSA_WITH_AES_128_CBC_SHA        \"ECDH-ECDSA-AES128-SHA\"\n# define TLS1_TXT_ECDH_ECDSA_WITH_AES_256_CBC_SHA        \"ECDH-ECDSA-AES256-SHA\"\n\n# define TLS1_TXT_ECDHE_ECDSA_WITH_NULL_SHA              \"ECDHE-ECDSA-NULL-SHA\"\n# define TLS1_TXT_ECDHE_ECDSA_WITH_RC4_128_SHA           \"ECDHE-ECDSA-RC4-SHA\"\n# define TLS1_TXT_ECDHE_ECDSA_WITH_DES_192_CBC3_SHA      \"ECDHE-ECDSA-DES-CBC3-SHA\"\n# define TLS1_TXT_ECDHE_ECDSA_WITH_AES_128_CBC_SHA       \"ECDHE-ECDSA-AES128-SHA\"\n# define TLS1_TXT_ECDHE_ECDSA_WITH_AES_256_CBC_SHA       \"ECDHE-ECDSA-AES256-SHA\"\n\n# define TLS1_TXT_ECDH_RSA_WITH_NULL_SHA                 \"ECDH-RSA-NULL-SHA\"\n# define TLS1_TXT_ECDH_RSA_WITH_RC4_128_SHA              \"ECDH-RSA-RC4-SHA\"\n# define TLS1_TXT_ECDH_RSA_WITH_DES_192_CBC3_SHA         \"ECDH-RSA-DES-CBC3-SHA\"\n# define TLS1_TXT_ECDH_RSA_WITH_AES_128_CBC_SHA          \"ECDH-RSA-AES128-SHA\"\n# define TLS1_TXT_ECDH_RSA_WITH_AES_256_CBC_SHA          \"ECDH-RSA-AES256-SHA\"\n\n# define TLS1_TXT_ECDHE_RSA_WITH_NULL_SHA                \"ECDHE-RSA-NULL-SHA\"\n# define TLS1_TXT_ECDHE_RSA_WITH_RC4_128_SHA             \"ECDHE-RSA-RC4-SHA\"\n# define TLS1_TXT_ECDHE_RSA_WITH_DES_192_CBC3_SHA        \"ECDHE-RSA-DES-CBC3-SHA\"\n# define TLS1_TXT_ECDHE_RSA_WITH_AES_128_CBC_SHA         \"ECDHE-RSA-AES128-SHA\"\n# define TLS1_TXT_ECDHE_RSA_WITH_AES_256_CBC_SHA         \"ECDHE-RSA-AES256-SHA\"\n\n# define TLS1_TXT_ECDH_anon_WITH_NULL_SHA                \"AECDH-NULL-SHA\"\n# define TLS1_TXT_ECDH_anon_WITH_RC4_128_SHA             \"AECDH-RC4-SHA\"\n# define TLS1_TXT_ECDH_anon_WITH_DES_192_CBC3_SHA        \"AECDH-DES-CBC3-SHA\"\n# define TLS1_TXT_ECDH_anon_WITH_AES_128_CBC_SHA         \"AECDH-AES128-SHA\"\n# define TLS1_TXT_ECDH_anon_WITH_AES_256_CBC_SHA         \"AECDH-AES256-SHA\"\n\n/* PSK ciphersuites from RFC 4279 */\n# define TLS1_TXT_PSK_WITH_RC4_128_SHA                   \"PSK-RC4-SHA\"\n# define TLS1_TXT_PSK_WITH_3DES_EDE_CBC_SHA              \"PSK-3DES-EDE-CBC-SHA\"\n# define TLS1_TXT_PSK_WITH_AES_128_CBC_SHA               \"PSK-AES128-CBC-SHA\"\n# define TLS1_TXT_PSK_WITH_AES_256_CBC_SHA               \"PSK-AES256-CBC-SHA\"\n\n/* SRP ciphersuite from RFC 5054 */\n# define TLS1_TXT_SRP_SHA_WITH_3DES_EDE_CBC_SHA          \"SRP-3DES-EDE-CBC-SHA\"\n# define TLS1_TXT_SRP_SHA_RSA_WITH_3DES_EDE_CBC_SHA      \"SRP-RSA-3DES-EDE-CBC-SHA\"\n# define TLS1_TXT_SRP_SHA_DSS_WITH_3DES_EDE_CBC_SHA      \"SRP-DSS-3DES-EDE-CBC-SHA\"\n# define TLS1_TXT_SRP_SHA_WITH_AES_128_CBC_SHA           \"SRP-AES-128-CBC-SHA\"\n# define TLS1_TXT_SRP_SHA_RSA_WITH_AES_128_CBC_SHA       \"SRP-RSA-AES-128-CBC-SHA\"\n# define TLS1_TXT_SRP_SHA_DSS_WITH_AES_128_CBC_SHA       \"SRP-DSS-AES-128-CBC-SHA\"\n# define TLS1_TXT_SRP_SHA_WITH_AES_256_CBC_SHA           \"SRP-AES-256-CBC-SHA\"\n# define TLS1_TXT_SRP_SHA_RSA_WITH_AES_256_CBC_SHA       \"SRP-RSA-AES-256-CBC-SHA\"\n# define TLS1_TXT_SRP_SHA_DSS_WITH_AES_256_CBC_SHA       \"SRP-DSS-AES-256-CBC-SHA\"\n\n/* Camellia ciphersuites from RFC4132 */\n# define TLS1_TXT_RSA_WITH_CAMELLIA_128_CBC_SHA          \"CAMELLIA128-SHA\"\n# define TLS1_TXT_DH_DSS_WITH_CAMELLIA_128_CBC_SHA       \"DH-DSS-CAMELLIA128-SHA\"\n# define TLS1_TXT_DH_RSA_WITH_CAMELLIA_128_CBC_SHA       \"DH-RSA-CAMELLIA128-SHA\"\n# define TLS1_TXT_DHE_DSS_WITH_CAMELLIA_128_CBC_SHA      \"DHE-DSS-CAMELLIA128-SHA\"\n# define TLS1_TXT_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA      \"DHE-RSA-CAMELLIA128-SHA\"\n# define TLS1_TXT_ADH_WITH_CAMELLIA_128_CBC_SHA          \"ADH-CAMELLIA128-SHA\"\n\n# define TLS1_TXT_RSA_WITH_CAMELLIA_256_CBC_SHA          \"CAMELLIA256-SHA\"\n# define TLS1_TXT_DH_DSS_WITH_CAMELLIA_256_CBC_SHA       \"DH-DSS-CAMELLIA256-SHA\"\n# define TLS1_TXT_DH_RSA_WITH_CAMELLIA_256_CBC_SHA       \"DH-RSA-CAMELLIA256-SHA\"\n# define TLS1_TXT_DHE_DSS_WITH_CAMELLIA_256_CBC_SHA      \"DHE-DSS-CAMELLIA256-SHA\"\n# define TLS1_TXT_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA      \"DHE-RSA-CAMELLIA256-SHA\"\n# define TLS1_TXT_ADH_WITH_CAMELLIA_256_CBC_SHA          \"ADH-CAMELLIA256-SHA\"\n\n/* SEED ciphersuites from RFC4162 */\n# define TLS1_TXT_RSA_WITH_SEED_SHA                      \"SEED-SHA\"\n# define TLS1_TXT_DH_DSS_WITH_SEED_SHA                   \"DH-DSS-SEED-SHA\"\n# define TLS1_TXT_DH_RSA_WITH_SEED_SHA                   \"DH-RSA-SEED-SHA\"\n# define TLS1_TXT_DHE_DSS_WITH_SEED_SHA                  \"DHE-DSS-SEED-SHA\"\n# define TLS1_TXT_DHE_RSA_WITH_SEED_SHA                  \"DHE-RSA-SEED-SHA\"\n# define TLS1_TXT_ADH_WITH_SEED_SHA                      \"ADH-SEED-SHA\"\n\n/* TLS v1.2 ciphersuites */\n# define TLS1_TXT_RSA_WITH_NULL_SHA256                   \"NULL-SHA256\"\n# define TLS1_TXT_RSA_WITH_AES_128_SHA256                \"AES128-SHA256\"\n# define TLS1_TXT_RSA_WITH_AES_256_SHA256                \"AES256-SHA256\"\n# define TLS1_TXT_DH_DSS_WITH_AES_128_SHA256             \"DH-DSS-AES128-SHA256\"\n# define TLS1_TXT_DH_RSA_WITH_AES_128_SHA256             \"DH-RSA-AES128-SHA256\"\n# define TLS1_TXT_DHE_DSS_WITH_AES_128_SHA256            \"DHE-DSS-AES128-SHA256\"\n# define TLS1_TXT_DHE_RSA_WITH_AES_128_SHA256            \"DHE-RSA-AES128-SHA256\"\n# define TLS1_TXT_DH_DSS_WITH_AES_256_SHA256             \"DH-DSS-AES256-SHA256\"\n# define TLS1_TXT_DH_RSA_WITH_AES_256_SHA256             \"DH-RSA-AES256-SHA256\"\n# define TLS1_TXT_DHE_DSS_WITH_AES_256_SHA256            \"DHE-DSS-AES256-SHA256\"\n# define TLS1_TXT_DHE_RSA_WITH_AES_256_SHA256            \"DHE-RSA-AES256-SHA256\"\n# define TLS1_TXT_ADH_WITH_AES_128_SHA256                \"ADH-AES128-SHA256\"\n# define TLS1_TXT_ADH_WITH_AES_256_SHA256                \"ADH-AES256-SHA256\"\n\n/* TLS v1.2 GCM ciphersuites from RFC5288 */\n# define TLS1_TXT_RSA_WITH_AES_128_GCM_SHA256            \"AES128-GCM-SHA256\"\n# define TLS1_TXT_RSA_WITH_AES_256_GCM_SHA384            \"AES256-GCM-SHA384\"\n# define TLS1_TXT_DHE_RSA_WITH_AES_128_GCM_SHA256        \"DHE-RSA-AES128-GCM-SHA256\"\n# define TLS1_TXT_DHE_RSA_WITH_AES_256_GCM_SHA384        \"DHE-RSA-AES256-GCM-SHA384\"\n# define TLS1_TXT_DH_RSA_WITH_AES_128_GCM_SHA256         \"DH-RSA-AES128-GCM-SHA256\"\n# define TLS1_TXT_DH_RSA_WITH_AES_256_GCM_SHA384         \"DH-RSA-AES256-GCM-SHA384\"\n# define TLS1_TXT_DHE_DSS_WITH_AES_128_GCM_SHA256        \"DHE-DSS-AES128-GCM-SHA256\"\n# define TLS1_TXT_DHE_DSS_WITH_AES_256_GCM_SHA384        \"DHE-DSS-AES256-GCM-SHA384\"\n# define TLS1_TXT_DH_DSS_WITH_AES_128_GCM_SHA256         \"DH-DSS-AES128-GCM-SHA256\"\n# define TLS1_TXT_DH_DSS_WITH_AES_256_GCM_SHA384         \"DH-DSS-AES256-GCM-SHA384\"\n# define TLS1_TXT_ADH_WITH_AES_128_GCM_SHA256            \"ADH-AES128-GCM-SHA256\"\n# define TLS1_TXT_ADH_WITH_AES_256_GCM_SHA384            \"ADH-AES256-GCM-SHA384\"\n\n/* ECDH HMAC based ciphersuites from RFC5289 */\n\n# define TLS1_TXT_ECDHE_ECDSA_WITH_AES_128_SHA256    \"ECDHE-ECDSA-AES128-SHA256\"\n# define TLS1_TXT_ECDHE_ECDSA_WITH_AES_256_SHA384    \"ECDHE-ECDSA-AES256-SHA384\"\n# define TLS1_TXT_ECDH_ECDSA_WITH_AES_128_SHA256     \"ECDH-ECDSA-AES128-SHA256\"\n# define TLS1_TXT_ECDH_ECDSA_WITH_AES_256_SHA384     \"ECDH-ECDSA-AES256-SHA384\"\n# define TLS1_TXT_ECDHE_RSA_WITH_AES_128_SHA256      \"ECDHE-RSA-AES128-SHA256\"\n# define TLS1_TXT_ECDHE_RSA_WITH_AES_256_SHA384      \"ECDHE-RSA-AES256-SHA384\"\n# define TLS1_TXT_ECDH_RSA_WITH_AES_128_SHA256       \"ECDH-RSA-AES128-SHA256\"\n# define TLS1_TXT_ECDH_RSA_WITH_AES_256_SHA384       \"ECDH-RSA-AES256-SHA384\"\n\n/* ECDH GCM based ciphersuites from RFC5289 */\n# define TLS1_TXT_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256    \"ECDHE-ECDSA-AES128-GCM-SHA256\"\n# define TLS1_TXT_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384    \"ECDHE-ECDSA-AES256-GCM-SHA384\"\n# define TLS1_TXT_ECDH_ECDSA_WITH_AES_128_GCM_SHA256     \"ECDH-ECDSA-AES128-GCM-SHA256\"\n# define TLS1_TXT_ECDH_ECDSA_WITH_AES_256_GCM_SHA384     \"ECDH-ECDSA-AES256-GCM-SHA384\"\n# define TLS1_TXT_ECDHE_RSA_WITH_AES_128_GCM_SHA256      \"ECDHE-RSA-AES128-GCM-SHA256\"\n# define TLS1_TXT_ECDHE_RSA_WITH_AES_256_GCM_SHA384      \"ECDHE-RSA-AES256-GCM-SHA384\"\n# define TLS1_TXT_ECDH_RSA_WITH_AES_128_GCM_SHA256       \"ECDH-RSA-AES128-GCM-SHA256\"\n# define TLS1_TXT_ECDH_RSA_WITH_AES_256_GCM_SHA384       \"ECDH-RSA-AES256-GCM-SHA384\"\n\n# define TLS_CT_RSA_SIGN                 1\n# define TLS_CT_DSS_SIGN                 2\n# define TLS_CT_RSA_FIXED_DH             3\n# define TLS_CT_DSS_FIXED_DH             4\n# define TLS_CT_ECDSA_SIGN               64\n# define TLS_CT_RSA_FIXED_ECDH           65\n# define TLS_CT_ECDSA_FIXED_ECDH         66\n# define TLS_CT_GOST94_SIGN              21\n# define TLS_CT_GOST01_SIGN              22\n/*\n * when correcting this number, correct also SSL3_CT_NUMBER in ssl3.h (see\n * comment there)\n */\n# define TLS_CT_NUMBER                   9\n\n# define TLS1_FINISH_MAC_LENGTH          12\n\n# define TLS_MD_MAX_CONST_SIZE                   20\n# define TLS_MD_CLIENT_FINISH_CONST              \"client finished\"\n# define TLS_MD_CLIENT_FINISH_CONST_SIZE         15\n# define TLS_MD_SERVER_FINISH_CONST              \"server finished\"\n# define TLS_MD_SERVER_FINISH_CONST_SIZE         15\n# define TLS_MD_SERVER_WRITE_KEY_CONST           \"server write key\"\n# define TLS_MD_SERVER_WRITE_KEY_CONST_SIZE      16\n# define TLS_MD_KEY_EXPANSION_CONST              \"key expansion\"\n# define TLS_MD_KEY_EXPANSION_CONST_SIZE         13\n# define TLS_MD_CLIENT_WRITE_KEY_CONST           \"client write key\"\n# define TLS_MD_CLIENT_WRITE_KEY_CONST_SIZE      16\n# define TLS_MD_SERVER_WRITE_KEY_CONST           \"server write key\"\n# define TLS_MD_SERVER_WRITE_KEY_CONST_SIZE      16\n# define TLS_MD_IV_BLOCK_CONST                   \"IV block\"\n# define TLS_MD_IV_BLOCK_CONST_SIZE              8\n# define TLS_MD_MASTER_SECRET_CONST              \"master secret\"\n# define TLS_MD_MASTER_SECRET_CONST_SIZE         13\n\n# ifdef CHARSET_EBCDIC\n#  undef TLS_MD_CLIENT_FINISH_CONST\n/*\n * client finished\n */\n#  define TLS_MD_CLIENT_FINISH_CONST    \"\\x63\\x6c\\x69\\x65\\x6e\\x74\\x20\\x66\\x69\\x6e\\x69\\x73\\x68\\x65\\x64\"\n\n#  undef TLS_MD_SERVER_FINISH_CONST\n/*\n * server finished\n */\n#  define TLS_MD_SERVER_FINISH_CONST    \"\\x73\\x65\\x72\\x76\\x65\\x72\\x20\\x66\\x69\\x6e\\x69\\x73\\x68\\x65\\x64\"\n\n#  undef TLS_MD_SERVER_WRITE_KEY_CONST\n/*\n * server write key\n */\n#  define TLS_MD_SERVER_WRITE_KEY_CONST \"\\x73\\x65\\x72\\x76\\x65\\x72\\x20\\x77\\x72\\x69\\x74\\x65\\x20\\x6b\\x65\\x79\"\n\n#  undef TLS_MD_KEY_EXPANSION_CONST\n/*\n * key expansion\n */\n#  define TLS_MD_KEY_EXPANSION_CONST    \"\\x6b\\x65\\x79\\x20\\x65\\x78\\x70\\x61\\x6e\\x73\\x69\\x6f\\x6e\"\n\n#  undef TLS_MD_CLIENT_WRITE_KEY_CONST\n/*\n * client write key\n */\n#  define TLS_MD_CLIENT_WRITE_KEY_CONST \"\\x63\\x6c\\x69\\x65\\x6e\\x74\\x20\\x77\\x72\\x69\\x74\\x65\\x20\\x6b\\x65\\x79\"\n\n#  undef TLS_MD_SERVER_WRITE_KEY_CONST\n/*\n * server write key\n */\n#  define TLS_MD_SERVER_WRITE_KEY_CONST \"\\x73\\x65\\x72\\x76\\x65\\x72\\x20\\x77\\x72\\x69\\x74\\x65\\x20\\x6b\\x65\\x79\"\n\n#  undef TLS_MD_IV_BLOCK_CONST\n/*\n * IV block\n */\n#  define TLS_MD_IV_BLOCK_CONST         \"\\x49\\x56\\x20\\x62\\x6c\\x6f\\x63\\x6b\"\n\n#  undef TLS_MD_MASTER_SECRET_CONST\n/*\n * master secret\n */\n#  define TLS_MD_MASTER_SECRET_CONST    \"\\x6d\\x61\\x73\\x74\\x65\\x72\\x20\\x73\\x65\\x63\\x72\\x65\\x74\"\n# endif\n\n/* TLS Session Ticket extension struct */\nstruct tls_session_ticket_ext_st {\n    unsigned short length;\n    void *data;\n};\n\n#ifdef  __cplusplus\n}\n#endif\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/x86/include/openssl/ts.h",
    "content": "/* crypto/ts/ts.h */\n/*\n * Written by Zoltan Glozik (zglozik@opentsa.org) for the OpenSSL project\n * 2002, 2003, 2004.\n */\n/* ====================================================================\n * Copyright (c) 2006 The OpenSSL Project.  All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n *\n * 1. Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n *\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in\n *    the documentation and/or other materials provided with the\n *    distribution.\n *\n * 3. All advertising materials mentioning features or use of this\n *    software must display the following acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)\"\n *\n * 4. The names \"OpenSSL Toolkit\" and \"OpenSSL Project\" must not be used to\n *    endorse or promote products derived from this software without\n *    prior written permission. For written permission, please contact\n *    licensing@OpenSSL.org.\n *\n * 5. Products derived from this software may not be called \"OpenSSL\"\n *    nor may \"OpenSSL\" appear in their names without prior written\n *    permission of the OpenSSL Project.\n *\n * 6. Redistributions of any form whatsoever must retain the following\n *    acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)\"\n *\n * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY\n * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\n * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR\n * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\n * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,\n * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED\n * OF THE POSSIBILITY OF SUCH DAMAGE.\n * ====================================================================\n *\n * This product includes cryptographic software written by Eric Young\n * (eay@cryptsoft.com).  This product includes software written by Tim\n * Hudson (tjh@cryptsoft.com).\n *\n */\n\n#ifndef HEADER_TS_H\n# define HEADER_TS_H\n\n# include <openssl/opensslconf.h>\n# include <openssl/symhacks.h>\n# ifndef OPENSSL_NO_BUFFER\n#  include <openssl/buffer.h>\n# endif\n# ifndef OPENSSL_NO_EVP\n#  include <openssl/evp.h>\n# endif\n# ifndef OPENSSL_NO_BIO\n#  include <openssl/bio.h>\n# endif\n# include <openssl/stack.h>\n# include <openssl/asn1.h>\n# include <openssl/safestack.h>\n\n# ifndef OPENSSL_NO_RSA\n#  include <openssl/rsa.h>\n# endif\n\n# ifndef OPENSSL_NO_DSA\n#  include <openssl/dsa.h>\n# endif\n\n# ifndef OPENSSL_NO_DH\n#  include <openssl/dh.h>\n# endif\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n# ifdef WIN32\n/* Under Win32 this is defined in wincrypt.h */\n#  undef X509_NAME\n# endif\n\n# include <openssl/x509.h>\n# include <openssl/x509v3.h>\n\n/*-\nMessageImprint ::= SEQUENCE  {\n     hashAlgorithm                AlgorithmIdentifier,\n     hashedMessage                OCTET STRING  }\n*/\n\ntypedef struct TS_msg_imprint_st {\n    X509_ALGOR *hash_algo;\n    ASN1_OCTET_STRING *hashed_msg;\n} TS_MSG_IMPRINT;\n\n/*-\nTimeStampReq ::= SEQUENCE  {\n   version                  INTEGER  { v1(1) },\n   messageImprint           MessageImprint,\n     --a hash algorithm OID and the hash value of the data to be\n     --time-stamped\n   reqPolicy                TSAPolicyId                OPTIONAL,\n   nonce                    INTEGER                    OPTIONAL,\n   certReq                  BOOLEAN                    DEFAULT FALSE,\n   extensions               [0] IMPLICIT Extensions    OPTIONAL  }\n*/\n\ntypedef struct TS_req_st {\n    ASN1_INTEGER *version;\n    TS_MSG_IMPRINT *msg_imprint;\n    ASN1_OBJECT *policy_id;     /* OPTIONAL */\n    ASN1_INTEGER *nonce;        /* OPTIONAL */\n    ASN1_BOOLEAN cert_req;      /* DEFAULT FALSE */\n    STACK_OF(X509_EXTENSION) *extensions; /* [0] OPTIONAL */\n} TS_REQ;\n\n/*-\nAccuracy ::= SEQUENCE {\n                seconds        INTEGER           OPTIONAL,\n                millis     [0] INTEGER  (1..999) OPTIONAL,\n                micros     [1] INTEGER  (1..999) OPTIONAL  }\n*/\n\ntypedef struct TS_accuracy_st {\n    ASN1_INTEGER *seconds;\n    ASN1_INTEGER *millis;\n    ASN1_INTEGER *micros;\n} TS_ACCURACY;\n\n/*-\nTSTInfo ::= SEQUENCE  {\n    version                      INTEGER  { v1(1) },\n    policy                       TSAPolicyId,\n    messageImprint               MessageImprint,\n      -- MUST have the same value as the similar field in\n      -- TimeStampReq\n    serialNumber                 INTEGER,\n     -- Time-Stamping users MUST be ready to accommodate integers\n     -- up to 160 bits.\n    genTime                      GeneralizedTime,\n    accuracy                     Accuracy                 OPTIONAL,\n    ordering                     BOOLEAN             DEFAULT FALSE,\n    nonce                        INTEGER                  OPTIONAL,\n      -- MUST be present if the similar field was present\n      -- in TimeStampReq.  In that case it MUST have the same value.\n    tsa                          [0] GeneralName          OPTIONAL,\n    extensions                   [1] IMPLICIT Extensions  OPTIONAL   }\n*/\n\ntypedef struct TS_tst_info_st {\n    ASN1_INTEGER *version;\n    ASN1_OBJECT *policy_id;\n    TS_MSG_IMPRINT *msg_imprint;\n    ASN1_INTEGER *serial;\n    ASN1_GENERALIZEDTIME *time;\n    TS_ACCURACY *accuracy;\n    ASN1_BOOLEAN ordering;\n    ASN1_INTEGER *nonce;\n    GENERAL_NAME *tsa;\n    STACK_OF(X509_EXTENSION) *extensions;\n} TS_TST_INFO;\n\n/*-\nPKIStatusInfo ::= SEQUENCE {\n    status        PKIStatus,\n    statusString  PKIFreeText     OPTIONAL,\n    failInfo      PKIFailureInfo  OPTIONAL  }\n\nFrom RFC 1510 - section 3.1.1:\nPKIFreeText ::= SEQUENCE SIZE (1..MAX) OF UTF8String\n        -- text encoded as UTF-8 String (note:  each UTF8String SHOULD\n        -- include an RFC 1766 language tag to indicate the language\n        -- of the contained text)\n*/\n\n/* Possible values for status. See ts_resp_print.c && ts_resp_verify.c. */\n\n# define TS_STATUS_GRANTED                       0\n# define TS_STATUS_GRANTED_WITH_MODS             1\n# define TS_STATUS_REJECTION                     2\n# define TS_STATUS_WAITING                       3\n# define TS_STATUS_REVOCATION_WARNING            4\n# define TS_STATUS_REVOCATION_NOTIFICATION       5\n\n/*\n * Possible values for failure_info. See ts_resp_print.c && ts_resp_verify.c\n */\n\n# define TS_INFO_BAD_ALG                 0\n# define TS_INFO_BAD_REQUEST             2\n# define TS_INFO_BAD_DATA_FORMAT         5\n# define TS_INFO_TIME_NOT_AVAILABLE      14\n# define TS_INFO_UNACCEPTED_POLICY       15\n# define TS_INFO_UNACCEPTED_EXTENSION    16\n# define TS_INFO_ADD_INFO_NOT_AVAILABLE  17\n# define TS_INFO_SYSTEM_FAILURE          25\n\ntypedef struct TS_status_info_st {\n    ASN1_INTEGER *status;\n    STACK_OF(ASN1_UTF8STRING) *text;\n    ASN1_BIT_STRING *failure_info;\n} TS_STATUS_INFO;\n\nDECLARE_STACK_OF(ASN1_UTF8STRING)\nDECLARE_ASN1_SET_OF(ASN1_UTF8STRING)\n\n/*-\nTimeStampResp ::= SEQUENCE  {\n     status                  PKIStatusInfo,\n     timeStampToken          TimeStampToken     OPTIONAL }\n*/\n\ntypedef struct TS_resp_st {\n    TS_STATUS_INFO *status_info;\n    PKCS7 *token;\n    TS_TST_INFO *tst_info;\n} TS_RESP;\n\n/* The structure below would belong to the ESS component. */\n\n/*-\nIssuerSerial ::= SEQUENCE {\n        issuer                   GeneralNames,\n        serialNumber             CertificateSerialNumber\n        }\n*/\n\ntypedef struct ESS_issuer_serial {\n    STACK_OF(GENERAL_NAME) *issuer;\n    ASN1_INTEGER *serial;\n} ESS_ISSUER_SERIAL;\n\n/*-\nESSCertID ::=  SEQUENCE {\n        certHash                 Hash,\n        issuerSerial             IssuerSerial OPTIONAL\n}\n*/\n\ntypedef struct ESS_cert_id {\n    ASN1_OCTET_STRING *hash;    /* Always SHA-1 digest. */\n    ESS_ISSUER_SERIAL *issuer_serial;\n} ESS_CERT_ID;\n\nDECLARE_STACK_OF(ESS_CERT_ID)\nDECLARE_ASN1_SET_OF(ESS_CERT_ID)\n\n/*-\nSigningCertificate ::=  SEQUENCE {\n       certs        SEQUENCE OF ESSCertID,\n       policies     SEQUENCE OF PolicyInformation OPTIONAL\n}\n*/\n\ntypedef struct ESS_signing_cert {\n    STACK_OF(ESS_CERT_ID) *cert_ids;\n    STACK_OF(POLICYINFO) *policy_info;\n} ESS_SIGNING_CERT;\n\nTS_REQ *TS_REQ_new(void);\nvoid TS_REQ_free(TS_REQ *a);\nint i2d_TS_REQ(const TS_REQ *a, unsigned char **pp);\nTS_REQ *d2i_TS_REQ(TS_REQ **a, const unsigned char **pp, long length);\n\nTS_REQ *TS_REQ_dup(TS_REQ *a);\n\nTS_REQ *d2i_TS_REQ_fp(FILE *fp, TS_REQ **a);\nint i2d_TS_REQ_fp(FILE *fp, TS_REQ *a);\nTS_REQ *d2i_TS_REQ_bio(BIO *fp, TS_REQ **a);\nint i2d_TS_REQ_bio(BIO *fp, TS_REQ *a);\n\nTS_MSG_IMPRINT *TS_MSG_IMPRINT_new(void);\nvoid TS_MSG_IMPRINT_free(TS_MSG_IMPRINT *a);\nint i2d_TS_MSG_IMPRINT(const TS_MSG_IMPRINT *a, unsigned char **pp);\nTS_MSG_IMPRINT *d2i_TS_MSG_IMPRINT(TS_MSG_IMPRINT **a,\n                                   const unsigned char **pp, long length);\n\nTS_MSG_IMPRINT *TS_MSG_IMPRINT_dup(TS_MSG_IMPRINT *a);\n\nTS_MSG_IMPRINT *d2i_TS_MSG_IMPRINT_fp(FILE *fp, TS_MSG_IMPRINT **a);\nint i2d_TS_MSG_IMPRINT_fp(FILE *fp, TS_MSG_IMPRINT *a);\nTS_MSG_IMPRINT *d2i_TS_MSG_IMPRINT_bio(BIO *fp, TS_MSG_IMPRINT **a);\nint i2d_TS_MSG_IMPRINT_bio(BIO *fp, TS_MSG_IMPRINT *a);\n\nTS_RESP *TS_RESP_new(void);\nvoid TS_RESP_free(TS_RESP *a);\nint i2d_TS_RESP(const TS_RESP *a, unsigned char **pp);\nTS_RESP *d2i_TS_RESP(TS_RESP **a, const unsigned char **pp, long length);\nTS_TST_INFO *PKCS7_to_TS_TST_INFO(PKCS7 *token);\nTS_RESP *TS_RESP_dup(TS_RESP *a);\n\nTS_RESP *d2i_TS_RESP_fp(FILE *fp, TS_RESP **a);\nint i2d_TS_RESP_fp(FILE *fp, TS_RESP *a);\nTS_RESP *d2i_TS_RESP_bio(BIO *fp, TS_RESP **a);\nint i2d_TS_RESP_bio(BIO *fp, TS_RESP *a);\n\nTS_STATUS_INFO *TS_STATUS_INFO_new(void);\nvoid TS_STATUS_INFO_free(TS_STATUS_INFO *a);\nint i2d_TS_STATUS_INFO(const TS_STATUS_INFO *a, unsigned char **pp);\nTS_STATUS_INFO *d2i_TS_STATUS_INFO(TS_STATUS_INFO **a,\n                                   const unsigned char **pp, long length);\nTS_STATUS_INFO *TS_STATUS_INFO_dup(TS_STATUS_INFO *a);\n\nTS_TST_INFO *TS_TST_INFO_new(void);\nvoid TS_TST_INFO_free(TS_TST_INFO *a);\nint i2d_TS_TST_INFO(const TS_TST_INFO *a, unsigned char **pp);\nTS_TST_INFO *d2i_TS_TST_INFO(TS_TST_INFO **a, const unsigned char **pp,\n                             long length);\nTS_TST_INFO *TS_TST_INFO_dup(TS_TST_INFO *a);\n\nTS_TST_INFO *d2i_TS_TST_INFO_fp(FILE *fp, TS_TST_INFO **a);\nint i2d_TS_TST_INFO_fp(FILE *fp, TS_TST_INFO *a);\nTS_TST_INFO *d2i_TS_TST_INFO_bio(BIO *fp, TS_TST_INFO **a);\nint i2d_TS_TST_INFO_bio(BIO *fp, TS_TST_INFO *a);\n\nTS_ACCURACY *TS_ACCURACY_new(void);\nvoid TS_ACCURACY_free(TS_ACCURACY *a);\nint i2d_TS_ACCURACY(const TS_ACCURACY *a, unsigned char **pp);\nTS_ACCURACY *d2i_TS_ACCURACY(TS_ACCURACY **a, const unsigned char **pp,\n                             long length);\nTS_ACCURACY *TS_ACCURACY_dup(TS_ACCURACY *a);\n\nESS_ISSUER_SERIAL *ESS_ISSUER_SERIAL_new(void);\nvoid ESS_ISSUER_SERIAL_free(ESS_ISSUER_SERIAL *a);\nint i2d_ESS_ISSUER_SERIAL(const ESS_ISSUER_SERIAL *a, unsigned char **pp);\nESS_ISSUER_SERIAL *d2i_ESS_ISSUER_SERIAL(ESS_ISSUER_SERIAL **a,\n                                         const unsigned char **pp,\n                                         long length);\nESS_ISSUER_SERIAL *ESS_ISSUER_SERIAL_dup(ESS_ISSUER_SERIAL *a);\n\nESS_CERT_ID *ESS_CERT_ID_new(void);\nvoid ESS_CERT_ID_free(ESS_CERT_ID *a);\nint i2d_ESS_CERT_ID(const ESS_CERT_ID *a, unsigned char **pp);\nESS_CERT_ID *d2i_ESS_CERT_ID(ESS_CERT_ID **a, const unsigned char **pp,\n                             long length);\nESS_CERT_ID *ESS_CERT_ID_dup(ESS_CERT_ID *a);\n\nESS_SIGNING_CERT *ESS_SIGNING_CERT_new(void);\nvoid ESS_SIGNING_CERT_free(ESS_SIGNING_CERT *a);\nint i2d_ESS_SIGNING_CERT(const ESS_SIGNING_CERT *a, unsigned char **pp);\nESS_SIGNING_CERT *d2i_ESS_SIGNING_CERT(ESS_SIGNING_CERT **a,\n                                       const unsigned char **pp, long length);\nESS_SIGNING_CERT *ESS_SIGNING_CERT_dup(ESS_SIGNING_CERT *a);\n\nvoid ERR_load_TS_strings(void);\n\nint TS_REQ_set_version(TS_REQ *a, long version);\nlong TS_REQ_get_version(const TS_REQ *a);\n\nint TS_REQ_set_msg_imprint(TS_REQ *a, TS_MSG_IMPRINT *msg_imprint);\nTS_MSG_IMPRINT *TS_REQ_get_msg_imprint(TS_REQ *a);\n\nint TS_MSG_IMPRINT_set_algo(TS_MSG_IMPRINT *a, X509_ALGOR *alg);\nX509_ALGOR *TS_MSG_IMPRINT_get_algo(TS_MSG_IMPRINT *a);\n\nint TS_MSG_IMPRINT_set_msg(TS_MSG_IMPRINT *a, unsigned char *d, int len);\nASN1_OCTET_STRING *TS_MSG_IMPRINT_get_msg(TS_MSG_IMPRINT *a);\n\nint TS_REQ_set_policy_id(TS_REQ *a, ASN1_OBJECT *policy);\nASN1_OBJECT *TS_REQ_get_policy_id(TS_REQ *a);\n\nint TS_REQ_set_nonce(TS_REQ *a, const ASN1_INTEGER *nonce);\nconst ASN1_INTEGER *TS_REQ_get_nonce(const TS_REQ *a);\n\nint TS_REQ_set_cert_req(TS_REQ *a, int cert_req);\nint TS_REQ_get_cert_req(const TS_REQ *a);\n\nSTACK_OF(X509_EXTENSION) *TS_REQ_get_exts(TS_REQ *a);\nvoid TS_REQ_ext_free(TS_REQ *a);\nint TS_REQ_get_ext_count(TS_REQ *a);\nint TS_REQ_get_ext_by_NID(TS_REQ *a, int nid, int lastpos);\nint TS_REQ_get_ext_by_OBJ(TS_REQ *a, ASN1_OBJECT *obj, int lastpos);\nint TS_REQ_get_ext_by_critical(TS_REQ *a, int crit, int lastpos);\nX509_EXTENSION *TS_REQ_get_ext(TS_REQ *a, int loc);\nX509_EXTENSION *TS_REQ_delete_ext(TS_REQ *a, int loc);\nint TS_REQ_add_ext(TS_REQ *a, X509_EXTENSION *ex, int loc);\nvoid *TS_REQ_get_ext_d2i(TS_REQ *a, int nid, int *crit, int *idx);\n\n/* Function declarations for TS_REQ defined in ts/ts_req_print.c */\n\nint TS_REQ_print_bio(BIO *bio, TS_REQ *a);\n\n/* Function declarations for TS_RESP defined in ts/ts_resp_utils.c */\n\nint TS_RESP_set_status_info(TS_RESP *a, TS_STATUS_INFO *info);\nTS_STATUS_INFO *TS_RESP_get_status_info(TS_RESP *a);\n\n/* Caller loses ownership of PKCS7 and TS_TST_INFO objects. */\nvoid TS_RESP_set_tst_info(TS_RESP *a, PKCS7 *p7, TS_TST_INFO *tst_info);\nPKCS7 *TS_RESP_get_token(TS_RESP *a);\nTS_TST_INFO *TS_RESP_get_tst_info(TS_RESP *a);\n\nint TS_TST_INFO_set_version(TS_TST_INFO *a, long version);\nlong TS_TST_INFO_get_version(const TS_TST_INFO *a);\n\nint TS_TST_INFO_set_policy_id(TS_TST_INFO *a, ASN1_OBJECT *policy_id);\nASN1_OBJECT *TS_TST_INFO_get_policy_id(TS_TST_INFO *a);\n\nint TS_TST_INFO_set_msg_imprint(TS_TST_INFO *a, TS_MSG_IMPRINT *msg_imprint);\nTS_MSG_IMPRINT *TS_TST_INFO_get_msg_imprint(TS_TST_INFO *a);\n\nint TS_TST_INFO_set_serial(TS_TST_INFO *a, const ASN1_INTEGER *serial);\nconst ASN1_INTEGER *TS_TST_INFO_get_serial(const TS_TST_INFO *a);\n\nint TS_TST_INFO_set_time(TS_TST_INFO *a, const ASN1_GENERALIZEDTIME *gtime);\nconst ASN1_GENERALIZEDTIME *TS_TST_INFO_get_time(const TS_TST_INFO *a);\n\nint TS_TST_INFO_set_accuracy(TS_TST_INFO *a, TS_ACCURACY *accuracy);\nTS_ACCURACY *TS_TST_INFO_get_accuracy(TS_TST_INFO *a);\n\nint TS_ACCURACY_set_seconds(TS_ACCURACY *a, const ASN1_INTEGER *seconds);\nconst ASN1_INTEGER *TS_ACCURACY_get_seconds(const TS_ACCURACY *a);\n\nint TS_ACCURACY_set_millis(TS_ACCURACY *a, const ASN1_INTEGER *millis);\nconst ASN1_INTEGER *TS_ACCURACY_get_millis(const TS_ACCURACY *a);\n\nint TS_ACCURACY_set_micros(TS_ACCURACY *a, const ASN1_INTEGER *micros);\nconst ASN1_INTEGER *TS_ACCURACY_get_micros(const TS_ACCURACY *a);\n\nint TS_TST_INFO_set_ordering(TS_TST_INFO *a, int ordering);\nint TS_TST_INFO_get_ordering(const TS_TST_INFO *a);\n\nint TS_TST_INFO_set_nonce(TS_TST_INFO *a, const ASN1_INTEGER *nonce);\nconst ASN1_INTEGER *TS_TST_INFO_get_nonce(const TS_TST_INFO *a);\n\nint TS_TST_INFO_set_tsa(TS_TST_INFO *a, GENERAL_NAME *tsa);\nGENERAL_NAME *TS_TST_INFO_get_tsa(TS_TST_INFO *a);\n\nSTACK_OF(X509_EXTENSION) *TS_TST_INFO_get_exts(TS_TST_INFO *a);\nvoid TS_TST_INFO_ext_free(TS_TST_INFO *a);\nint TS_TST_INFO_get_ext_count(TS_TST_INFO *a);\nint TS_TST_INFO_get_ext_by_NID(TS_TST_INFO *a, int nid, int lastpos);\nint TS_TST_INFO_get_ext_by_OBJ(TS_TST_INFO *a, ASN1_OBJECT *obj, int lastpos);\nint TS_TST_INFO_get_ext_by_critical(TS_TST_INFO *a, int crit, int lastpos);\nX509_EXTENSION *TS_TST_INFO_get_ext(TS_TST_INFO *a, int loc);\nX509_EXTENSION *TS_TST_INFO_delete_ext(TS_TST_INFO *a, int loc);\nint TS_TST_INFO_add_ext(TS_TST_INFO *a, X509_EXTENSION *ex, int loc);\nvoid *TS_TST_INFO_get_ext_d2i(TS_TST_INFO *a, int nid, int *crit, int *idx);\n\n/*\n * Declarations related to response generation, defined in ts/ts_resp_sign.c.\n */\n\n/* Optional flags for response generation. */\n\n/* Don't include the TSA name in response. */\n# define TS_TSA_NAME             0x01\n\n/* Set ordering to true in response. */\n# define TS_ORDERING             0x02\n\n/*\n * Include the signer certificate and the other specified certificates in\n * the ESS signing certificate attribute beside the PKCS7 signed data.\n * Only the signer certificates is included by default.\n */\n# define TS_ESS_CERT_ID_CHAIN    0x04\n\n/* Forward declaration. */\nstruct TS_resp_ctx;\n\n/* This must return a unique number less than 160 bits long. */\ntypedef ASN1_INTEGER *(*TS_serial_cb) (struct TS_resp_ctx *, void *);\n\n/*\n * This must return the seconds and microseconds since Jan 1, 1970 in the sec\n * and usec variables allocated by the caller. Return non-zero for success\n * and zero for failure.\n */\ntypedef int (*TS_time_cb) (struct TS_resp_ctx *, void *, long *sec,\n                           long *usec);\n\n/*\n * This must process the given extension. It can modify the TS_TST_INFO\n * object of the context. Return values: !0 (processed), 0 (error, it must\n * set the status info/failure info of the response).\n */\ntypedef int (*TS_extension_cb) (struct TS_resp_ctx *, X509_EXTENSION *,\n                                void *);\n\ntypedef struct TS_resp_ctx {\n    X509 *signer_cert;\n    EVP_PKEY *signer_key;\n    STACK_OF(X509) *certs;      /* Certs to include in signed data. */\n    STACK_OF(ASN1_OBJECT) *policies; /* Acceptable policies. */\n    ASN1_OBJECT *default_policy; /* It may appear in policies, too. */\n    STACK_OF(EVP_MD) *mds;      /* Acceptable message digests. */\n    ASN1_INTEGER *seconds;      /* accuracy, 0 means not specified. */\n    ASN1_INTEGER *millis;       /* accuracy, 0 means not specified. */\n    ASN1_INTEGER *micros;       /* accuracy, 0 means not specified. */\n    unsigned clock_precision_digits; /* fraction of seconds in time stamp\n                                      * token. */\n    unsigned flags;             /* Optional info, see values above. */\n    /* Callback functions. */\n    TS_serial_cb serial_cb;\n    void *serial_cb_data;       /* User data for serial_cb. */\n    TS_time_cb time_cb;\n    void *time_cb_data;         /* User data for time_cb. */\n    TS_extension_cb extension_cb;\n    void *extension_cb_data;    /* User data for extension_cb. */\n    /* These members are used only while creating the response. */\n    TS_REQ *request;\n    TS_RESP *response;\n    TS_TST_INFO *tst_info;\n} TS_RESP_CTX;\n\nDECLARE_STACK_OF(EVP_MD)\nDECLARE_ASN1_SET_OF(EVP_MD)\n\n/* Creates a response context that can be used for generating responses. */\nTS_RESP_CTX *TS_RESP_CTX_new(void);\nvoid TS_RESP_CTX_free(TS_RESP_CTX *ctx);\n\n/* This parameter must be set. */\nint TS_RESP_CTX_set_signer_cert(TS_RESP_CTX *ctx, X509 *signer);\n\n/* This parameter must be set. */\nint TS_RESP_CTX_set_signer_key(TS_RESP_CTX *ctx, EVP_PKEY *key);\n\n/* This parameter must be set. */\nint TS_RESP_CTX_set_def_policy(TS_RESP_CTX *ctx, ASN1_OBJECT *def_policy);\n\n/* No additional certs are included in the response by default. */\nint TS_RESP_CTX_set_certs(TS_RESP_CTX *ctx, STACK_OF(X509) *certs);\n\n/*\n * Adds a new acceptable policy, only the default policy is accepted by\n * default.\n */\nint TS_RESP_CTX_add_policy(TS_RESP_CTX *ctx, ASN1_OBJECT *policy);\n\n/*\n * Adds a new acceptable message digest. Note that no message digests are\n * accepted by default. The md argument is shared with the caller.\n */\nint TS_RESP_CTX_add_md(TS_RESP_CTX *ctx, const EVP_MD *md);\n\n/* Accuracy is not included by default. */\nint TS_RESP_CTX_set_accuracy(TS_RESP_CTX *ctx,\n                             int secs, int millis, int micros);\n\n/*\n * Clock precision digits, i.e. the number of decimal digits: '0' means sec,\n * '3' msec, '6' usec, and so on. Default is 0.\n */\nint TS_RESP_CTX_set_clock_precision_digits(TS_RESP_CTX *ctx,\n                                           unsigned clock_precision_digits);\n/* At most we accept usec precision. */\n# define TS_MAX_CLOCK_PRECISION_DIGITS   6\n\n/* Maximum status message length */\n# define TS_MAX_STATUS_LENGTH   (1024 * 1024)\n\n/* No flags are set by default. */\nvoid TS_RESP_CTX_add_flags(TS_RESP_CTX *ctx, int flags);\n\n/* Default callback always returns a constant. */\nvoid TS_RESP_CTX_set_serial_cb(TS_RESP_CTX *ctx, TS_serial_cb cb, void *data);\n\n/* Default callback uses the gettimeofday() and gmtime() system calls. */\nvoid TS_RESP_CTX_set_time_cb(TS_RESP_CTX *ctx, TS_time_cb cb, void *data);\n\n/*\n * Default callback rejects all extensions. The extension callback is called\n * when the TS_TST_INFO object is already set up and not signed yet.\n */\n/* FIXME: extension handling is not tested yet. */\nvoid TS_RESP_CTX_set_extension_cb(TS_RESP_CTX *ctx,\n                                  TS_extension_cb cb, void *data);\n\n/* The following methods can be used in the callbacks. */\nint TS_RESP_CTX_set_status_info(TS_RESP_CTX *ctx,\n                                int status, const char *text);\n\n/* Sets the status info only if it is still TS_STATUS_GRANTED. */\nint TS_RESP_CTX_set_status_info_cond(TS_RESP_CTX *ctx,\n                                     int status, const char *text);\n\nint TS_RESP_CTX_add_failure_info(TS_RESP_CTX *ctx, int failure);\n\n/* The get methods below can be used in the extension callback. */\nTS_REQ *TS_RESP_CTX_get_request(TS_RESP_CTX *ctx);\n\nTS_TST_INFO *TS_RESP_CTX_get_tst_info(TS_RESP_CTX *ctx);\n\n/*\n * Creates the signed TS_TST_INFO and puts it in TS_RESP.\n * In case of errors it sets the status info properly.\n * Returns NULL only in case of memory allocation/fatal error.\n */\nTS_RESP *TS_RESP_create_response(TS_RESP_CTX *ctx, BIO *req_bio);\n\n/*\n * Declarations related to response verification,\n * they are defined in ts/ts_resp_verify.c.\n */\n\nint TS_RESP_verify_signature(PKCS7 *token, STACK_OF(X509) *certs,\n                             X509_STORE *store, X509 **signer_out);\n\n/* Context structure for the generic verify method. */\n\n/* Verify the signer's certificate and the signature of the response. */\n# define TS_VFY_SIGNATURE        (1u << 0)\n/* Verify the version number of the response. */\n# define TS_VFY_VERSION          (1u << 1)\n/* Verify if the policy supplied by the user matches the policy of the TSA. */\n# define TS_VFY_POLICY           (1u << 2)\n/*\n * Verify the message imprint provided by the user. This flag should not be\n * specified with TS_VFY_DATA.\n */\n# define TS_VFY_IMPRINT          (1u << 3)\n/*\n * Verify the message imprint computed by the verify method from the user\n * provided data and the MD algorithm of the response. This flag should not\n * be specified with TS_VFY_IMPRINT.\n */\n# define TS_VFY_DATA             (1u << 4)\n/* Verify the nonce value. */\n# define TS_VFY_NONCE            (1u << 5)\n/* Verify if the TSA name field matches the signer certificate. */\n# define TS_VFY_SIGNER           (1u << 6)\n/* Verify if the TSA name field equals to the user provided name. */\n# define TS_VFY_TSA_NAME         (1u << 7)\n\n/* You can use the following convenience constants. */\n# define TS_VFY_ALL_IMPRINT      (TS_VFY_SIGNATURE       \\\n                                 | TS_VFY_VERSION       \\\n                                 | TS_VFY_POLICY        \\\n                                 | TS_VFY_IMPRINT       \\\n                                 | TS_VFY_NONCE         \\\n                                 | TS_VFY_SIGNER        \\\n                                 | TS_VFY_TSA_NAME)\n# define TS_VFY_ALL_DATA         (TS_VFY_SIGNATURE       \\\n                                 | TS_VFY_VERSION       \\\n                                 | TS_VFY_POLICY        \\\n                                 | TS_VFY_DATA          \\\n                                 | TS_VFY_NONCE         \\\n                                 | TS_VFY_SIGNER        \\\n                                 | TS_VFY_TSA_NAME)\n\ntypedef struct TS_verify_ctx {\n    /* Set this to the union of TS_VFY_... flags you want to carry out. */\n    unsigned flags;\n    /* Must be set only with TS_VFY_SIGNATURE. certs is optional. */\n    X509_STORE *store;\n    STACK_OF(X509) *certs;\n    /* Must be set only with TS_VFY_POLICY. */\n    ASN1_OBJECT *policy;\n    /*\n     * Must be set only with TS_VFY_IMPRINT. If md_alg is NULL, the\n     * algorithm from the response is used.\n     */\n    X509_ALGOR *md_alg;\n    unsigned char *imprint;\n    unsigned imprint_len;\n    /* Must be set only with TS_VFY_DATA. */\n    BIO *data;\n    /* Must be set only with TS_VFY_TSA_NAME. */\n    ASN1_INTEGER *nonce;\n    /* Must be set only with TS_VFY_TSA_NAME. */\n    GENERAL_NAME *tsa_name;\n} TS_VERIFY_CTX;\n\nint TS_RESP_verify_response(TS_VERIFY_CTX *ctx, TS_RESP *response);\nint TS_RESP_verify_token(TS_VERIFY_CTX *ctx, PKCS7 *token);\n\n/*\n * Declarations related to response verification context,\n * they are defined in ts/ts_verify_ctx.c.\n */\n\n/* Set all fields to zero. */\nTS_VERIFY_CTX *TS_VERIFY_CTX_new(void);\nvoid TS_VERIFY_CTX_init(TS_VERIFY_CTX *ctx);\nvoid TS_VERIFY_CTX_free(TS_VERIFY_CTX *ctx);\nvoid TS_VERIFY_CTX_cleanup(TS_VERIFY_CTX *ctx);\n\n/*-\n * If ctx is NULL, it allocates and returns a new object, otherwise\n * it returns ctx. It initialises all the members as follows:\n * flags = TS_VFY_ALL_IMPRINT & ~(TS_VFY_TSA_NAME | TS_VFY_SIGNATURE)\n * certs = NULL\n * store = NULL\n * policy = policy from the request or NULL if absent (in this case\n *      TS_VFY_POLICY is cleared from flags as well)\n * md_alg = MD algorithm from request\n * imprint, imprint_len = imprint from request\n * data = NULL\n * nonce, nonce_len = nonce from the request or NULL if absent (in this case\n *      TS_VFY_NONCE is cleared from flags as well)\n * tsa_name = NULL\n * Important: after calling this method TS_VFY_SIGNATURE should be added!\n */\nTS_VERIFY_CTX *TS_REQ_to_TS_VERIFY_CTX(TS_REQ *req, TS_VERIFY_CTX *ctx);\n\n/* Function declarations for TS_RESP defined in ts/ts_resp_print.c */\n\nint TS_RESP_print_bio(BIO *bio, TS_RESP *a);\nint TS_STATUS_INFO_print_bio(BIO *bio, TS_STATUS_INFO *a);\nint TS_TST_INFO_print_bio(BIO *bio, TS_TST_INFO *a);\n\n/* Common utility functions defined in ts/ts_lib.c */\n\nint TS_ASN1_INTEGER_print_bio(BIO *bio, const ASN1_INTEGER *num);\nint TS_OBJ_print_bio(BIO *bio, const ASN1_OBJECT *obj);\nint TS_ext_print_bio(BIO *bio, const STACK_OF(X509_EXTENSION) *extensions);\nint TS_X509_ALGOR_print_bio(BIO *bio, const X509_ALGOR *alg);\nint TS_MSG_IMPRINT_print_bio(BIO *bio, TS_MSG_IMPRINT *msg);\n\n/*\n * Function declarations for handling configuration options, defined in\n * ts/ts_conf.c\n */\n\nX509 *TS_CONF_load_cert(const char *file);\nSTACK_OF(X509) *TS_CONF_load_certs(const char *file);\nEVP_PKEY *TS_CONF_load_key(const char *file, const char *pass);\nconst char *TS_CONF_get_tsa_section(CONF *conf, const char *section);\nint TS_CONF_set_serial(CONF *conf, const char *section, TS_serial_cb cb,\n                       TS_RESP_CTX *ctx);\nint TS_CONF_set_crypto_device(CONF *conf, const char *section,\n                              const char *device);\nint TS_CONF_set_default_engine(const char *name);\nint TS_CONF_set_signer_cert(CONF *conf, const char *section,\n                            const char *cert, TS_RESP_CTX *ctx);\nint TS_CONF_set_certs(CONF *conf, const char *section, const char *certs,\n                      TS_RESP_CTX *ctx);\nint TS_CONF_set_signer_key(CONF *conf, const char *section,\n                           const char *key, const char *pass,\n                           TS_RESP_CTX *ctx);\nint TS_CONF_set_def_policy(CONF *conf, const char *section,\n                           const char *policy, TS_RESP_CTX *ctx);\nint TS_CONF_set_policies(CONF *conf, const char *section, TS_RESP_CTX *ctx);\nint TS_CONF_set_digests(CONF *conf, const char *section, TS_RESP_CTX *ctx);\nint TS_CONF_set_accuracy(CONF *conf, const char *section, TS_RESP_CTX *ctx);\nint TS_CONF_set_clock_precision_digits(CONF *conf, const char *section,\n                                       TS_RESP_CTX *ctx);\nint TS_CONF_set_ordering(CONF *conf, const char *section, TS_RESP_CTX *ctx);\nint TS_CONF_set_tsa_name(CONF *conf, const char *section, TS_RESP_CTX *ctx);\nint TS_CONF_set_ess_cert_id_chain(CONF *conf, const char *section,\n                                  TS_RESP_CTX *ctx);\n\n/* -------------------------------------------------- */\n/* BEGIN ERROR CODES */\n/*\n * The following lines are auto generated by the script mkerr.pl. Any changes\n * made after this point may be overwritten when the script is next run.\n */\nvoid ERR_load_TS_strings(void);\n\n/* Error codes for the TS functions. */\n\n/* Function codes. */\n# define TS_F_D2I_TS_RESP                                 147\n# define TS_F_DEF_SERIAL_CB                               110\n# define TS_F_DEF_TIME_CB                                 111\n# define TS_F_ESS_ADD_SIGNING_CERT                        112\n# define TS_F_ESS_CERT_ID_NEW_INIT                        113\n# define TS_F_ESS_SIGNING_CERT_NEW_INIT                   114\n# define TS_F_INT_TS_RESP_VERIFY_TOKEN                    149\n# define TS_F_PKCS7_TO_TS_TST_INFO                        148\n# define TS_F_TS_ACCURACY_SET_MICROS                      115\n# define TS_F_TS_ACCURACY_SET_MILLIS                      116\n# define TS_F_TS_ACCURACY_SET_SECONDS                     117\n# define TS_F_TS_CHECK_IMPRINTS                           100\n# define TS_F_TS_CHECK_NONCES                             101\n# define TS_F_TS_CHECK_POLICY                             102\n# define TS_F_TS_CHECK_SIGNING_CERTS                      103\n# define TS_F_TS_CHECK_STATUS_INFO                        104\n# define TS_F_TS_COMPUTE_IMPRINT                          145\n# define TS_F_TS_CONF_SET_DEFAULT_ENGINE                  146\n# define TS_F_TS_GET_STATUS_TEXT                          105\n# define TS_F_TS_MSG_IMPRINT_SET_ALGO                     118\n# define TS_F_TS_REQ_SET_MSG_IMPRINT                      119\n# define TS_F_TS_REQ_SET_NONCE                            120\n# define TS_F_TS_REQ_SET_POLICY_ID                        121\n# define TS_F_TS_RESP_CREATE_RESPONSE                     122\n# define TS_F_TS_RESP_CREATE_TST_INFO                     123\n# define TS_F_TS_RESP_CTX_ADD_FAILURE_INFO                124\n# define TS_F_TS_RESP_CTX_ADD_MD                          125\n# define TS_F_TS_RESP_CTX_ADD_POLICY                      126\n# define TS_F_TS_RESP_CTX_NEW                             127\n# define TS_F_TS_RESP_CTX_SET_ACCURACY                    128\n# define TS_F_TS_RESP_CTX_SET_CERTS                       129\n# define TS_F_TS_RESP_CTX_SET_DEF_POLICY                  130\n# define TS_F_TS_RESP_CTX_SET_SIGNER_CERT                 131\n# define TS_F_TS_RESP_CTX_SET_STATUS_INFO                 132\n# define TS_F_TS_RESP_GET_POLICY                          133\n# define TS_F_TS_RESP_SET_GENTIME_WITH_PRECISION          134\n# define TS_F_TS_RESP_SET_STATUS_INFO                     135\n# define TS_F_TS_RESP_SET_TST_INFO                        150\n# define TS_F_TS_RESP_SIGN                                136\n# define TS_F_TS_RESP_VERIFY_SIGNATURE                    106\n# define TS_F_TS_RESP_VERIFY_TOKEN                        107\n# define TS_F_TS_TST_INFO_SET_ACCURACY                    137\n# define TS_F_TS_TST_INFO_SET_MSG_IMPRINT                 138\n# define TS_F_TS_TST_INFO_SET_NONCE                       139\n# define TS_F_TS_TST_INFO_SET_POLICY_ID                   140\n# define TS_F_TS_TST_INFO_SET_SERIAL                      141\n# define TS_F_TS_TST_INFO_SET_TIME                        142\n# define TS_F_TS_TST_INFO_SET_TSA                         143\n# define TS_F_TS_VERIFY                                   108\n# define TS_F_TS_VERIFY_CERT                              109\n# define TS_F_TS_VERIFY_CTX_NEW                           144\n\n/* Reason codes. */\n# define TS_R_BAD_PKCS7_TYPE                              132\n# define TS_R_BAD_TYPE                                    133\n# define TS_R_CERTIFICATE_VERIFY_ERROR                    100\n# define TS_R_COULD_NOT_SET_ENGINE                        127\n# define TS_R_COULD_NOT_SET_TIME                          115\n# define TS_R_D2I_TS_RESP_INT_FAILED                      128\n# define TS_R_DETACHED_CONTENT                            134\n# define TS_R_ESS_ADD_SIGNING_CERT_ERROR                  116\n# define TS_R_ESS_SIGNING_CERTIFICATE_ERROR               101\n# define TS_R_INVALID_NULL_POINTER                        102\n# define TS_R_INVALID_SIGNER_CERTIFICATE_PURPOSE          117\n# define TS_R_MESSAGE_IMPRINT_MISMATCH                    103\n# define TS_R_NONCE_MISMATCH                              104\n# define TS_R_NONCE_NOT_RETURNED                          105\n# define TS_R_NO_CONTENT                                  106\n# define TS_R_NO_TIME_STAMP_TOKEN                         107\n# define TS_R_PKCS7_ADD_SIGNATURE_ERROR                   118\n# define TS_R_PKCS7_ADD_SIGNED_ATTR_ERROR                 119\n# define TS_R_PKCS7_TO_TS_TST_INFO_FAILED                 129\n# define TS_R_POLICY_MISMATCH                             108\n# define TS_R_PRIVATE_KEY_DOES_NOT_MATCH_CERTIFICATE      120\n# define TS_R_RESPONSE_SETUP_ERROR                        121\n# define TS_R_SIGNATURE_FAILURE                           109\n# define TS_R_THERE_MUST_BE_ONE_SIGNER                    110\n# define TS_R_TIME_SYSCALL_ERROR                          122\n# define TS_R_TOKEN_NOT_PRESENT                           130\n# define TS_R_TOKEN_PRESENT                               131\n# define TS_R_TSA_NAME_MISMATCH                           111\n# define TS_R_TSA_UNTRUSTED                               112\n# define TS_R_TST_INFO_SETUP_ERROR                        123\n# define TS_R_TS_DATASIGN                                 124\n# define TS_R_UNACCEPTABLE_POLICY                         125\n# define TS_R_UNSUPPORTED_MD_ALGORITHM                    126\n# define TS_R_UNSUPPORTED_VERSION                         113\n# define TS_R_WRONG_CONTENT_TYPE                          114\n\n#ifdef  __cplusplus\n}\n#endif\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/x86/include/openssl/txt_db.h",
    "content": "/* crypto/txt_db/txt_db.h */\n/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)\n * All rights reserved.\n *\n * This package is an SSL implementation written\n * by Eric Young (eay@cryptsoft.com).\n * The implementation was written so as to conform with Netscapes SSL.\n *\n * This library is free for commercial and non-commercial use as long as\n * the following conditions are aheared to.  The following conditions\n * apply to all code found in this distribution, be it the RC4, RSA,\n * lhash, DES, etc., code; not just the SSL code.  The SSL documentation\n * included with this distribution is covered by the same copyright terms\n * except that the holder is Tim Hudson (tjh@cryptsoft.com).\n *\n * Copyright remains Eric Young's, and as such any Copyright notices in\n * the code are not to be removed.\n * If this package is used in a product, Eric Young should be given attribution\n * as the author of the parts of the library used.\n * This can be in the form of a textual message at program startup or\n * in documentation (online or textual) provided with the package.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the copyright\n *    notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in the\n *    documentation and/or other materials provided with the distribution.\n * 3. All advertising materials mentioning features or use of this software\n *    must display the following acknowledgement:\n *    \"This product includes cryptographic software written by\n *     Eric Young (eay@cryptsoft.com)\"\n *    The word 'cryptographic' can be left out if the rouines from the library\n *    being used are not cryptographic related :-).\n * 4. If you include any Windows specific code (or a derivative thereof) from\n *    the apps directory (application code) you must include an acknowledgement:\n *    \"This product includes software written by Tim Hudson (tjh@cryptsoft.com)\"\n *\n * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n * SUCH DAMAGE.\n *\n * The licence and distribution terms for any publically available version or\n * derivative of this code cannot be changed.  i.e. this code cannot simply be\n * copied and put under another distribution licence\n * [including the GNU Public Licence.]\n */\n\n#ifndef HEADER_TXT_DB_H\n# define HEADER_TXT_DB_H\n\n# include <openssl/opensslconf.h>\n# ifndef OPENSSL_NO_BIO\n#  include <openssl/bio.h>\n# endif\n# include <openssl/stack.h>\n# include <openssl/lhash.h>\n\n# define DB_ERROR_OK                     0\n# define DB_ERROR_MALLOC                 1\n# define DB_ERROR_INDEX_CLASH            2\n# define DB_ERROR_INDEX_OUT_OF_RANGE     3\n# define DB_ERROR_NO_INDEX               4\n# define DB_ERROR_INSERT_INDEX_CLASH     5\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\ntypedef OPENSSL_STRING *OPENSSL_PSTRING;\nDECLARE_SPECIAL_STACK_OF(OPENSSL_PSTRING, OPENSSL_STRING)\n\ntypedef struct txt_db_st {\n    int num_fields;\n    STACK_OF(OPENSSL_PSTRING) *data;\n    LHASH_OF(OPENSSL_STRING) **index;\n    int (**qual) (OPENSSL_STRING *);\n    long error;\n    long arg1;\n    long arg2;\n    OPENSSL_STRING *arg_row;\n} TXT_DB;\n\n# ifndef OPENSSL_NO_BIO\nTXT_DB *TXT_DB_read(BIO *in, int num);\nlong TXT_DB_write(BIO *out, TXT_DB *db);\n# else\nTXT_DB *TXT_DB_read(char *in, int num);\nlong TXT_DB_write(char *out, TXT_DB *db);\n# endif\nint TXT_DB_create_index(TXT_DB *db, int field, int (*qual) (OPENSSL_STRING *),\n                        LHASH_HASH_FN_TYPE hash, LHASH_COMP_FN_TYPE cmp);\nvoid TXT_DB_free(TXT_DB *db);\nOPENSSL_STRING *TXT_DB_get_by_index(TXT_DB *db, int idx,\n                                    OPENSSL_STRING *value);\nint TXT_DB_insert(TXT_DB *db, OPENSSL_STRING *value);\n\n#ifdef  __cplusplus\n}\n#endif\n\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/x86/include/openssl/ui.h",
    "content": "/* crypto/ui/ui.h */\n/*\n * Written by Richard Levitte (richard@levitte.org) for the OpenSSL project\n * 2001.\n */\n/* ====================================================================\n * Copyright (c) 2001 The OpenSSL Project.  All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n *\n * 1. Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n *\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in\n *    the documentation and/or other materials provided with the\n *    distribution.\n *\n * 3. All advertising materials mentioning features or use of this\n *    software must display the following acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit. (http://www.openssl.org/)\"\n *\n * 4. The names \"OpenSSL Toolkit\" and \"OpenSSL Project\" must not be used to\n *    endorse or promote products derived from this software without\n *    prior written permission. For written permission, please contact\n *    openssl-core@openssl.org.\n *\n * 5. Products derived from this software may not be called \"OpenSSL\"\n *    nor may \"OpenSSL\" appear in their names without prior written\n *    permission of the OpenSSL Project.\n *\n * 6. Redistributions of any form whatsoever must retain the following\n *    acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit (http://www.openssl.org/)\"\n *\n * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY\n * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\n * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR\n * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\n * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,\n * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED\n * OF THE POSSIBILITY OF SUCH DAMAGE.\n * ====================================================================\n *\n * This product includes cryptographic software written by Eric Young\n * (eay@cryptsoft.com).  This product includes software written by Tim\n * Hudson (tjh@cryptsoft.com).\n *\n */\n\n#ifndef HEADER_UI_H\n# define HEADER_UI_H\n\n# ifndef OPENSSL_NO_DEPRECATED\n#  include <openssl/crypto.h>\n# endif\n# include <openssl/safestack.h>\n# include <openssl/ossl_typ.h>\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n/* Declared already in ossl_typ.h */\n/* typedef struct ui_st UI; */\n/* typedef struct ui_method_st UI_METHOD; */\n\n/*\n * All the following functions return -1 or NULL on error and in some cases\n * (UI_process()) -2 if interrupted or in some other way cancelled. When\n * everything is fine, they return 0, a positive value or a non-NULL pointer,\n * all depending on their purpose.\n */\n\n/* Creators and destructor.   */\nUI *UI_new(void);\nUI *UI_new_method(const UI_METHOD *method);\nvoid UI_free(UI *ui);\n\n/*-\n   The following functions are used to add strings to be printed and prompt\n   strings to prompt for data.  The names are UI_{add,dup}_<function>_string\n   and UI_{add,dup}_input_boolean.\n\n   UI_{add,dup}_<function>_string have the following meanings:\n        add     add a text or prompt string.  The pointers given to these\n                functions are used verbatim, no copying is done.\n        dup     make a copy of the text or prompt string, then add the copy\n                to the collection of strings in the user interface.\n        <function>\n                The function is a name for the functionality that the given\n                string shall be used for.  It can be one of:\n                        input   use the string as data prompt.\n                        verify  use the string as verification prompt.  This\n                                is used to verify a previous input.\n                        info    use the string for informational output.\n                        error   use the string for error output.\n   Honestly, there's currently no difference between info and error for the\n   moment.\n\n   UI_{add,dup}_input_boolean have the same semantics for \"add\" and \"dup\",\n   and are typically used when one wants to prompt for a yes/no response.\n\n   All of the functions in this group take a UI and a prompt string.\n   The string input and verify addition functions also take a flag argument,\n   a buffer for the result to end up with, a minimum input size and a maximum\n   input size (the result buffer MUST be large enough to be able to contain\n   the maximum number of characters).  Additionally, the verify addition\n   functions takes another buffer to compare the result against.\n   The boolean input functions take an action description string (which should\n   be safe to ignore if the expected user action is obvious, for example with\n   a dialog box with an OK button and a Cancel button), a string of acceptable\n   characters to mean OK and to mean Cancel.  The two last strings are checked\n   to make sure they don't have common characters.  Additionally, the same\n   flag argument as for the string input is taken, as well as a result buffer.\n   The result buffer is required to be at least one byte long.  Depending on\n   the answer, the first character from the OK or the Cancel character strings\n   will be stored in the first byte of the result buffer.  No NUL will be\n   added, so the result is *not* a string.\n\n   On success, the all return an index of the added information.  That index\n   is usefull when retrieving results with UI_get0_result(). */\nint UI_add_input_string(UI *ui, const char *prompt, int flags,\n                        char *result_buf, int minsize, int maxsize);\nint UI_dup_input_string(UI *ui, const char *prompt, int flags,\n                        char *result_buf, int minsize, int maxsize);\nint UI_add_verify_string(UI *ui, const char *prompt, int flags,\n                         char *result_buf, int minsize, int maxsize,\n                         const char *test_buf);\nint UI_dup_verify_string(UI *ui, const char *prompt, int flags,\n                         char *result_buf, int minsize, int maxsize,\n                         const char *test_buf);\nint UI_add_input_boolean(UI *ui, const char *prompt, const char *action_desc,\n                         const char *ok_chars, const char *cancel_chars,\n                         int flags, char *result_buf);\nint UI_dup_input_boolean(UI *ui, const char *prompt, const char *action_desc,\n                         const char *ok_chars, const char *cancel_chars,\n                         int flags, char *result_buf);\nint UI_add_info_string(UI *ui, const char *text);\nint UI_dup_info_string(UI *ui, const char *text);\nint UI_add_error_string(UI *ui, const char *text);\nint UI_dup_error_string(UI *ui, const char *text);\n\n/* These are the possible flags.  They can be or'ed together. */\n/* Use to have echoing of input */\n# define UI_INPUT_FLAG_ECHO              0x01\n/*\n * Use a default password.  Where that password is found is completely up to\n * the application, it might for example be in the user data set with\n * UI_add_user_data().  It is not recommended to have more than one input in\n * each UI being marked with this flag, or the application might get\n * confused.\n */\n# define UI_INPUT_FLAG_DEFAULT_PWD       0x02\n\n/*-\n * The user of these routines may want to define flags of their own.  The core\n * UI won't look at those, but will pass them on to the method routines.  They\n * must use higher bits so they don't get confused with the UI bits above.\n * UI_INPUT_FLAG_USER_BASE tells which is the lowest bit to use.  A good\n * example of use is this:\n *\n *    #define MY_UI_FLAG1       (0x01 << UI_INPUT_FLAG_USER_BASE)\n *\n*/\n# define UI_INPUT_FLAG_USER_BASE 16\n\n/*-\n * The following function helps construct a prompt.  object_desc is a\n * textual short description of the object, for example \"pass phrase\",\n * and object_name is the name of the object (might be a card name or\n * a file name.\n * The returned string shall always be allocated on the heap with\n * OPENSSL_malloc(), and need to be free'd with OPENSSL_free().\n *\n * If the ui_method doesn't contain a pointer to a user-defined prompt\n * constructor, a default string is built, looking like this:\n *\n *       \"Enter {object_desc} for {object_name}:\"\n *\n * So, if object_desc has the value \"pass phrase\" and object_name has\n * the value \"foo.key\", the resulting string is:\n *\n *       \"Enter pass phrase for foo.key:\"\n*/\nchar *UI_construct_prompt(UI *ui_method,\n                          const char *object_desc, const char *object_name);\n\n/*\n * The following function is used to store a pointer to user-specific data.\n * Any previous such pointer will be returned and replaced.\n *\n * For callback purposes, this function makes a lot more sense than using\n * ex_data, since the latter requires that different parts of OpenSSL or\n * applications share the same ex_data index.\n *\n * Note that the UI_OpenSSL() method completely ignores the user data. Other\n * methods may not, however.\n */\nvoid *UI_add_user_data(UI *ui, void *user_data);\n/* We need a user data retrieving function as well.  */\nvoid *UI_get0_user_data(UI *ui);\n\n/* Return the result associated with a prompt given with the index i. */\nconst char *UI_get0_result(UI *ui, int i);\n\n/* When all strings have been added, process the whole thing. */\nint UI_process(UI *ui);\n\n/*\n * Give a user interface parametrised control commands.  This can be used to\n * send down an integer, a data pointer or a function pointer, as well as be\n * used to get information from a UI.\n */\nint UI_ctrl(UI *ui, int cmd, long i, void *p, void (*f) (void));\n\n/* The commands */\n/*\n * Use UI_CONTROL_PRINT_ERRORS with the value 1 to have UI_process print the\n * OpenSSL error stack before printing any info or added error messages and\n * before any prompting.\n */\n# define UI_CTRL_PRINT_ERRORS            1\n/*\n * Check if a UI_process() is possible to do again with the same instance of\n * a user interface.  This makes UI_ctrl() return 1 if it is redoable, and 0\n * if not.\n */\n# define UI_CTRL_IS_REDOABLE             2\n\n/* Some methods may use extra data */\n# define UI_set_app_data(s,arg)         UI_set_ex_data(s,0,arg)\n# define UI_get_app_data(s)             UI_get_ex_data(s,0)\nint UI_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func,\n                        CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func);\nint UI_set_ex_data(UI *r, int idx, void *arg);\nvoid *UI_get_ex_data(UI *r, int idx);\n\n/* Use specific methods instead of the built-in one */\nvoid UI_set_default_method(const UI_METHOD *meth);\nconst UI_METHOD *UI_get_default_method(void);\nconst UI_METHOD *UI_get_method(UI *ui);\nconst UI_METHOD *UI_set_method(UI *ui, const UI_METHOD *meth);\n\n/* The method with all the built-in thingies */\nUI_METHOD *UI_OpenSSL(void);\n\n/* ---------- For method writers ---------- */\n/*-\n   A method contains a number of functions that implement the low level\n   of the User Interface.  The functions are:\n\n        an opener       This function starts a session, maybe by opening\n                        a channel to a tty, or by opening a window.\n        a writer        This function is called to write a given string,\n                        maybe to the tty, maybe as a field label in a\n                        window.\n        a flusher       This function is called to flush everything that\n                        has been output so far.  It can be used to actually\n                        display a dialog box after it has been built.\n        a reader        This function is called to read a given prompt,\n                        maybe from the tty, maybe from a field in a\n                        window.  Note that it's called wth all string\n                        structures, not only the prompt ones, so it must\n                        check such things itself.\n        a closer        This function closes the session, maybe by closing\n                        the channel to the tty, or closing the window.\n\n   All these functions are expected to return:\n\n        0       on error.\n        1       on success.\n        -1      on out-of-band events, for example if some prompting has\n                been canceled (by pressing Ctrl-C, for example).  This is\n                only checked when returned by the flusher or the reader.\n\n   The way this is used, the opener is first called, then the writer for all\n   strings, then the flusher, then the reader for all strings and finally the\n   closer.  Note that if you want to prompt from a terminal or other command\n   line interface, the best is to have the reader also write the prompts\n   instead of having the writer do it.  If you want to prompt from a dialog\n   box, the writer can be used to build up the contents of the box, and the\n   flusher to actually display the box and run the event loop until all data\n   has been given, after which the reader only grabs the given data and puts\n   them back into the UI strings.\n\n   All method functions take a UI as argument.  Additionally, the writer and\n   the reader take a UI_STRING.\n*/\n\n/*\n * The UI_STRING type is the data structure that contains all the needed info\n * about a string or a prompt, including test data for a verification prompt.\n */\ntypedef struct ui_string_st UI_STRING;\nDECLARE_STACK_OF(UI_STRING)\n\n/*\n * The different types of strings that are currently supported. This is only\n * needed by method authors.\n */\nenum UI_string_types {\n    UIT_NONE = 0,\n    UIT_PROMPT,                 /* Prompt for a string */\n    UIT_VERIFY,                 /* Prompt for a string and verify */\n    UIT_BOOLEAN,                /* Prompt for a yes/no response */\n    UIT_INFO,                   /* Send info to the user */\n    UIT_ERROR                   /* Send an error message to the user */\n};\n\n/* Create and manipulate methods */\nUI_METHOD *UI_create_method(char *name);\nvoid UI_destroy_method(UI_METHOD *ui_method);\nint UI_method_set_opener(UI_METHOD *method, int (*opener) (UI *ui));\nint UI_method_set_writer(UI_METHOD *method,\n                         int (*writer) (UI *ui, UI_STRING *uis));\nint UI_method_set_flusher(UI_METHOD *method, int (*flusher) (UI *ui));\nint UI_method_set_reader(UI_METHOD *method,\n                         int (*reader) (UI *ui, UI_STRING *uis));\nint UI_method_set_closer(UI_METHOD *method, int (*closer) (UI *ui));\nint UI_method_set_prompt_constructor(UI_METHOD *method,\n                                     char *(*prompt_constructor) (UI *ui,\n                                                                  const char\n                                                                  *object_desc,\n                                                                  const char\n                                                                  *object_name));\nint (*UI_method_get_opener(UI_METHOD *method)) (UI *);\nint (*UI_method_get_writer(UI_METHOD *method)) (UI *, UI_STRING *);\nint (*UI_method_get_flusher(UI_METHOD *method)) (UI *);\nint (*UI_method_get_reader(UI_METHOD *method)) (UI *, UI_STRING *);\nint (*UI_method_get_closer(UI_METHOD *method)) (UI *);\nchar *(*UI_method_get_prompt_constructor(UI_METHOD *method)) (UI *,\n                                                              const char *,\n                                                              const char *);\n\n/*\n * The following functions are helpers for method writers to access relevant\n * data from a UI_STRING.\n */\n\n/* Return type of the UI_STRING */\nenum UI_string_types UI_get_string_type(UI_STRING *uis);\n/* Return input flags of the UI_STRING */\nint UI_get_input_flags(UI_STRING *uis);\n/* Return the actual string to output (the prompt, info or error) */\nconst char *UI_get0_output_string(UI_STRING *uis);\n/*\n * Return the optional action string to output (the boolean promtp\n * instruction)\n */\nconst char *UI_get0_action_string(UI_STRING *uis);\n/* Return the result of a prompt */\nconst char *UI_get0_result_string(UI_STRING *uis);\n/*\n * Return the string to test the result against.  Only useful with verifies.\n */\nconst char *UI_get0_test_string(UI_STRING *uis);\n/* Return the required minimum size of the result */\nint UI_get_result_minsize(UI_STRING *uis);\n/* Return the required maximum size of the result */\nint UI_get_result_maxsize(UI_STRING *uis);\n/* Set the result of a UI_STRING. */\nint UI_set_result(UI *ui, UI_STRING *uis, const char *result);\n\n/* A couple of popular utility functions */\nint UI_UTIL_read_pw_string(char *buf, int length, const char *prompt,\n                           int verify);\nint UI_UTIL_read_pw(char *buf, char *buff, int size, const char *prompt,\n                    int verify);\n\n/* BEGIN ERROR CODES */\n/*\n * The following lines are auto generated by the script mkerr.pl. Any changes\n * made after this point may be overwritten when the script is next run.\n */\nvoid ERR_load_UI_strings(void);\n\n/* Error codes for the UI functions. */\n\n/* Function codes. */\n# define UI_F_GENERAL_ALLOCATE_BOOLEAN                    108\n# define UI_F_GENERAL_ALLOCATE_PROMPT                     109\n# define UI_F_GENERAL_ALLOCATE_STRING                     100\n# define UI_F_UI_CTRL                                     111\n# define UI_F_UI_DUP_ERROR_STRING                         101\n# define UI_F_UI_DUP_INFO_STRING                          102\n# define UI_F_UI_DUP_INPUT_BOOLEAN                        110\n# define UI_F_UI_DUP_INPUT_STRING                         103\n# define UI_F_UI_DUP_VERIFY_STRING                        106\n# define UI_F_UI_GET0_RESULT                              107\n# define UI_F_UI_NEW_METHOD                               104\n# define UI_F_UI_SET_RESULT                               105\n\n/* Reason codes. */\n# define UI_R_COMMON_OK_AND_CANCEL_CHARACTERS             104\n# define UI_R_INDEX_TOO_LARGE                             102\n# define UI_R_INDEX_TOO_SMALL                             103\n# define UI_R_NO_RESULT_BUFFER                            105\n# define UI_R_RESULT_TOO_LARGE                            100\n# define UI_R_RESULT_TOO_SMALL                            101\n# define UI_R_UNKNOWN_CONTROL_COMMAND                     106\n\n#ifdef  __cplusplus\n}\n#endif\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/x86/include/openssl/ui_compat.h",
    "content": "/* crypto/ui/ui.h */\n/*\n * Written by Richard Levitte (richard@levitte.org) for the OpenSSL project\n * 2001.\n */\n/* ====================================================================\n * Copyright (c) 2001 The OpenSSL Project.  All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n *\n * 1. Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n *\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in\n *    the documentation and/or other materials provided with the\n *    distribution.\n *\n * 3. All advertising materials mentioning features or use of this\n *    software must display the following acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit. (http://www.openssl.org/)\"\n *\n * 4. The names \"OpenSSL Toolkit\" and \"OpenSSL Project\" must not be used to\n *    endorse or promote products derived from this software without\n *    prior written permission. For written permission, please contact\n *    openssl-core@openssl.org.\n *\n * 5. Products derived from this software may not be called \"OpenSSL\"\n *    nor may \"OpenSSL\" appear in their names without prior written\n *    permission of the OpenSSL Project.\n *\n * 6. Redistributions of any form whatsoever must retain the following\n *    acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit (http://www.openssl.org/)\"\n *\n * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY\n * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\n * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR\n * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\n * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,\n * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED\n * OF THE POSSIBILITY OF SUCH DAMAGE.\n * ====================================================================\n *\n * This product includes cryptographic software written by Eric Young\n * (eay@cryptsoft.com).  This product includes software written by Tim\n * Hudson (tjh@cryptsoft.com).\n *\n */\n\n#ifndef HEADER_UI_COMPAT_H\n# define HEADER_UI_COMPAT_H\n\n# include <openssl/opensslconf.h>\n# include <openssl/ui.h>\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n/*\n * The following functions were previously part of the DES section, and are\n * provided here for backward compatibility reasons.\n */\n\n# define des_read_pw_string(b,l,p,v) \\\n        _ossl_old_des_read_pw_string((b),(l),(p),(v))\n# define des_read_pw(b,bf,s,p,v) \\\n        _ossl_old_des_read_pw((b),(bf),(s),(p),(v))\n\nint _ossl_old_des_read_pw_string(char *buf, int length, const char *prompt,\n                                 int verify);\nint _ossl_old_des_read_pw(char *buf, char *buff, int size, const char *prompt,\n                          int verify);\n\n#ifdef  __cplusplus\n}\n#endif\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/x86/include/openssl/whrlpool.h",
    "content": "#ifndef HEADER_WHRLPOOL_H\n# define HEADER_WHRLPOOL_H\n\n# include <openssl/e_os2.h>\n# include <stddef.h>\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n# define WHIRLPOOL_DIGEST_LENGTH (512/8)\n# define WHIRLPOOL_BBLOCK        512\n# define WHIRLPOOL_COUNTER       (256/8)\n\ntypedef struct {\n    union {\n        unsigned char c[WHIRLPOOL_DIGEST_LENGTH];\n        /* double q is here to ensure 64-bit alignment */\n        double q[WHIRLPOOL_DIGEST_LENGTH / sizeof(double)];\n    } H;\n    unsigned char data[WHIRLPOOL_BBLOCK / 8];\n    unsigned int bitoff;\n    size_t bitlen[WHIRLPOOL_COUNTER / sizeof(size_t)];\n} WHIRLPOOL_CTX;\n\n# ifndef OPENSSL_NO_WHIRLPOOL\n#  ifdef OPENSSL_FIPS\nint private_WHIRLPOOL_Init(WHIRLPOOL_CTX *c);\n#  endif\nint WHIRLPOOL_Init(WHIRLPOOL_CTX *c);\nint WHIRLPOOL_Update(WHIRLPOOL_CTX *c, const void *inp, size_t bytes);\nvoid WHIRLPOOL_BitUpdate(WHIRLPOOL_CTX *c, const void *inp, size_t bits);\nint WHIRLPOOL_Final(unsigned char *md, WHIRLPOOL_CTX *c);\nunsigned char *WHIRLPOOL(const void *inp, size_t bytes, unsigned char *md);\n# endif\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/x86/include/openssl/x509.h",
    "content": "/* crypto/x509/x509.h */\n/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)\n * All rights reserved.\n *\n * This package is an SSL implementation written\n * by Eric Young (eay@cryptsoft.com).\n * The implementation was written so as to conform with Netscapes SSL.\n *\n * This library is free for commercial and non-commercial use as long as\n * the following conditions are aheared to.  The following conditions\n * apply to all code found in this distribution, be it the RC4, RSA,\n * lhash, DES, etc., code; not just the SSL code.  The SSL documentation\n * included with this distribution is covered by the same copyright terms\n * except that the holder is Tim Hudson (tjh@cryptsoft.com).\n *\n * Copyright remains Eric Young's, and as such any Copyright notices in\n * the code are not to be removed.\n * If this package is used in a product, Eric Young should be given attribution\n * as the author of the parts of the library used.\n * This can be in the form of a textual message at program startup or\n * in documentation (online or textual) provided with the package.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the copyright\n *    notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in the\n *    documentation and/or other materials provided with the distribution.\n * 3. All advertising materials mentioning features or use of this software\n *    must display the following acknowledgement:\n *    \"This product includes cryptographic software written by\n *     Eric Young (eay@cryptsoft.com)\"\n *    The word 'cryptographic' can be left out if the rouines from the library\n *    being used are not cryptographic related :-).\n * 4. If you include any Windows specific code (or a derivative thereof) from\n *    the apps directory (application code) you must include an acknowledgement:\n *    \"This product includes software written by Tim Hudson (tjh@cryptsoft.com)\"\n *\n * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n * SUCH DAMAGE.\n *\n * The licence and distribution terms for any publically available version or\n * derivative of this code cannot be changed.  i.e. this code cannot simply be\n * copied and put under another distribution licence\n * [including the GNU Public Licence.]\n */\n/* ====================================================================\n * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED.\n * ECDH support in OpenSSL originally developed by\n * SUN MICROSYSTEMS, INC., and contributed to the OpenSSL project.\n */\n\n#ifndef HEADER_X509_H\n# define HEADER_X509_H\n\n# include <openssl/e_os2.h>\n# include <openssl/symhacks.h>\n# ifndef OPENSSL_NO_BUFFER\n#  include <openssl/buffer.h>\n# endif\n# ifndef OPENSSL_NO_EVP\n#  include <openssl/evp.h>\n# endif\n# ifndef OPENSSL_NO_BIO\n#  include <openssl/bio.h>\n# endif\n# include <openssl/stack.h>\n# include <openssl/asn1.h>\n# include <openssl/safestack.h>\n\n# ifndef OPENSSL_NO_EC\n#  include <openssl/ec.h>\n# endif\n\n# ifndef OPENSSL_NO_ECDSA\n#  include <openssl/ecdsa.h>\n# endif\n\n# ifndef OPENSSL_NO_ECDH\n#  include <openssl/ecdh.h>\n# endif\n\n# ifndef OPENSSL_NO_DEPRECATED\n#  ifndef OPENSSL_NO_RSA\n#   include <openssl/rsa.h>\n#  endif\n#  ifndef OPENSSL_NO_DSA\n#   include <openssl/dsa.h>\n#  endif\n#  ifndef OPENSSL_NO_DH\n#   include <openssl/dh.h>\n#  endif\n# endif\n\n# ifndef OPENSSL_NO_SHA\n#  include <openssl/sha.h>\n# endif\n# include <openssl/ossl_typ.h>\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n# ifdef OPENSSL_SYS_WIN32\n/* Under Win32 these are defined in wincrypt.h */\n#  undef X509_NAME\n#  undef X509_CERT_PAIR\n#  undef X509_EXTENSIONS\n# endif\n\n# define X509_FILETYPE_PEM       1\n# define X509_FILETYPE_ASN1      2\n# define X509_FILETYPE_DEFAULT   3\n\n# define X509v3_KU_DIGITAL_SIGNATURE     0x0080\n# define X509v3_KU_NON_REPUDIATION       0x0040\n# define X509v3_KU_KEY_ENCIPHERMENT      0x0020\n# define X509v3_KU_DATA_ENCIPHERMENT     0x0010\n# define X509v3_KU_KEY_AGREEMENT         0x0008\n# define X509v3_KU_KEY_CERT_SIGN         0x0004\n# define X509v3_KU_CRL_SIGN              0x0002\n# define X509v3_KU_ENCIPHER_ONLY         0x0001\n# define X509v3_KU_DECIPHER_ONLY         0x8000\n# define X509v3_KU_UNDEF                 0xffff\n\ntypedef struct X509_objects_st {\n    int nid;\n    int (*a2i) (void);\n    int (*i2a) (void);\n} X509_OBJECTS;\n\nstruct X509_algor_st {\n    ASN1_OBJECT *algorithm;\n    ASN1_TYPE *parameter;\n} /* X509_ALGOR */ ;\n\nDECLARE_ASN1_SET_OF(X509_ALGOR)\n\ntypedef STACK_OF(X509_ALGOR) X509_ALGORS;\n\ntypedef struct X509_val_st {\n    ASN1_TIME *notBefore;\n    ASN1_TIME *notAfter;\n} X509_VAL;\n\nstruct X509_pubkey_st {\n    X509_ALGOR *algor;\n    ASN1_BIT_STRING *public_key;\n    EVP_PKEY *pkey;\n};\n\ntypedef struct X509_sig_st {\n    X509_ALGOR *algor;\n    ASN1_OCTET_STRING *digest;\n} X509_SIG;\n\ntypedef struct X509_name_entry_st {\n    ASN1_OBJECT *object;\n    ASN1_STRING *value;\n    int set;\n    int size;                   /* temp variable */\n} X509_NAME_ENTRY;\n\nDECLARE_STACK_OF(X509_NAME_ENTRY)\nDECLARE_ASN1_SET_OF(X509_NAME_ENTRY)\n\n/* we always keep X509_NAMEs in 2 forms. */\nstruct X509_name_st {\n    STACK_OF(X509_NAME_ENTRY) *entries;\n    int modified;               /* true if 'bytes' needs to be built */\n# ifndef OPENSSL_NO_BUFFER\n    BUF_MEM *bytes;\n# else\n    char *bytes;\n# endif\n/*      unsigned long hash; Keep the hash around for lookups */\n    unsigned char *canon_enc;\n    int canon_enclen;\n} /* X509_NAME */ ;\n\nDECLARE_STACK_OF(X509_NAME)\n\n# define X509_EX_V_NETSCAPE_HACK         0x8000\n# define X509_EX_V_INIT                  0x0001\ntypedef struct X509_extension_st {\n    ASN1_OBJECT *object;\n    ASN1_BOOLEAN critical;\n    ASN1_OCTET_STRING *value;\n} X509_EXTENSION;\n\ntypedef STACK_OF(X509_EXTENSION) X509_EXTENSIONS;\n\nDECLARE_STACK_OF(X509_EXTENSION)\nDECLARE_ASN1_SET_OF(X509_EXTENSION)\n\n/* a sequence of these are used */\ntypedef struct x509_attributes_st {\n    ASN1_OBJECT *object;\n    int single;                 /* 0 for a set, 1 for a single item (which is\n                                 * wrong) */\n    union {\n        char *ptr;\n        /*\n         * 0\n         */ STACK_OF(ASN1_TYPE) *set;\n        /*\n         * 1\n         */ ASN1_TYPE *single;\n    } value;\n} X509_ATTRIBUTE;\n\nDECLARE_STACK_OF(X509_ATTRIBUTE)\nDECLARE_ASN1_SET_OF(X509_ATTRIBUTE)\n\ntypedef struct X509_req_info_st {\n    ASN1_ENCODING enc;\n    ASN1_INTEGER *version;\n    X509_NAME *subject;\n    X509_PUBKEY *pubkey;\n    /*  d=2 hl=2 l=  0 cons: cont: 00 */\n    STACK_OF(X509_ATTRIBUTE) *attributes; /* [ 0 ] */\n} X509_REQ_INFO;\n\ntypedef struct X509_req_st {\n    X509_REQ_INFO *req_info;\n    X509_ALGOR *sig_alg;\n    ASN1_BIT_STRING *signature;\n    int references;\n} X509_REQ;\n\ntypedef struct x509_cinf_st {\n    ASN1_INTEGER *version;      /* [ 0 ] default of v1 */\n    ASN1_INTEGER *serialNumber;\n    X509_ALGOR *signature;\n    X509_NAME *issuer;\n    X509_VAL *validity;\n    X509_NAME *subject;\n    X509_PUBKEY *key;\n    ASN1_BIT_STRING *issuerUID; /* [ 1 ] optional in v2 */\n    ASN1_BIT_STRING *subjectUID; /* [ 2 ] optional in v2 */\n    STACK_OF(X509_EXTENSION) *extensions; /* [ 3 ] optional in v3 */\n    ASN1_ENCODING enc;\n} X509_CINF;\n\n/*\n * This stuff is certificate \"auxiliary info\" it contains details which are\n * useful in certificate stores and databases. When used this is tagged onto\n * the end of the certificate itself\n */\n\ntypedef struct x509_cert_aux_st {\n    STACK_OF(ASN1_OBJECT) *trust; /* trusted uses */\n    STACK_OF(ASN1_OBJECT) *reject; /* rejected uses */\n    ASN1_UTF8STRING *alias;     /* \"friendly name\" */\n    ASN1_OCTET_STRING *keyid;   /* key id of private key */\n    STACK_OF(X509_ALGOR) *other; /* other unspecified info */\n} X509_CERT_AUX;\n\nstruct x509_st {\n    X509_CINF *cert_info;\n    X509_ALGOR *sig_alg;\n    ASN1_BIT_STRING *signature;\n    int valid;\n    int references;\n    char *name;\n    CRYPTO_EX_DATA ex_data;\n    /* These contain copies of various extension values */\n    long ex_pathlen;\n    long ex_pcpathlen;\n    unsigned long ex_flags;\n    unsigned long ex_kusage;\n    unsigned long ex_xkusage;\n    unsigned long ex_nscert;\n    ASN1_OCTET_STRING *skid;\n    AUTHORITY_KEYID *akid;\n    X509_POLICY_CACHE *policy_cache;\n    STACK_OF(DIST_POINT) *crldp;\n    STACK_OF(GENERAL_NAME) *altname;\n    NAME_CONSTRAINTS *nc;\n# ifndef OPENSSL_NO_RFC3779\n    STACK_OF(IPAddressFamily) *rfc3779_addr;\n    struct ASIdentifiers_st *rfc3779_asid;\n# endif\n# ifndef OPENSSL_NO_SHA\n    unsigned char sha1_hash[SHA_DIGEST_LENGTH];\n# endif\n    X509_CERT_AUX *aux;\n} /* X509 */ ;\n\nDECLARE_STACK_OF(X509)\nDECLARE_ASN1_SET_OF(X509)\n\n/* This is used for a table of trust checking functions */\n\ntypedef struct x509_trust_st {\n    int trust;\n    int flags;\n    int (*check_trust) (struct x509_trust_st *, X509 *, int);\n    char *name;\n    int arg1;\n    void *arg2;\n} X509_TRUST;\n\nDECLARE_STACK_OF(X509_TRUST)\n\ntypedef struct x509_cert_pair_st {\n    X509 *forward;\n    X509 *reverse;\n} X509_CERT_PAIR;\n\n/* standard trust ids */\n\n# define X509_TRUST_DEFAULT      -1/* Only valid in purpose settings */\n\n# define X509_TRUST_COMPAT       1\n# define X509_TRUST_SSL_CLIENT   2\n# define X509_TRUST_SSL_SERVER   3\n# define X509_TRUST_EMAIL        4\n# define X509_TRUST_OBJECT_SIGN  5\n# define X509_TRUST_OCSP_SIGN    6\n# define X509_TRUST_OCSP_REQUEST 7\n# define X509_TRUST_TSA          8\n\n/* Keep these up to date! */\n# define X509_TRUST_MIN          1\n# define X509_TRUST_MAX          8\n\n/* trust_flags values */\n# define X509_TRUST_DYNAMIC      1\n# define X509_TRUST_DYNAMIC_NAME 2\n\n/* check_trust return codes */\n\n# define X509_TRUST_TRUSTED      1\n# define X509_TRUST_REJECTED     2\n# define X509_TRUST_UNTRUSTED    3\n\n/* Flags for X509_print_ex() */\n\n# define X509_FLAG_COMPAT                0\n# define X509_FLAG_NO_HEADER             1L\n# define X509_FLAG_NO_VERSION            (1L << 1)\n# define X509_FLAG_NO_SERIAL             (1L << 2)\n# define X509_FLAG_NO_SIGNAME            (1L << 3)\n# define X509_FLAG_NO_ISSUER             (1L << 4)\n# define X509_FLAG_NO_VALIDITY           (1L << 5)\n# define X509_FLAG_NO_SUBJECT            (1L << 6)\n# define X509_FLAG_NO_PUBKEY             (1L << 7)\n# define X509_FLAG_NO_EXTENSIONS         (1L << 8)\n# define X509_FLAG_NO_SIGDUMP            (1L << 9)\n# define X509_FLAG_NO_AUX                (1L << 10)\n# define X509_FLAG_NO_ATTRIBUTES         (1L << 11)\n# define X509_FLAG_NO_IDS                (1L << 12)\n\n/* Flags specific to X509_NAME_print_ex() */\n\n/* The field separator information */\n\n# define XN_FLAG_SEP_MASK        (0xf << 16)\n\n# define XN_FLAG_COMPAT          0/* Traditional SSLeay: use old\n                                   * X509_NAME_print */\n# define XN_FLAG_SEP_COMMA_PLUS  (1 << 16)/* RFC2253 ,+ */\n# define XN_FLAG_SEP_CPLUS_SPC   (2 << 16)/* ,+ spaced: more readable */\n# define XN_FLAG_SEP_SPLUS_SPC   (3 << 16)/* ;+ spaced */\n# define XN_FLAG_SEP_MULTILINE   (4 << 16)/* One line per field */\n\n# define XN_FLAG_DN_REV          (1 << 20)/* Reverse DN order */\n\n/* How the field name is shown */\n\n# define XN_FLAG_FN_MASK         (0x3 << 21)\n\n# define XN_FLAG_FN_SN           0/* Object short name */\n# define XN_FLAG_FN_LN           (1 << 21)/* Object long name */\n# define XN_FLAG_FN_OID          (2 << 21)/* Always use OIDs */\n# define XN_FLAG_FN_NONE         (3 << 21)/* No field names */\n\n# define XN_FLAG_SPC_EQ          (1 << 23)/* Put spaces round '=' */\n\n/*\n * This determines if we dump fields we don't recognise: RFC2253 requires\n * this.\n */\n\n# define XN_FLAG_DUMP_UNKNOWN_FIELDS (1 << 24)\n\n# define XN_FLAG_FN_ALIGN        (1 << 25)/* Align field names to 20\n                                           * characters */\n\n/* Complete set of RFC2253 flags */\n\n# define XN_FLAG_RFC2253 (ASN1_STRFLGS_RFC2253 | \\\n                        XN_FLAG_SEP_COMMA_PLUS | \\\n                        XN_FLAG_DN_REV | \\\n                        XN_FLAG_FN_SN | \\\n                        XN_FLAG_DUMP_UNKNOWN_FIELDS)\n\n/* readable oneline form */\n\n# define XN_FLAG_ONELINE (ASN1_STRFLGS_RFC2253 | \\\n                        ASN1_STRFLGS_ESC_QUOTE | \\\n                        XN_FLAG_SEP_CPLUS_SPC | \\\n                        XN_FLAG_SPC_EQ | \\\n                        XN_FLAG_FN_SN)\n\n/* readable multiline form */\n\n# define XN_FLAG_MULTILINE (ASN1_STRFLGS_ESC_CTRL | \\\n                        ASN1_STRFLGS_ESC_MSB | \\\n                        XN_FLAG_SEP_MULTILINE | \\\n                        XN_FLAG_SPC_EQ | \\\n                        XN_FLAG_FN_LN | \\\n                        XN_FLAG_FN_ALIGN)\n\nstruct x509_revoked_st {\n    ASN1_INTEGER *serialNumber;\n    ASN1_TIME *revocationDate;\n    STACK_OF(X509_EXTENSION) /* optional */ *extensions;\n    /* Set up if indirect CRL */\n    STACK_OF(GENERAL_NAME) *issuer;\n    /* Revocation reason */\n    int reason;\n    int sequence;               /* load sequence */\n};\n\nDECLARE_STACK_OF(X509_REVOKED)\nDECLARE_ASN1_SET_OF(X509_REVOKED)\n\ntypedef struct X509_crl_info_st {\n    ASN1_INTEGER *version;\n    X509_ALGOR *sig_alg;\n    X509_NAME *issuer;\n    ASN1_TIME *lastUpdate;\n    ASN1_TIME *nextUpdate;\n    STACK_OF(X509_REVOKED) *revoked;\n    STACK_OF(X509_EXTENSION) /* [0] */ *extensions;\n    ASN1_ENCODING enc;\n} X509_CRL_INFO;\n\nstruct X509_crl_st {\n    /* actual signature */\n    X509_CRL_INFO *crl;\n    X509_ALGOR *sig_alg;\n    ASN1_BIT_STRING *signature;\n    int references;\n    int flags;\n    /* Copies of various extensions */\n    AUTHORITY_KEYID *akid;\n    ISSUING_DIST_POINT *idp;\n    /* Convenient breakdown of IDP */\n    int idp_flags;\n    int idp_reasons;\n    /* CRL and base CRL numbers for delta processing */\n    ASN1_INTEGER *crl_number;\n    ASN1_INTEGER *base_crl_number;\n# ifndef OPENSSL_NO_SHA\n    unsigned char sha1_hash[SHA_DIGEST_LENGTH];\n# endif\n    STACK_OF(GENERAL_NAMES) *issuers;\n    const X509_CRL_METHOD *meth;\n    void *meth_data;\n} /* X509_CRL */ ;\n\nDECLARE_STACK_OF(X509_CRL)\nDECLARE_ASN1_SET_OF(X509_CRL)\n\ntypedef struct private_key_st {\n    int version;\n    /* The PKCS#8 data types */\n    X509_ALGOR *enc_algor;\n    ASN1_OCTET_STRING *enc_pkey; /* encrypted pub key */\n    /* When decrypted, the following will not be NULL */\n    EVP_PKEY *dec_pkey;\n    /* used to encrypt and decrypt */\n    int key_length;\n    char *key_data;\n    int key_free;               /* true if we should auto free key_data */\n    /* expanded version of 'enc_algor' */\n    EVP_CIPHER_INFO cipher;\n    int references;\n} X509_PKEY;\n\n# ifndef OPENSSL_NO_EVP\ntypedef struct X509_info_st {\n    X509 *x509;\n    X509_CRL *crl;\n    X509_PKEY *x_pkey;\n    EVP_CIPHER_INFO enc_cipher;\n    int enc_len;\n    char *enc_data;\n    int references;\n} X509_INFO;\n\nDECLARE_STACK_OF(X509_INFO)\n# endif\n\n/*\n * The next 2 structures and their 8 routines were sent to me by Pat Richard\n * <patr@x509.com> and are used to manipulate Netscapes spki structures -\n * useful if you are writing a CA web page\n */\ntypedef struct Netscape_spkac_st {\n    X509_PUBKEY *pubkey;\n    ASN1_IA5STRING *challenge;  /* challenge sent in atlas >= PR2 */\n} NETSCAPE_SPKAC;\n\ntypedef struct Netscape_spki_st {\n    NETSCAPE_SPKAC *spkac;      /* signed public key and challenge */\n    X509_ALGOR *sig_algor;\n    ASN1_BIT_STRING *signature;\n} NETSCAPE_SPKI;\n\n/* Netscape certificate sequence structure */\ntypedef struct Netscape_certificate_sequence {\n    ASN1_OBJECT *type;\n    STACK_OF(X509) *certs;\n} NETSCAPE_CERT_SEQUENCE;\n\n/*- Unused (and iv length is wrong)\ntypedef struct CBCParameter_st\n        {\n        unsigned char iv[8];\n        } CBC_PARAM;\n*/\n\n/* Password based encryption structure */\n\ntypedef struct PBEPARAM_st {\n    ASN1_OCTET_STRING *salt;\n    ASN1_INTEGER *iter;\n} PBEPARAM;\n\n/* Password based encryption V2 structures */\n\ntypedef struct PBE2PARAM_st {\n    X509_ALGOR *keyfunc;\n    X509_ALGOR *encryption;\n} PBE2PARAM;\n\ntypedef struct PBKDF2PARAM_st {\n/* Usually OCTET STRING but could be anything */\n    ASN1_TYPE *salt;\n    ASN1_INTEGER *iter;\n    ASN1_INTEGER *keylength;\n    X509_ALGOR *prf;\n} PBKDF2PARAM;\n\n/* PKCS#8 private key info structure */\n\nstruct pkcs8_priv_key_info_st {\n    /* Flag for various broken formats */\n    int broken;\n# define PKCS8_OK                0\n# define PKCS8_NO_OCTET          1\n# define PKCS8_EMBEDDED_PARAM    2\n# define PKCS8_NS_DB             3\n# define PKCS8_NEG_PRIVKEY       4\n    ASN1_INTEGER *version;\n    X509_ALGOR *pkeyalg;\n    /* Should be OCTET STRING but some are broken */\n    ASN1_TYPE *pkey;\n    STACK_OF(X509_ATTRIBUTE) *attributes;\n};\n\n#ifdef  __cplusplus\n}\n#endif\n\n# include <openssl/x509_vfy.h>\n# include <openssl/pkcs7.h>\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n# define X509_EXT_PACK_UNKNOWN   1\n# define X509_EXT_PACK_STRING    2\n\n# define         X509_get_version(x) ASN1_INTEGER_get((x)->cert_info->version)\n/* #define      X509_get_serialNumber(x) ((x)->cert_info->serialNumber) */\n# define         X509_get_notBefore(x) ((x)->cert_info->validity->notBefore)\n# define         X509_get_notAfter(x) ((x)->cert_info->validity->notAfter)\n# define         X509_extract_key(x)     X509_get_pubkey(x)/*****/\n# define         X509_REQ_get_version(x) ASN1_INTEGER_get((x)->req_info->version)\n# define         X509_REQ_get_subject_name(x) ((x)->req_info->subject)\n# define         X509_REQ_extract_key(a) X509_REQ_get_pubkey(a)\n# define         X509_name_cmp(a,b)      X509_NAME_cmp((a),(b))\n# define         X509_get_signature_type(x) EVP_PKEY_type(OBJ_obj2nid((x)->sig_alg->algorithm))\n\n# define         X509_CRL_get_version(x) ASN1_INTEGER_get((x)->crl->version)\n# define         X509_CRL_get_lastUpdate(x) ((x)->crl->lastUpdate)\n# define         X509_CRL_get_nextUpdate(x) ((x)->crl->nextUpdate)\n# define         X509_CRL_get_issuer(x) ((x)->crl->issuer)\n# define         X509_CRL_get_REVOKED(x) ((x)->crl->revoked)\n\nvoid X509_CRL_set_default_method(const X509_CRL_METHOD *meth);\nX509_CRL_METHOD *X509_CRL_METHOD_new(int (*crl_init) (X509_CRL *crl),\n                                     int (*crl_free) (X509_CRL *crl),\n                                     int (*crl_lookup) (X509_CRL *crl,\n                                                        X509_REVOKED **ret,\n                                                        ASN1_INTEGER *ser,\n                                                        X509_NAME *issuer),\n                                     int (*crl_verify) (X509_CRL *crl,\n                                                        EVP_PKEY *pk));\nvoid X509_CRL_METHOD_free(X509_CRL_METHOD *m);\n\nvoid X509_CRL_set_meth_data(X509_CRL *crl, void *dat);\nvoid *X509_CRL_get_meth_data(X509_CRL *crl);\n\n/*\n * This one is only used so that a binary form can output, as in\n * i2d_X509_NAME(X509_get_X509_PUBKEY(x),&buf)\n */\n# define         X509_get_X509_PUBKEY(x) ((x)->cert_info->key)\n\nconst char *X509_verify_cert_error_string(long n);\n\n# ifndef OPENSSL_NO_EVP\nint X509_verify(X509 *a, EVP_PKEY *r);\n\nint X509_REQ_verify(X509_REQ *a, EVP_PKEY *r);\nint X509_CRL_verify(X509_CRL *a, EVP_PKEY *r);\nint NETSCAPE_SPKI_verify(NETSCAPE_SPKI *a, EVP_PKEY *r);\n\nNETSCAPE_SPKI *NETSCAPE_SPKI_b64_decode(const char *str, int len);\nchar *NETSCAPE_SPKI_b64_encode(NETSCAPE_SPKI *x);\nEVP_PKEY *NETSCAPE_SPKI_get_pubkey(NETSCAPE_SPKI *x);\nint NETSCAPE_SPKI_set_pubkey(NETSCAPE_SPKI *x, EVP_PKEY *pkey);\n\nint NETSCAPE_SPKI_print(BIO *out, NETSCAPE_SPKI *spki);\n\nint X509_signature_dump(BIO *bp, const ASN1_STRING *sig, int indent);\nint X509_signature_print(BIO *bp, X509_ALGOR *alg, ASN1_STRING *sig);\n\nint X509_sign(X509 *x, EVP_PKEY *pkey, const EVP_MD *md);\nint X509_sign_ctx(X509 *x, EVP_MD_CTX *ctx);\nint X509_http_nbio(OCSP_REQ_CTX *rctx, X509 **pcert);\nint X509_REQ_sign(X509_REQ *x, EVP_PKEY *pkey, const EVP_MD *md);\nint X509_REQ_sign_ctx(X509_REQ *x, EVP_MD_CTX *ctx);\nint X509_CRL_sign(X509_CRL *x, EVP_PKEY *pkey, const EVP_MD *md);\nint X509_CRL_sign_ctx(X509_CRL *x, EVP_MD_CTX *ctx);\nint X509_CRL_http_nbio(OCSP_REQ_CTX *rctx, X509_CRL **pcrl);\nint NETSCAPE_SPKI_sign(NETSCAPE_SPKI *x, EVP_PKEY *pkey, const EVP_MD *md);\n\nint X509_pubkey_digest(const X509 *data, const EVP_MD *type,\n                       unsigned char *md, unsigned int *len);\nint X509_digest(const X509 *data, const EVP_MD *type,\n                unsigned char *md, unsigned int *len);\nint X509_CRL_digest(const X509_CRL *data, const EVP_MD *type,\n                    unsigned char *md, unsigned int *len);\nint X509_REQ_digest(const X509_REQ *data, const EVP_MD *type,\n                    unsigned char *md, unsigned int *len);\nint X509_NAME_digest(const X509_NAME *data, const EVP_MD *type,\n                     unsigned char *md, unsigned int *len);\n# endif\n\n# ifndef OPENSSL_NO_FP_API\nX509 *d2i_X509_fp(FILE *fp, X509 **x509);\nint i2d_X509_fp(FILE *fp, X509 *x509);\nX509_CRL *d2i_X509_CRL_fp(FILE *fp, X509_CRL **crl);\nint i2d_X509_CRL_fp(FILE *fp, X509_CRL *crl);\nX509_REQ *d2i_X509_REQ_fp(FILE *fp, X509_REQ **req);\nint i2d_X509_REQ_fp(FILE *fp, X509_REQ *req);\n#  ifndef OPENSSL_NO_RSA\nRSA *d2i_RSAPrivateKey_fp(FILE *fp, RSA **rsa);\nint i2d_RSAPrivateKey_fp(FILE *fp, RSA *rsa);\nRSA *d2i_RSAPublicKey_fp(FILE *fp, RSA **rsa);\nint i2d_RSAPublicKey_fp(FILE *fp, RSA *rsa);\nRSA *d2i_RSA_PUBKEY_fp(FILE *fp, RSA **rsa);\nint i2d_RSA_PUBKEY_fp(FILE *fp, RSA *rsa);\n#  endif\n#  ifndef OPENSSL_NO_DSA\nDSA *d2i_DSA_PUBKEY_fp(FILE *fp, DSA **dsa);\nint i2d_DSA_PUBKEY_fp(FILE *fp, DSA *dsa);\nDSA *d2i_DSAPrivateKey_fp(FILE *fp, DSA **dsa);\nint i2d_DSAPrivateKey_fp(FILE *fp, DSA *dsa);\n#  endif\n#  ifndef OPENSSL_NO_EC\nEC_KEY *d2i_EC_PUBKEY_fp(FILE *fp, EC_KEY **eckey);\nint i2d_EC_PUBKEY_fp(FILE *fp, EC_KEY *eckey);\nEC_KEY *d2i_ECPrivateKey_fp(FILE *fp, EC_KEY **eckey);\nint i2d_ECPrivateKey_fp(FILE *fp, EC_KEY *eckey);\n#  endif\nX509_SIG *d2i_PKCS8_fp(FILE *fp, X509_SIG **p8);\nint i2d_PKCS8_fp(FILE *fp, X509_SIG *p8);\nPKCS8_PRIV_KEY_INFO *d2i_PKCS8_PRIV_KEY_INFO_fp(FILE *fp,\n                                                PKCS8_PRIV_KEY_INFO **p8inf);\nint i2d_PKCS8_PRIV_KEY_INFO_fp(FILE *fp, PKCS8_PRIV_KEY_INFO *p8inf);\nint i2d_PKCS8PrivateKeyInfo_fp(FILE *fp, EVP_PKEY *key);\nint i2d_PrivateKey_fp(FILE *fp, EVP_PKEY *pkey);\nEVP_PKEY *d2i_PrivateKey_fp(FILE *fp, EVP_PKEY **a);\nint i2d_PUBKEY_fp(FILE *fp, EVP_PKEY *pkey);\nEVP_PKEY *d2i_PUBKEY_fp(FILE *fp, EVP_PKEY **a);\n# endif\n\n# ifndef OPENSSL_NO_BIO\nX509 *d2i_X509_bio(BIO *bp, X509 **x509);\nint i2d_X509_bio(BIO *bp, X509 *x509);\nX509_CRL *d2i_X509_CRL_bio(BIO *bp, X509_CRL **crl);\nint i2d_X509_CRL_bio(BIO *bp, X509_CRL *crl);\nX509_REQ *d2i_X509_REQ_bio(BIO *bp, X509_REQ **req);\nint i2d_X509_REQ_bio(BIO *bp, X509_REQ *req);\n#  ifndef OPENSSL_NO_RSA\nRSA *d2i_RSAPrivateKey_bio(BIO *bp, RSA **rsa);\nint i2d_RSAPrivateKey_bio(BIO *bp, RSA *rsa);\nRSA *d2i_RSAPublicKey_bio(BIO *bp, RSA **rsa);\nint i2d_RSAPublicKey_bio(BIO *bp, RSA *rsa);\nRSA *d2i_RSA_PUBKEY_bio(BIO *bp, RSA **rsa);\nint i2d_RSA_PUBKEY_bio(BIO *bp, RSA *rsa);\n#  endif\n#  ifndef OPENSSL_NO_DSA\nDSA *d2i_DSA_PUBKEY_bio(BIO *bp, DSA **dsa);\nint i2d_DSA_PUBKEY_bio(BIO *bp, DSA *dsa);\nDSA *d2i_DSAPrivateKey_bio(BIO *bp, DSA **dsa);\nint i2d_DSAPrivateKey_bio(BIO *bp, DSA *dsa);\n#  endif\n#  ifndef OPENSSL_NO_EC\nEC_KEY *d2i_EC_PUBKEY_bio(BIO *bp, EC_KEY **eckey);\nint i2d_EC_PUBKEY_bio(BIO *bp, EC_KEY *eckey);\nEC_KEY *d2i_ECPrivateKey_bio(BIO *bp, EC_KEY **eckey);\nint i2d_ECPrivateKey_bio(BIO *bp, EC_KEY *eckey);\n#  endif\nX509_SIG *d2i_PKCS8_bio(BIO *bp, X509_SIG **p8);\nint i2d_PKCS8_bio(BIO *bp, X509_SIG *p8);\nPKCS8_PRIV_KEY_INFO *d2i_PKCS8_PRIV_KEY_INFO_bio(BIO *bp,\n                                                 PKCS8_PRIV_KEY_INFO **p8inf);\nint i2d_PKCS8_PRIV_KEY_INFO_bio(BIO *bp, PKCS8_PRIV_KEY_INFO *p8inf);\nint i2d_PKCS8PrivateKeyInfo_bio(BIO *bp, EVP_PKEY *key);\nint i2d_PrivateKey_bio(BIO *bp, EVP_PKEY *pkey);\nEVP_PKEY *d2i_PrivateKey_bio(BIO *bp, EVP_PKEY **a);\nint i2d_PUBKEY_bio(BIO *bp, EVP_PKEY *pkey);\nEVP_PKEY *d2i_PUBKEY_bio(BIO *bp, EVP_PKEY **a);\n# endif\n\nX509 *X509_dup(X509 *x509);\nX509_ATTRIBUTE *X509_ATTRIBUTE_dup(X509_ATTRIBUTE *xa);\nX509_EXTENSION *X509_EXTENSION_dup(X509_EXTENSION *ex);\nX509_CRL *X509_CRL_dup(X509_CRL *crl);\nX509_REVOKED *X509_REVOKED_dup(X509_REVOKED *rev);\nX509_REQ *X509_REQ_dup(X509_REQ *req);\nX509_ALGOR *X509_ALGOR_dup(X509_ALGOR *xn);\nint X509_ALGOR_set0(X509_ALGOR *alg, ASN1_OBJECT *aobj, int ptype,\n                    void *pval);\nvoid X509_ALGOR_get0(ASN1_OBJECT **paobj, int *pptype, void **ppval,\n                     X509_ALGOR *algor);\nvoid X509_ALGOR_set_md(X509_ALGOR *alg, const EVP_MD *md);\nint X509_ALGOR_cmp(const X509_ALGOR *a, const X509_ALGOR *b);\n\nX509_NAME *X509_NAME_dup(X509_NAME *xn);\nX509_NAME_ENTRY *X509_NAME_ENTRY_dup(X509_NAME_ENTRY *ne);\n\nint X509_cmp_time(const ASN1_TIME *s, time_t *t);\nint X509_cmp_current_time(const ASN1_TIME *s);\nASN1_TIME *X509_time_adj(ASN1_TIME *s, long adj, time_t *t);\nASN1_TIME *X509_time_adj_ex(ASN1_TIME *s,\n                            int offset_day, long offset_sec, time_t *t);\nASN1_TIME *X509_gmtime_adj(ASN1_TIME *s, long adj);\n\nconst char *X509_get_default_cert_area(void);\nconst char *X509_get_default_cert_dir(void);\nconst char *X509_get_default_cert_file(void);\nconst char *X509_get_default_cert_dir_env(void);\nconst char *X509_get_default_cert_file_env(void);\nconst char *X509_get_default_private_dir(void);\n\nX509_REQ *X509_to_X509_REQ(X509 *x, EVP_PKEY *pkey, const EVP_MD *md);\nX509 *X509_REQ_to_X509(X509_REQ *r, int days, EVP_PKEY *pkey);\n\nDECLARE_ASN1_FUNCTIONS(X509_ALGOR)\nDECLARE_ASN1_ENCODE_FUNCTIONS(X509_ALGORS, X509_ALGORS, X509_ALGORS)\nDECLARE_ASN1_FUNCTIONS(X509_VAL)\n\nDECLARE_ASN1_FUNCTIONS(X509_PUBKEY)\n\nint X509_PUBKEY_set(X509_PUBKEY **x, EVP_PKEY *pkey);\nEVP_PKEY *X509_PUBKEY_get(X509_PUBKEY *key);\nint X509_get_pubkey_parameters(EVP_PKEY *pkey, STACK_OF(X509) *chain);\nint i2d_PUBKEY(EVP_PKEY *a, unsigned char **pp);\nEVP_PKEY *d2i_PUBKEY(EVP_PKEY **a, const unsigned char **pp, long length);\n# ifndef OPENSSL_NO_RSA\nint i2d_RSA_PUBKEY(RSA *a, unsigned char **pp);\nRSA *d2i_RSA_PUBKEY(RSA **a, const unsigned char **pp, long length);\n# endif\n# ifndef OPENSSL_NO_DSA\nint i2d_DSA_PUBKEY(DSA *a, unsigned char **pp);\nDSA *d2i_DSA_PUBKEY(DSA **a, const unsigned char **pp, long length);\n# endif\n# ifndef OPENSSL_NO_EC\nint i2d_EC_PUBKEY(EC_KEY *a, unsigned char **pp);\nEC_KEY *d2i_EC_PUBKEY(EC_KEY **a, const unsigned char **pp, long length);\n# endif\n\nDECLARE_ASN1_FUNCTIONS(X509_SIG)\nDECLARE_ASN1_FUNCTIONS(X509_REQ_INFO)\nDECLARE_ASN1_FUNCTIONS(X509_REQ)\n\nDECLARE_ASN1_FUNCTIONS(X509_ATTRIBUTE)\nX509_ATTRIBUTE *X509_ATTRIBUTE_create(int nid, int atrtype, void *value);\n\nDECLARE_ASN1_FUNCTIONS(X509_EXTENSION)\nDECLARE_ASN1_ENCODE_FUNCTIONS(X509_EXTENSIONS, X509_EXTENSIONS, X509_EXTENSIONS)\n\nDECLARE_ASN1_FUNCTIONS(X509_NAME_ENTRY)\n\nDECLARE_ASN1_FUNCTIONS(X509_NAME)\n\nint X509_NAME_set(X509_NAME **xn, X509_NAME *name);\n\nDECLARE_ASN1_FUNCTIONS(X509_CINF)\n\nDECLARE_ASN1_FUNCTIONS(X509)\nDECLARE_ASN1_FUNCTIONS(X509_CERT_AUX)\n\nDECLARE_ASN1_FUNCTIONS(X509_CERT_PAIR)\n\nint X509_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func,\n                          CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func);\nint X509_set_ex_data(X509 *r, int idx, void *arg);\nvoid *X509_get_ex_data(X509 *r, int idx);\nint i2d_X509_AUX(X509 *a, unsigned char **pp);\nX509 *d2i_X509_AUX(X509 **a, const unsigned char **pp, long length);\n\nint i2d_re_X509_tbs(X509 *x, unsigned char **pp);\n\nvoid X509_get0_signature(ASN1_BIT_STRING **psig, X509_ALGOR **palg,\n                         const X509 *x);\nint X509_get_signature_nid(const X509 *x);\n\nint X509_alias_set1(X509 *x, unsigned char *name, int len);\nint X509_keyid_set1(X509 *x, unsigned char *id, int len);\nunsigned char *X509_alias_get0(X509 *x, int *len);\nunsigned char *X509_keyid_get0(X509 *x, int *len);\nint (*X509_TRUST_set_default(int (*trust) (int, X509 *, int))) (int, X509 *,\n                                                                int);\nint X509_TRUST_set(int *t, int trust);\nint X509_add1_trust_object(X509 *x, ASN1_OBJECT *obj);\nint X509_add1_reject_object(X509 *x, ASN1_OBJECT *obj);\nvoid X509_trust_clear(X509 *x);\nvoid X509_reject_clear(X509 *x);\n\nDECLARE_ASN1_FUNCTIONS(X509_REVOKED)\nDECLARE_ASN1_FUNCTIONS(X509_CRL_INFO)\nDECLARE_ASN1_FUNCTIONS(X509_CRL)\n\nint X509_CRL_add0_revoked(X509_CRL *crl, X509_REVOKED *rev);\nint X509_CRL_get0_by_serial(X509_CRL *crl,\n                            X509_REVOKED **ret, ASN1_INTEGER *serial);\nint X509_CRL_get0_by_cert(X509_CRL *crl, X509_REVOKED **ret, X509 *x);\n\nX509_PKEY *X509_PKEY_new(void);\nvoid X509_PKEY_free(X509_PKEY *a);\nint i2d_X509_PKEY(X509_PKEY *a, unsigned char **pp);\nX509_PKEY *d2i_X509_PKEY(X509_PKEY **a, const unsigned char **pp,\n                         long length);\n\nDECLARE_ASN1_FUNCTIONS(NETSCAPE_SPKI)\nDECLARE_ASN1_FUNCTIONS(NETSCAPE_SPKAC)\nDECLARE_ASN1_FUNCTIONS(NETSCAPE_CERT_SEQUENCE)\n\n# ifndef OPENSSL_NO_EVP\nX509_INFO *X509_INFO_new(void);\nvoid X509_INFO_free(X509_INFO *a);\nchar *X509_NAME_oneline(X509_NAME *a, char *buf, int size);\n\nint ASN1_verify(i2d_of_void *i2d, X509_ALGOR *algor1,\n                ASN1_BIT_STRING *signature, char *data, EVP_PKEY *pkey);\n\nint ASN1_digest(i2d_of_void *i2d, const EVP_MD *type, char *data,\n                unsigned char *md, unsigned int *len);\n\nint ASN1_sign(i2d_of_void *i2d, X509_ALGOR *algor1,\n              X509_ALGOR *algor2, ASN1_BIT_STRING *signature,\n              char *data, EVP_PKEY *pkey, const EVP_MD *type);\n\nint ASN1_item_digest(const ASN1_ITEM *it, const EVP_MD *type, void *data,\n                     unsigned char *md, unsigned int *len);\n\nint ASN1_item_verify(const ASN1_ITEM *it, X509_ALGOR *algor1,\n                     ASN1_BIT_STRING *signature, void *data, EVP_PKEY *pkey);\n\nint ASN1_item_sign(const ASN1_ITEM *it, X509_ALGOR *algor1,\n                   X509_ALGOR *algor2, ASN1_BIT_STRING *signature, void *data,\n                   EVP_PKEY *pkey, const EVP_MD *type);\nint ASN1_item_sign_ctx(const ASN1_ITEM *it, X509_ALGOR *algor1,\n                       X509_ALGOR *algor2, ASN1_BIT_STRING *signature,\n                       void *asn, EVP_MD_CTX *ctx);\n# endif\n\nint X509_set_version(X509 *x, long version);\nint X509_set_serialNumber(X509 *x, ASN1_INTEGER *serial);\nASN1_INTEGER *X509_get_serialNumber(X509 *x);\nint X509_set_issuer_name(X509 *x, X509_NAME *name);\nX509_NAME *X509_get_issuer_name(X509 *a);\nint X509_set_subject_name(X509 *x, X509_NAME *name);\nX509_NAME *X509_get_subject_name(X509 *a);\nint X509_set_notBefore(X509 *x, const ASN1_TIME *tm);\nint X509_set_notAfter(X509 *x, const ASN1_TIME *tm);\nint X509_set_pubkey(X509 *x, EVP_PKEY *pkey);\nEVP_PKEY *X509_get_pubkey(X509 *x);\nASN1_BIT_STRING *X509_get0_pubkey_bitstr(const X509 *x);\nint X509_certificate_type(X509 *x, EVP_PKEY *pubkey /* optional */ );\n\nint X509_REQ_set_version(X509_REQ *x, long version);\nint X509_REQ_set_subject_name(X509_REQ *req, X509_NAME *name);\nint X509_REQ_set_pubkey(X509_REQ *x, EVP_PKEY *pkey);\nEVP_PKEY *X509_REQ_get_pubkey(X509_REQ *req);\nint X509_REQ_extension_nid(int nid);\nint *X509_REQ_get_extension_nids(void);\nvoid X509_REQ_set_extension_nids(int *nids);\nSTACK_OF(X509_EXTENSION) *X509_REQ_get_extensions(X509_REQ *req);\nint X509_REQ_add_extensions_nid(X509_REQ *req, STACK_OF(X509_EXTENSION) *exts,\n                                int nid);\nint X509_REQ_add_extensions(X509_REQ *req, STACK_OF(X509_EXTENSION) *exts);\nint X509_REQ_get_attr_count(const X509_REQ *req);\nint X509_REQ_get_attr_by_NID(const X509_REQ *req, int nid, int lastpos);\nint X509_REQ_get_attr_by_OBJ(const X509_REQ *req, ASN1_OBJECT *obj,\n                             int lastpos);\nX509_ATTRIBUTE *X509_REQ_get_attr(const X509_REQ *req, int loc);\nX509_ATTRIBUTE *X509_REQ_delete_attr(X509_REQ *req, int loc);\nint X509_REQ_add1_attr(X509_REQ *req, X509_ATTRIBUTE *attr);\nint X509_REQ_add1_attr_by_OBJ(X509_REQ *req,\n                              const ASN1_OBJECT *obj, int type,\n                              const unsigned char *bytes, int len);\nint X509_REQ_add1_attr_by_NID(X509_REQ *req,\n                              int nid, int type,\n                              const unsigned char *bytes, int len);\nint X509_REQ_add1_attr_by_txt(X509_REQ *req,\n                              const char *attrname, int type,\n                              const unsigned char *bytes, int len);\n\nint X509_CRL_set_version(X509_CRL *x, long version);\nint X509_CRL_set_issuer_name(X509_CRL *x, X509_NAME *name);\nint X509_CRL_set_lastUpdate(X509_CRL *x, const ASN1_TIME *tm);\nint X509_CRL_set_nextUpdate(X509_CRL *x, const ASN1_TIME *tm);\nint X509_CRL_sort(X509_CRL *crl);\n\nint X509_REVOKED_set_serialNumber(X509_REVOKED *x, ASN1_INTEGER *serial);\nint X509_REVOKED_set_revocationDate(X509_REVOKED *r, ASN1_TIME *tm);\n\nX509_CRL *X509_CRL_diff(X509_CRL *base, X509_CRL *newer,\n                        EVP_PKEY *skey, const EVP_MD *md, unsigned int flags);\n\nint X509_REQ_check_private_key(X509_REQ *x509, EVP_PKEY *pkey);\n\nint X509_check_private_key(X509 *x509, EVP_PKEY *pkey);\nint X509_chain_check_suiteb(int *perror_depth,\n                            X509 *x, STACK_OF(X509) *chain,\n                            unsigned long flags);\nint X509_CRL_check_suiteb(X509_CRL *crl, EVP_PKEY *pk, unsigned long flags);\nSTACK_OF(X509) *X509_chain_up_ref(STACK_OF(X509) *chain);\n\nint X509_issuer_and_serial_cmp(const X509 *a, const X509 *b);\nunsigned long X509_issuer_and_serial_hash(X509 *a);\n\nint X509_issuer_name_cmp(const X509 *a, const X509 *b);\nunsigned long X509_issuer_name_hash(X509 *a);\n\nint X509_subject_name_cmp(const X509 *a, const X509 *b);\nunsigned long X509_subject_name_hash(X509 *x);\n\n# ifndef OPENSSL_NO_MD5\nunsigned long X509_issuer_name_hash_old(X509 *a);\nunsigned long X509_subject_name_hash_old(X509 *x);\n# endif\n\nint X509_cmp(const X509 *a, const X509 *b);\nint X509_NAME_cmp(const X509_NAME *a, const X509_NAME *b);\nunsigned long X509_NAME_hash(X509_NAME *x);\nunsigned long X509_NAME_hash_old(X509_NAME *x);\n\nint X509_CRL_cmp(const X509_CRL *a, const X509_CRL *b);\nint X509_CRL_match(const X509_CRL *a, const X509_CRL *b);\n# ifndef OPENSSL_NO_FP_API\nint X509_print_ex_fp(FILE *bp, X509 *x, unsigned long nmflag,\n                     unsigned long cflag);\nint X509_print_fp(FILE *bp, X509 *x);\nint X509_CRL_print_fp(FILE *bp, X509_CRL *x);\nint X509_REQ_print_fp(FILE *bp, X509_REQ *req);\nint X509_NAME_print_ex_fp(FILE *fp, X509_NAME *nm, int indent,\n                          unsigned long flags);\n# endif\n\n# ifndef OPENSSL_NO_BIO\nint X509_NAME_print(BIO *bp, X509_NAME *name, int obase);\nint X509_NAME_print_ex(BIO *out, X509_NAME *nm, int indent,\n                       unsigned long flags);\nint X509_print_ex(BIO *bp, X509 *x, unsigned long nmflag,\n                  unsigned long cflag);\nint X509_print(BIO *bp, X509 *x);\nint X509_ocspid_print(BIO *bp, X509 *x);\nint X509_CERT_AUX_print(BIO *bp, X509_CERT_AUX *x, int indent);\nint X509_CRL_print(BIO *bp, X509_CRL *x);\nint X509_REQ_print_ex(BIO *bp, X509_REQ *x, unsigned long nmflag,\n                      unsigned long cflag);\nint X509_REQ_print(BIO *bp, X509_REQ *req);\n# endif\n\nint X509_NAME_entry_count(X509_NAME *name);\nint X509_NAME_get_text_by_NID(X509_NAME *name, int nid, char *buf, int len);\nint X509_NAME_get_text_by_OBJ(X509_NAME *name, ASN1_OBJECT *obj,\n                              char *buf, int len);\n\n/*\n * NOTE: you should be passsing -1, not 0 as lastpos.  The functions that use\n * lastpos, search after that position on.\n */\nint X509_NAME_get_index_by_NID(X509_NAME *name, int nid, int lastpos);\nint X509_NAME_get_index_by_OBJ(X509_NAME *name, ASN1_OBJECT *obj,\n                               int lastpos);\nX509_NAME_ENTRY *X509_NAME_get_entry(X509_NAME *name, int loc);\nX509_NAME_ENTRY *X509_NAME_delete_entry(X509_NAME *name, int loc);\nint X509_NAME_add_entry(X509_NAME *name, X509_NAME_ENTRY *ne,\n                        int loc, int set);\nint X509_NAME_add_entry_by_OBJ(X509_NAME *name, ASN1_OBJECT *obj, int type,\n                               unsigned char *bytes, int len, int loc,\n                               int set);\nint X509_NAME_add_entry_by_NID(X509_NAME *name, int nid, int type,\n                               unsigned char *bytes, int len, int loc,\n                               int set);\nX509_NAME_ENTRY *X509_NAME_ENTRY_create_by_txt(X509_NAME_ENTRY **ne,\n                                               const char *field, int type,\n                                               const unsigned char *bytes,\n                                               int len);\nX509_NAME_ENTRY *X509_NAME_ENTRY_create_by_NID(X509_NAME_ENTRY **ne, int nid,\n                                               int type, unsigned char *bytes,\n                                               int len);\nint X509_NAME_add_entry_by_txt(X509_NAME *name, const char *field, int type,\n                               const unsigned char *bytes, int len, int loc,\n                               int set);\nX509_NAME_ENTRY *X509_NAME_ENTRY_create_by_OBJ(X509_NAME_ENTRY **ne,\n                                               ASN1_OBJECT *obj, int type,\n                                               const unsigned char *bytes,\n                                               int len);\nint X509_NAME_ENTRY_set_object(X509_NAME_ENTRY *ne, ASN1_OBJECT *obj);\nint X509_NAME_ENTRY_set_data(X509_NAME_ENTRY *ne, int type,\n                             const unsigned char *bytes, int len);\nASN1_OBJECT *X509_NAME_ENTRY_get_object(X509_NAME_ENTRY *ne);\nASN1_STRING *X509_NAME_ENTRY_get_data(X509_NAME_ENTRY *ne);\n\nint X509v3_get_ext_count(const STACK_OF(X509_EXTENSION) *x);\nint X509v3_get_ext_by_NID(const STACK_OF(X509_EXTENSION) *x,\n                          int nid, int lastpos);\nint X509v3_get_ext_by_OBJ(const STACK_OF(X509_EXTENSION) *x,\n                          ASN1_OBJECT *obj, int lastpos);\nint X509v3_get_ext_by_critical(const STACK_OF(X509_EXTENSION) *x,\n                               int crit, int lastpos);\nX509_EXTENSION *X509v3_get_ext(const STACK_OF(X509_EXTENSION) *x, int loc);\nX509_EXTENSION *X509v3_delete_ext(STACK_OF(X509_EXTENSION) *x, int loc);\nSTACK_OF(X509_EXTENSION) *X509v3_add_ext(STACK_OF(X509_EXTENSION) **x,\n                                         X509_EXTENSION *ex, int loc);\n\nint X509_get_ext_count(X509 *x);\nint X509_get_ext_by_NID(X509 *x, int nid, int lastpos);\nint X509_get_ext_by_OBJ(X509 *x, ASN1_OBJECT *obj, int lastpos);\nint X509_get_ext_by_critical(X509 *x, int crit, int lastpos);\nX509_EXTENSION *X509_get_ext(X509 *x, int loc);\nX509_EXTENSION *X509_delete_ext(X509 *x, int loc);\nint X509_add_ext(X509 *x, X509_EXTENSION *ex, int loc);\nvoid *X509_get_ext_d2i(X509 *x, int nid, int *crit, int *idx);\nint X509_add1_ext_i2d(X509 *x, int nid, void *value, int crit,\n                      unsigned long flags);\n\nint X509_CRL_get_ext_count(X509_CRL *x);\nint X509_CRL_get_ext_by_NID(X509_CRL *x, int nid, int lastpos);\nint X509_CRL_get_ext_by_OBJ(X509_CRL *x, ASN1_OBJECT *obj, int lastpos);\nint X509_CRL_get_ext_by_critical(X509_CRL *x, int crit, int lastpos);\nX509_EXTENSION *X509_CRL_get_ext(X509_CRL *x, int loc);\nX509_EXTENSION *X509_CRL_delete_ext(X509_CRL *x, int loc);\nint X509_CRL_add_ext(X509_CRL *x, X509_EXTENSION *ex, int loc);\nvoid *X509_CRL_get_ext_d2i(X509_CRL *x, int nid, int *crit, int *idx);\nint X509_CRL_add1_ext_i2d(X509_CRL *x, int nid, void *value, int crit,\n                          unsigned long flags);\n\nint X509_REVOKED_get_ext_count(X509_REVOKED *x);\nint X509_REVOKED_get_ext_by_NID(X509_REVOKED *x, int nid, int lastpos);\nint X509_REVOKED_get_ext_by_OBJ(X509_REVOKED *x, ASN1_OBJECT *obj,\n                                int lastpos);\nint X509_REVOKED_get_ext_by_critical(X509_REVOKED *x, int crit, int lastpos);\nX509_EXTENSION *X509_REVOKED_get_ext(X509_REVOKED *x, int loc);\nX509_EXTENSION *X509_REVOKED_delete_ext(X509_REVOKED *x, int loc);\nint X509_REVOKED_add_ext(X509_REVOKED *x, X509_EXTENSION *ex, int loc);\nvoid *X509_REVOKED_get_ext_d2i(X509_REVOKED *x, int nid, int *crit, int *idx);\nint X509_REVOKED_add1_ext_i2d(X509_REVOKED *x, int nid, void *value, int crit,\n                              unsigned long flags);\n\nX509_EXTENSION *X509_EXTENSION_create_by_NID(X509_EXTENSION **ex,\n                                             int nid, int crit,\n                                             ASN1_OCTET_STRING *data);\nX509_EXTENSION *X509_EXTENSION_create_by_OBJ(X509_EXTENSION **ex,\n                                             ASN1_OBJECT *obj, int crit,\n                                             ASN1_OCTET_STRING *data);\nint X509_EXTENSION_set_object(X509_EXTENSION *ex, ASN1_OBJECT *obj);\nint X509_EXTENSION_set_critical(X509_EXTENSION *ex, int crit);\nint X509_EXTENSION_set_data(X509_EXTENSION *ex, ASN1_OCTET_STRING *data);\nASN1_OBJECT *X509_EXTENSION_get_object(X509_EXTENSION *ex);\nASN1_OCTET_STRING *X509_EXTENSION_get_data(X509_EXTENSION *ne);\nint X509_EXTENSION_get_critical(X509_EXTENSION *ex);\n\nint X509at_get_attr_count(const STACK_OF(X509_ATTRIBUTE) *x);\nint X509at_get_attr_by_NID(const STACK_OF(X509_ATTRIBUTE) *x, int nid,\n                           int lastpos);\nint X509at_get_attr_by_OBJ(const STACK_OF(X509_ATTRIBUTE) *sk,\n                           ASN1_OBJECT *obj, int lastpos);\nX509_ATTRIBUTE *X509at_get_attr(const STACK_OF(X509_ATTRIBUTE) *x, int loc);\nX509_ATTRIBUTE *X509at_delete_attr(STACK_OF(X509_ATTRIBUTE) *x, int loc);\nSTACK_OF(X509_ATTRIBUTE) *X509at_add1_attr(STACK_OF(X509_ATTRIBUTE) **x,\n                                           X509_ATTRIBUTE *attr);\nSTACK_OF(X509_ATTRIBUTE) *X509at_add1_attr_by_OBJ(STACK_OF(X509_ATTRIBUTE)\n                                                  **x, const ASN1_OBJECT *obj,\n                                                  int type,\n                                                  const unsigned char *bytes,\n                                                  int len);\nSTACK_OF(X509_ATTRIBUTE) *X509at_add1_attr_by_NID(STACK_OF(X509_ATTRIBUTE)\n                                                  **x, int nid, int type,\n                                                  const unsigned char *bytes,\n                                                  int len);\nSTACK_OF(X509_ATTRIBUTE) *X509at_add1_attr_by_txt(STACK_OF(X509_ATTRIBUTE)\n                                                  **x, const char *attrname,\n                                                  int type,\n                                                  const unsigned char *bytes,\n                                                  int len);\nvoid *X509at_get0_data_by_OBJ(STACK_OF(X509_ATTRIBUTE) *x, ASN1_OBJECT *obj,\n                              int lastpos, int type);\nX509_ATTRIBUTE *X509_ATTRIBUTE_create_by_NID(X509_ATTRIBUTE **attr, int nid,\n                                             int atrtype, const void *data,\n                                             int len);\nX509_ATTRIBUTE *X509_ATTRIBUTE_create_by_OBJ(X509_ATTRIBUTE **attr,\n                                             const ASN1_OBJECT *obj,\n                                             int atrtype, const void *data,\n                                             int len);\nX509_ATTRIBUTE *X509_ATTRIBUTE_create_by_txt(X509_ATTRIBUTE **attr,\n                                             const char *atrname, int type,\n                                             const unsigned char *bytes,\n                                             int len);\nint X509_ATTRIBUTE_set1_object(X509_ATTRIBUTE *attr, const ASN1_OBJECT *obj);\nint X509_ATTRIBUTE_set1_data(X509_ATTRIBUTE *attr, int attrtype,\n                             const void *data, int len);\nvoid *X509_ATTRIBUTE_get0_data(X509_ATTRIBUTE *attr, int idx, int atrtype,\n                               void *data);\nint X509_ATTRIBUTE_count(X509_ATTRIBUTE *attr);\nASN1_OBJECT *X509_ATTRIBUTE_get0_object(X509_ATTRIBUTE *attr);\nASN1_TYPE *X509_ATTRIBUTE_get0_type(X509_ATTRIBUTE *attr, int idx);\n\nint EVP_PKEY_get_attr_count(const EVP_PKEY *key);\nint EVP_PKEY_get_attr_by_NID(const EVP_PKEY *key, int nid, int lastpos);\nint EVP_PKEY_get_attr_by_OBJ(const EVP_PKEY *key, ASN1_OBJECT *obj,\n                             int lastpos);\nX509_ATTRIBUTE *EVP_PKEY_get_attr(const EVP_PKEY *key, int loc);\nX509_ATTRIBUTE *EVP_PKEY_delete_attr(EVP_PKEY *key, int loc);\nint EVP_PKEY_add1_attr(EVP_PKEY *key, X509_ATTRIBUTE *attr);\nint EVP_PKEY_add1_attr_by_OBJ(EVP_PKEY *key,\n                              const ASN1_OBJECT *obj, int type,\n                              const unsigned char *bytes, int len);\nint EVP_PKEY_add1_attr_by_NID(EVP_PKEY *key,\n                              int nid, int type,\n                              const unsigned char *bytes, int len);\nint EVP_PKEY_add1_attr_by_txt(EVP_PKEY *key,\n                              const char *attrname, int type,\n                              const unsigned char *bytes, int len);\n\nint X509_verify_cert(X509_STORE_CTX *ctx);\n\n/* lookup a cert from a X509 STACK */\nX509 *X509_find_by_issuer_and_serial(STACK_OF(X509) *sk, X509_NAME *name,\n                                     ASN1_INTEGER *serial);\nX509 *X509_find_by_subject(STACK_OF(X509) *sk, X509_NAME *name);\n\nDECLARE_ASN1_FUNCTIONS(PBEPARAM)\nDECLARE_ASN1_FUNCTIONS(PBE2PARAM)\nDECLARE_ASN1_FUNCTIONS(PBKDF2PARAM)\n\nint PKCS5_pbe_set0_algor(X509_ALGOR *algor, int alg, int iter,\n                         const unsigned char *salt, int saltlen);\n\nX509_ALGOR *PKCS5_pbe_set(int alg, int iter,\n                          const unsigned char *salt, int saltlen);\nX509_ALGOR *PKCS5_pbe2_set(const EVP_CIPHER *cipher, int iter,\n                           unsigned char *salt, int saltlen);\nX509_ALGOR *PKCS5_pbe2_set_iv(const EVP_CIPHER *cipher, int iter,\n                              unsigned char *salt, int saltlen,\n                              unsigned char *aiv, int prf_nid);\n\nX509_ALGOR *PKCS5_pbkdf2_set(int iter, unsigned char *salt, int saltlen,\n                             int prf_nid, int keylen);\n\n/* PKCS#8 utilities */\n\nDECLARE_ASN1_FUNCTIONS(PKCS8_PRIV_KEY_INFO)\n\nEVP_PKEY *EVP_PKCS82PKEY(PKCS8_PRIV_KEY_INFO *p8);\nPKCS8_PRIV_KEY_INFO *EVP_PKEY2PKCS8(EVP_PKEY *pkey);\nPKCS8_PRIV_KEY_INFO *EVP_PKEY2PKCS8_broken(EVP_PKEY *pkey, int broken);\nPKCS8_PRIV_KEY_INFO *PKCS8_set_broken(PKCS8_PRIV_KEY_INFO *p8, int broken);\n\nint PKCS8_pkey_set0(PKCS8_PRIV_KEY_INFO *priv, ASN1_OBJECT *aobj,\n                    int version, int ptype, void *pval,\n                    unsigned char *penc, int penclen);\nint PKCS8_pkey_get0(ASN1_OBJECT **ppkalg,\n                    const unsigned char **pk, int *ppklen,\n                    X509_ALGOR **pa, PKCS8_PRIV_KEY_INFO *p8);\n\nint X509_PUBKEY_set0_param(X509_PUBKEY *pub, ASN1_OBJECT *aobj,\n                           int ptype, void *pval,\n                           unsigned char *penc, int penclen);\nint X509_PUBKEY_get0_param(ASN1_OBJECT **ppkalg,\n                           const unsigned char **pk, int *ppklen,\n                           X509_ALGOR **pa, X509_PUBKEY *pub);\n\nint X509_check_trust(X509 *x, int id, int flags);\nint X509_TRUST_get_count(void);\nX509_TRUST *X509_TRUST_get0(int idx);\nint X509_TRUST_get_by_id(int id);\nint X509_TRUST_add(int id, int flags, int (*ck) (X509_TRUST *, X509 *, int),\n                   char *name, int arg1, void *arg2);\nvoid X509_TRUST_cleanup(void);\nint X509_TRUST_get_flags(X509_TRUST *xp);\nchar *X509_TRUST_get0_name(X509_TRUST *xp);\nint X509_TRUST_get_trust(X509_TRUST *xp);\n\n/* BEGIN ERROR CODES */\n/*\n * The following lines are auto generated by the script mkerr.pl. Any changes\n * made after this point may be overwritten when the script is next run.\n */\n\nvoid ERR_load_X509_strings(void);\n\n/* Error codes for the X509 functions. */\n\n/* Function codes. */\n# define X509_F_ADD_CERT_DIR                              100\n# define X509_F_BY_FILE_CTRL                              101\n# define X509_F_CHECK_NAME_CONSTRAINTS                    106\n# define X509_F_CHECK_POLICY                              145\n# define X509_F_DIR_CTRL                                  102\n# define X509_F_GET_CERT_BY_SUBJECT                       103\n# define X509_F_NETSCAPE_SPKI_B64_DECODE                  129\n# define X509_F_NETSCAPE_SPKI_B64_ENCODE                  130\n# define X509_F_X509AT_ADD1_ATTR                          135\n# define X509_F_X509V3_ADD_EXT                            104\n# define X509_F_X509_ATTRIBUTE_CREATE_BY_NID              136\n# define X509_F_X509_ATTRIBUTE_CREATE_BY_OBJ              137\n# define X509_F_X509_ATTRIBUTE_CREATE_BY_TXT              140\n# define X509_F_X509_ATTRIBUTE_GET0_DATA                  139\n# define X509_F_X509_ATTRIBUTE_SET1_DATA                  138\n# define X509_F_X509_CHECK_PRIVATE_KEY                    128\n# define X509_F_X509_CRL_DIFF                             105\n# define X509_F_X509_CRL_PRINT_FP                         147\n# define X509_F_X509_EXTENSION_CREATE_BY_NID              108\n# define X509_F_X509_EXTENSION_CREATE_BY_OBJ              109\n# define X509_F_X509_GET_PUBKEY_PARAMETERS                110\n# define X509_F_X509_LOAD_CERT_CRL_FILE                   132\n# define X509_F_X509_LOAD_CERT_FILE                       111\n# define X509_F_X509_LOAD_CRL_FILE                        112\n# define X509_F_X509_NAME_ADD_ENTRY                       113\n# define X509_F_X509_NAME_ENTRY_CREATE_BY_NID             114\n# define X509_F_X509_NAME_ENTRY_CREATE_BY_TXT             131\n# define X509_F_X509_NAME_ENTRY_SET_OBJECT                115\n# define X509_F_X509_NAME_ONELINE                         116\n# define X509_F_X509_NAME_PRINT                           117\n# define X509_F_X509_PRINT_EX_FP                          118\n# define X509_F_X509_PUBKEY_GET                           119\n# define X509_F_X509_PUBKEY_SET                           120\n# define X509_F_X509_REQ_CHECK_PRIVATE_KEY                144\n# define X509_F_X509_REQ_PRINT_EX                         121\n# define X509_F_X509_REQ_PRINT_FP                         122\n# define X509_F_X509_REQ_TO_X509                          123\n# define X509_F_X509_STORE_ADD_CERT                       124\n# define X509_F_X509_STORE_ADD_CRL                        125\n# define X509_F_X509_STORE_CTX_GET1_ISSUER                146\n# define X509_F_X509_STORE_CTX_INIT                       143\n# define X509_F_X509_STORE_CTX_NEW                        142\n# define X509_F_X509_STORE_CTX_PURPOSE_INHERIT            134\n# define X509_F_X509_TO_X509_REQ                          126\n# define X509_F_X509_TRUST_ADD                            133\n# define X509_F_X509_TRUST_SET                            141\n# define X509_F_X509_VERIFY_CERT                          127\n\n/* Reason codes. */\n# define X509_R_AKID_MISMATCH                             110\n# define X509_R_BAD_X509_FILETYPE                         100\n# define X509_R_BASE64_DECODE_ERROR                       118\n# define X509_R_CANT_CHECK_DH_KEY                         114\n# define X509_R_CERT_ALREADY_IN_HASH_TABLE                101\n# define X509_R_CRL_ALREADY_DELTA                         127\n# define X509_R_CRL_VERIFY_FAILURE                        131\n# define X509_R_ERR_ASN1_LIB                              102\n# define X509_R_IDP_MISMATCH                              128\n# define X509_R_INVALID_DIRECTORY                         113\n# define X509_R_INVALID_FIELD_NAME                        119\n# define X509_R_INVALID_TRUST                             123\n# define X509_R_ISSUER_MISMATCH                           129\n# define X509_R_KEY_TYPE_MISMATCH                         115\n# define X509_R_KEY_VALUES_MISMATCH                       116\n# define X509_R_LOADING_CERT_DIR                          103\n# define X509_R_LOADING_DEFAULTS                          104\n# define X509_R_METHOD_NOT_SUPPORTED                      124\n# define X509_R_NAME_TOO_LONG                             134\n# define X509_R_NEWER_CRL_NOT_NEWER                       132\n# define X509_R_NO_CERT_SET_FOR_US_TO_VERIFY              105\n# define X509_R_NO_CRL_NUMBER                             130\n# define X509_R_PUBLIC_KEY_DECODE_ERROR                   125\n# define X509_R_PUBLIC_KEY_ENCODE_ERROR                   126\n# define X509_R_SHOULD_RETRY                              106\n# define X509_R_UNABLE_TO_FIND_PARAMETERS_IN_CHAIN        107\n# define X509_R_UNABLE_TO_GET_CERTS_PUBLIC_KEY            108\n# define X509_R_UNKNOWN_KEY_TYPE                          117\n# define X509_R_UNKNOWN_NID                               109\n# define X509_R_UNKNOWN_PURPOSE_ID                        121\n# define X509_R_UNKNOWN_TRUST_ID                          120\n# define X509_R_UNSUPPORTED_ALGORITHM                     111\n# define X509_R_WRONG_LOOKUP_TYPE                         112\n# define X509_R_WRONG_TYPE                                122\n\n# ifdef  __cplusplus\n}\n# endif\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/x86/include/openssl/x509_vfy.h",
    "content": "/* crypto/x509/x509_vfy.h */\n/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)\n * All rights reserved.\n *\n * This package is an SSL implementation written\n * by Eric Young (eay@cryptsoft.com).\n * The implementation was written so as to conform with Netscapes SSL.\n *\n * This library is free for commercial and non-commercial use as long as\n * the following conditions are aheared to.  The following conditions\n * apply to all code found in this distribution, be it the RC4, RSA,\n * lhash, DES, etc., code; not just the SSL code.  The SSL documentation\n * included with this distribution is covered by the same copyright terms\n * except that the holder is Tim Hudson (tjh@cryptsoft.com).\n *\n * Copyright remains Eric Young's, and as such any Copyright notices in\n * the code are not to be removed.\n * If this package is used in a product, Eric Young should be given attribution\n * as the author of the parts of the library used.\n * This can be in the form of a textual message at program startup or\n * in documentation (online or textual) provided with the package.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the copyright\n *    notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in the\n *    documentation and/or other materials provided with the distribution.\n * 3. All advertising materials mentioning features or use of this software\n *    must display the following acknowledgement:\n *    \"This product includes cryptographic software written by\n *     Eric Young (eay@cryptsoft.com)\"\n *    The word 'cryptographic' can be left out if the rouines from the library\n *    being used are not cryptographic related :-).\n * 4. If you include any Windows specific code (or a derivative thereof) from\n *    the apps directory (application code) you must include an acknowledgement:\n *    \"This product includes software written by Tim Hudson (tjh@cryptsoft.com)\"\n *\n * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n * SUCH DAMAGE.\n *\n * The licence and distribution terms for any publically available version or\n * derivative of this code cannot be changed.  i.e. this code cannot simply be\n * copied and put under another distribution licence\n * [including the GNU Public Licence.]\n */\n\n#ifndef HEADER_X509_H\n# include <openssl/x509.h>\n/*\n * openssl/x509.h ends up #include-ing this file at about the only\n * appropriate moment.\n */\n#endif\n\n#ifndef HEADER_X509_VFY_H\n# define HEADER_X509_VFY_H\n\n# include <openssl/opensslconf.h>\n# ifndef OPENSSL_NO_LHASH\n#  include <openssl/lhash.h>\n# endif\n# include <openssl/bio.h>\n# include <openssl/crypto.h>\n# include <openssl/symhacks.h>\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n# if 0\n/* Outer object */\ntypedef struct x509_hash_dir_st {\n    int num_dirs;\n    char **dirs;\n    int *dirs_type;\n    int num_dirs_alloced;\n} X509_HASH_DIR_CTX;\n# endif\n\ntypedef struct x509_file_st {\n    int num_paths;              /* number of paths to files or directories */\n    int num_alloced;\n    char **paths;               /* the list of paths or directories */\n    int *path_type;\n} X509_CERT_FILE_CTX;\n\n/*******************************/\n/*-\nSSL_CTX -> X509_STORE\n                -> X509_LOOKUP\n                        ->X509_LOOKUP_METHOD\n                -> X509_LOOKUP\n                        ->X509_LOOKUP_METHOD\n\nSSL     -> X509_STORE_CTX\n                ->X509_STORE\n\nThe X509_STORE holds the tables etc for verification stuff.\nA X509_STORE_CTX is used while validating a single certificate.\nThe X509_STORE has X509_LOOKUPs for looking up certs.\nThe X509_STORE then calls a function to actually verify the\ncertificate chain.\n*/\n\n# define X509_LU_RETRY           -1\n# define X509_LU_FAIL            0\n# define X509_LU_X509            1\n# define X509_LU_CRL             2\n# define X509_LU_PKEY            3\n\ntypedef struct x509_object_st {\n    /* one of the above types */\n    int type;\n    union {\n        char *ptr;\n        X509 *x509;\n        X509_CRL *crl;\n        EVP_PKEY *pkey;\n    } data;\n} X509_OBJECT;\n\ntypedef struct x509_lookup_st X509_LOOKUP;\n\nDECLARE_STACK_OF(X509_LOOKUP)\nDECLARE_STACK_OF(X509_OBJECT)\n\n/* This is a static that defines the function interface */\ntypedef struct x509_lookup_method_st {\n    const char *name;\n    int (*new_item) (X509_LOOKUP *ctx);\n    void (*free) (X509_LOOKUP *ctx);\n    int (*init) (X509_LOOKUP *ctx);\n    int (*shutdown) (X509_LOOKUP *ctx);\n    int (*ctrl) (X509_LOOKUP *ctx, int cmd, const char *argc, long argl,\n                 char **ret);\n    int (*get_by_subject) (X509_LOOKUP *ctx, int type, X509_NAME *name,\n                           X509_OBJECT *ret);\n    int (*get_by_issuer_serial) (X509_LOOKUP *ctx, int type, X509_NAME *name,\n                                 ASN1_INTEGER *serial, X509_OBJECT *ret);\n    int (*get_by_fingerprint) (X509_LOOKUP *ctx, int type,\n                               unsigned char *bytes, int len,\n                               X509_OBJECT *ret);\n    int (*get_by_alias) (X509_LOOKUP *ctx, int type, char *str, int len,\n                         X509_OBJECT *ret);\n} X509_LOOKUP_METHOD;\n\ntypedef struct X509_VERIFY_PARAM_ID_st X509_VERIFY_PARAM_ID;\n\n/*\n * This structure hold all parameters associated with a verify operation by\n * including an X509_VERIFY_PARAM structure in related structures the\n * parameters used can be customized\n */\n\ntypedef struct X509_VERIFY_PARAM_st {\n    char *name;\n    time_t check_time;          /* Time to use */\n    unsigned long inh_flags;    /* Inheritance flags */\n    unsigned long flags;        /* Various verify flags */\n    int purpose;                /* purpose to check untrusted certificates */\n    int trust;                  /* trust setting to check */\n    int depth;                  /* Verify depth */\n    STACK_OF(ASN1_OBJECT) *policies; /* Permissible policies */\n    X509_VERIFY_PARAM_ID *id;   /* opaque ID data */\n} X509_VERIFY_PARAM;\n\nDECLARE_STACK_OF(X509_VERIFY_PARAM)\n\n/*\n * This is used to hold everything.  It is used for all certificate\n * validation.  Once we have a certificate chain, the 'verify' function is\n * then called to actually check the cert chain.\n */\nstruct x509_store_st {\n    /* The following is a cache of trusted certs */\n    int cache;                  /* if true, stash any hits */\n    STACK_OF(X509_OBJECT) *objs; /* Cache of all objects */\n    /* These are external lookup methods */\n    STACK_OF(X509_LOOKUP) *get_cert_methods;\n    X509_VERIFY_PARAM *param;\n    /* Callbacks for various operations */\n    /* called to verify a certificate */\n    int (*verify) (X509_STORE_CTX *ctx);\n    /* error callback */\n    int (*verify_cb) (int ok, X509_STORE_CTX *ctx);\n    /* get issuers cert from ctx */\n    int (*get_issuer) (X509 **issuer, X509_STORE_CTX *ctx, X509 *x);\n    /* check issued */\n    int (*check_issued) (X509_STORE_CTX *ctx, X509 *x, X509 *issuer);\n    /* Check revocation status of chain */\n    int (*check_revocation) (X509_STORE_CTX *ctx);\n    /* retrieve CRL */\n    int (*get_crl) (X509_STORE_CTX *ctx, X509_CRL **crl, X509 *x);\n    /* Check CRL validity */\n    int (*check_crl) (X509_STORE_CTX *ctx, X509_CRL *crl);\n    /* Check certificate against CRL */\n    int (*cert_crl) (X509_STORE_CTX *ctx, X509_CRL *crl, X509 *x);\n    STACK_OF(X509) *(*lookup_certs) (X509_STORE_CTX *ctx, X509_NAME *nm);\n    STACK_OF(X509_CRL) *(*lookup_crls) (X509_STORE_CTX *ctx, X509_NAME *nm);\n    int (*cleanup) (X509_STORE_CTX *ctx);\n    CRYPTO_EX_DATA ex_data;\n    int references;\n} /* X509_STORE */ ;\n\nint X509_STORE_set_depth(X509_STORE *store, int depth);\n\n# define X509_STORE_set_verify_cb_func(ctx,func) ((ctx)->verify_cb=(func))\n# define X509_STORE_set_verify_func(ctx,func)    ((ctx)->verify=(func))\n\n/* This is the functions plus an instance of the local variables. */\nstruct x509_lookup_st {\n    int init;                   /* have we been started */\n    int skip;                   /* don't use us. */\n    X509_LOOKUP_METHOD *method; /* the functions */\n    char *method_data;          /* method data */\n    X509_STORE *store_ctx;      /* who owns us */\n} /* X509_LOOKUP */ ;\n\n/*\n * This is a used when verifying cert chains.  Since the gathering of the\n * cert chain can take some time (and have to be 'retried', this needs to be\n * kept and passed around.\n */\nstruct x509_store_ctx_st {      /* X509_STORE_CTX */\n    X509_STORE *ctx;\n    /* used when looking up certs */\n    int current_method;\n    /* The following are set by the caller */\n    /* The cert to check */\n    X509 *cert;\n    /* chain of X509s - untrusted - passed in */\n    STACK_OF(X509) *untrusted;\n    /* set of CRLs passed in */\n    STACK_OF(X509_CRL) *crls;\n    X509_VERIFY_PARAM *param;\n    /* Other info for use with get_issuer() */\n    void *other_ctx;\n    /* Callbacks for various operations */\n    /* called to verify a certificate */\n    int (*verify) (X509_STORE_CTX *ctx);\n    /* error callback */\n    int (*verify_cb) (int ok, X509_STORE_CTX *ctx);\n    /* get issuers cert from ctx */\n    int (*get_issuer) (X509 **issuer, X509_STORE_CTX *ctx, X509 *x);\n    /* check issued */\n    int (*check_issued) (X509_STORE_CTX *ctx, X509 *x, X509 *issuer);\n    /* Check revocation status of chain */\n    int (*check_revocation) (X509_STORE_CTX *ctx);\n    /* retrieve CRL */\n    int (*get_crl) (X509_STORE_CTX *ctx, X509_CRL **crl, X509 *x);\n    /* Check CRL validity */\n    int (*check_crl) (X509_STORE_CTX *ctx, X509_CRL *crl);\n    /* Check certificate against CRL */\n    int (*cert_crl) (X509_STORE_CTX *ctx, X509_CRL *crl, X509 *x);\n    int (*check_policy) (X509_STORE_CTX *ctx);\n    STACK_OF(X509) *(*lookup_certs) (X509_STORE_CTX *ctx, X509_NAME *nm);\n    STACK_OF(X509_CRL) *(*lookup_crls) (X509_STORE_CTX *ctx, X509_NAME *nm);\n    int (*cleanup) (X509_STORE_CTX *ctx);\n    /* The following is built up */\n    /* if 0, rebuild chain */\n    int valid;\n    /* index of last untrusted cert */\n    int last_untrusted;\n    /* chain of X509s - built up and trusted */\n    STACK_OF(X509) *chain;\n    /* Valid policy tree */\n    X509_POLICY_TREE *tree;\n    /* Require explicit policy value */\n    int explicit_policy;\n    /* When something goes wrong, this is why */\n    int error_depth;\n    int error;\n    X509 *current_cert;\n    /* cert currently being tested as valid issuer */\n    X509 *current_issuer;\n    /* current CRL */\n    X509_CRL *current_crl;\n    /* score of current CRL */\n    int current_crl_score;\n    /* Reason mask */\n    unsigned int current_reasons;\n    /* For CRL path validation: parent context */\n    X509_STORE_CTX *parent;\n    CRYPTO_EX_DATA ex_data;\n} /* X509_STORE_CTX */ ;\n\nvoid X509_STORE_CTX_set_depth(X509_STORE_CTX *ctx, int depth);\n\n# define X509_STORE_CTX_set_app_data(ctx,data) \\\n        X509_STORE_CTX_set_ex_data(ctx,0,data)\n# define X509_STORE_CTX_get_app_data(ctx) \\\n        X509_STORE_CTX_get_ex_data(ctx,0)\n\n# define X509_L_FILE_LOAD        1\n# define X509_L_ADD_DIR          2\n\n# define X509_LOOKUP_load_file(x,name,type) \\\n                X509_LOOKUP_ctrl((x),X509_L_FILE_LOAD,(name),(long)(type),NULL)\n\n# define X509_LOOKUP_add_dir(x,name,type) \\\n                X509_LOOKUP_ctrl((x),X509_L_ADD_DIR,(name),(long)(type),NULL)\n\n# define         X509_V_OK                                       0\n# define         X509_V_ERR_UNSPECIFIED                          1\n\n# define         X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT            2\n# define         X509_V_ERR_UNABLE_TO_GET_CRL                    3\n# define         X509_V_ERR_UNABLE_TO_DECRYPT_CERT_SIGNATURE     4\n# define         X509_V_ERR_UNABLE_TO_DECRYPT_CRL_SIGNATURE      5\n# define         X509_V_ERR_UNABLE_TO_DECODE_ISSUER_PUBLIC_KEY   6\n# define         X509_V_ERR_CERT_SIGNATURE_FAILURE               7\n# define         X509_V_ERR_CRL_SIGNATURE_FAILURE                8\n# define         X509_V_ERR_CERT_NOT_YET_VALID                   9\n# define         X509_V_ERR_CERT_HAS_EXPIRED                     10\n# define         X509_V_ERR_CRL_NOT_YET_VALID                    11\n# define         X509_V_ERR_CRL_HAS_EXPIRED                      12\n# define         X509_V_ERR_ERROR_IN_CERT_NOT_BEFORE_FIELD       13\n# define         X509_V_ERR_ERROR_IN_CERT_NOT_AFTER_FIELD        14\n# define         X509_V_ERR_ERROR_IN_CRL_LAST_UPDATE_FIELD       15\n# define         X509_V_ERR_ERROR_IN_CRL_NEXT_UPDATE_FIELD       16\n# define         X509_V_ERR_OUT_OF_MEM                           17\n# define         X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT          18\n# define         X509_V_ERR_SELF_SIGNED_CERT_IN_CHAIN            19\n# define         X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY    20\n# define         X509_V_ERR_UNABLE_TO_VERIFY_LEAF_SIGNATURE      21\n# define         X509_V_ERR_CERT_CHAIN_TOO_LONG                  22\n# define         X509_V_ERR_CERT_REVOKED                         23\n# define         X509_V_ERR_INVALID_CA                           24\n# define         X509_V_ERR_PATH_LENGTH_EXCEEDED                 25\n# define         X509_V_ERR_INVALID_PURPOSE                      26\n# define         X509_V_ERR_CERT_UNTRUSTED                       27\n# define         X509_V_ERR_CERT_REJECTED                        28\n/* These are 'informational' when looking for issuer cert */\n# define         X509_V_ERR_SUBJECT_ISSUER_MISMATCH              29\n# define         X509_V_ERR_AKID_SKID_MISMATCH                   30\n# define         X509_V_ERR_AKID_ISSUER_SERIAL_MISMATCH          31\n# define         X509_V_ERR_KEYUSAGE_NO_CERTSIGN                 32\n\n# define         X509_V_ERR_UNABLE_TO_GET_CRL_ISSUER             33\n# define         X509_V_ERR_UNHANDLED_CRITICAL_EXTENSION         34\n# define         X509_V_ERR_KEYUSAGE_NO_CRL_SIGN                 35\n# define         X509_V_ERR_UNHANDLED_CRITICAL_CRL_EXTENSION     36\n# define         X509_V_ERR_INVALID_NON_CA                       37\n# define         X509_V_ERR_PROXY_PATH_LENGTH_EXCEEDED           38\n# define         X509_V_ERR_KEYUSAGE_NO_DIGITAL_SIGNATURE        39\n# define         X509_V_ERR_PROXY_CERTIFICATES_NOT_ALLOWED       40\n\n# define         X509_V_ERR_INVALID_EXTENSION                    41\n# define         X509_V_ERR_INVALID_POLICY_EXTENSION             42\n# define         X509_V_ERR_NO_EXPLICIT_POLICY                   43\n# define         X509_V_ERR_DIFFERENT_CRL_SCOPE                  44\n# define         X509_V_ERR_UNSUPPORTED_EXTENSION_FEATURE        45\n\n# define         X509_V_ERR_UNNESTED_RESOURCE                    46\n\n# define         X509_V_ERR_PERMITTED_VIOLATION                  47\n# define         X509_V_ERR_EXCLUDED_VIOLATION                   48\n# define         X509_V_ERR_SUBTREE_MINMAX                       49\n# define         X509_V_ERR_APPLICATION_VERIFICATION             50\n# define         X509_V_ERR_UNSUPPORTED_CONSTRAINT_TYPE          51\n# define         X509_V_ERR_UNSUPPORTED_CONSTRAINT_SYNTAX        52\n# define         X509_V_ERR_UNSUPPORTED_NAME_SYNTAX              53\n# define         X509_V_ERR_CRL_PATH_VALIDATION_ERROR            54\n\n/* Suite B mode algorithm violation */\n# define         X509_V_ERR_SUITE_B_INVALID_VERSION              56\n# define         X509_V_ERR_SUITE_B_INVALID_ALGORITHM            57\n# define         X509_V_ERR_SUITE_B_INVALID_CURVE                58\n# define         X509_V_ERR_SUITE_B_INVALID_SIGNATURE_ALGORITHM  59\n# define         X509_V_ERR_SUITE_B_LOS_NOT_ALLOWED              60\n# define         X509_V_ERR_SUITE_B_CANNOT_SIGN_P_384_WITH_P_256 61\n\n/* Host, email and IP check errors */\n# define         X509_V_ERR_HOSTNAME_MISMATCH                    62\n# define         X509_V_ERR_EMAIL_MISMATCH                       63\n# define         X509_V_ERR_IP_ADDRESS_MISMATCH                  64\n\n/* Caller error */\n# define         X509_V_ERR_INVALID_CALL                         65\n/* Issuer lookup error */\n# define         X509_V_ERR_STORE_LOOKUP                         66\n\n# define         X509_V_ERR_PROXY_SUBJECT_NAME_VIOLATION         67\n\n/* Certificate verify flags */\n\n/* Send issuer+subject checks to verify_cb */\n# define X509_V_FLAG_CB_ISSUER_CHECK             0x1\n/* Use check time instead of current time */\n# define X509_V_FLAG_USE_CHECK_TIME              0x2\n/* Lookup CRLs */\n# define X509_V_FLAG_CRL_CHECK                   0x4\n/* Lookup CRLs for whole chain */\n# define X509_V_FLAG_CRL_CHECK_ALL               0x8\n/* Ignore unhandled critical extensions */\n# define X509_V_FLAG_IGNORE_CRITICAL             0x10\n/* Disable workarounds for broken certificates */\n# define X509_V_FLAG_X509_STRICT                 0x20\n/* Enable proxy certificate validation */\n# define X509_V_FLAG_ALLOW_PROXY_CERTS           0x40\n/* Enable policy checking */\n# define X509_V_FLAG_POLICY_CHECK                0x80\n/* Policy variable require-explicit-policy */\n# define X509_V_FLAG_EXPLICIT_POLICY             0x100\n/* Policy variable inhibit-any-policy */\n# define X509_V_FLAG_INHIBIT_ANY                 0x200\n/* Policy variable inhibit-policy-mapping */\n# define X509_V_FLAG_INHIBIT_MAP                 0x400\n/* Notify callback that policy is OK */\n# define X509_V_FLAG_NOTIFY_POLICY               0x800\n/* Extended CRL features such as indirect CRLs, alternate CRL signing keys */\n# define X509_V_FLAG_EXTENDED_CRL_SUPPORT        0x1000\n/* Delta CRL support */\n# define X509_V_FLAG_USE_DELTAS                  0x2000\n/* Check selfsigned CA signature */\n# define X509_V_FLAG_CHECK_SS_SIGNATURE          0x4000\n/* Use trusted store first */\n# define X509_V_FLAG_TRUSTED_FIRST               0x8000\n/* Suite B 128 bit only mode: not normally used */\n# define X509_V_FLAG_SUITEB_128_LOS_ONLY         0x10000\n/* Suite B 192 bit only mode */\n# define X509_V_FLAG_SUITEB_192_LOS              0x20000\n/* Suite B 128 bit mode allowing 192 bit algorithms */\n# define X509_V_FLAG_SUITEB_128_LOS              0x30000\n\n/* Allow partial chains if at least one certificate is in trusted store */\n# define X509_V_FLAG_PARTIAL_CHAIN               0x80000\n/*\n * If the initial chain is not trusted, do not attempt to build an alternative\n * chain. Alternate chain checking was introduced in 1.0.2b. Setting this flag\n * will force the behaviour to match that of previous versions.\n */\n# define X509_V_FLAG_NO_ALT_CHAINS               0x100000\n\n# define X509_VP_FLAG_DEFAULT                    0x1\n# define X509_VP_FLAG_OVERWRITE                  0x2\n# define X509_VP_FLAG_RESET_FLAGS                0x4\n# define X509_VP_FLAG_LOCKED                     0x8\n# define X509_VP_FLAG_ONCE                       0x10\n\n/* Internal use: mask of policy related options */\n# define X509_V_FLAG_POLICY_MASK (X509_V_FLAG_POLICY_CHECK \\\n                                | X509_V_FLAG_EXPLICIT_POLICY \\\n                                | X509_V_FLAG_INHIBIT_ANY \\\n                                | X509_V_FLAG_INHIBIT_MAP)\n\nint X509_OBJECT_idx_by_subject(STACK_OF(X509_OBJECT) *h, int type,\n                               X509_NAME *name);\nX509_OBJECT *X509_OBJECT_retrieve_by_subject(STACK_OF(X509_OBJECT) *h,\n                                             int type, X509_NAME *name);\nX509_OBJECT *X509_OBJECT_retrieve_match(STACK_OF(X509_OBJECT) *h,\n                                        X509_OBJECT *x);\nvoid X509_OBJECT_up_ref_count(X509_OBJECT *a);\nvoid X509_OBJECT_free_contents(X509_OBJECT *a);\nX509_STORE *X509_STORE_new(void);\nvoid X509_STORE_free(X509_STORE *v);\n\nSTACK_OF(X509) *X509_STORE_get1_certs(X509_STORE_CTX *st, X509_NAME *nm);\nSTACK_OF(X509_CRL) *X509_STORE_get1_crls(X509_STORE_CTX *st, X509_NAME *nm);\nint X509_STORE_set_flags(X509_STORE *ctx, unsigned long flags);\nint X509_STORE_set_purpose(X509_STORE *ctx, int purpose);\nint X509_STORE_set_trust(X509_STORE *ctx, int trust);\nint X509_STORE_set1_param(X509_STORE *ctx, X509_VERIFY_PARAM *pm);\n\nvoid X509_STORE_set_verify_cb(X509_STORE *ctx,\n                              int (*verify_cb) (int, X509_STORE_CTX *));\n\nvoid X509_STORE_set_lookup_crls_cb(X509_STORE *ctx,\n                                   STACK_OF(X509_CRL) *(*cb) (X509_STORE_CTX\n                                                              *ctx,\n                                                              X509_NAME *nm));\n\nX509_STORE_CTX *X509_STORE_CTX_new(void);\n\nint X509_STORE_CTX_get1_issuer(X509 **issuer, X509_STORE_CTX *ctx, X509 *x);\n\nvoid X509_STORE_CTX_free(X509_STORE_CTX *ctx);\nint X509_STORE_CTX_init(X509_STORE_CTX *ctx, X509_STORE *store,\n                        X509 *x509, STACK_OF(X509) *chain);\nvoid X509_STORE_CTX_trusted_stack(X509_STORE_CTX *ctx, STACK_OF(X509) *sk);\nvoid X509_STORE_CTX_cleanup(X509_STORE_CTX *ctx);\n\nX509_STORE *X509_STORE_CTX_get0_store(X509_STORE_CTX *ctx);\n\nX509_LOOKUP *X509_STORE_add_lookup(X509_STORE *v, X509_LOOKUP_METHOD *m);\n\nX509_LOOKUP_METHOD *X509_LOOKUP_hash_dir(void);\nX509_LOOKUP_METHOD *X509_LOOKUP_file(void);\n\nint X509_STORE_add_cert(X509_STORE *ctx, X509 *x);\nint X509_STORE_add_crl(X509_STORE *ctx, X509_CRL *x);\n\nint X509_STORE_get_by_subject(X509_STORE_CTX *vs, int type, X509_NAME *name,\n                              X509_OBJECT *ret);\n\nint X509_LOOKUP_ctrl(X509_LOOKUP *ctx, int cmd, const char *argc,\n                     long argl, char **ret);\n\n# ifndef OPENSSL_NO_STDIO\nint X509_load_cert_file(X509_LOOKUP *ctx, const char *file, int type);\nint X509_load_crl_file(X509_LOOKUP *ctx, const char *file, int type);\nint X509_load_cert_crl_file(X509_LOOKUP *ctx, const char *file, int type);\n# endif\n\nX509_LOOKUP *X509_LOOKUP_new(X509_LOOKUP_METHOD *method);\nvoid X509_LOOKUP_free(X509_LOOKUP *ctx);\nint X509_LOOKUP_init(X509_LOOKUP *ctx);\nint X509_LOOKUP_by_subject(X509_LOOKUP *ctx, int type, X509_NAME *name,\n                           X509_OBJECT *ret);\nint X509_LOOKUP_by_issuer_serial(X509_LOOKUP *ctx, int type, X509_NAME *name,\n                                 ASN1_INTEGER *serial, X509_OBJECT *ret);\nint X509_LOOKUP_by_fingerprint(X509_LOOKUP *ctx, int type,\n                               unsigned char *bytes, int len,\n                               X509_OBJECT *ret);\nint X509_LOOKUP_by_alias(X509_LOOKUP *ctx, int type, char *str, int len,\n                         X509_OBJECT *ret);\nint X509_LOOKUP_shutdown(X509_LOOKUP *ctx);\n\n# ifndef OPENSSL_NO_STDIO\nint X509_STORE_load_locations(X509_STORE *ctx,\n                              const char *file, const char *dir);\nint X509_STORE_set_default_paths(X509_STORE *ctx);\n# endif\n\nint X509_STORE_CTX_get_ex_new_index(long argl, void *argp,\n                                    CRYPTO_EX_new *new_func,\n                                    CRYPTO_EX_dup *dup_func,\n                                    CRYPTO_EX_free *free_func);\nint X509_STORE_CTX_set_ex_data(X509_STORE_CTX *ctx, int idx, void *data);\nvoid *X509_STORE_CTX_get_ex_data(X509_STORE_CTX *ctx, int idx);\nint X509_STORE_CTX_get_error(X509_STORE_CTX *ctx);\nvoid X509_STORE_CTX_set_error(X509_STORE_CTX *ctx, int s);\nint X509_STORE_CTX_get_error_depth(X509_STORE_CTX *ctx);\nX509 *X509_STORE_CTX_get_current_cert(X509_STORE_CTX *ctx);\nX509 *X509_STORE_CTX_get0_current_issuer(X509_STORE_CTX *ctx);\nX509_CRL *X509_STORE_CTX_get0_current_crl(X509_STORE_CTX *ctx);\nX509_STORE_CTX *X509_STORE_CTX_get0_parent_ctx(X509_STORE_CTX *ctx);\nSTACK_OF(X509) *X509_STORE_CTX_get_chain(X509_STORE_CTX *ctx);\nSTACK_OF(X509) *X509_STORE_CTX_get1_chain(X509_STORE_CTX *ctx);\nvoid X509_STORE_CTX_set_cert(X509_STORE_CTX *c, X509 *x);\nvoid X509_STORE_CTX_set_chain(X509_STORE_CTX *c, STACK_OF(X509) *sk);\nvoid X509_STORE_CTX_set0_crls(X509_STORE_CTX *c, STACK_OF(X509_CRL) *sk);\nint X509_STORE_CTX_set_purpose(X509_STORE_CTX *ctx, int purpose);\nint X509_STORE_CTX_set_trust(X509_STORE_CTX *ctx, int trust);\nint X509_STORE_CTX_purpose_inherit(X509_STORE_CTX *ctx, int def_purpose,\n                                   int purpose, int trust);\nvoid X509_STORE_CTX_set_flags(X509_STORE_CTX *ctx, unsigned long flags);\nvoid X509_STORE_CTX_set_time(X509_STORE_CTX *ctx, unsigned long flags,\n                             time_t t);\nvoid X509_STORE_CTX_set_verify_cb(X509_STORE_CTX *ctx,\n                                  int (*verify_cb) (int, X509_STORE_CTX *));\n\nX509_POLICY_TREE *X509_STORE_CTX_get0_policy_tree(X509_STORE_CTX *ctx);\nint X509_STORE_CTX_get_explicit_policy(X509_STORE_CTX *ctx);\n\nX509_VERIFY_PARAM *X509_STORE_CTX_get0_param(X509_STORE_CTX *ctx);\nvoid X509_STORE_CTX_set0_param(X509_STORE_CTX *ctx, X509_VERIFY_PARAM *param);\nint X509_STORE_CTX_set_default(X509_STORE_CTX *ctx, const char *name);\n\n/* X509_VERIFY_PARAM functions */\n\nX509_VERIFY_PARAM *X509_VERIFY_PARAM_new(void);\nvoid X509_VERIFY_PARAM_free(X509_VERIFY_PARAM *param);\nint X509_VERIFY_PARAM_inherit(X509_VERIFY_PARAM *to,\n                              const X509_VERIFY_PARAM *from);\nint X509_VERIFY_PARAM_set1(X509_VERIFY_PARAM *to,\n                           const X509_VERIFY_PARAM *from);\nint X509_VERIFY_PARAM_set1_name(X509_VERIFY_PARAM *param, const char *name);\nint X509_VERIFY_PARAM_set_flags(X509_VERIFY_PARAM *param,\n                                unsigned long flags);\nint X509_VERIFY_PARAM_clear_flags(X509_VERIFY_PARAM *param,\n                                  unsigned long flags);\nunsigned long X509_VERIFY_PARAM_get_flags(X509_VERIFY_PARAM *param);\nint X509_VERIFY_PARAM_set_purpose(X509_VERIFY_PARAM *param, int purpose);\nint X509_VERIFY_PARAM_set_trust(X509_VERIFY_PARAM *param, int trust);\nvoid X509_VERIFY_PARAM_set_depth(X509_VERIFY_PARAM *param, int depth);\nvoid X509_VERIFY_PARAM_set_time(X509_VERIFY_PARAM *param, time_t t);\nint X509_VERIFY_PARAM_add0_policy(X509_VERIFY_PARAM *param,\n                                  ASN1_OBJECT *policy);\nint X509_VERIFY_PARAM_set1_policies(X509_VERIFY_PARAM *param,\n                                    STACK_OF(ASN1_OBJECT) *policies);\n\nint X509_VERIFY_PARAM_set1_host(X509_VERIFY_PARAM *param,\n                                const char *name, size_t namelen);\nint X509_VERIFY_PARAM_add1_host(X509_VERIFY_PARAM *param,\n                                const char *name, size_t namelen);\nvoid X509_VERIFY_PARAM_set_hostflags(X509_VERIFY_PARAM *param,\n                                     unsigned int flags);\nchar *X509_VERIFY_PARAM_get0_peername(X509_VERIFY_PARAM *);\nint X509_VERIFY_PARAM_set1_email(X509_VERIFY_PARAM *param,\n                                 const char *email, size_t emaillen);\nint X509_VERIFY_PARAM_set1_ip(X509_VERIFY_PARAM *param,\n                              const unsigned char *ip, size_t iplen);\nint X509_VERIFY_PARAM_set1_ip_asc(X509_VERIFY_PARAM *param,\n                                  const char *ipasc);\n\nint X509_VERIFY_PARAM_get_depth(const X509_VERIFY_PARAM *param);\nconst char *X509_VERIFY_PARAM_get0_name(const X509_VERIFY_PARAM *param);\n\nint X509_VERIFY_PARAM_add0_table(X509_VERIFY_PARAM *param);\nint X509_VERIFY_PARAM_get_count(void);\nconst X509_VERIFY_PARAM *X509_VERIFY_PARAM_get0(int id);\nconst X509_VERIFY_PARAM *X509_VERIFY_PARAM_lookup(const char *name);\nvoid X509_VERIFY_PARAM_table_cleanup(void);\n\nint X509_policy_check(X509_POLICY_TREE **ptree, int *pexplicit_policy,\n                      STACK_OF(X509) *certs,\n                      STACK_OF(ASN1_OBJECT) *policy_oids, unsigned int flags);\n\nvoid X509_policy_tree_free(X509_POLICY_TREE *tree);\n\nint X509_policy_tree_level_count(const X509_POLICY_TREE *tree);\nX509_POLICY_LEVEL *X509_policy_tree_get0_level(const X509_POLICY_TREE *tree,\n                                               int i);\n\nSTACK_OF(X509_POLICY_NODE) *X509_policy_tree_get0_policies(const\n                                                           X509_POLICY_TREE\n                                                           *tree);\n\nSTACK_OF(X509_POLICY_NODE) *X509_policy_tree_get0_user_policies(const\n                                                                X509_POLICY_TREE\n                                                                *tree);\n\nint X509_policy_level_node_count(X509_POLICY_LEVEL *level);\n\nX509_POLICY_NODE *X509_policy_level_get0_node(X509_POLICY_LEVEL *level,\n                                              int i);\n\nconst ASN1_OBJECT *X509_policy_node_get0_policy(const X509_POLICY_NODE *node);\n\nSTACK_OF(POLICYQUALINFO) *X509_policy_node_get0_qualifiers(const\n                                                           X509_POLICY_NODE\n                                                           *node);\nconst X509_POLICY_NODE *X509_policy_node_get0_parent(const X509_POLICY_NODE\n                                                     *node);\n\n#ifdef  __cplusplus\n}\n#endif\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/x86/include/openssl/x509v3.h",
    "content": "/* x509v3.h */\n/*\n * Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL project\n * 1999.\n */\n/* ====================================================================\n * Copyright (c) 1999-2004 The OpenSSL Project.  All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n *\n * 1. Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n *\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in\n *    the documentation and/or other materials provided with the\n *    distribution.\n *\n * 3. All advertising materials mentioning features or use of this\n *    software must display the following acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)\"\n *\n * 4. The names \"OpenSSL Toolkit\" and \"OpenSSL Project\" must not be used to\n *    endorse or promote products derived from this software without\n *    prior written permission. For written permission, please contact\n *    licensing@OpenSSL.org.\n *\n * 5. Products derived from this software may not be called \"OpenSSL\"\n *    nor may \"OpenSSL\" appear in their names without prior written\n *    permission of the OpenSSL Project.\n *\n * 6. Redistributions of any form whatsoever must retain the following\n *    acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)\"\n *\n * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY\n * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\n * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR\n * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\n * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,\n * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED\n * OF THE POSSIBILITY OF SUCH DAMAGE.\n * ====================================================================\n *\n * This product includes cryptographic software written by Eric Young\n * (eay@cryptsoft.com).  This product includes software written by Tim\n * Hudson (tjh@cryptsoft.com).\n *\n */\n#ifndef HEADER_X509V3_H\n# define HEADER_X509V3_H\n\n# include <openssl/bio.h>\n# include <openssl/x509.h>\n# include <openssl/conf.h>\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n# ifdef OPENSSL_SYS_WIN32\n/* Under Win32 these are defined in wincrypt.h */\n#  undef X509_NAME\n#  undef X509_CERT_PAIR\n#  undef X509_EXTENSIONS\n# endif\n\n/* Forward reference */\nstruct v3_ext_method;\nstruct v3_ext_ctx;\n\n/* Useful typedefs */\n\ntypedef void *(*X509V3_EXT_NEW)(void);\ntypedef void (*X509V3_EXT_FREE) (void *);\ntypedef void *(*X509V3_EXT_D2I)(void *, const unsigned char **, long);\ntypedef int (*X509V3_EXT_I2D) (void *, unsigned char **);\ntypedef STACK_OF(CONF_VALUE) *\n    (*X509V3_EXT_I2V) (const struct v3_ext_method *method, void *ext,\n                       STACK_OF(CONF_VALUE) *extlist);\ntypedef void *(*X509V3_EXT_V2I)(const struct v3_ext_method *method,\n                                struct v3_ext_ctx *ctx,\n                                STACK_OF(CONF_VALUE) *values);\ntypedef char *(*X509V3_EXT_I2S)(const struct v3_ext_method *method,\n                                void *ext);\ntypedef void *(*X509V3_EXT_S2I)(const struct v3_ext_method *method,\n                                struct v3_ext_ctx *ctx, const char *str);\ntypedef int (*X509V3_EXT_I2R) (const struct v3_ext_method *method, void *ext,\n                               BIO *out, int indent);\ntypedef void *(*X509V3_EXT_R2I)(const struct v3_ext_method *method,\n                                struct v3_ext_ctx *ctx, const char *str);\n\n/* V3 extension structure */\n\nstruct v3_ext_method {\n    int ext_nid;\n    int ext_flags;\n/* If this is set the following four fields are ignored */\n    ASN1_ITEM_EXP *it;\n/* Old style ASN1 calls */\n    X509V3_EXT_NEW ext_new;\n    X509V3_EXT_FREE ext_free;\n    X509V3_EXT_D2I d2i;\n    X509V3_EXT_I2D i2d;\n/* The following pair is used for string extensions */\n    X509V3_EXT_I2S i2s;\n    X509V3_EXT_S2I s2i;\n/* The following pair is used for multi-valued extensions */\n    X509V3_EXT_I2V i2v;\n    X509V3_EXT_V2I v2i;\n/* The following are used for raw extensions */\n    X509V3_EXT_I2R i2r;\n    X509V3_EXT_R2I r2i;\n    void *usr_data;             /* Any extension specific data */\n};\n\ntypedef struct X509V3_CONF_METHOD_st {\n    char *(*get_string) (void *db, char *section, char *value);\n    STACK_OF(CONF_VALUE) *(*get_section) (void *db, char *section);\n    void (*free_string) (void *db, char *string);\n    void (*free_section) (void *db, STACK_OF(CONF_VALUE) *section);\n} X509V3_CONF_METHOD;\n\n/* Context specific info */\nstruct v3_ext_ctx {\n# define CTX_TEST 0x1\n    int flags;\n    X509 *issuer_cert;\n    X509 *subject_cert;\n    X509_REQ *subject_req;\n    X509_CRL *crl;\n    X509V3_CONF_METHOD *db_meth;\n    void *db;\n/* Maybe more here */\n};\n\ntypedef struct v3_ext_method X509V3_EXT_METHOD;\n\nDECLARE_STACK_OF(X509V3_EXT_METHOD)\n\n/* ext_flags values */\n# define X509V3_EXT_DYNAMIC      0x1\n# define X509V3_EXT_CTX_DEP      0x2\n# define X509V3_EXT_MULTILINE    0x4\n\ntypedef BIT_STRING_BITNAME ENUMERATED_NAMES;\n\ntypedef struct BASIC_CONSTRAINTS_st {\n    int ca;\n    ASN1_INTEGER *pathlen;\n} BASIC_CONSTRAINTS;\n\ntypedef struct PKEY_USAGE_PERIOD_st {\n    ASN1_GENERALIZEDTIME *notBefore;\n    ASN1_GENERALIZEDTIME *notAfter;\n} PKEY_USAGE_PERIOD;\n\ntypedef struct otherName_st {\n    ASN1_OBJECT *type_id;\n    ASN1_TYPE *value;\n} OTHERNAME;\n\ntypedef struct EDIPartyName_st {\n    ASN1_STRING *nameAssigner;\n    ASN1_STRING *partyName;\n} EDIPARTYNAME;\n\ntypedef struct GENERAL_NAME_st {\n# define GEN_OTHERNAME   0\n# define GEN_EMAIL       1\n# define GEN_DNS         2\n# define GEN_X400        3\n# define GEN_DIRNAME     4\n# define GEN_EDIPARTY    5\n# define GEN_URI         6\n# define GEN_IPADD       7\n# define GEN_RID         8\n    int type;\n    union {\n        char *ptr;\n        OTHERNAME *otherName;   /* otherName */\n        ASN1_IA5STRING *rfc822Name;\n        ASN1_IA5STRING *dNSName;\n        ASN1_TYPE *x400Address;\n        X509_NAME *directoryName;\n        EDIPARTYNAME *ediPartyName;\n        ASN1_IA5STRING *uniformResourceIdentifier;\n        ASN1_OCTET_STRING *iPAddress;\n        ASN1_OBJECT *registeredID;\n        /* Old names */\n        ASN1_OCTET_STRING *ip;  /* iPAddress */\n        X509_NAME *dirn;        /* dirn */\n        ASN1_IA5STRING *ia5;    /* rfc822Name, dNSName,\n                                 * uniformResourceIdentifier */\n        ASN1_OBJECT *rid;       /* registeredID */\n        ASN1_TYPE *other;       /* x400Address */\n    } d;\n} GENERAL_NAME;\n\ntypedef STACK_OF(GENERAL_NAME) GENERAL_NAMES;\n\ntypedef struct ACCESS_DESCRIPTION_st {\n    ASN1_OBJECT *method;\n    GENERAL_NAME *location;\n} ACCESS_DESCRIPTION;\n\ntypedef STACK_OF(ACCESS_DESCRIPTION) AUTHORITY_INFO_ACCESS;\n\ntypedef STACK_OF(ASN1_OBJECT) EXTENDED_KEY_USAGE;\n\nDECLARE_STACK_OF(GENERAL_NAME)\nDECLARE_ASN1_SET_OF(GENERAL_NAME)\n\nDECLARE_STACK_OF(ACCESS_DESCRIPTION)\nDECLARE_ASN1_SET_OF(ACCESS_DESCRIPTION)\n\ntypedef struct DIST_POINT_NAME_st {\n    int type;\n    union {\n        GENERAL_NAMES *fullname;\n        STACK_OF(X509_NAME_ENTRY) *relativename;\n    } name;\n/* If relativename then this contains the full distribution point name */\n    X509_NAME *dpname;\n} DIST_POINT_NAME;\n/* All existing reasons */\n# define CRLDP_ALL_REASONS       0x807f\n\n# define CRL_REASON_NONE                         -1\n# define CRL_REASON_UNSPECIFIED                  0\n# define CRL_REASON_KEY_COMPROMISE               1\n# define CRL_REASON_CA_COMPROMISE                2\n# define CRL_REASON_AFFILIATION_CHANGED          3\n# define CRL_REASON_SUPERSEDED                   4\n# define CRL_REASON_CESSATION_OF_OPERATION       5\n# define CRL_REASON_CERTIFICATE_HOLD             6\n# define CRL_REASON_REMOVE_FROM_CRL              8\n# define CRL_REASON_PRIVILEGE_WITHDRAWN          9\n# define CRL_REASON_AA_COMPROMISE                10\n\nstruct DIST_POINT_st {\n    DIST_POINT_NAME *distpoint;\n    ASN1_BIT_STRING *reasons;\n    GENERAL_NAMES *CRLissuer;\n    int dp_reasons;\n};\n\ntypedef STACK_OF(DIST_POINT) CRL_DIST_POINTS;\n\nDECLARE_STACK_OF(DIST_POINT)\nDECLARE_ASN1_SET_OF(DIST_POINT)\n\nstruct AUTHORITY_KEYID_st {\n    ASN1_OCTET_STRING *keyid;\n    GENERAL_NAMES *issuer;\n    ASN1_INTEGER *serial;\n};\n\n/* Strong extranet structures */\n\ntypedef struct SXNET_ID_st {\n    ASN1_INTEGER *zone;\n    ASN1_OCTET_STRING *user;\n} SXNETID;\n\nDECLARE_STACK_OF(SXNETID)\nDECLARE_ASN1_SET_OF(SXNETID)\n\ntypedef struct SXNET_st {\n    ASN1_INTEGER *version;\n    STACK_OF(SXNETID) *ids;\n} SXNET;\n\ntypedef struct NOTICEREF_st {\n    ASN1_STRING *organization;\n    STACK_OF(ASN1_INTEGER) *noticenos;\n} NOTICEREF;\n\ntypedef struct USERNOTICE_st {\n    NOTICEREF *noticeref;\n    ASN1_STRING *exptext;\n} USERNOTICE;\n\ntypedef struct POLICYQUALINFO_st {\n    ASN1_OBJECT *pqualid;\n    union {\n        ASN1_IA5STRING *cpsuri;\n        USERNOTICE *usernotice;\n        ASN1_TYPE *other;\n    } d;\n} POLICYQUALINFO;\n\nDECLARE_STACK_OF(POLICYQUALINFO)\nDECLARE_ASN1_SET_OF(POLICYQUALINFO)\n\ntypedef struct POLICYINFO_st {\n    ASN1_OBJECT *policyid;\n    STACK_OF(POLICYQUALINFO) *qualifiers;\n} POLICYINFO;\n\ntypedef STACK_OF(POLICYINFO) CERTIFICATEPOLICIES;\n\nDECLARE_STACK_OF(POLICYINFO)\nDECLARE_ASN1_SET_OF(POLICYINFO)\n\ntypedef struct POLICY_MAPPING_st {\n    ASN1_OBJECT *issuerDomainPolicy;\n    ASN1_OBJECT *subjectDomainPolicy;\n} POLICY_MAPPING;\n\nDECLARE_STACK_OF(POLICY_MAPPING)\n\ntypedef STACK_OF(POLICY_MAPPING) POLICY_MAPPINGS;\n\ntypedef struct GENERAL_SUBTREE_st {\n    GENERAL_NAME *base;\n    ASN1_INTEGER *minimum;\n    ASN1_INTEGER *maximum;\n} GENERAL_SUBTREE;\n\nDECLARE_STACK_OF(GENERAL_SUBTREE)\n\nstruct NAME_CONSTRAINTS_st {\n    STACK_OF(GENERAL_SUBTREE) *permittedSubtrees;\n    STACK_OF(GENERAL_SUBTREE) *excludedSubtrees;\n};\n\ntypedef struct POLICY_CONSTRAINTS_st {\n    ASN1_INTEGER *requireExplicitPolicy;\n    ASN1_INTEGER *inhibitPolicyMapping;\n} POLICY_CONSTRAINTS;\n\n/* Proxy certificate structures, see RFC 3820 */\ntypedef struct PROXY_POLICY_st {\n    ASN1_OBJECT *policyLanguage;\n    ASN1_OCTET_STRING *policy;\n} PROXY_POLICY;\n\ntypedef struct PROXY_CERT_INFO_EXTENSION_st {\n    ASN1_INTEGER *pcPathLengthConstraint;\n    PROXY_POLICY *proxyPolicy;\n} PROXY_CERT_INFO_EXTENSION;\n\nDECLARE_ASN1_FUNCTIONS(PROXY_POLICY)\nDECLARE_ASN1_FUNCTIONS(PROXY_CERT_INFO_EXTENSION)\n\nstruct ISSUING_DIST_POINT_st {\n    DIST_POINT_NAME *distpoint;\n    int onlyuser;\n    int onlyCA;\n    ASN1_BIT_STRING *onlysomereasons;\n    int indirectCRL;\n    int onlyattr;\n};\n\n/* Values in idp_flags field */\n/* IDP present */\n# define IDP_PRESENT     0x1\n/* IDP values inconsistent */\n# define IDP_INVALID     0x2\n/* onlyuser true */\n# define IDP_ONLYUSER    0x4\n/* onlyCA true */\n# define IDP_ONLYCA      0x8\n/* onlyattr true */\n# define IDP_ONLYATTR    0x10\n/* indirectCRL true */\n# define IDP_INDIRECT    0x20\n/* onlysomereasons present */\n# define IDP_REASONS     0x40\n\n# define X509V3_conf_err(val) ERR_add_error_data(6, \"section:\", val->section, \\\n\",name:\", val->name, \",value:\", val->value);\n\n# define X509V3_set_ctx_test(ctx) \\\n                        X509V3_set_ctx(ctx, NULL, NULL, NULL, NULL, CTX_TEST)\n# define X509V3_set_ctx_nodb(ctx) (ctx)->db = NULL;\n\n# define EXT_BITSTRING(nid, table) { nid, 0, ASN1_ITEM_ref(ASN1_BIT_STRING), \\\n                        0,0,0,0, \\\n                        0,0, \\\n                        (X509V3_EXT_I2V)i2v_ASN1_BIT_STRING, \\\n                        (X509V3_EXT_V2I)v2i_ASN1_BIT_STRING, \\\n                        NULL, NULL, \\\n                        table}\n\n# define EXT_IA5STRING(nid) { nid, 0, ASN1_ITEM_ref(ASN1_IA5STRING), \\\n                        0,0,0,0, \\\n                        (X509V3_EXT_I2S)i2s_ASN1_IA5STRING, \\\n                        (X509V3_EXT_S2I)s2i_ASN1_IA5STRING, \\\n                        0,0,0,0, \\\n                        NULL}\n\n# define EXT_END { -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}\n\n/* X509_PURPOSE stuff */\n\n# define EXFLAG_BCONS            0x1\n# define EXFLAG_KUSAGE           0x2\n# define EXFLAG_XKUSAGE          0x4\n# define EXFLAG_NSCERT           0x8\n\n# define EXFLAG_CA               0x10\n/* Really self issued not necessarily self signed */\n# define EXFLAG_SI               0x20\n# define EXFLAG_V1               0x40\n# define EXFLAG_INVALID          0x80\n# define EXFLAG_SET              0x100\n# define EXFLAG_CRITICAL         0x200\n# define EXFLAG_PROXY            0x400\n\n# define EXFLAG_INVALID_POLICY   0x800\n# define EXFLAG_FRESHEST         0x1000\n/* Self signed */\n# define EXFLAG_SS               0x2000\n\n# define KU_DIGITAL_SIGNATURE    0x0080\n# define KU_NON_REPUDIATION      0x0040\n# define KU_KEY_ENCIPHERMENT     0x0020\n# define KU_DATA_ENCIPHERMENT    0x0010\n# define KU_KEY_AGREEMENT        0x0008\n# define KU_KEY_CERT_SIGN        0x0004\n# define KU_CRL_SIGN             0x0002\n# define KU_ENCIPHER_ONLY        0x0001\n# define KU_DECIPHER_ONLY        0x8000\n\n# define NS_SSL_CLIENT           0x80\n# define NS_SSL_SERVER           0x40\n# define NS_SMIME                0x20\n# define NS_OBJSIGN              0x10\n# define NS_SSL_CA               0x04\n# define NS_SMIME_CA             0x02\n# define NS_OBJSIGN_CA           0x01\n# define NS_ANY_CA               (NS_SSL_CA|NS_SMIME_CA|NS_OBJSIGN_CA)\n\n# define XKU_SSL_SERVER          0x1\n# define XKU_SSL_CLIENT          0x2\n# define XKU_SMIME               0x4\n# define XKU_CODE_SIGN           0x8\n# define XKU_SGC                 0x10\n# define XKU_OCSP_SIGN           0x20\n# define XKU_TIMESTAMP           0x40\n# define XKU_DVCS                0x80\n# define XKU_ANYEKU              0x100\n\n# define X509_PURPOSE_DYNAMIC    0x1\n# define X509_PURPOSE_DYNAMIC_NAME       0x2\n\ntypedef struct x509_purpose_st {\n    int purpose;\n    int trust;                  /* Default trust ID */\n    int flags;\n    int (*check_purpose) (const struct x509_purpose_st *, const X509 *, int);\n    char *name;\n    char *sname;\n    void *usr_data;\n} X509_PURPOSE;\n\n# define X509_PURPOSE_SSL_CLIENT         1\n# define X509_PURPOSE_SSL_SERVER         2\n# define X509_PURPOSE_NS_SSL_SERVER      3\n# define X509_PURPOSE_SMIME_SIGN         4\n# define X509_PURPOSE_SMIME_ENCRYPT      5\n# define X509_PURPOSE_CRL_SIGN           6\n# define X509_PURPOSE_ANY                7\n# define X509_PURPOSE_OCSP_HELPER        8\n# define X509_PURPOSE_TIMESTAMP_SIGN     9\n\n# define X509_PURPOSE_MIN                1\n# define X509_PURPOSE_MAX                9\n\n/* Flags for X509V3_EXT_print() */\n\n# define X509V3_EXT_UNKNOWN_MASK         (0xfL << 16)\n/* Return error for unknown extensions */\n# define X509V3_EXT_DEFAULT              0\n/* Print error for unknown extensions */\n# define X509V3_EXT_ERROR_UNKNOWN        (1L << 16)\n/* ASN1 parse unknown extensions */\n# define X509V3_EXT_PARSE_UNKNOWN        (2L << 16)\n/* BIO_dump unknown extensions */\n# define X509V3_EXT_DUMP_UNKNOWN         (3L << 16)\n\n/* Flags for X509V3_add1_i2d */\n\n# define X509V3_ADD_OP_MASK              0xfL\n# define X509V3_ADD_DEFAULT              0L\n# define X509V3_ADD_APPEND               1L\n# define X509V3_ADD_REPLACE              2L\n# define X509V3_ADD_REPLACE_EXISTING     3L\n# define X509V3_ADD_KEEP_EXISTING        4L\n# define X509V3_ADD_DELETE               5L\n# define X509V3_ADD_SILENT               0x10\n\nDECLARE_STACK_OF(X509_PURPOSE)\n\nDECLARE_ASN1_FUNCTIONS(BASIC_CONSTRAINTS)\n\nDECLARE_ASN1_FUNCTIONS(SXNET)\nDECLARE_ASN1_FUNCTIONS(SXNETID)\n\nint SXNET_add_id_asc(SXNET **psx, char *zone, char *user, int userlen);\nint SXNET_add_id_ulong(SXNET **psx, unsigned long lzone, char *user,\n                       int userlen);\nint SXNET_add_id_INTEGER(SXNET **psx, ASN1_INTEGER *izone, char *user,\n                         int userlen);\n\nASN1_OCTET_STRING *SXNET_get_id_asc(SXNET *sx, char *zone);\nASN1_OCTET_STRING *SXNET_get_id_ulong(SXNET *sx, unsigned long lzone);\nASN1_OCTET_STRING *SXNET_get_id_INTEGER(SXNET *sx, ASN1_INTEGER *zone);\n\nDECLARE_ASN1_FUNCTIONS(AUTHORITY_KEYID)\n\nDECLARE_ASN1_FUNCTIONS(PKEY_USAGE_PERIOD)\n\nDECLARE_ASN1_FUNCTIONS(GENERAL_NAME)\nGENERAL_NAME *GENERAL_NAME_dup(GENERAL_NAME *a);\nint GENERAL_NAME_cmp(GENERAL_NAME *a, GENERAL_NAME *b);\n\nASN1_BIT_STRING *v2i_ASN1_BIT_STRING(X509V3_EXT_METHOD *method,\n                                     X509V3_CTX *ctx,\n                                     STACK_OF(CONF_VALUE) *nval);\nSTACK_OF(CONF_VALUE) *i2v_ASN1_BIT_STRING(X509V3_EXT_METHOD *method,\n                                          ASN1_BIT_STRING *bits,\n                                          STACK_OF(CONF_VALUE) *extlist);\n\nSTACK_OF(CONF_VALUE) *i2v_GENERAL_NAME(X509V3_EXT_METHOD *method,\n                                       GENERAL_NAME *gen,\n                                       STACK_OF(CONF_VALUE) *ret);\nint GENERAL_NAME_print(BIO *out, GENERAL_NAME *gen);\n\nDECLARE_ASN1_FUNCTIONS(GENERAL_NAMES)\n\nSTACK_OF(CONF_VALUE) *i2v_GENERAL_NAMES(X509V3_EXT_METHOD *method,\n                                        GENERAL_NAMES *gen,\n                                        STACK_OF(CONF_VALUE) *extlist);\nGENERAL_NAMES *v2i_GENERAL_NAMES(const X509V3_EXT_METHOD *method,\n                                 X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *nval);\n\nDECLARE_ASN1_FUNCTIONS(OTHERNAME)\nDECLARE_ASN1_FUNCTIONS(EDIPARTYNAME)\nint OTHERNAME_cmp(OTHERNAME *a, OTHERNAME *b);\nvoid GENERAL_NAME_set0_value(GENERAL_NAME *a, int type, void *value);\nvoid *GENERAL_NAME_get0_value(GENERAL_NAME *a, int *ptype);\nint GENERAL_NAME_set0_othername(GENERAL_NAME *gen,\n                                ASN1_OBJECT *oid, ASN1_TYPE *value);\nint GENERAL_NAME_get0_otherName(GENERAL_NAME *gen,\n                                ASN1_OBJECT **poid, ASN1_TYPE **pvalue);\n\nchar *i2s_ASN1_OCTET_STRING(X509V3_EXT_METHOD *method,\n                            ASN1_OCTET_STRING *ia5);\nASN1_OCTET_STRING *s2i_ASN1_OCTET_STRING(X509V3_EXT_METHOD *method,\n                                         X509V3_CTX *ctx, char *str);\n\nDECLARE_ASN1_FUNCTIONS(EXTENDED_KEY_USAGE)\nint i2a_ACCESS_DESCRIPTION(BIO *bp, ACCESS_DESCRIPTION *a);\n\nDECLARE_ASN1_FUNCTIONS(CERTIFICATEPOLICIES)\nDECLARE_ASN1_FUNCTIONS(POLICYINFO)\nDECLARE_ASN1_FUNCTIONS(POLICYQUALINFO)\nDECLARE_ASN1_FUNCTIONS(USERNOTICE)\nDECLARE_ASN1_FUNCTIONS(NOTICEREF)\n\nDECLARE_ASN1_FUNCTIONS(CRL_DIST_POINTS)\nDECLARE_ASN1_FUNCTIONS(DIST_POINT)\nDECLARE_ASN1_FUNCTIONS(DIST_POINT_NAME)\nDECLARE_ASN1_FUNCTIONS(ISSUING_DIST_POINT)\n\nint DIST_POINT_set_dpname(DIST_POINT_NAME *dpn, X509_NAME *iname);\n\nint NAME_CONSTRAINTS_check(X509 *x, NAME_CONSTRAINTS *nc);\n\nDECLARE_ASN1_FUNCTIONS(ACCESS_DESCRIPTION)\nDECLARE_ASN1_FUNCTIONS(AUTHORITY_INFO_ACCESS)\n\nDECLARE_ASN1_ITEM(POLICY_MAPPING)\nDECLARE_ASN1_ALLOC_FUNCTIONS(POLICY_MAPPING)\nDECLARE_ASN1_ITEM(POLICY_MAPPINGS)\n\nDECLARE_ASN1_ITEM(GENERAL_SUBTREE)\nDECLARE_ASN1_ALLOC_FUNCTIONS(GENERAL_SUBTREE)\n\nDECLARE_ASN1_ITEM(NAME_CONSTRAINTS)\nDECLARE_ASN1_ALLOC_FUNCTIONS(NAME_CONSTRAINTS)\n\nDECLARE_ASN1_ALLOC_FUNCTIONS(POLICY_CONSTRAINTS)\nDECLARE_ASN1_ITEM(POLICY_CONSTRAINTS)\n\nGENERAL_NAME *a2i_GENERAL_NAME(GENERAL_NAME *out,\n                               const X509V3_EXT_METHOD *method,\n                               X509V3_CTX *ctx, int gen_type, char *value,\n                               int is_nc);\n\n# ifdef HEADER_CONF_H\nGENERAL_NAME *v2i_GENERAL_NAME(const X509V3_EXT_METHOD *method,\n                               X509V3_CTX *ctx, CONF_VALUE *cnf);\nGENERAL_NAME *v2i_GENERAL_NAME_ex(GENERAL_NAME *out,\n                                  const X509V3_EXT_METHOD *method,\n                                  X509V3_CTX *ctx, CONF_VALUE *cnf,\n                                  int is_nc);\nvoid X509V3_conf_free(CONF_VALUE *val);\n\nX509_EXTENSION *X509V3_EXT_nconf_nid(CONF *conf, X509V3_CTX *ctx, int ext_nid,\n                                     char *value);\nX509_EXTENSION *X509V3_EXT_nconf(CONF *conf, X509V3_CTX *ctx, char *name,\n                                 char *value);\nint X509V3_EXT_add_nconf_sk(CONF *conf, X509V3_CTX *ctx, char *section,\n                            STACK_OF(X509_EXTENSION) **sk);\nint X509V3_EXT_add_nconf(CONF *conf, X509V3_CTX *ctx, char *section,\n                         X509 *cert);\nint X509V3_EXT_REQ_add_nconf(CONF *conf, X509V3_CTX *ctx, char *section,\n                             X509_REQ *req);\nint X509V3_EXT_CRL_add_nconf(CONF *conf, X509V3_CTX *ctx, char *section,\n                             X509_CRL *crl);\n\nX509_EXTENSION *X509V3_EXT_conf_nid(LHASH_OF(CONF_VALUE) *conf,\n                                    X509V3_CTX *ctx, int ext_nid,\n                                    char *value);\nX509_EXTENSION *X509V3_EXT_conf(LHASH_OF(CONF_VALUE) *conf, X509V3_CTX *ctx,\n                                char *name, char *value);\nint X509V3_EXT_add_conf(LHASH_OF(CONF_VALUE) *conf, X509V3_CTX *ctx,\n                        char *section, X509 *cert);\nint X509V3_EXT_REQ_add_conf(LHASH_OF(CONF_VALUE) *conf, X509V3_CTX *ctx,\n                            char *section, X509_REQ *req);\nint X509V3_EXT_CRL_add_conf(LHASH_OF(CONF_VALUE) *conf, X509V3_CTX *ctx,\n                            char *section, X509_CRL *crl);\n\nint X509V3_add_value_bool_nf(char *name, int asn1_bool,\n                             STACK_OF(CONF_VALUE) **extlist);\nint X509V3_get_value_bool(CONF_VALUE *value, int *asn1_bool);\nint X509V3_get_value_int(CONF_VALUE *value, ASN1_INTEGER **aint);\nvoid X509V3_set_nconf(X509V3_CTX *ctx, CONF *conf);\nvoid X509V3_set_conf_lhash(X509V3_CTX *ctx, LHASH_OF(CONF_VALUE) *lhash);\n# endif\n\nchar *X509V3_get_string(X509V3_CTX *ctx, char *name, char *section);\nSTACK_OF(CONF_VALUE) *X509V3_get_section(X509V3_CTX *ctx, char *section);\nvoid X509V3_string_free(X509V3_CTX *ctx, char *str);\nvoid X509V3_section_free(X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *section);\nvoid X509V3_set_ctx(X509V3_CTX *ctx, X509 *issuer, X509 *subject,\n                    X509_REQ *req, X509_CRL *crl, int flags);\n\nint X509V3_add_value(const char *name, const char *value,\n                     STACK_OF(CONF_VALUE) **extlist);\nint X509V3_add_value_uchar(const char *name, const unsigned char *value,\n                           STACK_OF(CONF_VALUE) **extlist);\nint X509V3_add_value_bool(const char *name, int asn1_bool,\n                          STACK_OF(CONF_VALUE) **extlist);\nint X509V3_add_value_int(const char *name, ASN1_INTEGER *aint,\n                         STACK_OF(CONF_VALUE) **extlist);\nchar *i2s_ASN1_INTEGER(X509V3_EXT_METHOD *meth, ASN1_INTEGER *aint);\nASN1_INTEGER *s2i_ASN1_INTEGER(X509V3_EXT_METHOD *meth, char *value);\nchar *i2s_ASN1_ENUMERATED(X509V3_EXT_METHOD *meth, ASN1_ENUMERATED *aint);\nchar *i2s_ASN1_ENUMERATED_TABLE(X509V3_EXT_METHOD *meth,\n                                ASN1_ENUMERATED *aint);\nint X509V3_EXT_add(X509V3_EXT_METHOD *ext);\nint X509V3_EXT_add_list(X509V3_EXT_METHOD *extlist);\nint X509V3_EXT_add_alias(int nid_to, int nid_from);\nvoid X509V3_EXT_cleanup(void);\n\nconst X509V3_EXT_METHOD *X509V3_EXT_get(X509_EXTENSION *ext);\nconst X509V3_EXT_METHOD *X509V3_EXT_get_nid(int nid);\nint X509V3_add_standard_extensions(void);\nSTACK_OF(CONF_VALUE) *X509V3_parse_list(const char *line);\nvoid *X509V3_EXT_d2i(X509_EXTENSION *ext);\nvoid *X509V3_get_d2i(STACK_OF(X509_EXTENSION) *x, int nid, int *crit,\n                     int *idx);\nint X509V3_EXT_free(int nid, void *ext_data);\n\nX509_EXTENSION *X509V3_EXT_i2d(int ext_nid, int crit, void *ext_struc);\nint X509V3_add1_i2d(STACK_OF(X509_EXTENSION) **x, int nid, void *value,\n                    int crit, unsigned long flags);\n\nchar *hex_to_string(const unsigned char *buffer, long len);\nunsigned char *string_to_hex(const char *str, long *len);\nint name_cmp(const char *name, const char *cmp);\n\nvoid X509V3_EXT_val_prn(BIO *out, STACK_OF(CONF_VALUE) *val, int indent,\n                        int ml);\nint X509V3_EXT_print(BIO *out, X509_EXTENSION *ext, unsigned long flag,\n                     int indent);\nint X509V3_EXT_print_fp(FILE *out, X509_EXTENSION *ext, int flag, int indent);\n\nint X509V3_extensions_print(BIO *out, char *title,\n                            STACK_OF(X509_EXTENSION) *exts,\n                            unsigned long flag, int indent);\n\nint X509_check_ca(X509 *x);\nint X509_check_purpose(X509 *x, int id, int ca);\nint X509_supported_extension(X509_EXTENSION *ex);\nint X509_PURPOSE_set(int *p, int purpose);\nint X509_check_issued(X509 *issuer, X509 *subject);\nint X509_check_akid(X509 *issuer, AUTHORITY_KEYID *akid);\nint X509_PURPOSE_get_count(void);\nX509_PURPOSE *X509_PURPOSE_get0(int idx);\nint X509_PURPOSE_get_by_sname(char *sname);\nint X509_PURPOSE_get_by_id(int id);\nint X509_PURPOSE_add(int id, int trust, int flags,\n                     int (*ck) (const X509_PURPOSE *, const X509 *, int),\n                     char *name, char *sname, void *arg);\nchar *X509_PURPOSE_get0_name(X509_PURPOSE *xp);\nchar *X509_PURPOSE_get0_sname(X509_PURPOSE *xp);\nint X509_PURPOSE_get_trust(X509_PURPOSE *xp);\nvoid X509_PURPOSE_cleanup(void);\nint X509_PURPOSE_get_id(X509_PURPOSE *);\n\nSTACK_OF(OPENSSL_STRING) *X509_get1_email(X509 *x);\nSTACK_OF(OPENSSL_STRING) *X509_REQ_get1_email(X509_REQ *x);\nvoid X509_email_free(STACK_OF(OPENSSL_STRING) *sk);\nSTACK_OF(OPENSSL_STRING) *X509_get1_ocsp(X509 *x);\n/* Flags for X509_check_* functions */\n\n/*\n * Always check subject name for host match even if subject alt names present\n */\n# define X509_CHECK_FLAG_ALWAYS_CHECK_SUBJECT    0x1\n/* Disable wildcard matching for dnsName fields and common name. */\n# define X509_CHECK_FLAG_NO_WILDCARDS    0x2\n/* Wildcards must not match a partial label. */\n# define X509_CHECK_FLAG_NO_PARTIAL_WILDCARDS 0x4\n/* Allow (non-partial) wildcards to match multiple labels. */\n# define X509_CHECK_FLAG_MULTI_LABEL_WILDCARDS 0x8\n/* Constraint verifier subdomain patterns to match a single labels. */\n# define X509_CHECK_FLAG_SINGLE_LABEL_SUBDOMAINS 0x10\n/*\n * Match reference identifiers starting with \".\" to any sub-domain.\n * This is a non-public flag, turned on implicitly when the subject\n * reference identity is a DNS name.\n */\n# define _X509_CHECK_FLAG_DOT_SUBDOMAINS 0x8000\n\nint X509_check_host(X509 *x, const char *chk, size_t chklen,\n                    unsigned int flags, char **peername);\nint X509_check_email(X509 *x, const char *chk, size_t chklen,\n                     unsigned int flags);\nint X509_check_ip(X509 *x, const unsigned char *chk, size_t chklen,\n                  unsigned int flags);\nint X509_check_ip_asc(X509 *x, const char *ipasc, unsigned int flags);\n\nASN1_OCTET_STRING *a2i_IPADDRESS(const char *ipasc);\nASN1_OCTET_STRING *a2i_IPADDRESS_NC(const char *ipasc);\nint a2i_ipadd(unsigned char *ipout, const char *ipasc);\nint X509V3_NAME_from_section(X509_NAME *nm, STACK_OF(CONF_VALUE) *dn_sk,\n                             unsigned long chtype);\n\nvoid X509_POLICY_NODE_print(BIO *out, X509_POLICY_NODE *node, int indent);\nDECLARE_STACK_OF(X509_POLICY_NODE)\n\n# ifndef OPENSSL_NO_RFC3779\n\ntypedef struct ASRange_st {\n    ASN1_INTEGER *min, *max;\n} ASRange;\n\n#  define ASIdOrRange_id          0\n#  define ASIdOrRange_range       1\n\ntypedef struct ASIdOrRange_st {\n    int type;\n    union {\n        ASN1_INTEGER *id;\n        ASRange *range;\n    } u;\n} ASIdOrRange;\n\ntypedef STACK_OF(ASIdOrRange) ASIdOrRanges;\nDECLARE_STACK_OF(ASIdOrRange)\n\n#  define ASIdentifierChoice_inherit              0\n#  define ASIdentifierChoice_asIdsOrRanges        1\n\ntypedef struct ASIdentifierChoice_st {\n    int type;\n    union {\n        ASN1_NULL *inherit;\n        ASIdOrRanges *asIdsOrRanges;\n    } u;\n} ASIdentifierChoice;\n\ntypedef struct ASIdentifiers_st {\n    ASIdentifierChoice *asnum, *rdi;\n} ASIdentifiers;\n\nDECLARE_ASN1_FUNCTIONS(ASRange)\nDECLARE_ASN1_FUNCTIONS(ASIdOrRange)\nDECLARE_ASN1_FUNCTIONS(ASIdentifierChoice)\nDECLARE_ASN1_FUNCTIONS(ASIdentifiers)\n\ntypedef struct IPAddressRange_st {\n    ASN1_BIT_STRING *min, *max;\n} IPAddressRange;\n\n#  define IPAddressOrRange_addressPrefix  0\n#  define IPAddressOrRange_addressRange   1\n\ntypedef struct IPAddressOrRange_st {\n    int type;\n    union {\n        ASN1_BIT_STRING *addressPrefix;\n        IPAddressRange *addressRange;\n    } u;\n} IPAddressOrRange;\n\ntypedef STACK_OF(IPAddressOrRange) IPAddressOrRanges;\nDECLARE_STACK_OF(IPAddressOrRange)\n\n#  define IPAddressChoice_inherit                 0\n#  define IPAddressChoice_addressesOrRanges       1\n\ntypedef struct IPAddressChoice_st {\n    int type;\n    union {\n        ASN1_NULL *inherit;\n        IPAddressOrRanges *addressesOrRanges;\n    } u;\n} IPAddressChoice;\n\ntypedef struct IPAddressFamily_st {\n    ASN1_OCTET_STRING *addressFamily;\n    IPAddressChoice *ipAddressChoice;\n} IPAddressFamily;\n\ntypedef STACK_OF(IPAddressFamily) IPAddrBlocks;\nDECLARE_STACK_OF(IPAddressFamily)\n\nDECLARE_ASN1_FUNCTIONS(IPAddressRange)\nDECLARE_ASN1_FUNCTIONS(IPAddressOrRange)\nDECLARE_ASN1_FUNCTIONS(IPAddressChoice)\nDECLARE_ASN1_FUNCTIONS(IPAddressFamily)\n\n/*\n * API tag for elements of the ASIdentifer SEQUENCE.\n */\n#  define V3_ASID_ASNUM   0\n#  define V3_ASID_RDI     1\n\n/*\n * AFI values, assigned by IANA.  It'd be nice to make the AFI\n * handling code totally generic, but there are too many little things\n * that would need to be defined for other address families for it to\n * be worth the trouble.\n */\n#  define IANA_AFI_IPV4   1\n#  define IANA_AFI_IPV6   2\n\n/*\n * Utilities to construct and extract values from RFC3779 extensions,\n * since some of the encodings (particularly for IP address prefixes\n * and ranges) are a bit tedious to work with directly.\n */\nint v3_asid_add_inherit(ASIdentifiers *asid, int which);\nint v3_asid_add_id_or_range(ASIdentifiers *asid, int which,\n                            ASN1_INTEGER *min, ASN1_INTEGER *max);\nint v3_addr_add_inherit(IPAddrBlocks *addr,\n                        const unsigned afi, const unsigned *safi);\nint v3_addr_add_prefix(IPAddrBlocks *addr,\n                       const unsigned afi, const unsigned *safi,\n                       unsigned char *a, const int prefixlen);\nint v3_addr_add_range(IPAddrBlocks *addr,\n                      const unsigned afi, const unsigned *safi,\n                      unsigned char *min, unsigned char *max);\nunsigned v3_addr_get_afi(const IPAddressFamily *f);\nint v3_addr_get_range(IPAddressOrRange *aor, const unsigned afi,\n                      unsigned char *min, unsigned char *max,\n                      const int length);\n\n/*\n * Canonical forms.\n */\nint v3_asid_is_canonical(ASIdentifiers *asid);\nint v3_addr_is_canonical(IPAddrBlocks *addr);\nint v3_asid_canonize(ASIdentifiers *asid);\nint v3_addr_canonize(IPAddrBlocks *addr);\n\n/*\n * Tests for inheritance and containment.\n */\nint v3_asid_inherits(ASIdentifiers *asid);\nint v3_addr_inherits(IPAddrBlocks *addr);\nint v3_asid_subset(ASIdentifiers *a, ASIdentifiers *b);\nint v3_addr_subset(IPAddrBlocks *a, IPAddrBlocks *b);\n\n/*\n * Check whether RFC 3779 extensions nest properly in chains.\n */\nint v3_asid_validate_path(X509_STORE_CTX *);\nint v3_addr_validate_path(X509_STORE_CTX *);\nint v3_asid_validate_resource_set(STACK_OF(X509) *chain,\n                                  ASIdentifiers *ext, int allow_inheritance);\nint v3_addr_validate_resource_set(STACK_OF(X509) *chain,\n                                  IPAddrBlocks *ext, int allow_inheritance);\n\n# endif                         /* OPENSSL_NO_RFC3779 */\n\n/* BEGIN ERROR CODES */\n/*\n * The following lines are auto generated by the script mkerr.pl. Any changes\n * made after this point may be overwritten when the script is next run.\n */\nvoid ERR_load_X509V3_strings(void);\n\n/* Error codes for the X509V3 functions. */\n\n/* Function codes. */\n# define X509V3_F_A2I_GENERAL_NAME                        164\n# define X509V3_F_ASIDENTIFIERCHOICE_CANONIZE             161\n# define X509V3_F_ASIDENTIFIERCHOICE_IS_CANONICAL         162\n# define X509V3_F_COPY_EMAIL                              122\n# define X509V3_F_COPY_ISSUER                             123\n# define X509V3_F_DO_DIRNAME                              144\n# define X509V3_F_DO_EXT_CONF                             124\n# define X509V3_F_DO_EXT_I2D                              135\n# define X509V3_F_DO_EXT_NCONF                            151\n# define X509V3_F_DO_I2V_NAME_CONSTRAINTS                 148\n# define X509V3_F_GNAMES_FROM_SECTNAME                    156\n# define X509V3_F_HEX_TO_STRING                           111\n# define X509V3_F_I2S_ASN1_ENUMERATED                     121\n# define X509V3_F_I2S_ASN1_IA5STRING                      149\n# define X509V3_F_I2S_ASN1_INTEGER                        120\n# define X509V3_F_I2V_AUTHORITY_INFO_ACCESS               138\n# define X509V3_F_NOTICE_SECTION                          132\n# define X509V3_F_NREF_NOS                                133\n# define X509V3_F_POLICY_SECTION                          131\n# define X509V3_F_PROCESS_PCI_VALUE                       150\n# define X509V3_F_R2I_CERTPOL                             130\n# define X509V3_F_R2I_PCI                                 155\n# define X509V3_F_S2I_ASN1_IA5STRING                      100\n# define X509V3_F_S2I_ASN1_INTEGER                        108\n# define X509V3_F_S2I_ASN1_OCTET_STRING                   112\n# define X509V3_F_S2I_ASN1_SKEY_ID                        114\n# define X509V3_F_S2I_SKEY_ID                             115\n# define X509V3_F_SET_DIST_POINT_NAME                     158\n# define X509V3_F_STRING_TO_HEX                           113\n# define X509V3_F_SXNET_ADD_ID_ASC                        125\n# define X509V3_F_SXNET_ADD_ID_INTEGER                    126\n# define X509V3_F_SXNET_ADD_ID_ULONG                      127\n# define X509V3_F_SXNET_GET_ID_ASC                        128\n# define X509V3_F_SXNET_GET_ID_ULONG                      129\n# define X509V3_F_V2I_ASIDENTIFIERS                       163\n# define X509V3_F_V2I_ASN1_BIT_STRING                     101\n# define X509V3_F_V2I_AUTHORITY_INFO_ACCESS               139\n# define X509V3_F_V2I_AUTHORITY_KEYID                     119\n# define X509V3_F_V2I_BASIC_CONSTRAINTS                   102\n# define X509V3_F_V2I_CRLD                                134\n# define X509V3_F_V2I_EXTENDED_KEY_USAGE                  103\n# define X509V3_F_V2I_GENERAL_NAMES                       118\n# define X509V3_F_V2I_GENERAL_NAME_EX                     117\n# define X509V3_F_V2I_IDP                                 157\n# define X509V3_F_V2I_IPADDRBLOCKS                        159\n# define X509V3_F_V2I_ISSUER_ALT                          153\n# define X509V3_F_V2I_NAME_CONSTRAINTS                    147\n# define X509V3_F_V2I_POLICY_CONSTRAINTS                  146\n# define X509V3_F_V2I_POLICY_MAPPINGS                     145\n# define X509V3_F_V2I_SUBJECT_ALT                         154\n# define X509V3_F_V3_ADDR_VALIDATE_PATH_INTERNAL          160\n# define X509V3_F_V3_GENERIC_EXTENSION                    116\n# define X509V3_F_X509V3_ADD1_I2D                         140\n# define X509V3_F_X509V3_ADD_VALUE                        105\n# define X509V3_F_X509V3_EXT_ADD                          104\n# define X509V3_F_X509V3_EXT_ADD_ALIAS                    106\n# define X509V3_F_X509V3_EXT_CONF                         107\n# define X509V3_F_X509V3_EXT_FREE                         165\n# define X509V3_F_X509V3_EXT_I2D                          136\n# define X509V3_F_X509V3_EXT_NCONF                        152\n# define X509V3_F_X509V3_GET_SECTION                      142\n# define X509V3_F_X509V3_GET_STRING                       143\n# define X509V3_F_X509V3_GET_VALUE_BOOL                   110\n# define X509V3_F_X509V3_PARSE_LIST                       109\n# define X509V3_F_X509_PURPOSE_ADD                        137\n# define X509V3_F_X509_PURPOSE_SET                        141\n\n/* Reason codes. */\n# define X509V3_R_BAD_IP_ADDRESS                          118\n# define X509V3_R_BAD_OBJECT                              119\n# define X509V3_R_BN_DEC2BN_ERROR                         100\n# define X509V3_R_BN_TO_ASN1_INTEGER_ERROR                101\n# define X509V3_R_CANNOT_FIND_FREE_FUNCTION               168\n# define X509V3_R_DIRNAME_ERROR                           149\n# define X509V3_R_DISTPOINT_ALREADY_SET                   160\n# define X509V3_R_DUPLICATE_ZONE_ID                       133\n# define X509V3_R_ERROR_CONVERTING_ZONE                   131\n# define X509V3_R_ERROR_CREATING_EXTENSION                144\n# define X509V3_R_ERROR_IN_EXTENSION                      128\n# define X509V3_R_EXPECTED_A_SECTION_NAME                 137\n# define X509V3_R_EXTENSION_EXISTS                        145\n# define X509V3_R_EXTENSION_NAME_ERROR                    115\n# define X509V3_R_EXTENSION_NOT_FOUND                     102\n# define X509V3_R_EXTENSION_SETTING_NOT_SUPPORTED         103\n# define X509V3_R_EXTENSION_VALUE_ERROR                   116\n# define X509V3_R_ILLEGAL_EMPTY_EXTENSION                 151\n# define X509V3_R_ILLEGAL_HEX_DIGIT                       113\n# define X509V3_R_INCORRECT_POLICY_SYNTAX_TAG             152\n# define X509V3_R_INVALID_ASNUMBER                        162\n# define X509V3_R_INVALID_ASRANGE                         163\n# define X509V3_R_INVALID_BOOLEAN_STRING                  104\n# define X509V3_R_INVALID_EXTENSION_STRING                105\n# define X509V3_R_INVALID_INHERITANCE                     165\n# define X509V3_R_INVALID_IPADDRESS                       166\n# define X509V3_R_INVALID_MULTIPLE_RDNS                   161\n# define X509V3_R_INVALID_NAME                            106\n# define X509V3_R_INVALID_NULL_ARGUMENT                   107\n# define X509V3_R_INVALID_NULL_NAME                       108\n# define X509V3_R_INVALID_NULL_VALUE                      109\n# define X509V3_R_INVALID_NUMBER                          140\n# define X509V3_R_INVALID_NUMBERS                         141\n# define X509V3_R_INVALID_OBJECT_IDENTIFIER               110\n# define X509V3_R_INVALID_OPTION                          138\n# define X509V3_R_INVALID_POLICY_IDENTIFIER               134\n# define X509V3_R_INVALID_PROXY_POLICY_SETTING            153\n# define X509V3_R_INVALID_PURPOSE                         146\n# define X509V3_R_INVALID_SAFI                            164\n# define X509V3_R_INVALID_SECTION                         135\n# define X509V3_R_INVALID_SYNTAX                          143\n# define X509V3_R_ISSUER_DECODE_ERROR                     126\n# define X509V3_R_MISSING_VALUE                           124\n# define X509V3_R_NEED_ORGANIZATION_AND_NUMBERS           142\n# define X509V3_R_NO_CONFIG_DATABASE                      136\n# define X509V3_R_NO_ISSUER_CERTIFICATE                   121\n# define X509V3_R_NO_ISSUER_DETAILS                       127\n# define X509V3_R_NO_POLICY_IDENTIFIER                    139\n# define X509V3_R_NO_PROXY_CERT_POLICY_LANGUAGE_DEFINED   154\n# define X509V3_R_NO_PUBLIC_KEY                           114\n# define X509V3_R_NO_SUBJECT_DETAILS                      125\n# define X509V3_R_ODD_NUMBER_OF_DIGITS                    112\n# define X509V3_R_OPERATION_NOT_DEFINED                   148\n# define X509V3_R_OTHERNAME_ERROR                         147\n# define X509V3_R_POLICY_LANGUAGE_ALREADY_DEFINED         155\n# define X509V3_R_POLICY_PATH_LENGTH                      156\n# define X509V3_R_POLICY_PATH_LENGTH_ALREADY_DEFINED      157\n# define X509V3_R_POLICY_SYNTAX_NOT_CURRENTLY_SUPPORTED   158\n# define X509V3_R_POLICY_WHEN_PROXY_LANGUAGE_REQUIRES_NO_POLICY 159\n# define X509V3_R_SECTION_NOT_FOUND                       150\n# define X509V3_R_UNABLE_TO_GET_ISSUER_DETAILS            122\n# define X509V3_R_UNABLE_TO_GET_ISSUER_KEYID              123\n# define X509V3_R_UNKNOWN_BIT_STRING_ARGUMENT             111\n# define X509V3_R_UNKNOWN_EXTENSION                       129\n# define X509V3_R_UNKNOWN_EXTENSION_NAME                  130\n# define X509V3_R_UNKNOWN_OPTION                          120\n# define X509V3_R_UNSUPPORTED_OPTION                      117\n# define X509V3_R_UNSUPPORTED_TYPE                        167\n# define X509V3_R_USER_TOO_LONG                           132\n\n#ifdef  __cplusplus\n}\n#endif\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/x86_64/include/openssl/aes.h",
    "content": "/* crypto/aes/aes.h */\n/* ====================================================================\n * Copyright (c) 1998-2002 The OpenSSL Project.  All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n *\n * 1. Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n *\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in\n *    the documentation and/or other materials provided with the\n *    distribution.\n *\n * 3. All advertising materials mentioning features or use of this\n *    software must display the following acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit. (http://www.openssl.org/)\"\n *\n * 4. The names \"OpenSSL Toolkit\" and \"OpenSSL Project\" must not be used to\n *    endorse or promote products derived from this software without\n *    prior written permission. For written permission, please contact\n *    openssl-core@openssl.org.\n *\n * 5. Products derived from this software may not be called \"OpenSSL\"\n *    nor may \"OpenSSL\" appear in their names without prior written\n *    permission of the OpenSSL Project.\n *\n * 6. Redistributions of any form whatsoever must retain the following\n *    acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit (http://www.openssl.org/)\"\n *\n * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY\n * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\n * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR\n * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\n * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,\n * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED\n * OF THE POSSIBILITY OF SUCH DAMAGE.\n * ====================================================================\n *\n */\n\n#ifndef HEADER_AES_H\n# define HEADER_AES_H\n\n# include <openssl/opensslconf.h>\n\n# ifdef OPENSSL_NO_AES\n#  error AES is disabled.\n# endif\n\n# include <stddef.h>\n\n# define AES_ENCRYPT     1\n# define AES_DECRYPT     0\n\n/*\n * Because array size can't be a const in C, the following two are macros.\n * Both sizes are in bytes.\n */\n# define AES_MAXNR 14\n# define AES_BLOCK_SIZE 16\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n/* This should be a hidden type, but EVP requires that the size be known */\nstruct aes_key_st {\n# ifdef AES_LONG\n    unsigned long rd_key[4 * (AES_MAXNR + 1)];\n# else\n    unsigned int rd_key[4 * (AES_MAXNR + 1)];\n# endif\n    int rounds;\n};\ntypedef struct aes_key_st AES_KEY;\n\nconst char *AES_options(void);\n\nint AES_set_encrypt_key(const unsigned char *userKey, const int bits,\n                        AES_KEY *key);\nint AES_set_decrypt_key(const unsigned char *userKey, const int bits,\n                        AES_KEY *key);\n\nint private_AES_set_encrypt_key(const unsigned char *userKey, const int bits,\n                                AES_KEY *key);\nint private_AES_set_decrypt_key(const unsigned char *userKey, const int bits,\n                                AES_KEY *key);\n\nvoid AES_encrypt(const unsigned char *in, unsigned char *out,\n                 const AES_KEY *key);\nvoid AES_decrypt(const unsigned char *in, unsigned char *out,\n                 const AES_KEY *key);\n\nvoid AES_ecb_encrypt(const unsigned char *in, unsigned char *out,\n                     const AES_KEY *key, const int enc);\nvoid AES_cbc_encrypt(const unsigned char *in, unsigned char *out,\n                     size_t length, const AES_KEY *key,\n                     unsigned char *ivec, const int enc);\nvoid AES_cfb128_encrypt(const unsigned char *in, unsigned char *out,\n                        size_t length, const AES_KEY *key,\n                        unsigned char *ivec, int *num, const int enc);\nvoid AES_cfb1_encrypt(const unsigned char *in, unsigned char *out,\n                      size_t length, const AES_KEY *key,\n                      unsigned char *ivec, int *num, const int enc);\nvoid AES_cfb8_encrypt(const unsigned char *in, unsigned char *out,\n                      size_t length, const AES_KEY *key,\n                      unsigned char *ivec, int *num, const int enc);\nvoid AES_ofb128_encrypt(const unsigned char *in, unsigned char *out,\n                        size_t length, const AES_KEY *key,\n                        unsigned char *ivec, int *num);\nvoid AES_ctr128_encrypt(const unsigned char *in, unsigned char *out,\n                        size_t length, const AES_KEY *key,\n                        unsigned char ivec[AES_BLOCK_SIZE],\n                        unsigned char ecount_buf[AES_BLOCK_SIZE],\n                        unsigned int *num);\n/* NB: the IV is _two_ blocks long */\nvoid AES_ige_encrypt(const unsigned char *in, unsigned char *out,\n                     size_t length, const AES_KEY *key,\n                     unsigned char *ivec, const int enc);\n/* NB: the IV is _four_ blocks long */\nvoid AES_bi_ige_encrypt(const unsigned char *in, unsigned char *out,\n                        size_t length, const AES_KEY *key,\n                        const AES_KEY *key2, const unsigned char *ivec,\n                        const int enc);\n\nint AES_wrap_key(AES_KEY *key, const unsigned char *iv,\n                 unsigned char *out,\n                 const unsigned char *in, unsigned int inlen);\nint AES_unwrap_key(AES_KEY *key, const unsigned char *iv,\n                   unsigned char *out,\n                   const unsigned char *in, unsigned int inlen);\n\n\n#ifdef  __cplusplus\n}\n#endif\n\n#endif                          /* !HEADER_AES_H */\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/x86_64/include/openssl/asn1.h",
    "content": "/* crypto/asn1/asn1.h */\n/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)\n * All rights reserved.\n *\n * This package is an SSL implementation written\n * by Eric Young (eay@cryptsoft.com).\n * The implementation was written so as to conform with Netscapes SSL.\n *\n * This library is free for commercial and non-commercial use as long as\n * the following conditions are aheared to.  The following conditions\n * apply to all code found in this distribution, be it the RC4, RSA,\n * lhash, DES, etc., code; not just the SSL code.  The SSL documentation\n * included with this distribution is covered by the same copyright terms\n * except that the holder is Tim Hudson (tjh@cryptsoft.com).\n *\n * Copyright remains Eric Young's, and as such any Copyright notices in\n * the code are not to be removed.\n * If this package is used in a product, Eric Young should be given attribution\n * as the author of the parts of the library used.\n * This can be in the form of a textual message at program startup or\n * in documentation (online or textual) provided with the package.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the copyright\n *    notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in the\n *    documentation and/or other materials provided with the distribution.\n * 3. All advertising materials mentioning features or use of this software\n *    must display the following acknowledgement:\n *    \"This product includes cryptographic software written by\n *     Eric Young (eay@cryptsoft.com)\"\n *    The word 'cryptographic' can be left out if the rouines from the library\n *    being used are not cryptographic related :-).\n * 4. If you include any Windows specific code (or a derivative thereof) from\n *    the apps directory (application code) you must include an acknowledgement:\n *    \"This product includes software written by Tim Hudson (tjh@cryptsoft.com)\"\n *\n * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n * SUCH DAMAGE.\n *\n * The licence and distribution terms for any publically available version or\n * derivative of this code cannot be changed.  i.e. this code cannot simply be\n * copied and put under another distribution licence\n * [including the GNU Public Licence.]\n */\n\n#ifndef HEADER_ASN1_H\n# define HEADER_ASN1_H\n\n# include <time.h>\n# include <openssl/e_os2.h>\n# ifndef OPENSSL_NO_BIO\n#  include <openssl/bio.h>\n# endif\n# include <openssl/stack.h>\n# include <openssl/safestack.h>\n\n# include <openssl/symhacks.h>\n\n# include <openssl/ossl_typ.h>\n# ifndef OPENSSL_NO_DEPRECATED\n#  include <openssl/bn.h>\n# endif\n\n# ifdef OPENSSL_BUILD_SHLIBCRYPTO\n#  undef OPENSSL_EXTERN\n#  define OPENSSL_EXTERN OPENSSL_EXPORT\n# endif\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n# define V_ASN1_UNIVERSAL                0x00\n# define V_ASN1_APPLICATION              0x40\n# define V_ASN1_CONTEXT_SPECIFIC         0x80\n# define V_ASN1_PRIVATE                  0xc0\n\n# define V_ASN1_CONSTRUCTED              0x20\n# define V_ASN1_PRIMITIVE_TAG            0x1f\n# define V_ASN1_PRIMATIVE_TAG            0x1f\n\n# define V_ASN1_APP_CHOOSE               -2/* let the recipient choose */\n# define V_ASN1_OTHER                    -3/* used in ASN1_TYPE */\n# define V_ASN1_ANY                      -4/* used in ASN1 template code */\n\n# define V_ASN1_NEG                      0x100/* negative flag */\n\n# define V_ASN1_UNDEF                    -1\n# define V_ASN1_EOC                      0\n# define V_ASN1_BOOLEAN                  1 /**/\n# define V_ASN1_INTEGER                  2\n# define V_ASN1_NEG_INTEGER              (2 | V_ASN1_NEG)\n# define V_ASN1_BIT_STRING               3\n# define V_ASN1_OCTET_STRING             4\n# define V_ASN1_NULL                     5\n# define V_ASN1_OBJECT                   6\n# define V_ASN1_OBJECT_DESCRIPTOR        7\n# define V_ASN1_EXTERNAL                 8\n# define V_ASN1_REAL                     9\n# define V_ASN1_ENUMERATED               10\n# define V_ASN1_NEG_ENUMERATED           (10 | V_ASN1_NEG)\n# define V_ASN1_UTF8STRING               12\n# define V_ASN1_SEQUENCE                 16\n# define V_ASN1_SET                      17\n# define V_ASN1_NUMERICSTRING            18 /**/\n# define V_ASN1_PRINTABLESTRING          19\n# define V_ASN1_T61STRING                20\n# define V_ASN1_TELETEXSTRING            20/* alias */\n# define V_ASN1_VIDEOTEXSTRING           21 /**/\n# define V_ASN1_IA5STRING                22\n# define V_ASN1_UTCTIME                  23\n# define V_ASN1_GENERALIZEDTIME          24 /**/\n# define V_ASN1_GRAPHICSTRING            25 /**/\n# define V_ASN1_ISO64STRING              26 /**/\n# define V_ASN1_VISIBLESTRING            26/* alias */\n# define V_ASN1_GENERALSTRING            27 /**/\n# define V_ASN1_UNIVERSALSTRING          28 /**/\n# define V_ASN1_BMPSTRING                30\n/* For use with d2i_ASN1_type_bytes() */\n# define B_ASN1_NUMERICSTRING    0x0001\n# define B_ASN1_PRINTABLESTRING  0x0002\n# define B_ASN1_T61STRING        0x0004\n# define B_ASN1_TELETEXSTRING    0x0004\n# define B_ASN1_VIDEOTEXSTRING   0x0008\n# define B_ASN1_IA5STRING        0x0010\n# define B_ASN1_GRAPHICSTRING    0x0020\n# define B_ASN1_ISO64STRING      0x0040\n# define B_ASN1_VISIBLESTRING    0x0040\n# define B_ASN1_GENERALSTRING    0x0080\n# define B_ASN1_UNIVERSALSTRING  0x0100\n# define B_ASN1_OCTET_STRING     0x0200\n# define B_ASN1_BIT_STRING       0x0400\n# define B_ASN1_BMPSTRING        0x0800\n# define B_ASN1_UNKNOWN          0x1000\n# define B_ASN1_UTF8STRING       0x2000\n# define B_ASN1_UTCTIME          0x4000\n# define B_ASN1_GENERALIZEDTIME  0x8000\n# define B_ASN1_SEQUENCE         0x10000\n/* For use with ASN1_mbstring_copy() */\n# define MBSTRING_FLAG           0x1000\n# define MBSTRING_UTF8           (MBSTRING_FLAG)\n# define MBSTRING_ASC            (MBSTRING_FLAG|1)\n# define MBSTRING_BMP            (MBSTRING_FLAG|2)\n# define MBSTRING_UNIV           (MBSTRING_FLAG|4)\n# define SMIME_OLDMIME           0x400\n# define SMIME_CRLFEOL           0x800\n# define SMIME_STREAM            0x1000\n    struct X509_algor_st;\nDECLARE_STACK_OF(X509_ALGOR)\n\n# define DECLARE_ASN1_SET_OF(type)/* filled in by mkstack.pl */\n# define IMPLEMENT_ASN1_SET_OF(type)/* nothing, no longer needed */\n\n/*\n * We MUST make sure that, except for constness, asn1_ctx_st and\n * asn1_const_ctx are exactly the same.  Fortunately, as soon as the old ASN1\n * parsing macros are gone, we can throw this away as well...\n */\ntypedef struct asn1_ctx_st {\n    unsigned char *p;           /* work char pointer */\n    int eos;                    /* end of sequence read for indefinite\n                                 * encoding */\n    int error;                  /* error code to use when returning an error */\n    int inf;                    /* constructed if 0x20, indefinite is 0x21 */\n    int tag;                    /* tag from last 'get object' */\n    int xclass;                 /* class from last 'get object' */\n    long slen;                  /* length of last 'get object' */\n    unsigned char *max;         /* largest value of p allowed */\n    unsigned char *q;           /* temporary variable */\n    unsigned char **pp;         /* variable */\n    int line;                   /* used in error processing */\n} ASN1_CTX;\n\ntypedef struct asn1_const_ctx_st {\n    const unsigned char *p;     /* work char pointer */\n    int eos;                    /* end of sequence read for indefinite\n                                 * encoding */\n    int error;                  /* error code to use when returning an error */\n    int inf;                    /* constructed if 0x20, indefinite is 0x21 */\n    int tag;                    /* tag from last 'get object' */\n    int xclass;                 /* class from last 'get object' */\n    long slen;                  /* length of last 'get object' */\n    const unsigned char *max;   /* largest value of p allowed */\n    const unsigned char *q;     /* temporary variable */\n    const unsigned char **pp;   /* variable */\n    int line;                   /* used in error processing */\n} ASN1_const_CTX;\n\n/*\n * These are used internally in the ASN1_OBJECT to keep track of whether the\n * names and data need to be free()ed\n */\n# define ASN1_OBJECT_FLAG_DYNAMIC         0x01/* internal use */\n# define ASN1_OBJECT_FLAG_CRITICAL        0x02/* critical x509v3 object id */\n# define ASN1_OBJECT_FLAG_DYNAMIC_STRINGS 0x04/* internal use */\n# define ASN1_OBJECT_FLAG_DYNAMIC_DATA    0x08/* internal use */\nstruct asn1_object_st {\n    const char *sn, *ln;\n    int nid;\n    int length;\n    const unsigned char *data;  /* data remains const after init */\n    int flags;                  /* Should we free this one */\n};\n\n# define ASN1_STRING_FLAG_BITS_LEFT 0x08/* Set if 0x07 has bits left value */\n/*\n * This indicates that the ASN1_STRING is not a real value but just a place\n * holder for the location where indefinite length constructed data should be\n * inserted in the memory buffer\n */\n# define ASN1_STRING_FLAG_NDEF 0x010\n\n/*\n * This flag is used by the CMS code to indicate that a string is not\n * complete and is a place holder for content when it had all been accessed.\n * The flag will be reset when content has been written to it.\n */\n\n# define ASN1_STRING_FLAG_CONT 0x020\n/*\n * This flag is used by ASN1 code to indicate an ASN1_STRING is an MSTRING\n * type.\n */\n# define ASN1_STRING_FLAG_MSTRING 0x040\n/* This is the base type that holds just about everything :-) */\nstruct asn1_string_st {\n    int length;\n    int type;\n    unsigned char *data;\n    /*\n     * The value of the following field depends on the type being held.  It\n     * is mostly being used for BIT_STRING so if the input data has a\n     * non-zero 'unused bits' value, it will be handled correctly\n     */\n    long flags;\n};\n\n/*\n * ASN1_ENCODING structure: this is used to save the received encoding of an\n * ASN1 type. This is useful to get round problems with invalid encodings\n * which can break signatures.\n */\n\ntypedef struct ASN1_ENCODING_st {\n    unsigned char *enc;         /* DER encoding */\n    long len;                   /* Length of encoding */\n    int modified;               /* set to 1 if 'enc' is invalid */\n} ASN1_ENCODING;\n\n/* Used with ASN1 LONG type: if a long is set to this it is omitted */\n# define ASN1_LONG_UNDEF 0x7fffffffL\n\n# define STABLE_FLAGS_MALLOC     0x01\n# define STABLE_NO_MASK          0x02\n# define DIRSTRING_TYPE  \\\n (B_ASN1_PRINTABLESTRING|B_ASN1_T61STRING|B_ASN1_BMPSTRING|B_ASN1_UTF8STRING)\n# define PKCS9STRING_TYPE (DIRSTRING_TYPE|B_ASN1_IA5STRING)\n\ntypedef struct asn1_string_table_st {\n    int nid;\n    long minsize;\n    long maxsize;\n    unsigned long mask;\n    unsigned long flags;\n} ASN1_STRING_TABLE;\n\nDECLARE_STACK_OF(ASN1_STRING_TABLE)\n\n/* size limits: this stuff is taken straight from RFC2459 */\n\n# define ub_name                         32768\n# define ub_common_name                  64\n# define ub_locality_name                128\n# define ub_state_name                   128\n# define ub_organization_name            64\n# define ub_organization_unit_name       64\n# define ub_title                        64\n# define ub_email_address                128\n\n/*\n * Declarations for template structures: for full definitions see asn1t.h\n */\ntypedef struct ASN1_TEMPLATE_st ASN1_TEMPLATE;\ntypedef struct ASN1_TLC_st ASN1_TLC;\n/* This is just an opaque pointer */\ntypedef struct ASN1_VALUE_st ASN1_VALUE;\n\n/* Declare ASN1 functions: the implement macro in in asn1t.h */\n\n# define DECLARE_ASN1_FUNCTIONS(type) DECLARE_ASN1_FUNCTIONS_name(type, type)\n\n# define DECLARE_ASN1_ALLOC_FUNCTIONS(type) \\\n        DECLARE_ASN1_ALLOC_FUNCTIONS_name(type, type)\n\n# define DECLARE_ASN1_FUNCTIONS_name(type, name) \\\n        DECLARE_ASN1_ALLOC_FUNCTIONS_name(type, name) \\\n        DECLARE_ASN1_ENCODE_FUNCTIONS(type, name, name)\n\n# define DECLARE_ASN1_FUNCTIONS_fname(type, itname, name) \\\n        DECLARE_ASN1_ALLOC_FUNCTIONS_name(type, name) \\\n        DECLARE_ASN1_ENCODE_FUNCTIONS(type, itname, name)\n\n# define DECLARE_ASN1_ENCODE_FUNCTIONS(type, itname, name) \\\n        type *d2i_##name(type **a, const unsigned char **in, long len); \\\n        int i2d_##name(type *a, unsigned char **out); \\\n        DECLARE_ASN1_ITEM(itname)\n\n# define DECLARE_ASN1_ENCODE_FUNCTIONS_const(type, name) \\\n        type *d2i_##name(type **a, const unsigned char **in, long len); \\\n        int i2d_##name(const type *a, unsigned char **out); \\\n        DECLARE_ASN1_ITEM(name)\n\n# define DECLARE_ASN1_NDEF_FUNCTION(name) \\\n        int i2d_##name##_NDEF(name *a, unsigned char **out);\n\n# define DECLARE_ASN1_FUNCTIONS_const(name) \\\n        DECLARE_ASN1_ALLOC_FUNCTIONS(name) \\\n        DECLARE_ASN1_ENCODE_FUNCTIONS_const(name, name)\n\n# define DECLARE_ASN1_ALLOC_FUNCTIONS_name(type, name) \\\n        type *name##_new(void); \\\n        void name##_free(type *a);\n\n# define DECLARE_ASN1_PRINT_FUNCTION(stname) \\\n        DECLARE_ASN1_PRINT_FUNCTION_fname(stname, stname)\n\n# define DECLARE_ASN1_PRINT_FUNCTION_fname(stname, fname) \\\n        int fname##_print_ctx(BIO *out, stname *x, int indent, \\\n                                         const ASN1_PCTX *pctx);\n\n# define D2I_OF(type) type *(*)(type **,const unsigned char **,long)\n# define I2D_OF(type) int (*)(type *,unsigned char **)\n# define I2D_OF_const(type) int (*)(const type *,unsigned char **)\n\n# define CHECKED_D2I_OF(type, d2i) \\\n    ((d2i_of_void*) (1 ? d2i : ((D2I_OF(type))0)))\n# define CHECKED_I2D_OF(type, i2d) \\\n    ((i2d_of_void*) (1 ? i2d : ((I2D_OF(type))0)))\n# define CHECKED_NEW_OF(type, xnew) \\\n    ((void *(*)(void)) (1 ? xnew : ((type *(*)(void))0)))\n# define CHECKED_PTR_OF(type, p) \\\n    ((void*) (1 ? p : (type*)0))\n# define CHECKED_PPTR_OF(type, p) \\\n    ((void**) (1 ? p : (type**)0))\n\n# define TYPEDEF_D2I_OF(type) typedef type *d2i_of_##type(type **,const unsigned char **,long)\n# define TYPEDEF_I2D_OF(type) typedef int i2d_of_##type(type *,unsigned char **)\n# define TYPEDEF_D2I2D_OF(type) TYPEDEF_D2I_OF(type); TYPEDEF_I2D_OF(type)\n\nTYPEDEF_D2I2D_OF(void);\n\n/*-\n * The following macros and typedefs allow an ASN1_ITEM\n * to be embedded in a structure and referenced. Since\n * the ASN1_ITEM pointers need to be globally accessible\n * (possibly from shared libraries) they may exist in\n * different forms. On platforms that support it the\n * ASN1_ITEM structure itself will be globally exported.\n * Other platforms will export a function that returns\n * an ASN1_ITEM pointer.\n *\n * To handle both cases transparently the macros below\n * should be used instead of hard coding an ASN1_ITEM\n * pointer in a structure.\n *\n * The structure will look like this:\n *\n * typedef struct SOMETHING_st {\n *      ...\n *      ASN1_ITEM_EXP *iptr;\n *      ...\n * } SOMETHING;\n *\n * It would be initialised as e.g.:\n *\n * SOMETHING somevar = {...,ASN1_ITEM_ref(X509),...};\n *\n * and the actual pointer extracted with:\n *\n * const ASN1_ITEM *it = ASN1_ITEM_ptr(somevar.iptr);\n *\n * Finally an ASN1_ITEM pointer can be extracted from an\n * appropriate reference with: ASN1_ITEM_rptr(X509). This\n * would be used when a function takes an ASN1_ITEM * argument.\n *\n */\n\n# ifndef OPENSSL_EXPORT_VAR_AS_FUNCTION\n\n/* ASN1_ITEM pointer exported type */\ntypedef const ASN1_ITEM ASN1_ITEM_EXP;\n\n/* Macro to obtain ASN1_ITEM pointer from exported type */\n#  define ASN1_ITEM_ptr(iptr) (iptr)\n\n/* Macro to include ASN1_ITEM pointer from base type */\n#  define ASN1_ITEM_ref(iptr) (&(iptr##_it))\n\n#  define ASN1_ITEM_rptr(ref) (&(ref##_it))\n\n#  define DECLARE_ASN1_ITEM(name) \\\n        OPENSSL_EXTERN const ASN1_ITEM name##_it;\n\n# else\n\n/*\n * Platforms that can't easily handle shared global variables are declared as\n * functions returning ASN1_ITEM pointers.\n */\n\n/* ASN1_ITEM pointer exported type */\ntypedef const ASN1_ITEM *ASN1_ITEM_EXP (void);\n\n/* Macro to obtain ASN1_ITEM pointer from exported type */\n#  define ASN1_ITEM_ptr(iptr) (iptr())\n\n/* Macro to include ASN1_ITEM pointer from base type */\n#  define ASN1_ITEM_ref(iptr) (iptr##_it)\n\n#  define ASN1_ITEM_rptr(ref) (ref##_it())\n\n#  define DECLARE_ASN1_ITEM(name) \\\n        const ASN1_ITEM * name##_it(void);\n\n# endif\n\n/* Parameters used by ASN1_STRING_print_ex() */\n\n/*\n * These determine which characters to escape: RFC2253 special characters,\n * control characters and MSB set characters\n */\n\n# define ASN1_STRFLGS_ESC_2253           1\n# define ASN1_STRFLGS_ESC_CTRL           2\n# define ASN1_STRFLGS_ESC_MSB            4\n\n/*\n * This flag determines how we do escaping: normally RC2253 backslash only,\n * set this to use backslash and quote.\n */\n\n# define ASN1_STRFLGS_ESC_QUOTE          8\n\n/* These three flags are internal use only. */\n\n/* Character is a valid PrintableString character */\n# define CHARTYPE_PRINTABLESTRING        0x10\n/* Character needs escaping if it is the first character */\n# define CHARTYPE_FIRST_ESC_2253         0x20\n/* Character needs escaping if it is the last character */\n# define CHARTYPE_LAST_ESC_2253          0x40\n\n/*\n * NB the internal flags are safely reused below by flags handled at the top\n * level.\n */\n\n/*\n * If this is set we convert all character strings to UTF8 first\n */\n\n# define ASN1_STRFLGS_UTF8_CONVERT       0x10\n\n/*\n * If this is set we don't attempt to interpret content: just assume all\n * strings are 1 byte per character. This will produce some pretty odd\n * looking output!\n */\n\n# define ASN1_STRFLGS_IGNORE_TYPE        0x20\n\n/* If this is set we include the string type in the output */\n# define ASN1_STRFLGS_SHOW_TYPE          0x40\n\n/*\n * This determines which strings to display and which to 'dump' (hex dump of\n * content octets or DER encoding). We can only dump non character strings or\n * everything. If we don't dump 'unknown' they are interpreted as character\n * strings with 1 octet per character and are subject to the usual escaping\n * options.\n */\n\n# define ASN1_STRFLGS_DUMP_ALL           0x80\n# define ASN1_STRFLGS_DUMP_UNKNOWN       0x100\n\n/*\n * These determine what 'dumping' does, we can dump the content octets or the\n * DER encoding: both use the RFC2253 #XXXXX notation.\n */\n\n# define ASN1_STRFLGS_DUMP_DER           0x200\n\n/*\n * All the string flags consistent with RFC2253, escaping control characters\n * isn't essential in RFC2253 but it is advisable anyway.\n */\n\n# define ASN1_STRFLGS_RFC2253    (ASN1_STRFLGS_ESC_2253 | \\\n                                ASN1_STRFLGS_ESC_CTRL | \\\n                                ASN1_STRFLGS_ESC_MSB | \\\n                                ASN1_STRFLGS_UTF8_CONVERT | \\\n                                ASN1_STRFLGS_DUMP_UNKNOWN | \\\n                                ASN1_STRFLGS_DUMP_DER)\n\nDECLARE_STACK_OF(ASN1_INTEGER)\nDECLARE_ASN1_SET_OF(ASN1_INTEGER)\n\nDECLARE_STACK_OF(ASN1_GENERALSTRING)\n\ntypedef struct asn1_type_st {\n    int type;\n    union {\n        char *ptr;\n        ASN1_BOOLEAN boolean;\n        ASN1_STRING *asn1_string;\n        ASN1_OBJECT *object;\n        ASN1_INTEGER *integer;\n        ASN1_ENUMERATED *enumerated;\n        ASN1_BIT_STRING *bit_string;\n        ASN1_OCTET_STRING *octet_string;\n        ASN1_PRINTABLESTRING *printablestring;\n        ASN1_T61STRING *t61string;\n        ASN1_IA5STRING *ia5string;\n        ASN1_GENERALSTRING *generalstring;\n        ASN1_BMPSTRING *bmpstring;\n        ASN1_UNIVERSALSTRING *universalstring;\n        ASN1_UTCTIME *utctime;\n        ASN1_GENERALIZEDTIME *generalizedtime;\n        ASN1_VISIBLESTRING *visiblestring;\n        ASN1_UTF8STRING *utf8string;\n        /*\n         * set and sequence are left complete and still contain the set or\n         * sequence bytes\n         */\n        ASN1_STRING *set;\n        ASN1_STRING *sequence;\n        ASN1_VALUE *asn1_value;\n    } value;\n} ASN1_TYPE;\n\nDECLARE_STACK_OF(ASN1_TYPE)\nDECLARE_ASN1_SET_OF(ASN1_TYPE)\n\ntypedef STACK_OF(ASN1_TYPE) ASN1_SEQUENCE_ANY;\n\nDECLARE_ASN1_ENCODE_FUNCTIONS_const(ASN1_SEQUENCE_ANY, ASN1_SEQUENCE_ANY)\nDECLARE_ASN1_ENCODE_FUNCTIONS_const(ASN1_SEQUENCE_ANY, ASN1_SET_ANY)\n\ntypedef struct NETSCAPE_X509_st {\n    ASN1_OCTET_STRING *header;\n    X509 *cert;\n} NETSCAPE_X509;\n\n/* This is used to contain a list of bit names */\ntypedef struct BIT_STRING_BITNAME_st {\n    int bitnum;\n    const char *lname;\n    const char *sname;\n} BIT_STRING_BITNAME;\n\n# define M_ASN1_STRING_length(x) ((x)->length)\n# define M_ASN1_STRING_length_set(x, n)  ((x)->length = (n))\n# define M_ASN1_STRING_type(x)   ((x)->type)\n# define M_ASN1_STRING_data(x)   ((x)->data)\n\n/* Macros for string operations */\n# define M_ASN1_BIT_STRING_new() (ASN1_BIT_STRING *)\\\n                ASN1_STRING_type_new(V_ASN1_BIT_STRING)\n# define M_ASN1_BIT_STRING_free(a)       ASN1_STRING_free((ASN1_STRING *)a)\n# define M_ASN1_BIT_STRING_dup(a) (ASN1_BIT_STRING *)\\\n                ASN1_STRING_dup((const ASN1_STRING *)a)\n# define M_ASN1_BIT_STRING_cmp(a,b) ASN1_STRING_cmp(\\\n                (const ASN1_STRING *)a,(const ASN1_STRING *)b)\n# define M_ASN1_BIT_STRING_set(a,b,c) ASN1_STRING_set((ASN1_STRING *)a,b,c)\n\n# define M_ASN1_INTEGER_new()    (ASN1_INTEGER *)\\\n                ASN1_STRING_type_new(V_ASN1_INTEGER)\n# define M_ASN1_INTEGER_free(a)          ASN1_STRING_free((ASN1_STRING *)a)\n# define M_ASN1_INTEGER_dup(a) (ASN1_INTEGER *)\\\n                ASN1_STRING_dup((const ASN1_STRING *)a)\n# define M_ASN1_INTEGER_cmp(a,b) ASN1_STRING_cmp(\\\n                (const ASN1_STRING *)a,(const ASN1_STRING *)b)\n\n# define M_ASN1_ENUMERATED_new() (ASN1_ENUMERATED *)\\\n                ASN1_STRING_type_new(V_ASN1_ENUMERATED)\n# define M_ASN1_ENUMERATED_free(a)       ASN1_STRING_free((ASN1_STRING *)a)\n# define M_ASN1_ENUMERATED_dup(a) (ASN1_ENUMERATED *)\\\n                ASN1_STRING_dup((const ASN1_STRING *)a)\n# define M_ASN1_ENUMERATED_cmp(a,b)      ASN1_STRING_cmp(\\\n                (const ASN1_STRING *)a,(const ASN1_STRING *)b)\n\n# define M_ASN1_OCTET_STRING_new()       (ASN1_OCTET_STRING *)\\\n                ASN1_STRING_type_new(V_ASN1_OCTET_STRING)\n# define M_ASN1_OCTET_STRING_free(a)     ASN1_STRING_free((ASN1_STRING *)a)\n# define M_ASN1_OCTET_STRING_dup(a) (ASN1_OCTET_STRING *)\\\n                ASN1_STRING_dup((const ASN1_STRING *)a)\n# define M_ASN1_OCTET_STRING_cmp(a,b) ASN1_STRING_cmp(\\\n                (const ASN1_STRING *)a,(const ASN1_STRING *)b)\n# define M_ASN1_OCTET_STRING_set(a,b,c)  ASN1_STRING_set((ASN1_STRING *)a,b,c)\n# define M_ASN1_OCTET_STRING_print(a,b)  ASN1_STRING_print(a,(ASN1_STRING *)b)\n# define M_i2d_ASN1_OCTET_STRING(a,pp) \\\n                i2d_ASN1_bytes((ASN1_STRING *)a,pp,V_ASN1_OCTET_STRING,\\\n                V_ASN1_UNIVERSAL)\n\n# define B_ASN1_TIME \\\n                        B_ASN1_UTCTIME | \\\n                        B_ASN1_GENERALIZEDTIME\n\n# define B_ASN1_PRINTABLE \\\n                        B_ASN1_NUMERICSTRING| \\\n                        B_ASN1_PRINTABLESTRING| \\\n                        B_ASN1_T61STRING| \\\n                        B_ASN1_IA5STRING| \\\n                        B_ASN1_BIT_STRING| \\\n                        B_ASN1_UNIVERSALSTRING|\\\n                        B_ASN1_BMPSTRING|\\\n                        B_ASN1_UTF8STRING|\\\n                        B_ASN1_SEQUENCE|\\\n                        B_ASN1_UNKNOWN\n\n# define B_ASN1_DIRECTORYSTRING \\\n                        B_ASN1_PRINTABLESTRING| \\\n                        B_ASN1_TELETEXSTRING|\\\n                        B_ASN1_BMPSTRING|\\\n                        B_ASN1_UNIVERSALSTRING|\\\n                        B_ASN1_UTF8STRING\n\n# define B_ASN1_DISPLAYTEXT \\\n                        B_ASN1_IA5STRING| \\\n                        B_ASN1_VISIBLESTRING| \\\n                        B_ASN1_BMPSTRING|\\\n                        B_ASN1_UTF8STRING\n\n# define M_ASN1_PRINTABLE_new()  ASN1_STRING_type_new(V_ASN1_T61STRING)\n# define M_ASN1_PRINTABLE_free(a)        ASN1_STRING_free((ASN1_STRING *)a)\n# define M_i2d_ASN1_PRINTABLE(a,pp) i2d_ASN1_bytes((ASN1_STRING *)a,\\\n                pp,a->type,V_ASN1_UNIVERSAL)\n# define M_d2i_ASN1_PRINTABLE(a,pp,l) \\\n                d2i_ASN1_type_bytes((ASN1_STRING **)a,pp,l, \\\n                        B_ASN1_PRINTABLE)\n\n# define M_DIRECTORYSTRING_new() ASN1_STRING_type_new(V_ASN1_PRINTABLESTRING)\n# define M_DIRECTORYSTRING_free(a)       ASN1_STRING_free((ASN1_STRING *)a)\n# define M_i2d_DIRECTORYSTRING(a,pp) i2d_ASN1_bytes((ASN1_STRING *)a,\\\n                                                pp,a->type,V_ASN1_UNIVERSAL)\n# define M_d2i_DIRECTORYSTRING(a,pp,l) \\\n                d2i_ASN1_type_bytes((ASN1_STRING **)a,pp,l, \\\n                        B_ASN1_DIRECTORYSTRING)\n\n# define M_DISPLAYTEXT_new() ASN1_STRING_type_new(V_ASN1_VISIBLESTRING)\n# define M_DISPLAYTEXT_free(a) ASN1_STRING_free((ASN1_STRING *)a)\n# define M_i2d_DISPLAYTEXT(a,pp) i2d_ASN1_bytes((ASN1_STRING *)a,\\\n                                                pp,a->type,V_ASN1_UNIVERSAL)\n# define M_d2i_DISPLAYTEXT(a,pp,l) \\\n                d2i_ASN1_type_bytes((ASN1_STRING **)a,pp,l, \\\n                        B_ASN1_DISPLAYTEXT)\n\n# define M_ASN1_PRINTABLESTRING_new() (ASN1_PRINTABLESTRING *)\\\n                ASN1_STRING_type_new(V_ASN1_PRINTABLESTRING)\n# define M_ASN1_PRINTABLESTRING_free(a)  ASN1_STRING_free((ASN1_STRING *)a)\n# define M_i2d_ASN1_PRINTABLESTRING(a,pp) \\\n                i2d_ASN1_bytes((ASN1_STRING *)a,pp,V_ASN1_PRINTABLESTRING,\\\n                V_ASN1_UNIVERSAL)\n# define M_d2i_ASN1_PRINTABLESTRING(a,pp,l) \\\n                (ASN1_PRINTABLESTRING *)d2i_ASN1_type_bytes\\\n                ((ASN1_STRING **)a,pp,l,B_ASN1_PRINTABLESTRING)\n\n# define M_ASN1_T61STRING_new()  (ASN1_T61STRING *)\\\n                ASN1_STRING_type_new(V_ASN1_T61STRING)\n# define M_ASN1_T61STRING_free(a)        ASN1_STRING_free((ASN1_STRING *)a)\n# define M_i2d_ASN1_T61STRING(a,pp) \\\n                i2d_ASN1_bytes((ASN1_STRING *)a,pp,V_ASN1_T61STRING,\\\n                V_ASN1_UNIVERSAL)\n# define M_d2i_ASN1_T61STRING(a,pp,l) \\\n                (ASN1_T61STRING *)d2i_ASN1_type_bytes\\\n                ((ASN1_STRING **)a,pp,l,B_ASN1_T61STRING)\n\n# define M_ASN1_IA5STRING_new()  (ASN1_IA5STRING *)\\\n                ASN1_STRING_type_new(V_ASN1_IA5STRING)\n# define M_ASN1_IA5STRING_free(a)        ASN1_STRING_free((ASN1_STRING *)a)\n# define M_ASN1_IA5STRING_dup(a) \\\n                (ASN1_IA5STRING *)ASN1_STRING_dup((const ASN1_STRING *)a)\n# define M_i2d_ASN1_IA5STRING(a,pp) \\\n                i2d_ASN1_bytes((ASN1_STRING *)a,pp,V_ASN1_IA5STRING,\\\n                        V_ASN1_UNIVERSAL)\n# define M_d2i_ASN1_IA5STRING(a,pp,l) \\\n                (ASN1_IA5STRING *)d2i_ASN1_type_bytes((ASN1_STRING **)a,pp,l,\\\n                        B_ASN1_IA5STRING)\n\n# define M_ASN1_UTCTIME_new()    (ASN1_UTCTIME *)\\\n                ASN1_STRING_type_new(V_ASN1_UTCTIME)\n# define M_ASN1_UTCTIME_free(a)  ASN1_STRING_free((ASN1_STRING *)a)\n# define M_ASN1_UTCTIME_dup(a) (ASN1_UTCTIME *)\\\n                ASN1_STRING_dup((const ASN1_STRING *)a)\n\n# define M_ASN1_GENERALIZEDTIME_new()    (ASN1_GENERALIZEDTIME *)\\\n                ASN1_STRING_type_new(V_ASN1_GENERALIZEDTIME)\n# define M_ASN1_GENERALIZEDTIME_free(a)  ASN1_STRING_free((ASN1_STRING *)a)\n# define M_ASN1_GENERALIZEDTIME_dup(a) (ASN1_GENERALIZEDTIME *)ASN1_STRING_dup(\\\n        (const ASN1_STRING *)a)\n\n# define M_ASN1_TIME_new()       (ASN1_TIME *)\\\n                ASN1_STRING_type_new(V_ASN1_UTCTIME)\n# define M_ASN1_TIME_free(a)     ASN1_STRING_free((ASN1_STRING *)a)\n# define M_ASN1_TIME_dup(a) (ASN1_TIME *)\\\n        ASN1_STRING_dup((const ASN1_STRING *)a)\n\n# define M_ASN1_GENERALSTRING_new()      (ASN1_GENERALSTRING *)\\\n                ASN1_STRING_type_new(V_ASN1_GENERALSTRING)\n# define M_ASN1_GENERALSTRING_free(a)    ASN1_STRING_free((ASN1_STRING *)a)\n# define M_i2d_ASN1_GENERALSTRING(a,pp) \\\n                i2d_ASN1_bytes((ASN1_STRING *)a,pp,V_ASN1_GENERALSTRING,\\\n                        V_ASN1_UNIVERSAL)\n# define M_d2i_ASN1_GENERALSTRING(a,pp,l) \\\n                (ASN1_GENERALSTRING *)d2i_ASN1_type_bytes\\\n                ((ASN1_STRING **)a,pp,l,B_ASN1_GENERALSTRING)\n\n# define M_ASN1_UNIVERSALSTRING_new()    (ASN1_UNIVERSALSTRING *)\\\n                ASN1_STRING_type_new(V_ASN1_UNIVERSALSTRING)\n# define M_ASN1_UNIVERSALSTRING_free(a)  ASN1_STRING_free((ASN1_STRING *)a)\n# define M_i2d_ASN1_UNIVERSALSTRING(a,pp) \\\n                i2d_ASN1_bytes((ASN1_STRING *)a,pp,V_ASN1_UNIVERSALSTRING,\\\n                        V_ASN1_UNIVERSAL)\n# define M_d2i_ASN1_UNIVERSALSTRING(a,pp,l) \\\n                (ASN1_UNIVERSALSTRING *)d2i_ASN1_type_bytes\\\n                ((ASN1_STRING **)a,pp,l,B_ASN1_UNIVERSALSTRING)\n\n# define M_ASN1_BMPSTRING_new()  (ASN1_BMPSTRING *)\\\n                ASN1_STRING_type_new(V_ASN1_BMPSTRING)\n# define M_ASN1_BMPSTRING_free(a)        ASN1_STRING_free((ASN1_STRING *)a)\n# define M_i2d_ASN1_BMPSTRING(a,pp) \\\n                i2d_ASN1_bytes((ASN1_STRING *)a,pp,V_ASN1_BMPSTRING,\\\n                        V_ASN1_UNIVERSAL)\n# define M_d2i_ASN1_BMPSTRING(a,pp,l) \\\n                (ASN1_BMPSTRING *)d2i_ASN1_type_bytes\\\n                ((ASN1_STRING **)a,pp,l,B_ASN1_BMPSTRING)\n\n# define M_ASN1_VISIBLESTRING_new()      (ASN1_VISIBLESTRING *)\\\n                ASN1_STRING_type_new(V_ASN1_VISIBLESTRING)\n# define M_ASN1_VISIBLESTRING_free(a)    ASN1_STRING_free((ASN1_STRING *)a)\n# define M_i2d_ASN1_VISIBLESTRING(a,pp) \\\n                i2d_ASN1_bytes((ASN1_STRING *)a,pp,V_ASN1_VISIBLESTRING,\\\n                        V_ASN1_UNIVERSAL)\n# define M_d2i_ASN1_VISIBLESTRING(a,pp,l) \\\n                (ASN1_VISIBLESTRING *)d2i_ASN1_type_bytes\\\n                ((ASN1_STRING **)a,pp,l,B_ASN1_VISIBLESTRING)\n\n# define M_ASN1_UTF8STRING_new() (ASN1_UTF8STRING *)\\\n                ASN1_STRING_type_new(V_ASN1_UTF8STRING)\n# define M_ASN1_UTF8STRING_free(a)       ASN1_STRING_free((ASN1_STRING *)a)\n# define M_i2d_ASN1_UTF8STRING(a,pp) \\\n                i2d_ASN1_bytes((ASN1_STRING *)a,pp,V_ASN1_UTF8STRING,\\\n                        V_ASN1_UNIVERSAL)\n# define M_d2i_ASN1_UTF8STRING(a,pp,l) \\\n                (ASN1_UTF8STRING *)d2i_ASN1_type_bytes\\\n                ((ASN1_STRING **)a,pp,l,B_ASN1_UTF8STRING)\n\n  /* for the is_set parameter to i2d_ASN1_SET */\n# define IS_SEQUENCE     0\n# define IS_SET          1\n\nDECLARE_ASN1_FUNCTIONS_fname(ASN1_TYPE, ASN1_ANY, ASN1_TYPE)\n\nint ASN1_TYPE_get(ASN1_TYPE *a);\nvoid ASN1_TYPE_set(ASN1_TYPE *a, int type, void *value);\nint ASN1_TYPE_set1(ASN1_TYPE *a, int type, const void *value);\nint ASN1_TYPE_cmp(const ASN1_TYPE *a, const ASN1_TYPE *b);\n\nASN1_OBJECT *ASN1_OBJECT_new(void);\nvoid ASN1_OBJECT_free(ASN1_OBJECT *a);\nint i2d_ASN1_OBJECT(ASN1_OBJECT *a, unsigned char **pp);\nASN1_OBJECT *c2i_ASN1_OBJECT(ASN1_OBJECT **a, const unsigned char **pp,\n                             long length);\nASN1_OBJECT *d2i_ASN1_OBJECT(ASN1_OBJECT **a, const unsigned char **pp,\n                             long length);\n\nDECLARE_ASN1_ITEM(ASN1_OBJECT)\n\nDECLARE_STACK_OF(ASN1_OBJECT)\nDECLARE_ASN1_SET_OF(ASN1_OBJECT)\n\nASN1_STRING *ASN1_STRING_new(void);\nvoid ASN1_STRING_free(ASN1_STRING *a);\nvoid ASN1_STRING_clear_free(ASN1_STRING *a);\nint ASN1_STRING_copy(ASN1_STRING *dst, const ASN1_STRING *str);\nASN1_STRING *ASN1_STRING_dup(const ASN1_STRING *a);\nASN1_STRING *ASN1_STRING_type_new(int type);\nint ASN1_STRING_cmp(const ASN1_STRING *a, const ASN1_STRING *b);\n  /*\n   * Since this is used to store all sorts of things, via macros, for now,\n   * make its data void *\n   */\nint ASN1_STRING_set(ASN1_STRING *str, const void *data, int len);\nvoid ASN1_STRING_set0(ASN1_STRING *str, void *data, int len);\nint ASN1_STRING_length(const ASN1_STRING *x);\nvoid ASN1_STRING_length_set(ASN1_STRING *x, int n);\nint ASN1_STRING_type(ASN1_STRING *x);\nunsigned char *ASN1_STRING_data(ASN1_STRING *x);\n\nDECLARE_ASN1_FUNCTIONS(ASN1_BIT_STRING)\nint i2c_ASN1_BIT_STRING(ASN1_BIT_STRING *a, unsigned char **pp);\nASN1_BIT_STRING *c2i_ASN1_BIT_STRING(ASN1_BIT_STRING **a,\n                                     const unsigned char **pp, long length);\nint ASN1_BIT_STRING_set(ASN1_BIT_STRING *a, unsigned char *d, int length);\nint ASN1_BIT_STRING_set_bit(ASN1_BIT_STRING *a, int n, int value);\nint ASN1_BIT_STRING_get_bit(ASN1_BIT_STRING *a, int n);\nint ASN1_BIT_STRING_check(ASN1_BIT_STRING *a,\n                          unsigned char *flags, int flags_len);\n\n# ifndef OPENSSL_NO_BIO\nint ASN1_BIT_STRING_name_print(BIO *out, ASN1_BIT_STRING *bs,\n                               BIT_STRING_BITNAME *tbl, int indent);\n# endif\nint ASN1_BIT_STRING_num_asc(char *name, BIT_STRING_BITNAME *tbl);\nint ASN1_BIT_STRING_set_asc(ASN1_BIT_STRING *bs, char *name, int value,\n                            BIT_STRING_BITNAME *tbl);\n\nint i2d_ASN1_BOOLEAN(int a, unsigned char **pp);\nint d2i_ASN1_BOOLEAN(int *a, const unsigned char **pp, long length);\n\nDECLARE_ASN1_FUNCTIONS(ASN1_INTEGER)\nint i2c_ASN1_INTEGER(ASN1_INTEGER *a, unsigned char **pp);\nASN1_INTEGER *c2i_ASN1_INTEGER(ASN1_INTEGER **a, const unsigned char **pp,\n                               long length);\nASN1_INTEGER *d2i_ASN1_UINTEGER(ASN1_INTEGER **a, const unsigned char **pp,\n                                long length);\nASN1_INTEGER *ASN1_INTEGER_dup(const ASN1_INTEGER *x);\nint ASN1_INTEGER_cmp(const ASN1_INTEGER *x, const ASN1_INTEGER *y);\n\nDECLARE_ASN1_FUNCTIONS(ASN1_ENUMERATED)\n\nint ASN1_UTCTIME_check(const ASN1_UTCTIME *a);\nASN1_UTCTIME *ASN1_UTCTIME_set(ASN1_UTCTIME *s, time_t t);\nASN1_UTCTIME *ASN1_UTCTIME_adj(ASN1_UTCTIME *s, time_t t,\n                               int offset_day, long offset_sec);\nint ASN1_UTCTIME_set_string(ASN1_UTCTIME *s, const char *str);\nint ASN1_UTCTIME_cmp_time_t(const ASN1_UTCTIME *s, time_t t);\n# if 0\ntime_t ASN1_UTCTIME_get(const ASN1_UTCTIME *s);\n# endif\n\nint ASN1_GENERALIZEDTIME_check(const ASN1_GENERALIZEDTIME *a);\nASN1_GENERALIZEDTIME *ASN1_GENERALIZEDTIME_set(ASN1_GENERALIZEDTIME *s,\n                                               time_t t);\nASN1_GENERALIZEDTIME *ASN1_GENERALIZEDTIME_adj(ASN1_GENERALIZEDTIME *s,\n                                               time_t t, int offset_day,\n                                               long offset_sec);\nint ASN1_GENERALIZEDTIME_set_string(ASN1_GENERALIZEDTIME *s, const char *str);\nint ASN1_TIME_diff(int *pday, int *psec,\n                   const ASN1_TIME *from, const ASN1_TIME *to);\n\nDECLARE_ASN1_FUNCTIONS(ASN1_OCTET_STRING)\nASN1_OCTET_STRING *ASN1_OCTET_STRING_dup(const ASN1_OCTET_STRING *a);\nint ASN1_OCTET_STRING_cmp(const ASN1_OCTET_STRING *a,\n                          const ASN1_OCTET_STRING *b);\nint ASN1_OCTET_STRING_set(ASN1_OCTET_STRING *str, const unsigned char *data,\n                          int len);\n\nDECLARE_ASN1_FUNCTIONS(ASN1_VISIBLESTRING)\nDECLARE_ASN1_FUNCTIONS(ASN1_UNIVERSALSTRING)\nDECLARE_ASN1_FUNCTIONS(ASN1_UTF8STRING)\nDECLARE_ASN1_FUNCTIONS(ASN1_NULL)\nDECLARE_ASN1_FUNCTIONS(ASN1_BMPSTRING)\n\nint UTF8_getc(const unsigned char *str, int len, unsigned long *val);\nint UTF8_putc(unsigned char *str, int len, unsigned long value);\n\nDECLARE_ASN1_FUNCTIONS_name(ASN1_STRING, ASN1_PRINTABLE)\n\nDECLARE_ASN1_FUNCTIONS_name(ASN1_STRING, DIRECTORYSTRING)\nDECLARE_ASN1_FUNCTIONS_name(ASN1_STRING, DISPLAYTEXT)\nDECLARE_ASN1_FUNCTIONS(ASN1_PRINTABLESTRING)\nDECLARE_ASN1_FUNCTIONS(ASN1_T61STRING)\nDECLARE_ASN1_FUNCTIONS(ASN1_IA5STRING)\nDECLARE_ASN1_FUNCTIONS(ASN1_GENERALSTRING)\nDECLARE_ASN1_FUNCTIONS(ASN1_UTCTIME)\nDECLARE_ASN1_FUNCTIONS(ASN1_GENERALIZEDTIME)\nDECLARE_ASN1_FUNCTIONS(ASN1_TIME)\n\nDECLARE_ASN1_ITEM(ASN1_OCTET_STRING_NDEF)\n\nASN1_TIME *ASN1_TIME_set(ASN1_TIME *s, time_t t);\nASN1_TIME *ASN1_TIME_adj(ASN1_TIME *s, time_t t,\n                         int offset_day, long offset_sec);\nint ASN1_TIME_check(ASN1_TIME *t);\nASN1_GENERALIZEDTIME *ASN1_TIME_to_generalizedtime(ASN1_TIME *t, ASN1_GENERALIZEDTIME\n                                                   **out);\nint ASN1_TIME_set_string(ASN1_TIME *s, const char *str);\n\nint i2d_ASN1_SET(STACK_OF(OPENSSL_BLOCK) *a, unsigned char **pp,\n                 i2d_of_void *i2d, int ex_tag, int ex_class, int is_set);\nSTACK_OF(OPENSSL_BLOCK) *d2i_ASN1_SET(STACK_OF(OPENSSL_BLOCK) **a,\n                                      const unsigned char **pp,\n                                      long length, d2i_of_void *d2i,\n                                      void (*free_func) (OPENSSL_BLOCK),\n                                      int ex_tag, int ex_class);\n\n# ifndef OPENSSL_NO_BIO\nint i2a_ASN1_INTEGER(BIO *bp, ASN1_INTEGER *a);\nint a2i_ASN1_INTEGER(BIO *bp, ASN1_INTEGER *bs, char *buf, int size);\nint i2a_ASN1_ENUMERATED(BIO *bp, ASN1_ENUMERATED *a);\nint a2i_ASN1_ENUMERATED(BIO *bp, ASN1_ENUMERATED *bs, char *buf, int size);\nint i2a_ASN1_OBJECT(BIO *bp, ASN1_OBJECT *a);\nint a2i_ASN1_STRING(BIO *bp, ASN1_STRING *bs, char *buf, int size);\nint i2a_ASN1_STRING(BIO *bp, ASN1_STRING *a, int type);\n# endif\nint i2t_ASN1_OBJECT(char *buf, int buf_len, ASN1_OBJECT *a);\n\nint a2d_ASN1_OBJECT(unsigned char *out, int olen, const char *buf, int num);\nASN1_OBJECT *ASN1_OBJECT_create(int nid, unsigned char *data, int len,\n                                const char *sn, const char *ln);\n\nint ASN1_INTEGER_set(ASN1_INTEGER *a, long v);\nlong ASN1_INTEGER_get(const ASN1_INTEGER *a);\nASN1_INTEGER *BN_to_ASN1_INTEGER(const BIGNUM *bn, ASN1_INTEGER *ai);\nBIGNUM *ASN1_INTEGER_to_BN(const ASN1_INTEGER *ai, BIGNUM *bn);\n\nint ASN1_ENUMERATED_set(ASN1_ENUMERATED *a, long v);\nlong ASN1_ENUMERATED_get(ASN1_ENUMERATED *a);\nASN1_ENUMERATED *BN_to_ASN1_ENUMERATED(BIGNUM *bn, ASN1_ENUMERATED *ai);\nBIGNUM *ASN1_ENUMERATED_to_BN(ASN1_ENUMERATED *ai, BIGNUM *bn);\n\n/* General */\n/* given a string, return the correct type, max is the maximum length */\nint ASN1_PRINTABLE_type(const unsigned char *s, int max);\n\nint i2d_ASN1_bytes(ASN1_STRING *a, unsigned char **pp, int tag, int xclass);\nASN1_STRING *d2i_ASN1_bytes(ASN1_STRING **a, const unsigned char **pp,\n                            long length, int Ptag, int Pclass);\nunsigned long ASN1_tag2bit(int tag);\n/* type is one or more of the B_ASN1_ values. */\nASN1_STRING *d2i_ASN1_type_bytes(ASN1_STRING **a, const unsigned char **pp,\n                                 long length, int type);\n\n/* PARSING */\nint asn1_Finish(ASN1_CTX *c);\nint asn1_const_Finish(ASN1_const_CTX *c);\n\n/* SPECIALS */\nint ASN1_get_object(const unsigned char **pp, long *plength, int *ptag,\n                    int *pclass, long omax);\nint ASN1_check_infinite_end(unsigned char **p, long len);\nint ASN1_const_check_infinite_end(const unsigned char **p, long len);\nvoid ASN1_put_object(unsigned char **pp, int constructed, int length,\n                     int tag, int xclass);\nint ASN1_put_eoc(unsigned char **pp);\nint ASN1_object_size(int constructed, int length, int tag);\n\n/* Used to implement other functions */\nvoid *ASN1_dup(i2d_of_void *i2d, d2i_of_void *d2i, void *x);\n\n# define ASN1_dup_of(type,i2d,d2i,x) \\\n    ((type*)ASN1_dup(CHECKED_I2D_OF(type, i2d), \\\n                     CHECKED_D2I_OF(type, d2i), \\\n                     CHECKED_PTR_OF(type, x)))\n\n# define ASN1_dup_of_const(type,i2d,d2i,x) \\\n    ((type*)ASN1_dup(CHECKED_I2D_OF(const type, i2d), \\\n                     CHECKED_D2I_OF(type, d2i), \\\n                     CHECKED_PTR_OF(const type, x)))\n\nvoid *ASN1_item_dup(const ASN1_ITEM *it, void *x);\n\n/* ASN1 alloc/free macros for when a type is only used internally */\n\n# define M_ASN1_new_of(type) (type *)ASN1_item_new(ASN1_ITEM_rptr(type))\n# define M_ASN1_free_of(x, type) \\\n                ASN1_item_free(CHECKED_PTR_OF(type, x), ASN1_ITEM_rptr(type))\n\n# ifndef OPENSSL_NO_FP_API\nvoid *ASN1_d2i_fp(void *(*xnew) (void), d2i_of_void *d2i, FILE *in, void **x);\n\n#  define ASN1_d2i_fp_of(type,xnew,d2i,in,x) \\\n    ((type*)ASN1_d2i_fp(CHECKED_NEW_OF(type, xnew), \\\n                        CHECKED_D2I_OF(type, d2i), \\\n                        in, \\\n                        CHECKED_PPTR_OF(type, x)))\n\nvoid *ASN1_item_d2i_fp(const ASN1_ITEM *it, FILE *in, void *x);\nint ASN1_i2d_fp(i2d_of_void *i2d, FILE *out, void *x);\n\n#  define ASN1_i2d_fp_of(type,i2d,out,x) \\\n    (ASN1_i2d_fp(CHECKED_I2D_OF(type, i2d), \\\n                 out, \\\n                 CHECKED_PTR_OF(type, x)))\n\n#  define ASN1_i2d_fp_of_const(type,i2d,out,x) \\\n    (ASN1_i2d_fp(CHECKED_I2D_OF(const type, i2d), \\\n                 out, \\\n                 CHECKED_PTR_OF(const type, x)))\n\nint ASN1_item_i2d_fp(const ASN1_ITEM *it, FILE *out, void *x);\nint ASN1_STRING_print_ex_fp(FILE *fp, ASN1_STRING *str, unsigned long flags);\n# endif\n\nint ASN1_STRING_to_UTF8(unsigned char **out, ASN1_STRING *in);\n\n# ifndef OPENSSL_NO_BIO\nvoid *ASN1_d2i_bio(void *(*xnew) (void), d2i_of_void *d2i, BIO *in, void **x);\n\n#  define ASN1_d2i_bio_of(type,xnew,d2i,in,x) \\\n    ((type*)ASN1_d2i_bio( CHECKED_NEW_OF(type, xnew), \\\n                          CHECKED_D2I_OF(type, d2i), \\\n                          in, \\\n                          CHECKED_PPTR_OF(type, x)))\n\nvoid *ASN1_item_d2i_bio(const ASN1_ITEM *it, BIO *in, void *x);\nint ASN1_i2d_bio(i2d_of_void *i2d, BIO *out, unsigned char *x);\n\n#  define ASN1_i2d_bio_of(type,i2d,out,x) \\\n    (ASN1_i2d_bio(CHECKED_I2D_OF(type, i2d), \\\n                  out, \\\n                  CHECKED_PTR_OF(type, x)))\n\n#  define ASN1_i2d_bio_of_const(type,i2d,out,x) \\\n    (ASN1_i2d_bio(CHECKED_I2D_OF(const type, i2d), \\\n                  out, \\\n                  CHECKED_PTR_OF(const type, x)))\n\nint ASN1_item_i2d_bio(const ASN1_ITEM *it, BIO *out, void *x);\nint ASN1_UTCTIME_print(BIO *fp, const ASN1_UTCTIME *a);\nint ASN1_GENERALIZEDTIME_print(BIO *fp, const ASN1_GENERALIZEDTIME *a);\nint ASN1_TIME_print(BIO *fp, const ASN1_TIME *a);\nint ASN1_STRING_print(BIO *bp, const ASN1_STRING *v);\nint ASN1_STRING_print_ex(BIO *out, ASN1_STRING *str, unsigned long flags);\nint ASN1_bn_print(BIO *bp, const char *number, const BIGNUM *num,\n                  unsigned char *buf, int off);\nint ASN1_parse(BIO *bp, const unsigned char *pp, long len, int indent);\nint ASN1_parse_dump(BIO *bp, const unsigned char *pp, long len, int indent,\n                    int dump);\n# endif\nconst char *ASN1_tag2str(int tag);\n\n/* Used to load and write netscape format cert */\n\nDECLARE_ASN1_FUNCTIONS(NETSCAPE_X509)\n\nint ASN1_UNIVERSALSTRING_to_string(ASN1_UNIVERSALSTRING *s);\n\nint ASN1_TYPE_set_octetstring(ASN1_TYPE *a, unsigned char *data, int len);\nint ASN1_TYPE_get_octetstring(ASN1_TYPE *a, unsigned char *data, int max_len);\nint ASN1_TYPE_set_int_octetstring(ASN1_TYPE *a, long num,\n                                  unsigned char *data, int len);\nint ASN1_TYPE_get_int_octetstring(ASN1_TYPE *a, long *num,\n                                  unsigned char *data, int max_len);\n\nSTACK_OF(OPENSSL_BLOCK) *ASN1_seq_unpack(const unsigned char *buf, int len,\n                                         d2i_of_void *d2i,\n                                         void (*free_func) (OPENSSL_BLOCK));\nunsigned char *ASN1_seq_pack(STACK_OF(OPENSSL_BLOCK) *safes, i2d_of_void *i2d,\n                             unsigned char **buf, int *len);\nvoid *ASN1_unpack_string(ASN1_STRING *oct, d2i_of_void *d2i);\nvoid *ASN1_item_unpack(ASN1_STRING *oct, const ASN1_ITEM *it);\nASN1_STRING *ASN1_pack_string(void *obj, i2d_of_void *i2d,\n                              ASN1_OCTET_STRING **oct);\n\n# define ASN1_pack_string_of(type,obj,i2d,oct) \\\n    (ASN1_pack_string(CHECKED_PTR_OF(type, obj), \\\n                      CHECKED_I2D_OF(type, i2d), \\\n                      oct))\n\nASN1_STRING *ASN1_item_pack(void *obj, const ASN1_ITEM *it,\n                            ASN1_OCTET_STRING **oct);\n\nvoid ASN1_STRING_set_default_mask(unsigned long mask);\nint ASN1_STRING_set_default_mask_asc(const char *p);\nunsigned long ASN1_STRING_get_default_mask(void);\nint ASN1_mbstring_copy(ASN1_STRING **out, const unsigned char *in, int len,\n                       int inform, unsigned long mask);\nint ASN1_mbstring_ncopy(ASN1_STRING **out, const unsigned char *in, int len,\n                        int inform, unsigned long mask,\n                        long minsize, long maxsize);\n\nASN1_STRING *ASN1_STRING_set_by_NID(ASN1_STRING **out,\n                                    const unsigned char *in, int inlen,\n                                    int inform, int nid);\nASN1_STRING_TABLE *ASN1_STRING_TABLE_get(int nid);\nint ASN1_STRING_TABLE_add(int, long, long, unsigned long, unsigned long);\nvoid ASN1_STRING_TABLE_cleanup(void);\n\n/* ASN1 template functions */\n\n/* Old API compatible functions */\nASN1_VALUE *ASN1_item_new(const ASN1_ITEM *it);\nvoid ASN1_item_free(ASN1_VALUE *val, const ASN1_ITEM *it);\nASN1_VALUE *ASN1_item_d2i(ASN1_VALUE **val, const unsigned char **in,\n                          long len, const ASN1_ITEM *it);\nint ASN1_item_i2d(ASN1_VALUE *val, unsigned char **out, const ASN1_ITEM *it);\nint ASN1_item_ndef_i2d(ASN1_VALUE *val, unsigned char **out,\n                       const ASN1_ITEM *it);\n\nvoid ASN1_add_oid_module(void);\n\nASN1_TYPE *ASN1_generate_nconf(char *str, CONF *nconf);\nASN1_TYPE *ASN1_generate_v3(char *str, X509V3_CTX *cnf);\n\n/* ASN1 Print flags */\n\n/* Indicate missing OPTIONAL fields */\n# define ASN1_PCTX_FLAGS_SHOW_ABSENT             0x001\n/* Mark start and end of SEQUENCE */\n# define ASN1_PCTX_FLAGS_SHOW_SEQUENCE           0x002\n/* Mark start and end of SEQUENCE/SET OF */\n# define ASN1_PCTX_FLAGS_SHOW_SSOF               0x004\n/* Show the ASN1 type of primitives */\n# define ASN1_PCTX_FLAGS_SHOW_TYPE               0x008\n/* Don't show ASN1 type of ANY */\n# define ASN1_PCTX_FLAGS_NO_ANY_TYPE             0x010\n/* Don't show ASN1 type of MSTRINGs */\n# define ASN1_PCTX_FLAGS_NO_MSTRING_TYPE         0x020\n/* Don't show field names in SEQUENCE */\n# define ASN1_PCTX_FLAGS_NO_FIELD_NAME           0x040\n/* Show structure names of each SEQUENCE field */\n# define ASN1_PCTX_FLAGS_SHOW_FIELD_STRUCT_NAME  0x080\n/* Don't show structure name even at top level */\n# define ASN1_PCTX_FLAGS_NO_STRUCT_NAME          0x100\n\nint ASN1_item_print(BIO *out, ASN1_VALUE *ifld, int indent,\n                    const ASN1_ITEM *it, const ASN1_PCTX *pctx);\nASN1_PCTX *ASN1_PCTX_new(void);\nvoid ASN1_PCTX_free(ASN1_PCTX *p);\nunsigned long ASN1_PCTX_get_flags(ASN1_PCTX *p);\nvoid ASN1_PCTX_set_flags(ASN1_PCTX *p, unsigned long flags);\nunsigned long ASN1_PCTX_get_nm_flags(ASN1_PCTX *p);\nvoid ASN1_PCTX_set_nm_flags(ASN1_PCTX *p, unsigned long flags);\nunsigned long ASN1_PCTX_get_cert_flags(ASN1_PCTX *p);\nvoid ASN1_PCTX_set_cert_flags(ASN1_PCTX *p, unsigned long flags);\nunsigned long ASN1_PCTX_get_oid_flags(ASN1_PCTX *p);\nvoid ASN1_PCTX_set_oid_flags(ASN1_PCTX *p, unsigned long flags);\nunsigned long ASN1_PCTX_get_str_flags(ASN1_PCTX *p);\nvoid ASN1_PCTX_set_str_flags(ASN1_PCTX *p, unsigned long flags);\n\nBIO_METHOD *BIO_f_asn1(void);\n\nBIO *BIO_new_NDEF(BIO *out, ASN1_VALUE *val, const ASN1_ITEM *it);\n\nint i2d_ASN1_bio_stream(BIO *out, ASN1_VALUE *val, BIO *in, int flags,\n                        const ASN1_ITEM *it);\nint PEM_write_bio_ASN1_stream(BIO *out, ASN1_VALUE *val, BIO *in, int flags,\n                              const char *hdr, const ASN1_ITEM *it);\nint SMIME_write_ASN1(BIO *bio, ASN1_VALUE *val, BIO *data, int flags,\n                     int ctype_nid, int econt_nid,\n                     STACK_OF(X509_ALGOR) *mdalgs, const ASN1_ITEM *it);\nASN1_VALUE *SMIME_read_ASN1(BIO *bio, BIO **bcont, const ASN1_ITEM *it);\nint SMIME_crlf_copy(BIO *in, BIO *out, int flags);\nint SMIME_text(BIO *in, BIO *out);\n\n/* BEGIN ERROR CODES */\n/*\n * The following lines are auto generated by the script mkerr.pl. Any changes\n * made after this point may be overwritten when the script is next run.\n */\nvoid ERR_load_ASN1_strings(void);\n\n/* Error codes for the ASN1 functions. */\n\n/* Function codes. */\n# define ASN1_F_A2D_ASN1_OBJECT                           100\n# define ASN1_F_A2I_ASN1_ENUMERATED                       101\n# define ASN1_F_A2I_ASN1_INTEGER                          102\n# define ASN1_F_A2I_ASN1_STRING                           103\n# define ASN1_F_APPEND_EXP                                176\n# define ASN1_F_ASN1_BIT_STRING_SET_BIT                   183\n# define ASN1_F_ASN1_CB                                   177\n# define ASN1_F_ASN1_CHECK_TLEN                           104\n# define ASN1_F_ASN1_COLLATE_PRIMITIVE                    105\n# define ASN1_F_ASN1_COLLECT                              106\n# define ASN1_F_ASN1_D2I_EX_PRIMITIVE                     108\n# define ASN1_F_ASN1_D2I_FP                               109\n# define ASN1_F_ASN1_D2I_READ_BIO                         107\n# define ASN1_F_ASN1_DIGEST                               184\n# define ASN1_F_ASN1_DO_ADB                               110\n# define ASN1_F_ASN1_DUP                                  111\n# define ASN1_F_ASN1_ENUMERATED_SET                       112\n# define ASN1_F_ASN1_ENUMERATED_TO_BN                     113\n# define ASN1_F_ASN1_EX_C2I                               204\n# define ASN1_F_ASN1_FIND_END                             190\n# define ASN1_F_ASN1_GENERALIZEDTIME_ADJ                  216\n# define ASN1_F_ASN1_GENERALIZEDTIME_SET                  185\n# define ASN1_F_ASN1_GENERATE_V3                          178\n# define ASN1_F_ASN1_GET_OBJECT                           114\n# define ASN1_F_ASN1_HEADER_NEW                           115\n# define ASN1_F_ASN1_I2D_BIO                              116\n# define ASN1_F_ASN1_I2D_FP                               117\n# define ASN1_F_ASN1_INTEGER_SET                          118\n# define ASN1_F_ASN1_INTEGER_TO_BN                        119\n# define ASN1_F_ASN1_ITEM_D2I_FP                          206\n# define ASN1_F_ASN1_ITEM_DUP                             191\n# define ASN1_F_ASN1_ITEM_EX_COMBINE_NEW                  121\n# define ASN1_F_ASN1_ITEM_EX_D2I                          120\n# define ASN1_F_ASN1_ITEM_I2D_BIO                         192\n# define ASN1_F_ASN1_ITEM_I2D_FP                          193\n# define ASN1_F_ASN1_ITEM_PACK                            198\n# define ASN1_F_ASN1_ITEM_SIGN                            195\n# define ASN1_F_ASN1_ITEM_SIGN_CTX                        220\n# define ASN1_F_ASN1_ITEM_UNPACK                          199\n# define ASN1_F_ASN1_ITEM_VERIFY                          197\n# define ASN1_F_ASN1_MBSTRING_NCOPY                       122\n# define ASN1_F_ASN1_OBJECT_NEW                           123\n# define ASN1_F_ASN1_OUTPUT_DATA                          214\n# define ASN1_F_ASN1_PACK_STRING                          124\n# define ASN1_F_ASN1_PCTX_NEW                             205\n# define ASN1_F_ASN1_PKCS5_PBE_SET                        125\n# define ASN1_F_ASN1_SEQ_PACK                             126\n# define ASN1_F_ASN1_SEQ_UNPACK                           127\n# define ASN1_F_ASN1_SIGN                                 128\n# define ASN1_F_ASN1_STR2TYPE                             179\n# define ASN1_F_ASN1_STRING_SET                           186\n# define ASN1_F_ASN1_STRING_TABLE_ADD                     129\n# define ASN1_F_ASN1_STRING_TYPE_NEW                      130\n# define ASN1_F_ASN1_TEMPLATE_EX_D2I                      132\n# define ASN1_F_ASN1_TEMPLATE_NEW                         133\n# define ASN1_F_ASN1_TEMPLATE_NOEXP_D2I                   131\n# define ASN1_F_ASN1_TIME_ADJ                             217\n# define ASN1_F_ASN1_TIME_SET                             175\n# define ASN1_F_ASN1_TYPE_GET_INT_OCTETSTRING             134\n# define ASN1_F_ASN1_TYPE_GET_OCTETSTRING                 135\n# define ASN1_F_ASN1_UNPACK_STRING                        136\n# define ASN1_F_ASN1_UTCTIME_ADJ                          218\n# define ASN1_F_ASN1_UTCTIME_SET                          187\n# define ASN1_F_ASN1_VERIFY                               137\n# define ASN1_F_B64_READ_ASN1                             209\n# define ASN1_F_B64_WRITE_ASN1                            210\n# define ASN1_F_BIO_NEW_NDEF                              208\n# define ASN1_F_BITSTR_CB                                 180\n# define ASN1_F_BN_TO_ASN1_ENUMERATED                     138\n# define ASN1_F_BN_TO_ASN1_INTEGER                        139\n# define ASN1_F_C2I_ASN1_BIT_STRING                       189\n# define ASN1_F_C2I_ASN1_INTEGER                          194\n# define ASN1_F_C2I_ASN1_OBJECT                           196\n# define ASN1_F_COLLECT_DATA                              140\n# define ASN1_F_D2I_ASN1_BIT_STRING                       141\n# define ASN1_F_D2I_ASN1_BOOLEAN                          142\n# define ASN1_F_D2I_ASN1_BYTES                            143\n# define ASN1_F_D2I_ASN1_GENERALIZEDTIME                  144\n# define ASN1_F_D2I_ASN1_HEADER                           145\n# define ASN1_F_D2I_ASN1_INTEGER                          146\n# define ASN1_F_D2I_ASN1_OBJECT                           147\n# define ASN1_F_D2I_ASN1_SET                              148\n# define ASN1_F_D2I_ASN1_TYPE_BYTES                       149\n# define ASN1_F_D2I_ASN1_UINTEGER                         150\n# define ASN1_F_D2I_ASN1_UTCTIME                          151\n# define ASN1_F_D2I_AUTOPRIVATEKEY                        207\n# define ASN1_F_D2I_NETSCAPE_RSA                          152\n# define ASN1_F_D2I_NETSCAPE_RSA_2                        153\n# define ASN1_F_D2I_PRIVATEKEY                            154\n# define ASN1_F_D2I_PUBLICKEY                             155\n# define ASN1_F_D2I_RSA_NET                               200\n# define ASN1_F_D2I_RSA_NET_2                             201\n# define ASN1_F_D2I_X509                                  156\n# define ASN1_F_D2I_X509_CINF                             157\n# define ASN1_F_D2I_X509_PKEY                             159\n# define ASN1_F_I2D_ASN1_BIO_STREAM                       211\n# define ASN1_F_I2D_ASN1_SET                              188\n# define ASN1_F_I2D_ASN1_TIME                             160\n# define ASN1_F_I2D_DSA_PUBKEY                            161\n# define ASN1_F_I2D_EC_PUBKEY                             181\n# define ASN1_F_I2D_PRIVATEKEY                            163\n# define ASN1_F_I2D_PUBLICKEY                             164\n# define ASN1_F_I2D_RSA_NET                               162\n# define ASN1_F_I2D_RSA_PUBKEY                            165\n# define ASN1_F_LONG_C2I                                  166\n# define ASN1_F_OID_MODULE_INIT                           174\n# define ASN1_F_PARSE_TAGGING                             182\n# define ASN1_F_PKCS5_PBE2_SET_IV                         167\n# define ASN1_F_PKCS5_PBE_SET                             202\n# define ASN1_F_PKCS5_PBE_SET0_ALGOR                      215\n# define ASN1_F_PKCS5_PBKDF2_SET                          219\n# define ASN1_F_SMIME_READ_ASN1                           212\n# define ASN1_F_SMIME_TEXT                                213\n# define ASN1_F_X509_CINF_NEW                             168\n# define ASN1_F_X509_CRL_ADD0_REVOKED                     169\n# define ASN1_F_X509_INFO_NEW                             170\n# define ASN1_F_X509_NAME_ENCODE                          203\n# define ASN1_F_X509_NAME_EX_D2I                          158\n# define ASN1_F_X509_NAME_EX_NEW                          171\n# define ASN1_F_X509_NEW                                  172\n# define ASN1_F_X509_PKEY_NEW                             173\n\n/* Reason codes. */\n# define ASN1_R_ADDING_OBJECT                             171\n# define ASN1_R_ASN1_PARSE_ERROR                          203\n# define ASN1_R_ASN1_SIG_PARSE_ERROR                      204\n# define ASN1_R_AUX_ERROR                                 100\n# define ASN1_R_BAD_CLASS                                 101\n# define ASN1_R_BAD_OBJECT_HEADER                         102\n# define ASN1_R_BAD_PASSWORD_READ                         103\n# define ASN1_R_BAD_TAG                                   104\n# define ASN1_R_BMPSTRING_IS_WRONG_LENGTH                 214\n# define ASN1_R_BN_LIB                                    105\n# define ASN1_R_BOOLEAN_IS_WRONG_LENGTH                   106\n# define ASN1_R_BUFFER_TOO_SMALL                          107\n# define ASN1_R_CIPHER_HAS_NO_OBJECT_IDENTIFIER           108\n# define ASN1_R_CONTEXT_NOT_INITIALISED                   217\n# define ASN1_R_DATA_IS_WRONG                             109\n# define ASN1_R_DECODE_ERROR                              110\n# define ASN1_R_DECODING_ERROR                            111\n# define ASN1_R_DEPTH_EXCEEDED                            174\n# define ASN1_R_DIGEST_AND_KEY_TYPE_NOT_SUPPORTED         198\n# define ASN1_R_ENCODE_ERROR                              112\n# define ASN1_R_ERROR_GETTING_TIME                        173\n# define ASN1_R_ERROR_LOADING_SECTION                     172\n# define ASN1_R_ERROR_PARSING_SET_ELEMENT                 113\n# define ASN1_R_ERROR_SETTING_CIPHER_PARAMS               114\n# define ASN1_R_EXPECTING_AN_INTEGER                      115\n# define ASN1_R_EXPECTING_AN_OBJECT                       116\n# define ASN1_R_EXPECTING_A_BOOLEAN                       117\n# define ASN1_R_EXPECTING_A_TIME                          118\n# define ASN1_R_EXPLICIT_LENGTH_MISMATCH                  119\n# define ASN1_R_EXPLICIT_TAG_NOT_CONSTRUCTED              120\n# define ASN1_R_FIELD_MISSING                             121\n# define ASN1_R_FIRST_NUM_TOO_LARGE                       122\n# define ASN1_R_HEADER_TOO_LONG                           123\n# define ASN1_R_ILLEGAL_BITSTRING_FORMAT                  175\n# define ASN1_R_ILLEGAL_BOOLEAN                           176\n# define ASN1_R_ILLEGAL_CHARACTERS                        124\n# define ASN1_R_ILLEGAL_FORMAT                            177\n# define ASN1_R_ILLEGAL_HEX                               178\n# define ASN1_R_ILLEGAL_IMPLICIT_TAG                      179\n# define ASN1_R_ILLEGAL_INTEGER                           180\n# define ASN1_R_ILLEGAL_NESTED_TAGGING                    181\n# define ASN1_R_ILLEGAL_NULL                              125\n# define ASN1_R_ILLEGAL_NULL_VALUE                        182\n# define ASN1_R_ILLEGAL_OBJECT                            183\n# define ASN1_R_ILLEGAL_OPTIONAL_ANY                      126\n# define ASN1_R_ILLEGAL_OPTIONS_ON_ITEM_TEMPLATE          170\n# define ASN1_R_ILLEGAL_TAGGED_ANY                        127\n# define ASN1_R_ILLEGAL_TIME_VALUE                        184\n# define ASN1_R_INTEGER_NOT_ASCII_FORMAT                  185\n# define ASN1_R_INTEGER_TOO_LARGE_FOR_LONG                128\n# define ASN1_R_INVALID_BIT_STRING_BITS_LEFT              220\n# define ASN1_R_INVALID_BMPSTRING_LENGTH                  129\n# define ASN1_R_INVALID_DIGIT                             130\n# define ASN1_R_INVALID_MIME_TYPE                         205\n# define ASN1_R_INVALID_MODIFIER                          186\n# define ASN1_R_INVALID_NUMBER                            187\n# define ASN1_R_INVALID_OBJECT_ENCODING                   216\n# define ASN1_R_INVALID_SEPARATOR                         131\n# define ASN1_R_INVALID_TIME_FORMAT                       132\n# define ASN1_R_INVALID_UNIVERSALSTRING_LENGTH            133\n# define ASN1_R_INVALID_UTF8STRING                        134\n# define ASN1_R_IV_TOO_LARGE                              135\n# define ASN1_R_LENGTH_ERROR                              136\n# define ASN1_R_LIST_ERROR                                188\n# define ASN1_R_MIME_NO_CONTENT_TYPE                      206\n# define ASN1_R_MIME_PARSE_ERROR                          207\n# define ASN1_R_MIME_SIG_PARSE_ERROR                      208\n# define ASN1_R_MISSING_EOC                               137\n# define ASN1_R_MISSING_SECOND_NUMBER                     138\n# define ASN1_R_MISSING_VALUE                             189\n# define ASN1_R_MSTRING_NOT_UNIVERSAL                     139\n# define ASN1_R_MSTRING_WRONG_TAG                         140\n# define ASN1_R_NESTED_ASN1_STRING                        197\n# define ASN1_R_NON_HEX_CHARACTERS                        141\n# define ASN1_R_NOT_ASCII_FORMAT                          190\n# define ASN1_R_NOT_ENOUGH_DATA                           142\n# define ASN1_R_NO_CONTENT_TYPE                           209\n# define ASN1_R_NO_DEFAULT_DIGEST                         201\n# define ASN1_R_NO_MATCHING_CHOICE_TYPE                   143\n# define ASN1_R_NO_MULTIPART_BODY_FAILURE                 210\n# define ASN1_R_NO_MULTIPART_BOUNDARY                     211\n# define ASN1_R_NO_SIG_CONTENT_TYPE                       212\n# define ASN1_R_NULL_IS_WRONG_LENGTH                      144\n# define ASN1_R_OBJECT_NOT_ASCII_FORMAT                   191\n# define ASN1_R_ODD_NUMBER_OF_CHARS                       145\n# define ASN1_R_PRIVATE_KEY_HEADER_MISSING                146\n# define ASN1_R_SECOND_NUMBER_TOO_LARGE                   147\n# define ASN1_R_SEQUENCE_LENGTH_MISMATCH                  148\n# define ASN1_R_SEQUENCE_NOT_CONSTRUCTED                  149\n# define ASN1_R_SEQUENCE_OR_SET_NEEDS_CONFIG              192\n# define ASN1_R_SHORT_LINE                                150\n# define ASN1_R_SIG_INVALID_MIME_TYPE                     213\n# define ASN1_R_STREAMING_NOT_SUPPORTED                   202\n# define ASN1_R_STRING_TOO_LONG                           151\n# define ASN1_R_STRING_TOO_SHORT                          152\n# define ASN1_R_TAG_VALUE_TOO_HIGH                        153\n# define ASN1_R_THE_ASN1_OBJECT_IDENTIFIER_IS_NOT_KNOWN_FOR_THIS_MD 154\n# define ASN1_R_TIME_NOT_ASCII_FORMAT                     193\n# define ASN1_R_TOO_LONG                                  155\n# define ASN1_R_TYPE_NOT_CONSTRUCTED                      156\n# define ASN1_R_TYPE_NOT_PRIMITIVE                        218\n# define ASN1_R_UNABLE_TO_DECODE_RSA_KEY                  157\n# define ASN1_R_UNABLE_TO_DECODE_RSA_PRIVATE_KEY          158\n# define ASN1_R_UNEXPECTED_EOC                            159\n# define ASN1_R_UNIVERSALSTRING_IS_WRONG_LENGTH           215\n# define ASN1_R_UNKNOWN_FORMAT                            160\n# define ASN1_R_UNKNOWN_MESSAGE_DIGEST_ALGORITHM          161\n# define ASN1_R_UNKNOWN_OBJECT_TYPE                       162\n# define ASN1_R_UNKNOWN_PUBLIC_KEY_TYPE                   163\n# define ASN1_R_UNKNOWN_SIGNATURE_ALGORITHM               199\n# define ASN1_R_UNKNOWN_TAG                               194\n# define ASN1_R_UNKOWN_FORMAT                             195\n# define ASN1_R_UNSUPPORTED_ANY_DEFINED_BY_TYPE           164\n# define ASN1_R_UNSUPPORTED_CIPHER                        165\n# define ASN1_R_UNSUPPORTED_ENCRYPTION_ALGORITHM          166\n# define ASN1_R_UNSUPPORTED_PUBLIC_KEY_TYPE               167\n# define ASN1_R_UNSUPPORTED_TYPE                          196\n# define ASN1_R_WRONG_PUBLIC_KEY_TYPE                     200\n# define ASN1_R_WRONG_TAG                                 168\n# define ASN1_R_WRONG_TYPE                                169\n\n#ifdef  __cplusplus\n}\n#endif\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/x86_64/include/openssl/asn1_mac.h",
    "content": "/* crypto/asn1/asn1_mac.h */\n/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)\n * All rights reserved.\n *\n * This package is an SSL implementation written\n * by Eric Young (eay@cryptsoft.com).\n * The implementation was written so as to conform with Netscapes SSL.\n *\n * This library is free for commercial and non-commercial use as long as\n * the following conditions are aheared to.  The following conditions\n * apply to all code found in this distribution, be it the RC4, RSA,\n * lhash, DES, etc., code; not just the SSL code.  The SSL documentation\n * included with this distribution is covered by the same copyright terms\n * except that the holder is Tim Hudson (tjh@cryptsoft.com).\n *\n * Copyright remains Eric Young's, and as such any Copyright notices in\n * the code are not to be removed.\n * If this package is used in a product, Eric Young should be given attribution\n * as the author of the parts of the library used.\n * This can be in the form of a textual message at program startup or\n * in documentation (online or textual) provided with the package.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the copyright\n *    notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in the\n *    documentation and/or other materials provided with the distribution.\n * 3. All advertising materials mentioning features or use of this software\n *    must display the following acknowledgement:\n *    \"This product includes cryptographic software written by\n *     Eric Young (eay@cryptsoft.com)\"\n *    The word 'cryptographic' can be left out if the rouines from the library\n *    being used are not cryptographic related :-).\n * 4. If you include any Windows specific code (or a derivative thereof) from\n *    the apps directory (application code) you must include an acknowledgement:\n *    \"This product includes software written by Tim Hudson (tjh@cryptsoft.com)\"\n *\n * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n * SUCH DAMAGE.\n *\n * The licence and distribution terms for any publically available version or\n * derivative of this code cannot be changed.  i.e. this code cannot simply be\n * copied and put under another distribution licence\n * [including the GNU Public Licence.]\n */\n\n#ifndef HEADER_ASN1_MAC_H\n# define HEADER_ASN1_MAC_H\n\n# include <openssl/asn1.h>\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n# ifndef ASN1_MAC_ERR_LIB\n#  define ASN1_MAC_ERR_LIB        ERR_LIB_ASN1\n# endif\n\n# define ASN1_MAC_H_err(f,r,line) \\\n        ERR_PUT_error(ASN1_MAC_ERR_LIB,(f),(r),__FILE__,(line))\n\n# define M_ASN1_D2I_vars(a,type,func) \\\n        ASN1_const_CTX c; \\\n        type ret=NULL; \\\n        \\\n        c.pp=(const unsigned char **)pp; \\\n        c.q= *(const unsigned char **)pp; \\\n        c.error=ERR_R_NESTED_ASN1_ERROR; \\\n        if ((a == NULL) || ((*a) == NULL)) \\\n                { if ((ret=(type)func()) == NULL) \\\n                        { c.line=__LINE__; goto err; } } \\\n        else    ret=(*a);\n\n# define M_ASN1_D2I_Init() \\\n        c.p= *(const unsigned char **)pp; \\\n        c.max=(length == 0)?0:(c.p+length);\n\n# define M_ASN1_D2I_Finish_2(a) \\\n        if (!asn1_const_Finish(&c)) \\\n                { c.line=__LINE__; goto err; } \\\n        *(const unsigned char **)pp=c.p; \\\n        if (a != NULL) (*a)=ret; \\\n        return(ret);\n\n# define M_ASN1_D2I_Finish(a,func,e) \\\n        M_ASN1_D2I_Finish_2(a); \\\nerr:\\\n        ASN1_MAC_H_err((e),c.error,c.line); \\\n        asn1_add_error(*(const unsigned char **)pp,(int)(c.q- *pp)); \\\n        if ((ret != NULL) && ((a == NULL) || (*a != ret))) func(ret); \\\n        return(NULL)\n\n# define M_ASN1_D2I_start_sequence() \\\n        if (!asn1_GetSequence(&c,&length)) \\\n                { c.line=__LINE__; goto err; }\n/* Begin reading ASN1 without a surrounding sequence */\n# define M_ASN1_D2I_begin() \\\n        c.slen = length;\n\n/* End reading ASN1 with no check on length */\n# define M_ASN1_D2I_Finish_nolen(a, func, e) \\\n        *pp=c.p; \\\n        if (a != NULL) (*a)=ret; \\\n        return(ret); \\\nerr:\\\n        ASN1_MAC_H_err((e),c.error,c.line); \\\n        asn1_add_error(*pp,(int)(c.q- *pp)); \\\n        if ((ret != NULL) && ((a == NULL) || (*a != ret))) func(ret); \\\n        return(NULL)\n\n# define M_ASN1_D2I_end_sequence() \\\n        (((c.inf&1) == 0)?(c.slen <= 0): \\\n                (c.eos=ASN1_const_check_infinite_end(&c.p,c.slen)))\n\n/* Don't use this with d2i_ASN1_BOOLEAN() */\n# define M_ASN1_D2I_get(b, func) \\\n        c.q=c.p; \\\n        if (func(&(b),&c.p,c.slen) == NULL) \\\n                {c.line=__LINE__; goto err; } \\\n        c.slen-=(c.p-c.q);\n\n/* Don't use this with d2i_ASN1_BOOLEAN() */\n# define M_ASN1_D2I_get_x(type,b,func) \\\n        c.q=c.p; \\\n        if (((D2I_OF(type))func)(&(b),&c.p,c.slen) == NULL) \\\n                {c.line=__LINE__; goto err; } \\\n        c.slen-=(c.p-c.q);\n\n/* use this instead () */\n# define M_ASN1_D2I_get_int(b,func) \\\n        c.q=c.p; \\\n        if (func(&(b),&c.p,c.slen) < 0) \\\n                {c.line=__LINE__; goto err; } \\\n        c.slen-=(c.p-c.q);\n\n# define M_ASN1_D2I_get_opt(b,func,type) \\\n        if ((c.slen != 0) && ((M_ASN1_next & (~V_ASN1_CONSTRUCTED)) \\\n                == (V_ASN1_UNIVERSAL|(type)))) \\\n                { \\\n                M_ASN1_D2I_get(b,func); \\\n                }\n\n# define M_ASN1_D2I_get_int_opt(b,func,type) \\\n        if ((c.slen != 0) && ((M_ASN1_next & (~V_ASN1_CONSTRUCTED)) \\\n                == (V_ASN1_UNIVERSAL|(type)))) \\\n                { \\\n                M_ASN1_D2I_get_int(b,func); \\\n                }\n\n# define M_ASN1_D2I_get_imp(b,func, type) \\\n        M_ASN1_next=(_tmp& V_ASN1_CONSTRUCTED)|type; \\\n        c.q=c.p; \\\n        if (func(&(b),&c.p,c.slen) == NULL) \\\n                {c.line=__LINE__; M_ASN1_next_prev = _tmp; goto err; } \\\n        c.slen-=(c.p-c.q);\\\n        M_ASN1_next_prev=_tmp;\n\n# define M_ASN1_D2I_get_IMP_opt(b,func,tag,type) \\\n        if ((c.slen != 0) && ((M_ASN1_next & (~V_ASN1_CONSTRUCTED)) == \\\n                (V_ASN1_CONTEXT_SPECIFIC|(tag)))) \\\n                { \\\n                unsigned char _tmp = M_ASN1_next; \\\n                M_ASN1_D2I_get_imp(b,func, type);\\\n                }\n\n# define M_ASN1_D2I_get_set(r,func,free_func) \\\n                M_ASN1_D2I_get_imp_set(r,func,free_func, \\\n                        V_ASN1_SET,V_ASN1_UNIVERSAL);\n\n# define M_ASN1_D2I_get_set_type(type,r,func,free_func) \\\n                M_ASN1_D2I_get_imp_set_type(type,r,func,free_func, \\\n                        V_ASN1_SET,V_ASN1_UNIVERSAL);\n\n# define M_ASN1_D2I_get_set_opt(r,func,free_func) \\\n        if ((c.slen != 0) && (M_ASN1_next == (V_ASN1_UNIVERSAL| \\\n                V_ASN1_CONSTRUCTED|V_ASN1_SET)))\\\n                { M_ASN1_D2I_get_set(r,func,free_func); }\n\n# define M_ASN1_D2I_get_set_opt_type(type,r,func,free_func) \\\n        if ((c.slen != 0) && (M_ASN1_next == (V_ASN1_UNIVERSAL| \\\n                V_ASN1_CONSTRUCTED|V_ASN1_SET)))\\\n                { M_ASN1_D2I_get_set_type(type,r,func,free_func); }\n\n# define M_ASN1_I2D_len_SET_opt(a,f) \\\n        if ((a != NULL) && (sk_num(a) != 0)) \\\n                M_ASN1_I2D_len_SET(a,f);\n\n# define M_ASN1_I2D_put_SET_opt(a,f) \\\n        if ((a != NULL) && (sk_num(a) != 0)) \\\n                M_ASN1_I2D_put_SET(a,f);\n\n# define M_ASN1_I2D_put_SEQUENCE_opt(a,f) \\\n        if ((a != NULL) && (sk_num(a) != 0)) \\\n                M_ASN1_I2D_put_SEQUENCE(a,f);\n\n# define M_ASN1_I2D_put_SEQUENCE_opt_type(type,a,f) \\\n        if ((a != NULL) && (sk_##type##_num(a) != 0)) \\\n                M_ASN1_I2D_put_SEQUENCE_type(type,a,f);\n\n# define M_ASN1_D2I_get_IMP_set_opt(b,func,free_func,tag) \\\n        if ((c.slen != 0) && \\\n                (M_ASN1_next == \\\n                (V_ASN1_CONTEXT_SPECIFIC|V_ASN1_CONSTRUCTED|(tag))))\\\n                { \\\n                M_ASN1_D2I_get_imp_set(b,func,free_func,\\\n                        tag,V_ASN1_CONTEXT_SPECIFIC); \\\n                }\n\n# define M_ASN1_D2I_get_IMP_set_opt_type(type,b,func,free_func,tag) \\\n        if ((c.slen != 0) && \\\n                (M_ASN1_next == \\\n                (V_ASN1_CONTEXT_SPECIFIC|V_ASN1_CONSTRUCTED|(tag))))\\\n                { \\\n                M_ASN1_D2I_get_imp_set_type(type,b,func,free_func,\\\n                        tag,V_ASN1_CONTEXT_SPECIFIC); \\\n                }\n\n# define M_ASN1_D2I_get_seq(r,func,free_func) \\\n                M_ASN1_D2I_get_imp_set(r,func,free_func,\\\n                        V_ASN1_SEQUENCE,V_ASN1_UNIVERSAL);\n\n# define M_ASN1_D2I_get_seq_type(type,r,func,free_func) \\\n                M_ASN1_D2I_get_imp_set_type(type,r,func,free_func,\\\n                                            V_ASN1_SEQUENCE,V_ASN1_UNIVERSAL)\n\n# define M_ASN1_D2I_get_seq_opt(r,func,free_func) \\\n        if ((c.slen != 0) && (M_ASN1_next == (V_ASN1_UNIVERSAL| \\\n                V_ASN1_CONSTRUCTED|V_ASN1_SEQUENCE)))\\\n                { M_ASN1_D2I_get_seq(r,func,free_func); }\n\n# define M_ASN1_D2I_get_seq_opt_type(type,r,func,free_func) \\\n        if ((c.slen != 0) && (M_ASN1_next == (V_ASN1_UNIVERSAL| \\\n                V_ASN1_CONSTRUCTED|V_ASN1_SEQUENCE)))\\\n                { M_ASN1_D2I_get_seq_type(type,r,func,free_func); }\n\n# define M_ASN1_D2I_get_IMP_set(r,func,free_func,x) \\\n                M_ASN1_D2I_get_imp_set(r,func,free_func,\\\n                        x,V_ASN1_CONTEXT_SPECIFIC);\n\n# define M_ASN1_D2I_get_IMP_set_type(type,r,func,free_func,x) \\\n                M_ASN1_D2I_get_imp_set_type(type,r,func,free_func,\\\n                        x,V_ASN1_CONTEXT_SPECIFIC);\n\n# define M_ASN1_D2I_get_imp_set(r,func,free_func,a,b) \\\n        c.q=c.p; \\\n        if (d2i_ASN1_SET(&(r),&c.p,c.slen,(char *(*)())func,\\\n                (void (*)())free_func,a,b) == NULL) \\\n                { c.line=__LINE__; goto err; } \\\n        c.slen-=(c.p-c.q);\n\n# define M_ASN1_D2I_get_imp_set_type(type,r,func,free_func,a,b) \\\n        c.q=c.p; \\\n        if (d2i_ASN1_SET_OF_##type(&(r),&c.p,c.slen,func,\\\n                                   free_func,a,b) == NULL) \\\n                { c.line=__LINE__; goto err; } \\\n        c.slen-=(c.p-c.q);\n\n# define M_ASN1_D2I_get_set_strings(r,func,a,b) \\\n        c.q=c.p; \\\n        if (d2i_ASN1_STRING_SET(&(r),&c.p,c.slen,a,b) == NULL) \\\n                { c.line=__LINE__; goto err; } \\\n        c.slen-=(c.p-c.q);\n\n# define M_ASN1_D2I_get_EXP_opt(r,func,tag) \\\n        if ((c.slen != 0L) && (M_ASN1_next == \\\n                (V_ASN1_CONSTRUCTED|V_ASN1_CONTEXT_SPECIFIC|tag))) \\\n                { \\\n                int Tinf,Ttag,Tclass; \\\n                long Tlen; \\\n                \\\n                c.q=c.p; \\\n                Tinf=ASN1_get_object(&c.p,&Tlen,&Ttag,&Tclass,c.slen); \\\n                if (Tinf & 0x80) \\\n                        { c.error=ERR_R_BAD_ASN1_OBJECT_HEADER; \\\n                        c.line=__LINE__; goto err; } \\\n                if (Tinf == (V_ASN1_CONSTRUCTED+1)) \\\n                                        Tlen = c.slen - (c.p - c.q) - 2; \\\n                if (func(&(r),&c.p,Tlen) == NULL) \\\n                        { c.line=__LINE__; goto err; } \\\n                if (Tinf == (V_ASN1_CONSTRUCTED+1)) { \\\n                        Tlen = c.slen - (c.p - c.q); \\\n                        if(!ASN1_const_check_infinite_end(&c.p, Tlen)) \\\n                                { c.error=ERR_R_MISSING_ASN1_EOS; \\\n                                c.line=__LINE__; goto err; } \\\n                }\\\n                c.slen-=(c.p-c.q); \\\n                }\n\n# define M_ASN1_D2I_get_EXP_set_opt(r,func,free_func,tag,b) \\\n        if ((c.slen != 0) && (M_ASN1_next == \\\n                (V_ASN1_CONSTRUCTED|V_ASN1_CONTEXT_SPECIFIC|tag))) \\\n                { \\\n                int Tinf,Ttag,Tclass; \\\n                long Tlen; \\\n                \\\n                c.q=c.p; \\\n                Tinf=ASN1_get_object(&c.p,&Tlen,&Ttag,&Tclass,c.slen); \\\n                if (Tinf & 0x80) \\\n                        { c.error=ERR_R_BAD_ASN1_OBJECT_HEADER; \\\n                        c.line=__LINE__; goto err; } \\\n                if (Tinf == (V_ASN1_CONSTRUCTED+1)) \\\n                                        Tlen = c.slen - (c.p - c.q) - 2; \\\n                if (d2i_ASN1_SET(&(r),&c.p,Tlen,(char *(*)())func, \\\n                        (void (*)())free_func, \\\n                        b,V_ASN1_UNIVERSAL) == NULL) \\\n                        { c.line=__LINE__; goto err; } \\\n                if (Tinf == (V_ASN1_CONSTRUCTED+1)) { \\\n                        Tlen = c.slen - (c.p - c.q); \\\n                        if(!ASN1_check_infinite_end(&c.p, Tlen)) \\\n                                { c.error=ERR_R_MISSING_ASN1_EOS; \\\n                                c.line=__LINE__; goto err; } \\\n                }\\\n                c.slen-=(c.p-c.q); \\\n                }\n\n# define M_ASN1_D2I_get_EXP_set_opt_type(type,r,func,free_func,tag,b) \\\n        if ((c.slen != 0) && (M_ASN1_next == \\\n                (V_ASN1_CONSTRUCTED|V_ASN1_CONTEXT_SPECIFIC|tag))) \\\n                { \\\n                int Tinf,Ttag,Tclass; \\\n                long Tlen; \\\n                \\\n                c.q=c.p; \\\n                Tinf=ASN1_get_object(&c.p,&Tlen,&Ttag,&Tclass,c.slen); \\\n                if (Tinf & 0x80) \\\n                        { c.error=ERR_R_BAD_ASN1_OBJECT_HEADER; \\\n                        c.line=__LINE__; goto err; } \\\n                if (Tinf == (V_ASN1_CONSTRUCTED+1)) \\\n                                        Tlen = c.slen - (c.p - c.q) - 2; \\\n                if (d2i_ASN1_SET_OF_##type(&(r),&c.p,Tlen,func, \\\n                        free_func,b,V_ASN1_UNIVERSAL) == NULL) \\\n                        { c.line=__LINE__; goto err; } \\\n                if (Tinf == (V_ASN1_CONSTRUCTED+1)) { \\\n                        Tlen = c.slen - (c.p - c.q); \\\n                        if(!ASN1_check_infinite_end(&c.p, Tlen)) \\\n                                { c.error=ERR_R_MISSING_ASN1_EOS; \\\n                                c.line=__LINE__; goto err; } \\\n                }\\\n                c.slen-=(c.p-c.q); \\\n                }\n\n/* New macros */\n# define M_ASN1_New_Malloc(ret,type) \\\n        if ((ret=(type *)OPENSSL_malloc(sizeof(type))) == NULL) \\\n                { c.line=__LINE__; goto err2; }\n\n# define M_ASN1_New(arg,func) \\\n        if (((arg)=func()) == NULL) return(NULL)\n\n# define M_ASN1_New_Error(a) \\\n/*-     err:    ASN1_MAC_H_err((a),ERR_R_NESTED_ASN1_ERROR,c.line); \\\n                return(NULL);*/ \\\n        err2:   ASN1_MAC_H_err((a),ERR_R_MALLOC_FAILURE,c.line); \\\n                return(NULL)\n\n/*\n * BIG UGLY WARNING! This is so damn ugly I wanna puke.  Unfortunately, some\n * macros that use ASN1_const_CTX still insist on writing in the input\n * stream.  ARGH! ARGH! ARGH! Let's get rid of this macro package. Please? --\n * Richard Levitte\n */\n# define M_ASN1_next             (*((unsigned char *)(c.p)))\n# define M_ASN1_next_prev        (*((unsigned char *)(c.q)))\n\n/*************************************************/\n\n# define M_ASN1_I2D_vars(a)      int r=0,ret=0; \\\n                                unsigned char *p; \\\n                                if (a == NULL) return(0)\n\n/* Length Macros */\n# define M_ASN1_I2D_len(a,f)     ret+=f(a,NULL)\n# define M_ASN1_I2D_len_IMP_opt(a,f)     if (a != NULL) M_ASN1_I2D_len(a,f)\n\n# define M_ASN1_I2D_len_SET(a,f) \\\n                ret+=i2d_ASN1_SET(a,NULL,f,V_ASN1_SET,V_ASN1_UNIVERSAL,IS_SET);\n\n# define M_ASN1_I2D_len_SET_type(type,a,f) \\\n                ret+=i2d_ASN1_SET_OF_##type(a,NULL,f,V_ASN1_SET, \\\n                                            V_ASN1_UNIVERSAL,IS_SET);\n\n# define M_ASN1_I2D_len_SEQUENCE(a,f) \\\n                ret+=i2d_ASN1_SET(a,NULL,f,V_ASN1_SEQUENCE,V_ASN1_UNIVERSAL, \\\n                                  IS_SEQUENCE);\n\n# define M_ASN1_I2D_len_SEQUENCE_type(type,a,f) \\\n                ret+=i2d_ASN1_SET_OF_##type(a,NULL,f,V_ASN1_SEQUENCE, \\\n                                            V_ASN1_UNIVERSAL,IS_SEQUENCE)\n\n# define M_ASN1_I2D_len_SEQUENCE_opt(a,f) \\\n                if ((a != NULL) && (sk_num(a) != 0)) \\\n                        M_ASN1_I2D_len_SEQUENCE(a,f);\n\n# define M_ASN1_I2D_len_SEQUENCE_opt_type(type,a,f) \\\n                if ((a != NULL) && (sk_##type##_num(a) != 0)) \\\n                        M_ASN1_I2D_len_SEQUENCE_type(type,a,f);\n\n# define M_ASN1_I2D_len_IMP_SET(a,f,x) \\\n                ret+=i2d_ASN1_SET(a,NULL,f,x,V_ASN1_CONTEXT_SPECIFIC,IS_SET);\n\n# define M_ASN1_I2D_len_IMP_SET_type(type,a,f,x) \\\n                ret+=i2d_ASN1_SET_OF_##type(a,NULL,f,x, \\\n                                            V_ASN1_CONTEXT_SPECIFIC,IS_SET);\n\n# define M_ASN1_I2D_len_IMP_SET_opt(a,f,x) \\\n                if ((a != NULL) && (sk_num(a) != 0)) \\\n                        ret+=i2d_ASN1_SET(a,NULL,f,x,V_ASN1_CONTEXT_SPECIFIC, \\\n                                          IS_SET);\n\n# define M_ASN1_I2D_len_IMP_SET_opt_type(type,a,f,x) \\\n                if ((a != NULL) && (sk_##type##_num(a) != 0)) \\\n                        ret+=i2d_ASN1_SET_OF_##type(a,NULL,f,x, \\\n                                               V_ASN1_CONTEXT_SPECIFIC,IS_SET);\n\n# define M_ASN1_I2D_len_IMP_SEQUENCE(a,f,x) \\\n                ret+=i2d_ASN1_SET(a,NULL,f,x,V_ASN1_CONTEXT_SPECIFIC, \\\n                                  IS_SEQUENCE);\n\n# define M_ASN1_I2D_len_IMP_SEQUENCE_opt(a,f,x) \\\n                if ((a != NULL) && (sk_num(a) != 0)) \\\n                        ret+=i2d_ASN1_SET(a,NULL,f,x,V_ASN1_CONTEXT_SPECIFIC, \\\n                                          IS_SEQUENCE);\n\n# define M_ASN1_I2D_len_IMP_SEQUENCE_opt_type(type,a,f,x) \\\n                if ((a != NULL) && (sk_##type##_num(a) != 0)) \\\n                        ret+=i2d_ASN1_SET_OF_##type(a,NULL,f,x, \\\n                                                    V_ASN1_CONTEXT_SPECIFIC, \\\n                                                    IS_SEQUENCE);\n\n# define M_ASN1_I2D_len_EXP_opt(a,f,mtag,v) \\\n                if (a != NULL)\\\n                        { \\\n                        v=f(a,NULL); \\\n                        ret+=ASN1_object_size(1,v,mtag); \\\n                        }\n\n# define M_ASN1_I2D_len_EXP_SET_opt(a,f,mtag,tag,v) \\\n                if ((a != NULL) && (sk_num(a) != 0))\\\n                        { \\\n                        v=i2d_ASN1_SET(a,NULL,f,tag,V_ASN1_UNIVERSAL,IS_SET); \\\n                        ret+=ASN1_object_size(1,v,mtag); \\\n                        }\n\n# define M_ASN1_I2D_len_EXP_SEQUENCE_opt(a,f,mtag,tag,v) \\\n                if ((a != NULL) && (sk_num(a) != 0))\\\n                        { \\\n                        v=i2d_ASN1_SET(a,NULL,f,tag,V_ASN1_UNIVERSAL, \\\n                                       IS_SEQUENCE); \\\n                        ret+=ASN1_object_size(1,v,mtag); \\\n                        }\n\n# define M_ASN1_I2D_len_EXP_SEQUENCE_opt_type(type,a,f,mtag,tag,v) \\\n                if ((a != NULL) && (sk_##type##_num(a) != 0))\\\n                        { \\\n                        v=i2d_ASN1_SET_OF_##type(a,NULL,f,tag, \\\n                                                 V_ASN1_UNIVERSAL, \\\n                                                 IS_SEQUENCE); \\\n                        ret+=ASN1_object_size(1,v,mtag); \\\n                        }\n\n/* Put Macros */\n# define M_ASN1_I2D_put(a,f)     f(a,&p)\n\n# define M_ASN1_I2D_put_IMP_opt(a,f,t)   \\\n                if (a != NULL) \\\n                        { \\\n                        unsigned char *q=p; \\\n                        f(a,&p); \\\n                        *q=(V_ASN1_CONTEXT_SPECIFIC|t|(*q&V_ASN1_CONSTRUCTED));\\\n                        }\n\n# define M_ASN1_I2D_put_SET(a,f) i2d_ASN1_SET(a,&p,f,V_ASN1_SET,\\\n                        V_ASN1_UNIVERSAL,IS_SET)\n# define M_ASN1_I2D_put_SET_type(type,a,f) \\\n     i2d_ASN1_SET_OF_##type(a,&p,f,V_ASN1_SET,V_ASN1_UNIVERSAL,IS_SET)\n# define M_ASN1_I2D_put_IMP_SET(a,f,x) i2d_ASN1_SET(a,&p,f,x,\\\n                        V_ASN1_CONTEXT_SPECIFIC,IS_SET)\n# define M_ASN1_I2D_put_IMP_SET_type(type,a,f,x) \\\n     i2d_ASN1_SET_OF_##type(a,&p,f,x,V_ASN1_CONTEXT_SPECIFIC,IS_SET)\n# define M_ASN1_I2D_put_IMP_SEQUENCE(a,f,x) i2d_ASN1_SET(a,&p,f,x,\\\n                        V_ASN1_CONTEXT_SPECIFIC,IS_SEQUENCE)\n\n# define M_ASN1_I2D_put_SEQUENCE(a,f) i2d_ASN1_SET(a,&p,f,V_ASN1_SEQUENCE,\\\n                                             V_ASN1_UNIVERSAL,IS_SEQUENCE)\n\n# define M_ASN1_I2D_put_SEQUENCE_type(type,a,f) \\\n     i2d_ASN1_SET_OF_##type(a,&p,f,V_ASN1_SEQUENCE,V_ASN1_UNIVERSAL, \\\n                            IS_SEQUENCE)\n\n# define M_ASN1_I2D_put_SEQUENCE_opt(a,f) \\\n                if ((a != NULL) && (sk_num(a) != 0)) \\\n                        M_ASN1_I2D_put_SEQUENCE(a,f);\n\n# define M_ASN1_I2D_put_IMP_SET_opt(a,f,x) \\\n                if ((a != NULL) && (sk_num(a) != 0)) \\\n                        { i2d_ASN1_SET(a,&p,f,x,V_ASN1_CONTEXT_SPECIFIC, \\\n                                       IS_SET); }\n\n# define M_ASN1_I2D_put_IMP_SET_opt_type(type,a,f,x) \\\n                if ((a != NULL) && (sk_##type##_num(a) != 0)) \\\n                        { i2d_ASN1_SET_OF_##type(a,&p,f,x, \\\n                                                 V_ASN1_CONTEXT_SPECIFIC, \\\n                                                 IS_SET); }\n\n# define M_ASN1_I2D_put_IMP_SEQUENCE_opt(a,f,x) \\\n                if ((a != NULL) && (sk_num(a) != 0)) \\\n                        { i2d_ASN1_SET(a,&p,f,x,V_ASN1_CONTEXT_SPECIFIC, \\\n                                       IS_SEQUENCE); }\n\n# define M_ASN1_I2D_put_IMP_SEQUENCE_opt_type(type,a,f,x) \\\n                if ((a != NULL) && (sk_##type##_num(a) != 0)) \\\n                        { i2d_ASN1_SET_OF_##type(a,&p,f,x, \\\n                                                 V_ASN1_CONTEXT_SPECIFIC, \\\n                                                 IS_SEQUENCE); }\n\n# define M_ASN1_I2D_put_EXP_opt(a,f,tag,v) \\\n                if (a != NULL) \\\n                        { \\\n                        ASN1_put_object(&p,1,v,tag,V_ASN1_CONTEXT_SPECIFIC); \\\n                        f(a,&p); \\\n                        }\n\n# define M_ASN1_I2D_put_EXP_SET_opt(a,f,mtag,tag,v) \\\n                if ((a != NULL) && (sk_num(a) != 0)) \\\n                        { \\\n                        ASN1_put_object(&p,1,v,mtag,V_ASN1_CONTEXT_SPECIFIC); \\\n                        i2d_ASN1_SET(a,&p,f,tag,V_ASN1_UNIVERSAL,IS_SET); \\\n                        }\n\n# define M_ASN1_I2D_put_EXP_SEQUENCE_opt(a,f,mtag,tag,v) \\\n                if ((a != NULL) && (sk_num(a) != 0)) \\\n                        { \\\n                        ASN1_put_object(&p,1,v,mtag,V_ASN1_CONTEXT_SPECIFIC); \\\n                        i2d_ASN1_SET(a,&p,f,tag,V_ASN1_UNIVERSAL,IS_SEQUENCE); \\\n                        }\n\n# define M_ASN1_I2D_put_EXP_SEQUENCE_opt_type(type,a,f,mtag,tag,v) \\\n                if ((a != NULL) && (sk_##type##_num(a) != 0)) \\\n                        { \\\n                        ASN1_put_object(&p,1,v,mtag,V_ASN1_CONTEXT_SPECIFIC); \\\n                        i2d_ASN1_SET_OF_##type(a,&p,f,tag,V_ASN1_UNIVERSAL, \\\n                                               IS_SEQUENCE); \\\n                        }\n\n# define M_ASN1_I2D_seq_total() \\\n                r=ASN1_object_size(1,ret,V_ASN1_SEQUENCE); \\\n                if (pp == NULL) return(r); \\\n                p= *pp; \\\n                ASN1_put_object(&p,1,ret,V_ASN1_SEQUENCE,V_ASN1_UNIVERSAL)\n\n# define M_ASN1_I2D_INF_seq_start(tag,ctx) \\\n                *(p++)=(V_ASN1_CONSTRUCTED|(tag)|(ctx)); \\\n                *(p++)=0x80\n\n# define M_ASN1_I2D_INF_seq_end() *(p++)=0x00; *(p++)=0x00\n\n# define M_ASN1_I2D_finish()     *pp=p; \\\n                                return(r);\n\nint asn1_GetSequence(ASN1_const_CTX *c, long *length);\nvoid asn1_add_error(const unsigned char *address, int offset);\n#ifdef  __cplusplus\n}\n#endif\n\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/x86_64/include/openssl/asn1t.h",
    "content": "/* asn1t.h */\n/*\n * Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL project\n * 2000.\n */\n/* ====================================================================\n * Copyright (c) 2000-2005 The OpenSSL Project.  All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n *\n * 1. Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n *\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in\n *    the documentation and/or other materials provided with the\n *    distribution.\n *\n * 3. All advertising materials mentioning features or use of this\n *    software must display the following acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)\"\n *\n * 4. The names \"OpenSSL Toolkit\" and \"OpenSSL Project\" must not be used to\n *    endorse or promote products derived from this software without\n *    prior written permission. For written permission, please contact\n *    licensing@OpenSSL.org.\n *\n * 5. Products derived from this software may not be called \"OpenSSL\"\n *    nor may \"OpenSSL\" appear in their names without prior written\n *    permission of the OpenSSL Project.\n *\n * 6. Redistributions of any form whatsoever must retain the following\n *    acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)\"\n *\n * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY\n * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\n * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR\n * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\n * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,\n * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED\n * OF THE POSSIBILITY OF SUCH DAMAGE.\n * ====================================================================\n *\n * This product includes cryptographic software written by Eric Young\n * (eay@cryptsoft.com).  This product includes software written by Tim\n * Hudson (tjh@cryptsoft.com).\n *\n */\n#ifndef HEADER_ASN1T_H\n# define HEADER_ASN1T_H\n\n# include <stddef.h>\n# include <openssl/e_os2.h>\n# include <openssl/asn1.h>\n\n# ifdef OPENSSL_BUILD_SHLIBCRYPTO\n#  undef OPENSSL_EXTERN\n#  define OPENSSL_EXTERN OPENSSL_EXPORT\n# endif\n\n/* ASN1 template defines, structures and functions */\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n# ifndef OPENSSL_EXPORT_VAR_AS_FUNCTION\n\n/* Macro to obtain ASN1_ADB pointer from a type (only used internally) */\n#  define ASN1_ADB_ptr(iptr) ((const ASN1_ADB *)(iptr))\n\n/* Macros for start and end of ASN1_ITEM definition */\n\n#  define ASN1_ITEM_start(itname) \\\n        OPENSSL_GLOBAL const ASN1_ITEM itname##_it = {\n\n#  define ASN1_ITEM_end(itname) \\\n                };\n\n# else\n\n/* Macro to obtain ASN1_ADB pointer from a type (only used internally) */\n#  define ASN1_ADB_ptr(iptr) ((const ASN1_ADB *)(iptr()))\n\n/* Macros for start and end of ASN1_ITEM definition */\n\n#  define ASN1_ITEM_start(itname) \\\n        const ASN1_ITEM * itname##_it(void) \\\n        { \\\n                static const ASN1_ITEM local_it = {\n\n#  define ASN1_ITEM_end(itname) \\\n                }; \\\n        return &local_it; \\\n        }\n\n# endif\n\n/* Macros to aid ASN1 template writing */\n\n# define ASN1_ITEM_TEMPLATE(tname) \\\n        static const ASN1_TEMPLATE tname##_item_tt\n\n# define ASN1_ITEM_TEMPLATE_END(tname) \\\n        ;\\\n        ASN1_ITEM_start(tname) \\\n                ASN1_ITYPE_PRIMITIVE,\\\n                -1,\\\n                &tname##_item_tt,\\\n                0,\\\n                NULL,\\\n                0,\\\n                #tname \\\n        ASN1_ITEM_end(tname)\n\n/* This is a ASN1 type which just embeds a template */\n\n/*-\n * This pair helps declare a SEQUENCE. We can do:\n *\n *      ASN1_SEQUENCE(stname) = {\n *              ... SEQUENCE components ...\n *      } ASN1_SEQUENCE_END(stname)\n *\n *      This will produce an ASN1_ITEM called stname_it\n *      for a structure called stname.\n *\n *      If you want the same structure but a different\n *      name then use:\n *\n *      ASN1_SEQUENCE(itname) = {\n *              ... SEQUENCE components ...\n *      } ASN1_SEQUENCE_END_name(stname, itname)\n *\n *      This will create an item called itname_it using\n *      a structure called stname.\n */\n\n# define ASN1_SEQUENCE(tname) \\\n        static const ASN1_TEMPLATE tname##_seq_tt[]\n\n# define ASN1_SEQUENCE_END(stname) ASN1_SEQUENCE_END_name(stname, stname)\n\n# define ASN1_SEQUENCE_END_name(stname, tname) \\\n        ;\\\n        ASN1_ITEM_start(tname) \\\n                ASN1_ITYPE_SEQUENCE,\\\n                V_ASN1_SEQUENCE,\\\n                tname##_seq_tt,\\\n                sizeof(tname##_seq_tt) / sizeof(ASN1_TEMPLATE),\\\n                NULL,\\\n                sizeof(stname),\\\n                #stname \\\n        ASN1_ITEM_end(tname)\n\n# define ASN1_NDEF_SEQUENCE(tname) \\\n        ASN1_SEQUENCE(tname)\n\n# define ASN1_NDEF_SEQUENCE_cb(tname, cb) \\\n        ASN1_SEQUENCE_cb(tname, cb)\n\n# define ASN1_SEQUENCE_cb(tname, cb) \\\n        static const ASN1_AUX tname##_aux = {NULL, 0, 0, 0, cb, 0}; \\\n        ASN1_SEQUENCE(tname)\n\n# define ASN1_BROKEN_SEQUENCE(tname) \\\n        static const ASN1_AUX tname##_aux = {NULL, ASN1_AFLG_BROKEN, 0, 0, 0, 0}; \\\n        ASN1_SEQUENCE(tname)\n\n# define ASN1_SEQUENCE_ref(tname, cb, lck) \\\n        static const ASN1_AUX tname##_aux = {NULL, ASN1_AFLG_REFCOUNT, offsetof(tname, references), lck, cb, 0}; \\\n        ASN1_SEQUENCE(tname)\n\n# define ASN1_SEQUENCE_enc(tname, enc, cb) \\\n        static const ASN1_AUX tname##_aux = {NULL, ASN1_AFLG_ENCODING, 0, 0, cb, offsetof(tname, enc)}; \\\n        ASN1_SEQUENCE(tname)\n\n# define ASN1_NDEF_SEQUENCE_END(tname) \\\n        ;\\\n        ASN1_ITEM_start(tname) \\\n                ASN1_ITYPE_NDEF_SEQUENCE,\\\n                V_ASN1_SEQUENCE,\\\n                tname##_seq_tt,\\\n                sizeof(tname##_seq_tt) / sizeof(ASN1_TEMPLATE),\\\n                NULL,\\\n                sizeof(tname),\\\n                #tname \\\n        ASN1_ITEM_end(tname)\n\n# define ASN1_BROKEN_SEQUENCE_END(stname) ASN1_SEQUENCE_END_ref(stname, stname)\n\n# define ASN1_SEQUENCE_END_enc(stname, tname) ASN1_SEQUENCE_END_ref(stname, tname)\n\n# define ASN1_SEQUENCE_END_cb(stname, tname) ASN1_SEQUENCE_END_ref(stname, tname)\n\n# define ASN1_SEQUENCE_END_ref(stname, tname) \\\n        ;\\\n        ASN1_ITEM_start(tname) \\\n                ASN1_ITYPE_SEQUENCE,\\\n                V_ASN1_SEQUENCE,\\\n                tname##_seq_tt,\\\n                sizeof(tname##_seq_tt) / sizeof(ASN1_TEMPLATE),\\\n                &tname##_aux,\\\n                sizeof(stname),\\\n                #stname \\\n        ASN1_ITEM_end(tname)\n\n# define ASN1_NDEF_SEQUENCE_END_cb(stname, tname) \\\n        ;\\\n        ASN1_ITEM_start(tname) \\\n                ASN1_ITYPE_NDEF_SEQUENCE,\\\n                V_ASN1_SEQUENCE,\\\n                tname##_seq_tt,\\\n                sizeof(tname##_seq_tt) / sizeof(ASN1_TEMPLATE),\\\n                &tname##_aux,\\\n                sizeof(stname),\\\n                #stname \\\n        ASN1_ITEM_end(tname)\n\n/*-\n * This pair helps declare a CHOICE type. We can do:\n *\n *      ASN1_CHOICE(chname) = {\n *              ... CHOICE options ...\n *      ASN1_CHOICE_END(chname)\n *\n *      This will produce an ASN1_ITEM called chname_it\n *      for a structure called chname. The structure\n *      definition must look like this:\n *      typedef struct {\n *              int type;\n *              union {\n *                      ASN1_SOMETHING *opt1;\n *                      ASN1_SOMEOTHER *opt2;\n *              } value;\n *      } chname;\n *\n *      the name of the selector must be 'type'.\n *      to use an alternative selector name use the\n *      ASN1_CHOICE_END_selector() version.\n */\n\n# define ASN1_CHOICE(tname) \\\n        static const ASN1_TEMPLATE tname##_ch_tt[]\n\n# define ASN1_CHOICE_cb(tname, cb) \\\n        static const ASN1_AUX tname##_aux = {NULL, 0, 0, 0, cb, 0}; \\\n        ASN1_CHOICE(tname)\n\n# define ASN1_CHOICE_END(stname) ASN1_CHOICE_END_name(stname, stname)\n\n# define ASN1_CHOICE_END_name(stname, tname) ASN1_CHOICE_END_selector(stname, tname, type)\n\n# define ASN1_CHOICE_END_selector(stname, tname, selname) \\\n        ;\\\n        ASN1_ITEM_start(tname) \\\n                ASN1_ITYPE_CHOICE,\\\n                offsetof(stname,selname) ,\\\n                tname##_ch_tt,\\\n                sizeof(tname##_ch_tt) / sizeof(ASN1_TEMPLATE),\\\n                NULL,\\\n                sizeof(stname),\\\n                #stname \\\n        ASN1_ITEM_end(tname)\n\n# define ASN1_CHOICE_END_cb(stname, tname, selname) \\\n        ;\\\n        ASN1_ITEM_start(tname) \\\n                ASN1_ITYPE_CHOICE,\\\n                offsetof(stname,selname) ,\\\n                tname##_ch_tt,\\\n                sizeof(tname##_ch_tt) / sizeof(ASN1_TEMPLATE),\\\n                &tname##_aux,\\\n                sizeof(stname),\\\n                #stname \\\n        ASN1_ITEM_end(tname)\n\n/* This helps with the template wrapper form of ASN1_ITEM */\n\n# define ASN1_EX_TEMPLATE_TYPE(flags, tag, name, type) { \\\n        (flags), (tag), 0,\\\n        #name, ASN1_ITEM_ref(type) }\n\n/* These help with SEQUENCE or CHOICE components */\n\n/* used to declare other types */\n\n# define ASN1_EX_TYPE(flags, tag, stname, field, type) { \\\n        (flags), (tag), offsetof(stname, field),\\\n        #field, ASN1_ITEM_ref(type) }\n\n/* used when the structure is combined with the parent */\n\n# define ASN1_EX_COMBINE(flags, tag, type) { \\\n        (flags)|ASN1_TFLG_COMBINE, (tag), 0, NULL, ASN1_ITEM_ref(type) }\n\n/* implicit and explicit helper macros */\n\n# define ASN1_IMP_EX(stname, field, type, tag, ex) \\\n                ASN1_EX_TYPE(ASN1_TFLG_IMPLICIT | ex, tag, stname, field, type)\n\n# define ASN1_EXP_EX(stname, field, type, tag, ex) \\\n                ASN1_EX_TYPE(ASN1_TFLG_EXPLICIT | ex, tag, stname, field, type)\n\n/* Any defined by macros: the field used is in the table itself */\n\n# ifndef OPENSSL_EXPORT_VAR_AS_FUNCTION\n#  define ASN1_ADB_OBJECT(tblname) { ASN1_TFLG_ADB_OID, -1, 0, #tblname, (const ASN1_ITEM *)&(tblname##_adb) }\n#  define ASN1_ADB_INTEGER(tblname) { ASN1_TFLG_ADB_INT, -1, 0, #tblname, (const ASN1_ITEM *)&(tblname##_adb) }\n# else\n#  define ASN1_ADB_OBJECT(tblname) { ASN1_TFLG_ADB_OID, -1, 0, #tblname, tblname##_adb }\n#  define ASN1_ADB_INTEGER(tblname) { ASN1_TFLG_ADB_INT, -1, 0, #tblname, tblname##_adb }\n# endif\n/* Plain simple type */\n# define ASN1_SIMPLE(stname, field, type) ASN1_EX_TYPE(0,0, stname, field, type)\n\n/* OPTIONAL simple type */\n# define ASN1_OPT(stname, field, type) ASN1_EX_TYPE(ASN1_TFLG_OPTIONAL, 0, stname, field, type)\n\n/* IMPLICIT tagged simple type */\n# define ASN1_IMP(stname, field, type, tag) ASN1_IMP_EX(stname, field, type, tag, 0)\n\n/* IMPLICIT tagged OPTIONAL simple type */\n# define ASN1_IMP_OPT(stname, field, type, tag) ASN1_IMP_EX(stname, field, type, tag, ASN1_TFLG_OPTIONAL)\n\n/* Same as above but EXPLICIT */\n\n# define ASN1_EXP(stname, field, type, tag) ASN1_EXP_EX(stname, field, type, tag, 0)\n# define ASN1_EXP_OPT(stname, field, type, tag) ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_OPTIONAL)\n\n/* SEQUENCE OF type */\n# define ASN1_SEQUENCE_OF(stname, field, type) \\\n                ASN1_EX_TYPE(ASN1_TFLG_SEQUENCE_OF, 0, stname, field, type)\n\n/* OPTIONAL SEQUENCE OF */\n# define ASN1_SEQUENCE_OF_OPT(stname, field, type) \\\n                ASN1_EX_TYPE(ASN1_TFLG_SEQUENCE_OF|ASN1_TFLG_OPTIONAL, 0, stname, field, type)\n\n/* Same as above but for SET OF */\n\n# define ASN1_SET_OF(stname, field, type) \\\n                ASN1_EX_TYPE(ASN1_TFLG_SET_OF, 0, stname, field, type)\n\n# define ASN1_SET_OF_OPT(stname, field, type) \\\n                ASN1_EX_TYPE(ASN1_TFLG_SET_OF|ASN1_TFLG_OPTIONAL, 0, stname, field, type)\n\n/* Finally compound types of SEQUENCE, SET, IMPLICIT, EXPLICIT and OPTIONAL */\n\n# define ASN1_IMP_SET_OF(stname, field, type, tag) \\\n                        ASN1_IMP_EX(stname, field, type, tag, ASN1_TFLG_SET_OF)\n\n# define ASN1_EXP_SET_OF(stname, field, type, tag) \\\n                        ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_SET_OF)\n\n# define ASN1_IMP_SET_OF_OPT(stname, field, type, tag) \\\n                        ASN1_IMP_EX(stname, field, type, tag, ASN1_TFLG_SET_OF|ASN1_TFLG_OPTIONAL)\n\n# define ASN1_EXP_SET_OF_OPT(stname, field, type, tag) \\\n                        ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_SET_OF|ASN1_TFLG_OPTIONAL)\n\n# define ASN1_IMP_SEQUENCE_OF(stname, field, type, tag) \\\n                        ASN1_IMP_EX(stname, field, type, tag, ASN1_TFLG_SEQUENCE_OF)\n\n# define ASN1_IMP_SEQUENCE_OF_OPT(stname, field, type, tag) \\\n                        ASN1_IMP_EX(stname, field, type, tag, ASN1_TFLG_SEQUENCE_OF|ASN1_TFLG_OPTIONAL)\n\n# define ASN1_EXP_SEQUENCE_OF(stname, field, type, tag) \\\n                        ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_SEQUENCE_OF)\n\n# define ASN1_EXP_SEQUENCE_OF_OPT(stname, field, type, tag) \\\n                        ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_SEQUENCE_OF|ASN1_TFLG_OPTIONAL)\n\n/* EXPLICIT using indefinite length constructed form */\n# define ASN1_NDEF_EXP(stname, field, type, tag) \\\n                        ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_NDEF)\n\n/* EXPLICIT OPTIONAL using indefinite length constructed form */\n# define ASN1_NDEF_EXP_OPT(stname, field, type, tag) \\\n                        ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_OPTIONAL|ASN1_TFLG_NDEF)\n\n/* Macros for the ASN1_ADB structure */\n\n# define ASN1_ADB(name) \\\n        static const ASN1_ADB_TABLE name##_adbtbl[]\n\n# ifndef OPENSSL_EXPORT_VAR_AS_FUNCTION\n\n#  define ASN1_ADB_END(name, flags, field, app_table, def, none) \\\n        ;\\\n        static const ASN1_ADB name##_adb = {\\\n                flags,\\\n                offsetof(name, field),\\\n                app_table,\\\n                name##_adbtbl,\\\n                sizeof(name##_adbtbl) / sizeof(ASN1_ADB_TABLE),\\\n                def,\\\n                none\\\n        }\n\n# else\n\n#  define ASN1_ADB_END(name, flags, field, app_table, def, none) \\\n        ;\\\n        static const ASN1_ITEM *name##_adb(void) \\\n        { \\\n        static const ASN1_ADB internal_adb = \\\n                {\\\n                flags,\\\n                offsetof(name, field),\\\n                app_table,\\\n                name##_adbtbl,\\\n                sizeof(name##_adbtbl) / sizeof(ASN1_ADB_TABLE),\\\n                def,\\\n                none\\\n                }; \\\n                return (const ASN1_ITEM *) &internal_adb; \\\n        } \\\n        void dummy_function(void)\n\n# endif\n\n# define ADB_ENTRY(val, template) {val, template}\n\n# define ASN1_ADB_TEMPLATE(name) \\\n        static const ASN1_TEMPLATE name##_tt\n\n/*\n * This is the ASN1 template structure that defines a wrapper round the\n * actual type. It determines the actual position of the field in the value\n * structure, various flags such as OPTIONAL and the field name.\n */\n\nstruct ASN1_TEMPLATE_st {\n    unsigned long flags;        /* Various flags */\n    long tag;                   /* tag, not used if no tagging */\n    unsigned long offset;       /* Offset of this field in structure */\n# ifndef NO_ASN1_FIELD_NAMES\n    const char *field_name;     /* Field name */\n# endif\n    ASN1_ITEM_EXP *item;        /* Relevant ASN1_ITEM or ASN1_ADB */\n};\n\n/* Macro to extract ASN1_ITEM and ASN1_ADB pointer from ASN1_TEMPLATE */\n\n# define ASN1_TEMPLATE_item(t) (t->item_ptr)\n# define ASN1_TEMPLATE_adb(t) (t->item_ptr)\n\ntypedef struct ASN1_ADB_TABLE_st ASN1_ADB_TABLE;\ntypedef struct ASN1_ADB_st ASN1_ADB;\n\nstruct ASN1_ADB_st {\n    unsigned long flags;        /* Various flags */\n    unsigned long offset;       /* Offset of selector field */\n    STACK_OF(ASN1_ADB_TABLE) **app_items; /* Application defined items */\n    const ASN1_ADB_TABLE *tbl;  /* Table of possible types */\n    long tblcount;              /* Number of entries in tbl */\n    const ASN1_TEMPLATE *default_tt; /* Type to use if no match */\n    const ASN1_TEMPLATE *null_tt; /* Type to use if selector is NULL */\n};\n\nstruct ASN1_ADB_TABLE_st {\n    long value;                 /* NID for an object or value for an int */\n    const ASN1_TEMPLATE tt;     /* item for this value */\n};\n\n/* template flags */\n\n/* Field is optional */\n# define ASN1_TFLG_OPTIONAL      (0x1)\n\n/* Field is a SET OF */\n# define ASN1_TFLG_SET_OF        (0x1 << 1)\n\n/* Field is a SEQUENCE OF */\n# define ASN1_TFLG_SEQUENCE_OF   (0x2 << 1)\n\n/*\n * Special case: this refers to a SET OF that will be sorted into DER order\n * when encoded *and* the corresponding STACK will be modified to match the\n * new order.\n */\n# define ASN1_TFLG_SET_ORDER     (0x3 << 1)\n\n/* Mask for SET OF or SEQUENCE OF */\n# define ASN1_TFLG_SK_MASK       (0x3 << 1)\n\n/*\n * These flags mean the tag should be taken from the tag field. If EXPLICIT\n * then the underlying type is used for the inner tag.\n */\n\n/* IMPLICIT tagging */\n# define ASN1_TFLG_IMPTAG        (0x1 << 3)\n\n/* EXPLICIT tagging, inner tag from underlying type */\n# define ASN1_TFLG_EXPTAG        (0x2 << 3)\n\n# define ASN1_TFLG_TAG_MASK      (0x3 << 3)\n\n/* context specific IMPLICIT */\n# define ASN1_TFLG_IMPLICIT      ASN1_TFLG_IMPTAG|ASN1_TFLG_CONTEXT\n\n/* context specific EXPLICIT */\n# define ASN1_TFLG_EXPLICIT      ASN1_TFLG_EXPTAG|ASN1_TFLG_CONTEXT\n\n/*\n * If tagging is in force these determine the type of tag to use. Otherwise\n * the tag is determined by the underlying type. These values reflect the\n * actual octet format.\n */\n\n/* Universal tag */\n# define ASN1_TFLG_UNIVERSAL     (0x0<<6)\n/* Application tag */\n# define ASN1_TFLG_APPLICATION   (0x1<<6)\n/* Context specific tag */\n# define ASN1_TFLG_CONTEXT       (0x2<<6)\n/* Private tag */\n# define ASN1_TFLG_PRIVATE       (0x3<<6)\n\n# define ASN1_TFLG_TAG_CLASS     (0x3<<6)\n\n/*\n * These are for ANY DEFINED BY type. In this case the 'item' field points to\n * an ASN1_ADB structure which contains a table of values to decode the\n * relevant type\n */\n\n# define ASN1_TFLG_ADB_MASK      (0x3<<8)\n\n# define ASN1_TFLG_ADB_OID       (0x1<<8)\n\n# define ASN1_TFLG_ADB_INT       (0x1<<9)\n\n/*\n * This flag means a parent structure is passed instead of the field: this is\n * useful is a SEQUENCE is being combined with a CHOICE for example. Since\n * this means the structure and item name will differ we need to use the\n * ASN1_CHOICE_END_name() macro for example.\n */\n\n# define ASN1_TFLG_COMBINE       (0x1<<10)\n\n/*\n * This flag when present in a SEQUENCE OF, SET OF or EXPLICIT causes\n * indefinite length constructed encoding to be used if required.\n */\n\n# define ASN1_TFLG_NDEF          (0x1<<11)\n\n/* This is the actual ASN1 item itself */\n\nstruct ASN1_ITEM_st {\n    char itype;                 /* The item type, primitive, SEQUENCE, CHOICE\n                                 * or extern */\n    long utype;                 /* underlying type */\n    const ASN1_TEMPLATE *templates; /* If SEQUENCE or CHOICE this contains\n                                     * the contents */\n    long tcount;                /* Number of templates if SEQUENCE or CHOICE */\n    const void *funcs;          /* functions that handle this type */\n    long size;                  /* Structure size (usually) */\n# ifndef NO_ASN1_FIELD_NAMES\n    const char *sname;          /* Structure name */\n# endif\n};\n\n/*-\n * These are values for the itype field and\n * determine how the type is interpreted.\n *\n * For PRIMITIVE types the underlying type\n * determines the behaviour if items is NULL.\n *\n * Otherwise templates must contain a single\n * template and the type is treated in the\n * same way as the type specified in the template.\n *\n * For SEQUENCE types the templates field points\n * to the members, the size field is the\n * structure size.\n *\n * For CHOICE types the templates field points\n * to each possible member (typically a union)\n * and the 'size' field is the offset of the\n * selector.\n *\n * The 'funcs' field is used for application\n * specific functions.\n *\n * For COMPAT types the funcs field gives a\n * set of functions that handle this type, this\n * supports the old d2i, i2d convention.\n *\n * The EXTERN type uses a new style d2i/i2d.\n * The new style should be used where possible\n * because it avoids things like the d2i IMPLICIT\n * hack.\n *\n * MSTRING is a multiple string type, it is used\n * for a CHOICE of character strings where the\n * actual strings all occupy an ASN1_STRING\n * structure. In this case the 'utype' field\n * has a special meaning, it is used as a mask\n * of acceptable types using the B_ASN1 constants.\n *\n * NDEF_SEQUENCE is the same as SEQUENCE except\n * that it will use indefinite length constructed\n * encoding if requested.\n *\n */\n\n# define ASN1_ITYPE_PRIMITIVE            0x0\n\n# define ASN1_ITYPE_SEQUENCE             0x1\n\n# define ASN1_ITYPE_CHOICE               0x2\n\n# define ASN1_ITYPE_COMPAT               0x3\n\n# define ASN1_ITYPE_EXTERN               0x4\n\n# define ASN1_ITYPE_MSTRING              0x5\n\n# define ASN1_ITYPE_NDEF_SEQUENCE        0x6\n\n/*\n * Cache for ASN1 tag and length, so we don't keep re-reading it for things\n * like CHOICE\n */\n\nstruct ASN1_TLC_st {\n    char valid;                 /* Values below are valid */\n    int ret;                    /* return value */\n    long plen;                  /* length */\n    int ptag;                   /* class value */\n    int pclass;                 /* class value */\n    int hdrlen;                 /* header length */\n};\n\n/* Typedefs for ASN1 function pointers */\n\ntypedef ASN1_VALUE *ASN1_new_func(void);\ntypedef void ASN1_free_func(ASN1_VALUE *a);\ntypedef ASN1_VALUE *ASN1_d2i_func(ASN1_VALUE **a, const unsigned char **in,\n                                  long length);\ntypedef int ASN1_i2d_func(ASN1_VALUE *a, unsigned char **in);\n\ntypedef int ASN1_ex_d2i(ASN1_VALUE **pval, const unsigned char **in, long len,\n                        const ASN1_ITEM *it, int tag, int aclass, char opt,\n                        ASN1_TLC *ctx);\n\ntypedef int ASN1_ex_i2d(ASN1_VALUE **pval, unsigned char **out,\n                        const ASN1_ITEM *it, int tag, int aclass);\ntypedef int ASN1_ex_new_func(ASN1_VALUE **pval, const ASN1_ITEM *it);\ntypedef void ASN1_ex_free_func(ASN1_VALUE **pval, const ASN1_ITEM *it);\n\ntypedef int ASN1_ex_print_func(BIO *out, ASN1_VALUE **pval,\n                               int indent, const char *fname,\n                               const ASN1_PCTX *pctx);\n\ntypedef int ASN1_primitive_i2c(ASN1_VALUE **pval, unsigned char *cont,\n                               int *putype, const ASN1_ITEM *it);\ntypedef int ASN1_primitive_c2i(ASN1_VALUE **pval, const unsigned char *cont,\n                               int len, int utype, char *free_cont,\n                               const ASN1_ITEM *it);\ntypedef int ASN1_primitive_print(BIO *out, ASN1_VALUE **pval,\n                                 const ASN1_ITEM *it, int indent,\n                                 const ASN1_PCTX *pctx);\n\ntypedef struct ASN1_COMPAT_FUNCS_st {\n    ASN1_new_func *asn1_new;\n    ASN1_free_func *asn1_free;\n    ASN1_d2i_func *asn1_d2i;\n    ASN1_i2d_func *asn1_i2d;\n} ASN1_COMPAT_FUNCS;\n\ntypedef struct ASN1_EXTERN_FUNCS_st {\n    void *app_data;\n    ASN1_ex_new_func *asn1_ex_new;\n    ASN1_ex_free_func *asn1_ex_free;\n    ASN1_ex_free_func *asn1_ex_clear;\n    ASN1_ex_d2i *asn1_ex_d2i;\n    ASN1_ex_i2d *asn1_ex_i2d;\n    ASN1_ex_print_func *asn1_ex_print;\n} ASN1_EXTERN_FUNCS;\n\ntypedef struct ASN1_PRIMITIVE_FUNCS_st {\n    void *app_data;\n    unsigned long flags;\n    ASN1_ex_new_func *prim_new;\n    ASN1_ex_free_func *prim_free;\n    ASN1_ex_free_func *prim_clear;\n    ASN1_primitive_c2i *prim_c2i;\n    ASN1_primitive_i2c *prim_i2c;\n    ASN1_primitive_print *prim_print;\n} ASN1_PRIMITIVE_FUNCS;\n\n/*\n * This is the ASN1_AUX structure: it handles various miscellaneous\n * requirements. For example the use of reference counts and an informational\n * callback. The \"informational callback\" is called at various points during\n * the ASN1 encoding and decoding. It can be used to provide minor\n * customisation of the structures used. This is most useful where the\n * supplied routines *almost* do the right thing but need some extra help at\n * a few points. If the callback returns zero then it is assumed a fatal\n * error has occurred and the main operation should be abandoned. If major\n * changes in the default behaviour are required then an external type is\n * more appropriate.\n */\n\ntypedef int ASN1_aux_cb(int operation, ASN1_VALUE **in, const ASN1_ITEM *it,\n                        void *exarg);\n\ntypedef struct ASN1_AUX_st {\n    void *app_data;\n    int flags;\n    int ref_offset;             /* Offset of reference value */\n    int ref_lock;               /* Lock type to use */\n    ASN1_aux_cb *asn1_cb;\n    int enc_offset;             /* Offset of ASN1_ENCODING structure */\n} ASN1_AUX;\n\n/* For print related callbacks exarg points to this structure */\ntypedef struct ASN1_PRINT_ARG_st {\n    BIO *out;\n    int indent;\n    const ASN1_PCTX *pctx;\n} ASN1_PRINT_ARG;\n\n/* For streaming related callbacks exarg points to this structure */\ntypedef struct ASN1_STREAM_ARG_st {\n    /* BIO to stream through */\n    BIO *out;\n    /* BIO with filters appended */\n    BIO *ndef_bio;\n    /* Streaming I/O boundary */\n    unsigned char **boundary;\n} ASN1_STREAM_ARG;\n\n/* Flags in ASN1_AUX */\n\n/* Use a reference count */\n# define ASN1_AFLG_REFCOUNT      1\n/* Save the encoding of structure (useful for signatures) */\n# define ASN1_AFLG_ENCODING      2\n/* The Sequence length is invalid */\n# define ASN1_AFLG_BROKEN        4\n\n/* operation values for asn1_cb */\n\n# define ASN1_OP_NEW_PRE         0\n# define ASN1_OP_NEW_POST        1\n# define ASN1_OP_FREE_PRE        2\n# define ASN1_OP_FREE_POST       3\n# define ASN1_OP_D2I_PRE         4\n# define ASN1_OP_D2I_POST        5\n# define ASN1_OP_I2D_PRE         6\n# define ASN1_OP_I2D_POST        7\n# define ASN1_OP_PRINT_PRE       8\n# define ASN1_OP_PRINT_POST      9\n# define ASN1_OP_STREAM_PRE      10\n# define ASN1_OP_STREAM_POST     11\n# define ASN1_OP_DETACHED_PRE    12\n# define ASN1_OP_DETACHED_POST   13\n\n/* Macro to implement a primitive type */\n# define IMPLEMENT_ASN1_TYPE(stname) IMPLEMENT_ASN1_TYPE_ex(stname, stname, 0)\n# define IMPLEMENT_ASN1_TYPE_ex(itname, vname, ex) \\\n                                ASN1_ITEM_start(itname) \\\n                                        ASN1_ITYPE_PRIMITIVE, V_##vname, NULL, 0, NULL, ex, #itname \\\n                                ASN1_ITEM_end(itname)\n\n/* Macro to implement a multi string type */\n# define IMPLEMENT_ASN1_MSTRING(itname, mask) \\\n                                ASN1_ITEM_start(itname) \\\n                                        ASN1_ITYPE_MSTRING, mask, NULL, 0, NULL, sizeof(ASN1_STRING), #itname \\\n                                ASN1_ITEM_end(itname)\n\n/* Macro to implement an ASN1_ITEM in terms of old style funcs */\n\n# define IMPLEMENT_COMPAT_ASN1(sname) IMPLEMENT_COMPAT_ASN1_type(sname, V_ASN1_SEQUENCE)\n\n# define IMPLEMENT_COMPAT_ASN1_type(sname, tag) \\\n        static const ASN1_COMPAT_FUNCS sname##_ff = { \\\n                (ASN1_new_func *)sname##_new, \\\n                (ASN1_free_func *)sname##_free, \\\n                (ASN1_d2i_func *)d2i_##sname, \\\n                (ASN1_i2d_func *)i2d_##sname, \\\n        }; \\\n        ASN1_ITEM_start(sname) \\\n                ASN1_ITYPE_COMPAT, \\\n                tag, \\\n                NULL, \\\n                0, \\\n                &sname##_ff, \\\n                0, \\\n                #sname \\\n        ASN1_ITEM_end(sname)\n\n# define IMPLEMENT_EXTERN_ASN1(sname, tag, fptrs) \\\n        ASN1_ITEM_start(sname) \\\n                ASN1_ITYPE_EXTERN, \\\n                tag, \\\n                NULL, \\\n                0, \\\n                &fptrs, \\\n                0, \\\n                #sname \\\n        ASN1_ITEM_end(sname)\n\n/* Macro to implement standard functions in terms of ASN1_ITEM structures */\n\n# define IMPLEMENT_ASN1_FUNCTIONS(stname) IMPLEMENT_ASN1_FUNCTIONS_fname(stname, stname, stname)\n\n# define IMPLEMENT_ASN1_FUNCTIONS_name(stname, itname) IMPLEMENT_ASN1_FUNCTIONS_fname(stname, itname, itname)\n\n# define IMPLEMENT_ASN1_FUNCTIONS_ENCODE_name(stname, itname) \\\n                        IMPLEMENT_ASN1_FUNCTIONS_ENCODE_fname(stname, itname, itname)\n\n# define IMPLEMENT_STATIC_ASN1_ALLOC_FUNCTIONS(stname) \\\n                IMPLEMENT_ASN1_ALLOC_FUNCTIONS_pfname(static, stname, stname, stname)\n\n# define IMPLEMENT_ASN1_ALLOC_FUNCTIONS(stname) \\\n                IMPLEMENT_ASN1_ALLOC_FUNCTIONS_fname(stname, stname, stname)\n\n# define IMPLEMENT_ASN1_ALLOC_FUNCTIONS_pfname(pre, stname, itname, fname) \\\n        pre stname *fname##_new(void) \\\n        { \\\n                return (stname *)ASN1_item_new(ASN1_ITEM_rptr(itname)); \\\n        } \\\n        pre void fname##_free(stname *a) \\\n        { \\\n                ASN1_item_free((ASN1_VALUE *)a, ASN1_ITEM_rptr(itname)); \\\n        }\n\n# define IMPLEMENT_ASN1_ALLOC_FUNCTIONS_fname(stname, itname, fname) \\\n        stname *fname##_new(void) \\\n        { \\\n                return (stname *)ASN1_item_new(ASN1_ITEM_rptr(itname)); \\\n        } \\\n        void fname##_free(stname *a) \\\n        { \\\n                ASN1_item_free((ASN1_VALUE *)a, ASN1_ITEM_rptr(itname)); \\\n        }\n\n# define IMPLEMENT_ASN1_FUNCTIONS_fname(stname, itname, fname) \\\n        IMPLEMENT_ASN1_ENCODE_FUNCTIONS_fname(stname, itname, fname) \\\n        IMPLEMENT_ASN1_ALLOC_FUNCTIONS_fname(stname, itname, fname)\n\n# define IMPLEMENT_ASN1_ENCODE_FUNCTIONS_fname(stname, itname, fname) \\\n        stname *d2i_##fname(stname **a, const unsigned char **in, long len) \\\n        { \\\n                return (stname *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, ASN1_ITEM_rptr(itname));\\\n        } \\\n        int i2d_##fname(stname *a, unsigned char **out) \\\n        { \\\n                return ASN1_item_i2d((ASN1_VALUE *)a, out, ASN1_ITEM_rptr(itname));\\\n        }\n\n# define IMPLEMENT_ASN1_NDEF_FUNCTION(stname) \\\n        int i2d_##stname##_NDEF(stname *a, unsigned char **out) \\\n        { \\\n                return ASN1_item_ndef_i2d((ASN1_VALUE *)a, out, ASN1_ITEM_rptr(stname));\\\n        }\n\n/*\n * This includes evil casts to remove const: they will go away when full ASN1\n * constification is done.\n */\n# define IMPLEMENT_ASN1_ENCODE_FUNCTIONS_const_fname(stname, itname, fname) \\\n        stname *d2i_##fname(stname **a, const unsigned char **in, long len) \\\n        { \\\n                return (stname *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, ASN1_ITEM_rptr(itname));\\\n        } \\\n        int i2d_##fname(const stname *a, unsigned char **out) \\\n        { \\\n                return ASN1_item_i2d((ASN1_VALUE *)a, out, ASN1_ITEM_rptr(itname));\\\n        }\n\n# define IMPLEMENT_ASN1_DUP_FUNCTION(stname) \\\n        stname * stname##_dup(stname *x) \\\n        { \\\n        return ASN1_item_dup(ASN1_ITEM_rptr(stname), x); \\\n        }\n\n# define IMPLEMENT_ASN1_PRINT_FUNCTION(stname) \\\n        IMPLEMENT_ASN1_PRINT_FUNCTION_fname(stname, stname, stname)\n\n# define IMPLEMENT_ASN1_PRINT_FUNCTION_fname(stname, itname, fname) \\\n        int fname##_print_ctx(BIO *out, stname *x, int indent, \\\n                                                const ASN1_PCTX *pctx) \\\n        { \\\n                return ASN1_item_print(out, (ASN1_VALUE *)x, indent, \\\n                        ASN1_ITEM_rptr(itname), pctx); \\\n        }\n\n# define IMPLEMENT_ASN1_FUNCTIONS_const(name) \\\n                IMPLEMENT_ASN1_FUNCTIONS_const_fname(name, name, name)\n\n# define IMPLEMENT_ASN1_FUNCTIONS_const_fname(stname, itname, fname) \\\n        IMPLEMENT_ASN1_ENCODE_FUNCTIONS_const_fname(stname, itname, fname) \\\n        IMPLEMENT_ASN1_ALLOC_FUNCTIONS_fname(stname, itname, fname)\n\n/* external definitions for primitive types */\n\nDECLARE_ASN1_ITEM(ASN1_BOOLEAN)\nDECLARE_ASN1_ITEM(ASN1_TBOOLEAN)\nDECLARE_ASN1_ITEM(ASN1_FBOOLEAN)\nDECLARE_ASN1_ITEM(ASN1_SEQUENCE)\nDECLARE_ASN1_ITEM(CBIGNUM)\nDECLARE_ASN1_ITEM(BIGNUM)\nDECLARE_ASN1_ITEM(LONG)\nDECLARE_ASN1_ITEM(ZLONG)\n\nDECLARE_STACK_OF(ASN1_VALUE)\n\n/* Functions used internally by the ASN1 code */\n\nint ASN1_item_ex_new(ASN1_VALUE **pval, const ASN1_ITEM *it);\nvoid ASN1_item_ex_free(ASN1_VALUE **pval, const ASN1_ITEM *it);\nint ASN1_template_new(ASN1_VALUE **pval, const ASN1_TEMPLATE *tt);\nint ASN1_primitive_new(ASN1_VALUE **pval, const ASN1_ITEM *it);\n\nvoid ASN1_template_free(ASN1_VALUE **pval, const ASN1_TEMPLATE *tt);\nint ASN1_template_d2i(ASN1_VALUE **pval, const unsigned char **in, long len,\n                      const ASN1_TEMPLATE *tt);\nint ASN1_item_ex_d2i(ASN1_VALUE **pval, const unsigned char **in, long len,\n                     const ASN1_ITEM *it, int tag, int aclass, char opt,\n                     ASN1_TLC *ctx);\n\nint ASN1_item_ex_i2d(ASN1_VALUE **pval, unsigned char **out,\n                     const ASN1_ITEM *it, int tag, int aclass);\nint ASN1_template_i2d(ASN1_VALUE **pval, unsigned char **out,\n                      const ASN1_TEMPLATE *tt);\nvoid ASN1_primitive_free(ASN1_VALUE **pval, const ASN1_ITEM *it);\n\nint asn1_ex_i2c(ASN1_VALUE **pval, unsigned char *cont, int *putype,\n                const ASN1_ITEM *it);\nint asn1_ex_c2i(ASN1_VALUE **pval, const unsigned char *cont, int len,\n                int utype, char *free_cont, const ASN1_ITEM *it);\n\nint asn1_get_choice_selector(ASN1_VALUE **pval, const ASN1_ITEM *it);\nint asn1_set_choice_selector(ASN1_VALUE **pval, int value,\n                             const ASN1_ITEM *it);\n\nASN1_VALUE **asn1_get_field_ptr(ASN1_VALUE **pval, const ASN1_TEMPLATE *tt);\n\nconst ASN1_TEMPLATE *asn1_do_adb(ASN1_VALUE **pval, const ASN1_TEMPLATE *tt,\n                                 int nullerr);\n\nint asn1_do_lock(ASN1_VALUE **pval, int op, const ASN1_ITEM *it);\n\nvoid asn1_enc_init(ASN1_VALUE **pval, const ASN1_ITEM *it);\nvoid asn1_enc_free(ASN1_VALUE **pval, const ASN1_ITEM *it);\nint asn1_enc_restore(int *len, unsigned char **out, ASN1_VALUE **pval,\n                     const ASN1_ITEM *it);\nint asn1_enc_save(ASN1_VALUE **pval, const unsigned char *in, int inlen,\n                  const ASN1_ITEM *it);\n\n#ifdef  __cplusplus\n}\n#endif\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/x86_64/include/openssl/bio.h",
    "content": "/* crypto/bio/bio.h */\n/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)\n * All rights reserved.\n *\n * This package is an SSL implementation written\n * by Eric Young (eay@cryptsoft.com).\n * The implementation was written so as to conform with Netscapes SSL.\n *\n * This library is free for commercial and non-commercial use as long as\n * the following conditions are aheared to.  The following conditions\n * apply to all code found in this distribution, be it the RC4, RSA,\n * lhash, DES, etc., code; not just the SSL code.  The SSL documentation\n * included with this distribution is covered by the same copyright terms\n * except that the holder is Tim Hudson (tjh@cryptsoft.com).\n *\n * Copyright remains Eric Young's, and as such any Copyright notices in\n * the code are not to be removed.\n * If this package is used in a product, Eric Young should be given attribution\n * as the author of the parts of the library used.\n * This can be in the form of a textual message at program startup or\n * in documentation (online or textual) provided with the package.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the copyright\n *    notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in the\n *    documentation and/or other materials provided with the distribution.\n * 3. All advertising materials mentioning features or use of this software\n *    must display the following acknowledgement:\n *    \"This product includes cryptographic software written by\n *     Eric Young (eay@cryptsoft.com)\"\n *    The word 'cryptographic' can be left out if the rouines from the library\n *    being used are not cryptographic related :-).\n * 4. If you include any Windows specific code (or a derivative thereof) from\n *    the apps directory (application code) you must include an acknowledgement:\n *    \"This product includes software written by Tim Hudson (tjh@cryptsoft.com)\"\n *\n * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n * SUCH DAMAGE.\n *\n * The licence and distribution terms for any publically available version or\n * derivative of this code cannot be changed.  i.e. this code cannot simply be\n * copied and put under another distribution licence\n * [including the GNU Public Licence.]\n */\n\n#ifndef HEADER_BIO_H\n# define HEADER_BIO_H\n\n# include <openssl/e_os2.h>\n\n# ifndef OPENSSL_NO_FP_API\n#  include <stdio.h>\n# endif\n# include <stdarg.h>\n\n# include <openssl/crypto.h>\n\n# ifndef OPENSSL_NO_SCTP\n#  ifndef OPENSSL_SYS_VMS\n#   include <stdint.h>\n#  else\n#   include <inttypes.h>\n#  endif\n# endif\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n/* These are the 'types' of BIOs */\n# define BIO_TYPE_NONE           0\n# define BIO_TYPE_MEM            (1|0x0400)\n# define BIO_TYPE_FILE           (2|0x0400)\n\n# define BIO_TYPE_FD             (4|0x0400|0x0100)\n# define BIO_TYPE_SOCKET         (5|0x0400|0x0100)\n# define BIO_TYPE_NULL           (6|0x0400)\n# define BIO_TYPE_SSL            (7|0x0200)\n# define BIO_TYPE_MD             (8|0x0200)/* passive filter */\n# define BIO_TYPE_BUFFER         (9|0x0200)/* filter */\n# define BIO_TYPE_CIPHER         (10|0x0200)/* filter */\n# define BIO_TYPE_BASE64         (11|0x0200)/* filter */\n# define BIO_TYPE_CONNECT        (12|0x0400|0x0100)/* socket - connect */\n# define BIO_TYPE_ACCEPT         (13|0x0400|0x0100)/* socket for accept */\n# define BIO_TYPE_PROXY_CLIENT   (14|0x0200)/* client proxy BIO */\n# define BIO_TYPE_PROXY_SERVER   (15|0x0200)/* server proxy BIO */\n# define BIO_TYPE_NBIO_TEST      (16|0x0200)/* server proxy BIO */\n# define BIO_TYPE_NULL_FILTER    (17|0x0200)\n# define BIO_TYPE_BER            (18|0x0200)/* BER -> bin filter */\n# define BIO_TYPE_BIO            (19|0x0400)/* (half a) BIO pair */\n# define BIO_TYPE_LINEBUFFER     (20|0x0200)/* filter */\n# define BIO_TYPE_DGRAM          (21|0x0400|0x0100)\n# ifndef OPENSSL_NO_SCTP\n#  define BIO_TYPE_DGRAM_SCTP     (24|0x0400|0x0100)\n# endif\n# define BIO_TYPE_ASN1           (22|0x0200)/* filter */\n# define BIO_TYPE_COMP           (23|0x0200)/* filter */\n\n# define BIO_TYPE_DESCRIPTOR     0x0100/* socket, fd, connect or accept */\n# define BIO_TYPE_FILTER         0x0200\n# define BIO_TYPE_SOURCE_SINK    0x0400\n\n/*\n * BIO_FILENAME_READ|BIO_CLOSE to open or close on free.\n * BIO_set_fp(in,stdin,BIO_NOCLOSE);\n */\n# define BIO_NOCLOSE             0x00\n# define BIO_CLOSE               0x01\n\n/*\n * These are used in the following macros and are passed to BIO_ctrl()\n */\n# define BIO_CTRL_RESET          1/* opt - rewind/zero etc */\n# define BIO_CTRL_EOF            2/* opt - are we at the eof */\n# define BIO_CTRL_INFO           3/* opt - extra tit-bits */\n# define BIO_CTRL_SET            4/* man - set the 'IO' type */\n# define BIO_CTRL_GET            5/* man - get the 'IO' type */\n# define BIO_CTRL_PUSH           6/* opt - internal, used to signify change */\n# define BIO_CTRL_POP            7/* opt - internal, used to signify change */\n# define BIO_CTRL_GET_CLOSE      8/* man - set the 'close' on free */\n# define BIO_CTRL_SET_CLOSE      9/* man - set the 'close' on free */\n# define BIO_CTRL_PENDING        10/* opt - is their more data buffered */\n# define BIO_CTRL_FLUSH          11/* opt - 'flush' buffered output */\n# define BIO_CTRL_DUP            12/* man - extra stuff for 'duped' BIO */\n# define BIO_CTRL_WPENDING       13/* opt - number of bytes still to write */\n/* callback is int cb(BIO *bio,state,ret); */\n# define BIO_CTRL_SET_CALLBACK   14/* opt - set callback function */\n# define BIO_CTRL_GET_CALLBACK   15/* opt - set callback function */\n\n# define BIO_CTRL_SET_FILENAME   30/* BIO_s_file special */\n\n/* dgram BIO stuff */\n# define BIO_CTRL_DGRAM_CONNECT       31/* BIO dgram special */\n# define BIO_CTRL_DGRAM_SET_CONNECTED 32/* allow for an externally connected\n                                         * socket to be passed in */\n# define BIO_CTRL_DGRAM_SET_RECV_TIMEOUT 33/* setsockopt, essentially */\n# define BIO_CTRL_DGRAM_GET_RECV_TIMEOUT 34/* getsockopt, essentially */\n# define BIO_CTRL_DGRAM_SET_SEND_TIMEOUT 35/* setsockopt, essentially */\n# define BIO_CTRL_DGRAM_GET_SEND_TIMEOUT 36/* getsockopt, essentially */\n\n# define BIO_CTRL_DGRAM_GET_RECV_TIMER_EXP 37/* flag whether the last */\n# define BIO_CTRL_DGRAM_GET_SEND_TIMER_EXP 38/* I/O operation tiemd out */\n\n/* #ifdef IP_MTU_DISCOVER */\n# define BIO_CTRL_DGRAM_MTU_DISCOVER       39/* set DF bit on egress packets */\n/* #endif */\n\n# define BIO_CTRL_DGRAM_QUERY_MTU          40/* as kernel for current MTU */\n# define BIO_CTRL_DGRAM_GET_FALLBACK_MTU   47\n# define BIO_CTRL_DGRAM_GET_MTU            41/* get cached value for MTU */\n# define BIO_CTRL_DGRAM_SET_MTU            42/* set cached value for MTU.\n                                              * want to use this if asking\n                                              * the kernel fails */\n\n# define BIO_CTRL_DGRAM_MTU_EXCEEDED       43/* check whether the MTU was\n                                              * exceed in the previous write\n                                              * operation */\n\n# define BIO_CTRL_DGRAM_GET_PEER           46\n# define BIO_CTRL_DGRAM_SET_PEER           44/* Destination for the data */\n\n# define BIO_CTRL_DGRAM_SET_NEXT_TIMEOUT   45/* Next DTLS handshake timeout\n                                              * to adjust socket timeouts */\n# define BIO_CTRL_DGRAM_SET_DONT_FRAG      48\n\n# define BIO_CTRL_DGRAM_GET_MTU_OVERHEAD   49\n\n# ifndef OPENSSL_NO_SCTP\n/* SCTP stuff */\n#  define BIO_CTRL_DGRAM_SCTP_SET_IN_HANDSHAKE    50\n#  define BIO_CTRL_DGRAM_SCTP_ADD_AUTH_KEY                51\n#  define BIO_CTRL_DGRAM_SCTP_NEXT_AUTH_KEY               52\n#  define BIO_CTRL_DGRAM_SCTP_AUTH_CCS_RCVD               53\n#  define BIO_CTRL_DGRAM_SCTP_GET_SNDINFO         60\n#  define BIO_CTRL_DGRAM_SCTP_SET_SNDINFO         61\n#  define BIO_CTRL_DGRAM_SCTP_GET_RCVINFO         62\n#  define BIO_CTRL_DGRAM_SCTP_SET_RCVINFO         63\n#  define BIO_CTRL_DGRAM_SCTP_GET_PRINFO                  64\n#  define BIO_CTRL_DGRAM_SCTP_SET_PRINFO                  65\n#  define BIO_CTRL_DGRAM_SCTP_SAVE_SHUTDOWN               70\n# endif\n\n/* modifiers */\n# define BIO_FP_READ             0x02\n# define BIO_FP_WRITE            0x04\n# define BIO_FP_APPEND           0x08\n# define BIO_FP_TEXT             0x10\n\n# define BIO_FLAGS_READ          0x01\n# define BIO_FLAGS_WRITE         0x02\n# define BIO_FLAGS_IO_SPECIAL    0x04\n# define BIO_FLAGS_RWS (BIO_FLAGS_READ|BIO_FLAGS_WRITE|BIO_FLAGS_IO_SPECIAL)\n# define BIO_FLAGS_SHOULD_RETRY  0x08\n# ifndef BIO_FLAGS_UPLINK\n/*\n * \"UPLINK\" flag denotes file descriptors provided by application. It\n * defaults to 0, as most platforms don't require UPLINK interface.\n */\n#  define BIO_FLAGS_UPLINK        0\n# endif\n\n/* Used in BIO_gethostbyname() */\n# define BIO_GHBN_CTRL_HITS              1\n# define BIO_GHBN_CTRL_MISSES            2\n# define BIO_GHBN_CTRL_CACHE_SIZE        3\n# define BIO_GHBN_CTRL_GET_ENTRY         4\n# define BIO_GHBN_CTRL_FLUSH             5\n\n/* Mostly used in the SSL BIO */\n/*-\n * Not used anymore\n * #define BIO_FLAGS_PROTOCOL_DELAYED_READ 0x10\n * #define BIO_FLAGS_PROTOCOL_DELAYED_WRITE 0x20\n * #define BIO_FLAGS_PROTOCOL_STARTUP   0x40\n */\n\n# define BIO_FLAGS_BASE64_NO_NL  0x100\n\n/*\n * This is used with memory BIOs: it means we shouldn't free up or change the\n * data in any way.\n */\n# define BIO_FLAGS_MEM_RDONLY    0x200\n\ntypedef struct bio_st BIO;\n\nvoid BIO_set_flags(BIO *b, int flags);\nint BIO_test_flags(const BIO *b, int flags);\nvoid BIO_clear_flags(BIO *b, int flags);\n\n# define BIO_get_flags(b) BIO_test_flags(b, ~(0x0))\n# define BIO_set_retry_special(b) \\\n                BIO_set_flags(b, (BIO_FLAGS_IO_SPECIAL|BIO_FLAGS_SHOULD_RETRY))\n# define BIO_set_retry_read(b) \\\n                BIO_set_flags(b, (BIO_FLAGS_READ|BIO_FLAGS_SHOULD_RETRY))\n# define BIO_set_retry_write(b) \\\n                BIO_set_flags(b, (BIO_FLAGS_WRITE|BIO_FLAGS_SHOULD_RETRY))\n\n/* These are normally used internally in BIOs */\n# define BIO_clear_retry_flags(b) \\\n                BIO_clear_flags(b, (BIO_FLAGS_RWS|BIO_FLAGS_SHOULD_RETRY))\n# define BIO_get_retry_flags(b) \\\n                BIO_test_flags(b, (BIO_FLAGS_RWS|BIO_FLAGS_SHOULD_RETRY))\n\n/* These should be used by the application to tell why we should retry */\n# define BIO_should_read(a)              BIO_test_flags(a, BIO_FLAGS_READ)\n# define BIO_should_write(a)             BIO_test_flags(a, BIO_FLAGS_WRITE)\n# define BIO_should_io_special(a)        BIO_test_flags(a, BIO_FLAGS_IO_SPECIAL)\n# define BIO_retry_type(a)               BIO_test_flags(a, BIO_FLAGS_RWS)\n# define BIO_should_retry(a)             BIO_test_flags(a, BIO_FLAGS_SHOULD_RETRY)\n\n/*\n * The next three are used in conjunction with the BIO_should_io_special()\n * condition.  After this returns true, BIO *BIO_get_retry_BIO(BIO *bio, int\n * *reason); will walk the BIO stack and return the 'reason' for the special\n * and the offending BIO. Given a BIO, BIO_get_retry_reason(bio) will return\n * the code.\n */\n/*\n * Returned from the SSL bio when the certificate retrieval code had an error\n */\n# define BIO_RR_SSL_X509_LOOKUP          0x01\n/* Returned from the connect BIO when a connect would have blocked */\n# define BIO_RR_CONNECT                  0x02\n/* Returned from the accept BIO when an accept would have blocked */\n# define BIO_RR_ACCEPT                   0x03\n\n/* These are passed by the BIO callback */\n# define BIO_CB_FREE     0x01\n# define BIO_CB_READ     0x02\n# define BIO_CB_WRITE    0x03\n# define BIO_CB_PUTS     0x04\n# define BIO_CB_GETS     0x05\n# define BIO_CB_CTRL     0x06\n\n/*\n * The callback is called before and after the underling operation, The\n * BIO_CB_RETURN flag indicates if it is after the call\n */\n# define BIO_CB_RETURN   0x80\n# define BIO_CB_return(a) ((a)|BIO_CB_RETURN)\n# define BIO_cb_pre(a)   (!((a)&BIO_CB_RETURN))\n# define BIO_cb_post(a)  ((a)&BIO_CB_RETURN)\n\nlong (*BIO_get_callback(const BIO *b)) (struct bio_st *, int, const char *,\n                                        int, long, long);\nvoid BIO_set_callback(BIO *b,\n                      long (*callback) (struct bio_st *, int, const char *,\n                                        int, long, long));\nchar *BIO_get_callback_arg(const BIO *b);\nvoid BIO_set_callback_arg(BIO *b, char *arg);\n\nconst char *BIO_method_name(const BIO *b);\nint BIO_method_type(const BIO *b);\n\ntypedef void bio_info_cb (struct bio_st *, int, const char *, int, long,\n                          long);\n\ntypedef struct bio_method_st {\n    int type;\n    const char *name;\n    int (*bwrite) (BIO *, const char *, int);\n    int (*bread) (BIO *, char *, int);\n    int (*bputs) (BIO *, const char *);\n    int (*bgets) (BIO *, char *, int);\n    long (*ctrl) (BIO *, int, long, void *);\n    int (*create) (BIO *);\n    int (*destroy) (BIO *);\n    long (*callback_ctrl) (BIO *, int, bio_info_cb *);\n} BIO_METHOD;\n\nstruct bio_st {\n    BIO_METHOD *method;\n    /* bio, mode, argp, argi, argl, ret */\n    long (*callback) (struct bio_st *, int, const char *, int, long, long);\n    char *cb_arg;               /* first argument for the callback */\n    int init;\n    int shutdown;\n    int flags;                  /* extra storage */\n    int retry_reason;\n    int num;\n    void *ptr;\n    struct bio_st *next_bio;    /* used by filter BIOs */\n    struct bio_st *prev_bio;    /* used by filter BIOs */\n    int references;\n    unsigned long num_read;\n    unsigned long num_write;\n    CRYPTO_EX_DATA ex_data;\n};\n\nDECLARE_STACK_OF(BIO)\n\ntypedef struct bio_f_buffer_ctx_struct {\n    /*-\n     * Buffers are setup like this:\n     *\n     * <---------------------- size ----------------------->\n     * +---------------------------------------------------+\n     * | consumed | remaining          | free space        |\n     * +---------------------------------------------------+\n     * <-- off --><------- len ------->\n     */\n    /*- BIO *bio; *//*\n     * this is now in the BIO struct\n     */\n    int ibuf_size;              /* how big is the input buffer */\n    int obuf_size;              /* how big is the output buffer */\n    char *ibuf;                 /* the char array */\n    int ibuf_len;               /* how many bytes are in it */\n    int ibuf_off;               /* write/read offset */\n    char *obuf;                 /* the char array */\n    int obuf_len;               /* how many bytes are in it */\n    int obuf_off;               /* write/read offset */\n} BIO_F_BUFFER_CTX;\n\n/* Prefix and suffix callback in ASN1 BIO */\ntypedef int asn1_ps_func (BIO *b, unsigned char **pbuf, int *plen,\n                          void *parg);\n\n# ifndef OPENSSL_NO_SCTP\n/* SCTP parameter structs */\nstruct bio_dgram_sctp_sndinfo {\n    uint16_t snd_sid;\n    uint16_t snd_flags;\n    uint32_t snd_ppid;\n    uint32_t snd_context;\n};\n\nstruct bio_dgram_sctp_rcvinfo {\n    uint16_t rcv_sid;\n    uint16_t rcv_ssn;\n    uint16_t rcv_flags;\n    uint32_t rcv_ppid;\n    uint32_t rcv_tsn;\n    uint32_t rcv_cumtsn;\n    uint32_t rcv_context;\n};\n\nstruct bio_dgram_sctp_prinfo {\n    uint16_t pr_policy;\n    uint32_t pr_value;\n};\n# endif\n\n/* connect BIO stuff */\n# define BIO_CONN_S_BEFORE               1\n# define BIO_CONN_S_GET_IP               2\n# define BIO_CONN_S_GET_PORT             3\n# define BIO_CONN_S_CREATE_SOCKET        4\n# define BIO_CONN_S_CONNECT              5\n# define BIO_CONN_S_OK                   6\n# define BIO_CONN_S_BLOCKED_CONNECT      7\n# define BIO_CONN_S_NBIO                 8\n/*\n * #define BIO_CONN_get_param_hostname BIO_ctrl\n */\n\n# define BIO_C_SET_CONNECT                       100\n# define BIO_C_DO_STATE_MACHINE                  101\n# define BIO_C_SET_NBIO                          102\n# define BIO_C_SET_PROXY_PARAM                   103\n# define BIO_C_SET_FD                            104\n# define BIO_C_GET_FD                            105\n# define BIO_C_SET_FILE_PTR                      106\n# define BIO_C_GET_FILE_PTR                      107\n# define BIO_C_SET_FILENAME                      108\n# define BIO_C_SET_SSL                           109\n# define BIO_C_GET_SSL                           110\n# define BIO_C_SET_MD                            111\n# define BIO_C_GET_MD                            112\n# define BIO_C_GET_CIPHER_STATUS                 113\n# define BIO_C_SET_BUF_MEM                       114\n# define BIO_C_GET_BUF_MEM_PTR                   115\n# define BIO_C_GET_BUFF_NUM_LINES                116\n# define BIO_C_SET_BUFF_SIZE                     117\n# define BIO_C_SET_ACCEPT                        118\n# define BIO_C_SSL_MODE                          119\n# define BIO_C_GET_MD_CTX                        120\n# define BIO_C_GET_PROXY_PARAM                   121\n# define BIO_C_SET_BUFF_READ_DATA                122/* data to read first */\n# define BIO_C_GET_CONNECT                       123\n# define BIO_C_GET_ACCEPT                        124\n# define BIO_C_SET_SSL_RENEGOTIATE_BYTES         125\n# define BIO_C_GET_SSL_NUM_RENEGOTIATES          126\n# define BIO_C_SET_SSL_RENEGOTIATE_TIMEOUT       127\n# define BIO_C_FILE_SEEK                         128\n# define BIO_C_GET_CIPHER_CTX                    129\n# define BIO_C_SET_BUF_MEM_EOF_RETURN            130/* return end of input\n                                                     * value */\n# define BIO_C_SET_BIND_MODE                     131\n# define BIO_C_GET_BIND_MODE                     132\n# define BIO_C_FILE_TELL                         133\n# define BIO_C_GET_SOCKS                         134\n# define BIO_C_SET_SOCKS                         135\n\n# define BIO_C_SET_WRITE_BUF_SIZE                136/* for BIO_s_bio */\n# define BIO_C_GET_WRITE_BUF_SIZE                137\n# define BIO_C_MAKE_BIO_PAIR                     138\n# define BIO_C_DESTROY_BIO_PAIR                  139\n# define BIO_C_GET_WRITE_GUARANTEE               140\n# define BIO_C_GET_READ_REQUEST                  141\n# define BIO_C_SHUTDOWN_WR                       142\n# define BIO_C_NREAD0                            143\n# define BIO_C_NREAD                             144\n# define BIO_C_NWRITE0                           145\n# define BIO_C_NWRITE                            146\n# define BIO_C_RESET_READ_REQUEST                147\n# define BIO_C_SET_MD_CTX                        148\n\n# define BIO_C_SET_PREFIX                        149\n# define BIO_C_GET_PREFIX                        150\n# define BIO_C_SET_SUFFIX                        151\n# define BIO_C_GET_SUFFIX                        152\n\n# define BIO_C_SET_EX_ARG                        153\n# define BIO_C_GET_EX_ARG                        154\n\n# define BIO_set_app_data(s,arg)         BIO_set_ex_data(s,0,arg)\n# define BIO_get_app_data(s)             BIO_get_ex_data(s,0)\n\n/* BIO_s_connect() and BIO_s_socks4a_connect() */\n# define BIO_set_conn_hostname(b,name) BIO_ctrl(b,BIO_C_SET_CONNECT,0,(char *)name)\n# define BIO_set_conn_port(b,port) BIO_ctrl(b,BIO_C_SET_CONNECT,1,(char *)port)\n# define BIO_set_conn_ip(b,ip)     BIO_ctrl(b,BIO_C_SET_CONNECT,2,(char *)ip)\n# define BIO_set_conn_int_port(b,port) BIO_ctrl(b,BIO_C_SET_CONNECT,3,(char *)port)\n# define BIO_get_conn_hostname(b)  BIO_ptr_ctrl(b,BIO_C_GET_CONNECT,0)\n# define BIO_get_conn_port(b)      BIO_ptr_ctrl(b,BIO_C_GET_CONNECT,1)\n# define BIO_get_conn_ip(b)               BIO_ptr_ctrl(b,BIO_C_GET_CONNECT,2)\n# define BIO_get_conn_int_port(b) BIO_ctrl(b,BIO_C_GET_CONNECT,3,NULL)\n\n# define BIO_set_nbio(b,n)       BIO_ctrl(b,BIO_C_SET_NBIO,(n),NULL)\n\n/* BIO_s_accept() */\n# define BIO_set_accept_port(b,name) BIO_ctrl(b,BIO_C_SET_ACCEPT,0,(char *)name)\n# define BIO_get_accept_port(b)  BIO_ptr_ctrl(b,BIO_C_GET_ACCEPT,0)\n/* #define BIO_set_nbio(b,n)    BIO_ctrl(b,BIO_C_SET_NBIO,(n),NULL) */\n# define BIO_set_nbio_accept(b,n) BIO_ctrl(b,BIO_C_SET_ACCEPT,1,(n)?(void *)\"a\":NULL)\n# define BIO_set_accept_bios(b,bio) BIO_ctrl(b,BIO_C_SET_ACCEPT,2,(char *)bio)\n\n# define BIO_BIND_NORMAL                 0\n# define BIO_BIND_REUSEADDR_IF_UNUSED    1\n# define BIO_BIND_REUSEADDR              2\n# define BIO_set_bind_mode(b,mode) BIO_ctrl(b,BIO_C_SET_BIND_MODE,mode,NULL)\n# define BIO_get_bind_mode(b,mode) BIO_ctrl(b,BIO_C_GET_BIND_MODE,0,NULL)\n\n/* BIO_s_accept() and BIO_s_connect() */\n# define BIO_do_connect(b)       BIO_do_handshake(b)\n# define BIO_do_accept(b)        BIO_do_handshake(b)\n# define BIO_do_handshake(b)     BIO_ctrl(b,BIO_C_DO_STATE_MACHINE,0,NULL)\n\n/* BIO_s_proxy_client() */\n# define BIO_set_url(b,url)      BIO_ctrl(b,BIO_C_SET_PROXY_PARAM,0,(char *)(url))\n# define BIO_set_proxies(b,p)    BIO_ctrl(b,BIO_C_SET_PROXY_PARAM,1,(char *)(p))\n/* BIO_set_nbio(b,n) */\n# define BIO_set_filter_bio(b,s) BIO_ctrl(b,BIO_C_SET_PROXY_PARAM,2,(char *)(s))\n/* BIO *BIO_get_filter_bio(BIO *bio); */\n# define BIO_set_proxy_cb(b,cb) BIO_callback_ctrl(b,BIO_C_SET_PROXY_PARAM,3,(void *(*cb)()))\n# define BIO_set_proxy_header(b,sk) BIO_ctrl(b,BIO_C_SET_PROXY_PARAM,4,(char *)sk)\n# define BIO_set_no_connect_return(b,bool) BIO_int_ctrl(b,BIO_C_SET_PROXY_PARAM,5,bool)\n\n# define BIO_get_proxy_header(b,skp) BIO_ctrl(b,BIO_C_GET_PROXY_PARAM,0,(char *)skp)\n# define BIO_get_proxies(b,pxy_p) BIO_ctrl(b,BIO_C_GET_PROXY_PARAM,1,(char *)(pxy_p))\n# define BIO_get_url(b,url)      BIO_ctrl(b,BIO_C_GET_PROXY_PARAM,2,(char *)(url))\n# define BIO_get_no_connect_return(b)    BIO_ctrl(b,BIO_C_GET_PROXY_PARAM,5,NULL)\n\n/* BIO_s_datagram(), BIO_s_fd(), BIO_s_socket(), BIO_s_accept() and BIO_s_connect() */\n# define BIO_set_fd(b,fd,c)      BIO_int_ctrl(b,BIO_C_SET_FD,c,fd)\n# define BIO_get_fd(b,c)         BIO_ctrl(b,BIO_C_GET_FD,0,(char *)c)\n\n/* BIO_s_file() */\n# define BIO_set_fp(b,fp,c)      BIO_ctrl(b,BIO_C_SET_FILE_PTR,c,(char *)fp)\n# define BIO_get_fp(b,fpp)       BIO_ctrl(b,BIO_C_GET_FILE_PTR,0,(char *)fpp)\n\n/* BIO_s_fd() and BIO_s_file() */\n# define BIO_seek(b,ofs) (int)BIO_ctrl(b,BIO_C_FILE_SEEK,ofs,NULL)\n# define BIO_tell(b)     (int)BIO_ctrl(b,BIO_C_FILE_TELL,0,NULL)\n\n/*\n * name is cast to lose const, but might be better to route through a\n * function so we can do it safely\n */\n# ifdef CONST_STRICT\n/*\n * If you are wondering why this isn't defined, its because CONST_STRICT is\n * purely a compile-time kludge to allow const to be checked.\n */\nint BIO_read_filename(BIO *b, const char *name);\n# else\n#  define BIO_read_filename(b,name) BIO_ctrl(b,BIO_C_SET_FILENAME, \\\n                BIO_CLOSE|BIO_FP_READ,(char *)name)\n# endif\n# define BIO_write_filename(b,name) BIO_ctrl(b,BIO_C_SET_FILENAME, \\\n                BIO_CLOSE|BIO_FP_WRITE,name)\n# define BIO_append_filename(b,name) BIO_ctrl(b,BIO_C_SET_FILENAME, \\\n                BIO_CLOSE|BIO_FP_APPEND,name)\n# define BIO_rw_filename(b,name) BIO_ctrl(b,BIO_C_SET_FILENAME, \\\n                BIO_CLOSE|BIO_FP_READ|BIO_FP_WRITE,name)\n\n/*\n * WARNING WARNING, this ups the reference count on the read bio of the SSL\n * structure.  This is because the ssl read BIO is now pointed to by the\n * next_bio field in the bio.  So when you free the BIO, make sure you are\n * doing a BIO_free_all() to catch the underlying BIO.\n */\n# define BIO_set_ssl(b,ssl,c)    BIO_ctrl(b,BIO_C_SET_SSL,c,(char *)ssl)\n# define BIO_get_ssl(b,sslp)     BIO_ctrl(b,BIO_C_GET_SSL,0,(char *)sslp)\n# define BIO_set_ssl_mode(b,client)      BIO_ctrl(b,BIO_C_SSL_MODE,client,NULL)\n# define BIO_set_ssl_renegotiate_bytes(b,num) \\\n        BIO_ctrl(b,BIO_C_SET_SSL_RENEGOTIATE_BYTES,num,NULL)\n# define BIO_get_num_renegotiates(b) \\\n        BIO_ctrl(b,BIO_C_GET_SSL_NUM_RENEGOTIATES,0,NULL)\n# define BIO_set_ssl_renegotiate_timeout(b,seconds) \\\n        BIO_ctrl(b,BIO_C_SET_SSL_RENEGOTIATE_TIMEOUT,seconds,NULL)\n\n/* defined in evp.h */\n/* #define BIO_set_md(b,md)     BIO_ctrl(b,BIO_C_SET_MD,1,(char *)md) */\n\n# define BIO_get_mem_data(b,pp)  BIO_ctrl(b,BIO_CTRL_INFO,0,(char *)pp)\n# define BIO_set_mem_buf(b,bm,c) BIO_ctrl(b,BIO_C_SET_BUF_MEM,c,(char *)bm)\n# define BIO_get_mem_ptr(b,pp)   BIO_ctrl(b,BIO_C_GET_BUF_MEM_PTR,0,(char *)pp)\n# define BIO_set_mem_eof_return(b,v) \\\n                                BIO_ctrl(b,BIO_C_SET_BUF_MEM_EOF_RETURN,v,NULL)\n\n/* For the BIO_f_buffer() type */\n# define BIO_get_buffer_num_lines(b)     BIO_ctrl(b,BIO_C_GET_BUFF_NUM_LINES,0,NULL)\n# define BIO_set_buffer_size(b,size)     BIO_ctrl(b,BIO_C_SET_BUFF_SIZE,size,NULL)\n# define BIO_set_read_buffer_size(b,size) BIO_int_ctrl(b,BIO_C_SET_BUFF_SIZE,size,0)\n# define BIO_set_write_buffer_size(b,size) BIO_int_ctrl(b,BIO_C_SET_BUFF_SIZE,size,1)\n# define BIO_set_buffer_read_data(b,buf,num) BIO_ctrl(b,BIO_C_SET_BUFF_READ_DATA,num,buf)\n\n/* Don't use the next one unless you know what you are doing :-) */\n# define BIO_dup_state(b,ret)    BIO_ctrl(b,BIO_CTRL_DUP,0,(char *)(ret))\n\n# define BIO_reset(b)            (int)BIO_ctrl(b,BIO_CTRL_RESET,0,NULL)\n# define BIO_eof(b)              (int)BIO_ctrl(b,BIO_CTRL_EOF,0,NULL)\n# define BIO_set_close(b,c)      (int)BIO_ctrl(b,BIO_CTRL_SET_CLOSE,(c),NULL)\n# define BIO_get_close(b)        (int)BIO_ctrl(b,BIO_CTRL_GET_CLOSE,0,NULL)\n# define BIO_pending(b)          (int)BIO_ctrl(b,BIO_CTRL_PENDING,0,NULL)\n# define BIO_wpending(b)         (int)BIO_ctrl(b,BIO_CTRL_WPENDING,0,NULL)\n/* ...pending macros have inappropriate return type */\nsize_t BIO_ctrl_pending(BIO *b);\nsize_t BIO_ctrl_wpending(BIO *b);\n# define BIO_flush(b)            (int)BIO_ctrl(b,BIO_CTRL_FLUSH,0,NULL)\n# define BIO_get_info_callback(b,cbp) (int)BIO_ctrl(b,BIO_CTRL_GET_CALLBACK,0, \\\n                                                   cbp)\n# define BIO_set_info_callback(b,cb) (int)BIO_callback_ctrl(b,BIO_CTRL_SET_CALLBACK,cb)\n\n/* For the BIO_f_buffer() type */\n# define BIO_buffer_get_num_lines(b) BIO_ctrl(b,BIO_CTRL_GET,0,NULL)\n\n/* For BIO_s_bio() */\n# define BIO_set_write_buf_size(b,size) (int)BIO_ctrl(b,BIO_C_SET_WRITE_BUF_SIZE,size,NULL)\n# define BIO_get_write_buf_size(b,size) (size_t)BIO_ctrl(b,BIO_C_GET_WRITE_BUF_SIZE,size,NULL)\n# define BIO_make_bio_pair(b1,b2)   (int)BIO_ctrl(b1,BIO_C_MAKE_BIO_PAIR,0,b2)\n# define BIO_destroy_bio_pair(b)    (int)BIO_ctrl(b,BIO_C_DESTROY_BIO_PAIR,0,NULL)\n# define BIO_shutdown_wr(b) (int)BIO_ctrl(b, BIO_C_SHUTDOWN_WR, 0, NULL)\n/* macros with inappropriate type -- but ...pending macros use int too: */\n# define BIO_get_write_guarantee(b) (int)BIO_ctrl(b,BIO_C_GET_WRITE_GUARANTEE,0,NULL)\n# define BIO_get_read_request(b)    (int)BIO_ctrl(b,BIO_C_GET_READ_REQUEST,0,NULL)\nsize_t BIO_ctrl_get_write_guarantee(BIO *b);\nsize_t BIO_ctrl_get_read_request(BIO *b);\nint BIO_ctrl_reset_read_request(BIO *b);\n\n/* ctrl macros for dgram */\n# define BIO_ctrl_dgram_connect(b,peer)  \\\n                     (int)BIO_ctrl(b,BIO_CTRL_DGRAM_CONNECT,0, (char *)peer)\n# define BIO_ctrl_set_connected(b, state, peer) \\\n         (int)BIO_ctrl(b, BIO_CTRL_DGRAM_SET_CONNECTED, state, (char *)peer)\n# define BIO_dgram_recv_timedout(b) \\\n         (int)BIO_ctrl(b, BIO_CTRL_DGRAM_GET_RECV_TIMER_EXP, 0, NULL)\n# define BIO_dgram_send_timedout(b) \\\n         (int)BIO_ctrl(b, BIO_CTRL_DGRAM_GET_SEND_TIMER_EXP, 0, NULL)\n# define BIO_dgram_get_peer(b,peer) \\\n         (int)BIO_ctrl(b, BIO_CTRL_DGRAM_GET_PEER, 0, (char *)peer)\n# define BIO_dgram_set_peer(b,peer) \\\n         (int)BIO_ctrl(b, BIO_CTRL_DGRAM_SET_PEER, 0, (char *)peer)\n# define BIO_dgram_get_mtu_overhead(b) \\\n         (unsigned int)BIO_ctrl((b), BIO_CTRL_DGRAM_GET_MTU_OVERHEAD, 0, NULL)\n\n/* These two aren't currently implemented */\n/* int BIO_get_ex_num(BIO *bio); */\n/* void BIO_set_ex_free_func(BIO *bio,int idx,void (*cb)()); */\nint BIO_set_ex_data(BIO *bio, int idx, void *data);\nvoid *BIO_get_ex_data(BIO *bio, int idx);\nint BIO_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func,\n                         CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func);\nunsigned long BIO_number_read(BIO *bio);\nunsigned long BIO_number_written(BIO *bio);\n\n/* For BIO_f_asn1() */\nint BIO_asn1_set_prefix(BIO *b, asn1_ps_func *prefix,\n                        asn1_ps_func *prefix_free);\nint BIO_asn1_get_prefix(BIO *b, asn1_ps_func **pprefix,\n                        asn1_ps_func **pprefix_free);\nint BIO_asn1_set_suffix(BIO *b, asn1_ps_func *suffix,\n                        asn1_ps_func *suffix_free);\nint BIO_asn1_get_suffix(BIO *b, asn1_ps_func **psuffix,\n                        asn1_ps_func **psuffix_free);\n\n# ifndef OPENSSL_NO_FP_API\nBIO_METHOD *BIO_s_file(void);\nBIO *BIO_new_file(const char *filename, const char *mode);\nBIO *BIO_new_fp(FILE *stream, int close_flag);\n#  define BIO_s_file_internal    BIO_s_file\n# endif\nBIO *BIO_new(BIO_METHOD *type);\nint BIO_set(BIO *a, BIO_METHOD *type);\nint BIO_free(BIO *a);\nvoid BIO_vfree(BIO *a);\nint BIO_read(BIO *b, void *data, int len);\nint BIO_gets(BIO *bp, char *buf, int size);\nint BIO_write(BIO *b, const void *data, int len);\nint BIO_puts(BIO *bp, const char *buf);\nint BIO_indent(BIO *b, int indent, int max);\nlong BIO_ctrl(BIO *bp, int cmd, long larg, void *parg);\nlong BIO_callback_ctrl(BIO *b, int cmd,\n                       void (*fp) (struct bio_st *, int, const char *, int,\n                                   long, long));\nchar *BIO_ptr_ctrl(BIO *bp, int cmd, long larg);\nlong BIO_int_ctrl(BIO *bp, int cmd, long larg, int iarg);\nBIO *BIO_push(BIO *b, BIO *append);\nBIO *BIO_pop(BIO *b);\nvoid BIO_free_all(BIO *a);\nBIO *BIO_find_type(BIO *b, int bio_type);\nBIO *BIO_next(BIO *b);\nBIO *BIO_get_retry_BIO(BIO *bio, int *reason);\nint BIO_get_retry_reason(BIO *bio);\nBIO *BIO_dup_chain(BIO *in);\n\nint BIO_nread0(BIO *bio, char **buf);\nint BIO_nread(BIO *bio, char **buf, int num);\nint BIO_nwrite0(BIO *bio, char **buf);\nint BIO_nwrite(BIO *bio, char **buf, int num);\n\nlong BIO_debug_callback(BIO *bio, int cmd, const char *argp, int argi,\n                        long argl, long ret);\n\nBIO_METHOD *BIO_s_mem(void);\nBIO *BIO_new_mem_buf(const void *buf, int len);\nBIO_METHOD *BIO_s_socket(void);\nBIO_METHOD *BIO_s_connect(void);\nBIO_METHOD *BIO_s_accept(void);\nBIO_METHOD *BIO_s_fd(void);\n# ifndef OPENSSL_SYS_OS2\nBIO_METHOD *BIO_s_log(void);\n# endif\nBIO_METHOD *BIO_s_bio(void);\nBIO_METHOD *BIO_s_null(void);\nBIO_METHOD *BIO_f_null(void);\nBIO_METHOD *BIO_f_buffer(void);\n# ifdef OPENSSL_SYS_VMS\nBIO_METHOD *BIO_f_linebuffer(void);\n# endif\nBIO_METHOD *BIO_f_nbio_test(void);\n# ifndef OPENSSL_NO_DGRAM\nBIO_METHOD *BIO_s_datagram(void);\n#  ifndef OPENSSL_NO_SCTP\nBIO_METHOD *BIO_s_datagram_sctp(void);\n#  endif\n# endif\n\n/* BIO_METHOD *BIO_f_ber(void); */\n\nint BIO_sock_should_retry(int i);\nint BIO_sock_non_fatal_error(int error);\nint BIO_dgram_non_fatal_error(int error);\n\nint BIO_fd_should_retry(int i);\nint BIO_fd_non_fatal_error(int error);\nint BIO_dump_cb(int (*cb) (const void *data, size_t len, void *u),\n                void *u, const char *s, int len);\nint BIO_dump_indent_cb(int (*cb) (const void *data, size_t len, void *u),\n                       void *u, const char *s, int len, int indent);\nint BIO_dump(BIO *b, const char *bytes, int len);\nint BIO_dump_indent(BIO *b, const char *bytes, int len, int indent);\n# ifndef OPENSSL_NO_FP_API\nint BIO_dump_fp(FILE *fp, const char *s, int len);\nint BIO_dump_indent_fp(FILE *fp, const char *s, int len, int indent);\n# endif\nint BIO_hex_string(BIO *out, int indent, int width, unsigned char *data,\n                   int datalen);\n\nstruct hostent *BIO_gethostbyname(const char *name);\n/*-\n * We might want a thread-safe interface too:\n * struct hostent *BIO_gethostbyname_r(const char *name,\n *     struct hostent *result, void *buffer, size_t buflen);\n * or something similar (caller allocates a struct hostent,\n * pointed to by \"result\", and additional buffer space for the various\n * substructures; if the buffer does not suffice, NULL is returned\n * and an appropriate error code is set).\n */\nint BIO_sock_error(int sock);\nint BIO_socket_ioctl(int fd, long type, void *arg);\nint BIO_socket_nbio(int fd, int mode);\nint BIO_get_port(const char *str, unsigned short *port_ptr);\nint BIO_get_host_ip(const char *str, unsigned char *ip);\nint BIO_get_accept_socket(char *host_port, int mode);\nint BIO_accept(int sock, char **ip_port);\nint BIO_sock_init(void);\nvoid BIO_sock_cleanup(void);\nint BIO_set_tcp_ndelay(int sock, int turn_on);\n\nBIO *BIO_new_socket(int sock, int close_flag);\nBIO *BIO_new_dgram(int fd, int close_flag);\n# ifndef OPENSSL_NO_SCTP\nBIO *BIO_new_dgram_sctp(int fd, int close_flag);\nint BIO_dgram_is_sctp(BIO *bio);\nint BIO_dgram_sctp_notification_cb(BIO *b,\n                                   void (*handle_notifications) (BIO *bio,\n                                                                 void\n                                                                 *context,\n                                                                 void *buf),\n                                   void *context);\nint BIO_dgram_sctp_wait_for_dry(BIO *b);\nint BIO_dgram_sctp_msg_waiting(BIO *b);\n# endif\nBIO *BIO_new_fd(int fd, int close_flag);\nBIO *BIO_new_connect(const char *host_port);\nBIO *BIO_new_accept(const char *host_port);\n\nint BIO_new_bio_pair(BIO **bio1, size_t writebuf1,\n                     BIO **bio2, size_t writebuf2);\n/*\n * If successful, returns 1 and in *bio1, *bio2 two BIO pair endpoints.\n * Otherwise returns 0 and sets *bio1 and *bio2 to NULL. Size 0 uses default\n * value.\n */\n\nvoid BIO_copy_next_retry(BIO *b);\n\n/*\n * long BIO_ghbn_ctrl(int cmd,int iarg,char *parg);\n */\n\n# ifdef __GNUC__\n#  define __bio_h__attr__ __attribute__\n# else\n#  define __bio_h__attr__(x)\n# endif\nint BIO_printf(BIO *bio, const char *format, ...)\n__bio_h__attr__((__format__(__printf__, 2, 3)));\nint BIO_vprintf(BIO *bio, const char *format, va_list args)\n__bio_h__attr__((__format__(__printf__, 2, 0)));\nint BIO_snprintf(char *buf, size_t n, const char *format, ...)\n__bio_h__attr__((__format__(__printf__, 3, 4)));\nint BIO_vsnprintf(char *buf, size_t n, const char *format, va_list args)\n__bio_h__attr__((__format__(__printf__, 3, 0)));\n# undef __bio_h__attr__\n\n/* BEGIN ERROR CODES */\n/*\n * The following lines are auto generated by the script mkerr.pl. Any changes\n * made after this point may be overwritten when the script is next run.\n */\nvoid ERR_load_BIO_strings(void);\n\n/* Error codes for the BIO functions. */\n\n/* Function codes. */\n# define BIO_F_ACPT_STATE                                 100\n# define BIO_F_BIO_ACCEPT                                 101\n# define BIO_F_BIO_BER_GET_HEADER                         102\n# define BIO_F_BIO_CALLBACK_CTRL                          131\n# define BIO_F_BIO_CTRL                                   103\n# define BIO_F_BIO_GETHOSTBYNAME                          120\n# define BIO_F_BIO_GETS                                   104\n# define BIO_F_BIO_GET_ACCEPT_SOCKET                      105\n# define BIO_F_BIO_GET_HOST_IP                            106\n# define BIO_F_BIO_GET_PORT                               107\n# define BIO_F_BIO_MAKE_PAIR                              121\n# define BIO_F_BIO_NEW                                    108\n# define BIO_F_BIO_NEW_FILE                               109\n# define BIO_F_BIO_NEW_MEM_BUF                            126\n# define BIO_F_BIO_NREAD                                  123\n# define BIO_F_BIO_NREAD0                                 124\n# define BIO_F_BIO_NWRITE                                 125\n# define BIO_F_BIO_NWRITE0                                122\n# define BIO_F_BIO_PUTS                                   110\n# define BIO_F_BIO_READ                                   111\n# define BIO_F_BIO_SOCK_INIT                              112\n# define BIO_F_BIO_WRITE                                  113\n# define BIO_F_BUFFER_CTRL                                114\n# define BIO_F_CONN_CTRL                                  127\n# define BIO_F_CONN_STATE                                 115\n# define BIO_F_DGRAM_SCTP_READ                            132\n# define BIO_F_DGRAM_SCTP_WRITE                           133\n# define BIO_F_FILE_CTRL                                  116\n# define BIO_F_FILE_READ                                  130\n# define BIO_F_LINEBUFFER_CTRL                            129\n# define BIO_F_MEM_READ                                   128\n# define BIO_F_MEM_WRITE                                  117\n# define BIO_F_SSL_NEW                                    118\n# define BIO_F_WSASTARTUP                                 119\n\n/* Reason codes. */\n# define BIO_R_ACCEPT_ERROR                               100\n# define BIO_R_BAD_FOPEN_MODE                             101\n# define BIO_R_BAD_HOSTNAME_LOOKUP                        102\n# define BIO_R_BROKEN_PIPE                                124\n# define BIO_R_CONNECT_ERROR                              103\n# define BIO_R_EOF_ON_MEMORY_BIO                          127\n# define BIO_R_ERROR_SETTING_NBIO                         104\n# define BIO_R_ERROR_SETTING_NBIO_ON_ACCEPTED_SOCKET      105\n# define BIO_R_ERROR_SETTING_NBIO_ON_ACCEPT_SOCKET        106\n# define BIO_R_GETHOSTBYNAME_ADDR_IS_NOT_AF_INET          107\n# define BIO_R_INVALID_ARGUMENT                           125\n# define BIO_R_INVALID_IP_ADDRESS                         108\n# define BIO_R_IN_USE                                     123\n# define BIO_R_KEEPALIVE                                  109\n# define BIO_R_NBIO_CONNECT_ERROR                         110\n# define BIO_R_NO_ACCEPT_PORT_SPECIFIED                   111\n# define BIO_R_NO_HOSTNAME_SPECIFIED                      112\n# define BIO_R_NO_PORT_DEFINED                            113\n# define BIO_R_NO_PORT_SPECIFIED                          114\n# define BIO_R_NO_SUCH_FILE                               128\n# define BIO_R_NULL_PARAMETER                             115\n# define BIO_R_TAG_MISMATCH                               116\n# define BIO_R_UNABLE_TO_BIND_SOCKET                      117\n# define BIO_R_UNABLE_TO_CREATE_SOCKET                    118\n# define BIO_R_UNABLE_TO_LISTEN_SOCKET                    119\n# define BIO_R_UNINITIALIZED                              120\n# define BIO_R_UNSUPPORTED_METHOD                         121\n# define BIO_R_WRITE_TO_READ_ONLY_BIO                     126\n# define BIO_R_WSASTARTUP                                 122\n\n#ifdef  __cplusplus\n}\n#endif\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/x86_64/include/openssl/blowfish.h",
    "content": "/* crypto/bf/blowfish.h */\n/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)\n * All rights reserved.\n *\n * This package is an SSL implementation written\n * by Eric Young (eay@cryptsoft.com).\n * The implementation was written so as to conform with Netscapes SSL.\n *\n * This library is free for commercial and non-commercial use as long as\n * the following conditions are aheared to.  The following conditions\n * apply to all code found in this distribution, be it the RC4, RSA,\n * lhash, DES, etc., code; not just the SSL code.  The SSL documentation\n * included with this distribution is covered by the same copyright terms\n * except that the holder is Tim Hudson (tjh@cryptsoft.com).\n *\n * Copyright remains Eric Young's, and as such any Copyright notices in\n * the code are not to be removed.\n * If this package is used in a product, Eric Young should be given attribution\n * as the author of the parts of the library used.\n * This can be in the form of a textual message at program startup or\n * in documentation (online or textual) provided with the package.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the copyright\n *    notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in the\n *    documentation and/or other materials provided with the distribution.\n * 3. All advertising materials mentioning features or use of this software\n *    must display the following acknowledgement:\n *    \"This product includes cryptographic software written by\n *     Eric Young (eay@cryptsoft.com)\"\n *    The word 'cryptographic' can be left out if the rouines from the library\n *    being used are not cryptographic related :-).\n * 4. If you include any Windows specific code (or a derivative thereof) from\n *    the apps directory (application code) you must include an acknowledgement:\n *    \"This product includes software written by Tim Hudson (tjh@cryptsoft.com)\"\n *\n * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n * SUCH DAMAGE.\n *\n * The licence and distribution terms for any publically available version or\n * derivative of this code cannot be changed.  i.e. this code cannot simply be\n * copied and put under another distribution licence\n * [including the GNU Public Licence.]\n */\n\n#ifndef HEADER_BLOWFISH_H\n# define HEADER_BLOWFISH_H\n\n# include <openssl/e_os2.h>\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n# ifdef OPENSSL_NO_BF\n#  error BF is disabled.\n# endif\n\n# define BF_ENCRYPT      1\n# define BF_DECRYPT      0\n\n/*-\n * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n * ! BF_LONG has to be at least 32 bits wide. If it's wider, then !\n * ! BF_LONG_LOG2 has to be defined along.                        !\n * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n */\n\n# if defined(__LP32__)\n#  define BF_LONG unsigned long\n# elif defined(OPENSSL_SYS_CRAY) || defined(__ILP64__)\n#  define BF_LONG unsigned long\n#  define BF_LONG_LOG2 3\n/*\n * _CRAY note. I could declare short, but I have no idea what impact\n * does it have on performance on none-T3E machines. I could declare\n * int, but at least on C90 sizeof(int) can be chosen at compile time.\n * So I've chosen long...\n *                                      <appro@fy.chalmers.se>\n */\n# else\n#  define BF_LONG unsigned int\n# endif\n\n# define BF_ROUNDS       16\n# define BF_BLOCK        8\n\ntypedef struct bf_key_st {\n    BF_LONG P[BF_ROUNDS + 2];\n    BF_LONG S[4 * 256];\n} BF_KEY;\n\n# ifdef OPENSSL_FIPS\nvoid private_BF_set_key(BF_KEY *key, int len, const unsigned char *data);\n# endif\nvoid BF_set_key(BF_KEY *key, int len, const unsigned char *data);\n\nvoid BF_encrypt(BF_LONG *data, const BF_KEY *key);\nvoid BF_decrypt(BF_LONG *data, const BF_KEY *key);\n\nvoid BF_ecb_encrypt(const unsigned char *in, unsigned char *out,\n                    const BF_KEY *key, int enc);\nvoid BF_cbc_encrypt(const unsigned char *in, unsigned char *out, long length,\n                    const BF_KEY *schedule, unsigned char *ivec, int enc);\nvoid BF_cfb64_encrypt(const unsigned char *in, unsigned char *out,\n                      long length, const BF_KEY *schedule,\n                      unsigned char *ivec, int *num, int enc);\nvoid BF_ofb64_encrypt(const unsigned char *in, unsigned char *out,\n                      long length, const BF_KEY *schedule,\n                      unsigned char *ivec, int *num);\nconst char *BF_options(void);\n\n#ifdef  __cplusplus\n}\n#endif\n\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/x86_64/include/openssl/bn.h",
    "content": "/* crypto/bn/bn.h */\n/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)\n * All rights reserved.\n *\n * This package is an SSL implementation written\n * by Eric Young (eay@cryptsoft.com).\n * The implementation was written so as to conform with Netscapes SSL.\n *\n * This library is free for commercial and non-commercial use as long as\n * the following conditions are aheared to.  The following conditions\n * apply to all code found in this distribution, be it the RC4, RSA,\n * lhash, DES, etc., code; not just the SSL code.  The SSL documentation\n * included with this distribution is covered by the same copyright terms\n * except that the holder is Tim Hudson (tjh@cryptsoft.com).\n *\n * Copyright remains Eric Young's, and as such any Copyright notices in\n * the code are not to be removed.\n * If this package is used in a product, Eric Young should be given attribution\n * as the author of the parts of the library used.\n * This can be in the form of a textual message at program startup or\n * in documentation (online or textual) provided with the package.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the copyright\n *    notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in the\n *    documentation and/or other materials provided with the distribution.\n * 3. All advertising materials mentioning features or use of this software\n *    must display the following acknowledgement:\n *    \"This product includes cryptographic software written by\n *     Eric Young (eay@cryptsoft.com)\"\n *    The word 'cryptographic' can be left out if the rouines from the library\n *    being used are not cryptographic related :-).\n * 4. If you include any Windows specific code (or a derivative thereof) from\n *    the apps directory (application code) you must include an acknowledgement:\n *    \"This product includes software written by Tim Hudson (tjh@cryptsoft.com)\"\n *\n * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n * SUCH DAMAGE.\n *\n * The licence and distribution terms for any publically available version or\n * derivative of this code cannot be changed.  i.e. this code cannot simply be\n * copied and put under another distribution licence\n * [including the GNU Public Licence.]\n */\n/* ====================================================================\n * Copyright (c) 1998-2006 The OpenSSL Project.  All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n *\n * 1. Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n *\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in\n *    the documentation and/or other materials provided with the\n *    distribution.\n *\n * 3. All advertising materials mentioning features or use of this\n *    software must display the following acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit. (http://www.openssl.org/)\"\n *\n * 4. The names \"OpenSSL Toolkit\" and \"OpenSSL Project\" must not be used to\n *    endorse or promote products derived from this software without\n *    prior written permission. For written permission, please contact\n *    openssl-core@openssl.org.\n *\n * 5. Products derived from this software may not be called \"OpenSSL\"\n *    nor may \"OpenSSL\" appear in their names without prior written\n *    permission of the OpenSSL Project.\n *\n * 6. Redistributions of any form whatsoever must retain the following\n *    acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit (http://www.openssl.org/)\"\n *\n * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY\n * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\n * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR\n * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\n * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,\n * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED\n * OF THE POSSIBILITY OF SUCH DAMAGE.\n * ====================================================================\n *\n * This product includes cryptographic software written by Eric Young\n * (eay@cryptsoft.com).  This product includes software written by Tim\n * Hudson (tjh@cryptsoft.com).\n *\n */\n/* ====================================================================\n * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED.\n *\n * Portions of the attached software (\"Contribution\") are developed by\n * SUN MICROSYSTEMS, INC., and are contributed to the OpenSSL project.\n *\n * The Contribution is licensed pursuant to the Eric Young open source\n * license provided above.\n *\n * The binary polynomial arithmetic software is originally written by\n * Sheueling Chang Shantz and Douglas Stebila of Sun Microsystems Laboratories.\n *\n */\n\n#ifndef HEADER_BN_H\n# define HEADER_BN_H\n\n# include <limits.h>\n# include <openssl/e_os2.h>\n# ifndef OPENSSL_NO_FP_API\n#  include <stdio.h>            /* FILE */\n# endif\n# include <openssl/ossl_typ.h>\n# include <openssl/crypto.h>\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n/*\n * These preprocessor symbols control various aspects of the bignum headers\n * and library code. They're not defined by any \"normal\" configuration, as\n * they are intended for development and testing purposes. NB: defining all\n * three can be useful for debugging application code as well as openssl\n * itself. BN_DEBUG - turn on various debugging alterations to the bignum\n * code BN_DEBUG_RAND - uses random poisoning of unused words to trip up\n * mismanagement of bignum internals. You must also define BN_DEBUG.\n */\n/* #define BN_DEBUG */\n/* #define BN_DEBUG_RAND */\n\n# ifndef OPENSSL_SMALL_FOOTPRINT\n#  define BN_MUL_COMBA\n#  define BN_SQR_COMBA\n#  define BN_RECURSION\n# endif\n\n/*\n * This next option uses the C libraries (2 word)/(1 word) function. If it is\n * not defined, I use my C version (which is slower). The reason for this\n * flag is that when the particular C compiler library routine is used, and\n * the library is linked with a different compiler, the library is missing.\n * This mostly happens when the library is built with gcc and then linked\n * using normal cc.  This would be a common occurrence because gcc normally\n * produces code that is 2 times faster than system compilers for the big\n * number stuff. For machines with only one compiler (or shared libraries),\n * this should be on.  Again this in only really a problem on machines using\n * \"long long's\", are 32bit, and are not using my assembler code.\n */\n# if defined(OPENSSL_SYS_MSDOS) || defined(OPENSSL_SYS_WINDOWS) || \\\n    defined(OPENSSL_SYS_WIN32) || defined(linux)\n#  ifndef BN_DIV2W\n#   define BN_DIV2W\n#  endif\n# endif\n\n/*\n * assuming long is 64bit - this is the DEC Alpha unsigned long long is only\n * 64 bits :-(, don't define BN_LLONG for the DEC Alpha\n */\n# ifdef SIXTY_FOUR_BIT_LONG\n#  define BN_ULLONG       unsigned long long\n#  define BN_ULONG        unsigned long\n#  define BN_LONG         long\n#  define BN_BITS         128\n#  define BN_BYTES        8\n#  define BN_BITS2        64\n#  define BN_BITS4        32\n#  define BN_MASK         (0xffffffffffffffffffffffffffffffffLL)\n#  define BN_MASK2        (0xffffffffffffffffL)\n#  define BN_MASK2l       (0xffffffffL)\n#  define BN_MASK2h       (0xffffffff00000000L)\n#  define BN_MASK2h1      (0xffffffff80000000L)\n#  define BN_TBIT         (0x8000000000000000L)\n#  define BN_DEC_CONV     (10000000000000000000UL)\n#  define BN_DEC_FMT1     \"%lu\"\n#  define BN_DEC_FMT2     \"%019lu\"\n#  define BN_DEC_NUM      19\n#  define BN_HEX_FMT1     \"%lX\"\n#  define BN_HEX_FMT2     \"%016lX\"\n# endif\n\n/*\n * This is where the long long data type is 64 bits, but long is 32. For\n * machines where there are 64bit registers, this is the mode to use. IRIX,\n * on R4000 and above should use this mode, along with the relevant assembler\n * code :-).  Do NOT define BN_LLONG.\n */\n# ifdef SIXTY_FOUR_BIT\n#  undef BN_LLONG\n#  undef BN_ULLONG\n#  define BN_ULONG        unsigned long long\n#  define BN_LONG         long long\n#  define BN_BITS         128\n#  define BN_BYTES        8\n#  define BN_BITS2        64\n#  define BN_BITS4        32\n#  define BN_MASK2        (0xffffffffffffffffLL)\n#  define BN_MASK2l       (0xffffffffL)\n#  define BN_MASK2h       (0xffffffff00000000LL)\n#  define BN_MASK2h1      (0xffffffff80000000LL)\n#  define BN_TBIT         (0x8000000000000000LL)\n#  define BN_DEC_CONV     (10000000000000000000ULL)\n#  define BN_DEC_FMT1     \"%llu\"\n#  define BN_DEC_FMT2     \"%019llu\"\n#  define BN_DEC_NUM      19\n#  define BN_HEX_FMT1     \"%llX\"\n#  define BN_HEX_FMT2     \"%016llX\"\n# endif\n\n# ifdef THIRTY_TWO_BIT\n#  ifdef BN_LLONG\n#   if defined(_WIN32) && !defined(__GNUC__)\n#    define BN_ULLONG     unsigned __int64\n#    define BN_MASK       (0xffffffffffffffffI64)\n#   else\n#    define BN_ULLONG     unsigned long long\n#    define BN_MASK       (0xffffffffffffffffLL)\n#   endif\n#  endif\n#  define BN_ULONG        unsigned int\n#  define BN_LONG         int\n#  define BN_BITS         64\n#  define BN_BYTES        4\n#  define BN_BITS2        32\n#  define BN_BITS4        16\n#  define BN_MASK2        (0xffffffffL)\n#  define BN_MASK2l       (0xffff)\n#  define BN_MASK2h1      (0xffff8000L)\n#  define BN_MASK2h       (0xffff0000L)\n#  define BN_TBIT         (0x80000000L)\n#  define BN_DEC_CONV     (1000000000L)\n#  define BN_DEC_FMT1     \"%u\"\n#  define BN_DEC_FMT2     \"%09u\"\n#  define BN_DEC_NUM      9\n#  define BN_HEX_FMT1     \"%X\"\n#  define BN_HEX_FMT2     \"%08X\"\n# endif\n\n# define BN_DEFAULT_BITS 1280\n\n# define BN_FLG_MALLOCED         0x01\n# define BN_FLG_STATIC_DATA      0x02\n\n/*\n * avoid leaking exponent information through timing,\n * BN_mod_exp_mont() will call BN_mod_exp_mont_consttime,\n * BN_div() will call BN_div_no_branch,\n * BN_mod_inverse() will call BN_mod_inverse_no_branch.\n */\n# define BN_FLG_CONSTTIME        0x04\n\n# ifdef OPENSSL_NO_DEPRECATED\n/* deprecated name for the flag */\n#  define BN_FLG_EXP_CONSTTIME BN_FLG_CONSTTIME\n/*\n * avoid leaking exponent information through timings\n * (BN_mod_exp_mont() will call BN_mod_exp_mont_consttime)\n */\n# endif\n\n# ifndef OPENSSL_NO_DEPRECATED\n#  define BN_FLG_FREE             0x8000\n                                       /* used for debuging */\n# endif\n# define BN_set_flags(b,n)       ((b)->flags|=(n))\n# define BN_get_flags(b,n)       ((b)->flags&(n))\n\n/*\n * get a clone of a BIGNUM with changed flags, for *temporary* use only (the\n * two BIGNUMs cannot not be used in parallel!)\n */\n# define BN_with_flags(dest,b,n)  ((dest)->d=(b)->d, \\\n                                  (dest)->top=(b)->top, \\\n                                  (dest)->dmax=(b)->dmax, \\\n                                  (dest)->neg=(b)->neg, \\\n                                  (dest)->flags=(((dest)->flags & BN_FLG_MALLOCED) \\\n                                                 |  ((b)->flags & ~BN_FLG_MALLOCED) \\\n                                                 |  BN_FLG_STATIC_DATA \\\n                                                 |  (n)))\n\n/* Already declared in ossl_typ.h */\n# if 0\ntypedef struct bignum_st BIGNUM;\n/* Used for temp variables (declaration hidden in bn_lcl.h) */\ntypedef struct bignum_ctx BN_CTX;\ntypedef struct bn_blinding_st BN_BLINDING;\ntypedef struct bn_mont_ctx_st BN_MONT_CTX;\ntypedef struct bn_recp_ctx_st BN_RECP_CTX;\ntypedef struct bn_gencb_st BN_GENCB;\n# endif\n\nstruct bignum_st {\n    BN_ULONG *d;                /* Pointer to an array of 'BN_BITS2' bit\n                                 * chunks. */\n    int top;                    /* Index of last used d +1. */\n    /* The next are internal book keeping for bn_expand. */\n    int dmax;                   /* Size of the d array. */\n    int neg;                    /* one if the number is negative */\n    int flags;\n};\n\n/* Used for montgomery multiplication */\nstruct bn_mont_ctx_st {\n    int ri;                     /* number of bits in R */\n    BIGNUM RR;                  /* used to convert to montgomery form */\n    BIGNUM N;                   /* The modulus */\n    BIGNUM Ni;                  /* R*(1/R mod N) - N*Ni = 1 (Ni is only\n                                 * stored for bignum algorithm) */\n    BN_ULONG n0[2];             /* least significant word(s) of Ni; (type\n                                 * changed with 0.9.9, was \"BN_ULONG n0;\"\n                                 * before) */\n    int flags;\n};\n\n/*\n * Used for reciprocal division/mod functions It cannot be shared between\n * threads\n */\nstruct bn_recp_ctx_st {\n    BIGNUM N;                   /* the divisor */\n    BIGNUM Nr;                  /* the reciprocal */\n    int num_bits;\n    int shift;\n    int flags;\n};\n\n/* Used for slow \"generation\" functions. */\nstruct bn_gencb_st {\n    unsigned int ver;           /* To handle binary (in)compatibility */\n    void *arg;                  /* callback-specific data */\n    union {\n        /* if(ver==1) - handles old style callbacks */\n        void (*cb_1) (int, int, void *);\n        /* if(ver==2) - new callback style */\n        int (*cb_2) (int, int, BN_GENCB *);\n    } cb;\n};\n/* Wrapper function to make using BN_GENCB easier,  */\nint BN_GENCB_call(BN_GENCB *cb, int a, int b);\n/* Macro to populate a BN_GENCB structure with an \"old\"-style callback */\n# define BN_GENCB_set_old(gencb, callback, cb_arg) { \\\n                BN_GENCB *tmp_gencb = (gencb); \\\n                tmp_gencb->ver = 1; \\\n                tmp_gencb->arg = (cb_arg); \\\n                tmp_gencb->cb.cb_1 = (callback); }\n/* Macro to populate a BN_GENCB structure with a \"new\"-style callback */\n# define BN_GENCB_set(gencb, callback, cb_arg) { \\\n                BN_GENCB *tmp_gencb = (gencb); \\\n                tmp_gencb->ver = 2; \\\n                tmp_gencb->arg = (cb_arg); \\\n                tmp_gencb->cb.cb_2 = (callback); }\n\n# define BN_prime_checks 0      /* default: select number of iterations based\n                                 * on the size of the number */\n\n/*\n * number of Miller-Rabin iterations for an error rate of less than 2^-80 for\n * random 'b'-bit input, b >= 100 (taken from table 4.4 in the Handbook of\n * Applied Cryptography [Menezes, van Oorschot, Vanstone; CRC Press 1996];\n * original paper: Damgaard, Landrock, Pomerance: Average case error\n * estimates for the strong probable prime test. -- Math. Comp. 61 (1993)\n * 177-194)\n */\n# define BN_prime_checks_for_size(b) ((b) >= 1300 ?  2 : \\\n                                (b) >=  850 ?  3 : \\\n                                (b) >=  650 ?  4 : \\\n                                (b) >=  550 ?  5 : \\\n                                (b) >=  450 ?  6 : \\\n                                (b) >=  400 ?  7 : \\\n                                (b) >=  350 ?  8 : \\\n                                (b) >=  300 ?  9 : \\\n                                (b) >=  250 ? 12 : \\\n                                (b) >=  200 ? 15 : \\\n                                (b) >=  150 ? 18 : \\\n                                /* b >= 100 */ 27)\n\n# define BN_num_bytes(a) ((BN_num_bits(a)+7)/8)\n\n/* Note that BN_abs_is_word didn't work reliably for w == 0 until 0.9.8 */\n# define BN_abs_is_word(a,w) ((((a)->top == 1) && ((a)->d[0] == (BN_ULONG)(w))) || \\\n                                (((w) == 0) && ((a)->top == 0)))\n# define BN_is_zero(a)       ((a)->top == 0)\n# define BN_is_one(a)        (BN_abs_is_word((a),1) && !(a)->neg)\n# define BN_is_word(a,w)     (BN_abs_is_word((a),(w)) && (!(w) || !(a)->neg))\n# define BN_is_odd(a)        (((a)->top > 0) && ((a)->d[0] & 1))\n\n# define BN_one(a)       (BN_set_word((a),1))\n# define BN_zero_ex(a) \\\n        do { \\\n                BIGNUM *_tmp_bn = (a); \\\n                _tmp_bn->top = 0; \\\n                _tmp_bn->neg = 0; \\\n        } while(0)\n# ifdef OPENSSL_NO_DEPRECATED\n#  define BN_zero(a)      BN_zero_ex(a)\n# else\n#  define BN_zero(a)      (BN_set_word((a),0))\n# endif\n\nconst BIGNUM *BN_value_one(void);\nchar *BN_options(void);\nBN_CTX *BN_CTX_new(void);\n# ifndef OPENSSL_NO_DEPRECATED\nvoid BN_CTX_init(BN_CTX *c);\n# endif\nvoid BN_CTX_free(BN_CTX *c);\nvoid BN_CTX_start(BN_CTX *ctx);\nBIGNUM *BN_CTX_get(BN_CTX *ctx);\nvoid BN_CTX_end(BN_CTX *ctx);\nint BN_rand(BIGNUM *rnd, int bits, int top, int bottom);\nint BN_pseudo_rand(BIGNUM *rnd, int bits, int top, int bottom);\nint BN_rand_range(BIGNUM *rnd, const BIGNUM *range);\nint BN_pseudo_rand_range(BIGNUM *rnd, const BIGNUM *range);\nint BN_num_bits(const BIGNUM *a);\nint BN_num_bits_word(BN_ULONG);\nBIGNUM *BN_new(void);\nvoid BN_init(BIGNUM *);\nvoid BN_clear_free(BIGNUM *a);\nBIGNUM *BN_copy(BIGNUM *a, const BIGNUM *b);\nvoid BN_swap(BIGNUM *a, BIGNUM *b);\nBIGNUM *BN_bin2bn(const unsigned char *s, int len, BIGNUM *ret);\nint BN_bn2bin(const BIGNUM *a, unsigned char *to);\nBIGNUM *BN_mpi2bn(const unsigned char *s, int len, BIGNUM *ret);\nint BN_bn2mpi(const BIGNUM *a, unsigned char *to);\nint BN_sub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b);\nint BN_usub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b);\nint BN_uadd(BIGNUM *r, const BIGNUM *a, const BIGNUM *b);\nint BN_add(BIGNUM *r, const BIGNUM *a, const BIGNUM *b);\nint BN_mul(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx);\nint BN_sqr(BIGNUM *r, const BIGNUM *a, BN_CTX *ctx);\n/** BN_set_negative sets sign of a BIGNUM\n * \\param  b  pointer to the BIGNUM object\n * \\param  n  0 if the BIGNUM b should be positive and a value != 0 otherwise\n */\nvoid BN_set_negative(BIGNUM *b, int n);\n/** BN_is_negative returns 1 if the BIGNUM is negative\n * \\param  a  pointer to the BIGNUM object\n * \\return 1 if a < 0 and 0 otherwise\n */\n# define BN_is_negative(a) ((a)->neg != 0)\n\nint BN_div(BIGNUM *dv, BIGNUM *rem, const BIGNUM *m, const BIGNUM *d,\n           BN_CTX *ctx);\n# define BN_mod(rem,m,d,ctx) BN_div(NULL,(rem),(m),(d),(ctx))\nint BN_nnmod(BIGNUM *r, const BIGNUM *m, const BIGNUM *d, BN_CTX *ctx);\nint BN_mod_add(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *m,\n               BN_CTX *ctx);\nint BN_mod_add_quick(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,\n                     const BIGNUM *m);\nint BN_mod_sub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *m,\n               BN_CTX *ctx);\nint BN_mod_sub_quick(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,\n                     const BIGNUM *m);\nint BN_mod_mul(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *m,\n               BN_CTX *ctx);\nint BN_mod_sqr(BIGNUM *r, const BIGNUM *a, const BIGNUM *m, BN_CTX *ctx);\nint BN_mod_lshift1(BIGNUM *r, const BIGNUM *a, const BIGNUM *m, BN_CTX *ctx);\nint BN_mod_lshift1_quick(BIGNUM *r, const BIGNUM *a, const BIGNUM *m);\nint BN_mod_lshift(BIGNUM *r, const BIGNUM *a, int n, const BIGNUM *m,\n                  BN_CTX *ctx);\nint BN_mod_lshift_quick(BIGNUM *r, const BIGNUM *a, int n, const BIGNUM *m);\n\nBN_ULONG BN_mod_word(const BIGNUM *a, BN_ULONG w);\nBN_ULONG BN_div_word(BIGNUM *a, BN_ULONG w);\nint BN_mul_word(BIGNUM *a, BN_ULONG w);\nint BN_add_word(BIGNUM *a, BN_ULONG w);\nint BN_sub_word(BIGNUM *a, BN_ULONG w);\nint BN_set_word(BIGNUM *a, BN_ULONG w);\nBN_ULONG BN_get_word(const BIGNUM *a);\n\nint BN_cmp(const BIGNUM *a, const BIGNUM *b);\nvoid BN_free(BIGNUM *a);\nint BN_is_bit_set(const BIGNUM *a, int n);\nint BN_lshift(BIGNUM *r, const BIGNUM *a, int n);\nint BN_lshift1(BIGNUM *r, const BIGNUM *a);\nint BN_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx);\n\nint BN_mod_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,\n               const BIGNUM *m, BN_CTX *ctx);\nint BN_mod_exp_mont(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,\n                    const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx);\nint BN_mod_exp_mont_consttime(BIGNUM *rr, const BIGNUM *a, const BIGNUM *p,\n                              const BIGNUM *m, BN_CTX *ctx,\n                              BN_MONT_CTX *in_mont);\nint BN_mod_exp_mont_word(BIGNUM *r, BN_ULONG a, const BIGNUM *p,\n                         const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx);\nint BN_mod_exp2_mont(BIGNUM *r, const BIGNUM *a1, const BIGNUM *p1,\n                     const BIGNUM *a2, const BIGNUM *p2, const BIGNUM *m,\n                     BN_CTX *ctx, BN_MONT_CTX *m_ctx);\nint BN_mod_exp_simple(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,\n                      const BIGNUM *m, BN_CTX *ctx);\n\nint BN_mask_bits(BIGNUM *a, int n);\n# ifndef OPENSSL_NO_FP_API\nint BN_print_fp(FILE *fp, const BIGNUM *a);\n# endif\n# ifdef HEADER_BIO_H\nint BN_print(BIO *fp, const BIGNUM *a);\n# else\nint BN_print(void *fp, const BIGNUM *a);\n# endif\nint BN_reciprocal(BIGNUM *r, const BIGNUM *m, int len, BN_CTX *ctx);\nint BN_rshift(BIGNUM *r, const BIGNUM *a, int n);\nint BN_rshift1(BIGNUM *r, const BIGNUM *a);\nvoid BN_clear(BIGNUM *a);\nBIGNUM *BN_dup(const BIGNUM *a);\nint BN_ucmp(const BIGNUM *a, const BIGNUM *b);\nint BN_set_bit(BIGNUM *a, int n);\nint BN_clear_bit(BIGNUM *a, int n);\nchar *BN_bn2hex(const BIGNUM *a);\nchar *BN_bn2dec(const BIGNUM *a);\nint BN_hex2bn(BIGNUM **a, const char *str);\nint BN_dec2bn(BIGNUM **a, const char *str);\nint BN_asc2bn(BIGNUM **a, const char *str);\nint BN_gcd(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx);\nint BN_kronecker(const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx); /* returns\n                                                                  * -2 for\n                                                                  * error */\nBIGNUM *BN_mod_inverse(BIGNUM *ret,\n                       const BIGNUM *a, const BIGNUM *n, BN_CTX *ctx);\nBIGNUM *BN_mod_sqrt(BIGNUM *ret,\n                    const BIGNUM *a, const BIGNUM *n, BN_CTX *ctx);\n\nvoid BN_consttime_swap(BN_ULONG swap, BIGNUM *a, BIGNUM *b, int nwords);\n\n/* Deprecated versions */\n# ifndef OPENSSL_NO_DEPRECATED\nBIGNUM *BN_generate_prime(BIGNUM *ret, int bits, int safe,\n                          const BIGNUM *add, const BIGNUM *rem,\n                          void (*callback) (int, int, void *), void *cb_arg);\nint BN_is_prime(const BIGNUM *p, int nchecks,\n                void (*callback) (int, int, void *),\n                BN_CTX *ctx, void *cb_arg);\nint BN_is_prime_fasttest(const BIGNUM *p, int nchecks,\n                         void (*callback) (int, int, void *), BN_CTX *ctx,\n                         void *cb_arg, int do_trial_division);\n# endif                         /* !defined(OPENSSL_NO_DEPRECATED) */\n\n/* Newer versions */\nint BN_generate_prime_ex(BIGNUM *ret, int bits, int safe, const BIGNUM *add,\n                         const BIGNUM *rem, BN_GENCB *cb);\nint BN_is_prime_ex(const BIGNUM *p, int nchecks, BN_CTX *ctx, BN_GENCB *cb);\nint BN_is_prime_fasttest_ex(const BIGNUM *p, int nchecks, BN_CTX *ctx,\n                            int do_trial_division, BN_GENCB *cb);\n\nint BN_X931_generate_Xpq(BIGNUM *Xp, BIGNUM *Xq, int nbits, BN_CTX *ctx);\n\nint BN_X931_derive_prime_ex(BIGNUM *p, BIGNUM *p1, BIGNUM *p2,\n                            const BIGNUM *Xp, const BIGNUM *Xp1,\n                            const BIGNUM *Xp2, const BIGNUM *e, BN_CTX *ctx,\n                            BN_GENCB *cb);\nint BN_X931_generate_prime_ex(BIGNUM *p, BIGNUM *p1, BIGNUM *p2, BIGNUM *Xp1,\n                              BIGNUM *Xp2, const BIGNUM *Xp, const BIGNUM *e,\n                              BN_CTX *ctx, BN_GENCB *cb);\n\nBN_MONT_CTX *BN_MONT_CTX_new(void);\nvoid BN_MONT_CTX_init(BN_MONT_CTX *ctx);\nint BN_mod_mul_montgomery(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,\n                          BN_MONT_CTX *mont, BN_CTX *ctx);\n# define BN_to_montgomery(r,a,mont,ctx)  BN_mod_mul_montgomery(\\\n        (r),(a),&((mont)->RR),(mont),(ctx))\nint BN_from_montgomery(BIGNUM *r, const BIGNUM *a,\n                       BN_MONT_CTX *mont, BN_CTX *ctx);\nvoid BN_MONT_CTX_free(BN_MONT_CTX *mont);\nint BN_MONT_CTX_set(BN_MONT_CTX *mont, const BIGNUM *mod, BN_CTX *ctx);\nBN_MONT_CTX *BN_MONT_CTX_copy(BN_MONT_CTX *to, BN_MONT_CTX *from);\nBN_MONT_CTX *BN_MONT_CTX_set_locked(BN_MONT_CTX **pmont, int lock,\n                                    const BIGNUM *mod, BN_CTX *ctx);\n\n/* BN_BLINDING flags */\n# define BN_BLINDING_NO_UPDATE   0x00000001\n# define BN_BLINDING_NO_RECREATE 0x00000002\n\nBN_BLINDING *BN_BLINDING_new(const BIGNUM *A, const BIGNUM *Ai, BIGNUM *mod);\nvoid BN_BLINDING_free(BN_BLINDING *b);\nint BN_BLINDING_update(BN_BLINDING *b, BN_CTX *ctx);\nint BN_BLINDING_convert(BIGNUM *n, BN_BLINDING *b, BN_CTX *ctx);\nint BN_BLINDING_invert(BIGNUM *n, BN_BLINDING *b, BN_CTX *ctx);\nint BN_BLINDING_convert_ex(BIGNUM *n, BIGNUM *r, BN_BLINDING *b, BN_CTX *);\nint BN_BLINDING_invert_ex(BIGNUM *n, const BIGNUM *r, BN_BLINDING *b,\n                          BN_CTX *);\n# ifndef OPENSSL_NO_DEPRECATED\nunsigned long BN_BLINDING_get_thread_id(const BN_BLINDING *);\nvoid BN_BLINDING_set_thread_id(BN_BLINDING *, unsigned long);\n# endif\nCRYPTO_THREADID *BN_BLINDING_thread_id(BN_BLINDING *);\nunsigned long BN_BLINDING_get_flags(const BN_BLINDING *);\nvoid BN_BLINDING_set_flags(BN_BLINDING *, unsigned long);\nBN_BLINDING *BN_BLINDING_create_param(BN_BLINDING *b,\n                                      const BIGNUM *e, BIGNUM *m, BN_CTX *ctx,\n                                      int (*bn_mod_exp) (BIGNUM *r,\n                                                         const BIGNUM *a,\n                                                         const BIGNUM *p,\n                                                         const BIGNUM *m,\n                                                         BN_CTX *ctx,\n                                                         BN_MONT_CTX *m_ctx),\n                                      BN_MONT_CTX *m_ctx);\n\n# ifndef OPENSSL_NO_DEPRECATED\nvoid BN_set_params(int mul, int high, int low, int mont);\nint BN_get_params(int which);   /* 0, mul, 1 high, 2 low, 3 mont */\n# endif\n\nvoid BN_RECP_CTX_init(BN_RECP_CTX *recp);\nBN_RECP_CTX *BN_RECP_CTX_new(void);\nvoid BN_RECP_CTX_free(BN_RECP_CTX *recp);\nint BN_RECP_CTX_set(BN_RECP_CTX *recp, const BIGNUM *rdiv, BN_CTX *ctx);\nint BN_mod_mul_reciprocal(BIGNUM *r, const BIGNUM *x, const BIGNUM *y,\n                          BN_RECP_CTX *recp, BN_CTX *ctx);\nint BN_mod_exp_recp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,\n                    const BIGNUM *m, BN_CTX *ctx);\nint BN_div_recp(BIGNUM *dv, BIGNUM *rem, const BIGNUM *m,\n                BN_RECP_CTX *recp, BN_CTX *ctx);\n\n# ifndef OPENSSL_NO_EC2M\n\n/*\n * Functions for arithmetic over binary polynomials represented by BIGNUMs.\n * The BIGNUM::neg property of BIGNUMs representing binary polynomials is\n * ignored. Note that input arguments are not const so that their bit arrays\n * can be expanded to the appropriate size if needed.\n */\n\n/*\n * r = a + b\n */\nint BN_GF2m_add(BIGNUM *r, const BIGNUM *a, const BIGNUM *b);\n#  define BN_GF2m_sub(r, a, b) BN_GF2m_add(r, a, b)\n/*\n * r=a mod p\n */\nint BN_GF2m_mod(BIGNUM *r, const BIGNUM *a, const BIGNUM *p);\n/* r = (a * b) mod p */\nint BN_GF2m_mod_mul(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,\n                    const BIGNUM *p, BN_CTX *ctx);\n/* r = (a * a) mod p */\nint BN_GF2m_mod_sqr(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx);\n/* r = (1 / b) mod p */\nint BN_GF2m_mod_inv(BIGNUM *r, const BIGNUM *b, const BIGNUM *p, BN_CTX *ctx);\n/* r = (a / b) mod p */\nint BN_GF2m_mod_div(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,\n                    const BIGNUM *p, BN_CTX *ctx);\n/* r = (a ^ b) mod p */\nint BN_GF2m_mod_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,\n                    const BIGNUM *p, BN_CTX *ctx);\n/* r = sqrt(a) mod p */\nint BN_GF2m_mod_sqrt(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,\n                     BN_CTX *ctx);\n/* r^2 + r = a mod p */\nint BN_GF2m_mod_solve_quad(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,\n                           BN_CTX *ctx);\n#  define BN_GF2m_cmp(a, b) BN_ucmp((a), (b))\n/*-\n * Some functions allow for representation of the irreducible polynomials\n * as an unsigned int[], say p.  The irreducible f(t) is then of the form:\n *     t^p[0] + t^p[1] + ... + t^p[k]\n * where m = p[0] > p[1] > ... > p[k] = 0.\n */\n/* r = a mod p */\nint BN_GF2m_mod_arr(BIGNUM *r, const BIGNUM *a, const int p[]);\n/* r = (a * b) mod p */\nint BN_GF2m_mod_mul_arr(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,\n                        const int p[], BN_CTX *ctx);\n/* r = (a * a) mod p */\nint BN_GF2m_mod_sqr_arr(BIGNUM *r, const BIGNUM *a, const int p[],\n                        BN_CTX *ctx);\n/* r = (1 / b) mod p */\nint BN_GF2m_mod_inv_arr(BIGNUM *r, const BIGNUM *b, const int p[],\n                        BN_CTX *ctx);\n/* r = (a / b) mod p */\nint BN_GF2m_mod_div_arr(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,\n                        const int p[], BN_CTX *ctx);\n/* r = (a ^ b) mod p */\nint BN_GF2m_mod_exp_arr(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,\n                        const int p[], BN_CTX *ctx);\n/* r = sqrt(a) mod p */\nint BN_GF2m_mod_sqrt_arr(BIGNUM *r, const BIGNUM *a,\n                         const int p[], BN_CTX *ctx);\n/* r^2 + r = a mod p */\nint BN_GF2m_mod_solve_quad_arr(BIGNUM *r, const BIGNUM *a,\n                               const int p[], BN_CTX *ctx);\nint BN_GF2m_poly2arr(const BIGNUM *a, int p[], int max);\nint BN_GF2m_arr2poly(const int p[], BIGNUM *a);\n\n# endif\n\n/*\n * faster mod functions for the 'NIST primes' 0 <= a < p^2\n */\nint BN_nist_mod_192(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx);\nint BN_nist_mod_224(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx);\nint BN_nist_mod_256(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx);\nint BN_nist_mod_384(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx);\nint BN_nist_mod_521(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx);\n\nconst BIGNUM *BN_get0_nist_prime_192(void);\nconst BIGNUM *BN_get0_nist_prime_224(void);\nconst BIGNUM *BN_get0_nist_prime_256(void);\nconst BIGNUM *BN_get0_nist_prime_384(void);\nconst BIGNUM *BN_get0_nist_prime_521(void);\n\n/* library internal functions */\n\n# define bn_expand(a,bits) \\\n    ( \\\n        bits > (INT_MAX - BN_BITS2 + 1) ? \\\n            NULL \\\n        : \\\n            (((bits+BN_BITS2-1)/BN_BITS2) <= (a)->dmax) ? \\\n                (a) \\\n            : \\\n                bn_expand2((a),(bits+BN_BITS2-1)/BN_BITS2) \\\n    )\n\n# define bn_wexpand(a,words) (((words) <= (a)->dmax)?(a):bn_expand2((a),(words)))\nBIGNUM *bn_expand2(BIGNUM *a, int words);\n# ifndef OPENSSL_NO_DEPRECATED\nBIGNUM *bn_dup_expand(const BIGNUM *a, int words); /* unused */\n# endif\n\n/*-\n * Bignum consistency macros\n * There is one \"API\" macro, bn_fix_top(), for stripping leading zeroes from\n * bignum data after direct manipulations on the data. There is also an\n * \"internal\" macro, bn_check_top(), for verifying that there are no leading\n * zeroes. Unfortunately, some auditing is required due to the fact that\n * bn_fix_top() has become an overabused duct-tape because bignum data is\n * occasionally passed around in an inconsistent state. So the following\n * changes have been made to sort this out;\n * - bn_fix_top()s implementation has been moved to bn_correct_top()\n * - if BN_DEBUG isn't defined, bn_fix_top() maps to bn_correct_top(), and\n *   bn_check_top() is as before.\n * - if BN_DEBUG *is* defined;\n *   - bn_check_top() tries to pollute unused words even if the bignum 'top' is\n *     consistent. (ed: only if BN_DEBUG_RAND is defined)\n *   - bn_fix_top() maps to bn_check_top() rather than \"fixing\" anything.\n * The idea is to have debug builds flag up inconsistent bignums when they\n * occur. If that occurs in a bn_fix_top(), we examine the code in question; if\n * the use of bn_fix_top() was appropriate (ie. it follows directly after code\n * that manipulates the bignum) it is converted to bn_correct_top(), and if it\n * was not appropriate, we convert it permanently to bn_check_top() and track\n * down the cause of the bug. Eventually, no internal code should be using the\n * bn_fix_top() macro. External applications and libraries should try this with\n * their own code too, both in terms of building against the openssl headers\n * with BN_DEBUG defined *and* linking with a version of OpenSSL built with it\n * defined. This not only improves external code, it provides more test\n * coverage for openssl's own code.\n */\n\n# ifdef BN_DEBUG\n\n/* We only need assert() when debugging */\n#  include <assert.h>\n\n#  ifdef BN_DEBUG_RAND\n/* To avoid \"make update\" cvs wars due to BN_DEBUG, use some tricks */\n#   ifndef RAND_pseudo_bytes\nint RAND_pseudo_bytes(unsigned char *buf, int num);\n#    define BN_DEBUG_TRIX\n#   endif\n#   define bn_pollute(a) \\\n        do { \\\n                const BIGNUM *_bnum1 = (a); \\\n                if(_bnum1->top < _bnum1->dmax) { \\\n                        unsigned char _tmp_char; \\\n                        /* We cast away const without the compiler knowing, any \\\n                         * *genuinely* constant variables that aren't mutable \\\n                         * wouldn't be constructed with top!=dmax. */ \\\n                        BN_ULONG *_not_const; \\\n                        memcpy(&_not_const, &_bnum1->d, sizeof(BN_ULONG*)); \\\n                        /* Debug only - safe to ignore error return */ \\\n                        RAND_pseudo_bytes(&_tmp_char, 1); \\\n                        memset((unsigned char *)(_not_const + _bnum1->top), _tmp_char, \\\n                                (_bnum1->dmax - _bnum1->top) * sizeof(BN_ULONG)); \\\n                } \\\n        } while(0)\n#   ifdef BN_DEBUG_TRIX\n#    undef RAND_pseudo_bytes\n#   endif\n#  else\n#   define bn_pollute(a)\n#  endif\n#  define bn_check_top(a) \\\n        do { \\\n                const BIGNUM *_bnum2 = (a); \\\n                if (_bnum2 != NULL) { \\\n                        assert((_bnum2->top == 0) || \\\n                                (_bnum2->d[_bnum2->top - 1] != 0)); \\\n                        bn_pollute(_bnum2); \\\n                } \\\n        } while(0)\n\n#  define bn_fix_top(a)           bn_check_top(a)\n\n#  define bn_check_size(bn, bits) bn_wcheck_size(bn, ((bits+BN_BITS2-1))/BN_BITS2)\n#  define bn_wcheck_size(bn, words) \\\n        do { \\\n                const BIGNUM *_bnum2 = (bn); \\\n                assert((words) <= (_bnum2)->dmax && (words) >= (_bnum2)->top); \\\n                /* avoid unused variable warning with NDEBUG */ \\\n                (void)(_bnum2); \\\n        } while(0)\n\n# else                          /* !BN_DEBUG */\n\n#  define bn_pollute(a)\n#  define bn_check_top(a)\n#  define bn_fix_top(a)           bn_correct_top(a)\n#  define bn_check_size(bn, bits)\n#  define bn_wcheck_size(bn, words)\n\n# endif\n\n# define bn_correct_top(a) \\\n        { \\\n        BN_ULONG *ftl; \\\n        int tmp_top = (a)->top; \\\n        if (tmp_top > 0) \\\n                { \\\n                for (ftl= &((a)->d[tmp_top-1]); tmp_top > 0; tmp_top--) \\\n                        if (*(ftl--)) break; \\\n                (a)->top = tmp_top; \\\n                } \\\n        if ((a)->top == 0) \\\n            (a)->neg = 0; \\\n        bn_pollute(a); \\\n        }\n\nBN_ULONG bn_mul_add_words(BN_ULONG *rp, const BN_ULONG *ap, int num,\n                          BN_ULONG w);\nBN_ULONG bn_mul_words(BN_ULONG *rp, const BN_ULONG *ap, int num, BN_ULONG w);\nvoid bn_sqr_words(BN_ULONG *rp, const BN_ULONG *ap, int num);\nBN_ULONG bn_div_words(BN_ULONG h, BN_ULONG l, BN_ULONG d);\nBN_ULONG bn_add_words(BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp,\n                      int num);\nBN_ULONG bn_sub_words(BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp,\n                      int num);\n\n/* Primes from RFC 2409 */\nBIGNUM *get_rfc2409_prime_768(BIGNUM *bn);\nBIGNUM *get_rfc2409_prime_1024(BIGNUM *bn);\n\n/* Primes from RFC 3526 */\nBIGNUM *get_rfc3526_prime_1536(BIGNUM *bn);\nBIGNUM *get_rfc3526_prime_2048(BIGNUM *bn);\nBIGNUM *get_rfc3526_prime_3072(BIGNUM *bn);\nBIGNUM *get_rfc3526_prime_4096(BIGNUM *bn);\nBIGNUM *get_rfc3526_prime_6144(BIGNUM *bn);\nBIGNUM *get_rfc3526_prime_8192(BIGNUM *bn);\n\nint BN_bntest_rand(BIGNUM *rnd, int bits, int top, int bottom);\n\n/* BEGIN ERROR CODES */\n/*\n * The following lines are auto generated by the script mkerr.pl. Any changes\n * made after this point may be overwritten when the script is next run.\n */\nvoid ERR_load_BN_strings(void);\n\n/* Error codes for the BN functions. */\n\n/* Function codes. */\n# define BN_F_BNRAND                                      127\n# define BN_F_BN_BLINDING_CONVERT_EX                      100\n# define BN_F_BN_BLINDING_CREATE_PARAM                    128\n# define BN_F_BN_BLINDING_INVERT_EX                       101\n# define BN_F_BN_BLINDING_NEW                             102\n# define BN_F_BN_BLINDING_UPDATE                          103\n# define BN_F_BN_BN2DEC                                   104\n# define BN_F_BN_BN2HEX                                   105\n# define BN_F_BN_CTX_GET                                  116\n# define BN_F_BN_CTX_NEW                                  106\n# define BN_F_BN_CTX_START                                129\n# define BN_F_BN_DIV                                      107\n# define BN_F_BN_DIV_NO_BRANCH                            138\n# define BN_F_BN_DIV_RECP                                 130\n# define BN_F_BN_EXP                                      123\n# define BN_F_BN_EXPAND2                                  108\n# define BN_F_BN_EXPAND_INTERNAL                          120\n# define BN_F_BN_GF2M_MOD                                 131\n# define BN_F_BN_GF2M_MOD_EXP                             132\n# define BN_F_BN_GF2M_MOD_MUL                             133\n# define BN_F_BN_GF2M_MOD_SOLVE_QUAD                      134\n# define BN_F_BN_GF2M_MOD_SOLVE_QUAD_ARR                  135\n# define BN_F_BN_GF2M_MOD_SQR                             136\n# define BN_F_BN_GF2M_MOD_SQRT                            137\n# define BN_F_BN_LSHIFT                                   145\n# define BN_F_BN_MOD_EXP2_MONT                            118\n# define BN_F_BN_MOD_EXP_MONT                             109\n# define BN_F_BN_MOD_EXP_MONT_CONSTTIME                   124\n# define BN_F_BN_MOD_EXP_MONT_WORD                        117\n# define BN_F_BN_MOD_EXP_RECP                             125\n# define BN_F_BN_MOD_EXP_SIMPLE                           126\n# define BN_F_BN_MOD_INVERSE                              110\n# define BN_F_BN_MOD_INVERSE_NO_BRANCH                    139\n# define BN_F_BN_MOD_LSHIFT_QUICK                         119\n# define BN_F_BN_MOD_MUL_RECIPROCAL                       111\n# define BN_F_BN_MOD_SQRT                                 121\n# define BN_F_BN_MPI2BN                                   112\n# define BN_F_BN_NEW                                      113\n# define BN_F_BN_RAND                                     114\n# define BN_F_BN_RAND_RANGE                               122\n# define BN_F_BN_RSHIFT                                   146\n# define BN_F_BN_USUB                                     115\n\n/* Reason codes. */\n# define BN_R_ARG2_LT_ARG3                                100\n# define BN_R_BAD_RECIPROCAL                              101\n# define BN_R_BIGNUM_TOO_LONG                             114\n# define BN_R_BITS_TOO_SMALL                              118\n# define BN_R_CALLED_WITH_EVEN_MODULUS                    102\n# define BN_R_DIV_BY_ZERO                                 103\n# define BN_R_ENCODING_ERROR                              104\n# define BN_R_EXPAND_ON_STATIC_BIGNUM_DATA                105\n# define BN_R_INPUT_NOT_REDUCED                           110\n# define BN_R_INVALID_LENGTH                              106\n# define BN_R_INVALID_RANGE                               115\n# define BN_R_INVALID_SHIFT                               119\n# define BN_R_NOT_A_SQUARE                                111\n# define BN_R_NOT_INITIALIZED                             107\n# define BN_R_NO_INVERSE                                  108\n# define BN_R_NO_SOLUTION                                 116\n# define BN_R_P_IS_NOT_PRIME                              112\n# define BN_R_TOO_MANY_ITERATIONS                         113\n# define BN_R_TOO_MANY_TEMPORARY_VARIABLES                109\n\n#ifdef  __cplusplus\n}\n#endif\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/x86_64/include/openssl/buffer.h",
    "content": "/* crypto/buffer/buffer.h */\n/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)\n * All rights reserved.\n *\n * This package is an SSL implementation written\n * by Eric Young (eay@cryptsoft.com).\n * The implementation was written so as to conform with Netscapes SSL.\n *\n * This library is free for commercial and non-commercial use as long as\n * the following conditions are aheared to.  The following conditions\n * apply to all code found in this distribution, be it the RC4, RSA,\n * lhash, DES, etc., code; not just the SSL code.  The SSL documentation\n * included with this distribution is covered by the same copyright terms\n * except that the holder is Tim Hudson (tjh@cryptsoft.com).\n *\n * Copyright remains Eric Young's, and as such any Copyright notices in\n * the code are not to be removed.\n * If this package is used in a product, Eric Young should be given attribution\n * as the author of the parts of the library used.\n * This can be in the form of a textual message at program startup or\n * in documentation (online or textual) provided with the package.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the copyright\n *    notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in the\n *    documentation and/or other materials provided with the distribution.\n * 3. All advertising materials mentioning features or use of this software\n *    must display the following acknowledgement:\n *    \"This product includes cryptographic software written by\n *     Eric Young (eay@cryptsoft.com)\"\n *    The word 'cryptographic' can be left out if the rouines from the library\n *    being used are not cryptographic related :-).\n * 4. If you include any Windows specific code (or a derivative thereof) from\n *    the apps directory (application code) you must include an acknowledgement:\n *    \"This product includes software written by Tim Hudson (tjh@cryptsoft.com)\"\n *\n * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n * SUCH DAMAGE.\n *\n * The licence and distribution terms for any publically available version or\n * derivative of this code cannot be changed.  i.e. this code cannot simply be\n * copied and put under another distribution licence\n * [including the GNU Public Licence.]\n */\n\n#ifndef HEADER_BUFFER_H\n# define HEADER_BUFFER_H\n\n# include <openssl/ossl_typ.h>\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n# include <stddef.h>\n\n# if !defined(NO_SYS_TYPES_H)\n#  include <sys/types.h>\n# endif\n\n/* Already declared in ossl_typ.h */\n/* typedef struct buf_mem_st BUF_MEM; */\n\nstruct buf_mem_st {\n    size_t length;              /* current number of bytes */\n    char *data;\n    size_t max;                 /* size of buffer */\n};\n\nBUF_MEM *BUF_MEM_new(void);\nvoid BUF_MEM_free(BUF_MEM *a);\nint BUF_MEM_grow(BUF_MEM *str, size_t len);\nint BUF_MEM_grow_clean(BUF_MEM *str, size_t len);\nsize_t BUF_strnlen(const char *str, size_t maxlen);\nchar *BUF_strdup(const char *str);\n\n/*\n * Like strndup, but in addition, explicitly guarantees to never read past the\n * first |siz| bytes of |str|.\n */\nchar *BUF_strndup(const char *str, size_t siz);\n\nvoid *BUF_memdup(const void *data, size_t siz);\nvoid BUF_reverse(unsigned char *out, const unsigned char *in, size_t siz);\n\n/* safe string functions */\nsize_t BUF_strlcpy(char *dst, const char *src, size_t siz);\nsize_t BUF_strlcat(char *dst, const char *src, size_t siz);\n\n/* BEGIN ERROR CODES */\n/*\n * The following lines are auto generated by the script mkerr.pl. Any changes\n * made after this point may be overwritten when the script is next run.\n */\nvoid ERR_load_BUF_strings(void);\n\n/* Error codes for the BUF functions. */\n\n/* Function codes. */\n# define BUF_F_BUF_MEMDUP                                 103\n# define BUF_F_BUF_MEM_GROW                               100\n# define BUF_F_BUF_MEM_GROW_CLEAN                         105\n# define BUF_F_BUF_MEM_NEW                                101\n# define BUF_F_BUF_STRDUP                                 102\n# define BUF_F_BUF_STRNDUP                                104\n\n/* Reason codes. */\n\n#ifdef  __cplusplus\n}\n#endif\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/x86_64/include/openssl/camellia.h",
    "content": "/* crypto/camellia/camellia.h */\n/* ====================================================================\n * Copyright (c) 2006 The OpenSSL Project.  All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n *\n * 1. Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n *\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in\n *    the documentation and/or other materials provided with the\n *    distribution.\n *\n * 3. All advertising materials mentioning features or use of this\n *    software must display the following acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit. (http://www.openssl.org/)\"\n *\n * 4. The names \"OpenSSL Toolkit\" and \"OpenSSL Project\" must not be used to\n *    endorse or promote products derived from this software without\n *    prior written permission. For written permission, please contact\n *    openssl-core@openssl.org.\n *\n * 5. Products derived from this software may not be called \"OpenSSL\"\n *    nor may \"OpenSSL\" appear in their names without prior written\n *    permission of the OpenSSL Project.\n *\n * 6. Redistributions of any form whatsoever must retain the following\n *    acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit (http://www.openssl.org/)\"\n *\n * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY\n * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\n * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR\n * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\n * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,\n * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED\n * OF THE POSSIBILITY OF SUCH DAMAGE.\n * ====================================================================\n *\n */\n\n#ifndef HEADER_CAMELLIA_H\n# define HEADER_CAMELLIA_H\n\n# include <openssl/opensslconf.h>\n\n# ifdef OPENSSL_NO_CAMELLIA\n#  error CAMELLIA is disabled.\n# endif\n\n# include <stddef.h>\n\n# define CAMELLIA_ENCRYPT        1\n# define CAMELLIA_DECRYPT        0\n\n/*\n * Because array size can't be a const in C, the following two are macros.\n * Both sizes are in bytes.\n */\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n/* This should be a hidden type, but EVP requires that the size be known */\n\n# define CAMELLIA_BLOCK_SIZE 16\n# define CAMELLIA_TABLE_BYTE_LEN 272\n# define CAMELLIA_TABLE_WORD_LEN (CAMELLIA_TABLE_BYTE_LEN / 4)\n\ntypedef unsigned int KEY_TABLE_TYPE[CAMELLIA_TABLE_WORD_LEN]; /* to match\n                                                               * with WORD */\n\nstruct camellia_key_st {\n    union {\n        double d;               /* ensures 64-bit align */\n        KEY_TABLE_TYPE rd_key;\n    } u;\n    int grand_rounds;\n};\ntypedef struct camellia_key_st CAMELLIA_KEY;\n\n# ifdef OPENSSL_FIPS\nint private_Camellia_set_key(const unsigned char *userKey, const int bits,\n                             CAMELLIA_KEY *key);\n# endif\nint Camellia_set_key(const unsigned char *userKey, const int bits,\n                     CAMELLIA_KEY *key);\n\nvoid Camellia_encrypt(const unsigned char *in, unsigned char *out,\n                      const CAMELLIA_KEY *key);\nvoid Camellia_decrypt(const unsigned char *in, unsigned char *out,\n                      const CAMELLIA_KEY *key);\n\nvoid Camellia_ecb_encrypt(const unsigned char *in, unsigned char *out,\n                          const CAMELLIA_KEY *key, const int enc);\nvoid Camellia_cbc_encrypt(const unsigned char *in, unsigned char *out,\n                          size_t length, const CAMELLIA_KEY *key,\n                          unsigned char *ivec, const int enc);\nvoid Camellia_cfb128_encrypt(const unsigned char *in, unsigned char *out,\n                             size_t length, const CAMELLIA_KEY *key,\n                             unsigned char *ivec, int *num, const int enc);\nvoid Camellia_cfb1_encrypt(const unsigned char *in, unsigned char *out,\n                           size_t length, const CAMELLIA_KEY *key,\n                           unsigned char *ivec, int *num, const int enc);\nvoid Camellia_cfb8_encrypt(const unsigned char *in, unsigned char *out,\n                           size_t length, const CAMELLIA_KEY *key,\n                           unsigned char *ivec, int *num, const int enc);\nvoid Camellia_ofb128_encrypt(const unsigned char *in, unsigned char *out,\n                             size_t length, const CAMELLIA_KEY *key,\n                             unsigned char *ivec, int *num);\nvoid Camellia_ctr128_encrypt(const unsigned char *in, unsigned char *out,\n                             size_t length, const CAMELLIA_KEY *key,\n                             unsigned char ivec[CAMELLIA_BLOCK_SIZE],\n                             unsigned char ecount_buf[CAMELLIA_BLOCK_SIZE],\n                             unsigned int *num);\n\n#ifdef  __cplusplus\n}\n#endif\n\n#endif                          /* !HEADER_Camellia_H */\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/x86_64/include/openssl/cmac.h",
    "content": "/* crypto/cmac/cmac.h */\n/*\n * Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL\n * project.\n */\n/* ====================================================================\n * Copyright (c) 2010 The OpenSSL Project.  All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n *\n * 1. Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n *\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in\n *    the documentation and/or other materials provided with the\n *    distribution.\n *\n * 3. All advertising materials mentioning features or use of this\n *    software must display the following acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)\"\n *\n * 4. The names \"OpenSSL Toolkit\" and \"OpenSSL Project\" must not be used to\n *    endorse or promote products derived from this software without\n *    prior written permission. For written permission, please contact\n *    licensing@OpenSSL.org.\n *\n * 5. Products derived from this software may not be called \"OpenSSL\"\n *    nor may \"OpenSSL\" appear in their names without prior written\n *    permission of the OpenSSL Project.\n *\n * 6. Redistributions of any form whatsoever must retain the following\n *    acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)\"\n *\n * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY\n * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\n * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR\n * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\n * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,\n * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED\n * OF THE POSSIBILITY OF SUCH DAMAGE.\n * ====================================================================\n */\n\n#ifndef HEADER_CMAC_H\n# define HEADER_CMAC_H\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n# include <openssl/evp.h>\n\n/* Opaque */\ntypedef struct CMAC_CTX_st CMAC_CTX;\n\nCMAC_CTX *CMAC_CTX_new(void);\nvoid CMAC_CTX_cleanup(CMAC_CTX *ctx);\nvoid CMAC_CTX_free(CMAC_CTX *ctx);\nEVP_CIPHER_CTX *CMAC_CTX_get0_cipher_ctx(CMAC_CTX *ctx);\nint CMAC_CTX_copy(CMAC_CTX *out, const CMAC_CTX *in);\n\nint CMAC_Init(CMAC_CTX *ctx, const void *key, size_t keylen,\n              const EVP_CIPHER *cipher, ENGINE *impl);\nint CMAC_Update(CMAC_CTX *ctx, const void *data, size_t dlen);\nint CMAC_Final(CMAC_CTX *ctx, unsigned char *out, size_t *poutlen);\nint CMAC_resume(CMAC_CTX *ctx);\n\n#ifdef  __cplusplus\n}\n#endif\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/x86_64/include/openssl/cms.h",
    "content": "/* crypto/cms/cms.h */\n/*\n * Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL\n * project.\n */\n/* ====================================================================\n * Copyright (c) 2008 The OpenSSL Project.  All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n *\n * 1. Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n *\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in\n *    the documentation and/or other materials provided with the\n *    distribution.\n *\n * 3. All advertising materials mentioning features or use of this\n *    software must display the following acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)\"\n *\n * 4. The names \"OpenSSL Toolkit\" and \"OpenSSL Project\" must not be used to\n *    endorse or promote products derived from this software without\n *    prior written permission. For written permission, please contact\n *    licensing@OpenSSL.org.\n *\n * 5. Products derived from this software may not be called \"OpenSSL\"\n *    nor may \"OpenSSL\" appear in their names without prior written\n *    permission of the OpenSSL Project.\n *\n * 6. Redistributions of any form whatsoever must retain the following\n *    acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)\"\n *\n * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY\n * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\n * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR\n * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\n * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,\n * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED\n * OF THE POSSIBILITY OF SUCH DAMAGE.\n * ====================================================================\n */\n\n#ifndef HEADER_CMS_H\n# define HEADER_CMS_H\n\n# include <openssl/x509.h>\n\n# ifdef OPENSSL_NO_CMS\n#  error CMS is disabled.\n# endif\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\ntypedef struct CMS_ContentInfo_st CMS_ContentInfo;\ntypedef struct CMS_SignerInfo_st CMS_SignerInfo;\ntypedef struct CMS_CertificateChoices CMS_CertificateChoices;\ntypedef struct CMS_RevocationInfoChoice_st CMS_RevocationInfoChoice;\ntypedef struct CMS_RecipientInfo_st CMS_RecipientInfo;\ntypedef struct CMS_ReceiptRequest_st CMS_ReceiptRequest;\ntypedef struct CMS_Receipt_st CMS_Receipt;\ntypedef struct CMS_RecipientEncryptedKey_st CMS_RecipientEncryptedKey;\ntypedef struct CMS_OtherKeyAttribute_st CMS_OtherKeyAttribute;\n\nDECLARE_STACK_OF(CMS_SignerInfo)\nDECLARE_STACK_OF(GENERAL_NAMES)\nDECLARE_STACK_OF(CMS_RecipientEncryptedKey)\nDECLARE_ASN1_FUNCTIONS(CMS_ContentInfo)\nDECLARE_ASN1_FUNCTIONS(CMS_ReceiptRequest)\nDECLARE_ASN1_PRINT_FUNCTION(CMS_ContentInfo)\n\n# define CMS_SIGNERINFO_ISSUER_SERIAL    0\n# define CMS_SIGNERINFO_KEYIDENTIFIER    1\n\n# define CMS_RECIPINFO_NONE              -1\n# define CMS_RECIPINFO_TRANS             0\n# define CMS_RECIPINFO_AGREE             1\n# define CMS_RECIPINFO_KEK               2\n# define CMS_RECIPINFO_PASS              3\n# define CMS_RECIPINFO_OTHER             4\n\n/* S/MIME related flags */\n\n# define CMS_TEXT                        0x1\n# define CMS_NOCERTS                     0x2\n# define CMS_NO_CONTENT_VERIFY           0x4\n# define CMS_NO_ATTR_VERIFY              0x8\n# define CMS_NOSIGS                      \\\n                        (CMS_NO_CONTENT_VERIFY|CMS_NO_ATTR_VERIFY)\n# define CMS_NOINTERN                    0x10\n# define CMS_NO_SIGNER_CERT_VERIFY       0x20\n# define CMS_NOVERIFY                    0x20\n# define CMS_DETACHED                    0x40\n# define CMS_BINARY                      0x80\n# define CMS_NOATTR                      0x100\n# define CMS_NOSMIMECAP                  0x200\n# define CMS_NOOLDMIMETYPE               0x400\n# define CMS_CRLFEOL                     0x800\n# define CMS_STREAM                      0x1000\n# define CMS_NOCRL                       0x2000\n# define CMS_PARTIAL                     0x4000\n# define CMS_REUSE_DIGEST                0x8000\n# define CMS_USE_KEYID                   0x10000\n# define CMS_DEBUG_DECRYPT               0x20000\n# define CMS_KEY_PARAM                   0x40000\n\nconst ASN1_OBJECT *CMS_get0_type(CMS_ContentInfo *cms);\n\nBIO *CMS_dataInit(CMS_ContentInfo *cms, BIO *icont);\nint CMS_dataFinal(CMS_ContentInfo *cms, BIO *bio);\n\nASN1_OCTET_STRING **CMS_get0_content(CMS_ContentInfo *cms);\nint CMS_is_detached(CMS_ContentInfo *cms);\nint CMS_set_detached(CMS_ContentInfo *cms, int detached);\n\n# ifdef HEADER_PEM_H\nDECLARE_PEM_rw_const(CMS, CMS_ContentInfo)\n# endif\nint CMS_stream(unsigned char ***boundary, CMS_ContentInfo *cms);\nCMS_ContentInfo *d2i_CMS_bio(BIO *bp, CMS_ContentInfo **cms);\nint i2d_CMS_bio(BIO *bp, CMS_ContentInfo *cms);\n\nBIO *BIO_new_CMS(BIO *out, CMS_ContentInfo *cms);\nint i2d_CMS_bio_stream(BIO *out, CMS_ContentInfo *cms, BIO *in, int flags);\nint PEM_write_bio_CMS_stream(BIO *out, CMS_ContentInfo *cms, BIO *in,\n                             int flags);\nCMS_ContentInfo *SMIME_read_CMS(BIO *bio, BIO **bcont);\nint SMIME_write_CMS(BIO *bio, CMS_ContentInfo *cms, BIO *data, int flags);\n\nint CMS_final(CMS_ContentInfo *cms, BIO *data, BIO *dcont,\n              unsigned int flags);\n\nCMS_ContentInfo *CMS_sign(X509 *signcert, EVP_PKEY *pkey,\n                          STACK_OF(X509) *certs, BIO *data,\n                          unsigned int flags);\n\nCMS_ContentInfo *CMS_sign_receipt(CMS_SignerInfo *si,\n                                  X509 *signcert, EVP_PKEY *pkey,\n                                  STACK_OF(X509) *certs, unsigned int flags);\n\nint CMS_data(CMS_ContentInfo *cms, BIO *out, unsigned int flags);\nCMS_ContentInfo *CMS_data_create(BIO *in, unsigned int flags);\n\nint CMS_digest_verify(CMS_ContentInfo *cms, BIO *dcont, BIO *out,\n                      unsigned int flags);\nCMS_ContentInfo *CMS_digest_create(BIO *in, const EVP_MD *md,\n                                   unsigned int flags);\n\nint CMS_EncryptedData_decrypt(CMS_ContentInfo *cms,\n                              const unsigned char *key, size_t keylen,\n                              BIO *dcont, BIO *out, unsigned int flags);\n\nCMS_ContentInfo *CMS_EncryptedData_encrypt(BIO *in, const EVP_CIPHER *cipher,\n                                           const unsigned char *key,\n                                           size_t keylen, unsigned int flags);\n\nint CMS_EncryptedData_set1_key(CMS_ContentInfo *cms, const EVP_CIPHER *ciph,\n                               const unsigned char *key, size_t keylen);\n\nint CMS_verify(CMS_ContentInfo *cms, STACK_OF(X509) *certs,\n               X509_STORE *store, BIO *dcont, BIO *out, unsigned int flags);\n\nint CMS_verify_receipt(CMS_ContentInfo *rcms, CMS_ContentInfo *ocms,\n                       STACK_OF(X509) *certs,\n                       X509_STORE *store, unsigned int flags);\n\nSTACK_OF(X509) *CMS_get0_signers(CMS_ContentInfo *cms);\n\nCMS_ContentInfo *CMS_encrypt(STACK_OF(X509) *certs, BIO *in,\n                             const EVP_CIPHER *cipher, unsigned int flags);\n\nint CMS_decrypt(CMS_ContentInfo *cms, EVP_PKEY *pkey, X509 *cert,\n                BIO *dcont, BIO *out, unsigned int flags);\n\nint CMS_decrypt_set1_pkey(CMS_ContentInfo *cms, EVP_PKEY *pk, X509 *cert);\nint CMS_decrypt_set1_key(CMS_ContentInfo *cms,\n                         unsigned char *key, size_t keylen,\n                         unsigned char *id, size_t idlen);\nint CMS_decrypt_set1_password(CMS_ContentInfo *cms,\n                              unsigned char *pass, ossl_ssize_t passlen);\n\nSTACK_OF(CMS_RecipientInfo) *CMS_get0_RecipientInfos(CMS_ContentInfo *cms);\nint CMS_RecipientInfo_type(CMS_RecipientInfo *ri);\nEVP_PKEY_CTX *CMS_RecipientInfo_get0_pkey_ctx(CMS_RecipientInfo *ri);\nCMS_ContentInfo *CMS_EnvelopedData_create(const EVP_CIPHER *cipher);\nCMS_RecipientInfo *CMS_add1_recipient_cert(CMS_ContentInfo *cms,\n                                           X509 *recip, unsigned int flags);\nint CMS_RecipientInfo_set0_pkey(CMS_RecipientInfo *ri, EVP_PKEY *pkey);\nint CMS_RecipientInfo_ktri_cert_cmp(CMS_RecipientInfo *ri, X509 *cert);\nint CMS_RecipientInfo_ktri_get0_algs(CMS_RecipientInfo *ri,\n                                     EVP_PKEY **pk, X509 **recip,\n                                     X509_ALGOR **palg);\nint CMS_RecipientInfo_ktri_get0_signer_id(CMS_RecipientInfo *ri,\n                                          ASN1_OCTET_STRING **keyid,\n                                          X509_NAME **issuer,\n                                          ASN1_INTEGER **sno);\n\nCMS_RecipientInfo *CMS_add0_recipient_key(CMS_ContentInfo *cms, int nid,\n                                          unsigned char *key, size_t keylen,\n                                          unsigned char *id, size_t idlen,\n                                          ASN1_GENERALIZEDTIME *date,\n                                          ASN1_OBJECT *otherTypeId,\n                                          ASN1_TYPE *otherType);\n\nint CMS_RecipientInfo_kekri_get0_id(CMS_RecipientInfo *ri,\n                                    X509_ALGOR **palg,\n                                    ASN1_OCTET_STRING **pid,\n                                    ASN1_GENERALIZEDTIME **pdate,\n                                    ASN1_OBJECT **potherid,\n                                    ASN1_TYPE **pothertype);\n\nint CMS_RecipientInfo_set0_key(CMS_RecipientInfo *ri,\n                               unsigned char *key, size_t keylen);\n\nint CMS_RecipientInfo_kekri_id_cmp(CMS_RecipientInfo *ri,\n                                   const unsigned char *id, size_t idlen);\n\nint CMS_RecipientInfo_set0_password(CMS_RecipientInfo *ri,\n                                    unsigned char *pass,\n                                    ossl_ssize_t passlen);\n\nCMS_RecipientInfo *CMS_add0_recipient_password(CMS_ContentInfo *cms,\n                                               int iter, int wrap_nid,\n                                               int pbe_nid,\n                                               unsigned char *pass,\n                                               ossl_ssize_t passlen,\n                                               const EVP_CIPHER *kekciph);\n\nint CMS_RecipientInfo_decrypt(CMS_ContentInfo *cms, CMS_RecipientInfo *ri);\nint CMS_RecipientInfo_encrypt(CMS_ContentInfo *cms, CMS_RecipientInfo *ri);\n\nint CMS_uncompress(CMS_ContentInfo *cms, BIO *dcont, BIO *out,\n                   unsigned int flags);\nCMS_ContentInfo *CMS_compress(BIO *in, int comp_nid, unsigned int flags);\n\nint CMS_set1_eContentType(CMS_ContentInfo *cms, const ASN1_OBJECT *oid);\nconst ASN1_OBJECT *CMS_get0_eContentType(CMS_ContentInfo *cms);\n\nCMS_CertificateChoices *CMS_add0_CertificateChoices(CMS_ContentInfo *cms);\nint CMS_add0_cert(CMS_ContentInfo *cms, X509 *cert);\nint CMS_add1_cert(CMS_ContentInfo *cms, X509 *cert);\nSTACK_OF(X509) *CMS_get1_certs(CMS_ContentInfo *cms);\n\nCMS_RevocationInfoChoice *CMS_add0_RevocationInfoChoice(CMS_ContentInfo *cms);\nint CMS_add0_crl(CMS_ContentInfo *cms, X509_CRL *crl);\nint CMS_add1_crl(CMS_ContentInfo *cms, X509_CRL *crl);\nSTACK_OF(X509_CRL) *CMS_get1_crls(CMS_ContentInfo *cms);\n\nint CMS_SignedData_init(CMS_ContentInfo *cms);\nCMS_SignerInfo *CMS_add1_signer(CMS_ContentInfo *cms,\n                                X509 *signer, EVP_PKEY *pk, const EVP_MD *md,\n                                unsigned int flags);\nEVP_PKEY_CTX *CMS_SignerInfo_get0_pkey_ctx(CMS_SignerInfo *si);\nEVP_MD_CTX *CMS_SignerInfo_get0_md_ctx(CMS_SignerInfo *si);\nSTACK_OF(CMS_SignerInfo) *CMS_get0_SignerInfos(CMS_ContentInfo *cms);\n\nvoid CMS_SignerInfo_set1_signer_cert(CMS_SignerInfo *si, X509 *signer);\nint CMS_SignerInfo_get0_signer_id(CMS_SignerInfo *si,\n                                  ASN1_OCTET_STRING **keyid,\n                                  X509_NAME **issuer, ASN1_INTEGER **sno);\nint CMS_SignerInfo_cert_cmp(CMS_SignerInfo *si, X509 *cert);\nint CMS_set1_signers_certs(CMS_ContentInfo *cms, STACK_OF(X509) *certs,\n                           unsigned int flags);\nvoid CMS_SignerInfo_get0_algs(CMS_SignerInfo *si, EVP_PKEY **pk,\n                              X509 **signer, X509_ALGOR **pdig,\n                              X509_ALGOR **psig);\nASN1_OCTET_STRING *CMS_SignerInfo_get0_signature(CMS_SignerInfo *si);\nint CMS_SignerInfo_sign(CMS_SignerInfo *si);\nint CMS_SignerInfo_verify(CMS_SignerInfo *si);\nint CMS_SignerInfo_verify_content(CMS_SignerInfo *si, BIO *chain);\n\nint CMS_add_smimecap(CMS_SignerInfo *si, STACK_OF(X509_ALGOR) *algs);\nint CMS_add_simple_smimecap(STACK_OF(X509_ALGOR) **algs,\n                            int algnid, int keysize);\nint CMS_add_standard_smimecap(STACK_OF(X509_ALGOR) **smcap);\n\nint CMS_signed_get_attr_count(const CMS_SignerInfo *si);\nint CMS_signed_get_attr_by_NID(const CMS_SignerInfo *si, int nid,\n                               int lastpos);\nint CMS_signed_get_attr_by_OBJ(const CMS_SignerInfo *si, ASN1_OBJECT *obj,\n                               int lastpos);\nX509_ATTRIBUTE *CMS_signed_get_attr(const CMS_SignerInfo *si, int loc);\nX509_ATTRIBUTE *CMS_signed_delete_attr(CMS_SignerInfo *si, int loc);\nint CMS_signed_add1_attr(CMS_SignerInfo *si, X509_ATTRIBUTE *attr);\nint CMS_signed_add1_attr_by_OBJ(CMS_SignerInfo *si,\n                                const ASN1_OBJECT *obj, int type,\n                                const void *bytes, int len);\nint CMS_signed_add1_attr_by_NID(CMS_SignerInfo *si,\n                                int nid, int type,\n                                const void *bytes, int len);\nint CMS_signed_add1_attr_by_txt(CMS_SignerInfo *si,\n                                const char *attrname, int type,\n                                const void *bytes, int len);\nvoid *CMS_signed_get0_data_by_OBJ(CMS_SignerInfo *si, ASN1_OBJECT *oid,\n                                  int lastpos, int type);\n\nint CMS_unsigned_get_attr_count(const CMS_SignerInfo *si);\nint CMS_unsigned_get_attr_by_NID(const CMS_SignerInfo *si, int nid,\n                                 int lastpos);\nint CMS_unsigned_get_attr_by_OBJ(const CMS_SignerInfo *si, ASN1_OBJECT *obj,\n                                 int lastpos);\nX509_ATTRIBUTE *CMS_unsigned_get_attr(const CMS_SignerInfo *si, int loc);\nX509_ATTRIBUTE *CMS_unsigned_delete_attr(CMS_SignerInfo *si, int loc);\nint CMS_unsigned_add1_attr(CMS_SignerInfo *si, X509_ATTRIBUTE *attr);\nint CMS_unsigned_add1_attr_by_OBJ(CMS_SignerInfo *si,\n                                  const ASN1_OBJECT *obj, int type,\n                                  const void *bytes, int len);\nint CMS_unsigned_add1_attr_by_NID(CMS_SignerInfo *si,\n                                  int nid, int type,\n                                  const void *bytes, int len);\nint CMS_unsigned_add1_attr_by_txt(CMS_SignerInfo *si,\n                                  const char *attrname, int type,\n                                  const void *bytes, int len);\nvoid *CMS_unsigned_get0_data_by_OBJ(CMS_SignerInfo *si, ASN1_OBJECT *oid,\n                                    int lastpos, int type);\n\n# ifdef HEADER_X509V3_H\n\nint CMS_get1_ReceiptRequest(CMS_SignerInfo *si, CMS_ReceiptRequest **prr);\nCMS_ReceiptRequest *CMS_ReceiptRequest_create0(unsigned char *id, int idlen,\n                                               int allorfirst,\n                                               STACK_OF(GENERAL_NAMES)\n                                               *receiptList, STACK_OF(GENERAL_NAMES)\n                                               *receiptsTo);\nint CMS_add1_ReceiptRequest(CMS_SignerInfo *si, CMS_ReceiptRequest *rr);\nvoid CMS_ReceiptRequest_get0_values(CMS_ReceiptRequest *rr,\n                                    ASN1_STRING **pcid,\n                                    int *pallorfirst,\n                                    STACK_OF(GENERAL_NAMES) **plist,\n                                    STACK_OF(GENERAL_NAMES) **prto);\n# endif\nint CMS_RecipientInfo_kari_get0_alg(CMS_RecipientInfo *ri,\n                                    X509_ALGOR **palg,\n                                    ASN1_OCTET_STRING **pukm);\nSTACK_OF(CMS_RecipientEncryptedKey)\n*CMS_RecipientInfo_kari_get0_reks(CMS_RecipientInfo *ri);\n\nint CMS_RecipientInfo_kari_get0_orig_id(CMS_RecipientInfo *ri,\n                                        X509_ALGOR **pubalg,\n                                        ASN1_BIT_STRING **pubkey,\n                                        ASN1_OCTET_STRING **keyid,\n                                        X509_NAME **issuer,\n                                        ASN1_INTEGER **sno);\n\nint CMS_RecipientInfo_kari_orig_id_cmp(CMS_RecipientInfo *ri, X509 *cert);\n\nint CMS_RecipientEncryptedKey_get0_id(CMS_RecipientEncryptedKey *rek,\n                                      ASN1_OCTET_STRING **keyid,\n                                      ASN1_GENERALIZEDTIME **tm,\n                                      CMS_OtherKeyAttribute **other,\n                                      X509_NAME **issuer, ASN1_INTEGER **sno);\nint CMS_RecipientEncryptedKey_cert_cmp(CMS_RecipientEncryptedKey *rek,\n                                       X509 *cert);\nint CMS_RecipientInfo_kari_set0_pkey(CMS_RecipientInfo *ri, EVP_PKEY *pk);\nEVP_CIPHER_CTX *CMS_RecipientInfo_kari_get0_ctx(CMS_RecipientInfo *ri);\nint CMS_RecipientInfo_kari_decrypt(CMS_ContentInfo *cms,\n                                   CMS_RecipientInfo *ri,\n                                   CMS_RecipientEncryptedKey *rek);\n\nint CMS_SharedInfo_encode(unsigned char **pder, X509_ALGOR *kekalg,\n                          ASN1_OCTET_STRING *ukm, int keylen);\n\n/* BEGIN ERROR CODES */\n/*\n * The following lines are auto generated by the script mkerr.pl. Any changes\n * made after this point may be overwritten when the script is next run.\n */\nvoid ERR_load_CMS_strings(void);\n\n/* Error codes for the CMS functions. */\n\n/* Function codes. */\n# define CMS_F_CHECK_CONTENT                              99\n# define CMS_F_CMS_ADD0_CERT                              164\n# define CMS_F_CMS_ADD0_RECIPIENT_KEY                     100\n# define CMS_F_CMS_ADD0_RECIPIENT_PASSWORD                165\n# define CMS_F_CMS_ADD1_RECEIPTREQUEST                    158\n# define CMS_F_CMS_ADD1_RECIPIENT_CERT                    101\n# define CMS_F_CMS_ADD1_SIGNER                            102\n# define CMS_F_CMS_ADD1_SIGNINGTIME                       103\n# define CMS_F_CMS_COMPRESS                               104\n# define CMS_F_CMS_COMPRESSEDDATA_CREATE                  105\n# define CMS_F_CMS_COMPRESSEDDATA_INIT_BIO                106\n# define CMS_F_CMS_COPY_CONTENT                           107\n# define CMS_F_CMS_COPY_MESSAGEDIGEST                     108\n# define CMS_F_CMS_DATA                                   109\n# define CMS_F_CMS_DATAFINAL                              110\n# define CMS_F_CMS_DATAINIT                               111\n# define CMS_F_CMS_DECRYPT                                112\n# define CMS_F_CMS_DECRYPT_SET1_KEY                       113\n# define CMS_F_CMS_DECRYPT_SET1_PASSWORD                  166\n# define CMS_F_CMS_DECRYPT_SET1_PKEY                      114\n# define CMS_F_CMS_DIGESTALGORITHM_FIND_CTX               115\n# define CMS_F_CMS_DIGESTALGORITHM_INIT_BIO               116\n# define CMS_F_CMS_DIGESTEDDATA_DO_FINAL                  117\n# define CMS_F_CMS_DIGEST_VERIFY                          118\n# define CMS_F_CMS_ENCODE_RECEIPT                         161\n# define CMS_F_CMS_ENCRYPT                                119\n# define CMS_F_CMS_ENCRYPTEDCONTENT_INIT_BIO              120\n# define CMS_F_CMS_ENCRYPTEDDATA_DECRYPT                  121\n# define CMS_F_CMS_ENCRYPTEDDATA_ENCRYPT                  122\n# define CMS_F_CMS_ENCRYPTEDDATA_SET1_KEY                 123\n# define CMS_F_CMS_ENVELOPEDDATA_CREATE                   124\n# define CMS_F_CMS_ENVELOPEDDATA_INIT_BIO                 125\n# define CMS_F_CMS_ENVELOPED_DATA_INIT                    126\n# define CMS_F_CMS_ENV_ASN1_CTRL                          171\n# define CMS_F_CMS_FINAL                                  127\n# define CMS_F_CMS_GET0_CERTIFICATE_CHOICES               128\n# define CMS_F_CMS_GET0_CONTENT                           129\n# define CMS_F_CMS_GET0_ECONTENT_TYPE                     130\n# define CMS_F_CMS_GET0_ENVELOPED                         131\n# define CMS_F_CMS_GET0_REVOCATION_CHOICES                132\n# define CMS_F_CMS_GET0_SIGNED                            133\n# define CMS_F_CMS_MSGSIGDIGEST_ADD1                      162\n# define CMS_F_CMS_RECEIPTREQUEST_CREATE0                 159\n# define CMS_F_CMS_RECEIPT_VERIFY                         160\n# define CMS_F_CMS_RECIPIENTINFO_DECRYPT                  134\n# define CMS_F_CMS_RECIPIENTINFO_ENCRYPT                  169\n# define CMS_F_CMS_RECIPIENTINFO_KARI_ENCRYPT             178\n# define CMS_F_CMS_RECIPIENTINFO_KARI_GET0_ALG            175\n# define CMS_F_CMS_RECIPIENTINFO_KARI_GET0_ORIG_ID        173\n# define CMS_F_CMS_RECIPIENTINFO_KARI_GET0_REKS           172\n# define CMS_F_CMS_RECIPIENTINFO_KARI_ORIG_ID_CMP         174\n# define CMS_F_CMS_RECIPIENTINFO_KEKRI_DECRYPT            135\n# define CMS_F_CMS_RECIPIENTINFO_KEKRI_ENCRYPT            136\n# define CMS_F_CMS_RECIPIENTINFO_KEKRI_GET0_ID            137\n# define CMS_F_CMS_RECIPIENTINFO_KEKRI_ID_CMP             138\n# define CMS_F_CMS_RECIPIENTINFO_KTRI_CERT_CMP            139\n# define CMS_F_CMS_RECIPIENTINFO_KTRI_DECRYPT             140\n# define CMS_F_CMS_RECIPIENTINFO_KTRI_ENCRYPT             141\n# define CMS_F_CMS_RECIPIENTINFO_KTRI_GET0_ALGS           142\n# define CMS_F_CMS_RECIPIENTINFO_KTRI_GET0_SIGNER_ID      143\n# define CMS_F_CMS_RECIPIENTINFO_PWRI_CRYPT               167\n# define CMS_F_CMS_RECIPIENTINFO_SET0_KEY                 144\n# define CMS_F_CMS_RECIPIENTINFO_SET0_PASSWORD            168\n# define CMS_F_CMS_RECIPIENTINFO_SET0_PKEY                145\n# define CMS_F_CMS_SD_ASN1_CTRL                           170\n# define CMS_F_CMS_SET1_IAS                               176\n# define CMS_F_CMS_SET1_KEYID                             177\n# define CMS_F_CMS_SET1_SIGNERIDENTIFIER                  146\n# define CMS_F_CMS_SET_DETACHED                           147\n# define CMS_F_CMS_SIGN                                   148\n# define CMS_F_CMS_SIGNED_DATA_INIT                       149\n# define CMS_F_CMS_SIGNERINFO_CONTENT_SIGN                150\n# define CMS_F_CMS_SIGNERINFO_SIGN                        151\n# define CMS_F_CMS_SIGNERINFO_VERIFY                      152\n# define CMS_F_CMS_SIGNERINFO_VERIFY_CERT                 153\n# define CMS_F_CMS_SIGNERINFO_VERIFY_CONTENT              154\n# define CMS_F_CMS_SIGN_RECEIPT                           163\n# define CMS_F_CMS_STREAM                                 155\n# define CMS_F_CMS_UNCOMPRESS                             156\n# define CMS_F_CMS_VERIFY                                 157\n\n/* Reason codes. */\n# define CMS_R_ADD_SIGNER_ERROR                           99\n# define CMS_R_CERTIFICATE_ALREADY_PRESENT                175\n# define CMS_R_CERTIFICATE_HAS_NO_KEYID                   160\n# define CMS_R_CERTIFICATE_VERIFY_ERROR                   100\n# define CMS_R_CIPHER_INITIALISATION_ERROR                101\n# define CMS_R_CIPHER_PARAMETER_INITIALISATION_ERROR      102\n# define CMS_R_CMS_DATAFINAL_ERROR                        103\n# define CMS_R_CMS_LIB                                    104\n# define CMS_R_CONTENTIDENTIFIER_MISMATCH                 170\n# define CMS_R_CONTENT_NOT_FOUND                          105\n# define CMS_R_CONTENT_TYPE_MISMATCH                      171\n# define CMS_R_CONTENT_TYPE_NOT_COMPRESSED_DATA           106\n# define CMS_R_CONTENT_TYPE_NOT_ENVELOPED_DATA            107\n# define CMS_R_CONTENT_TYPE_NOT_SIGNED_DATA               108\n# define CMS_R_CONTENT_VERIFY_ERROR                       109\n# define CMS_R_CTRL_ERROR                                 110\n# define CMS_R_CTRL_FAILURE                               111\n# define CMS_R_DECRYPT_ERROR                              112\n# define CMS_R_DIGEST_ERROR                               161\n# define CMS_R_ERROR_GETTING_PUBLIC_KEY                   113\n# define CMS_R_ERROR_READING_MESSAGEDIGEST_ATTRIBUTE      114\n# define CMS_R_ERROR_SETTING_KEY                          115\n# define CMS_R_ERROR_SETTING_RECIPIENTINFO                116\n# define CMS_R_INVALID_ENCRYPTED_KEY_LENGTH               117\n# define CMS_R_INVALID_KEY_ENCRYPTION_PARAMETER           176\n# define CMS_R_INVALID_KEY_LENGTH                         118\n# define CMS_R_MD_BIO_INIT_ERROR                          119\n# define CMS_R_MESSAGEDIGEST_ATTRIBUTE_WRONG_LENGTH       120\n# define CMS_R_MESSAGEDIGEST_WRONG_LENGTH                 121\n# define CMS_R_MSGSIGDIGEST_ERROR                         172\n# define CMS_R_MSGSIGDIGEST_VERIFICATION_FAILURE          162\n# define CMS_R_MSGSIGDIGEST_WRONG_LENGTH                  163\n# define CMS_R_NEED_ONE_SIGNER                            164\n# define CMS_R_NOT_A_SIGNED_RECEIPT                       165\n# define CMS_R_NOT_ENCRYPTED_DATA                         122\n# define CMS_R_NOT_KEK                                    123\n# define CMS_R_NOT_KEY_AGREEMENT                          181\n# define CMS_R_NOT_KEY_TRANSPORT                          124\n# define CMS_R_NOT_PWRI                                   177\n# define CMS_R_NOT_SUPPORTED_FOR_THIS_KEY_TYPE            125\n# define CMS_R_NO_CIPHER                                  126\n# define CMS_R_NO_CONTENT                                 127\n# define CMS_R_NO_CONTENT_TYPE                            173\n# define CMS_R_NO_DEFAULT_DIGEST                          128\n# define CMS_R_NO_DIGEST_SET                              129\n# define CMS_R_NO_KEY                                     130\n# define CMS_R_NO_KEY_OR_CERT                             174\n# define CMS_R_NO_MATCHING_DIGEST                         131\n# define CMS_R_NO_MATCHING_RECIPIENT                      132\n# define CMS_R_NO_MATCHING_SIGNATURE                      166\n# define CMS_R_NO_MSGSIGDIGEST                            167\n# define CMS_R_NO_PASSWORD                                178\n# define CMS_R_NO_PRIVATE_KEY                             133\n# define CMS_R_NO_PUBLIC_KEY                              134\n# define CMS_R_NO_RECEIPT_REQUEST                         168\n# define CMS_R_NO_SIGNERS                                 135\n# define CMS_R_PRIVATE_KEY_DOES_NOT_MATCH_CERTIFICATE     136\n# define CMS_R_RECEIPT_DECODE_ERROR                       169\n# define CMS_R_RECIPIENT_ERROR                            137\n# define CMS_R_SIGNER_CERTIFICATE_NOT_FOUND               138\n# define CMS_R_SIGNFINAL_ERROR                            139\n# define CMS_R_SMIME_TEXT_ERROR                           140\n# define CMS_R_STORE_INIT_ERROR                           141\n# define CMS_R_TYPE_NOT_COMPRESSED_DATA                   142\n# define CMS_R_TYPE_NOT_DATA                              143\n# define CMS_R_TYPE_NOT_DIGESTED_DATA                     144\n# define CMS_R_TYPE_NOT_ENCRYPTED_DATA                    145\n# define CMS_R_TYPE_NOT_ENVELOPED_DATA                    146\n# define CMS_R_UNABLE_TO_FINALIZE_CONTEXT                 147\n# define CMS_R_UNKNOWN_CIPHER                             148\n# define CMS_R_UNKNOWN_DIGEST_ALGORIHM                    149\n# define CMS_R_UNKNOWN_ID                                 150\n# define CMS_R_UNSUPPORTED_COMPRESSION_ALGORITHM          151\n# define CMS_R_UNSUPPORTED_CONTENT_TYPE                   152\n# define CMS_R_UNSUPPORTED_KEK_ALGORITHM                  153\n# define CMS_R_UNSUPPORTED_KEY_ENCRYPTION_ALGORITHM       179\n# define CMS_R_UNSUPPORTED_RECIPIENT_TYPE                 154\n# define CMS_R_UNSUPPORTED_RECPIENTINFO_TYPE              155\n# define CMS_R_UNSUPPORTED_TYPE                           156\n# define CMS_R_UNWRAP_ERROR                               157\n# define CMS_R_UNWRAP_FAILURE                             180\n# define CMS_R_VERIFICATION_FAILURE                       158\n# define CMS_R_WRAP_ERROR                                 159\n\n#ifdef  __cplusplus\n}\n#endif\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/x86_64/include/openssl/conf.h",
    "content": "/* crypto/conf/conf.h */\n/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)\n * All rights reserved.\n *\n * This package is an SSL implementation written\n * by Eric Young (eay@cryptsoft.com).\n * The implementation was written so as to conform with Netscapes SSL.\n *\n * This library is free for commercial and non-commercial use as long as\n * the following conditions are aheared to.  The following conditions\n * apply to all code found in this distribution, be it the RC4, RSA,\n * lhash, DES, etc., code; not just the SSL code.  The SSL documentation\n * included with this distribution is covered by the same copyright terms\n * except that the holder is Tim Hudson (tjh@cryptsoft.com).\n *\n * Copyright remains Eric Young's, and as such any Copyright notices in\n * the code are not to be removed.\n * If this package is used in a product, Eric Young should be given attribution\n * as the author of the parts of the library used.\n * This can be in the form of a textual message at program startup or\n * in documentation (online or textual) provided with the package.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the copyright\n *    notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in the\n *    documentation and/or other materials provided with the distribution.\n * 3. All advertising materials mentioning features or use of this software\n *    must display the following acknowledgement:\n *    \"This product includes cryptographic software written by\n *     Eric Young (eay@cryptsoft.com)\"\n *    The word 'cryptographic' can be left out if the rouines from the library\n *    being used are not cryptographic related :-).\n * 4. If you include any Windows specific code (or a derivative thereof) from\n *    the apps directory (application code) you must include an acknowledgement:\n *    \"This product includes software written by Tim Hudson (tjh@cryptsoft.com)\"\n *\n * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n * SUCH DAMAGE.\n *\n * The licence and distribution terms for any publically available version or\n * derivative of this code cannot be changed.  i.e. this code cannot simply be\n * copied and put under another distribution licence\n * [including the GNU Public Licence.]\n */\n\n#ifndef  HEADER_CONF_H\n# define HEADER_CONF_H\n\n# include <openssl/bio.h>\n# include <openssl/lhash.h>\n# include <openssl/stack.h>\n# include <openssl/safestack.h>\n# include <openssl/e_os2.h>\n\n# include <openssl/ossl_typ.h>\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\ntypedef struct {\n    char *section;\n    char *name;\n    char *value;\n} CONF_VALUE;\n\nDECLARE_STACK_OF(CONF_VALUE)\nDECLARE_LHASH_OF(CONF_VALUE);\n\nstruct conf_st;\nstruct conf_method_st;\ntypedef struct conf_method_st CONF_METHOD;\n\nstruct conf_method_st {\n    const char *name;\n    CONF *(*create) (CONF_METHOD *meth);\n    int (*init) (CONF *conf);\n    int (*destroy) (CONF *conf);\n    int (*destroy_data) (CONF *conf);\n    int (*load_bio) (CONF *conf, BIO *bp, long *eline);\n    int (*dump) (const CONF *conf, BIO *bp);\n    int (*is_number) (const CONF *conf, char c);\n    int (*to_int) (const CONF *conf, char c);\n    int (*load) (CONF *conf, const char *name, long *eline);\n};\n\n/* Module definitions */\n\ntypedef struct conf_imodule_st CONF_IMODULE;\ntypedef struct conf_module_st CONF_MODULE;\n\nDECLARE_STACK_OF(CONF_MODULE)\nDECLARE_STACK_OF(CONF_IMODULE)\n\n/* DSO module function typedefs */\ntypedef int conf_init_func (CONF_IMODULE *md, const CONF *cnf);\ntypedef void conf_finish_func (CONF_IMODULE *md);\n\n# define CONF_MFLAGS_IGNORE_ERRORS       0x1\n# define CONF_MFLAGS_IGNORE_RETURN_CODES 0x2\n# define CONF_MFLAGS_SILENT              0x4\n# define CONF_MFLAGS_NO_DSO              0x8\n# define CONF_MFLAGS_IGNORE_MISSING_FILE 0x10\n# define CONF_MFLAGS_DEFAULT_SECTION     0x20\n\nint CONF_set_default_method(CONF_METHOD *meth);\nvoid CONF_set_nconf(CONF *conf, LHASH_OF(CONF_VALUE) *hash);\nLHASH_OF(CONF_VALUE) *CONF_load(LHASH_OF(CONF_VALUE) *conf, const char *file,\n                                long *eline);\n# ifndef OPENSSL_NO_FP_API\nLHASH_OF(CONF_VALUE) *CONF_load_fp(LHASH_OF(CONF_VALUE) *conf, FILE *fp,\n                                   long *eline);\n# endif\nLHASH_OF(CONF_VALUE) *CONF_load_bio(LHASH_OF(CONF_VALUE) *conf, BIO *bp,\n                                    long *eline);\nSTACK_OF(CONF_VALUE) *CONF_get_section(LHASH_OF(CONF_VALUE) *conf,\n                                       const char *section);\nchar *CONF_get_string(LHASH_OF(CONF_VALUE) *conf, const char *group,\n                      const char *name);\nlong CONF_get_number(LHASH_OF(CONF_VALUE) *conf, const char *group,\n                     const char *name);\nvoid CONF_free(LHASH_OF(CONF_VALUE) *conf);\nint CONF_dump_fp(LHASH_OF(CONF_VALUE) *conf, FILE *out);\nint CONF_dump_bio(LHASH_OF(CONF_VALUE) *conf, BIO *out);\n\nvoid OPENSSL_config(const char *config_name);\nvoid OPENSSL_no_config(void);\n\n/*\n * New conf code.  The semantics are different from the functions above. If\n * that wasn't the case, the above functions would have been replaced\n */\n\nstruct conf_st {\n    CONF_METHOD *meth;\n    void *meth_data;\n    LHASH_OF(CONF_VALUE) *data;\n};\n\nCONF *NCONF_new(CONF_METHOD *meth);\nCONF_METHOD *NCONF_default(void);\nCONF_METHOD *NCONF_WIN32(void);\n# if 0                          /* Just to give you an idea of what I have in\n                                 * mind */\nCONF_METHOD *NCONF_XML(void);\n# endif\nvoid NCONF_free(CONF *conf);\nvoid NCONF_free_data(CONF *conf);\n\nint NCONF_load(CONF *conf, const char *file, long *eline);\n# ifndef OPENSSL_NO_FP_API\nint NCONF_load_fp(CONF *conf, FILE *fp, long *eline);\n# endif\nint NCONF_load_bio(CONF *conf, BIO *bp, long *eline);\nSTACK_OF(CONF_VALUE) *NCONF_get_section(const CONF *conf,\n                                        const char *section);\nchar *NCONF_get_string(const CONF *conf, const char *group, const char *name);\nint NCONF_get_number_e(const CONF *conf, const char *group, const char *name,\n                       long *result);\nint NCONF_dump_fp(const CONF *conf, FILE *out);\nint NCONF_dump_bio(const CONF *conf, BIO *out);\n\n# if 0                          /* The following function has no error\n                                 * checking, and should therefore be avoided */\nlong NCONF_get_number(CONF *conf, char *group, char *name);\n# else\n#  define NCONF_get_number(c,g,n,r) NCONF_get_number_e(c,g,n,r)\n# endif\n\n/* Module functions */\n\nint CONF_modules_load(const CONF *cnf, const char *appname,\n                      unsigned long flags);\nint CONF_modules_load_file(const char *filename, const char *appname,\n                           unsigned long flags);\nvoid CONF_modules_unload(int all);\nvoid CONF_modules_finish(void);\nvoid CONF_modules_free(void);\nint CONF_module_add(const char *name, conf_init_func *ifunc,\n                    conf_finish_func *ffunc);\n\nconst char *CONF_imodule_get_name(const CONF_IMODULE *md);\nconst char *CONF_imodule_get_value(const CONF_IMODULE *md);\nvoid *CONF_imodule_get_usr_data(const CONF_IMODULE *md);\nvoid CONF_imodule_set_usr_data(CONF_IMODULE *md, void *usr_data);\nCONF_MODULE *CONF_imodule_get_module(const CONF_IMODULE *md);\nunsigned long CONF_imodule_get_flags(const CONF_IMODULE *md);\nvoid CONF_imodule_set_flags(CONF_IMODULE *md, unsigned long flags);\nvoid *CONF_module_get_usr_data(CONF_MODULE *pmod);\nvoid CONF_module_set_usr_data(CONF_MODULE *pmod, void *usr_data);\n\nchar *CONF_get1_default_config_file(void);\n\nint CONF_parse_list(const char *list, int sep, int nospc,\n                    int (*list_cb) (const char *elem, int len, void *usr),\n                    void *arg);\n\nvoid OPENSSL_load_builtin_modules(void);\n\n/* BEGIN ERROR CODES */\n/*\n * The following lines are auto generated by the script mkerr.pl. Any changes\n * made after this point may be overwritten when the script is next run.\n */\nvoid ERR_load_CONF_strings(void);\n\n/* Error codes for the CONF functions. */\n\n/* Function codes. */\n# define CONF_F_CONF_DUMP_FP                              104\n# define CONF_F_CONF_LOAD                                 100\n# define CONF_F_CONF_LOAD_BIO                             102\n# define CONF_F_CONF_LOAD_FP                              103\n# define CONF_F_CONF_MODULES_LOAD                         116\n# define CONF_F_CONF_PARSE_LIST                           119\n# define CONF_F_DEF_LOAD                                  120\n# define CONF_F_DEF_LOAD_BIO                              121\n# define CONF_F_MODULE_INIT                               115\n# define CONF_F_MODULE_LOAD_DSO                           117\n# define CONF_F_MODULE_RUN                                118\n# define CONF_F_NCONF_DUMP_BIO                            105\n# define CONF_F_NCONF_DUMP_FP                             106\n# define CONF_F_NCONF_GET_NUMBER                          107\n# define CONF_F_NCONF_GET_NUMBER_E                        112\n# define CONF_F_NCONF_GET_SECTION                         108\n# define CONF_F_NCONF_GET_STRING                          109\n# define CONF_F_NCONF_LOAD                                113\n# define CONF_F_NCONF_LOAD_BIO                            110\n# define CONF_F_NCONF_LOAD_FP                             114\n# define CONF_F_NCONF_NEW                                 111\n# define CONF_F_STR_COPY                                  101\n\n/* Reason codes. */\n# define CONF_R_ERROR_LOADING_DSO                         110\n# define CONF_R_LIST_CANNOT_BE_NULL                       115\n# define CONF_R_MISSING_CLOSE_SQUARE_BRACKET              100\n# define CONF_R_MISSING_EQUAL_SIGN                        101\n# define CONF_R_MISSING_FINISH_FUNCTION                   111\n# define CONF_R_MISSING_INIT_FUNCTION                     112\n# define CONF_R_MODULE_INITIALIZATION_ERROR               109\n# define CONF_R_NO_CLOSE_BRACE                            102\n# define CONF_R_NO_CONF                                   105\n# define CONF_R_NO_CONF_OR_ENVIRONMENT_VARIABLE           106\n# define CONF_R_NO_SECTION                                107\n# define CONF_R_NO_SUCH_FILE                              114\n# define CONF_R_NO_VALUE                                  108\n# define CONF_R_UNABLE_TO_CREATE_NEW_SECTION              103\n# define CONF_R_UNKNOWN_MODULE_NAME                       113\n# define CONF_R_VARIABLE_HAS_NO_VALUE                     104\n\n#ifdef  __cplusplus\n}\n#endif\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/x86_64/include/openssl/conf_api.h",
    "content": "/* conf_api.h */\n/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)\n * All rights reserved.\n *\n * This package is an SSL implementation written\n * by Eric Young (eay@cryptsoft.com).\n * The implementation was written so as to conform with Netscapes SSL.\n *\n * This library is free for commercial and non-commercial use as long as\n * the following conditions are aheared to.  The following conditions\n * apply to all code found in this distribution, be it the RC4, RSA,\n * lhash, DES, etc., code; not just the SSL code.  The SSL documentation\n * included with this distribution is covered by the same copyright terms\n * except that the holder is Tim Hudson (tjh@cryptsoft.com).\n *\n * Copyright remains Eric Young's, and as such any Copyright notices in\n * the code are not to be removed.\n * If this package is used in a product, Eric Young should be given attribution\n * as the author of the parts of the library used.\n * This can be in the form of a textual message at program startup or\n * in documentation (online or textual) provided with the package.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the copyright\n *    notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in the\n *    documentation and/or other materials provided with the distribution.\n * 3. All advertising materials mentioning features or use of this software\n *    must display the following acknowledgement:\n *    \"This product includes cryptographic software written by\n *     Eric Young (eay@cryptsoft.com)\"\n *    The word 'cryptographic' can be left out if the rouines from the library\n *    being used are not cryptographic related :-).\n * 4. If you include any Windows specific code (or a derivative thereof) from\n *    the apps directory (application code) you must include an acknowledgement:\n *    \"This product includes software written by Tim Hudson (tjh@cryptsoft.com)\"\n *\n * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n * SUCH DAMAGE.\n *\n * The licence and distribution terms for any publically available version or\n * derivative of this code cannot be changed.  i.e. this code cannot simply be\n * copied and put under another distribution licence\n * [including the GNU Public Licence.]\n */\n\n#ifndef  HEADER_CONF_API_H\n# define HEADER_CONF_API_H\n\n# include <openssl/lhash.h>\n# include <openssl/conf.h>\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n/* Up until OpenSSL 0.9.5a, this was new_section */\nCONF_VALUE *_CONF_new_section(CONF *conf, const char *section);\n/* Up until OpenSSL 0.9.5a, this was get_section */\nCONF_VALUE *_CONF_get_section(const CONF *conf, const char *section);\n/* Up until OpenSSL 0.9.5a, this was CONF_get_section */\nSTACK_OF(CONF_VALUE) *_CONF_get_section_values(const CONF *conf,\n                                               const char *section);\n\nint _CONF_add_string(CONF *conf, CONF_VALUE *section, CONF_VALUE *value);\nchar *_CONF_get_string(const CONF *conf, const char *section,\n                       const char *name);\nlong _CONF_get_number(const CONF *conf, const char *section,\n                      const char *name);\n\nint _CONF_new_data(CONF *conf);\nvoid _CONF_free_data(CONF *conf);\n\n#ifdef  __cplusplus\n}\n#endif\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/x86_64/include/openssl/crypto.h",
    "content": "/* crypto/crypto.h */\n/* ====================================================================\n * Copyright (c) 1998-2006 The OpenSSL Project.  All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n *\n * 1. Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n *\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in\n *    the documentation and/or other materials provided with the\n *    distribution.\n *\n * 3. All advertising materials mentioning features or use of this\n *    software must display the following acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit. (http://www.openssl.org/)\"\n *\n * 4. The names \"OpenSSL Toolkit\" and \"OpenSSL Project\" must not be used to\n *    endorse or promote products derived from this software without\n *    prior written permission. For written permission, please contact\n *    openssl-core@openssl.org.\n *\n * 5. Products derived from this software may not be called \"OpenSSL\"\n *    nor may \"OpenSSL\" appear in their names without prior written\n *    permission of the OpenSSL Project.\n *\n * 6. Redistributions of any form whatsoever must retain the following\n *    acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit (http://www.openssl.org/)\"\n *\n * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY\n * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\n * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR\n * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\n * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,\n * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED\n * OF THE POSSIBILITY OF SUCH DAMAGE.\n * ====================================================================\n *\n * This product includes cryptographic software written by Eric Young\n * (eay@cryptsoft.com).  This product includes software written by Tim\n * Hudson (tjh@cryptsoft.com).\n *\n */\n/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)\n * All rights reserved.\n *\n * This package is an SSL implementation written\n * by Eric Young (eay@cryptsoft.com).\n * The implementation was written so as to conform with Netscapes SSL.\n *\n * This library is free for commercial and non-commercial use as long as\n * the following conditions are aheared to.  The following conditions\n * apply to all code found in this distribution, be it the RC4, RSA,\n * lhash, DES, etc., code; not just the SSL code.  The SSL documentation\n * included with this distribution is covered by the same copyright terms\n * except that the holder is Tim Hudson (tjh@cryptsoft.com).\n *\n * Copyright remains Eric Young's, and as such any Copyright notices in\n * the code are not to be removed.\n * If this package is used in a product, Eric Young should be given attribution\n * as the author of the parts of the library used.\n * This can be in the form of a textual message at program startup or\n * in documentation (online or textual) provided with the package.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the copyright\n *    notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in the\n *    documentation and/or other materials provided with the distribution.\n * 3. All advertising materials mentioning features or use of this software\n *    must display the following acknowledgement:\n *    \"This product includes cryptographic software written by\n *     Eric Young (eay@cryptsoft.com)\"\n *    The word 'cryptographic' can be left out if the rouines from the library\n *    being used are not cryptographic related :-).\n * 4. If you include any Windows specific code (or a derivative thereof) from\n *    the apps directory (application code) you must include an acknowledgement:\n *    \"This product includes software written by Tim Hudson (tjh@cryptsoft.com)\"\n *\n * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n * SUCH DAMAGE.\n *\n * The licence and distribution terms for any publically available version or\n * derivative of this code cannot be changed.  i.e. this code cannot simply be\n * copied and put under another distribution licence\n * [including the GNU Public Licence.]\n */\n/* ====================================================================\n * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED.\n * ECDH support in OpenSSL originally developed by\n * SUN MICROSYSTEMS, INC., and contributed to the OpenSSL project.\n */\n\n#ifndef HEADER_CRYPTO_H\n# define HEADER_CRYPTO_H\n\n# include <stdlib.h>\n\n# include <openssl/e_os2.h>\n\n# ifndef OPENSSL_NO_FP_API\n#  include <stdio.h>\n# endif\n\n# include <openssl/stack.h>\n# include <openssl/safestack.h>\n# include <openssl/opensslv.h>\n# include <openssl/ossl_typ.h>\n\n# ifdef CHARSET_EBCDIC\n#  include <openssl/ebcdic.h>\n# endif\n\n/*\n * Resolve problems on some operating systems with symbol names that clash\n * one way or another\n */\n# include <openssl/symhacks.h>\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n/* Backward compatibility to SSLeay */\n/*\n * This is more to be used to check the correct DLL is being used in the MS\n * world.\n */\n# define SSLEAY_VERSION_NUMBER   OPENSSL_VERSION_NUMBER\n# define SSLEAY_VERSION          0\n/* #define SSLEAY_OPTIONS       1 no longer supported */\n# define SSLEAY_CFLAGS           2\n# define SSLEAY_BUILT_ON         3\n# define SSLEAY_PLATFORM         4\n# define SSLEAY_DIR              5\n\n/* Already declared in ossl_typ.h */\n# if 0\ntypedef struct crypto_ex_data_st CRYPTO_EX_DATA;\n/* Called when a new object is created */\ntypedef int CRYPTO_EX_new (void *parent, void *ptr, CRYPTO_EX_DATA *ad,\n                           int idx, long argl, void *argp);\n/* Called when an object is free()ed */\ntypedef void CRYPTO_EX_free (void *parent, void *ptr, CRYPTO_EX_DATA *ad,\n                             int idx, long argl, void *argp);\n/* Called when we need to dup an object */\ntypedef int CRYPTO_EX_dup (CRYPTO_EX_DATA *to, CRYPTO_EX_DATA *from,\n                           void *from_d, int idx, long argl, void *argp);\n# endif\n\n/* A generic structure to pass assorted data in a expandable way */\ntypedef struct openssl_item_st {\n    int code;\n    void *value;                /* Not used for flag attributes */\n    size_t value_size;          /* Max size of value for output, length for\n                                 * input */\n    size_t *value_length;       /* Returned length of value for output */\n} OPENSSL_ITEM;\n\n/*\n * When changing the CRYPTO_LOCK_* list, be sure to maintin the text lock\n * names in cryptlib.c\n */\n\n# define CRYPTO_LOCK_ERR                 1\n# define CRYPTO_LOCK_EX_DATA             2\n# define CRYPTO_LOCK_X509                3\n# define CRYPTO_LOCK_X509_INFO           4\n# define CRYPTO_LOCK_X509_PKEY           5\n# define CRYPTO_LOCK_X509_CRL            6\n# define CRYPTO_LOCK_X509_REQ            7\n# define CRYPTO_LOCK_DSA                 8\n# define CRYPTO_LOCK_RSA                 9\n# define CRYPTO_LOCK_EVP_PKEY            10\n# define CRYPTO_LOCK_X509_STORE          11\n# define CRYPTO_LOCK_SSL_CTX             12\n# define CRYPTO_LOCK_SSL_CERT            13\n# define CRYPTO_LOCK_SSL_SESSION         14\n# define CRYPTO_LOCK_SSL_SESS_CERT       15\n# define CRYPTO_LOCK_SSL                 16\n# define CRYPTO_LOCK_SSL_METHOD          17\n# define CRYPTO_LOCK_RAND                18\n# define CRYPTO_LOCK_RAND2               19\n# define CRYPTO_LOCK_MALLOC              20\n# define CRYPTO_LOCK_BIO                 21\n# define CRYPTO_LOCK_GETHOSTBYNAME       22\n# define CRYPTO_LOCK_GETSERVBYNAME       23\n# define CRYPTO_LOCK_READDIR             24\n# define CRYPTO_LOCK_RSA_BLINDING        25\n# define CRYPTO_LOCK_DH                  26\n# define CRYPTO_LOCK_MALLOC2             27\n# define CRYPTO_LOCK_DSO                 28\n# define CRYPTO_LOCK_DYNLOCK             29\n# define CRYPTO_LOCK_ENGINE              30\n# define CRYPTO_LOCK_UI                  31\n# define CRYPTO_LOCK_ECDSA               32\n# define CRYPTO_LOCK_EC                  33\n# define CRYPTO_LOCK_ECDH                34\n# define CRYPTO_LOCK_BN                  35\n# define CRYPTO_LOCK_EC_PRE_COMP         36\n# define CRYPTO_LOCK_STORE               37\n# define CRYPTO_LOCK_COMP                38\n# define CRYPTO_LOCK_FIPS                39\n# define CRYPTO_LOCK_FIPS2               40\n# define CRYPTO_NUM_LOCKS                41\n\n# define CRYPTO_LOCK             1\n# define CRYPTO_UNLOCK           2\n# define CRYPTO_READ             4\n# define CRYPTO_WRITE            8\n\n# ifndef OPENSSL_NO_LOCKING\n#  ifndef CRYPTO_w_lock\n#   define CRYPTO_w_lock(type)     \\\n        CRYPTO_lock(CRYPTO_LOCK|CRYPTO_WRITE,type,__FILE__,__LINE__)\n#   define CRYPTO_w_unlock(type)   \\\n        CRYPTO_lock(CRYPTO_UNLOCK|CRYPTO_WRITE,type,__FILE__,__LINE__)\n#   define CRYPTO_r_lock(type)     \\\n        CRYPTO_lock(CRYPTO_LOCK|CRYPTO_READ,type,__FILE__,__LINE__)\n#   define CRYPTO_r_unlock(type)   \\\n        CRYPTO_lock(CRYPTO_UNLOCK|CRYPTO_READ,type,__FILE__,__LINE__)\n#   define CRYPTO_add(addr,amount,type)    \\\n        CRYPTO_add_lock(addr,amount,type,__FILE__,__LINE__)\n#  endif\n# else\n#  define CRYPTO_w_lock(a)\n#  define CRYPTO_w_unlock(a)\n#  define CRYPTO_r_lock(a)\n#  define CRYPTO_r_unlock(a)\n#  define CRYPTO_add(a,b,c)       ((*(a))+=(b))\n# endif\n\n/*\n * Some applications as well as some parts of OpenSSL need to allocate and\n * deallocate locks in a dynamic fashion.  The following typedef makes this\n * possible in a type-safe manner.\n */\n/* struct CRYPTO_dynlock_value has to be defined by the application. */\ntypedef struct {\n    int references;\n    struct CRYPTO_dynlock_value *data;\n} CRYPTO_dynlock;\n\n/*\n * The following can be used to detect memory leaks in the SSLeay library. It\n * used, it turns on malloc checking\n */\n\n# define CRYPTO_MEM_CHECK_OFF    0x0/* an enume */\n# define CRYPTO_MEM_CHECK_ON     0x1/* a bit */\n# define CRYPTO_MEM_CHECK_ENABLE 0x2/* a bit */\n# define CRYPTO_MEM_CHECK_DISABLE 0x3/* an enume */\n\n/*\n * The following are bit values to turn on or off options connected to the\n * malloc checking functionality\n */\n\n/* Adds time to the memory checking information */\n# define V_CRYPTO_MDEBUG_TIME    0x1/* a bit */\n/* Adds thread number to the memory checking information */\n# define V_CRYPTO_MDEBUG_THREAD  0x2/* a bit */\n\n# define V_CRYPTO_MDEBUG_ALL (V_CRYPTO_MDEBUG_TIME | V_CRYPTO_MDEBUG_THREAD)\n\n/* predec of the BIO type */\ntypedef struct bio_st BIO_dummy;\n\nstruct crypto_ex_data_st {\n    STACK_OF(void) *sk;\n    /* gcc is screwing up this data structure :-( */\n    int dummy;\n};\nDECLARE_STACK_OF(void)\n\n/*\n * This stuff is basically class callback functions The current classes are\n * SSL_CTX, SSL, SSL_SESSION, and a few more\n */\n\ntypedef struct crypto_ex_data_func_st {\n    long argl;                  /* Arbitary long */\n    void *argp;                 /* Arbitary void * */\n    CRYPTO_EX_new *new_func;\n    CRYPTO_EX_free *free_func;\n    CRYPTO_EX_dup *dup_func;\n} CRYPTO_EX_DATA_FUNCS;\n\nDECLARE_STACK_OF(CRYPTO_EX_DATA_FUNCS)\n\n/*\n * Per class, we have a STACK of CRYPTO_EX_DATA_FUNCS for each CRYPTO_EX_DATA\n * entry.\n */\n\n# define CRYPTO_EX_INDEX_BIO             0\n# define CRYPTO_EX_INDEX_SSL             1\n# define CRYPTO_EX_INDEX_SSL_CTX         2\n# define CRYPTO_EX_INDEX_SSL_SESSION     3\n# define CRYPTO_EX_INDEX_X509_STORE      4\n# define CRYPTO_EX_INDEX_X509_STORE_CTX  5\n# define CRYPTO_EX_INDEX_RSA             6\n# define CRYPTO_EX_INDEX_DSA             7\n# define CRYPTO_EX_INDEX_DH              8\n# define CRYPTO_EX_INDEX_ENGINE          9\n# define CRYPTO_EX_INDEX_X509            10\n# define CRYPTO_EX_INDEX_UI              11\n# define CRYPTO_EX_INDEX_ECDSA           12\n# define CRYPTO_EX_INDEX_ECDH            13\n# define CRYPTO_EX_INDEX_COMP            14\n# define CRYPTO_EX_INDEX_STORE           15\n\n/*\n * Dynamically assigned indexes start from this value (don't use directly,\n * use via CRYPTO_ex_data_new_class).\n */\n# define CRYPTO_EX_INDEX_USER            100\n\n/*\n * This is the default callbacks, but we can have others as well: this is\n * needed in Win32 where the application malloc and the library malloc may\n * not be the same.\n */\n# define CRYPTO_malloc_init()    CRYPTO_set_mem_functions(\\\n        malloc, realloc, free)\n\n# if defined CRYPTO_MDEBUG_ALL || defined CRYPTO_MDEBUG_TIME || defined CRYPTO_MDEBUG_THREAD\n#  ifndef CRYPTO_MDEBUG         /* avoid duplicate #define */\n#   define CRYPTO_MDEBUG\n#  endif\n# endif\n\n/*\n * Set standard debugging functions (not done by default unless CRYPTO_MDEBUG\n * is defined)\n */\n# define CRYPTO_malloc_debug_init()      do {\\\n        CRYPTO_set_mem_debug_functions(\\\n                CRYPTO_dbg_malloc,\\\n                CRYPTO_dbg_realloc,\\\n                CRYPTO_dbg_free,\\\n                CRYPTO_dbg_set_options,\\\n                CRYPTO_dbg_get_options);\\\n        } while(0)\n\nint CRYPTO_mem_ctrl(int mode);\nint CRYPTO_is_mem_check_on(void);\n\n/* for applications */\n# define MemCheck_start() CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON)\n# define MemCheck_stop() CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_OFF)\n\n/* for library-internal use */\n# define MemCheck_on()   CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ENABLE)\n# define MemCheck_off()  CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_DISABLE)\n# define is_MemCheck_on() CRYPTO_is_mem_check_on()\n\n# define OPENSSL_malloc(num)     CRYPTO_malloc((int)num,__FILE__,__LINE__)\n# define OPENSSL_strdup(str)     CRYPTO_strdup((str),__FILE__,__LINE__)\n# define OPENSSL_realloc(addr,num) \\\n        CRYPTO_realloc((char *)addr,(int)num,__FILE__,__LINE__)\n# define OPENSSL_realloc_clean(addr,old_num,num) \\\n        CRYPTO_realloc_clean(addr,old_num,num,__FILE__,__LINE__)\n# define OPENSSL_remalloc(addr,num) \\\n        CRYPTO_remalloc((char **)addr,(int)num,__FILE__,__LINE__)\n# define OPENSSL_freeFunc        CRYPTO_free\n# define OPENSSL_free(addr)      CRYPTO_free(addr)\n\n# define OPENSSL_malloc_locked(num) \\\n        CRYPTO_malloc_locked((int)num,__FILE__,__LINE__)\n# define OPENSSL_free_locked(addr) CRYPTO_free_locked(addr)\n\nconst char *SSLeay_version(int type);\nunsigned long SSLeay(void);\n\nint OPENSSL_issetugid(void);\n\n/* An opaque type representing an implementation of \"ex_data\" support */\ntypedef struct st_CRYPTO_EX_DATA_IMPL CRYPTO_EX_DATA_IMPL;\n/* Return an opaque pointer to the current \"ex_data\" implementation */\nconst CRYPTO_EX_DATA_IMPL *CRYPTO_get_ex_data_implementation(void);\n/* Sets the \"ex_data\" implementation to be used (if it's not too late) */\nint CRYPTO_set_ex_data_implementation(const CRYPTO_EX_DATA_IMPL *i);\n/* Get a new \"ex_data\" class, and return the corresponding \"class_index\" */\nint CRYPTO_ex_data_new_class(void);\n/* Within a given class, get/register a new index */\nint CRYPTO_get_ex_new_index(int class_index, long argl, void *argp,\n                            CRYPTO_EX_new *new_func, CRYPTO_EX_dup *dup_func,\n                            CRYPTO_EX_free *free_func);\n/*\n * Initialise/duplicate/free CRYPTO_EX_DATA variables corresponding to a\n * given class (invokes whatever per-class callbacks are applicable)\n */\nint CRYPTO_new_ex_data(int class_index, void *obj, CRYPTO_EX_DATA *ad);\nint CRYPTO_dup_ex_data(int class_index, CRYPTO_EX_DATA *to,\n                       CRYPTO_EX_DATA *from);\nvoid CRYPTO_free_ex_data(int class_index, void *obj, CRYPTO_EX_DATA *ad);\n/*\n * Get/set data in a CRYPTO_EX_DATA variable corresponding to a particular\n * index (relative to the class type involved)\n */\nint CRYPTO_set_ex_data(CRYPTO_EX_DATA *ad, int idx, void *val);\nvoid *CRYPTO_get_ex_data(const CRYPTO_EX_DATA *ad, int idx);\n/*\n * This function cleans up all \"ex_data\" state. It mustn't be called under\n * potential race-conditions.\n */\nvoid CRYPTO_cleanup_all_ex_data(void);\n\nint CRYPTO_get_new_lockid(char *name);\n\nint CRYPTO_num_locks(void);     /* return CRYPTO_NUM_LOCKS (shared libs!) */\nvoid CRYPTO_lock(int mode, int type, const char *file, int line);\nvoid CRYPTO_set_locking_callback(void (*func) (int mode, int type,\n                                               const char *file, int line));\nvoid (*CRYPTO_get_locking_callback(void)) (int mode, int type,\n                                           const char *file, int line);\nvoid CRYPTO_set_add_lock_callback(int (*func)\n                                   (int *num, int mount, int type,\n                                    const char *file, int line));\nint (*CRYPTO_get_add_lock_callback(void)) (int *num, int mount, int type,\n                                           const char *file, int line);\n\n/* Don't use this structure directly. */\ntypedef struct crypto_threadid_st {\n    void *ptr;\n    unsigned long val;\n} CRYPTO_THREADID;\n/* Only use CRYPTO_THREADID_set_[numeric|pointer]() within callbacks */\nvoid CRYPTO_THREADID_set_numeric(CRYPTO_THREADID *id, unsigned long val);\nvoid CRYPTO_THREADID_set_pointer(CRYPTO_THREADID *id, void *ptr);\nint CRYPTO_THREADID_set_callback(void (*threadid_func) (CRYPTO_THREADID *));\nvoid (*CRYPTO_THREADID_get_callback(void)) (CRYPTO_THREADID *);\nvoid CRYPTO_THREADID_current(CRYPTO_THREADID *id);\nint CRYPTO_THREADID_cmp(const CRYPTO_THREADID *a, const CRYPTO_THREADID *b);\nvoid CRYPTO_THREADID_cpy(CRYPTO_THREADID *dest, const CRYPTO_THREADID *src);\nunsigned long CRYPTO_THREADID_hash(const CRYPTO_THREADID *id);\n# ifndef OPENSSL_NO_DEPRECATED\nvoid CRYPTO_set_id_callback(unsigned long (*func) (void));\nunsigned long (*CRYPTO_get_id_callback(void)) (void);\nunsigned long CRYPTO_thread_id(void);\n# endif\n\nconst char *CRYPTO_get_lock_name(int type);\nint CRYPTO_add_lock(int *pointer, int amount, int type, const char *file,\n                    int line);\n\nint CRYPTO_get_new_dynlockid(void);\nvoid CRYPTO_destroy_dynlockid(int i);\nstruct CRYPTO_dynlock_value *CRYPTO_get_dynlock_value(int i);\nvoid CRYPTO_set_dynlock_create_callback(struct CRYPTO_dynlock_value\n                                        *(*dyn_create_function) (const char\n                                                                 *file,\n                                                                 int line));\nvoid CRYPTO_set_dynlock_lock_callback(void (*dyn_lock_function)\n                                       (int mode,\n                                        struct CRYPTO_dynlock_value *l,\n                                        const char *file, int line));\nvoid CRYPTO_set_dynlock_destroy_callback(void (*dyn_destroy_function)\n                                          (struct CRYPTO_dynlock_value *l,\n                                           const char *file, int line));\nstruct CRYPTO_dynlock_value\n*(*CRYPTO_get_dynlock_create_callback(void)) (const char *file, int line);\nvoid (*CRYPTO_get_dynlock_lock_callback(void)) (int mode,\n                                                struct CRYPTO_dynlock_value\n                                                *l, const char *file,\n                                                int line);\nvoid (*CRYPTO_get_dynlock_destroy_callback(void)) (struct CRYPTO_dynlock_value\n                                                   *l, const char *file,\n                                                   int line);\n\n/*\n * CRYPTO_set_mem_functions includes CRYPTO_set_locked_mem_functions -- call\n * the latter last if you need different functions\n */\nint CRYPTO_set_mem_functions(void *(*m) (size_t), void *(*r) (void *, size_t),\n                             void (*f) (void *));\nint CRYPTO_set_locked_mem_functions(void *(*m) (size_t),\n                                    void (*free_func) (void *));\nint CRYPTO_set_mem_ex_functions(void *(*m) (size_t, const char *, int),\n                                void *(*r) (void *, size_t, const char *,\n                                            int), void (*f) (void *));\nint CRYPTO_set_locked_mem_ex_functions(void *(*m) (size_t, const char *, int),\n                                       void (*free_func) (void *));\nint CRYPTO_set_mem_debug_functions(void (*m)\n                                    (void *, int, const char *, int, int),\n                                   void (*r) (void *, void *, int,\n                                              const char *, int, int),\n                                   void (*f) (void *, int), void (*so) (long),\n                                   long (*go) (void));\nvoid CRYPTO_get_mem_functions(void *(**m) (size_t),\n                              void *(**r) (void *, size_t),\n                              void (**f) (void *));\nvoid CRYPTO_get_locked_mem_functions(void *(**m) (size_t),\n                                     void (**f) (void *));\nvoid CRYPTO_get_mem_ex_functions(void *(**m) (size_t, const char *, int),\n                                 void *(**r) (void *, size_t, const char *,\n                                              int), void (**f) (void *));\nvoid CRYPTO_get_locked_mem_ex_functions(void\n                                        *(**m) (size_t, const char *, int),\n                                        void (**f) (void *));\nvoid CRYPTO_get_mem_debug_functions(void (**m)\n                                     (void *, int, const char *, int, int),\n                                    void (**r) (void *, void *, int,\n                                                const char *, int, int),\n                                    void (**f) (void *, int),\n                                    void (**so) (long), long (**go) (void));\n\nvoid *CRYPTO_malloc_locked(int num, const char *file, int line);\nvoid CRYPTO_free_locked(void *ptr);\nvoid *CRYPTO_malloc(int num, const char *file, int line);\nchar *CRYPTO_strdup(const char *str, const char *file, int line);\nvoid CRYPTO_free(void *ptr);\nvoid *CRYPTO_realloc(void *addr, int num, const char *file, int line);\nvoid *CRYPTO_realloc_clean(void *addr, int old_num, int num, const char *file,\n                           int line);\nvoid *CRYPTO_remalloc(void *addr, int num, const char *file, int line);\n\nvoid OPENSSL_cleanse(void *ptr, size_t len);\n\nvoid CRYPTO_set_mem_debug_options(long bits);\nlong CRYPTO_get_mem_debug_options(void);\n\n# define CRYPTO_push_info(info) \\\n        CRYPTO_push_info_(info, __FILE__, __LINE__);\nint CRYPTO_push_info_(const char *info, const char *file, int line);\nint CRYPTO_pop_info(void);\nint CRYPTO_remove_all_info(void);\n\n/*\n * Default debugging functions (enabled by CRYPTO_malloc_debug_init() macro;\n * used as default in CRYPTO_MDEBUG compilations):\n */\n/*-\n * The last argument has the following significance:\n *\n * 0:   called before the actual memory allocation has taken place\n * 1:   called after the actual memory allocation has taken place\n */\nvoid CRYPTO_dbg_malloc(void *addr, int num, const char *file, int line,\n                       int before_p);\nvoid CRYPTO_dbg_realloc(void *addr1, void *addr2, int num, const char *file,\n                        int line, int before_p);\nvoid CRYPTO_dbg_free(void *addr, int before_p);\n/*-\n * Tell the debugging code about options.  By default, the following values\n * apply:\n *\n * 0:                           Clear all options.\n * V_CRYPTO_MDEBUG_TIME (1):    Set the \"Show Time\" option.\n * V_CRYPTO_MDEBUG_THREAD (2):  Set the \"Show Thread Number\" option.\n * V_CRYPTO_MDEBUG_ALL (3):     1 + 2\n */\nvoid CRYPTO_dbg_set_options(long bits);\nlong CRYPTO_dbg_get_options(void);\n\n# ifndef OPENSSL_NO_FP_API\nvoid CRYPTO_mem_leaks_fp(FILE *);\n# endif\nvoid CRYPTO_mem_leaks(struct bio_st *bio);\n/* unsigned long order, char *file, int line, int num_bytes, char *addr */\ntypedef void *CRYPTO_MEM_LEAK_CB (unsigned long, const char *, int, int,\n                                  void *);\nvoid CRYPTO_mem_leaks_cb(CRYPTO_MEM_LEAK_CB *cb);\n\n/* die if we have to */\nvoid OpenSSLDie(const char *file, int line, const char *assertion);\n# define OPENSSL_assert(e)       (void)((e) ? 0 : (OpenSSLDie(__FILE__, __LINE__, #e),1))\n\nunsigned long *OPENSSL_ia32cap_loc(void);\n# define OPENSSL_ia32cap (*(OPENSSL_ia32cap_loc()))\nint OPENSSL_isservice(void);\n\nint FIPS_mode(void);\nint FIPS_mode_set(int r);\n\nvoid OPENSSL_init(void);\n\n# define fips_md_init(alg) fips_md_init_ctx(alg, alg)\n\n# ifdef OPENSSL_FIPS\n#  define fips_md_init_ctx(alg, cx) \\\n        int alg##_Init(cx##_CTX *c) \\\n        { \\\n        if (FIPS_mode()) OpenSSLDie(__FILE__, __LINE__, \\\n                \"Low level API call to digest \" #alg \" forbidden in FIPS mode!\"); \\\n        return private_##alg##_Init(c); \\\n        } \\\n        int private_##alg##_Init(cx##_CTX *c)\n\n#  define fips_cipher_abort(alg) \\\n        if (FIPS_mode()) OpenSSLDie(__FILE__, __LINE__, \\\n                \"Low level API call to cipher \" #alg \" forbidden in FIPS mode!\")\n\n# else\n#  define fips_md_init_ctx(alg, cx) \\\n        int alg##_Init(cx##_CTX *c)\n#  define fips_cipher_abort(alg) while(0)\n# endif\n\n/*\n * CRYPTO_memcmp returns zero iff the |len| bytes at |a| and |b| are equal.\n * It takes an amount of time dependent on |len|, but independent of the\n * contents of |a| and |b|. Unlike memcmp, it cannot be used to put elements\n * into a defined order as the return value when a != b is undefined, other\n * than to be non-zero.\n */\nint CRYPTO_memcmp(const volatile void *a, const volatile void *b, size_t len);\n\n/* BEGIN ERROR CODES */\n/*\n * The following lines are auto generated by the script mkerr.pl. Any changes\n * made after this point may be overwritten when the script is next run.\n */\nvoid ERR_load_CRYPTO_strings(void);\n\n/* Error codes for the CRYPTO functions. */\n\n/* Function codes. */\n# define CRYPTO_F_CRYPTO_GET_EX_NEW_INDEX                 100\n# define CRYPTO_F_CRYPTO_GET_NEW_DYNLOCKID                103\n# define CRYPTO_F_CRYPTO_GET_NEW_LOCKID                   101\n# define CRYPTO_F_CRYPTO_SET_EX_DATA                      102\n# define CRYPTO_F_DEF_ADD_INDEX                           104\n# define CRYPTO_F_DEF_GET_CLASS                           105\n# define CRYPTO_F_FIPS_MODE_SET                           109\n# define CRYPTO_F_INT_DUP_EX_DATA                         106\n# define CRYPTO_F_INT_FREE_EX_DATA                        107\n# define CRYPTO_F_INT_NEW_EX_DATA                         108\n\n/* Reason codes. */\n# define CRYPTO_R_FIPS_MODE_NOT_SUPPORTED                 101\n# define CRYPTO_R_NO_DYNLOCK_CREATE_CALLBACK              100\n\n#ifdef  __cplusplus\n}\n#endif\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/x86_64/include/openssl/des.h",
    "content": "/* crypto/des/des.h */\n/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)\n * All rights reserved.\n *\n * This package is an SSL implementation written\n * by Eric Young (eay@cryptsoft.com).\n * The implementation was written so as to conform with Netscapes SSL.\n *\n * This library is free for commercial and non-commercial use as long as\n * the following conditions are aheared to.  The following conditions\n * apply to all code found in this distribution, be it the RC4, RSA,\n * lhash, DES, etc., code; not just the SSL code.  The SSL documentation\n * included with this distribution is covered by the same copyright terms\n * except that the holder is Tim Hudson (tjh@cryptsoft.com).\n *\n * Copyright remains Eric Young's, and as such any Copyright notices in\n * the code are not to be removed.\n * If this package is used in a product, Eric Young should be given attribution\n * as the author of the parts of the library used.\n * This can be in the form of a textual message at program startup or\n * in documentation (online or textual) provided with the package.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the copyright\n *    notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in the\n *    documentation and/or other materials provided with the distribution.\n * 3. All advertising materials mentioning features or use of this software\n *    must display the following acknowledgement:\n *    \"This product includes cryptographic software written by\n *     Eric Young (eay@cryptsoft.com)\"\n *    The word 'cryptographic' can be left out if the rouines from the library\n *    being used are not cryptographic related :-).\n * 4. If you include any Windows specific code (or a derivative thereof) from\n *    the apps directory (application code) you must include an acknowledgement:\n *    \"This product includes software written by Tim Hudson (tjh@cryptsoft.com)\"\n *\n * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n * SUCH DAMAGE.\n *\n * The licence and distribution terms for any publically available version or\n * derivative of this code cannot be changed.  i.e. this code cannot simply be\n * copied and put under another distribution licence\n * [including the GNU Public Licence.]\n */\n\n#ifndef HEADER_NEW_DES_H\n# define HEADER_NEW_DES_H\n\n# include <openssl/e_os2.h>     /* OPENSSL_EXTERN, OPENSSL_NO_DES, DES_LONG\n                                 * (via openssl/opensslconf.h */\n\n# ifdef OPENSSL_NO_DES\n#  error DES is disabled.\n# endif\n\n# ifdef OPENSSL_BUILD_SHLIBCRYPTO\n#  undef OPENSSL_EXTERN\n#  define OPENSSL_EXTERN OPENSSL_EXPORT\n# endif\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\ntypedef unsigned char DES_cblock[8];\ntypedef /* const */ unsigned char const_DES_cblock[8];\n/*\n * With \"const\", gcc 2.8.1 on Solaris thinks that DES_cblock * and\n * const_DES_cblock * are incompatible pointer types.\n */\n\ntypedef struct DES_ks {\n    union {\n        DES_cblock cblock;\n        /*\n         * make sure things are correct size on machines with 8 byte longs\n         */\n        DES_LONG deslong[2];\n    } ks[16];\n} DES_key_schedule;\n\n# ifndef OPENSSL_DISABLE_OLD_DES_SUPPORT\n#  ifndef OPENSSL_ENABLE_OLD_DES_SUPPORT\n#   define OPENSSL_ENABLE_OLD_DES_SUPPORT\n#  endif\n# endif\n\n# ifdef OPENSSL_ENABLE_OLD_DES_SUPPORT\n#  include <openssl/des_old.h>\n# endif\n\n# define DES_KEY_SZ      (sizeof(DES_cblock))\n# define DES_SCHEDULE_SZ (sizeof(DES_key_schedule))\n\n# define DES_ENCRYPT     1\n# define DES_DECRYPT     0\n\n# define DES_CBC_MODE    0\n# define DES_PCBC_MODE   1\n\n# define DES_ecb2_encrypt(i,o,k1,k2,e) \\\n        DES_ecb3_encrypt((i),(o),(k1),(k2),(k1),(e))\n\n# define DES_ede2_cbc_encrypt(i,o,l,k1,k2,iv,e) \\\n        DES_ede3_cbc_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(e))\n\n# define DES_ede2_cfb64_encrypt(i,o,l,k1,k2,iv,n,e) \\\n        DES_ede3_cfb64_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(n),(e))\n\n# define DES_ede2_ofb64_encrypt(i,o,l,k1,k2,iv,n) \\\n        DES_ede3_ofb64_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(n))\n\nOPENSSL_DECLARE_GLOBAL(int, DES_check_key); /* defaults to false */\n# define DES_check_key OPENSSL_GLOBAL_REF(DES_check_key)\nOPENSSL_DECLARE_GLOBAL(int, DES_rw_mode); /* defaults to DES_PCBC_MODE */\n# define DES_rw_mode OPENSSL_GLOBAL_REF(DES_rw_mode)\n\nconst char *DES_options(void);\nvoid DES_ecb3_encrypt(const_DES_cblock *input, DES_cblock *output,\n                      DES_key_schedule *ks1, DES_key_schedule *ks2,\n                      DES_key_schedule *ks3, int enc);\nDES_LONG DES_cbc_cksum(const unsigned char *input, DES_cblock *output,\n                       long length, DES_key_schedule *schedule,\n                       const_DES_cblock *ivec);\n/* DES_cbc_encrypt does not update the IV!  Use DES_ncbc_encrypt instead. */\nvoid DES_cbc_encrypt(const unsigned char *input, unsigned char *output,\n                     long length, DES_key_schedule *schedule,\n                     DES_cblock *ivec, int enc);\nvoid DES_ncbc_encrypt(const unsigned char *input, unsigned char *output,\n                      long length, DES_key_schedule *schedule,\n                      DES_cblock *ivec, int enc);\nvoid DES_xcbc_encrypt(const unsigned char *input, unsigned char *output,\n                      long length, DES_key_schedule *schedule,\n                      DES_cblock *ivec, const_DES_cblock *inw,\n                      const_DES_cblock *outw, int enc);\nvoid DES_cfb_encrypt(const unsigned char *in, unsigned char *out, int numbits,\n                     long length, DES_key_schedule *schedule,\n                     DES_cblock *ivec, int enc);\nvoid DES_ecb_encrypt(const_DES_cblock *input, DES_cblock *output,\n                     DES_key_schedule *ks, int enc);\n\n/*\n * This is the DES encryption function that gets called by just about every\n * other DES routine in the library.  You should not use this function except\n * to implement 'modes' of DES.  I say this because the functions that call\n * this routine do the conversion from 'char *' to long, and this needs to be\n * done to make sure 'non-aligned' memory access do not occur.  The\n * characters are loaded 'little endian'. Data is a pointer to 2 unsigned\n * long's and ks is the DES_key_schedule to use.  enc, is non zero specifies\n * encryption, zero if decryption.\n */\nvoid DES_encrypt1(DES_LONG *data, DES_key_schedule *ks, int enc);\n\n/*\n * This functions is the same as DES_encrypt1() except that the DES initial\n * permutation (IP) and final permutation (FP) have been left out.  As for\n * DES_encrypt1(), you should not use this function. It is used by the\n * routines in the library that implement triple DES. IP() DES_encrypt2()\n * DES_encrypt2() DES_encrypt2() FP() is the same as DES_encrypt1()\n * DES_encrypt1() DES_encrypt1() except faster :-).\n */\nvoid DES_encrypt2(DES_LONG *data, DES_key_schedule *ks, int enc);\n\nvoid DES_encrypt3(DES_LONG *data, DES_key_schedule *ks1,\n                  DES_key_schedule *ks2, DES_key_schedule *ks3);\nvoid DES_decrypt3(DES_LONG *data, DES_key_schedule *ks1,\n                  DES_key_schedule *ks2, DES_key_schedule *ks3);\nvoid DES_ede3_cbc_encrypt(const unsigned char *input, unsigned char *output,\n                          long length,\n                          DES_key_schedule *ks1, DES_key_schedule *ks2,\n                          DES_key_schedule *ks3, DES_cblock *ivec, int enc);\nvoid DES_ede3_cbcm_encrypt(const unsigned char *in, unsigned char *out,\n                           long length,\n                           DES_key_schedule *ks1, DES_key_schedule *ks2,\n                           DES_key_schedule *ks3,\n                           DES_cblock *ivec1, DES_cblock *ivec2, int enc);\nvoid DES_ede3_cfb64_encrypt(const unsigned char *in, unsigned char *out,\n                            long length, DES_key_schedule *ks1,\n                            DES_key_schedule *ks2, DES_key_schedule *ks3,\n                            DES_cblock *ivec, int *num, int enc);\nvoid DES_ede3_cfb_encrypt(const unsigned char *in, unsigned char *out,\n                          int numbits, long length, DES_key_schedule *ks1,\n                          DES_key_schedule *ks2, DES_key_schedule *ks3,\n                          DES_cblock *ivec, int enc);\nvoid DES_ede3_ofb64_encrypt(const unsigned char *in, unsigned char *out,\n                            long length, DES_key_schedule *ks1,\n                            DES_key_schedule *ks2, DES_key_schedule *ks3,\n                            DES_cblock *ivec, int *num);\n# if 0\nvoid DES_xwhite_in2out(const_DES_cblock *DES_key, const_DES_cblock *in_white,\n                       DES_cblock *out_white);\n# endif\n\nint DES_enc_read(int fd, void *buf, int len, DES_key_schedule *sched,\n                 DES_cblock *iv);\nint DES_enc_write(int fd, const void *buf, int len, DES_key_schedule *sched,\n                  DES_cblock *iv);\nchar *DES_fcrypt(const char *buf, const char *salt, char *ret);\nchar *DES_crypt(const char *buf, const char *salt);\nvoid DES_ofb_encrypt(const unsigned char *in, unsigned char *out, int numbits,\n                     long length, DES_key_schedule *schedule,\n                     DES_cblock *ivec);\nvoid DES_pcbc_encrypt(const unsigned char *input, unsigned char *output,\n                      long length, DES_key_schedule *schedule,\n                      DES_cblock *ivec, int enc);\nDES_LONG DES_quad_cksum(const unsigned char *input, DES_cblock output[],\n                        long length, int out_count, DES_cblock *seed);\nint DES_random_key(DES_cblock *ret);\nvoid DES_set_odd_parity(DES_cblock *key);\nint DES_check_key_parity(const_DES_cblock *key);\nint DES_is_weak_key(const_DES_cblock *key);\n/*\n * DES_set_key (= set_key = DES_key_sched = key_sched) calls\n * DES_set_key_checked if global variable DES_check_key is set,\n * DES_set_key_unchecked otherwise.\n */\nint DES_set_key(const_DES_cblock *key, DES_key_schedule *schedule);\nint DES_key_sched(const_DES_cblock *key, DES_key_schedule *schedule);\nint DES_set_key_checked(const_DES_cblock *key, DES_key_schedule *schedule);\nvoid DES_set_key_unchecked(const_DES_cblock *key, DES_key_schedule *schedule);\n# ifdef OPENSSL_FIPS\nvoid private_DES_set_key_unchecked(const_DES_cblock *key,\n                                   DES_key_schedule *schedule);\n# endif\nvoid DES_string_to_key(const char *str, DES_cblock *key);\nvoid DES_string_to_2keys(const char *str, DES_cblock *key1, DES_cblock *key2);\nvoid DES_cfb64_encrypt(const unsigned char *in, unsigned char *out,\n                       long length, DES_key_schedule *schedule,\n                       DES_cblock *ivec, int *num, int enc);\nvoid DES_ofb64_encrypt(const unsigned char *in, unsigned char *out,\n                       long length, DES_key_schedule *schedule,\n                       DES_cblock *ivec, int *num);\n\nint DES_read_password(DES_cblock *key, const char *prompt, int verify);\nint DES_read_2passwords(DES_cblock *key1, DES_cblock *key2,\n                        const char *prompt, int verify);\n\n# define DES_fixup_key_parity DES_set_odd_parity\n\n#ifdef  __cplusplus\n}\n#endif\n\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/x86_64/include/openssl/des_old.h",
    "content": "/* crypto/des/des_old.h */\n\n/*-\n * WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING\n *\n * The function names in here are deprecated and are only present to\n * provide an interface compatible with openssl 0.9.6 and older as\n * well as libdes.  OpenSSL now provides functions where \"des_\" has\n * been replaced with \"DES_\" in the names, to make it possible to\n * make incompatible changes that are needed for C type security and\n * other stuff.\n *\n * This include files has two compatibility modes:\n *\n *   - If OPENSSL_DES_LIBDES_COMPATIBILITY is defined, you get an API\n *     that is compatible with libdes and SSLeay.\n *   - If OPENSSL_DES_LIBDES_COMPATIBILITY isn't defined, you get an\n *     API that is compatible with OpenSSL 0.9.5x to 0.9.6x.\n *\n * Note that these modes break earlier snapshots of OpenSSL, where\n * libdes compatibility was the only available mode or (later on) the\n * prefered compatibility mode.  However, after much consideration\n * (and more or less violent discussions with external parties), it\n * was concluded that OpenSSL should be compatible with earlier versions\n * of itself before anything else.  Also, in all honesty, libdes is\n * an old beast that shouldn't really be used any more.\n *\n * Please consider starting to use the DES_ functions rather than the\n * des_ ones.  The des_ functions will disappear completely before\n * OpenSSL 1.0!\n *\n * WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING\n */\n\n/*\n * Written by Richard Levitte (richard@levitte.org) for the OpenSSL project\n * 2001.\n */\n/* ====================================================================\n * Copyright (c) 1998-2002 The OpenSSL Project.  All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n *\n * 1. Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n *\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in\n *    the documentation and/or other materials provided with the\n *    distribution.\n *\n * 3. All advertising materials mentioning features or use of this\n *    software must display the following acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit. (http://www.openssl.org/)\"\n *\n * 4. The names \"OpenSSL Toolkit\" and \"OpenSSL Project\" must not be used to\n *    endorse or promote products derived from this software without\n *    prior written permission. For written permission, please contact\n *    openssl-core@openssl.org.\n *\n * 5. Products derived from this software may not be called \"OpenSSL\"\n *    nor may \"OpenSSL\" appear in their names without prior written\n *    permission of the OpenSSL Project.\n *\n * 6. Redistributions of any form whatsoever must retain the following\n *    acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit (http://www.openssl.org/)\"\n *\n * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY\n * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\n * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR\n * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\n * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,\n * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED\n * OF THE POSSIBILITY OF SUCH DAMAGE.\n * ====================================================================\n *\n * This product includes cryptographic software written by Eric Young\n * (eay@cryptsoft.com).  This product includes software written by Tim\n * Hudson (tjh@cryptsoft.com).\n *\n */\n\n#ifndef HEADER_DES_H\n# define HEADER_DES_H\n\n# include <openssl/e_os2.h>     /* OPENSSL_EXTERN, OPENSSL_NO_DES, DES_LONG */\n\n# ifdef OPENSSL_NO_DES\n#  error DES is disabled.\n# endif\n\n# ifndef HEADER_NEW_DES_H\n#  error You must include des.h, not des_old.h directly.\n# endif\n\n# ifdef _KERBEROS_DES_H\n#  error <openssl/des_old.h> replaces <kerberos/des.h>.\n# endif\n\n# include <openssl/symhacks.h>\n\n# ifdef OPENSSL_BUILD_SHLIBCRYPTO\n#  undef OPENSSL_EXTERN\n#  define OPENSSL_EXTERN OPENSSL_EXPORT\n# endif\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n# ifdef _\n#  undef _\n# endif\n\ntypedef unsigned char _ossl_old_des_cblock[8];\ntypedef struct _ossl_old_des_ks_struct {\n    union {\n        _ossl_old_des_cblock _;\n        /*\n         * make sure things are correct size on machines with 8 byte longs\n         */\n        DES_LONG pad[2];\n    } ks;\n} _ossl_old_des_key_schedule[16];\n\n# ifndef OPENSSL_DES_LIBDES_COMPATIBILITY\n#  define des_cblock DES_cblock\n#  define const_des_cblock const_DES_cblock\n#  define des_key_schedule DES_key_schedule\n#  define des_ecb3_encrypt(i,o,k1,k2,k3,e)\\\n        DES_ecb3_encrypt((i),(o),&(k1),&(k2),&(k3),(e))\n#  define des_ede3_cbc_encrypt(i,o,l,k1,k2,k3,iv,e)\\\n        DES_ede3_cbc_encrypt((i),(o),(l),&(k1),&(k2),&(k3),(iv),(e))\n#  define des_ede3_cbcm_encrypt(i,o,l,k1,k2,k3,iv1,iv2,e)\\\n        DES_ede3_cbcm_encrypt((i),(o),(l),&(k1),&(k2),&(k3),(iv1),(iv2),(e))\n#  define des_ede3_cfb64_encrypt(i,o,l,k1,k2,k3,iv,n,e)\\\n        DES_ede3_cfb64_encrypt((i),(o),(l),&(k1),&(k2),&(k3),(iv),(n),(e))\n#  define des_ede3_ofb64_encrypt(i,o,l,k1,k2,k3,iv,n)\\\n        DES_ede3_ofb64_encrypt((i),(o),(l),&(k1),&(k2),&(k3),(iv),(n))\n#  define des_options()\\\n        DES_options()\n#  define des_cbc_cksum(i,o,l,k,iv)\\\n        DES_cbc_cksum((i),(o),(l),&(k),(iv))\n#  define des_cbc_encrypt(i,o,l,k,iv,e)\\\n        DES_cbc_encrypt((i),(o),(l),&(k),(iv),(e))\n#  define des_ncbc_encrypt(i,o,l,k,iv,e)\\\n        DES_ncbc_encrypt((i),(o),(l),&(k),(iv),(e))\n#  define des_xcbc_encrypt(i,o,l,k,iv,inw,outw,e)\\\n        DES_xcbc_encrypt((i),(o),(l),&(k),(iv),(inw),(outw),(e))\n#  define des_cfb_encrypt(i,o,n,l,k,iv,e)\\\n        DES_cfb_encrypt((i),(o),(n),(l),&(k),(iv),(e))\n#  define des_ecb_encrypt(i,o,k,e)\\\n        DES_ecb_encrypt((i),(o),&(k),(e))\n#  define des_encrypt1(d,k,e)\\\n        DES_encrypt1((d),&(k),(e))\n#  define des_encrypt2(d,k,e)\\\n        DES_encrypt2((d),&(k),(e))\n#  define des_encrypt3(d,k1,k2,k3)\\\n        DES_encrypt3((d),&(k1),&(k2),&(k3))\n#  define des_decrypt3(d,k1,k2,k3)\\\n        DES_decrypt3((d),&(k1),&(k2),&(k3))\n#  define des_xwhite_in2out(k,i,o)\\\n        DES_xwhite_in2out((k),(i),(o))\n#  define des_enc_read(f,b,l,k,iv)\\\n        DES_enc_read((f),(b),(l),&(k),(iv))\n#  define des_enc_write(f,b,l,k,iv)\\\n        DES_enc_write((f),(b),(l),&(k),(iv))\n#  define des_fcrypt(b,s,r)\\\n        DES_fcrypt((b),(s),(r))\n#  if 0\n#   define des_crypt(b,s)\\\n        DES_crypt((b),(s))\n#   if !defined(PERL5) && !defined(__FreeBSD__) && !defined(NeXT) && !defined(__OpenBSD__)\n#    define crypt(b,s)\\\n        DES_crypt((b),(s))\n#   endif\n#  endif\n#  define des_ofb_encrypt(i,o,n,l,k,iv)\\\n        DES_ofb_encrypt((i),(o),(n),(l),&(k),(iv))\n#  define des_pcbc_encrypt(i,o,l,k,iv,e)\\\n        DES_pcbc_encrypt((i),(o),(l),&(k),(iv),(e))\n#  define des_quad_cksum(i,o,l,c,s)\\\n        DES_quad_cksum((i),(o),(l),(c),(s))\n#  define des_random_seed(k)\\\n        _ossl_096_des_random_seed((k))\n#  define des_random_key(r)\\\n        DES_random_key((r))\n#  define des_read_password(k,p,v) \\\n        DES_read_password((k),(p),(v))\n#  define des_read_2passwords(k1,k2,p,v) \\\n        DES_read_2passwords((k1),(k2),(p),(v))\n#  define des_set_odd_parity(k)\\\n        DES_set_odd_parity((k))\n#  define des_check_key_parity(k)\\\n        DES_check_key_parity((k))\n#  define des_is_weak_key(k)\\\n        DES_is_weak_key((k))\n#  define des_set_key(k,ks)\\\n        DES_set_key((k),&(ks))\n#  define des_key_sched(k,ks)\\\n        DES_key_sched((k),&(ks))\n#  define des_set_key_checked(k,ks)\\\n        DES_set_key_checked((k),&(ks))\n#  define des_set_key_unchecked(k,ks)\\\n        DES_set_key_unchecked((k),&(ks))\n#  define des_string_to_key(s,k)\\\n        DES_string_to_key((s),(k))\n#  define des_string_to_2keys(s,k1,k2)\\\n        DES_string_to_2keys((s),(k1),(k2))\n#  define des_cfb64_encrypt(i,o,l,ks,iv,n,e)\\\n        DES_cfb64_encrypt((i),(o),(l),&(ks),(iv),(n),(e))\n#  define des_ofb64_encrypt(i,o,l,ks,iv,n)\\\n        DES_ofb64_encrypt((i),(o),(l),&(ks),(iv),(n))\n\n#  define des_ecb2_encrypt(i,o,k1,k2,e) \\\n        des_ecb3_encrypt((i),(o),(k1),(k2),(k1),(e))\n\n#  define des_ede2_cbc_encrypt(i,o,l,k1,k2,iv,e) \\\n        des_ede3_cbc_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(e))\n\n#  define des_ede2_cfb64_encrypt(i,o,l,k1,k2,iv,n,e) \\\n        des_ede3_cfb64_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(n),(e))\n\n#  define des_ede2_ofb64_encrypt(i,o,l,k1,k2,iv,n) \\\n        des_ede3_ofb64_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(n))\n\n#  define des_check_key DES_check_key\n#  define des_rw_mode DES_rw_mode\n# else                          /* libdes compatibility */\n/*\n * Map all symbol names to _ossl_old_des_* form, so we avoid all clashes with\n * libdes\n */\n#  define des_cblock _ossl_old_des_cblock\n#  define des_key_schedule _ossl_old_des_key_schedule\n#  define des_ecb3_encrypt(i,o,k1,k2,k3,e)\\\n        _ossl_old_des_ecb3_encrypt((i),(o),(k1),(k2),(k3),(e))\n#  define des_ede3_cbc_encrypt(i,o,l,k1,k2,k3,iv,e)\\\n        _ossl_old_des_ede3_cbc_encrypt((i),(o),(l),(k1),(k2),(k3),(iv),(e))\n#  define des_ede3_cfb64_encrypt(i,o,l,k1,k2,k3,iv,n,e)\\\n        _ossl_old_des_ede3_cfb64_encrypt((i),(o),(l),(k1),(k2),(k3),(iv),(n),(e))\n#  define des_ede3_ofb64_encrypt(i,o,l,k1,k2,k3,iv,n)\\\n        _ossl_old_des_ede3_ofb64_encrypt((i),(o),(l),(k1),(k2),(k3),(iv),(n))\n#  define des_options()\\\n        _ossl_old_des_options()\n#  define des_cbc_cksum(i,o,l,k,iv)\\\n        _ossl_old_des_cbc_cksum((i),(o),(l),(k),(iv))\n#  define des_cbc_encrypt(i,o,l,k,iv,e)\\\n        _ossl_old_des_cbc_encrypt((i),(o),(l),(k),(iv),(e))\n#  define des_ncbc_encrypt(i,o,l,k,iv,e)\\\n        _ossl_old_des_ncbc_encrypt((i),(o),(l),(k),(iv),(e))\n#  define des_xcbc_encrypt(i,o,l,k,iv,inw,outw,e)\\\n        _ossl_old_des_xcbc_encrypt((i),(o),(l),(k),(iv),(inw),(outw),(e))\n#  define des_cfb_encrypt(i,o,n,l,k,iv,e)\\\n        _ossl_old_des_cfb_encrypt((i),(o),(n),(l),(k),(iv),(e))\n#  define des_ecb_encrypt(i,o,k,e)\\\n        _ossl_old_des_ecb_encrypt((i),(o),(k),(e))\n#  define des_encrypt(d,k,e)\\\n        _ossl_old_des_encrypt((d),(k),(e))\n#  define des_encrypt2(d,k,e)\\\n        _ossl_old_des_encrypt2((d),(k),(e))\n#  define des_encrypt3(d,k1,k2,k3)\\\n        _ossl_old_des_encrypt3((d),(k1),(k2),(k3))\n#  define des_decrypt3(d,k1,k2,k3)\\\n        _ossl_old_des_decrypt3((d),(k1),(k2),(k3))\n#  define des_xwhite_in2out(k,i,o)\\\n        _ossl_old_des_xwhite_in2out((k),(i),(o))\n#  define des_enc_read(f,b,l,k,iv)\\\n        _ossl_old_des_enc_read((f),(b),(l),(k),(iv))\n#  define des_enc_write(f,b,l,k,iv)\\\n        _ossl_old_des_enc_write((f),(b),(l),(k),(iv))\n#  define des_fcrypt(b,s,r)\\\n        _ossl_old_des_fcrypt((b),(s),(r))\n#  define des_crypt(b,s)\\\n        _ossl_old_des_crypt((b),(s))\n#  if 0\n#   define crypt(b,s)\\\n        _ossl_old_crypt((b),(s))\n#  endif\n#  define des_ofb_encrypt(i,o,n,l,k,iv)\\\n        _ossl_old_des_ofb_encrypt((i),(o),(n),(l),(k),(iv))\n#  define des_pcbc_encrypt(i,o,l,k,iv,e)\\\n        _ossl_old_des_pcbc_encrypt((i),(o),(l),(k),(iv),(e))\n#  define des_quad_cksum(i,o,l,c,s)\\\n        _ossl_old_des_quad_cksum((i),(o),(l),(c),(s))\n#  define des_random_seed(k)\\\n        _ossl_old_des_random_seed((k))\n#  define des_random_key(r)\\\n        _ossl_old_des_random_key((r))\n#  define des_read_password(k,p,v) \\\n        _ossl_old_des_read_password((k),(p),(v))\n#  define des_read_2passwords(k1,k2,p,v) \\\n        _ossl_old_des_read_2passwords((k1),(k2),(p),(v))\n#  define des_set_odd_parity(k)\\\n        _ossl_old_des_set_odd_parity((k))\n#  define des_is_weak_key(k)\\\n        _ossl_old_des_is_weak_key((k))\n#  define des_set_key(k,ks)\\\n        _ossl_old_des_set_key((k),(ks))\n#  define des_key_sched(k,ks)\\\n        _ossl_old_des_key_sched((k),(ks))\n#  define des_string_to_key(s,k)\\\n        _ossl_old_des_string_to_key((s),(k))\n#  define des_string_to_2keys(s,k1,k2)\\\n        _ossl_old_des_string_to_2keys((s),(k1),(k2))\n#  define des_cfb64_encrypt(i,o,l,ks,iv,n,e)\\\n        _ossl_old_des_cfb64_encrypt((i),(o),(l),(ks),(iv),(n),(e))\n#  define des_ofb64_encrypt(i,o,l,ks,iv,n)\\\n        _ossl_old_des_ofb64_encrypt((i),(o),(l),(ks),(iv),(n))\n\n#  define des_ecb2_encrypt(i,o,k1,k2,e) \\\n        des_ecb3_encrypt((i),(o),(k1),(k2),(k1),(e))\n\n#  define des_ede2_cbc_encrypt(i,o,l,k1,k2,iv,e) \\\n        des_ede3_cbc_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(e))\n\n#  define des_ede2_cfb64_encrypt(i,o,l,k1,k2,iv,n,e) \\\n        des_ede3_cfb64_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(n),(e))\n\n#  define des_ede2_ofb64_encrypt(i,o,l,k1,k2,iv,n) \\\n        des_ede3_ofb64_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(n))\n\n#  define des_check_key DES_check_key\n#  define des_rw_mode DES_rw_mode\n# endif\n\nconst char *_ossl_old_des_options(void);\nvoid _ossl_old_des_ecb3_encrypt(_ossl_old_des_cblock *input,\n                                _ossl_old_des_cblock *output,\n                                _ossl_old_des_key_schedule ks1,\n                                _ossl_old_des_key_schedule ks2,\n                                _ossl_old_des_key_schedule ks3, int enc);\nDES_LONG _ossl_old_des_cbc_cksum(_ossl_old_des_cblock *input,\n                                 _ossl_old_des_cblock *output, long length,\n                                 _ossl_old_des_key_schedule schedule,\n                                 _ossl_old_des_cblock *ivec);\nvoid _ossl_old_des_cbc_encrypt(_ossl_old_des_cblock *input,\n                               _ossl_old_des_cblock *output, long length,\n                               _ossl_old_des_key_schedule schedule,\n                               _ossl_old_des_cblock *ivec, int enc);\nvoid _ossl_old_des_ncbc_encrypt(_ossl_old_des_cblock *input,\n                                _ossl_old_des_cblock *output, long length,\n                                _ossl_old_des_key_schedule schedule,\n                                _ossl_old_des_cblock *ivec, int enc);\nvoid _ossl_old_des_xcbc_encrypt(_ossl_old_des_cblock *input,\n                                _ossl_old_des_cblock *output, long length,\n                                _ossl_old_des_key_schedule schedule,\n                                _ossl_old_des_cblock *ivec,\n                                _ossl_old_des_cblock *inw,\n                                _ossl_old_des_cblock *outw, int enc);\nvoid _ossl_old_des_cfb_encrypt(unsigned char *in, unsigned char *out,\n                               int numbits, long length,\n                               _ossl_old_des_key_schedule schedule,\n                               _ossl_old_des_cblock *ivec, int enc);\nvoid _ossl_old_des_ecb_encrypt(_ossl_old_des_cblock *input,\n                               _ossl_old_des_cblock *output,\n                               _ossl_old_des_key_schedule ks, int enc);\nvoid _ossl_old_des_encrypt(DES_LONG *data, _ossl_old_des_key_schedule ks,\n                           int enc);\nvoid _ossl_old_des_encrypt2(DES_LONG *data, _ossl_old_des_key_schedule ks,\n                            int enc);\nvoid _ossl_old_des_encrypt3(DES_LONG *data, _ossl_old_des_key_schedule ks1,\n                            _ossl_old_des_key_schedule ks2,\n                            _ossl_old_des_key_schedule ks3);\nvoid _ossl_old_des_decrypt3(DES_LONG *data, _ossl_old_des_key_schedule ks1,\n                            _ossl_old_des_key_schedule ks2,\n                            _ossl_old_des_key_schedule ks3);\nvoid _ossl_old_des_ede3_cbc_encrypt(_ossl_old_des_cblock *input,\n                                    _ossl_old_des_cblock *output, long length,\n                                    _ossl_old_des_key_schedule ks1,\n                                    _ossl_old_des_key_schedule ks2,\n                                    _ossl_old_des_key_schedule ks3,\n                                    _ossl_old_des_cblock *ivec, int enc);\nvoid _ossl_old_des_ede3_cfb64_encrypt(unsigned char *in, unsigned char *out,\n                                      long length,\n                                      _ossl_old_des_key_schedule ks1,\n                                      _ossl_old_des_key_schedule ks2,\n                                      _ossl_old_des_key_schedule ks3,\n                                      _ossl_old_des_cblock *ivec, int *num,\n                                      int enc);\nvoid _ossl_old_des_ede3_ofb64_encrypt(unsigned char *in, unsigned char *out,\n                                      long length,\n                                      _ossl_old_des_key_schedule ks1,\n                                      _ossl_old_des_key_schedule ks2,\n                                      _ossl_old_des_key_schedule ks3,\n                                      _ossl_old_des_cblock *ivec, int *num);\n# if 0\nvoid _ossl_old_des_xwhite_in2out(_ossl_old_des_cblock (*des_key),\n                                 _ossl_old_des_cblock (*in_white),\n                                 _ossl_old_des_cblock (*out_white));\n# endif\n\nint _ossl_old_des_enc_read(int fd, char *buf, int len,\n                           _ossl_old_des_key_schedule sched,\n                           _ossl_old_des_cblock *iv);\nint _ossl_old_des_enc_write(int fd, char *buf, int len,\n                            _ossl_old_des_key_schedule sched,\n                            _ossl_old_des_cblock *iv);\nchar *_ossl_old_des_fcrypt(const char *buf, const char *salt, char *ret);\nchar *_ossl_old_des_crypt(const char *buf, const char *salt);\n# if !defined(PERL5) && !defined(NeXT)\nchar *_ossl_old_crypt(const char *buf, const char *salt);\n# endif\nvoid _ossl_old_des_ofb_encrypt(unsigned char *in, unsigned char *out,\n                               int numbits, long length,\n                               _ossl_old_des_key_schedule schedule,\n                               _ossl_old_des_cblock *ivec);\nvoid _ossl_old_des_pcbc_encrypt(_ossl_old_des_cblock *input,\n                                _ossl_old_des_cblock *output, long length,\n                                _ossl_old_des_key_schedule schedule,\n                                _ossl_old_des_cblock *ivec, int enc);\nDES_LONG _ossl_old_des_quad_cksum(_ossl_old_des_cblock *input,\n                                  _ossl_old_des_cblock *output, long length,\n                                  int out_count, _ossl_old_des_cblock *seed);\nvoid _ossl_old_des_random_seed(_ossl_old_des_cblock key);\nvoid _ossl_old_des_random_key(_ossl_old_des_cblock ret);\nint _ossl_old_des_read_password(_ossl_old_des_cblock *key, const char *prompt,\n                                int verify);\nint _ossl_old_des_read_2passwords(_ossl_old_des_cblock *key1,\n                                  _ossl_old_des_cblock *key2,\n                                  const char *prompt, int verify);\nvoid _ossl_old_des_set_odd_parity(_ossl_old_des_cblock *key);\nint _ossl_old_des_is_weak_key(_ossl_old_des_cblock *key);\nint _ossl_old_des_set_key(_ossl_old_des_cblock *key,\n                          _ossl_old_des_key_schedule schedule);\nint _ossl_old_des_key_sched(_ossl_old_des_cblock *key,\n                            _ossl_old_des_key_schedule schedule);\nvoid _ossl_old_des_string_to_key(char *str, _ossl_old_des_cblock *key);\nvoid _ossl_old_des_string_to_2keys(char *str, _ossl_old_des_cblock *key1,\n                                   _ossl_old_des_cblock *key2);\nvoid _ossl_old_des_cfb64_encrypt(unsigned char *in, unsigned char *out,\n                                 long length,\n                                 _ossl_old_des_key_schedule schedule,\n                                 _ossl_old_des_cblock *ivec, int *num,\n                                 int enc);\nvoid _ossl_old_des_ofb64_encrypt(unsigned char *in, unsigned char *out,\n                                 long length,\n                                 _ossl_old_des_key_schedule schedule,\n                                 _ossl_old_des_cblock *ivec, int *num);\n\nvoid _ossl_096_des_random_seed(des_cblock *key);\n\n/*\n * The following definitions provide compatibility with the MIT Kerberos\n * library. The _ossl_old_des_key_schedule structure is not binary\n * compatible.\n */\n\n# define _KERBEROS_DES_H\n\n# define KRBDES_ENCRYPT DES_ENCRYPT\n# define KRBDES_DECRYPT DES_DECRYPT\n\n# ifdef KERBEROS\n#  define ENCRYPT DES_ENCRYPT\n#  define DECRYPT DES_DECRYPT\n# endif\n\n# ifndef NCOMPAT\n#  define C_Block des_cblock\n#  define Key_schedule des_key_schedule\n#  define KEY_SZ DES_KEY_SZ\n#  define string_to_key des_string_to_key\n#  define read_pw_string des_read_pw_string\n#  define random_key des_random_key\n#  define pcbc_encrypt des_pcbc_encrypt\n#  define set_key des_set_key\n#  define key_sched des_key_sched\n#  define ecb_encrypt des_ecb_encrypt\n#  define cbc_encrypt des_cbc_encrypt\n#  define ncbc_encrypt des_ncbc_encrypt\n#  define xcbc_encrypt des_xcbc_encrypt\n#  define cbc_cksum des_cbc_cksum\n#  define quad_cksum des_quad_cksum\n#  define check_parity des_check_key_parity\n# endif\n\n# define des_fixup_key_parity DES_fixup_key_parity\n\n#ifdef  __cplusplus\n}\n#endif\n\n/* for DES_read_pw_string et al */\n# include <openssl/ui_compat.h>\n\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/x86_64/include/openssl/dso.h",
    "content": "/* dso.h */\n/*\n * Written by Geoff Thorpe (geoff@geoffthorpe.net) for the OpenSSL project\n * 2000.\n */\n/* ====================================================================\n * Copyright (c) 2000 The OpenSSL Project.  All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n *\n * 1. Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n *\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in\n *    the documentation and/or other materials provided with the\n *    distribution.\n *\n * 3. All advertising materials mentioning features or use of this\n *    software must display the following acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)\"\n *\n * 4. The names \"OpenSSL Toolkit\" and \"OpenSSL Project\" must not be used to\n *    endorse or promote products derived from this software without\n *    prior written permission. For written permission, please contact\n *    licensing@OpenSSL.org.\n *\n * 5. Products derived from this software may not be called \"OpenSSL\"\n *    nor may \"OpenSSL\" appear in their names without prior written\n *    permission of the OpenSSL Project.\n *\n * 6. Redistributions of any form whatsoever must retain the following\n *    acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)\"\n *\n * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY\n * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\n * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR\n * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\n * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,\n * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED\n * OF THE POSSIBILITY OF SUCH DAMAGE.\n * ====================================================================\n *\n * This product includes cryptographic software written by Eric Young\n * (eay@cryptsoft.com).  This product includes software written by Tim\n * Hudson (tjh@cryptsoft.com).\n *\n */\n\n#ifndef HEADER_DSO_H\n# define HEADER_DSO_H\n\n# include <openssl/crypto.h>\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/* These values are used as commands to DSO_ctrl() */\n# define DSO_CTRL_GET_FLAGS      1\n# define DSO_CTRL_SET_FLAGS      2\n# define DSO_CTRL_OR_FLAGS       3\n\n/*\n * By default, DSO_load() will translate the provided filename into a form\n * typical for the platform (more specifically the DSO_METHOD) using the\n * dso_name_converter function of the method. Eg. win32 will transform \"blah\"\n * into \"blah.dll\", and dlfcn will transform it into \"libblah.so\". The\n * behaviour can be overriden by setting the name_converter callback in the\n * DSO object (using DSO_set_name_converter()). This callback could even\n * utilise the DSO_METHOD's converter too if it only wants to override\n * behaviour for one or two possible DSO methods. However, the following flag\n * can be set in a DSO to prevent *any* native name-translation at all - eg.\n * if the caller has prompted the user for a path to a driver library so the\n * filename should be interpreted as-is.\n */\n# define DSO_FLAG_NO_NAME_TRANSLATION            0x01\n/*\n * An extra flag to give if only the extension should be added as\n * translation.  This is obviously only of importance on Unix and other\n * operating systems where the translation also may prefix the name with\n * something, like 'lib', and ignored everywhere else. This flag is also\n * ignored if DSO_FLAG_NO_NAME_TRANSLATION is used at the same time.\n */\n# define DSO_FLAG_NAME_TRANSLATION_EXT_ONLY      0x02\n\n/*\n * The following flag controls the translation of symbol names to upper case.\n * This is currently only being implemented for OpenVMS.\n */\n# define DSO_FLAG_UPCASE_SYMBOL                  0x10\n\n/*\n * This flag loads the library with public symbols. Meaning: The exported\n * symbols of this library are public to all libraries loaded after this\n * library. At the moment only implemented in unix.\n */\n# define DSO_FLAG_GLOBAL_SYMBOLS                 0x20\n\ntypedef void (*DSO_FUNC_TYPE) (void);\n\ntypedef struct dso_st DSO;\n\n/*\n * The function prototype used for method functions (or caller-provided\n * callbacks) that transform filenames. They are passed a DSO structure\n * pointer (or NULL if they are to be used independantly of a DSO object) and\n * a filename to transform. They should either return NULL (if there is an\n * error condition) or a newly allocated string containing the transformed\n * form that the caller will need to free with OPENSSL_free() when done.\n */\ntypedef char *(*DSO_NAME_CONVERTER_FUNC)(DSO *, const char *);\n/*\n * The function prototype used for method functions (or caller-provided\n * callbacks) that merge two file specifications. They are passed a DSO\n * structure pointer (or NULL if they are to be used independantly of a DSO\n * object) and two file specifications to merge. They should either return\n * NULL (if there is an error condition) or a newly allocated string\n * containing the result of merging that the caller will need to free with\n * OPENSSL_free() when done. Here, merging means that bits and pieces are\n * taken from each of the file specifications and added together in whatever\n * fashion that is sensible for the DSO method in question.  The only rule\n * that really applies is that if the two specification contain pieces of the\n * same type, the copy from the first string takes priority.  One could see\n * it as the first specification is the one given by the user and the second\n * being a bunch of defaults to add on if they're missing in the first.\n */\ntypedef char *(*DSO_MERGER_FUNC)(DSO *, const char *, const char *);\n\ntypedef struct dso_meth_st {\n    const char *name;\n    /*\n     * Loads a shared library, NB: new DSO_METHODs must ensure that a\n     * successful load populates the loaded_filename field, and likewise a\n     * successful unload OPENSSL_frees and NULLs it out.\n     */\n    int (*dso_load) (DSO *dso);\n    /* Unloads a shared library */\n    int (*dso_unload) (DSO *dso);\n    /* Binds a variable */\n    void *(*dso_bind_var) (DSO *dso, const char *symname);\n    /*\n     * Binds a function - assumes a return type of DSO_FUNC_TYPE. This should\n     * be cast to the real function prototype by the caller. Platforms that\n     * don't have compatible representations for different prototypes (this\n     * is possible within ANSI C) are highly unlikely to have shared\n     * libraries at all, let alone a DSO_METHOD implemented for them.\n     */\n    DSO_FUNC_TYPE (*dso_bind_func) (DSO *dso, const char *symname);\n/* I don't think this would actually be used in any circumstances. */\n# if 0\n    /* Unbinds a variable */\n    int (*dso_unbind_var) (DSO *dso, char *symname, void *symptr);\n    /* Unbinds a function */\n    int (*dso_unbind_func) (DSO *dso, char *symname, DSO_FUNC_TYPE symptr);\n# endif\n    /*\n     * The generic (yuck) \"ctrl()\" function. NB: Negative return values\n     * (rather than zero) indicate errors.\n     */\n    long (*dso_ctrl) (DSO *dso, int cmd, long larg, void *parg);\n    /*\n     * The default DSO_METHOD-specific function for converting filenames to a\n     * canonical native form.\n     */\n    DSO_NAME_CONVERTER_FUNC dso_name_converter;\n    /*\n     * The default DSO_METHOD-specific function for converting filenames to a\n     * canonical native form.\n     */\n    DSO_MERGER_FUNC dso_merger;\n    /* [De]Initialisation handlers. */\n    int (*init) (DSO *dso);\n    int (*finish) (DSO *dso);\n    /* Return pathname of the module containing location */\n    int (*pathbyaddr) (void *addr, char *path, int sz);\n    /* Perform global symbol lookup, i.e. among *all* modules */\n    void *(*globallookup) (const char *symname);\n} DSO_METHOD;\n\n/**********************************************************************/\n/* The low-level handle type used to refer to a loaded shared library */\n\nstruct dso_st {\n    DSO_METHOD *meth;\n    /*\n     * Standard dlopen uses a (void *). Win32 uses a HANDLE. VMS doesn't use\n     * anything but will need to cache the filename for use in the dso_bind\n     * handler. All in all, let each method control its own destiny.\n     * \"Handles\" and such go in a STACK.\n     */\n    STACK_OF(void) *meth_data;\n    int references;\n    int flags;\n    /*\n     * For use by applications etc ... use this for your bits'n'pieces, don't\n     * touch meth_data!\n     */\n    CRYPTO_EX_DATA ex_data;\n    /*\n     * If this callback function pointer is set to non-NULL, then it will be\n     * used in DSO_load() in place of meth->dso_name_converter. NB: This\n     * should normally set using DSO_set_name_converter().\n     */\n    DSO_NAME_CONVERTER_FUNC name_converter;\n    /*\n     * If this callback function pointer is set to non-NULL, then it will be\n     * used in DSO_load() in place of meth->dso_merger. NB: This should\n     * normally set using DSO_set_merger().\n     */\n    DSO_MERGER_FUNC merger;\n    /*\n     * This is populated with (a copy of) the platform-independant filename\n     * used for this DSO.\n     */\n    char *filename;\n    /*\n     * This is populated with (a copy of) the translated filename by which\n     * the DSO was actually loaded. It is NULL iff the DSO is not currently\n     * loaded. NB: This is here because the filename translation process may\n     * involve a callback being invoked more than once not only to convert to\n     * a platform-specific form, but also to try different filenames in the\n     * process of trying to perform a load. As such, this variable can be\n     * used to indicate (a) whether this DSO structure corresponds to a\n     * loaded library or not, and (b) the filename with which it was actually\n     * loaded.\n     */\n    char *loaded_filename;\n};\n\nDSO *DSO_new(void);\nDSO *DSO_new_method(DSO_METHOD *method);\nint DSO_free(DSO *dso);\nint DSO_flags(DSO *dso);\nint DSO_up_ref(DSO *dso);\nlong DSO_ctrl(DSO *dso, int cmd, long larg, void *parg);\n\n/*\n * This function sets the DSO's name_converter callback. If it is non-NULL,\n * then it will be used instead of the associated DSO_METHOD's function. If\n * oldcb is non-NULL then it is set to the function pointer value being\n * replaced. Return value is non-zero for success.\n */\nint DSO_set_name_converter(DSO *dso, DSO_NAME_CONVERTER_FUNC cb,\n                           DSO_NAME_CONVERTER_FUNC *oldcb);\n/*\n * These functions can be used to get/set the platform-independant filename\n * used for a DSO. NB: set will fail if the DSO is already loaded.\n */\nconst char *DSO_get_filename(DSO *dso);\nint DSO_set_filename(DSO *dso, const char *filename);\n/*\n * This function will invoke the DSO's name_converter callback to translate a\n * filename, or if the callback isn't set it will instead use the DSO_METHOD's\n * converter. If \"filename\" is NULL, the \"filename\" in the DSO itself will be\n * used. If the DSO_FLAG_NO_NAME_TRANSLATION flag is set, then the filename is\n * simply duplicated. NB: This function is usually called from within a\n * DSO_METHOD during the processing of a DSO_load() call, and is exposed so\n * that caller-created DSO_METHODs can do the same thing. A non-NULL return\n * value will need to be OPENSSL_free()'d.\n */\nchar *DSO_convert_filename(DSO *dso, const char *filename);\n/*\n * This function will invoke the DSO's merger callback to merge two file\n * specifications, or if the callback isn't set it will instead use the\n * DSO_METHOD's merger.  A non-NULL return value will need to be\n * OPENSSL_free()'d.\n */\nchar *DSO_merge(DSO *dso, const char *filespec1, const char *filespec2);\n/*\n * If the DSO is currently loaded, this returns the filename that it was\n * loaded under, otherwise it returns NULL. So it is also useful as a test as\n * to whether the DSO is currently loaded. NB: This will not necessarily\n * return the same value as DSO_convert_filename(dso, dso->filename), because\n * the DSO_METHOD's load function may have tried a variety of filenames (with\n * and/or without the aid of the converters) before settling on the one it\n * actually loaded.\n */\nconst char *DSO_get_loaded_filename(DSO *dso);\n\nvoid DSO_set_default_method(DSO_METHOD *meth);\nDSO_METHOD *DSO_get_default_method(void);\nDSO_METHOD *DSO_get_method(DSO *dso);\nDSO_METHOD *DSO_set_method(DSO *dso, DSO_METHOD *meth);\n\n/*\n * The all-singing all-dancing load function, you normally pass NULL for the\n * first and third parameters. Use DSO_up and DSO_free for subsequent\n * reference count handling. Any flags passed in will be set in the\n * constructed DSO after its init() function but before the load operation.\n * If 'dso' is non-NULL, 'flags' is ignored.\n */\nDSO *DSO_load(DSO *dso, const char *filename, DSO_METHOD *meth, int flags);\n\n/* This function binds to a variable inside a shared library. */\nvoid *DSO_bind_var(DSO *dso, const char *symname);\n\n/* This function binds to a function inside a shared library. */\nDSO_FUNC_TYPE DSO_bind_func(DSO *dso, const char *symname);\n\n/*\n * This method is the default, but will beg, borrow, or steal whatever method\n * should be the default on any particular platform (including\n * DSO_METH_null() if necessary).\n */\nDSO_METHOD *DSO_METHOD_openssl(void);\n\n/*\n * This method is defined for all platforms - if a platform has no DSO\n * support then this will be the only method!\n */\nDSO_METHOD *DSO_METHOD_null(void);\n\n/*\n * If DSO_DLFCN is defined, the standard dlfcn.h-style functions (dlopen,\n * dlclose, dlsym, etc) will be used and incorporated into this method. If\n * not, this method will return NULL.\n */\nDSO_METHOD *DSO_METHOD_dlfcn(void);\n\n/*\n * If DSO_DL is defined, the standard dl.h-style functions (shl_load,\n * shl_unload, shl_findsym, etc) will be used and incorporated into this\n * method. If not, this method will return NULL.\n */\nDSO_METHOD *DSO_METHOD_dl(void);\n\n/* If WIN32 is defined, use DLLs. If not, return NULL. */\nDSO_METHOD *DSO_METHOD_win32(void);\n\n/* If VMS is defined, use shared images. If not, return NULL. */\nDSO_METHOD *DSO_METHOD_vms(void);\n\n/*\n * This function writes null-terminated pathname of DSO module containing\n * 'addr' into 'sz' large caller-provided 'path' and returns the number of\n * characters [including trailing zero] written to it. If 'sz' is 0 or\n * negative, 'path' is ignored and required amount of charachers [including\n * trailing zero] to accomodate pathname is returned. If 'addr' is NULL, then\n * pathname of cryptolib itself is returned. Negative or zero return value\n * denotes error.\n */\nint DSO_pathbyaddr(void *addr, char *path, int sz);\n\n/*\n * This function should be used with caution! It looks up symbols in *all*\n * loaded modules and if module gets unloaded by somebody else attempt to\n * dereference the pointer is doomed to have fatal consequences. Primary\n * usage for this function is to probe *core* system functionality, e.g.\n * check if getnameinfo(3) is available at run-time without bothering about\n * OS-specific details such as libc.so.versioning or where does it actually\n * reside: in libc itself or libsocket.\n */\nvoid *DSO_global_lookup(const char *name);\n\n/* If BeOS is defined, use shared images. If not, return NULL. */\nDSO_METHOD *DSO_METHOD_beos(void);\n\n/* BEGIN ERROR CODES */\n/*\n * The following lines are auto generated by the script mkerr.pl. Any changes\n * made after this point may be overwritten when the script is next run.\n */\nvoid ERR_load_DSO_strings(void);\n\n/* Error codes for the DSO functions. */\n\n/* Function codes. */\n# define DSO_F_BEOS_BIND_FUNC                             144\n# define DSO_F_BEOS_BIND_VAR                              145\n# define DSO_F_BEOS_LOAD                                  146\n# define DSO_F_BEOS_NAME_CONVERTER                        147\n# define DSO_F_BEOS_UNLOAD                                148\n# define DSO_F_DLFCN_BIND_FUNC                            100\n# define DSO_F_DLFCN_BIND_VAR                             101\n# define DSO_F_DLFCN_LOAD                                 102\n# define DSO_F_DLFCN_MERGER                               130\n# define DSO_F_DLFCN_NAME_CONVERTER                       123\n# define DSO_F_DLFCN_UNLOAD                               103\n# define DSO_F_DL_BIND_FUNC                               104\n# define DSO_F_DL_BIND_VAR                                105\n# define DSO_F_DL_LOAD                                    106\n# define DSO_F_DL_MERGER                                  131\n# define DSO_F_DL_NAME_CONVERTER                          124\n# define DSO_F_DL_UNLOAD                                  107\n# define DSO_F_DSO_BIND_FUNC                              108\n# define DSO_F_DSO_BIND_VAR                               109\n# define DSO_F_DSO_CONVERT_FILENAME                       126\n# define DSO_F_DSO_CTRL                                   110\n# define DSO_F_DSO_FREE                                   111\n# define DSO_F_DSO_GET_FILENAME                           127\n# define DSO_F_DSO_GET_LOADED_FILENAME                    128\n# define DSO_F_DSO_GLOBAL_LOOKUP                          139\n# define DSO_F_DSO_LOAD                                   112\n# define DSO_F_DSO_MERGE                                  132\n# define DSO_F_DSO_NEW_METHOD                             113\n# define DSO_F_DSO_PATHBYADDR                             140\n# define DSO_F_DSO_SET_FILENAME                           129\n# define DSO_F_DSO_SET_NAME_CONVERTER                     122\n# define DSO_F_DSO_UP_REF                                 114\n# define DSO_F_GLOBAL_LOOKUP_FUNC                         138\n# define DSO_F_PATHBYADDR                                 137\n# define DSO_F_VMS_BIND_SYM                               115\n# define DSO_F_VMS_LOAD                                   116\n# define DSO_F_VMS_MERGER                                 133\n# define DSO_F_VMS_UNLOAD                                 117\n# define DSO_F_WIN32_BIND_FUNC                            118\n# define DSO_F_WIN32_BIND_VAR                             119\n# define DSO_F_WIN32_GLOBALLOOKUP                         142\n# define DSO_F_WIN32_GLOBALLOOKUP_FUNC                    143\n# define DSO_F_WIN32_JOINER                               135\n# define DSO_F_WIN32_LOAD                                 120\n# define DSO_F_WIN32_MERGER                               134\n# define DSO_F_WIN32_NAME_CONVERTER                       125\n# define DSO_F_WIN32_PATHBYADDR                           141\n# define DSO_F_WIN32_SPLITTER                             136\n# define DSO_F_WIN32_UNLOAD                               121\n\n/* Reason codes. */\n# define DSO_R_CTRL_FAILED                                100\n# define DSO_R_DSO_ALREADY_LOADED                         110\n# define DSO_R_EMPTY_FILE_STRUCTURE                       113\n# define DSO_R_FAILURE                                    114\n# define DSO_R_FILENAME_TOO_BIG                           101\n# define DSO_R_FINISH_FAILED                              102\n# define DSO_R_INCORRECT_FILE_SYNTAX                      115\n# define DSO_R_LOAD_FAILED                                103\n# define DSO_R_NAME_TRANSLATION_FAILED                    109\n# define DSO_R_NO_FILENAME                                111\n# define DSO_R_NO_FILE_SPECIFICATION                      116\n# define DSO_R_NULL_HANDLE                                104\n# define DSO_R_SET_FILENAME_FAILED                        112\n# define DSO_R_STACK_ERROR                                105\n# define DSO_R_SYM_FAILURE                                106\n# define DSO_R_UNLOAD_FAILED                              107\n# define DSO_R_UNSUPPORTED                                108\n\n#ifdef  __cplusplus\n}\n#endif\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/x86_64/include/openssl/e_os2.h",
    "content": "/* e_os2.h */\n/* ====================================================================\n * Copyright (c) 1998-2000 The OpenSSL Project.  All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n *\n * 1. Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n *\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in\n *    the documentation and/or other materials provided with the\n *    distribution.\n *\n * 3. All advertising materials mentioning features or use of this\n *    software must display the following acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit. (http://www.openssl.org/)\"\n *\n * 4. The names \"OpenSSL Toolkit\" and \"OpenSSL Project\" must not be used to\n *    endorse or promote products derived from this software without\n *    prior written permission. For written permission, please contact\n *    openssl-core@openssl.org.\n *\n * 5. Products derived from this software may not be called \"OpenSSL\"\n *    nor may \"OpenSSL\" appear in their names without prior written\n *    permission of the OpenSSL Project.\n *\n * 6. Redistributions of any form whatsoever must retain the following\n *    acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit (http://www.openssl.org/)\"\n *\n * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY\n * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\n * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR\n * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\n * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,\n * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED\n * OF THE POSSIBILITY OF SUCH DAMAGE.\n * ====================================================================\n *\n * This product includes cryptographic software written by Eric Young\n * (eay@cryptsoft.com).  This product includes software written by Tim\n * Hudson (tjh@cryptsoft.com).\n *\n */\n\n#include <openssl/opensslconf.h>\n\n#ifndef HEADER_E_OS2_H\n# define HEADER_E_OS2_H\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n/******************************************************************************\n * Detect operating systems.  This probably needs completing.\n * The result is that at least one OPENSSL_SYS_os macro should be defined.\n * However, if none is defined, Unix is assumed.\n **/\n\n# define OPENSSL_SYS_UNIX\n\n/* ---------------------- Macintosh, before MacOS X ----------------------- */\n# if defined(__MWERKS__) && defined(macintosh) || defined(OPENSSL_SYSNAME_MAC)\n#  undef OPENSSL_SYS_UNIX\n#  define OPENSSL_SYS_MACINTOSH_CLASSIC\n# endif\n\n/* ---------------------- NetWare ----------------------------------------- */\n# if defined(NETWARE) || defined(OPENSSL_SYSNAME_NETWARE)\n#  undef OPENSSL_SYS_UNIX\n#  define OPENSSL_SYS_NETWARE\n# endif\n\n/* --------------------- Microsoft operating systems ---------------------- */\n\n/*\n * Note that MSDOS actually denotes 32-bit environments running on top of\n * MS-DOS, such as DJGPP one.\n */\n# if defined(OPENSSL_SYSNAME_MSDOS)\n#  undef OPENSSL_SYS_UNIX\n#  define OPENSSL_SYS_MSDOS\n# endif\n\n/*\n * For 32 bit environment, there seems to be the CygWin environment and then\n * all the others that try to do the same thing Microsoft does...\n */\n# if defined(OPENSSL_SYSNAME_UWIN)\n#  undef OPENSSL_SYS_UNIX\n#  define OPENSSL_SYS_WIN32_UWIN\n# else\n#  if defined(__CYGWIN__) || defined(OPENSSL_SYSNAME_CYGWIN)\n#   undef OPENSSL_SYS_UNIX\n#   define OPENSSL_SYS_WIN32_CYGWIN\n#  else\n#   if defined(_WIN32) || defined(OPENSSL_SYSNAME_WIN32)\n#    undef OPENSSL_SYS_UNIX\n#    define OPENSSL_SYS_WIN32\n#   endif\n#   if defined(_WIN64) || defined(OPENSSL_SYSNAME_WIN64)\n#    undef OPENSSL_SYS_UNIX\n#    if !defined(OPENSSL_SYS_WIN64)\n#     define OPENSSL_SYS_WIN64\n#    endif\n#   endif\n#   if defined(OPENSSL_SYSNAME_WINNT)\n#    undef OPENSSL_SYS_UNIX\n#    define OPENSSL_SYS_WINNT\n#   endif\n#   if defined(OPENSSL_SYSNAME_WINCE)\n#    undef OPENSSL_SYS_UNIX\n#    define OPENSSL_SYS_WINCE\n#   endif\n#  endif\n# endif\n\n/* Anything that tries to look like Microsoft is \"Windows\" */\n# if defined(OPENSSL_SYS_WIN32) || defined(OPENSSL_SYS_WIN64) || defined(OPENSSL_SYS_WINNT) || defined(OPENSSL_SYS_WINCE)\n#  undef OPENSSL_SYS_UNIX\n#  define OPENSSL_SYS_WINDOWS\n#  ifndef OPENSSL_SYS_MSDOS\n#   define OPENSSL_SYS_MSDOS\n#  endif\n# endif\n\n/*\n * DLL settings.  This part is a bit tough, because it's up to the\n * application implementor how he or she will link the application, so it\n * requires some macro to be used.\n */\n# ifdef OPENSSL_SYS_WINDOWS\n#  ifndef OPENSSL_OPT_WINDLL\n#   if defined(_WINDLL)         /* This is used when building OpenSSL to\n                                 * indicate that DLL linkage should be used */\n#    define OPENSSL_OPT_WINDLL\n#   endif\n#  endif\n# endif\n\n/* ------------------------------- OpenVMS -------------------------------- */\n# if defined(__VMS) || defined(VMS) || defined(OPENSSL_SYSNAME_VMS)\n#  undef OPENSSL_SYS_UNIX\n#  define OPENSSL_SYS_VMS\n#  if defined(__DECC)\n#   define OPENSSL_SYS_VMS_DECC\n#  elif defined(__DECCXX)\n#   define OPENSSL_SYS_VMS_DECC\n#   define OPENSSL_SYS_VMS_DECCXX\n#  else\n#   define OPENSSL_SYS_VMS_NODECC\n#  endif\n# endif\n\n/* -------------------------------- OS/2 ---------------------------------- */\n# if defined(__EMX__) || defined(__OS2__)\n#  undef OPENSSL_SYS_UNIX\n#  define OPENSSL_SYS_OS2\n# endif\n\n/* -------------------------------- Unix ---------------------------------- */\n# ifdef OPENSSL_SYS_UNIX\n#  if defined(linux) || defined(__linux__) || defined(OPENSSL_SYSNAME_LINUX)\n#   define OPENSSL_SYS_LINUX\n#  endif\n#  ifdef OPENSSL_SYSNAME_MPE\n#   define OPENSSL_SYS_MPE\n#  endif\n#  ifdef OPENSSL_SYSNAME_SNI\n#   define OPENSSL_SYS_SNI\n#  endif\n#  ifdef OPENSSL_SYSNAME_ULTRASPARC\n#   define OPENSSL_SYS_ULTRASPARC\n#  endif\n#  ifdef OPENSSL_SYSNAME_NEWS4\n#   define OPENSSL_SYS_NEWS4\n#  endif\n#  ifdef OPENSSL_SYSNAME_MACOSX\n#   define OPENSSL_SYS_MACOSX\n#  endif\n#  ifdef OPENSSL_SYSNAME_MACOSX_RHAPSODY\n#   define OPENSSL_SYS_MACOSX_RHAPSODY\n#   define OPENSSL_SYS_MACOSX\n#  endif\n#  ifdef OPENSSL_SYSNAME_SUNOS\n#   define OPENSSL_SYS_SUNOS\n#  endif\n#  if defined(_CRAY) || defined(OPENSSL_SYSNAME_CRAY)\n#   define OPENSSL_SYS_CRAY\n#  endif\n#  if defined(_AIX) || defined(OPENSSL_SYSNAME_AIX)\n#   define OPENSSL_SYS_AIX\n#  endif\n# endif\n\n/* -------------------------------- VOS ----------------------------------- */\n# if defined(__VOS__) || defined(OPENSSL_SYSNAME_VOS)\n#  define OPENSSL_SYS_VOS\n#  ifdef __HPPA__\n#   define OPENSSL_SYS_VOS_HPPA\n#  endif\n#  ifdef __IA32__\n#   define OPENSSL_SYS_VOS_IA32\n#  endif\n# endif\n\n/* ------------------------------ VxWorks --------------------------------- */\n# ifdef OPENSSL_SYSNAME_VXWORKS\n#  define OPENSSL_SYS_VXWORKS\n# endif\n\n/* -------------------------------- BeOS ---------------------------------- */\n# if defined(__BEOS__)\n#  define OPENSSL_SYS_BEOS\n#  include <sys/socket.h>\n#  if defined(BONE_VERSION)\n#   define OPENSSL_SYS_BEOS_BONE\n#  else\n#   define OPENSSL_SYS_BEOS_R5\n#  endif\n# endif\n\n/**\n * That's it for OS-specific stuff\n *****************************************************************************/\n\n/* Specials for I/O an exit */\n# ifdef OPENSSL_SYS_MSDOS\n#  define OPENSSL_UNISTD_IO <io.h>\n#  define OPENSSL_DECLARE_EXIT extern void exit(int);\n# else\n#  define OPENSSL_UNISTD_IO OPENSSL_UNISTD\n#  define OPENSSL_DECLARE_EXIT  /* declared in unistd.h */\n# endif\n\n/*-\n * Definitions of OPENSSL_GLOBAL and OPENSSL_EXTERN, to define and declare\n * certain global symbols that, with some compilers under VMS, have to be\n * defined and declared explicitely with globaldef and globalref.\n * Definitions of OPENSSL_EXPORT and OPENSSL_IMPORT, to define and declare\n * DLL exports and imports for compilers under Win32.  These are a little\n * more complicated to use.  Basically, for any library that exports some\n * global variables, the following code must be present in the header file\n * that declares them, before OPENSSL_EXTERN is used:\n *\n * #ifdef SOME_BUILD_FLAG_MACRO\n * # undef OPENSSL_EXTERN\n * # define OPENSSL_EXTERN OPENSSL_EXPORT\n * #endif\n *\n * The default is to have OPENSSL_EXPORT, OPENSSL_IMPORT and OPENSSL_GLOBAL\n * have some generally sensible values, and for OPENSSL_EXTERN to have the\n * value OPENSSL_IMPORT.\n */\n\n# if defined(OPENSSL_SYS_VMS_NODECC)\n#  define OPENSSL_EXPORT globalref\n#  define OPENSSL_IMPORT globalref\n#  define OPENSSL_GLOBAL globaldef\n# elif defined(OPENSSL_SYS_WINDOWS) && defined(OPENSSL_OPT_WINDLL)\n#  define OPENSSL_EXPORT extern __declspec(dllexport)\n#  define OPENSSL_IMPORT extern __declspec(dllimport)\n#  define OPENSSL_GLOBAL\n# else\n#  define OPENSSL_EXPORT extern\n#  define OPENSSL_IMPORT extern\n#  define OPENSSL_GLOBAL\n# endif\n# define OPENSSL_EXTERN OPENSSL_IMPORT\n\n/*-\n * Macros to allow global variables to be reached through function calls when\n * required (if a shared library version requires it, for example.\n * The way it's done allows definitions like this:\n *\n *      // in foobar.c\n *      OPENSSL_IMPLEMENT_GLOBAL(int,foobar,0)\n *      // in foobar.h\n *      OPENSSL_DECLARE_GLOBAL(int,foobar);\n *      #define foobar OPENSSL_GLOBAL_REF(foobar)\n */\n# ifdef OPENSSL_EXPORT_VAR_AS_FUNCTION\n#  define OPENSSL_IMPLEMENT_GLOBAL(type,name,value)                      \\\n        type *_shadow_##name(void)                                      \\\n        { static type _hide_##name=value; return &_hide_##name; }\n#  define OPENSSL_DECLARE_GLOBAL(type,name) type *_shadow_##name(void)\n#  define OPENSSL_GLOBAL_REF(name) (*(_shadow_##name()))\n# else\n#  define OPENSSL_IMPLEMENT_GLOBAL(type,name,value) OPENSSL_GLOBAL type _shadow_##name=value;\n#  define OPENSSL_DECLARE_GLOBAL(type,name) OPENSSL_EXPORT type _shadow_##name\n#  define OPENSSL_GLOBAL_REF(name) _shadow_##name\n# endif\n\n# if defined(OPENSSL_SYS_MACINTOSH_CLASSIC) && macintosh==1 && !defined(MAC_OS_GUSI_SOURCE)\n#  define ossl_ssize_t long\n# endif\n\n# ifdef OPENSSL_SYS_MSDOS\n#  define ossl_ssize_t long\n# endif\n\n# if defined(NeXT) || defined(OPENSSL_SYS_NEWS4) || defined(OPENSSL_SYS_SUNOS)\n#  define ssize_t int\n# endif\n\n# if defined(__ultrix) && !defined(ssize_t)\n#  define ossl_ssize_t int\n# endif\n\n# ifndef ossl_ssize_t\n#  define ossl_ssize_t ssize_t\n# endif\n\n#ifdef  __cplusplus\n}\n#endif\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/x86_64/include/openssl/ebcdic.h",
    "content": "/* crypto/ebcdic.h */\n\n#ifndef HEADER_EBCDIC_H\n# define HEADER_EBCDIC_H\n\n# include <sys/types.h>\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n/* Avoid name clashes with other applications */\n# define os_toascii   _openssl_os_toascii\n# define os_toebcdic  _openssl_os_toebcdic\n# define ebcdic2ascii _openssl_ebcdic2ascii\n# define ascii2ebcdic _openssl_ascii2ebcdic\n\nextern const unsigned char os_toascii[256];\nextern const unsigned char os_toebcdic[256];\nvoid *ebcdic2ascii(void *dest, const void *srce, size_t count);\nvoid *ascii2ebcdic(void *dest, const void *srce, size_t count);\n\n#ifdef  __cplusplus\n}\n#endif\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/x86_64/include/openssl/err.h",
    "content": "/* crypto/err/err.h */\n/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)\n * All rights reserved.\n *\n * This package is an SSL implementation written\n * by Eric Young (eay@cryptsoft.com).\n * The implementation was written so as to conform with Netscapes SSL.\n *\n * This library is free for commercial and non-commercial use as long as\n * the following conditions are aheared to.  The following conditions\n * apply to all code found in this distribution, be it the RC4, RSA,\n * lhash, DES, etc., code; not just the SSL code.  The SSL documentation\n * included with this distribution is covered by the same copyright terms\n * except that the holder is Tim Hudson (tjh@cryptsoft.com).\n *\n * Copyright remains Eric Young's, and as such any Copyright notices in\n * the code are not to be removed.\n * If this package is used in a product, Eric Young should be given attribution\n * as the author of the parts of the library used.\n * This can be in the form of a textual message at program startup or\n * in documentation (online or textual) provided with the package.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the copyright\n *    notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in the\n *    documentation and/or other materials provided with the distribution.\n * 3. All advertising materials mentioning features or use of this software\n *    must display the following acknowledgement:\n *    \"This product includes cryptographic software written by\n *     Eric Young (eay@cryptsoft.com)\"\n *    The word 'cryptographic' can be left out if the rouines from the library\n *    being used are not cryptographic related :-).\n * 4. If you include any Windows specific code (or a derivative thereof) from\n *    the apps directory (application code) you must include an acknowledgement:\n *    \"This product includes software written by Tim Hudson (tjh@cryptsoft.com)\"\n *\n * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n * SUCH DAMAGE.\n *\n * The licence and distribution terms for any publically available version or\n * derivative of this code cannot be changed.  i.e. this code cannot simply be\n * copied and put under another distribution licence\n * [including the GNU Public Licence.]\n */\n/* ====================================================================\n * Copyright (c) 1998-2006 The OpenSSL Project.  All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n *\n * 1. Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n *\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in\n *    the documentation and/or other materials provided with the\n *    distribution.\n *\n * 3. All advertising materials mentioning features or use of this\n *    software must display the following acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit. (http://www.openssl.org/)\"\n *\n * 4. The names \"OpenSSL Toolkit\" and \"OpenSSL Project\" must not be used to\n *    endorse or promote products derived from this software without\n *    prior written permission. For written permission, please contact\n *    openssl-core@openssl.org.\n *\n * 5. Products derived from this software may not be called \"OpenSSL\"\n *    nor may \"OpenSSL\" appear in their names without prior written\n *    permission of the OpenSSL Project.\n *\n * 6. Redistributions of any form whatsoever must retain the following\n *    acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit (http://www.openssl.org/)\"\n *\n * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY\n * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\n * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR\n * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\n * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,\n * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED\n * OF THE POSSIBILITY OF SUCH DAMAGE.\n * ====================================================================\n *\n * This product includes cryptographic software written by Eric Young\n * (eay@cryptsoft.com).  This product includes software written by Tim\n * Hudson (tjh@cryptsoft.com).\n *\n */\n\n#ifndef HEADER_ERR_H\n# define HEADER_ERR_H\n\n# include <openssl/e_os2.h>\n\n# ifndef OPENSSL_NO_FP_API\n#  include <stdio.h>\n#  include <stdlib.h>\n# endif\n\n# include <openssl/ossl_typ.h>\n# ifndef OPENSSL_NO_BIO\n#  include <openssl/bio.h>\n# endif\n# ifndef OPENSSL_NO_LHASH\n#  include <openssl/lhash.h>\n# endif\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n# ifndef OPENSSL_NO_ERR\n#  define ERR_PUT_error(a,b,c,d,e)        ERR_put_error(a,b,c,d,e)\n# else\n#  define ERR_PUT_error(a,b,c,d,e)        ERR_put_error(a,b,c,NULL,0)\n# endif\n\n# include <errno.h>\n\n# define ERR_TXT_MALLOCED        0x01\n# define ERR_TXT_STRING          0x02\n\n# define ERR_FLAG_MARK           0x01\n\n# define ERR_NUM_ERRORS  16\ntypedef struct err_state_st {\n    CRYPTO_THREADID tid;\n    int err_flags[ERR_NUM_ERRORS];\n    unsigned long err_buffer[ERR_NUM_ERRORS];\n    char *err_data[ERR_NUM_ERRORS];\n    int err_data_flags[ERR_NUM_ERRORS];\n    const char *err_file[ERR_NUM_ERRORS];\n    int err_line[ERR_NUM_ERRORS];\n    int top, bottom;\n} ERR_STATE;\n\n/* library */\n# define ERR_LIB_NONE            1\n# define ERR_LIB_SYS             2\n# define ERR_LIB_BN              3\n# define ERR_LIB_RSA             4\n# define ERR_LIB_DH              5\n# define ERR_LIB_EVP             6\n# define ERR_LIB_BUF             7\n# define ERR_LIB_OBJ             8\n# define ERR_LIB_PEM             9\n# define ERR_LIB_DSA             10\n# define ERR_LIB_X509            11\n/* #define ERR_LIB_METH         12 */\n# define ERR_LIB_ASN1            13\n# define ERR_LIB_CONF            14\n# define ERR_LIB_CRYPTO          15\n# define ERR_LIB_EC              16\n# define ERR_LIB_SSL             20\n/* #define ERR_LIB_SSL23        21 */\n/* #define ERR_LIB_SSL2         22 */\n/* #define ERR_LIB_SSL3         23 */\n/* #define ERR_LIB_RSAREF       30 */\n/* #define ERR_LIB_PROXY        31 */\n# define ERR_LIB_BIO             32\n# define ERR_LIB_PKCS7           33\n# define ERR_LIB_X509V3          34\n# define ERR_LIB_PKCS12          35\n# define ERR_LIB_RAND            36\n# define ERR_LIB_DSO             37\n# define ERR_LIB_ENGINE          38\n# define ERR_LIB_OCSP            39\n# define ERR_LIB_UI              40\n# define ERR_LIB_COMP            41\n# define ERR_LIB_ECDSA           42\n# define ERR_LIB_ECDH            43\n# define ERR_LIB_STORE           44\n# define ERR_LIB_FIPS            45\n# define ERR_LIB_CMS             46\n# define ERR_LIB_TS              47\n# define ERR_LIB_HMAC            48\n# define ERR_LIB_JPAKE           49\n\n# define ERR_LIB_USER            128\n\n# define SYSerr(f,r)  ERR_PUT_error(ERR_LIB_SYS,(f),(r),__FILE__,__LINE__)\n# define BNerr(f,r)   ERR_PUT_error(ERR_LIB_BN,(f),(r),__FILE__,__LINE__)\n# define RSAerr(f,r)  ERR_PUT_error(ERR_LIB_RSA,(f),(r),__FILE__,__LINE__)\n# define DHerr(f,r)   ERR_PUT_error(ERR_LIB_DH,(f),(r),__FILE__,__LINE__)\n# define EVPerr(f,r)  ERR_PUT_error(ERR_LIB_EVP,(f),(r),__FILE__,__LINE__)\n# define BUFerr(f,r)  ERR_PUT_error(ERR_LIB_BUF,(f),(r),__FILE__,__LINE__)\n# define OBJerr(f,r)  ERR_PUT_error(ERR_LIB_OBJ,(f),(r),__FILE__,__LINE__)\n# define PEMerr(f,r)  ERR_PUT_error(ERR_LIB_PEM,(f),(r),__FILE__,__LINE__)\n# define DSAerr(f,r)  ERR_PUT_error(ERR_LIB_DSA,(f),(r),__FILE__,__LINE__)\n# define X509err(f,r) ERR_PUT_error(ERR_LIB_X509,(f),(r),__FILE__,__LINE__)\n# define ASN1err(f,r) ERR_PUT_error(ERR_LIB_ASN1,(f),(r),__FILE__,__LINE__)\n# define CONFerr(f,r) ERR_PUT_error(ERR_LIB_CONF,(f),(r),__FILE__,__LINE__)\n# define CRYPTOerr(f,r) ERR_PUT_error(ERR_LIB_CRYPTO,(f),(r),__FILE__,__LINE__)\n# define ECerr(f,r)   ERR_PUT_error(ERR_LIB_EC,(f),(r),__FILE__,__LINE__)\n# define SSLerr(f,r)  ERR_PUT_error(ERR_LIB_SSL,(f),(r),__FILE__,__LINE__)\n# define BIOerr(f,r)  ERR_PUT_error(ERR_LIB_BIO,(f),(r),__FILE__,__LINE__)\n# define PKCS7err(f,r) ERR_PUT_error(ERR_LIB_PKCS7,(f),(r),__FILE__,__LINE__)\n# define X509V3err(f,r) ERR_PUT_error(ERR_LIB_X509V3,(f),(r),__FILE__,__LINE__)\n# define PKCS12err(f,r) ERR_PUT_error(ERR_LIB_PKCS12,(f),(r),__FILE__,__LINE__)\n# define RANDerr(f,r) ERR_PUT_error(ERR_LIB_RAND,(f),(r),__FILE__,__LINE__)\n# define DSOerr(f,r) ERR_PUT_error(ERR_LIB_DSO,(f),(r),__FILE__,__LINE__)\n# define ENGINEerr(f,r) ERR_PUT_error(ERR_LIB_ENGINE,(f),(r),__FILE__,__LINE__)\n# define OCSPerr(f,r) ERR_PUT_error(ERR_LIB_OCSP,(f),(r),__FILE__,__LINE__)\n# define UIerr(f,r) ERR_PUT_error(ERR_LIB_UI,(f),(r),__FILE__,__LINE__)\n# define COMPerr(f,r) ERR_PUT_error(ERR_LIB_COMP,(f),(r),__FILE__,__LINE__)\n# define ECDSAerr(f,r)  ERR_PUT_error(ERR_LIB_ECDSA,(f),(r),__FILE__,__LINE__)\n# define ECDHerr(f,r)  ERR_PUT_error(ERR_LIB_ECDH,(f),(r),__FILE__,__LINE__)\n# define STOREerr(f,r) ERR_PUT_error(ERR_LIB_STORE,(f),(r),__FILE__,__LINE__)\n# define FIPSerr(f,r) ERR_PUT_error(ERR_LIB_FIPS,(f),(r),__FILE__,__LINE__)\n# define CMSerr(f,r) ERR_PUT_error(ERR_LIB_CMS,(f),(r),__FILE__,__LINE__)\n# define TSerr(f,r) ERR_PUT_error(ERR_LIB_TS,(f),(r),__FILE__,__LINE__)\n# define HMACerr(f,r) ERR_PUT_error(ERR_LIB_HMAC,(f),(r),__FILE__,__LINE__)\n# define JPAKEerr(f,r) ERR_PUT_error(ERR_LIB_JPAKE,(f),(r),__FILE__,__LINE__)\n\n/*\n * Borland C seems too stupid to be able to shift and do longs in the\n * pre-processor :-(\n */\n# define ERR_PACK(l,f,r)         (((((unsigned long)l)&0xffL)*0x1000000)| \\\n                                ((((unsigned long)f)&0xfffL)*0x1000)| \\\n                                ((((unsigned long)r)&0xfffL)))\n# define ERR_GET_LIB(l)          (int)((((unsigned long)l)>>24L)&0xffL)\n# define ERR_GET_FUNC(l)         (int)((((unsigned long)l)>>12L)&0xfffL)\n# define ERR_GET_REASON(l)       (int)((l)&0xfffL)\n# define ERR_FATAL_ERROR(l)      (int)((l)&ERR_R_FATAL)\n\n/* OS functions */\n# define SYS_F_FOPEN             1\n# define SYS_F_CONNECT           2\n# define SYS_F_GETSERVBYNAME     3\n# define SYS_F_SOCKET            4\n# define SYS_F_IOCTLSOCKET       5\n# define SYS_F_BIND              6\n# define SYS_F_LISTEN            7\n# define SYS_F_ACCEPT            8\n# define SYS_F_WSASTARTUP        9/* Winsock stuff */\n# define SYS_F_OPENDIR           10\n# define SYS_F_FREAD             11\n\n/* reasons */\n# define ERR_R_SYS_LIB   ERR_LIB_SYS/* 2 */\n# define ERR_R_BN_LIB    ERR_LIB_BN/* 3 */\n# define ERR_R_RSA_LIB   ERR_LIB_RSA/* 4 */\n# define ERR_R_DH_LIB    ERR_LIB_DH/* 5 */\n# define ERR_R_EVP_LIB   ERR_LIB_EVP/* 6 */\n# define ERR_R_BUF_LIB   ERR_LIB_BUF/* 7 */\n# define ERR_R_OBJ_LIB   ERR_LIB_OBJ/* 8 */\n# define ERR_R_PEM_LIB   ERR_LIB_PEM/* 9 */\n# define ERR_R_DSA_LIB   ERR_LIB_DSA/* 10 */\n# define ERR_R_X509_LIB  ERR_LIB_X509/* 11 */\n# define ERR_R_ASN1_LIB  ERR_LIB_ASN1/* 13 */\n# define ERR_R_CONF_LIB  ERR_LIB_CONF/* 14 */\n# define ERR_R_CRYPTO_LIB ERR_LIB_CRYPTO/* 15 */\n# define ERR_R_EC_LIB    ERR_LIB_EC/* 16 */\n# define ERR_R_SSL_LIB   ERR_LIB_SSL/* 20 */\n# define ERR_R_BIO_LIB   ERR_LIB_BIO/* 32 */\n# define ERR_R_PKCS7_LIB ERR_LIB_PKCS7/* 33 */\n# define ERR_R_X509V3_LIB ERR_LIB_X509V3/* 34 */\n# define ERR_R_PKCS12_LIB ERR_LIB_PKCS12/* 35 */\n# define ERR_R_RAND_LIB  ERR_LIB_RAND/* 36 */\n# define ERR_R_DSO_LIB   ERR_LIB_DSO/* 37 */\n# define ERR_R_ENGINE_LIB ERR_LIB_ENGINE/* 38 */\n# define ERR_R_OCSP_LIB  ERR_LIB_OCSP/* 39 */\n# define ERR_R_UI_LIB    ERR_LIB_UI/* 40 */\n# define ERR_R_COMP_LIB  ERR_LIB_COMP/* 41 */\n# define ERR_R_ECDSA_LIB ERR_LIB_ECDSA/* 42 */\n# define ERR_R_ECDH_LIB  ERR_LIB_ECDH/* 43 */\n# define ERR_R_STORE_LIB ERR_LIB_STORE/* 44 */\n# define ERR_R_TS_LIB    ERR_LIB_TS/* 45 */\n\n# define ERR_R_NESTED_ASN1_ERROR                 58\n# define ERR_R_BAD_ASN1_OBJECT_HEADER            59\n# define ERR_R_BAD_GET_ASN1_OBJECT_CALL          60\n# define ERR_R_EXPECTING_AN_ASN1_SEQUENCE        61\n# define ERR_R_ASN1_LENGTH_MISMATCH              62\n# define ERR_R_MISSING_ASN1_EOS                  63\n\n/* fatal error */\n# define ERR_R_FATAL                             64\n# define ERR_R_MALLOC_FAILURE                    (1|ERR_R_FATAL)\n# define ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED       (2|ERR_R_FATAL)\n# define ERR_R_PASSED_NULL_PARAMETER             (3|ERR_R_FATAL)\n# define ERR_R_INTERNAL_ERROR                    (4|ERR_R_FATAL)\n# define ERR_R_DISABLED                          (5|ERR_R_FATAL)\n\n/*\n * 99 is the maximum possible ERR_R_... code, higher values are reserved for\n * the individual libraries\n */\n\ntypedef struct ERR_string_data_st {\n    unsigned long error;\n    const char *string;\n} ERR_STRING_DATA;\n\nvoid ERR_put_error(int lib, int func, int reason, const char *file, int line);\nvoid ERR_set_error_data(char *data, int flags);\n\nunsigned long ERR_get_error(void);\nunsigned long ERR_get_error_line(const char **file, int *line);\nunsigned long ERR_get_error_line_data(const char **file, int *line,\n                                      const char **data, int *flags);\nunsigned long ERR_peek_error(void);\nunsigned long ERR_peek_error_line(const char **file, int *line);\nunsigned long ERR_peek_error_line_data(const char **file, int *line,\n                                       const char **data, int *flags);\nunsigned long ERR_peek_last_error(void);\nunsigned long ERR_peek_last_error_line(const char **file, int *line);\nunsigned long ERR_peek_last_error_line_data(const char **file, int *line,\n                                            const char **data, int *flags);\nvoid ERR_clear_error(void);\nchar *ERR_error_string(unsigned long e, char *buf);\nvoid ERR_error_string_n(unsigned long e, char *buf, size_t len);\nconst char *ERR_lib_error_string(unsigned long e);\nconst char *ERR_func_error_string(unsigned long e);\nconst char *ERR_reason_error_string(unsigned long e);\nvoid ERR_print_errors_cb(int (*cb) (const char *str, size_t len, void *u),\n                         void *u);\n# ifndef OPENSSL_NO_FP_API\nvoid ERR_print_errors_fp(FILE *fp);\n# endif\n# ifndef OPENSSL_NO_BIO\nvoid ERR_print_errors(BIO *bp);\n# endif\nvoid ERR_add_error_data(int num, ...);\nvoid ERR_add_error_vdata(int num, va_list args);\nvoid ERR_load_strings(int lib, ERR_STRING_DATA str[]);\nvoid ERR_unload_strings(int lib, ERR_STRING_DATA str[]);\nvoid ERR_load_ERR_strings(void);\nvoid ERR_load_crypto_strings(void);\nvoid ERR_free_strings(void);\n\nvoid ERR_remove_thread_state(const CRYPTO_THREADID *tid);\n# ifndef OPENSSL_NO_DEPRECATED\nvoid ERR_remove_state(unsigned long pid); /* if zero we look it up */\n# endif\nERR_STATE *ERR_get_state(void);\n\n# ifndef OPENSSL_NO_LHASH\nLHASH_OF(ERR_STRING_DATA) *ERR_get_string_table(void);\nLHASH_OF(ERR_STATE) *ERR_get_err_state_table(void);\nvoid ERR_release_err_state_table(LHASH_OF(ERR_STATE) **hash);\n# endif\n\nint ERR_get_next_error_library(void);\n\nint ERR_set_mark(void);\nint ERR_pop_to_mark(void);\n\n/* Already defined in ossl_typ.h */\n/* typedef struct st_ERR_FNS ERR_FNS; */\n/*\n * An application can use this function and provide the return value to\n * loaded modules that should use the application's ERR state/functionality\n */\nconst ERR_FNS *ERR_get_implementation(void);\n/*\n * A loaded module should call this function prior to any ERR operations\n * using the application's \"ERR_FNS\".\n */\nint ERR_set_implementation(const ERR_FNS *fns);\n\n#ifdef  __cplusplus\n}\n#endif\n\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/x86_64/include/openssl/evp.h",
    "content": "/* crypto/evp/evp.h */\n/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)\n * All rights reserved.\n *\n * This package is an SSL implementation written\n * by Eric Young (eay@cryptsoft.com).\n * The implementation was written so as to conform with Netscapes SSL.\n *\n * This library is free for commercial and non-commercial use as long as\n * the following conditions are aheared to.  The following conditions\n * apply to all code found in this distribution, be it the RC4, RSA,\n * lhash, DES, etc., code; not just the SSL code.  The SSL documentation\n * included with this distribution is covered by the same copyright terms\n * except that the holder is Tim Hudson (tjh@cryptsoft.com).\n *\n * Copyright remains Eric Young's, and as such any Copyright notices in\n * the code are not to be removed.\n * If this package is used in a product, Eric Young should be given attribution\n * as the author of the parts of the library used.\n * This can be in the form of a textual message at program startup or\n * in documentation (online or textual) provided with the package.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the copyright\n *    notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in the\n *    documentation and/or other materials provided with the distribution.\n * 3. All advertising materials mentioning features or use of this software\n *    must display the following acknowledgement:\n *    \"This product includes cryptographic software written by\n *     Eric Young (eay@cryptsoft.com)\"\n *    The word 'cryptographic' can be left out if the rouines from the library\n *    being used are not cryptographic related :-).\n * 4. If you include any Windows specific code (or a derivative thereof) from\n *    the apps directory (application code) you must include an acknowledgement:\n *    \"This product includes software written by Tim Hudson (tjh@cryptsoft.com)\"\n *\n * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n * SUCH DAMAGE.\n *\n * The licence and distribution terms for any publically available version or\n * derivative of this code cannot be changed.  i.e. this code cannot simply be\n * copied and put under another distribution licence\n * [including the GNU Public Licence.]\n */\n\n#ifndef HEADER_ENVELOPE_H\n# define HEADER_ENVELOPE_H\n\n# ifdef OPENSSL_ALGORITHM_DEFINES\n#  include <openssl/opensslconf.h>\n# else\n#  define OPENSSL_ALGORITHM_DEFINES\n#  include <openssl/opensslconf.h>\n#  undef OPENSSL_ALGORITHM_DEFINES\n# endif\n\n# include <openssl/ossl_typ.h>\n\n# include <openssl/symhacks.h>\n\n# ifndef OPENSSL_NO_BIO\n#  include <openssl/bio.h>\n# endif\n\n/*-\n#define EVP_RC2_KEY_SIZE                16\n#define EVP_RC4_KEY_SIZE                16\n#define EVP_BLOWFISH_KEY_SIZE           16\n#define EVP_CAST5_KEY_SIZE              16\n#define EVP_RC5_32_12_16_KEY_SIZE       16\n*/\n# define EVP_MAX_MD_SIZE                 64/* longest known is SHA512 */\n# define EVP_MAX_KEY_LENGTH              64\n# define EVP_MAX_IV_LENGTH               16\n# define EVP_MAX_BLOCK_LENGTH            32\n\n# define PKCS5_SALT_LEN                  8\n/* Default PKCS#5 iteration count */\n# define PKCS5_DEFAULT_ITER              2048\n\n# include <openssl/objects.h>\n\n# define EVP_PK_RSA      0x0001\n# define EVP_PK_DSA      0x0002\n# define EVP_PK_DH       0x0004\n# define EVP_PK_EC       0x0008\n# define EVP_PKT_SIGN    0x0010\n# define EVP_PKT_ENC     0x0020\n# define EVP_PKT_EXCH    0x0040\n# define EVP_PKS_RSA     0x0100\n# define EVP_PKS_DSA     0x0200\n# define EVP_PKS_EC      0x0400\n\n# define EVP_PKEY_NONE   NID_undef\n# define EVP_PKEY_RSA    NID_rsaEncryption\n# define EVP_PKEY_RSA2   NID_rsa\n# define EVP_PKEY_DSA    NID_dsa\n# define EVP_PKEY_DSA1   NID_dsa_2\n# define EVP_PKEY_DSA2   NID_dsaWithSHA\n# define EVP_PKEY_DSA3   NID_dsaWithSHA1\n# define EVP_PKEY_DSA4   NID_dsaWithSHA1_2\n# define EVP_PKEY_DH     NID_dhKeyAgreement\n# define EVP_PKEY_DHX    NID_dhpublicnumber\n# define EVP_PKEY_EC     NID_X9_62_id_ecPublicKey\n# define EVP_PKEY_HMAC   NID_hmac\n# define EVP_PKEY_CMAC   NID_cmac\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n/*\n * Type needs to be a bit field Sub-type needs to be for variations on the\n * method, as in, can it do arbitrary encryption....\n */\nstruct evp_pkey_st {\n    int type;\n    int save_type;\n    int references;\n    const EVP_PKEY_ASN1_METHOD *ameth;\n    ENGINE *engine;\n    union {\n        char *ptr;\n# ifndef OPENSSL_NO_RSA\n        struct rsa_st *rsa;     /* RSA */\n# endif\n# ifndef OPENSSL_NO_DSA\n        struct dsa_st *dsa;     /* DSA */\n# endif\n# ifndef OPENSSL_NO_DH\n        struct dh_st *dh;       /* DH */\n# endif\n# ifndef OPENSSL_NO_EC\n        struct ec_key_st *ec;   /* ECC */\n# endif\n    } pkey;\n    int save_parameters;\n    STACK_OF(X509_ATTRIBUTE) *attributes; /* [ 0 ] */\n} /* EVP_PKEY */ ;\n\n# define EVP_PKEY_MO_SIGN        0x0001\n# define EVP_PKEY_MO_VERIFY      0x0002\n# define EVP_PKEY_MO_ENCRYPT     0x0004\n# define EVP_PKEY_MO_DECRYPT     0x0008\n\n# ifndef EVP_MD\nstruct env_md_st {\n    int type;\n    int pkey_type;\n    int md_size;\n    unsigned long flags;\n    int (*init) (EVP_MD_CTX *ctx);\n    int (*update) (EVP_MD_CTX *ctx, const void *data, size_t count);\n    int (*final) (EVP_MD_CTX *ctx, unsigned char *md);\n    int (*copy) (EVP_MD_CTX *to, const EVP_MD_CTX *from);\n    int (*cleanup) (EVP_MD_CTX *ctx);\n    /* FIXME: prototype these some day */\n    int (*sign) (int type, const unsigned char *m, unsigned int m_length,\n                 unsigned char *sigret, unsigned int *siglen, void *key);\n    int (*verify) (int type, const unsigned char *m, unsigned int m_length,\n                   const unsigned char *sigbuf, unsigned int siglen,\n                   void *key);\n    int required_pkey_type[5];  /* EVP_PKEY_xxx */\n    int block_size;\n    int ctx_size;               /* how big does the ctx->md_data need to be */\n    /* control function */\n    int (*md_ctrl) (EVP_MD_CTX *ctx, int cmd, int p1, void *p2);\n} /* EVP_MD */ ;\n\ntypedef int evp_sign_method(int type, const unsigned char *m,\n                            unsigned int m_length, unsigned char *sigret,\n                            unsigned int *siglen, void *key);\ntypedef int evp_verify_method(int type, const unsigned char *m,\n                              unsigned int m_length,\n                              const unsigned char *sigbuf,\n                              unsigned int siglen, void *key);\n\n/* digest can only handle a single block */\n#  define EVP_MD_FLAG_ONESHOT     0x0001\n\n/*\n * digest is a \"clone\" digest used\n * which is a copy of an existing\n * one for a specific public key type.\n * EVP_dss1() etc\n */\n#  define EVP_MD_FLAG_PKEY_DIGEST 0x0002\n\n/* Digest uses EVP_PKEY_METHOD for signing instead of MD specific signing */\n\n#  define EVP_MD_FLAG_PKEY_METHOD_SIGNATURE       0x0004\n\n/* DigestAlgorithmIdentifier flags... */\n\n#  define EVP_MD_FLAG_DIGALGID_MASK               0x0018\n\n/* NULL or absent parameter accepted. Use NULL */\n\n#  define EVP_MD_FLAG_DIGALGID_NULL               0x0000\n\n/* NULL or absent parameter accepted. Use NULL for PKCS#1 otherwise absent */\n\n#  define EVP_MD_FLAG_DIGALGID_ABSENT             0x0008\n\n/* Custom handling via ctrl */\n\n#  define EVP_MD_FLAG_DIGALGID_CUSTOM             0x0018\n\n/* Note if suitable for use in FIPS mode */\n#  define EVP_MD_FLAG_FIPS        0x0400\n\n/* Digest ctrls */\n\n#  define EVP_MD_CTRL_DIGALGID                    0x1\n#  define EVP_MD_CTRL_MICALG                      0x2\n\n/* Minimum Algorithm specific ctrl value */\n\n#  define EVP_MD_CTRL_ALG_CTRL                    0x1000\n\n#  define EVP_PKEY_NULL_method    NULL,NULL,{0,0,0,0}\n\n#  ifndef OPENSSL_NO_DSA\n#   define EVP_PKEY_DSA_method     (evp_sign_method *)DSA_sign, \\\n                                (evp_verify_method *)DSA_verify, \\\n                                {EVP_PKEY_DSA,EVP_PKEY_DSA2,EVP_PKEY_DSA3, \\\n                                        EVP_PKEY_DSA4,0}\n#  else\n#   define EVP_PKEY_DSA_method     EVP_PKEY_NULL_method\n#  endif\n\n#  ifndef OPENSSL_NO_ECDSA\n#   define EVP_PKEY_ECDSA_method   (evp_sign_method *)ECDSA_sign, \\\n                                (evp_verify_method *)ECDSA_verify, \\\n                                 {EVP_PKEY_EC,0,0,0}\n#  else\n#   define EVP_PKEY_ECDSA_method   EVP_PKEY_NULL_method\n#  endif\n\n#  ifndef OPENSSL_NO_RSA\n#   define EVP_PKEY_RSA_method     (evp_sign_method *)RSA_sign, \\\n                                (evp_verify_method *)RSA_verify, \\\n                                {EVP_PKEY_RSA,EVP_PKEY_RSA2,0,0}\n#   define EVP_PKEY_RSA_ASN1_OCTET_STRING_method \\\n                                (evp_sign_method *)RSA_sign_ASN1_OCTET_STRING, \\\n                                (evp_verify_method *)RSA_verify_ASN1_OCTET_STRING, \\\n                                {EVP_PKEY_RSA,EVP_PKEY_RSA2,0,0}\n#  else\n#   define EVP_PKEY_RSA_method     EVP_PKEY_NULL_method\n#   define EVP_PKEY_RSA_ASN1_OCTET_STRING_method EVP_PKEY_NULL_method\n#  endif\n\n# endif                         /* !EVP_MD */\n\nstruct env_md_ctx_st {\n    const EVP_MD *digest;\n    ENGINE *engine;             /* functional reference if 'digest' is\n                                 * ENGINE-provided */\n    unsigned long flags;\n    void *md_data;\n    /* Public key context for sign/verify */\n    EVP_PKEY_CTX *pctx;\n    /* Update function: usually copied from EVP_MD */\n    int (*update) (EVP_MD_CTX *ctx, const void *data, size_t count);\n} /* EVP_MD_CTX */ ;\n\n/* values for EVP_MD_CTX flags */\n\n# define EVP_MD_CTX_FLAG_ONESHOT         0x0001/* digest update will be\n                                                * called once only */\n# define EVP_MD_CTX_FLAG_CLEANED         0x0002/* context has already been\n                                                * cleaned */\n# define EVP_MD_CTX_FLAG_REUSE           0x0004/* Don't free up ctx->md_data\n                                                * in EVP_MD_CTX_cleanup */\n/*\n * FIPS and pad options are ignored in 1.0.0, definitions are here so we\n * don't accidentally reuse the values for other purposes.\n */\n\n# define EVP_MD_CTX_FLAG_NON_FIPS_ALLOW  0x0008/* Allow use of non FIPS\n                                                * digest in FIPS mode */\n\n/*\n * The following PAD options are also currently ignored in 1.0.0, digest\n * parameters are handled through EVP_DigestSign*() and EVP_DigestVerify*()\n * instead.\n */\n# define EVP_MD_CTX_FLAG_PAD_MASK        0xF0/* RSA mode to use */\n# define EVP_MD_CTX_FLAG_PAD_PKCS1       0x00/* PKCS#1 v1.5 mode */\n# define EVP_MD_CTX_FLAG_PAD_X931        0x10/* X9.31 mode */\n# define EVP_MD_CTX_FLAG_PAD_PSS         0x20/* PSS mode */\n\n# define EVP_MD_CTX_FLAG_NO_INIT         0x0100/* Don't initialize md_data */\n\nstruct evp_cipher_st {\n    int nid;\n    int block_size;\n    /* Default value for variable length ciphers */\n    int key_len;\n    int iv_len;\n    /* Various flags */\n    unsigned long flags;\n    /* init key */\n    int (*init) (EVP_CIPHER_CTX *ctx, const unsigned char *key,\n                 const unsigned char *iv, int enc);\n    /* encrypt/decrypt data */\n    int (*do_cipher) (EVP_CIPHER_CTX *ctx, unsigned char *out,\n                      const unsigned char *in, size_t inl);\n    /* cleanup ctx */\n    int (*cleanup) (EVP_CIPHER_CTX *);\n    /* how big ctx->cipher_data needs to be */\n    int ctx_size;\n    /* Populate a ASN1_TYPE with parameters */\n    int (*set_asn1_parameters) (EVP_CIPHER_CTX *, ASN1_TYPE *);\n    /* Get parameters from a ASN1_TYPE */\n    int (*get_asn1_parameters) (EVP_CIPHER_CTX *, ASN1_TYPE *);\n    /* Miscellaneous operations */\n    int (*ctrl) (EVP_CIPHER_CTX *, int type, int arg, void *ptr);\n    /* Application data */\n    void *app_data;\n} /* EVP_CIPHER */ ;\n\n/* Values for cipher flags */\n\n/* Modes for ciphers */\n\n# define         EVP_CIPH_STREAM_CIPHER          0x0\n# define         EVP_CIPH_ECB_MODE               0x1\n# define         EVP_CIPH_CBC_MODE               0x2\n# define         EVP_CIPH_CFB_MODE               0x3\n# define         EVP_CIPH_OFB_MODE               0x4\n# define         EVP_CIPH_CTR_MODE               0x5\n# define         EVP_CIPH_GCM_MODE               0x6\n# define         EVP_CIPH_CCM_MODE               0x7\n# define         EVP_CIPH_XTS_MODE               0x10001\n# define         EVP_CIPH_WRAP_MODE              0x10002\n# define         EVP_CIPH_MODE                   0xF0007\n/* Set if variable length cipher */\n# define         EVP_CIPH_VARIABLE_LENGTH        0x8\n/* Set if the iv handling should be done by the cipher itself */\n# define         EVP_CIPH_CUSTOM_IV              0x10\n/* Set if the cipher's init() function should be called if key is NULL */\n# define         EVP_CIPH_ALWAYS_CALL_INIT       0x20\n/* Call ctrl() to init cipher parameters */\n# define         EVP_CIPH_CTRL_INIT              0x40\n/* Don't use standard key length function */\n# define         EVP_CIPH_CUSTOM_KEY_LENGTH      0x80\n/* Don't use standard block padding */\n# define         EVP_CIPH_NO_PADDING             0x100\n/* cipher handles random key generation */\n# define         EVP_CIPH_RAND_KEY               0x200\n/* cipher has its own additional copying logic */\n# define         EVP_CIPH_CUSTOM_COPY            0x400\n/* Allow use default ASN1 get/set iv */\n# define         EVP_CIPH_FLAG_DEFAULT_ASN1      0x1000\n/* Buffer length in bits not bytes: CFB1 mode only */\n# define         EVP_CIPH_FLAG_LENGTH_BITS       0x2000\n/* Note if suitable for use in FIPS mode */\n# define         EVP_CIPH_FLAG_FIPS              0x4000\n/* Allow non FIPS cipher in FIPS mode */\n# define         EVP_CIPH_FLAG_NON_FIPS_ALLOW    0x8000\n/*\n * Cipher handles any and all padding logic as well as finalisation.\n */\n# define         EVP_CIPH_FLAG_CUSTOM_CIPHER     0x100000\n# define         EVP_CIPH_FLAG_AEAD_CIPHER       0x200000\n# define         EVP_CIPH_FLAG_TLS1_1_MULTIBLOCK 0x400000\n\n/*\n * Cipher context flag to indicate we can handle wrap mode: if allowed in\n * older applications it could overflow buffers.\n */\n\n# define         EVP_CIPHER_CTX_FLAG_WRAP_ALLOW  0x1\n\n/* ctrl() values */\n\n# define         EVP_CTRL_INIT                   0x0\n# define         EVP_CTRL_SET_KEY_LENGTH         0x1\n# define         EVP_CTRL_GET_RC2_KEY_BITS       0x2\n# define         EVP_CTRL_SET_RC2_KEY_BITS       0x3\n# define         EVP_CTRL_GET_RC5_ROUNDS         0x4\n# define         EVP_CTRL_SET_RC5_ROUNDS         0x5\n# define         EVP_CTRL_RAND_KEY               0x6\n# define         EVP_CTRL_PBE_PRF_NID            0x7\n# define         EVP_CTRL_COPY                   0x8\n# define         EVP_CTRL_GCM_SET_IVLEN          0x9\n# define         EVP_CTRL_GCM_GET_TAG            0x10\n# define         EVP_CTRL_GCM_SET_TAG            0x11\n# define         EVP_CTRL_GCM_SET_IV_FIXED       0x12\n# define         EVP_CTRL_GCM_IV_GEN             0x13\n# define         EVP_CTRL_CCM_SET_IVLEN          EVP_CTRL_GCM_SET_IVLEN\n# define         EVP_CTRL_CCM_GET_TAG            EVP_CTRL_GCM_GET_TAG\n# define         EVP_CTRL_CCM_SET_TAG            EVP_CTRL_GCM_SET_TAG\n# define         EVP_CTRL_CCM_SET_L              0x14\n# define         EVP_CTRL_CCM_SET_MSGLEN         0x15\n/*\n * AEAD cipher deduces payload length and returns number of bytes required to\n * store MAC and eventual padding. Subsequent call to EVP_Cipher even\n * appends/verifies MAC.\n */\n# define         EVP_CTRL_AEAD_TLS1_AAD          0x16\n/* Used by composite AEAD ciphers, no-op in GCM, CCM... */\n# define         EVP_CTRL_AEAD_SET_MAC_KEY       0x17\n/* Set the GCM invocation field, decrypt only */\n# define         EVP_CTRL_GCM_SET_IV_INV         0x18\n\n# define         EVP_CTRL_TLS1_1_MULTIBLOCK_AAD  0x19\n# define         EVP_CTRL_TLS1_1_MULTIBLOCK_ENCRYPT      0x1a\n# define         EVP_CTRL_TLS1_1_MULTIBLOCK_DECRYPT      0x1b\n# define         EVP_CTRL_TLS1_1_MULTIBLOCK_MAX_BUFSIZE  0x1c\n\n/* RFC 5246 defines additional data to be 13 bytes in length */\n# define         EVP_AEAD_TLS1_AAD_LEN           13\n\ntypedef struct {\n    unsigned char *out;\n    const unsigned char *inp;\n    size_t len;\n    unsigned int interleave;\n} EVP_CTRL_TLS1_1_MULTIBLOCK_PARAM;\n\n/* GCM TLS constants */\n/* Length of fixed part of IV derived from PRF */\n# define EVP_GCM_TLS_FIXED_IV_LEN                        4\n/* Length of explicit part of IV part of TLS records */\n# define EVP_GCM_TLS_EXPLICIT_IV_LEN                     8\n/* Length of tag for TLS */\n# define EVP_GCM_TLS_TAG_LEN                             16\n\ntypedef struct evp_cipher_info_st {\n    const EVP_CIPHER *cipher;\n    unsigned char iv[EVP_MAX_IV_LENGTH];\n} EVP_CIPHER_INFO;\n\nstruct evp_cipher_ctx_st {\n    const EVP_CIPHER *cipher;\n    ENGINE *engine;             /* functional reference if 'cipher' is\n                                 * ENGINE-provided */\n    int encrypt;                /* encrypt or decrypt */\n    int buf_len;                /* number we have left */\n    unsigned char oiv[EVP_MAX_IV_LENGTH]; /* original iv */\n    unsigned char iv[EVP_MAX_IV_LENGTH]; /* working iv */\n    unsigned char buf[EVP_MAX_BLOCK_LENGTH]; /* saved partial block */\n    int num;                    /* used by cfb/ofb/ctr mode */\n    void *app_data;             /* application stuff */\n    int key_len;                /* May change for variable length cipher */\n    unsigned long flags;        /* Various flags */\n    void *cipher_data;          /* per EVP data */\n    int final_used;\n    int block_mask;\n    unsigned char final[EVP_MAX_BLOCK_LENGTH]; /* possible final block */\n} /* EVP_CIPHER_CTX */ ;\n\ntypedef struct evp_Encode_Ctx_st {\n    /* number saved in a partial encode/decode */\n    int num;\n    /*\n     * The length is either the output line length (in input bytes) or the\n     * shortest input line length that is ok.  Once decoding begins, the\n     * length is adjusted up each time a longer line is decoded\n     */\n    int length;\n    /* data to encode */\n    unsigned char enc_data[80];\n    /* number read on current line */\n    int line_num;\n    int expect_nl;\n} EVP_ENCODE_CTX;\n\n/* Password based encryption function */\ntypedef int (EVP_PBE_KEYGEN) (EVP_CIPHER_CTX *ctx, const char *pass,\n                              int passlen, ASN1_TYPE *param,\n                              const EVP_CIPHER *cipher, const EVP_MD *md,\n                              int en_de);\n\n# ifndef OPENSSL_NO_RSA\n#  define EVP_PKEY_assign_RSA(pkey,rsa) EVP_PKEY_assign((pkey),EVP_PKEY_RSA,\\\n                                        (char *)(rsa))\n# endif\n\n# ifndef OPENSSL_NO_DSA\n#  define EVP_PKEY_assign_DSA(pkey,dsa) EVP_PKEY_assign((pkey),EVP_PKEY_DSA,\\\n                                        (char *)(dsa))\n# endif\n\n# ifndef OPENSSL_NO_DH\n#  define EVP_PKEY_assign_DH(pkey,dh) EVP_PKEY_assign((pkey),EVP_PKEY_DH,\\\n                                        (char *)(dh))\n# endif\n\n# ifndef OPENSSL_NO_EC\n#  define EVP_PKEY_assign_EC_KEY(pkey,eckey) EVP_PKEY_assign((pkey),EVP_PKEY_EC,\\\n                                        (char *)(eckey))\n# endif\n\n/* Add some extra combinations */\n# define EVP_get_digestbynid(a) EVP_get_digestbyname(OBJ_nid2sn(a))\n# define EVP_get_digestbyobj(a) EVP_get_digestbynid(OBJ_obj2nid(a))\n# define EVP_get_cipherbynid(a) EVP_get_cipherbyname(OBJ_nid2sn(a))\n# define EVP_get_cipherbyobj(a) EVP_get_cipherbynid(OBJ_obj2nid(a))\n\nint EVP_MD_type(const EVP_MD *md);\n# define EVP_MD_nid(e)                   EVP_MD_type(e)\n# define EVP_MD_name(e)                  OBJ_nid2sn(EVP_MD_nid(e))\nint EVP_MD_pkey_type(const EVP_MD *md);\nint EVP_MD_size(const EVP_MD *md);\nint EVP_MD_block_size(const EVP_MD *md);\nunsigned long EVP_MD_flags(const EVP_MD *md);\n\nconst EVP_MD *EVP_MD_CTX_md(const EVP_MD_CTX *ctx);\n# define EVP_MD_CTX_size(e)              EVP_MD_size(EVP_MD_CTX_md(e))\n# define EVP_MD_CTX_block_size(e)        EVP_MD_block_size(EVP_MD_CTX_md(e))\n# define EVP_MD_CTX_type(e)              EVP_MD_type(EVP_MD_CTX_md(e))\n\nint EVP_CIPHER_nid(const EVP_CIPHER *cipher);\n# define EVP_CIPHER_name(e)              OBJ_nid2sn(EVP_CIPHER_nid(e))\nint EVP_CIPHER_block_size(const EVP_CIPHER *cipher);\nint EVP_CIPHER_key_length(const EVP_CIPHER *cipher);\nint EVP_CIPHER_iv_length(const EVP_CIPHER *cipher);\nunsigned long EVP_CIPHER_flags(const EVP_CIPHER *cipher);\n# define EVP_CIPHER_mode(e)              (EVP_CIPHER_flags(e) & EVP_CIPH_MODE)\n\nconst EVP_CIPHER *EVP_CIPHER_CTX_cipher(const EVP_CIPHER_CTX *ctx);\nint EVP_CIPHER_CTX_nid(const EVP_CIPHER_CTX *ctx);\nint EVP_CIPHER_CTX_block_size(const EVP_CIPHER_CTX *ctx);\nint EVP_CIPHER_CTX_key_length(const EVP_CIPHER_CTX *ctx);\nint EVP_CIPHER_CTX_iv_length(const EVP_CIPHER_CTX *ctx);\nint EVP_CIPHER_CTX_copy(EVP_CIPHER_CTX *out, const EVP_CIPHER_CTX *in);\nvoid *EVP_CIPHER_CTX_get_app_data(const EVP_CIPHER_CTX *ctx);\nvoid EVP_CIPHER_CTX_set_app_data(EVP_CIPHER_CTX *ctx, void *data);\n# define EVP_CIPHER_CTX_type(c)         EVP_CIPHER_type(EVP_CIPHER_CTX_cipher(c))\nunsigned long EVP_CIPHER_CTX_flags(const EVP_CIPHER_CTX *ctx);\n# define EVP_CIPHER_CTX_mode(e)          (EVP_CIPHER_CTX_flags(e) & EVP_CIPH_MODE)\n\n# define EVP_ENCODE_LENGTH(l)    (((l+2)/3*4)+(l/48+1)*2+80)\n# define EVP_DECODE_LENGTH(l)    ((l+3)/4*3+80)\n\n# define EVP_SignInit_ex(a,b,c)          EVP_DigestInit_ex(a,b,c)\n# define EVP_SignInit(a,b)               EVP_DigestInit(a,b)\n# define EVP_SignUpdate(a,b,c)           EVP_DigestUpdate(a,b,c)\n# define EVP_VerifyInit_ex(a,b,c)        EVP_DigestInit_ex(a,b,c)\n# define EVP_VerifyInit(a,b)             EVP_DigestInit(a,b)\n# define EVP_VerifyUpdate(a,b,c)         EVP_DigestUpdate(a,b,c)\n# define EVP_OpenUpdate(a,b,c,d,e)       EVP_DecryptUpdate(a,b,c,d,e)\n# define EVP_SealUpdate(a,b,c,d,e)       EVP_EncryptUpdate(a,b,c,d,e)\n# define EVP_DigestSignUpdate(a,b,c)     EVP_DigestUpdate(a,b,c)\n# define EVP_DigestVerifyUpdate(a,b,c)   EVP_DigestUpdate(a,b,c)\n\n# ifdef CONST_STRICT\nvoid BIO_set_md(BIO *, const EVP_MD *md);\n# else\n#  define BIO_set_md(b,md)               BIO_ctrl(b,BIO_C_SET_MD,0,(char *)md)\n# endif\n# define BIO_get_md(b,mdp)               BIO_ctrl(b,BIO_C_GET_MD,0,(char *)mdp)\n# define BIO_get_md_ctx(b,mdcp)     BIO_ctrl(b,BIO_C_GET_MD_CTX,0,(char *)mdcp)\n# define BIO_set_md_ctx(b,mdcp)     BIO_ctrl(b,BIO_C_SET_MD_CTX,0,(char *)mdcp)\n# define BIO_get_cipher_status(b)        BIO_ctrl(b,BIO_C_GET_CIPHER_STATUS,0,NULL)\n# define BIO_get_cipher_ctx(b,c_pp)      BIO_ctrl(b,BIO_C_GET_CIPHER_CTX,0,(char *)c_pp)\n\nint EVP_Cipher(EVP_CIPHER_CTX *c,\n               unsigned char *out, const unsigned char *in, unsigned int inl);\n\n# define EVP_add_cipher_alias(n,alias) \\\n        OBJ_NAME_add((alias),OBJ_NAME_TYPE_CIPHER_METH|OBJ_NAME_ALIAS,(n))\n# define EVP_add_digest_alias(n,alias) \\\n        OBJ_NAME_add((alias),OBJ_NAME_TYPE_MD_METH|OBJ_NAME_ALIAS,(n))\n# define EVP_delete_cipher_alias(alias) \\\n        OBJ_NAME_remove(alias,OBJ_NAME_TYPE_CIPHER_METH|OBJ_NAME_ALIAS);\n# define EVP_delete_digest_alias(alias) \\\n        OBJ_NAME_remove(alias,OBJ_NAME_TYPE_MD_METH|OBJ_NAME_ALIAS);\n\nvoid EVP_MD_CTX_init(EVP_MD_CTX *ctx);\nint EVP_MD_CTX_cleanup(EVP_MD_CTX *ctx);\nEVP_MD_CTX *EVP_MD_CTX_create(void);\nvoid EVP_MD_CTX_destroy(EVP_MD_CTX *ctx);\nint EVP_MD_CTX_copy_ex(EVP_MD_CTX *out, const EVP_MD_CTX *in);\nvoid EVP_MD_CTX_set_flags(EVP_MD_CTX *ctx, int flags);\nvoid EVP_MD_CTX_clear_flags(EVP_MD_CTX *ctx, int flags);\nint EVP_MD_CTX_test_flags(const EVP_MD_CTX *ctx, int flags);\nint EVP_DigestInit_ex(EVP_MD_CTX *ctx, const EVP_MD *type, ENGINE *impl);\nint EVP_DigestUpdate(EVP_MD_CTX *ctx, const void *d, size_t cnt);\nint EVP_DigestFinal_ex(EVP_MD_CTX *ctx, unsigned char *md, unsigned int *s);\nint EVP_Digest(const void *data, size_t count,\n               unsigned char *md, unsigned int *size, const EVP_MD *type,\n               ENGINE *impl);\n\nint EVP_MD_CTX_copy(EVP_MD_CTX *out, const EVP_MD_CTX *in);\nint EVP_DigestInit(EVP_MD_CTX *ctx, const EVP_MD *type);\nint EVP_DigestFinal(EVP_MD_CTX *ctx, unsigned char *md, unsigned int *s);\n\nint EVP_read_pw_string(char *buf, int length, const char *prompt, int verify);\nint EVP_read_pw_string_min(char *buf, int minlen, int maxlen,\n                           const char *prompt, int verify);\nvoid EVP_set_pw_prompt(const char *prompt);\nchar *EVP_get_pw_prompt(void);\n\nint EVP_BytesToKey(const EVP_CIPHER *type, const EVP_MD *md,\n                   const unsigned char *salt, const unsigned char *data,\n                   int datal, int count, unsigned char *key,\n                   unsigned char *iv);\n\nvoid EVP_CIPHER_CTX_set_flags(EVP_CIPHER_CTX *ctx, int flags);\nvoid EVP_CIPHER_CTX_clear_flags(EVP_CIPHER_CTX *ctx, int flags);\nint EVP_CIPHER_CTX_test_flags(const EVP_CIPHER_CTX *ctx, int flags);\n\nint EVP_EncryptInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher,\n                    const unsigned char *key, const unsigned char *iv);\nint EVP_EncryptInit_ex(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher,\n                       ENGINE *impl, const unsigned char *key,\n                       const unsigned char *iv);\nint EVP_EncryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl,\n                      const unsigned char *in, int inl);\nint EVP_EncryptFinal_ex(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl);\nint EVP_EncryptFinal(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl);\n\nint EVP_DecryptInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher,\n                    const unsigned char *key, const unsigned char *iv);\nint EVP_DecryptInit_ex(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher,\n                       ENGINE *impl, const unsigned char *key,\n                       const unsigned char *iv);\nint EVP_DecryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl,\n                      const unsigned char *in, int inl);\nint EVP_DecryptFinal(EVP_CIPHER_CTX *ctx, unsigned char *outm, int *outl);\nint EVP_DecryptFinal_ex(EVP_CIPHER_CTX *ctx, unsigned char *outm, int *outl);\n\nint EVP_CipherInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher,\n                   const unsigned char *key, const unsigned char *iv,\n                   int enc);\nint EVP_CipherInit_ex(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher,\n                      ENGINE *impl, const unsigned char *key,\n                      const unsigned char *iv, int enc);\nint EVP_CipherUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl,\n                     const unsigned char *in, int inl);\nint EVP_CipherFinal(EVP_CIPHER_CTX *ctx, unsigned char *outm, int *outl);\nint EVP_CipherFinal_ex(EVP_CIPHER_CTX *ctx, unsigned char *outm, int *outl);\n\nint EVP_SignFinal(EVP_MD_CTX *ctx, unsigned char *md, unsigned int *s,\n                  EVP_PKEY *pkey);\n\nint EVP_VerifyFinal(EVP_MD_CTX *ctx, const unsigned char *sigbuf,\n                    unsigned int siglen, EVP_PKEY *pkey);\n\nint EVP_DigestSignInit(EVP_MD_CTX *ctx, EVP_PKEY_CTX **pctx,\n                       const EVP_MD *type, ENGINE *e, EVP_PKEY *pkey);\nint EVP_DigestSignFinal(EVP_MD_CTX *ctx,\n                        unsigned char *sigret, size_t *siglen);\n\nint EVP_DigestVerifyInit(EVP_MD_CTX *ctx, EVP_PKEY_CTX **pctx,\n                         const EVP_MD *type, ENGINE *e, EVP_PKEY *pkey);\nint EVP_DigestVerifyFinal(EVP_MD_CTX *ctx,\n                          const unsigned char *sig, size_t siglen);\n\nint EVP_OpenInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *type,\n                 const unsigned char *ek, int ekl, const unsigned char *iv,\n                 EVP_PKEY *priv);\nint EVP_OpenFinal(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl);\n\nint EVP_SealInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *type,\n                 unsigned char **ek, int *ekl, unsigned char *iv,\n                 EVP_PKEY **pubk, int npubk);\nint EVP_SealFinal(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl);\n\nvoid EVP_EncodeInit(EVP_ENCODE_CTX *ctx);\nvoid EVP_EncodeUpdate(EVP_ENCODE_CTX *ctx, unsigned char *out, int *outl,\n                      const unsigned char *in, int inl);\nvoid EVP_EncodeFinal(EVP_ENCODE_CTX *ctx, unsigned char *out, int *outl);\nint EVP_EncodeBlock(unsigned char *t, const unsigned char *f, int n);\n\nvoid EVP_DecodeInit(EVP_ENCODE_CTX *ctx);\nint EVP_DecodeUpdate(EVP_ENCODE_CTX *ctx, unsigned char *out, int *outl,\n                     const unsigned char *in, int inl);\nint EVP_DecodeFinal(EVP_ENCODE_CTX *ctx, unsigned\n                    char *out, int *outl);\nint EVP_DecodeBlock(unsigned char *t, const unsigned char *f, int n);\n\nvoid EVP_CIPHER_CTX_init(EVP_CIPHER_CTX *a);\nint EVP_CIPHER_CTX_cleanup(EVP_CIPHER_CTX *a);\nEVP_CIPHER_CTX *EVP_CIPHER_CTX_new(void);\nvoid EVP_CIPHER_CTX_free(EVP_CIPHER_CTX *a);\nint EVP_CIPHER_CTX_set_key_length(EVP_CIPHER_CTX *x, int keylen);\nint EVP_CIPHER_CTX_set_padding(EVP_CIPHER_CTX *c, int pad);\nint EVP_CIPHER_CTX_ctrl(EVP_CIPHER_CTX *ctx, int type, int arg, void *ptr);\nint EVP_CIPHER_CTX_rand_key(EVP_CIPHER_CTX *ctx, unsigned char *key);\n\n# ifndef OPENSSL_NO_BIO\nBIO_METHOD *BIO_f_md(void);\nBIO_METHOD *BIO_f_base64(void);\nBIO_METHOD *BIO_f_cipher(void);\nBIO_METHOD *BIO_f_reliable(void);\nvoid BIO_set_cipher(BIO *b, const EVP_CIPHER *c, const unsigned char *k,\n                    const unsigned char *i, int enc);\n# endif\n\nconst EVP_MD *EVP_md_null(void);\n# ifndef OPENSSL_NO_MD2\nconst EVP_MD *EVP_md2(void);\n# endif\n# ifndef OPENSSL_NO_MD4\nconst EVP_MD *EVP_md4(void);\n# endif\n# ifndef OPENSSL_NO_MD5\nconst EVP_MD *EVP_md5(void);\n# endif\n# ifndef OPENSSL_NO_SHA\nconst EVP_MD *EVP_sha(void);\nconst EVP_MD *EVP_sha1(void);\nconst EVP_MD *EVP_dss(void);\nconst EVP_MD *EVP_dss1(void);\nconst EVP_MD *EVP_ecdsa(void);\n# endif\n# ifndef OPENSSL_NO_SHA256\nconst EVP_MD *EVP_sha224(void);\nconst EVP_MD *EVP_sha256(void);\n# endif\n# ifndef OPENSSL_NO_SHA512\nconst EVP_MD *EVP_sha384(void);\nconst EVP_MD *EVP_sha512(void);\n# endif\n# ifndef OPENSSL_NO_MDC2\nconst EVP_MD *EVP_mdc2(void);\n# endif\n# ifndef OPENSSL_NO_RIPEMD\nconst EVP_MD *EVP_ripemd160(void);\n# endif\n# ifndef OPENSSL_NO_WHIRLPOOL\nconst EVP_MD *EVP_whirlpool(void);\n# endif\nconst EVP_CIPHER *EVP_enc_null(void); /* does nothing :-) */\n# ifndef OPENSSL_NO_DES\nconst EVP_CIPHER *EVP_des_ecb(void);\nconst EVP_CIPHER *EVP_des_ede(void);\nconst EVP_CIPHER *EVP_des_ede3(void);\nconst EVP_CIPHER *EVP_des_ede_ecb(void);\nconst EVP_CIPHER *EVP_des_ede3_ecb(void);\nconst EVP_CIPHER *EVP_des_cfb64(void);\n#  define EVP_des_cfb EVP_des_cfb64\nconst EVP_CIPHER *EVP_des_cfb1(void);\nconst EVP_CIPHER *EVP_des_cfb8(void);\nconst EVP_CIPHER *EVP_des_ede_cfb64(void);\n#  define EVP_des_ede_cfb EVP_des_ede_cfb64\n#  if 0\nconst EVP_CIPHER *EVP_des_ede_cfb1(void);\nconst EVP_CIPHER *EVP_des_ede_cfb8(void);\n#  endif\nconst EVP_CIPHER *EVP_des_ede3_cfb64(void);\n#  define EVP_des_ede3_cfb EVP_des_ede3_cfb64\nconst EVP_CIPHER *EVP_des_ede3_cfb1(void);\nconst EVP_CIPHER *EVP_des_ede3_cfb8(void);\nconst EVP_CIPHER *EVP_des_ofb(void);\nconst EVP_CIPHER *EVP_des_ede_ofb(void);\nconst EVP_CIPHER *EVP_des_ede3_ofb(void);\nconst EVP_CIPHER *EVP_des_cbc(void);\nconst EVP_CIPHER *EVP_des_ede_cbc(void);\nconst EVP_CIPHER *EVP_des_ede3_cbc(void);\nconst EVP_CIPHER *EVP_desx_cbc(void);\nconst EVP_CIPHER *EVP_des_ede3_wrap(void);\n/*\n * This should now be supported through the dev_crypto ENGINE. But also, why\n * are rc4 and md5 declarations made here inside a \"NO_DES\" precompiler\n * branch?\n */\n#  if 0\n#   ifdef OPENSSL_OPENBSD_DEV_CRYPTO\nconst EVP_CIPHER *EVP_dev_crypto_des_ede3_cbc(void);\nconst EVP_CIPHER *EVP_dev_crypto_rc4(void);\nconst EVP_MD *EVP_dev_crypto_md5(void);\n#   endif\n#  endif\n# endif\n# ifndef OPENSSL_NO_RC4\nconst EVP_CIPHER *EVP_rc4(void);\nconst EVP_CIPHER *EVP_rc4_40(void);\n#  ifndef OPENSSL_NO_MD5\nconst EVP_CIPHER *EVP_rc4_hmac_md5(void);\n#  endif\n# endif\n# ifndef OPENSSL_NO_IDEA\nconst EVP_CIPHER *EVP_idea_ecb(void);\nconst EVP_CIPHER *EVP_idea_cfb64(void);\n#  define EVP_idea_cfb EVP_idea_cfb64\nconst EVP_CIPHER *EVP_idea_ofb(void);\nconst EVP_CIPHER *EVP_idea_cbc(void);\n# endif\n# ifndef OPENSSL_NO_RC2\nconst EVP_CIPHER *EVP_rc2_ecb(void);\nconst EVP_CIPHER *EVP_rc2_cbc(void);\nconst EVP_CIPHER *EVP_rc2_40_cbc(void);\nconst EVP_CIPHER *EVP_rc2_64_cbc(void);\nconst EVP_CIPHER *EVP_rc2_cfb64(void);\n#  define EVP_rc2_cfb EVP_rc2_cfb64\nconst EVP_CIPHER *EVP_rc2_ofb(void);\n# endif\n# ifndef OPENSSL_NO_BF\nconst EVP_CIPHER *EVP_bf_ecb(void);\nconst EVP_CIPHER *EVP_bf_cbc(void);\nconst EVP_CIPHER *EVP_bf_cfb64(void);\n#  define EVP_bf_cfb EVP_bf_cfb64\nconst EVP_CIPHER *EVP_bf_ofb(void);\n# endif\n# ifndef OPENSSL_NO_CAST\nconst EVP_CIPHER *EVP_cast5_ecb(void);\nconst EVP_CIPHER *EVP_cast5_cbc(void);\nconst EVP_CIPHER *EVP_cast5_cfb64(void);\n#  define EVP_cast5_cfb EVP_cast5_cfb64\nconst EVP_CIPHER *EVP_cast5_ofb(void);\n# endif\n# ifndef OPENSSL_NO_RC5\nconst EVP_CIPHER *EVP_rc5_32_12_16_cbc(void);\nconst EVP_CIPHER *EVP_rc5_32_12_16_ecb(void);\nconst EVP_CIPHER *EVP_rc5_32_12_16_cfb64(void);\n#  define EVP_rc5_32_12_16_cfb EVP_rc5_32_12_16_cfb64\nconst EVP_CIPHER *EVP_rc5_32_12_16_ofb(void);\n# endif\n# ifndef OPENSSL_NO_AES\nconst EVP_CIPHER *EVP_aes_128_ecb(void);\nconst EVP_CIPHER *EVP_aes_128_cbc(void);\nconst EVP_CIPHER *EVP_aes_128_cfb1(void);\nconst EVP_CIPHER *EVP_aes_128_cfb8(void);\nconst EVP_CIPHER *EVP_aes_128_cfb128(void);\n#  define EVP_aes_128_cfb EVP_aes_128_cfb128\nconst EVP_CIPHER *EVP_aes_128_ofb(void);\nconst EVP_CIPHER *EVP_aes_128_ctr(void);\nconst EVP_CIPHER *EVP_aes_128_ccm(void);\nconst EVP_CIPHER *EVP_aes_128_gcm(void);\nconst EVP_CIPHER *EVP_aes_128_xts(void);\nconst EVP_CIPHER *EVP_aes_128_wrap(void);\nconst EVP_CIPHER *EVP_aes_192_ecb(void);\nconst EVP_CIPHER *EVP_aes_192_cbc(void);\nconst EVP_CIPHER *EVP_aes_192_cfb1(void);\nconst EVP_CIPHER *EVP_aes_192_cfb8(void);\nconst EVP_CIPHER *EVP_aes_192_cfb128(void);\n#  define EVP_aes_192_cfb EVP_aes_192_cfb128\nconst EVP_CIPHER *EVP_aes_192_ofb(void);\nconst EVP_CIPHER *EVP_aes_192_ctr(void);\nconst EVP_CIPHER *EVP_aes_192_ccm(void);\nconst EVP_CIPHER *EVP_aes_192_gcm(void);\nconst EVP_CIPHER *EVP_aes_192_wrap(void);\nconst EVP_CIPHER *EVP_aes_256_ecb(void);\nconst EVP_CIPHER *EVP_aes_256_cbc(void);\nconst EVP_CIPHER *EVP_aes_256_cfb1(void);\nconst EVP_CIPHER *EVP_aes_256_cfb8(void);\nconst EVP_CIPHER *EVP_aes_256_cfb128(void);\n#  define EVP_aes_256_cfb EVP_aes_256_cfb128\nconst EVP_CIPHER *EVP_aes_256_ofb(void);\nconst EVP_CIPHER *EVP_aes_256_ctr(void);\nconst EVP_CIPHER *EVP_aes_256_ccm(void);\nconst EVP_CIPHER *EVP_aes_256_gcm(void);\nconst EVP_CIPHER *EVP_aes_256_xts(void);\nconst EVP_CIPHER *EVP_aes_256_wrap(void);\n#  if !defined(OPENSSL_NO_SHA) && !defined(OPENSSL_NO_SHA1)\nconst EVP_CIPHER *EVP_aes_128_cbc_hmac_sha1(void);\nconst EVP_CIPHER *EVP_aes_256_cbc_hmac_sha1(void);\n#  endif\n#  ifndef OPENSSL_NO_SHA256\nconst EVP_CIPHER *EVP_aes_128_cbc_hmac_sha256(void);\nconst EVP_CIPHER *EVP_aes_256_cbc_hmac_sha256(void);\n#  endif\n# endif\n# ifndef OPENSSL_NO_CAMELLIA\nconst EVP_CIPHER *EVP_camellia_128_ecb(void);\nconst EVP_CIPHER *EVP_camellia_128_cbc(void);\nconst EVP_CIPHER *EVP_camellia_128_cfb1(void);\nconst EVP_CIPHER *EVP_camellia_128_cfb8(void);\nconst EVP_CIPHER *EVP_camellia_128_cfb128(void);\n#  define EVP_camellia_128_cfb EVP_camellia_128_cfb128\nconst EVP_CIPHER *EVP_camellia_128_ofb(void);\nconst EVP_CIPHER *EVP_camellia_192_ecb(void);\nconst EVP_CIPHER *EVP_camellia_192_cbc(void);\nconst EVP_CIPHER *EVP_camellia_192_cfb1(void);\nconst EVP_CIPHER *EVP_camellia_192_cfb8(void);\nconst EVP_CIPHER *EVP_camellia_192_cfb128(void);\n#  define EVP_camellia_192_cfb EVP_camellia_192_cfb128\nconst EVP_CIPHER *EVP_camellia_192_ofb(void);\nconst EVP_CIPHER *EVP_camellia_256_ecb(void);\nconst EVP_CIPHER *EVP_camellia_256_cbc(void);\nconst EVP_CIPHER *EVP_camellia_256_cfb1(void);\nconst EVP_CIPHER *EVP_camellia_256_cfb8(void);\nconst EVP_CIPHER *EVP_camellia_256_cfb128(void);\n#  define EVP_camellia_256_cfb EVP_camellia_256_cfb128\nconst EVP_CIPHER *EVP_camellia_256_ofb(void);\n# endif\n\n# ifndef OPENSSL_NO_SEED\nconst EVP_CIPHER *EVP_seed_ecb(void);\nconst EVP_CIPHER *EVP_seed_cbc(void);\nconst EVP_CIPHER *EVP_seed_cfb128(void);\n#  define EVP_seed_cfb EVP_seed_cfb128\nconst EVP_CIPHER *EVP_seed_ofb(void);\n# endif\n\nvoid OPENSSL_add_all_algorithms_noconf(void);\nvoid OPENSSL_add_all_algorithms_conf(void);\n\n# ifdef OPENSSL_LOAD_CONF\n#  define OpenSSL_add_all_algorithms() \\\n                OPENSSL_add_all_algorithms_conf()\n# else\n#  define OpenSSL_add_all_algorithms() \\\n                OPENSSL_add_all_algorithms_noconf()\n# endif\n\nvoid OpenSSL_add_all_ciphers(void);\nvoid OpenSSL_add_all_digests(void);\n# define SSLeay_add_all_algorithms() OpenSSL_add_all_algorithms()\n# define SSLeay_add_all_ciphers() OpenSSL_add_all_ciphers()\n# define SSLeay_add_all_digests() OpenSSL_add_all_digests()\n\nint EVP_add_cipher(const EVP_CIPHER *cipher);\nint EVP_add_digest(const EVP_MD *digest);\n\nconst EVP_CIPHER *EVP_get_cipherbyname(const char *name);\nconst EVP_MD *EVP_get_digestbyname(const char *name);\nvoid EVP_cleanup(void);\n\nvoid EVP_CIPHER_do_all(void (*fn) (const EVP_CIPHER *ciph,\n                                   const char *from, const char *to, void *x),\n                       void *arg);\nvoid EVP_CIPHER_do_all_sorted(void (*fn)\n                               (const EVP_CIPHER *ciph, const char *from,\n                                const char *to, void *x), void *arg);\n\nvoid EVP_MD_do_all(void (*fn) (const EVP_MD *ciph,\n                               const char *from, const char *to, void *x),\n                   void *arg);\nvoid EVP_MD_do_all_sorted(void (*fn)\n                           (const EVP_MD *ciph, const char *from,\n                            const char *to, void *x), void *arg);\n\nint EVP_PKEY_decrypt_old(unsigned char *dec_key,\n                         const unsigned char *enc_key, int enc_key_len,\n                         EVP_PKEY *private_key);\nint EVP_PKEY_encrypt_old(unsigned char *enc_key,\n                         const unsigned char *key, int key_len,\n                         EVP_PKEY *pub_key);\nint EVP_PKEY_type(int type);\nint EVP_PKEY_id(const EVP_PKEY *pkey);\nint EVP_PKEY_base_id(const EVP_PKEY *pkey);\nint EVP_PKEY_bits(EVP_PKEY *pkey);\nint EVP_PKEY_size(EVP_PKEY *pkey);\nint EVP_PKEY_set_type(EVP_PKEY *pkey, int type);\nint EVP_PKEY_set_type_str(EVP_PKEY *pkey, const char *str, int len);\nint EVP_PKEY_assign(EVP_PKEY *pkey, int type, void *key);\nvoid *EVP_PKEY_get0(EVP_PKEY *pkey);\n\n# ifndef OPENSSL_NO_RSA\nstruct rsa_st;\nint EVP_PKEY_set1_RSA(EVP_PKEY *pkey, struct rsa_st *key);\nstruct rsa_st *EVP_PKEY_get1_RSA(EVP_PKEY *pkey);\n# endif\n# ifndef OPENSSL_NO_DSA\nstruct dsa_st;\nint EVP_PKEY_set1_DSA(EVP_PKEY *pkey, struct dsa_st *key);\nstruct dsa_st *EVP_PKEY_get1_DSA(EVP_PKEY *pkey);\n# endif\n# ifndef OPENSSL_NO_DH\nstruct dh_st;\nint EVP_PKEY_set1_DH(EVP_PKEY *pkey, struct dh_st *key);\nstruct dh_st *EVP_PKEY_get1_DH(EVP_PKEY *pkey);\n# endif\n# ifndef OPENSSL_NO_EC\nstruct ec_key_st;\nint EVP_PKEY_set1_EC_KEY(EVP_PKEY *pkey, struct ec_key_st *key);\nstruct ec_key_st *EVP_PKEY_get1_EC_KEY(EVP_PKEY *pkey);\n# endif\n\nEVP_PKEY *EVP_PKEY_new(void);\nvoid EVP_PKEY_free(EVP_PKEY *pkey);\n\nEVP_PKEY *d2i_PublicKey(int type, EVP_PKEY **a, const unsigned char **pp,\n                        long length);\nint i2d_PublicKey(EVP_PKEY *a, unsigned char **pp);\n\nEVP_PKEY *d2i_PrivateKey(int type, EVP_PKEY **a, const unsigned char **pp,\n                         long length);\nEVP_PKEY *d2i_AutoPrivateKey(EVP_PKEY **a, const unsigned char **pp,\n                             long length);\nint i2d_PrivateKey(EVP_PKEY *a, unsigned char **pp);\n\nint EVP_PKEY_copy_parameters(EVP_PKEY *to, const EVP_PKEY *from);\nint EVP_PKEY_missing_parameters(const EVP_PKEY *pkey);\nint EVP_PKEY_save_parameters(EVP_PKEY *pkey, int mode);\nint EVP_PKEY_cmp_parameters(const EVP_PKEY *a, const EVP_PKEY *b);\n\nint EVP_PKEY_cmp(const EVP_PKEY *a, const EVP_PKEY *b);\n\nint EVP_PKEY_print_public(BIO *out, const EVP_PKEY *pkey,\n                          int indent, ASN1_PCTX *pctx);\nint EVP_PKEY_print_private(BIO *out, const EVP_PKEY *pkey,\n                           int indent, ASN1_PCTX *pctx);\nint EVP_PKEY_print_params(BIO *out, const EVP_PKEY *pkey,\n                          int indent, ASN1_PCTX *pctx);\n\nint EVP_PKEY_get_default_digest_nid(EVP_PKEY *pkey, int *pnid);\n\nint EVP_CIPHER_type(const EVP_CIPHER *ctx);\n\n/* calls methods */\nint EVP_CIPHER_param_to_asn1(EVP_CIPHER_CTX *c, ASN1_TYPE *type);\nint EVP_CIPHER_asn1_to_param(EVP_CIPHER_CTX *c, ASN1_TYPE *type);\n\n/* These are used by EVP_CIPHER methods */\nint EVP_CIPHER_set_asn1_iv(EVP_CIPHER_CTX *c, ASN1_TYPE *type);\nint EVP_CIPHER_get_asn1_iv(EVP_CIPHER_CTX *c, ASN1_TYPE *type);\n\n/* PKCS5 password based encryption */\nint PKCS5_PBE_keyivgen(EVP_CIPHER_CTX *ctx, const char *pass, int passlen,\n                       ASN1_TYPE *param, const EVP_CIPHER *cipher,\n                       const EVP_MD *md, int en_de);\nint PKCS5_PBKDF2_HMAC_SHA1(const char *pass, int passlen,\n                           const unsigned char *salt, int saltlen, int iter,\n                           int keylen, unsigned char *out);\nint PKCS5_PBKDF2_HMAC(const char *pass, int passlen,\n                      const unsigned char *salt, int saltlen, int iter,\n                      const EVP_MD *digest, int keylen, unsigned char *out);\nint PKCS5_v2_PBE_keyivgen(EVP_CIPHER_CTX *ctx, const char *pass, int passlen,\n                          ASN1_TYPE *param, const EVP_CIPHER *cipher,\n                          const EVP_MD *md, int en_de);\n\nvoid PKCS5_PBE_add(void);\n\nint EVP_PBE_CipherInit(ASN1_OBJECT *pbe_obj, const char *pass, int passlen,\n                       ASN1_TYPE *param, EVP_CIPHER_CTX *ctx, int en_de);\n\n/* PBE type */\n\n/* Can appear as the outermost AlgorithmIdentifier */\n# define EVP_PBE_TYPE_OUTER      0x0\n/* Is an PRF type OID */\n# define EVP_PBE_TYPE_PRF        0x1\n\nint EVP_PBE_alg_add_type(int pbe_type, int pbe_nid, int cipher_nid,\n                         int md_nid, EVP_PBE_KEYGEN *keygen);\nint EVP_PBE_alg_add(int nid, const EVP_CIPHER *cipher, const EVP_MD *md,\n                    EVP_PBE_KEYGEN *keygen);\nint EVP_PBE_find(int type, int pbe_nid, int *pcnid, int *pmnid,\n                 EVP_PBE_KEYGEN **pkeygen);\nvoid EVP_PBE_cleanup(void);\n\n# define ASN1_PKEY_ALIAS         0x1\n# define ASN1_PKEY_DYNAMIC       0x2\n# define ASN1_PKEY_SIGPARAM_NULL 0x4\n\n# define ASN1_PKEY_CTRL_PKCS7_SIGN       0x1\n# define ASN1_PKEY_CTRL_PKCS7_ENCRYPT    0x2\n# define ASN1_PKEY_CTRL_DEFAULT_MD_NID   0x3\n# define ASN1_PKEY_CTRL_CMS_SIGN         0x5\n# define ASN1_PKEY_CTRL_CMS_ENVELOPE     0x7\n# define ASN1_PKEY_CTRL_CMS_RI_TYPE      0x8\n\nint EVP_PKEY_asn1_get_count(void);\nconst EVP_PKEY_ASN1_METHOD *EVP_PKEY_asn1_get0(int idx);\nconst EVP_PKEY_ASN1_METHOD *EVP_PKEY_asn1_find(ENGINE **pe, int type);\nconst EVP_PKEY_ASN1_METHOD *EVP_PKEY_asn1_find_str(ENGINE **pe,\n                                                   const char *str, int len);\nint EVP_PKEY_asn1_add0(const EVP_PKEY_ASN1_METHOD *ameth);\nint EVP_PKEY_asn1_add_alias(int to, int from);\nint EVP_PKEY_asn1_get0_info(int *ppkey_id, int *pkey_base_id,\n                            int *ppkey_flags, const char **pinfo,\n                            const char **ppem_str,\n                            const EVP_PKEY_ASN1_METHOD *ameth);\n\nconst EVP_PKEY_ASN1_METHOD *EVP_PKEY_get0_asn1(EVP_PKEY *pkey);\nEVP_PKEY_ASN1_METHOD *EVP_PKEY_asn1_new(int id, int flags,\n                                        const char *pem_str,\n                                        const char *info);\nvoid EVP_PKEY_asn1_copy(EVP_PKEY_ASN1_METHOD *dst,\n                        const EVP_PKEY_ASN1_METHOD *src);\nvoid EVP_PKEY_asn1_free(EVP_PKEY_ASN1_METHOD *ameth);\nvoid EVP_PKEY_asn1_set_public(EVP_PKEY_ASN1_METHOD *ameth,\n                              int (*pub_decode) (EVP_PKEY *pk,\n                                                 X509_PUBKEY *pub),\n                              int (*pub_encode) (X509_PUBKEY *pub,\n                                                 const EVP_PKEY *pk),\n                              int (*pub_cmp) (const EVP_PKEY *a,\n                                              const EVP_PKEY *b),\n                              int (*pub_print) (BIO *out,\n                                                const EVP_PKEY *pkey,\n                                                int indent, ASN1_PCTX *pctx),\n                              int (*pkey_size) (const EVP_PKEY *pk),\n                              int (*pkey_bits) (const EVP_PKEY *pk));\nvoid EVP_PKEY_asn1_set_private(EVP_PKEY_ASN1_METHOD *ameth,\n                               int (*priv_decode) (EVP_PKEY *pk,\n                                                   PKCS8_PRIV_KEY_INFO\n                                                   *p8inf),\n                               int (*priv_encode) (PKCS8_PRIV_KEY_INFO *p8,\n                                                   const EVP_PKEY *pk),\n                               int (*priv_print) (BIO *out,\n                                                  const EVP_PKEY *pkey,\n                                                  int indent,\n                                                  ASN1_PCTX *pctx));\nvoid EVP_PKEY_asn1_set_param(EVP_PKEY_ASN1_METHOD *ameth,\n                             int (*param_decode) (EVP_PKEY *pkey,\n                                                  const unsigned char **pder,\n                                                  int derlen),\n                             int (*param_encode) (const EVP_PKEY *pkey,\n                                                  unsigned char **pder),\n                             int (*param_missing) (const EVP_PKEY *pk),\n                             int (*param_copy) (EVP_PKEY *to,\n                                                const EVP_PKEY *from),\n                             int (*param_cmp) (const EVP_PKEY *a,\n                                               const EVP_PKEY *b),\n                             int (*param_print) (BIO *out,\n                                                 const EVP_PKEY *pkey,\n                                                 int indent,\n                                                 ASN1_PCTX *pctx));\n\nvoid EVP_PKEY_asn1_set_free(EVP_PKEY_ASN1_METHOD *ameth,\n                            void (*pkey_free) (EVP_PKEY *pkey));\nvoid EVP_PKEY_asn1_set_ctrl(EVP_PKEY_ASN1_METHOD *ameth,\n                            int (*pkey_ctrl) (EVP_PKEY *pkey, int op,\n                                              long arg1, void *arg2));\nvoid EVP_PKEY_asn1_set_item(EVP_PKEY_ASN1_METHOD *ameth,\n                            int (*item_verify) (EVP_MD_CTX *ctx,\n                                                const ASN1_ITEM *it,\n                                                void *asn,\n                                                X509_ALGOR *a,\n                                                ASN1_BIT_STRING *sig,\n                                                EVP_PKEY *pkey),\n                            int (*item_sign) (EVP_MD_CTX *ctx,\n                                              const ASN1_ITEM *it,\n                                              void *asn,\n                                              X509_ALGOR *alg1,\n                                              X509_ALGOR *alg2,\n                                              ASN1_BIT_STRING *sig));\n\n# define EVP_PKEY_OP_UNDEFINED           0\n# define EVP_PKEY_OP_PARAMGEN            (1<<1)\n# define EVP_PKEY_OP_KEYGEN              (1<<2)\n# define EVP_PKEY_OP_SIGN                (1<<3)\n# define EVP_PKEY_OP_VERIFY              (1<<4)\n# define EVP_PKEY_OP_VERIFYRECOVER       (1<<5)\n# define EVP_PKEY_OP_SIGNCTX             (1<<6)\n# define EVP_PKEY_OP_VERIFYCTX           (1<<7)\n# define EVP_PKEY_OP_ENCRYPT             (1<<8)\n# define EVP_PKEY_OP_DECRYPT             (1<<9)\n# define EVP_PKEY_OP_DERIVE              (1<<10)\n\n# define EVP_PKEY_OP_TYPE_SIG    \\\n        (EVP_PKEY_OP_SIGN | EVP_PKEY_OP_VERIFY | EVP_PKEY_OP_VERIFYRECOVER \\\n                | EVP_PKEY_OP_SIGNCTX | EVP_PKEY_OP_VERIFYCTX)\n\n# define EVP_PKEY_OP_TYPE_CRYPT \\\n        (EVP_PKEY_OP_ENCRYPT | EVP_PKEY_OP_DECRYPT)\n\n# define EVP_PKEY_OP_TYPE_NOGEN \\\n        (EVP_PKEY_OP_SIG | EVP_PKEY_OP_CRYPT | EVP_PKEY_OP_DERIVE)\n\n# define EVP_PKEY_OP_TYPE_GEN \\\n                (EVP_PKEY_OP_PARAMGEN | EVP_PKEY_OP_KEYGEN)\n\n# define  EVP_PKEY_CTX_set_signature_md(ctx, md) \\\n                EVP_PKEY_CTX_ctrl(ctx, -1, EVP_PKEY_OP_TYPE_SIG,  \\\n                                        EVP_PKEY_CTRL_MD, 0, (void *)md)\n\n# define  EVP_PKEY_CTX_get_signature_md(ctx, pmd)        \\\n                EVP_PKEY_CTX_ctrl(ctx, -1, EVP_PKEY_OP_TYPE_SIG,  \\\n                                        EVP_PKEY_CTRL_GET_MD, 0, (void *)pmd)\n\n# define EVP_PKEY_CTRL_MD                1\n# define EVP_PKEY_CTRL_PEER_KEY          2\n\n# define EVP_PKEY_CTRL_PKCS7_ENCRYPT     3\n# define EVP_PKEY_CTRL_PKCS7_DECRYPT     4\n\n# define EVP_PKEY_CTRL_PKCS7_SIGN        5\n\n# define EVP_PKEY_CTRL_SET_MAC_KEY       6\n\n# define EVP_PKEY_CTRL_DIGESTINIT        7\n\n/* Used by GOST key encryption in TLS */\n# define EVP_PKEY_CTRL_SET_IV            8\n\n# define EVP_PKEY_CTRL_CMS_ENCRYPT       9\n# define EVP_PKEY_CTRL_CMS_DECRYPT       10\n# define EVP_PKEY_CTRL_CMS_SIGN          11\n\n# define EVP_PKEY_CTRL_CIPHER            12\n\n# define EVP_PKEY_CTRL_GET_MD            13\n\n# define EVP_PKEY_ALG_CTRL               0x1000\n\n# define EVP_PKEY_FLAG_AUTOARGLEN        2\n/*\n * Method handles all operations: don't assume any digest related defaults.\n */\n# define EVP_PKEY_FLAG_SIGCTX_CUSTOM     4\n\nconst EVP_PKEY_METHOD *EVP_PKEY_meth_find(int type);\nEVP_PKEY_METHOD *EVP_PKEY_meth_new(int id, int flags);\nvoid EVP_PKEY_meth_get0_info(int *ppkey_id, int *pflags,\n                             const EVP_PKEY_METHOD *meth);\nvoid EVP_PKEY_meth_copy(EVP_PKEY_METHOD *dst, const EVP_PKEY_METHOD *src);\nvoid EVP_PKEY_meth_free(EVP_PKEY_METHOD *pmeth);\nint EVP_PKEY_meth_add0(const EVP_PKEY_METHOD *pmeth);\n\nEVP_PKEY_CTX *EVP_PKEY_CTX_new(EVP_PKEY *pkey, ENGINE *e);\nEVP_PKEY_CTX *EVP_PKEY_CTX_new_id(int id, ENGINE *e);\nEVP_PKEY_CTX *EVP_PKEY_CTX_dup(EVP_PKEY_CTX *ctx);\nvoid EVP_PKEY_CTX_free(EVP_PKEY_CTX *ctx);\n\nint EVP_PKEY_CTX_ctrl(EVP_PKEY_CTX *ctx, int keytype, int optype,\n                      int cmd, int p1, void *p2);\nint EVP_PKEY_CTX_ctrl_str(EVP_PKEY_CTX *ctx, const char *type,\n                          const char *value);\n\nint EVP_PKEY_CTX_get_operation(EVP_PKEY_CTX *ctx);\nvoid EVP_PKEY_CTX_set0_keygen_info(EVP_PKEY_CTX *ctx, int *dat, int datlen);\n\nEVP_PKEY *EVP_PKEY_new_mac_key(int type, ENGINE *e,\n                               const unsigned char *key, int keylen);\n\nvoid EVP_PKEY_CTX_set_data(EVP_PKEY_CTX *ctx, void *data);\nvoid *EVP_PKEY_CTX_get_data(EVP_PKEY_CTX *ctx);\nEVP_PKEY *EVP_PKEY_CTX_get0_pkey(EVP_PKEY_CTX *ctx);\n\nEVP_PKEY *EVP_PKEY_CTX_get0_peerkey(EVP_PKEY_CTX *ctx);\n\nvoid EVP_PKEY_CTX_set_app_data(EVP_PKEY_CTX *ctx, void *data);\nvoid *EVP_PKEY_CTX_get_app_data(EVP_PKEY_CTX *ctx);\n\nint EVP_PKEY_sign_init(EVP_PKEY_CTX *ctx);\nint EVP_PKEY_sign(EVP_PKEY_CTX *ctx,\n                  unsigned char *sig, size_t *siglen,\n                  const unsigned char *tbs, size_t tbslen);\nint EVP_PKEY_verify_init(EVP_PKEY_CTX *ctx);\nint EVP_PKEY_verify(EVP_PKEY_CTX *ctx,\n                    const unsigned char *sig, size_t siglen,\n                    const unsigned char *tbs, size_t tbslen);\nint EVP_PKEY_verify_recover_init(EVP_PKEY_CTX *ctx);\nint EVP_PKEY_verify_recover(EVP_PKEY_CTX *ctx,\n                            unsigned char *rout, size_t *routlen,\n                            const unsigned char *sig, size_t siglen);\nint EVP_PKEY_encrypt_init(EVP_PKEY_CTX *ctx);\nint EVP_PKEY_encrypt(EVP_PKEY_CTX *ctx,\n                     unsigned char *out, size_t *outlen,\n                     const unsigned char *in, size_t inlen);\nint EVP_PKEY_decrypt_init(EVP_PKEY_CTX *ctx);\nint EVP_PKEY_decrypt(EVP_PKEY_CTX *ctx,\n                     unsigned char *out, size_t *outlen,\n                     const unsigned char *in, size_t inlen);\n\nint EVP_PKEY_derive_init(EVP_PKEY_CTX *ctx);\nint EVP_PKEY_derive_set_peer(EVP_PKEY_CTX *ctx, EVP_PKEY *peer);\nint EVP_PKEY_derive(EVP_PKEY_CTX *ctx, unsigned char *key, size_t *keylen);\n\ntypedef int EVP_PKEY_gen_cb (EVP_PKEY_CTX *ctx);\n\nint EVP_PKEY_paramgen_init(EVP_PKEY_CTX *ctx);\nint EVP_PKEY_paramgen(EVP_PKEY_CTX *ctx, EVP_PKEY **ppkey);\nint EVP_PKEY_keygen_init(EVP_PKEY_CTX *ctx);\nint EVP_PKEY_keygen(EVP_PKEY_CTX *ctx, EVP_PKEY **ppkey);\n\nvoid EVP_PKEY_CTX_set_cb(EVP_PKEY_CTX *ctx, EVP_PKEY_gen_cb *cb);\nEVP_PKEY_gen_cb *EVP_PKEY_CTX_get_cb(EVP_PKEY_CTX *ctx);\n\nint EVP_PKEY_CTX_get_keygen_info(EVP_PKEY_CTX *ctx, int idx);\n\nvoid EVP_PKEY_meth_set_init(EVP_PKEY_METHOD *pmeth,\n                            int (*init) (EVP_PKEY_CTX *ctx));\n\nvoid EVP_PKEY_meth_set_copy(EVP_PKEY_METHOD *pmeth,\n                            int (*copy) (EVP_PKEY_CTX *dst,\n                                         EVP_PKEY_CTX *src));\n\nvoid EVP_PKEY_meth_set_cleanup(EVP_PKEY_METHOD *pmeth,\n                               void (*cleanup) (EVP_PKEY_CTX *ctx));\n\nvoid EVP_PKEY_meth_set_paramgen(EVP_PKEY_METHOD *pmeth,\n                                int (*paramgen_init) (EVP_PKEY_CTX *ctx),\n                                int (*paramgen) (EVP_PKEY_CTX *ctx,\n                                                 EVP_PKEY *pkey));\n\nvoid EVP_PKEY_meth_set_keygen(EVP_PKEY_METHOD *pmeth,\n                              int (*keygen_init) (EVP_PKEY_CTX *ctx),\n                              int (*keygen) (EVP_PKEY_CTX *ctx,\n                                             EVP_PKEY *pkey));\n\nvoid EVP_PKEY_meth_set_sign(EVP_PKEY_METHOD *pmeth,\n                            int (*sign_init) (EVP_PKEY_CTX *ctx),\n                            int (*sign) (EVP_PKEY_CTX *ctx,\n                                         unsigned char *sig, size_t *siglen,\n                                         const unsigned char *tbs,\n                                         size_t tbslen));\n\nvoid EVP_PKEY_meth_set_verify(EVP_PKEY_METHOD *pmeth,\n                              int (*verify_init) (EVP_PKEY_CTX *ctx),\n                              int (*verify) (EVP_PKEY_CTX *ctx,\n                                             const unsigned char *sig,\n                                             size_t siglen,\n                                             const unsigned char *tbs,\n                                             size_t tbslen));\n\nvoid EVP_PKEY_meth_set_verify_recover(EVP_PKEY_METHOD *pmeth,\n                                      int (*verify_recover_init) (EVP_PKEY_CTX\n                                                                  *ctx),\n                                      int (*verify_recover) (EVP_PKEY_CTX\n                                                             *ctx,\n                                                             unsigned char\n                                                             *sig,\n                                                             size_t *siglen,\n                                                             const unsigned\n                                                             char *tbs,\n                                                             size_t tbslen));\n\nvoid EVP_PKEY_meth_set_signctx(EVP_PKEY_METHOD *pmeth,\n                               int (*signctx_init) (EVP_PKEY_CTX *ctx,\n                                                    EVP_MD_CTX *mctx),\n                               int (*signctx) (EVP_PKEY_CTX *ctx,\n                                               unsigned char *sig,\n                                               size_t *siglen,\n                                               EVP_MD_CTX *mctx));\n\nvoid EVP_PKEY_meth_set_verifyctx(EVP_PKEY_METHOD *pmeth,\n                                 int (*verifyctx_init) (EVP_PKEY_CTX *ctx,\n                                                        EVP_MD_CTX *mctx),\n                                 int (*verifyctx) (EVP_PKEY_CTX *ctx,\n                                                   const unsigned char *sig,\n                                                   int siglen,\n                                                   EVP_MD_CTX *mctx));\n\nvoid EVP_PKEY_meth_set_encrypt(EVP_PKEY_METHOD *pmeth,\n                               int (*encrypt_init) (EVP_PKEY_CTX *ctx),\n                               int (*encryptfn) (EVP_PKEY_CTX *ctx,\n                                                 unsigned char *out,\n                                                 size_t *outlen,\n                                                 const unsigned char *in,\n                                                 size_t inlen));\n\nvoid EVP_PKEY_meth_set_decrypt(EVP_PKEY_METHOD *pmeth,\n                               int (*decrypt_init) (EVP_PKEY_CTX *ctx),\n                               int (*decrypt) (EVP_PKEY_CTX *ctx,\n                                               unsigned char *out,\n                                               size_t *outlen,\n                                               const unsigned char *in,\n                                               size_t inlen));\n\nvoid EVP_PKEY_meth_set_derive(EVP_PKEY_METHOD *pmeth,\n                              int (*derive_init) (EVP_PKEY_CTX *ctx),\n                              int (*derive) (EVP_PKEY_CTX *ctx,\n                                             unsigned char *key,\n                                             size_t *keylen));\n\nvoid EVP_PKEY_meth_set_ctrl(EVP_PKEY_METHOD *pmeth,\n                            int (*ctrl) (EVP_PKEY_CTX *ctx, int type, int p1,\n                                         void *p2),\n                            int (*ctrl_str) (EVP_PKEY_CTX *ctx,\n                                             const char *type,\n                                             const char *value));\n\nvoid EVP_add_alg_module(void);\n\n/* BEGIN ERROR CODES */\n/*\n * The following lines are auto generated by the script mkerr.pl. Any changes\n * made after this point may be overwritten when the script is next run.\n */\n\nvoid ERR_load_EVP_strings(void);\n\n/* Error codes for the EVP functions. */\n\n/* Function codes. */\n# define EVP_F_AESNI_INIT_KEY                             165\n# define EVP_F_AESNI_XTS_CIPHER                           176\n# define EVP_F_AES_INIT_KEY                               133\n# define EVP_F_AES_T4_INIT_KEY                            178\n# define EVP_F_AES_XTS                                    172\n# define EVP_F_AES_XTS_CIPHER                             175\n# define EVP_F_ALG_MODULE_INIT                            177\n# define EVP_F_CAMELLIA_INIT_KEY                          159\n# define EVP_F_CMAC_INIT                                  173\n# define EVP_F_CMLL_T4_INIT_KEY                           179\n# define EVP_F_D2I_PKEY                                   100\n# define EVP_F_DO_SIGVER_INIT                             161\n# define EVP_F_DSAPKEY2PKCS8                              134\n# define EVP_F_DSA_PKEY2PKCS8                             135\n# define EVP_F_ECDSA_PKEY2PKCS8                           129\n# define EVP_F_ECKEY_PKEY2PKCS8                           132\n# define EVP_F_EVP_CIPHERINIT_EX                          123\n# define EVP_F_EVP_CIPHER_CTX_COPY                        163\n# define EVP_F_EVP_CIPHER_CTX_CTRL                        124\n# define EVP_F_EVP_CIPHER_CTX_SET_KEY_LENGTH              122\n# define EVP_F_EVP_DECRYPTFINAL_EX                        101\n# define EVP_F_EVP_DIGESTINIT_EX                          128\n# define EVP_F_EVP_ENCRYPTFINAL_EX                        127\n# define EVP_F_EVP_MD_CTX_COPY_EX                         110\n# define EVP_F_EVP_MD_SIZE                                162\n# define EVP_F_EVP_OPENINIT                               102\n# define EVP_F_EVP_PBE_ALG_ADD                            115\n# define EVP_F_EVP_PBE_ALG_ADD_TYPE                       160\n# define EVP_F_EVP_PBE_CIPHERINIT                         116\n# define EVP_F_EVP_PKCS82PKEY                             111\n# define EVP_F_EVP_PKCS82PKEY_BROKEN                      136\n# define EVP_F_EVP_PKEY2PKCS8_BROKEN                      113\n# define EVP_F_EVP_PKEY_COPY_PARAMETERS                   103\n# define EVP_F_EVP_PKEY_CTX_CTRL                          137\n# define EVP_F_EVP_PKEY_CTX_CTRL_STR                      150\n# define EVP_F_EVP_PKEY_CTX_DUP                           156\n# define EVP_F_EVP_PKEY_DECRYPT                           104\n# define EVP_F_EVP_PKEY_DECRYPT_INIT                      138\n# define EVP_F_EVP_PKEY_DECRYPT_OLD                       151\n# define EVP_F_EVP_PKEY_DERIVE                            153\n# define EVP_F_EVP_PKEY_DERIVE_INIT                       154\n# define EVP_F_EVP_PKEY_DERIVE_SET_PEER                   155\n# define EVP_F_EVP_PKEY_ENCRYPT                           105\n# define EVP_F_EVP_PKEY_ENCRYPT_INIT                      139\n# define EVP_F_EVP_PKEY_ENCRYPT_OLD                       152\n# define EVP_F_EVP_PKEY_GET1_DH                           119\n# define EVP_F_EVP_PKEY_GET1_DSA                          120\n# define EVP_F_EVP_PKEY_GET1_ECDSA                        130\n# define EVP_F_EVP_PKEY_GET1_EC_KEY                       131\n# define EVP_F_EVP_PKEY_GET1_RSA                          121\n# define EVP_F_EVP_PKEY_KEYGEN                            146\n# define EVP_F_EVP_PKEY_KEYGEN_INIT                       147\n# define EVP_F_EVP_PKEY_NEW                               106\n# define EVP_F_EVP_PKEY_PARAMGEN                          148\n# define EVP_F_EVP_PKEY_PARAMGEN_INIT                     149\n# define EVP_F_EVP_PKEY_SIGN                              140\n# define EVP_F_EVP_PKEY_SIGN_INIT                         141\n# define EVP_F_EVP_PKEY_VERIFY                            142\n# define EVP_F_EVP_PKEY_VERIFY_INIT                       143\n# define EVP_F_EVP_PKEY_VERIFY_RECOVER                    144\n# define EVP_F_EVP_PKEY_VERIFY_RECOVER_INIT               145\n# define EVP_F_EVP_RIJNDAEL                               126\n# define EVP_F_EVP_SIGNFINAL                              107\n# define EVP_F_EVP_VERIFYFINAL                            108\n# define EVP_F_FIPS_CIPHERINIT                            166\n# define EVP_F_FIPS_CIPHER_CTX_COPY                       170\n# define EVP_F_FIPS_CIPHER_CTX_CTRL                       167\n# define EVP_F_FIPS_CIPHER_CTX_SET_KEY_LENGTH             171\n# define EVP_F_FIPS_DIGESTINIT                            168\n# define EVP_F_FIPS_MD_CTX_COPY                           169\n# define EVP_F_HMAC_INIT_EX                               174\n# define EVP_F_INT_CTX_NEW                                157\n# define EVP_F_PKCS5_PBE_KEYIVGEN                         117\n# define EVP_F_PKCS5_V2_PBE_KEYIVGEN                      118\n# define EVP_F_PKCS5_V2_PBKDF2_KEYIVGEN                   164\n# define EVP_F_PKCS8_SET_BROKEN                           112\n# define EVP_F_PKEY_SET_TYPE                              158\n# define EVP_F_RC2_MAGIC_TO_METH                          109\n# define EVP_F_RC5_CTRL                                   125\n\n/* Reason codes. */\n# define EVP_R_AES_IV_SETUP_FAILED                        162\n# define EVP_R_AES_KEY_SETUP_FAILED                       143\n# define EVP_R_ASN1_LIB                                   140\n# define EVP_R_BAD_BLOCK_LENGTH                           136\n# define EVP_R_BAD_DECRYPT                                100\n# define EVP_R_BAD_KEY_LENGTH                             137\n# define EVP_R_BN_DECODE_ERROR                            112\n# define EVP_R_BN_PUBKEY_ERROR                            113\n# define EVP_R_BUFFER_TOO_SMALL                           155\n# define EVP_R_CAMELLIA_KEY_SETUP_FAILED                  157\n# define EVP_R_CIPHER_PARAMETER_ERROR                     122\n# define EVP_R_COMMAND_NOT_SUPPORTED                      147\n# define EVP_R_CTRL_NOT_IMPLEMENTED                       132\n# define EVP_R_CTRL_OPERATION_NOT_IMPLEMENTED             133\n# define EVP_R_DATA_NOT_MULTIPLE_OF_BLOCK_LENGTH          138\n# define EVP_R_DECODE_ERROR                               114\n# define EVP_R_DIFFERENT_KEY_TYPES                        101\n# define EVP_R_DIFFERENT_PARAMETERS                       153\n# define EVP_R_DISABLED_FOR_FIPS                          163\n# define EVP_R_ENCODE_ERROR                               115\n# define EVP_R_ERROR_LOADING_SECTION                      165\n# define EVP_R_ERROR_SETTING_FIPS_MODE                    166\n# define EVP_R_EVP_PBE_CIPHERINIT_ERROR                   119\n# define EVP_R_EXPECTING_AN_RSA_KEY                       127\n# define EVP_R_EXPECTING_A_DH_KEY                         128\n# define EVP_R_EXPECTING_A_DSA_KEY                        129\n# define EVP_R_EXPECTING_A_ECDSA_KEY                      141\n# define EVP_R_EXPECTING_A_EC_KEY                         142\n# define EVP_R_FIPS_MODE_NOT_SUPPORTED                    167\n# define EVP_R_INITIALIZATION_ERROR                       134\n# define EVP_R_INPUT_NOT_INITIALIZED                      111\n# define EVP_R_INVALID_DIGEST                             152\n# define EVP_R_INVALID_FIPS_MODE                          168\n# define EVP_R_INVALID_KEY                                171\n# define EVP_R_INVALID_KEY_LENGTH                         130\n# define EVP_R_INVALID_OPERATION                          148\n# define EVP_R_IV_TOO_LARGE                               102\n# define EVP_R_KEYGEN_FAILURE                             120\n# define EVP_R_MESSAGE_DIGEST_IS_NULL                     159\n# define EVP_R_METHOD_NOT_SUPPORTED                       144\n# define EVP_R_MISSING_PARAMETERS                         103\n# define EVP_R_NO_CIPHER_SET                              131\n# define EVP_R_NO_DEFAULT_DIGEST                          158\n# define EVP_R_NO_DIGEST_SET                              139\n# define EVP_R_NO_DSA_PARAMETERS                          116\n# define EVP_R_NO_KEY_SET                                 154\n# define EVP_R_NO_OPERATION_SET                           149\n# define EVP_R_NO_SIGN_FUNCTION_CONFIGURED                104\n# define EVP_R_NO_VERIFY_FUNCTION_CONFIGURED              105\n# define EVP_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE   150\n# define EVP_R_OPERATON_NOT_INITIALIZED                   151\n# define EVP_R_PKCS8_UNKNOWN_BROKEN_TYPE                  117\n# define EVP_R_PRIVATE_KEY_DECODE_ERROR                   145\n# define EVP_R_PRIVATE_KEY_ENCODE_ERROR                   146\n# define EVP_R_PUBLIC_KEY_NOT_RSA                         106\n# define EVP_R_TOO_LARGE                                  164\n# define EVP_R_UNKNOWN_CIPHER                             160\n# define EVP_R_UNKNOWN_DIGEST                             161\n# define EVP_R_UNKNOWN_OPTION                             169\n# define EVP_R_UNKNOWN_PBE_ALGORITHM                      121\n# define EVP_R_UNSUPORTED_NUMBER_OF_ROUNDS                135\n# define EVP_R_UNSUPPORTED_ALGORITHM                      156\n# define EVP_R_UNSUPPORTED_CIPHER                         107\n# define EVP_R_UNSUPPORTED_KEYLENGTH                      123\n# define EVP_R_UNSUPPORTED_KEY_DERIVATION_FUNCTION        124\n# define EVP_R_UNSUPPORTED_KEY_SIZE                       108\n# define EVP_R_UNSUPPORTED_PRF                            125\n# define EVP_R_UNSUPPORTED_PRIVATE_KEY_ALGORITHM          118\n# define EVP_R_UNSUPPORTED_SALT_TYPE                      126\n# define EVP_R_WRAP_MODE_NOT_ALLOWED                      170\n# define EVP_R_WRONG_FINAL_BLOCK_LENGTH                   109\n# define EVP_R_WRONG_PUBLIC_KEY_TYPE                      110\n\n# ifdef  __cplusplus\n}\n# endif\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/x86_64/include/openssl/hmac.h",
    "content": "/* crypto/hmac/hmac.h */\n/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)\n * All rights reserved.\n *\n * This package is an SSL implementation written\n * by Eric Young (eay@cryptsoft.com).\n * The implementation was written so as to conform with Netscapes SSL.\n *\n * This library is free for commercial and non-commercial use as long as\n * the following conditions are aheared to.  The following conditions\n * apply to all code found in this distribution, be it the RC4, RSA,\n * lhash, DES, etc., code; not just the SSL code.  The SSL documentation\n * included with this distribution is covered by the same copyright terms\n * except that the holder is Tim Hudson (tjh@cryptsoft.com).\n *\n * Copyright remains Eric Young's, and as such any Copyright notices in\n * the code are not to be removed.\n * If this package is used in a product, Eric Young should be given attribution\n * as the author of the parts of the library used.\n * This can be in the form of a textual message at program startup or\n * in documentation (online or textual) provided with the package.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the copyright\n *    notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in the\n *    documentation and/or other materials provided with the distribution.\n * 3. All advertising materials mentioning features or use of this software\n *    must display the following acknowledgement:\n *    \"This product includes cryptographic software written by\n *     Eric Young (eay@cryptsoft.com)\"\n *    The word 'cryptographic' can be left out if the rouines from the library\n *    being used are not cryptographic related :-).\n * 4. If you include any Windows specific code (or a derivative thereof) from\n *    the apps directory (application code) you must include an acknowledgement:\n *    \"This product includes software written by Tim Hudson (tjh@cryptsoft.com)\"\n *\n * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n * SUCH DAMAGE.\n *\n * The licence and distribution terms for any publically available version or\n * derivative of this code cannot be changed.  i.e. this code cannot simply be\n * copied and put under another distribution licence\n * [including the GNU Public Licence.]\n */\n#ifndef HEADER_HMAC_H\n# define HEADER_HMAC_H\n\n# include <openssl/opensslconf.h>\n\n# ifdef OPENSSL_NO_HMAC\n#  error HMAC is disabled.\n# endif\n\n# include <openssl/evp.h>\n\n# define HMAC_MAX_MD_CBLOCK      128/* largest known is SHA512 */\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\ntypedef struct hmac_ctx_st {\n    const EVP_MD *md;\n    EVP_MD_CTX md_ctx;\n    EVP_MD_CTX i_ctx;\n    EVP_MD_CTX o_ctx;\n    unsigned int key_length;\n    unsigned char key[HMAC_MAX_MD_CBLOCK];\n} HMAC_CTX;\n\n# define HMAC_size(e)    (EVP_MD_size((e)->md))\n\nvoid HMAC_CTX_init(HMAC_CTX *ctx);\nvoid HMAC_CTX_cleanup(HMAC_CTX *ctx);\n\n/* deprecated */\n# define HMAC_cleanup(ctx) HMAC_CTX_cleanup(ctx)\n\n/* deprecated */\nint HMAC_Init(HMAC_CTX *ctx, const void *key, int len, const EVP_MD *md);\nint HMAC_Init_ex(HMAC_CTX *ctx, const void *key, int len,\n                 const EVP_MD *md, ENGINE *impl);\nint HMAC_Update(HMAC_CTX *ctx, const unsigned char *data, size_t len);\nint HMAC_Final(HMAC_CTX *ctx, unsigned char *md, unsigned int *len);\nunsigned char *HMAC(const EVP_MD *evp_md, const void *key, int key_len,\n                    const unsigned char *d, size_t n, unsigned char *md,\n                    unsigned int *md_len);\nint HMAC_CTX_copy(HMAC_CTX *dctx, HMAC_CTX *sctx);\n\nvoid HMAC_CTX_set_flags(HMAC_CTX *ctx, unsigned long flags);\n\n#ifdef  __cplusplus\n}\n#endif\n\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/x86_64/include/openssl/idea.h",
    "content": "/* crypto/idea/idea.h */\n/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)\n * All rights reserved.\n *\n * This package is an SSL implementation written\n * by Eric Young (eay@cryptsoft.com).\n * The implementation was written so as to conform with Netscapes SSL.\n *\n * This library is free for commercial and non-commercial use as long as\n * the following conditions are aheared to.  The following conditions\n * apply to all code found in this distribution, be it the RC4, RSA,\n * lhash, DES, etc., code; not just the SSL code.  The SSL documentation\n * included with this distribution is covered by the same copyright terms\n * except that the holder is Tim Hudson (tjh@cryptsoft.com).\n *\n * Copyright remains Eric Young's, and as such any Copyright notices in\n * the code are not to be removed.\n * If this package is used in a product, Eric Young should be given attribution\n * as the author of the parts of the library used.\n * This can be in the form of a textual message at program startup or\n * in documentation (online or textual) provided with the package.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the copyright\n *    notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in the\n *    documentation and/or other materials provided with the distribution.\n * 3. All advertising materials mentioning features or use of this software\n *    must display the following acknowledgement:\n *    \"This product includes cryptographic software written by\n *     Eric Young (eay@cryptsoft.com)\"\n *    The word 'cryptographic' can be left out if the rouines from the library\n *    being used are not cryptographic related :-).\n * 4. If you include any Windows specific code (or a derivative thereof) from\n *    the apps directory (application code) you must include an acknowledgement:\n *    \"This product includes software written by Tim Hudson (tjh@cryptsoft.com)\"\n *\n * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n * SUCH DAMAGE.\n *\n * The licence and distribution terms for any publically available version or\n * derivative of this code cannot be changed.  i.e. this code cannot simply be\n * copied and put under another distribution licence\n * [including the GNU Public Licence.]\n */\n\n#ifndef HEADER_IDEA_H\n# define HEADER_IDEA_H\n\n# include <openssl/opensslconf.h>/* IDEA_INT, OPENSSL_NO_IDEA */\n\n# ifdef OPENSSL_NO_IDEA\n#  error IDEA is disabled.\n# endif\n\n# define IDEA_ENCRYPT    1\n# define IDEA_DECRYPT    0\n\n# define IDEA_BLOCK      8\n# define IDEA_KEY_LENGTH 16\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\ntypedef struct idea_key_st {\n    IDEA_INT data[9][6];\n} IDEA_KEY_SCHEDULE;\n\nconst char *idea_options(void);\nvoid idea_ecb_encrypt(const unsigned char *in, unsigned char *out,\n                      IDEA_KEY_SCHEDULE *ks);\n# ifdef OPENSSL_FIPS\nvoid private_idea_set_encrypt_key(const unsigned char *key,\n                                  IDEA_KEY_SCHEDULE *ks);\n# endif\nvoid idea_set_encrypt_key(const unsigned char *key, IDEA_KEY_SCHEDULE *ks);\nvoid idea_set_decrypt_key(IDEA_KEY_SCHEDULE *ek, IDEA_KEY_SCHEDULE *dk);\nvoid idea_cbc_encrypt(const unsigned char *in, unsigned char *out,\n                      long length, IDEA_KEY_SCHEDULE *ks, unsigned char *iv,\n                      int enc);\nvoid idea_cfb64_encrypt(const unsigned char *in, unsigned char *out,\n                        long length, IDEA_KEY_SCHEDULE *ks, unsigned char *iv,\n                        int *num, int enc);\nvoid idea_ofb64_encrypt(const unsigned char *in, unsigned char *out,\n                        long length, IDEA_KEY_SCHEDULE *ks, unsigned char *iv,\n                        int *num);\nvoid idea_encrypt(unsigned long *in, IDEA_KEY_SCHEDULE *ks);\n#ifdef  __cplusplus\n}\n#endif\n\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/x86_64/include/openssl/krb5_asn.h",
    "content": "/* krb5_asn.h */\n/*\n * Written by Vern Staats <staatsvr@asc.hpc.mil> for the OpenSSL project, **\n * using ocsp/{*.h,*asn*.c} as a starting point\n */\n\n/* ====================================================================\n * Copyright (c) 1998-2000 The OpenSSL Project.  All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n *\n * 1. Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n *\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in\n *    the documentation and/or other materials provided with the\n *    distribution.\n *\n * 3. All advertising materials mentioning features or use of this\n *    software must display the following acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit. (http://www.openssl.org/)\"\n *\n * 4. The names \"OpenSSL Toolkit\" and \"OpenSSL Project\" must not be used to\n *    endorse or promote products derived from this software without\n *    prior written permission. For written permission, please contact\n *    openssl-core@openssl.org.\n *\n * 5. Products derived from this software may not be called \"OpenSSL\"\n *    nor may \"OpenSSL\" appear in their names without prior written\n *    permission of the OpenSSL Project.\n *\n * 6. Redistributions of any form whatsoever must retain the following\n *    acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit (http://www.openssl.org/)\"\n *\n * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY\n * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\n * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR\n * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\n * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,\n * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED\n * OF THE POSSIBILITY OF SUCH DAMAGE.\n * ====================================================================\n *\n * This product includes cryptographic software written by Eric Young\n * (eay@cryptsoft.com).  This product includes software written by Tim\n * Hudson (tjh@cryptsoft.com).\n *\n */\n\n#ifndef HEADER_KRB5_ASN_H\n# define HEADER_KRB5_ASN_H\n\n/*\n * #include <krb5.h>\n */\n# include <openssl/safestack.h>\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n/*\n * ASN.1 from Kerberos RFC 1510\n */\n\n/*-     EncryptedData ::=   SEQUENCE {\n *              etype[0]                      INTEGER, -- EncryptionType\n *              kvno[1]                       INTEGER OPTIONAL,\n *              cipher[2]                     OCTET STRING -- ciphertext\n *      }\n */\ntypedef struct krb5_encdata_st {\n    ASN1_INTEGER *etype;\n    ASN1_INTEGER *kvno;\n    ASN1_OCTET_STRING *cipher;\n} KRB5_ENCDATA;\n\nDECLARE_STACK_OF(KRB5_ENCDATA)\n\n/*-     PrincipalName ::=   SEQUENCE {\n *              name-type[0]                  INTEGER,\n *              name-string[1]                SEQUENCE OF GeneralString\n *      }\n */\ntypedef struct krb5_princname_st {\n    ASN1_INTEGER *nametype;\n    STACK_OF(ASN1_GENERALSTRING) *namestring;\n} KRB5_PRINCNAME;\n\nDECLARE_STACK_OF(KRB5_PRINCNAME)\n\n/*-     Ticket ::=      [APPLICATION 1] SEQUENCE {\n *              tkt-vno[0]                    INTEGER,\n *              realm[1]                      Realm,\n *              sname[2]                      PrincipalName,\n *              enc-part[3]                   EncryptedData\n *      }\n */\ntypedef struct krb5_tktbody_st {\n    ASN1_INTEGER *tktvno;\n    ASN1_GENERALSTRING *realm;\n    KRB5_PRINCNAME *sname;\n    KRB5_ENCDATA *encdata;\n} KRB5_TKTBODY;\n\ntypedef STACK_OF(KRB5_TKTBODY) KRB5_TICKET;\nDECLARE_STACK_OF(KRB5_TKTBODY)\n\n/*-     AP-REQ ::=      [APPLICATION 14] SEQUENCE {\n *              pvno[0]                       INTEGER,\n *              msg-type[1]                   INTEGER,\n *              ap-options[2]                 APOptions,\n *              ticket[3]                     Ticket,\n *              authenticator[4]              EncryptedData\n *      }\n *\n *      APOptions ::=   BIT STRING {\n *              reserved(0), use-session-key(1), mutual-required(2) }\n */\ntypedef struct krb5_ap_req_st {\n    ASN1_INTEGER *pvno;\n    ASN1_INTEGER *msgtype;\n    ASN1_BIT_STRING *apoptions;\n    KRB5_TICKET *ticket;\n    KRB5_ENCDATA *authenticator;\n} KRB5_APREQBODY;\n\ntypedef STACK_OF(KRB5_APREQBODY) KRB5_APREQ;\nDECLARE_STACK_OF(KRB5_APREQBODY)\n\n/*      Authenticator Stuff     */\n\n/*-     Checksum ::=   SEQUENCE {\n *              cksumtype[0]                  INTEGER,\n *              checksum[1]                   OCTET STRING\n *      }\n */\ntypedef struct krb5_checksum_st {\n    ASN1_INTEGER *ctype;\n    ASN1_OCTET_STRING *checksum;\n} KRB5_CHECKSUM;\n\nDECLARE_STACK_OF(KRB5_CHECKSUM)\n\n/*-     EncryptionKey ::=   SEQUENCE {\n *              keytype[0]                    INTEGER,\n *              keyvalue[1]                   OCTET STRING\n *      }\n */\ntypedef struct krb5_encryptionkey_st {\n    ASN1_INTEGER *ktype;\n    ASN1_OCTET_STRING *keyvalue;\n} KRB5_ENCKEY;\n\nDECLARE_STACK_OF(KRB5_ENCKEY)\n\n/*-     AuthorizationData ::=   SEQUENCE OF SEQUENCE {\n *              ad-type[0]                    INTEGER,\n *              ad-data[1]                    OCTET STRING\n *      }\n */\ntypedef struct krb5_authorization_st {\n    ASN1_INTEGER *adtype;\n    ASN1_OCTET_STRING *addata;\n} KRB5_AUTHDATA;\n\nDECLARE_STACK_OF(KRB5_AUTHDATA)\n\n/*-     -- Unencrypted authenticator\n *      Authenticator ::=    [APPLICATION 2] SEQUENCE    {\n *              authenticator-vno[0]          INTEGER,\n *              crealm[1]                     Realm,\n *              cname[2]                      PrincipalName,\n *              cksum[3]                      Checksum OPTIONAL,\n *              cusec[4]                      INTEGER,\n *              ctime[5]                      KerberosTime,\n *              subkey[6]                     EncryptionKey OPTIONAL,\n *              seq-number[7]                 INTEGER OPTIONAL,\n *              authorization-data[8]         AuthorizationData OPTIONAL\n *      }\n */\ntypedef struct krb5_authenticator_st {\n    ASN1_INTEGER *avno;\n    ASN1_GENERALSTRING *crealm;\n    KRB5_PRINCNAME *cname;\n    KRB5_CHECKSUM *cksum;\n    ASN1_INTEGER *cusec;\n    ASN1_GENERALIZEDTIME *ctime;\n    KRB5_ENCKEY *subkey;\n    ASN1_INTEGER *seqnum;\n    KRB5_AUTHDATA *authorization;\n} KRB5_AUTHENTBODY;\n\ntypedef STACK_OF(KRB5_AUTHENTBODY) KRB5_AUTHENT;\nDECLARE_STACK_OF(KRB5_AUTHENTBODY)\n\n/*-  DECLARE_ASN1_FUNCTIONS(type) = DECLARE_ASN1_FUNCTIONS_name(type, type) =\n *      type *name##_new(void);\n *      void name##_free(type *a);\n *      DECLARE_ASN1_ENCODE_FUNCTIONS(type, name, name) =\n *       DECLARE_ASN1_ENCODE_FUNCTIONS(type, itname, name) =\n *        type *d2i_##name(type **a, const unsigned char **in, long len);\n *        int i2d_##name(type *a, unsigned char **out);\n *        DECLARE_ASN1_ITEM(itname) = OPENSSL_EXTERN const ASN1_ITEM itname##_it\n */\n\nDECLARE_ASN1_FUNCTIONS(KRB5_ENCDATA)\nDECLARE_ASN1_FUNCTIONS(KRB5_PRINCNAME)\nDECLARE_ASN1_FUNCTIONS(KRB5_TKTBODY)\nDECLARE_ASN1_FUNCTIONS(KRB5_APREQBODY)\nDECLARE_ASN1_FUNCTIONS(KRB5_TICKET)\nDECLARE_ASN1_FUNCTIONS(KRB5_APREQ)\n\nDECLARE_ASN1_FUNCTIONS(KRB5_CHECKSUM)\nDECLARE_ASN1_FUNCTIONS(KRB5_ENCKEY)\nDECLARE_ASN1_FUNCTIONS(KRB5_AUTHDATA)\nDECLARE_ASN1_FUNCTIONS(KRB5_AUTHENTBODY)\nDECLARE_ASN1_FUNCTIONS(KRB5_AUTHENT)\n\n/* BEGIN ERROR CODES */\n/*\n * The following lines are auto generated by the script mkerr.pl. Any changes\n * made after this point may be overwritten when the script is next run.\n */\n\n#ifdef  __cplusplus\n}\n#endif\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/x86_64/include/openssl/lhash.h",
    "content": "/* crypto/lhash/lhash.h */\n/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)\n * All rights reserved.\n *\n * This package is an SSL implementation written\n * by Eric Young (eay@cryptsoft.com).\n * The implementation was written so as to conform with Netscapes SSL.\n *\n * This library is free for commercial and non-commercial use as long as\n * the following conditions are aheared to.  The following conditions\n * apply to all code found in this distribution, be it the RC4, RSA,\n * lhash, DES, etc., code; not just the SSL code.  The SSL documentation\n * included with this distribution is covered by the same copyright terms\n * except that the holder is Tim Hudson (tjh@cryptsoft.com).\n *\n * Copyright remains Eric Young's, and as such any Copyright notices in\n * the code are not to be removed.\n * If this package is used in a product, Eric Young should be given attribution\n * as the author of the parts of the library used.\n * This can be in the form of a textual message at program startup or\n * in documentation (online or textual) provided with the package.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the copyright\n *    notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in the\n *    documentation and/or other materials provided with the distribution.\n * 3. All advertising materials mentioning features or use of this software\n *    must display the following acknowledgement:\n *    \"This product includes cryptographic software written by\n *     Eric Young (eay@cryptsoft.com)\"\n *    The word 'cryptographic' can be left out if the rouines from the library\n *    being used are not cryptographic related :-).\n * 4. If you include any Windows specific code (or a derivative thereof) from\n *    the apps directory (application code) you must include an acknowledgement:\n *    \"This product includes software written by Tim Hudson (tjh@cryptsoft.com)\"\n *\n * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n * SUCH DAMAGE.\n *\n * The licence and distribution terms for any publically available version or\n * derivative of this code cannot be changed.  i.e. this code cannot simply be\n * copied and put under another distribution licence\n * [including the GNU Public Licence.]\n */\n\n/*\n * Header for dynamic hash table routines Author - Eric Young\n */\n\n#ifndef HEADER_LHASH_H\n# define HEADER_LHASH_H\n\n# include <openssl/e_os2.h>\n# ifndef OPENSSL_NO_FP_API\n#  include <stdio.h>\n# endif\n\n# ifndef OPENSSL_NO_BIO\n#  include <openssl/bio.h>\n# endif\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\ntypedef struct lhash_node_st {\n    void *data;\n    struct lhash_node_st *next;\n# ifndef OPENSSL_NO_HASH_COMP\n    unsigned long hash;\n# endif\n} LHASH_NODE;\n\ntypedef int (*LHASH_COMP_FN_TYPE) (const void *, const void *);\ntypedef unsigned long (*LHASH_HASH_FN_TYPE) (const void *);\ntypedef void (*LHASH_DOALL_FN_TYPE) (void *);\ntypedef void (*LHASH_DOALL_ARG_FN_TYPE) (void *, void *);\n\n/*\n * Macros for declaring and implementing type-safe wrappers for LHASH\n * callbacks. This way, callbacks can be provided to LHASH structures without\n * function pointer casting and the macro-defined callbacks provide\n * per-variable casting before deferring to the underlying type-specific\n * callbacks. NB: It is possible to place a \"static\" in front of both the\n * DECLARE and IMPLEMENT macros if the functions are strictly internal.\n */\n\n/* First: \"hash\" functions */\n# define DECLARE_LHASH_HASH_FN(name, o_type) \\\n        unsigned long name##_LHASH_HASH(const void *);\n# define IMPLEMENT_LHASH_HASH_FN(name, o_type) \\\n        unsigned long name##_LHASH_HASH(const void *arg) { \\\n                const o_type *a = arg; \\\n                return name##_hash(a); }\n# define LHASH_HASH_FN(name) name##_LHASH_HASH\n\n/* Second: \"compare\" functions */\n# define DECLARE_LHASH_COMP_FN(name, o_type) \\\n        int name##_LHASH_COMP(const void *, const void *);\n# define IMPLEMENT_LHASH_COMP_FN(name, o_type) \\\n        int name##_LHASH_COMP(const void *arg1, const void *arg2) { \\\n                const o_type *a = arg1;             \\\n                const o_type *b = arg2; \\\n                return name##_cmp(a,b); }\n# define LHASH_COMP_FN(name) name##_LHASH_COMP\n\n/* Third: \"doall\" functions */\n# define DECLARE_LHASH_DOALL_FN(name, o_type) \\\n        void name##_LHASH_DOALL(void *);\n# define IMPLEMENT_LHASH_DOALL_FN(name, o_type) \\\n        void name##_LHASH_DOALL(void *arg) { \\\n                o_type *a = arg; \\\n                name##_doall(a); }\n# define LHASH_DOALL_FN(name) name##_LHASH_DOALL\n\n/* Fourth: \"doall_arg\" functions */\n# define DECLARE_LHASH_DOALL_ARG_FN(name, o_type, a_type) \\\n        void name##_LHASH_DOALL_ARG(void *, void *);\n# define IMPLEMENT_LHASH_DOALL_ARG_FN(name, o_type, a_type) \\\n        void name##_LHASH_DOALL_ARG(void *arg1, void *arg2) { \\\n                o_type *a = arg1; \\\n                a_type *b = arg2; \\\n                name##_doall_arg(a, b); }\n# define LHASH_DOALL_ARG_FN(name) name##_LHASH_DOALL_ARG\n\ntypedef struct lhash_st {\n    LHASH_NODE **b;\n    LHASH_COMP_FN_TYPE comp;\n    LHASH_HASH_FN_TYPE hash;\n    unsigned int num_nodes;\n    unsigned int num_alloc_nodes;\n    unsigned int p;\n    unsigned int pmax;\n    unsigned long up_load;      /* load times 256 */\n    unsigned long down_load;    /* load times 256 */\n    unsigned long num_items;\n    unsigned long num_expands;\n    unsigned long num_expand_reallocs;\n    unsigned long num_contracts;\n    unsigned long num_contract_reallocs;\n    unsigned long num_hash_calls;\n    unsigned long num_comp_calls;\n    unsigned long num_insert;\n    unsigned long num_replace;\n    unsigned long num_delete;\n    unsigned long num_no_delete;\n    unsigned long num_retrieve;\n    unsigned long num_retrieve_miss;\n    unsigned long num_hash_comps;\n    int error;\n} _LHASH;                       /* Do not use _LHASH directly, use LHASH_OF\n                                 * and friends */\n\n# define LH_LOAD_MULT    256\n\n/*\n * Indicates a malloc() error in the last call, this is only bad in\n * lh_insert().\n */\n# define lh_error(lh)    ((lh)->error)\n\n_LHASH *lh_new(LHASH_HASH_FN_TYPE h, LHASH_COMP_FN_TYPE c);\nvoid lh_free(_LHASH *lh);\nvoid *lh_insert(_LHASH *lh, void *data);\nvoid *lh_delete(_LHASH *lh, const void *data);\nvoid *lh_retrieve(_LHASH *lh, const void *data);\nvoid lh_doall(_LHASH *lh, LHASH_DOALL_FN_TYPE func);\nvoid lh_doall_arg(_LHASH *lh, LHASH_DOALL_ARG_FN_TYPE func, void *arg);\nunsigned long lh_strhash(const char *c);\nunsigned long lh_num_items(const _LHASH *lh);\n\n# ifndef OPENSSL_NO_FP_API\nvoid lh_stats(const _LHASH *lh, FILE *out);\nvoid lh_node_stats(const _LHASH *lh, FILE *out);\nvoid lh_node_usage_stats(const _LHASH *lh, FILE *out);\n# endif\n\n# ifndef OPENSSL_NO_BIO\nvoid lh_stats_bio(const _LHASH *lh, BIO *out);\nvoid lh_node_stats_bio(const _LHASH *lh, BIO *out);\nvoid lh_node_usage_stats_bio(const _LHASH *lh, BIO *out);\n# endif\n\n/* Type checking... */\n\n# define LHASH_OF(type) struct lhash_st_##type\n\n# define DECLARE_LHASH_OF(type) LHASH_OF(type) { int dummy; }\n\n# define CHECKED_LHASH_OF(type,lh) \\\n  ((_LHASH *)CHECKED_PTR_OF(LHASH_OF(type),lh))\n\n/* Define wrapper functions. */\n# define LHM_lh_new(type, name) \\\n  ((LHASH_OF(type) *)lh_new(LHASH_HASH_FN(name), LHASH_COMP_FN(name)))\n# define LHM_lh_error(type, lh) \\\n  lh_error(CHECKED_LHASH_OF(type,lh))\n# define LHM_lh_insert(type, lh, inst) \\\n  ((type *)lh_insert(CHECKED_LHASH_OF(type, lh), \\\n                     CHECKED_PTR_OF(type, inst)))\n# define LHM_lh_retrieve(type, lh, inst) \\\n  ((type *)lh_retrieve(CHECKED_LHASH_OF(type, lh), \\\n                       CHECKED_PTR_OF(type, inst)))\n# define LHM_lh_delete(type, lh, inst) \\\n  ((type *)lh_delete(CHECKED_LHASH_OF(type, lh),                        \\\n                     CHECKED_PTR_OF(type, inst)))\n# define LHM_lh_doall(type, lh,fn) lh_doall(CHECKED_LHASH_OF(type, lh), fn)\n# define LHM_lh_doall_arg(type, lh, fn, arg_type, arg) \\\n  lh_doall_arg(CHECKED_LHASH_OF(type, lh), fn, CHECKED_PTR_OF(arg_type, arg))\n# define LHM_lh_num_items(type, lh) lh_num_items(CHECKED_LHASH_OF(type, lh))\n# define LHM_lh_down_load(type, lh) (CHECKED_LHASH_OF(type, lh)->down_load)\n# define LHM_lh_node_stats_bio(type, lh, out) \\\n  lh_node_stats_bio(CHECKED_LHASH_OF(type, lh), out)\n# define LHM_lh_node_usage_stats_bio(type, lh, out) \\\n  lh_node_usage_stats_bio(CHECKED_LHASH_OF(type, lh), out)\n# define LHM_lh_stats_bio(type, lh, out) \\\n  lh_stats_bio(CHECKED_LHASH_OF(type, lh), out)\n# define LHM_lh_free(type, lh) lh_free(CHECKED_LHASH_OF(type, lh))\n\nDECLARE_LHASH_OF(OPENSSL_STRING);\nDECLARE_LHASH_OF(OPENSSL_CSTRING);\n\n#ifdef  __cplusplus\n}\n#endif\n\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/x86_64/include/openssl/modes.h",
    "content": "/* ====================================================================\n * Copyright (c) 2008 The OpenSSL Project. All rights reserved.\n *\n * Rights for redistribution and usage in source and binary\n * forms are granted according to the OpenSSL license.\n */\n\n#include <stddef.h>\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\ntypedef void (*block128_f) (const unsigned char in[16],\n                            unsigned char out[16], const void *key);\n\ntypedef void (*cbc128_f) (const unsigned char *in, unsigned char *out,\n                          size_t len, const void *key,\n                          unsigned char ivec[16], int enc);\n\ntypedef void (*ctr128_f) (const unsigned char *in, unsigned char *out,\n                          size_t blocks, const void *key,\n                          const unsigned char ivec[16]);\n\ntypedef void (*ccm128_f) (const unsigned char *in, unsigned char *out,\n                          size_t blocks, const void *key,\n                          const unsigned char ivec[16],\n                          unsigned char cmac[16]);\n\nvoid CRYPTO_cbc128_encrypt(const unsigned char *in, unsigned char *out,\n                           size_t len, const void *key,\n                           unsigned char ivec[16], block128_f block);\nvoid CRYPTO_cbc128_decrypt(const unsigned char *in, unsigned char *out,\n                           size_t len, const void *key,\n                           unsigned char ivec[16], block128_f block);\n\nvoid CRYPTO_ctr128_encrypt(const unsigned char *in, unsigned char *out,\n                           size_t len, const void *key,\n                           unsigned char ivec[16],\n                           unsigned char ecount_buf[16], unsigned int *num,\n                           block128_f block);\n\nvoid CRYPTO_ctr128_encrypt_ctr32(const unsigned char *in, unsigned char *out,\n                                 size_t len, const void *key,\n                                 unsigned char ivec[16],\n                                 unsigned char ecount_buf[16],\n                                 unsigned int *num, ctr128_f ctr);\n\nvoid CRYPTO_ofb128_encrypt(const unsigned char *in, unsigned char *out,\n                           size_t len, const void *key,\n                           unsigned char ivec[16], int *num,\n                           block128_f block);\n\nvoid CRYPTO_cfb128_encrypt(const unsigned char *in, unsigned char *out,\n                           size_t len, const void *key,\n                           unsigned char ivec[16], int *num,\n                           int enc, block128_f block);\nvoid CRYPTO_cfb128_8_encrypt(const unsigned char *in, unsigned char *out,\n                             size_t length, const void *key,\n                             unsigned char ivec[16], int *num,\n                             int enc, block128_f block);\nvoid CRYPTO_cfb128_1_encrypt(const unsigned char *in, unsigned char *out,\n                             size_t bits, const void *key,\n                             unsigned char ivec[16], int *num,\n                             int enc, block128_f block);\n\nsize_t CRYPTO_cts128_encrypt_block(const unsigned char *in,\n                                   unsigned char *out, size_t len,\n                                   const void *key, unsigned char ivec[16],\n                                   block128_f block);\nsize_t CRYPTO_cts128_encrypt(const unsigned char *in, unsigned char *out,\n                             size_t len, const void *key,\n                             unsigned char ivec[16], cbc128_f cbc);\nsize_t CRYPTO_cts128_decrypt_block(const unsigned char *in,\n                                   unsigned char *out, size_t len,\n                                   const void *key, unsigned char ivec[16],\n                                   block128_f block);\nsize_t CRYPTO_cts128_decrypt(const unsigned char *in, unsigned char *out,\n                             size_t len, const void *key,\n                             unsigned char ivec[16], cbc128_f cbc);\n\nsize_t CRYPTO_nistcts128_encrypt_block(const unsigned char *in,\n                                       unsigned char *out, size_t len,\n                                       const void *key,\n                                       unsigned char ivec[16],\n                                       block128_f block);\nsize_t CRYPTO_nistcts128_encrypt(const unsigned char *in, unsigned char *out,\n                                 size_t len, const void *key,\n                                 unsigned char ivec[16], cbc128_f cbc);\nsize_t CRYPTO_nistcts128_decrypt_block(const unsigned char *in,\n                                       unsigned char *out, size_t len,\n                                       const void *key,\n                                       unsigned char ivec[16],\n                                       block128_f block);\nsize_t CRYPTO_nistcts128_decrypt(const unsigned char *in, unsigned char *out,\n                                 size_t len, const void *key,\n                                 unsigned char ivec[16], cbc128_f cbc);\n\ntypedef struct gcm128_context GCM128_CONTEXT;\n\nGCM128_CONTEXT *CRYPTO_gcm128_new(void *key, block128_f block);\nvoid CRYPTO_gcm128_init(GCM128_CONTEXT *ctx, void *key, block128_f block);\nvoid CRYPTO_gcm128_setiv(GCM128_CONTEXT *ctx, const unsigned char *iv,\n                         size_t len);\nint CRYPTO_gcm128_aad(GCM128_CONTEXT *ctx, const unsigned char *aad,\n                      size_t len);\nint CRYPTO_gcm128_encrypt(GCM128_CONTEXT *ctx,\n                          const unsigned char *in, unsigned char *out,\n                          size_t len);\nint CRYPTO_gcm128_decrypt(GCM128_CONTEXT *ctx,\n                          const unsigned char *in, unsigned char *out,\n                          size_t len);\nint CRYPTO_gcm128_encrypt_ctr32(GCM128_CONTEXT *ctx,\n                                const unsigned char *in, unsigned char *out,\n                                size_t len, ctr128_f stream);\nint CRYPTO_gcm128_decrypt_ctr32(GCM128_CONTEXT *ctx,\n                                const unsigned char *in, unsigned char *out,\n                                size_t len, ctr128_f stream);\nint CRYPTO_gcm128_finish(GCM128_CONTEXT *ctx, const unsigned char *tag,\n                         size_t len);\nvoid CRYPTO_gcm128_tag(GCM128_CONTEXT *ctx, unsigned char *tag, size_t len);\nvoid CRYPTO_gcm128_release(GCM128_CONTEXT *ctx);\n\ntypedef struct ccm128_context CCM128_CONTEXT;\n\nvoid CRYPTO_ccm128_init(CCM128_CONTEXT *ctx,\n                        unsigned int M, unsigned int L, void *key,\n                        block128_f block);\nint CRYPTO_ccm128_setiv(CCM128_CONTEXT *ctx, const unsigned char *nonce,\n                        size_t nlen, size_t mlen);\nvoid CRYPTO_ccm128_aad(CCM128_CONTEXT *ctx, const unsigned char *aad,\n                       size_t alen);\nint CRYPTO_ccm128_encrypt(CCM128_CONTEXT *ctx, const unsigned char *inp,\n                          unsigned char *out, size_t len);\nint CRYPTO_ccm128_decrypt(CCM128_CONTEXT *ctx, const unsigned char *inp,\n                          unsigned char *out, size_t len);\nint CRYPTO_ccm128_encrypt_ccm64(CCM128_CONTEXT *ctx, const unsigned char *inp,\n                                unsigned char *out, size_t len,\n                                ccm128_f stream);\nint CRYPTO_ccm128_decrypt_ccm64(CCM128_CONTEXT *ctx, const unsigned char *inp,\n                                unsigned char *out, size_t len,\n                                ccm128_f stream);\nsize_t CRYPTO_ccm128_tag(CCM128_CONTEXT *ctx, unsigned char *tag, size_t len);\n\ntypedef struct xts128_context XTS128_CONTEXT;\n\nint CRYPTO_xts128_encrypt(const XTS128_CONTEXT *ctx,\n                          const unsigned char iv[16],\n                          const unsigned char *inp, unsigned char *out,\n                          size_t len, int enc);\n\nsize_t CRYPTO_128_wrap(void *key, const unsigned char *iv,\n                       unsigned char *out,\n                       const unsigned char *in, size_t inlen,\n                       block128_f block);\n\nsize_t CRYPTO_128_unwrap(void *key, const unsigned char *iv,\n                         unsigned char *out,\n                         const unsigned char *in, size_t inlen,\n                         block128_f block);\n\n#ifdef  __cplusplus\n}\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/x86_64/include/openssl/obj_mac.h",
    "content": "/* crypto/objects/obj_mac.h */\n\n/*\n * THIS FILE IS GENERATED FROM objects.txt by objects.pl via the following\n * command: perl objects.pl objects.txt obj_mac.num obj_mac.h\n */\n\n/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)\n * All rights reserved.\n *\n * This package is an SSL implementation written\n * by Eric Young (eay@cryptsoft.com).\n * The implementation was written so as to conform with Netscapes SSL.\n *\n * This library is free for commercial and non-commercial use as long as\n * the following conditions are aheared to.  The following conditions\n * apply to all code found in this distribution, be it the RC4, RSA,\n * lhash, DES, etc., code; not just the SSL code.  The SSL documentation\n * included with this distribution is covered by the same copyright terms\n * except that the holder is Tim Hudson (tjh@cryptsoft.com).\n *\n * Copyright remains Eric Young's, and as such any Copyright notices in\n * the code are not to be removed.\n * If this package is used in a product, Eric Young should be given attribution\n * as the author of the parts of the library used.\n * This can be in the form of a textual message at program startup or\n * in documentation (online or textual) provided with the package.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the copyright\n *    notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in the\n *    documentation and/or other materials provided with the distribution.\n * 3. All advertising materials mentioning features or use of this software\n *    must display the following acknowledgement:\n *    \"This product includes cryptographic software written by\n *     Eric Young (eay@cryptsoft.com)\"\n *    The word 'cryptographic' can be left out if the rouines from the library\n *    being used are not cryptographic related :-).\n * 4. If you include any Windows specific code (or a derivative thereof) from\n *    the apps directory (application code) you must include an acknowledgement:\n *    \"This product includes software written by Tim Hudson (tjh@cryptsoft.com)\"\n *\n * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n * SUCH DAMAGE.\n *\n * The licence and distribution terms for any publically available version or\n * derivative of this code cannot be changed.  i.e. this code cannot simply be\n * copied and put under another distribution licence\n * [including the GNU Public Licence.]\n */\n\n#define SN_undef                        \"UNDEF\"\n#define LN_undef                        \"undefined\"\n#define NID_undef                       0\n#define OBJ_undef                       0L\n\n#define SN_itu_t                \"ITU-T\"\n#define LN_itu_t                \"itu-t\"\n#define NID_itu_t               645\n#define OBJ_itu_t               0L\n\n#define NID_ccitt               404\n#define OBJ_ccitt               OBJ_itu_t\n\n#define SN_iso          \"ISO\"\n#define LN_iso          \"iso\"\n#define NID_iso         181\n#define OBJ_iso         1L\n\n#define SN_joint_iso_itu_t              \"JOINT-ISO-ITU-T\"\n#define LN_joint_iso_itu_t              \"joint-iso-itu-t\"\n#define NID_joint_iso_itu_t             646\n#define OBJ_joint_iso_itu_t             2L\n\n#define NID_joint_iso_ccitt             393\n#define OBJ_joint_iso_ccitt             OBJ_joint_iso_itu_t\n\n#define SN_member_body          \"member-body\"\n#define LN_member_body          \"ISO Member Body\"\n#define NID_member_body         182\n#define OBJ_member_body         OBJ_iso,2L\n\n#define SN_identified_organization              \"identified-organization\"\n#define NID_identified_organization             676\n#define OBJ_identified_organization             OBJ_iso,3L\n\n#define SN_hmac_md5             \"HMAC-MD5\"\n#define LN_hmac_md5             \"hmac-md5\"\n#define NID_hmac_md5            780\n#define OBJ_hmac_md5            OBJ_identified_organization,6L,1L,5L,5L,8L,1L,1L\n\n#define SN_hmac_sha1            \"HMAC-SHA1\"\n#define LN_hmac_sha1            \"hmac-sha1\"\n#define NID_hmac_sha1           781\n#define OBJ_hmac_sha1           OBJ_identified_organization,6L,1L,5L,5L,8L,1L,2L\n\n#define SN_certicom_arc         \"certicom-arc\"\n#define NID_certicom_arc                677\n#define OBJ_certicom_arc                OBJ_identified_organization,132L\n\n#define SN_international_organizations          \"international-organizations\"\n#define LN_international_organizations          \"International Organizations\"\n#define NID_international_organizations         647\n#define OBJ_international_organizations         OBJ_joint_iso_itu_t,23L\n\n#define SN_wap          \"wap\"\n#define NID_wap         678\n#define OBJ_wap         OBJ_international_organizations,43L\n\n#define SN_wap_wsg              \"wap-wsg\"\n#define NID_wap_wsg             679\n#define OBJ_wap_wsg             OBJ_wap,1L\n\n#define SN_selected_attribute_types             \"selected-attribute-types\"\n#define LN_selected_attribute_types             \"Selected Attribute Types\"\n#define NID_selected_attribute_types            394\n#define OBJ_selected_attribute_types            OBJ_joint_iso_itu_t,5L,1L,5L\n\n#define SN_clearance            \"clearance\"\n#define NID_clearance           395\n#define OBJ_clearance           OBJ_selected_attribute_types,55L\n\n#define SN_ISO_US               \"ISO-US\"\n#define LN_ISO_US               \"ISO US Member Body\"\n#define NID_ISO_US              183\n#define OBJ_ISO_US              OBJ_member_body,840L\n\n#define SN_X9_57                \"X9-57\"\n#define LN_X9_57                \"X9.57\"\n#define NID_X9_57               184\n#define OBJ_X9_57               OBJ_ISO_US,10040L\n\n#define SN_X9cm         \"X9cm\"\n#define LN_X9cm         \"X9.57 CM ?\"\n#define NID_X9cm                185\n#define OBJ_X9cm                OBJ_X9_57,4L\n\n#define SN_dsa          \"DSA\"\n#define LN_dsa          \"dsaEncryption\"\n#define NID_dsa         116\n#define OBJ_dsa         OBJ_X9cm,1L\n\n#define SN_dsaWithSHA1          \"DSA-SHA1\"\n#define LN_dsaWithSHA1          \"dsaWithSHA1\"\n#define NID_dsaWithSHA1         113\n#define OBJ_dsaWithSHA1         OBJ_X9cm,3L\n\n#define SN_ansi_X9_62           \"ansi-X9-62\"\n#define LN_ansi_X9_62           \"ANSI X9.62\"\n#define NID_ansi_X9_62          405\n#define OBJ_ansi_X9_62          OBJ_ISO_US,10045L\n\n#define OBJ_X9_62_id_fieldType          OBJ_ansi_X9_62,1L\n\n#define SN_X9_62_prime_field            \"prime-field\"\n#define NID_X9_62_prime_field           406\n#define OBJ_X9_62_prime_field           OBJ_X9_62_id_fieldType,1L\n\n#define SN_X9_62_characteristic_two_field               \"characteristic-two-field\"\n#define NID_X9_62_characteristic_two_field              407\n#define OBJ_X9_62_characteristic_two_field              OBJ_X9_62_id_fieldType,2L\n\n#define SN_X9_62_id_characteristic_two_basis            \"id-characteristic-two-basis\"\n#define NID_X9_62_id_characteristic_two_basis           680\n#define OBJ_X9_62_id_characteristic_two_basis           OBJ_X9_62_characteristic_two_field,3L\n\n#define SN_X9_62_onBasis                \"onBasis\"\n#define NID_X9_62_onBasis               681\n#define OBJ_X9_62_onBasis               OBJ_X9_62_id_characteristic_two_basis,1L\n\n#define SN_X9_62_tpBasis                \"tpBasis\"\n#define NID_X9_62_tpBasis               682\n#define OBJ_X9_62_tpBasis               OBJ_X9_62_id_characteristic_two_basis,2L\n\n#define SN_X9_62_ppBasis                \"ppBasis\"\n#define NID_X9_62_ppBasis               683\n#define OBJ_X9_62_ppBasis               OBJ_X9_62_id_characteristic_two_basis,3L\n\n#define OBJ_X9_62_id_publicKeyType              OBJ_ansi_X9_62,2L\n\n#define SN_X9_62_id_ecPublicKey         \"id-ecPublicKey\"\n#define NID_X9_62_id_ecPublicKey                408\n#define OBJ_X9_62_id_ecPublicKey                OBJ_X9_62_id_publicKeyType,1L\n\n#define OBJ_X9_62_ellipticCurve         OBJ_ansi_X9_62,3L\n\n#define OBJ_X9_62_c_TwoCurve            OBJ_X9_62_ellipticCurve,0L\n\n#define SN_X9_62_c2pnb163v1             \"c2pnb163v1\"\n#define NID_X9_62_c2pnb163v1            684\n#define OBJ_X9_62_c2pnb163v1            OBJ_X9_62_c_TwoCurve,1L\n\n#define SN_X9_62_c2pnb163v2             \"c2pnb163v2\"\n#define NID_X9_62_c2pnb163v2            685\n#define OBJ_X9_62_c2pnb163v2            OBJ_X9_62_c_TwoCurve,2L\n\n#define SN_X9_62_c2pnb163v3             \"c2pnb163v3\"\n#define NID_X9_62_c2pnb163v3            686\n#define OBJ_X9_62_c2pnb163v3            OBJ_X9_62_c_TwoCurve,3L\n\n#define SN_X9_62_c2pnb176v1             \"c2pnb176v1\"\n#define NID_X9_62_c2pnb176v1            687\n#define OBJ_X9_62_c2pnb176v1            OBJ_X9_62_c_TwoCurve,4L\n\n#define SN_X9_62_c2tnb191v1             \"c2tnb191v1\"\n#define NID_X9_62_c2tnb191v1            688\n#define OBJ_X9_62_c2tnb191v1            OBJ_X9_62_c_TwoCurve,5L\n\n#define SN_X9_62_c2tnb191v2             \"c2tnb191v2\"\n#define NID_X9_62_c2tnb191v2            689\n#define OBJ_X9_62_c2tnb191v2            OBJ_X9_62_c_TwoCurve,6L\n\n#define SN_X9_62_c2tnb191v3             \"c2tnb191v3\"\n#define NID_X9_62_c2tnb191v3            690\n#define OBJ_X9_62_c2tnb191v3            OBJ_X9_62_c_TwoCurve,7L\n\n#define SN_X9_62_c2onb191v4             \"c2onb191v4\"\n#define NID_X9_62_c2onb191v4            691\n#define OBJ_X9_62_c2onb191v4            OBJ_X9_62_c_TwoCurve,8L\n\n#define SN_X9_62_c2onb191v5             \"c2onb191v5\"\n#define NID_X9_62_c2onb191v5            692\n#define OBJ_X9_62_c2onb191v5            OBJ_X9_62_c_TwoCurve,9L\n\n#define SN_X9_62_c2pnb208w1             \"c2pnb208w1\"\n#define NID_X9_62_c2pnb208w1            693\n#define OBJ_X9_62_c2pnb208w1            OBJ_X9_62_c_TwoCurve,10L\n\n#define SN_X9_62_c2tnb239v1             \"c2tnb239v1\"\n#define NID_X9_62_c2tnb239v1            694\n#define OBJ_X9_62_c2tnb239v1            OBJ_X9_62_c_TwoCurve,11L\n\n#define SN_X9_62_c2tnb239v2             \"c2tnb239v2\"\n#define NID_X9_62_c2tnb239v2            695\n#define OBJ_X9_62_c2tnb239v2            OBJ_X9_62_c_TwoCurve,12L\n\n#define SN_X9_62_c2tnb239v3             \"c2tnb239v3\"\n#define NID_X9_62_c2tnb239v3            696\n#define OBJ_X9_62_c2tnb239v3            OBJ_X9_62_c_TwoCurve,13L\n\n#define SN_X9_62_c2onb239v4             \"c2onb239v4\"\n#define NID_X9_62_c2onb239v4            697\n#define OBJ_X9_62_c2onb239v4            OBJ_X9_62_c_TwoCurve,14L\n\n#define SN_X9_62_c2onb239v5             \"c2onb239v5\"\n#define NID_X9_62_c2onb239v5            698\n#define OBJ_X9_62_c2onb239v5            OBJ_X9_62_c_TwoCurve,15L\n\n#define SN_X9_62_c2pnb272w1             \"c2pnb272w1\"\n#define NID_X9_62_c2pnb272w1            699\n#define OBJ_X9_62_c2pnb272w1            OBJ_X9_62_c_TwoCurve,16L\n\n#define SN_X9_62_c2pnb304w1             \"c2pnb304w1\"\n#define NID_X9_62_c2pnb304w1            700\n#define OBJ_X9_62_c2pnb304w1            OBJ_X9_62_c_TwoCurve,17L\n\n#define SN_X9_62_c2tnb359v1             \"c2tnb359v1\"\n#define NID_X9_62_c2tnb359v1            701\n#define OBJ_X9_62_c2tnb359v1            OBJ_X9_62_c_TwoCurve,18L\n\n#define SN_X9_62_c2pnb368w1             \"c2pnb368w1\"\n#define NID_X9_62_c2pnb368w1            702\n#define OBJ_X9_62_c2pnb368w1            OBJ_X9_62_c_TwoCurve,19L\n\n#define SN_X9_62_c2tnb431r1             \"c2tnb431r1\"\n#define NID_X9_62_c2tnb431r1            703\n#define OBJ_X9_62_c2tnb431r1            OBJ_X9_62_c_TwoCurve,20L\n\n#define OBJ_X9_62_primeCurve            OBJ_X9_62_ellipticCurve,1L\n\n#define SN_X9_62_prime192v1             \"prime192v1\"\n#define NID_X9_62_prime192v1            409\n#define OBJ_X9_62_prime192v1            OBJ_X9_62_primeCurve,1L\n\n#define SN_X9_62_prime192v2             \"prime192v2\"\n#define NID_X9_62_prime192v2            410\n#define OBJ_X9_62_prime192v2            OBJ_X9_62_primeCurve,2L\n\n#define SN_X9_62_prime192v3             \"prime192v3\"\n#define NID_X9_62_prime192v3            411\n#define OBJ_X9_62_prime192v3            OBJ_X9_62_primeCurve,3L\n\n#define SN_X9_62_prime239v1             \"prime239v1\"\n#define NID_X9_62_prime239v1            412\n#define OBJ_X9_62_prime239v1            OBJ_X9_62_primeCurve,4L\n\n#define SN_X9_62_prime239v2             \"prime239v2\"\n#define NID_X9_62_prime239v2            413\n#define OBJ_X9_62_prime239v2            OBJ_X9_62_primeCurve,5L\n\n#define SN_X9_62_prime239v3             \"prime239v3\"\n#define NID_X9_62_prime239v3            414\n#define OBJ_X9_62_prime239v3            OBJ_X9_62_primeCurve,6L\n\n#define SN_X9_62_prime256v1             \"prime256v1\"\n#define NID_X9_62_prime256v1            415\n#define OBJ_X9_62_prime256v1            OBJ_X9_62_primeCurve,7L\n\n#define OBJ_X9_62_id_ecSigType          OBJ_ansi_X9_62,4L\n\n#define SN_ecdsa_with_SHA1              \"ecdsa-with-SHA1\"\n#define NID_ecdsa_with_SHA1             416\n#define OBJ_ecdsa_with_SHA1             OBJ_X9_62_id_ecSigType,1L\n\n#define SN_ecdsa_with_Recommended               \"ecdsa-with-Recommended\"\n#define NID_ecdsa_with_Recommended              791\n#define OBJ_ecdsa_with_Recommended              OBJ_X9_62_id_ecSigType,2L\n\n#define SN_ecdsa_with_Specified         \"ecdsa-with-Specified\"\n#define NID_ecdsa_with_Specified                792\n#define OBJ_ecdsa_with_Specified                OBJ_X9_62_id_ecSigType,3L\n\n#define SN_ecdsa_with_SHA224            \"ecdsa-with-SHA224\"\n#define NID_ecdsa_with_SHA224           793\n#define OBJ_ecdsa_with_SHA224           OBJ_ecdsa_with_Specified,1L\n\n#define SN_ecdsa_with_SHA256            \"ecdsa-with-SHA256\"\n#define NID_ecdsa_with_SHA256           794\n#define OBJ_ecdsa_with_SHA256           OBJ_ecdsa_with_Specified,2L\n\n#define SN_ecdsa_with_SHA384            \"ecdsa-with-SHA384\"\n#define NID_ecdsa_with_SHA384           795\n#define OBJ_ecdsa_with_SHA384           OBJ_ecdsa_with_Specified,3L\n\n#define SN_ecdsa_with_SHA512            \"ecdsa-with-SHA512\"\n#define NID_ecdsa_with_SHA512           796\n#define OBJ_ecdsa_with_SHA512           OBJ_ecdsa_with_Specified,4L\n\n#define OBJ_secg_ellipticCurve          OBJ_certicom_arc,0L\n\n#define SN_secp112r1            \"secp112r1\"\n#define NID_secp112r1           704\n#define OBJ_secp112r1           OBJ_secg_ellipticCurve,6L\n\n#define SN_secp112r2            \"secp112r2\"\n#define NID_secp112r2           705\n#define OBJ_secp112r2           OBJ_secg_ellipticCurve,7L\n\n#define SN_secp128r1            \"secp128r1\"\n#define NID_secp128r1           706\n#define OBJ_secp128r1           OBJ_secg_ellipticCurve,28L\n\n#define SN_secp128r2            \"secp128r2\"\n#define NID_secp128r2           707\n#define OBJ_secp128r2           OBJ_secg_ellipticCurve,29L\n\n#define SN_secp160k1            \"secp160k1\"\n#define NID_secp160k1           708\n#define OBJ_secp160k1           OBJ_secg_ellipticCurve,9L\n\n#define SN_secp160r1            \"secp160r1\"\n#define NID_secp160r1           709\n#define OBJ_secp160r1           OBJ_secg_ellipticCurve,8L\n\n#define SN_secp160r2            \"secp160r2\"\n#define NID_secp160r2           710\n#define OBJ_secp160r2           OBJ_secg_ellipticCurve,30L\n\n#define SN_secp192k1            \"secp192k1\"\n#define NID_secp192k1           711\n#define OBJ_secp192k1           OBJ_secg_ellipticCurve,31L\n\n#define SN_secp224k1            \"secp224k1\"\n#define NID_secp224k1           712\n#define OBJ_secp224k1           OBJ_secg_ellipticCurve,32L\n\n#define SN_secp224r1            \"secp224r1\"\n#define NID_secp224r1           713\n#define OBJ_secp224r1           OBJ_secg_ellipticCurve,33L\n\n#define SN_secp256k1            \"secp256k1\"\n#define NID_secp256k1           714\n#define OBJ_secp256k1           OBJ_secg_ellipticCurve,10L\n\n#define SN_secp384r1            \"secp384r1\"\n#define NID_secp384r1           715\n#define OBJ_secp384r1           OBJ_secg_ellipticCurve,34L\n\n#define SN_secp521r1            \"secp521r1\"\n#define NID_secp521r1           716\n#define OBJ_secp521r1           OBJ_secg_ellipticCurve,35L\n\n#define SN_sect113r1            \"sect113r1\"\n#define NID_sect113r1           717\n#define OBJ_sect113r1           OBJ_secg_ellipticCurve,4L\n\n#define SN_sect113r2            \"sect113r2\"\n#define NID_sect113r2           718\n#define OBJ_sect113r2           OBJ_secg_ellipticCurve,5L\n\n#define SN_sect131r1            \"sect131r1\"\n#define NID_sect131r1           719\n#define OBJ_sect131r1           OBJ_secg_ellipticCurve,22L\n\n#define SN_sect131r2            \"sect131r2\"\n#define NID_sect131r2           720\n#define OBJ_sect131r2           OBJ_secg_ellipticCurve,23L\n\n#define SN_sect163k1            \"sect163k1\"\n#define NID_sect163k1           721\n#define OBJ_sect163k1           OBJ_secg_ellipticCurve,1L\n\n#define SN_sect163r1            \"sect163r1\"\n#define NID_sect163r1           722\n#define OBJ_sect163r1           OBJ_secg_ellipticCurve,2L\n\n#define SN_sect163r2            \"sect163r2\"\n#define NID_sect163r2           723\n#define OBJ_sect163r2           OBJ_secg_ellipticCurve,15L\n\n#define SN_sect193r1            \"sect193r1\"\n#define NID_sect193r1           724\n#define OBJ_sect193r1           OBJ_secg_ellipticCurve,24L\n\n#define SN_sect193r2            \"sect193r2\"\n#define NID_sect193r2           725\n#define OBJ_sect193r2           OBJ_secg_ellipticCurve,25L\n\n#define SN_sect233k1            \"sect233k1\"\n#define NID_sect233k1           726\n#define OBJ_sect233k1           OBJ_secg_ellipticCurve,26L\n\n#define SN_sect233r1            \"sect233r1\"\n#define NID_sect233r1           727\n#define OBJ_sect233r1           OBJ_secg_ellipticCurve,27L\n\n#define SN_sect239k1            \"sect239k1\"\n#define NID_sect239k1           728\n#define OBJ_sect239k1           OBJ_secg_ellipticCurve,3L\n\n#define SN_sect283k1            \"sect283k1\"\n#define NID_sect283k1           729\n#define OBJ_sect283k1           OBJ_secg_ellipticCurve,16L\n\n#define SN_sect283r1            \"sect283r1\"\n#define NID_sect283r1           730\n#define OBJ_sect283r1           OBJ_secg_ellipticCurve,17L\n\n#define SN_sect409k1            \"sect409k1\"\n#define NID_sect409k1           731\n#define OBJ_sect409k1           OBJ_secg_ellipticCurve,36L\n\n#define SN_sect409r1            \"sect409r1\"\n#define NID_sect409r1           732\n#define OBJ_sect409r1           OBJ_secg_ellipticCurve,37L\n\n#define SN_sect571k1            \"sect571k1\"\n#define NID_sect571k1           733\n#define OBJ_sect571k1           OBJ_secg_ellipticCurve,38L\n\n#define SN_sect571r1            \"sect571r1\"\n#define NID_sect571r1           734\n#define OBJ_sect571r1           OBJ_secg_ellipticCurve,39L\n\n#define OBJ_wap_wsg_idm_ecid            OBJ_wap_wsg,4L\n\n#define SN_wap_wsg_idm_ecid_wtls1               \"wap-wsg-idm-ecid-wtls1\"\n#define NID_wap_wsg_idm_ecid_wtls1              735\n#define OBJ_wap_wsg_idm_ecid_wtls1              OBJ_wap_wsg_idm_ecid,1L\n\n#define SN_wap_wsg_idm_ecid_wtls3               \"wap-wsg-idm-ecid-wtls3\"\n#define NID_wap_wsg_idm_ecid_wtls3              736\n#define OBJ_wap_wsg_idm_ecid_wtls3              OBJ_wap_wsg_idm_ecid,3L\n\n#define SN_wap_wsg_idm_ecid_wtls4               \"wap-wsg-idm-ecid-wtls4\"\n#define NID_wap_wsg_idm_ecid_wtls4              737\n#define OBJ_wap_wsg_idm_ecid_wtls4              OBJ_wap_wsg_idm_ecid,4L\n\n#define SN_wap_wsg_idm_ecid_wtls5               \"wap-wsg-idm-ecid-wtls5\"\n#define NID_wap_wsg_idm_ecid_wtls5              738\n#define OBJ_wap_wsg_idm_ecid_wtls5              OBJ_wap_wsg_idm_ecid,5L\n\n#define SN_wap_wsg_idm_ecid_wtls6               \"wap-wsg-idm-ecid-wtls6\"\n#define NID_wap_wsg_idm_ecid_wtls6              739\n#define OBJ_wap_wsg_idm_ecid_wtls6              OBJ_wap_wsg_idm_ecid,6L\n\n#define SN_wap_wsg_idm_ecid_wtls7               \"wap-wsg-idm-ecid-wtls7\"\n#define NID_wap_wsg_idm_ecid_wtls7              740\n#define OBJ_wap_wsg_idm_ecid_wtls7              OBJ_wap_wsg_idm_ecid,7L\n\n#define SN_wap_wsg_idm_ecid_wtls8               \"wap-wsg-idm-ecid-wtls8\"\n#define NID_wap_wsg_idm_ecid_wtls8              741\n#define OBJ_wap_wsg_idm_ecid_wtls8              OBJ_wap_wsg_idm_ecid,8L\n\n#define SN_wap_wsg_idm_ecid_wtls9               \"wap-wsg-idm-ecid-wtls9\"\n#define NID_wap_wsg_idm_ecid_wtls9              742\n#define OBJ_wap_wsg_idm_ecid_wtls9              OBJ_wap_wsg_idm_ecid,9L\n\n#define SN_wap_wsg_idm_ecid_wtls10              \"wap-wsg-idm-ecid-wtls10\"\n#define NID_wap_wsg_idm_ecid_wtls10             743\n#define OBJ_wap_wsg_idm_ecid_wtls10             OBJ_wap_wsg_idm_ecid,10L\n\n#define SN_wap_wsg_idm_ecid_wtls11              \"wap-wsg-idm-ecid-wtls11\"\n#define NID_wap_wsg_idm_ecid_wtls11             744\n#define OBJ_wap_wsg_idm_ecid_wtls11             OBJ_wap_wsg_idm_ecid,11L\n\n#define SN_wap_wsg_idm_ecid_wtls12              \"wap-wsg-idm-ecid-wtls12\"\n#define NID_wap_wsg_idm_ecid_wtls12             745\n#define OBJ_wap_wsg_idm_ecid_wtls12             OBJ_wap_wsg_idm_ecid,12L\n\n#define SN_cast5_cbc            \"CAST5-CBC\"\n#define LN_cast5_cbc            \"cast5-cbc\"\n#define NID_cast5_cbc           108\n#define OBJ_cast5_cbc           OBJ_ISO_US,113533L,7L,66L,10L\n\n#define SN_cast5_ecb            \"CAST5-ECB\"\n#define LN_cast5_ecb            \"cast5-ecb\"\n#define NID_cast5_ecb           109\n\n#define SN_cast5_cfb64          \"CAST5-CFB\"\n#define LN_cast5_cfb64          \"cast5-cfb\"\n#define NID_cast5_cfb64         110\n\n#define SN_cast5_ofb64          \"CAST5-OFB\"\n#define LN_cast5_ofb64          \"cast5-ofb\"\n#define NID_cast5_ofb64         111\n\n#define LN_pbeWithMD5AndCast5_CBC               \"pbeWithMD5AndCast5CBC\"\n#define NID_pbeWithMD5AndCast5_CBC              112\n#define OBJ_pbeWithMD5AndCast5_CBC              OBJ_ISO_US,113533L,7L,66L,12L\n\n#define SN_id_PasswordBasedMAC          \"id-PasswordBasedMAC\"\n#define LN_id_PasswordBasedMAC          \"password based MAC\"\n#define NID_id_PasswordBasedMAC         782\n#define OBJ_id_PasswordBasedMAC         OBJ_ISO_US,113533L,7L,66L,13L\n\n#define SN_id_DHBasedMac                \"id-DHBasedMac\"\n#define LN_id_DHBasedMac                \"Diffie-Hellman based MAC\"\n#define NID_id_DHBasedMac               783\n#define OBJ_id_DHBasedMac               OBJ_ISO_US,113533L,7L,66L,30L\n\n#define SN_rsadsi               \"rsadsi\"\n#define LN_rsadsi               \"RSA Data Security, Inc.\"\n#define NID_rsadsi              1\n#define OBJ_rsadsi              OBJ_ISO_US,113549L\n\n#define SN_pkcs         \"pkcs\"\n#define LN_pkcs         \"RSA Data Security, Inc. PKCS\"\n#define NID_pkcs                2\n#define OBJ_pkcs                OBJ_rsadsi,1L\n\n#define SN_pkcs1                \"pkcs1\"\n#define NID_pkcs1               186\n#define OBJ_pkcs1               OBJ_pkcs,1L\n\n#define LN_rsaEncryption                \"rsaEncryption\"\n#define NID_rsaEncryption               6\n#define OBJ_rsaEncryption               OBJ_pkcs1,1L\n\n#define SN_md2WithRSAEncryption         \"RSA-MD2\"\n#define LN_md2WithRSAEncryption         \"md2WithRSAEncryption\"\n#define NID_md2WithRSAEncryption                7\n#define OBJ_md2WithRSAEncryption                OBJ_pkcs1,2L\n\n#define SN_md4WithRSAEncryption         \"RSA-MD4\"\n#define LN_md4WithRSAEncryption         \"md4WithRSAEncryption\"\n#define NID_md4WithRSAEncryption                396\n#define OBJ_md4WithRSAEncryption                OBJ_pkcs1,3L\n\n#define SN_md5WithRSAEncryption         \"RSA-MD5\"\n#define LN_md5WithRSAEncryption         \"md5WithRSAEncryption\"\n#define NID_md5WithRSAEncryption                8\n#define OBJ_md5WithRSAEncryption                OBJ_pkcs1,4L\n\n#define SN_sha1WithRSAEncryption                \"RSA-SHA1\"\n#define LN_sha1WithRSAEncryption                \"sha1WithRSAEncryption\"\n#define NID_sha1WithRSAEncryption               65\n#define OBJ_sha1WithRSAEncryption               OBJ_pkcs1,5L\n\n#define SN_rsaesOaep            \"RSAES-OAEP\"\n#define LN_rsaesOaep            \"rsaesOaep\"\n#define NID_rsaesOaep           919\n#define OBJ_rsaesOaep           OBJ_pkcs1,7L\n\n#define SN_mgf1         \"MGF1\"\n#define LN_mgf1         \"mgf1\"\n#define NID_mgf1                911\n#define OBJ_mgf1                OBJ_pkcs1,8L\n\n#define SN_pSpecified           \"PSPECIFIED\"\n#define LN_pSpecified           \"pSpecified\"\n#define NID_pSpecified          935\n#define OBJ_pSpecified          OBJ_pkcs1,9L\n\n#define SN_rsassaPss            \"RSASSA-PSS\"\n#define LN_rsassaPss            \"rsassaPss\"\n#define NID_rsassaPss           912\n#define OBJ_rsassaPss           OBJ_pkcs1,10L\n\n#define SN_sha256WithRSAEncryption              \"RSA-SHA256\"\n#define LN_sha256WithRSAEncryption              \"sha256WithRSAEncryption\"\n#define NID_sha256WithRSAEncryption             668\n#define OBJ_sha256WithRSAEncryption             OBJ_pkcs1,11L\n\n#define SN_sha384WithRSAEncryption              \"RSA-SHA384\"\n#define LN_sha384WithRSAEncryption              \"sha384WithRSAEncryption\"\n#define NID_sha384WithRSAEncryption             669\n#define OBJ_sha384WithRSAEncryption             OBJ_pkcs1,12L\n\n#define SN_sha512WithRSAEncryption              \"RSA-SHA512\"\n#define LN_sha512WithRSAEncryption              \"sha512WithRSAEncryption\"\n#define NID_sha512WithRSAEncryption             670\n#define OBJ_sha512WithRSAEncryption             OBJ_pkcs1,13L\n\n#define SN_sha224WithRSAEncryption              \"RSA-SHA224\"\n#define LN_sha224WithRSAEncryption              \"sha224WithRSAEncryption\"\n#define NID_sha224WithRSAEncryption             671\n#define OBJ_sha224WithRSAEncryption             OBJ_pkcs1,14L\n\n#define SN_pkcs3                \"pkcs3\"\n#define NID_pkcs3               27\n#define OBJ_pkcs3               OBJ_pkcs,3L\n\n#define LN_dhKeyAgreement               \"dhKeyAgreement\"\n#define NID_dhKeyAgreement              28\n#define OBJ_dhKeyAgreement              OBJ_pkcs3,1L\n\n#define SN_pkcs5                \"pkcs5\"\n#define NID_pkcs5               187\n#define OBJ_pkcs5               OBJ_pkcs,5L\n\n#define SN_pbeWithMD2AndDES_CBC         \"PBE-MD2-DES\"\n#define LN_pbeWithMD2AndDES_CBC         \"pbeWithMD2AndDES-CBC\"\n#define NID_pbeWithMD2AndDES_CBC                9\n#define OBJ_pbeWithMD2AndDES_CBC                OBJ_pkcs5,1L\n\n#define SN_pbeWithMD5AndDES_CBC         \"PBE-MD5-DES\"\n#define LN_pbeWithMD5AndDES_CBC         \"pbeWithMD5AndDES-CBC\"\n#define NID_pbeWithMD5AndDES_CBC                10\n#define OBJ_pbeWithMD5AndDES_CBC                OBJ_pkcs5,3L\n\n#define SN_pbeWithMD2AndRC2_CBC         \"PBE-MD2-RC2-64\"\n#define LN_pbeWithMD2AndRC2_CBC         \"pbeWithMD2AndRC2-CBC\"\n#define NID_pbeWithMD2AndRC2_CBC                168\n#define OBJ_pbeWithMD2AndRC2_CBC                OBJ_pkcs5,4L\n\n#define SN_pbeWithMD5AndRC2_CBC         \"PBE-MD5-RC2-64\"\n#define LN_pbeWithMD5AndRC2_CBC         \"pbeWithMD5AndRC2-CBC\"\n#define NID_pbeWithMD5AndRC2_CBC                169\n#define OBJ_pbeWithMD5AndRC2_CBC                OBJ_pkcs5,6L\n\n#define SN_pbeWithSHA1AndDES_CBC                \"PBE-SHA1-DES\"\n#define LN_pbeWithSHA1AndDES_CBC                \"pbeWithSHA1AndDES-CBC\"\n#define NID_pbeWithSHA1AndDES_CBC               170\n#define OBJ_pbeWithSHA1AndDES_CBC               OBJ_pkcs5,10L\n\n#define SN_pbeWithSHA1AndRC2_CBC                \"PBE-SHA1-RC2-64\"\n#define LN_pbeWithSHA1AndRC2_CBC                \"pbeWithSHA1AndRC2-CBC\"\n#define NID_pbeWithSHA1AndRC2_CBC               68\n#define OBJ_pbeWithSHA1AndRC2_CBC               OBJ_pkcs5,11L\n\n#define LN_id_pbkdf2            \"PBKDF2\"\n#define NID_id_pbkdf2           69\n#define OBJ_id_pbkdf2           OBJ_pkcs5,12L\n\n#define LN_pbes2                \"PBES2\"\n#define NID_pbes2               161\n#define OBJ_pbes2               OBJ_pkcs5,13L\n\n#define LN_pbmac1               \"PBMAC1\"\n#define NID_pbmac1              162\n#define OBJ_pbmac1              OBJ_pkcs5,14L\n\n#define SN_pkcs7                \"pkcs7\"\n#define NID_pkcs7               20\n#define OBJ_pkcs7               OBJ_pkcs,7L\n\n#define LN_pkcs7_data           \"pkcs7-data\"\n#define NID_pkcs7_data          21\n#define OBJ_pkcs7_data          OBJ_pkcs7,1L\n\n#define LN_pkcs7_signed         \"pkcs7-signedData\"\n#define NID_pkcs7_signed                22\n#define OBJ_pkcs7_signed                OBJ_pkcs7,2L\n\n#define LN_pkcs7_enveloped              \"pkcs7-envelopedData\"\n#define NID_pkcs7_enveloped             23\n#define OBJ_pkcs7_enveloped             OBJ_pkcs7,3L\n\n#define LN_pkcs7_signedAndEnveloped             \"pkcs7-signedAndEnvelopedData\"\n#define NID_pkcs7_signedAndEnveloped            24\n#define OBJ_pkcs7_signedAndEnveloped            OBJ_pkcs7,4L\n\n#define LN_pkcs7_digest         \"pkcs7-digestData\"\n#define NID_pkcs7_digest                25\n#define OBJ_pkcs7_digest                OBJ_pkcs7,5L\n\n#define LN_pkcs7_encrypted              \"pkcs7-encryptedData\"\n#define NID_pkcs7_encrypted             26\n#define OBJ_pkcs7_encrypted             OBJ_pkcs7,6L\n\n#define SN_pkcs9                \"pkcs9\"\n#define NID_pkcs9               47\n#define OBJ_pkcs9               OBJ_pkcs,9L\n\n#define LN_pkcs9_emailAddress           \"emailAddress\"\n#define NID_pkcs9_emailAddress          48\n#define OBJ_pkcs9_emailAddress          OBJ_pkcs9,1L\n\n#define LN_pkcs9_unstructuredName               \"unstructuredName\"\n#define NID_pkcs9_unstructuredName              49\n#define OBJ_pkcs9_unstructuredName              OBJ_pkcs9,2L\n\n#define LN_pkcs9_contentType            \"contentType\"\n#define NID_pkcs9_contentType           50\n#define OBJ_pkcs9_contentType           OBJ_pkcs9,3L\n\n#define LN_pkcs9_messageDigest          \"messageDigest\"\n#define NID_pkcs9_messageDigest         51\n#define OBJ_pkcs9_messageDigest         OBJ_pkcs9,4L\n\n#define LN_pkcs9_signingTime            \"signingTime\"\n#define NID_pkcs9_signingTime           52\n#define OBJ_pkcs9_signingTime           OBJ_pkcs9,5L\n\n#define LN_pkcs9_countersignature               \"countersignature\"\n#define NID_pkcs9_countersignature              53\n#define OBJ_pkcs9_countersignature              OBJ_pkcs9,6L\n\n#define LN_pkcs9_challengePassword              \"challengePassword\"\n#define NID_pkcs9_challengePassword             54\n#define OBJ_pkcs9_challengePassword             OBJ_pkcs9,7L\n\n#define LN_pkcs9_unstructuredAddress            \"unstructuredAddress\"\n#define NID_pkcs9_unstructuredAddress           55\n#define OBJ_pkcs9_unstructuredAddress           OBJ_pkcs9,8L\n\n#define LN_pkcs9_extCertAttributes              \"extendedCertificateAttributes\"\n#define NID_pkcs9_extCertAttributes             56\n#define OBJ_pkcs9_extCertAttributes             OBJ_pkcs9,9L\n\n#define SN_ext_req              \"extReq\"\n#define LN_ext_req              \"Extension Request\"\n#define NID_ext_req             172\n#define OBJ_ext_req             OBJ_pkcs9,14L\n\n#define SN_SMIMECapabilities            \"SMIME-CAPS\"\n#define LN_SMIMECapabilities            \"S/MIME Capabilities\"\n#define NID_SMIMECapabilities           167\n#define OBJ_SMIMECapabilities           OBJ_pkcs9,15L\n\n#define SN_SMIME                \"SMIME\"\n#define LN_SMIME                \"S/MIME\"\n#define NID_SMIME               188\n#define OBJ_SMIME               OBJ_pkcs9,16L\n\n#define SN_id_smime_mod         \"id-smime-mod\"\n#define NID_id_smime_mod                189\n#define OBJ_id_smime_mod                OBJ_SMIME,0L\n\n#define SN_id_smime_ct          \"id-smime-ct\"\n#define NID_id_smime_ct         190\n#define OBJ_id_smime_ct         OBJ_SMIME,1L\n\n#define SN_id_smime_aa          \"id-smime-aa\"\n#define NID_id_smime_aa         191\n#define OBJ_id_smime_aa         OBJ_SMIME,2L\n\n#define SN_id_smime_alg         \"id-smime-alg\"\n#define NID_id_smime_alg                192\n#define OBJ_id_smime_alg                OBJ_SMIME,3L\n\n#define SN_id_smime_cd          \"id-smime-cd\"\n#define NID_id_smime_cd         193\n#define OBJ_id_smime_cd         OBJ_SMIME,4L\n\n#define SN_id_smime_spq         \"id-smime-spq\"\n#define NID_id_smime_spq                194\n#define OBJ_id_smime_spq                OBJ_SMIME,5L\n\n#define SN_id_smime_cti         \"id-smime-cti\"\n#define NID_id_smime_cti                195\n#define OBJ_id_smime_cti                OBJ_SMIME,6L\n\n#define SN_id_smime_mod_cms             \"id-smime-mod-cms\"\n#define NID_id_smime_mod_cms            196\n#define OBJ_id_smime_mod_cms            OBJ_id_smime_mod,1L\n\n#define SN_id_smime_mod_ess             \"id-smime-mod-ess\"\n#define NID_id_smime_mod_ess            197\n#define OBJ_id_smime_mod_ess            OBJ_id_smime_mod,2L\n\n#define SN_id_smime_mod_oid             \"id-smime-mod-oid\"\n#define NID_id_smime_mod_oid            198\n#define OBJ_id_smime_mod_oid            OBJ_id_smime_mod,3L\n\n#define SN_id_smime_mod_msg_v3          \"id-smime-mod-msg-v3\"\n#define NID_id_smime_mod_msg_v3         199\n#define OBJ_id_smime_mod_msg_v3         OBJ_id_smime_mod,4L\n\n#define SN_id_smime_mod_ets_eSignature_88               \"id-smime-mod-ets-eSignature-88\"\n#define NID_id_smime_mod_ets_eSignature_88              200\n#define OBJ_id_smime_mod_ets_eSignature_88              OBJ_id_smime_mod,5L\n\n#define SN_id_smime_mod_ets_eSignature_97               \"id-smime-mod-ets-eSignature-97\"\n#define NID_id_smime_mod_ets_eSignature_97              201\n#define OBJ_id_smime_mod_ets_eSignature_97              OBJ_id_smime_mod,6L\n\n#define SN_id_smime_mod_ets_eSigPolicy_88               \"id-smime-mod-ets-eSigPolicy-88\"\n#define NID_id_smime_mod_ets_eSigPolicy_88              202\n#define OBJ_id_smime_mod_ets_eSigPolicy_88              OBJ_id_smime_mod,7L\n\n#define SN_id_smime_mod_ets_eSigPolicy_97               \"id-smime-mod-ets-eSigPolicy-97\"\n#define NID_id_smime_mod_ets_eSigPolicy_97              203\n#define OBJ_id_smime_mod_ets_eSigPolicy_97              OBJ_id_smime_mod,8L\n\n#define SN_id_smime_ct_receipt          \"id-smime-ct-receipt\"\n#define NID_id_smime_ct_receipt         204\n#define OBJ_id_smime_ct_receipt         OBJ_id_smime_ct,1L\n\n#define SN_id_smime_ct_authData         \"id-smime-ct-authData\"\n#define NID_id_smime_ct_authData                205\n#define OBJ_id_smime_ct_authData                OBJ_id_smime_ct,2L\n\n#define SN_id_smime_ct_publishCert              \"id-smime-ct-publishCert\"\n#define NID_id_smime_ct_publishCert             206\n#define OBJ_id_smime_ct_publishCert             OBJ_id_smime_ct,3L\n\n#define SN_id_smime_ct_TSTInfo          \"id-smime-ct-TSTInfo\"\n#define NID_id_smime_ct_TSTInfo         207\n#define OBJ_id_smime_ct_TSTInfo         OBJ_id_smime_ct,4L\n\n#define SN_id_smime_ct_TDTInfo          \"id-smime-ct-TDTInfo\"\n#define NID_id_smime_ct_TDTInfo         208\n#define OBJ_id_smime_ct_TDTInfo         OBJ_id_smime_ct,5L\n\n#define SN_id_smime_ct_contentInfo              \"id-smime-ct-contentInfo\"\n#define NID_id_smime_ct_contentInfo             209\n#define OBJ_id_smime_ct_contentInfo             OBJ_id_smime_ct,6L\n\n#define SN_id_smime_ct_DVCSRequestData          \"id-smime-ct-DVCSRequestData\"\n#define NID_id_smime_ct_DVCSRequestData         210\n#define OBJ_id_smime_ct_DVCSRequestData         OBJ_id_smime_ct,7L\n\n#define SN_id_smime_ct_DVCSResponseData         \"id-smime-ct-DVCSResponseData\"\n#define NID_id_smime_ct_DVCSResponseData                211\n#define OBJ_id_smime_ct_DVCSResponseData                OBJ_id_smime_ct,8L\n\n#define SN_id_smime_ct_compressedData           \"id-smime-ct-compressedData\"\n#define NID_id_smime_ct_compressedData          786\n#define OBJ_id_smime_ct_compressedData          OBJ_id_smime_ct,9L\n\n#define SN_id_ct_asciiTextWithCRLF              \"id-ct-asciiTextWithCRLF\"\n#define NID_id_ct_asciiTextWithCRLF             787\n#define OBJ_id_ct_asciiTextWithCRLF             OBJ_id_smime_ct,27L\n\n#define SN_id_smime_aa_receiptRequest           \"id-smime-aa-receiptRequest\"\n#define NID_id_smime_aa_receiptRequest          212\n#define OBJ_id_smime_aa_receiptRequest          OBJ_id_smime_aa,1L\n\n#define SN_id_smime_aa_securityLabel            \"id-smime-aa-securityLabel\"\n#define NID_id_smime_aa_securityLabel           213\n#define OBJ_id_smime_aa_securityLabel           OBJ_id_smime_aa,2L\n\n#define SN_id_smime_aa_mlExpandHistory          \"id-smime-aa-mlExpandHistory\"\n#define NID_id_smime_aa_mlExpandHistory         214\n#define OBJ_id_smime_aa_mlExpandHistory         OBJ_id_smime_aa,3L\n\n#define SN_id_smime_aa_contentHint              \"id-smime-aa-contentHint\"\n#define NID_id_smime_aa_contentHint             215\n#define OBJ_id_smime_aa_contentHint             OBJ_id_smime_aa,4L\n\n#define SN_id_smime_aa_msgSigDigest             \"id-smime-aa-msgSigDigest\"\n#define NID_id_smime_aa_msgSigDigest            216\n#define OBJ_id_smime_aa_msgSigDigest            OBJ_id_smime_aa,5L\n\n#define SN_id_smime_aa_encapContentType         \"id-smime-aa-encapContentType\"\n#define NID_id_smime_aa_encapContentType                217\n#define OBJ_id_smime_aa_encapContentType                OBJ_id_smime_aa,6L\n\n#define SN_id_smime_aa_contentIdentifier                \"id-smime-aa-contentIdentifier\"\n#define NID_id_smime_aa_contentIdentifier               218\n#define OBJ_id_smime_aa_contentIdentifier               OBJ_id_smime_aa,7L\n\n#define SN_id_smime_aa_macValue         \"id-smime-aa-macValue\"\n#define NID_id_smime_aa_macValue                219\n#define OBJ_id_smime_aa_macValue                OBJ_id_smime_aa,8L\n\n#define SN_id_smime_aa_equivalentLabels         \"id-smime-aa-equivalentLabels\"\n#define NID_id_smime_aa_equivalentLabels                220\n#define OBJ_id_smime_aa_equivalentLabels                OBJ_id_smime_aa,9L\n\n#define SN_id_smime_aa_contentReference         \"id-smime-aa-contentReference\"\n#define NID_id_smime_aa_contentReference                221\n#define OBJ_id_smime_aa_contentReference                OBJ_id_smime_aa,10L\n\n#define SN_id_smime_aa_encrypKeyPref            \"id-smime-aa-encrypKeyPref\"\n#define NID_id_smime_aa_encrypKeyPref           222\n#define OBJ_id_smime_aa_encrypKeyPref           OBJ_id_smime_aa,11L\n\n#define SN_id_smime_aa_signingCertificate               \"id-smime-aa-signingCertificate\"\n#define NID_id_smime_aa_signingCertificate              223\n#define OBJ_id_smime_aa_signingCertificate              OBJ_id_smime_aa,12L\n\n#define SN_id_smime_aa_smimeEncryptCerts                \"id-smime-aa-smimeEncryptCerts\"\n#define NID_id_smime_aa_smimeEncryptCerts               224\n#define OBJ_id_smime_aa_smimeEncryptCerts               OBJ_id_smime_aa,13L\n\n#define SN_id_smime_aa_timeStampToken           \"id-smime-aa-timeStampToken\"\n#define NID_id_smime_aa_timeStampToken          225\n#define OBJ_id_smime_aa_timeStampToken          OBJ_id_smime_aa,14L\n\n#define SN_id_smime_aa_ets_sigPolicyId          \"id-smime-aa-ets-sigPolicyId\"\n#define NID_id_smime_aa_ets_sigPolicyId         226\n#define OBJ_id_smime_aa_ets_sigPolicyId         OBJ_id_smime_aa,15L\n\n#define SN_id_smime_aa_ets_commitmentType               \"id-smime-aa-ets-commitmentType\"\n#define NID_id_smime_aa_ets_commitmentType              227\n#define OBJ_id_smime_aa_ets_commitmentType              OBJ_id_smime_aa,16L\n\n#define SN_id_smime_aa_ets_signerLocation               \"id-smime-aa-ets-signerLocation\"\n#define NID_id_smime_aa_ets_signerLocation              228\n#define OBJ_id_smime_aa_ets_signerLocation              OBJ_id_smime_aa,17L\n\n#define SN_id_smime_aa_ets_signerAttr           \"id-smime-aa-ets-signerAttr\"\n#define NID_id_smime_aa_ets_signerAttr          229\n#define OBJ_id_smime_aa_ets_signerAttr          OBJ_id_smime_aa,18L\n\n#define SN_id_smime_aa_ets_otherSigCert         \"id-smime-aa-ets-otherSigCert\"\n#define NID_id_smime_aa_ets_otherSigCert                230\n#define OBJ_id_smime_aa_ets_otherSigCert                OBJ_id_smime_aa,19L\n\n#define SN_id_smime_aa_ets_contentTimestamp             \"id-smime-aa-ets-contentTimestamp\"\n#define NID_id_smime_aa_ets_contentTimestamp            231\n#define OBJ_id_smime_aa_ets_contentTimestamp            OBJ_id_smime_aa,20L\n\n#define SN_id_smime_aa_ets_CertificateRefs              \"id-smime-aa-ets-CertificateRefs\"\n#define NID_id_smime_aa_ets_CertificateRefs             232\n#define OBJ_id_smime_aa_ets_CertificateRefs             OBJ_id_smime_aa,21L\n\n#define SN_id_smime_aa_ets_RevocationRefs               \"id-smime-aa-ets-RevocationRefs\"\n#define NID_id_smime_aa_ets_RevocationRefs              233\n#define OBJ_id_smime_aa_ets_RevocationRefs              OBJ_id_smime_aa,22L\n\n#define SN_id_smime_aa_ets_certValues           \"id-smime-aa-ets-certValues\"\n#define NID_id_smime_aa_ets_certValues          234\n#define OBJ_id_smime_aa_ets_certValues          OBJ_id_smime_aa,23L\n\n#define SN_id_smime_aa_ets_revocationValues             \"id-smime-aa-ets-revocationValues\"\n#define NID_id_smime_aa_ets_revocationValues            235\n#define OBJ_id_smime_aa_ets_revocationValues            OBJ_id_smime_aa,24L\n\n#define SN_id_smime_aa_ets_escTimeStamp         \"id-smime-aa-ets-escTimeStamp\"\n#define NID_id_smime_aa_ets_escTimeStamp                236\n#define OBJ_id_smime_aa_ets_escTimeStamp                OBJ_id_smime_aa,25L\n\n#define SN_id_smime_aa_ets_certCRLTimestamp             \"id-smime-aa-ets-certCRLTimestamp\"\n#define NID_id_smime_aa_ets_certCRLTimestamp            237\n#define OBJ_id_smime_aa_ets_certCRLTimestamp            OBJ_id_smime_aa,26L\n\n#define SN_id_smime_aa_ets_archiveTimeStamp             \"id-smime-aa-ets-archiveTimeStamp\"\n#define NID_id_smime_aa_ets_archiveTimeStamp            238\n#define OBJ_id_smime_aa_ets_archiveTimeStamp            OBJ_id_smime_aa,27L\n\n#define SN_id_smime_aa_signatureType            \"id-smime-aa-signatureType\"\n#define NID_id_smime_aa_signatureType           239\n#define OBJ_id_smime_aa_signatureType           OBJ_id_smime_aa,28L\n\n#define SN_id_smime_aa_dvcs_dvc         \"id-smime-aa-dvcs-dvc\"\n#define NID_id_smime_aa_dvcs_dvc                240\n#define OBJ_id_smime_aa_dvcs_dvc                OBJ_id_smime_aa,29L\n\n#define SN_id_smime_alg_ESDHwith3DES            \"id-smime-alg-ESDHwith3DES\"\n#define NID_id_smime_alg_ESDHwith3DES           241\n#define OBJ_id_smime_alg_ESDHwith3DES           OBJ_id_smime_alg,1L\n\n#define SN_id_smime_alg_ESDHwithRC2             \"id-smime-alg-ESDHwithRC2\"\n#define NID_id_smime_alg_ESDHwithRC2            242\n#define OBJ_id_smime_alg_ESDHwithRC2            OBJ_id_smime_alg,2L\n\n#define SN_id_smime_alg_3DESwrap                \"id-smime-alg-3DESwrap\"\n#define NID_id_smime_alg_3DESwrap               243\n#define OBJ_id_smime_alg_3DESwrap               OBJ_id_smime_alg,3L\n\n#define SN_id_smime_alg_RC2wrap         \"id-smime-alg-RC2wrap\"\n#define NID_id_smime_alg_RC2wrap                244\n#define OBJ_id_smime_alg_RC2wrap                OBJ_id_smime_alg,4L\n\n#define SN_id_smime_alg_ESDH            \"id-smime-alg-ESDH\"\n#define NID_id_smime_alg_ESDH           245\n#define OBJ_id_smime_alg_ESDH           OBJ_id_smime_alg,5L\n\n#define SN_id_smime_alg_CMS3DESwrap             \"id-smime-alg-CMS3DESwrap\"\n#define NID_id_smime_alg_CMS3DESwrap            246\n#define OBJ_id_smime_alg_CMS3DESwrap            OBJ_id_smime_alg,6L\n\n#define SN_id_smime_alg_CMSRC2wrap              \"id-smime-alg-CMSRC2wrap\"\n#define NID_id_smime_alg_CMSRC2wrap             247\n#define OBJ_id_smime_alg_CMSRC2wrap             OBJ_id_smime_alg,7L\n\n#define SN_id_alg_PWRI_KEK              \"id-alg-PWRI-KEK\"\n#define NID_id_alg_PWRI_KEK             893\n#define OBJ_id_alg_PWRI_KEK             OBJ_id_smime_alg,9L\n\n#define SN_id_smime_cd_ldap             \"id-smime-cd-ldap\"\n#define NID_id_smime_cd_ldap            248\n#define OBJ_id_smime_cd_ldap            OBJ_id_smime_cd,1L\n\n#define SN_id_smime_spq_ets_sqt_uri             \"id-smime-spq-ets-sqt-uri\"\n#define NID_id_smime_spq_ets_sqt_uri            249\n#define OBJ_id_smime_spq_ets_sqt_uri            OBJ_id_smime_spq,1L\n\n#define SN_id_smime_spq_ets_sqt_unotice         \"id-smime-spq-ets-sqt-unotice\"\n#define NID_id_smime_spq_ets_sqt_unotice                250\n#define OBJ_id_smime_spq_ets_sqt_unotice                OBJ_id_smime_spq,2L\n\n#define SN_id_smime_cti_ets_proofOfOrigin               \"id-smime-cti-ets-proofOfOrigin\"\n#define NID_id_smime_cti_ets_proofOfOrigin              251\n#define OBJ_id_smime_cti_ets_proofOfOrigin              OBJ_id_smime_cti,1L\n\n#define SN_id_smime_cti_ets_proofOfReceipt              \"id-smime-cti-ets-proofOfReceipt\"\n#define NID_id_smime_cti_ets_proofOfReceipt             252\n#define OBJ_id_smime_cti_ets_proofOfReceipt             OBJ_id_smime_cti,2L\n\n#define SN_id_smime_cti_ets_proofOfDelivery             \"id-smime-cti-ets-proofOfDelivery\"\n#define NID_id_smime_cti_ets_proofOfDelivery            253\n#define OBJ_id_smime_cti_ets_proofOfDelivery            OBJ_id_smime_cti,3L\n\n#define SN_id_smime_cti_ets_proofOfSender               \"id-smime-cti-ets-proofOfSender\"\n#define NID_id_smime_cti_ets_proofOfSender              254\n#define OBJ_id_smime_cti_ets_proofOfSender              OBJ_id_smime_cti,4L\n\n#define SN_id_smime_cti_ets_proofOfApproval             \"id-smime-cti-ets-proofOfApproval\"\n#define NID_id_smime_cti_ets_proofOfApproval            255\n#define OBJ_id_smime_cti_ets_proofOfApproval            OBJ_id_smime_cti,5L\n\n#define SN_id_smime_cti_ets_proofOfCreation             \"id-smime-cti-ets-proofOfCreation\"\n#define NID_id_smime_cti_ets_proofOfCreation            256\n#define OBJ_id_smime_cti_ets_proofOfCreation            OBJ_id_smime_cti,6L\n\n#define LN_friendlyName         \"friendlyName\"\n#define NID_friendlyName                156\n#define OBJ_friendlyName                OBJ_pkcs9,20L\n\n#define LN_localKeyID           \"localKeyID\"\n#define NID_localKeyID          157\n#define OBJ_localKeyID          OBJ_pkcs9,21L\n\n#define SN_ms_csp_name          \"CSPName\"\n#define LN_ms_csp_name          \"Microsoft CSP Name\"\n#define NID_ms_csp_name         417\n#define OBJ_ms_csp_name         1L,3L,6L,1L,4L,1L,311L,17L,1L\n\n#define SN_LocalKeySet          \"LocalKeySet\"\n#define LN_LocalKeySet          \"Microsoft Local Key set\"\n#define NID_LocalKeySet         856\n#define OBJ_LocalKeySet         1L,3L,6L,1L,4L,1L,311L,17L,2L\n\n#define OBJ_certTypes           OBJ_pkcs9,22L\n\n#define LN_x509Certificate              \"x509Certificate\"\n#define NID_x509Certificate             158\n#define OBJ_x509Certificate             OBJ_certTypes,1L\n\n#define LN_sdsiCertificate              \"sdsiCertificate\"\n#define NID_sdsiCertificate             159\n#define OBJ_sdsiCertificate             OBJ_certTypes,2L\n\n#define OBJ_crlTypes            OBJ_pkcs9,23L\n\n#define LN_x509Crl              \"x509Crl\"\n#define NID_x509Crl             160\n#define OBJ_x509Crl             OBJ_crlTypes,1L\n\n#define OBJ_pkcs12              OBJ_pkcs,12L\n\n#define OBJ_pkcs12_pbeids               OBJ_pkcs12,1L\n\n#define SN_pbe_WithSHA1And128BitRC4             \"PBE-SHA1-RC4-128\"\n#define LN_pbe_WithSHA1And128BitRC4             \"pbeWithSHA1And128BitRC4\"\n#define NID_pbe_WithSHA1And128BitRC4            144\n#define OBJ_pbe_WithSHA1And128BitRC4            OBJ_pkcs12_pbeids,1L\n\n#define SN_pbe_WithSHA1And40BitRC4              \"PBE-SHA1-RC4-40\"\n#define LN_pbe_WithSHA1And40BitRC4              \"pbeWithSHA1And40BitRC4\"\n#define NID_pbe_WithSHA1And40BitRC4             145\n#define OBJ_pbe_WithSHA1And40BitRC4             OBJ_pkcs12_pbeids,2L\n\n#define SN_pbe_WithSHA1And3_Key_TripleDES_CBC           \"PBE-SHA1-3DES\"\n#define LN_pbe_WithSHA1And3_Key_TripleDES_CBC           \"pbeWithSHA1And3-KeyTripleDES-CBC\"\n#define NID_pbe_WithSHA1And3_Key_TripleDES_CBC          146\n#define OBJ_pbe_WithSHA1And3_Key_TripleDES_CBC          OBJ_pkcs12_pbeids,3L\n\n#define SN_pbe_WithSHA1And2_Key_TripleDES_CBC           \"PBE-SHA1-2DES\"\n#define LN_pbe_WithSHA1And2_Key_TripleDES_CBC           \"pbeWithSHA1And2-KeyTripleDES-CBC\"\n#define NID_pbe_WithSHA1And2_Key_TripleDES_CBC          147\n#define OBJ_pbe_WithSHA1And2_Key_TripleDES_CBC          OBJ_pkcs12_pbeids,4L\n\n#define SN_pbe_WithSHA1And128BitRC2_CBC         \"PBE-SHA1-RC2-128\"\n#define LN_pbe_WithSHA1And128BitRC2_CBC         \"pbeWithSHA1And128BitRC2-CBC\"\n#define NID_pbe_WithSHA1And128BitRC2_CBC                148\n#define OBJ_pbe_WithSHA1And128BitRC2_CBC                OBJ_pkcs12_pbeids,5L\n\n#define SN_pbe_WithSHA1And40BitRC2_CBC          \"PBE-SHA1-RC2-40\"\n#define LN_pbe_WithSHA1And40BitRC2_CBC          \"pbeWithSHA1And40BitRC2-CBC\"\n#define NID_pbe_WithSHA1And40BitRC2_CBC         149\n#define OBJ_pbe_WithSHA1And40BitRC2_CBC         OBJ_pkcs12_pbeids,6L\n\n#define OBJ_pkcs12_Version1             OBJ_pkcs12,10L\n\n#define OBJ_pkcs12_BagIds               OBJ_pkcs12_Version1,1L\n\n#define LN_keyBag               \"keyBag\"\n#define NID_keyBag              150\n#define OBJ_keyBag              OBJ_pkcs12_BagIds,1L\n\n#define LN_pkcs8ShroudedKeyBag          \"pkcs8ShroudedKeyBag\"\n#define NID_pkcs8ShroudedKeyBag         151\n#define OBJ_pkcs8ShroudedKeyBag         OBJ_pkcs12_BagIds,2L\n\n#define LN_certBag              \"certBag\"\n#define NID_certBag             152\n#define OBJ_certBag             OBJ_pkcs12_BagIds,3L\n\n#define LN_crlBag               \"crlBag\"\n#define NID_crlBag              153\n#define OBJ_crlBag              OBJ_pkcs12_BagIds,4L\n\n#define LN_secretBag            \"secretBag\"\n#define NID_secretBag           154\n#define OBJ_secretBag           OBJ_pkcs12_BagIds,5L\n\n#define LN_safeContentsBag              \"safeContentsBag\"\n#define NID_safeContentsBag             155\n#define OBJ_safeContentsBag             OBJ_pkcs12_BagIds,6L\n\n#define SN_md2          \"MD2\"\n#define LN_md2          \"md2\"\n#define NID_md2         3\n#define OBJ_md2         OBJ_rsadsi,2L,2L\n\n#define SN_md4          \"MD4\"\n#define LN_md4          \"md4\"\n#define NID_md4         257\n#define OBJ_md4         OBJ_rsadsi,2L,4L\n\n#define SN_md5          \"MD5\"\n#define LN_md5          \"md5\"\n#define NID_md5         4\n#define OBJ_md5         OBJ_rsadsi,2L,5L\n\n#define SN_md5_sha1             \"MD5-SHA1\"\n#define LN_md5_sha1             \"md5-sha1\"\n#define NID_md5_sha1            114\n\n#define LN_hmacWithMD5          \"hmacWithMD5\"\n#define NID_hmacWithMD5         797\n#define OBJ_hmacWithMD5         OBJ_rsadsi,2L,6L\n\n#define LN_hmacWithSHA1         \"hmacWithSHA1\"\n#define NID_hmacWithSHA1                163\n#define OBJ_hmacWithSHA1                OBJ_rsadsi,2L,7L\n\n#define LN_hmacWithSHA224               \"hmacWithSHA224\"\n#define NID_hmacWithSHA224              798\n#define OBJ_hmacWithSHA224              OBJ_rsadsi,2L,8L\n\n#define LN_hmacWithSHA256               \"hmacWithSHA256\"\n#define NID_hmacWithSHA256              799\n#define OBJ_hmacWithSHA256              OBJ_rsadsi,2L,9L\n\n#define LN_hmacWithSHA384               \"hmacWithSHA384\"\n#define NID_hmacWithSHA384              800\n#define OBJ_hmacWithSHA384              OBJ_rsadsi,2L,10L\n\n#define LN_hmacWithSHA512               \"hmacWithSHA512\"\n#define NID_hmacWithSHA512              801\n#define OBJ_hmacWithSHA512              OBJ_rsadsi,2L,11L\n\n#define SN_rc2_cbc              \"RC2-CBC\"\n#define LN_rc2_cbc              \"rc2-cbc\"\n#define NID_rc2_cbc             37\n#define OBJ_rc2_cbc             OBJ_rsadsi,3L,2L\n\n#define SN_rc2_ecb              \"RC2-ECB\"\n#define LN_rc2_ecb              \"rc2-ecb\"\n#define NID_rc2_ecb             38\n\n#define SN_rc2_cfb64            \"RC2-CFB\"\n#define LN_rc2_cfb64            \"rc2-cfb\"\n#define NID_rc2_cfb64           39\n\n#define SN_rc2_ofb64            \"RC2-OFB\"\n#define LN_rc2_ofb64            \"rc2-ofb\"\n#define NID_rc2_ofb64           40\n\n#define SN_rc2_40_cbc           \"RC2-40-CBC\"\n#define LN_rc2_40_cbc           \"rc2-40-cbc\"\n#define NID_rc2_40_cbc          98\n\n#define SN_rc2_64_cbc           \"RC2-64-CBC\"\n#define LN_rc2_64_cbc           \"rc2-64-cbc\"\n#define NID_rc2_64_cbc          166\n\n#define SN_rc4          \"RC4\"\n#define LN_rc4          \"rc4\"\n#define NID_rc4         5\n#define OBJ_rc4         OBJ_rsadsi,3L,4L\n\n#define SN_rc4_40               \"RC4-40\"\n#define LN_rc4_40               \"rc4-40\"\n#define NID_rc4_40              97\n\n#define SN_des_ede3_cbc         \"DES-EDE3-CBC\"\n#define LN_des_ede3_cbc         \"des-ede3-cbc\"\n#define NID_des_ede3_cbc                44\n#define OBJ_des_ede3_cbc                OBJ_rsadsi,3L,7L\n\n#define SN_rc5_cbc              \"RC5-CBC\"\n#define LN_rc5_cbc              \"rc5-cbc\"\n#define NID_rc5_cbc             120\n#define OBJ_rc5_cbc             OBJ_rsadsi,3L,8L\n\n#define SN_rc5_ecb              \"RC5-ECB\"\n#define LN_rc5_ecb              \"rc5-ecb\"\n#define NID_rc5_ecb             121\n\n#define SN_rc5_cfb64            \"RC5-CFB\"\n#define LN_rc5_cfb64            \"rc5-cfb\"\n#define NID_rc5_cfb64           122\n\n#define SN_rc5_ofb64            \"RC5-OFB\"\n#define LN_rc5_ofb64            \"rc5-ofb\"\n#define NID_rc5_ofb64           123\n\n#define SN_ms_ext_req           \"msExtReq\"\n#define LN_ms_ext_req           \"Microsoft Extension Request\"\n#define NID_ms_ext_req          171\n#define OBJ_ms_ext_req          1L,3L,6L,1L,4L,1L,311L,2L,1L,14L\n\n#define SN_ms_code_ind          \"msCodeInd\"\n#define LN_ms_code_ind          \"Microsoft Individual Code Signing\"\n#define NID_ms_code_ind         134\n#define OBJ_ms_code_ind         1L,3L,6L,1L,4L,1L,311L,2L,1L,21L\n\n#define SN_ms_code_com          \"msCodeCom\"\n#define LN_ms_code_com          \"Microsoft Commercial Code Signing\"\n#define NID_ms_code_com         135\n#define OBJ_ms_code_com         1L,3L,6L,1L,4L,1L,311L,2L,1L,22L\n\n#define SN_ms_ctl_sign          \"msCTLSign\"\n#define LN_ms_ctl_sign          \"Microsoft Trust List Signing\"\n#define NID_ms_ctl_sign         136\n#define OBJ_ms_ctl_sign         1L,3L,6L,1L,4L,1L,311L,10L,3L,1L\n\n#define SN_ms_sgc               \"msSGC\"\n#define LN_ms_sgc               \"Microsoft Server Gated Crypto\"\n#define NID_ms_sgc              137\n#define OBJ_ms_sgc              1L,3L,6L,1L,4L,1L,311L,10L,3L,3L\n\n#define SN_ms_efs               \"msEFS\"\n#define LN_ms_efs               \"Microsoft Encrypted File System\"\n#define NID_ms_efs              138\n#define OBJ_ms_efs              1L,3L,6L,1L,4L,1L,311L,10L,3L,4L\n\n#define SN_ms_smartcard_login           \"msSmartcardLogin\"\n#define LN_ms_smartcard_login           \"Microsoft Smartcardlogin\"\n#define NID_ms_smartcard_login          648\n#define OBJ_ms_smartcard_login          1L,3L,6L,1L,4L,1L,311L,20L,2L,2L\n\n#define SN_ms_upn               \"msUPN\"\n#define LN_ms_upn               \"Microsoft Universal Principal Name\"\n#define NID_ms_upn              649\n#define OBJ_ms_upn              1L,3L,6L,1L,4L,1L,311L,20L,2L,3L\n\n#define SN_idea_cbc             \"IDEA-CBC\"\n#define LN_idea_cbc             \"idea-cbc\"\n#define NID_idea_cbc            34\n#define OBJ_idea_cbc            1L,3L,6L,1L,4L,1L,188L,7L,1L,1L,2L\n\n#define SN_idea_ecb             \"IDEA-ECB\"\n#define LN_idea_ecb             \"idea-ecb\"\n#define NID_idea_ecb            36\n\n#define SN_idea_cfb64           \"IDEA-CFB\"\n#define LN_idea_cfb64           \"idea-cfb\"\n#define NID_idea_cfb64          35\n\n#define SN_idea_ofb64           \"IDEA-OFB\"\n#define LN_idea_ofb64           \"idea-ofb\"\n#define NID_idea_ofb64          46\n\n#define SN_bf_cbc               \"BF-CBC\"\n#define LN_bf_cbc               \"bf-cbc\"\n#define NID_bf_cbc              91\n#define OBJ_bf_cbc              1L,3L,6L,1L,4L,1L,3029L,1L,2L\n\n#define SN_bf_ecb               \"BF-ECB\"\n#define LN_bf_ecb               \"bf-ecb\"\n#define NID_bf_ecb              92\n\n#define SN_bf_cfb64             \"BF-CFB\"\n#define LN_bf_cfb64             \"bf-cfb\"\n#define NID_bf_cfb64            93\n\n#define SN_bf_ofb64             \"BF-OFB\"\n#define LN_bf_ofb64             \"bf-ofb\"\n#define NID_bf_ofb64            94\n\n#define SN_id_pkix              \"PKIX\"\n#define NID_id_pkix             127\n#define OBJ_id_pkix             1L,3L,6L,1L,5L,5L,7L\n\n#define SN_id_pkix_mod          \"id-pkix-mod\"\n#define NID_id_pkix_mod         258\n#define OBJ_id_pkix_mod         OBJ_id_pkix,0L\n\n#define SN_id_pe                \"id-pe\"\n#define NID_id_pe               175\n#define OBJ_id_pe               OBJ_id_pkix,1L\n\n#define SN_id_qt                \"id-qt\"\n#define NID_id_qt               259\n#define OBJ_id_qt               OBJ_id_pkix,2L\n\n#define SN_id_kp                \"id-kp\"\n#define NID_id_kp               128\n#define OBJ_id_kp               OBJ_id_pkix,3L\n\n#define SN_id_it                \"id-it\"\n#define NID_id_it               260\n#define OBJ_id_it               OBJ_id_pkix,4L\n\n#define SN_id_pkip              \"id-pkip\"\n#define NID_id_pkip             261\n#define OBJ_id_pkip             OBJ_id_pkix,5L\n\n#define SN_id_alg               \"id-alg\"\n#define NID_id_alg              262\n#define OBJ_id_alg              OBJ_id_pkix,6L\n\n#define SN_id_cmc               \"id-cmc\"\n#define NID_id_cmc              263\n#define OBJ_id_cmc              OBJ_id_pkix,7L\n\n#define SN_id_on                \"id-on\"\n#define NID_id_on               264\n#define OBJ_id_on               OBJ_id_pkix,8L\n\n#define SN_id_pda               \"id-pda\"\n#define NID_id_pda              265\n#define OBJ_id_pda              OBJ_id_pkix,9L\n\n#define SN_id_aca               \"id-aca\"\n#define NID_id_aca              266\n#define OBJ_id_aca              OBJ_id_pkix,10L\n\n#define SN_id_qcs               \"id-qcs\"\n#define NID_id_qcs              267\n#define OBJ_id_qcs              OBJ_id_pkix,11L\n\n#define SN_id_cct               \"id-cct\"\n#define NID_id_cct              268\n#define OBJ_id_cct              OBJ_id_pkix,12L\n\n#define SN_id_ppl               \"id-ppl\"\n#define NID_id_ppl              662\n#define OBJ_id_ppl              OBJ_id_pkix,21L\n\n#define SN_id_ad                \"id-ad\"\n#define NID_id_ad               176\n#define OBJ_id_ad               OBJ_id_pkix,48L\n\n#define SN_id_pkix1_explicit_88         \"id-pkix1-explicit-88\"\n#define NID_id_pkix1_explicit_88                269\n#define OBJ_id_pkix1_explicit_88                OBJ_id_pkix_mod,1L\n\n#define SN_id_pkix1_implicit_88         \"id-pkix1-implicit-88\"\n#define NID_id_pkix1_implicit_88                270\n#define OBJ_id_pkix1_implicit_88                OBJ_id_pkix_mod,2L\n\n#define SN_id_pkix1_explicit_93         \"id-pkix1-explicit-93\"\n#define NID_id_pkix1_explicit_93                271\n#define OBJ_id_pkix1_explicit_93                OBJ_id_pkix_mod,3L\n\n#define SN_id_pkix1_implicit_93         \"id-pkix1-implicit-93\"\n#define NID_id_pkix1_implicit_93                272\n#define OBJ_id_pkix1_implicit_93                OBJ_id_pkix_mod,4L\n\n#define SN_id_mod_crmf          \"id-mod-crmf\"\n#define NID_id_mod_crmf         273\n#define OBJ_id_mod_crmf         OBJ_id_pkix_mod,5L\n\n#define SN_id_mod_cmc           \"id-mod-cmc\"\n#define NID_id_mod_cmc          274\n#define OBJ_id_mod_cmc          OBJ_id_pkix_mod,6L\n\n#define SN_id_mod_kea_profile_88                \"id-mod-kea-profile-88\"\n#define NID_id_mod_kea_profile_88               275\n#define OBJ_id_mod_kea_profile_88               OBJ_id_pkix_mod,7L\n\n#define SN_id_mod_kea_profile_93                \"id-mod-kea-profile-93\"\n#define NID_id_mod_kea_profile_93               276\n#define OBJ_id_mod_kea_profile_93               OBJ_id_pkix_mod,8L\n\n#define SN_id_mod_cmp           \"id-mod-cmp\"\n#define NID_id_mod_cmp          277\n#define OBJ_id_mod_cmp          OBJ_id_pkix_mod,9L\n\n#define SN_id_mod_qualified_cert_88             \"id-mod-qualified-cert-88\"\n#define NID_id_mod_qualified_cert_88            278\n#define OBJ_id_mod_qualified_cert_88            OBJ_id_pkix_mod,10L\n\n#define SN_id_mod_qualified_cert_93             \"id-mod-qualified-cert-93\"\n#define NID_id_mod_qualified_cert_93            279\n#define OBJ_id_mod_qualified_cert_93            OBJ_id_pkix_mod,11L\n\n#define SN_id_mod_attribute_cert                \"id-mod-attribute-cert\"\n#define NID_id_mod_attribute_cert               280\n#define OBJ_id_mod_attribute_cert               OBJ_id_pkix_mod,12L\n\n#define SN_id_mod_timestamp_protocol            \"id-mod-timestamp-protocol\"\n#define NID_id_mod_timestamp_protocol           281\n#define OBJ_id_mod_timestamp_protocol           OBJ_id_pkix_mod,13L\n\n#define SN_id_mod_ocsp          \"id-mod-ocsp\"\n#define NID_id_mod_ocsp         282\n#define OBJ_id_mod_ocsp         OBJ_id_pkix_mod,14L\n\n#define SN_id_mod_dvcs          \"id-mod-dvcs\"\n#define NID_id_mod_dvcs         283\n#define OBJ_id_mod_dvcs         OBJ_id_pkix_mod,15L\n\n#define SN_id_mod_cmp2000               \"id-mod-cmp2000\"\n#define NID_id_mod_cmp2000              284\n#define OBJ_id_mod_cmp2000              OBJ_id_pkix_mod,16L\n\n#define SN_info_access          \"authorityInfoAccess\"\n#define LN_info_access          \"Authority Information Access\"\n#define NID_info_access         177\n#define OBJ_info_access         OBJ_id_pe,1L\n\n#define SN_biometricInfo                \"biometricInfo\"\n#define LN_biometricInfo                \"Biometric Info\"\n#define NID_biometricInfo               285\n#define OBJ_biometricInfo               OBJ_id_pe,2L\n\n#define SN_qcStatements         \"qcStatements\"\n#define NID_qcStatements                286\n#define OBJ_qcStatements                OBJ_id_pe,3L\n\n#define SN_ac_auditEntity               \"ac-auditEntity\"\n#define NID_ac_auditEntity              287\n#define OBJ_ac_auditEntity              OBJ_id_pe,4L\n\n#define SN_ac_targeting         \"ac-targeting\"\n#define NID_ac_targeting                288\n#define OBJ_ac_targeting                OBJ_id_pe,5L\n\n#define SN_aaControls           \"aaControls\"\n#define NID_aaControls          289\n#define OBJ_aaControls          OBJ_id_pe,6L\n\n#define SN_sbgp_ipAddrBlock             \"sbgp-ipAddrBlock\"\n#define NID_sbgp_ipAddrBlock            290\n#define OBJ_sbgp_ipAddrBlock            OBJ_id_pe,7L\n\n#define SN_sbgp_autonomousSysNum                \"sbgp-autonomousSysNum\"\n#define NID_sbgp_autonomousSysNum               291\n#define OBJ_sbgp_autonomousSysNum               OBJ_id_pe,8L\n\n#define SN_sbgp_routerIdentifier                \"sbgp-routerIdentifier\"\n#define NID_sbgp_routerIdentifier               292\n#define OBJ_sbgp_routerIdentifier               OBJ_id_pe,9L\n\n#define SN_ac_proxying          \"ac-proxying\"\n#define NID_ac_proxying         397\n#define OBJ_ac_proxying         OBJ_id_pe,10L\n\n#define SN_sinfo_access         \"subjectInfoAccess\"\n#define LN_sinfo_access         \"Subject Information Access\"\n#define NID_sinfo_access                398\n#define OBJ_sinfo_access                OBJ_id_pe,11L\n\n#define SN_proxyCertInfo                \"proxyCertInfo\"\n#define LN_proxyCertInfo                \"Proxy Certificate Information\"\n#define NID_proxyCertInfo               663\n#define OBJ_proxyCertInfo               OBJ_id_pe,14L\n\n#define SN_id_qt_cps            \"id-qt-cps\"\n#define LN_id_qt_cps            \"Policy Qualifier CPS\"\n#define NID_id_qt_cps           164\n#define OBJ_id_qt_cps           OBJ_id_qt,1L\n\n#define SN_id_qt_unotice                \"id-qt-unotice\"\n#define LN_id_qt_unotice                \"Policy Qualifier User Notice\"\n#define NID_id_qt_unotice               165\n#define OBJ_id_qt_unotice               OBJ_id_qt,2L\n\n#define SN_textNotice           \"textNotice\"\n#define NID_textNotice          293\n#define OBJ_textNotice          OBJ_id_qt,3L\n\n#define SN_server_auth          \"serverAuth\"\n#define LN_server_auth          \"TLS Web Server Authentication\"\n#define NID_server_auth         129\n#define OBJ_server_auth         OBJ_id_kp,1L\n\n#define SN_client_auth          \"clientAuth\"\n#define LN_client_auth          \"TLS Web Client Authentication\"\n#define NID_client_auth         130\n#define OBJ_client_auth         OBJ_id_kp,2L\n\n#define SN_code_sign            \"codeSigning\"\n#define LN_code_sign            \"Code Signing\"\n#define NID_code_sign           131\n#define OBJ_code_sign           OBJ_id_kp,3L\n\n#define SN_email_protect                \"emailProtection\"\n#define LN_email_protect                \"E-mail Protection\"\n#define NID_email_protect               132\n#define OBJ_email_protect               OBJ_id_kp,4L\n\n#define SN_ipsecEndSystem               \"ipsecEndSystem\"\n#define LN_ipsecEndSystem               \"IPSec End System\"\n#define NID_ipsecEndSystem              294\n#define OBJ_ipsecEndSystem              OBJ_id_kp,5L\n\n#define SN_ipsecTunnel          \"ipsecTunnel\"\n#define LN_ipsecTunnel          \"IPSec Tunnel\"\n#define NID_ipsecTunnel         295\n#define OBJ_ipsecTunnel         OBJ_id_kp,6L\n\n#define SN_ipsecUser            \"ipsecUser\"\n#define LN_ipsecUser            \"IPSec User\"\n#define NID_ipsecUser           296\n#define OBJ_ipsecUser           OBJ_id_kp,7L\n\n#define SN_time_stamp           \"timeStamping\"\n#define LN_time_stamp           \"Time Stamping\"\n#define NID_time_stamp          133\n#define OBJ_time_stamp          OBJ_id_kp,8L\n\n#define SN_OCSP_sign            \"OCSPSigning\"\n#define LN_OCSP_sign            \"OCSP Signing\"\n#define NID_OCSP_sign           180\n#define OBJ_OCSP_sign           OBJ_id_kp,9L\n\n#define SN_dvcs         \"DVCS\"\n#define LN_dvcs         \"dvcs\"\n#define NID_dvcs                297\n#define OBJ_dvcs                OBJ_id_kp,10L\n\n#define SN_id_it_caProtEncCert          \"id-it-caProtEncCert\"\n#define NID_id_it_caProtEncCert         298\n#define OBJ_id_it_caProtEncCert         OBJ_id_it,1L\n\n#define SN_id_it_signKeyPairTypes               \"id-it-signKeyPairTypes\"\n#define NID_id_it_signKeyPairTypes              299\n#define OBJ_id_it_signKeyPairTypes              OBJ_id_it,2L\n\n#define SN_id_it_encKeyPairTypes                \"id-it-encKeyPairTypes\"\n#define NID_id_it_encKeyPairTypes               300\n#define OBJ_id_it_encKeyPairTypes               OBJ_id_it,3L\n\n#define SN_id_it_preferredSymmAlg               \"id-it-preferredSymmAlg\"\n#define NID_id_it_preferredSymmAlg              301\n#define OBJ_id_it_preferredSymmAlg              OBJ_id_it,4L\n\n#define SN_id_it_caKeyUpdateInfo                \"id-it-caKeyUpdateInfo\"\n#define NID_id_it_caKeyUpdateInfo               302\n#define OBJ_id_it_caKeyUpdateInfo               OBJ_id_it,5L\n\n#define SN_id_it_currentCRL             \"id-it-currentCRL\"\n#define NID_id_it_currentCRL            303\n#define OBJ_id_it_currentCRL            OBJ_id_it,6L\n\n#define SN_id_it_unsupportedOIDs                \"id-it-unsupportedOIDs\"\n#define NID_id_it_unsupportedOIDs               304\n#define OBJ_id_it_unsupportedOIDs               OBJ_id_it,7L\n\n#define SN_id_it_subscriptionRequest            \"id-it-subscriptionRequest\"\n#define NID_id_it_subscriptionRequest           305\n#define OBJ_id_it_subscriptionRequest           OBJ_id_it,8L\n\n#define SN_id_it_subscriptionResponse           \"id-it-subscriptionResponse\"\n#define NID_id_it_subscriptionResponse          306\n#define OBJ_id_it_subscriptionResponse          OBJ_id_it,9L\n\n#define SN_id_it_keyPairParamReq                \"id-it-keyPairParamReq\"\n#define NID_id_it_keyPairParamReq               307\n#define OBJ_id_it_keyPairParamReq               OBJ_id_it,10L\n\n#define SN_id_it_keyPairParamRep                \"id-it-keyPairParamRep\"\n#define NID_id_it_keyPairParamRep               308\n#define OBJ_id_it_keyPairParamRep               OBJ_id_it,11L\n\n#define SN_id_it_revPassphrase          \"id-it-revPassphrase\"\n#define NID_id_it_revPassphrase         309\n#define OBJ_id_it_revPassphrase         OBJ_id_it,12L\n\n#define SN_id_it_implicitConfirm                \"id-it-implicitConfirm\"\n#define NID_id_it_implicitConfirm               310\n#define OBJ_id_it_implicitConfirm               OBJ_id_it,13L\n\n#define SN_id_it_confirmWaitTime                \"id-it-confirmWaitTime\"\n#define NID_id_it_confirmWaitTime               311\n#define OBJ_id_it_confirmWaitTime               OBJ_id_it,14L\n\n#define SN_id_it_origPKIMessage         \"id-it-origPKIMessage\"\n#define NID_id_it_origPKIMessage                312\n#define OBJ_id_it_origPKIMessage                OBJ_id_it,15L\n\n#define SN_id_it_suppLangTags           \"id-it-suppLangTags\"\n#define NID_id_it_suppLangTags          784\n#define OBJ_id_it_suppLangTags          OBJ_id_it,16L\n\n#define SN_id_regCtrl           \"id-regCtrl\"\n#define NID_id_regCtrl          313\n#define OBJ_id_regCtrl          OBJ_id_pkip,1L\n\n#define SN_id_regInfo           \"id-regInfo\"\n#define NID_id_regInfo          314\n#define OBJ_id_regInfo          OBJ_id_pkip,2L\n\n#define SN_id_regCtrl_regToken          \"id-regCtrl-regToken\"\n#define NID_id_regCtrl_regToken         315\n#define OBJ_id_regCtrl_regToken         OBJ_id_regCtrl,1L\n\n#define SN_id_regCtrl_authenticator             \"id-regCtrl-authenticator\"\n#define NID_id_regCtrl_authenticator            316\n#define OBJ_id_regCtrl_authenticator            OBJ_id_regCtrl,2L\n\n#define SN_id_regCtrl_pkiPublicationInfo                \"id-regCtrl-pkiPublicationInfo\"\n#define NID_id_regCtrl_pkiPublicationInfo               317\n#define OBJ_id_regCtrl_pkiPublicationInfo               OBJ_id_regCtrl,3L\n\n#define SN_id_regCtrl_pkiArchiveOptions         \"id-regCtrl-pkiArchiveOptions\"\n#define NID_id_regCtrl_pkiArchiveOptions                318\n#define OBJ_id_regCtrl_pkiArchiveOptions                OBJ_id_regCtrl,4L\n\n#define SN_id_regCtrl_oldCertID         \"id-regCtrl-oldCertID\"\n#define NID_id_regCtrl_oldCertID                319\n#define OBJ_id_regCtrl_oldCertID                OBJ_id_regCtrl,5L\n\n#define SN_id_regCtrl_protocolEncrKey           \"id-regCtrl-protocolEncrKey\"\n#define NID_id_regCtrl_protocolEncrKey          320\n#define OBJ_id_regCtrl_protocolEncrKey          OBJ_id_regCtrl,6L\n\n#define SN_id_regInfo_utf8Pairs         \"id-regInfo-utf8Pairs\"\n#define NID_id_regInfo_utf8Pairs                321\n#define OBJ_id_regInfo_utf8Pairs                OBJ_id_regInfo,1L\n\n#define SN_id_regInfo_certReq           \"id-regInfo-certReq\"\n#define NID_id_regInfo_certReq          322\n#define OBJ_id_regInfo_certReq          OBJ_id_regInfo,2L\n\n#define SN_id_alg_des40         \"id-alg-des40\"\n#define NID_id_alg_des40                323\n#define OBJ_id_alg_des40                OBJ_id_alg,1L\n\n#define SN_id_alg_noSignature           \"id-alg-noSignature\"\n#define NID_id_alg_noSignature          324\n#define OBJ_id_alg_noSignature          OBJ_id_alg,2L\n\n#define SN_id_alg_dh_sig_hmac_sha1              \"id-alg-dh-sig-hmac-sha1\"\n#define NID_id_alg_dh_sig_hmac_sha1             325\n#define OBJ_id_alg_dh_sig_hmac_sha1             OBJ_id_alg,3L\n\n#define SN_id_alg_dh_pop                \"id-alg-dh-pop\"\n#define NID_id_alg_dh_pop               326\n#define OBJ_id_alg_dh_pop               OBJ_id_alg,4L\n\n#define SN_id_cmc_statusInfo            \"id-cmc-statusInfo\"\n#define NID_id_cmc_statusInfo           327\n#define OBJ_id_cmc_statusInfo           OBJ_id_cmc,1L\n\n#define SN_id_cmc_identification                \"id-cmc-identification\"\n#define NID_id_cmc_identification               328\n#define OBJ_id_cmc_identification               OBJ_id_cmc,2L\n\n#define SN_id_cmc_identityProof         \"id-cmc-identityProof\"\n#define NID_id_cmc_identityProof                329\n#define OBJ_id_cmc_identityProof                OBJ_id_cmc,3L\n\n#define SN_id_cmc_dataReturn            \"id-cmc-dataReturn\"\n#define NID_id_cmc_dataReturn           330\n#define OBJ_id_cmc_dataReturn           OBJ_id_cmc,4L\n\n#define SN_id_cmc_transactionId         \"id-cmc-transactionId\"\n#define NID_id_cmc_transactionId                331\n#define OBJ_id_cmc_transactionId                OBJ_id_cmc,5L\n\n#define SN_id_cmc_senderNonce           \"id-cmc-senderNonce\"\n#define NID_id_cmc_senderNonce          332\n#define OBJ_id_cmc_senderNonce          OBJ_id_cmc,6L\n\n#define SN_id_cmc_recipientNonce                \"id-cmc-recipientNonce\"\n#define NID_id_cmc_recipientNonce               333\n#define OBJ_id_cmc_recipientNonce               OBJ_id_cmc,7L\n\n#define SN_id_cmc_addExtensions         \"id-cmc-addExtensions\"\n#define NID_id_cmc_addExtensions                334\n#define OBJ_id_cmc_addExtensions                OBJ_id_cmc,8L\n\n#define SN_id_cmc_encryptedPOP          \"id-cmc-encryptedPOP\"\n#define NID_id_cmc_encryptedPOP         335\n#define OBJ_id_cmc_encryptedPOP         OBJ_id_cmc,9L\n\n#define SN_id_cmc_decryptedPOP          \"id-cmc-decryptedPOP\"\n#define NID_id_cmc_decryptedPOP         336\n#define OBJ_id_cmc_decryptedPOP         OBJ_id_cmc,10L\n\n#define SN_id_cmc_lraPOPWitness         \"id-cmc-lraPOPWitness\"\n#define NID_id_cmc_lraPOPWitness                337\n#define OBJ_id_cmc_lraPOPWitness                OBJ_id_cmc,11L\n\n#define SN_id_cmc_getCert               \"id-cmc-getCert\"\n#define NID_id_cmc_getCert              338\n#define OBJ_id_cmc_getCert              OBJ_id_cmc,15L\n\n#define SN_id_cmc_getCRL                \"id-cmc-getCRL\"\n#define NID_id_cmc_getCRL               339\n#define OBJ_id_cmc_getCRL               OBJ_id_cmc,16L\n\n#define SN_id_cmc_revokeRequest         \"id-cmc-revokeRequest\"\n#define NID_id_cmc_revokeRequest                340\n#define OBJ_id_cmc_revokeRequest                OBJ_id_cmc,17L\n\n#define SN_id_cmc_regInfo               \"id-cmc-regInfo\"\n#define NID_id_cmc_regInfo              341\n#define OBJ_id_cmc_regInfo              OBJ_id_cmc,18L\n\n#define SN_id_cmc_responseInfo          \"id-cmc-responseInfo\"\n#define NID_id_cmc_responseInfo         342\n#define OBJ_id_cmc_responseInfo         OBJ_id_cmc,19L\n\n#define SN_id_cmc_queryPending          \"id-cmc-queryPending\"\n#define NID_id_cmc_queryPending         343\n#define OBJ_id_cmc_queryPending         OBJ_id_cmc,21L\n\n#define SN_id_cmc_popLinkRandom         \"id-cmc-popLinkRandom\"\n#define NID_id_cmc_popLinkRandom                344\n#define OBJ_id_cmc_popLinkRandom                OBJ_id_cmc,22L\n\n#define SN_id_cmc_popLinkWitness                \"id-cmc-popLinkWitness\"\n#define NID_id_cmc_popLinkWitness               345\n#define OBJ_id_cmc_popLinkWitness               OBJ_id_cmc,23L\n\n#define SN_id_cmc_confirmCertAcceptance         \"id-cmc-confirmCertAcceptance\"\n#define NID_id_cmc_confirmCertAcceptance                346\n#define OBJ_id_cmc_confirmCertAcceptance                OBJ_id_cmc,24L\n\n#define SN_id_on_personalData           \"id-on-personalData\"\n#define NID_id_on_personalData          347\n#define OBJ_id_on_personalData          OBJ_id_on,1L\n\n#define SN_id_on_permanentIdentifier            \"id-on-permanentIdentifier\"\n#define LN_id_on_permanentIdentifier            \"Permanent Identifier\"\n#define NID_id_on_permanentIdentifier           858\n#define OBJ_id_on_permanentIdentifier           OBJ_id_on,3L\n\n#define SN_id_pda_dateOfBirth           \"id-pda-dateOfBirth\"\n#define NID_id_pda_dateOfBirth          348\n#define OBJ_id_pda_dateOfBirth          OBJ_id_pda,1L\n\n#define SN_id_pda_placeOfBirth          \"id-pda-placeOfBirth\"\n#define NID_id_pda_placeOfBirth         349\n#define OBJ_id_pda_placeOfBirth         OBJ_id_pda,2L\n\n#define SN_id_pda_gender                \"id-pda-gender\"\n#define NID_id_pda_gender               351\n#define OBJ_id_pda_gender               OBJ_id_pda,3L\n\n#define SN_id_pda_countryOfCitizenship          \"id-pda-countryOfCitizenship\"\n#define NID_id_pda_countryOfCitizenship         352\n#define OBJ_id_pda_countryOfCitizenship         OBJ_id_pda,4L\n\n#define SN_id_pda_countryOfResidence            \"id-pda-countryOfResidence\"\n#define NID_id_pda_countryOfResidence           353\n#define OBJ_id_pda_countryOfResidence           OBJ_id_pda,5L\n\n#define SN_id_aca_authenticationInfo            \"id-aca-authenticationInfo\"\n#define NID_id_aca_authenticationInfo           354\n#define OBJ_id_aca_authenticationInfo           OBJ_id_aca,1L\n\n#define SN_id_aca_accessIdentity                \"id-aca-accessIdentity\"\n#define NID_id_aca_accessIdentity               355\n#define OBJ_id_aca_accessIdentity               OBJ_id_aca,2L\n\n#define SN_id_aca_chargingIdentity              \"id-aca-chargingIdentity\"\n#define NID_id_aca_chargingIdentity             356\n#define OBJ_id_aca_chargingIdentity             OBJ_id_aca,3L\n\n#define SN_id_aca_group         \"id-aca-group\"\n#define NID_id_aca_group                357\n#define OBJ_id_aca_group                OBJ_id_aca,4L\n\n#define SN_id_aca_role          \"id-aca-role\"\n#define NID_id_aca_role         358\n#define OBJ_id_aca_role         OBJ_id_aca,5L\n\n#define SN_id_aca_encAttrs              \"id-aca-encAttrs\"\n#define NID_id_aca_encAttrs             399\n#define OBJ_id_aca_encAttrs             OBJ_id_aca,6L\n\n#define SN_id_qcs_pkixQCSyntax_v1               \"id-qcs-pkixQCSyntax-v1\"\n#define NID_id_qcs_pkixQCSyntax_v1              359\n#define OBJ_id_qcs_pkixQCSyntax_v1              OBJ_id_qcs,1L\n\n#define SN_id_cct_crs           \"id-cct-crs\"\n#define NID_id_cct_crs          360\n#define OBJ_id_cct_crs          OBJ_id_cct,1L\n\n#define SN_id_cct_PKIData               \"id-cct-PKIData\"\n#define NID_id_cct_PKIData              361\n#define OBJ_id_cct_PKIData              OBJ_id_cct,2L\n\n#define SN_id_cct_PKIResponse           \"id-cct-PKIResponse\"\n#define NID_id_cct_PKIResponse          362\n#define OBJ_id_cct_PKIResponse          OBJ_id_cct,3L\n\n#define SN_id_ppl_anyLanguage           \"id-ppl-anyLanguage\"\n#define LN_id_ppl_anyLanguage           \"Any language\"\n#define NID_id_ppl_anyLanguage          664\n#define OBJ_id_ppl_anyLanguage          OBJ_id_ppl,0L\n\n#define SN_id_ppl_inheritAll            \"id-ppl-inheritAll\"\n#define LN_id_ppl_inheritAll            \"Inherit all\"\n#define NID_id_ppl_inheritAll           665\n#define OBJ_id_ppl_inheritAll           OBJ_id_ppl,1L\n\n#define SN_Independent          \"id-ppl-independent\"\n#define LN_Independent          \"Independent\"\n#define NID_Independent         667\n#define OBJ_Independent         OBJ_id_ppl,2L\n\n#define SN_ad_OCSP              \"OCSP\"\n#define LN_ad_OCSP              \"OCSP\"\n#define NID_ad_OCSP             178\n#define OBJ_ad_OCSP             OBJ_id_ad,1L\n\n#define SN_ad_ca_issuers                \"caIssuers\"\n#define LN_ad_ca_issuers                \"CA Issuers\"\n#define NID_ad_ca_issuers               179\n#define OBJ_ad_ca_issuers               OBJ_id_ad,2L\n\n#define SN_ad_timeStamping              \"ad_timestamping\"\n#define LN_ad_timeStamping              \"AD Time Stamping\"\n#define NID_ad_timeStamping             363\n#define OBJ_ad_timeStamping             OBJ_id_ad,3L\n\n#define SN_ad_dvcs              \"AD_DVCS\"\n#define LN_ad_dvcs              \"ad dvcs\"\n#define NID_ad_dvcs             364\n#define OBJ_ad_dvcs             OBJ_id_ad,4L\n\n#define SN_caRepository         \"caRepository\"\n#define LN_caRepository         \"CA Repository\"\n#define NID_caRepository                785\n#define OBJ_caRepository                OBJ_id_ad,5L\n\n#define OBJ_id_pkix_OCSP                OBJ_ad_OCSP\n\n#define SN_id_pkix_OCSP_basic           \"basicOCSPResponse\"\n#define LN_id_pkix_OCSP_basic           \"Basic OCSP Response\"\n#define NID_id_pkix_OCSP_basic          365\n#define OBJ_id_pkix_OCSP_basic          OBJ_id_pkix_OCSP,1L\n\n#define SN_id_pkix_OCSP_Nonce           \"Nonce\"\n#define LN_id_pkix_OCSP_Nonce           \"OCSP Nonce\"\n#define NID_id_pkix_OCSP_Nonce          366\n#define OBJ_id_pkix_OCSP_Nonce          OBJ_id_pkix_OCSP,2L\n\n#define SN_id_pkix_OCSP_CrlID           \"CrlID\"\n#define LN_id_pkix_OCSP_CrlID           \"OCSP CRL ID\"\n#define NID_id_pkix_OCSP_CrlID          367\n#define OBJ_id_pkix_OCSP_CrlID          OBJ_id_pkix_OCSP,3L\n\n#define SN_id_pkix_OCSP_acceptableResponses             \"acceptableResponses\"\n#define LN_id_pkix_OCSP_acceptableResponses             \"Acceptable OCSP Responses\"\n#define NID_id_pkix_OCSP_acceptableResponses            368\n#define OBJ_id_pkix_OCSP_acceptableResponses            OBJ_id_pkix_OCSP,4L\n\n#define SN_id_pkix_OCSP_noCheck         \"noCheck\"\n#define LN_id_pkix_OCSP_noCheck         \"OCSP No Check\"\n#define NID_id_pkix_OCSP_noCheck                369\n#define OBJ_id_pkix_OCSP_noCheck                OBJ_id_pkix_OCSP,5L\n\n#define SN_id_pkix_OCSP_archiveCutoff           \"archiveCutoff\"\n#define LN_id_pkix_OCSP_archiveCutoff           \"OCSP Archive Cutoff\"\n#define NID_id_pkix_OCSP_archiveCutoff          370\n#define OBJ_id_pkix_OCSP_archiveCutoff          OBJ_id_pkix_OCSP,6L\n\n#define SN_id_pkix_OCSP_serviceLocator          \"serviceLocator\"\n#define LN_id_pkix_OCSP_serviceLocator          \"OCSP Service Locator\"\n#define NID_id_pkix_OCSP_serviceLocator         371\n#define OBJ_id_pkix_OCSP_serviceLocator         OBJ_id_pkix_OCSP,7L\n\n#define SN_id_pkix_OCSP_extendedStatus          \"extendedStatus\"\n#define LN_id_pkix_OCSP_extendedStatus          \"Extended OCSP Status\"\n#define NID_id_pkix_OCSP_extendedStatus         372\n#define OBJ_id_pkix_OCSP_extendedStatus         OBJ_id_pkix_OCSP,8L\n\n#define SN_id_pkix_OCSP_valid           \"valid\"\n#define NID_id_pkix_OCSP_valid          373\n#define OBJ_id_pkix_OCSP_valid          OBJ_id_pkix_OCSP,9L\n\n#define SN_id_pkix_OCSP_path            \"path\"\n#define NID_id_pkix_OCSP_path           374\n#define OBJ_id_pkix_OCSP_path           OBJ_id_pkix_OCSP,10L\n\n#define SN_id_pkix_OCSP_trustRoot               \"trustRoot\"\n#define LN_id_pkix_OCSP_trustRoot               \"Trust Root\"\n#define NID_id_pkix_OCSP_trustRoot              375\n#define OBJ_id_pkix_OCSP_trustRoot              OBJ_id_pkix_OCSP,11L\n\n#define SN_algorithm            \"algorithm\"\n#define LN_algorithm            \"algorithm\"\n#define NID_algorithm           376\n#define OBJ_algorithm           1L,3L,14L,3L,2L\n\n#define SN_md5WithRSA           \"RSA-NP-MD5\"\n#define LN_md5WithRSA           \"md5WithRSA\"\n#define NID_md5WithRSA          104\n#define OBJ_md5WithRSA          OBJ_algorithm,3L\n\n#define SN_des_ecb              \"DES-ECB\"\n#define LN_des_ecb              \"des-ecb\"\n#define NID_des_ecb             29\n#define OBJ_des_ecb             OBJ_algorithm,6L\n\n#define SN_des_cbc              \"DES-CBC\"\n#define LN_des_cbc              \"des-cbc\"\n#define NID_des_cbc             31\n#define OBJ_des_cbc             OBJ_algorithm,7L\n\n#define SN_des_ofb64            \"DES-OFB\"\n#define LN_des_ofb64            \"des-ofb\"\n#define NID_des_ofb64           45\n#define OBJ_des_ofb64           OBJ_algorithm,8L\n\n#define SN_des_cfb64            \"DES-CFB\"\n#define LN_des_cfb64            \"des-cfb\"\n#define NID_des_cfb64           30\n#define OBJ_des_cfb64           OBJ_algorithm,9L\n\n#define SN_rsaSignature         \"rsaSignature\"\n#define NID_rsaSignature                377\n#define OBJ_rsaSignature                OBJ_algorithm,11L\n\n#define SN_dsa_2                \"DSA-old\"\n#define LN_dsa_2                \"dsaEncryption-old\"\n#define NID_dsa_2               67\n#define OBJ_dsa_2               OBJ_algorithm,12L\n\n#define SN_dsaWithSHA           \"DSA-SHA\"\n#define LN_dsaWithSHA           \"dsaWithSHA\"\n#define NID_dsaWithSHA          66\n#define OBJ_dsaWithSHA          OBJ_algorithm,13L\n\n#define SN_shaWithRSAEncryption         \"RSA-SHA\"\n#define LN_shaWithRSAEncryption         \"shaWithRSAEncryption\"\n#define NID_shaWithRSAEncryption                42\n#define OBJ_shaWithRSAEncryption                OBJ_algorithm,15L\n\n#define SN_des_ede_ecb          \"DES-EDE\"\n#define LN_des_ede_ecb          \"des-ede\"\n#define NID_des_ede_ecb         32\n#define OBJ_des_ede_ecb         OBJ_algorithm,17L\n\n#define SN_des_ede3_ecb         \"DES-EDE3\"\n#define LN_des_ede3_ecb         \"des-ede3\"\n#define NID_des_ede3_ecb                33\n\n#define SN_des_ede_cbc          \"DES-EDE-CBC\"\n#define LN_des_ede_cbc          \"des-ede-cbc\"\n#define NID_des_ede_cbc         43\n\n#define SN_des_ede_cfb64                \"DES-EDE-CFB\"\n#define LN_des_ede_cfb64                \"des-ede-cfb\"\n#define NID_des_ede_cfb64               60\n\n#define SN_des_ede3_cfb64               \"DES-EDE3-CFB\"\n#define LN_des_ede3_cfb64               \"des-ede3-cfb\"\n#define NID_des_ede3_cfb64              61\n\n#define SN_des_ede_ofb64                \"DES-EDE-OFB\"\n#define LN_des_ede_ofb64                \"des-ede-ofb\"\n#define NID_des_ede_ofb64               62\n\n#define SN_des_ede3_ofb64               \"DES-EDE3-OFB\"\n#define LN_des_ede3_ofb64               \"des-ede3-ofb\"\n#define NID_des_ede3_ofb64              63\n\n#define SN_desx_cbc             \"DESX-CBC\"\n#define LN_desx_cbc             \"desx-cbc\"\n#define NID_desx_cbc            80\n\n#define SN_sha          \"SHA\"\n#define LN_sha          \"sha\"\n#define NID_sha         41\n#define OBJ_sha         OBJ_algorithm,18L\n\n#define SN_sha1         \"SHA1\"\n#define LN_sha1         \"sha1\"\n#define NID_sha1                64\n#define OBJ_sha1                OBJ_algorithm,26L\n\n#define SN_dsaWithSHA1_2                \"DSA-SHA1-old\"\n#define LN_dsaWithSHA1_2                \"dsaWithSHA1-old\"\n#define NID_dsaWithSHA1_2               70\n#define OBJ_dsaWithSHA1_2               OBJ_algorithm,27L\n\n#define SN_sha1WithRSA          \"RSA-SHA1-2\"\n#define LN_sha1WithRSA          \"sha1WithRSA\"\n#define NID_sha1WithRSA         115\n#define OBJ_sha1WithRSA         OBJ_algorithm,29L\n\n#define SN_ripemd160            \"RIPEMD160\"\n#define LN_ripemd160            \"ripemd160\"\n#define NID_ripemd160           117\n#define OBJ_ripemd160           1L,3L,36L,3L,2L,1L\n\n#define SN_ripemd160WithRSA             \"RSA-RIPEMD160\"\n#define LN_ripemd160WithRSA             \"ripemd160WithRSA\"\n#define NID_ripemd160WithRSA            119\n#define OBJ_ripemd160WithRSA            1L,3L,36L,3L,3L,1L,2L\n\n#define SN_sxnet                \"SXNetID\"\n#define LN_sxnet                \"Strong Extranet ID\"\n#define NID_sxnet               143\n#define OBJ_sxnet               1L,3L,101L,1L,4L,1L\n\n#define SN_X500         \"X500\"\n#define LN_X500         \"directory services (X.500)\"\n#define NID_X500                11\n#define OBJ_X500                2L,5L\n\n#define SN_X509         \"X509\"\n#define NID_X509                12\n#define OBJ_X509                OBJ_X500,4L\n\n#define SN_commonName           \"CN\"\n#define LN_commonName           \"commonName\"\n#define NID_commonName          13\n#define OBJ_commonName          OBJ_X509,3L\n\n#define SN_surname              \"SN\"\n#define LN_surname              \"surname\"\n#define NID_surname             100\n#define OBJ_surname             OBJ_X509,4L\n\n#define LN_serialNumber         \"serialNumber\"\n#define NID_serialNumber                105\n#define OBJ_serialNumber                OBJ_X509,5L\n\n#define SN_countryName          \"C\"\n#define LN_countryName          \"countryName\"\n#define NID_countryName         14\n#define OBJ_countryName         OBJ_X509,6L\n\n#define SN_localityName         \"L\"\n#define LN_localityName         \"localityName\"\n#define NID_localityName                15\n#define OBJ_localityName                OBJ_X509,7L\n\n#define SN_stateOrProvinceName          \"ST\"\n#define LN_stateOrProvinceName          \"stateOrProvinceName\"\n#define NID_stateOrProvinceName         16\n#define OBJ_stateOrProvinceName         OBJ_X509,8L\n\n#define SN_streetAddress                \"street\"\n#define LN_streetAddress                \"streetAddress\"\n#define NID_streetAddress               660\n#define OBJ_streetAddress               OBJ_X509,9L\n\n#define SN_organizationName             \"O\"\n#define LN_organizationName             \"organizationName\"\n#define NID_organizationName            17\n#define OBJ_organizationName            OBJ_X509,10L\n\n#define SN_organizationalUnitName               \"OU\"\n#define LN_organizationalUnitName               \"organizationalUnitName\"\n#define NID_organizationalUnitName              18\n#define OBJ_organizationalUnitName              OBJ_X509,11L\n\n#define SN_title                \"title\"\n#define LN_title                \"title\"\n#define NID_title               106\n#define OBJ_title               OBJ_X509,12L\n\n#define LN_description          \"description\"\n#define NID_description         107\n#define OBJ_description         OBJ_X509,13L\n\n#define LN_searchGuide          \"searchGuide\"\n#define NID_searchGuide         859\n#define OBJ_searchGuide         OBJ_X509,14L\n\n#define LN_businessCategory             \"businessCategory\"\n#define NID_businessCategory            860\n#define OBJ_businessCategory            OBJ_X509,15L\n\n#define LN_postalAddress                \"postalAddress\"\n#define NID_postalAddress               861\n#define OBJ_postalAddress               OBJ_X509,16L\n\n#define LN_postalCode           \"postalCode\"\n#define NID_postalCode          661\n#define OBJ_postalCode          OBJ_X509,17L\n\n#define LN_postOfficeBox                \"postOfficeBox\"\n#define NID_postOfficeBox               862\n#define OBJ_postOfficeBox               OBJ_X509,18L\n\n#define LN_physicalDeliveryOfficeName           \"physicalDeliveryOfficeName\"\n#define NID_physicalDeliveryOfficeName          863\n#define OBJ_physicalDeliveryOfficeName          OBJ_X509,19L\n\n#define LN_telephoneNumber              \"telephoneNumber\"\n#define NID_telephoneNumber             864\n#define OBJ_telephoneNumber             OBJ_X509,20L\n\n#define LN_telexNumber          \"telexNumber\"\n#define NID_telexNumber         865\n#define OBJ_telexNumber         OBJ_X509,21L\n\n#define LN_teletexTerminalIdentifier            \"teletexTerminalIdentifier\"\n#define NID_teletexTerminalIdentifier           866\n#define OBJ_teletexTerminalIdentifier           OBJ_X509,22L\n\n#define LN_facsimileTelephoneNumber             \"facsimileTelephoneNumber\"\n#define NID_facsimileTelephoneNumber            867\n#define OBJ_facsimileTelephoneNumber            OBJ_X509,23L\n\n#define LN_x121Address          \"x121Address\"\n#define NID_x121Address         868\n#define OBJ_x121Address         OBJ_X509,24L\n\n#define LN_internationaliSDNNumber              \"internationaliSDNNumber\"\n#define NID_internationaliSDNNumber             869\n#define OBJ_internationaliSDNNumber             OBJ_X509,25L\n\n#define LN_registeredAddress            \"registeredAddress\"\n#define NID_registeredAddress           870\n#define OBJ_registeredAddress           OBJ_X509,26L\n\n#define LN_destinationIndicator         \"destinationIndicator\"\n#define NID_destinationIndicator                871\n#define OBJ_destinationIndicator                OBJ_X509,27L\n\n#define LN_preferredDeliveryMethod              \"preferredDeliveryMethod\"\n#define NID_preferredDeliveryMethod             872\n#define OBJ_preferredDeliveryMethod             OBJ_X509,28L\n\n#define LN_presentationAddress          \"presentationAddress\"\n#define NID_presentationAddress         873\n#define OBJ_presentationAddress         OBJ_X509,29L\n\n#define LN_supportedApplicationContext          \"supportedApplicationContext\"\n#define NID_supportedApplicationContext         874\n#define OBJ_supportedApplicationContext         OBJ_X509,30L\n\n#define SN_member               \"member\"\n#define NID_member              875\n#define OBJ_member              OBJ_X509,31L\n\n#define SN_owner                \"owner\"\n#define NID_owner               876\n#define OBJ_owner               OBJ_X509,32L\n\n#define LN_roleOccupant         \"roleOccupant\"\n#define NID_roleOccupant                877\n#define OBJ_roleOccupant                OBJ_X509,33L\n\n#define SN_seeAlso              \"seeAlso\"\n#define NID_seeAlso             878\n#define OBJ_seeAlso             OBJ_X509,34L\n\n#define LN_userPassword         \"userPassword\"\n#define NID_userPassword                879\n#define OBJ_userPassword                OBJ_X509,35L\n\n#define LN_userCertificate              \"userCertificate\"\n#define NID_userCertificate             880\n#define OBJ_userCertificate             OBJ_X509,36L\n\n#define LN_cACertificate                \"cACertificate\"\n#define NID_cACertificate               881\n#define OBJ_cACertificate               OBJ_X509,37L\n\n#define LN_authorityRevocationList              \"authorityRevocationList\"\n#define NID_authorityRevocationList             882\n#define OBJ_authorityRevocationList             OBJ_X509,38L\n\n#define LN_certificateRevocationList            \"certificateRevocationList\"\n#define NID_certificateRevocationList           883\n#define OBJ_certificateRevocationList           OBJ_X509,39L\n\n#define LN_crossCertificatePair         \"crossCertificatePair\"\n#define NID_crossCertificatePair                884\n#define OBJ_crossCertificatePair                OBJ_X509,40L\n\n#define SN_name         \"name\"\n#define LN_name         \"name\"\n#define NID_name                173\n#define OBJ_name                OBJ_X509,41L\n\n#define SN_givenName            \"GN\"\n#define LN_givenName            \"givenName\"\n#define NID_givenName           99\n#define OBJ_givenName           OBJ_X509,42L\n\n#define SN_initials             \"initials\"\n#define LN_initials             \"initials\"\n#define NID_initials            101\n#define OBJ_initials            OBJ_X509,43L\n\n#define LN_generationQualifier          \"generationQualifier\"\n#define NID_generationQualifier         509\n#define OBJ_generationQualifier         OBJ_X509,44L\n\n#define LN_x500UniqueIdentifier         \"x500UniqueIdentifier\"\n#define NID_x500UniqueIdentifier                503\n#define OBJ_x500UniqueIdentifier                OBJ_X509,45L\n\n#define SN_dnQualifier          \"dnQualifier\"\n#define LN_dnQualifier          \"dnQualifier\"\n#define NID_dnQualifier         174\n#define OBJ_dnQualifier         OBJ_X509,46L\n\n#define LN_enhancedSearchGuide          \"enhancedSearchGuide\"\n#define NID_enhancedSearchGuide         885\n#define OBJ_enhancedSearchGuide         OBJ_X509,47L\n\n#define LN_protocolInformation          \"protocolInformation\"\n#define NID_protocolInformation         886\n#define OBJ_protocolInformation         OBJ_X509,48L\n\n#define LN_distinguishedName            \"distinguishedName\"\n#define NID_distinguishedName           887\n#define OBJ_distinguishedName           OBJ_X509,49L\n\n#define LN_uniqueMember         \"uniqueMember\"\n#define NID_uniqueMember                888\n#define OBJ_uniqueMember                OBJ_X509,50L\n\n#define LN_houseIdentifier              \"houseIdentifier\"\n#define NID_houseIdentifier             889\n#define OBJ_houseIdentifier             OBJ_X509,51L\n\n#define LN_supportedAlgorithms          \"supportedAlgorithms\"\n#define NID_supportedAlgorithms         890\n#define OBJ_supportedAlgorithms         OBJ_X509,52L\n\n#define LN_deltaRevocationList          \"deltaRevocationList\"\n#define NID_deltaRevocationList         891\n#define OBJ_deltaRevocationList         OBJ_X509,53L\n\n#define SN_dmdName              \"dmdName\"\n#define NID_dmdName             892\n#define OBJ_dmdName             OBJ_X509,54L\n\n#define LN_pseudonym            \"pseudonym\"\n#define NID_pseudonym           510\n#define OBJ_pseudonym           OBJ_X509,65L\n\n#define SN_role         \"role\"\n#define LN_role         \"role\"\n#define NID_role                400\n#define OBJ_role                OBJ_X509,72L\n\n#define SN_X500algorithms               \"X500algorithms\"\n#define LN_X500algorithms               \"directory services - algorithms\"\n#define NID_X500algorithms              378\n#define OBJ_X500algorithms              OBJ_X500,8L\n\n#define SN_rsa          \"RSA\"\n#define LN_rsa          \"rsa\"\n#define NID_rsa         19\n#define OBJ_rsa         OBJ_X500algorithms,1L,1L\n\n#define SN_mdc2WithRSA          \"RSA-MDC2\"\n#define LN_mdc2WithRSA          \"mdc2WithRSA\"\n#define NID_mdc2WithRSA         96\n#define OBJ_mdc2WithRSA         OBJ_X500algorithms,3L,100L\n\n#define SN_mdc2         \"MDC2\"\n#define LN_mdc2         \"mdc2\"\n#define NID_mdc2                95\n#define OBJ_mdc2                OBJ_X500algorithms,3L,101L\n\n#define SN_id_ce                \"id-ce\"\n#define NID_id_ce               81\n#define OBJ_id_ce               OBJ_X500,29L\n\n#define SN_subject_directory_attributes         \"subjectDirectoryAttributes\"\n#define LN_subject_directory_attributes         \"X509v3 Subject Directory Attributes\"\n#define NID_subject_directory_attributes                769\n#define OBJ_subject_directory_attributes                OBJ_id_ce,9L\n\n#define SN_subject_key_identifier               \"subjectKeyIdentifier\"\n#define LN_subject_key_identifier               \"X509v3 Subject Key Identifier\"\n#define NID_subject_key_identifier              82\n#define OBJ_subject_key_identifier              OBJ_id_ce,14L\n\n#define SN_key_usage            \"keyUsage\"\n#define LN_key_usage            \"X509v3 Key Usage\"\n#define NID_key_usage           83\n#define OBJ_key_usage           OBJ_id_ce,15L\n\n#define SN_private_key_usage_period             \"privateKeyUsagePeriod\"\n#define LN_private_key_usage_period             \"X509v3 Private Key Usage Period\"\n#define NID_private_key_usage_period            84\n#define OBJ_private_key_usage_period            OBJ_id_ce,16L\n\n#define SN_subject_alt_name             \"subjectAltName\"\n#define LN_subject_alt_name             \"X509v3 Subject Alternative Name\"\n#define NID_subject_alt_name            85\n#define OBJ_subject_alt_name            OBJ_id_ce,17L\n\n#define SN_issuer_alt_name              \"issuerAltName\"\n#define LN_issuer_alt_name              \"X509v3 Issuer Alternative Name\"\n#define NID_issuer_alt_name             86\n#define OBJ_issuer_alt_name             OBJ_id_ce,18L\n\n#define SN_basic_constraints            \"basicConstraints\"\n#define LN_basic_constraints            \"X509v3 Basic Constraints\"\n#define NID_basic_constraints           87\n#define OBJ_basic_constraints           OBJ_id_ce,19L\n\n#define SN_crl_number           \"crlNumber\"\n#define LN_crl_number           \"X509v3 CRL Number\"\n#define NID_crl_number          88\n#define OBJ_crl_number          OBJ_id_ce,20L\n\n#define SN_crl_reason           \"CRLReason\"\n#define LN_crl_reason           \"X509v3 CRL Reason Code\"\n#define NID_crl_reason          141\n#define OBJ_crl_reason          OBJ_id_ce,21L\n\n#define SN_invalidity_date              \"invalidityDate\"\n#define LN_invalidity_date              \"Invalidity Date\"\n#define NID_invalidity_date             142\n#define OBJ_invalidity_date             OBJ_id_ce,24L\n\n#define SN_delta_crl            \"deltaCRL\"\n#define LN_delta_crl            \"X509v3 Delta CRL Indicator\"\n#define NID_delta_crl           140\n#define OBJ_delta_crl           OBJ_id_ce,27L\n\n#define SN_issuing_distribution_point           \"issuingDistributionPoint\"\n#define LN_issuing_distribution_point           \"X509v3 Issuing Distrubution Point\"\n#define NID_issuing_distribution_point          770\n#define OBJ_issuing_distribution_point          OBJ_id_ce,28L\n\n#define SN_certificate_issuer           \"certificateIssuer\"\n#define LN_certificate_issuer           \"X509v3 Certificate Issuer\"\n#define NID_certificate_issuer          771\n#define OBJ_certificate_issuer          OBJ_id_ce,29L\n\n#define SN_name_constraints             \"nameConstraints\"\n#define LN_name_constraints             \"X509v3 Name Constraints\"\n#define NID_name_constraints            666\n#define OBJ_name_constraints            OBJ_id_ce,30L\n\n#define SN_crl_distribution_points              \"crlDistributionPoints\"\n#define LN_crl_distribution_points              \"X509v3 CRL Distribution Points\"\n#define NID_crl_distribution_points             103\n#define OBJ_crl_distribution_points             OBJ_id_ce,31L\n\n#define SN_certificate_policies         \"certificatePolicies\"\n#define LN_certificate_policies         \"X509v3 Certificate Policies\"\n#define NID_certificate_policies                89\n#define OBJ_certificate_policies                OBJ_id_ce,32L\n\n#define SN_any_policy           \"anyPolicy\"\n#define LN_any_policy           \"X509v3 Any Policy\"\n#define NID_any_policy          746\n#define OBJ_any_policy          OBJ_certificate_policies,0L\n\n#define SN_policy_mappings              \"policyMappings\"\n#define LN_policy_mappings              \"X509v3 Policy Mappings\"\n#define NID_policy_mappings             747\n#define OBJ_policy_mappings             OBJ_id_ce,33L\n\n#define SN_authority_key_identifier             \"authorityKeyIdentifier\"\n#define LN_authority_key_identifier             \"X509v3 Authority Key Identifier\"\n#define NID_authority_key_identifier            90\n#define OBJ_authority_key_identifier            OBJ_id_ce,35L\n\n#define SN_policy_constraints           \"policyConstraints\"\n#define LN_policy_constraints           \"X509v3 Policy Constraints\"\n#define NID_policy_constraints          401\n#define OBJ_policy_constraints          OBJ_id_ce,36L\n\n#define SN_ext_key_usage                \"extendedKeyUsage\"\n#define LN_ext_key_usage                \"X509v3 Extended Key Usage\"\n#define NID_ext_key_usage               126\n#define OBJ_ext_key_usage               OBJ_id_ce,37L\n\n#define SN_freshest_crl         \"freshestCRL\"\n#define LN_freshest_crl         \"X509v3 Freshest CRL\"\n#define NID_freshest_crl                857\n#define OBJ_freshest_crl                OBJ_id_ce,46L\n\n#define SN_inhibit_any_policy           \"inhibitAnyPolicy\"\n#define LN_inhibit_any_policy           \"X509v3 Inhibit Any Policy\"\n#define NID_inhibit_any_policy          748\n#define OBJ_inhibit_any_policy          OBJ_id_ce,54L\n\n#define SN_target_information           \"targetInformation\"\n#define LN_target_information           \"X509v3 AC Targeting\"\n#define NID_target_information          402\n#define OBJ_target_information          OBJ_id_ce,55L\n\n#define SN_no_rev_avail         \"noRevAvail\"\n#define LN_no_rev_avail         \"X509v3 No Revocation Available\"\n#define NID_no_rev_avail                403\n#define OBJ_no_rev_avail                OBJ_id_ce,56L\n\n#define SN_anyExtendedKeyUsage          \"anyExtendedKeyUsage\"\n#define LN_anyExtendedKeyUsage          \"Any Extended Key Usage\"\n#define NID_anyExtendedKeyUsage         910\n#define OBJ_anyExtendedKeyUsage         OBJ_ext_key_usage,0L\n\n#define SN_netscape             \"Netscape\"\n#define LN_netscape             \"Netscape Communications Corp.\"\n#define NID_netscape            57\n#define OBJ_netscape            2L,16L,840L,1L,113730L\n\n#define SN_netscape_cert_extension              \"nsCertExt\"\n#define LN_netscape_cert_extension              \"Netscape Certificate Extension\"\n#define NID_netscape_cert_extension             58\n#define OBJ_netscape_cert_extension             OBJ_netscape,1L\n\n#define SN_netscape_data_type           \"nsDataType\"\n#define LN_netscape_data_type           \"Netscape Data Type\"\n#define NID_netscape_data_type          59\n#define OBJ_netscape_data_type          OBJ_netscape,2L\n\n#define SN_netscape_cert_type           \"nsCertType\"\n#define LN_netscape_cert_type           \"Netscape Cert Type\"\n#define NID_netscape_cert_type          71\n#define OBJ_netscape_cert_type          OBJ_netscape_cert_extension,1L\n\n#define SN_netscape_base_url            \"nsBaseUrl\"\n#define LN_netscape_base_url            \"Netscape Base Url\"\n#define NID_netscape_base_url           72\n#define OBJ_netscape_base_url           OBJ_netscape_cert_extension,2L\n\n#define SN_netscape_revocation_url              \"nsRevocationUrl\"\n#define LN_netscape_revocation_url              \"Netscape Revocation Url\"\n#define NID_netscape_revocation_url             73\n#define OBJ_netscape_revocation_url             OBJ_netscape_cert_extension,3L\n\n#define SN_netscape_ca_revocation_url           \"nsCaRevocationUrl\"\n#define LN_netscape_ca_revocation_url           \"Netscape CA Revocation Url\"\n#define NID_netscape_ca_revocation_url          74\n#define OBJ_netscape_ca_revocation_url          OBJ_netscape_cert_extension,4L\n\n#define SN_netscape_renewal_url         \"nsRenewalUrl\"\n#define LN_netscape_renewal_url         \"Netscape Renewal Url\"\n#define NID_netscape_renewal_url                75\n#define OBJ_netscape_renewal_url                OBJ_netscape_cert_extension,7L\n\n#define SN_netscape_ca_policy_url               \"nsCaPolicyUrl\"\n#define LN_netscape_ca_policy_url               \"Netscape CA Policy Url\"\n#define NID_netscape_ca_policy_url              76\n#define OBJ_netscape_ca_policy_url              OBJ_netscape_cert_extension,8L\n\n#define SN_netscape_ssl_server_name             \"nsSslServerName\"\n#define LN_netscape_ssl_server_name             \"Netscape SSL Server Name\"\n#define NID_netscape_ssl_server_name            77\n#define OBJ_netscape_ssl_server_name            OBJ_netscape_cert_extension,12L\n\n#define SN_netscape_comment             \"nsComment\"\n#define LN_netscape_comment             \"Netscape Comment\"\n#define NID_netscape_comment            78\n#define OBJ_netscape_comment            OBJ_netscape_cert_extension,13L\n\n#define SN_netscape_cert_sequence               \"nsCertSequence\"\n#define LN_netscape_cert_sequence               \"Netscape Certificate Sequence\"\n#define NID_netscape_cert_sequence              79\n#define OBJ_netscape_cert_sequence              OBJ_netscape_data_type,5L\n\n#define SN_ns_sgc               \"nsSGC\"\n#define LN_ns_sgc               \"Netscape Server Gated Crypto\"\n#define NID_ns_sgc              139\n#define OBJ_ns_sgc              OBJ_netscape,4L,1L\n\n#define SN_org          \"ORG\"\n#define LN_org          \"org\"\n#define NID_org         379\n#define OBJ_org         OBJ_iso,3L\n\n#define SN_dod          \"DOD\"\n#define LN_dod          \"dod\"\n#define NID_dod         380\n#define OBJ_dod         OBJ_org,6L\n\n#define SN_iana         \"IANA\"\n#define LN_iana         \"iana\"\n#define NID_iana                381\n#define OBJ_iana                OBJ_dod,1L\n\n#define OBJ_internet            OBJ_iana\n\n#define SN_Directory            \"directory\"\n#define LN_Directory            \"Directory\"\n#define NID_Directory           382\n#define OBJ_Directory           OBJ_internet,1L\n\n#define SN_Management           \"mgmt\"\n#define LN_Management           \"Management\"\n#define NID_Management          383\n#define OBJ_Management          OBJ_internet,2L\n\n#define SN_Experimental         \"experimental\"\n#define LN_Experimental         \"Experimental\"\n#define NID_Experimental                384\n#define OBJ_Experimental                OBJ_internet,3L\n\n#define SN_Private              \"private\"\n#define LN_Private              \"Private\"\n#define NID_Private             385\n#define OBJ_Private             OBJ_internet,4L\n\n#define SN_Security             \"security\"\n#define LN_Security             \"Security\"\n#define NID_Security            386\n#define OBJ_Security            OBJ_internet,5L\n\n#define SN_SNMPv2               \"snmpv2\"\n#define LN_SNMPv2               \"SNMPv2\"\n#define NID_SNMPv2              387\n#define OBJ_SNMPv2              OBJ_internet,6L\n\n#define LN_Mail         \"Mail\"\n#define NID_Mail                388\n#define OBJ_Mail                OBJ_internet,7L\n\n#define SN_Enterprises          \"enterprises\"\n#define LN_Enterprises          \"Enterprises\"\n#define NID_Enterprises         389\n#define OBJ_Enterprises         OBJ_Private,1L\n\n#define SN_dcObject             \"dcobject\"\n#define LN_dcObject             \"dcObject\"\n#define NID_dcObject            390\n#define OBJ_dcObject            OBJ_Enterprises,1466L,344L\n\n#define SN_mime_mhs             \"mime-mhs\"\n#define LN_mime_mhs             \"MIME MHS\"\n#define NID_mime_mhs            504\n#define OBJ_mime_mhs            OBJ_Mail,1L\n\n#define SN_mime_mhs_headings            \"mime-mhs-headings\"\n#define LN_mime_mhs_headings            \"mime-mhs-headings\"\n#define NID_mime_mhs_headings           505\n#define OBJ_mime_mhs_headings           OBJ_mime_mhs,1L\n\n#define SN_mime_mhs_bodies              \"mime-mhs-bodies\"\n#define LN_mime_mhs_bodies              \"mime-mhs-bodies\"\n#define NID_mime_mhs_bodies             506\n#define OBJ_mime_mhs_bodies             OBJ_mime_mhs,2L\n\n#define SN_id_hex_partial_message               \"id-hex-partial-message\"\n#define LN_id_hex_partial_message               \"id-hex-partial-message\"\n#define NID_id_hex_partial_message              507\n#define OBJ_id_hex_partial_message              OBJ_mime_mhs_headings,1L\n\n#define SN_id_hex_multipart_message             \"id-hex-multipart-message\"\n#define LN_id_hex_multipart_message             \"id-hex-multipart-message\"\n#define NID_id_hex_multipart_message            508\n#define OBJ_id_hex_multipart_message            OBJ_mime_mhs_headings,2L\n\n#define SN_rle_compression              \"RLE\"\n#define LN_rle_compression              \"run length compression\"\n#define NID_rle_compression             124\n#define OBJ_rle_compression             1L,1L,1L,1L,666L,1L\n\n#define SN_zlib_compression             \"ZLIB\"\n#define LN_zlib_compression             \"zlib compression\"\n#define NID_zlib_compression            125\n#define OBJ_zlib_compression            OBJ_id_smime_alg,8L\n\n#define OBJ_csor                2L,16L,840L,1L,101L,3L\n\n#define OBJ_nistAlgorithms              OBJ_csor,4L\n\n#define OBJ_aes         OBJ_nistAlgorithms,1L\n\n#define SN_aes_128_ecb          \"AES-128-ECB\"\n#define LN_aes_128_ecb          \"aes-128-ecb\"\n#define NID_aes_128_ecb         418\n#define OBJ_aes_128_ecb         OBJ_aes,1L\n\n#define SN_aes_128_cbc          \"AES-128-CBC\"\n#define LN_aes_128_cbc          \"aes-128-cbc\"\n#define NID_aes_128_cbc         419\n#define OBJ_aes_128_cbc         OBJ_aes,2L\n\n#define SN_aes_128_ofb128               \"AES-128-OFB\"\n#define LN_aes_128_ofb128               \"aes-128-ofb\"\n#define NID_aes_128_ofb128              420\n#define OBJ_aes_128_ofb128              OBJ_aes,3L\n\n#define SN_aes_128_cfb128               \"AES-128-CFB\"\n#define LN_aes_128_cfb128               \"aes-128-cfb\"\n#define NID_aes_128_cfb128              421\n#define OBJ_aes_128_cfb128              OBJ_aes,4L\n\n#define SN_id_aes128_wrap               \"id-aes128-wrap\"\n#define NID_id_aes128_wrap              788\n#define OBJ_id_aes128_wrap              OBJ_aes,5L\n\n#define SN_aes_128_gcm          \"id-aes128-GCM\"\n#define LN_aes_128_gcm          \"aes-128-gcm\"\n#define NID_aes_128_gcm         895\n#define OBJ_aes_128_gcm         OBJ_aes,6L\n\n#define SN_aes_128_ccm          \"id-aes128-CCM\"\n#define LN_aes_128_ccm          \"aes-128-ccm\"\n#define NID_aes_128_ccm         896\n#define OBJ_aes_128_ccm         OBJ_aes,7L\n\n#define SN_id_aes128_wrap_pad           \"id-aes128-wrap-pad\"\n#define NID_id_aes128_wrap_pad          897\n#define OBJ_id_aes128_wrap_pad          OBJ_aes,8L\n\n#define SN_aes_192_ecb          \"AES-192-ECB\"\n#define LN_aes_192_ecb          \"aes-192-ecb\"\n#define NID_aes_192_ecb         422\n#define OBJ_aes_192_ecb         OBJ_aes,21L\n\n#define SN_aes_192_cbc          \"AES-192-CBC\"\n#define LN_aes_192_cbc          \"aes-192-cbc\"\n#define NID_aes_192_cbc         423\n#define OBJ_aes_192_cbc         OBJ_aes,22L\n\n#define SN_aes_192_ofb128               \"AES-192-OFB\"\n#define LN_aes_192_ofb128               \"aes-192-ofb\"\n#define NID_aes_192_ofb128              424\n#define OBJ_aes_192_ofb128              OBJ_aes,23L\n\n#define SN_aes_192_cfb128               \"AES-192-CFB\"\n#define LN_aes_192_cfb128               \"aes-192-cfb\"\n#define NID_aes_192_cfb128              425\n#define OBJ_aes_192_cfb128              OBJ_aes,24L\n\n#define SN_id_aes192_wrap               \"id-aes192-wrap\"\n#define NID_id_aes192_wrap              789\n#define OBJ_id_aes192_wrap              OBJ_aes,25L\n\n#define SN_aes_192_gcm          \"id-aes192-GCM\"\n#define LN_aes_192_gcm          \"aes-192-gcm\"\n#define NID_aes_192_gcm         898\n#define OBJ_aes_192_gcm         OBJ_aes,26L\n\n#define SN_aes_192_ccm          \"id-aes192-CCM\"\n#define LN_aes_192_ccm          \"aes-192-ccm\"\n#define NID_aes_192_ccm         899\n#define OBJ_aes_192_ccm         OBJ_aes,27L\n\n#define SN_id_aes192_wrap_pad           \"id-aes192-wrap-pad\"\n#define NID_id_aes192_wrap_pad          900\n#define OBJ_id_aes192_wrap_pad          OBJ_aes,28L\n\n#define SN_aes_256_ecb          \"AES-256-ECB\"\n#define LN_aes_256_ecb          \"aes-256-ecb\"\n#define NID_aes_256_ecb         426\n#define OBJ_aes_256_ecb         OBJ_aes,41L\n\n#define SN_aes_256_cbc          \"AES-256-CBC\"\n#define LN_aes_256_cbc          \"aes-256-cbc\"\n#define NID_aes_256_cbc         427\n#define OBJ_aes_256_cbc         OBJ_aes,42L\n\n#define SN_aes_256_ofb128               \"AES-256-OFB\"\n#define LN_aes_256_ofb128               \"aes-256-ofb\"\n#define NID_aes_256_ofb128              428\n#define OBJ_aes_256_ofb128              OBJ_aes,43L\n\n#define SN_aes_256_cfb128               \"AES-256-CFB\"\n#define LN_aes_256_cfb128               \"aes-256-cfb\"\n#define NID_aes_256_cfb128              429\n#define OBJ_aes_256_cfb128              OBJ_aes,44L\n\n#define SN_id_aes256_wrap               \"id-aes256-wrap\"\n#define NID_id_aes256_wrap              790\n#define OBJ_id_aes256_wrap              OBJ_aes,45L\n\n#define SN_aes_256_gcm          \"id-aes256-GCM\"\n#define LN_aes_256_gcm          \"aes-256-gcm\"\n#define NID_aes_256_gcm         901\n#define OBJ_aes_256_gcm         OBJ_aes,46L\n\n#define SN_aes_256_ccm          \"id-aes256-CCM\"\n#define LN_aes_256_ccm          \"aes-256-ccm\"\n#define NID_aes_256_ccm         902\n#define OBJ_aes_256_ccm         OBJ_aes,47L\n\n#define SN_id_aes256_wrap_pad           \"id-aes256-wrap-pad\"\n#define NID_id_aes256_wrap_pad          903\n#define OBJ_id_aes256_wrap_pad          OBJ_aes,48L\n\n#define SN_aes_128_cfb1         \"AES-128-CFB1\"\n#define LN_aes_128_cfb1         \"aes-128-cfb1\"\n#define NID_aes_128_cfb1                650\n\n#define SN_aes_192_cfb1         \"AES-192-CFB1\"\n#define LN_aes_192_cfb1         \"aes-192-cfb1\"\n#define NID_aes_192_cfb1                651\n\n#define SN_aes_256_cfb1         \"AES-256-CFB1\"\n#define LN_aes_256_cfb1         \"aes-256-cfb1\"\n#define NID_aes_256_cfb1                652\n\n#define SN_aes_128_cfb8         \"AES-128-CFB8\"\n#define LN_aes_128_cfb8         \"aes-128-cfb8\"\n#define NID_aes_128_cfb8                653\n\n#define SN_aes_192_cfb8         \"AES-192-CFB8\"\n#define LN_aes_192_cfb8         \"aes-192-cfb8\"\n#define NID_aes_192_cfb8                654\n\n#define SN_aes_256_cfb8         \"AES-256-CFB8\"\n#define LN_aes_256_cfb8         \"aes-256-cfb8\"\n#define NID_aes_256_cfb8                655\n\n#define SN_aes_128_ctr          \"AES-128-CTR\"\n#define LN_aes_128_ctr          \"aes-128-ctr\"\n#define NID_aes_128_ctr         904\n\n#define SN_aes_192_ctr          \"AES-192-CTR\"\n#define LN_aes_192_ctr          \"aes-192-ctr\"\n#define NID_aes_192_ctr         905\n\n#define SN_aes_256_ctr          \"AES-256-CTR\"\n#define LN_aes_256_ctr          \"aes-256-ctr\"\n#define NID_aes_256_ctr         906\n\n#define SN_aes_128_xts          \"AES-128-XTS\"\n#define LN_aes_128_xts          \"aes-128-xts\"\n#define NID_aes_128_xts         913\n\n#define SN_aes_256_xts          \"AES-256-XTS\"\n#define LN_aes_256_xts          \"aes-256-xts\"\n#define NID_aes_256_xts         914\n\n#define SN_des_cfb1             \"DES-CFB1\"\n#define LN_des_cfb1             \"des-cfb1\"\n#define NID_des_cfb1            656\n\n#define SN_des_cfb8             \"DES-CFB8\"\n#define LN_des_cfb8             \"des-cfb8\"\n#define NID_des_cfb8            657\n\n#define SN_des_ede3_cfb1                \"DES-EDE3-CFB1\"\n#define LN_des_ede3_cfb1                \"des-ede3-cfb1\"\n#define NID_des_ede3_cfb1               658\n\n#define SN_des_ede3_cfb8                \"DES-EDE3-CFB8\"\n#define LN_des_ede3_cfb8                \"des-ede3-cfb8\"\n#define NID_des_ede3_cfb8               659\n\n#define OBJ_nist_hashalgs               OBJ_nistAlgorithms,2L\n\n#define SN_sha256               \"SHA256\"\n#define LN_sha256               \"sha256\"\n#define NID_sha256              672\n#define OBJ_sha256              OBJ_nist_hashalgs,1L\n\n#define SN_sha384               \"SHA384\"\n#define LN_sha384               \"sha384\"\n#define NID_sha384              673\n#define OBJ_sha384              OBJ_nist_hashalgs,2L\n\n#define SN_sha512               \"SHA512\"\n#define LN_sha512               \"sha512\"\n#define NID_sha512              674\n#define OBJ_sha512              OBJ_nist_hashalgs,3L\n\n#define SN_sha224               \"SHA224\"\n#define LN_sha224               \"sha224\"\n#define NID_sha224              675\n#define OBJ_sha224              OBJ_nist_hashalgs,4L\n\n#define OBJ_dsa_with_sha2               OBJ_nistAlgorithms,3L\n\n#define SN_dsa_with_SHA224              \"dsa_with_SHA224\"\n#define NID_dsa_with_SHA224             802\n#define OBJ_dsa_with_SHA224             OBJ_dsa_with_sha2,1L\n\n#define SN_dsa_with_SHA256              \"dsa_with_SHA256\"\n#define NID_dsa_with_SHA256             803\n#define OBJ_dsa_with_SHA256             OBJ_dsa_with_sha2,2L\n\n#define SN_hold_instruction_code                \"holdInstructionCode\"\n#define LN_hold_instruction_code                \"Hold Instruction Code\"\n#define NID_hold_instruction_code               430\n#define OBJ_hold_instruction_code               OBJ_id_ce,23L\n\n#define OBJ_holdInstruction             OBJ_X9_57,2L\n\n#define SN_hold_instruction_none                \"holdInstructionNone\"\n#define LN_hold_instruction_none                \"Hold Instruction None\"\n#define NID_hold_instruction_none               431\n#define OBJ_hold_instruction_none               OBJ_holdInstruction,1L\n\n#define SN_hold_instruction_call_issuer         \"holdInstructionCallIssuer\"\n#define LN_hold_instruction_call_issuer         \"Hold Instruction Call Issuer\"\n#define NID_hold_instruction_call_issuer                432\n#define OBJ_hold_instruction_call_issuer                OBJ_holdInstruction,2L\n\n#define SN_hold_instruction_reject              \"holdInstructionReject\"\n#define LN_hold_instruction_reject              \"Hold Instruction Reject\"\n#define NID_hold_instruction_reject             433\n#define OBJ_hold_instruction_reject             OBJ_holdInstruction,3L\n\n#define SN_data         \"data\"\n#define NID_data                434\n#define OBJ_data                OBJ_itu_t,9L\n\n#define SN_pss          \"pss\"\n#define NID_pss         435\n#define OBJ_pss         OBJ_data,2342L\n\n#define SN_ucl          \"ucl\"\n#define NID_ucl         436\n#define OBJ_ucl         OBJ_pss,19200300L\n\n#define SN_pilot                \"pilot\"\n#define NID_pilot               437\n#define OBJ_pilot               OBJ_ucl,100L\n\n#define LN_pilotAttributeType           \"pilotAttributeType\"\n#define NID_pilotAttributeType          438\n#define OBJ_pilotAttributeType          OBJ_pilot,1L\n\n#define LN_pilotAttributeSyntax         \"pilotAttributeSyntax\"\n#define NID_pilotAttributeSyntax                439\n#define OBJ_pilotAttributeSyntax                OBJ_pilot,3L\n\n#define LN_pilotObjectClass             \"pilotObjectClass\"\n#define NID_pilotObjectClass            440\n#define OBJ_pilotObjectClass            OBJ_pilot,4L\n\n#define LN_pilotGroups          \"pilotGroups\"\n#define NID_pilotGroups         441\n#define OBJ_pilotGroups         OBJ_pilot,10L\n\n#define LN_iA5StringSyntax              \"iA5StringSyntax\"\n#define NID_iA5StringSyntax             442\n#define OBJ_iA5StringSyntax             OBJ_pilotAttributeSyntax,4L\n\n#define LN_caseIgnoreIA5StringSyntax            \"caseIgnoreIA5StringSyntax\"\n#define NID_caseIgnoreIA5StringSyntax           443\n#define OBJ_caseIgnoreIA5StringSyntax           OBJ_pilotAttributeSyntax,5L\n\n#define LN_pilotObject          \"pilotObject\"\n#define NID_pilotObject         444\n#define OBJ_pilotObject         OBJ_pilotObjectClass,3L\n\n#define LN_pilotPerson          \"pilotPerson\"\n#define NID_pilotPerson         445\n#define OBJ_pilotPerson         OBJ_pilotObjectClass,4L\n\n#define SN_account              \"account\"\n#define NID_account             446\n#define OBJ_account             OBJ_pilotObjectClass,5L\n\n#define SN_document             \"document\"\n#define NID_document            447\n#define OBJ_document            OBJ_pilotObjectClass,6L\n\n#define SN_room         \"room\"\n#define NID_room                448\n#define OBJ_room                OBJ_pilotObjectClass,7L\n\n#define LN_documentSeries               \"documentSeries\"\n#define NID_documentSeries              449\n#define OBJ_documentSeries              OBJ_pilotObjectClass,9L\n\n#define SN_Domain               \"domain\"\n#define LN_Domain               \"Domain\"\n#define NID_Domain              392\n#define OBJ_Domain              OBJ_pilotObjectClass,13L\n\n#define LN_rFC822localPart              \"rFC822localPart\"\n#define NID_rFC822localPart             450\n#define OBJ_rFC822localPart             OBJ_pilotObjectClass,14L\n\n#define LN_dNSDomain            \"dNSDomain\"\n#define NID_dNSDomain           451\n#define OBJ_dNSDomain           OBJ_pilotObjectClass,15L\n\n#define LN_domainRelatedObject          \"domainRelatedObject\"\n#define NID_domainRelatedObject         452\n#define OBJ_domainRelatedObject         OBJ_pilotObjectClass,17L\n\n#define LN_friendlyCountry              \"friendlyCountry\"\n#define NID_friendlyCountry             453\n#define OBJ_friendlyCountry             OBJ_pilotObjectClass,18L\n\n#define LN_simpleSecurityObject         \"simpleSecurityObject\"\n#define NID_simpleSecurityObject                454\n#define OBJ_simpleSecurityObject                OBJ_pilotObjectClass,19L\n\n#define LN_pilotOrganization            \"pilotOrganization\"\n#define NID_pilotOrganization           455\n#define OBJ_pilotOrganization           OBJ_pilotObjectClass,20L\n\n#define LN_pilotDSA             \"pilotDSA\"\n#define NID_pilotDSA            456\n#define OBJ_pilotDSA            OBJ_pilotObjectClass,21L\n\n#define LN_qualityLabelledData          \"qualityLabelledData\"\n#define NID_qualityLabelledData         457\n#define OBJ_qualityLabelledData         OBJ_pilotObjectClass,22L\n\n#define SN_userId               \"UID\"\n#define LN_userId               \"userId\"\n#define NID_userId              458\n#define OBJ_userId              OBJ_pilotAttributeType,1L\n\n#define LN_textEncodedORAddress         \"textEncodedORAddress\"\n#define NID_textEncodedORAddress                459\n#define OBJ_textEncodedORAddress                OBJ_pilotAttributeType,2L\n\n#define SN_rfc822Mailbox                \"mail\"\n#define LN_rfc822Mailbox                \"rfc822Mailbox\"\n#define NID_rfc822Mailbox               460\n#define OBJ_rfc822Mailbox               OBJ_pilotAttributeType,3L\n\n#define SN_info         \"info\"\n#define NID_info                461\n#define OBJ_info                OBJ_pilotAttributeType,4L\n\n#define LN_favouriteDrink               \"favouriteDrink\"\n#define NID_favouriteDrink              462\n#define OBJ_favouriteDrink              OBJ_pilotAttributeType,5L\n\n#define LN_roomNumber           \"roomNumber\"\n#define NID_roomNumber          463\n#define OBJ_roomNumber          OBJ_pilotAttributeType,6L\n\n#define SN_photo                \"photo\"\n#define NID_photo               464\n#define OBJ_photo               OBJ_pilotAttributeType,7L\n\n#define LN_userClass            \"userClass\"\n#define NID_userClass           465\n#define OBJ_userClass           OBJ_pilotAttributeType,8L\n\n#define SN_host         \"host\"\n#define NID_host                466\n#define OBJ_host                OBJ_pilotAttributeType,9L\n\n#define SN_manager              \"manager\"\n#define NID_manager             467\n#define OBJ_manager             OBJ_pilotAttributeType,10L\n\n#define LN_documentIdentifier           \"documentIdentifier\"\n#define NID_documentIdentifier          468\n#define OBJ_documentIdentifier          OBJ_pilotAttributeType,11L\n\n#define LN_documentTitle                \"documentTitle\"\n#define NID_documentTitle               469\n#define OBJ_documentTitle               OBJ_pilotAttributeType,12L\n\n#define LN_documentVersion              \"documentVersion\"\n#define NID_documentVersion             470\n#define OBJ_documentVersion             OBJ_pilotAttributeType,13L\n\n#define LN_documentAuthor               \"documentAuthor\"\n#define NID_documentAuthor              471\n#define OBJ_documentAuthor              OBJ_pilotAttributeType,14L\n\n#define LN_documentLocation             \"documentLocation\"\n#define NID_documentLocation            472\n#define OBJ_documentLocation            OBJ_pilotAttributeType,15L\n\n#define LN_homeTelephoneNumber          \"homeTelephoneNumber\"\n#define NID_homeTelephoneNumber         473\n#define OBJ_homeTelephoneNumber         OBJ_pilotAttributeType,20L\n\n#define SN_secretary            \"secretary\"\n#define NID_secretary           474\n#define OBJ_secretary           OBJ_pilotAttributeType,21L\n\n#define LN_otherMailbox         \"otherMailbox\"\n#define NID_otherMailbox                475\n#define OBJ_otherMailbox                OBJ_pilotAttributeType,22L\n\n#define LN_lastModifiedTime             \"lastModifiedTime\"\n#define NID_lastModifiedTime            476\n#define OBJ_lastModifiedTime            OBJ_pilotAttributeType,23L\n\n#define LN_lastModifiedBy               \"lastModifiedBy\"\n#define NID_lastModifiedBy              477\n#define OBJ_lastModifiedBy              OBJ_pilotAttributeType,24L\n\n#define SN_domainComponent              \"DC\"\n#define LN_domainComponent              \"domainComponent\"\n#define NID_domainComponent             391\n#define OBJ_domainComponent             OBJ_pilotAttributeType,25L\n\n#define LN_aRecord              \"aRecord\"\n#define NID_aRecord             478\n#define OBJ_aRecord             OBJ_pilotAttributeType,26L\n\n#define LN_pilotAttributeType27         \"pilotAttributeType27\"\n#define NID_pilotAttributeType27                479\n#define OBJ_pilotAttributeType27                OBJ_pilotAttributeType,27L\n\n#define LN_mXRecord             \"mXRecord\"\n#define NID_mXRecord            480\n#define OBJ_mXRecord            OBJ_pilotAttributeType,28L\n\n#define LN_nSRecord             \"nSRecord\"\n#define NID_nSRecord            481\n#define OBJ_nSRecord            OBJ_pilotAttributeType,29L\n\n#define LN_sOARecord            \"sOARecord\"\n#define NID_sOARecord           482\n#define OBJ_sOARecord           OBJ_pilotAttributeType,30L\n\n#define LN_cNAMERecord          \"cNAMERecord\"\n#define NID_cNAMERecord         483\n#define OBJ_cNAMERecord         OBJ_pilotAttributeType,31L\n\n#define LN_associatedDomain             \"associatedDomain\"\n#define NID_associatedDomain            484\n#define OBJ_associatedDomain            OBJ_pilotAttributeType,37L\n\n#define LN_associatedName               \"associatedName\"\n#define NID_associatedName              485\n#define OBJ_associatedName              OBJ_pilotAttributeType,38L\n\n#define LN_homePostalAddress            \"homePostalAddress\"\n#define NID_homePostalAddress           486\n#define OBJ_homePostalAddress           OBJ_pilotAttributeType,39L\n\n#define LN_personalTitle                \"personalTitle\"\n#define NID_personalTitle               487\n#define OBJ_personalTitle               OBJ_pilotAttributeType,40L\n\n#define LN_mobileTelephoneNumber                \"mobileTelephoneNumber\"\n#define NID_mobileTelephoneNumber               488\n#define OBJ_mobileTelephoneNumber               OBJ_pilotAttributeType,41L\n\n#define LN_pagerTelephoneNumber         \"pagerTelephoneNumber\"\n#define NID_pagerTelephoneNumber                489\n#define OBJ_pagerTelephoneNumber                OBJ_pilotAttributeType,42L\n\n#define LN_friendlyCountryName          \"friendlyCountryName\"\n#define NID_friendlyCountryName         490\n#define OBJ_friendlyCountryName         OBJ_pilotAttributeType,43L\n\n#define LN_organizationalStatus         \"organizationalStatus\"\n#define NID_organizationalStatus                491\n#define OBJ_organizationalStatus                OBJ_pilotAttributeType,45L\n\n#define LN_janetMailbox         \"janetMailbox\"\n#define NID_janetMailbox                492\n#define OBJ_janetMailbox                OBJ_pilotAttributeType,46L\n\n#define LN_mailPreferenceOption         \"mailPreferenceOption\"\n#define NID_mailPreferenceOption                493\n#define OBJ_mailPreferenceOption                OBJ_pilotAttributeType,47L\n\n#define LN_buildingName         \"buildingName\"\n#define NID_buildingName                494\n#define OBJ_buildingName                OBJ_pilotAttributeType,48L\n\n#define LN_dSAQuality           \"dSAQuality\"\n#define NID_dSAQuality          495\n#define OBJ_dSAQuality          OBJ_pilotAttributeType,49L\n\n#define LN_singleLevelQuality           \"singleLevelQuality\"\n#define NID_singleLevelQuality          496\n#define OBJ_singleLevelQuality          OBJ_pilotAttributeType,50L\n\n#define LN_subtreeMinimumQuality                \"subtreeMinimumQuality\"\n#define NID_subtreeMinimumQuality               497\n#define OBJ_subtreeMinimumQuality               OBJ_pilotAttributeType,51L\n\n#define LN_subtreeMaximumQuality                \"subtreeMaximumQuality\"\n#define NID_subtreeMaximumQuality               498\n#define OBJ_subtreeMaximumQuality               OBJ_pilotAttributeType,52L\n\n#define LN_personalSignature            \"personalSignature\"\n#define NID_personalSignature           499\n#define OBJ_personalSignature           OBJ_pilotAttributeType,53L\n\n#define LN_dITRedirect          \"dITRedirect\"\n#define NID_dITRedirect         500\n#define OBJ_dITRedirect         OBJ_pilotAttributeType,54L\n\n#define SN_audio                \"audio\"\n#define NID_audio               501\n#define OBJ_audio               OBJ_pilotAttributeType,55L\n\n#define LN_documentPublisher            \"documentPublisher\"\n#define NID_documentPublisher           502\n#define OBJ_documentPublisher           OBJ_pilotAttributeType,56L\n\n#define SN_id_set               \"id-set\"\n#define LN_id_set               \"Secure Electronic Transactions\"\n#define NID_id_set              512\n#define OBJ_id_set              OBJ_international_organizations,42L\n\n#define SN_set_ctype            \"set-ctype\"\n#define LN_set_ctype            \"content types\"\n#define NID_set_ctype           513\n#define OBJ_set_ctype           OBJ_id_set,0L\n\n#define SN_set_msgExt           \"set-msgExt\"\n#define LN_set_msgExt           \"message extensions\"\n#define NID_set_msgExt          514\n#define OBJ_set_msgExt          OBJ_id_set,1L\n\n#define SN_set_attr             \"set-attr\"\n#define NID_set_attr            515\n#define OBJ_set_attr            OBJ_id_set,3L\n\n#define SN_set_policy           \"set-policy\"\n#define NID_set_policy          516\n#define OBJ_set_policy          OBJ_id_set,5L\n\n#define SN_set_certExt          \"set-certExt\"\n#define LN_set_certExt          \"certificate extensions\"\n#define NID_set_certExt         517\n#define OBJ_set_certExt         OBJ_id_set,7L\n\n#define SN_set_brand            \"set-brand\"\n#define NID_set_brand           518\n#define OBJ_set_brand           OBJ_id_set,8L\n\n#define SN_setct_PANData                \"setct-PANData\"\n#define NID_setct_PANData               519\n#define OBJ_setct_PANData               OBJ_set_ctype,0L\n\n#define SN_setct_PANToken               \"setct-PANToken\"\n#define NID_setct_PANToken              520\n#define OBJ_setct_PANToken              OBJ_set_ctype,1L\n\n#define SN_setct_PANOnly                \"setct-PANOnly\"\n#define NID_setct_PANOnly               521\n#define OBJ_setct_PANOnly               OBJ_set_ctype,2L\n\n#define SN_setct_OIData         \"setct-OIData\"\n#define NID_setct_OIData                522\n#define OBJ_setct_OIData                OBJ_set_ctype,3L\n\n#define SN_setct_PI             \"setct-PI\"\n#define NID_setct_PI            523\n#define OBJ_setct_PI            OBJ_set_ctype,4L\n\n#define SN_setct_PIData         \"setct-PIData\"\n#define NID_setct_PIData                524\n#define OBJ_setct_PIData                OBJ_set_ctype,5L\n\n#define SN_setct_PIDataUnsigned         \"setct-PIDataUnsigned\"\n#define NID_setct_PIDataUnsigned                525\n#define OBJ_setct_PIDataUnsigned                OBJ_set_ctype,6L\n\n#define SN_setct_HODInput               \"setct-HODInput\"\n#define NID_setct_HODInput              526\n#define OBJ_setct_HODInput              OBJ_set_ctype,7L\n\n#define SN_setct_AuthResBaggage         \"setct-AuthResBaggage\"\n#define NID_setct_AuthResBaggage                527\n#define OBJ_setct_AuthResBaggage                OBJ_set_ctype,8L\n\n#define SN_setct_AuthRevReqBaggage              \"setct-AuthRevReqBaggage\"\n#define NID_setct_AuthRevReqBaggage             528\n#define OBJ_setct_AuthRevReqBaggage             OBJ_set_ctype,9L\n\n#define SN_setct_AuthRevResBaggage              \"setct-AuthRevResBaggage\"\n#define NID_setct_AuthRevResBaggage             529\n#define OBJ_setct_AuthRevResBaggage             OBJ_set_ctype,10L\n\n#define SN_setct_CapTokenSeq            \"setct-CapTokenSeq\"\n#define NID_setct_CapTokenSeq           530\n#define OBJ_setct_CapTokenSeq           OBJ_set_ctype,11L\n\n#define SN_setct_PInitResData           \"setct-PInitResData\"\n#define NID_setct_PInitResData          531\n#define OBJ_setct_PInitResData          OBJ_set_ctype,12L\n\n#define SN_setct_PI_TBS         \"setct-PI-TBS\"\n#define NID_setct_PI_TBS                532\n#define OBJ_setct_PI_TBS                OBJ_set_ctype,13L\n\n#define SN_setct_PResData               \"setct-PResData\"\n#define NID_setct_PResData              533\n#define OBJ_setct_PResData              OBJ_set_ctype,14L\n\n#define SN_setct_AuthReqTBS             \"setct-AuthReqTBS\"\n#define NID_setct_AuthReqTBS            534\n#define OBJ_setct_AuthReqTBS            OBJ_set_ctype,16L\n\n#define SN_setct_AuthResTBS             \"setct-AuthResTBS\"\n#define NID_setct_AuthResTBS            535\n#define OBJ_setct_AuthResTBS            OBJ_set_ctype,17L\n\n#define SN_setct_AuthResTBSX            \"setct-AuthResTBSX\"\n#define NID_setct_AuthResTBSX           536\n#define OBJ_setct_AuthResTBSX           OBJ_set_ctype,18L\n\n#define SN_setct_AuthTokenTBS           \"setct-AuthTokenTBS\"\n#define NID_setct_AuthTokenTBS          537\n#define OBJ_setct_AuthTokenTBS          OBJ_set_ctype,19L\n\n#define SN_setct_CapTokenData           \"setct-CapTokenData\"\n#define NID_setct_CapTokenData          538\n#define OBJ_setct_CapTokenData          OBJ_set_ctype,20L\n\n#define SN_setct_CapTokenTBS            \"setct-CapTokenTBS\"\n#define NID_setct_CapTokenTBS           539\n#define OBJ_setct_CapTokenTBS           OBJ_set_ctype,21L\n\n#define SN_setct_AcqCardCodeMsg         \"setct-AcqCardCodeMsg\"\n#define NID_setct_AcqCardCodeMsg                540\n#define OBJ_setct_AcqCardCodeMsg                OBJ_set_ctype,22L\n\n#define SN_setct_AuthRevReqTBS          \"setct-AuthRevReqTBS\"\n#define NID_setct_AuthRevReqTBS         541\n#define OBJ_setct_AuthRevReqTBS         OBJ_set_ctype,23L\n\n#define SN_setct_AuthRevResData         \"setct-AuthRevResData\"\n#define NID_setct_AuthRevResData                542\n#define OBJ_setct_AuthRevResData                OBJ_set_ctype,24L\n\n#define SN_setct_AuthRevResTBS          \"setct-AuthRevResTBS\"\n#define NID_setct_AuthRevResTBS         543\n#define OBJ_setct_AuthRevResTBS         OBJ_set_ctype,25L\n\n#define SN_setct_CapReqTBS              \"setct-CapReqTBS\"\n#define NID_setct_CapReqTBS             544\n#define OBJ_setct_CapReqTBS             OBJ_set_ctype,26L\n\n#define SN_setct_CapReqTBSX             \"setct-CapReqTBSX\"\n#define NID_setct_CapReqTBSX            545\n#define OBJ_setct_CapReqTBSX            OBJ_set_ctype,27L\n\n#define SN_setct_CapResData             \"setct-CapResData\"\n#define NID_setct_CapResData            546\n#define OBJ_setct_CapResData            OBJ_set_ctype,28L\n\n#define SN_setct_CapRevReqTBS           \"setct-CapRevReqTBS\"\n#define NID_setct_CapRevReqTBS          547\n#define OBJ_setct_CapRevReqTBS          OBJ_set_ctype,29L\n\n#define SN_setct_CapRevReqTBSX          \"setct-CapRevReqTBSX\"\n#define NID_setct_CapRevReqTBSX         548\n#define OBJ_setct_CapRevReqTBSX         OBJ_set_ctype,30L\n\n#define SN_setct_CapRevResData          \"setct-CapRevResData\"\n#define NID_setct_CapRevResData         549\n#define OBJ_setct_CapRevResData         OBJ_set_ctype,31L\n\n#define SN_setct_CredReqTBS             \"setct-CredReqTBS\"\n#define NID_setct_CredReqTBS            550\n#define OBJ_setct_CredReqTBS            OBJ_set_ctype,32L\n\n#define SN_setct_CredReqTBSX            \"setct-CredReqTBSX\"\n#define NID_setct_CredReqTBSX           551\n#define OBJ_setct_CredReqTBSX           OBJ_set_ctype,33L\n\n#define SN_setct_CredResData            \"setct-CredResData\"\n#define NID_setct_CredResData           552\n#define OBJ_setct_CredResData           OBJ_set_ctype,34L\n\n#define SN_setct_CredRevReqTBS          \"setct-CredRevReqTBS\"\n#define NID_setct_CredRevReqTBS         553\n#define OBJ_setct_CredRevReqTBS         OBJ_set_ctype,35L\n\n#define SN_setct_CredRevReqTBSX         \"setct-CredRevReqTBSX\"\n#define NID_setct_CredRevReqTBSX                554\n#define OBJ_setct_CredRevReqTBSX                OBJ_set_ctype,36L\n\n#define SN_setct_CredRevResData         \"setct-CredRevResData\"\n#define NID_setct_CredRevResData                555\n#define OBJ_setct_CredRevResData                OBJ_set_ctype,37L\n\n#define SN_setct_PCertReqData           \"setct-PCertReqData\"\n#define NID_setct_PCertReqData          556\n#define OBJ_setct_PCertReqData          OBJ_set_ctype,38L\n\n#define SN_setct_PCertResTBS            \"setct-PCertResTBS\"\n#define NID_setct_PCertResTBS           557\n#define OBJ_setct_PCertResTBS           OBJ_set_ctype,39L\n\n#define SN_setct_BatchAdminReqData              \"setct-BatchAdminReqData\"\n#define NID_setct_BatchAdminReqData             558\n#define OBJ_setct_BatchAdminReqData             OBJ_set_ctype,40L\n\n#define SN_setct_BatchAdminResData              \"setct-BatchAdminResData\"\n#define NID_setct_BatchAdminResData             559\n#define OBJ_setct_BatchAdminResData             OBJ_set_ctype,41L\n\n#define SN_setct_CardCInitResTBS                \"setct-CardCInitResTBS\"\n#define NID_setct_CardCInitResTBS               560\n#define OBJ_setct_CardCInitResTBS               OBJ_set_ctype,42L\n\n#define SN_setct_MeAqCInitResTBS                \"setct-MeAqCInitResTBS\"\n#define NID_setct_MeAqCInitResTBS               561\n#define OBJ_setct_MeAqCInitResTBS               OBJ_set_ctype,43L\n\n#define SN_setct_RegFormResTBS          \"setct-RegFormResTBS\"\n#define NID_setct_RegFormResTBS         562\n#define OBJ_setct_RegFormResTBS         OBJ_set_ctype,44L\n\n#define SN_setct_CertReqData            \"setct-CertReqData\"\n#define NID_setct_CertReqData           563\n#define OBJ_setct_CertReqData           OBJ_set_ctype,45L\n\n#define SN_setct_CertReqTBS             \"setct-CertReqTBS\"\n#define NID_setct_CertReqTBS            564\n#define OBJ_setct_CertReqTBS            OBJ_set_ctype,46L\n\n#define SN_setct_CertResData            \"setct-CertResData\"\n#define NID_setct_CertResData           565\n#define OBJ_setct_CertResData           OBJ_set_ctype,47L\n\n#define SN_setct_CertInqReqTBS          \"setct-CertInqReqTBS\"\n#define NID_setct_CertInqReqTBS         566\n#define OBJ_setct_CertInqReqTBS         OBJ_set_ctype,48L\n\n#define SN_setct_ErrorTBS               \"setct-ErrorTBS\"\n#define NID_setct_ErrorTBS              567\n#define OBJ_setct_ErrorTBS              OBJ_set_ctype,49L\n\n#define SN_setct_PIDualSignedTBE                \"setct-PIDualSignedTBE\"\n#define NID_setct_PIDualSignedTBE               568\n#define OBJ_setct_PIDualSignedTBE               OBJ_set_ctype,50L\n\n#define SN_setct_PIUnsignedTBE          \"setct-PIUnsignedTBE\"\n#define NID_setct_PIUnsignedTBE         569\n#define OBJ_setct_PIUnsignedTBE         OBJ_set_ctype,51L\n\n#define SN_setct_AuthReqTBE             \"setct-AuthReqTBE\"\n#define NID_setct_AuthReqTBE            570\n#define OBJ_setct_AuthReqTBE            OBJ_set_ctype,52L\n\n#define SN_setct_AuthResTBE             \"setct-AuthResTBE\"\n#define NID_setct_AuthResTBE            571\n#define OBJ_setct_AuthResTBE            OBJ_set_ctype,53L\n\n#define SN_setct_AuthResTBEX            \"setct-AuthResTBEX\"\n#define NID_setct_AuthResTBEX           572\n#define OBJ_setct_AuthResTBEX           OBJ_set_ctype,54L\n\n#define SN_setct_AuthTokenTBE           \"setct-AuthTokenTBE\"\n#define NID_setct_AuthTokenTBE          573\n#define OBJ_setct_AuthTokenTBE          OBJ_set_ctype,55L\n\n#define SN_setct_CapTokenTBE            \"setct-CapTokenTBE\"\n#define NID_setct_CapTokenTBE           574\n#define OBJ_setct_CapTokenTBE           OBJ_set_ctype,56L\n\n#define SN_setct_CapTokenTBEX           \"setct-CapTokenTBEX\"\n#define NID_setct_CapTokenTBEX          575\n#define OBJ_setct_CapTokenTBEX          OBJ_set_ctype,57L\n\n#define SN_setct_AcqCardCodeMsgTBE              \"setct-AcqCardCodeMsgTBE\"\n#define NID_setct_AcqCardCodeMsgTBE             576\n#define OBJ_setct_AcqCardCodeMsgTBE             OBJ_set_ctype,58L\n\n#define SN_setct_AuthRevReqTBE          \"setct-AuthRevReqTBE\"\n#define NID_setct_AuthRevReqTBE         577\n#define OBJ_setct_AuthRevReqTBE         OBJ_set_ctype,59L\n\n#define SN_setct_AuthRevResTBE          \"setct-AuthRevResTBE\"\n#define NID_setct_AuthRevResTBE         578\n#define OBJ_setct_AuthRevResTBE         OBJ_set_ctype,60L\n\n#define SN_setct_AuthRevResTBEB         \"setct-AuthRevResTBEB\"\n#define NID_setct_AuthRevResTBEB                579\n#define OBJ_setct_AuthRevResTBEB                OBJ_set_ctype,61L\n\n#define SN_setct_CapReqTBE              \"setct-CapReqTBE\"\n#define NID_setct_CapReqTBE             580\n#define OBJ_setct_CapReqTBE             OBJ_set_ctype,62L\n\n#define SN_setct_CapReqTBEX             \"setct-CapReqTBEX\"\n#define NID_setct_CapReqTBEX            581\n#define OBJ_setct_CapReqTBEX            OBJ_set_ctype,63L\n\n#define SN_setct_CapResTBE              \"setct-CapResTBE\"\n#define NID_setct_CapResTBE             582\n#define OBJ_setct_CapResTBE             OBJ_set_ctype,64L\n\n#define SN_setct_CapRevReqTBE           \"setct-CapRevReqTBE\"\n#define NID_setct_CapRevReqTBE          583\n#define OBJ_setct_CapRevReqTBE          OBJ_set_ctype,65L\n\n#define SN_setct_CapRevReqTBEX          \"setct-CapRevReqTBEX\"\n#define NID_setct_CapRevReqTBEX         584\n#define OBJ_setct_CapRevReqTBEX         OBJ_set_ctype,66L\n\n#define SN_setct_CapRevResTBE           \"setct-CapRevResTBE\"\n#define NID_setct_CapRevResTBE          585\n#define OBJ_setct_CapRevResTBE          OBJ_set_ctype,67L\n\n#define SN_setct_CredReqTBE             \"setct-CredReqTBE\"\n#define NID_setct_CredReqTBE            586\n#define OBJ_setct_CredReqTBE            OBJ_set_ctype,68L\n\n#define SN_setct_CredReqTBEX            \"setct-CredReqTBEX\"\n#define NID_setct_CredReqTBEX           587\n#define OBJ_setct_CredReqTBEX           OBJ_set_ctype,69L\n\n#define SN_setct_CredResTBE             \"setct-CredResTBE\"\n#define NID_setct_CredResTBE            588\n#define OBJ_setct_CredResTBE            OBJ_set_ctype,70L\n\n#define SN_setct_CredRevReqTBE          \"setct-CredRevReqTBE\"\n#define NID_setct_CredRevReqTBE         589\n#define OBJ_setct_CredRevReqTBE         OBJ_set_ctype,71L\n\n#define SN_setct_CredRevReqTBEX         \"setct-CredRevReqTBEX\"\n#define NID_setct_CredRevReqTBEX                590\n#define OBJ_setct_CredRevReqTBEX                OBJ_set_ctype,72L\n\n#define SN_setct_CredRevResTBE          \"setct-CredRevResTBE\"\n#define NID_setct_CredRevResTBE         591\n#define OBJ_setct_CredRevResTBE         OBJ_set_ctype,73L\n\n#define SN_setct_BatchAdminReqTBE               \"setct-BatchAdminReqTBE\"\n#define NID_setct_BatchAdminReqTBE              592\n#define OBJ_setct_BatchAdminReqTBE              OBJ_set_ctype,74L\n\n#define SN_setct_BatchAdminResTBE               \"setct-BatchAdminResTBE\"\n#define NID_setct_BatchAdminResTBE              593\n#define OBJ_setct_BatchAdminResTBE              OBJ_set_ctype,75L\n\n#define SN_setct_RegFormReqTBE          \"setct-RegFormReqTBE\"\n#define NID_setct_RegFormReqTBE         594\n#define OBJ_setct_RegFormReqTBE         OBJ_set_ctype,76L\n\n#define SN_setct_CertReqTBE             \"setct-CertReqTBE\"\n#define NID_setct_CertReqTBE            595\n#define OBJ_setct_CertReqTBE            OBJ_set_ctype,77L\n\n#define SN_setct_CertReqTBEX            \"setct-CertReqTBEX\"\n#define NID_setct_CertReqTBEX           596\n#define OBJ_setct_CertReqTBEX           OBJ_set_ctype,78L\n\n#define SN_setct_CertResTBE             \"setct-CertResTBE\"\n#define NID_setct_CertResTBE            597\n#define OBJ_setct_CertResTBE            OBJ_set_ctype,79L\n\n#define SN_setct_CRLNotificationTBS             \"setct-CRLNotificationTBS\"\n#define NID_setct_CRLNotificationTBS            598\n#define OBJ_setct_CRLNotificationTBS            OBJ_set_ctype,80L\n\n#define SN_setct_CRLNotificationResTBS          \"setct-CRLNotificationResTBS\"\n#define NID_setct_CRLNotificationResTBS         599\n#define OBJ_setct_CRLNotificationResTBS         OBJ_set_ctype,81L\n\n#define SN_setct_BCIDistributionTBS             \"setct-BCIDistributionTBS\"\n#define NID_setct_BCIDistributionTBS            600\n#define OBJ_setct_BCIDistributionTBS            OBJ_set_ctype,82L\n\n#define SN_setext_genCrypt              \"setext-genCrypt\"\n#define LN_setext_genCrypt              \"generic cryptogram\"\n#define NID_setext_genCrypt             601\n#define OBJ_setext_genCrypt             OBJ_set_msgExt,1L\n\n#define SN_setext_miAuth                \"setext-miAuth\"\n#define LN_setext_miAuth                \"merchant initiated auth\"\n#define NID_setext_miAuth               602\n#define OBJ_setext_miAuth               OBJ_set_msgExt,3L\n\n#define SN_setext_pinSecure             \"setext-pinSecure\"\n#define NID_setext_pinSecure            603\n#define OBJ_setext_pinSecure            OBJ_set_msgExt,4L\n\n#define SN_setext_pinAny                \"setext-pinAny\"\n#define NID_setext_pinAny               604\n#define OBJ_setext_pinAny               OBJ_set_msgExt,5L\n\n#define SN_setext_track2                \"setext-track2\"\n#define NID_setext_track2               605\n#define OBJ_setext_track2               OBJ_set_msgExt,7L\n\n#define SN_setext_cv            \"setext-cv\"\n#define LN_setext_cv            \"additional verification\"\n#define NID_setext_cv           606\n#define OBJ_setext_cv           OBJ_set_msgExt,8L\n\n#define SN_set_policy_root              \"set-policy-root\"\n#define NID_set_policy_root             607\n#define OBJ_set_policy_root             OBJ_set_policy,0L\n\n#define SN_setCext_hashedRoot           \"setCext-hashedRoot\"\n#define NID_setCext_hashedRoot          608\n#define OBJ_setCext_hashedRoot          OBJ_set_certExt,0L\n\n#define SN_setCext_certType             \"setCext-certType\"\n#define NID_setCext_certType            609\n#define OBJ_setCext_certType            OBJ_set_certExt,1L\n\n#define SN_setCext_merchData            \"setCext-merchData\"\n#define NID_setCext_merchData           610\n#define OBJ_setCext_merchData           OBJ_set_certExt,2L\n\n#define SN_setCext_cCertRequired                \"setCext-cCertRequired\"\n#define NID_setCext_cCertRequired               611\n#define OBJ_setCext_cCertRequired               OBJ_set_certExt,3L\n\n#define SN_setCext_tunneling            \"setCext-tunneling\"\n#define NID_setCext_tunneling           612\n#define OBJ_setCext_tunneling           OBJ_set_certExt,4L\n\n#define SN_setCext_setExt               \"setCext-setExt\"\n#define NID_setCext_setExt              613\n#define OBJ_setCext_setExt              OBJ_set_certExt,5L\n\n#define SN_setCext_setQualf             \"setCext-setQualf\"\n#define NID_setCext_setQualf            614\n#define OBJ_setCext_setQualf            OBJ_set_certExt,6L\n\n#define SN_setCext_PGWYcapabilities             \"setCext-PGWYcapabilities\"\n#define NID_setCext_PGWYcapabilities            615\n#define OBJ_setCext_PGWYcapabilities            OBJ_set_certExt,7L\n\n#define SN_setCext_TokenIdentifier              \"setCext-TokenIdentifier\"\n#define NID_setCext_TokenIdentifier             616\n#define OBJ_setCext_TokenIdentifier             OBJ_set_certExt,8L\n\n#define SN_setCext_Track2Data           \"setCext-Track2Data\"\n#define NID_setCext_Track2Data          617\n#define OBJ_setCext_Track2Data          OBJ_set_certExt,9L\n\n#define SN_setCext_TokenType            \"setCext-TokenType\"\n#define NID_setCext_TokenType           618\n#define OBJ_setCext_TokenType           OBJ_set_certExt,10L\n\n#define SN_setCext_IssuerCapabilities           \"setCext-IssuerCapabilities\"\n#define NID_setCext_IssuerCapabilities          619\n#define OBJ_setCext_IssuerCapabilities          OBJ_set_certExt,11L\n\n#define SN_setAttr_Cert         \"setAttr-Cert\"\n#define NID_setAttr_Cert                620\n#define OBJ_setAttr_Cert                OBJ_set_attr,0L\n\n#define SN_setAttr_PGWYcap              \"setAttr-PGWYcap\"\n#define LN_setAttr_PGWYcap              \"payment gateway capabilities\"\n#define NID_setAttr_PGWYcap             621\n#define OBJ_setAttr_PGWYcap             OBJ_set_attr,1L\n\n#define SN_setAttr_TokenType            \"setAttr-TokenType\"\n#define NID_setAttr_TokenType           622\n#define OBJ_setAttr_TokenType           OBJ_set_attr,2L\n\n#define SN_setAttr_IssCap               \"setAttr-IssCap\"\n#define LN_setAttr_IssCap               \"issuer capabilities\"\n#define NID_setAttr_IssCap              623\n#define OBJ_setAttr_IssCap              OBJ_set_attr,3L\n\n#define SN_set_rootKeyThumb             \"set-rootKeyThumb\"\n#define NID_set_rootKeyThumb            624\n#define OBJ_set_rootKeyThumb            OBJ_setAttr_Cert,0L\n\n#define SN_set_addPolicy                \"set-addPolicy\"\n#define NID_set_addPolicy               625\n#define OBJ_set_addPolicy               OBJ_setAttr_Cert,1L\n\n#define SN_setAttr_Token_EMV            \"setAttr-Token-EMV\"\n#define NID_setAttr_Token_EMV           626\n#define OBJ_setAttr_Token_EMV           OBJ_setAttr_TokenType,1L\n\n#define SN_setAttr_Token_B0Prime                \"setAttr-Token-B0Prime\"\n#define NID_setAttr_Token_B0Prime               627\n#define OBJ_setAttr_Token_B0Prime               OBJ_setAttr_TokenType,2L\n\n#define SN_setAttr_IssCap_CVM           \"setAttr-IssCap-CVM\"\n#define NID_setAttr_IssCap_CVM          628\n#define OBJ_setAttr_IssCap_CVM          OBJ_setAttr_IssCap,3L\n\n#define SN_setAttr_IssCap_T2            \"setAttr-IssCap-T2\"\n#define NID_setAttr_IssCap_T2           629\n#define OBJ_setAttr_IssCap_T2           OBJ_setAttr_IssCap,4L\n\n#define SN_setAttr_IssCap_Sig           \"setAttr-IssCap-Sig\"\n#define NID_setAttr_IssCap_Sig          630\n#define OBJ_setAttr_IssCap_Sig          OBJ_setAttr_IssCap,5L\n\n#define SN_setAttr_GenCryptgrm          \"setAttr-GenCryptgrm\"\n#define LN_setAttr_GenCryptgrm          \"generate cryptogram\"\n#define NID_setAttr_GenCryptgrm         631\n#define OBJ_setAttr_GenCryptgrm         OBJ_setAttr_IssCap_CVM,1L\n\n#define SN_setAttr_T2Enc                \"setAttr-T2Enc\"\n#define LN_setAttr_T2Enc                \"encrypted track 2\"\n#define NID_setAttr_T2Enc               632\n#define OBJ_setAttr_T2Enc               OBJ_setAttr_IssCap_T2,1L\n\n#define SN_setAttr_T2cleartxt           \"setAttr-T2cleartxt\"\n#define LN_setAttr_T2cleartxt           \"cleartext track 2\"\n#define NID_setAttr_T2cleartxt          633\n#define OBJ_setAttr_T2cleartxt          OBJ_setAttr_IssCap_T2,2L\n\n#define SN_setAttr_TokICCsig            \"setAttr-TokICCsig\"\n#define LN_setAttr_TokICCsig            \"ICC or token signature\"\n#define NID_setAttr_TokICCsig           634\n#define OBJ_setAttr_TokICCsig           OBJ_setAttr_IssCap_Sig,1L\n\n#define SN_setAttr_SecDevSig            \"setAttr-SecDevSig\"\n#define LN_setAttr_SecDevSig            \"secure device signature\"\n#define NID_setAttr_SecDevSig           635\n#define OBJ_setAttr_SecDevSig           OBJ_setAttr_IssCap_Sig,2L\n\n#define SN_set_brand_IATA_ATA           \"set-brand-IATA-ATA\"\n#define NID_set_brand_IATA_ATA          636\n#define OBJ_set_brand_IATA_ATA          OBJ_set_brand,1L\n\n#define SN_set_brand_Diners             \"set-brand-Diners\"\n#define NID_set_brand_Diners            637\n#define OBJ_set_brand_Diners            OBJ_set_brand,30L\n\n#define SN_set_brand_AmericanExpress            \"set-brand-AmericanExpress\"\n#define NID_set_brand_AmericanExpress           638\n#define OBJ_set_brand_AmericanExpress           OBJ_set_brand,34L\n\n#define SN_set_brand_JCB                \"set-brand-JCB\"\n#define NID_set_brand_JCB               639\n#define OBJ_set_brand_JCB               OBJ_set_brand,35L\n\n#define SN_set_brand_Visa               \"set-brand-Visa\"\n#define NID_set_brand_Visa              640\n#define OBJ_set_brand_Visa              OBJ_set_brand,4L\n\n#define SN_set_brand_MasterCard         \"set-brand-MasterCard\"\n#define NID_set_brand_MasterCard                641\n#define OBJ_set_brand_MasterCard                OBJ_set_brand,5L\n\n#define SN_set_brand_Novus              \"set-brand-Novus\"\n#define NID_set_brand_Novus             642\n#define OBJ_set_brand_Novus             OBJ_set_brand,6011L\n\n#define SN_des_cdmf             \"DES-CDMF\"\n#define LN_des_cdmf             \"des-cdmf\"\n#define NID_des_cdmf            643\n#define OBJ_des_cdmf            OBJ_rsadsi,3L,10L\n\n#define SN_rsaOAEPEncryptionSET         \"rsaOAEPEncryptionSET\"\n#define NID_rsaOAEPEncryptionSET                644\n#define OBJ_rsaOAEPEncryptionSET                OBJ_rsadsi,1L,1L,6L\n\n#define SN_ipsec3               \"Oakley-EC2N-3\"\n#define LN_ipsec3               \"ipsec3\"\n#define NID_ipsec3              749\n\n#define SN_ipsec4               \"Oakley-EC2N-4\"\n#define LN_ipsec4               \"ipsec4\"\n#define NID_ipsec4              750\n\n#define SN_whirlpool            \"whirlpool\"\n#define NID_whirlpool           804\n#define OBJ_whirlpool           OBJ_iso,0L,10118L,3L,0L,55L\n\n#define SN_cryptopro            \"cryptopro\"\n#define NID_cryptopro           805\n#define OBJ_cryptopro           OBJ_member_body,643L,2L,2L\n\n#define SN_cryptocom            \"cryptocom\"\n#define NID_cryptocom           806\n#define OBJ_cryptocom           OBJ_member_body,643L,2L,9L\n\n#define SN_id_GostR3411_94_with_GostR3410_2001          \"id-GostR3411-94-with-GostR3410-2001\"\n#define LN_id_GostR3411_94_with_GostR3410_2001          \"GOST R 34.11-94 with GOST R 34.10-2001\"\n#define NID_id_GostR3411_94_with_GostR3410_2001         807\n#define OBJ_id_GostR3411_94_with_GostR3410_2001         OBJ_cryptopro,3L\n\n#define SN_id_GostR3411_94_with_GostR3410_94            \"id-GostR3411-94-with-GostR3410-94\"\n#define LN_id_GostR3411_94_with_GostR3410_94            \"GOST R 34.11-94 with GOST R 34.10-94\"\n#define NID_id_GostR3411_94_with_GostR3410_94           808\n#define OBJ_id_GostR3411_94_with_GostR3410_94           OBJ_cryptopro,4L\n\n#define SN_id_GostR3411_94              \"md_gost94\"\n#define LN_id_GostR3411_94              \"GOST R 34.11-94\"\n#define NID_id_GostR3411_94             809\n#define OBJ_id_GostR3411_94             OBJ_cryptopro,9L\n\n#define SN_id_HMACGostR3411_94          \"id-HMACGostR3411-94\"\n#define LN_id_HMACGostR3411_94          \"HMAC GOST 34.11-94\"\n#define NID_id_HMACGostR3411_94         810\n#define OBJ_id_HMACGostR3411_94         OBJ_cryptopro,10L\n\n#define SN_id_GostR3410_2001            \"gost2001\"\n#define LN_id_GostR3410_2001            \"GOST R 34.10-2001\"\n#define NID_id_GostR3410_2001           811\n#define OBJ_id_GostR3410_2001           OBJ_cryptopro,19L\n\n#define SN_id_GostR3410_94              \"gost94\"\n#define LN_id_GostR3410_94              \"GOST R 34.10-94\"\n#define NID_id_GostR3410_94             812\n#define OBJ_id_GostR3410_94             OBJ_cryptopro,20L\n\n#define SN_id_Gost28147_89              \"gost89\"\n#define LN_id_Gost28147_89              \"GOST 28147-89\"\n#define NID_id_Gost28147_89             813\n#define OBJ_id_Gost28147_89             OBJ_cryptopro,21L\n\n#define SN_gost89_cnt           \"gost89-cnt\"\n#define NID_gost89_cnt          814\n\n#define SN_id_Gost28147_89_MAC          \"gost-mac\"\n#define LN_id_Gost28147_89_MAC          \"GOST 28147-89 MAC\"\n#define NID_id_Gost28147_89_MAC         815\n#define OBJ_id_Gost28147_89_MAC         OBJ_cryptopro,22L\n\n#define SN_id_GostR3411_94_prf          \"prf-gostr3411-94\"\n#define LN_id_GostR3411_94_prf          \"GOST R 34.11-94 PRF\"\n#define NID_id_GostR3411_94_prf         816\n#define OBJ_id_GostR3411_94_prf         OBJ_cryptopro,23L\n\n#define SN_id_GostR3410_2001DH          \"id-GostR3410-2001DH\"\n#define LN_id_GostR3410_2001DH          \"GOST R 34.10-2001 DH\"\n#define NID_id_GostR3410_2001DH         817\n#define OBJ_id_GostR3410_2001DH         OBJ_cryptopro,98L\n\n#define SN_id_GostR3410_94DH            \"id-GostR3410-94DH\"\n#define LN_id_GostR3410_94DH            \"GOST R 34.10-94 DH\"\n#define NID_id_GostR3410_94DH           818\n#define OBJ_id_GostR3410_94DH           OBJ_cryptopro,99L\n\n#define SN_id_Gost28147_89_CryptoPro_KeyMeshing         \"id-Gost28147-89-CryptoPro-KeyMeshing\"\n#define NID_id_Gost28147_89_CryptoPro_KeyMeshing                819\n#define OBJ_id_Gost28147_89_CryptoPro_KeyMeshing                OBJ_cryptopro,14L,1L\n\n#define SN_id_Gost28147_89_None_KeyMeshing              \"id-Gost28147-89-None-KeyMeshing\"\n#define NID_id_Gost28147_89_None_KeyMeshing             820\n#define OBJ_id_Gost28147_89_None_KeyMeshing             OBJ_cryptopro,14L,0L\n\n#define SN_id_GostR3411_94_TestParamSet         \"id-GostR3411-94-TestParamSet\"\n#define NID_id_GostR3411_94_TestParamSet                821\n#define OBJ_id_GostR3411_94_TestParamSet                OBJ_cryptopro,30L,0L\n\n#define SN_id_GostR3411_94_CryptoProParamSet            \"id-GostR3411-94-CryptoProParamSet\"\n#define NID_id_GostR3411_94_CryptoProParamSet           822\n#define OBJ_id_GostR3411_94_CryptoProParamSet           OBJ_cryptopro,30L,1L\n\n#define SN_id_Gost28147_89_TestParamSet         \"id-Gost28147-89-TestParamSet\"\n#define NID_id_Gost28147_89_TestParamSet                823\n#define OBJ_id_Gost28147_89_TestParamSet                OBJ_cryptopro,31L,0L\n\n#define SN_id_Gost28147_89_CryptoPro_A_ParamSet         \"id-Gost28147-89-CryptoPro-A-ParamSet\"\n#define NID_id_Gost28147_89_CryptoPro_A_ParamSet                824\n#define OBJ_id_Gost28147_89_CryptoPro_A_ParamSet                OBJ_cryptopro,31L,1L\n\n#define SN_id_Gost28147_89_CryptoPro_B_ParamSet         \"id-Gost28147-89-CryptoPro-B-ParamSet\"\n#define NID_id_Gost28147_89_CryptoPro_B_ParamSet                825\n#define OBJ_id_Gost28147_89_CryptoPro_B_ParamSet                OBJ_cryptopro,31L,2L\n\n#define SN_id_Gost28147_89_CryptoPro_C_ParamSet         \"id-Gost28147-89-CryptoPro-C-ParamSet\"\n#define NID_id_Gost28147_89_CryptoPro_C_ParamSet                826\n#define OBJ_id_Gost28147_89_CryptoPro_C_ParamSet                OBJ_cryptopro,31L,3L\n\n#define SN_id_Gost28147_89_CryptoPro_D_ParamSet         \"id-Gost28147-89-CryptoPro-D-ParamSet\"\n#define NID_id_Gost28147_89_CryptoPro_D_ParamSet                827\n#define OBJ_id_Gost28147_89_CryptoPro_D_ParamSet                OBJ_cryptopro,31L,4L\n\n#define SN_id_Gost28147_89_CryptoPro_Oscar_1_1_ParamSet         \"id-Gost28147-89-CryptoPro-Oscar-1-1-ParamSet\"\n#define NID_id_Gost28147_89_CryptoPro_Oscar_1_1_ParamSet                828\n#define OBJ_id_Gost28147_89_CryptoPro_Oscar_1_1_ParamSet                OBJ_cryptopro,31L,5L\n\n#define SN_id_Gost28147_89_CryptoPro_Oscar_1_0_ParamSet         \"id-Gost28147-89-CryptoPro-Oscar-1-0-ParamSet\"\n#define NID_id_Gost28147_89_CryptoPro_Oscar_1_0_ParamSet                829\n#define OBJ_id_Gost28147_89_CryptoPro_Oscar_1_0_ParamSet                OBJ_cryptopro,31L,6L\n\n#define SN_id_Gost28147_89_CryptoPro_RIC_1_ParamSet             \"id-Gost28147-89-CryptoPro-RIC-1-ParamSet\"\n#define NID_id_Gost28147_89_CryptoPro_RIC_1_ParamSet            830\n#define OBJ_id_Gost28147_89_CryptoPro_RIC_1_ParamSet            OBJ_cryptopro,31L,7L\n\n#define SN_id_GostR3410_94_TestParamSet         \"id-GostR3410-94-TestParamSet\"\n#define NID_id_GostR3410_94_TestParamSet                831\n#define OBJ_id_GostR3410_94_TestParamSet                OBJ_cryptopro,32L,0L\n\n#define SN_id_GostR3410_94_CryptoPro_A_ParamSet         \"id-GostR3410-94-CryptoPro-A-ParamSet\"\n#define NID_id_GostR3410_94_CryptoPro_A_ParamSet                832\n#define OBJ_id_GostR3410_94_CryptoPro_A_ParamSet                OBJ_cryptopro,32L,2L\n\n#define SN_id_GostR3410_94_CryptoPro_B_ParamSet         \"id-GostR3410-94-CryptoPro-B-ParamSet\"\n#define NID_id_GostR3410_94_CryptoPro_B_ParamSet                833\n#define OBJ_id_GostR3410_94_CryptoPro_B_ParamSet                OBJ_cryptopro,32L,3L\n\n#define SN_id_GostR3410_94_CryptoPro_C_ParamSet         \"id-GostR3410-94-CryptoPro-C-ParamSet\"\n#define NID_id_GostR3410_94_CryptoPro_C_ParamSet                834\n#define OBJ_id_GostR3410_94_CryptoPro_C_ParamSet                OBJ_cryptopro,32L,4L\n\n#define SN_id_GostR3410_94_CryptoPro_D_ParamSet         \"id-GostR3410-94-CryptoPro-D-ParamSet\"\n#define NID_id_GostR3410_94_CryptoPro_D_ParamSet                835\n#define OBJ_id_GostR3410_94_CryptoPro_D_ParamSet                OBJ_cryptopro,32L,5L\n\n#define SN_id_GostR3410_94_CryptoPro_XchA_ParamSet              \"id-GostR3410-94-CryptoPro-XchA-ParamSet\"\n#define NID_id_GostR3410_94_CryptoPro_XchA_ParamSet             836\n#define OBJ_id_GostR3410_94_CryptoPro_XchA_ParamSet             OBJ_cryptopro,33L,1L\n\n#define SN_id_GostR3410_94_CryptoPro_XchB_ParamSet              \"id-GostR3410-94-CryptoPro-XchB-ParamSet\"\n#define NID_id_GostR3410_94_CryptoPro_XchB_ParamSet             837\n#define OBJ_id_GostR3410_94_CryptoPro_XchB_ParamSet             OBJ_cryptopro,33L,2L\n\n#define SN_id_GostR3410_94_CryptoPro_XchC_ParamSet              \"id-GostR3410-94-CryptoPro-XchC-ParamSet\"\n#define NID_id_GostR3410_94_CryptoPro_XchC_ParamSet             838\n#define OBJ_id_GostR3410_94_CryptoPro_XchC_ParamSet             OBJ_cryptopro,33L,3L\n\n#define SN_id_GostR3410_2001_TestParamSet               \"id-GostR3410-2001-TestParamSet\"\n#define NID_id_GostR3410_2001_TestParamSet              839\n#define OBJ_id_GostR3410_2001_TestParamSet              OBJ_cryptopro,35L,0L\n\n#define SN_id_GostR3410_2001_CryptoPro_A_ParamSet               \"id-GostR3410-2001-CryptoPro-A-ParamSet\"\n#define NID_id_GostR3410_2001_CryptoPro_A_ParamSet              840\n#define OBJ_id_GostR3410_2001_CryptoPro_A_ParamSet              OBJ_cryptopro,35L,1L\n\n#define SN_id_GostR3410_2001_CryptoPro_B_ParamSet               \"id-GostR3410-2001-CryptoPro-B-ParamSet\"\n#define NID_id_GostR3410_2001_CryptoPro_B_ParamSet              841\n#define OBJ_id_GostR3410_2001_CryptoPro_B_ParamSet              OBJ_cryptopro,35L,2L\n\n#define SN_id_GostR3410_2001_CryptoPro_C_ParamSet               \"id-GostR3410-2001-CryptoPro-C-ParamSet\"\n#define NID_id_GostR3410_2001_CryptoPro_C_ParamSet              842\n#define OBJ_id_GostR3410_2001_CryptoPro_C_ParamSet              OBJ_cryptopro,35L,3L\n\n#define SN_id_GostR3410_2001_CryptoPro_XchA_ParamSet            \"id-GostR3410-2001-CryptoPro-XchA-ParamSet\"\n#define NID_id_GostR3410_2001_CryptoPro_XchA_ParamSet           843\n#define OBJ_id_GostR3410_2001_CryptoPro_XchA_ParamSet           OBJ_cryptopro,36L,0L\n\n#define SN_id_GostR3410_2001_CryptoPro_XchB_ParamSet            \"id-GostR3410-2001-CryptoPro-XchB-ParamSet\"\n#define NID_id_GostR3410_2001_CryptoPro_XchB_ParamSet           844\n#define OBJ_id_GostR3410_2001_CryptoPro_XchB_ParamSet           OBJ_cryptopro,36L,1L\n\n#define SN_id_GostR3410_94_a            \"id-GostR3410-94-a\"\n#define NID_id_GostR3410_94_a           845\n#define OBJ_id_GostR3410_94_a           OBJ_id_GostR3410_94,1L\n\n#define SN_id_GostR3410_94_aBis         \"id-GostR3410-94-aBis\"\n#define NID_id_GostR3410_94_aBis                846\n#define OBJ_id_GostR3410_94_aBis                OBJ_id_GostR3410_94,2L\n\n#define SN_id_GostR3410_94_b            \"id-GostR3410-94-b\"\n#define NID_id_GostR3410_94_b           847\n#define OBJ_id_GostR3410_94_b           OBJ_id_GostR3410_94,3L\n\n#define SN_id_GostR3410_94_bBis         \"id-GostR3410-94-bBis\"\n#define NID_id_GostR3410_94_bBis                848\n#define OBJ_id_GostR3410_94_bBis                OBJ_id_GostR3410_94,4L\n\n#define SN_id_Gost28147_89_cc           \"id-Gost28147-89-cc\"\n#define LN_id_Gost28147_89_cc           \"GOST 28147-89 Cryptocom ParamSet\"\n#define NID_id_Gost28147_89_cc          849\n#define OBJ_id_Gost28147_89_cc          OBJ_cryptocom,1L,6L,1L\n\n#define SN_id_GostR3410_94_cc           \"gost94cc\"\n#define LN_id_GostR3410_94_cc           \"GOST 34.10-94 Cryptocom\"\n#define NID_id_GostR3410_94_cc          850\n#define OBJ_id_GostR3410_94_cc          OBJ_cryptocom,1L,5L,3L\n\n#define SN_id_GostR3410_2001_cc         \"gost2001cc\"\n#define LN_id_GostR3410_2001_cc         \"GOST 34.10-2001 Cryptocom\"\n#define NID_id_GostR3410_2001_cc                851\n#define OBJ_id_GostR3410_2001_cc                OBJ_cryptocom,1L,5L,4L\n\n#define SN_id_GostR3411_94_with_GostR3410_94_cc         \"id-GostR3411-94-with-GostR3410-94-cc\"\n#define LN_id_GostR3411_94_with_GostR3410_94_cc         \"GOST R 34.11-94 with GOST R 34.10-94 Cryptocom\"\n#define NID_id_GostR3411_94_with_GostR3410_94_cc                852\n#define OBJ_id_GostR3411_94_with_GostR3410_94_cc                OBJ_cryptocom,1L,3L,3L\n\n#define SN_id_GostR3411_94_with_GostR3410_2001_cc               \"id-GostR3411-94-with-GostR3410-2001-cc\"\n#define LN_id_GostR3411_94_with_GostR3410_2001_cc               \"GOST R 34.11-94 with GOST R 34.10-2001 Cryptocom\"\n#define NID_id_GostR3411_94_with_GostR3410_2001_cc              853\n#define OBJ_id_GostR3411_94_with_GostR3410_2001_cc              OBJ_cryptocom,1L,3L,4L\n\n#define SN_id_GostR3410_2001_ParamSet_cc                \"id-GostR3410-2001-ParamSet-cc\"\n#define LN_id_GostR3410_2001_ParamSet_cc                \"GOST R 3410-2001 Parameter Set Cryptocom\"\n#define NID_id_GostR3410_2001_ParamSet_cc               854\n#define OBJ_id_GostR3410_2001_ParamSet_cc               OBJ_cryptocom,1L,8L,1L\n\n#define SN_camellia_128_cbc             \"CAMELLIA-128-CBC\"\n#define LN_camellia_128_cbc             \"camellia-128-cbc\"\n#define NID_camellia_128_cbc            751\n#define OBJ_camellia_128_cbc            1L,2L,392L,200011L,61L,1L,1L,1L,2L\n\n#define SN_camellia_192_cbc             \"CAMELLIA-192-CBC\"\n#define LN_camellia_192_cbc             \"camellia-192-cbc\"\n#define NID_camellia_192_cbc            752\n#define OBJ_camellia_192_cbc            1L,2L,392L,200011L,61L,1L,1L,1L,3L\n\n#define SN_camellia_256_cbc             \"CAMELLIA-256-CBC\"\n#define LN_camellia_256_cbc             \"camellia-256-cbc\"\n#define NID_camellia_256_cbc            753\n#define OBJ_camellia_256_cbc            1L,2L,392L,200011L,61L,1L,1L,1L,4L\n\n#define SN_id_camellia128_wrap          \"id-camellia128-wrap\"\n#define NID_id_camellia128_wrap         907\n#define OBJ_id_camellia128_wrap         1L,2L,392L,200011L,61L,1L,1L,3L,2L\n\n#define SN_id_camellia192_wrap          \"id-camellia192-wrap\"\n#define NID_id_camellia192_wrap         908\n#define OBJ_id_camellia192_wrap         1L,2L,392L,200011L,61L,1L,1L,3L,3L\n\n#define SN_id_camellia256_wrap          \"id-camellia256-wrap\"\n#define NID_id_camellia256_wrap         909\n#define OBJ_id_camellia256_wrap         1L,2L,392L,200011L,61L,1L,1L,3L,4L\n\n#define OBJ_ntt_ds              0L,3L,4401L,5L\n\n#define OBJ_camellia            OBJ_ntt_ds,3L,1L,9L\n\n#define SN_camellia_128_ecb             \"CAMELLIA-128-ECB\"\n#define LN_camellia_128_ecb             \"camellia-128-ecb\"\n#define NID_camellia_128_ecb            754\n#define OBJ_camellia_128_ecb            OBJ_camellia,1L\n\n#define SN_camellia_128_ofb128          \"CAMELLIA-128-OFB\"\n#define LN_camellia_128_ofb128          \"camellia-128-ofb\"\n#define NID_camellia_128_ofb128         766\n#define OBJ_camellia_128_ofb128         OBJ_camellia,3L\n\n#define SN_camellia_128_cfb128          \"CAMELLIA-128-CFB\"\n#define LN_camellia_128_cfb128          \"camellia-128-cfb\"\n#define NID_camellia_128_cfb128         757\n#define OBJ_camellia_128_cfb128         OBJ_camellia,4L\n\n#define SN_camellia_192_ecb             \"CAMELLIA-192-ECB\"\n#define LN_camellia_192_ecb             \"camellia-192-ecb\"\n#define NID_camellia_192_ecb            755\n#define OBJ_camellia_192_ecb            OBJ_camellia,21L\n\n#define SN_camellia_192_ofb128          \"CAMELLIA-192-OFB\"\n#define LN_camellia_192_ofb128          \"camellia-192-ofb\"\n#define NID_camellia_192_ofb128         767\n#define OBJ_camellia_192_ofb128         OBJ_camellia,23L\n\n#define SN_camellia_192_cfb128          \"CAMELLIA-192-CFB\"\n#define LN_camellia_192_cfb128          \"camellia-192-cfb\"\n#define NID_camellia_192_cfb128         758\n#define OBJ_camellia_192_cfb128         OBJ_camellia,24L\n\n#define SN_camellia_256_ecb             \"CAMELLIA-256-ECB\"\n#define LN_camellia_256_ecb             \"camellia-256-ecb\"\n#define NID_camellia_256_ecb            756\n#define OBJ_camellia_256_ecb            OBJ_camellia,41L\n\n#define SN_camellia_256_ofb128          \"CAMELLIA-256-OFB\"\n#define LN_camellia_256_ofb128          \"camellia-256-ofb\"\n#define NID_camellia_256_ofb128         768\n#define OBJ_camellia_256_ofb128         OBJ_camellia,43L\n\n#define SN_camellia_256_cfb128          \"CAMELLIA-256-CFB\"\n#define LN_camellia_256_cfb128          \"camellia-256-cfb\"\n#define NID_camellia_256_cfb128         759\n#define OBJ_camellia_256_cfb128         OBJ_camellia,44L\n\n#define SN_camellia_128_cfb1            \"CAMELLIA-128-CFB1\"\n#define LN_camellia_128_cfb1            \"camellia-128-cfb1\"\n#define NID_camellia_128_cfb1           760\n\n#define SN_camellia_192_cfb1            \"CAMELLIA-192-CFB1\"\n#define LN_camellia_192_cfb1            \"camellia-192-cfb1\"\n#define NID_camellia_192_cfb1           761\n\n#define SN_camellia_256_cfb1            \"CAMELLIA-256-CFB1\"\n#define LN_camellia_256_cfb1            \"camellia-256-cfb1\"\n#define NID_camellia_256_cfb1           762\n\n#define SN_camellia_128_cfb8            \"CAMELLIA-128-CFB8\"\n#define LN_camellia_128_cfb8            \"camellia-128-cfb8\"\n#define NID_camellia_128_cfb8           763\n\n#define SN_camellia_192_cfb8            \"CAMELLIA-192-CFB8\"\n#define LN_camellia_192_cfb8            \"camellia-192-cfb8\"\n#define NID_camellia_192_cfb8           764\n\n#define SN_camellia_256_cfb8            \"CAMELLIA-256-CFB8\"\n#define LN_camellia_256_cfb8            \"camellia-256-cfb8\"\n#define NID_camellia_256_cfb8           765\n\n#define SN_kisa         \"KISA\"\n#define LN_kisa         \"kisa\"\n#define NID_kisa                773\n#define OBJ_kisa                OBJ_member_body,410L,200004L\n\n#define SN_seed_ecb             \"SEED-ECB\"\n#define LN_seed_ecb             \"seed-ecb\"\n#define NID_seed_ecb            776\n#define OBJ_seed_ecb            OBJ_kisa,1L,3L\n\n#define SN_seed_cbc             \"SEED-CBC\"\n#define LN_seed_cbc             \"seed-cbc\"\n#define NID_seed_cbc            777\n#define OBJ_seed_cbc            OBJ_kisa,1L,4L\n\n#define SN_seed_cfb128          \"SEED-CFB\"\n#define LN_seed_cfb128          \"seed-cfb\"\n#define NID_seed_cfb128         779\n#define OBJ_seed_cfb128         OBJ_kisa,1L,5L\n\n#define SN_seed_ofb128          \"SEED-OFB\"\n#define LN_seed_ofb128          \"seed-ofb\"\n#define NID_seed_ofb128         778\n#define OBJ_seed_ofb128         OBJ_kisa,1L,6L\n\n#define SN_hmac         \"HMAC\"\n#define LN_hmac         \"hmac\"\n#define NID_hmac                855\n\n#define SN_cmac         \"CMAC\"\n#define LN_cmac         \"cmac\"\n#define NID_cmac                894\n\n#define SN_rc4_hmac_md5         \"RC4-HMAC-MD5\"\n#define LN_rc4_hmac_md5         \"rc4-hmac-md5\"\n#define NID_rc4_hmac_md5                915\n\n#define SN_aes_128_cbc_hmac_sha1                \"AES-128-CBC-HMAC-SHA1\"\n#define LN_aes_128_cbc_hmac_sha1                \"aes-128-cbc-hmac-sha1\"\n#define NID_aes_128_cbc_hmac_sha1               916\n\n#define SN_aes_192_cbc_hmac_sha1                \"AES-192-CBC-HMAC-SHA1\"\n#define LN_aes_192_cbc_hmac_sha1                \"aes-192-cbc-hmac-sha1\"\n#define NID_aes_192_cbc_hmac_sha1               917\n\n#define SN_aes_256_cbc_hmac_sha1                \"AES-256-CBC-HMAC-SHA1\"\n#define LN_aes_256_cbc_hmac_sha1                \"aes-256-cbc-hmac-sha1\"\n#define NID_aes_256_cbc_hmac_sha1               918\n\n#define SN_aes_128_cbc_hmac_sha256              \"AES-128-CBC-HMAC-SHA256\"\n#define LN_aes_128_cbc_hmac_sha256              \"aes-128-cbc-hmac-sha256\"\n#define NID_aes_128_cbc_hmac_sha256             948\n\n#define SN_aes_192_cbc_hmac_sha256              \"AES-192-CBC-HMAC-SHA256\"\n#define LN_aes_192_cbc_hmac_sha256              \"aes-192-cbc-hmac-sha256\"\n#define NID_aes_192_cbc_hmac_sha256             949\n\n#define SN_aes_256_cbc_hmac_sha256              \"AES-256-CBC-HMAC-SHA256\"\n#define LN_aes_256_cbc_hmac_sha256              \"aes-256-cbc-hmac-sha256\"\n#define NID_aes_256_cbc_hmac_sha256             950\n\n#define SN_dhpublicnumber               \"dhpublicnumber\"\n#define LN_dhpublicnumber               \"X9.42 DH\"\n#define NID_dhpublicnumber              920\n#define OBJ_dhpublicnumber              OBJ_ISO_US,10046L,2L,1L\n\n#define SN_brainpoolP160r1              \"brainpoolP160r1\"\n#define NID_brainpoolP160r1             921\n#define OBJ_brainpoolP160r1             1L,3L,36L,3L,3L,2L,8L,1L,1L,1L\n\n#define SN_brainpoolP160t1              \"brainpoolP160t1\"\n#define NID_brainpoolP160t1             922\n#define OBJ_brainpoolP160t1             1L,3L,36L,3L,3L,2L,8L,1L,1L,2L\n\n#define SN_brainpoolP192r1              \"brainpoolP192r1\"\n#define NID_brainpoolP192r1             923\n#define OBJ_brainpoolP192r1             1L,3L,36L,3L,3L,2L,8L,1L,1L,3L\n\n#define SN_brainpoolP192t1              \"brainpoolP192t1\"\n#define NID_brainpoolP192t1             924\n#define OBJ_brainpoolP192t1             1L,3L,36L,3L,3L,2L,8L,1L,1L,4L\n\n#define SN_brainpoolP224r1              \"brainpoolP224r1\"\n#define NID_brainpoolP224r1             925\n#define OBJ_brainpoolP224r1             1L,3L,36L,3L,3L,2L,8L,1L,1L,5L\n\n#define SN_brainpoolP224t1              \"brainpoolP224t1\"\n#define NID_brainpoolP224t1             926\n#define OBJ_brainpoolP224t1             1L,3L,36L,3L,3L,2L,8L,1L,1L,6L\n\n#define SN_brainpoolP256r1              \"brainpoolP256r1\"\n#define NID_brainpoolP256r1             927\n#define OBJ_brainpoolP256r1             1L,3L,36L,3L,3L,2L,8L,1L,1L,7L\n\n#define SN_brainpoolP256t1              \"brainpoolP256t1\"\n#define NID_brainpoolP256t1             928\n#define OBJ_brainpoolP256t1             1L,3L,36L,3L,3L,2L,8L,1L,1L,8L\n\n#define SN_brainpoolP320r1              \"brainpoolP320r1\"\n#define NID_brainpoolP320r1             929\n#define OBJ_brainpoolP320r1             1L,3L,36L,3L,3L,2L,8L,1L,1L,9L\n\n#define SN_brainpoolP320t1              \"brainpoolP320t1\"\n#define NID_brainpoolP320t1             930\n#define OBJ_brainpoolP320t1             1L,3L,36L,3L,3L,2L,8L,1L,1L,10L\n\n#define SN_brainpoolP384r1              \"brainpoolP384r1\"\n#define NID_brainpoolP384r1             931\n#define OBJ_brainpoolP384r1             1L,3L,36L,3L,3L,2L,8L,1L,1L,11L\n\n#define SN_brainpoolP384t1              \"brainpoolP384t1\"\n#define NID_brainpoolP384t1             932\n#define OBJ_brainpoolP384t1             1L,3L,36L,3L,3L,2L,8L,1L,1L,12L\n\n#define SN_brainpoolP512r1              \"brainpoolP512r1\"\n#define NID_brainpoolP512r1             933\n#define OBJ_brainpoolP512r1             1L,3L,36L,3L,3L,2L,8L,1L,1L,13L\n\n#define SN_brainpoolP512t1              \"brainpoolP512t1\"\n#define NID_brainpoolP512t1             934\n#define OBJ_brainpoolP512t1             1L,3L,36L,3L,3L,2L,8L,1L,1L,14L\n\n#define OBJ_x9_63_scheme                1L,3L,133L,16L,840L,63L,0L\n\n#define OBJ_secg_scheme         OBJ_certicom_arc,1L\n\n#define SN_dhSinglePass_stdDH_sha1kdf_scheme            \"dhSinglePass-stdDH-sha1kdf-scheme\"\n#define NID_dhSinglePass_stdDH_sha1kdf_scheme           936\n#define OBJ_dhSinglePass_stdDH_sha1kdf_scheme           OBJ_x9_63_scheme,2L\n\n#define SN_dhSinglePass_stdDH_sha224kdf_scheme          \"dhSinglePass-stdDH-sha224kdf-scheme\"\n#define NID_dhSinglePass_stdDH_sha224kdf_scheme         937\n#define OBJ_dhSinglePass_stdDH_sha224kdf_scheme         OBJ_secg_scheme,11L,0L\n\n#define SN_dhSinglePass_stdDH_sha256kdf_scheme          \"dhSinglePass-stdDH-sha256kdf-scheme\"\n#define NID_dhSinglePass_stdDH_sha256kdf_scheme         938\n#define OBJ_dhSinglePass_stdDH_sha256kdf_scheme         OBJ_secg_scheme,11L,1L\n\n#define SN_dhSinglePass_stdDH_sha384kdf_scheme          \"dhSinglePass-stdDH-sha384kdf-scheme\"\n#define NID_dhSinglePass_stdDH_sha384kdf_scheme         939\n#define OBJ_dhSinglePass_stdDH_sha384kdf_scheme         OBJ_secg_scheme,11L,2L\n\n#define SN_dhSinglePass_stdDH_sha512kdf_scheme          \"dhSinglePass-stdDH-sha512kdf-scheme\"\n#define NID_dhSinglePass_stdDH_sha512kdf_scheme         940\n#define OBJ_dhSinglePass_stdDH_sha512kdf_scheme         OBJ_secg_scheme,11L,3L\n\n#define SN_dhSinglePass_cofactorDH_sha1kdf_scheme               \"dhSinglePass-cofactorDH-sha1kdf-scheme\"\n#define NID_dhSinglePass_cofactorDH_sha1kdf_scheme              941\n#define OBJ_dhSinglePass_cofactorDH_sha1kdf_scheme              OBJ_x9_63_scheme,3L\n\n#define SN_dhSinglePass_cofactorDH_sha224kdf_scheme             \"dhSinglePass-cofactorDH-sha224kdf-scheme\"\n#define NID_dhSinglePass_cofactorDH_sha224kdf_scheme            942\n#define OBJ_dhSinglePass_cofactorDH_sha224kdf_scheme            OBJ_secg_scheme,14L,0L\n\n#define SN_dhSinglePass_cofactorDH_sha256kdf_scheme             \"dhSinglePass-cofactorDH-sha256kdf-scheme\"\n#define NID_dhSinglePass_cofactorDH_sha256kdf_scheme            943\n#define OBJ_dhSinglePass_cofactorDH_sha256kdf_scheme            OBJ_secg_scheme,14L,1L\n\n#define SN_dhSinglePass_cofactorDH_sha384kdf_scheme             \"dhSinglePass-cofactorDH-sha384kdf-scheme\"\n#define NID_dhSinglePass_cofactorDH_sha384kdf_scheme            944\n#define OBJ_dhSinglePass_cofactorDH_sha384kdf_scheme            OBJ_secg_scheme,14L,2L\n\n#define SN_dhSinglePass_cofactorDH_sha512kdf_scheme             \"dhSinglePass-cofactorDH-sha512kdf-scheme\"\n#define NID_dhSinglePass_cofactorDH_sha512kdf_scheme            945\n#define OBJ_dhSinglePass_cofactorDH_sha512kdf_scheme            OBJ_secg_scheme,14L,3L\n\n#define SN_dh_std_kdf           \"dh-std-kdf\"\n#define NID_dh_std_kdf          946\n\n#define SN_dh_cofactor_kdf              \"dh-cofactor-kdf\"\n#define NID_dh_cofactor_kdf             947\n\n#define SN_ct_precert_scts              \"ct_precert_scts\"\n#define LN_ct_precert_scts              \"CT Precertificate SCTs\"\n#define NID_ct_precert_scts             951\n#define OBJ_ct_precert_scts             1L,3L,6L,1L,4L,1L,11129L,2L,4L,2L\n\n#define SN_ct_precert_poison            \"ct_precert_poison\"\n#define LN_ct_precert_poison            \"CT Precertificate Poison\"\n#define NID_ct_precert_poison           952\n#define OBJ_ct_precert_poison           1L,3L,6L,1L,4L,1L,11129L,2L,4L,3L\n\n#define SN_ct_precert_signer            \"ct_precert_signer\"\n#define LN_ct_precert_signer            \"CT Precertificate Signer\"\n#define NID_ct_precert_signer           953\n#define OBJ_ct_precert_signer           1L,3L,6L,1L,4L,1L,11129L,2L,4L,4L\n\n#define SN_ct_cert_scts         \"ct_cert_scts\"\n#define LN_ct_cert_scts         \"CT Certificate SCTs\"\n#define NID_ct_cert_scts                954\n#define OBJ_ct_cert_scts                1L,3L,6L,1L,4L,1L,11129L,2L,4L,5L\n\n#define SN_jurisdictionLocalityName             \"jurisdictionL\"\n#define LN_jurisdictionLocalityName             \"jurisdictionLocalityName\"\n#define NID_jurisdictionLocalityName            955\n#define OBJ_jurisdictionLocalityName            1L,3L,6L,1L,4L,1L,311L,60L,2L,1L,1L\n\n#define SN_jurisdictionStateOrProvinceName              \"jurisdictionST\"\n#define LN_jurisdictionStateOrProvinceName              \"jurisdictionStateOrProvinceName\"\n#define NID_jurisdictionStateOrProvinceName             956\n#define OBJ_jurisdictionStateOrProvinceName             1L,3L,6L,1L,4L,1L,311L,60L,2L,1L,2L\n\n#define SN_jurisdictionCountryName              \"jurisdictionC\"\n#define LN_jurisdictionCountryName              \"jurisdictionCountryName\"\n#define NID_jurisdictionCountryName             957\n#define OBJ_jurisdictionCountryName             1L,3L,6L,1L,4L,1L,311L,60L,2L,1L,3L\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/x86_64/include/openssl/objects.h",
    "content": "/* crypto/objects/objects.h */\n/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)\n * All rights reserved.\n *\n * This package is an SSL implementation written\n * by Eric Young (eay@cryptsoft.com).\n * The implementation was written so as to conform with Netscapes SSL.\n *\n * This library is free for commercial and non-commercial use as long as\n * the following conditions are aheared to.  The following conditions\n * apply to all code found in this distribution, be it the RC4, RSA,\n * lhash, DES, etc., code; not just the SSL code.  The SSL documentation\n * included with this distribution is covered by the same copyright terms\n * except that the holder is Tim Hudson (tjh@cryptsoft.com).\n *\n * Copyright remains Eric Young's, and as such any Copyright notices in\n * the code are not to be removed.\n * If this package is used in a product, Eric Young should be given attribution\n * as the author of the parts of the library used.\n * This can be in the form of a textual message at program startup or\n * in documentation (online or textual) provided with the package.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the copyright\n *    notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in the\n *    documentation and/or other materials provided with the distribution.\n * 3. All advertising materials mentioning features or use of this software\n *    must display the following acknowledgement:\n *    \"This product includes cryptographic software written by\n *     Eric Young (eay@cryptsoft.com)\"\n *    The word 'cryptographic' can be left out if the rouines from the library\n *    being used are not cryptographic related :-).\n * 4. If you include any Windows specific code (or a derivative thereof) from\n *    the apps directory (application code) you must include an acknowledgement:\n *    \"This product includes software written by Tim Hudson (tjh@cryptsoft.com)\"\n *\n * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n * SUCH DAMAGE.\n *\n * The licence and distribution terms for any publically available version or\n * derivative of this code cannot be changed.  i.e. this code cannot simply be\n * copied and put under another distribution licence\n * [including the GNU Public Licence.]\n */\n\n#ifndef HEADER_OBJECTS_H\n# define HEADER_OBJECTS_H\n\n# define USE_OBJ_MAC\n\n# ifdef USE_OBJ_MAC\n#  include <openssl/obj_mac.h>\n# else\n#  define SN_undef                        \"UNDEF\"\n#  define LN_undef                        \"undefined\"\n#  define NID_undef                       0\n#  define OBJ_undef                       0L\n\n#  define SN_Algorithm                    \"Algorithm\"\n#  define LN_algorithm                    \"algorithm\"\n#  define NID_algorithm                   38\n#  define OBJ_algorithm                   1L,3L,14L,3L,2L\n\n#  define LN_rsadsi                       \"rsadsi\"\n#  define NID_rsadsi                      1\n#  define OBJ_rsadsi                      1L,2L,840L,113549L\n\n#  define LN_pkcs                         \"pkcs\"\n#  define NID_pkcs                        2\n#  define OBJ_pkcs                        OBJ_rsadsi,1L\n\n#  define SN_md2                          \"MD2\"\n#  define LN_md2                          \"md2\"\n#  define NID_md2                         3\n#  define OBJ_md2                         OBJ_rsadsi,2L,2L\n\n#  define SN_md5                          \"MD5\"\n#  define LN_md5                          \"md5\"\n#  define NID_md5                         4\n#  define OBJ_md5                         OBJ_rsadsi,2L,5L\n\n#  define SN_rc4                          \"RC4\"\n#  define LN_rc4                          \"rc4\"\n#  define NID_rc4                         5\n#  define OBJ_rc4                         OBJ_rsadsi,3L,4L\n\n#  define LN_rsaEncryption                \"rsaEncryption\"\n#  define NID_rsaEncryption               6\n#  define OBJ_rsaEncryption               OBJ_pkcs,1L,1L\n\n#  define SN_md2WithRSAEncryption         \"RSA-MD2\"\n#  define LN_md2WithRSAEncryption         \"md2WithRSAEncryption\"\n#  define NID_md2WithRSAEncryption        7\n#  define OBJ_md2WithRSAEncryption        OBJ_pkcs,1L,2L\n\n#  define SN_md5WithRSAEncryption         \"RSA-MD5\"\n#  define LN_md5WithRSAEncryption         \"md5WithRSAEncryption\"\n#  define NID_md5WithRSAEncryption        8\n#  define OBJ_md5WithRSAEncryption        OBJ_pkcs,1L,4L\n\n#  define SN_pbeWithMD2AndDES_CBC         \"PBE-MD2-DES\"\n#  define LN_pbeWithMD2AndDES_CBC         \"pbeWithMD2AndDES-CBC\"\n#  define NID_pbeWithMD2AndDES_CBC        9\n#  define OBJ_pbeWithMD2AndDES_CBC        OBJ_pkcs,5L,1L\n\n#  define SN_pbeWithMD5AndDES_CBC         \"PBE-MD5-DES\"\n#  define LN_pbeWithMD5AndDES_CBC         \"pbeWithMD5AndDES-CBC\"\n#  define NID_pbeWithMD5AndDES_CBC        10\n#  define OBJ_pbeWithMD5AndDES_CBC        OBJ_pkcs,5L,3L\n\n#  define LN_X500                         \"X500\"\n#  define NID_X500                        11\n#  define OBJ_X500                        2L,5L\n\n#  define LN_X509                         \"X509\"\n#  define NID_X509                        12\n#  define OBJ_X509                        OBJ_X500,4L\n\n#  define SN_commonName                   \"CN\"\n#  define LN_commonName                   \"commonName\"\n#  define NID_commonName                  13\n#  define OBJ_commonName                  OBJ_X509,3L\n\n#  define SN_countryName                  \"C\"\n#  define LN_countryName                  \"countryName\"\n#  define NID_countryName                 14\n#  define OBJ_countryName                 OBJ_X509,6L\n\n#  define SN_localityName                 \"L\"\n#  define LN_localityName                 \"localityName\"\n#  define NID_localityName                15\n#  define OBJ_localityName                OBJ_X509,7L\n\n/* Postal Address? PA */\n\n/* should be \"ST\" (rfc1327) but MS uses 'S' */\n#  define SN_stateOrProvinceName          \"ST\"\n#  define LN_stateOrProvinceName          \"stateOrProvinceName\"\n#  define NID_stateOrProvinceName         16\n#  define OBJ_stateOrProvinceName         OBJ_X509,8L\n\n#  define SN_organizationName             \"O\"\n#  define LN_organizationName             \"organizationName\"\n#  define NID_organizationName            17\n#  define OBJ_organizationName            OBJ_X509,10L\n\n#  define SN_organizationalUnitName       \"OU\"\n#  define LN_organizationalUnitName       \"organizationalUnitName\"\n#  define NID_organizationalUnitName      18\n#  define OBJ_organizationalUnitName      OBJ_X509,11L\n\n#  define SN_rsa                          \"RSA\"\n#  define LN_rsa                          \"rsa\"\n#  define NID_rsa                         19\n#  define OBJ_rsa                         OBJ_X500,8L,1L,1L\n\n#  define LN_pkcs7                        \"pkcs7\"\n#  define NID_pkcs7                       20\n#  define OBJ_pkcs7                       OBJ_pkcs,7L\n\n#  define LN_pkcs7_data                   \"pkcs7-data\"\n#  define NID_pkcs7_data                  21\n#  define OBJ_pkcs7_data                  OBJ_pkcs7,1L\n\n#  define LN_pkcs7_signed                 \"pkcs7-signedData\"\n#  define NID_pkcs7_signed                22\n#  define OBJ_pkcs7_signed                OBJ_pkcs7,2L\n\n#  define LN_pkcs7_enveloped              \"pkcs7-envelopedData\"\n#  define NID_pkcs7_enveloped             23\n#  define OBJ_pkcs7_enveloped             OBJ_pkcs7,3L\n\n#  define LN_pkcs7_signedAndEnveloped     \"pkcs7-signedAndEnvelopedData\"\n#  define NID_pkcs7_signedAndEnveloped    24\n#  define OBJ_pkcs7_signedAndEnveloped    OBJ_pkcs7,4L\n\n#  define LN_pkcs7_digest                 \"pkcs7-digestData\"\n#  define NID_pkcs7_digest                25\n#  define OBJ_pkcs7_digest                OBJ_pkcs7,5L\n\n#  define LN_pkcs7_encrypted              \"pkcs7-encryptedData\"\n#  define NID_pkcs7_encrypted             26\n#  define OBJ_pkcs7_encrypted             OBJ_pkcs7,6L\n\n#  define LN_pkcs3                        \"pkcs3\"\n#  define NID_pkcs3                       27\n#  define OBJ_pkcs3                       OBJ_pkcs,3L\n\n#  define LN_dhKeyAgreement               \"dhKeyAgreement\"\n#  define NID_dhKeyAgreement              28\n#  define OBJ_dhKeyAgreement              OBJ_pkcs3,1L\n\n#  define SN_des_ecb                      \"DES-ECB\"\n#  define LN_des_ecb                      \"des-ecb\"\n#  define NID_des_ecb                     29\n#  define OBJ_des_ecb                     OBJ_algorithm,6L\n\n#  define SN_des_cfb64                    \"DES-CFB\"\n#  define LN_des_cfb64                    \"des-cfb\"\n#  define NID_des_cfb64                   30\n/* IV + num */\n#  define OBJ_des_cfb64                   OBJ_algorithm,9L\n\n#  define SN_des_cbc                      \"DES-CBC\"\n#  define LN_des_cbc                      \"des-cbc\"\n#  define NID_des_cbc                     31\n/* IV */\n#  define OBJ_des_cbc                     OBJ_algorithm,7L\n\n#  define SN_des_ede                      \"DES-EDE\"\n#  define LN_des_ede                      \"des-ede\"\n#  define NID_des_ede                     32\n/* ?? */\n#  define OBJ_des_ede                     OBJ_algorithm,17L\n\n#  define SN_des_ede3                     \"DES-EDE3\"\n#  define LN_des_ede3                     \"des-ede3\"\n#  define NID_des_ede3                    33\n\n#  define SN_idea_cbc                     \"IDEA-CBC\"\n#  define LN_idea_cbc                     \"idea-cbc\"\n#  define NID_idea_cbc                    34\n#  define OBJ_idea_cbc                    1L,3L,6L,1L,4L,1L,188L,7L,1L,1L,2L\n\n#  define SN_idea_cfb64                   \"IDEA-CFB\"\n#  define LN_idea_cfb64                   \"idea-cfb\"\n#  define NID_idea_cfb64                  35\n\n#  define SN_idea_ecb                     \"IDEA-ECB\"\n#  define LN_idea_ecb                     \"idea-ecb\"\n#  define NID_idea_ecb                    36\n\n#  define SN_rc2_cbc                      \"RC2-CBC\"\n#  define LN_rc2_cbc                      \"rc2-cbc\"\n#  define NID_rc2_cbc                     37\n#  define OBJ_rc2_cbc                     OBJ_rsadsi,3L,2L\n\n#  define SN_rc2_ecb                      \"RC2-ECB\"\n#  define LN_rc2_ecb                      \"rc2-ecb\"\n#  define NID_rc2_ecb                     38\n\n#  define SN_rc2_cfb64                    \"RC2-CFB\"\n#  define LN_rc2_cfb64                    \"rc2-cfb\"\n#  define NID_rc2_cfb64                   39\n\n#  define SN_rc2_ofb64                    \"RC2-OFB\"\n#  define LN_rc2_ofb64                    \"rc2-ofb\"\n#  define NID_rc2_ofb64                   40\n\n#  define SN_sha                          \"SHA\"\n#  define LN_sha                          \"sha\"\n#  define NID_sha                         41\n#  define OBJ_sha                         OBJ_algorithm,18L\n\n#  define SN_shaWithRSAEncryption         \"RSA-SHA\"\n#  define LN_shaWithRSAEncryption         \"shaWithRSAEncryption\"\n#  define NID_shaWithRSAEncryption        42\n#  define OBJ_shaWithRSAEncryption        OBJ_algorithm,15L\n\n#  define SN_des_ede_cbc                  \"DES-EDE-CBC\"\n#  define LN_des_ede_cbc                  \"des-ede-cbc\"\n#  define NID_des_ede_cbc                 43\n\n#  define SN_des_ede3_cbc                 \"DES-EDE3-CBC\"\n#  define LN_des_ede3_cbc                 \"des-ede3-cbc\"\n#  define NID_des_ede3_cbc                44\n#  define OBJ_des_ede3_cbc                OBJ_rsadsi,3L,7L\n\n#  define SN_des_ofb64                    \"DES-OFB\"\n#  define LN_des_ofb64                    \"des-ofb\"\n#  define NID_des_ofb64                   45\n#  define OBJ_des_ofb64                   OBJ_algorithm,8L\n\n#  define SN_idea_ofb64                   \"IDEA-OFB\"\n#  define LN_idea_ofb64                   \"idea-ofb\"\n#  define NID_idea_ofb64                  46\n\n#  define LN_pkcs9                        \"pkcs9\"\n#  define NID_pkcs9                       47\n#  define OBJ_pkcs9                       OBJ_pkcs,9L\n\n#  define SN_pkcs9_emailAddress           \"Email\"\n#  define LN_pkcs9_emailAddress           \"emailAddress\"\n#  define NID_pkcs9_emailAddress          48\n#  define OBJ_pkcs9_emailAddress          OBJ_pkcs9,1L\n\n#  define LN_pkcs9_unstructuredName       \"unstructuredName\"\n#  define NID_pkcs9_unstructuredName      49\n#  define OBJ_pkcs9_unstructuredName      OBJ_pkcs9,2L\n\n#  define LN_pkcs9_contentType            \"contentType\"\n#  define NID_pkcs9_contentType           50\n#  define OBJ_pkcs9_contentType           OBJ_pkcs9,3L\n\n#  define LN_pkcs9_messageDigest          \"messageDigest\"\n#  define NID_pkcs9_messageDigest         51\n#  define OBJ_pkcs9_messageDigest         OBJ_pkcs9,4L\n\n#  define LN_pkcs9_signingTime            \"signingTime\"\n#  define NID_pkcs9_signingTime           52\n#  define OBJ_pkcs9_signingTime           OBJ_pkcs9,5L\n\n#  define LN_pkcs9_countersignature       \"countersignature\"\n#  define NID_pkcs9_countersignature      53\n#  define OBJ_pkcs9_countersignature      OBJ_pkcs9,6L\n\n#  define LN_pkcs9_challengePassword      \"challengePassword\"\n#  define NID_pkcs9_challengePassword     54\n#  define OBJ_pkcs9_challengePassword     OBJ_pkcs9,7L\n\n#  define LN_pkcs9_unstructuredAddress    \"unstructuredAddress\"\n#  define NID_pkcs9_unstructuredAddress   55\n#  define OBJ_pkcs9_unstructuredAddress   OBJ_pkcs9,8L\n\n#  define LN_pkcs9_extCertAttributes      \"extendedCertificateAttributes\"\n#  define NID_pkcs9_extCertAttributes     56\n#  define OBJ_pkcs9_extCertAttributes     OBJ_pkcs9,9L\n\n#  define SN_netscape                     \"Netscape\"\n#  define LN_netscape                     \"Netscape Communications Corp.\"\n#  define NID_netscape                    57\n#  define OBJ_netscape                    2L,16L,840L,1L,113730L\n\n#  define SN_netscape_cert_extension      \"nsCertExt\"\n#  define LN_netscape_cert_extension      \"Netscape Certificate Extension\"\n#  define NID_netscape_cert_extension     58\n#  define OBJ_netscape_cert_extension     OBJ_netscape,1L\n\n#  define SN_netscape_data_type           \"nsDataType\"\n#  define LN_netscape_data_type           \"Netscape Data Type\"\n#  define NID_netscape_data_type          59\n#  define OBJ_netscape_data_type          OBJ_netscape,2L\n\n#  define SN_des_ede_cfb64                \"DES-EDE-CFB\"\n#  define LN_des_ede_cfb64                \"des-ede-cfb\"\n#  define NID_des_ede_cfb64               60\n\n#  define SN_des_ede3_cfb64               \"DES-EDE3-CFB\"\n#  define LN_des_ede3_cfb64               \"des-ede3-cfb\"\n#  define NID_des_ede3_cfb64              61\n\n#  define SN_des_ede_ofb64                \"DES-EDE-OFB\"\n#  define LN_des_ede_ofb64                \"des-ede-ofb\"\n#  define NID_des_ede_ofb64               62\n\n#  define SN_des_ede3_ofb64               \"DES-EDE3-OFB\"\n#  define LN_des_ede3_ofb64               \"des-ede3-ofb\"\n#  define NID_des_ede3_ofb64              63\n\n/* I'm not sure about the object ID */\n#  define SN_sha1                         \"SHA1\"\n#  define LN_sha1                         \"sha1\"\n#  define NID_sha1                        64\n#  define OBJ_sha1                        OBJ_algorithm,26L\n/* 28 Jun 1996 - eay */\n/* #define OBJ_sha1                     1L,3L,14L,2L,26L,05L <- wrong */\n\n#  define SN_sha1WithRSAEncryption        \"RSA-SHA1\"\n#  define LN_sha1WithRSAEncryption        \"sha1WithRSAEncryption\"\n#  define NID_sha1WithRSAEncryption       65\n#  define OBJ_sha1WithRSAEncryption       OBJ_pkcs,1L,5L\n\n#  define SN_dsaWithSHA                   \"DSA-SHA\"\n#  define LN_dsaWithSHA                   \"dsaWithSHA\"\n#  define NID_dsaWithSHA                  66\n#  define OBJ_dsaWithSHA                  OBJ_algorithm,13L\n\n#  define SN_dsa_2                        \"DSA-old\"\n#  define LN_dsa_2                        \"dsaEncryption-old\"\n#  define NID_dsa_2                       67\n#  define OBJ_dsa_2                       OBJ_algorithm,12L\n\n/* proposed by microsoft to RSA */\n#  define SN_pbeWithSHA1AndRC2_CBC        \"PBE-SHA1-RC2-64\"\n#  define LN_pbeWithSHA1AndRC2_CBC        \"pbeWithSHA1AndRC2-CBC\"\n#  define NID_pbeWithSHA1AndRC2_CBC       68\n#  define OBJ_pbeWithSHA1AndRC2_CBC       OBJ_pkcs,5L,11L\n\n/*\n * proposed by microsoft to RSA as pbeWithSHA1AndRC4: it is now defined\n * explicitly in PKCS#5 v2.0 as id-PBKDF2 which is something completely\n * different.\n */\n#  define LN_id_pbkdf2                    \"PBKDF2\"\n#  define NID_id_pbkdf2                   69\n#  define OBJ_id_pbkdf2                   OBJ_pkcs,5L,12L\n\n#  define SN_dsaWithSHA1_2                \"DSA-SHA1-old\"\n#  define LN_dsaWithSHA1_2                \"dsaWithSHA1-old\"\n#  define NID_dsaWithSHA1_2               70\n/* Got this one from 'sdn706r20.pdf' which is actually an NSA document :-) */\n#  define OBJ_dsaWithSHA1_2               OBJ_algorithm,27L\n\n#  define SN_netscape_cert_type           \"nsCertType\"\n#  define LN_netscape_cert_type           \"Netscape Cert Type\"\n#  define NID_netscape_cert_type          71\n#  define OBJ_netscape_cert_type          OBJ_netscape_cert_extension,1L\n\n#  define SN_netscape_base_url            \"nsBaseUrl\"\n#  define LN_netscape_base_url            \"Netscape Base Url\"\n#  define NID_netscape_base_url           72\n#  define OBJ_netscape_base_url           OBJ_netscape_cert_extension,2L\n\n#  define SN_netscape_revocation_url      \"nsRevocationUrl\"\n#  define LN_netscape_revocation_url      \"Netscape Revocation Url\"\n#  define NID_netscape_revocation_url     73\n#  define OBJ_netscape_revocation_url     OBJ_netscape_cert_extension,3L\n\n#  define SN_netscape_ca_revocation_url   \"nsCaRevocationUrl\"\n#  define LN_netscape_ca_revocation_url   \"Netscape CA Revocation Url\"\n#  define NID_netscape_ca_revocation_url  74\n#  define OBJ_netscape_ca_revocation_url  OBJ_netscape_cert_extension,4L\n\n#  define SN_netscape_renewal_url         \"nsRenewalUrl\"\n#  define LN_netscape_renewal_url         \"Netscape Renewal Url\"\n#  define NID_netscape_renewal_url        75\n#  define OBJ_netscape_renewal_url        OBJ_netscape_cert_extension,7L\n\n#  define SN_netscape_ca_policy_url       \"nsCaPolicyUrl\"\n#  define LN_netscape_ca_policy_url       \"Netscape CA Policy Url\"\n#  define NID_netscape_ca_policy_url      76\n#  define OBJ_netscape_ca_policy_url      OBJ_netscape_cert_extension,8L\n\n#  define SN_netscape_ssl_server_name     \"nsSslServerName\"\n#  define LN_netscape_ssl_server_name     \"Netscape SSL Server Name\"\n#  define NID_netscape_ssl_server_name    77\n#  define OBJ_netscape_ssl_server_name    OBJ_netscape_cert_extension,12L\n\n#  define SN_netscape_comment             \"nsComment\"\n#  define LN_netscape_comment             \"Netscape Comment\"\n#  define NID_netscape_comment            78\n#  define OBJ_netscape_comment            OBJ_netscape_cert_extension,13L\n\n#  define SN_netscape_cert_sequence       \"nsCertSequence\"\n#  define LN_netscape_cert_sequence       \"Netscape Certificate Sequence\"\n#  define NID_netscape_cert_sequence      79\n#  define OBJ_netscape_cert_sequence      OBJ_netscape_data_type,5L\n\n#  define SN_desx_cbc                     \"DESX-CBC\"\n#  define LN_desx_cbc                     \"desx-cbc\"\n#  define NID_desx_cbc                    80\n\n#  define SN_id_ce                        \"id-ce\"\n#  define NID_id_ce                       81\n#  define OBJ_id_ce                       2L,5L,29L\n\n#  define SN_subject_key_identifier       \"subjectKeyIdentifier\"\n#  define LN_subject_key_identifier       \"X509v3 Subject Key Identifier\"\n#  define NID_subject_key_identifier      82\n#  define OBJ_subject_key_identifier      OBJ_id_ce,14L\n\n#  define SN_key_usage                    \"keyUsage\"\n#  define LN_key_usage                    \"X509v3 Key Usage\"\n#  define NID_key_usage                   83\n#  define OBJ_key_usage                   OBJ_id_ce,15L\n\n#  define SN_private_key_usage_period     \"privateKeyUsagePeriod\"\n#  define LN_private_key_usage_period     \"X509v3 Private Key Usage Period\"\n#  define NID_private_key_usage_period    84\n#  define OBJ_private_key_usage_period    OBJ_id_ce,16L\n\n#  define SN_subject_alt_name             \"subjectAltName\"\n#  define LN_subject_alt_name             \"X509v3 Subject Alternative Name\"\n#  define NID_subject_alt_name            85\n#  define OBJ_subject_alt_name            OBJ_id_ce,17L\n\n#  define SN_issuer_alt_name              \"issuerAltName\"\n#  define LN_issuer_alt_name              \"X509v3 Issuer Alternative Name\"\n#  define NID_issuer_alt_name             86\n#  define OBJ_issuer_alt_name             OBJ_id_ce,18L\n\n#  define SN_basic_constraints            \"basicConstraints\"\n#  define LN_basic_constraints            \"X509v3 Basic Constraints\"\n#  define NID_basic_constraints           87\n#  define OBJ_basic_constraints           OBJ_id_ce,19L\n\n#  define SN_crl_number                   \"crlNumber\"\n#  define LN_crl_number                   \"X509v3 CRL Number\"\n#  define NID_crl_number                  88\n#  define OBJ_crl_number                  OBJ_id_ce,20L\n\n#  define SN_certificate_policies         \"certificatePolicies\"\n#  define LN_certificate_policies         \"X509v3 Certificate Policies\"\n#  define NID_certificate_policies        89\n#  define OBJ_certificate_policies        OBJ_id_ce,32L\n\n#  define SN_authority_key_identifier     \"authorityKeyIdentifier\"\n#  define LN_authority_key_identifier     \"X509v3 Authority Key Identifier\"\n#  define NID_authority_key_identifier    90\n#  define OBJ_authority_key_identifier    OBJ_id_ce,35L\n\n#  define SN_bf_cbc                       \"BF-CBC\"\n#  define LN_bf_cbc                       \"bf-cbc\"\n#  define NID_bf_cbc                      91\n#  define OBJ_bf_cbc                      1L,3L,6L,1L,4L,1L,3029L,1L,2L\n\n#  define SN_bf_ecb                       \"BF-ECB\"\n#  define LN_bf_ecb                       \"bf-ecb\"\n#  define NID_bf_ecb                      92\n\n#  define SN_bf_cfb64                     \"BF-CFB\"\n#  define LN_bf_cfb64                     \"bf-cfb\"\n#  define NID_bf_cfb64                    93\n\n#  define SN_bf_ofb64                     \"BF-OFB\"\n#  define LN_bf_ofb64                     \"bf-ofb\"\n#  define NID_bf_ofb64                    94\n\n#  define SN_mdc2                         \"MDC2\"\n#  define LN_mdc2                         \"mdc2\"\n#  define NID_mdc2                        95\n#  define OBJ_mdc2                        2L,5L,8L,3L,101L\n/* An alternative?                      1L,3L,14L,3L,2L,19L */\n\n#  define SN_mdc2WithRSA                  \"RSA-MDC2\"\n#  define LN_mdc2WithRSA                  \"mdc2withRSA\"\n#  define NID_mdc2WithRSA                 96\n#  define OBJ_mdc2WithRSA                 2L,5L,8L,3L,100L\n\n#  define SN_rc4_40                       \"RC4-40\"\n#  define LN_rc4_40                       \"rc4-40\"\n#  define NID_rc4_40                      97\n\n#  define SN_rc2_40_cbc                   \"RC2-40-CBC\"\n#  define LN_rc2_40_cbc                   \"rc2-40-cbc\"\n#  define NID_rc2_40_cbc                  98\n\n#  define SN_givenName                    \"G\"\n#  define LN_givenName                    \"givenName\"\n#  define NID_givenName                   99\n#  define OBJ_givenName                   OBJ_X509,42L\n\n#  define SN_surname                      \"S\"\n#  define LN_surname                      \"surname\"\n#  define NID_surname                     100\n#  define OBJ_surname                     OBJ_X509,4L\n\n#  define SN_initials                     \"I\"\n#  define LN_initials                     \"initials\"\n#  define NID_initials                    101\n#  define OBJ_initials                    OBJ_X509,43L\n\n#  define SN_uniqueIdentifier             \"UID\"\n#  define LN_uniqueIdentifier             \"uniqueIdentifier\"\n#  define NID_uniqueIdentifier            102\n#  define OBJ_uniqueIdentifier            OBJ_X509,45L\n\n#  define SN_crl_distribution_points      \"crlDistributionPoints\"\n#  define LN_crl_distribution_points      \"X509v3 CRL Distribution Points\"\n#  define NID_crl_distribution_points     103\n#  define OBJ_crl_distribution_points     OBJ_id_ce,31L\n\n#  define SN_md5WithRSA                   \"RSA-NP-MD5\"\n#  define LN_md5WithRSA                   \"md5WithRSA\"\n#  define NID_md5WithRSA                  104\n#  define OBJ_md5WithRSA                  OBJ_algorithm,3L\n\n#  define SN_serialNumber                 \"SN\"\n#  define LN_serialNumber                 \"serialNumber\"\n#  define NID_serialNumber                105\n#  define OBJ_serialNumber                OBJ_X509,5L\n\n#  define SN_title                        \"T\"\n#  define LN_title                        \"title\"\n#  define NID_title                       106\n#  define OBJ_title                       OBJ_X509,12L\n\n#  define SN_description                  \"D\"\n#  define LN_description                  \"description\"\n#  define NID_description                 107\n#  define OBJ_description                 OBJ_X509,13L\n\n/* CAST5 is CAST-128, I'm just sticking with the documentation */\n#  define SN_cast5_cbc                    \"CAST5-CBC\"\n#  define LN_cast5_cbc                    \"cast5-cbc\"\n#  define NID_cast5_cbc                   108\n#  define OBJ_cast5_cbc                   1L,2L,840L,113533L,7L,66L,10L\n\n#  define SN_cast5_ecb                    \"CAST5-ECB\"\n#  define LN_cast5_ecb                    \"cast5-ecb\"\n#  define NID_cast5_ecb                   109\n\n#  define SN_cast5_cfb64                  \"CAST5-CFB\"\n#  define LN_cast5_cfb64                  \"cast5-cfb\"\n#  define NID_cast5_cfb64                 110\n\n#  define SN_cast5_ofb64                  \"CAST5-OFB\"\n#  define LN_cast5_ofb64                  \"cast5-ofb\"\n#  define NID_cast5_ofb64                 111\n\n#  define LN_pbeWithMD5AndCast5_CBC       \"pbeWithMD5AndCast5CBC\"\n#  define NID_pbeWithMD5AndCast5_CBC      112\n#  define OBJ_pbeWithMD5AndCast5_CBC      1L,2L,840L,113533L,7L,66L,12L\n\n/*-\n * This is one sun will soon be using :-(\n * id-dsa-with-sha1 ID  ::= {\n *   iso(1) member-body(2) us(840) x9-57 (10040) x9cm(4) 3 }\n */\n#  define SN_dsaWithSHA1                  \"DSA-SHA1\"\n#  define LN_dsaWithSHA1                  \"dsaWithSHA1\"\n#  define NID_dsaWithSHA1                 113\n#  define OBJ_dsaWithSHA1                 1L,2L,840L,10040L,4L,3L\n\n#  define NID_md5_sha1                    114\n#  define SN_md5_sha1                     \"MD5-SHA1\"\n#  define LN_md5_sha1                     \"md5-sha1\"\n\n#  define SN_sha1WithRSA                  \"RSA-SHA1-2\"\n#  define LN_sha1WithRSA                  \"sha1WithRSA\"\n#  define NID_sha1WithRSA                 115\n#  define OBJ_sha1WithRSA                 OBJ_algorithm,29L\n\n#  define SN_dsa                          \"DSA\"\n#  define LN_dsa                          \"dsaEncryption\"\n#  define NID_dsa                         116\n#  define OBJ_dsa                         1L,2L,840L,10040L,4L,1L\n\n#  define SN_ripemd160                    \"RIPEMD160\"\n#  define LN_ripemd160                    \"ripemd160\"\n#  define NID_ripemd160                   117\n#  define OBJ_ripemd160                   1L,3L,36L,3L,2L,1L\n\n/*\n * The name should actually be rsaSignatureWithripemd160, but I'm going to\n * continue using the convention I'm using with the other ciphers\n */\n#  define SN_ripemd160WithRSA             \"RSA-RIPEMD160\"\n#  define LN_ripemd160WithRSA             \"ripemd160WithRSA\"\n#  define NID_ripemd160WithRSA            119\n#  define OBJ_ripemd160WithRSA            1L,3L,36L,3L,3L,1L,2L\n\n/*-\n * Taken from rfc2040\n *  RC5_CBC_Parameters ::= SEQUENCE {\n *      version           INTEGER (v1_0(16)),\n *      rounds            INTEGER (8..127),\n *      blockSizeInBits   INTEGER (64, 128),\n *      iv                OCTET STRING OPTIONAL\n *      }\n */\n#  define SN_rc5_cbc                      \"RC5-CBC\"\n#  define LN_rc5_cbc                      \"rc5-cbc\"\n#  define NID_rc5_cbc                     120\n#  define OBJ_rc5_cbc                     OBJ_rsadsi,3L,8L\n\n#  define SN_rc5_ecb                      \"RC5-ECB\"\n#  define LN_rc5_ecb                      \"rc5-ecb\"\n#  define NID_rc5_ecb                     121\n\n#  define SN_rc5_cfb64                    \"RC5-CFB\"\n#  define LN_rc5_cfb64                    \"rc5-cfb\"\n#  define NID_rc5_cfb64                   122\n\n#  define SN_rc5_ofb64                    \"RC5-OFB\"\n#  define LN_rc5_ofb64                    \"rc5-ofb\"\n#  define NID_rc5_ofb64                   123\n\n#  define SN_rle_compression              \"RLE\"\n#  define LN_rle_compression              \"run length compression\"\n#  define NID_rle_compression             124\n#  define OBJ_rle_compression             1L,1L,1L,1L,666L,1L\n\n#  define SN_zlib_compression             \"ZLIB\"\n#  define LN_zlib_compression             \"zlib compression\"\n#  define NID_zlib_compression            125\n#  define OBJ_zlib_compression            1L,1L,1L,1L,666L,2L\n\n#  define SN_ext_key_usage                \"extendedKeyUsage\"\n#  define LN_ext_key_usage                \"X509v3 Extended Key Usage\"\n#  define NID_ext_key_usage               126\n#  define OBJ_ext_key_usage               OBJ_id_ce,37\n\n#  define SN_id_pkix                      \"PKIX\"\n#  define NID_id_pkix                     127\n#  define OBJ_id_pkix                     1L,3L,6L,1L,5L,5L,7L\n\n#  define SN_id_kp                        \"id-kp\"\n#  define NID_id_kp                       128\n#  define OBJ_id_kp                       OBJ_id_pkix,3L\n\n/* PKIX extended key usage OIDs */\n\n#  define SN_server_auth                  \"serverAuth\"\n#  define LN_server_auth                  \"TLS Web Server Authentication\"\n#  define NID_server_auth                 129\n#  define OBJ_server_auth                 OBJ_id_kp,1L\n\n#  define SN_client_auth                  \"clientAuth\"\n#  define LN_client_auth                  \"TLS Web Client Authentication\"\n#  define NID_client_auth                 130\n#  define OBJ_client_auth                 OBJ_id_kp,2L\n\n#  define SN_code_sign                    \"codeSigning\"\n#  define LN_code_sign                    \"Code Signing\"\n#  define NID_code_sign                   131\n#  define OBJ_code_sign                   OBJ_id_kp,3L\n\n#  define SN_email_protect                \"emailProtection\"\n#  define LN_email_protect                \"E-mail Protection\"\n#  define NID_email_protect               132\n#  define OBJ_email_protect               OBJ_id_kp,4L\n\n#  define SN_time_stamp                   \"timeStamping\"\n#  define LN_time_stamp                   \"Time Stamping\"\n#  define NID_time_stamp                  133\n#  define OBJ_time_stamp                  OBJ_id_kp,8L\n\n/* Additional extended key usage OIDs: Microsoft */\n\n#  define SN_ms_code_ind                  \"msCodeInd\"\n#  define LN_ms_code_ind                  \"Microsoft Individual Code Signing\"\n#  define NID_ms_code_ind                 134\n#  define OBJ_ms_code_ind                 1L,3L,6L,1L,4L,1L,311L,2L,1L,21L\n\n#  define SN_ms_code_com                  \"msCodeCom\"\n#  define LN_ms_code_com                  \"Microsoft Commercial Code Signing\"\n#  define NID_ms_code_com                 135\n#  define OBJ_ms_code_com                 1L,3L,6L,1L,4L,1L,311L,2L,1L,22L\n\n#  define SN_ms_ctl_sign                  \"msCTLSign\"\n#  define LN_ms_ctl_sign                  \"Microsoft Trust List Signing\"\n#  define NID_ms_ctl_sign                 136\n#  define OBJ_ms_ctl_sign                 1L,3L,6L,1L,4L,1L,311L,10L,3L,1L\n\n#  define SN_ms_sgc                       \"msSGC\"\n#  define LN_ms_sgc                       \"Microsoft Server Gated Crypto\"\n#  define NID_ms_sgc                      137\n#  define OBJ_ms_sgc                      1L,3L,6L,1L,4L,1L,311L,10L,3L,3L\n\n#  define SN_ms_efs                       \"msEFS\"\n#  define LN_ms_efs                       \"Microsoft Encrypted File System\"\n#  define NID_ms_efs                      138\n#  define OBJ_ms_efs                      1L,3L,6L,1L,4L,1L,311L,10L,3L,4L\n\n/* Additional usage: Netscape */\n\n#  define SN_ns_sgc                       \"nsSGC\"\n#  define LN_ns_sgc                       \"Netscape Server Gated Crypto\"\n#  define NID_ns_sgc                      139\n#  define OBJ_ns_sgc                      OBJ_netscape,4L,1L\n\n#  define SN_delta_crl                    \"deltaCRL\"\n#  define LN_delta_crl                    \"X509v3 Delta CRL Indicator\"\n#  define NID_delta_crl                   140\n#  define OBJ_delta_crl                   OBJ_id_ce,27L\n\n#  define SN_crl_reason                   \"CRLReason\"\n#  define LN_crl_reason                   \"CRL Reason Code\"\n#  define NID_crl_reason                  141\n#  define OBJ_crl_reason                  OBJ_id_ce,21L\n\n#  define SN_invalidity_date              \"invalidityDate\"\n#  define LN_invalidity_date              \"Invalidity Date\"\n#  define NID_invalidity_date             142\n#  define OBJ_invalidity_date             OBJ_id_ce,24L\n\n#  define SN_sxnet                        \"SXNetID\"\n#  define LN_sxnet                        \"Strong Extranet ID\"\n#  define NID_sxnet                       143\n#  define OBJ_sxnet                       1L,3L,101L,1L,4L,1L\n\n/* PKCS12 and related OBJECT IDENTIFIERS */\n\n#  define OBJ_pkcs12                      OBJ_pkcs,12L\n#  define OBJ_pkcs12_pbeids               OBJ_pkcs12, 1\n\n#  define SN_pbe_WithSHA1And128BitRC4     \"PBE-SHA1-RC4-128\"\n#  define LN_pbe_WithSHA1And128BitRC4     \"pbeWithSHA1And128BitRC4\"\n#  define NID_pbe_WithSHA1And128BitRC4    144\n#  define OBJ_pbe_WithSHA1And128BitRC4    OBJ_pkcs12_pbeids, 1L\n\n#  define SN_pbe_WithSHA1And40BitRC4      \"PBE-SHA1-RC4-40\"\n#  define LN_pbe_WithSHA1And40BitRC4      \"pbeWithSHA1And40BitRC4\"\n#  define NID_pbe_WithSHA1And40BitRC4     145\n#  define OBJ_pbe_WithSHA1And40BitRC4     OBJ_pkcs12_pbeids, 2L\n\n#  define SN_pbe_WithSHA1And3_Key_TripleDES_CBC   \"PBE-SHA1-3DES\"\n#  define LN_pbe_WithSHA1And3_Key_TripleDES_CBC   \"pbeWithSHA1And3-KeyTripleDES-CBC\"\n#  define NID_pbe_WithSHA1And3_Key_TripleDES_CBC  146\n#  define OBJ_pbe_WithSHA1And3_Key_TripleDES_CBC  OBJ_pkcs12_pbeids, 3L\n\n#  define SN_pbe_WithSHA1And2_Key_TripleDES_CBC   \"PBE-SHA1-2DES\"\n#  define LN_pbe_WithSHA1And2_Key_TripleDES_CBC   \"pbeWithSHA1And2-KeyTripleDES-CBC\"\n#  define NID_pbe_WithSHA1And2_Key_TripleDES_CBC  147\n#  define OBJ_pbe_WithSHA1And2_Key_TripleDES_CBC  OBJ_pkcs12_pbeids, 4L\n\n#  define SN_pbe_WithSHA1And128BitRC2_CBC         \"PBE-SHA1-RC2-128\"\n#  define LN_pbe_WithSHA1And128BitRC2_CBC         \"pbeWithSHA1And128BitRC2-CBC\"\n#  define NID_pbe_WithSHA1And128BitRC2_CBC        148\n#  define OBJ_pbe_WithSHA1And128BitRC2_CBC        OBJ_pkcs12_pbeids, 5L\n\n#  define SN_pbe_WithSHA1And40BitRC2_CBC  \"PBE-SHA1-RC2-40\"\n#  define LN_pbe_WithSHA1And40BitRC2_CBC  \"pbeWithSHA1And40BitRC2-CBC\"\n#  define NID_pbe_WithSHA1And40BitRC2_CBC 149\n#  define OBJ_pbe_WithSHA1And40BitRC2_CBC OBJ_pkcs12_pbeids, 6L\n\n#  define OBJ_pkcs12_Version1     OBJ_pkcs12, 10L\n\n#  define OBJ_pkcs12_BagIds       OBJ_pkcs12_Version1, 1L\n\n#  define LN_keyBag               \"keyBag\"\n#  define NID_keyBag              150\n#  define OBJ_keyBag              OBJ_pkcs12_BagIds, 1L\n\n#  define LN_pkcs8ShroudedKeyBag  \"pkcs8ShroudedKeyBag\"\n#  define NID_pkcs8ShroudedKeyBag 151\n#  define OBJ_pkcs8ShroudedKeyBag OBJ_pkcs12_BagIds, 2L\n\n#  define LN_certBag              \"certBag\"\n#  define NID_certBag             152\n#  define OBJ_certBag             OBJ_pkcs12_BagIds, 3L\n\n#  define LN_crlBag               \"crlBag\"\n#  define NID_crlBag              153\n#  define OBJ_crlBag              OBJ_pkcs12_BagIds, 4L\n\n#  define LN_secretBag            \"secretBag\"\n#  define NID_secretBag           154\n#  define OBJ_secretBag           OBJ_pkcs12_BagIds, 5L\n\n#  define LN_safeContentsBag      \"safeContentsBag\"\n#  define NID_safeContentsBag     155\n#  define OBJ_safeContentsBag     OBJ_pkcs12_BagIds, 6L\n\n#  define LN_friendlyName         \"friendlyName\"\n#  define NID_friendlyName        156\n#  define OBJ_friendlyName        OBJ_pkcs9, 20L\n\n#  define LN_localKeyID           \"localKeyID\"\n#  define NID_localKeyID          157\n#  define OBJ_localKeyID          OBJ_pkcs9, 21L\n\n#  define OBJ_certTypes           OBJ_pkcs9, 22L\n\n#  define LN_x509Certificate      \"x509Certificate\"\n#  define NID_x509Certificate     158\n#  define OBJ_x509Certificate     OBJ_certTypes, 1L\n\n#  define LN_sdsiCertificate      \"sdsiCertificate\"\n#  define NID_sdsiCertificate     159\n#  define OBJ_sdsiCertificate     OBJ_certTypes, 2L\n\n#  define OBJ_crlTypes            OBJ_pkcs9, 23L\n\n#  define LN_x509Crl              \"x509Crl\"\n#  define NID_x509Crl             160\n#  define OBJ_x509Crl             OBJ_crlTypes, 1L\n\n/* PKCS#5 v2 OIDs */\n\n#  define LN_pbes2                \"PBES2\"\n#  define NID_pbes2               161\n#  define OBJ_pbes2               OBJ_pkcs,5L,13L\n\n#  define LN_pbmac1               \"PBMAC1\"\n#  define NID_pbmac1              162\n#  define OBJ_pbmac1              OBJ_pkcs,5L,14L\n\n#  define LN_hmacWithSHA1         \"hmacWithSHA1\"\n#  define NID_hmacWithSHA1        163\n#  define OBJ_hmacWithSHA1        OBJ_rsadsi,2L,7L\n\n/* Policy Qualifier Ids */\n\n#  define LN_id_qt_cps            \"Policy Qualifier CPS\"\n#  define SN_id_qt_cps            \"id-qt-cps\"\n#  define NID_id_qt_cps           164\n#  define OBJ_id_qt_cps           OBJ_id_pkix,2L,1L\n\n#  define LN_id_qt_unotice        \"Policy Qualifier User Notice\"\n#  define SN_id_qt_unotice        \"id-qt-unotice\"\n#  define NID_id_qt_unotice       165\n#  define OBJ_id_qt_unotice       OBJ_id_pkix,2L,2L\n\n#  define SN_rc2_64_cbc                   \"RC2-64-CBC\"\n#  define LN_rc2_64_cbc                   \"rc2-64-cbc\"\n#  define NID_rc2_64_cbc                  166\n\n#  define SN_SMIMECapabilities            \"SMIME-CAPS\"\n#  define LN_SMIMECapabilities            \"S/MIME Capabilities\"\n#  define NID_SMIMECapabilities           167\n#  define OBJ_SMIMECapabilities           OBJ_pkcs9,15L\n\n#  define SN_pbeWithMD2AndRC2_CBC         \"PBE-MD2-RC2-64\"\n#  define LN_pbeWithMD2AndRC2_CBC         \"pbeWithMD2AndRC2-CBC\"\n#  define NID_pbeWithMD2AndRC2_CBC        168\n#  define OBJ_pbeWithMD2AndRC2_CBC        OBJ_pkcs,5L,4L\n\n#  define SN_pbeWithMD5AndRC2_CBC         \"PBE-MD5-RC2-64\"\n#  define LN_pbeWithMD5AndRC2_CBC         \"pbeWithMD5AndRC2-CBC\"\n#  define NID_pbeWithMD5AndRC2_CBC        169\n#  define OBJ_pbeWithMD5AndRC2_CBC        OBJ_pkcs,5L,6L\n\n#  define SN_pbeWithSHA1AndDES_CBC        \"PBE-SHA1-DES\"\n#  define LN_pbeWithSHA1AndDES_CBC        \"pbeWithSHA1AndDES-CBC\"\n#  define NID_pbeWithSHA1AndDES_CBC       170\n#  define OBJ_pbeWithSHA1AndDES_CBC       OBJ_pkcs,5L,10L\n\n/* Extension request OIDs */\n\n#  define LN_ms_ext_req                   \"Microsoft Extension Request\"\n#  define SN_ms_ext_req                   \"msExtReq\"\n#  define NID_ms_ext_req                  171\n#  define OBJ_ms_ext_req                  1L,3L,6L,1L,4L,1L,311L,2L,1L,14L\n\n#  define LN_ext_req                      \"Extension Request\"\n#  define SN_ext_req                      \"extReq\"\n#  define NID_ext_req                     172\n#  define OBJ_ext_req                     OBJ_pkcs9,14L\n\n#  define SN_name                         \"name\"\n#  define LN_name                         \"name\"\n#  define NID_name                        173\n#  define OBJ_name                        OBJ_X509,41L\n\n#  define SN_dnQualifier                  \"dnQualifier\"\n#  define LN_dnQualifier                  \"dnQualifier\"\n#  define NID_dnQualifier                 174\n#  define OBJ_dnQualifier                 OBJ_X509,46L\n\n#  define SN_id_pe                        \"id-pe\"\n#  define NID_id_pe                       175\n#  define OBJ_id_pe                       OBJ_id_pkix,1L\n\n#  define SN_id_ad                        \"id-ad\"\n#  define NID_id_ad                       176\n#  define OBJ_id_ad                       OBJ_id_pkix,48L\n\n#  define SN_info_access                  \"authorityInfoAccess\"\n#  define LN_info_access                  \"Authority Information Access\"\n#  define NID_info_access                 177\n#  define OBJ_info_access                 OBJ_id_pe,1L\n\n#  define SN_ad_OCSP                      \"OCSP\"\n#  define LN_ad_OCSP                      \"OCSP\"\n#  define NID_ad_OCSP                     178\n#  define OBJ_ad_OCSP                     OBJ_id_ad,1L\n\n#  define SN_ad_ca_issuers                \"caIssuers\"\n#  define LN_ad_ca_issuers                \"CA Issuers\"\n#  define NID_ad_ca_issuers               179\n#  define OBJ_ad_ca_issuers               OBJ_id_ad,2L\n\n#  define SN_OCSP_sign                    \"OCSPSigning\"\n#  define LN_OCSP_sign                    \"OCSP Signing\"\n#  define NID_OCSP_sign                   180\n#  define OBJ_OCSP_sign                   OBJ_id_kp,9L\n# endif                         /* USE_OBJ_MAC */\n\n# include <openssl/bio.h>\n# include <openssl/asn1.h>\n\n# define OBJ_NAME_TYPE_UNDEF             0x00\n# define OBJ_NAME_TYPE_MD_METH           0x01\n# define OBJ_NAME_TYPE_CIPHER_METH       0x02\n# define OBJ_NAME_TYPE_PKEY_METH         0x03\n# define OBJ_NAME_TYPE_COMP_METH         0x04\n# define OBJ_NAME_TYPE_NUM               0x05\n\n# define OBJ_NAME_ALIAS                  0x8000\n\n# define OBJ_BSEARCH_VALUE_ON_NOMATCH            0x01\n# define OBJ_BSEARCH_FIRST_VALUE_ON_MATCH        0x02\n\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\ntypedef struct obj_name_st {\n    int type;\n    int alias;\n    const char *name;\n    const char *data;\n} OBJ_NAME;\n\n# define         OBJ_create_and_add_object(a,b,c) OBJ_create(a,b,c)\n\nint OBJ_NAME_init(void);\nint OBJ_NAME_new_index(unsigned long (*hash_func) (const char *),\n                       int (*cmp_func) (const char *, const char *),\n                       void (*free_func) (const char *, int, const char *));\nconst char *OBJ_NAME_get(const char *name, int type);\nint OBJ_NAME_add(const char *name, int type, const char *data);\nint OBJ_NAME_remove(const char *name, int type);\nvoid OBJ_NAME_cleanup(int type); /* -1 for everything */\nvoid OBJ_NAME_do_all(int type, void (*fn) (const OBJ_NAME *, void *arg),\n                     void *arg);\nvoid OBJ_NAME_do_all_sorted(int type,\n                            void (*fn) (const OBJ_NAME *, void *arg),\n                            void *arg);\n\nASN1_OBJECT *OBJ_dup(const ASN1_OBJECT *o);\nASN1_OBJECT *OBJ_nid2obj(int n);\nconst char *OBJ_nid2ln(int n);\nconst char *OBJ_nid2sn(int n);\nint OBJ_obj2nid(const ASN1_OBJECT *o);\nASN1_OBJECT *OBJ_txt2obj(const char *s, int no_name);\nint OBJ_obj2txt(char *buf, int buf_len, const ASN1_OBJECT *a, int no_name);\nint OBJ_txt2nid(const char *s);\nint OBJ_ln2nid(const char *s);\nint OBJ_sn2nid(const char *s);\nint OBJ_cmp(const ASN1_OBJECT *a, const ASN1_OBJECT *b);\nconst void *OBJ_bsearch_(const void *key, const void *base, int num, int size,\n                         int (*cmp) (const void *, const void *));\nconst void *OBJ_bsearch_ex_(const void *key, const void *base, int num,\n                            int size,\n                            int (*cmp) (const void *, const void *),\n                            int flags);\n\n# define _DECLARE_OBJ_BSEARCH_CMP_FN(scope, type1, type2, nm)    \\\n  static int nm##_cmp_BSEARCH_CMP_FN(const void *, const void *); \\\n  static int nm##_cmp(type1 const *, type2 const *); \\\n  scope type2 * OBJ_bsearch_##nm(type1 *key, type2 const *base, int num)\n\n# define DECLARE_OBJ_BSEARCH_CMP_FN(type1, type2, cmp)   \\\n  _DECLARE_OBJ_BSEARCH_CMP_FN(static, type1, type2, cmp)\n# define DECLARE_OBJ_BSEARCH_GLOBAL_CMP_FN(type1, type2, nm)     \\\n  type2 * OBJ_bsearch_##nm(type1 *key, type2 const *base, int num)\n\n/*-\n * Unsolved problem: if a type is actually a pointer type, like\n * nid_triple is, then its impossible to get a const where you need\n * it. Consider:\n *\n * typedef int nid_triple[3];\n * const void *a_;\n * const nid_triple const *a = a_;\n *\n * The assignement discards a const because what you really want is:\n *\n * const int const * const *a = a_;\n *\n * But if you do that, you lose the fact that a is an array of 3 ints,\n * which breaks comparison functions.\n *\n * Thus we end up having to cast, sadly, or unpack the\n * declarations. Or, as I finally did in this case, delcare nid_triple\n * to be a struct, which it should have been in the first place.\n *\n * Ben, August 2008.\n *\n * Also, strictly speaking not all types need be const, but handling\n * the non-constness means a lot of complication, and in practice\n * comparison routines do always not touch their arguments.\n */\n\n# define IMPLEMENT_OBJ_BSEARCH_CMP_FN(type1, type2, nm)  \\\n  static int nm##_cmp_BSEARCH_CMP_FN(const void *a_, const void *b_)    \\\n      { \\\n      type1 const *a = a_; \\\n      type2 const *b = b_; \\\n      return nm##_cmp(a,b); \\\n      } \\\n  static type2 *OBJ_bsearch_##nm(type1 *key, type2 const *base, int num) \\\n      { \\\n      return (type2 *)OBJ_bsearch_(key, base, num, sizeof(type2), \\\n                                        nm##_cmp_BSEARCH_CMP_FN); \\\n      } \\\n      extern void dummy_prototype(void)\n\n# define IMPLEMENT_OBJ_BSEARCH_GLOBAL_CMP_FN(type1, type2, nm)   \\\n  static int nm##_cmp_BSEARCH_CMP_FN(const void *a_, const void *b_)    \\\n      { \\\n      type1 const *a = a_; \\\n      type2 const *b = b_; \\\n      return nm##_cmp(a,b); \\\n      } \\\n  type2 *OBJ_bsearch_##nm(type1 *key, type2 const *base, int num) \\\n      { \\\n      return (type2 *)OBJ_bsearch_(key, base, num, sizeof(type2), \\\n                                        nm##_cmp_BSEARCH_CMP_FN); \\\n      } \\\n      extern void dummy_prototype(void)\n\n# define OBJ_bsearch(type1,key,type2,base,num,cmp)                              \\\n  ((type2 *)OBJ_bsearch_(CHECKED_PTR_OF(type1,key),CHECKED_PTR_OF(type2,base), \\\n                         num,sizeof(type2),                             \\\n                         ((void)CHECKED_PTR_OF(type1,cmp##_type_1),     \\\n                          (void)CHECKED_PTR_OF(type2,cmp##_type_2),     \\\n                          cmp##_BSEARCH_CMP_FN)))\n\n# define OBJ_bsearch_ex(type1,key,type2,base,num,cmp,flags)                      \\\n  ((type2 *)OBJ_bsearch_ex_(CHECKED_PTR_OF(type1,key),CHECKED_PTR_OF(type2,base), \\\n                         num,sizeof(type2),                             \\\n                         ((void)CHECKED_PTR_OF(type1,cmp##_type_1),     \\\n                          (void)type_2=CHECKED_PTR_OF(type2,cmp##_type_2), \\\n                          cmp##_BSEARCH_CMP_FN)),flags)\n\nint OBJ_new_nid(int num);\nint OBJ_add_object(const ASN1_OBJECT *obj);\nint OBJ_create(const char *oid, const char *sn, const char *ln);\nvoid OBJ_cleanup(void);\nint OBJ_create_objects(BIO *in);\n\nint OBJ_find_sigid_algs(int signid, int *pdig_nid, int *ppkey_nid);\nint OBJ_find_sigid_by_algs(int *psignid, int dig_nid, int pkey_nid);\nint OBJ_add_sigid(int signid, int dig_id, int pkey_id);\nvoid OBJ_sigid_free(void);\n\nextern int obj_cleanup_defer;\nvoid check_defer(int nid);\n\n/* BEGIN ERROR CODES */\n/*\n * The following lines are auto generated by the script mkerr.pl. Any changes\n * made after this point may be overwritten when the script is next run.\n */\nvoid ERR_load_OBJ_strings(void);\n\n/* Error codes for the OBJ functions. */\n\n/* Function codes. */\n# define OBJ_F_OBJ_ADD_OBJECT                             105\n# define OBJ_F_OBJ_CREATE                                 100\n# define OBJ_F_OBJ_DUP                                    101\n# define OBJ_F_OBJ_NAME_NEW_INDEX                         106\n# define OBJ_F_OBJ_NID2LN                                 102\n# define OBJ_F_OBJ_NID2OBJ                                103\n# define OBJ_F_OBJ_NID2SN                                 104\n\n/* Reason codes. */\n# define OBJ_R_MALLOC_FAILURE                             100\n# define OBJ_R_UNKNOWN_NID                                101\n\n#ifdef  __cplusplus\n}\n#endif\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/x86_64/include/openssl/ocsp.h",
    "content": "/* ocsp.h */\n/*\n * Written by Tom Titchener <Tom_Titchener@groove.net> for the OpenSSL\n * project.\n */\n\n/*\n * History: This file was transfered to Richard Levitte from CertCo by Kathy\n * Weinhold in mid-spring 2000 to be included in OpenSSL or released as a\n * patch kit.\n */\n\n/* ====================================================================\n * Copyright (c) 1998-2000 The OpenSSL Project.  All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n *\n * 1. Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n *\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in\n *    the documentation and/or other materials provided with the\n *    distribution.\n *\n * 3. All advertising materials mentioning features or use of this\n *    software must display the following acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit. (http://www.openssl.org/)\"\n *\n * 4. The names \"OpenSSL Toolkit\" and \"OpenSSL Project\" must not be used to\n *    endorse or promote products derived from this software without\n *    prior written permission. For written permission, please contact\n *    openssl-core@openssl.org.\n *\n * 5. Products derived from this software may not be called \"OpenSSL\"\n *    nor may \"OpenSSL\" appear in their names without prior written\n *    permission of the OpenSSL Project.\n *\n * 6. Redistributions of any form whatsoever must retain the following\n *    acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit (http://www.openssl.org/)\"\n *\n * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY\n * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\n * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR\n * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\n * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,\n * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED\n * OF THE POSSIBILITY OF SUCH DAMAGE.\n * ====================================================================\n *\n * This product includes cryptographic software written by Eric Young\n * (eay@cryptsoft.com).  This product includes software written by Tim\n * Hudson (tjh@cryptsoft.com).\n *\n */\n\n#ifndef HEADER_OCSP_H\n# define HEADER_OCSP_H\n\n# include <openssl/ossl_typ.h>\n# include <openssl/x509.h>\n# include <openssl/x509v3.h>\n# include <openssl/safestack.h>\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n/* Various flags and values */\n\n# define OCSP_DEFAULT_NONCE_LENGTH       16\n\n# define OCSP_NOCERTS                    0x1\n# define OCSP_NOINTERN                   0x2\n# define OCSP_NOSIGS                     0x4\n# define OCSP_NOCHAIN                    0x8\n# define OCSP_NOVERIFY                   0x10\n# define OCSP_NOEXPLICIT                 0x20\n# define OCSP_NOCASIGN                   0x40\n# define OCSP_NODELEGATED                0x80\n# define OCSP_NOCHECKS                   0x100\n# define OCSP_TRUSTOTHER                 0x200\n# define OCSP_RESPID_KEY                 0x400\n# define OCSP_NOTIME                     0x800\n\n/*-  CertID ::= SEQUENCE {\n *       hashAlgorithm            AlgorithmIdentifier,\n *       issuerNameHash     OCTET STRING, -- Hash of Issuer's DN\n *       issuerKeyHash      OCTET STRING, -- Hash of Issuers public key (excluding the tag & length fields)\n *       serialNumber       CertificateSerialNumber }\n */\ntypedef struct ocsp_cert_id_st {\n    X509_ALGOR *hashAlgorithm;\n    ASN1_OCTET_STRING *issuerNameHash;\n    ASN1_OCTET_STRING *issuerKeyHash;\n    ASN1_INTEGER *serialNumber;\n} OCSP_CERTID;\n\nDECLARE_STACK_OF(OCSP_CERTID)\n\n/*-  Request ::=     SEQUENCE {\n *       reqCert                    CertID,\n *       singleRequestExtensions    [0] EXPLICIT Extensions OPTIONAL }\n */\ntypedef struct ocsp_one_request_st {\n    OCSP_CERTID *reqCert;\n    STACK_OF(X509_EXTENSION) *singleRequestExtensions;\n} OCSP_ONEREQ;\n\nDECLARE_STACK_OF(OCSP_ONEREQ)\nDECLARE_ASN1_SET_OF(OCSP_ONEREQ)\n\n/*-  TBSRequest      ::=     SEQUENCE {\n *       version             [0] EXPLICIT Version DEFAULT v1,\n *       requestorName       [1] EXPLICIT GeneralName OPTIONAL,\n *       requestList             SEQUENCE OF Request,\n *       requestExtensions   [2] EXPLICIT Extensions OPTIONAL }\n */\ntypedef struct ocsp_req_info_st {\n    ASN1_INTEGER *version;\n    GENERAL_NAME *requestorName;\n    STACK_OF(OCSP_ONEREQ) *requestList;\n    STACK_OF(X509_EXTENSION) *requestExtensions;\n} OCSP_REQINFO;\n\n/*-  Signature       ::=     SEQUENCE {\n *       signatureAlgorithm   AlgorithmIdentifier,\n *       signature            BIT STRING,\n *       certs                [0] EXPLICIT SEQUENCE OF Certificate OPTIONAL }\n */\ntypedef struct ocsp_signature_st {\n    X509_ALGOR *signatureAlgorithm;\n    ASN1_BIT_STRING *signature;\n    STACK_OF(X509) *certs;\n} OCSP_SIGNATURE;\n\n/*-  OCSPRequest     ::=     SEQUENCE {\n *       tbsRequest                  TBSRequest,\n *       optionalSignature   [0]     EXPLICIT Signature OPTIONAL }\n */\ntypedef struct ocsp_request_st {\n    OCSP_REQINFO *tbsRequest;\n    OCSP_SIGNATURE *optionalSignature; /* OPTIONAL */\n} OCSP_REQUEST;\n\n/*-  OCSPResponseStatus ::= ENUMERATED {\n *       successful            (0),      --Response has valid confirmations\n *       malformedRequest      (1),      --Illegal confirmation request\n *       internalError         (2),      --Internal error in issuer\n *       tryLater              (3),      --Try again later\n *                                       --(4) is not used\n *       sigRequired           (5),      --Must sign the request\n *       unauthorized          (6)       --Request unauthorized\n *   }\n */\n# define OCSP_RESPONSE_STATUS_SUCCESSFUL          0\n# define OCSP_RESPONSE_STATUS_MALFORMEDREQUEST     1\n# define OCSP_RESPONSE_STATUS_INTERNALERROR        2\n# define OCSP_RESPONSE_STATUS_TRYLATER             3\n# define OCSP_RESPONSE_STATUS_SIGREQUIRED          5\n# define OCSP_RESPONSE_STATUS_UNAUTHORIZED         6\n\n/*-  ResponseBytes ::=       SEQUENCE {\n *       responseType   OBJECT IDENTIFIER,\n *       response       OCTET STRING }\n */\ntypedef struct ocsp_resp_bytes_st {\n    ASN1_OBJECT *responseType;\n    ASN1_OCTET_STRING *response;\n} OCSP_RESPBYTES;\n\n/*-  OCSPResponse ::= SEQUENCE {\n *      responseStatus         OCSPResponseStatus,\n *      responseBytes          [0] EXPLICIT ResponseBytes OPTIONAL }\n */\nstruct ocsp_response_st {\n    ASN1_ENUMERATED *responseStatus;\n    OCSP_RESPBYTES *responseBytes;\n};\n\n/*-  ResponderID ::= CHOICE {\n *      byName   [1] Name,\n *      byKey    [2] KeyHash }\n */\n# define V_OCSP_RESPID_NAME 0\n# define V_OCSP_RESPID_KEY  1\nstruct ocsp_responder_id_st {\n    int type;\n    union {\n        X509_NAME *byName;\n        ASN1_OCTET_STRING *byKey;\n    } value;\n};\n\nDECLARE_STACK_OF(OCSP_RESPID)\nDECLARE_ASN1_FUNCTIONS(OCSP_RESPID)\n\n/*-  KeyHash ::= OCTET STRING --SHA-1 hash of responder's public key\n *                            --(excluding the tag and length fields)\n */\n\n/*-  RevokedInfo ::= SEQUENCE {\n *       revocationTime              GeneralizedTime,\n *       revocationReason    [0]     EXPLICIT CRLReason OPTIONAL }\n */\ntypedef struct ocsp_revoked_info_st {\n    ASN1_GENERALIZEDTIME *revocationTime;\n    ASN1_ENUMERATED *revocationReason;\n} OCSP_REVOKEDINFO;\n\n/*-  CertStatus ::= CHOICE {\n *       good                [0]     IMPLICIT NULL,\n *       revoked             [1]     IMPLICIT RevokedInfo,\n *       unknown             [2]     IMPLICIT UnknownInfo }\n */\n# define V_OCSP_CERTSTATUS_GOOD    0\n# define V_OCSP_CERTSTATUS_REVOKED 1\n# define V_OCSP_CERTSTATUS_UNKNOWN 2\ntypedef struct ocsp_cert_status_st {\n    int type;\n    union {\n        ASN1_NULL *good;\n        OCSP_REVOKEDINFO *revoked;\n        ASN1_NULL *unknown;\n    } value;\n} OCSP_CERTSTATUS;\n\n/*-  SingleResponse ::= SEQUENCE {\n *      certID                       CertID,\n *      certStatus                   CertStatus,\n *      thisUpdate                   GeneralizedTime,\n *      nextUpdate           [0]     EXPLICIT GeneralizedTime OPTIONAL,\n *      singleExtensions     [1]     EXPLICIT Extensions OPTIONAL }\n */\ntypedef struct ocsp_single_response_st {\n    OCSP_CERTID *certId;\n    OCSP_CERTSTATUS *certStatus;\n    ASN1_GENERALIZEDTIME *thisUpdate;\n    ASN1_GENERALIZEDTIME *nextUpdate;\n    STACK_OF(X509_EXTENSION) *singleExtensions;\n} OCSP_SINGLERESP;\n\nDECLARE_STACK_OF(OCSP_SINGLERESP)\nDECLARE_ASN1_SET_OF(OCSP_SINGLERESP)\n\n/*-  ResponseData ::= SEQUENCE {\n *      version              [0] EXPLICIT Version DEFAULT v1,\n *      responderID              ResponderID,\n *      producedAt               GeneralizedTime,\n *      responses                SEQUENCE OF SingleResponse,\n *      responseExtensions   [1] EXPLICIT Extensions OPTIONAL }\n */\ntypedef struct ocsp_response_data_st {\n    ASN1_INTEGER *version;\n    OCSP_RESPID *responderId;\n    ASN1_GENERALIZEDTIME *producedAt;\n    STACK_OF(OCSP_SINGLERESP) *responses;\n    STACK_OF(X509_EXTENSION) *responseExtensions;\n} OCSP_RESPDATA;\n\n/*-  BasicOCSPResponse       ::= SEQUENCE {\n *      tbsResponseData      ResponseData,\n *      signatureAlgorithm   AlgorithmIdentifier,\n *      signature            BIT STRING,\n *      certs                [0] EXPLICIT SEQUENCE OF Certificate OPTIONAL }\n */\n  /*\n   * Note 1: The value for \"signature\" is specified in the OCSP rfc2560 as\n   * follows: \"The value for the signature SHALL be computed on the hash of\n   * the DER encoding ResponseData.\" This means that you must hash the\n   * DER-encoded tbsResponseData, and then run it through a crypto-signing\n   * function, which will (at least w/RSA) do a hash-'n'-private-encrypt\n   * operation.  This seems a bit odd, but that's the spec.  Also note that\n   * the data structures do not leave anywhere to independently specify the\n   * algorithm used for the initial hash. So, we look at the\n   * signature-specification algorithm, and try to do something intelligent.\n   * -- Kathy Weinhold, CertCo\n   */\n  /*\n   * Note 2: It seems that the mentioned passage from RFC 2560 (section\n   * 4.2.1) is open for interpretation.  I've done tests against another\n   * responder, and found that it doesn't do the double hashing that the RFC\n   * seems to say one should.  Therefore, all relevant functions take a flag\n   * saying which variant should be used.  -- Richard Levitte, OpenSSL team\n   * and CeloCom\n   */\ntypedef struct ocsp_basic_response_st {\n    OCSP_RESPDATA *tbsResponseData;\n    X509_ALGOR *signatureAlgorithm;\n    ASN1_BIT_STRING *signature;\n    STACK_OF(X509) *certs;\n} OCSP_BASICRESP;\n\n/*-\n *   CRLReason ::= ENUMERATED {\n *        unspecified             (0),\n *        keyCompromise           (1),\n *        cACompromise            (2),\n *        affiliationChanged      (3),\n *        superseded              (4),\n *        cessationOfOperation    (5),\n *        certificateHold         (6),\n *        removeFromCRL           (8) }\n */\n# define OCSP_REVOKED_STATUS_NOSTATUS               -1\n# define OCSP_REVOKED_STATUS_UNSPECIFIED             0\n# define OCSP_REVOKED_STATUS_KEYCOMPROMISE           1\n# define OCSP_REVOKED_STATUS_CACOMPROMISE            2\n# define OCSP_REVOKED_STATUS_AFFILIATIONCHANGED      3\n# define OCSP_REVOKED_STATUS_SUPERSEDED              4\n# define OCSP_REVOKED_STATUS_CESSATIONOFOPERATION    5\n# define OCSP_REVOKED_STATUS_CERTIFICATEHOLD         6\n# define OCSP_REVOKED_STATUS_REMOVEFROMCRL           8\n\n/*-\n * CrlID ::= SEQUENCE {\n *     crlUrl               [0]     EXPLICIT IA5String OPTIONAL,\n *     crlNum               [1]     EXPLICIT INTEGER OPTIONAL,\n *     crlTime              [2]     EXPLICIT GeneralizedTime OPTIONAL }\n */\ntypedef struct ocsp_crl_id_st {\n    ASN1_IA5STRING *crlUrl;\n    ASN1_INTEGER *crlNum;\n    ASN1_GENERALIZEDTIME *crlTime;\n} OCSP_CRLID;\n\n/*-\n * ServiceLocator ::= SEQUENCE {\n *      issuer    Name,\n *      locator   AuthorityInfoAccessSyntax OPTIONAL }\n */\ntypedef struct ocsp_service_locator_st {\n    X509_NAME *issuer;\n    STACK_OF(ACCESS_DESCRIPTION) *locator;\n} OCSP_SERVICELOC;\n\n# define PEM_STRING_OCSP_REQUEST \"OCSP REQUEST\"\n# define PEM_STRING_OCSP_RESPONSE \"OCSP RESPONSE\"\n\n# define d2i_OCSP_REQUEST_bio(bp,p) ASN1_d2i_bio_of(OCSP_REQUEST,OCSP_REQUEST_new,d2i_OCSP_REQUEST,bp,p)\n\n# define d2i_OCSP_RESPONSE_bio(bp,p) ASN1_d2i_bio_of(OCSP_RESPONSE,OCSP_RESPONSE_new,d2i_OCSP_RESPONSE,bp,p)\n\n# define PEM_read_bio_OCSP_REQUEST(bp,x,cb) (OCSP_REQUEST *)PEM_ASN1_read_bio( \\\n     (char *(*)())d2i_OCSP_REQUEST,PEM_STRING_OCSP_REQUEST,bp,(char **)x,cb,NULL)\n\n# define PEM_read_bio_OCSP_RESPONSE(bp,x,cb)(OCSP_RESPONSE *)PEM_ASN1_read_bio(\\\n     (char *(*)())d2i_OCSP_RESPONSE,PEM_STRING_OCSP_RESPONSE,bp,(char **)x,cb,NULL)\n\n# define PEM_write_bio_OCSP_REQUEST(bp,o) \\\n    PEM_ASN1_write_bio((int (*)())i2d_OCSP_REQUEST,PEM_STRING_OCSP_REQUEST,\\\n                        bp,(char *)o, NULL,NULL,0,NULL,NULL)\n\n# define PEM_write_bio_OCSP_RESPONSE(bp,o) \\\n    PEM_ASN1_write_bio((int (*)())i2d_OCSP_RESPONSE,PEM_STRING_OCSP_RESPONSE,\\\n                        bp,(char *)o, NULL,NULL,0,NULL,NULL)\n\n# define i2d_OCSP_RESPONSE_bio(bp,o) ASN1_i2d_bio_of(OCSP_RESPONSE,i2d_OCSP_RESPONSE,bp,o)\n\n# define i2d_OCSP_REQUEST_bio(bp,o) ASN1_i2d_bio_of(OCSP_REQUEST,i2d_OCSP_REQUEST,bp,o)\n\n# define OCSP_REQUEST_sign(o,pkey,md) \\\n        ASN1_item_sign(ASN1_ITEM_rptr(OCSP_REQINFO),\\\n                o->optionalSignature->signatureAlgorithm,NULL,\\\n                o->optionalSignature->signature,o->tbsRequest,pkey,md)\n\n# define OCSP_BASICRESP_sign(o,pkey,md,d) \\\n        ASN1_item_sign(ASN1_ITEM_rptr(OCSP_RESPDATA),o->signatureAlgorithm,NULL,\\\n                o->signature,o->tbsResponseData,pkey,md)\n\n# define OCSP_REQUEST_verify(a,r) ASN1_item_verify(ASN1_ITEM_rptr(OCSP_REQINFO),\\\n        a->optionalSignature->signatureAlgorithm,\\\n        a->optionalSignature->signature,a->tbsRequest,r)\n\n# define OCSP_BASICRESP_verify(a,r,d) ASN1_item_verify(ASN1_ITEM_rptr(OCSP_RESPDATA),\\\n        a->signatureAlgorithm,a->signature,a->tbsResponseData,r)\n\n# define ASN1_BIT_STRING_digest(data,type,md,len) \\\n        ASN1_item_digest(ASN1_ITEM_rptr(ASN1_BIT_STRING),type,data,md,len)\n\n# define OCSP_CERTSTATUS_dup(cs)\\\n                (OCSP_CERTSTATUS*)ASN1_dup((int(*)())i2d_OCSP_CERTSTATUS,\\\n                (char *(*)())d2i_OCSP_CERTSTATUS,(char *)(cs))\n\nOCSP_CERTID *OCSP_CERTID_dup(OCSP_CERTID *id);\n\nOCSP_RESPONSE *OCSP_sendreq_bio(BIO *b, const char *path, OCSP_REQUEST *req);\nOCSP_REQ_CTX *OCSP_sendreq_new(BIO *io, const char *path, OCSP_REQUEST *req,\n                               int maxline);\nint OCSP_REQ_CTX_nbio(OCSP_REQ_CTX *rctx);\nint OCSP_sendreq_nbio(OCSP_RESPONSE **presp, OCSP_REQ_CTX *rctx);\nOCSP_REQ_CTX *OCSP_REQ_CTX_new(BIO *io, int maxline);\nvoid OCSP_REQ_CTX_free(OCSP_REQ_CTX *rctx);\nvoid OCSP_set_max_response_length(OCSP_REQ_CTX *rctx, unsigned long len);\nint OCSP_REQ_CTX_i2d(OCSP_REQ_CTX *rctx, const ASN1_ITEM *it,\n                     ASN1_VALUE *val);\nint OCSP_REQ_CTX_nbio_d2i(OCSP_REQ_CTX *rctx, ASN1_VALUE **pval,\n                          const ASN1_ITEM *it);\nBIO *OCSP_REQ_CTX_get0_mem_bio(OCSP_REQ_CTX *rctx);\nint OCSP_REQ_CTX_i2d(OCSP_REQ_CTX *rctx, const ASN1_ITEM *it,\n                     ASN1_VALUE *val);\nint OCSP_REQ_CTX_http(OCSP_REQ_CTX *rctx, const char *op, const char *path);\nint OCSP_REQ_CTX_set1_req(OCSP_REQ_CTX *rctx, OCSP_REQUEST *req);\nint OCSP_REQ_CTX_add1_header(OCSP_REQ_CTX *rctx,\n                             const char *name, const char *value);\n\nOCSP_CERTID *OCSP_cert_to_id(const EVP_MD *dgst, X509 *subject, X509 *issuer);\n\nOCSP_CERTID *OCSP_cert_id_new(const EVP_MD *dgst,\n                              X509_NAME *issuerName,\n                              ASN1_BIT_STRING *issuerKey,\n                              ASN1_INTEGER *serialNumber);\n\nOCSP_ONEREQ *OCSP_request_add0_id(OCSP_REQUEST *req, OCSP_CERTID *cid);\n\nint OCSP_request_add1_nonce(OCSP_REQUEST *req, unsigned char *val, int len);\nint OCSP_basic_add1_nonce(OCSP_BASICRESP *resp, unsigned char *val, int len);\nint OCSP_check_nonce(OCSP_REQUEST *req, OCSP_BASICRESP *bs);\nint OCSP_copy_nonce(OCSP_BASICRESP *resp, OCSP_REQUEST *req);\n\nint OCSP_request_set1_name(OCSP_REQUEST *req, X509_NAME *nm);\nint OCSP_request_add1_cert(OCSP_REQUEST *req, X509 *cert);\n\nint OCSP_request_sign(OCSP_REQUEST *req,\n                      X509 *signer,\n                      EVP_PKEY *key,\n                      const EVP_MD *dgst,\n                      STACK_OF(X509) *certs, unsigned long flags);\n\nint OCSP_response_status(OCSP_RESPONSE *resp);\nOCSP_BASICRESP *OCSP_response_get1_basic(OCSP_RESPONSE *resp);\n\nint OCSP_resp_count(OCSP_BASICRESP *bs);\nOCSP_SINGLERESP *OCSP_resp_get0(OCSP_BASICRESP *bs, int idx);\nint OCSP_resp_find(OCSP_BASICRESP *bs, OCSP_CERTID *id, int last);\nint OCSP_single_get0_status(OCSP_SINGLERESP *single, int *reason,\n                            ASN1_GENERALIZEDTIME **revtime,\n                            ASN1_GENERALIZEDTIME **thisupd,\n                            ASN1_GENERALIZEDTIME **nextupd);\nint OCSP_resp_find_status(OCSP_BASICRESP *bs, OCSP_CERTID *id, int *status,\n                          int *reason,\n                          ASN1_GENERALIZEDTIME **revtime,\n                          ASN1_GENERALIZEDTIME **thisupd,\n                          ASN1_GENERALIZEDTIME **nextupd);\nint OCSP_check_validity(ASN1_GENERALIZEDTIME *thisupd,\n                        ASN1_GENERALIZEDTIME *nextupd, long sec, long maxsec);\n\nint OCSP_request_verify(OCSP_REQUEST *req, STACK_OF(X509) *certs,\n                        X509_STORE *store, unsigned long flags);\n\nint OCSP_parse_url(const char *url, char **phost, char **pport, char **ppath,\n                   int *pssl);\n\nint OCSP_id_issuer_cmp(OCSP_CERTID *a, OCSP_CERTID *b);\nint OCSP_id_cmp(OCSP_CERTID *a, OCSP_CERTID *b);\n\nint OCSP_request_onereq_count(OCSP_REQUEST *req);\nOCSP_ONEREQ *OCSP_request_onereq_get0(OCSP_REQUEST *req, int i);\nOCSP_CERTID *OCSP_onereq_get0_id(OCSP_ONEREQ *one);\nint OCSP_id_get0_info(ASN1_OCTET_STRING **piNameHash, ASN1_OBJECT **pmd,\n                      ASN1_OCTET_STRING **pikeyHash,\n                      ASN1_INTEGER **pserial, OCSP_CERTID *cid);\nint OCSP_request_is_signed(OCSP_REQUEST *req);\nOCSP_RESPONSE *OCSP_response_create(int status, OCSP_BASICRESP *bs);\nOCSP_SINGLERESP *OCSP_basic_add1_status(OCSP_BASICRESP *rsp,\n                                        OCSP_CERTID *cid,\n                                        int status, int reason,\n                                        ASN1_TIME *revtime,\n                                        ASN1_TIME *thisupd,\n                                        ASN1_TIME *nextupd);\nint OCSP_basic_add1_cert(OCSP_BASICRESP *resp, X509 *cert);\nint OCSP_basic_sign(OCSP_BASICRESP *brsp,\n                    X509 *signer, EVP_PKEY *key, const EVP_MD *dgst,\n                    STACK_OF(X509) *certs, unsigned long flags);\n\nX509_EXTENSION *OCSP_crlID_new(char *url, long *n, char *tim);\n\nX509_EXTENSION *OCSP_accept_responses_new(char **oids);\n\nX509_EXTENSION *OCSP_archive_cutoff_new(char *tim);\n\nX509_EXTENSION *OCSP_url_svcloc_new(X509_NAME *issuer, char **urls);\n\nint OCSP_REQUEST_get_ext_count(OCSP_REQUEST *x);\nint OCSP_REQUEST_get_ext_by_NID(OCSP_REQUEST *x, int nid, int lastpos);\nint OCSP_REQUEST_get_ext_by_OBJ(OCSP_REQUEST *x, ASN1_OBJECT *obj,\n                                int lastpos);\nint OCSP_REQUEST_get_ext_by_critical(OCSP_REQUEST *x, int crit, int lastpos);\nX509_EXTENSION *OCSP_REQUEST_get_ext(OCSP_REQUEST *x, int loc);\nX509_EXTENSION *OCSP_REQUEST_delete_ext(OCSP_REQUEST *x, int loc);\nvoid *OCSP_REQUEST_get1_ext_d2i(OCSP_REQUEST *x, int nid, int *crit,\n                                int *idx);\nint OCSP_REQUEST_add1_ext_i2d(OCSP_REQUEST *x, int nid, void *value, int crit,\n                              unsigned long flags);\nint OCSP_REQUEST_add_ext(OCSP_REQUEST *x, X509_EXTENSION *ex, int loc);\n\nint OCSP_ONEREQ_get_ext_count(OCSP_ONEREQ *x);\nint OCSP_ONEREQ_get_ext_by_NID(OCSP_ONEREQ *x, int nid, int lastpos);\nint OCSP_ONEREQ_get_ext_by_OBJ(OCSP_ONEREQ *x, ASN1_OBJECT *obj, int lastpos);\nint OCSP_ONEREQ_get_ext_by_critical(OCSP_ONEREQ *x, int crit, int lastpos);\nX509_EXTENSION *OCSP_ONEREQ_get_ext(OCSP_ONEREQ *x, int loc);\nX509_EXTENSION *OCSP_ONEREQ_delete_ext(OCSP_ONEREQ *x, int loc);\nvoid *OCSP_ONEREQ_get1_ext_d2i(OCSP_ONEREQ *x, int nid, int *crit, int *idx);\nint OCSP_ONEREQ_add1_ext_i2d(OCSP_ONEREQ *x, int nid, void *value, int crit,\n                             unsigned long flags);\nint OCSP_ONEREQ_add_ext(OCSP_ONEREQ *x, X509_EXTENSION *ex, int loc);\n\nint OCSP_BASICRESP_get_ext_count(OCSP_BASICRESP *x);\nint OCSP_BASICRESP_get_ext_by_NID(OCSP_BASICRESP *x, int nid, int lastpos);\nint OCSP_BASICRESP_get_ext_by_OBJ(OCSP_BASICRESP *x, ASN1_OBJECT *obj,\n                                  int lastpos);\nint OCSP_BASICRESP_get_ext_by_critical(OCSP_BASICRESP *x, int crit,\n                                       int lastpos);\nX509_EXTENSION *OCSP_BASICRESP_get_ext(OCSP_BASICRESP *x, int loc);\nX509_EXTENSION *OCSP_BASICRESP_delete_ext(OCSP_BASICRESP *x, int loc);\nvoid *OCSP_BASICRESP_get1_ext_d2i(OCSP_BASICRESP *x, int nid, int *crit,\n                                  int *idx);\nint OCSP_BASICRESP_add1_ext_i2d(OCSP_BASICRESP *x, int nid, void *value,\n                                int crit, unsigned long flags);\nint OCSP_BASICRESP_add_ext(OCSP_BASICRESP *x, X509_EXTENSION *ex, int loc);\n\nint OCSP_SINGLERESP_get_ext_count(OCSP_SINGLERESP *x);\nint OCSP_SINGLERESP_get_ext_by_NID(OCSP_SINGLERESP *x, int nid, int lastpos);\nint OCSP_SINGLERESP_get_ext_by_OBJ(OCSP_SINGLERESP *x, ASN1_OBJECT *obj,\n                                   int lastpos);\nint OCSP_SINGLERESP_get_ext_by_critical(OCSP_SINGLERESP *x, int crit,\n                                        int lastpos);\nX509_EXTENSION *OCSP_SINGLERESP_get_ext(OCSP_SINGLERESP *x, int loc);\nX509_EXTENSION *OCSP_SINGLERESP_delete_ext(OCSP_SINGLERESP *x, int loc);\nvoid *OCSP_SINGLERESP_get1_ext_d2i(OCSP_SINGLERESP *x, int nid, int *crit,\n                                   int *idx);\nint OCSP_SINGLERESP_add1_ext_i2d(OCSP_SINGLERESP *x, int nid, void *value,\n                                 int crit, unsigned long flags);\nint OCSP_SINGLERESP_add_ext(OCSP_SINGLERESP *x, X509_EXTENSION *ex, int loc);\n\nDECLARE_ASN1_FUNCTIONS(OCSP_SINGLERESP)\nDECLARE_ASN1_FUNCTIONS(OCSP_CERTSTATUS)\nDECLARE_ASN1_FUNCTIONS(OCSP_REVOKEDINFO)\nDECLARE_ASN1_FUNCTIONS(OCSP_BASICRESP)\nDECLARE_ASN1_FUNCTIONS(OCSP_RESPDATA)\nDECLARE_ASN1_FUNCTIONS(OCSP_RESPID)\nDECLARE_ASN1_FUNCTIONS(OCSP_RESPONSE)\nDECLARE_ASN1_FUNCTIONS(OCSP_RESPBYTES)\nDECLARE_ASN1_FUNCTIONS(OCSP_ONEREQ)\nDECLARE_ASN1_FUNCTIONS(OCSP_CERTID)\nDECLARE_ASN1_FUNCTIONS(OCSP_REQUEST)\nDECLARE_ASN1_FUNCTIONS(OCSP_SIGNATURE)\nDECLARE_ASN1_FUNCTIONS(OCSP_REQINFO)\nDECLARE_ASN1_FUNCTIONS(OCSP_CRLID)\nDECLARE_ASN1_FUNCTIONS(OCSP_SERVICELOC)\n\nconst char *OCSP_response_status_str(long s);\nconst char *OCSP_cert_status_str(long s);\nconst char *OCSP_crl_reason_str(long s);\n\nint OCSP_REQUEST_print(BIO *bp, OCSP_REQUEST *a, unsigned long flags);\nint OCSP_RESPONSE_print(BIO *bp, OCSP_RESPONSE *o, unsigned long flags);\n\nint OCSP_basic_verify(OCSP_BASICRESP *bs, STACK_OF(X509) *certs,\n                      X509_STORE *st, unsigned long flags);\n\n/* BEGIN ERROR CODES */\n/*\n * The following lines are auto generated by the script mkerr.pl. Any changes\n * made after this point may be overwritten when the script is next run.\n */\nvoid ERR_load_OCSP_strings(void);\n\n/* Error codes for the OCSP functions. */\n\n/* Function codes. */\n# define OCSP_F_ASN1_STRING_ENCODE                        100\n# define OCSP_F_D2I_OCSP_NONCE                            102\n# define OCSP_F_OCSP_BASIC_ADD1_STATUS                    103\n# define OCSP_F_OCSP_BASIC_SIGN                           104\n# define OCSP_F_OCSP_BASIC_VERIFY                         105\n# define OCSP_F_OCSP_CERT_ID_NEW                          101\n# define OCSP_F_OCSP_CHECK_DELEGATED                      106\n# define OCSP_F_OCSP_CHECK_IDS                            107\n# define OCSP_F_OCSP_CHECK_ISSUER                         108\n# define OCSP_F_OCSP_CHECK_VALIDITY                       115\n# define OCSP_F_OCSP_MATCH_ISSUERID                       109\n# define OCSP_F_OCSP_PARSE_URL                            114\n# define OCSP_F_OCSP_REQUEST_SIGN                         110\n# define OCSP_F_OCSP_REQUEST_VERIFY                       116\n# define OCSP_F_OCSP_RESPONSE_GET1_BASIC                  111\n# define OCSP_F_OCSP_SENDREQ_BIO                          112\n# define OCSP_F_OCSP_SENDREQ_NBIO                         117\n# define OCSP_F_PARSE_HTTP_LINE1                          118\n# define OCSP_F_REQUEST_VERIFY                            113\n\n/* Reason codes. */\n# define OCSP_R_BAD_DATA                                  100\n# define OCSP_R_CERTIFICATE_VERIFY_ERROR                  101\n# define OCSP_R_DIGEST_ERR                                102\n# define OCSP_R_ERROR_IN_NEXTUPDATE_FIELD                 122\n# define OCSP_R_ERROR_IN_THISUPDATE_FIELD                 123\n# define OCSP_R_ERROR_PARSING_URL                         121\n# define OCSP_R_MISSING_OCSPSIGNING_USAGE                 103\n# define OCSP_R_NEXTUPDATE_BEFORE_THISUPDATE              124\n# define OCSP_R_NOT_BASIC_RESPONSE                        104\n# define OCSP_R_NO_CERTIFICATES_IN_CHAIN                  105\n# define OCSP_R_NO_CONTENT                                106\n# define OCSP_R_NO_PUBLIC_KEY                             107\n# define OCSP_R_NO_RESPONSE_DATA                          108\n# define OCSP_R_NO_REVOKED_TIME                           109\n# define OCSP_R_PRIVATE_KEY_DOES_NOT_MATCH_CERTIFICATE    110\n# define OCSP_R_REQUEST_NOT_SIGNED                        128\n# define OCSP_R_RESPONSE_CONTAINS_NO_REVOCATION_DATA      111\n# define OCSP_R_ROOT_CA_NOT_TRUSTED                       112\n# define OCSP_R_SERVER_READ_ERROR                         113\n# define OCSP_R_SERVER_RESPONSE_ERROR                     114\n# define OCSP_R_SERVER_RESPONSE_PARSE_ERROR               115\n# define OCSP_R_SERVER_WRITE_ERROR                        116\n# define OCSP_R_SIGNATURE_FAILURE                         117\n# define OCSP_R_SIGNER_CERTIFICATE_NOT_FOUND              118\n# define OCSP_R_STATUS_EXPIRED                            125\n# define OCSP_R_STATUS_NOT_YET_VALID                      126\n# define OCSP_R_STATUS_TOO_OLD                            127\n# define OCSP_R_UNKNOWN_MESSAGE_DIGEST                    119\n# define OCSP_R_UNKNOWN_NID                               120\n# define OCSP_R_UNSUPPORTED_REQUESTORNAME_TYPE            129\n\n#ifdef  __cplusplus\n}\n#endif\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/x86_64/include/openssl/opensslconf.h",
    "content": "/* opensslconf.h */\n/* WARNING: Generated automatically from opensslconf.h.in by Configure. */\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n/* OpenSSL was configured with the following options: */\n#ifndef OPENSSL_DOING_MAKEDEPEND\n\n\n#ifndef OPENSSL_NO_CAST\n# define OPENSSL_NO_CAST\n#endif\n#ifndef OPENSSL_NO_COMP\n# define OPENSSL_NO_COMP\n#endif\n#ifndef OPENSSL_NO_DH\n# define OPENSSL_NO_DH\n#endif\n#ifndef OPENSSL_NO_DSA\n# define OPENSSL_NO_DSA\n#endif\n#ifndef OPENSSL_NO_EC\n# define OPENSSL_NO_EC\n#endif\n#ifndef OPENSSL_NO_EC_NISTP_64_GCC_128\n# define OPENSSL_NO_EC_NISTP_64_GCC_128\n#endif\n#ifndef OPENSSL_NO_ECDH\n# define OPENSSL_NO_ECDH\n#endif\n#ifndef OPENSSL_NO_ECDSA\n# define OPENSSL_NO_ECDSA\n#endif\n#ifndef OPENSSL_NO_ENGINE\n# define OPENSSL_NO_ENGINE\n#endif\n#ifndef OPENSSL_NO_FIPS\n# define OPENSSL_NO_FIPS\n#endif\n#ifndef OPENSSL_NO_GMP\n# define OPENSSL_NO_GMP\n#endif\n#ifndef OPENSSL_NO_GOST\n# define OPENSSL_NO_GOST\n#endif\n#ifndef OPENSSL_NO_JPAKE\n# define OPENSSL_NO_JPAKE\n#endif\n#ifndef OPENSSL_NO_KRB5\n# define OPENSSL_NO_KRB5\n#endif\n#ifndef OPENSSL_NO_LIBUNBOUND\n# define OPENSSL_NO_LIBUNBOUND\n#endif\n#ifndef OPENSSL_NO_MD2\n# define OPENSSL_NO_MD2\n#endif\n#ifndef OPENSSL_NO_MD4\n# define OPENSSL_NO_MD4\n#endif\n#ifndef OPENSSL_NO_MD5\n# define OPENSSL_NO_MD5\n#endif\n#ifndef OPENSSL_NO_MDC2\n# define OPENSSL_NO_MDC2\n#endif\n#ifndef OPENSSL_NO_RC2\n# define OPENSSL_NO_RC2\n#endif\n#ifndef OPENSSL_NO_RC5\n# define OPENSSL_NO_RC5\n#endif\n#ifndef OPENSSL_NO_RFC3779\n# define OPENSSL_NO_RFC3779\n#endif\n#ifndef OPENSSL_NO_RIPEMD\n# define OPENSSL_NO_RIPEMD\n#endif\n#ifndef OPENSSL_NO_RSA\n# define OPENSSL_NO_RSA\n#endif\n#ifndef OPENSSL_NO_SCTP\n# define OPENSSL_NO_SCTP\n#endif\n#ifndef OPENSSL_NO_SOCK\n# define OPENSSL_NO_SOCK\n#endif\n#ifndef OPENSSL_NO_SSL_TRACE\n# define OPENSSL_NO_SSL_TRACE\n#endif\n#ifndef OPENSSL_NO_SSL2\n# define OPENSSL_NO_SSL2\n#endif\n#ifndef OPENSSL_NO_SSL3\n# define OPENSSL_NO_SSL3\n#endif\n#ifndef OPENSSL_NO_STORE\n# define OPENSSL_NO_STORE\n#endif\n#ifndef OPENSSL_NO_TLS1\n# define OPENSSL_NO_TLS1\n#endif\n#ifndef OPENSSL_NO_UNIT_TEST\n# define OPENSSL_NO_UNIT_TEST\n#endif\n#ifndef OPENSSL_NO_WEAK_SSL_CIPHERS\n# define OPENSSL_NO_WEAK_SSL_CIPHERS\n#endif\n\n#endif /* OPENSSL_DOING_MAKEDEPEND */\n\n#ifndef OPENSSL_THREADS\n# define OPENSSL_THREADS\n#endif\n#ifndef OPENSSL_NO_HW\n# define OPENSSL_NO_HW\n#endif\n#ifndef OPENSSL_NO_DYNAMIC_ENGINE\n# define OPENSSL_NO_DYNAMIC_ENGINE\n#endif\n\n/* The OPENSSL_NO_* macros are also defined as NO_* if the application\n   asks for it.  This is a transient feature that is provided for those\n   who haven't had the time to do the appropriate changes in their\n   applications.  */\n#ifdef OPENSSL_ALGORITHM_DEFINES\n# if defined(OPENSSL_NO_CAST) && !defined(NO_CAST)\n#  define NO_CAST\n# endif\n# if defined(OPENSSL_NO_COMP) && !defined(NO_COMP)\n#  define NO_COMP\n# endif\n# if defined(OPENSSL_NO_DH) && !defined(NO_DH)\n#  define NO_DH\n# endif\n# if defined(OPENSSL_NO_DSA) && !defined(NO_DSA)\n#  define NO_DSA\n# endif\n# if defined(OPENSSL_NO_EC) && !defined(NO_EC)\n#  define NO_EC\n# endif\n# if defined(OPENSSL_NO_EC_NISTP_64_GCC_128) && !defined(NO_EC_NISTP_64_GCC_128)\n#  define NO_EC_NISTP_64_GCC_128\n# endif\n# if defined(OPENSSL_NO_ECDH) && !defined(NO_ECDH)\n#  define NO_ECDH\n# endif\n# if defined(OPENSSL_NO_ECDSA) && !defined(NO_ECDSA)\n#  define NO_ECDSA\n# endif\n# if defined(OPENSSL_NO_ENGINE) && !defined(NO_ENGINE)\n#  define NO_ENGINE\n# endif\n# if defined(OPENSSL_NO_FIPS) && !defined(NO_FIPS)\n#  define NO_FIPS\n# endif\n# if defined(OPENSSL_NO_GMP) && !defined(NO_GMP)\n#  define NO_GMP\n# endif\n# if defined(OPENSSL_NO_GOST) && !defined(NO_GOST)\n#  define NO_GOST\n# endif\n# if defined(OPENSSL_NO_JPAKE) && !defined(NO_JPAKE)\n#  define NO_JPAKE\n# endif\n# if defined(OPENSSL_NO_KRB5) && !defined(NO_KRB5)\n#  define NO_KRB5\n# endif\n# if defined(OPENSSL_NO_LIBUNBOUND) && !defined(NO_LIBUNBOUND)\n#  define NO_LIBUNBOUND\n# endif\n# if defined(OPENSSL_NO_MD2) && !defined(NO_MD2)\n#  define NO_MD2\n# endif\n# if defined(OPENSSL_NO_MD4) && !defined(NO_MD4)\n#  define NO_MD4\n# endif\n# if defined(OPENSSL_NO_MD5) && !defined(NO_MD5)\n#  define NO_MD5\n# endif\n# if defined(OPENSSL_NO_MDC2) && !defined(NO_MDC2)\n#  define NO_MDC2\n# endif\n# if defined(OPENSSL_NO_RC2) && !defined(NO_RC2)\n#  define NO_RC2\n# endif\n# if defined(OPENSSL_NO_RC5) && !defined(NO_RC5)\n#  define NO_RC5\n# endif\n# if defined(OPENSSL_NO_RFC3779) && !defined(NO_RFC3779)\n#  define NO_RFC3779\n# endif\n# if defined(OPENSSL_NO_RIPEMD) && !defined(NO_RIPEMD)\n#  define NO_RIPEMD\n# endif\n# if defined(OPENSSL_NO_RSA) && !defined(NO_RSA)\n#  define NO_RSA\n# endif\n# if defined(OPENSSL_NO_SCTP) && !defined(NO_SCTP)\n#  define NO_SCTP\n# endif\n# if defined(OPENSSL_NO_SOCK) && !defined(NO_SOCK)\n#  define NO_SOCK\n# endif\n# if defined(OPENSSL_NO_SSL_TRACE) && !defined(NO_SSL_TRACE)\n#  define NO_SSL_TRACE\n# endif\n# if defined(OPENSSL_NO_SSL2) && !defined(NO_SSL2)\n#  define NO_SSL2\n# endif\n# if defined(OPENSSL_NO_SSL3) && !defined(NO_SSL3)\n#  define NO_SSL3\n# endif\n# if defined(OPENSSL_NO_STORE) && !defined(NO_STORE)\n#  define NO_STORE\n# endif\n# if defined(OPENSSL_NO_TLS1) && !defined(NO_TLS1)\n#  define NO_TLS1\n# endif\n# if defined(OPENSSL_NO_UNIT_TEST) && !defined(NO_UNIT_TEST)\n#  define NO_UNIT_TEST\n# endif\n# if defined(OPENSSL_NO_WEAK_SSL_CIPHERS) && !defined(NO_WEAK_SSL_CIPHERS)\n#  define NO_WEAK_SSL_CIPHERS\n# endif\n#endif\n\n#define OPENSSL_CPUID_OBJ\n\n/* crypto/opensslconf.h.in */\n\n/* Generate 80386 code? */\n#undef I386_ONLY\n\n#if !(defined(VMS) || defined(__VMS)) /* VMS uses logical names instead */\n#if defined(HEADER_CRYPTLIB_H) && !defined(OPENSSLDIR)\n#define ENGINESDIR \"/c/projects/wcdb/android/prebuilt/x86_64/lib/engines\"\n#define OPENSSLDIR \"/c/projects/wcdb/android/prebuilt/x86_64\"\n#endif\n#endif\n\n#undef OPENSSL_UNISTD\n#define OPENSSL_UNISTD <unistd.h>\n\n#undef OPENSSL_EXPORT_VAR_AS_FUNCTION\n\n#if defined(HEADER_IDEA_H) && !defined(IDEA_INT)\n#define IDEA_INT unsigned int\n#endif\n\n#if defined(HEADER_MD2_H) && !defined(MD2_INT)\n#define MD2_INT unsigned int\n#endif\n\n#if defined(HEADER_RC2_H) && !defined(RC2_INT)\n/* I need to put in a mod for the alpha - eay */\n#define RC2_INT unsigned int\n#endif\n\n#if defined(HEADER_RC4_H)\n#if !defined(RC4_INT)\n/* using int types make the structure larger but make the code faster\n * on most boxes I have tested - up to %20 faster. */\n/*\n * I don't know what does \"most\" mean, but declaring \"int\" is a must on:\n * - Intel P6 because partial register stalls are very expensive;\n * - elder Alpha because it lacks byte load/store instructions;\n */\n#define RC4_INT unsigned int\n#endif\n#if !defined(RC4_CHUNK)\n/*\n * This enables code handling data aligned at natural CPU word\n * boundary. See crypto/rc4/rc4_enc.c for further details.\n */\n#define RC4_CHUNK unsigned long\n#endif\n#endif\n\n#if (defined(HEADER_NEW_DES_H) || defined(HEADER_DES_H)) && !defined(DES_LONG)\n/* If this is set to 'unsigned int' on a DEC Alpha, this gives about a\n * %20 speed up (longs are 8 bytes, int's are 4). */\n#ifndef DES_LONG\n#define DES_LONG unsigned int\n#endif\n#endif\n\n#if defined(HEADER_BN_H) && !defined(CONFIG_HEADER_BN_H)\n#define CONFIG_HEADER_BN_H\n#undef BN_LLONG\n\n/* Should we define BN_DIV2W here? */\n\n/* Only one for the following should be defined */\n#define SIXTY_FOUR_BIT_LONG\n#undef SIXTY_FOUR_BIT\n#undef THIRTY_TWO_BIT\n#endif\n\n#if defined(HEADER_RC4_LOCL_H) && !defined(CONFIG_HEADER_RC4_LOCL_H)\n#define CONFIG_HEADER_RC4_LOCL_H\n/* if this is defined data[i] is used instead of *data, this is a %20\n * speedup on x86 */\n#undef RC4_INDEX\n#endif\n\n#if defined(HEADER_BF_LOCL_H) && !defined(CONFIG_HEADER_BF_LOCL_H)\n#define CONFIG_HEADER_BF_LOCL_H\n#undef BF_PTR\n#endif /* HEADER_BF_LOCL_H */\n\n#if defined(HEADER_DES_LOCL_H) && !defined(CONFIG_HEADER_DES_LOCL_H)\n#define CONFIG_HEADER_DES_LOCL_H\n#ifndef DES_DEFAULT_OPTIONS\n/* the following is tweaked from a config script, that is why it is a\n * protected undef/define */\n#ifndef DES_PTR\n#undef DES_PTR\n#endif\n\n/* This helps C compiler generate the correct code for multiple functional\n * units.  It reduces register dependancies at the expense of 2 more\n * registers */\n#ifndef DES_RISC1\n#undef DES_RISC1\n#endif\n\n#ifndef DES_RISC2\n#undef DES_RISC2\n#endif\n\n#if defined(DES_RISC1) && defined(DES_RISC2)\n#error YOU SHOULD NOT HAVE BOTH DES_RISC1 AND DES_RISC2 DEFINED!!!!!\n#endif\n\n/* Unroll the inner loop, this sometimes helps, sometimes hinders.\n * Very mucy CPU dependant */\n#ifndef DES_UNROLL\n#define DES_UNROLL\n#endif\n\n/* These default values were supplied by\n * Peter Gutman <pgut001@cs.auckland.ac.nz>\n * They are only used if nothing else has been defined */\n#if !defined(DES_PTR) && !defined(DES_RISC1) && !defined(DES_RISC2) && !defined(DES_UNROLL)\n/* Special defines which change the way the code is built depending on the\n   CPU and OS.  For SGI machines you can use _MIPS_SZLONG (32 or 64) to find\n   even newer MIPS CPU's, but at the moment one size fits all for\n   optimization options.  Older Sparc's work better with only UNROLL, but\n   there's no way to tell at compile time what it is you're running on */\n \n#if defined( __sun ) || defined ( sun )\t\t/* Newer Sparc's */\n#  define DES_PTR\n#  define DES_RISC1\n#  define DES_UNROLL\n#elif defined( __ultrix )\t/* Older MIPS */\n#  define DES_PTR\n#  define DES_RISC2\n#  define DES_UNROLL\n#elif defined( __osf1__ )\t/* Alpha */\n#  define DES_PTR\n#  define DES_RISC2\n#elif defined ( _AIX )\t\t/* RS6000 */\n  /* Unknown */\n#elif defined( __hpux )\t\t/* HP-PA */\n  /* Unknown */\n#elif defined( __aux )\t\t/* 68K */\n  /* Unknown */\n#elif defined( __dgux )\t\t/* 88K (but P6 in latest boxes) */\n#  define DES_UNROLL\n#elif defined( __sgi )\t\t/* Newer MIPS */\n#  define DES_PTR\n#  define DES_RISC2\n#  define DES_UNROLL\n#elif defined(i386) || defined(__i386__)\t/* x86 boxes, should be gcc */\n#  define DES_PTR\n#  define DES_RISC1\n#  define DES_UNROLL\n#endif /* Systems-specific speed defines */\n#endif\n\n#endif /* DES_DEFAULT_OPTIONS */\n#endif /* HEADER_DES_LOCL_H */\n#ifdef  __cplusplus\n}\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/x86_64/include/openssl/opensslv.h",
    "content": "#ifndef HEADER_OPENSSLV_H\n# define HEADER_OPENSSLV_H\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n/*-\n * Numeric release version identifier:\n * MNNFFPPS: major minor fix patch status\n * The status nibble has one of the values 0 for development, 1 to e for betas\n * 1 to 14, and f for release.  The patch level is exactly that.\n * For example:\n * 0.9.3-dev      0x00903000\n * 0.9.3-beta1    0x00903001\n * 0.9.3-beta2-dev 0x00903002\n * 0.9.3-beta2    0x00903002 (same as ...beta2-dev)\n * 0.9.3          0x0090300f\n * 0.9.3a         0x0090301f\n * 0.9.4          0x0090400f\n * 1.2.3z         0x102031af\n *\n * For continuity reasons (because 0.9.5 is already out, and is coded\n * 0x00905100), between 0.9.5 and 0.9.6 the coding of the patch level\n * part is slightly different, by setting the highest bit.  This means\n * that 0.9.5a looks like this: 0x0090581f.  At 0.9.6, we can start\n * with 0x0090600S...\n *\n * (Prior to 0.9.3-dev a different scheme was used: 0.9.2b is 0x0922.)\n * (Prior to 0.9.5a beta1, a different scheme was used: MMNNFFRBB for\n *  major minor fix final patch/beta)\n */\n# define OPENSSL_VERSION_NUMBER  0x100020bfL\n# ifdef OPENSSL_FIPS\n#  define OPENSSL_VERSION_TEXT    \"OpenSSL 1.0.2k-fips  26 Jan 2017\"\n# else\n#  define OPENSSL_VERSION_TEXT    \"OpenSSL 1.0.2k  26 Jan 2017\"\n# endif\n# define OPENSSL_VERSION_PTEXT   \" part of \" OPENSSL_VERSION_TEXT\n\n/*-\n * The macros below are to be used for shared library (.so, .dll, ...)\n * versioning.  That kind of versioning works a bit differently between\n * operating systems.  The most usual scheme is to set a major and a minor\n * number, and have the runtime loader check that the major number is equal\n * to what it was at application link time, while the minor number has to\n * be greater or equal to what it was at application link time.  With this\n * scheme, the version number is usually part of the file name, like this:\n *\n *      libcrypto.so.0.9\n *\n * Some unixen also make a softlink with the major verson number only:\n *\n *      libcrypto.so.0\n *\n * On Tru64 and IRIX 6.x it works a little bit differently.  There, the\n * shared library version is stored in the file, and is actually a series\n * of versions, separated by colons.  The rightmost version present in the\n * library when linking an application is stored in the application to be\n * matched at run time.  When the application is run, a check is done to\n * see if the library version stored in the application matches any of the\n * versions in the version string of the library itself.\n * This version string can be constructed in any way, depending on what\n * kind of matching is desired.  However, to implement the same scheme as\n * the one used in the other unixen, all compatible versions, from lowest\n * to highest, should be part of the string.  Consecutive builds would\n * give the following versions strings:\n *\n *      3.0\n *      3.0:3.1\n *      3.0:3.1:3.2\n *      4.0\n *      4.0:4.1\n *\n * Notice how version 4 is completely incompatible with version, and\n * therefore give the breach you can see.\n *\n * There may be other schemes as well that I haven't yet discovered.\n *\n * So, here's the way it works here: first of all, the library version\n * number doesn't need at all to match the overall OpenSSL version.\n * However, it's nice and more understandable if it actually does.\n * The current library version is stored in the macro SHLIB_VERSION_NUMBER,\n * which is just a piece of text in the format \"M.m.e\" (Major, minor, edit).\n * For the sake of Tru64, IRIX, and any other OS that behaves in similar ways,\n * we need to keep a history of version numbers, which is done in the\n * macro SHLIB_VERSION_HISTORY.  The numbers are separated by colons and\n * should only keep the versions that are binary compatible with the current.\n */\n# define SHLIB_VERSION_HISTORY \"\"\n# define SHLIB_VERSION_NUMBER \"1.0.0\"\n\n\n#ifdef  __cplusplus\n}\n#endif\n#endif                          /* HEADER_OPENSSLV_H */\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/x86_64/include/openssl/ossl_typ.h",
    "content": "/* ====================================================================\n * Copyright (c) 1998-2001 The OpenSSL Project.  All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n *\n * 1. Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n *\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in\n *    the documentation and/or other materials provided with the\n *    distribution.\n *\n * 3. All advertising materials mentioning features or use of this\n *    software must display the following acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit. (http://www.openssl.org/)\"\n *\n * 4. The names \"OpenSSL Toolkit\" and \"OpenSSL Project\" must not be used to\n *    endorse or promote products derived from this software without\n *    prior written permission. For written permission, please contact\n *    openssl-core@openssl.org.\n *\n * 5. Products derived from this software may not be called \"OpenSSL\"\n *    nor may \"OpenSSL\" appear in their names without prior written\n *    permission of the OpenSSL Project.\n *\n * 6. Redistributions of any form whatsoever must retain the following\n *    acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit (http://www.openssl.org/)\"\n *\n * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY\n * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\n * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR\n * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\n * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,\n * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED\n * OF THE POSSIBILITY OF SUCH DAMAGE.\n * ====================================================================\n *\n * This product includes cryptographic software written by Eric Young\n * (eay@cryptsoft.com).  This product includes software written by Tim\n * Hudson (tjh@cryptsoft.com).\n *\n */\n\n#ifndef HEADER_OPENSSL_TYPES_H\n# define HEADER_OPENSSL_TYPES_H\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n# include <openssl/e_os2.h>\n\n# ifdef NO_ASN1_TYPEDEFS\n#  define ASN1_INTEGER            ASN1_STRING\n#  define ASN1_ENUMERATED         ASN1_STRING\n#  define ASN1_BIT_STRING         ASN1_STRING\n#  define ASN1_OCTET_STRING       ASN1_STRING\n#  define ASN1_PRINTABLESTRING    ASN1_STRING\n#  define ASN1_T61STRING          ASN1_STRING\n#  define ASN1_IA5STRING          ASN1_STRING\n#  define ASN1_UTCTIME            ASN1_STRING\n#  define ASN1_GENERALIZEDTIME    ASN1_STRING\n#  define ASN1_TIME               ASN1_STRING\n#  define ASN1_GENERALSTRING      ASN1_STRING\n#  define ASN1_UNIVERSALSTRING    ASN1_STRING\n#  define ASN1_BMPSTRING          ASN1_STRING\n#  define ASN1_VISIBLESTRING      ASN1_STRING\n#  define ASN1_UTF8STRING         ASN1_STRING\n#  define ASN1_BOOLEAN            int\n#  define ASN1_NULL               int\n# else\ntypedef struct asn1_string_st ASN1_INTEGER;\ntypedef struct asn1_string_st ASN1_ENUMERATED;\ntypedef struct asn1_string_st ASN1_BIT_STRING;\ntypedef struct asn1_string_st ASN1_OCTET_STRING;\ntypedef struct asn1_string_st ASN1_PRINTABLESTRING;\ntypedef struct asn1_string_st ASN1_T61STRING;\ntypedef struct asn1_string_st ASN1_IA5STRING;\ntypedef struct asn1_string_st ASN1_GENERALSTRING;\ntypedef struct asn1_string_st ASN1_UNIVERSALSTRING;\ntypedef struct asn1_string_st ASN1_BMPSTRING;\ntypedef struct asn1_string_st ASN1_UTCTIME;\ntypedef struct asn1_string_st ASN1_TIME;\ntypedef struct asn1_string_st ASN1_GENERALIZEDTIME;\ntypedef struct asn1_string_st ASN1_VISIBLESTRING;\ntypedef struct asn1_string_st ASN1_UTF8STRING;\ntypedef struct asn1_string_st ASN1_STRING;\ntypedef int ASN1_BOOLEAN;\ntypedef int ASN1_NULL;\n# endif\n\ntypedef struct asn1_object_st ASN1_OBJECT;\n\ntypedef struct ASN1_ITEM_st ASN1_ITEM;\ntypedef struct asn1_pctx_st ASN1_PCTX;\n\n# ifdef OPENSSL_SYS_WIN32\n#  undef X509_NAME\n#  undef X509_EXTENSIONS\n#  undef X509_CERT_PAIR\n#  undef PKCS7_ISSUER_AND_SERIAL\n#  undef OCSP_REQUEST\n#  undef OCSP_RESPONSE\n# endif\n\n# ifdef BIGNUM\n#  undef BIGNUM\n# endif\ntypedef struct bignum_st BIGNUM;\ntypedef struct bignum_ctx BN_CTX;\ntypedef struct bn_blinding_st BN_BLINDING;\ntypedef struct bn_mont_ctx_st BN_MONT_CTX;\ntypedef struct bn_recp_ctx_st BN_RECP_CTX;\ntypedef struct bn_gencb_st BN_GENCB;\n\ntypedef struct buf_mem_st BUF_MEM;\n\ntypedef struct evp_cipher_st EVP_CIPHER;\ntypedef struct evp_cipher_ctx_st EVP_CIPHER_CTX;\ntypedef struct env_md_st EVP_MD;\ntypedef struct env_md_ctx_st EVP_MD_CTX;\ntypedef struct evp_pkey_st EVP_PKEY;\n\ntypedef struct evp_pkey_asn1_method_st EVP_PKEY_ASN1_METHOD;\n\ntypedef struct evp_pkey_method_st EVP_PKEY_METHOD;\ntypedef struct evp_pkey_ctx_st EVP_PKEY_CTX;\n\ntypedef struct dh_st DH;\ntypedef struct dh_method DH_METHOD;\n\ntypedef struct dsa_st DSA;\ntypedef struct dsa_method DSA_METHOD;\n\ntypedef struct rsa_st RSA;\ntypedef struct rsa_meth_st RSA_METHOD;\n\ntypedef struct rand_meth_st RAND_METHOD;\n\ntypedef struct ecdh_method ECDH_METHOD;\ntypedef struct ecdsa_method ECDSA_METHOD;\n\ntypedef struct x509_st X509;\ntypedef struct X509_algor_st X509_ALGOR;\ntypedef struct X509_crl_st X509_CRL;\ntypedef struct x509_crl_method_st X509_CRL_METHOD;\ntypedef struct x509_revoked_st X509_REVOKED;\ntypedef struct X509_name_st X509_NAME;\ntypedef struct X509_pubkey_st X509_PUBKEY;\ntypedef struct x509_store_st X509_STORE;\ntypedef struct x509_store_ctx_st X509_STORE_CTX;\n\ntypedef struct pkcs8_priv_key_info_st PKCS8_PRIV_KEY_INFO;\n\ntypedef struct v3_ext_ctx X509V3_CTX;\ntypedef struct conf_st CONF;\n\ntypedef struct store_st STORE;\ntypedef struct store_method_st STORE_METHOD;\n\ntypedef struct ui_st UI;\ntypedef struct ui_method_st UI_METHOD;\n\ntypedef struct st_ERR_FNS ERR_FNS;\n\ntypedef struct engine_st ENGINE;\ntypedef struct ssl_st SSL;\ntypedef struct ssl_ctx_st SSL_CTX;\n\ntypedef struct comp_method_st COMP_METHOD;\n\ntypedef struct X509_POLICY_NODE_st X509_POLICY_NODE;\ntypedef struct X509_POLICY_LEVEL_st X509_POLICY_LEVEL;\ntypedef struct X509_POLICY_TREE_st X509_POLICY_TREE;\ntypedef struct X509_POLICY_CACHE_st X509_POLICY_CACHE;\n\ntypedef struct AUTHORITY_KEYID_st AUTHORITY_KEYID;\ntypedef struct DIST_POINT_st DIST_POINT;\ntypedef struct ISSUING_DIST_POINT_st ISSUING_DIST_POINT;\ntypedef struct NAME_CONSTRAINTS_st NAME_CONSTRAINTS;\n\n  /* If placed in pkcs12.h, we end up with a circular depency with pkcs7.h */\n# define DECLARE_PKCS12_STACK_OF(type)/* Nothing */\n# define IMPLEMENT_PKCS12_STACK_OF(type)/* Nothing */\n\ntypedef struct crypto_ex_data_st CRYPTO_EX_DATA;\n/* Callback types for crypto.h */\ntypedef int CRYPTO_EX_new (void *parent, void *ptr, CRYPTO_EX_DATA *ad,\n                           int idx, long argl, void *argp);\ntypedef void CRYPTO_EX_free (void *parent, void *ptr, CRYPTO_EX_DATA *ad,\n                             int idx, long argl, void *argp);\ntypedef int CRYPTO_EX_dup (CRYPTO_EX_DATA *to, CRYPTO_EX_DATA *from,\n                           void *from_d, int idx, long argl, void *argp);\n\ntypedef struct ocsp_req_ctx_st OCSP_REQ_CTX;\ntypedef struct ocsp_response_st OCSP_RESPONSE;\ntypedef struct ocsp_responder_id_st OCSP_RESPID;\n\n#ifdef  __cplusplus\n}\n#endif\n#endif                          /* def HEADER_OPENSSL_TYPES_H */\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/x86_64/include/openssl/pem.h",
    "content": "/* crypto/pem/pem.h */\n/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)\n * All rights reserved.\n *\n * This package is an SSL implementation written\n * by Eric Young (eay@cryptsoft.com).\n * The implementation was written so as to conform with Netscapes SSL.\n *\n * This library is free for commercial and non-commercial use as long as\n * the following conditions are aheared to.  The following conditions\n * apply to all code found in this distribution, be it the RC4, RSA,\n * lhash, DES, etc., code; not just the SSL code.  The SSL documentation\n * included with this distribution is covered by the same copyright terms\n * except that the holder is Tim Hudson (tjh@cryptsoft.com).\n *\n * Copyright remains Eric Young's, and as such any Copyright notices in\n * the code are not to be removed.\n * If this package is used in a product, Eric Young should be given attribution\n * as the author of the parts of the library used.\n * This can be in the form of a textual message at program startup or\n * in documentation (online or textual) provided with the package.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the copyright\n *    notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in the\n *    documentation and/or other materials provided with the distribution.\n * 3. All advertising materials mentioning features or use of this software\n *    must display the following acknowledgement:\n *    \"This product includes cryptographic software written by\n *     Eric Young (eay@cryptsoft.com)\"\n *    The word 'cryptographic' can be left out if the rouines from the library\n *    being used are not cryptographic related :-).\n * 4. If you include any Windows specific code (or a derivative thereof) from\n *    the apps directory (application code) you must include an acknowledgement:\n *    \"This product includes software written by Tim Hudson (tjh@cryptsoft.com)\"\n *\n * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n * SUCH DAMAGE.\n *\n * The licence and distribution terms for any publically available version or\n * derivative of this code cannot be changed.  i.e. this code cannot simply be\n * copied and put under another distribution licence\n * [including the GNU Public Licence.]\n */\n\n#ifndef HEADER_PEM_H\n# define HEADER_PEM_H\n\n# include <openssl/e_os2.h>\n# ifndef OPENSSL_NO_BIO\n#  include <openssl/bio.h>\n# endif\n# ifndef OPENSSL_NO_STACK\n#  include <openssl/stack.h>\n# endif\n# include <openssl/evp.h>\n# include <openssl/x509.h>\n# include <openssl/pem2.h>\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n# define PEM_BUFSIZE             1024\n\n# define PEM_OBJ_UNDEF           0\n# define PEM_OBJ_X509            1\n# define PEM_OBJ_X509_REQ        2\n# define PEM_OBJ_CRL             3\n# define PEM_OBJ_SSL_SESSION     4\n# define PEM_OBJ_PRIV_KEY        10\n# define PEM_OBJ_PRIV_RSA        11\n# define PEM_OBJ_PRIV_DSA        12\n# define PEM_OBJ_PRIV_DH         13\n# define PEM_OBJ_PUB_RSA         14\n# define PEM_OBJ_PUB_DSA         15\n# define PEM_OBJ_PUB_DH          16\n# define PEM_OBJ_DHPARAMS        17\n# define PEM_OBJ_DSAPARAMS       18\n# define PEM_OBJ_PRIV_RSA_PUBLIC 19\n# define PEM_OBJ_PRIV_ECDSA      20\n# define PEM_OBJ_PUB_ECDSA       21\n# define PEM_OBJ_ECPARAMETERS    22\n\n# define PEM_ERROR               30\n# define PEM_DEK_DES_CBC         40\n# define PEM_DEK_IDEA_CBC        45\n# define PEM_DEK_DES_EDE         50\n# define PEM_DEK_DES_ECB         60\n# define PEM_DEK_RSA             70\n# define PEM_DEK_RSA_MD2         80\n# define PEM_DEK_RSA_MD5         90\n\n# define PEM_MD_MD2              NID_md2\n# define PEM_MD_MD5              NID_md5\n# define PEM_MD_SHA              NID_sha\n# define PEM_MD_MD2_RSA          NID_md2WithRSAEncryption\n# define PEM_MD_MD5_RSA          NID_md5WithRSAEncryption\n# define PEM_MD_SHA_RSA          NID_sha1WithRSAEncryption\n\n# define PEM_STRING_X509_OLD     \"X509 CERTIFICATE\"\n# define PEM_STRING_X509         \"CERTIFICATE\"\n# define PEM_STRING_X509_PAIR    \"CERTIFICATE PAIR\"\n# define PEM_STRING_X509_TRUSTED \"TRUSTED CERTIFICATE\"\n# define PEM_STRING_X509_REQ_OLD \"NEW CERTIFICATE REQUEST\"\n# define PEM_STRING_X509_REQ     \"CERTIFICATE REQUEST\"\n# define PEM_STRING_X509_CRL     \"X509 CRL\"\n# define PEM_STRING_EVP_PKEY     \"ANY PRIVATE KEY\"\n# define PEM_STRING_PUBLIC       \"PUBLIC KEY\"\n# define PEM_STRING_RSA          \"RSA PRIVATE KEY\"\n# define PEM_STRING_RSA_PUBLIC   \"RSA PUBLIC KEY\"\n# define PEM_STRING_DSA          \"DSA PRIVATE KEY\"\n# define PEM_STRING_DSA_PUBLIC   \"DSA PUBLIC KEY\"\n# define PEM_STRING_PKCS7        \"PKCS7\"\n# define PEM_STRING_PKCS7_SIGNED \"PKCS #7 SIGNED DATA\"\n# define PEM_STRING_PKCS8        \"ENCRYPTED PRIVATE KEY\"\n# define PEM_STRING_PKCS8INF     \"PRIVATE KEY\"\n# define PEM_STRING_DHPARAMS     \"DH PARAMETERS\"\n# define PEM_STRING_DHXPARAMS    \"X9.42 DH PARAMETERS\"\n# define PEM_STRING_SSL_SESSION  \"SSL SESSION PARAMETERS\"\n# define PEM_STRING_DSAPARAMS    \"DSA PARAMETERS\"\n# define PEM_STRING_ECDSA_PUBLIC \"ECDSA PUBLIC KEY\"\n# define PEM_STRING_ECPARAMETERS \"EC PARAMETERS\"\n# define PEM_STRING_ECPRIVATEKEY \"EC PRIVATE KEY\"\n# define PEM_STRING_PARAMETERS   \"PARAMETERS\"\n# define PEM_STRING_CMS          \"CMS\"\n\n  /*\n   * Note that this structure is initialised by PEM_SealInit and cleaned up\n   * by PEM_SealFinal (at least for now)\n   */\ntypedef struct PEM_Encode_Seal_st {\n    EVP_ENCODE_CTX encode;\n    EVP_MD_CTX md;\n    EVP_CIPHER_CTX cipher;\n} PEM_ENCODE_SEAL_CTX;\n\n/* enc_type is one off */\n# define PEM_TYPE_ENCRYPTED      10\n# define PEM_TYPE_MIC_ONLY       20\n# define PEM_TYPE_MIC_CLEAR      30\n# define PEM_TYPE_CLEAR          40\n\ntypedef struct pem_recip_st {\n    char *name;\n    X509_NAME *dn;\n    int cipher;\n    int key_enc;\n    /*      char iv[8]; unused and wrong size */\n} PEM_USER;\n\ntypedef struct pem_ctx_st {\n    int type;                   /* what type of object */\n    struct {\n        int version;\n        int mode;\n    } proc_type;\n\n    char *domain;\n\n    struct {\n        int cipher;\n        /*-\n        unused, and wrong size\n        unsigned char iv[8]; */\n    } DEK_info;\n\n    PEM_USER *originator;\n\n    int num_recipient;\n    PEM_USER **recipient;\n/*-\n    XXX(ben): don#t think this is used!\n        STACK *x509_chain;      / * certificate chain */\n    EVP_MD *md;                 /* signature type */\n\n    int md_enc;                 /* is the md encrypted or not? */\n    int md_len;                 /* length of md_data */\n    char *md_data;              /* message digest, could be pkey encrypted */\n\n    EVP_CIPHER *dec;            /* date encryption cipher */\n    int key_len;                /* key length */\n    unsigned char *key;         /* key */\n  /*-\n    unused, and wrong size\n    unsigned char iv[8]; */\n\n    int data_enc;               /* is the data encrypted */\n    int data_len;\n    unsigned char *data;\n} PEM_CTX;\n\n/*\n * These macros make the PEM_read/PEM_write functions easier to maintain and\n * write. Now they are all implemented with either: IMPLEMENT_PEM_rw(...) or\n * IMPLEMENT_PEM_rw_cb(...)\n */\n\n# ifdef OPENSSL_NO_FP_API\n\n#  define IMPLEMENT_PEM_read_fp(name, type, str, asn1) /**/\n#  define IMPLEMENT_PEM_write_fp(name, type, str, asn1) /**/\n#  define IMPLEMENT_PEM_write_fp_const(name, type, str, asn1) /**/\n#  define IMPLEMENT_PEM_write_cb_fp(name, type, str, asn1) /**/\n#  define IMPLEMENT_PEM_write_cb_fp_const(name, type, str, asn1) /**/\n# else\n\n#  define IMPLEMENT_PEM_read_fp(name, type, str, asn1) \\\ntype *PEM_read_##name(FILE *fp, type **x, pem_password_cb *cb, void *u)\\\n{ \\\nreturn PEM_ASN1_read((d2i_of_void *)d2i_##asn1, str,fp,(void **)x,cb,u); \\\n}\n\n#  define IMPLEMENT_PEM_write_fp(name, type, str, asn1) \\\nint PEM_write_##name(FILE *fp, type *x) \\\n{ \\\nreturn PEM_ASN1_write((i2d_of_void *)i2d_##asn1,str,fp,x,NULL,NULL,0,NULL,NULL); \\\n}\n\n#  define IMPLEMENT_PEM_write_fp_const(name, type, str, asn1) \\\nint PEM_write_##name(FILE *fp, const type *x) \\\n{ \\\nreturn PEM_ASN1_write((i2d_of_void *)i2d_##asn1,str,fp,(void *)x,NULL,NULL,0,NULL,NULL); \\\n}\n\n#  define IMPLEMENT_PEM_write_cb_fp(name, type, str, asn1) \\\nint PEM_write_##name(FILE *fp, type *x, const EVP_CIPHER *enc, \\\n             unsigned char *kstr, int klen, pem_password_cb *cb, \\\n                  void *u) \\\n        { \\\n        return PEM_ASN1_write((i2d_of_void *)i2d_##asn1,str,fp,x,enc,kstr,klen,cb,u); \\\n        }\n\n#  define IMPLEMENT_PEM_write_cb_fp_const(name, type, str, asn1) \\\nint PEM_write_##name(FILE *fp, type *x, const EVP_CIPHER *enc, \\\n             unsigned char *kstr, int klen, pem_password_cb *cb, \\\n                  void *u) \\\n        { \\\n        return PEM_ASN1_write((i2d_of_void *)i2d_##asn1,str,fp,x,enc,kstr,klen,cb,u); \\\n        }\n\n# endif\n\n# define IMPLEMENT_PEM_read_bio(name, type, str, asn1) \\\ntype *PEM_read_bio_##name(BIO *bp, type **x, pem_password_cb *cb, void *u)\\\n{ \\\nreturn PEM_ASN1_read_bio((d2i_of_void *)d2i_##asn1, str,bp,(void **)x,cb,u); \\\n}\n\n# define IMPLEMENT_PEM_write_bio(name, type, str, asn1) \\\nint PEM_write_bio_##name(BIO *bp, type *x) \\\n{ \\\nreturn PEM_ASN1_write_bio((i2d_of_void *)i2d_##asn1,str,bp,x,NULL,NULL,0,NULL,NULL); \\\n}\n\n# define IMPLEMENT_PEM_write_bio_const(name, type, str, asn1) \\\nint PEM_write_bio_##name(BIO *bp, const type *x) \\\n{ \\\nreturn PEM_ASN1_write_bio((i2d_of_void *)i2d_##asn1,str,bp,(void *)x,NULL,NULL,0,NULL,NULL); \\\n}\n\n# define IMPLEMENT_PEM_write_cb_bio(name, type, str, asn1) \\\nint PEM_write_bio_##name(BIO *bp, type *x, const EVP_CIPHER *enc, \\\n             unsigned char *kstr, int klen, pem_password_cb *cb, void *u) \\\n        { \\\n        return PEM_ASN1_write_bio((i2d_of_void *)i2d_##asn1,str,bp,x,enc,kstr,klen,cb,u); \\\n        }\n\n# define IMPLEMENT_PEM_write_cb_bio_const(name, type, str, asn1) \\\nint PEM_write_bio_##name(BIO *bp, type *x, const EVP_CIPHER *enc, \\\n             unsigned char *kstr, int klen, pem_password_cb *cb, void *u) \\\n        { \\\n        return PEM_ASN1_write_bio((i2d_of_void *)i2d_##asn1,str,bp,(void *)x,enc,kstr,klen,cb,u); \\\n        }\n\n# define IMPLEMENT_PEM_write(name, type, str, asn1) \\\n        IMPLEMENT_PEM_write_bio(name, type, str, asn1) \\\n        IMPLEMENT_PEM_write_fp(name, type, str, asn1)\n\n# define IMPLEMENT_PEM_write_const(name, type, str, asn1) \\\n        IMPLEMENT_PEM_write_bio_const(name, type, str, asn1) \\\n        IMPLEMENT_PEM_write_fp_const(name, type, str, asn1)\n\n# define IMPLEMENT_PEM_write_cb(name, type, str, asn1) \\\n        IMPLEMENT_PEM_write_cb_bio(name, type, str, asn1) \\\n        IMPLEMENT_PEM_write_cb_fp(name, type, str, asn1)\n\n# define IMPLEMENT_PEM_write_cb_const(name, type, str, asn1) \\\n        IMPLEMENT_PEM_write_cb_bio_const(name, type, str, asn1) \\\n        IMPLEMENT_PEM_write_cb_fp_const(name, type, str, asn1)\n\n# define IMPLEMENT_PEM_read(name, type, str, asn1) \\\n        IMPLEMENT_PEM_read_bio(name, type, str, asn1) \\\n        IMPLEMENT_PEM_read_fp(name, type, str, asn1)\n\n# define IMPLEMENT_PEM_rw(name, type, str, asn1) \\\n        IMPLEMENT_PEM_read(name, type, str, asn1) \\\n        IMPLEMENT_PEM_write(name, type, str, asn1)\n\n# define IMPLEMENT_PEM_rw_const(name, type, str, asn1) \\\n        IMPLEMENT_PEM_read(name, type, str, asn1) \\\n        IMPLEMENT_PEM_write_const(name, type, str, asn1)\n\n# define IMPLEMENT_PEM_rw_cb(name, type, str, asn1) \\\n        IMPLEMENT_PEM_read(name, type, str, asn1) \\\n        IMPLEMENT_PEM_write_cb(name, type, str, asn1)\n\n/* These are the same except they are for the declarations */\n\n# if defined(OPENSSL_NO_FP_API)\n\n#  define DECLARE_PEM_read_fp(name, type) /**/\n#  define DECLARE_PEM_write_fp(name, type) /**/\n#  define DECLARE_PEM_write_cb_fp(name, type) /**/\n# else\n\n#  define DECLARE_PEM_read_fp(name, type) \\\n        type *PEM_read_##name(FILE *fp, type **x, pem_password_cb *cb, void *u);\n\n#  define DECLARE_PEM_write_fp(name, type) \\\n        int PEM_write_##name(FILE *fp, type *x);\n\n#  define DECLARE_PEM_write_fp_const(name, type) \\\n        int PEM_write_##name(FILE *fp, const type *x);\n\n#  define DECLARE_PEM_write_cb_fp(name, type) \\\n        int PEM_write_##name(FILE *fp, type *x, const EVP_CIPHER *enc, \\\n             unsigned char *kstr, int klen, pem_password_cb *cb, void *u);\n\n# endif\n\n# ifndef OPENSSL_NO_BIO\n#  define DECLARE_PEM_read_bio(name, type) \\\n        type *PEM_read_bio_##name(BIO *bp, type **x, pem_password_cb *cb, void *u);\n\n#  define DECLARE_PEM_write_bio(name, type) \\\n        int PEM_write_bio_##name(BIO *bp, type *x);\n\n#  define DECLARE_PEM_write_bio_const(name, type) \\\n        int PEM_write_bio_##name(BIO *bp, const type *x);\n\n#  define DECLARE_PEM_write_cb_bio(name, type) \\\n        int PEM_write_bio_##name(BIO *bp, type *x, const EVP_CIPHER *enc, \\\n             unsigned char *kstr, int klen, pem_password_cb *cb, void *u);\n\n# else\n\n#  define DECLARE_PEM_read_bio(name, type) /**/\n#  define DECLARE_PEM_write_bio(name, type) /**/\n#  define DECLARE_PEM_write_bio_const(name, type) /**/\n#  define DECLARE_PEM_write_cb_bio(name, type) /**/\n# endif\n# define DECLARE_PEM_write(name, type) \\\n        DECLARE_PEM_write_bio(name, type) \\\n        DECLARE_PEM_write_fp(name, type)\n# define DECLARE_PEM_write_const(name, type) \\\n        DECLARE_PEM_write_bio_const(name, type) \\\n        DECLARE_PEM_write_fp_const(name, type)\n# define DECLARE_PEM_write_cb(name, type) \\\n        DECLARE_PEM_write_cb_bio(name, type) \\\n        DECLARE_PEM_write_cb_fp(name, type)\n# define DECLARE_PEM_read(name, type) \\\n        DECLARE_PEM_read_bio(name, type) \\\n        DECLARE_PEM_read_fp(name, type)\n# define DECLARE_PEM_rw(name, type) \\\n        DECLARE_PEM_read(name, type) \\\n        DECLARE_PEM_write(name, type)\n# define DECLARE_PEM_rw_const(name, type) \\\n        DECLARE_PEM_read(name, type) \\\n        DECLARE_PEM_write_const(name, type)\n# define DECLARE_PEM_rw_cb(name, type) \\\n        DECLARE_PEM_read(name, type) \\\n        DECLARE_PEM_write_cb(name, type)\n# if 1\n/* \"userdata\": new with OpenSSL 0.9.4 */\ntypedef int pem_password_cb (char *buf, int size, int rwflag, void *userdata);\n# else\n/* OpenSSL 0.9.3, 0.9.3a */\ntypedef int pem_password_cb (char *buf, int size, int rwflag);\n# endif\n\nint PEM_get_EVP_CIPHER_INFO(char *header, EVP_CIPHER_INFO *cipher);\nint PEM_do_header(EVP_CIPHER_INFO *cipher, unsigned char *data, long *len,\n                  pem_password_cb *callback, void *u);\n\n# ifndef OPENSSL_NO_BIO\nint PEM_read_bio(BIO *bp, char **name, char **header,\n                 unsigned char **data, long *len);\nint PEM_write_bio(BIO *bp, const char *name, const char *hdr,\n                  const unsigned char *data, long len);\nint PEM_bytes_read_bio(unsigned char **pdata, long *plen, char **pnm,\n                       const char *name, BIO *bp, pem_password_cb *cb,\n                       void *u);\nvoid *PEM_ASN1_read_bio(d2i_of_void *d2i, const char *name, BIO *bp, void **x,\n                        pem_password_cb *cb, void *u);\nint PEM_ASN1_write_bio(i2d_of_void *i2d, const char *name, BIO *bp, void *x,\n                       const EVP_CIPHER *enc, unsigned char *kstr, int klen,\n                       pem_password_cb *cb, void *u);\n\nSTACK_OF(X509_INFO) *PEM_X509_INFO_read_bio(BIO *bp, STACK_OF(X509_INFO) *sk,\n                                            pem_password_cb *cb, void *u);\nint PEM_X509_INFO_write_bio(BIO *bp, X509_INFO *xi, EVP_CIPHER *enc,\n                            unsigned char *kstr, int klen,\n                            pem_password_cb *cd, void *u);\n# endif\n\nint PEM_read(FILE *fp, char **name, char **header,\n             unsigned char **data, long *len);\nint PEM_write(FILE *fp, const char *name, const char *hdr,\n              const unsigned char *data, long len);\nvoid *PEM_ASN1_read(d2i_of_void *d2i, const char *name, FILE *fp, void **x,\n                    pem_password_cb *cb, void *u);\nint PEM_ASN1_write(i2d_of_void *i2d, const char *name, FILE *fp,\n                   void *x, const EVP_CIPHER *enc, unsigned char *kstr,\n                   int klen, pem_password_cb *callback, void *u);\nSTACK_OF(X509_INFO) *PEM_X509_INFO_read(FILE *fp, STACK_OF(X509_INFO) *sk,\n                                        pem_password_cb *cb, void *u);\n\nint PEM_SealInit(PEM_ENCODE_SEAL_CTX *ctx, EVP_CIPHER *type,\n                 EVP_MD *md_type, unsigned char **ek, int *ekl,\n                 unsigned char *iv, EVP_PKEY **pubk, int npubk);\nvoid PEM_SealUpdate(PEM_ENCODE_SEAL_CTX *ctx, unsigned char *out, int *outl,\n                    unsigned char *in, int inl);\nint PEM_SealFinal(PEM_ENCODE_SEAL_CTX *ctx, unsigned char *sig, int *sigl,\n                  unsigned char *out, int *outl, EVP_PKEY *priv);\n\nvoid PEM_SignInit(EVP_MD_CTX *ctx, EVP_MD *type);\nvoid PEM_SignUpdate(EVP_MD_CTX *ctx, unsigned char *d, unsigned int cnt);\nint PEM_SignFinal(EVP_MD_CTX *ctx, unsigned char *sigret,\n                  unsigned int *siglen, EVP_PKEY *pkey);\n\nint PEM_def_callback(char *buf, int num, int w, void *key);\nvoid PEM_proc_type(char *buf, int type);\nvoid PEM_dek_info(char *buf, const char *type, int len, char *str);\n\n# include <openssl/symhacks.h>\n\nDECLARE_PEM_rw(X509, X509)\nDECLARE_PEM_rw(X509_AUX, X509)\nDECLARE_PEM_rw(X509_CERT_PAIR, X509_CERT_PAIR)\nDECLARE_PEM_rw(X509_REQ, X509_REQ)\nDECLARE_PEM_write(X509_REQ_NEW, X509_REQ)\nDECLARE_PEM_rw(X509_CRL, X509_CRL)\nDECLARE_PEM_rw(PKCS7, PKCS7)\nDECLARE_PEM_rw(NETSCAPE_CERT_SEQUENCE, NETSCAPE_CERT_SEQUENCE)\nDECLARE_PEM_rw(PKCS8, X509_SIG)\nDECLARE_PEM_rw(PKCS8_PRIV_KEY_INFO, PKCS8_PRIV_KEY_INFO)\n# ifndef OPENSSL_NO_RSA\nDECLARE_PEM_rw_cb(RSAPrivateKey, RSA)\nDECLARE_PEM_rw_const(RSAPublicKey, RSA)\nDECLARE_PEM_rw(RSA_PUBKEY, RSA)\n# endif\n# ifndef OPENSSL_NO_DSA\nDECLARE_PEM_rw_cb(DSAPrivateKey, DSA)\nDECLARE_PEM_rw(DSA_PUBKEY, DSA)\nDECLARE_PEM_rw_const(DSAparams, DSA)\n# endif\n# ifndef OPENSSL_NO_EC\nDECLARE_PEM_rw_const(ECPKParameters, EC_GROUP)\nDECLARE_PEM_rw_cb(ECPrivateKey, EC_KEY)\nDECLARE_PEM_rw(EC_PUBKEY, EC_KEY)\n# endif\n# ifndef OPENSSL_NO_DH\nDECLARE_PEM_rw_const(DHparams, DH)\nDECLARE_PEM_write_const(DHxparams, DH)\n# endif\nDECLARE_PEM_rw_cb(PrivateKey, EVP_PKEY)\nDECLARE_PEM_rw(PUBKEY, EVP_PKEY)\n\nint PEM_write_bio_PKCS8PrivateKey_nid(BIO *bp, EVP_PKEY *x, int nid,\n                                      char *kstr, int klen,\n                                      pem_password_cb *cb, void *u);\nint PEM_write_bio_PKCS8PrivateKey(BIO *, EVP_PKEY *, const EVP_CIPHER *,\n                                  char *, int, pem_password_cb *, void *);\nint i2d_PKCS8PrivateKey_bio(BIO *bp, EVP_PKEY *x, const EVP_CIPHER *enc,\n                            char *kstr, int klen,\n                            pem_password_cb *cb, void *u);\nint i2d_PKCS8PrivateKey_nid_bio(BIO *bp, EVP_PKEY *x, int nid,\n                                char *kstr, int klen,\n                                pem_password_cb *cb, void *u);\nEVP_PKEY *d2i_PKCS8PrivateKey_bio(BIO *bp, EVP_PKEY **x, pem_password_cb *cb,\n                                  void *u);\n\nint i2d_PKCS8PrivateKey_fp(FILE *fp, EVP_PKEY *x, const EVP_CIPHER *enc,\n                           char *kstr, int klen,\n                           pem_password_cb *cb, void *u);\nint i2d_PKCS8PrivateKey_nid_fp(FILE *fp, EVP_PKEY *x, int nid,\n                               char *kstr, int klen,\n                               pem_password_cb *cb, void *u);\nint PEM_write_PKCS8PrivateKey_nid(FILE *fp, EVP_PKEY *x, int nid,\n                                  char *kstr, int klen,\n                                  pem_password_cb *cb, void *u);\n\nEVP_PKEY *d2i_PKCS8PrivateKey_fp(FILE *fp, EVP_PKEY **x, pem_password_cb *cb,\n                                 void *u);\n\nint PEM_write_PKCS8PrivateKey(FILE *fp, EVP_PKEY *x, const EVP_CIPHER *enc,\n                              char *kstr, int klen, pem_password_cb *cd,\n                              void *u);\n\nEVP_PKEY *PEM_read_bio_Parameters(BIO *bp, EVP_PKEY **x);\nint PEM_write_bio_Parameters(BIO *bp, EVP_PKEY *x);\n\nEVP_PKEY *b2i_PrivateKey(const unsigned char **in, long length);\nEVP_PKEY *b2i_PublicKey(const unsigned char **in, long length);\nEVP_PKEY *b2i_PrivateKey_bio(BIO *in);\nEVP_PKEY *b2i_PublicKey_bio(BIO *in);\nint i2b_PrivateKey_bio(BIO *out, EVP_PKEY *pk);\nint i2b_PublicKey_bio(BIO *out, EVP_PKEY *pk);\n# ifndef OPENSSL_NO_RC4\nEVP_PKEY *b2i_PVK_bio(BIO *in, pem_password_cb *cb, void *u);\nint i2b_PVK_bio(BIO *out, EVP_PKEY *pk, int enclevel,\n                pem_password_cb *cb, void *u);\n# endif\n\n/* BEGIN ERROR CODES */\n/*\n * The following lines are auto generated by the script mkerr.pl. Any changes\n * made after this point may be overwritten when the script is next run.\n */\n\nvoid ERR_load_PEM_strings(void);\n\n/* Error codes for the PEM functions. */\n\n/* Function codes. */\n# define PEM_F_B2I_DSS                                    127\n# define PEM_F_B2I_PVK_BIO                                128\n# define PEM_F_B2I_RSA                                    129\n# define PEM_F_CHECK_BITLEN_DSA                           130\n# define PEM_F_CHECK_BITLEN_RSA                           131\n# define PEM_F_D2I_PKCS8PRIVATEKEY_BIO                    120\n# define PEM_F_D2I_PKCS8PRIVATEKEY_FP                     121\n# define PEM_F_DO_B2I                                     132\n# define PEM_F_DO_B2I_BIO                                 133\n# define PEM_F_DO_BLOB_HEADER                             134\n# define PEM_F_DO_PK8PKEY                                 126\n# define PEM_F_DO_PK8PKEY_FP                              125\n# define PEM_F_DO_PVK_BODY                                135\n# define PEM_F_DO_PVK_HEADER                              136\n# define PEM_F_I2B_PVK                                    137\n# define PEM_F_I2B_PVK_BIO                                138\n# define PEM_F_LOAD_IV                                    101\n# define PEM_F_PEM_ASN1_READ                              102\n# define PEM_F_PEM_ASN1_READ_BIO                          103\n# define PEM_F_PEM_ASN1_WRITE                             104\n# define PEM_F_PEM_ASN1_WRITE_BIO                         105\n# define PEM_F_PEM_DEF_CALLBACK                           100\n# define PEM_F_PEM_DO_HEADER                              106\n# define PEM_F_PEM_F_PEM_WRITE_PKCS8PRIVATEKEY            118\n# define PEM_F_PEM_GET_EVP_CIPHER_INFO                    107\n# define PEM_F_PEM_PK8PKEY                                119\n# define PEM_F_PEM_READ                                   108\n# define PEM_F_PEM_READ_BIO                               109\n# define PEM_F_PEM_READ_BIO_DHPARAMS                      141\n# define PEM_F_PEM_READ_BIO_PARAMETERS                    140\n# define PEM_F_PEM_READ_BIO_PRIVATEKEY                    123\n# define PEM_F_PEM_READ_DHPARAMS                          142\n# define PEM_F_PEM_READ_PRIVATEKEY                        124\n# define PEM_F_PEM_SEALFINAL                              110\n# define PEM_F_PEM_SEALINIT                               111\n# define PEM_F_PEM_SIGNFINAL                              112\n# define PEM_F_PEM_WRITE                                  113\n# define PEM_F_PEM_WRITE_BIO                              114\n# define PEM_F_PEM_WRITE_PRIVATEKEY                       139\n# define PEM_F_PEM_X509_INFO_READ                         115\n# define PEM_F_PEM_X509_INFO_READ_BIO                     116\n# define PEM_F_PEM_X509_INFO_WRITE_BIO                    117\n\n/* Reason codes. */\n# define PEM_R_BAD_BASE64_DECODE                          100\n# define PEM_R_BAD_DECRYPT                                101\n# define PEM_R_BAD_END_LINE                               102\n# define PEM_R_BAD_IV_CHARS                               103\n# define PEM_R_BAD_MAGIC_NUMBER                           116\n# define PEM_R_BAD_PASSWORD_READ                          104\n# define PEM_R_BAD_VERSION_NUMBER                         117\n# define PEM_R_BIO_WRITE_FAILURE                          118\n# define PEM_R_CIPHER_IS_NULL                             127\n# define PEM_R_ERROR_CONVERTING_PRIVATE_KEY               115\n# define PEM_R_EXPECTING_PRIVATE_KEY_BLOB                 119\n# define PEM_R_EXPECTING_PUBLIC_KEY_BLOB                  120\n# define PEM_R_HEADER_TOO_LONG                            128\n# define PEM_R_INCONSISTENT_HEADER                        121\n# define PEM_R_KEYBLOB_HEADER_PARSE_ERROR                 122\n# define PEM_R_KEYBLOB_TOO_SHORT                          123\n# define PEM_R_NOT_DEK_INFO                               105\n# define PEM_R_NOT_ENCRYPTED                              106\n# define PEM_R_NOT_PROC_TYPE                              107\n# define PEM_R_NO_START_LINE                              108\n# define PEM_R_PROBLEMS_GETTING_PASSWORD                  109\n# define PEM_R_PUBLIC_KEY_NO_RSA                          110\n# define PEM_R_PVK_DATA_TOO_SHORT                         124\n# define PEM_R_PVK_TOO_SHORT                              125\n# define PEM_R_READ_KEY                                   111\n# define PEM_R_SHORT_HEADER                               112\n# define PEM_R_UNSUPPORTED_CIPHER                         113\n# define PEM_R_UNSUPPORTED_ENCRYPTION                     114\n# define PEM_R_UNSUPPORTED_KEY_COMPONENTS                 126\n\n# ifdef  __cplusplus\n}\n# endif\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/x86_64/include/openssl/pem2.h",
    "content": "/* ====================================================================\n * Copyright (c) 1999 The OpenSSL Project.  All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n *\n * 1. Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n *\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in\n *    the documentation and/or other materials provided with the\n *    distribution.\n *\n * 3. All advertising materials mentioning features or use of this\n *    software must display the following acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)\"\n *\n * 4. The names \"OpenSSL Toolkit\" and \"OpenSSL Project\" must not be used to\n *    endorse or promote products derived from this software without\n *    prior written permission. For written permission, please contact\n *    licensing@OpenSSL.org.\n *\n * 5. Products derived from this software may not be called \"OpenSSL\"\n *    nor may \"OpenSSL\" appear in their names without prior written\n *    permission of the OpenSSL Project.\n *\n * 6. Redistributions of any form whatsoever must retain the following\n *    acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)\"\n *\n * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY\n * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\n * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR\n * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\n * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,\n * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED\n * OF THE POSSIBILITY OF SUCH DAMAGE.\n * ====================================================================\n *\n * This product includes cryptographic software written by Eric Young\n * (eay@cryptsoft.com).  This product includes software written by Tim\n * Hudson (tjh@cryptsoft.com).\n *\n */\n\n/*\n * This header only exists to break a circular dependency between pem and err\n * Ben 30 Jan 1999.\n */\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n#ifndef HEADER_PEM_H\nvoid ERR_load_PEM_strings(void);\n#endif\n\n#ifdef __cplusplus\n}\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/x86_64/include/openssl/pkcs12.h",
    "content": "/* pkcs12.h */\n/*\n * Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL project\n * 1999.\n */\n/* ====================================================================\n * Copyright (c) 1999 The OpenSSL Project.  All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n *\n * 1. Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n *\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in\n *    the documentation and/or other materials provided with the\n *    distribution.\n *\n * 3. All advertising materials mentioning features or use of this\n *    software must display the following acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)\"\n *\n * 4. The names \"OpenSSL Toolkit\" and \"OpenSSL Project\" must not be used to\n *    endorse or promote products derived from this software without\n *    prior written permission. For written permission, please contact\n *    licensing@OpenSSL.org.\n *\n * 5. Products derived from this software may not be called \"OpenSSL\"\n *    nor may \"OpenSSL\" appear in their names without prior written\n *    permission of the OpenSSL Project.\n *\n * 6. Redistributions of any form whatsoever must retain the following\n *    acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)\"\n *\n * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY\n * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\n * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR\n * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\n * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,\n * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED\n * OF THE POSSIBILITY OF SUCH DAMAGE.\n * ====================================================================\n *\n * This product includes cryptographic software written by Eric Young\n * (eay@cryptsoft.com).  This product includes software written by Tim\n * Hudson (tjh@cryptsoft.com).\n *\n */\n\n#ifndef HEADER_PKCS12_H\n# define HEADER_PKCS12_H\n\n# include <openssl/bio.h>\n# include <openssl/x509.h>\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n# define PKCS12_KEY_ID   1\n# define PKCS12_IV_ID    2\n# define PKCS12_MAC_ID   3\n\n/* Default iteration count */\n# ifndef PKCS12_DEFAULT_ITER\n#  define PKCS12_DEFAULT_ITER     PKCS5_DEFAULT_ITER\n# endif\n\n# define PKCS12_MAC_KEY_LENGTH 20\n\n# define PKCS12_SALT_LEN 8\n\n/* Uncomment out next line for unicode password and names, otherwise ASCII */\n\n/*\n * #define PBE_UNICODE\n */\n\n# ifdef PBE_UNICODE\n#  define PKCS12_key_gen PKCS12_key_gen_uni\n#  define PKCS12_add_friendlyname PKCS12_add_friendlyname_uni\n# else\n#  define PKCS12_key_gen PKCS12_key_gen_asc\n#  define PKCS12_add_friendlyname PKCS12_add_friendlyname_asc\n# endif\n\n/* MS key usage constants */\n\n# define KEY_EX  0x10\n# define KEY_SIG 0x80\n\ntypedef struct {\n    X509_SIG *dinfo;\n    ASN1_OCTET_STRING *salt;\n    ASN1_INTEGER *iter;         /* defaults to 1 */\n} PKCS12_MAC_DATA;\n\ntypedef struct {\n    ASN1_INTEGER *version;\n    PKCS12_MAC_DATA *mac;\n    PKCS7 *authsafes;\n} PKCS12;\n\ntypedef struct {\n    ASN1_OBJECT *type;\n    union {\n        struct pkcs12_bag_st *bag; /* secret, crl and certbag */\n        struct pkcs8_priv_key_info_st *keybag; /* keybag */\n        X509_SIG *shkeybag;     /* shrouded key bag */\n        STACK_OF(PKCS12_SAFEBAG) *safes;\n        ASN1_TYPE *other;\n    } value;\n    STACK_OF(X509_ATTRIBUTE) *attrib;\n} PKCS12_SAFEBAG;\n\nDECLARE_STACK_OF(PKCS12_SAFEBAG)\nDECLARE_ASN1_SET_OF(PKCS12_SAFEBAG)\nDECLARE_PKCS12_STACK_OF(PKCS12_SAFEBAG)\n\ntypedef struct pkcs12_bag_st {\n    ASN1_OBJECT *type;\n    union {\n        ASN1_OCTET_STRING *x509cert;\n        ASN1_OCTET_STRING *x509crl;\n        ASN1_OCTET_STRING *octet;\n        ASN1_IA5STRING *sdsicert;\n        ASN1_TYPE *other;       /* Secret or other bag */\n    } value;\n} PKCS12_BAGS;\n\n# define PKCS12_ERROR    0\n# define PKCS12_OK       1\n\n/* Compatibility macros */\n\n# define M_PKCS12_x5092certbag PKCS12_x5092certbag\n# define M_PKCS12_x509crl2certbag PKCS12_x509crl2certbag\n\n# define M_PKCS12_certbag2x509 PKCS12_certbag2x509\n# define M_PKCS12_certbag2x509crl PKCS12_certbag2x509crl\n\n# define M_PKCS12_unpack_p7data PKCS12_unpack_p7data\n# define M_PKCS12_pack_authsafes PKCS12_pack_authsafes\n# define M_PKCS12_unpack_authsafes PKCS12_unpack_authsafes\n# define M_PKCS12_unpack_p7encdata PKCS12_unpack_p7encdata\n\n# define M_PKCS12_decrypt_skey PKCS12_decrypt_skey\n# define M_PKCS8_decrypt PKCS8_decrypt\n\n# define M_PKCS12_bag_type(bg) OBJ_obj2nid((bg)->type)\n# define M_PKCS12_cert_bag_type(bg) OBJ_obj2nid((bg)->value.bag->type)\n# define M_PKCS12_crl_bag_type M_PKCS12_cert_bag_type\n\n# define PKCS12_get_attr(bag, attr_nid) \\\n                         PKCS12_get_attr_gen(bag->attrib, attr_nid)\n\n# define PKCS8_get_attr(p8, attr_nid) \\\n                PKCS12_get_attr_gen(p8->attributes, attr_nid)\n\n# define PKCS12_mac_present(p12) ((p12)->mac ? 1 : 0)\n\nPKCS12_SAFEBAG *PKCS12_x5092certbag(X509 *x509);\nPKCS12_SAFEBAG *PKCS12_x509crl2certbag(X509_CRL *crl);\nX509 *PKCS12_certbag2x509(PKCS12_SAFEBAG *bag);\nX509_CRL *PKCS12_certbag2x509crl(PKCS12_SAFEBAG *bag);\n\nPKCS12_SAFEBAG *PKCS12_item_pack_safebag(void *obj, const ASN1_ITEM *it,\n                                         int nid1, int nid2);\nPKCS12_SAFEBAG *PKCS12_MAKE_KEYBAG(PKCS8_PRIV_KEY_INFO *p8);\nPKCS8_PRIV_KEY_INFO *PKCS8_decrypt(X509_SIG *p8, const char *pass,\n                                   int passlen);\nPKCS8_PRIV_KEY_INFO *PKCS12_decrypt_skey(PKCS12_SAFEBAG *bag,\n                                         const char *pass, int passlen);\nX509_SIG *PKCS8_encrypt(int pbe_nid, const EVP_CIPHER *cipher,\n                        const char *pass, int passlen, unsigned char *salt,\n                        int saltlen, int iter, PKCS8_PRIV_KEY_INFO *p8);\nPKCS12_SAFEBAG *PKCS12_MAKE_SHKEYBAG(int pbe_nid, const char *pass,\n                                     int passlen, unsigned char *salt,\n                                     int saltlen, int iter,\n                                     PKCS8_PRIV_KEY_INFO *p8);\nPKCS7 *PKCS12_pack_p7data(STACK_OF(PKCS12_SAFEBAG) *sk);\nSTACK_OF(PKCS12_SAFEBAG) *PKCS12_unpack_p7data(PKCS7 *p7);\nPKCS7 *PKCS12_pack_p7encdata(int pbe_nid, const char *pass, int passlen,\n                             unsigned char *salt, int saltlen, int iter,\n                             STACK_OF(PKCS12_SAFEBAG) *bags);\nSTACK_OF(PKCS12_SAFEBAG) *PKCS12_unpack_p7encdata(PKCS7 *p7, const char *pass,\n                                                  int passlen);\n\nint PKCS12_pack_authsafes(PKCS12 *p12, STACK_OF(PKCS7) *safes);\nSTACK_OF(PKCS7) *PKCS12_unpack_authsafes(PKCS12 *p12);\n\nint PKCS12_add_localkeyid(PKCS12_SAFEBAG *bag, unsigned char *name,\n                          int namelen);\nint PKCS12_add_friendlyname_asc(PKCS12_SAFEBAG *bag, const char *name,\n                                int namelen);\nint PKCS12_add_CSPName_asc(PKCS12_SAFEBAG *bag, const char *name,\n                           int namelen);\nint PKCS12_add_friendlyname_uni(PKCS12_SAFEBAG *bag,\n                                const unsigned char *name, int namelen);\nint PKCS8_add_keyusage(PKCS8_PRIV_KEY_INFO *p8, int usage);\nASN1_TYPE *PKCS12_get_attr_gen(STACK_OF(X509_ATTRIBUTE) *attrs, int attr_nid);\nchar *PKCS12_get_friendlyname(PKCS12_SAFEBAG *bag);\nunsigned char *PKCS12_pbe_crypt(X509_ALGOR *algor, const char *pass,\n                                int passlen, unsigned char *in, int inlen,\n                                unsigned char **data, int *datalen,\n                                int en_de);\nvoid *PKCS12_item_decrypt_d2i(X509_ALGOR *algor, const ASN1_ITEM *it,\n                              const char *pass, int passlen,\n                              ASN1_OCTET_STRING *oct, int zbuf);\nASN1_OCTET_STRING *PKCS12_item_i2d_encrypt(X509_ALGOR *algor,\n                                           const ASN1_ITEM *it,\n                                           const char *pass, int passlen,\n                                           void *obj, int zbuf);\nPKCS12 *PKCS12_init(int mode);\nint PKCS12_key_gen_asc(const char *pass, int passlen, unsigned char *salt,\n                       int saltlen, int id, int iter, int n,\n                       unsigned char *out, const EVP_MD *md_type);\nint PKCS12_key_gen_uni(unsigned char *pass, int passlen, unsigned char *salt,\n                       int saltlen, int id, int iter, int n,\n                       unsigned char *out, const EVP_MD *md_type);\nint PKCS12_PBE_keyivgen(EVP_CIPHER_CTX *ctx, const char *pass, int passlen,\n                        ASN1_TYPE *param, const EVP_CIPHER *cipher,\n                        const EVP_MD *md_type, int en_de);\nint PKCS12_gen_mac(PKCS12 *p12, const char *pass, int passlen,\n                   unsigned char *mac, unsigned int *maclen);\nint PKCS12_verify_mac(PKCS12 *p12, const char *pass, int passlen);\nint PKCS12_set_mac(PKCS12 *p12, const char *pass, int passlen,\n                   unsigned char *salt, int saltlen, int iter,\n                   const EVP_MD *md_type);\nint PKCS12_setup_mac(PKCS12 *p12, int iter, unsigned char *salt,\n                     int saltlen, const EVP_MD *md_type);\nunsigned char *OPENSSL_asc2uni(const char *asc, int asclen,\n                               unsigned char **uni, int *unilen);\nchar *OPENSSL_uni2asc(unsigned char *uni, int unilen);\n\nDECLARE_ASN1_FUNCTIONS(PKCS12)\nDECLARE_ASN1_FUNCTIONS(PKCS12_MAC_DATA)\nDECLARE_ASN1_FUNCTIONS(PKCS12_SAFEBAG)\nDECLARE_ASN1_FUNCTIONS(PKCS12_BAGS)\n\nDECLARE_ASN1_ITEM(PKCS12_SAFEBAGS)\nDECLARE_ASN1_ITEM(PKCS12_AUTHSAFES)\n\nvoid PKCS12_PBE_add(void);\nint PKCS12_parse(PKCS12 *p12, const char *pass, EVP_PKEY **pkey, X509 **cert,\n                 STACK_OF(X509) **ca);\nPKCS12 *PKCS12_create(char *pass, char *name, EVP_PKEY *pkey, X509 *cert,\n                      STACK_OF(X509) *ca, int nid_key, int nid_cert, int iter,\n                      int mac_iter, int keytype);\n\nPKCS12_SAFEBAG *PKCS12_add_cert(STACK_OF(PKCS12_SAFEBAG) **pbags, X509 *cert);\nPKCS12_SAFEBAG *PKCS12_add_key(STACK_OF(PKCS12_SAFEBAG) **pbags,\n                               EVP_PKEY *key, int key_usage, int iter,\n                               int key_nid, char *pass);\nint PKCS12_add_safe(STACK_OF(PKCS7) **psafes, STACK_OF(PKCS12_SAFEBAG) *bags,\n                    int safe_nid, int iter, char *pass);\nPKCS12 *PKCS12_add_safes(STACK_OF(PKCS7) *safes, int p7_nid);\n\nint i2d_PKCS12_bio(BIO *bp, PKCS12 *p12);\nint i2d_PKCS12_fp(FILE *fp, PKCS12 *p12);\nPKCS12 *d2i_PKCS12_bio(BIO *bp, PKCS12 **p12);\nPKCS12 *d2i_PKCS12_fp(FILE *fp, PKCS12 **p12);\nint PKCS12_newpass(PKCS12 *p12, const char *oldpass, const char *newpass);\n\n/* BEGIN ERROR CODES */\n/*\n * The following lines are auto generated by the script mkerr.pl. Any changes\n * made after this point may be overwritten when the script is next run.\n */\nvoid ERR_load_PKCS12_strings(void);\n\n/* Error codes for the PKCS12 functions. */\n\n/* Function codes. */\n# define PKCS12_F_PARSE_BAG                               129\n# define PKCS12_F_PARSE_BAGS                              103\n# define PKCS12_F_PKCS12_ADD_FRIENDLYNAME                 100\n# define PKCS12_F_PKCS12_ADD_FRIENDLYNAME_ASC             127\n# define PKCS12_F_PKCS12_ADD_FRIENDLYNAME_UNI             102\n# define PKCS12_F_PKCS12_ADD_LOCALKEYID                   104\n# define PKCS12_F_PKCS12_CREATE                           105\n# define PKCS12_F_PKCS12_GEN_MAC                          107\n# define PKCS12_F_PKCS12_INIT                             109\n# define PKCS12_F_PKCS12_ITEM_DECRYPT_D2I                 106\n# define PKCS12_F_PKCS12_ITEM_I2D_ENCRYPT                 108\n# define PKCS12_F_PKCS12_ITEM_PACK_SAFEBAG                117\n# define PKCS12_F_PKCS12_KEY_GEN_ASC                      110\n# define PKCS12_F_PKCS12_KEY_GEN_UNI                      111\n# define PKCS12_F_PKCS12_MAKE_KEYBAG                      112\n# define PKCS12_F_PKCS12_MAKE_SHKEYBAG                    113\n# define PKCS12_F_PKCS12_NEWPASS                          128\n# define PKCS12_F_PKCS12_PACK_P7DATA                      114\n# define PKCS12_F_PKCS12_PACK_P7ENCDATA                   115\n# define PKCS12_F_PKCS12_PARSE                            118\n# define PKCS12_F_PKCS12_PBE_CRYPT                        119\n# define PKCS12_F_PKCS12_PBE_KEYIVGEN                     120\n# define PKCS12_F_PKCS12_SETUP_MAC                        122\n# define PKCS12_F_PKCS12_SET_MAC                          123\n# define PKCS12_F_PKCS12_UNPACK_AUTHSAFES                 130\n# define PKCS12_F_PKCS12_UNPACK_P7DATA                    131\n# define PKCS12_F_PKCS12_VERIFY_MAC                       126\n# define PKCS12_F_PKCS8_ADD_KEYUSAGE                      124\n# define PKCS12_F_PKCS8_ENCRYPT                           125\n\n/* Reason codes. */\n# define PKCS12_R_CANT_PACK_STRUCTURE                     100\n# define PKCS12_R_CONTENT_TYPE_NOT_DATA                   121\n# define PKCS12_R_DECODE_ERROR                            101\n# define PKCS12_R_ENCODE_ERROR                            102\n# define PKCS12_R_ENCRYPT_ERROR                           103\n# define PKCS12_R_ERROR_SETTING_ENCRYPTED_DATA_TYPE       120\n# define PKCS12_R_INVALID_NULL_ARGUMENT                   104\n# define PKCS12_R_INVALID_NULL_PKCS12_POINTER             105\n# define PKCS12_R_IV_GEN_ERROR                            106\n# define PKCS12_R_KEY_GEN_ERROR                           107\n# define PKCS12_R_MAC_ABSENT                              108\n# define PKCS12_R_MAC_GENERATION_ERROR                    109\n# define PKCS12_R_MAC_SETUP_ERROR                         110\n# define PKCS12_R_MAC_STRING_SET_ERROR                    111\n# define PKCS12_R_MAC_VERIFY_ERROR                        112\n# define PKCS12_R_MAC_VERIFY_FAILURE                      113\n# define PKCS12_R_PARSE_ERROR                             114\n# define PKCS12_R_PKCS12_ALGOR_CIPHERINIT_ERROR           115\n# define PKCS12_R_PKCS12_CIPHERFINAL_ERROR                116\n# define PKCS12_R_PKCS12_PBE_CRYPT_ERROR                  117\n# define PKCS12_R_UNKNOWN_DIGEST_ALGORITHM                118\n# define PKCS12_R_UNSUPPORTED_PKCS12_MODE                 119\n\n#ifdef  __cplusplus\n}\n#endif\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/x86_64/include/openssl/pkcs7.h",
    "content": "/* crypto/pkcs7/pkcs7.h */\n/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)\n * All rights reserved.\n *\n * This package is an SSL implementation written\n * by Eric Young (eay@cryptsoft.com).\n * The implementation was written so as to conform with Netscapes SSL.\n *\n * This library is free for commercial and non-commercial use as long as\n * the following conditions are aheared to.  The following conditions\n * apply to all code found in this distribution, be it the RC4, RSA,\n * lhash, DES, etc., code; not just the SSL code.  The SSL documentation\n * included with this distribution is covered by the same copyright terms\n * except that the holder is Tim Hudson (tjh@cryptsoft.com).\n *\n * Copyright remains Eric Young's, and as such any Copyright notices in\n * the code are not to be removed.\n * If this package is used in a product, Eric Young should be given attribution\n * as the author of the parts of the library used.\n * This can be in the form of a textual message at program startup or\n * in documentation (online or textual) provided with the package.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the copyright\n *    notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in the\n *    documentation and/or other materials provided with the distribution.\n * 3. All advertising materials mentioning features or use of this software\n *    must display the following acknowledgement:\n *    \"This product includes cryptographic software written by\n *     Eric Young (eay@cryptsoft.com)\"\n *    The word 'cryptographic' can be left out if the rouines from the library\n *    being used are not cryptographic related :-).\n * 4. If you include any Windows specific code (or a derivative thereof) from\n *    the apps directory (application code) you must include an acknowledgement:\n *    \"This product includes software written by Tim Hudson (tjh@cryptsoft.com)\"\n *\n * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n * SUCH DAMAGE.\n *\n * The licence and distribution terms for any publically available version or\n * derivative of this code cannot be changed.  i.e. this code cannot simply be\n * copied and put under another distribution licence\n * [including the GNU Public Licence.]\n */\n\n#ifndef HEADER_PKCS7_H\n# define HEADER_PKCS7_H\n\n# include <openssl/asn1.h>\n# include <openssl/bio.h>\n# include <openssl/e_os2.h>\n\n# include <openssl/symhacks.h>\n# include <openssl/ossl_typ.h>\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n# ifdef OPENSSL_SYS_WIN32\n/* Under Win32 thes are defined in wincrypt.h */\n#  undef PKCS7_ISSUER_AND_SERIAL\n#  undef PKCS7_SIGNER_INFO\n# endif\n\n/*-\nEncryption_ID           DES-CBC\nDigest_ID               MD5\nDigest_Encryption_ID    rsaEncryption\nKey_Encryption_ID       rsaEncryption\n*/\n\ntypedef struct pkcs7_issuer_and_serial_st {\n    X509_NAME *issuer;\n    ASN1_INTEGER *serial;\n} PKCS7_ISSUER_AND_SERIAL;\n\ntypedef struct pkcs7_signer_info_st {\n    ASN1_INTEGER *version;      /* version 1 */\n    PKCS7_ISSUER_AND_SERIAL *issuer_and_serial;\n    X509_ALGOR *digest_alg;\n    STACK_OF(X509_ATTRIBUTE) *auth_attr; /* [ 0 ] */\n    X509_ALGOR *digest_enc_alg;\n    ASN1_OCTET_STRING *enc_digest;\n    STACK_OF(X509_ATTRIBUTE) *unauth_attr; /* [ 1 ] */\n    /* The private key to sign with */\n    EVP_PKEY *pkey;\n} PKCS7_SIGNER_INFO;\n\nDECLARE_STACK_OF(PKCS7_SIGNER_INFO)\nDECLARE_ASN1_SET_OF(PKCS7_SIGNER_INFO)\n\ntypedef struct pkcs7_recip_info_st {\n    ASN1_INTEGER *version;      /* version 0 */\n    PKCS7_ISSUER_AND_SERIAL *issuer_and_serial;\n    X509_ALGOR *key_enc_algor;\n    ASN1_OCTET_STRING *enc_key;\n    X509 *cert;                 /* get the pub-key from this */\n} PKCS7_RECIP_INFO;\n\nDECLARE_STACK_OF(PKCS7_RECIP_INFO)\nDECLARE_ASN1_SET_OF(PKCS7_RECIP_INFO)\n\ntypedef struct pkcs7_signed_st {\n    ASN1_INTEGER *version;      /* version 1 */\n    STACK_OF(X509_ALGOR) *md_algs; /* md used */\n    STACK_OF(X509) *cert;       /* [ 0 ] */\n    STACK_OF(X509_CRL) *crl;    /* [ 1 ] */\n    STACK_OF(PKCS7_SIGNER_INFO) *signer_info;\n    struct pkcs7_st *contents;\n} PKCS7_SIGNED;\n/*\n * The above structure is very very similar to PKCS7_SIGN_ENVELOPE. How about\n * merging the two\n */\n\ntypedef struct pkcs7_enc_content_st {\n    ASN1_OBJECT *content_type;\n    X509_ALGOR *algorithm;\n    ASN1_OCTET_STRING *enc_data; /* [ 0 ] */\n    const EVP_CIPHER *cipher;\n} PKCS7_ENC_CONTENT;\n\ntypedef struct pkcs7_enveloped_st {\n    ASN1_INTEGER *version;      /* version 0 */\n    STACK_OF(PKCS7_RECIP_INFO) *recipientinfo;\n    PKCS7_ENC_CONTENT *enc_data;\n} PKCS7_ENVELOPE;\n\ntypedef struct pkcs7_signedandenveloped_st {\n    ASN1_INTEGER *version;      /* version 1 */\n    STACK_OF(X509_ALGOR) *md_algs; /* md used */\n    STACK_OF(X509) *cert;       /* [ 0 ] */\n    STACK_OF(X509_CRL) *crl;    /* [ 1 ] */\n    STACK_OF(PKCS7_SIGNER_INFO) *signer_info;\n    PKCS7_ENC_CONTENT *enc_data;\n    STACK_OF(PKCS7_RECIP_INFO) *recipientinfo;\n} PKCS7_SIGN_ENVELOPE;\n\ntypedef struct pkcs7_digest_st {\n    ASN1_INTEGER *version;      /* version 0 */\n    X509_ALGOR *md;             /* md used */\n    struct pkcs7_st *contents;\n    ASN1_OCTET_STRING *digest;\n} PKCS7_DIGEST;\n\ntypedef struct pkcs7_encrypted_st {\n    ASN1_INTEGER *version;      /* version 0 */\n    PKCS7_ENC_CONTENT *enc_data;\n} PKCS7_ENCRYPT;\n\ntypedef struct pkcs7_st {\n    /*\n     * The following is non NULL if it contains ASN1 encoding of this\n     * structure\n     */\n    unsigned char *asn1;\n    long length;\n# define PKCS7_S_HEADER  0\n# define PKCS7_S_BODY    1\n# define PKCS7_S_TAIL    2\n    int state;                  /* used during processing */\n    int detached;\n    ASN1_OBJECT *type;\n    /* content as defined by the type */\n    /*\n     * all encryption/message digests are applied to the 'contents', leaving\n     * out the 'type' field.\n     */\n    union {\n        char *ptr;\n        /* NID_pkcs7_data */\n        ASN1_OCTET_STRING *data;\n        /* NID_pkcs7_signed */\n        PKCS7_SIGNED *sign;\n        /* NID_pkcs7_enveloped */\n        PKCS7_ENVELOPE *enveloped;\n        /* NID_pkcs7_signedAndEnveloped */\n        PKCS7_SIGN_ENVELOPE *signed_and_enveloped;\n        /* NID_pkcs7_digest */\n        PKCS7_DIGEST *digest;\n        /* NID_pkcs7_encrypted */\n        PKCS7_ENCRYPT *encrypted;\n        /* Anything else */\n        ASN1_TYPE *other;\n    } d;\n} PKCS7;\n\nDECLARE_STACK_OF(PKCS7)\nDECLARE_ASN1_SET_OF(PKCS7)\nDECLARE_PKCS12_STACK_OF(PKCS7)\n\n# define PKCS7_OP_SET_DETACHED_SIGNATURE 1\n# define PKCS7_OP_GET_DETACHED_SIGNATURE 2\n\n# define PKCS7_get_signed_attributes(si) ((si)->auth_attr)\n# define PKCS7_get_attributes(si)        ((si)->unauth_attr)\n\n# define PKCS7_type_is_signed(a) (OBJ_obj2nid((a)->type) == NID_pkcs7_signed)\n# define PKCS7_type_is_encrypted(a) (OBJ_obj2nid((a)->type) == NID_pkcs7_encrypted)\n# define PKCS7_type_is_enveloped(a) (OBJ_obj2nid((a)->type) == NID_pkcs7_enveloped)\n# define PKCS7_type_is_signedAndEnveloped(a) \\\n                (OBJ_obj2nid((a)->type) == NID_pkcs7_signedAndEnveloped)\n# define PKCS7_type_is_data(a)   (OBJ_obj2nid((a)->type) == NID_pkcs7_data)\n# define PKCS7_type_is_digest(a)   (OBJ_obj2nid((a)->type) == NID_pkcs7_digest)\n\n# define PKCS7_set_detached(p,v) \\\n                PKCS7_ctrl(p,PKCS7_OP_SET_DETACHED_SIGNATURE,v,NULL)\n# define PKCS7_get_detached(p) \\\n                PKCS7_ctrl(p,PKCS7_OP_GET_DETACHED_SIGNATURE,0,NULL)\n\n# define PKCS7_is_detached(p7) (PKCS7_type_is_signed(p7) && PKCS7_get_detached(p7))\n\n/* S/MIME related flags */\n\n# define PKCS7_TEXT              0x1\n# define PKCS7_NOCERTS           0x2\n# define PKCS7_NOSIGS            0x4\n# define PKCS7_NOCHAIN           0x8\n# define PKCS7_NOINTERN          0x10\n# define PKCS7_NOVERIFY          0x20\n# define PKCS7_DETACHED          0x40\n# define PKCS7_BINARY            0x80\n# define PKCS7_NOATTR            0x100\n# define PKCS7_NOSMIMECAP        0x200\n# define PKCS7_NOOLDMIMETYPE     0x400\n# define PKCS7_CRLFEOL           0x800\n# define PKCS7_STREAM            0x1000\n# define PKCS7_NOCRL             0x2000\n# define PKCS7_PARTIAL           0x4000\n# define PKCS7_REUSE_DIGEST      0x8000\n\n/* Flags: for compatibility with older code */\n\n# define SMIME_TEXT      PKCS7_TEXT\n# define SMIME_NOCERTS   PKCS7_NOCERTS\n# define SMIME_NOSIGS    PKCS7_NOSIGS\n# define SMIME_NOCHAIN   PKCS7_NOCHAIN\n# define SMIME_NOINTERN  PKCS7_NOINTERN\n# define SMIME_NOVERIFY  PKCS7_NOVERIFY\n# define SMIME_DETACHED  PKCS7_DETACHED\n# define SMIME_BINARY    PKCS7_BINARY\n# define SMIME_NOATTR    PKCS7_NOATTR\n\nDECLARE_ASN1_FUNCTIONS(PKCS7_ISSUER_AND_SERIAL)\n\nint PKCS7_ISSUER_AND_SERIAL_digest(PKCS7_ISSUER_AND_SERIAL *data,\n                                   const EVP_MD *type, unsigned char *md,\n                                   unsigned int *len);\n# ifndef OPENSSL_NO_FP_API\nPKCS7 *d2i_PKCS7_fp(FILE *fp, PKCS7 **p7);\nint i2d_PKCS7_fp(FILE *fp, PKCS7 *p7);\n# endif\nPKCS7 *PKCS7_dup(PKCS7 *p7);\nPKCS7 *d2i_PKCS7_bio(BIO *bp, PKCS7 **p7);\nint i2d_PKCS7_bio(BIO *bp, PKCS7 *p7);\nint i2d_PKCS7_bio_stream(BIO *out, PKCS7 *p7, BIO *in, int flags);\nint PEM_write_bio_PKCS7_stream(BIO *out, PKCS7 *p7, BIO *in, int flags);\n\nDECLARE_ASN1_FUNCTIONS(PKCS7_SIGNER_INFO)\nDECLARE_ASN1_FUNCTIONS(PKCS7_RECIP_INFO)\nDECLARE_ASN1_FUNCTIONS(PKCS7_SIGNED)\nDECLARE_ASN1_FUNCTIONS(PKCS7_ENC_CONTENT)\nDECLARE_ASN1_FUNCTIONS(PKCS7_ENVELOPE)\nDECLARE_ASN1_FUNCTIONS(PKCS7_SIGN_ENVELOPE)\nDECLARE_ASN1_FUNCTIONS(PKCS7_DIGEST)\nDECLARE_ASN1_FUNCTIONS(PKCS7_ENCRYPT)\nDECLARE_ASN1_FUNCTIONS(PKCS7)\n\nDECLARE_ASN1_ITEM(PKCS7_ATTR_SIGN)\nDECLARE_ASN1_ITEM(PKCS7_ATTR_VERIFY)\n\nDECLARE_ASN1_NDEF_FUNCTION(PKCS7)\nDECLARE_ASN1_PRINT_FUNCTION(PKCS7)\n\nlong PKCS7_ctrl(PKCS7 *p7, int cmd, long larg, char *parg);\n\nint PKCS7_set_type(PKCS7 *p7, int type);\nint PKCS7_set0_type_other(PKCS7 *p7, int type, ASN1_TYPE *other);\nint PKCS7_set_content(PKCS7 *p7, PKCS7 *p7_data);\nint PKCS7_SIGNER_INFO_set(PKCS7_SIGNER_INFO *p7i, X509 *x509, EVP_PKEY *pkey,\n                          const EVP_MD *dgst);\nint PKCS7_SIGNER_INFO_sign(PKCS7_SIGNER_INFO *si);\nint PKCS7_add_signer(PKCS7 *p7, PKCS7_SIGNER_INFO *p7i);\nint PKCS7_add_certificate(PKCS7 *p7, X509 *x509);\nint PKCS7_add_crl(PKCS7 *p7, X509_CRL *x509);\nint PKCS7_content_new(PKCS7 *p7, int nid);\nint PKCS7_dataVerify(X509_STORE *cert_store, X509_STORE_CTX *ctx,\n                     BIO *bio, PKCS7 *p7, PKCS7_SIGNER_INFO *si);\nint PKCS7_signatureVerify(BIO *bio, PKCS7 *p7, PKCS7_SIGNER_INFO *si,\n                          X509 *x509);\n\nBIO *PKCS7_dataInit(PKCS7 *p7, BIO *bio);\nint PKCS7_dataFinal(PKCS7 *p7, BIO *bio);\nBIO *PKCS7_dataDecode(PKCS7 *p7, EVP_PKEY *pkey, BIO *in_bio, X509 *pcert);\n\nPKCS7_SIGNER_INFO *PKCS7_add_signature(PKCS7 *p7, X509 *x509,\n                                       EVP_PKEY *pkey, const EVP_MD *dgst);\nX509 *PKCS7_cert_from_signer_info(PKCS7 *p7, PKCS7_SIGNER_INFO *si);\nint PKCS7_set_digest(PKCS7 *p7, const EVP_MD *md);\nSTACK_OF(PKCS7_SIGNER_INFO) *PKCS7_get_signer_info(PKCS7 *p7);\n\nPKCS7_RECIP_INFO *PKCS7_add_recipient(PKCS7 *p7, X509 *x509);\nvoid PKCS7_SIGNER_INFO_get0_algs(PKCS7_SIGNER_INFO *si, EVP_PKEY **pk,\n                                 X509_ALGOR **pdig, X509_ALGOR **psig);\nvoid PKCS7_RECIP_INFO_get0_alg(PKCS7_RECIP_INFO *ri, X509_ALGOR **penc);\nint PKCS7_add_recipient_info(PKCS7 *p7, PKCS7_RECIP_INFO *ri);\nint PKCS7_RECIP_INFO_set(PKCS7_RECIP_INFO *p7i, X509 *x509);\nint PKCS7_set_cipher(PKCS7 *p7, const EVP_CIPHER *cipher);\nint PKCS7_stream(unsigned char ***boundary, PKCS7 *p7);\n\nPKCS7_ISSUER_AND_SERIAL *PKCS7_get_issuer_and_serial(PKCS7 *p7, int idx);\nASN1_OCTET_STRING *PKCS7_digest_from_attributes(STACK_OF(X509_ATTRIBUTE) *sk);\nint PKCS7_add_signed_attribute(PKCS7_SIGNER_INFO *p7si, int nid, int type,\n                               void *data);\nint PKCS7_add_attribute(PKCS7_SIGNER_INFO *p7si, int nid, int atrtype,\n                        void *value);\nASN1_TYPE *PKCS7_get_attribute(PKCS7_SIGNER_INFO *si, int nid);\nASN1_TYPE *PKCS7_get_signed_attribute(PKCS7_SIGNER_INFO *si, int nid);\nint PKCS7_set_signed_attributes(PKCS7_SIGNER_INFO *p7si,\n                                STACK_OF(X509_ATTRIBUTE) *sk);\nint PKCS7_set_attributes(PKCS7_SIGNER_INFO *p7si,\n                         STACK_OF(X509_ATTRIBUTE) *sk);\n\nPKCS7 *PKCS7_sign(X509 *signcert, EVP_PKEY *pkey, STACK_OF(X509) *certs,\n                  BIO *data, int flags);\n\nPKCS7_SIGNER_INFO *PKCS7_sign_add_signer(PKCS7 *p7,\n                                         X509 *signcert, EVP_PKEY *pkey,\n                                         const EVP_MD *md, int flags);\n\nint PKCS7_final(PKCS7 *p7, BIO *data, int flags);\nint PKCS7_verify(PKCS7 *p7, STACK_OF(X509) *certs, X509_STORE *store,\n                 BIO *indata, BIO *out, int flags);\nSTACK_OF(X509) *PKCS7_get0_signers(PKCS7 *p7, STACK_OF(X509) *certs,\n                                   int flags);\nPKCS7 *PKCS7_encrypt(STACK_OF(X509) *certs, BIO *in, const EVP_CIPHER *cipher,\n                     int flags);\nint PKCS7_decrypt(PKCS7 *p7, EVP_PKEY *pkey, X509 *cert, BIO *data,\n                  int flags);\n\nint PKCS7_add_attrib_smimecap(PKCS7_SIGNER_INFO *si,\n                              STACK_OF(X509_ALGOR) *cap);\nSTACK_OF(X509_ALGOR) *PKCS7_get_smimecap(PKCS7_SIGNER_INFO *si);\nint PKCS7_simple_smimecap(STACK_OF(X509_ALGOR) *sk, int nid, int arg);\n\nint PKCS7_add_attrib_content_type(PKCS7_SIGNER_INFO *si, ASN1_OBJECT *coid);\nint PKCS7_add0_attrib_signing_time(PKCS7_SIGNER_INFO *si, ASN1_TIME *t);\nint PKCS7_add1_attrib_digest(PKCS7_SIGNER_INFO *si,\n                             const unsigned char *md, int mdlen);\n\nint SMIME_write_PKCS7(BIO *bio, PKCS7 *p7, BIO *data, int flags);\nPKCS7 *SMIME_read_PKCS7(BIO *bio, BIO **bcont);\n\nBIO *BIO_new_PKCS7(BIO *out, PKCS7 *p7);\n\n/* BEGIN ERROR CODES */\n/*\n * The following lines are auto generated by the script mkerr.pl. Any changes\n * made after this point may be overwritten when the script is next run.\n */\nvoid ERR_load_PKCS7_strings(void);\n\n/* Error codes for the PKCS7 functions. */\n\n/* Function codes. */\n# define PKCS7_F_B64_READ_PKCS7                           120\n# define PKCS7_F_B64_WRITE_PKCS7                          121\n# define PKCS7_F_DO_PKCS7_SIGNED_ATTRIB                   136\n# define PKCS7_F_I2D_PKCS7_BIO_STREAM                     140\n# define PKCS7_F_PKCS7_ADD0_ATTRIB_SIGNING_TIME           135\n# define PKCS7_F_PKCS7_ADD_ATTRIB_SMIMECAP                118\n# define PKCS7_F_PKCS7_ADD_CERTIFICATE                    100\n# define PKCS7_F_PKCS7_ADD_CRL                            101\n# define PKCS7_F_PKCS7_ADD_RECIPIENT_INFO                 102\n# define PKCS7_F_PKCS7_ADD_SIGNATURE                      131\n# define PKCS7_F_PKCS7_ADD_SIGNER                         103\n# define PKCS7_F_PKCS7_BIO_ADD_DIGEST                     125\n# define PKCS7_F_PKCS7_COPY_EXISTING_DIGEST               138\n# define PKCS7_F_PKCS7_CTRL                               104\n# define PKCS7_F_PKCS7_DATADECODE                         112\n# define PKCS7_F_PKCS7_DATAFINAL                          128\n# define PKCS7_F_PKCS7_DATAINIT                           105\n# define PKCS7_F_PKCS7_DATASIGN                           106\n# define PKCS7_F_PKCS7_DATAVERIFY                         107\n# define PKCS7_F_PKCS7_DECRYPT                            114\n# define PKCS7_F_PKCS7_DECRYPT_RINFO                      133\n# define PKCS7_F_PKCS7_ENCODE_RINFO                       132\n# define PKCS7_F_PKCS7_ENCRYPT                            115\n# define PKCS7_F_PKCS7_FINAL                              134\n# define PKCS7_F_PKCS7_FIND_DIGEST                        127\n# define PKCS7_F_PKCS7_GET0_SIGNERS                       124\n# define PKCS7_F_PKCS7_RECIP_INFO_SET                     130\n# define PKCS7_F_PKCS7_SET_CIPHER                         108\n# define PKCS7_F_PKCS7_SET_CONTENT                        109\n# define PKCS7_F_PKCS7_SET_DIGEST                         126\n# define PKCS7_F_PKCS7_SET_TYPE                           110\n# define PKCS7_F_PKCS7_SIGN                               116\n# define PKCS7_F_PKCS7_SIGNATUREVERIFY                    113\n# define PKCS7_F_PKCS7_SIGNER_INFO_SET                    129\n# define PKCS7_F_PKCS7_SIGNER_INFO_SIGN                   139\n# define PKCS7_F_PKCS7_SIGN_ADD_SIGNER                    137\n# define PKCS7_F_PKCS7_SIMPLE_SMIMECAP                    119\n# define PKCS7_F_PKCS7_VERIFY                             117\n# define PKCS7_F_SMIME_READ_PKCS7                         122\n# define PKCS7_F_SMIME_TEXT                               123\n\n/* Reason codes. */\n# define PKCS7_R_CERTIFICATE_VERIFY_ERROR                 117\n# define PKCS7_R_CIPHER_HAS_NO_OBJECT_IDENTIFIER          144\n# define PKCS7_R_CIPHER_NOT_INITIALIZED                   116\n# define PKCS7_R_CONTENT_AND_DATA_PRESENT                 118\n# define PKCS7_R_CTRL_ERROR                               152\n# define PKCS7_R_DECODE_ERROR                             130\n# define PKCS7_R_DECRYPTED_KEY_IS_WRONG_LENGTH            100\n# define PKCS7_R_DECRYPT_ERROR                            119\n# define PKCS7_R_DIGEST_FAILURE                           101\n# define PKCS7_R_ENCRYPTION_CTRL_FAILURE                  149\n# define PKCS7_R_ENCRYPTION_NOT_SUPPORTED_FOR_THIS_KEY_TYPE 150\n# define PKCS7_R_ERROR_ADDING_RECIPIENT                   120\n# define PKCS7_R_ERROR_SETTING_CIPHER                     121\n# define PKCS7_R_INVALID_MIME_TYPE                        131\n# define PKCS7_R_INVALID_NULL_POINTER                     143\n# define PKCS7_R_INVALID_SIGNED_DATA_TYPE                 155\n# define PKCS7_R_MIME_NO_CONTENT_TYPE                     132\n# define PKCS7_R_MIME_PARSE_ERROR                         133\n# define PKCS7_R_MIME_SIG_PARSE_ERROR                     134\n# define PKCS7_R_MISSING_CERIPEND_INFO                    103\n# define PKCS7_R_NO_CONTENT                               122\n# define PKCS7_R_NO_CONTENT_TYPE                          135\n# define PKCS7_R_NO_DEFAULT_DIGEST                        151\n# define PKCS7_R_NO_MATCHING_DIGEST_TYPE_FOUND            154\n# define PKCS7_R_NO_MULTIPART_BODY_FAILURE                136\n# define PKCS7_R_NO_MULTIPART_BOUNDARY                    137\n# define PKCS7_R_NO_RECIPIENT_MATCHES_CERTIFICATE         115\n# define PKCS7_R_NO_RECIPIENT_MATCHES_KEY                 146\n# define PKCS7_R_NO_SIGNATURES_ON_DATA                    123\n# define PKCS7_R_NO_SIGNERS                               142\n# define PKCS7_R_NO_SIG_CONTENT_TYPE                      138\n# define PKCS7_R_OPERATION_NOT_SUPPORTED_ON_THIS_TYPE     104\n# define PKCS7_R_PKCS7_ADD_SIGNATURE_ERROR                124\n# define PKCS7_R_PKCS7_ADD_SIGNER_ERROR                   153\n# define PKCS7_R_PKCS7_DATAFINAL                          126\n# define PKCS7_R_PKCS7_DATAFINAL_ERROR                    125\n# define PKCS7_R_PKCS7_DATASIGN                           145\n# define PKCS7_R_PKCS7_PARSE_ERROR                        139\n# define PKCS7_R_PKCS7_SIG_PARSE_ERROR                    140\n# define PKCS7_R_PRIVATE_KEY_DOES_NOT_MATCH_CERTIFICATE   127\n# define PKCS7_R_SIGNATURE_FAILURE                        105\n# define PKCS7_R_SIGNER_CERTIFICATE_NOT_FOUND             128\n# define PKCS7_R_SIGNING_CTRL_FAILURE                     147\n# define PKCS7_R_SIGNING_NOT_SUPPORTED_FOR_THIS_KEY_TYPE  148\n# define PKCS7_R_SIG_INVALID_MIME_TYPE                    141\n# define PKCS7_R_SMIME_TEXT_ERROR                         129\n# define PKCS7_R_UNABLE_TO_FIND_CERTIFICATE               106\n# define PKCS7_R_UNABLE_TO_FIND_MEM_BIO                   107\n# define PKCS7_R_UNABLE_TO_FIND_MESSAGE_DIGEST            108\n# define PKCS7_R_UNKNOWN_DIGEST_TYPE                      109\n# define PKCS7_R_UNKNOWN_OPERATION                        110\n# define PKCS7_R_UNSUPPORTED_CIPHER_TYPE                  111\n# define PKCS7_R_UNSUPPORTED_CONTENT_TYPE                 112\n# define PKCS7_R_WRONG_CONTENT_TYPE                       113\n# define PKCS7_R_WRONG_PKCS7_TYPE                         114\n\n#ifdef  __cplusplus\n}\n#endif\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/x86_64/include/openssl/pqueue.h",
    "content": "/* crypto/pqueue/pqueue.h */\n/*\n * DTLS implementation written by Nagendra Modadugu\n * (nagendra@cs.stanford.edu) for the OpenSSL project 2005.\n */\n/* ====================================================================\n * Copyright (c) 1999-2005 The OpenSSL Project.  All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n *\n * 1. Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n *\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in\n *    the documentation and/or other materials provided with the\n *    distribution.\n *\n * 3. All advertising materials mentioning features or use of this\n *    software must display the following acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)\"\n *\n * 4. The names \"OpenSSL Toolkit\" and \"OpenSSL Project\" must not be used to\n *    endorse or promote products derived from this software without\n *    prior written permission. For written permission, please contact\n *    openssl-core@OpenSSL.org.\n *\n * 5. Products derived from this software may not be called \"OpenSSL\"\n *    nor may \"OpenSSL\" appear in their names without prior written\n *    permission of the OpenSSL Project.\n *\n * 6. Redistributions of any form whatsoever must retain the following\n *    acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)\"\n *\n * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY\n * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\n * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR\n * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\n * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,\n * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED\n * OF THE POSSIBILITY OF SUCH DAMAGE.\n * ====================================================================\n *\n * This product includes cryptographic software written by Eric Young\n * (eay@cryptsoft.com).  This product includes software written by Tim\n * Hudson (tjh@cryptsoft.com).\n *\n */\n\n#ifndef HEADER_PQUEUE_H\n# define HEADER_PQUEUE_H\n\n# include <stdio.h>\n# include <stdlib.h>\n# include <string.h>\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\ntypedef struct _pqueue *pqueue;\n\ntypedef struct _pitem {\n    unsigned char priority[8];  /* 64-bit value in big-endian encoding */\n    void *data;\n    struct _pitem *next;\n} pitem;\n\ntypedef struct _pitem *piterator;\n\npitem *pitem_new(unsigned char *prio64be, void *data);\nvoid pitem_free(pitem *item);\n\npqueue pqueue_new(void);\nvoid pqueue_free(pqueue pq);\n\npitem *pqueue_insert(pqueue pq, pitem *item);\npitem *pqueue_peek(pqueue pq);\npitem *pqueue_pop(pqueue pq);\npitem *pqueue_find(pqueue pq, unsigned char *prio64be);\npitem *pqueue_iterator(pqueue pq);\npitem *pqueue_next(piterator *iter);\n\nvoid pqueue_print(pqueue pq);\nint pqueue_size(pqueue pq);\n\n#ifdef  __cplusplus\n}\n#endif\n#endif                          /* ! HEADER_PQUEUE_H */\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/x86_64/include/openssl/rand.h",
    "content": "/* crypto/rand/rand.h */\n/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)\n * All rights reserved.\n *\n * This package is an SSL implementation written\n * by Eric Young (eay@cryptsoft.com).\n * The implementation was written so as to conform with Netscapes SSL.\n *\n * This library is free for commercial and non-commercial use as long as\n * the following conditions are aheared to.  The following conditions\n * apply to all code found in this distribution, be it the RC4, RSA,\n * lhash, DES, etc., code; not just the SSL code.  The SSL documentation\n * included with this distribution is covered by the same copyright terms\n * except that the holder is Tim Hudson (tjh@cryptsoft.com).\n *\n * Copyright remains Eric Young's, and as such any Copyright notices in\n * the code are not to be removed.\n * If this package is used in a product, Eric Young should be given attribution\n * as the author of the parts of the library used.\n * This can be in the form of a textual message at program startup or\n * in documentation (online or textual) provided with the package.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the copyright\n *    notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in the\n *    documentation and/or other materials provided with the distribution.\n * 3. All advertising materials mentioning features or use of this software\n *    must display the following acknowledgement:\n *    \"This product includes cryptographic software written by\n *     Eric Young (eay@cryptsoft.com)\"\n *    The word 'cryptographic' can be left out if the rouines from the library\n *    being used are not cryptographic related :-).\n * 4. If you include any Windows specific code (or a derivative thereof) from\n *    the apps directory (application code) you must include an acknowledgement:\n *    \"This product includes software written by Tim Hudson (tjh@cryptsoft.com)\"\n *\n * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n * SUCH DAMAGE.\n *\n * The licence and distribution terms for any publically available version or\n * derivative of this code cannot be changed.  i.e. this code cannot simply be\n * copied and put under another distribution licence\n * [including the GNU Public Licence.]\n */\n\n#ifndef HEADER_RAND_H\n# define HEADER_RAND_H\n\n# include <stdlib.h>\n# include <openssl/ossl_typ.h>\n# include <openssl/e_os2.h>\n\n# if defined(OPENSSL_SYS_WINDOWS)\n#  include <windows.h>\n# endif\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n# if defined(OPENSSL_FIPS)\n#  define FIPS_RAND_SIZE_T size_t\n# endif\n\n/* Already defined in ossl_typ.h */\n/* typedef struct rand_meth_st RAND_METHOD; */\n\nstruct rand_meth_st {\n    void (*seed) (const void *buf, int num);\n    int (*bytes) (unsigned char *buf, int num);\n    void (*cleanup) (void);\n    void (*add) (const void *buf, int num, double entropy);\n    int (*pseudorand) (unsigned char *buf, int num);\n    int (*status) (void);\n};\n\n# ifdef BN_DEBUG\nextern int rand_predictable;\n# endif\n\nint RAND_set_rand_method(const RAND_METHOD *meth);\nconst RAND_METHOD *RAND_get_rand_method(void);\n# ifndef OPENSSL_NO_ENGINE\nint RAND_set_rand_engine(ENGINE *engine);\n# endif\nRAND_METHOD *RAND_SSLeay(void);\nvoid RAND_cleanup(void);\nint RAND_bytes(unsigned char *buf, int num);\nint RAND_pseudo_bytes(unsigned char *buf, int num);\nvoid RAND_seed(const void *buf, int num);\nvoid RAND_add(const void *buf, int num, double entropy);\nint RAND_load_file(const char *file, long max_bytes);\nint RAND_write_file(const char *file);\nconst char *RAND_file_name(char *file, size_t num);\nint RAND_status(void);\nint RAND_query_egd_bytes(const char *path, unsigned char *buf, int bytes);\nint RAND_egd(const char *path);\nint RAND_egd_bytes(const char *path, int bytes);\nint RAND_poll(void);\n\n# if defined(OPENSSL_SYS_WINDOWS) || defined(OPENSSL_SYS_WIN32)\n\nvoid RAND_screen(void);\nint RAND_event(UINT, WPARAM, LPARAM);\n\n# endif\n\n# ifdef OPENSSL_FIPS\nvoid RAND_set_fips_drbg_type(int type, int flags);\nint RAND_init_fips(void);\n# endif\n\n/* BEGIN ERROR CODES */\n/*\n * The following lines are auto generated by the script mkerr.pl. Any changes\n * made after this point may be overwritten when the script is next run.\n */\nvoid ERR_load_RAND_strings(void);\n\n/* Error codes for the RAND functions. */\n\n/* Function codes. */\n# define RAND_F_RAND_GET_RAND_METHOD                      101\n# define RAND_F_RAND_INIT_FIPS                            102\n# define RAND_F_SSLEAY_RAND_BYTES                         100\n\n/* Reason codes. */\n# define RAND_R_DUAL_EC_DRBG_DISABLED                     104\n# define RAND_R_ERROR_INITIALISING_DRBG                   102\n# define RAND_R_ERROR_INSTANTIATING_DRBG                  103\n# define RAND_R_NO_FIPS_RANDOM_METHOD_SET                 101\n# define RAND_R_PRNG_NOT_SEEDED                           100\n\n#ifdef  __cplusplus\n}\n#endif\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/x86_64/include/openssl/rc4.h",
    "content": "/* crypto/rc4/rc4.h */\n/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)\n * All rights reserved.\n *\n * This package is an SSL implementation written\n * by Eric Young (eay@cryptsoft.com).\n * The implementation was written so as to conform with Netscapes SSL.\n *\n * This library is free for commercial and non-commercial use as long as\n * the following conditions are aheared to.  The following conditions\n * apply to all code found in this distribution, be it the RC4, RSA,\n * lhash, DES, etc., code; not just the SSL code.  The SSL documentation\n * included with this distribution is covered by the same copyright terms\n * except that the holder is Tim Hudson (tjh@cryptsoft.com).\n *\n * Copyright remains Eric Young's, and as such any Copyright notices in\n * the code are not to be removed.\n * If this package is used in a product, Eric Young should be given attribution\n * as the author of the parts of the library used.\n * This can be in the form of a textual message at program startup or\n * in documentation (online or textual) provided with the package.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the copyright\n *    notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in the\n *    documentation and/or other materials provided with the distribution.\n * 3. All advertising materials mentioning features or use of this software\n *    must display the following acknowledgement:\n *    \"This product includes cryptographic software written by\n *     Eric Young (eay@cryptsoft.com)\"\n *    The word 'cryptographic' can be left out if the rouines from the library\n *    being used are not cryptographic related :-).\n * 4. If you include any Windows specific code (or a derivative thereof) from\n *    the apps directory (application code) you must include an acknowledgement:\n *    \"This product includes software written by Tim Hudson (tjh@cryptsoft.com)\"\n *\n * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n * SUCH DAMAGE.\n *\n * The licence and distribution terms for any publically available version or\n * derivative of this code cannot be changed.  i.e. this code cannot simply be\n * copied and put under another distribution licence\n * [including the GNU Public Licence.]\n */\n\n#ifndef HEADER_RC4_H\n# define HEADER_RC4_H\n\n# include <openssl/opensslconf.h>/* OPENSSL_NO_RC4, RC4_INT */\n# ifdef OPENSSL_NO_RC4\n#  error RC4 is disabled.\n# endif\n\n# include <stddef.h>\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\ntypedef struct rc4_key_st {\n    RC4_INT x, y;\n    RC4_INT data[256];\n} RC4_KEY;\n\nconst char *RC4_options(void);\nvoid RC4_set_key(RC4_KEY *key, int len, const unsigned char *data);\nvoid private_RC4_set_key(RC4_KEY *key, int len, const unsigned char *data);\nvoid RC4(RC4_KEY *key, size_t len, const unsigned char *indata,\n         unsigned char *outdata);\n\n#ifdef  __cplusplus\n}\n#endif\n\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/x86_64/include/openssl/safestack.h",
    "content": "/* ====================================================================\n * Copyright (c) 1999 The OpenSSL Project.  All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n *\n * 1. Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n *\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in\n *    the documentation and/or other materials provided with the\n *    distribution.\n *\n * 3. All advertising materials mentioning features or use of this\n *    software must display the following acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit. (http://www.openssl.org/)\"\n *\n * 4. The names \"OpenSSL Toolkit\" and \"OpenSSL Project\" must not be used to\n *    endorse or promote products derived from this software without\n *    prior written permission. For written permission, please contact\n *    openssl-core@openssl.org.\n *\n * 5. Products derived from this software may not be called \"OpenSSL\"\n *    nor may \"OpenSSL\" appear in their names without prior written\n *    permission of the OpenSSL Project.\n *\n * 6. Redistributions of any form whatsoever must retain the following\n *    acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit (http://www.openssl.org/)\"\n *\n * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY\n * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\n * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR\n * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\n * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,\n * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED\n * OF THE POSSIBILITY OF SUCH DAMAGE.\n * ====================================================================\n *\n * This product includes cryptographic software written by Eric Young\n * (eay@cryptsoft.com).  This product includes software written by Tim\n * Hudson (tjh@cryptsoft.com).\n *\n */\n\n#ifndef HEADER_SAFESTACK_H\n# define HEADER_SAFESTACK_H\n\n# include <openssl/stack.h>\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n# ifndef CHECKED_PTR_OF\n#  define CHECKED_PTR_OF(type, p) \\\n    ((void*) (1 ? p : (type*)0))\n# endif\n\n/*\n * In C++ we get problems because an explicit cast is needed from (void *) we\n * use CHECKED_STACK_OF to ensure the correct type is passed in the macros\n * below.\n */\n\n# define CHECKED_STACK_OF(type, p) \\\n    ((_STACK*) (1 ? p : (STACK_OF(type)*)0))\n\n# define CHECKED_SK_COPY_FUNC(type, p) \\\n    ((void *(*)(void *)) ((1 ? p : (type *(*)(const type *))0)))\n\n# define CHECKED_SK_FREE_FUNC(type, p) \\\n    ((void (*)(void *)) ((1 ? p : (void (*)(type *))0)))\n\n# define CHECKED_SK_CMP_FUNC(type, p) \\\n    ((int (*)(const void *, const void *)) \\\n        ((1 ? p : (int (*)(const type * const *, const type * const *))0)))\n\n# define STACK_OF(type) struct stack_st_##type\n# define PREDECLARE_STACK_OF(type) STACK_OF(type);\n\n# define DECLARE_STACK_OF(type) \\\nSTACK_OF(type) \\\n    { \\\n    _STACK stack; \\\n    };\n# define DECLARE_SPECIAL_STACK_OF(type, type2) \\\nSTACK_OF(type) \\\n    { \\\n    _STACK stack; \\\n    };\n\n/* nada (obsolete in new safestack approach)*/\n# define IMPLEMENT_STACK_OF(type)\n\n/*-\n * Strings are special: normally an lhash entry will point to a single\n * (somewhat) mutable object. In the case of strings:\n *\n * a) Instead of a single char, there is an array of chars, NUL-terminated.\n * b) The string may have be immutable.\n *\n * So, they need their own declarations. Especially important for\n * type-checking tools, such as Deputy.\n *\n * In practice, however, it appears to be hard to have a const\n * string. For now, I'm settling for dealing with the fact it is a\n * string at all.\n */\ntypedef char *OPENSSL_STRING;\n\ntypedef const char *OPENSSL_CSTRING;\n\n/*\n * Confusingly, LHASH_OF(STRING) deals with char ** throughout, but\n * STACK_OF(STRING) is really more like STACK_OF(char), only, as mentioned\n * above, instead of a single char each entry is a NUL-terminated array of\n * chars. So, we have to implement STRING specially for STACK_OF. This is\n * dealt with in the autogenerated macros below.\n */\n\nDECLARE_SPECIAL_STACK_OF(OPENSSL_STRING, char)\n\n/*\n * Similarly, we sometimes use a block of characters, NOT nul-terminated.\n * These should also be distinguished from \"normal\" stacks.\n */\ntypedef void *OPENSSL_BLOCK;\nDECLARE_SPECIAL_STACK_OF(OPENSSL_BLOCK, void)\n\n/*\n * SKM_sk_... stack macros are internal to safestack.h: never use them\n * directly, use sk_<type>_... instead\n */\n# define SKM_sk_new(type, cmp) \\\n        ((STACK_OF(type) *)sk_new(CHECKED_SK_CMP_FUNC(type, cmp)))\n# define SKM_sk_new_null(type) \\\n        ((STACK_OF(type) *)sk_new_null())\n# define SKM_sk_free(type, st) \\\n        sk_free(CHECKED_STACK_OF(type, st))\n# define SKM_sk_num(type, st) \\\n        sk_num(CHECKED_STACK_OF(type, st))\n# define SKM_sk_value(type, st,i) \\\n        ((type *)sk_value(CHECKED_STACK_OF(type, st), i))\n# define SKM_sk_set(type, st,i,val) \\\n        sk_set(CHECKED_STACK_OF(type, st), i, CHECKED_PTR_OF(type, val))\n# define SKM_sk_zero(type, st) \\\n        sk_zero(CHECKED_STACK_OF(type, st))\n# define SKM_sk_push(type, st, val) \\\n        sk_push(CHECKED_STACK_OF(type, st), CHECKED_PTR_OF(type, val))\n# define SKM_sk_unshift(type, st, val) \\\n        sk_unshift(CHECKED_STACK_OF(type, st), CHECKED_PTR_OF(type, val))\n# define SKM_sk_find(type, st, val) \\\n        sk_find(CHECKED_STACK_OF(type, st), CHECKED_PTR_OF(type, val))\n# define SKM_sk_find_ex(type, st, val) \\\n        sk_find_ex(CHECKED_STACK_OF(type, st), \\\n                   CHECKED_PTR_OF(type, val))\n# define SKM_sk_delete(type, st, i) \\\n        (type *)sk_delete(CHECKED_STACK_OF(type, st), i)\n# define SKM_sk_delete_ptr(type, st, ptr) \\\n        (type *)sk_delete_ptr(CHECKED_STACK_OF(type, st), CHECKED_PTR_OF(type, ptr))\n# define SKM_sk_insert(type, st,val, i) \\\n        sk_insert(CHECKED_STACK_OF(type, st), CHECKED_PTR_OF(type, val), i)\n# define SKM_sk_set_cmp_func(type, st, cmp) \\\n        ((int (*)(const type * const *,const type * const *)) \\\n        sk_set_cmp_func(CHECKED_STACK_OF(type, st), CHECKED_SK_CMP_FUNC(type, cmp)))\n# define SKM_sk_dup(type, st) \\\n        (STACK_OF(type) *)sk_dup(CHECKED_STACK_OF(type, st))\n# define SKM_sk_pop_free(type, st, free_func) \\\n        sk_pop_free(CHECKED_STACK_OF(type, st), CHECKED_SK_FREE_FUNC(type, free_func))\n# define SKM_sk_deep_copy(type, st, copy_func, free_func) \\\n        (STACK_OF(type) *)sk_deep_copy(CHECKED_STACK_OF(type, st), CHECKED_SK_COPY_FUNC(type, copy_func), CHECKED_SK_FREE_FUNC(type, free_func))\n# define SKM_sk_shift(type, st) \\\n        (type *)sk_shift(CHECKED_STACK_OF(type, st))\n# define SKM_sk_pop(type, st) \\\n        (type *)sk_pop(CHECKED_STACK_OF(type, st))\n# define SKM_sk_sort(type, st) \\\n        sk_sort(CHECKED_STACK_OF(type, st))\n# define SKM_sk_is_sorted(type, st) \\\n        sk_is_sorted(CHECKED_STACK_OF(type, st))\n# define SKM_ASN1_SET_OF_d2i(type, st, pp, length, d2i_func, free_func, ex_tag, ex_class) \\\n  (STACK_OF(type) *)d2i_ASN1_SET( \\\n                                (STACK_OF(OPENSSL_BLOCK) **)CHECKED_PTR_OF(STACK_OF(type)*, st), \\\n                                pp, length, \\\n                                CHECKED_D2I_OF(type, d2i_func), \\\n                                CHECKED_SK_FREE_FUNC(type, free_func), \\\n                                ex_tag, ex_class)\n# define SKM_ASN1_SET_OF_i2d(type, st, pp, i2d_func, ex_tag, ex_class, is_set) \\\n  i2d_ASN1_SET((STACK_OF(OPENSSL_BLOCK) *)CHECKED_STACK_OF(type, st), pp, \\\n                                CHECKED_I2D_OF(type, i2d_func), \\\n                                ex_tag, ex_class, is_set)\n# define SKM_ASN1_seq_pack(type, st, i2d_func, buf, len) \\\n        ASN1_seq_pack(CHECKED_PTR_OF(STACK_OF(type), st), \\\n                        CHECKED_I2D_OF(type, i2d_func), buf, len)\n# define SKM_ASN1_seq_unpack(type, buf, len, d2i_func, free_func) \\\n        (STACK_OF(type) *)ASN1_seq_unpack(buf, len, CHECKED_D2I_OF(type, d2i_func), CHECKED_SK_FREE_FUNC(type, free_func))\n# define SKM_PKCS12_decrypt_d2i(type, algor, d2i_func, free_func, pass, passlen, oct, seq) \\\n        (STACK_OF(type) *)PKCS12_decrypt_d2i(algor, \\\n                                CHECKED_D2I_OF(type, d2i_func), \\\n                                CHECKED_SK_FREE_FUNC(type, free_func), \\\n                                pass, passlen, oct, seq)\n/*\n * This block of defines is updated by util/mkstack.pl, please do not touch!\n */\n# define sk_ACCESS_DESCRIPTION_new(cmp) SKM_sk_new(ACCESS_DESCRIPTION, (cmp))\n# define sk_ACCESS_DESCRIPTION_new_null() SKM_sk_new_null(ACCESS_DESCRIPTION)\n# define sk_ACCESS_DESCRIPTION_free(st) SKM_sk_free(ACCESS_DESCRIPTION, (st))\n# define sk_ACCESS_DESCRIPTION_num(st) SKM_sk_num(ACCESS_DESCRIPTION, (st))\n# define sk_ACCESS_DESCRIPTION_value(st, i) SKM_sk_value(ACCESS_DESCRIPTION, (st), (i))\n# define sk_ACCESS_DESCRIPTION_set(st, i, val) SKM_sk_set(ACCESS_DESCRIPTION, (st), (i), (val))\n# define sk_ACCESS_DESCRIPTION_zero(st) SKM_sk_zero(ACCESS_DESCRIPTION, (st))\n# define sk_ACCESS_DESCRIPTION_push(st, val) SKM_sk_push(ACCESS_DESCRIPTION, (st), (val))\n# define sk_ACCESS_DESCRIPTION_unshift(st, val) SKM_sk_unshift(ACCESS_DESCRIPTION, (st), (val))\n# define sk_ACCESS_DESCRIPTION_find(st, val) SKM_sk_find(ACCESS_DESCRIPTION, (st), (val))\n# define sk_ACCESS_DESCRIPTION_find_ex(st, val) SKM_sk_find_ex(ACCESS_DESCRIPTION, (st), (val))\n# define sk_ACCESS_DESCRIPTION_delete(st, i) SKM_sk_delete(ACCESS_DESCRIPTION, (st), (i))\n# define sk_ACCESS_DESCRIPTION_delete_ptr(st, ptr) SKM_sk_delete_ptr(ACCESS_DESCRIPTION, (st), (ptr))\n# define sk_ACCESS_DESCRIPTION_insert(st, val, i) SKM_sk_insert(ACCESS_DESCRIPTION, (st), (val), (i))\n# define sk_ACCESS_DESCRIPTION_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(ACCESS_DESCRIPTION, (st), (cmp))\n# define sk_ACCESS_DESCRIPTION_dup(st) SKM_sk_dup(ACCESS_DESCRIPTION, st)\n# define sk_ACCESS_DESCRIPTION_pop_free(st, free_func) SKM_sk_pop_free(ACCESS_DESCRIPTION, (st), (free_func))\n# define sk_ACCESS_DESCRIPTION_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(ACCESS_DESCRIPTION, (st), (copy_func), (free_func))\n# define sk_ACCESS_DESCRIPTION_shift(st) SKM_sk_shift(ACCESS_DESCRIPTION, (st))\n# define sk_ACCESS_DESCRIPTION_pop(st) SKM_sk_pop(ACCESS_DESCRIPTION, (st))\n# define sk_ACCESS_DESCRIPTION_sort(st) SKM_sk_sort(ACCESS_DESCRIPTION, (st))\n# define sk_ACCESS_DESCRIPTION_is_sorted(st) SKM_sk_is_sorted(ACCESS_DESCRIPTION, (st))\n# define sk_ASIdOrRange_new(cmp) SKM_sk_new(ASIdOrRange, (cmp))\n# define sk_ASIdOrRange_new_null() SKM_sk_new_null(ASIdOrRange)\n# define sk_ASIdOrRange_free(st) SKM_sk_free(ASIdOrRange, (st))\n# define sk_ASIdOrRange_num(st) SKM_sk_num(ASIdOrRange, (st))\n# define sk_ASIdOrRange_value(st, i) SKM_sk_value(ASIdOrRange, (st), (i))\n# define sk_ASIdOrRange_set(st, i, val) SKM_sk_set(ASIdOrRange, (st), (i), (val))\n# define sk_ASIdOrRange_zero(st) SKM_sk_zero(ASIdOrRange, (st))\n# define sk_ASIdOrRange_push(st, val) SKM_sk_push(ASIdOrRange, (st), (val))\n# define sk_ASIdOrRange_unshift(st, val) SKM_sk_unshift(ASIdOrRange, (st), (val))\n# define sk_ASIdOrRange_find(st, val) SKM_sk_find(ASIdOrRange, (st), (val))\n# define sk_ASIdOrRange_find_ex(st, val) SKM_sk_find_ex(ASIdOrRange, (st), (val))\n# define sk_ASIdOrRange_delete(st, i) SKM_sk_delete(ASIdOrRange, (st), (i))\n# define sk_ASIdOrRange_delete_ptr(st, ptr) SKM_sk_delete_ptr(ASIdOrRange, (st), (ptr))\n# define sk_ASIdOrRange_insert(st, val, i) SKM_sk_insert(ASIdOrRange, (st), (val), (i))\n# define sk_ASIdOrRange_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(ASIdOrRange, (st), (cmp))\n# define sk_ASIdOrRange_dup(st) SKM_sk_dup(ASIdOrRange, st)\n# define sk_ASIdOrRange_pop_free(st, free_func) SKM_sk_pop_free(ASIdOrRange, (st), (free_func))\n# define sk_ASIdOrRange_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(ASIdOrRange, (st), (copy_func), (free_func))\n# define sk_ASIdOrRange_shift(st) SKM_sk_shift(ASIdOrRange, (st))\n# define sk_ASIdOrRange_pop(st) SKM_sk_pop(ASIdOrRange, (st))\n# define sk_ASIdOrRange_sort(st) SKM_sk_sort(ASIdOrRange, (st))\n# define sk_ASIdOrRange_is_sorted(st) SKM_sk_is_sorted(ASIdOrRange, (st))\n# define sk_ASN1_GENERALSTRING_new(cmp) SKM_sk_new(ASN1_GENERALSTRING, (cmp))\n# define sk_ASN1_GENERALSTRING_new_null() SKM_sk_new_null(ASN1_GENERALSTRING)\n# define sk_ASN1_GENERALSTRING_free(st) SKM_sk_free(ASN1_GENERALSTRING, (st))\n# define sk_ASN1_GENERALSTRING_num(st) SKM_sk_num(ASN1_GENERALSTRING, (st))\n# define sk_ASN1_GENERALSTRING_value(st, i) SKM_sk_value(ASN1_GENERALSTRING, (st), (i))\n# define sk_ASN1_GENERALSTRING_set(st, i, val) SKM_sk_set(ASN1_GENERALSTRING, (st), (i), (val))\n# define sk_ASN1_GENERALSTRING_zero(st) SKM_sk_zero(ASN1_GENERALSTRING, (st))\n# define sk_ASN1_GENERALSTRING_push(st, val) SKM_sk_push(ASN1_GENERALSTRING, (st), (val))\n# define sk_ASN1_GENERALSTRING_unshift(st, val) SKM_sk_unshift(ASN1_GENERALSTRING, (st), (val))\n# define sk_ASN1_GENERALSTRING_find(st, val) SKM_sk_find(ASN1_GENERALSTRING, (st), (val))\n# define sk_ASN1_GENERALSTRING_find_ex(st, val) SKM_sk_find_ex(ASN1_GENERALSTRING, (st), (val))\n# define sk_ASN1_GENERALSTRING_delete(st, i) SKM_sk_delete(ASN1_GENERALSTRING, (st), (i))\n# define sk_ASN1_GENERALSTRING_delete_ptr(st, ptr) SKM_sk_delete_ptr(ASN1_GENERALSTRING, (st), (ptr))\n# define sk_ASN1_GENERALSTRING_insert(st, val, i) SKM_sk_insert(ASN1_GENERALSTRING, (st), (val), (i))\n# define sk_ASN1_GENERALSTRING_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(ASN1_GENERALSTRING, (st), (cmp))\n# define sk_ASN1_GENERALSTRING_dup(st) SKM_sk_dup(ASN1_GENERALSTRING, st)\n# define sk_ASN1_GENERALSTRING_pop_free(st, free_func) SKM_sk_pop_free(ASN1_GENERALSTRING, (st), (free_func))\n# define sk_ASN1_GENERALSTRING_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(ASN1_GENERALSTRING, (st), (copy_func), (free_func))\n# define sk_ASN1_GENERALSTRING_shift(st) SKM_sk_shift(ASN1_GENERALSTRING, (st))\n# define sk_ASN1_GENERALSTRING_pop(st) SKM_sk_pop(ASN1_GENERALSTRING, (st))\n# define sk_ASN1_GENERALSTRING_sort(st) SKM_sk_sort(ASN1_GENERALSTRING, (st))\n# define sk_ASN1_GENERALSTRING_is_sorted(st) SKM_sk_is_sorted(ASN1_GENERALSTRING, (st))\n# define sk_ASN1_INTEGER_new(cmp) SKM_sk_new(ASN1_INTEGER, (cmp))\n# define sk_ASN1_INTEGER_new_null() SKM_sk_new_null(ASN1_INTEGER)\n# define sk_ASN1_INTEGER_free(st) SKM_sk_free(ASN1_INTEGER, (st))\n# define sk_ASN1_INTEGER_num(st) SKM_sk_num(ASN1_INTEGER, (st))\n# define sk_ASN1_INTEGER_value(st, i) SKM_sk_value(ASN1_INTEGER, (st), (i))\n# define sk_ASN1_INTEGER_set(st, i, val) SKM_sk_set(ASN1_INTEGER, (st), (i), (val))\n# define sk_ASN1_INTEGER_zero(st) SKM_sk_zero(ASN1_INTEGER, (st))\n# define sk_ASN1_INTEGER_push(st, val) SKM_sk_push(ASN1_INTEGER, (st), (val))\n# define sk_ASN1_INTEGER_unshift(st, val) SKM_sk_unshift(ASN1_INTEGER, (st), (val))\n# define sk_ASN1_INTEGER_find(st, val) SKM_sk_find(ASN1_INTEGER, (st), (val))\n# define sk_ASN1_INTEGER_find_ex(st, val) SKM_sk_find_ex(ASN1_INTEGER, (st), (val))\n# define sk_ASN1_INTEGER_delete(st, i) SKM_sk_delete(ASN1_INTEGER, (st), (i))\n# define sk_ASN1_INTEGER_delete_ptr(st, ptr) SKM_sk_delete_ptr(ASN1_INTEGER, (st), (ptr))\n# define sk_ASN1_INTEGER_insert(st, val, i) SKM_sk_insert(ASN1_INTEGER, (st), (val), (i))\n# define sk_ASN1_INTEGER_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(ASN1_INTEGER, (st), (cmp))\n# define sk_ASN1_INTEGER_dup(st) SKM_sk_dup(ASN1_INTEGER, st)\n# define sk_ASN1_INTEGER_pop_free(st, free_func) SKM_sk_pop_free(ASN1_INTEGER, (st), (free_func))\n# define sk_ASN1_INTEGER_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(ASN1_INTEGER, (st), (copy_func), (free_func))\n# define sk_ASN1_INTEGER_shift(st) SKM_sk_shift(ASN1_INTEGER, (st))\n# define sk_ASN1_INTEGER_pop(st) SKM_sk_pop(ASN1_INTEGER, (st))\n# define sk_ASN1_INTEGER_sort(st) SKM_sk_sort(ASN1_INTEGER, (st))\n# define sk_ASN1_INTEGER_is_sorted(st) SKM_sk_is_sorted(ASN1_INTEGER, (st))\n# define sk_ASN1_OBJECT_new(cmp) SKM_sk_new(ASN1_OBJECT, (cmp))\n# define sk_ASN1_OBJECT_new_null() SKM_sk_new_null(ASN1_OBJECT)\n# define sk_ASN1_OBJECT_free(st) SKM_sk_free(ASN1_OBJECT, (st))\n# define sk_ASN1_OBJECT_num(st) SKM_sk_num(ASN1_OBJECT, (st))\n# define sk_ASN1_OBJECT_value(st, i) SKM_sk_value(ASN1_OBJECT, (st), (i))\n# define sk_ASN1_OBJECT_set(st, i, val) SKM_sk_set(ASN1_OBJECT, (st), (i), (val))\n# define sk_ASN1_OBJECT_zero(st) SKM_sk_zero(ASN1_OBJECT, (st))\n# define sk_ASN1_OBJECT_push(st, val) SKM_sk_push(ASN1_OBJECT, (st), (val))\n# define sk_ASN1_OBJECT_unshift(st, val) SKM_sk_unshift(ASN1_OBJECT, (st), (val))\n# define sk_ASN1_OBJECT_find(st, val) SKM_sk_find(ASN1_OBJECT, (st), (val))\n# define sk_ASN1_OBJECT_find_ex(st, val) SKM_sk_find_ex(ASN1_OBJECT, (st), (val))\n# define sk_ASN1_OBJECT_delete(st, i) SKM_sk_delete(ASN1_OBJECT, (st), (i))\n# define sk_ASN1_OBJECT_delete_ptr(st, ptr) SKM_sk_delete_ptr(ASN1_OBJECT, (st), (ptr))\n# define sk_ASN1_OBJECT_insert(st, val, i) SKM_sk_insert(ASN1_OBJECT, (st), (val), (i))\n# define sk_ASN1_OBJECT_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(ASN1_OBJECT, (st), (cmp))\n# define sk_ASN1_OBJECT_dup(st) SKM_sk_dup(ASN1_OBJECT, st)\n# define sk_ASN1_OBJECT_pop_free(st, free_func) SKM_sk_pop_free(ASN1_OBJECT, (st), (free_func))\n# define sk_ASN1_OBJECT_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(ASN1_OBJECT, (st), (copy_func), (free_func))\n# define sk_ASN1_OBJECT_shift(st) SKM_sk_shift(ASN1_OBJECT, (st))\n# define sk_ASN1_OBJECT_pop(st) SKM_sk_pop(ASN1_OBJECT, (st))\n# define sk_ASN1_OBJECT_sort(st) SKM_sk_sort(ASN1_OBJECT, (st))\n# define sk_ASN1_OBJECT_is_sorted(st) SKM_sk_is_sorted(ASN1_OBJECT, (st))\n# define sk_ASN1_STRING_TABLE_new(cmp) SKM_sk_new(ASN1_STRING_TABLE, (cmp))\n# define sk_ASN1_STRING_TABLE_new_null() SKM_sk_new_null(ASN1_STRING_TABLE)\n# define sk_ASN1_STRING_TABLE_free(st) SKM_sk_free(ASN1_STRING_TABLE, (st))\n# define sk_ASN1_STRING_TABLE_num(st) SKM_sk_num(ASN1_STRING_TABLE, (st))\n# define sk_ASN1_STRING_TABLE_value(st, i) SKM_sk_value(ASN1_STRING_TABLE, (st), (i))\n# define sk_ASN1_STRING_TABLE_set(st, i, val) SKM_sk_set(ASN1_STRING_TABLE, (st), (i), (val))\n# define sk_ASN1_STRING_TABLE_zero(st) SKM_sk_zero(ASN1_STRING_TABLE, (st))\n# define sk_ASN1_STRING_TABLE_push(st, val) SKM_sk_push(ASN1_STRING_TABLE, (st), (val))\n# define sk_ASN1_STRING_TABLE_unshift(st, val) SKM_sk_unshift(ASN1_STRING_TABLE, (st), (val))\n# define sk_ASN1_STRING_TABLE_find(st, val) SKM_sk_find(ASN1_STRING_TABLE, (st), (val))\n# define sk_ASN1_STRING_TABLE_find_ex(st, val) SKM_sk_find_ex(ASN1_STRING_TABLE, (st), (val))\n# define sk_ASN1_STRING_TABLE_delete(st, i) SKM_sk_delete(ASN1_STRING_TABLE, (st), (i))\n# define sk_ASN1_STRING_TABLE_delete_ptr(st, ptr) SKM_sk_delete_ptr(ASN1_STRING_TABLE, (st), (ptr))\n# define sk_ASN1_STRING_TABLE_insert(st, val, i) SKM_sk_insert(ASN1_STRING_TABLE, (st), (val), (i))\n# define sk_ASN1_STRING_TABLE_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(ASN1_STRING_TABLE, (st), (cmp))\n# define sk_ASN1_STRING_TABLE_dup(st) SKM_sk_dup(ASN1_STRING_TABLE, st)\n# define sk_ASN1_STRING_TABLE_pop_free(st, free_func) SKM_sk_pop_free(ASN1_STRING_TABLE, (st), (free_func))\n# define sk_ASN1_STRING_TABLE_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(ASN1_STRING_TABLE, (st), (copy_func), (free_func))\n# define sk_ASN1_STRING_TABLE_shift(st) SKM_sk_shift(ASN1_STRING_TABLE, (st))\n# define sk_ASN1_STRING_TABLE_pop(st) SKM_sk_pop(ASN1_STRING_TABLE, (st))\n# define sk_ASN1_STRING_TABLE_sort(st) SKM_sk_sort(ASN1_STRING_TABLE, (st))\n# define sk_ASN1_STRING_TABLE_is_sorted(st) SKM_sk_is_sorted(ASN1_STRING_TABLE, (st))\n# define sk_ASN1_TYPE_new(cmp) SKM_sk_new(ASN1_TYPE, (cmp))\n# define sk_ASN1_TYPE_new_null() SKM_sk_new_null(ASN1_TYPE)\n# define sk_ASN1_TYPE_free(st) SKM_sk_free(ASN1_TYPE, (st))\n# define sk_ASN1_TYPE_num(st) SKM_sk_num(ASN1_TYPE, (st))\n# define sk_ASN1_TYPE_value(st, i) SKM_sk_value(ASN1_TYPE, (st), (i))\n# define sk_ASN1_TYPE_set(st, i, val) SKM_sk_set(ASN1_TYPE, (st), (i), (val))\n# define sk_ASN1_TYPE_zero(st) SKM_sk_zero(ASN1_TYPE, (st))\n# define sk_ASN1_TYPE_push(st, val) SKM_sk_push(ASN1_TYPE, (st), (val))\n# define sk_ASN1_TYPE_unshift(st, val) SKM_sk_unshift(ASN1_TYPE, (st), (val))\n# define sk_ASN1_TYPE_find(st, val) SKM_sk_find(ASN1_TYPE, (st), (val))\n# define sk_ASN1_TYPE_find_ex(st, val) SKM_sk_find_ex(ASN1_TYPE, (st), (val))\n# define sk_ASN1_TYPE_delete(st, i) SKM_sk_delete(ASN1_TYPE, (st), (i))\n# define sk_ASN1_TYPE_delete_ptr(st, ptr) SKM_sk_delete_ptr(ASN1_TYPE, (st), (ptr))\n# define sk_ASN1_TYPE_insert(st, val, i) SKM_sk_insert(ASN1_TYPE, (st), (val), (i))\n# define sk_ASN1_TYPE_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(ASN1_TYPE, (st), (cmp))\n# define sk_ASN1_TYPE_dup(st) SKM_sk_dup(ASN1_TYPE, st)\n# define sk_ASN1_TYPE_pop_free(st, free_func) SKM_sk_pop_free(ASN1_TYPE, (st), (free_func))\n# define sk_ASN1_TYPE_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(ASN1_TYPE, (st), (copy_func), (free_func))\n# define sk_ASN1_TYPE_shift(st) SKM_sk_shift(ASN1_TYPE, (st))\n# define sk_ASN1_TYPE_pop(st) SKM_sk_pop(ASN1_TYPE, (st))\n# define sk_ASN1_TYPE_sort(st) SKM_sk_sort(ASN1_TYPE, (st))\n# define sk_ASN1_TYPE_is_sorted(st) SKM_sk_is_sorted(ASN1_TYPE, (st))\n# define sk_ASN1_UTF8STRING_new(cmp) SKM_sk_new(ASN1_UTF8STRING, (cmp))\n# define sk_ASN1_UTF8STRING_new_null() SKM_sk_new_null(ASN1_UTF8STRING)\n# define sk_ASN1_UTF8STRING_free(st) SKM_sk_free(ASN1_UTF8STRING, (st))\n# define sk_ASN1_UTF8STRING_num(st) SKM_sk_num(ASN1_UTF8STRING, (st))\n# define sk_ASN1_UTF8STRING_value(st, i) SKM_sk_value(ASN1_UTF8STRING, (st), (i))\n# define sk_ASN1_UTF8STRING_set(st, i, val) SKM_sk_set(ASN1_UTF8STRING, (st), (i), (val))\n# define sk_ASN1_UTF8STRING_zero(st) SKM_sk_zero(ASN1_UTF8STRING, (st))\n# define sk_ASN1_UTF8STRING_push(st, val) SKM_sk_push(ASN1_UTF8STRING, (st), (val))\n# define sk_ASN1_UTF8STRING_unshift(st, val) SKM_sk_unshift(ASN1_UTF8STRING, (st), (val))\n# define sk_ASN1_UTF8STRING_find(st, val) SKM_sk_find(ASN1_UTF8STRING, (st), (val))\n# define sk_ASN1_UTF8STRING_find_ex(st, val) SKM_sk_find_ex(ASN1_UTF8STRING, (st), (val))\n# define sk_ASN1_UTF8STRING_delete(st, i) SKM_sk_delete(ASN1_UTF8STRING, (st), (i))\n# define sk_ASN1_UTF8STRING_delete_ptr(st, ptr) SKM_sk_delete_ptr(ASN1_UTF8STRING, (st), (ptr))\n# define sk_ASN1_UTF8STRING_insert(st, val, i) SKM_sk_insert(ASN1_UTF8STRING, (st), (val), (i))\n# define sk_ASN1_UTF8STRING_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(ASN1_UTF8STRING, (st), (cmp))\n# define sk_ASN1_UTF8STRING_dup(st) SKM_sk_dup(ASN1_UTF8STRING, st)\n# define sk_ASN1_UTF8STRING_pop_free(st, free_func) SKM_sk_pop_free(ASN1_UTF8STRING, (st), (free_func))\n# define sk_ASN1_UTF8STRING_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(ASN1_UTF8STRING, (st), (copy_func), (free_func))\n# define sk_ASN1_UTF8STRING_shift(st) SKM_sk_shift(ASN1_UTF8STRING, (st))\n# define sk_ASN1_UTF8STRING_pop(st) SKM_sk_pop(ASN1_UTF8STRING, (st))\n# define sk_ASN1_UTF8STRING_sort(st) SKM_sk_sort(ASN1_UTF8STRING, (st))\n# define sk_ASN1_UTF8STRING_is_sorted(st) SKM_sk_is_sorted(ASN1_UTF8STRING, (st))\n# define sk_ASN1_VALUE_new(cmp) SKM_sk_new(ASN1_VALUE, (cmp))\n# define sk_ASN1_VALUE_new_null() SKM_sk_new_null(ASN1_VALUE)\n# define sk_ASN1_VALUE_free(st) SKM_sk_free(ASN1_VALUE, (st))\n# define sk_ASN1_VALUE_num(st) SKM_sk_num(ASN1_VALUE, (st))\n# define sk_ASN1_VALUE_value(st, i) SKM_sk_value(ASN1_VALUE, (st), (i))\n# define sk_ASN1_VALUE_set(st, i, val) SKM_sk_set(ASN1_VALUE, (st), (i), (val))\n# define sk_ASN1_VALUE_zero(st) SKM_sk_zero(ASN1_VALUE, (st))\n# define sk_ASN1_VALUE_push(st, val) SKM_sk_push(ASN1_VALUE, (st), (val))\n# define sk_ASN1_VALUE_unshift(st, val) SKM_sk_unshift(ASN1_VALUE, (st), (val))\n# define sk_ASN1_VALUE_find(st, val) SKM_sk_find(ASN1_VALUE, (st), (val))\n# define sk_ASN1_VALUE_find_ex(st, val) SKM_sk_find_ex(ASN1_VALUE, (st), (val))\n# define sk_ASN1_VALUE_delete(st, i) SKM_sk_delete(ASN1_VALUE, (st), (i))\n# define sk_ASN1_VALUE_delete_ptr(st, ptr) SKM_sk_delete_ptr(ASN1_VALUE, (st), (ptr))\n# define sk_ASN1_VALUE_insert(st, val, i) SKM_sk_insert(ASN1_VALUE, (st), (val), (i))\n# define sk_ASN1_VALUE_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(ASN1_VALUE, (st), (cmp))\n# define sk_ASN1_VALUE_dup(st) SKM_sk_dup(ASN1_VALUE, st)\n# define sk_ASN1_VALUE_pop_free(st, free_func) SKM_sk_pop_free(ASN1_VALUE, (st), (free_func))\n# define sk_ASN1_VALUE_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(ASN1_VALUE, (st), (copy_func), (free_func))\n# define sk_ASN1_VALUE_shift(st) SKM_sk_shift(ASN1_VALUE, (st))\n# define sk_ASN1_VALUE_pop(st) SKM_sk_pop(ASN1_VALUE, (st))\n# define sk_ASN1_VALUE_sort(st) SKM_sk_sort(ASN1_VALUE, (st))\n# define sk_ASN1_VALUE_is_sorted(st) SKM_sk_is_sorted(ASN1_VALUE, (st))\n# define sk_BIO_new(cmp) SKM_sk_new(BIO, (cmp))\n# define sk_BIO_new_null() SKM_sk_new_null(BIO)\n# define sk_BIO_free(st) SKM_sk_free(BIO, (st))\n# define sk_BIO_num(st) SKM_sk_num(BIO, (st))\n# define sk_BIO_value(st, i) SKM_sk_value(BIO, (st), (i))\n# define sk_BIO_set(st, i, val) SKM_sk_set(BIO, (st), (i), (val))\n# define sk_BIO_zero(st) SKM_sk_zero(BIO, (st))\n# define sk_BIO_push(st, val) SKM_sk_push(BIO, (st), (val))\n# define sk_BIO_unshift(st, val) SKM_sk_unshift(BIO, (st), (val))\n# define sk_BIO_find(st, val) SKM_sk_find(BIO, (st), (val))\n# define sk_BIO_find_ex(st, val) SKM_sk_find_ex(BIO, (st), (val))\n# define sk_BIO_delete(st, i) SKM_sk_delete(BIO, (st), (i))\n# define sk_BIO_delete_ptr(st, ptr) SKM_sk_delete_ptr(BIO, (st), (ptr))\n# define sk_BIO_insert(st, val, i) SKM_sk_insert(BIO, (st), (val), (i))\n# define sk_BIO_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(BIO, (st), (cmp))\n# define sk_BIO_dup(st) SKM_sk_dup(BIO, st)\n# define sk_BIO_pop_free(st, free_func) SKM_sk_pop_free(BIO, (st), (free_func))\n# define sk_BIO_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(BIO, (st), (copy_func), (free_func))\n# define sk_BIO_shift(st) SKM_sk_shift(BIO, (st))\n# define sk_BIO_pop(st) SKM_sk_pop(BIO, (st))\n# define sk_BIO_sort(st) SKM_sk_sort(BIO, (st))\n# define sk_BIO_is_sorted(st) SKM_sk_is_sorted(BIO, (st))\n# define sk_BY_DIR_ENTRY_new(cmp) SKM_sk_new(BY_DIR_ENTRY, (cmp))\n# define sk_BY_DIR_ENTRY_new_null() SKM_sk_new_null(BY_DIR_ENTRY)\n# define sk_BY_DIR_ENTRY_free(st) SKM_sk_free(BY_DIR_ENTRY, (st))\n# define sk_BY_DIR_ENTRY_num(st) SKM_sk_num(BY_DIR_ENTRY, (st))\n# define sk_BY_DIR_ENTRY_value(st, i) SKM_sk_value(BY_DIR_ENTRY, (st), (i))\n# define sk_BY_DIR_ENTRY_set(st, i, val) SKM_sk_set(BY_DIR_ENTRY, (st), (i), (val))\n# define sk_BY_DIR_ENTRY_zero(st) SKM_sk_zero(BY_DIR_ENTRY, (st))\n# define sk_BY_DIR_ENTRY_push(st, val) SKM_sk_push(BY_DIR_ENTRY, (st), (val))\n# define sk_BY_DIR_ENTRY_unshift(st, val) SKM_sk_unshift(BY_DIR_ENTRY, (st), (val))\n# define sk_BY_DIR_ENTRY_find(st, val) SKM_sk_find(BY_DIR_ENTRY, (st), (val))\n# define sk_BY_DIR_ENTRY_find_ex(st, val) SKM_sk_find_ex(BY_DIR_ENTRY, (st), (val))\n# define sk_BY_DIR_ENTRY_delete(st, i) SKM_sk_delete(BY_DIR_ENTRY, (st), (i))\n# define sk_BY_DIR_ENTRY_delete_ptr(st, ptr) SKM_sk_delete_ptr(BY_DIR_ENTRY, (st), (ptr))\n# define sk_BY_DIR_ENTRY_insert(st, val, i) SKM_sk_insert(BY_DIR_ENTRY, (st), (val), (i))\n# define sk_BY_DIR_ENTRY_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(BY_DIR_ENTRY, (st), (cmp))\n# define sk_BY_DIR_ENTRY_dup(st) SKM_sk_dup(BY_DIR_ENTRY, st)\n# define sk_BY_DIR_ENTRY_pop_free(st, free_func) SKM_sk_pop_free(BY_DIR_ENTRY, (st), (free_func))\n# define sk_BY_DIR_ENTRY_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(BY_DIR_ENTRY, (st), (copy_func), (free_func))\n# define sk_BY_DIR_ENTRY_shift(st) SKM_sk_shift(BY_DIR_ENTRY, (st))\n# define sk_BY_DIR_ENTRY_pop(st) SKM_sk_pop(BY_DIR_ENTRY, (st))\n# define sk_BY_DIR_ENTRY_sort(st) SKM_sk_sort(BY_DIR_ENTRY, (st))\n# define sk_BY_DIR_ENTRY_is_sorted(st) SKM_sk_is_sorted(BY_DIR_ENTRY, (st))\n# define sk_BY_DIR_HASH_new(cmp) SKM_sk_new(BY_DIR_HASH, (cmp))\n# define sk_BY_DIR_HASH_new_null() SKM_sk_new_null(BY_DIR_HASH)\n# define sk_BY_DIR_HASH_free(st) SKM_sk_free(BY_DIR_HASH, (st))\n# define sk_BY_DIR_HASH_num(st) SKM_sk_num(BY_DIR_HASH, (st))\n# define sk_BY_DIR_HASH_value(st, i) SKM_sk_value(BY_DIR_HASH, (st), (i))\n# define sk_BY_DIR_HASH_set(st, i, val) SKM_sk_set(BY_DIR_HASH, (st), (i), (val))\n# define sk_BY_DIR_HASH_zero(st) SKM_sk_zero(BY_DIR_HASH, (st))\n# define sk_BY_DIR_HASH_push(st, val) SKM_sk_push(BY_DIR_HASH, (st), (val))\n# define sk_BY_DIR_HASH_unshift(st, val) SKM_sk_unshift(BY_DIR_HASH, (st), (val))\n# define sk_BY_DIR_HASH_find(st, val) SKM_sk_find(BY_DIR_HASH, (st), (val))\n# define sk_BY_DIR_HASH_find_ex(st, val) SKM_sk_find_ex(BY_DIR_HASH, (st), (val))\n# define sk_BY_DIR_HASH_delete(st, i) SKM_sk_delete(BY_DIR_HASH, (st), (i))\n# define sk_BY_DIR_HASH_delete_ptr(st, ptr) SKM_sk_delete_ptr(BY_DIR_HASH, (st), (ptr))\n# define sk_BY_DIR_HASH_insert(st, val, i) SKM_sk_insert(BY_DIR_HASH, (st), (val), (i))\n# define sk_BY_DIR_HASH_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(BY_DIR_HASH, (st), (cmp))\n# define sk_BY_DIR_HASH_dup(st) SKM_sk_dup(BY_DIR_HASH, st)\n# define sk_BY_DIR_HASH_pop_free(st, free_func) SKM_sk_pop_free(BY_DIR_HASH, (st), (free_func))\n# define sk_BY_DIR_HASH_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(BY_DIR_HASH, (st), (copy_func), (free_func))\n# define sk_BY_DIR_HASH_shift(st) SKM_sk_shift(BY_DIR_HASH, (st))\n# define sk_BY_DIR_HASH_pop(st) SKM_sk_pop(BY_DIR_HASH, (st))\n# define sk_BY_DIR_HASH_sort(st) SKM_sk_sort(BY_DIR_HASH, (st))\n# define sk_BY_DIR_HASH_is_sorted(st) SKM_sk_is_sorted(BY_DIR_HASH, (st))\n# define sk_CMS_CertificateChoices_new(cmp) SKM_sk_new(CMS_CertificateChoices, (cmp))\n# define sk_CMS_CertificateChoices_new_null() SKM_sk_new_null(CMS_CertificateChoices)\n# define sk_CMS_CertificateChoices_free(st) SKM_sk_free(CMS_CertificateChoices, (st))\n# define sk_CMS_CertificateChoices_num(st) SKM_sk_num(CMS_CertificateChoices, (st))\n# define sk_CMS_CertificateChoices_value(st, i) SKM_sk_value(CMS_CertificateChoices, (st), (i))\n# define sk_CMS_CertificateChoices_set(st, i, val) SKM_sk_set(CMS_CertificateChoices, (st), (i), (val))\n# define sk_CMS_CertificateChoices_zero(st) SKM_sk_zero(CMS_CertificateChoices, (st))\n# define sk_CMS_CertificateChoices_push(st, val) SKM_sk_push(CMS_CertificateChoices, (st), (val))\n# define sk_CMS_CertificateChoices_unshift(st, val) SKM_sk_unshift(CMS_CertificateChoices, (st), (val))\n# define sk_CMS_CertificateChoices_find(st, val) SKM_sk_find(CMS_CertificateChoices, (st), (val))\n# define sk_CMS_CertificateChoices_find_ex(st, val) SKM_sk_find_ex(CMS_CertificateChoices, (st), (val))\n# define sk_CMS_CertificateChoices_delete(st, i) SKM_sk_delete(CMS_CertificateChoices, (st), (i))\n# define sk_CMS_CertificateChoices_delete_ptr(st, ptr) SKM_sk_delete_ptr(CMS_CertificateChoices, (st), (ptr))\n# define sk_CMS_CertificateChoices_insert(st, val, i) SKM_sk_insert(CMS_CertificateChoices, (st), (val), (i))\n# define sk_CMS_CertificateChoices_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(CMS_CertificateChoices, (st), (cmp))\n# define sk_CMS_CertificateChoices_dup(st) SKM_sk_dup(CMS_CertificateChoices, st)\n# define sk_CMS_CertificateChoices_pop_free(st, free_func) SKM_sk_pop_free(CMS_CertificateChoices, (st), (free_func))\n# define sk_CMS_CertificateChoices_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(CMS_CertificateChoices, (st), (copy_func), (free_func))\n# define sk_CMS_CertificateChoices_shift(st) SKM_sk_shift(CMS_CertificateChoices, (st))\n# define sk_CMS_CertificateChoices_pop(st) SKM_sk_pop(CMS_CertificateChoices, (st))\n# define sk_CMS_CertificateChoices_sort(st) SKM_sk_sort(CMS_CertificateChoices, (st))\n# define sk_CMS_CertificateChoices_is_sorted(st) SKM_sk_is_sorted(CMS_CertificateChoices, (st))\n# define sk_CMS_RecipientEncryptedKey_new(cmp) SKM_sk_new(CMS_RecipientEncryptedKey, (cmp))\n# define sk_CMS_RecipientEncryptedKey_new_null() SKM_sk_new_null(CMS_RecipientEncryptedKey)\n# define sk_CMS_RecipientEncryptedKey_free(st) SKM_sk_free(CMS_RecipientEncryptedKey, (st))\n# define sk_CMS_RecipientEncryptedKey_num(st) SKM_sk_num(CMS_RecipientEncryptedKey, (st))\n# define sk_CMS_RecipientEncryptedKey_value(st, i) SKM_sk_value(CMS_RecipientEncryptedKey, (st), (i))\n# define sk_CMS_RecipientEncryptedKey_set(st, i, val) SKM_sk_set(CMS_RecipientEncryptedKey, (st), (i), (val))\n# define sk_CMS_RecipientEncryptedKey_zero(st) SKM_sk_zero(CMS_RecipientEncryptedKey, (st))\n# define sk_CMS_RecipientEncryptedKey_push(st, val) SKM_sk_push(CMS_RecipientEncryptedKey, (st), (val))\n# define sk_CMS_RecipientEncryptedKey_unshift(st, val) SKM_sk_unshift(CMS_RecipientEncryptedKey, (st), (val))\n# define sk_CMS_RecipientEncryptedKey_find(st, val) SKM_sk_find(CMS_RecipientEncryptedKey, (st), (val))\n# define sk_CMS_RecipientEncryptedKey_find_ex(st, val) SKM_sk_find_ex(CMS_RecipientEncryptedKey, (st), (val))\n# define sk_CMS_RecipientEncryptedKey_delete(st, i) SKM_sk_delete(CMS_RecipientEncryptedKey, (st), (i))\n# define sk_CMS_RecipientEncryptedKey_delete_ptr(st, ptr) SKM_sk_delete_ptr(CMS_RecipientEncryptedKey, (st), (ptr))\n# define sk_CMS_RecipientEncryptedKey_insert(st, val, i) SKM_sk_insert(CMS_RecipientEncryptedKey, (st), (val), (i))\n# define sk_CMS_RecipientEncryptedKey_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(CMS_RecipientEncryptedKey, (st), (cmp))\n# define sk_CMS_RecipientEncryptedKey_dup(st) SKM_sk_dup(CMS_RecipientEncryptedKey, st)\n# define sk_CMS_RecipientEncryptedKey_pop_free(st, free_func) SKM_sk_pop_free(CMS_RecipientEncryptedKey, (st), (free_func))\n# define sk_CMS_RecipientEncryptedKey_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(CMS_RecipientEncryptedKey, (st), (copy_func), (free_func))\n# define sk_CMS_RecipientEncryptedKey_shift(st) SKM_sk_shift(CMS_RecipientEncryptedKey, (st))\n# define sk_CMS_RecipientEncryptedKey_pop(st) SKM_sk_pop(CMS_RecipientEncryptedKey, (st))\n# define sk_CMS_RecipientEncryptedKey_sort(st) SKM_sk_sort(CMS_RecipientEncryptedKey, (st))\n# define sk_CMS_RecipientEncryptedKey_is_sorted(st) SKM_sk_is_sorted(CMS_RecipientEncryptedKey, (st))\n# define sk_CMS_RecipientInfo_new(cmp) SKM_sk_new(CMS_RecipientInfo, (cmp))\n# define sk_CMS_RecipientInfo_new_null() SKM_sk_new_null(CMS_RecipientInfo)\n# define sk_CMS_RecipientInfo_free(st) SKM_sk_free(CMS_RecipientInfo, (st))\n# define sk_CMS_RecipientInfo_num(st) SKM_sk_num(CMS_RecipientInfo, (st))\n# define sk_CMS_RecipientInfo_value(st, i) SKM_sk_value(CMS_RecipientInfo, (st), (i))\n# define sk_CMS_RecipientInfo_set(st, i, val) SKM_sk_set(CMS_RecipientInfo, (st), (i), (val))\n# define sk_CMS_RecipientInfo_zero(st) SKM_sk_zero(CMS_RecipientInfo, (st))\n# define sk_CMS_RecipientInfo_push(st, val) SKM_sk_push(CMS_RecipientInfo, (st), (val))\n# define sk_CMS_RecipientInfo_unshift(st, val) SKM_sk_unshift(CMS_RecipientInfo, (st), (val))\n# define sk_CMS_RecipientInfo_find(st, val) SKM_sk_find(CMS_RecipientInfo, (st), (val))\n# define sk_CMS_RecipientInfo_find_ex(st, val) SKM_sk_find_ex(CMS_RecipientInfo, (st), (val))\n# define sk_CMS_RecipientInfo_delete(st, i) SKM_sk_delete(CMS_RecipientInfo, (st), (i))\n# define sk_CMS_RecipientInfo_delete_ptr(st, ptr) SKM_sk_delete_ptr(CMS_RecipientInfo, (st), (ptr))\n# define sk_CMS_RecipientInfo_insert(st, val, i) SKM_sk_insert(CMS_RecipientInfo, (st), (val), (i))\n# define sk_CMS_RecipientInfo_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(CMS_RecipientInfo, (st), (cmp))\n# define sk_CMS_RecipientInfo_dup(st) SKM_sk_dup(CMS_RecipientInfo, st)\n# define sk_CMS_RecipientInfo_pop_free(st, free_func) SKM_sk_pop_free(CMS_RecipientInfo, (st), (free_func))\n# define sk_CMS_RecipientInfo_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(CMS_RecipientInfo, (st), (copy_func), (free_func))\n# define sk_CMS_RecipientInfo_shift(st) SKM_sk_shift(CMS_RecipientInfo, (st))\n# define sk_CMS_RecipientInfo_pop(st) SKM_sk_pop(CMS_RecipientInfo, (st))\n# define sk_CMS_RecipientInfo_sort(st) SKM_sk_sort(CMS_RecipientInfo, (st))\n# define sk_CMS_RecipientInfo_is_sorted(st) SKM_sk_is_sorted(CMS_RecipientInfo, (st))\n# define sk_CMS_RevocationInfoChoice_new(cmp) SKM_sk_new(CMS_RevocationInfoChoice, (cmp))\n# define sk_CMS_RevocationInfoChoice_new_null() SKM_sk_new_null(CMS_RevocationInfoChoice)\n# define sk_CMS_RevocationInfoChoice_free(st) SKM_sk_free(CMS_RevocationInfoChoice, (st))\n# define sk_CMS_RevocationInfoChoice_num(st) SKM_sk_num(CMS_RevocationInfoChoice, (st))\n# define sk_CMS_RevocationInfoChoice_value(st, i) SKM_sk_value(CMS_RevocationInfoChoice, (st), (i))\n# define sk_CMS_RevocationInfoChoice_set(st, i, val) SKM_sk_set(CMS_RevocationInfoChoice, (st), (i), (val))\n# define sk_CMS_RevocationInfoChoice_zero(st) SKM_sk_zero(CMS_RevocationInfoChoice, (st))\n# define sk_CMS_RevocationInfoChoice_push(st, val) SKM_sk_push(CMS_RevocationInfoChoice, (st), (val))\n# define sk_CMS_RevocationInfoChoice_unshift(st, val) SKM_sk_unshift(CMS_RevocationInfoChoice, (st), (val))\n# define sk_CMS_RevocationInfoChoice_find(st, val) SKM_sk_find(CMS_RevocationInfoChoice, (st), (val))\n# define sk_CMS_RevocationInfoChoice_find_ex(st, val) SKM_sk_find_ex(CMS_RevocationInfoChoice, (st), (val))\n# define sk_CMS_RevocationInfoChoice_delete(st, i) SKM_sk_delete(CMS_RevocationInfoChoice, (st), (i))\n# define sk_CMS_RevocationInfoChoice_delete_ptr(st, ptr) SKM_sk_delete_ptr(CMS_RevocationInfoChoice, (st), (ptr))\n# define sk_CMS_RevocationInfoChoice_insert(st, val, i) SKM_sk_insert(CMS_RevocationInfoChoice, (st), (val), (i))\n# define sk_CMS_RevocationInfoChoice_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(CMS_RevocationInfoChoice, (st), (cmp))\n# define sk_CMS_RevocationInfoChoice_dup(st) SKM_sk_dup(CMS_RevocationInfoChoice, st)\n# define sk_CMS_RevocationInfoChoice_pop_free(st, free_func) SKM_sk_pop_free(CMS_RevocationInfoChoice, (st), (free_func))\n# define sk_CMS_RevocationInfoChoice_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(CMS_RevocationInfoChoice, (st), (copy_func), (free_func))\n# define sk_CMS_RevocationInfoChoice_shift(st) SKM_sk_shift(CMS_RevocationInfoChoice, (st))\n# define sk_CMS_RevocationInfoChoice_pop(st) SKM_sk_pop(CMS_RevocationInfoChoice, (st))\n# define sk_CMS_RevocationInfoChoice_sort(st) SKM_sk_sort(CMS_RevocationInfoChoice, (st))\n# define sk_CMS_RevocationInfoChoice_is_sorted(st) SKM_sk_is_sorted(CMS_RevocationInfoChoice, (st))\n# define sk_CMS_SignerInfo_new(cmp) SKM_sk_new(CMS_SignerInfo, (cmp))\n# define sk_CMS_SignerInfo_new_null() SKM_sk_new_null(CMS_SignerInfo)\n# define sk_CMS_SignerInfo_free(st) SKM_sk_free(CMS_SignerInfo, (st))\n# define sk_CMS_SignerInfo_num(st) SKM_sk_num(CMS_SignerInfo, (st))\n# define sk_CMS_SignerInfo_value(st, i) SKM_sk_value(CMS_SignerInfo, (st), (i))\n# define sk_CMS_SignerInfo_set(st, i, val) SKM_sk_set(CMS_SignerInfo, (st), (i), (val))\n# define sk_CMS_SignerInfo_zero(st) SKM_sk_zero(CMS_SignerInfo, (st))\n# define sk_CMS_SignerInfo_push(st, val) SKM_sk_push(CMS_SignerInfo, (st), (val))\n# define sk_CMS_SignerInfo_unshift(st, val) SKM_sk_unshift(CMS_SignerInfo, (st), (val))\n# define sk_CMS_SignerInfo_find(st, val) SKM_sk_find(CMS_SignerInfo, (st), (val))\n# define sk_CMS_SignerInfo_find_ex(st, val) SKM_sk_find_ex(CMS_SignerInfo, (st), (val))\n# define sk_CMS_SignerInfo_delete(st, i) SKM_sk_delete(CMS_SignerInfo, (st), (i))\n# define sk_CMS_SignerInfo_delete_ptr(st, ptr) SKM_sk_delete_ptr(CMS_SignerInfo, (st), (ptr))\n# define sk_CMS_SignerInfo_insert(st, val, i) SKM_sk_insert(CMS_SignerInfo, (st), (val), (i))\n# define sk_CMS_SignerInfo_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(CMS_SignerInfo, (st), (cmp))\n# define sk_CMS_SignerInfo_dup(st) SKM_sk_dup(CMS_SignerInfo, st)\n# define sk_CMS_SignerInfo_pop_free(st, free_func) SKM_sk_pop_free(CMS_SignerInfo, (st), (free_func))\n# define sk_CMS_SignerInfo_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(CMS_SignerInfo, (st), (copy_func), (free_func))\n# define sk_CMS_SignerInfo_shift(st) SKM_sk_shift(CMS_SignerInfo, (st))\n# define sk_CMS_SignerInfo_pop(st) SKM_sk_pop(CMS_SignerInfo, (st))\n# define sk_CMS_SignerInfo_sort(st) SKM_sk_sort(CMS_SignerInfo, (st))\n# define sk_CMS_SignerInfo_is_sorted(st) SKM_sk_is_sorted(CMS_SignerInfo, (st))\n# define sk_CONF_IMODULE_new(cmp) SKM_sk_new(CONF_IMODULE, (cmp))\n# define sk_CONF_IMODULE_new_null() SKM_sk_new_null(CONF_IMODULE)\n# define sk_CONF_IMODULE_free(st) SKM_sk_free(CONF_IMODULE, (st))\n# define sk_CONF_IMODULE_num(st) SKM_sk_num(CONF_IMODULE, (st))\n# define sk_CONF_IMODULE_value(st, i) SKM_sk_value(CONF_IMODULE, (st), (i))\n# define sk_CONF_IMODULE_set(st, i, val) SKM_sk_set(CONF_IMODULE, (st), (i), (val))\n# define sk_CONF_IMODULE_zero(st) SKM_sk_zero(CONF_IMODULE, (st))\n# define sk_CONF_IMODULE_push(st, val) SKM_sk_push(CONF_IMODULE, (st), (val))\n# define sk_CONF_IMODULE_unshift(st, val) SKM_sk_unshift(CONF_IMODULE, (st), (val))\n# define sk_CONF_IMODULE_find(st, val) SKM_sk_find(CONF_IMODULE, (st), (val))\n# define sk_CONF_IMODULE_find_ex(st, val) SKM_sk_find_ex(CONF_IMODULE, (st), (val))\n# define sk_CONF_IMODULE_delete(st, i) SKM_sk_delete(CONF_IMODULE, (st), (i))\n# define sk_CONF_IMODULE_delete_ptr(st, ptr) SKM_sk_delete_ptr(CONF_IMODULE, (st), (ptr))\n# define sk_CONF_IMODULE_insert(st, val, i) SKM_sk_insert(CONF_IMODULE, (st), (val), (i))\n# define sk_CONF_IMODULE_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(CONF_IMODULE, (st), (cmp))\n# define sk_CONF_IMODULE_dup(st) SKM_sk_dup(CONF_IMODULE, st)\n# define sk_CONF_IMODULE_pop_free(st, free_func) SKM_sk_pop_free(CONF_IMODULE, (st), (free_func))\n# define sk_CONF_IMODULE_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(CONF_IMODULE, (st), (copy_func), (free_func))\n# define sk_CONF_IMODULE_shift(st) SKM_sk_shift(CONF_IMODULE, (st))\n# define sk_CONF_IMODULE_pop(st) SKM_sk_pop(CONF_IMODULE, (st))\n# define sk_CONF_IMODULE_sort(st) SKM_sk_sort(CONF_IMODULE, (st))\n# define sk_CONF_IMODULE_is_sorted(st) SKM_sk_is_sorted(CONF_IMODULE, (st))\n# define sk_CONF_MODULE_new(cmp) SKM_sk_new(CONF_MODULE, (cmp))\n# define sk_CONF_MODULE_new_null() SKM_sk_new_null(CONF_MODULE)\n# define sk_CONF_MODULE_free(st) SKM_sk_free(CONF_MODULE, (st))\n# define sk_CONF_MODULE_num(st) SKM_sk_num(CONF_MODULE, (st))\n# define sk_CONF_MODULE_value(st, i) SKM_sk_value(CONF_MODULE, (st), (i))\n# define sk_CONF_MODULE_set(st, i, val) SKM_sk_set(CONF_MODULE, (st), (i), (val))\n# define sk_CONF_MODULE_zero(st) SKM_sk_zero(CONF_MODULE, (st))\n# define sk_CONF_MODULE_push(st, val) SKM_sk_push(CONF_MODULE, (st), (val))\n# define sk_CONF_MODULE_unshift(st, val) SKM_sk_unshift(CONF_MODULE, (st), (val))\n# define sk_CONF_MODULE_find(st, val) SKM_sk_find(CONF_MODULE, (st), (val))\n# define sk_CONF_MODULE_find_ex(st, val) SKM_sk_find_ex(CONF_MODULE, (st), (val))\n# define sk_CONF_MODULE_delete(st, i) SKM_sk_delete(CONF_MODULE, (st), (i))\n# define sk_CONF_MODULE_delete_ptr(st, ptr) SKM_sk_delete_ptr(CONF_MODULE, (st), (ptr))\n# define sk_CONF_MODULE_insert(st, val, i) SKM_sk_insert(CONF_MODULE, (st), (val), (i))\n# define sk_CONF_MODULE_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(CONF_MODULE, (st), (cmp))\n# define sk_CONF_MODULE_dup(st) SKM_sk_dup(CONF_MODULE, st)\n# define sk_CONF_MODULE_pop_free(st, free_func) SKM_sk_pop_free(CONF_MODULE, (st), (free_func))\n# define sk_CONF_MODULE_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(CONF_MODULE, (st), (copy_func), (free_func))\n# define sk_CONF_MODULE_shift(st) SKM_sk_shift(CONF_MODULE, (st))\n# define sk_CONF_MODULE_pop(st) SKM_sk_pop(CONF_MODULE, (st))\n# define sk_CONF_MODULE_sort(st) SKM_sk_sort(CONF_MODULE, (st))\n# define sk_CONF_MODULE_is_sorted(st) SKM_sk_is_sorted(CONF_MODULE, (st))\n# define sk_CONF_VALUE_new(cmp) SKM_sk_new(CONF_VALUE, (cmp))\n# define sk_CONF_VALUE_new_null() SKM_sk_new_null(CONF_VALUE)\n# define sk_CONF_VALUE_free(st) SKM_sk_free(CONF_VALUE, (st))\n# define sk_CONF_VALUE_num(st) SKM_sk_num(CONF_VALUE, (st))\n# define sk_CONF_VALUE_value(st, i) SKM_sk_value(CONF_VALUE, (st), (i))\n# define sk_CONF_VALUE_set(st, i, val) SKM_sk_set(CONF_VALUE, (st), (i), (val))\n# define sk_CONF_VALUE_zero(st) SKM_sk_zero(CONF_VALUE, (st))\n# define sk_CONF_VALUE_push(st, val) SKM_sk_push(CONF_VALUE, (st), (val))\n# define sk_CONF_VALUE_unshift(st, val) SKM_sk_unshift(CONF_VALUE, (st), (val))\n# define sk_CONF_VALUE_find(st, val) SKM_sk_find(CONF_VALUE, (st), (val))\n# define sk_CONF_VALUE_find_ex(st, val) SKM_sk_find_ex(CONF_VALUE, (st), (val))\n# define sk_CONF_VALUE_delete(st, i) SKM_sk_delete(CONF_VALUE, (st), (i))\n# define sk_CONF_VALUE_delete_ptr(st, ptr) SKM_sk_delete_ptr(CONF_VALUE, (st), (ptr))\n# define sk_CONF_VALUE_insert(st, val, i) SKM_sk_insert(CONF_VALUE, (st), (val), (i))\n# define sk_CONF_VALUE_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(CONF_VALUE, (st), (cmp))\n# define sk_CONF_VALUE_dup(st) SKM_sk_dup(CONF_VALUE, st)\n# define sk_CONF_VALUE_pop_free(st, free_func) SKM_sk_pop_free(CONF_VALUE, (st), (free_func))\n# define sk_CONF_VALUE_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(CONF_VALUE, (st), (copy_func), (free_func))\n# define sk_CONF_VALUE_shift(st) SKM_sk_shift(CONF_VALUE, (st))\n# define sk_CONF_VALUE_pop(st) SKM_sk_pop(CONF_VALUE, (st))\n# define sk_CONF_VALUE_sort(st) SKM_sk_sort(CONF_VALUE, (st))\n# define sk_CONF_VALUE_is_sorted(st) SKM_sk_is_sorted(CONF_VALUE, (st))\n# define sk_CRYPTO_EX_DATA_FUNCS_new(cmp) SKM_sk_new(CRYPTO_EX_DATA_FUNCS, (cmp))\n# define sk_CRYPTO_EX_DATA_FUNCS_new_null() SKM_sk_new_null(CRYPTO_EX_DATA_FUNCS)\n# define sk_CRYPTO_EX_DATA_FUNCS_free(st) SKM_sk_free(CRYPTO_EX_DATA_FUNCS, (st))\n# define sk_CRYPTO_EX_DATA_FUNCS_num(st) SKM_sk_num(CRYPTO_EX_DATA_FUNCS, (st))\n# define sk_CRYPTO_EX_DATA_FUNCS_value(st, i) SKM_sk_value(CRYPTO_EX_DATA_FUNCS, (st), (i))\n# define sk_CRYPTO_EX_DATA_FUNCS_set(st, i, val) SKM_sk_set(CRYPTO_EX_DATA_FUNCS, (st), (i), (val))\n# define sk_CRYPTO_EX_DATA_FUNCS_zero(st) SKM_sk_zero(CRYPTO_EX_DATA_FUNCS, (st))\n# define sk_CRYPTO_EX_DATA_FUNCS_push(st, val) SKM_sk_push(CRYPTO_EX_DATA_FUNCS, (st), (val))\n# define sk_CRYPTO_EX_DATA_FUNCS_unshift(st, val) SKM_sk_unshift(CRYPTO_EX_DATA_FUNCS, (st), (val))\n# define sk_CRYPTO_EX_DATA_FUNCS_find(st, val) SKM_sk_find(CRYPTO_EX_DATA_FUNCS, (st), (val))\n# define sk_CRYPTO_EX_DATA_FUNCS_find_ex(st, val) SKM_sk_find_ex(CRYPTO_EX_DATA_FUNCS, (st), (val))\n# define sk_CRYPTO_EX_DATA_FUNCS_delete(st, i) SKM_sk_delete(CRYPTO_EX_DATA_FUNCS, (st), (i))\n# define sk_CRYPTO_EX_DATA_FUNCS_delete_ptr(st, ptr) SKM_sk_delete_ptr(CRYPTO_EX_DATA_FUNCS, (st), (ptr))\n# define sk_CRYPTO_EX_DATA_FUNCS_insert(st, val, i) SKM_sk_insert(CRYPTO_EX_DATA_FUNCS, (st), (val), (i))\n# define sk_CRYPTO_EX_DATA_FUNCS_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(CRYPTO_EX_DATA_FUNCS, (st), (cmp))\n# define sk_CRYPTO_EX_DATA_FUNCS_dup(st) SKM_sk_dup(CRYPTO_EX_DATA_FUNCS, st)\n# define sk_CRYPTO_EX_DATA_FUNCS_pop_free(st, free_func) SKM_sk_pop_free(CRYPTO_EX_DATA_FUNCS, (st), (free_func))\n# define sk_CRYPTO_EX_DATA_FUNCS_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(CRYPTO_EX_DATA_FUNCS, (st), (copy_func), (free_func))\n# define sk_CRYPTO_EX_DATA_FUNCS_shift(st) SKM_sk_shift(CRYPTO_EX_DATA_FUNCS, (st))\n# define sk_CRYPTO_EX_DATA_FUNCS_pop(st) SKM_sk_pop(CRYPTO_EX_DATA_FUNCS, (st))\n# define sk_CRYPTO_EX_DATA_FUNCS_sort(st) SKM_sk_sort(CRYPTO_EX_DATA_FUNCS, (st))\n# define sk_CRYPTO_EX_DATA_FUNCS_is_sorted(st) SKM_sk_is_sorted(CRYPTO_EX_DATA_FUNCS, (st))\n# define sk_CRYPTO_dynlock_new(cmp) SKM_sk_new(CRYPTO_dynlock, (cmp))\n# define sk_CRYPTO_dynlock_new_null() SKM_sk_new_null(CRYPTO_dynlock)\n# define sk_CRYPTO_dynlock_free(st) SKM_sk_free(CRYPTO_dynlock, (st))\n# define sk_CRYPTO_dynlock_num(st) SKM_sk_num(CRYPTO_dynlock, (st))\n# define sk_CRYPTO_dynlock_value(st, i) SKM_sk_value(CRYPTO_dynlock, (st), (i))\n# define sk_CRYPTO_dynlock_set(st, i, val) SKM_sk_set(CRYPTO_dynlock, (st), (i), (val))\n# define sk_CRYPTO_dynlock_zero(st) SKM_sk_zero(CRYPTO_dynlock, (st))\n# define sk_CRYPTO_dynlock_push(st, val) SKM_sk_push(CRYPTO_dynlock, (st), (val))\n# define sk_CRYPTO_dynlock_unshift(st, val) SKM_sk_unshift(CRYPTO_dynlock, (st), (val))\n# define sk_CRYPTO_dynlock_find(st, val) SKM_sk_find(CRYPTO_dynlock, (st), (val))\n# define sk_CRYPTO_dynlock_find_ex(st, val) SKM_sk_find_ex(CRYPTO_dynlock, (st), (val))\n# define sk_CRYPTO_dynlock_delete(st, i) SKM_sk_delete(CRYPTO_dynlock, (st), (i))\n# define sk_CRYPTO_dynlock_delete_ptr(st, ptr) SKM_sk_delete_ptr(CRYPTO_dynlock, (st), (ptr))\n# define sk_CRYPTO_dynlock_insert(st, val, i) SKM_sk_insert(CRYPTO_dynlock, (st), (val), (i))\n# define sk_CRYPTO_dynlock_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(CRYPTO_dynlock, (st), (cmp))\n# define sk_CRYPTO_dynlock_dup(st) SKM_sk_dup(CRYPTO_dynlock, st)\n# define sk_CRYPTO_dynlock_pop_free(st, free_func) SKM_sk_pop_free(CRYPTO_dynlock, (st), (free_func))\n# define sk_CRYPTO_dynlock_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(CRYPTO_dynlock, (st), (copy_func), (free_func))\n# define sk_CRYPTO_dynlock_shift(st) SKM_sk_shift(CRYPTO_dynlock, (st))\n# define sk_CRYPTO_dynlock_pop(st) SKM_sk_pop(CRYPTO_dynlock, (st))\n# define sk_CRYPTO_dynlock_sort(st) SKM_sk_sort(CRYPTO_dynlock, (st))\n# define sk_CRYPTO_dynlock_is_sorted(st) SKM_sk_is_sorted(CRYPTO_dynlock, (st))\n# define sk_DIST_POINT_new(cmp) SKM_sk_new(DIST_POINT, (cmp))\n# define sk_DIST_POINT_new_null() SKM_sk_new_null(DIST_POINT)\n# define sk_DIST_POINT_free(st) SKM_sk_free(DIST_POINT, (st))\n# define sk_DIST_POINT_num(st) SKM_sk_num(DIST_POINT, (st))\n# define sk_DIST_POINT_value(st, i) SKM_sk_value(DIST_POINT, (st), (i))\n# define sk_DIST_POINT_set(st, i, val) SKM_sk_set(DIST_POINT, (st), (i), (val))\n# define sk_DIST_POINT_zero(st) SKM_sk_zero(DIST_POINT, (st))\n# define sk_DIST_POINT_push(st, val) SKM_sk_push(DIST_POINT, (st), (val))\n# define sk_DIST_POINT_unshift(st, val) SKM_sk_unshift(DIST_POINT, (st), (val))\n# define sk_DIST_POINT_find(st, val) SKM_sk_find(DIST_POINT, (st), (val))\n# define sk_DIST_POINT_find_ex(st, val) SKM_sk_find_ex(DIST_POINT, (st), (val))\n# define sk_DIST_POINT_delete(st, i) SKM_sk_delete(DIST_POINT, (st), (i))\n# define sk_DIST_POINT_delete_ptr(st, ptr) SKM_sk_delete_ptr(DIST_POINT, (st), (ptr))\n# define sk_DIST_POINT_insert(st, val, i) SKM_sk_insert(DIST_POINT, (st), (val), (i))\n# define sk_DIST_POINT_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(DIST_POINT, (st), (cmp))\n# define sk_DIST_POINT_dup(st) SKM_sk_dup(DIST_POINT, st)\n# define sk_DIST_POINT_pop_free(st, free_func) SKM_sk_pop_free(DIST_POINT, (st), (free_func))\n# define sk_DIST_POINT_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(DIST_POINT, (st), (copy_func), (free_func))\n# define sk_DIST_POINT_shift(st) SKM_sk_shift(DIST_POINT, (st))\n# define sk_DIST_POINT_pop(st) SKM_sk_pop(DIST_POINT, (st))\n# define sk_DIST_POINT_sort(st) SKM_sk_sort(DIST_POINT, (st))\n# define sk_DIST_POINT_is_sorted(st) SKM_sk_is_sorted(DIST_POINT, (st))\n# define sk_ENGINE_new(cmp) SKM_sk_new(ENGINE, (cmp))\n# define sk_ENGINE_new_null() SKM_sk_new_null(ENGINE)\n# define sk_ENGINE_free(st) SKM_sk_free(ENGINE, (st))\n# define sk_ENGINE_num(st) SKM_sk_num(ENGINE, (st))\n# define sk_ENGINE_value(st, i) SKM_sk_value(ENGINE, (st), (i))\n# define sk_ENGINE_set(st, i, val) SKM_sk_set(ENGINE, (st), (i), (val))\n# define sk_ENGINE_zero(st) SKM_sk_zero(ENGINE, (st))\n# define sk_ENGINE_push(st, val) SKM_sk_push(ENGINE, (st), (val))\n# define sk_ENGINE_unshift(st, val) SKM_sk_unshift(ENGINE, (st), (val))\n# define sk_ENGINE_find(st, val) SKM_sk_find(ENGINE, (st), (val))\n# define sk_ENGINE_find_ex(st, val) SKM_sk_find_ex(ENGINE, (st), (val))\n# define sk_ENGINE_delete(st, i) SKM_sk_delete(ENGINE, (st), (i))\n# define sk_ENGINE_delete_ptr(st, ptr) SKM_sk_delete_ptr(ENGINE, (st), (ptr))\n# define sk_ENGINE_insert(st, val, i) SKM_sk_insert(ENGINE, (st), (val), (i))\n# define sk_ENGINE_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(ENGINE, (st), (cmp))\n# define sk_ENGINE_dup(st) SKM_sk_dup(ENGINE, st)\n# define sk_ENGINE_pop_free(st, free_func) SKM_sk_pop_free(ENGINE, (st), (free_func))\n# define sk_ENGINE_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(ENGINE, (st), (copy_func), (free_func))\n# define sk_ENGINE_shift(st) SKM_sk_shift(ENGINE, (st))\n# define sk_ENGINE_pop(st) SKM_sk_pop(ENGINE, (st))\n# define sk_ENGINE_sort(st) SKM_sk_sort(ENGINE, (st))\n# define sk_ENGINE_is_sorted(st) SKM_sk_is_sorted(ENGINE, (st))\n# define sk_ENGINE_CLEANUP_ITEM_new(cmp) SKM_sk_new(ENGINE_CLEANUP_ITEM, (cmp))\n# define sk_ENGINE_CLEANUP_ITEM_new_null() SKM_sk_new_null(ENGINE_CLEANUP_ITEM)\n# define sk_ENGINE_CLEANUP_ITEM_free(st) SKM_sk_free(ENGINE_CLEANUP_ITEM, (st))\n# define sk_ENGINE_CLEANUP_ITEM_num(st) SKM_sk_num(ENGINE_CLEANUP_ITEM, (st))\n# define sk_ENGINE_CLEANUP_ITEM_value(st, i) SKM_sk_value(ENGINE_CLEANUP_ITEM, (st), (i))\n# define sk_ENGINE_CLEANUP_ITEM_set(st, i, val) SKM_sk_set(ENGINE_CLEANUP_ITEM, (st), (i), (val))\n# define sk_ENGINE_CLEANUP_ITEM_zero(st) SKM_sk_zero(ENGINE_CLEANUP_ITEM, (st))\n# define sk_ENGINE_CLEANUP_ITEM_push(st, val) SKM_sk_push(ENGINE_CLEANUP_ITEM, (st), (val))\n# define sk_ENGINE_CLEANUP_ITEM_unshift(st, val) SKM_sk_unshift(ENGINE_CLEANUP_ITEM, (st), (val))\n# define sk_ENGINE_CLEANUP_ITEM_find(st, val) SKM_sk_find(ENGINE_CLEANUP_ITEM, (st), (val))\n# define sk_ENGINE_CLEANUP_ITEM_find_ex(st, val) SKM_sk_find_ex(ENGINE_CLEANUP_ITEM, (st), (val))\n# define sk_ENGINE_CLEANUP_ITEM_delete(st, i) SKM_sk_delete(ENGINE_CLEANUP_ITEM, (st), (i))\n# define sk_ENGINE_CLEANUP_ITEM_delete_ptr(st, ptr) SKM_sk_delete_ptr(ENGINE_CLEANUP_ITEM, (st), (ptr))\n# define sk_ENGINE_CLEANUP_ITEM_insert(st, val, i) SKM_sk_insert(ENGINE_CLEANUP_ITEM, (st), (val), (i))\n# define sk_ENGINE_CLEANUP_ITEM_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(ENGINE_CLEANUP_ITEM, (st), (cmp))\n# define sk_ENGINE_CLEANUP_ITEM_dup(st) SKM_sk_dup(ENGINE_CLEANUP_ITEM, st)\n# define sk_ENGINE_CLEANUP_ITEM_pop_free(st, free_func) SKM_sk_pop_free(ENGINE_CLEANUP_ITEM, (st), (free_func))\n# define sk_ENGINE_CLEANUP_ITEM_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(ENGINE_CLEANUP_ITEM, (st), (copy_func), (free_func))\n# define sk_ENGINE_CLEANUP_ITEM_shift(st) SKM_sk_shift(ENGINE_CLEANUP_ITEM, (st))\n# define sk_ENGINE_CLEANUP_ITEM_pop(st) SKM_sk_pop(ENGINE_CLEANUP_ITEM, (st))\n# define sk_ENGINE_CLEANUP_ITEM_sort(st) SKM_sk_sort(ENGINE_CLEANUP_ITEM, (st))\n# define sk_ENGINE_CLEANUP_ITEM_is_sorted(st) SKM_sk_is_sorted(ENGINE_CLEANUP_ITEM, (st))\n# define sk_ESS_CERT_ID_new(cmp) SKM_sk_new(ESS_CERT_ID, (cmp))\n# define sk_ESS_CERT_ID_new_null() SKM_sk_new_null(ESS_CERT_ID)\n# define sk_ESS_CERT_ID_free(st) SKM_sk_free(ESS_CERT_ID, (st))\n# define sk_ESS_CERT_ID_num(st) SKM_sk_num(ESS_CERT_ID, (st))\n# define sk_ESS_CERT_ID_value(st, i) SKM_sk_value(ESS_CERT_ID, (st), (i))\n# define sk_ESS_CERT_ID_set(st, i, val) SKM_sk_set(ESS_CERT_ID, (st), (i), (val))\n# define sk_ESS_CERT_ID_zero(st) SKM_sk_zero(ESS_CERT_ID, (st))\n# define sk_ESS_CERT_ID_push(st, val) SKM_sk_push(ESS_CERT_ID, (st), (val))\n# define sk_ESS_CERT_ID_unshift(st, val) SKM_sk_unshift(ESS_CERT_ID, (st), (val))\n# define sk_ESS_CERT_ID_find(st, val) SKM_sk_find(ESS_CERT_ID, (st), (val))\n# define sk_ESS_CERT_ID_find_ex(st, val) SKM_sk_find_ex(ESS_CERT_ID, (st), (val))\n# define sk_ESS_CERT_ID_delete(st, i) SKM_sk_delete(ESS_CERT_ID, (st), (i))\n# define sk_ESS_CERT_ID_delete_ptr(st, ptr) SKM_sk_delete_ptr(ESS_CERT_ID, (st), (ptr))\n# define sk_ESS_CERT_ID_insert(st, val, i) SKM_sk_insert(ESS_CERT_ID, (st), (val), (i))\n# define sk_ESS_CERT_ID_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(ESS_CERT_ID, (st), (cmp))\n# define sk_ESS_CERT_ID_dup(st) SKM_sk_dup(ESS_CERT_ID, st)\n# define sk_ESS_CERT_ID_pop_free(st, free_func) SKM_sk_pop_free(ESS_CERT_ID, (st), (free_func))\n# define sk_ESS_CERT_ID_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(ESS_CERT_ID, (st), (copy_func), (free_func))\n# define sk_ESS_CERT_ID_shift(st) SKM_sk_shift(ESS_CERT_ID, (st))\n# define sk_ESS_CERT_ID_pop(st) SKM_sk_pop(ESS_CERT_ID, (st))\n# define sk_ESS_CERT_ID_sort(st) SKM_sk_sort(ESS_CERT_ID, (st))\n# define sk_ESS_CERT_ID_is_sorted(st) SKM_sk_is_sorted(ESS_CERT_ID, (st))\n# define sk_EVP_MD_new(cmp) SKM_sk_new(EVP_MD, (cmp))\n# define sk_EVP_MD_new_null() SKM_sk_new_null(EVP_MD)\n# define sk_EVP_MD_free(st) SKM_sk_free(EVP_MD, (st))\n# define sk_EVP_MD_num(st) SKM_sk_num(EVP_MD, (st))\n# define sk_EVP_MD_value(st, i) SKM_sk_value(EVP_MD, (st), (i))\n# define sk_EVP_MD_set(st, i, val) SKM_sk_set(EVP_MD, (st), (i), (val))\n# define sk_EVP_MD_zero(st) SKM_sk_zero(EVP_MD, (st))\n# define sk_EVP_MD_push(st, val) SKM_sk_push(EVP_MD, (st), (val))\n# define sk_EVP_MD_unshift(st, val) SKM_sk_unshift(EVP_MD, (st), (val))\n# define sk_EVP_MD_find(st, val) SKM_sk_find(EVP_MD, (st), (val))\n# define sk_EVP_MD_find_ex(st, val) SKM_sk_find_ex(EVP_MD, (st), (val))\n# define sk_EVP_MD_delete(st, i) SKM_sk_delete(EVP_MD, (st), (i))\n# define sk_EVP_MD_delete_ptr(st, ptr) SKM_sk_delete_ptr(EVP_MD, (st), (ptr))\n# define sk_EVP_MD_insert(st, val, i) SKM_sk_insert(EVP_MD, (st), (val), (i))\n# define sk_EVP_MD_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(EVP_MD, (st), (cmp))\n# define sk_EVP_MD_dup(st) SKM_sk_dup(EVP_MD, st)\n# define sk_EVP_MD_pop_free(st, free_func) SKM_sk_pop_free(EVP_MD, (st), (free_func))\n# define sk_EVP_MD_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(EVP_MD, (st), (copy_func), (free_func))\n# define sk_EVP_MD_shift(st) SKM_sk_shift(EVP_MD, (st))\n# define sk_EVP_MD_pop(st) SKM_sk_pop(EVP_MD, (st))\n# define sk_EVP_MD_sort(st) SKM_sk_sort(EVP_MD, (st))\n# define sk_EVP_MD_is_sorted(st) SKM_sk_is_sorted(EVP_MD, (st))\n# define sk_EVP_PBE_CTL_new(cmp) SKM_sk_new(EVP_PBE_CTL, (cmp))\n# define sk_EVP_PBE_CTL_new_null() SKM_sk_new_null(EVP_PBE_CTL)\n# define sk_EVP_PBE_CTL_free(st) SKM_sk_free(EVP_PBE_CTL, (st))\n# define sk_EVP_PBE_CTL_num(st) SKM_sk_num(EVP_PBE_CTL, (st))\n# define sk_EVP_PBE_CTL_value(st, i) SKM_sk_value(EVP_PBE_CTL, (st), (i))\n# define sk_EVP_PBE_CTL_set(st, i, val) SKM_sk_set(EVP_PBE_CTL, (st), (i), (val))\n# define sk_EVP_PBE_CTL_zero(st) SKM_sk_zero(EVP_PBE_CTL, (st))\n# define sk_EVP_PBE_CTL_push(st, val) SKM_sk_push(EVP_PBE_CTL, (st), (val))\n# define sk_EVP_PBE_CTL_unshift(st, val) SKM_sk_unshift(EVP_PBE_CTL, (st), (val))\n# define sk_EVP_PBE_CTL_find(st, val) SKM_sk_find(EVP_PBE_CTL, (st), (val))\n# define sk_EVP_PBE_CTL_find_ex(st, val) SKM_sk_find_ex(EVP_PBE_CTL, (st), (val))\n# define sk_EVP_PBE_CTL_delete(st, i) SKM_sk_delete(EVP_PBE_CTL, (st), (i))\n# define sk_EVP_PBE_CTL_delete_ptr(st, ptr) SKM_sk_delete_ptr(EVP_PBE_CTL, (st), (ptr))\n# define sk_EVP_PBE_CTL_insert(st, val, i) SKM_sk_insert(EVP_PBE_CTL, (st), (val), (i))\n# define sk_EVP_PBE_CTL_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(EVP_PBE_CTL, (st), (cmp))\n# define sk_EVP_PBE_CTL_dup(st) SKM_sk_dup(EVP_PBE_CTL, st)\n# define sk_EVP_PBE_CTL_pop_free(st, free_func) SKM_sk_pop_free(EVP_PBE_CTL, (st), (free_func))\n# define sk_EVP_PBE_CTL_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(EVP_PBE_CTL, (st), (copy_func), (free_func))\n# define sk_EVP_PBE_CTL_shift(st) SKM_sk_shift(EVP_PBE_CTL, (st))\n# define sk_EVP_PBE_CTL_pop(st) SKM_sk_pop(EVP_PBE_CTL, (st))\n# define sk_EVP_PBE_CTL_sort(st) SKM_sk_sort(EVP_PBE_CTL, (st))\n# define sk_EVP_PBE_CTL_is_sorted(st) SKM_sk_is_sorted(EVP_PBE_CTL, (st))\n# define sk_EVP_PKEY_ASN1_METHOD_new(cmp) SKM_sk_new(EVP_PKEY_ASN1_METHOD, (cmp))\n# define sk_EVP_PKEY_ASN1_METHOD_new_null() SKM_sk_new_null(EVP_PKEY_ASN1_METHOD)\n# define sk_EVP_PKEY_ASN1_METHOD_free(st) SKM_sk_free(EVP_PKEY_ASN1_METHOD, (st))\n# define sk_EVP_PKEY_ASN1_METHOD_num(st) SKM_sk_num(EVP_PKEY_ASN1_METHOD, (st))\n# define sk_EVP_PKEY_ASN1_METHOD_value(st, i) SKM_sk_value(EVP_PKEY_ASN1_METHOD, (st), (i))\n# define sk_EVP_PKEY_ASN1_METHOD_set(st, i, val) SKM_sk_set(EVP_PKEY_ASN1_METHOD, (st), (i), (val))\n# define sk_EVP_PKEY_ASN1_METHOD_zero(st) SKM_sk_zero(EVP_PKEY_ASN1_METHOD, (st))\n# define sk_EVP_PKEY_ASN1_METHOD_push(st, val) SKM_sk_push(EVP_PKEY_ASN1_METHOD, (st), (val))\n# define sk_EVP_PKEY_ASN1_METHOD_unshift(st, val) SKM_sk_unshift(EVP_PKEY_ASN1_METHOD, (st), (val))\n# define sk_EVP_PKEY_ASN1_METHOD_find(st, val) SKM_sk_find(EVP_PKEY_ASN1_METHOD, (st), (val))\n# define sk_EVP_PKEY_ASN1_METHOD_find_ex(st, val) SKM_sk_find_ex(EVP_PKEY_ASN1_METHOD, (st), (val))\n# define sk_EVP_PKEY_ASN1_METHOD_delete(st, i) SKM_sk_delete(EVP_PKEY_ASN1_METHOD, (st), (i))\n# define sk_EVP_PKEY_ASN1_METHOD_delete_ptr(st, ptr) SKM_sk_delete_ptr(EVP_PKEY_ASN1_METHOD, (st), (ptr))\n# define sk_EVP_PKEY_ASN1_METHOD_insert(st, val, i) SKM_sk_insert(EVP_PKEY_ASN1_METHOD, (st), (val), (i))\n# define sk_EVP_PKEY_ASN1_METHOD_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(EVP_PKEY_ASN1_METHOD, (st), (cmp))\n# define sk_EVP_PKEY_ASN1_METHOD_dup(st) SKM_sk_dup(EVP_PKEY_ASN1_METHOD, st)\n# define sk_EVP_PKEY_ASN1_METHOD_pop_free(st, free_func) SKM_sk_pop_free(EVP_PKEY_ASN1_METHOD, (st), (free_func))\n# define sk_EVP_PKEY_ASN1_METHOD_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(EVP_PKEY_ASN1_METHOD, (st), (copy_func), (free_func))\n# define sk_EVP_PKEY_ASN1_METHOD_shift(st) SKM_sk_shift(EVP_PKEY_ASN1_METHOD, (st))\n# define sk_EVP_PKEY_ASN1_METHOD_pop(st) SKM_sk_pop(EVP_PKEY_ASN1_METHOD, (st))\n# define sk_EVP_PKEY_ASN1_METHOD_sort(st) SKM_sk_sort(EVP_PKEY_ASN1_METHOD, (st))\n# define sk_EVP_PKEY_ASN1_METHOD_is_sorted(st) SKM_sk_is_sorted(EVP_PKEY_ASN1_METHOD, (st))\n# define sk_EVP_PKEY_METHOD_new(cmp) SKM_sk_new(EVP_PKEY_METHOD, (cmp))\n# define sk_EVP_PKEY_METHOD_new_null() SKM_sk_new_null(EVP_PKEY_METHOD)\n# define sk_EVP_PKEY_METHOD_free(st) SKM_sk_free(EVP_PKEY_METHOD, (st))\n# define sk_EVP_PKEY_METHOD_num(st) SKM_sk_num(EVP_PKEY_METHOD, (st))\n# define sk_EVP_PKEY_METHOD_value(st, i) SKM_sk_value(EVP_PKEY_METHOD, (st), (i))\n# define sk_EVP_PKEY_METHOD_set(st, i, val) SKM_sk_set(EVP_PKEY_METHOD, (st), (i), (val))\n# define sk_EVP_PKEY_METHOD_zero(st) SKM_sk_zero(EVP_PKEY_METHOD, (st))\n# define sk_EVP_PKEY_METHOD_push(st, val) SKM_sk_push(EVP_PKEY_METHOD, (st), (val))\n# define sk_EVP_PKEY_METHOD_unshift(st, val) SKM_sk_unshift(EVP_PKEY_METHOD, (st), (val))\n# define sk_EVP_PKEY_METHOD_find(st, val) SKM_sk_find(EVP_PKEY_METHOD, (st), (val))\n# define sk_EVP_PKEY_METHOD_find_ex(st, val) SKM_sk_find_ex(EVP_PKEY_METHOD, (st), (val))\n# define sk_EVP_PKEY_METHOD_delete(st, i) SKM_sk_delete(EVP_PKEY_METHOD, (st), (i))\n# define sk_EVP_PKEY_METHOD_delete_ptr(st, ptr) SKM_sk_delete_ptr(EVP_PKEY_METHOD, (st), (ptr))\n# define sk_EVP_PKEY_METHOD_insert(st, val, i) SKM_sk_insert(EVP_PKEY_METHOD, (st), (val), (i))\n# define sk_EVP_PKEY_METHOD_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(EVP_PKEY_METHOD, (st), (cmp))\n# define sk_EVP_PKEY_METHOD_dup(st) SKM_sk_dup(EVP_PKEY_METHOD, st)\n# define sk_EVP_PKEY_METHOD_pop_free(st, free_func) SKM_sk_pop_free(EVP_PKEY_METHOD, (st), (free_func))\n# define sk_EVP_PKEY_METHOD_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(EVP_PKEY_METHOD, (st), (copy_func), (free_func))\n# define sk_EVP_PKEY_METHOD_shift(st) SKM_sk_shift(EVP_PKEY_METHOD, (st))\n# define sk_EVP_PKEY_METHOD_pop(st) SKM_sk_pop(EVP_PKEY_METHOD, (st))\n# define sk_EVP_PKEY_METHOD_sort(st) SKM_sk_sort(EVP_PKEY_METHOD, (st))\n# define sk_EVP_PKEY_METHOD_is_sorted(st) SKM_sk_is_sorted(EVP_PKEY_METHOD, (st))\n# define sk_GENERAL_NAME_new(cmp) SKM_sk_new(GENERAL_NAME, (cmp))\n# define sk_GENERAL_NAME_new_null() SKM_sk_new_null(GENERAL_NAME)\n# define sk_GENERAL_NAME_free(st) SKM_sk_free(GENERAL_NAME, (st))\n# define sk_GENERAL_NAME_num(st) SKM_sk_num(GENERAL_NAME, (st))\n# define sk_GENERAL_NAME_value(st, i) SKM_sk_value(GENERAL_NAME, (st), (i))\n# define sk_GENERAL_NAME_set(st, i, val) SKM_sk_set(GENERAL_NAME, (st), (i), (val))\n# define sk_GENERAL_NAME_zero(st) SKM_sk_zero(GENERAL_NAME, (st))\n# define sk_GENERAL_NAME_push(st, val) SKM_sk_push(GENERAL_NAME, (st), (val))\n# define sk_GENERAL_NAME_unshift(st, val) SKM_sk_unshift(GENERAL_NAME, (st), (val))\n# define sk_GENERAL_NAME_find(st, val) SKM_sk_find(GENERAL_NAME, (st), (val))\n# define sk_GENERAL_NAME_find_ex(st, val) SKM_sk_find_ex(GENERAL_NAME, (st), (val))\n# define sk_GENERAL_NAME_delete(st, i) SKM_sk_delete(GENERAL_NAME, (st), (i))\n# define sk_GENERAL_NAME_delete_ptr(st, ptr) SKM_sk_delete_ptr(GENERAL_NAME, (st), (ptr))\n# define sk_GENERAL_NAME_insert(st, val, i) SKM_sk_insert(GENERAL_NAME, (st), (val), (i))\n# define sk_GENERAL_NAME_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(GENERAL_NAME, (st), (cmp))\n# define sk_GENERAL_NAME_dup(st) SKM_sk_dup(GENERAL_NAME, st)\n# define sk_GENERAL_NAME_pop_free(st, free_func) SKM_sk_pop_free(GENERAL_NAME, (st), (free_func))\n# define sk_GENERAL_NAME_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(GENERAL_NAME, (st), (copy_func), (free_func))\n# define sk_GENERAL_NAME_shift(st) SKM_sk_shift(GENERAL_NAME, (st))\n# define sk_GENERAL_NAME_pop(st) SKM_sk_pop(GENERAL_NAME, (st))\n# define sk_GENERAL_NAME_sort(st) SKM_sk_sort(GENERAL_NAME, (st))\n# define sk_GENERAL_NAME_is_sorted(st) SKM_sk_is_sorted(GENERAL_NAME, (st))\n# define sk_GENERAL_NAMES_new(cmp) SKM_sk_new(GENERAL_NAMES, (cmp))\n# define sk_GENERAL_NAMES_new_null() SKM_sk_new_null(GENERAL_NAMES)\n# define sk_GENERAL_NAMES_free(st) SKM_sk_free(GENERAL_NAMES, (st))\n# define sk_GENERAL_NAMES_num(st) SKM_sk_num(GENERAL_NAMES, (st))\n# define sk_GENERAL_NAMES_value(st, i) SKM_sk_value(GENERAL_NAMES, (st), (i))\n# define sk_GENERAL_NAMES_set(st, i, val) SKM_sk_set(GENERAL_NAMES, (st), (i), (val))\n# define sk_GENERAL_NAMES_zero(st) SKM_sk_zero(GENERAL_NAMES, (st))\n# define sk_GENERAL_NAMES_push(st, val) SKM_sk_push(GENERAL_NAMES, (st), (val))\n# define sk_GENERAL_NAMES_unshift(st, val) SKM_sk_unshift(GENERAL_NAMES, (st), (val))\n# define sk_GENERAL_NAMES_find(st, val) SKM_sk_find(GENERAL_NAMES, (st), (val))\n# define sk_GENERAL_NAMES_find_ex(st, val) SKM_sk_find_ex(GENERAL_NAMES, (st), (val))\n# define sk_GENERAL_NAMES_delete(st, i) SKM_sk_delete(GENERAL_NAMES, (st), (i))\n# define sk_GENERAL_NAMES_delete_ptr(st, ptr) SKM_sk_delete_ptr(GENERAL_NAMES, (st), (ptr))\n# define sk_GENERAL_NAMES_insert(st, val, i) SKM_sk_insert(GENERAL_NAMES, (st), (val), (i))\n# define sk_GENERAL_NAMES_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(GENERAL_NAMES, (st), (cmp))\n# define sk_GENERAL_NAMES_dup(st) SKM_sk_dup(GENERAL_NAMES, st)\n# define sk_GENERAL_NAMES_pop_free(st, free_func) SKM_sk_pop_free(GENERAL_NAMES, (st), (free_func))\n# define sk_GENERAL_NAMES_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(GENERAL_NAMES, (st), (copy_func), (free_func))\n# define sk_GENERAL_NAMES_shift(st) SKM_sk_shift(GENERAL_NAMES, (st))\n# define sk_GENERAL_NAMES_pop(st) SKM_sk_pop(GENERAL_NAMES, (st))\n# define sk_GENERAL_NAMES_sort(st) SKM_sk_sort(GENERAL_NAMES, (st))\n# define sk_GENERAL_NAMES_is_sorted(st) SKM_sk_is_sorted(GENERAL_NAMES, (st))\n# define sk_GENERAL_SUBTREE_new(cmp) SKM_sk_new(GENERAL_SUBTREE, (cmp))\n# define sk_GENERAL_SUBTREE_new_null() SKM_sk_new_null(GENERAL_SUBTREE)\n# define sk_GENERAL_SUBTREE_free(st) SKM_sk_free(GENERAL_SUBTREE, (st))\n# define sk_GENERAL_SUBTREE_num(st) SKM_sk_num(GENERAL_SUBTREE, (st))\n# define sk_GENERAL_SUBTREE_value(st, i) SKM_sk_value(GENERAL_SUBTREE, (st), (i))\n# define sk_GENERAL_SUBTREE_set(st, i, val) SKM_sk_set(GENERAL_SUBTREE, (st), (i), (val))\n# define sk_GENERAL_SUBTREE_zero(st) SKM_sk_zero(GENERAL_SUBTREE, (st))\n# define sk_GENERAL_SUBTREE_push(st, val) SKM_sk_push(GENERAL_SUBTREE, (st), (val))\n# define sk_GENERAL_SUBTREE_unshift(st, val) SKM_sk_unshift(GENERAL_SUBTREE, (st), (val))\n# define sk_GENERAL_SUBTREE_find(st, val) SKM_sk_find(GENERAL_SUBTREE, (st), (val))\n# define sk_GENERAL_SUBTREE_find_ex(st, val) SKM_sk_find_ex(GENERAL_SUBTREE, (st), (val))\n# define sk_GENERAL_SUBTREE_delete(st, i) SKM_sk_delete(GENERAL_SUBTREE, (st), (i))\n# define sk_GENERAL_SUBTREE_delete_ptr(st, ptr) SKM_sk_delete_ptr(GENERAL_SUBTREE, (st), (ptr))\n# define sk_GENERAL_SUBTREE_insert(st, val, i) SKM_sk_insert(GENERAL_SUBTREE, (st), (val), (i))\n# define sk_GENERAL_SUBTREE_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(GENERAL_SUBTREE, (st), (cmp))\n# define sk_GENERAL_SUBTREE_dup(st) SKM_sk_dup(GENERAL_SUBTREE, st)\n# define sk_GENERAL_SUBTREE_pop_free(st, free_func) SKM_sk_pop_free(GENERAL_SUBTREE, (st), (free_func))\n# define sk_GENERAL_SUBTREE_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(GENERAL_SUBTREE, (st), (copy_func), (free_func))\n# define sk_GENERAL_SUBTREE_shift(st) SKM_sk_shift(GENERAL_SUBTREE, (st))\n# define sk_GENERAL_SUBTREE_pop(st) SKM_sk_pop(GENERAL_SUBTREE, (st))\n# define sk_GENERAL_SUBTREE_sort(st) SKM_sk_sort(GENERAL_SUBTREE, (st))\n# define sk_GENERAL_SUBTREE_is_sorted(st) SKM_sk_is_sorted(GENERAL_SUBTREE, (st))\n# define sk_IPAddressFamily_new(cmp) SKM_sk_new(IPAddressFamily, (cmp))\n# define sk_IPAddressFamily_new_null() SKM_sk_new_null(IPAddressFamily)\n# define sk_IPAddressFamily_free(st) SKM_sk_free(IPAddressFamily, (st))\n# define sk_IPAddressFamily_num(st) SKM_sk_num(IPAddressFamily, (st))\n# define sk_IPAddressFamily_value(st, i) SKM_sk_value(IPAddressFamily, (st), (i))\n# define sk_IPAddressFamily_set(st, i, val) SKM_sk_set(IPAddressFamily, (st), (i), (val))\n# define sk_IPAddressFamily_zero(st) SKM_sk_zero(IPAddressFamily, (st))\n# define sk_IPAddressFamily_push(st, val) SKM_sk_push(IPAddressFamily, (st), (val))\n# define sk_IPAddressFamily_unshift(st, val) SKM_sk_unshift(IPAddressFamily, (st), (val))\n# define sk_IPAddressFamily_find(st, val) SKM_sk_find(IPAddressFamily, (st), (val))\n# define sk_IPAddressFamily_find_ex(st, val) SKM_sk_find_ex(IPAddressFamily, (st), (val))\n# define sk_IPAddressFamily_delete(st, i) SKM_sk_delete(IPAddressFamily, (st), (i))\n# define sk_IPAddressFamily_delete_ptr(st, ptr) SKM_sk_delete_ptr(IPAddressFamily, (st), (ptr))\n# define sk_IPAddressFamily_insert(st, val, i) SKM_sk_insert(IPAddressFamily, (st), (val), (i))\n# define sk_IPAddressFamily_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(IPAddressFamily, (st), (cmp))\n# define sk_IPAddressFamily_dup(st) SKM_sk_dup(IPAddressFamily, st)\n# define sk_IPAddressFamily_pop_free(st, free_func) SKM_sk_pop_free(IPAddressFamily, (st), (free_func))\n# define sk_IPAddressFamily_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(IPAddressFamily, (st), (copy_func), (free_func))\n# define sk_IPAddressFamily_shift(st) SKM_sk_shift(IPAddressFamily, (st))\n# define sk_IPAddressFamily_pop(st) SKM_sk_pop(IPAddressFamily, (st))\n# define sk_IPAddressFamily_sort(st) SKM_sk_sort(IPAddressFamily, (st))\n# define sk_IPAddressFamily_is_sorted(st) SKM_sk_is_sorted(IPAddressFamily, (st))\n# define sk_IPAddressOrRange_new(cmp) SKM_sk_new(IPAddressOrRange, (cmp))\n# define sk_IPAddressOrRange_new_null() SKM_sk_new_null(IPAddressOrRange)\n# define sk_IPAddressOrRange_free(st) SKM_sk_free(IPAddressOrRange, (st))\n# define sk_IPAddressOrRange_num(st) SKM_sk_num(IPAddressOrRange, (st))\n# define sk_IPAddressOrRange_value(st, i) SKM_sk_value(IPAddressOrRange, (st), (i))\n# define sk_IPAddressOrRange_set(st, i, val) SKM_sk_set(IPAddressOrRange, (st), (i), (val))\n# define sk_IPAddressOrRange_zero(st) SKM_sk_zero(IPAddressOrRange, (st))\n# define sk_IPAddressOrRange_push(st, val) SKM_sk_push(IPAddressOrRange, (st), (val))\n# define sk_IPAddressOrRange_unshift(st, val) SKM_sk_unshift(IPAddressOrRange, (st), (val))\n# define sk_IPAddressOrRange_find(st, val) SKM_sk_find(IPAddressOrRange, (st), (val))\n# define sk_IPAddressOrRange_find_ex(st, val) SKM_sk_find_ex(IPAddressOrRange, (st), (val))\n# define sk_IPAddressOrRange_delete(st, i) SKM_sk_delete(IPAddressOrRange, (st), (i))\n# define sk_IPAddressOrRange_delete_ptr(st, ptr) SKM_sk_delete_ptr(IPAddressOrRange, (st), (ptr))\n# define sk_IPAddressOrRange_insert(st, val, i) SKM_sk_insert(IPAddressOrRange, (st), (val), (i))\n# define sk_IPAddressOrRange_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(IPAddressOrRange, (st), (cmp))\n# define sk_IPAddressOrRange_dup(st) SKM_sk_dup(IPAddressOrRange, st)\n# define sk_IPAddressOrRange_pop_free(st, free_func) SKM_sk_pop_free(IPAddressOrRange, (st), (free_func))\n# define sk_IPAddressOrRange_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(IPAddressOrRange, (st), (copy_func), (free_func))\n# define sk_IPAddressOrRange_shift(st) SKM_sk_shift(IPAddressOrRange, (st))\n# define sk_IPAddressOrRange_pop(st) SKM_sk_pop(IPAddressOrRange, (st))\n# define sk_IPAddressOrRange_sort(st) SKM_sk_sort(IPAddressOrRange, (st))\n# define sk_IPAddressOrRange_is_sorted(st) SKM_sk_is_sorted(IPAddressOrRange, (st))\n# define sk_KRB5_APREQBODY_new(cmp) SKM_sk_new(KRB5_APREQBODY, (cmp))\n# define sk_KRB5_APREQBODY_new_null() SKM_sk_new_null(KRB5_APREQBODY)\n# define sk_KRB5_APREQBODY_free(st) SKM_sk_free(KRB5_APREQBODY, (st))\n# define sk_KRB5_APREQBODY_num(st) SKM_sk_num(KRB5_APREQBODY, (st))\n# define sk_KRB5_APREQBODY_value(st, i) SKM_sk_value(KRB5_APREQBODY, (st), (i))\n# define sk_KRB5_APREQBODY_set(st, i, val) SKM_sk_set(KRB5_APREQBODY, (st), (i), (val))\n# define sk_KRB5_APREQBODY_zero(st) SKM_sk_zero(KRB5_APREQBODY, (st))\n# define sk_KRB5_APREQBODY_push(st, val) SKM_sk_push(KRB5_APREQBODY, (st), (val))\n# define sk_KRB5_APREQBODY_unshift(st, val) SKM_sk_unshift(KRB5_APREQBODY, (st), (val))\n# define sk_KRB5_APREQBODY_find(st, val) SKM_sk_find(KRB5_APREQBODY, (st), (val))\n# define sk_KRB5_APREQBODY_find_ex(st, val) SKM_sk_find_ex(KRB5_APREQBODY, (st), (val))\n# define sk_KRB5_APREQBODY_delete(st, i) SKM_sk_delete(KRB5_APREQBODY, (st), (i))\n# define sk_KRB5_APREQBODY_delete_ptr(st, ptr) SKM_sk_delete_ptr(KRB5_APREQBODY, (st), (ptr))\n# define sk_KRB5_APREQBODY_insert(st, val, i) SKM_sk_insert(KRB5_APREQBODY, (st), (val), (i))\n# define sk_KRB5_APREQBODY_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(KRB5_APREQBODY, (st), (cmp))\n# define sk_KRB5_APREQBODY_dup(st) SKM_sk_dup(KRB5_APREQBODY, st)\n# define sk_KRB5_APREQBODY_pop_free(st, free_func) SKM_sk_pop_free(KRB5_APREQBODY, (st), (free_func))\n# define sk_KRB5_APREQBODY_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(KRB5_APREQBODY, (st), (copy_func), (free_func))\n# define sk_KRB5_APREQBODY_shift(st) SKM_sk_shift(KRB5_APREQBODY, (st))\n# define sk_KRB5_APREQBODY_pop(st) SKM_sk_pop(KRB5_APREQBODY, (st))\n# define sk_KRB5_APREQBODY_sort(st) SKM_sk_sort(KRB5_APREQBODY, (st))\n# define sk_KRB5_APREQBODY_is_sorted(st) SKM_sk_is_sorted(KRB5_APREQBODY, (st))\n# define sk_KRB5_AUTHDATA_new(cmp) SKM_sk_new(KRB5_AUTHDATA, (cmp))\n# define sk_KRB5_AUTHDATA_new_null() SKM_sk_new_null(KRB5_AUTHDATA)\n# define sk_KRB5_AUTHDATA_free(st) SKM_sk_free(KRB5_AUTHDATA, (st))\n# define sk_KRB5_AUTHDATA_num(st) SKM_sk_num(KRB5_AUTHDATA, (st))\n# define sk_KRB5_AUTHDATA_value(st, i) SKM_sk_value(KRB5_AUTHDATA, (st), (i))\n# define sk_KRB5_AUTHDATA_set(st, i, val) SKM_sk_set(KRB5_AUTHDATA, (st), (i), (val))\n# define sk_KRB5_AUTHDATA_zero(st) SKM_sk_zero(KRB5_AUTHDATA, (st))\n# define sk_KRB5_AUTHDATA_push(st, val) SKM_sk_push(KRB5_AUTHDATA, (st), (val))\n# define sk_KRB5_AUTHDATA_unshift(st, val) SKM_sk_unshift(KRB5_AUTHDATA, (st), (val))\n# define sk_KRB5_AUTHDATA_find(st, val) SKM_sk_find(KRB5_AUTHDATA, (st), (val))\n# define sk_KRB5_AUTHDATA_find_ex(st, val) SKM_sk_find_ex(KRB5_AUTHDATA, (st), (val))\n# define sk_KRB5_AUTHDATA_delete(st, i) SKM_sk_delete(KRB5_AUTHDATA, (st), (i))\n# define sk_KRB5_AUTHDATA_delete_ptr(st, ptr) SKM_sk_delete_ptr(KRB5_AUTHDATA, (st), (ptr))\n# define sk_KRB5_AUTHDATA_insert(st, val, i) SKM_sk_insert(KRB5_AUTHDATA, (st), (val), (i))\n# define sk_KRB5_AUTHDATA_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(KRB5_AUTHDATA, (st), (cmp))\n# define sk_KRB5_AUTHDATA_dup(st) SKM_sk_dup(KRB5_AUTHDATA, st)\n# define sk_KRB5_AUTHDATA_pop_free(st, free_func) SKM_sk_pop_free(KRB5_AUTHDATA, (st), (free_func))\n# define sk_KRB5_AUTHDATA_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(KRB5_AUTHDATA, (st), (copy_func), (free_func))\n# define sk_KRB5_AUTHDATA_shift(st) SKM_sk_shift(KRB5_AUTHDATA, (st))\n# define sk_KRB5_AUTHDATA_pop(st) SKM_sk_pop(KRB5_AUTHDATA, (st))\n# define sk_KRB5_AUTHDATA_sort(st) SKM_sk_sort(KRB5_AUTHDATA, (st))\n# define sk_KRB5_AUTHDATA_is_sorted(st) SKM_sk_is_sorted(KRB5_AUTHDATA, (st))\n# define sk_KRB5_AUTHENTBODY_new(cmp) SKM_sk_new(KRB5_AUTHENTBODY, (cmp))\n# define sk_KRB5_AUTHENTBODY_new_null() SKM_sk_new_null(KRB5_AUTHENTBODY)\n# define sk_KRB5_AUTHENTBODY_free(st) SKM_sk_free(KRB5_AUTHENTBODY, (st))\n# define sk_KRB5_AUTHENTBODY_num(st) SKM_sk_num(KRB5_AUTHENTBODY, (st))\n# define sk_KRB5_AUTHENTBODY_value(st, i) SKM_sk_value(KRB5_AUTHENTBODY, (st), (i))\n# define sk_KRB5_AUTHENTBODY_set(st, i, val) SKM_sk_set(KRB5_AUTHENTBODY, (st), (i), (val))\n# define sk_KRB5_AUTHENTBODY_zero(st) SKM_sk_zero(KRB5_AUTHENTBODY, (st))\n# define sk_KRB5_AUTHENTBODY_push(st, val) SKM_sk_push(KRB5_AUTHENTBODY, (st), (val))\n# define sk_KRB5_AUTHENTBODY_unshift(st, val) SKM_sk_unshift(KRB5_AUTHENTBODY, (st), (val))\n# define sk_KRB5_AUTHENTBODY_find(st, val) SKM_sk_find(KRB5_AUTHENTBODY, (st), (val))\n# define sk_KRB5_AUTHENTBODY_find_ex(st, val) SKM_sk_find_ex(KRB5_AUTHENTBODY, (st), (val))\n# define sk_KRB5_AUTHENTBODY_delete(st, i) SKM_sk_delete(KRB5_AUTHENTBODY, (st), (i))\n# define sk_KRB5_AUTHENTBODY_delete_ptr(st, ptr) SKM_sk_delete_ptr(KRB5_AUTHENTBODY, (st), (ptr))\n# define sk_KRB5_AUTHENTBODY_insert(st, val, i) SKM_sk_insert(KRB5_AUTHENTBODY, (st), (val), (i))\n# define sk_KRB5_AUTHENTBODY_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(KRB5_AUTHENTBODY, (st), (cmp))\n# define sk_KRB5_AUTHENTBODY_dup(st) SKM_sk_dup(KRB5_AUTHENTBODY, st)\n# define sk_KRB5_AUTHENTBODY_pop_free(st, free_func) SKM_sk_pop_free(KRB5_AUTHENTBODY, (st), (free_func))\n# define sk_KRB5_AUTHENTBODY_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(KRB5_AUTHENTBODY, (st), (copy_func), (free_func))\n# define sk_KRB5_AUTHENTBODY_shift(st) SKM_sk_shift(KRB5_AUTHENTBODY, (st))\n# define sk_KRB5_AUTHENTBODY_pop(st) SKM_sk_pop(KRB5_AUTHENTBODY, (st))\n# define sk_KRB5_AUTHENTBODY_sort(st) SKM_sk_sort(KRB5_AUTHENTBODY, (st))\n# define sk_KRB5_AUTHENTBODY_is_sorted(st) SKM_sk_is_sorted(KRB5_AUTHENTBODY, (st))\n# define sk_KRB5_CHECKSUM_new(cmp) SKM_sk_new(KRB5_CHECKSUM, (cmp))\n# define sk_KRB5_CHECKSUM_new_null() SKM_sk_new_null(KRB5_CHECKSUM)\n# define sk_KRB5_CHECKSUM_free(st) SKM_sk_free(KRB5_CHECKSUM, (st))\n# define sk_KRB5_CHECKSUM_num(st) SKM_sk_num(KRB5_CHECKSUM, (st))\n# define sk_KRB5_CHECKSUM_value(st, i) SKM_sk_value(KRB5_CHECKSUM, (st), (i))\n# define sk_KRB5_CHECKSUM_set(st, i, val) SKM_sk_set(KRB5_CHECKSUM, (st), (i), (val))\n# define sk_KRB5_CHECKSUM_zero(st) SKM_sk_zero(KRB5_CHECKSUM, (st))\n# define sk_KRB5_CHECKSUM_push(st, val) SKM_sk_push(KRB5_CHECKSUM, (st), (val))\n# define sk_KRB5_CHECKSUM_unshift(st, val) SKM_sk_unshift(KRB5_CHECKSUM, (st), (val))\n# define sk_KRB5_CHECKSUM_find(st, val) SKM_sk_find(KRB5_CHECKSUM, (st), (val))\n# define sk_KRB5_CHECKSUM_find_ex(st, val) SKM_sk_find_ex(KRB5_CHECKSUM, (st), (val))\n# define sk_KRB5_CHECKSUM_delete(st, i) SKM_sk_delete(KRB5_CHECKSUM, (st), (i))\n# define sk_KRB5_CHECKSUM_delete_ptr(st, ptr) SKM_sk_delete_ptr(KRB5_CHECKSUM, (st), (ptr))\n# define sk_KRB5_CHECKSUM_insert(st, val, i) SKM_sk_insert(KRB5_CHECKSUM, (st), (val), (i))\n# define sk_KRB5_CHECKSUM_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(KRB5_CHECKSUM, (st), (cmp))\n# define sk_KRB5_CHECKSUM_dup(st) SKM_sk_dup(KRB5_CHECKSUM, st)\n# define sk_KRB5_CHECKSUM_pop_free(st, free_func) SKM_sk_pop_free(KRB5_CHECKSUM, (st), (free_func))\n# define sk_KRB5_CHECKSUM_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(KRB5_CHECKSUM, (st), (copy_func), (free_func))\n# define sk_KRB5_CHECKSUM_shift(st) SKM_sk_shift(KRB5_CHECKSUM, (st))\n# define sk_KRB5_CHECKSUM_pop(st) SKM_sk_pop(KRB5_CHECKSUM, (st))\n# define sk_KRB5_CHECKSUM_sort(st) SKM_sk_sort(KRB5_CHECKSUM, (st))\n# define sk_KRB5_CHECKSUM_is_sorted(st) SKM_sk_is_sorted(KRB5_CHECKSUM, (st))\n# define sk_KRB5_ENCDATA_new(cmp) SKM_sk_new(KRB5_ENCDATA, (cmp))\n# define sk_KRB5_ENCDATA_new_null() SKM_sk_new_null(KRB5_ENCDATA)\n# define sk_KRB5_ENCDATA_free(st) SKM_sk_free(KRB5_ENCDATA, (st))\n# define sk_KRB5_ENCDATA_num(st) SKM_sk_num(KRB5_ENCDATA, (st))\n# define sk_KRB5_ENCDATA_value(st, i) SKM_sk_value(KRB5_ENCDATA, (st), (i))\n# define sk_KRB5_ENCDATA_set(st, i, val) SKM_sk_set(KRB5_ENCDATA, (st), (i), (val))\n# define sk_KRB5_ENCDATA_zero(st) SKM_sk_zero(KRB5_ENCDATA, (st))\n# define sk_KRB5_ENCDATA_push(st, val) SKM_sk_push(KRB5_ENCDATA, (st), (val))\n# define sk_KRB5_ENCDATA_unshift(st, val) SKM_sk_unshift(KRB5_ENCDATA, (st), (val))\n# define sk_KRB5_ENCDATA_find(st, val) SKM_sk_find(KRB5_ENCDATA, (st), (val))\n# define sk_KRB5_ENCDATA_find_ex(st, val) SKM_sk_find_ex(KRB5_ENCDATA, (st), (val))\n# define sk_KRB5_ENCDATA_delete(st, i) SKM_sk_delete(KRB5_ENCDATA, (st), (i))\n# define sk_KRB5_ENCDATA_delete_ptr(st, ptr) SKM_sk_delete_ptr(KRB5_ENCDATA, (st), (ptr))\n# define sk_KRB5_ENCDATA_insert(st, val, i) SKM_sk_insert(KRB5_ENCDATA, (st), (val), (i))\n# define sk_KRB5_ENCDATA_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(KRB5_ENCDATA, (st), (cmp))\n# define sk_KRB5_ENCDATA_dup(st) SKM_sk_dup(KRB5_ENCDATA, st)\n# define sk_KRB5_ENCDATA_pop_free(st, free_func) SKM_sk_pop_free(KRB5_ENCDATA, (st), (free_func))\n# define sk_KRB5_ENCDATA_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(KRB5_ENCDATA, (st), (copy_func), (free_func))\n# define sk_KRB5_ENCDATA_shift(st) SKM_sk_shift(KRB5_ENCDATA, (st))\n# define sk_KRB5_ENCDATA_pop(st) SKM_sk_pop(KRB5_ENCDATA, (st))\n# define sk_KRB5_ENCDATA_sort(st) SKM_sk_sort(KRB5_ENCDATA, (st))\n# define sk_KRB5_ENCDATA_is_sorted(st) SKM_sk_is_sorted(KRB5_ENCDATA, (st))\n# define sk_KRB5_ENCKEY_new(cmp) SKM_sk_new(KRB5_ENCKEY, (cmp))\n# define sk_KRB5_ENCKEY_new_null() SKM_sk_new_null(KRB5_ENCKEY)\n# define sk_KRB5_ENCKEY_free(st) SKM_sk_free(KRB5_ENCKEY, (st))\n# define sk_KRB5_ENCKEY_num(st) SKM_sk_num(KRB5_ENCKEY, (st))\n# define sk_KRB5_ENCKEY_value(st, i) SKM_sk_value(KRB5_ENCKEY, (st), (i))\n# define sk_KRB5_ENCKEY_set(st, i, val) SKM_sk_set(KRB5_ENCKEY, (st), (i), (val))\n# define sk_KRB5_ENCKEY_zero(st) SKM_sk_zero(KRB5_ENCKEY, (st))\n# define sk_KRB5_ENCKEY_push(st, val) SKM_sk_push(KRB5_ENCKEY, (st), (val))\n# define sk_KRB5_ENCKEY_unshift(st, val) SKM_sk_unshift(KRB5_ENCKEY, (st), (val))\n# define sk_KRB5_ENCKEY_find(st, val) SKM_sk_find(KRB5_ENCKEY, (st), (val))\n# define sk_KRB5_ENCKEY_find_ex(st, val) SKM_sk_find_ex(KRB5_ENCKEY, (st), (val))\n# define sk_KRB5_ENCKEY_delete(st, i) SKM_sk_delete(KRB5_ENCKEY, (st), (i))\n# define sk_KRB5_ENCKEY_delete_ptr(st, ptr) SKM_sk_delete_ptr(KRB5_ENCKEY, (st), (ptr))\n# define sk_KRB5_ENCKEY_insert(st, val, i) SKM_sk_insert(KRB5_ENCKEY, (st), (val), (i))\n# define sk_KRB5_ENCKEY_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(KRB5_ENCKEY, (st), (cmp))\n# define sk_KRB5_ENCKEY_dup(st) SKM_sk_dup(KRB5_ENCKEY, st)\n# define sk_KRB5_ENCKEY_pop_free(st, free_func) SKM_sk_pop_free(KRB5_ENCKEY, (st), (free_func))\n# define sk_KRB5_ENCKEY_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(KRB5_ENCKEY, (st), (copy_func), (free_func))\n# define sk_KRB5_ENCKEY_shift(st) SKM_sk_shift(KRB5_ENCKEY, (st))\n# define sk_KRB5_ENCKEY_pop(st) SKM_sk_pop(KRB5_ENCKEY, (st))\n# define sk_KRB5_ENCKEY_sort(st) SKM_sk_sort(KRB5_ENCKEY, (st))\n# define sk_KRB5_ENCKEY_is_sorted(st) SKM_sk_is_sorted(KRB5_ENCKEY, (st))\n# define sk_KRB5_PRINCNAME_new(cmp) SKM_sk_new(KRB5_PRINCNAME, (cmp))\n# define sk_KRB5_PRINCNAME_new_null() SKM_sk_new_null(KRB5_PRINCNAME)\n# define sk_KRB5_PRINCNAME_free(st) SKM_sk_free(KRB5_PRINCNAME, (st))\n# define sk_KRB5_PRINCNAME_num(st) SKM_sk_num(KRB5_PRINCNAME, (st))\n# define sk_KRB5_PRINCNAME_value(st, i) SKM_sk_value(KRB5_PRINCNAME, (st), (i))\n# define sk_KRB5_PRINCNAME_set(st, i, val) SKM_sk_set(KRB5_PRINCNAME, (st), (i), (val))\n# define sk_KRB5_PRINCNAME_zero(st) SKM_sk_zero(KRB5_PRINCNAME, (st))\n# define sk_KRB5_PRINCNAME_push(st, val) SKM_sk_push(KRB5_PRINCNAME, (st), (val))\n# define sk_KRB5_PRINCNAME_unshift(st, val) SKM_sk_unshift(KRB5_PRINCNAME, (st), (val))\n# define sk_KRB5_PRINCNAME_find(st, val) SKM_sk_find(KRB5_PRINCNAME, (st), (val))\n# define sk_KRB5_PRINCNAME_find_ex(st, val) SKM_sk_find_ex(KRB5_PRINCNAME, (st), (val))\n# define sk_KRB5_PRINCNAME_delete(st, i) SKM_sk_delete(KRB5_PRINCNAME, (st), (i))\n# define sk_KRB5_PRINCNAME_delete_ptr(st, ptr) SKM_sk_delete_ptr(KRB5_PRINCNAME, (st), (ptr))\n# define sk_KRB5_PRINCNAME_insert(st, val, i) SKM_sk_insert(KRB5_PRINCNAME, (st), (val), (i))\n# define sk_KRB5_PRINCNAME_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(KRB5_PRINCNAME, (st), (cmp))\n# define sk_KRB5_PRINCNAME_dup(st) SKM_sk_dup(KRB5_PRINCNAME, st)\n# define sk_KRB5_PRINCNAME_pop_free(st, free_func) SKM_sk_pop_free(KRB5_PRINCNAME, (st), (free_func))\n# define sk_KRB5_PRINCNAME_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(KRB5_PRINCNAME, (st), (copy_func), (free_func))\n# define sk_KRB5_PRINCNAME_shift(st) SKM_sk_shift(KRB5_PRINCNAME, (st))\n# define sk_KRB5_PRINCNAME_pop(st) SKM_sk_pop(KRB5_PRINCNAME, (st))\n# define sk_KRB5_PRINCNAME_sort(st) SKM_sk_sort(KRB5_PRINCNAME, (st))\n# define sk_KRB5_PRINCNAME_is_sorted(st) SKM_sk_is_sorted(KRB5_PRINCNAME, (st))\n# define sk_KRB5_TKTBODY_new(cmp) SKM_sk_new(KRB5_TKTBODY, (cmp))\n# define sk_KRB5_TKTBODY_new_null() SKM_sk_new_null(KRB5_TKTBODY)\n# define sk_KRB5_TKTBODY_free(st) SKM_sk_free(KRB5_TKTBODY, (st))\n# define sk_KRB5_TKTBODY_num(st) SKM_sk_num(KRB5_TKTBODY, (st))\n# define sk_KRB5_TKTBODY_value(st, i) SKM_sk_value(KRB5_TKTBODY, (st), (i))\n# define sk_KRB5_TKTBODY_set(st, i, val) SKM_sk_set(KRB5_TKTBODY, (st), (i), (val))\n# define sk_KRB5_TKTBODY_zero(st) SKM_sk_zero(KRB5_TKTBODY, (st))\n# define sk_KRB5_TKTBODY_push(st, val) SKM_sk_push(KRB5_TKTBODY, (st), (val))\n# define sk_KRB5_TKTBODY_unshift(st, val) SKM_sk_unshift(KRB5_TKTBODY, (st), (val))\n# define sk_KRB5_TKTBODY_find(st, val) SKM_sk_find(KRB5_TKTBODY, (st), (val))\n# define sk_KRB5_TKTBODY_find_ex(st, val) SKM_sk_find_ex(KRB5_TKTBODY, (st), (val))\n# define sk_KRB5_TKTBODY_delete(st, i) SKM_sk_delete(KRB5_TKTBODY, (st), (i))\n# define sk_KRB5_TKTBODY_delete_ptr(st, ptr) SKM_sk_delete_ptr(KRB5_TKTBODY, (st), (ptr))\n# define sk_KRB5_TKTBODY_insert(st, val, i) SKM_sk_insert(KRB5_TKTBODY, (st), (val), (i))\n# define sk_KRB5_TKTBODY_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(KRB5_TKTBODY, (st), (cmp))\n# define sk_KRB5_TKTBODY_dup(st) SKM_sk_dup(KRB5_TKTBODY, st)\n# define sk_KRB5_TKTBODY_pop_free(st, free_func) SKM_sk_pop_free(KRB5_TKTBODY, (st), (free_func))\n# define sk_KRB5_TKTBODY_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(KRB5_TKTBODY, (st), (copy_func), (free_func))\n# define sk_KRB5_TKTBODY_shift(st) SKM_sk_shift(KRB5_TKTBODY, (st))\n# define sk_KRB5_TKTBODY_pop(st) SKM_sk_pop(KRB5_TKTBODY, (st))\n# define sk_KRB5_TKTBODY_sort(st) SKM_sk_sort(KRB5_TKTBODY, (st))\n# define sk_KRB5_TKTBODY_is_sorted(st) SKM_sk_is_sorted(KRB5_TKTBODY, (st))\n# define sk_MEM_OBJECT_DATA_new(cmp) SKM_sk_new(MEM_OBJECT_DATA, (cmp))\n# define sk_MEM_OBJECT_DATA_new_null() SKM_sk_new_null(MEM_OBJECT_DATA)\n# define sk_MEM_OBJECT_DATA_free(st) SKM_sk_free(MEM_OBJECT_DATA, (st))\n# define sk_MEM_OBJECT_DATA_num(st) SKM_sk_num(MEM_OBJECT_DATA, (st))\n# define sk_MEM_OBJECT_DATA_value(st, i) SKM_sk_value(MEM_OBJECT_DATA, (st), (i))\n# define sk_MEM_OBJECT_DATA_set(st, i, val) SKM_sk_set(MEM_OBJECT_DATA, (st), (i), (val))\n# define sk_MEM_OBJECT_DATA_zero(st) SKM_sk_zero(MEM_OBJECT_DATA, (st))\n# define sk_MEM_OBJECT_DATA_push(st, val) SKM_sk_push(MEM_OBJECT_DATA, (st), (val))\n# define sk_MEM_OBJECT_DATA_unshift(st, val) SKM_sk_unshift(MEM_OBJECT_DATA, (st), (val))\n# define sk_MEM_OBJECT_DATA_find(st, val) SKM_sk_find(MEM_OBJECT_DATA, (st), (val))\n# define sk_MEM_OBJECT_DATA_find_ex(st, val) SKM_sk_find_ex(MEM_OBJECT_DATA, (st), (val))\n# define sk_MEM_OBJECT_DATA_delete(st, i) SKM_sk_delete(MEM_OBJECT_DATA, (st), (i))\n# define sk_MEM_OBJECT_DATA_delete_ptr(st, ptr) SKM_sk_delete_ptr(MEM_OBJECT_DATA, (st), (ptr))\n# define sk_MEM_OBJECT_DATA_insert(st, val, i) SKM_sk_insert(MEM_OBJECT_DATA, (st), (val), (i))\n# define sk_MEM_OBJECT_DATA_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(MEM_OBJECT_DATA, (st), (cmp))\n# define sk_MEM_OBJECT_DATA_dup(st) SKM_sk_dup(MEM_OBJECT_DATA, st)\n# define sk_MEM_OBJECT_DATA_pop_free(st, free_func) SKM_sk_pop_free(MEM_OBJECT_DATA, (st), (free_func))\n# define sk_MEM_OBJECT_DATA_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(MEM_OBJECT_DATA, (st), (copy_func), (free_func))\n# define sk_MEM_OBJECT_DATA_shift(st) SKM_sk_shift(MEM_OBJECT_DATA, (st))\n# define sk_MEM_OBJECT_DATA_pop(st) SKM_sk_pop(MEM_OBJECT_DATA, (st))\n# define sk_MEM_OBJECT_DATA_sort(st) SKM_sk_sort(MEM_OBJECT_DATA, (st))\n# define sk_MEM_OBJECT_DATA_is_sorted(st) SKM_sk_is_sorted(MEM_OBJECT_DATA, (st))\n# define sk_MIME_HEADER_new(cmp) SKM_sk_new(MIME_HEADER, (cmp))\n# define sk_MIME_HEADER_new_null() SKM_sk_new_null(MIME_HEADER)\n# define sk_MIME_HEADER_free(st) SKM_sk_free(MIME_HEADER, (st))\n# define sk_MIME_HEADER_num(st) SKM_sk_num(MIME_HEADER, (st))\n# define sk_MIME_HEADER_value(st, i) SKM_sk_value(MIME_HEADER, (st), (i))\n# define sk_MIME_HEADER_set(st, i, val) SKM_sk_set(MIME_HEADER, (st), (i), (val))\n# define sk_MIME_HEADER_zero(st) SKM_sk_zero(MIME_HEADER, (st))\n# define sk_MIME_HEADER_push(st, val) SKM_sk_push(MIME_HEADER, (st), (val))\n# define sk_MIME_HEADER_unshift(st, val) SKM_sk_unshift(MIME_HEADER, (st), (val))\n# define sk_MIME_HEADER_find(st, val) SKM_sk_find(MIME_HEADER, (st), (val))\n# define sk_MIME_HEADER_find_ex(st, val) SKM_sk_find_ex(MIME_HEADER, (st), (val))\n# define sk_MIME_HEADER_delete(st, i) SKM_sk_delete(MIME_HEADER, (st), (i))\n# define sk_MIME_HEADER_delete_ptr(st, ptr) SKM_sk_delete_ptr(MIME_HEADER, (st), (ptr))\n# define sk_MIME_HEADER_insert(st, val, i) SKM_sk_insert(MIME_HEADER, (st), (val), (i))\n# define sk_MIME_HEADER_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(MIME_HEADER, (st), (cmp))\n# define sk_MIME_HEADER_dup(st) SKM_sk_dup(MIME_HEADER, st)\n# define sk_MIME_HEADER_pop_free(st, free_func) SKM_sk_pop_free(MIME_HEADER, (st), (free_func))\n# define sk_MIME_HEADER_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(MIME_HEADER, (st), (copy_func), (free_func))\n# define sk_MIME_HEADER_shift(st) SKM_sk_shift(MIME_HEADER, (st))\n# define sk_MIME_HEADER_pop(st) SKM_sk_pop(MIME_HEADER, (st))\n# define sk_MIME_HEADER_sort(st) SKM_sk_sort(MIME_HEADER, (st))\n# define sk_MIME_HEADER_is_sorted(st) SKM_sk_is_sorted(MIME_HEADER, (st))\n# define sk_MIME_PARAM_new(cmp) SKM_sk_new(MIME_PARAM, (cmp))\n# define sk_MIME_PARAM_new_null() SKM_sk_new_null(MIME_PARAM)\n# define sk_MIME_PARAM_free(st) SKM_sk_free(MIME_PARAM, (st))\n# define sk_MIME_PARAM_num(st) SKM_sk_num(MIME_PARAM, (st))\n# define sk_MIME_PARAM_value(st, i) SKM_sk_value(MIME_PARAM, (st), (i))\n# define sk_MIME_PARAM_set(st, i, val) SKM_sk_set(MIME_PARAM, (st), (i), (val))\n# define sk_MIME_PARAM_zero(st) SKM_sk_zero(MIME_PARAM, (st))\n# define sk_MIME_PARAM_push(st, val) SKM_sk_push(MIME_PARAM, (st), (val))\n# define sk_MIME_PARAM_unshift(st, val) SKM_sk_unshift(MIME_PARAM, (st), (val))\n# define sk_MIME_PARAM_find(st, val) SKM_sk_find(MIME_PARAM, (st), (val))\n# define sk_MIME_PARAM_find_ex(st, val) SKM_sk_find_ex(MIME_PARAM, (st), (val))\n# define sk_MIME_PARAM_delete(st, i) SKM_sk_delete(MIME_PARAM, (st), (i))\n# define sk_MIME_PARAM_delete_ptr(st, ptr) SKM_sk_delete_ptr(MIME_PARAM, (st), (ptr))\n# define sk_MIME_PARAM_insert(st, val, i) SKM_sk_insert(MIME_PARAM, (st), (val), (i))\n# define sk_MIME_PARAM_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(MIME_PARAM, (st), (cmp))\n# define sk_MIME_PARAM_dup(st) SKM_sk_dup(MIME_PARAM, st)\n# define sk_MIME_PARAM_pop_free(st, free_func) SKM_sk_pop_free(MIME_PARAM, (st), (free_func))\n# define sk_MIME_PARAM_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(MIME_PARAM, (st), (copy_func), (free_func))\n# define sk_MIME_PARAM_shift(st) SKM_sk_shift(MIME_PARAM, (st))\n# define sk_MIME_PARAM_pop(st) SKM_sk_pop(MIME_PARAM, (st))\n# define sk_MIME_PARAM_sort(st) SKM_sk_sort(MIME_PARAM, (st))\n# define sk_MIME_PARAM_is_sorted(st) SKM_sk_is_sorted(MIME_PARAM, (st))\n# define sk_NAME_FUNCS_new(cmp) SKM_sk_new(NAME_FUNCS, (cmp))\n# define sk_NAME_FUNCS_new_null() SKM_sk_new_null(NAME_FUNCS)\n# define sk_NAME_FUNCS_free(st) SKM_sk_free(NAME_FUNCS, (st))\n# define sk_NAME_FUNCS_num(st) SKM_sk_num(NAME_FUNCS, (st))\n# define sk_NAME_FUNCS_value(st, i) SKM_sk_value(NAME_FUNCS, (st), (i))\n# define sk_NAME_FUNCS_set(st, i, val) SKM_sk_set(NAME_FUNCS, (st), (i), (val))\n# define sk_NAME_FUNCS_zero(st) SKM_sk_zero(NAME_FUNCS, (st))\n# define sk_NAME_FUNCS_push(st, val) SKM_sk_push(NAME_FUNCS, (st), (val))\n# define sk_NAME_FUNCS_unshift(st, val) SKM_sk_unshift(NAME_FUNCS, (st), (val))\n# define sk_NAME_FUNCS_find(st, val) SKM_sk_find(NAME_FUNCS, (st), (val))\n# define sk_NAME_FUNCS_find_ex(st, val) SKM_sk_find_ex(NAME_FUNCS, (st), (val))\n# define sk_NAME_FUNCS_delete(st, i) SKM_sk_delete(NAME_FUNCS, (st), (i))\n# define sk_NAME_FUNCS_delete_ptr(st, ptr) SKM_sk_delete_ptr(NAME_FUNCS, (st), (ptr))\n# define sk_NAME_FUNCS_insert(st, val, i) SKM_sk_insert(NAME_FUNCS, (st), (val), (i))\n# define sk_NAME_FUNCS_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(NAME_FUNCS, (st), (cmp))\n# define sk_NAME_FUNCS_dup(st) SKM_sk_dup(NAME_FUNCS, st)\n# define sk_NAME_FUNCS_pop_free(st, free_func) SKM_sk_pop_free(NAME_FUNCS, (st), (free_func))\n# define sk_NAME_FUNCS_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(NAME_FUNCS, (st), (copy_func), (free_func))\n# define sk_NAME_FUNCS_shift(st) SKM_sk_shift(NAME_FUNCS, (st))\n# define sk_NAME_FUNCS_pop(st) SKM_sk_pop(NAME_FUNCS, (st))\n# define sk_NAME_FUNCS_sort(st) SKM_sk_sort(NAME_FUNCS, (st))\n# define sk_NAME_FUNCS_is_sorted(st) SKM_sk_is_sorted(NAME_FUNCS, (st))\n# define sk_OCSP_CERTID_new(cmp) SKM_sk_new(OCSP_CERTID, (cmp))\n# define sk_OCSP_CERTID_new_null() SKM_sk_new_null(OCSP_CERTID)\n# define sk_OCSP_CERTID_free(st) SKM_sk_free(OCSP_CERTID, (st))\n# define sk_OCSP_CERTID_num(st) SKM_sk_num(OCSP_CERTID, (st))\n# define sk_OCSP_CERTID_value(st, i) SKM_sk_value(OCSP_CERTID, (st), (i))\n# define sk_OCSP_CERTID_set(st, i, val) SKM_sk_set(OCSP_CERTID, (st), (i), (val))\n# define sk_OCSP_CERTID_zero(st) SKM_sk_zero(OCSP_CERTID, (st))\n# define sk_OCSP_CERTID_push(st, val) SKM_sk_push(OCSP_CERTID, (st), (val))\n# define sk_OCSP_CERTID_unshift(st, val) SKM_sk_unshift(OCSP_CERTID, (st), (val))\n# define sk_OCSP_CERTID_find(st, val) SKM_sk_find(OCSP_CERTID, (st), (val))\n# define sk_OCSP_CERTID_find_ex(st, val) SKM_sk_find_ex(OCSP_CERTID, (st), (val))\n# define sk_OCSP_CERTID_delete(st, i) SKM_sk_delete(OCSP_CERTID, (st), (i))\n# define sk_OCSP_CERTID_delete_ptr(st, ptr) SKM_sk_delete_ptr(OCSP_CERTID, (st), (ptr))\n# define sk_OCSP_CERTID_insert(st, val, i) SKM_sk_insert(OCSP_CERTID, (st), (val), (i))\n# define sk_OCSP_CERTID_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(OCSP_CERTID, (st), (cmp))\n# define sk_OCSP_CERTID_dup(st) SKM_sk_dup(OCSP_CERTID, st)\n# define sk_OCSP_CERTID_pop_free(st, free_func) SKM_sk_pop_free(OCSP_CERTID, (st), (free_func))\n# define sk_OCSP_CERTID_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(OCSP_CERTID, (st), (copy_func), (free_func))\n# define sk_OCSP_CERTID_shift(st) SKM_sk_shift(OCSP_CERTID, (st))\n# define sk_OCSP_CERTID_pop(st) SKM_sk_pop(OCSP_CERTID, (st))\n# define sk_OCSP_CERTID_sort(st) SKM_sk_sort(OCSP_CERTID, (st))\n# define sk_OCSP_CERTID_is_sorted(st) SKM_sk_is_sorted(OCSP_CERTID, (st))\n# define sk_OCSP_ONEREQ_new(cmp) SKM_sk_new(OCSP_ONEREQ, (cmp))\n# define sk_OCSP_ONEREQ_new_null() SKM_sk_new_null(OCSP_ONEREQ)\n# define sk_OCSP_ONEREQ_free(st) SKM_sk_free(OCSP_ONEREQ, (st))\n# define sk_OCSP_ONEREQ_num(st) SKM_sk_num(OCSP_ONEREQ, (st))\n# define sk_OCSP_ONEREQ_value(st, i) SKM_sk_value(OCSP_ONEREQ, (st), (i))\n# define sk_OCSP_ONEREQ_set(st, i, val) SKM_sk_set(OCSP_ONEREQ, (st), (i), (val))\n# define sk_OCSP_ONEREQ_zero(st) SKM_sk_zero(OCSP_ONEREQ, (st))\n# define sk_OCSP_ONEREQ_push(st, val) SKM_sk_push(OCSP_ONEREQ, (st), (val))\n# define sk_OCSP_ONEREQ_unshift(st, val) SKM_sk_unshift(OCSP_ONEREQ, (st), (val))\n# define sk_OCSP_ONEREQ_find(st, val) SKM_sk_find(OCSP_ONEREQ, (st), (val))\n# define sk_OCSP_ONEREQ_find_ex(st, val) SKM_sk_find_ex(OCSP_ONEREQ, (st), (val))\n# define sk_OCSP_ONEREQ_delete(st, i) SKM_sk_delete(OCSP_ONEREQ, (st), (i))\n# define sk_OCSP_ONEREQ_delete_ptr(st, ptr) SKM_sk_delete_ptr(OCSP_ONEREQ, (st), (ptr))\n# define sk_OCSP_ONEREQ_insert(st, val, i) SKM_sk_insert(OCSP_ONEREQ, (st), (val), (i))\n# define sk_OCSP_ONEREQ_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(OCSP_ONEREQ, (st), (cmp))\n# define sk_OCSP_ONEREQ_dup(st) SKM_sk_dup(OCSP_ONEREQ, st)\n# define sk_OCSP_ONEREQ_pop_free(st, free_func) SKM_sk_pop_free(OCSP_ONEREQ, (st), (free_func))\n# define sk_OCSP_ONEREQ_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(OCSP_ONEREQ, (st), (copy_func), (free_func))\n# define sk_OCSP_ONEREQ_shift(st) SKM_sk_shift(OCSP_ONEREQ, (st))\n# define sk_OCSP_ONEREQ_pop(st) SKM_sk_pop(OCSP_ONEREQ, (st))\n# define sk_OCSP_ONEREQ_sort(st) SKM_sk_sort(OCSP_ONEREQ, (st))\n# define sk_OCSP_ONEREQ_is_sorted(st) SKM_sk_is_sorted(OCSP_ONEREQ, (st))\n# define sk_OCSP_RESPID_new(cmp) SKM_sk_new(OCSP_RESPID, (cmp))\n# define sk_OCSP_RESPID_new_null() SKM_sk_new_null(OCSP_RESPID)\n# define sk_OCSP_RESPID_free(st) SKM_sk_free(OCSP_RESPID, (st))\n# define sk_OCSP_RESPID_num(st) SKM_sk_num(OCSP_RESPID, (st))\n# define sk_OCSP_RESPID_value(st, i) SKM_sk_value(OCSP_RESPID, (st), (i))\n# define sk_OCSP_RESPID_set(st, i, val) SKM_sk_set(OCSP_RESPID, (st), (i), (val))\n# define sk_OCSP_RESPID_zero(st) SKM_sk_zero(OCSP_RESPID, (st))\n# define sk_OCSP_RESPID_push(st, val) SKM_sk_push(OCSP_RESPID, (st), (val))\n# define sk_OCSP_RESPID_unshift(st, val) SKM_sk_unshift(OCSP_RESPID, (st), (val))\n# define sk_OCSP_RESPID_find(st, val) SKM_sk_find(OCSP_RESPID, (st), (val))\n# define sk_OCSP_RESPID_find_ex(st, val) SKM_sk_find_ex(OCSP_RESPID, (st), (val))\n# define sk_OCSP_RESPID_delete(st, i) SKM_sk_delete(OCSP_RESPID, (st), (i))\n# define sk_OCSP_RESPID_delete_ptr(st, ptr) SKM_sk_delete_ptr(OCSP_RESPID, (st), (ptr))\n# define sk_OCSP_RESPID_insert(st, val, i) SKM_sk_insert(OCSP_RESPID, (st), (val), (i))\n# define sk_OCSP_RESPID_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(OCSP_RESPID, (st), (cmp))\n# define sk_OCSP_RESPID_dup(st) SKM_sk_dup(OCSP_RESPID, st)\n# define sk_OCSP_RESPID_pop_free(st, free_func) SKM_sk_pop_free(OCSP_RESPID, (st), (free_func))\n# define sk_OCSP_RESPID_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(OCSP_RESPID, (st), (copy_func), (free_func))\n# define sk_OCSP_RESPID_shift(st) SKM_sk_shift(OCSP_RESPID, (st))\n# define sk_OCSP_RESPID_pop(st) SKM_sk_pop(OCSP_RESPID, (st))\n# define sk_OCSP_RESPID_sort(st) SKM_sk_sort(OCSP_RESPID, (st))\n# define sk_OCSP_RESPID_is_sorted(st) SKM_sk_is_sorted(OCSP_RESPID, (st))\n# define sk_OCSP_SINGLERESP_new(cmp) SKM_sk_new(OCSP_SINGLERESP, (cmp))\n# define sk_OCSP_SINGLERESP_new_null() SKM_sk_new_null(OCSP_SINGLERESP)\n# define sk_OCSP_SINGLERESP_free(st) SKM_sk_free(OCSP_SINGLERESP, (st))\n# define sk_OCSP_SINGLERESP_num(st) SKM_sk_num(OCSP_SINGLERESP, (st))\n# define sk_OCSP_SINGLERESP_value(st, i) SKM_sk_value(OCSP_SINGLERESP, (st), (i))\n# define sk_OCSP_SINGLERESP_set(st, i, val) SKM_sk_set(OCSP_SINGLERESP, (st), (i), (val))\n# define sk_OCSP_SINGLERESP_zero(st) SKM_sk_zero(OCSP_SINGLERESP, (st))\n# define sk_OCSP_SINGLERESP_push(st, val) SKM_sk_push(OCSP_SINGLERESP, (st), (val))\n# define sk_OCSP_SINGLERESP_unshift(st, val) SKM_sk_unshift(OCSP_SINGLERESP, (st), (val))\n# define sk_OCSP_SINGLERESP_find(st, val) SKM_sk_find(OCSP_SINGLERESP, (st), (val))\n# define sk_OCSP_SINGLERESP_find_ex(st, val) SKM_sk_find_ex(OCSP_SINGLERESP, (st), (val))\n# define sk_OCSP_SINGLERESP_delete(st, i) SKM_sk_delete(OCSP_SINGLERESP, (st), (i))\n# define sk_OCSP_SINGLERESP_delete_ptr(st, ptr) SKM_sk_delete_ptr(OCSP_SINGLERESP, (st), (ptr))\n# define sk_OCSP_SINGLERESP_insert(st, val, i) SKM_sk_insert(OCSP_SINGLERESP, (st), (val), (i))\n# define sk_OCSP_SINGLERESP_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(OCSP_SINGLERESP, (st), (cmp))\n# define sk_OCSP_SINGLERESP_dup(st) SKM_sk_dup(OCSP_SINGLERESP, st)\n# define sk_OCSP_SINGLERESP_pop_free(st, free_func) SKM_sk_pop_free(OCSP_SINGLERESP, (st), (free_func))\n# define sk_OCSP_SINGLERESP_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(OCSP_SINGLERESP, (st), (copy_func), (free_func))\n# define sk_OCSP_SINGLERESP_shift(st) SKM_sk_shift(OCSP_SINGLERESP, (st))\n# define sk_OCSP_SINGLERESP_pop(st) SKM_sk_pop(OCSP_SINGLERESP, (st))\n# define sk_OCSP_SINGLERESP_sort(st) SKM_sk_sort(OCSP_SINGLERESP, (st))\n# define sk_OCSP_SINGLERESP_is_sorted(st) SKM_sk_is_sorted(OCSP_SINGLERESP, (st))\n# define sk_PKCS12_SAFEBAG_new(cmp) SKM_sk_new(PKCS12_SAFEBAG, (cmp))\n# define sk_PKCS12_SAFEBAG_new_null() SKM_sk_new_null(PKCS12_SAFEBAG)\n# define sk_PKCS12_SAFEBAG_free(st) SKM_sk_free(PKCS12_SAFEBAG, (st))\n# define sk_PKCS12_SAFEBAG_num(st) SKM_sk_num(PKCS12_SAFEBAG, (st))\n# define sk_PKCS12_SAFEBAG_value(st, i) SKM_sk_value(PKCS12_SAFEBAG, (st), (i))\n# define sk_PKCS12_SAFEBAG_set(st, i, val) SKM_sk_set(PKCS12_SAFEBAG, (st), (i), (val))\n# define sk_PKCS12_SAFEBAG_zero(st) SKM_sk_zero(PKCS12_SAFEBAG, (st))\n# define sk_PKCS12_SAFEBAG_push(st, val) SKM_sk_push(PKCS12_SAFEBAG, (st), (val))\n# define sk_PKCS12_SAFEBAG_unshift(st, val) SKM_sk_unshift(PKCS12_SAFEBAG, (st), (val))\n# define sk_PKCS12_SAFEBAG_find(st, val) SKM_sk_find(PKCS12_SAFEBAG, (st), (val))\n# define sk_PKCS12_SAFEBAG_find_ex(st, val) SKM_sk_find_ex(PKCS12_SAFEBAG, (st), (val))\n# define sk_PKCS12_SAFEBAG_delete(st, i) SKM_sk_delete(PKCS12_SAFEBAG, (st), (i))\n# define sk_PKCS12_SAFEBAG_delete_ptr(st, ptr) SKM_sk_delete_ptr(PKCS12_SAFEBAG, (st), (ptr))\n# define sk_PKCS12_SAFEBAG_insert(st, val, i) SKM_sk_insert(PKCS12_SAFEBAG, (st), (val), (i))\n# define sk_PKCS12_SAFEBAG_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(PKCS12_SAFEBAG, (st), (cmp))\n# define sk_PKCS12_SAFEBAG_dup(st) SKM_sk_dup(PKCS12_SAFEBAG, st)\n# define sk_PKCS12_SAFEBAG_pop_free(st, free_func) SKM_sk_pop_free(PKCS12_SAFEBAG, (st), (free_func))\n# define sk_PKCS12_SAFEBAG_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(PKCS12_SAFEBAG, (st), (copy_func), (free_func))\n# define sk_PKCS12_SAFEBAG_shift(st) SKM_sk_shift(PKCS12_SAFEBAG, (st))\n# define sk_PKCS12_SAFEBAG_pop(st) SKM_sk_pop(PKCS12_SAFEBAG, (st))\n# define sk_PKCS12_SAFEBAG_sort(st) SKM_sk_sort(PKCS12_SAFEBAG, (st))\n# define sk_PKCS12_SAFEBAG_is_sorted(st) SKM_sk_is_sorted(PKCS12_SAFEBAG, (st))\n# define sk_PKCS7_new(cmp) SKM_sk_new(PKCS7, (cmp))\n# define sk_PKCS7_new_null() SKM_sk_new_null(PKCS7)\n# define sk_PKCS7_free(st) SKM_sk_free(PKCS7, (st))\n# define sk_PKCS7_num(st) SKM_sk_num(PKCS7, (st))\n# define sk_PKCS7_value(st, i) SKM_sk_value(PKCS7, (st), (i))\n# define sk_PKCS7_set(st, i, val) SKM_sk_set(PKCS7, (st), (i), (val))\n# define sk_PKCS7_zero(st) SKM_sk_zero(PKCS7, (st))\n# define sk_PKCS7_push(st, val) SKM_sk_push(PKCS7, (st), (val))\n# define sk_PKCS7_unshift(st, val) SKM_sk_unshift(PKCS7, (st), (val))\n# define sk_PKCS7_find(st, val) SKM_sk_find(PKCS7, (st), (val))\n# define sk_PKCS7_find_ex(st, val) SKM_sk_find_ex(PKCS7, (st), (val))\n# define sk_PKCS7_delete(st, i) SKM_sk_delete(PKCS7, (st), (i))\n# define sk_PKCS7_delete_ptr(st, ptr) SKM_sk_delete_ptr(PKCS7, (st), (ptr))\n# define sk_PKCS7_insert(st, val, i) SKM_sk_insert(PKCS7, (st), (val), (i))\n# define sk_PKCS7_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(PKCS7, (st), (cmp))\n# define sk_PKCS7_dup(st) SKM_sk_dup(PKCS7, st)\n# define sk_PKCS7_pop_free(st, free_func) SKM_sk_pop_free(PKCS7, (st), (free_func))\n# define sk_PKCS7_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(PKCS7, (st), (copy_func), (free_func))\n# define sk_PKCS7_shift(st) SKM_sk_shift(PKCS7, (st))\n# define sk_PKCS7_pop(st) SKM_sk_pop(PKCS7, (st))\n# define sk_PKCS7_sort(st) SKM_sk_sort(PKCS7, (st))\n# define sk_PKCS7_is_sorted(st) SKM_sk_is_sorted(PKCS7, (st))\n# define sk_PKCS7_RECIP_INFO_new(cmp) SKM_sk_new(PKCS7_RECIP_INFO, (cmp))\n# define sk_PKCS7_RECIP_INFO_new_null() SKM_sk_new_null(PKCS7_RECIP_INFO)\n# define sk_PKCS7_RECIP_INFO_free(st) SKM_sk_free(PKCS7_RECIP_INFO, (st))\n# define sk_PKCS7_RECIP_INFO_num(st) SKM_sk_num(PKCS7_RECIP_INFO, (st))\n# define sk_PKCS7_RECIP_INFO_value(st, i) SKM_sk_value(PKCS7_RECIP_INFO, (st), (i))\n# define sk_PKCS7_RECIP_INFO_set(st, i, val) SKM_sk_set(PKCS7_RECIP_INFO, (st), (i), (val))\n# define sk_PKCS7_RECIP_INFO_zero(st) SKM_sk_zero(PKCS7_RECIP_INFO, (st))\n# define sk_PKCS7_RECIP_INFO_push(st, val) SKM_sk_push(PKCS7_RECIP_INFO, (st), (val))\n# define sk_PKCS7_RECIP_INFO_unshift(st, val) SKM_sk_unshift(PKCS7_RECIP_INFO, (st), (val))\n# define sk_PKCS7_RECIP_INFO_find(st, val) SKM_sk_find(PKCS7_RECIP_INFO, (st), (val))\n# define sk_PKCS7_RECIP_INFO_find_ex(st, val) SKM_sk_find_ex(PKCS7_RECIP_INFO, (st), (val))\n# define sk_PKCS7_RECIP_INFO_delete(st, i) SKM_sk_delete(PKCS7_RECIP_INFO, (st), (i))\n# define sk_PKCS7_RECIP_INFO_delete_ptr(st, ptr) SKM_sk_delete_ptr(PKCS7_RECIP_INFO, (st), (ptr))\n# define sk_PKCS7_RECIP_INFO_insert(st, val, i) SKM_sk_insert(PKCS7_RECIP_INFO, (st), (val), (i))\n# define sk_PKCS7_RECIP_INFO_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(PKCS7_RECIP_INFO, (st), (cmp))\n# define sk_PKCS7_RECIP_INFO_dup(st) SKM_sk_dup(PKCS7_RECIP_INFO, st)\n# define sk_PKCS7_RECIP_INFO_pop_free(st, free_func) SKM_sk_pop_free(PKCS7_RECIP_INFO, (st), (free_func))\n# define sk_PKCS7_RECIP_INFO_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(PKCS7_RECIP_INFO, (st), (copy_func), (free_func))\n# define sk_PKCS7_RECIP_INFO_shift(st) SKM_sk_shift(PKCS7_RECIP_INFO, (st))\n# define sk_PKCS7_RECIP_INFO_pop(st) SKM_sk_pop(PKCS7_RECIP_INFO, (st))\n# define sk_PKCS7_RECIP_INFO_sort(st) SKM_sk_sort(PKCS7_RECIP_INFO, (st))\n# define sk_PKCS7_RECIP_INFO_is_sorted(st) SKM_sk_is_sorted(PKCS7_RECIP_INFO, (st))\n# define sk_PKCS7_SIGNER_INFO_new(cmp) SKM_sk_new(PKCS7_SIGNER_INFO, (cmp))\n# define sk_PKCS7_SIGNER_INFO_new_null() SKM_sk_new_null(PKCS7_SIGNER_INFO)\n# define sk_PKCS7_SIGNER_INFO_free(st) SKM_sk_free(PKCS7_SIGNER_INFO, (st))\n# define sk_PKCS7_SIGNER_INFO_num(st) SKM_sk_num(PKCS7_SIGNER_INFO, (st))\n# define sk_PKCS7_SIGNER_INFO_value(st, i) SKM_sk_value(PKCS7_SIGNER_INFO, (st), (i))\n# define sk_PKCS7_SIGNER_INFO_set(st, i, val) SKM_sk_set(PKCS7_SIGNER_INFO, (st), (i), (val))\n# define sk_PKCS7_SIGNER_INFO_zero(st) SKM_sk_zero(PKCS7_SIGNER_INFO, (st))\n# define sk_PKCS7_SIGNER_INFO_push(st, val) SKM_sk_push(PKCS7_SIGNER_INFO, (st), (val))\n# define sk_PKCS7_SIGNER_INFO_unshift(st, val) SKM_sk_unshift(PKCS7_SIGNER_INFO, (st), (val))\n# define sk_PKCS7_SIGNER_INFO_find(st, val) SKM_sk_find(PKCS7_SIGNER_INFO, (st), (val))\n# define sk_PKCS7_SIGNER_INFO_find_ex(st, val) SKM_sk_find_ex(PKCS7_SIGNER_INFO, (st), (val))\n# define sk_PKCS7_SIGNER_INFO_delete(st, i) SKM_sk_delete(PKCS7_SIGNER_INFO, (st), (i))\n# define sk_PKCS7_SIGNER_INFO_delete_ptr(st, ptr) SKM_sk_delete_ptr(PKCS7_SIGNER_INFO, (st), (ptr))\n# define sk_PKCS7_SIGNER_INFO_insert(st, val, i) SKM_sk_insert(PKCS7_SIGNER_INFO, (st), (val), (i))\n# define sk_PKCS7_SIGNER_INFO_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(PKCS7_SIGNER_INFO, (st), (cmp))\n# define sk_PKCS7_SIGNER_INFO_dup(st) SKM_sk_dup(PKCS7_SIGNER_INFO, st)\n# define sk_PKCS7_SIGNER_INFO_pop_free(st, free_func) SKM_sk_pop_free(PKCS7_SIGNER_INFO, (st), (free_func))\n# define sk_PKCS7_SIGNER_INFO_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(PKCS7_SIGNER_INFO, (st), (copy_func), (free_func))\n# define sk_PKCS7_SIGNER_INFO_shift(st) SKM_sk_shift(PKCS7_SIGNER_INFO, (st))\n# define sk_PKCS7_SIGNER_INFO_pop(st) SKM_sk_pop(PKCS7_SIGNER_INFO, (st))\n# define sk_PKCS7_SIGNER_INFO_sort(st) SKM_sk_sort(PKCS7_SIGNER_INFO, (st))\n# define sk_PKCS7_SIGNER_INFO_is_sorted(st) SKM_sk_is_sorted(PKCS7_SIGNER_INFO, (st))\n# define sk_POLICYINFO_new(cmp) SKM_sk_new(POLICYINFO, (cmp))\n# define sk_POLICYINFO_new_null() SKM_sk_new_null(POLICYINFO)\n# define sk_POLICYINFO_free(st) SKM_sk_free(POLICYINFO, (st))\n# define sk_POLICYINFO_num(st) SKM_sk_num(POLICYINFO, (st))\n# define sk_POLICYINFO_value(st, i) SKM_sk_value(POLICYINFO, (st), (i))\n# define sk_POLICYINFO_set(st, i, val) SKM_sk_set(POLICYINFO, (st), (i), (val))\n# define sk_POLICYINFO_zero(st) SKM_sk_zero(POLICYINFO, (st))\n# define sk_POLICYINFO_push(st, val) SKM_sk_push(POLICYINFO, (st), (val))\n# define sk_POLICYINFO_unshift(st, val) SKM_sk_unshift(POLICYINFO, (st), (val))\n# define sk_POLICYINFO_find(st, val) SKM_sk_find(POLICYINFO, (st), (val))\n# define sk_POLICYINFO_find_ex(st, val) SKM_sk_find_ex(POLICYINFO, (st), (val))\n# define sk_POLICYINFO_delete(st, i) SKM_sk_delete(POLICYINFO, (st), (i))\n# define sk_POLICYINFO_delete_ptr(st, ptr) SKM_sk_delete_ptr(POLICYINFO, (st), (ptr))\n# define sk_POLICYINFO_insert(st, val, i) SKM_sk_insert(POLICYINFO, (st), (val), (i))\n# define sk_POLICYINFO_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(POLICYINFO, (st), (cmp))\n# define sk_POLICYINFO_dup(st) SKM_sk_dup(POLICYINFO, st)\n# define sk_POLICYINFO_pop_free(st, free_func) SKM_sk_pop_free(POLICYINFO, (st), (free_func))\n# define sk_POLICYINFO_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(POLICYINFO, (st), (copy_func), (free_func))\n# define sk_POLICYINFO_shift(st) SKM_sk_shift(POLICYINFO, (st))\n# define sk_POLICYINFO_pop(st) SKM_sk_pop(POLICYINFO, (st))\n# define sk_POLICYINFO_sort(st) SKM_sk_sort(POLICYINFO, (st))\n# define sk_POLICYINFO_is_sorted(st) SKM_sk_is_sorted(POLICYINFO, (st))\n# define sk_POLICYQUALINFO_new(cmp) SKM_sk_new(POLICYQUALINFO, (cmp))\n# define sk_POLICYQUALINFO_new_null() SKM_sk_new_null(POLICYQUALINFO)\n# define sk_POLICYQUALINFO_free(st) SKM_sk_free(POLICYQUALINFO, (st))\n# define sk_POLICYQUALINFO_num(st) SKM_sk_num(POLICYQUALINFO, (st))\n# define sk_POLICYQUALINFO_value(st, i) SKM_sk_value(POLICYQUALINFO, (st), (i))\n# define sk_POLICYQUALINFO_set(st, i, val) SKM_sk_set(POLICYQUALINFO, (st), (i), (val))\n# define sk_POLICYQUALINFO_zero(st) SKM_sk_zero(POLICYQUALINFO, (st))\n# define sk_POLICYQUALINFO_push(st, val) SKM_sk_push(POLICYQUALINFO, (st), (val))\n# define sk_POLICYQUALINFO_unshift(st, val) SKM_sk_unshift(POLICYQUALINFO, (st), (val))\n# define sk_POLICYQUALINFO_find(st, val) SKM_sk_find(POLICYQUALINFO, (st), (val))\n# define sk_POLICYQUALINFO_find_ex(st, val) SKM_sk_find_ex(POLICYQUALINFO, (st), (val))\n# define sk_POLICYQUALINFO_delete(st, i) SKM_sk_delete(POLICYQUALINFO, (st), (i))\n# define sk_POLICYQUALINFO_delete_ptr(st, ptr) SKM_sk_delete_ptr(POLICYQUALINFO, (st), (ptr))\n# define sk_POLICYQUALINFO_insert(st, val, i) SKM_sk_insert(POLICYQUALINFO, (st), (val), (i))\n# define sk_POLICYQUALINFO_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(POLICYQUALINFO, (st), (cmp))\n# define sk_POLICYQUALINFO_dup(st) SKM_sk_dup(POLICYQUALINFO, st)\n# define sk_POLICYQUALINFO_pop_free(st, free_func) SKM_sk_pop_free(POLICYQUALINFO, (st), (free_func))\n# define sk_POLICYQUALINFO_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(POLICYQUALINFO, (st), (copy_func), (free_func))\n# define sk_POLICYQUALINFO_shift(st) SKM_sk_shift(POLICYQUALINFO, (st))\n# define sk_POLICYQUALINFO_pop(st) SKM_sk_pop(POLICYQUALINFO, (st))\n# define sk_POLICYQUALINFO_sort(st) SKM_sk_sort(POLICYQUALINFO, (st))\n# define sk_POLICYQUALINFO_is_sorted(st) SKM_sk_is_sorted(POLICYQUALINFO, (st))\n# define sk_POLICY_MAPPING_new(cmp) SKM_sk_new(POLICY_MAPPING, (cmp))\n# define sk_POLICY_MAPPING_new_null() SKM_sk_new_null(POLICY_MAPPING)\n# define sk_POLICY_MAPPING_free(st) SKM_sk_free(POLICY_MAPPING, (st))\n# define sk_POLICY_MAPPING_num(st) SKM_sk_num(POLICY_MAPPING, (st))\n# define sk_POLICY_MAPPING_value(st, i) SKM_sk_value(POLICY_MAPPING, (st), (i))\n# define sk_POLICY_MAPPING_set(st, i, val) SKM_sk_set(POLICY_MAPPING, (st), (i), (val))\n# define sk_POLICY_MAPPING_zero(st) SKM_sk_zero(POLICY_MAPPING, (st))\n# define sk_POLICY_MAPPING_push(st, val) SKM_sk_push(POLICY_MAPPING, (st), (val))\n# define sk_POLICY_MAPPING_unshift(st, val) SKM_sk_unshift(POLICY_MAPPING, (st), (val))\n# define sk_POLICY_MAPPING_find(st, val) SKM_sk_find(POLICY_MAPPING, (st), (val))\n# define sk_POLICY_MAPPING_find_ex(st, val) SKM_sk_find_ex(POLICY_MAPPING, (st), (val))\n# define sk_POLICY_MAPPING_delete(st, i) SKM_sk_delete(POLICY_MAPPING, (st), (i))\n# define sk_POLICY_MAPPING_delete_ptr(st, ptr) SKM_sk_delete_ptr(POLICY_MAPPING, (st), (ptr))\n# define sk_POLICY_MAPPING_insert(st, val, i) SKM_sk_insert(POLICY_MAPPING, (st), (val), (i))\n# define sk_POLICY_MAPPING_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(POLICY_MAPPING, (st), (cmp))\n# define sk_POLICY_MAPPING_dup(st) SKM_sk_dup(POLICY_MAPPING, st)\n# define sk_POLICY_MAPPING_pop_free(st, free_func) SKM_sk_pop_free(POLICY_MAPPING, (st), (free_func))\n# define sk_POLICY_MAPPING_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(POLICY_MAPPING, (st), (copy_func), (free_func))\n# define sk_POLICY_MAPPING_shift(st) SKM_sk_shift(POLICY_MAPPING, (st))\n# define sk_POLICY_MAPPING_pop(st) SKM_sk_pop(POLICY_MAPPING, (st))\n# define sk_POLICY_MAPPING_sort(st) SKM_sk_sort(POLICY_MAPPING, (st))\n# define sk_POLICY_MAPPING_is_sorted(st) SKM_sk_is_sorted(POLICY_MAPPING, (st))\n# define sk_SCT_new(cmp) SKM_sk_new(SCT, (cmp))\n# define sk_SCT_new_null() SKM_sk_new_null(SCT)\n# define sk_SCT_free(st) SKM_sk_free(SCT, (st))\n# define sk_SCT_num(st) SKM_sk_num(SCT, (st))\n# define sk_SCT_value(st, i) SKM_sk_value(SCT, (st), (i))\n# define sk_SCT_set(st, i, val) SKM_sk_set(SCT, (st), (i), (val))\n# define sk_SCT_zero(st) SKM_sk_zero(SCT, (st))\n# define sk_SCT_push(st, val) SKM_sk_push(SCT, (st), (val))\n# define sk_SCT_unshift(st, val) SKM_sk_unshift(SCT, (st), (val))\n# define sk_SCT_find(st, val) SKM_sk_find(SCT, (st), (val))\n# define sk_SCT_find_ex(st, val) SKM_sk_find_ex(SCT, (st), (val))\n# define sk_SCT_delete(st, i) SKM_sk_delete(SCT, (st), (i))\n# define sk_SCT_delete_ptr(st, ptr) SKM_sk_delete_ptr(SCT, (st), (ptr))\n# define sk_SCT_insert(st, val, i) SKM_sk_insert(SCT, (st), (val), (i))\n# define sk_SCT_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(SCT, (st), (cmp))\n# define sk_SCT_dup(st) SKM_sk_dup(SCT, st)\n# define sk_SCT_pop_free(st, free_func) SKM_sk_pop_free(SCT, (st), (free_func))\n# define sk_SCT_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(SCT, (st), (copy_func), (free_func))\n# define sk_SCT_shift(st) SKM_sk_shift(SCT, (st))\n# define sk_SCT_pop(st) SKM_sk_pop(SCT, (st))\n# define sk_SCT_sort(st) SKM_sk_sort(SCT, (st))\n# define sk_SCT_is_sorted(st) SKM_sk_is_sorted(SCT, (st))\n# define sk_SRP_gN_new(cmp) SKM_sk_new(SRP_gN, (cmp))\n# define sk_SRP_gN_new_null() SKM_sk_new_null(SRP_gN)\n# define sk_SRP_gN_free(st) SKM_sk_free(SRP_gN, (st))\n# define sk_SRP_gN_num(st) SKM_sk_num(SRP_gN, (st))\n# define sk_SRP_gN_value(st, i) SKM_sk_value(SRP_gN, (st), (i))\n# define sk_SRP_gN_set(st, i, val) SKM_sk_set(SRP_gN, (st), (i), (val))\n# define sk_SRP_gN_zero(st) SKM_sk_zero(SRP_gN, (st))\n# define sk_SRP_gN_push(st, val) SKM_sk_push(SRP_gN, (st), (val))\n# define sk_SRP_gN_unshift(st, val) SKM_sk_unshift(SRP_gN, (st), (val))\n# define sk_SRP_gN_find(st, val) SKM_sk_find(SRP_gN, (st), (val))\n# define sk_SRP_gN_find_ex(st, val) SKM_sk_find_ex(SRP_gN, (st), (val))\n# define sk_SRP_gN_delete(st, i) SKM_sk_delete(SRP_gN, (st), (i))\n# define sk_SRP_gN_delete_ptr(st, ptr) SKM_sk_delete_ptr(SRP_gN, (st), (ptr))\n# define sk_SRP_gN_insert(st, val, i) SKM_sk_insert(SRP_gN, (st), (val), (i))\n# define sk_SRP_gN_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(SRP_gN, (st), (cmp))\n# define sk_SRP_gN_dup(st) SKM_sk_dup(SRP_gN, st)\n# define sk_SRP_gN_pop_free(st, free_func) SKM_sk_pop_free(SRP_gN, (st), (free_func))\n# define sk_SRP_gN_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(SRP_gN, (st), (copy_func), (free_func))\n# define sk_SRP_gN_shift(st) SKM_sk_shift(SRP_gN, (st))\n# define sk_SRP_gN_pop(st) SKM_sk_pop(SRP_gN, (st))\n# define sk_SRP_gN_sort(st) SKM_sk_sort(SRP_gN, (st))\n# define sk_SRP_gN_is_sorted(st) SKM_sk_is_sorted(SRP_gN, (st))\n# define sk_SRP_gN_cache_new(cmp) SKM_sk_new(SRP_gN_cache, (cmp))\n# define sk_SRP_gN_cache_new_null() SKM_sk_new_null(SRP_gN_cache)\n# define sk_SRP_gN_cache_free(st) SKM_sk_free(SRP_gN_cache, (st))\n# define sk_SRP_gN_cache_num(st) SKM_sk_num(SRP_gN_cache, (st))\n# define sk_SRP_gN_cache_value(st, i) SKM_sk_value(SRP_gN_cache, (st), (i))\n# define sk_SRP_gN_cache_set(st, i, val) SKM_sk_set(SRP_gN_cache, (st), (i), (val))\n# define sk_SRP_gN_cache_zero(st) SKM_sk_zero(SRP_gN_cache, (st))\n# define sk_SRP_gN_cache_push(st, val) SKM_sk_push(SRP_gN_cache, (st), (val))\n# define sk_SRP_gN_cache_unshift(st, val) SKM_sk_unshift(SRP_gN_cache, (st), (val))\n# define sk_SRP_gN_cache_find(st, val) SKM_sk_find(SRP_gN_cache, (st), (val))\n# define sk_SRP_gN_cache_find_ex(st, val) SKM_sk_find_ex(SRP_gN_cache, (st), (val))\n# define sk_SRP_gN_cache_delete(st, i) SKM_sk_delete(SRP_gN_cache, (st), (i))\n# define sk_SRP_gN_cache_delete_ptr(st, ptr) SKM_sk_delete_ptr(SRP_gN_cache, (st), (ptr))\n# define sk_SRP_gN_cache_insert(st, val, i) SKM_sk_insert(SRP_gN_cache, (st), (val), (i))\n# define sk_SRP_gN_cache_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(SRP_gN_cache, (st), (cmp))\n# define sk_SRP_gN_cache_dup(st) SKM_sk_dup(SRP_gN_cache, st)\n# define sk_SRP_gN_cache_pop_free(st, free_func) SKM_sk_pop_free(SRP_gN_cache, (st), (free_func))\n# define sk_SRP_gN_cache_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(SRP_gN_cache, (st), (copy_func), (free_func))\n# define sk_SRP_gN_cache_shift(st) SKM_sk_shift(SRP_gN_cache, (st))\n# define sk_SRP_gN_cache_pop(st) SKM_sk_pop(SRP_gN_cache, (st))\n# define sk_SRP_gN_cache_sort(st) SKM_sk_sort(SRP_gN_cache, (st))\n# define sk_SRP_gN_cache_is_sorted(st) SKM_sk_is_sorted(SRP_gN_cache, (st))\n# define sk_SRP_user_pwd_new(cmp) SKM_sk_new(SRP_user_pwd, (cmp))\n# define sk_SRP_user_pwd_new_null() SKM_sk_new_null(SRP_user_pwd)\n# define sk_SRP_user_pwd_free(st) SKM_sk_free(SRP_user_pwd, (st))\n# define sk_SRP_user_pwd_num(st) SKM_sk_num(SRP_user_pwd, (st))\n# define sk_SRP_user_pwd_value(st, i) SKM_sk_value(SRP_user_pwd, (st), (i))\n# define sk_SRP_user_pwd_set(st, i, val) SKM_sk_set(SRP_user_pwd, (st), (i), (val))\n# define sk_SRP_user_pwd_zero(st) SKM_sk_zero(SRP_user_pwd, (st))\n# define sk_SRP_user_pwd_push(st, val) SKM_sk_push(SRP_user_pwd, (st), (val))\n# define sk_SRP_user_pwd_unshift(st, val) SKM_sk_unshift(SRP_user_pwd, (st), (val))\n# define sk_SRP_user_pwd_find(st, val) SKM_sk_find(SRP_user_pwd, (st), (val))\n# define sk_SRP_user_pwd_find_ex(st, val) SKM_sk_find_ex(SRP_user_pwd, (st), (val))\n# define sk_SRP_user_pwd_delete(st, i) SKM_sk_delete(SRP_user_pwd, (st), (i))\n# define sk_SRP_user_pwd_delete_ptr(st, ptr) SKM_sk_delete_ptr(SRP_user_pwd, (st), (ptr))\n# define sk_SRP_user_pwd_insert(st, val, i) SKM_sk_insert(SRP_user_pwd, (st), (val), (i))\n# define sk_SRP_user_pwd_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(SRP_user_pwd, (st), (cmp))\n# define sk_SRP_user_pwd_dup(st) SKM_sk_dup(SRP_user_pwd, st)\n# define sk_SRP_user_pwd_pop_free(st, free_func) SKM_sk_pop_free(SRP_user_pwd, (st), (free_func))\n# define sk_SRP_user_pwd_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(SRP_user_pwd, (st), (copy_func), (free_func))\n# define sk_SRP_user_pwd_shift(st) SKM_sk_shift(SRP_user_pwd, (st))\n# define sk_SRP_user_pwd_pop(st) SKM_sk_pop(SRP_user_pwd, (st))\n# define sk_SRP_user_pwd_sort(st) SKM_sk_sort(SRP_user_pwd, (st))\n# define sk_SRP_user_pwd_is_sorted(st) SKM_sk_is_sorted(SRP_user_pwd, (st))\n# define sk_SRTP_PROTECTION_PROFILE_new(cmp) SKM_sk_new(SRTP_PROTECTION_PROFILE, (cmp))\n# define sk_SRTP_PROTECTION_PROFILE_new_null() SKM_sk_new_null(SRTP_PROTECTION_PROFILE)\n# define sk_SRTP_PROTECTION_PROFILE_free(st) SKM_sk_free(SRTP_PROTECTION_PROFILE, (st))\n# define sk_SRTP_PROTECTION_PROFILE_num(st) SKM_sk_num(SRTP_PROTECTION_PROFILE, (st))\n# define sk_SRTP_PROTECTION_PROFILE_value(st, i) SKM_sk_value(SRTP_PROTECTION_PROFILE, (st), (i))\n# define sk_SRTP_PROTECTION_PROFILE_set(st, i, val) SKM_sk_set(SRTP_PROTECTION_PROFILE, (st), (i), (val))\n# define sk_SRTP_PROTECTION_PROFILE_zero(st) SKM_sk_zero(SRTP_PROTECTION_PROFILE, (st))\n# define sk_SRTP_PROTECTION_PROFILE_push(st, val) SKM_sk_push(SRTP_PROTECTION_PROFILE, (st), (val))\n# define sk_SRTP_PROTECTION_PROFILE_unshift(st, val) SKM_sk_unshift(SRTP_PROTECTION_PROFILE, (st), (val))\n# define sk_SRTP_PROTECTION_PROFILE_find(st, val) SKM_sk_find(SRTP_PROTECTION_PROFILE, (st), (val))\n# define sk_SRTP_PROTECTION_PROFILE_find_ex(st, val) SKM_sk_find_ex(SRTP_PROTECTION_PROFILE, (st), (val))\n# define sk_SRTP_PROTECTION_PROFILE_delete(st, i) SKM_sk_delete(SRTP_PROTECTION_PROFILE, (st), (i))\n# define sk_SRTP_PROTECTION_PROFILE_delete_ptr(st, ptr) SKM_sk_delete_ptr(SRTP_PROTECTION_PROFILE, (st), (ptr))\n# define sk_SRTP_PROTECTION_PROFILE_insert(st, val, i) SKM_sk_insert(SRTP_PROTECTION_PROFILE, (st), (val), (i))\n# define sk_SRTP_PROTECTION_PROFILE_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(SRTP_PROTECTION_PROFILE, (st), (cmp))\n# define sk_SRTP_PROTECTION_PROFILE_dup(st) SKM_sk_dup(SRTP_PROTECTION_PROFILE, st)\n# define sk_SRTP_PROTECTION_PROFILE_pop_free(st, free_func) SKM_sk_pop_free(SRTP_PROTECTION_PROFILE, (st), (free_func))\n# define sk_SRTP_PROTECTION_PROFILE_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(SRTP_PROTECTION_PROFILE, (st), (copy_func), (free_func))\n# define sk_SRTP_PROTECTION_PROFILE_shift(st) SKM_sk_shift(SRTP_PROTECTION_PROFILE, (st))\n# define sk_SRTP_PROTECTION_PROFILE_pop(st) SKM_sk_pop(SRTP_PROTECTION_PROFILE, (st))\n# define sk_SRTP_PROTECTION_PROFILE_sort(st) SKM_sk_sort(SRTP_PROTECTION_PROFILE, (st))\n# define sk_SRTP_PROTECTION_PROFILE_is_sorted(st) SKM_sk_is_sorted(SRTP_PROTECTION_PROFILE, (st))\n# define sk_SSL_CIPHER_new(cmp) SKM_sk_new(SSL_CIPHER, (cmp))\n# define sk_SSL_CIPHER_new_null() SKM_sk_new_null(SSL_CIPHER)\n# define sk_SSL_CIPHER_free(st) SKM_sk_free(SSL_CIPHER, (st))\n# define sk_SSL_CIPHER_num(st) SKM_sk_num(SSL_CIPHER, (st))\n# define sk_SSL_CIPHER_value(st, i) SKM_sk_value(SSL_CIPHER, (st), (i))\n# define sk_SSL_CIPHER_set(st, i, val) SKM_sk_set(SSL_CIPHER, (st), (i), (val))\n# define sk_SSL_CIPHER_zero(st) SKM_sk_zero(SSL_CIPHER, (st))\n# define sk_SSL_CIPHER_push(st, val) SKM_sk_push(SSL_CIPHER, (st), (val))\n# define sk_SSL_CIPHER_unshift(st, val) SKM_sk_unshift(SSL_CIPHER, (st), (val))\n# define sk_SSL_CIPHER_find(st, val) SKM_sk_find(SSL_CIPHER, (st), (val))\n# define sk_SSL_CIPHER_find_ex(st, val) SKM_sk_find_ex(SSL_CIPHER, (st), (val))\n# define sk_SSL_CIPHER_delete(st, i) SKM_sk_delete(SSL_CIPHER, (st), (i))\n# define sk_SSL_CIPHER_delete_ptr(st, ptr) SKM_sk_delete_ptr(SSL_CIPHER, (st), (ptr))\n# define sk_SSL_CIPHER_insert(st, val, i) SKM_sk_insert(SSL_CIPHER, (st), (val), (i))\n# define sk_SSL_CIPHER_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(SSL_CIPHER, (st), (cmp))\n# define sk_SSL_CIPHER_dup(st) SKM_sk_dup(SSL_CIPHER, st)\n# define sk_SSL_CIPHER_pop_free(st, free_func) SKM_sk_pop_free(SSL_CIPHER, (st), (free_func))\n# define sk_SSL_CIPHER_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(SSL_CIPHER, (st), (copy_func), (free_func))\n# define sk_SSL_CIPHER_shift(st) SKM_sk_shift(SSL_CIPHER, (st))\n# define sk_SSL_CIPHER_pop(st) SKM_sk_pop(SSL_CIPHER, (st))\n# define sk_SSL_CIPHER_sort(st) SKM_sk_sort(SSL_CIPHER, (st))\n# define sk_SSL_CIPHER_is_sorted(st) SKM_sk_is_sorted(SSL_CIPHER, (st))\n# define sk_SSL_COMP_new(cmp) SKM_sk_new(SSL_COMP, (cmp))\n# define sk_SSL_COMP_new_null() SKM_sk_new_null(SSL_COMP)\n# define sk_SSL_COMP_free(st) SKM_sk_free(SSL_COMP, (st))\n# define sk_SSL_COMP_num(st) SKM_sk_num(SSL_COMP, (st))\n# define sk_SSL_COMP_value(st, i) SKM_sk_value(SSL_COMP, (st), (i))\n# define sk_SSL_COMP_set(st, i, val) SKM_sk_set(SSL_COMP, (st), (i), (val))\n# define sk_SSL_COMP_zero(st) SKM_sk_zero(SSL_COMP, (st))\n# define sk_SSL_COMP_push(st, val) SKM_sk_push(SSL_COMP, (st), (val))\n# define sk_SSL_COMP_unshift(st, val) SKM_sk_unshift(SSL_COMP, (st), (val))\n# define sk_SSL_COMP_find(st, val) SKM_sk_find(SSL_COMP, (st), (val))\n# define sk_SSL_COMP_find_ex(st, val) SKM_sk_find_ex(SSL_COMP, (st), (val))\n# define sk_SSL_COMP_delete(st, i) SKM_sk_delete(SSL_COMP, (st), (i))\n# define sk_SSL_COMP_delete_ptr(st, ptr) SKM_sk_delete_ptr(SSL_COMP, (st), (ptr))\n# define sk_SSL_COMP_insert(st, val, i) SKM_sk_insert(SSL_COMP, (st), (val), (i))\n# define sk_SSL_COMP_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(SSL_COMP, (st), (cmp))\n# define sk_SSL_COMP_dup(st) SKM_sk_dup(SSL_COMP, st)\n# define sk_SSL_COMP_pop_free(st, free_func) SKM_sk_pop_free(SSL_COMP, (st), (free_func))\n# define sk_SSL_COMP_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(SSL_COMP, (st), (copy_func), (free_func))\n# define sk_SSL_COMP_shift(st) SKM_sk_shift(SSL_COMP, (st))\n# define sk_SSL_COMP_pop(st) SKM_sk_pop(SSL_COMP, (st))\n# define sk_SSL_COMP_sort(st) SKM_sk_sort(SSL_COMP, (st))\n# define sk_SSL_COMP_is_sorted(st) SKM_sk_is_sorted(SSL_COMP, (st))\n# define sk_STACK_OF_X509_NAME_ENTRY_new(cmp) SKM_sk_new(STACK_OF_X509_NAME_ENTRY, (cmp))\n# define sk_STACK_OF_X509_NAME_ENTRY_new_null() SKM_sk_new_null(STACK_OF_X509_NAME_ENTRY)\n# define sk_STACK_OF_X509_NAME_ENTRY_free(st) SKM_sk_free(STACK_OF_X509_NAME_ENTRY, (st))\n# define sk_STACK_OF_X509_NAME_ENTRY_num(st) SKM_sk_num(STACK_OF_X509_NAME_ENTRY, (st))\n# define sk_STACK_OF_X509_NAME_ENTRY_value(st, i) SKM_sk_value(STACK_OF_X509_NAME_ENTRY, (st), (i))\n# define sk_STACK_OF_X509_NAME_ENTRY_set(st, i, val) SKM_sk_set(STACK_OF_X509_NAME_ENTRY, (st), (i), (val))\n# define sk_STACK_OF_X509_NAME_ENTRY_zero(st) SKM_sk_zero(STACK_OF_X509_NAME_ENTRY, (st))\n# define sk_STACK_OF_X509_NAME_ENTRY_push(st, val) SKM_sk_push(STACK_OF_X509_NAME_ENTRY, (st), (val))\n# define sk_STACK_OF_X509_NAME_ENTRY_unshift(st, val) SKM_sk_unshift(STACK_OF_X509_NAME_ENTRY, (st), (val))\n# define sk_STACK_OF_X509_NAME_ENTRY_find(st, val) SKM_sk_find(STACK_OF_X509_NAME_ENTRY, (st), (val))\n# define sk_STACK_OF_X509_NAME_ENTRY_find_ex(st, val) SKM_sk_find_ex(STACK_OF_X509_NAME_ENTRY, (st), (val))\n# define sk_STACK_OF_X509_NAME_ENTRY_delete(st, i) SKM_sk_delete(STACK_OF_X509_NAME_ENTRY, (st), (i))\n# define sk_STACK_OF_X509_NAME_ENTRY_delete_ptr(st, ptr) SKM_sk_delete_ptr(STACK_OF_X509_NAME_ENTRY, (st), (ptr))\n# define sk_STACK_OF_X509_NAME_ENTRY_insert(st, val, i) SKM_sk_insert(STACK_OF_X509_NAME_ENTRY, (st), (val), (i))\n# define sk_STACK_OF_X509_NAME_ENTRY_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(STACK_OF_X509_NAME_ENTRY, (st), (cmp))\n# define sk_STACK_OF_X509_NAME_ENTRY_dup(st) SKM_sk_dup(STACK_OF_X509_NAME_ENTRY, st)\n# define sk_STACK_OF_X509_NAME_ENTRY_pop_free(st, free_func) SKM_sk_pop_free(STACK_OF_X509_NAME_ENTRY, (st), (free_func))\n# define sk_STACK_OF_X509_NAME_ENTRY_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(STACK_OF_X509_NAME_ENTRY, (st), (copy_func), (free_func))\n# define sk_STACK_OF_X509_NAME_ENTRY_shift(st) SKM_sk_shift(STACK_OF_X509_NAME_ENTRY, (st))\n# define sk_STACK_OF_X509_NAME_ENTRY_pop(st) SKM_sk_pop(STACK_OF_X509_NAME_ENTRY, (st))\n# define sk_STACK_OF_X509_NAME_ENTRY_sort(st) SKM_sk_sort(STACK_OF_X509_NAME_ENTRY, (st))\n# define sk_STACK_OF_X509_NAME_ENTRY_is_sorted(st) SKM_sk_is_sorted(STACK_OF_X509_NAME_ENTRY, (st))\n# define sk_STORE_ATTR_INFO_new(cmp) SKM_sk_new(STORE_ATTR_INFO, (cmp))\n# define sk_STORE_ATTR_INFO_new_null() SKM_sk_new_null(STORE_ATTR_INFO)\n# define sk_STORE_ATTR_INFO_free(st) SKM_sk_free(STORE_ATTR_INFO, (st))\n# define sk_STORE_ATTR_INFO_num(st) SKM_sk_num(STORE_ATTR_INFO, (st))\n# define sk_STORE_ATTR_INFO_value(st, i) SKM_sk_value(STORE_ATTR_INFO, (st), (i))\n# define sk_STORE_ATTR_INFO_set(st, i, val) SKM_sk_set(STORE_ATTR_INFO, (st), (i), (val))\n# define sk_STORE_ATTR_INFO_zero(st) SKM_sk_zero(STORE_ATTR_INFO, (st))\n# define sk_STORE_ATTR_INFO_push(st, val) SKM_sk_push(STORE_ATTR_INFO, (st), (val))\n# define sk_STORE_ATTR_INFO_unshift(st, val) SKM_sk_unshift(STORE_ATTR_INFO, (st), (val))\n# define sk_STORE_ATTR_INFO_find(st, val) SKM_sk_find(STORE_ATTR_INFO, (st), (val))\n# define sk_STORE_ATTR_INFO_find_ex(st, val) SKM_sk_find_ex(STORE_ATTR_INFO, (st), (val))\n# define sk_STORE_ATTR_INFO_delete(st, i) SKM_sk_delete(STORE_ATTR_INFO, (st), (i))\n# define sk_STORE_ATTR_INFO_delete_ptr(st, ptr) SKM_sk_delete_ptr(STORE_ATTR_INFO, (st), (ptr))\n# define sk_STORE_ATTR_INFO_insert(st, val, i) SKM_sk_insert(STORE_ATTR_INFO, (st), (val), (i))\n# define sk_STORE_ATTR_INFO_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(STORE_ATTR_INFO, (st), (cmp))\n# define sk_STORE_ATTR_INFO_dup(st) SKM_sk_dup(STORE_ATTR_INFO, st)\n# define sk_STORE_ATTR_INFO_pop_free(st, free_func) SKM_sk_pop_free(STORE_ATTR_INFO, (st), (free_func))\n# define sk_STORE_ATTR_INFO_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(STORE_ATTR_INFO, (st), (copy_func), (free_func))\n# define sk_STORE_ATTR_INFO_shift(st) SKM_sk_shift(STORE_ATTR_INFO, (st))\n# define sk_STORE_ATTR_INFO_pop(st) SKM_sk_pop(STORE_ATTR_INFO, (st))\n# define sk_STORE_ATTR_INFO_sort(st) SKM_sk_sort(STORE_ATTR_INFO, (st))\n# define sk_STORE_ATTR_INFO_is_sorted(st) SKM_sk_is_sorted(STORE_ATTR_INFO, (st))\n# define sk_STORE_OBJECT_new(cmp) SKM_sk_new(STORE_OBJECT, (cmp))\n# define sk_STORE_OBJECT_new_null() SKM_sk_new_null(STORE_OBJECT)\n# define sk_STORE_OBJECT_free(st) SKM_sk_free(STORE_OBJECT, (st))\n# define sk_STORE_OBJECT_num(st) SKM_sk_num(STORE_OBJECT, (st))\n# define sk_STORE_OBJECT_value(st, i) SKM_sk_value(STORE_OBJECT, (st), (i))\n# define sk_STORE_OBJECT_set(st, i, val) SKM_sk_set(STORE_OBJECT, (st), (i), (val))\n# define sk_STORE_OBJECT_zero(st) SKM_sk_zero(STORE_OBJECT, (st))\n# define sk_STORE_OBJECT_push(st, val) SKM_sk_push(STORE_OBJECT, (st), (val))\n# define sk_STORE_OBJECT_unshift(st, val) SKM_sk_unshift(STORE_OBJECT, (st), (val))\n# define sk_STORE_OBJECT_find(st, val) SKM_sk_find(STORE_OBJECT, (st), (val))\n# define sk_STORE_OBJECT_find_ex(st, val) SKM_sk_find_ex(STORE_OBJECT, (st), (val))\n# define sk_STORE_OBJECT_delete(st, i) SKM_sk_delete(STORE_OBJECT, (st), (i))\n# define sk_STORE_OBJECT_delete_ptr(st, ptr) SKM_sk_delete_ptr(STORE_OBJECT, (st), (ptr))\n# define sk_STORE_OBJECT_insert(st, val, i) SKM_sk_insert(STORE_OBJECT, (st), (val), (i))\n# define sk_STORE_OBJECT_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(STORE_OBJECT, (st), (cmp))\n# define sk_STORE_OBJECT_dup(st) SKM_sk_dup(STORE_OBJECT, st)\n# define sk_STORE_OBJECT_pop_free(st, free_func) SKM_sk_pop_free(STORE_OBJECT, (st), (free_func))\n# define sk_STORE_OBJECT_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(STORE_OBJECT, (st), (copy_func), (free_func))\n# define sk_STORE_OBJECT_shift(st) SKM_sk_shift(STORE_OBJECT, (st))\n# define sk_STORE_OBJECT_pop(st) SKM_sk_pop(STORE_OBJECT, (st))\n# define sk_STORE_OBJECT_sort(st) SKM_sk_sort(STORE_OBJECT, (st))\n# define sk_STORE_OBJECT_is_sorted(st) SKM_sk_is_sorted(STORE_OBJECT, (st))\n# define sk_SXNETID_new(cmp) SKM_sk_new(SXNETID, (cmp))\n# define sk_SXNETID_new_null() SKM_sk_new_null(SXNETID)\n# define sk_SXNETID_free(st) SKM_sk_free(SXNETID, (st))\n# define sk_SXNETID_num(st) SKM_sk_num(SXNETID, (st))\n# define sk_SXNETID_value(st, i) SKM_sk_value(SXNETID, (st), (i))\n# define sk_SXNETID_set(st, i, val) SKM_sk_set(SXNETID, (st), (i), (val))\n# define sk_SXNETID_zero(st) SKM_sk_zero(SXNETID, (st))\n# define sk_SXNETID_push(st, val) SKM_sk_push(SXNETID, (st), (val))\n# define sk_SXNETID_unshift(st, val) SKM_sk_unshift(SXNETID, (st), (val))\n# define sk_SXNETID_find(st, val) SKM_sk_find(SXNETID, (st), (val))\n# define sk_SXNETID_find_ex(st, val) SKM_sk_find_ex(SXNETID, (st), (val))\n# define sk_SXNETID_delete(st, i) SKM_sk_delete(SXNETID, (st), (i))\n# define sk_SXNETID_delete_ptr(st, ptr) SKM_sk_delete_ptr(SXNETID, (st), (ptr))\n# define sk_SXNETID_insert(st, val, i) SKM_sk_insert(SXNETID, (st), (val), (i))\n# define sk_SXNETID_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(SXNETID, (st), (cmp))\n# define sk_SXNETID_dup(st) SKM_sk_dup(SXNETID, st)\n# define sk_SXNETID_pop_free(st, free_func) SKM_sk_pop_free(SXNETID, (st), (free_func))\n# define sk_SXNETID_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(SXNETID, (st), (copy_func), (free_func))\n# define sk_SXNETID_shift(st) SKM_sk_shift(SXNETID, (st))\n# define sk_SXNETID_pop(st) SKM_sk_pop(SXNETID, (st))\n# define sk_SXNETID_sort(st) SKM_sk_sort(SXNETID, (st))\n# define sk_SXNETID_is_sorted(st) SKM_sk_is_sorted(SXNETID, (st))\n# define sk_UI_STRING_new(cmp) SKM_sk_new(UI_STRING, (cmp))\n# define sk_UI_STRING_new_null() SKM_sk_new_null(UI_STRING)\n# define sk_UI_STRING_free(st) SKM_sk_free(UI_STRING, (st))\n# define sk_UI_STRING_num(st) SKM_sk_num(UI_STRING, (st))\n# define sk_UI_STRING_value(st, i) SKM_sk_value(UI_STRING, (st), (i))\n# define sk_UI_STRING_set(st, i, val) SKM_sk_set(UI_STRING, (st), (i), (val))\n# define sk_UI_STRING_zero(st) SKM_sk_zero(UI_STRING, (st))\n# define sk_UI_STRING_push(st, val) SKM_sk_push(UI_STRING, (st), (val))\n# define sk_UI_STRING_unshift(st, val) SKM_sk_unshift(UI_STRING, (st), (val))\n# define sk_UI_STRING_find(st, val) SKM_sk_find(UI_STRING, (st), (val))\n# define sk_UI_STRING_find_ex(st, val) SKM_sk_find_ex(UI_STRING, (st), (val))\n# define sk_UI_STRING_delete(st, i) SKM_sk_delete(UI_STRING, (st), (i))\n# define sk_UI_STRING_delete_ptr(st, ptr) SKM_sk_delete_ptr(UI_STRING, (st), (ptr))\n# define sk_UI_STRING_insert(st, val, i) SKM_sk_insert(UI_STRING, (st), (val), (i))\n# define sk_UI_STRING_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(UI_STRING, (st), (cmp))\n# define sk_UI_STRING_dup(st) SKM_sk_dup(UI_STRING, st)\n# define sk_UI_STRING_pop_free(st, free_func) SKM_sk_pop_free(UI_STRING, (st), (free_func))\n# define sk_UI_STRING_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(UI_STRING, (st), (copy_func), (free_func))\n# define sk_UI_STRING_shift(st) SKM_sk_shift(UI_STRING, (st))\n# define sk_UI_STRING_pop(st) SKM_sk_pop(UI_STRING, (st))\n# define sk_UI_STRING_sort(st) SKM_sk_sort(UI_STRING, (st))\n# define sk_UI_STRING_is_sorted(st) SKM_sk_is_sorted(UI_STRING, (st))\n# define sk_X509_new(cmp) SKM_sk_new(X509, (cmp))\n# define sk_X509_new_null() SKM_sk_new_null(X509)\n# define sk_X509_free(st) SKM_sk_free(X509, (st))\n# define sk_X509_num(st) SKM_sk_num(X509, (st))\n# define sk_X509_value(st, i) SKM_sk_value(X509, (st), (i))\n# define sk_X509_set(st, i, val) SKM_sk_set(X509, (st), (i), (val))\n# define sk_X509_zero(st) SKM_sk_zero(X509, (st))\n# define sk_X509_push(st, val) SKM_sk_push(X509, (st), (val))\n# define sk_X509_unshift(st, val) SKM_sk_unshift(X509, (st), (val))\n# define sk_X509_find(st, val) SKM_sk_find(X509, (st), (val))\n# define sk_X509_find_ex(st, val) SKM_sk_find_ex(X509, (st), (val))\n# define sk_X509_delete(st, i) SKM_sk_delete(X509, (st), (i))\n# define sk_X509_delete_ptr(st, ptr) SKM_sk_delete_ptr(X509, (st), (ptr))\n# define sk_X509_insert(st, val, i) SKM_sk_insert(X509, (st), (val), (i))\n# define sk_X509_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(X509, (st), (cmp))\n# define sk_X509_dup(st) SKM_sk_dup(X509, st)\n# define sk_X509_pop_free(st, free_func) SKM_sk_pop_free(X509, (st), (free_func))\n# define sk_X509_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(X509, (st), (copy_func), (free_func))\n# define sk_X509_shift(st) SKM_sk_shift(X509, (st))\n# define sk_X509_pop(st) SKM_sk_pop(X509, (st))\n# define sk_X509_sort(st) SKM_sk_sort(X509, (st))\n# define sk_X509_is_sorted(st) SKM_sk_is_sorted(X509, (st))\n# define sk_X509V3_EXT_METHOD_new(cmp) SKM_sk_new(X509V3_EXT_METHOD, (cmp))\n# define sk_X509V3_EXT_METHOD_new_null() SKM_sk_new_null(X509V3_EXT_METHOD)\n# define sk_X509V3_EXT_METHOD_free(st) SKM_sk_free(X509V3_EXT_METHOD, (st))\n# define sk_X509V3_EXT_METHOD_num(st) SKM_sk_num(X509V3_EXT_METHOD, (st))\n# define sk_X509V3_EXT_METHOD_value(st, i) SKM_sk_value(X509V3_EXT_METHOD, (st), (i))\n# define sk_X509V3_EXT_METHOD_set(st, i, val) SKM_sk_set(X509V3_EXT_METHOD, (st), (i), (val))\n# define sk_X509V3_EXT_METHOD_zero(st) SKM_sk_zero(X509V3_EXT_METHOD, (st))\n# define sk_X509V3_EXT_METHOD_push(st, val) SKM_sk_push(X509V3_EXT_METHOD, (st), (val))\n# define sk_X509V3_EXT_METHOD_unshift(st, val) SKM_sk_unshift(X509V3_EXT_METHOD, (st), (val))\n# define sk_X509V3_EXT_METHOD_find(st, val) SKM_sk_find(X509V3_EXT_METHOD, (st), (val))\n# define sk_X509V3_EXT_METHOD_find_ex(st, val) SKM_sk_find_ex(X509V3_EXT_METHOD, (st), (val))\n# define sk_X509V3_EXT_METHOD_delete(st, i) SKM_sk_delete(X509V3_EXT_METHOD, (st), (i))\n# define sk_X509V3_EXT_METHOD_delete_ptr(st, ptr) SKM_sk_delete_ptr(X509V3_EXT_METHOD, (st), (ptr))\n# define sk_X509V3_EXT_METHOD_insert(st, val, i) SKM_sk_insert(X509V3_EXT_METHOD, (st), (val), (i))\n# define sk_X509V3_EXT_METHOD_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(X509V3_EXT_METHOD, (st), (cmp))\n# define sk_X509V3_EXT_METHOD_dup(st) SKM_sk_dup(X509V3_EXT_METHOD, st)\n# define sk_X509V3_EXT_METHOD_pop_free(st, free_func) SKM_sk_pop_free(X509V3_EXT_METHOD, (st), (free_func))\n# define sk_X509V3_EXT_METHOD_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(X509V3_EXT_METHOD, (st), (copy_func), (free_func))\n# define sk_X509V3_EXT_METHOD_shift(st) SKM_sk_shift(X509V3_EXT_METHOD, (st))\n# define sk_X509V3_EXT_METHOD_pop(st) SKM_sk_pop(X509V3_EXT_METHOD, (st))\n# define sk_X509V3_EXT_METHOD_sort(st) SKM_sk_sort(X509V3_EXT_METHOD, (st))\n# define sk_X509V3_EXT_METHOD_is_sorted(st) SKM_sk_is_sorted(X509V3_EXT_METHOD, (st))\n# define sk_X509_ALGOR_new(cmp) SKM_sk_new(X509_ALGOR, (cmp))\n# define sk_X509_ALGOR_new_null() SKM_sk_new_null(X509_ALGOR)\n# define sk_X509_ALGOR_free(st) SKM_sk_free(X509_ALGOR, (st))\n# define sk_X509_ALGOR_num(st) SKM_sk_num(X509_ALGOR, (st))\n# define sk_X509_ALGOR_value(st, i) SKM_sk_value(X509_ALGOR, (st), (i))\n# define sk_X509_ALGOR_set(st, i, val) SKM_sk_set(X509_ALGOR, (st), (i), (val))\n# define sk_X509_ALGOR_zero(st) SKM_sk_zero(X509_ALGOR, (st))\n# define sk_X509_ALGOR_push(st, val) SKM_sk_push(X509_ALGOR, (st), (val))\n# define sk_X509_ALGOR_unshift(st, val) SKM_sk_unshift(X509_ALGOR, (st), (val))\n# define sk_X509_ALGOR_find(st, val) SKM_sk_find(X509_ALGOR, (st), (val))\n# define sk_X509_ALGOR_find_ex(st, val) SKM_sk_find_ex(X509_ALGOR, (st), (val))\n# define sk_X509_ALGOR_delete(st, i) SKM_sk_delete(X509_ALGOR, (st), (i))\n# define sk_X509_ALGOR_delete_ptr(st, ptr) SKM_sk_delete_ptr(X509_ALGOR, (st), (ptr))\n# define sk_X509_ALGOR_insert(st, val, i) SKM_sk_insert(X509_ALGOR, (st), (val), (i))\n# define sk_X509_ALGOR_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(X509_ALGOR, (st), (cmp))\n# define sk_X509_ALGOR_dup(st) SKM_sk_dup(X509_ALGOR, st)\n# define sk_X509_ALGOR_pop_free(st, free_func) SKM_sk_pop_free(X509_ALGOR, (st), (free_func))\n# define sk_X509_ALGOR_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(X509_ALGOR, (st), (copy_func), (free_func))\n# define sk_X509_ALGOR_shift(st) SKM_sk_shift(X509_ALGOR, (st))\n# define sk_X509_ALGOR_pop(st) SKM_sk_pop(X509_ALGOR, (st))\n# define sk_X509_ALGOR_sort(st) SKM_sk_sort(X509_ALGOR, (st))\n# define sk_X509_ALGOR_is_sorted(st) SKM_sk_is_sorted(X509_ALGOR, (st))\n# define sk_X509_ATTRIBUTE_new(cmp) SKM_sk_new(X509_ATTRIBUTE, (cmp))\n# define sk_X509_ATTRIBUTE_new_null() SKM_sk_new_null(X509_ATTRIBUTE)\n# define sk_X509_ATTRIBUTE_free(st) SKM_sk_free(X509_ATTRIBUTE, (st))\n# define sk_X509_ATTRIBUTE_num(st) SKM_sk_num(X509_ATTRIBUTE, (st))\n# define sk_X509_ATTRIBUTE_value(st, i) SKM_sk_value(X509_ATTRIBUTE, (st), (i))\n# define sk_X509_ATTRIBUTE_set(st, i, val) SKM_sk_set(X509_ATTRIBUTE, (st), (i), (val))\n# define sk_X509_ATTRIBUTE_zero(st) SKM_sk_zero(X509_ATTRIBUTE, (st))\n# define sk_X509_ATTRIBUTE_push(st, val) SKM_sk_push(X509_ATTRIBUTE, (st), (val))\n# define sk_X509_ATTRIBUTE_unshift(st, val) SKM_sk_unshift(X509_ATTRIBUTE, (st), (val))\n# define sk_X509_ATTRIBUTE_find(st, val) SKM_sk_find(X509_ATTRIBUTE, (st), (val))\n# define sk_X509_ATTRIBUTE_find_ex(st, val) SKM_sk_find_ex(X509_ATTRIBUTE, (st), (val))\n# define sk_X509_ATTRIBUTE_delete(st, i) SKM_sk_delete(X509_ATTRIBUTE, (st), (i))\n# define sk_X509_ATTRIBUTE_delete_ptr(st, ptr) SKM_sk_delete_ptr(X509_ATTRIBUTE, (st), (ptr))\n# define sk_X509_ATTRIBUTE_insert(st, val, i) SKM_sk_insert(X509_ATTRIBUTE, (st), (val), (i))\n# define sk_X509_ATTRIBUTE_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(X509_ATTRIBUTE, (st), (cmp))\n# define sk_X509_ATTRIBUTE_dup(st) SKM_sk_dup(X509_ATTRIBUTE, st)\n# define sk_X509_ATTRIBUTE_pop_free(st, free_func) SKM_sk_pop_free(X509_ATTRIBUTE, (st), (free_func))\n# define sk_X509_ATTRIBUTE_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(X509_ATTRIBUTE, (st), (copy_func), (free_func))\n# define sk_X509_ATTRIBUTE_shift(st) SKM_sk_shift(X509_ATTRIBUTE, (st))\n# define sk_X509_ATTRIBUTE_pop(st) SKM_sk_pop(X509_ATTRIBUTE, (st))\n# define sk_X509_ATTRIBUTE_sort(st) SKM_sk_sort(X509_ATTRIBUTE, (st))\n# define sk_X509_ATTRIBUTE_is_sorted(st) SKM_sk_is_sorted(X509_ATTRIBUTE, (st))\n# define sk_X509_CRL_new(cmp) SKM_sk_new(X509_CRL, (cmp))\n# define sk_X509_CRL_new_null() SKM_sk_new_null(X509_CRL)\n# define sk_X509_CRL_free(st) SKM_sk_free(X509_CRL, (st))\n# define sk_X509_CRL_num(st) SKM_sk_num(X509_CRL, (st))\n# define sk_X509_CRL_value(st, i) SKM_sk_value(X509_CRL, (st), (i))\n# define sk_X509_CRL_set(st, i, val) SKM_sk_set(X509_CRL, (st), (i), (val))\n# define sk_X509_CRL_zero(st) SKM_sk_zero(X509_CRL, (st))\n# define sk_X509_CRL_push(st, val) SKM_sk_push(X509_CRL, (st), (val))\n# define sk_X509_CRL_unshift(st, val) SKM_sk_unshift(X509_CRL, (st), (val))\n# define sk_X509_CRL_find(st, val) SKM_sk_find(X509_CRL, (st), (val))\n# define sk_X509_CRL_find_ex(st, val) SKM_sk_find_ex(X509_CRL, (st), (val))\n# define sk_X509_CRL_delete(st, i) SKM_sk_delete(X509_CRL, (st), (i))\n# define sk_X509_CRL_delete_ptr(st, ptr) SKM_sk_delete_ptr(X509_CRL, (st), (ptr))\n# define sk_X509_CRL_insert(st, val, i) SKM_sk_insert(X509_CRL, (st), (val), (i))\n# define sk_X509_CRL_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(X509_CRL, (st), (cmp))\n# define sk_X509_CRL_dup(st) SKM_sk_dup(X509_CRL, st)\n# define sk_X509_CRL_pop_free(st, free_func) SKM_sk_pop_free(X509_CRL, (st), (free_func))\n# define sk_X509_CRL_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(X509_CRL, (st), (copy_func), (free_func))\n# define sk_X509_CRL_shift(st) SKM_sk_shift(X509_CRL, (st))\n# define sk_X509_CRL_pop(st) SKM_sk_pop(X509_CRL, (st))\n# define sk_X509_CRL_sort(st) SKM_sk_sort(X509_CRL, (st))\n# define sk_X509_CRL_is_sorted(st) SKM_sk_is_sorted(X509_CRL, (st))\n# define sk_X509_EXTENSION_new(cmp) SKM_sk_new(X509_EXTENSION, (cmp))\n# define sk_X509_EXTENSION_new_null() SKM_sk_new_null(X509_EXTENSION)\n# define sk_X509_EXTENSION_free(st) SKM_sk_free(X509_EXTENSION, (st))\n# define sk_X509_EXTENSION_num(st) SKM_sk_num(X509_EXTENSION, (st))\n# define sk_X509_EXTENSION_value(st, i) SKM_sk_value(X509_EXTENSION, (st), (i))\n# define sk_X509_EXTENSION_set(st, i, val) SKM_sk_set(X509_EXTENSION, (st), (i), (val))\n# define sk_X509_EXTENSION_zero(st) SKM_sk_zero(X509_EXTENSION, (st))\n# define sk_X509_EXTENSION_push(st, val) SKM_sk_push(X509_EXTENSION, (st), (val))\n# define sk_X509_EXTENSION_unshift(st, val) SKM_sk_unshift(X509_EXTENSION, (st), (val))\n# define sk_X509_EXTENSION_find(st, val) SKM_sk_find(X509_EXTENSION, (st), (val))\n# define sk_X509_EXTENSION_find_ex(st, val) SKM_sk_find_ex(X509_EXTENSION, (st), (val))\n# define sk_X509_EXTENSION_delete(st, i) SKM_sk_delete(X509_EXTENSION, (st), (i))\n# define sk_X509_EXTENSION_delete_ptr(st, ptr) SKM_sk_delete_ptr(X509_EXTENSION, (st), (ptr))\n# define sk_X509_EXTENSION_insert(st, val, i) SKM_sk_insert(X509_EXTENSION, (st), (val), (i))\n# define sk_X509_EXTENSION_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(X509_EXTENSION, (st), (cmp))\n# define sk_X509_EXTENSION_dup(st) SKM_sk_dup(X509_EXTENSION, st)\n# define sk_X509_EXTENSION_pop_free(st, free_func) SKM_sk_pop_free(X509_EXTENSION, (st), (free_func))\n# define sk_X509_EXTENSION_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(X509_EXTENSION, (st), (copy_func), (free_func))\n# define sk_X509_EXTENSION_shift(st) SKM_sk_shift(X509_EXTENSION, (st))\n# define sk_X509_EXTENSION_pop(st) SKM_sk_pop(X509_EXTENSION, (st))\n# define sk_X509_EXTENSION_sort(st) SKM_sk_sort(X509_EXTENSION, (st))\n# define sk_X509_EXTENSION_is_sorted(st) SKM_sk_is_sorted(X509_EXTENSION, (st))\n# define sk_X509_INFO_new(cmp) SKM_sk_new(X509_INFO, (cmp))\n# define sk_X509_INFO_new_null() SKM_sk_new_null(X509_INFO)\n# define sk_X509_INFO_free(st) SKM_sk_free(X509_INFO, (st))\n# define sk_X509_INFO_num(st) SKM_sk_num(X509_INFO, (st))\n# define sk_X509_INFO_value(st, i) SKM_sk_value(X509_INFO, (st), (i))\n# define sk_X509_INFO_set(st, i, val) SKM_sk_set(X509_INFO, (st), (i), (val))\n# define sk_X509_INFO_zero(st) SKM_sk_zero(X509_INFO, (st))\n# define sk_X509_INFO_push(st, val) SKM_sk_push(X509_INFO, (st), (val))\n# define sk_X509_INFO_unshift(st, val) SKM_sk_unshift(X509_INFO, (st), (val))\n# define sk_X509_INFO_find(st, val) SKM_sk_find(X509_INFO, (st), (val))\n# define sk_X509_INFO_find_ex(st, val) SKM_sk_find_ex(X509_INFO, (st), (val))\n# define sk_X509_INFO_delete(st, i) SKM_sk_delete(X509_INFO, (st), (i))\n# define sk_X509_INFO_delete_ptr(st, ptr) SKM_sk_delete_ptr(X509_INFO, (st), (ptr))\n# define sk_X509_INFO_insert(st, val, i) SKM_sk_insert(X509_INFO, (st), (val), (i))\n# define sk_X509_INFO_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(X509_INFO, (st), (cmp))\n# define sk_X509_INFO_dup(st) SKM_sk_dup(X509_INFO, st)\n# define sk_X509_INFO_pop_free(st, free_func) SKM_sk_pop_free(X509_INFO, (st), (free_func))\n# define sk_X509_INFO_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(X509_INFO, (st), (copy_func), (free_func))\n# define sk_X509_INFO_shift(st) SKM_sk_shift(X509_INFO, (st))\n# define sk_X509_INFO_pop(st) SKM_sk_pop(X509_INFO, (st))\n# define sk_X509_INFO_sort(st) SKM_sk_sort(X509_INFO, (st))\n# define sk_X509_INFO_is_sorted(st) SKM_sk_is_sorted(X509_INFO, (st))\n# define sk_X509_LOOKUP_new(cmp) SKM_sk_new(X509_LOOKUP, (cmp))\n# define sk_X509_LOOKUP_new_null() SKM_sk_new_null(X509_LOOKUP)\n# define sk_X509_LOOKUP_free(st) SKM_sk_free(X509_LOOKUP, (st))\n# define sk_X509_LOOKUP_num(st) SKM_sk_num(X509_LOOKUP, (st))\n# define sk_X509_LOOKUP_value(st, i) SKM_sk_value(X509_LOOKUP, (st), (i))\n# define sk_X509_LOOKUP_set(st, i, val) SKM_sk_set(X509_LOOKUP, (st), (i), (val))\n# define sk_X509_LOOKUP_zero(st) SKM_sk_zero(X509_LOOKUP, (st))\n# define sk_X509_LOOKUP_push(st, val) SKM_sk_push(X509_LOOKUP, (st), (val))\n# define sk_X509_LOOKUP_unshift(st, val) SKM_sk_unshift(X509_LOOKUP, (st), (val))\n# define sk_X509_LOOKUP_find(st, val) SKM_sk_find(X509_LOOKUP, (st), (val))\n# define sk_X509_LOOKUP_find_ex(st, val) SKM_sk_find_ex(X509_LOOKUP, (st), (val))\n# define sk_X509_LOOKUP_delete(st, i) SKM_sk_delete(X509_LOOKUP, (st), (i))\n# define sk_X509_LOOKUP_delete_ptr(st, ptr) SKM_sk_delete_ptr(X509_LOOKUP, (st), (ptr))\n# define sk_X509_LOOKUP_insert(st, val, i) SKM_sk_insert(X509_LOOKUP, (st), (val), (i))\n# define sk_X509_LOOKUP_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(X509_LOOKUP, (st), (cmp))\n# define sk_X509_LOOKUP_dup(st) SKM_sk_dup(X509_LOOKUP, st)\n# define sk_X509_LOOKUP_pop_free(st, free_func) SKM_sk_pop_free(X509_LOOKUP, (st), (free_func))\n# define sk_X509_LOOKUP_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(X509_LOOKUP, (st), (copy_func), (free_func))\n# define sk_X509_LOOKUP_shift(st) SKM_sk_shift(X509_LOOKUP, (st))\n# define sk_X509_LOOKUP_pop(st) SKM_sk_pop(X509_LOOKUP, (st))\n# define sk_X509_LOOKUP_sort(st) SKM_sk_sort(X509_LOOKUP, (st))\n# define sk_X509_LOOKUP_is_sorted(st) SKM_sk_is_sorted(X509_LOOKUP, (st))\n# define sk_X509_NAME_new(cmp) SKM_sk_new(X509_NAME, (cmp))\n# define sk_X509_NAME_new_null() SKM_sk_new_null(X509_NAME)\n# define sk_X509_NAME_free(st) SKM_sk_free(X509_NAME, (st))\n# define sk_X509_NAME_num(st) SKM_sk_num(X509_NAME, (st))\n# define sk_X509_NAME_value(st, i) SKM_sk_value(X509_NAME, (st), (i))\n# define sk_X509_NAME_set(st, i, val) SKM_sk_set(X509_NAME, (st), (i), (val))\n# define sk_X509_NAME_zero(st) SKM_sk_zero(X509_NAME, (st))\n# define sk_X509_NAME_push(st, val) SKM_sk_push(X509_NAME, (st), (val))\n# define sk_X509_NAME_unshift(st, val) SKM_sk_unshift(X509_NAME, (st), (val))\n# define sk_X509_NAME_find(st, val) SKM_sk_find(X509_NAME, (st), (val))\n# define sk_X509_NAME_find_ex(st, val) SKM_sk_find_ex(X509_NAME, (st), (val))\n# define sk_X509_NAME_delete(st, i) SKM_sk_delete(X509_NAME, (st), (i))\n# define sk_X509_NAME_delete_ptr(st, ptr) SKM_sk_delete_ptr(X509_NAME, (st), (ptr))\n# define sk_X509_NAME_insert(st, val, i) SKM_sk_insert(X509_NAME, (st), (val), (i))\n# define sk_X509_NAME_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(X509_NAME, (st), (cmp))\n# define sk_X509_NAME_dup(st) SKM_sk_dup(X509_NAME, st)\n# define sk_X509_NAME_pop_free(st, free_func) SKM_sk_pop_free(X509_NAME, (st), (free_func))\n# define sk_X509_NAME_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(X509_NAME, (st), (copy_func), (free_func))\n# define sk_X509_NAME_shift(st) SKM_sk_shift(X509_NAME, (st))\n# define sk_X509_NAME_pop(st) SKM_sk_pop(X509_NAME, (st))\n# define sk_X509_NAME_sort(st) SKM_sk_sort(X509_NAME, (st))\n# define sk_X509_NAME_is_sorted(st) SKM_sk_is_sorted(X509_NAME, (st))\n# define sk_X509_NAME_ENTRY_new(cmp) SKM_sk_new(X509_NAME_ENTRY, (cmp))\n# define sk_X509_NAME_ENTRY_new_null() SKM_sk_new_null(X509_NAME_ENTRY)\n# define sk_X509_NAME_ENTRY_free(st) SKM_sk_free(X509_NAME_ENTRY, (st))\n# define sk_X509_NAME_ENTRY_num(st) SKM_sk_num(X509_NAME_ENTRY, (st))\n# define sk_X509_NAME_ENTRY_value(st, i) SKM_sk_value(X509_NAME_ENTRY, (st), (i))\n# define sk_X509_NAME_ENTRY_set(st, i, val) SKM_sk_set(X509_NAME_ENTRY, (st), (i), (val))\n# define sk_X509_NAME_ENTRY_zero(st) SKM_sk_zero(X509_NAME_ENTRY, (st))\n# define sk_X509_NAME_ENTRY_push(st, val) SKM_sk_push(X509_NAME_ENTRY, (st), (val))\n# define sk_X509_NAME_ENTRY_unshift(st, val) SKM_sk_unshift(X509_NAME_ENTRY, (st), (val))\n# define sk_X509_NAME_ENTRY_find(st, val) SKM_sk_find(X509_NAME_ENTRY, (st), (val))\n# define sk_X509_NAME_ENTRY_find_ex(st, val) SKM_sk_find_ex(X509_NAME_ENTRY, (st), (val))\n# define sk_X509_NAME_ENTRY_delete(st, i) SKM_sk_delete(X509_NAME_ENTRY, (st), (i))\n# define sk_X509_NAME_ENTRY_delete_ptr(st, ptr) SKM_sk_delete_ptr(X509_NAME_ENTRY, (st), (ptr))\n# define sk_X509_NAME_ENTRY_insert(st, val, i) SKM_sk_insert(X509_NAME_ENTRY, (st), (val), (i))\n# define sk_X509_NAME_ENTRY_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(X509_NAME_ENTRY, (st), (cmp))\n# define sk_X509_NAME_ENTRY_dup(st) SKM_sk_dup(X509_NAME_ENTRY, st)\n# define sk_X509_NAME_ENTRY_pop_free(st, free_func) SKM_sk_pop_free(X509_NAME_ENTRY, (st), (free_func))\n# define sk_X509_NAME_ENTRY_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(X509_NAME_ENTRY, (st), (copy_func), (free_func))\n# define sk_X509_NAME_ENTRY_shift(st) SKM_sk_shift(X509_NAME_ENTRY, (st))\n# define sk_X509_NAME_ENTRY_pop(st) SKM_sk_pop(X509_NAME_ENTRY, (st))\n# define sk_X509_NAME_ENTRY_sort(st) SKM_sk_sort(X509_NAME_ENTRY, (st))\n# define sk_X509_NAME_ENTRY_is_sorted(st) SKM_sk_is_sorted(X509_NAME_ENTRY, (st))\n# define sk_X509_OBJECT_new(cmp) SKM_sk_new(X509_OBJECT, (cmp))\n# define sk_X509_OBJECT_new_null() SKM_sk_new_null(X509_OBJECT)\n# define sk_X509_OBJECT_free(st) SKM_sk_free(X509_OBJECT, (st))\n# define sk_X509_OBJECT_num(st) SKM_sk_num(X509_OBJECT, (st))\n# define sk_X509_OBJECT_value(st, i) SKM_sk_value(X509_OBJECT, (st), (i))\n# define sk_X509_OBJECT_set(st, i, val) SKM_sk_set(X509_OBJECT, (st), (i), (val))\n# define sk_X509_OBJECT_zero(st) SKM_sk_zero(X509_OBJECT, (st))\n# define sk_X509_OBJECT_push(st, val) SKM_sk_push(X509_OBJECT, (st), (val))\n# define sk_X509_OBJECT_unshift(st, val) SKM_sk_unshift(X509_OBJECT, (st), (val))\n# define sk_X509_OBJECT_find(st, val) SKM_sk_find(X509_OBJECT, (st), (val))\n# define sk_X509_OBJECT_find_ex(st, val) SKM_sk_find_ex(X509_OBJECT, (st), (val))\n# define sk_X509_OBJECT_delete(st, i) SKM_sk_delete(X509_OBJECT, (st), (i))\n# define sk_X509_OBJECT_delete_ptr(st, ptr) SKM_sk_delete_ptr(X509_OBJECT, (st), (ptr))\n# define sk_X509_OBJECT_insert(st, val, i) SKM_sk_insert(X509_OBJECT, (st), (val), (i))\n# define sk_X509_OBJECT_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(X509_OBJECT, (st), (cmp))\n# define sk_X509_OBJECT_dup(st) SKM_sk_dup(X509_OBJECT, st)\n# define sk_X509_OBJECT_pop_free(st, free_func) SKM_sk_pop_free(X509_OBJECT, (st), (free_func))\n# define sk_X509_OBJECT_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(X509_OBJECT, (st), (copy_func), (free_func))\n# define sk_X509_OBJECT_shift(st) SKM_sk_shift(X509_OBJECT, (st))\n# define sk_X509_OBJECT_pop(st) SKM_sk_pop(X509_OBJECT, (st))\n# define sk_X509_OBJECT_sort(st) SKM_sk_sort(X509_OBJECT, (st))\n# define sk_X509_OBJECT_is_sorted(st) SKM_sk_is_sorted(X509_OBJECT, (st))\n# define sk_X509_POLICY_DATA_new(cmp) SKM_sk_new(X509_POLICY_DATA, (cmp))\n# define sk_X509_POLICY_DATA_new_null() SKM_sk_new_null(X509_POLICY_DATA)\n# define sk_X509_POLICY_DATA_free(st) SKM_sk_free(X509_POLICY_DATA, (st))\n# define sk_X509_POLICY_DATA_num(st) SKM_sk_num(X509_POLICY_DATA, (st))\n# define sk_X509_POLICY_DATA_value(st, i) SKM_sk_value(X509_POLICY_DATA, (st), (i))\n# define sk_X509_POLICY_DATA_set(st, i, val) SKM_sk_set(X509_POLICY_DATA, (st), (i), (val))\n# define sk_X509_POLICY_DATA_zero(st) SKM_sk_zero(X509_POLICY_DATA, (st))\n# define sk_X509_POLICY_DATA_push(st, val) SKM_sk_push(X509_POLICY_DATA, (st), (val))\n# define sk_X509_POLICY_DATA_unshift(st, val) SKM_sk_unshift(X509_POLICY_DATA, (st), (val))\n# define sk_X509_POLICY_DATA_find(st, val) SKM_sk_find(X509_POLICY_DATA, (st), (val))\n# define sk_X509_POLICY_DATA_find_ex(st, val) SKM_sk_find_ex(X509_POLICY_DATA, (st), (val))\n# define sk_X509_POLICY_DATA_delete(st, i) SKM_sk_delete(X509_POLICY_DATA, (st), (i))\n# define sk_X509_POLICY_DATA_delete_ptr(st, ptr) SKM_sk_delete_ptr(X509_POLICY_DATA, (st), (ptr))\n# define sk_X509_POLICY_DATA_insert(st, val, i) SKM_sk_insert(X509_POLICY_DATA, (st), (val), (i))\n# define sk_X509_POLICY_DATA_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(X509_POLICY_DATA, (st), (cmp))\n# define sk_X509_POLICY_DATA_dup(st) SKM_sk_dup(X509_POLICY_DATA, st)\n# define sk_X509_POLICY_DATA_pop_free(st, free_func) SKM_sk_pop_free(X509_POLICY_DATA, (st), (free_func))\n# define sk_X509_POLICY_DATA_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(X509_POLICY_DATA, (st), (copy_func), (free_func))\n# define sk_X509_POLICY_DATA_shift(st) SKM_sk_shift(X509_POLICY_DATA, (st))\n# define sk_X509_POLICY_DATA_pop(st) SKM_sk_pop(X509_POLICY_DATA, (st))\n# define sk_X509_POLICY_DATA_sort(st) SKM_sk_sort(X509_POLICY_DATA, (st))\n# define sk_X509_POLICY_DATA_is_sorted(st) SKM_sk_is_sorted(X509_POLICY_DATA, (st))\n# define sk_X509_POLICY_NODE_new(cmp) SKM_sk_new(X509_POLICY_NODE, (cmp))\n# define sk_X509_POLICY_NODE_new_null() SKM_sk_new_null(X509_POLICY_NODE)\n# define sk_X509_POLICY_NODE_free(st) SKM_sk_free(X509_POLICY_NODE, (st))\n# define sk_X509_POLICY_NODE_num(st) SKM_sk_num(X509_POLICY_NODE, (st))\n# define sk_X509_POLICY_NODE_value(st, i) SKM_sk_value(X509_POLICY_NODE, (st), (i))\n# define sk_X509_POLICY_NODE_set(st, i, val) SKM_sk_set(X509_POLICY_NODE, (st), (i), (val))\n# define sk_X509_POLICY_NODE_zero(st) SKM_sk_zero(X509_POLICY_NODE, (st))\n# define sk_X509_POLICY_NODE_push(st, val) SKM_sk_push(X509_POLICY_NODE, (st), (val))\n# define sk_X509_POLICY_NODE_unshift(st, val) SKM_sk_unshift(X509_POLICY_NODE, (st), (val))\n# define sk_X509_POLICY_NODE_find(st, val) SKM_sk_find(X509_POLICY_NODE, (st), (val))\n# define sk_X509_POLICY_NODE_find_ex(st, val) SKM_sk_find_ex(X509_POLICY_NODE, (st), (val))\n# define sk_X509_POLICY_NODE_delete(st, i) SKM_sk_delete(X509_POLICY_NODE, (st), (i))\n# define sk_X509_POLICY_NODE_delete_ptr(st, ptr) SKM_sk_delete_ptr(X509_POLICY_NODE, (st), (ptr))\n# define sk_X509_POLICY_NODE_insert(st, val, i) SKM_sk_insert(X509_POLICY_NODE, (st), (val), (i))\n# define sk_X509_POLICY_NODE_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(X509_POLICY_NODE, (st), (cmp))\n# define sk_X509_POLICY_NODE_dup(st) SKM_sk_dup(X509_POLICY_NODE, st)\n# define sk_X509_POLICY_NODE_pop_free(st, free_func) SKM_sk_pop_free(X509_POLICY_NODE, (st), (free_func))\n# define sk_X509_POLICY_NODE_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(X509_POLICY_NODE, (st), (copy_func), (free_func))\n# define sk_X509_POLICY_NODE_shift(st) SKM_sk_shift(X509_POLICY_NODE, (st))\n# define sk_X509_POLICY_NODE_pop(st) SKM_sk_pop(X509_POLICY_NODE, (st))\n# define sk_X509_POLICY_NODE_sort(st) SKM_sk_sort(X509_POLICY_NODE, (st))\n# define sk_X509_POLICY_NODE_is_sorted(st) SKM_sk_is_sorted(X509_POLICY_NODE, (st))\n# define sk_X509_PURPOSE_new(cmp) SKM_sk_new(X509_PURPOSE, (cmp))\n# define sk_X509_PURPOSE_new_null() SKM_sk_new_null(X509_PURPOSE)\n# define sk_X509_PURPOSE_free(st) SKM_sk_free(X509_PURPOSE, (st))\n# define sk_X509_PURPOSE_num(st) SKM_sk_num(X509_PURPOSE, (st))\n# define sk_X509_PURPOSE_value(st, i) SKM_sk_value(X509_PURPOSE, (st), (i))\n# define sk_X509_PURPOSE_set(st, i, val) SKM_sk_set(X509_PURPOSE, (st), (i), (val))\n# define sk_X509_PURPOSE_zero(st) SKM_sk_zero(X509_PURPOSE, (st))\n# define sk_X509_PURPOSE_push(st, val) SKM_sk_push(X509_PURPOSE, (st), (val))\n# define sk_X509_PURPOSE_unshift(st, val) SKM_sk_unshift(X509_PURPOSE, (st), (val))\n# define sk_X509_PURPOSE_find(st, val) SKM_sk_find(X509_PURPOSE, (st), (val))\n# define sk_X509_PURPOSE_find_ex(st, val) SKM_sk_find_ex(X509_PURPOSE, (st), (val))\n# define sk_X509_PURPOSE_delete(st, i) SKM_sk_delete(X509_PURPOSE, (st), (i))\n# define sk_X509_PURPOSE_delete_ptr(st, ptr) SKM_sk_delete_ptr(X509_PURPOSE, (st), (ptr))\n# define sk_X509_PURPOSE_insert(st, val, i) SKM_sk_insert(X509_PURPOSE, (st), (val), (i))\n# define sk_X509_PURPOSE_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(X509_PURPOSE, (st), (cmp))\n# define sk_X509_PURPOSE_dup(st) SKM_sk_dup(X509_PURPOSE, st)\n# define sk_X509_PURPOSE_pop_free(st, free_func) SKM_sk_pop_free(X509_PURPOSE, (st), (free_func))\n# define sk_X509_PURPOSE_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(X509_PURPOSE, (st), (copy_func), (free_func))\n# define sk_X509_PURPOSE_shift(st) SKM_sk_shift(X509_PURPOSE, (st))\n# define sk_X509_PURPOSE_pop(st) SKM_sk_pop(X509_PURPOSE, (st))\n# define sk_X509_PURPOSE_sort(st) SKM_sk_sort(X509_PURPOSE, (st))\n# define sk_X509_PURPOSE_is_sorted(st) SKM_sk_is_sorted(X509_PURPOSE, (st))\n# define sk_X509_REVOKED_new(cmp) SKM_sk_new(X509_REVOKED, (cmp))\n# define sk_X509_REVOKED_new_null() SKM_sk_new_null(X509_REVOKED)\n# define sk_X509_REVOKED_free(st) SKM_sk_free(X509_REVOKED, (st))\n# define sk_X509_REVOKED_num(st) SKM_sk_num(X509_REVOKED, (st))\n# define sk_X509_REVOKED_value(st, i) SKM_sk_value(X509_REVOKED, (st), (i))\n# define sk_X509_REVOKED_set(st, i, val) SKM_sk_set(X509_REVOKED, (st), (i), (val))\n# define sk_X509_REVOKED_zero(st) SKM_sk_zero(X509_REVOKED, (st))\n# define sk_X509_REVOKED_push(st, val) SKM_sk_push(X509_REVOKED, (st), (val))\n# define sk_X509_REVOKED_unshift(st, val) SKM_sk_unshift(X509_REVOKED, (st), (val))\n# define sk_X509_REVOKED_find(st, val) SKM_sk_find(X509_REVOKED, (st), (val))\n# define sk_X509_REVOKED_find_ex(st, val) SKM_sk_find_ex(X509_REVOKED, (st), (val))\n# define sk_X509_REVOKED_delete(st, i) SKM_sk_delete(X509_REVOKED, (st), (i))\n# define sk_X509_REVOKED_delete_ptr(st, ptr) SKM_sk_delete_ptr(X509_REVOKED, (st), (ptr))\n# define sk_X509_REVOKED_insert(st, val, i) SKM_sk_insert(X509_REVOKED, (st), (val), (i))\n# define sk_X509_REVOKED_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(X509_REVOKED, (st), (cmp))\n# define sk_X509_REVOKED_dup(st) SKM_sk_dup(X509_REVOKED, st)\n# define sk_X509_REVOKED_pop_free(st, free_func) SKM_sk_pop_free(X509_REVOKED, (st), (free_func))\n# define sk_X509_REVOKED_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(X509_REVOKED, (st), (copy_func), (free_func))\n# define sk_X509_REVOKED_shift(st) SKM_sk_shift(X509_REVOKED, (st))\n# define sk_X509_REVOKED_pop(st) SKM_sk_pop(X509_REVOKED, (st))\n# define sk_X509_REVOKED_sort(st) SKM_sk_sort(X509_REVOKED, (st))\n# define sk_X509_REVOKED_is_sorted(st) SKM_sk_is_sorted(X509_REVOKED, (st))\n# define sk_X509_TRUST_new(cmp) SKM_sk_new(X509_TRUST, (cmp))\n# define sk_X509_TRUST_new_null() SKM_sk_new_null(X509_TRUST)\n# define sk_X509_TRUST_free(st) SKM_sk_free(X509_TRUST, (st))\n# define sk_X509_TRUST_num(st) SKM_sk_num(X509_TRUST, (st))\n# define sk_X509_TRUST_value(st, i) SKM_sk_value(X509_TRUST, (st), (i))\n# define sk_X509_TRUST_set(st, i, val) SKM_sk_set(X509_TRUST, (st), (i), (val))\n# define sk_X509_TRUST_zero(st) SKM_sk_zero(X509_TRUST, (st))\n# define sk_X509_TRUST_push(st, val) SKM_sk_push(X509_TRUST, (st), (val))\n# define sk_X509_TRUST_unshift(st, val) SKM_sk_unshift(X509_TRUST, (st), (val))\n# define sk_X509_TRUST_find(st, val) SKM_sk_find(X509_TRUST, (st), (val))\n# define sk_X509_TRUST_find_ex(st, val) SKM_sk_find_ex(X509_TRUST, (st), (val))\n# define sk_X509_TRUST_delete(st, i) SKM_sk_delete(X509_TRUST, (st), (i))\n# define sk_X509_TRUST_delete_ptr(st, ptr) SKM_sk_delete_ptr(X509_TRUST, (st), (ptr))\n# define sk_X509_TRUST_insert(st, val, i) SKM_sk_insert(X509_TRUST, (st), (val), (i))\n# define sk_X509_TRUST_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(X509_TRUST, (st), (cmp))\n# define sk_X509_TRUST_dup(st) SKM_sk_dup(X509_TRUST, st)\n# define sk_X509_TRUST_pop_free(st, free_func) SKM_sk_pop_free(X509_TRUST, (st), (free_func))\n# define sk_X509_TRUST_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(X509_TRUST, (st), (copy_func), (free_func))\n# define sk_X509_TRUST_shift(st) SKM_sk_shift(X509_TRUST, (st))\n# define sk_X509_TRUST_pop(st) SKM_sk_pop(X509_TRUST, (st))\n# define sk_X509_TRUST_sort(st) SKM_sk_sort(X509_TRUST, (st))\n# define sk_X509_TRUST_is_sorted(st) SKM_sk_is_sorted(X509_TRUST, (st))\n# define sk_X509_VERIFY_PARAM_new(cmp) SKM_sk_new(X509_VERIFY_PARAM, (cmp))\n# define sk_X509_VERIFY_PARAM_new_null() SKM_sk_new_null(X509_VERIFY_PARAM)\n# define sk_X509_VERIFY_PARAM_free(st) SKM_sk_free(X509_VERIFY_PARAM, (st))\n# define sk_X509_VERIFY_PARAM_num(st) SKM_sk_num(X509_VERIFY_PARAM, (st))\n# define sk_X509_VERIFY_PARAM_value(st, i) SKM_sk_value(X509_VERIFY_PARAM, (st), (i))\n# define sk_X509_VERIFY_PARAM_set(st, i, val) SKM_sk_set(X509_VERIFY_PARAM, (st), (i), (val))\n# define sk_X509_VERIFY_PARAM_zero(st) SKM_sk_zero(X509_VERIFY_PARAM, (st))\n# define sk_X509_VERIFY_PARAM_push(st, val) SKM_sk_push(X509_VERIFY_PARAM, (st), (val))\n# define sk_X509_VERIFY_PARAM_unshift(st, val) SKM_sk_unshift(X509_VERIFY_PARAM, (st), (val))\n# define sk_X509_VERIFY_PARAM_find(st, val) SKM_sk_find(X509_VERIFY_PARAM, (st), (val))\n# define sk_X509_VERIFY_PARAM_find_ex(st, val) SKM_sk_find_ex(X509_VERIFY_PARAM, (st), (val))\n# define sk_X509_VERIFY_PARAM_delete(st, i) SKM_sk_delete(X509_VERIFY_PARAM, (st), (i))\n# define sk_X509_VERIFY_PARAM_delete_ptr(st, ptr) SKM_sk_delete_ptr(X509_VERIFY_PARAM, (st), (ptr))\n# define sk_X509_VERIFY_PARAM_insert(st, val, i) SKM_sk_insert(X509_VERIFY_PARAM, (st), (val), (i))\n# define sk_X509_VERIFY_PARAM_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(X509_VERIFY_PARAM, (st), (cmp))\n# define sk_X509_VERIFY_PARAM_dup(st) SKM_sk_dup(X509_VERIFY_PARAM, st)\n# define sk_X509_VERIFY_PARAM_pop_free(st, free_func) SKM_sk_pop_free(X509_VERIFY_PARAM, (st), (free_func))\n# define sk_X509_VERIFY_PARAM_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(X509_VERIFY_PARAM, (st), (copy_func), (free_func))\n# define sk_X509_VERIFY_PARAM_shift(st) SKM_sk_shift(X509_VERIFY_PARAM, (st))\n# define sk_X509_VERIFY_PARAM_pop(st) SKM_sk_pop(X509_VERIFY_PARAM, (st))\n# define sk_X509_VERIFY_PARAM_sort(st) SKM_sk_sort(X509_VERIFY_PARAM, (st))\n# define sk_X509_VERIFY_PARAM_is_sorted(st) SKM_sk_is_sorted(X509_VERIFY_PARAM, (st))\n# define sk_nid_triple_new(cmp) SKM_sk_new(nid_triple, (cmp))\n# define sk_nid_triple_new_null() SKM_sk_new_null(nid_triple)\n# define sk_nid_triple_free(st) SKM_sk_free(nid_triple, (st))\n# define sk_nid_triple_num(st) SKM_sk_num(nid_triple, (st))\n# define sk_nid_triple_value(st, i) SKM_sk_value(nid_triple, (st), (i))\n# define sk_nid_triple_set(st, i, val) SKM_sk_set(nid_triple, (st), (i), (val))\n# define sk_nid_triple_zero(st) SKM_sk_zero(nid_triple, (st))\n# define sk_nid_triple_push(st, val) SKM_sk_push(nid_triple, (st), (val))\n# define sk_nid_triple_unshift(st, val) SKM_sk_unshift(nid_triple, (st), (val))\n# define sk_nid_triple_find(st, val) SKM_sk_find(nid_triple, (st), (val))\n# define sk_nid_triple_find_ex(st, val) SKM_sk_find_ex(nid_triple, (st), (val))\n# define sk_nid_triple_delete(st, i) SKM_sk_delete(nid_triple, (st), (i))\n# define sk_nid_triple_delete_ptr(st, ptr) SKM_sk_delete_ptr(nid_triple, (st), (ptr))\n# define sk_nid_triple_insert(st, val, i) SKM_sk_insert(nid_triple, (st), (val), (i))\n# define sk_nid_triple_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(nid_triple, (st), (cmp))\n# define sk_nid_triple_dup(st) SKM_sk_dup(nid_triple, st)\n# define sk_nid_triple_pop_free(st, free_func) SKM_sk_pop_free(nid_triple, (st), (free_func))\n# define sk_nid_triple_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(nid_triple, (st), (copy_func), (free_func))\n# define sk_nid_triple_shift(st) SKM_sk_shift(nid_triple, (st))\n# define sk_nid_triple_pop(st) SKM_sk_pop(nid_triple, (st))\n# define sk_nid_triple_sort(st) SKM_sk_sort(nid_triple, (st))\n# define sk_nid_triple_is_sorted(st) SKM_sk_is_sorted(nid_triple, (st))\n# define sk_void_new(cmp) SKM_sk_new(void, (cmp))\n# define sk_void_new_null() SKM_sk_new_null(void)\n# define sk_void_free(st) SKM_sk_free(void, (st))\n# define sk_void_num(st) SKM_sk_num(void, (st))\n# define sk_void_value(st, i) SKM_sk_value(void, (st), (i))\n# define sk_void_set(st, i, val) SKM_sk_set(void, (st), (i), (val))\n# define sk_void_zero(st) SKM_sk_zero(void, (st))\n# define sk_void_push(st, val) SKM_sk_push(void, (st), (val))\n# define sk_void_unshift(st, val) SKM_sk_unshift(void, (st), (val))\n# define sk_void_find(st, val) SKM_sk_find(void, (st), (val))\n# define sk_void_find_ex(st, val) SKM_sk_find_ex(void, (st), (val))\n# define sk_void_delete(st, i) SKM_sk_delete(void, (st), (i))\n# define sk_void_delete_ptr(st, ptr) SKM_sk_delete_ptr(void, (st), (ptr))\n# define sk_void_insert(st, val, i) SKM_sk_insert(void, (st), (val), (i))\n# define sk_void_set_cmp_func(st, cmp) SKM_sk_set_cmp_func(void, (st), (cmp))\n# define sk_void_dup(st) SKM_sk_dup(void, st)\n# define sk_void_pop_free(st, free_func) SKM_sk_pop_free(void, (st), (free_func))\n# define sk_void_deep_copy(st, copy_func, free_func) SKM_sk_deep_copy(void, (st), (copy_func), (free_func))\n# define sk_void_shift(st) SKM_sk_shift(void, (st))\n# define sk_void_pop(st) SKM_sk_pop(void, (st))\n# define sk_void_sort(st) SKM_sk_sort(void, (st))\n# define sk_void_is_sorted(st) SKM_sk_is_sorted(void, (st))\n# define sk_OPENSSL_STRING_new(cmp) ((STACK_OF(OPENSSL_STRING) *)sk_new(CHECKED_SK_CMP_FUNC(char, cmp)))\n# define sk_OPENSSL_STRING_new_null() ((STACK_OF(OPENSSL_STRING) *)sk_new_null())\n# define sk_OPENSSL_STRING_push(st, val) sk_push(CHECKED_STACK_OF(OPENSSL_STRING, st), CHECKED_PTR_OF(char, val))\n# define sk_OPENSSL_STRING_find(st, val) sk_find(CHECKED_STACK_OF(OPENSSL_STRING, st), CHECKED_PTR_OF(char, val))\n# define sk_OPENSSL_STRING_value(st, i) ((OPENSSL_STRING)sk_value(CHECKED_STACK_OF(OPENSSL_STRING, st), i))\n# define sk_OPENSSL_STRING_num(st) SKM_sk_num(OPENSSL_STRING, st)\n# define sk_OPENSSL_STRING_pop_free(st, free_func) sk_pop_free(CHECKED_STACK_OF(OPENSSL_STRING, st), CHECKED_SK_FREE_FUNC(char, free_func))\n# define sk_OPENSSL_STRING_deep_copy(st, copy_func, free_func) ((STACK_OF(OPENSSL_STRING) *)sk_deep_copy(CHECKED_STACK_OF(OPENSSL_STRING, st), CHECKED_SK_COPY_FUNC(char, copy_func), CHECKED_SK_FREE_FUNC(char, free_func)))\n# define sk_OPENSSL_STRING_insert(st, val, i) sk_insert(CHECKED_STACK_OF(OPENSSL_STRING, st), CHECKED_PTR_OF(char, val), i)\n# define sk_OPENSSL_STRING_free(st) SKM_sk_free(OPENSSL_STRING, st)\n# define sk_OPENSSL_STRING_set(st, i, val) sk_set(CHECKED_STACK_OF(OPENSSL_STRING, st), i, CHECKED_PTR_OF(char, val))\n# define sk_OPENSSL_STRING_zero(st) SKM_sk_zero(OPENSSL_STRING, (st))\n# define sk_OPENSSL_STRING_unshift(st, val) sk_unshift(CHECKED_STACK_OF(OPENSSL_STRING, st), CHECKED_PTR_OF(char, val))\n# define sk_OPENSSL_STRING_find_ex(st, val) sk_find_ex((_STACK *)CHECKED_CONST_PTR_OF(STACK_OF(OPENSSL_STRING), st), CHECKED_CONST_PTR_OF(char, val))\n# define sk_OPENSSL_STRING_delete(st, i) SKM_sk_delete(OPENSSL_STRING, (st), (i))\n# define sk_OPENSSL_STRING_delete_ptr(st, ptr) (OPENSSL_STRING *)sk_delete_ptr(CHECKED_STACK_OF(OPENSSL_STRING, st), CHECKED_PTR_OF(char, ptr))\n# define sk_OPENSSL_STRING_set_cmp_func(st, cmp)  \\\n        ((int (*)(const char * const *,const char * const *)) \\\n        sk_set_cmp_func(CHECKED_STACK_OF(OPENSSL_STRING, st), CHECKED_SK_CMP_FUNC(char, cmp)))\n# define sk_OPENSSL_STRING_dup(st) SKM_sk_dup(OPENSSL_STRING, st)\n# define sk_OPENSSL_STRING_shift(st) SKM_sk_shift(OPENSSL_STRING, (st))\n# define sk_OPENSSL_STRING_pop(st) (char *)sk_pop(CHECKED_STACK_OF(OPENSSL_STRING, st))\n# define sk_OPENSSL_STRING_sort(st) SKM_sk_sort(OPENSSL_STRING, (st))\n# define sk_OPENSSL_STRING_is_sorted(st) SKM_sk_is_sorted(OPENSSL_STRING, (st))\n# define sk_OPENSSL_BLOCK_new(cmp) ((STACK_OF(OPENSSL_BLOCK) *)sk_new(CHECKED_SK_CMP_FUNC(void, cmp)))\n# define sk_OPENSSL_BLOCK_new_null() ((STACK_OF(OPENSSL_BLOCK) *)sk_new_null())\n# define sk_OPENSSL_BLOCK_push(st, val) sk_push(CHECKED_STACK_OF(OPENSSL_BLOCK, st), CHECKED_PTR_OF(void, val))\n# define sk_OPENSSL_BLOCK_find(st, val) sk_find(CHECKED_STACK_OF(OPENSSL_BLOCK, st), CHECKED_PTR_OF(void, val))\n# define sk_OPENSSL_BLOCK_value(st, i) ((OPENSSL_BLOCK)sk_value(CHECKED_STACK_OF(OPENSSL_BLOCK, st), i))\n# define sk_OPENSSL_BLOCK_num(st) SKM_sk_num(OPENSSL_BLOCK, st)\n# define sk_OPENSSL_BLOCK_pop_free(st, free_func) sk_pop_free(CHECKED_STACK_OF(OPENSSL_BLOCK, st), CHECKED_SK_FREE_FUNC(void, free_func))\n# define sk_OPENSSL_BLOCK_deep_copy(st, copy_func, free_func) ((STACK_OF(OPENSSL_BLOCK) *)sk_deep_copy(CHECKED_STACK_OF(OPENSSL_BLOCK, st), CHECKED_SK_COPY_FUNC(void, copy_func), CHECKED_SK_FREE_FUNC(void, free_func)))\n# define sk_OPENSSL_BLOCK_insert(st, val, i) sk_insert(CHECKED_STACK_OF(OPENSSL_BLOCK, st), CHECKED_PTR_OF(void, val), i)\n# define sk_OPENSSL_BLOCK_free(st) SKM_sk_free(OPENSSL_BLOCK, st)\n# define sk_OPENSSL_BLOCK_set(st, i, val) sk_set(CHECKED_STACK_OF(OPENSSL_BLOCK, st), i, CHECKED_PTR_OF(void, val))\n# define sk_OPENSSL_BLOCK_zero(st) SKM_sk_zero(OPENSSL_BLOCK, (st))\n# define sk_OPENSSL_BLOCK_unshift(st, val) sk_unshift(CHECKED_STACK_OF(OPENSSL_BLOCK, st), CHECKED_PTR_OF(void, val))\n# define sk_OPENSSL_BLOCK_find_ex(st, val) sk_find_ex((_STACK *)CHECKED_CONST_PTR_OF(STACK_OF(OPENSSL_BLOCK), st), CHECKED_CONST_PTR_OF(void, val))\n# define sk_OPENSSL_BLOCK_delete(st, i) SKM_sk_delete(OPENSSL_BLOCK, (st), (i))\n# define sk_OPENSSL_BLOCK_delete_ptr(st, ptr) (OPENSSL_BLOCK *)sk_delete_ptr(CHECKED_STACK_OF(OPENSSL_BLOCK, st), CHECKED_PTR_OF(void, ptr))\n# define sk_OPENSSL_BLOCK_set_cmp_func(st, cmp)  \\\n        ((int (*)(const void * const *,const void * const *)) \\\n        sk_set_cmp_func(CHECKED_STACK_OF(OPENSSL_BLOCK, st), CHECKED_SK_CMP_FUNC(void, cmp)))\n# define sk_OPENSSL_BLOCK_dup(st) SKM_sk_dup(OPENSSL_BLOCK, st)\n# define sk_OPENSSL_BLOCK_shift(st) SKM_sk_shift(OPENSSL_BLOCK, (st))\n# define sk_OPENSSL_BLOCK_pop(st) (void *)sk_pop(CHECKED_STACK_OF(OPENSSL_BLOCK, st))\n# define sk_OPENSSL_BLOCK_sort(st) SKM_sk_sort(OPENSSL_BLOCK, (st))\n# define sk_OPENSSL_BLOCK_is_sorted(st) SKM_sk_is_sorted(OPENSSL_BLOCK, (st))\n# define sk_OPENSSL_PSTRING_new(cmp) ((STACK_OF(OPENSSL_PSTRING) *)sk_new(CHECKED_SK_CMP_FUNC(OPENSSL_STRING, cmp)))\n# define sk_OPENSSL_PSTRING_new_null() ((STACK_OF(OPENSSL_PSTRING) *)sk_new_null())\n# define sk_OPENSSL_PSTRING_push(st, val) sk_push(CHECKED_STACK_OF(OPENSSL_PSTRING, st), CHECKED_PTR_OF(OPENSSL_STRING, val))\n# define sk_OPENSSL_PSTRING_find(st, val) sk_find(CHECKED_STACK_OF(OPENSSL_PSTRING, st), CHECKED_PTR_OF(OPENSSL_STRING, val))\n# define sk_OPENSSL_PSTRING_value(st, i) ((OPENSSL_PSTRING)sk_value(CHECKED_STACK_OF(OPENSSL_PSTRING, st), i))\n# define sk_OPENSSL_PSTRING_num(st) SKM_sk_num(OPENSSL_PSTRING, st)\n# define sk_OPENSSL_PSTRING_pop_free(st, free_func) sk_pop_free(CHECKED_STACK_OF(OPENSSL_PSTRING, st), CHECKED_SK_FREE_FUNC(OPENSSL_STRING, free_func))\n# define sk_OPENSSL_PSTRING_deep_copy(st, copy_func, free_func) ((STACK_OF(OPENSSL_PSTRING) *)sk_deep_copy(CHECKED_STACK_OF(OPENSSL_PSTRING, st), CHECKED_SK_COPY_FUNC(OPENSSL_STRING, copy_func), CHECKED_SK_FREE_FUNC(OPENSSL_STRING, free_func)))\n# define sk_OPENSSL_PSTRING_insert(st, val, i) sk_insert(CHECKED_STACK_OF(OPENSSL_PSTRING, st), CHECKED_PTR_OF(OPENSSL_STRING, val), i)\n# define sk_OPENSSL_PSTRING_free(st) SKM_sk_free(OPENSSL_PSTRING, st)\n# define sk_OPENSSL_PSTRING_set(st, i, val) sk_set(CHECKED_STACK_OF(OPENSSL_PSTRING, st), i, CHECKED_PTR_OF(OPENSSL_STRING, val))\n# define sk_OPENSSL_PSTRING_zero(st) SKM_sk_zero(OPENSSL_PSTRING, (st))\n# define sk_OPENSSL_PSTRING_unshift(st, val) sk_unshift(CHECKED_STACK_OF(OPENSSL_PSTRING, st), CHECKED_PTR_OF(OPENSSL_STRING, val))\n# define sk_OPENSSL_PSTRING_find_ex(st, val) sk_find_ex((_STACK *)CHECKED_CONST_PTR_OF(STACK_OF(OPENSSL_PSTRING), st), CHECKED_CONST_PTR_OF(OPENSSL_STRING, val))\n# define sk_OPENSSL_PSTRING_delete(st, i) SKM_sk_delete(OPENSSL_PSTRING, (st), (i))\n# define sk_OPENSSL_PSTRING_delete_ptr(st, ptr) (OPENSSL_PSTRING *)sk_delete_ptr(CHECKED_STACK_OF(OPENSSL_PSTRING, st), CHECKED_PTR_OF(OPENSSL_STRING, ptr))\n# define sk_OPENSSL_PSTRING_set_cmp_func(st, cmp)  \\\n        ((int (*)(const OPENSSL_STRING * const *,const OPENSSL_STRING * const *)) \\\n        sk_set_cmp_func(CHECKED_STACK_OF(OPENSSL_PSTRING, st), CHECKED_SK_CMP_FUNC(OPENSSL_STRING, cmp)))\n# define sk_OPENSSL_PSTRING_dup(st) SKM_sk_dup(OPENSSL_PSTRING, st)\n# define sk_OPENSSL_PSTRING_shift(st) SKM_sk_shift(OPENSSL_PSTRING, (st))\n# define sk_OPENSSL_PSTRING_pop(st) (OPENSSL_STRING *)sk_pop(CHECKED_STACK_OF(OPENSSL_PSTRING, st))\n# define sk_OPENSSL_PSTRING_sort(st) SKM_sk_sort(OPENSSL_PSTRING, (st))\n# define sk_OPENSSL_PSTRING_is_sorted(st) SKM_sk_is_sorted(OPENSSL_PSTRING, (st))\n# define d2i_ASN1_SET_OF_ACCESS_DESCRIPTION(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \\\n        SKM_ASN1_SET_OF_d2i(ACCESS_DESCRIPTION, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class))\n# define i2d_ASN1_SET_OF_ACCESS_DESCRIPTION(st, pp, i2d_func, ex_tag, ex_class, is_set) \\\n        SKM_ASN1_SET_OF_i2d(ACCESS_DESCRIPTION, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set))\n# define ASN1_seq_pack_ACCESS_DESCRIPTION(st, i2d_func, buf, len) \\\n        SKM_ASN1_seq_pack(ACCESS_DESCRIPTION, (st), (i2d_func), (buf), (len))\n# define ASN1_seq_unpack_ACCESS_DESCRIPTION(buf, len, d2i_func, free_func) \\\n        SKM_ASN1_seq_unpack(ACCESS_DESCRIPTION, (buf), (len), (d2i_func), (free_func))\n# define d2i_ASN1_SET_OF_ASN1_INTEGER(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \\\n        SKM_ASN1_SET_OF_d2i(ASN1_INTEGER, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class))\n# define i2d_ASN1_SET_OF_ASN1_INTEGER(st, pp, i2d_func, ex_tag, ex_class, is_set) \\\n        SKM_ASN1_SET_OF_i2d(ASN1_INTEGER, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set))\n# define ASN1_seq_pack_ASN1_INTEGER(st, i2d_func, buf, len) \\\n        SKM_ASN1_seq_pack(ASN1_INTEGER, (st), (i2d_func), (buf), (len))\n# define ASN1_seq_unpack_ASN1_INTEGER(buf, len, d2i_func, free_func) \\\n        SKM_ASN1_seq_unpack(ASN1_INTEGER, (buf), (len), (d2i_func), (free_func))\n# define d2i_ASN1_SET_OF_ASN1_OBJECT(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \\\n        SKM_ASN1_SET_OF_d2i(ASN1_OBJECT, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class))\n# define i2d_ASN1_SET_OF_ASN1_OBJECT(st, pp, i2d_func, ex_tag, ex_class, is_set) \\\n        SKM_ASN1_SET_OF_i2d(ASN1_OBJECT, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set))\n# define ASN1_seq_pack_ASN1_OBJECT(st, i2d_func, buf, len) \\\n        SKM_ASN1_seq_pack(ASN1_OBJECT, (st), (i2d_func), (buf), (len))\n# define ASN1_seq_unpack_ASN1_OBJECT(buf, len, d2i_func, free_func) \\\n        SKM_ASN1_seq_unpack(ASN1_OBJECT, (buf), (len), (d2i_func), (free_func))\n# define d2i_ASN1_SET_OF_ASN1_TYPE(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \\\n        SKM_ASN1_SET_OF_d2i(ASN1_TYPE, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class))\n# define i2d_ASN1_SET_OF_ASN1_TYPE(st, pp, i2d_func, ex_tag, ex_class, is_set) \\\n        SKM_ASN1_SET_OF_i2d(ASN1_TYPE, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set))\n# define ASN1_seq_pack_ASN1_TYPE(st, i2d_func, buf, len) \\\n        SKM_ASN1_seq_pack(ASN1_TYPE, (st), (i2d_func), (buf), (len))\n# define ASN1_seq_unpack_ASN1_TYPE(buf, len, d2i_func, free_func) \\\n        SKM_ASN1_seq_unpack(ASN1_TYPE, (buf), (len), (d2i_func), (free_func))\n# define d2i_ASN1_SET_OF_ASN1_UTF8STRING(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \\\n        SKM_ASN1_SET_OF_d2i(ASN1_UTF8STRING, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class))\n# define i2d_ASN1_SET_OF_ASN1_UTF8STRING(st, pp, i2d_func, ex_tag, ex_class, is_set) \\\n        SKM_ASN1_SET_OF_i2d(ASN1_UTF8STRING, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set))\n# define ASN1_seq_pack_ASN1_UTF8STRING(st, i2d_func, buf, len) \\\n        SKM_ASN1_seq_pack(ASN1_UTF8STRING, (st), (i2d_func), (buf), (len))\n# define ASN1_seq_unpack_ASN1_UTF8STRING(buf, len, d2i_func, free_func) \\\n        SKM_ASN1_seq_unpack(ASN1_UTF8STRING, (buf), (len), (d2i_func), (free_func))\n# define d2i_ASN1_SET_OF_DIST_POINT(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \\\n        SKM_ASN1_SET_OF_d2i(DIST_POINT, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class))\n# define i2d_ASN1_SET_OF_DIST_POINT(st, pp, i2d_func, ex_tag, ex_class, is_set) \\\n        SKM_ASN1_SET_OF_i2d(DIST_POINT, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set))\n# define ASN1_seq_pack_DIST_POINT(st, i2d_func, buf, len) \\\n        SKM_ASN1_seq_pack(DIST_POINT, (st), (i2d_func), (buf), (len))\n# define ASN1_seq_unpack_DIST_POINT(buf, len, d2i_func, free_func) \\\n        SKM_ASN1_seq_unpack(DIST_POINT, (buf), (len), (d2i_func), (free_func))\n# define d2i_ASN1_SET_OF_ESS_CERT_ID(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \\\n        SKM_ASN1_SET_OF_d2i(ESS_CERT_ID, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class))\n# define i2d_ASN1_SET_OF_ESS_CERT_ID(st, pp, i2d_func, ex_tag, ex_class, is_set) \\\n        SKM_ASN1_SET_OF_i2d(ESS_CERT_ID, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set))\n# define ASN1_seq_pack_ESS_CERT_ID(st, i2d_func, buf, len) \\\n        SKM_ASN1_seq_pack(ESS_CERT_ID, (st), (i2d_func), (buf), (len))\n# define ASN1_seq_unpack_ESS_CERT_ID(buf, len, d2i_func, free_func) \\\n        SKM_ASN1_seq_unpack(ESS_CERT_ID, (buf), (len), (d2i_func), (free_func))\n# define d2i_ASN1_SET_OF_EVP_MD(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \\\n        SKM_ASN1_SET_OF_d2i(EVP_MD, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class))\n# define i2d_ASN1_SET_OF_EVP_MD(st, pp, i2d_func, ex_tag, ex_class, is_set) \\\n        SKM_ASN1_SET_OF_i2d(EVP_MD, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set))\n# define ASN1_seq_pack_EVP_MD(st, i2d_func, buf, len) \\\n        SKM_ASN1_seq_pack(EVP_MD, (st), (i2d_func), (buf), (len))\n# define ASN1_seq_unpack_EVP_MD(buf, len, d2i_func, free_func) \\\n        SKM_ASN1_seq_unpack(EVP_MD, (buf), (len), (d2i_func), (free_func))\n# define d2i_ASN1_SET_OF_GENERAL_NAME(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \\\n        SKM_ASN1_SET_OF_d2i(GENERAL_NAME, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class))\n# define i2d_ASN1_SET_OF_GENERAL_NAME(st, pp, i2d_func, ex_tag, ex_class, is_set) \\\n        SKM_ASN1_SET_OF_i2d(GENERAL_NAME, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set))\n# define ASN1_seq_pack_GENERAL_NAME(st, i2d_func, buf, len) \\\n        SKM_ASN1_seq_pack(GENERAL_NAME, (st), (i2d_func), (buf), (len))\n# define ASN1_seq_unpack_GENERAL_NAME(buf, len, d2i_func, free_func) \\\n        SKM_ASN1_seq_unpack(GENERAL_NAME, (buf), (len), (d2i_func), (free_func))\n# define d2i_ASN1_SET_OF_OCSP_ONEREQ(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \\\n        SKM_ASN1_SET_OF_d2i(OCSP_ONEREQ, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class))\n# define i2d_ASN1_SET_OF_OCSP_ONEREQ(st, pp, i2d_func, ex_tag, ex_class, is_set) \\\n        SKM_ASN1_SET_OF_i2d(OCSP_ONEREQ, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set))\n# define ASN1_seq_pack_OCSP_ONEREQ(st, i2d_func, buf, len) \\\n        SKM_ASN1_seq_pack(OCSP_ONEREQ, (st), (i2d_func), (buf), (len))\n# define ASN1_seq_unpack_OCSP_ONEREQ(buf, len, d2i_func, free_func) \\\n        SKM_ASN1_seq_unpack(OCSP_ONEREQ, (buf), (len), (d2i_func), (free_func))\n# define d2i_ASN1_SET_OF_OCSP_SINGLERESP(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \\\n        SKM_ASN1_SET_OF_d2i(OCSP_SINGLERESP, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class))\n# define i2d_ASN1_SET_OF_OCSP_SINGLERESP(st, pp, i2d_func, ex_tag, ex_class, is_set) \\\n        SKM_ASN1_SET_OF_i2d(OCSP_SINGLERESP, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set))\n# define ASN1_seq_pack_OCSP_SINGLERESP(st, i2d_func, buf, len) \\\n        SKM_ASN1_seq_pack(OCSP_SINGLERESP, (st), (i2d_func), (buf), (len))\n# define ASN1_seq_unpack_OCSP_SINGLERESP(buf, len, d2i_func, free_func) \\\n        SKM_ASN1_seq_unpack(OCSP_SINGLERESP, (buf), (len), (d2i_func), (free_func))\n# define d2i_ASN1_SET_OF_PKCS12_SAFEBAG(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \\\n        SKM_ASN1_SET_OF_d2i(PKCS12_SAFEBAG, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class))\n# define i2d_ASN1_SET_OF_PKCS12_SAFEBAG(st, pp, i2d_func, ex_tag, ex_class, is_set) \\\n        SKM_ASN1_SET_OF_i2d(PKCS12_SAFEBAG, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set))\n# define ASN1_seq_pack_PKCS12_SAFEBAG(st, i2d_func, buf, len) \\\n        SKM_ASN1_seq_pack(PKCS12_SAFEBAG, (st), (i2d_func), (buf), (len))\n# define ASN1_seq_unpack_PKCS12_SAFEBAG(buf, len, d2i_func, free_func) \\\n        SKM_ASN1_seq_unpack(PKCS12_SAFEBAG, (buf), (len), (d2i_func), (free_func))\n# define d2i_ASN1_SET_OF_PKCS7(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \\\n        SKM_ASN1_SET_OF_d2i(PKCS7, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class))\n# define i2d_ASN1_SET_OF_PKCS7(st, pp, i2d_func, ex_tag, ex_class, is_set) \\\n        SKM_ASN1_SET_OF_i2d(PKCS7, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set))\n# define ASN1_seq_pack_PKCS7(st, i2d_func, buf, len) \\\n        SKM_ASN1_seq_pack(PKCS7, (st), (i2d_func), (buf), (len))\n# define ASN1_seq_unpack_PKCS7(buf, len, d2i_func, free_func) \\\n        SKM_ASN1_seq_unpack(PKCS7, (buf), (len), (d2i_func), (free_func))\n# define d2i_ASN1_SET_OF_PKCS7_RECIP_INFO(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \\\n        SKM_ASN1_SET_OF_d2i(PKCS7_RECIP_INFO, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class))\n# define i2d_ASN1_SET_OF_PKCS7_RECIP_INFO(st, pp, i2d_func, ex_tag, ex_class, is_set) \\\n        SKM_ASN1_SET_OF_i2d(PKCS7_RECIP_INFO, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set))\n# define ASN1_seq_pack_PKCS7_RECIP_INFO(st, i2d_func, buf, len) \\\n        SKM_ASN1_seq_pack(PKCS7_RECIP_INFO, (st), (i2d_func), (buf), (len))\n# define ASN1_seq_unpack_PKCS7_RECIP_INFO(buf, len, d2i_func, free_func) \\\n        SKM_ASN1_seq_unpack(PKCS7_RECIP_INFO, (buf), (len), (d2i_func), (free_func))\n# define d2i_ASN1_SET_OF_PKCS7_SIGNER_INFO(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \\\n        SKM_ASN1_SET_OF_d2i(PKCS7_SIGNER_INFO, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class))\n# define i2d_ASN1_SET_OF_PKCS7_SIGNER_INFO(st, pp, i2d_func, ex_tag, ex_class, is_set) \\\n        SKM_ASN1_SET_OF_i2d(PKCS7_SIGNER_INFO, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set))\n# define ASN1_seq_pack_PKCS7_SIGNER_INFO(st, i2d_func, buf, len) \\\n        SKM_ASN1_seq_pack(PKCS7_SIGNER_INFO, (st), (i2d_func), (buf), (len))\n# define ASN1_seq_unpack_PKCS7_SIGNER_INFO(buf, len, d2i_func, free_func) \\\n        SKM_ASN1_seq_unpack(PKCS7_SIGNER_INFO, (buf), (len), (d2i_func), (free_func))\n# define d2i_ASN1_SET_OF_POLICYINFO(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \\\n        SKM_ASN1_SET_OF_d2i(POLICYINFO, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class))\n# define i2d_ASN1_SET_OF_POLICYINFO(st, pp, i2d_func, ex_tag, ex_class, is_set) \\\n        SKM_ASN1_SET_OF_i2d(POLICYINFO, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set))\n# define ASN1_seq_pack_POLICYINFO(st, i2d_func, buf, len) \\\n        SKM_ASN1_seq_pack(POLICYINFO, (st), (i2d_func), (buf), (len))\n# define ASN1_seq_unpack_POLICYINFO(buf, len, d2i_func, free_func) \\\n        SKM_ASN1_seq_unpack(POLICYINFO, (buf), (len), (d2i_func), (free_func))\n# define d2i_ASN1_SET_OF_POLICYQUALINFO(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \\\n        SKM_ASN1_SET_OF_d2i(POLICYQUALINFO, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class))\n# define i2d_ASN1_SET_OF_POLICYQUALINFO(st, pp, i2d_func, ex_tag, ex_class, is_set) \\\n        SKM_ASN1_SET_OF_i2d(POLICYQUALINFO, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set))\n# define ASN1_seq_pack_POLICYQUALINFO(st, i2d_func, buf, len) \\\n        SKM_ASN1_seq_pack(POLICYQUALINFO, (st), (i2d_func), (buf), (len))\n# define ASN1_seq_unpack_POLICYQUALINFO(buf, len, d2i_func, free_func) \\\n        SKM_ASN1_seq_unpack(POLICYQUALINFO, (buf), (len), (d2i_func), (free_func))\n# define d2i_ASN1_SET_OF_SXNETID(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \\\n        SKM_ASN1_SET_OF_d2i(SXNETID, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class))\n# define i2d_ASN1_SET_OF_SXNETID(st, pp, i2d_func, ex_tag, ex_class, is_set) \\\n        SKM_ASN1_SET_OF_i2d(SXNETID, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set))\n# define ASN1_seq_pack_SXNETID(st, i2d_func, buf, len) \\\n        SKM_ASN1_seq_pack(SXNETID, (st), (i2d_func), (buf), (len))\n# define ASN1_seq_unpack_SXNETID(buf, len, d2i_func, free_func) \\\n        SKM_ASN1_seq_unpack(SXNETID, (buf), (len), (d2i_func), (free_func))\n# define d2i_ASN1_SET_OF_X509(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \\\n        SKM_ASN1_SET_OF_d2i(X509, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class))\n# define i2d_ASN1_SET_OF_X509(st, pp, i2d_func, ex_tag, ex_class, is_set) \\\n        SKM_ASN1_SET_OF_i2d(X509, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set))\n# define ASN1_seq_pack_X509(st, i2d_func, buf, len) \\\n        SKM_ASN1_seq_pack(X509, (st), (i2d_func), (buf), (len))\n# define ASN1_seq_unpack_X509(buf, len, d2i_func, free_func) \\\n        SKM_ASN1_seq_unpack(X509, (buf), (len), (d2i_func), (free_func))\n# define d2i_ASN1_SET_OF_X509_ALGOR(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \\\n        SKM_ASN1_SET_OF_d2i(X509_ALGOR, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class))\n# define i2d_ASN1_SET_OF_X509_ALGOR(st, pp, i2d_func, ex_tag, ex_class, is_set) \\\n        SKM_ASN1_SET_OF_i2d(X509_ALGOR, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set))\n# define ASN1_seq_pack_X509_ALGOR(st, i2d_func, buf, len) \\\n        SKM_ASN1_seq_pack(X509_ALGOR, (st), (i2d_func), (buf), (len))\n# define ASN1_seq_unpack_X509_ALGOR(buf, len, d2i_func, free_func) \\\n        SKM_ASN1_seq_unpack(X509_ALGOR, (buf), (len), (d2i_func), (free_func))\n# define d2i_ASN1_SET_OF_X509_ATTRIBUTE(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \\\n        SKM_ASN1_SET_OF_d2i(X509_ATTRIBUTE, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class))\n# define i2d_ASN1_SET_OF_X509_ATTRIBUTE(st, pp, i2d_func, ex_tag, ex_class, is_set) \\\n        SKM_ASN1_SET_OF_i2d(X509_ATTRIBUTE, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set))\n# define ASN1_seq_pack_X509_ATTRIBUTE(st, i2d_func, buf, len) \\\n        SKM_ASN1_seq_pack(X509_ATTRIBUTE, (st), (i2d_func), (buf), (len))\n# define ASN1_seq_unpack_X509_ATTRIBUTE(buf, len, d2i_func, free_func) \\\n        SKM_ASN1_seq_unpack(X509_ATTRIBUTE, (buf), (len), (d2i_func), (free_func))\n# define d2i_ASN1_SET_OF_X509_CRL(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \\\n        SKM_ASN1_SET_OF_d2i(X509_CRL, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class))\n# define i2d_ASN1_SET_OF_X509_CRL(st, pp, i2d_func, ex_tag, ex_class, is_set) \\\n        SKM_ASN1_SET_OF_i2d(X509_CRL, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set))\n# define ASN1_seq_pack_X509_CRL(st, i2d_func, buf, len) \\\n        SKM_ASN1_seq_pack(X509_CRL, (st), (i2d_func), (buf), (len))\n# define ASN1_seq_unpack_X509_CRL(buf, len, d2i_func, free_func) \\\n        SKM_ASN1_seq_unpack(X509_CRL, (buf), (len), (d2i_func), (free_func))\n# define d2i_ASN1_SET_OF_X509_EXTENSION(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \\\n        SKM_ASN1_SET_OF_d2i(X509_EXTENSION, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class))\n# define i2d_ASN1_SET_OF_X509_EXTENSION(st, pp, i2d_func, ex_tag, ex_class, is_set) \\\n        SKM_ASN1_SET_OF_i2d(X509_EXTENSION, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set))\n# define ASN1_seq_pack_X509_EXTENSION(st, i2d_func, buf, len) \\\n        SKM_ASN1_seq_pack(X509_EXTENSION, (st), (i2d_func), (buf), (len))\n# define ASN1_seq_unpack_X509_EXTENSION(buf, len, d2i_func, free_func) \\\n        SKM_ASN1_seq_unpack(X509_EXTENSION, (buf), (len), (d2i_func), (free_func))\n# define d2i_ASN1_SET_OF_X509_NAME_ENTRY(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \\\n        SKM_ASN1_SET_OF_d2i(X509_NAME_ENTRY, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class))\n# define i2d_ASN1_SET_OF_X509_NAME_ENTRY(st, pp, i2d_func, ex_tag, ex_class, is_set) \\\n        SKM_ASN1_SET_OF_i2d(X509_NAME_ENTRY, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set))\n# define ASN1_seq_pack_X509_NAME_ENTRY(st, i2d_func, buf, len) \\\n        SKM_ASN1_seq_pack(X509_NAME_ENTRY, (st), (i2d_func), (buf), (len))\n# define ASN1_seq_unpack_X509_NAME_ENTRY(buf, len, d2i_func, free_func) \\\n        SKM_ASN1_seq_unpack(X509_NAME_ENTRY, (buf), (len), (d2i_func), (free_func))\n# define d2i_ASN1_SET_OF_X509_REVOKED(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \\\n        SKM_ASN1_SET_OF_d2i(X509_REVOKED, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class))\n# define i2d_ASN1_SET_OF_X509_REVOKED(st, pp, i2d_func, ex_tag, ex_class, is_set) \\\n        SKM_ASN1_SET_OF_i2d(X509_REVOKED, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set))\n# define ASN1_seq_pack_X509_REVOKED(st, i2d_func, buf, len) \\\n        SKM_ASN1_seq_pack(X509_REVOKED, (st), (i2d_func), (buf), (len))\n# define ASN1_seq_unpack_X509_REVOKED(buf, len, d2i_func, free_func) \\\n        SKM_ASN1_seq_unpack(X509_REVOKED, (buf), (len), (d2i_func), (free_func))\n# define PKCS12_decrypt_d2i_PKCS12_SAFEBAG(algor, d2i_func, free_func, pass, passlen, oct, seq) \\\n        SKM_PKCS12_decrypt_d2i(PKCS12_SAFEBAG, (algor), (d2i_func), (free_func), (pass), (passlen), (oct), (seq))\n# define PKCS12_decrypt_d2i_PKCS7(algor, d2i_func, free_func, pass, passlen, oct, seq) \\\n        SKM_PKCS12_decrypt_d2i(PKCS7, (algor), (d2i_func), (free_func), (pass), (passlen), (oct), (seq))\n# define lh_ADDED_OBJ_new() LHM_lh_new(ADDED_OBJ,added_obj)\n# define lh_ADDED_OBJ_insert(lh,inst) LHM_lh_insert(ADDED_OBJ,lh,inst)\n# define lh_ADDED_OBJ_retrieve(lh,inst) LHM_lh_retrieve(ADDED_OBJ,lh,inst)\n# define lh_ADDED_OBJ_delete(lh,inst) LHM_lh_delete(ADDED_OBJ,lh,inst)\n# define lh_ADDED_OBJ_doall(lh,fn) LHM_lh_doall(ADDED_OBJ,lh,fn)\n# define lh_ADDED_OBJ_doall_arg(lh,fn,arg_type,arg) \\\n  LHM_lh_doall_arg(ADDED_OBJ,lh,fn,arg_type,arg)\n# define lh_ADDED_OBJ_error(lh) LHM_lh_error(ADDED_OBJ,lh)\n# define lh_ADDED_OBJ_num_items(lh) LHM_lh_num_items(ADDED_OBJ,lh)\n# define lh_ADDED_OBJ_down_load(lh) LHM_lh_down_load(ADDED_OBJ,lh)\n# define lh_ADDED_OBJ_node_stats_bio(lh,out) \\\n  LHM_lh_node_stats_bio(ADDED_OBJ,lh,out)\n# define lh_ADDED_OBJ_node_usage_stats_bio(lh,out) \\\n  LHM_lh_node_usage_stats_bio(ADDED_OBJ,lh,out)\n# define lh_ADDED_OBJ_stats_bio(lh,out) \\\n  LHM_lh_stats_bio(ADDED_OBJ,lh,out)\n# define lh_ADDED_OBJ_free(lh) LHM_lh_free(ADDED_OBJ,lh)\n# define lh_APP_INFO_new() LHM_lh_new(APP_INFO,app_info)\n# define lh_APP_INFO_insert(lh,inst) LHM_lh_insert(APP_INFO,lh,inst)\n# define lh_APP_INFO_retrieve(lh,inst) LHM_lh_retrieve(APP_INFO,lh,inst)\n# define lh_APP_INFO_delete(lh,inst) LHM_lh_delete(APP_INFO,lh,inst)\n# define lh_APP_INFO_doall(lh,fn) LHM_lh_doall(APP_INFO,lh,fn)\n# define lh_APP_INFO_doall_arg(lh,fn,arg_type,arg) \\\n  LHM_lh_doall_arg(APP_INFO,lh,fn,arg_type,arg)\n# define lh_APP_INFO_error(lh) LHM_lh_error(APP_INFO,lh)\n# define lh_APP_INFO_num_items(lh) LHM_lh_num_items(APP_INFO,lh)\n# define lh_APP_INFO_down_load(lh) LHM_lh_down_load(APP_INFO,lh)\n# define lh_APP_INFO_node_stats_bio(lh,out) \\\n  LHM_lh_node_stats_bio(APP_INFO,lh,out)\n# define lh_APP_INFO_node_usage_stats_bio(lh,out) \\\n  LHM_lh_node_usage_stats_bio(APP_INFO,lh,out)\n# define lh_APP_INFO_stats_bio(lh,out) \\\n  LHM_lh_stats_bio(APP_INFO,lh,out)\n# define lh_APP_INFO_free(lh) LHM_lh_free(APP_INFO,lh)\n# define lh_CONF_VALUE_new() LHM_lh_new(CONF_VALUE,conf_value)\n# define lh_CONF_VALUE_insert(lh,inst) LHM_lh_insert(CONF_VALUE,lh,inst)\n# define lh_CONF_VALUE_retrieve(lh,inst) LHM_lh_retrieve(CONF_VALUE,lh,inst)\n# define lh_CONF_VALUE_delete(lh,inst) LHM_lh_delete(CONF_VALUE,lh,inst)\n# define lh_CONF_VALUE_doall(lh,fn) LHM_lh_doall(CONF_VALUE,lh,fn)\n# define lh_CONF_VALUE_doall_arg(lh,fn,arg_type,arg) \\\n  LHM_lh_doall_arg(CONF_VALUE,lh,fn,arg_type,arg)\n# define lh_CONF_VALUE_error(lh) LHM_lh_error(CONF_VALUE,lh)\n# define lh_CONF_VALUE_num_items(lh) LHM_lh_num_items(CONF_VALUE,lh)\n# define lh_CONF_VALUE_down_load(lh) LHM_lh_down_load(CONF_VALUE,lh)\n# define lh_CONF_VALUE_node_stats_bio(lh,out) \\\n  LHM_lh_node_stats_bio(CONF_VALUE,lh,out)\n# define lh_CONF_VALUE_node_usage_stats_bio(lh,out) \\\n  LHM_lh_node_usage_stats_bio(CONF_VALUE,lh,out)\n# define lh_CONF_VALUE_stats_bio(lh,out) \\\n  LHM_lh_stats_bio(CONF_VALUE,lh,out)\n# define lh_CONF_VALUE_free(lh) LHM_lh_free(CONF_VALUE,lh)\n# define lh_ENGINE_PILE_new() LHM_lh_new(ENGINE_PILE,engine_pile)\n# define lh_ENGINE_PILE_insert(lh,inst) LHM_lh_insert(ENGINE_PILE,lh,inst)\n# define lh_ENGINE_PILE_retrieve(lh,inst) LHM_lh_retrieve(ENGINE_PILE,lh,inst)\n# define lh_ENGINE_PILE_delete(lh,inst) LHM_lh_delete(ENGINE_PILE,lh,inst)\n# define lh_ENGINE_PILE_doall(lh,fn) LHM_lh_doall(ENGINE_PILE,lh,fn)\n# define lh_ENGINE_PILE_doall_arg(lh,fn,arg_type,arg) \\\n  LHM_lh_doall_arg(ENGINE_PILE,lh,fn,arg_type,arg)\n# define lh_ENGINE_PILE_error(lh) LHM_lh_error(ENGINE_PILE,lh)\n# define lh_ENGINE_PILE_num_items(lh) LHM_lh_num_items(ENGINE_PILE,lh)\n# define lh_ENGINE_PILE_down_load(lh) LHM_lh_down_load(ENGINE_PILE,lh)\n# define lh_ENGINE_PILE_node_stats_bio(lh,out) \\\n  LHM_lh_node_stats_bio(ENGINE_PILE,lh,out)\n# define lh_ENGINE_PILE_node_usage_stats_bio(lh,out) \\\n  LHM_lh_node_usage_stats_bio(ENGINE_PILE,lh,out)\n# define lh_ENGINE_PILE_stats_bio(lh,out) \\\n  LHM_lh_stats_bio(ENGINE_PILE,lh,out)\n# define lh_ENGINE_PILE_free(lh) LHM_lh_free(ENGINE_PILE,lh)\n# define lh_ERR_STATE_new() LHM_lh_new(ERR_STATE,err_state)\n# define lh_ERR_STATE_insert(lh,inst) LHM_lh_insert(ERR_STATE,lh,inst)\n# define lh_ERR_STATE_retrieve(lh,inst) LHM_lh_retrieve(ERR_STATE,lh,inst)\n# define lh_ERR_STATE_delete(lh,inst) LHM_lh_delete(ERR_STATE,lh,inst)\n# define lh_ERR_STATE_doall(lh,fn) LHM_lh_doall(ERR_STATE,lh,fn)\n# define lh_ERR_STATE_doall_arg(lh,fn,arg_type,arg) \\\n  LHM_lh_doall_arg(ERR_STATE,lh,fn,arg_type,arg)\n# define lh_ERR_STATE_error(lh) LHM_lh_error(ERR_STATE,lh)\n# define lh_ERR_STATE_num_items(lh) LHM_lh_num_items(ERR_STATE,lh)\n# define lh_ERR_STATE_down_load(lh) LHM_lh_down_load(ERR_STATE,lh)\n# define lh_ERR_STATE_node_stats_bio(lh,out) \\\n  LHM_lh_node_stats_bio(ERR_STATE,lh,out)\n# define lh_ERR_STATE_node_usage_stats_bio(lh,out) \\\n  LHM_lh_node_usage_stats_bio(ERR_STATE,lh,out)\n# define lh_ERR_STATE_stats_bio(lh,out) \\\n  LHM_lh_stats_bio(ERR_STATE,lh,out)\n# define lh_ERR_STATE_free(lh) LHM_lh_free(ERR_STATE,lh)\n# define lh_ERR_STRING_DATA_new() LHM_lh_new(ERR_STRING_DATA,err_string_data)\n# define lh_ERR_STRING_DATA_insert(lh,inst) LHM_lh_insert(ERR_STRING_DATA,lh,inst)\n# define lh_ERR_STRING_DATA_retrieve(lh,inst) LHM_lh_retrieve(ERR_STRING_DATA,lh,inst)\n# define lh_ERR_STRING_DATA_delete(lh,inst) LHM_lh_delete(ERR_STRING_DATA,lh,inst)\n# define lh_ERR_STRING_DATA_doall(lh,fn) LHM_lh_doall(ERR_STRING_DATA,lh,fn)\n# define lh_ERR_STRING_DATA_doall_arg(lh,fn,arg_type,arg) \\\n  LHM_lh_doall_arg(ERR_STRING_DATA,lh,fn,arg_type,arg)\n# define lh_ERR_STRING_DATA_error(lh) LHM_lh_error(ERR_STRING_DATA,lh)\n# define lh_ERR_STRING_DATA_num_items(lh) LHM_lh_num_items(ERR_STRING_DATA,lh)\n# define lh_ERR_STRING_DATA_down_load(lh) LHM_lh_down_load(ERR_STRING_DATA,lh)\n# define lh_ERR_STRING_DATA_node_stats_bio(lh,out) \\\n  LHM_lh_node_stats_bio(ERR_STRING_DATA,lh,out)\n# define lh_ERR_STRING_DATA_node_usage_stats_bio(lh,out) \\\n  LHM_lh_node_usage_stats_bio(ERR_STRING_DATA,lh,out)\n# define lh_ERR_STRING_DATA_stats_bio(lh,out) \\\n  LHM_lh_stats_bio(ERR_STRING_DATA,lh,out)\n# define lh_ERR_STRING_DATA_free(lh) LHM_lh_free(ERR_STRING_DATA,lh)\n# define lh_EX_CLASS_ITEM_new() LHM_lh_new(EX_CLASS_ITEM,ex_class_item)\n# define lh_EX_CLASS_ITEM_insert(lh,inst) LHM_lh_insert(EX_CLASS_ITEM,lh,inst)\n# define lh_EX_CLASS_ITEM_retrieve(lh,inst) LHM_lh_retrieve(EX_CLASS_ITEM,lh,inst)\n# define lh_EX_CLASS_ITEM_delete(lh,inst) LHM_lh_delete(EX_CLASS_ITEM,lh,inst)\n# define lh_EX_CLASS_ITEM_doall(lh,fn) LHM_lh_doall(EX_CLASS_ITEM,lh,fn)\n# define lh_EX_CLASS_ITEM_doall_arg(lh,fn,arg_type,arg) \\\n  LHM_lh_doall_arg(EX_CLASS_ITEM,lh,fn,arg_type,arg)\n# define lh_EX_CLASS_ITEM_error(lh) LHM_lh_error(EX_CLASS_ITEM,lh)\n# define lh_EX_CLASS_ITEM_num_items(lh) LHM_lh_num_items(EX_CLASS_ITEM,lh)\n# define lh_EX_CLASS_ITEM_down_load(lh) LHM_lh_down_load(EX_CLASS_ITEM,lh)\n# define lh_EX_CLASS_ITEM_node_stats_bio(lh,out) \\\n  LHM_lh_node_stats_bio(EX_CLASS_ITEM,lh,out)\n# define lh_EX_CLASS_ITEM_node_usage_stats_bio(lh,out) \\\n  LHM_lh_node_usage_stats_bio(EX_CLASS_ITEM,lh,out)\n# define lh_EX_CLASS_ITEM_stats_bio(lh,out) \\\n  LHM_lh_stats_bio(EX_CLASS_ITEM,lh,out)\n# define lh_EX_CLASS_ITEM_free(lh) LHM_lh_free(EX_CLASS_ITEM,lh)\n# define lh_FUNCTION_new() LHM_lh_new(FUNCTION,function)\n# define lh_FUNCTION_insert(lh,inst) LHM_lh_insert(FUNCTION,lh,inst)\n# define lh_FUNCTION_retrieve(lh,inst) LHM_lh_retrieve(FUNCTION,lh,inst)\n# define lh_FUNCTION_delete(lh,inst) LHM_lh_delete(FUNCTION,lh,inst)\n# define lh_FUNCTION_doall(lh,fn) LHM_lh_doall(FUNCTION,lh,fn)\n# define lh_FUNCTION_doall_arg(lh,fn,arg_type,arg) \\\n  LHM_lh_doall_arg(FUNCTION,lh,fn,arg_type,arg)\n# define lh_FUNCTION_error(lh) LHM_lh_error(FUNCTION,lh)\n# define lh_FUNCTION_num_items(lh) LHM_lh_num_items(FUNCTION,lh)\n# define lh_FUNCTION_down_load(lh) LHM_lh_down_load(FUNCTION,lh)\n# define lh_FUNCTION_node_stats_bio(lh,out) \\\n  LHM_lh_node_stats_bio(FUNCTION,lh,out)\n# define lh_FUNCTION_node_usage_stats_bio(lh,out) \\\n  LHM_lh_node_usage_stats_bio(FUNCTION,lh,out)\n# define lh_FUNCTION_stats_bio(lh,out) \\\n  LHM_lh_stats_bio(FUNCTION,lh,out)\n# define lh_FUNCTION_free(lh) LHM_lh_free(FUNCTION,lh)\n# define lh_MEM_new() LHM_lh_new(MEM,mem)\n# define lh_MEM_insert(lh,inst) LHM_lh_insert(MEM,lh,inst)\n# define lh_MEM_retrieve(lh,inst) LHM_lh_retrieve(MEM,lh,inst)\n# define lh_MEM_delete(lh,inst) LHM_lh_delete(MEM,lh,inst)\n# define lh_MEM_doall(lh,fn) LHM_lh_doall(MEM,lh,fn)\n# define lh_MEM_doall_arg(lh,fn,arg_type,arg) \\\n  LHM_lh_doall_arg(MEM,lh,fn,arg_type,arg)\n# define lh_MEM_error(lh) LHM_lh_error(MEM,lh)\n# define lh_MEM_num_items(lh) LHM_lh_num_items(MEM,lh)\n# define lh_MEM_down_load(lh) LHM_lh_down_load(MEM,lh)\n# define lh_MEM_node_stats_bio(lh,out) \\\n  LHM_lh_node_stats_bio(MEM,lh,out)\n# define lh_MEM_node_usage_stats_bio(lh,out) \\\n  LHM_lh_node_usage_stats_bio(MEM,lh,out)\n# define lh_MEM_stats_bio(lh,out) \\\n  LHM_lh_stats_bio(MEM,lh,out)\n# define lh_MEM_free(lh) LHM_lh_free(MEM,lh)\n# define lh_OBJ_NAME_new() LHM_lh_new(OBJ_NAME,obj_name)\n# define lh_OBJ_NAME_insert(lh,inst) LHM_lh_insert(OBJ_NAME,lh,inst)\n# define lh_OBJ_NAME_retrieve(lh,inst) LHM_lh_retrieve(OBJ_NAME,lh,inst)\n# define lh_OBJ_NAME_delete(lh,inst) LHM_lh_delete(OBJ_NAME,lh,inst)\n# define lh_OBJ_NAME_doall(lh,fn) LHM_lh_doall(OBJ_NAME,lh,fn)\n# define lh_OBJ_NAME_doall_arg(lh,fn,arg_type,arg) \\\n  LHM_lh_doall_arg(OBJ_NAME,lh,fn,arg_type,arg)\n# define lh_OBJ_NAME_error(lh) LHM_lh_error(OBJ_NAME,lh)\n# define lh_OBJ_NAME_num_items(lh) LHM_lh_num_items(OBJ_NAME,lh)\n# define lh_OBJ_NAME_down_load(lh) LHM_lh_down_load(OBJ_NAME,lh)\n# define lh_OBJ_NAME_node_stats_bio(lh,out) \\\n  LHM_lh_node_stats_bio(OBJ_NAME,lh,out)\n# define lh_OBJ_NAME_node_usage_stats_bio(lh,out) \\\n  LHM_lh_node_usage_stats_bio(OBJ_NAME,lh,out)\n# define lh_OBJ_NAME_stats_bio(lh,out) \\\n  LHM_lh_stats_bio(OBJ_NAME,lh,out)\n# define lh_OBJ_NAME_free(lh) LHM_lh_free(OBJ_NAME,lh)\n# define lh_OPENSSL_CSTRING_new() LHM_lh_new(OPENSSL_CSTRING,openssl_cstring)\n# define lh_OPENSSL_CSTRING_insert(lh,inst) LHM_lh_insert(OPENSSL_CSTRING,lh,inst)\n# define lh_OPENSSL_CSTRING_retrieve(lh,inst) LHM_lh_retrieve(OPENSSL_CSTRING,lh,inst)\n# define lh_OPENSSL_CSTRING_delete(lh,inst) LHM_lh_delete(OPENSSL_CSTRING,lh,inst)\n# define lh_OPENSSL_CSTRING_doall(lh,fn) LHM_lh_doall(OPENSSL_CSTRING,lh,fn)\n# define lh_OPENSSL_CSTRING_doall_arg(lh,fn,arg_type,arg) \\\n  LHM_lh_doall_arg(OPENSSL_CSTRING,lh,fn,arg_type,arg)\n# define lh_OPENSSL_CSTRING_error(lh) LHM_lh_error(OPENSSL_CSTRING,lh)\n# define lh_OPENSSL_CSTRING_num_items(lh) LHM_lh_num_items(OPENSSL_CSTRING,lh)\n# define lh_OPENSSL_CSTRING_down_load(lh) LHM_lh_down_load(OPENSSL_CSTRING,lh)\n# define lh_OPENSSL_CSTRING_node_stats_bio(lh,out) \\\n  LHM_lh_node_stats_bio(OPENSSL_CSTRING,lh,out)\n# define lh_OPENSSL_CSTRING_node_usage_stats_bio(lh,out) \\\n  LHM_lh_node_usage_stats_bio(OPENSSL_CSTRING,lh,out)\n# define lh_OPENSSL_CSTRING_stats_bio(lh,out) \\\n  LHM_lh_stats_bio(OPENSSL_CSTRING,lh,out)\n# define lh_OPENSSL_CSTRING_free(lh) LHM_lh_free(OPENSSL_CSTRING,lh)\n# define lh_OPENSSL_STRING_new() LHM_lh_new(OPENSSL_STRING,openssl_string)\n# define lh_OPENSSL_STRING_insert(lh,inst) LHM_lh_insert(OPENSSL_STRING,lh,inst)\n# define lh_OPENSSL_STRING_retrieve(lh,inst) LHM_lh_retrieve(OPENSSL_STRING,lh,inst)\n# define lh_OPENSSL_STRING_delete(lh,inst) LHM_lh_delete(OPENSSL_STRING,lh,inst)\n# define lh_OPENSSL_STRING_doall(lh,fn) LHM_lh_doall(OPENSSL_STRING,lh,fn)\n# define lh_OPENSSL_STRING_doall_arg(lh,fn,arg_type,arg) \\\n  LHM_lh_doall_arg(OPENSSL_STRING,lh,fn,arg_type,arg)\n# define lh_OPENSSL_STRING_error(lh) LHM_lh_error(OPENSSL_STRING,lh)\n# define lh_OPENSSL_STRING_num_items(lh) LHM_lh_num_items(OPENSSL_STRING,lh)\n# define lh_OPENSSL_STRING_down_load(lh) LHM_lh_down_load(OPENSSL_STRING,lh)\n# define lh_OPENSSL_STRING_node_stats_bio(lh,out) \\\n  LHM_lh_node_stats_bio(OPENSSL_STRING,lh,out)\n# define lh_OPENSSL_STRING_node_usage_stats_bio(lh,out) \\\n  LHM_lh_node_usage_stats_bio(OPENSSL_STRING,lh,out)\n# define lh_OPENSSL_STRING_stats_bio(lh,out) \\\n  LHM_lh_stats_bio(OPENSSL_STRING,lh,out)\n# define lh_OPENSSL_STRING_free(lh) LHM_lh_free(OPENSSL_STRING,lh)\n# define lh_SSL_SESSION_new() LHM_lh_new(SSL_SESSION,ssl_session)\n# define lh_SSL_SESSION_insert(lh,inst) LHM_lh_insert(SSL_SESSION,lh,inst)\n# define lh_SSL_SESSION_retrieve(lh,inst) LHM_lh_retrieve(SSL_SESSION,lh,inst)\n# define lh_SSL_SESSION_delete(lh,inst) LHM_lh_delete(SSL_SESSION,lh,inst)\n# define lh_SSL_SESSION_doall(lh,fn) LHM_lh_doall(SSL_SESSION,lh,fn)\n# define lh_SSL_SESSION_doall_arg(lh,fn,arg_type,arg) \\\n  LHM_lh_doall_arg(SSL_SESSION,lh,fn,arg_type,arg)\n# define lh_SSL_SESSION_error(lh) LHM_lh_error(SSL_SESSION,lh)\n# define lh_SSL_SESSION_num_items(lh) LHM_lh_num_items(SSL_SESSION,lh)\n# define lh_SSL_SESSION_down_load(lh) LHM_lh_down_load(SSL_SESSION,lh)\n# define lh_SSL_SESSION_node_stats_bio(lh,out) \\\n  LHM_lh_node_stats_bio(SSL_SESSION,lh,out)\n# define lh_SSL_SESSION_node_usage_stats_bio(lh,out) \\\n  LHM_lh_node_usage_stats_bio(SSL_SESSION,lh,out)\n# define lh_SSL_SESSION_stats_bio(lh,out) \\\n  LHM_lh_stats_bio(SSL_SESSION,lh,out)\n# define lh_SSL_SESSION_free(lh) LHM_lh_free(SSL_SESSION,lh)\n#ifdef  __cplusplus\n}\n#endif\n#endif                          /* !defined HEADER_SAFESTACK_H */\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/x86_64/include/openssl/seed.h",
    "content": "/*\n * Copyright (c) 2007 KISA(Korea Information Security Agency). All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n * 2. Neither the name of author nor the names of its contributors may\n *    be used to endorse or promote products derived from this software\n *    without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED.  IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n * SUCH DAMAGE.\n *\n */\n/* ====================================================================\n * Copyright (c) 1998-2007 The OpenSSL Project.  All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n *\n * 1. Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n *\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in\n *    the documentation and/or other materials provided with the\n *    distribution.\n *\n * 3. All advertising materials mentioning features or use of this\n *    software must display the following acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit. (http://www.openssl.org/)\"\n *\n * 4. The names \"OpenSSL Toolkit\" and \"OpenSSL Project\" must not be used to\n *    endorse or promote products derived from this software without\n *    prior written permission. For written permission, please contact\n *    openssl-core@openssl.org.\n *\n * 5. Products derived from this software may not be called \"OpenSSL\"\n *    nor may \"OpenSSL\" appear in their names without prior written\n *    permission of the OpenSSL Project.\n *\n * 6. Redistributions of any form whatsoever must retain the following\n *    acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit (http://www.openssl.org/)\"\n *\n * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY\n * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\n * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR\n * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\n * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,\n * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED\n * OF THE POSSIBILITY OF SUCH DAMAGE.\n * ====================================================================\n *\n * This product includes cryptographic software written by Eric Young\n * (eay@cryptsoft.com).  This product includes software written by Tim\n * Hudson (tjh@cryptsoft.com).\n *\n */\n\n#ifndef HEADER_SEED_H\n# define HEADER_SEED_H\n\n# include <openssl/opensslconf.h>\n# include <openssl/e_os2.h>\n# include <openssl/crypto.h>\n\n# ifdef OPENSSL_NO_SEED\n#  error SEED is disabled.\n# endif\n\n/* look whether we need 'long' to get 32 bits */\n# ifdef AES_LONG\n#  ifndef SEED_LONG\n#   define SEED_LONG 1\n#  endif\n# endif\n\n# if !defined(NO_SYS_TYPES_H)\n#  include <sys/types.h>\n# endif\n\n# define SEED_BLOCK_SIZE 16\n# define SEED_KEY_LENGTH 16\n\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\ntypedef struct seed_key_st {\n# ifdef SEED_LONG\n    unsigned long data[32];\n# else\n    unsigned int data[32];\n# endif\n} SEED_KEY_SCHEDULE;\n\n# ifdef OPENSSL_FIPS\nvoid private_SEED_set_key(const unsigned char rawkey[SEED_KEY_LENGTH],\n                          SEED_KEY_SCHEDULE *ks);\n# endif\nvoid SEED_set_key(const unsigned char rawkey[SEED_KEY_LENGTH],\n                  SEED_KEY_SCHEDULE *ks);\n\nvoid SEED_encrypt(const unsigned char s[SEED_BLOCK_SIZE],\n                  unsigned char d[SEED_BLOCK_SIZE],\n                  const SEED_KEY_SCHEDULE *ks);\nvoid SEED_decrypt(const unsigned char s[SEED_BLOCK_SIZE],\n                  unsigned char d[SEED_BLOCK_SIZE],\n                  const SEED_KEY_SCHEDULE *ks);\n\nvoid SEED_ecb_encrypt(const unsigned char *in, unsigned char *out,\n                      const SEED_KEY_SCHEDULE *ks, int enc);\nvoid SEED_cbc_encrypt(const unsigned char *in, unsigned char *out, size_t len,\n                      const SEED_KEY_SCHEDULE *ks,\n                      unsigned char ivec[SEED_BLOCK_SIZE], int enc);\nvoid SEED_cfb128_encrypt(const unsigned char *in, unsigned char *out,\n                         size_t len, const SEED_KEY_SCHEDULE *ks,\n                         unsigned char ivec[SEED_BLOCK_SIZE], int *num,\n                         int enc);\nvoid SEED_ofb128_encrypt(const unsigned char *in, unsigned char *out,\n                         size_t len, const SEED_KEY_SCHEDULE *ks,\n                         unsigned char ivec[SEED_BLOCK_SIZE], int *num);\n\n#ifdef  __cplusplus\n}\n#endif\n\n#endif                          /* HEADER_SEED_H */\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/x86_64/include/openssl/sha.h",
    "content": "/* crypto/sha/sha.h */\n/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)\n * All rights reserved.\n *\n * This package is an SSL implementation written\n * by Eric Young (eay@cryptsoft.com).\n * The implementation was written so as to conform with Netscapes SSL.\n *\n * This library is free for commercial and non-commercial use as long as\n * the following conditions are aheared to.  The following conditions\n * apply to all code found in this distribution, be it the RC4, RSA,\n * lhash, DES, etc., code; not just the SSL code.  The SSL documentation\n * included with this distribution is covered by the same copyright terms\n * except that the holder is Tim Hudson (tjh@cryptsoft.com).\n *\n * Copyright remains Eric Young's, and as such any Copyright notices in\n * the code are not to be removed.\n * If this package is used in a product, Eric Young should be given attribution\n * as the author of the parts of the library used.\n * This can be in the form of a textual message at program startup or\n * in documentation (online or textual) provided with the package.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the copyright\n *    notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in the\n *    documentation and/or other materials provided with the distribution.\n * 3. All advertising materials mentioning features or use of this software\n *    must display the following acknowledgement:\n *    \"This product includes cryptographic software written by\n *     Eric Young (eay@cryptsoft.com)\"\n *    The word 'cryptographic' can be left out if the rouines from the library\n *    being used are not cryptographic related :-).\n * 4. If you include any Windows specific code (or a derivative thereof) from\n *    the apps directory (application code) you must include an acknowledgement:\n *    \"This product includes software written by Tim Hudson (tjh@cryptsoft.com)\"\n *\n * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n * SUCH DAMAGE.\n *\n * The licence and distribution terms for any publically available version or\n * derivative of this code cannot be changed.  i.e. this code cannot simply be\n * copied and put under another distribution licence\n * [including the GNU Public Licence.]\n */\n\n#ifndef HEADER_SHA_H\n# define HEADER_SHA_H\n\n# include <openssl/e_os2.h>\n# include <stddef.h>\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n# if defined(OPENSSL_NO_SHA) || (defined(OPENSSL_NO_SHA0) && defined(OPENSSL_NO_SHA1))\n#  error SHA is disabled.\n# endif\n\n# if defined(OPENSSL_FIPS)\n#  define FIPS_SHA_SIZE_T size_t\n# endif\n\n/*-\n * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n * ! SHA_LONG has to be at least 32 bits wide. If it's wider, then !\n * ! SHA_LONG_LOG2 has to be defined along.                        !\n * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n */\n\n# if defined(__LP32__)\n#  define SHA_LONG unsigned long\n# elif defined(OPENSSL_SYS_CRAY) || defined(__ILP64__)\n#  define SHA_LONG unsigned long\n#  define SHA_LONG_LOG2 3\n# else\n#  define SHA_LONG unsigned int\n# endif\n\n# define SHA_LBLOCK      16\n# define SHA_CBLOCK      (SHA_LBLOCK*4)/* SHA treats input data as a\n                                        * contiguous array of 32 bit wide\n                                        * big-endian values. */\n# define SHA_LAST_BLOCK  (SHA_CBLOCK-8)\n# define SHA_DIGEST_LENGTH 20\n\ntypedef struct SHAstate_st {\n    SHA_LONG h0, h1, h2, h3, h4;\n    SHA_LONG Nl, Nh;\n    SHA_LONG data[SHA_LBLOCK];\n    unsigned int num;\n} SHA_CTX;\n\n# ifndef OPENSSL_NO_SHA0\n#  ifdef OPENSSL_FIPS\nint private_SHA_Init(SHA_CTX *c);\n#  endif\nint SHA_Init(SHA_CTX *c);\nint SHA_Update(SHA_CTX *c, const void *data, size_t len);\nint SHA_Final(unsigned char *md, SHA_CTX *c);\nunsigned char *SHA(const unsigned char *d, size_t n, unsigned char *md);\nvoid SHA_Transform(SHA_CTX *c, const unsigned char *data);\n# endif\n# ifndef OPENSSL_NO_SHA1\n#  ifdef OPENSSL_FIPS\nint private_SHA1_Init(SHA_CTX *c);\n#  endif\nint SHA1_Init(SHA_CTX *c);\nint SHA1_Update(SHA_CTX *c, const void *data, size_t len);\nint SHA1_Final(unsigned char *md, SHA_CTX *c);\nunsigned char *SHA1(const unsigned char *d, size_t n, unsigned char *md);\nvoid SHA1_Transform(SHA_CTX *c, const unsigned char *data);\n# endif\n\n# define SHA256_CBLOCK   (SHA_LBLOCK*4)/* SHA-256 treats input data as a\n                                        * contiguous array of 32 bit wide\n                                        * big-endian values. */\n# define SHA224_DIGEST_LENGTH    28\n# define SHA256_DIGEST_LENGTH    32\n\ntypedef struct SHA256state_st {\n    SHA_LONG h[8];\n    SHA_LONG Nl, Nh;\n    SHA_LONG data[SHA_LBLOCK];\n    unsigned int num, md_len;\n} SHA256_CTX;\n\n# ifndef OPENSSL_NO_SHA256\n#  ifdef OPENSSL_FIPS\nint private_SHA224_Init(SHA256_CTX *c);\nint private_SHA256_Init(SHA256_CTX *c);\n#  endif\nint SHA224_Init(SHA256_CTX *c);\nint SHA224_Update(SHA256_CTX *c, const void *data, size_t len);\nint SHA224_Final(unsigned char *md, SHA256_CTX *c);\nunsigned char *SHA224(const unsigned char *d, size_t n, unsigned char *md);\nint SHA256_Init(SHA256_CTX *c);\nint SHA256_Update(SHA256_CTX *c, const void *data, size_t len);\nint SHA256_Final(unsigned char *md, SHA256_CTX *c);\nunsigned char *SHA256(const unsigned char *d, size_t n, unsigned char *md);\nvoid SHA256_Transform(SHA256_CTX *c, const unsigned char *data);\n# endif\n\n# define SHA384_DIGEST_LENGTH    48\n# define SHA512_DIGEST_LENGTH    64\n\n# ifndef OPENSSL_NO_SHA512\n/*\n * Unlike 32-bit digest algorithms, SHA-512 *relies* on SHA_LONG64\n * being exactly 64-bit wide. See Implementation Notes in sha512.c\n * for further details.\n */\n/*\n * SHA-512 treats input data as a\n * contiguous array of 64 bit\n * wide big-endian values.\n */\n#  define SHA512_CBLOCK   (SHA_LBLOCK*8)\n#  if (defined(_WIN32) || defined(_WIN64)) && !defined(__MINGW32__)\n#   define SHA_LONG64 unsigned __int64\n#   define U64(C)     C##UI64\n#  elif defined(__arch64__)\n#   define SHA_LONG64 unsigned long\n#   define U64(C)     C##UL\n#  else\n#   define SHA_LONG64 unsigned long long\n#   define U64(C)     C##ULL\n#  endif\n\ntypedef struct SHA512state_st {\n    SHA_LONG64 h[8];\n    SHA_LONG64 Nl, Nh;\n    union {\n        SHA_LONG64 d[SHA_LBLOCK];\n        unsigned char p[SHA512_CBLOCK];\n    } u;\n    unsigned int num, md_len;\n} SHA512_CTX;\n# endif\n\n# ifndef OPENSSL_NO_SHA512\n#  ifdef OPENSSL_FIPS\nint private_SHA384_Init(SHA512_CTX *c);\nint private_SHA512_Init(SHA512_CTX *c);\n#  endif\nint SHA384_Init(SHA512_CTX *c);\nint SHA384_Update(SHA512_CTX *c, const void *data, size_t len);\nint SHA384_Final(unsigned char *md, SHA512_CTX *c);\nunsigned char *SHA384(const unsigned char *d, size_t n, unsigned char *md);\nint SHA512_Init(SHA512_CTX *c);\nint SHA512_Update(SHA512_CTX *c, const void *data, size_t len);\nint SHA512_Final(unsigned char *md, SHA512_CTX *c);\nunsigned char *SHA512(const unsigned char *d, size_t n, unsigned char *md);\nvoid SHA512_Transform(SHA512_CTX *c, const unsigned char *data);\n# endif\n\n#ifdef  __cplusplus\n}\n#endif\n\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/x86_64/include/openssl/srp.h",
    "content": "/* crypto/srp/srp.h */\n/*\n * Written by Christophe Renou (christophe.renou@edelweb.fr) with the\n * precious help of Peter Sylvester (peter.sylvester@edelweb.fr) for the\n * EdelKey project and contributed to the OpenSSL project 2004.\n */\n/* ====================================================================\n * Copyright (c) 2004 The OpenSSL Project.  All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n *\n * 1. Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n *\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in\n *    the documentation and/or other materials provided with the\n *    distribution.\n *\n * 3. All advertising materials mentioning features or use of this\n *    software must display the following acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)\"\n *\n * 4. The names \"OpenSSL Toolkit\" and \"OpenSSL Project\" must not be used to\n *    endorse or promote products derived from this software without\n *    prior written permission. For written permission, please contact\n *    licensing@OpenSSL.org.\n *\n * 5. Products derived from this software may not be called \"OpenSSL\"\n *    nor may \"OpenSSL\" appear in their names without prior written\n *    permission of the OpenSSL Project.\n *\n * 6. Redistributions of any form whatsoever must retain the following\n *    acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)\"\n *\n * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY\n * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\n * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR\n * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\n * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,\n * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED\n * OF THE POSSIBILITY OF SUCH DAMAGE.\n * ====================================================================\n *\n * This product includes cryptographic software written by Eric Young\n * (eay@cryptsoft.com).  This product includes software written by Tim\n * Hudson (tjh@cryptsoft.com).\n *\n */\n#ifndef __SRP_H__\n# define __SRP_H__\n\n# ifndef OPENSSL_NO_SRP\n\n#  include <stdio.h>\n#  include <string.h>\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n#  include <openssl/safestack.h>\n#  include <openssl/bn.h>\n#  include <openssl/crypto.h>\n\ntypedef struct SRP_gN_cache_st {\n    char *b64_bn;\n    BIGNUM *bn;\n} SRP_gN_cache;\n\n\nDECLARE_STACK_OF(SRP_gN_cache)\n\ntypedef struct SRP_user_pwd_st {\n    /* Owned by us. */\n    char *id;\n    BIGNUM *s;\n    BIGNUM *v;\n    /* Not owned by us. */\n    const BIGNUM *g;\n    const BIGNUM *N;\n    /* Owned by us. */\n    char *info;\n} SRP_user_pwd;\n\nDECLARE_STACK_OF(SRP_user_pwd)\n\nvoid SRP_user_pwd_free(SRP_user_pwd *user_pwd);\n\ntypedef struct SRP_VBASE_st {\n    STACK_OF(SRP_user_pwd) *users_pwd;\n    STACK_OF(SRP_gN_cache) *gN_cache;\n/* to simulate a user */\n    char *seed_key;\n    BIGNUM *default_g;\n    BIGNUM *default_N;\n} SRP_VBASE;\n\n/*\n * Structure interne pour retenir les couples N et g\n */\ntypedef struct SRP_gN_st {\n    char *id;\n    BIGNUM *g;\n    BIGNUM *N;\n} SRP_gN;\n\nDECLARE_STACK_OF(SRP_gN)\n\nSRP_VBASE *SRP_VBASE_new(char *seed_key);\nint SRP_VBASE_free(SRP_VBASE *vb);\nint SRP_VBASE_init(SRP_VBASE *vb, char *verifier_file);\n\n/* This method ignores the configured seed and fails for an unknown user. */\nSRP_user_pwd *SRP_VBASE_get_by_user(SRP_VBASE *vb, char *username);\n/* NOTE: unlike in SRP_VBASE_get_by_user, caller owns the returned pointer.*/\nSRP_user_pwd *SRP_VBASE_get1_by_user(SRP_VBASE *vb, char *username);\n\nchar *SRP_create_verifier(const char *user, const char *pass, char **salt,\n                          char **verifier, const char *N, const char *g);\nint SRP_create_verifier_BN(const char *user, const char *pass, BIGNUM **salt,\n                           BIGNUM **verifier, BIGNUM *N, BIGNUM *g);\n\n#  define SRP_NO_ERROR 0\n#  define SRP_ERR_VBASE_INCOMPLETE_FILE 1\n#  define SRP_ERR_VBASE_BN_LIB 2\n#  define SRP_ERR_OPEN_FILE 3\n#  define SRP_ERR_MEMORY 4\n\n#  define DB_srptype      0\n#  define DB_srpverifier  1\n#  define DB_srpsalt      2\n#  define DB_srpid        3\n#  define DB_srpgN        4\n#  define DB_srpinfo      5\n#  undef  DB_NUMBER\n#  define DB_NUMBER       6\n\n#  define DB_SRP_INDEX    'I'\n#  define DB_SRP_VALID    'V'\n#  define DB_SRP_REVOKED  'R'\n#  define DB_SRP_MODIF    'v'\n\n/* see srp.c */\nchar *SRP_check_known_gN_param(BIGNUM *g, BIGNUM *N);\nSRP_gN *SRP_get_default_gN(const char *id);\n\n/* server side .... */\nBIGNUM *SRP_Calc_server_key(BIGNUM *A, BIGNUM *v, BIGNUM *u, BIGNUM *b,\n                            BIGNUM *N);\nBIGNUM *SRP_Calc_B(BIGNUM *b, BIGNUM *N, BIGNUM *g, BIGNUM *v);\nint SRP_Verify_A_mod_N(BIGNUM *A, BIGNUM *N);\nBIGNUM *SRP_Calc_u(BIGNUM *A, BIGNUM *B, BIGNUM *N);\n\n/* client side .... */\nBIGNUM *SRP_Calc_x(BIGNUM *s, const char *user, const char *pass);\nBIGNUM *SRP_Calc_A(BIGNUM *a, BIGNUM *N, BIGNUM *g);\nBIGNUM *SRP_Calc_client_key(BIGNUM *N, BIGNUM *B, BIGNUM *g, BIGNUM *x,\n                            BIGNUM *a, BIGNUM *u);\nint SRP_Verify_B_mod_N(BIGNUM *B, BIGNUM *N);\n\n#  define SRP_MINIMAL_N 1024\n\n#ifdef  __cplusplus\n}\n#endif\n\n# endif\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/x86_64/include/openssl/stack.h",
    "content": "/* crypto/stack/stack.h */\n/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)\n * All rights reserved.\n *\n * This package is an SSL implementation written\n * by Eric Young (eay@cryptsoft.com).\n * The implementation was written so as to conform with Netscapes SSL.\n *\n * This library is free for commercial and non-commercial use as long as\n * the following conditions are aheared to.  The following conditions\n * apply to all code found in this distribution, be it the RC4, RSA,\n * lhash, DES, etc., code; not just the SSL code.  The SSL documentation\n * included with this distribution is covered by the same copyright terms\n * except that the holder is Tim Hudson (tjh@cryptsoft.com).\n *\n * Copyright remains Eric Young's, and as such any Copyright notices in\n * the code are not to be removed.\n * If this package is used in a product, Eric Young should be given attribution\n * as the author of the parts of the library used.\n * This can be in the form of a textual message at program startup or\n * in documentation (online or textual) provided with the package.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the copyright\n *    notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in the\n *    documentation and/or other materials provided with the distribution.\n * 3. All advertising materials mentioning features or use of this software\n *    must display the following acknowledgement:\n *    \"This product includes cryptographic software written by\n *     Eric Young (eay@cryptsoft.com)\"\n *    The word 'cryptographic' can be left out if the rouines from the library\n *    being used are not cryptographic related :-).\n * 4. If you include any Windows specific code (or a derivative thereof) from\n *    the apps directory (application code) you must include an acknowledgement:\n *    \"This product includes software written by Tim Hudson (tjh@cryptsoft.com)\"\n *\n * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n * SUCH DAMAGE.\n *\n * The licence and distribution terms for any publically available version or\n * derivative of this code cannot be changed.  i.e. this code cannot simply be\n * copied and put under another distribution licence\n * [including the GNU Public Licence.]\n */\n\n#ifndef HEADER_STACK_H\n# define HEADER_STACK_H\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\ntypedef struct stack_st {\n    int num;\n    char **data;\n    int sorted;\n    int num_alloc;\n    int (*comp) (const void *, const void *);\n} _STACK;                       /* Use STACK_OF(...) instead */\n\n# define M_sk_num(sk)            ((sk) ? (sk)->num:-1)\n# define M_sk_value(sk,n)        ((sk) ? (sk)->data[n] : NULL)\n\nint sk_num(const _STACK *);\nvoid *sk_value(const _STACK *, int);\n\nvoid *sk_set(_STACK *, int, void *);\n\n_STACK *sk_new(int (*cmp) (const void *, const void *));\n_STACK *sk_new_null(void);\nvoid sk_free(_STACK *);\nvoid sk_pop_free(_STACK *st, void (*func) (void *));\n_STACK *sk_deep_copy(_STACK *, void *(*)(void *), void (*)(void *));\nint sk_insert(_STACK *sk, void *data, int where);\nvoid *sk_delete(_STACK *st, int loc);\nvoid *sk_delete_ptr(_STACK *st, void *p);\nint sk_find(_STACK *st, void *data);\nint sk_find_ex(_STACK *st, void *data);\nint sk_push(_STACK *st, void *data);\nint sk_unshift(_STACK *st, void *data);\nvoid *sk_shift(_STACK *st);\nvoid *sk_pop(_STACK *st);\nvoid sk_zero(_STACK *st);\nint (*sk_set_cmp_func(_STACK *sk, int (*c) (const void *, const void *)))\n (const void *, const void *);\n_STACK *sk_dup(_STACK *st);\nvoid sk_sort(_STACK *st);\nint sk_is_sorted(const _STACK *st);\n\n#ifdef  __cplusplus\n}\n#endif\n\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/x86_64/include/openssl/symhacks.h",
    "content": "/* ====================================================================\n * Copyright (c) 1999 The OpenSSL Project.  All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n *\n * 1. Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n *\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in\n *    the documentation and/or other materials provided with the\n *    distribution.\n *\n * 3. All advertising materials mentioning features or use of this\n *    software must display the following acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit. (http://www.openssl.org/)\"\n *\n * 4. The names \"OpenSSL Toolkit\" and \"OpenSSL Project\" must not be used to\n *    endorse or promote products derived from this software without\n *    prior written permission. For written permission, please contact\n *    openssl-core@openssl.org.\n *\n * 5. Products derived from this software may not be called \"OpenSSL\"\n *    nor may \"OpenSSL\" appear in their names without prior written\n *    permission of the OpenSSL Project.\n *\n * 6. Redistributions of any form whatsoever must retain the following\n *    acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit (http://www.openssl.org/)\"\n *\n * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY\n * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\n * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR\n * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\n * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,\n * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED\n * OF THE POSSIBILITY OF SUCH DAMAGE.\n * ====================================================================\n *\n * This product includes cryptographic software written by Eric Young\n * (eay@cryptsoft.com).  This product includes software written by Tim\n * Hudson (tjh@cryptsoft.com).\n *\n */\n\n#ifndef HEADER_SYMHACKS_H\n# define HEADER_SYMHACKS_H\n\n# include <openssl/e_os2.h>\n\n/*\n * Hacks to solve the problem with linkers incapable of handling very long\n * symbol names.  In the case of VMS, the limit is 31 characters on VMS for\n * VAX.\n */\n/*\n * Note that this affects util/libeay.num and util/ssleay.num...  you may\n * change those manually, but that's not recommended, as those files are\n * controlled centrally and updated on Unix, and the central definition may\n * disagree with yours, which in turn may come with shareable library\n * incompatibilities.\n */\n# ifdef OPENSSL_SYS_VMS\n\n/* Hack a long name in crypto/ex_data.c */\n#  undef CRYPTO_get_ex_data_implementation\n#  define CRYPTO_get_ex_data_implementation       CRYPTO_get_ex_data_impl\n#  undef CRYPTO_set_ex_data_implementation\n#  define CRYPTO_set_ex_data_implementation       CRYPTO_set_ex_data_impl\n\n/* Hack a long name in crypto/asn1/a_mbstr.c */\n#  undef ASN1_STRING_set_default_mask_asc\n#  define ASN1_STRING_set_default_mask_asc        ASN1_STRING_set_def_mask_asc\n\n#  if 0                         /* No longer needed, since safestack macro\n                                 * magic does the job */\n/* Hack the names created with DECLARE_ASN1_SET_OF(PKCS7_SIGNER_INFO) */\n#   undef i2d_ASN1_SET_OF_PKCS7_SIGNER_INFO\n#   define i2d_ASN1_SET_OF_PKCS7_SIGNER_INFO       i2d_ASN1_SET_OF_PKCS7_SIGINF\n#   undef d2i_ASN1_SET_OF_PKCS7_SIGNER_INFO\n#   define d2i_ASN1_SET_OF_PKCS7_SIGNER_INFO       d2i_ASN1_SET_OF_PKCS7_SIGINF\n#  endif\n\n#  if 0                         /* No longer needed, since safestack macro\n                                 * magic does the job */\n/* Hack the names created with DECLARE_ASN1_SET_OF(PKCS7_RECIP_INFO) */\n#   undef i2d_ASN1_SET_OF_PKCS7_RECIP_INFO\n#   define i2d_ASN1_SET_OF_PKCS7_RECIP_INFO        i2d_ASN1_SET_OF_PKCS7_RECINF\n#   undef d2i_ASN1_SET_OF_PKCS7_RECIP_INFO\n#   define d2i_ASN1_SET_OF_PKCS7_RECIP_INFO        d2i_ASN1_SET_OF_PKCS7_RECINF\n#  endif\n\n#  if 0                         /* No longer needed, since safestack macro\n                                 * magic does the job */\n/* Hack the names created with DECLARE_ASN1_SET_OF(ACCESS_DESCRIPTION) */\n#   undef i2d_ASN1_SET_OF_ACCESS_DESCRIPTION\n#   define i2d_ASN1_SET_OF_ACCESS_DESCRIPTION      i2d_ASN1_SET_OF_ACC_DESC\n#   undef d2i_ASN1_SET_OF_ACCESS_DESCRIPTION\n#   define d2i_ASN1_SET_OF_ACCESS_DESCRIPTION      d2i_ASN1_SET_OF_ACC_DESC\n#  endif\n\n/* Hack the names created with DECLARE_PEM_rw(NETSCAPE_CERT_SEQUENCE) */\n#  undef PEM_read_NETSCAPE_CERT_SEQUENCE\n#  define PEM_read_NETSCAPE_CERT_SEQUENCE         PEM_read_NS_CERT_SEQ\n#  undef PEM_write_NETSCAPE_CERT_SEQUENCE\n#  define PEM_write_NETSCAPE_CERT_SEQUENCE        PEM_write_NS_CERT_SEQ\n#  undef PEM_read_bio_NETSCAPE_CERT_SEQUENCE\n#  define PEM_read_bio_NETSCAPE_CERT_SEQUENCE     PEM_read_bio_NS_CERT_SEQ\n#  undef PEM_write_bio_NETSCAPE_CERT_SEQUENCE\n#  define PEM_write_bio_NETSCAPE_CERT_SEQUENCE    PEM_write_bio_NS_CERT_SEQ\n#  undef PEM_write_cb_bio_NETSCAPE_CERT_SEQUENCE\n#  define PEM_write_cb_bio_NETSCAPE_CERT_SEQUENCE PEM_write_cb_bio_NS_CERT_SEQ\n\n/* Hack the names created with DECLARE_PEM_rw(PKCS8_PRIV_KEY_INFO) */\n#  undef PEM_read_PKCS8_PRIV_KEY_INFO\n#  define PEM_read_PKCS8_PRIV_KEY_INFO            PEM_read_P8_PRIV_KEY_INFO\n#  undef PEM_write_PKCS8_PRIV_KEY_INFO\n#  define PEM_write_PKCS8_PRIV_KEY_INFO           PEM_write_P8_PRIV_KEY_INFO\n#  undef PEM_read_bio_PKCS8_PRIV_KEY_INFO\n#  define PEM_read_bio_PKCS8_PRIV_KEY_INFO        PEM_read_bio_P8_PRIV_KEY_INFO\n#  undef PEM_write_bio_PKCS8_PRIV_KEY_INFO\n#  define PEM_write_bio_PKCS8_PRIV_KEY_INFO       PEM_write_bio_P8_PRIV_KEY_INFO\n#  undef PEM_write_cb_bio_PKCS8_PRIV_KEY_INFO\n#  define PEM_write_cb_bio_PKCS8_PRIV_KEY_INFO    PEM_wrt_cb_bio_P8_PRIV_KEY_INFO\n\n/* Hack other PEM names */\n#  undef PEM_write_bio_PKCS8PrivateKey_nid\n#  define PEM_write_bio_PKCS8PrivateKey_nid       PEM_write_bio_PKCS8PrivKey_nid\n\n/* Hack some long X509 names */\n#  undef X509_REVOKED_get_ext_by_critical\n#  define X509_REVOKED_get_ext_by_critical        X509_REVOKED_get_ext_by_critic\n#  undef X509_policy_tree_get0_user_policies\n#  define X509_policy_tree_get0_user_policies     X509_pcy_tree_get0_usr_policies\n#  undef X509_policy_node_get0_qualifiers\n#  define X509_policy_node_get0_qualifiers        X509_pcy_node_get0_qualifiers\n#  undef X509_STORE_CTX_get_explicit_policy\n#  define X509_STORE_CTX_get_explicit_policy      X509_STORE_CTX_get_expl_policy\n#  undef X509_STORE_CTX_get0_current_issuer\n#  define X509_STORE_CTX_get0_current_issuer      X509_STORE_CTX_get0_cur_issuer\n\n/* Hack some long CRYPTO names */\n#  undef CRYPTO_set_dynlock_destroy_callback\n#  define CRYPTO_set_dynlock_destroy_callback     CRYPTO_set_dynlock_destroy_cb\n#  undef CRYPTO_set_dynlock_create_callback\n#  define CRYPTO_set_dynlock_create_callback      CRYPTO_set_dynlock_create_cb\n#  undef CRYPTO_set_dynlock_lock_callback\n#  define CRYPTO_set_dynlock_lock_callback        CRYPTO_set_dynlock_lock_cb\n#  undef CRYPTO_get_dynlock_lock_callback\n#  define CRYPTO_get_dynlock_lock_callback        CRYPTO_get_dynlock_lock_cb\n#  undef CRYPTO_get_dynlock_destroy_callback\n#  define CRYPTO_get_dynlock_destroy_callback     CRYPTO_get_dynlock_destroy_cb\n#  undef CRYPTO_get_dynlock_create_callback\n#  define CRYPTO_get_dynlock_create_callback      CRYPTO_get_dynlock_create_cb\n#  undef CRYPTO_set_locked_mem_ex_functions\n#  define CRYPTO_set_locked_mem_ex_functions      CRYPTO_set_locked_mem_ex_funcs\n#  undef CRYPTO_get_locked_mem_ex_functions\n#  define CRYPTO_get_locked_mem_ex_functions      CRYPTO_get_locked_mem_ex_funcs\n\n/* Hack some long SSL/TLS names */\n#  undef SSL_CTX_set_default_verify_paths\n#  define SSL_CTX_set_default_verify_paths        SSL_CTX_set_def_verify_paths\n#  undef SSL_get_ex_data_X509_STORE_CTX_idx\n#  define SSL_get_ex_data_X509_STORE_CTX_idx      SSL_get_ex_d_X509_STORE_CTX_idx\n#  undef SSL_add_file_cert_subjects_to_stack\n#  define SSL_add_file_cert_subjects_to_stack     SSL_add_file_cert_subjs_to_stk\n#  undef SSL_add_dir_cert_subjects_to_stack\n#  define SSL_add_dir_cert_subjects_to_stack      SSL_add_dir_cert_subjs_to_stk\n#  undef SSL_CTX_use_certificate_chain_file\n#  define SSL_CTX_use_certificate_chain_file      SSL_CTX_use_cert_chain_file\n#  undef SSL_CTX_set_cert_verify_callback\n#  define SSL_CTX_set_cert_verify_callback        SSL_CTX_set_cert_verify_cb\n#  undef SSL_CTX_set_default_passwd_cb_userdata\n#  define SSL_CTX_set_default_passwd_cb_userdata  SSL_CTX_set_def_passwd_cb_ud\n#  undef SSL_COMP_get_compression_methods\n#  define SSL_COMP_get_compression_methods        SSL_COMP_get_compress_methods\n#  undef SSL_COMP_set0_compression_methods\n#  define SSL_COMP_set0_compression_methods       SSL_COMP_set0_compress_methods\n#  undef SSL_COMP_free_compression_methods\n#  define SSL_COMP_free_compression_methods       SSL_COMP_free_compress_methods\n#  undef ssl_add_clienthello_renegotiate_ext\n#  define ssl_add_clienthello_renegotiate_ext     ssl_add_clienthello_reneg_ext\n#  undef ssl_add_serverhello_renegotiate_ext\n#  define ssl_add_serverhello_renegotiate_ext     ssl_add_serverhello_reneg_ext\n#  undef ssl_parse_clienthello_renegotiate_ext\n#  define ssl_parse_clienthello_renegotiate_ext   ssl_parse_clienthello_reneg_ext\n#  undef ssl_parse_serverhello_renegotiate_ext\n#  define ssl_parse_serverhello_renegotiate_ext   ssl_parse_serverhello_reneg_ext\n#  undef SSL_srp_server_param_with_username\n#  define SSL_srp_server_param_with_username      SSL_srp_server_param_with_un\n#  undef SSL_CTX_set_srp_client_pwd_callback\n#  define SSL_CTX_set_srp_client_pwd_callback     SSL_CTX_set_srp_client_pwd_cb\n#  undef SSL_CTX_set_srp_verify_param_callback\n#  define SSL_CTX_set_srp_verify_param_callback   SSL_CTX_set_srp_vfy_param_cb\n#  undef SSL_CTX_set_srp_username_callback\n#  define SSL_CTX_set_srp_username_callback       SSL_CTX_set_srp_un_cb\n#  undef ssl_add_clienthello_use_srtp_ext\n#  define ssl_add_clienthello_use_srtp_ext        ssl_add_clihello_use_srtp_ext\n#  undef ssl_add_serverhello_use_srtp_ext\n#  define ssl_add_serverhello_use_srtp_ext        ssl_add_serhello_use_srtp_ext\n#  undef ssl_parse_clienthello_use_srtp_ext\n#  define ssl_parse_clienthello_use_srtp_ext      ssl_parse_clihello_use_srtp_ext\n#  undef ssl_parse_serverhello_use_srtp_ext\n#  define ssl_parse_serverhello_use_srtp_ext      ssl_parse_serhello_use_srtp_ext\n#  undef SSL_CTX_set_next_protos_advertised_cb\n#  define SSL_CTX_set_next_protos_advertised_cb   SSL_CTX_set_next_protos_adv_cb\n#  undef SSL_CTX_set_next_proto_select_cb\n#  define SSL_CTX_set_next_proto_select_cb        SSL_CTX_set_next_proto_sel_cb\n\n#  undef tls1_send_server_supplemental_data\n#  define tls1_send_server_supplemental_data      tls1_send_server_suppl_data\n#  undef tls1_send_client_supplemental_data\n#  define tls1_send_client_supplemental_data      tls1_send_client_suppl_data\n#  undef tls1_get_server_supplemental_data\n#  define tls1_get_server_supplemental_data       tls1_get_server_suppl_data\n#  undef tls1_get_client_supplemental_data\n#  define tls1_get_client_supplemental_data       tls1_get_client_suppl_data\n\n#  undef ssl3_cbc_record_digest_supported\n#  define ssl3_cbc_record_digest_supported        ssl3_cbc_record_digest_support\n#  undef ssl_check_clienthello_tlsext_late\n#  define ssl_check_clienthello_tlsext_late       ssl_check_clihello_tlsext_late\n#  undef ssl_check_clienthello_tlsext_early\n#  define ssl_check_clienthello_tlsext_early      ssl_check_clihello_tlsext_early\n\n/* Hack some RSA long names */\n#  undef RSA_padding_check_PKCS1_OAEP_mgf1\n#  define RSA_padding_check_PKCS1_OAEP_mgf1       RSA_pad_check_PKCS1_OAEP_mgf1\n\n/* Hack some ENGINE long names */\n#  undef ENGINE_get_default_BN_mod_exp_crt\n#  define ENGINE_get_default_BN_mod_exp_crt       ENGINE_get_def_BN_mod_exp_crt\n#  undef ENGINE_set_default_BN_mod_exp_crt\n#  define ENGINE_set_default_BN_mod_exp_crt       ENGINE_set_def_BN_mod_exp_crt\n#  undef ENGINE_set_load_privkey_function\n#  define ENGINE_set_load_privkey_function        ENGINE_set_load_privkey_fn\n#  undef ENGINE_get_load_privkey_function\n#  define ENGINE_get_load_privkey_function        ENGINE_get_load_privkey_fn\n#  undef ENGINE_unregister_pkey_asn1_meths\n#  define ENGINE_unregister_pkey_asn1_meths       ENGINE_unreg_pkey_asn1_meths\n#  undef ENGINE_register_all_pkey_asn1_meths\n#  define ENGINE_register_all_pkey_asn1_meths     ENGINE_reg_all_pkey_asn1_meths\n#  undef ENGINE_set_default_pkey_asn1_meths\n#  define ENGINE_set_default_pkey_asn1_meths      ENGINE_set_def_pkey_asn1_meths\n#  undef ENGINE_get_pkey_asn1_meth_engine\n#  define ENGINE_get_pkey_asn1_meth_engine        ENGINE_get_pkey_asn1_meth_eng\n#  undef ENGINE_set_load_ssl_client_cert_function\n#  define ENGINE_set_load_ssl_client_cert_function \\\n                                                ENGINE_set_ld_ssl_clnt_cert_fn\n#  undef ENGINE_get_ssl_client_cert_function\n#  define ENGINE_get_ssl_client_cert_function     ENGINE_get_ssl_client_cert_fn\n\n/* Hack some long OCSP names */\n#  undef OCSP_REQUEST_get_ext_by_critical\n#  define OCSP_REQUEST_get_ext_by_critical        OCSP_REQUEST_get_ext_by_crit\n#  undef OCSP_BASICRESP_get_ext_by_critical\n#  define OCSP_BASICRESP_get_ext_by_critical      OCSP_BASICRESP_get_ext_by_crit\n#  undef OCSP_SINGLERESP_get_ext_by_critical\n#  define OCSP_SINGLERESP_get_ext_by_critical     OCSP_SINGLERESP_get_ext_by_crit\n\n/* Hack some long DES names */\n#  undef _ossl_old_des_ede3_cfb64_encrypt\n#  define _ossl_old_des_ede3_cfb64_encrypt        _ossl_odes_ede3_cfb64_encrypt\n#  undef _ossl_old_des_ede3_ofb64_encrypt\n#  define _ossl_old_des_ede3_ofb64_encrypt        _ossl_odes_ede3_ofb64_encrypt\n\n/* Hack some long EVP names */\n#  undef OPENSSL_add_all_algorithms_noconf\n#  define OPENSSL_add_all_algorithms_noconf       OPENSSL_add_all_algo_noconf\n#  undef OPENSSL_add_all_algorithms_conf\n#  define OPENSSL_add_all_algorithms_conf         OPENSSL_add_all_algo_conf\n#  undef EVP_PKEY_meth_set_verify_recover\n#  define EVP_PKEY_meth_set_verify_recover        EVP_PKEY_meth_set_vrfy_recover\n\n/* Hack some long EC names */\n#  undef EC_GROUP_set_point_conversion_form\n#  define EC_GROUP_set_point_conversion_form      EC_GROUP_set_point_conv_form\n#  undef EC_GROUP_get_point_conversion_form\n#  define EC_GROUP_get_point_conversion_form      EC_GROUP_get_point_conv_form\n#  undef EC_GROUP_clear_free_all_extra_data\n#  define EC_GROUP_clear_free_all_extra_data      EC_GROUP_clr_free_all_xtra_data\n#  undef EC_KEY_set_public_key_affine_coordinates\n#  define EC_KEY_set_public_key_affine_coordinates \\\n                                                EC_KEY_set_pub_key_aff_coords\n#  undef EC_POINT_set_Jprojective_coordinates_GFp\n#  define EC_POINT_set_Jprojective_coordinates_GFp \\\n                                                EC_POINT_set_Jproj_coords_GFp\n#  undef EC_POINT_get_Jprojective_coordinates_GFp\n#  define EC_POINT_get_Jprojective_coordinates_GFp \\\n                                                EC_POINT_get_Jproj_coords_GFp\n#  undef EC_POINT_set_affine_coordinates_GFp\n#  define EC_POINT_set_affine_coordinates_GFp     EC_POINT_set_affine_coords_GFp\n#  undef EC_POINT_get_affine_coordinates_GFp\n#  define EC_POINT_get_affine_coordinates_GFp     EC_POINT_get_affine_coords_GFp\n#  undef EC_POINT_set_compressed_coordinates_GFp\n#  define EC_POINT_set_compressed_coordinates_GFp EC_POINT_set_compr_coords_GFp\n#  undef EC_POINT_set_affine_coordinates_GF2m\n#  define EC_POINT_set_affine_coordinates_GF2m    EC_POINT_set_affine_coords_GF2m\n#  undef EC_POINT_get_affine_coordinates_GF2m\n#  define EC_POINT_get_affine_coordinates_GF2m    EC_POINT_get_affine_coords_GF2m\n#  undef EC_POINT_set_compressed_coordinates_GF2m\n#  define EC_POINT_set_compressed_coordinates_GF2m \\\n                                                EC_POINT_set_compr_coords_GF2m\n#  undef ec_GF2m_simple_group_clear_finish\n#  define ec_GF2m_simple_group_clear_finish       ec_GF2m_simple_grp_clr_finish\n#  undef ec_GF2m_simple_group_check_discriminant\n#  define ec_GF2m_simple_group_check_discriminant ec_GF2m_simple_grp_chk_discrim\n#  undef ec_GF2m_simple_point_clear_finish\n#  define ec_GF2m_simple_point_clear_finish       ec_GF2m_simple_pt_clr_finish\n#  undef ec_GF2m_simple_point_set_to_infinity\n#  define ec_GF2m_simple_point_set_to_infinity    ec_GF2m_simple_pt_set_to_inf\n#  undef ec_GF2m_simple_points_make_affine\n#  define ec_GF2m_simple_points_make_affine       ec_GF2m_simple_pts_make_affine\n#  undef ec_GF2m_simple_point_set_affine_coordinates\n#  define ec_GF2m_simple_point_set_affine_coordinates \\\n                                                ec_GF2m_smp_pt_set_af_coords\n#  undef ec_GF2m_simple_point_get_affine_coordinates\n#  define ec_GF2m_simple_point_get_affine_coordinates \\\n                                                ec_GF2m_smp_pt_get_af_coords\n#  undef ec_GF2m_simple_set_compressed_coordinates\n#  define ec_GF2m_simple_set_compressed_coordinates \\\n                                                ec_GF2m_smp_set_compr_coords\n#  undef ec_GFp_simple_group_set_curve_GFp\n#  define ec_GFp_simple_group_set_curve_GFp       ec_GFp_simple_grp_set_curve_GFp\n#  undef ec_GFp_simple_group_get_curve_GFp\n#  define ec_GFp_simple_group_get_curve_GFp       ec_GFp_simple_grp_get_curve_GFp\n#  undef ec_GFp_simple_group_clear_finish\n#  define ec_GFp_simple_group_clear_finish        ec_GFp_simple_grp_clear_finish\n#  undef ec_GFp_simple_group_set_generator\n#  define ec_GFp_simple_group_set_generator       ec_GFp_simple_grp_set_generator\n#  undef ec_GFp_simple_group_get0_generator\n#  define ec_GFp_simple_group_get0_generator      ec_GFp_simple_grp_gt0_generator\n#  undef ec_GFp_simple_group_get_cofactor\n#  define ec_GFp_simple_group_get_cofactor        ec_GFp_simple_grp_get_cofactor\n#  undef ec_GFp_simple_point_clear_finish\n#  define ec_GFp_simple_point_clear_finish        ec_GFp_simple_pt_clear_finish\n#  undef ec_GFp_simple_point_set_to_infinity\n#  define ec_GFp_simple_point_set_to_infinity     ec_GFp_simple_pt_set_to_inf\n#  undef ec_GFp_simple_points_make_affine\n#  define ec_GFp_simple_points_make_affine        ec_GFp_simple_pts_make_affine\n#  undef ec_GFp_simple_set_Jprojective_coordinates_GFp\n#  define ec_GFp_simple_set_Jprojective_coordinates_GFp \\\n                                                ec_GFp_smp_set_Jproj_coords_GFp\n#  undef ec_GFp_simple_get_Jprojective_coordinates_GFp\n#  define ec_GFp_simple_get_Jprojective_coordinates_GFp \\\n                                                ec_GFp_smp_get_Jproj_coords_GFp\n#  undef ec_GFp_simple_point_set_affine_coordinates_GFp\n#  define ec_GFp_simple_point_set_affine_coordinates_GFp \\\n                                                ec_GFp_smp_pt_set_af_coords_GFp\n#  undef ec_GFp_simple_point_get_affine_coordinates_GFp\n#  define ec_GFp_simple_point_get_affine_coordinates_GFp \\\n                                                ec_GFp_smp_pt_get_af_coords_GFp\n#  undef ec_GFp_simple_set_compressed_coordinates_GFp\n#  define ec_GFp_simple_set_compressed_coordinates_GFp \\\n                                                ec_GFp_smp_set_compr_coords_GFp\n#  undef ec_GFp_simple_point_set_affine_coordinates\n#  define ec_GFp_simple_point_set_affine_coordinates \\\n                                                ec_GFp_smp_pt_set_af_coords\n#  undef ec_GFp_simple_point_get_affine_coordinates\n#  define ec_GFp_simple_point_get_affine_coordinates \\\n                                                ec_GFp_smp_pt_get_af_coords\n#  undef ec_GFp_simple_set_compressed_coordinates\n#  define ec_GFp_simple_set_compressed_coordinates \\\n                                                ec_GFp_smp_set_compr_coords\n#  undef ec_GFp_simple_group_check_discriminant\n#  define ec_GFp_simple_group_check_discriminant  ec_GFp_simple_grp_chk_discrim\n\n/* Hack som long STORE names */\n#  undef STORE_method_set_initialise_function\n#  define STORE_method_set_initialise_function    STORE_meth_set_initialise_fn\n#  undef STORE_method_set_cleanup_function\n#  define STORE_method_set_cleanup_function       STORE_meth_set_cleanup_fn\n#  undef STORE_method_set_generate_function\n#  define STORE_method_set_generate_function      STORE_meth_set_generate_fn\n#  undef STORE_method_set_modify_function\n#  define STORE_method_set_modify_function        STORE_meth_set_modify_fn\n#  undef STORE_method_set_revoke_function\n#  define STORE_method_set_revoke_function        STORE_meth_set_revoke_fn\n#  undef STORE_method_set_delete_function\n#  define STORE_method_set_delete_function        STORE_meth_set_delete_fn\n#  undef STORE_method_set_list_start_function\n#  define STORE_method_set_list_start_function    STORE_meth_set_list_start_fn\n#  undef STORE_method_set_list_next_function\n#  define STORE_method_set_list_next_function     STORE_meth_set_list_next_fn\n#  undef STORE_method_set_list_end_function\n#  define STORE_method_set_list_end_function      STORE_meth_set_list_end_fn\n#  undef STORE_method_set_update_store_function\n#  define STORE_method_set_update_store_function  STORE_meth_set_update_store_fn\n#  undef STORE_method_set_lock_store_function\n#  define STORE_method_set_lock_store_function    STORE_meth_set_lock_store_fn\n#  undef STORE_method_set_unlock_store_function\n#  define STORE_method_set_unlock_store_function  STORE_meth_set_unlock_store_fn\n#  undef STORE_method_get_initialise_function\n#  define STORE_method_get_initialise_function    STORE_meth_get_initialise_fn\n#  undef STORE_method_get_cleanup_function\n#  define STORE_method_get_cleanup_function       STORE_meth_get_cleanup_fn\n#  undef STORE_method_get_generate_function\n#  define STORE_method_get_generate_function      STORE_meth_get_generate_fn\n#  undef STORE_method_get_modify_function\n#  define STORE_method_get_modify_function        STORE_meth_get_modify_fn\n#  undef STORE_method_get_revoke_function\n#  define STORE_method_get_revoke_function        STORE_meth_get_revoke_fn\n#  undef STORE_method_get_delete_function\n#  define STORE_method_get_delete_function        STORE_meth_get_delete_fn\n#  undef STORE_method_get_list_start_function\n#  define STORE_method_get_list_start_function    STORE_meth_get_list_start_fn\n#  undef STORE_method_get_list_next_function\n#  define STORE_method_get_list_next_function     STORE_meth_get_list_next_fn\n#  undef STORE_method_get_list_end_function\n#  define STORE_method_get_list_end_function      STORE_meth_get_list_end_fn\n#  undef STORE_method_get_update_store_function\n#  define STORE_method_get_update_store_function  STORE_meth_get_update_store_fn\n#  undef STORE_method_get_lock_store_function\n#  define STORE_method_get_lock_store_function    STORE_meth_get_lock_store_fn\n#  undef STORE_method_get_unlock_store_function\n#  define STORE_method_get_unlock_store_function  STORE_meth_get_unlock_store_fn\n\n/* Hack some long TS names */\n#  undef TS_RESP_CTX_set_status_info_cond\n#  define TS_RESP_CTX_set_status_info_cond        TS_RESP_CTX_set_stat_info_cond\n#  undef TS_RESP_CTX_set_clock_precision_digits\n#  define TS_RESP_CTX_set_clock_precision_digits  TS_RESP_CTX_set_clk_prec_digits\n#  undef TS_CONF_set_clock_precision_digits\n#  define TS_CONF_set_clock_precision_digits      TS_CONF_set_clk_prec_digits\n\n/* Hack some long CMS names */\n#  undef CMS_RecipientInfo_ktri_get0_algs\n#  define CMS_RecipientInfo_ktri_get0_algs        CMS_RecipInfo_ktri_get0_algs\n#  undef CMS_RecipientInfo_ktri_get0_signer_id\n#  define CMS_RecipientInfo_ktri_get0_signer_id   CMS_RecipInfo_ktri_get0_sigr_id\n#  undef CMS_OtherRevocationInfoFormat_it\n#  define CMS_OtherRevocationInfoFormat_it        CMS_OtherRevocInfoFormat_it\n#  undef CMS_KeyAgreeRecipientIdentifier_it\n#  define CMS_KeyAgreeRecipientIdentifier_it      CMS_KeyAgreeRecipIdentifier_it\n#  undef CMS_OriginatorIdentifierOrKey_it\n#  define CMS_OriginatorIdentifierOrKey_it        CMS_OriginatorIdOrKey_it\n#  undef cms_SignerIdentifier_get0_signer_id\n#  define cms_SignerIdentifier_get0_signer_id     cms_SignerId_get0_signer_id\n#  undef CMS_RecipientInfo_kari_get0_orig_id\n#  define CMS_RecipientInfo_kari_get0_orig_id     CMS_RecipInfo_kari_get0_orig_id\n#  undef CMS_RecipientInfo_kari_get0_reks\n#  define CMS_RecipientInfo_kari_get0_reks        CMS_RecipInfo_kari_get0_reks\n#  undef CMS_RecipientEncryptedKey_cert_cmp\n#  define CMS_RecipientEncryptedKey_cert_cmp      CMS_RecipEncryptedKey_cert_cmp\n#  undef CMS_RecipientInfo_kari_set0_pkey\n#  define CMS_RecipientInfo_kari_set0_pkey        CMS_RecipInfo_kari_set0_pkey\n#  undef CMS_RecipientEncryptedKey_get0_id\n#  define CMS_RecipientEncryptedKey_get0_id       CMS_RecipEncryptedKey_get0_id\n#  undef CMS_RecipientInfo_kari_orig_id_cmp\n#  define CMS_RecipientInfo_kari_orig_id_cmp      CMS_RecipInfo_kari_orig_id_cmp\n\n/* Hack some long DTLS1 names */\n#  undef dtls1_retransmit_buffered_messages\n#  define dtls1_retransmit_buffered_messages      dtls1_retransmit_buffered_msgs\n\n/* Hack some long SRP names */\n#  undef SRP_generate_server_master_secret\n#  define SRP_generate_server_master_secret       SRP_gen_server_master_secret\n#  undef SRP_generate_client_master_secret\n#  define SRP_generate_client_master_secret       SRP_gen_client_master_secret\n\n/* Hack some long UI names */\n#  undef UI_method_get_prompt_constructor\n#  define UI_method_get_prompt_constructor        UI_method_get_prompt_constructr\n#  undef UI_method_set_prompt_constructor\n#  define UI_method_set_prompt_constructor        UI_method_set_prompt_constructr\n\n# endif                         /* defined OPENSSL_SYS_VMS */\n\n/* Case insensitive linking causes problems.... */\n# if defined(OPENSSL_SYS_VMS) || defined(OPENSSL_SYS_OS2)\n#  undef ERR_load_CRYPTO_strings\n#  define ERR_load_CRYPTO_strings                 ERR_load_CRYPTOlib_strings\n#  undef OCSP_crlID_new\n#  define OCSP_crlID_new                          OCSP_crlID2_new\n\n#  undef d2i_ECPARAMETERS\n#  define d2i_ECPARAMETERS                        d2i_UC_ECPARAMETERS\n#  undef i2d_ECPARAMETERS\n#  define i2d_ECPARAMETERS                        i2d_UC_ECPARAMETERS\n#  undef d2i_ECPKPARAMETERS\n#  define d2i_ECPKPARAMETERS                      d2i_UC_ECPKPARAMETERS\n#  undef i2d_ECPKPARAMETERS\n#  define i2d_ECPKPARAMETERS                      i2d_UC_ECPKPARAMETERS\n\n/*\n * These functions do not seem to exist! However, I'm paranoid... Original\n * command in x509v3.h: These functions are being redefined in another\n * directory, and clash when the linker is case-insensitive, so let's hide\n * them a little, by giving them an extra 'o' at the beginning of the name...\n */\n#  undef X509v3_cleanup_extensions\n#  define X509v3_cleanup_extensions               oX509v3_cleanup_extensions\n#  undef X509v3_add_extension\n#  define X509v3_add_extension                    oX509v3_add_extension\n#  undef X509v3_add_netscape_extensions\n#  define X509v3_add_netscape_extensions          oX509v3_add_netscape_extensions\n#  undef X509v3_add_standard_extensions\n#  define X509v3_add_standard_extensions          oX509v3_add_standard_extensions\n\n/* This one clashes with CMS_data_create */\n#  undef cms_Data_create\n#  define cms_Data_create                         priv_cms_Data_create\n\n# endif\n\n#endif                          /* ! defined HEADER_VMS_IDHACKS_H */\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/x86_64/include/openssl/ts.h",
    "content": "/* crypto/ts/ts.h */\n/*\n * Written by Zoltan Glozik (zglozik@opentsa.org) for the OpenSSL project\n * 2002, 2003, 2004.\n */\n/* ====================================================================\n * Copyright (c) 2006 The OpenSSL Project.  All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n *\n * 1. Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n *\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in\n *    the documentation and/or other materials provided with the\n *    distribution.\n *\n * 3. All advertising materials mentioning features or use of this\n *    software must display the following acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)\"\n *\n * 4. The names \"OpenSSL Toolkit\" and \"OpenSSL Project\" must not be used to\n *    endorse or promote products derived from this software without\n *    prior written permission. For written permission, please contact\n *    licensing@OpenSSL.org.\n *\n * 5. Products derived from this software may not be called \"OpenSSL\"\n *    nor may \"OpenSSL\" appear in their names without prior written\n *    permission of the OpenSSL Project.\n *\n * 6. Redistributions of any form whatsoever must retain the following\n *    acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)\"\n *\n * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY\n * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\n * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR\n * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\n * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,\n * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED\n * OF THE POSSIBILITY OF SUCH DAMAGE.\n * ====================================================================\n *\n * This product includes cryptographic software written by Eric Young\n * (eay@cryptsoft.com).  This product includes software written by Tim\n * Hudson (tjh@cryptsoft.com).\n *\n */\n\n#ifndef HEADER_TS_H\n# define HEADER_TS_H\n\n# include <openssl/opensslconf.h>\n# include <openssl/symhacks.h>\n# ifndef OPENSSL_NO_BUFFER\n#  include <openssl/buffer.h>\n# endif\n# ifndef OPENSSL_NO_EVP\n#  include <openssl/evp.h>\n# endif\n# ifndef OPENSSL_NO_BIO\n#  include <openssl/bio.h>\n# endif\n# include <openssl/stack.h>\n# include <openssl/asn1.h>\n# include <openssl/safestack.h>\n\n# ifndef OPENSSL_NO_RSA\n#  include <openssl/rsa.h>\n# endif\n\n# ifndef OPENSSL_NO_DSA\n#  include <openssl/dsa.h>\n# endif\n\n# ifndef OPENSSL_NO_DH\n#  include <openssl/dh.h>\n# endif\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n# ifdef WIN32\n/* Under Win32 this is defined in wincrypt.h */\n#  undef X509_NAME\n# endif\n\n# include <openssl/x509.h>\n# include <openssl/x509v3.h>\n\n/*-\nMessageImprint ::= SEQUENCE  {\n     hashAlgorithm                AlgorithmIdentifier,\n     hashedMessage                OCTET STRING  }\n*/\n\ntypedef struct TS_msg_imprint_st {\n    X509_ALGOR *hash_algo;\n    ASN1_OCTET_STRING *hashed_msg;\n} TS_MSG_IMPRINT;\n\n/*-\nTimeStampReq ::= SEQUENCE  {\n   version                  INTEGER  { v1(1) },\n   messageImprint           MessageImprint,\n     --a hash algorithm OID and the hash value of the data to be\n     --time-stamped\n   reqPolicy                TSAPolicyId                OPTIONAL,\n   nonce                    INTEGER                    OPTIONAL,\n   certReq                  BOOLEAN                    DEFAULT FALSE,\n   extensions               [0] IMPLICIT Extensions    OPTIONAL  }\n*/\n\ntypedef struct TS_req_st {\n    ASN1_INTEGER *version;\n    TS_MSG_IMPRINT *msg_imprint;\n    ASN1_OBJECT *policy_id;     /* OPTIONAL */\n    ASN1_INTEGER *nonce;        /* OPTIONAL */\n    ASN1_BOOLEAN cert_req;      /* DEFAULT FALSE */\n    STACK_OF(X509_EXTENSION) *extensions; /* [0] OPTIONAL */\n} TS_REQ;\n\n/*-\nAccuracy ::= SEQUENCE {\n                seconds        INTEGER           OPTIONAL,\n                millis     [0] INTEGER  (1..999) OPTIONAL,\n                micros     [1] INTEGER  (1..999) OPTIONAL  }\n*/\n\ntypedef struct TS_accuracy_st {\n    ASN1_INTEGER *seconds;\n    ASN1_INTEGER *millis;\n    ASN1_INTEGER *micros;\n} TS_ACCURACY;\n\n/*-\nTSTInfo ::= SEQUENCE  {\n    version                      INTEGER  { v1(1) },\n    policy                       TSAPolicyId,\n    messageImprint               MessageImprint,\n      -- MUST have the same value as the similar field in\n      -- TimeStampReq\n    serialNumber                 INTEGER,\n     -- Time-Stamping users MUST be ready to accommodate integers\n     -- up to 160 bits.\n    genTime                      GeneralizedTime,\n    accuracy                     Accuracy                 OPTIONAL,\n    ordering                     BOOLEAN             DEFAULT FALSE,\n    nonce                        INTEGER                  OPTIONAL,\n      -- MUST be present if the similar field was present\n      -- in TimeStampReq.  In that case it MUST have the same value.\n    tsa                          [0] GeneralName          OPTIONAL,\n    extensions                   [1] IMPLICIT Extensions  OPTIONAL   }\n*/\n\ntypedef struct TS_tst_info_st {\n    ASN1_INTEGER *version;\n    ASN1_OBJECT *policy_id;\n    TS_MSG_IMPRINT *msg_imprint;\n    ASN1_INTEGER *serial;\n    ASN1_GENERALIZEDTIME *time;\n    TS_ACCURACY *accuracy;\n    ASN1_BOOLEAN ordering;\n    ASN1_INTEGER *nonce;\n    GENERAL_NAME *tsa;\n    STACK_OF(X509_EXTENSION) *extensions;\n} TS_TST_INFO;\n\n/*-\nPKIStatusInfo ::= SEQUENCE {\n    status        PKIStatus,\n    statusString  PKIFreeText     OPTIONAL,\n    failInfo      PKIFailureInfo  OPTIONAL  }\n\nFrom RFC 1510 - section 3.1.1:\nPKIFreeText ::= SEQUENCE SIZE (1..MAX) OF UTF8String\n        -- text encoded as UTF-8 String (note:  each UTF8String SHOULD\n        -- include an RFC 1766 language tag to indicate the language\n        -- of the contained text)\n*/\n\n/* Possible values for status. See ts_resp_print.c && ts_resp_verify.c. */\n\n# define TS_STATUS_GRANTED                       0\n# define TS_STATUS_GRANTED_WITH_MODS             1\n# define TS_STATUS_REJECTION                     2\n# define TS_STATUS_WAITING                       3\n# define TS_STATUS_REVOCATION_WARNING            4\n# define TS_STATUS_REVOCATION_NOTIFICATION       5\n\n/*\n * Possible values for failure_info. See ts_resp_print.c && ts_resp_verify.c\n */\n\n# define TS_INFO_BAD_ALG                 0\n# define TS_INFO_BAD_REQUEST             2\n# define TS_INFO_BAD_DATA_FORMAT         5\n# define TS_INFO_TIME_NOT_AVAILABLE      14\n# define TS_INFO_UNACCEPTED_POLICY       15\n# define TS_INFO_UNACCEPTED_EXTENSION    16\n# define TS_INFO_ADD_INFO_NOT_AVAILABLE  17\n# define TS_INFO_SYSTEM_FAILURE          25\n\ntypedef struct TS_status_info_st {\n    ASN1_INTEGER *status;\n    STACK_OF(ASN1_UTF8STRING) *text;\n    ASN1_BIT_STRING *failure_info;\n} TS_STATUS_INFO;\n\nDECLARE_STACK_OF(ASN1_UTF8STRING)\nDECLARE_ASN1_SET_OF(ASN1_UTF8STRING)\n\n/*-\nTimeStampResp ::= SEQUENCE  {\n     status                  PKIStatusInfo,\n     timeStampToken          TimeStampToken     OPTIONAL }\n*/\n\ntypedef struct TS_resp_st {\n    TS_STATUS_INFO *status_info;\n    PKCS7 *token;\n    TS_TST_INFO *tst_info;\n} TS_RESP;\n\n/* The structure below would belong to the ESS component. */\n\n/*-\nIssuerSerial ::= SEQUENCE {\n        issuer                   GeneralNames,\n        serialNumber             CertificateSerialNumber\n        }\n*/\n\ntypedef struct ESS_issuer_serial {\n    STACK_OF(GENERAL_NAME) *issuer;\n    ASN1_INTEGER *serial;\n} ESS_ISSUER_SERIAL;\n\n/*-\nESSCertID ::=  SEQUENCE {\n        certHash                 Hash,\n        issuerSerial             IssuerSerial OPTIONAL\n}\n*/\n\ntypedef struct ESS_cert_id {\n    ASN1_OCTET_STRING *hash;    /* Always SHA-1 digest. */\n    ESS_ISSUER_SERIAL *issuer_serial;\n} ESS_CERT_ID;\n\nDECLARE_STACK_OF(ESS_CERT_ID)\nDECLARE_ASN1_SET_OF(ESS_CERT_ID)\n\n/*-\nSigningCertificate ::=  SEQUENCE {\n       certs        SEQUENCE OF ESSCertID,\n       policies     SEQUENCE OF PolicyInformation OPTIONAL\n}\n*/\n\ntypedef struct ESS_signing_cert {\n    STACK_OF(ESS_CERT_ID) *cert_ids;\n    STACK_OF(POLICYINFO) *policy_info;\n} ESS_SIGNING_CERT;\n\nTS_REQ *TS_REQ_new(void);\nvoid TS_REQ_free(TS_REQ *a);\nint i2d_TS_REQ(const TS_REQ *a, unsigned char **pp);\nTS_REQ *d2i_TS_REQ(TS_REQ **a, const unsigned char **pp, long length);\n\nTS_REQ *TS_REQ_dup(TS_REQ *a);\n\nTS_REQ *d2i_TS_REQ_fp(FILE *fp, TS_REQ **a);\nint i2d_TS_REQ_fp(FILE *fp, TS_REQ *a);\nTS_REQ *d2i_TS_REQ_bio(BIO *fp, TS_REQ **a);\nint i2d_TS_REQ_bio(BIO *fp, TS_REQ *a);\n\nTS_MSG_IMPRINT *TS_MSG_IMPRINT_new(void);\nvoid TS_MSG_IMPRINT_free(TS_MSG_IMPRINT *a);\nint i2d_TS_MSG_IMPRINT(const TS_MSG_IMPRINT *a, unsigned char **pp);\nTS_MSG_IMPRINT *d2i_TS_MSG_IMPRINT(TS_MSG_IMPRINT **a,\n                                   const unsigned char **pp, long length);\n\nTS_MSG_IMPRINT *TS_MSG_IMPRINT_dup(TS_MSG_IMPRINT *a);\n\nTS_MSG_IMPRINT *d2i_TS_MSG_IMPRINT_fp(FILE *fp, TS_MSG_IMPRINT **a);\nint i2d_TS_MSG_IMPRINT_fp(FILE *fp, TS_MSG_IMPRINT *a);\nTS_MSG_IMPRINT *d2i_TS_MSG_IMPRINT_bio(BIO *fp, TS_MSG_IMPRINT **a);\nint i2d_TS_MSG_IMPRINT_bio(BIO *fp, TS_MSG_IMPRINT *a);\n\nTS_RESP *TS_RESP_new(void);\nvoid TS_RESP_free(TS_RESP *a);\nint i2d_TS_RESP(const TS_RESP *a, unsigned char **pp);\nTS_RESP *d2i_TS_RESP(TS_RESP **a, const unsigned char **pp, long length);\nTS_TST_INFO *PKCS7_to_TS_TST_INFO(PKCS7 *token);\nTS_RESP *TS_RESP_dup(TS_RESP *a);\n\nTS_RESP *d2i_TS_RESP_fp(FILE *fp, TS_RESP **a);\nint i2d_TS_RESP_fp(FILE *fp, TS_RESP *a);\nTS_RESP *d2i_TS_RESP_bio(BIO *fp, TS_RESP **a);\nint i2d_TS_RESP_bio(BIO *fp, TS_RESP *a);\n\nTS_STATUS_INFO *TS_STATUS_INFO_new(void);\nvoid TS_STATUS_INFO_free(TS_STATUS_INFO *a);\nint i2d_TS_STATUS_INFO(const TS_STATUS_INFO *a, unsigned char **pp);\nTS_STATUS_INFO *d2i_TS_STATUS_INFO(TS_STATUS_INFO **a,\n                                   const unsigned char **pp, long length);\nTS_STATUS_INFO *TS_STATUS_INFO_dup(TS_STATUS_INFO *a);\n\nTS_TST_INFO *TS_TST_INFO_new(void);\nvoid TS_TST_INFO_free(TS_TST_INFO *a);\nint i2d_TS_TST_INFO(const TS_TST_INFO *a, unsigned char **pp);\nTS_TST_INFO *d2i_TS_TST_INFO(TS_TST_INFO **a, const unsigned char **pp,\n                             long length);\nTS_TST_INFO *TS_TST_INFO_dup(TS_TST_INFO *a);\n\nTS_TST_INFO *d2i_TS_TST_INFO_fp(FILE *fp, TS_TST_INFO **a);\nint i2d_TS_TST_INFO_fp(FILE *fp, TS_TST_INFO *a);\nTS_TST_INFO *d2i_TS_TST_INFO_bio(BIO *fp, TS_TST_INFO **a);\nint i2d_TS_TST_INFO_bio(BIO *fp, TS_TST_INFO *a);\n\nTS_ACCURACY *TS_ACCURACY_new(void);\nvoid TS_ACCURACY_free(TS_ACCURACY *a);\nint i2d_TS_ACCURACY(const TS_ACCURACY *a, unsigned char **pp);\nTS_ACCURACY *d2i_TS_ACCURACY(TS_ACCURACY **a, const unsigned char **pp,\n                             long length);\nTS_ACCURACY *TS_ACCURACY_dup(TS_ACCURACY *a);\n\nESS_ISSUER_SERIAL *ESS_ISSUER_SERIAL_new(void);\nvoid ESS_ISSUER_SERIAL_free(ESS_ISSUER_SERIAL *a);\nint i2d_ESS_ISSUER_SERIAL(const ESS_ISSUER_SERIAL *a, unsigned char **pp);\nESS_ISSUER_SERIAL *d2i_ESS_ISSUER_SERIAL(ESS_ISSUER_SERIAL **a,\n                                         const unsigned char **pp,\n                                         long length);\nESS_ISSUER_SERIAL *ESS_ISSUER_SERIAL_dup(ESS_ISSUER_SERIAL *a);\n\nESS_CERT_ID *ESS_CERT_ID_new(void);\nvoid ESS_CERT_ID_free(ESS_CERT_ID *a);\nint i2d_ESS_CERT_ID(const ESS_CERT_ID *a, unsigned char **pp);\nESS_CERT_ID *d2i_ESS_CERT_ID(ESS_CERT_ID **a, const unsigned char **pp,\n                             long length);\nESS_CERT_ID *ESS_CERT_ID_dup(ESS_CERT_ID *a);\n\nESS_SIGNING_CERT *ESS_SIGNING_CERT_new(void);\nvoid ESS_SIGNING_CERT_free(ESS_SIGNING_CERT *a);\nint i2d_ESS_SIGNING_CERT(const ESS_SIGNING_CERT *a, unsigned char **pp);\nESS_SIGNING_CERT *d2i_ESS_SIGNING_CERT(ESS_SIGNING_CERT **a,\n                                       const unsigned char **pp, long length);\nESS_SIGNING_CERT *ESS_SIGNING_CERT_dup(ESS_SIGNING_CERT *a);\n\nvoid ERR_load_TS_strings(void);\n\nint TS_REQ_set_version(TS_REQ *a, long version);\nlong TS_REQ_get_version(const TS_REQ *a);\n\nint TS_REQ_set_msg_imprint(TS_REQ *a, TS_MSG_IMPRINT *msg_imprint);\nTS_MSG_IMPRINT *TS_REQ_get_msg_imprint(TS_REQ *a);\n\nint TS_MSG_IMPRINT_set_algo(TS_MSG_IMPRINT *a, X509_ALGOR *alg);\nX509_ALGOR *TS_MSG_IMPRINT_get_algo(TS_MSG_IMPRINT *a);\n\nint TS_MSG_IMPRINT_set_msg(TS_MSG_IMPRINT *a, unsigned char *d, int len);\nASN1_OCTET_STRING *TS_MSG_IMPRINT_get_msg(TS_MSG_IMPRINT *a);\n\nint TS_REQ_set_policy_id(TS_REQ *a, ASN1_OBJECT *policy);\nASN1_OBJECT *TS_REQ_get_policy_id(TS_REQ *a);\n\nint TS_REQ_set_nonce(TS_REQ *a, const ASN1_INTEGER *nonce);\nconst ASN1_INTEGER *TS_REQ_get_nonce(const TS_REQ *a);\n\nint TS_REQ_set_cert_req(TS_REQ *a, int cert_req);\nint TS_REQ_get_cert_req(const TS_REQ *a);\n\nSTACK_OF(X509_EXTENSION) *TS_REQ_get_exts(TS_REQ *a);\nvoid TS_REQ_ext_free(TS_REQ *a);\nint TS_REQ_get_ext_count(TS_REQ *a);\nint TS_REQ_get_ext_by_NID(TS_REQ *a, int nid, int lastpos);\nint TS_REQ_get_ext_by_OBJ(TS_REQ *a, ASN1_OBJECT *obj, int lastpos);\nint TS_REQ_get_ext_by_critical(TS_REQ *a, int crit, int lastpos);\nX509_EXTENSION *TS_REQ_get_ext(TS_REQ *a, int loc);\nX509_EXTENSION *TS_REQ_delete_ext(TS_REQ *a, int loc);\nint TS_REQ_add_ext(TS_REQ *a, X509_EXTENSION *ex, int loc);\nvoid *TS_REQ_get_ext_d2i(TS_REQ *a, int nid, int *crit, int *idx);\n\n/* Function declarations for TS_REQ defined in ts/ts_req_print.c */\n\nint TS_REQ_print_bio(BIO *bio, TS_REQ *a);\n\n/* Function declarations for TS_RESP defined in ts/ts_resp_utils.c */\n\nint TS_RESP_set_status_info(TS_RESP *a, TS_STATUS_INFO *info);\nTS_STATUS_INFO *TS_RESP_get_status_info(TS_RESP *a);\n\n/* Caller loses ownership of PKCS7 and TS_TST_INFO objects. */\nvoid TS_RESP_set_tst_info(TS_RESP *a, PKCS7 *p7, TS_TST_INFO *tst_info);\nPKCS7 *TS_RESP_get_token(TS_RESP *a);\nTS_TST_INFO *TS_RESP_get_tst_info(TS_RESP *a);\n\nint TS_TST_INFO_set_version(TS_TST_INFO *a, long version);\nlong TS_TST_INFO_get_version(const TS_TST_INFO *a);\n\nint TS_TST_INFO_set_policy_id(TS_TST_INFO *a, ASN1_OBJECT *policy_id);\nASN1_OBJECT *TS_TST_INFO_get_policy_id(TS_TST_INFO *a);\n\nint TS_TST_INFO_set_msg_imprint(TS_TST_INFO *a, TS_MSG_IMPRINT *msg_imprint);\nTS_MSG_IMPRINT *TS_TST_INFO_get_msg_imprint(TS_TST_INFO *a);\n\nint TS_TST_INFO_set_serial(TS_TST_INFO *a, const ASN1_INTEGER *serial);\nconst ASN1_INTEGER *TS_TST_INFO_get_serial(const TS_TST_INFO *a);\n\nint TS_TST_INFO_set_time(TS_TST_INFO *a, const ASN1_GENERALIZEDTIME *gtime);\nconst ASN1_GENERALIZEDTIME *TS_TST_INFO_get_time(const TS_TST_INFO *a);\n\nint TS_TST_INFO_set_accuracy(TS_TST_INFO *a, TS_ACCURACY *accuracy);\nTS_ACCURACY *TS_TST_INFO_get_accuracy(TS_TST_INFO *a);\n\nint TS_ACCURACY_set_seconds(TS_ACCURACY *a, const ASN1_INTEGER *seconds);\nconst ASN1_INTEGER *TS_ACCURACY_get_seconds(const TS_ACCURACY *a);\n\nint TS_ACCURACY_set_millis(TS_ACCURACY *a, const ASN1_INTEGER *millis);\nconst ASN1_INTEGER *TS_ACCURACY_get_millis(const TS_ACCURACY *a);\n\nint TS_ACCURACY_set_micros(TS_ACCURACY *a, const ASN1_INTEGER *micros);\nconst ASN1_INTEGER *TS_ACCURACY_get_micros(const TS_ACCURACY *a);\n\nint TS_TST_INFO_set_ordering(TS_TST_INFO *a, int ordering);\nint TS_TST_INFO_get_ordering(const TS_TST_INFO *a);\n\nint TS_TST_INFO_set_nonce(TS_TST_INFO *a, const ASN1_INTEGER *nonce);\nconst ASN1_INTEGER *TS_TST_INFO_get_nonce(const TS_TST_INFO *a);\n\nint TS_TST_INFO_set_tsa(TS_TST_INFO *a, GENERAL_NAME *tsa);\nGENERAL_NAME *TS_TST_INFO_get_tsa(TS_TST_INFO *a);\n\nSTACK_OF(X509_EXTENSION) *TS_TST_INFO_get_exts(TS_TST_INFO *a);\nvoid TS_TST_INFO_ext_free(TS_TST_INFO *a);\nint TS_TST_INFO_get_ext_count(TS_TST_INFO *a);\nint TS_TST_INFO_get_ext_by_NID(TS_TST_INFO *a, int nid, int lastpos);\nint TS_TST_INFO_get_ext_by_OBJ(TS_TST_INFO *a, ASN1_OBJECT *obj, int lastpos);\nint TS_TST_INFO_get_ext_by_critical(TS_TST_INFO *a, int crit, int lastpos);\nX509_EXTENSION *TS_TST_INFO_get_ext(TS_TST_INFO *a, int loc);\nX509_EXTENSION *TS_TST_INFO_delete_ext(TS_TST_INFO *a, int loc);\nint TS_TST_INFO_add_ext(TS_TST_INFO *a, X509_EXTENSION *ex, int loc);\nvoid *TS_TST_INFO_get_ext_d2i(TS_TST_INFO *a, int nid, int *crit, int *idx);\n\n/*\n * Declarations related to response generation, defined in ts/ts_resp_sign.c.\n */\n\n/* Optional flags for response generation. */\n\n/* Don't include the TSA name in response. */\n# define TS_TSA_NAME             0x01\n\n/* Set ordering to true in response. */\n# define TS_ORDERING             0x02\n\n/*\n * Include the signer certificate and the other specified certificates in\n * the ESS signing certificate attribute beside the PKCS7 signed data.\n * Only the signer certificates is included by default.\n */\n# define TS_ESS_CERT_ID_CHAIN    0x04\n\n/* Forward declaration. */\nstruct TS_resp_ctx;\n\n/* This must return a unique number less than 160 bits long. */\ntypedef ASN1_INTEGER *(*TS_serial_cb) (struct TS_resp_ctx *, void *);\n\n/*\n * This must return the seconds and microseconds since Jan 1, 1970 in the sec\n * and usec variables allocated by the caller. Return non-zero for success\n * and zero for failure.\n */\ntypedef int (*TS_time_cb) (struct TS_resp_ctx *, void *, long *sec,\n                           long *usec);\n\n/*\n * This must process the given extension. It can modify the TS_TST_INFO\n * object of the context. Return values: !0 (processed), 0 (error, it must\n * set the status info/failure info of the response).\n */\ntypedef int (*TS_extension_cb) (struct TS_resp_ctx *, X509_EXTENSION *,\n                                void *);\n\ntypedef struct TS_resp_ctx {\n    X509 *signer_cert;\n    EVP_PKEY *signer_key;\n    STACK_OF(X509) *certs;      /* Certs to include in signed data. */\n    STACK_OF(ASN1_OBJECT) *policies; /* Acceptable policies. */\n    ASN1_OBJECT *default_policy; /* It may appear in policies, too. */\n    STACK_OF(EVP_MD) *mds;      /* Acceptable message digests. */\n    ASN1_INTEGER *seconds;      /* accuracy, 0 means not specified. */\n    ASN1_INTEGER *millis;       /* accuracy, 0 means not specified. */\n    ASN1_INTEGER *micros;       /* accuracy, 0 means not specified. */\n    unsigned clock_precision_digits; /* fraction of seconds in time stamp\n                                      * token. */\n    unsigned flags;             /* Optional info, see values above. */\n    /* Callback functions. */\n    TS_serial_cb serial_cb;\n    void *serial_cb_data;       /* User data for serial_cb. */\n    TS_time_cb time_cb;\n    void *time_cb_data;         /* User data for time_cb. */\n    TS_extension_cb extension_cb;\n    void *extension_cb_data;    /* User data for extension_cb. */\n    /* These members are used only while creating the response. */\n    TS_REQ *request;\n    TS_RESP *response;\n    TS_TST_INFO *tst_info;\n} TS_RESP_CTX;\n\nDECLARE_STACK_OF(EVP_MD)\nDECLARE_ASN1_SET_OF(EVP_MD)\n\n/* Creates a response context that can be used for generating responses. */\nTS_RESP_CTX *TS_RESP_CTX_new(void);\nvoid TS_RESP_CTX_free(TS_RESP_CTX *ctx);\n\n/* This parameter must be set. */\nint TS_RESP_CTX_set_signer_cert(TS_RESP_CTX *ctx, X509 *signer);\n\n/* This parameter must be set. */\nint TS_RESP_CTX_set_signer_key(TS_RESP_CTX *ctx, EVP_PKEY *key);\n\n/* This parameter must be set. */\nint TS_RESP_CTX_set_def_policy(TS_RESP_CTX *ctx, ASN1_OBJECT *def_policy);\n\n/* No additional certs are included in the response by default. */\nint TS_RESP_CTX_set_certs(TS_RESP_CTX *ctx, STACK_OF(X509) *certs);\n\n/*\n * Adds a new acceptable policy, only the default policy is accepted by\n * default.\n */\nint TS_RESP_CTX_add_policy(TS_RESP_CTX *ctx, ASN1_OBJECT *policy);\n\n/*\n * Adds a new acceptable message digest. Note that no message digests are\n * accepted by default. The md argument is shared with the caller.\n */\nint TS_RESP_CTX_add_md(TS_RESP_CTX *ctx, const EVP_MD *md);\n\n/* Accuracy is not included by default. */\nint TS_RESP_CTX_set_accuracy(TS_RESP_CTX *ctx,\n                             int secs, int millis, int micros);\n\n/*\n * Clock precision digits, i.e. the number of decimal digits: '0' means sec,\n * '3' msec, '6' usec, and so on. Default is 0.\n */\nint TS_RESP_CTX_set_clock_precision_digits(TS_RESP_CTX *ctx,\n                                           unsigned clock_precision_digits);\n/* At most we accept usec precision. */\n# define TS_MAX_CLOCK_PRECISION_DIGITS   6\n\n/* Maximum status message length */\n# define TS_MAX_STATUS_LENGTH   (1024 * 1024)\n\n/* No flags are set by default. */\nvoid TS_RESP_CTX_add_flags(TS_RESP_CTX *ctx, int flags);\n\n/* Default callback always returns a constant. */\nvoid TS_RESP_CTX_set_serial_cb(TS_RESP_CTX *ctx, TS_serial_cb cb, void *data);\n\n/* Default callback uses the gettimeofday() and gmtime() system calls. */\nvoid TS_RESP_CTX_set_time_cb(TS_RESP_CTX *ctx, TS_time_cb cb, void *data);\n\n/*\n * Default callback rejects all extensions. The extension callback is called\n * when the TS_TST_INFO object is already set up and not signed yet.\n */\n/* FIXME: extension handling is not tested yet. */\nvoid TS_RESP_CTX_set_extension_cb(TS_RESP_CTX *ctx,\n                                  TS_extension_cb cb, void *data);\n\n/* The following methods can be used in the callbacks. */\nint TS_RESP_CTX_set_status_info(TS_RESP_CTX *ctx,\n                                int status, const char *text);\n\n/* Sets the status info only if it is still TS_STATUS_GRANTED. */\nint TS_RESP_CTX_set_status_info_cond(TS_RESP_CTX *ctx,\n                                     int status, const char *text);\n\nint TS_RESP_CTX_add_failure_info(TS_RESP_CTX *ctx, int failure);\n\n/* The get methods below can be used in the extension callback. */\nTS_REQ *TS_RESP_CTX_get_request(TS_RESP_CTX *ctx);\n\nTS_TST_INFO *TS_RESP_CTX_get_tst_info(TS_RESP_CTX *ctx);\n\n/*\n * Creates the signed TS_TST_INFO and puts it in TS_RESP.\n * In case of errors it sets the status info properly.\n * Returns NULL only in case of memory allocation/fatal error.\n */\nTS_RESP *TS_RESP_create_response(TS_RESP_CTX *ctx, BIO *req_bio);\n\n/*\n * Declarations related to response verification,\n * they are defined in ts/ts_resp_verify.c.\n */\n\nint TS_RESP_verify_signature(PKCS7 *token, STACK_OF(X509) *certs,\n                             X509_STORE *store, X509 **signer_out);\n\n/* Context structure for the generic verify method. */\n\n/* Verify the signer's certificate and the signature of the response. */\n# define TS_VFY_SIGNATURE        (1u << 0)\n/* Verify the version number of the response. */\n# define TS_VFY_VERSION          (1u << 1)\n/* Verify if the policy supplied by the user matches the policy of the TSA. */\n# define TS_VFY_POLICY           (1u << 2)\n/*\n * Verify the message imprint provided by the user. This flag should not be\n * specified with TS_VFY_DATA.\n */\n# define TS_VFY_IMPRINT          (1u << 3)\n/*\n * Verify the message imprint computed by the verify method from the user\n * provided data and the MD algorithm of the response. This flag should not\n * be specified with TS_VFY_IMPRINT.\n */\n# define TS_VFY_DATA             (1u << 4)\n/* Verify the nonce value. */\n# define TS_VFY_NONCE            (1u << 5)\n/* Verify if the TSA name field matches the signer certificate. */\n# define TS_VFY_SIGNER           (1u << 6)\n/* Verify if the TSA name field equals to the user provided name. */\n# define TS_VFY_TSA_NAME         (1u << 7)\n\n/* You can use the following convenience constants. */\n# define TS_VFY_ALL_IMPRINT      (TS_VFY_SIGNATURE       \\\n                                 | TS_VFY_VERSION       \\\n                                 | TS_VFY_POLICY        \\\n                                 | TS_VFY_IMPRINT       \\\n                                 | TS_VFY_NONCE         \\\n                                 | TS_VFY_SIGNER        \\\n                                 | TS_VFY_TSA_NAME)\n# define TS_VFY_ALL_DATA         (TS_VFY_SIGNATURE       \\\n                                 | TS_VFY_VERSION       \\\n                                 | TS_VFY_POLICY        \\\n                                 | TS_VFY_DATA          \\\n                                 | TS_VFY_NONCE         \\\n                                 | TS_VFY_SIGNER        \\\n                                 | TS_VFY_TSA_NAME)\n\ntypedef struct TS_verify_ctx {\n    /* Set this to the union of TS_VFY_... flags you want to carry out. */\n    unsigned flags;\n    /* Must be set only with TS_VFY_SIGNATURE. certs is optional. */\n    X509_STORE *store;\n    STACK_OF(X509) *certs;\n    /* Must be set only with TS_VFY_POLICY. */\n    ASN1_OBJECT *policy;\n    /*\n     * Must be set only with TS_VFY_IMPRINT. If md_alg is NULL, the\n     * algorithm from the response is used.\n     */\n    X509_ALGOR *md_alg;\n    unsigned char *imprint;\n    unsigned imprint_len;\n    /* Must be set only with TS_VFY_DATA. */\n    BIO *data;\n    /* Must be set only with TS_VFY_TSA_NAME. */\n    ASN1_INTEGER *nonce;\n    /* Must be set only with TS_VFY_TSA_NAME. */\n    GENERAL_NAME *tsa_name;\n} TS_VERIFY_CTX;\n\nint TS_RESP_verify_response(TS_VERIFY_CTX *ctx, TS_RESP *response);\nint TS_RESP_verify_token(TS_VERIFY_CTX *ctx, PKCS7 *token);\n\n/*\n * Declarations related to response verification context,\n * they are defined in ts/ts_verify_ctx.c.\n */\n\n/* Set all fields to zero. */\nTS_VERIFY_CTX *TS_VERIFY_CTX_new(void);\nvoid TS_VERIFY_CTX_init(TS_VERIFY_CTX *ctx);\nvoid TS_VERIFY_CTX_free(TS_VERIFY_CTX *ctx);\nvoid TS_VERIFY_CTX_cleanup(TS_VERIFY_CTX *ctx);\n\n/*-\n * If ctx is NULL, it allocates and returns a new object, otherwise\n * it returns ctx. It initialises all the members as follows:\n * flags = TS_VFY_ALL_IMPRINT & ~(TS_VFY_TSA_NAME | TS_VFY_SIGNATURE)\n * certs = NULL\n * store = NULL\n * policy = policy from the request or NULL if absent (in this case\n *      TS_VFY_POLICY is cleared from flags as well)\n * md_alg = MD algorithm from request\n * imprint, imprint_len = imprint from request\n * data = NULL\n * nonce, nonce_len = nonce from the request or NULL if absent (in this case\n *      TS_VFY_NONCE is cleared from flags as well)\n * tsa_name = NULL\n * Important: after calling this method TS_VFY_SIGNATURE should be added!\n */\nTS_VERIFY_CTX *TS_REQ_to_TS_VERIFY_CTX(TS_REQ *req, TS_VERIFY_CTX *ctx);\n\n/* Function declarations for TS_RESP defined in ts/ts_resp_print.c */\n\nint TS_RESP_print_bio(BIO *bio, TS_RESP *a);\nint TS_STATUS_INFO_print_bio(BIO *bio, TS_STATUS_INFO *a);\nint TS_TST_INFO_print_bio(BIO *bio, TS_TST_INFO *a);\n\n/* Common utility functions defined in ts/ts_lib.c */\n\nint TS_ASN1_INTEGER_print_bio(BIO *bio, const ASN1_INTEGER *num);\nint TS_OBJ_print_bio(BIO *bio, const ASN1_OBJECT *obj);\nint TS_ext_print_bio(BIO *bio, const STACK_OF(X509_EXTENSION) *extensions);\nint TS_X509_ALGOR_print_bio(BIO *bio, const X509_ALGOR *alg);\nint TS_MSG_IMPRINT_print_bio(BIO *bio, TS_MSG_IMPRINT *msg);\n\n/*\n * Function declarations for handling configuration options, defined in\n * ts/ts_conf.c\n */\n\nX509 *TS_CONF_load_cert(const char *file);\nSTACK_OF(X509) *TS_CONF_load_certs(const char *file);\nEVP_PKEY *TS_CONF_load_key(const char *file, const char *pass);\nconst char *TS_CONF_get_tsa_section(CONF *conf, const char *section);\nint TS_CONF_set_serial(CONF *conf, const char *section, TS_serial_cb cb,\n                       TS_RESP_CTX *ctx);\nint TS_CONF_set_crypto_device(CONF *conf, const char *section,\n                              const char *device);\nint TS_CONF_set_default_engine(const char *name);\nint TS_CONF_set_signer_cert(CONF *conf, const char *section,\n                            const char *cert, TS_RESP_CTX *ctx);\nint TS_CONF_set_certs(CONF *conf, const char *section, const char *certs,\n                      TS_RESP_CTX *ctx);\nint TS_CONF_set_signer_key(CONF *conf, const char *section,\n                           const char *key, const char *pass,\n                           TS_RESP_CTX *ctx);\nint TS_CONF_set_def_policy(CONF *conf, const char *section,\n                           const char *policy, TS_RESP_CTX *ctx);\nint TS_CONF_set_policies(CONF *conf, const char *section, TS_RESP_CTX *ctx);\nint TS_CONF_set_digests(CONF *conf, const char *section, TS_RESP_CTX *ctx);\nint TS_CONF_set_accuracy(CONF *conf, const char *section, TS_RESP_CTX *ctx);\nint TS_CONF_set_clock_precision_digits(CONF *conf, const char *section,\n                                       TS_RESP_CTX *ctx);\nint TS_CONF_set_ordering(CONF *conf, const char *section, TS_RESP_CTX *ctx);\nint TS_CONF_set_tsa_name(CONF *conf, const char *section, TS_RESP_CTX *ctx);\nint TS_CONF_set_ess_cert_id_chain(CONF *conf, const char *section,\n                                  TS_RESP_CTX *ctx);\n\n/* -------------------------------------------------- */\n/* BEGIN ERROR CODES */\n/*\n * The following lines are auto generated by the script mkerr.pl. Any changes\n * made after this point may be overwritten when the script is next run.\n */\nvoid ERR_load_TS_strings(void);\n\n/* Error codes for the TS functions. */\n\n/* Function codes. */\n# define TS_F_D2I_TS_RESP                                 147\n# define TS_F_DEF_SERIAL_CB                               110\n# define TS_F_DEF_TIME_CB                                 111\n# define TS_F_ESS_ADD_SIGNING_CERT                        112\n# define TS_F_ESS_CERT_ID_NEW_INIT                        113\n# define TS_F_ESS_SIGNING_CERT_NEW_INIT                   114\n# define TS_F_INT_TS_RESP_VERIFY_TOKEN                    149\n# define TS_F_PKCS7_TO_TS_TST_INFO                        148\n# define TS_F_TS_ACCURACY_SET_MICROS                      115\n# define TS_F_TS_ACCURACY_SET_MILLIS                      116\n# define TS_F_TS_ACCURACY_SET_SECONDS                     117\n# define TS_F_TS_CHECK_IMPRINTS                           100\n# define TS_F_TS_CHECK_NONCES                             101\n# define TS_F_TS_CHECK_POLICY                             102\n# define TS_F_TS_CHECK_SIGNING_CERTS                      103\n# define TS_F_TS_CHECK_STATUS_INFO                        104\n# define TS_F_TS_COMPUTE_IMPRINT                          145\n# define TS_F_TS_CONF_SET_DEFAULT_ENGINE                  146\n# define TS_F_TS_GET_STATUS_TEXT                          105\n# define TS_F_TS_MSG_IMPRINT_SET_ALGO                     118\n# define TS_F_TS_REQ_SET_MSG_IMPRINT                      119\n# define TS_F_TS_REQ_SET_NONCE                            120\n# define TS_F_TS_REQ_SET_POLICY_ID                        121\n# define TS_F_TS_RESP_CREATE_RESPONSE                     122\n# define TS_F_TS_RESP_CREATE_TST_INFO                     123\n# define TS_F_TS_RESP_CTX_ADD_FAILURE_INFO                124\n# define TS_F_TS_RESP_CTX_ADD_MD                          125\n# define TS_F_TS_RESP_CTX_ADD_POLICY                      126\n# define TS_F_TS_RESP_CTX_NEW                             127\n# define TS_F_TS_RESP_CTX_SET_ACCURACY                    128\n# define TS_F_TS_RESP_CTX_SET_CERTS                       129\n# define TS_F_TS_RESP_CTX_SET_DEF_POLICY                  130\n# define TS_F_TS_RESP_CTX_SET_SIGNER_CERT                 131\n# define TS_F_TS_RESP_CTX_SET_STATUS_INFO                 132\n# define TS_F_TS_RESP_GET_POLICY                          133\n# define TS_F_TS_RESP_SET_GENTIME_WITH_PRECISION          134\n# define TS_F_TS_RESP_SET_STATUS_INFO                     135\n# define TS_F_TS_RESP_SET_TST_INFO                        150\n# define TS_F_TS_RESP_SIGN                                136\n# define TS_F_TS_RESP_VERIFY_SIGNATURE                    106\n# define TS_F_TS_RESP_VERIFY_TOKEN                        107\n# define TS_F_TS_TST_INFO_SET_ACCURACY                    137\n# define TS_F_TS_TST_INFO_SET_MSG_IMPRINT                 138\n# define TS_F_TS_TST_INFO_SET_NONCE                       139\n# define TS_F_TS_TST_INFO_SET_POLICY_ID                   140\n# define TS_F_TS_TST_INFO_SET_SERIAL                      141\n# define TS_F_TS_TST_INFO_SET_TIME                        142\n# define TS_F_TS_TST_INFO_SET_TSA                         143\n# define TS_F_TS_VERIFY                                   108\n# define TS_F_TS_VERIFY_CERT                              109\n# define TS_F_TS_VERIFY_CTX_NEW                           144\n\n/* Reason codes. */\n# define TS_R_BAD_PKCS7_TYPE                              132\n# define TS_R_BAD_TYPE                                    133\n# define TS_R_CERTIFICATE_VERIFY_ERROR                    100\n# define TS_R_COULD_NOT_SET_ENGINE                        127\n# define TS_R_COULD_NOT_SET_TIME                          115\n# define TS_R_D2I_TS_RESP_INT_FAILED                      128\n# define TS_R_DETACHED_CONTENT                            134\n# define TS_R_ESS_ADD_SIGNING_CERT_ERROR                  116\n# define TS_R_ESS_SIGNING_CERTIFICATE_ERROR               101\n# define TS_R_INVALID_NULL_POINTER                        102\n# define TS_R_INVALID_SIGNER_CERTIFICATE_PURPOSE          117\n# define TS_R_MESSAGE_IMPRINT_MISMATCH                    103\n# define TS_R_NONCE_MISMATCH                              104\n# define TS_R_NONCE_NOT_RETURNED                          105\n# define TS_R_NO_CONTENT                                  106\n# define TS_R_NO_TIME_STAMP_TOKEN                         107\n# define TS_R_PKCS7_ADD_SIGNATURE_ERROR                   118\n# define TS_R_PKCS7_ADD_SIGNED_ATTR_ERROR                 119\n# define TS_R_PKCS7_TO_TS_TST_INFO_FAILED                 129\n# define TS_R_POLICY_MISMATCH                             108\n# define TS_R_PRIVATE_KEY_DOES_NOT_MATCH_CERTIFICATE      120\n# define TS_R_RESPONSE_SETUP_ERROR                        121\n# define TS_R_SIGNATURE_FAILURE                           109\n# define TS_R_THERE_MUST_BE_ONE_SIGNER                    110\n# define TS_R_TIME_SYSCALL_ERROR                          122\n# define TS_R_TOKEN_NOT_PRESENT                           130\n# define TS_R_TOKEN_PRESENT                               131\n# define TS_R_TSA_NAME_MISMATCH                           111\n# define TS_R_TSA_UNTRUSTED                               112\n# define TS_R_TST_INFO_SETUP_ERROR                        123\n# define TS_R_TS_DATASIGN                                 124\n# define TS_R_UNACCEPTABLE_POLICY                         125\n# define TS_R_UNSUPPORTED_MD_ALGORITHM                    126\n# define TS_R_UNSUPPORTED_VERSION                         113\n# define TS_R_WRONG_CONTENT_TYPE                          114\n\n#ifdef  __cplusplus\n}\n#endif\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/x86_64/include/openssl/txt_db.h",
    "content": "/* crypto/txt_db/txt_db.h */\n/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)\n * All rights reserved.\n *\n * This package is an SSL implementation written\n * by Eric Young (eay@cryptsoft.com).\n * The implementation was written so as to conform with Netscapes SSL.\n *\n * This library is free for commercial and non-commercial use as long as\n * the following conditions are aheared to.  The following conditions\n * apply to all code found in this distribution, be it the RC4, RSA,\n * lhash, DES, etc., code; not just the SSL code.  The SSL documentation\n * included with this distribution is covered by the same copyright terms\n * except that the holder is Tim Hudson (tjh@cryptsoft.com).\n *\n * Copyright remains Eric Young's, and as such any Copyright notices in\n * the code are not to be removed.\n * If this package is used in a product, Eric Young should be given attribution\n * as the author of the parts of the library used.\n * This can be in the form of a textual message at program startup or\n * in documentation (online or textual) provided with the package.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the copyright\n *    notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in the\n *    documentation and/or other materials provided with the distribution.\n * 3. All advertising materials mentioning features or use of this software\n *    must display the following acknowledgement:\n *    \"This product includes cryptographic software written by\n *     Eric Young (eay@cryptsoft.com)\"\n *    The word 'cryptographic' can be left out if the rouines from the library\n *    being used are not cryptographic related :-).\n * 4. If you include any Windows specific code (or a derivative thereof) from\n *    the apps directory (application code) you must include an acknowledgement:\n *    \"This product includes software written by Tim Hudson (tjh@cryptsoft.com)\"\n *\n * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n * SUCH DAMAGE.\n *\n * The licence and distribution terms for any publically available version or\n * derivative of this code cannot be changed.  i.e. this code cannot simply be\n * copied and put under another distribution licence\n * [including the GNU Public Licence.]\n */\n\n#ifndef HEADER_TXT_DB_H\n# define HEADER_TXT_DB_H\n\n# include <openssl/opensslconf.h>\n# ifndef OPENSSL_NO_BIO\n#  include <openssl/bio.h>\n# endif\n# include <openssl/stack.h>\n# include <openssl/lhash.h>\n\n# define DB_ERROR_OK                     0\n# define DB_ERROR_MALLOC                 1\n# define DB_ERROR_INDEX_CLASH            2\n# define DB_ERROR_INDEX_OUT_OF_RANGE     3\n# define DB_ERROR_NO_INDEX               4\n# define DB_ERROR_INSERT_INDEX_CLASH     5\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\ntypedef OPENSSL_STRING *OPENSSL_PSTRING;\nDECLARE_SPECIAL_STACK_OF(OPENSSL_PSTRING, OPENSSL_STRING)\n\ntypedef struct txt_db_st {\n    int num_fields;\n    STACK_OF(OPENSSL_PSTRING) *data;\n    LHASH_OF(OPENSSL_STRING) **index;\n    int (**qual) (OPENSSL_STRING *);\n    long error;\n    long arg1;\n    long arg2;\n    OPENSSL_STRING *arg_row;\n} TXT_DB;\n\n# ifndef OPENSSL_NO_BIO\nTXT_DB *TXT_DB_read(BIO *in, int num);\nlong TXT_DB_write(BIO *out, TXT_DB *db);\n# else\nTXT_DB *TXT_DB_read(char *in, int num);\nlong TXT_DB_write(char *out, TXT_DB *db);\n# endif\nint TXT_DB_create_index(TXT_DB *db, int field, int (*qual) (OPENSSL_STRING *),\n                        LHASH_HASH_FN_TYPE hash, LHASH_COMP_FN_TYPE cmp);\nvoid TXT_DB_free(TXT_DB *db);\nOPENSSL_STRING *TXT_DB_get_by_index(TXT_DB *db, int idx,\n                                    OPENSSL_STRING *value);\nint TXT_DB_insert(TXT_DB *db, OPENSSL_STRING *value);\n\n#ifdef  __cplusplus\n}\n#endif\n\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/x86_64/include/openssl/ui.h",
    "content": "/* crypto/ui/ui.h */\n/*\n * Written by Richard Levitte (richard@levitte.org) for the OpenSSL project\n * 2001.\n */\n/* ====================================================================\n * Copyright (c) 2001 The OpenSSL Project.  All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n *\n * 1. Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n *\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in\n *    the documentation and/or other materials provided with the\n *    distribution.\n *\n * 3. All advertising materials mentioning features or use of this\n *    software must display the following acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit. (http://www.openssl.org/)\"\n *\n * 4. The names \"OpenSSL Toolkit\" and \"OpenSSL Project\" must not be used to\n *    endorse or promote products derived from this software without\n *    prior written permission. For written permission, please contact\n *    openssl-core@openssl.org.\n *\n * 5. Products derived from this software may not be called \"OpenSSL\"\n *    nor may \"OpenSSL\" appear in their names without prior written\n *    permission of the OpenSSL Project.\n *\n * 6. Redistributions of any form whatsoever must retain the following\n *    acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit (http://www.openssl.org/)\"\n *\n * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY\n * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\n * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR\n * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\n * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,\n * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED\n * OF THE POSSIBILITY OF SUCH DAMAGE.\n * ====================================================================\n *\n * This product includes cryptographic software written by Eric Young\n * (eay@cryptsoft.com).  This product includes software written by Tim\n * Hudson (tjh@cryptsoft.com).\n *\n */\n\n#ifndef HEADER_UI_H\n# define HEADER_UI_H\n\n# ifndef OPENSSL_NO_DEPRECATED\n#  include <openssl/crypto.h>\n# endif\n# include <openssl/safestack.h>\n# include <openssl/ossl_typ.h>\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n/* Declared already in ossl_typ.h */\n/* typedef struct ui_st UI; */\n/* typedef struct ui_method_st UI_METHOD; */\n\n/*\n * All the following functions return -1 or NULL on error and in some cases\n * (UI_process()) -2 if interrupted or in some other way cancelled. When\n * everything is fine, they return 0, a positive value or a non-NULL pointer,\n * all depending on their purpose.\n */\n\n/* Creators and destructor.   */\nUI *UI_new(void);\nUI *UI_new_method(const UI_METHOD *method);\nvoid UI_free(UI *ui);\n\n/*-\n   The following functions are used to add strings to be printed and prompt\n   strings to prompt for data.  The names are UI_{add,dup}_<function>_string\n   and UI_{add,dup}_input_boolean.\n\n   UI_{add,dup}_<function>_string have the following meanings:\n        add     add a text or prompt string.  The pointers given to these\n                functions are used verbatim, no copying is done.\n        dup     make a copy of the text or prompt string, then add the copy\n                to the collection of strings in the user interface.\n        <function>\n                The function is a name for the functionality that the given\n                string shall be used for.  It can be one of:\n                        input   use the string as data prompt.\n                        verify  use the string as verification prompt.  This\n                                is used to verify a previous input.\n                        info    use the string for informational output.\n                        error   use the string for error output.\n   Honestly, there's currently no difference between info and error for the\n   moment.\n\n   UI_{add,dup}_input_boolean have the same semantics for \"add\" and \"dup\",\n   and are typically used when one wants to prompt for a yes/no response.\n\n   All of the functions in this group take a UI and a prompt string.\n   The string input and verify addition functions also take a flag argument,\n   a buffer for the result to end up with, a minimum input size and a maximum\n   input size (the result buffer MUST be large enough to be able to contain\n   the maximum number of characters).  Additionally, the verify addition\n   functions takes another buffer to compare the result against.\n   The boolean input functions take an action description string (which should\n   be safe to ignore if the expected user action is obvious, for example with\n   a dialog box with an OK button and a Cancel button), a string of acceptable\n   characters to mean OK and to mean Cancel.  The two last strings are checked\n   to make sure they don't have common characters.  Additionally, the same\n   flag argument as for the string input is taken, as well as a result buffer.\n   The result buffer is required to be at least one byte long.  Depending on\n   the answer, the first character from the OK or the Cancel character strings\n   will be stored in the first byte of the result buffer.  No NUL will be\n   added, so the result is *not* a string.\n\n   On success, the all return an index of the added information.  That index\n   is usefull when retrieving results with UI_get0_result(). */\nint UI_add_input_string(UI *ui, const char *prompt, int flags,\n                        char *result_buf, int minsize, int maxsize);\nint UI_dup_input_string(UI *ui, const char *prompt, int flags,\n                        char *result_buf, int minsize, int maxsize);\nint UI_add_verify_string(UI *ui, const char *prompt, int flags,\n                         char *result_buf, int minsize, int maxsize,\n                         const char *test_buf);\nint UI_dup_verify_string(UI *ui, const char *prompt, int flags,\n                         char *result_buf, int minsize, int maxsize,\n                         const char *test_buf);\nint UI_add_input_boolean(UI *ui, const char *prompt, const char *action_desc,\n                         const char *ok_chars, const char *cancel_chars,\n                         int flags, char *result_buf);\nint UI_dup_input_boolean(UI *ui, const char *prompt, const char *action_desc,\n                         const char *ok_chars, const char *cancel_chars,\n                         int flags, char *result_buf);\nint UI_add_info_string(UI *ui, const char *text);\nint UI_dup_info_string(UI *ui, const char *text);\nint UI_add_error_string(UI *ui, const char *text);\nint UI_dup_error_string(UI *ui, const char *text);\n\n/* These are the possible flags.  They can be or'ed together. */\n/* Use to have echoing of input */\n# define UI_INPUT_FLAG_ECHO              0x01\n/*\n * Use a default password.  Where that password is found is completely up to\n * the application, it might for example be in the user data set with\n * UI_add_user_data().  It is not recommended to have more than one input in\n * each UI being marked with this flag, or the application might get\n * confused.\n */\n# define UI_INPUT_FLAG_DEFAULT_PWD       0x02\n\n/*-\n * The user of these routines may want to define flags of their own.  The core\n * UI won't look at those, but will pass them on to the method routines.  They\n * must use higher bits so they don't get confused with the UI bits above.\n * UI_INPUT_FLAG_USER_BASE tells which is the lowest bit to use.  A good\n * example of use is this:\n *\n *    #define MY_UI_FLAG1       (0x01 << UI_INPUT_FLAG_USER_BASE)\n *\n*/\n# define UI_INPUT_FLAG_USER_BASE 16\n\n/*-\n * The following function helps construct a prompt.  object_desc is a\n * textual short description of the object, for example \"pass phrase\",\n * and object_name is the name of the object (might be a card name or\n * a file name.\n * The returned string shall always be allocated on the heap with\n * OPENSSL_malloc(), and need to be free'd with OPENSSL_free().\n *\n * If the ui_method doesn't contain a pointer to a user-defined prompt\n * constructor, a default string is built, looking like this:\n *\n *       \"Enter {object_desc} for {object_name}:\"\n *\n * So, if object_desc has the value \"pass phrase\" and object_name has\n * the value \"foo.key\", the resulting string is:\n *\n *       \"Enter pass phrase for foo.key:\"\n*/\nchar *UI_construct_prompt(UI *ui_method,\n                          const char *object_desc, const char *object_name);\n\n/*\n * The following function is used to store a pointer to user-specific data.\n * Any previous such pointer will be returned and replaced.\n *\n * For callback purposes, this function makes a lot more sense than using\n * ex_data, since the latter requires that different parts of OpenSSL or\n * applications share the same ex_data index.\n *\n * Note that the UI_OpenSSL() method completely ignores the user data. Other\n * methods may not, however.\n */\nvoid *UI_add_user_data(UI *ui, void *user_data);\n/* We need a user data retrieving function as well.  */\nvoid *UI_get0_user_data(UI *ui);\n\n/* Return the result associated with a prompt given with the index i. */\nconst char *UI_get0_result(UI *ui, int i);\n\n/* When all strings have been added, process the whole thing. */\nint UI_process(UI *ui);\n\n/*\n * Give a user interface parametrised control commands.  This can be used to\n * send down an integer, a data pointer or a function pointer, as well as be\n * used to get information from a UI.\n */\nint UI_ctrl(UI *ui, int cmd, long i, void *p, void (*f) (void));\n\n/* The commands */\n/*\n * Use UI_CONTROL_PRINT_ERRORS with the value 1 to have UI_process print the\n * OpenSSL error stack before printing any info or added error messages and\n * before any prompting.\n */\n# define UI_CTRL_PRINT_ERRORS            1\n/*\n * Check if a UI_process() is possible to do again with the same instance of\n * a user interface.  This makes UI_ctrl() return 1 if it is redoable, and 0\n * if not.\n */\n# define UI_CTRL_IS_REDOABLE             2\n\n/* Some methods may use extra data */\n# define UI_set_app_data(s,arg)         UI_set_ex_data(s,0,arg)\n# define UI_get_app_data(s)             UI_get_ex_data(s,0)\nint UI_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func,\n                        CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func);\nint UI_set_ex_data(UI *r, int idx, void *arg);\nvoid *UI_get_ex_data(UI *r, int idx);\n\n/* Use specific methods instead of the built-in one */\nvoid UI_set_default_method(const UI_METHOD *meth);\nconst UI_METHOD *UI_get_default_method(void);\nconst UI_METHOD *UI_get_method(UI *ui);\nconst UI_METHOD *UI_set_method(UI *ui, const UI_METHOD *meth);\n\n/* The method with all the built-in thingies */\nUI_METHOD *UI_OpenSSL(void);\n\n/* ---------- For method writers ---------- */\n/*-\n   A method contains a number of functions that implement the low level\n   of the User Interface.  The functions are:\n\n        an opener       This function starts a session, maybe by opening\n                        a channel to a tty, or by opening a window.\n        a writer        This function is called to write a given string,\n                        maybe to the tty, maybe as a field label in a\n                        window.\n        a flusher       This function is called to flush everything that\n                        has been output so far.  It can be used to actually\n                        display a dialog box after it has been built.\n        a reader        This function is called to read a given prompt,\n                        maybe from the tty, maybe from a field in a\n                        window.  Note that it's called wth all string\n                        structures, not only the prompt ones, so it must\n                        check such things itself.\n        a closer        This function closes the session, maybe by closing\n                        the channel to the tty, or closing the window.\n\n   All these functions are expected to return:\n\n        0       on error.\n        1       on success.\n        -1      on out-of-band events, for example if some prompting has\n                been canceled (by pressing Ctrl-C, for example).  This is\n                only checked when returned by the flusher or the reader.\n\n   The way this is used, the opener is first called, then the writer for all\n   strings, then the flusher, then the reader for all strings and finally the\n   closer.  Note that if you want to prompt from a terminal or other command\n   line interface, the best is to have the reader also write the prompts\n   instead of having the writer do it.  If you want to prompt from a dialog\n   box, the writer can be used to build up the contents of the box, and the\n   flusher to actually display the box and run the event loop until all data\n   has been given, after which the reader only grabs the given data and puts\n   them back into the UI strings.\n\n   All method functions take a UI as argument.  Additionally, the writer and\n   the reader take a UI_STRING.\n*/\n\n/*\n * The UI_STRING type is the data structure that contains all the needed info\n * about a string or a prompt, including test data for a verification prompt.\n */\ntypedef struct ui_string_st UI_STRING;\nDECLARE_STACK_OF(UI_STRING)\n\n/*\n * The different types of strings that are currently supported. This is only\n * needed by method authors.\n */\nenum UI_string_types {\n    UIT_NONE = 0,\n    UIT_PROMPT,                 /* Prompt for a string */\n    UIT_VERIFY,                 /* Prompt for a string and verify */\n    UIT_BOOLEAN,                /* Prompt for a yes/no response */\n    UIT_INFO,                   /* Send info to the user */\n    UIT_ERROR                   /* Send an error message to the user */\n};\n\n/* Create and manipulate methods */\nUI_METHOD *UI_create_method(char *name);\nvoid UI_destroy_method(UI_METHOD *ui_method);\nint UI_method_set_opener(UI_METHOD *method, int (*opener) (UI *ui));\nint UI_method_set_writer(UI_METHOD *method,\n                         int (*writer) (UI *ui, UI_STRING *uis));\nint UI_method_set_flusher(UI_METHOD *method, int (*flusher) (UI *ui));\nint UI_method_set_reader(UI_METHOD *method,\n                         int (*reader) (UI *ui, UI_STRING *uis));\nint UI_method_set_closer(UI_METHOD *method, int (*closer) (UI *ui));\nint UI_method_set_prompt_constructor(UI_METHOD *method,\n                                     char *(*prompt_constructor) (UI *ui,\n                                                                  const char\n                                                                  *object_desc,\n                                                                  const char\n                                                                  *object_name));\nint (*UI_method_get_opener(UI_METHOD *method)) (UI *);\nint (*UI_method_get_writer(UI_METHOD *method)) (UI *, UI_STRING *);\nint (*UI_method_get_flusher(UI_METHOD *method)) (UI *);\nint (*UI_method_get_reader(UI_METHOD *method)) (UI *, UI_STRING *);\nint (*UI_method_get_closer(UI_METHOD *method)) (UI *);\nchar *(*UI_method_get_prompt_constructor(UI_METHOD *method)) (UI *,\n                                                              const char *,\n                                                              const char *);\n\n/*\n * The following functions are helpers for method writers to access relevant\n * data from a UI_STRING.\n */\n\n/* Return type of the UI_STRING */\nenum UI_string_types UI_get_string_type(UI_STRING *uis);\n/* Return input flags of the UI_STRING */\nint UI_get_input_flags(UI_STRING *uis);\n/* Return the actual string to output (the prompt, info or error) */\nconst char *UI_get0_output_string(UI_STRING *uis);\n/*\n * Return the optional action string to output (the boolean promtp\n * instruction)\n */\nconst char *UI_get0_action_string(UI_STRING *uis);\n/* Return the result of a prompt */\nconst char *UI_get0_result_string(UI_STRING *uis);\n/*\n * Return the string to test the result against.  Only useful with verifies.\n */\nconst char *UI_get0_test_string(UI_STRING *uis);\n/* Return the required minimum size of the result */\nint UI_get_result_minsize(UI_STRING *uis);\n/* Return the required maximum size of the result */\nint UI_get_result_maxsize(UI_STRING *uis);\n/* Set the result of a UI_STRING. */\nint UI_set_result(UI *ui, UI_STRING *uis, const char *result);\n\n/* A couple of popular utility functions */\nint UI_UTIL_read_pw_string(char *buf, int length, const char *prompt,\n                           int verify);\nint UI_UTIL_read_pw(char *buf, char *buff, int size, const char *prompt,\n                    int verify);\n\n/* BEGIN ERROR CODES */\n/*\n * The following lines are auto generated by the script mkerr.pl. Any changes\n * made after this point may be overwritten when the script is next run.\n */\nvoid ERR_load_UI_strings(void);\n\n/* Error codes for the UI functions. */\n\n/* Function codes. */\n# define UI_F_GENERAL_ALLOCATE_BOOLEAN                    108\n# define UI_F_GENERAL_ALLOCATE_PROMPT                     109\n# define UI_F_GENERAL_ALLOCATE_STRING                     100\n# define UI_F_UI_CTRL                                     111\n# define UI_F_UI_DUP_ERROR_STRING                         101\n# define UI_F_UI_DUP_INFO_STRING                          102\n# define UI_F_UI_DUP_INPUT_BOOLEAN                        110\n# define UI_F_UI_DUP_INPUT_STRING                         103\n# define UI_F_UI_DUP_VERIFY_STRING                        106\n# define UI_F_UI_GET0_RESULT                              107\n# define UI_F_UI_NEW_METHOD                               104\n# define UI_F_UI_SET_RESULT                               105\n\n/* Reason codes. */\n# define UI_R_COMMON_OK_AND_CANCEL_CHARACTERS             104\n# define UI_R_INDEX_TOO_LARGE                             102\n# define UI_R_INDEX_TOO_SMALL                             103\n# define UI_R_NO_RESULT_BUFFER                            105\n# define UI_R_RESULT_TOO_LARGE                            100\n# define UI_R_RESULT_TOO_SMALL                            101\n# define UI_R_UNKNOWN_CONTROL_COMMAND                     106\n\n#ifdef  __cplusplus\n}\n#endif\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/x86_64/include/openssl/ui_compat.h",
    "content": "/* crypto/ui/ui.h */\n/*\n * Written by Richard Levitte (richard@levitte.org) for the OpenSSL project\n * 2001.\n */\n/* ====================================================================\n * Copyright (c) 2001 The OpenSSL Project.  All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n *\n * 1. Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n *\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in\n *    the documentation and/or other materials provided with the\n *    distribution.\n *\n * 3. All advertising materials mentioning features or use of this\n *    software must display the following acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit. (http://www.openssl.org/)\"\n *\n * 4. The names \"OpenSSL Toolkit\" and \"OpenSSL Project\" must not be used to\n *    endorse or promote products derived from this software without\n *    prior written permission. For written permission, please contact\n *    openssl-core@openssl.org.\n *\n * 5. Products derived from this software may not be called \"OpenSSL\"\n *    nor may \"OpenSSL\" appear in their names without prior written\n *    permission of the OpenSSL Project.\n *\n * 6. Redistributions of any form whatsoever must retain the following\n *    acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit (http://www.openssl.org/)\"\n *\n * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY\n * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\n * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR\n * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\n * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,\n * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED\n * OF THE POSSIBILITY OF SUCH DAMAGE.\n * ====================================================================\n *\n * This product includes cryptographic software written by Eric Young\n * (eay@cryptsoft.com).  This product includes software written by Tim\n * Hudson (tjh@cryptsoft.com).\n *\n */\n\n#ifndef HEADER_UI_COMPAT_H\n# define HEADER_UI_COMPAT_H\n\n# include <openssl/opensslconf.h>\n# include <openssl/ui.h>\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n/*\n * The following functions were previously part of the DES section, and are\n * provided here for backward compatibility reasons.\n */\n\n# define des_read_pw_string(b,l,p,v) \\\n        _ossl_old_des_read_pw_string((b),(l),(p),(v))\n# define des_read_pw(b,bf,s,p,v) \\\n        _ossl_old_des_read_pw((b),(bf),(s),(p),(v))\n\nint _ossl_old_des_read_pw_string(char *buf, int length, const char *prompt,\n                                 int verify);\nint _ossl_old_des_read_pw(char *buf, char *buff, int size, const char *prompt,\n                          int verify);\n\n#ifdef  __cplusplus\n}\n#endif\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/x86_64/include/openssl/whrlpool.h",
    "content": "#ifndef HEADER_WHRLPOOL_H\n# define HEADER_WHRLPOOL_H\n\n# include <openssl/e_os2.h>\n# include <stddef.h>\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n# define WHIRLPOOL_DIGEST_LENGTH (512/8)\n# define WHIRLPOOL_BBLOCK        512\n# define WHIRLPOOL_COUNTER       (256/8)\n\ntypedef struct {\n    union {\n        unsigned char c[WHIRLPOOL_DIGEST_LENGTH];\n        /* double q is here to ensure 64-bit alignment */\n        double q[WHIRLPOOL_DIGEST_LENGTH / sizeof(double)];\n    } H;\n    unsigned char data[WHIRLPOOL_BBLOCK / 8];\n    unsigned int bitoff;\n    size_t bitlen[WHIRLPOOL_COUNTER / sizeof(size_t)];\n} WHIRLPOOL_CTX;\n\n# ifndef OPENSSL_NO_WHIRLPOOL\n#  ifdef OPENSSL_FIPS\nint private_WHIRLPOOL_Init(WHIRLPOOL_CTX *c);\n#  endif\nint WHIRLPOOL_Init(WHIRLPOOL_CTX *c);\nint WHIRLPOOL_Update(WHIRLPOOL_CTX *c, const void *inp, size_t bytes);\nvoid WHIRLPOOL_BitUpdate(WHIRLPOOL_CTX *c, const void *inp, size_t bits);\nint WHIRLPOOL_Final(unsigned char *md, WHIRLPOOL_CTX *c);\nunsigned char *WHIRLPOOL(const void *inp, size_t bytes, unsigned char *md);\n# endif\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/x86_64/include/openssl/x509.h",
    "content": "/* crypto/x509/x509.h */\n/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)\n * All rights reserved.\n *\n * This package is an SSL implementation written\n * by Eric Young (eay@cryptsoft.com).\n * The implementation was written so as to conform with Netscapes SSL.\n *\n * This library is free for commercial and non-commercial use as long as\n * the following conditions are aheared to.  The following conditions\n * apply to all code found in this distribution, be it the RC4, RSA,\n * lhash, DES, etc., code; not just the SSL code.  The SSL documentation\n * included with this distribution is covered by the same copyright terms\n * except that the holder is Tim Hudson (tjh@cryptsoft.com).\n *\n * Copyright remains Eric Young's, and as such any Copyright notices in\n * the code are not to be removed.\n * If this package is used in a product, Eric Young should be given attribution\n * as the author of the parts of the library used.\n * This can be in the form of a textual message at program startup or\n * in documentation (online or textual) provided with the package.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the copyright\n *    notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in the\n *    documentation and/or other materials provided with the distribution.\n * 3. All advertising materials mentioning features or use of this software\n *    must display the following acknowledgement:\n *    \"This product includes cryptographic software written by\n *     Eric Young (eay@cryptsoft.com)\"\n *    The word 'cryptographic' can be left out if the rouines from the library\n *    being used are not cryptographic related :-).\n * 4. If you include any Windows specific code (or a derivative thereof) from\n *    the apps directory (application code) you must include an acknowledgement:\n *    \"This product includes software written by Tim Hudson (tjh@cryptsoft.com)\"\n *\n * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n * SUCH DAMAGE.\n *\n * The licence and distribution terms for any publically available version or\n * derivative of this code cannot be changed.  i.e. this code cannot simply be\n * copied and put under another distribution licence\n * [including the GNU Public Licence.]\n */\n/* ====================================================================\n * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED.\n * ECDH support in OpenSSL originally developed by\n * SUN MICROSYSTEMS, INC., and contributed to the OpenSSL project.\n */\n\n#ifndef HEADER_X509_H\n# define HEADER_X509_H\n\n# include <openssl/e_os2.h>\n# include <openssl/symhacks.h>\n# ifndef OPENSSL_NO_BUFFER\n#  include <openssl/buffer.h>\n# endif\n# ifndef OPENSSL_NO_EVP\n#  include <openssl/evp.h>\n# endif\n# ifndef OPENSSL_NO_BIO\n#  include <openssl/bio.h>\n# endif\n# include <openssl/stack.h>\n# include <openssl/asn1.h>\n# include <openssl/safestack.h>\n\n# ifndef OPENSSL_NO_EC\n#  include <openssl/ec.h>\n# endif\n\n# ifndef OPENSSL_NO_ECDSA\n#  include <openssl/ecdsa.h>\n# endif\n\n# ifndef OPENSSL_NO_ECDH\n#  include <openssl/ecdh.h>\n# endif\n\n# ifndef OPENSSL_NO_DEPRECATED\n#  ifndef OPENSSL_NO_RSA\n#   include <openssl/rsa.h>\n#  endif\n#  ifndef OPENSSL_NO_DSA\n#   include <openssl/dsa.h>\n#  endif\n#  ifndef OPENSSL_NO_DH\n#   include <openssl/dh.h>\n#  endif\n# endif\n\n# ifndef OPENSSL_NO_SHA\n#  include <openssl/sha.h>\n# endif\n# include <openssl/ossl_typ.h>\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n# ifdef OPENSSL_SYS_WIN32\n/* Under Win32 these are defined in wincrypt.h */\n#  undef X509_NAME\n#  undef X509_CERT_PAIR\n#  undef X509_EXTENSIONS\n# endif\n\n# define X509_FILETYPE_PEM       1\n# define X509_FILETYPE_ASN1      2\n# define X509_FILETYPE_DEFAULT   3\n\n# define X509v3_KU_DIGITAL_SIGNATURE     0x0080\n# define X509v3_KU_NON_REPUDIATION       0x0040\n# define X509v3_KU_KEY_ENCIPHERMENT      0x0020\n# define X509v3_KU_DATA_ENCIPHERMENT     0x0010\n# define X509v3_KU_KEY_AGREEMENT         0x0008\n# define X509v3_KU_KEY_CERT_SIGN         0x0004\n# define X509v3_KU_CRL_SIGN              0x0002\n# define X509v3_KU_ENCIPHER_ONLY         0x0001\n# define X509v3_KU_DECIPHER_ONLY         0x8000\n# define X509v3_KU_UNDEF                 0xffff\n\ntypedef struct X509_objects_st {\n    int nid;\n    int (*a2i) (void);\n    int (*i2a) (void);\n} X509_OBJECTS;\n\nstruct X509_algor_st {\n    ASN1_OBJECT *algorithm;\n    ASN1_TYPE *parameter;\n} /* X509_ALGOR */ ;\n\nDECLARE_ASN1_SET_OF(X509_ALGOR)\n\ntypedef STACK_OF(X509_ALGOR) X509_ALGORS;\n\ntypedef struct X509_val_st {\n    ASN1_TIME *notBefore;\n    ASN1_TIME *notAfter;\n} X509_VAL;\n\nstruct X509_pubkey_st {\n    X509_ALGOR *algor;\n    ASN1_BIT_STRING *public_key;\n    EVP_PKEY *pkey;\n};\n\ntypedef struct X509_sig_st {\n    X509_ALGOR *algor;\n    ASN1_OCTET_STRING *digest;\n} X509_SIG;\n\ntypedef struct X509_name_entry_st {\n    ASN1_OBJECT *object;\n    ASN1_STRING *value;\n    int set;\n    int size;                   /* temp variable */\n} X509_NAME_ENTRY;\n\nDECLARE_STACK_OF(X509_NAME_ENTRY)\nDECLARE_ASN1_SET_OF(X509_NAME_ENTRY)\n\n/* we always keep X509_NAMEs in 2 forms. */\nstruct X509_name_st {\n    STACK_OF(X509_NAME_ENTRY) *entries;\n    int modified;               /* true if 'bytes' needs to be built */\n# ifndef OPENSSL_NO_BUFFER\n    BUF_MEM *bytes;\n# else\n    char *bytes;\n# endif\n/*      unsigned long hash; Keep the hash around for lookups */\n    unsigned char *canon_enc;\n    int canon_enclen;\n} /* X509_NAME */ ;\n\nDECLARE_STACK_OF(X509_NAME)\n\n# define X509_EX_V_NETSCAPE_HACK         0x8000\n# define X509_EX_V_INIT                  0x0001\ntypedef struct X509_extension_st {\n    ASN1_OBJECT *object;\n    ASN1_BOOLEAN critical;\n    ASN1_OCTET_STRING *value;\n} X509_EXTENSION;\n\ntypedef STACK_OF(X509_EXTENSION) X509_EXTENSIONS;\n\nDECLARE_STACK_OF(X509_EXTENSION)\nDECLARE_ASN1_SET_OF(X509_EXTENSION)\n\n/* a sequence of these are used */\ntypedef struct x509_attributes_st {\n    ASN1_OBJECT *object;\n    int single;                 /* 0 for a set, 1 for a single item (which is\n                                 * wrong) */\n    union {\n        char *ptr;\n        /*\n         * 0\n         */ STACK_OF(ASN1_TYPE) *set;\n        /*\n         * 1\n         */ ASN1_TYPE *single;\n    } value;\n} X509_ATTRIBUTE;\n\nDECLARE_STACK_OF(X509_ATTRIBUTE)\nDECLARE_ASN1_SET_OF(X509_ATTRIBUTE)\n\ntypedef struct X509_req_info_st {\n    ASN1_ENCODING enc;\n    ASN1_INTEGER *version;\n    X509_NAME *subject;\n    X509_PUBKEY *pubkey;\n    /*  d=2 hl=2 l=  0 cons: cont: 00 */\n    STACK_OF(X509_ATTRIBUTE) *attributes; /* [ 0 ] */\n} X509_REQ_INFO;\n\ntypedef struct X509_req_st {\n    X509_REQ_INFO *req_info;\n    X509_ALGOR *sig_alg;\n    ASN1_BIT_STRING *signature;\n    int references;\n} X509_REQ;\n\ntypedef struct x509_cinf_st {\n    ASN1_INTEGER *version;      /* [ 0 ] default of v1 */\n    ASN1_INTEGER *serialNumber;\n    X509_ALGOR *signature;\n    X509_NAME *issuer;\n    X509_VAL *validity;\n    X509_NAME *subject;\n    X509_PUBKEY *key;\n    ASN1_BIT_STRING *issuerUID; /* [ 1 ] optional in v2 */\n    ASN1_BIT_STRING *subjectUID; /* [ 2 ] optional in v2 */\n    STACK_OF(X509_EXTENSION) *extensions; /* [ 3 ] optional in v3 */\n    ASN1_ENCODING enc;\n} X509_CINF;\n\n/*\n * This stuff is certificate \"auxiliary info\" it contains details which are\n * useful in certificate stores and databases. When used this is tagged onto\n * the end of the certificate itself\n */\n\ntypedef struct x509_cert_aux_st {\n    STACK_OF(ASN1_OBJECT) *trust; /* trusted uses */\n    STACK_OF(ASN1_OBJECT) *reject; /* rejected uses */\n    ASN1_UTF8STRING *alias;     /* \"friendly name\" */\n    ASN1_OCTET_STRING *keyid;   /* key id of private key */\n    STACK_OF(X509_ALGOR) *other; /* other unspecified info */\n} X509_CERT_AUX;\n\nstruct x509_st {\n    X509_CINF *cert_info;\n    X509_ALGOR *sig_alg;\n    ASN1_BIT_STRING *signature;\n    int valid;\n    int references;\n    char *name;\n    CRYPTO_EX_DATA ex_data;\n    /* These contain copies of various extension values */\n    long ex_pathlen;\n    long ex_pcpathlen;\n    unsigned long ex_flags;\n    unsigned long ex_kusage;\n    unsigned long ex_xkusage;\n    unsigned long ex_nscert;\n    ASN1_OCTET_STRING *skid;\n    AUTHORITY_KEYID *akid;\n    X509_POLICY_CACHE *policy_cache;\n    STACK_OF(DIST_POINT) *crldp;\n    STACK_OF(GENERAL_NAME) *altname;\n    NAME_CONSTRAINTS *nc;\n# ifndef OPENSSL_NO_RFC3779\n    STACK_OF(IPAddressFamily) *rfc3779_addr;\n    struct ASIdentifiers_st *rfc3779_asid;\n# endif\n# ifndef OPENSSL_NO_SHA\n    unsigned char sha1_hash[SHA_DIGEST_LENGTH];\n# endif\n    X509_CERT_AUX *aux;\n} /* X509 */ ;\n\nDECLARE_STACK_OF(X509)\nDECLARE_ASN1_SET_OF(X509)\n\n/* This is used for a table of trust checking functions */\n\ntypedef struct x509_trust_st {\n    int trust;\n    int flags;\n    int (*check_trust) (struct x509_trust_st *, X509 *, int);\n    char *name;\n    int arg1;\n    void *arg2;\n} X509_TRUST;\n\nDECLARE_STACK_OF(X509_TRUST)\n\ntypedef struct x509_cert_pair_st {\n    X509 *forward;\n    X509 *reverse;\n} X509_CERT_PAIR;\n\n/* standard trust ids */\n\n# define X509_TRUST_DEFAULT      -1/* Only valid in purpose settings */\n\n# define X509_TRUST_COMPAT       1\n# define X509_TRUST_SSL_CLIENT   2\n# define X509_TRUST_SSL_SERVER   3\n# define X509_TRUST_EMAIL        4\n# define X509_TRUST_OBJECT_SIGN  5\n# define X509_TRUST_OCSP_SIGN    6\n# define X509_TRUST_OCSP_REQUEST 7\n# define X509_TRUST_TSA          8\n\n/* Keep these up to date! */\n# define X509_TRUST_MIN          1\n# define X509_TRUST_MAX          8\n\n/* trust_flags values */\n# define X509_TRUST_DYNAMIC      1\n# define X509_TRUST_DYNAMIC_NAME 2\n\n/* check_trust return codes */\n\n# define X509_TRUST_TRUSTED      1\n# define X509_TRUST_REJECTED     2\n# define X509_TRUST_UNTRUSTED    3\n\n/* Flags for X509_print_ex() */\n\n# define X509_FLAG_COMPAT                0\n# define X509_FLAG_NO_HEADER             1L\n# define X509_FLAG_NO_VERSION            (1L << 1)\n# define X509_FLAG_NO_SERIAL             (1L << 2)\n# define X509_FLAG_NO_SIGNAME            (1L << 3)\n# define X509_FLAG_NO_ISSUER             (1L << 4)\n# define X509_FLAG_NO_VALIDITY           (1L << 5)\n# define X509_FLAG_NO_SUBJECT            (1L << 6)\n# define X509_FLAG_NO_PUBKEY             (1L << 7)\n# define X509_FLAG_NO_EXTENSIONS         (1L << 8)\n# define X509_FLAG_NO_SIGDUMP            (1L << 9)\n# define X509_FLAG_NO_AUX                (1L << 10)\n# define X509_FLAG_NO_ATTRIBUTES         (1L << 11)\n# define X509_FLAG_NO_IDS                (1L << 12)\n\n/* Flags specific to X509_NAME_print_ex() */\n\n/* The field separator information */\n\n# define XN_FLAG_SEP_MASK        (0xf << 16)\n\n# define XN_FLAG_COMPAT          0/* Traditional SSLeay: use old\n                                   * X509_NAME_print */\n# define XN_FLAG_SEP_COMMA_PLUS  (1 << 16)/* RFC2253 ,+ */\n# define XN_FLAG_SEP_CPLUS_SPC   (2 << 16)/* ,+ spaced: more readable */\n# define XN_FLAG_SEP_SPLUS_SPC   (3 << 16)/* ;+ spaced */\n# define XN_FLAG_SEP_MULTILINE   (4 << 16)/* One line per field */\n\n# define XN_FLAG_DN_REV          (1 << 20)/* Reverse DN order */\n\n/* How the field name is shown */\n\n# define XN_FLAG_FN_MASK         (0x3 << 21)\n\n# define XN_FLAG_FN_SN           0/* Object short name */\n# define XN_FLAG_FN_LN           (1 << 21)/* Object long name */\n# define XN_FLAG_FN_OID          (2 << 21)/* Always use OIDs */\n# define XN_FLAG_FN_NONE         (3 << 21)/* No field names */\n\n# define XN_FLAG_SPC_EQ          (1 << 23)/* Put spaces round '=' */\n\n/*\n * This determines if we dump fields we don't recognise: RFC2253 requires\n * this.\n */\n\n# define XN_FLAG_DUMP_UNKNOWN_FIELDS (1 << 24)\n\n# define XN_FLAG_FN_ALIGN        (1 << 25)/* Align field names to 20\n                                           * characters */\n\n/* Complete set of RFC2253 flags */\n\n# define XN_FLAG_RFC2253 (ASN1_STRFLGS_RFC2253 | \\\n                        XN_FLAG_SEP_COMMA_PLUS | \\\n                        XN_FLAG_DN_REV | \\\n                        XN_FLAG_FN_SN | \\\n                        XN_FLAG_DUMP_UNKNOWN_FIELDS)\n\n/* readable oneline form */\n\n# define XN_FLAG_ONELINE (ASN1_STRFLGS_RFC2253 | \\\n                        ASN1_STRFLGS_ESC_QUOTE | \\\n                        XN_FLAG_SEP_CPLUS_SPC | \\\n                        XN_FLAG_SPC_EQ | \\\n                        XN_FLAG_FN_SN)\n\n/* readable multiline form */\n\n# define XN_FLAG_MULTILINE (ASN1_STRFLGS_ESC_CTRL | \\\n                        ASN1_STRFLGS_ESC_MSB | \\\n                        XN_FLAG_SEP_MULTILINE | \\\n                        XN_FLAG_SPC_EQ | \\\n                        XN_FLAG_FN_LN | \\\n                        XN_FLAG_FN_ALIGN)\n\nstruct x509_revoked_st {\n    ASN1_INTEGER *serialNumber;\n    ASN1_TIME *revocationDate;\n    STACK_OF(X509_EXTENSION) /* optional */ *extensions;\n    /* Set up if indirect CRL */\n    STACK_OF(GENERAL_NAME) *issuer;\n    /* Revocation reason */\n    int reason;\n    int sequence;               /* load sequence */\n};\n\nDECLARE_STACK_OF(X509_REVOKED)\nDECLARE_ASN1_SET_OF(X509_REVOKED)\n\ntypedef struct X509_crl_info_st {\n    ASN1_INTEGER *version;\n    X509_ALGOR *sig_alg;\n    X509_NAME *issuer;\n    ASN1_TIME *lastUpdate;\n    ASN1_TIME *nextUpdate;\n    STACK_OF(X509_REVOKED) *revoked;\n    STACK_OF(X509_EXTENSION) /* [0] */ *extensions;\n    ASN1_ENCODING enc;\n} X509_CRL_INFO;\n\nstruct X509_crl_st {\n    /* actual signature */\n    X509_CRL_INFO *crl;\n    X509_ALGOR *sig_alg;\n    ASN1_BIT_STRING *signature;\n    int references;\n    int flags;\n    /* Copies of various extensions */\n    AUTHORITY_KEYID *akid;\n    ISSUING_DIST_POINT *idp;\n    /* Convenient breakdown of IDP */\n    int idp_flags;\n    int idp_reasons;\n    /* CRL and base CRL numbers for delta processing */\n    ASN1_INTEGER *crl_number;\n    ASN1_INTEGER *base_crl_number;\n# ifndef OPENSSL_NO_SHA\n    unsigned char sha1_hash[SHA_DIGEST_LENGTH];\n# endif\n    STACK_OF(GENERAL_NAMES) *issuers;\n    const X509_CRL_METHOD *meth;\n    void *meth_data;\n} /* X509_CRL */ ;\n\nDECLARE_STACK_OF(X509_CRL)\nDECLARE_ASN1_SET_OF(X509_CRL)\n\ntypedef struct private_key_st {\n    int version;\n    /* The PKCS#8 data types */\n    X509_ALGOR *enc_algor;\n    ASN1_OCTET_STRING *enc_pkey; /* encrypted pub key */\n    /* When decrypted, the following will not be NULL */\n    EVP_PKEY *dec_pkey;\n    /* used to encrypt and decrypt */\n    int key_length;\n    char *key_data;\n    int key_free;               /* true if we should auto free key_data */\n    /* expanded version of 'enc_algor' */\n    EVP_CIPHER_INFO cipher;\n    int references;\n} X509_PKEY;\n\n# ifndef OPENSSL_NO_EVP\ntypedef struct X509_info_st {\n    X509 *x509;\n    X509_CRL *crl;\n    X509_PKEY *x_pkey;\n    EVP_CIPHER_INFO enc_cipher;\n    int enc_len;\n    char *enc_data;\n    int references;\n} X509_INFO;\n\nDECLARE_STACK_OF(X509_INFO)\n# endif\n\n/*\n * The next 2 structures and their 8 routines were sent to me by Pat Richard\n * <patr@x509.com> and are used to manipulate Netscapes spki structures -\n * useful if you are writing a CA web page\n */\ntypedef struct Netscape_spkac_st {\n    X509_PUBKEY *pubkey;\n    ASN1_IA5STRING *challenge;  /* challenge sent in atlas >= PR2 */\n} NETSCAPE_SPKAC;\n\ntypedef struct Netscape_spki_st {\n    NETSCAPE_SPKAC *spkac;      /* signed public key and challenge */\n    X509_ALGOR *sig_algor;\n    ASN1_BIT_STRING *signature;\n} NETSCAPE_SPKI;\n\n/* Netscape certificate sequence structure */\ntypedef struct Netscape_certificate_sequence {\n    ASN1_OBJECT *type;\n    STACK_OF(X509) *certs;\n} NETSCAPE_CERT_SEQUENCE;\n\n/*- Unused (and iv length is wrong)\ntypedef struct CBCParameter_st\n        {\n        unsigned char iv[8];\n        } CBC_PARAM;\n*/\n\n/* Password based encryption structure */\n\ntypedef struct PBEPARAM_st {\n    ASN1_OCTET_STRING *salt;\n    ASN1_INTEGER *iter;\n} PBEPARAM;\n\n/* Password based encryption V2 structures */\n\ntypedef struct PBE2PARAM_st {\n    X509_ALGOR *keyfunc;\n    X509_ALGOR *encryption;\n} PBE2PARAM;\n\ntypedef struct PBKDF2PARAM_st {\n/* Usually OCTET STRING but could be anything */\n    ASN1_TYPE *salt;\n    ASN1_INTEGER *iter;\n    ASN1_INTEGER *keylength;\n    X509_ALGOR *prf;\n} PBKDF2PARAM;\n\n/* PKCS#8 private key info structure */\n\nstruct pkcs8_priv_key_info_st {\n    /* Flag for various broken formats */\n    int broken;\n# define PKCS8_OK                0\n# define PKCS8_NO_OCTET          1\n# define PKCS8_EMBEDDED_PARAM    2\n# define PKCS8_NS_DB             3\n# define PKCS8_NEG_PRIVKEY       4\n    ASN1_INTEGER *version;\n    X509_ALGOR *pkeyalg;\n    /* Should be OCTET STRING but some are broken */\n    ASN1_TYPE *pkey;\n    STACK_OF(X509_ATTRIBUTE) *attributes;\n};\n\n#ifdef  __cplusplus\n}\n#endif\n\n# include <openssl/x509_vfy.h>\n# include <openssl/pkcs7.h>\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n# define X509_EXT_PACK_UNKNOWN   1\n# define X509_EXT_PACK_STRING    2\n\n# define         X509_get_version(x) ASN1_INTEGER_get((x)->cert_info->version)\n/* #define      X509_get_serialNumber(x) ((x)->cert_info->serialNumber) */\n# define         X509_get_notBefore(x) ((x)->cert_info->validity->notBefore)\n# define         X509_get_notAfter(x) ((x)->cert_info->validity->notAfter)\n# define         X509_extract_key(x)     X509_get_pubkey(x)/*****/\n# define         X509_REQ_get_version(x) ASN1_INTEGER_get((x)->req_info->version)\n# define         X509_REQ_get_subject_name(x) ((x)->req_info->subject)\n# define         X509_REQ_extract_key(a) X509_REQ_get_pubkey(a)\n# define         X509_name_cmp(a,b)      X509_NAME_cmp((a),(b))\n# define         X509_get_signature_type(x) EVP_PKEY_type(OBJ_obj2nid((x)->sig_alg->algorithm))\n\n# define         X509_CRL_get_version(x) ASN1_INTEGER_get((x)->crl->version)\n# define         X509_CRL_get_lastUpdate(x) ((x)->crl->lastUpdate)\n# define         X509_CRL_get_nextUpdate(x) ((x)->crl->nextUpdate)\n# define         X509_CRL_get_issuer(x) ((x)->crl->issuer)\n# define         X509_CRL_get_REVOKED(x) ((x)->crl->revoked)\n\nvoid X509_CRL_set_default_method(const X509_CRL_METHOD *meth);\nX509_CRL_METHOD *X509_CRL_METHOD_new(int (*crl_init) (X509_CRL *crl),\n                                     int (*crl_free) (X509_CRL *crl),\n                                     int (*crl_lookup) (X509_CRL *crl,\n                                                        X509_REVOKED **ret,\n                                                        ASN1_INTEGER *ser,\n                                                        X509_NAME *issuer),\n                                     int (*crl_verify) (X509_CRL *crl,\n                                                        EVP_PKEY *pk));\nvoid X509_CRL_METHOD_free(X509_CRL_METHOD *m);\n\nvoid X509_CRL_set_meth_data(X509_CRL *crl, void *dat);\nvoid *X509_CRL_get_meth_data(X509_CRL *crl);\n\n/*\n * This one is only used so that a binary form can output, as in\n * i2d_X509_NAME(X509_get_X509_PUBKEY(x),&buf)\n */\n# define         X509_get_X509_PUBKEY(x) ((x)->cert_info->key)\n\nconst char *X509_verify_cert_error_string(long n);\n\n# ifndef OPENSSL_NO_EVP\nint X509_verify(X509 *a, EVP_PKEY *r);\n\nint X509_REQ_verify(X509_REQ *a, EVP_PKEY *r);\nint X509_CRL_verify(X509_CRL *a, EVP_PKEY *r);\nint NETSCAPE_SPKI_verify(NETSCAPE_SPKI *a, EVP_PKEY *r);\n\nNETSCAPE_SPKI *NETSCAPE_SPKI_b64_decode(const char *str, int len);\nchar *NETSCAPE_SPKI_b64_encode(NETSCAPE_SPKI *x);\nEVP_PKEY *NETSCAPE_SPKI_get_pubkey(NETSCAPE_SPKI *x);\nint NETSCAPE_SPKI_set_pubkey(NETSCAPE_SPKI *x, EVP_PKEY *pkey);\n\nint NETSCAPE_SPKI_print(BIO *out, NETSCAPE_SPKI *spki);\n\nint X509_signature_dump(BIO *bp, const ASN1_STRING *sig, int indent);\nint X509_signature_print(BIO *bp, X509_ALGOR *alg, ASN1_STRING *sig);\n\nint X509_sign(X509 *x, EVP_PKEY *pkey, const EVP_MD *md);\nint X509_sign_ctx(X509 *x, EVP_MD_CTX *ctx);\nint X509_http_nbio(OCSP_REQ_CTX *rctx, X509 **pcert);\nint X509_REQ_sign(X509_REQ *x, EVP_PKEY *pkey, const EVP_MD *md);\nint X509_REQ_sign_ctx(X509_REQ *x, EVP_MD_CTX *ctx);\nint X509_CRL_sign(X509_CRL *x, EVP_PKEY *pkey, const EVP_MD *md);\nint X509_CRL_sign_ctx(X509_CRL *x, EVP_MD_CTX *ctx);\nint X509_CRL_http_nbio(OCSP_REQ_CTX *rctx, X509_CRL **pcrl);\nint NETSCAPE_SPKI_sign(NETSCAPE_SPKI *x, EVP_PKEY *pkey, const EVP_MD *md);\n\nint X509_pubkey_digest(const X509 *data, const EVP_MD *type,\n                       unsigned char *md, unsigned int *len);\nint X509_digest(const X509 *data, const EVP_MD *type,\n                unsigned char *md, unsigned int *len);\nint X509_CRL_digest(const X509_CRL *data, const EVP_MD *type,\n                    unsigned char *md, unsigned int *len);\nint X509_REQ_digest(const X509_REQ *data, const EVP_MD *type,\n                    unsigned char *md, unsigned int *len);\nint X509_NAME_digest(const X509_NAME *data, const EVP_MD *type,\n                     unsigned char *md, unsigned int *len);\n# endif\n\n# ifndef OPENSSL_NO_FP_API\nX509 *d2i_X509_fp(FILE *fp, X509 **x509);\nint i2d_X509_fp(FILE *fp, X509 *x509);\nX509_CRL *d2i_X509_CRL_fp(FILE *fp, X509_CRL **crl);\nint i2d_X509_CRL_fp(FILE *fp, X509_CRL *crl);\nX509_REQ *d2i_X509_REQ_fp(FILE *fp, X509_REQ **req);\nint i2d_X509_REQ_fp(FILE *fp, X509_REQ *req);\n#  ifndef OPENSSL_NO_RSA\nRSA *d2i_RSAPrivateKey_fp(FILE *fp, RSA **rsa);\nint i2d_RSAPrivateKey_fp(FILE *fp, RSA *rsa);\nRSA *d2i_RSAPublicKey_fp(FILE *fp, RSA **rsa);\nint i2d_RSAPublicKey_fp(FILE *fp, RSA *rsa);\nRSA *d2i_RSA_PUBKEY_fp(FILE *fp, RSA **rsa);\nint i2d_RSA_PUBKEY_fp(FILE *fp, RSA *rsa);\n#  endif\n#  ifndef OPENSSL_NO_DSA\nDSA *d2i_DSA_PUBKEY_fp(FILE *fp, DSA **dsa);\nint i2d_DSA_PUBKEY_fp(FILE *fp, DSA *dsa);\nDSA *d2i_DSAPrivateKey_fp(FILE *fp, DSA **dsa);\nint i2d_DSAPrivateKey_fp(FILE *fp, DSA *dsa);\n#  endif\n#  ifndef OPENSSL_NO_EC\nEC_KEY *d2i_EC_PUBKEY_fp(FILE *fp, EC_KEY **eckey);\nint i2d_EC_PUBKEY_fp(FILE *fp, EC_KEY *eckey);\nEC_KEY *d2i_ECPrivateKey_fp(FILE *fp, EC_KEY **eckey);\nint i2d_ECPrivateKey_fp(FILE *fp, EC_KEY *eckey);\n#  endif\nX509_SIG *d2i_PKCS8_fp(FILE *fp, X509_SIG **p8);\nint i2d_PKCS8_fp(FILE *fp, X509_SIG *p8);\nPKCS8_PRIV_KEY_INFO *d2i_PKCS8_PRIV_KEY_INFO_fp(FILE *fp,\n                                                PKCS8_PRIV_KEY_INFO **p8inf);\nint i2d_PKCS8_PRIV_KEY_INFO_fp(FILE *fp, PKCS8_PRIV_KEY_INFO *p8inf);\nint i2d_PKCS8PrivateKeyInfo_fp(FILE *fp, EVP_PKEY *key);\nint i2d_PrivateKey_fp(FILE *fp, EVP_PKEY *pkey);\nEVP_PKEY *d2i_PrivateKey_fp(FILE *fp, EVP_PKEY **a);\nint i2d_PUBKEY_fp(FILE *fp, EVP_PKEY *pkey);\nEVP_PKEY *d2i_PUBKEY_fp(FILE *fp, EVP_PKEY **a);\n# endif\n\n# ifndef OPENSSL_NO_BIO\nX509 *d2i_X509_bio(BIO *bp, X509 **x509);\nint i2d_X509_bio(BIO *bp, X509 *x509);\nX509_CRL *d2i_X509_CRL_bio(BIO *bp, X509_CRL **crl);\nint i2d_X509_CRL_bio(BIO *bp, X509_CRL *crl);\nX509_REQ *d2i_X509_REQ_bio(BIO *bp, X509_REQ **req);\nint i2d_X509_REQ_bio(BIO *bp, X509_REQ *req);\n#  ifndef OPENSSL_NO_RSA\nRSA *d2i_RSAPrivateKey_bio(BIO *bp, RSA **rsa);\nint i2d_RSAPrivateKey_bio(BIO *bp, RSA *rsa);\nRSA *d2i_RSAPublicKey_bio(BIO *bp, RSA **rsa);\nint i2d_RSAPublicKey_bio(BIO *bp, RSA *rsa);\nRSA *d2i_RSA_PUBKEY_bio(BIO *bp, RSA **rsa);\nint i2d_RSA_PUBKEY_bio(BIO *bp, RSA *rsa);\n#  endif\n#  ifndef OPENSSL_NO_DSA\nDSA *d2i_DSA_PUBKEY_bio(BIO *bp, DSA **dsa);\nint i2d_DSA_PUBKEY_bio(BIO *bp, DSA *dsa);\nDSA *d2i_DSAPrivateKey_bio(BIO *bp, DSA **dsa);\nint i2d_DSAPrivateKey_bio(BIO *bp, DSA *dsa);\n#  endif\n#  ifndef OPENSSL_NO_EC\nEC_KEY *d2i_EC_PUBKEY_bio(BIO *bp, EC_KEY **eckey);\nint i2d_EC_PUBKEY_bio(BIO *bp, EC_KEY *eckey);\nEC_KEY *d2i_ECPrivateKey_bio(BIO *bp, EC_KEY **eckey);\nint i2d_ECPrivateKey_bio(BIO *bp, EC_KEY *eckey);\n#  endif\nX509_SIG *d2i_PKCS8_bio(BIO *bp, X509_SIG **p8);\nint i2d_PKCS8_bio(BIO *bp, X509_SIG *p8);\nPKCS8_PRIV_KEY_INFO *d2i_PKCS8_PRIV_KEY_INFO_bio(BIO *bp,\n                                                 PKCS8_PRIV_KEY_INFO **p8inf);\nint i2d_PKCS8_PRIV_KEY_INFO_bio(BIO *bp, PKCS8_PRIV_KEY_INFO *p8inf);\nint i2d_PKCS8PrivateKeyInfo_bio(BIO *bp, EVP_PKEY *key);\nint i2d_PrivateKey_bio(BIO *bp, EVP_PKEY *pkey);\nEVP_PKEY *d2i_PrivateKey_bio(BIO *bp, EVP_PKEY **a);\nint i2d_PUBKEY_bio(BIO *bp, EVP_PKEY *pkey);\nEVP_PKEY *d2i_PUBKEY_bio(BIO *bp, EVP_PKEY **a);\n# endif\n\nX509 *X509_dup(X509 *x509);\nX509_ATTRIBUTE *X509_ATTRIBUTE_dup(X509_ATTRIBUTE *xa);\nX509_EXTENSION *X509_EXTENSION_dup(X509_EXTENSION *ex);\nX509_CRL *X509_CRL_dup(X509_CRL *crl);\nX509_REVOKED *X509_REVOKED_dup(X509_REVOKED *rev);\nX509_REQ *X509_REQ_dup(X509_REQ *req);\nX509_ALGOR *X509_ALGOR_dup(X509_ALGOR *xn);\nint X509_ALGOR_set0(X509_ALGOR *alg, ASN1_OBJECT *aobj, int ptype,\n                    void *pval);\nvoid X509_ALGOR_get0(ASN1_OBJECT **paobj, int *pptype, void **ppval,\n                     X509_ALGOR *algor);\nvoid X509_ALGOR_set_md(X509_ALGOR *alg, const EVP_MD *md);\nint X509_ALGOR_cmp(const X509_ALGOR *a, const X509_ALGOR *b);\n\nX509_NAME *X509_NAME_dup(X509_NAME *xn);\nX509_NAME_ENTRY *X509_NAME_ENTRY_dup(X509_NAME_ENTRY *ne);\n\nint X509_cmp_time(const ASN1_TIME *s, time_t *t);\nint X509_cmp_current_time(const ASN1_TIME *s);\nASN1_TIME *X509_time_adj(ASN1_TIME *s, long adj, time_t *t);\nASN1_TIME *X509_time_adj_ex(ASN1_TIME *s,\n                            int offset_day, long offset_sec, time_t *t);\nASN1_TIME *X509_gmtime_adj(ASN1_TIME *s, long adj);\n\nconst char *X509_get_default_cert_area(void);\nconst char *X509_get_default_cert_dir(void);\nconst char *X509_get_default_cert_file(void);\nconst char *X509_get_default_cert_dir_env(void);\nconst char *X509_get_default_cert_file_env(void);\nconst char *X509_get_default_private_dir(void);\n\nX509_REQ *X509_to_X509_REQ(X509 *x, EVP_PKEY *pkey, const EVP_MD *md);\nX509 *X509_REQ_to_X509(X509_REQ *r, int days, EVP_PKEY *pkey);\n\nDECLARE_ASN1_FUNCTIONS(X509_ALGOR)\nDECLARE_ASN1_ENCODE_FUNCTIONS(X509_ALGORS, X509_ALGORS, X509_ALGORS)\nDECLARE_ASN1_FUNCTIONS(X509_VAL)\n\nDECLARE_ASN1_FUNCTIONS(X509_PUBKEY)\n\nint X509_PUBKEY_set(X509_PUBKEY **x, EVP_PKEY *pkey);\nEVP_PKEY *X509_PUBKEY_get(X509_PUBKEY *key);\nint X509_get_pubkey_parameters(EVP_PKEY *pkey, STACK_OF(X509) *chain);\nint i2d_PUBKEY(EVP_PKEY *a, unsigned char **pp);\nEVP_PKEY *d2i_PUBKEY(EVP_PKEY **a, const unsigned char **pp, long length);\n# ifndef OPENSSL_NO_RSA\nint i2d_RSA_PUBKEY(RSA *a, unsigned char **pp);\nRSA *d2i_RSA_PUBKEY(RSA **a, const unsigned char **pp, long length);\n# endif\n# ifndef OPENSSL_NO_DSA\nint i2d_DSA_PUBKEY(DSA *a, unsigned char **pp);\nDSA *d2i_DSA_PUBKEY(DSA **a, const unsigned char **pp, long length);\n# endif\n# ifndef OPENSSL_NO_EC\nint i2d_EC_PUBKEY(EC_KEY *a, unsigned char **pp);\nEC_KEY *d2i_EC_PUBKEY(EC_KEY **a, const unsigned char **pp, long length);\n# endif\n\nDECLARE_ASN1_FUNCTIONS(X509_SIG)\nDECLARE_ASN1_FUNCTIONS(X509_REQ_INFO)\nDECLARE_ASN1_FUNCTIONS(X509_REQ)\n\nDECLARE_ASN1_FUNCTIONS(X509_ATTRIBUTE)\nX509_ATTRIBUTE *X509_ATTRIBUTE_create(int nid, int atrtype, void *value);\n\nDECLARE_ASN1_FUNCTIONS(X509_EXTENSION)\nDECLARE_ASN1_ENCODE_FUNCTIONS(X509_EXTENSIONS, X509_EXTENSIONS, X509_EXTENSIONS)\n\nDECLARE_ASN1_FUNCTIONS(X509_NAME_ENTRY)\n\nDECLARE_ASN1_FUNCTIONS(X509_NAME)\n\nint X509_NAME_set(X509_NAME **xn, X509_NAME *name);\n\nDECLARE_ASN1_FUNCTIONS(X509_CINF)\n\nDECLARE_ASN1_FUNCTIONS(X509)\nDECLARE_ASN1_FUNCTIONS(X509_CERT_AUX)\n\nDECLARE_ASN1_FUNCTIONS(X509_CERT_PAIR)\n\nint X509_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func,\n                          CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func);\nint X509_set_ex_data(X509 *r, int idx, void *arg);\nvoid *X509_get_ex_data(X509 *r, int idx);\nint i2d_X509_AUX(X509 *a, unsigned char **pp);\nX509 *d2i_X509_AUX(X509 **a, const unsigned char **pp, long length);\n\nint i2d_re_X509_tbs(X509 *x, unsigned char **pp);\n\nvoid X509_get0_signature(ASN1_BIT_STRING **psig, X509_ALGOR **palg,\n                         const X509 *x);\nint X509_get_signature_nid(const X509 *x);\n\nint X509_alias_set1(X509 *x, unsigned char *name, int len);\nint X509_keyid_set1(X509 *x, unsigned char *id, int len);\nunsigned char *X509_alias_get0(X509 *x, int *len);\nunsigned char *X509_keyid_get0(X509 *x, int *len);\nint (*X509_TRUST_set_default(int (*trust) (int, X509 *, int))) (int, X509 *,\n                                                                int);\nint X509_TRUST_set(int *t, int trust);\nint X509_add1_trust_object(X509 *x, ASN1_OBJECT *obj);\nint X509_add1_reject_object(X509 *x, ASN1_OBJECT *obj);\nvoid X509_trust_clear(X509 *x);\nvoid X509_reject_clear(X509 *x);\n\nDECLARE_ASN1_FUNCTIONS(X509_REVOKED)\nDECLARE_ASN1_FUNCTIONS(X509_CRL_INFO)\nDECLARE_ASN1_FUNCTIONS(X509_CRL)\n\nint X509_CRL_add0_revoked(X509_CRL *crl, X509_REVOKED *rev);\nint X509_CRL_get0_by_serial(X509_CRL *crl,\n                            X509_REVOKED **ret, ASN1_INTEGER *serial);\nint X509_CRL_get0_by_cert(X509_CRL *crl, X509_REVOKED **ret, X509 *x);\n\nX509_PKEY *X509_PKEY_new(void);\nvoid X509_PKEY_free(X509_PKEY *a);\nint i2d_X509_PKEY(X509_PKEY *a, unsigned char **pp);\nX509_PKEY *d2i_X509_PKEY(X509_PKEY **a, const unsigned char **pp,\n                         long length);\n\nDECLARE_ASN1_FUNCTIONS(NETSCAPE_SPKI)\nDECLARE_ASN1_FUNCTIONS(NETSCAPE_SPKAC)\nDECLARE_ASN1_FUNCTIONS(NETSCAPE_CERT_SEQUENCE)\n\n# ifndef OPENSSL_NO_EVP\nX509_INFO *X509_INFO_new(void);\nvoid X509_INFO_free(X509_INFO *a);\nchar *X509_NAME_oneline(X509_NAME *a, char *buf, int size);\n\nint ASN1_verify(i2d_of_void *i2d, X509_ALGOR *algor1,\n                ASN1_BIT_STRING *signature, char *data, EVP_PKEY *pkey);\n\nint ASN1_digest(i2d_of_void *i2d, const EVP_MD *type, char *data,\n                unsigned char *md, unsigned int *len);\n\nint ASN1_sign(i2d_of_void *i2d, X509_ALGOR *algor1,\n              X509_ALGOR *algor2, ASN1_BIT_STRING *signature,\n              char *data, EVP_PKEY *pkey, const EVP_MD *type);\n\nint ASN1_item_digest(const ASN1_ITEM *it, const EVP_MD *type, void *data,\n                     unsigned char *md, unsigned int *len);\n\nint ASN1_item_verify(const ASN1_ITEM *it, X509_ALGOR *algor1,\n                     ASN1_BIT_STRING *signature, void *data, EVP_PKEY *pkey);\n\nint ASN1_item_sign(const ASN1_ITEM *it, X509_ALGOR *algor1,\n                   X509_ALGOR *algor2, ASN1_BIT_STRING *signature, void *data,\n                   EVP_PKEY *pkey, const EVP_MD *type);\nint ASN1_item_sign_ctx(const ASN1_ITEM *it, X509_ALGOR *algor1,\n                       X509_ALGOR *algor2, ASN1_BIT_STRING *signature,\n                       void *asn, EVP_MD_CTX *ctx);\n# endif\n\nint X509_set_version(X509 *x, long version);\nint X509_set_serialNumber(X509 *x, ASN1_INTEGER *serial);\nASN1_INTEGER *X509_get_serialNumber(X509 *x);\nint X509_set_issuer_name(X509 *x, X509_NAME *name);\nX509_NAME *X509_get_issuer_name(X509 *a);\nint X509_set_subject_name(X509 *x, X509_NAME *name);\nX509_NAME *X509_get_subject_name(X509 *a);\nint X509_set_notBefore(X509 *x, const ASN1_TIME *tm);\nint X509_set_notAfter(X509 *x, const ASN1_TIME *tm);\nint X509_set_pubkey(X509 *x, EVP_PKEY *pkey);\nEVP_PKEY *X509_get_pubkey(X509 *x);\nASN1_BIT_STRING *X509_get0_pubkey_bitstr(const X509 *x);\nint X509_certificate_type(X509 *x, EVP_PKEY *pubkey /* optional */ );\n\nint X509_REQ_set_version(X509_REQ *x, long version);\nint X509_REQ_set_subject_name(X509_REQ *req, X509_NAME *name);\nint X509_REQ_set_pubkey(X509_REQ *x, EVP_PKEY *pkey);\nEVP_PKEY *X509_REQ_get_pubkey(X509_REQ *req);\nint X509_REQ_extension_nid(int nid);\nint *X509_REQ_get_extension_nids(void);\nvoid X509_REQ_set_extension_nids(int *nids);\nSTACK_OF(X509_EXTENSION) *X509_REQ_get_extensions(X509_REQ *req);\nint X509_REQ_add_extensions_nid(X509_REQ *req, STACK_OF(X509_EXTENSION) *exts,\n                                int nid);\nint X509_REQ_add_extensions(X509_REQ *req, STACK_OF(X509_EXTENSION) *exts);\nint X509_REQ_get_attr_count(const X509_REQ *req);\nint X509_REQ_get_attr_by_NID(const X509_REQ *req, int nid, int lastpos);\nint X509_REQ_get_attr_by_OBJ(const X509_REQ *req, ASN1_OBJECT *obj,\n                             int lastpos);\nX509_ATTRIBUTE *X509_REQ_get_attr(const X509_REQ *req, int loc);\nX509_ATTRIBUTE *X509_REQ_delete_attr(X509_REQ *req, int loc);\nint X509_REQ_add1_attr(X509_REQ *req, X509_ATTRIBUTE *attr);\nint X509_REQ_add1_attr_by_OBJ(X509_REQ *req,\n                              const ASN1_OBJECT *obj, int type,\n                              const unsigned char *bytes, int len);\nint X509_REQ_add1_attr_by_NID(X509_REQ *req,\n                              int nid, int type,\n                              const unsigned char *bytes, int len);\nint X509_REQ_add1_attr_by_txt(X509_REQ *req,\n                              const char *attrname, int type,\n                              const unsigned char *bytes, int len);\n\nint X509_CRL_set_version(X509_CRL *x, long version);\nint X509_CRL_set_issuer_name(X509_CRL *x, X509_NAME *name);\nint X509_CRL_set_lastUpdate(X509_CRL *x, const ASN1_TIME *tm);\nint X509_CRL_set_nextUpdate(X509_CRL *x, const ASN1_TIME *tm);\nint X509_CRL_sort(X509_CRL *crl);\n\nint X509_REVOKED_set_serialNumber(X509_REVOKED *x, ASN1_INTEGER *serial);\nint X509_REVOKED_set_revocationDate(X509_REVOKED *r, ASN1_TIME *tm);\n\nX509_CRL *X509_CRL_diff(X509_CRL *base, X509_CRL *newer,\n                        EVP_PKEY *skey, const EVP_MD *md, unsigned int flags);\n\nint X509_REQ_check_private_key(X509_REQ *x509, EVP_PKEY *pkey);\n\nint X509_check_private_key(X509 *x509, EVP_PKEY *pkey);\nint X509_chain_check_suiteb(int *perror_depth,\n                            X509 *x, STACK_OF(X509) *chain,\n                            unsigned long flags);\nint X509_CRL_check_suiteb(X509_CRL *crl, EVP_PKEY *pk, unsigned long flags);\nSTACK_OF(X509) *X509_chain_up_ref(STACK_OF(X509) *chain);\n\nint X509_issuer_and_serial_cmp(const X509 *a, const X509 *b);\nunsigned long X509_issuer_and_serial_hash(X509 *a);\n\nint X509_issuer_name_cmp(const X509 *a, const X509 *b);\nunsigned long X509_issuer_name_hash(X509 *a);\n\nint X509_subject_name_cmp(const X509 *a, const X509 *b);\nunsigned long X509_subject_name_hash(X509 *x);\n\n# ifndef OPENSSL_NO_MD5\nunsigned long X509_issuer_name_hash_old(X509 *a);\nunsigned long X509_subject_name_hash_old(X509 *x);\n# endif\n\nint X509_cmp(const X509 *a, const X509 *b);\nint X509_NAME_cmp(const X509_NAME *a, const X509_NAME *b);\nunsigned long X509_NAME_hash(X509_NAME *x);\nunsigned long X509_NAME_hash_old(X509_NAME *x);\n\nint X509_CRL_cmp(const X509_CRL *a, const X509_CRL *b);\nint X509_CRL_match(const X509_CRL *a, const X509_CRL *b);\n# ifndef OPENSSL_NO_FP_API\nint X509_print_ex_fp(FILE *bp, X509 *x, unsigned long nmflag,\n                     unsigned long cflag);\nint X509_print_fp(FILE *bp, X509 *x);\nint X509_CRL_print_fp(FILE *bp, X509_CRL *x);\nint X509_REQ_print_fp(FILE *bp, X509_REQ *req);\nint X509_NAME_print_ex_fp(FILE *fp, X509_NAME *nm, int indent,\n                          unsigned long flags);\n# endif\n\n# ifndef OPENSSL_NO_BIO\nint X509_NAME_print(BIO *bp, X509_NAME *name, int obase);\nint X509_NAME_print_ex(BIO *out, X509_NAME *nm, int indent,\n                       unsigned long flags);\nint X509_print_ex(BIO *bp, X509 *x, unsigned long nmflag,\n                  unsigned long cflag);\nint X509_print(BIO *bp, X509 *x);\nint X509_ocspid_print(BIO *bp, X509 *x);\nint X509_CERT_AUX_print(BIO *bp, X509_CERT_AUX *x, int indent);\nint X509_CRL_print(BIO *bp, X509_CRL *x);\nint X509_REQ_print_ex(BIO *bp, X509_REQ *x, unsigned long nmflag,\n                      unsigned long cflag);\nint X509_REQ_print(BIO *bp, X509_REQ *req);\n# endif\n\nint X509_NAME_entry_count(X509_NAME *name);\nint X509_NAME_get_text_by_NID(X509_NAME *name, int nid, char *buf, int len);\nint X509_NAME_get_text_by_OBJ(X509_NAME *name, ASN1_OBJECT *obj,\n                              char *buf, int len);\n\n/*\n * NOTE: you should be passsing -1, not 0 as lastpos.  The functions that use\n * lastpos, search after that position on.\n */\nint X509_NAME_get_index_by_NID(X509_NAME *name, int nid, int lastpos);\nint X509_NAME_get_index_by_OBJ(X509_NAME *name, ASN1_OBJECT *obj,\n                               int lastpos);\nX509_NAME_ENTRY *X509_NAME_get_entry(X509_NAME *name, int loc);\nX509_NAME_ENTRY *X509_NAME_delete_entry(X509_NAME *name, int loc);\nint X509_NAME_add_entry(X509_NAME *name, X509_NAME_ENTRY *ne,\n                        int loc, int set);\nint X509_NAME_add_entry_by_OBJ(X509_NAME *name, ASN1_OBJECT *obj, int type,\n                               unsigned char *bytes, int len, int loc,\n                               int set);\nint X509_NAME_add_entry_by_NID(X509_NAME *name, int nid, int type,\n                               unsigned char *bytes, int len, int loc,\n                               int set);\nX509_NAME_ENTRY *X509_NAME_ENTRY_create_by_txt(X509_NAME_ENTRY **ne,\n                                               const char *field, int type,\n                                               const unsigned char *bytes,\n                                               int len);\nX509_NAME_ENTRY *X509_NAME_ENTRY_create_by_NID(X509_NAME_ENTRY **ne, int nid,\n                                               int type, unsigned char *bytes,\n                                               int len);\nint X509_NAME_add_entry_by_txt(X509_NAME *name, const char *field, int type,\n                               const unsigned char *bytes, int len, int loc,\n                               int set);\nX509_NAME_ENTRY *X509_NAME_ENTRY_create_by_OBJ(X509_NAME_ENTRY **ne,\n                                               ASN1_OBJECT *obj, int type,\n                                               const unsigned char *bytes,\n                                               int len);\nint X509_NAME_ENTRY_set_object(X509_NAME_ENTRY *ne, ASN1_OBJECT *obj);\nint X509_NAME_ENTRY_set_data(X509_NAME_ENTRY *ne, int type,\n                             const unsigned char *bytes, int len);\nASN1_OBJECT *X509_NAME_ENTRY_get_object(X509_NAME_ENTRY *ne);\nASN1_STRING *X509_NAME_ENTRY_get_data(X509_NAME_ENTRY *ne);\n\nint X509v3_get_ext_count(const STACK_OF(X509_EXTENSION) *x);\nint X509v3_get_ext_by_NID(const STACK_OF(X509_EXTENSION) *x,\n                          int nid, int lastpos);\nint X509v3_get_ext_by_OBJ(const STACK_OF(X509_EXTENSION) *x,\n                          ASN1_OBJECT *obj, int lastpos);\nint X509v3_get_ext_by_critical(const STACK_OF(X509_EXTENSION) *x,\n                               int crit, int lastpos);\nX509_EXTENSION *X509v3_get_ext(const STACK_OF(X509_EXTENSION) *x, int loc);\nX509_EXTENSION *X509v3_delete_ext(STACK_OF(X509_EXTENSION) *x, int loc);\nSTACK_OF(X509_EXTENSION) *X509v3_add_ext(STACK_OF(X509_EXTENSION) **x,\n                                         X509_EXTENSION *ex, int loc);\n\nint X509_get_ext_count(X509 *x);\nint X509_get_ext_by_NID(X509 *x, int nid, int lastpos);\nint X509_get_ext_by_OBJ(X509 *x, ASN1_OBJECT *obj, int lastpos);\nint X509_get_ext_by_critical(X509 *x, int crit, int lastpos);\nX509_EXTENSION *X509_get_ext(X509 *x, int loc);\nX509_EXTENSION *X509_delete_ext(X509 *x, int loc);\nint X509_add_ext(X509 *x, X509_EXTENSION *ex, int loc);\nvoid *X509_get_ext_d2i(X509 *x, int nid, int *crit, int *idx);\nint X509_add1_ext_i2d(X509 *x, int nid, void *value, int crit,\n                      unsigned long flags);\n\nint X509_CRL_get_ext_count(X509_CRL *x);\nint X509_CRL_get_ext_by_NID(X509_CRL *x, int nid, int lastpos);\nint X509_CRL_get_ext_by_OBJ(X509_CRL *x, ASN1_OBJECT *obj, int lastpos);\nint X509_CRL_get_ext_by_critical(X509_CRL *x, int crit, int lastpos);\nX509_EXTENSION *X509_CRL_get_ext(X509_CRL *x, int loc);\nX509_EXTENSION *X509_CRL_delete_ext(X509_CRL *x, int loc);\nint X509_CRL_add_ext(X509_CRL *x, X509_EXTENSION *ex, int loc);\nvoid *X509_CRL_get_ext_d2i(X509_CRL *x, int nid, int *crit, int *idx);\nint X509_CRL_add1_ext_i2d(X509_CRL *x, int nid, void *value, int crit,\n                          unsigned long flags);\n\nint X509_REVOKED_get_ext_count(X509_REVOKED *x);\nint X509_REVOKED_get_ext_by_NID(X509_REVOKED *x, int nid, int lastpos);\nint X509_REVOKED_get_ext_by_OBJ(X509_REVOKED *x, ASN1_OBJECT *obj,\n                                int lastpos);\nint X509_REVOKED_get_ext_by_critical(X509_REVOKED *x, int crit, int lastpos);\nX509_EXTENSION *X509_REVOKED_get_ext(X509_REVOKED *x, int loc);\nX509_EXTENSION *X509_REVOKED_delete_ext(X509_REVOKED *x, int loc);\nint X509_REVOKED_add_ext(X509_REVOKED *x, X509_EXTENSION *ex, int loc);\nvoid *X509_REVOKED_get_ext_d2i(X509_REVOKED *x, int nid, int *crit, int *idx);\nint X509_REVOKED_add1_ext_i2d(X509_REVOKED *x, int nid, void *value, int crit,\n                              unsigned long flags);\n\nX509_EXTENSION *X509_EXTENSION_create_by_NID(X509_EXTENSION **ex,\n                                             int nid, int crit,\n                                             ASN1_OCTET_STRING *data);\nX509_EXTENSION *X509_EXTENSION_create_by_OBJ(X509_EXTENSION **ex,\n                                             ASN1_OBJECT *obj, int crit,\n                                             ASN1_OCTET_STRING *data);\nint X509_EXTENSION_set_object(X509_EXTENSION *ex, ASN1_OBJECT *obj);\nint X509_EXTENSION_set_critical(X509_EXTENSION *ex, int crit);\nint X509_EXTENSION_set_data(X509_EXTENSION *ex, ASN1_OCTET_STRING *data);\nASN1_OBJECT *X509_EXTENSION_get_object(X509_EXTENSION *ex);\nASN1_OCTET_STRING *X509_EXTENSION_get_data(X509_EXTENSION *ne);\nint X509_EXTENSION_get_critical(X509_EXTENSION *ex);\n\nint X509at_get_attr_count(const STACK_OF(X509_ATTRIBUTE) *x);\nint X509at_get_attr_by_NID(const STACK_OF(X509_ATTRIBUTE) *x, int nid,\n                           int lastpos);\nint X509at_get_attr_by_OBJ(const STACK_OF(X509_ATTRIBUTE) *sk,\n                           ASN1_OBJECT *obj, int lastpos);\nX509_ATTRIBUTE *X509at_get_attr(const STACK_OF(X509_ATTRIBUTE) *x, int loc);\nX509_ATTRIBUTE *X509at_delete_attr(STACK_OF(X509_ATTRIBUTE) *x, int loc);\nSTACK_OF(X509_ATTRIBUTE) *X509at_add1_attr(STACK_OF(X509_ATTRIBUTE) **x,\n                                           X509_ATTRIBUTE *attr);\nSTACK_OF(X509_ATTRIBUTE) *X509at_add1_attr_by_OBJ(STACK_OF(X509_ATTRIBUTE)\n                                                  **x, const ASN1_OBJECT *obj,\n                                                  int type,\n                                                  const unsigned char *bytes,\n                                                  int len);\nSTACK_OF(X509_ATTRIBUTE) *X509at_add1_attr_by_NID(STACK_OF(X509_ATTRIBUTE)\n                                                  **x, int nid, int type,\n                                                  const unsigned char *bytes,\n                                                  int len);\nSTACK_OF(X509_ATTRIBUTE) *X509at_add1_attr_by_txt(STACK_OF(X509_ATTRIBUTE)\n                                                  **x, const char *attrname,\n                                                  int type,\n                                                  const unsigned char *bytes,\n                                                  int len);\nvoid *X509at_get0_data_by_OBJ(STACK_OF(X509_ATTRIBUTE) *x, ASN1_OBJECT *obj,\n                              int lastpos, int type);\nX509_ATTRIBUTE *X509_ATTRIBUTE_create_by_NID(X509_ATTRIBUTE **attr, int nid,\n                                             int atrtype, const void *data,\n                                             int len);\nX509_ATTRIBUTE *X509_ATTRIBUTE_create_by_OBJ(X509_ATTRIBUTE **attr,\n                                             const ASN1_OBJECT *obj,\n                                             int atrtype, const void *data,\n                                             int len);\nX509_ATTRIBUTE *X509_ATTRIBUTE_create_by_txt(X509_ATTRIBUTE **attr,\n                                             const char *atrname, int type,\n                                             const unsigned char *bytes,\n                                             int len);\nint X509_ATTRIBUTE_set1_object(X509_ATTRIBUTE *attr, const ASN1_OBJECT *obj);\nint X509_ATTRIBUTE_set1_data(X509_ATTRIBUTE *attr, int attrtype,\n                             const void *data, int len);\nvoid *X509_ATTRIBUTE_get0_data(X509_ATTRIBUTE *attr, int idx, int atrtype,\n                               void *data);\nint X509_ATTRIBUTE_count(X509_ATTRIBUTE *attr);\nASN1_OBJECT *X509_ATTRIBUTE_get0_object(X509_ATTRIBUTE *attr);\nASN1_TYPE *X509_ATTRIBUTE_get0_type(X509_ATTRIBUTE *attr, int idx);\n\nint EVP_PKEY_get_attr_count(const EVP_PKEY *key);\nint EVP_PKEY_get_attr_by_NID(const EVP_PKEY *key, int nid, int lastpos);\nint EVP_PKEY_get_attr_by_OBJ(const EVP_PKEY *key, ASN1_OBJECT *obj,\n                             int lastpos);\nX509_ATTRIBUTE *EVP_PKEY_get_attr(const EVP_PKEY *key, int loc);\nX509_ATTRIBUTE *EVP_PKEY_delete_attr(EVP_PKEY *key, int loc);\nint EVP_PKEY_add1_attr(EVP_PKEY *key, X509_ATTRIBUTE *attr);\nint EVP_PKEY_add1_attr_by_OBJ(EVP_PKEY *key,\n                              const ASN1_OBJECT *obj, int type,\n                              const unsigned char *bytes, int len);\nint EVP_PKEY_add1_attr_by_NID(EVP_PKEY *key,\n                              int nid, int type,\n                              const unsigned char *bytes, int len);\nint EVP_PKEY_add1_attr_by_txt(EVP_PKEY *key,\n                              const char *attrname, int type,\n                              const unsigned char *bytes, int len);\n\nint X509_verify_cert(X509_STORE_CTX *ctx);\n\n/* lookup a cert from a X509 STACK */\nX509 *X509_find_by_issuer_and_serial(STACK_OF(X509) *sk, X509_NAME *name,\n                                     ASN1_INTEGER *serial);\nX509 *X509_find_by_subject(STACK_OF(X509) *sk, X509_NAME *name);\n\nDECLARE_ASN1_FUNCTIONS(PBEPARAM)\nDECLARE_ASN1_FUNCTIONS(PBE2PARAM)\nDECLARE_ASN1_FUNCTIONS(PBKDF2PARAM)\n\nint PKCS5_pbe_set0_algor(X509_ALGOR *algor, int alg, int iter,\n                         const unsigned char *salt, int saltlen);\n\nX509_ALGOR *PKCS5_pbe_set(int alg, int iter,\n                          const unsigned char *salt, int saltlen);\nX509_ALGOR *PKCS5_pbe2_set(const EVP_CIPHER *cipher, int iter,\n                           unsigned char *salt, int saltlen);\nX509_ALGOR *PKCS5_pbe2_set_iv(const EVP_CIPHER *cipher, int iter,\n                              unsigned char *salt, int saltlen,\n                              unsigned char *aiv, int prf_nid);\n\nX509_ALGOR *PKCS5_pbkdf2_set(int iter, unsigned char *salt, int saltlen,\n                             int prf_nid, int keylen);\n\n/* PKCS#8 utilities */\n\nDECLARE_ASN1_FUNCTIONS(PKCS8_PRIV_KEY_INFO)\n\nEVP_PKEY *EVP_PKCS82PKEY(PKCS8_PRIV_KEY_INFO *p8);\nPKCS8_PRIV_KEY_INFO *EVP_PKEY2PKCS8(EVP_PKEY *pkey);\nPKCS8_PRIV_KEY_INFO *EVP_PKEY2PKCS8_broken(EVP_PKEY *pkey, int broken);\nPKCS8_PRIV_KEY_INFO *PKCS8_set_broken(PKCS8_PRIV_KEY_INFO *p8, int broken);\n\nint PKCS8_pkey_set0(PKCS8_PRIV_KEY_INFO *priv, ASN1_OBJECT *aobj,\n                    int version, int ptype, void *pval,\n                    unsigned char *penc, int penclen);\nint PKCS8_pkey_get0(ASN1_OBJECT **ppkalg,\n                    const unsigned char **pk, int *ppklen,\n                    X509_ALGOR **pa, PKCS8_PRIV_KEY_INFO *p8);\n\nint X509_PUBKEY_set0_param(X509_PUBKEY *pub, ASN1_OBJECT *aobj,\n                           int ptype, void *pval,\n                           unsigned char *penc, int penclen);\nint X509_PUBKEY_get0_param(ASN1_OBJECT **ppkalg,\n                           const unsigned char **pk, int *ppklen,\n                           X509_ALGOR **pa, X509_PUBKEY *pub);\n\nint X509_check_trust(X509 *x, int id, int flags);\nint X509_TRUST_get_count(void);\nX509_TRUST *X509_TRUST_get0(int idx);\nint X509_TRUST_get_by_id(int id);\nint X509_TRUST_add(int id, int flags, int (*ck) (X509_TRUST *, X509 *, int),\n                   char *name, int arg1, void *arg2);\nvoid X509_TRUST_cleanup(void);\nint X509_TRUST_get_flags(X509_TRUST *xp);\nchar *X509_TRUST_get0_name(X509_TRUST *xp);\nint X509_TRUST_get_trust(X509_TRUST *xp);\n\n/* BEGIN ERROR CODES */\n/*\n * The following lines are auto generated by the script mkerr.pl. Any changes\n * made after this point may be overwritten when the script is next run.\n */\n\nvoid ERR_load_X509_strings(void);\n\n/* Error codes for the X509 functions. */\n\n/* Function codes. */\n# define X509_F_ADD_CERT_DIR                              100\n# define X509_F_BY_FILE_CTRL                              101\n# define X509_F_CHECK_NAME_CONSTRAINTS                    106\n# define X509_F_CHECK_POLICY                              145\n# define X509_F_DIR_CTRL                                  102\n# define X509_F_GET_CERT_BY_SUBJECT                       103\n# define X509_F_NETSCAPE_SPKI_B64_DECODE                  129\n# define X509_F_NETSCAPE_SPKI_B64_ENCODE                  130\n# define X509_F_X509AT_ADD1_ATTR                          135\n# define X509_F_X509V3_ADD_EXT                            104\n# define X509_F_X509_ATTRIBUTE_CREATE_BY_NID              136\n# define X509_F_X509_ATTRIBUTE_CREATE_BY_OBJ              137\n# define X509_F_X509_ATTRIBUTE_CREATE_BY_TXT              140\n# define X509_F_X509_ATTRIBUTE_GET0_DATA                  139\n# define X509_F_X509_ATTRIBUTE_SET1_DATA                  138\n# define X509_F_X509_CHECK_PRIVATE_KEY                    128\n# define X509_F_X509_CRL_DIFF                             105\n# define X509_F_X509_CRL_PRINT_FP                         147\n# define X509_F_X509_EXTENSION_CREATE_BY_NID              108\n# define X509_F_X509_EXTENSION_CREATE_BY_OBJ              109\n# define X509_F_X509_GET_PUBKEY_PARAMETERS                110\n# define X509_F_X509_LOAD_CERT_CRL_FILE                   132\n# define X509_F_X509_LOAD_CERT_FILE                       111\n# define X509_F_X509_LOAD_CRL_FILE                        112\n# define X509_F_X509_NAME_ADD_ENTRY                       113\n# define X509_F_X509_NAME_ENTRY_CREATE_BY_NID             114\n# define X509_F_X509_NAME_ENTRY_CREATE_BY_TXT             131\n# define X509_F_X509_NAME_ENTRY_SET_OBJECT                115\n# define X509_F_X509_NAME_ONELINE                         116\n# define X509_F_X509_NAME_PRINT                           117\n# define X509_F_X509_PRINT_EX_FP                          118\n# define X509_F_X509_PUBKEY_GET                           119\n# define X509_F_X509_PUBKEY_SET                           120\n# define X509_F_X509_REQ_CHECK_PRIVATE_KEY                144\n# define X509_F_X509_REQ_PRINT_EX                         121\n# define X509_F_X509_REQ_PRINT_FP                         122\n# define X509_F_X509_REQ_TO_X509                          123\n# define X509_F_X509_STORE_ADD_CERT                       124\n# define X509_F_X509_STORE_ADD_CRL                        125\n# define X509_F_X509_STORE_CTX_GET1_ISSUER                146\n# define X509_F_X509_STORE_CTX_INIT                       143\n# define X509_F_X509_STORE_CTX_NEW                        142\n# define X509_F_X509_STORE_CTX_PURPOSE_INHERIT            134\n# define X509_F_X509_TO_X509_REQ                          126\n# define X509_F_X509_TRUST_ADD                            133\n# define X509_F_X509_TRUST_SET                            141\n# define X509_F_X509_VERIFY_CERT                          127\n\n/* Reason codes. */\n# define X509_R_AKID_MISMATCH                             110\n# define X509_R_BAD_X509_FILETYPE                         100\n# define X509_R_BASE64_DECODE_ERROR                       118\n# define X509_R_CANT_CHECK_DH_KEY                         114\n# define X509_R_CERT_ALREADY_IN_HASH_TABLE                101\n# define X509_R_CRL_ALREADY_DELTA                         127\n# define X509_R_CRL_VERIFY_FAILURE                        131\n# define X509_R_ERR_ASN1_LIB                              102\n# define X509_R_IDP_MISMATCH                              128\n# define X509_R_INVALID_DIRECTORY                         113\n# define X509_R_INVALID_FIELD_NAME                        119\n# define X509_R_INVALID_TRUST                             123\n# define X509_R_ISSUER_MISMATCH                           129\n# define X509_R_KEY_TYPE_MISMATCH                         115\n# define X509_R_KEY_VALUES_MISMATCH                       116\n# define X509_R_LOADING_CERT_DIR                          103\n# define X509_R_LOADING_DEFAULTS                          104\n# define X509_R_METHOD_NOT_SUPPORTED                      124\n# define X509_R_NAME_TOO_LONG                             134\n# define X509_R_NEWER_CRL_NOT_NEWER                       132\n# define X509_R_NO_CERT_SET_FOR_US_TO_VERIFY              105\n# define X509_R_NO_CRL_NUMBER                             130\n# define X509_R_PUBLIC_KEY_DECODE_ERROR                   125\n# define X509_R_PUBLIC_KEY_ENCODE_ERROR                   126\n# define X509_R_SHOULD_RETRY                              106\n# define X509_R_UNABLE_TO_FIND_PARAMETERS_IN_CHAIN        107\n# define X509_R_UNABLE_TO_GET_CERTS_PUBLIC_KEY            108\n# define X509_R_UNKNOWN_KEY_TYPE                          117\n# define X509_R_UNKNOWN_NID                               109\n# define X509_R_UNKNOWN_PURPOSE_ID                        121\n# define X509_R_UNKNOWN_TRUST_ID                          120\n# define X509_R_UNSUPPORTED_ALGORITHM                     111\n# define X509_R_WRONG_LOOKUP_TYPE                         112\n# define X509_R_WRONG_TYPE                                122\n\n# ifdef  __cplusplus\n}\n# endif\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/x86_64/include/openssl/x509_vfy.h",
    "content": "/* crypto/x509/x509_vfy.h */\n/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)\n * All rights reserved.\n *\n * This package is an SSL implementation written\n * by Eric Young (eay@cryptsoft.com).\n * The implementation was written so as to conform with Netscapes SSL.\n *\n * This library is free for commercial and non-commercial use as long as\n * the following conditions are aheared to.  The following conditions\n * apply to all code found in this distribution, be it the RC4, RSA,\n * lhash, DES, etc., code; not just the SSL code.  The SSL documentation\n * included with this distribution is covered by the same copyright terms\n * except that the holder is Tim Hudson (tjh@cryptsoft.com).\n *\n * Copyright remains Eric Young's, and as such any Copyright notices in\n * the code are not to be removed.\n * If this package is used in a product, Eric Young should be given attribution\n * as the author of the parts of the library used.\n * This can be in the form of a textual message at program startup or\n * in documentation (online or textual) provided with the package.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the copyright\n *    notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in the\n *    documentation and/or other materials provided with the distribution.\n * 3. All advertising materials mentioning features or use of this software\n *    must display the following acknowledgement:\n *    \"This product includes cryptographic software written by\n *     Eric Young (eay@cryptsoft.com)\"\n *    The word 'cryptographic' can be left out if the rouines from the library\n *    being used are not cryptographic related :-).\n * 4. If you include any Windows specific code (or a derivative thereof) from\n *    the apps directory (application code) you must include an acknowledgement:\n *    \"This product includes software written by Tim Hudson (tjh@cryptsoft.com)\"\n *\n * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n * SUCH DAMAGE.\n *\n * The licence and distribution terms for any publically available version or\n * derivative of this code cannot be changed.  i.e. this code cannot simply be\n * copied and put under another distribution licence\n * [including the GNU Public Licence.]\n */\n\n#ifndef HEADER_X509_H\n# include <openssl/x509.h>\n/*\n * openssl/x509.h ends up #include-ing this file at about the only\n * appropriate moment.\n */\n#endif\n\n#ifndef HEADER_X509_VFY_H\n# define HEADER_X509_VFY_H\n\n# include <openssl/opensslconf.h>\n# ifndef OPENSSL_NO_LHASH\n#  include <openssl/lhash.h>\n# endif\n# include <openssl/bio.h>\n# include <openssl/crypto.h>\n# include <openssl/symhacks.h>\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n# if 0\n/* Outer object */\ntypedef struct x509_hash_dir_st {\n    int num_dirs;\n    char **dirs;\n    int *dirs_type;\n    int num_dirs_alloced;\n} X509_HASH_DIR_CTX;\n# endif\n\ntypedef struct x509_file_st {\n    int num_paths;              /* number of paths to files or directories */\n    int num_alloced;\n    char **paths;               /* the list of paths or directories */\n    int *path_type;\n} X509_CERT_FILE_CTX;\n\n/*******************************/\n/*-\nSSL_CTX -> X509_STORE\n                -> X509_LOOKUP\n                        ->X509_LOOKUP_METHOD\n                -> X509_LOOKUP\n                        ->X509_LOOKUP_METHOD\n\nSSL     -> X509_STORE_CTX\n                ->X509_STORE\n\nThe X509_STORE holds the tables etc for verification stuff.\nA X509_STORE_CTX is used while validating a single certificate.\nThe X509_STORE has X509_LOOKUPs for looking up certs.\nThe X509_STORE then calls a function to actually verify the\ncertificate chain.\n*/\n\n# define X509_LU_RETRY           -1\n# define X509_LU_FAIL            0\n# define X509_LU_X509            1\n# define X509_LU_CRL             2\n# define X509_LU_PKEY            3\n\ntypedef struct x509_object_st {\n    /* one of the above types */\n    int type;\n    union {\n        char *ptr;\n        X509 *x509;\n        X509_CRL *crl;\n        EVP_PKEY *pkey;\n    } data;\n} X509_OBJECT;\n\ntypedef struct x509_lookup_st X509_LOOKUP;\n\nDECLARE_STACK_OF(X509_LOOKUP)\nDECLARE_STACK_OF(X509_OBJECT)\n\n/* This is a static that defines the function interface */\ntypedef struct x509_lookup_method_st {\n    const char *name;\n    int (*new_item) (X509_LOOKUP *ctx);\n    void (*free) (X509_LOOKUP *ctx);\n    int (*init) (X509_LOOKUP *ctx);\n    int (*shutdown) (X509_LOOKUP *ctx);\n    int (*ctrl) (X509_LOOKUP *ctx, int cmd, const char *argc, long argl,\n                 char **ret);\n    int (*get_by_subject) (X509_LOOKUP *ctx, int type, X509_NAME *name,\n                           X509_OBJECT *ret);\n    int (*get_by_issuer_serial) (X509_LOOKUP *ctx, int type, X509_NAME *name,\n                                 ASN1_INTEGER *serial, X509_OBJECT *ret);\n    int (*get_by_fingerprint) (X509_LOOKUP *ctx, int type,\n                               unsigned char *bytes, int len,\n                               X509_OBJECT *ret);\n    int (*get_by_alias) (X509_LOOKUP *ctx, int type, char *str, int len,\n                         X509_OBJECT *ret);\n} X509_LOOKUP_METHOD;\n\ntypedef struct X509_VERIFY_PARAM_ID_st X509_VERIFY_PARAM_ID;\n\n/*\n * This structure hold all parameters associated with a verify operation by\n * including an X509_VERIFY_PARAM structure in related structures the\n * parameters used can be customized\n */\n\ntypedef struct X509_VERIFY_PARAM_st {\n    char *name;\n    time_t check_time;          /* Time to use */\n    unsigned long inh_flags;    /* Inheritance flags */\n    unsigned long flags;        /* Various verify flags */\n    int purpose;                /* purpose to check untrusted certificates */\n    int trust;                  /* trust setting to check */\n    int depth;                  /* Verify depth */\n    STACK_OF(ASN1_OBJECT) *policies; /* Permissible policies */\n    X509_VERIFY_PARAM_ID *id;   /* opaque ID data */\n} X509_VERIFY_PARAM;\n\nDECLARE_STACK_OF(X509_VERIFY_PARAM)\n\n/*\n * This is used to hold everything.  It is used for all certificate\n * validation.  Once we have a certificate chain, the 'verify' function is\n * then called to actually check the cert chain.\n */\nstruct x509_store_st {\n    /* The following is a cache of trusted certs */\n    int cache;                  /* if true, stash any hits */\n    STACK_OF(X509_OBJECT) *objs; /* Cache of all objects */\n    /* These are external lookup methods */\n    STACK_OF(X509_LOOKUP) *get_cert_methods;\n    X509_VERIFY_PARAM *param;\n    /* Callbacks for various operations */\n    /* called to verify a certificate */\n    int (*verify) (X509_STORE_CTX *ctx);\n    /* error callback */\n    int (*verify_cb) (int ok, X509_STORE_CTX *ctx);\n    /* get issuers cert from ctx */\n    int (*get_issuer) (X509 **issuer, X509_STORE_CTX *ctx, X509 *x);\n    /* check issued */\n    int (*check_issued) (X509_STORE_CTX *ctx, X509 *x, X509 *issuer);\n    /* Check revocation status of chain */\n    int (*check_revocation) (X509_STORE_CTX *ctx);\n    /* retrieve CRL */\n    int (*get_crl) (X509_STORE_CTX *ctx, X509_CRL **crl, X509 *x);\n    /* Check CRL validity */\n    int (*check_crl) (X509_STORE_CTX *ctx, X509_CRL *crl);\n    /* Check certificate against CRL */\n    int (*cert_crl) (X509_STORE_CTX *ctx, X509_CRL *crl, X509 *x);\n    STACK_OF(X509) *(*lookup_certs) (X509_STORE_CTX *ctx, X509_NAME *nm);\n    STACK_OF(X509_CRL) *(*lookup_crls) (X509_STORE_CTX *ctx, X509_NAME *nm);\n    int (*cleanup) (X509_STORE_CTX *ctx);\n    CRYPTO_EX_DATA ex_data;\n    int references;\n} /* X509_STORE */ ;\n\nint X509_STORE_set_depth(X509_STORE *store, int depth);\n\n# define X509_STORE_set_verify_cb_func(ctx,func) ((ctx)->verify_cb=(func))\n# define X509_STORE_set_verify_func(ctx,func)    ((ctx)->verify=(func))\n\n/* This is the functions plus an instance of the local variables. */\nstruct x509_lookup_st {\n    int init;                   /* have we been started */\n    int skip;                   /* don't use us. */\n    X509_LOOKUP_METHOD *method; /* the functions */\n    char *method_data;          /* method data */\n    X509_STORE *store_ctx;      /* who owns us */\n} /* X509_LOOKUP */ ;\n\n/*\n * This is a used when verifying cert chains.  Since the gathering of the\n * cert chain can take some time (and have to be 'retried', this needs to be\n * kept and passed around.\n */\nstruct x509_store_ctx_st {      /* X509_STORE_CTX */\n    X509_STORE *ctx;\n    /* used when looking up certs */\n    int current_method;\n    /* The following are set by the caller */\n    /* The cert to check */\n    X509 *cert;\n    /* chain of X509s - untrusted - passed in */\n    STACK_OF(X509) *untrusted;\n    /* set of CRLs passed in */\n    STACK_OF(X509_CRL) *crls;\n    X509_VERIFY_PARAM *param;\n    /* Other info for use with get_issuer() */\n    void *other_ctx;\n    /* Callbacks for various operations */\n    /* called to verify a certificate */\n    int (*verify) (X509_STORE_CTX *ctx);\n    /* error callback */\n    int (*verify_cb) (int ok, X509_STORE_CTX *ctx);\n    /* get issuers cert from ctx */\n    int (*get_issuer) (X509 **issuer, X509_STORE_CTX *ctx, X509 *x);\n    /* check issued */\n    int (*check_issued) (X509_STORE_CTX *ctx, X509 *x, X509 *issuer);\n    /* Check revocation status of chain */\n    int (*check_revocation) (X509_STORE_CTX *ctx);\n    /* retrieve CRL */\n    int (*get_crl) (X509_STORE_CTX *ctx, X509_CRL **crl, X509 *x);\n    /* Check CRL validity */\n    int (*check_crl) (X509_STORE_CTX *ctx, X509_CRL *crl);\n    /* Check certificate against CRL */\n    int (*cert_crl) (X509_STORE_CTX *ctx, X509_CRL *crl, X509 *x);\n    int (*check_policy) (X509_STORE_CTX *ctx);\n    STACK_OF(X509) *(*lookup_certs) (X509_STORE_CTX *ctx, X509_NAME *nm);\n    STACK_OF(X509_CRL) *(*lookup_crls) (X509_STORE_CTX *ctx, X509_NAME *nm);\n    int (*cleanup) (X509_STORE_CTX *ctx);\n    /* The following is built up */\n    /* if 0, rebuild chain */\n    int valid;\n    /* index of last untrusted cert */\n    int last_untrusted;\n    /* chain of X509s - built up and trusted */\n    STACK_OF(X509) *chain;\n    /* Valid policy tree */\n    X509_POLICY_TREE *tree;\n    /* Require explicit policy value */\n    int explicit_policy;\n    /* When something goes wrong, this is why */\n    int error_depth;\n    int error;\n    X509 *current_cert;\n    /* cert currently being tested as valid issuer */\n    X509 *current_issuer;\n    /* current CRL */\n    X509_CRL *current_crl;\n    /* score of current CRL */\n    int current_crl_score;\n    /* Reason mask */\n    unsigned int current_reasons;\n    /* For CRL path validation: parent context */\n    X509_STORE_CTX *parent;\n    CRYPTO_EX_DATA ex_data;\n} /* X509_STORE_CTX */ ;\n\nvoid X509_STORE_CTX_set_depth(X509_STORE_CTX *ctx, int depth);\n\n# define X509_STORE_CTX_set_app_data(ctx,data) \\\n        X509_STORE_CTX_set_ex_data(ctx,0,data)\n# define X509_STORE_CTX_get_app_data(ctx) \\\n        X509_STORE_CTX_get_ex_data(ctx,0)\n\n# define X509_L_FILE_LOAD        1\n# define X509_L_ADD_DIR          2\n\n# define X509_LOOKUP_load_file(x,name,type) \\\n                X509_LOOKUP_ctrl((x),X509_L_FILE_LOAD,(name),(long)(type),NULL)\n\n# define X509_LOOKUP_add_dir(x,name,type) \\\n                X509_LOOKUP_ctrl((x),X509_L_ADD_DIR,(name),(long)(type),NULL)\n\n# define         X509_V_OK                                       0\n# define         X509_V_ERR_UNSPECIFIED                          1\n\n# define         X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT            2\n# define         X509_V_ERR_UNABLE_TO_GET_CRL                    3\n# define         X509_V_ERR_UNABLE_TO_DECRYPT_CERT_SIGNATURE     4\n# define         X509_V_ERR_UNABLE_TO_DECRYPT_CRL_SIGNATURE      5\n# define         X509_V_ERR_UNABLE_TO_DECODE_ISSUER_PUBLIC_KEY   6\n# define         X509_V_ERR_CERT_SIGNATURE_FAILURE               7\n# define         X509_V_ERR_CRL_SIGNATURE_FAILURE                8\n# define         X509_V_ERR_CERT_NOT_YET_VALID                   9\n# define         X509_V_ERR_CERT_HAS_EXPIRED                     10\n# define         X509_V_ERR_CRL_NOT_YET_VALID                    11\n# define         X509_V_ERR_CRL_HAS_EXPIRED                      12\n# define         X509_V_ERR_ERROR_IN_CERT_NOT_BEFORE_FIELD       13\n# define         X509_V_ERR_ERROR_IN_CERT_NOT_AFTER_FIELD        14\n# define         X509_V_ERR_ERROR_IN_CRL_LAST_UPDATE_FIELD       15\n# define         X509_V_ERR_ERROR_IN_CRL_NEXT_UPDATE_FIELD       16\n# define         X509_V_ERR_OUT_OF_MEM                           17\n# define         X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT          18\n# define         X509_V_ERR_SELF_SIGNED_CERT_IN_CHAIN            19\n# define         X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY    20\n# define         X509_V_ERR_UNABLE_TO_VERIFY_LEAF_SIGNATURE      21\n# define         X509_V_ERR_CERT_CHAIN_TOO_LONG                  22\n# define         X509_V_ERR_CERT_REVOKED                         23\n# define         X509_V_ERR_INVALID_CA                           24\n# define         X509_V_ERR_PATH_LENGTH_EXCEEDED                 25\n# define         X509_V_ERR_INVALID_PURPOSE                      26\n# define         X509_V_ERR_CERT_UNTRUSTED                       27\n# define         X509_V_ERR_CERT_REJECTED                        28\n/* These are 'informational' when looking for issuer cert */\n# define         X509_V_ERR_SUBJECT_ISSUER_MISMATCH              29\n# define         X509_V_ERR_AKID_SKID_MISMATCH                   30\n# define         X509_V_ERR_AKID_ISSUER_SERIAL_MISMATCH          31\n# define         X509_V_ERR_KEYUSAGE_NO_CERTSIGN                 32\n\n# define         X509_V_ERR_UNABLE_TO_GET_CRL_ISSUER             33\n# define         X509_V_ERR_UNHANDLED_CRITICAL_EXTENSION         34\n# define         X509_V_ERR_KEYUSAGE_NO_CRL_SIGN                 35\n# define         X509_V_ERR_UNHANDLED_CRITICAL_CRL_EXTENSION     36\n# define         X509_V_ERR_INVALID_NON_CA                       37\n# define         X509_V_ERR_PROXY_PATH_LENGTH_EXCEEDED           38\n# define         X509_V_ERR_KEYUSAGE_NO_DIGITAL_SIGNATURE        39\n# define         X509_V_ERR_PROXY_CERTIFICATES_NOT_ALLOWED       40\n\n# define         X509_V_ERR_INVALID_EXTENSION                    41\n# define         X509_V_ERR_INVALID_POLICY_EXTENSION             42\n# define         X509_V_ERR_NO_EXPLICIT_POLICY                   43\n# define         X509_V_ERR_DIFFERENT_CRL_SCOPE                  44\n# define         X509_V_ERR_UNSUPPORTED_EXTENSION_FEATURE        45\n\n# define         X509_V_ERR_UNNESTED_RESOURCE                    46\n\n# define         X509_V_ERR_PERMITTED_VIOLATION                  47\n# define         X509_V_ERR_EXCLUDED_VIOLATION                   48\n# define         X509_V_ERR_SUBTREE_MINMAX                       49\n# define         X509_V_ERR_APPLICATION_VERIFICATION             50\n# define         X509_V_ERR_UNSUPPORTED_CONSTRAINT_TYPE          51\n# define         X509_V_ERR_UNSUPPORTED_CONSTRAINT_SYNTAX        52\n# define         X509_V_ERR_UNSUPPORTED_NAME_SYNTAX              53\n# define         X509_V_ERR_CRL_PATH_VALIDATION_ERROR            54\n\n/* Suite B mode algorithm violation */\n# define         X509_V_ERR_SUITE_B_INVALID_VERSION              56\n# define         X509_V_ERR_SUITE_B_INVALID_ALGORITHM            57\n# define         X509_V_ERR_SUITE_B_INVALID_CURVE                58\n# define         X509_V_ERR_SUITE_B_INVALID_SIGNATURE_ALGORITHM  59\n# define         X509_V_ERR_SUITE_B_LOS_NOT_ALLOWED              60\n# define         X509_V_ERR_SUITE_B_CANNOT_SIGN_P_384_WITH_P_256 61\n\n/* Host, email and IP check errors */\n# define         X509_V_ERR_HOSTNAME_MISMATCH                    62\n# define         X509_V_ERR_EMAIL_MISMATCH                       63\n# define         X509_V_ERR_IP_ADDRESS_MISMATCH                  64\n\n/* Caller error */\n# define         X509_V_ERR_INVALID_CALL                         65\n/* Issuer lookup error */\n# define         X509_V_ERR_STORE_LOOKUP                         66\n\n# define         X509_V_ERR_PROXY_SUBJECT_NAME_VIOLATION         67\n\n/* Certificate verify flags */\n\n/* Send issuer+subject checks to verify_cb */\n# define X509_V_FLAG_CB_ISSUER_CHECK             0x1\n/* Use check time instead of current time */\n# define X509_V_FLAG_USE_CHECK_TIME              0x2\n/* Lookup CRLs */\n# define X509_V_FLAG_CRL_CHECK                   0x4\n/* Lookup CRLs for whole chain */\n# define X509_V_FLAG_CRL_CHECK_ALL               0x8\n/* Ignore unhandled critical extensions */\n# define X509_V_FLAG_IGNORE_CRITICAL             0x10\n/* Disable workarounds for broken certificates */\n# define X509_V_FLAG_X509_STRICT                 0x20\n/* Enable proxy certificate validation */\n# define X509_V_FLAG_ALLOW_PROXY_CERTS           0x40\n/* Enable policy checking */\n# define X509_V_FLAG_POLICY_CHECK                0x80\n/* Policy variable require-explicit-policy */\n# define X509_V_FLAG_EXPLICIT_POLICY             0x100\n/* Policy variable inhibit-any-policy */\n# define X509_V_FLAG_INHIBIT_ANY                 0x200\n/* Policy variable inhibit-policy-mapping */\n# define X509_V_FLAG_INHIBIT_MAP                 0x400\n/* Notify callback that policy is OK */\n# define X509_V_FLAG_NOTIFY_POLICY               0x800\n/* Extended CRL features such as indirect CRLs, alternate CRL signing keys */\n# define X509_V_FLAG_EXTENDED_CRL_SUPPORT        0x1000\n/* Delta CRL support */\n# define X509_V_FLAG_USE_DELTAS                  0x2000\n/* Check selfsigned CA signature */\n# define X509_V_FLAG_CHECK_SS_SIGNATURE          0x4000\n/* Use trusted store first */\n# define X509_V_FLAG_TRUSTED_FIRST               0x8000\n/* Suite B 128 bit only mode: not normally used */\n# define X509_V_FLAG_SUITEB_128_LOS_ONLY         0x10000\n/* Suite B 192 bit only mode */\n# define X509_V_FLAG_SUITEB_192_LOS              0x20000\n/* Suite B 128 bit mode allowing 192 bit algorithms */\n# define X509_V_FLAG_SUITEB_128_LOS              0x30000\n\n/* Allow partial chains if at least one certificate is in trusted store */\n# define X509_V_FLAG_PARTIAL_CHAIN               0x80000\n/*\n * If the initial chain is not trusted, do not attempt to build an alternative\n * chain. Alternate chain checking was introduced in 1.0.2b. Setting this flag\n * will force the behaviour to match that of previous versions.\n */\n# define X509_V_FLAG_NO_ALT_CHAINS               0x100000\n\n# define X509_VP_FLAG_DEFAULT                    0x1\n# define X509_VP_FLAG_OVERWRITE                  0x2\n# define X509_VP_FLAG_RESET_FLAGS                0x4\n# define X509_VP_FLAG_LOCKED                     0x8\n# define X509_VP_FLAG_ONCE                       0x10\n\n/* Internal use: mask of policy related options */\n# define X509_V_FLAG_POLICY_MASK (X509_V_FLAG_POLICY_CHECK \\\n                                | X509_V_FLAG_EXPLICIT_POLICY \\\n                                | X509_V_FLAG_INHIBIT_ANY \\\n                                | X509_V_FLAG_INHIBIT_MAP)\n\nint X509_OBJECT_idx_by_subject(STACK_OF(X509_OBJECT) *h, int type,\n                               X509_NAME *name);\nX509_OBJECT *X509_OBJECT_retrieve_by_subject(STACK_OF(X509_OBJECT) *h,\n                                             int type, X509_NAME *name);\nX509_OBJECT *X509_OBJECT_retrieve_match(STACK_OF(X509_OBJECT) *h,\n                                        X509_OBJECT *x);\nvoid X509_OBJECT_up_ref_count(X509_OBJECT *a);\nvoid X509_OBJECT_free_contents(X509_OBJECT *a);\nX509_STORE *X509_STORE_new(void);\nvoid X509_STORE_free(X509_STORE *v);\n\nSTACK_OF(X509) *X509_STORE_get1_certs(X509_STORE_CTX *st, X509_NAME *nm);\nSTACK_OF(X509_CRL) *X509_STORE_get1_crls(X509_STORE_CTX *st, X509_NAME *nm);\nint X509_STORE_set_flags(X509_STORE *ctx, unsigned long flags);\nint X509_STORE_set_purpose(X509_STORE *ctx, int purpose);\nint X509_STORE_set_trust(X509_STORE *ctx, int trust);\nint X509_STORE_set1_param(X509_STORE *ctx, X509_VERIFY_PARAM *pm);\n\nvoid X509_STORE_set_verify_cb(X509_STORE *ctx,\n                              int (*verify_cb) (int, X509_STORE_CTX *));\n\nvoid X509_STORE_set_lookup_crls_cb(X509_STORE *ctx,\n                                   STACK_OF(X509_CRL) *(*cb) (X509_STORE_CTX\n                                                              *ctx,\n                                                              X509_NAME *nm));\n\nX509_STORE_CTX *X509_STORE_CTX_new(void);\n\nint X509_STORE_CTX_get1_issuer(X509 **issuer, X509_STORE_CTX *ctx, X509 *x);\n\nvoid X509_STORE_CTX_free(X509_STORE_CTX *ctx);\nint X509_STORE_CTX_init(X509_STORE_CTX *ctx, X509_STORE *store,\n                        X509 *x509, STACK_OF(X509) *chain);\nvoid X509_STORE_CTX_trusted_stack(X509_STORE_CTX *ctx, STACK_OF(X509) *sk);\nvoid X509_STORE_CTX_cleanup(X509_STORE_CTX *ctx);\n\nX509_STORE *X509_STORE_CTX_get0_store(X509_STORE_CTX *ctx);\n\nX509_LOOKUP *X509_STORE_add_lookup(X509_STORE *v, X509_LOOKUP_METHOD *m);\n\nX509_LOOKUP_METHOD *X509_LOOKUP_hash_dir(void);\nX509_LOOKUP_METHOD *X509_LOOKUP_file(void);\n\nint X509_STORE_add_cert(X509_STORE *ctx, X509 *x);\nint X509_STORE_add_crl(X509_STORE *ctx, X509_CRL *x);\n\nint X509_STORE_get_by_subject(X509_STORE_CTX *vs, int type, X509_NAME *name,\n                              X509_OBJECT *ret);\n\nint X509_LOOKUP_ctrl(X509_LOOKUP *ctx, int cmd, const char *argc,\n                     long argl, char **ret);\n\n# ifndef OPENSSL_NO_STDIO\nint X509_load_cert_file(X509_LOOKUP *ctx, const char *file, int type);\nint X509_load_crl_file(X509_LOOKUP *ctx, const char *file, int type);\nint X509_load_cert_crl_file(X509_LOOKUP *ctx, const char *file, int type);\n# endif\n\nX509_LOOKUP *X509_LOOKUP_new(X509_LOOKUP_METHOD *method);\nvoid X509_LOOKUP_free(X509_LOOKUP *ctx);\nint X509_LOOKUP_init(X509_LOOKUP *ctx);\nint X509_LOOKUP_by_subject(X509_LOOKUP *ctx, int type, X509_NAME *name,\n                           X509_OBJECT *ret);\nint X509_LOOKUP_by_issuer_serial(X509_LOOKUP *ctx, int type, X509_NAME *name,\n                                 ASN1_INTEGER *serial, X509_OBJECT *ret);\nint X509_LOOKUP_by_fingerprint(X509_LOOKUP *ctx, int type,\n                               unsigned char *bytes, int len,\n                               X509_OBJECT *ret);\nint X509_LOOKUP_by_alias(X509_LOOKUP *ctx, int type, char *str, int len,\n                         X509_OBJECT *ret);\nint X509_LOOKUP_shutdown(X509_LOOKUP *ctx);\n\n# ifndef OPENSSL_NO_STDIO\nint X509_STORE_load_locations(X509_STORE *ctx,\n                              const char *file, const char *dir);\nint X509_STORE_set_default_paths(X509_STORE *ctx);\n# endif\n\nint X509_STORE_CTX_get_ex_new_index(long argl, void *argp,\n                                    CRYPTO_EX_new *new_func,\n                                    CRYPTO_EX_dup *dup_func,\n                                    CRYPTO_EX_free *free_func);\nint X509_STORE_CTX_set_ex_data(X509_STORE_CTX *ctx, int idx, void *data);\nvoid *X509_STORE_CTX_get_ex_data(X509_STORE_CTX *ctx, int idx);\nint X509_STORE_CTX_get_error(X509_STORE_CTX *ctx);\nvoid X509_STORE_CTX_set_error(X509_STORE_CTX *ctx, int s);\nint X509_STORE_CTX_get_error_depth(X509_STORE_CTX *ctx);\nX509 *X509_STORE_CTX_get_current_cert(X509_STORE_CTX *ctx);\nX509 *X509_STORE_CTX_get0_current_issuer(X509_STORE_CTX *ctx);\nX509_CRL *X509_STORE_CTX_get0_current_crl(X509_STORE_CTX *ctx);\nX509_STORE_CTX *X509_STORE_CTX_get0_parent_ctx(X509_STORE_CTX *ctx);\nSTACK_OF(X509) *X509_STORE_CTX_get_chain(X509_STORE_CTX *ctx);\nSTACK_OF(X509) *X509_STORE_CTX_get1_chain(X509_STORE_CTX *ctx);\nvoid X509_STORE_CTX_set_cert(X509_STORE_CTX *c, X509 *x);\nvoid X509_STORE_CTX_set_chain(X509_STORE_CTX *c, STACK_OF(X509) *sk);\nvoid X509_STORE_CTX_set0_crls(X509_STORE_CTX *c, STACK_OF(X509_CRL) *sk);\nint X509_STORE_CTX_set_purpose(X509_STORE_CTX *ctx, int purpose);\nint X509_STORE_CTX_set_trust(X509_STORE_CTX *ctx, int trust);\nint X509_STORE_CTX_purpose_inherit(X509_STORE_CTX *ctx, int def_purpose,\n                                   int purpose, int trust);\nvoid X509_STORE_CTX_set_flags(X509_STORE_CTX *ctx, unsigned long flags);\nvoid X509_STORE_CTX_set_time(X509_STORE_CTX *ctx, unsigned long flags,\n                             time_t t);\nvoid X509_STORE_CTX_set_verify_cb(X509_STORE_CTX *ctx,\n                                  int (*verify_cb) (int, X509_STORE_CTX *));\n\nX509_POLICY_TREE *X509_STORE_CTX_get0_policy_tree(X509_STORE_CTX *ctx);\nint X509_STORE_CTX_get_explicit_policy(X509_STORE_CTX *ctx);\n\nX509_VERIFY_PARAM *X509_STORE_CTX_get0_param(X509_STORE_CTX *ctx);\nvoid X509_STORE_CTX_set0_param(X509_STORE_CTX *ctx, X509_VERIFY_PARAM *param);\nint X509_STORE_CTX_set_default(X509_STORE_CTX *ctx, const char *name);\n\n/* X509_VERIFY_PARAM functions */\n\nX509_VERIFY_PARAM *X509_VERIFY_PARAM_new(void);\nvoid X509_VERIFY_PARAM_free(X509_VERIFY_PARAM *param);\nint X509_VERIFY_PARAM_inherit(X509_VERIFY_PARAM *to,\n                              const X509_VERIFY_PARAM *from);\nint X509_VERIFY_PARAM_set1(X509_VERIFY_PARAM *to,\n                           const X509_VERIFY_PARAM *from);\nint X509_VERIFY_PARAM_set1_name(X509_VERIFY_PARAM *param, const char *name);\nint X509_VERIFY_PARAM_set_flags(X509_VERIFY_PARAM *param,\n                                unsigned long flags);\nint X509_VERIFY_PARAM_clear_flags(X509_VERIFY_PARAM *param,\n                                  unsigned long flags);\nunsigned long X509_VERIFY_PARAM_get_flags(X509_VERIFY_PARAM *param);\nint X509_VERIFY_PARAM_set_purpose(X509_VERIFY_PARAM *param, int purpose);\nint X509_VERIFY_PARAM_set_trust(X509_VERIFY_PARAM *param, int trust);\nvoid X509_VERIFY_PARAM_set_depth(X509_VERIFY_PARAM *param, int depth);\nvoid X509_VERIFY_PARAM_set_time(X509_VERIFY_PARAM *param, time_t t);\nint X509_VERIFY_PARAM_add0_policy(X509_VERIFY_PARAM *param,\n                                  ASN1_OBJECT *policy);\nint X509_VERIFY_PARAM_set1_policies(X509_VERIFY_PARAM *param,\n                                    STACK_OF(ASN1_OBJECT) *policies);\n\nint X509_VERIFY_PARAM_set1_host(X509_VERIFY_PARAM *param,\n                                const char *name, size_t namelen);\nint X509_VERIFY_PARAM_add1_host(X509_VERIFY_PARAM *param,\n                                const char *name, size_t namelen);\nvoid X509_VERIFY_PARAM_set_hostflags(X509_VERIFY_PARAM *param,\n                                     unsigned int flags);\nchar *X509_VERIFY_PARAM_get0_peername(X509_VERIFY_PARAM *);\nint X509_VERIFY_PARAM_set1_email(X509_VERIFY_PARAM *param,\n                                 const char *email, size_t emaillen);\nint X509_VERIFY_PARAM_set1_ip(X509_VERIFY_PARAM *param,\n                              const unsigned char *ip, size_t iplen);\nint X509_VERIFY_PARAM_set1_ip_asc(X509_VERIFY_PARAM *param,\n                                  const char *ipasc);\n\nint X509_VERIFY_PARAM_get_depth(const X509_VERIFY_PARAM *param);\nconst char *X509_VERIFY_PARAM_get0_name(const X509_VERIFY_PARAM *param);\n\nint X509_VERIFY_PARAM_add0_table(X509_VERIFY_PARAM *param);\nint X509_VERIFY_PARAM_get_count(void);\nconst X509_VERIFY_PARAM *X509_VERIFY_PARAM_get0(int id);\nconst X509_VERIFY_PARAM *X509_VERIFY_PARAM_lookup(const char *name);\nvoid X509_VERIFY_PARAM_table_cleanup(void);\n\nint X509_policy_check(X509_POLICY_TREE **ptree, int *pexplicit_policy,\n                      STACK_OF(X509) *certs,\n                      STACK_OF(ASN1_OBJECT) *policy_oids, unsigned int flags);\n\nvoid X509_policy_tree_free(X509_POLICY_TREE *tree);\n\nint X509_policy_tree_level_count(const X509_POLICY_TREE *tree);\nX509_POLICY_LEVEL *X509_policy_tree_get0_level(const X509_POLICY_TREE *tree,\n                                               int i);\n\nSTACK_OF(X509_POLICY_NODE) *X509_policy_tree_get0_policies(const\n                                                           X509_POLICY_TREE\n                                                           *tree);\n\nSTACK_OF(X509_POLICY_NODE) *X509_policy_tree_get0_user_policies(const\n                                                                X509_POLICY_TREE\n                                                                *tree);\n\nint X509_policy_level_node_count(X509_POLICY_LEVEL *level);\n\nX509_POLICY_NODE *X509_policy_level_get0_node(X509_POLICY_LEVEL *level,\n                                              int i);\n\nconst ASN1_OBJECT *X509_policy_node_get0_policy(const X509_POLICY_NODE *node);\n\nSTACK_OF(POLICYQUALINFO) *X509_policy_node_get0_qualifiers(const\n                                                           X509_POLICY_NODE\n                                                           *node);\nconst X509_POLICY_NODE *X509_policy_node_get0_parent(const X509_POLICY_NODE\n                                                     *node);\n\n#ifdef  __cplusplus\n}\n#endif\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/android_old/x86_64/include/openssl/x509v3.h",
    "content": "/* x509v3.h */\n/*\n * Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL project\n * 1999.\n */\n/* ====================================================================\n * Copyright (c) 1999-2004 The OpenSSL Project.  All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n *\n * 1. Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n *\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in\n *    the documentation and/or other materials provided with the\n *    distribution.\n *\n * 3. All advertising materials mentioning features or use of this\n *    software must display the following acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)\"\n *\n * 4. The names \"OpenSSL Toolkit\" and \"OpenSSL Project\" must not be used to\n *    endorse or promote products derived from this software without\n *    prior written permission. For written permission, please contact\n *    licensing@OpenSSL.org.\n *\n * 5. Products derived from this software may not be called \"OpenSSL\"\n *    nor may \"OpenSSL\" appear in their names without prior written\n *    permission of the OpenSSL Project.\n *\n * 6. Redistributions of any form whatsoever must retain the following\n *    acknowledgment:\n *    \"This product includes software developed by the OpenSSL Project\n *    for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)\"\n *\n * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY\n * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\n * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR\n * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\n * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,\n * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED\n * OF THE POSSIBILITY OF SUCH DAMAGE.\n * ====================================================================\n *\n * This product includes cryptographic software written by Eric Young\n * (eay@cryptsoft.com).  This product includes software written by Tim\n * Hudson (tjh@cryptsoft.com).\n *\n */\n#ifndef HEADER_X509V3_H\n# define HEADER_X509V3_H\n\n# include <openssl/bio.h>\n# include <openssl/x509.h>\n# include <openssl/conf.h>\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n# ifdef OPENSSL_SYS_WIN32\n/* Under Win32 these are defined in wincrypt.h */\n#  undef X509_NAME\n#  undef X509_CERT_PAIR\n#  undef X509_EXTENSIONS\n# endif\n\n/* Forward reference */\nstruct v3_ext_method;\nstruct v3_ext_ctx;\n\n/* Useful typedefs */\n\ntypedef void *(*X509V3_EXT_NEW)(void);\ntypedef void (*X509V3_EXT_FREE) (void *);\ntypedef void *(*X509V3_EXT_D2I)(void *, const unsigned char **, long);\ntypedef int (*X509V3_EXT_I2D) (void *, unsigned char **);\ntypedef STACK_OF(CONF_VALUE) *\n    (*X509V3_EXT_I2V) (const struct v3_ext_method *method, void *ext,\n                       STACK_OF(CONF_VALUE) *extlist);\ntypedef void *(*X509V3_EXT_V2I)(const struct v3_ext_method *method,\n                                struct v3_ext_ctx *ctx,\n                                STACK_OF(CONF_VALUE) *values);\ntypedef char *(*X509V3_EXT_I2S)(const struct v3_ext_method *method,\n                                void *ext);\ntypedef void *(*X509V3_EXT_S2I)(const struct v3_ext_method *method,\n                                struct v3_ext_ctx *ctx, const char *str);\ntypedef int (*X509V3_EXT_I2R) (const struct v3_ext_method *method, void *ext,\n                               BIO *out, int indent);\ntypedef void *(*X509V3_EXT_R2I)(const struct v3_ext_method *method,\n                                struct v3_ext_ctx *ctx, const char *str);\n\n/* V3 extension structure */\n\nstruct v3_ext_method {\n    int ext_nid;\n    int ext_flags;\n/* If this is set the following four fields are ignored */\n    ASN1_ITEM_EXP *it;\n/* Old style ASN1 calls */\n    X509V3_EXT_NEW ext_new;\n    X509V3_EXT_FREE ext_free;\n    X509V3_EXT_D2I d2i;\n    X509V3_EXT_I2D i2d;\n/* The following pair is used for string extensions */\n    X509V3_EXT_I2S i2s;\n    X509V3_EXT_S2I s2i;\n/* The following pair is used for multi-valued extensions */\n    X509V3_EXT_I2V i2v;\n    X509V3_EXT_V2I v2i;\n/* The following are used for raw extensions */\n    X509V3_EXT_I2R i2r;\n    X509V3_EXT_R2I r2i;\n    void *usr_data;             /* Any extension specific data */\n};\n\ntypedef struct X509V3_CONF_METHOD_st {\n    char *(*get_string) (void *db, char *section, char *value);\n    STACK_OF(CONF_VALUE) *(*get_section) (void *db, char *section);\n    void (*free_string) (void *db, char *string);\n    void (*free_section) (void *db, STACK_OF(CONF_VALUE) *section);\n} X509V3_CONF_METHOD;\n\n/* Context specific info */\nstruct v3_ext_ctx {\n# define CTX_TEST 0x1\n    int flags;\n    X509 *issuer_cert;\n    X509 *subject_cert;\n    X509_REQ *subject_req;\n    X509_CRL *crl;\n    X509V3_CONF_METHOD *db_meth;\n    void *db;\n/* Maybe more here */\n};\n\ntypedef struct v3_ext_method X509V3_EXT_METHOD;\n\nDECLARE_STACK_OF(X509V3_EXT_METHOD)\n\n/* ext_flags values */\n# define X509V3_EXT_DYNAMIC      0x1\n# define X509V3_EXT_CTX_DEP      0x2\n# define X509V3_EXT_MULTILINE    0x4\n\ntypedef BIT_STRING_BITNAME ENUMERATED_NAMES;\n\ntypedef struct BASIC_CONSTRAINTS_st {\n    int ca;\n    ASN1_INTEGER *pathlen;\n} BASIC_CONSTRAINTS;\n\ntypedef struct PKEY_USAGE_PERIOD_st {\n    ASN1_GENERALIZEDTIME *notBefore;\n    ASN1_GENERALIZEDTIME *notAfter;\n} PKEY_USAGE_PERIOD;\n\ntypedef struct otherName_st {\n    ASN1_OBJECT *type_id;\n    ASN1_TYPE *value;\n} OTHERNAME;\n\ntypedef struct EDIPartyName_st {\n    ASN1_STRING *nameAssigner;\n    ASN1_STRING *partyName;\n} EDIPARTYNAME;\n\ntypedef struct GENERAL_NAME_st {\n# define GEN_OTHERNAME   0\n# define GEN_EMAIL       1\n# define GEN_DNS         2\n# define GEN_X400        3\n# define GEN_DIRNAME     4\n# define GEN_EDIPARTY    5\n# define GEN_URI         6\n# define GEN_IPADD       7\n# define GEN_RID         8\n    int type;\n    union {\n        char *ptr;\n        OTHERNAME *otherName;   /* otherName */\n        ASN1_IA5STRING *rfc822Name;\n        ASN1_IA5STRING *dNSName;\n        ASN1_TYPE *x400Address;\n        X509_NAME *directoryName;\n        EDIPARTYNAME *ediPartyName;\n        ASN1_IA5STRING *uniformResourceIdentifier;\n        ASN1_OCTET_STRING *iPAddress;\n        ASN1_OBJECT *registeredID;\n        /* Old names */\n        ASN1_OCTET_STRING *ip;  /* iPAddress */\n        X509_NAME *dirn;        /* dirn */\n        ASN1_IA5STRING *ia5;    /* rfc822Name, dNSName,\n                                 * uniformResourceIdentifier */\n        ASN1_OBJECT *rid;       /* registeredID */\n        ASN1_TYPE *other;       /* x400Address */\n    } d;\n} GENERAL_NAME;\n\ntypedef STACK_OF(GENERAL_NAME) GENERAL_NAMES;\n\ntypedef struct ACCESS_DESCRIPTION_st {\n    ASN1_OBJECT *method;\n    GENERAL_NAME *location;\n} ACCESS_DESCRIPTION;\n\ntypedef STACK_OF(ACCESS_DESCRIPTION) AUTHORITY_INFO_ACCESS;\n\ntypedef STACK_OF(ASN1_OBJECT) EXTENDED_KEY_USAGE;\n\nDECLARE_STACK_OF(GENERAL_NAME)\nDECLARE_ASN1_SET_OF(GENERAL_NAME)\n\nDECLARE_STACK_OF(ACCESS_DESCRIPTION)\nDECLARE_ASN1_SET_OF(ACCESS_DESCRIPTION)\n\ntypedef struct DIST_POINT_NAME_st {\n    int type;\n    union {\n        GENERAL_NAMES *fullname;\n        STACK_OF(X509_NAME_ENTRY) *relativename;\n    } name;\n/* If relativename then this contains the full distribution point name */\n    X509_NAME *dpname;\n} DIST_POINT_NAME;\n/* All existing reasons */\n# define CRLDP_ALL_REASONS       0x807f\n\n# define CRL_REASON_NONE                         -1\n# define CRL_REASON_UNSPECIFIED                  0\n# define CRL_REASON_KEY_COMPROMISE               1\n# define CRL_REASON_CA_COMPROMISE                2\n# define CRL_REASON_AFFILIATION_CHANGED          3\n# define CRL_REASON_SUPERSEDED                   4\n# define CRL_REASON_CESSATION_OF_OPERATION       5\n# define CRL_REASON_CERTIFICATE_HOLD             6\n# define CRL_REASON_REMOVE_FROM_CRL              8\n# define CRL_REASON_PRIVILEGE_WITHDRAWN          9\n# define CRL_REASON_AA_COMPROMISE                10\n\nstruct DIST_POINT_st {\n    DIST_POINT_NAME *distpoint;\n    ASN1_BIT_STRING *reasons;\n    GENERAL_NAMES *CRLissuer;\n    int dp_reasons;\n};\n\ntypedef STACK_OF(DIST_POINT) CRL_DIST_POINTS;\n\nDECLARE_STACK_OF(DIST_POINT)\nDECLARE_ASN1_SET_OF(DIST_POINT)\n\nstruct AUTHORITY_KEYID_st {\n    ASN1_OCTET_STRING *keyid;\n    GENERAL_NAMES *issuer;\n    ASN1_INTEGER *serial;\n};\n\n/* Strong extranet structures */\n\ntypedef struct SXNET_ID_st {\n    ASN1_INTEGER *zone;\n    ASN1_OCTET_STRING *user;\n} SXNETID;\n\nDECLARE_STACK_OF(SXNETID)\nDECLARE_ASN1_SET_OF(SXNETID)\n\ntypedef struct SXNET_st {\n    ASN1_INTEGER *version;\n    STACK_OF(SXNETID) *ids;\n} SXNET;\n\ntypedef struct NOTICEREF_st {\n    ASN1_STRING *organization;\n    STACK_OF(ASN1_INTEGER) *noticenos;\n} NOTICEREF;\n\ntypedef struct USERNOTICE_st {\n    NOTICEREF *noticeref;\n    ASN1_STRING *exptext;\n} USERNOTICE;\n\ntypedef struct POLICYQUALINFO_st {\n    ASN1_OBJECT *pqualid;\n    union {\n        ASN1_IA5STRING *cpsuri;\n        USERNOTICE *usernotice;\n        ASN1_TYPE *other;\n    } d;\n} POLICYQUALINFO;\n\nDECLARE_STACK_OF(POLICYQUALINFO)\nDECLARE_ASN1_SET_OF(POLICYQUALINFO)\n\ntypedef struct POLICYINFO_st {\n    ASN1_OBJECT *policyid;\n    STACK_OF(POLICYQUALINFO) *qualifiers;\n} POLICYINFO;\n\ntypedef STACK_OF(POLICYINFO) CERTIFICATEPOLICIES;\n\nDECLARE_STACK_OF(POLICYINFO)\nDECLARE_ASN1_SET_OF(POLICYINFO)\n\ntypedef struct POLICY_MAPPING_st {\n    ASN1_OBJECT *issuerDomainPolicy;\n    ASN1_OBJECT *subjectDomainPolicy;\n} POLICY_MAPPING;\n\nDECLARE_STACK_OF(POLICY_MAPPING)\n\ntypedef STACK_OF(POLICY_MAPPING) POLICY_MAPPINGS;\n\ntypedef struct GENERAL_SUBTREE_st {\n    GENERAL_NAME *base;\n    ASN1_INTEGER *minimum;\n    ASN1_INTEGER *maximum;\n} GENERAL_SUBTREE;\n\nDECLARE_STACK_OF(GENERAL_SUBTREE)\n\nstruct NAME_CONSTRAINTS_st {\n    STACK_OF(GENERAL_SUBTREE) *permittedSubtrees;\n    STACK_OF(GENERAL_SUBTREE) *excludedSubtrees;\n};\n\ntypedef struct POLICY_CONSTRAINTS_st {\n    ASN1_INTEGER *requireExplicitPolicy;\n    ASN1_INTEGER *inhibitPolicyMapping;\n} POLICY_CONSTRAINTS;\n\n/* Proxy certificate structures, see RFC 3820 */\ntypedef struct PROXY_POLICY_st {\n    ASN1_OBJECT *policyLanguage;\n    ASN1_OCTET_STRING *policy;\n} PROXY_POLICY;\n\ntypedef struct PROXY_CERT_INFO_EXTENSION_st {\n    ASN1_INTEGER *pcPathLengthConstraint;\n    PROXY_POLICY *proxyPolicy;\n} PROXY_CERT_INFO_EXTENSION;\n\nDECLARE_ASN1_FUNCTIONS(PROXY_POLICY)\nDECLARE_ASN1_FUNCTIONS(PROXY_CERT_INFO_EXTENSION)\n\nstruct ISSUING_DIST_POINT_st {\n    DIST_POINT_NAME *distpoint;\n    int onlyuser;\n    int onlyCA;\n    ASN1_BIT_STRING *onlysomereasons;\n    int indirectCRL;\n    int onlyattr;\n};\n\n/* Values in idp_flags field */\n/* IDP present */\n# define IDP_PRESENT     0x1\n/* IDP values inconsistent */\n# define IDP_INVALID     0x2\n/* onlyuser true */\n# define IDP_ONLYUSER    0x4\n/* onlyCA true */\n# define IDP_ONLYCA      0x8\n/* onlyattr true */\n# define IDP_ONLYATTR    0x10\n/* indirectCRL true */\n# define IDP_INDIRECT    0x20\n/* onlysomereasons present */\n# define IDP_REASONS     0x40\n\n# define X509V3_conf_err(val) ERR_add_error_data(6, \"section:\", val->section, \\\n\",name:\", val->name, \",value:\", val->value);\n\n# define X509V3_set_ctx_test(ctx) \\\n                        X509V3_set_ctx(ctx, NULL, NULL, NULL, NULL, CTX_TEST)\n# define X509V3_set_ctx_nodb(ctx) (ctx)->db = NULL;\n\n# define EXT_BITSTRING(nid, table) { nid, 0, ASN1_ITEM_ref(ASN1_BIT_STRING), \\\n                        0,0,0,0, \\\n                        0,0, \\\n                        (X509V3_EXT_I2V)i2v_ASN1_BIT_STRING, \\\n                        (X509V3_EXT_V2I)v2i_ASN1_BIT_STRING, \\\n                        NULL, NULL, \\\n                        table}\n\n# define EXT_IA5STRING(nid) { nid, 0, ASN1_ITEM_ref(ASN1_IA5STRING), \\\n                        0,0,0,0, \\\n                        (X509V3_EXT_I2S)i2s_ASN1_IA5STRING, \\\n                        (X509V3_EXT_S2I)s2i_ASN1_IA5STRING, \\\n                        0,0,0,0, \\\n                        NULL}\n\n# define EXT_END { -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}\n\n/* X509_PURPOSE stuff */\n\n# define EXFLAG_BCONS            0x1\n# define EXFLAG_KUSAGE           0x2\n# define EXFLAG_XKUSAGE          0x4\n# define EXFLAG_NSCERT           0x8\n\n# define EXFLAG_CA               0x10\n/* Really self issued not necessarily self signed */\n# define EXFLAG_SI               0x20\n# define EXFLAG_V1               0x40\n# define EXFLAG_INVALID          0x80\n# define EXFLAG_SET              0x100\n# define EXFLAG_CRITICAL         0x200\n# define EXFLAG_PROXY            0x400\n\n# define EXFLAG_INVALID_POLICY   0x800\n# define EXFLAG_FRESHEST         0x1000\n/* Self signed */\n# define EXFLAG_SS               0x2000\n\n# define KU_DIGITAL_SIGNATURE    0x0080\n# define KU_NON_REPUDIATION      0x0040\n# define KU_KEY_ENCIPHERMENT     0x0020\n# define KU_DATA_ENCIPHERMENT    0x0010\n# define KU_KEY_AGREEMENT        0x0008\n# define KU_KEY_CERT_SIGN        0x0004\n# define KU_CRL_SIGN             0x0002\n# define KU_ENCIPHER_ONLY        0x0001\n# define KU_DECIPHER_ONLY        0x8000\n\n# define NS_SSL_CLIENT           0x80\n# define NS_SSL_SERVER           0x40\n# define NS_SMIME                0x20\n# define NS_OBJSIGN              0x10\n# define NS_SSL_CA               0x04\n# define NS_SMIME_CA             0x02\n# define NS_OBJSIGN_CA           0x01\n# define NS_ANY_CA               (NS_SSL_CA|NS_SMIME_CA|NS_OBJSIGN_CA)\n\n# define XKU_SSL_SERVER          0x1\n# define XKU_SSL_CLIENT          0x2\n# define XKU_SMIME               0x4\n# define XKU_CODE_SIGN           0x8\n# define XKU_SGC                 0x10\n# define XKU_OCSP_SIGN           0x20\n# define XKU_TIMESTAMP           0x40\n# define XKU_DVCS                0x80\n# define XKU_ANYEKU              0x100\n\n# define X509_PURPOSE_DYNAMIC    0x1\n# define X509_PURPOSE_DYNAMIC_NAME       0x2\n\ntypedef struct x509_purpose_st {\n    int purpose;\n    int trust;                  /* Default trust ID */\n    int flags;\n    int (*check_purpose) (const struct x509_purpose_st *, const X509 *, int);\n    char *name;\n    char *sname;\n    void *usr_data;\n} X509_PURPOSE;\n\n# define X509_PURPOSE_SSL_CLIENT         1\n# define X509_PURPOSE_SSL_SERVER         2\n# define X509_PURPOSE_NS_SSL_SERVER      3\n# define X509_PURPOSE_SMIME_SIGN         4\n# define X509_PURPOSE_SMIME_ENCRYPT      5\n# define X509_PURPOSE_CRL_SIGN           6\n# define X509_PURPOSE_ANY                7\n# define X509_PURPOSE_OCSP_HELPER        8\n# define X509_PURPOSE_TIMESTAMP_SIGN     9\n\n# define X509_PURPOSE_MIN                1\n# define X509_PURPOSE_MAX                9\n\n/* Flags for X509V3_EXT_print() */\n\n# define X509V3_EXT_UNKNOWN_MASK         (0xfL << 16)\n/* Return error for unknown extensions */\n# define X509V3_EXT_DEFAULT              0\n/* Print error for unknown extensions */\n# define X509V3_EXT_ERROR_UNKNOWN        (1L << 16)\n/* ASN1 parse unknown extensions */\n# define X509V3_EXT_PARSE_UNKNOWN        (2L << 16)\n/* BIO_dump unknown extensions */\n# define X509V3_EXT_DUMP_UNKNOWN         (3L << 16)\n\n/* Flags for X509V3_add1_i2d */\n\n# define X509V3_ADD_OP_MASK              0xfL\n# define X509V3_ADD_DEFAULT              0L\n# define X509V3_ADD_APPEND               1L\n# define X509V3_ADD_REPLACE              2L\n# define X509V3_ADD_REPLACE_EXISTING     3L\n# define X509V3_ADD_KEEP_EXISTING        4L\n# define X509V3_ADD_DELETE               5L\n# define X509V3_ADD_SILENT               0x10\n\nDECLARE_STACK_OF(X509_PURPOSE)\n\nDECLARE_ASN1_FUNCTIONS(BASIC_CONSTRAINTS)\n\nDECLARE_ASN1_FUNCTIONS(SXNET)\nDECLARE_ASN1_FUNCTIONS(SXNETID)\n\nint SXNET_add_id_asc(SXNET **psx, char *zone, char *user, int userlen);\nint SXNET_add_id_ulong(SXNET **psx, unsigned long lzone, char *user,\n                       int userlen);\nint SXNET_add_id_INTEGER(SXNET **psx, ASN1_INTEGER *izone, char *user,\n                         int userlen);\n\nASN1_OCTET_STRING *SXNET_get_id_asc(SXNET *sx, char *zone);\nASN1_OCTET_STRING *SXNET_get_id_ulong(SXNET *sx, unsigned long lzone);\nASN1_OCTET_STRING *SXNET_get_id_INTEGER(SXNET *sx, ASN1_INTEGER *zone);\n\nDECLARE_ASN1_FUNCTIONS(AUTHORITY_KEYID)\n\nDECLARE_ASN1_FUNCTIONS(PKEY_USAGE_PERIOD)\n\nDECLARE_ASN1_FUNCTIONS(GENERAL_NAME)\nGENERAL_NAME *GENERAL_NAME_dup(GENERAL_NAME *a);\nint GENERAL_NAME_cmp(GENERAL_NAME *a, GENERAL_NAME *b);\n\nASN1_BIT_STRING *v2i_ASN1_BIT_STRING(X509V3_EXT_METHOD *method,\n                                     X509V3_CTX *ctx,\n                                     STACK_OF(CONF_VALUE) *nval);\nSTACK_OF(CONF_VALUE) *i2v_ASN1_BIT_STRING(X509V3_EXT_METHOD *method,\n                                          ASN1_BIT_STRING *bits,\n                                          STACK_OF(CONF_VALUE) *extlist);\n\nSTACK_OF(CONF_VALUE) *i2v_GENERAL_NAME(X509V3_EXT_METHOD *method,\n                                       GENERAL_NAME *gen,\n                                       STACK_OF(CONF_VALUE) *ret);\nint GENERAL_NAME_print(BIO *out, GENERAL_NAME *gen);\n\nDECLARE_ASN1_FUNCTIONS(GENERAL_NAMES)\n\nSTACK_OF(CONF_VALUE) *i2v_GENERAL_NAMES(X509V3_EXT_METHOD *method,\n                                        GENERAL_NAMES *gen,\n                                        STACK_OF(CONF_VALUE) *extlist);\nGENERAL_NAMES *v2i_GENERAL_NAMES(const X509V3_EXT_METHOD *method,\n                                 X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *nval);\n\nDECLARE_ASN1_FUNCTIONS(OTHERNAME)\nDECLARE_ASN1_FUNCTIONS(EDIPARTYNAME)\nint OTHERNAME_cmp(OTHERNAME *a, OTHERNAME *b);\nvoid GENERAL_NAME_set0_value(GENERAL_NAME *a, int type, void *value);\nvoid *GENERAL_NAME_get0_value(GENERAL_NAME *a, int *ptype);\nint GENERAL_NAME_set0_othername(GENERAL_NAME *gen,\n                                ASN1_OBJECT *oid, ASN1_TYPE *value);\nint GENERAL_NAME_get0_otherName(GENERAL_NAME *gen,\n                                ASN1_OBJECT **poid, ASN1_TYPE **pvalue);\n\nchar *i2s_ASN1_OCTET_STRING(X509V3_EXT_METHOD *method,\n                            ASN1_OCTET_STRING *ia5);\nASN1_OCTET_STRING *s2i_ASN1_OCTET_STRING(X509V3_EXT_METHOD *method,\n                                         X509V3_CTX *ctx, char *str);\n\nDECLARE_ASN1_FUNCTIONS(EXTENDED_KEY_USAGE)\nint i2a_ACCESS_DESCRIPTION(BIO *bp, ACCESS_DESCRIPTION *a);\n\nDECLARE_ASN1_FUNCTIONS(CERTIFICATEPOLICIES)\nDECLARE_ASN1_FUNCTIONS(POLICYINFO)\nDECLARE_ASN1_FUNCTIONS(POLICYQUALINFO)\nDECLARE_ASN1_FUNCTIONS(USERNOTICE)\nDECLARE_ASN1_FUNCTIONS(NOTICEREF)\n\nDECLARE_ASN1_FUNCTIONS(CRL_DIST_POINTS)\nDECLARE_ASN1_FUNCTIONS(DIST_POINT)\nDECLARE_ASN1_FUNCTIONS(DIST_POINT_NAME)\nDECLARE_ASN1_FUNCTIONS(ISSUING_DIST_POINT)\n\nint DIST_POINT_set_dpname(DIST_POINT_NAME *dpn, X509_NAME *iname);\n\nint NAME_CONSTRAINTS_check(X509 *x, NAME_CONSTRAINTS *nc);\n\nDECLARE_ASN1_FUNCTIONS(ACCESS_DESCRIPTION)\nDECLARE_ASN1_FUNCTIONS(AUTHORITY_INFO_ACCESS)\n\nDECLARE_ASN1_ITEM(POLICY_MAPPING)\nDECLARE_ASN1_ALLOC_FUNCTIONS(POLICY_MAPPING)\nDECLARE_ASN1_ITEM(POLICY_MAPPINGS)\n\nDECLARE_ASN1_ITEM(GENERAL_SUBTREE)\nDECLARE_ASN1_ALLOC_FUNCTIONS(GENERAL_SUBTREE)\n\nDECLARE_ASN1_ITEM(NAME_CONSTRAINTS)\nDECLARE_ASN1_ALLOC_FUNCTIONS(NAME_CONSTRAINTS)\n\nDECLARE_ASN1_ALLOC_FUNCTIONS(POLICY_CONSTRAINTS)\nDECLARE_ASN1_ITEM(POLICY_CONSTRAINTS)\n\nGENERAL_NAME *a2i_GENERAL_NAME(GENERAL_NAME *out,\n                               const X509V3_EXT_METHOD *method,\n                               X509V3_CTX *ctx, int gen_type, char *value,\n                               int is_nc);\n\n# ifdef HEADER_CONF_H\nGENERAL_NAME *v2i_GENERAL_NAME(const X509V3_EXT_METHOD *method,\n                               X509V3_CTX *ctx, CONF_VALUE *cnf);\nGENERAL_NAME *v2i_GENERAL_NAME_ex(GENERAL_NAME *out,\n                                  const X509V3_EXT_METHOD *method,\n                                  X509V3_CTX *ctx, CONF_VALUE *cnf,\n                                  int is_nc);\nvoid X509V3_conf_free(CONF_VALUE *val);\n\nX509_EXTENSION *X509V3_EXT_nconf_nid(CONF *conf, X509V3_CTX *ctx, int ext_nid,\n                                     char *value);\nX509_EXTENSION *X509V3_EXT_nconf(CONF *conf, X509V3_CTX *ctx, char *name,\n                                 char *value);\nint X509V3_EXT_add_nconf_sk(CONF *conf, X509V3_CTX *ctx, char *section,\n                            STACK_OF(X509_EXTENSION) **sk);\nint X509V3_EXT_add_nconf(CONF *conf, X509V3_CTX *ctx, char *section,\n                         X509 *cert);\nint X509V3_EXT_REQ_add_nconf(CONF *conf, X509V3_CTX *ctx, char *section,\n                             X509_REQ *req);\nint X509V3_EXT_CRL_add_nconf(CONF *conf, X509V3_CTX *ctx, char *section,\n                             X509_CRL *crl);\n\nX509_EXTENSION *X509V3_EXT_conf_nid(LHASH_OF(CONF_VALUE) *conf,\n                                    X509V3_CTX *ctx, int ext_nid,\n                                    char *value);\nX509_EXTENSION *X509V3_EXT_conf(LHASH_OF(CONF_VALUE) *conf, X509V3_CTX *ctx,\n                                char *name, char *value);\nint X509V3_EXT_add_conf(LHASH_OF(CONF_VALUE) *conf, X509V3_CTX *ctx,\n                        char *section, X509 *cert);\nint X509V3_EXT_REQ_add_conf(LHASH_OF(CONF_VALUE) *conf, X509V3_CTX *ctx,\n                            char *section, X509_REQ *req);\nint X509V3_EXT_CRL_add_conf(LHASH_OF(CONF_VALUE) *conf, X509V3_CTX *ctx,\n                            char *section, X509_CRL *crl);\n\nint X509V3_add_value_bool_nf(char *name, int asn1_bool,\n                             STACK_OF(CONF_VALUE) **extlist);\nint X509V3_get_value_bool(CONF_VALUE *value, int *asn1_bool);\nint X509V3_get_value_int(CONF_VALUE *value, ASN1_INTEGER **aint);\nvoid X509V3_set_nconf(X509V3_CTX *ctx, CONF *conf);\nvoid X509V3_set_conf_lhash(X509V3_CTX *ctx, LHASH_OF(CONF_VALUE) *lhash);\n# endif\n\nchar *X509V3_get_string(X509V3_CTX *ctx, char *name, char *section);\nSTACK_OF(CONF_VALUE) *X509V3_get_section(X509V3_CTX *ctx, char *section);\nvoid X509V3_string_free(X509V3_CTX *ctx, char *str);\nvoid X509V3_section_free(X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *section);\nvoid X509V3_set_ctx(X509V3_CTX *ctx, X509 *issuer, X509 *subject,\n                    X509_REQ *req, X509_CRL *crl, int flags);\n\nint X509V3_add_value(const char *name, const char *value,\n                     STACK_OF(CONF_VALUE) **extlist);\nint X509V3_add_value_uchar(const char *name, const unsigned char *value,\n                           STACK_OF(CONF_VALUE) **extlist);\nint X509V3_add_value_bool(const char *name, int asn1_bool,\n                          STACK_OF(CONF_VALUE) **extlist);\nint X509V3_add_value_int(const char *name, ASN1_INTEGER *aint,\n                         STACK_OF(CONF_VALUE) **extlist);\nchar *i2s_ASN1_INTEGER(X509V3_EXT_METHOD *meth, ASN1_INTEGER *aint);\nASN1_INTEGER *s2i_ASN1_INTEGER(X509V3_EXT_METHOD *meth, char *value);\nchar *i2s_ASN1_ENUMERATED(X509V3_EXT_METHOD *meth, ASN1_ENUMERATED *aint);\nchar *i2s_ASN1_ENUMERATED_TABLE(X509V3_EXT_METHOD *meth,\n                                ASN1_ENUMERATED *aint);\nint X509V3_EXT_add(X509V3_EXT_METHOD *ext);\nint X509V3_EXT_add_list(X509V3_EXT_METHOD *extlist);\nint X509V3_EXT_add_alias(int nid_to, int nid_from);\nvoid X509V3_EXT_cleanup(void);\n\nconst X509V3_EXT_METHOD *X509V3_EXT_get(X509_EXTENSION *ext);\nconst X509V3_EXT_METHOD *X509V3_EXT_get_nid(int nid);\nint X509V3_add_standard_extensions(void);\nSTACK_OF(CONF_VALUE) *X509V3_parse_list(const char *line);\nvoid *X509V3_EXT_d2i(X509_EXTENSION *ext);\nvoid *X509V3_get_d2i(STACK_OF(X509_EXTENSION) *x, int nid, int *crit,\n                     int *idx);\nint X509V3_EXT_free(int nid, void *ext_data);\n\nX509_EXTENSION *X509V3_EXT_i2d(int ext_nid, int crit, void *ext_struc);\nint X509V3_add1_i2d(STACK_OF(X509_EXTENSION) **x, int nid, void *value,\n                    int crit, unsigned long flags);\n\nchar *hex_to_string(const unsigned char *buffer, long len);\nunsigned char *string_to_hex(const char *str, long *len);\nint name_cmp(const char *name, const char *cmp);\n\nvoid X509V3_EXT_val_prn(BIO *out, STACK_OF(CONF_VALUE) *val, int indent,\n                        int ml);\nint X509V3_EXT_print(BIO *out, X509_EXTENSION *ext, unsigned long flag,\n                     int indent);\nint X509V3_EXT_print_fp(FILE *out, X509_EXTENSION *ext, int flag, int indent);\n\nint X509V3_extensions_print(BIO *out, char *title,\n                            STACK_OF(X509_EXTENSION) *exts,\n                            unsigned long flag, int indent);\n\nint X509_check_ca(X509 *x);\nint X509_check_purpose(X509 *x, int id, int ca);\nint X509_supported_extension(X509_EXTENSION *ex);\nint X509_PURPOSE_set(int *p, int purpose);\nint X509_check_issued(X509 *issuer, X509 *subject);\nint X509_check_akid(X509 *issuer, AUTHORITY_KEYID *akid);\nint X509_PURPOSE_get_count(void);\nX509_PURPOSE *X509_PURPOSE_get0(int idx);\nint X509_PURPOSE_get_by_sname(char *sname);\nint X509_PURPOSE_get_by_id(int id);\nint X509_PURPOSE_add(int id, int trust, int flags,\n                     int (*ck) (const X509_PURPOSE *, const X509 *, int),\n                     char *name, char *sname, void *arg);\nchar *X509_PURPOSE_get0_name(X509_PURPOSE *xp);\nchar *X509_PURPOSE_get0_sname(X509_PURPOSE *xp);\nint X509_PURPOSE_get_trust(X509_PURPOSE *xp);\nvoid X509_PURPOSE_cleanup(void);\nint X509_PURPOSE_get_id(X509_PURPOSE *);\n\nSTACK_OF(OPENSSL_STRING) *X509_get1_email(X509 *x);\nSTACK_OF(OPENSSL_STRING) *X509_REQ_get1_email(X509_REQ *x);\nvoid X509_email_free(STACK_OF(OPENSSL_STRING) *sk);\nSTACK_OF(OPENSSL_STRING) *X509_get1_ocsp(X509 *x);\n/* Flags for X509_check_* functions */\n\n/*\n * Always check subject name for host match even if subject alt names present\n */\n# define X509_CHECK_FLAG_ALWAYS_CHECK_SUBJECT    0x1\n/* Disable wildcard matching for dnsName fields and common name. */\n# define X509_CHECK_FLAG_NO_WILDCARDS    0x2\n/* Wildcards must not match a partial label. */\n# define X509_CHECK_FLAG_NO_PARTIAL_WILDCARDS 0x4\n/* Allow (non-partial) wildcards to match multiple labels. */\n# define X509_CHECK_FLAG_MULTI_LABEL_WILDCARDS 0x8\n/* Constraint verifier subdomain patterns to match a single labels. */\n# define X509_CHECK_FLAG_SINGLE_LABEL_SUBDOMAINS 0x10\n/*\n * Match reference identifiers starting with \".\" to any sub-domain.\n * This is a non-public flag, turned on implicitly when the subject\n * reference identity is a DNS name.\n */\n# define _X509_CHECK_FLAG_DOT_SUBDOMAINS 0x8000\n\nint X509_check_host(X509 *x, const char *chk, size_t chklen,\n                    unsigned int flags, char **peername);\nint X509_check_email(X509 *x, const char *chk, size_t chklen,\n                     unsigned int flags);\nint X509_check_ip(X509 *x, const unsigned char *chk, size_t chklen,\n                  unsigned int flags);\nint X509_check_ip_asc(X509 *x, const char *ipasc, unsigned int flags);\n\nASN1_OCTET_STRING *a2i_IPADDRESS(const char *ipasc);\nASN1_OCTET_STRING *a2i_IPADDRESS_NC(const char *ipasc);\nint a2i_ipadd(unsigned char *ipout, const char *ipasc);\nint X509V3_NAME_from_section(X509_NAME *nm, STACK_OF(CONF_VALUE) *dn_sk,\n                             unsigned long chtype);\n\nvoid X509_POLICY_NODE_print(BIO *out, X509_POLICY_NODE *node, int indent);\nDECLARE_STACK_OF(X509_POLICY_NODE)\n\n# ifndef OPENSSL_NO_RFC3779\n\ntypedef struct ASRange_st {\n    ASN1_INTEGER *min, *max;\n} ASRange;\n\n#  define ASIdOrRange_id          0\n#  define ASIdOrRange_range       1\n\ntypedef struct ASIdOrRange_st {\n    int type;\n    union {\n        ASN1_INTEGER *id;\n        ASRange *range;\n    } u;\n} ASIdOrRange;\n\ntypedef STACK_OF(ASIdOrRange) ASIdOrRanges;\nDECLARE_STACK_OF(ASIdOrRange)\n\n#  define ASIdentifierChoice_inherit              0\n#  define ASIdentifierChoice_asIdsOrRanges        1\n\ntypedef struct ASIdentifierChoice_st {\n    int type;\n    union {\n        ASN1_NULL *inherit;\n        ASIdOrRanges *asIdsOrRanges;\n    } u;\n} ASIdentifierChoice;\n\ntypedef struct ASIdentifiers_st {\n    ASIdentifierChoice *asnum, *rdi;\n} ASIdentifiers;\n\nDECLARE_ASN1_FUNCTIONS(ASRange)\nDECLARE_ASN1_FUNCTIONS(ASIdOrRange)\nDECLARE_ASN1_FUNCTIONS(ASIdentifierChoice)\nDECLARE_ASN1_FUNCTIONS(ASIdentifiers)\n\ntypedef struct IPAddressRange_st {\n    ASN1_BIT_STRING *min, *max;\n} IPAddressRange;\n\n#  define IPAddressOrRange_addressPrefix  0\n#  define IPAddressOrRange_addressRange   1\n\ntypedef struct IPAddressOrRange_st {\n    int type;\n    union {\n        ASN1_BIT_STRING *addressPrefix;\n        IPAddressRange *addressRange;\n    } u;\n} IPAddressOrRange;\n\ntypedef STACK_OF(IPAddressOrRange) IPAddressOrRanges;\nDECLARE_STACK_OF(IPAddressOrRange)\n\n#  define IPAddressChoice_inherit                 0\n#  define IPAddressChoice_addressesOrRanges       1\n\ntypedef struct IPAddressChoice_st {\n    int type;\n    union {\n        ASN1_NULL *inherit;\n        IPAddressOrRanges *addressesOrRanges;\n    } u;\n} IPAddressChoice;\n\ntypedef struct IPAddressFamily_st {\n    ASN1_OCTET_STRING *addressFamily;\n    IPAddressChoice *ipAddressChoice;\n} IPAddressFamily;\n\ntypedef STACK_OF(IPAddressFamily) IPAddrBlocks;\nDECLARE_STACK_OF(IPAddressFamily)\n\nDECLARE_ASN1_FUNCTIONS(IPAddressRange)\nDECLARE_ASN1_FUNCTIONS(IPAddressOrRange)\nDECLARE_ASN1_FUNCTIONS(IPAddressChoice)\nDECLARE_ASN1_FUNCTIONS(IPAddressFamily)\n\n/*\n * API tag for elements of the ASIdentifer SEQUENCE.\n */\n#  define V3_ASID_ASNUM   0\n#  define V3_ASID_RDI     1\n\n/*\n * AFI values, assigned by IANA.  It'd be nice to make the AFI\n * handling code totally generic, but there are too many little things\n * that would need to be defined for other address families for it to\n * be worth the trouble.\n */\n#  define IANA_AFI_IPV4   1\n#  define IANA_AFI_IPV6   2\n\n/*\n * Utilities to construct and extract values from RFC3779 extensions,\n * since some of the encodings (particularly for IP address prefixes\n * and ranges) are a bit tedious to work with directly.\n */\nint v3_asid_add_inherit(ASIdentifiers *asid, int which);\nint v3_asid_add_id_or_range(ASIdentifiers *asid, int which,\n                            ASN1_INTEGER *min, ASN1_INTEGER *max);\nint v3_addr_add_inherit(IPAddrBlocks *addr,\n                        const unsigned afi, const unsigned *safi);\nint v3_addr_add_prefix(IPAddrBlocks *addr,\n                       const unsigned afi, const unsigned *safi,\n                       unsigned char *a, const int prefixlen);\nint v3_addr_add_range(IPAddrBlocks *addr,\n                      const unsigned afi, const unsigned *safi,\n                      unsigned char *min, unsigned char *max);\nunsigned v3_addr_get_afi(const IPAddressFamily *f);\nint v3_addr_get_range(IPAddressOrRange *aor, const unsigned afi,\n                      unsigned char *min, unsigned char *max,\n                      const int length);\n\n/*\n * Canonical forms.\n */\nint v3_asid_is_canonical(ASIdentifiers *asid);\nint v3_addr_is_canonical(IPAddrBlocks *addr);\nint v3_asid_canonize(ASIdentifiers *asid);\nint v3_addr_canonize(IPAddrBlocks *addr);\n\n/*\n * Tests for inheritance and containment.\n */\nint v3_asid_inherits(ASIdentifiers *asid);\nint v3_addr_inherits(IPAddrBlocks *addr);\nint v3_asid_subset(ASIdentifiers *a, ASIdentifiers *b);\nint v3_addr_subset(IPAddrBlocks *a, IPAddrBlocks *b);\n\n/*\n * Check whether RFC 3779 extensions nest properly in chains.\n */\nint v3_asid_validate_path(X509_STORE_CTX *);\nint v3_addr_validate_path(X509_STORE_CTX *);\nint v3_asid_validate_resource_set(STACK_OF(X509) *chain,\n                                  ASIdentifiers *ext, int allow_inheritance);\nint v3_addr_validate_resource_set(STACK_OF(X509) *chain,\n                                  IPAddrBlocks *ext, int allow_inheritance);\n\n# endif                         /* OPENSSL_NO_RFC3779 */\n\n/* BEGIN ERROR CODES */\n/*\n * The following lines are auto generated by the script mkerr.pl. Any changes\n * made after this point may be overwritten when the script is next run.\n */\nvoid ERR_load_X509V3_strings(void);\n\n/* Error codes for the X509V3 functions. */\n\n/* Function codes. */\n# define X509V3_F_A2I_GENERAL_NAME                        164\n# define X509V3_F_ASIDENTIFIERCHOICE_CANONIZE             161\n# define X509V3_F_ASIDENTIFIERCHOICE_IS_CANONICAL         162\n# define X509V3_F_COPY_EMAIL                              122\n# define X509V3_F_COPY_ISSUER                             123\n# define X509V3_F_DO_DIRNAME                              144\n# define X509V3_F_DO_EXT_CONF                             124\n# define X509V3_F_DO_EXT_I2D                              135\n# define X509V3_F_DO_EXT_NCONF                            151\n# define X509V3_F_DO_I2V_NAME_CONSTRAINTS                 148\n# define X509V3_F_GNAMES_FROM_SECTNAME                    156\n# define X509V3_F_HEX_TO_STRING                           111\n# define X509V3_F_I2S_ASN1_ENUMERATED                     121\n# define X509V3_F_I2S_ASN1_IA5STRING                      149\n# define X509V3_F_I2S_ASN1_INTEGER                        120\n# define X509V3_F_I2V_AUTHORITY_INFO_ACCESS               138\n# define X509V3_F_NOTICE_SECTION                          132\n# define X509V3_F_NREF_NOS                                133\n# define X509V3_F_POLICY_SECTION                          131\n# define X509V3_F_PROCESS_PCI_VALUE                       150\n# define X509V3_F_R2I_CERTPOL                             130\n# define X509V3_F_R2I_PCI                                 155\n# define X509V3_F_S2I_ASN1_IA5STRING                      100\n# define X509V3_F_S2I_ASN1_INTEGER                        108\n# define X509V3_F_S2I_ASN1_OCTET_STRING                   112\n# define X509V3_F_S2I_ASN1_SKEY_ID                        114\n# define X509V3_F_S2I_SKEY_ID                             115\n# define X509V3_F_SET_DIST_POINT_NAME                     158\n# define X509V3_F_STRING_TO_HEX                           113\n# define X509V3_F_SXNET_ADD_ID_ASC                        125\n# define X509V3_F_SXNET_ADD_ID_INTEGER                    126\n# define X509V3_F_SXNET_ADD_ID_ULONG                      127\n# define X509V3_F_SXNET_GET_ID_ASC                        128\n# define X509V3_F_SXNET_GET_ID_ULONG                      129\n# define X509V3_F_V2I_ASIDENTIFIERS                       163\n# define X509V3_F_V2I_ASN1_BIT_STRING                     101\n# define X509V3_F_V2I_AUTHORITY_INFO_ACCESS               139\n# define X509V3_F_V2I_AUTHORITY_KEYID                     119\n# define X509V3_F_V2I_BASIC_CONSTRAINTS                   102\n# define X509V3_F_V2I_CRLD                                134\n# define X509V3_F_V2I_EXTENDED_KEY_USAGE                  103\n# define X509V3_F_V2I_GENERAL_NAMES                       118\n# define X509V3_F_V2I_GENERAL_NAME_EX                     117\n# define X509V3_F_V2I_IDP                                 157\n# define X509V3_F_V2I_IPADDRBLOCKS                        159\n# define X509V3_F_V2I_ISSUER_ALT                          153\n# define X509V3_F_V2I_NAME_CONSTRAINTS                    147\n# define X509V3_F_V2I_POLICY_CONSTRAINTS                  146\n# define X509V3_F_V2I_POLICY_MAPPINGS                     145\n# define X509V3_F_V2I_SUBJECT_ALT                         154\n# define X509V3_F_V3_ADDR_VALIDATE_PATH_INTERNAL          160\n# define X509V3_F_V3_GENERIC_EXTENSION                    116\n# define X509V3_F_X509V3_ADD1_I2D                         140\n# define X509V3_F_X509V3_ADD_VALUE                        105\n# define X509V3_F_X509V3_EXT_ADD                          104\n# define X509V3_F_X509V3_EXT_ADD_ALIAS                    106\n# define X509V3_F_X509V3_EXT_CONF                         107\n# define X509V3_F_X509V3_EXT_FREE                         165\n# define X509V3_F_X509V3_EXT_I2D                          136\n# define X509V3_F_X509V3_EXT_NCONF                        152\n# define X509V3_F_X509V3_GET_SECTION                      142\n# define X509V3_F_X509V3_GET_STRING                       143\n# define X509V3_F_X509V3_GET_VALUE_BOOL                   110\n# define X509V3_F_X509V3_PARSE_LIST                       109\n# define X509V3_F_X509_PURPOSE_ADD                        137\n# define X509V3_F_X509_PURPOSE_SET                        141\n\n/* Reason codes. */\n# define X509V3_R_BAD_IP_ADDRESS                          118\n# define X509V3_R_BAD_OBJECT                              119\n# define X509V3_R_BN_DEC2BN_ERROR                         100\n# define X509V3_R_BN_TO_ASN1_INTEGER_ERROR                101\n# define X509V3_R_CANNOT_FIND_FREE_FUNCTION               168\n# define X509V3_R_DIRNAME_ERROR                           149\n# define X509V3_R_DISTPOINT_ALREADY_SET                   160\n# define X509V3_R_DUPLICATE_ZONE_ID                       133\n# define X509V3_R_ERROR_CONVERTING_ZONE                   131\n# define X509V3_R_ERROR_CREATING_EXTENSION                144\n# define X509V3_R_ERROR_IN_EXTENSION                      128\n# define X509V3_R_EXPECTED_A_SECTION_NAME                 137\n# define X509V3_R_EXTENSION_EXISTS                        145\n# define X509V3_R_EXTENSION_NAME_ERROR                    115\n# define X509V3_R_EXTENSION_NOT_FOUND                     102\n# define X509V3_R_EXTENSION_SETTING_NOT_SUPPORTED         103\n# define X509V3_R_EXTENSION_VALUE_ERROR                   116\n# define X509V3_R_ILLEGAL_EMPTY_EXTENSION                 151\n# define X509V3_R_ILLEGAL_HEX_DIGIT                       113\n# define X509V3_R_INCORRECT_POLICY_SYNTAX_TAG             152\n# define X509V3_R_INVALID_ASNUMBER                        162\n# define X509V3_R_INVALID_ASRANGE                         163\n# define X509V3_R_INVALID_BOOLEAN_STRING                  104\n# define X509V3_R_INVALID_EXTENSION_STRING                105\n# define X509V3_R_INVALID_INHERITANCE                     165\n# define X509V3_R_INVALID_IPADDRESS                       166\n# define X509V3_R_INVALID_MULTIPLE_RDNS                   161\n# define X509V3_R_INVALID_NAME                            106\n# define X509V3_R_INVALID_NULL_ARGUMENT                   107\n# define X509V3_R_INVALID_NULL_NAME                       108\n# define X509V3_R_INVALID_NULL_VALUE                      109\n# define X509V3_R_INVALID_NUMBER                          140\n# define X509V3_R_INVALID_NUMBERS                         141\n# define X509V3_R_INVALID_OBJECT_IDENTIFIER               110\n# define X509V3_R_INVALID_OPTION                          138\n# define X509V3_R_INVALID_POLICY_IDENTIFIER               134\n# define X509V3_R_INVALID_PROXY_POLICY_SETTING            153\n# define X509V3_R_INVALID_PURPOSE                         146\n# define X509V3_R_INVALID_SAFI                            164\n# define X509V3_R_INVALID_SECTION                         135\n# define X509V3_R_INVALID_SYNTAX                          143\n# define X509V3_R_ISSUER_DECODE_ERROR                     126\n# define X509V3_R_MISSING_VALUE                           124\n# define X509V3_R_NEED_ORGANIZATION_AND_NUMBERS           142\n# define X509V3_R_NO_CONFIG_DATABASE                      136\n# define X509V3_R_NO_ISSUER_CERTIFICATE                   121\n# define X509V3_R_NO_ISSUER_DETAILS                       127\n# define X509V3_R_NO_POLICY_IDENTIFIER                    139\n# define X509V3_R_NO_PROXY_CERT_POLICY_LANGUAGE_DEFINED   154\n# define X509V3_R_NO_PUBLIC_KEY                           114\n# define X509V3_R_NO_SUBJECT_DETAILS                      125\n# define X509V3_R_ODD_NUMBER_OF_DIGITS                    112\n# define X509V3_R_OPERATION_NOT_DEFINED                   148\n# define X509V3_R_OTHERNAME_ERROR                         147\n# define X509V3_R_POLICY_LANGUAGE_ALREADY_DEFINED         155\n# define X509V3_R_POLICY_PATH_LENGTH                      156\n# define X509V3_R_POLICY_PATH_LENGTH_ALREADY_DEFINED      157\n# define X509V3_R_POLICY_SYNTAX_NOT_CURRENTLY_SUPPORTED   158\n# define X509V3_R_POLICY_WHEN_PROXY_LANGUAGE_REQUIRES_NO_POLICY 159\n# define X509V3_R_SECTION_NOT_FOUND                       150\n# define X509V3_R_UNABLE_TO_GET_ISSUER_DETAILS            122\n# define X509V3_R_UNABLE_TO_GET_ISSUER_KEYID              123\n# define X509V3_R_UNKNOWN_BIT_STRING_ARGUMENT             111\n# define X509V3_R_UNKNOWN_EXTENSION                       129\n# define X509V3_R_UNKNOWN_EXTENSION_NAME                  130\n# define X509V3_R_UNKNOWN_OPTION                          120\n# define X509V3_R_UNSUPPORTED_OPTION                      117\n# define X509V3_R_UNSUPPORTED_TYPE                        167\n# define X509V3_R_USER_TOO_LONG                           132\n\n#ifdef  __cplusplus\n}\n#endif\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/include/openssl/aes.h",
    "content": "/*\n * Copyright 2002-2016 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef HEADER_AES_H\n# define HEADER_AES_H\n\n# include <openssl/opensslconf.h>\n\n# include <stddef.h>\n# ifdef  __cplusplus\nextern \"C\" {\n# endif\n\n# define AES_ENCRYPT     1\n# define AES_DECRYPT     0\n\n/*\n * Because array size can't be a const in C, the following two are macros.\n * Both sizes are in bytes.\n */\n# define AES_MAXNR 14\n# define AES_BLOCK_SIZE 16\n\n/* This should be a hidden type, but EVP requires that the size be known */\nstruct aes_key_st {\n# ifdef AES_LONG\n    unsigned long rd_key[4 * (AES_MAXNR + 1)];\n# else\n    unsigned int rd_key[4 * (AES_MAXNR + 1)];\n# endif\n    int rounds;\n};\ntypedef struct aes_key_st AES_KEY;\n\nconst char *AES_options(void);\n\nint AES_set_encrypt_key(const unsigned char *userKey, const int bits,\n                        AES_KEY *key);\nint AES_set_decrypt_key(const unsigned char *userKey, const int bits,\n                        AES_KEY *key);\n\nvoid AES_encrypt(const unsigned char *in, unsigned char *out,\n                 const AES_KEY *key);\nvoid AES_decrypt(const unsigned char *in, unsigned char *out,\n                 const AES_KEY *key);\n\nvoid AES_ecb_encrypt(const unsigned char *in, unsigned char *out,\n                     const AES_KEY *key, const int enc);\nvoid AES_cbc_encrypt(const unsigned char *in, unsigned char *out,\n                     size_t length, const AES_KEY *key,\n                     unsigned char *ivec, const int enc);\nvoid AES_cfb128_encrypt(const unsigned char *in, unsigned char *out,\n                        size_t length, const AES_KEY *key,\n                        unsigned char *ivec, int *num, const int enc);\nvoid AES_cfb1_encrypt(const unsigned char *in, unsigned char *out,\n                      size_t length, const AES_KEY *key,\n                      unsigned char *ivec, int *num, const int enc);\nvoid AES_cfb8_encrypt(const unsigned char *in, unsigned char *out,\n                      size_t length, const AES_KEY *key,\n                      unsigned char *ivec, int *num, const int enc);\nvoid AES_ofb128_encrypt(const unsigned char *in, unsigned char *out,\n                        size_t length, const AES_KEY *key,\n                        unsigned char *ivec, int *num);\n/* NB: the IV is _two_ blocks long */\nvoid AES_ige_encrypt(const unsigned char *in, unsigned char *out,\n                     size_t length, const AES_KEY *key,\n                     unsigned char *ivec, const int enc);\n/* NB: the IV is _four_ blocks long */\nvoid AES_bi_ige_encrypt(const unsigned char *in, unsigned char *out,\n                        size_t length, const AES_KEY *key,\n                        const AES_KEY *key2, const unsigned char *ivec,\n                        const int enc);\n\nint AES_wrap_key(AES_KEY *key, const unsigned char *iv,\n                 unsigned char *out,\n                 const unsigned char *in, unsigned int inlen);\nint AES_unwrap_key(AES_KEY *key, const unsigned char *iv,\n                   unsigned char *out,\n                   const unsigned char *in, unsigned int inlen);\n\n\n# ifdef  __cplusplus\n}\n# endif\n\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/include/openssl/asn1.h",
    "content": "/*\n * Copyright 1995-2017 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef HEADER_ASN1_H\n# define HEADER_ASN1_H\n\n# include <time.h>\n# include <openssl/e_os2.h>\n# include <openssl/opensslconf.h>\n# include <openssl/bio.h>\n# include <openssl/safestack.h>\n# include <openssl/asn1err.h>\n# include <openssl/symhacks.h>\n\n# include <openssl/ossl_typ.h>\n# if OPENSSL_API_COMPAT < 0x10100000L\n#  include <openssl/bn.h>\n# endif\n\n# ifdef OPENSSL_BUILD_SHLIBCRYPTO\n#  undef OPENSSL_EXTERN\n#  define OPENSSL_EXTERN OPENSSL_EXPORT\n# endif\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n# define V_ASN1_UNIVERSAL                0x00\n# define V_ASN1_APPLICATION              0x40\n# define V_ASN1_CONTEXT_SPECIFIC         0x80\n# define V_ASN1_PRIVATE                  0xc0\n\n# define V_ASN1_CONSTRUCTED              0x20\n# define V_ASN1_PRIMITIVE_TAG            0x1f\n# define V_ASN1_PRIMATIVE_TAG /*compat*/ V_ASN1_PRIMITIVE_TAG\n\n# define V_ASN1_APP_CHOOSE               -2/* let the recipient choose */\n# define V_ASN1_OTHER                    -3/* used in ASN1_TYPE */\n# define V_ASN1_ANY                      -4/* used in ASN1 template code */\n\n# define V_ASN1_UNDEF                    -1\n/* ASN.1 tag values */\n# define V_ASN1_EOC                      0\n# define V_ASN1_BOOLEAN                  1 /**/\n# define V_ASN1_INTEGER                  2\n# define V_ASN1_BIT_STRING               3\n# define V_ASN1_OCTET_STRING             4\n# define V_ASN1_NULL                     5\n# define V_ASN1_OBJECT                   6\n# define V_ASN1_OBJECT_DESCRIPTOR        7\n# define V_ASN1_EXTERNAL                 8\n# define V_ASN1_REAL                     9\n# define V_ASN1_ENUMERATED               10\n# define V_ASN1_UTF8STRING               12\n# define V_ASN1_SEQUENCE                 16\n# define V_ASN1_SET                      17\n# define V_ASN1_NUMERICSTRING            18 /**/\n# define V_ASN1_PRINTABLESTRING          19\n# define V_ASN1_T61STRING                20\n# define V_ASN1_TELETEXSTRING            20/* alias */\n# define V_ASN1_VIDEOTEXSTRING           21 /**/\n# define V_ASN1_IA5STRING                22\n# define V_ASN1_UTCTIME                  23\n# define V_ASN1_GENERALIZEDTIME          24 /**/\n# define V_ASN1_GRAPHICSTRING            25 /**/\n# define V_ASN1_ISO64STRING              26 /**/\n# define V_ASN1_VISIBLESTRING            26/* alias */\n# define V_ASN1_GENERALSTRING            27 /**/\n# define V_ASN1_UNIVERSALSTRING          28 /**/\n# define V_ASN1_BMPSTRING                30\n\n/*\n * NB the constants below are used internally by ASN1_INTEGER\n * and ASN1_ENUMERATED to indicate the sign. They are *not* on\n * the wire tag values.\n */\n\n# define V_ASN1_NEG                      0x100\n# define V_ASN1_NEG_INTEGER              (2 | V_ASN1_NEG)\n# define V_ASN1_NEG_ENUMERATED           (10 | V_ASN1_NEG)\n\n/* For use with d2i_ASN1_type_bytes() */\n# define B_ASN1_NUMERICSTRING    0x0001\n# define B_ASN1_PRINTABLESTRING  0x0002\n# define B_ASN1_T61STRING        0x0004\n# define B_ASN1_TELETEXSTRING    0x0004\n# define B_ASN1_VIDEOTEXSTRING   0x0008\n# define B_ASN1_IA5STRING        0x0010\n# define B_ASN1_GRAPHICSTRING    0x0020\n# define B_ASN1_ISO64STRING      0x0040\n# define B_ASN1_VISIBLESTRING    0x0040\n# define B_ASN1_GENERALSTRING    0x0080\n# define B_ASN1_UNIVERSALSTRING  0x0100\n# define B_ASN1_OCTET_STRING     0x0200\n# define B_ASN1_BIT_STRING       0x0400\n# define B_ASN1_BMPSTRING        0x0800\n# define B_ASN1_UNKNOWN          0x1000\n# define B_ASN1_UTF8STRING       0x2000\n# define B_ASN1_UTCTIME          0x4000\n# define B_ASN1_GENERALIZEDTIME  0x8000\n# define B_ASN1_SEQUENCE         0x10000\n/* For use with ASN1_mbstring_copy() */\n# define MBSTRING_FLAG           0x1000\n# define MBSTRING_UTF8           (MBSTRING_FLAG)\n# define MBSTRING_ASC            (MBSTRING_FLAG|1)\n# define MBSTRING_BMP            (MBSTRING_FLAG|2)\n# define MBSTRING_UNIV           (MBSTRING_FLAG|4)\n# define SMIME_OLDMIME           0x400\n# define SMIME_CRLFEOL           0x800\n# define SMIME_STREAM            0x1000\n    struct X509_algor_st;\nDEFINE_STACK_OF(X509_ALGOR)\n\n# define ASN1_STRING_FLAG_BITS_LEFT 0x08/* Set if 0x07 has bits left value */\n/*\n * This indicates that the ASN1_STRING is not a real value but just a place\n * holder for the location where indefinite length constructed data should be\n * inserted in the memory buffer\n */\n# define ASN1_STRING_FLAG_NDEF 0x010\n\n/*\n * This flag is used by the CMS code to indicate that a string is not\n * complete and is a place holder for content when it had all been accessed.\n * The flag will be reset when content has been written to it.\n */\n\n# define ASN1_STRING_FLAG_CONT 0x020\n/*\n * This flag is used by ASN1 code to indicate an ASN1_STRING is an MSTRING\n * type.\n */\n# define ASN1_STRING_FLAG_MSTRING 0x040\n/* String is embedded and only content should be freed */\n# define ASN1_STRING_FLAG_EMBED 0x080\n/* String should be parsed in RFC 5280's time format */\n# define ASN1_STRING_FLAG_X509_TIME 0x100\n/* This is the base type that holds just about everything :-) */\nstruct asn1_string_st {\n    int length;\n    int type;\n    unsigned char *data;\n    /*\n     * The value of the following field depends on the type being held.  It\n     * is mostly being used for BIT_STRING so if the input data has a\n     * non-zero 'unused bits' value, it will be handled correctly\n     */\n    long flags;\n};\n\n/*\n * ASN1_ENCODING structure: this is used to save the received encoding of an\n * ASN1 type. This is useful to get round problems with invalid encodings\n * which can break signatures.\n */\n\ntypedef struct ASN1_ENCODING_st {\n    unsigned char *enc;         /* DER encoding */\n    long len;                   /* Length of encoding */\n    int modified;               /* set to 1 if 'enc' is invalid */\n} ASN1_ENCODING;\n\n/* Used with ASN1 LONG type: if a long is set to this it is omitted */\n# define ASN1_LONG_UNDEF 0x7fffffffL\n\n# define STABLE_FLAGS_MALLOC     0x01\n/*\n * A zero passed to ASN1_STRING_TABLE_new_add for the flags is interpreted\n * as \"don't change\" and STABLE_FLAGS_MALLOC is always set. By setting\n * STABLE_FLAGS_MALLOC only we can clear the existing value. Use the alias\n * STABLE_FLAGS_CLEAR to reflect this.\n */\n# define STABLE_FLAGS_CLEAR      STABLE_FLAGS_MALLOC\n# define STABLE_NO_MASK          0x02\n# define DIRSTRING_TYPE  \\\n (B_ASN1_PRINTABLESTRING|B_ASN1_T61STRING|B_ASN1_BMPSTRING|B_ASN1_UTF8STRING)\n# define PKCS9STRING_TYPE (DIRSTRING_TYPE|B_ASN1_IA5STRING)\n\ntypedef struct asn1_string_table_st {\n    int nid;\n    long minsize;\n    long maxsize;\n    unsigned long mask;\n    unsigned long flags;\n} ASN1_STRING_TABLE;\n\nDEFINE_STACK_OF(ASN1_STRING_TABLE)\n\n/* size limits: this stuff is taken straight from RFC2459 */\n\n# define ub_name                         32768\n# define ub_common_name                  64\n# define ub_locality_name                128\n# define ub_state_name                   128\n# define ub_organization_name            64\n# define ub_organization_unit_name       64\n# define ub_title                        64\n# define ub_email_address                128\n\n/*\n * Declarations for template structures: for full definitions see asn1t.h\n */\ntypedef struct ASN1_TEMPLATE_st ASN1_TEMPLATE;\ntypedef struct ASN1_TLC_st ASN1_TLC;\n/* This is just an opaque pointer */\ntypedef struct ASN1_VALUE_st ASN1_VALUE;\n\n/* Declare ASN1 functions: the implement macro in in asn1t.h */\n\n# define DECLARE_ASN1_FUNCTIONS(type) DECLARE_ASN1_FUNCTIONS_name(type, type)\n\n# define DECLARE_ASN1_ALLOC_FUNCTIONS(type) \\\n        DECLARE_ASN1_ALLOC_FUNCTIONS_name(type, type)\n\n# define DECLARE_ASN1_FUNCTIONS_name(type, name) \\\n        DECLARE_ASN1_ALLOC_FUNCTIONS_name(type, name) \\\n        DECLARE_ASN1_ENCODE_FUNCTIONS(type, name, name)\n\n# define DECLARE_ASN1_FUNCTIONS_fname(type, itname, name) \\\n        DECLARE_ASN1_ALLOC_FUNCTIONS_name(type, name) \\\n        DECLARE_ASN1_ENCODE_FUNCTIONS(type, itname, name)\n\n# define DECLARE_ASN1_ENCODE_FUNCTIONS(type, itname, name) \\\n        type *d2i_##name(type **a, const unsigned char **in, long len); \\\n        int i2d_##name(type *a, unsigned char **out); \\\n        DECLARE_ASN1_ITEM(itname)\n\n# define DECLARE_ASN1_ENCODE_FUNCTIONS_const(type, name) \\\n        type *d2i_##name(type **a, const unsigned char **in, long len); \\\n        int i2d_##name(const type *a, unsigned char **out); \\\n        DECLARE_ASN1_ITEM(name)\n\n# define DECLARE_ASN1_NDEF_FUNCTION(name) \\\n        int i2d_##name##_NDEF(name *a, unsigned char **out);\n\n# define DECLARE_ASN1_FUNCTIONS_const(name) \\\n        DECLARE_ASN1_ALLOC_FUNCTIONS(name) \\\n        DECLARE_ASN1_ENCODE_FUNCTIONS_const(name, name)\n\n# define DECLARE_ASN1_ALLOC_FUNCTIONS_name(type, name) \\\n        type *name##_new(void); \\\n        void name##_free(type *a);\n\n# define DECLARE_ASN1_PRINT_FUNCTION(stname) \\\n        DECLARE_ASN1_PRINT_FUNCTION_fname(stname, stname)\n\n# define DECLARE_ASN1_PRINT_FUNCTION_fname(stname, fname) \\\n        int fname##_print_ctx(BIO *out, stname *x, int indent, \\\n                                         const ASN1_PCTX *pctx);\n\n# define D2I_OF(type) type *(*)(type **,const unsigned char **,long)\n# define I2D_OF(type) int (*)(type *,unsigned char **)\n# define I2D_OF_const(type) int (*)(const type *,unsigned char **)\n\n# define CHECKED_D2I_OF(type, d2i) \\\n    ((d2i_of_void*) (1 ? d2i : ((D2I_OF(type))0)))\n# define CHECKED_I2D_OF(type, i2d) \\\n    ((i2d_of_void*) (1 ? i2d : ((I2D_OF(type))0)))\n# define CHECKED_NEW_OF(type, xnew) \\\n    ((void *(*)(void)) (1 ? xnew : ((type *(*)(void))0)))\n# define CHECKED_PTR_OF(type, p) \\\n    ((void*) (1 ? p : (type*)0))\n# define CHECKED_PPTR_OF(type, p) \\\n    ((void**) (1 ? p : (type**)0))\n\n# define TYPEDEF_D2I_OF(type) typedef type *d2i_of_##type(type **,const unsigned char **,long)\n# define TYPEDEF_I2D_OF(type) typedef int i2d_of_##type(type *,unsigned char **)\n# define TYPEDEF_D2I2D_OF(type) TYPEDEF_D2I_OF(type); TYPEDEF_I2D_OF(type)\n\nTYPEDEF_D2I2D_OF(void);\n\n/*-\n * The following macros and typedefs allow an ASN1_ITEM\n * to be embedded in a structure and referenced. Since\n * the ASN1_ITEM pointers need to be globally accessible\n * (possibly from shared libraries) they may exist in\n * different forms. On platforms that support it the\n * ASN1_ITEM structure itself will be globally exported.\n * Other platforms will export a function that returns\n * an ASN1_ITEM pointer.\n *\n * To handle both cases transparently the macros below\n * should be used instead of hard coding an ASN1_ITEM\n * pointer in a structure.\n *\n * The structure will look like this:\n *\n * typedef struct SOMETHING_st {\n *      ...\n *      ASN1_ITEM_EXP *iptr;\n *      ...\n * } SOMETHING;\n *\n * It would be initialised as e.g.:\n *\n * SOMETHING somevar = {...,ASN1_ITEM_ref(X509),...};\n *\n * and the actual pointer extracted with:\n *\n * const ASN1_ITEM *it = ASN1_ITEM_ptr(somevar.iptr);\n *\n * Finally an ASN1_ITEM pointer can be extracted from an\n * appropriate reference with: ASN1_ITEM_rptr(X509). This\n * would be used when a function takes an ASN1_ITEM * argument.\n *\n */\n\n# ifndef OPENSSL_EXPORT_VAR_AS_FUNCTION\n\n/* ASN1_ITEM pointer exported type */\ntypedef const ASN1_ITEM ASN1_ITEM_EXP;\n\n/* Macro to obtain ASN1_ITEM pointer from exported type */\n#  define ASN1_ITEM_ptr(iptr) (iptr)\n\n/* Macro to include ASN1_ITEM pointer from base type */\n#  define ASN1_ITEM_ref(iptr) (&(iptr##_it))\n\n#  define ASN1_ITEM_rptr(ref) (&(ref##_it))\n\n#  define DECLARE_ASN1_ITEM(name) \\\n        OPENSSL_EXTERN const ASN1_ITEM name##_it;\n\n# else\n\n/*\n * Platforms that can't easily handle shared global variables are declared as\n * functions returning ASN1_ITEM pointers.\n */\n\n/* ASN1_ITEM pointer exported type */\ntypedef const ASN1_ITEM *ASN1_ITEM_EXP (void);\n\n/* Macro to obtain ASN1_ITEM pointer from exported type */\n#  define ASN1_ITEM_ptr(iptr) (iptr())\n\n/* Macro to include ASN1_ITEM pointer from base type */\n#  define ASN1_ITEM_ref(iptr) (iptr##_it)\n\n#  define ASN1_ITEM_rptr(ref) (ref##_it())\n\n#  define DECLARE_ASN1_ITEM(name) \\\n        const ASN1_ITEM * name##_it(void);\n\n# endif\n\n/* Parameters used by ASN1_STRING_print_ex() */\n\n/*\n * These determine which characters to escape: RFC2253 special characters,\n * control characters and MSB set characters\n */\n\n# define ASN1_STRFLGS_ESC_2253           1\n# define ASN1_STRFLGS_ESC_CTRL           2\n# define ASN1_STRFLGS_ESC_MSB            4\n\n/*\n * This flag determines how we do escaping: normally RC2253 backslash only,\n * set this to use backslash and quote.\n */\n\n# define ASN1_STRFLGS_ESC_QUOTE          8\n\n/* These three flags are internal use only. */\n\n/* Character is a valid PrintableString character */\n# define CHARTYPE_PRINTABLESTRING        0x10\n/* Character needs escaping if it is the first character */\n# define CHARTYPE_FIRST_ESC_2253         0x20\n/* Character needs escaping if it is the last character */\n# define CHARTYPE_LAST_ESC_2253          0x40\n\n/*\n * NB the internal flags are safely reused below by flags handled at the top\n * level.\n */\n\n/*\n * If this is set we convert all character strings to UTF8 first\n */\n\n# define ASN1_STRFLGS_UTF8_CONVERT       0x10\n\n/*\n * If this is set we don't attempt to interpret content: just assume all\n * strings are 1 byte per character. This will produce some pretty odd\n * looking output!\n */\n\n# define ASN1_STRFLGS_IGNORE_TYPE        0x20\n\n/* If this is set we include the string type in the output */\n# define ASN1_STRFLGS_SHOW_TYPE          0x40\n\n/*\n * This determines which strings to display and which to 'dump' (hex dump of\n * content octets or DER encoding). We can only dump non character strings or\n * everything. If we don't dump 'unknown' they are interpreted as character\n * strings with 1 octet per character and are subject to the usual escaping\n * options.\n */\n\n# define ASN1_STRFLGS_DUMP_ALL           0x80\n# define ASN1_STRFLGS_DUMP_UNKNOWN       0x100\n\n/*\n * These determine what 'dumping' does, we can dump the content octets or the\n * DER encoding: both use the RFC2253 #XXXXX notation.\n */\n\n# define ASN1_STRFLGS_DUMP_DER           0x200\n\n/*\n * This flag specifies that RC2254 escaping shall be performed.\n */\n#define ASN1_STRFLGS_ESC_2254           0x400\n\n/*\n * All the string flags consistent with RFC2253, escaping control characters\n * isn't essential in RFC2253 but it is advisable anyway.\n */\n\n# define ASN1_STRFLGS_RFC2253    (ASN1_STRFLGS_ESC_2253 | \\\n                                ASN1_STRFLGS_ESC_CTRL | \\\n                                ASN1_STRFLGS_ESC_MSB | \\\n                                ASN1_STRFLGS_UTF8_CONVERT | \\\n                                ASN1_STRFLGS_DUMP_UNKNOWN | \\\n                                ASN1_STRFLGS_DUMP_DER)\n\nDEFINE_STACK_OF(ASN1_INTEGER)\n\nDEFINE_STACK_OF(ASN1_GENERALSTRING)\n\nDEFINE_STACK_OF(ASN1_UTF8STRING)\n\ntypedef struct asn1_type_st {\n    int type;\n    union {\n        char *ptr;\n        ASN1_BOOLEAN boolean;\n        ASN1_STRING *asn1_string;\n        ASN1_OBJECT *object;\n        ASN1_INTEGER *integer;\n        ASN1_ENUMERATED *enumerated;\n        ASN1_BIT_STRING *bit_string;\n        ASN1_OCTET_STRING *octet_string;\n        ASN1_PRINTABLESTRING *printablestring;\n        ASN1_T61STRING *t61string;\n        ASN1_IA5STRING *ia5string;\n        ASN1_GENERALSTRING *generalstring;\n        ASN1_BMPSTRING *bmpstring;\n        ASN1_UNIVERSALSTRING *universalstring;\n        ASN1_UTCTIME *utctime;\n        ASN1_GENERALIZEDTIME *generalizedtime;\n        ASN1_VISIBLESTRING *visiblestring;\n        ASN1_UTF8STRING *utf8string;\n        /*\n         * set and sequence are left complete and still contain the set or\n         * sequence bytes\n         */\n        ASN1_STRING *set;\n        ASN1_STRING *sequence;\n        ASN1_VALUE *asn1_value;\n    } value;\n} ASN1_TYPE;\n\nDEFINE_STACK_OF(ASN1_TYPE)\n\ntypedef STACK_OF(ASN1_TYPE) ASN1_SEQUENCE_ANY;\n\nDECLARE_ASN1_ENCODE_FUNCTIONS_const(ASN1_SEQUENCE_ANY, ASN1_SEQUENCE_ANY)\nDECLARE_ASN1_ENCODE_FUNCTIONS_const(ASN1_SEQUENCE_ANY, ASN1_SET_ANY)\n\n/* This is used to contain a list of bit names */\ntypedef struct BIT_STRING_BITNAME_st {\n    int bitnum;\n    const char *lname;\n    const char *sname;\n} BIT_STRING_BITNAME;\n\n# define B_ASN1_TIME \\\n                        B_ASN1_UTCTIME | \\\n                        B_ASN1_GENERALIZEDTIME\n\n# define B_ASN1_PRINTABLE \\\n                        B_ASN1_NUMERICSTRING| \\\n                        B_ASN1_PRINTABLESTRING| \\\n                        B_ASN1_T61STRING| \\\n                        B_ASN1_IA5STRING| \\\n                        B_ASN1_BIT_STRING| \\\n                        B_ASN1_UNIVERSALSTRING|\\\n                        B_ASN1_BMPSTRING|\\\n                        B_ASN1_UTF8STRING|\\\n                        B_ASN1_SEQUENCE|\\\n                        B_ASN1_UNKNOWN\n\n# define B_ASN1_DIRECTORYSTRING \\\n                        B_ASN1_PRINTABLESTRING| \\\n                        B_ASN1_TELETEXSTRING|\\\n                        B_ASN1_BMPSTRING|\\\n                        B_ASN1_UNIVERSALSTRING|\\\n                        B_ASN1_UTF8STRING\n\n# define B_ASN1_DISPLAYTEXT \\\n                        B_ASN1_IA5STRING| \\\n                        B_ASN1_VISIBLESTRING| \\\n                        B_ASN1_BMPSTRING|\\\n                        B_ASN1_UTF8STRING\n\nDECLARE_ASN1_FUNCTIONS_fname(ASN1_TYPE, ASN1_ANY, ASN1_TYPE)\n\nint ASN1_TYPE_get(const ASN1_TYPE *a);\nvoid ASN1_TYPE_set(ASN1_TYPE *a, int type, void *value);\nint ASN1_TYPE_set1(ASN1_TYPE *a, int type, const void *value);\nint ASN1_TYPE_cmp(const ASN1_TYPE *a, const ASN1_TYPE *b);\n\nASN1_TYPE *ASN1_TYPE_pack_sequence(const ASN1_ITEM *it, void *s, ASN1_TYPE **t);\nvoid *ASN1_TYPE_unpack_sequence(const ASN1_ITEM *it, const ASN1_TYPE *t);\n\nASN1_OBJECT *ASN1_OBJECT_new(void);\nvoid ASN1_OBJECT_free(ASN1_OBJECT *a);\nint i2d_ASN1_OBJECT(const ASN1_OBJECT *a, unsigned char **pp);\nASN1_OBJECT *d2i_ASN1_OBJECT(ASN1_OBJECT **a, const unsigned char **pp,\n                             long length);\n\nDECLARE_ASN1_ITEM(ASN1_OBJECT)\n\nDEFINE_STACK_OF(ASN1_OBJECT)\n\nASN1_STRING *ASN1_STRING_new(void);\nvoid ASN1_STRING_free(ASN1_STRING *a);\nvoid ASN1_STRING_clear_free(ASN1_STRING *a);\nint ASN1_STRING_copy(ASN1_STRING *dst, const ASN1_STRING *str);\nASN1_STRING *ASN1_STRING_dup(const ASN1_STRING *a);\nASN1_STRING *ASN1_STRING_type_new(int type);\nint ASN1_STRING_cmp(const ASN1_STRING *a, const ASN1_STRING *b);\n  /*\n   * Since this is used to store all sorts of things, via macros, for now,\n   * make its data void *\n   */\nint ASN1_STRING_set(ASN1_STRING *str, const void *data, int len);\nvoid ASN1_STRING_set0(ASN1_STRING *str, void *data, int len);\nint ASN1_STRING_length(const ASN1_STRING *x);\nvoid ASN1_STRING_length_set(ASN1_STRING *x, int n);\nint ASN1_STRING_type(const ASN1_STRING *x);\nDEPRECATEDIN_1_1_0(unsigned char *ASN1_STRING_data(ASN1_STRING *x))\nconst unsigned char *ASN1_STRING_get0_data(const ASN1_STRING *x);\n\nDECLARE_ASN1_FUNCTIONS(ASN1_BIT_STRING)\nint ASN1_BIT_STRING_set(ASN1_BIT_STRING *a, unsigned char *d, int length);\nint ASN1_BIT_STRING_set_bit(ASN1_BIT_STRING *a, int n, int value);\nint ASN1_BIT_STRING_get_bit(const ASN1_BIT_STRING *a, int n);\nint ASN1_BIT_STRING_check(const ASN1_BIT_STRING *a,\n                          const unsigned char *flags, int flags_len);\n\nint ASN1_BIT_STRING_name_print(BIO *out, ASN1_BIT_STRING *bs,\n                               BIT_STRING_BITNAME *tbl, int indent);\nint ASN1_BIT_STRING_num_asc(const char *name, BIT_STRING_BITNAME *tbl);\nint ASN1_BIT_STRING_set_asc(ASN1_BIT_STRING *bs, const char *name, int value,\n                            BIT_STRING_BITNAME *tbl);\n\nDECLARE_ASN1_FUNCTIONS(ASN1_INTEGER)\nASN1_INTEGER *d2i_ASN1_UINTEGER(ASN1_INTEGER **a, const unsigned char **pp,\n                                long length);\nASN1_INTEGER *ASN1_INTEGER_dup(const ASN1_INTEGER *x);\nint ASN1_INTEGER_cmp(const ASN1_INTEGER *x, const ASN1_INTEGER *y);\n\nDECLARE_ASN1_FUNCTIONS(ASN1_ENUMERATED)\n\nint ASN1_UTCTIME_check(const ASN1_UTCTIME *a);\nASN1_UTCTIME *ASN1_UTCTIME_set(ASN1_UTCTIME *s, time_t t);\nASN1_UTCTIME *ASN1_UTCTIME_adj(ASN1_UTCTIME *s, time_t t,\n                               int offset_day, long offset_sec);\nint ASN1_UTCTIME_set_string(ASN1_UTCTIME *s, const char *str);\nint ASN1_UTCTIME_cmp_time_t(const ASN1_UTCTIME *s, time_t t);\n\nint ASN1_GENERALIZEDTIME_check(const ASN1_GENERALIZEDTIME *a);\nASN1_GENERALIZEDTIME *ASN1_GENERALIZEDTIME_set(ASN1_GENERALIZEDTIME *s,\n                                               time_t t);\nASN1_GENERALIZEDTIME *ASN1_GENERALIZEDTIME_adj(ASN1_GENERALIZEDTIME *s,\n                                               time_t t, int offset_day,\n                                               long offset_sec);\nint ASN1_GENERALIZEDTIME_set_string(ASN1_GENERALIZEDTIME *s, const char *str);\n\nint ASN1_TIME_diff(int *pday, int *psec,\n                   const ASN1_TIME *from, const ASN1_TIME *to);\n\nDECLARE_ASN1_FUNCTIONS(ASN1_OCTET_STRING)\nASN1_OCTET_STRING *ASN1_OCTET_STRING_dup(const ASN1_OCTET_STRING *a);\nint ASN1_OCTET_STRING_cmp(const ASN1_OCTET_STRING *a,\n                          const ASN1_OCTET_STRING *b);\nint ASN1_OCTET_STRING_set(ASN1_OCTET_STRING *str, const unsigned char *data,\n                          int len);\n\nDECLARE_ASN1_FUNCTIONS(ASN1_VISIBLESTRING)\nDECLARE_ASN1_FUNCTIONS(ASN1_UNIVERSALSTRING)\nDECLARE_ASN1_FUNCTIONS(ASN1_UTF8STRING)\nDECLARE_ASN1_FUNCTIONS(ASN1_NULL)\nDECLARE_ASN1_FUNCTIONS(ASN1_BMPSTRING)\n\nint UTF8_getc(const unsigned char *str, int len, unsigned long *val);\nint UTF8_putc(unsigned char *str, int len, unsigned long value);\n\nDECLARE_ASN1_FUNCTIONS_name(ASN1_STRING, ASN1_PRINTABLE)\n\nDECLARE_ASN1_FUNCTIONS_name(ASN1_STRING, DIRECTORYSTRING)\nDECLARE_ASN1_FUNCTIONS_name(ASN1_STRING, DISPLAYTEXT)\nDECLARE_ASN1_FUNCTIONS(ASN1_PRINTABLESTRING)\nDECLARE_ASN1_FUNCTIONS(ASN1_T61STRING)\nDECLARE_ASN1_FUNCTIONS(ASN1_IA5STRING)\nDECLARE_ASN1_FUNCTIONS(ASN1_GENERALSTRING)\nDECLARE_ASN1_FUNCTIONS(ASN1_UTCTIME)\nDECLARE_ASN1_FUNCTIONS(ASN1_GENERALIZEDTIME)\nDECLARE_ASN1_FUNCTIONS(ASN1_TIME)\n\nDECLARE_ASN1_ITEM(ASN1_OCTET_STRING_NDEF)\n\nASN1_TIME *ASN1_TIME_set(ASN1_TIME *s, time_t t);\nASN1_TIME *ASN1_TIME_adj(ASN1_TIME *s, time_t t,\n                         int offset_day, long offset_sec);\nint ASN1_TIME_check(const ASN1_TIME *t);\nASN1_GENERALIZEDTIME *ASN1_TIME_to_generalizedtime(const ASN1_TIME *t,\n                                                   ASN1_GENERALIZEDTIME **out);\nint ASN1_TIME_set_string(ASN1_TIME *s, const char *str);\nint ASN1_TIME_set_string_X509(ASN1_TIME *s, const char *str);\nint ASN1_TIME_to_tm(const ASN1_TIME *s, struct tm *tm);\nint ASN1_TIME_normalize(ASN1_TIME *s);\nint ASN1_TIME_cmp_time_t(const ASN1_TIME *s, time_t t);\nint ASN1_TIME_compare(const ASN1_TIME *a, const ASN1_TIME *b);\n\nint i2a_ASN1_INTEGER(BIO *bp, const ASN1_INTEGER *a);\nint a2i_ASN1_INTEGER(BIO *bp, ASN1_INTEGER *bs, char *buf, int size);\nint i2a_ASN1_ENUMERATED(BIO *bp, const ASN1_ENUMERATED *a);\nint a2i_ASN1_ENUMERATED(BIO *bp, ASN1_ENUMERATED *bs, char *buf, int size);\nint i2a_ASN1_OBJECT(BIO *bp, const ASN1_OBJECT *a);\nint a2i_ASN1_STRING(BIO *bp, ASN1_STRING *bs, char *buf, int size);\nint i2a_ASN1_STRING(BIO *bp, const ASN1_STRING *a, int type);\nint i2t_ASN1_OBJECT(char *buf, int buf_len, const ASN1_OBJECT *a);\n\nint a2d_ASN1_OBJECT(unsigned char *out, int olen, const char *buf, int num);\nASN1_OBJECT *ASN1_OBJECT_create(int nid, unsigned char *data, int len,\n                                const char *sn, const char *ln);\n\nint ASN1_INTEGER_get_int64(int64_t *pr, const ASN1_INTEGER *a);\nint ASN1_INTEGER_set_int64(ASN1_INTEGER *a, int64_t r);\nint ASN1_INTEGER_get_uint64(uint64_t *pr, const ASN1_INTEGER *a);\nint ASN1_INTEGER_set_uint64(ASN1_INTEGER *a, uint64_t r);\n\nint ASN1_INTEGER_set(ASN1_INTEGER *a, long v);\nlong ASN1_INTEGER_get(const ASN1_INTEGER *a);\nASN1_INTEGER *BN_to_ASN1_INTEGER(const BIGNUM *bn, ASN1_INTEGER *ai);\nBIGNUM *ASN1_INTEGER_to_BN(const ASN1_INTEGER *ai, BIGNUM *bn);\n\nint ASN1_ENUMERATED_get_int64(int64_t *pr, const ASN1_ENUMERATED *a);\nint ASN1_ENUMERATED_set_int64(ASN1_ENUMERATED *a, int64_t r);\n\n\nint ASN1_ENUMERATED_set(ASN1_ENUMERATED *a, long v);\nlong ASN1_ENUMERATED_get(const ASN1_ENUMERATED *a);\nASN1_ENUMERATED *BN_to_ASN1_ENUMERATED(const BIGNUM *bn, ASN1_ENUMERATED *ai);\nBIGNUM *ASN1_ENUMERATED_to_BN(const ASN1_ENUMERATED *ai, BIGNUM *bn);\n\n/* General */\n/* given a string, return the correct type, max is the maximum length */\nint ASN1_PRINTABLE_type(const unsigned char *s, int max);\n\nunsigned long ASN1_tag2bit(int tag);\n\n/* SPECIALS */\nint ASN1_get_object(const unsigned char **pp, long *plength, int *ptag,\n                    int *pclass, long omax);\nint ASN1_check_infinite_end(unsigned char **p, long len);\nint ASN1_const_check_infinite_end(const unsigned char **p, long len);\nvoid ASN1_put_object(unsigned char **pp, int constructed, int length,\n                     int tag, int xclass);\nint ASN1_put_eoc(unsigned char **pp);\nint ASN1_object_size(int constructed, int length, int tag);\n\n/* Used to implement other functions */\nvoid *ASN1_dup(i2d_of_void *i2d, d2i_of_void *d2i, void *x);\n\n# define ASN1_dup_of(type,i2d,d2i,x) \\\n    ((type*)ASN1_dup(CHECKED_I2D_OF(type, i2d), \\\n                     CHECKED_D2I_OF(type, d2i), \\\n                     CHECKED_PTR_OF(type, x)))\n\n# define ASN1_dup_of_const(type,i2d,d2i,x) \\\n    ((type*)ASN1_dup(CHECKED_I2D_OF(const type, i2d), \\\n                     CHECKED_D2I_OF(type, d2i), \\\n                     CHECKED_PTR_OF(const type, x)))\n\nvoid *ASN1_item_dup(const ASN1_ITEM *it, void *x);\n\n/* ASN1 alloc/free macros for when a type is only used internally */\n\n# define M_ASN1_new_of(type) (type *)ASN1_item_new(ASN1_ITEM_rptr(type))\n# define M_ASN1_free_of(x, type) \\\n                ASN1_item_free(CHECKED_PTR_OF(type, x), ASN1_ITEM_rptr(type))\n\n# ifndef OPENSSL_NO_STDIO\nvoid *ASN1_d2i_fp(void *(*xnew) (void), d2i_of_void *d2i, FILE *in, void **x);\n\n#  define ASN1_d2i_fp_of(type,xnew,d2i,in,x) \\\n    ((type*)ASN1_d2i_fp(CHECKED_NEW_OF(type, xnew), \\\n                        CHECKED_D2I_OF(type, d2i), \\\n                        in, \\\n                        CHECKED_PPTR_OF(type, x)))\n\nvoid *ASN1_item_d2i_fp(const ASN1_ITEM *it, FILE *in, void *x);\nint ASN1_i2d_fp(i2d_of_void *i2d, FILE *out, void *x);\n\n#  define ASN1_i2d_fp_of(type,i2d,out,x) \\\n    (ASN1_i2d_fp(CHECKED_I2D_OF(type, i2d), \\\n                 out, \\\n                 CHECKED_PTR_OF(type, x)))\n\n#  define ASN1_i2d_fp_of_const(type,i2d,out,x) \\\n    (ASN1_i2d_fp(CHECKED_I2D_OF(const type, i2d), \\\n                 out, \\\n                 CHECKED_PTR_OF(const type, x)))\n\nint ASN1_item_i2d_fp(const ASN1_ITEM *it, FILE *out, void *x);\nint ASN1_STRING_print_ex_fp(FILE *fp, const ASN1_STRING *str, unsigned long flags);\n# endif\n\nint ASN1_STRING_to_UTF8(unsigned char **out, const ASN1_STRING *in);\n\nvoid *ASN1_d2i_bio(void *(*xnew) (void), d2i_of_void *d2i, BIO *in, void **x);\n\n#  define ASN1_d2i_bio_of(type,xnew,d2i,in,x) \\\n    ((type*)ASN1_d2i_bio( CHECKED_NEW_OF(type, xnew), \\\n                          CHECKED_D2I_OF(type, d2i), \\\n                          in, \\\n                          CHECKED_PPTR_OF(type, x)))\n\nvoid *ASN1_item_d2i_bio(const ASN1_ITEM *it, BIO *in, void *x);\nint ASN1_i2d_bio(i2d_of_void *i2d, BIO *out, unsigned char *x);\n\n#  define ASN1_i2d_bio_of(type,i2d,out,x) \\\n    (ASN1_i2d_bio(CHECKED_I2D_OF(type, i2d), \\\n                  out, \\\n                  CHECKED_PTR_OF(type, x)))\n\n#  define ASN1_i2d_bio_of_const(type,i2d,out,x) \\\n    (ASN1_i2d_bio(CHECKED_I2D_OF(const type, i2d), \\\n                  out, \\\n                  CHECKED_PTR_OF(const type, x)))\n\nint ASN1_item_i2d_bio(const ASN1_ITEM *it, BIO *out, void *x);\nint ASN1_UTCTIME_print(BIO *fp, const ASN1_UTCTIME *a);\nint ASN1_GENERALIZEDTIME_print(BIO *fp, const ASN1_GENERALIZEDTIME *a);\nint ASN1_TIME_print(BIO *fp, const ASN1_TIME *a);\nint ASN1_STRING_print(BIO *bp, const ASN1_STRING *v);\nint ASN1_STRING_print_ex(BIO *out, const ASN1_STRING *str, unsigned long flags);\nint ASN1_buf_print(BIO *bp, const unsigned char *buf, size_t buflen, int off);\nint ASN1_bn_print(BIO *bp, const char *number, const BIGNUM *num,\n                  unsigned char *buf, int off);\nint ASN1_parse(BIO *bp, const unsigned char *pp, long len, int indent);\nint ASN1_parse_dump(BIO *bp, const unsigned char *pp, long len, int indent,\n                    int dump);\nconst char *ASN1_tag2str(int tag);\n\n/* Used to load and write Netscape format cert */\n\nint ASN1_UNIVERSALSTRING_to_string(ASN1_UNIVERSALSTRING *s);\n\nint ASN1_TYPE_set_octetstring(ASN1_TYPE *a, unsigned char *data, int len);\nint ASN1_TYPE_get_octetstring(const ASN1_TYPE *a, unsigned char *data, int max_len);\nint ASN1_TYPE_set_int_octetstring(ASN1_TYPE *a, long num,\n                                  unsigned char *data, int len);\nint ASN1_TYPE_get_int_octetstring(const ASN1_TYPE *a, long *num,\n                                  unsigned char *data, int max_len);\n\nvoid *ASN1_item_unpack(const ASN1_STRING *oct, const ASN1_ITEM *it);\n\nASN1_STRING *ASN1_item_pack(void *obj, const ASN1_ITEM *it,\n                            ASN1_OCTET_STRING **oct);\n\nvoid ASN1_STRING_set_default_mask(unsigned long mask);\nint ASN1_STRING_set_default_mask_asc(const char *p);\nunsigned long ASN1_STRING_get_default_mask(void);\nint ASN1_mbstring_copy(ASN1_STRING **out, const unsigned char *in, int len,\n                       int inform, unsigned long mask);\nint ASN1_mbstring_ncopy(ASN1_STRING **out, const unsigned char *in, int len,\n                        int inform, unsigned long mask,\n                        long minsize, long maxsize);\n\nASN1_STRING *ASN1_STRING_set_by_NID(ASN1_STRING **out,\n                                    const unsigned char *in, int inlen,\n                                    int inform, int nid);\nASN1_STRING_TABLE *ASN1_STRING_TABLE_get(int nid);\nint ASN1_STRING_TABLE_add(int, long, long, unsigned long, unsigned long);\nvoid ASN1_STRING_TABLE_cleanup(void);\n\n/* ASN1 template functions */\n\n/* Old API compatible functions */\nASN1_VALUE *ASN1_item_new(const ASN1_ITEM *it);\nvoid ASN1_item_free(ASN1_VALUE *val, const ASN1_ITEM *it);\nASN1_VALUE *ASN1_item_d2i(ASN1_VALUE **val, const unsigned char **in,\n                          long len, const ASN1_ITEM *it);\nint ASN1_item_i2d(ASN1_VALUE *val, unsigned char **out, const ASN1_ITEM *it);\nint ASN1_item_ndef_i2d(ASN1_VALUE *val, unsigned char **out,\n                       const ASN1_ITEM *it);\n\nvoid ASN1_add_oid_module(void);\nvoid ASN1_add_stable_module(void);\n\nASN1_TYPE *ASN1_generate_nconf(const char *str, CONF *nconf);\nASN1_TYPE *ASN1_generate_v3(const char *str, X509V3_CTX *cnf);\nint ASN1_str2mask(const char *str, unsigned long *pmask);\n\n/* ASN1 Print flags */\n\n/* Indicate missing OPTIONAL fields */\n# define ASN1_PCTX_FLAGS_SHOW_ABSENT             0x001\n/* Mark start and end of SEQUENCE */\n# define ASN1_PCTX_FLAGS_SHOW_SEQUENCE           0x002\n/* Mark start and end of SEQUENCE/SET OF */\n# define ASN1_PCTX_FLAGS_SHOW_SSOF               0x004\n/* Show the ASN1 type of primitives */\n# define ASN1_PCTX_FLAGS_SHOW_TYPE               0x008\n/* Don't show ASN1 type of ANY */\n# define ASN1_PCTX_FLAGS_NO_ANY_TYPE             0x010\n/* Don't show ASN1 type of MSTRINGs */\n# define ASN1_PCTX_FLAGS_NO_MSTRING_TYPE         0x020\n/* Don't show field names in SEQUENCE */\n# define ASN1_PCTX_FLAGS_NO_FIELD_NAME           0x040\n/* Show structure names of each SEQUENCE field */\n# define ASN1_PCTX_FLAGS_SHOW_FIELD_STRUCT_NAME  0x080\n/* Don't show structure name even at top level */\n# define ASN1_PCTX_FLAGS_NO_STRUCT_NAME          0x100\n\nint ASN1_item_print(BIO *out, ASN1_VALUE *ifld, int indent,\n                    const ASN1_ITEM *it, const ASN1_PCTX *pctx);\nASN1_PCTX *ASN1_PCTX_new(void);\nvoid ASN1_PCTX_free(ASN1_PCTX *p);\nunsigned long ASN1_PCTX_get_flags(const ASN1_PCTX *p);\nvoid ASN1_PCTX_set_flags(ASN1_PCTX *p, unsigned long flags);\nunsigned long ASN1_PCTX_get_nm_flags(const ASN1_PCTX *p);\nvoid ASN1_PCTX_set_nm_flags(ASN1_PCTX *p, unsigned long flags);\nunsigned long ASN1_PCTX_get_cert_flags(const ASN1_PCTX *p);\nvoid ASN1_PCTX_set_cert_flags(ASN1_PCTX *p, unsigned long flags);\nunsigned long ASN1_PCTX_get_oid_flags(const ASN1_PCTX *p);\nvoid ASN1_PCTX_set_oid_flags(ASN1_PCTX *p, unsigned long flags);\nunsigned long ASN1_PCTX_get_str_flags(const ASN1_PCTX *p);\nvoid ASN1_PCTX_set_str_flags(ASN1_PCTX *p, unsigned long flags);\n\nASN1_SCTX *ASN1_SCTX_new(int (*scan_cb) (ASN1_SCTX *ctx));\nvoid ASN1_SCTX_free(ASN1_SCTX *p);\nconst ASN1_ITEM *ASN1_SCTX_get_item(ASN1_SCTX *p);\nconst ASN1_TEMPLATE *ASN1_SCTX_get_template(ASN1_SCTX *p);\nunsigned long ASN1_SCTX_get_flags(ASN1_SCTX *p);\nvoid ASN1_SCTX_set_app_data(ASN1_SCTX *p, void *data);\nvoid *ASN1_SCTX_get_app_data(ASN1_SCTX *p);\n\nconst BIO_METHOD *BIO_f_asn1(void);\n\nBIO *BIO_new_NDEF(BIO *out, ASN1_VALUE *val, const ASN1_ITEM *it);\n\nint i2d_ASN1_bio_stream(BIO *out, ASN1_VALUE *val, BIO *in, int flags,\n                        const ASN1_ITEM *it);\nint PEM_write_bio_ASN1_stream(BIO *out, ASN1_VALUE *val, BIO *in, int flags,\n                              const char *hdr, const ASN1_ITEM *it);\nint SMIME_write_ASN1(BIO *bio, ASN1_VALUE *val, BIO *data, int flags,\n                     int ctype_nid, int econt_nid,\n                     STACK_OF(X509_ALGOR) *mdalgs, const ASN1_ITEM *it);\nASN1_VALUE *SMIME_read_ASN1(BIO *bio, BIO **bcont, const ASN1_ITEM *it);\nint SMIME_crlf_copy(BIO *in, BIO *out, int flags);\nint SMIME_text(BIO *in, BIO *out);\n\nconst ASN1_ITEM *ASN1_ITEM_lookup(const char *name);\nconst ASN1_ITEM *ASN1_ITEM_get(size_t i);\n\n# ifdef  __cplusplus\n}\n# endif\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/include/openssl/asn1_mac.h",
    "content": "/*\n * Copyright 2015-2016 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#error \"This file is obsolete; please update your software.\"\n"
  },
  {
    "path": "tools/prebuild/openssl/include/openssl/asn1err.h",
    "content": "/*\n * Generated by util/mkerr.pl DO NOT EDIT\n * Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef HEADER_ASN1ERR_H\n# define HEADER_ASN1ERR_H\n\n# include <openssl/symhacks.h>\n\n# ifdef  __cplusplus\nextern \"C\"\n# endif\nint ERR_load_ASN1_strings(void);\n\n/*\n * ASN1 function codes.\n */\n# define ASN1_F_A2D_ASN1_OBJECT                           100\n# define ASN1_F_A2I_ASN1_INTEGER                          102\n# define ASN1_F_A2I_ASN1_STRING                           103\n# define ASN1_F_APPEND_EXP                                176\n# define ASN1_F_ASN1_BIO_INIT                             113\n# define ASN1_F_ASN1_BIT_STRING_SET_BIT                   183\n# define ASN1_F_ASN1_CB                                   177\n# define ASN1_F_ASN1_CHECK_TLEN                           104\n# define ASN1_F_ASN1_COLLECT                              106\n# define ASN1_F_ASN1_D2I_EX_PRIMITIVE                     108\n# define ASN1_F_ASN1_D2I_FP                               109\n# define ASN1_F_ASN1_D2I_READ_BIO                         107\n# define ASN1_F_ASN1_DIGEST                               184\n# define ASN1_F_ASN1_DO_ADB                               110\n# define ASN1_F_ASN1_DO_LOCK                              233\n# define ASN1_F_ASN1_DUP                                  111\n# define ASN1_F_ASN1_ENC_SAVE                             115\n# define ASN1_F_ASN1_EX_C2I                               204\n# define ASN1_F_ASN1_FIND_END                             190\n# define ASN1_F_ASN1_GENERALIZEDTIME_ADJ                  216\n# define ASN1_F_ASN1_GENERATE_V3                          178\n# define ASN1_F_ASN1_GET_INT64                            224\n# define ASN1_F_ASN1_GET_OBJECT                           114\n# define ASN1_F_ASN1_GET_UINT64                           225\n# define ASN1_F_ASN1_I2D_BIO                              116\n# define ASN1_F_ASN1_I2D_FP                               117\n# define ASN1_F_ASN1_ITEM_D2I_FP                          206\n# define ASN1_F_ASN1_ITEM_DUP                             191\n# define ASN1_F_ASN1_ITEM_EMBED_D2I                       120\n# define ASN1_F_ASN1_ITEM_EMBED_NEW                       121\n# define ASN1_F_ASN1_ITEM_EX_I2D                          144\n# define ASN1_F_ASN1_ITEM_FLAGS_I2D                       118\n# define ASN1_F_ASN1_ITEM_I2D_BIO                         192\n# define ASN1_F_ASN1_ITEM_I2D_FP                          193\n# define ASN1_F_ASN1_ITEM_PACK                            198\n# define ASN1_F_ASN1_ITEM_SIGN                            195\n# define ASN1_F_ASN1_ITEM_SIGN_CTX                        220\n# define ASN1_F_ASN1_ITEM_UNPACK                          199\n# define ASN1_F_ASN1_ITEM_VERIFY                          197\n# define ASN1_F_ASN1_MBSTRING_NCOPY                       122\n# define ASN1_F_ASN1_OBJECT_NEW                           123\n# define ASN1_F_ASN1_OUTPUT_DATA                          214\n# define ASN1_F_ASN1_PCTX_NEW                             205\n# define ASN1_F_ASN1_PRIMITIVE_NEW                        119\n# define ASN1_F_ASN1_SCTX_NEW                             221\n# define ASN1_F_ASN1_SIGN                                 128\n# define ASN1_F_ASN1_STR2TYPE                             179\n# define ASN1_F_ASN1_STRING_GET_INT64                     227\n# define ASN1_F_ASN1_STRING_GET_UINT64                    230\n# define ASN1_F_ASN1_STRING_SET                           186\n# define ASN1_F_ASN1_STRING_TABLE_ADD                     129\n# define ASN1_F_ASN1_STRING_TO_BN                         228\n# define ASN1_F_ASN1_STRING_TYPE_NEW                      130\n# define ASN1_F_ASN1_TEMPLATE_EX_D2I                      132\n# define ASN1_F_ASN1_TEMPLATE_NEW                         133\n# define ASN1_F_ASN1_TEMPLATE_NOEXP_D2I                   131\n# define ASN1_F_ASN1_TIME_ADJ                             217\n# define ASN1_F_ASN1_TYPE_GET_INT_OCTETSTRING             134\n# define ASN1_F_ASN1_TYPE_GET_OCTETSTRING                 135\n# define ASN1_F_ASN1_UTCTIME_ADJ                          218\n# define ASN1_F_ASN1_VERIFY                               137\n# define ASN1_F_B64_READ_ASN1                             209\n# define ASN1_F_B64_WRITE_ASN1                            210\n# define ASN1_F_BIO_NEW_NDEF                              208\n# define ASN1_F_BITSTR_CB                                 180\n# define ASN1_F_BN_TO_ASN1_STRING                         229\n# define ASN1_F_C2I_ASN1_BIT_STRING                       189\n# define ASN1_F_C2I_ASN1_INTEGER                          194\n# define ASN1_F_C2I_ASN1_OBJECT                           196\n# define ASN1_F_C2I_IBUF                                  226\n# define ASN1_F_C2I_UINT64_INT                            101\n# define ASN1_F_COLLECT_DATA                              140\n# define ASN1_F_D2I_ASN1_OBJECT                           147\n# define ASN1_F_D2I_ASN1_UINTEGER                         150\n# define ASN1_F_D2I_AUTOPRIVATEKEY                        207\n# define ASN1_F_D2I_PRIVATEKEY                            154\n# define ASN1_F_D2I_PUBLICKEY                             155\n# define ASN1_F_DO_BUF                                    142\n# define ASN1_F_DO_CREATE                                 124\n# define ASN1_F_DO_DUMP                                   125\n# define ASN1_F_DO_TCREATE                                222\n# define ASN1_F_I2A_ASN1_OBJECT                           126\n# define ASN1_F_I2D_ASN1_BIO_STREAM                       211\n# define ASN1_F_I2D_ASN1_OBJECT                           143\n# define ASN1_F_I2D_DSA_PUBKEY                            161\n# define ASN1_F_I2D_EC_PUBKEY                             181\n# define ASN1_F_I2D_PRIVATEKEY                            163\n# define ASN1_F_I2D_PUBLICKEY                             164\n# define ASN1_F_I2D_RSA_PUBKEY                            165\n# define ASN1_F_LONG_C2I                                  166\n# define ASN1_F_NDEF_PREFIX                               127\n# define ASN1_F_NDEF_SUFFIX                               136\n# define ASN1_F_OID_MODULE_INIT                           174\n# define ASN1_F_PARSE_TAGGING                             182\n# define ASN1_F_PKCS5_PBE2_SET_IV                         167\n# define ASN1_F_PKCS5_PBE2_SET_SCRYPT                     231\n# define ASN1_F_PKCS5_PBE_SET                             202\n# define ASN1_F_PKCS5_PBE_SET0_ALGOR                      215\n# define ASN1_F_PKCS5_PBKDF2_SET                          219\n# define ASN1_F_PKCS5_SCRYPT_SET                          232\n# define ASN1_F_SMIME_READ_ASN1                           212\n# define ASN1_F_SMIME_TEXT                                213\n# define ASN1_F_STABLE_GET                                138\n# define ASN1_F_STBL_MODULE_INIT                          223\n# define ASN1_F_UINT32_C2I                                105\n# define ASN1_F_UINT32_NEW                                139\n# define ASN1_F_UINT64_C2I                                112\n# define ASN1_F_UINT64_NEW                                141\n# define ASN1_F_X509_CRL_ADD0_REVOKED                     169\n# define ASN1_F_X509_INFO_NEW                             170\n# define ASN1_F_X509_NAME_ENCODE                          203\n# define ASN1_F_X509_NAME_EX_D2I                          158\n# define ASN1_F_X509_NAME_EX_NEW                          171\n# define ASN1_F_X509_PKEY_NEW                             173\n\n/*\n * ASN1 reason codes.\n */\n# define ASN1_R_ADDING_OBJECT                             171\n# define ASN1_R_ASN1_PARSE_ERROR                          203\n# define ASN1_R_ASN1_SIG_PARSE_ERROR                      204\n# define ASN1_R_AUX_ERROR                                 100\n# define ASN1_R_BAD_OBJECT_HEADER                         102\n# define ASN1_R_BAD_TEMPLATE                              230\n# define ASN1_R_BMPSTRING_IS_WRONG_LENGTH                 214\n# define ASN1_R_BN_LIB                                    105\n# define ASN1_R_BOOLEAN_IS_WRONG_LENGTH                   106\n# define ASN1_R_BUFFER_TOO_SMALL                          107\n# define ASN1_R_CIPHER_HAS_NO_OBJECT_IDENTIFIER           108\n# define ASN1_R_CONTEXT_NOT_INITIALISED                   217\n# define ASN1_R_DATA_IS_WRONG                             109\n# define ASN1_R_DECODE_ERROR                              110\n# define ASN1_R_DEPTH_EXCEEDED                            174\n# define ASN1_R_DIGEST_AND_KEY_TYPE_NOT_SUPPORTED         198\n# define ASN1_R_ENCODE_ERROR                              112\n# define ASN1_R_ERROR_GETTING_TIME                        173\n# define ASN1_R_ERROR_LOADING_SECTION                     172\n# define ASN1_R_ERROR_SETTING_CIPHER_PARAMS               114\n# define ASN1_R_EXPECTING_AN_INTEGER                      115\n# define ASN1_R_EXPECTING_AN_OBJECT                       116\n# define ASN1_R_EXPLICIT_LENGTH_MISMATCH                  119\n# define ASN1_R_EXPLICIT_TAG_NOT_CONSTRUCTED              120\n# define ASN1_R_FIELD_MISSING                             121\n# define ASN1_R_FIRST_NUM_TOO_LARGE                       122\n# define ASN1_R_HEADER_TOO_LONG                           123\n# define ASN1_R_ILLEGAL_BITSTRING_FORMAT                  175\n# define ASN1_R_ILLEGAL_BOOLEAN                           176\n# define ASN1_R_ILLEGAL_CHARACTERS                        124\n# define ASN1_R_ILLEGAL_FORMAT                            177\n# define ASN1_R_ILLEGAL_HEX                               178\n# define ASN1_R_ILLEGAL_IMPLICIT_TAG                      179\n# define ASN1_R_ILLEGAL_INTEGER                           180\n# define ASN1_R_ILLEGAL_NEGATIVE_VALUE                    226\n# define ASN1_R_ILLEGAL_NESTED_TAGGING                    181\n# define ASN1_R_ILLEGAL_NULL                              125\n# define ASN1_R_ILLEGAL_NULL_VALUE                        182\n# define ASN1_R_ILLEGAL_OBJECT                            183\n# define ASN1_R_ILLEGAL_OPTIONAL_ANY                      126\n# define ASN1_R_ILLEGAL_OPTIONS_ON_ITEM_TEMPLATE          170\n# define ASN1_R_ILLEGAL_PADDING                           221\n# define ASN1_R_ILLEGAL_TAGGED_ANY                        127\n# define ASN1_R_ILLEGAL_TIME_VALUE                        184\n# define ASN1_R_ILLEGAL_ZERO_CONTENT                      222\n# define ASN1_R_INTEGER_NOT_ASCII_FORMAT                  185\n# define ASN1_R_INTEGER_TOO_LARGE_FOR_LONG                128\n# define ASN1_R_INVALID_BIT_STRING_BITS_LEFT              220\n# define ASN1_R_INVALID_BMPSTRING_LENGTH                  129\n# define ASN1_R_INVALID_DIGIT                             130\n# define ASN1_R_INVALID_MIME_TYPE                         205\n# define ASN1_R_INVALID_MODIFIER                          186\n# define ASN1_R_INVALID_NUMBER                            187\n# define ASN1_R_INVALID_OBJECT_ENCODING                   216\n# define ASN1_R_INVALID_SCRYPT_PARAMETERS                 227\n# define ASN1_R_INVALID_SEPARATOR                         131\n# define ASN1_R_INVALID_STRING_TABLE_VALUE                218\n# define ASN1_R_INVALID_UNIVERSALSTRING_LENGTH            133\n# define ASN1_R_INVALID_UTF8STRING                        134\n# define ASN1_R_INVALID_VALUE                             219\n# define ASN1_R_LIST_ERROR                                188\n# define ASN1_R_MIME_NO_CONTENT_TYPE                      206\n# define ASN1_R_MIME_PARSE_ERROR                          207\n# define ASN1_R_MIME_SIG_PARSE_ERROR                      208\n# define ASN1_R_MISSING_EOC                               137\n# define ASN1_R_MISSING_SECOND_NUMBER                     138\n# define ASN1_R_MISSING_VALUE                             189\n# define ASN1_R_MSTRING_NOT_UNIVERSAL                     139\n# define ASN1_R_MSTRING_WRONG_TAG                         140\n# define ASN1_R_NESTED_ASN1_STRING                        197\n# define ASN1_R_NESTED_TOO_DEEP                           201\n# define ASN1_R_NON_HEX_CHARACTERS                        141\n# define ASN1_R_NOT_ASCII_FORMAT                          190\n# define ASN1_R_NOT_ENOUGH_DATA                           142\n# define ASN1_R_NO_CONTENT_TYPE                           209\n# define ASN1_R_NO_MATCHING_CHOICE_TYPE                   143\n# define ASN1_R_NO_MULTIPART_BODY_FAILURE                 210\n# define ASN1_R_NO_MULTIPART_BOUNDARY                     211\n# define ASN1_R_NO_SIG_CONTENT_TYPE                       212\n# define ASN1_R_NULL_IS_WRONG_LENGTH                      144\n# define ASN1_R_OBJECT_NOT_ASCII_FORMAT                   191\n# define ASN1_R_ODD_NUMBER_OF_CHARS                       145\n# define ASN1_R_SECOND_NUMBER_TOO_LARGE                   147\n# define ASN1_R_SEQUENCE_LENGTH_MISMATCH                  148\n# define ASN1_R_SEQUENCE_NOT_CONSTRUCTED                  149\n# define ASN1_R_SEQUENCE_OR_SET_NEEDS_CONFIG              192\n# define ASN1_R_SHORT_LINE                                150\n# define ASN1_R_SIG_INVALID_MIME_TYPE                     213\n# define ASN1_R_STREAMING_NOT_SUPPORTED                   202\n# define ASN1_R_STRING_TOO_LONG                           151\n# define ASN1_R_STRING_TOO_SHORT                          152\n# define ASN1_R_THE_ASN1_OBJECT_IDENTIFIER_IS_NOT_KNOWN_FOR_THIS_MD 154\n# define ASN1_R_TIME_NOT_ASCII_FORMAT                     193\n# define ASN1_R_TOO_LARGE                                 223\n# define ASN1_R_TOO_LONG                                  155\n# define ASN1_R_TOO_SMALL                                 224\n# define ASN1_R_TYPE_NOT_CONSTRUCTED                      156\n# define ASN1_R_TYPE_NOT_PRIMITIVE                        195\n# define ASN1_R_UNEXPECTED_EOC                            159\n# define ASN1_R_UNIVERSALSTRING_IS_WRONG_LENGTH           215\n# define ASN1_R_UNKNOWN_FORMAT                            160\n# define ASN1_R_UNKNOWN_MESSAGE_DIGEST_ALGORITHM          161\n# define ASN1_R_UNKNOWN_OBJECT_TYPE                       162\n# define ASN1_R_UNKNOWN_PUBLIC_KEY_TYPE                   163\n# define ASN1_R_UNKNOWN_SIGNATURE_ALGORITHM               199\n# define ASN1_R_UNKNOWN_TAG                               194\n# define ASN1_R_UNSUPPORTED_ANY_DEFINED_BY_TYPE           164\n# define ASN1_R_UNSUPPORTED_CIPHER                        228\n# define ASN1_R_UNSUPPORTED_PUBLIC_KEY_TYPE               167\n# define ASN1_R_UNSUPPORTED_TYPE                          196\n# define ASN1_R_WRONG_INTEGER_TYPE                        225\n# define ASN1_R_WRONG_PUBLIC_KEY_TYPE                     200\n# define ASN1_R_WRONG_TAG                                 168\n\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/include/openssl/asn1t.h",
    "content": "/*\n * Copyright 2000-2016 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef HEADER_ASN1T_H\n# define HEADER_ASN1T_H\n\n# include <stddef.h>\n# include <openssl/e_os2.h>\n# include <openssl/asn1.h>\n\n# ifdef OPENSSL_BUILD_SHLIBCRYPTO\n#  undef OPENSSL_EXTERN\n#  define OPENSSL_EXTERN OPENSSL_EXPORT\n# endif\n\n/* ASN1 template defines, structures and functions */\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n# ifndef OPENSSL_EXPORT_VAR_AS_FUNCTION\n\n/* Macro to obtain ASN1_ADB pointer from a type (only used internally) */\n#  define ASN1_ADB_ptr(iptr) ((const ASN1_ADB *)(iptr))\n\n/* Macros for start and end of ASN1_ITEM definition */\n\n#  define ASN1_ITEM_start(itname) \\\n        const ASN1_ITEM itname##_it = {\n\n#  define static_ASN1_ITEM_start(itname) \\\n        static const ASN1_ITEM itname##_it = {\n\n#  define ASN1_ITEM_end(itname)                 \\\n                };\n\n# else\n\n/* Macro to obtain ASN1_ADB pointer from a type (only used internally) */\n#  define ASN1_ADB_ptr(iptr) ((const ASN1_ADB *)((iptr)()))\n\n/* Macros for start and end of ASN1_ITEM definition */\n\n#  define ASN1_ITEM_start(itname) \\\n        const ASN1_ITEM * itname##_it(void) \\\n        { \\\n                static const ASN1_ITEM local_it = {\n\n#  define static_ASN1_ITEM_start(itname) \\\n        static ASN1_ITEM_start(itname)\n\n#  define ASN1_ITEM_end(itname) \\\n                }; \\\n        return &local_it; \\\n        }\n\n# endif\n\n/* Macros to aid ASN1 template writing */\n\n# define ASN1_ITEM_TEMPLATE(tname) \\\n        static const ASN1_TEMPLATE tname##_item_tt\n\n# define ASN1_ITEM_TEMPLATE_END(tname) \\\n        ;\\\n        ASN1_ITEM_start(tname) \\\n                ASN1_ITYPE_PRIMITIVE,\\\n                -1,\\\n                &tname##_item_tt,\\\n                0,\\\n                NULL,\\\n                0,\\\n                #tname \\\n        ASN1_ITEM_end(tname)\n# define static_ASN1_ITEM_TEMPLATE_END(tname) \\\n        ;\\\n        static_ASN1_ITEM_start(tname) \\\n                ASN1_ITYPE_PRIMITIVE,\\\n                -1,\\\n                &tname##_item_tt,\\\n                0,\\\n                NULL,\\\n                0,\\\n                #tname \\\n        ASN1_ITEM_end(tname)\n\n/* This is a ASN1 type which just embeds a template */\n\n/*-\n * This pair helps declare a SEQUENCE. We can do:\n *\n *      ASN1_SEQUENCE(stname) = {\n *              ... SEQUENCE components ...\n *      } ASN1_SEQUENCE_END(stname)\n *\n *      This will produce an ASN1_ITEM called stname_it\n *      for a structure called stname.\n *\n *      If you want the same structure but a different\n *      name then use:\n *\n *      ASN1_SEQUENCE(itname) = {\n *              ... SEQUENCE components ...\n *      } ASN1_SEQUENCE_END_name(stname, itname)\n *\n *      This will create an item called itname_it using\n *      a structure called stname.\n */\n\n# define ASN1_SEQUENCE(tname) \\\n        static const ASN1_TEMPLATE tname##_seq_tt[]\n\n# define ASN1_SEQUENCE_END(stname) ASN1_SEQUENCE_END_name(stname, stname)\n\n# define static_ASN1_SEQUENCE_END(stname) static_ASN1_SEQUENCE_END_name(stname, stname)\n\n# define ASN1_SEQUENCE_END_name(stname, tname) \\\n        ;\\\n        ASN1_ITEM_start(tname) \\\n                ASN1_ITYPE_SEQUENCE,\\\n                V_ASN1_SEQUENCE,\\\n                tname##_seq_tt,\\\n                sizeof(tname##_seq_tt) / sizeof(ASN1_TEMPLATE),\\\n                NULL,\\\n                sizeof(stname),\\\n                #tname \\\n        ASN1_ITEM_end(tname)\n\n# define static_ASN1_SEQUENCE_END_name(stname, tname) \\\n        ;\\\n        static_ASN1_ITEM_start(tname) \\\n                ASN1_ITYPE_SEQUENCE,\\\n                V_ASN1_SEQUENCE,\\\n                tname##_seq_tt,\\\n                sizeof(tname##_seq_tt) / sizeof(ASN1_TEMPLATE),\\\n                NULL,\\\n                sizeof(stname),\\\n                #stname \\\n        ASN1_ITEM_end(tname)\n\n# define ASN1_NDEF_SEQUENCE(tname) \\\n        ASN1_SEQUENCE(tname)\n\n# define ASN1_NDEF_SEQUENCE_cb(tname, cb) \\\n        ASN1_SEQUENCE_cb(tname, cb)\n\n# define ASN1_SEQUENCE_cb(tname, cb) \\\n        static const ASN1_AUX tname##_aux = {NULL, 0, 0, 0, cb, 0}; \\\n        ASN1_SEQUENCE(tname)\n\n# define ASN1_BROKEN_SEQUENCE(tname) \\\n        static const ASN1_AUX tname##_aux = {NULL, ASN1_AFLG_BROKEN, 0, 0, 0, 0}; \\\n        ASN1_SEQUENCE(tname)\n\n# define ASN1_SEQUENCE_ref(tname, cb) \\\n        static const ASN1_AUX tname##_aux = {NULL, ASN1_AFLG_REFCOUNT, offsetof(tname, references), offsetof(tname, lock), cb, 0}; \\\n        ASN1_SEQUENCE(tname)\n\n# define ASN1_SEQUENCE_enc(tname, enc, cb) \\\n        static const ASN1_AUX tname##_aux = {NULL, ASN1_AFLG_ENCODING, 0, 0, cb, offsetof(tname, enc)}; \\\n        ASN1_SEQUENCE(tname)\n\n# define ASN1_NDEF_SEQUENCE_END(tname) \\\n        ;\\\n        ASN1_ITEM_start(tname) \\\n                ASN1_ITYPE_NDEF_SEQUENCE,\\\n                V_ASN1_SEQUENCE,\\\n                tname##_seq_tt,\\\n                sizeof(tname##_seq_tt) / sizeof(ASN1_TEMPLATE),\\\n                NULL,\\\n                sizeof(tname),\\\n                #tname \\\n        ASN1_ITEM_end(tname)\n# define static_ASN1_NDEF_SEQUENCE_END(tname) \\\n        ;\\\n        static_ASN1_ITEM_start(tname) \\\n                ASN1_ITYPE_NDEF_SEQUENCE,\\\n                V_ASN1_SEQUENCE,\\\n                tname##_seq_tt,\\\n                sizeof(tname##_seq_tt) / sizeof(ASN1_TEMPLATE),\\\n                NULL,\\\n                sizeof(tname),\\\n                #tname \\\n        ASN1_ITEM_end(tname)\n\n# define ASN1_BROKEN_SEQUENCE_END(stname) ASN1_SEQUENCE_END_ref(stname, stname)\n# define static_ASN1_BROKEN_SEQUENCE_END(stname) \\\n        static_ASN1_SEQUENCE_END_ref(stname, stname)\n\n# define ASN1_SEQUENCE_END_enc(stname, tname) ASN1_SEQUENCE_END_ref(stname, tname)\n\n# define ASN1_SEQUENCE_END_cb(stname, tname) ASN1_SEQUENCE_END_ref(stname, tname)\n# define static_ASN1_SEQUENCE_END_cb(stname, tname) static_ASN1_SEQUENCE_END_ref(stname, tname)\n\n# define ASN1_SEQUENCE_END_ref(stname, tname) \\\n        ;\\\n        ASN1_ITEM_start(tname) \\\n                ASN1_ITYPE_SEQUENCE,\\\n                V_ASN1_SEQUENCE,\\\n                tname##_seq_tt,\\\n                sizeof(tname##_seq_tt) / sizeof(ASN1_TEMPLATE),\\\n                &tname##_aux,\\\n                sizeof(stname),\\\n                #tname \\\n        ASN1_ITEM_end(tname)\n# define static_ASN1_SEQUENCE_END_ref(stname, tname) \\\n        ;\\\n        static_ASN1_ITEM_start(tname) \\\n                ASN1_ITYPE_SEQUENCE,\\\n                V_ASN1_SEQUENCE,\\\n                tname##_seq_tt,\\\n                sizeof(tname##_seq_tt) / sizeof(ASN1_TEMPLATE),\\\n                &tname##_aux,\\\n                sizeof(stname),\\\n                #stname \\\n        ASN1_ITEM_end(tname)\n\n# define ASN1_NDEF_SEQUENCE_END_cb(stname, tname) \\\n        ;\\\n        ASN1_ITEM_start(tname) \\\n                ASN1_ITYPE_NDEF_SEQUENCE,\\\n                V_ASN1_SEQUENCE,\\\n                tname##_seq_tt,\\\n                sizeof(tname##_seq_tt) / sizeof(ASN1_TEMPLATE),\\\n                &tname##_aux,\\\n                sizeof(stname),\\\n                #stname \\\n        ASN1_ITEM_end(tname)\n\n/*-\n * This pair helps declare a CHOICE type. We can do:\n *\n *      ASN1_CHOICE(chname) = {\n *              ... CHOICE options ...\n *      ASN1_CHOICE_END(chname)\n *\n *      This will produce an ASN1_ITEM called chname_it\n *      for a structure called chname. The structure\n *      definition must look like this:\n *      typedef struct {\n *              int type;\n *              union {\n *                      ASN1_SOMETHING *opt1;\n *                      ASN1_SOMEOTHER *opt2;\n *              } value;\n *      } chname;\n *\n *      the name of the selector must be 'type'.\n *      to use an alternative selector name use the\n *      ASN1_CHOICE_END_selector() version.\n */\n\n# define ASN1_CHOICE(tname) \\\n        static const ASN1_TEMPLATE tname##_ch_tt[]\n\n# define ASN1_CHOICE_cb(tname, cb) \\\n        static const ASN1_AUX tname##_aux = {NULL, 0, 0, 0, cb, 0}; \\\n        ASN1_CHOICE(tname)\n\n# define ASN1_CHOICE_END(stname) ASN1_CHOICE_END_name(stname, stname)\n\n# define static_ASN1_CHOICE_END(stname) static_ASN1_CHOICE_END_name(stname, stname)\n\n# define ASN1_CHOICE_END_name(stname, tname) ASN1_CHOICE_END_selector(stname, tname, type)\n\n# define static_ASN1_CHOICE_END_name(stname, tname) static_ASN1_CHOICE_END_selector(stname, tname, type)\n\n# define ASN1_CHOICE_END_selector(stname, tname, selname) \\\n        ;\\\n        ASN1_ITEM_start(tname) \\\n                ASN1_ITYPE_CHOICE,\\\n                offsetof(stname,selname) ,\\\n                tname##_ch_tt,\\\n                sizeof(tname##_ch_tt) / sizeof(ASN1_TEMPLATE),\\\n                NULL,\\\n                sizeof(stname),\\\n                #stname \\\n        ASN1_ITEM_end(tname)\n\n# define static_ASN1_CHOICE_END_selector(stname, tname, selname) \\\n        ;\\\n        static_ASN1_ITEM_start(tname) \\\n                ASN1_ITYPE_CHOICE,\\\n                offsetof(stname,selname) ,\\\n                tname##_ch_tt,\\\n                sizeof(tname##_ch_tt) / sizeof(ASN1_TEMPLATE),\\\n                NULL,\\\n                sizeof(stname),\\\n                #stname \\\n        ASN1_ITEM_end(tname)\n\n# define ASN1_CHOICE_END_cb(stname, tname, selname) \\\n        ;\\\n        ASN1_ITEM_start(tname) \\\n                ASN1_ITYPE_CHOICE,\\\n                offsetof(stname,selname) ,\\\n                tname##_ch_tt,\\\n                sizeof(tname##_ch_tt) / sizeof(ASN1_TEMPLATE),\\\n                &tname##_aux,\\\n                sizeof(stname),\\\n                #stname \\\n        ASN1_ITEM_end(tname)\n\n/* This helps with the template wrapper form of ASN1_ITEM */\n\n# define ASN1_EX_TEMPLATE_TYPE(flags, tag, name, type) { \\\n        (flags), (tag), 0,\\\n        #name, ASN1_ITEM_ref(type) }\n\n/* These help with SEQUENCE or CHOICE components */\n\n/* used to declare other types */\n\n# define ASN1_EX_TYPE(flags, tag, stname, field, type) { \\\n        (flags), (tag), offsetof(stname, field),\\\n        #field, ASN1_ITEM_ref(type) }\n\n/* implicit and explicit helper macros */\n\n# define ASN1_IMP_EX(stname, field, type, tag, ex) \\\n         ASN1_EX_TYPE(ASN1_TFLG_IMPLICIT | (ex), tag, stname, field, type)\n\n# define ASN1_EXP_EX(stname, field, type, tag, ex) \\\n         ASN1_EX_TYPE(ASN1_TFLG_EXPLICIT | (ex), tag, stname, field, type)\n\n/* Any defined by macros: the field used is in the table itself */\n\n# ifndef OPENSSL_EXPORT_VAR_AS_FUNCTION\n#  define ASN1_ADB_OBJECT(tblname) { ASN1_TFLG_ADB_OID, -1, 0, #tblname, (const ASN1_ITEM *)&(tblname##_adb) }\n#  define ASN1_ADB_INTEGER(tblname) { ASN1_TFLG_ADB_INT, -1, 0, #tblname, (const ASN1_ITEM *)&(tblname##_adb) }\n# else\n#  define ASN1_ADB_OBJECT(tblname) { ASN1_TFLG_ADB_OID, -1, 0, #tblname, tblname##_adb }\n#  define ASN1_ADB_INTEGER(tblname) { ASN1_TFLG_ADB_INT, -1, 0, #tblname, tblname##_adb }\n# endif\n/* Plain simple type */\n# define ASN1_SIMPLE(stname, field, type) ASN1_EX_TYPE(0,0, stname, field, type)\n/* Embedded simple type */\n# define ASN1_EMBED(stname, field, type) ASN1_EX_TYPE(ASN1_TFLG_EMBED,0, stname, field, type)\n\n/* OPTIONAL simple type */\n# define ASN1_OPT(stname, field, type) ASN1_EX_TYPE(ASN1_TFLG_OPTIONAL, 0, stname, field, type)\n# define ASN1_OPT_EMBED(stname, field, type) ASN1_EX_TYPE(ASN1_TFLG_OPTIONAL|ASN1_TFLG_EMBED, 0, stname, field, type)\n\n/* IMPLICIT tagged simple type */\n# define ASN1_IMP(stname, field, type, tag) ASN1_IMP_EX(stname, field, type, tag, 0)\n# define ASN1_IMP_EMBED(stname, field, type, tag) ASN1_IMP_EX(stname, field, type, tag, ASN1_TFLG_EMBED)\n\n/* IMPLICIT tagged OPTIONAL simple type */\n# define ASN1_IMP_OPT(stname, field, type, tag) ASN1_IMP_EX(stname, field, type, tag, ASN1_TFLG_OPTIONAL)\n# define ASN1_IMP_OPT_EMBED(stname, field, type, tag) ASN1_IMP_EX(stname, field, type, tag, ASN1_TFLG_OPTIONAL|ASN1_TFLG_EMBED)\n\n/* Same as above but EXPLICIT */\n\n# define ASN1_EXP(stname, field, type, tag) ASN1_EXP_EX(stname, field, type, tag, 0)\n# define ASN1_EXP_EMBED(stname, field, type, tag) ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_EMBED)\n# define ASN1_EXP_OPT(stname, field, type, tag) ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_OPTIONAL)\n# define ASN1_EXP_OPT_EMBED(stname, field, type, tag) ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_OPTIONAL|ASN1_TFLG_EMBED)\n\n/* SEQUENCE OF type */\n# define ASN1_SEQUENCE_OF(stname, field, type) \\\n                ASN1_EX_TYPE(ASN1_TFLG_SEQUENCE_OF, 0, stname, field, type)\n\n/* OPTIONAL SEQUENCE OF */\n# define ASN1_SEQUENCE_OF_OPT(stname, field, type) \\\n                ASN1_EX_TYPE(ASN1_TFLG_SEQUENCE_OF|ASN1_TFLG_OPTIONAL, 0, stname, field, type)\n\n/* Same as above but for SET OF */\n\n# define ASN1_SET_OF(stname, field, type) \\\n                ASN1_EX_TYPE(ASN1_TFLG_SET_OF, 0, stname, field, type)\n\n# define ASN1_SET_OF_OPT(stname, field, type) \\\n                ASN1_EX_TYPE(ASN1_TFLG_SET_OF|ASN1_TFLG_OPTIONAL, 0, stname, field, type)\n\n/* Finally compound types of SEQUENCE, SET, IMPLICIT, EXPLICIT and OPTIONAL */\n\n# define ASN1_IMP_SET_OF(stname, field, type, tag) \\\n                        ASN1_IMP_EX(stname, field, type, tag, ASN1_TFLG_SET_OF)\n\n# define ASN1_EXP_SET_OF(stname, field, type, tag) \\\n                        ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_SET_OF)\n\n# define ASN1_IMP_SET_OF_OPT(stname, field, type, tag) \\\n                        ASN1_IMP_EX(stname, field, type, tag, ASN1_TFLG_SET_OF|ASN1_TFLG_OPTIONAL)\n\n# define ASN1_EXP_SET_OF_OPT(stname, field, type, tag) \\\n                        ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_SET_OF|ASN1_TFLG_OPTIONAL)\n\n# define ASN1_IMP_SEQUENCE_OF(stname, field, type, tag) \\\n                        ASN1_IMP_EX(stname, field, type, tag, ASN1_TFLG_SEQUENCE_OF)\n\n# define ASN1_IMP_SEQUENCE_OF_OPT(stname, field, type, tag) \\\n                        ASN1_IMP_EX(stname, field, type, tag, ASN1_TFLG_SEQUENCE_OF|ASN1_TFLG_OPTIONAL)\n\n# define ASN1_EXP_SEQUENCE_OF(stname, field, type, tag) \\\n                        ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_SEQUENCE_OF)\n\n# define ASN1_EXP_SEQUENCE_OF_OPT(stname, field, type, tag) \\\n                        ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_SEQUENCE_OF|ASN1_TFLG_OPTIONAL)\n\n/* EXPLICIT using indefinite length constructed form */\n# define ASN1_NDEF_EXP(stname, field, type, tag) \\\n                        ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_NDEF)\n\n/* EXPLICIT OPTIONAL using indefinite length constructed form */\n# define ASN1_NDEF_EXP_OPT(stname, field, type, tag) \\\n                        ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_OPTIONAL|ASN1_TFLG_NDEF)\n\n/* Macros for the ASN1_ADB structure */\n\n# define ASN1_ADB(name) \\\n        static const ASN1_ADB_TABLE name##_adbtbl[]\n\n# ifndef OPENSSL_EXPORT_VAR_AS_FUNCTION\n\n#  define ASN1_ADB_END(name, flags, field, adb_cb, def, none) \\\n        ;\\\n        static const ASN1_ADB name##_adb = {\\\n                flags,\\\n                offsetof(name, field),\\\n                adb_cb,\\\n                name##_adbtbl,\\\n                sizeof(name##_adbtbl) / sizeof(ASN1_ADB_TABLE),\\\n                def,\\\n                none\\\n        }\n\n# else\n\n#  define ASN1_ADB_END(name, flags, field, adb_cb, def, none) \\\n        ;\\\n        static const ASN1_ITEM *name##_adb(void) \\\n        { \\\n        static const ASN1_ADB internal_adb = \\\n                {\\\n                flags,\\\n                offsetof(name, field),\\\n                adb_cb,\\\n                name##_adbtbl,\\\n                sizeof(name##_adbtbl) / sizeof(ASN1_ADB_TABLE),\\\n                def,\\\n                none\\\n                }; \\\n                return (const ASN1_ITEM *) &internal_adb; \\\n        } \\\n        void dummy_function(void)\n\n# endif\n\n# define ADB_ENTRY(val, template) {val, template}\n\n# define ASN1_ADB_TEMPLATE(name) \\\n        static const ASN1_TEMPLATE name##_tt\n\n/*\n * This is the ASN1 template structure that defines a wrapper round the\n * actual type. It determines the actual position of the field in the value\n * structure, various flags such as OPTIONAL and the field name.\n */\n\nstruct ASN1_TEMPLATE_st {\n    unsigned long flags;        /* Various flags */\n    long tag;                   /* tag, not used if no tagging */\n    unsigned long offset;       /* Offset of this field in structure */\n    const char *field_name;     /* Field name */\n    ASN1_ITEM_EXP *item;        /* Relevant ASN1_ITEM or ASN1_ADB */\n};\n\n/* Macro to extract ASN1_ITEM and ASN1_ADB pointer from ASN1_TEMPLATE */\n\n# define ASN1_TEMPLATE_item(t) (t->item_ptr)\n# define ASN1_TEMPLATE_adb(t) (t->item_ptr)\n\ntypedef struct ASN1_ADB_TABLE_st ASN1_ADB_TABLE;\ntypedef struct ASN1_ADB_st ASN1_ADB;\n\nstruct ASN1_ADB_st {\n    unsigned long flags;        /* Various flags */\n    unsigned long offset;       /* Offset of selector field */\n    int (*adb_cb)(long *psel);  /* Application callback */\n    const ASN1_ADB_TABLE *tbl;  /* Table of possible types */\n    long tblcount;              /* Number of entries in tbl */\n    const ASN1_TEMPLATE *default_tt; /* Type to use if no match */\n    const ASN1_TEMPLATE *null_tt; /* Type to use if selector is NULL */\n};\n\nstruct ASN1_ADB_TABLE_st {\n    long value;                 /* NID for an object or value for an int */\n    const ASN1_TEMPLATE tt;     /* item for this value */\n};\n\n/* template flags */\n\n/* Field is optional */\n# define ASN1_TFLG_OPTIONAL      (0x1)\n\n/* Field is a SET OF */\n# define ASN1_TFLG_SET_OF        (0x1 << 1)\n\n/* Field is a SEQUENCE OF */\n# define ASN1_TFLG_SEQUENCE_OF   (0x2 << 1)\n\n/*\n * Special case: this refers to a SET OF that will be sorted into DER order\n * when encoded *and* the corresponding STACK will be modified to match the\n * new order.\n */\n# define ASN1_TFLG_SET_ORDER     (0x3 << 1)\n\n/* Mask for SET OF or SEQUENCE OF */\n# define ASN1_TFLG_SK_MASK       (0x3 << 1)\n\n/*\n * These flags mean the tag should be taken from the tag field. If EXPLICIT\n * then the underlying type is used for the inner tag.\n */\n\n/* IMPLICIT tagging */\n# define ASN1_TFLG_IMPTAG        (0x1 << 3)\n\n/* EXPLICIT tagging, inner tag from underlying type */\n# define ASN1_TFLG_EXPTAG        (0x2 << 3)\n\n# define ASN1_TFLG_TAG_MASK      (0x3 << 3)\n\n/* context specific IMPLICIT */\n# define ASN1_TFLG_IMPLICIT      (ASN1_TFLG_IMPTAG|ASN1_TFLG_CONTEXT)\n\n/* context specific EXPLICIT */\n# define ASN1_TFLG_EXPLICIT      (ASN1_TFLG_EXPTAG|ASN1_TFLG_CONTEXT)\n\n/*\n * If tagging is in force these determine the type of tag to use. Otherwise\n * the tag is determined by the underlying type. These values reflect the\n * actual octet format.\n */\n\n/* Universal tag */\n# define ASN1_TFLG_UNIVERSAL     (0x0<<6)\n/* Application tag */\n# define ASN1_TFLG_APPLICATION   (0x1<<6)\n/* Context specific tag */\n# define ASN1_TFLG_CONTEXT       (0x2<<6)\n/* Private tag */\n# define ASN1_TFLG_PRIVATE       (0x3<<6)\n\n# define ASN1_TFLG_TAG_CLASS     (0x3<<6)\n\n/*\n * These are for ANY DEFINED BY type. In this case the 'item' field points to\n * an ASN1_ADB structure which contains a table of values to decode the\n * relevant type\n */\n\n# define ASN1_TFLG_ADB_MASK      (0x3<<8)\n\n# define ASN1_TFLG_ADB_OID       (0x1<<8)\n\n# define ASN1_TFLG_ADB_INT       (0x1<<9)\n\n/*\n * This flag when present in a SEQUENCE OF, SET OF or EXPLICIT causes\n * indefinite length constructed encoding to be used if required.\n */\n\n# define ASN1_TFLG_NDEF          (0x1<<11)\n\n/* Field is embedded and not a pointer */\n# define ASN1_TFLG_EMBED         (0x1 << 12)\n\n/* This is the actual ASN1 item itself */\n\nstruct ASN1_ITEM_st {\n    char itype;                 /* The item type, primitive, SEQUENCE, CHOICE\n                                 * or extern */\n    long utype;                 /* underlying type */\n    const ASN1_TEMPLATE *templates; /* If SEQUENCE or CHOICE this contains\n                                     * the contents */\n    long tcount;                /* Number of templates if SEQUENCE or CHOICE */\n    const void *funcs;          /* functions that handle this type */\n    long size;                  /* Structure size (usually) */\n    const char *sname;          /* Structure name */\n};\n\n/*-\n * These are values for the itype field and\n * determine how the type is interpreted.\n *\n * For PRIMITIVE types the underlying type\n * determines the behaviour if items is NULL.\n *\n * Otherwise templates must contain a single\n * template and the type is treated in the\n * same way as the type specified in the template.\n *\n * For SEQUENCE types the templates field points\n * to the members, the size field is the\n * structure size.\n *\n * For CHOICE types the templates field points\n * to each possible member (typically a union)\n * and the 'size' field is the offset of the\n * selector.\n *\n * The 'funcs' field is used for application\n * specific functions.\n *\n * The EXTERN type uses a new style d2i/i2d.\n * The new style should be used where possible\n * because it avoids things like the d2i IMPLICIT\n * hack.\n *\n * MSTRING is a multiple string type, it is used\n * for a CHOICE of character strings where the\n * actual strings all occupy an ASN1_STRING\n * structure. In this case the 'utype' field\n * has a special meaning, it is used as a mask\n * of acceptable types using the B_ASN1 constants.\n *\n * NDEF_SEQUENCE is the same as SEQUENCE except\n * that it will use indefinite length constructed\n * encoding if requested.\n *\n */\n\n# define ASN1_ITYPE_PRIMITIVE            0x0\n\n# define ASN1_ITYPE_SEQUENCE             0x1\n\n# define ASN1_ITYPE_CHOICE               0x2\n\n# define ASN1_ITYPE_EXTERN               0x4\n\n# define ASN1_ITYPE_MSTRING              0x5\n\n# define ASN1_ITYPE_NDEF_SEQUENCE        0x6\n\n/*\n * Cache for ASN1 tag and length, so we don't keep re-reading it for things\n * like CHOICE\n */\n\nstruct ASN1_TLC_st {\n    char valid;                 /* Values below are valid */\n    int ret;                    /* return value */\n    long plen;                  /* length */\n    int ptag;                   /* class value */\n    int pclass;                 /* class value */\n    int hdrlen;                 /* header length */\n};\n\n/* Typedefs for ASN1 function pointers */\ntypedef int ASN1_ex_d2i(ASN1_VALUE **pval, const unsigned char **in, long len,\n                        const ASN1_ITEM *it, int tag, int aclass, char opt,\n                        ASN1_TLC *ctx);\n\ntypedef int ASN1_ex_i2d(ASN1_VALUE **pval, unsigned char **out,\n                        const ASN1_ITEM *it, int tag, int aclass);\ntypedef int ASN1_ex_new_func(ASN1_VALUE **pval, const ASN1_ITEM *it);\ntypedef void ASN1_ex_free_func(ASN1_VALUE **pval, const ASN1_ITEM *it);\n\ntypedef int ASN1_ex_print_func(BIO *out, ASN1_VALUE **pval,\n                               int indent, const char *fname,\n                               const ASN1_PCTX *pctx);\n\ntypedef int ASN1_primitive_i2c(ASN1_VALUE **pval, unsigned char *cont,\n                               int *putype, const ASN1_ITEM *it);\ntypedef int ASN1_primitive_c2i(ASN1_VALUE **pval, const unsigned char *cont,\n                               int len, int utype, char *free_cont,\n                               const ASN1_ITEM *it);\ntypedef int ASN1_primitive_print(BIO *out, ASN1_VALUE **pval,\n                                 const ASN1_ITEM *it, int indent,\n                                 const ASN1_PCTX *pctx);\n\ntypedef struct ASN1_EXTERN_FUNCS_st {\n    void *app_data;\n    ASN1_ex_new_func *asn1_ex_new;\n    ASN1_ex_free_func *asn1_ex_free;\n    ASN1_ex_free_func *asn1_ex_clear;\n    ASN1_ex_d2i *asn1_ex_d2i;\n    ASN1_ex_i2d *asn1_ex_i2d;\n    ASN1_ex_print_func *asn1_ex_print;\n} ASN1_EXTERN_FUNCS;\n\ntypedef struct ASN1_PRIMITIVE_FUNCS_st {\n    void *app_data;\n    unsigned long flags;\n    ASN1_ex_new_func *prim_new;\n    ASN1_ex_free_func *prim_free;\n    ASN1_ex_free_func *prim_clear;\n    ASN1_primitive_c2i *prim_c2i;\n    ASN1_primitive_i2c *prim_i2c;\n    ASN1_primitive_print *prim_print;\n} ASN1_PRIMITIVE_FUNCS;\n\n/*\n * This is the ASN1_AUX structure: it handles various miscellaneous\n * requirements. For example the use of reference counts and an informational\n * callback. The \"informational callback\" is called at various points during\n * the ASN1 encoding and decoding. It can be used to provide minor\n * customisation of the structures used. This is most useful where the\n * supplied routines *almost* do the right thing but need some extra help at\n * a few points. If the callback returns zero then it is assumed a fatal\n * error has occurred and the main operation should be abandoned. If major\n * changes in the default behaviour are required then an external type is\n * more appropriate.\n */\n\ntypedef int ASN1_aux_cb(int operation, ASN1_VALUE **in, const ASN1_ITEM *it,\n                        void *exarg);\n\ntypedef struct ASN1_AUX_st {\n    void *app_data;\n    int flags;\n    int ref_offset;             /* Offset of reference value */\n    int ref_lock;               /* Lock type to use */\n    ASN1_aux_cb *asn1_cb;\n    int enc_offset;             /* Offset of ASN1_ENCODING structure */\n} ASN1_AUX;\n\n/* For print related callbacks exarg points to this structure */\ntypedef struct ASN1_PRINT_ARG_st {\n    BIO *out;\n    int indent;\n    const ASN1_PCTX *pctx;\n} ASN1_PRINT_ARG;\n\n/* For streaming related callbacks exarg points to this structure */\ntypedef struct ASN1_STREAM_ARG_st {\n    /* BIO to stream through */\n    BIO *out;\n    /* BIO with filters appended */\n    BIO *ndef_bio;\n    /* Streaming I/O boundary */\n    unsigned char **boundary;\n} ASN1_STREAM_ARG;\n\n/* Flags in ASN1_AUX */\n\n/* Use a reference count */\n# define ASN1_AFLG_REFCOUNT      1\n/* Save the encoding of structure (useful for signatures) */\n# define ASN1_AFLG_ENCODING      2\n/* The Sequence length is invalid */\n# define ASN1_AFLG_BROKEN        4\n\n/* operation values for asn1_cb */\n\n# define ASN1_OP_NEW_PRE         0\n# define ASN1_OP_NEW_POST        1\n# define ASN1_OP_FREE_PRE        2\n# define ASN1_OP_FREE_POST       3\n# define ASN1_OP_D2I_PRE         4\n# define ASN1_OP_D2I_POST        5\n# define ASN1_OP_I2D_PRE         6\n# define ASN1_OP_I2D_POST        7\n# define ASN1_OP_PRINT_PRE       8\n# define ASN1_OP_PRINT_POST      9\n# define ASN1_OP_STREAM_PRE      10\n# define ASN1_OP_STREAM_POST     11\n# define ASN1_OP_DETACHED_PRE    12\n# define ASN1_OP_DETACHED_POST   13\n\n/* Macro to implement a primitive type */\n# define IMPLEMENT_ASN1_TYPE(stname) IMPLEMENT_ASN1_TYPE_ex(stname, stname, 0)\n# define IMPLEMENT_ASN1_TYPE_ex(itname, vname, ex) \\\n                                ASN1_ITEM_start(itname) \\\n                                        ASN1_ITYPE_PRIMITIVE, V_##vname, NULL, 0, NULL, ex, #itname \\\n                                ASN1_ITEM_end(itname)\n\n/* Macro to implement a multi string type */\n# define IMPLEMENT_ASN1_MSTRING(itname, mask) \\\n                                ASN1_ITEM_start(itname) \\\n                                        ASN1_ITYPE_MSTRING, mask, NULL, 0, NULL, sizeof(ASN1_STRING), #itname \\\n                                ASN1_ITEM_end(itname)\n\n# define IMPLEMENT_EXTERN_ASN1(sname, tag, fptrs) \\\n        ASN1_ITEM_start(sname) \\\n                ASN1_ITYPE_EXTERN, \\\n                tag, \\\n                NULL, \\\n                0, \\\n                &fptrs, \\\n                0, \\\n                #sname \\\n        ASN1_ITEM_end(sname)\n\n/* Macro to implement standard functions in terms of ASN1_ITEM structures */\n\n# define IMPLEMENT_ASN1_FUNCTIONS(stname) IMPLEMENT_ASN1_FUNCTIONS_fname(stname, stname, stname)\n\n# define IMPLEMENT_ASN1_FUNCTIONS_name(stname, itname) IMPLEMENT_ASN1_FUNCTIONS_fname(stname, itname, itname)\n\n# define IMPLEMENT_ASN1_FUNCTIONS_ENCODE_name(stname, itname) \\\n                        IMPLEMENT_ASN1_FUNCTIONS_ENCODE_fname(stname, itname, itname)\n\n# define IMPLEMENT_STATIC_ASN1_ALLOC_FUNCTIONS(stname) \\\n                IMPLEMENT_ASN1_ALLOC_FUNCTIONS_pfname(static, stname, stname, stname)\n\n# define IMPLEMENT_ASN1_ALLOC_FUNCTIONS(stname) \\\n                IMPLEMENT_ASN1_ALLOC_FUNCTIONS_fname(stname, stname, stname)\n\n# define IMPLEMENT_ASN1_ALLOC_FUNCTIONS_pfname(pre, stname, itname, fname) \\\n        pre stname *fname##_new(void) \\\n        { \\\n                return (stname *)ASN1_item_new(ASN1_ITEM_rptr(itname)); \\\n        } \\\n        pre void fname##_free(stname *a) \\\n        { \\\n                ASN1_item_free((ASN1_VALUE *)a, ASN1_ITEM_rptr(itname)); \\\n        }\n\n# define IMPLEMENT_ASN1_ALLOC_FUNCTIONS_fname(stname, itname, fname) \\\n        stname *fname##_new(void) \\\n        { \\\n                return (stname *)ASN1_item_new(ASN1_ITEM_rptr(itname)); \\\n        } \\\n        void fname##_free(stname *a) \\\n        { \\\n                ASN1_item_free((ASN1_VALUE *)a, ASN1_ITEM_rptr(itname)); \\\n        }\n\n# define IMPLEMENT_ASN1_FUNCTIONS_fname(stname, itname, fname) \\\n        IMPLEMENT_ASN1_ENCODE_FUNCTIONS_fname(stname, itname, fname) \\\n        IMPLEMENT_ASN1_ALLOC_FUNCTIONS_fname(stname, itname, fname)\n\n# define IMPLEMENT_ASN1_ENCODE_FUNCTIONS_fname(stname, itname, fname) \\\n        stname *d2i_##fname(stname **a, const unsigned char **in, long len) \\\n        { \\\n                return (stname *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, ASN1_ITEM_rptr(itname));\\\n        } \\\n        int i2d_##fname(stname *a, unsigned char **out) \\\n        { \\\n                return ASN1_item_i2d((ASN1_VALUE *)a, out, ASN1_ITEM_rptr(itname));\\\n        }\n\n# define IMPLEMENT_ASN1_NDEF_FUNCTION(stname) \\\n        int i2d_##stname##_NDEF(stname *a, unsigned char **out) \\\n        { \\\n                return ASN1_item_ndef_i2d((ASN1_VALUE *)a, out, ASN1_ITEM_rptr(stname));\\\n        }\n\n# define IMPLEMENT_STATIC_ASN1_ENCODE_FUNCTIONS(stname) \\\n        static stname *d2i_##stname(stname **a, \\\n                                   const unsigned char **in, long len) \\\n        { \\\n                return (stname *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, \\\n                                               ASN1_ITEM_rptr(stname)); \\\n        } \\\n        static int i2d_##stname(stname *a, unsigned char **out) \\\n        { \\\n                return ASN1_item_i2d((ASN1_VALUE *)a, out, \\\n                                     ASN1_ITEM_rptr(stname)); \\\n        }\n\n/*\n * This includes evil casts to remove const: they will go away when full ASN1\n * constification is done.\n */\n# define IMPLEMENT_ASN1_ENCODE_FUNCTIONS_const_fname(stname, itname, fname) \\\n        stname *d2i_##fname(stname **a, const unsigned char **in, long len) \\\n        { \\\n                return (stname *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, ASN1_ITEM_rptr(itname));\\\n        } \\\n        int i2d_##fname(const stname *a, unsigned char **out) \\\n        { \\\n                return ASN1_item_i2d((ASN1_VALUE *)a, out, ASN1_ITEM_rptr(itname));\\\n        }\n\n# define IMPLEMENT_ASN1_DUP_FUNCTION(stname) \\\n        stname * stname##_dup(stname *x) \\\n        { \\\n        return ASN1_item_dup(ASN1_ITEM_rptr(stname), x); \\\n        }\n\n# define IMPLEMENT_ASN1_PRINT_FUNCTION(stname) \\\n        IMPLEMENT_ASN1_PRINT_FUNCTION_fname(stname, stname, stname)\n\n# define IMPLEMENT_ASN1_PRINT_FUNCTION_fname(stname, itname, fname) \\\n        int fname##_print_ctx(BIO *out, stname *x, int indent, \\\n                                                const ASN1_PCTX *pctx) \\\n        { \\\n                return ASN1_item_print(out, (ASN1_VALUE *)x, indent, \\\n                        ASN1_ITEM_rptr(itname), pctx); \\\n        }\n\n# define IMPLEMENT_ASN1_FUNCTIONS_const(name) \\\n                IMPLEMENT_ASN1_FUNCTIONS_const_fname(name, name, name)\n\n# define IMPLEMENT_ASN1_FUNCTIONS_const_fname(stname, itname, fname) \\\n        IMPLEMENT_ASN1_ENCODE_FUNCTIONS_const_fname(stname, itname, fname) \\\n        IMPLEMENT_ASN1_ALLOC_FUNCTIONS_fname(stname, itname, fname)\n\n/* external definitions for primitive types */\n\nDECLARE_ASN1_ITEM(ASN1_BOOLEAN)\nDECLARE_ASN1_ITEM(ASN1_TBOOLEAN)\nDECLARE_ASN1_ITEM(ASN1_FBOOLEAN)\nDECLARE_ASN1_ITEM(ASN1_SEQUENCE)\nDECLARE_ASN1_ITEM(CBIGNUM)\nDECLARE_ASN1_ITEM(BIGNUM)\nDECLARE_ASN1_ITEM(INT32)\nDECLARE_ASN1_ITEM(ZINT32)\nDECLARE_ASN1_ITEM(UINT32)\nDECLARE_ASN1_ITEM(ZUINT32)\nDECLARE_ASN1_ITEM(INT64)\nDECLARE_ASN1_ITEM(ZINT64)\nDECLARE_ASN1_ITEM(UINT64)\nDECLARE_ASN1_ITEM(ZUINT64)\n\n# if OPENSSL_API_COMPAT < 0x10200000L\n/*\n * LONG and ZLONG are strongly discouraged for use as stored data, as the\n * underlying C type (long) differs in size depending on the architecture.\n * They are designed with 32-bit longs in mind.\n */\nDECLARE_ASN1_ITEM(LONG)\nDECLARE_ASN1_ITEM(ZLONG)\n# endif\n\nDEFINE_STACK_OF(ASN1_VALUE)\n\n/* Functions used internally by the ASN1 code */\n\nint ASN1_item_ex_new(ASN1_VALUE **pval, const ASN1_ITEM *it);\nvoid ASN1_item_ex_free(ASN1_VALUE **pval, const ASN1_ITEM *it);\n\nint ASN1_item_ex_d2i(ASN1_VALUE **pval, const unsigned char **in, long len,\n                     const ASN1_ITEM *it, int tag, int aclass, char opt,\n                     ASN1_TLC *ctx);\n\nint ASN1_item_ex_i2d(ASN1_VALUE **pval, unsigned char **out,\n                     const ASN1_ITEM *it, int tag, int aclass);\n\n#ifdef  __cplusplus\n}\n#endif\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/include/openssl/async.h",
    "content": "/*\n * Copyright 2015-2018 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#include <stdlib.h>\n\n#ifndef HEADER_ASYNC_H\n# define HEADER_ASYNC_H\n\n#if defined(_WIN32)\n# if defined(BASETYPES) || defined(_WINDEF_H)\n/* application has to include <windows.h> to use this */\n#define OSSL_ASYNC_FD       HANDLE\n#define OSSL_BAD_ASYNC_FD   INVALID_HANDLE_VALUE\n# endif\n#else\n#define OSSL_ASYNC_FD       int\n#define OSSL_BAD_ASYNC_FD   -1\n#endif\n# include <openssl/asyncerr.h>\n\n\n# ifdef  __cplusplus\nextern \"C\" {\n# endif\n\ntypedef struct async_job_st ASYNC_JOB;\ntypedef struct async_wait_ctx_st ASYNC_WAIT_CTX;\n\n#define ASYNC_ERR      0\n#define ASYNC_NO_JOBS  1\n#define ASYNC_PAUSE    2\n#define ASYNC_FINISH   3\n\nint ASYNC_init_thread(size_t max_size, size_t init_size);\nvoid ASYNC_cleanup_thread(void);\n\n#ifdef OSSL_ASYNC_FD\nASYNC_WAIT_CTX *ASYNC_WAIT_CTX_new(void);\nvoid ASYNC_WAIT_CTX_free(ASYNC_WAIT_CTX *ctx);\nint ASYNC_WAIT_CTX_set_wait_fd(ASYNC_WAIT_CTX *ctx, const void *key,\n                               OSSL_ASYNC_FD fd,\n                               void *custom_data,\n                               void (*cleanup)(ASYNC_WAIT_CTX *, const void *,\n                                               OSSL_ASYNC_FD, void *));\nint ASYNC_WAIT_CTX_get_fd(ASYNC_WAIT_CTX *ctx, const void *key,\n                        OSSL_ASYNC_FD *fd, void **custom_data);\nint ASYNC_WAIT_CTX_get_all_fds(ASYNC_WAIT_CTX *ctx, OSSL_ASYNC_FD *fd,\n                               size_t *numfds);\nint ASYNC_WAIT_CTX_get_changed_fds(ASYNC_WAIT_CTX *ctx, OSSL_ASYNC_FD *addfd,\n                                   size_t *numaddfds, OSSL_ASYNC_FD *delfd,\n                                   size_t *numdelfds);\nint ASYNC_WAIT_CTX_clear_fd(ASYNC_WAIT_CTX *ctx, const void *key);\n#endif\n\nint ASYNC_is_capable(void);\n\nint ASYNC_start_job(ASYNC_JOB **job, ASYNC_WAIT_CTX *ctx, int *ret,\n                    int (*func)(void *), void *args, size_t size);\nint ASYNC_pause_job(void);\n\nASYNC_JOB *ASYNC_get_current_job(void);\nASYNC_WAIT_CTX *ASYNC_get_wait_ctx(ASYNC_JOB *job);\nvoid ASYNC_block_pause(void);\nvoid ASYNC_unblock_pause(void);\n\n\n# ifdef  __cplusplus\n}\n# endif\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/include/openssl/asyncerr.h",
    "content": "/*\n * Generated by util/mkerr.pl DO NOT EDIT\n * Copyright 1995-2019 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef HEADER_ASYNCERR_H\n# define HEADER_ASYNCERR_H\n\n# ifndef HEADER_SYMHACKS_H\n#  include <openssl/symhacks.h>\n# endif\n\n# ifdef  __cplusplus\nextern \"C\"\n# endif\nint ERR_load_ASYNC_strings(void);\n\n/*\n * ASYNC function codes.\n */\n# define ASYNC_F_ASYNC_CTX_NEW                            100\n# define ASYNC_F_ASYNC_INIT_THREAD                        101\n# define ASYNC_F_ASYNC_JOB_NEW                            102\n# define ASYNC_F_ASYNC_PAUSE_JOB                          103\n# define ASYNC_F_ASYNC_START_FUNC                         104\n# define ASYNC_F_ASYNC_START_JOB                          105\n# define ASYNC_F_ASYNC_WAIT_CTX_SET_WAIT_FD               106\n\n/*\n * ASYNC reason codes.\n */\n# define ASYNC_R_FAILED_TO_SET_POOL                       101\n# define ASYNC_R_FAILED_TO_SWAP_CONTEXT                   102\n# define ASYNC_R_INIT_FAILED                              105\n# define ASYNC_R_INVALID_POOL_SIZE                        103\n\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/include/openssl/bio.h",
    "content": "/*\n * Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef HEADER_BIO_H\n# define HEADER_BIO_H\n\n# include <openssl/e_os2.h>\n\n# ifndef OPENSSL_NO_STDIO\n#  include <stdio.h>\n# endif\n# include <stdarg.h>\n\n# include <openssl/crypto.h>\n# include <openssl/bioerr.h>\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n/* There are the classes of BIOs */\n# define BIO_TYPE_DESCRIPTOR     0x0100 /* socket, fd, connect or accept */\n# define BIO_TYPE_FILTER         0x0200\n# define BIO_TYPE_SOURCE_SINK    0x0400\n\n/* These are the 'types' of BIOs */\n# define BIO_TYPE_NONE             0\n# define BIO_TYPE_MEM            ( 1|BIO_TYPE_SOURCE_SINK)\n# define BIO_TYPE_FILE           ( 2|BIO_TYPE_SOURCE_SINK)\n\n# define BIO_TYPE_FD             ( 4|BIO_TYPE_SOURCE_SINK|BIO_TYPE_DESCRIPTOR)\n# define BIO_TYPE_SOCKET         ( 5|BIO_TYPE_SOURCE_SINK|BIO_TYPE_DESCRIPTOR)\n# define BIO_TYPE_NULL           ( 6|BIO_TYPE_SOURCE_SINK)\n# define BIO_TYPE_SSL            ( 7|BIO_TYPE_FILTER)\n# define BIO_TYPE_MD             ( 8|BIO_TYPE_FILTER)\n# define BIO_TYPE_BUFFER         ( 9|BIO_TYPE_FILTER)\n# define BIO_TYPE_CIPHER         (10|BIO_TYPE_FILTER)\n# define BIO_TYPE_BASE64         (11|BIO_TYPE_FILTER)\n# define BIO_TYPE_CONNECT        (12|BIO_TYPE_SOURCE_SINK|BIO_TYPE_DESCRIPTOR)\n# define BIO_TYPE_ACCEPT         (13|BIO_TYPE_SOURCE_SINK|BIO_TYPE_DESCRIPTOR)\n\n# define BIO_TYPE_NBIO_TEST      (16|BIO_TYPE_FILTER)/* server proxy BIO */\n# define BIO_TYPE_NULL_FILTER    (17|BIO_TYPE_FILTER)\n# define BIO_TYPE_BIO            (19|BIO_TYPE_SOURCE_SINK)/* half a BIO pair */\n# define BIO_TYPE_LINEBUFFER     (20|BIO_TYPE_FILTER)\n# define BIO_TYPE_DGRAM          (21|BIO_TYPE_SOURCE_SINK|BIO_TYPE_DESCRIPTOR)\n# define BIO_TYPE_ASN1           (22|BIO_TYPE_FILTER)\n# define BIO_TYPE_COMP           (23|BIO_TYPE_FILTER)\n# ifndef OPENSSL_NO_SCTP\n#  define BIO_TYPE_DGRAM_SCTP    (24|BIO_TYPE_SOURCE_SINK|BIO_TYPE_DESCRIPTOR)\n# endif\n\n#define BIO_TYPE_START           128\n\n/*\n * BIO_FILENAME_READ|BIO_CLOSE to open or close on free.\n * BIO_set_fp(in,stdin,BIO_NOCLOSE);\n */\n# define BIO_NOCLOSE             0x00\n# define BIO_CLOSE               0x01\n\n/*\n * These are used in the following macros and are passed to BIO_ctrl()\n */\n# define BIO_CTRL_RESET          1/* opt - rewind/zero etc */\n# define BIO_CTRL_EOF            2/* opt - are we at the eof */\n# define BIO_CTRL_INFO           3/* opt - extra tit-bits */\n# define BIO_CTRL_SET            4/* man - set the 'IO' type */\n# define BIO_CTRL_GET            5/* man - get the 'IO' type */\n# define BIO_CTRL_PUSH           6/* opt - internal, used to signify change */\n# define BIO_CTRL_POP            7/* opt - internal, used to signify change */\n# define BIO_CTRL_GET_CLOSE      8/* man - set the 'close' on free */\n# define BIO_CTRL_SET_CLOSE      9/* man - set the 'close' on free */\n# define BIO_CTRL_PENDING        10/* opt - is their more data buffered */\n# define BIO_CTRL_FLUSH          11/* opt - 'flush' buffered output */\n# define BIO_CTRL_DUP            12/* man - extra stuff for 'duped' BIO */\n# define BIO_CTRL_WPENDING       13/* opt - number of bytes still to write */\n# define BIO_CTRL_SET_CALLBACK   14/* opt - set callback function */\n# define BIO_CTRL_GET_CALLBACK   15/* opt - set callback function */\n\n# define BIO_CTRL_PEEK           29/* BIO_f_buffer special */\n# define BIO_CTRL_SET_FILENAME   30/* BIO_s_file special */\n\n/* dgram BIO stuff */\n# define BIO_CTRL_DGRAM_CONNECT       31/* BIO dgram special */\n# define BIO_CTRL_DGRAM_SET_CONNECTED 32/* allow for an externally connected\n                                         * socket to be passed in */\n# define BIO_CTRL_DGRAM_SET_RECV_TIMEOUT 33/* setsockopt, essentially */\n# define BIO_CTRL_DGRAM_GET_RECV_TIMEOUT 34/* getsockopt, essentially */\n# define BIO_CTRL_DGRAM_SET_SEND_TIMEOUT 35/* setsockopt, essentially */\n# define BIO_CTRL_DGRAM_GET_SEND_TIMEOUT 36/* getsockopt, essentially */\n\n# define BIO_CTRL_DGRAM_GET_RECV_TIMER_EXP 37/* flag whether the last */\n# define BIO_CTRL_DGRAM_GET_SEND_TIMER_EXP 38/* I/O operation tiemd out */\n\n/* #ifdef IP_MTU_DISCOVER */\n# define BIO_CTRL_DGRAM_MTU_DISCOVER       39/* set DF bit on egress packets */\n/* #endif */\n\n# define BIO_CTRL_DGRAM_QUERY_MTU          40/* as kernel for current MTU */\n# define BIO_CTRL_DGRAM_GET_FALLBACK_MTU   47\n# define BIO_CTRL_DGRAM_GET_MTU            41/* get cached value for MTU */\n# define BIO_CTRL_DGRAM_SET_MTU            42/* set cached value for MTU.\n                                              * want to use this if asking\n                                              * the kernel fails */\n\n# define BIO_CTRL_DGRAM_MTU_EXCEEDED       43/* check whether the MTU was\n                                              * exceed in the previous write\n                                              * operation */\n\n# define BIO_CTRL_DGRAM_GET_PEER           46\n# define BIO_CTRL_DGRAM_SET_PEER           44/* Destination for the data */\n\n# define BIO_CTRL_DGRAM_SET_NEXT_TIMEOUT   45/* Next DTLS handshake timeout\n                                              * to adjust socket timeouts */\n# define BIO_CTRL_DGRAM_SET_DONT_FRAG      48\n\n# define BIO_CTRL_DGRAM_GET_MTU_OVERHEAD   49\n\n/* Deliberately outside of OPENSSL_NO_SCTP - used in bss_dgram.c */\n#  define BIO_CTRL_DGRAM_SCTP_SET_IN_HANDSHAKE    50\n# ifndef OPENSSL_NO_SCTP\n/* SCTP stuff */\n#  define BIO_CTRL_DGRAM_SCTP_ADD_AUTH_KEY                51\n#  define BIO_CTRL_DGRAM_SCTP_NEXT_AUTH_KEY               52\n#  define BIO_CTRL_DGRAM_SCTP_AUTH_CCS_RCVD               53\n#  define BIO_CTRL_DGRAM_SCTP_GET_SNDINFO         60\n#  define BIO_CTRL_DGRAM_SCTP_SET_SNDINFO         61\n#  define BIO_CTRL_DGRAM_SCTP_GET_RCVINFO         62\n#  define BIO_CTRL_DGRAM_SCTP_SET_RCVINFO         63\n#  define BIO_CTRL_DGRAM_SCTP_GET_PRINFO                  64\n#  define BIO_CTRL_DGRAM_SCTP_SET_PRINFO                  65\n#  define BIO_CTRL_DGRAM_SCTP_SAVE_SHUTDOWN               70\n# endif\n\n# define BIO_CTRL_DGRAM_SET_PEEK_MODE      71\n\n/* modifiers */\n# define BIO_FP_READ             0x02\n# define BIO_FP_WRITE            0x04\n# define BIO_FP_APPEND           0x08\n# define BIO_FP_TEXT             0x10\n\n# define BIO_FLAGS_READ          0x01\n# define BIO_FLAGS_WRITE         0x02\n# define BIO_FLAGS_IO_SPECIAL    0x04\n# define BIO_FLAGS_RWS (BIO_FLAGS_READ|BIO_FLAGS_WRITE|BIO_FLAGS_IO_SPECIAL)\n# define BIO_FLAGS_SHOULD_RETRY  0x08\n# ifndef BIO_FLAGS_UPLINK\n/*\n * \"UPLINK\" flag denotes file descriptors provided by application. It\n * defaults to 0, as most platforms don't require UPLINK interface.\n */\n#  define BIO_FLAGS_UPLINK        0\n# endif\n\n# define BIO_FLAGS_BASE64_NO_NL  0x100\n\n/*\n * This is used with memory BIOs:\n * BIO_FLAGS_MEM_RDONLY means we shouldn't free up or change the data in any way;\n * BIO_FLAGS_NONCLEAR_RST means we shouldn't clear data on reset.\n */\n# define BIO_FLAGS_MEM_RDONLY    0x200\n# define BIO_FLAGS_NONCLEAR_RST  0x400\n# define BIO_FLAGS_IN_EOF        0x800\n\ntypedef union bio_addr_st BIO_ADDR;\ntypedef struct bio_addrinfo_st BIO_ADDRINFO;\n\nint BIO_get_new_index(void);\nvoid BIO_set_flags(BIO *b, int flags);\nint BIO_test_flags(const BIO *b, int flags);\nvoid BIO_clear_flags(BIO *b, int flags);\n\n# define BIO_get_flags(b) BIO_test_flags(b, ~(0x0))\n# define BIO_set_retry_special(b) \\\n                BIO_set_flags(b, (BIO_FLAGS_IO_SPECIAL|BIO_FLAGS_SHOULD_RETRY))\n# define BIO_set_retry_read(b) \\\n                BIO_set_flags(b, (BIO_FLAGS_READ|BIO_FLAGS_SHOULD_RETRY))\n# define BIO_set_retry_write(b) \\\n                BIO_set_flags(b, (BIO_FLAGS_WRITE|BIO_FLAGS_SHOULD_RETRY))\n\n/* These are normally used internally in BIOs */\n# define BIO_clear_retry_flags(b) \\\n                BIO_clear_flags(b, (BIO_FLAGS_RWS|BIO_FLAGS_SHOULD_RETRY))\n# define BIO_get_retry_flags(b) \\\n                BIO_test_flags(b, (BIO_FLAGS_RWS|BIO_FLAGS_SHOULD_RETRY))\n\n/* These should be used by the application to tell why we should retry */\n# define BIO_should_read(a)              BIO_test_flags(a, BIO_FLAGS_READ)\n# define BIO_should_write(a)             BIO_test_flags(a, BIO_FLAGS_WRITE)\n# define BIO_should_io_special(a)        BIO_test_flags(a, BIO_FLAGS_IO_SPECIAL)\n# define BIO_retry_type(a)               BIO_test_flags(a, BIO_FLAGS_RWS)\n# define BIO_should_retry(a)             BIO_test_flags(a, BIO_FLAGS_SHOULD_RETRY)\n\n/*\n * The next three are used in conjunction with the BIO_should_io_special()\n * condition.  After this returns true, BIO *BIO_get_retry_BIO(BIO *bio, int\n * *reason); will walk the BIO stack and return the 'reason' for the special\n * and the offending BIO. Given a BIO, BIO_get_retry_reason(bio) will return\n * the code.\n */\n/*\n * Returned from the SSL bio when the certificate retrieval code had an error\n */\n# define BIO_RR_SSL_X509_LOOKUP          0x01\n/* Returned from the connect BIO when a connect would have blocked */\n# define BIO_RR_CONNECT                  0x02\n/* Returned from the accept BIO when an accept would have blocked */\n# define BIO_RR_ACCEPT                   0x03\n\n/* These are passed by the BIO callback */\n# define BIO_CB_FREE     0x01\n# define BIO_CB_READ     0x02\n# define BIO_CB_WRITE    0x03\n# define BIO_CB_PUTS     0x04\n# define BIO_CB_GETS     0x05\n# define BIO_CB_CTRL     0x06\n\n/*\n * The callback is called before and after the underling operation, The\n * BIO_CB_RETURN flag indicates if it is after the call\n */\n# define BIO_CB_RETURN   0x80\n# define BIO_CB_return(a) ((a)|BIO_CB_RETURN)\n# define BIO_cb_pre(a)   (!((a)&BIO_CB_RETURN))\n# define BIO_cb_post(a)  ((a)&BIO_CB_RETURN)\n\ntypedef long (*BIO_callback_fn)(BIO *b, int oper, const char *argp, int argi,\n                                long argl, long ret);\ntypedef long (*BIO_callback_fn_ex)(BIO *b, int oper, const char *argp,\n                                   size_t len, int argi,\n                                   long argl, int ret, size_t *processed);\nBIO_callback_fn BIO_get_callback(const BIO *b);\nvoid BIO_set_callback(BIO *b, BIO_callback_fn callback);\n\nBIO_callback_fn_ex BIO_get_callback_ex(const BIO *b);\nvoid BIO_set_callback_ex(BIO *b, BIO_callback_fn_ex callback);\n\nchar *BIO_get_callback_arg(const BIO *b);\nvoid BIO_set_callback_arg(BIO *b, char *arg);\n\ntypedef struct bio_method_st BIO_METHOD;\n\nconst char *BIO_method_name(const BIO *b);\nint BIO_method_type(const BIO *b);\n\ntypedef int BIO_info_cb(BIO *, int, int);\ntypedef BIO_info_cb bio_info_cb;  /* backward compatibility */\n\nDEFINE_STACK_OF(BIO)\n\n/* Prefix and suffix callback in ASN1 BIO */\ntypedef int asn1_ps_func (BIO *b, unsigned char **pbuf, int *plen,\n                          void *parg);\n\n# ifndef OPENSSL_NO_SCTP\n/* SCTP parameter structs */\nstruct bio_dgram_sctp_sndinfo {\n    uint16_t snd_sid;\n    uint16_t snd_flags;\n    uint32_t snd_ppid;\n    uint32_t snd_context;\n};\n\nstruct bio_dgram_sctp_rcvinfo {\n    uint16_t rcv_sid;\n    uint16_t rcv_ssn;\n    uint16_t rcv_flags;\n    uint32_t rcv_ppid;\n    uint32_t rcv_tsn;\n    uint32_t rcv_cumtsn;\n    uint32_t rcv_context;\n};\n\nstruct bio_dgram_sctp_prinfo {\n    uint16_t pr_policy;\n    uint32_t pr_value;\n};\n# endif\n\n/*\n * #define BIO_CONN_get_param_hostname BIO_ctrl\n */\n\n# define BIO_C_SET_CONNECT                       100\n# define BIO_C_DO_STATE_MACHINE                  101\n# define BIO_C_SET_NBIO                          102\n/* # define BIO_C_SET_PROXY_PARAM                   103 */\n# define BIO_C_SET_FD                            104\n# define BIO_C_GET_FD                            105\n# define BIO_C_SET_FILE_PTR                      106\n# define BIO_C_GET_FILE_PTR                      107\n# define BIO_C_SET_FILENAME                      108\n# define BIO_C_SET_SSL                           109\n# define BIO_C_GET_SSL                           110\n# define BIO_C_SET_MD                            111\n# define BIO_C_GET_MD                            112\n# define BIO_C_GET_CIPHER_STATUS                 113\n# define BIO_C_SET_BUF_MEM                       114\n# define BIO_C_GET_BUF_MEM_PTR                   115\n# define BIO_C_GET_BUFF_NUM_LINES                116\n# define BIO_C_SET_BUFF_SIZE                     117\n# define BIO_C_SET_ACCEPT                        118\n# define BIO_C_SSL_MODE                          119\n# define BIO_C_GET_MD_CTX                        120\n/* # define BIO_C_GET_PROXY_PARAM                   121 */\n# define BIO_C_SET_BUFF_READ_DATA                122/* data to read first */\n# define BIO_C_GET_CONNECT                       123\n# define BIO_C_GET_ACCEPT                        124\n# define BIO_C_SET_SSL_RENEGOTIATE_BYTES         125\n# define BIO_C_GET_SSL_NUM_RENEGOTIATES          126\n# define BIO_C_SET_SSL_RENEGOTIATE_TIMEOUT       127\n# define BIO_C_FILE_SEEK                         128\n# define BIO_C_GET_CIPHER_CTX                    129\n# define BIO_C_SET_BUF_MEM_EOF_RETURN            130/* return end of input\n                                                     * value */\n# define BIO_C_SET_BIND_MODE                     131\n# define BIO_C_GET_BIND_MODE                     132\n# define BIO_C_FILE_TELL                         133\n# define BIO_C_GET_SOCKS                         134\n# define BIO_C_SET_SOCKS                         135\n\n# define BIO_C_SET_WRITE_BUF_SIZE                136/* for BIO_s_bio */\n# define BIO_C_GET_WRITE_BUF_SIZE                137\n# define BIO_C_MAKE_BIO_PAIR                     138\n# define BIO_C_DESTROY_BIO_PAIR                  139\n# define BIO_C_GET_WRITE_GUARANTEE               140\n# define BIO_C_GET_READ_REQUEST                  141\n# define BIO_C_SHUTDOWN_WR                       142\n# define BIO_C_NREAD0                            143\n# define BIO_C_NREAD                             144\n# define BIO_C_NWRITE0                           145\n# define BIO_C_NWRITE                            146\n# define BIO_C_RESET_READ_REQUEST                147\n# define BIO_C_SET_MD_CTX                        148\n\n# define BIO_C_SET_PREFIX                        149\n# define BIO_C_GET_PREFIX                        150\n# define BIO_C_SET_SUFFIX                        151\n# define BIO_C_GET_SUFFIX                        152\n\n# define BIO_C_SET_EX_ARG                        153\n# define BIO_C_GET_EX_ARG                        154\n\n# define BIO_C_SET_CONNECT_MODE                  155\n\n# define BIO_set_app_data(s,arg)         BIO_set_ex_data(s,0,arg)\n# define BIO_get_app_data(s)             BIO_get_ex_data(s,0)\n\n# define BIO_set_nbio(b,n)             BIO_ctrl(b,BIO_C_SET_NBIO,(n),NULL)\n\n# ifndef OPENSSL_NO_SOCK\n/* IP families we support, for BIO_s_connect() and BIO_s_accept() */\n/* Note: the underlying operating system may not support some of them */\n#  define BIO_FAMILY_IPV4                         4\n#  define BIO_FAMILY_IPV6                         6\n#  define BIO_FAMILY_IPANY                        256\n\n/* BIO_s_connect() */\n#  define BIO_set_conn_hostname(b,name) BIO_ctrl(b,BIO_C_SET_CONNECT,0, \\\n                                                 (char *)(name))\n#  define BIO_set_conn_port(b,port)     BIO_ctrl(b,BIO_C_SET_CONNECT,1, \\\n                                                 (char *)(port))\n#  define BIO_set_conn_address(b,addr)  BIO_ctrl(b,BIO_C_SET_CONNECT,2, \\\n                                                 (char *)(addr))\n#  define BIO_set_conn_ip_family(b,f)   BIO_int_ctrl(b,BIO_C_SET_CONNECT,3,f)\n#  define BIO_get_conn_hostname(b)      ((const char *)BIO_ptr_ctrl(b,BIO_C_GET_CONNECT,0))\n#  define BIO_get_conn_port(b)          ((const char *)BIO_ptr_ctrl(b,BIO_C_GET_CONNECT,1))\n#  define BIO_get_conn_address(b)       ((const BIO_ADDR *)BIO_ptr_ctrl(b,BIO_C_GET_CONNECT,2))\n#  define BIO_get_conn_ip_family(b)     BIO_ctrl(b,BIO_C_GET_CONNECT,3,NULL)\n#  define BIO_set_conn_mode(b,n)        BIO_ctrl(b,BIO_C_SET_CONNECT_MODE,(n),NULL)\n\n/* BIO_s_accept() */\n#  define BIO_set_accept_name(b,name)   BIO_ctrl(b,BIO_C_SET_ACCEPT,0, \\\n                                                 (char *)(name))\n#  define BIO_set_accept_port(b,port)   BIO_ctrl(b,BIO_C_SET_ACCEPT,1, \\\n                                                 (char *)(port))\n#  define BIO_get_accept_name(b)        ((const char *)BIO_ptr_ctrl(b,BIO_C_GET_ACCEPT,0))\n#  define BIO_get_accept_port(b)        ((const char *)BIO_ptr_ctrl(b,BIO_C_GET_ACCEPT,1))\n#  define BIO_get_peer_name(b)          ((const char *)BIO_ptr_ctrl(b,BIO_C_GET_ACCEPT,2))\n#  define BIO_get_peer_port(b)          ((const char *)BIO_ptr_ctrl(b,BIO_C_GET_ACCEPT,3))\n/* #define BIO_set_nbio(b,n)    BIO_ctrl(b,BIO_C_SET_NBIO,(n),NULL) */\n#  define BIO_set_nbio_accept(b,n)      BIO_ctrl(b,BIO_C_SET_ACCEPT,2,(n)?(void *)\"a\":NULL)\n#  define BIO_set_accept_bios(b,bio)    BIO_ctrl(b,BIO_C_SET_ACCEPT,3, \\\n                                                 (char *)(bio))\n#  define BIO_set_accept_ip_family(b,f) BIO_int_ctrl(b,BIO_C_SET_ACCEPT,4,f)\n#  define BIO_get_accept_ip_family(b)   BIO_ctrl(b,BIO_C_GET_ACCEPT,4,NULL)\n\n/* Aliases kept for backward compatibility */\n#  define BIO_BIND_NORMAL                 0\n#  define BIO_BIND_REUSEADDR              BIO_SOCK_REUSEADDR\n#  define BIO_BIND_REUSEADDR_IF_UNUSED    BIO_SOCK_REUSEADDR\n#  define BIO_set_bind_mode(b,mode) BIO_ctrl(b,BIO_C_SET_BIND_MODE,mode,NULL)\n#  define BIO_get_bind_mode(b)    BIO_ctrl(b,BIO_C_GET_BIND_MODE,0,NULL)\n\n/* BIO_s_accept() and BIO_s_connect() */\n#  define BIO_do_connect(b)       BIO_do_handshake(b)\n#  define BIO_do_accept(b)        BIO_do_handshake(b)\n# endif /* OPENSSL_NO_SOCK */\n\n# define BIO_do_handshake(b)     BIO_ctrl(b,BIO_C_DO_STATE_MACHINE,0,NULL)\n\n/* BIO_s_datagram(), BIO_s_fd(), BIO_s_socket(), BIO_s_accept() and BIO_s_connect() */\n# define BIO_set_fd(b,fd,c)      BIO_int_ctrl(b,BIO_C_SET_FD,c,fd)\n# define BIO_get_fd(b,c)         BIO_ctrl(b,BIO_C_GET_FD,0,(char *)(c))\n\n/* BIO_s_file() */\n# define BIO_set_fp(b,fp,c)      BIO_ctrl(b,BIO_C_SET_FILE_PTR,c,(char *)(fp))\n# define BIO_get_fp(b,fpp)       BIO_ctrl(b,BIO_C_GET_FILE_PTR,0,(char *)(fpp))\n\n/* BIO_s_fd() and BIO_s_file() */\n# define BIO_seek(b,ofs) (int)BIO_ctrl(b,BIO_C_FILE_SEEK,ofs,NULL)\n# define BIO_tell(b)     (int)BIO_ctrl(b,BIO_C_FILE_TELL,0,NULL)\n\n/*\n * name is cast to lose const, but might be better to route through a\n * function so we can do it safely\n */\n# ifdef CONST_STRICT\n/*\n * If you are wondering why this isn't defined, its because CONST_STRICT is\n * purely a compile-time kludge to allow const to be checked.\n */\nint BIO_read_filename(BIO *b, const char *name);\n# else\n#  define BIO_read_filename(b,name) (int)BIO_ctrl(b,BIO_C_SET_FILENAME, \\\n                BIO_CLOSE|BIO_FP_READ,(char *)(name))\n# endif\n# define BIO_write_filename(b,name) (int)BIO_ctrl(b,BIO_C_SET_FILENAME, \\\n                BIO_CLOSE|BIO_FP_WRITE,name)\n# define BIO_append_filename(b,name) (int)BIO_ctrl(b,BIO_C_SET_FILENAME, \\\n                BIO_CLOSE|BIO_FP_APPEND,name)\n# define BIO_rw_filename(b,name) (int)BIO_ctrl(b,BIO_C_SET_FILENAME, \\\n                BIO_CLOSE|BIO_FP_READ|BIO_FP_WRITE,name)\n\n/*\n * WARNING WARNING, this ups the reference count on the read bio of the SSL\n * structure.  This is because the ssl read BIO is now pointed to by the\n * next_bio field in the bio.  So when you free the BIO, make sure you are\n * doing a BIO_free_all() to catch the underlying BIO.\n */\n# define BIO_set_ssl(b,ssl,c)    BIO_ctrl(b,BIO_C_SET_SSL,c,(char *)(ssl))\n# define BIO_get_ssl(b,sslp)     BIO_ctrl(b,BIO_C_GET_SSL,0,(char *)(sslp))\n# define BIO_set_ssl_mode(b,client)      BIO_ctrl(b,BIO_C_SSL_MODE,client,NULL)\n# define BIO_set_ssl_renegotiate_bytes(b,num) \\\n        BIO_ctrl(b,BIO_C_SET_SSL_RENEGOTIATE_BYTES,num,NULL)\n# define BIO_get_num_renegotiates(b) \\\n        BIO_ctrl(b,BIO_C_GET_SSL_NUM_RENEGOTIATES,0,NULL)\n# define BIO_set_ssl_renegotiate_timeout(b,seconds) \\\n        BIO_ctrl(b,BIO_C_SET_SSL_RENEGOTIATE_TIMEOUT,seconds,NULL)\n\n/* defined in evp.h */\n/* #define BIO_set_md(b,md)     BIO_ctrl(b,BIO_C_SET_MD,1,(char *)(md)) */\n\n# define BIO_get_mem_data(b,pp)  BIO_ctrl(b,BIO_CTRL_INFO,0,(char *)(pp))\n# define BIO_set_mem_buf(b,bm,c) BIO_ctrl(b,BIO_C_SET_BUF_MEM,c,(char *)(bm))\n# define BIO_get_mem_ptr(b,pp)   BIO_ctrl(b,BIO_C_GET_BUF_MEM_PTR,0, \\\n                                          (char *)(pp))\n# define BIO_set_mem_eof_return(b,v) \\\n                                BIO_ctrl(b,BIO_C_SET_BUF_MEM_EOF_RETURN,v,NULL)\n\n/* For the BIO_f_buffer() type */\n# define BIO_get_buffer_num_lines(b)     BIO_ctrl(b,BIO_C_GET_BUFF_NUM_LINES,0,NULL)\n# define BIO_set_buffer_size(b,size)     BIO_ctrl(b,BIO_C_SET_BUFF_SIZE,size,NULL)\n# define BIO_set_read_buffer_size(b,size) BIO_int_ctrl(b,BIO_C_SET_BUFF_SIZE,size,0)\n# define BIO_set_write_buffer_size(b,size) BIO_int_ctrl(b,BIO_C_SET_BUFF_SIZE,size,1)\n# define BIO_set_buffer_read_data(b,buf,num) BIO_ctrl(b,BIO_C_SET_BUFF_READ_DATA,num,buf)\n\n/* Don't use the next one unless you know what you are doing :-) */\n# define BIO_dup_state(b,ret)    BIO_ctrl(b,BIO_CTRL_DUP,0,(char *)(ret))\n\n# define BIO_reset(b)            (int)BIO_ctrl(b,BIO_CTRL_RESET,0,NULL)\n# define BIO_eof(b)              (int)BIO_ctrl(b,BIO_CTRL_EOF,0,NULL)\n# define BIO_set_close(b,c)      (int)BIO_ctrl(b,BIO_CTRL_SET_CLOSE,(c),NULL)\n# define BIO_get_close(b)        (int)BIO_ctrl(b,BIO_CTRL_GET_CLOSE,0,NULL)\n# define BIO_pending(b)          (int)BIO_ctrl(b,BIO_CTRL_PENDING,0,NULL)\n# define BIO_wpending(b)         (int)BIO_ctrl(b,BIO_CTRL_WPENDING,0,NULL)\n/* ...pending macros have inappropriate return type */\nsize_t BIO_ctrl_pending(BIO *b);\nsize_t BIO_ctrl_wpending(BIO *b);\n# define BIO_flush(b)            (int)BIO_ctrl(b,BIO_CTRL_FLUSH,0,NULL)\n# define BIO_get_info_callback(b,cbp) (int)BIO_ctrl(b,BIO_CTRL_GET_CALLBACK,0, \\\n                                                   cbp)\n# define BIO_set_info_callback(b,cb) (int)BIO_callback_ctrl(b,BIO_CTRL_SET_CALLBACK,cb)\n\n/* For the BIO_f_buffer() type */\n# define BIO_buffer_get_num_lines(b) BIO_ctrl(b,BIO_CTRL_GET,0,NULL)\n# define BIO_buffer_peek(b,s,l) BIO_ctrl(b,BIO_CTRL_PEEK,(l),(s))\n\n/* For BIO_s_bio() */\n# define BIO_set_write_buf_size(b,size) (int)BIO_ctrl(b,BIO_C_SET_WRITE_BUF_SIZE,size,NULL)\n# define BIO_get_write_buf_size(b,size) (size_t)BIO_ctrl(b,BIO_C_GET_WRITE_BUF_SIZE,size,NULL)\n# define BIO_make_bio_pair(b1,b2)   (int)BIO_ctrl(b1,BIO_C_MAKE_BIO_PAIR,0,b2)\n# define BIO_destroy_bio_pair(b)    (int)BIO_ctrl(b,BIO_C_DESTROY_BIO_PAIR,0,NULL)\n# define BIO_shutdown_wr(b) (int)BIO_ctrl(b, BIO_C_SHUTDOWN_WR, 0, NULL)\n/* macros with inappropriate type -- but ...pending macros use int too: */\n# define BIO_get_write_guarantee(b) (int)BIO_ctrl(b,BIO_C_GET_WRITE_GUARANTEE,0,NULL)\n# define BIO_get_read_request(b)    (int)BIO_ctrl(b,BIO_C_GET_READ_REQUEST,0,NULL)\nsize_t BIO_ctrl_get_write_guarantee(BIO *b);\nsize_t BIO_ctrl_get_read_request(BIO *b);\nint BIO_ctrl_reset_read_request(BIO *b);\n\n/* ctrl macros for dgram */\n# define BIO_ctrl_dgram_connect(b,peer)  \\\n                     (int)BIO_ctrl(b,BIO_CTRL_DGRAM_CONNECT,0, (char *)(peer))\n# define BIO_ctrl_set_connected(b,peer) \\\n         (int)BIO_ctrl(b, BIO_CTRL_DGRAM_SET_CONNECTED, 0, (char *)(peer))\n# define BIO_dgram_recv_timedout(b) \\\n         (int)BIO_ctrl(b, BIO_CTRL_DGRAM_GET_RECV_TIMER_EXP, 0, NULL)\n# define BIO_dgram_send_timedout(b) \\\n         (int)BIO_ctrl(b, BIO_CTRL_DGRAM_GET_SEND_TIMER_EXP, 0, NULL)\n# define BIO_dgram_get_peer(b,peer) \\\n         (int)BIO_ctrl(b, BIO_CTRL_DGRAM_GET_PEER, 0, (char *)(peer))\n# define BIO_dgram_set_peer(b,peer) \\\n         (int)BIO_ctrl(b, BIO_CTRL_DGRAM_SET_PEER, 0, (char *)(peer))\n# define BIO_dgram_get_mtu_overhead(b) \\\n         (unsigned int)BIO_ctrl((b), BIO_CTRL_DGRAM_GET_MTU_OVERHEAD, 0, NULL)\n\n#define BIO_get_ex_new_index(l, p, newf, dupf, freef) \\\n    CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_BIO, l, p, newf, dupf, freef)\nint BIO_set_ex_data(BIO *bio, int idx, void *data);\nvoid *BIO_get_ex_data(BIO *bio, int idx);\nuint64_t BIO_number_read(BIO *bio);\nuint64_t BIO_number_written(BIO *bio);\n\n/* For BIO_f_asn1() */\nint BIO_asn1_set_prefix(BIO *b, asn1_ps_func *prefix,\n                        asn1_ps_func *prefix_free);\nint BIO_asn1_get_prefix(BIO *b, asn1_ps_func **pprefix,\n                        asn1_ps_func **pprefix_free);\nint BIO_asn1_set_suffix(BIO *b, asn1_ps_func *suffix,\n                        asn1_ps_func *suffix_free);\nint BIO_asn1_get_suffix(BIO *b, asn1_ps_func **psuffix,\n                        asn1_ps_func **psuffix_free);\n\nconst BIO_METHOD *BIO_s_file(void);\nBIO *BIO_new_file(const char *filename, const char *mode);\n# ifndef OPENSSL_NO_STDIO\nBIO *BIO_new_fp(FILE *stream, int close_flag);\n# endif\nBIO *BIO_new(const BIO_METHOD *type);\nint BIO_free(BIO *a);\nvoid BIO_set_data(BIO *a, void *ptr);\nvoid *BIO_get_data(BIO *a);\nvoid BIO_set_init(BIO *a, int init);\nint BIO_get_init(BIO *a);\nvoid BIO_set_shutdown(BIO *a, int shut);\nint BIO_get_shutdown(BIO *a);\nvoid BIO_vfree(BIO *a);\nint BIO_up_ref(BIO *a);\nint BIO_read(BIO *b, void *data, int dlen);\nint BIO_read_ex(BIO *b, void *data, size_t dlen, size_t *readbytes);\nint BIO_gets(BIO *bp, char *buf, int size);\nint BIO_write(BIO *b, const void *data, int dlen);\nint BIO_write_ex(BIO *b, const void *data, size_t dlen, size_t *written);\nint BIO_puts(BIO *bp, const char *buf);\nint BIO_indent(BIO *b, int indent, int max);\nlong BIO_ctrl(BIO *bp, int cmd, long larg, void *parg);\nlong BIO_callback_ctrl(BIO *b, int cmd, BIO_info_cb *fp);\nvoid *BIO_ptr_ctrl(BIO *bp, int cmd, long larg);\nlong BIO_int_ctrl(BIO *bp, int cmd, long larg, int iarg);\nBIO *BIO_push(BIO *b, BIO *append);\nBIO *BIO_pop(BIO *b);\nvoid BIO_free_all(BIO *a);\nBIO *BIO_find_type(BIO *b, int bio_type);\nBIO *BIO_next(BIO *b);\nvoid BIO_set_next(BIO *b, BIO *next);\nBIO *BIO_get_retry_BIO(BIO *bio, int *reason);\nint BIO_get_retry_reason(BIO *bio);\nvoid BIO_set_retry_reason(BIO *bio, int reason);\nBIO *BIO_dup_chain(BIO *in);\n\nint BIO_nread0(BIO *bio, char **buf);\nint BIO_nread(BIO *bio, char **buf, int num);\nint BIO_nwrite0(BIO *bio, char **buf);\nint BIO_nwrite(BIO *bio, char **buf, int num);\n\nlong BIO_debug_callback(BIO *bio, int cmd, const char *argp, int argi,\n                        long argl, long ret);\n\nconst BIO_METHOD *BIO_s_mem(void);\nconst BIO_METHOD *BIO_s_secmem(void);\nBIO *BIO_new_mem_buf(const void *buf, int len);\n# ifndef OPENSSL_NO_SOCK\nconst BIO_METHOD *BIO_s_socket(void);\nconst BIO_METHOD *BIO_s_connect(void);\nconst BIO_METHOD *BIO_s_accept(void);\n# endif\nconst BIO_METHOD *BIO_s_fd(void);\nconst BIO_METHOD *BIO_s_log(void);\nconst BIO_METHOD *BIO_s_bio(void);\nconst BIO_METHOD *BIO_s_null(void);\nconst BIO_METHOD *BIO_f_null(void);\nconst BIO_METHOD *BIO_f_buffer(void);\nconst BIO_METHOD *BIO_f_linebuffer(void);\nconst BIO_METHOD *BIO_f_nbio_test(void);\n# ifndef OPENSSL_NO_DGRAM\nconst BIO_METHOD *BIO_s_datagram(void);\nint BIO_dgram_non_fatal_error(int error);\nBIO *BIO_new_dgram(int fd, int close_flag);\n#  ifndef OPENSSL_NO_SCTP\nconst BIO_METHOD *BIO_s_datagram_sctp(void);\nBIO *BIO_new_dgram_sctp(int fd, int close_flag);\nint BIO_dgram_is_sctp(BIO *bio);\nint BIO_dgram_sctp_notification_cb(BIO *b,\n                                   void (*handle_notifications) (BIO *bio,\n                                                                 void *context,\n                                                                 void *buf),\n                                   void *context);\nint BIO_dgram_sctp_wait_for_dry(BIO *b);\nint BIO_dgram_sctp_msg_waiting(BIO *b);\n#  endif\n# endif\n\n# ifndef OPENSSL_NO_SOCK\nint BIO_sock_should_retry(int i);\nint BIO_sock_non_fatal_error(int error);\n# endif\n\nint BIO_fd_should_retry(int i);\nint BIO_fd_non_fatal_error(int error);\nint BIO_dump_cb(int (*cb) (const void *data, size_t len, void *u),\n                void *u, const char *s, int len);\nint BIO_dump_indent_cb(int (*cb) (const void *data, size_t len, void *u),\n                       void *u, const char *s, int len, int indent);\nint BIO_dump(BIO *b, const char *bytes, int len);\nint BIO_dump_indent(BIO *b, const char *bytes, int len, int indent);\n# ifndef OPENSSL_NO_STDIO\nint BIO_dump_fp(FILE *fp, const char *s, int len);\nint BIO_dump_indent_fp(FILE *fp, const char *s, int len, int indent);\n# endif\nint BIO_hex_string(BIO *out, int indent, int width, unsigned char *data,\n                   int datalen);\n\n# ifndef OPENSSL_NO_SOCK\nBIO_ADDR *BIO_ADDR_new(void);\nint BIO_ADDR_rawmake(BIO_ADDR *ap, int family,\n                     const void *where, size_t wherelen, unsigned short port);\nvoid BIO_ADDR_free(BIO_ADDR *);\nvoid BIO_ADDR_clear(BIO_ADDR *ap);\nint BIO_ADDR_family(const BIO_ADDR *ap);\nint BIO_ADDR_rawaddress(const BIO_ADDR *ap, void *p, size_t *l);\nunsigned short BIO_ADDR_rawport(const BIO_ADDR *ap);\nchar *BIO_ADDR_hostname_string(const BIO_ADDR *ap, int numeric);\nchar *BIO_ADDR_service_string(const BIO_ADDR *ap, int numeric);\nchar *BIO_ADDR_path_string(const BIO_ADDR *ap);\n\nconst BIO_ADDRINFO *BIO_ADDRINFO_next(const BIO_ADDRINFO *bai);\nint BIO_ADDRINFO_family(const BIO_ADDRINFO *bai);\nint BIO_ADDRINFO_socktype(const BIO_ADDRINFO *bai);\nint BIO_ADDRINFO_protocol(const BIO_ADDRINFO *bai);\nconst BIO_ADDR *BIO_ADDRINFO_address(const BIO_ADDRINFO *bai);\nvoid BIO_ADDRINFO_free(BIO_ADDRINFO *bai);\n\nenum BIO_hostserv_priorities {\n    BIO_PARSE_PRIO_HOST, BIO_PARSE_PRIO_SERV\n};\nint BIO_parse_hostserv(const char *hostserv, char **host, char **service,\n                       enum BIO_hostserv_priorities hostserv_prio);\nenum BIO_lookup_type {\n    BIO_LOOKUP_CLIENT, BIO_LOOKUP_SERVER\n};\nint BIO_lookup(const char *host, const char *service,\n               enum BIO_lookup_type lookup_type,\n               int family, int socktype, BIO_ADDRINFO **res);\nint BIO_lookup_ex(const char *host, const char *service,\n                  int lookup_type, int family, int socktype, int protocol,\n                  BIO_ADDRINFO **res);\nint BIO_sock_error(int sock);\nint BIO_socket_ioctl(int fd, long type, void *arg);\nint BIO_socket_nbio(int fd, int mode);\nint BIO_sock_init(void);\n# if OPENSSL_API_COMPAT < 0x10100000L\n#  define BIO_sock_cleanup() while(0) continue\n# endif\nint BIO_set_tcp_ndelay(int sock, int turn_on);\n\nDEPRECATEDIN_1_1_0(struct hostent *BIO_gethostbyname(const char *name))\nDEPRECATEDIN_1_1_0(int BIO_get_port(const char *str, unsigned short *port_ptr))\nDEPRECATEDIN_1_1_0(int BIO_get_host_ip(const char *str, unsigned char *ip))\nDEPRECATEDIN_1_1_0(int BIO_get_accept_socket(char *host_port, int mode))\nDEPRECATEDIN_1_1_0(int BIO_accept(int sock, char **ip_port))\n\nunion BIO_sock_info_u {\n    BIO_ADDR *addr;\n};\nenum BIO_sock_info_type {\n    BIO_SOCK_INFO_ADDRESS\n};\nint BIO_sock_info(int sock,\n                  enum BIO_sock_info_type type, union BIO_sock_info_u *info);\n\n#  define BIO_SOCK_REUSEADDR    0x01\n#  define BIO_SOCK_V6_ONLY      0x02\n#  define BIO_SOCK_KEEPALIVE    0x04\n#  define BIO_SOCK_NONBLOCK     0x08\n#  define BIO_SOCK_NODELAY      0x10\n\nint BIO_socket(int domain, int socktype, int protocol, int options);\nint BIO_connect(int sock, const BIO_ADDR *addr, int options);\nint BIO_bind(int sock, const BIO_ADDR *addr, int options);\nint BIO_listen(int sock, const BIO_ADDR *addr, int options);\nint BIO_accept_ex(int accept_sock, BIO_ADDR *addr, int options);\nint BIO_closesocket(int sock);\n\nBIO *BIO_new_socket(int sock, int close_flag);\nBIO *BIO_new_connect(const char *host_port);\nBIO *BIO_new_accept(const char *host_port);\n# endif /* OPENSSL_NO_SOCK*/\n\nBIO *BIO_new_fd(int fd, int close_flag);\n\nint BIO_new_bio_pair(BIO **bio1, size_t writebuf1,\n                     BIO **bio2, size_t writebuf2);\n/*\n * If successful, returns 1 and in *bio1, *bio2 two BIO pair endpoints.\n * Otherwise returns 0 and sets *bio1 and *bio2 to NULL. Size 0 uses default\n * value.\n */\n\nvoid BIO_copy_next_retry(BIO *b);\n\n/*\n * long BIO_ghbn_ctrl(int cmd,int iarg,char *parg);\n */\n\n# define ossl_bio__attr__(x)\n# if defined(__GNUC__) && defined(__STDC_VERSION__) \\\n    && !defined(__APPLE__)\n    /*\n     * Because we support the 'z' modifier, which made its appearance in C99,\n     * we can't use __attribute__ with pre C99 dialects.\n     */\n#  if __STDC_VERSION__ >= 199901L\n#   undef ossl_bio__attr__\n#   define ossl_bio__attr__ __attribute__\n#   if __GNUC__*10 + __GNUC_MINOR__ >= 44\n#    define ossl_bio__printf__ __gnu_printf__\n#   else\n#    define ossl_bio__printf__ __printf__\n#   endif\n#  endif\n# endif\nint BIO_printf(BIO *bio, const char *format, ...)\nossl_bio__attr__((__format__(ossl_bio__printf__, 2, 3)));\nint BIO_vprintf(BIO *bio, const char *format, va_list args)\nossl_bio__attr__((__format__(ossl_bio__printf__, 2, 0)));\nint BIO_snprintf(char *buf, size_t n, const char *format, ...)\nossl_bio__attr__((__format__(ossl_bio__printf__, 3, 4)));\nint BIO_vsnprintf(char *buf, size_t n, const char *format, va_list args)\nossl_bio__attr__((__format__(ossl_bio__printf__, 3, 0)));\n# undef ossl_bio__attr__\n# undef ossl_bio__printf__\n\n\nBIO_METHOD *BIO_meth_new(int type, const char *name);\nvoid BIO_meth_free(BIO_METHOD *biom);\nint (*BIO_meth_get_write(const BIO_METHOD *biom)) (BIO *, const char *, int);\nint (*BIO_meth_get_write_ex(const BIO_METHOD *biom)) (BIO *, const char *, size_t,\n                                                size_t *);\nint BIO_meth_set_write(BIO_METHOD *biom,\n                       int (*write) (BIO *, const char *, int));\nint BIO_meth_set_write_ex(BIO_METHOD *biom,\n                       int (*bwrite) (BIO *, const char *, size_t, size_t *));\nint (*BIO_meth_get_read(const BIO_METHOD *biom)) (BIO *, char *, int);\nint (*BIO_meth_get_read_ex(const BIO_METHOD *biom)) (BIO *, char *, size_t, size_t *);\nint BIO_meth_set_read(BIO_METHOD *biom,\n                      int (*read) (BIO *, char *, int));\nint BIO_meth_set_read_ex(BIO_METHOD *biom,\n                         int (*bread) (BIO *, char *, size_t, size_t *));\nint (*BIO_meth_get_puts(const BIO_METHOD *biom)) (BIO *, const char *);\nint BIO_meth_set_puts(BIO_METHOD *biom,\n                      int (*puts) (BIO *, const char *));\nint (*BIO_meth_get_gets(const BIO_METHOD *biom)) (BIO *, char *, int);\nint BIO_meth_set_gets(BIO_METHOD *biom,\n                      int (*gets) (BIO *, char *, int));\nlong (*BIO_meth_get_ctrl(const BIO_METHOD *biom)) (BIO *, int, long, void *);\nint BIO_meth_set_ctrl(BIO_METHOD *biom,\n                      long (*ctrl) (BIO *, int, long, void *));\nint (*BIO_meth_get_create(const BIO_METHOD *bion)) (BIO *);\nint BIO_meth_set_create(BIO_METHOD *biom, int (*create) (BIO *));\nint (*BIO_meth_get_destroy(const BIO_METHOD *biom)) (BIO *);\nint BIO_meth_set_destroy(BIO_METHOD *biom, int (*destroy) (BIO *));\nlong (*BIO_meth_get_callback_ctrl(const BIO_METHOD *biom))\n                                 (BIO *, int, BIO_info_cb *);\nint BIO_meth_set_callback_ctrl(BIO_METHOD *biom,\n                               long (*callback_ctrl) (BIO *, int,\n                                                      BIO_info_cb *));\n\n# ifdef  __cplusplus\n}\n# endif\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/include/openssl/bioerr.h",
    "content": "/*\n * Generated by util/mkerr.pl DO NOT EDIT\n * Copyright 1995-2019 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef HEADER_BIOERR_H\n# define HEADER_BIOERR_H\n\n# ifndef HEADER_SYMHACKS_H\n#  include <openssl/symhacks.h>\n# endif\n\n# ifdef  __cplusplus\nextern \"C\"\n# endif\nint ERR_load_BIO_strings(void);\n\n/*\n * BIO function codes.\n */\n# define BIO_F_ACPT_STATE                                 100\n# define BIO_F_ADDRINFO_WRAP                              148\n# define BIO_F_ADDR_STRINGS                               134\n# define BIO_F_BIO_ACCEPT                                 101\n# define BIO_F_BIO_ACCEPT_EX                              137\n# define BIO_F_BIO_ACCEPT_NEW                             152\n# define BIO_F_BIO_ADDR_NEW                               144\n# define BIO_F_BIO_BIND                                   147\n# define BIO_F_BIO_CALLBACK_CTRL                          131\n# define BIO_F_BIO_CONNECT                                138\n# define BIO_F_BIO_CONNECT_NEW                            153\n# define BIO_F_BIO_CTRL                                   103\n# define BIO_F_BIO_GETS                                   104\n# define BIO_F_BIO_GET_HOST_IP                            106\n# define BIO_F_BIO_GET_NEW_INDEX                          102\n# define BIO_F_BIO_GET_PORT                               107\n# define BIO_F_BIO_LISTEN                                 139\n# define BIO_F_BIO_LOOKUP                                 135\n# define BIO_F_BIO_LOOKUP_EX                              143\n# define BIO_F_BIO_MAKE_PAIR                              121\n# define BIO_F_BIO_METH_NEW                               146\n# define BIO_F_BIO_NEW                                    108\n# define BIO_F_BIO_NEW_DGRAM_SCTP                         145\n# define BIO_F_BIO_NEW_FILE                               109\n# define BIO_F_BIO_NEW_MEM_BUF                            126\n# define BIO_F_BIO_NREAD                                  123\n# define BIO_F_BIO_NREAD0                                 124\n# define BIO_F_BIO_NWRITE                                 125\n# define BIO_F_BIO_NWRITE0                                122\n# define BIO_F_BIO_PARSE_HOSTSERV                         136\n# define BIO_F_BIO_PUTS                                   110\n# define BIO_F_BIO_READ                                   111\n# define BIO_F_BIO_READ_EX                                105\n# define BIO_F_BIO_READ_INTERN                            120\n# define BIO_F_BIO_SOCKET                                 140\n# define BIO_F_BIO_SOCKET_NBIO                            142\n# define BIO_F_BIO_SOCK_INFO                              141\n# define BIO_F_BIO_SOCK_INIT                              112\n# define BIO_F_BIO_WRITE                                  113\n# define BIO_F_BIO_WRITE_EX                               119\n# define BIO_F_BIO_WRITE_INTERN                           128\n# define BIO_F_BUFFER_CTRL                                114\n# define BIO_F_CONN_CTRL                                  127\n# define BIO_F_CONN_STATE                                 115\n# define BIO_F_DGRAM_SCTP_NEW                             149\n# define BIO_F_DGRAM_SCTP_READ                            132\n# define BIO_F_DGRAM_SCTP_WRITE                           133\n# define BIO_F_DOAPR_OUTCH                                150\n# define BIO_F_FILE_CTRL                                  116\n# define BIO_F_FILE_READ                                  130\n# define BIO_F_LINEBUFFER_CTRL                            129\n# define BIO_F_LINEBUFFER_NEW                             151\n# define BIO_F_MEM_WRITE                                  117\n# define BIO_F_NBIOF_NEW                                  154\n# define BIO_F_SLG_WRITE                                  155\n# define BIO_F_SSL_NEW                                    118\n\n/*\n * BIO reason codes.\n */\n# define BIO_R_ACCEPT_ERROR                               100\n# define BIO_R_ADDRINFO_ADDR_IS_NOT_AF_INET               141\n# define BIO_R_AMBIGUOUS_HOST_OR_SERVICE                  129\n# define BIO_R_BAD_FOPEN_MODE                             101\n# define BIO_R_BROKEN_PIPE                                124\n# define BIO_R_CONNECT_ERROR                              103\n# define BIO_R_GETHOSTBYNAME_ADDR_IS_NOT_AF_INET          107\n# define BIO_R_GETSOCKNAME_ERROR                          132\n# define BIO_R_GETSOCKNAME_TRUNCATED_ADDRESS              133\n# define BIO_R_GETTING_SOCKTYPE                           134\n# define BIO_R_INVALID_ARGUMENT                           125\n# define BIO_R_INVALID_SOCKET                             135\n# define BIO_R_IN_USE                                     123\n# define BIO_R_LENGTH_TOO_LONG                            102\n# define BIO_R_LISTEN_V6_ONLY                             136\n# define BIO_R_LOOKUP_RETURNED_NOTHING                    142\n# define BIO_R_MALFORMED_HOST_OR_SERVICE                  130\n# define BIO_R_NBIO_CONNECT_ERROR                         110\n# define BIO_R_NO_ACCEPT_ADDR_OR_SERVICE_SPECIFIED        143\n# define BIO_R_NO_HOSTNAME_OR_SERVICE_SPECIFIED           144\n# define BIO_R_NO_PORT_DEFINED                            113\n# define BIO_R_NO_SUCH_FILE                               128\n# define BIO_R_NULL_PARAMETER                             115\n# define BIO_R_UNABLE_TO_BIND_SOCKET                      117\n# define BIO_R_UNABLE_TO_CREATE_SOCKET                    118\n# define BIO_R_UNABLE_TO_KEEPALIVE                        137\n# define BIO_R_UNABLE_TO_LISTEN_SOCKET                    119\n# define BIO_R_UNABLE_TO_NODELAY                          138\n# define BIO_R_UNABLE_TO_REUSEADDR                        139\n# define BIO_R_UNAVAILABLE_IP_FAMILY                      145\n# define BIO_R_UNINITIALIZED                              120\n# define BIO_R_UNKNOWN_INFO_TYPE                          140\n# define BIO_R_UNSUPPORTED_IP_FAMILY                      146\n# define BIO_R_UNSUPPORTED_METHOD                         121\n# define BIO_R_UNSUPPORTED_PROTOCOL_FAMILY                131\n# define BIO_R_WRITE_TO_READ_ONLY_BIO                     126\n# define BIO_R_WSASTARTUP                                 122\n\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/include/openssl/blowfish.h",
    "content": "/*\n * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef HEADER_BLOWFISH_H\n# define HEADER_BLOWFISH_H\n\n# include <openssl/opensslconf.h>\n\n# ifndef OPENSSL_NO_BF\n# include <openssl/e_os2.h>\n# ifdef  __cplusplus\nextern \"C\" {\n# endif\n\n# define BF_ENCRYPT      1\n# define BF_DECRYPT      0\n\n/*-\n * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n * ! BF_LONG has to be at least 32 bits wide.                     !\n * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n */\n# define BF_LONG unsigned int\n\n# define BF_ROUNDS       16\n# define BF_BLOCK        8\n\ntypedef struct bf_key_st {\n    BF_LONG P[BF_ROUNDS + 2];\n    BF_LONG S[4 * 256];\n} BF_KEY;\n\nvoid BF_set_key(BF_KEY *key, int len, const unsigned char *data);\n\nvoid BF_encrypt(BF_LONG *data, const BF_KEY *key);\nvoid BF_decrypt(BF_LONG *data, const BF_KEY *key);\n\nvoid BF_ecb_encrypt(const unsigned char *in, unsigned char *out,\n                    const BF_KEY *key, int enc);\nvoid BF_cbc_encrypt(const unsigned char *in, unsigned char *out, long length,\n                    const BF_KEY *schedule, unsigned char *ivec, int enc);\nvoid BF_cfb64_encrypt(const unsigned char *in, unsigned char *out,\n                      long length, const BF_KEY *schedule,\n                      unsigned char *ivec, int *num, int enc);\nvoid BF_ofb64_encrypt(const unsigned char *in, unsigned char *out,\n                      long length, const BF_KEY *schedule,\n                      unsigned char *ivec, int *num);\nconst char *BF_options(void);\n\n# ifdef  __cplusplus\n}\n# endif\n# endif\n\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/include/openssl/bn.h",
    "content": "/*\n * Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved.\n * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef HEADER_BN_H\n# define HEADER_BN_H\n\n# include <openssl/e_os2.h>\n# ifndef OPENSSL_NO_STDIO\n#  include <stdio.h>\n# endif\n# include <openssl/opensslconf.h>\n# include <openssl/ossl_typ.h>\n# include <openssl/crypto.h>\n# include <openssl/bnerr.h>\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n/*\n * 64-bit processor with LP64 ABI\n */\n# ifdef SIXTY_FOUR_BIT_LONG\n#  define BN_ULONG        unsigned long\n#  define BN_BYTES        8\n# endif\n\n/*\n * 64-bit processor other than LP64 ABI\n */\n# ifdef SIXTY_FOUR_BIT\n#  define BN_ULONG        unsigned long long\n#  define BN_BYTES        8\n# endif\n\n# ifdef THIRTY_TWO_BIT\n#  define BN_ULONG        unsigned int\n#  define BN_BYTES        4\n# endif\n\n# define BN_BITS2       (BN_BYTES * 8)\n# define BN_BITS        (BN_BITS2 * 2)\n# define BN_TBIT        ((BN_ULONG)1 << (BN_BITS2 - 1))\n\n# define BN_FLG_MALLOCED         0x01\n# define BN_FLG_STATIC_DATA      0x02\n\n/*\n * avoid leaking exponent information through timing,\n * BN_mod_exp_mont() will call BN_mod_exp_mont_consttime,\n * BN_div() will call BN_div_no_branch,\n * BN_mod_inverse() will call bn_mod_inverse_no_branch.\n */\n# define BN_FLG_CONSTTIME        0x04\n# define BN_FLG_SECURE           0x08\n\n# if OPENSSL_API_COMPAT < 0x00908000L\n/* deprecated name for the flag */\n#  define BN_FLG_EXP_CONSTTIME BN_FLG_CONSTTIME\n#  define BN_FLG_FREE            0x8000 /* used for debugging */\n# endif\n\nvoid BN_set_flags(BIGNUM *b, int n);\nint BN_get_flags(const BIGNUM *b, int n);\n\n/* Values for |top| in BN_rand() */\n#define BN_RAND_TOP_ANY    -1\n#define BN_RAND_TOP_ONE     0\n#define BN_RAND_TOP_TWO     1\n\n/* Values for |bottom| in BN_rand() */\n#define BN_RAND_BOTTOM_ANY  0\n#define BN_RAND_BOTTOM_ODD  1\n\n/*\n * get a clone of a BIGNUM with changed flags, for *temporary* use only (the\n * two BIGNUMs cannot be used in parallel!). Also only for *read only* use. The\n * value |dest| should be a newly allocated BIGNUM obtained via BN_new() that\n * has not been otherwise initialised or used.\n */\nvoid BN_with_flags(BIGNUM *dest, const BIGNUM *b, int flags);\n\n/* Wrapper function to make using BN_GENCB easier */\nint BN_GENCB_call(BN_GENCB *cb, int a, int b);\n\nBN_GENCB *BN_GENCB_new(void);\nvoid BN_GENCB_free(BN_GENCB *cb);\n\n/* Populate a BN_GENCB structure with an \"old\"-style callback */\nvoid BN_GENCB_set_old(BN_GENCB *gencb, void (*callback) (int, int, void *),\n                      void *cb_arg);\n\n/* Populate a BN_GENCB structure with a \"new\"-style callback */\nvoid BN_GENCB_set(BN_GENCB *gencb, int (*callback) (int, int, BN_GENCB *),\n                  void *cb_arg);\n\nvoid *BN_GENCB_get_arg(BN_GENCB *cb);\n\n# define BN_prime_checks 0      /* default: select number of iterations based\n                                 * on the size of the number */\n\n/*\n * BN_prime_checks_for_size() returns the number of Miller-Rabin iterations\n * that will be done for checking that a random number is probably prime. The\n * error rate for accepting a composite number as prime depends on the size of\n * the prime |b|. The error rates used are for calculating an RSA key with 2 primes,\n * and so the level is what you would expect for a key of double the size of the\n * prime.\n *\n * This table is generated using the algorithm of FIPS PUB 186-4\n * Digital Signature Standard (DSS), section F.1, page 117.\n * (https://dx.doi.org/10.6028/NIST.FIPS.186-4)\n *\n * The following magma script was used to generate the output:\n * securitybits:=125;\n * k:=1024;\n * for t:=1 to 65 do\n *   for M:=3 to Floor(2*Sqrt(k-1)-1) do\n *     S:=0;\n *     // Sum over m\n *     for m:=3 to M do\n *       s:=0;\n *       // Sum over j\n *       for j:=2 to m do\n *         s+:=(RealField(32)!2)^-(j+(k-1)/j);\n *       end for;\n *       S+:=2^(m-(m-1)*t)*s;\n *     end for;\n *     A:=2^(k-2-M*t);\n *     B:=8*(Pi(RealField(32))^2-6)/3*2^(k-2)*S;\n *     pkt:=2.00743*Log(2)*k*2^-k*(A+B);\n *     seclevel:=Floor(-Log(2,pkt));\n *     if seclevel ge securitybits then\n *       printf \"k: %5o, security: %o bits  (t: %o, M: %o)\\n\",k,seclevel,t,M;\n *       break;\n *     end if;\n *   end for;\n *   if seclevel ge securitybits then break; end if;\n * end for;\n *\n * It can be run online at:\n * http://magma.maths.usyd.edu.au/calc\n *\n * And will output:\n * k:  1024, security: 129 bits  (t: 6, M: 23)\n *\n * k is the number of bits of the prime, securitybits is the level we want to\n * reach.\n *\n * prime length | RSA key size | # MR tests | security level\n * -------------+--------------|------------+---------------\n *  (b) >= 6394 |     >= 12788 |          3 |        256 bit\n *  (b) >= 3747 |     >=  7494 |          3 |        192 bit\n *  (b) >= 1345 |     >=  2690 |          4 |        128 bit\n *  (b) >= 1080 |     >=  2160 |          5 |        128 bit\n *  (b) >=  852 |     >=  1704 |          5 |        112 bit\n *  (b) >=  476 |     >=   952 |          5 |         80 bit\n *  (b) >=  400 |     >=   800 |          6 |         80 bit\n *  (b) >=  347 |     >=   694 |          7 |         80 bit\n *  (b) >=  308 |     >=   616 |          8 |         80 bit\n *  (b) >=   55 |     >=   110 |         27 |         64 bit\n *  (b) >=    6 |     >=    12 |         34 |         64 bit\n */\n\n# define BN_prime_checks_for_size(b) ((b) >= 3747 ?  3 : \\\n                                (b) >=  1345 ?  4 : \\\n                                (b) >=  476 ?  5 : \\\n                                (b) >=  400 ?  6 : \\\n                                (b) >=  347 ?  7 : \\\n                                (b) >=  308 ?  8 : \\\n                                (b) >=  55  ? 27 : \\\n                                /* b >= 6 */ 34)\n\n# define BN_num_bytes(a) ((BN_num_bits(a)+7)/8)\n\nint BN_abs_is_word(const BIGNUM *a, const BN_ULONG w);\nint BN_is_zero(const BIGNUM *a);\nint BN_is_one(const BIGNUM *a);\nint BN_is_word(const BIGNUM *a, const BN_ULONG w);\nint BN_is_odd(const BIGNUM *a);\n\n# define BN_one(a)       (BN_set_word((a),1))\n\nvoid BN_zero_ex(BIGNUM *a);\n\n# if OPENSSL_API_COMPAT >= 0x00908000L\n#  define BN_zero(a)      BN_zero_ex(a)\n# else\n#  define BN_zero(a)      (BN_set_word((a),0))\n# endif\n\nconst BIGNUM *BN_value_one(void);\nchar *BN_options(void);\nBN_CTX *BN_CTX_new(void);\nBN_CTX *BN_CTX_secure_new(void);\nvoid BN_CTX_free(BN_CTX *c);\nvoid BN_CTX_start(BN_CTX *ctx);\nBIGNUM *BN_CTX_get(BN_CTX *ctx);\nvoid BN_CTX_end(BN_CTX *ctx);\nint BN_rand(BIGNUM *rnd, int bits, int top, int bottom);\nint BN_priv_rand(BIGNUM *rnd, int bits, int top, int bottom);\nint BN_rand_range(BIGNUM *rnd, const BIGNUM *range);\nint BN_priv_rand_range(BIGNUM *rnd, const BIGNUM *range);\nint BN_pseudo_rand(BIGNUM *rnd, int bits, int top, int bottom);\nint BN_pseudo_rand_range(BIGNUM *rnd, const BIGNUM *range);\nint BN_num_bits(const BIGNUM *a);\nint BN_num_bits_word(BN_ULONG l);\nint BN_security_bits(int L, int N);\nBIGNUM *BN_new(void);\nBIGNUM *BN_secure_new(void);\nvoid BN_clear_free(BIGNUM *a);\nBIGNUM *BN_copy(BIGNUM *a, const BIGNUM *b);\nvoid BN_swap(BIGNUM *a, BIGNUM *b);\nBIGNUM *BN_bin2bn(const unsigned char *s, int len, BIGNUM *ret);\nint BN_bn2bin(const BIGNUM *a, unsigned char *to);\nint BN_bn2binpad(const BIGNUM *a, unsigned char *to, int tolen);\nBIGNUM *BN_lebin2bn(const unsigned char *s, int len, BIGNUM *ret);\nint BN_bn2lebinpad(const BIGNUM *a, unsigned char *to, int tolen);\nBIGNUM *BN_mpi2bn(const unsigned char *s, int len, BIGNUM *ret);\nint BN_bn2mpi(const BIGNUM *a, unsigned char *to);\nint BN_sub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b);\nint BN_usub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b);\nint BN_uadd(BIGNUM *r, const BIGNUM *a, const BIGNUM *b);\nint BN_add(BIGNUM *r, const BIGNUM *a, const BIGNUM *b);\nint BN_mul(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx);\nint BN_sqr(BIGNUM *r, const BIGNUM *a, BN_CTX *ctx);\n/** BN_set_negative sets sign of a BIGNUM\n * \\param  b  pointer to the BIGNUM object\n * \\param  n  0 if the BIGNUM b should be positive and a value != 0 otherwise\n */\nvoid BN_set_negative(BIGNUM *b, int n);\n/** BN_is_negative returns 1 if the BIGNUM is negative\n * \\param  b  pointer to the BIGNUM object\n * \\return 1 if a < 0 and 0 otherwise\n */\nint BN_is_negative(const BIGNUM *b);\n\nint BN_div(BIGNUM *dv, BIGNUM *rem, const BIGNUM *m, const BIGNUM *d,\n           BN_CTX *ctx);\n# define BN_mod(rem,m,d,ctx) BN_div(NULL,(rem),(m),(d),(ctx))\nint BN_nnmod(BIGNUM *r, const BIGNUM *m, const BIGNUM *d, BN_CTX *ctx);\nint BN_mod_add(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *m,\n               BN_CTX *ctx);\nint BN_mod_add_quick(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,\n                     const BIGNUM *m);\nint BN_mod_sub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *m,\n               BN_CTX *ctx);\nint BN_mod_sub_quick(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,\n                     const BIGNUM *m);\nint BN_mod_mul(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *m,\n               BN_CTX *ctx);\nint BN_mod_sqr(BIGNUM *r, const BIGNUM *a, const BIGNUM *m, BN_CTX *ctx);\nint BN_mod_lshift1(BIGNUM *r, const BIGNUM *a, const BIGNUM *m, BN_CTX *ctx);\nint BN_mod_lshift1_quick(BIGNUM *r, const BIGNUM *a, const BIGNUM *m);\nint BN_mod_lshift(BIGNUM *r, const BIGNUM *a, int n, const BIGNUM *m,\n                  BN_CTX *ctx);\nint BN_mod_lshift_quick(BIGNUM *r, const BIGNUM *a, int n, const BIGNUM *m);\n\nBN_ULONG BN_mod_word(const BIGNUM *a, BN_ULONG w);\nBN_ULONG BN_div_word(BIGNUM *a, BN_ULONG w);\nint BN_mul_word(BIGNUM *a, BN_ULONG w);\nint BN_add_word(BIGNUM *a, BN_ULONG w);\nint BN_sub_word(BIGNUM *a, BN_ULONG w);\nint BN_set_word(BIGNUM *a, BN_ULONG w);\nBN_ULONG BN_get_word(const BIGNUM *a);\n\nint BN_cmp(const BIGNUM *a, const BIGNUM *b);\nvoid BN_free(BIGNUM *a);\nint BN_is_bit_set(const BIGNUM *a, int n);\nint BN_lshift(BIGNUM *r, const BIGNUM *a, int n);\nint BN_lshift1(BIGNUM *r, const BIGNUM *a);\nint BN_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx);\n\nint BN_mod_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,\n               const BIGNUM *m, BN_CTX *ctx);\nint BN_mod_exp_mont(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,\n                    const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx);\nint BN_mod_exp_mont_consttime(BIGNUM *rr, const BIGNUM *a, const BIGNUM *p,\n                              const BIGNUM *m, BN_CTX *ctx,\n                              BN_MONT_CTX *in_mont);\nint BN_mod_exp_mont_word(BIGNUM *r, BN_ULONG a, const BIGNUM *p,\n                         const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx);\nint BN_mod_exp2_mont(BIGNUM *r, const BIGNUM *a1, const BIGNUM *p1,\n                     const BIGNUM *a2, const BIGNUM *p2, const BIGNUM *m,\n                     BN_CTX *ctx, BN_MONT_CTX *m_ctx);\nint BN_mod_exp_simple(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,\n                      const BIGNUM *m, BN_CTX *ctx);\n\nint BN_mask_bits(BIGNUM *a, int n);\n# ifndef OPENSSL_NO_STDIO\nint BN_print_fp(FILE *fp, const BIGNUM *a);\n# endif\nint BN_print(BIO *bio, const BIGNUM *a);\nint BN_reciprocal(BIGNUM *r, const BIGNUM *m, int len, BN_CTX *ctx);\nint BN_rshift(BIGNUM *r, const BIGNUM *a, int n);\nint BN_rshift1(BIGNUM *r, const BIGNUM *a);\nvoid BN_clear(BIGNUM *a);\nBIGNUM *BN_dup(const BIGNUM *a);\nint BN_ucmp(const BIGNUM *a, const BIGNUM *b);\nint BN_set_bit(BIGNUM *a, int n);\nint BN_clear_bit(BIGNUM *a, int n);\nchar *BN_bn2hex(const BIGNUM *a);\nchar *BN_bn2dec(const BIGNUM *a);\nint BN_hex2bn(BIGNUM **a, const char *str);\nint BN_dec2bn(BIGNUM **a, const char *str);\nint BN_asc2bn(BIGNUM **a, const char *str);\nint BN_gcd(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx);\nint BN_kronecker(const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx); /* returns\n                                                                  * -2 for\n                                                                  * error */\nBIGNUM *BN_mod_inverse(BIGNUM *ret,\n                       const BIGNUM *a, const BIGNUM *n, BN_CTX *ctx);\nBIGNUM *BN_mod_sqrt(BIGNUM *ret,\n                    const BIGNUM *a, const BIGNUM *n, BN_CTX *ctx);\n\nvoid BN_consttime_swap(BN_ULONG swap, BIGNUM *a, BIGNUM *b, int nwords);\n\n/* Deprecated versions */\nDEPRECATEDIN_0_9_8(BIGNUM *BN_generate_prime(BIGNUM *ret, int bits, int safe,\n                                             const BIGNUM *add,\n                                             const BIGNUM *rem,\n                                             void (*callback) (int, int,\n                                                               void *),\n                                             void *cb_arg))\nDEPRECATEDIN_0_9_8(int\n                   BN_is_prime(const BIGNUM *p, int nchecks,\n                               void (*callback) (int, int, void *),\n                               BN_CTX *ctx, void *cb_arg))\nDEPRECATEDIN_0_9_8(int\n                   BN_is_prime_fasttest(const BIGNUM *p, int nchecks,\n                                        void (*callback) (int, int, void *),\n                                        BN_CTX *ctx, void *cb_arg,\n                                        int do_trial_division))\n\n/* Newer versions */\nint BN_generate_prime_ex(BIGNUM *ret, int bits, int safe, const BIGNUM *add,\n                         const BIGNUM *rem, BN_GENCB *cb);\nint BN_is_prime_ex(const BIGNUM *p, int nchecks, BN_CTX *ctx, BN_GENCB *cb);\nint BN_is_prime_fasttest_ex(const BIGNUM *p, int nchecks, BN_CTX *ctx,\n                            int do_trial_division, BN_GENCB *cb);\n\nint BN_X931_generate_Xpq(BIGNUM *Xp, BIGNUM *Xq, int nbits, BN_CTX *ctx);\n\nint BN_X931_derive_prime_ex(BIGNUM *p, BIGNUM *p1, BIGNUM *p2,\n                            const BIGNUM *Xp, const BIGNUM *Xp1,\n                            const BIGNUM *Xp2, const BIGNUM *e, BN_CTX *ctx,\n                            BN_GENCB *cb);\nint BN_X931_generate_prime_ex(BIGNUM *p, BIGNUM *p1, BIGNUM *p2, BIGNUM *Xp1,\n                              BIGNUM *Xp2, const BIGNUM *Xp, const BIGNUM *e,\n                              BN_CTX *ctx, BN_GENCB *cb);\n\nBN_MONT_CTX *BN_MONT_CTX_new(void);\nint BN_mod_mul_montgomery(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,\n                          BN_MONT_CTX *mont, BN_CTX *ctx);\nint BN_to_montgomery(BIGNUM *r, const BIGNUM *a, BN_MONT_CTX *mont,\n                     BN_CTX *ctx);\nint BN_from_montgomery(BIGNUM *r, const BIGNUM *a, BN_MONT_CTX *mont,\n                       BN_CTX *ctx);\nvoid BN_MONT_CTX_free(BN_MONT_CTX *mont);\nint BN_MONT_CTX_set(BN_MONT_CTX *mont, const BIGNUM *mod, BN_CTX *ctx);\nBN_MONT_CTX *BN_MONT_CTX_copy(BN_MONT_CTX *to, BN_MONT_CTX *from);\nBN_MONT_CTX *BN_MONT_CTX_set_locked(BN_MONT_CTX **pmont, CRYPTO_RWLOCK *lock,\n                                    const BIGNUM *mod, BN_CTX *ctx);\n\n/* BN_BLINDING flags */\n# define BN_BLINDING_NO_UPDATE   0x00000001\n# define BN_BLINDING_NO_RECREATE 0x00000002\n\nBN_BLINDING *BN_BLINDING_new(const BIGNUM *A, const BIGNUM *Ai, BIGNUM *mod);\nvoid BN_BLINDING_free(BN_BLINDING *b);\nint BN_BLINDING_update(BN_BLINDING *b, BN_CTX *ctx);\nint BN_BLINDING_convert(BIGNUM *n, BN_BLINDING *b, BN_CTX *ctx);\nint BN_BLINDING_invert(BIGNUM *n, BN_BLINDING *b, BN_CTX *ctx);\nint BN_BLINDING_convert_ex(BIGNUM *n, BIGNUM *r, BN_BLINDING *b, BN_CTX *);\nint BN_BLINDING_invert_ex(BIGNUM *n, const BIGNUM *r, BN_BLINDING *b,\n                          BN_CTX *);\n\nint BN_BLINDING_is_current_thread(BN_BLINDING *b);\nvoid BN_BLINDING_set_current_thread(BN_BLINDING *b);\nint BN_BLINDING_lock(BN_BLINDING *b);\nint BN_BLINDING_unlock(BN_BLINDING *b);\n\nunsigned long BN_BLINDING_get_flags(const BN_BLINDING *);\nvoid BN_BLINDING_set_flags(BN_BLINDING *, unsigned long);\nBN_BLINDING *BN_BLINDING_create_param(BN_BLINDING *b,\n                                      const BIGNUM *e, BIGNUM *m, BN_CTX *ctx,\n                                      int (*bn_mod_exp) (BIGNUM *r,\n                                                         const BIGNUM *a,\n                                                         const BIGNUM *p,\n                                                         const BIGNUM *m,\n                                                         BN_CTX *ctx,\n                                                         BN_MONT_CTX *m_ctx),\n                                      BN_MONT_CTX *m_ctx);\n\nDEPRECATEDIN_0_9_8(void BN_set_params(int mul, int high, int low, int mont))\nDEPRECATEDIN_0_9_8(int BN_get_params(int which)) /* 0, mul, 1 high, 2 low, 3\n                                                  * mont */\n\nBN_RECP_CTX *BN_RECP_CTX_new(void);\nvoid BN_RECP_CTX_free(BN_RECP_CTX *recp);\nint BN_RECP_CTX_set(BN_RECP_CTX *recp, const BIGNUM *rdiv, BN_CTX *ctx);\nint BN_mod_mul_reciprocal(BIGNUM *r, const BIGNUM *x, const BIGNUM *y,\n                          BN_RECP_CTX *recp, BN_CTX *ctx);\nint BN_mod_exp_recp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,\n                    const BIGNUM *m, BN_CTX *ctx);\nint BN_div_recp(BIGNUM *dv, BIGNUM *rem, const BIGNUM *m,\n                BN_RECP_CTX *recp, BN_CTX *ctx);\n\n# ifndef OPENSSL_NO_EC2M\n\n/*\n * Functions for arithmetic over binary polynomials represented by BIGNUMs.\n * The BIGNUM::neg property of BIGNUMs representing binary polynomials is\n * ignored. Note that input arguments are not const so that their bit arrays\n * can be expanded to the appropriate size if needed.\n */\n\n/*\n * r = a + b\n */\nint BN_GF2m_add(BIGNUM *r, const BIGNUM *a, const BIGNUM *b);\n#  define BN_GF2m_sub(r, a, b) BN_GF2m_add(r, a, b)\n/*\n * r=a mod p\n */\nint BN_GF2m_mod(BIGNUM *r, const BIGNUM *a, const BIGNUM *p);\n/* r = (a * b) mod p */\nint BN_GF2m_mod_mul(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,\n                    const BIGNUM *p, BN_CTX *ctx);\n/* r = (a * a) mod p */\nint BN_GF2m_mod_sqr(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx);\n/* r = (1 / b) mod p */\nint BN_GF2m_mod_inv(BIGNUM *r, const BIGNUM *b, const BIGNUM *p, BN_CTX *ctx);\n/* r = (a / b) mod p */\nint BN_GF2m_mod_div(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,\n                    const BIGNUM *p, BN_CTX *ctx);\n/* r = (a ^ b) mod p */\nint BN_GF2m_mod_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,\n                    const BIGNUM *p, BN_CTX *ctx);\n/* r = sqrt(a) mod p */\nint BN_GF2m_mod_sqrt(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,\n                     BN_CTX *ctx);\n/* r^2 + r = a mod p */\nint BN_GF2m_mod_solve_quad(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,\n                           BN_CTX *ctx);\n#  define BN_GF2m_cmp(a, b) BN_ucmp((a), (b))\n/*-\n * Some functions allow for representation of the irreducible polynomials\n * as an unsigned int[], say p.  The irreducible f(t) is then of the form:\n *     t^p[0] + t^p[1] + ... + t^p[k]\n * where m = p[0] > p[1] > ... > p[k] = 0.\n */\n/* r = a mod p */\nint BN_GF2m_mod_arr(BIGNUM *r, const BIGNUM *a, const int p[]);\n/* r = (a * b) mod p */\nint BN_GF2m_mod_mul_arr(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,\n                        const int p[], BN_CTX *ctx);\n/* r = (a * a) mod p */\nint BN_GF2m_mod_sqr_arr(BIGNUM *r, const BIGNUM *a, const int p[],\n                        BN_CTX *ctx);\n/* r = (1 / b) mod p */\nint BN_GF2m_mod_inv_arr(BIGNUM *r, const BIGNUM *b, const int p[],\n                        BN_CTX *ctx);\n/* r = (a / b) mod p */\nint BN_GF2m_mod_div_arr(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,\n                        const int p[], BN_CTX *ctx);\n/* r = (a ^ b) mod p */\nint BN_GF2m_mod_exp_arr(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,\n                        const int p[], BN_CTX *ctx);\n/* r = sqrt(a) mod p */\nint BN_GF2m_mod_sqrt_arr(BIGNUM *r, const BIGNUM *a,\n                         const int p[], BN_CTX *ctx);\n/* r^2 + r = a mod p */\nint BN_GF2m_mod_solve_quad_arr(BIGNUM *r, const BIGNUM *a,\n                               const int p[], BN_CTX *ctx);\nint BN_GF2m_poly2arr(const BIGNUM *a, int p[], int max);\nint BN_GF2m_arr2poly(const int p[], BIGNUM *a);\n\n# endif\n\n/*\n * faster mod functions for the 'NIST primes' 0 <= a < p^2\n */\nint BN_nist_mod_192(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx);\nint BN_nist_mod_224(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx);\nint BN_nist_mod_256(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx);\nint BN_nist_mod_384(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx);\nint BN_nist_mod_521(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx);\n\nconst BIGNUM *BN_get0_nist_prime_192(void);\nconst BIGNUM *BN_get0_nist_prime_224(void);\nconst BIGNUM *BN_get0_nist_prime_256(void);\nconst BIGNUM *BN_get0_nist_prime_384(void);\nconst BIGNUM *BN_get0_nist_prime_521(void);\n\nint (*BN_nist_mod_func(const BIGNUM *p)) (BIGNUM *r, const BIGNUM *a,\n                                          const BIGNUM *field, BN_CTX *ctx);\n\nint BN_generate_dsa_nonce(BIGNUM *out, const BIGNUM *range,\n                          const BIGNUM *priv, const unsigned char *message,\n                          size_t message_len, BN_CTX *ctx);\n\n/* Primes from RFC 2409 */\nBIGNUM *BN_get_rfc2409_prime_768(BIGNUM *bn);\nBIGNUM *BN_get_rfc2409_prime_1024(BIGNUM *bn);\n\n/* Primes from RFC 3526 */\nBIGNUM *BN_get_rfc3526_prime_1536(BIGNUM *bn);\nBIGNUM *BN_get_rfc3526_prime_2048(BIGNUM *bn);\nBIGNUM *BN_get_rfc3526_prime_3072(BIGNUM *bn);\nBIGNUM *BN_get_rfc3526_prime_4096(BIGNUM *bn);\nBIGNUM *BN_get_rfc3526_prime_6144(BIGNUM *bn);\nBIGNUM *BN_get_rfc3526_prime_8192(BIGNUM *bn);\n\n# if OPENSSL_API_COMPAT < 0x10100000L\n#  define get_rfc2409_prime_768 BN_get_rfc2409_prime_768\n#  define get_rfc2409_prime_1024 BN_get_rfc2409_prime_1024\n#  define get_rfc3526_prime_1536 BN_get_rfc3526_prime_1536\n#  define get_rfc3526_prime_2048 BN_get_rfc3526_prime_2048\n#  define get_rfc3526_prime_3072 BN_get_rfc3526_prime_3072\n#  define get_rfc3526_prime_4096 BN_get_rfc3526_prime_4096\n#  define get_rfc3526_prime_6144 BN_get_rfc3526_prime_6144\n#  define get_rfc3526_prime_8192 BN_get_rfc3526_prime_8192\n# endif\n\nint BN_bntest_rand(BIGNUM *rnd, int bits, int top, int bottom);\n\n\n# ifdef  __cplusplus\n}\n# endif\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/include/openssl/bnerr.h",
    "content": "/*\n * Generated by util/mkerr.pl DO NOT EDIT\n * Copyright 1995-2019 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef HEADER_BNERR_H\n# define HEADER_BNERR_H\n\n# ifndef HEADER_SYMHACKS_H\n#  include <openssl/symhacks.h>\n# endif\n\n# ifdef  __cplusplus\nextern \"C\"\n# endif\nint ERR_load_BN_strings(void);\n\n/*\n * BN function codes.\n */\n# define BN_F_BNRAND                                      127\n# define BN_F_BNRAND_RANGE                                138\n# define BN_F_BN_BLINDING_CONVERT_EX                      100\n# define BN_F_BN_BLINDING_CREATE_PARAM                    128\n# define BN_F_BN_BLINDING_INVERT_EX                       101\n# define BN_F_BN_BLINDING_NEW                             102\n# define BN_F_BN_BLINDING_UPDATE                          103\n# define BN_F_BN_BN2DEC                                   104\n# define BN_F_BN_BN2HEX                                   105\n# define BN_F_BN_COMPUTE_WNAF                             142\n# define BN_F_BN_CTX_GET                                  116\n# define BN_F_BN_CTX_NEW                                  106\n# define BN_F_BN_CTX_START                                129\n# define BN_F_BN_DIV                                      107\n# define BN_F_BN_DIV_RECP                                 130\n# define BN_F_BN_EXP                                      123\n# define BN_F_BN_EXPAND_INTERNAL                          120\n# define BN_F_BN_GENCB_NEW                                143\n# define BN_F_BN_GENERATE_DSA_NONCE                       140\n# define BN_F_BN_GENERATE_PRIME_EX                        141\n# define BN_F_BN_GF2M_MOD                                 131\n# define BN_F_BN_GF2M_MOD_EXP                             132\n# define BN_F_BN_GF2M_MOD_MUL                             133\n# define BN_F_BN_GF2M_MOD_SOLVE_QUAD                      134\n# define BN_F_BN_GF2M_MOD_SOLVE_QUAD_ARR                  135\n# define BN_F_BN_GF2M_MOD_SQR                             136\n# define BN_F_BN_GF2M_MOD_SQRT                            137\n# define BN_F_BN_LSHIFT                                   145\n# define BN_F_BN_MOD_EXP2_MONT                            118\n# define BN_F_BN_MOD_EXP_MONT                             109\n# define BN_F_BN_MOD_EXP_MONT_CONSTTIME                   124\n# define BN_F_BN_MOD_EXP_MONT_WORD                        117\n# define BN_F_BN_MOD_EXP_RECP                             125\n# define BN_F_BN_MOD_EXP_SIMPLE                           126\n# define BN_F_BN_MOD_INVERSE                              110\n# define BN_F_BN_MOD_INVERSE_NO_BRANCH                    139\n# define BN_F_BN_MOD_LSHIFT_QUICK                         119\n# define BN_F_BN_MOD_SQRT                                 121\n# define BN_F_BN_MONT_CTX_NEW                             149\n# define BN_F_BN_MPI2BN                                   112\n# define BN_F_BN_NEW                                      113\n# define BN_F_BN_POOL_GET                                 147\n# define BN_F_BN_RAND                                     114\n# define BN_F_BN_RAND_RANGE                               122\n# define BN_F_BN_RECP_CTX_NEW                             150\n# define BN_F_BN_RSHIFT                                   146\n# define BN_F_BN_SET_WORDS                                144\n# define BN_F_BN_STACK_PUSH                               148\n# define BN_F_BN_USUB                                     115\n\n/*\n * BN reason codes.\n */\n# define BN_R_ARG2_LT_ARG3                                100\n# define BN_R_BAD_RECIPROCAL                              101\n# define BN_R_BIGNUM_TOO_LONG                             114\n# define BN_R_BITS_TOO_SMALL                              118\n# define BN_R_CALLED_WITH_EVEN_MODULUS                    102\n# define BN_R_DIV_BY_ZERO                                 103\n# define BN_R_ENCODING_ERROR                              104\n# define BN_R_EXPAND_ON_STATIC_BIGNUM_DATA                105\n# define BN_R_INPUT_NOT_REDUCED                           110\n# define BN_R_INVALID_LENGTH                              106\n# define BN_R_INVALID_RANGE                               115\n# define BN_R_INVALID_SHIFT                               119\n# define BN_R_NOT_A_SQUARE                                111\n# define BN_R_NOT_INITIALIZED                             107\n# define BN_R_NO_INVERSE                                  108\n# define BN_R_NO_SOLUTION                                 116\n# define BN_R_PRIVATE_KEY_TOO_LARGE                       117\n# define BN_R_P_IS_NOT_PRIME                              112\n# define BN_R_TOO_MANY_ITERATIONS                         113\n# define BN_R_TOO_MANY_TEMPORARY_VARIABLES                109\n\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/include/openssl/buffer.h",
    "content": "/*\n * Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef HEADER_BUFFER_H\n# define HEADER_BUFFER_H\n\n# include <openssl/ossl_typ.h>\n# ifndef HEADER_CRYPTO_H\n#  include <openssl/crypto.h>\n# endif\n# include <openssl/buffererr.h>\n\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n# include <stddef.h>\n# include <sys/types.h>\n\n/*\n * These names are outdated as of OpenSSL 1.1; a future release\n * will move them to be deprecated.\n */\n# define BUF_strdup(s) OPENSSL_strdup(s)\n# define BUF_strndup(s, size) OPENSSL_strndup(s, size)\n# define BUF_memdup(data, size) OPENSSL_memdup(data, size)\n# define BUF_strlcpy(dst, src, size)  OPENSSL_strlcpy(dst, src, size)\n# define BUF_strlcat(dst, src, size) OPENSSL_strlcat(dst, src, size)\n# define BUF_strnlen(str, maxlen) OPENSSL_strnlen(str, maxlen)\n\nstruct buf_mem_st {\n    size_t length;              /* current number of bytes */\n    char *data;\n    size_t max;                 /* size of buffer */\n    unsigned long flags;\n};\n\n# define BUF_MEM_FLAG_SECURE  0x01\n\nBUF_MEM *BUF_MEM_new(void);\nBUF_MEM *BUF_MEM_new_ex(unsigned long flags);\nvoid BUF_MEM_free(BUF_MEM *a);\nsize_t BUF_MEM_grow(BUF_MEM *str, size_t len);\nsize_t BUF_MEM_grow_clean(BUF_MEM *str, size_t len);\nvoid BUF_reverse(unsigned char *out, const unsigned char *in, size_t siz);\n\n\n# ifdef  __cplusplus\n}\n# endif\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/include/openssl/buffererr.h",
    "content": "/*\n * Generated by util/mkerr.pl DO NOT EDIT\n * Copyright 1995-2019 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef HEADER_BUFERR_H\n# define HEADER_BUFERR_H\n\n# ifndef HEADER_SYMHACKS_H\n#  include <openssl/symhacks.h>\n# endif\n\n# ifdef  __cplusplus\nextern \"C\"\n# endif\nint ERR_load_BUF_strings(void);\n\n/*\n * BUF function codes.\n */\n# define BUF_F_BUF_MEM_GROW                               100\n# define BUF_F_BUF_MEM_GROW_CLEAN                         105\n# define BUF_F_BUF_MEM_NEW                                101\n\n/*\n * BUF reason codes.\n */\n\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/include/openssl/camellia.h",
    "content": "/*\n * Copyright 2006-2016 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef HEADER_CAMELLIA_H\n# define HEADER_CAMELLIA_H\n\n# include <openssl/opensslconf.h>\n\n# ifndef OPENSSL_NO_CAMELLIA\n# include <stddef.h>\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n# define CAMELLIA_ENCRYPT        1\n# define CAMELLIA_DECRYPT        0\n\n/*\n * Because array size can't be a const in C, the following two are macros.\n * Both sizes are in bytes.\n */\n\n/* This should be a hidden type, but EVP requires that the size be known */\n\n# define CAMELLIA_BLOCK_SIZE 16\n# define CAMELLIA_TABLE_BYTE_LEN 272\n# define CAMELLIA_TABLE_WORD_LEN (CAMELLIA_TABLE_BYTE_LEN / 4)\n\ntypedef unsigned int KEY_TABLE_TYPE[CAMELLIA_TABLE_WORD_LEN]; /* to match\n                                                               * with WORD */\n\nstruct camellia_key_st {\n    union {\n        double d;               /* ensures 64-bit align */\n        KEY_TABLE_TYPE rd_key;\n    } u;\n    int grand_rounds;\n};\ntypedef struct camellia_key_st CAMELLIA_KEY;\n\nint Camellia_set_key(const unsigned char *userKey, const int bits,\n                     CAMELLIA_KEY *key);\n\nvoid Camellia_encrypt(const unsigned char *in, unsigned char *out,\n                      const CAMELLIA_KEY *key);\nvoid Camellia_decrypt(const unsigned char *in, unsigned char *out,\n                      const CAMELLIA_KEY *key);\n\nvoid Camellia_ecb_encrypt(const unsigned char *in, unsigned char *out,\n                          const CAMELLIA_KEY *key, const int enc);\nvoid Camellia_cbc_encrypt(const unsigned char *in, unsigned char *out,\n                          size_t length, const CAMELLIA_KEY *key,\n                          unsigned char *ivec, const int enc);\nvoid Camellia_cfb128_encrypt(const unsigned char *in, unsigned char *out,\n                             size_t length, const CAMELLIA_KEY *key,\n                             unsigned char *ivec, int *num, const int enc);\nvoid Camellia_cfb1_encrypt(const unsigned char *in, unsigned char *out,\n                           size_t length, const CAMELLIA_KEY *key,\n                           unsigned char *ivec, int *num, const int enc);\nvoid Camellia_cfb8_encrypt(const unsigned char *in, unsigned char *out,\n                           size_t length, const CAMELLIA_KEY *key,\n                           unsigned char *ivec, int *num, const int enc);\nvoid Camellia_ofb128_encrypt(const unsigned char *in, unsigned char *out,\n                             size_t length, const CAMELLIA_KEY *key,\n                             unsigned char *ivec, int *num);\nvoid Camellia_ctr128_encrypt(const unsigned char *in, unsigned char *out,\n                             size_t length, const CAMELLIA_KEY *key,\n                             unsigned char ivec[CAMELLIA_BLOCK_SIZE],\n                             unsigned char ecount_buf[CAMELLIA_BLOCK_SIZE],\n                             unsigned int *num);\n\n# ifdef  __cplusplus\n}\n# endif\n# endif\n\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/include/openssl/cast.h",
    "content": "/*\n * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef HEADER_CAST_H\n# define HEADER_CAST_H\n\n# include <openssl/opensslconf.h>\n\n# ifndef OPENSSL_NO_CAST\n# ifdef  __cplusplus\nextern \"C\" {\n# endif\n\n# define CAST_ENCRYPT    1\n# define CAST_DECRYPT    0\n\n# define CAST_LONG unsigned int\n\n# define CAST_BLOCK      8\n# define CAST_KEY_LENGTH 16\n\ntypedef struct cast_key_st {\n    CAST_LONG data[32];\n    int short_key;              /* Use reduced rounds for short key */\n} CAST_KEY;\n\nvoid CAST_set_key(CAST_KEY *key, int len, const unsigned char *data);\nvoid CAST_ecb_encrypt(const unsigned char *in, unsigned char *out,\n                      const CAST_KEY *key, int enc);\nvoid CAST_encrypt(CAST_LONG *data, const CAST_KEY *key);\nvoid CAST_decrypt(CAST_LONG *data, const CAST_KEY *key);\nvoid CAST_cbc_encrypt(const unsigned char *in, unsigned char *out,\n                      long length, const CAST_KEY *ks, unsigned char *iv,\n                      int enc);\nvoid CAST_cfb64_encrypt(const unsigned char *in, unsigned char *out,\n                        long length, const CAST_KEY *schedule,\n                        unsigned char *ivec, int *num, int enc);\nvoid CAST_ofb64_encrypt(const unsigned char *in, unsigned char *out,\n                        long length, const CAST_KEY *schedule,\n                        unsigned char *ivec, int *num);\n\n# ifdef  __cplusplus\n}\n# endif\n# endif\n\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/include/openssl/cmac.h",
    "content": "/*\n * Copyright 2010-2016 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef HEADER_CMAC_H\n# define HEADER_CMAC_H\n\n# ifndef OPENSSL_NO_CMAC\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n# include <openssl/evp.h>\n\n/* Opaque */\ntypedef struct CMAC_CTX_st CMAC_CTX;\n\nCMAC_CTX *CMAC_CTX_new(void);\nvoid CMAC_CTX_cleanup(CMAC_CTX *ctx);\nvoid CMAC_CTX_free(CMAC_CTX *ctx);\nEVP_CIPHER_CTX *CMAC_CTX_get0_cipher_ctx(CMAC_CTX *ctx);\nint CMAC_CTX_copy(CMAC_CTX *out, const CMAC_CTX *in);\n\nint CMAC_Init(CMAC_CTX *ctx, const void *key, size_t keylen,\n              const EVP_CIPHER *cipher, ENGINE *impl);\nint CMAC_Update(CMAC_CTX *ctx, const void *data, size_t dlen);\nint CMAC_Final(CMAC_CTX *ctx, unsigned char *out, size_t *poutlen);\nint CMAC_resume(CMAC_CTX *ctx);\n\n#ifdef  __cplusplus\n}\n#endif\n\n# endif\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/include/openssl/cms.h",
    "content": "/*\n * Copyright 2008-2019 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef HEADER_CMS_H\n# define HEADER_CMS_H\n\n# include <openssl/opensslconf.h>\n\n# ifndef OPENSSL_NO_CMS\n# include <openssl/x509.h>\n# include <openssl/x509v3.h>\n# include <openssl/cmserr.h>\n# ifdef __cplusplus\nextern \"C\" {\n# endif\n\ntypedef struct CMS_ContentInfo_st CMS_ContentInfo;\ntypedef struct CMS_SignerInfo_st CMS_SignerInfo;\ntypedef struct CMS_CertificateChoices CMS_CertificateChoices;\ntypedef struct CMS_RevocationInfoChoice_st CMS_RevocationInfoChoice;\ntypedef struct CMS_RecipientInfo_st CMS_RecipientInfo;\ntypedef struct CMS_ReceiptRequest_st CMS_ReceiptRequest;\ntypedef struct CMS_Receipt_st CMS_Receipt;\ntypedef struct CMS_RecipientEncryptedKey_st CMS_RecipientEncryptedKey;\ntypedef struct CMS_OtherKeyAttribute_st CMS_OtherKeyAttribute;\n\nDEFINE_STACK_OF(CMS_SignerInfo)\nDEFINE_STACK_OF(CMS_RecipientEncryptedKey)\nDEFINE_STACK_OF(CMS_RecipientInfo)\nDEFINE_STACK_OF(CMS_RevocationInfoChoice)\nDECLARE_ASN1_FUNCTIONS(CMS_ContentInfo)\nDECLARE_ASN1_FUNCTIONS(CMS_ReceiptRequest)\nDECLARE_ASN1_PRINT_FUNCTION(CMS_ContentInfo)\n\n# define CMS_SIGNERINFO_ISSUER_SERIAL    0\n# define CMS_SIGNERINFO_KEYIDENTIFIER    1\n\n# define CMS_RECIPINFO_NONE              -1\n# define CMS_RECIPINFO_TRANS             0\n# define CMS_RECIPINFO_AGREE             1\n# define CMS_RECIPINFO_KEK               2\n# define CMS_RECIPINFO_PASS              3\n# define CMS_RECIPINFO_OTHER             4\n\n/* S/MIME related flags */\n\n# define CMS_TEXT                        0x1\n# define CMS_NOCERTS                     0x2\n# define CMS_NO_CONTENT_VERIFY           0x4\n# define CMS_NO_ATTR_VERIFY              0x8\n# define CMS_NOSIGS                      \\\n                        (CMS_NO_CONTENT_VERIFY|CMS_NO_ATTR_VERIFY)\n# define CMS_NOINTERN                    0x10\n# define CMS_NO_SIGNER_CERT_VERIFY       0x20\n# define CMS_NOVERIFY                    0x20\n# define CMS_DETACHED                    0x40\n# define CMS_BINARY                      0x80\n# define CMS_NOATTR                      0x100\n# define CMS_NOSMIMECAP                  0x200\n# define CMS_NOOLDMIMETYPE               0x400\n# define CMS_CRLFEOL                     0x800\n# define CMS_STREAM                      0x1000\n# define CMS_NOCRL                       0x2000\n# define CMS_PARTIAL                     0x4000\n# define CMS_REUSE_DIGEST                0x8000\n# define CMS_USE_KEYID                   0x10000\n# define CMS_DEBUG_DECRYPT               0x20000\n# define CMS_KEY_PARAM                   0x40000\n# define CMS_ASCIICRLF                   0x80000\n\nconst ASN1_OBJECT *CMS_get0_type(const CMS_ContentInfo *cms);\n\nBIO *CMS_dataInit(CMS_ContentInfo *cms, BIO *icont);\nint CMS_dataFinal(CMS_ContentInfo *cms, BIO *bio);\n\nASN1_OCTET_STRING **CMS_get0_content(CMS_ContentInfo *cms);\nint CMS_is_detached(CMS_ContentInfo *cms);\nint CMS_set_detached(CMS_ContentInfo *cms, int detached);\n\n# ifdef HEADER_PEM_H\nDECLARE_PEM_rw_const(CMS, CMS_ContentInfo)\n# endif\nint CMS_stream(unsigned char ***boundary, CMS_ContentInfo *cms);\nCMS_ContentInfo *d2i_CMS_bio(BIO *bp, CMS_ContentInfo **cms);\nint i2d_CMS_bio(BIO *bp, CMS_ContentInfo *cms);\n\nBIO *BIO_new_CMS(BIO *out, CMS_ContentInfo *cms);\nint i2d_CMS_bio_stream(BIO *out, CMS_ContentInfo *cms, BIO *in, int flags);\nint PEM_write_bio_CMS_stream(BIO *out, CMS_ContentInfo *cms, BIO *in,\n                             int flags);\nCMS_ContentInfo *SMIME_read_CMS(BIO *bio, BIO **bcont);\nint SMIME_write_CMS(BIO *bio, CMS_ContentInfo *cms, BIO *data, int flags);\n\nint CMS_final(CMS_ContentInfo *cms, BIO *data, BIO *dcont,\n              unsigned int flags);\n\nCMS_ContentInfo *CMS_sign(X509 *signcert, EVP_PKEY *pkey,\n                          STACK_OF(X509) *certs, BIO *data,\n                          unsigned int flags);\n\nCMS_ContentInfo *CMS_sign_receipt(CMS_SignerInfo *si,\n                                  X509 *signcert, EVP_PKEY *pkey,\n                                  STACK_OF(X509) *certs, unsigned int flags);\n\nint CMS_data(CMS_ContentInfo *cms, BIO *out, unsigned int flags);\nCMS_ContentInfo *CMS_data_create(BIO *in, unsigned int flags);\n\nint CMS_digest_verify(CMS_ContentInfo *cms, BIO *dcont, BIO *out,\n                      unsigned int flags);\nCMS_ContentInfo *CMS_digest_create(BIO *in, const EVP_MD *md,\n                                   unsigned int flags);\n\nint CMS_EncryptedData_decrypt(CMS_ContentInfo *cms,\n                              const unsigned char *key, size_t keylen,\n                              BIO *dcont, BIO *out, unsigned int flags);\n\nCMS_ContentInfo *CMS_EncryptedData_encrypt(BIO *in, const EVP_CIPHER *cipher,\n                                           const unsigned char *key,\n                                           size_t keylen, unsigned int flags);\n\nint CMS_EncryptedData_set1_key(CMS_ContentInfo *cms, const EVP_CIPHER *ciph,\n                               const unsigned char *key, size_t keylen);\n\nint CMS_verify(CMS_ContentInfo *cms, STACK_OF(X509) *certs,\n               X509_STORE *store, BIO *dcont, BIO *out, unsigned int flags);\n\nint CMS_verify_receipt(CMS_ContentInfo *rcms, CMS_ContentInfo *ocms,\n                       STACK_OF(X509) *certs,\n                       X509_STORE *store, unsigned int flags);\n\nSTACK_OF(X509) *CMS_get0_signers(CMS_ContentInfo *cms);\n\nCMS_ContentInfo *CMS_encrypt(STACK_OF(X509) *certs, BIO *in,\n                             const EVP_CIPHER *cipher, unsigned int flags);\n\nint CMS_decrypt(CMS_ContentInfo *cms, EVP_PKEY *pkey, X509 *cert,\n                BIO *dcont, BIO *out, unsigned int flags);\n\nint CMS_decrypt_set1_pkey(CMS_ContentInfo *cms, EVP_PKEY *pk, X509 *cert);\nint CMS_decrypt_set1_key(CMS_ContentInfo *cms,\n                         unsigned char *key, size_t keylen,\n                         const unsigned char *id, size_t idlen);\nint CMS_decrypt_set1_password(CMS_ContentInfo *cms,\n                              unsigned char *pass, ossl_ssize_t passlen);\n\nSTACK_OF(CMS_RecipientInfo) *CMS_get0_RecipientInfos(CMS_ContentInfo *cms);\nint CMS_RecipientInfo_type(CMS_RecipientInfo *ri);\nEVP_PKEY_CTX *CMS_RecipientInfo_get0_pkey_ctx(CMS_RecipientInfo *ri);\nCMS_ContentInfo *CMS_EnvelopedData_create(const EVP_CIPHER *cipher);\nCMS_RecipientInfo *CMS_add1_recipient_cert(CMS_ContentInfo *cms,\n                                           X509 *recip, unsigned int flags);\nint CMS_RecipientInfo_set0_pkey(CMS_RecipientInfo *ri, EVP_PKEY *pkey);\nint CMS_RecipientInfo_ktri_cert_cmp(CMS_RecipientInfo *ri, X509 *cert);\nint CMS_RecipientInfo_ktri_get0_algs(CMS_RecipientInfo *ri,\n                                     EVP_PKEY **pk, X509 **recip,\n                                     X509_ALGOR **palg);\nint CMS_RecipientInfo_ktri_get0_signer_id(CMS_RecipientInfo *ri,\n                                          ASN1_OCTET_STRING **keyid,\n                                          X509_NAME **issuer,\n                                          ASN1_INTEGER **sno);\n\nCMS_RecipientInfo *CMS_add0_recipient_key(CMS_ContentInfo *cms, int nid,\n                                          unsigned char *key, size_t keylen,\n                                          unsigned char *id, size_t idlen,\n                                          ASN1_GENERALIZEDTIME *date,\n                                          ASN1_OBJECT *otherTypeId,\n                                          ASN1_TYPE *otherType);\n\nint CMS_RecipientInfo_kekri_get0_id(CMS_RecipientInfo *ri,\n                                    X509_ALGOR **palg,\n                                    ASN1_OCTET_STRING **pid,\n                                    ASN1_GENERALIZEDTIME **pdate,\n                                    ASN1_OBJECT **potherid,\n                                    ASN1_TYPE **pothertype);\n\nint CMS_RecipientInfo_set0_key(CMS_RecipientInfo *ri,\n                               unsigned char *key, size_t keylen);\n\nint CMS_RecipientInfo_kekri_id_cmp(CMS_RecipientInfo *ri,\n                                   const unsigned char *id, size_t idlen);\n\nint CMS_RecipientInfo_set0_password(CMS_RecipientInfo *ri,\n                                    unsigned char *pass,\n                                    ossl_ssize_t passlen);\n\nCMS_RecipientInfo *CMS_add0_recipient_password(CMS_ContentInfo *cms,\n                                               int iter, int wrap_nid,\n                                               int pbe_nid,\n                                               unsigned char *pass,\n                                               ossl_ssize_t passlen,\n                                               const EVP_CIPHER *kekciph);\n\nint CMS_RecipientInfo_decrypt(CMS_ContentInfo *cms, CMS_RecipientInfo *ri);\nint CMS_RecipientInfo_encrypt(CMS_ContentInfo *cms, CMS_RecipientInfo *ri);\n\nint CMS_uncompress(CMS_ContentInfo *cms, BIO *dcont, BIO *out,\n                   unsigned int flags);\nCMS_ContentInfo *CMS_compress(BIO *in, int comp_nid, unsigned int flags);\n\nint CMS_set1_eContentType(CMS_ContentInfo *cms, const ASN1_OBJECT *oid);\nconst ASN1_OBJECT *CMS_get0_eContentType(CMS_ContentInfo *cms);\n\nCMS_CertificateChoices *CMS_add0_CertificateChoices(CMS_ContentInfo *cms);\nint CMS_add0_cert(CMS_ContentInfo *cms, X509 *cert);\nint CMS_add1_cert(CMS_ContentInfo *cms, X509 *cert);\nSTACK_OF(X509) *CMS_get1_certs(CMS_ContentInfo *cms);\n\nCMS_RevocationInfoChoice *CMS_add0_RevocationInfoChoice(CMS_ContentInfo *cms);\nint CMS_add0_crl(CMS_ContentInfo *cms, X509_CRL *crl);\nint CMS_add1_crl(CMS_ContentInfo *cms, X509_CRL *crl);\nSTACK_OF(X509_CRL) *CMS_get1_crls(CMS_ContentInfo *cms);\n\nint CMS_SignedData_init(CMS_ContentInfo *cms);\nCMS_SignerInfo *CMS_add1_signer(CMS_ContentInfo *cms,\n                                X509 *signer, EVP_PKEY *pk, const EVP_MD *md,\n                                unsigned int flags);\nEVP_PKEY_CTX *CMS_SignerInfo_get0_pkey_ctx(CMS_SignerInfo *si);\nEVP_MD_CTX *CMS_SignerInfo_get0_md_ctx(CMS_SignerInfo *si);\nSTACK_OF(CMS_SignerInfo) *CMS_get0_SignerInfos(CMS_ContentInfo *cms);\n\nvoid CMS_SignerInfo_set1_signer_cert(CMS_SignerInfo *si, X509 *signer);\nint CMS_SignerInfo_get0_signer_id(CMS_SignerInfo *si,\n                                  ASN1_OCTET_STRING **keyid,\n                                  X509_NAME **issuer, ASN1_INTEGER **sno);\nint CMS_SignerInfo_cert_cmp(CMS_SignerInfo *si, X509 *cert);\nint CMS_set1_signers_certs(CMS_ContentInfo *cms, STACK_OF(X509) *certs,\n                           unsigned int flags);\nvoid CMS_SignerInfo_get0_algs(CMS_SignerInfo *si, EVP_PKEY **pk,\n                              X509 **signer, X509_ALGOR **pdig,\n                              X509_ALGOR **psig);\nASN1_OCTET_STRING *CMS_SignerInfo_get0_signature(CMS_SignerInfo *si);\nint CMS_SignerInfo_sign(CMS_SignerInfo *si);\nint CMS_SignerInfo_verify(CMS_SignerInfo *si);\nint CMS_SignerInfo_verify_content(CMS_SignerInfo *si, BIO *chain);\n\nint CMS_add_smimecap(CMS_SignerInfo *si, STACK_OF(X509_ALGOR) *algs);\nint CMS_add_simple_smimecap(STACK_OF(X509_ALGOR) **algs,\n                            int algnid, int keysize);\nint CMS_add_standard_smimecap(STACK_OF(X509_ALGOR) **smcap);\n\nint CMS_signed_get_attr_count(const CMS_SignerInfo *si);\nint CMS_signed_get_attr_by_NID(const CMS_SignerInfo *si, int nid,\n                               int lastpos);\nint CMS_signed_get_attr_by_OBJ(const CMS_SignerInfo *si, const ASN1_OBJECT *obj,\n                               int lastpos);\nX509_ATTRIBUTE *CMS_signed_get_attr(const CMS_SignerInfo *si, int loc);\nX509_ATTRIBUTE *CMS_signed_delete_attr(CMS_SignerInfo *si, int loc);\nint CMS_signed_add1_attr(CMS_SignerInfo *si, X509_ATTRIBUTE *attr);\nint CMS_signed_add1_attr_by_OBJ(CMS_SignerInfo *si,\n                                const ASN1_OBJECT *obj, int type,\n                                const void *bytes, int len);\nint CMS_signed_add1_attr_by_NID(CMS_SignerInfo *si,\n                                int nid, int type,\n                                const void *bytes, int len);\nint CMS_signed_add1_attr_by_txt(CMS_SignerInfo *si,\n                                const char *attrname, int type,\n                                const void *bytes, int len);\nvoid *CMS_signed_get0_data_by_OBJ(CMS_SignerInfo *si, const ASN1_OBJECT *oid,\n                                  int lastpos, int type);\n\nint CMS_unsigned_get_attr_count(const CMS_SignerInfo *si);\nint CMS_unsigned_get_attr_by_NID(const CMS_SignerInfo *si, int nid,\n                                 int lastpos);\nint CMS_unsigned_get_attr_by_OBJ(const CMS_SignerInfo *si,\n                                 const ASN1_OBJECT *obj, int lastpos);\nX509_ATTRIBUTE *CMS_unsigned_get_attr(const CMS_SignerInfo *si, int loc);\nX509_ATTRIBUTE *CMS_unsigned_delete_attr(CMS_SignerInfo *si, int loc);\nint CMS_unsigned_add1_attr(CMS_SignerInfo *si, X509_ATTRIBUTE *attr);\nint CMS_unsigned_add1_attr_by_OBJ(CMS_SignerInfo *si,\n                                  const ASN1_OBJECT *obj, int type,\n                                  const void *bytes, int len);\nint CMS_unsigned_add1_attr_by_NID(CMS_SignerInfo *si,\n                                  int nid, int type,\n                                  const void *bytes, int len);\nint CMS_unsigned_add1_attr_by_txt(CMS_SignerInfo *si,\n                                  const char *attrname, int type,\n                                  const void *bytes, int len);\nvoid *CMS_unsigned_get0_data_by_OBJ(CMS_SignerInfo *si, ASN1_OBJECT *oid,\n                                    int lastpos, int type);\n\nint CMS_get1_ReceiptRequest(CMS_SignerInfo *si, CMS_ReceiptRequest **prr);\nCMS_ReceiptRequest *CMS_ReceiptRequest_create0(unsigned char *id, int idlen,\n                                               int allorfirst,\n                                               STACK_OF(GENERAL_NAMES)\n                                               *receiptList, STACK_OF(GENERAL_NAMES)\n                                               *receiptsTo);\nint CMS_add1_ReceiptRequest(CMS_SignerInfo *si, CMS_ReceiptRequest *rr);\nvoid CMS_ReceiptRequest_get0_values(CMS_ReceiptRequest *rr,\n                                    ASN1_STRING **pcid,\n                                    int *pallorfirst,\n                                    STACK_OF(GENERAL_NAMES) **plist,\n                                    STACK_OF(GENERAL_NAMES) **prto);\nint CMS_RecipientInfo_kari_get0_alg(CMS_RecipientInfo *ri,\n                                    X509_ALGOR **palg,\n                                    ASN1_OCTET_STRING **pukm);\nSTACK_OF(CMS_RecipientEncryptedKey)\n*CMS_RecipientInfo_kari_get0_reks(CMS_RecipientInfo *ri);\n\nint CMS_RecipientInfo_kari_get0_orig_id(CMS_RecipientInfo *ri,\n                                        X509_ALGOR **pubalg,\n                                        ASN1_BIT_STRING **pubkey,\n                                        ASN1_OCTET_STRING **keyid,\n                                        X509_NAME **issuer,\n                                        ASN1_INTEGER **sno);\n\nint CMS_RecipientInfo_kari_orig_id_cmp(CMS_RecipientInfo *ri, X509 *cert);\n\nint CMS_RecipientEncryptedKey_get0_id(CMS_RecipientEncryptedKey *rek,\n                                      ASN1_OCTET_STRING **keyid,\n                                      ASN1_GENERALIZEDTIME **tm,\n                                      CMS_OtherKeyAttribute **other,\n                                      X509_NAME **issuer, ASN1_INTEGER **sno);\nint CMS_RecipientEncryptedKey_cert_cmp(CMS_RecipientEncryptedKey *rek,\n                                       X509 *cert);\nint CMS_RecipientInfo_kari_set0_pkey(CMS_RecipientInfo *ri, EVP_PKEY *pk);\nEVP_CIPHER_CTX *CMS_RecipientInfo_kari_get0_ctx(CMS_RecipientInfo *ri);\nint CMS_RecipientInfo_kari_decrypt(CMS_ContentInfo *cms,\n                                   CMS_RecipientInfo *ri,\n                                   CMS_RecipientEncryptedKey *rek);\n\nint CMS_SharedInfo_encode(unsigned char **pder, X509_ALGOR *kekalg,\n                          ASN1_OCTET_STRING *ukm, int keylen);\n\n/* Backward compatibility for spelling errors. */\n# define CMS_R_UNKNOWN_DIGEST_ALGORITM CMS_R_UNKNOWN_DIGEST_ALGORITHM\n# define CMS_R_UNSUPPORTED_RECPIENTINFO_TYPE \\\n    CMS_R_UNSUPPORTED_RECIPIENTINFO_TYPE\n\n#  ifdef  __cplusplus\n}\n#  endif\n# endif\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/include/openssl/cmserr.h",
    "content": "/*\n * Generated by util/mkerr.pl DO NOT EDIT\n * Copyright 1995-2019 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef HEADER_CMSERR_H\n# define HEADER_CMSERR_H\n\n# ifndef HEADER_SYMHACKS_H\n#  include <openssl/symhacks.h>\n# endif\n\n# include <openssl/opensslconf.h>\n\n# ifndef OPENSSL_NO_CMS\n\n#  ifdef  __cplusplus\nextern \"C\"\n#  endif\nint ERR_load_CMS_strings(void);\n\n/*\n * CMS function codes.\n */\n#  define CMS_F_CHECK_CONTENT                              99\n#  define CMS_F_CMS_ADD0_CERT                              164\n#  define CMS_F_CMS_ADD0_RECIPIENT_KEY                     100\n#  define CMS_F_CMS_ADD0_RECIPIENT_PASSWORD                165\n#  define CMS_F_CMS_ADD1_RECEIPTREQUEST                    158\n#  define CMS_F_CMS_ADD1_RECIPIENT_CERT                    101\n#  define CMS_F_CMS_ADD1_SIGNER                            102\n#  define CMS_F_CMS_ADD1_SIGNINGTIME                       103\n#  define CMS_F_CMS_COMPRESS                               104\n#  define CMS_F_CMS_COMPRESSEDDATA_CREATE                  105\n#  define CMS_F_CMS_COMPRESSEDDATA_INIT_BIO                106\n#  define CMS_F_CMS_COPY_CONTENT                           107\n#  define CMS_F_CMS_COPY_MESSAGEDIGEST                     108\n#  define CMS_F_CMS_DATA                                   109\n#  define CMS_F_CMS_DATAFINAL                              110\n#  define CMS_F_CMS_DATAINIT                               111\n#  define CMS_F_CMS_DECRYPT                                112\n#  define CMS_F_CMS_DECRYPT_SET1_KEY                       113\n#  define CMS_F_CMS_DECRYPT_SET1_PASSWORD                  166\n#  define CMS_F_CMS_DECRYPT_SET1_PKEY                      114\n#  define CMS_F_CMS_DIGESTALGORITHM_FIND_CTX               115\n#  define CMS_F_CMS_DIGESTALGORITHM_INIT_BIO               116\n#  define CMS_F_CMS_DIGESTEDDATA_DO_FINAL                  117\n#  define CMS_F_CMS_DIGEST_VERIFY                          118\n#  define CMS_F_CMS_ENCODE_RECEIPT                         161\n#  define CMS_F_CMS_ENCRYPT                                119\n#  define CMS_F_CMS_ENCRYPTEDCONTENT_INIT                  179\n#  define CMS_F_CMS_ENCRYPTEDCONTENT_INIT_BIO              120\n#  define CMS_F_CMS_ENCRYPTEDDATA_DECRYPT                  121\n#  define CMS_F_CMS_ENCRYPTEDDATA_ENCRYPT                  122\n#  define CMS_F_CMS_ENCRYPTEDDATA_SET1_KEY                 123\n#  define CMS_F_CMS_ENVELOPEDDATA_CREATE                   124\n#  define CMS_F_CMS_ENVELOPEDDATA_INIT_BIO                 125\n#  define CMS_F_CMS_ENVELOPED_DATA_INIT                    126\n#  define CMS_F_CMS_ENV_ASN1_CTRL                          171\n#  define CMS_F_CMS_FINAL                                  127\n#  define CMS_F_CMS_GET0_CERTIFICATE_CHOICES               128\n#  define CMS_F_CMS_GET0_CONTENT                           129\n#  define CMS_F_CMS_GET0_ECONTENT_TYPE                     130\n#  define CMS_F_CMS_GET0_ENVELOPED                         131\n#  define CMS_F_CMS_GET0_REVOCATION_CHOICES                132\n#  define CMS_F_CMS_GET0_SIGNED                            133\n#  define CMS_F_CMS_MSGSIGDIGEST_ADD1                      162\n#  define CMS_F_CMS_RECEIPTREQUEST_CREATE0                 159\n#  define CMS_F_CMS_RECEIPT_VERIFY                         160\n#  define CMS_F_CMS_RECIPIENTINFO_DECRYPT                  134\n#  define CMS_F_CMS_RECIPIENTINFO_ENCRYPT                  169\n#  define CMS_F_CMS_RECIPIENTINFO_KARI_ENCRYPT             178\n#  define CMS_F_CMS_RECIPIENTINFO_KARI_GET0_ALG            175\n#  define CMS_F_CMS_RECIPIENTINFO_KARI_GET0_ORIG_ID        173\n#  define CMS_F_CMS_RECIPIENTINFO_KARI_GET0_REKS           172\n#  define CMS_F_CMS_RECIPIENTINFO_KARI_ORIG_ID_CMP         174\n#  define CMS_F_CMS_RECIPIENTINFO_KEKRI_DECRYPT            135\n#  define CMS_F_CMS_RECIPIENTINFO_KEKRI_ENCRYPT            136\n#  define CMS_F_CMS_RECIPIENTINFO_KEKRI_GET0_ID            137\n#  define CMS_F_CMS_RECIPIENTINFO_KEKRI_ID_CMP             138\n#  define CMS_F_CMS_RECIPIENTINFO_KTRI_CERT_CMP            139\n#  define CMS_F_CMS_RECIPIENTINFO_KTRI_DECRYPT             140\n#  define CMS_F_CMS_RECIPIENTINFO_KTRI_ENCRYPT             141\n#  define CMS_F_CMS_RECIPIENTINFO_KTRI_GET0_ALGS           142\n#  define CMS_F_CMS_RECIPIENTINFO_KTRI_GET0_SIGNER_ID      143\n#  define CMS_F_CMS_RECIPIENTINFO_PWRI_CRYPT               167\n#  define CMS_F_CMS_RECIPIENTINFO_SET0_KEY                 144\n#  define CMS_F_CMS_RECIPIENTINFO_SET0_PASSWORD            168\n#  define CMS_F_CMS_RECIPIENTINFO_SET0_PKEY                145\n#  define CMS_F_CMS_SD_ASN1_CTRL                           170\n#  define CMS_F_CMS_SET1_IAS                               176\n#  define CMS_F_CMS_SET1_KEYID                             177\n#  define CMS_F_CMS_SET1_SIGNERIDENTIFIER                  146\n#  define CMS_F_CMS_SET_DETACHED                           147\n#  define CMS_F_CMS_SIGN                                   148\n#  define CMS_F_CMS_SIGNED_DATA_INIT                       149\n#  define CMS_F_CMS_SIGNERINFO_CONTENT_SIGN                150\n#  define CMS_F_CMS_SIGNERINFO_SIGN                        151\n#  define CMS_F_CMS_SIGNERINFO_VERIFY                      152\n#  define CMS_F_CMS_SIGNERINFO_VERIFY_CERT                 153\n#  define CMS_F_CMS_SIGNERINFO_VERIFY_CONTENT              154\n#  define CMS_F_CMS_SIGN_RECEIPT                           163\n#  define CMS_F_CMS_SI_CHECK_ATTRIBUTES                    183\n#  define CMS_F_CMS_STREAM                                 155\n#  define CMS_F_CMS_UNCOMPRESS                             156\n#  define CMS_F_CMS_VERIFY                                 157\n#  define CMS_F_KEK_UNWRAP_KEY                             180\n\n/*\n * CMS reason codes.\n */\n#  define CMS_R_ADD_SIGNER_ERROR                           99\n#  define CMS_R_ATTRIBUTE_ERROR                            161\n#  define CMS_R_CERTIFICATE_ALREADY_PRESENT                175\n#  define CMS_R_CERTIFICATE_HAS_NO_KEYID                   160\n#  define CMS_R_CERTIFICATE_VERIFY_ERROR                   100\n#  define CMS_R_CIPHER_INITIALISATION_ERROR                101\n#  define CMS_R_CIPHER_PARAMETER_INITIALISATION_ERROR      102\n#  define CMS_R_CMS_DATAFINAL_ERROR                        103\n#  define CMS_R_CMS_LIB                                    104\n#  define CMS_R_CONTENTIDENTIFIER_MISMATCH                 170\n#  define CMS_R_CONTENT_NOT_FOUND                          105\n#  define CMS_R_CONTENT_TYPE_MISMATCH                      171\n#  define CMS_R_CONTENT_TYPE_NOT_COMPRESSED_DATA           106\n#  define CMS_R_CONTENT_TYPE_NOT_ENVELOPED_DATA            107\n#  define CMS_R_CONTENT_TYPE_NOT_SIGNED_DATA               108\n#  define CMS_R_CONTENT_VERIFY_ERROR                       109\n#  define CMS_R_CTRL_ERROR                                 110\n#  define CMS_R_CTRL_FAILURE                               111\n#  define CMS_R_DECRYPT_ERROR                              112\n#  define CMS_R_ERROR_GETTING_PUBLIC_KEY                   113\n#  define CMS_R_ERROR_READING_MESSAGEDIGEST_ATTRIBUTE      114\n#  define CMS_R_ERROR_SETTING_KEY                          115\n#  define CMS_R_ERROR_SETTING_RECIPIENTINFO                116\n#  define CMS_R_INVALID_ENCRYPTED_KEY_LENGTH               117\n#  define CMS_R_INVALID_KEY_ENCRYPTION_PARAMETER           176\n#  define CMS_R_INVALID_KEY_LENGTH                         118\n#  define CMS_R_MD_BIO_INIT_ERROR                          119\n#  define CMS_R_MESSAGEDIGEST_ATTRIBUTE_WRONG_LENGTH       120\n#  define CMS_R_MESSAGEDIGEST_WRONG_LENGTH                 121\n#  define CMS_R_MSGSIGDIGEST_ERROR                         172\n#  define CMS_R_MSGSIGDIGEST_VERIFICATION_FAILURE          162\n#  define CMS_R_MSGSIGDIGEST_WRONG_LENGTH                  163\n#  define CMS_R_NEED_ONE_SIGNER                            164\n#  define CMS_R_NOT_A_SIGNED_RECEIPT                       165\n#  define CMS_R_NOT_ENCRYPTED_DATA                         122\n#  define CMS_R_NOT_KEK                                    123\n#  define CMS_R_NOT_KEY_AGREEMENT                          181\n#  define CMS_R_NOT_KEY_TRANSPORT                          124\n#  define CMS_R_NOT_PWRI                                   177\n#  define CMS_R_NOT_SUPPORTED_FOR_THIS_KEY_TYPE            125\n#  define CMS_R_NO_CIPHER                                  126\n#  define CMS_R_NO_CONTENT                                 127\n#  define CMS_R_NO_CONTENT_TYPE                            173\n#  define CMS_R_NO_DEFAULT_DIGEST                          128\n#  define CMS_R_NO_DIGEST_SET                              129\n#  define CMS_R_NO_KEY                                     130\n#  define CMS_R_NO_KEY_OR_CERT                             174\n#  define CMS_R_NO_MATCHING_DIGEST                         131\n#  define CMS_R_NO_MATCHING_RECIPIENT                      132\n#  define CMS_R_NO_MATCHING_SIGNATURE                      166\n#  define CMS_R_NO_MSGSIGDIGEST                            167\n#  define CMS_R_NO_PASSWORD                                178\n#  define CMS_R_NO_PRIVATE_KEY                             133\n#  define CMS_R_NO_PUBLIC_KEY                              134\n#  define CMS_R_NO_RECEIPT_REQUEST                         168\n#  define CMS_R_NO_SIGNERS                                 135\n#  define CMS_R_PRIVATE_KEY_DOES_NOT_MATCH_CERTIFICATE     136\n#  define CMS_R_RECEIPT_DECODE_ERROR                       169\n#  define CMS_R_RECIPIENT_ERROR                            137\n#  define CMS_R_SIGNER_CERTIFICATE_NOT_FOUND               138\n#  define CMS_R_SIGNFINAL_ERROR                            139\n#  define CMS_R_SMIME_TEXT_ERROR                           140\n#  define CMS_R_STORE_INIT_ERROR                           141\n#  define CMS_R_TYPE_NOT_COMPRESSED_DATA                   142\n#  define CMS_R_TYPE_NOT_DATA                              143\n#  define CMS_R_TYPE_NOT_DIGESTED_DATA                     144\n#  define CMS_R_TYPE_NOT_ENCRYPTED_DATA                    145\n#  define CMS_R_TYPE_NOT_ENVELOPED_DATA                    146\n#  define CMS_R_UNABLE_TO_FINALIZE_CONTEXT                 147\n#  define CMS_R_UNKNOWN_CIPHER                             148\n#  define CMS_R_UNKNOWN_DIGEST_ALGORITHM                   149\n#  define CMS_R_UNKNOWN_ID                                 150\n#  define CMS_R_UNSUPPORTED_COMPRESSION_ALGORITHM          151\n#  define CMS_R_UNSUPPORTED_CONTENT_TYPE                   152\n#  define CMS_R_UNSUPPORTED_KEK_ALGORITHM                  153\n#  define CMS_R_UNSUPPORTED_KEY_ENCRYPTION_ALGORITHM       179\n#  define CMS_R_UNSUPPORTED_RECIPIENTINFO_TYPE             155\n#  define CMS_R_UNSUPPORTED_RECIPIENT_TYPE                 154\n#  define CMS_R_UNSUPPORTED_TYPE                           156\n#  define CMS_R_UNWRAP_ERROR                               157\n#  define CMS_R_UNWRAP_FAILURE                             180\n#  define CMS_R_VERIFICATION_FAILURE                       158\n#  define CMS_R_WRAP_ERROR                                 159\n\n# endif\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/include/openssl/comp.h",
    "content": "/*\n * Copyright 2015-2018 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef HEADER_COMP_H\n# define HEADER_COMP_H\n\n# include <openssl/opensslconf.h>\n\n# ifndef OPENSSL_NO_COMP\n# include <openssl/crypto.h>\n# include <openssl/comperr.h>\n# ifdef  __cplusplus\nextern \"C\" {\n# endif\n\n\n\nCOMP_CTX *COMP_CTX_new(COMP_METHOD *meth);\nconst COMP_METHOD *COMP_CTX_get_method(const COMP_CTX *ctx);\nint COMP_CTX_get_type(const COMP_CTX* comp);\nint COMP_get_type(const COMP_METHOD *meth);\nconst char *COMP_get_name(const COMP_METHOD *meth);\nvoid COMP_CTX_free(COMP_CTX *ctx);\n\nint COMP_compress_block(COMP_CTX *ctx, unsigned char *out, int olen,\n                        unsigned char *in, int ilen);\nint COMP_expand_block(COMP_CTX *ctx, unsigned char *out, int olen,\n                      unsigned char *in, int ilen);\n\nCOMP_METHOD *COMP_zlib(void);\n\n#if OPENSSL_API_COMPAT < 0x10100000L\n#define COMP_zlib_cleanup() while(0) continue\n#endif\n\n# ifdef HEADER_BIO_H\n#  ifdef ZLIB\nconst BIO_METHOD *BIO_f_zlib(void);\n#  endif\n# endif\n\n\n#  ifdef  __cplusplus\n}\n#  endif\n# endif\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/include/openssl/comperr.h",
    "content": "/*\n * Generated by util/mkerr.pl DO NOT EDIT\n * Copyright 1995-2019 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef HEADER_COMPERR_H\n# define HEADER_COMPERR_H\n\n# ifndef HEADER_SYMHACKS_H\n#  include <openssl/symhacks.h>\n# endif\n\n# include <openssl/opensslconf.h>\n\n# ifndef OPENSSL_NO_COMP\n\n#  ifdef  __cplusplus\nextern \"C\"\n#  endif\nint ERR_load_COMP_strings(void);\n\n/*\n * COMP function codes.\n */\n#  define COMP_F_BIO_ZLIB_FLUSH                            99\n#  define COMP_F_BIO_ZLIB_NEW                              100\n#  define COMP_F_BIO_ZLIB_READ                             101\n#  define COMP_F_BIO_ZLIB_WRITE                            102\n#  define COMP_F_COMP_CTX_NEW                              103\n\n/*\n * COMP reason codes.\n */\n#  define COMP_R_ZLIB_DEFLATE_ERROR                        99\n#  define COMP_R_ZLIB_INFLATE_ERROR                        100\n#  define COMP_R_ZLIB_NOT_SUPPORTED                        101\n\n# endif\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/include/openssl/conf.h",
    "content": "/*\n * Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef  HEADER_CONF_H\n# define HEADER_CONF_H\n\n# include <openssl/bio.h>\n# include <openssl/lhash.h>\n# include <openssl/safestack.h>\n# include <openssl/e_os2.h>\n# include <openssl/ossl_typ.h>\n# include <openssl/conferr.h>\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\ntypedef struct {\n    char *section;\n    char *name;\n    char *value;\n} CONF_VALUE;\n\nDEFINE_STACK_OF(CONF_VALUE)\nDEFINE_LHASH_OF(CONF_VALUE);\n\nstruct conf_st;\nstruct conf_method_st;\ntypedef struct conf_method_st CONF_METHOD;\n\nstruct conf_method_st {\n    const char *name;\n    CONF *(*create) (CONF_METHOD *meth);\n    int (*init) (CONF *conf);\n    int (*destroy) (CONF *conf);\n    int (*destroy_data) (CONF *conf);\n    int (*load_bio) (CONF *conf, BIO *bp, long *eline);\n    int (*dump) (const CONF *conf, BIO *bp);\n    int (*is_number) (const CONF *conf, char c);\n    int (*to_int) (const CONF *conf, char c);\n    int (*load) (CONF *conf, const char *name, long *eline);\n};\n\n/* Module definitions */\n\ntypedef struct conf_imodule_st CONF_IMODULE;\ntypedef struct conf_module_st CONF_MODULE;\n\nDEFINE_STACK_OF(CONF_MODULE)\nDEFINE_STACK_OF(CONF_IMODULE)\n\n/* DSO module function typedefs */\ntypedef int conf_init_func (CONF_IMODULE *md, const CONF *cnf);\ntypedef void conf_finish_func (CONF_IMODULE *md);\n\n# define CONF_MFLAGS_IGNORE_ERRORS       0x1\n# define CONF_MFLAGS_IGNORE_RETURN_CODES 0x2\n# define CONF_MFLAGS_SILENT              0x4\n# define CONF_MFLAGS_NO_DSO              0x8\n# define CONF_MFLAGS_IGNORE_MISSING_FILE 0x10\n# define CONF_MFLAGS_DEFAULT_SECTION     0x20\n\nint CONF_set_default_method(CONF_METHOD *meth);\nvoid CONF_set_nconf(CONF *conf, LHASH_OF(CONF_VALUE) *hash);\nLHASH_OF(CONF_VALUE) *CONF_load(LHASH_OF(CONF_VALUE) *conf, const char *file,\n                                long *eline);\n# ifndef OPENSSL_NO_STDIO\nLHASH_OF(CONF_VALUE) *CONF_load_fp(LHASH_OF(CONF_VALUE) *conf, FILE *fp,\n                                   long *eline);\n# endif\nLHASH_OF(CONF_VALUE) *CONF_load_bio(LHASH_OF(CONF_VALUE) *conf, BIO *bp,\n                                    long *eline);\nSTACK_OF(CONF_VALUE) *CONF_get_section(LHASH_OF(CONF_VALUE) *conf,\n                                       const char *section);\nchar *CONF_get_string(LHASH_OF(CONF_VALUE) *conf, const char *group,\n                      const char *name);\nlong CONF_get_number(LHASH_OF(CONF_VALUE) *conf, const char *group,\n                     const char *name);\nvoid CONF_free(LHASH_OF(CONF_VALUE) *conf);\n#ifndef OPENSSL_NO_STDIO\nint CONF_dump_fp(LHASH_OF(CONF_VALUE) *conf, FILE *out);\n#endif\nint CONF_dump_bio(LHASH_OF(CONF_VALUE) *conf, BIO *out);\n\nDEPRECATEDIN_1_1_0(void OPENSSL_config(const char *config_name))\n\n#if OPENSSL_API_COMPAT < 0x10100000L\n# define OPENSSL_no_config() \\\n    OPENSSL_init_crypto(OPENSSL_INIT_NO_LOAD_CONFIG, NULL)\n#endif\n\n/*\n * New conf code.  The semantics are different from the functions above. If\n * that wasn't the case, the above functions would have been replaced\n */\n\nstruct conf_st {\n    CONF_METHOD *meth;\n    void *meth_data;\n    LHASH_OF(CONF_VALUE) *data;\n};\n\nCONF *NCONF_new(CONF_METHOD *meth);\nCONF_METHOD *NCONF_default(void);\nCONF_METHOD *NCONF_WIN32(void);\nvoid NCONF_free(CONF *conf);\nvoid NCONF_free_data(CONF *conf);\n\nint NCONF_load(CONF *conf, const char *file, long *eline);\n# ifndef OPENSSL_NO_STDIO\nint NCONF_load_fp(CONF *conf, FILE *fp, long *eline);\n# endif\nint NCONF_load_bio(CONF *conf, BIO *bp, long *eline);\nSTACK_OF(CONF_VALUE) *NCONF_get_section(const CONF *conf,\n                                        const char *section);\nchar *NCONF_get_string(const CONF *conf, const char *group, const char *name);\nint NCONF_get_number_e(const CONF *conf, const char *group, const char *name,\n                       long *result);\n#ifndef OPENSSL_NO_STDIO\nint NCONF_dump_fp(const CONF *conf, FILE *out);\n#endif\nint NCONF_dump_bio(const CONF *conf, BIO *out);\n\n#define NCONF_get_number(c,g,n,r) NCONF_get_number_e(c,g,n,r)\n\n/* Module functions */\n\nint CONF_modules_load(const CONF *cnf, const char *appname,\n                      unsigned long flags);\nint CONF_modules_load_file(const char *filename, const char *appname,\n                           unsigned long flags);\nvoid CONF_modules_unload(int all);\nvoid CONF_modules_finish(void);\n#if OPENSSL_API_COMPAT < 0x10100000L\n# define CONF_modules_free() while(0) continue\n#endif\nint CONF_module_add(const char *name, conf_init_func *ifunc,\n                    conf_finish_func *ffunc);\n\nconst char *CONF_imodule_get_name(const CONF_IMODULE *md);\nconst char *CONF_imodule_get_value(const CONF_IMODULE *md);\nvoid *CONF_imodule_get_usr_data(const CONF_IMODULE *md);\nvoid CONF_imodule_set_usr_data(CONF_IMODULE *md, void *usr_data);\nCONF_MODULE *CONF_imodule_get_module(const CONF_IMODULE *md);\nunsigned long CONF_imodule_get_flags(const CONF_IMODULE *md);\nvoid CONF_imodule_set_flags(CONF_IMODULE *md, unsigned long flags);\nvoid *CONF_module_get_usr_data(CONF_MODULE *pmod);\nvoid CONF_module_set_usr_data(CONF_MODULE *pmod, void *usr_data);\n\nchar *CONF_get1_default_config_file(void);\n\nint CONF_parse_list(const char *list, int sep, int nospc,\n                    int (*list_cb) (const char *elem, int len, void *usr),\n                    void *arg);\n\nvoid OPENSSL_load_builtin_modules(void);\n\n\n# ifdef  __cplusplus\n}\n# endif\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/include/openssl/conf_api.h",
    "content": "/*\n * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef  HEADER_CONF_API_H\n# define HEADER_CONF_API_H\n\n# include <openssl/lhash.h>\n# include <openssl/conf.h>\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n/* Up until OpenSSL 0.9.5a, this was new_section */\nCONF_VALUE *_CONF_new_section(CONF *conf, const char *section);\n/* Up until OpenSSL 0.9.5a, this was get_section */\nCONF_VALUE *_CONF_get_section(const CONF *conf, const char *section);\n/* Up until OpenSSL 0.9.5a, this was CONF_get_section */\nSTACK_OF(CONF_VALUE) *_CONF_get_section_values(const CONF *conf,\n                                               const char *section);\n\nint _CONF_add_string(CONF *conf, CONF_VALUE *section, CONF_VALUE *value);\nchar *_CONF_get_string(const CONF *conf, const char *section,\n                       const char *name);\nlong _CONF_get_number(const CONF *conf, const char *section,\n                      const char *name);\n\nint _CONF_new_data(CONF *conf);\nvoid _CONF_free_data(CONF *conf);\n\n#ifdef  __cplusplus\n}\n#endif\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/include/openssl/conferr.h",
    "content": "/*\n * Generated by util/mkerr.pl DO NOT EDIT\n * Copyright 1995-2019 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef HEADER_CONFERR_H\n# define HEADER_CONFERR_H\n\n# ifndef HEADER_SYMHACKS_H\n#  include <openssl/symhacks.h>\n# endif\n\n# ifdef  __cplusplus\nextern \"C\"\n# endif\nint ERR_load_CONF_strings(void);\n\n/*\n * CONF function codes.\n */\n# define CONF_F_CONF_DUMP_FP                              104\n# define CONF_F_CONF_LOAD                                 100\n# define CONF_F_CONF_LOAD_FP                              103\n# define CONF_F_CONF_PARSE_LIST                           119\n# define CONF_F_DEF_LOAD                                  120\n# define CONF_F_DEF_LOAD_BIO                              121\n# define CONF_F_GET_NEXT_FILE                             107\n# define CONF_F_MODULE_ADD                                122\n# define CONF_F_MODULE_INIT                               115\n# define CONF_F_MODULE_LOAD_DSO                           117\n# define CONF_F_MODULE_RUN                                118\n# define CONF_F_NCONF_DUMP_BIO                            105\n# define CONF_F_NCONF_DUMP_FP                             106\n# define CONF_F_NCONF_GET_NUMBER_E                        112\n# define CONF_F_NCONF_GET_SECTION                         108\n# define CONF_F_NCONF_GET_STRING                          109\n# define CONF_F_NCONF_LOAD                                113\n# define CONF_F_NCONF_LOAD_BIO                            110\n# define CONF_F_NCONF_LOAD_FP                             114\n# define CONF_F_NCONF_NEW                                 111\n# define CONF_F_PROCESS_INCLUDE                           116\n# define CONF_F_SSL_MODULE_INIT                           123\n# define CONF_F_STR_COPY                                  101\n\n/*\n * CONF reason codes.\n */\n# define CONF_R_ERROR_LOADING_DSO                         110\n# define CONF_R_LIST_CANNOT_BE_NULL                       115\n# define CONF_R_MISSING_CLOSE_SQUARE_BRACKET              100\n# define CONF_R_MISSING_EQUAL_SIGN                        101\n# define CONF_R_MISSING_INIT_FUNCTION                     112\n# define CONF_R_MODULE_INITIALIZATION_ERROR               109\n# define CONF_R_NO_CLOSE_BRACE                            102\n# define CONF_R_NO_CONF                                   105\n# define CONF_R_NO_CONF_OR_ENVIRONMENT_VARIABLE           106\n# define CONF_R_NO_SECTION                                107\n# define CONF_R_NO_SUCH_FILE                              114\n# define CONF_R_NO_VALUE                                  108\n# define CONF_R_NUMBER_TOO_LARGE                          121\n# define CONF_R_RECURSIVE_DIRECTORY_INCLUDE               111\n# define CONF_R_SSL_COMMAND_SECTION_EMPTY                 117\n# define CONF_R_SSL_COMMAND_SECTION_NOT_FOUND             118\n# define CONF_R_SSL_SECTION_EMPTY                         119\n# define CONF_R_SSL_SECTION_NOT_FOUND                     120\n# define CONF_R_UNABLE_TO_CREATE_NEW_SECTION              103\n# define CONF_R_UNKNOWN_MODULE_NAME                       113\n# define CONF_R_VARIABLE_EXPANSION_TOO_LONG               116\n# define CONF_R_VARIABLE_HAS_NO_VALUE                     104\n\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/include/openssl/crypto.h",
    "content": "/*\n * Copyright 1995-2019 The OpenSSL Project Authors. All Rights Reserved.\n * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef HEADER_CRYPTO_H\n# define HEADER_CRYPTO_H\n\n# include <stdlib.h>\n# include <time.h>\n\n# include <openssl/e_os2.h>\n\n# ifndef OPENSSL_NO_STDIO\n#  include <stdio.h>\n# endif\n\n# include <openssl/safestack.h>\n# include <openssl/opensslv.h>\n# include <openssl/ossl_typ.h>\n# include <openssl/opensslconf.h>\n# include <openssl/cryptoerr.h>\n\n# ifdef CHARSET_EBCDIC\n#  include <openssl/ebcdic.h>\n# endif\n\n/*\n * Resolve problems on some operating systems with symbol names that clash\n * one way or another\n */\n# include <openssl/symhacks.h>\n\n# if OPENSSL_API_COMPAT < 0x10100000L\n#  include <openssl/opensslv.h>\n# endif\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n# if OPENSSL_API_COMPAT < 0x10100000L\n#  define SSLeay                  OpenSSL_version_num\n#  define SSLeay_version          OpenSSL_version\n#  define SSLEAY_VERSION_NUMBER   OPENSSL_VERSION_NUMBER\n#  define SSLEAY_VERSION          OPENSSL_VERSION\n#  define SSLEAY_CFLAGS           OPENSSL_CFLAGS\n#  define SSLEAY_BUILT_ON         OPENSSL_BUILT_ON\n#  define SSLEAY_PLATFORM         OPENSSL_PLATFORM\n#  define SSLEAY_DIR              OPENSSL_DIR\n\n/*\n * Old type for allocating dynamic locks. No longer used. Use the new thread\n * API instead.\n */\ntypedef struct {\n    int dummy;\n} CRYPTO_dynlock;\n\n# endif /* OPENSSL_API_COMPAT */\n\ntypedef void CRYPTO_RWLOCK;\n\nCRYPTO_RWLOCK *CRYPTO_THREAD_lock_new(void);\nint CRYPTO_THREAD_read_lock(CRYPTO_RWLOCK *lock);\nint CRYPTO_THREAD_write_lock(CRYPTO_RWLOCK *lock);\nint CRYPTO_THREAD_unlock(CRYPTO_RWLOCK *lock);\nvoid CRYPTO_THREAD_lock_free(CRYPTO_RWLOCK *lock);\n\nint CRYPTO_atomic_add(int *val, int amount, int *ret, CRYPTO_RWLOCK *lock);\n\n/*\n * The following can be used to detect memory leaks in the library. If\n * used, it turns on malloc checking\n */\n# define CRYPTO_MEM_CHECK_OFF     0x0   /* Control only */\n# define CRYPTO_MEM_CHECK_ON      0x1   /* Control and mode bit */\n# define CRYPTO_MEM_CHECK_ENABLE  0x2   /* Control and mode bit */\n# define CRYPTO_MEM_CHECK_DISABLE 0x3   /* Control only */\n\nstruct crypto_ex_data_st {\n    STACK_OF(void) *sk;\n};\nDEFINE_STACK_OF(void)\n\n/*\n * Per class, we have a STACK of function pointers.\n */\n# define CRYPTO_EX_INDEX_SSL              0\n# define CRYPTO_EX_INDEX_SSL_CTX          1\n# define CRYPTO_EX_INDEX_SSL_SESSION      2\n# define CRYPTO_EX_INDEX_X509             3\n# define CRYPTO_EX_INDEX_X509_STORE       4\n# define CRYPTO_EX_INDEX_X509_STORE_CTX   5\n# define CRYPTO_EX_INDEX_DH               6\n# define CRYPTO_EX_INDEX_DSA              7\n# define CRYPTO_EX_INDEX_EC_KEY           8\n# define CRYPTO_EX_INDEX_RSA              9\n# define CRYPTO_EX_INDEX_ENGINE          10\n# define CRYPTO_EX_INDEX_UI              11\n# define CRYPTO_EX_INDEX_BIO             12\n# define CRYPTO_EX_INDEX_APP             13\n# define CRYPTO_EX_INDEX_UI_METHOD       14\n# define CRYPTO_EX_INDEX_DRBG            15\n# define CRYPTO_EX_INDEX__COUNT          16\n\n/* No longer needed, so this is a no-op */\n#define OPENSSL_malloc_init() while(0) continue\n\nint CRYPTO_mem_ctrl(int mode);\n\n# define OPENSSL_malloc(num) \\\n        CRYPTO_malloc(num, OPENSSL_FILE, OPENSSL_LINE)\n# define OPENSSL_zalloc(num) \\\n        CRYPTO_zalloc(num, OPENSSL_FILE, OPENSSL_LINE)\n# define OPENSSL_realloc(addr, num) \\\n        CRYPTO_realloc(addr, num, OPENSSL_FILE, OPENSSL_LINE)\n# define OPENSSL_clear_realloc(addr, old_num, num) \\\n        CRYPTO_clear_realloc(addr, old_num, num, OPENSSL_FILE, OPENSSL_LINE)\n# define OPENSSL_clear_free(addr, num) \\\n        CRYPTO_clear_free(addr, num, OPENSSL_FILE, OPENSSL_LINE)\n# define OPENSSL_free(addr) \\\n        CRYPTO_free(addr, OPENSSL_FILE, OPENSSL_LINE)\n# define OPENSSL_memdup(str, s) \\\n        CRYPTO_memdup((str), s, OPENSSL_FILE, OPENSSL_LINE)\n# define OPENSSL_strdup(str) \\\n        CRYPTO_strdup(str, OPENSSL_FILE, OPENSSL_LINE)\n# define OPENSSL_strndup(str, n) \\\n        CRYPTO_strndup(str, n, OPENSSL_FILE, OPENSSL_LINE)\n# define OPENSSL_secure_malloc(num) \\\n        CRYPTO_secure_malloc(num, OPENSSL_FILE, OPENSSL_LINE)\n# define OPENSSL_secure_zalloc(num) \\\n        CRYPTO_secure_zalloc(num, OPENSSL_FILE, OPENSSL_LINE)\n# define OPENSSL_secure_free(addr) \\\n        CRYPTO_secure_free(addr, OPENSSL_FILE, OPENSSL_LINE)\n# define OPENSSL_secure_clear_free(addr, num) \\\n        CRYPTO_secure_clear_free(addr, num, OPENSSL_FILE, OPENSSL_LINE)\n# define OPENSSL_secure_actual_size(ptr) \\\n        CRYPTO_secure_actual_size(ptr)\n\nsize_t OPENSSL_strlcpy(char *dst, const char *src, size_t siz);\nsize_t OPENSSL_strlcat(char *dst, const char *src, size_t siz);\nsize_t OPENSSL_strnlen(const char *str, size_t maxlen);\nchar *OPENSSL_buf2hexstr(const unsigned char *buffer, long len);\nunsigned char *OPENSSL_hexstr2buf(const char *str, long *len);\nint OPENSSL_hexchar2int(unsigned char c);\n\n# define OPENSSL_MALLOC_MAX_NELEMS(type)  (((1U<<(sizeof(int)*8-1))-1)/sizeof(type))\n\nunsigned long OpenSSL_version_num(void);\nconst char *OpenSSL_version(int type);\n# define OPENSSL_VERSION          0\n# define OPENSSL_CFLAGS           1\n# define OPENSSL_BUILT_ON         2\n# define OPENSSL_PLATFORM         3\n# define OPENSSL_DIR              4\n# define OPENSSL_ENGINES_DIR      5\n\nint OPENSSL_issetugid(void);\n\ntypedef void CRYPTO_EX_new (void *parent, void *ptr, CRYPTO_EX_DATA *ad,\n                           int idx, long argl, void *argp);\ntypedef void CRYPTO_EX_free (void *parent, void *ptr, CRYPTO_EX_DATA *ad,\n                             int idx, long argl, void *argp);\ntypedef int CRYPTO_EX_dup (CRYPTO_EX_DATA *to, const CRYPTO_EX_DATA *from,\n                           void *from_d, int idx, long argl, void *argp);\n__owur int CRYPTO_get_ex_new_index(int class_index, long argl, void *argp,\n                            CRYPTO_EX_new *new_func, CRYPTO_EX_dup *dup_func,\n                            CRYPTO_EX_free *free_func);\n/* No longer use an index. */\nint CRYPTO_free_ex_index(int class_index, int idx);\n\n/*\n * Initialise/duplicate/free CRYPTO_EX_DATA variables corresponding to a\n * given class (invokes whatever per-class callbacks are applicable)\n */\nint CRYPTO_new_ex_data(int class_index, void *obj, CRYPTO_EX_DATA *ad);\nint CRYPTO_dup_ex_data(int class_index, CRYPTO_EX_DATA *to,\n                       const CRYPTO_EX_DATA *from);\n\nvoid CRYPTO_free_ex_data(int class_index, void *obj, CRYPTO_EX_DATA *ad);\n\n/*\n * Get/set data in a CRYPTO_EX_DATA variable corresponding to a particular\n * index (relative to the class type involved)\n */\nint CRYPTO_set_ex_data(CRYPTO_EX_DATA *ad, int idx, void *val);\nvoid *CRYPTO_get_ex_data(const CRYPTO_EX_DATA *ad, int idx);\n\n# if OPENSSL_API_COMPAT < 0x10100000L\n/*\n * This function cleans up all \"ex_data\" state. It mustn't be called under\n * potential race-conditions.\n */\n# define CRYPTO_cleanup_all_ex_data() while(0) continue\n\n/*\n * The old locking functions have been removed completely without compatibility\n * macros. This is because the old functions either could not properly report\n * errors, or the returned error values were not clearly documented.\n * Replacing the locking functions with no-ops would cause race condition\n * issues in the affected applications. It is far better for them to fail at\n * compile time.\n * On the other hand, the locking callbacks are no longer used.  Consequently,\n * the callback management functions can be safely replaced with no-op macros.\n */\n#  define CRYPTO_num_locks()            (1)\n#  define CRYPTO_set_locking_callback(func)\n#  define CRYPTO_get_locking_callback()         (NULL)\n#  define CRYPTO_set_add_lock_callback(func)\n#  define CRYPTO_get_add_lock_callback()        (NULL)\n\n/*\n * These defines where used in combination with the old locking callbacks,\n * they are not called anymore, but old code that's not called might still\n * use them.\n */\n#  define CRYPTO_LOCK             1\n#  define CRYPTO_UNLOCK           2\n#  define CRYPTO_READ             4\n#  define CRYPTO_WRITE            8\n\n/* This structure is no longer used */\ntypedef struct crypto_threadid_st {\n    int dummy;\n} CRYPTO_THREADID;\n/* Only use CRYPTO_THREADID_set_[numeric|pointer]() within callbacks */\n#  define CRYPTO_THREADID_set_numeric(id, val)\n#  define CRYPTO_THREADID_set_pointer(id, ptr)\n#  define CRYPTO_THREADID_set_callback(threadid_func)   (0)\n#  define CRYPTO_THREADID_get_callback()                (NULL)\n#  define CRYPTO_THREADID_current(id)\n#  define CRYPTO_THREADID_cmp(a, b)                     (-1)\n#  define CRYPTO_THREADID_cpy(dest, src)\n#  define CRYPTO_THREADID_hash(id)                      (0UL)\n\n#  if OPENSSL_API_COMPAT < 0x10000000L\n#   define CRYPTO_set_id_callback(func)\n#   define CRYPTO_get_id_callback()                     (NULL)\n#   define CRYPTO_thread_id()                           (0UL)\n#  endif /* OPENSSL_API_COMPAT < 0x10000000L */\n\n#  define CRYPTO_set_dynlock_create_callback(dyn_create_function)\n#  define CRYPTO_set_dynlock_lock_callback(dyn_lock_function)\n#  define CRYPTO_set_dynlock_destroy_callback(dyn_destroy_function)\n#  define CRYPTO_get_dynlock_create_callback()          (NULL)\n#  define CRYPTO_get_dynlock_lock_callback()            (NULL)\n#  define CRYPTO_get_dynlock_destroy_callback()         (NULL)\n# endif /* OPENSSL_API_COMPAT < 0x10100000L */\n\nint CRYPTO_set_mem_functions(\n        void *(*m) (size_t, const char *, int),\n        void *(*r) (void *, size_t, const char *, int),\n        void (*f) (void *, const char *, int));\nint CRYPTO_set_mem_debug(int flag);\nvoid CRYPTO_get_mem_functions(\n        void *(**m) (size_t, const char *, int),\n        void *(**r) (void *, size_t, const char *, int),\n        void (**f) (void *, const char *, int));\n\nvoid *CRYPTO_malloc(size_t num, const char *file, int line);\nvoid *CRYPTO_zalloc(size_t num, const char *file, int line);\nvoid *CRYPTO_memdup(const void *str, size_t siz, const char *file, int line);\nchar *CRYPTO_strdup(const char *str, const char *file, int line);\nchar *CRYPTO_strndup(const char *str, size_t s, const char *file, int line);\nvoid CRYPTO_free(void *ptr, const char *file, int line);\nvoid CRYPTO_clear_free(void *ptr, size_t num, const char *file, int line);\nvoid *CRYPTO_realloc(void *addr, size_t num, const char *file, int line);\nvoid *CRYPTO_clear_realloc(void *addr, size_t old_num, size_t num,\n                           const char *file, int line);\n\nint CRYPTO_secure_malloc_init(size_t sz, int minsize);\nint CRYPTO_secure_malloc_done(void);\nvoid *CRYPTO_secure_malloc(size_t num, const char *file, int line);\nvoid *CRYPTO_secure_zalloc(size_t num, const char *file, int line);\nvoid CRYPTO_secure_free(void *ptr, const char *file, int line);\nvoid CRYPTO_secure_clear_free(void *ptr, size_t num,\n                              const char *file, int line);\nint CRYPTO_secure_allocated(const void *ptr);\nint CRYPTO_secure_malloc_initialized(void);\nsize_t CRYPTO_secure_actual_size(void *ptr);\nsize_t CRYPTO_secure_used(void);\n\nvoid OPENSSL_cleanse(void *ptr, size_t len);\n\n# ifndef OPENSSL_NO_CRYPTO_MDEBUG\n#  define OPENSSL_mem_debug_push(info) \\\n        CRYPTO_mem_debug_push(info, OPENSSL_FILE, OPENSSL_LINE)\n#  define OPENSSL_mem_debug_pop() \\\n        CRYPTO_mem_debug_pop()\nint CRYPTO_mem_debug_push(const char *info, const char *file, int line);\nint CRYPTO_mem_debug_pop(void);\nvoid CRYPTO_get_alloc_counts(int *mcount, int *rcount, int *fcount);\n\n/*-\n * Debugging functions (enabled by CRYPTO_set_mem_debug(1))\n * The flag argument has the following significance:\n *   0:   called before the actual memory allocation has taken place\n *   1:   called after the actual memory allocation has taken place\n */\nvoid CRYPTO_mem_debug_malloc(void *addr, size_t num, int flag,\n        const char *file, int line);\nvoid CRYPTO_mem_debug_realloc(void *addr1, void *addr2, size_t num, int flag,\n        const char *file, int line);\nvoid CRYPTO_mem_debug_free(void *addr, int flag,\n        const char *file, int line);\n\nint CRYPTO_mem_leaks_cb(int (*cb) (const char *str, size_t len, void *u),\n                        void *u);\n#  ifndef OPENSSL_NO_STDIO\nint CRYPTO_mem_leaks_fp(FILE *);\n#  endif\nint CRYPTO_mem_leaks(BIO *bio);\n# endif\n\n/* die if we have to */\nossl_noreturn void OPENSSL_die(const char *assertion, const char *file, int line);\n# if OPENSSL_API_COMPAT < 0x10100000L\n#  define OpenSSLDie(f,l,a) OPENSSL_die((a),(f),(l))\n# endif\n# define OPENSSL_assert(e) \\\n    (void)((e) ? 0 : (OPENSSL_die(\"assertion failed: \" #e, OPENSSL_FILE, OPENSSL_LINE), 1))\n\nint OPENSSL_isservice(void);\n\nint FIPS_mode(void);\nint FIPS_mode_set(int r);\n\nvoid OPENSSL_init(void);\n# ifdef OPENSSL_SYS_UNIX\nvoid OPENSSL_fork_prepare(void);\nvoid OPENSSL_fork_parent(void);\nvoid OPENSSL_fork_child(void);\n# endif\n\nstruct tm *OPENSSL_gmtime(const time_t *timer, struct tm *result);\nint OPENSSL_gmtime_adj(struct tm *tm, int offset_day, long offset_sec);\nint OPENSSL_gmtime_diff(int *pday, int *psec,\n                        const struct tm *from, const struct tm *to);\n\n/*\n * CRYPTO_memcmp returns zero iff the |len| bytes at |a| and |b| are equal.\n * It takes an amount of time dependent on |len|, but independent of the\n * contents of |a| and |b|. Unlike memcmp, it cannot be used to put elements\n * into a defined order as the return value when a != b is undefined, other\n * than to be non-zero.\n */\nint CRYPTO_memcmp(const void * in_a, const void * in_b, size_t len);\n\n/* Standard initialisation options */\n# define OPENSSL_INIT_NO_LOAD_CRYPTO_STRINGS 0x00000001L\n# define OPENSSL_INIT_LOAD_CRYPTO_STRINGS    0x00000002L\n# define OPENSSL_INIT_ADD_ALL_CIPHERS        0x00000004L\n# define OPENSSL_INIT_ADD_ALL_DIGESTS        0x00000008L\n# define OPENSSL_INIT_NO_ADD_ALL_CIPHERS     0x00000010L\n# define OPENSSL_INIT_NO_ADD_ALL_DIGESTS     0x00000020L\n# define OPENSSL_INIT_LOAD_CONFIG            0x00000040L\n# define OPENSSL_INIT_NO_LOAD_CONFIG         0x00000080L\n# define OPENSSL_INIT_ASYNC                  0x00000100L\n# define OPENSSL_INIT_ENGINE_RDRAND          0x00000200L\n# define OPENSSL_INIT_ENGINE_DYNAMIC         0x00000400L\n# define OPENSSL_INIT_ENGINE_OPENSSL         0x00000800L\n# define OPENSSL_INIT_ENGINE_CRYPTODEV       0x00001000L\n# define OPENSSL_INIT_ENGINE_CAPI            0x00002000L\n# define OPENSSL_INIT_ENGINE_PADLOCK         0x00004000L\n# define OPENSSL_INIT_ENGINE_AFALG           0x00008000L\n/* OPENSSL_INIT_ZLIB                         0x00010000L */\n# define OPENSSL_INIT_ATFORK                 0x00020000L\n/* OPENSSL_INIT_BASE_ONLY                    0x00040000L */\n# define OPENSSL_INIT_NO_ATEXIT              0x00080000L\n/* OPENSSL_INIT flag range 0xfff00000 reserved for OPENSSL_init_ssl() */\n/* Max OPENSSL_INIT flag value is 0x80000000 */\n\n/* openssl and dasync not counted as builtin */\n# define OPENSSL_INIT_ENGINE_ALL_BUILTIN \\\n    (OPENSSL_INIT_ENGINE_RDRAND | OPENSSL_INIT_ENGINE_DYNAMIC \\\n    | OPENSSL_INIT_ENGINE_CRYPTODEV | OPENSSL_INIT_ENGINE_CAPI | \\\n    OPENSSL_INIT_ENGINE_PADLOCK)\n\n\n/* Library initialisation functions */\nvoid OPENSSL_cleanup(void);\nint OPENSSL_init_crypto(uint64_t opts, const OPENSSL_INIT_SETTINGS *settings);\nint OPENSSL_atexit(void (*handler)(void));\nvoid OPENSSL_thread_stop(void);\n\n/* Low-level control of initialization */\nOPENSSL_INIT_SETTINGS *OPENSSL_INIT_new(void);\n# ifndef OPENSSL_NO_STDIO\nint OPENSSL_INIT_set_config_filename(OPENSSL_INIT_SETTINGS *settings,\n                                     const char *config_filename);\nvoid OPENSSL_INIT_set_config_file_flags(OPENSSL_INIT_SETTINGS *settings,\n                                        unsigned long flags);\nint OPENSSL_INIT_set_config_appname(OPENSSL_INIT_SETTINGS *settings,\n                                    const char *config_appname);\n# endif\nvoid OPENSSL_INIT_free(OPENSSL_INIT_SETTINGS *settings);\n\n# if defined(OPENSSL_THREADS) && !defined(CRYPTO_TDEBUG)\n#  if defined(_WIN32)\n#   if defined(BASETYPES) || defined(_WINDEF_H)\n/* application has to include <windows.h> in order to use this */\ntypedef DWORD CRYPTO_THREAD_LOCAL;\ntypedef DWORD CRYPTO_THREAD_ID;\n\ntypedef LONG CRYPTO_ONCE;\n#    define CRYPTO_ONCE_STATIC_INIT 0\n#   endif\n#  else\n#   include <pthread.h>\ntypedef pthread_once_t CRYPTO_ONCE;\ntypedef pthread_key_t CRYPTO_THREAD_LOCAL;\ntypedef pthread_t CRYPTO_THREAD_ID;\n\n#   define CRYPTO_ONCE_STATIC_INIT PTHREAD_ONCE_INIT\n#  endif\n# endif\n\n# if !defined(CRYPTO_ONCE_STATIC_INIT)\ntypedef unsigned int CRYPTO_ONCE;\ntypedef unsigned int CRYPTO_THREAD_LOCAL;\ntypedef unsigned int CRYPTO_THREAD_ID;\n#  define CRYPTO_ONCE_STATIC_INIT 0\n# endif\n\nint CRYPTO_THREAD_run_once(CRYPTO_ONCE *once, void (*init)(void));\n\nint CRYPTO_THREAD_init_local(CRYPTO_THREAD_LOCAL *key, void (*cleanup)(void *));\nvoid *CRYPTO_THREAD_get_local(CRYPTO_THREAD_LOCAL *key);\nint CRYPTO_THREAD_set_local(CRYPTO_THREAD_LOCAL *key, void *val);\nint CRYPTO_THREAD_cleanup_local(CRYPTO_THREAD_LOCAL *key);\n\nCRYPTO_THREAD_ID CRYPTO_THREAD_get_current_id(void);\nint CRYPTO_THREAD_compare_id(CRYPTO_THREAD_ID a, CRYPTO_THREAD_ID b);\n\n\n# ifdef  __cplusplus\n}\n# endif\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/include/openssl/cryptoerr.h",
    "content": "/*\n * Generated by util/mkerr.pl DO NOT EDIT\n * Copyright 1995-2019 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef HEADER_CRYPTOERR_H\n# define HEADER_CRYPTOERR_H\n\n# ifndef HEADER_SYMHACKS_H\n#  include <openssl/symhacks.h>\n# endif\n\n# ifdef  __cplusplus\nextern \"C\"\n# endif\nint ERR_load_CRYPTO_strings(void);\n\n/*\n * CRYPTO function codes.\n */\n# define CRYPTO_F_CMAC_CTX_NEW                            120\n# define CRYPTO_F_CRYPTO_DUP_EX_DATA                      110\n# define CRYPTO_F_CRYPTO_FREE_EX_DATA                     111\n# define CRYPTO_F_CRYPTO_GET_EX_NEW_INDEX                 100\n# define CRYPTO_F_CRYPTO_MEMDUP                           115\n# define CRYPTO_F_CRYPTO_NEW_EX_DATA                      112\n# define CRYPTO_F_CRYPTO_OCB128_COPY_CTX                  121\n# define CRYPTO_F_CRYPTO_OCB128_INIT                      122\n# define CRYPTO_F_CRYPTO_SET_EX_DATA                      102\n# define CRYPTO_F_FIPS_MODE_SET                           109\n# define CRYPTO_F_GET_AND_LOCK                            113\n# define CRYPTO_F_OPENSSL_ATEXIT                          114\n# define CRYPTO_F_OPENSSL_BUF2HEXSTR                      117\n# define CRYPTO_F_OPENSSL_FOPEN                           119\n# define CRYPTO_F_OPENSSL_HEXSTR2BUF                      118\n# define CRYPTO_F_OPENSSL_INIT_CRYPTO                     116\n# define CRYPTO_F_OPENSSL_LH_NEW                          126\n# define CRYPTO_F_OPENSSL_SK_DEEP_COPY                    127\n# define CRYPTO_F_OPENSSL_SK_DUP                          128\n# define CRYPTO_F_PKEY_HMAC_INIT                          123\n# define CRYPTO_F_PKEY_POLY1305_INIT                      124\n# define CRYPTO_F_PKEY_SIPHASH_INIT                       125\n# define CRYPTO_F_SK_RESERVE                              129\n\n/*\n * CRYPTO reason codes.\n */\n# define CRYPTO_R_FIPS_MODE_NOT_SUPPORTED                 101\n# define CRYPTO_R_ILLEGAL_HEX_DIGIT                       102\n# define CRYPTO_R_ODD_NUMBER_OF_DIGITS                    103\n\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/include/openssl/ct.h",
    "content": "/*\n * Copyright 2016-2018 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef HEADER_CT_H\n# define HEADER_CT_H\n\n# include <openssl/opensslconf.h>\n\n# ifndef OPENSSL_NO_CT\n# include <openssl/ossl_typ.h>\n# include <openssl/safestack.h>\n# include <openssl/x509.h>\n# include <openssl/cterr.h>\n# ifdef  __cplusplus\nextern \"C\" {\n# endif\n\n\n/* Minimum RSA key size, from RFC6962 */\n# define SCT_MIN_RSA_BITS 2048\n\n/* All hashes are SHA256 in v1 of Certificate Transparency */\n# define CT_V1_HASHLEN SHA256_DIGEST_LENGTH\n\ntypedef enum {\n    CT_LOG_ENTRY_TYPE_NOT_SET = -1,\n    CT_LOG_ENTRY_TYPE_X509 = 0,\n    CT_LOG_ENTRY_TYPE_PRECERT = 1\n} ct_log_entry_type_t;\n\ntypedef enum {\n    SCT_VERSION_NOT_SET = -1,\n    SCT_VERSION_V1 = 0\n} sct_version_t;\n\ntypedef enum {\n    SCT_SOURCE_UNKNOWN,\n    SCT_SOURCE_TLS_EXTENSION,\n    SCT_SOURCE_X509V3_EXTENSION,\n    SCT_SOURCE_OCSP_STAPLED_RESPONSE\n} sct_source_t;\n\ntypedef enum {\n    SCT_VALIDATION_STATUS_NOT_SET,\n    SCT_VALIDATION_STATUS_UNKNOWN_LOG,\n    SCT_VALIDATION_STATUS_VALID,\n    SCT_VALIDATION_STATUS_INVALID,\n    SCT_VALIDATION_STATUS_UNVERIFIED,\n    SCT_VALIDATION_STATUS_UNKNOWN_VERSION\n} sct_validation_status_t;\n\nDEFINE_STACK_OF(SCT)\nDEFINE_STACK_OF(CTLOG)\n\n/******************************************\n * CT policy evaluation context functions *\n ******************************************/\n\n/*\n * Creates a new, empty policy evaluation context.\n * The caller is responsible for calling CT_POLICY_EVAL_CTX_free when finished\n * with the CT_POLICY_EVAL_CTX.\n */\nCT_POLICY_EVAL_CTX *CT_POLICY_EVAL_CTX_new(void);\n\n/* Deletes a policy evaluation context and anything it owns. */\nvoid CT_POLICY_EVAL_CTX_free(CT_POLICY_EVAL_CTX *ctx);\n\n/* Gets the peer certificate that the SCTs are for */\nX509* CT_POLICY_EVAL_CTX_get0_cert(const CT_POLICY_EVAL_CTX *ctx);\n\n/*\n * Sets the certificate associated with the received SCTs.\n * Increments the reference count of cert.\n * Returns 1 on success, 0 otherwise.\n */\nint CT_POLICY_EVAL_CTX_set1_cert(CT_POLICY_EVAL_CTX *ctx, X509 *cert);\n\n/* Gets the issuer of the aforementioned certificate */\nX509* CT_POLICY_EVAL_CTX_get0_issuer(const CT_POLICY_EVAL_CTX *ctx);\n\n/*\n * Sets the issuer of the certificate associated with the received SCTs.\n * Increments the reference count of issuer.\n * Returns 1 on success, 0 otherwise.\n */\nint CT_POLICY_EVAL_CTX_set1_issuer(CT_POLICY_EVAL_CTX *ctx, X509 *issuer);\n\n/* Gets the CT logs that are trusted sources of SCTs */\nconst CTLOG_STORE *CT_POLICY_EVAL_CTX_get0_log_store(const CT_POLICY_EVAL_CTX *ctx);\n\n/* Sets the log store that is in use. It must outlive the CT_POLICY_EVAL_CTX. */\nvoid CT_POLICY_EVAL_CTX_set_shared_CTLOG_STORE(CT_POLICY_EVAL_CTX *ctx,\n                                               CTLOG_STORE *log_store);\n\n/*\n * Gets the time, in milliseconds since the Unix epoch, that will be used as the\n * current time when checking whether an SCT was issued in the future.\n * Such SCTs will fail validation, as required by RFC6962.\n */\nuint64_t CT_POLICY_EVAL_CTX_get_time(const CT_POLICY_EVAL_CTX *ctx);\n\n/*\n * Sets the time to evaluate SCTs against, in milliseconds since the Unix epoch.\n * If an SCT's timestamp is after this time, it will be interpreted as having\n * been issued in the future. RFC6962 states that \"TLS clients MUST reject SCTs\n * whose timestamp is in the future\", so an SCT will not validate in this case.\n */\nvoid CT_POLICY_EVAL_CTX_set_time(CT_POLICY_EVAL_CTX *ctx, uint64_t time_in_ms);\n\n/*****************\n * SCT functions *\n *****************/\n\n/*\n * Creates a new, blank SCT.\n * The caller is responsible for calling SCT_free when finished with the SCT.\n */\nSCT *SCT_new(void);\n\n/*\n * Creates a new SCT from some base64-encoded strings.\n * The caller is responsible for calling SCT_free when finished with the SCT.\n */\nSCT *SCT_new_from_base64(unsigned char version,\n                         const char *logid_base64,\n                         ct_log_entry_type_t entry_type,\n                         uint64_t timestamp,\n                         const char *extensions_base64,\n                         const char *signature_base64);\n\n/*\n * Frees the SCT and the underlying data structures.\n */\nvoid SCT_free(SCT *sct);\n\n/*\n * Free a stack of SCTs, and the underlying SCTs themselves.\n * Intended to be compatible with X509V3_EXT_FREE.\n */\nvoid SCT_LIST_free(STACK_OF(SCT) *a);\n\n/*\n * Returns the version of the SCT.\n */\nsct_version_t SCT_get_version(const SCT *sct);\n\n/*\n * Set the version of an SCT.\n * Returns 1 on success, 0 if the version is unrecognized.\n */\n__owur int SCT_set_version(SCT *sct, sct_version_t version);\n\n/*\n * Returns the log entry type of the SCT.\n */\nct_log_entry_type_t SCT_get_log_entry_type(const SCT *sct);\n\n/*\n * Set the log entry type of an SCT.\n * Returns 1 on success, 0 otherwise.\n */\n__owur int SCT_set_log_entry_type(SCT *sct, ct_log_entry_type_t entry_type);\n\n/*\n * Gets the ID of the log that an SCT came from.\n * Ownership of the log ID remains with the SCT.\n * Returns the length of the log ID.\n */\nsize_t SCT_get0_log_id(const SCT *sct, unsigned char **log_id);\n\n/*\n * Set the log ID of an SCT to point directly to the *log_id specified.\n * The SCT takes ownership of the specified pointer.\n * Returns 1 on success, 0 otherwise.\n */\n__owur int SCT_set0_log_id(SCT *sct, unsigned char *log_id, size_t log_id_len);\n\n/*\n * Set the log ID of an SCT.\n * This makes a copy of the log_id.\n * Returns 1 on success, 0 otherwise.\n */\n__owur int SCT_set1_log_id(SCT *sct, const unsigned char *log_id,\n                           size_t log_id_len);\n\n/*\n * Returns the timestamp for the SCT (epoch time in milliseconds).\n */\nuint64_t SCT_get_timestamp(const SCT *sct);\n\n/*\n * Set the timestamp of an SCT (epoch time in milliseconds).\n */\nvoid SCT_set_timestamp(SCT *sct, uint64_t timestamp);\n\n/*\n * Return the NID for the signature used by the SCT.\n * For CT v1, this will be either NID_sha256WithRSAEncryption or\n * NID_ecdsa_with_SHA256 (or NID_undef if incorrect/unset).\n */\nint SCT_get_signature_nid(const SCT *sct);\n\n/*\n * Set the signature type of an SCT\n * For CT v1, this should be either NID_sha256WithRSAEncryption or\n * NID_ecdsa_with_SHA256.\n * Returns 1 on success, 0 otherwise.\n */\n__owur int SCT_set_signature_nid(SCT *sct, int nid);\n\n/*\n * Set *ext to point to the extension data for the SCT. ext must not be NULL.\n * The SCT retains ownership of this pointer.\n * Returns length of the data pointed to.\n */\nsize_t SCT_get0_extensions(const SCT *sct, unsigned char **ext);\n\n/*\n * Set the extensions of an SCT to point directly to the *ext specified.\n * The SCT takes ownership of the specified pointer.\n */\nvoid SCT_set0_extensions(SCT *sct, unsigned char *ext, size_t ext_len);\n\n/*\n * Set the extensions of an SCT.\n * This takes a copy of the ext.\n * Returns 1 on success, 0 otherwise.\n */\n__owur int SCT_set1_extensions(SCT *sct, const unsigned char *ext,\n                               size_t ext_len);\n\n/*\n * Set *sig to point to the signature for the SCT. sig must not be NULL.\n * The SCT retains ownership of this pointer.\n * Returns length of the data pointed to.\n */\nsize_t SCT_get0_signature(const SCT *sct, unsigned char **sig);\n\n/*\n * Set the signature of an SCT to point directly to the *sig specified.\n * The SCT takes ownership of the specified pointer.\n */\nvoid SCT_set0_signature(SCT *sct, unsigned char *sig, size_t sig_len);\n\n/*\n * Set the signature of an SCT to be a copy of the *sig specified.\n * Returns 1 on success, 0 otherwise.\n */\n__owur int SCT_set1_signature(SCT *sct, const unsigned char *sig,\n                              size_t sig_len);\n\n/*\n * The origin of this SCT, e.g. TLS extension, OCSP response, etc.\n */\nsct_source_t SCT_get_source(const SCT *sct);\n\n/*\n * Set the origin of this SCT, e.g. TLS extension, OCSP response, etc.\n * Returns 1 on success, 0 otherwise.\n */\n__owur int SCT_set_source(SCT *sct, sct_source_t source);\n\n/*\n * Returns a text string describing the validation status of |sct|.\n */\nconst char *SCT_validation_status_string(const SCT *sct);\n\n/*\n * Pretty-prints an |sct| to |out|.\n * It will be indented by the number of spaces specified by |indent|.\n * If |logs| is not NULL, it will be used to lookup the CT log that the SCT came\n * from, so that the log name can be printed.\n */\nvoid SCT_print(const SCT *sct, BIO *out, int indent, const CTLOG_STORE *logs);\n\n/*\n * Pretty-prints an |sct_list| to |out|.\n * It will be indented by the number of spaces specified by |indent|.\n * SCTs will be delimited by |separator|.\n * If |logs| is not NULL, it will be used to lookup the CT log that each SCT\n * came from, so that the log names can be printed.\n */\nvoid SCT_LIST_print(const STACK_OF(SCT) *sct_list, BIO *out, int indent,\n                    const char *separator, const CTLOG_STORE *logs);\n\n/*\n * Gets the last result of validating this SCT.\n * If it has not been validated yet, returns SCT_VALIDATION_STATUS_NOT_SET.\n */\nsct_validation_status_t SCT_get_validation_status(const SCT *sct);\n\n/*\n * Validates the given SCT with the provided context.\n * Sets the \"validation_status\" field of the SCT.\n * Returns 1 if the SCT is valid and the signature verifies.\n * Returns 0 if the SCT is invalid or could not be verified.\n * Returns -1 if an error occurs.\n */\n__owur int SCT_validate(SCT *sct, const CT_POLICY_EVAL_CTX *ctx);\n\n/*\n * Validates the given list of SCTs with the provided context.\n * Sets the \"validation_status\" field of each SCT.\n * Returns 1 if there are no invalid SCTs and all signatures verify.\n * Returns 0 if at least one SCT is invalid or could not be verified.\n * Returns a negative integer if an error occurs.\n */\n__owur int SCT_LIST_validate(const STACK_OF(SCT) *scts,\n                             CT_POLICY_EVAL_CTX *ctx);\n\n\n/*********************************\n * SCT parsing and serialisation *\n *********************************/\n\n/*\n * Serialize (to TLS format) a stack of SCTs and return the length.\n * \"a\" must not be NULL.\n * If \"pp\" is NULL, just return the length of what would have been serialized.\n * If \"pp\" is not NULL and \"*pp\" is null, function will allocate a new pointer\n * for data that caller is responsible for freeing (only if function returns\n * successfully).\n * If \"pp\" is NULL and \"*pp\" is not NULL, caller is responsible for ensuring\n * that \"*pp\" is large enough to accept all of the serialized data.\n * Returns < 0 on error, >= 0 indicating bytes written (or would have been)\n * on success.\n */\n__owur int i2o_SCT_LIST(const STACK_OF(SCT) *a, unsigned char **pp);\n\n/*\n * Convert TLS format SCT list to a stack of SCTs.\n * If \"a\" or \"*a\" is NULL, a new stack will be created that the caller is\n * responsible for freeing (by calling SCT_LIST_free).\n * \"**pp\" and \"*pp\" must not be NULL.\n * Upon success, \"*pp\" will point to after the last bytes read, and a stack\n * will be returned.\n * Upon failure, a NULL pointer will be returned, and the position of \"*pp\" is\n * not defined.\n */\nSTACK_OF(SCT) *o2i_SCT_LIST(STACK_OF(SCT) **a, const unsigned char **pp,\n                            size_t len);\n\n/*\n * Serialize (to DER format) a stack of SCTs and return the length.\n * \"a\" must not be NULL.\n * If \"pp\" is NULL, just returns the length of what would have been serialized.\n * If \"pp\" is not NULL and \"*pp\" is null, function will allocate a new pointer\n * for data that caller is responsible for freeing (only if function returns\n * successfully).\n * If \"pp\" is NULL and \"*pp\" is not NULL, caller is responsible for ensuring\n * that \"*pp\" is large enough to accept all of the serialized data.\n * Returns < 0 on error, >= 0 indicating bytes written (or would have been)\n * on success.\n */\n__owur int i2d_SCT_LIST(const STACK_OF(SCT) *a, unsigned char **pp);\n\n/*\n * Parses an SCT list in DER format and returns it.\n * If \"a\" or \"*a\" is NULL, a new stack will be created that the caller is\n * responsible for freeing (by calling SCT_LIST_free).\n * \"**pp\" and \"*pp\" must not be NULL.\n * Upon success, \"*pp\" will point to after the last bytes read, and a stack\n * will be returned.\n * Upon failure, a NULL pointer will be returned, and the position of \"*pp\" is\n * not defined.\n */\nSTACK_OF(SCT) *d2i_SCT_LIST(STACK_OF(SCT) **a, const unsigned char **pp,\n                            long len);\n\n/*\n * Serialize (to TLS format) an |sct| and write it to |out|.\n * If |out| is null, no SCT will be output but the length will still be returned.\n * If |out| points to a null pointer, a string will be allocated to hold the\n * TLS-format SCT. It is the responsibility of the caller to free it.\n * If |out| points to an allocated string, the TLS-format SCT will be written\n * to it.\n * The length of the SCT in TLS format will be returned.\n */\n__owur int i2o_SCT(const SCT *sct, unsigned char **out);\n\n/*\n * Parses an SCT in TLS format and returns it.\n * If |psct| is not null, it will end up pointing to the parsed SCT. If it\n * already points to a non-null pointer, the pointer will be free'd.\n * |in| should be a pointer to a string containing the TLS-format SCT.\n * |in| will be advanced to the end of the SCT if parsing succeeds.\n * |len| should be the length of the SCT in |in|.\n * Returns NULL if an error occurs.\n * If the SCT is an unsupported version, only the SCT's 'sct' and 'sct_len'\n * fields will be populated (with |in| and |len| respectively).\n */\nSCT *o2i_SCT(SCT **psct, const unsigned char **in, size_t len);\n\n/********************\n * CT log functions *\n ********************/\n\n/*\n * Creates a new CT log instance with the given |public_key| and |name|.\n * Takes ownership of |public_key| but copies |name|.\n * Returns NULL if malloc fails or if |public_key| cannot be converted to DER.\n * Should be deleted by the caller using CTLOG_free when no longer needed.\n */\nCTLOG *CTLOG_new(EVP_PKEY *public_key, const char *name);\n\n/*\n * Creates a new CTLOG instance with the base64-encoded SubjectPublicKeyInfo DER\n * in |pkey_base64|. The |name| is a string to help users identify this log.\n * Returns 1 on success, 0 on failure.\n * Should be deleted by the caller using CTLOG_free when no longer needed.\n */\nint CTLOG_new_from_base64(CTLOG ** ct_log,\n                          const char *pkey_base64, const char *name);\n\n/*\n * Deletes a CT log instance and its fields.\n */\nvoid CTLOG_free(CTLOG *log);\n\n/* Gets the name of the CT log */\nconst char *CTLOG_get0_name(const CTLOG *log);\n/* Gets the ID of the CT log */\nvoid CTLOG_get0_log_id(const CTLOG *log, const uint8_t **log_id,\n                       size_t *log_id_len);\n/* Gets the public key of the CT log */\nEVP_PKEY *CTLOG_get0_public_key(const CTLOG *log);\n\n/**************************\n * CT log store functions *\n **************************/\n\n/*\n * Creates a new CT log store.\n * Should be deleted by the caller using CTLOG_STORE_free when no longer needed.\n */\nCTLOG_STORE *CTLOG_STORE_new(void);\n\n/*\n * Deletes a CT log store and all of the CT log instances held within.\n */\nvoid CTLOG_STORE_free(CTLOG_STORE *store);\n\n/*\n * Finds a CT log in the store based on its log ID.\n * Returns the CT log, or NULL if no match is found.\n */\nconst CTLOG *CTLOG_STORE_get0_log_by_id(const CTLOG_STORE *store,\n                                        const uint8_t *log_id,\n                                        size_t log_id_len);\n\n/*\n * Loads a CT log list into a |store| from a |file|.\n * Returns 1 if loading is successful, or 0 otherwise.\n */\n__owur int CTLOG_STORE_load_file(CTLOG_STORE *store, const char *file);\n\n/*\n * Loads the default CT log list into a |store|.\n * Returns 1 if loading is successful, or 0 otherwise.\n */\n__owur int CTLOG_STORE_load_default_file(CTLOG_STORE *store);\n\n#  ifdef  __cplusplus\n}\n#  endif\n# endif\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/include/openssl/cterr.h",
    "content": "/*\n * Generated by util/mkerr.pl DO NOT EDIT\n * Copyright 1995-2019 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef HEADER_CTERR_H\n# define HEADER_CTERR_H\n\n# ifndef HEADER_SYMHACKS_H\n#  include <openssl/symhacks.h>\n# endif\n\n# include <openssl/opensslconf.h>\n\n# ifndef OPENSSL_NO_CT\n\n#  ifdef  __cplusplus\nextern \"C\"\n#  endif\nint ERR_load_CT_strings(void);\n\n/*\n * CT function codes.\n */\n#  define CT_F_CTLOG_NEW                                   117\n#  define CT_F_CTLOG_NEW_FROM_BASE64                       118\n#  define CT_F_CTLOG_NEW_FROM_CONF                         119\n#  define CT_F_CTLOG_STORE_LOAD_CTX_NEW                    122\n#  define CT_F_CTLOG_STORE_LOAD_FILE                       123\n#  define CT_F_CTLOG_STORE_LOAD_LOG                        130\n#  define CT_F_CTLOG_STORE_NEW                             131\n#  define CT_F_CT_BASE64_DECODE                            124\n#  define CT_F_CT_POLICY_EVAL_CTX_NEW                      133\n#  define CT_F_CT_V1_LOG_ID_FROM_PKEY                      125\n#  define CT_F_I2O_SCT                                     107\n#  define CT_F_I2O_SCT_LIST                                108\n#  define CT_F_I2O_SCT_SIGNATURE                           109\n#  define CT_F_O2I_SCT                                     110\n#  define CT_F_O2I_SCT_LIST                                111\n#  define CT_F_O2I_SCT_SIGNATURE                           112\n#  define CT_F_SCT_CTX_NEW                                 126\n#  define CT_F_SCT_CTX_VERIFY                              128\n#  define CT_F_SCT_NEW                                     100\n#  define CT_F_SCT_NEW_FROM_BASE64                         127\n#  define CT_F_SCT_SET0_LOG_ID                             101\n#  define CT_F_SCT_SET1_EXTENSIONS                         114\n#  define CT_F_SCT_SET1_LOG_ID                             115\n#  define CT_F_SCT_SET1_SIGNATURE                          116\n#  define CT_F_SCT_SET_LOG_ENTRY_TYPE                      102\n#  define CT_F_SCT_SET_SIGNATURE_NID                       103\n#  define CT_F_SCT_SET_VERSION                             104\n\n/*\n * CT reason codes.\n */\n#  define CT_R_BASE64_DECODE_ERROR                         108\n#  define CT_R_INVALID_LOG_ID_LENGTH                       100\n#  define CT_R_LOG_CONF_INVALID                            109\n#  define CT_R_LOG_CONF_INVALID_KEY                        110\n#  define CT_R_LOG_CONF_MISSING_DESCRIPTION                111\n#  define CT_R_LOG_CONF_MISSING_KEY                        112\n#  define CT_R_LOG_KEY_INVALID                             113\n#  define CT_R_SCT_FUTURE_TIMESTAMP                        116\n#  define CT_R_SCT_INVALID                                 104\n#  define CT_R_SCT_INVALID_SIGNATURE                       107\n#  define CT_R_SCT_LIST_INVALID                            105\n#  define CT_R_SCT_LOG_ID_MISMATCH                         114\n#  define CT_R_SCT_NOT_SET                                 106\n#  define CT_R_SCT_UNSUPPORTED_VERSION                     115\n#  define CT_R_UNRECOGNIZED_SIGNATURE_NID                  101\n#  define CT_R_UNSUPPORTED_ENTRY_TYPE                      102\n#  define CT_R_UNSUPPORTED_VERSION                         103\n\n# endif\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/include/openssl/des.h",
    "content": "/*\n * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef HEADER_DES_H\n# define HEADER_DES_H\n\n# include <openssl/opensslconf.h>\n\n# ifndef OPENSSL_NO_DES\n# ifdef  __cplusplus\nextern \"C\" {\n# endif\n# include <openssl/e_os2.h>\n\ntypedef unsigned int DES_LONG;\n\n# ifdef OPENSSL_BUILD_SHLIBCRYPTO\n#  undef OPENSSL_EXTERN\n#  define OPENSSL_EXTERN OPENSSL_EXPORT\n# endif\n\ntypedef unsigned char DES_cblock[8];\ntypedef /* const */ unsigned char const_DES_cblock[8];\n/*\n * With \"const\", gcc 2.8.1 on Solaris thinks that DES_cblock * and\n * const_DES_cblock * are incompatible pointer types.\n */\n\ntypedef struct DES_ks {\n    union {\n        DES_cblock cblock;\n        /*\n         * make sure things are correct size on machines with 8 byte longs\n         */\n        DES_LONG deslong[2];\n    } ks[16];\n} DES_key_schedule;\n\n# define DES_KEY_SZ      (sizeof(DES_cblock))\n# define DES_SCHEDULE_SZ (sizeof(DES_key_schedule))\n\n# define DES_ENCRYPT     1\n# define DES_DECRYPT     0\n\n# define DES_CBC_MODE    0\n# define DES_PCBC_MODE   1\n\n# define DES_ecb2_encrypt(i,o,k1,k2,e) \\\n        DES_ecb3_encrypt((i),(o),(k1),(k2),(k1),(e))\n\n# define DES_ede2_cbc_encrypt(i,o,l,k1,k2,iv,e) \\\n        DES_ede3_cbc_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(e))\n\n# define DES_ede2_cfb64_encrypt(i,o,l,k1,k2,iv,n,e) \\\n        DES_ede3_cfb64_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(n),(e))\n\n# define DES_ede2_ofb64_encrypt(i,o,l,k1,k2,iv,n) \\\n        DES_ede3_ofb64_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(n))\n\nOPENSSL_DECLARE_GLOBAL(int, DES_check_key); /* defaults to false */\n# define DES_check_key OPENSSL_GLOBAL_REF(DES_check_key)\n\nconst char *DES_options(void);\nvoid DES_ecb3_encrypt(const_DES_cblock *input, DES_cblock *output,\n                      DES_key_schedule *ks1, DES_key_schedule *ks2,\n                      DES_key_schedule *ks3, int enc);\nDES_LONG DES_cbc_cksum(const unsigned char *input, DES_cblock *output,\n                       long length, DES_key_schedule *schedule,\n                       const_DES_cblock *ivec);\n/* DES_cbc_encrypt does not update the IV!  Use DES_ncbc_encrypt instead. */\nvoid DES_cbc_encrypt(const unsigned char *input, unsigned char *output,\n                     long length, DES_key_schedule *schedule,\n                     DES_cblock *ivec, int enc);\nvoid DES_ncbc_encrypt(const unsigned char *input, unsigned char *output,\n                      long length, DES_key_schedule *schedule,\n                      DES_cblock *ivec, int enc);\nvoid DES_xcbc_encrypt(const unsigned char *input, unsigned char *output,\n                      long length, DES_key_schedule *schedule,\n                      DES_cblock *ivec, const_DES_cblock *inw,\n                      const_DES_cblock *outw, int enc);\nvoid DES_cfb_encrypt(const unsigned char *in, unsigned char *out, int numbits,\n                     long length, DES_key_schedule *schedule,\n                     DES_cblock *ivec, int enc);\nvoid DES_ecb_encrypt(const_DES_cblock *input, DES_cblock *output,\n                     DES_key_schedule *ks, int enc);\n\n/*\n * This is the DES encryption function that gets called by just about every\n * other DES routine in the library.  You should not use this function except\n * to implement 'modes' of DES.  I say this because the functions that call\n * this routine do the conversion from 'char *' to long, and this needs to be\n * done to make sure 'non-aligned' memory access do not occur.  The\n * characters are loaded 'little endian'. Data is a pointer to 2 unsigned\n * long's and ks is the DES_key_schedule to use.  enc, is non zero specifies\n * encryption, zero if decryption.\n */\nvoid DES_encrypt1(DES_LONG *data, DES_key_schedule *ks, int enc);\n\n/*\n * This functions is the same as DES_encrypt1() except that the DES initial\n * permutation (IP) and final permutation (FP) have been left out.  As for\n * DES_encrypt1(), you should not use this function. It is used by the\n * routines in the library that implement triple DES. IP() DES_encrypt2()\n * DES_encrypt2() DES_encrypt2() FP() is the same as DES_encrypt1()\n * DES_encrypt1() DES_encrypt1() except faster :-).\n */\nvoid DES_encrypt2(DES_LONG *data, DES_key_schedule *ks, int enc);\n\nvoid DES_encrypt3(DES_LONG *data, DES_key_schedule *ks1,\n                  DES_key_schedule *ks2, DES_key_schedule *ks3);\nvoid DES_decrypt3(DES_LONG *data, DES_key_schedule *ks1,\n                  DES_key_schedule *ks2, DES_key_schedule *ks3);\nvoid DES_ede3_cbc_encrypt(const unsigned char *input, unsigned char *output,\n                          long length,\n                          DES_key_schedule *ks1, DES_key_schedule *ks2,\n                          DES_key_schedule *ks3, DES_cblock *ivec, int enc);\nvoid DES_ede3_cfb64_encrypt(const unsigned char *in, unsigned char *out,\n                            long length, DES_key_schedule *ks1,\n                            DES_key_schedule *ks2, DES_key_schedule *ks3,\n                            DES_cblock *ivec, int *num, int enc);\nvoid DES_ede3_cfb_encrypt(const unsigned char *in, unsigned char *out,\n                          int numbits, long length, DES_key_schedule *ks1,\n                          DES_key_schedule *ks2, DES_key_schedule *ks3,\n                          DES_cblock *ivec, int enc);\nvoid DES_ede3_ofb64_encrypt(const unsigned char *in, unsigned char *out,\n                            long length, DES_key_schedule *ks1,\n                            DES_key_schedule *ks2, DES_key_schedule *ks3,\n                            DES_cblock *ivec, int *num);\nchar *DES_fcrypt(const char *buf, const char *salt, char *ret);\nchar *DES_crypt(const char *buf, const char *salt);\nvoid DES_ofb_encrypt(const unsigned char *in, unsigned char *out, int numbits,\n                     long length, DES_key_schedule *schedule,\n                     DES_cblock *ivec);\nvoid DES_pcbc_encrypt(const unsigned char *input, unsigned char *output,\n                      long length, DES_key_schedule *schedule,\n                      DES_cblock *ivec, int enc);\nDES_LONG DES_quad_cksum(const unsigned char *input, DES_cblock output[],\n                        long length, int out_count, DES_cblock *seed);\nint DES_random_key(DES_cblock *ret);\nvoid DES_set_odd_parity(DES_cblock *key);\nint DES_check_key_parity(const_DES_cblock *key);\nint DES_is_weak_key(const_DES_cblock *key);\n/*\n * DES_set_key (= set_key = DES_key_sched = key_sched) calls\n * DES_set_key_checked if global variable DES_check_key is set,\n * DES_set_key_unchecked otherwise.\n */\nint DES_set_key(const_DES_cblock *key, DES_key_schedule *schedule);\nint DES_key_sched(const_DES_cblock *key, DES_key_schedule *schedule);\nint DES_set_key_checked(const_DES_cblock *key, DES_key_schedule *schedule);\nvoid DES_set_key_unchecked(const_DES_cblock *key, DES_key_schedule *schedule);\nvoid DES_string_to_key(const char *str, DES_cblock *key);\nvoid DES_string_to_2keys(const char *str, DES_cblock *key1, DES_cblock *key2);\nvoid DES_cfb64_encrypt(const unsigned char *in, unsigned char *out,\n                       long length, DES_key_schedule *schedule,\n                       DES_cblock *ivec, int *num, int enc);\nvoid DES_ofb64_encrypt(const unsigned char *in, unsigned char *out,\n                       long length, DES_key_schedule *schedule,\n                       DES_cblock *ivec, int *num);\n\n# define DES_fixup_key_parity DES_set_odd_parity\n\n# ifdef  __cplusplus\n}\n# endif\n# endif\n\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/include/openssl/dh.h",
    "content": "/*\n * Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef HEADER_DH_H\n# define HEADER_DH_H\n\n# include <openssl/opensslconf.h>\n\n# ifndef OPENSSL_NO_DH\n# include <openssl/e_os2.h>\n# include <openssl/bio.h>\n# include <openssl/asn1.h>\n# include <openssl/ossl_typ.h>\n# if OPENSSL_API_COMPAT < 0x10100000L\n#  include <openssl/bn.h>\n# endif\n# include <openssl/dherr.h>\n\n# ifdef  __cplusplus\nextern \"C\" {\n# endif\n\n# ifndef OPENSSL_DH_MAX_MODULUS_BITS\n#  define OPENSSL_DH_MAX_MODULUS_BITS    10000\n# endif\n\n# define OPENSSL_DH_FIPS_MIN_MODULUS_BITS 1024\n\n# define DH_FLAG_CACHE_MONT_P     0x01\n\n# if OPENSSL_API_COMPAT < 0x10100000L\n/*\n * Does nothing. Previously this switched off constant time behaviour.\n */\n#  define DH_FLAG_NO_EXP_CONSTTIME 0x00\n# endif\n\n/*\n * If this flag is set the DH method is FIPS compliant and can be used in\n * FIPS mode. This is set in the validated module method. If an application\n * sets this flag in its own methods it is its responsibility to ensure the\n * result is compliant.\n */\n\n# define DH_FLAG_FIPS_METHOD                     0x0400\n\n/*\n * If this flag is set the operations normally disabled in FIPS mode are\n * permitted it is then the applications responsibility to ensure that the\n * usage is compliant.\n */\n\n# define DH_FLAG_NON_FIPS_ALLOW                  0x0400\n\n/* Already defined in ossl_typ.h */\n/* typedef struct dh_st DH; */\n/* typedef struct dh_method DH_METHOD; */\n\nDECLARE_ASN1_ITEM(DHparams)\n\n# define DH_GENERATOR_2          2\n/* #define DH_GENERATOR_3       3 */\n# define DH_GENERATOR_5          5\n\n/* DH_check error codes */\n# define DH_CHECK_P_NOT_PRIME            0x01\n# define DH_CHECK_P_NOT_SAFE_PRIME       0x02\n# define DH_UNABLE_TO_CHECK_GENERATOR    0x04\n# define DH_NOT_SUITABLE_GENERATOR       0x08\n# define DH_CHECK_Q_NOT_PRIME            0x10\n# define DH_CHECK_INVALID_Q_VALUE        0x20\n# define DH_CHECK_INVALID_J_VALUE        0x40\n\n/* DH_check_pub_key error codes */\n# define DH_CHECK_PUBKEY_TOO_SMALL       0x01\n# define DH_CHECK_PUBKEY_TOO_LARGE       0x02\n# define DH_CHECK_PUBKEY_INVALID         0x04\n\n/*\n * primes p where (p-1)/2 is prime too are called \"safe\"; we define this for\n * backward compatibility:\n */\n# define DH_CHECK_P_NOT_STRONG_PRIME     DH_CHECK_P_NOT_SAFE_PRIME\n\n# define d2i_DHparams_fp(fp,x) \\\n    (DH *)ASN1_d2i_fp((char *(*)())DH_new, \\\n                      (char *(*)())d2i_DHparams, \\\n                      (fp), \\\n                      (unsigned char **)(x))\n# define i2d_DHparams_fp(fp,x) \\\n    ASN1_i2d_fp(i2d_DHparams,(fp), (unsigned char *)(x))\n# define d2i_DHparams_bio(bp,x) \\\n    ASN1_d2i_bio_of(DH, DH_new, d2i_DHparams, bp, x)\n# define i2d_DHparams_bio(bp,x) \\\n    ASN1_i2d_bio_of_const(DH,i2d_DHparams,bp,x)\n\n# define d2i_DHxparams_fp(fp,x) \\\n    (DH *)ASN1_d2i_fp((char *(*)())DH_new, \\\n                      (char *(*)())d2i_DHxparams, \\\n                      (fp), \\\n                      (unsigned char **)(x))\n# define i2d_DHxparams_fp(fp,x) \\\n    ASN1_i2d_fp(i2d_DHxparams,(fp), (unsigned char *)(x))\n# define d2i_DHxparams_bio(bp,x) \\\n    ASN1_d2i_bio_of(DH, DH_new, d2i_DHxparams, bp, x)\n# define i2d_DHxparams_bio(bp,x) \\\n    ASN1_i2d_bio_of_const(DH, i2d_DHxparams, bp, x)\n\nDH *DHparams_dup(DH *);\n\nconst DH_METHOD *DH_OpenSSL(void);\n\nvoid DH_set_default_method(const DH_METHOD *meth);\nconst DH_METHOD *DH_get_default_method(void);\nint DH_set_method(DH *dh, const DH_METHOD *meth);\nDH *DH_new_method(ENGINE *engine);\n\nDH *DH_new(void);\nvoid DH_free(DH *dh);\nint DH_up_ref(DH *dh);\nint DH_bits(const DH *dh);\nint DH_size(const DH *dh);\nint DH_security_bits(const DH *dh);\n#define DH_get_ex_new_index(l, p, newf, dupf, freef) \\\n    CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_DH, l, p, newf, dupf, freef)\nint DH_set_ex_data(DH *d, int idx, void *arg);\nvoid *DH_get_ex_data(DH *d, int idx);\n\n/* Deprecated version */\nDEPRECATEDIN_0_9_8(DH *DH_generate_parameters(int prime_len, int generator,\n                                              void (*callback) (int, int,\n                                                                void *),\n                                              void *cb_arg))\n\n/* New version */\nint DH_generate_parameters_ex(DH *dh, int prime_len, int generator,\n                              BN_GENCB *cb);\n\nint DH_check_params_ex(const DH *dh);\nint DH_check_ex(const DH *dh);\nint DH_check_pub_key_ex(const DH *dh, const BIGNUM *pub_key);\nint DH_check_params(const DH *dh, int *ret);\nint DH_check(const DH *dh, int *codes);\nint DH_check_pub_key(const DH *dh, const BIGNUM *pub_key, int *codes);\nint DH_generate_key(DH *dh);\nint DH_compute_key(unsigned char *key, const BIGNUM *pub_key, DH *dh);\nint DH_compute_key_padded(unsigned char *key, const BIGNUM *pub_key, DH *dh);\nDH *d2i_DHparams(DH **a, const unsigned char **pp, long length);\nint i2d_DHparams(const DH *a, unsigned char **pp);\nDH *d2i_DHxparams(DH **a, const unsigned char **pp, long length);\nint i2d_DHxparams(const DH *a, unsigned char **pp);\n# ifndef OPENSSL_NO_STDIO\nint DHparams_print_fp(FILE *fp, const DH *x);\n# endif\nint DHparams_print(BIO *bp, const DH *x);\n\n/* RFC 5114 parameters */\nDH *DH_get_1024_160(void);\nDH *DH_get_2048_224(void);\nDH *DH_get_2048_256(void);\n\n/* Named parameters, currently RFC7919 */\nDH *DH_new_by_nid(int nid);\nint DH_get_nid(const DH *dh);\n\n# ifndef OPENSSL_NO_CMS\n/* RFC2631 KDF */\nint DH_KDF_X9_42(unsigned char *out, size_t outlen,\n                 const unsigned char *Z, size_t Zlen,\n                 ASN1_OBJECT *key_oid,\n                 const unsigned char *ukm, size_t ukmlen, const EVP_MD *md);\n# endif\n\nvoid DH_get0_pqg(const DH *dh,\n                 const BIGNUM **p, const BIGNUM **q, const BIGNUM **g);\nint DH_set0_pqg(DH *dh, BIGNUM *p, BIGNUM *q, BIGNUM *g);\nvoid DH_get0_key(const DH *dh,\n                 const BIGNUM **pub_key, const BIGNUM **priv_key);\nint DH_set0_key(DH *dh, BIGNUM *pub_key, BIGNUM *priv_key);\nconst BIGNUM *DH_get0_p(const DH *dh);\nconst BIGNUM *DH_get0_q(const DH *dh);\nconst BIGNUM *DH_get0_g(const DH *dh);\nconst BIGNUM *DH_get0_priv_key(const DH *dh);\nconst BIGNUM *DH_get0_pub_key(const DH *dh);\nvoid DH_clear_flags(DH *dh, int flags);\nint DH_test_flags(const DH *dh, int flags);\nvoid DH_set_flags(DH *dh, int flags);\nENGINE *DH_get0_engine(DH *d);\nlong DH_get_length(const DH *dh);\nint DH_set_length(DH *dh, long length);\n\nDH_METHOD *DH_meth_new(const char *name, int flags);\nvoid DH_meth_free(DH_METHOD *dhm);\nDH_METHOD *DH_meth_dup(const DH_METHOD *dhm);\nconst char *DH_meth_get0_name(const DH_METHOD *dhm);\nint DH_meth_set1_name(DH_METHOD *dhm, const char *name);\nint DH_meth_get_flags(const DH_METHOD *dhm);\nint DH_meth_set_flags(DH_METHOD *dhm, int flags);\nvoid *DH_meth_get0_app_data(const DH_METHOD *dhm);\nint DH_meth_set0_app_data(DH_METHOD *dhm, void *app_data);\nint (*DH_meth_get_generate_key(const DH_METHOD *dhm)) (DH *);\nint DH_meth_set_generate_key(DH_METHOD *dhm, int (*generate_key) (DH *));\nint (*DH_meth_get_compute_key(const DH_METHOD *dhm))\n        (unsigned char *key, const BIGNUM *pub_key, DH *dh);\nint DH_meth_set_compute_key(DH_METHOD *dhm,\n        int (*compute_key) (unsigned char *key, const BIGNUM *pub_key, DH *dh));\nint (*DH_meth_get_bn_mod_exp(const DH_METHOD *dhm))\n    (const DH *, BIGNUM *, const BIGNUM *, const BIGNUM *, const BIGNUM *,\n     BN_CTX *, BN_MONT_CTX *);\nint DH_meth_set_bn_mod_exp(DH_METHOD *dhm,\n    int (*bn_mod_exp) (const DH *, BIGNUM *, const BIGNUM *, const BIGNUM *,\n                       const BIGNUM *, BN_CTX *, BN_MONT_CTX *));\nint (*DH_meth_get_init(const DH_METHOD *dhm))(DH *);\nint DH_meth_set_init(DH_METHOD *dhm, int (*init)(DH *));\nint (*DH_meth_get_finish(const DH_METHOD *dhm)) (DH *);\nint DH_meth_set_finish(DH_METHOD *dhm, int (*finish) (DH *));\nint (*DH_meth_get_generate_params(const DH_METHOD *dhm))\n        (DH *, int, int, BN_GENCB *);\nint DH_meth_set_generate_params(DH_METHOD *dhm,\n        int (*generate_params) (DH *, int, int, BN_GENCB *));\n\n\n# define EVP_PKEY_CTX_set_dh_paramgen_prime_len(ctx, len) \\\n        EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DH, EVP_PKEY_OP_PARAMGEN, \\\n                        EVP_PKEY_CTRL_DH_PARAMGEN_PRIME_LEN, len, NULL)\n\n# define EVP_PKEY_CTX_set_dh_paramgen_subprime_len(ctx, len) \\\n        EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DH, EVP_PKEY_OP_PARAMGEN, \\\n                        EVP_PKEY_CTRL_DH_PARAMGEN_SUBPRIME_LEN, len, NULL)\n\n# define EVP_PKEY_CTX_set_dh_paramgen_type(ctx, typ) \\\n        EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DH, EVP_PKEY_OP_PARAMGEN, \\\n                        EVP_PKEY_CTRL_DH_PARAMGEN_TYPE, typ, NULL)\n\n# define EVP_PKEY_CTX_set_dh_paramgen_generator(ctx, gen) \\\n        EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DH, EVP_PKEY_OP_PARAMGEN, \\\n                        EVP_PKEY_CTRL_DH_PARAMGEN_GENERATOR, gen, NULL)\n\n# define EVP_PKEY_CTX_set_dh_rfc5114(ctx, gen) \\\n        EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DHX, EVP_PKEY_OP_PARAMGEN, \\\n                        EVP_PKEY_CTRL_DH_RFC5114, gen, NULL)\n\n# define EVP_PKEY_CTX_set_dhx_rfc5114(ctx, gen) \\\n        EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DHX, EVP_PKEY_OP_PARAMGEN, \\\n                        EVP_PKEY_CTRL_DH_RFC5114, gen, NULL)\n\n# define EVP_PKEY_CTX_set_dh_nid(ctx, nid) \\\n        EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DH, \\\n                        EVP_PKEY_OP_PARAMGEN | EVP_PKEY_OP_KEYGEN, \\\n                        EVP_PKEY_CTRL_DH_NID, nid, NULL)\n\n# define EVP_PKEY_CTX_set_dh_pad(ctx, pad) \\\n        EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DH, EVP_PKEY_OP_DERIVE, \\\n                          EVP_PKEY_CTRL_DH_PAD, pad, NULL)\n\n# define EVP_PKEY_CTX_set_dh_kdf_type(ctx, kdf) \\\n        EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DHX, \\\n                                EVP_PKEY_OP_DERIVE, \\\n                                EVP_PKEY_CTRL_DH_KDF_TYPE, kdf, NULL)\n\n# define EVP_PKEY_CTX_get_dh_kdf_type(ctx) \\\n        EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DHX, \\\n                                EVP_PKEY_OP_DERIVE, \\\n                                EVP_PKEY_CTRL_DH_KDF_TYPE, -2, NULL)\n\n# define EVP_PKEY_CTX_set0_dh_kdf_oid(ctx, oid) \\\n        EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DHX, \\\n                                EVP_PKEY_OP_DERIVE, \\\n                                EVP_PKEY_CTRL_DH_KDF_OID, 0, (void *)(oid))\n\n# define EVP_PKEY_CTX_get0_dh_kdf_oid(ctx, poid) \\\n        EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DHX, \\\n                                EVP_PKEY_OP_DERIVE, \\\n                                EVP_PKEY_CTRL_GET_DH_KDF_OID, 0, (void *)(poid))\n\n# define EVP_PKEY_CTX_set_dh_kdf_md(ctx, md) \\\n        EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DHX, \\\n                                EVP_PKEY_OP_DERIVE, \\\n                                EVP_PKEY_CTRL_DH_KDF_MD, 0, (void *)(md))\n\n# define EVP_PKEY_CTX_get_dh_kdf_md(ctx, pmd) \\\n        EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DHX, \\\n                                EVP_PKEY_OP_DERIVE, \\\n                                EVP_PKEY_CTRL_GET_DH_KDF_MD, 0, (void *)(pmd))\n\n# define EVP_PKEY_CTX_set_dh_kdf_outlen(ctx, len) \\\n        EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DHX, \\\n                                EVP_PKEY_OP_DERIVE, \\\n                                EVP_PKEY_CTRL_DH_KDF_OUTLEN, len, NULL)\n\n# define EVP_PKEY_CTX_get_dh_kdf_outlen(ctx, plen) \\\n        EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DHX, \\\n                                EVP_PKEY_OP_DERIVE, \\\n                        EVP_PKEY_CTRL_GET_DH_KDF_OUTLEN, 0, (void *)(plen))\n\n# define EVP_PKEY_CTX_set0_dh_kdf_ukm(ctx, p, plen) \\\n        EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DHX, \\\n                                EVP_PKEY_OP_DERIVE, \\\n                                EVP_PKEY_CTRL_DH_KDF_UKM, plen, (void *)(p))\n\n# define EVP_PKEY_CTX_get0_dh_kdf_ukm(ctx, p) \\\n        EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DHX, \\\n                                EVP_PKEY_OP_DERIVE, \\\n                                EVP_PKEY_CTRL_GET_DH_KDF_UKM, 0, (void *)(p))\n\n# define EVP_PKEY_CTRL_DH_PARAMGEN_PRIME_LEN     (EVP_PKEY_ALG_CTRL + 1)\n# define EVP_PKEY_CTRL_DH_PARAMGEN_GENERATOR     (EVP_PKEY_ALG_CTRL + 2)\n# define EVP_PKEY_CTRL_DH_RFC5114                (EVP_PKEY_ALG_CTRL + 3)\n# define EVP_PKEY_CTRL_DH_PARAMGEN_SUBPRIME_LEN  (EVP_PKEY_ALG_CTRL + 4)\n# define EVP_PKEY_CTRL_DH_PARAMGEN_TYPE          (EVP_PKEY_ALG_CTRL + 5)\n# define EVP_PKEY_CTRL_DH_KDF_TYPE               (EVP_PKEY_ALG_CTRL + 6)\n# define EVP_PKEY_CTRL_DH_KDF_MD                 (EVP_PKEY_ALG_CTRL + 7)\n# define EVP_PKEY_CTRL_GET_DH_KDF_MD             (EVP_PKEY_ALG_CTRL + 8)\n# define EVP_PKEY_CTRL_DH_KDF_OUTLEN             (EVP_PKEY_ALG_CTRL + 9)\n# define EVP_PKEY_CTRL_GET_DH_KDF_OUTLEN         (EVP_PKEY_ALG_CTRL + 10)\n# define EVP_PKEY_CTRL_DH_KDF_UKM                (EVP_PKEY_ALG_CTRL + 11)\n# define EVP_PKEY_CTRL_GET_DH_KDF_UKM            (EVP_PKEY_ALG_CTRL + 12)\n# define EVP_PKEY_CTRL_DH_KDF_OID                (EVP_PKEY_ALG_CTRL + 13)\n# define EVP_PKEY_CTRL_GET_DH_KDF_OID            (EVP_PKEY_ALG_CTRL + 14)\n# define EVP_PKEY_CTRL_DH_NID                    (EVP_PKEY_ALG_CTRL + 15)\n# define EVP_PKEY_CTRL_DH_PAD                    (EVP_PKEY_ALG_CTRL + 16)\n\n/* KDF types */\n# define EVP_PKEY_DH_KDF_NONE                            1\n# ifndef OPENSSL_NO_CMS\n# define EVP_PKEY_DH_KDF_X9_42                           2\n# endif\n\n\n#  ifdef  __cplusplus\n}\n#  endif\n# endif\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/include/openssl/dherr.h",
    "content": "/*\n * Generated by util/mkerr.pl DO NOT EDIT\n * Copyright 1995-2019 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef HEADER_DHERR_H\n# define HEADER_DHERR_H\n\n# ifndef HEADER_SYMHACKS_H\n#  include <openssl/symhacks.h>\n# endif\n\n# include <openssl/opensslconf.h>\n\n# ifndef OPENSSL_NO_DH\n\n#  ifdef  __cplusplus\nextern \"C\"\n#  endif\nint ERR_load_DH_strings(void);\n\n/*\n * DH function codes.\n */\n#  define DH_F_COMPUTE_KEY                                 102\n#  define DH_F_DHPARAMS_PRINT_FP                           101\n#  define DH_F_DH_BUILTIN_GENPARAMS                        106\n#  define DH_F_DH_CHECK_EX                                 121\n#  define DH_F_DH_CHECK_PARAMS_EX                          122\n#  define DH_F_DH_CHECK_PUB_KEY_EX                         123\n#  define DH_F_DH_CMS_DECRYPT                              114\n#  define DH_F_DH_CMS_SET_PEERKEY                          115\n#  define DH_F_DH_CMS_SET_SHARED_INFO                      116\n#  define DH_F_DH_METH_DUP                                 117\n#  define DH_F_DH_METH_NEW                                 118\n#  define DH_F_DH_METH_SET1_NAME                           119\n#  define DH_F_DH_NEW_BY_NID                               104\n#  define DH_F_DH_NEW_METHOD                               105\n#  define DH_F_DH_PARAM_DECODE                             107\n#  define DH_F_DH_PKEY_PUBLIC_CHECK                        124\n#  define DH_F_DH_PRIV_DECODE                              110\n#  define DH_F_DH_PRIV_ENCODE                              111\n#  define DH_F_DH_PUB_DECODE                               108\n#  define DH_F_DH_PUB_ENCODE                               109\n#  define DH_F_DO_DH_PRINT                                 100\n#  define DH_F_GENERATE_KEY                                103\n#  define DH_F_PKEY_DH_CTRL_STR                            120\n#  define DH_F_PKEY_DH_DERIVE                              112\n#  define DH_F_PKEY_DH_INIT                                125\n#  define DH_F_PKEY_DH_KEYGEN                              113\n\n/*\n * DH reason codes.\n */\n#  define DH_R_BAD_GENERATOR                               101\n#  define DH_R_BN_DECODE_ERROR                             109\n#  define DH_R_BN_ERROR                                    106\n#  define DH_R_CHECK_INVALID_J_VALUE                       115\n#  define DH_R_CHECK_INVALID_Q_VALUE                       116\n#  define DH_R_CHECK_PUBKEY_INVALID                        122\n#  define DH_R_CHECK_PUBKEY_TOO_LARGE                      123\n#  define DH_R_CHECK_PUBKEY_TOO_SMALL                      124\n#  define DH_R_CHECK_P_NOT_PRIME                           117\n#  define DH_R_CHECK_P_NOT_SAFE_PRIME                      118\n#  define DH_R_CHECK_Q_NOT_PRIME                           119\n#  define DH_R_DECODE_ERROR                                104\n#  define DH_R_INVALID_PARAMETER_NAME                      110\n#  define DH_R_INVALID_PARAMETER_NID                       114\n#  define DH_R_INVALID_PUBKEY                              102\n#  define DH_R_KDF_PARAMETER_ERROR                         112\n#  define DH_R_KEYS_NOT_SET                                108\n#  define DH_R_MISSING_PUBKEY                              125\n#  define DH_R_MODULUS_TOO_LARGE                           103\n#  define DH_R_NOT_SUITABLE_GENERATOR                      120\n#  define DH_R_NO_PARAMETERS_SET                           107\n#  define DH_R_NO_PRIVATE_VALUE                            100\n#  define DH_R_PARAMETER_ENCODING_ERROR                    105\n#  define DH_R_PEER_KEY_ERROR                              111\n#  define DH_R_SHARED_INFO_ERROR                           113\n#  define DH_R_UNABLE_TO_CHECK_GENERATOR                   121\n\n# endif\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/include/openssl/dsa.h",
    "content": "/*\n * Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef HEADER_DSA_H\n# define HEADER_DSA_H\n\n# include <openssl/opensslconf.h>\n\n# ifndef OPENSSL_NO_DSA\n# ifdef  __cplusplus\nextern \"C\" {\n# endif\n# include <openssl/e_os2.h>\n# include <openssl/bio.h>\n# include <openssl/crypto.h>\n# include <openssl/ossl_typ.h>\n# include <openssl/bn.h>\n# if OPENSSL_API_COMPAT < 0x10100000L\n#  include <openssl/dh.h>\n# endif\n# include <openssl/dsaerr.h>\n\n# ifndef OPENSSL_DSA_MAX_MODULUS_BITS\n#  define OPENSSL_DSA_MAX_MODULUS_BITS   10000\n# endif\n\n# define OPENSSL_DSA_FIPS_MIN_MODULUS_BITS 1024\n\n# define DSA_FLAG_CACHE_MONT_P   0x01\n# if OPENSSL_API_COMPAT < 0x10100000L\n/*\n * Does nothing. Previously this switched off constant time behaviour.\n */\n#  define DSA_FLAG_NO_EXP_CONSTTIME       0x00\n# endif\n\n/*\n * If this flag is set the DSA method is FIPS compliant and can be used in\n * FIPS mode. This is set in the validated module method. If an application\n * sets this flag in its own methods it is its responsibility to ensure the\n * result is compliant.\n */\n\n# define DSA_FLAG_FIPS_METHOD                    0x0400\n\n/*\n * If this flag is set the operations normally disabled in FIPS mode are\n * permitted it is then the applications responsibility to ensure that the\n * usage is compliant.\n */\n\n# define DSA_FLAG_NON_FIPS_ALLOW                 0x0400\n# define DSA_FLAG_FIPS_CHECKED                   0x0800\n\n/* Already defined in ossl_typ.h */\n/* typedef struct dsa_st DSA; */\n/* typedef struct dsa_method DSA_METHOD; */\n\ntypedef struct DSA_SIG_st DSA_SIG;\n\n# define d2i_DSAparams_fp(fp,x) (DSA *)ASN1_d2i_fp((char *(*)())DSA_new, \\\n                (char *(*)())d2i_DSAparams,(fp),(unsigned char **)(x))\n# define i2d_DSAparams_fp(fp,x) ASN1_i2d_fp(i2d_DSAparams,(fp), \\\n                (unsigned char *)(x))\n# define d2i_DSAparams_bio(bp,x) ASN1_d2i_bio_of(DSA,DSA_new,d2i_DSAparams,bp,x)\n# define i2d_DSAparams_bio(bp,x) ASN1_i2d_bio_of_const(DSA,i2d_DSAparams,bp,x)\n\nDSA *DSAparams_dup(DSA *x);\nDSA_SIG *DSA_SIG_new(void);\nvoid DSA_SIG_free(DSA_SIG *a);\nint i2d_DSA_SIG(const DSA_SIG *a, unsigned char **pp);\nDSA_SIG *d2i_DSA_SIG(DSA_SIG **v, const unsigned char **pp, long length);\nvoid DSA_SIG_get0(const DSA_SIG *sig, const BIGNUM **pr, const BIGNUM **ps);\nint DSA_SIG_set0(DSA_SIG *sig, BIGNUM *r, BIGNUM *s);\n\nDSA_SIG *DSA_do_sign(const unsigned char *dgst, int dlen, DSA *dsa);\nint DSA_do_verify(const unsigned char *dgst, int dgst_len,\n                  DSA_SIG *sig, DSA *dsa);\n\nconst DSA_METHOD *DSA_OpenSSL(void);\n\nvoid DSA_set_default_method(const DSA_METHOD *);\nconst DSA_METHOD *DSA_get_default_method(void);\nint DSA_set_method(DSA *dsa, const DSA_METHOD *);\nconst DSA_METHOD *DSA_get_method(DSA *d);\n\nDSA *DSA_new(void);\nDSA *DSA_new_method(ENGINE *engine);\nvoid DSA_free(DSA *r);\n/* \"up\" the DSA object's reference count */\nint DSA_up_ref(DSA *r);\nint DSA_size(const DSA *);\nint DSA_bits(const DSA *d);\nint DSA_security_bits(const DSA *d);\n        /* next 4 return -1 on error */\nDEPRECATEDIN_1_2_0(int DSA_sign_setup(DSA *dsa, BN_CTX *ctx_in, BIGNUM **kinvp, BIGNUM **rp))\nint DSA_sign(int type, const unsigned char *dgst, int dlen,\n             unsigned char *sig, unsigned int *siglen, DSA *dsa);\nint DSA_verify(int type, const unsigned char *dgst, int dgst_len,\n               const unsigned char *sigbuf, int siglen, DSA *dsa);\n#define DSA_get_ex_new_index(l, p, newf, dupf, freef) \\\n    CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_DSA, l, p, newf, dupf, freef)\nint DSA_set_ex_data(DSA *d, int idx, void *arg);\nvoid *DSA_get_ex_data(DSA *d, int idx);\n\nDSA *d2i_DSAPublicKey(DSA **a, const unsigned char **pp, long length);\nDSA *d2i_DSAPrivateKey(DSA **a, const unsigned char **pp, long length);\nDSA *d2i_DSAparams(DSA **a, const unsigned char **pp, long length);\n\n/* Deprecated version */\nDEPRECATEDIN_0_9_8(DSA *DSA_generate_parameters(int bits,\n                                                unsigned char *seed,\n                                                int seed_len,\n                                                int *counter_ret,\n                                                unsigned long *h_ret, void\n                                                 (*callback) (int, int,\n                                                              void *),\n                                                void *cb_arg))\n\n/* New version */\nint DSA_generate_parameters_ex(DSA *dsa, int bits,\n                               const unsigned char *seed, int seed_len,\n                               int *counter_ret, unsigned long *h_ret,\n                               BN_GENCB *cb);\n\nint DSA_generate_key(DSA *a);\nint i2d_DSAPublicKey(const DSA *a, unsigned char **pp);\nint i2d_DSAPrivateKey(const DSA *a, unsigned char **pp);\nint i2d_DSAparams(const DSA *a, unsigned char **pp);\n\nint DSAparams_print(BIO *bp, const DSA *x);\nint DSA_print(BIO *bp, const DSA *x, int off);\n# ifndef OPENSSL_NO_STDIO\nint DSAparams_print_fp(FILE *fp, const DSA *x);\nint DSA_print_fp(FILE *bp, const DSA *x, int off);\n# endif\n\n# define DSS_prime_checks 64\n/*\n * Primality test according to FIPS PUB 186-4, Appendix C.3. Since we only\n * have one value here we set the number of checks to 64 which is the 128 bit\n * security level that is the highest level and valid for creating a 3072 bit\n * DSA key.\n */\n# define DSA_is_prime(n, callback, cb_arg) \\\n        BN_is_prime(n, DSS_prime_checks, callback, NULL, cb_arg)\n\n# ifndef OPENSSL_NO_DH\n/*\n * Convert DSA structure (key or just parameters) into DH structure (be\n * careful to avoid small subgroup attacks when using this!)\n */\nDH *DSA_dup_DH(const DSA *r);\n# endif\n\n# define EVP_PKEY_CTX_set_dsa_paramgen_bits(ctx, nbits) \\\n        EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DSA, EVP_PKEY_OP_PARAMGEN, \\\n                                EVP_PKEY_CTRL_DSA_PARAMGEN_BITS, nbits, NULL)\n# define EVP_PKEY_CTX_set_dsa_paramgen_q_bits(ctx, qbits) \\\n        EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DSA, EVP_PKEY_OP_PARAMGEN, \\\n                                EVP_PKEY_CTRL_DSA_PARAMGEN_Q_BITS, qbits, NULL)\n# define EVP_PKEY_CTX_set_dsa_paramgen_md(ctx, md) \\\n        EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DSA, EVP_PKEY_OP_PARAMGEN, \\\n                                EVP_PKEY_CTRL_DSA_PARAMGEN_MD, 0, (void *)(md))\n\n# define EVP_PKEY_CTRL_DSA_PARAMGEN_BITS         (EVP_PKEY_ALG_CTRL + 1)\n# define EVP_PKEY_CTRL_DSA_PARAMGEN_Q_BITS       (EVP_PKEY_ALG_CTRL + 2)\n# define EVP_PKEY_CTRL_DSA_PARAMGEN_MD           (EVP_PKEY_ALG_CTRL + 3)\n\nvoid DSA_get0_pqg(const DSA *d,\n                  const BIGNUM **p, const BIGNUM **q, const BIGNUM **g);\nint DSA_set0_pqg(DSA *d, BIGNUM *p, BIGNUM *q, BIGNUM *g);\nvoid DSA_get0_key(const DSA *d,\n                  const BIGNUM **pub_key, const BIGNUM **priv_key);\nint DSA_set0_key(DSA *d, BIGNUM *pub_key, BIGNUM *priv_key);\nconst BIGNUM *DSA_get0_p(const DSA *d);\nconst BIGNUM *DSA_get0_q(const DSA *d);\nconst BIGNUM *DSA_get0_g(const DSA *d);\nconst BIGNUM *DSA_get0_pub_key(const DSA *d);\nconst BIGNUM *DSA_get0_priv_key(const DSA *d);\nvoid DSA_clear_flags(DSA *d, int flags);\nint DSA_test_flags(const DSA *d, int flags);\nvoid DSA_set_flags(DSA *d, int flags);\nENGINE *DSA_get0_engine(DSA *d);\n\nDSA_METHOD *DSA_meth_new(const char *name, int flags);\nvoid DSA_meth_free(DSA_METHOD *dsam);\nDSA_METHOD *DSA_meth_dup(const DSA_METHOD *dsam);\nconst char *DSA_meth_get0_name(const DSA_METHOD *dsam);\nint DSA_meth_set1_name(DSA_METHOD *dsam, const char *name);\nint DSA_meth_get_flags(const DSA_METHOD *dsam);\nint DSA_meth_set_flags(DSA_METHOD *dsam, int flags);\nvoid *DSA_meth_get0_app_data(const DSA_METHOD *dsam);\nint DSA_meth_set0_app_data(DSA_METHOD *dsam, void *app_data);\nDSA_SIG *(*DSA_meth_get_sign(const DSA_METHOD *dsam))\n        (const unsigned char *, int, DSA *);\nint DSA_meth_set_sign(DSA_METHOD *dsam,\n                       DSA_SIG *(*sign) (const unsigned char *, int, DSA *));\nint (*DSA_meth_get_sign_setup(const DSA_METHOD *dsam))\n        (DSA *, BN_CTX *, BIGNUM **, BIGNUM **);\nint DSA_meth_set_sign_setup(DSA_METHOD *dsam,\n        int (*sign_setup) (DSA *, BN_CTX *, BIGNUM **, BIGNUM **));\nint (*DSA_meth_get_verify(const DSA_METHOD *dsam))\n        (const unsigned char *, int, DSA_SIG *, DSA *);\nint DSA_meth_set_verify(DSA_METHOD *dsam,\n    int (*verify) (const unsigned char *, int, DSA_SIG *, DSA *));\nint (*DSA_meth_get_mod_exp(const DSA_METHOD *dsam))\n        (DSA *, BIGNUM *, const BIGNUM *, const BIGNUM *, const BIGNUM *,\n         const BIGNUM *, const BIGNUM *, BN_CTX *, BN_MONT_CTX *);\nint DSA_meth_set_mod_exp(DSA_METHOD *dsam,\n    int (*mod_exp) (DSA *, BIGNUM *, const BIGNUM *, const BIGNUM *,\n                    const BIGNUM *, const BIGNUM *, const BIGNUM *, BN_CTX *,\n                    BN_MONT_CTX *));\nint (*DSA_meth_get_bn_mod_exp(const DSA_METHOD *dsam))\n    (DSA *, BIGNUM *, const BIGNUM *, const BIGNUM *, const BIGNUM *,\n     BN_CTX *, BN_MONT_CTX *);\nint DSA_meth_set_bn_mod_exp(DSA_METHOD *dsam,\n    int (*bn_mod_exp) (DSA *, BIGNUM *, const BIGNUM *, const BIGNUM *,\n                       const BIGNUM *, BN_CTX *, BN_MONT_CTX *));\nint (*DSA_meth_get_init(const DSA_METHOD *dsam))(DSA *);\nint DSA_meth_set_init(DSA_METHOD *dsam, int (*init)(DSA *));\nint (*DSA_meth_get_finish(const DSA_METHOD *dsam)) (DSA *);\nint DSA_meth_set_finish(DSA_METHOD *dsam, int (*finish) (DSA *));\nint (*DSA_meth_get_paramgen(const DSA_METHOD *dsam))\n        (DSA *, int, const unsigned char *, int, int *, unsigned long *,\n         BN_GENCB *);\nint DSA_meth_set_paramgen(DSA_METHOD *dsam,\n        int (*paramgen) (DSA *, int, const unsigned char *, int, int *,\n                         unsigned long *, BN_GENCB *));\nint (*DSA_meth_get_keygen(const DSA_METHOD *dsam)) (DSA *);\nint DSA_meth_set_keygen(DSA_METHOD *dsam, int (*keygen) (DSA *));\n\n\n#  ifdef  __cplusplus\n}\n#  endif\n# endif\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/include/openssl/dsaerr.h",
    "content": "/*\n * Generated by util/mkerr.pl DO NOT EDIT\n * Copyright 1995-2019 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef HEADER_DSAERR_H\n# define HEADER_DSAERR_H\n\n# ifndef HEADER_SYMHACKS_H\n#  include <openssl/symhacks.h>\n# endif\n\n# include <openssl/opensslconf.h>\n\n# ifndef OPENSSL_NO_DSA\n\n#  ifdef  __cplusplus\nextern \"C\"\n#  endif\nint ERR_load_DSA_strings(void);\n\n/*\n * DSA function codes.\n */\n#  define DSA_F_DSAPARAMS_PRINT                            100\n#  define DSA_F_DSAPARAMS_PRINT_FP                         101\n#  define DSA_F_DSA_BUILTIN_PARAMGEN                       125\n#  define DSA_F_DSA_BUILTIN_PARAMGEN2                      126\n#  define DSA_F_DSA_DO_SIGN                                112\n#  define DSA_F_DSA_DO_VERIFY                              113\n#  define DSA_F_DSA_METH_DUP                               127\n#  define DSA_F_DSA_METH_NEW                               128\n#  define DSA_F_DSA_METH_SET1_NAME                         129\n#  define DSA_F_DSA_NEW_METHOD                             103\n#  define DSA_F_DSA_PARAM_DECODE                           119\n#  define DSA_F_DSA_PRINT_FP                               105\n#  define DSA_F_DSA_PRIV_DECODE                            115\n#  define DSA_F_DSA_PRIV_ENCODE                            116\n#  define DSA_F_DSA_PUB_DECODE                             117\n#  define DSA_F_DSA_PUB_ENCODE                             118\n#  define DSA_F_DSA_SIGN                                   106\n#  define DSA_F_DSA_SIGN_SETUP                             107\n#  define DSA_F_DSA_SIG_NEW                                102\n#  define DSA_F_OLD_DSA_PRIV_DECODE                        122\n#  define DSA_F_PKEY_DSA_CTRL                              120\n#  define DSA_F_PKEY_DSA_CTRL_STR                          104\n#  define DSA_F_PKEY_DSA_KEYGEN                            121\n\n/*\n * DSA reason codes.\n */\n#  define DSA_R_BAD_Q_VALUE                                102\n#  define DSA_R_BN_DECODE_ERROR                            108\n#  define DSA_R_BN_ERROR                                   109\n#  define DSA_R_DECODE_ERROR                               104\n#  define DSA_R_INVALID_DIGEST_TYPE                        106\n#  define DSA_R_INVALID_PARAMETERS                         112\n#  define DSA_R_MISSING_PARAMETERS                         101\n#  define DSA_R_MISSING_PRIVATE_KEY                        111\n#  define DSA_R_MODULUS_TOO_LARGE                          103\n#  define DSA_R_NO_PARAMETERS_SET                          107\n#  define DSA_R_PARAMETER_ENCODING_ERROR                   105\n#  define DSA_R_Q_NOT_PRIME                                113\n#  define DSA_R_SEED_LEN_SMALL                             110\n\n# endif\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/include/openssl/dtls1.h",
    "content": "/*\n * Copyright 2005-2018 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef HEADER_DTLS1_H\n# define HEADER_DTLS1_H\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n# define DTLS1_VERSION                   0xFEFF\n# define DTLS1_2_VERSION                 0xFEFD\n# define DTLS_MIN_VERSION                DTLS1_VERSION\n# define DTLS_MAX_VERSION                DTLS1_2_VERSION\n# define DTLS1_VERSION_MAJOR             0xFE\n\n# define DTLS1_BAD_VER                   0x0100\n\n/* Special value for method supporting multiple versions */\n# define DTLS_ANY_VERSION                0x1FFFF\n\n/* lengths of messages */\n/*\n * Actually the max cookie length in DTLS is 255. But we can't change this now\n * due to compatibility concerns.\n */\n# define DTLS1_COOKIE_LENGTH                     256\n\n# define DTLS1_RT_HEADER_LENGTH                  13\n\n# define DTLS1_HM_HEADER_LENGTH                  12\n\n# define DTLS1_HM_BAD_FRAGMENT                   -2\n# define DTLS1_HM_FRAGMENT_RETRY                 -3\n\n# define DTLS1_CCS_HEADER_LENGTH                  1\n\n# define DTLS1_AL_HEADER_LENGTH                   2\n\n/* Timeout multipliers */\n# define DTLS1_TMO_READ_COUNT                      2\n# define DTLS1_TMO_WRITE_COUNT                     2\n\n# define DTLS1_TMO_ALERT_COUNT                     12\n\n#ifdef  __cplusplus\n}\n#endif\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/include/openssl/e_os2.h",
    "content": "/*\n * Copyright 1995-2021 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef HEADER_E_OS2_H\n# define HEADER_E_OS2_H\n\n# include <openssl/opensslconf.h>\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n/******************************************************************************\n * Detect operating systems.  This probably needs completing.\n * The result is that at least one OPENSSL_SYS_os macro should be defined.\n * However, if none is defined, Unix is assumed.\n **/\n\n# define OPENSSL_SYS_UNIX\n\n/* --------------------- Microsoft operating systems ---------------------- */\n\n/*\n * Note that MSDOS actually denotes 32-bit environments running on top of\n * MS-DOS, such as DJGPP one.\n */\n# if defined(OPENSSL_SYS_MSDOS)\n#  undef OPENSSL_SYS_UNIX\n# endif\n\n/*\n * For 32 bit environment, there seems to be the CygWin environment and then\n * all the others that try to do the same thing Microsoft does...\n */\n/*\n * UEFI lives here because it might be built with a Microsoft toolchain and\n * we need to avoid the false positive match on Windows.\n */\n# if defined(OPENSSL_SYS_UEFI)\n#  undef OPENSSL_SYS_UNIX\n# elif defined(OPENSSL_SYS_UWIN)\n#  undef OPENSSL_SYS_UNIX\n#  define OPENSSL_SYS_WIN32_UWIN\n# else\n#  if defined(__CYGWIN__) || defined(OPENSSL_SYS_CYGWIN)\n#   define OPENSSL_SYS_WIN32_CYGWIN\n#  else\n#   if defined(_WIN32) || defined(OPENSSL_SYS_WIN32)\n#    undef OPENSSL_SYS_UNIX\n#    if !defined(OPENSSL_SYS_WIN32)\n#     define OPENSSL_SYS_WIN32\n#    endif\n#   endif\n#   if defined(_WIN64) || defined(OPENSSL_SYS_WIN64)\n#    undef OPENSSL_SYS_UNIX\n#    if !defined(OPENSSL_SYS_WIN64)\n#     define OPENSSL_SYS_WIN64\n#    endif\n#   endif\n#   if defined(OPENSSL_SYS_WINNT)\n#    undef OPENSSL_SYS_UNIX\n#   endif\n#   if defined(OPENSSL_SYS_WINCE)\n#    undef OPENSSL_SYS_UNIX\n#   endif\n#  endif\n# endif\n\n/* Anything that tries to look like Microsoft is \"Windows\" */\n# if defined(OPENSSL_SYS_WIN32) || defined(OPENSSL_SYS_WIN64) || defined(OPENSSL_SYS_WINNT) || defined(OPENSSL_SYS_WINCE)\n#  undef OPENSSL_SYS_UNIX\n#  define OPENSSL_SYS_WINDOWS\n#  ifndef OPENSSL_SYS_MSDOS\n#   define OPENSSL_SYS_MSDOS\n#  endif\n# endif\n\n/*\n * DLL settings.  This part is a bit tough, because it's up to the\n * application implementor how he or she will link the application, so it\n * requires some macro to be used.\n */\n# ifdef OPENSSL_SYS_WINDOWS\n#  ifndef OPENSSL_OPT_WINDLL\n#   if defined(_WINDLL)         /* This is used when building OpenSSL to\n                                 * indicate that DLL linkage should be used */\n#    define OPENSSL_OPT_WINDLL\n#   endif\n#  endif\n# endif\n\n/* ------------------------------- OpenVMS -------------------------------- */\n# if defined(__VMS) || defined(VMS) || defined(OPENSSL_SYS_VMS)\n#  if !defined(OPENSSL_SYS_VMS)\n#   undef OPENSSL_SYS_UNIX\n#  endif\n#  define OPENSSL_SYS_VMS\n#  if defined(__DECC)\n#   define OPENSSL_SYS_VMS_DECC\n#  elif defined(__DECCXX)\n#   define OPENSSL_SYS_VMS_DECC\n#   define OPENSSL_SYS_VMS_DECCXX\n#  else\n#   define OPENSSL_SYS_VMS_NODECC\n#  endif\n# endif\n\n/* -------------------------------- Unix ---------------------------------- */\n# ifdef OPENSSL_SYS_UNIX\n#  if defined(linux) || defined(__linux__) && !defined(OPENSSL_SYS_LINUX)\n#   define OPENSSL_SYS_LINUX\n#  endif\n#  if defined(_AIX) && !defined(OPENSSL_SYS_AIX)\n#   define OPENSSL_SYS_AIX\n#  endif\n# endif\n\n/* -------------------------------- VOS ----------------------------------- */\n# if defined(__VOS__) && !defined(OPENSSL_SYS_VOS)\n#  define OPENSSL_SYS_VOS\n#  ifdef __HPPA__\n#   define OPENSSL_SYS_VOS_HPPA\n#  endif\n#  ifdef __IA32__\n#   define OPENSSL_SYS_VOS_IA32\n#  endif\n# endif\n\n/**\n * That's it for OS-specific stuff\n *****************************************************************************/\n\n/* Specials for I/O an exit */\n# ifdef OPENSSL_SYS_MSDOS\n#  define OPENSSL_UNISTD_IO <io.h>\n#  define OPENSSL_DECLARE_EXIT extern void exit(int);\n# else\n#  define OPENSSL_UNISTD_IO OPENSSL_UNISTD\n#  define OPENSSL_DECLARE_EXIT  /* declared in unistd.h */\n# endif\n\n/*-\n * OPENSSL_EXTERN is normally used to declare a symbol with possible extra\n * attributes to handle its presence in a shared library.\n * OPENSSL_EXPORT is used to define a symbol with extra possible attributes\n * to make it visible in a shared library.\n * Care needs to be taken when a header file is used both to declare and\n * define symbols.  Basically, for any library that exports some global\n * variables, the following code must be present in the header file that\n * declares them, before OPENSSL_EXTERN is used:\n *\n * #ifdef SOME_BUILD_FLAG_MACRO\n * # undef OPENSSL_EXTERN\n * # define OPENSSL_EXTERN OPENSSL_EXPORT\n * #endif\n *\n * The default is to have OPENSSL_EXPORT and OPENSSL_EXTERN\n * have some generally sensible values.\n */\n\n# if defined(OPENSSL_SYS_WINDOWS) && defined(OPENSSL_OPT_WINDLL)\n#  define OPENSSL_EXPORT extern __declspec(dllexport)\n#  define OPENSSL_EXTERN extern __declspec(dllimport)\n# else\n#  define OPENSSL_EXPORT extern\n#  define OPENSSL_EXTERN extern\n# endif\n\n/*-\n * Macros to allow global variables to be reached through function calls when\n * required (if a shared library version requires it, for example.\n * The way it's done allows definitions like this:\n *\n *      // in foobar.c\n *      OPENSSL_IMPLEMENT_GLOBAL(int,foobar,0)\n *      // in foobar.h\n *      OPENSSL_DECLARE_GLOBAL(int,foobar);\n *      #define foobar OPENSSL_GLOBAL_REF(foobar)\n */\n# ifdef OPENSSL_EXPORT_VAR_AS_FUNCTION\n#  define OPENSSL_IMPLEMENT_GLOBAL(type,name,value)                      \\\n        type *_shadow_##name(void)                                      \\\n        { static type _hide_##name=value; return &_hide_##name; }\n#  define OPENSSL_DECLARE_GLOBAL(type,name) type *_shadow_##name(void)\n#  define OPENSSL_GLOBAL_REF(name) (*(_shadow_##name()))\n# else\n#  define OPENSSL_IMPLEMENT_GLOBAL(type,name,value) type _shadow_##name=value;\n#  define OPENSSL_DECLARE_GLOBAL(type,name) OPENSSL_EXPORT type _shadow_##name\n#  define OPENSSL_GLOBAL_REF(name) _shadow_##name\n# endif\n\n# ifdef _WIN32\n#  ifdef _WIN64\n#   define ossl_ssize_t __int64\n#   define OSSL_SSIZE_MAX _I64_MAX\n#  else\n#   define ossl_ssize_t int\n#   define OSSL_SSIZE_MAX INT_MAX\n#  endif\n# endif\n\n# if defined(OPENSSL_SYS_UEFI) && !defined(ossl_ssize_t)\n#  define ossl_ssize_t INTN\n#  define OSSL_SSIZE_MAX MAX_INTN\n# endif\n\n# ifndef ossl_ssize_t\n#  define ossl_ssize_t ssize_t\n#  if defined(SSIZE_MAX)\n#   define OSSL_SSIZE_MAX SSIZE_MAX\n#  elif defined(_POSIX_SSIZE_MAX)\n#   define OSSL_SSIZE_MAX _POSIX_SSIZE_MAX\n#  else\n#   define OSSL_SSIZE_MAX ((ssize_t)(SIZE_MAX>>1))\n#  endif\n# endif\n\n# ifdef DEBUG_UNUSED\n#  define __owur __attribute__((__warn_unused_result__))\n# else\n#  define __owur\n# endif\n\n/* Standard integer types */\n# if defined(OPENSSL_SYS_UEFI)\ntypedef INT8 int8_t;\ntypedef UINT8 uint8_t;\ntypedef INT16 int16_t;\ntypedef UINT16 uint16_t;\ntypedef INT32 int32_t;\ntypedef UINT32 uint32_t;\ntypedef INT64 int64_t;\ntypedef UINT64 uint64_t;\n# elif (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || \\\n     defined(__osf__) || defined(__sgi) || defined(__hpux) || \\\n     defined(OPENSSL_SYS_VMS) || defined (__OpenBSD__)\n#  include <inttypes.h>\n# elif defined(_MSC_VER) && _MSC_VER<1600\n/*\n * minimally required typdefs for systems not supporting inttypes.h or\n * stdint.h: currently just older VC++\n */\ntypedef signed char int8_t;\ntypedef unsigned char uint8_t;\ntypedef short int16_t;\ntypedef unsigned short uint16_t;\ntypedef int int32_t;\ntypedef unsigned int uint32_t;\ntypedef __int64 int64_t;\ntypedef unsigned __int64 uint64_t;\n# else\n#  include <stdint.h>\n# endif\n\n/* ossl_inline: portable inline definition usable in public headers */\n# if !defined(inline) && !defined(__cplusplus)\n#  if defined(__STDC_VERSION__) && __STDC_VERSION__>=199901L\n   /* just use inline */\n#   define ossl_inline inline\n#  elif defined(__GNUC__) && __GNUC__>=2\n#   define ossl_inline __inline__\n#  elif defined(_MSC_VER)\n  /*\n   * Visual Studio: inline is available in C++ only, however\n   * __inline is available for C, see\n   * http://msdn.microsoft.com/en-us/library/z8y1yy88.aspx\n   */\n#   define ossl_inline __inline\n#  else\n#   define ossl_inline\n#  endif\n# else\n#  define ossl_inline inline\n# endif\n\n# if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L && \\\n     !defined(__cplusplus) \n#  define ossl_noreturn _Noreturn\n# elif defined(__GNUC__) && __GNUC__ >= 2\n#  define ossl_noreturn __attribute__((noreturn))\n# else\n#  define ossl_noreturn\n# endif\n\n/* ossl_unused: portable unused attribute for use in public headers */\n# if defined(__GNUC__)\n#  define ossl_unused __attribute__((unused))\n# else\n#  define ossl_unused\n# endif\n\n#ifdef  __cplusplus\n}\n#endif\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/include/openssl/ebcdic.h",
    "content": "/*\n * Copyright 1999-2016 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef HEADER_EBCDIC_H\n# define HEADER_EBCDIC_H\n\n# include <stdlib.h>\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n/* Avoid name clashes with other applications */\n# define os_toascii   _openssl_os_toascii\n# define os_toebcdic  _openssl_os_toebcdic\n# define ebcdic2ascii _openssl_ebcdic2ascii\n# define ascii2ebcdic _openssl_ascii2ebcdic\n\nextern const unsigned char os_toascii[256];\nextern const unsigned char os_toebcdic[256];\nvoid *ebcdic2ascii(void *dest, const void *srce, size_t count);\nvoid *ascii2ebcdic(void *dest, const void *srce, size_t count);\n\n#ifdef  __cplusplus\n}\n#endif\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/include/openssl/ec.h",
    "content": "/*\n * Copyright 2002-2020 The OpenSSL Project Authors. All Rights Reserved.\n * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef HEADER_EC_H\n# define HEADER_EC_H\n\n# include <openssl/opensslconf.h>\n\n# ifndef OPENSSL_NO_EC\n# include <openssl/asn1.h>\n# include <openssl/symhacks.h>\n# if OPENSSL_API_COMPAT < 0x10100000L\n#  include <openssl/bn.h>\n# endif\n# include <openssl/ecerr.h>\n# ifdef  __cplusplus\nextern \"C\" {\n# endif\n\n# ifndef OPENSSL_ECC_MAX_FIELD_BITS\n#  define OPENSSL_ECC_MAX_FIELD_BITS 661\n# endif\n\n/** Enum for the point conversion form as defined in X9.62 (ECDSA)\n *  for the encoding of a elliptic curve point (x,y) */\ntypedef enum {\n        /** the point is encoded as z||x, where the octet z specifies\n         *  which solution of the quadratic equation y is  */\n    POINT_CONVERSION_COMPRESSED = 2,\n        /** the point is encoded as z||x||y, where z is the octet 0x04  */\n    POINT_CONVERSION_UNCOMPRESSED = 4,\n        /** the point is encoded as z||x||y, where the octet z specifies\n         *  which solution of the quadratic equation y is  */\n    POINT_CONVERSION_HYBRID = 6\n} point_conversion_form_t;\n\ntypedef struct ec_method_st EC_METHOD;\ntypedef struct ec_group_st EC_GROUP;\ntypedef struct ec_point_st EC_POINT;\ntypedef struct ecpk_parameters_st ECPKPARAMETERS;\ntypedef struct ec_parameters_st ECPARAMETERS;\n\n/********************************************************************/\n/*               EC_METHODs for curves over GF(p)                   */\n/********************************************************************/\n\n/** Returns the basic GFp ec methods which provides the basis for the\n *  optimized methods.\n *  \\return  EC_METHOD object\n */\nconst EC_METHOD *EC_GFp_simple_method(void);\n\n/** Returns GFp methods using montgomery multiplication.\n *  \\return  EC_METHOD object\n */\nconst EC_METHOD *EC_GFp_mont_method(void);\n\n/** Returns GFp methods using optimized methods for NIST recommended curves\n *  \\return  EC_METHOD object\n */\nconst EC_METHOD *EC_GFp_nist_method(void);\n\n# ifndef OPENSSL_NO_EC_NISTP_64_GCC_128\n/** Returns 64-bit optimized methods for nistp224\n *  \\return  EC_METHOD object\n */\nconst EC_METHOD *EC_GFp_nistp224_method(void);\n\n/** Returns 64-bit optimized methods for nistp256\n *  \\return  EC_METHOD object\n */\nconst EC_METHOD *EC_GFp_nistp256_method(void);\n\n/** Returns 64-bit optimized methods for nistp521\n *  \\return  EC_METHOD object\n */\nconst EC_METHOD *EC_GFp_nistp521_method(void);\n# endif\n\n# ifndef OPENSSL_NO_EC2M\n/********************************************************************/\n/*           EC_METHOD for curves over GF(2^m)                      */\n/********************************************************************/\n\n/** Returns the basic GF2m ec method\n *  \\return  EC_METHOD object\n */\nconst EC_METHOD *EC_GF2m_simple_method(void);\n\n# endif\n\n/********************************************************************/\n/*                   EC_GROUP functions                             */\n/********************************************************************/\n\n/** Creates a new EC_GROUP object\n *  \\param   meth  EC_METHOD to use\n *  \\return  newly created EC_GROUP object or NULL in case of an error.\n */\nEC_GROUP *EC_GROUP_new(const EC_METHOD *meth);\n\n/** Frees a EC_GROUP object\n *  \\param  group  EC_GROUP object to be freed.\n */\nvoid EC_GROUP_free(EC_GROUP *group);\n\n/** Clears and frees a EC_GROUP object\n *  \\param  group  EC_GROUP object to be cleared and freed.\n */\nvoid EC_GROUP_clear_free(EC_GROUP *group);\n\n/** Copies EC_GROUP objects. Note: both EC_GROUPs must use the same EC_METHOD.\n *  \\param  dst  destination EC_GROUP object\n *  \\param  src  source EC_GROUP object\n *  \\return 1 on success and 0 if an error occurred.\n */\nint EC_GROUP_copy(EC_GROUP *dst, const EC_GROUP *src);\n\n/** Creates a new EC_GROUP object and copies the copies the content\n *  form src to the newly created EC_KEY object\n *  \\param  src  source EC_GROUP object\n *  \\return newly created EC_GROUP object or NULL in case of an error.\n */\nEC_GROUP *EC_GROUP_dup(const EC_GROUP *src);\n\n/** Returns the EC_METHOD of the EC_GROUP object.\n *  \\param  group  EC_GROUP object\n *  \\return EC_METHOD used in this EC_GROUP object.\n */\nconst EC_METHOD *EC_GROUP_method_of(const EC_GROUP *group);\n\n/** Returns the field type of the EC_METHOD.\n *  \\param  meth  EC_METHOD object\n *  \\return NID of the underlying field type OID.\n */\nint EC_METHOD_get_field_type(const EC_METHOD *meth);\n\n/** Sets the generator and its order/cofactor of a EC_GROUP object.\n *  \\param  group      EC_GROUP object\n *  \\param  generator  EC_POINT object with the generator.\n *  \\param  order      the order of the group generated by the generator.\n *  \\param  cofactor   the index of the sub-group generated by the generator\n *                     in the group of all points on the elliptic curve.\n *  \\return 1 on success and 0 if an error occurred\n */\nint EC_GROUP_set_generator(EC_GROUP *group, const EC_POINT *generator,\n                           const BIGNUM *order, const BIGNUM *cofactor);\n\n/** Returns the generator of a EC_GROUP object.\n *  \\param  group  EC_GROUP object\n *  \\return the currently used generator (possibly NULL).\n */\nconst EC_POINT *EC_GROUP_get0_generator(const EC_GROUP *group);\n\n/** Returns the montgomery data for order(Generator)\n *  \\param  group  EC_GROUP object\n *  \\return the currently used montgomery data (possibly NULL).\n*/\nBN_MONT_CTX *EC_GROUP_get_mont_data(const EC_GROUP *group);\n\n/** Gets the order of a EC_GROUP\n *  \\param  group  EC_GROUP object\n *  \\param  order  BIGNUM to which the order is copied\n *  \\param  ctx    unused\n *  \\return 1 on success and 0 if an error occurred\n */\nint EC_GROUP_get_order(const EC_GROUP *group, BIGNUM *order, BN_CTX *ctx);\n\n/** Gets the order of an EC_GROUP\n *  \\param  group  EC_GROUP object\n *  \\return the group order\n */\nconst BIGNUM *EC_GROUP_get0_order(const EC_GROUP *group);\n\n/** Gets the number of bits of the order of an EC_GROUP\n *  \\param  group  EC_GROUP object\n *  \\return number of bits of group order.\n */\nint EC_GROUP_order_bits(const EC_GROUP *group);\n\n/** Gets the cofactor of a EC_GROUP\n *  \\param  group     EC_GROUP object\n *  \\param  cofactor  BIGNUM to which the cofactor is copied\n *  \\param  ctx       unused\n *  \\return 1 on success and 0 if an error occurred\n */\nint EC_GROUP_get_cofactor(const EC_GROUP *group, BIGNUM *cofactor,\n                          BN_CTX *ctx);\n\n/** Gets the cofactor of an EC_GROUP\n *  \\param  group  EC_GROUP object\n *  \\return the group cofactor\n */\nconst BIGNUM *EC_GROUP_get0_cofactor(const EC_GROUP *group);\n\n/** Sets the name of a EC_GROUP object\n *  \\param  group  EC_GROUP object\n *  \\param  nid    NID of the curve name OID\n */\nvoid EC_GROUP_set_curve_name(EC_GROUP *group, int nid);\n\n/** Returns the curve name of a EC_GROUP object\n *  \\param  group  EC_GROUP object\n *  \\return NID of the curve name OID or 0 if not set.\n */\nint EC_GROUP_get_curve_name(const EC_GROUP *group);\n\nvoid EC_GROUP_set_asn1_flag(EC_GROUP *group, int flag);\nint EC_GROUP_get_asn1_flag(const EC_GROUP *group);\n\nvoid EC_GROUP_set_point_conversion_form(EC_GROUP *group,\n                                        point_conversion_form_t form);\npoint_conversion_form_t EC_GROUP_get_point_conversion_form(const EC_GROUP *);\n\nunsigned char *EC_GROUP_get0_seed(const EC_GROUP *x);\nsize_t EC_GROUP_get_seed_len(const EC_GROUP *);\nsize_t EC_GROUP_set_seed(EC_GROUP *, const unsigned char *, size_t len);\n\n/** Sets the parameters of a ec curve defined by y^2 = x^3 + a*x + b (for GFp)\n *  or y^2 + x*y = x^3 + a*x^2 + b (for GF2m)\n *  \\param  group  EC_GROUP object\n *  \\param  p      BIGNUM with the prime number (GFp) or the polynomial\n *                 defining the underlying field (GF2m)\n *  \\param  a      BIGNUM with parameter a of the equation\n *  \\param  b      BIGNUM with parameter b of the equation\n *  \\param  ctx    BN_CTX object (optional)\n *  \\return 1 on success and 0 if an error occurred\n */\nint EC_GROUP_set_curve(EC_GROUP *group, const BIGNUM *p, const BIGNUM *a,\n                       const BIGNUM *b, BN_CTX *ctx);\n\n/** Gets the parameters of the ec curve defined by y^2 = x^3 + a*x + b (for GFp)\n *  or y^2 + x*y = x^3 + a*x^2 + b (for GF2m)\n *  \\param  group  EC_GROUP object\n *  \\param  p      BIGNUM with the prime number (GFp) or the polynomial\n *                 defining the underlying field (GF2m)\n *  \\param  a      BIGNUM for parameter a of the equation\n *  \\param  b      BIGNUM for parameter b of the equation\n *  \\param  ctx    BN_CTX object (optional)\n *  \\return 1 on success and 0 if an error occurred\n */\nint EC_GROUP_get_curve(const EC_GROUP *group, BIGNUM *p, BIGNUM *a, BIGNUM *b,\n                       BN_CTX *ctx);\n\n/** Sets the parameters of an ec curve. Synonym for EC_GROUP_set_curve\n *  \\param  group  EC_GROUP object\n *  \\param  p      BIGNUM with the prime number (GFp) or the polynomial\n *                 defining the underlying field (GF2m)\n *  \\param  a      BIGNUM with parameter a of the equation\n *  \\param  b      BIGNUM with parameter b of the equation\n *  \\param  ctx    BN_CTX object (optional)\n *  \\return 1 on success and 0 if an error occurred\n */\nDEPRECATEDIN_1_2_0(int EC_GROUP_set_curve_GFp(EC_GROUP *group, const BIGNUM *p,\n                                              const BIGNUM *a, const BIGNUM *b,\n                                              BN_CTX *ctx))\n\n/** Gets the parameters of an ec curve. Synonym for EC_GROUP_get_curve\n *  \\param  group  EC_GROUP object\n *  \\param  p      BIGNUM with the prime number (GFp) or the polynomial\n *                 defining the underlying field (GF2m)\n *  \\param  a      BIGNUM for parameter a of the equation\n *  \\param  b      BIGNUM for parameter b of the equation\n *  \\param  ctx    BN_CTX object (optional)\n *  \\return 1 on success and 0 if an error occurred\n */\nDEPRECATEDIN_1_2_0(int EC_GROUP_get_curve_GFp(const EC_GROUP *group, BIGNUM *p,\n                                              BIGNUM *a, BIGNUM *b,\n                                              BN_CTX *ctx))\n\n# ifndef OPENSSL_NO_EC2M\n/** Sets the parameter of an ec curve. Synonym for EC_GROUP_set_curve\n *  \\param  group  EC_GROUP object\n *  \\param  p      BIGNUM with the prime number (GFp) or the polynomial\n *                 defining the underlying field (GF2m)\n *  \\param  a      BIGNUM with parameter a of the equation\n *  \\param  b      BIGNUM with parameter b of the equation\n *  \\param  ctx    BN_CTX object (optional)\n *  \\return 1 on success and 0 if an error occurred\n */\nDEPRECATEDIN_1_2_0(int EC_GROUP_set_curve_GF2m(EC_GROUP *group, const BIGNUM *p,\n                                               const BIGNUM *a, const BIGNUM *b,\n                                               BN_CTX *ctx))\n\n/** Gets the parameters of an ec curve. Synonym for EC_GROUP_get_curve\n *  \\param  group  EC_GROUP object\n *  \\param  p      BIGNUM with the prime number (GFp) or the polynomial\n *                 defining the underlying field (GF2m)\n *  \\param  a      BIGNUM for parameter a of the equation\n *  \\param  b      BIGNUM for parameter b of the equation\n *  \\param  ctx    BN_CTX object (optional)\n *  \\return 1 on success and 0 if an error occurred\n */\nDEPRECATEDIN_1_2_0(int EC_GROUP_get_curve_GF2m(const EC_GROUP *group, BIGNUM *p,\n                                               BIGNUM *a, BIGNUM *b,\n                                               BN_CTX *ctx))\n# endif\n/** Returns the number of bits needed to represent a field element\n *  \\param  group  EC_GROUP object\n *  \\return number of bits needed to represent a field element\n */\nint EC_GROUP_get_degree(const EC_GROUP *group);\n\n/** Checks whether the parameter in the EC_GROUP define a valid ec group\n *  \\param  group  EC_GROUP object\n *  \\param  ctx    BN_CTX object (optional)\n *  \\return 1 if group is a valid ec group and 0 otherwise\n */\nint EC_GROUP_check(const EC_GROUP *group, BN_CTX *ctx);\n\n/** Checks whether the discriminant of the elliptic curve is zero or not\n *  \\param  group  EC_GROUP object\n *  \\param  ctx    BN_CTX object (optional)\n *  \\return 1 if the discriminant is not zero and 0 otherwise\n */\nint EC_GROUP_check_discriminant(const EC_GROUP *group, BN_CTX *ctx);\n\n/** Compares two EC_GROUP objects\n *  \\param  a    first EC_GROUP object\n *  \\param  b    second EC_GROUP object\n *  \\param  ctx  BN_CTX object (optional)\n *  \\return 0 if the groups are equal, 1 if not, or -1 on error\n */\nint EC_GROUP_cmp(const EC_GROUP *a, const EC_GROUP *b, BN_CTX *ctx);\n\n/*\n * EC_GROUP_new_GF*() calls EC_GROUP_new() and EC_GROUP_set_GF*() after\n * choosing an appropriate EC_METHOD\n */\n\n/** Creates a new EC_GROUP object with the specified parameters defined\n *  over GFp (defined by the equation y^2 = x^3 + a*x + b)\n *  \\param  p    BIGNUM with the prime number\n *  \\param  a    BIGNUM with the parameter a of the equation\n *  \\param  b    BIGNUM with the parameter b of the equation\n *  \\param  ctx  BN_CTX object (optional)\n *  \\return newly created EC_GROUP object with the specified parameters\n */\nEC_GROUP *EC_GROUP_new_curve_GFp(const BIGNUM *p, const BIGNUM *a,\n                                 const BIGNUM *b, BN_CTX *ctx);\n# ifndef OPENSSL_NO_EC2M\n/** Creates a new EC_GROUP object with the specified parameters defined\n *  over GF2m (defined by the equation y^2 + x*y = x^3 + a*x^2 + b)\n *  \\param  p    BIGNUM with the polynomial defining the underlying field\n *  \\param  a    BIGNUM with the parameter a of the equation\n *  \\param  b    BIGNUM with the parameter b of the equation\n *  \\param  ctx  BN_CTX object (optional)\n *  \\return newly created EC_GROUP object with the specified parameters\n */\nEC_GROUP *EC_GROUP_new_curve_GF2m(const BIGNUM *p, const BIGNUM *a,\n                                  const BIGNUM *b, BN_CTX *ctx);\n# endif\n\n/** Creates a EC_GROUP object with a curve specified by a NID\n *  \\param  nid  NID of the OID of the curve name\n *  \\return newly created EC_GROUP object with specified curve or NULL\n *          if an error occurred\n */\nEC_GROUP *EC_GROUP_new_by_curve_name(int nid);\n\n/** Creates a new EC_GROUP object from an ECPARAMETERS object\n *  \\param  params  pointer to the ECPARAMETERS object\n *  \\return newly created EC_GROUP object with specified curve or NULL\n *          if an error occurred\n */\nEC_GROUP *EC_GROUP_new_from_ecparameters(const ECPARAMETERS *params);\n\n/** Creates an ECPARAMETERS object for the given EC_GROUP object.\n *  \\param  group   pointer to the EC_GROUP object\n *  \\param  params  pointer to an existing ECPARAMETERS object or NULL\n *  \\return pointer to the new ECPARAMETERS object or NULL\n *          if an error occurred.\n */\nECPARAMETERS *EC_GROUP_get_ecparameters(const EC_GROUP *group,\n                                        ECPARAMETERS *params);\n\n/** Creates a new EC_GROUP object from an ECPKPARAMETERS object\n *  \\param  params  pointer to an existing ECPKPARAMETERS object, or NULL\n *  \\return newly created EC_GROUP object with specified curve, or NULL\n *          if an error occurred\n */\nEC_GROUP *EC_GROUP_new_from_ecpkparameters(const ECPKPARAMETERS *params);\n\n/** Creates an ECPKPARAMETERS object for the given EC_GROUP object.\n *  \\param  group   pointer to the EC_GROUP object\n *  \\param  params  pointer to an existing ECPKPARAMETERS object or NULL\n *  \\return pointer to the new ECPKPARAMETERS object or NULL\n *          if an error occurred.\n */\nECPKPARAMETERS *EC_GROUP_get_ecpkparameters(const EC_GROUP *group,\n                                            ECPKPARAMETERS *params);\n\n/********************************************************************/\n/*               handling of internal curves                        */\n/********************************************************************/\n\ntypedef struct {\n    int nid;\n    const char *comment;\n} EC_builtin_curve;\n\n/*\n * EC_builtin_curves(EC_builtin_curve *r, size_t size) returns number of all\n * available curves or zero if a error occurred. In case r is not zero,\n * nitems EC_builtin_curve structures are filled with the data of the first\n * nitems internal groups\n */\nsize_t EC_get_builtin_curves(EC_builtin_curve *r, size_t nitems);\n\nconst char *EC_curve_nid2nist(int nid);\nint EC_curve_nist2nid(const char *name);\n\n/********************************************************************/\n/*                    EC_POINT functions                            */\n/********************************************************************/\n\n/** Creates a new EC_POINT object for the specified EC_GROUP\n *  \\param  group  EC_GROUP the underlying EC_GROUP object\n *  \\return newly created EC_POINT object or NULL if an error occurred\n */\nEC_POINT *EC_POINT_new(const EC_GROUP *group);\n\n/** Frees a EC_POINT object\n *  \\param  point  EC_POINT object to be freed\n */\nvoid EC_POINT_free(EC_POINT *point);\n\n/** Clears and frees a EC_POINT object\n *  \\param  point  EC_POINT object to be cleared and freed\n */\nvoid EC_POINT_clear_free(EC_POINT *point);\n\n/** Copies EC_POINT object\n *  \\param  dst  destination EC_POINT object\n *  \\param  src  source EC_POINT object\n *  \\return 1 on success and 0 if an error occurred\n */\nint EC_POINT_copy(EC_POINT *dst, const EC_POINT *src);\n\n/** Creates a new EC_POINT object and copies the content of the supplied\n *  EC_POINT\n *  \\param  src    source EC_POINT object\n *  \\param  group  underlying the EC_GROUP object\n *  \\return newly created EC_POINT object or NULL if an error occurred\n */\nEC_POINT *EC_POINT_dup(const EC_POINT *src, const EC_GROUP *group);\n\n/** Returns the EC_METHOD used in EC_POINT object\n *  \\param  point  EC_POINT object\n *  \\return the EC_METHOD used\n */\nconst EC_METHOD *EC_POINT_method_of(const EC_POINT *point);\n\n/** Sets a point to infinity (neutral element)\n *  \\param  group  underlying EC_GROUP object\n *  \\param  point  EC_POINT to set to infinity\n *  \\return 1 on success and 0 if an error occurred\n */\nint EC_POINT_set_to_infinity(const EC_GROUP *group, EC_POINT *point);\n\n/** Sets the jacobian projective coordinates of a EC_POINT over GFp\n *  \\param  group  underlying EC_GROUP object\n *  \\param  p      EC_POINT object\n *  \\param  x      BIGNUM with the x-coordinate\n *  \\param  y      BIGNUM with the y-coordinate\n *  \\param  z      BIGNUM with the z-coordinate\n *  \\param  ctx    BN_CTX object (optional)\n *  \\return 1 on success and 0 if an error occurred\n */\nint EC_POINT_set_Jprojective_coordinates_GFp(const EC_GROUP *group,\n                                             EC_POINT *p, const BIGNUM *x,\n                                             const BIGNUM *y, const BIGNUM *z,\n                                             BN_CTX *ctx);\n\n/** Gets the jacobian projective coordinates of a EC_POINT over GFp\n *  \\param  group  underlying EC_GROUP object\n *  \\param  p      EC_POINT object\n *  \\param  x      BIGNUM for the x-coordinate\n *  \\param  y      BIGNUM for the y-coordinate\n *  \\param  z      BIGNUM for the z-coordinate\n *  \\param  ctx    BN_CTX object (optional)\n *  \\return 1 on success and 0 if an error occurred\n */\nint EC_POINT_get_Jprojective_coordinates_GFp(const EC_GROUP *group,\n                                             const EC_POINT *p, BIGNUM *x,\n                                             BIGNUM *y, BIGNUM *z,\n                                             BN_CTX *ctx);\n\n/** Sets the affine coordinates of an EC_POINT\n *  \\param  group  underlying EC_GROUP object\n *  \\param  p      EC_POINT object\n *  \\param  x      BIGNUM with the x-coordinate\n *  \\param  y      BIGNUM with the y-coordinate\n *  \\param  ctx    BN_CTX object (optional)\n *  \\return 1 on success and 0 if an error occurred\n */\nint EC_POINT_set_affine_coordinates(const EC_GROUP *group, EC_POINT *p,\n                                    const BIGNUM *x, const BIGNUM *y,\n                                    BN_CTX *ctx);\n\n/** Gets the affine coordinates of an EC_POINT.\n *  \\param  group  underlying EC_GROUP object\n *  \\param  p      EC_POINT object\n *  \\param  x      BIGNUM for the x-coordinate\n *  \\param  y      BIGNUM for the y-coordinate\n *  \\param  ctx    BN_CTX object (optional)\n *  \\return 1 on success and 0 if an error occurred\n */\nint EC_POINT_get_affine_coordinates(const EC_GROUP *group, const EC_POINT *p,\n                                    BIGNUM *x, BIGNUM *y, BN_CTX *ctx);\n\n/** Sets the affine coordinates of an EC_POINT. A synonym of\n *  EC_POINT_set_affine_coordinates\n *  \\param  group  underlying EC_GROUP object\n *  \\param  p      EC_POINT object\n *  \\param  x      BIGNUM with the x-coordinate\n *  \\param  y      BIGNUM with the y-coordinate\n *  \\param  ctx    BN_CTX object (optional)\n *  \\return 1 on success and 0 if an error occurred\n */\nDEPRECATEDIN_1_2_0(int EC_POINT_set_affine_coordinates_GFp(const EC_GROUP *group,\n                                                           EC_POINT *p,\n                                                           const BIGNUM *x,\n                                                           const BIGNUM *y,\n                                                           BN_CTX *ctx))\n\n/** Gets the affine coordinates of an EC_POINT. A synonym of\n *  EC_POINT_get_affine_coordinates\n *  \\param  group  underlying EC_GROUP object\n *  \\param  p      EC_POINT object\n *  \\param  x      BIGNUM for the x-coordinate\n *  \\param  y      BIGNUM for the y-coordinate\n *  \\param  ctx    BN_CTX object (optional)\n *  \\return 1 on success and 0 if an error occurred\n */\nDEPRECATEDIN_1_2_0(int EC_POINT_get_affine_coordinates_GFp(const EC_GROUP *group,\n                                                           const EC_POINT *p,\n                                                           BIGNUM *x,\n                                                           BIGNUM *y,\n                                                           BN_CTX *ctx))\n\n/** Sets the x9.62 compressed coordinates of a EC_POINT\n *  \\param  group  underlying EC_GROUP object\n *  \\param  p      EC_POINT object\n *  \\param  x      BIGNUM with x-coordinate\n *  \\param  y_bit  integer with the y-Bit (either 0 or 1)\n *  \\param  ctx    BN_CTX object (optional)\n *  \\return 1 on success and 0 if an error occurred\n */\nint EC_POINT_set_compressed_coordinates(const EC_GROUP *group, EC_POINT *p,\n                                        const BIGNUM *x, int y_bit,\n                                        BN_CTX *ctx);\n\n/** Sets the x9.62 compressed coordinates of a EC_POINT. A synonym of\n *  EC_POINT_set_compressed_coordinates\n *  \\param  group  underlying EC_GROUP object\n *  \\param  p      EC_POINT object\n *  \\param  x      BIGNUM with x-coordinate\n *  \\param  y_bit  integer with the y-Bit (either 0 or 1)\n *  \\param  ctx    BN_CTX object (optional)\n *  \\return 1 on success and 0 if an error occurred\n */\nDEPRECATEDIN_1_2_0(int EC_POINT_set_compressed_coordinates_GFp(const EC_GROUP *group,\n                                                               EC_POINT *p,\n                                                               const BIGNUM *x,\n                                                               int y_bit,\n                                                               BN_CTX *ctx))\n# ifndef OPENSSL_NO_EC2M\n/** Sets the affine coordinates of an EC_POINT. A synonym of\n *  EC_POINT_set_affine_coordinates\n *  \\param  group  underlying EC_GROUP object\n *  \\param  p      EC_POINT object\n *  \\param  x      BIGNUM with the x-coordinate\n *  \\param  y      BIGNUM with the y-coordinate\n *  \\param  ctx    BN_CTX object (optional)\n *  \\return 1 on success and 0 if an error occurred\n */\nDEPRECATEDIN_1_2_0(int EC_POINT_set_affine_coordinates_GF2m(const EC_GROUP *group,\n                                                            EC_POINT *p,\n                                                            const BIGNUM *x,\n                                                            const BIGNUM *y,\n                                                            BN_CTX *ctx))\n\n/** Gets the affine coordinates of an EC_POINT. A synonym of\n *  EC_POINT_get_affine_coordinates\n *  \\param  group  underlying EC_GROUP object\n *  \\param  p      EC_POINT object\n *  \\param  x      BIGNUM for the x-coordinate\n *  \\param  y      BIGNUM for the y-coordinate\n *  \\param  ctx    BN_CTX object (optional)\n *  \\return 1 on success and 0 if an error occurred\n */\nDEPRECATEDIN_1_2_0(int EC_POINT_get_affine_coordinates_GF2m(const EC_GROUP *group,\n                                                            const EC_POINT *p,\n                                                            BIGNUM *x,\n                                                            BIGNUM *y,\n                                                            BN_CTX *ctx))\n\n/** Sets the x9.62 compressed coordinates of a EC_POINT. A synonym of\n *  EC_POINT_set_compressed_coordinates\n *  \\param  group  underlying EC_GROUP object\n *  \\param  p      EC_POINT object\n *  \\param  x      BIGNUM with x-coordinate\n *  \\param  y_bit  integer with the y-Bit (either 0 or 1)\n *  \\param  ctx    BN_CTX object (optional)\n *  \\return 1 on success and 0 if an error occurred\n */\nDEPRECATEDIN_1_2_0(int EC_POINT_set_compressed_coordinates_GF2m(const EC_GROUP *group,\n                                                                EC_POINT *p,\n                                                                const BIGNUM *x,\n                                                                int y_bit,\n                                                                BN_CTX *ctx))\n# endif\n/** Encodes a EC_POINT object to a octet string\n *  \\param  group  underlying EC_GROUP object\n *  \\param  p      EC_POINT object\n *  \\param  form   point conversion form\n *  \\param  buf    memory buffer for the result. If NULL the function returns\n *                 required buffer size.\n *  \\param  len    length of the memory buffer\n *  \\param  ctx    BN_CTX object (optional)\n *  \\return the length of the encoded octet string or 0 if an error occurred\n */\nsize_t EC_POINT_point2oct(const EC_GROUP *group, const EC_POINT *p,\n                          point_conversion_form_t form,\n                          unsigned char *buf, size_t len, BN_CTX *ctx);\n\n/** Decodes a EC_POINT from a octet string\n *  \\param  group  underlying EC_GROUP object\n *  \\param  p      EC_POINT object\n *  \\param  buf    memory buffer with the encoded ec point\n *  \\param  len    length of the encoded ec point\n *  \\param  ctx    BN_CTX object (optional)\n *  \\return 1 on success and 0 if an error occurred\n */\nint EC_POINT_oct2point(const EC_GROUP *group, EC_POINT *p,\n                       const unsigned char *buf, size_t len, BN_CTX *ctx);\n\n/** Encodes an EC_POINT object to an allocated octet string\n *  \\param  group  underlying EC_GROUP object\n *  \\param  point  EC_POINT object\n *  \\param  form   point conversion form\n *  \\param  pbuf   returns pointer to allocated buffer\n *  \\param  ctx    BN_CTX object (optional)\n *  \\return the length of the encoded octet string or 0 if an error occurred\n */\nsize_t EC_POINT_point2buf(const EC_GROUP *group, const EC_POINT *point,\n                          point_conversion_form_t form,\n                          unsigned char **pbuf, BN_CTX *ctx);\n\n/* other interfaces to point2oct/oct2point: */\nBIGNUM *EC_POINT_point2bn(const EC_GROUP *, const EC_POINT *,\n                          point_conversion_form_t form, BIGNUM *, BN_CTX *);\nEC_POINT *EC_POINT_bn2point(const EC_GROUP *, const BIGNUM *,\n                            EC_POINT *, BN_CTX *);\nchar *EC_POINT_point2hex(const EC_GROUP *, const EC_POINT *,\n                         point_conversion_form_t form, BN_CTX *);\nEC_POINT *EC_POINT_hex2point(const EC_GROUP *, const char *,\n                             EC_POINT *, BN_CTX *);\n\n/********************************************************************/\n/*         functions for doing EC_POINT arithmetic                  */\n/********************************************************************/\n\n/** Computes the sum of two EC_POINT\n *  \\param  group  underlying EC_GROUP object\n *  \\param  r      EC_POINT object for the result (r = a + b)\n *  \\param  a      EC_POINT object with the first summand\n *  \\param  b      EC_POINT object with the second summand\n *  \\param  ctx    BN_CTX object (optional)\n *  \\return 1 on success and 0 if an error occurred\n */\nint EC_POINT_add(const EC_GROUP *group, EC_POINT *r, const EC_POINT *a,\n                 const EC_POINT *b, BN_CTX *ctx);\n\n/** Computes the double of a EC_POINT\n *  \\param  group  underlying EC_GROUP object\n *  \\param  r      EC_POINT object for the result (r = 2 * a)\n *  \\param  a      EC_POINT object\n *  \\param  ctx    BN_CTX object (optional)\n *  \\return 1 on success and 0 if an error occurred\n */\nint EC_POINT_dbl(const EC_GROUP *group, EC_POINT *r, const EC_POINT *a,\n                 BN_CTX *ctx);\n\n/** Computes the inverse of a EC_POINT\n *  \\param  group  underlying EC_GROUP object\n *  \\param  a      EC_POINT object to be inverted (it's used for the result as well)\n *  \\param  ctx    BN_CTX object (optional)\n *  \\return 1 on success and 0 if an error occurred\n */\nint EC_POINT_invert(const EC_GROUP *group, EC_POINT *a, BN_CTX *ctx);\n\n/** Checks whether the point is the neutral element of the group\n *  \\param  group  the underlying EC_GROUP object\n *  \\param  p      EC_POINT object\n *  \\return 1 if the point is the neutral element and 0 otherwise\n */\nint EC_POINT_is_at_infinity(const EC_GROUP *group, const EC_POINT *p);\n\n/** Checks whether the point is on the curve\n *  \\param  group  underlying EC_GROUP object\n *  \\param  point  EC_POINT object to check\n *  \\param  ctx    BN_CTX object (optional)\n *  \\return 1 if the point is on the curve, 0 if not, or -1 on error\n */\nint EC_POINT_is_on_curve(const EC_GROUP *group, const EC_POINT *point,\n                         BN_CTX *ctx);\n\n/** Compares two EC_POINTs\n *  \\param  group  underlying EC_GROUP object\n *  \\param  a      first EC_POINT object\n *  \\param  b      second EC_POINT object\n *  \\param  ctx    BN_CTX object (optional)\n *  \\return 1 if the points are not equal, 0 if they are, or -1 on error\n */\nint EC_POINT_cmp(const EC_GROUP *group, const EC_POINT *a, const EC_POINT *b,\n                 BN_CTX *ctx);\n\nint EC_POINT_make_affine(const EC_GROUP *group, EC_POINT *point, BN_CTX *ctx);\nint EC_POINTs_make_affine(const EC_GROUP *group, size_t num,\n                          EC_POINT *points[], BN_CTX *ctx);\n\n/** Computes r = generator * n + sum_{i=0}^{num-1} p[i] * m[i]\n *  \\param  group  underlying EC_GROUP object\n *  \\param  r      EC_POINT object for the result\n *  \\param  n      BIGNUM with the multiplier for the group generator (optional)\n *  \\param  num    number further summands\n *  \\param  p      array of size num of EC_POINT objects\n *  \\param  m      array of size num of BIGNUM objects\n *  \\param  ctx    BN_CTX object (optional)\n *  \\return 1 on success and 0 if an error occurred\n */\nint EC_POINTs_mul(const EC_GROUP *group, EC_POINT *r, const BIGNUM *n,\n                  size_t num, const EC_POINT *p[], const BIGNUM *m[],\n                  BN_CTX *ctx);\n\n/** Computes r = generator * n + q * m\n *  \\param  group  underlying EC_GROUP object\n *  \\param  r      EC_POINT object for the result\n *  \\param  n      BIGNUM with the multiplier for the group generator (optional)\n *  \\param  q      EC_POINT object with the first factor of the second summand\n *  \\param  m      BIGNUM with the second factor of the second summand\n *  \\param  ctx    BN_CTX object (optional)\n *  \\return 1 on success and 0 if an error occurred\n */\nint EC_POINT_mul(const EC_GROUP *group, EC_POINT *r, const BIGNUM *n,\n                 const EC_POINT *q, const BIGNUM *m, BN_CTX *ctx);\n\n/** Stores multiples of generator for faster point multiplication\n *  \\param  group  EC_GROUP object\n *  \\param  ctx    BN_CTX object (optional)\n *  \\return 1 on success and 0 if an error occurred\n */\nint EC_GROUP_precompute_mult(EC_GROUP *group, BN_CTX *ctx);\n\n/** Reports whether a precomputation has been done\n *  \\param  group  EC_GROUP object\n *  \\return 1 if a pre-computation has been done and 0 otherwise\n */\nint EC_GROUP_have_precompute_mult(const EC_GROUP *group);\n\n/********************************************************************/\n/*                       ASN1 stuff                                 */\n/********************************************************************/\n\nDECLARE_ASN1_ITEM(ECPKPARAMETERS)\nDECLARE_ASN1_ALLOC_FUNCTIONS(ECPKPARAMETERS)\nDECLARE_ASN1_ITEM(ECPARAMETERS)\nDECLARE_ASN1_ALLOC_FUNCTIONS(ECPARAMETERS)\n\n/*\n * EC_GROUP_get_basis_type() returns the NID of the basis type used to\n * represent the field elements\n */\nint EC_GROUP_get_basis_type(const EC_GROUP *);\n# ifndef OPENSSL_NO_EC2M\nint EC_GROUP_get_trinomial_basis(const EC_GROUP *, unsigned int *k);\nint EC_GROUP_get_pentanomial_basis(const EC_GROUP *, unsigned int *k1,\n                                   unsigned int *k2, unsigned int *k3);\n# endif\n\n# define OPENSSL_EC_EXPLICIT_CURVE  0x000\n# define OPENSSL_EC_NAMED_CURVE     0x001\n\nEC_GROUP *d2i_ECPKParameters(EC_GROUP **, const unsigned char **in, long len);\nint i2d_ECPKParameters(const EC_GROUP *, unsigned char **out);\n\n# define d2i_ECPKParameters_bio(bp,x) ASN1_d2i_bio_of(EC_GROUP,NULL,d2i_ECPKParameters,bp,x)\n# define i2d_ECPKParameters_bio(bp,x) ASN1_i2d_bio_of_const(EC_GROUP,i2d_ECPKParameters,bp,x)\n# define d2i_ECPKParameters_fp(fp,x) (EC_GROUP *)ASN1_d2i_fp(NULL, \\\n                (char *(*)())d2i_ECPKParameters,(fp),(unsigned char **)(x))\n# define i2d_ECPKParameters_fp(fp,x) ASN1_i2d_fp(i2d_ECPKParameters,(fp), \\\n                (unsigned char *)(x))\n\nint ECPKParameters_print(BIO *bp, const EC_GROUP *x, int off);\n# ifndef OPENSSL_NO_STDIO\nint ECPKParameters_print_fp(FILE *fp, const EC_GROUP *x, int off);\n# endif\n\n/********************************************************************/\n/*                      EC_KEY functions                            */\n/********************************************************************/\n\n/* some values for the encoding_flag */\n# define EC_PKEY_NO_PARAMETERS   0x001\n# define EC_PKEY_NO_PUBKEY       0x002\n\n/* some values for the flags field */\n# define EC_FLAG_NON_FIPS_ALLOW  0x1\n# define EC_FLAG_FIPS_CHECKED    0x2\n# define EC_FLAG_COFACTOR_ECDH   0x1000\n\n/** Creates a new EC_KEY object.\n *  \\return EC_KEY object or NULL if an error occurred.\n */\nEC_KEY *EC_KEY_new(void);\n\nint EC_KEY_get_flags(const EC_KEY *key);\n\nvoid EC_KEY_set_flags(EC_KEY *key, int flags);\n\nvoid EC_KEY_clear_flags(EC_KEY *key, int flags);\n\nint EC_KEY_decoded_from_explicit_params(const EC_KEY *key);\n\n/** Creates a new EC_KEY object using a named curve as underlying\n *  EC_GROUP object.\n *  \\param  nid  NID of the named curve.\n *  \\return EC_KEY object or NULL if an error occurred.\n */\nEC_KEY *EC_KEY_new_by_curve_name(int nid);\n\n/** Frees a EC_KEY object.\n *  \\param  key  EC_KEY object to be freed.\n */\nvoid EC_KEY_free(EC_KEY *key);\n\n/** Copies a EC_KEY object.\n *  \\param  dst  destination EC_KEY object\n *  \\param  src  src EC_KEY object\n *  \\return dst or NULL if an error occurred.\n */\nEC_KEY *EC_KEY_copy(EC_KEY *dst, const EC_KEY *src);\n\n/** Creates a new EC_KEY object and copies the content from src to it.\n *  \\param  src  the source EC_KEY object\n *  \\return newly created EC_KEY object or NULL if an error occurred.\n */\nEC_KEY *EC_KEY_dup(const EC_KEY *src);\n\n/** Increases the internal reference count of a EC_KEY object.\n *  \\param  key  EC_KEY object\n *  \\return 1 on success and 0 if an error occurred.\n */\nint EC_KEY_up_ref(EC_KEY *key);\n\n/** Returns the ENGINE object of a EC_KEY object\n *  \\param  eckey  EC_KEY object\n *  \\return the ENGINE object (possibly NULL).\n */\nENGINE *EC_KEY_get0_engine(const EC_KEY *eckey);\n\n/** Returns the EC_GROUP object of a EC_KEY object\n *  \\param  key  EC_KEY object\n *  \\return the EC_GROUP object (possibly NULL).\n */\nconst EC_GROUP *EC_KEY_get0_group(const EC_KEY *key);\n\n/** Sets the EC_GROUP of a EC_KEY object.\n *  \\param  key    EC_KEY object\n *  \\param  group  EC_GROUP to use in the EC_KEY object (note: the EC_KEY\n *                 object will use an own copy of the EC_GROUP).\n *  \\return 1 on success and 0 if an error occurred.\n */\nint EC_KEY_set_group(EC_KEY *key, const EC_GROUP *group);\n\n/** Returns the private key of a EC_KEY object.\n *  \\param  key  EC_KEY object\n *  \\return a BIGNUM with the private key (possibly NULL).\n */\nconst BIGNUM *EC_KEY_get0_private_key(const EC_KEY *key);\n\n/** Sets the private key of a EC_KEY object.\n *  \\param  key  EC_KEY object\n *  \\param  prv  BIGNUM with the private key (note: the EC_KEY object\n *               will use an own copy of the BIGNUM).\n *  \\return 1 on success and 0 if an error occurred.\n */\nint EC_KEY_set_private_key(EC_KEY *key, const BIGNUM *prv);\n\n/** Returns the public key of a EC_KEY object.\n *  \\param  key  the EC_KEY object\n *  \\return a EC_POINT object with the public key (possibly NULL)\n */\nconst EC_POINT *EC_KEY_get0_public_key(const EC_KEY *key);\n\n/** Sets the public key of a EC_KEY object.\n *  \\param  key  EC_KEY object\n *  \\param  pub  EC_POINT object with the public key (note: the EC_KEY object\n *               will use an own copy of the EC_POINT object).\n *  \\return 1 on success and 0 if an error occurred.\n */\nint EC_KEY_set_public_key(EC_KEY *key, const EC_POINT *pub);\n\nunsigned EC_KEY_get_enc_flags(const EC_KEY *key);\nvoid EC_KEY_set_enc_flags(EC_KEY *eckey, unsigned int flags);\npoint_conversion_form_t EC_KEY_get_conv_form(const EC_KEY *key);\nvoid EC_KEY_set_conv_form(EC_KEY *eckey, point_conversion_form_t cform);\n\n#define EC_KEY_get_ex_new_index(l, p, newf, dupf, freef) \\\n    CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_EC_KEY, l, p, newf, dupf, freef)\nint EC_KEY_set_ex_data(EC_KEY *key, int idx, void *arg);\nvoid *EC_KEY_get_ex_data(const EC_KEY *key, int idx);\n\n/* wrapper functions for the underlying EC_GROUP object */\nvoid EC_KEY_set_asn1_flag(EC_KEY *eckey, int asn1_flag);\n\n/** Creates a table of pre-computed multiples of the generator to\n *  accelerate further EC_KEY operations.\n *  \\param  key  EC_KEY object\n *  \\param  ctx  BN_CTX object (optional)\n *  \\return 1 on success and 0 if an error occurred.\n */\nint EC_KEY_precompute_mult(EC_KEY *key, BN_CTX *ctx);\n\n/** Creates a new ec private (and optional a new public) key.\n *  \\param  key  EC_KEY object\n *  \\return 1 on success and 0 if an error occurred.\n */\nint EC_KEY_generate_key(EC_KEY *key);\n\n/** Verifies that a private and/or public key is valid.\n *  \\param  key  the EC_KEY object\n *  \\return 1 on success and 0 otherwise.\n */\nint EC_KEY_check_key(const EC_KEY *key);\n\n/** Indicates if an EC_KEY can be used for signing.\n *  \\param  eckey  the EC_KEY object\n *  \\return 1 if can can sign and 0 otherwise.\n */\nint EC_KEY_can_sign(const EC_KEY *eckey);\n\n/** Sets a public key from affine coordinates performing\n *  necessary NIST PKV tests.\n *  \\param  key  the EC_KEY object\n *  \\param  x    public key x coordinate\n *  \\param  y    public key y coordinate\n *  \\return 1 on success and 0 otherwise.\n */\nint EC_KEY_set_public_key_affine_coordinates(EC_KEY *key, BIGNUM *x,\n                                             BIGNUM *y);\n\n/** Encodes an EC_KEY public key to an allocated octet string\n *  \\param  key    key to encode\n *  \\param  form   point conversion form\n *  \\param  pbuf   returns pointer to allocated buffer\n *  \\param  ctx    BN_CTX object (optional)\n *  \\return the length of the encoded octet string or 0 if an error occurred\n */\nsize_t EC_KEY_key2buf(const EC_KEY *key, point_conversion_form_t form,\n                      unsigned char **pbuf, BN_CTX *ctx);\n\n/** Decodes a EC_KEY public key from a octet string\n *  \\param  key    key to decode\n *  \\param  buf    memory buffer with the encoded ec point\n *  \\param  len    length of the encoded ec point\n *  \\param  ctx    BN_CTX object (optional)\n *  \\return 1 on success and 0 if an error occurred\n */\n\nint EC_KEY_oct2key(EC_KEY *key, const unsigned char *buf, size_t len,\n                   BN_CTX *ctx);\n\n/** Decodes an EC_KEY private key from an octet string\n *  \\param  key    key to decode\n *  \\param  buf    memory buffer with the encoded private key\n *  \\param  len    length of the encoded key\n *  \\return 1 on success and 0 if an error occurred\n */\n\nint EC_KEY_oct2priv(EC_KEY *key, const unsigned char *buf, size_t len);\n\n/** Encodes a EC_KEY private key to an octet string\n *  \\param  key    key to encode\n *  \\param  buf    memory buffer for the result. If NULL the function returns\n *                 required buffer size.\n *  \\param  len    length of the memory buffer\n *  \\return the length of the encoded octet string or 0 if an error occurred\n */\n\nsize_t EC_KEY_priv2oct(const EC_KEY *key, unsigned char *buf, size_t len);\n\n/** Encodes an EC_KEY private key to an allocated octet string\n *  \\param  eckey  key to encode\n *  \\param  pbuf   returns pointer to allocated buffer\n *  \\return the length of the encoded octet string or 0 if an error occurred\n */\nsize_t EC_KEY_priv2buf(const EC_KEY *eckey, unsigned char **pbuf);\n\n/********************************************************************/\n/*        de- and encoding functions for SEC1 ECPrivateKey          */\n/********************************************************************/\n\n/** Decodes a private key from a memory buffer.\n *  \\param  key  a pointer to a EC_KEY object which should be used (or NULL)\n *  \\param  in   pointer to memory with the DER encoded private key\n *  \\param  len  length of the DER encoded private key\n *  \\return the decoded private key or NULL if an error occurred.\n */\nEC_KEY *d2i_ECPrivateKey(EC_KEY **key, const unsigned char **in, long len);\n\n/** Encodes a private key object and stores the result in a buffer.\n *  \\param  key  the EC_KEY object to encode\n *  \\param  out  the buffer for the result (if NULL the function returns number\n *               of bytes needed).\n *  \\return 1 on success and 0 if an error occurred.\n */\nint i2d_ECPrivateKey(EC_KEY *key, unsigned char **out);\n\n/********************************************************************/\n/*        de- and encoding functions for EC parameters              */\n/********************************************************************/\n\n/** Decodes ec parameter from a memory buffer.\n *  \\param  key  a pointer to a EC_KEY object which should be used (or NULL)\n *  \\param  in   pointer to memory with the DER encoded ec parameters\n *  \\param  len  length of the DER encoded ec parameters\n *  \\return a EC_KEY object with the decoded parameters or NULL if an error\n *          occurred.\n */\nEC_KEY *d2i_ECParameters(EC_KEY **key, const unsigned char **in, long len);\n\n/** Encodes ec parameter and stores the result in a buffer.\n *  \\param  key  the EC_KEY object with ec parameters to encode\n *  \\param  out  the buffer for the result (if NULL the function returns number\n *               of bytes needed).\n *  \\return 1 on success and 0 if an error occurred.\n */\nint i2d_ECParameters(EC_KEY *key, unsigned char **out);\n\n/********************************************************************/\n/*         de- and encoding functions for EC public key             */\n/*         (octet string, not DER -- hence 'o2i' and 'i2o')         */\n/********************************************************************/\n\n/** Decodes a ec public key from a octet string.\n *  \\param  key  a pointer to a EC_KEY object which should be used\n *  \\param  in   memory buffer with the encoded public key\n *  \\param  len  length of the encoded public key\n *  \\return EC_KEY object with decoded public key or NULL if an error\n *          occurred.\n */\nEC_KEY *o2i_ECPublicKey(EC_KEY **key, const unsigned char **in, long len);\n\n/** Encodes a ec public key in an octet string.\n *  \\param  key  the EC_KEY object with the public key\n *  \\param  out  the buffer for the result (if NULL the function returns number\n *               of bytes needed).\n *  \\return 1 on success and 0 if an error occurred\n */\nint i2o_ECPublicKey(const EC_KEY *key, unsigned char **out);\n\n/** Prints out the ec parameters on human readable form.\n *  \\param  bp   BIO object to which the information is printed\n *  \\param  key  EC_KEY object\n *  \\return 1 on success and 0 if an error occurred\n */\nint ECParameters_print(BIO *bp, const EC_KEY *key);\n\n/** Prints out the contents of a EC_KEY object\n *  \\param  bp   BIO object to which the information is printed\n *  \\param  key  EC_KEY object\n *  \\param  off  line offset\n *  \\return 1 on success and 0 if an error occurred\n */\nint EC_KEY_print(BIO *bp, const EC_KEY *key, int off);\n\n# ifndef OPENSSL_NO_STDIO\n/** Prints out the ec parameters on human readable form.\n *  \\param  fp   file descriptor to which the information is printed\n *  \\param  key  EC_KEY object\n *  \\return 1 on success and 0 if an error occurred\n */\nint ECParameters_print_fp(FILE *fp, const EC_KEY *key);\n\n/** Prints out the contents of a EC_KEY object\n *  \\param  fp   file descriptor to which the information is printed\n *  \\param  key  EC_KEY object\n *  \\param  off  line offset\n *  \\return 1 on success and 0 if an error occurred\n */\nint EC_KEY_print_fp(FILE *fp, const EC_KEY *key, int off);\n\n# endif\n\nconst EC_KEY_METHOD *EC_KEY_OpenSSL(void);\nconst EC_KEY_METHOD *EC_KEY_get_default_method(void);\nvoid EC_KEY_set_default_method(const EC_KEY_METHOD *meth);\nconst EC_KEY_METHOD *EC_KEY_get_method(const EC_KEY *key);\nint EC_KEY_set_method(EC_KEY *key, const EC_KEY_METHOD *meth);\nEC_KEY *EC_KEY_new_method(ENGINE *engine);\n\n/** The old name for ecdh_KDF_X9_63\n *  The ECDH KDF specification has been mistakingly attributed to ANSI X9.62,\n *  it is actually specified in ANSI X9.63.\n *  This identifier is retained for backwards compatibility\n */\nint ECDH_KDF_X9_62(unsigned char *out, size_t outlen,\n                   const unsigned char *Z, size_t Zlen,\n                   const unsigned char *sinfo, size_t sinfolen,\n                   const EVP_MD *md);\n\nint ECDH_compute_key(void *out, size_t outlen, const EC_POINT *pub_key,\n                     const EC_KEY *ecdh,\n                     void *(*KDF) (const void *in, size_t inlen,\n                                   void *out, size_t *outlen));\n\ntypedef struct ECDSA_SIG_st ECDSA_SIG;\n\n/** Allocates and initialize a ECDSA_SIG structure\n *  \\return pointer to a ECDSA_SIG structure or NULL if an error occurred\n */\nECDSA_SIG *ECDSA_SIG_new(void);\n\n/** frees a ECDSA_SIG structure\n *  \\param  sig  pointer to the ECDSA_SIG structure\n */\nvoid ECDSA_SIG_free(ECDSA_SIG *sig);\n\n/** DER encode content of ECDSA_SIG object (note: this function modifies *pp\n *  (*pp += length of the DER encoded signature)).\n *  \\param  sig  pointer to the ECDSA_SIG object\n *  \\param  pp   pointer to a unsigned char pointer for the output or NULL\n *  \\return the length of the DER encoded ECDSA_SIG object or a negative value\n *          on error\n */\nint i2d_ECDSA_SIG(const ECDSA_SIG *sig, unsigned char **pp);\n\n/** Decodes a DER encoded ECDSA signature (note: this function changes *pp\n *  (*pp += len)).\n *  \\param  sig  pointer to ECDSA_SIG pointer (may be NULL)\n *  \\param  pp   memory buffer with the DER encoded signature\n *  \\param  len  length of the buffer\n *  \\return pointer to the decoded ECDSA_SIG structure (or NULL)\n */\nECDSA_SIG *d2i_ECDSA_SIG(ECDSA_SIG **sig, const unsigned char **pp, long len);\n\n/** Accessor for r and s fields of ECDSA_SIG\n *  \\param  sig  pointer to ECDSA_SIG structure\n *  \\param  pr   pointer to BIGNUM pointer for r (may be NULL)\n *  \\param  ps   pointer to BIGNUM pointer for s (may be NULL)\n */\nvoid ECDSA_SIG_get0(const ECDSA_SIG *sig, const BIGNUM **pr, const BIGNUM **ps);\n\n/** Accessor for r field of ECDSA_SIG\n *  \\param  sig  pointer to ECDSA_SIG structure\n */\nconst BIGNUM *ECDSA_SIG_get0_r(const ECDSA_SIG *sig);\n\n/** Accessor for s field of ECDSA_SIG\n *  \\param  sig  pointer to ECDSA_SIG structure\n */\nconst BIGNUM *ECDSA_SIG_get0_s(const ECDSA_SIG *sig);\n\n/** Setter for r and s fields of ECDSA_SIG\n *  \\param  sig  pointer to ECDSA_SIG structure\n *  \\param  r    pointer to BIGNUM for r (may be NULL)\n *  \\param  s    pointer to BIGNUM for s (may be NULL)\n */\nint ECDSA_SIG_set0(ECDSA_SIG *sig, BIGNUM *r, BIGNUM *s);\n\n/** Computes the ECDSA signature of the given hash value using\n *  the supplied private key and returns the created signature.\n *  \\param  dgst      pointer to the hash value\n *  \\param  dgst_len  length of the hash value\n *  \\param  eckey     EC_KEY object containing a private EC key\n *  \\return pointer to a ECDSA_SIG structure or NULL if an error occurred\n */\nECDSA_SIG *ECDSA_do_sign(const unsigned char *dgst, int dgst_len,\n                         EC_KEY *eckey);\n\n/** Computes ECDSA signature of a given hash value using the supplied\n *  private key (note: sig must point to ECDSA_size(eckey) bytes of memory).\n *  \\param  dgst     pointer to the hash value to sign\n *  \\param  dgstlen  length of the hash value\n *  \\param  kinv     BIGNUM with a pre-computed inverse k (optional)\n *  \\param  rp       BIGNUM with a pre-computed rp value (optional),\n *                   see ECDSA_sign_setup\n *  \\param  eckey    EC_KEY object containing a private EC key\n *  \\return pointer to a ECDSA_SIG structure or NULL if an error occurred\n */\nECDSA_SIG *ECDSA_do_sign_ex(const unsigned char *dgst, int dgstlen,\n                            const BIGNUM *kinv, const BIGNUM *rp,\n                            EC_KEY *eckey);\n\n/** Verifies that the supplied signature is a valid ECDSA\n *  signature of the supplied hash value using the supplied public key.\n *  \\param  dgst      pointer to the hash value\n *  \\param  dgst_len  length of the hash value\n *  \\param  sig       ECDSA_SIG structure\n *  \\param  eckey     EC_KEY object containing a public EC key\n *  \\return 1 if the signature is valid, 0 if the signature is invalid\n *          and -1 on error\n */\nint ECDSA_do_verify(const unsigned char *dgst, int dgst_len,\n                    const ECDSA_SIG *sig, EC_KEY *eckey);\n\n/** Precompute parts of the signing operation\n *  \\param  eckey  EC_KEY object containing a private EC key\n *  \\param  ctx    BN_CTX object (optional)\n *  \\param  kinv   BIGNUM pointer for the inverse of k\n *  \\param  rp     BIGNUM pointer for x coordinate of k * generator\n *  \\return 1 on success and 0 otherwise\n */\nint ECDSA_sign_setup(EC_KEY *eckey, BN_CTX *ctx, BIGNUM **kinv, BIGNUM **rp);\n\n/** Computes ECDSA signature of a given hash value using the supplied\n *  private key (note: sig must point to ECDSA_size(eckey) bytes of memory).\n *  \\param  type     this parameter is ignored\n *  \\param  dgst     pointer to the hash value to sign\n *  \\param  dgstlen  length of the hash value\n *  \\param  sig      memory for the DER encoded created signature\n *  \\param  siglen   pointer to the length of the returned signature\n *  \\param  eckey    EC_KEY object containing a private EC key\n *  \\return 1 on success and 0 otherwise\n */\nint ECDSA_sign(int type, const unsigned char *dgst, int dgstlen,\n               unsigned char *sig, unsigned int *siglen, EC_KEY *eckey);\n\n/** Computes ECDSA signature of a given hash value using the supplied\n *  private key (note: sig must point to ECDSA_size(eckey) bytes of memory).\n *  \\param  type     this parameter is ignored\n *  \\param  dgst     pointer to the hash value to sign\n *  \\param  dgstlen  length of the hash value\n *  \\param  sig      buffer to hold the DER encoded signature\n *  \\param  siglen   pointer to the length of the returned signature\n *  \\param  kinv     BIGNUM with a pre-computed inverse k (optional)\n *  \\param  rp       BIGNUM with a pre-computed rp value (optional),\n *                   see ECDSA_sign_setup\n *  \\param  eckey    EC_KEY object containing a private EC key\n *  \\return 1 on success and 0 otherwise\n */\nint ECDSA_sign_ex(int type, const unsigned char *dgst, int dgstlen,\n                  unsigned char *sig, unsigned int *siglen,\n                  const BIGNUM *kinv, const BIGNUM *rp, EC_KEY *eckey);\n\n/** Verifies that the given signature is valid ECDSA signature\n *  of the supplied hash value using the specified public key.\n *  \\param  type     this parameter is ignored\n *  \\param  dgst     pointer to the hash value\n *  \\param  dgstlen  length of the hash value\n *  \\param  sig      pointer to the DER encoded signature\n *  \\param  siglen   length of the DER encoded signature\n *  \\param  eckey    EC_KEY object containing a public EC key\n *  \\return 1 if the signature is valid, 0 if the signature is invalid\n *          and -1 on error\n */\nint ECDSA_verify(int type, const unsigned char *dgst, int dgstlen,\n                 const unsigned char *sig, int siglen, EC_KEY *eckey);\n\n/** Returns the maximum length of the DER encoded signature\n *  \\param  eckey  EC_KEY object\n *  \\return numbers of bytes required for the DER encoded signature\n */\nint ECDSA_size(const EC_KEY *eckey);\n\n/********************************************************************/\n/*  EC_KEY_METHOD constructors, destructors, writers and accessors  */\n/********************************************************************/\n\nEC_KEY_METHOD *EC_KEY_METHOD_new(const EC_KEY_METHOD *meth);\nvoid EC_KEY_METHOD_free(EC_KEY_METHOD *meth);\nvoid EC_KEY_METHOD_set_init(EC_KEY_METHOD *meth,\n                            int (*init)(EC_KEY *key),\n                            void (*finish)(EC_KEY *key),\n                            int (*copy)(EC_KEY *dest, const EC_KEY *src),\n                            int (*set_group)(EC_KEY *key, const EC_GROUP *grp),\n                            int (*set_private)(EC_KEY *key,\n                                               const BIGNUM *priv_key),\n                            int (*set_public)(EC_KEY *key,\n                                              const EC_POINT *pub_key));\n\nvoid EC_KEY_METHOD_set_keygen(EC_KEY_METHOD *meth,\n                              int (*keygen)(EC_KEY *key));\n\nvoid EC_KEY_METHOD_set_compute_key(EC_KEY_METHOD *meth,\n                                   int (*ckey)(unsigned char **psec,\n                                               size_t *pseclen,\n                                               const EC_POINT *pub_key,\n                                               const EC_KEY *ecdh));\n\nvoid EC_KEY_METHOD_set_sign(EC_KEY_METHOD *meth,\n                            int (*sign)(int type, const unsigned char *dgst,\n                                        int dlen, unsigned char *sig,\n                                        unsigned int *siglen,\n                                        const BIGNUM *kinv, const BIGNUM *r,\n                                        EC_KEY *eckey),\n                            int (*sign_setup)(EC_KEY *eckey, BN_CTX *ctx_in,\n                                              BIGNUM **kinvp, BIGNUM **rp),\n                            ECDSA_SIG *(*sign_sig)(const unsigned char *dgst,\n                                                   int dgst_len,\n                                                   const BIGNUM *in_kinv,\n                                                   const BIGNUM *in_r,\n                                                   EC_KEY *eckey));\n\nvoid EC_KEY_METHOD_set_verify(EC_KEY_METHOD *meth,\n                              int (*verify)(int type, const unsigned\n                                            char *dgst, int dgst_len,\n                                            const unsigned char *sigbuf,\n                                            int sig_len, EC_KEY *eckey),\n                              int (*verify_sig)(const unsigned char *dgst,\n                                                int dgst_len,\n                                                const ECDSA_SIG *sig,\n                                                EC_KEY *eckey));\n\nvoid EC_KEY_METHOD_get_init(const EC_KEY_METHOD *meth,\n                            int (**pinit)(EC_KEY *key),\n                            void (**pfinish)(EC_KEY *key),\n                            int (**pcopy)(EC_KEY *dest, const EC_KEY *src),\n                            int (**pset_group)(EC_KEY *key,\n                                               const EC_GROUP *grp),\n                            int (**pset_private)(EC_KEY *key,\n                                                 const BIGNUM *priv_key),\n                            int (**pset_public)(EC_KEY *key,\n                                                const EC_POINT *pub_key));\n\nvoid EC_KEY_METHOD_get_keygen(const EC_KEY_METHOD *meth,\n                              int (**pkeygen)(EC_KEY *key));\n\nvoid EC_KEY_METHOD_get_compute_key(const EC_KEY_METHOD *meth,\n                                   int (**pck)(unsigned char **psec,\n                                               size_t *pseclen,\n                                               const EC_POINT *pub_key,\n                                               const EC_KEY *ecdh));\n\nvoid EC_KEY_METHOD_get_sign(const EC_KEY_METHOD *meth,\n                            int (**psign)(int type, const unsigned char *dgst,\n                                          int dlen, unsigned char *sig,\n                                          unsigned int *siglen,\n                                          const BIGNUM *kinv, const BIGNUM *r,\n                                          EC_KEY *eckey),\n                            int (**psign_setup)(EC_KEY *eckey, BN_CTX *ctx_in,\n                                                BIGNUM **kinvp, BIGNUM **rp),\n                            ECDSA_SIG *(**psign_sig)(const unsigned char *dgst,\n                                                     int dgst_len,\n                                                     const BIGNUM *in_kinv,\n                                                     const BIGNUM *in_r,\n                                                     EC_KEY *eckey));\n\nvoid EC_KEY_METHOD_get_verify(const EC_KEY_METHOD *meth,\n                              int (**pverify)(int type, const unsigned\n                                              char *dgst, int dgst_len,\n                                              const unsigned char *sigbuf,\n                                              int sig_len, EC_KEY *eckey),\n                              int (**pverify_sig)(const unsigned char *dgst,\n                                                  int dgst_len,\n                                                  const ECDSA_SIG *sig,\n                                                  EC_KEY *eckey));\n\n# define ECParameters_dup(x) ASN1_dup_of(EC_KEY,i2d_ECParameters,d2i_ECParameters,x)\n\n# ifndef __cplusplus\n#  if defined(__SUNPRO_C)\n#   if __SUNPRO_C >= 0x520\n#    pragma error_messages (default,E_ARRAY_OF_INCOMPLETE_NONAME,E_ARRAY_OF_INCOMPLETE)\n#   endif\n#  endif\n# endif\n\n# define EVP_PKEY_CTX_set_ec_paramgen_curve_nid(ctx, nid) \\\n        EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_EC, \\\n                                EVP_PKEY_OP_PARAMGEN|EVP_PKEY_OP_KEYGEN, \\\n                                EVP_PKEY_CTRL_EC_PARAMGEN_CURVE_NID, nid, NULL)\n\n# define EVP_PKEY_CTX_set_ec_param_enc(ctx, flag) \\\n        EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_EC, \\\n                                EVP_PKEY_OP_PARAMGEN|EVP_PKEY_OP_KEYGEN, \\\n                                EVP_PKEY_CTRL_EC_PARAM_ENC, flag, NULL)\n\n# define EVP_PKEY_CTX_set_ecdh_cofactor_mode(ctx, flag) \\\n        EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_EC, \\\n                                EVP_PKEY_OP_DERIVE, \\\n                                EVP_PKEY_CTRL_EC_ECDH_COFACTOR, flag, NULL)\n\n# define EVP_PKEY_CTX_get_ecdh_cofactor_mode(ctx) \\\n        EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_EC, \\\n                                EVP_PKEY_OP_DERIVE, \\\n                                EVP_PKEY_CTRL_EC_ECDH_COFACTOR, -2, NULL)\n\n# define EVP_PKEY_CTX_set_ecdh_kdf_type(ctx, kdf) \\\n        EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_EC, \\\n                                EVP_PKEY_OP_DERIVE, \\\n                                EVP_PKEY_CTRL_EC_KDF_TYPE, kdf, NULL)\n\n# define EVP_PKEY_CTX_get_ecdh_kdf_type(ctx) \\\n        EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_EC, \\\n                                EVP_PKEY_OP_DERIVE, \\\n                                EVP_PKEY_CTRL_EC_KDF_TYPE, -2, NULL)\n\n# define EVP_PKEY_CTX_set_ecdh_kdf_md(ctx, md) \\\n        EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_EC, \\\n                                EVP_PKEY_OP_DERIVE, \\\n                                EVP_PKEY_CTRL_EC_KDF_MD, 0, (void *)(md))\n\n# define EVP_PKEY_CTX_get_ecdh_kdf_md(ctx, pmd) \\\n        EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_EC, \\\n                                EVP_PKEY_OP_DERIVE, \\\n                                EVP_PKEY_CTRL_GET_EC_KDF_MD, 0, (void *)(pmd))\n\n# define EVP_PKEY_CTX_set_ecdh_kdf_outlen(ctx, len) \\\n        EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_EC, \\\n                                EVP_PKEY_OP_DERIVE, \\\n                                EVP_PKEY_CTRL_EC_KDF_OUTLEN, len, NULL)\n\n# define EVP_PKEY_CTX_get_ecdh_kdf_outlen(ctx, plen) \\\n        EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_EC, \\\n                                EVP_PKEY_OP_DERIVE, \\\n                                EVP_PKEY_CTRL_GET_EC_KDF_OUTLEN, 0, \\\n                                (void *)(plen))\n\n# define EVP_PKEY_CTX_set0_ecdh_kdf_ukm(ctx, p, plen) \\\n        EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_EC, \\\n                                EVP_PKEY_OP_DERIVE, \\\n                                EVP_PKEY_CTRL_EC_KDF_UKM, plen, (void *)(p))\n\n# define EVP_PKEY_CTX_get0_ecdh_kdf_ukm(ctx, p) \\\n        EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_EC, \\\n                                EVP_PKEY_OP_DERIVE, \\\n                                EVP_PKEY_CTRL_GET_EC_KDF_UKM, 0, (void *)(p))\n\n/* SM2 will skip the operation check so no need to pass operation here */\n# define EVP_PKEY_CTX_set1_id(ctx, id, id_len) \\\n        EVP_PKEY_CTX_ctrl(ctx, -1, -1, \\\n                                EVP_PKEY_CTRL_SET1_ID, (int)id_len, (void*)(id))\n\n# define EVP_PKEY_CTX_get1_id(ctx, id) \\\n        EVP_PKEY_CTX_ctrl(ctx, -1, -1, \\\n                                EVP_PKEY_CTRL_GET1_ID, 0, (void*)(id))\n\n# define EVP_PKEY_CTX_get1_id_len(ctx, id_len) \\\n        EVP_PKEY_CTX_ctrl(ctx, -1, -1, \\\n                                EVP_PKEY_CTRL_GET1_ID_LEN, 0, (void*)(id_len))\n\n# define EVP_PKEY_CTRL_EC_PARAMGEN_CURVE_NID             (EVP_PKEY_ALG_CTRL + 1)\n# define EVP_PKEY_CTRL_EC_PARAM_ENC                      (EVP_PKEY_ALG_CTRL + 2)\n# define EVP_PKEY_CTRL_EC_ECDH_COFACTOR                  (EVP_PKEY_ALG_CTRL + 3)\n# define EVP_PKEY_CTRL_EC_KDF_TYPE                       (EVP_PKEY_ALG_CTRL + 4)\n# define EVP_PKEY_CTRL_EC_KDF_MD                         (EVP_PKEY_ALG_CTRL + 5)\n# define EVP_PKEY_CTRL_GET_EC_KDF_MD                     (EVP_PKEY_ALG_CTRL + 6)\n# define EVP_PKEY_CTRL_EC_KDF_OUTLEN                     (EVP_PKEY_ALG_CTRL + 7)\n# define EVP_PKEY_CTRL_GET_EC_KDF_OUTLEN                 (EVP_PKEY_ALG_CTRL + 8)\n# define EVP_PKEY_CTRL_EC_KDF_UKM                        (EVP_PKEY_ALG_CTRL + 9)\n# define EVP_PKEY_CTRL_GET_EC_KDF_UKM                    (EVP_PKEY_ALG_CTRL + 10)\n# define EVP_PKEY_CTRL_SET1_ID                           (EVP_PKEY_ALG_CTRL + 11)\n# define EVP_PKEY_CTRL_GET1_ID                           (EVP_PKEY_ALG_CTRL + 12)\n# define EVP_PKEY_CTRL_GET1_ID_LEN                       (EVP_PKEY_ALG_CTRL + 13)\n/* KDF types */\n# define EVP_PKEY_ECDH_KDF_NONE                          1\n# define EVP_PKEY_ECDH_KDF_X9_63                         2\n/** The old name for EVP_PKEY_ECDH_KDF_X9_63\n *  The ECDH KDF specification has been mistakingly attributed to ANSI X9.62,\n *  it is actually specified in ANSI X9.63.\n *  This identifier is retained for backwards compatibility\n */\n# define EVP_PKEY_ECDH_KDF_X9_62   EVP_PKEY_ECDH_KDF_X9_63\n\n\n#  ifdef  __cplusplus\n}\n#  endif\n# endif\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/include/openssl/ecdh.h",
    "content": "/*\n * Copyright 2002-2016 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#include <openssl/ec.h>\n"
  },
  {
    "path": "tools/prebuild/openssl/include/openssl/ecdsa.h",
    "content": "/*\n * Copyright 2002-2016 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#include <openssl/ec.h>\n"
  },
  {
    "path": "tools/prebuild/openssl/include/openssl/ecerr.h",
    "content": "/*\n * Generated by util/mkerr.pl DO NOT EDIT\n * Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef HEADER_ECERR_H\n# define HEADER_ECERR_H\n\n# ifndef HEADER_SYMHACKS_H\n#  include <openssl/symhacks.h>\n# endif\n\n# include <openssl/opensslconf.h>\n\n# ifndef OPENSSL_NO_EC\n\n#  ifdef  __cplusplus\nextern \"C\"\n#  endif\nint ERR_load_EC_strings(void);\n\n/*\n * EC function codes.\n */\n#  define EC_F_BN_TO_FELEM                                 224\n#  define EC_F_D2I_ECPARAMETERS                            144\n#  define EC_F_D2I_ECPKPARAMETERS                          145\n#  define EC_F_D2I_ECPRIVATEKEY                            146\n#  define EC_F_DO_EC_KEY_PRINT                             221\n#  define EC_F_ECDH_CMS_DECRYPT                            238\n#  define EC_F_ECDH_CMS_SET_SHARED_INFO                    239\n#  define EC_F_ECDH_COMPUTE_KEY                            246\n#  define EC_F_ECDH_SIMPLE_COMPUTE_KEY                     257\n#  define EC_F_ECDSA_DO_SIGN_EX                            251\n#  define EC_F_ECDSA_DO_VERIFY                             252\n#  define EC_F_ECDSA_SIGN_EX                               254\n#  define EC_F_ECDSA_SIGN_SETUP                            248\n#  define EC_F_ECDSA_SIG_NEW                               265\n#  define EC_F_ECDSA_VERIFY                                253\n#  define EC_F_ECD_ITEM_VERIFY                             270\n#  define EC_F_ECKEY_PARAM2TYPE                            223\n#  define EC_F_ECKEY_PARAM_DECODE                          212\n#  define EC_F_ECKEY_PRIV_DECODE                           213\n#  define EC_F_ECKEY_PRIV_ENCODE                           214\n#  define EC_F_ECKEY_PUB_DECODE                            215\n#  define EC_F_ECKEY_PUB_ENCODE                            216\n#  define EC_F_ECKEY_TYPE2PARAM                            220\n#  define EC_F_ECPARAMETERS_PRINT                          147\n#  define EC_F_ECPARAMETERS_PRINT_FP                       148\n#  define EC_F_ECPKPARAMETERS_PRINT                        149\n#  define EC_F_ECPKPARAMETERS_PRINT_FP                     150\n#  define EC_F_ECP_NISTZ256_GET_AFFINE                     240\n#  define EC_F_ECP_NISTZ256_INV_MOD_ORD                    275\n#  define EC_F_ECP_NISTZ256_MULT_PRECOMPUTE                243\n#  define EC_F_ECP_NISTZ256_POINTS_MUL                     241\n#  define EC_F_ECP_NISTZ256_PRE_COMP_NEW                   244\n#  define EC_F_ECP_NISTZ256_WINDOWED_MUL                   242\n#  define EC_F_ECX_KEY_OP                                  266\n#  define EC_F_ECX_PRIV_ENCODE                             267\n#  define EC_F_ECX_PUB_ENCODE                              268\n#  define EC_F_EC_ASN1_GROUP2CURVE                         153\n#  define EC_F_EC_ASN1_GROUP2FIELDID                       154\n#  define EC_F_EC_GF2M_MONTGOMERY_POINT_MULTIPLY           208\n#  define EC_F_EC_GF2M_SIMPLE_FIELD_INV                    296\n#  define EC_F_EC_GF2M_SIMPLE_GROUP_CHECK_DISCRIMINANT     159\n#  define EC_F_EC_GF2M_SIMPLE_GROUP_SET_CURVE              195\n#  define EC_F_EC_GF2M_SIMPLE_LADDER_POST                  285\n#  define EC_F_EC_GF2M_SIMPLE_LADDER_PRE                   288\n#  define EC_F_EC_GF2M_SIMPLE_OCT2POINT                    160\n#  define EC_F_EC_GF2M_SIMPLE_POINT2OCT                    161\n#  define EC_F_EC_GF2M_SIMPLE_POINTS_MUL                   289\n#  define EC_F_EC_GF2M_SIMPLE_POINT_GET_AFFINE_COORDINATES 162\n#  define EC_F_EC_GF2M_SIMPLE_POINT_SET_AFFINE_COORDINATES 163\n#  define EC_F_EC_GF2M_SIMPLE_SET_COMPRESSED_COORDINATES   164\n#  define EC_F_EC_GFP_MONT_FIELD_DECODE                    133\n#  define EC_F_EC_GFP_MONT_FIELD_ENCODE                    134\n#  define EC_F_EC_GFP_MONT_FIELD_INV                       297\n#  define EC_F_EC_GFP_MONT_FIELD_MUL                       131\n#  define EC_F_EC_GFP_MONT_FIELD_SET_TO_ONE                209\n#  define EC_F_EC_GFP_MONT_FIELD_SQR                       132\n#  define EC_F_EC_GFP_MONT_GROUP_SET_CURVE                 189\n#  define EC_F_EC_GFP_NISTP224_GROUP_SET_CURVE             225\n#  define EC_F_EC_GFP_NISTP224_POINTS_MUL                  228\n#  define EC_F_EC_GFP_NISTP224_POINT_GET_AFFINE_COORDINATES 226\n#  define EC_F_EC_GFP_NISTP256_GROUP_SET_CURVE             230\n#  define EC_F_EC_GFP_NISTP256_POINTS_MUL                  231\n#  define EC_F_EC_GFP_NISTP256_POINT_GET_AFFINE_COORDINATES 232\n#  define EC_F_EC_GFP_NISTP521_GROUP_SET_CURVE             233\n#  define EC_F_EC_GFP_NISTP521_POINTS_MUL                  234\n#  define EC_F_EC_GFP_NISTP521_POINT_GET_AFFINE_COORDINATES 235\n#  define EC_F_EC_GFP_NIST_FIELD_MUL                       200\n#  define EC_F_EC_GFP_NIST_FIELD_SQR                       201\n#  define EC_F_EC_GFP_NIST_GROUP_SET_CURVE                 202\n#  define EC_F_EC_GFP_SIMPLE_BLIND_COORDINATES             287\n#  define EC_F_EC_GFP_SIMPLE_FIELD_INV                     298\n#  define EC_F_EC_GFP_SIMPLE_GROUP_CHECK_DISCRIMINANT      165\n#  define EC_F_EC_GFP_SIMPLE_GROUP_SET_CURVE               166\n#  define EC_F_EC_GFP_SIMPLE_MAKE_AFFINE                   102\n#  define EC_F_EC_GFP_SIMPLE_OCT2POINT                     103\n#  define EC_F_EC_GFP_SIMPLE_POINT2OCT                     104\n#  define EC_F_EC_GFP_SIMPLE_POINTS_MAKE_AFFINE            137\n#  define EC_F_EC_GFP_SIMPLE_POINT_GET_AFFINE_COORDINATES  167\n#  define EC_F_EC_GFP_SIMPLE_POINT_SET_AFFINE_COORDINATES  168\n#  define EC_F_EC_GFP_SIMPLE_SET_COMPRESSED_COORDINATES    169\n#  define EC_F_EC_GROUP_CHECK                              170\n#  define EC_F_EC_GROUP_CHECK_DISCRIMINANT                 171\n#  define EC_F_EC_GROUP_COPY                               106\n#  define EC_F_EC_GROUP_GET_CURVE                          291\n#  define EC_F_EC_GROUP_GET_CURVE_GF2M                     172\n#  define EC_F_EC_GROUP_GET_CURVE_GFP                      130\n#  define EC_F_EC_GROUP_GET_DEGREE                         173\n#  define EC_F_EC_GROUP_GET_ECPARAMETERS                   261\n#  define EC_F_EC_GROUP_GET_ECPKPARAMETERS                 262\n#  define EC_F_EC_GROUP_GET_PENTANOMIAL_BASIS              193\n#  define EC_F_EC_GROUP_GET_TRINOMIAL_BASIS                194\n#  define EC_F_EC_GROUP_NEW                                108\n#  define EC_F_EC_GROUP_NEW_BY_CURVE_NAME                  174\n#  define EC_F_EC_GROUP_NEW_FROM_DATA                      175\n#  define EC_F_EC_GROUP_NEW_FROM_ECPARAMETERS              263\n#  define EC_F_EC_GROUP_NEW_FROM_ECPKPARAMETERS            264\n#  define EC_F_EC_GROUP_SET_CURVE                          292\n#  define EC_F_EC_GROUP_SET_CURVE_GF2M                     176\n#  define EC_F_EC_GROUP_SET_CURVE_GFP                      109\n#  define EC_F_EC_GROUP_SET_GENERATOR                      111\n#  define EC_F_EC_GROUP_SET_SEED                           286\n#  define EC_F_EC_KEY_CHECK_KEY                            177\n#  define EC_F_EC_KEY_COPY                                 178\n#  define EC_F_EC_KEY_GENERATE_KEY                         179\n#  define EC_F_EC_KEY_NEW                                  182\n#  define EC_F_EC_KEY_NEW_METHOD                           245\n#  define EC_F_EC_KEY_OCT2PRIV                             255\n#  define EC_F_EC_KEY_PRINT                                180\n#  define EC_F_EC_KEY_PRINT_FP                             181\n#  define EC_F_EC_KEY_PRIV2BUF                             279\n#  define EC_F_EC_KEY_PRIV2OCT                             256\n#  define EC_F_EC_KEY_SET_PUBLIC_KEY_AFFINE_COORDINATES    229\n#  define EC_F_EC_KEY_SIMPLE_CHECK_KEY                     258\n#  define EC_F_EC_KEY_SIMPLE_OCT2PRIV                      259\n#  define EC_F_EC_KEY_SIMPLE_PRIV2OCT                      260\n#  define EC_F_EC_PKEY_CHECK                               273\n#  define EC_F_EC_PKEY_PARAM_CHECK                         274\n#  define EC_F_EC_POINTS_MAKE_AFFINE                       136\n#  define EC_F_EC_POINTS_MUL                               290\n#  define EC_F_EC_POINT_ADD                                112\n#  define EC_F_EC_POINT_BN2POINT                           280\n#  define EC_F_EC_POINT_CMP                                113\n#  define EC_F_EC_POINT_COPY                               114\n#  define EC_F_EC_POINT_DBL                                115\n#  define EC_F_EC_POINT_GET_AFFINE_COORDINATES             293\n#  define EC_F_EC_POINT_GET_AFFINE_COORDINATES_GF2M        183\n#  define EC_F_EC_POINT_GET_AFFINE_COORDINATES_GFP         116\n#  define EC_F_EC_POINT_GET_JPROJECTIVE_COORDINATES_GFP    117\n#  define EC_F_EC_POINT_INVERT                             210\n#  define EC_F_EC_POINT_IS_AT_INFINITY                     118\n#  define EC_F_EC_POINT_IS_ON_CURVE                        119\n#  define EC_F_EC_POINT_MAKE_AFFINE                        120\n#  define EC_F_EC_POINT_NEW                                121\n#  define EC_F_EC_POINT_OCT2POINT                          122\n#  define EC_F_EC_POINT_POINT2BUF                          281\n#  define EC_F_EC_POINT_POINT2OCT                          123\n#  define EC_F_EC_POINT_SET_AFFINE_COORDINATES             294\n#  define EC_F_EC_POINT_SET_AFFINE_COORDINATES_GF2M        185\n#  define EC_F_EC_POINT_SET_AFFINE_COORDINATES_GFP         124\n#  define EC_F_EC_POINT_SET_COMPRESSED_COORDINATES         295\n#  define EC_F_EC_POINT_SET_COMPRESSED_COORDINATES_GF2M    186\n#  define EC_F_EC_POINT_SET_COMPRESSED_COORDINATES_GFP     125\n#  define EC_F_EC_POINT_SET_JPROJECTIVE_COORDINATES_GFP    126\n#  define EC_F_EC_POINT_SET_TO_INFINITY                    127\n#  define EC_F_EC_PRE_COMP_NEW                             196\n#  define EC_F_EC_SCALAR_MUL_LADDER                        284\n#  define EC_F_EC_WNAF_MUL                                 187\n#  define EC_F_EC_WNAF_PRECOMPUTE_MULT                     188\n#  define EC_F_I2D_ECPARAMETERS                            190\n#  define EC_F_I2D_ECPKPARAMETERS                          191\n#  define EC_F_I2D_ECPRIVATEKEY                            192\n#  define EC_F_I2O_ECPUBLICKEY                             151\n#  define EC_F_NISTP224_PRE_COMP_NEW                       227\n#  define EC_F_NISTP256_PRE_COMP_NEW                       236\n#  define EC_F_NISTP521_PRE_COMP_NEW                       237\n#  define EC_F_O2I_ECPUBLICKEY                             152\n#  define EC_F_OLD_EC_PRIV_DECODE                          222\n#  define EC_F_OSSL_ECDH_COMPUTE_KEY                       247\n#  define EC_F_OSSL_ECDSA_SIGN_SIG                         249\n#  define EC_F_OSSL_ECDSA_VERIFY_SIG                       250\n#  define EC_F_PKEY_ECD_CTRL                               271\n#  define EC_F_PKEY_ECD_DIGESTSIGN                         272\n#  define EC_F_PKEY_ECD_DIGESTSIGN25519                    276\n#  define EC_F_PKEY_ECD_DIGESTSIGN448                      277\n#  define EC_F_PKEY_ECX_DERIVE                             269\n#  define EC_F_PKEY_EC_CTRL                                197\n#  define EC_F_PKEY_EC_CTRL_STR                            198\n#  define EC_F_PKEY_EC_DERIVE                              217\n#  define EC_F_PKEY_EC_INIT                                282\n#  define EC_F_PKEY_EC_KDF_DERIVE                          283\n#  define EC_F_PKEY_EC_KEYGEN                              199\n#  define EC_F_PKEY_EC_PARAMGEN                            219\n#  define EC_F_PKEY_EC_SIGN                                218\n#  define EC_F_VALIDATE_ECX_DERIVE                         278\n\n/*\n * EC reason codes.\n */\n#  define EC_R_ASN1_ERROR                                  115\n#  define EC_R_BAD_SIGNATURE                               156\n#  define EC_R_BIGNUM_OUT_OF_RANGE                         144\n#  define EC_R_BUFFER_TOO_SMALL                            100\n#  define EC_R_CANNOT_INVERT                               165\n#  define EC_R_COORDINATES_OUT_OF_RANGE                    146\n#  define EC_R_CURVE_DOES_NOT_SUPPORT_ECDH                 160\n#  define EC_R_CURVE_DOES_NOT_SUPPORT_SIGNING              159\n#  define EC_R_D2I_ECPKPARAMETERS_FAILURE                  117\n#  define EC_R_DECODE_ERROR                                142\n#  define EC_R_DISCRIMINANT_IS_ZERO                        118\n#  define EC_R_EC_GROUP_NEW_BY_NAME_FAILURE                119\n#  define EC_R_FIELD_TOO_LARGE                             143\n#  define EC_R_GF2M_NOT_SUPPORTED                          147\n#  define EC_R_GROUP2PKPARAMETERS_FAILURE                  120\n#  define EC_R_I2D_ECPKPARAMETERS_FAILURE                  121\n#  define EC_R_INCOMPATIBLE_OBJECTS                        101\n#  define EC_R_INVALID_ARGUMENT                            112\n#  define EC_R_INVALID_COMPRESSED_POINT                    110\n#  define EC_R_INVALID_COMPRESSION_BIT                     109\n#  define EC_R_INVALID_CURVE                               141\n#  define EC_R_INVALID_DIGEST                              151\n#  define EC_R_INVALID_DIGEST_TYPE                         138\n#  define EC_R_INVALID_ENCODING                            102\n#  define EC_R_INVALID_FIELD                               103\n#  define EC_R_INVALID_FORM                                104\n#  define EC_R_INVALID_GROUP_ORDER                         122\n#  define EC_R_INVALID_KEY                                 116\n#  define EC_R_INVALID_OUTPUT_LENGTH                       161\n#  define EC_R_INVALID_PEER_KEY                            133\n#  define EC_R_INVALID_PENTANOMIAL_BASIS                   132\n#  define EC_R_INVALID_PRIVATE_KEY                         123\n#  define EC_R_INVALID_TRINOMIAL_BASIS                     137\n#  define EC_R_KDF_PARAMETER_ERROR                         148\n#  define EC_R_KEYS_NOT_SET                                140\n#  define EC_R_LADDER_POST_FAILURE                         136\n#  define EC_R_LADDER_PRE_FAILURE                          153\n#  define EC_R_LADDER_STEP_FAILURE                         162\n#  define EC_R_MISSING_OID                                 167\n#  define EC_R_MISSING_PARAMETERS                          124\n#  define EC_R_MISSING_PRIVATE_KEY                         125\n#  define EC_R_NEED_NEW_SETUP_VALUES                       157\n#  define EC_R_NOT_A_NIST_PRIME                            135\n#  define EC_R_NOT_IMPLEMENTED                             126\n#  define EC_R_NOT_INITIALIZED                             111\n#  define EC_R_NO_PARAMETERS_SET                           139\n#  define EC_R_NO_PRIVATE_VALUE                            154\n#  define EC_R_OPERATION_NOT_SUPPORTED                     152\n#  define EC_R_PASSED_NULL_PARAMETER                       134\n#  define EC_R_PEER_KEY_ERROR                              149\n#  define EC_R_PKPARAMETERS2GROUP_FAILURE                  127\n#  define EC_R_POINT_ARITHMETIC_FAILURE                    155\n#  define EC_R_POINT_AT_INFINITY                           106\n#  define EC_R_POINT_COORDINATES_BLIND_FAILURE             163\n#  define EC_R_POINT_IS_NOT_ON_CURVE                       107\n#  define EC_R_RANDOM_NUMBER_GENERATION_FAILED             158\n#  define EC_R_SHARED_INFO_ERROR                           150\n#  define EC_R_SLOT_FULL                                   108\n#  define EC_R_UNDEFINED_GENERATOR                         113\n#  define EC_R_UNDEFINED_ORDER                             128\n#  define EC_R_UNKNOWN_COFACTOR                            164\n#  define EC_R_UNKNOWN_GROUP                               129\n#  define EC_R_UNKNOWN_ORDER                               114\n#  define EC_R_UNSUPPORTED_FIELD                           131\n#  define EC_R_WRONG_CURVE_PARAMETERS                      145\n#  define EC_R_WRONG_ORDER                                 130\n\n# endif\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/include/openssl/engine.h",
    "content": "/*\n * Copyright 2000-2018 The OpenSSL Project Authors. All Rights Reserved.\n * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef HEADER_ENGINE_H\n# define HEADER_ENGINE_H\n\n# include <openssl/opensslconf.h>\n\n# ifndef OPENSSL_NO_ENGINE\n# if OPENSSL_API_COMPAT < 0x10100000L\n#  include <openssl/bn.h>\n#  include <openssl/rsa.h>\n#  include <openssl/dsa.h>\n#  include <openssl/dh.h>\n#  include <openssl/ec.h>\n#  include <openssl/rand.h>\n#  include <openssl/ui.h>\n#  include <openssl/err.h>\n# endif\n# include <openssl/ossl_typ.h>\n# include <openssl/symhacks.h>\n# include <openssl/x509.h>\n# include <openssl/engineerr.h>\n# ifdef  __cplusplus\nextern \"C\" {\n# endif\n\n/*\n * These flags are used to control combinations of algorithm (methods) by\n * bitwise \"OR\"ing.\n */\n# define ENGINE_METHOD_RSA               (unsigned int)0x0001\n# define ENGINE_METHOD_DSA               (unsigned int)0x0002\n# define ENGINE_METHOD_DH                (unsigned int)0x0004\n# define ENGINE_METHOD_RAND              (unsigned int)0x0008\n# define ENGINE_METHOD_CIPHERS           (unsigned int)0x0040\n# define ENGINE_METHOD_DIGESTS           (unsigned int)0x0080\n# define ENGINE_METHOD_PKEY_METHS        (unsigned int)0x0200\n# define ENGINE_METHOD_PKEY_ASN1_METHS   (unsigned int)0x0400\n# define ENGINE_METHOD_EC                (unsigned int)0x0800\n/* Obvious all-or-nothing cases. */\n# define ENGINE_METHOD_ALL               (unsigned int)0xFFFF\n# define ENGINE_METHOD_NONE              (unsigned int)0x0000\n\n/*\n * This(ese) flag(s) controls behaviour of the ENGINE_TABLE mechanism used\n * internally to control registration of ENGINE implementations, and can be\n * set by ENGINE_set_table_flags(). The \"NOINIT\" flag prevents attempts to\n * initialise registered ENGINEs if they are not already initialised.\n */\n# define ENGINE_TABLE_FLAG_NOINIT        (unsigned int)0x0001\n\n/* ENGINE flags that can be set by ENGINE_set_flags(). */\n/* Not used */\n/* #define ENGINE_FLAGS_MALLOCED        0x0001 */\n\n/*\n * This flag is for ENGINEs that wish to handle the various 'CMD'-related\n * control commands on their own. Without this flag, ENGINE_ctrl() handles\n * these control commands on behalf of the ENGINE using their \"cmd_defns\"\n * data.\n */\n# define ENGINE_FLAGS_MANUAL_CMD_CTRL    (int)0x0002\n\n/*\n * This flag is for ENGINEs who return new duplicate structures when found\n * via \"ENGINE_by_id()\". When an ENGINE must store state (eg. if\n * ENGINE_ctrl() commands are called in sequence as part of some stateful\n * process like key-generation setup and execution), it can set this flag -\n * then each attempt to obtain the ENGINE will result in it being copied into\n * a new structure. Normally, ENGINEs don't declare this flag so\n * ENGINE_by_id() just increments the existing ENGINE's structural reference\n * count.\n */\n# define ENGINE_FLAGS_BY_ID_COPY         (int)0x0004\n\n/*\n * This flag if for an ENGINE that does not want its methods registered as\n * part of ENGINE_register_all_complete() for example if the methods are not\n * usable as default methods.\n */\n\n# define ENGINE_FLAGS_NO_REGISTER_ALL    (int)0x0008\n\n/*\n * ENGINEs can support their own command types, and these flags are used in\n * ENGINE_CTRL_GET_CMD_FLAGS to indicate to the caller what kind of input\n * each command expects. Currently only numeric and string input is\n * supported. If a control command supports none of the _NUMERIC, _STRING, or\n * _NO_INPUT options, then it is regarded as an \"internal\" control command -\n * and not for use in config setting situations. As such, they're not\n * available to the ENGINE_ctrl_cmd_string() function, only raw ENGINE_ctrl()\n * access. Changes to this list of 'command types' should be reflected\n * carefully in ENGINE_cmd_is_executable() and ENGINE_ctrl_cmd_string().\n */\n\n/* accepts a 'long' input value (3rd parameter to ENGINE_ctrl) */\n# define ENGINE_CMD_FLAG_NUMERIC         (unsigned int)0x0001\n/*\n * accepts string input (cast from 'void*' to 'const char *', 4th parameter\n * to ENGINE_ctrl)\n */\n# define ENGINE_CMD_FLAG_STRING          (unsigned int)0x0002\n/*\n * Indicates that the control command takes *no* input. Ie. the control\n * command is unparameterised.\n */\n# define ENGINE_CMD_FLAG_NO_INPUT        (unsigned int)0x0004\n/*\n * Indicates that the control command is internal. This control command won't\n * be shown in any output, and is only usable through the ENGINE_ctrl_cmd()\n * function.\n */\n# define ENGINE_CMD_FLAG_INTERNAL        (unsigned int)0x0008\n\n/*\n * NB: These 3 control commands are deprecated and should not be used.\n * ENGINEs relying on these commands should compile conditional support for\n * compatibility (eg. if these symbols are defined) but should also migrate\n * the same functionality to their own ENGINE-specific control functions that\n * can be \"discovered\" by calling applications. The fact these control\n * commands wouldn't be \"executable\" (ie. usable by text-based config)\n * doesn't change the fact that application code can find and use them\n * without requiring per-ENGINE hacking.\n */\n\n/*\n * These flags are used to tell the ctrl function what should be done. All\n * command numbers are shared between all engines, even if some don't make\n * sense to some engines.  In such a case, they do nothing but return the\n * error ENGINE_R_CTRL_COMMAND_NOT_IMPLEMENTED.\n */\n# define ENGINE_CTRL_SET_LOGSTREAM               1\n# define ENGINE_CTRL_SET_PASSWORD_CALLBACK       2\n# define ENGINE_CTRL_HUP                         3/* Close and reinitialise\n                                                   * any handles/connections\n                                                   * etc. */\n# define ENGINE_CTRL_SET_USER_INTERFACE          4/* Alternative to callback */\n# define ENGINE_CTRL_SET_CALLBACK_DATA           5/* User-specific data, used\n                                                   * when calling the password\n                                                   * callback and the user\n                                                   * interface */\n# define ENGINE_CTRL_LOAD_CONFIGURATION          6/* Load a configuration,\n                                                   * given a string that\n                                                   * represents a file name\n                                                   * or so */\n# define ENGINE_CTRL_LOAD_SECTION                7/* Load data from a given\n                                                   * section in the already\n                                                   * loaded configuration */\n\n/*\n * These control commands allow an application to deal with an arbitrary\n * engine in a dynamic way. Warn: Negative return values indicate errors FOR\n * THESE COMMANDS because zero is used to indicate 'end-of-list'. Other\n * commands, including ENGINE-specific command types, return zero for an\n * error. An ENGINE can choose to implement these ctrl functions, and can\n * internally manage things however it chooses - it does so by setting the\n * ENGINE_FLAGS_MANUAL_CMD_CTRL flag (using ENGINE_set_flags()). Otherwise\n * the ENGINE_ctrl() code handles this on the ENGINE's behalf using the\n * cmd_defns data (set using ENGINE_set_cmd_defns()). This means an ENGINE's\n * ctrl() handler need only implement its own commands - the above \"meta\"\n * commands will be taken care of.\n */\n\n/*\n * Returns non-zero if the supplied ENGINE has a ctrl() handler. If \"not\",\n * then all the remaining control commands will return failure, so it is\n * worth checking this first if the caller is trying to \"discover\" the\n * engine's capabilities and doesn't want errors generated unnecessarily.\n */\n# define ENGINE_CTRL_HAS_CTRL_FUNCTION           10\n/*\n * Returns a positive command number for the first command supported by the\n * engine. Returns zero if no ctrl commands are supported.\n */\n# define ENGINE_CTRL_GET_FIRST_CMD_TYPE          11\n/*\n * The 'long' argument specifies a command implemented by the engine, and the\n * return value is the next command supported, or zero if there are no more.\n */\n# define ENGINE_CTRL_GET_NEXT_CMD_TYPE           12\n/*\n * The 'void*' argument is a command name (cast from 'const char *'), and the\n * return value is the command that corresponds to it.\n */\n# define ENGINE_CTRL_GET_CMD_FROM_NAME           13\n/*\n * The next two allow a command to be converted into its corresponding string\n * form. In each case, the 'long' argument supplies the command. In the\n * NAME_LEN case, the return value is the length of the command name (not\n * counting a trailing EOL). In the NAME case, the 'void*' argument must be a\n * string buffer large enough, and it will be populated with the name of the\n * command (WITH a trailing EOL).\n */\n# define ENGINE_CTRL_GET_NAME_LEN_FROM_CMD       14\n# define ENGINE_CTRL_GET_NAME_FROM_CMD           15\n/* The next two are similar but give a \"short description\" of a command. */\n# define ENGINE_CTRL_GET_DESC_LEN_FROM_CMD       16\n# define ENGINE_CTRL_GET_DESC_FROM_CMD           17\n/*\n * With this command, the return value is the OR'd combination of\n * ENGINE_CMD_FLAG_*** values that indicate what kind of input a given\n * engine-specific ctrl command expects.\n */\n# define ENGINE_CTRL_GET_CMD_FLAGS               18\n\n/*\n * ENGINE implementations should start the numbering of their own control\n * commands from this value. (ie. ENGINE_CMD_BASE, ENGINE_CMD_BASE + 1, etc).\n */\n# define ENGINE_CMD_BASE                         200\n\n/*\n * NB: These 2 nCipher \"chil\" control commands are deprecated, and their\n * functionality is now available through ENGINE-specific control commands\n * (exposed through the above-mentioned 'CMD'-handling). Code using these 2\n * commands should be migrated to the more general command handling before\n * these are removed.\n */\n\n/* Flags specific to the nCipher \"chil\" engine */\n# define ENGINE_CTRL_CHIL_SET_FORKCHECK          100\n        /*\n         * Depending on the value of the (long)i argument, this sets or\n         * unsets the SimpleForkCheck flag in the CHIL API to enable or\n         * disable checking and workarounds for applications that fork().\n         */\n# define ENGINE_CTRL_CHIL_NO_LOCKING             101\n        /*\n         * This prevents the initialisation function from providing mutex\n         * callbacks to the nCipher library.\n         */\n\n/*\n * If an ENGINE supports its own specific control commands and wishes the\n * framework to handle the above 'ENGINE_CMD_***'-manipulation commands on\n * its behalf, it should supply a null-terminated array of ENGINE_CMD_DEFN\n * entries to ENGINE_set_cmd_defns(). It should also implement a ctrl()\n * handler that supports the stated commands (ie. the \"cmd_num\" entries as\n * described by the array). NB: The array must be ordered in increasing order\n * of cmd_num. \"null-terminated\" means that the last ENGINE_CMD_DEFN element\n * has cmd_num set to zero and/or cmd_name set to NULL.\n */\ntypedef struct ENGINE_CMD_DEFN_st {\n    unsigned int cmd_num;       /* The command number */\n    const char *cmd_name;       /* The command name itself */\n    const char *cmd_desc;       /* A short description of the command */\n    unsigned int cmd_flags;     /* The input the command expects */\n} ENGINE_CMD_DEFN;\n\n/* Generic function pointer */\ntypedef int (*ENGINE_GEN_FUNC_PTR) (void);\n/* Generic function pointer taking no arguments */\ntypedef int (*ENGINE_GEN_INT_FUNC_PTR) (ENGINE *);\n/* Specific control function pointer */\ntypedef int (*ENGINE_CTRL_FUNC_PTR) (ENGINE *, int, long, void *,\n                                     void (*f) (void));\n/* Generic load_key function pointer */\ntypedef EVP_PKEY *(*ENGINE_LOAD_KEY_PTR)(ENGINE *, const char *,\n                                         UI_METHOD *ui_method,\n                                         void *callback_data);\ntypedef int (*ENGINE_SSL_CLIENT_CERT_PTR) (ENGINE *, SSL *ssl,\n                                           STACK_OF(X509_NAME) *ca_dn,\n                                           X509 **pcert, EVP_PKEY **pkey,\n                                           STACK_OF(X509) **pother,\n                                           UI_METHOD *ui_method,\n                                           void *callback_data);\n/*-\n * These callback types are for an ENGINE's handler for cipher and digest logic.\n * These handlers have these prototypes;\n *   int foo(ENGINE *e, const EVP_CIPHER **cipher, const int **nids, int nid);\n *   int foo(ENGINE *e, const EVP_MD **digest, const int **nids, int nid);\n * Looking at how to implement these handlers in the case of cipher support, if\n * the framework wants the EVP_CIPHER for 'nid', it will call;\n *   foo(e, &p_evp_cipher, NULL, nid);    (return zero for failure)\n * If the framework wants a list of supported 'nid's, it will call;\n *   foo(e, NULL, &p_nids, 0); (returns number of 'nids' or -1 for error)\n */\n/*\n * Returns to a pointer to the array of supported cipher 'nid's. If the\n * second parameter is non-NULL it is set to the size of the returned array.\n */\ntypedef int (*ENGINE_CIPHERS_PTR) (ENGINE *, const EVP_CIPHER **,\n                                   const int **, int);\ntypedef int (*ENGINE_DIGESTS_PTR) (ENGINE *, const EVP_MD **, const int **,\n                                   int);\ntypedef int (*ENGINE_PKEY_METHS_PTR) (ENGINE *, EVP_PKEY_METHOD **,\n                                      const int **, int);\ntypedef int (*ENGINE_PKEY_ASN1_METHS_PTR) (ENGINE *, EVP_PKEY_ASN1_METHOD **,\n                                           const int **, int);\n/*\n * STRUCTURE functions ... all of these functions deal with pointers to\n * ENGINE structures where the pointers have a \"structural reference\". This\n * means that their reference is to allowed access to the structure but it\n * does not imply that the structure is functional. To simply increment or\n * decrement the structural reference count, use ENGINE_by_id and\n * ENGINE_free. NB: This is not required when iterating using ENGINE_get_next\n * as it will automatically decrement the structural reference count of the\n * \"current\" ENGINE and increment the structural reference count of the\n * ENGINE it returns (unless it is NULL).\n */\n\n/* Get the first/last \"ENGINE\" type available. */\nENGINE *ENGINE_get_first(void);\nENGINE *ENGINE_get_last(void);\n/* Iterate to the next/previous \"ENGINE\" type (NULL = end of the list). */\nENGINE *ENGINE_get_next(ENGINE *e);\nENGINE *ENGINE_get_prev(ENGINE *e);\n/* Add another \"ENGINE\" type into the array. */\nint ENGINE_add(ENGINE *e);\n/* Remove an existing \"ENGINE\" type from the array. */\nint ENGINE_remove(ENGINE *e);\n/* Retrieve an engine from the list by its unique \"id\" value. */\nENGINE *ENGINE_by_id(const char *id);\n\n#if OPENSSL_API_COMPAT < 0x10100000L\n# define ENGINE_load_openssl() \\\n    OPENSSL_init_crypto(OPENSSL_INIT_ENGINE_OPENSSL, NULL)\n# define ENGINE_load_dynamic() \\\n    OPENSSL_init_crypto(OPENSSL_INIT_ENGINE_DYNAMIC, NULL)\n# ifndef OPENSSL_NO_STATIC_ENGINE\n#  define ENGINE_load_padlock() \\\n    OPENSSL_init_crypto(OPENSSL_INIT_ENGINE_PADLOCK, NULL)\n#  define ENGINE_load_capi() \\\n    OPENSSL_init_crypto(OPENSSL_INIT_ENGINE_CAPI, NULL)\n#  define ENGINE_load_afalg() \\\n    OPENSSL_init_crypto(OPENSSL_INIT_ENGINE_AFALG, NULL)\n# endif\n# define ENGINE_load_cryptodev() \\\n    OPENSSL_init_crypto(OPENSSL_INIT_ENGINE_CRYPTODEV, NULL)\n# define ENGINE_load_rdrand() \\\n    OPENSSL_init_crypto(OPENSSL_INIT_ENGINE_RDRAND, NULL)\n#endif\nvoid ENGINE_load_builtin_engines(void);\n\n/*\n * Get and set global flags (ENGINE_TABLE_FLAG_***) for the implementation\n * \"registry\" handling.\n */\nunsigned int ENGINE_get_table_flags(void);\nvoid ENGINE_set_table_flags(unsigned int flags);\n\n/*- Manage registration of ENGINEs per \"table\". For each type, there are 3\n * functions;\n *   ENGINE_register_***(e) - registers the implementation from 'e' (if it has one)\n *   ENGINE_unregister_***(e) - unregister the implementation from 'e'\n *   ENGINE_register_all_***() - call ENGINE_register_***() for each 'e' in the list\n * Cleanup is automatically registered from each table when required.\n */\n\nint ENGINE_register_RSA(ENGINE *e);\nvoid ENGINE_unregister_RSA(ENGINE *e);\nvoid ENGINE_register_all_RSA(void);\n\nint ENGINE_register_DSA(ENGINE *e);\nvoid ENGINE_unregister_DSA(ENGINE *e);\nvoid ENGINE_register_all_DSA(void);\n\nint ENGINE_register_EC(ENGINE *e);\nvoid ENGINE_unregister_EC(ENGINE *e);\nvoid ENGINE_register_all_EC(void);\n\nint ENGINE_register_DH(ENGINE *e);\nvoid ENGINE_unregister_DH(ENGINE *e);\nvoid ENGINE_register_all_DH(void);\n\nint ENGINE_register_RAND(ENGINE *e);\nvoid ENGINE_unregister_RAND(ENGINE *e);\nvoid ENGINE_register_all_RAND(void);\n\nint ENGINE_register_ciphers(ENGINE *e);\nvoid ENGINE_unregister_ciphers(ENGINE *e);\nvoid ENGINE_register_all_ciphers(void);\n\nint ENGINE_register_digests(ENGINE *e);\nvoid ENGINE_unregister_digests(ENGINE *e);\nvoid ENGINE_register_all_digests(void);\n\nint ENGINE_register_pkey_meths(ENGINE *e);\nvoid ENGINE_unregister_pkey_meths(ENGINE *e);\nvoid ENGINE_register_all_pkey_meths(void);\n\nint ENGINE_register_pkey_asn1_meths(ENGINE *e);\nvoid ENGINE_unregister_pkey_asn1_meths(ENGINE *e);\nvoid ENGINE_register_all_pkey_asn1_meths(void);\n\n/*\n * These functions register all support from the above categories. Note, use\n * of these functions can result in static linkage of code your application\n * may not need. If you only need a subset of functionality, consider using\n * more selective initialisation.\n */\nint ENGINE_register_complete(ENGINE *e);\nint ENGINE_register_all_complete(void);\n\n/*\n * Send parameterised control commands to the engine. The possibilities to\n * send down an integer, a pointer to data or a function pointer are\n * provided. Any of the parameters may or may not be NULL, depending on the\n * command number. In actuality, this function only requires a structural\n * (rather than functional) reference to an engine, but many control commands\n * may require the engine be functional. The caller should be aware of trying\n * commands that require an operational ENGINE, and only use functional\n * references in such situations.\n */\nint ENGINE_ctrl(ENGINE *e, int cmd, long i, void *p, void (*f) (void));\n\n/*\n * This function tests if an ENGINE-specific command is usable as a\n * \"setting\". Eg. in an application's config file that gets processed through\n * ENGINE_ctrl_cmd_string(). If this returns zero, it is not available to\n * ENGINE_ctrl_cmd_string(), only ENGINE_ctrl().\n */\nint ENGINE_cmd_is_executable(ENGINE *e, int cmd);\n\n/*\n * This function works like ENGINE_ctrl() with the exception of taking a\n * command name instead of a command number, and can handle optional\n * commands. See the comment on ENGINE_ctrl_cmd_string() for an explanation\n * on how to use the cmd_name and cmd_optional.\n */\nint ENGINE_ctrl_cmd(ENGINE *e, const char *cmd_name,\n                    long i, void *p, void (*f) (void), int cmd_optional);\n\n/*\n * This function passes a command-name and argument to an ENGINE. The\n * cmd_name is converted to a command number and the control command is\n * called using 'arg' as an argument (unless the ENGINE doesn't support such\n * a command, in which case no control command is called). The command is\n * checked for input flags, and if necessary the argument will be converted\n * to a numeric value. If cmd_optional is non-zero, then if the ENGINE\n * doesn't support the given cmd_name the return value will be success\n * anyway. This function is intended for applications to use so that users\n * (or config files) can supply engine-specific config data to the ENGINE at\n * run-time to control behaviour of specific engines. As such, it shouldn't\n * be used for calling ENGINE_ctrl() functions that return data, deal with\n * binary data, or that are otherwise supposed to be used directly through\n * ENGINE_ctrl() in application code. Any \"return\" data from an ENGINE_ctrl()\n * operation in this function will be lost - the return value is interpreted\n * as failure if the return value is zero, success otherwise, and this\n * function returns a boolean value as a result. In other words, vendors of\n * 'ENGINE'-enabled devices should write ENGINE implementations with\n * parameterisations that work in this scheme, so that compliant ENGINE-based\n * applications can work consistently with the same configuration for the\n * same ENGINE-enabled devices, across applications.\n */\nint ENGINE_ctrl_cmd_string(ENGINE *e, const char *cmd_name, const char *arg,\n                           int cmd_optional);\n\n/*\n * These functions are useful for manufacturing new ENGINE structures. They\n * don't address reference counting at all - one uses them to populate an\n * ENGINE structure with personalised implementations of things prior to\n * using it directly or adding it to the builtin ENGINE list in OpenSSL.\n * These are also here so that the ENGINE structure doesn't have to be\n * exposed and break binary compatibility!\n */\nENGINE *ENGINE_new(void);\nint ENGINE_free(ENGINE *e);\nint ENGINE_up_ref(ENGINE *e);\nint ENGINE_set_id(ENGINE *e, const char *id);\nint ENGINE_set_name(ENGINE *e, const char *name);\nint ENGINE_set_RSA(ENGINE *e, const RSA_METHOD *rsa_meth);\nint ENGINE_set_DSA(ENGINE *e, const DSA_METHOD *dsa_meth);\nint ENGINE_set_EC(ENGINE *e, const EC_KEY_METHOD *ecdsa_meth);\nint ENGINE_set_DH(ENGINE *e, const DH_METHOD *dh_meth);\nint ENGINE_set_RAND(ENGINE *e, const RAND_METHOD *rand_meth);\nint ENGINE_set_destroy_function(ENGINE *e, ENGINE_GEN_INT_FUNC_PTR destroy_f);\nint ENGINE_set_init_function(ENGINE *e, ENGINE_GEN_INT_FUNC_PTR init_f);\nint ENGINE_set_finish_function(ENGINE *e, ENGINE_GEN_INT_FUNC_PTR finish_f);\nint ENGINE_set_ctrl_function(ENGINE *e, ENGINE_CTRL_FUNC_PTR ctrl_f);\nint ENGINE_set_load_privkey_function(ENGINE *e,\n                                     ENGINE_LOAD_KEY_PTR loadpriv_f);\nint ENGINE_set_load_pubkey_function(ENGINE *e, ENGINE_LOAD_KEY_PTR loadpub_f);\nint ENGINE_set_load_ssl_client_cert_function(ENGINE *e,\n                                             ENGINE_SSL_CLIENT_CERT_PTR\n                                             loadssl_f);\nint ENGINE_set_ciphers(ENGINE *e, ENGINE_CIPHERS_PTR f);\nint ENGINE_set_digests(ENGINE *e, ENGINE_DIGESTS_PTR f);\nint ENGINE_set_pkey_meths(ENGINE *e, ENGINE_PKEY_METHS_PTR f);\nint ENGINE_set_pkey_asn1_meths(ENGINE *e, ENGINE_PKEY_ASN1_METHS_PTR f);\nint ENGINE_set_flags(ENGINE *e, int flags);\nint ENGINE_set_cmd_defns(ENGINE *e, const ENGINE_CMD_DEFN *defns);\n/* These functions allow control over any per-structure ENGINE data. */\n#define ENGINE_get_ex_new_index(l, p, newf, dupf, freef) \\\n    CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_ENGINE, l, p, newf, dupf, freef)\nint ENGINE_set_ex_data(ENGINE *e, int idx, void *arg);\nvoid *ENGINE_get_ex_data(const ENGINE *e, int idx);\n\n#if OPENSSL_API_COMPAT < 0x10100000L\n/*\n * This function previously cleaned up anything that needs it. Auto-deinit will\n * now take care of it so it is no longer required to call this function.\n */\n# define ENGINE_cleanup() while(0) continue\n#endif\n\n/*\n * These return values from within the ENGINE structure. These can be useful\n * with functional references as well as structural references - it depends\n * which you obtained. Using the result for functional purposes if you only\n * obtained a structural reference may be problematic!\n */\nconst char *ENGINE_get_id(const ENGINE *e);\nconst char *ENGINE_get_name(const ENGINE *e);\nconst RSA_METHOD *ENGINE_get_RSA(const ENGINE *e);\nconst DSA_METHOD *ENGINE_get_DSA(const ENGINE *e);\nconst EC_KEY_METHOD *ENGINE_get_EC(const ENGINE *e);\nconst DH_METHOD *ENGINE_get_DH(const ENGINE *e);\nconst RAND_METHOD *ENGINE_get_RAND(const ENGINE *e);\nENGINE_GEN_INT_FUNC_PTR ENGINE_get_destroy_function(const ENGINE *e);\nENGINE_GEN_INT_FUNC_PTR ENGINE_get_init_function(const ENGINE *e);\nENGINE_GEN_INT_FUNC_PTR ENGINE_get_finish_function(const ENGINE *e);\nENGINE_CTRL_FUNC_PTR ENGINE_get_ctrl_function(const ENGINE *e);\nENGINE_LOAD_KEY_PTR ENGINE_get_load_privkey_function(const ENGINE *e);\nENGINE_LOAD_KEY_PTR ENGINE_get_load_pubkey_function(const ENGINE *e);\nENGINE_SSL_CLIENT_CERT_PTR ENGINE_get_ssl_client_cert_function(const ENGINE\n                                                               *e);\nENGINE_CIPHERS_PTR ENGINE_get_ciphers(const ENGINE *e);\nENGINE_DIGESTS_PTR ENGINE_get_digests(const ENGINE *e);\nENGINE_PKEY_METHS_PTR ENGINE_get_pkey_meths(const ENGINE *e);\nENGINE_PKEY_ASN1_METHS_PTR ENGINE_get_pkey_asn1_meths(const ENGINE *e);\nconst EVP_CIPHER *ENGINE_get_cipher(ENGINE *e, int nid);\nconst EVP_MD *ENGINE_get_digest(ENGINE *e, int nid);\nconst EVP_PKEY_METHOD *ENGINE_get_pkey_meth(ENGINE *e, int nid);\nconst EVP_PKEY_ASN1_METHOD *ENGINE_get_pkey_asn1_meth(ENGINE *e, int nid);\nconst EVP_PKEY_ASN1_METHOD *ENGINE_get_pkey_asn1_meth_str(ENGINE *e,\n                                                          const char *str,\n                                                          int len);\nconst EVP_PKEY_ASN1_METHOD *ENGINE_pkey_asn1_find_str(ENGINE **pe,\n                                                      const char *str,\n                                                      int len);\nconst ENGINE_CMD_DEFN *ENGINE_get_cmd_defns(const ENGINE *e);\nint ENGINE_get_flags(const ENGINE *e);\n\n/*\n * FUNCTIONAL functions. These functions deal with ENGINE structures that\n * have (or will) be initialised for use. Broadly speaking, the structural\n * functions are useful for iterating the list of available engine types,\n * creating new engine types, and other \"list\" operations. These functions\n * actually deal with ENGINEs that are to be used. As such these functions\n * can fail (if applicable) when particular engines are unavailable - eg. if\n * a hardware accelerator is not attached or not functioning correctly. Each\n * ENGINE has 2 reference counts; structural and functional. Every time a\n * functional reference is obtained or released, a corresponding structural\n * reference is automatically obtained or released too.\n */\n\n/*\n * Initialise a engine type for use (or up its reference count if it's\n * already in use). This will fail if the engine is not currently operational\n * and cannot initialise.\n */\nint ENGINE_init(ENGINE *e);\n/*\n * Free a functional reference to a engine type. This does not require a\n * corresponding call to ENGINE_free as it also releases a structural\n * reference.\n */\nint ENGINE_finish(ENGINE *e);\n\n/*\n * The following functions handle keys that are stored in some secondary\n * location, handled by the engine.  The storage may be on a card or\n * whatever.\n */\nEVP_PKEY *ENGINE_load_private_key(ENGINE *e, const char *key_id,\n                                  UI_METHOD *ui_method, void *callback_data);\nEVP_PKEY *ENGINE_load_public_key(ENGINE *e, const char *key_id,\n                                 UI_METHOD *ui_method, void *callback_data);\nint ENGINE_load_ssl_client_cert(ENGINE *e, SSL *s,\n                                STACK_OF(X509_NAME) *ca_dn, X509 **pcert,\n                                EVP_PKEY **ppkey, STACK_OF(X509) **pother,\n                                UI_METHOD *ui_method, void *callback_data);\n\n/*\n * This returns a pointer for the current ENGINE structure that is (by\n * default) performing any RSA operations. The value returned is an\n * incremented reference, so it should be free'd (ENGINE_finish) before it is\n * discarded.\n */\nENGINE *ENGINE_get_default_RSA(void);\n/* Same for the other \"methods\" */\nENGINE *ENGINE_get_default_DSA(void);\nENGINE *ENGINE_get_default_EC(void);\nENGINE *ENGINE_get_default_DH(void);\nENGINE *ENGINE_get_default_RAND(void);\n/*\n * These functions can be used to get a functional reference to perform\n * ciphering or digesting corresponding to \"nid\".\n */\nENGINE *ENGINE_get_cipher_engine(int nid);\nENGINE *ENGINE_get_digest_engine(int nid);\nENGINE *ENGINE_get_pkey_meth_engine(int nid);\nENGINE *ENGINE_get_pkey_asn1_meth_engine(int nid);\n\n/*\n * This sets a new default ENGINE structure for performing RSA operations. If\n * the result is non-zero (success) then the ENGINE structure will have had\n * its reference count up'd so the caller should still free their own\n * reference 'e'.\n */\nint ENGINE_set_default_RSA(ENGINE *e);\nint ENGINE_set_default_string(ENGINE *e, const char *def_list);\n/* Same for the other \"methods\" */\nint ENGINE_set_default_DSA(ENGINE *e);\nint ENGINE_set_default_EC(ENGINE *e);\nint ENGINE_set_default_DH(ENGINE *e);\nint ENGINE_set_default_RAND(ENGINE *e);\nint ENGINE_set_default_ciphers(ENGINE *e);\nint ENGINE_set_default_digests(ENGINE *e);\nint ENGINE_set_default_pkey_meths(ENGINE *e);\nint ENGINE_set_default_pkey_asn1_meths(ENGINE *e);\n\n/*\n * The combination \"set\" - the flags are bitwise \"OR\"d from the\n * ENGINE_METHOD_*** defines above. As with the \"ENGINE_register_complete()\"\n * function, this function can result in unnecessary static linkage. If your\n * application requires only specific functionality, consider using more\n * selective functions.\n */\nint ENGINE_set_default(ENGINE *e, unsigned int flags);\n\nvoid ENGINE_add_conf_module(void);\n\n/* Deprecated functions ... */\n/* int ENGINE_clear_defaults(void); */\n\n/**************************/\n/* DYNAMIC ENGINE SUPPORT */\n/**************************/\n\n/* Binary/behaviour compatibility levels */\n# define OSSL_DYNAMIC_VERSION            (unsigned long)0x00030000\n/*\n * Binary versions older than this are too old for us (whether we're a loader\n * or a loadee)\n */\n# define OSSL_DYNAMIC_OLDEST             (unsigned long)0x00030000\n\n/*\n * When compiling an ENGINE entirely as an external shared library, loadable\n * by the \"dynamic\" ENGINE, these types are needed. The 'dynamic_fns'\n * structure type provides the calling application's (or library's) error\n * functionality and memory management function pointers to the loaded\n * library. These should be used/set in the loaded library code so that the\n * loading application's 'state' will be used/changed in all operations. The\n * 'static_state' pointer allows the loaded library to know if it shares the\n * same static data as the calling application (or library), and thus whether\n * these callbacks need to be set or not.\n */\ntypedef void *(*dyn_MEM_malloc_fn) (size_t, const char *, int);\ntypedef void *(*dyn_MEM_realloc_fn) (void *, size_t, const char *, int);\ntypedef void (*dyn_MEM_free_fn) (void *, const char *, int);\ntypedef struct st_dynamic_MEM_fns {\n    dyn_MEM_malloc_fn malloc_fn;\n    dyn_MEM_realloc_fn realloc_fn;\n    dyn_MEM_free_fn free_fn;\n} dynamic_MEM_fns;\n/*\n * FIXME: Perhaps the memory and locking code (crypto.h) should declare and\n * use these types so we (and any other dependent code) can simplify a bit??\n */\n/* The top-level structure */\ntypedef struct st_dynamic_fns {\n    void *static_state;\n    dynamic_MEM_fns mem_fns;\n} dynamic_fns;\n\n/*\n * The version checking function should be of this prototype. NB: The\n * ossl_version value passed in is the OSSL_DYNAMIC_VERSION of the loading\n * code. If this function returns zero, it indicates a (potential) version\n * incompatibility and the loaded library doesn't believe it can proceed.\n * Otherwise, the returned value is the (latest) version supported by the\n * loading library. The loader may still decide that the loaded code's\n * version is unsatisfactory and could veto the load. The function is\n * expected to be implemented with the symbol name \"v_check\", and a default\n * implementation can be fully instantiated with\n * IMPLEMENT_DYNAMIC_CHECK_FN().\n */\ntypedef unsigned long (*dynamic_v_check_fn) (unsigned long ossl_version);\n# define IMPLEMENT_DYNAMIC_CHECK_FN() \\\n        OPENSSL_EXPORT unsigned long v_check(unsigned long v); \\\n        OPENSSL_EXPORT unsigned long v_check(unsigned long v) { \\\n                if (v >= OSSL_DYNAMIC_OLDEST) return OSSL_DYNAMIC_VERSION; \\\n                return 0; }\n\n/*\n * This function is passed the ENGINE structure to initialise with its own\n * function and command settings. It should not adjust the structural or\n * functional reference counts. If this function returns zero, (a) the load\n * will be aborted, (b) the previous ENGINE state will be memcpy'd back onto\n * the structure, and (c) the shared library will be unloaded. So\n * implementations should do their own internal cleanup in failure\n * circumstances otherwise they could leak. The 'id' parameter, if non-NULL,\n * represents the ENGINE id that the loader is looking for. If this is NULL,\n * the shared library can choose to return failure or to initialise a\n * 'default' ENGINE. If non-NULL, the shared library must initialise only an\n * ENGINE matching the passed 'id'. The function is expected to be\n * implemented with the symbol name \"bind_engine\". A standard implementation\n * can be instantiated with IMPLEMENT_DYNAMIC_BIND_FN(fn) where the parameter\n * 'fn' is a callback function that populates the ENGINE structure and\n * returns an int value (zero for failure). 'fn' should have prototype;\n * [static] int fn(ENGINE *e, const char *id);\n */\ntypedef int (*dynamic_bind_engine) (ENGINE *e, const char *id,\n                                    const dynamic_fns *fns);\n# define IMPLEMENT_DYNAMIC_BIND_FN(fn) \\\n        OPENSSL_EXPORT \\\n        int bind_engine(ENGINE *e, const char *id, const dynamic_fns *fns); \\\n        OPENSSL_EXPORT \\\n        int bind_engine(ENGINE *e, const char *id, const dynamic_fns *fns) { \\\n            if (ENGINE_get_static_state() == fns->static_state) goto skip_cbs; \\\n            CRYPTO_set_mem_functions(fns->mem_fns.malloc_fn, \\\n                                     fns->mem_fns.realloc_fn, \\\n                                     fns->mem_fns.free_fn); \\\n        skip_cbs: \\\n            if (!fn(e, id)) return 0; \\\n            return 1; }\n\n/*\n * If the loading application (or library) and the loaded ENGINE library\n * share the same static data (eg. they're both dynamically linked to the\n * same libcrypto.so) we need a way to avoid trying to set system callbacks -\n * this would fail, and for the same reason that it's unnecessary to try. If\n * the loaded ENGINE has (or gets from through the loader) its own copy of\n * the libcrypto static data, we will need to set the callbacks. The easiest\n * way to detect this is to have a function that returns a pointer to some\n * static data and let the loading application and loaded ENGINE compare\n * their respective values.\n */\nvoid *ENGINE_get_static_state(void);\n\n# if defined(__OpenBSD__) || defined(__FreeBSD__) || defined(__DragonFly__)\nDEPRECATEDIN_1_1_0(void ENGINE_setup_bsd_cryptodev(void))\n# endif\n\n\n#  ifdef  __cplusplus\n}\n#  endif\n# endif\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/include/openssl/engineerr.h",
    "content": "/*\n * Generated by util/mkerr.pl DO NOT EDIT\n * Copyright 1995-2019 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef HEADER_ENGINEERR_H\n# define HEADER_ENGINEERR_H\n\n# ifndef HEADER_SYMHACKS_H\n#  include <openssl/symhacks.h>\n# endif\n\n# include <openssl/opensslconf.h>\n\n# ifndef OPENSSL_NO_ENGINE\n\n#  ifdef  __cplusplus\nextern \"C\"\n#  endif\nint ERR_load_ENGINE_strings(void);\n\n/*\n * ENGINE function codes.\n */\n#  define ENGINE_F_DIGEST_UPDATE                           198\n#  define ENGINE_F_DYNAMIC_CTRL                            180\n#  define ENGINE_F_DYNAMIC_GET_DATA_CTX                    181\n#  define ENGINE_F_DYNAMIC_LOAD                            182\n#  define ENGINE_F_DYNAMIC_SET_DATA_CTX                    183\n#  define ENGINE_F_ENGINE_ADD                              105\n#  define ENGINE_F_ENGINE_BY_ID                            106\n#  define ENGINE_F_ENGINE_CMD_IS_EXECUTABLE                170\n#  define ENGINE_F_ENGINE_CTRL                             142\n#  define ENGINE_F_ENGINE_CTRL_CMD                         178\n#  define ENGINE_F_ENGINE_CTRL_CMD_STRING                  171\n#  define ENGINE_F_ENGINE_FINISH                           107\n#  define ENGINE_F_ENGINE_GET_CIPHER                       185\n#  define ENGINE_F_ENGINE_GET_DIGEST                       186\n#  define ENGINE_F_ENGINE_GET_FIRST                        195\n#  define ENGINE_F_ENGINE_GET_LAST                         196\n#  define ENGINE_F_ENGINE_GET_NEXT                         115\n#  define ENGINE_F_ENGINE_GET_PKEY_ASN1_METH               193\n#  define ENGINE_F_ENGINE_GET_PKEY_METH                    192\n#  define ENGINE_F_ENGINE_GET_PREV                         116\n#  define ENGINE_F_ENGINE_INIT                             119\n#  define ENGINE_F_ENGINE_LIST_ADD                         120\n#  define ENGINE_F_ENGINE_LIST_REMOVE                      121\n#  define ENGINE_F_ENGINE_LOAD_PRIVATE_KEY                 150\n#  define ENGINE_F_ENGINE_LOAD_PUBLIC_KEY                  151\n#  define ENGINE_F_ENGINE_LOAD_SSL_CLIENT_CERT             194\n#  define ENGINE_F_ENGINE_NEW                              122\n#  define ENGINE_F_ENGINE_PKEY_ASN1_FIND_STR               197\n#  define ENGINE_F_ENGINE_REMOVE                           123\n#  define ENGINE_F_ENGINE_SET_DEFAULT_STRING               189\n#  define ENGINE_F_ENGINE_SET_ID                           129\n#  define ENGINE_F_ENGINE_SET_NAME                         130\n#  define ENGINE_F_ENGINE_TABLE_REGISTER                   184\n#  define ENGINE_F_ENGINE_UNLOCKED_FINISH                  191\n#  define ENGINE_F_ENGINE_UP_REF                           190\n#  define ENGINE_F_INT_CLEANUP_ITEM                        199\n#  define ENGINE_F_INT_CTRL_HELPER                         172\n#  define ENGINE_F_INT_ENGINE_CONFIGURE                    188\n#  define ENGINE_F_INT_ENGINE_MODULE_INIT                  187\n#  define ENGINE_F_OSSL_HMAC_INIT                          200\n\n/*\n * ENGINE reason codes.\n */\n#  define ENGINE_R_ALREADY_LOADED                          100\n#  define ENGINE_R_ARGUMENT_IS_NOT_A_NUMBER                133\n#  define ENGINE_R_CMD_NOT_EXECUTABLE                      134\n#  define ENGINE_R_COMMAND_TAKES_INPUT                     135\n#  define ENGINE_R_COMMAND_TAKES_NO_INPUT                  136\n#  define ENGINE_R_CONFLICTING_ENGINE_ID                   103\n#  define ENGINE_R_CTRL_COMMAND_NOT_IMPLEMENTED            119\n#  define ENGINE_R_DSO_FAILURE                             104\n#  define ENGINE_R_DSO_NOT_FOUND                           132\n#  define ENGINE_R_ENGINES_SECTION_ERROR                   148\n#  define ENGINE_R_ENGINE_CONFIGURATION_ERROR              102\n#  define ENGINE_R_ENGINE_IS_NOT_IN_LIST                   105\n#  define ENGINE_R_ENGINE_SECTION_ERROR                    149\n#  define ENGINE_R_FAILED_LOADING_PRIVATE_KEY              128\n#  define ENGINE_R_FAILED_LOADING_PUBLIC_KEY               129\n#  define ENGINE_R_FINISH_FAILED                           106\n#  define ENGINE_R_ID_OR_NAME_MISSING                      108\n#  define ENGINE_R_INIT_FAILED                             109\n#  define ENGINE_R_INTERNAL_LIST_ERROR                     110\n#  define ENGINE_R_INVALID_ARGUMENT                        143\n#  define ENGINE_R_INVALID_CMD_NAME                        137\n#  define ENGINE_R_INVALID_CMD_NUMBER                      138\n#  define ENGINE_R_INVALID_INIT_VALUE                      151\n#  define ENGINE_R_INVALID_STRING                          150\n#  define ENGINE_R_NOT_INITIALISED                         117\n#  define ENGINE_R_NOT_LOADED                              112\n#  define ENGINE_R_NO_CONTROL_FUNCTION                     120\n#  define ENGINE_R_NO_INDEX                                144\n#  define ENGINE_R_NO_LOAD_FUNCTION                        125\n#  define ENGINE_R_NO_REFERENCE                            130\n#  define ENGINE_R_NO_SUCH_ENGINE                          116\n#  define ENGINE_R_UNIMPLEMENTED_CIPHER                    146\n#  define ENGINE_R_UNIMPLEMENTED_DIGEST                    147\n#  define ENGINE_R_UNIMPLEMENTED_PUBLIC_KEY_METHOD         101\n#  define ENGINE_R_VERSION_INCOMPATIBILITY                 145\n\n# endif\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/include/openssl/err.h",
    "content": "/*\n * Copyright 1995-2019 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef HEADER_ERR_H\n# define HEADER_ERR_H\n\n# include <openssl/e_os2.h>\n\n# ifndef OPENSSL_NO_STDIO\n#  include <stdio.h>\n#  include <stdlib.h>\n# endif\n\n# include <openssl/ossl_typ.h>\n# include <openssl/bio.h>\n# include <openssl/lhash.h>\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n# ifndef OPENSSL_NO_ERR\n#  define ERR_PUT_error(a,b,c,d,e)        ERR_put_error(a,b,c,d,e)\n# else\n#  define ERR_PUT_error(a,b,c,d,e)        ERR_put_error(a,b,c,NULL,0)\n# endif\n\n# include <errno.h>\n\n# define ERR_TXT_MALLOCED        0x01\n# define ERR_TXT_STRING          0x02\n\n# define ERR_FLAG_MARK           0x01\n# define ERR_FLAG_CLEAR          0x02\n\n# define ERR_NUM_ERRORS  16\ntypedef struct err_state_st {\n    int err_flags[ERR_NUM_ERRORS];\n    unsigned long err_buffer[ERR_NUM_ERRORS];\n    char *err_data[ERR_NUM_ERRORS];\n    int err_data_flags[ERR_NUM_ERRORS];\n    const char *err_file[ERR_NUM_ERRORS];\n    int err_line[ERR_NUM_ERRORS];\n    int top, bottom;\n} ERR_STATE;\n\n/* library */\n# define ERR_LIB_NONE            1\n# define ERR_LIB_SYS             2\n# define ERR_LIB_BN              3\n# define ERR_LIB_RSA             4\n# define ERR_LIB_DH              5\n# define ERR_LIB_EVP             6\n# define ERR_LIB_BUF             7\n# define ERR_LIB_OBJ             8\n# define ERR_LIB_PEM             9\n# define ERR_LIB_DSA             10\n# define ERR_LIB_X509            11\n/* #define ERR_LIB_METH         12 */\n# define ERR_LIB_ASN1            13\n# define ERR_LIB_CONF            14\n# define ERR_LIB_CRYPTO          15\n# define ERR_LIB_EC              16\n# define ERR_LIB_SSL             20\n/* #define ERR_LIB_SSL23        21 */\n/* #define ERR_LIB_SSL2         22 */\n/* #define ERR_LIB_SSL3         23 */\n/* #define ERR_LIB_RSAREF       30 */\n/* #define ERR_LIB_PROXY        31 */\n# define ERR_LIB_BIO             32\n# define ERR_LIB_PKCS7           33\n# define ERR_LIB_X509V3          34\n# define ERR_LIB_PKCS12          35\n# define ERR_LIB_RAND            36\n# define ERR_LIB_DSO             37\n# define ERR_LIB_ENGINE          38\n# define ERR_LIB_OCSP            39\n# define ERR_LIB_UI              40\n# define ERR_LIB_COMP            41\n# define ERR_LIB_ECDSA           42\n# define ERR_LIB_ECDH            43\n# define ERR_LIB_OSSL_STORE      44\n# define ERR_LIB_FIPS            45\n# define ERR_LIB_CMS             46\n# define ERR_LIB_TS              47\n# define ERR_LIB_HMAC            48\n/* # define ERR_LIB_JPAKE       49 */\n# define ERR_LIB_CT              50\n# define ERR_LIB_ASYNC           51\n# define ERR_LIB_KDF             52\n# define ERR_LIB_SM2             53\n\n# define ERR_LIB_USER            128\n\n# define SYSerr(f,r)  ERR_PUT_error(ERR_LIB_SYS,(f),(r),OPENSSL_FILE,OPENSSL_LINE)\n# define BNerr(f,r)   ERR_PUT_error(ERR_LIB_BN,(f),(r),OPENSSL_FILE,OPENSSL_LINE)\n# define RSAerr(f,r)  ERR_PUT_error(ERR_LIB_RSA,(f),(r),OPENSSL_FILE,OPENSSL_LINE)\n# define DHerr(f,r)   ERR_PUT_error(ERR_LIB_DH,(f),(r),OPENSSL_FILE,OPENSSL_LINE)\n# define EVPerr(f,r)  ERR_PUT_error(ERR_LIB_EVP,(f),(r),OPENSSL_FILE,OPENSSL_LINE)\n# define BUFerr(f,r)  ERR_PUT_error(ERR_LIB_BUF,(f),(r),OPENSSL_FILE,OPENSSL_LINE)\n# define OBJerr(f,r)  ERR_PUT_error(ERR_LIB_OBJ,(f),(r),OPENSSL_FILE,OPENSSL_LINE)\n# define PEMerr(f,r)  ERR_PUT_error(ERR_LIB_PEM,(f),(r),OPENSSL_FILE,OPENSSL_LINE)\n# define DSAerr(f,r)  ERR_PUT_error(ERR_LIB_DSA,(f),(r),OPENSSL_FILE,OPENSSL_LINE)\n# define X509err(f,r) ERR_PUT_error(ERR_LIB_X509,(f),(r),OPENSSL_FILE,OPENSSL_LINE)\n# define ASN1err(f,r) ERR_PUT_error(ERR_LIB_ASN1,(f),(r),OPENSSL_FILE,OPENSSL_LINE)\n# define CONFerr(f,r) ERR_PUT_error(ERR_LIB_CONF,(f),(r),OPENSSL_FILE,OPENSSL_LINE)\n# define CRYPTOerr(f,r) ERR_PUT_error(ERR_LIB_CRYPTO,(f),(r),OPENSSL_FILE,OPENSSL_LINE)\n# define ECerr(f,r)   ERR_PUT_error(ERR_LIB_EC,(f),(r),OPENSSL_FILE,OPENSSL_LINE)\n# define SSLerr(f,r)  ERR_PUT_error(ERR_LIB_SSL,(f),(r),OPENSSL_FILE,OPENSSL_LINE)\n# define BIOerr(f,r)  ERR_PUT_error(ERR_LIB_BIO,(f),(r),OPENSSL_FILE,OPENSSL_LINE)\n# define PKCS7err(f,r) ERR_PUT_error(ERR_LIB_PKCS7,(f),(r),OPENSSL_FILE,OPENSSL_LINE)\n# define X509V3err(f,r) ERR_PUT_error(ERR_LIB_X509V3,(f),(r),OPENSSL_FILE,OPENSSL_LINE)\n# define PKCS12err(f,r) ERR_PUT_error(ERR_LIB_PKCS12,(f),(r),OPENSSL_FILE,OPENSSL_LINE)\n# define RANDerr(f,r) ERR_PUT_error(ERR_LIB_RAND,(f),(r),OPENSSL_FILE,OPENSSL_LINE)\n# define DSOerr(f,r) ERR_PUT_error(ERR_LIB_DSO,(f),(r),OPENSSL_FILE,OPENSSL_LINE)\n# define ENGINEerr(f,r) ERR_PUT_error(ERR_LIB_ENGINE,(f),(r),OPENSSL_FILE,OPENSSL_LINE)\n# define OCSPerr(f,r) ERR_PUT_error(ERR_LIB_OCSP,(f),(r),OPENSSL_FILE,OPENSSL_LINE)\n# define UIerr(f,r) ERR_PUT_error(ERR_LIB_UI,(f),(r),OPENSSL_FILE,OPENSSL_LINE)\n# define COMPerr(f,r) ERR_PUT_error(ERR_LIB_COMP,(f),(r),OPENSSL_FILE,OPENSSL_LINE)\n# define ECDSAerr(f,r)  ERR_PUT_error(ERR_LIB_ECDSA,(f),(r),OPENSSL_FILE,OPENSSL_LINE)\n# define ECDHerr(f,r)  ERR_PUT_error(ERR_LIB_ECDH,(f),(r),OPENSSL_FILE,OPENSSL_LINE)\n# define OSSL_STOREerr(f,r) ERR_PUT_error(ERR_LIB_OSSL_STORE,(f),(r),OPENSSL_FILE,OPENSSL_LINE)\n# define FIPSerr(f,r) ERR_PUT_error(ERR_LIB_FIPS,(f),(r),OPENSSL_FILE,OPENSSL_LINE)\n# define CMSerr(f,r) ERR_PUT_error(ERR_LIB_CMS,(f),(r),OPENSSL_FILE,OPENSSL_LINE)\n# define TSerr(f,r) ERR_PUT_error(ERR_LIB_TS,(f),(r),OPENSSL_FILE,OPENSSL_LINE)\n# define HMACerr(f,r) ERR_PUT_error(ERR_LIB_HMAC,(f),(r),OPENSSL_FILE,OPENSSL_LINE)\n# define CTerr(f,r) ERR_PUT_error(ERR_LIB_CT,(f),(r),OPENSSL_FILE,OPENSSL_LINE)\n# define ASYNCerr(f,r) ERR_PUT_error(ERR_LIB_ASYNC,(f),(r),OPENSSL_FILE,OPENSSL_LINE)\n# define KDFerr(f,r) ERR_PUT_error(ERR_LIB_KDF,(f),(r),OPENSSL_FILE,OPENSSL_LINE)\n# define SM2err(f,r) ERR_PUT_error(ERR_LIB_SM2,(f),(r),OPENSSL_FILE,OPENSSL_LINE)\n\n# define ERR_PACK(l,f,r) ( \\\n        (((unsigned int)(l) & 0x0FF) << 24L) | \\\n        (((unsigned int)(f) & 0xFFF) << 12L) | \\\n        (((unsigned int)(r) & 0xFFF)       ) )\n# define ERR_GET_LIB(l)          (int)(((l) >> 24L) & 0x0FFL)\n# define ERR_GET_FUNC(l)         (int)(((l) >> 12L) & 0xFFFL)\n# define ERR_GET_REASON(l)       (int)( (l)         & 0xFFFL)\n# define ERR_FATAL_ERROR(l)      (int)( (l)         & ERR_R_FATAL)\n\n/* OS functions */\n# define SYS_F_FOPEN             1\n# define SYS_F_CONNECT           2\n# define SYS_F_GETSERVBYNAME     3\n# define SYS_F_SOCKET            4\n# define SYS_F_IOCTLSOCKET       5\n# define SYS_F_BIND              6\n# define SYS_F_LISTEN            7\n# define SYS_F_ACCEPT            8\n# define SYS_F_WSASTARTUP        9/* Winsock stuff */\n# define SYS_F_OPENDIR           10\n# define SYS_F_FREAD             11\n# define SYS_F_GETADDRINFO       12\n# define SYS_F_GETNAMEINFO       13\n# define SYS_F_SETSOCKOPT        14\n# define SYS_F_GETSOCKOPT        15\n# define SYS_F_GETSOCKNAME       16\n# define SYS_F_GETHOSTBYNAME     17\n# define SYS_F_FFLUSH            18\n# define SYS_F_OPEN              19\n# define SYS_F_CLOSE             20\n# define SYS_F_IOCTL             21\n# define SYS_F_STAT              22\n# define SYS_F_FCNTL             23\n# define SYS_F_FSTAT             24\n\n/* reasons */\n# define ERR_R_SYS_LIB   ERR_LIB_SYS/* 2 */\n# define ERR_R_BN_LIB    ERR_LIB_BN/* 3 */\n# define ERR_R_RSA_LIB   ERR_LIB_RSA/* 4 */\n# define ERR_R_DH_LIB    ERR_LIB_DH/* 5 */\n# define ERR_R_EVP_LIB   ERR_LIB_EVP/* 6 */\n# define ERR_R_BUF_LIB   ERR_LIB_BUF/* 7 */\n# define ERR_R_OBJ_LIB   ERR_LIB_OBJ/* 8 */\n# define ERR_R_PEM_LIB   ERR_LIB_PEM/* 9 */\n# define ERR_R_DSA_LIB   ERR_LIB_DSA/* 10 */\n# define ERR_R_X509_LIB  ERR_LIB_X509/* 11 */\n# define ERR_R_ASN1_LIB  ERR_LIB_ASN1/* 13 */\n# define ERR_R_EC_LIB    ERR_LIB_EC/* 16 */\n# define ERR_R_BIO_LIB   ERR_LIB_BIO/* 32 */\n# define ERR_R_PKCS7_LIB ERR_LIB_PKCS7/* 33 */\n# define ERR_R_X509V3_LIB ERR_LIB_X509V3/* 34 */\n# define ERR_R_ENGINE_LIB ERR_LIB_ENGINE/* 38 */\n# define ERR_R_UI_LIB    ERR_LIB_UI/* 40 */\n# define ERR_R_ECDSA_LIB ERR_LIB_ECDSA/* 42 */\n# define ERR_R_OSSL_STORE_LIB ERR_LIB_OSSL_STORE/* 44 */\n\n# define ERR_R_NESTED_ASN1_ERROR                 58\n# define ERR_R_MISSING_ASN1_EOS                  63\n\n/* fatal error */\n# define ERR_R_FATAL                             64\n# define ERR_R_MALLOC_FAILURE                    (1|ERR_R_FATAL)\n# define ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED       (2|ERR_R_FATAL)\n# define ERR_R_PASSED_NULL_PARAMETER             (3|ERR_R_FATAL)\n# define ERR_R_INTERNAL_ERROR                    (4|ERR_R_FATAL)\n# define ERR_R_DISABLED                          (5|ERR_R_FATAL)\n# define ERR_R_INIT_FAIL                         (6|ERR_R_FATAL)\n# define ERR_R_PASSED_INVALID_ARGUMENT           (7)\n# define ERR_R_OPERATION_FAIL                    (8|ERR_R_FATAL)\n\n/*\n * 99 is the maximum possible ERR_R_... code, higher values are reserved for\n * the individual libraries\n */\n\ntypedef struct ERR_string_data_st {\n    unsigned long error;\n    const char *string;\n} ERR_STRING_DATA;\n\nDEFINE_LHASH_OF(ERR_STRING_DATA);\n\nvoid ERR_put_error(int lib, int func, int reason, const char *file, int line);\nvoid ERR_set_error_data(char *data, int flags);\n\nunsigned long ERR_get_error(void);\nunsigned long ERR_get_error_line(const char **file, int *line);\nunsigned long ERR_get_error_line_data(const char **file, int *line,\n                                      const char **data, int *flags);\nunsigned long ERR_peek_error(void);\nunsigned long ERR_peek_error_line(const char **file, int *line);\nunsigned long ERR_peek_error_line_data(const char **file, int *line,\n                                       const char **data, int *flags);\nunsigned long ERR_peek_last_error(void);\nunsigned long ERR_peek_last_error_line(const char **file, int *line);\nunsigned long ERR_peek_last_error_line_data(const char **file, int *line,\n                                            const char **data, int *flags);\nvoid ERR_clear_error(void);\nchar *ERR_error_string(unsigned long e, char *buf);\nvoid ERR_error_string_n(unsigned long e, char *buf, size_t len);\nconst char *ERR_lib_error_string(unsigned long e);\nconst char *ERR_func_error_string(unsigned long e);\nconst char *ERR_reason_error_string(unsigned long e);\nvoid ERR_print_errors_cb(int (*cb) (const char *str, size_t len, void *u),\n                         void *u);\n# ifndef OPENSSL_NO_STDIO\nvoid ERR_print_errors_fp(FILE *fp);\n# endif\nvoid ERR_print_errors(BIO *bp);\nvoid ERR_add_error_data(int num, ...);\nvoid ERR_add_error_vdata(int num, va_list args);\nint ERR_load_strings(int lib, ERR_STRING_DATA *str);\nint ERR_load_strings_const(const ERR_STRING_DATA *str);\nint ERR_unload_strings(int lib, ERR_STRING_DATA *str);\nint ERR_load_ERR_strings(void);\n\n#if OPENSSL_API_COMPAT < 0x10100000L\n# define ERR_load_crypto_strings() \\\n    OPENSSL_init_crypto(OPENSSL_INIT_LOAD_CRYPTO_STRINGS, NULL)\n# define ERR_free_strings() while(0) continue\n#endif\n\nDEPRECATEDIN_1_1_0(void ERR_remove_thread_state(void *))\nDEPRECATEDIN_1_0_0(void ERR_remove_state(unsigned long pid))\nERR_STATE *ERR_get_state(void);\n\nint ERR_get_next_error_library(void);\n\nint ERR_set_mark(void);\nint ERR_pop_to_mark(void);\nint ERR_clear_last_mark(void);\n\n#ifdef  __cplusplus\n}\n#endif\n\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/include/openssl/evp.h",
    "content": "/*\n * Copyright 1995-2019 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef HEADER_ENVELOPE_H\n# define HEADER_ENVELOPE_H\n\n# include <openssl/opensslconf.h>\n# include <openssl/ossl_typ.h>\n# include <openssl/symhacks.h>\n# include <openssl/bio.h>\n# include <openssl/evperr.h>\n\n# define EVP_MAX_MD_SIZE                 64/* longest known is SHA512 */\n# define EVP_MAX_KEY_LENGTH              64\n# define EVP_MAX_IV_LENGTH               16\n# define EVP_MAX_BLOCK_LENGTH            32\n\n# define PKCS5_SALT_LEN                  8\n/* Default PKCS#5 iteration count */\n# define PKCS5_DEFAULT_ITER              2048\n\n# include <openssl/objects.h>\n\n# define EVP_PK_RSA      0x0001\n# define EVP_PK_DSA      0x0002\n# define EVP_PK_DH       0x0004\n# define EVP_PK_EC       0x0008\n# define EVP_PKT_SIGN    0x0010\n# define EVP_PKT_ENC     0x0020\n# define EVP_PKT_EXCH    0x0040\n# define EVP_PKS_RSA     0x0100\n# define EVP_PKS_DSA     0x0200\n# define EVP_PKS_EC      0x0400\n\n# define EVP_PKEY_NONE   NID_undef\n# define EVP_PKEY_RSA    NID_rsaEncryption\n# define EVP_PKEY_RSA2   NID_rsa\n# define EVP_PKEY_RSA_PSS NID_rsassaPss\n# define EVP_PKEY_DSA    NID_dsa\n# define EVP_PKEY_DSA1   NID_dsa_2\n# define EVP_PKEY_DSA2   NID_dsaWithSHA\n# define EVP_PKEY_DSA3   NID_dsaWithSHA1\n# define EVP_PKEY_DSA4   NID_dsaWithSHA1_2\n# define EVP_PKEY_DH     NID_dhKeyAgreement\n# define EVP_PKEY_DHX    NID_dhpublicnumber\n# define EVP_PKEY_EC     NID_X9_62_id_ecPublicKey\n# define EVP_PKEY_SM2    NID_sm2\n# define EVP_PKEY_HMAC   NID_hmac\n# define EVP_PKEY_CMAC   NID_cmac\n# define EVP_PKEY_SCRYPT NID_id_scrypt\n# define EVP_PKEY_TLS1_PRF NID_tls1_prf\n# define EVP_PKEY_HKDF   NID_hkdf\n# define EVP_PKEY_POLY1305 NID_poly1305\n# define EVP_PKEY_SIPHASH NID_siphash\n# define EVP_PKEY_X25519 NID_X25519\n# define EVP_PKEY_ED25519 NID_ED25519\n# define EVP_PKEY_X448 NID_X448\n# define EVP_PKEY_ED448 NID_ED448\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n# define EVP_PKEY_MO_SIGN        0x0001\n# define EVP_PKEY_MO_VERIFY      0x0002\n# define EVP_PKEY_MO_ENCRYPT     0x0004\n# define EVP_PKEY_MO_DECRYPT     0x0008\n\n# ifndef EVP_MD\nEVP_MD *EVP_MD_meth_new(int md_type, int pkey_type);\nEVP_MD *EVP_MD_meth_dup(const EVP_MD *md);\nvoid EVP_MD_meth_free(EVP_MD *md);\n\nint EVP_MD_meth_set_input_blocksize(EVP_MD *md, int blocksize);\nint EVP_MD_meth_set_result_size(EVP_MD *md, int resultsize);\nint EVP_MD_meth_set_app_datasize(EVP_MD *md, int datasize);\nint EVP_MD_meth_set_flags(EVP_MD *md, unsigned long flags);\nint EVP_MD_meth_set_init(EVP_MD *md, int (*init)(EVP_MD_CTX *ctx));\nint EVP_MD_meth_set_update(EVP_MD *md, int (*update)(EVP_MD_CTX *ctx,\n                                                     const void *data,\n                                                     size_t count));\nint EVP_MD_meth_set_final(EVP_MD *md, int (*final)(EVP_MD_CTX *ctx,\n                                                   unsigned char *md));\nint EVP_MD_meth_set_copy(EVP_MD *md, int (*copy)(EVP_MD_CTX *to,\n                                                 const EVP_MD_CTX *from));\nint EVP_MD_meth_set_cleanup(EVP_MD *md, int (*cleanup)(EVP_MD_CTX *ctx));\nint EVP_MD_meth_set_ctrl(EVP_MD *md, int (*ctrl)(EVP_MD_CTX *ctx, int cmd,\n                                                 int p1, void *p2));\n\nint EVP_MD_meth_get_input_blocksize(const EVP_MD *md);\nint EVP_MD_meth_get_result_size(const EVP_MD *md);\nint EVP_MD_meth_get_app_datasize(const EVP_MD *md);\nunsigned long EVP_MD_meth_get_flags(const EVP_MD *md);\nint (*EVP_MD_meth_get_init(const EVP_MD *md))(EVP_MD_CTX *ctx);\nint (*EVP_MD_meth_get_update(const EVP_MD *md))(EVP_MD_CTX *ctx,\n                                                const void *data,\n                                                size_t count);\nint (*EVP_MD_meth_get_final(const EVP_MD *md))(EVP_MD_CTX *ctx,\n                                               unsigned char *md);\nint (*EVP_MD_meth_get_copy(const EVP_MD *md))(EVP_MD_CTX *to,\n                                              const EVP_MD_CTX *from);\nint (*EVP_MD_meth_get_cleanup(const EVP_MD *md))(EVP_MD_CTX *ctx);\nint (*EVP_MD_meth_get_ctrl(const EVP_MD *md))(EVP_MD_CTX *ctx, int cmd,\n                                              int p1, void *p2);\n\n/* digest can only handle a single block */\n#  define EVP_MD_FLAG_ONESHOT     0x0001\n\n/* digest is extensible-output function, XOF */\n#  define EVP_MD_FLAG_XOF         0x0002\n\n/* DigestAlgorithmIdentifier flags... */\n\n#  define EVP_MD_FLAG_DIGALGID_MASK               0x0018\n\n/* NULL or absent parameter accepted. Use NULL */\n\n#  define EVP_MD_FLAG_DIGALGID_NULL               0x0000\n\n/* NULL or absent parameter accepted. Use NULL for PKCS#1 otherwise absent */\n\n#  define EVP_MD_FLAG_DIGALGID_ABSENT             0x0008\n\n/* Custom handling via ctrl */\n\n#  define EVP_MD_FLAG_DIGALGID_CUSTOM             0x0018\n\n/* Note if suitable for use in FIPS mode */\n#  define EVP_MD_FLAG_FIPS        0x0400\n\n/* Digest ctrls */\n\n#  define EVP_MD_CTRL_DIGALGID                    0x1\n#  define EVP_MD_CTRL_MICALG                      0x2\n#  define EVP_MD_CTRL_XOF_LEN                     0x3\n\n/* Minimum Algorithm specific ctrl value */\n\n#  define EVP_MD_CTRL_ALG_CTRL                    0x1000\n\n# endif                         /* !EVP_MD */\n\n/* values for EVP_MD_CTX flags */\n\n# define EVP_MD_CTX_FLAG_ONESHOT         0x0001/* digest update will be\n                                                * called once only */\n# define EVP_MD_CTX_FLAG_CLEANED         0x0002/* context has already been\n                                                * cleaned */\n# define EVP_MD_CTX_FLAG_REUSE           0x0004/* Don't free up ctx->md_data\n                                                * in EVP_MD_CTX_reset */\n/*\n * FIPS and pad options are ignored in 1.0.0, definitions are here so we\n * don't accidentally reuse the values for other purposes.\n */\n\n# define EVP_MD_CTX_FLAG_NON_FIPS_ALLOW  0x0008/* Allow use of non FIPS\n                                                * digest in FIPS mode */\n\n/*\n * The following PAD options are also currently ignored in 1.0.0, digest\n * parameters are handled through EVP_DigestSign*() and EVP_DigestVerify*()\n * instead.\n */\n# define EVP_MD_CTX_FLAG_PAD_MASK        0xF0/* RSA mode to use */\n# define EVP_MD_CTX_FLAG_PAD_PKCS1       0x00/* PKCS#1 v1.5 mode */\n# define EVP_MD_CTX_FLAG_PAD_X931        0x10/* X9.31 mode */\n# define EVP_MD_CTX_FLAG_PAD_PSS         0x20/* PSS mode */\n\n# define EVP_MD_CTX_FLAG_NO_INIT         0x0100/* Don't initialize md_data */\n/*\n * Some functions such as EVP_DigestSign only finalise copies of internal\n * contexts so additional data can be included after the finalisation call.\n * This is inefficient if this functionality is not required: it is disabled\n * if the following flag is set.\n */\n# define EVP_MD_CTX_FLAG_FINALISE        0x0200\n/* NOTE: 0x0400 is reserved for internal usage */\n\nEVP_CIPHER *EVP_CIPHER_meth_new(int cipher_type, int block_size, int key_len);\nEVP_CIPHER *EVP_CIPHER_meth_dup(const EVP_CIPHER *cipher);\nvoid EVP_CIPHER_meth_free(EVP_CIPHER *cipher);\n\nint EVP_CIPHER_meth_set_iv_length(EVP_CIPHER *cipher, int iv_len);\nint EVP_CIPHER_meth_set_flags(EVP_CIPHER *cipher, unsigned long flags);\nint EVP_CIPHER_meth_set_impl_ctx_size(EVP_CIPHER *cipher, int ctx_size);\nint EVP_CIPHER_meth_set_init(EVP_CIPHER *cipher,\n                             int (*init) (EVP_CIPHER_CTX *ctx,\n                                          const unsigned char *key,\n                                          const unsigned char *iv,\n                                          int enc));\nint EVP_CIPHER_meth_set_do_cipher(EVP_CIPHER *cipher,\n                                  int (*do_cipher) (EVP_CIPHER_CTX *ctx,\n                                                    unsigned char *out,\n                                                    const unsigned char *in,\n                                                    size_t inl));\nint EVP_CIPHER_meth_set_cleanup(EVP_CIPHER *cipher,\n                                int (*cleanup) (EVP_CIPHER_CTX *));\nint EVP_CIPHER_meth_set_set_asn1_params(EVP_CIPHER *cipher,\n                                        int (*set_asn1_parameters) (EVP_CIPHER_CTX *,\n                                                                    ASN1_TYPE *));\nint EVP_CIPHER_meth_set_get_asn1_params(EVP_CIPHER *cipher,\n                                        int (*get_asn1_parameters) (EVP_CIPHER_CTX *,\n                                                                    ASN1_TYPE *));\nint EVP_CIPHER_meth_set_ctrl(EVP_CIPHER *cipher,\n                             int (*ctrl) (EVP_CIPHER_CTX *, int type,\n                                          int arg, void *ptr));\n\nint (*EVP_CIPHER_meth_get_init(const EVP_CIPHER *cipher))(EVP_CIPHER_CTX *ctx,\n                                                          const unsigned char *key,\n                                                          const unsigned char *iv,\n                                                          int enc);\nint (*EVP_CIPHER_meth_get_do_cipher(const EVP_CIPHER *cipher))(EVP_CIPHER_CTX *ctx,\n                                                               unsigned char *out,\n                                                               const unsigned char *in,\n                                                               size_t inl);\nint (*EVP_CIPHER_meth_get_cleanup(const EVP_CIPHER *cipher))(EVP_CIPHER_CTX *);\nint (*EVP_CIPHER_meth_get_set_asn1_params(const EVP_CIPHER *cipher))(EVP_CIPHER_CTX *,\n                                                                     ASN1_TYPE *);\nint (*EVP_CIPHER_meth_get_get_asn1_params(const EVP_CIPHER *cipher))(EVP_CIPHER_CTX *,\n                                                               ASN1_TYPE *);\nint (*EVP_CIPHER_meth_get_ctrl(const EVP_CIPHER *cipher))(EVP_CIPHER_CTX *,\n                                                          int type, int arg,\n                                                          void *ptr);\n\n/* Values for cipher flags */\n\n/* Modes for ciphers */\n\n# define         EVP_CIPH_STREAM_CIPHER          0x0\n# define         EVP_CIPH_ECB_MODE               0x1\n# define         EVP_CIPH_CBC_MODE               0x2\n# define         EVP_CIPH_CFB_MODE               0x3\n# define         EVP_CIPH_OFB_MODE               0x4\n# define         EVP_CIPH_CTR_MODE               0x5\n# define         EVP_CIPH_GCM_MODE               0x6\n# define         EVP_CIPH_CCM_MODE               0x7\n# define         EVP_CIPH_XTS_MODE               0x10001\n# define         EVP_CIPH_WRAP_MODE              0x10002\n# define         EVP_CIPH_OCB_MODE               0x10003\n# define         EVP_CIPH_MODE                   0xF0007\n/* Set if variable length cipher */\n# define         EVP_CIPH_VARIABLE_LENGTH        0x8\n/* Set if the iv handling should be done by the cipher itself */\n# define         EVP_CIPH_CUSTOM_IV              0x10\n/* Set if the cipher's init() function should be called if key is NULL */\n# define         EVP_CIPH_ALWAYS_CALL_INIT       0x20\n/* Call ctrl() to init cipher parameters */\n# define         EVP_CIPH_CTRL_INIT              0x40\n/* Don't use standard key length function */\n# define         EVP_CIPH_CUSTOM_KEY_LENGTH      0x80\n/* Don't use standard block padding */\n# define         EVP_CIPH_NO_PADDING             0x100\n/* cipher handles random key generation */\n# define         EVP_CIPH_RAND_KEY               0x200\n/* cipher has its own additional copying logic */\n# define         EVP_CIPH_CUSTOM_COPY            0x400\n/* Don't use standard iv length function */\n# define         EVP_CIPH_CUSTOM_IV_LENGTH       0x800\n/* Allow use default ASN1 get/set iv */\n# define         EVP_CIPH_FLAG_DEFAULT_ASN1      0x1000\n/* Buffer length in bits not bytes: CFB1 mode only */\n# define         EVP_CIPH_FLAG_LENGTH_BITS       0x2000\n/* Note if suitable for use in FIPS mode */\n# define         EVP_CIPH_FLAG_FIPS              0x4000\n/* Allow non FIPS cipher in FIPS mode */\n# define         EVP_CIPH_FLAG_NON_FIPS_ALLOW    0x8000\n/*\n * Cipher handles any and all padding logic as well as finalisation.\n */\n# define         EVP_CIPH_FLAG_CUSTOM_CIPHER     0x100000\n# define         EVP_CIPH_FLAG_AEAD_CIPHER       0x200000\n# define         EVP_CIPH_FLAG_TLS1_1_MULTIBLOCK 0x400000\n/* Cipher can handle pipeline operations */\n# define         EVP_CIPH_FLAG_PIPELINE          0X800000\n\n/*\n * Cipher context flag to indicate we can handle wrap mode: if allowed in\n * older applications it could overflow buffers.\n */\n\n# define         EVP_CIPHER_CTX_FLAG_WRAP_ALLOW  0x1\n\n/* ctrl() values */\n\n# define         EVP_CTRL_INIT                   0x0\n# define         EVP_CTRL_SET_KEY_LENGTH         0x1\n# define         EVP_CTRL_GET_RC2_KEY_BITS       0x2\n# define         EVP_CTRL_SET_RC2_KEY_BITS       0x3\n# define         EVP_CTRL_GET_RC5_ROUNDS         0x4\n# define         EVP_CTRL_SET_RC5_ROUNDS         0x5\n# define         EVP_CTRL_RAND_KEY               0x6\n# define         EVP_CTRL_PBE_PRF_NID            0x7\n# define         EVP_CTRL_COPY                   0x8\n# define         EVP_CTRL_AEAD_SET_IVLEN         0x9\n# define         EVP_CTRL_AEAD_GET_TAG           0x10\n# define         EVP_CTRL_AEAD_SET_TAG           0x11\n# define         EVP_CTRL_AEAD_SET_IV_FIXED      0x12\n# define         EVP_CTRL_GCM_SET_IVLEN          EVP_CTRL_AEAD_SET_IVLEN\n# define         EVP_CTRL_GCM_GET_TAG            EVP_CTRL_AEAD_GET_TAG\n# define         EVP_CTRL_GCM_SET_TAG            EVP_CTRL_AEAD_SET_TAG\n# define         EVP_CTRL_GCM_SET_IV_FIXED       EVP_CTRL_AEAD_SET_IV_FIXED\n# define         EVP_CTRL_GCM_IV_GEN             0x13\n# define         EVP_CTRL_CCM_SET_IVLEN          EVP_CTRL_AEAD_SET_IVLEN\n# define         EVP_CTRL_CCM_GET_TAG            EVP_CTRL_AEAD_GET_TAG\n# define         EVP_CTRL_CCM_SET_TAG            EVP_CTRL_AEAD_SET_TAG\n# define         EVP_CTRL_CCM_SET_IV_FIXED       EVP_CTRL_AEAD_SET_IV_FIXED\n# define         EVP_CTRL_CCM_SET_L              0x14\n# define         EVP_CTRL_CCM_SET_MSGLEN         0x15\n/*\n * AEAD cipher deduces payload length and returns number of bytes required to\n * store MAC and eventual padding. Subsequent call to EVP_Cipher even\n * appends/verifies MAC.\n */\n# define         EVP_CTRL_AEAD_TLS1_AAD          0x16\n/* Used by composite AEAD ciphers, no-op in GCM, CCM... */\n# define         EVP_CTRL_AEAD_SET_MAC_KEY       0x17\n/* Set the GCM invocation field, decrypt only */\n# define         EVP_CTRL_GCM_SET_IV_INV         0x18\n\n# define         EVP_CTRL_TLS1_1_MULTIBLOCK_AAD  0x19\n# define         EVP_CTRL_TLS1_1_MULTIBLOCK_ENCRYPT      0x1a\n# define         EVP_CTRL_TLS1_1_MULTIBLOCK_DECRYPT      0x1b\n# define         EVP_CTRL_TLS1_1_MULTIBLOCK_MAX_BUFSIZE  0x1c\n\n# define         EVP_CTRL_SSL3_MASTER_SECRET             0x1d\n\n/* EVP_CTRL_SET_SBOX takes the char * specifying S-boxes */\n# define         EVP_CTRL_SET_SBOX                       0x1e\n/*\n * EVP_CTRL_SBOX_USED takes a 'size_t' and 'char *', pointing at a\n * pre-allocated buffer with specified size\n */\n# define         EVP_CTRL_SBOX_USED                      0x1f\n/* EVP_CTRL_KEY_MESH takes 'size_t' number of bytes to mesh the key after,\n * 0 switches meshing off\n */\n# define         EVP_CTRL_KEY_MESH                       0x20\n/* EVP_CTRL_BLOCK_PADDING_MODE takes the padding mode */\n# define         EVP_CTRL_BLOCK_PADDING_MODE             0x21\n\n/* Set the output buffers to use for a pipelined operation */\n# define         EVP_CTRL_SET_PIPELINE_OUTPUT_BUFS       0x22\n/* Set the input buffers to use for a pipelined operation */\n# define         EVP_CTRL_SET_PIPELINE_INPUT_BUFS        0x23\n/* Set the input buffer lengths to use for a pipelined operation */\n# define         EVP_CTRL_SET_PIPELINE_INPUT_LENS        0x24\n\n# define         EVP_CTRL_GET_IVLEN                      0x25\n\n/* Padding modes */\n#define EVP_PADDING_PKCS7       1\n#define EVP_PADDING_ISO7816_4   2\n#define EVP_PADDING_ANSI923     3\n#define EVP_PADDING_ISO10126    4\n#define EVP_PADDING_ZERO        5\n\n/* RFC 5246 defines additional data to be 13 bytes in length */\n# define         EVP_AEAD_TLS1_AAD_LEN           13\n\ntypedef struct {\n    unsigned char *out;\n    const unsigned char *inp;\n    size_t len;\n    unsigned int interleave;\n} EVP_CTRL_TLS1_1_MULTIBLOCK_PARAM;\n\n/* GCM TLS constants */\n/* Length of fixed part of IV derived from PRF */\n# define EVP_GCM_TLS_FIXED_IV_LEN                        4\n/* Length of explicit part of IV part of TLS records */\n# define EVP_GCM_TLS_EXPLICIT_IV_LEN                     8\n/* Length of tag for TLS */\n# define EVP_GCM_TLS_TAG_LEN                             16\n\n/* CCM TLS constants */\n/* Length of fixed part of IV derived from PRF */\n# define EVP_CCM_TLS_FIXED_IV_LEN                        4\n/* Length of explicit part of IV part of TLS records */\n# define EVP_CCM_TLS_EXPLICIT_IV_LEN                     8\n/* Total length of CCM IV length for TLS */\n# define EVP_CCM_TLS_IV_LEN                              12\n/* Length of tag for TLS */\n# define EVP_CCM_TLS_TAG_LEN                             16\n/* Length of CCM8 tag for TLS */\n# define EVP_CCM8_TLS_TAG_LEN                            8\n\n/* Length of tag for TLS */\n# define EVP_CHACHAPOLY_TLS_TAG_LEN                      16\n\ntypedef struct evp_cipher_info_st {\n    const EVP_CIPHER *cipher;\n    unsigned char iv[EVP_MAX_IV_LENGTH];\n} EVP_CIPHER_INFO;\n\n\n/* Password based encryption function */\ntypedef int (EVP_PBE_KEYGEN) (EVP_CIPHER_CTX *ctx, const char *pass,\n                              int passlen, ASN1_TYPE *param,\n                              const EVP_CIPHER *cipher, const EVP_MD *md,\n                              int en_de);\n\n# ifndef OPENSSL_NO_RSA\n#  define EVP_PKEY_assign_RSA(pkey,rsa) EVP_PKEY_assign((pkey),EVP_PKEY_RSA,\\\n                                        (char *)(rsa))\n# endif\n\n# ifndef OPENSSL_NO_DSA\n#  define EVP_PKEY_assign_DSA(pkey,dsa) EVP_PKEY_assign((pkey),EVP_PKEY_DSA,\\\n                                        (char *)(dsa))\n# endif\n\n# ifndef OPENSSL_NO_DH\n#  define EVP_PKEY_assign_DH(pkey,dh) EVP_PKEY_assign((pkey),EVP_PKEY_DH,\\\n                                        (char *)(dh))\n# endif\n\n# ifndef OPENSSL_NO_EC\n#  define EVP_PKEY_assign_EC_KEY(pkey,eckey) EVP_PKEY_assign((pkey),EVP_PKEY_EC,\\\n                                        (char *)(eckey))\n# endif\n# ifndef OPENSSL_NO_SIPHASH\n#  define EVP_PKEY_assign_SIPHASH(pkey,shkey) EVP_PKEY_assign((pkey),EVP_PKEY_SIPHASH,\\\n                                        (char *)(shkey))\n# endif\n\n# ifndef OPENSSL_NO_POLY1305\n#  define EVP_PKEY_assign_POLY1305(pkey,polykey) EVP_PKEY_assign((pkey),EVP_PKEY_POLY1305,\\\n                                        (char *)(polykey))\n# endif\n\n/* Add some extra combinations */\n# define EVP_get_digestbynid(a) EVP_get_digestbyname(OBJ_nid2sn(a))\n# define EVP_get_digestbyobj(a) EVP_get_digestbynid(OBJ_obj2nid(a))\n# define EVP_get_cipherbynid(a) EVP_get_cipherbyname(OBJ_nid2sn(a))\n# define EVP_get_cipherbyobj(a) EVP_get_cipherbynid(OBJ_obj2nid(a))\n\nint EVP_MD_type(const EVP_MD *md);\n# define EVP_MD_nid(e)                   EVP_MD_type(e)\n# define EVP_MD_name(e)                  OBJ_nid2sn(EVP_MD_nid(e))\nint EVP_MD_pkey_type(const EVP_MD *md);\nint EVP_MD_size(const EVP_MD *md);\nint EVP_MD_block_size(const EVP_MD *md);\nunsigned long EVP_MD_flags(const EVP_MD *md);\n\nconst EVP_MD *EVP_MD_CTX_md(const EVP_MD_CTX *ctx);\nint (*EVP_MD_CTX_update_fn(EVP_MD_CTX *ctx))(EVP_MD_CTX *ctx,\n                                             const void *data, size_t count);\nvoid EVP_MD_CTX_set_update_fn(EVP_MD_CTX *ctx,\n                              int (*update) (EVP_MD_CTX *ctx,\n                                             const void *data, size_t count));\n# define EVP_MD_CTX_size(e)              EVP_MD_size(EVP_MD_CTX_md(e))\n# define EVP_MD_CTX_block_size(e)        EVP_MD_block_size(EVP_MD_CTX_md(e))\n# define EVP_MD_CTX_type(e)              EVP_MD_type(EVP_MD_CTX_md(e))\nEVP_PKEY_CTX *EVP_MD_CTX_pkey_ctx(const EVP_MD_CTX *ctx);\nvoid EVP_MD_CTX_set_pkey_ctx(EVP_MD_CTX *ctx, EVP_PKEY_CTX *pctx);\nvoid *EVP_MD_CTX_md_data(const EVP_MD_CTX *ctx);\n\nint EVP_CIPHER_nid(const EVP_CIPHER *cipher);\n# define EVP_CIPHER_name(e)              OBJ_nid2sn(EVP_CIPHER_nid(e))\nint EVP_CIPHER_block_size(const EVP_CIPHER *cipher);\nint EVP_CIPHER_impl_ctx_size(const EVP_CIPHER *cipher);\nint EVP_CIPHER_key_length(const EVP_CIPHER *cipher);\nint EVP_CIPHER_iv_length(const EVP_CIPHER *cipher);\nunsigned long EVP_CIPHER_flags(const EVP_CIPHER *cipher);\n# define EVP_CIPHER_mode(e)              (EVP_CIPHER_flags(e) & EVP_CIPH_MODE)\n\nconst EVP_CIPHER *EVP_CIPHER_CTX_cipher(const EVP_CIPHER_CTX *ctx);\nint EVP_CIPHER_CTX_encrypting(const EVP_CIPHER_CTX *ctx);\nint EVP_CIPHER_CTX_nid(const EVP_CIPHER_CTX *ctx);\nint EVP_CIPHER_CTX_block_size(const EVP_CIPHER_CTX *ctx);\nint EVP_CIPHER_CTX_key_length(const EVP_CIPHER_CTX *ctx);\nint EVP_CIPHER_CTX_iv_length(const EVP_CIPHER_CTX *ctx);\nconst unsigned char *EVP_CIPHER_CTX_iv(const EVP_CIPHER_CTX *ctx);\nconst unsigned char *EVP_CIPHER_CTX_original_iv(const EVP_CIPHER_CTX *ctx);\nunsigned char *EVP_CIPHER_CTX_iv_noconst(EVP_CIPHER_CTX *ctx);\nunsigned char *EVP_CIPHER_CTX_buf_noconst(EVP_CIPHER_CTX *ctx);\nint EVP_CIPHER_CTX_num(const EVP_CIPHER_CTX *ctx);\nvoid EVP_CIPHER_CTX_set_num(EVP_CIPHER_CTX *ctx, int num);\nint EVP_CIPHER_CTX_copy(EVP_CIPHER_CTX *out, const EVP_CIPHER_CTX *in);\nvoid *EVP_CIPHER_CTX_get_app_data(const EVP_CIPHER_CTX *ctx);\nvoid EVP_CIPHER_CTX_set_app_data(EVP_CIPHER_CTX *ctx, void *data);\nvoid *EVP_CIPHER_CTX_get_cipher_data(const EVP_CIPHER_CTX *ctx);\nvoid *EVP_CIPHER_CTX_set_cipher_data(EVP_CIPHER_CTX *ctx, void *cipher_data);\n# define EVP_CIPHER_CTX_type(c)         EVP_CIPHER_type(EVP_CIPHER_CTX_cipher(c))\n# if OPENSSL_API_COMPAT < 0x10100000L\n#  define EVP_CIPHER_CTX_flags(c)       EVP_CIPHER_flags(EVP_CIPHER_CTX_cipher(c))\n# endif\n# define EVP_CIPHER_CTX_mode(c)         EVP_CIPHER_mode(EVP_CIPHER_CTX_cipher(c))\n\n# define EVP_ENCODE_LENGTH(l)    ((((l)+2)/3*4)+((l)/48+1)*2+80)\n# define EVP_DECODE_LENGTH(l)    (((l)+3)/4*3+80)\n\n# define EVP_SignInit_ex(a,b,c)          EVP_DigestInit_ex(a,b,c)\n# define EVP_SignInit(a,b)               EVP_DigestInit(a,b)\n# define EVP_SignUpdate(a,b,c)           EVP_DigestUpdate(a,b,c)\n# define EVP_VerifyInit_ex(a,b,c)        EVP_DigestInit_ex(a,b,c)\n# define EVP_VerifyInit(a,b)             EVP_DigestInit(a,b)\n# define EVP_VerifyUpdate(a,b,c)         EVP_DigestUpdate(a,b,c)\n# define EVP_OpenUpdate(a,b,c,d,e)       EVP_DecryptUpdate(a,b,c,d,e)\n# define EVP_SealUpdate(a,b,c,d,e)       EVP_EncryptUpdate(a,b,c,d,e)\n# define EVP_DigestSignUpdate(a,b,c)     EVP_DigestUpdate(a,b,c)\n# define EVP_DigestVerifyUpdate(a,b,c)   EVP_DigestUpdate(a,b,c)\n\n# ifdef CONST_STRICT\nvoid BIO_set_md(BIO *, const EVP_MD *md);\n# else\n#  define BIO_set_md(b,md)          BIO_ctrl(b,BIO_C_SET_MD,0,(char *)(md))\n# endif\n# define BIO_get_md(b,mdp)          BIO_ctrl(b,BIO_C_GET_MD,0,(char *)(mdp))\n# define BIO_get_md_ctx(b,mdcp)     BIO_ctrl(b,BIO_C_GET_MD_CTX,0, \\\n                                             (char *)(mdcp))\n# define BIO_set_md_ctx(b,mdcp)     BIO_ctrl(b,BIO_C_SET_MD_CTX,0, \\\n                                             (char *)(mdcp))\n# define BIO_get_cipher_status(b)   BIO_ctrl(b,BIO_C_GET_CIPHER_STATUS,0,NULL)\n# define BIO_get_cipher_ctx(b,c_pp) BIO_ctrl(b,BIO_C_GET_CIPHER_CTX,0, \\\n                                             (char *)(c_pp))\n\n/*__owur*/ int EVP_Cipher(EVP_CIPHER_CTX *c,\n                          unsigned char *out,\n                          const unsigned char *in, unsigned int inl);\n\n# define EVP_add_cipher_alias(n,alias) \\\n        OBJ_NAME_add((alias),OBJ_NAME_TYPE_CIPHER_METH|OBJ_NAME_ALIAS,(n))\n# define EVP_add_digest_alias(n,alias) \\\n        OBJ_NAME_add((alias),OBJ_NAME_TYPE_MD_METH|OBJ_NAME_ALIAS,(n))\n# define EVP_delete_cipher_alias(alias) \\\n        OBJ_NAME_remove(alias,OBJ_NAME_TYPE_CIPHER_METH|OBJ_NAME_ALIAS);\n# define EVP_delete_digest_alias(alias) \\\n        OBJ_NAME_remove(alias,OBJ_NAME_TYPE_MD_METH|OBJ_NAME_ALIAS);\n\nint EVP_MD_CTX_ctrl(EVP_MD_CTX *ctx, int cmd, int p1, void *p2);\nEVP_MD_CTX *EVP_MD_CTX_new(void);\nint EVP_MD_CTX_reset(EVP_MD_CTX *ctx);\nvoid EVP_MD_CTX_free(EVP_MD_CTX *ctx);\n# define EVP_MD_CTX_create()     EVP_MD_CTX_new()\n# define EVP_MD_CTX_init(ctx)    EVP_MD_CTX_reset((ctx))\n# define EVP_MD_CTX_destroy(ctx) EVP_MD_CTX_free((ctx))\n__owur int EVP_MD_CTX_copy_ex(EVP_MD_CTX *out, const EVP_MD_CTX *in);\nvoid EVP_MD_CTX_set_flags(EVP_MD_CTX *ctx, int flags);\nvoid EVP_MD_CTX_clear_flags(EVP_MD_CTX *ctx, int flags);\nint EVP_MD_CTX_test_flags(const EVP_MD_CTX *ctx, int flags);\n__owur int EVP_DigestInit_ex(EVP_MD_CTX *ctx, const EVP_MD *type,\n                                 ENGINE *impl);\n__owur int EVP_DigestUpdate(EVP_MD_CTX *ctx, const void *d,\n                                size_t cnt);\n__owur int EVP_DigestFinal_ex(EVP_MD_CTX *ctx, unsigned char *md,\n                                  unsigned int *s);\n__owur int EVP_Digest(const void *data, size_t count,\n                          unsigned char *md, unsigned int *size,\n                          const EVP_MD *type, ENGINE *impl);\n\n__owur int EVP_MD_CTX_copy(EVP_MD_CTX *out, const EVP_MD_CTX *in);\n__owur int EVP_DigestInit(EVP_MD_CTX *ctx, const EVP_MD *type);\n__owur int EVP_DigestFinal(EVP_MD_CTX *ctx, unsigned char *md,\n                           unsigned int *s);\n__owur int EVP_DigestFinalXOF(EVP_MD_CTX *ctx, unsigned char *md,\n                              size_t len);\n\nint EVP_read_pw_string(char *buf, int length, const char *prompt, int verify);\nint EVP_read_pw_string_min(char *buf, int minlen, int maxlen,\n                           const char *prompt, int verify);\nvoid EVP_set_pw_prompt(const char *prompt);\nchar *EVP_get_pw_prompt(void);\n\n__owur int EVP_BytesToKey(const EVP_CIPHER *type, const EVP_MD *md,\n                          const unsigned char *salt,\n                          const unsigned char *data, int datal, int count,\n                          unsigned char *key, unsigned char *iv);\n\nvoid EVP_CIPHER_CTX_set_flags(EVP_CIPHER_CTX *ctx, int flags);\nvoid EVP_CIPHER_CTX_clear_flags(EVP_CIPHER_CTX *ctx, int flags);\nint EVP_CIPHER_CTX_test_flags(const EVP_CIPHER_CTX *ctx, int flags);\n\n__owur int EVP_EncryptInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher,\n                           const unsigned char *key, const unsigned char *iv);\n/*__owur*/ int EVP_EncryptInit_ex(EVP_CIPHER_CTX *ctx,\n                                  const EVP_CIPHER *cipher, ENGINE *impl,\n                                  const unsigned char *key,\n                                  const unsigned char *iv);\n/*__owur*/ int EVP_EncryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out,\n                                 int *outl, const unsigned char *in, int inl);\n/*__owur*/ int EVP_EncryptFinal_ex(EVP_CIPHER_CTX *ctx, unsigned char *out,\n                                   int *outl);\n/*__owur*/ int EVP_EncryptFinal(EVP_CIPHER_CTX *ctx, unsigned char *out,\n                                int *outl);\n\n__owur int EVP_DecryptInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher,\n                           const unsigned char *key, const unsigned char *iv);\n/*__owur*/ int EVP_DecryptInit_ex(EVP_CIPHER_CTX *ctx,\n                                  const EVP_CIPHER *cipher, ENGINE *impl,\n                                  const unsigned char *key,\n                                  const unsigned char *iv);\n/*__owur*/ int EVP_DecryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out,\n                                 int *outl, const unsigned char *in, int inl);\n__owur int EVP_DecryptFinal(EVP_CIPHER_CTX *ctx, unsigned char *outm,\n                            int *outl);\n/*__owur*/ int EVP_DecryptFinal_ex(EVP_CIPHER_CTX *ctx, unsigned char *outm,\n                                   int *outl);\n\n__owur int EVP_CipherInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher,\n                          const unsigned char *key, const unsigned char *iv,\n                          int enc);\n/*__owur*/ int EVP_CipherInit_ex(EVP_CIPHER_CTX *ctx,\n                                 const EVP_CIPHER *cipher, ENGINE *impl,\n                                 const unsigned char *key,\n                                 const unsigned char *iv, int enc);\n__owur int EVP_CipherUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out,\n                            int *outl, const unsigned char *in, int inl);\n__owur int EVP_CipherFinal(EVP_CIPHER_CTX *ctx, unsigned char *outm,\n                           int *outl);\n__owur int EVP_CipherFinal_ex(EVP_CIPHER_CTX *ctx, unsigned char *outm,\n                              int *outl);\n\n__owur int EVP_SignFinal(EVP_MD_CTX *ctx, unsigned char *md, unsigned int *s,\n                         EVP_PKEY *pkey);\n\n__owur int EVP_DigestSign(EVP_MD_CTX *ctx, unsigned char *sigret,\n                          size_t *siglen, const unsigned char *tbs,\n                          size_t tbslen);\n\n__owur int EVP_VerifyFinal(EVP_MD_CTX *ctx, const unsigned char *sigbuf,\n                           unsigned int siglen, EVP_PKEY *pkey);\n\n__owur int EVP_DigestVerify(EVP_MD_CTX *ctx, const unsigned char *sigret,\n                            size_t siglen, const unsigned char *tbs,\n                            size_t tbslen);\n\n/*__owur*/ int EVP_DigestSignInit(EVP_MD_CTX *ctx, EVP_PKEY_CTX **pctx,\n                                  const EVP_MD *type, ENGINE *e,\n                                  EVP_PKEY *pkey);\n__owur int EVP_DigestSignFinal(EVP_MD_CTX *ctx, unsigned char *sigret,\n                               size_t *siglen);\n\n__owur int EVP_DigestVerifyInit(EVP_MD_CTX *ctx, EVP_PKEY_CTX **pctx,\n                                const EVP_MD *type, ENGINE *e,\n                                EVP_PKEY *pkey);\n__owur int EVP_DigestVerifyFinal(EVP_MD_CTX *ctx, const unsigned char *sig,\n                                 size_t siglen);\n\n# ifndef OPENSSL_NO_RSA\n__owur int EVP_OpenInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *type,\n                        const unsigned char *ek, int ekl,\n                        const unsigned char *iv, EVP_PKEY *priv);\n__owur int EVP_OpenFinal(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl);\n\n__owur int EVP_SealInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *type,\n                        unsigned char **ek, int *ekl, unsigned char *iv,\n                        EVP_PKEY **pubk, int npubk);\n__owur int EVP_SealFinal(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl);\n# endif\n\nEVP_ENCODE_CTX *EVP_ENCODE_CTX_new(void);\nvoid EVP_ENCODE_CTX_free(EVP_ENCODE_CTX *ctx);\nint EVP_ENCODE_CTX_copy(EVP_ENCODE_CTX *dctx, EVP_ENCODE_CTX *sctx);\nint EVP_ENCODE_CTX_num(EVP_ENCODE_CTX *ctx);\nvoid EVP_EncodeInit(EVP_ENCODE_CTX *ctx);\nint EVP_EncodeUpdate(EVP_ENCODE_CTX *ctx, unsigned char *out, int *outl,\n                     const unsigned char *in, int inl);\nvoid EVP_EncodeFinal(EVP_ENCODE_CTX *ctx, unsigned char *out, int *outl);\nint EVP_EncodeBlock(unsigned char *t, const unsigned char *f, int n);\n\nvoid EVP_DecodeInit(EVP_ENCODE_CTX *ctx);\nint EVP_DecodeUpdate(EVP_ENCODE_CTX *ctx, unsigned char *out, int *outl,\n                     const unsigned char *in, int inl);\nint EVP_DecodeFinal(EVP_ENCODE_CTX *ctx, unsigned\n                    char *out, int *outl);\nint EVP_DecodeBlock(unsigned char *t, const unsigned char *f, int n);\n\n# if OPENSSL_API_COMPAT < 0x10100000L\n#  define EVP_CIPHER_CTX_init(c)      EVP_CIPHER_CTX_reset(c)\n#  define EVP_CIPHER_CTX_cleanup(c)   EVP_CIPHER_CTX_reset(c)\n# endif\nEVP_CIPHER_CTX *EVP_CIPHER_CTX_new(void);\nint EVP_CIPHER_CTX_reset(EVP_CIPHER_CTX *c);\nvoid EVP_CIPHER_CTX_free(EVP_CIPHER_CTX *c);\nint EVP_CIPHER_CTX_set_key_length(EVP_CIPHER_CTX *x, int keylen);\nint EVP_CIPHER_CTX_set_padding(EVP_CIPHER_CTX *c, int pad);\nint EVP_CIPHER_CTX_ctrl(EVP_CIPHER_CTX *ctx, int type, int arg, void *ptr);\nint EVP_CIPHER_CTX_rand_key(EVP_CIPHER_CTX *ctx, unsigned char *key);\n\nconst BIO_METHOD *BIO_f_md(void);\nconst BIO_METHOD *BIO_f_base64(void);\nconst BIO_METHOD *BIO_f_cipher(void);\nconst BIO_METHOD *BIO_f_reliable(void);\n__owur int BIO_set_cipher(BIO *b, const EVP_CIPHER *c, const unsigned char *k,\n                          const unsigned char *i, int enc);\n\nconst EVP_MD *EVP_md_null(void);\n# ifndef OPENSSL_NO_MD2\nconst EVP_MD *EVP_md2(void);\n# endif\n# ifndef OPENSSL_NO_MD4\nconst EVP_MD *EVP_md4(void);\n# endif\n# ifndef OPENSSL_NO_MD5\nconst EVP_MD *EVP_md5(void);\nconst EVP_MD *EVP_md5_sha1(void);\n# endif\n# ifndef OPENSSL_NO_BLAKE2\nconst EVP_MD *EVP_blake2b512(void);\nconst EVP_MD *EVP_blake2s256(void);\n# endif\nconst EVP_MD *EVP_sha1(void);\nconst EVP_MD *EVP_sha224(void);\nconst EVP_MD *EVP_sha256(void);\nconst EVP_MD *EVP_sha384(void);\nconst EVP_MD *EVP_sha512(void);\nconst EVP_MD *EVP_sha512_224(void);\nconst EVP_MD *EVP_sha512_256(void);\nconst EVP_MD *EVP_sha3_224(void);\nconst EVP_MD *EVP_sha3_256(void);\nconst EVP_MD *EVP_sha3_384(void);\nconst EVP_MD *EVP_sha3_512(void);\nconst EVP_MD *EVP_shake128(void);\nconst EVP_MD *EVP_shake256(void);\n# ifndef OPENSSL_NO_MDC2\nconst EVP_MD *EVP_mdc2(void);\n# endif\n# ifndef OPENSSL_NO_RMD160\nconst EVP_MD *EVP_ripemd160(void);\n# endif\n# ifndef OPENSSL_NO_WHIRLPOOL\nconst EVP_MD *EVP_whirlpool(void);\n# endif\n# ifndef OPENSSL_NO_SM3\nconst EVP_MD *EVP_sm3(void);\n# endif\nconst EVP_CIPHER *EVP_enc_null(void); /* does nothing :-) */\n# ifndef OPENSSL_NO_DES\nconst EVP_CIPHER *EVP_des_ecb(void);\nconst EVP_CIPHER *EVP_des_ede(void);\nconst EVP_CIPHER *EVP_des_ede3(void);\nconst EVP_CIPHER *EVP_des_ede_ecb(void);\nconst EVP_CIPHER *EVP_des_ede3_ecb(void);\nconst EVP_CIPHER *EVP_des_cfb64(void);\n#  define EVP_des_cfb EVP_des_cfb64\nconst EVP_CIPHER *EVP_des_cfb1(void);\nconst EVP_CIPHER *EVP_des_cfb8(void);\nconst EVP_CIPHER *EVP_des_ede_cfb64(void);\n#  define EVP_des_ede_cfb EVP_des_ede_cfb64\nconst EVP_CIPHER *EVP_des_ede3_cfb64(void);\n#  define EVP_des_ede3_cfb EVP_des_ede3_cfb64\nconst EVP_CIPHER *EVP_des_ede3_cfb1(void);\nconst EVP_CIPHER *EVP_des_ede3_cfb8(void);\nconst EVP_CIPHER *EVP_des_ofb(void);\nconst EVP_CIPHER *EVP_des_ede_ofb(void);\nconst EVP_CIPHER *EVP_des_ede3_ofb(void);\nconst EVP_CIPHER *EVP_des_cbc(void);\nconst EVP_CIPHER *EVP_des_ede_cbc(void);\nconst EVP_CIPHER *EVP_des_ede3_cbc(void);\nconst EVP_CIPHER *EVP_desx_cbc(void);\nconst EVP_CIPHER *EVP_des_ede3_wrap(void);\n/*\n * This should now be supported through the dev_crypto ENGINE. But also, why\n * are rc4 and md5 declarations made here inside a \"NO_DES\" precompiler\n * branch?\n */\n# endif\n# ifndef OPENSSL_NO_RC4\nconst EVP_CIPHER *EVP_rc4(void);\nconst EVP_CIPHER *EVP_rc4_40(void);\n#  ifndef OPENSSL_NO_MD5\nconst EVP_CIPHER *EVP_rc4_hmac_md5(void);\n#  endif\n# endif\n# ifndef OPENSSL_NO_IDEA\nconst EVP_CIPHER *EVP_idea_ecb(void);\nconst EVP_CIPHER *EVP_idea_cfb64(void);\n#  define EVP_idea_cfb EVP_idea_cfb64\nconst EVP_CIPHER *EVP_idea_ofb(void);\nconst EVP_CIPHER *EVP_idea_cbc(void);\n# endif\n# ifndef OPENSSL_NO_RC2\nconst EVP_CIPHER *EVP_rc2_ecb(void);\nconst EVP_CIPHER *EVP_rc2_cbc(void);\nconst EVP_CIPHER *EVP_rc2_40_cbc(void);\nconst EVP_CIPHER *EVP_rc2_64_cbc(void);\nconst EVP_CIPHER *EVP_rc2_cfb64(void);\n#  define EVP_rc2_cfb EVP_rc2_cfb64\nconst EVP_CIPHER *EVP_rc2_ofb(void);\n# endif\n# ifndef OPENSSL_NO_BF\nconst EVP_CIPHER *EVP_bf_ecb(void);\nconst EVP_CIPHER *EVP_bf_cbc(void);\nconst EVP_CIPHER *EVP_bf_cfb64(void);\n#  define EVP_bf_cfb EVP_bf_cfb64\nconst EVP_CIPHER *EVP_bf_ofb(void);\n# endif\n# ifndef OPENSSL_NO_CAST\nconst EVP_CIPHER *EVP_cast5_ecb(void);\nconst EVP_CIPHER *EVP_cast5_cbc(void);\nconst EVP_CIPHER *EVP_cast5_cfb64(void);\n#  define EVP_cast5_cfb EVP_cast5_cfb64\nconst EVP_CIPHER *EVP_cast5_ofb(void);\n# endif\n# ifndef OPENSSL_NO_RC5\nconst EVP_CIPHER *EVP_rc5_32_12_16_cbc(void);\nconst EVP_CIPHER *EVP_rc5_32_12_16_ecb(void);\nconst EVP_CIPHER *EVP_rc5_32_12_16_cfb64(void);\n#  define EVP_rc5_32_12_16_cfb EVP_rc5_32_12_16_cfb64\nconst EVP_CIPHER *EVP_rc5_32_12_16_ofb(void);\n# endif\nconst EVP_CIPHER *EVP_aes_128_ecb(void);\nconst EVP_CIPHER *EVP_aes_128_cbc(void);\nconst EVP_CIPHER *EVP_aes_128_cfb1(void);\nconst EVP_CIPHER *EVP_aes_128_cfb8(void);\nconst EVP_CIPHER *EVP_aes_128_cfb128(void);\n# define EVP_aes_128_cfb EVP_aes_128_cfb128\nconst EVP_CIPHER *EVP_aes_128_ofb(void);\nconst EVP_CIPHER *EVP_aes_128_ctr(void);\nconst EVP_CIPHER *EVP_aes_128_ccm(void);\nconst EVP_CIPHER *EVP_aes_128_gcm(void);\nconst EVP_CIPHER *EVP_aes_128_xts(void);\nconst EVP_CIPHER *EVP_aes_128_wrap(void);\nconst EVP_CIPHER *EVP_aes_128_wrap_pad(void);\n# ifndef OPENSSL_NO_OCB\nconst EVP_CIPHER *EVP_aes_128_ocb(void);\n# endif\nconst EVP_CIPHER *EVP_aes_192_ecb(void);\nconst EVP_CIPHER *EVP_aes_192_cbc(void);\nconst EVP_CIPHER *EVP_aes_192_cfb1(void);\nconst EVP_CIPHER *EVP_aes_192_cfb8(void);\nconst EVP_CIPHER *EVP_aes_192_cfb128(void);\n# define EVP_aes_192_cfb EVP_aes_192_cfb128\nconst EVP_CIPHER *EVP_aes_192_ofb(void);\nconst EVP_CIPHER *EVP_aes_192_ctr(void);\nconst EVP_CIPHER *EVP_aes_192_ccm(void);\nconst EVP_CIPHER *EVP_aes_192_gcm(void);\nconst EVP_CIPHER *EVP_aes_192_wrap(void);\nconst EVP_CIPHER *EVP_aes_192_wrap_pad(void);\n# ifndef OPENSSL_NO_OCB\nconst EVP_CIPHER *EVP_aes_192_ocb(void);\n# endif\nconst EVP_CIPHER *EVP_aes_256_ecb(void);\nconst EVP_CIPHER *EVP_aes_256_cbc(void);\nconst EVP_CIPHER *EVP_aes_256_cfb1(void);\nconst EVP_CIPHER *EVP_aes_256_cfb8(void);\nconst EVP_CIPHER *EVP_aes_256_cfb128(void);\n# define EVP_aes_256_cfb EVP_aes_256_cfb128\nconst EVP_CIPHER *EVP_aes_256_ofb(void);\nconst EVP_CIPHER *EVP_aes_256_ctr(void);\nconst EVP_CIPHER *EVP_aes_256_ccm(void);\nconst EVP_CIPHER *EVP_aes_256_gcm(void);\nconst EVP_CIPHER *EVP_aes_256_xts(void);\nconst EVP_CIPHER *EVP_aes_256_wrap(void);\nconst EVP_CIPHER *EVP_aes_256_wrap_pad(void);\n# ifndef OPENSSL_NO_OCB\nconst EVP_CIPHER *EVP_aes_256_ocb(void);\n# endif\nconst EVP_CIPHER *EVP_aes_128_cbc_hmac_sha1(void);\nconst EVP_CIPHER *EVP_aes_256_cbc_hmac_sha1(void);\nconst EVP_CIPHER *EVP_aes_128_cbc_hmac_sha256(void);\nconst EVP_CIPHER *EVP_aes_256_cbc_hmac_sha256(void);\n# ifndef OPENSSL_NO_ARIA\nconst EVP_CIPHER *EVP_aria_128_ecb(void);\nconst EVP_CIPHER *EVP_aria_128_cbc(void);\nconst EVP_CIPHER *EVP_aria_128_cfb1(void);\nconst EVP_CIPHER *EVP_aria_128_cfb8(void);\nconst EVP_CIPHER *EVP_aria_128_cfb128(void);\n#  define EVP_aria_128_cfb EVP_aria_128_cfb128\nconst EVP_CIPHER *EVP_aria_128_ctr(void);\nconst EVP_CIPHER *EVP_aria_128_ofb(void);\nconst EVP_CIPHER *EVP_aria_128_gcm(void);\nconst EVP_CIPHER *EVP_aria_128_ccm(void);\nconst EVP_CIPHER *EVP_aria_192_ecb(void);\nconst EVP_CIPHER *EVP_aria_192_cbc(void);\nconst EVP_CIPHER *EVP_aria_192_cfb1(void);\nconst EVP_CIPHER *EVP_aria_192_cfb8(void);\nconst EVP_CIPHER *EVP_aria_192_cfb128(void);\n#  define EVP_aria_192_cfb EVP_aria_192_cfb128\nconst EVP_CIPHER *EVP_aria_192_ctr(void);\nconst EVP_CIPHER *EVP_aria_192_ofb(void);\nconst EVP_CIPHER *EVP_aria_192_gcm(void);\nconst EVP_CIPHER *EVP_aria_192_ccm(void);\nconst EVP_CIPHER *EVP_aria_256_ecb(void);\nconst EVP_CIPHER *EVP_aria_256_cbc(void);\nconst EVP_CIPHER *EVP_aria_256_cfb1(void);\nconst EVP_CIPHER *EVP_aria_256_cfb8(void);\nconst EVP_CIPHER *EVP_aria_256_cfb128(void);\n#  define EVP_aria_256_cfb EVP_aria_256_cfb128\nconst EVP_CIPHER *EVP_aria_256_ctr(void);\nconst EVP_CIPHER *EVP_aria_256_ofb(void);\nconst EVP_CIPHER *EVP_aria_256_gcm(void);\nconst EVP_CIPHER *EVP_aria_256_ccm(void);\n# endif\n# ifndef OPENSSL_NO_CAMELLIA\nconst EVP_CIPHER *EVP_camellia_128_ecb(void);\nconst EVP_CIPHER *EVP_camellia_128_cbc(void);\nconst EVP_CIPHER *EVP_camellia_128_cfb1(void);\nconst EVP_CIPHER *EVP_camellia_128_cfb8(void);\nconst EVP_CIPHER *EVP_camellia_128_cfb128(void);\n#  define EVP_camellia_128_cfb EVP_camellia_128_cfb128\nconst EVP_CIPHER *EVP_camellia_128_ofb(void);\nconst EVP_CIPHER *EVP_camellia_128_ctr(void);\nconst EVP_CIPHER *EVP_camellia_192_ecb(void);\nconst EVP_CIPHER *EVP_camellia_192_cbc(void);\nconst EVP_CIPHER *EVP_camellia_192_cfb1(void);\nconst EVP_CIPHER *EVP_camellia_192_cfb8(void);\nconst EVP_CIPHER *EVP_camellia_192_cfb128(void);\n#  define EVP_camellia_192_cfb EVP_camellia_192_cfb128\nconst EVP_CIPHER *EVP_camellia_192_ofb(void);\nconst EVP_CIPHER *EVP_camellia_192_ctr(void);\nconst EVP_CIPHER *EVP_camellia_256_ecb(void);\nconst EVP_CIPHER *EVP_camellia_256_cbc(void);\nconst EVP_CIPHER *EVP_camellia_256_cfb1(void);\nconst EVP_CIPHER *EVP_camellia_256_cfb8(void);\nconst EVP_CIPHER *EVP_camellia_256_cfb128(void);\n#  define EVP_camellia_256_cfb EVP_camellia_256_cfb128\nconst EVP_CIPHER *EVP_camellia_256_ofb(void);\nconst EVP_CIPHER *EVP_camellia_256_ctr(void);\n# endif\n# ifndef OPENSSL_NO_CHACHA\nconst EVP_CIPHER *EVP_chacha20(void);\n#  ifndef OPENSSL_NO_POLY1305\nconst EVP_CIPHER *EVP_chacha20_poly1305(void);\n#  endif\n# endif\n\n# ifndef OPENSSL_NO_SEED\nconst EVP_CIPHER *EVP_seed_ecb(void);\nconst EVP_CIPHER *EVP_seed_cbc(void);\nconst EVP_CIPHER *EVP_seed_cfb128(void);\n#  define EVP_seed_cfb EVP_seed_cfb128\nconst EVP_CIPHER *EVP_seed_ofb(void);\n# endif\n\n# ifndef OPENSSL_NO_SM4\nconst EVP_CIPHER *EVP_sm4_ecb(void);\nconst EVP_CIPHER *EVP_sm4_cbc(void);\nconst EVP_CIPHER *EVP_sm4_cfb128(void);\n#  define EVP_sm4_cfb EVP_sm4_cfb128\nconst EVP_CIPHER *EVP_sm4_ofb(void);\nconst EVP_CIPHER *EVP_sm4_ctr(void);\n# endif\n\n# if OPENSSL_API_COMPAT < 0x10100000L\n#  define OPENSSL_add_all_algorithms_conf() \\\n    OPENSSL_init_crypto(OPENSSL_INIT_ADD_ALL_CIPHERS \\\n                        | OPENSSL_INIT_ADD_ALL_DIGESTS \\\n                        | OPENSSL_INIT_LOAD_CONFIG, NULL)\n#  define OPENSSL_add_all_algorithms_noconf() \\\n    OPENSSL_init_crypto(OPENSSL_INIT_ADD_ALL_CIPHERS \\\n                        | OPENSSL_INIT_ADD_ALL_DIGESTS, NULL)\n\n#  ifdef OPENSSL_LOAD_CONF\n#   define OpenSSL_add_all_algorithms() OPENSSL_add_all_algorithms_conf()\n#  else\n#   define OpenSSL_add_all_algorithms() OPENSSL_add_all_algorithms_noconf()\n#  endif\n\n#  define OpenSSL_add_all_ciphers() \\\n    OPENSSL_init_crypto(OPENSSL_INIT_ADD_ALL_CIPHERS, NULL)\n#  define OpenSSL_add_all_digests() \\\n    OPENSSL_init_crypto(OPENSSL_INIT_ADD_ALL_DIGESTS, NULL)\n\n#  define EVP_cleanup() while(0) continue\n# endif\n\nint EVP_add_cipher(const EVP_CIPHER *cipher);\nint EVP_add_digest(const EVP_MD *digest);\n\nconst EVP_CIPHER *EVP_get_cipherbyname(const char *name);\nconst EVP_MD *EVP_get_digestbyname(const char *name);\n\nvoid EVP_CIPHER_do_all(void (*fn) (const EVP_CIPHER *ciph,\n                                   const char *from, const char *to, void *x),\n                       void *arg);\nvoid EVP_CIPHER_do_all_sorted(void (*fn)\n                               (const EVP_CIPHER *ciph, const char *from,\n                                const char *to, void *x), void *arg);\n\nvoid EVP_MD_do_all(void (*fn) (const EVP_MD *ciph,\n                               const char *from, const char *to, void *x),\n                   void *arg);\nvoid EVP_MD_do_all_sorted(void (*fn)\n                           (const EVP_MD *ciph, const char *from,\n                            const char *to, void *x), void *arg);\n\nint EVP_PKEY_decrypt_old(unsigned char *dec_key,\n                         const unsigned char *enc_key, int enc_key_len,\n                         EVP_PKEY *private_key);\nint EVP_PKEY_encrypt_old(unsigned char *enc_key,\n                         const unsigned char *key, int key_len,\n                         EVP_PKEY *pub_key);\nint EVP_PKEY_type(int type);\nint EVP_PKEY_id(const EVP_PKEY *pkey);\nint EVP_PKEY_base_id(const EVP_PKEY *pkey);\nint EVP_PKEY_bits(const EVP_PKEY *pkey);\nint EVP_PKEY_security_bits(const EVP_PKEY *pkey);\nint EVP_PKEY_size(const EVP_PKEY *pkey);\nint EVP_PKEY_set_type(EVP_PKEY *pkey, int type);\nint EVP_PKEY_set_type_str(EVP_PKEY *pkey, const char *str, int len);\nint EVP_PKEY_set_alias_type(EVP_PKEY *pkey, int type);\n# ifndef OPENSSL_NO_ENGINE\nint EVP_PKEY_set1_engine(EVP_PKEY *pkey, ENGINE *e);\nENGINE *EVP_PKEY_get0_engine(const EVP_PKEY *pkey);\n# endif\nint EVP_PKEY_assign(EVP_PKEY *pkey, int type, void *key);\nvoid *EVP_PKEY_get0(const EVP_PKEY *pkey);\nconst unsigned char *EVP_PKEY_get0_hmac(const EVP_PKEY *pkey, size_t *len);\n# ifndef OPENSSL_NO_POLY1305\nconst unsigned char *EVP_PKEY_get0_poly1305(const EVP_PKEY *pkey, size_t *len);\n# endif\n# ifndef OPENSSL_NO_SIPHASH\nconst unsigned char *EVP_PKEY_get0_siphash(const EVP_PKEY *pkey, size_t *len);\n# endif\n\n# ifndef OPENSSL_NO_RSA\nstruct rsa_st;\nint EVP_PKEY_set1_RSA(EVP_PKEY *pkey, struct rsa_st *key);\nstruct rsa_st *EVP_PKEY_get0_RSA(EVP_PKEY *pkey);\nstruct rsa_st *EVP_PKEY_get1_RSA(EVP_PKEY *pkey);\n# endif\n# ifndef OPENSSL_NO_DSA\nstruct dsa_st;\nint EVP_PKEY_set1_DSA(EVP_PKEY *pkey, struct dsa_st *key);\nstruct dsa_st *EVP_PKEY_get0_DSA(EVP_PKEY *pkey);\nstruct dsa_st *EVP_PKEY_get1_DSA(EVP_PKEY *pkey);\n# endif\n# ifndef OPENSSL_NO_DH\nstruct dh_st;\nint EVP_PKEY_set1_DH(EVP_PKEY *pkey, struct dh_st *key);\nstruct dh_st *EVP_PKEY_get0_DH(EVP_PKEY *pkey);\nstruct dh_st *EVP_PKEY_get1_DH(EVP_PKEY *pkey);\n# endif\n# ifndef OPENSSL_NO_EC\nstruct ec_key_st;\nint EVP_PKEY_set1_EC_KEY(EVP_PKEY *pkey, struct ec_key_st *key);\nstruct ec_key_st *EVP_PKEY_get0_EC_KEY(EVP_PKEY *pkey);\nstruct ec_key_st *EVP_PKEY_get1_EC_KEY(EVP_PKEY *pkey);\n# endif\n\nEVP_PKEY *EVP_PKEY_new(void);\nint EVP_PKEY_up_ref(EVP_PKEY *pkey);\nvoid EVP_PKEY_free(EVP_PKEY *pkey);\n\nEVP_PKEY *d2i_PublicKey(int type, EVP_PKEY **a, const unsigned char **pp,\n                        long length);\nint i2d_PublicKey(EVP_PKEY *a, unsigned char **pp);\n\nEVP_PKEY *d2i_PrivateKey(int type, EVP_PKEY **a, const unsigned char **pp,\n                         long length);\nEVP_PKEY *d2i_AutoPrivateKey(EVP_PKEY **a, const unsigned char **pp,\n                             long length);\nint i2d_PrivateKey(EVP_PKEY *a, unsigned char **pp);\n\nint EVP_PKEY_copy_parameters(EVP_PKEY *to, const EVP_PKEY *from);\nint EVP_PKEY_missing_parameters(const EVP_PKEY *pkey);\nint EVP_PKEY_save_parameters(EVP_PKEY *pkey, int mode);\nint EVP_PKEY_cmp_parameters(const EVP_PKEY *a, const EVP_PKEY *b);\n\nint EVP_PKEY_cmp(const EVP_PKEY *a, const EVP_PKEY *b);\n\nint EVP_PKEY_print_public(BIO *out, const EVP_PKEY *pkey,\n                          int indent, ASN1_PCTX *pctx);\nint EVP_PKEY_print_private(BIO *out, const EVP_PKEY *pkey,\n                           int indent, ASN1_PCTX *pctx);\nint EVP_PKEY_print_params(BIO *out, const EVP_PKEY *pkey,\n                          int indent, ASN1_PCTX *pctx);\n\nint EVP_PKEY_get_default_digest_nid(EVP_PKEY *pkey, int *pnid);\n\nint EVP_PKEY_set1_tls_encodedpoint(EVP_PKEY *pkey,\n                                   const unsigned char *pt, size_t ptlen);\nsize_t EVP_PKEY_get1_tls_encodedpoint(EVP_PKEY *pkey, unsigned char **ppt);\n\nint EVP_CIPHER_type(const EVP_CIPHER *ctx);\n\n/* calls methods */\nint EVP_CIPHER_param_to_asn1(EVP_CIPHER_CTX *c, ASN1_TYPE *type);\nint EVP_CIPHER_asn1_to_param(EVP_CIPHER_CTX *c, ASN1_TYPE *type);\n\n/* These are used by EVP_CIPHER methods */\nint EVP_CIPHER_set_asn1_iv(EVP_CIPHER_CTX *c, ASN1_TYPE *type);\nint EVP_CIPHER_get_asn1_iv(EVP_CIPHER_CTX *c, ASN1_TYPE *type);\n\n/* PKCS5 password based encryption */\nint PKCS5_PBE_keyivgen(EVP_CIPHER_CTX *ctx, const char *pass, int passlen,\n                       ASN1_TYPE *param, const EVP_CIPHER *cipher,\n                       const EVP_MD *md, int en_de);\nint PKCS5_PBKDF2_HMAC_SHA1(const char *pass, int passlen,\n                           const unsigned char *salt, int saltlen, int iter,\n                           int keylen, unsigned char *out);\nint PKCS5_PBKDF2_HMAC(const char *pass, int passlen,\n                      const unsigned char *salt, int saltlen, int iter,\n                      const EVP_MD *digest, int keylen, unsigned char *out);\nint PKCS5_v2_PBE_keyivgen(EVP_CIPHER_CTX *ctx, const char *pass, int passlen,\n                          ASN1_TYPE *param, const EVP_CIPHER *cipher,\n                          const EVP_MD *md, int en_de);\n\n#ifndef OPENSSL_NO_SCRYPT\nint EVP_PBE_scrypt(const char *pass, size_t passlen,\n                   const unsigned char *salt, size_t saltlen,\n                   uint64_t N, uint64_t r, uint64_t p, uint64_t maxmem,\n                   unsigned char *key, size_t keylen);\n\nint PKCS5_v2_scrypt_keyivgen(EVP_CIPHER_CTX *ctx, const char *pass,\n                             int passlen, ASN1_TYPE *param,\n                             const EVP_CIPHER *c, const EVP_MD *md, int en_de);\n#endif\n\nvoid PKCS5_PBE_add(void);\n\nint EVP_PBE_CipherInit(ASN1_OBJECT *pbe_obj, const char *pass, int passlen,\n                       ASN1_TYPE *param, EVP_CIPHER_CTX *ctx, int en_de);\n\n/* PBE type */\n\n/* Can appear as the outermost AlgorithmIdentifier */\n# define EVP_PBE_TYPE_OUTER      0x0\n/* Is an PRF type OID */\n# define EVP_PBE_TYPE_PRF        0x1\n/* Is a PKCS#5 v2.0 KDF */\n# define EVP_PBE_TYPE_KDF        0x2\n\nint EVP_PBE_alg_add_type(int pbe_type, int pbe_nid, int cipher_nid,\n                         int md_nid, EVP_PBE_KEYGEN *keygen);\nint EVP_PBE_alg_add(int nid, const EVP_CIPHER *cipher, const EVP_MD *md,\n                    EVP_PBE_KEYGEN *keygen);\nint EVP_PBE_find(int type, int pbe_nid, int *pcnid, int *pmnid,\n                 EVP_PBE_KEYGEN **pkeygen);\nvoid EVP_PBE_cleanup(void);\nint EVP_PBE_get(int *ptype, int *ppbe_nid, size_t num);\n\n# define ASN1_PKEY_ALIAS         0x1\n# define ASN1_PKEY_DYNAMIC       0x2\n# define ASN1_PKEY_SIGPARAM_NULL 0x4\n\n# define ASN1_PKEY_CTRL_PKCS7_SIGN       0x1\n# define ASN1_PKEY_CTRL_PKCS7_ENCRYPT    0x2\n# define ASN1_PKEY_CTRL_DEFAULT_MD_NID   0x3\n# define ASN1_PKEY_CTRL_CMS_SIGN         0x5\n# define ASN1_PKEY_CTRL_CMS_ENVELOPE     0x7\n# define ASN1_PKEY_CTRL_CMS_RI_TYPE      0x8\n\n# define ASN1_PKEY_CTRL_SET1_TLS_ENCPT   0x9\n# define ASN1_PKEY_CTRL_GET1_TLS_ENCPT   0xa\n\nint EVP_PKEY_asn1_get_count(void);\nconst EVP_PKEY_ASN1_METHOD *EVP_PKEY_asn1_get0(int idx);\nconst EVP_PKEY_ASN1_METHOD *EVP_PKEY_asn1_find(ENGINE **pe, int type);\nconst EVP_PKEY_ASN1_METHOD *EVP_PKEY_asn1_find_str(ENGINE **pe,\n                                                   const char *str, int len);\nint EVP_PKEY_asn1_add0(const EVP_PKEY_ASN1_METHOD *ameth);\nint EVP_PKEY_asn1_add_alias(int to, int from);\nint EVP_PKEY_asn1_get0_info(int *ppkey_id, int *pkey_base_id,\n                            int *ppkey_flags, const char **pinfo,\n                            const char **ppem_str,\n                            const EVP_PKEY_ASN1_METHOD *ameth);\n\nconst EVP_PKEY_ASN1_METHOD *EVP_PKEY_get0_asn1(const EVP_PKEY *pkey);\nEVP_PKEY_ASN1_METHOD *EVP_PKEY_asn1_new(int id, int flags,\n                                        const char *pem_str,\n                                        const char *info);\nvoid EVP_PKEY_asn1_copy(EVP_PKEY_ASN1_METHOD *dst,\n                        const EVP_PKEY_ASN1_METHOD *src);\nvoid EVP_PKEY_asn1_free(EVP_PKEY_ASN1_METHOD *ameth);\nvoid EVP_PKEY_asn1_set_public(EVP_PKEY_ASN1_METHOD *ameth,\n                              int (*pub_decode) (EVP_PKEY *pk,\n                                                 X509_PUBKEY *pub),\n                              int (*pub_encode) (X509_PUBKEY *pub,\n                                                 const EVP_PKEY *pk),\n                              int (*pub_cmp) (const EVP_PKEY *a,\n                                              const EVP_PKEY *b),\n                              int (*pub_print) (BIO *out,\n                                                const EVP_PKEY *pkey,\n                                                int indent, ASN1_PCTX *pctx),\n                              int (*pkey_size) (const EVP_PKEY *pk),\n                              int (*pkey_bits) (const EVP_PKEY *pk));\nvoid EVP_PKEY_asn1_set_private(EVP_PKEY_ASN1_METHOD *ameth,\n                               int (*priv_decode) (EVP_PKEY *pk,\n                                                   const PKCS8_PRIV_KEY_INFO\n                                                   *p8inf),\n                               int (*priv_encode) (PKCS8_PRIV_KEY_INFO *p8,\n                                                   const EVP_PKEY *pk),\n                               int (*priv_print) (BIO *out,\n                                                  const EVP_PKEY *pkey,\n                                                  int indent,\n                                                  ASN1_PCTX *pctx));\nvoid EVP_PKEY_asn1_set_param(EVP_PKEY_ASN1_METHOD *ameth,\n                             int (*param_decode) (EVP_PKEY *pkey,\n                                                  const unsigned char **pder,\n                                                  int derlen),\n                             int (*param_encode) (const EVP_PKEY *pkey,\n                                                  unsigned char **pder),\n                             int (*param_missing) (const EVP_PKEY *pk),\n                             int (*param_copy) (EVP_PKEY *to,\n                                                const EVP_PKEY *from),\n                             int (*param_cmp) (const EVP_PKEY *a,\n                                               const EVP_PKEY *b),\n                             int (*param_print) (BIO *out,\n                                                 const EVP_PKEY *pkey,\n                                                 int indent,\n                                                 ASN1_PCTX *pctx));\n\nvoid EVP_PKEY_asn1_set_free(EVP_PKEY_ASN1_METHOD *ameth,\n                            void (*pkey_free) (EVP_PKEY *pkey));\nvoid EVP_PKEY_asn1_set_ctrl(EVP_PKEY_ASN1_METHOD *ameth,\n                            int (*pkey_ctrl) (EVP_PKEY *pkey, int op,\n                                              long arg1, void *arg2));\nvoid EVP_PKEY_asn1_set_item(EVP_PKEY_ASN1_METHOD *ameth,\n                            int (*item_verify) (EVP_MD_CTX *ctx,\n                                                const ASN1_ITEM *it,\n                                                void *asn,\n                                                X509_ALGOR *a,\n                                                ASN1_BIT_STRING *sig,\n                                                EVP_PKEY *pkey),\n                            int (*item_sign) (EVP_MD_CTX *ctx,\n                                              const ASN1_ITEM *it,\n                                              void *asn,\n                                              X509_ALGOR *alg1,\n                                              X509_ALGOR *alg2,\n                                              ASN1_BIT_STRING *sig));\n\nvoid EVP_PKEY_asn1_set_siginf(EVP_PKEY_ASN1_METHOD *ameth,\n                              int (*siginf_set) (X509_SIG_INFO *siginf,\n                                                 const X509_ALGOR *alg,\n                                                 const ASN1_STRING *sig));\n\nvoid EVP_PKEY_asn1_set_check(EVP_PKEY_ASN1_METHOD *ameth,\n                             int (*pkey_check) (const EVP_PKEY *pk));\n\nvoid EVP_PKEY_asn1_set_public_check(EVP_PKEY_ASN1_METHOD *ameth,\n                                    int (*pkey_pub_check) (const EVP_PKEY *pk));\n\nvoid EVP_PKEY_asn1_set_param_check(EVP_PKEY_ASN1_METHOD *ameth,\n                                   int (*pkey_param_check) (const EVP_PKEY *pk));\n\nvoid EVP_PKEY_asn1_set_set_priv_key(EVP_PKEY_ASN1_METHOD *ameth,\n                                    int (*set_priv_key) (EVP_PKEY *pk,\n                                                         const unsigned char\n                                                            *priv,\n                                                         size_t len));\nvoid EVP_PKEY_asn1_set_set_pub_key(EVP_PKEY_ASN1_METHOD *ameth,\n                                   int (*set_pub_key) (EVP_PKEY *pk,\n                                                       const unsigned char *pub,\n                                                       size_t len));\nvoid EVP_PKEY_asn1_set_get_priv_key(EVP_PKEY_ASN1_METHOD *ameth,\n                                    int (*get_priv_key) (const EVP_PKEY *pk,\n                                                         unsigned char *priv,\n                                                         size_t *len));\nvoid EVP_PKEY_asn1_set_get_pub_key(EVP_PKEY_ASN1_METHOD *ameth,\n                                   int (*get_pub_key) (const EVP_PKEY *pk,\n                                                       unsigned char *pub,\n                                                       size_t *len));\n\nvoid EVP_PKEY_asn1_set_security_bits(EVP_PKEY_ASN1_METHOD *ameth,\n                                     int (*pkey_security_bits) (const EVP_PKEY\n                                                                *pk));\n\n# define EVP_PKEY_OP_UNDEFINED           0\n# define EVP_PKEY_OP_PARAMGEN            (1<<1)\n# define EVP_PKEY_OP_KEYGEN              (1<<2)\n# define EVP_PKEY_OP_SIGN                (1<<3)\n# define EVP_PKEY_OP_VERIFY              (1<<4)\n# define EVP_PKEY_OP_VERIFYRECOVER       (1<<5)\n# define EVP_PKEY_OP_SIGNCTX             (1<<6)\n# define EVP_PKEY_OP_VERIFYCTX           (1<<7)\n# define EVP_PKEY_OP_ENCRYPT             (1<<8)\n# define EVP_PKEY_OP_DECRYPT             (1<<9)\n# define EVP_PKEY_OP_DERIVE              (1<<10)\n\n# define EVP_PKEY_OP_TYPE_SIG    \\\n        (EVP_PKEY_OP_SIGN | EVP_PKEY_OP_VERIFY | EVP_PKEY_OP_VERIFYRECOVER \\\n                | EVP_PKEY_OP_SIGNCTX | EVP_PKEY_OP_VERIFYCTX)\n\n# define EVP_PKEY_OP_TYPE_CRYPT \\\n        (EVP_PKEY_OP_ENCRYPT | EVP_PKEY_OP_DECRYPT)\n\n# define EVP_PKEY_OP_TYPE_NOGEN \\\n        (EVP_PKEY_OP_TYPE_SIG | EVP_PKEY_OP_TYPE_CRYPT | EVP_PKEY_OP_DERIVE)\n\n# define EVP_PKEY_OP_TYPE_GEN \\\n                (EVP_PKEY_OP_PARAMGEN | EVP_PKEY_OP_KEYGEN)\n\n# define  EVP_PKEY_CTX_set_signature_md(ctx, md) \\\n                EVP_PKEY_CTX_ctrl(ctx, -1, EVP_PKEY_OP_TYPE_SIG,  \\\n                                        EVP_PKEY_CTRL_MD, 0, (void *)(md))\n\n# define  EVP_PKEY_CTX_get_signature_md(ctx, pmd)        \\\n                EVP_PKEY_CTX_ctrl(ctx, -1, EVP_PKEY_OP_TYPE_SIG,  \\\n                                        EVP_PKEY_CTRL_GET_MD, 0, (void *)(pmd))\n\n# define  EVP_PKEY_CTX_set_mac_key(ctx, key, len)        \\\n                EVP_PKEY_CTX_ctrl(ctx, -1, EVP_PKEY_OP_KEYGEN,  \\\n                                  EVP_PKEY_CTRL_SET_MAC_KEY, len, (void *)(key))\n\n# define EVP_PKEY_CTRL_MD                1\n# define EVP_PKEY_CTRL_PEER_KEY          2\n\n# define EVP_PKEY_CTRL_PKCS7_ENCRYPT     3\n# define EVP_PKEY_CTRL_PKCS7_DECRYPT     4\n\n# define EVP_PKEY_CTRL_PKCS7_SIGN        5\n\n# define EVP_PKEY_CTRL_SET_MAC_KEY       6\n\n# define EVP_PKEY_CTRL_DIGESTINIT        7\n\n/* Used by GOST key encryption in TLS */\n# define EVP_PKEY_CTRL_SET_IV            8\n\n# define EVP_PKEY_CTRL_CMS_ENCRYPT       9\n# define EVP_PKEY_CTRL_CMS_DECRYPT       10\n# define EVP_PKEY_CTRL_CMS_SIGN          11\n\n# define EVP_PKEY_CTRL_CIPHER            12\n\n# define EVP_PKEY_CTRL_GET_MD            13\n\n# define EVP_PKEY_CTRL_SET_DIGEST_SIZE   14\n\n# define EVP_PKEY_ALG_CTRL               0x1000\n\n# define EVP_PKEY_FLAG_AUTOARGLEN        2\n/*\n * Method handles all operations: don't assume any digest related defaults.\n */\n# define EVP_PKEY_FLAG_SIGCTX_CUSTOM     4\n\nconst EVP_PKEY_METHOD *EVP_PKEY_meth_find(int type);\nEVP_PKEY_METHOD *EVP_PKEY_meth_new(int id, int flags);\nvoid EVP_PKEY_meth_get0_info(int *ppkey_id, int *pflags,\n                             const EVP_PKEY_METHOD *meth);\nvoid EVP_PKEY_meth_copy(EVP_PKEY_METHOD *dst, const EVP_PKEY_METHOD *src);\nvoid EVP_PKEY_meth_free(EVP_PKEY_METHOD *pmeth);\nint EVP_PKEY_meth_add0(const EVP_PKEY_METHOD *pmeth);\nint EVP_PKEY_meth_remove(const EVP_PKEY_METHOD *pmeth);\nsize_t EVP_PKEY_meth_get_count(void);\nconst EVP_PKEY_METHOD *EVP_PKEY_meth_get0(size_t idx);\n\nEVP_PKEY_CTX *EVP_PKEY_CTX_new(EVP_PKEY *pkey, ENGINE *e);\nEVP_PKEY_CTX *EVP_PKEY_CTX_new_id(int id, ENGINE *e);\nEVP_PKEY_CTX *EVP_PKEY_CTX_dup(EVP_PKEY_CTX *ctx);\nvoid EVP_PKEY_CTX_free(EVP_PKEY_CTX *ctx);\n\nint EVP_PKEY_CTX_ctrl(EVP_PKEY_CTX *ctx, int keytype, int optype,\n                      int cmd, int p1, void *p2);\nint EVP_PKEY_CTX_ctrl_str(EVP_PKEY_CTX *ctx, const char *type,\n                          const char *value);\nint EVP_PKEY_CTX_ctrl_uint64(EVP_PKEY_CTX *ctx, int keytype, int optype,\n                             int cmd, uint64_t value);\n\nint EVP_PKEY_CTX_str2ctrl(EVP_PKEY_CTX *ctx, int cmd, const char *str);\nint EVP_PKEY_CTX_hex2ctrl(EVP_PKEY_CTX *ctx, int cmd, const char *hex);\n\nint EVP_PKEY_CTX_md(EVP_PKEY_CTX *ctx, int optype, int cmd, const char *md);\n\nint EVP_PKEY_CTX_get_operation(EVP_PKEY_CTX *ctx);\nvoid EVP_PKEY_CTX_set0_keygen_info(EVP_PKEY_CTX *ctx, int *dat, int datlen);\n\nEVP_PKEY *EVP_PKEY_new_mac_key(int type, ENGINE *e,\n                               const unsigned char *key, int keylen);\nEVP_PKEY *EVP_PKEY_new_raw_private_key(int type, ENGINE *e,\n                                       const unsigned char *priv,\n                                       size_t len);\nEVP_PKEY *EVP_PKEY_new_raw_public_key(int type, ENGINE *e,\n                                      const unsigned char *pub,\n                                      size_t len);\nint EVP_PKEY_get_raw_private_key(const EVP_PKEY *pkey, unsigned char *priv,\n                                 size_t *len);\nint EVP_PKEY_get_raw_public_key(const EVP_PKEY *pkey, unsigned char *pub,\n                                size_t *len);\n\nEVP_PKEY *EVP_PKEY_new_CMAC_key(ENGINE *e, const unsigned char *priv,\n                                size_t len, const EVP_CIPHER *cipher);\n\nvoid EVP_PKEY_CTX_set_data(EVP_PKEY_CTX *ctx, void *data);\nvoid *EVP_PKEY_CTX_get_data(EVP_PKEY_CTX *ctx);\nEVP_PKEY *EVP_PKEY_CTX_get0_pkey(EVP_PKEY_CTX *ctx);\n\nEVP_PKEY *EVP_PKEY_CTX_get0_peerkey(EVP_PKEY_CTX *ctx);\n\nvoid EVP_PKEY_CTX_set_app_data(EVP_PKEY_CTX *ctx, void *data);\nvoid *EVP_PKEY_CTX_get_app_data(EVP_PKEY_CTX *ctx);\n\nint EVP_PKEY_sign_init(EVP_PKEY_CTX *ctx);\nint EVP_PKEY_sign(EVP_PKEY_CTX *ctx,\n                  unsigned char *sig, size_t *siglen,\n                  const unsigned char *tbs, size_t tbslen);\nint EVP_PKEY_verify_init(EVP_PKEY_CTX *ctx);\nint EVP_PKEY_verify(EVP_PKEY_CTX *ctx,\n                    const unsigned char *sig, size_t siglen,\n                    const unsigned char *tbs, size_t tbslen);\nint EVP_PKEY_verify_recover_init(EVP_PKEY_CTX *ctx);\nint EVP_PKEY_verify_recover(EVP_PKEY_CTX *ctx,\n                            unsigned char *rout, size_t *routlen,\n                            const unsigned char *sig, size_t siglen);\nint EVP_PKEY_encrypt_init(EVP_PKEY_CTX *ctx);\nint EVP_PKEY_encrypt(EVP_PKEY_CTX *ctx,\n                     unsigned char *out, size_t *outlen,\n                     const unsigned char *in, size_t inlen);\nint EVP_PKEY_decrypt_init(EVP_PKEY_CTX *ctx);\nint EVP_PKEY_decrypt(EVP_PKEY_CTX *ctx,\n                     unsigned char *out, size_t *outlen,\n                     const unsigned char *in, size_t inlen);\n\nint EVP_PKEY_derive_init(EVP_PKEY_CTX *ctx);\nint EVP_PKEY_derive_set_peer(EVP_PKEY_CTX *ctx, EVP_PKEY *peer);\nint EVP_PKEY_derive(EVP_PKEY_CTX *ctx, unsigned char *key, size_t *keylen);\n\ntypedef int EVP_PKEY_gen_cb(EVP_PKEY_CTX *ctx);\n\nint EVP_PKEY_paramgen_init(EVP_PKEY_CTX *ctx);\nint EVP_PKEY_paramgen(EVP_PKEY_CTX *ctx, EVP_PKEY **ppkey);\nint EVP_PKEY_keygen_init(EVP_PKEY_CTX *ctx);\nint EVP_PKEY_keygen(EVP_PKEY_CTX *ctx, EVP_PKEY **ppkey);\nint EVP_PKEY_check(EVP_PKEY_CTX *ctx);\nint EVP_PKEY_public_check(EVP_PKEY_CTX *ctx);\nint EVP_PKEY_param_check(EVP_PKEY_CTX *ctx);\n\nvoid EVP_PKEY_CTX_set_cb(EVP_PKEY_CTX *ctx, EVP_PKEY_gen_cb *cb);\nEVP_PKEY_gen_cb *EVP_PKEY_CTX_get_cb(EVP_PKEY_CTX *ctx);\n\nint EVP_PKEY_CTX_get_keygen_info(EVP_PKEY_CTX *ctx, int idx);\n\nvoid EVP_PKEY_meth_set_init(EVP_PKEY_METHOD *pmeth,\n                            int (*init) (EVP_PKEY_CTX *ctx));\n\nvoid EVP_PKEY_meth_set_copy(EVP_PKEY_METHOD *pmeth,\n                            int (*copy) (EVP_PKEY_CTX *dst,\n                                         EVP_PKEY_CTX *src));\n\nvoid EVP_PKEY_meth_set_cleanup(EVP_PKEY_METHOD *pmeth,\n                               void (*cleanup) (EVP_PKEY_CTX *ctx));\n\nvoid EVP_PKEY_meth_set_paramgen(EVP_PKEY_METHOD *pmeth,\n                                int (*paramgen_init) (EVP_PKEY_CTX *ctx),\n                                int (*paramgen) (EVP_PKEY_CTX *ctx,\n                                                 EVP_PKEY *pkey));\n\nvoid EVP_PKEY_meth_set_keygen(EVP_PKEY_METHOD *pmeth,\n                              int (*keygen_init) (EVP_PKEY_CTX *ctx),\n                              int (*keygen) (EVP_PKEY_CTX *ctx,\n                                             EVP_PKEY *pkey));\n\nvoid EVP_PKEY_meth_set_sign(EVP_PKEY_METHOD *pmeth,\n                            int (*sign_init) (EVP_PKEY_CTX *ctx),\n                            int (*sign) (EVP_PKEY_CTX *ctx,\n                                         unsigned char *sig, size_t *siglen,\n                                         const unsigned char *tbs,\n                                         size_t tbslen));\n\nvoid EVP_PKEY_meth_set_verify(EVP_PKEY_METHOD *pmeth,\n                              int (*verify_init) (EVP_PKEY_CTX *ctx),\n                              int (*verify) (EVP_PKEY_CTX *ctx,\n                                             const unsigned char *sig,\n                                             size_t siglen,\n                                             const unsigned char *tbs,\n                                             size_t tbslen));\n\nvoid EVP_PKEY_meth_set_verify_recover(EVP_PKEY_METHOD *pmeth,\n                                      int (*verify_recover_init) (EVP_PKEY_CTX\n                                                                  *ctx),\n                                      int (*verify_recover) (EVP_PKEY_CTX\n                                                             *ctx,\n                                                             unsigned char\n                                                             *sig,\n                                                             size_t *siglen,\n                                                             const unsigned\n                                                             char *tbs,\n                                                             size_t tbslen));\n\nvoid EVP_PKEY_meth_set_signctx(EVP_PKEY_METHOD *pmeth,\n                               int (*signctx_init) (EVP_PKEY_CTX *ctx,\n                                                    EVP_MD_CTX *mctx),\n                               int (*signctx) (EVP_PKEY_CTX *ctx,\n                                               unsigned char *sig,\n                                               size_t *siglen,\n                                               EVP_MD_CTX *mctx));\n\nvoid EVP_PKEY_meth_set_verifyctx(EVP_PKEY_METHOD *pmeth,\n                                 int (*verifyctx_init) (EVP_PKEY_CTX *ctx,\n                                                        EVP_MD_CTX *mctx),\n                                 int (*verifyctx) (EVP_PKEY_CTX *ctx,\n                                                   const unsigned char *sig,\n                                                   int siglen,\n                                                   EVP_MD_CTX *mctx));\n\nvoid EVP_PKEY_meth_set_encrypt(EVP_PKEY_METHOD *pmeth,\n                               int (*encrypt_init) (EVP_PKEY_CTX *ctx),\n                               int (*encryptfn) (EVP_PKEY_CTX *ctx,\n                                                 unsigned char *out,\n                                                 size_t *outlen,\n                                                 const unsigned char *in,\n                                                 size_t inlen));\n\nvoid EVP_PKEY_meth_set_decrypt(EVP_PKEY_METHOD *pmeth,\n                               int (*decrypt_init) (EVP_PKEY_CTX *ctx),\n                               int (*decrypt) (EVP_PKEY_CTX *ctx,\n                                               unsigned char *out,\n                                               size_t *outlen,\n                                               const unsigned char *in,\n                                               size_t inlen));\n\nvoid EVP_PKEY_meth_set_derive(EVP_PKEY_METHOD *pmeth,\n                              int (*derive_init) (EVP_PKEY_CTX *ctx),\n                              int (*derive) (EVP_PKEY_CTX *ctx,\n                                             unsigned char *key,\n                                             size_t *keylen));\n\nvoid EVP_PKEY_meth_set_ctrl(EVP_PKEY_METHOD *pmeth,\n                            int (*ctrl) (EVP_PKEY_CTX *ctx, int type, int p1,\n                                         void *p2),\n                            int (*ctrl_str) (EVP_PKEY_CTX *ctx,\n                                             const char *type,\n                                             const char *value));\n\nvoid EVP_PKEY_meth_set_digestsign(EVP_PKEY_METHOD *pmeth,\n                                  int (*digestsign) (EVP_MD_CTX *ctx,\n                                                     unsigned char *sig,\n                                                     size_t *siglen,\n                                                     const unsigned char *tbs,\n                                                     size_t tbslen));\n\nvoid EVP_PKEY_meth_set_digestverify(EVP_PKEY_METHOD *pmeth,\n                                    int (*digestverify) (EVP_MD_CTX *ctx,\n                                                         const unsigned char *sig,\n                                                         size_t siglen,\n                                                         const unsigned char *tbs,\n                                                         size_t tbslen));\n\nvoid EVP_PKEY_meth_set_check(EVP_PKEY_METHOD *pmeth,\n                             int (*check) (EVP_PKEY *pkey));\n\nvoid EVP_PKEY_meth_set_public_check(EVP_PKEY_METHOD *pmeth,\n                                    int (*check) (EVP_PKEY *pkey));\n\nvoid EVP_PKEY_meth_set_param_check(EVP_PKEY_METHOD *pmeth,\n                                   int (*check) (EVP_PKEY *pkey));\n\nvoid EVP_PKEY_meth_set_digest_custom(EVP_PKEY_METHOD *pmeth,\n                                     int (*digest_custom) (EVP_PKEY_CTX *ctx,\n                                                           EVP_MD_CTX *mctx));\n\nvoid EVP_PKEY_meth_get_init(const EVP_PKEY_METHOD *pmeth,\n                            int (**pinit) (EVP_PKEY_CTX *ctx));\n\nvoid EVP_PKEY_meth_get_copy(const EVP_PKEY_METHOD *pmeth,\n                            int (**pcopy) (EVP_PKEY_CTX *dst,\n                                           EVP_PKEY_CTX *src));\n\nvoid EVP_PKEY_meth_get_cleanup(const EVP_PKEY_METHOD *pmeth,\n                               void (**pcleanup) (EVP_PKEY_CTX *ctx));\n\nvoid EVP_PKEY_meth_get_paramgen(const EVP_PKEY_METHOD *pmeth,\n                                int (**pparamgen_init) (EVP_PKEY_CTX *ctx),\n                                int (**pparamgen) (EVP_PKEY_CTX *ctx,\n                                                   EVP_PKEY *pkey));\n\nvoid EVP_PKEY_meth_get_keygen(const EVP_PKEY_METHOD *pmeth,\n                              int (**pkeygen_init) (EVP_PKEY_CTX *ctx),\n                              int (**pkeygen) (EVP_PKEY_CTX *ctx,\n                                               EVP_PKEY *pkey));\n\nvoid EVP_PKEY_meth_get_sign(const EVP_PKEY_METHOD *pmeth,\n                            int (**psign_init) (EVP_PKEY_CTX *ctx),\n                            int (**psign) (EVP_PKEY_CTX *ctx,\n                                           unsigned char *sig, size_t *siglen,\n                                           const unsigned char *tbs,\n                                           size_t tbslen));\n\nvoid EVP_PKEY_meth_get_verify(const EVP_PKEY_METHOD *pmeth,\n                              int (**pverify_init) (EVP_PKEY_CTX *ctx),\n                              int (**pverify) (EVP_PKEY_CTX *ctx,\n                                               const unsigned char *sig,\n                                               size_t siglen,\n                                               const unsigned char *tbs,\n                                               size_t tbslen));\n\nvoid EVP_PKEY_meth_get_verify_recover(const EVP_PKEY_METHOD *pmeth,\n                                      int (**pverify_recover_init) (EVP_PKEY_CTX\n                                                                    *ctx),\n                                      int (**pverify_recover) (EVP_PKEY_CTX\n                                                               *ctx,\n                                                               unsigned char\n                                                               *sig,\n                                                               size_t *siglen,\n                                                               const unsigned\n                                                               char *tbs,\n                                                               size_t tbslen));\n\nvoid EVP_PKEY_meth_get_signctx(const EVP_PKEY_METHOD *pmeth,\n                               int (**psignctx_init) (EVP_PKEY_CTX *ctx,\n                                                      EVP_MD_CTX *mctx),\n                               int (**psignctx) (EVP_PKEY_CTX *ctx,\n                                                 unsigned char *sig,\n                                                 size_t *siglen,\n                                                 EVP_MD_CTX *mctx));\n\nvoid EVP_PKEY_meth_get_verifyctx(const EVP_PKEY_METHOD *pmeth,\n                                 int (**pverifyctx_init) (EVP_PKEY_CTX *ctx,\n                                                          EVP_MD_CTX *mctx),\n                                 int (**pverifyctx) (EVP_PKEY_CTX *ctx,\n                                                     const unsigned char *sig,\n                                                     int siglen,\n                                                     EVP_MD_CTX *mctx));\n\nvoid EVP_PKEY_meth_get_encrypt(const EVP_PKEY_METHOD *pmeth,\n                               int (**pencrypt_init) (EVP_PKEY_CTX *ctx),\n                               int (**pencryptfn) (EVP_PKEY_CTX *ctx,\n                                                   unsigned char *out,\n                                                   size_t *outlen,\n                                                   const unsigned char *in,\n                                                   size_t inlen));\n\nvoid EVP_PKEY_meth_get_decrypt(const EVP_PKEY_METHOD *pmeth,\n                               int (**pdecrypt_init) (EVP_PKEY_CTX *ctx),\n                               int (**pdecrypt) (EVP_PKEY_CTX *ctx,\n                                                 unsigned char *out,\n                                                 size_t *outlen,\n                                                 const unsigned char *in,\n                                                 size_t inlen));\n\nvoid EVP_PKEY_meth_get_derive(const EVP_PKEY_METHOD *pmeth,\n                              int (**pderive_init) (EVP_PKEY_CTX *ctx),\n                              int (**pderive) (EVP_PKEY_CTX *ctx,\n                                               unsigned char *key,\n                                               size_t *keylen));\n\nvoid EVP_PKEY_meth_get_ctrl(const EVP_PKEY_METHOD *pmeth,\n                            int (**pctrl) (EVP_PKEY_CTX *ctx, int type, int p1,\n                                           void *p2),\n                            int (**pctrl_str) (EVP_PKEY_CTX *ctx,\n                                               const char *type,\n                                               const char *value));\n\nvoid EVP_PKEY_meth_get_digestsign(EVP_PKEY_METHOD *pmeth,\n                                  int (**digestsign) (EVP_MD_CTX *ctx,\n                                                      unsigned char *sig,\n                                                      size_t *siglen,\n                                                      const unsigned char *tbs,\n                                                      size_t tbslen));\n\nvoid EVP_PKEY_meth_get_digestverify(EVP_PKEY_METHOD *pmeth,\n                                    int (**digestverify) (EVP_MD_CTX *ctx,\n                                                          const unsigned char *sig,\n                                                          size_t siglen,\n                                                          const unsigned char *tbs,\n                                                          size_t tbslen));\n\nvoid EVP_PKEY_meth_get_check(const EVP_PKEY_METHOD *pmeth,\n                             int (**pcheck) (EVP_PKEY *pkey));\n\nvoid EVP_PKEY_meth_get_public_check(const EVP_PKEY_METHOD *pmeth,\n                                    int (**pcheck) (EVP_PKEY *pkey));\n\nvoid EVP_PKEY_meth_get_param_check(const EVP_PKEY_METHOD *pmeth,\n                                   int (**pcheck) (EVP_PKEY *pkey));\n\nvoid EVP_PKEY_meth_get_digest_custom(EVP_PKEY_METHOD *pmeth,\n                                     int (**pdigest_custom) (EVP_PKEY_CTX *ctx,\n                                                             EVP_MD_CTX *mctx));\nvoid EVP_add_alg_module(void);\n\n\n# ifdef  __cplusplus\n}\n# endif\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/include/openssl/evperr.h",
    "content": "/*\n * Generated by util/mkerr.pl DO NOT EDIT\n * Copyright 1995-2021 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef HEADER_EVPERR_H\n# define HEADER_EVPERR_H\n\n# include <openssl/symhacks.h>\n\n# ifdef  __cplusplus\nextern \"C\"\n# endif\nint ERR_load_EVP_strings(void);\n\n/*\n * EVP function codes.\n */\n# define EVP_F_AESNI_INIT_KEY                             165\n# define EVP_F_AESNI_XTS_INIT_KEY                         207\n# define EVP_F_AES_GCM_CTRL                               196\n# define EVP_F_AES_INIT_KEY                               133\n# define EVP_F_AES_OCB_CIPHER                             169\n# define EVP_F_AES_T4_INIT_KEY                            178\n# define EVP_F_AES_T4_XTS_INIT_KEY                        208\n# define EVP_F_AES_WRAP_CIPHER                            170\n# define EVP_F_AES_XTS_INIT_KEY                           209\n# define EVP_F_ALG_MODULE_INIT                            177\n# define EVP_F_ARIA_CCM_INIT_KEY                          175\n# define EVP_F_ARIA_GCM_CTRL                              197\n# define EVP_F_ARIA_GCM_INIT_KEY                          176\n# define EVP_F_ARIA_INIT_KEY                              185\n# define EVP_F_B64_NEW                                    198\n# define EVP_F_CAMELLIA_INIT_KEY                          159\n# define EVP_F_CHACHA20_POLY1305_CTRL                     182\n# define EVP_F_CMLL_T4_INIT_KEY                           179\n# define EVP_F_DES_EDE3_WRAP_CIPHER                       171\n# define EVP_F_DO_SIGVER_INIT                             161\n# define EVP_F_ENC_NEW                                    199\n# define EVP_F_EVP_CIPHERINIT_EX                          123\n# define EVP_F_EVP_CIPHER_ASN1_TO_PARAM                   204\n# define EVP_F_EVP_CIPHER_CTX_COPY                        163\n# define EVP_F_EVP_CIPHER_CTX_CTRL                        124\n# define EVP_F_EVP_CIPHER_CTX_SET_KEY_LENGTH              122\n# define EVP_F_EVP_CIPHER_PARAM_TO_ASN1                   205\n# define EVP_F_EVP_DECRYPTFINAL_EX                        101\n# define EVP_F_EVP_DECRYPTUPDATE                          166\n# define EVP_F_EVP_DIGESTFINALXOF                         174\n# define EVP_F_EVP_DIGESTINIT_EX                          128\n# define EVP_F_EVP_ENCRYPTDECRYPTUPDATE                   219\n# define EVP_F_EVP_ENCRYPTFINAL_EX                        127\n# define EVP_F_EVP_ENCRYPTUPDATE                          167\n# define EVP_F_EVP_MD_CTX_COPY_EX                         110\n# define EVP_F_EVP_MD_SIZE                                162\n# define EVP_F_EVP_OPENINIT                               102\n# define EVP_F_EVP_PBE_ALG_ADD                            115\n# define EVP_F_EVP_PBE_ALG_ADD_TYPE                       160\n# define EVP_F_EVP_PBE_CIPHERINIT                         116\n# define EVP_F_EVP_PBE_SCRYPT                             181\n# define EVP_F_EVP_PKCS82PKEY                             111\n# define EVP_F_EVP_PKEY2PKCS8                             113\n# define EVP_F_EVP_PKEY_ASN1_ADD0                         188\n# define EVP_F_EVP_PKEY_CHECK                             186\n# define EVP_F_EVP_PKEY_COPY_PARAMETERS                   103\n# define EVP_F_EVP_PKEY_CTX_CTRL                          137\n# define EVP_F_EVP_PKEY_CTX_CTRL_STR                      150\n# define EVP_F_EVP_PKEY_CTX_DUP                           156\n# define EVP_F_EVP_PKEY_CTX_MD                            168\n# define EVP_F_EVP_PKEY_DECRYPT                           104\n# define EVP_F_EVP_PKEY_DECRYPT_INIT                      138\n# define EVP_F_EVP_PKEY_DECRYPT_OLD                       151\n# define EVP_F_EVP_PKEY_DERIVE                            153\n# define EVP_F_EVP_PKEY_DERIVE_INIT                       154\n# define EVP_F_EVP_PKEY_DERIVE_SET_PEER                   155\n# define EVP_F_EVP_PKEY_ENCRYPT                           105\n# define EVP_F_EVP_PKEY_ENCRYPT_INIT                      139\n# define EVP_F_EVP_PKEY_ENCRYPT_OLD                       152\n# define EVP_F_EVP_PKEY_GET0_DH                           119\n# define EVP_F_EVP_PKEY_GET0_DSA                          120\n# define EVP_F_EVP_PKEY_GET0_EC_KEY                       131\n# define EVP_F_EVP_PKEY_GET0_HMAC                         183\n# define EVP_F_EVP_PKEY_GET0_POLY1305                     184\n# define EVP_F_EVP_PKEY_GET0_RSA                          121\n# define EVP_F_EVP_PKEY_GET0_SIPHASH                      172\n# define EVP_F_EVP_PKEY_GET_RAW_PRIVATE_KEY               202\n# define EVP_F_EVP_PKEY_GET_RAW_PUBLIC_KEY                203\n# define EVP_F_EVP_PKEY_KEYGEN                            146\n# define EVP_F_EVP_PKEY_KEYGEN_INIT                       147\n# define EVP_F_EVP_PKEY_METH_ADD0                         194\n# define EVP_F_EVP_PKEY_METH_NEW                          195\n# define EVP_F_EVP_PKEY_NEW                               106\n# define EVP_F_EVP_PKEY_NEW_CMAC_KEY                      193\n# define EVP_F_EVP_PKEY_NEW_RAW_PRIVATE_KEY               191\n# define EVP_F_EVP_PKEY_NEW_RAW_PUBLIC_KEY                192\n# define EVP_F_EVP_PKEY_PARAMGEN                          148\n# define EVP_F_EVP_PKEY_PARAMGEN_INIT                     149\n# define EVP_F_EVP_PKEY_PARAM_CHECK                       189\n# define EVP_F_EVP_PKEY_PUBLIC_CHECK                      190\n# define EVP_F_EVP_PKEY_SET1_ENGINE                       187\n# define EVP_F_EVP_PKEY_SET_ALIAS_TYPE                    206\n# define EVP_F_EVP_PKEY_SIGN                              140\n# define EVP_F_EVP_PKEY_SIGN_INIT                         141\n# define EVP_F_EVP_PKEY_VERIFY                            142\n# define EVP_F_EVP_PKEY_VERIFY_INIT                       143\n# define EVP_F_EVP_PKEY_VERIFY_RECOVER                    144\n# define EVP_F_EVP_PKEY_VERIFY_RECOVER_INIT               145\n# define EVP_F_EVP_SIGNFINAL                              107\n# define EVP_F_EVP_VERIFYFINAL                            108\n# define EVP_F_INT_CTX_NEW                                157\n# define EVP_F_OK_NEW                                     200\n# define EVP_F_PKCS5_PBE_KEYIVGEN                         117\n# define EVP_F_PKCS5_V2_PBE_KEYIVGEN                      118\n# define EVP_F_PKCS5_V2_PBKDF2_KEYIVGEN                   164\n# define EVP_F_PKCS5_V2_SCRYPT_KEYIVGEN                   180\n# define EVP_F_PKEY_SET_TYPE                              158\n# define EVP_F_RC2_MAGIC_TO_METH                          109\n# define EVP_F_RC5_CTRL                                   125\n# define EVP_F_R_32_12_16_INIT_KEY                        242\n# define EVP_F_S390X_AES_GCM_CTRL                         201\n# define EVP_F_UPDATE                                     173\n\n/*\n * EVP reason codes.\n */\n# define EVP_R_AES_KEY_SETUP_FAILED                       143\n# define EVP_R_ARIA_KEY_SETUP_FAILED                      176\n# define EVP_R_BAD_DECRYPT                                100\n# define EVP_R_BAD_KEY_LENGTH                             195\n# define EVP_R_BUFFER_TOO_SMALL                           155\n# define EVP_R_CAMELLIA_KEY_SETUP_FAILED                  157\n# define EVP_R_CIPHER_PARAMETER_ERROR                     122\n# define EVP_R_COMMAND_NOT_SUPPORTED                      147\n# define EVP_R_COPY_ERROR                                 173\n# define EVP_R_CTRL_NOT_IMPLEMENTED                       132\n# define EVP_R_CTRL_OPERATION_NOT_IMPLEMENTED             133\n# define EVP_R_DATA_NOT_MULTIPLE_OF_BLOCK_LENGTH          138\n# define EVP_R_DECODE_ERROR                               114\n# define EVP_R_DIFFERENT_KEY_TYPES                        101\n# define EVP_R_DIFFERENT_PARAMETERS                       153\n# define EVP_R_ERROR_LOADING_SECTION                      165\n# define EVP_R_ERROR_SETTING_FIPS_MODE                    166\n# define EVP_R_EXPECTING_AN_HMAC_KEY                      174\n# define EVP_R_EXPECTING_AN_RSA_KEY                       127\n# define EVP_R_EXPECTING_A_DH_KEY                         128\n# define EVP_R_EXPECTING_A_DSA_KEY                        129\n# define EVP_R_EXPECTING_A_EC_KEY                         142\n# define EVP_R_EXPECTING_A_POLY1305_KEY                   164\n# define EVP_R_EXPECTING_A_SIPHASH_KEY                    175\n# define EVP_R_FIPS_MODE_NOT_SUPPORTED                    167\n# define EVP_R_GET_RAW_KEY_FAILED                         182\n# define EVP_R_ILLEGAL_SCRYPT_PARAMETERS                  171\n# define EVP_R_INITIALIZATION_ERROR                       134\n# define EVP_R_INPUT_NOT_INITIALIZED                      111\n# define EVP_R_INVALID_DIGEST                             152\n# define EVP_R_INVALID_FIPS_MODE                          168\n# define EVP_R_INVALID_IV_LENGTH                          194\n# define EVP_R_INVALID_KEY                                163\n# define EVP_R_INVALID_KEY_LENGTH                         130\n# define EVP_R_INVALID_OPERATION                          148\n# define EVP_R_KEYGEN_FAILURE                             120\n# define EVP_R_KEY_SETUP_FAILED                           180\n# define EVP_R_MEMORY_LIMIT_EXCEEDED                      172\n# define EVP_R_MESSAGE_DIGEST_IS_NULL                     159\n# define EVP_R_METHOD_NOT_SUPPORTED                       144\n# define EVP_R_MISSING_PARAMETERS                         103\n# define EVP_R_NOT_XOF_OR_INVALID_LENGTH                  178\n# define EVP_R_NO_CIPHER_SET                              131\n# define EVP_R_NO_DEFAULT_DIGEST                          158\n# define EVP_R_NO_DIGEST_SET                              139\n# define EVP_R_NO_KEY_SET                                 154\n# define EVP_R_NO_OPERATION_SET                           149\n# define EVP_R_ONLY_ONESHOT_SUPPORTED                     177\n# define EVP_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE   150\n# define EVP_R_OPERATON_NOT_INITIALIZED                   151\n# define EVP_R_OUTPUT_WOULD_OVERFLOW                      184\n# define EVP_R_PARTIALLY_OVERLAPPING                      162\n# define EVP_R_PBKDF2_ERROR                               181\n# define EVP_R_PKEY_APPLICATION_ASN1_METHOD_ALREADY_REGISTERED 179\n# define EVP_R_PRIVATE_KEY_DECODE_ERROR                   145\n# define EVP_R_PRIVATE_KEY_ENCODE_ERROR                   146\n# define EVP_R_PUBLIC_KEY_NOT_RSA                         106\n# define EVP_R_UNKNOWN_CIPHER                             160\n# define EVP_R_UNKNOWN_DIGEST                             161\n# define EVP_R_UNKNOWN_OPTION                             169\n# define EVP_R_UNKNOWN_PBE_ALGORITHM                      121\n# define EVP_R_UNSUPPORTED_ALGORITHM                      156\n# define EVP_R_UNSUPPORTED_CIPHER                         107\n# define EVP_R_UNSUPPORTED_KEYLENGTH                      123\n# define EVP_R_UNSUPPORTED_KEY_DERIVATION_FUNCTION        124\n# define EVP_R_UNSUPPORTED_KEY_SIZE                       108\n# define EVP_R_UNSUPPORTED_NUMBER_OF_ROUNDS               135\n# define EVP_R_UNSUPPORTED_PRF                            125\n# define EVP_R_UNSUPPORTED_PRIVATE_KEY_ALGORITHM          118\n# define EVP_R_UNSUPPORTED_SALT_TYPE                      126\n# define EVP_R_WRAP_MODE_NOT_ALLOWED                      170\n# define EVP_R_WRONG_FINAL_BLOCK_LENGTH                   109\n# define EVP_R_XTS_DUPLICATED_KEYS                        183\n\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/include/openssl/hmac.h",
    "content": "/*\n * Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef HEADER_HMAC_H\n# define HEADER_HMAC_H\n\n# include <openssl/opensslconf.h>\n\n# include <openssl/evp.h>\n\n# if OPENSSL_API_COMPAT < 0x10200000L\n#  define HMAC_MAX_MD_CBLOCK      128    /* Deprecated */\n# endif\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\nsize_t HMAC_size(const HMAC_CTX *e);\nHMAC_CTX *HMAC_CTX_new(void);\nint HMAC_CTX_reset(HMAC_CTX *ctx);\nvoid HMAC_CTX_free(HMAC_CTX *ctx);\n\nDEPRECATEDIN_1_1_0(__owur int HMAC_Init(HMAC_CTX *ctx, const void *key, int len,\n                     const EVP_MD *md))\n\n/*__owur*/ int HMAC_Init_ex(HMAC_CTX *ctx, const void *key, int len,\n                            const EVP_MD *md, ENGINE *impl);\n/*__owur*/ int HMAC_Update(HMAC_CTX *ctx, const unsigned char *data,\n                           size_t len);\n/*__owur*/ int HMAC_Final(HMAC_CTX *ctx, unsigned char *md,\n                          unsigned int *len);\nunsigned char *HMAC(const EVP_MD *evp_md, const void *key, int key_len,\n                    const unsigned char *d, size_t n, unsigned char *md,\n                    unsigned int *md_len);\n__owur int HMAC_CTX_copy(HMAC_CTX *dctx, HMAC_CTX *sctx);\n\nvoid HMAC_CTX_set_flags(HMAC_CTX *ctx, unsigned long flags);\nconst EVP_MD *HMAC_CTX_get_md(const HMAC_CTX *ctx);\n\n#ifdef  __cplusplus\n}\n#endif\n\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/include/openssl/idea.h",
    "content": "/*\n * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef HEADER_IDEA_H\n# define HEADER_IDEA_H\n\n# include <openssl/opensslconf.h>\n\n# ifndef OPENSSL_NO_IDEA\n# ifdef  __cplusplus\nextern \"C\" {\n# endif\n\ntypedef unsigned int IDEA_INT;\n\n# define IDEA_ENCRYPT    1\n# define IDEA_DECRYPT    0\n\n# define IDEA_BLOCK      8\n# define IDEA_KEY_LENGTH 16\n\ntypedef struct idea_key_st {\n    IDEA_INT data[9][6];\n} IDEA_KEY_SCHEDULE;\n\nconst char *IDEA_options(void);\nvoid IDEA_ecb_encrypt(const unsigned char *in, unsigned char *out,\n                      IDEA_KEY_SCHEDULE *ks);\nvoid IDEA_set_encrypt_key(const unsigned char *key, IDEA_KEY_SCHEDULE *ks);\nvoid IDEA_set_decrypt_key(IDEA_KEY_SCHEDULE *ek, IDEA_KEY_SCHEDULE *dk);\nvoid IDEA_cbc_encrypt(const unsigned char *in, unsigned char *out,\n                      long length, IDEA_KEY_SCHEDULE *ks, unsigned char *iv,\n                      int enc);\nvoid IDEA_cfb64_encrypt(const unsigned char *in, unsigned char *out,\n                        long length, IDEA_KEY_SCHEDULE *ks, unsigned char *iv,\n                        int *num, int enc);\nvoid IDEA_ofb64_encrypt(const unsigned char *in, unsigned char *out,\n                        long length, IDEA_KEY_SCHEDULE *ks, unsigned char *iv,\n                        int *num);\nvoid IDEA_encrypt(unsigned long *in, IDEA_KEY_SCHEDULE *ks);\n\n# if OPENSSL_API_COMPAT < 0x10100000L\n#  define idea_options          IDEA_options\n#  define idea_ecb_encrypt      IDEA_ecb_encrypt\n#  define idea_set_encrypt_key  IDEA_set_encrypt_key\n#  define idea_set_decrypt_key  IDEA_set_decrypt_key\n#  define idea_cbc_encrypt      IDEA_cbc_encrypt\n#  define idea_cfb64_encrypt    IDEA_cfb64_encrypt\n#  define idea_ofb64_encrypt    IDEA_ofb64_encrypt\n#  define idea_encrypt          IDEA_encrypt\n# endif\n\n# ifdef  __cplusplus\n}\n# endif\n# endif\n\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/include/openssl/kdf.h",
    "content": "/*\n * Copyright 2016-2018 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef HEADER_KDF_H\n# define HEADER_KDF_H\n\n# include <openssl/kdferr.h>\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n# define EVP_PKEY_CTRL_TLS_MD                   (EVP_PKEY_ALG_CTRL)\n# define EVP_PKEY_CTRL_TLS_SECRET               (EVP_PKEY_ALG_CTRL + 1)\n# define EVP_PKEY_CTRL_TLS_SEED                 (EVP_PKEY_ALG_CTRL + 2)\n# define EVP_PKEY_CTRL_HKDF_MD                  (EVP_PKEY_ALG_CTRL + 3)\n# define EVP_PKEY_CTRL_HKDF_SALT                (EVP_PKEY_ALG_CTRL + 4)\n# define EVP_PKEY_CTRL_HKDF_KEY                 (EVP_PKEY_ALG_CTRL + 5)\n# define EVP_PKEY_CTRL_HKDF_INFO                (EVP_PKEY_ALG_CTRL + 6)\n# define EVP_PKEY_CTRL_HKDF_MODE                (EVP_PKEY_ALG_CTRL + 7)\n# define EVP_PKEY_CTRL_PASS                     (EVP_PKEY_ALG_CTRL + 8)\n# define EVP_PKEY_CTRL_SCRYPT_SALT              (EVP_PKEY_ALG_CTRL + 9)\n# define EVP_PKEY_CTRL_SCRYPT_N                 (EVP_PKEY_ALG_CTRL + 10)\n# define EVP_PKEY_CTRL_SCRYPT_R                 (EVP_PKEY_ALG_CTRL + 11)\n# define EVP_PKEY_CTRL_SCRYPT_P                 (EVP_PKEY_ALG_CTRL + 12)\n# define EVP_PKEY_CTRL_SCRYPT_MAXMEM_BYTES      (EVP_PKEY_ALG_CTRL + 13)\n\n# define EVP_PKEY_HKDEF_MODE_EXTRACT_AND_EXPAND 0\n# define EVP_PKEY_HKDEF_MODE_EXTRACT_ONLY       1\n# define EVP_PKEY_HKDEF_MODE_EXPAND_ONLY        2\n\n# define EVP_PKEY_CTX_set_tls1_prf_md(pctx, md) \\\n            EVP_PKEY_CTX_ctrl(pctx, -1, EVP_PKEY_OP_DERIVE, \\\n                              EVP_PKEY_CTRL_TLS_MD, 0, (void *)(md))\n\n# define EVP_PKEY_CTX_set1_tls1_prf_secret(pctx, sec, seclen) \\\n            EVP_PKEY_CTX_ctrl(pctx, -1, EVP_PKEY_OP_DERIVE, \\\n                              EVP_PKEY_CTRL_TLS_SECRET, seclen, (void *)(sec))\n\n# define EVP_PKEY_CTX_add1_tls1_prf_seed(pctx, seed, seedlen) \\\n            EVP_PKEY_CTX_ctrl(pctx, -1, EVP_PKEY_OP_DERIVE, \\\n                              EVP_PKEY_CTRL_TLS_SEED, seedlen, (void *)(seed))\n\n# define EVP_PKEY_CTX_set_hkdf_md(pctx, md) \\\n            EVP_PKEY_CTX_ctrl(pctx, -1, EVP_PKEY_OP_DERIVE, \\\n                              EVP_PKEY_CTRL_HKDF_MD, 0, (void *)(md))\n\n# define EVP_PKEY_CTX_set1_hkdf_salt(pctx, salt, saltlen) \\\n            EVP_PKEY_CTX_ctrl(pctx, -1, EVP_PKEY_OP_DERIVE, \\\n                              EVP_PKEY_CTRL_HKDF_SALT, saltlen, (void *)(salt))\n\n# define EVP_PKEY_CTX_set1_hkdf_key(pctx, key, keylen) \\\n            EVP_PKEY_CTX_ctrl(pctx, -1, EVP_PKEY_OP_DERIVE, \\\n                              EVP_PKEY_CTRL_HKDF_KEY, keylen, (void *)(key))\n\n# define EVP_PKEY_CTX_add1_hkdf_info(pctx, info, infolen) \\\n            EVP_PKEY_CTX_ctrl(pctx, -1, EVP_PKEY_OP_DERIVE, \\\n                              EVP_PKEY_CTRL_HKDF_INFO, infolen, (void *)(info))\n\n# define EVP_PKEY_CTX_hkdf_mode(pctx, mode) \\\n            EVP_PKEY_CTX_ctrl(pctx, -1, EVP_PKEY_OP_DERIVE, \\\n                              EVP_PKEY_CTRL_HKDF_MODE, mode, NULL)\n\n# define EVP_PKEY_CTX_set1_pbe_pass(pctx, pass, passlen) \\\n            EVP_PKEY_CTX_ctrl(pctx, -1, EVP_PKEY_OP_DERIVE, \\\n                            EVP_PKEY_CTRL_PASS, passlen, (void *)(pass))\n\n# define EVP_PKEY_CTX_set1_scrypt_salt(pctx, salt, saltlen) \\\n            EVP_PKEY_CTX_ctrl(pctx, -1, EVP_PKEY_OP_DERIVE, \\\n                            EVP_PKEY_CTRL_SCRYPT_SALT, saltlen, (void *)(salt))\n\n# define EVP_PKEY_CTX_set_scrypt_N(pctx, n) \\\n            EVP_PKEY_CTX_ctrl_uint64(pctx, -1, EVP_PKEY_OP_DERIVE, \\\n                            EVP_PKEY_CTRL_SCRYPT_N, n)\n\n# define EVP_PKEY_CTX_set_scrypt_r(pctx, r) \\\n            EVP_PKEY_CTX_ctrl_uint64(pctx, -1, EVP_PKEY_OP_DERIVE, \\\n                            EVP_PKEY_CTRL_SCRYPT_R, r)\n\n# define EVP_PKEY_CTX_set_scrypt_p(pctx, p) \\\n            EVP_PKEY_CTX_ctrl_uint64(pctx, -1, EVP_PKEY_OP_DERIVE, \\\n                            EVP_PKEY_CTRL_SCRYPT_P, p)\n\n# define EVP_PKEY_CTX_set_scrypt_maxmem_bytes(pctx, maxmem_bytes) \\\n            EVP_PKEY_CTX_ctrl_uint64(pctx, -1, EVP_PKEY_OP_DERIVE, \\\n                            EVP_PKEY_CTRL_SCRYPT_MAXMEM_BYTES, maxmem_bytes)\n\n\n# ifdef  __cplusplus\n}\n# endif\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/include/openssl/kdferr.h",
    "content": "/*\n * Generated by util/mkerr.pl DO NOT EDIT\n * Copyright 1995-2019 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef HEADER_KDFERR_H\n# define HEADER_KDFERR_H\n\n# ifndef HEADER_SYMHACKS_H\n#  include <openssl/symhacks.h>\n# endif\n\n# ifdef  __cplusplus\nextern \"C\"\n# endif\nint ERR_load_KDF_strings(void);\n\n/*\n * KDF function codes.\n */\n# define KDF_F_PKEY_HKDF_CTRL_STR                         103\n# define KDF_F_PKEY_HKDF_DERIVE                           102\n# define KDF_F_PKEY_HKDF_INIT                             108\n# define KDF_F_PKEY_SCRYPT_CTRL_STR                       104\n# define KDF_F_PKEY_SCRYPT_CTRL_UINT64                    105\n# define KDF_F_PKEY_SCRYPT_DERIVE                         109\n# define KDF_F_PKEY_SCRYPT_INIT                           106\n# define KDF_F_PKEY_SCRYPT_SET_MEMBUF                     107\n# define KDF_F_PKEY_TLS1_PRF_CTRL_STR                     100\n# define KDF_F_PKEY_TLS1_PRF_DERIVE                       101\n# define KDF_F_PKEY_TLS1_PRF_INIT                         110\n# define KDF_F_TLS1_PRF_ALG                               111\n\n/*\n * KDF reason codes.\n */\n# define KDF_R_INVALID_DIGEST                             100\n# define KDF_R_MISSING_ITERATION_COUNT                    109\n# define KDF_R_MISSING_KEY                                104\n# define KDF_R_MISSING_MESSAGE_DIGEST                     105\n# define KDF_R_MISSING_PARAMETER                          101\n# define KDF_R_MISSING_PASS                               110\n# define KDF_R_MISSING_SALT                               111\n# define KDF_R_MISSING_SECRET                             107\n# define KDF_R_MISSING_SEED                               106\n# define KDF_R_UNKNOWN_PARAMETER_TYPE                     103\n# define KDF_R_VALUE_ERROR                                108\n# define KDF_R_VALUE_MISSING                              102\n\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/include/openssl/lhash.h",
    "content": "/*\n * Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n/*\n * Header for dynamic hash table routines Author - Eric Young\n */\n\n#ifndef HEADER_LHASH_H\n# define HEADER_LHASH_H\n\n# include <openssl/e_os2.h>\n# include <openssl/bio.h>\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\ntypedef struct lhash_node_st OPENSSL_LH_NODE;\ntypedef int (*OPENSSL_LH_COMPFUNC) (const void *, const void *);\ntypedef unsigned long (*OPENSSL_LH_HASHFUNC) (const void *);\ntypedef void (*OPENSSL_LH_DOALL_FUNC) (void *);\ntypedef void (*OPENSSL_LH_DOALL_FUNCARG) (void *, void *);\ntypedef struct lhash_st OPENSSL_LHASH;\n\n/*\n * Macros for declaring and implementing type-safe wrappers for LHASH\n * callbacks. This way, callbacks can be provided to LHASH structures without\n * function pointer casting and the macro-defined callbacks provide\n * per-variable casting before deferring to the underlying type-specific\n * callbacks. NB: It is possible to place a \"static\" in front of both the\n * DECLARE and IMPLEMENT macros if the functions are strictly internal.\n */\n\n/* First: \"hash\" functions */\n# define DECLARE_LHASH_HASH_FN(name, o_type) \\\n        unsigned long name##_LHASH_HASH(const void *);\n# define IMPLEMENT_LHASH_HASH_FN(name, o_type) \\\n        unsigned long name##_LHASH_HASH(const void *arg) { \\\n                const o_type *a = arg; \\\n                return name##_hash(a); }\n# define LHASH_HASH_FN(name) name##_LHASH_HASH\n\n/* Second: \"compare\" functions */\n# define DECLARE_LHASH_COMP_FN(name, o_type) \\\n        int name##_LHASH_COMP(const void *, const void *);\n# define IMPLEMENT_LHASH_COMP_FN(name, o_type) \\\n        int name##_LHASH_COMP(const void *arg1, const void *arg2) { \\\n                const o_type *a = arg1;             \\\n                const o_type *b = arg2; \\\n                return name##_cmp(a,b); }\n# define LHASH_COMP_FN(name) name##_LHASH_COMP\n\n/* Fourth: \"doall_arg\" functions */\n# define DECLARE_LHASH_DOALL_ARG_FN(name, o_type, a_type) \\\n        void name##_LHASH_DOALL_ARG(void *, void *);\n# define IMPLEMENT_LHASH_DOALL_ARG_FN(name, o_type, a_type) \\\n        void name##_LHASH_DOALL_ARG(void *arg1, void *arg2) { \\\n                o_type *a = arg1; \\\n                a_type *b = arg2; \\\n                name##_doall_arg(a, b); }\n# define LHASH_DOALL_ARG_FN(name) name##_LHASH_DOALL_ARG\n\n\n# define LH_LOAD_MULT    256\n\nint OPENSSL_LH_error(OPENSSL_LHASH *lh);\nOPENSSL_LHASH *OPENSSL_LH_new(OPENSSL_LH_HASHFUNC h, OPENSSL_LH_COMPFUNC c);\nvoid OPENSSL_LH_free(OPENSSL_LHASH *lh);\nvoid *OPENSSL_LH_insert(OPENSSL_LHASH *lh, void *data);\nvoid *OPENSSL_LH_delete(OPENSSL_LHASH *lh, const void *data);\nvoid *OPENSSL_LH_retrieve(OPENSSL_LHASH *lh, const void *data);\nvoid OPENSSL_LH_doall(OPENSSL_LHASH *lh, OPENSSL_LH_DOALL_FUNC func);\nvoid OPENSSL_LH_doall_arg(OPENSSL_LHASH *lh, OPENSSL_LH_DOALL_FUNCARG func, void *arg);\nunsigned long OPENSSL_LH_strhash(const char *c);\nunsigned long OPENSSL_LH_num_items(const OPENSSL_LHASH *lh);\nunsigned long OPENSSL_LH_get_down_load(const OPENSSL_LHASH *lh);\nvoid OPENSSL_LH_set_down_load(OPENSSL_LHASH *lh, unsigned long down_load);\n\n# ifndef OPENSSL_NO_STDIO\nvoid OPENSSL_LH_stats(const OPENSSL_LHASH *lh, FILE *fp);\nvoid OPENSSL_LH_node_stats(const OPENSSL_LHASH *lh, FILE *fp);\nvoid OPENSSL_LH_node_usage_stats(const OPENSSL_LHASH *lh, FILE *fp);\n# endif\nvoid OPENSSL_LH_stats_bio(const OPENSSL_LHASH *lh, BIO *out);\nvoid OPENSSL_LH_node_stats_bio(const OPENSSL_LHASH *lh, BIO *out);\nvoid OPENSSL_LH_node_usage_stats_bio(const OPENSSL_LHASH *lh, BIO *out);\n\n# if OPENSSL_API_COMPAT < 0x10100000L\n#  define _LHASH OPENSSL_LHASH\n#  define LHASH_NODE OPENSSL_LH_NODE\n#  define lh_error OPENSSL_LH_error\n#  define lh_new OPENSSL_LH_new\n#  define lh_free OPENSSL_LH_free\n#  define lh_insert OPENSSL_LH_insert\n#  define lh_delete OPENSSL_LH_delete\n#  define lh_retrieve OPENSSL_LH_retrieve\n#  define lh_doall OPENSSL_LH_doall\n#  define lh_doall_arg OPENSSL_LH_doall_arg\n#  define lh_strhash OPENSSL_LH_strhash\n#  define lh_num_items OPENSSL_LH_num_items\n#  ifndef OPENSSL_NO_STDIO\n#   define lh_stats OPENSSL_LH_stats\n#   define lh_node_stats OPENSSL_LH_node_stats\n#   define lh_node_usage_stats OPENSSL_LH_node_usage_stats\n#  endif\n#  define lh_stats_bio OPENSSL_LH_stats_bio\n#  define lh_node_stats_bio OPENSSL_LH_node_stats_bio\n#  define lh_node_usage_stats_bio OPENSSL_LH_node_usage_stats_bio\n# endif\n\n/* Type checking... */\n\n# define LHASH_OF(type) struct lhash_st_##type\n\n# define DEFINE_LHASH_OF(type) \\\n    LHASH_OF(type) { union lh_##type##_dummy { void* d1; unsigned long d2; int d3; } dummy; }; \\\n    static ossl_unused ossl_inline LHASH_OF(type) *lh_##type##_new(unsigned long (*hfn)(const type *), \\\n                                                                   int (*cfn)(const type *, const type *)) \\\n    { \\\n        return (LHASH_OF(type) *) \\\n            OPENSSL_LH_new((OPENSSL_LH_HASHFUNC)hfn, (OPENSSL_LH_COMPFUNC)cfn); \\\n    } \\\n    static ossl_unused ossl_inline void lh_##type##_free(LHASH_OF(type) *lh) \\\n    { \\\n        OPENSSL_LH_free((OPENSSL_LHASH *)lh); \\\n    } \\\n    static ossl_unused ossl_inline type *lh_##type##_insert(LHASH_OF(type) *lh, type *d) \\\n    { \\\n        return (type *)OPENSSL_LH_insert((OPENSSL_LHASH *)lh, d); \\\n    } \\\n    static ossl_unused ossl_inline type *lh_##type##_delete(LHASH_OF(type) *lh, const type *d) \\\n    { \\\n        return (type *)OPENSSL_LH_delete((OPENSSL_LHASH *)lh, d); \\\n    } \\\n    static ossl_unused ossl_inline type *lh_##type##_retrieve(LHASH_OF(type) *lh, const type *d) \\\n    { \\\n        return (type *)OPENSSL_LH_retrieve((OPENSSL_LHASH *)lh, d); \\\n    } \\\n    static ossl_unused ossl_inline int lh_##type##_error(LHASH_OF(type) *lh) \\\n    { \\\n        return OPENSSL_LH_error((OPENSSL_LHASH *)lh); \\\n    } \\\n    static ossl_unused ossl_inline unsigned long lh_##type##_num_items(LHASH_OF(type) *lh) \\\n    { \\\n        return OPENSSL_LH_num_items((OPENSSL_LHASH *)lh); \\\n    } \\\n    static ossl_unused ossl_inline void lh_##type##_node_stats_bio(const LHASH_OF(type) *lh, BIO *out) \\\n    { \\\n        OPENSSL_LH_node_stats_bio((const OPENSSL_LHASH *)lh, out); \\\n    } \\\n    static ossl_unused ossl_inline void lh_##type##_node_usage_stats_bio(const LHASH_OF(type) *lh, BIO *out) \\\n    { \\\n        OPENSSL_LH_node_usage_stats_bio((const OPENSSL_LHASH *)lh, out); \\\n    } \\\n    static ossl_unused ossl_inline void lh_##type##_stats_bio(const LHASH_OF(type) *lh, BIO *out) \\\n    { \\\n        OPENSSL_LH_stats_bio((const OPENSSL_LHASH *)lh, out); \\\n    } \\\n    static ossl_unused ossl_inline unsigned long lh_##type##_get_down_load(LHASH_OF(type) *lh) \\\n    { \\\n        return OPENSSL_LH_get_down_load((OPENSSL_LHASH *)lh); \\\n    } \\\n    static ossl_unused ossl_inline void lh_##type##_set_down_load(LHASH_OF(type) *lh, unsigned long dl) \\\n    { \\\n        OPENSSL_LH_set_down_load((OPENSSL_LHASH *)lh, dl); \\\n    } \\\n    static ossl_unused ossl_inline void lh_##type##_doall(LHASH_OF(type) *lh, \\\n                                                          void (*doall)(type *)) \\\n    { \\\n        OPENSSL_LH_doall((OPENSSL_LHASH *)lh, (OPENSSL_LH_DOALL_FUNC)doall); \\\n    } \\\n    LHASH_OF(type)\n\n#define IMPLEMENT_LHASH_DOALL_ARG_CONST(type, argtype) \\\n    int_implement_lhash_doall(type, argtype, const type)\n\n#define IMPLEMENT_LHASH_DOALL_ARG(type, argtype) \\\n    int_implement_lhash_doall(type, argtype, type)\n\n#define int_implement_lhash_doall(type, argtype, cbargtype) \\\n    static ossl_unused ossl_inline void \\\n        lh_##type##_doall_##argtype(LHASH_OF(type) *lh, \\\n                                   void (*fn)(cbargtype *, argtype *), \\\n                                   argtype *arg) \\\n    { \\\n        OPENSSL_LH_doall_arg((OPENSSL_LHASH *)lh, (OPENSSL_LH_DOALL_FUNCARG)fn, (void *)arg); \\\n    } \\\n    LHASH_OF(type)\n\nDEFINE_LHASH_OF(OPENSSL_STRING);\n# ifdef _MSC_VER\n/*\n * push and pop this warning:\n *   warning C4090: 'function': different 'const' qualifiers\n */\n#  pragma warning (push)\n#  pragma warning (disable: 4090)\n# endif\n\nDEFINE_LHASH_OF(OPENSSL_CSTRING);\n\n# ifdef _MSC_VER\n#  pragma warning (pop)\n# endif\n\n/*\n * If called without higher optimization (min. -xO3) the Oracle Developer\n * Studio compiler generates code for the defined (static inline) functions\n * above.\n * This would later lead to the linker complaining about missing symbols when\n * this header file is included but the resulting object is not linked against\n * the Crypto library (openssl#6912).\n */\n# ifdef __SUNPRO_C\n#  pragma weak OPENSSL_LH_new\n#  pragma weak OPENSSL_LH_free\n#  pragma weak OPENSSL_LH_insert\n#  pragma weak OPENSSL_LH_delete\n#  pragma weak OPENSSL_LH_retrieve\n#  pragma weak OPENSSL_LH_error\n#  pragma weak OPENSSL_LH_num_items\n#  pragma weak OPENSSL_LH_node_stats_bio\n#  pragma weak OPENSSL_LH_node_usage_stats_bio\n#  pragma weak OPENSSL_LH_stats_bio\n#  pragma weak OPENSSL_LH_get_down_load\n#  pragma weak OPENSSL_LH_set_down_load\n#  pragma weak OPENSSL_LH_doall\n#  pragma weak OPENSSL_LH_doall_arg\n# endif /* __SUNPRO_C */\n\n#ifdef  __cplusplus\n}\n#endif\n\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/include/openssl/md2.h",
    "content": "/*\n * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef HEADER_MD2_H\n# define HEADER_MD2_H\n\n# include <openssl/opensslconf.h>\n\n# ifndef OPENSSL_NO_MD2\n# include <stddef.h>\n# ifdef  __cplusplus\nextern \"C\" {\n# endif\n\ntypedef unsigned char MD2_INT;\n\n# define MD2_DIGEST_LENGTH       16\n# define MD2_BLOCK               16\n\ntypedef struct MD2state_st {\n    unsigned int num;\n    unsigned char data[MD2_BLOCK];\n    MD2_INT cksm[MD2_BLOCK];\n    MD2_INT state[MD2_BLOCK];\n} MD2_CTX;\n\nconst char *MD2_options(void);\nint MD2_Init(MD2_CTX *c);\nint MD2_Update(MD2_CTX *c, const unsigned char *data, size_t len);\nint MD2_Final(unsigned char *md, MD2_CTX *c);\nunsigned char *MD2(const unsigned char *d, size_t n, unsigned char *md);\n\n# ifdef  __cplusplus\n}\n# endif\n# endif\n\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/include/openssl/md4.h",
    "content": "/*\n * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef HEADER_MD4_H\n# define HEADER_MD4_H\n\n# include <openssl/opensslconf.h>\n\n# ifndef OPENSSL_NO_MD4\n# include <openssl/e_os2.h>\n# include <stddef.h>\n# ifdef  __cplusplus\nextern \"C\" {\n# endif\n\n/*-\n * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n * ! MD4_LONG has to be at least 32 bits wide.                     !\n * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n */\n# define MD4_LONG unsigned int\n\n# define MD4_CBLOCK      64\n# define MD4_LBLOCK      (MD4_CBLOCK/4)\n# define MD4_DIGEST_LENGTH 16\n\ntypedef struct MD4state_st {\n    MD4_LONG A, B, C, D;\n    MD4_LONG Nl, Nh;\n    MD4_LONG data[MD4_LBLOCK];\n    unsigned int num;\n} MD4_CTX;\n\nint MD4_Init(MD4_CTX *c);\nint MD4_Update(MD4_CTX *c, const void *data, size_t len);\nint MD4_Final(unsigned char *md, MD4_CTX *c);\nunsigned char *MD4(const unsigned char *d, size_t n, unsigned char *md);\nvoid MD4_Transform(MD4_CTX *c, const unsigned char *b);\n\n# ifdef  __cplusplus\n}\n# endif\n# endif\n\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/include/openssl/md5.h",
    "content": "/*\n * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef HEADER_MD5_H\n# define HEADER_MD5_H\n\n# include <openssl/opensslconf.h>\n\n# ifndef OPENSSL_NO_MD5\n# include <openssl/e_os2.h>\n# include <stddef.h>\n# ifdef  __cplusplus\nextern \"C\" {\n# endif\n\n/*\n * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n * ! MD5_LONG has to be at least 32 bits wide.                     !\n * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n */\n# define MD5_LONG unsigned int\n\n# define MD5_CBLOCK      64\n# define MD5_LBLOCK      (MD5_CBLOCK/4)\n# define MD5_DIGEST_LENGTH 16\n\ntypedef struct MD5state_st {\n    MD5_LONG A, B, C, D;\n    MD5_LONG Nl, Nh;\n    MD5_LONG data[MD5_LBLOCK];\n    unsigned int num;\n} MD5_CTX;\n\nint MD5_Init(MD5_CTX *c);\nint MD5_Update(MD5_CTX *c, const void *data, size_t len);\nint MD5_Final(unsigned char *md, MD5_CTX *c);\nunsigned char *MD5(const unsigned char *d, size_t n, unsigned char *md);\nvoid MD5_Transform(MD5_CTX *c, const unsigned char *b);\n# ifdef  __cplusplus\n}\n# endif\n# endif\n\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/include/openssl/mdc2.h",
    "content": "/*\n * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef HEADER_MDC2_H\n# define HEADER_MDC2_H\n\n# include <openssl/opensslconf.h>\n\n#ifndef OPENSSL_NO_MDC2\n# include <stdlib.h>\n# include <openssl/des.h>\n# ifdef  __cplusplus\nextern \"C\" {\n# endif\n\n# define MDC2_BLOCK              8\n# define MDC2_DIGEST_LENGTH      16\n\ntypedef struct mdc2_ctx_st {\n    unsigned int num;\n    unsigned char data[MDC2_BLOCK];\n    DES_cblock h, hh;\n    int pad_type;               /* either 1 or 2, default 1 */\n} MDC2_CTX;\n\nint MDC2_Init(MDC2_CTX *c);\nint MDC2_Update(MDC2_CTX *c, const unsigned char *data, size_t len);\nint MDC2_Final(unsigned char *md, MDC2_CTX *c);\nunsigned char *MDC2(const unsigned char *d, size_t n, unsigned char *md);\n\n# ifdef  __cplusplus\n}\n# endif\n# endif\n\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/include/openssl/modes.h",
    "content": "/*\n * Copyright 2008-2016 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef HEADER_MODES_H\n# define HEADER_MODES_H\n\n# include <stddef.h>\n\n# ifdef  __cplusplus\nextern \"C\" {\n# endif\ntypedef void (*block128_f) (const unsigned char in[16],\n                            unsigned char out[16], const void *key);\n\ntypedef void (*cbc128_f) (const unsigned char *in, unsigned char *out,\n                          size_t len, const void *key,\n                          unsigned char ivec[16], int enc);\n\ntypedef void (*ctr128_f) (const unsigned char *in, unsigned char *out,\n                          size_t blocks, const void *key,\n                          const unsigned char ivec[16]);\n\ntypedef void (*ccm128_f) (const unsigned char *in, unsigned char *out,\n                          size_t blocks, const void *key,\n                          const unsigned char ivec[16],\n                          unsigned char cmac[16]);\n\nvoid CRYPTO_cbc128_encrypt(const unsigned char *in, unsigned char *out,\n                           size_t len, const void *key,\n                           unsigned char ivec[16], block128_f block);\nvoid CRYPTO_cbc128_decrypt(const unsigned char *in, unsigned char *out,\n                           size_t len, const void *key,\n                           unsigned char ivec[16], block128_f block);\n\nvoid CRYPTO_ctr128_encrypt(const unsigned char *in, unsigned char *out,\n                           size_t len, const void *key,\n                           unsigned char ivec[16],\n                           unsigned char ecount_buf[16], unsigned int *num,\n                           block128_f block);\n\nvoid CRYPTO_ctr128_encrypt_ctr32(const unsigned char *in, unsigned char *out,\n                                 size_t len, const void *key,\n                                 unsigned char ivec[16],\n                                 unsigned char ecount_buf[16],\n                                 unsigned int *num, ctr128_f ctr);\n\nvoid CRYPTO_ofb128_encrypt(const unsigned char *in, unsigned char *out,\n                           size_t len, const void *key,\n                           unsigned char ivec[16], int *num,\n                           block128_f block);\n\nvoid CRYPTO_cfb128_encrypt(const unsigned char *in, unsigned char *out,\n                           size_t len, const void *key,\n                           unsigned char ivec[16], int *num,\n                           int enc, block128_f block);\nvoid CRYPTO_cfb128_8_encrypt(const unsigned char *in, unsigned char *out,\n                             size_t length, const void *key,\n                             unsigned char ivec[16], int *num,\n                             int enc, block128_f block);\nvoid CRYPTO_cfb128_1_encrypt(const unsigned char *in, unsigned char *out,\n                             size_t bits, const void *key,\n                             unsigned char ivec[16], int *num,\n                             int enc, block128_f block);\n\nsize_t CRYPTO_cts128_encrypt_block(const unsigned char *in,\n                                   unsigned char *out, size_t len,\n                                   const void *key, unsigned char ivec[16],\n                                   block128_f block);\nsize_t CRYPTO_cts128_encrypt(const unsigned char *in, unsigned char *out,\n                             size_t len, const void *key,\n                             unsigned char ivec[16], cbc128_f cbc);\nsize_t CRYPTO_cts128_decrypt_block(const unsigned char *in,\n                                   unsigned char *out, size_t len,\n                                   const void *key, unsigned char ivec[16],\n                                   block128_f block);\nsize_t CRYPTO_cts128_decrypt(const unsigned char *in, unsigned char *out,\n                             size_t len, const void *key,\n                             unsigned char ivec[16], cbc128_f cbc);\n\nsize_t CRYPTO_nistcts128_encrypt_block(const unsigned char *in,\n                                       unsigned char *out, size_t len,\n                                       const void *key,\n                                       unsigned char ivec[16],\n                                       block128_f block);\nsize_t CRYPTO_nistcts128_encrypt(const unsigned char *in, unsigned char *out,\n                                 size_t len, const void *key,\n                                 unsigned char ivec[16], cbc128_f cbc);\nsize_t CRYPTO_nistcts128_decrypt_block(const unsigned char *in,\n                                       unsigned char *out, size_t len,\n                                       const void *key,\n                                       unsigned char ivec[16],\n                                       block128_f block);\nsize_t CRYPTO_nistcts128_decrypt(const unsigned char *in, unsigned char *out,\n                                 size_t len, const void *key,\n                                 unsigned char ivec[16], cbc128_f cbc);\n\ntypedef struct gcm128_context GCM128_CONTEXT;\n\nGCM128_CONTEXT *CRYPTO_gcm128_new(void *key, block128_f block);\nvoid CRYPTO_gcm128_init(GCM128_CONTEXT *ctx, void *key, block128_f block);\nvoid CRYPTO_gcm128_setiv(GCM128_CONTEXT *ctx, const unsigned char *iv,\n                         size_t len);\nint CRYPTO_gcm128_aad(GCM128_CONTEXT *ctx, const unsigned char *aad,\n                      size_t len);\nint CRYPTO_gcm128_encrypt(GCM128_CONTEXT *ctx,\n                          const unsigned char *in, unsigned char *out,\n                          size_t len);\nint CRYPTO_gcm128_decrypt(GCM128_CONTEXT *ctx,\n                          const unsigned char *in, unsigned char *out,\n                          size_t len);\nint CRYPTO_gcm128_encrypt_ctr32(GCM128_CONTEXT *ctx,\n                                const unsigned char *in, unsigned char *out,\n                                size_t len, ctr128_f stream);\nint CRYPTO_gcm128_decrypt_ctr32(GCM128_CONTEXT *ctx,\n                                const unsigned char *in, unsigned char *out,\n                                size_t len, ctr128_f stream);\nint CRYPTO_gcm128_finish(GCM128_CONTEXT *ctx, const unsigned char *tag,\n                         size_t len);\nvoid CRYPTO_gcm128_tag(GCM128_CONTEXT *ctx, unsigned char *tag, size_t len);\nvoid CRYPTO_gcm128_release(GCM128_CONTEXT *ctx);\n\ntypedef struct ccm128_context CCM128_CONTEXT;\n\nvoid CRYPTO_ccm128_init(CCM128_CONTEXT *ctx,\n                        unsigned int M, unsigned int L, void *key,\n                        block128_f block);\nint CRYPTO_ccm128_setiv(CCM128_CONTEXT *ctx, const unsigned char *nonce,\n                        size_t nlen, size_t mlen);\nvoid CRYPTO_ccm128_aad(CCM128_CONTEXT *ctx, const unsigned char *aad,\n                       size_t alen);\nint CRYPTO_ccm128_encrypt(CCM128_CONTEXT *ctx, const unsigned char *inp,\n                          unsigned char *out, size_t len);\nint CRYPTO_ccm128_decrypt(CCM128_CONTEXT *ctx, const unsigned char *inp,\n                          unsigned char *out, size_t len);\nint CRYPTO_ccm128_encrypt_ccm64(CCM128_CONTEXT *ctx, const unsigned char *inp,\n                                unsigned char *out, size_t len,\n                                ccm128_f stream);\nint CRYPTO_ccm128_decrypt_ccm64(CCM128_CONTEXT *ctx, const unsigned char *inp,\n                                unsigned char *out, size_t len,\n                                ccm128_f stream);\nsize_t CRYPTO_ccm128_tag(CCM128_CONTEXT *ctx, unsigned char *tag, size_t len);\n\ntypedef struct xts128_context XTS128_CONTEXT;\n\nint CRYPTO_xts128_encrypt(const XTS128_CONTEXT *ctx,\n                          const unsigned char iv[16],\n                          const unsigned char *inp, unsigned char *out,\n                          size_t len, int enc);\n\nsize_t CRYPTO_128_wrap(void *key, const unsigned char *iv,\n                       unsigned char *out,\n                       const unsigned char *in, size_t inlen,\n                       block128_f block);\n\nsize_t CRYPTO_128_unwrap(void *key, const unsigned char *iv,\n                         unsigned char *out,\n                         const unsigned char *in, size_t inlen,\n                         block128_f block);\nsize_t CRYPTO_128_wrap_pad(void *key, const unsigned char *icv,\n                           unsigned char *out, const unsigned char *in,\n                           size_t inlen, block128_f block);\nsize_t CRYPTO_128_unwrap_pad(void *key, const unsigned char *icv,\n                             unsigned char *out, const unsigned char *in,\n                             size_t inlen, block128_f block);\n\n# ifndef OPENSSL_NO_OCB\ntypedef struct ocb128_context OCB128_CONTEXT;\n\ntypedef void (*ocb128_f) (const unsigned char *in, unsigned char *out,\n                          size_t blocks, const void *key,\n                          size_t start_block_num,\n                          unsigned char offset_i[16],\n                          const unsigned char L_[][16],\n                          unsigned char checksum[16]);\n\nOCB128_CONTEXT *CRYPTO_ocb128_new(void *keyenc, void *keydec,\n                                  block128_f encrypt, block128_f decrypt,\n                                  ocb128_f stream);\nint CRYPTO_ocb128_init(OCB128_CONTEXT *ctx, void *keyenc, void *keydec,\n                       block128_f encrypt, block128_f decrypt,\n                       ocb128_f stream);\nint CRYPTO_ocb128_copy_ctx(OCB128_CONTEXT *dest, OCB128_CONTEXT *src,\n                           void *keyenc, void *keydec);\nint CRYPTO_ocb128_setiv(OCB128_CONTEXT *ctx, const unsigned char *iv,\n                        size_t len, size_t taglen);\nint CRYPTO_ocb128_aad(OCB128_CONTEXT *ctx, const unsigned char *aad,\n                      size_t len);\nint CRYPTO_ocb128_encrypt(OCB128_CONTEXT *ctx, const unsigned char *in,\n                          unsigned char *out, size_t len);\nint CRYPTO_ocb128_decrypt(OCB128_CONTEXT *ctx, const unsigned char *in,\n                          unsigned char *out, size_t len);\nint CRYPTO_ocb128_finish(OCB128_CONTEXT *ctx, const unsigned char *tag,\n                         size_t len);\nint CRYPTO_ocb128_tag(OCB128_CONTEXT *ctx, unsigned char *tag, size_t len);\nvoid CRYPTO_ocb128_cleanup(OCB128_CONTEXT *ctx);\n# endif                          /* OPENSSL_NO_OCB */\n\n# ifdef  __cplusplus\n}\n# endif\n\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/include/openssl/obj_mac.h",
    "content": "/*\n * WARNING: do not edit!\n * Generated by crypto/objects/objects.pl\n *\n * Copyright 2000-2021 The OpenSSL Project Authors. All Rights Reserved.\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#define SN_undef                        \"UNDEF\"\n#define LN_undef                        \"undefined\"\n#define NID_undef                       0\n#define OBJ_undef                       0L\n\n#define SN_itu_t                \"ITU-T\"\n#define LN_itu_t                \"itu-t\"\n#define NID_itu_t               645\n#define OBJ_itu_t               0L\n\n#define NID_ccitt               404\n#define OBJ_ccitt               OBJ_itu_t\n\n#define SN_iso          \"ISO\"\n#define LN_iso          \"iso\"\n#define NID_iso         181\n#define OBJ_iso         1L\n\n#define SN_joint_iso_itu_t              \"JOINT-ISO-ITU-T\"\n#define LN_joint_iso_itu_t              \"joint-iso-itu-t\"\n#define NID_joint_iso_itu_t             646\n#define OBJ_joint_iso_itu_t             2L\n\n#define NID_joint_iso_ccitt             393\n#define OBJ_joint_iso_ccitt             OBJ_joint_iso_itu_t\n\n#define SN_member_body          \"member-body\"\n#define LN_member_body          \"ISO Member Body\"\n#define NID_member_body         182\n#define OBJ_member_body         OBJ_iso,2L\n\n#define SN_identified_organization              \"identified-organization\"\n#define NID_identified_organization             676\n#define OBJ_identified_organization             OBJ_iso,3L\n\n#define SN_hmac_md5             \"HMAC-MD5\"\n#define LN_hmac_md5             \"hmac-md5\"\n#define NID_hmac_md5            780\n#define OBJ_hmac_md5            OBJ_identified_organization,6L,1L,5L,5L,8L,1L,1L\n\n#define SN_hmac_sha1            \"HMAC-SHA1\"\n#define LN_hmac_sha1            \"hmac-sha1\"\n#define NID_hmac_sha1           781\n#define OBJ_hmac_sha1           OBJ_identified_organization,6L,1L,5L,5L,8L,1L,2L\n\n#define SN_x509ExtAdmission             \"x509ExtAdmission\"\n#define LN_x509ExtAdmission             \"Professional Information or basis for Admission\"\n#define NID_x509ExtAdmission            1093\n#define OBJ_x509ExtAdmission            OBJ_identified_organization,36L,8L,3L,3L\n\n#define SN_certicom_arc         \"certicom-arc\"\n#define NID_certicom_arc                677\n#define OBJ_certicom_arc                OBJ_identified_organization,132L\n\n#define SN_ieee         \"ieee\"\n#define NID_ieee                1170\n#define OBJ_ieee                OBJ_identified_organization,111L\n\n#define SN_ieee_siswg           \"ieee-siswg\"\n#define LN_ieee_siswg           \"IEEE Security in Storage Working Group\"\n#define NID_ieee_siswg          1171\n#define OBJ_ieee_siswg          OBJ_ieee,2L,1619L\n\n#define SN_international_organizations          \"international-organizations\"\n#define LN_international_organizations          \"International Organizations\"\n#define NID_international_organizations         647\n#define OBJ_international_organizations         OBJ_joint_iso_itu_t,23L\n\n#define SN_wap          \"wap\"\n#define NID_wap         678\n#define OBJ_wap         OBJ_international_organizations,43L\n\n#define SN_wap_wsg              \"wap-wsg\"\n#define NID_wap_wsg             679\n#define OBJ_wap_wsg             OBJ_wap,1L\n\n#define SN_selected_attribute_types             \"selected-attribute-types\"\n#define LN_selected_attribute_types             \"Selected Attribute Types\"\n#define NID_selected_attribute_types            394\n#define OBJ_selected_attribute_types            OBJ_joint_iso_itu_t,5L,1L,5L\n\n#define SN_clearance            \"clearance\"\n#define NID_clearance           395\n#define OBJ_clearance           OBJ_selected_attribute_types,55L\n\n#define SN_ISO_US               \"ISO-US\"\n#define LN_ISO_US               \"ISO US Member Body\"\n#define NID_ISO_US              183\n#define OBJ_ISO_US              OBJ_member_body,840L\n\n#define SN_X9_57                \"X9-57\"\n#define LN_X9_57                \"X9.57\"\n#define NID_X9_57               184\n#define OBJ_X9_57               OBJ_ISO_US,10040L\n\n#define SN_X9cm         \"X9cm\"\n#define LN_X9cm         \"X9.57 CM ?\"\n#define NID_X9cm                185\n#define OBJ_X9cm                OBJ_X9_57,4L\n\n#define SN_ISO_CN               \"ISO-CN\"\n#define LN_ISO_CN               \"ISO CN Member Body\"\n#define NID_ISO_CN              1140\n#define OBJ_ISO_CN              OBJ_member_body,156L\n\n#define SN_oscca                \"oscca\"\n#define NID_oscca               1141\n#define OBJ_oscca               OBJ_ISO_CN,10197L\n\n#define SN_sm_scheme            \"sm-scheme\"\n#define NID_sm_scheme           1142\n#define OBJ_sm_scheme           OBJ_oscca,1L\n\n#define SN_dsa          \"DSA\"\n#define LN_dsa          \"dsaEncryption\"\n#define NID_dsa         116\n#define OBJ_dsa         OBJ_X9cm,1L\n\n#define SN_dsaWithSHA1          \"DSA-SHA1\"\n#define LN_dsaWithSHA1          \"dsaWithSHA1\"\n#define NID_dsaWithSHA1         113\n#define OBJ_dsaWithSHA1         OBJ_X9cm,3L\n\n#define SN_ansi_X9_62           \"ansi-X9-62\"\n#define LN_ansi_X9_62           \"ANSI X9.62\"\n#define NID_ansi_X9_62          405\n#define OBJ_ansi_X9_62          OBJ_ISO_US,10045L\n\n#define OBJ_X9_62_id_fieldType          OBJ_ansi_X9_62,1L\n\n#define SN_X9_62_prime_field            \"prime-field\"\n#define NID_X9_62_prime_field           406\n#define OBJ_X9_62_prime_field           OBJ_X9_62_id_fieldType,1L\n\n#define SN_X9_62_characteristic_two_field               \"characteristic-two-field\"\n#define NID_X9_62_characteristic_two_field              407\n#define OBJ_X9_62_characteristic_two_field              OBJ_X9_62_id_fieldType,2L\n\n#define SN_X9_62_id_characteristic_two_basis            \"id-characteristic-two-basis\"\n#define NID_X9_62_id_characteristic_two_basis           680\n#define OBJ_X9_62_id_characteristic_two_basis           OBJ_X9_62_characteristic_two_field,3L\n\n#define SN_X9_62_onBasis                \"onBasis\"\n#define NID_X9_62_onBasis               681\n#define OBJ_X9_62_onBasis               OBJ_X9_62_id_characteristic_two_basis,1L\n\n#define SN_X9_62_tpBasis                \"tpBasis\"\n#define NID_X9_62_tpBasis               682\n#define OBJ_X9_62_tpBasis               OBJ_X9_62_id_characteristic_two_basis,2L\n\n#define SN_X9_62_ppBasis                \"ppBasis\"\n#define NID_X9_62_ppBasis               683\n#define OBJ_X9_62_ppBasis               OBJ_X9_62_id_characteristic_two_basis,3L\n\n#define OBJ_X9_62_id_publicKeyType              OBJ_ansi_X9_62,2L\n\n#define SN_X9_62_id_ecPublicKey         \"id-ecPublicKey\"\n#define NID_X9_62_id_ecPublicKey                408\n#define OBJ_X9_62_id_ecPublicKey                OBJ_X9_62_id_publicKeyType,1L\n\n#define OBJ_X9_62_ellipticCurve         OBJ_ansi_X9_62,3L\n\n#define OBJ_X9_62_c_TwoCurve            OBJ_X9_62_ellipticCurve,0L\n\n#define SN_X9_62_c2pnb163v1             \"c2pnb163v1\"\n#define NID_X9_62_c2pnb163v1            684\n#define OBJ_X9_62_c2pnb163v1            OBJ_X9_62_c_TwoCurve,1L\n\n#define SN_X9_62_c2pnb163v2             \"c2pnb163v2\"\n#define NID_X9_62_c2pnb163v2            685\n#define OBJ_X9_62_c2pnb163v2            OBJ_X9_62_c_TwoCurve,2L\n\n#define SN_X9_62_c2pnb163v3             \"c2pnb163v3\"\n#define NID_X9_62_c2pnb163v3            686\n#define OBJ_X9_62_c2pnb163v3            OBJ_X9_62_c_TwoCurve,3L\n\n#define SN_X9_62_c2pnb176v1             \"c2pnb176v1\"\n#define NID_X9_62_c2pnb176v1            687\n#define OBJ_X9_62_c2pnb176v1            OBJ_X9_62_c_TwoCurve,4L\n\n#define SN_X9_62_c2tnb191v1             \"c2tnb191v1\"\n#define NID_X9_62_c2tnb191v1            688\n#define OBJ_X9_62_c2tnb191v1            OBJ_X9_62_c_TwoCurve,5L\n\n#define SN_X9_62_c2tnb191v2             \"c2tnb191v2\"\n#define NID_X9_62_c2tnb191v2            689\n#define OBJ_X9_62_c2tnb191v2            OBJ_X9_62_c_TwoCurve,6L\n\n#define SN_X9_62_c2tnb191v3             \"c2tnb191v3\"\n#define NID_X9_62_c2tnb191v3            690\n#define OBJ_X9_62_c2tnb191v3            OBJ_X9_62_c_TwoCurve,7L\n\n#define SN_X9_62_c2onb191v4             \"c2onb191v4\"\n#define NID_X9_62_c2onb191v4            691\n#define OBJ_X9_62_c2onb191v4            OBJ_X9_62_c_TwoCurve,8L\n\n#define SN_X9_62_c2onb191v5             \"c2onb191v5\"\n#define NID_X9_62_c2onb191v5            692\n#define OBJ_X9_62_c2onb191v5            OBJ_X9_62_c_TwoCurve,9L\n\n#define SN_X9_62_c2pnb208w1             \"c2pnb208w1\"\n#define NID_X9_62_c2pnb208w1            693\n#define OBJ_X9_62_c2pnb208w1            OBJ_X9_62_c_TwoCurve,10L\n\n#define SN_X9_62_c2tnb239v1             \"c2tnb239v1\"\n#define NID_X9_62_c2tnb239v1            694\n#define OBJ_X9_62_c2tnb239v1            OBJ_X9_62_c_TwoCurve,11L\n\n#define SN_X9_62_c2tnb239v2             \"c2tnb239v2\"\n#define NID_X9_62_c2tnb239v2            695\n#define OBJ_X9_62_c2tnb239v2            OBJ_X9_62_c_TwoCurve,12L\n\n#define SN_X9_62_c2tnb239v3             \"c2tnb239v3\"\n#define NID_X9_62_c2tnb239v3            696\n#define OBJ_X9_62_c2tnb239v3            OBJ_X9_62_c_TwoCurve,13L\n\n#define SN_X9_62_c2onb239v4             \"c2onb239v4\"\n#define NID_X9_62_c2onb239v4            697\n#define OBJ_X9_62_c2onb239v4            OBJ_X9_62_c_TwoCurve,14L\n\n#define SN_X9_62_c2onb239v5             \"c2onb239v5\"\n#define NID_X9_62_c2onb239v5            698\n#define OBJ_X9_62_c2onb239v5            OBJ_X9_62_c_TwoCurve,15L\n\n#define SN_X9_62_c2pnb272w1             \"c2pnb272w1\"\n#define NID_X9_62_c2pnb272w1            699\n#define OBJ_X9_62_c2pnb272w1            OBJ_X9_62_c_TwoCurve,16L\n\n#define SN_X9_62_c2pnb304w1             \"c2pnb304w1\"\n#define NID_X9_62_c2pnb304w1            700\n#define OBJ_X9_62_c2pnb304w1            OBJ_X9_62_c_TwoCurve,17L\n\n#define SN_X9_62_c2tnb359v1             \"c2tnb359v1\"\n#define NID_X9_62_c2tnb359v1            701\n#define OBJ_X9_62_c2tnb359v1            OBJ_X9_62_c_TwoCurve,18L\n\n#define SN_X9_62_c2pnb368w1             \"c2pnb368w1\"\n#define NID_X9_62_c2pnb368w1            702\n#define OBJ_X9_62_c2pnb368w1            OBJ_X9_62_c_TwoCurve,19L\n\n#define SN_X9_62_c2tnb431r1             \"c2tnb431r1\"\n#define NID_X9_62_c2tnb431r1            703\n#define OBJ_X9_62_c2tnb431r1            OBJ_X9_62_c_TwoCurve,20L\n\n#define OBJ_X9_62_primeCurve            OBJ_X9_62_ellipticCurve,1L\n\n#define SN_X9_62_prime192v1             \"prime192v1\"\n#define NID_X9_62_prime192v1            409\n#define OBJ_X9_62_prime192v1            OBJ_X9_62_primeCurve,1L\n\n#define SN_X9_62_prime192v2             \"prime192v2\"\n#define NID_X9_62_prime192v2            410\n#define OBJ_X9_62_prime192v2            OBJ_X9_62_primeCurve,2L\n\n#define SN_X9_62_prime192v3             \"prime192v3\"\n#define NID_X9_62_prime192v3            411\n#define OBJ_X9_62_prime192v3            OBJ_X9_62_primeCurve,3L\n\n#define SN_X9_62_prime239v1             \"prime239v1\"\n#define NID_X9_62_prime239v1            412\n#define OBJ_X9_62_prime239v1            OBJ_X9_62_primeCurve,4L\n\n#define SN_X9_62_prime239v2             \"prime239v2\"\n#define NID_X9_62_prime239v2            413\n#define OBJ_X9_62_prime239v2            OBJ_X9_62_primeCurve,5L\n\n#define SN_X9_62_prime239v3             \"prime239v3\"\n#define NID_X9_62_prime239v3            414\n#define OBJ_X9_62_prime239v3            OBJ_X9_62_primeCurve,6L\n\n#define SN_X9_62_prime256v1             \"prime256v1\"\n#define NID_X9_62_prime256v1            415\n#define OBJ_X9_62_prime256v1            OBJ_X9_62_primeCurve,7L\n\n#define OBJ_X9_62_id_ecSigType          OBJ_ansi_X9_62,4L\n\n#define SN_ecdsa_with_SHA1              \"ecdsa-with-SHA1\"\n#define NID_ecdsa_with_SHA1             416\n#define OBJ_ecdsa_with_SHA1             OBJ_X9_62_id_ecSigType,1L\n\n#define SN_ecdsa_with_Recommended               \"ecdsa-with-Recommended\"\n#define NID_ecdsa_with_Recommended              791\n#define OBJ_ecdsa_with_Recommended              OBJ_X9_62_id_ecSigType,2L\n\n#define SN_ecdsa_with_Specified         \"ecdsa-with-Specified\"\n#define NID_ecdsa_with_Specified                792\n#define OBJ_ecdsa_with_Specified                OBJ_X9_62_id_ecSigType,3L\n\n#define SN_ecdsa_with_SHA224            \"ecdsa-with-SHA224\"\n#define NID_ecdsa_with_SHA224           793\n#define OBJ_ecdsa_with_SHA224           OBJ_ecdsa_with_Specified,1L\n\n#define SN_ecdsa_with_SHA256            \"ecdsa-with-SHA256\"\n#define NID_ecdsa_with_SHA256           794\n#define OBJ_ecdsa_with_SHA256           OBJ_ecdsa_with_Specified,2L\n\n#define SN_ecdsa_with_SHA384            \"ecdsa-with-SHA384\"\n#define NID_ecdsa_with_SHA384           795\n#define OBJ_ecdsa_with_SHA384           OBJ_ecdsa_with_Specified,3L\n\n#define SN_ecdsa_with_SHA512            \"ecdsa-with-SHA512\"\n#define NID_ecdsa_with_SHA512           796\n#define OBJ_ecdsa_with_SHA512           OBJ_ecdsa_with_Specified,4L\n\n#define OBJ_secg_ellipticCurve          OBJ_certicom_arc,0L\n\n#define SN_secp112r1            \"secp112r1\"\n#define NID_secp112r1           704\n#define OBJ_secp112r1           OBJ_secg_ellipticCurve,6L\n\n#define SN_secp112r2            \"secp112r2\"\n#define NID_secp112r2           705\n#define OBJ_secp112r2           OBJ_secg_ellipticCurve,7L\n\n#define SN_secp128r1            \"secp128r1\"\n#define NID_secp128r1           706\n#define OBJ_secp128r1           OBJ_secg_ellipticCurve,28L\n\n#define SN_secp128r2            \"secp128r2\"\n#define NID_secp128r2           707\n#define OBJ_secp128r2           OBJ_secg_ellipticCurve,29L\n\n#define SN_secp160k1            \"secp160k1\"\n#define NID_secp160k1           708\n#define OBJ_secp160k1           OBJ_secg_ellipticCurve,9L\n\n#define SN_secp160r1            \"secp160r1\"\n#define NID_secp160r1           709\n#define OBJ_secp160r1           OBJ_secg_ellipticCurve,8L\n\n#define SN_secp160r2            \"secp160r2\"\n#define NID_secp160r2           710\n#define OBJ_secp160r2           OBJ_secg_ellipticCurve,30L\n\n#define SN_secp192k1            \"secp192k1\"\n#define NID_secp192k1           711\n#define OBJ_secp192k1           OBJ_secg_ellipticCurve,31L\n\n#define SN_secp224k1            \"secp224k1\"\n#define NID_secp224k1           712\n#define OBJ_secp224k1           OBJ_secg_ellipticCurve,32L\n\n#define SN_secp224r1            \"secp224r1\"\n#define NID_secp224r1           713\n#define OBJ_secp224r1           OBJ_secg_ellipticCurve,33L\n\n#define SN_secp256k1            \"secp256k1\"\n#define NID_secp256k1           714\n#define OBJ_secp256k1           OBJ_secg_ellipticCurve,10L\n\n#define SN_secp384r1            \"secp384r1\"\n#define NID_secp384r1           715\n#define OBJ_secp384r1           OBJ_secg_ellipticCurve,34L\n\n#define SN_secp521r1            \"secp521r1\"\n#define NID_secp521r1           716\n#define OBJ_secp521r1           OBJ_secg_ellipticCurve,35L\n\n#define SN_sect113r1            \"sect113r1\"\n#define NID_sect113r1           717\n#define OBJ_sect113r1           OBJ_secg_ellipticCurve,4L\n\n#define SN_sect113r2            \"sect113r2\"\n#define NID_sect113r2           718\n#define OBJ_sect113r2           OBJ_secg_ellipticCurve,5L\n\n#define SN_sect131r1            \"sect131r1\"\n#define NID_sect131r1           719\n#define OBJ_sect131r1           OBJ_secg_ellipticCurve,22L\n\n#define SN_sect131r2            \"sect131r2\"\n#define NID_sect131r2           720\n#define OBJ_sect131r2           OBJ_secg_ellipticCurve,23L\n\n#define SN_sect163k1            \"sect163k1\"\n#define NID_sect163k1           721\n#define OBJ_sect163k1           OBJ_secg_ellipticCurve,1L\n\n#define SN_sect163r1            \"sect163r1\"\n#define NID_sect163r1           722\n#define OBJ_sect163r1           OBJ_secg_ellipticCurve,2L\n\n#define SN_sect163r2            \"sect163r2\"\n#define NID_sect163r2           723\n#define OBJ_sect163r2           OBJ_secg_ellipticCurve,15L\n\n#define SN_sect193r1            \"sect193r1\"\n#define NID_sect193r1           724\n#define OBJ_sect193r1           OBJ_secg_ellipticCurve,24L\n\n#define SN_sect193r2            \"sect193r2\"\n#define NID_sect193r2           725\n#define OBJ_sect193r2           OBJ_secg_ellipticCurve,25L\n\n#define SN_sect233k1            \"sect233k1\"\n#define NID_sect233k1           726\n#define OBJ_sect233k1           OBJ_secg_ellipticCurve,26L\n\n#define SN_sect233r1            \"sect233r1\"\n#define NID_sect233r1           727\n#define OBJ_sect233r1           OBJ_secg_ellipticCurve,27L\n\n#define SN_sect239k1            \"sect239k1\"\n#define NID_sect239k1           728\n#define OBJ_sect239k1           OBJ_secg_ellipticCurve,3L\n\n#define SN_sect283k1            \"sect283k1\"\n#define NID_sect283k1           729\n#define OBJ_sect283k1           OBJ_secg_ellipticCurve,16L\n\n#define SN_sect283r1            \"sect283r1\"\n#define NID_sect283r1           730\n#define OBJ_sect283r1           OBJ_secg_ellipticCurve,17L\n\n#define SN_sect409k1            \"sect409k1\"\n#define NID_sect409k1           731\n#define OBJ_sect409k1           OBJ_secg_ellipticCurve,36L\n\n#define SN_sect409r1            \"sect409r1\"\n#define NID_sect409r1           732\n#define OBJ_sect409r1           OBJ_secg_ellipticCurve,37L\n\n#define SN_sect571k1            \"sect571k1\"\n#define NID_sect571k1           733\n#define OBJ_sect571k1           OBJ_secg_ellipticCurve,38L\n\n#define SN_sect571r1            \"sect571r1\"\n#define NID_sect571r1           734\n#define OBJ_sect571r1           OBJ_secg_ellipticCurve,39L\n\n#define OBJ_wap_wsg_idm_ecid            OBJ_wap_wsg,4L\n\n#define SN_wap_wsg_idm_ecid_wtls1               \"wap-wsg-idm-ecid-wtls1\"\n#define NID_wap_wsg_idm_ecid_wtls1              735\n#define OBJ_wap_wsg_idm_ecid_wtls1              OBJ_wap_wsg_idm_ecid,1L\n\n#define SN_wap_wsg_idm_ecid_wtls3               \"wap-wsg-idm-ecid-wtls3\"\n#define NID_wap_wsg_idm_ecid_wtls3              736\n#define OBJ_wap_wsg_idm_ecid_wtls3              OBJ_wap_wsg_idm_ecid,3L\n\n#define SN_wap_wsg_idm_ecid_wtls4               \"wap-wsg-idm-ecid-wtls4\"\n#define NID_wap_wsg_idm_ecid_wtls4              737\n#define OBJ_wap_wsg_idm_ecid_wtls4              OBJ_wap_wsg_idm_ecid,4L\n\n#define SN_wap_wsg_idm_ecid_wtls5               \"wap-wsg-idm-ecid-wtls5\"\n#define NID_wap_wsg_idm_ecid_wtls5              738\n#define OBJ_wap_wsg_idm_ecid_wtls5              OBJ_wap_wsg_idm_ecid,5L\n\n#define SN_wap_wsg_idm_ecid_wtls6               \"wap-wsg-idm-ecid-wtls6\"\n#define NID_wap_wsg_idm_ecid_wtls6              739\n#define OBJ_wap_wsg_idm_ecid_wtls6              OBJ_wap_wsg_idm_ecid,6L\n\n#define SN_wap_wsg_idm_ecid_wtls7               \"wap-wsg-idm-ecid-wtls7\"\n#define NID_wap_wsg_idm_ecid_wtls7              740\n#define OBJ_wap_wsg_idm_ecid_wtls7              OBJ_wap_wsg_idm_ecid,7L\n\n#define SN_wap_wsg_idm_ecid_wtls8               \"wap-wsg-idm-ecid-wtls8\"\n#define NID_wap_wsg_idm_ecid_wtls8              741\n#define OBJ_wap_wsg_idm_ecid_wtls8              OBJ_wap_wsg_idm_ecid,8L\n\n#define SN_wap_wsg_idm_ecid_wtls9               \"wap-wsg-idm-ecid-wtls9\"\n#define NID_wap_wsg_idm_ecid_wtls9              742\n#define OBJ_wap_wsg_idm_ecid_wtls9              OBJ_wap_wsg_idm_ecid,9L\n\n#define SN_wap_wsg_idm_ecid_wtls10              \"wap-wsg-idm-ecid-wtls10\"\n#define NID_wap_wsg_idm_ecid_wtls10             743\n#define OBJ_wap_wsg_idm_ecid_wtls10             OBJ_wap_wsg_idm_ecid,10L\n\n#define SN_wap_wsg_idm_ecid_wtls11              \"wap-wsg-idm-ecid-wtls11\"\n#define NID_wap_wsg_idm_ecid_wtls11             744\n#define OBJ_wap_wsg_idm_ecid_wtls11             OBJ_wap_wsg_idm_ecid,11L\n\n#define SN_wap_wsg_idm_ecid_wtls12              \"wap-wsg-idm-ecid-wtls12\"\n#define NID_wap_wsg_idm_ecid_wtls12             745\n#define OBJ_wap_wsg_idm_ecid_wtls12             OBJ_wap_wsg_idm_ecid,12L\n\n#define SN_cast5_cbc            \"CAST5-CBC\"\n#define LN_cast5_cbc            \"cast5-cbc\"\n#define NID_cast5_cbc           108\n#define OBJ_cast5_cbc           OBJ_ISO_US,113533L,7L,66L,10L\n\n#define SN_cast5_ecb            \"CAST5-ECB\"\n#define LN_cast5_ecb            \"cast5-ecb\"\n#define NID_cast5_ecb           109\n\n#define SN_cast5_cfb64          \"CAST5-CFB\"\n#define LN_cast5_cfb64          \"cast5-cfb\"\n#define NID_cast5_cfb64         110\n\n#define SN_cast5_ofb64          \"CAST5-OFB\"\n#define LN_cast5_ofb64          \"cast5-ofb\"\n#define NID_cast5_ofb64         111\n\n#define LN_pbeWithMD5AndCast5_CBC               \"pbeWithMD5AndCast5CBC\"\n#define NID_pbeWithMD5AndCast5_CBC              112\n#define OBJ_pbeWithMD5AndCast5_CBC              OBJ_ISO_US,113533L,7L,66L,12L\n\n#define SN_id_PasswordBasedMAC          \"id-PasswordBasedMAC\"\n#define LN_id_PasswordBasedMAC          \"password based MAC\"\n#define NID_id_PasswordBasedMAC         782\n#define OBJ_id_PasswordBasedMAC         OBJ_ISO_US,113533L,7L,66L,13L\n\n#define SN_id_DHBasedMac                \"id-DHBasedMac\"\n#define LN_id_DHBasedMac                \"Diffie-Hellman based MAC\"\n#define NID_id_DHBasedMac               783\n#define OBJ_id_DHBasedMac               OBJ_ISO_US,113533L,7L,66L,30L\n\n#define SN_rsadsi               \"rsadsi\"\n#define LN_rsadsi               \"RSA Data Security, Inc.\"\n#define NID_rsadsi              1\n#define OBJ_rsadsi              OBJ_ISO_US,113549L\n\n#define SN_pkcs         \"pkcs\"\n#define LN_pkcs         \"RSA Data Security, Inc. PKCS\"\n#define NID_pkcs                2\n#define OBJ_pkcs                OBJ_rsadsi,1L\n\n#define SN_pkcs1                \"pkcs1\"\n#define NID_pkcs1               186\n#define OBJ_pkcs1               OBJ_pkcs,1L\n\n#define LN_rsaEncryption                \"rsaEncryption\"\n#define NID_rsaEncryption               6\n#define OBJ_rsaEncryption               OBJ_pkcs1,1L\n\n#define SN_md2WithRSAEncryption         \"RSA-MD2\"\n#define LN_md2WithRSAEncryption         \"md2WithRSAEncryption\"\n#define NID_md2WithRSAEncryption                7\n#define OBJ_md2WithRSAEncryption                OBJ_pkcs1,2L\n\n#define SN_md4WithRSAEncryption         \"RSA-MD4\"\n#define LN_md4WithRSAEncryption         \"md4WithRSAEncryption\"\n#define NID_md4WithRSAEncryption                396\n#define OBJ_md4WithRSAEncryption                OBJ_pkcs1,3L\n\n#define SN_md5WithRSAEncryption         \"RSA-MD5\"\n#define LN_md5WithRSAEncryption         \"md5WithRSAEncryption\"\n#define NID_md5WithRSAEncryption                8\n#define OBJ_md5WithRSAEncryption                OBJ_pkcs1,4L\n\n#define SN_sha1WithRSAEncryption                \"RSA-SHA1\"\n#define LN_sha1WithRSAEncryption                \"sha1WithRSAEncryption\"\n#define NID_sha1WithRSAEncryption               65\n#define OBJ_sha1WithRSAEncryption               OBJ_pkcs1,5L\n\n#define SN_rsaesOaep            \"RSAES-OAEP\"\n#define LN_rsaesOaep            \"rsaesOaep\"\n#define NID_rsaesOaep           919\n#define OBJ_rsaesOaep           OBJ_pkcs1,7L\n\n#define SN_mgf1         \"MGF1\"\n#define LN_mgf1         \"mgf1\"\n#define NID_mgf1                911\n#define OBJ_mgf1                OBJ_pkcs1,8L\n\n#define SN_pSpecified           \"PSPECIFIED\"\n#define LN_pSpecified           \"pSpecified\"\n#define NID_pSpecified          935\n#define OBJ_pSpecified          OBJ_pkcs1,9L\n\n#define SN_rsassaPss            \"RSASSA-PSS\"\n#define LN_rsassaPss            \"rsassaPss\"\n#define NID_rsassaPss           912\n#define OBJ_rsassaPss           OBJ_pkcs1,10L\n\n#define SN_sha256WithRSAEncryption              \"RSA-SHA256\"\n#define LN_sha256WithRSAEncryption              \"sha256WithRSAEncryption\"\n#define NID_sha256WithRSAEncryption             668\n#define OBJ_sha256WithRSAEncryption             OBJ_pkcs1,11L\n\n#define SN_sha384WithRSAEncryption              \"RSA-SHA384\"\n#define LN_sha384WithRSAEncryption              \"sha384WithRSAEncryption\"\n#define NID_sha384WithRSAEncryption             669\n#define OBJ_sha384WithRSAEncryption             OBJ_pkcs1,12L\n\n#define SN_sha512WithRSAEncryption              \"RSA-SHA512\"\n#define LN_sha512WithRSAEncryption              \"sha512WithRSAEncryption\"\n#define NID_sha512WithRSAEncryption             670\n#define OBJ_sha512WithRSAEncryption             OBJ_pkcs1,13L\n\n#define SN_sha224WithRSAEncryption              \"RSA-SHA224\"\n#define LN_sha224WithRSAEncryption              \"sha224WithRSAEncryption\"\n#define NID_sha224WithRSAEncryption             671\n#define OBJ_sha224WithRSAEncryption             OBJ_pkcs1,14L\n\n#define SN_sha512_224WithRSAEncryption          \"RSA-SHA512/224\"\n#define LN_sha512_224WithRSAEncryption          \"sha512-224WithRSAEncryption\"\n#define NID_sha512_224WithRSAEncryption         1145\n#define OBJ_sha512_224WithRSAEncryption         OBJ_pkcs1,15L\n\n#define SN_sha512_256WithRSAEncryption          \"RSA-SHA512/256\"\n#define LN_sha512_256WithRSAEncryption          \"sha512-256WithRSAEncryption\"\n#define NID_sha512_256WithRSAEncryption         1146\n#define OBJ_sha512_256WithRSAEncryption         OBJ_pkcs1,16L\n\n#define SN_pkcs3                \"pkcs3\"\n#define NID_pkcs3               27\n#define OBJ_pkcs3               OBJ_pkcs,3L\n\n#define LN_dhKeyAgreement               \"dhKeyAgreement\"\n#define NID_dhKeyAgreement              28\n#define OBJ_dhKeyAgreement              OBJ_pkcs3,1L\n\n#define SN_pkcs5                \"pkcs5\"\n#define NID_pkcs5               187\n#define OBJ_pkcs5               OBJ_pkcs,5L\n\n#define SN_pbeWithMD2AndDES_CBC         \"PBE-MD2-DES\"\n#define LN_pbeWithMD2AndDES_CBC         \"pbeWithMD2AndDES-CBC\"\n#define NID_pbeWithMD2AndDES_CBC                9\n#define OBJ_pbeWithMD2AndDES_CBC                OBJ_pkcs5,1L\n\n#define SN_pbeWithMD5AndDES_CBC         \"PBE-MD5-DES\"\n#define LN_pbeWithMD5AndDES_CBC         \"pbeWithMD5AndDES-CBC\"\n#define NID_pbeWithMD5AndDES_CBC                10\n#define OBJ_pbeWithMD5AndDES_CBC                OBJ_pkcs5,3L\n\n#define SN_pbeWithMD2AndRC2_CBC         \"PBE-MD2-RC2-64\"\n#define LN_pbeWithMD2AndRC2_CBC         \"pbeWithMD2AndRC2-CBC\"\n#define NID_pbeWithMD2AndRC2_CBC                168\n#define OBJ_pbeWithMD2AndRC2_CBC                OBJ_pkcs5,4L\n\n#define SN_pbeWithMD5AndRC2_CBC         \"PBE-MD5-RC2-64\"\n#define LN_pbeWithMD5AndRC2_CBC         \"pbeWithMD5AndRC2-CBC\"\n#define NID_pbeWithMD5AndRC2_CBC                169\n#define OBJ_pbeWithMD5AndRC2_CBC                OBJ_pkcs5,6L\n\n#define SN_pbeWithSHA1AndDES_CBC                \"PBE-SHA1-DES\"\n#define LN_pbeWithSHA1AndDES_CBC                \"pbeWithSHA1AndDES-CBC\"\n#define NID_pbeWithSHA1AndDES_CBC               170\n#define OBJ_pbeWithSHA1AndDES_CBC               OBJ_pkcs5,10L\n\n#define SN_pbeWithSHA1AndRC2_CBC                \"PBE-SHA1-RC2-64\"\n#define LN_pbeWithSHA1AndRC2_CBC                \"pbeWithSHA1AndRC2-CBC\"\n#define NID_pbeWithSHA1AndRC2_CBC               68\n#define OBJ_pbeWithSHA1AndRC2_CBC               OBJ_pkcs5,11L\n\n#define LN_id_pbkdf2            \"PBKDF2\"\n#define NID_id_pbkdf2           69\n#define OBJ_id_pbkdf2           OBJ_pkcs5,12L\n\n#define LN_pbes2                \"PBES2\"\n#define NID_pbes2               161\n#define OBJ_pbes2               OBJ_pkcs5,13L\n\n#define LN_pbmac1               \"PBMAC1\"\n#define NID_pbmac1              162\n#define OBJ_pbmac1              OBJ_pkcs5,14L\n\n#define SN_pkcs7                \"pkcs7\"\n#define NID_pkcs7               20\n#define OBJ_pkcs7               OBJ_pkcs,7L\n\n#define LN_pkcs7_data           \"pkcs7-data\"\n#define NID_pkcs7_data          21\n#define OBJ_pkcs7_data          OBJ_pkcs7,1L\n\n#define LN_pkcs7_signed         \"pkcs7-signedData\"\n#define NID_pkcs7_signed                22\n#define OBJ_pkcs7_signed                OBJ_pkcs7,2L\n\n#define LN_pkcs7_enveloped              \"pkcs7-envelopedData\"\n#define NID_pkcs7_enveloped             23\n#define OBJ_pkcs7_enveloped             OBJ_pkcs7,3L\n\n#define LN_pkcs7_signedAndEnveloped             \"pkcs7-signedAndEnvelopedData\"\n#define NID_pkcs7_signedAndEnveloped            24\n#define OBJ_pkcs7_signedAndEnveloped            OBJ_pkcs7,4L\n\n#define LN_pkcs7_digest         \"pkcs7-digestData\"\n#define NID_pkcs7_digest                25\n#define OBJ_pkcs7_digest                OBJ_pkcs7,5L\n\n#define LN_pkcs7_encrypted              \"pkcs7-encryptedData\"\n#define NID_pkcs7_encrypted             26\n#define OBJ_pkcs7_encrypted             OBJ_pkcs7,6L\n\n#define SN_pkcs9                \"pkcs9\"\n#define NID_pkcs9               47\n#define OBJ_pkcs9               OBJ_pkcs,9L\n\n#define LN_pkcs9_emailAddress           \"emailAddress\"\n#define NID_pkcs9_emailAddress          48\n#define OBJ_pkcs9_emailAddress          OBJ_pkcs9,1L\n\n#define LN_pkcs9_unstructuredName               \"unstructuredName\"\n#define NID_pkcs9_unstructuredName              49\n#define OBJ_pkcs9_unstructuredName              OBJ_pkcs9,2L\n\n#define LN_pkcs9_contentType            \"contentType\"\n#define NID_pkcs9_contentType           50\n#define OBJ_pkcs9_contentType           OBJ_pkcs9,3L\n\n#define LN_pkcs9_messageDigest          \"messageDigest\"\n#define NID_pkcs9_messageDigest         51\n#define OBJ_pkcs9_messageDigest         OBJ_pkcs9,4L\n\n#define LN_pkcs9_signingTime            \"signingTime\"\n#define NID_pkcs9_signingTime           52\n#define OBJ_pkcs9_signingTime           OBJ_pkcs9,5L\n\n#define LN_pkcs9_countersignature               \"countersignature\"\n#define NID_pkcs9_countersignature              53\n#define OBJ_pkcs9_countersignature              OBJ_pkcs9,6L\n\n#define LN_pkcs9_challengePassword              \"challengePassword\"\n#define NID_pkcs9_challengePassword             54\n#define OBJ_pkcs9_challengePassword             OBJ_pkcs9,7L\n\n#define LN_pkcs9_unstructuredAddress            \"unstructuredAddress\"\n#define NID_pkcs9_unstructuredAddress           55\n#define OBJ_pkcs9_unstructuredAddress           OBJ_pkcs9,8L\n\n#define LN_pkcs9_extCertAttributes              \"extendedCertificateAttributes\"\n#define NID_pkcs9_extCertAttributes             56\n#define OBJ_pkcs9_extCertAttributes             OBJ_pkcs9,9L\n\n#define SN_ext_req              \"extReq\"\n#define LN_ext_req              \"Extension Request\"\n#define NID_ext_req             172\n#define OBJ_ext_req             OBJ_pkcs9,14L\n\n#define SN_SMIMECapabilities            \"SMIME-CAPS\"\n#define LN_SMIMECapabilities            \"S/MIME Capabilities\"\n#define NID_SMIMECapabilities           167\n#define OBJ_SMIMECapabilities           OBJ_pkcs9,15L\n\n#define SN_SMIME                \"SMIME\"\n#define LN_SMIME                \"S/MIME\"\n#define NID_SMIME               188\n#define OBJ_SMIME               OBJ_pkcs9,16L\n\n#define SN_id_smime_mod         \"id-smime-mod\"\n#define NID_id_smime_mod                189\n#define OBJ_id_smime_mod                OBJ_SMIME,0L\n\n#define SN_id_smime_ct          \"id-smime-ct\"\n#define NID_id_smime_ct         190\n#define OBJ_id_smime_ct         OBJ_SMIME,1L\n\n#define SN_id_smime_aa          \"id-smime-aa\"\n#define NID_id_smime_aa         191\n#define OBJ_id_smime_aa         OBJ_SMIME,2L\n\n#define SN_id_smime_alg         \"id-smime-alg\"\n#define NID_id_smime_alg                192\n#define OBJ_id_smime_alg                OBJ_SMIME,3L\n\n#define SN_id_smime_cd          \"id-smime-cd\"\n#define NID_id_smime_cd         193\n#define OBJ_id_smime_cd         OBJ_SMIME,4L\n\n#define SN_id_smime_spq         \"id-smime-spq\"\n#define NID_id_smime_spq                194\n#define OBJ_id_smime_spq                OBJ_SMIME,5L\n\n#define SN_id_smime_cti         \"id-smime-cti\"\n#define NID_id_smime_cti                195\n#define OBJ_id_smime_cti                OBJ_SMIME,6L\n\n#define SN_id_smime_mod_cms             \"id-smime-mod-cms\"\n#define NID_id_smime_mod_cms            196\n#define OBJ_id_smime_mod_cms            OBJ_id_smime_mod,1L\n\n#define SN_id_smime_mod_ess             \"id-smime-mod-ess\"\n#define NID_id_smime_mod_ess            197\n#define OBJ_id_smime_mod_ess            OBJ_id_smime_mod,2L\n\n#define SN_id_smime_mod_oid             \"id-smime-mod-oid\"\n#define NID_id_smime_mod_oid            198\n#define OBJ_id_smime_mod_oid            OBJ_id_smime_mod,3L\n\n#define SN_id_smime_mod_msg_v3          \"id-smime-mod-msg-v3\"\n#define NID_id_smime_mod_msg_v3         199\n#define OBJ_id_smime_mod_msg_v3         OBJ_id_smime_mod,4L\n\n#define SN_id_smime_mod_ets_eSignature_88               \"id-smime-mod-ets-eSignature-88\"\n#define NID_id_smime_mod_ets_eSignature_88              200\n#define OBJ_id_smime_mod_ets_eSignature_88              OBJ_id_smime_mod,5L\n\n#define SN_id_smime_mod_ets_eSignature_97               \"id-smime-mod-ets-eSignature-97\"\n#define NID_id_smime_mod_ets_eSignature_97              201\n#define OBJ_id_smime_mod_ets_eSignature_97              OBJ_id_smime_mod,6L\n\n#define SN_id_smime_mod_ets_eSigPolicy_88               \"id-smime-mod-ets-eSigPolicy-88\"\n#define NID_id_smime_mod_ets_eSigPolicy_88              202\n#define OBJ_id_smime_mod_ets_eSigPolicy_88              OBJ_id_smime_mod,7L\n\n#define SN_id_smime_mod_ets_eSigPolicy_97               \"id-smime-mod-ets-eSigPolicy-97\"\n#define NID_id_smime_mod_ets_eSigPolicy_97              203\n#define OBJ_id_smime_mod_ets_eSigPolicy_97              OBJ_id_smime_mod,8L\n\n#define SN_id_smime_ct_receipt          \"id-smime-ct-receipt\"\n#define NID_id_smime_ct_receipt         204\n#define OBJ_id_smime_ct_receipt         OBJ_id_smime_ct,1L\n\n#define SN_id_smime_ct_authData         \"id-smime-ct-authData\"\n#define NID_id_smime_ct_authData                205\n#define OBJ_id_smime_ct_authData                OBJ_id_smime_ct,2L\n\n#define SN_id_smime_ct_publishCert              \"id-smime-ct-publishCert\"\n#define NID_id_smime_ct_publishCert             206\n#define OBJ_id_smime_ct_publishCert             OBJ_id_smime_ct,3L\n\n#define SN_id_smime_ct_TSTInfo          \"id-smime-ct-TSTInfo\"\n#define NID_id_smime_ct_TSTInfo         207\n#define OBJ_id_smime_ct_TSTInfo         OBJ_id_smime_ct,4L\n\n#define SN_id_smime_ct_TDTInfo          \"id-smime-ct-TDTInfo\"\n#define NID_id_smime_ct_TDTInfo         208\n#define OBJ_id_smime_ct_TDTInfo         OBJ_id_smime_ct,5L\n\n#define SN_id_smime_ct_contentInfo              \"id-smime-ct-contentInfo\"\n#define NID_id_smime_ct_contentInfo             209\n#define OBJ_id_smime_ct_contentInfo             OBJ_id_smime_ct,6L\n\n#define SN_id_smime_ct_DVCSRequestData          \"id-smime-ct-DVCSRequestData\"\n#define NID_id_smime_ct_DVCSRequestData         210\n#define OBJ_id_smime_ct_DVCSRequestData         OBJ_id_smime_ct,7L\n\n#define SN_id_smime_ct_DVCSResponseData         \"id-smime-ct-DVCSResponseData\"\n#define NID_id_smime_ct_DVCSResponseData                211\n#define OBJ_id_smime_ct_DVCSResponseData                OBJ_id_smime_ct,8L\n\n#define SN_id_smime_ct_compressedData           \"id-smime-ct-compressedData\"\n#define NID_id_smime_ct_compressedData          786\n#define OBJ_id_smime_ct_compressedData          OBJ_id_smime_ct,9L\n\n#define SN_id_smime_ct_contentCollection                \"id-smime-ct-contentCollection\"\n#define NID_id_smime_ct_contentCollection               1058\n#define OBJ_id_smime_ct_contentCollection               OBJ_id_smime_ct,19L\n\n#define SN_id_smime_ct_authEnvelopedData                \"id-smime-ct-authEnvelopedData\"\n#define NID_id_smime_ct_authEnvelopedData               1059\n#define OBJ_id_smime_ct_authEnvelopedData               OBJ_id_smime_ct,23L\n\n#define SN_id_ct_asciiTextWithCRLF              \"id-ct-asciiTextWithCRLF\"\n#define NID_id_ct_asciiTextWithCRLF             787\n#define OBJ_id_ct_asciiTextWithCRLF             OBJ_id_smime_ct,27L\n\n#define SN_id_ct_xml            \"id-ct-xml\"\n#define NID_id_ct_xml           1060\n#define OBJ_id_ct_xml           OBJ_id_smime_ct,28L\n\n#define SN_id_smime_aa_receiptRequest           \"id-smime-aa-receiptRequest\"\n#define NID_id_smime_aa_receiptRequest          212\n#define OBJ_id_smime_aa_receiptRequest          OBJ_id_smime_aa,1L\n\n#define SN_id_smime_aa_securityLabel            \"id-smime-aa-securityLabel\"\n#define NID_id_smime_aa_securityLabel           213\n#define OBJ_id_smime_aa_securityLabel           OBJ_id_smime_aa,2L\n\n#define SN_id_smime_aa_mlExpandHistory          \"id-smime-aa-mlExpandHistory\"\n#define NID_id_smime_aa_mlExpandHistory         214\n#define OBJ_id_smime_aa_mlExpandHistory         OBJ_id_smime_aa,3L\n\n#define SN_id_smime_aa_contentHint              \"id-smime-aa-contentHint\"\n#define NID_id_smime_aa_contentHint             215\n#define OBJ_id_smime_aa_contentHint             OBJ_id_smime_aa,4L\n\n#define SN_id_smime_aa_msgSigDigest             \"id-smime-aa-msgSigDigest\"\n#define NID_id_smime_aa_msgSigDigest            216\n#define OBJ_id_smime_aa_msgSigDigest            OBJ_id_smime_aa,5L\n\n#define SN_id_smime_aa_encapContentType         \"id-smime-aa-encapContentType\"\n#define NID_id_smime_aa_encapContentType                217\n#define OBJ_id_smime_aa_encapContentType                OBJ_id_smime_aa,6L\n\n#define SN_id_smime_aa_contentIdentifier                \"id-smime-aa-contentIdentifier\"\n#define NID_id_smime_aa_contentIdentifier               218\n#define OBJ_id_smime_aa_contentIdentifier               OBJ_id_smime_aa,7L\n\n#define SN_id_smime_aa_macValue         \"id-smime-aa-macValue\"\n#define NID_id_smime_aa_macValue                219\n#define OBJ_id_smime_aa_macValue                OBJ_id_smime_aa,8L\n\n#define SN_id_smime_aa_equivalentLabels         \"id-smime-aa-equivalentLabels\"\n#define NID_id_smime_aa_equivalentLabels                220\n#define OBJ_id_smime_aa_equivalentLabels                OBJ_id_smime_aa,9L\n\n#define SN_id_smime_aa_contentReference         \"id-smime-aa-contentReference\"\n#define NID_id_smime_aa_contentReference                221\n#define OBJ_id_smime_aa_contentReference                OBJ_id_smime_aa,10L\n\n#define SN_id_smime_aa_encrypKeyPref            \"id-smime-aa-encrypKeyPref\"\n#define NID_id_smime_aa_encrypKeyPref           222\n#define OBJ_id_smime_aa_encrypKeyPref           OBJ_id_smime_aa,11L\n\n#define SN_id_smime_aa_signingCertificate               \"id-smime-aa-signingCertificate\"\n#define NID_id_smime_aa_signingCertificate              223\n#define OBJ_id_smime_aa_signingCertificate              OBJ_id_smime_aa,12L\n\n#define SN_id_smime_aa_smimeEncryptCerts                \"id-smime-aa-smimeEncryptCerts\"\n#define NID_id_smime_aa_smimeEncryptCerts               224\n#define OBJ_id_smime_aa_smimeEncryptCerts               OBJ_id_smime_aa,13L\n\n#define SN_id_smime_aa_timeStampToken           \"id-smime-aa-timeStampToken\"\n#define NID_id_smime_aa_timeStampToken          225\n#define OBJ_id_smime_aa_timeStampToken          OBJ_id_smime_aa,14L\n\n#define SN_id_smime_aa_ets_sigPolicyId          \"id-smime-aa-ets-sigPolicyId\"\n#define NID_id_smime_aa_ets_sigPolicyId         226\n#define OBJ_id_smime_aa_ets_sigPolicyId         OBJ_id_smime_aa,15L\n\n#define SN_id_smime_aa_ets_commitmentType               \"id-smime-aa-ets-commitmentType\"\n#define NID_id_smime_aa_ets_commitmentType              227\n#define OBJ_id_smime_aa_ets_commitmentType              OBJ_id_smime_aa,16L\n\n#define SN_id_smime_aa_ets_signerLocation               \"id-smime-aa-ets-signerLocation\"\n#define NID_id_smime_aa_ets_signerLocation              228\n#define OBJ_id_smime_aa_ets_signerLocation              OBJ_id_smime_aa,17L\n\n#define SN_id_smime_aa_ets_signerAttr           \"id-smime-aa-ets-signerAttr\"\n#define NID_id_smime_aa_ets_signerAttr          229\n#define OBJ_id_smime_aa_ets_signerAttr          OBJ_id_smime_aa,18L\n\n#define SN_id_smime_aa_ets_otherSigCert         \"id-smime-aa-ets-otherSigCert\"\n#define NID_id_smime_aa_ets_otherSigCert                230\n#define OBJ_id_smime_aa_ets_otherSigCert                OBJ_id_smime_aa,19L\n\n#define SN_id_smime_aa_ets_contentTimestamp             \"id-smime-aa-ets-contentTimestamp\"\n#define NID_id_smime_aa_ets_contentTimestamp            231\n#define OBJ_id_smime_aa_ets_contentTimestamp            OBJ_id_smime_aa,20L\n\n#define SN_id_smime_aa_ets_CertificateRefs              \"id-smime-aa-ets-CertificateRefs\"\n#define NID_id_smime_aa_ets_CertificateRefs             232\n#define OBJ_id_smime_aa_ets_CertificateRefs             OBJ_id_smime_aa,21L\n\n#define SN_id_smime_aa_ets_RevocationRefs               \"id-smime-aa-ets-RevocationRefs\"\n#define NID_id_smime_aa_ets_RevocationRefs              233\n#define OBJ_id_smime_aa_ets_RevocationRefs              OBJ_id_smime_aa,22L\n\n#define SN_id_smime_aa_ets_certValues           \"id-smime-aa-ets-certValues\"\n#define NID_id_smime_aa_ets_certValues          234\n#define OBJ_id_smime_aa_ets_certValues          OBJ_id_smime_aa,23L\n\n#define SN_id_smime_aa_ets_revocationValues             \"id-smime-aa-ets-revocationValues\"\n#define NID_id_smime_aa_ets_revocationValues            235\n#define OBJ_id_smime_aa_ets_revocationValues            OBJ_id_smime_aa,24L\n\n#define SN_id_smime_aa_ets_escTimeStamp         \"id-smime-aa-ets-escTimeStamp\"\n#define NID_id_smime_aa_ets_escTimeStamp                236\n#define OBJ_id_smime_aa_ets_escTimeStamp                OBJ_id_smime_aa,25L\n\n#define SN_id_smime_aa_ets_certCRLTimestamp             \"id-smime-aa-ets-certCRLTimestamp\"\n#define NID_id_smime_aa_ets_certCRLTimestamp            237\n#define OBJ_id_smime_aa_ets_certCRLTimestamp            OBJ_id_smime_aa,26L\n\n#define SN_id_smime_aa_ets_archiveTimeStamp             \"id-smime-aa-ets-archiveTimeStamp\"\n#define NID_id_smime_aa_ets_archiveTimeStamp            238\n#define OBJ_id_smime_aa_ets_archiveTimeStamp            OBJ_id_smime_aa,27L\n\n#define SN_id_smime_aa_signatureType            \"id-smime-aa-signatureType\"\n#define NID_id_smime_aa_signatureType           239\n#define OBJ_id_smime_aa_signatureType           OBJ_id_smime_aa,28L\n\n#define SN_id_smime_aa_dvcs_dvc         \"id-smime-aa-dvcs-dvc\"\n#define NID_id_smime_aa_dvcs_dvc                240\n#define OBJ_id_smime_aa_dvcs_dvc                OBJ_id_smime_aa,29L\n\n#define SN_id_smime_aa_signingCertificateV2             \"id-smime-aa-signingCertificateV2\"\n#define NID_id_smime_aa_signingCertificateV2            1086\n#define OBJ_id_smime_aa_signingCertificateV2            OBJ_id_smime_aa,47L\n\n#define SN_id_smime_alg_ESDHwith3DES            \"id-smime-alg-ESDHwith3DES\"\n#define NID_id_smime_alg_ESDHwith3DES           241\n#define OBJ_id_smime_alg_ESDHwith3DES           OBJ_id_smime_alg,1L\n\n#define SN_id_smime_alg_ESDHwithRC2             \"id-smime-alg-ESDHwithRC2\"\n#define NID_id_smime_alg_ESDHwithRC2            242\n#define OBJ_id_smime_alg_ESDHwithRC2            OBJ_id_smime_alg,2L\n\n#define SN_id_smime_alg_3DESwrap                \"id-smime-alg-3DESwrap\"\n#define NID_id_smime_alg_3DESwrap               243\n#define OBJ_id_smime_alg_3DESwrap               OBJ_id_smime_alg,3L\n\n#define SN_id_smime_alg_RC2wrap         \"id-smime-alg-RC2wrap\"\n#define NID_id_smime_alg_RC2wrap                244\n#define OBJ_id_smime_alg_RC2wrap                OBJ_id_smime_alg,4L\n\n#define SN_id_smime_alg_ESDH            \"id-smime-alg-ESDH\"\n#define NID_id_smime_alg_ESDH           245\n#define OBJ_id_smime_alg_ESDH           OBJ_id_smime_alg,5L\n\n#define SN_id_smime_alg_CMS3DESwrap             \"id-smime-alg-CMS3DESwrap\"\n#define NID_id_smime_alg_CMS3DESwrap            246\n#define OBJ_id_smime_alg_CMS3DESwrap            OBJ_id_smime_alg,6L\n\n#define SN_id_smime_alg_CMSRC2wrap              \"id-smime-alg-CMSRC2wrap\"\n#define NID_id_smime_alg_CMSRC2wrap             247\n#define OBJ_id_smime_alg_CMSRC2wrap             OBJ_id_smime_alg,7L\n\n#define SN_id_alg_PWRI_KEK              \"id-alg-PWRI-KEK\"\n#define NID_id_alg_PWRI_KEK             893\n#define OBJ_id_alg_PWRI_KEK             OBJ_id_smime_alg,9L\n\n#define SN_id_smime_cd_ldap             \"id-smime-cd-ldap\"\n#define NID_id_smime_cd_ldap            248\n#define OBJ_id_smime_cd_ldap            OBJ_id_smime_cd,1L\n\n#define SN_id_smime_spq_ets_sqt_uri             \"id-smime-spq-ets-sqt-uri\"\n#define NID_id_smime_spq_ets_sqt_uri            249\n#define OBJ_id_smime_spq_ets_sqt_uri            OBJ_id_smime_spq,1L\n\n#define SN_id_smime_spq_ets_sqt_unotice         \"id-smime-spq-ets-sqt-unotice\"\n#define NID_id_smime_spq_ets_sqt_unotice                250\n#define OBJ_id_smime_spq_ets_sqt_unotice                OBJ_id_smime_spq,2L\n\n#define SN_id_smime_cti_ets_proofOfOrigin               \"id-smime-cti-ets-proofOfOrigin\"\n#define NID_id_smime_cti_ets_proofOfOrigin              251\n#define OBJ_id_smime_cti_ets_proofOfOrigin              OBJ_id_smime_cti,1L\n\n#define SN_id_smime_cti_ets_proofOfReceipt              \"id-smime-cti-ets-proofOfReceipt\"\n#define NID_id_smime_cti_ets_proofOfReceipt             252\n#define OBJ_id_smime_cti_ets_proofOfReceipt             OBJ_id_smime_cti,2L\n\n#define SN_id_smime_cti_ets_proofOfDelivery             \"id-smime-cti-ets-proofOfDelivery\"\n#define NID_id_smime_cti_ets_proofOfDelivery            253\n#define OBJ_id_smime_cti_ets_proofOfDelivery            OBJ_id_smime_cti,3L\n\n#define SN_id_smime_cti_ets_proofOfSender               \"id-smime-cti-ets-proofOfSender\"\n#define NID_id_smime_cti_ets_proofOfSender              254\n#define OBJ_id_smime_cti_ets_proofOfSender              OBJ_id_smime_cti,4L\n\n#define SN_id_smime_cti_ets_proofOfApproval             \"id-smime-cti-ets-proofOfApproval\"\n#define NID_id_smime_cti_ets_proofOfApproval            255\n#define OBJ_id_smime_cti_ets_proofOfApproval            OBJ_id_smime_cti,5L\n\n#define SN_id_smime_cti_ets_proofOfCreation             \"id-smime-cti-ets-proofOfCreation\"\n#define NID_id_smime_cti_ets_proofOfCreation            256\n#define OBJ_id_smime_cti_ets_proofOfCreation            OBJ_id_smime_cti,6L\n\n#define LN_friendlyName         \"friendlyName\"\n#define NID_friendlyName                156\n#define OBJ_friendlyName                OBJ_pkcs9,20L\n\n#define LN_localKeyID           \"localKeyID\"\n#define NID_localKeyID          157\n#define OBJ_localKeyID          OBJ_pkcs9,21L\n\n#define SN_ms_csp_name          \"CSPName\"\n#define LN_ms_csp_name          \"Microsoft CSP Name\"\n#define NID_ms_csp_name         417\n#define OBJ_ms_csp_name         1L,3L,6L,1L,4L,1L,311L,17L,1L\n\n#define SN_LocalKeySet          \"LocalKeySet\"\n#define LN_LocalKeySet          \"Microsoft Local Key set\"\n#define NID_LocalKeySet         856\n#define OBJ_LocalKeySet         1L,3L,6L,1L,4L,1L,311L,17L,2L\n\n#define OBJ_certTypes           OBJ_pkcs9,22L\n\n#define LN_x509Certificate              \"x509Certificate\"\n#define NID_x509Certificate             158\n#define OBJ_x509Certificate             OBJ_certTypes,1L\n\n#define LN_sdsiCertificate              \"sdsiCertificate\"\n#define NID_sdsiCertificate             159\n#define OBJ_sdsiCertificate             OBJ_certTypes,2L\n\n#define OBJ_crlTypes            OBJ_pkcs9,23L\n\n#define LN_x509Crl              \"x509Crl\"\n#define NID_x509Crl             160\n#define OBJ_x509Crl             OBJ_crlTypes,1L\n\n#define OBJ_pkcs12              OBJ_pkcs,12L\n\n#define OBJ_pkcs12_pbeids               OBJ_pkcs12,1L\n\n#define SN_pbe_WithSHA1And128BitRC4             \"PBE-SHA1-RC4-128\"\n#define LN_pbe_WithSHA1And128BitRC4             \"pbeWithSHA1And128BitRC4\"\n#define NID_pbe_WithSHA1And128BitRC4            144\n#define OBJ_pbe_WithSHA1And128BitRC4            OBJ_pkcs12_pbeids,1L\n\n#define SN_pbe_WithSHA1And40BitRC4              \"PBE-SHA1-RC4-40\"\n#define LN_pbe_WithSHA1And40BitRC4              \"pbeWithSHA1And40BitRC4\"\n#define NID_pbe_WithSHA1And40BitRC4             145\n#define OBJ_pbe_WithSHA1And40BitRC4             OBJ_pkcs12_pbeids,2L\n\n#define SN_pbe_WithSHA1And3_Key_TripleDES_CBC           \"PBE-SHA1-3DES\"\n#define LN_pbe_WithSHA1And3_Key_TripleDES_CBC           \"pbeWithSHA1And3-KeyTripleDES-CBC\"\n#define NID_pbe_WithSHA1And3_Key_TripleDES_CBC          146\n#define OBJ_pbe_WithSHA1And3_Key_TripleDES_CBC          OBJ_pkcs12_pbeids,3L\n\n#define SN_pbe_WithSHA1And2_Key_TripleDES_CBC           \"PBE-SHA1-2DES\"\n#define LN_pbe_WithSHA1And2_Key_TripleDES_CBC           \"pbeWithSHA1And2-KeyTripleDES-CBC\"\n#define NID_pbe_WithSHA1And2_Key_TripleDES_CBC          147\n#define OBJ_pbe_WithSHA1And2_Key_TripleDES_CBC          OBJ_pkcs12_pbeids,4L\n\n#define SN_pbe_WithSHA1And128BitRC2_CBC         \"PBE-SHA1-RC2-128\"\n#define LN_pbe_WithSHA1And128BitRC2_CBC         \"pbeWithSHA1And128BitRC2-CBC\"\n#define NID_pbe_WithSHA1And128BitRC2_CBC                148\n#define OBJ_pbe_WithSHA1And128BitRC2_CBC                OBJ_pkcs12_pbeids,5L\n\n#define SN_pbe_WithSHA1And40BitRC2_CBC          \"PBE-SHA1-RC2-40\"\n#define LN_pbe_WithSHA1And40BitRC2_CBC          \"pbeWithSHA1And40BitRC2-CBC\"\n#define NID_pbe_WithSHA1And40BitRC2_CBC         149\n#define OBJ_pbe_WithSHA1And40BitRC2_CBC         OBJ_pkcs12_pbeids,6L\n\n#define OBJ_pkcs12_Version1             OBJ_pkcs12,10L\n\n#define OBJ_pkcs12_BagIds               OBJ_pkcs12_Version1,1L\n\n#define LN_keyBag               \"keyBag\"\n#define NID_keyBag              150\n#define OBJ_keyBag              OBJ_pkcs12_BagIds,1L\n\n#define LN_pkcs8ShroudedKeyBag          \"pkcs8ShroudedKeyBag\"\n#define NID_pkcs8ShroudedKeyBag         151\n#define OBJ_pkcs8ShroudedKeyBag         OBJ_pkcs12_BagIds,2L\n\n#define LN_certBag              \"certBag\"\n#define NID_certBag             152\n#define OBJ_certBag             OBJ_pkcs12_BagIds,3L\n\n#define LN_crlBag               \"crlBag\"\n#define NID_crlBag              153\n#define OBJ_crlBag              OBJ_pkcs12_BagIds,4L\n\n#define LN_secretBag            \"secretBag\"\n#define NID_secretBag           154\n#define OBJ_secretBag           OBJ_pkcs12_BagIds,5L\n\n#define LN_safeContentsBag              \"safeContentsBag\"\n#define NID_safeContentsBag             155\n#define OBJ_safeContentsBag             OBJ_pkcs12_BagIds,6L\n\n#define SN_md2          \"MD2\"\n#define LN_md2          \"md2\"\n#define NID_md2         3\n#define OBJ_md2         OBJ_rsadsi,2L,2L\n\n#define SN_md4          \"MD4\"\n#define LN_md4          \"md4\"\n#define NID_md4         257\n#define OBJ_md4         OBJ_rsadsi,2L,4L\n\n#define SN_md5          \"MD5\"\n#define LN_md5          \"md5\"\n#define NID_md5         4\n#define OBJ_md5         OBJ_rsadsi,2L,5L\n\n#define SN_md5_sha1             \"MD5-SHA1\"\n#define LN_md5_sha1             \"md5-sha1\"\n#define NID_md5_sha1            114\n\n#define LN_hmacWithMD5          \"hmacWithMD5\"\n#define NID_hmacWithMD5         797\n#define OBJ_hmacWithMD5         OBJ_rsadsi,2L,6L\n\n#define LN_hmacWithSHA1         \"hmacWithSHA1\"\n#define NID_hmacWithSHA1                163\n#define OBJ_hmacWithSHA1                OBJ_rsadsi,2L,7L\n\n#define SN_sm2          \"SM2\"\n#define LN_sm2          \"sm2\"\n#define NID_sm2         1172\n#define OBJ_sm2         OBJ_sm_scheme,301L\n\n#define SN_sm3          \"SM3\"\n#define LN_sm3          \"sm3\"\n#define NID_sm3         1143\n#define OBJ_sm3         OBJ_sm_scheme,401L\n\n#define SN_sm3WithRSAEncryption         \"RSA-SM3\"\n#define LN_sm3WithRSAEncryption         \"sm3WithRSAEncryption\"\n#define NID_sm3WithRSAEncryption                1144\n#define OBJ_sm3WithRSAEncryption                OBJ_sm_scheme,504L\n\n#define LN_hmacWithSHA224               \"hmacWithSHA224\"\n#define NID_hmacWithSHA224              798\n#define OBJ_hmacWithSHA224              OBJ_rsadsi,2L,8L\n\n#define LN_hmacWithSHA256               \"hmacWithSHA256\"\n#define NID_hmacWithSHA256              799\n#define OBJ_hmacWithSHA256              OBJ_rsadsi,2L,9L\n\n#define LN_hmacWithSHA384               \"hmacWithSHA384\"\n#define NID_hmacWithSHA384              800\n#define OBJ_hmacWithSHA384              OBJ_rsadsi,2L,10L\n\n#define LN_hmacWithSHA512               \"hmacWithSHA512\"\n#define NID_hmacWithSHA512              801\n#define OBJ_hmacWithSHA512              OBJ_rsadsi,2L,11L\n\n#define LN_hmacWithSHA512_224           \"hmacWithSHA512-224\"\n#define NID_hmacWithSHA512_224          1193\n#define OBJ_hmacWithSHA512_224          OBJ_rsadsi,2L,12L\n\n#define LN_hmacWithSHA512_256           \"hmacWithSHA512-256\"\n#define NID_hmacWithSHA512_256          1194\n#define OBJ_hmacWithSHA512_256          OBJ_rsadsi,2L,13L\n\n#define SN_rc2_cbc              \"RC2-CBC\"\n#define LN_rc2_cbc              \"rc2-cbc\"\n#define NID_rc2_cbc             37\n#define OBJ_rc2_cbc             OBJ_rsadsi,3L,2L\n\n#define SN_rc2_ecb              \"RC2-ECB\"\n#define LN_rc2_ecb              \"rc2-ecb\"\n#define NID_rc2_ecb             38\n\n#define SN_rc2_cfb64            \"RC2-CFB\"\n#define LN_rc2_cfb64            \"rc2-cfb\"\n#define NID_rc2_cfb64           39\n\n#define SN_rc2_ofb64            \"RC2-OFB\"\n#define LN_rc2_ofb64            \"rc2-ofb\"\n#define NID_rc2_ofb64           40\n\n#define SN_rc2_40_cbc           \"RC2-40-CBC\"\n#define LN_rc2_40_cbc           \"rc2-40-cbc\"\n#define NID_rc2_40_cbc          98\n\n#define SN_rc2_64_cbc           \"RC2-64-CBC\"\n#define LN_rc2_64_cbc           \"rc2-64-cbc\"\n#define NID_rc2_64_cbc          166\n\n#define SN_rc4          \"RC4\"\n#define LN_rc4          \"rc4\"\n#define NID_rc4         5\n#define OBJ_rc4         OBJ_rsadsi,3L,4L\n\n#define SN_rc4_40               \"RC4-40\"\n#define LN_rc4_40               \"rc4-40\"\n#define NID_rc4_40              97\n\n#define SN_des_ede3_cbc         \"DES-EDE3-CBC\"\n#define LN_des_ede3_cbc         \"des-ede3-cbc\"\n#define NID_des_ede3_cbc                44\n#define OBJ_des_ede3_cbc                OBJ_rsadsi,3L,7L\n\n#define SN_rc5_cbc              \"RC5-CBC\"\n#define LN_rc5_cbc              \"rc5-cbc\"\n#define NID_rc5_cbc             120\n#define OBJ_rc5_cbc             OBJ_rsadsi,3L,8L\n\n#define SN_rc5_ecb              \"RC5-ECB\"\n#define LN_rc5_ecb              \"rc5-ecb\"\n#define NID_rc5_ecb             121\n\n#define SN_rc5_cfb64            \"RC5-CFB\"\n#define LN_rc5_cfb64            \"rc5-cfb\"\n#define NID_rc5_cfb64           122\n\n#define SN_rc5_ofb64            \"RC5-OFB\"\n#define LN_rc5_ofb64            \"rc5-ofb\"\n#define NID_rc5_ofb64           123\n\n#define SN_ms_ext_req           \"msExtReq\"\n#define LN_ms_ext_req           \"Microsoft Extension Request\"\n#define NID_ms_ext_req          171\n#define OBJ_ms_ext_req          1L,3L,6L,1L,4L,1L,311L,2L,1L,14L\n\n#define SN_ms_code_ind          \"msCodeInd\"\n#define LN_ms_code_ind          \"Microsoft Individual Code Signing\"\n#define NID_ms_code_ind         134\n#define OBJ_ms_code_ind         1L,3L,6L,1L,4L,1L,311L,2L,1L,21L\n\n#define SN_ms_code_com          \"msCodeCom\"\n#define LN_ms_code_com          \"Microsoft Commercial Code Signing\"\n#define NID_ms_code_com         135\n#define OBJ_ms_code_com         1L,3L,6L,1L,4L,1L,311L,2L,1L,22L\n\n#define SN_ms_ctl_sign          \"msCTLSign\"\n#define LN_ms_ctl_sign          \"Microsoft Trust List Signing\"\n#define NID_ms_ctl_sign         136\n#define OBJ_ms_ctl_sign         1L,3L,6L,1L,4L,1L,311L,10L,3L,1L\n\n#define SN_ms_sgc               \"msSGC\"\n#define LN_ms_sgc               \"Microsoft Server Gated Crypto\"\n#define NID_ms_sgc              137\n#define OBJ_ms_sgc              1L,3L,6L,1L,4L,1L,311L,10L,3L,3L\n\n#define SN_ms_efs               \"msEFS\"\n#define LN_ms_efs               \"Microsoft Encrypted File System\"\n#define NID_ms_efs              138\n#define OBJ_ms_efs              1L,3L,6L,1L,4L,1L,311L,10L,3L,4L\n\n#define SN_ms_smartcard_login           \"msSmartcardLogin\"\n#define LN_ms_smartcard_login           \"Microsoft Smartcard Login\"\n#define NID_ms_smartcard_login          648\n#define OBJ_ms_smartcard_login          1L,3L,6L,1L,4L,1L,311L,20L,2L,2L\n\n#define SN_ms_upn               \"msUPN\"\n#define LN_ms_upn               \"Microsoft User Principal Name\"\n#define NID_ms_upn              649\n#define OBJ_ms_upn              1L,3L,6L,1L,4L,1L,311L,20L,2L,3L\n\n#define SN_idea_cbc             \"IDEA-CBC\"\n#define LN_idea_cbc             \"idea-cbc\"\n#define NID_idea_cbc            34\n#define OBJ_idea_cbc            1L,3L,6L,1L,4L,1L,188L,7L,1L,1L,2L\n\n#define SN_idea_ecb             \"IDEA-ECB\"\n#define LN_idea_ecb             \"idea-ecb\"\n#define NID_idea_ecb            36\n\n#define SN_idea_cfb64           \"IDEA-CFB\"\n#define LN_idea_cfb64           \"idea-cfb\"\n#define NID_idea_cfb64          35\n\n#define SN_idea_ofb64           \"IDEA-OFB\"\n#define LN_idea_ofb64           \"idea-ofb\"\n#define NID_idea_ofb64          46\n\n#define SN_bf_cbc               \"BF-CBC\"\n#define LN_bf_cbc               \"bf-cbc\"\n#define NID_bf_cbc              91\n#define OBJ_bf_cbc              1L,3L,6L,1L,4L,1L,3029L,1L,2L\n\n#define SN_bf_ecb               \"BF-ECB\"\n#define LN_bf_ecb               \"bf-ecb\"\n#define NID_bf_ecb              92\n\n#define SN_bf_cfb64             \"BF-CFB\"\n#define LN_bf_cfb64             \"bf-cfb\"\n#define NID_bf_cfb64            93\n\n#define SN_bf_ofb64             \"BF-OFB\"\n#define LN_bf_ofb64             \"bf-ofb\"\n#define NID_bf_ofb64            94\n\n#define SN_id_pkix              \"PKIX\"\n#define NID_id_pkix             127\n#define OBJ_id_pkix             1L,3L,6L,1L,5L,5L,7L\n\n#define SN_id_pkix_mod          \"id-pkix-mod\"\n#define NID_id_pkix_mod         258\n#define OBJ_id_pkix_mod         OBJ_id_pkix,0L\n\n#define SN_id_pe                \"id-pe\"\n#define NID_id_pe               175\n#define OBJ_id_pe               OBJ_id_pkix,1L\n\n#define SN_id_qt                \"id-qt\"\n#define NID_id_qt               259\n#define OBJ_id_qt               OBJ_id_pkix,2L\n\n#define SN_id_kp                \"id-kp\"\n#define NID_id_kp               128\n#define OBJ_id_kp               OBJ_id_pkix,3L\n\n#define SN_id_it                \"id-it\"\n#define NID_id_it               260\n#define OBJ_id_it               OBJ_id_pkix,4L\n\n#define SN_id_pkip              \"id-pkip\"\n#define NID_id_pkip             261\n#define OBJ_id_pkip             OBJ_id_pkix,5L\n\n#define SN_id_alg               \"id-alg\"\n#define NID_id_alg              262\n#define OBJ_id_alg              OBJ_id_pkix,6L\n\n#define SN_id_cmc               \"id-cmc\"\n#define NID_id_cmc              263\n#define OBJ_id_cmc              OBJ_id_pkix,7L\n\n#define SN_id_on                \"id-on\"\n#define NID_id_on               264\n#define OBJ_id_on               OBJ_id_pkix,8L\n\n#define SN_id_pda               \"id-pda\"\n#define NID_id_pda              265\n#define OBJ_id_pda              OBJ_id_pkix,9L\n\n#define SN_id_aca               \"id-aca\"\n#define NID_id_aca              266\n#define OBJ_id_aca              OBJ_id_pkix,10L\n\n#define SN_id_qcs               \"id-qcs\"\n#define NID_id_qcs              267\n#define OBJ_id_qcs              OBJ_id_pkix,11L\n\n#define SN_id_cct               \"id-cct\"\n#define NID_id_cct              268\n#define OBJ_id_cct              OBJ_id_pkix,12L\n\n#define SN_id_ppl               \"id-ppl\"\n#define NID_id_ppl              662\n#define OBJ_id_ppl              OBJ_id_pkix,21L\n\n#define SN_id_ad                \"id-ad\"\n#define NID_id_ad               176\n#define OBJ_id_ad               OBJ_id_pkix,48L\n\n#define SN_id_pkix1_explicit_88         \"id-pkix1-explicit-88\"\n#define NID_id_pkix1_explicit_88                269\n#define OBJ_id_pkix1_explicit_88                OBJ_id_pkix_mod,1L\n\n#define SN_id_pkix1_implicit_88         \"id-pkix1-implicit-88\"\n#define NID_id_pkix1_implicit_88                270\n#define OBJ_id_pkix1_implicit_88                OBJ_id_pkix_mod,2L\n\n#define SN_id_pkix1_explicit_93         \"id-pkix1-explicit-93\"\n#define NID_id_pkix1_explicit_93                271\n#define OBJ_id_pkix1_explicit_93                OBJ_id_pkix_mod,3L\n\n#define SN_id_pkix1_implicit_93         \"id-pkix1-implicit-93\"\n#define NID_id_pkix1_implicit_93                272\n#define OBJ_id_pkix1_implicit_93                OBJ_id_pkix_mod,4L\n\n#define SN_id_mod_crmf          \"id-mod-crmf\"\n#define NID_id_mod_crmf         273\n#define OBJ_id_mod_crmf         OBJ_id_pkix_mod,5L\n\n#define SN_id_mod_cmc           \"id-mod-cmc\"\n#define NID_id_mod_cmc          274\n#define OBJ_id_mod_cmc          OBJ_id_pkix_mod,6L\n\n#define SN_id_mod_kea_profile_88                \"id-mod-kea-profile-88\"\n#define NID_id_mod_kea_profile_88               275\n#define OBJ_id_mod_kea_profile_88               OBJ_id_pkix_mod,7L\n\n#define SN_id_mod_kea_profile_93                \"id-mod-kea-profile-93\"\n#define NID_id_mod_kea_profile_93               276\n#define OBJ_id_mod_kea_profile_93               OBJ_id_pkix_mod,8L\n\n#define SN_id_mod_cmp           \"id-mod-cmp\"\n#define NID_id_mod_cmp          277\n#define OBJ_id_mod_cmp          OBJ_id_pkix_mod,9L\n\n#define SN_id_mod_qualified_cert_88             \"id-mod-qualified-cert-88\"\n#define NID_id_mod_qualified_cert_88            278\n#define OBJ_id_mod_qualified_cert_88            OBJ_id_pkix_mod,10L\n\n#define SN_id_mod_qualified_cert_93             \"id-mod-qualified-cert-93\"\n#define NID_id_mod_qualified_cert_93            279\n#define OBJ_id_mod_qualified_cert_93            OBJ_id_pkix_mod,11L\n\n#define SN_id_mod_attribute_cert                \"id-mod-attribute-cert\"\n#define NID_id_mod_attribute_cert               280\n#define OBJ_id_mod_attribute_cert               OBJ_id_pkix_mod,12L\n\n#define SN_id_mod_timestamp_protocol            \"id-mod-timestamp-protocol\"\n#define NID_id_mod_timestamp_protocol           281\n#define OBJ_id_mod_timestamp_protocol           OBJ_id_pkix_mod,13L\n\n#define SN_id_mod_ocsp          \"id-mod-ocsp\"\n#define NID_id_mod_ocsp         282\n#define OBJ_id_mod_ocsp         OBJ_id_pkix_mod,14L\n\n#define SN_id_mod_dvcs          \"id-mod-dvcs\"\n#define NID_id_mod_dvcs         283\n#define OBJ_id_mod_dvcs         OBJ_id_pkix_mod,15L\n\n#define SN_id_mod_cmp2000               \"id-mod-cmp2000\"\n#define NID_id_mod_cmp2000              284\n#define OBJ_id_mod_cmp2000              OBJ_id_pkix_mod,16L\n\n#define SN_info_access          \"authorityInfoAccess\"\n#define LN_info_access          \"Authority Information Access\"\n#define NID_info_access         177\n#define OBJ_info_access         OBJ_id_pe,1L\n\n#define SN_biometricInfo                \"biometricInfo\"\n#define LN_biometricInfo                \"Biometric Info\"\n#define NID_biometricInfo               285\n#define OBJ_biometricInfo               OBJ_id_pe,2L\n\n#define SN_qcStatements         \"qcStatements\"\n#define NID_qcStatements                286\n#define OBJ_qcStatements                OBJ_id_pe,3L\n\n#define SN_ac_auditEntity               \"ac-auditEntity\"\n#define NID_ac_auditEntity              287\n#define OBJ_ac_auditEntity              OBJ_id_pe,4L\n\n#define SN_ac_targeting         \"ac-targeting\"\n#define NID_ac_targeting                288\n#define OBJ_ac_targeting                OBJ_id_pe,5L\n\n#define SN_aaControls           \"aaControls\"\n#define NID_aaControls          289\n#define OBJ_aaControls          OBJ_id_pe,6L\n\n#define SN_sbgp_ipAddrBlock             \"sbgp-ipAddrBlock\"\n#define NID_sbgp_ipAddrBlock            290\n#define OBJ_sbgp_ipAddrBlock            OBJ_id_pe,7L\n\n#define SN_sbgp_autonomousSysNum                \"sbgp-autonomousSysNum\"\n#define NID_sbgp_autonomousSysNum               291\n#define OBJ_sbgp_autonomousSysNum               OBJ_id_pe,8L\n\n#define SN_sbgp_routerIdentifier                \"sbgp-routerIdentifier\"\n#define NID_sbgp_routerIdentifier               292\n#define OBJ_sbgp_routerIdentifier               OBJ_id_pe,9L\n\n#define SN_ac_proxying          \"ac-proxying\"\n#define NID_ac_proxying         397\n#define OBJ_ac_proxying         OBJ_id_pe,10L\n\n#define SN_sinfo_access         \"subjectInfoAccess\"\n#define LN_sinfo_access         \"Subject Information Access\"\n#define NID_sinfo_access                398\n#define OBJ_sinfo_access                OBJ_id_pe,11L\n\n#define SN_proxyCertInfo                \"proxyCertInfo\"\n#define LN_proxyCertInfo                \"Proxy Certificate Information\"\n#define NID_proxyCertInfo               663\n#define OBJ_proxyCertInfo               OBJ_id_pe,14L\n\n#define SN_tlsfeature           \"tlsfeature\"\n#define LN_tlsfeature           \"TLS Feature\"\n#define NID_tlsfeature          1020\n#define OBJ_tlsfeature          OBJ_id_pe,24L\n\n#define SN_id_qt_cps            \"id-qt-cps\"\n#define LN_id_qt_cps            \"Policy Qualifier CPS\"\n#define NID_id_qt_cps           164\n#define OBJ_id_qt_cps           OBJ_id_qt,1L\n\n#define SN_id_qt_unotice                \"id-qt-unotice\"\n#define LN_id_qt_unotice                \"Policy Qualifier User Notice\"\n#define NID_id_qt_unotice               165\n#define OBJ_id_qt_unotice               OBJ_id_qt,2L\n\n#define SN_textNotice           \"textNotice\"\n#define NID_textNotice          293\n#define OBJ_textNotice          OBJ_id_qt,3L\n\n#define SN_server_auth          \"serverAuth\"\n#define LN_server_auth          \"TLS Web Server Authentication\"\n#define NID_server_auth         129\n#define OBJ_server_auth         OBJ_id_kp,1L\n\n#define SN_client_auth          \"clientAuth\"\n#define LN_client_auth          \"TLS Web Client Authentication\"\n#define NID_client_auth         130\n#define OBJ_client_auth         OBJ_id_kp,2L\n\n#define SN_code_sign            \"codeSigning\"\n#define LN_code_sign            \"Code Signing\"\n#define NID_code_sign           131\n#define OBJ_code_sign           OBJ_id_kp,3L\n\n#define SN_email_protect                \"emailProtection\"\n#define LN_email_protect                \"E-mail Protection\"\n#define NID_email_protect               132\n#define OBJ_email_protect               OBJ_id_kp,4L\n\n#define SN_ipsecEndSystem               \"ipsecEndSystem\"\n#define LN_ipsecEndSystem               \"IPSec End System\"\n#define NID_ipsecEndSystem              294\n#define OBJ_ipsecEndSystem              OBJ_id_kp,5L\n\n#define SN_ipsecTunnel          \"ipsecTunnel\"\n#define LN_ipsecTunnel          \"IPSec Tunnel\"\n#define NID_ipsecTunnel         295\n#define OBJ_ipsecTunnel         OBJ_id_kp,6L\n\n#define SN_ipsecUser            \"ipsecUser\"\n#define LN_ipsecUser            \"IPSec User\"\n#define NID_ipsecUser           296\n#define OBJ_ipsecUser           OBJ_id_kp,7L\n\n#define SN_time_stamp           \"timeStamping\"\n#define LN_time_stamp           \"Time Stamping\"\n#define NID_time_stamp          133\n#define OBJ_time_stamp          OBJ_id_kp,8L\n\n#define SN_OCSP_sign            \"OCSPSigning\"\n#define LN_OCSP_sign            \"OCSP Signing\"\n#define NID_OCSP_sign           180\n#define OBJ_OCSP_sign           OBJ_id_kp,9L\n\n#define SN_dvcs         \"DVCS\"\n#define LN_dvcs         \"dvcs\"\n#define NID_dvcs                297\n#define OBJ_dvcs                OBJ_id_kp,10L\n\n#define SN_ipsec_IKE            \"ipsecIKE\"\n#define LN_ipsec_IKE            \"ipsec Internet Key Exchange\"\n#define NID_ipsec_IKE           1022\n#define OBJ_ipsec_IKE           OBJ_id_kp,17L\n\n#define SN_capwapAC             \"capwapAC\"\n#define LN_capwapAC             \"Ctrl/provision WAP Access\"\n#define NID_capwapAC            1023\n#define OBJ_capwapAC            OBJ_id_kp,18L\n\n#define SN_capwapWTP            \"capwapWTP\"\n#define LN_capwapWTP            \"Ctrl/Provision WAP Termination\"\n#define NID_capwapWTP           1024\n#define OBJ_capwapWTP           OBJ_id_kp,19L\n\n#define SN_sshClient            \"secureShellClient\"\n#define LN_sshClient            \"SSH Client\"\n#define NID_sshClient           1025\n#define OBJ_sshClient           OBJ_id_kp,21L\n\n#define SN_sshServer            \"secureShellServer\"\n#define LN_sshServer            \"SSH Server\"\n#define NID_sshServer           1026\n#define OBJ_sshServer           OBJ_id_kp,22L\n\n#define SN_sendRouter           \"sendRouter\"\n#define LN_sendRouter           \"Send Router\"\n#define NID_sendRouter          1027\n#define OBJ_sendRouter          OBJ_id_kp,23L\n\n#define SN_sendProxiedRouter            \"sendProxiedRouter\"\n#define LN_sendProxiedRouter            \"Send Proxied Router\"\n#define NID_sendProxiedRouter           1028\n#define OBJ_sendProxiedRouter           OBJ_id_kp,24L\n\n#define SN_sendOwner            \"sendOwner\"\n#define LN_sendOwner            \"Send Owner\"\n#define NID_sendOwner           1029\n#define OBJ_sendOwner           OBJ_id_kp,25L\n\n#define SN_sendProxiedOwner             \"sendProxiedOwner\"\n#define LN_sendProxiedOwner             \"Send Proxied Owner\"\n#define NID_sendProxiedOwner            1030\n#define OBJ_sendProxiedOwner            OBJ_id_kp,26L\n\n#define SN_cmcCA                \"cmcCA\"\n#define LN_cmcCA                \"CMC Certificate Authority\"\n#define NID_cmcCA               1131\n#define OBJ_cmcCA               OBJ_id_kp,27L\n\n#define SN_cmcRA                \"cmcRA\"\n#define LN_cmcRA                \"CMC Registration Authority\"\n#define NID_cmcRA               1132\n#define OBJ_cmcRA               OBJ_id_kp,28L\n\n#define SN_id_it_caProtEncCert          \"id-it-caProtEncCert\"\n#define NID_id_it_caProtEncCert         298\n#define OBJ_id_it_caProtEncCert         OBJ_id_it,1L\n\n#define SN_id_it_signKeyPairTypes               \"id-it-signKeyPairTypes\"\n#define NID_id_it_signKeyPairTypes              299\n#define OBJ_id_it_signKeyPairTypes              OBJ_id_it,2L\n\n#define SN_id_it_encKeyPairTypes                \"id-it-encKeyPairTypes\"\n#define NID_id_it_encKeyPairTypes               300\n#define OBJ_id_it_encKeyPairTypes               OBJ_id_it,3L\n\n#define SN_id_it_preferredSymmAlg               \"id-it-preferredSymmAlg\"\n#define NID_id_it_preferredSymmAlg              301\n#define OBJ_id_it_preferredSymmAlg              OBJ_id_it,4L\n\n#define SN_id_it_caKeyUpdateInfo                \"id-it-caKeyUpdateInfo\"\n#define NID_id_it_caKeyUpdateInfo               302\n#define OBJ_id_it_caKeyUpdateInfo               OBJ_id_it,5L\n\n#define SN_id_it_currentCRL             \"id-it-currentCRL\"\n#define NID_id_it_currentCRL            303\n#define OBJ_id_it_currentCRL            OBJ_id_it,6L\n\n#define SN_id_it_unsupportedOIDs                \"id-it-unsupportedOIDs\"\n#define NID_id_it_unsupportedOIDs               304\n#define OBJ_id_it_unsupportedOIDs               OBJ_id_it,7L\n\n#define SN_id_it_subscriptionRequest            \"id-it-subscriptionRequest\"\n#define NID_id_it_subscriptionRequest           305\n#define OBJ_id_it_subscriptionRequest           OBJ_id_it,8L\n\n#define SN_id_it_subscriptionResponse           \"id-it-subscriptionResponse\"\n#define NID_id_it_subscriptionResponse          306\n#define OBJ_id_it_subscriptionResponse          OBJ_id_it,9L\n\n#define SN_id_it_keyPairParamReq                \"id-it-keyPairParamReq\"\n#define NID_id_it_keyPairParamReq               307\n#define OBJ_id_it_keyPairParamReq               OBJ_id_it,10L\n\n#define SN_id_it_keyPairParamRep                \"id-it-keyPairParamRep\"\n#define NID_id_it_keyPairParamRep               308\n#define OBJ_id_it_keyPairParamRep               OBJ_id_it,11L\n\n#define SN_id_it_revPassphrase          \"id-it-revPassphrase\"\n#define NID_id_it_revPassphrase         309\n#define OBJ_id_it_revPassphrase         OBJ_id_it,12L\n\n#define SN_id_it_implicitConfirm                \"id-it-implicitConfirm\"\n#define NID_id_it_implicitConfirm               310\n#define OBJ_id_it_implicitConfirm               OBJ_id_it,13L\n\n#define SN_id_it_confirmWaitTime                \"id-it-confirmWaitTime\"\n#define NID_id_it_confirmWaitTime               311\n#define OBJ_id_it_confirmWaitTime               OBJ_id_it,14L\n\n#define SN_id_it_origPKIMessage         \"id-it-origPKIMessage\"\n#define NID_id_it_origPKIMessage                312\n#define OBJ_id_it_origPKIMessage                OBJ_id_it,15L\n\n#define SN_id_it_suppLangTags           \"id-it-suppLangTags\"\n#define NID_id_it_suppLangTags          784\n#define OBJ_id_it_suppLangTags          OBJ_id_it,16L\n\n#define SN_id_regCtrl           \"id-regCtrl\"\n#define NID_id_regCtrl          313\n#define OBJ_id_regCtrl          OBJ_id_pkip,1L\n\n#define SN_id_regInfo           \"id-regInfo\"\n#define NID_id_regInfo          314\n#define OBJ_id_regInfo          OBJ_id_pkip,2L\n\n#define SN_id_regCtrl_regToken          \"id-regCtrl-regToken\"\n#define NID_id_regCtrl_regToken         315\n#define OBJ_id_regCtrl_regToken         OBJ_id_regCtrl,1L\n\n#define SN_id_regCtrl_authenticator             \"id-regCtrl-authenticator\"\n#define NID_id_regCtrl_authenticator            316\n#define OBJ_id_regCtrl_authenticator            OBJ_id_regCtrl,2L\n\n#define SN_id_regCtrl_pkiPublicationInfo                \"id-regCtrl-pkiPublicationInfo\"\n#define NID_id_regCtrl_pkiPublicationInfo               317\n#define OBJ_id_regCtrl_pkiPublicationInfo               OBJ_id_regCtrl,3L\n\n#define SN_id_regCtrl_pkiArchiveOptions         \"id-regCtrl-pkiArchiveOptions\"\n#define NID_id_regCtrl_pkiArchiveOptions                318\n#define OBJ_id_regCtrl_pkiArchiveOptions                OBJ_id_regCtrl,4L\n\n#define SN_id_regCtrl_oldCertID         \"id-regCtrl-oldCertID\"\n#define NID_id_regCtrl_oldCertID                319\n#define OBJ_id_regCtrl_oldCertID                OBJ_id_regCtrl,5L\n\n#define SN_id_regCtrl_protocolEncrKey           \"id-regCtrl-protocolEncrKey\"\n#define NID_id_regCtrl_protocolEncrKey          320\n#define OBJ_id_regCtrl_protocolEncrKey          OBJ_id_regCtrl,6L\n\n#define SN_id_regInfo_utf8Pairs         \"id-regInfo-utf8Pairs\"\n#define NID_id_regInfo_utf8Pairs                321\n#define OBJ_id_regInfo_utf8Pairs                OBJ_id_regInfo,1L\n\n#define SN_id_regInfo_certReq           \"id-regInfo-certReq\"\n#define NID_id_regInfo_certReq          322\n#define OBJ_id_regInfo_certReq          OBJ_id_regInfo,2L\n\n#define SN_id_alg_des40         \"id-alg-des40\"\n#define NID_id_alg_des40                323\n#define OBJ_id_alg_des40                OBJ_id_alg,1L\n\n#define SN_id_alg_noSignature           \"id-alg-noSignature\"\n#define NID_id_alg_noSignature          324\n#define OBJ_id_alg_noSignature          OBJ_id_alg,2L\n\n#define SN_id_alg_dh_sig_hmac_sha1              \"id-alg-dh-sig-hmac-sha1\"\n#define NID_id_alg_dh_sig_hmac_sha1             325\n#define OBJ_id_alg_dh_sig_hmac_sha1             OBJ_id_alg,3L\n\n#define SN_id_alg_dh_pop                \"id-alg-dh-pop\"\n#define NID_id_alg_dh_pop               326\n#define OBJ_id_alg_dh_pop               OBJ_id_alg,4L\n\n#define SN_id_cmc_statusInfo            \"id-cmc-statusInfo\"\n#define NID_id_cmc_statusInfo           327\n#define OBJ_id_cmc_statusInfo           OBJ_id_cmc,1L\n\n#define SN_id_cmc_identification                \"id-cmc-identification\"\n#define NID_id_cmc_identification               328\n#define OBJ_id_cmc_identification               OBJ_id_cmc,2L\n\n#define SN_id_cmc_identityProof         \"id-cmc-identityProof\"\n#define NID_id_cmc_identityProof                329\n#define OBJ_id_cmc_identityProof                OBJ_id_cmc,3L\n\n#define SN_id_cmc_dataReturn            \"id-cmc-dataReturn\"\n#define NID_id_cmc_dataReturn           330\n#define OBJ_id_cmc_dataReturn           OBJ_id_cmc,4L\n\n#define SN_id_cmc_transactionId         \"id-cmc-transactionId\"\n#define NID_id_cmc_transactionId                331\n#define OBJ_id_cmc_transactionId                OBJ_id_cmc,5L\n\n#define SN_id_cmc_senderNonce           \"id-cmc-senderNonce\"\n#define NID_id_cmc_senderNonce          332\n#define OBJ_id_cmc_senderNonce          OBJ_id_cmc,6L\n\n#define SN_id_cmc_recipientNonce                \"id-cmc-recipientNonce\"\n#define NID_id_cmc_recipientNonce               333\n#define OBJ_id_cmc_recipientNonce               OBJ_id_cmc,7L\n\n#define SN_id_cmc_addExtensions         \"id-cmc-addExtensions\"\n#define NID_id_cmc_addExtensions                334\n#define OBJ_id_cmc_addExtensions                OBJ_id_cmc,8L\n\n#define SN_id_cmc_encryptedPOP          \"id-cmc-encryptedPOP\"\n#define NID_id_cmc_encryptedPOP         335\n#define OBJ_id_cmc_encryptedPOP         OBJ_id_cmc,9L\n\n#define SN_id_cmc_decryptedPOP          \"id-cmc-decryptedPOP\"\n#define NID_id_cmc_decryptedPOP         336\n#define OBJ_id_cmc_decryptedPOP         OBJ_id_cmc,10L\n\n#define SN_id_cmc_lraPOPWitness         \"id-cmc-lraPOPWitness\"\n#define NID_id_cmc_lraPOPWitness                337\n#define OBJ_id_cmc_lraPOPWitness                OBJ_id_cmc,11L\n\n#define SN_id_cmc_getCert               \"id-cmc-getCert\"\n#define NID_id_cmc_getCert              338\n#define OBJ_id_cmc_getCert              OBJ_id_cmc,15L\n\n#define SN_id_cmc_getCRL                \"id-cmc-getCRL\"\n#define NID_id_cmc_getCRL               339\n#define OBJ_id_cmc_getCRL               OBJ_id_cmc,16L\n\n#define SN_id_cmc_revokeRequest         \"id-cmc-revokeRequest\"\n#define NID_id_cmc_revokeRequest                340\n#define OBJ_id_cmc_revokeRequest                OBJ_id_cmc,17L\n\n#define SN_id_cmc_regInfo               \"id-cmc-regInfo\"\n#define NID_id_cmc_regInfo              341\n#define OBJ_id_cmc_regInfo              OBJ_id_cmc,18L\n\n#define SN_id_cmc_responseInfo          \"id-cmc-responseInfo\"\n#define NID_id_cmc_responseInfo         342\n#define OBJ_id_cmc_responseInfo         OBJ_id_cmc,19L\n\n#define SN_id_cmc_queryPending          \"id-cmc-queryPending\"\n#define NID_id_cmc_queryPending         343\n#define OBJ_id_cmc_queryPending         OBJ_id_cmc,21L\n\n#define SN_id_cmc_popLinkRandom         \"id-cmc-popLinkRandom\"\n#define NID_id_cmc_popLinkRandom                344\n#define OBJ_id_cmc_popLinkRandom                OBJ_id_cmc,22L\n\n#define SN_id_cmc_popLinkWitness                \"id-cmc-popLinkWitness\"\n#define NID_id_cmc_popLinkWitness               345\n#define OBJ_id_cmc_popLinkWitness               OBJ_id_cmc,23L\n\n#define SN_id_cmc_confirmCertAcceptance         \"id-cmc-confirmCertAcceptance\"\n#define NID_id_cmc_confirmCertAcceptance                346\n#define OBJ_id_cmc_confirmCertAcceptance                OBJ_id_cmc,24L\n\n#define SN_id_on_personalData           \"id-on-personalData\"\n#define NID_id_on_personalData          347\n#define OBJ_id_on_personalData          OBJ_id_on,1L\n\n#define SN_id_on_permanentIdentifier            \"id-on-permanentIdentifier\"\n#define LN_id_on_permanentIdentifier            \"Permanent Identifier\"\n#define NID_id_on_permanentIdentifier           858\n#define OBJ_id_on_permanentIdentifier           OBJ_id_on,3L\n\n#define SN_id_pda_dateOfBirth           \"id-pda-dateOfBirth\"\n#define NID_id_pda_dateOfBirth          348\n#define OBJ_id_pda_dateOfBirth          OBJ_id_pda,1L\n\n#define SN_id_pda_placeOfBirth          \"id-pda-placeOfBirth\"\n#define NID_id_pda_placeOfBirth         349\n#define OBJ_id_pda_placeOfBirth         OBJ_id_pda,2L\n\n#define SN_id_pda_gender                \"id-pda-gender\"\n#define NID_id_pda_gender               351\n#define OBJ_id_pda_gender               OBJ_id_pda,3L\n\n#define SN_id_pda_countryOfCitizenship          \"id-pda-countryOfCitizenship\"\n#define NID_id_pda_countryOfCitizenship         352\n#define OBJ_id_pda_countryOfCitizenship         OBJ_id_pda,4L\n\n#define SN_id_pda_countryOfResidence            \"id-pda-countryOfResidence\"\n#define NID_id_pda_countryOfResidence           353\n#define OBJ_id_pda_countryOfResidence           OBJ_id_pda,5L\n\n#define SN_id_aca_authenticationInfo            \"id-aca-authenticationInfo\"\n#define NID_id_aca_authenticationInfo           354\n#define OBJ_id_aca_authenticationInfo           OBJ_id_aca,1L\n\n#define SN_id_aca_accessIdentity                \"id-aca-accessIdentity\"\n#define NID_id_aca_accessIdentity               355\n#define OBJ_id_aca_accessIdentity               OBJ_id_aca,2L\n\n#define SN_id_aca_chargingIdentity              \"id-aca-chargingIdentity\"\n#define NID_id_aca_chargingIdentity             356\n#define OBJ_id_aca_chargingIdentity             OBJ_id_aca,3L\n\n#define SN_id_aca_group         \"id-aca-group\"\n#define NID_id_aca_group                357\n#define OBJ_id_aca_group                OBJ_id_aca,4L\n\n#define SN_id_aca_role          \"id-aca-role\"\n#define NID_id_aca_role         358\n#define OBJ_id_aca_role         OBJ_id_aca,5L\n\n#define SN_id_aca_encAttrs              \"id-aca-encAttrs\"\n#define NID_id_aca_encAttrs             399\n#define OBJ_id_aca_encAttrs             OBJ_id_aca,6L\n\n#define SN_id_qcs_pkixQCSyntax_v1               \"id-qcs-pkixQCSyntax-v1\"\n#define NID_id_qcs_pkixQCSyntax_v1              359\n#define OBJ_id_qcs_pkixQCSyntax_v1              OBJ_id_qcs,1L\n\n#define SN_id_cct_crs           \"id-cct-crs\"\n#define NID_id_cct_crs          360\n#define OBJ_id_cct_crs          OBJ_id_cct,1L\n\n#define SN_id_cct_PKIData               \"id-cct-PKIData\"\n#define NID_id_cct_PKIData              361\n#define OBJ_id_cct_PKIData              OBJ_id_cct,2L\n\n#define SN_id_cct_PKIResponse           \"id-cct-PKIResponse\"\n#define NID_id_cct_PKIResponse          362\n#define OBJ_id_cct_PKIResponse          OBJ_id_cct,3L\n\n#define SN_id_ppl_anyLanguage           \"id-ppl-anyLanguage\"\n#define LN_id_ppl_anyLanguage           \"Any language\"\n#define NID_id_ppl_anyLanguage          664\n#define OBJ_id_ppl_anyLanguage          OBJ_id_ppl,0L\n\n#define SN_id_ppl_inheritAll            \"id-ppl-inheritAll\"\n#define LN_id_ppl_inheritAll            \"Inherit all\"\n#define NID_id_ppl_inheritAll           665\n#define OBJ_id_ppl_inheritAll           OBJ_id_ppl,1L\n\n#define SN_Independent          \"id-ppl-independent\"\n#define LN_Independent          \"Independent\"\n#define NID_Independent         667\n#define OBJ_Independent         OBJ_id_ppl,2L\n\n#define SN_ad_OCSP              \"OCSP\"\n#define LN_ad_OCSP              \"OCSP\"\n#define NID_ad_OCSP             178\n#define OBJ_ad_OCSP             OBJ_id_ad,1L\n\n#define SN_ad_ca_issuers                \"caIssuers\"\n#define LN_ad_ca_issuers                \"CA Issuers\"\n#define NID_ad_ca_issuers               179\n#define OBJ_ad_ca_issuers               OBJ_id_ad,2L\n\n#define SN_ad_timeStamping              \"ad_timestamping\"\n#define LN_ad_timeStamping              \"AD Time Stamping\"\n#define NID_ad_timeStamping             363\n#define OBJ_ad_timeStamping             OBJ_id_ad,3L\n\n#define SN_ad_dvcs              \"AD_DVCS\"\n#define LN_ad_dvcs              \"ad dvcs\"\n#define NID_ad_dvcs             364\n#define OBJ_ad_dvcs             OBJ_id_ad,4L\n\n#define SN_caRepository         \"caRepository\"\n#define LN_caRepository         \"CA Repository\"\n#define NID_caRepository                785\n#define OBJ_caRepository                OBJ_id_ad,5L\n\n#define OBJ_id_pkix_OCSP                OBJ_ad_OCSP\n\n#define SN_id_pkix_OCSP_basic           \"basicOCSPResponse\"\n#define LN_id_pkix_OCSP_basic           \"Basic OCSP Response\"\n#define NID_id_pkix_OCSP_basic          365\n#define OBJ_id_pkix_OCSP_basic          OBJ_id_pkix_OCSP,1L\n\n#define SN_id_pkix_OCSP_Nonce           \"Nonce\"\n#define LN_id_pkix_OCSP_Nonce           \"OCSP Nonce\"\n#define NID_id_pkix_OCSP_Nonce          366\n#define OBJ_id_pkix_OCSP_Nonce          OBJ_id_pkix_OCSP,2L\n\n#define SN_id_pkix_OCSP_CrlID           \"CrlID\"\n#define LN_id_pkix_OCSP_CrlID           \"OCSP CRL ID\"\n#define NID_id_pkix_OCSP_CrlID          367\n#define OBJ_id_pkix_OCSP_CrlID          OBJ_id_pkix_OCSP,3L\n\n#define SN_id_pkix_OCSP_acceptableResponses             \"acceptableResponses\"\n#define LN_id_pkix_OCSP_acceptableResponses             \"Acceptable OCSP Responses\"\n#define NID_id_pkix_OCSP_acceptableResponses            368\n#define OBJ_id_pkix_OCSP_acceptableResponses            OBJ_id_pkix_OCSP,4L\n\n#define SN_id_pkix_OCSP_noCheck         \"noCheck\"\n#define LN_id_pkix_OCSP_noCheck         \"OCSP No Check\"\n#define NID_id_pkix_OCSP_noCheck                369\n#define OBJ_id_pkix_OCSP_noCheck                OBJ_id_pkix_OCSP,5L\n\n#define SN_id_pkix_OCSP_archiveCutoff           \"archiveCutoff\"\n#define LN_id_pkix_OCSP_archiveCutoff           \"OCSP Archive Cutoff\"\n#define NID_id_pkix_OCSP_archiveCutoff          370\n#define OBJ_id_pkix_OCSP_archiveCutoff          OBJ_id_pkix_OCSP,6L\n\n#define SN_id_pkix_OCSP_serviceLocator          \"serviceLocator\"\n#define LN_id_pkix_OCSP_serviceLocator          \"OCSP Service Locator\"\n#define NID_id_pkix_OCSP_serviceLocator         371\n#define OBJ_id_pkix_OCSP_serviceLocator         OBJ_id_pkix_OCSP,7L\n\n#define SN_id_pkix_OCSP_extendedStatus          \"extendedStatus\"\n#define LN_id_pkix_OCSP_extendedStatus          \"Extended OCSP Status\"\n#define NID_id_pkix_OCSP_extendedStatus         372\n#define OBJ_id_pkix_OCSP_extendedStatus         OBJ_id_pkix_OCSP,8L\n\n#define SN_id_pkix_OCSP_valid           \"valid\"\n#define NID_id_pkix_OCSP_valid          373\n#define OBJ_id_pkix_OCSP_valid          OBJ_id_pkix_OCSP,9L\n\n#define SN_id_pkix_OCSP_path            \"path\"\n#define NID_id_pkix_OCSP_path           374\n#define OBJ_id_pkix_OCSP_path           OBJ_id_pkix_OCSP,10L\n\n#define SN_id_pkix_OCSP_trustRoot               \"trustRoot\"\n#define LN_id_pkix_OCSP_trustRoot               \"Trust Root\"\n#define NID_id_pkix_OCSP_trustRoot              375\n#define OBJ_id_pkix_OCSP_trustRoot              OBJ_id_pkix_OCSP,11L\n\n#define SN_algorithm            \"algorithm\"\n#define LN_algorithm            \"algorithm\"\n#define NID_algorithm           376\n#define OBJ_algorithm           1L,3L,14L,3L,2L\n\n#define SN_md5WithRSA           \"RSA-NP-MD5\"\n#define LN_md5WithRSA           \"md5WithRSA\"\n#define NID_md5WithRSA          104\n#define OBJ_md5WithRSA          OBJ_algorithm,3L\n\n#define SN_des_ecb              \"DES-ECB\"\n#define LN_des_ecb              \"des-ecb\"\n#define NID_des_ecb             29\n#define OBJ_des_ecb             OBJ_algorithm,6L\n\n#define SN_des_cbc              \"DES-CBC\"\n#define LN_des_cbc              \"des-cbc\"\n#define NID_des_cbc             31\n#define OBJ_des_cbc             OBJ_algorithm,7L\n\n#define SN_des_ofb64            \"DES-OFB\"\n#define LN_des_ofb64            \"des-ofb\"\n#define NID_des_ofb64           45\n#define OBJ_des_ofb64           OBJ_algorithm,8L\n\n#define SN_des_cfb64            \"DES-CFB\"\n#define LN_des_cfb64            \"des-cfb\"\n#define NID_des_cfb64           30\n#define OBJ_des_cfb64           OBJ_algorithm,9L\n\n#define SN_rsaSignature         \"rsaSignature\"\n#define NID_rsaSignature                377\n#define OBJ_rsaSignature                OBJ_algorithm,11L\n\n#define SN_dsa_2                \"DSA-old\"\n#define LN_dsa_2                \"dsaEncryption-old\"\n#define NID_dsa_2               67\n#define OBJ_dsa_2               OBJ_algorithm,12L\n\n#define SN_dsaWithSHA           \"DSA-SHA\"\n#define LN_dsaWithSHA           \"dsaWithSHA\"\n#define NID_dsaWithSHA          66\n#define OBJ_dsaWithSHA          OBJ_algorithm,13L\n\n#define SN_shaWithRSAEncryption         \"RSA-SHA\"\n#define LN_shaWithRSAEncryption         \"shaWithRSAEncryption\"\n#define NID_shaWithRSAEncryption                42\n#define OBJ_shaWithRSAEncryption                OBJ_algorithm,15L\n\n#define SN_des_ede_ecb          \"DES-EDE\"\n#define LN_des_ede_ecb          \"des-ede\"\n#define NID_des_ede_ecb         32\n#define OBJ_des_ede_ecb         OBJ_algorithm,17L\n\n#define SN_des_ede3_ecb         \"DES-EDE3\"\n#define LN_des_ede3_ecb         \"des-ede3\"\n#define NID_des_ede3_ecb                33\n\n#define SN_des_ede_cbc          \"DES-EDE-CBC\"\n#define LN_des_ede_cbc          \"des-ede-cbc\"\n#define NID_des_ede_cbc         43\n\n#define SN_des_ede_cfb64                \"DES-EDE-CFB\"\n#define LN_des_ede_cfb64                \"des-ede-cfb\"\n#define NID_des_ede_cfb64               60\n\n#define SN_des_ede3_cfb64               \"DES-EDE3-CFB\"\n#define LN_des_ede3_cfb64               \"des-ede3-cfb\"\n#define NID_des_ede3_cfb64              61\n\n#define SN_des_ede_ofb64                \"DES-EDE-OFB\"\n#define LN_des_ede_ofb64                \"des-ede-ofb\"\n#define NID_des_ede_ofb64               62\n\n#define SN_des_ede3_ofb64               \"DES-EDE3-OFB\"\n#define LN_des_ede3_ofb64               \"des-ede3-ofb\"\n#define NID_des_ede3_ofb64              63\n\n#define SN_desx_cbc             \"DESX-CBC\"\n#define LN_desx_cbc             \"desx-cbc\"\n#define NID_desx_cbc            80\n\n#define SN_sha          \"SHA\"\n#define LN_sha          \"sha\"\n#define NID_sha         41\n#define OBJ_sha         OBJ_algorithm,18L\n\n#define SN_sha1         \"SHA1\"\n#define LN_sha1         \"sha1\"\n#define NID_sha1                64\n#define OBJ_sha1                OBJ_algorithm,26L\n\n#define SN_dsaWithSHA1_2                \"DSA-SHA1-old\"\n#define LN_dsaWithSHA1_2                \"dsaWithSHA1-old\"\n#define NID_dsaWithSHA1_2               70\n#define OBJ_dsaWithSHA1_2               OBJ_algorithm,27L\n\n#define SN_sha1WithRSA          \"RSA-SHA1-2\"\n#define LN_sha1WithRSA          \"sha1WithRSA\"\n#define NID_sha1WithRSA         115\n#define OBJ_sha1WithRSA         OBJ_algorithm,29L\n\n#define SN_ripemd160            \"RIPEMD160\"\n#define LN_ripemd160            \"ripemd160\"\n#define NID_ripemd160           117\n#define OBJ_ripemd160           1L,3L,36L,3L,2L,1L\n\n#define SN_ripemd160WithRSA             \"RSA-RIPEMD160\"\n#define LN_ripemd160WithRSA             \"ripemd160WithRSA\"\n#define NID_ripemd160WithRSA            119\n#define OBJ_ripemd160WithRSA            1L,3L,36L,3L,3L,1L,2L\n\n#define SN_blake2b512           \"BLAKE2b512\"\n#define LN_blake2b512           \"blake2b512\"\n#define NID_blake2b512          1056\n#define OBJ_blake2b512          1L,3L,6L,1L,4L,1L,1722L,12L,2L,1L,16L\n\n#define SN_blake2s256           \"BLAKE2s256\"\n#define LN_blake2s256           \"blake2s256\"\n#define NID_blake2s256          1057\n#define OBJ_blake2s256          1L,3L,6L,1L,4L,1L,1722L,12L,2L,2L,8L\n\n#define SN_sxnet                \"SXNetID\"\n#define LN_sxnet                \"Strong Extranet ID\"\n#define NID_sxnet               143\n#define OBJ_sxnet               1L,3L,101L,1L,4L,1L\n\n#define SN_X500         \"X500\"\n#define LN_X500         \"directory services (X.500)\"\n#define NID_X500                11\n#define OBJ_X500                2L,5L\n\n#define SN_X509         \"X509\"\n#define NID_X509                12\n#define OBJ_X509                OBJ_X500,4L\n\n#define SN_commonName           \"CN\"\n#define LN_commonName           \"commonName\"\n#define NID_commonName          13\n#define OBJ_commonName          OBJ_X509,3L\n\n#define SN_surname              \"SN\"\n#define LN_surname              \"surname\"\n#define NID_surname             100\n#define OBJ_surname             OBJ_X509,4L\n\n#define LN_serialNumber         \"serialNumber\"\n#define NID_serialNumber                105\n#define OBJ_serialNumber                OBJ_X509,5L\n\n#define SN_countryName          \"C\"\n#define LN_countryName          \"countryName\"\n#define NID_countryName         14\n#define OBJ_countryName         OBJ_X509,6L\n\n#define SN_localityName         \"L\"\n#define LN_localityName         \"localityName\"\n#define NID_localityName                15\n#define OBJ_localityName                OBJ_X509,7L\n\n#define SN_stateOrProvinceName          \"ST\"\n#define LN_stateOrProvinceName          \"stateOrProvinceName\"\n#define NID_stateOrProvinceName         16\n#define OBJ_stateOrProvinceName         OBJ_X509,8L\n\n#define SN_streetAddress                \"street\"\n#define LN_streetAddress                \"streetAddress\"\n#define NID_streetAddress               660\n#define OBJ_streetAddress               OBJ_X509,9L\n\n#define SN_organizationName             \"O\"\n#define LN_organizationName             \"organizationName\"\n#define NID_organizationName            17\n#define OBJ_organizationName            OBJ_X509,10L\n\n#define SN_organizationalUnitName               \"OU\"\n#define LN_organizationalUnitName               \"organizationalUnitName\"\n#define NID_organizationalUnitName              18\n#define OBJ_organizationalUnitName              OBJ_X509,11L\n\n#define SN_title                \"title\"\n#define LN_title                \"title\"\n#define NID_title               106\n#define OBJ_title               OBJ_X509,12L\n\n#define LN_description          \"description\"\n#define NID_description         107\n#define OBJ_description         OBJ_X509,13L\n\n#define LN_searchGuide          \"searchGuide\"\n#define NID_searchGuide         859\n#define OBJ_searchGuide         OBJ_X509,14L\n\n#define LN_businessCategory             \"businessCategory\"\n#define NID_businessCategory            860\n#define OBJ_businessCategory            OBJ_X509,15L\n\n#define LN_postalAddress                \"postalAddress\"\n#define NID_postalAddress               861\n#define OBJ_postalAddress               OBJ_X509,16L\n\n#define LN_postalCode           \"postalCode\"\n#define NID_postalCode          661\n#define OBJ_postalCode          OBJ_X509,17L\n\n#define LN_postOfficeBox                \"postOfficeBox\"\n#define NID_postOfficeBox               862\n#define OBJ_postOfficeBox               OBJ_X509,18L\n\n#define LN_physicalDeliveryOfficeName           \"physicalDeliveryOfficeName\"\n#define NID_physicalDeliveryOfficeName          863\n#define OBJ_physicalDeliveryOfficeName          OBJ_X509,19L\n\n#define LN_telephoneNumber              \"telephoneNumber\"\n#define NID_telephoneNumber             864\n#define OBJ_telephoneNumber             OBJ_X509,20L\n\n#define LN_telexNumber          \"telexNumber\"\n#define NID_telexNumber         865\n#define OBJ_telexNumber         OBJ_X509,21L\n\n#define LN_teletexTerminalIdentifier            \"teletexTerminalIdentifier\"\n#define NID_teletexTerminalIdentifier           866\n#define OBJ_teletexTerminalIdentifier           OBJ_X509,22L\n\n#define LN_facsimileTelephoneNumber             \"facsimileTelephoneNumber\"\n#define NID_facsimileTelephoneNumber            867\n#define OBJ_facsimileTelephoneNumber            OBJ_X509,23L\n\n#define LN_x121Address          \"x121Address\"\n#define NID_x121Address         868\n#define OBJ_x121Address         OBJ_X509,24L\n\n#define LN_internationaliSDNNumber              \"internationaliSDNNumber\"\n#define NID_internationaliSDNNumber             869\n#define OBJ_internationaliSDNNumber             OBJ_X509,25L\n\n#define LN_registeredAddress            \"registeredAddress\"\n#define NID_registeredAddress           870\n#define OBJ_registeredAddress           OBJ_X509,26L\n\n#define LN_destinationIndicator         \"destinationIndicator\"\n#define NID_destinationIndicator                871\n#define OBJ_destinationIndicator                OBJ_X509,27L\n\n#define LN_preferredDeliveryMethod              \"preferredDeliveryMethod\"\n#define NID_preferredDeliveryMethod             872\n#define OBJ_preferredDeliveryMethod             OBJ_X509,28L\n\n#define LN_presentationAddress          \"presentationAddress\"\n#define NID_presentationAddress         873\n#define OBJ_presentationAddress         OBJ_X509,29L\n\n#define LN_supportedApplicationContext          \"supportedApplicationContext\"\n#define NID_supportedApplicationContext         874\n#define OBJ_supportedApplicationContext         OBJ_X509,30L\n\n#define SN_member               \"member\"\n#define NID_member              875\n#define OBJ_member              OBJ_X509,31L\n\n#define SN_owner                \"owner\"\n#define NID_owner               876\n#define OBJ_owner               OBJ_X509,32L\n\n#define LN_roleOccupant         \"roleOccupant\"\n#define NID_roleOccupant                877\n#define OBJ_roleOccupant                OBJ_X509,33L\n\n#define SN_seeAlso              \"seeAlso\"\n#define NID_seeAlso             878\n#define OBJ_seeAlso             OBJ_X509,34L\n\n#define LN_userPassword         \"userPassword\"\n#define NID_userPassword                879\n#define OBJ_userPassword                OBJ_X509,35L\n\n#define LN_userCertificate              \"userCertificate\"\n#define NID_userCertificate             880\n#define OBJ_userCertificate             OBJ_X509,36L\n\n#define LN_cACertificate                \"cACertificate\"\n#define NID_cACertificate               881\n#define OBJ_cACertificate               OBJ_X509,37L\n\n#define LN_authorityRevocationList              \"authorityRevocationList\"\n#define NID_authorityRevocationList             882\n#define OBJ_authorityRevocationList             OBJ_X509,38L\n\n#define LN_certificateRevocationList            \"certificateRevocationList\"\n#define NID_certificateRevocationList           883\n#define OBJ_certificateRevocationList           OBJ_X509,39L\n\n#define LN_crossCertificatePair         \"crossCertificatePair\"\n#define NID_crossCertificatePair                884\n#define OBJ_crossCertificatePair                OBJ_X509,40L\n\n#define SN_name         \"name\"\n#define LN_name         \"name\"\n#define NID_name                173\n#define OBJ_name                OBJ_X509,41L\n\n#define SN_givenName            \"GN\"\n#define LN_givenName            \"givenName\"\n#define NID_givenName           99\n#define OBJ_givenName           OBJ_X509,42L\n\n#define SN_initials             \"initials\"\n#define LN_initials             \"initials\"\n#define NID_initials            101\n#define OBJ_initials            OBJ_X509,43L\n\n#define LN_generationQualifier          \"generationQualifier\"\n#define NID_generationQualifier         509\n#define OBJ_generationQualifier         OBJ_X509,44L\n\n#define LN_x500UniqueIdentifier         \"x500UniqueIdentifier\"\n#define NID_x500UniqueIdentifier                503\n#define OBJ_x500UniqueIdentifier                OBJ_X509,45L\n\n#define SN_dnQualifier          \"dnQualifier\"\n#define LN_dnQualifier          \"dnQualifier\"\n#define NID_dnQualifier         174\n#define OBJ_dnQualifier         OBJ_X509,46L\n\n#define LN_enhancedSearchGuide          \"enhancedSearchGuide\"\n#define NID_enhancedSearchGuide         885\n#define OBJ_enhancedSearchGuide         OBJ_X509,47L\n\n#define LN_protocolInformation          \"protocolInformation\"\n#define NID_protocolInformation         886\n#define OBJ_protocolInformation         OBJ_X509,48L\n\n#define LN_distinguishedName            \"distinguishedName\"\n#define NID_distinguishedName           887\n#define OBJ_distinguishedName           OBJ_X509,49L\n\n#define LN_uniqueMember         \"uniqueMember\"\n#define NID_uniqueMember                888\n#define OBJ_uniqueMember                OBJ_X509,50L\n\n#define LN_houseIdentifier              \"houseIdentifier\"\n#define NID_houseIdentifier             889\n#define OBJ_houseIdentifier             OBJ_X509,51L\n\n#define LN_supportedAlgorithms          \"supportedAlgorithms\"\n#define NID_supportedAlgorithms         890\n#define OBJ_supportedAlgorithms         OBJ_X509,52L\n\n#define LN_deltaRevocationList          \"deltaRevocationList\"\n#define NID_deltaRevocationList         891\n#define OBJ_deltaRevocationList         OBJ_X509,53L\n\n#define SN_dmdName              \"dmdName\"\n#define NID_dmdName             892\n#define OBJ_dmdName             OBJ_X509,54L\n\n#define LN_pseudonym            \"pseudonym\"\n#define NID_pseudonym           510\n#define OBJ_pseudonym           OBJ_X509,65L\n\n#define SN_role         \"role\"\n#define LN_role         \"role\"\n#define NID_role                400\n#define OBJ_role                OBJ_X509,72L\n\n#define LN_organizationIdentifier               \"organizationIdentifier\"\n#define NID_organizationIdentifier              1089\n#define OBJ_organizationIdentifier              OBJ_X509,97L\n\n#define SN_countryCode3c                \"c3\"\n#define LN_countryCode3c                \"countryCode3c\"\n#define NID_countryCode3c               1090\n#define OBJ_countryCode3c               OBJ_X509,98L\n\n#define SN_countryCode3n                \"n3\"\n#define LN_countryCode3n                \"countryCode3n\"\n#define NID_countryCode3n               1091\n#define OBJ_countryCode3n               OBJ_X509,99L\n\n#define LN_dnsName              \"dnsName\"\n#define NID_dnsName             1092\n#define OBJ_dnsName             OBJ_X509,100L\n\n#define SN_X500algorithms               \"X500algorithms\"\n#define LN_X500algorithms               \"directory services - algorithms\"\n#define NID_X500algorithms              378\n#define OBJ_X500algorithms              OBJ_X500,8L\n\n#define SN_rsa          \"RSA\"\n#define LN_rsa          \"rsa\"\n#define NID_rsa         19\n#define OBJ_rsa         OBJ_X500algorithms,1L,1L\n\n#define SN_mdc2WithRSA          \"RSA-MDC2\"\n#define LN_mdc2WithRSA          \"mdc2WithRSA\"\n#define NID_mdc2WithRSA         96\n#define OBJ_mdc2WithRSA         OBJ_X500algorithms,3L,100L\n\n#define SN_mdc2         \"MDC2\"\n#define LN_mdc2         \"mdc2\"\n#define NID_mdc2                95\n#define OBJ_mdc2                OBJ_X500algorithms,3L,101L\n\n#define SN_id_ce                \"id-ce\"\n#define NID_id_ce               81\n#define OBJ_id_ce               OBJ_X500,29L\n\n#define SN_subject_directory_attributes         \"subjectDirectoryAttributes\"\n#define LN_subject_directory_attributes         \"X509v3 Subject Directory Attributes\"\n#define NID_subject_directory_attributes                769\n#define OBJ_subject_directory_attributes                OBJ_id_ce,9L\n\n#define SN_subject_key_identifier               \"subjectKeyIdentifier\"\n#define LN_subject_key_identifier               \"X509v3 Subject Key Identifier\"\n#define NID_subject_key_identifier              82\n#define OBJ_subject_key_identifier              OBJ_id_ce,14L\n\n#define SN_key_usage            \"keyUsage\"\n#define LN_key_usage            \"X509v3 Key Usage\"\n#define NID_key_usage           83\n#define OBJ_key_usage           OBJ_id_ce,15L\n\n#define SN_private_key_usage_period             \"privateKeyUsagePeriod\"\n#define LN_private_key_usage_period             \"X509v3 Private Key Usage Period\"\n#define NID_private_key_usage_period            84\n#define OBJ_private_key_usage_period            OBJ_id_ce,16L\n\n#define SN_subject_alt_name             \"subjectAltName\"\n#define LN_subject_alt_name             \"X509v3 Subject Alternative Name\"\n#define NID_subject_alt_name            85\n#define OBJ_subject_alt_name            OBJ_id_ce,17L\n\n#define SN_issuer_alt_name              \"issuerAltName\"\n#define LN_issuer_alt_name              \"X509v3 Issuer Alternative Name\"\n#define NID_issuer_alt_name             86\n#define OBJ_issuer_alt_name             OBJ_id_ce,18L\n\n#define SN_basic_constraints            \"basicConstraints\"\n#define LN_basic_constraints            \"X509v3 Basic Constraints\"\n#define NID_basic_constraints           87\n#define OBJ_basic_constraints           OBJ_id_ce,19L\n\n#define SN_crl_number           \"crlNumber\"\n#define LN_crl_number           \"X509v3 CRL Number\"\n#define NID_crl_number          88\n#define OBJ_crl_number          OBJ_id_ce,20L\n\n#define SN_crl_reason           \"CRLReason\"\n#define LN_crl_reason           \"X509v3 CRL Reason Code\"\n#define NID_crl_reason          141\n#define OBJ_crl_reason          OBJ_id_ce,21L\n\n#define SN_invalidity_date              \"invalidityDate\"\n#define LN_invalidity_date              \"Invalidity Date\"\n#define NID_invalidity_date             142\n#define OBJ_invalidity_date             OBJ_id_ce,24L\n\n#define SN_delta_crl            \"deltaCRL\"\n#define LN_delta_crl            \"X509v3 Delta CRL Indicator\"\n#define NID_delta_crl           140\n#define OBJ_delta_crl           OBJ_id_ce,27L\n\n#define SN_issuing_distribution_point           \"issuingDistributionPoint\"\n#define LN_issuing_distribution_point           \"X509v3 Issuing Distribution Point\"\n#define NID_issuing_distribution_point          770\n#define OBJ_issuing_distribution_point          OBJ_id_ce,28L\n\n#define SN_certificate_issuer           \"certificateIssuer\"\n#define LN_certificate_issuer           \"X509v3 Certificate Issuer\"\n#define NID_certificate_issuer          771\n#define OBJ_certificate_issuer          OBJ_id_ce,29L\n\n#define SN_name_constraints             \"nameConstraints\"\n#define LN_name_constraints             \"X509v3 Name Constraints\"\n#define NID_name_constraints            666\n#define OBJ_name_constraints            OBJ_id_ce,30L\n\n#define SN_crl_distribution_points              \"crlDistributionPoints\"\n#define LN_crl_distribution_points              \"X509v3 CRL Distribution Points\"\n#define NID_crl_distribution_points             103\n#define OBJ_crl_distribution_points             OBJ_id_ce,31L\n\n#define SN_certificate_policies         \"certificatePolicies\"\n#define LN_certificate_policies         \"X509v3 Certificate Policies\"\n#define NID_certificate_policies                89\n#define OBJ_certificate_policies                OBJ_id_ce,32L\n\n#define SN_any_policy           \"anyPolicy\"\n#define LN_any_policy           \"X509v3 Any Policy\"\n#define NID_any_policy          746\n#define OBJ_any_policy          OBJ_certificate_policies,0L\n\n#define SN_policy_mappings              \"policyMappings\"\n#define LN_policy_mappings              \"X509v3 Policy Mappings\"\n#define NID_policy_mappings             747\n#define OBJ_policy_mappings             OBJ_id_ce,33L\n\n#define SN_authority_key_identifier             \"authorityKeyIdentifier\"\n#define LN_authority_key_identifier             \"X509v3 Authority Key Identifier\"\n#define NID_authority_key_identifier            90\n#define OBJ_authority_key_identifier            OBJ_id_ce,35L\n\n#define SN_policy_constraints           \"policyConstraints\"\n#define LN_policy_constraints           \"X509v3 Policy Constraints\"\n#define NID_policy_constraints          401\n#define OBJ_policy_constraints          OBJ_id_ce,36L\n\n#define SN_ext_key_usage                \"extendedKeyUsage\"\n#define LN_ext_key_usage                \"X509v3 Extended Key Usage\"\n#define NID_ext_key_usage               126\n#define OBJ_ext_key_usage               OBJ_id_ce,37L\n\n#define SN_freshest_crl         \"freshestCRL\"\n#define LN_freshest_crl         \"X509v3 Freshest CRL\"\n#define NID_freshest_crl                857\n#define OBJ_freshest_crl                OBJ_id_ce,46L\n\n#define SN_inhibit_any_policy           \"inhibitAnyPolicy\"\n#define LN_inhibit_any_policy           \"X509v3 Inhibit Any Policy\"\n#define NID_inhibit_any_policy          748\n#define OBJ_inhibit_any_policy          OBJ_id_ce,54L\n\n#define SN_target_information           \"targetInformation\"\n#define LN_target_information           \"X509v3 AC Targeting\"\n#define NID_target_information          402\n#define OBJ_target_information          OBJ_id_ce,55L\n\n#define SN_no_rev_avail         \"noRevAvail\"\n#define LN_no_rev_avail         \"X509v3 No Revocation Available\"\n#define NID_no_rev_avail                403\n#define OBJ_no_rev_avail                OBJ_id_ce,56L\n\n#define SN_anyExtendedKeyUsage          \"anyExtendedKeyUsage\"\n#define LN_anyExtendedKeyUsage          \"Any Extended Key Usage\"\n#define NID_anyExtendedKeyUsage         910\n#define OBJ_anyExtendedKeyUsage         OBJ_ext_key_usage,0L\n\n#define SN_netscape             \"Netscape\"\n#define LN_netscape             \"Netscape Communications Corp.\"\n#define NID_netscape            57\n#define OBJ_netscape            2L,16L,840L,1L,113730L\n\n#define SN_netscape_cert_extension              \"nsCertExt\"\n#define LN_netscape_cert_extension              \"Netscape Certificate Extension\"\n#define NID_netscape_cert_extension             58\n#define OBJ_netscape_cert_extension             OBJ_netscape,1L\n\n#define SN_netscape_data_type           \"nsDataType\"\n#define LN_netscape_data_type           \"Netscape Data Type\"\n#define NID_netscape_data_type          59\n#define OBJ_netscape_data_type          OBJ_netscape,2L\n\n#define SN_netscape_cert_type           \"nsCertType\"\n#define LN_netscape_cert_type           \"Netscape Cert Type\"\n#define NID_netscape_cert_type          71\n#define OBJ_netscape_cert_type          OBJ_netscape_cert_extension,1L\n\n#define SN_netscape_base_url            \"nsBaseUrl\"\n#define LN_netscape_base_url            \"Netscape Base Url\"\n#define NID_netscape_base_url           72\n#define OBJ_netscape_base_url           OBJ_netscape_cert_extension,2L\n\n#define SN_netscape_revocation_url              \"nsRevocationUrl\"\n#define LN_netscape_revocation_url              \"Netscape Revocation Url\"\n#define NID_netscape_revocation_url             73\n#define OBJ_netscape_revocation_url             OBJ_netscape_cert_extension,3L\n\n#define SN_netscape_ca_revocation_url           \"nsCaRevocationUrl\"\n#define LN_netscape_ca_revocation_url           \"Netscape CA Revocation Url\"\n#define NID_netscape_ca_revocation_url          74\n#define OBJ_netscape_ca_revocation_url          OBJ_netscape_cert_extension,4L\n\n#define SN_netscape_renewal_url         \"nsRenewalUrl\"\n#define LN_netscape_renewal_url         \"Netscape Renewal Url\"\n#define NID_netscape_renewal_url                75\n#define OBJ_netscape_renewal_url                OBJ_netscape_cert_extension,7L\n\n#define SN_netscape_ca_policy_url               \"nsCaPolicyUrl\"\n#define LN_netscape_ca_policy_url               \"Netscape CA Policy Url\"\n#define NID_netscape_ca_policy_url              76\n#define OBJ_netscape_ca_policy_url              OBJ_netscape_cert_extension,8L\n\n#define SN_netscape_ssl_server_name             \"nsSslServerName\"\n#define LN_netscape_ssl_server_name             \"Netscape SSL Server Name\"\n#define NID_netscape_ssl_server_name            77\n#define OBJ_netscape_ssl_server_name            OBJ_netscape_cert_extension,12L\n\n#define SN_netscape_comment             \"nsComment\"\n#define LN_netscape_comment             \"Netscape Comment\"\n#define NID_netscape_comment            78\n#define OBJ_netscape_comment            OBJ_netscape_cert_extension,13L\n\n#define SN_netscape_cert_sequence               \"nsCertSequence\"\n#define LN_netscape_cert_sequence               \"Netscape Certificate Sequence\"\n#define NID_netscape_cert_sequence              79\n#define OBJ_netscape_cert_sequence              OBJ_netscape_data_type,5L\n\n#define SN_ns_sgc               \"nsSGC\"\n#define LN_ns_sgc               \"Netscape Server Gated Crypto\"\n#define NID_ns_sgc              139\n#define OBJ_ns_sgc              OBJ_netscape,4L,1L\n\n#define SN_org          \"ORG\"\n#define LN_org          \"org\"\n#define NID_org         379\n#define OBJ_org         OBJ_iso,3L\n\n#define SN_dod          \"DOD\"\n#define LN_dod          \"dod\"\n#define NID_dod         380\n#define OBJ_dod         OBJ_org,6L\n\n#define SN_iana         \"IANA\"\n#define LN_iana         \"iana\"\n#define NID_iana                381\n#define OBJ_iana                OBJ_dod,1L\n\n#define OBJ_internet            OBJ_iana\n\n#define SN_Directory            \"directory\"\n#define LN_Directory            \"Directory\"\n#define NID_Directory           382\n#define OBJ_Directory           OBJ_internet,1L\n\n#define SN_Management           \"mgmt\"\n#define LN_Management           \"Management\"\n#define NID_Management          383\n#define OBJ_Management          OBJ_internet,2L\n\n#define SN_Experimental         \"experimental\"\n#define LN_Experimental         \"Experimental\"\n#define NID_Experimental                384\n#define OBJ_Experimental                OBJ_internet,3L\n\n#define SN_Private              \"private\"\n#define LN_Private              \"Private\"\n#define NID_Private             385\n#define OBJ_Private             OBJ_internet,4L\n\n#define SN_Security             \"security\"\n#define LN_Security             \"Security\"\n#define NID_Security            386\n#define OBJ_Security            OBJ_internet,5L\n\n#define SN_SNMPv2               \"snmpv2\"\n#define LN_SNMPv2               \"SNMPv2\"\n#define NID_SNMPv2              387\n#define OBJ_SNMPv2              OBJ_internet,6L\n\n#define LN_Mail         \"Mail\"\n#define NID_Mail                388\n#define OBJ_Mail                OBJ_internet,7L\n\n#define SN_Enterprises          \"enterprises\"\n#define LN_Enterprises          \"Enterprises\"\n#define NID_Enterprises         389\n#define OBJ_Enterprises         OBJ_Private,1L\n\n#define SN_dcObject             \"dcobject\"\n#define LN_dcObject             \"dcObject\"\n#define NID_dcObject            390\n#define OBJ_dcObject            OBJ_Enterprises,1466L,344L\n\n#define SN_mime_mhs             \"mime-mhs\"\n#define LN_mime_mhs             \"MIME MHS\"\n#define NID_mime_mhs            504\n#define OBJ_mime_mhs            OBJ_Mail,1L\n\n#define SN_mime_mhs_headings            \"mime-mhs-headings\"\n#define LN_mime_mhs_headings            \"mime-mhs-headings\"\n#define NID_mime_mhs_headings           505\n#define OBJ_mime_mhs_headings           OBJ_mime_mhs,1L\n\n#define SN_mime_mhs_bodies              \"mime-mhs-bodies\"\n#define LN_mime_mhs_bodies              \"mime-mhs-bodies\"\n#define NID_mime_mhs_bodies             506\n#define OBJ_mime_mhs_bodies             OBJ_mime_mhs,2L\n\n#define SN_id_hex_partial_message               \"id-hex-partial-message\"\n#define LN_id_hex_partial_message               \"id-hex-partial-message\"\n#define NID_id_hex_partial_message              507\n#define OBJ_id_hex_partial_message              OBJ_mime_mhs_headings,1L\n\n#define SN_id_hex_multipart_message             \"id-hex-multipart-message\"\n#define LN_id_hex_multipart_message             \"id-hex-multipart-message\"\n#define NID_id_hex_multipart_message            508\n#define OBJ_id_hex_multipart_message            OBJ_mime_mhs_headings,2L\n\n#define SN_zlib_compression             \"ZLIB\"\n#define LN_zlib_compression             \"zlib compression\"\n#define NID_zlib_compression            125\n#define OBJ_zlib_compression            OBJ_id_smime_alg,8L\n\n#define OBJ_csor                2L,16L,840L,1L,101L,3L\n\n#define OBJ_nistAlgorithms              OBJ_csor,4L\n\n#define OBJ_aes         OBJ_nistAlgorithms,1L\n\n#define SN_aes_128_ecb          \"AES-128-ECB\"\n#define LN_aes_128_ecb          \"aes-128-ecb\"\n#define NID_aes_128_ecb         418\n#define OBJ_aes_128_ecb         OBJ_aes,1L\n\n#define SN_aes_128_cbc          \"AES-128-CBC\"\n#define LN_aes_128_cbc          \"aes-128-cbc\"\n#define NID_aes_128_cbc         419\n#define OBJ_aes_128_cbc         OBJ_aes,2L\n\n#define SN_aes_128_ofb128               \"AES-128-OFB\"\n#define LN_aes_128_ofb128               \"aes-128-ofb\"\n#define NID_aes_128_ofb128              420\n#define OBJ_aes_128_ofb128              OBJ_aes,3L\n\n#define SN_aes_128_cfb128               \"AES-128-CFB\"\n#define LN_aes_128_cfb128               \"aes-128-cfb\"\n#define NID_aes_128_cfb128              421\n#define OBJ_aes_128_cfb128              OBJ_aes,4L\n\n#define SN_id_aes128_wrap               \"id-aes128-wrap\"\n#define NID_id_aes128_wrap              788\n#define OBJ_id_aes128_wrap              OBJ_aes,5L\n\n#define SN_aes_128_gcm          \"id-aes128-GCM\"\n#define LN_aes_128_gcm          \"aes-128-gcm\"\n#define NID_aes_128_gcm         895\n#define OBJ_aes_128_gcm         OBJ_aes,6L\n\n#define SN_aes_128_ccm          \"id-aes128-CCM\"\n#define LN_aes_128_ccm          \"aes-128-ccm\"\n#define NID_aes_128_ccm         896\n#define OBJ_aes_128_ccm         OBJ_aes,7L\n\n#define SN_id_aes128_wrap_pad           \"id-aes128-wrap-pad\"\n#define NID_id_aes128_wrap_pad          897\n#define OBJ_id_aes128_wrap_pad          OBJ_aes,8L\n\n#define SN_aes_192_ecb          \"AES-192-ECB\"\n#define LN_aes_192_ecb          \"aes-192-ecb\"\n#define NID_aes_192_ecb         422\n#define OBJ_aes_192_ecb         OBJ_aes,21L\n\n#define SN_aes_192_cbc          \"AES-192-CBC\"\n#define LN_aes_192_cbc          \"aes-192-cbc\"\n#define NID_aes_192_cbc         423\n#define OBJ_aes_192_cbc         OBJ_aes,22L\n\n#define SN_aes_192_ofb128               \"AES-192-OFB\"\n#define LN_aes_192_ofb128               \"aes-192-ofb\"\n#define NID_aes_192_ofb128              424\n#define OBJ_aes_192_ofb128              OBJ_aes,23L\n\n#define SN_aes_192_cfb128               \"AES-192-CFB\"\n#define LN_aes_192_cfb128               \"aes-192-cfb\"\n#define NID_aes_192_cfb128              425\n#define OBJ_aes_192_cfb128              OBJ_aes,24L\n\n#define SN_id_aes192_wrap               \"id-aes192-wrap\"\n#define NID_id_aes192_wrap              789\n#define OBJ_id_aes192_wrap              OBJ_aes,25L\n\n#define SN_aes_192_gcm          \"id-aes192-GCM\"\n#define LN_aes_192_gcm          \"aes-192-gcm\"\n#define NID_aes_192_gcm         898\n#define OBJ_aes_192_gcm         OBJ_aes,26L\n\n#define SN_aes_192_ccm          \"id-aes192-CCM\"\n#define LN_aes_192_ccm          \"aes-192-ccm\"\n#define NID_aes_192_ccm         899\n#define OBJ_aes_192_ccm         OBJ_aes,27L\n\n#define SN_id_aes192_wrap_pad           \"id-aes192-wrap-pad\"\n#define NID_id_aes192_wrap_pad          900\n#define OBJ_id_aes192_wrap_pad          OBJ_aes,28L\n\n#define SN_aes_256_ecb          \"AES-256-ECB\"\n#define LN_aes_256_ecb          \"aes-256-ecb\"\n#define NID_aes_256_ecb         426\n#define OBJ_aes_256_ecb         OBJ_aes,41L\n\n#define SN_aes_256_cbc          \"AES-256-CBC\"\n#define LN_aes_256_cbc          \"aes-256-cbc\"\n#define NID_aes_256_cbc         427\n#define OBJ_aes_256_cbc         OBJ_aes,42L\n\n#define SN_aes_256_ofb128               \"AES-256-OFB\"\n#define LN_aes_256_ofb128               \"aes-256-ofb\"\n#define NID_aes_256_ofb128              428\n#define OBJ_aes_256_ofb128              OBJ_aes,43L\n\n#define SN_aes_256_cfb128               \"AES-256-CFB\"\n#define LN_aes_256_cfb128               \"aes-256-cfb\"\n#define NID_aes_256_cfb128              429\n#define OBJ_aes_256_cfb128              OBJ_aes,44L\n\n#define SN_id_aes256_wrap               \"id-aes256-wrap\"\n#define NID_id_aes256_wrap              790\n#define OBJ_id_aes256_wrap              OBJ_aes,45L\n\n#define SN_aes_256_gcm          \"id-aes256-GCM\"\n#define LN_aes_256_gcm          \"aes-256-gcm\"\n#define NID_aes_256_gcm         901\n#define OBJ_aes_256_gcm         OBJ_aes,46L\n\n#define SN_aes_256_ccm          \"id-aes256-CCM\"\n#define LN_aes_256_ccm          \"aes-256-ccm\"\n#define NID_aes_256_ccm         902\n#define OBJ_aes_256_ccm         OBJ_aes,47L\n\n#define SN_id_aes256_wrap_pad           \"id-aes256-wrap-pad\"\n#define NID_id_aes256_wrap_pad          903\n#define OBJ_id_aes256_wrap_pad          OBJ_aes,48L\n\n#define SN_aes_128_xts          \"AES-128-XTS\"\n#define LN_aes_128_xts          \"aes-128-xts\"\n#define NID_aes_128_xts         913\n#define OBJ_aes_128_xts         OBJ_ieee_siswg,0L,1L,1L\n\n#define SN_aes_256_xts          \"AES-256-XTS\"\n#define LN_aes_256_xts          \"aes-256-xts\"\n#define NID_aes_256_xts         914\n#define OBJ_aes_256_xts         OBJ_ieee_siswg,0L,1L,2L\n\n#define SN_aes_128_cfb1         \"AES-128-CFB1\"\n#define LN_aes_128_cfb1         \"aes-128-cfb1\"\n#define NID_aes_128_cfb1                650\n\n#define SN_aes_192_cfb1         \"AES-192-CFB1\"\n#define LN_aes_192_cfb1         \"aes-192-cfb1\"\n#define NID_aes_192_cfb1                651\n\n#define SN_aes_256_cfb1         \"AES-256-CFB1\"\n#define LN_aes_256_cfb1         \"aes-256-cfb1\"\n#define NID_aes_256_cfb1                652\n\n#define SN_aes_128_cfb8         \"AES-128-CFB8\"\n#define LN_aes_128_cfb8         \"aes-128-cfb8\"\n#define NID_aes_128_cfb8                653\n\n#define SN_aes_192_cfb8         \"AES-192-CFB8\"\n#define LN_aes_192_cfb8         \"aes-192-cfb8\"\n#define NID_aes_192_cfb8                654\n\n#define SN_aes_256_cfb8         \"AES-256-CFB8\"\n#define LN_aes_256_cfb8         \"aes-256-cfb8\"\n#define NID_aes_256_cfb8                655\n\n#define SN_aes_128_ctr          \"AES-128-CTR\"\n#define LN_aes_128_ctr          \"aes-128-ctr\"\n#define NID_aes_128_ctr         904\n\n#define SN_aes_192_ctr          \"AES-192-CTR\"\n#define LN_aes_192_ctr          \"aes-192-ctr\"\n#define NID_aes_192_ctr         905\n\n#define SN_aes_256_ctr          \"AES-256-CTR\"\n#define LN_aes_256_ctr          \"aes-256-ctr\"\n#define NID_aes_256_ctr         906\n\n#define SN_aes_128_ocb          \"AES-128-OCB\"\n#define LN_aes_128_ocb          \"aes-128-ocb\"\n#define NID_aes_128_ocb         958\n\n#define SN_aes_192_ocb          \"AES-192-OCB\"\n#define LN_aes_192_ocb          \"aes-192-ocb\"\n#define NID_aes_192_ocb         959\n\n#define SN_aes_256_ocb          \"AES-256-OCB\"\n#define LN_aes_256_ocb          \"aes-256-ocb\"\n#define NID_aes_256_ocb         960\n\n#define SN_des_cfb1             \"DES-CFB1\"\n#define LN_des_cfb1             \"des-cfb1\"\n#define NID_des_cfb1            656\n\n#define SN_des_cfb8             \"DES-CFB8\"\n#define LN_des_cfb8             \"des-cfb8\"\n#define NID_des_cfb8            657\n\n#define SN_des_ede3_cfb1                \"DES-EDE3-CFB1\"\n#define LN_des_ede3_cfb1                \"des-ede3-cfb1\"\n#define NID_des_ede3_cfb1               658\n\n#define SN_des_ede3_cfb8                \"DES-EDE3-CFB8\"\n#define LN_des_ede3_cfb8                \"des-ede3-cfb8\"\n#define NID_des_ede3_cfb8               659\n\n#define OBJ_nist_hashalgs               OBJ_nistAlgorithms,2L\n\n#define SN_sha256               \"SHA256\"\n#define LN_sha256               \"sha256\"\n#define NID_sha256              672\n#define OBJ_sha256              OBJ_nist_hashalgs,1L\n\n#define SN_sha384               \"SHA384\"\n#define LN_sha384               \"sha384\"\n#define NID_sha384              673\n#define OBJ_sha384              OBJ_nist_hashalgs,2L\n\n#define SN_sha512               \"SHA512\"\n#define LN_sha512               \"sha512\"\n#define NID_sha512              674\n#define OBJ_sha512              OBJ_nist_hashalgs,3L\n\n#define SN_sha224               \"SHA224\"\n#define LN_sha224               \"sha224\"\n#define NID_sha224              675\n#define OBJ_sha224              OBJ_nist_hashalgs,4L\n\n#define SN_sha512_224           \"SHA512-224\"\n#define LN_sha512_224           \"sha512-224\"\n#define NID_sha512_224          1094\n#define OBJ_sha512_224          OBJ_nist_hashalgs,5L\n\n#define SN_sha512_256           \"SHA512-256\"\n#define LN_sha512_256           \"sha512-256\"\n#define NID_sha512_256          1095\n#define OBJ_sha512_256          OBJ_nist_hashalgs,6L\n\n#define SN_sha3_224             \"SHA3-224\"\n#define LN_sha3_224             \"sha3-224\"\n#define NID_sha3_224            1096\n#define OBJ_sha3_224            OBJ_nist_hashalgs,7L\n\n#define SN_sha3_256             \"SHA3-256\"\n#define LN_sha3_256             \"sha3-256\"\n#define NID_sha3_256            1097\n#define OBJ_sha3_256            OBJ_nist_hashalgs,8L\n\n#define SN_sha3_384             \"SHA3-384\"\n#define LN_sha3_384             \"sha3-384\"\n#define NID_sha3_384            1098\n#define OBJ_sha3_384            OBJ_nist_hashalgs,9L\n\n#define SN_sha3_512             \"SHA3-512\"\n#define LN_sha3_512             \"sha3-512\"\n#define NID_sha3_512            1099\n#define OBJ_sha3_512            OBJ_nist_hashalgs,10L\n\n#define SN_shake128             \"SHAKE128\"\n#define LN_shake128             \"shake128\"\n#define NID_shake128            1100\n#define OBJ_shake128            OBJ_nist_hashalgs,11L\n\n#define SN_shake256             \"SHAKE256\"\n#define LN_shake256             \"shake256\"\n#define NID_shake256            1101\n#define OBJ_shake256            OBJ_nist_hashalgs,12L\n\n#define SN_hmac_sha3_224                \"id-hmacWithSHA3-224\"\n#define LN_hmac_sha3_224                \"hmac-sha3-224\"\n#define NID_hmac_sha3_224               1102\n#define OBJ_hmac_sha3_224               OBJ_nist_hashalgs,13L\n\n#define SN_hmac_sha3_256                \"id-hmacWithSHA3-256\"\n#define LN_hmac_sha3_256                \"hmac-sha3-256\"\n#define NID_hmac_sha3_256               1103\n#define OBJ_hmac_sha3_256               OBJ_nist_hashalgs,14L\n\n#define SN_hmac_sha3_384                \"id-hmacWithSHA3-384\"\n#define LN_hmac_sha3_384                \"hmac-sha3-384\"\n#define NID_hmac_sha3_384               1104\n#define OBJ_hmac_sha3_384               OBJ_nist_hashalgs,15L\n\n#define SN_hmac_sha3_512                \"id-hmacWithSHA3-512\"\n#define LN_hmac_sha3_512                \"hmac-sha3-512\"\n#define NID_hmac_sha3_512               1105\n#define OBJ_hmac_sha3_512               OBJ_nist_hashalgs,16L\n\n#define OBJ_dsa_with_sha2               OBJ_nistAlgorithms,3L\n\n#define SN_dsa_with_SHA224              \"dsa_with_SHA224\"\n#define NID_dsa_with_SHA224             802\n#define OBJ_dsa_with_SHA224             OBJ_dsa_with_sha2,1L\n\n#define SN_dsa_with_SHA256              \"dsa_with_SHA256\"\n#define NID_dsa_with_SHA256             803\n#define OBJ_dsa_with_SHA256             OBJ_dsa_with_sha2,2L\n\n#define OBJ_sigAlgs             OBJ_nistAlgorithms,3L\n\n#define SN_dsa_with_SHA384              \"id-dsa-with-sha384\"\n#define LN_dsa_with_SHA384              \"dsa_with_SHA384\"\n#define NID_dsa_with_SHA384             1106\n#define OBJ_dsa_with_SHA384             OBJ_sigAlgs,3L\n\n#define SN_dsa_with_SHA512              \"id-dsa-with-sha512\"\n#define LN_dsa_with_SHA512              \"dsa_with_SHA512\"\n#define NID_dsa_with_SHA512             1107\n#define OBJ_dsa_with_SHA512             OBJ_sigAlgs,4L\n\n#define SN_dsa_with_SHA3_224            \"id-dsa-with-sha3-224\"\n#define LN_dsa_with_SHA3_224            \"dsa_with_SHA3-224\"\n#define NID_dsa_with_SHA3_224           1108\n#define OBJ_dsa_with_SHA3_224           OBJ_sigAlgs,5L\n\n#define SN_dsa_with_SHA3_256            \"id-dsa-with-sha3-256\"\n#define LN_dsa_with_SHA3_256            \"dsa_with_SHA3-256\"\n#define NID_dsa_with_SHA3_256           1109\n#define OBJ_dsa_with_SHA3_256           OBJ_sigAlgs,6L\n\n#define SN_dsa_with_SHA3_384            \"id-dsa-with-sha3-384\"\n#define LN_dsa_with_SHA3_384            \"dsa_with_SHA3-384\"\n#define NID_dsa_with_SHA3_384           1110\n#define OBJ_dsa_with_SHA3_384           OBJ_sigAlgs,7L\n\n#define SN_dsa_with_SHA3_512            \"id-dsa-with-sha3-512\"\n#define LN_dsa_with_SHA3_512            \"dsa_with_SHA3-512\"\n#define NID_dsa_with_SHA3_512           1111\n#define OBJ_dsa_with_SHA3_512           OBJ_sigAlgs,8L\n\n#define SN_ecdsa_with_SHA3_224          \"id-ecdsa-with-sha3-224\"\n#define LN_ecdsa_with_SHA3_224          \"ecdsa_with_SHA3-224\"\n#define NID_ecdsa_with_SHA3_224         1112\n#define OBJ_ecdsa_with_SHA3_224         OBJ_sigAlgs,9L\n\n#define SN_ecdsa_with_SHA3_256          \"id-ecdsa-with-sha3-256\"\n#define LN_ecdsa_with_SHA3_256          \"ecdsa_with_SHA3-256\"\n#define NID_ecdsa_with_SHA3_256         1113\n#define OBJ_ecdsa_with_SHA3_256         OBJ_sigAlgs,10L\n\n#define SN_ecdsa_with_SHA3_384          \"id-ecdsa-with-sha3-384\"\n#define LN_ecdsa_with_SHA3_384          \"ecdsa_with_SHA3-384\"\n#define NID_ecdsa_with_SHA3_384         1114\n#define OBJ_ecdsa_with_SHA3_384         OBJ_sigAlgs,11L\n\n#define SN_ecdsa_with_SHA3_512          \"id-ecdsa-with-sha3-512\"\n#define LN_ecdsa_with_SHA3_512          \"ecdsa_with_SHA3-512\"\n#define NID_ecdsa_with_SHA3_512         1115\n#define OBJ_ecdsa_with_SHA3_512         OBJ_sigAlgs,12L\n\n#define SN_RSA_SHA3_224         \"id-rsassa-pkcs1-v1_5-with-sha3-224\"\n#define LN_RSA_SHA3_224         \"RSA-SHA3-224\"\n#define NID_RSA_SHA3_224                1116\n#define OBJ_RSA_SHA3_224                OBJ_sigAlgs,13L\n\n#define SN_RSA_SHA3_256         \"id-rsassa-pkcs1-v1_5-with-sha3-256\"\n#define LN_RSA_SHA3_256         \"RSA-SHA3-256\"\n#define NID_RSA_SHA3_256                1117\n#define OBJ_RSA_SHA3_256                OBJ_sigAlgs,14L\n\n#define SN_RSA_SHA3_384         \"id-rsassa-pkcs1-v1_5-with-sha3-384\"\n#define LN_RSA_SHA3_384         \"RSA-SHA3-384\"\n#define NID_RSA_SHA3_384                1118\n#define OBJ_RSA_SHA3_384                OBJ_sigAlgs,15L\n\n#define SN_RSA_SHA3_512         \"id-rsassa-pkcs1-v1_5-with-sha3-512\"\n#define LN_RSA_SHA3_512         \"RSA-SHA3-512\"\n#define NID_RSA_SHA3_512                1119\n#define OBJ_RSA_SHA3_512                OBJ_sigAlgs,16L\n\n#define SN_hold_instruction_code                \"holdInstructionCode\"\n#define LN_hold_instruction_code                \"Hold Instruction Code\"\n#define NID_hold_instruction_code               430\n#define OBJ_hold_instruction_code               OBJ_id_ce,23L\n\n#define OBJ_holdInstruction             OBJ_X9_57,2L\n\n#define SN_hold_instruction_none                \"holdInstructionNone\"\n#define LN_hold_instruction_none                \"Hold Instruction None\"\n#define NID_hold_instruction_none               431\n#define OBJ_hold_instruction_none               OBJ_holdInstruction,1L\n\n#define SN_hold_instruction_call_issuer         \"holdInstructionCallIssuer\"\n#define LN_hold_instruction_call_issuer         \"Hold Instruction Call Issuer\"\n#define NID_hold_instruction_call_issuer                432\n#define OBJ_hold_instruction_call_issuer                OBJ_holdInstruction,2L\n\n#define SN_hold_instruction_reject              \"holdInstructionReject\"\n#define LN_hold_instruction_reject              \"Hold Instruction Reject\"\n#define NID_hold_instruction_reject             433\n#define OBJ_hold_instruction_reject             OBJ_holdInstruction,3L\n\n#define SN_data         \"data\"\n#define NID_data                434\n#define OBJ_data                OBJ_itu_t,9L\n\n#define SN_pss          \"pss\"\n#define NID_pss         435\n#define OBJ_pss         OBJ_data,2342L\n\n#define SN_ucl          \"ucl\"\n#define NID_ucl         436\n#define OBJ_ucl         OBJ_pss,19200300L\n\n#define SN_pilot                \"pilot\"\n#define NID_pilot               437\n#define OBJ_pilot               OBJ_ucl,100L\n\n#define LN_pilotAttributeType           \"pilotAttributeType\"\n#define NID_pilotAttributeType          438\n#define OBJ_pilotAttributeType          OBJ_pilot,1L\n\n#define LN_pilotAttributeSyntax         \"pilotAttributeSyntax\"\n#define NID_pilotAttributeSyntax                439\n#define OBJ_pilotAttributeSyntax                OBJ_pilot,3L\n\n#define LN_pilotObjectClass             \"pilotObjectClass\"\n#define NID_pilotObjectClass            440\n#define OBJ_pilotObjectClass            OBJ_pilot,4L\n\n#define LN_pilotGroups          \"pilotGroups\"\n#define NID_pilotGroups         441\n#define OBJ_pilotGroups         OBJ_pilot,10L\n\n#define LN_iA5StringSyntax              \"iA5StringSyntax\"\n#define NID_iA5StringSyntax             442\n#define OBJ_iA5StringSyntax             OBJ_pilotAttributeSyntax,4L\n\n#define LN_caseIgnoreIA5StringSyntax            \"caseIgnoreIA5StringSyntax\"\n#define NID_caseIgnoreIA5StringSyntax           443\n#define OBJ_caseIgnoreIA5StringSyntax           OBJ_pilotAttributeSyntax,5L\n\n#define LN_pilotObject          \"pilotObject\"\n#define NID_pilotObject         444\n#define OBJ_pilotObject         OBJ_pilotObjectClass,3L\n\n#define LN_pilotPerson          \"pilotPerson\"\n#define NID_pilotPerson         445\n#define OBJ_pilotPerson         OBJ_pilotObjectClass,4L\n\n#define SN_account              \"account\"\n#define NID_account             446\n#define OBJ_account             OBJ_pilotObjectClass,5L\n\n#define SN_document             \"document\"\n#define NID_document            447\n#define OBJ_document            OBJ_pilotObjectClass,6L\n\n#define SN_room         \"room\"\n#define NID_room                448\n#define OBJ_room                OBJ_pilotObjectClass,7L\n\n#define LN_documentSeries               \"documentSeries\"\n#define NID_documentSeries              449\n#define OBJ_documentSeries              OBJ_pilotObjectClass,9L\n\n#define SN_Domain               \"domain\"\n#define LN_Domain               \"Domain\"\n#define NID_Domain              392\n#define OBJ_Domain              OBJ_pilotObjectClass,13L\n\n#define LN_rFC822localPart              \"rFC822localPart\"\n#define NID_rFC822localPart             450\n#define OBJ_rFC822localPart             OBJ_pilotObjectClass,14L\n\n#define LN_dNSDomain            \"dNSDomain\"\n#define NID_dNSDomain           451\n#define OBJ_dNSDomain           OBJ_pilotObjectClass,15L\n\n#define LN_domainRelatedObject          \"domainRelatedObject\"\n#define NID_domainRelatedObject         452\n#define OBJ_domainRelatedObject         OBJ_pilotObjectClass,17L\n\n#define LN_friendlyCountry              \"friendlyCountry\"\n#define NID_friendlyCountry             453\n#define OBJ_friendlyCountry             OBJ_pilotObjectClass,18L\n\n#define LN_simpleSecurityObject         \"simpleSecurityObject\"\n#define NID_simpleSecurityObject                454\n#define OBJ_simpleSecurityObject                OBJ_pilotObjectClass,19L\n\n#define LN_pilotOrganization            \"pilotOrganization\"\n#define NID_pilotOrganization           455\n#define OBJ_pilotOrganization           OBJ_pilotObjectClass,20L\n\n#define LN_pilotDSA             \"pilotDSA\"\n#define NID_pilotDSA            456\n#define OBJ_pilotDSA            OBJ_pilotObjectClass,21L\n\n#define LN_qualityLabelledData          \"qualityLabelledData\"\n#define NID_qualityLabelledData         457\n#define OBJ_qualityLabelledData         OBJ_pilotObjectClass,22L\n\n#define SN_userId               \"UID\"\n#define LN_userId               \"userId\"\n#define NID_userId              458\n#define OBJ_userId              OBJ_pilotAttributeType,1L\n\n#define LN_textEncodedORAddress         \"textEncodedORAddress\"\n#define NID_textEncodedORAddress                459\n#define OBJ_textEncodedORAddress                OBJ_pilotAttributeType,2L\n\n#define SN_rfc822Mailbox                \"mail\"\n#define LN_rfc822Mailbox                \"rfc822Mailbox\"\n#define NID_rfc822Mailbox               460\n#define OBJ_rfc822Mailbox               OBJ_pilotAttributeType,3L\n\n#define SN_info         \"info\"\n#define NID_info                461\n#define OBJ_info                OBJ_pilotAttributeType,4L\n\n#define LN_favouriteDrink               \"favouriteDrink\"\n#define NID_favouriteDrink              462\n#define OBJ_favouriteDrink              OBJ_pilotAttributeType,5L\n\n#define LN_roomNumber           \"roomNumber\"\n#define NID_roomNumber          463\n#define OBJ_roomNumber          OBJ_pilotAttributeType,6L\n\n#define SN_photo                \"photo\"\n#define NID_photo               464\n#define OBJ_photo               OBJ_pilotAttributeType,7L\n\n#define LN_userClass            \"userClass\"\n#define NID_userClass           465\n#define OBJ_userClass           OBJ_pilotAttributeType,8L\n\n#define SN_host         \"host\"\n#define NID_host                466\n#define OBJ_host                OBJ_pilotAttributeType,9L\n\n#define SN_manager              \"manager\"\n#define NID_manager             467\n#define OBJ_manager             OBJ_pilotAttributeType,10L\n\n#define LN_documentIdentifier           \"documentIdentifier\"\n#define NID_documentIdentifier          468\n#define OBJ_documentIdentifier          OBJ_pilotAttributeType,11L\n\n#define LN_documentTitle                \"documentTitle\"\n#define NID_documentTitle               469\n#define OBJ_documentTitle               OBJ_pilotAttributeType,12L\n\n#define LN_documentVersion              \"documentVersion\"\n#define NID_documentVersion             470\n#define OBJ_documentVersion             OBJ_pilotAttributeType,13L\n\n#define LN_documentAuthor               \"documentAuthor\"\n#define NID_documentAuthor              471\n#define OBJ_documentAuthor              OBJ_pilotAttributeType,14L\n\n#define LN_documentLocation             \"documentLocation\"\n#define NID_documentLocation            472\n#define OBJ_documentLocation            OBJ_pilotAttributeType,15L\n\n#define LN_homeTelephoneNumber          \"homeTelephoneNumber\"\n#define NID_homeTelephoneNumber         473\n#define OBJ_homeTelephoneNumber         OBJ_pilotAttributeType,20L\n\n#define SN_secretary            \"secretary\"\n#define NID_secretary           474\n#define OBJ_secretary           OBJ_pilotAttributeType,21L\n\n#define LN_otherMailbox         \"otherMailbox\"\n#define NID_otherMailbox                475\n#define OBJ_otherMailbox                OBJ_pilotAttributeType,22L\n\n#define LN_lastModifiedTime             \"lastModifiedTime\"\n#define NID_lastModifiedTime            476\n#define OBJ_lastModifiedTime            OBJ_pilotAttributeType,23L\n\n#define LN_lastModifiedBy               \"lastModifiedBy\"\n#define NID_lastModifiedBy              477\n#define OBJ_lastModifiedBy              OBJ_pilotAttributeType,24L\n\n#define SN_domainComponent              \"DC\"\n#define LN_domainComponent              \"domainComponent\"\n#define NID_domainComponent             391\n#define OBJ_domainComponent             OBJ_pilotAttributeType,25L\n\n#define LN_aRecord              \"aRecord\"\n#define NID_aRecord             478\n#define OBJ_aRecord             OBJ_pilotAttributeType,26L\n\n#define LN_pilotAttributeType27         \"pilotAttributeType27\"\n#define NID_pilotAttributeType27                479\n#define OBJ_pilotAttributeType27                OBJ_pilotAttributeType,27L\n\n#define LN_mXRecord             \"mXRecord\"\n#define NID_mXRecord            480\n#define OBJ_mXRecord            OBJ_pilotAttributeType,28L\n\n#define LN_nSRecord             \"nSRecord\"\n#define NID_nSRecord            481\n#define OBJ_nSRecord            OBJ_pilotAttributeType,29L\n\n#define LN_sOARecord            \"sOARecord\"\n#define NID_sOARecord           482\n#define OBJ_sOARecord           OBJ_pilotAttributeType,30L\n\n#define LN_cNAMERecord          \"cNAMERecord\"\n#define NID_cNAMERecord         483\n#define OBJ_cNAMERecord         OBJ_pilotAttributeType,31L\n\n#define LN_associatedDomain             \"associatedDomain\"\n#define NID_associatedDomain            484\n#define OBJ_associatedDomain            OBJ_pilotAttributeType,37L\n\n#define LN_associatedName               \"associatedName\"\n#define NID_associatedName              485\n#define OBJ_associatedName              OBJ_pilotAttributeType,38L\n\n#define LN_homePostalAddress            \"homePostalAddress\"\n#define NID_homePostalAddress           486\n#define OBJ_homePostalAddress           OBJ_pilotAttributeType,39L\n\n#define LN_personalTitle                \"personalTitle\"\n#define NID_personalTitle               487\n#define OBJ_personalTitle               OBJ_pilotAttributeType,40L\n\n#define LN_mobileTelephoneNumber                \"mobileTelephoneNumber\"\n#define NID_mobileTelephoneNumber               488\n#define OBJ_mobileTelephoneNumber               OBJ_pilotAttributeType,41L\n\n#define LN_pagerTelephoneNumber         \"pagerTelephoneNumber\"\n#define NID_pagerTelephoneNumber                489\n#define OBJ_pagerTelephoneNumber                OBJ_pilotAttributeType,42L\n\n#define LN_friendlyCountryName          \"friendlyCountryName\"\n#define NID_friendlyCountryName         490\n#define OBJ_friendlyCountryName         OBJ_pilotAttributeType,43L\n\n#define SN_uniqueIdentifier             \"uid\"\n#define LN_uniqueIdentifier             \"uniqueIdentifier\"\n#define NID_uniqueIdentifier            102\n#define OBJ_uniqueIdentifier            OBJ_pilotAttributeType,44L\n\n#define LN_organizationalStatus         \"organizationalStatus\"\n#define NID_organizationalStatus                491\n#define OBJ_organizationalStatus                OBJ_pilotAttributeType,45L\n\n#define LN_janetMailbox         \"janetMailbox\"\n#define NID_janetMailbox                492\n#define OBJ_janetMailbox                OBJ_pilotAttributeType,46L\n\n#define LN_mailPreferenceOption         \"mailPreferenceOption\"\n#define NID_mailPreferenceOption                493\n#define OBJ_mailPreferenceOption                OBJ_pilotAttributeType,47L\n\n#define LN_buildingName         \"buildingName\"\n#define NID_buildingName                494\n#define OBJ_buildingName                OBJ_pilotAttributeType,48L\n\n#define LN_dSAQuality           \"dSAQuality\"\n#define NID_dSAQuality          495\n#define OBJ_dSAQuality          OBJ_pilotAttributeType,49L\n\n#define LN_singleLevelQuality           \"singleLevelQuality\"\n#define NID_singleLevelQuality          496\n#define OBJ_singleLevelQuality          OBJ_pilotAttributeType,50L\n\n#define LN_subtreeMinimumQuality                \"subtreeMinimumQuality\"\n#define NID_subtreeMinimumQuality               497\n#define OBJ_subtreeMinimumQuality               OBJ_pilotAttributeType,51L\n\n#define LN_subtreeMaximumQuality                \"subtreeMaximumQuality\"\n#define NID_subtreeMaximumQuality               498\n#define OBJ_subtreeMaximumQuality               OBJ_pilotAttributeType,52L\n\n#define LN_personalSignature            \"personalSignature\"\n#define NID_personalSignature           499\n#define OBJ_personalSignature           OBJ_pilotAttributeType,53L\n\n#define LN_dITRedirect          \"dITRedirect\"\n#define NID_dITRedirect         500\n#define OBJ_dITRedirect         OBJ_pilotAttributeType,54L\n\n#define SN_audio                \"audio\"\n#define NID_audio               501\n#define OBJ_audio               OBJ_pilotAttributeType,55L\n\n#define LN_documentPublisher            \"documentPublisher\"\n#define NID_documentPublisher           502\n#define OBJ_documentPublisher           OBJ_pilotAttributeType,56L\n\n#define SN_id_set               \"id-set\"\n#define LN_id_set               \"Secure Electronic Transactions\"\n#define NID_id_set              512\n#define OBJ_id_set              OBJ_international_organizations,42L\n\n#define SN_set_ctype            \"set-ctype\"\n#define LN_set_ctype            \"content types\"\n#define NID_set_ctype           513\n#define OBJ_set_ctype           OBJ_id_set,0L\n\n#define SN_set_msgExt           \"set-msgExt\"\n#define LN_set_msgExt           \"message extensions\"\n#define NID_set_msgExt          514\n#define OBJ_set_msgExt          OBJ_id_set,1L\n\n#define SN_set_attr             \"set-attr\"\n#define NID_set_attr            515\n#define OBJ_set_attr            OBJ_id_set,3L\n\n#define SN_set_policy           \"set-policy\"\n#define NID_set_policy          516\n#define OBJ_set_policy          OBJ_id_set,5L\n\n#define SN_set_certExt          \"set-certExt\"\n#define LN_set_certExt          \"certificate extensions\"\n#define NID_set_certExt         517\n#define OBJ_set_certExt         OBJ_id_set,7L\n\n#define SN_set_brand            \"set-brand\"\n#define NID_set_brand           518\n#define OBJ_set_brand           OBJ_id_set,8L\n\n#define SN_setct_PANData                \"setct-PANData\"\n#define NID_setct_PANData               519\n#define OBJ_setct_PANData               OBJ_set_ctype,0L\n\n#define SN_setct_PANToken               \"setct-PANToken\"\n#define NID_setct_PANToken              520\n#define OBJ_setct_PANToken              OBJ_set_ctype,1L\n\n#define SN_setct_PANOnly                \"setct-PANOnly\"\n#define NID_setct_PANOnly               521\n#define OBJ_setct_PANOnly               OBJ_set_ctype,2L\n\n#define SN_setct_OIData         \"setct-OIData\"\n#define NID_setct_OIData                522\n#define OBJ_setct_OIData                OBJ_set_ctype,3L\n\n#define SN_setct_PI             \"setct-PI\"\n#define NID_setct_PI            523\n#define OBJ_setct_PI            OBJ_set_ctype,4L\n\n#define SN_setct_PIData         \"setct-PIData\"\n#define NID_setct_PIData                524\n#define OBJ_setct_PIData                OBJ_set_ctype,5L\n\n#define SN_setct_PIDataUnsigned         \"setct-PIDataUnsigned\"\n#define NID_setct_PIDataUnsigned                525\n#define OBJ_setct_PIDataUnsigned                OBJ_set_ctype,6L\n\n#define SN_setct_HODInput               \"setct-HODInput\"\n#define NID_setct_HODInput              526\n#define OBJ_setct_HODInput              OBJ_set_ctype,7L\n\n#define SN_setct_AuthResBaggage         \"setct-AuthResBaggage\"\n#define NID_setct_AuthResBaggage                527\n#define OBJ_setct_AuthResBaggage                OBJ_set_ctype,8L\n\n#define SN_setct_AuthRevReqBaggage              \"setct-AuthRevReqBaggage\"\n#define NID_setct_AuthRevReqBaggage             528\n#define OBJ_setct_AuthRevReqBaggage             OBJ_set_ctype,9L\n\n#define SN_setct_AuthRevResBaggage              \"setct-AuthRevResBaggage\"\n#define NID_setct_AuthRevResBaggage             529\n#define OBJ_setct_AuthRevResBaggage             OBJ_set_ctype,10L\n\n#define SN_setct_CapTokenSeq            \"setct-CapTokenSeq\"\n#define NID_setct_CapTokenSeq           530\n#define OBJ_setct_CapTokenSeq           OBJ_set_ctype,11L\n\n#define SN_setct_PInitResData           \"setct-PInitResData\"\n#define NID_setct_PInitResData          531\n#define OBJ_setct_PInitResData          OBJ_set_ctype,12L\n\n#define SN_setct_PI_TBS         \"setct-PI-TBS\"\n#define NID_setct_PI_TBS                532\n#define OBJ_setct_PI_TBS                OBJ_set_ctype,13L\n\n#define SN_setct_PResData               \"setct-PResData\"\n#define NID_setct_PResData              533\n#define OBJ_setct_PResData              OBJ_set_ctype,14L\n\n#define SN_setct_AuthReqTBS             \"setct-AuthReqTBS\"\n#define NID_setct_AuthReqTBS            534\n#define OBJ_setct_AuthReqTBS            OBJ_set_ctype,16L\n\n#define SN_setct_AuthResTBS             \"setct-AuthResTBS\"\n#define NID_setct_AuthResTBS            535\n#define OBJ_setct_AuthResTBS            OBJ_set_ctype,17L\n\n#define SN_setct_AuthResTBSX            \"setct-AuthResTBSX\"\n#define NID_setct_AuthResTBSX           536\n#define OBJ_setct_AuthResTBSX           OBJ_set_ctype,18L\n\n#define SN_setct_AuthTokenTBS           \"setct-AuthTokenTBS\"\n#define NID_setct_AuthTokenTBS          537\n#define OBJ_setct_AuthTokenTBS          OBJ_set_ctype,19L\n\n#define SN_setct_CapTokenData           \"setct-CapTokenData\"\n#define NID_setct_CapTokenData          538\n#define OBJ_setct_CapTokenData          OBJ_set_ctype,20L\n\n#define SN_setct_CapTokenTBS            \"setct-CapTokenTBS\"\n#define NID_setct_CapTokenTBS           539\n#define OBJ_setct_CapTokenTBS           OBJ_set_ctype,21L\n\n#define SN_setct_AcqCardCodeMsg         \"setct-AcqCardCodeMsg\"\n#define NID_setct_AcqCardCodeMsg                540\n#define OBJ_setct_AcqCardCodeMsg                OBJ_set_ctype,22L\n\n#define SN_setct_AuthRevReqTBS          \"setct-AuthRevReqTBS\"\n#define NID_setct_AuthRevReqTBS         541\n#define OBJ_setct_AuthRevReqTBS         OBJ_set_ctype,23L\n\n#define SN_setct_AuthRevResData         \"setct-AuthRevResData\"\n#define NID_setct_AuthRevResData                542\n#define OBJ_setct_AuthRevResData                OBJ_set_ctype,24L\n\n#define SN_setct_AuthRevResTBS          \"setct-AuthRevResTBS\"\n#define NID_setct_AuthRevResTBS         543\n#define OBJ_setct_AuthRevResTBS         OBJ_set_ctype,25L\n\n#define SN_setct_CapReqTBS              \"setct-CapReqTBS\"\n#define NID_setct_CapReqTBS             544\n#define OBJ_setct_CapReqTBS             OBJ_set_ctype,26L\n\n#define SN_setct_CapReqTBSX             \"setct-CapReqTBSX\"\n#define NID_setct_CapReqTBSX            545\n#define OBJ_setct_CapReqTBSX            OBJ_set_ctype,27L\n\n#define SN_setct_CapResData             \"setct-CapResData\"\n#define NID_setct_CapResData            546\n#define OBJ_setct_CapResData            OBJ_set_ctype,28L\n\n#define SN_setct_CapRevReqTBS           \"setct-CapRevReqTBS\"\n#define NID_setct_CapRevReqTBS          547\n#define OBJ_setct_CapRevReqTBS          OBJ_set_ctype,29L\n\n#define SN_setct_CapRevReqTBSX          \"setct-CapRevReqTBSX\"\n#define NID_setct_CapRevReqTBSX         548\n#define OBJ_setct_CapRevReqTBSX         OBJ_set_ctype,30L\n\n#define SN_setct_CapRevResData          \"setct-CapRevResData\"\n#define NID_setct_CapRevResData         549\n#define OBJ_setct_CapRevResData         OBJ_set_ctype,31L\n\n#define SN_setct_CredReqTBS             \"setct-CredReqTBS\"\n#define NID_setct_CredReqTBS            550\n#define OBJ_setct_CredReqTBS            OBJ_set_ctype,32L\n\n#define SN_setct_CredReqTBSX            \"setct-CredReqTBSX\"\n#define NID_setct_CredReqTBSX           551\n#define OBJ_setct_CredReqTBSX           OBJ_set_ctype,33L\n\n#define SN_setct_CredResData            \"setct-CredResData\"\n#define NID_setct_CredResData           552\n#define OBJ_setct_CredResData           OBJ_set_ctype,34L\n\n#define SN_setct_CredRevReqTBS          \"setct-CredRevReqTBS\"\n#define NID_setct_CredRevReqTBS         553\n#define OBJ_setct_CredRevReqTBS         OBJ_set_ctype,35L\n\n#define SN_setct_CredRevReqTBSX         \"setct-CredRevReqTBSX\"\n#define NID_setct_CredRevReqTBSX                554\n#define OBJ_setct_CredRevReqTBSX                OBJ_set_ctype,36L\n\n#define SN_setct_CredRevResData         \"setct-CredRevResData\"\n#define NID_setct_CredRevResData                555\n#define OBJ_setct_CredRevResData                OBJ_set_ctype,37L\n\n#define SN_setct_PCertReqData           \"setct-PCertReqData\"\n#define NID_setct_PCertReqData          556\n#define OBJ_setct_PCertReqData          OBJ_set_ctype,38L\n\n#define SN_setct_PCertResTBS            \"setct-PCertResTBS\"\n#define NID_setct_PCertResTBS           557\n#define OBJ_setct_PCertResTBS           OBJ_set_ctype,39L\n\n#define SN_setct_BatchAdminReqData              \"setct-BatchAdminReqData\"\n#define NID_setct_BatchAdminReqData             558\n#define OBJ_setct_BatchAdminReqData             OBJ_set_ctype,40L\n\n#define SN_setct_BatchAdminResData              \"setct-BatchAdminResData\"\n#define NID_setct_BatchAdminResData             559\n#define OBJ_setct_BatchAdminResData             OBJ_set_ctype,41L\n\n#define SN_setct_CardCInitResTBS                \"setct-CardCInitResTBS\"\n#define NID_setct_CardCInitResTBS               560\n#define OBJ_setct_CardCInitResTBS               OBJ_set_ctype,42L\n\n#define SN_setct_MeAqCInitResTBS                \"setct-MeAqCInitResTBS\"\n#define NID_setct_MeAqCInitResTBS               561\n#define OBJ_setct_MeAqCInitResTBS               OBJ_set_ctype,43L\n\n#define SN_setct_RegFormResTBS          \"setct-RegFormResTBS\"\n#define NID_setct_RegFormResTBS         562\n#define OBJ_setct_RegFormResTBS         OBJ_set_ctype,44L\n\n#define SN_setct_CertReqData            \"setct-CertReqData\"\n#define NID_setct_CertReqData           563\n#define OBJ_setct_CertReqData           OBJ_set_ctype,45L\n\n#define SN_setct_CertReqTBS             \"setct-CertReqTBS\"\n#define NID_setct_CertReqTBS            564\n#define OBJ_setct_CertReqTBS            OBJ_set_ctype,46L\n\n#define SN_setct_CertResData            \"setct-CertResData\"\n#define NID_setct_CertResData           565\n#define OBJ_setct_CertResData           OBJ_set_ctype,47L\n\n#define SN_setct_CertInqReqTBS          \"setct-CertInqReqTBS\"\n#define NID_setct_CertInqReqTBS         566\n#define OBJ_setct_CertInqReqTBS         OBJ_set_ctype,48L\n\n#define SN_setct_ErrorTBS               \"setct-ErrorTBS\"\n#define NID_setct_ErrorTBS              567\n#define OBJ_setct_ErrorTBS              OBJ_set_ctype,49L\n\n#define SN_setct_PIDualSignedTBE                \"setct-PIDualSignedTBE\"\n#define NID_setct_PIDualSignedTBE               568\n#define OBJ_setct_PIDualSignedTBE               OBJ_set_ctype,50L\n\n#define SN_setct_PIUnsignedTBE          \"setct-PIUnsignedTBE\"\n#define NID_setct_PIUnsignedTBE         569\n#define OBJ_setct_PIUnsignedTBE         OBJ_set_ctype,51L\n\n#define SN_setct_AuthReqTBE             \"setct-AuthReqTBE\"\n#define NID_setct_AuthReqTBE            570\n#define OBJ_setct_AuthReqTBE            OBJ_set_ctype,52L\n\n#define SN_setct_AuthResTBE             \"setct-AuthResTBE\"\n#define NID_setct_AuthResTBE            571\n#define OBJ_setct_AuthResTBE            OBJ_set_ctype,53L\n\n#define SN_setct_AuthResTBEX            \"setct-AuthResTBEX\"\n#define NID_setct_AuthResTBEX           572\n#define OBJ_setct_AuthResTBEX           OBJ_set_ctype,54L\n\n#define SN_setct_AuthTokenTBE           \"setct-AuthTokenTBE\"\n#define NID_setct_AuthTokenTBE          573\n#define OBJ_setct_AuthTokenTBE          OBJ_set_ctype,55L\n\n#define SN_setct_CapTokenTBE            \"setct-CapTokenTBE\"\n#define NID_setct_CapTokenTBE           574\n#define OBJ_setct_CapTokenTBE           OBJ_set_ctype,56L\n\n#define SN_setct_CapTokenTBEX           \"setct-CapTokenTBEX\"\n#define NID_setct_CapTokenTBEX          575\n#define OBJ_setct_CapTokenTBEX          OBJ_set_ctype,57L\n\n#define SN_setct_AcqCardCodeMsgTBE              \"setct-AcqCardCodeMsgTBE\"\n#define NID_setct_AcqCardCodeMsgTBE             576\n#define OBJ_setct_AcqCardCodeMsgTBE             OBJ_set_ctype,58L\n\n#define SN_setct_AuthRevReqTBE          \"setct-AuthRevReqTBE\"\n#define NID_setct_AuthRevReqTBE         577\n#define OBJ_setct_AuthRevReqTBE         OBJ_set_ctype,59L\n\n#define SN_setct_AuthRevResTBE          \"setct-AuthRevResTBE\"\n#define NID_setct_AuthRevResTBE         578\n#define OBJ_setct_AuthRevResTBE         OBJ_set_ctype,60L\n\n#define SN_setct_AuthRevResTBEB         \"setct-AuthRevResTBEB\"\n#define NID_setct_AuthRevResTBEB                579\n#define OBJ_setct_AuthRevResTBEB                OBJ_set_ctype,61L\n\n#define SN_setct_CapReqTBE              \"setct-CapReqTBE\"\n#define NID_setct_CapReqTBE             580\n#define OBJ_setct_CapReqTBE             OBJ_set_ctype,62L\n\n#define SN_setct_CapReqTBEX             \"setct-CapReqTBEX\"\n#define NID_setct_CapReqTBEX            581\n#define OBJ_setct_CapReqTBEX            OBJ_set_ctype,63L\n\n#define SN_setct_CapResTBE              \"setct-CapResTBE\"\n#define NID_setct_CapResTBE             582\n#define OBJ_setct_CapResTBE             OBJ_set_ctype,64L\n\n#define SN_setct_CapRevReqTBE           \"setct-CapRevReqTBE\"\n#define NID_setct_CapRevReqTBE          583\n#define OBJ_setct_CapRevReqTBE          OBJ_set_ctype,65L\n\n#define SN_setct_CapRevReqTBEX          \"setct-CapRevReqTBEX\"\n#define NID_setct_CapRevReqTBEX         584\n#define OBJ_setct_CapRevReqTBEX         OBJ_set_ctype,66L\n\n#define SN_setct_CapRevResTBE           \"setct-CapRevResTBE\"\n#define NID_setct_CapRevResTBE          585\n#define OBJ_setct_CapRevResTBE          OBJ_set_ctype,67L\n\n#define SN_setct_CredReqTBE             \"setct-CredReqTBE\"\n#define NID_setct_CredReqTBE            586\n#define OBJ_setct_CredReqTBE            OBJ_set_ctype,68L\n\n#define SN_setct_CredReqTBEX            \"setct-CredReqTBEX\"\n#define NID_setct_CredReqTBEX           587\n#define OBJ_setct_CredReqTBEX           OBJ_set_ctype,69L\n\n#define SN_setct_CredResTBE             \"setct-CredResTBE\"\n#define NID_setct_CredResTBE            588\n#define OBJ_setct_CredResTBE            OBJ_set_ctype,70L\n\n#define SN_setct_CredRevReqTBE          \"setct-CredRevReqTBE\"\n#define NID_setct_CredRevReqTBE         589\n#define OBJ_setct_CredRevReqTBE         OBJ_set_ctype,71L\n\n#define SN_setct_CredRevReqTBEX         \"setct-CredRevReqTBEX\"\n#define NID_setct_CredRevReqTBEX                590\n#define OBJ_setct_CredRevReqTBEX                OBJ_set_ctype,72L\n\n#define SN_setct_CredRevResTBE          \"setct-CredRevResTBE\"\n#define NID_setct_CredRevResTBE         591\n#define OBJ_setct_CredRevResTBE         OBJ_set_ctype,73L\n\n#define SN_setct_BatchAdminReqTBE               \"setct-BatchAdminReqTBE\"\n#define NID_setct_BatchAdminReqTBE              592\n#define OBJ_setct_BatchAdminReqTBE              OBJ_set_ctype,74L\n\n#define SN_setct_BatchAdminResTBE               \"setct-BatchAdminResTBE\"\n#define NID_setct_BatchAdminResTBE              593\n#define OBJ_setct_BatchAdminResTBE              OBJ_set_ctype,75L\n\n#define SN_setct_RegFormReqTBE          \"setct-RegFormReqTBE\"\n#define NID_setct_RegFormReqTBE         594\n#define OBJ_setct_RegFormReqTBE         OBJ_set_ctype,76L\n\n#define SN_setct_CertReqTBE             \"setct-CertReqTBE\"\n#define NID_setct_CertReqTBE            595\n#define OBJ_setct_CertReqTBE            OBJ_set_ctype,77L\n\n#define SN_setct_CertReqTBEX            \"setct-CertReqTBEX\"\n#define NID_setct_CertReqTBEX           596\n#define OBJ_setct_CertReqTBEX           OBJ_set_ctype,78L\n\n#define SN_setct_CertResTBE             \"setct-CertResTBE\"\n#define NID_setct_CertResTBE            597\n#define OBJ_setct_CertResTBE            OBJ_set_ctype,79L\n\n#define SN_setct_CRLNotificationTBS             \"setct-CRLNotificationTBS\"\n#define NID_setct_CRLNotificationTBS            598\n#define OBJ_setct_CRLNotificationTBS            OBJ_set_ctype,80L\n\n#define SN_setct_CRLNotificationResTBS          \"setct-CRLNotificationResTBS\"\n#define NID_setct_CRLNotificationResTBS         599\n#define OBJ_setct_CRLNotificationResTBS         OBJ_set_ctype,81L\n\n#define SN_setct_BCIDistributionTBS             \"setct-BCIDistributionTBS\"\n#define NID_setct_BCIDistributionTBS            600\n#define OBJ_setct_BCIDistributionTBS            OBJ_set_ctype,82L\n\n#define SN_setext_genCrypt              \"setext-genCrypt\"\n#define LN_setext_genCrypt              \"generic cryptogram\"\n#define NID_setext_genCrypt             601\n#define OBJ_setext_genCrypt             OBJ_set_msgExt,1L\n\n#define SN_setext_miAuth                \"setext-miAuth\"\n#define LN_setext_miAuth                \"merchant initiated auth\"\n#define NID_setext_miAuth               602\n#define OBJ_setext_miAuth               OBJ_set_msgExt,3L\n\n#define SN_setext_pinSecure             \"setext-pinSecure\"\n#define NID_setext_pinSecure            603\n#define OBJ_setext_pinSecure            OBJ_set_msgExt,4L\n\n#define SN_setext_pinAny                \"setext-pinAny\"\n#define NID_setext_pinAny               604\n#define OBJ_setext_pinAny               OBJ_set_msgExt,5L\n\n#define SN_setext_track2                \"setext-track2\"\n#define NID_setext_track2               605\n#define OBJ_setext_track2               OBJ_set_msgExt,7L\n\n#define SN_setext_cv            \"setext-cv\"\n#define LN_setext_cv            \"additional verification\"\n#define NID_setext_cv           606\n#define OBJ_setext_cv           OBJ_set_msgExt,8L\n\n#define SN_set_policy_root              \"set-policy-root\"\n#define NID_set_policy_root             607\n#define OBJ_set_policy_root             OBJ_set_policy,0L\n\n#define SN_setCext_hashedRoot           \"setCext-hashedRoot\"\n#define NID_setCext_hashedRoot          608\n#define OBJ_setCext_hashedRoot          OBJ_set_certExt,0L\n\n#define SN_setCext_certType             \"setCext-certType\"\n#define NID_setCext_certType            609\n#define OBJ_setCext_certType            OBJ_set_certExt,1L\n\n#define SN_setCext_merchData            \"setCext-merchData\"\n#define NID_setCext_merchData           610\n#define OBJ_setCext_merchData           OBJ_set_certExt,2L\n\n#define SN_setCext_cCertRequired                \"setCext-cCertRequired\"\n#define NID_setCext_cCertRequired               611\n#define OBJ_setCext_cCertRequired               OBJ_set_certExt,3L\n\n#define SN_setCext_tunneling            \"setCext-tunneling\"\n#define NID_setCext_tunneling           612\n#define OBJ_setCext_tunneling           OBJ_set_certExt,4L\n\n#define SN_setCext_setExt               \"setCext-setExt\"\n#define NID_setCext_setExt              613\n#define OBJ_setCext_setExt              OBJ_set_certExt,5L\n\n#define SN_setCext_setQualf             \"setCext-setQualf\"\n#define NID_setCext_setQualf            614\n#define OBJ_setCext_setQualf            OBJ_set_certExt,6L\n\n#define SN_setCext_PGWYcapabilities             \"setCext-PGWYcapabilities\"\n#define NID_setCext_PGWYcapabilities            615\n#define OBJ_setCext_PGWYcapabilities            OBJ_set_certExt,7L\n\n#define SN_setCext_TokenIdentifier              \"setCext-TokenIdentifier\"\n#define NID_setCext_TokenIdentifier             616\n#define OBJ_setCext_TokenIdentifier             OBJ_set_certExt,8L\n\n#define SN_setCext_Track2Data           \"setCext-Track2Data\"\n#define NID_setCext_Track2Data          617\n#define OBJ_setCext_Track2Data          OBJ_set_certExt,9L\n\n#define SN_setCext_TokenType            \"setCext-TokenType\"\n#define NID_setCext_TokenType           618\n#define OBJ_setCext_TokenType           OBJ_set_certExt,10L\n\n#define SN_setCext_IssuerCapabilities           \"setCext-IssuerCapabilities\"\n#define NID_setCext_IssuerCapabilities          619\n#define OBJ_setCext_IssuerCapabilities          OBJ_set_certExt,11L\n\n#define SN_setAttr_Cert         \"setAttr-Cert\"\n#define NID_setAttr_Cert                620\n#define OBJ_setAttr_Cert                OBJ_set_attr,0L\n\n#define SN_setAttr_PGWYcap              \"setAttr-PGWYcap\"\n#define LN_setAttr_PGWYcap              \"payment gateway capabilities\"\n#define NID_setAttr_PGWYcap             621\n#define OBJ_setAttr_PGWYcap             OBJ_set_attr,1L\n\n#define SN_setAttr_TokenType            \"setAttr-TokenType\"\n#define NID_setAttr_TokenType           622\n#define OBJ_setAttr_TokenType           OBJ_set_attr,2L\n\n#define SN_setAttr_IssCap               \"setAttr-IssCap\"\n#define LN_setAttr_IssCap               \"issuer capabilities\"\n#define NID_setAttr_IssCap              623\n#define OBJ_setAttr_IssCap              OBJ_set_attr,3L\n\n#define SN_set_rootKeyThumb             \"set-rootKeyThumb\"\n#define NID_set_rootKeyThumb            624\n#define OBJ_set_rootKeyThumb            OBJ_setAttr_Cert,0L\n\n#define SN_set_addPolicy                \"set-addPolicy\"\n#define NID_set_addPolicy               625\n#define OBJ_set_addPolicy               OBJ_setAttr_Cert,1L\n\n#define SN_setAttr_Token_EMV            \"setAttr-Token-EMV\"\n#define NID_setAttr_Token_EMV           626\n#define OBJ_setAttr_Token_EMV           OBJ_setAttr_TokenType,1L\n\n#define SN_setAttr_Token_B0Prime                \"setAttr-Token-B0Prime\"\n#define NID_setAttr_Token_B0Prime               627\n#define OBJ_setAttr_Token_B0Prime               OBJ_setAttr_TokenType,2L\n\n#define SN_setAttr_IssCap_CVM           \"setAttr-IssCap-CVM\"\n#define NID_setAttr_IssCap_CVM          628\n#define OBJ_setAttr_IssCap_CVM          OBJ_setAttr_IssCap,3L\n\n#define SN_setAttr_IssCap_T2            \"setAttr-IssCap-T2\"\n#define NID_setAttr_IssCap_T2           629\n#define OBJ_setAttr_IssCap_T2           OBJ_setAttr_IssCap,4L\n\n#define SN_setAttr_IssCap_Sig           \"setAttr-IssCap-Sig\"\n#define NID_setAttr_IssCap_Sig          630\n#define OBJ_setAttr_IssCap_Sig          OBJ_setAttr_IssCap,5L\n\n#define SN_setAttr_GenCryptgrm          \"setAttr-GenCryptgrm\"\n#define LN_setAttr_GenCryptgrm          \"generate cryptogram\"\n#define NID_setAttr_GenCryptgrm         631\n#define OBJ_setAttr_GenCryptgrm         OBJ_setAttr_IssCap_CVM,1L\n\n#define SN_setAttr_T2Enc                \"setAttr-T2Enc\"\n#define LN_setAttr_T2Enc                \"encrypted track 2\"\n#define NID_setAttr_T2Enc               632\n#define OBJ_setAttr_T2Enc               OBJ_setAttr_IssCap_T2,1L\n\n#define SN_setAttr_T2cleartxt           \"setAttr-T2cleartxt\"\n#define LN_setAttr_T2cleartxt           \"cleartext track 2\"\n#define NID_setAttr_T2cleartxt          633\n#define OBJ_setAttr_T2cleartxt          OBJ_setAttr_IssCap_T2,2L\n\n#define SN_setAttr_TokICCsig            \"setAttr-TokICCsig\"\n#define LN_setAttr_TokICCsig            \"ICC or token signature\"\n#define NID_setAttr_TokICCsig           634\n#define OBJ_setAttr_TokICCsig           OBJ_setAttr_IssCap_Sig,1L\n\n#define SN_setAttr_SecDevSig            \"setAttr-SecDevSig\"\n#define LN_setAttr_SecDevSig            \"secure device signature\"\n#define NID_setAttr_SecDevSig           635\n#define OBJ_setAttr_SecDevSig           OBJ_setAttr_IssCap_Sig,2L\n\n#define SN_set_brand_IATA_ATA           \"set-brand-IATA-ATA\"\n#define NID_set_brand_IATA_ATA          636\n#define OBJ_set_brand_IATA_ATA          OBJ_set_brand,1L\n\n#define SN_set_brand_Diners             \"set-brand-Diners\"\n#define NID_set_brand_Diners            637\n#define OBJ_set_brand_Diners            OBJ_set_brand,30L\n\n#define SN_set_brand_AmericanExpress            \"set-brand-AmericanExpress\"\n#define NID_set_brand_AmericanExpress           638\n#define OBJ_set_brand_AmericanExpress           OBJ_set_brand,34L\n\n#define SN_set_brand_JCB                \"set-brand-JCB\"\n#define NID_set_brand_JCB               639\n#define OBJ_set_brand_JCB               OBJ_set_brand,35L\n\n#define SN_set_brand_Visa               \"set-brand-Visa\"\n#define NID_set_brand_Visa              640\n#define OBJ_set_brand_Visa              OBJ_set_brand,4L\n\n#define SN_set_brand_MasterCard         \"set-brand-MasterCard\"\n#define NID_set_brand_MasterCard                641\n#define OBJ_set_brand_MasterCard                OBJ_set_brand,5L\n\n#define SN_set_brand_Novus              \"set-brand-Novus\"\n#define NID_set_brand_Novus             642\n#define OBJ_set_brand_Novus             OBJ_set_brand,6011L\n\n#define SN_des_cdmf             \"DES-CDMF\"\n#define LN_des_cdmf             \"des-cdmf\"\n#define NID_des_cdmf            643\n#define OBJ_des_cdmf            OBJ_rsadsi,3L,10L\n\n#define SN_rsaOAEPEncryptionSET         \"rsaOAEPEncryptionSET\"\n#define NID_rsaOAEPEncryptionSET                644\n#define OBJ_rsaOAEPEncryptionSET                OBJ_rsadsi,1L,1L,6L\n\n#define SN_ipsec3               \"Oakley-EC2N-3\"\n#define LN_ipsec3               \"ipsec3\"\n#define NID_ipsec3              749\n\n#define SN_ipsec4               \"Oakley-EC2N-4\"\n#define LN_ipsec4               \"ipsec4\"\n#define NID_ipsec4              750\n\n#define SN_whirlpool            \"whirlpool\"\n#define NID_whirlpool           804\n#define OBJ_whirlpool           OBJ_iso,0L,10118L,3L,0L,55L\n\n#define SN_cryptopro            \"cryptopro\"\n#define NID_cryptopro           805\n#define OBJ_cryptopro           OBJ_member_body,643L,2L,2L\n\n#define SN_cryptocom            \"cryptocom\"\n#define NID_cryptocom           806\n#define OBJ_cryptocom           OBJ_member_body,643L,2L,9L\n\n#define SN_id_tc26              \"id-tc26\"\n#define NID_id_tc26             974\n#define OBJ_id_tc26             OBJ_member_body,643L,7L,1L\n\n#define SN_id_GostR3411_94_with_GostR3410_2001          \"id-GostR3411-94-with-GostR3410-2001\"\n#define LN_id_GostR3411_94_with_GostR3410_2001          \"GOST R 34.11-94 with GOST R 34.10-2001\"\n#define NID_id_GostR3411_94_with_GostR3410_2001         807\n#define OBJ_id_GostR3411_94_with_GostR3410_2001         OBJ_cryptopro,3L\n\n#define SN_id_GostR3411_94_with_GostR3410_94            \"id-GostR3411-94-with-GostR3410-94\"\n#define LN_id_GostR3411_94_with_GostR3410_94            \"GOST R 34.11-94 with GOST R 34.10-94\"\n#define NID_id_GostR3411_94_with_GostR3410_94           808\n#define OBJ_id_GostR3411_94_with_GostR3410_94           OBJ_cryptopro,4L\n\n#define SN_id_GostR3411_94              \"md_gost94\"\n#define LN_id_GostR3411_94              \"GOST R 34.11-94\"\n#define NID_id_GostR3411_94             809\n#define OBJ_id_GostR3411_94             OBJ_cryptopro,9L\n\n#define SN_id_HMACGostR3411_94          \"id-HMACGostR3411-94\"\n#define LN_id_HMACGostR3411_94          \"HMAC GOST 34.11-94\"\n#define NID_id_HMACGostR3411_94         810\n#define OBJ_id_HMACGostR3411_94         OBJ_cryptopro,10L\n\n#define SN_id_GostR3410_2001            \"gost2001\"\n#define LN_id_GostR3410_2001            \"GOST R 34.10-2001\"\n#define NID_id_GostR3410_2001           811\n#define OBJ_id_GostR3410_2001           OBJ_cryptopro,19L\n\n#define SN_id_GostR3410_94              \"gost94\"\n#define LN_id_GostR3410_94              \"GOST R 34.10-94\"\n#define NID_id_GostR3410_94             812\n#define OBJ_id_GostR3410_94             OBJ_cryptopro,20L\n\n#define SN_id_Gost28147_89              \"gost89\"\n#define LN_id_Gost28147_89              \"GOST 28147-89\"\n#define NID_id_Gost28147_89             813\n#define OBJ_id_Gost28147_89             OBJ_cryptopro,21L\n\n#define SN_gost89_cnt           \"gost89-cnt\"\n#define NID_gost89_cnt          814\n\n#define SN_gost89_cnt_12                \"gost89-cnt-12\"\n#define NID_gost89_cnt_12               975\n\n#define SN_gost89_cbc           \"gost89-cbc\"\n#define NID_gost89_cbc          1009\n\n#define SN_gost89_ecb           \"gost89-ecb\"\n#define NID_gost89_ecb          1010\n\n#define SN_gost89_ctr           \"gost89-ctr\"\n#define NID_gost89_ctr          1011\n\n#define SN_id_Gost28147_89_MAC          \"gost-mac\"\n#define LN_id_Gost28147_89_MAC          \"GOST 28147-89 MAC\"\n#define NID_id_Gost28147_89_MAC         815\n#define OBJ_id_Gost28147_89_MAC         OBJ_cryptopro,22L\n\n#define SN_gost_mac_12          \"gost-mac-12\"\n#define NID_gost_mac_12         976\n\n#define SN_id_GostR3411_94_prf          \"prf-gostr3411-94\"\n#define LN_id_GostR3411_94_prf          \"GOST R 34.11-94 PRF\"\n#define NID_id_GostR3411_94_prf         816\n#define OBJ_id_GostR3411_94_prf         OBJ_cryptopro,23L\n\n#define SN_id_GostR3410_2001DH          \"id-GostR3410-2001DH\"\n#define LN_id_GostR3410_2001DH          \"GOST R 34.10-2001 DH\"\n#define NID_id_GostR3410_2001DH         817\n#define OBJ_id_GostR3410_2001DH         OBJ_cryptopro,98L\n\n#define SN_id_GostR3410_94DH            \"id-GostR3410-94DH\"\n#define LN_id_GostR3410_94DH            \"GOST R 34.10-94 DH\"\n#define NID_id_GostR3410_94DH           818\n#define OBJ_id_GostR3410_94DH           OBJ_cryptopro,99L\n\n#define SN_id_Gost28147_89_CryptoPro_KeyMeshing         \"id-Gost28147-89-CryptoPro-KeyMeshing\"\n#define NID_id_Gost28147_89_CryptoPro_KeyMeshing                819\n#define OBJ_id_Gost28147_89_CryptoPro_KeyMeshing                OBJ_cryptopro,14L,1L\n\n#define SN_id_Gost28147_89_None_KeyMeshing              \"id-Gost28147-89-None-KeyMeshing\"\n#define NID_id_Gost28147_89_None_KeyMeshing             820\n#define OBJ_id_Gost28147_89_None_KeyMeshing             OBJ_cryptopro,14L,0L\n\n#define SN_id_GostR3411_94_TestParamSet         \"id-GostR3411-94-TestParamSet\"\n#define NID_id_GostR3411_94_TestParamSet                821\n#define OBJ_id_GostR3411_94_TestParamSet                OBJ_cryptopro,30L,0L\n\n#define SN_id_GostR3411_94_CryptoProParamSet            \"id-GostR3411-94-CryptoProParamSet\"\n#define NID_id_GostR3411_94_CryptoProParamSet           822\n#define OBJ_id_GostR3411_94_CryptoProParamSet           OBJ_cryptopro,30L,1L\n\n#define SN_id_Gost28147_89_TestParamSet         \"id-Gost28147-89-TestParamSet\"\n#define NID_id_Gost28147_89_TestParamSet                823\n#define OBJ_id_Gost28147_89_TestParamSet                OBJ_cryptopro,31L,0L\n\n#define SN_id_Gost28147_89_CryptoPro_A_ParamSet         \"id-Gost28147-89-CryptoPro-A-ParamSet\"\n#define NID_id_Gost28147_89_CryptoPro_A_ParamSet                824\n#define OBJ_id_Gost28147_89_CryptoPro_A_ParamSet                OBJ_cryptopro,31L,1L\n\n#define SN_id_Gost28147_89_CryptoPro_B_ParamSet         \"id-Gost28147-89-CryptoPro-B-ParamSet\"\n#define NID_id_Gost28147_89_CryptoPro_B_ParamSet                825\n#define OBJ_id_Gost28147_89_CryptoPro_B_ParamSet                OBJ_cryptopro,31L,2L\n\n#define SN_id_Gost28147_89_CryptoPro_C_ParamSet         \"id-Gost28147-89-CryptoPro-C-ParamSet\"\n#define NID_id_Gost28147_89_CryptoPro_C_ParamSet                826\n#define OBJ_id_Gost28147_89_CryptoPro_C_ParamSet                OBJ_cryptopro,31L,3L\n\n#define SN_id_Gost28147_89_CryptoPro_D_ParamSet         \"id-Gost28147-89-CryptoPro-D-ParamSet\"\n#define NID_id_Gost28147_89_CryptoPro_D_ParamSet                827\n#define OBJ_id_Gost28147_89_CryptoPro_D_ParamSet                OBJ_cryptopro,31L,4L\n\n#define SN_id_Gost28147_89_CryptoPro_Oscar_1_1_ParamSet         \"id-Gost28147-89-CryptoPro-Oscar-1-1-ParamSet\"\n#define NID_id_Gost28147_89_CryptoPro_Oscar_1_1_ParamSet                828\n#define OBJ_id_Gost28147_89_CryptoPro_Oscar_1_1_ParamSet                OBJ_cryptopro,31L,5L\n\n#define SN_id_Gost28147_89_CryptoPro_Oscar_1_0_ParamSet         \"id-Gost28147-89-CryptoPro-Oscar-1-0-ParamSet\"\n#define NID_id_Gost28147_89_CryptoPro_Oscar_1_0_ParamSet                829\n#define OBJ_id_Gost28147_89_CryptoPro_Oscar_1_0_ParamSet                OBJ_cryptopro,31L,6L\n\n#define SN_id_Gost28147_89_CryptoPro_RIC_1_ParamSet             \"id-Gost28147-89-CryptoPro-RIC-1-ParamSet\"\n#define NID_id_Gost28147_89_CryptoPro_RIC_1_ParamSet            830\n#define OBJ_id_Gost28147_89_CryptoPro_RIC_1_ParamSet            OBJ_cryptopro,31L,7L\n\n#define SN_id_GostR3410_94_TestParamSet         \"id-GostR3410-94-TestParamSet\"\n#define NID_id_GostR3410_94_TestParamSet                831\n#define OBJ_id_GostR3410_94_TestParamSet                OBJ_cryptopro,32L,0L\n\n#define SN_id_GostR3410_94_CryptoPro_A_ParamSet         \"id-GostR3410-94-CryptoPro-A-ParamSet\"\n#define NID_id_GostR3410_94_CryptoPro_A_ParamSet                832\n#define OBJ_id_GostR3410_94_CryptoPro_A_ParamSet                OBJ_cryptopro,32L,2L\n\n#define SN_id_GostR3410_94_CryptoPro_B_ParamSet         \"id-GostR3410-94-CryptoPro-B-ParamSet\"\n#define NID_id_GostR3410_94_CryptoPro_B_ParamSet                833\n#define OBJ_id_GostR3410_94_CryptoPro_B_ParamSet                OBJ_cryptopro,32L,3L\n\n#define SN_id_GostR3410_94_CryptoPro_C_ParamSet         \"id-GostR3410-94-CryptoPro-C-ParamSet\"\n#define NID_id_GostR3410_94_CryptoPro_C_ParamSet                834\n#define OBJ_id_GostR3410_94_CryptoPro_C_ParamSet                OBJ_cryptopro,32L,4L\n\n#define SN_id_GostR3410_94_CryptoPro_D_ParamSet         \"id-GostR3410-94-CryptoPro-D-ParamSet\"\n#define NID_id_GostR3410_94_CryptoPro_D_ParamSet                835\n#define OBJ_id_GostR3410_94_CryptoPro_D_ParamSet                OBJ_cryptopro,32L,5L\n\n#define SN_id_GostR3410_94_CryptoPro_XchA_ParamSet              \"id-GostR3410-94-CryptoPro-XchA-ParamSet\"\n#define NID_id_GostR3410_94_CryptoPro_XchA_ParamSet             836\n#define OBJ_id_GostR3410_94_CryptoPro_XchA_ParamSet             OBJ_cryptopro,33L,1L\n\n#define SN_id_GostR3410_94_CryptoPro_XchB_ParamSet              \"id-GostR3410-94-CryptoPro-XchB-ParamSet\"\n#define NID_id_GostR3410_94_CryptoPro_XchB_ParamSet             837\n#define OBJ_id_GostR3410_94_CryptoPro_XchB_ParamSet             OBJ_cryptopro,33L,2L\n\n#define SN_id_GostR3410_94_CryptoPro_XchC_ParamSet              \"id-GostR3410-94-CryptoPro-XchC-ParamSet\"\n#define NID_id_GostR3410_94_CryptoPro_XchC_ParamSet             838\n#define OBJ_id_GostR3410_94_CryptoPro_XchC_ParamSet             OBJ_cryptopro,33L,3L\n\n#define SN_id_GostR3410_2001_TestParamSet               \"id-GostR3410-2001-TestParamSet\"\n#define NID_id_GostR3410_2001_TestParamSet              839\n#define OBJ_id_GostR3410_2001_TestParamSet              OBJ_cryptopro,35L,0L\n\n#define SN_id_GostR3410_2001_CryptoPro_A_ParamSet               \"id-GostR3410-2001-CryptoPro-A-ParamSet\"\n#define NID_id_GostR3410_2001_CryptoPro_A_ParamSet              840\n#define OBJ_id_GostR3410_2001_CryptoPro_A_ParamSet              OBJ_cryptopro,35L,1L\n\n#define SN_id_GostR3410_2001_CryptoPro_B_ParamSet               \"id-GostR3410-2001-CryptoPro-B-ParamSet\"\n#define NID_id_GostR3410_2001_CryptoPro_B_ParamSet              841\n#define OBJ_id_GostR3410_2001_CryptoPro_B_ParamSet              OBJ_cryptopro,35L,2L\n\n#define SN_id_GostR3410_2001_CryptoPro_C_ParamSet               \"id-GostR3410-2001-CryptoPro-C-ParamSet\"\n#define NID_id_GostR3410_2001_CryptoPro_C_ParamSet              842\n#define OBJ_id_GostR3410_2001_CryptoPro_C_ParamSet              OBJ_cryptopro,35L,3L\n\n#define SN_id_GostR3410_2001_CryptoPro_XchA_ParamSet            \"id-GostR3410-2001-CryptoPro-XchA-ParamSet\"\n#define NID_id_GostR3410_2001_CryptoPro_XchA_ParamSet           843\n#define OBJ_id_GostR3410_2001_CryptoPro_XchA_ParamSet           OBJ_cryptopro,36L,0L\n\n#define SN_id_GostR3410_2001_CryptoPro_XchB_ParamSet            \"id-GostR3410-2001-CryptoPro-XchB-ParamSet\"\n#define NID_id_GostR3410_2001_CryptoPro_XchB_ParamSet           844\n#define OBJ_id_GostR3410_2001_CryptoPro_XchB_ParamSet           OBJ_cryptopro,36L,1L\n\n#define SN_id_GostR3410_94_a            \"id-GostR3410-94-a\"\n#define NID_id_GostR3410_94_a           845\n#define OBJ_id_GostR3410_94_a           OBJ_id_GostR3410_94,1L\n\n#define SN_id_GostR3410_94_aBis         \"id-GostR3410-94-aBis\"\n#define NID_id_GostR3410_94_aBis                846\n#define OBJ_id_GostR3410_94_aBis                OBJ_id_GostR3410_94,2L\n\n#define SN_id_GostR3410_94_b            \"id-GostR3410-94-b\"\n#define NID_id_GostR3410_94_b           847\n#define OBJ_id_GostR3410_94_b           OBJ_id_GostR3410_94,3L\n\n#define SN_id_GostR3410_94_bBis         \"id-GostR3410-94-bBis\"\n#define NID_id_GostR3410_94_bBis                848\n#define OBJ_id_GostR3410_94_bBis                OBJ_id_GostR3410_94,4L\n\n#define SN_id_Gost28147_89_cc           \"id-Gost28147-89-cc\"\n#define LN_id_Gost28147_89_cc           \"GOST 28147-89 Cryptocom ParamSet\"\n#define NID_id_Gost28147_89_cc          849\n#define OBJ_id_Gost28147_89_cc          OBJ_cryptocom,1L,6L,1L\n\n#define SN_id_GostR3410_94_cc           \"gost94cc\"\n#define LN_id_GostR3410_94_cc           \"GOST 34.10-94 Cryptocom\"\n#define NID_id_GostR3410_94_cc          850\n#define OBJ_id_GostR3410_94_cc          OBJ_cryptocom,1L,5L,3L\n\n#define SN_id_GostR3410_2001_cc         \"gost2001cc\"\n#define LN_id_GostR3410_2001_cc         \"GOST 34.10-2001 Cryptocom\"\n#define NID_id_GostR3410_2001_cc                851\n#define OBJ_id_GostR3410_2001_cc                OBJ_cryptocom,1L,5L,4L\n\n#define SN_id_GostR3411_94_with_GostR3410_94_cc         \"id-GostR3411-94-with-GostR3410-94-cc\"\n#define LN_id_GostR3411_94_with_GostR3410_94_cc         \"GOST R 34.11-94 with GOST R 34.10-94 Cryptocom\"\n#define NID_id_GostR3411_94_with_GostR3410_94_cc                852\n#define OBJ_id_GostR3411_94_with_GostR3410_94_cc                OBJ_cryptocom,1L,3L,3L\n\n#define SN_id_GostR3411_94_with_GostR3410_2001_cc               \"id-GostR3411-94-with-GostR3410-2001-cc\"\n#define LN_id_GostR3411_94_with_GostR3410_2001_cc               \"GOST R 34.11-94 with GOST R 34.10-2001 Cryptocom\"\n#define NID_id_GostR3411_94_with_GostR3410_2001_cc              853\n#define OBJ_id_GostR3411_94_with_GostR3410_2001_cc              OBJ_cryptocom,1L,3L,4L\n\n#define SN_id_GostR3410_2001_ParamSet_cc                \"id-GostR3410-2001-ParamSet-cc\"\n#define LN_id_GostR3410_2001_ParamSet_cc                \"GOST R 3410-2001 Parameter Set Cryptocom\"\n#define NID_id_GostR3410_2001_ParamSet_cc               854\n#define OBJ_id_GostR3410_2001_ParamSet_cc               OBJ_cryptocom,1L,8L,1L\n\n#define SN_id_tc26_algorithms           \"id-tc26-algorithms\"\n#define NID_id_tc26_algorithms          977\n#define OBJ_id_tc26_algorithms          OBJ_id_tc26,1L\n\n#define SN_id_tc26_sign         \"id-tc26-sign\"\n#define NID_id_tc26_sign                978\n#define OBJ_id_tc26_sign                OBJ_id_tc26_algorithms,1L\n\n#define SN_id_GostR3410_2012_256                \"gost2012_256\"\n#define LN_id_GostR3410_2012_256                \"GOST R 34.10-2012 with 256 bit modulus\"\n#define NID_id_GostR3410_2012_256               979\n#define OBJ_id_GostR3410_2012_256               OBJ_id_tc26_sign,1L\n\n#define SN_id_GostR3410_2012_512                \"gost2012_512\"\n#define LN_id_GostR3410_2012_512                \"GOST R 34.10-2012 with 512 bit modulus\"\n#define NID_id_GostR3410_2012_512               980\n#define OBJ_id_GostR3410_2012_512               OBJ_id_tc26_sign,2L\n\n#define SN_id_tc26_digest               \"id-tc26-digest\"\n#define NID_id_tc26_digest              981\n#define OBJ_id_tc26_digest              OBJ_id_tc26_algorithms,2L\n\n#define SN_id_GostR3411_2012_256                \"md_gost12_256\"\n#define LN_id_GostR3411_2012_256                \"GOST R 34.11-2012 with 256 bit hash\"\n#define NID_id_GostR3411_2012_256               982\n#define OBJ_id_GostR3411_2012_256               OBJ_id_tc26_digest,2L\n\n#define SN_id_GostR3411_2012_512                \"md_gost12_512\"\n#define LN_id_GostR3411_2012_512                \"GOST R 34.11-2012 with 512 bit hash\"\n#define NID_id_GostR3411_2012_512               983\n#define OBJ_id_GostR3411_2012_512               OBJ_id_tc26_digest,3L\n\n#define SN_id_tc26_signwithdigest               \"id-tc26-signwithdigest\"\n#define NID_id_tc26_signwithdigest              984\n#define OBJ_id_tc26_signwithdigest              OBJ_id_tc26_algorithms,3L\n\n#define SN_id_tc26_signwithdigest_gost3410_2012_256             \"id-tc26-signwithdigest-gost3410-2012-256\"\n#define LN_id_tc26_signwithdigest_gost3410_2012_256             \"GOST R 34.10-2012 with GOST R 34.11-2012 (256 bit)\"\n#define NID_id_tc26_signwithdigest_gost3410_2012_256            985\n#define OBJ_id_tc26_signwithdigest_gost3410_2012_256            OBJ_id_tc26_signwithdigest,2L\n\n#define SN_id_tc26_signwithdigest_gost3410_2012_512             \"id-tc26-signwithdigest-gost3410-2012-512\"\n#define LN_id_tc26_signwithdigest_gost3410_2012_512             \"GOST R 34.10-2012 with GOST R 34.11-2012 (512 bit)\"\n#define NID_id_tc26_signwithdigest_gost3410_2012_512            986\n#define OBJ_id_tc26_signwithdigest_gost3410_2012_512            OBJ_id_tc26_signwithdigest,3L\n\n#define SN_id_tc26_mac          \"id-tc26-mac\"\n#define NID_id_tc26_mac         987\n#define OBJ_id_tc26_mac         OBJ_id_tc26_algorithms,4L\n\n#define SN_id_tc26_hmac_gost_3411_2012_256              \"id-tc26-hmac-gost-3411-2012-256\"\n#define LN_id_tc26_hmac_gost_3411_2012_256              \"HMAC GOST 34.11-2012 256 bit\"\n#define NID_id_tc26_hmac_gost_3411_2012_256             988\n#define OBJ_id_tc26_hmac_gost_3411_2012_256             OBJ_id_tc26_mac,1L\n\n#define SN_id_tc26_hmac_gost_3411_2012_512              \"id-tc26-hmac-gost-3411-2012-512\"\n#define LN_id_tc26_hmac_gost_3411_2012_512              \"HMAC GOST 34.11-2012 512 bit\"\n#define NID_id_tc26_hmac_gost_3411_2012_512             989\n#define OBJ_id_tc26_hmac_gost_3411_2012_512             OBJ_id_tc26_mac,2L\n\n#define SN_id_tc26_cipher               \"id-tc26-cipher\"\n#define NID_id_tc26_cipher              990\n#define OBJ_id_tc26_cipher              OBJ_id_tc26_algorithms,5L\n\n#define SN_id_tc26_cipher_gostr3412_2015_magma          \"id-tc26-cipher-gostr3412-2015-magma\"\n#define NID_id_tc26_cipher_gostr3412_2015_magma         1173\n#define OBJ_id_tc26_cipher_gostr3412_2015_magma         OBJ_id_tc26_cipher,1L\n\n#define SN_id_tc26_cipher_gostr3412_2015_magma_ctracpkm         \"id-tc26-cipher-gostr3412-2015-magma-ctracpkm\"\n#define NID_id_tc26_cipher_gostr3412_2015_magma_ctracpkm                1174\n#define OBJ_id_tc26_cipher_gostr3412_2015_magma_ctracpkm                OBJ_id_tc26_cipher_gostr3412_2015_magma,1L\n\n#define SN_id_tc26_cipher_gostr3412_2015_magma_ctracpkm_omac            \"id-tc26-cipher-gostr3412-2015-magma-ctracpkm-omac\"\n#define NID_id_tc26_cipher_gostr3412_2015_magma_ctracpkm_omac           1175\n#define OBJ_id_tc26_cipher_gostr3412_2015_magma_ctracpkm_omac           OBJ_id_tc26_cipher_gostr3412_2015_magma,2L\n\n#define SN_id_tc26_cipher_gostr3412_2015_kuznyechik             \"id-tc26-cipher-gostr3412-2015-kuznyechik\"\n#define NID_id_tc26_cipher_gostr3412_2015_kuznyechik            1176\n#define OBJ_id_tc26_cipher_gostr3412_2015_kuznyechik            OBJ_id_tc26_cipher,2L\n\n#define SN_id_tc26_cipher_gostr3412_2015_kuznyechik_ctracpkm            \"id-tc26-cipher-gostr3412-2015-kuznyechik-ctracpkm\"\n#define NID_id_tc26_cipher_gostr3412_2015_kuznyechik_ctracpkm           1177\n#define OBJ_id_tc26_cipher_gostr3412_2015_kuznyechik_ctracpkm           OBJ_id_tc26_cipher_gostr3412_2015_kuznyechik,1L\n\n#define SN_id_tc26_cipher_gostr3412_2015_kuznyechik_ctracpkm_omac               \"id-tc26-cipher-gostr3412-2015-kuznyechik-ctracpkm-omac\"\n#define NID_id_tc26_cipher_gostr3412_2015_kuznyechik_ctracpkm_omac              1178\n#define OBJ_id_tc26_cipher_gostr3412_2015_kuznyechik_ctracpkm_omac              OBJ_id_tc26_cipher_gostr3412_2015_kuznyechik,2L\n\n#define SN_id_tc26_agreement            \"id-tc26-agreement\"\n#define NID_id_tc26_agreement           991\n#define OBJ_id_tc26_agreement           OBJ_id_tc26_algorithms,6L\n\n#define SN_id_tc26_agreement_gost_3410_2012_256         \"id-tc26-agreement-gost-3410-2012-256\"\n#define NID_id_tc26_agreement_gost_3410_2012_256                992\n#define OBJ_id_tc26_agreement_gost_3410_2012_256                OBJ_id_tc26_agreement,1L\n\n#define SN_id_tc26_agreement_gost_3410_2012_512         \"id-tc26-agreement-gost-3410-2012-512\"\n#define NID_id_tc26_agreement_gost_3410_2012_512                993\n#define OBJ_id_tc26_agreement_gost_3410_2012_512                OBJ_id_tc26_agreement,2L\n\n#define SN_id_tc26_wrap         \"id-tc26-wrap\"\n#define NID_id_tc26_wrap                1179\n#define OBJ_id_tc26_wrap                OBJ_id_tc26_algorithms,7L\n\n#define SN_id_tc26_wrap_gostr3412_2015_magma            \"id-tc26-wrap-gostr3412-2015-magma\"\n#define NID_id_tc26_wrap_gostr3412_2015_magma           1180\n#define OBJ_id_tc26_wrap_gostr3412_2015_magma           OBJ_id_tc26_wrap,1L\n\n#define SN_id_tc26_wrap_gostr3412_2015_magma_kexp15             \"id-tc26-wrap-gostr3412-2015-magma-kexp15\"\n#define NID_id_tc26_wrap_gostr3412_2015_magma_kexp15            1181\n#define OBJ_id_tc26_wrap_gostr3412_2015_magma_kexp15            OBJ_id_tc26_wrap_gostr3412_2015_magma,1L\n\n#define SN_id_tc26_wrap_gostr3412_2015_kuznyechik               \"id-tc26-wrap-gostr3412-2015-kuznyechik\"\n#define NID_id_tc26_wrap_gostr3412_2015_kuznyechik              1182\n#define OBJ_id_tc26_wrap_gostr3412_2015_kuznyechik              OBJ_id_tc26_wrap,2L\n\n#define SN_id_tc26_wrap_gostr3412_2015_kuznyechik_kexp15                \"id-tc26-wrap-gostr3412-2015-kuznyechik-kexp15\"\n#define NID_id_tc26_wrap_gostr3412_2015_kuznyechik_kexp15               1183\n#define OBJ_id_tc26_wrap_gostr3412_2015_kuznyechik_kexp15               OBJ_id_tc26_wrap_gostr3412_2015_kuznyechik,1L\n\n#define SN_id_tc26_constants            \"id-tc26-constants\"\n#define NID_id_tc26_constants           994\n#define OBJ_id_tc26_constants           OBJ_id_tc26,2L\n\n#define SN_id_tc26_sign_constants               \"id-tc26-sign-constants\"\n#define NID_id_tc26_sign_constants              995\n#define OBJ_id_tc26_sign_constants              OBJ_id_tc26_constants,1L\n\n#define SN_id_tc26_gost_3410_2012_256_constants         \"id-tc26-gost-3410-2012-256-constants\"\n#define NID_id_tc26_gost_3410_2012_256_constants                1147\n#define OBJ_id_tc26_gost_3410_2012_256_constants                OBJ_id_tc26_sign_constants,1L\n\n#define SN_id_tc26_gost_3410_2012_256_paramSetA         \"id-tc26-gost-3410-2012-256-paramSetA\"\n#define LN_id_tc26_gost_3410_2012_256_paramSetA         \"GOST R 34.10-2012 (256 bit) ParamSet A\"\n#define NID_id_tc26_gost_3410_2012_256_paramSetA                1148\n#define OBJ_id_tc26_gost_3410_2012_256_paramSetA                OBJ_id_tc26_gost_3410_2012_256_constants,1L\n\n#define SN_id_tc26_gost_3410_2012_256_paramSetB         \"id-tc26-gost-3410-2012-256-paramSetB\"\n#define LN_id_tc26_gost_3410_2012_256_paramSetB         \"GOST R 34.10-2012 (256 bit) ParamSet B\"\n#define NID_id_tc26_gost_3410_2012_256_paramSetB                1184\n#define OBJ_id_tc26_gost_3410_2012_256_paramSetB                OBJ_id_tc26_gost_3410_2012_256_constants,2L\n\n#define SN_id_tc26_gost_3410_2012_256_paramSetC         \"id-tc26-gost-3410-2012-256-paramSetC\"\n#define LN_id_tc26_gost_3410_2012_256_paramSetC         \"GOST R 34.10-2012 (256 bit) ParamSet C\"\n#define NID_id_tc26_gost_3410_2012_256_paramSetC                1185\n#define OBJ_id_tc26_gost_3410_2012_256_paramSetC                OBJ_id_tc26_gost_3410_2012_256_constants,3L\n\n#define SN_id_tc26_gost_3410_2012_256_paramSetD         \"id-tc26-gost-3410-2012-256-paramSetD\"\n#define LN_id_tc26_gost_3410_2012_256_paramSetD         \"GOST R 34.10-2012 (256 bit) ParamSet D\"\n#define NID_id_tc26_gost_3410_2012_256_paramSetD                1186\n#define OBJ_id_tc26_gost_3410_2012_256_paramSetD                OBJ_id_tc26_gost_3410_2012_256_constants,4L\n\n#define SN_id_tc26_gost_3410_2012_512_constants         \"id-tc26-gost-3410-2012-512-constants\"\n#define NID_id_tc26_gost_3410_2012_512_constants                996\n#define OBJ_id_tc26_gost_3410_2012_512_constants                OBJ_id_tc26_sign_constants,2L\n\n#define SN_id_tc26_gost_3410_2012_512_paramSetTest              \"id-tc26-gost-3410-2012-512-paramSetTest\"\n#define LN_id_tc26_gost_3410_2012_512_paramSetTest              \"GOST R 34.10-2012 (512 bit) testing parameter set\"\n#define NID_id_tc26_gost_3410_2012_512_paramSetTest             997\n#define OBJ_id_tc26_gost_3410_2012_512_paramSetTest             OBJ_id_tc26_gost_3410_2012_512_constants,0L\n\n#define SN_id_tc26_gost_3410_2012_512_paramSetA         \"id-tc26-gost-3410-2012-512-paramSetA\"\n#define LN_id_tc26_gost_3410_2012_512_paramSetA         \"GOST R 34.10-2012 (512 bit) ParamSet A\"\n#define NID_id_tc26_gost_3410_2012_512_paramSetA                998\n#define OBJ_id_tc26_gost_3410_2012_512_paramSetA                OBJ_id_tc26_gost_3410_2012_512_constants,1L\n\n#define SN_id_tc26_gost_3410_2012_512_paramSetB         \"id-tc26-gost-3410-2012-512-paramSetB\"\n#define LN_id_tc26_gost_3410_2012_512_paramSetB         \"GOST R 34.10-2012 (512 bit) ParamSet B\"\n#define NID_id_tc26_gost_3410_2012_512_paramSetB                999\n#define OBJ_id_tc26_gost_3410_2012_512_paramSetB                OBJ_id_tc26_gost_3410_2012_512_constants,2L\n\n#define SN_id_tc26_gost_3410_2012_512_paramSetC         \"id-tc26-gost-3410-2012-512-paramSetC\"\n#define LN_id_tc26_gost_3410_2012_512_paramSetC         \"GOST R 34.10-2012 (512 bit) ParamSet C\"\n#define NID_id_tc26_gost_3410_2012_512_paramSetC                1149\n#define OBJ_id_tc26_gost_3410_2012_512_paramSetC                OBJ_id_tc26_gost_3410_2012_512_constants,3L\n\n#define SN_id_tc26_digest_constants             \"id-tc26-digest-constants\"\n#define NID_id_tc26_digest_constants            1000\n#define OBJ_id_tc26_digest_constants            OBJ_id_tc26_constants,2L\n\n#define SN_id_tc26_cipher_constants             \"id-tc26-cipher-constants\"\n#define NID_id_tc26_cipher_constants            1001\n#define OBJ_id_tc26_cipher_constants            OBJ_id_tc26_constants,5L\n\n#define SN_id_tc26_gost_28147_constants         \"id-tc26-gost-28147-constants\"\n#define NID_id_tc26_gost_28147_constants                1002\n#define OBJ_id_tc26_gost_28147_constants                OBJ_id_tc26_cipher_constants,1L\n\n#define SN_id_tc26_gost_28147_param_Z           \"id-tc26-gost-28147-param-Z\"\n#define LN_id_tc26_gost_28147_param_Z           \"GOST 28147-89 TC26 parameter set\"\n#define NID_id_tc26_gost_28147_param_Z          1003\n#define OBJ_id_tc26_gost_28147_param_Z          OBJ_id_tc26_gost_28147_constants,1L\n\n#define SN_INN          \"INN\"\n#define LN_INN          \"INN\"\n#define NID_INN         1004\n#define OBJ_INN         OBJ_member_body,643L,3L,131L,1L,1L\n\n#define SN_OGRN         \"OGRN\"\n#define LN_OGRN         \"OGRN\"\n#define NID_OGRN                1005\n#define OBJ_OGRN                OBJ_member_body,643L,100L,1L\n\n#define SN_SNILS                \"SNILS\"\n#define LN_SNILS                \"SNILS\"\n#define NID_SNILS               1006\n#define OBJ_SNILS               OBJ_member_body,643L,100L,3L\n\n#define SN_subjectSignTool              \"subjectSignTool\"\n#define LN_subjectSignTool              \"Signing Tool of Subject\"\n#define NID_subjectSignTool             1007\n#define OBJ_subjectSignTool             OBJ_member_body,643L,100L,111L\n\n#define SN_issuerSignTool               \"issuerSignTool\"\n#define LN_issuerSignTool               \"Signing Tool of Issuer\"\n#define NID_issuerSignTool              1008\n#define OBJ_issuerSignTool              OBJ_member_body,643L,100L,112L\n\n#define SN_grasshopper_ecb              \"grasshopper-ecb\"\n#define NID_grasshopper_ecb             1012\n\n#define SN_grasshopper_ctr              \"grasshopper-ctr\"\n#define NID_grasshopper_ctr             1013\n\n#define SN_grasshopper_ofb              \"grasshopper-ofb\"\n#define NID_grasshopper_ofb             1014\n\n#define SN_grasshopper_cbc              \"grasshopper-cbc\"\n#define NID_grasshopper_cbc             1015\n\n#define SN_grasshopper_cfb              \"grasshopper-cfb\"\n#define NID_grasshopper_cfb             1016\n\n#define SN_grasshopper_mac              \"grasshopper-mac\"\n#define NID_grasshopper_mac             1017\n\n#define SN_magma_ecb            \"magma-ecb\"\n#define NID_magma_ecb           1187\n\n#define SN_magma_ctr            \"magma-ctr\"\n#define NID_magma_ctr           1188\n\n#define SN_magma_ofb            \"magma-ofb\"\n#define NID_magma_ofb           1189\n\n#define SN_magma_cbc            \"magma-cbc\"\n#define NID_magma_cbc           1190\n\n#define SN_magma_cfb            \"magma-cfb\"\n#define NID_magma_cfb           1191\n\n#define SN_magma_mac            \"magma-mac\"\n#define NID_magma_mac           1192\n\n#define SN_camellia_128_cbc             \"CAMELLIA-128-CBC\"\n#define LN_camellia_128_cbc             \"camellia-128-cbc\"\n#define NID_camellia_128_cbc            751\n#define OBJ_camellia_128_cbc            1L,2L,392L,200011L,61L,1L,1L,1L,2L\n\n#define SN_camellia_192_cbc             \"CAMELLIA-192-CBC\"\n#define LN_camellia_192_cbc             \"camellia-192-cbc\"\n#define NID_camellia_192_cbc            752\n#define OBJ_camellia_192_cbc            1L,2L,392L,200011L,61L,1L,1L,1L,3L\n\n#define SN_camellia_256_cbc             \"CAMELLIA-256-CBC\"\n#define LN_camellia_256_cbc             \"camellia-256-cbc\"\n#define NID_camellia_256_cbc            753\n#define OBJ_camellia_256_cbc            1L,2L,392L,200011L,61L,1L,1L,1L,4L\n\n#define SN_id_camellia128_wrap          \"id-camellia128-wrap\"\n#define NID_id_camellia128_wrap         907\n#define OBJ_id_camellia128_wrap         1L,2L,392L,200011L,61L,1L,1L,3L,2L\n\n#define SN_id_camellia192_wrap          \"id-camellia192-wrap\"\n#define NID_id_camellia192_wrap         908\n#define OBJ_id_camellia192_wrap         1L,2L,392L,200011L,61L,1L,1L,3L,3L\n\n#define SN_id_camellia256_wrap          \"id-camellia256-wrap\"\n#define NID_id_camellia256_wrap         909\n#define OBJ_id_camellia256_wrap         1L,2L,392L,200011L,61L,1L,1L,3L,4L\n\n#define OBJ_ntt_ds              0L,3L,4401L,5L\n\n#define OBJ_camellia            OBJ_ntt_ds,3L,1L,9L\n\n#define SN_camellia_128_ecb             \"CAMELLIA-128-ECB\"\n#define LN_camellia_128_ecb             \"camellia-128-ecb\"\n#define NID_camellia_128_ecb            754\n#define OBJ_camellia_128_ecb            OBJ_camellia,1L\n\n#define SN_camellia_128_ofb128          \"CAMELLIA-128-OFB\"\n#define LN_camellia_128_ofb128          \"camellia-128-ofb\"\n#define NID_camellia_128_ofb128         766\n#define OBJ_camellia_128_ofb128         OBJ_camellia,3L\n\n#define SN_camellia_128_cfb128          \"CAMELLIA-128-CFB\"\n#define LN_camellia_128_cfb128          \"camellia-128-cfb\"\n#define NID_camellia_128_cfb128         757\n#define OBJ_camellia_128_cfb128         OBJ_camellia,4L\n\n#define SN_camellia_128_gcm             \"CAMELLIA-128-GCM\"\n#define LN_camellia_128_gcm             \"camellia-128-gcm\"\n#define NID_camellia_128_gcm            961\n#define OBJ_camellia_128_gcm            OBJ_camellia,6L\n\n#define SN_camellia_128_ccm             \"CAMELLIA-128-CCM\"\n#define LN_camellia_128_ccm             \"camellia-128-ccm\"\n#define NID_camellia_128_ccm            962\n#define OBJ_camellia_128_ccm            OBJ_camellia,7L\n\n#define SN_camellia_128_ctr             \"CAMELLIA-128-CTR\"\n#define LN_camellia_128_ctr             \"camellia-128-ctr\"\n#define NID_camellia_128_ctr            963\n#define OBJ_camellia_128_ctr            OBJ_camellia,9L\n\n#define SN_camellia_128_cmac            \"CAMELLIA-128-CMAC\"\n#define LN_camellia_128_cmac            \"camellia-128-cmac\"\n#define NID_camellia_128_cmac           964\n#define OBJ_camellia_128_cmac           OBJ_camellia,10L\n\n#define SN_camellia_192_ecb             \"CAMELLIA-192-ECB\"\n#define LN_camellia_192_ecb             \"camellia-192-ecb\"\n#define NID_camellia_192_ecb            755\n#define OBJ_camellia_192_ecb            OBJ_camellia,21L\n\n#define SN_camellia_192_ofb128          \"CAMELLIA-192-OFB\"\n#define LN_camellia_192_ofb128          \"camellia-192-ofb\"\n#define NID_camellia_192_ofb128         767\n#define OBJ_camellia_192_ofb128         OBJ_camellia,23L\n\n#define SN_camellia_192_cfb128          \"CAMELLIA-192-CFB\"\n#define LN_camellia_192_cfb128          \"camellia-192-cfb\"\n#define NID_camellia_192_cfb128         758\n#define OBJ_camellia_192_cfb128         OBJ_camellia,24L\n\n#define SN_camellia_192_gcm             \"CAMELLIA-192-GCM\"\n#define LN_camellia_192_gcm             \"camellia-192-gcm\"\n#define NID_camellia_192_gcm            965\n#define OBJ_camellia_192_gcm            OBJ_camellia,26L\n\n#define SN_camellia_192_ccm             \"CAMELLIA-192-CCM\"\n#define LN_camellia_192_ccm             \"camellia-192-ccm\"\n#define NID_camellia_192_ccm            966\n#define OBJ_camellia_192_ccm            OBJ_camellia,27L\n\n#define SN_camellia_192_ctr             \"CAMELLIA-192-CTR\"\n#define LN_camellia_192_ctr             \"camellia-192-ctr\"\n#define NID_camellia_192_ctr            967\n#define OBJ_camellia_192_ctr            OBJ_camellia,29L\n\n#define SN_camellia_192_cmac            \"CAMELLIA-192-CMAC\"\n#define LN_camellia_192_cmac            \"camellia-192-cmac\"\n#define NID_camellia_192_cmac           968\n#define OBJ_camellia_192_cmac           OBJ_camellia,30L\n\n#define SN_camellia_256_ecb             \"CAMELLIA-256-ECB\"\n#define LN_camellia_256_ecb             \"camellia-256-ecb\"\n#define NID_camellia_256_ecb            756\n#define OBJ_camellia_256_ecb            OBJ_camellia,41L\n\n#define SN_camellia_256_ofb128          \"CAMELLIA-256-OFB\"\n#define LN_camellia_256_ofb128          \"camellia-256-ofb\"\n#define NID_camellia_256_ofb128         768\n#define OBJ_camellia_256_ofb128         OBJ_camellia,43L\n\n#define SN_camellia_256_cfb128          \"CAMELLIA-256-CFB\"\n#define LN_camellia_256_cfb128          \"camellia-256-cfb\"\n#define NID_camellia_256_cfb128         759\n#define OBJ_camellia_256_cfb128         OBJ_camellia,44L\n\n#define SN_camellia_256_gcm             \"CAMELLIA-256-GCM\"\n#define LN_camellia_256_gcm             \"camellia-256-gcm\"\n#define NID_camellia_256_gcm            969\n#define OBJ_camellia_256_gcm            OBJ_camellia,46L\n\n#define SN_camellia_256_ccm             \"CAMELLIA-256-CCM\"\n#define LN_camellia_256_ccm             \"camellia-256-ccm\"\n#define NID_camellia_256_ccm            970\n#define OBJ_camellia_256_ccm            OBJ_camellia,47L\n\n#define SN_camellia_256_ctr             \"CAMELLIA-256-CTR\"\n#define LN_camellia_256_ctr             \"camellia-256-ctr\"\n#define NID_camellia_256_ctr            971\n#define OBJ_camellia_256_ctr            OBJ_camellia,49L\n\n#define SN_camellia_256_cmac            \"CAMELLIA-256-CMAC\"\n#define LN_camellia_256_cmac            \"camellia-256-cmac\"\n#define NID_camellia_256_cmac           972\n#define OBJ_camellia_256_cmac           OBJ_camellia,50L\n\n#define SN_camellia_128_cfb1            \"CAMELLIA-128-CFB1\"\n#define LN_camellia_128_cfb1            \"camellia-128-cfb1\"\n#define NID_camellia_128_cfb1           760\n\n#define SN_camellia_192_cfb1            \"CAMELLIA-192-CFB1\"\n#define LN_camellia_192_cfb1            \"camellia-192-cfb1\"\n#define NID_camellia_192_cfb1           761\n\n#define SN_camellia_256_cfb1            \"CAMELLIA-256-CFB1\"\n#define LN_camellia_256_cfb1            \"camellia-256-cfb1\"\n#define NID_camellia_256_cfb1           762\n\n#define SN_camellia_128_cfb8            \"CAMELLIA-128-CFB8\"\n#define LN_camellia_128_cfb8            \"camellia-128-cfb8\"\n#define NID_camellia_128_cfb8           763\n\n#define SN_camellia_192_cfb8            \"CAMELLIA-192-CFB8\"\n#define LN_camellia_192_cfb8            \"camellia-192-cfb8\"\n#define NID_camellia_192_cfb8           764\n\n#define SN_camellia_256_cfb8            \"CAMELLIA-256-CFB8\"\n#define LN_camellia_256_cfb8            \"camellia-256-cfb8\"\n#define NID_camellia_256_cfb8           765\n\n#define OBJ_aria                1L,2L,410L,200046L,1L,1L\n\n#define SN_aria_128_ecb         \"ARIA-128-ECB\"\n#define LN_aria_128_ecb         \"aria-128-ecb\"\n#define NID_aria_128_ecb                1065\n#define OBJ_aria_128_ecb                OBJ_aria,1L\n\n#define SN_aria_128_cbc         \"ARIA-128-CBC\"\n#define LN_aria_128_cbc         \"aria-128-cbc\"\n#define NID_aria_128_cbc                1066\n#define OBJ_aria_128_cbc                OBJ_aria,2L\n\n#define SN_aria_128_cfb128              \"ARIA-128-CFB\"\n#define LN_aria_128_cfb128              \"aria-128-cfb\"\n#define NID_aria_128_cfb128             1067\n#define OBJ_aria_128_cfb128             OBJ_aria,3L\n\n#define SN_aria_128_ofb128              \"ARIA-128-OFB\"\n#define LN_aria_128_ofb128              \"aria-128-ofb\"\n#define NID_aria_128_ofb128             1068\n#define OBJ_aria_128_ofb128             OBJ_aria,4L\n\n#define SN_aria_128_ctr         \"ARIA-128-CTR\"\n#define LN_aria_128_ctr         \"aria-128-ctr\"\n#define NID_aria_128_ctr                1069\n#define OBJ_aria_128_ctr                OBJ_aria,5L\n\n#define SN_aria_192_ecb         \"ARIA-192-ECB\"\n#define LN_aria_192_ecb         \"aria-192-ecb\"\n#define NID_aria_192_ecb                1070\n#define OBJ_aria_192_ecb                OBJ_aria,6L\n\n#define SN_aria_192_cbc         \"ARIA-192-CBC\"\n#define LN_aria_192_cbc         \"aria-192-cbc\"\n#define NID_aria_192_cbc                1071\n#define OBJ_aria_192_cbc                OBJ_aria,7L\n\n#define SN_aria_192_cfb128              \"ARIA-192-CFB\"\n#define LN_aria_192_cfb128              \"aria-192-cfb\"\n#define NID_aria_192_cfb128             1072\n#define OBJ_aria_192_cfb128             OBJ_aria,8L\n\n#define SN_aria_192_ofb128              \"ARIA-192-OFB\"\n#define LN_aria_192_ofb128              \"aria-192-ofb\"\n#define NID_aria_192_ofb128             1073\n#define OBJ_aria_192_ofb128             OBJ_aria,9L\n\n#define SN_aria_192_ctr         \"ARIA-192-CTR\"\n#define LN_aria_192_ctr         \"aria-192-ctr\"\n#define NID_aria_192_ctr                1074\n#define OBJ_aria_192_ctr                OBJ_aria,10L\n\n#define SN_aria_256_ecb         \"ARIA-256-ECB\"\n#define LN_aria_256_ecb         \"aria-256-ecb\"\n#define NID_aria_256_ecb                1075\n#define OBJ_aria_256_ecb                OBJ_aria,11L\n\n#define SN_aria_256_cbc         \"ARIA-256-CBC\"\n#define LN_aria_256_cbc         \"aria-256-cbc\"\n#define NID_aria_256_cbc                1076\n#define OBJ_aria_256_cbc                OBJ_aria,12L\n\n#define SN_aria_256_cfb128              \"ARIA-256-CFB\"\n#define LN_aria_256_cfb128              \"aria-256-cfb\"\n#define NID_aria_256_cfb128             1077\n#define OBJ_aria_256_cfb128             OBJ_aria,13L\n\n#define SN_aria_256_ofb128              \"ARIA-256-OFB\"\n#define LN_aria_256_ofb128              \"aria-256-ofb\"\n#define NID_aria_256_ofb128             1078\n#define OBJ_aria_256_ofb128             OBJ_aria,14L\n\n#define SN_aria_256_ctr         \"ARIA-256-CTR\"\n#define LN_aria_256_ctr         \"aria-256-ctr\"\n#define NID_aria_256_ctr                1079\n#define OBJ_aria_256_ctr                OBJ_aria,15L\n\n#define SN_aria_128_cfb1                \"ARIA-128-CFB1\"\n#define LN_aria_128_cfb1                \"aria-128-cfb1\"\n#define NID_aria_128_cfb1               1080\n\n#define SN_aria_192_cfb1                \"ARIA-192-CFB1\"\n#define LN_aria_192_cfb1                \"aria-192-cfb1\"\n#define NID_aria_192_cfb1               1081\n\n#define SN_aria_256_cfb1                \"ARIA-256-CFB1\"\n#define LN_aria_256_cfb1                \"aria-256-cfb1\"\n#define NID_aria_256_cfb1               1082\n\n#define SN_aria_128_cfb8                \"ARIA-128-CFB8\"\n#define LN_aria_128_cfb8                \"aria-128-cfb8\"\n#define NID_aria_128_cfb8               1083\n\n#define SN_aria_192_cfb8                \"ARIA-192-CFB8\"\n#define LN_aria_192_cfb8                \"aria-192-cfb8\"\n#define NID_aria_192_cfb8               1084\n\n#define SN_aria_256_cfb8                \"ARIA-256-CFB8\"\n#define LN_aria_256_cfb8                \"aria-256-cfb8\"\n#define NID_aria_256_cfb8               1085\n\n#define SN_aria_128_ccm         \"ARIA-128-CCM\"\n#define LN_aria_128_ccm         \"aria-128-ccm\"\n#define NID_aria_128_ccm                1120\n#define OBJ_aria_128_ccm                OBJ_aria,37L\n\n#define SN_aria_192_ccm         \"ARIA-192-CCM\"\n#define LN_aria_192_ccm         \"aria-192-ccm\"\n#define NID_aria_192_ccm                1121\n#define OBJ_aria_192_ccm                OBJ_aria,38L\n\n#define SN_aria_256_ccm         \"ARIA-256-CCM\"\n#define LN_aria_256_ccm         \"aria-256-ccm\"\n#define NID_aria_256_ccm                1122\n#define OBJ_aria_256_ccm                OBJ_aria,39L\n\n#define SN_aria_128_gcm         \"ARIA-128-GCM\"\n#define LN_aria_128_gcm         \"aria-128-gcm\"\n#define NID_aria_128_gcm                1123\n#define OBJ_aria_128_gcm                OBJ_aria,34L\n\n#define SN_aria_192_gcm         \"ARIA-192-GCM\"\n#define LN_aria_192_gcm         \"aria-192-gcm\"\n#define NID_aria_192_gcm                1124\n#define OBJ_aria_192_gcm                OBJ_aria,35L\n\n#define SN_aria_256_gcm         \"ARIA-256-GCM\"\n#define LN_aria_256_gcm         \"aria-256-gcm\"\n#define NID_aria_256_gcm                1125\n#define OBJ_aria_256_gcm                OBJ_aria,36L\n\n#define SN_kisa         \"KISA\"\n#define LN_kisa         \"kisa\"\n#define NID_kisa                773\n#define OBJ_kisa                OBJ_member_body,410L,200004L\n\n#define SN_seed_ecb             \"SEED-ECB\"\n#define LN_seed_ecb             \"seed-ecb\"\n#define NID_seed_ecb            776\n#define OBJ_seed_ecb            OBJ_kisa,1L,3L\n\n#define SN_seed_cbc             \"SEED-CBC\"\n#define LN_seed_cbc             \"seed-cbc\"\n#define NID_seed_cbc            777\n#define OBJ_seed_cbc            OBJ_kisa,1L,4L\n\n#define SN_seed_cfb128          \"SEED-CFB\"\n#define LN_seed_cfb128          \"seed-cfb\"\n#define NID_seed_cfb128         779\n#define OBJ_seed_cfb128         OBJ_kisa,1L,5L\n\n#define SN_seed_ofb128          \"SEED-OFB\"\n#define LN_seed_ofb128          \"seed-ofb\"\n#define NID_seed_ofb128         778\n#define OBJ_seed_ofb128         OBJ_kisa,1L,6L\n\n#define SN_sm4_ecb              \"SM4-ECB\"\n#define LN_sm4_ecb              \"sm4-ecb\"\n#define NID_sm4_ecb             1133\n#define OBJ_sm4_ecb             OBJ_sm_scheme,104L,1L\n\n#define SN_sm4_cbc              \"SM4-CBC\"\n#define LN_sm4_cbc              \"sm4-cbc\"\n#define NID_sm4_cbc             1134\n#define OBJ_sm4_cbc             OBJ_sm_scheme,104L,2L\n\n#define SN_sm4_ofb128           \"SM4-OFB\"\n#define LN_sm4_ofb128           \"sm4-ofb\"\n#define NID_sm4_ofb128          1135\n#define OBJ_sm4_ofb128          OBJ_sm_scheme,104L,3L\n\n#define SN_sm4_cfb128           \"SM4-CFB\"\n#define LN_sm4_cfb128           \"sm4-cfb\"\n#define NID_sm4_cfb128          1137\n#define OBJ_sm4_cfb128          OBJ_sm_scheme,104L,4L\n\n#define SN_sm4_cfb1             \"SM4-CFB1\"\n#define LN_sm4_cfb1             \"sm4-cfb1\"\n#define NID_sm4_cfb1            1136\n#define OBJ_sm4_cfb1            OBJ_sm_scheme,104L,5L\n\n#define SN_sm4_cfb8             \"SM4-CFB8\"\n#define LN_sm4_cfb8             \"sm4-cfb8\"\n#define NID_sm4_cfb8            1138\n#define OBJ_sm4_cfb8            OBJ_sm_scheme,104L,6L\n\n#define SN_sm4_ctr              \"SM4-CTR\"\n#define LN_sm4_ctr              \"sm4-ctr\"\n#define NID_sm4_ctr             1139\n#define OBJ_sm4_ctr             OBJ_sm_scheme,104L,7L\n\n#define SN_hmac         \"HMAC\"\n#define LN_hmac         \"hmac\"\n#define NID_hmac                855\n\n#define SN_cmac         \"CMAC\"\n#define LN_cmac         \"cmac\"\n#define NID_cmac                894\n\n#define SN_rc4_hmac_md5         \"RC4-HMAC-MD5\"\n#define LN_rc4_hmac_md5         \"rc4-hmac-md5\"\n#define NID_rc4_hmac_md5                915\n\n#define SN_aes_128_cbc_hmac_sha1                \"AES-128-CBC-HMAC-SHA1\"\n#define LN_aes_128_cbc_hmac_sha1                \"aes-128-cbc-hmac-sha1\"\n#define NID_aes_128_cbc_hmac_sha1               916\n\n#define SN_aes_192_cbc_hmac_sha1                \"AES-192-CBC-HMAC-SHA1\"\n#define LN_aes_192_cbc_hmac_sha1                \"aes-192-cbc-hmac-sha1\"\n#define NID_aes_192_cbc_hmac_sha1               917\n\n#define SN_aes_256_cbc_hmac_sha1                \"AES-256-CBC-HMAC-SHA1\"\n#define LN_aes_256_cbc_hmac_sha1                \"aes-256-cbc-hmac-sha1\"\n#define NID_aes_256_cbc_hmac_sha1               918\n\n#define SN_aes_128_cbc_hmac_sha256              \"AES-128-CBC-HMAC-SHA256\"\n#define LN_aes_128_cbc_hmac_sha256              \"aes-128-cbc-hmac-sha256\"\n#define NID_aes_128_cbc_hmac_sha256             948\n\n#define SN_aes_192_cbc_hmac_sha256              \"AES-192-CBC-HMAC-SHA256\"\n#define LN_aes_192_cbc_hmac_sha256              \"aes-192-cbc-hmac-sha256\"\n#define NID_aes_192_cbc_hmac_sha256             949\n\n#define SN_aes_256_cbc_hmac_sha256              \"AES-256-CBC-HMAC-SHA256\"\n#define LN_aes_256_cbc_hmac_sha256              \"aes-256-cbc-hmac-sha256\"\n#define NID_aes_256_cbc_hmac_sha256             950\n\n#define SN_chacha20_poly1305            \"ChaCha20-Poly1305\"\n#define LN_chacha20_poly1305            \"chacha20-poly1305\"\n#define NID_chacha20_poly1305           1018\n\n#define SN_chacha20             \"ChaCha20\"\n#define LN_chacha20             \"chacha20\"\n#define NID_chacha20            1019\n\n#define SN_dhpublicnumber               \"dhpublicnumber\"\n#define LN_dhpublicnumber               \"X9.42 DH\"\n#define NID_dhpublicnumber              920\n#define OBJ_dhpublicnumber              OBJ_ISO_US,10046L,2L,1L\n\n#define SN_brainpoolP160r1              \"brainpoolP160r1\"\n#define NID_brainpoolP160r1             921\n#define OBJ_brainpoolP160r1             1L,3L,36L,3L,3L,2L,8L,1L,1L,1L\n\n#define SN_brainpoolP160t1              \"brainpoolP160t1\"\n#define NID_brainpoolP160t1             922\n#define OBJ_brainpoolP160t1             1L,3L,36L,3L,3L,2L,8L,1L,1L,2L\n\n#define SN_brainpoolP192r1              \"brainpoolP192r1\"\n#define NID_brainpoolP192r1             923\n#define OBJ_brainpoolP192r1             1L,3L,36L,3L,3L,2L,8L,1L,1L,3L\n\n#define SN_brainpoolP192t1              \"brainpoolP192t1\"\n#define NID_brainpoolP192t1             924\n#define OBJ_brainpoolP192t1             1L,3L,36L,3L,3L,2L,8L,1L,1L,4L\n\n#define SN_brainpoolP224r1              \"brainpoolP224r1\"\n#define NID_brainpoolP224r1             925\n#define OBJ_brainpoolP224r1             1L,3L,36L,3L,3L,2L,8L,1L,1L,5L\n\n#define SN_brainpoolP224t1              \"brainpoolP224t1\"\n#define NID_brainpoolP224t1             926\n#define OBJ_brainpoolP224t1             1L,3L,36L,3L,3L,2L,8L,1L,1L,6L\n\n#define SN_brainpoolP256r1              \"brainpoolP256r1\"\n#define NID_brainpoolP256r1             927\n#define OBJ_brainpoolP256r1             1L,3L,36L,3L,3L,2L,8L,1L,1L,7L\n\n#define SN_brainpoolP256t1              \"brainpoolP256t1\"\n#define NID_brainpoolP256t1             928\n#define OBJ_brainpoolP256t1             1L,3L,36L,3L,3L,2L,8L,1L,1L,8L\n\n#define SN_brainpoolP320r1              \"brainpoolP320r1\"\n#define NID_brainpoolP320r1             929\n#define OBJ_brainpoolP320r1             1L,3L,36L,3L,3L,2L,8L,1L,1L,9L\n\n#define SN_brainpoolP320t1              \"brainpoolP320t1\"\n#define NID_brainpoolP320t1             930\n#define OBJ_brainpoolP320t1             1L,3L,36L,3L,3L,2L,8L,1L,1L,10L\n\n#define SN_brainpoolP384r1              \"brainpoolP384r1\"\n#define NID_brainpoolP384r1             931\n#define OBJ_brainpoolP384r1             1L,3L,36L,3L,3L,2L,8L,1L,1L,11L\n\n#define SN_brainpoolP384t1              \"brainpoolP384t1\"\n#define NID_brainpoolP384t1             932\n#define OBJ_brainpoolP384t1             1L,3L,36L,3L,3L,2L,8L,1L,1L,12L\n\n#define SN_brainpoolP512r1              \"brainpoolP512r1\"\n#define NID_brainpoolP512r1             933\n#define OBJ_brainpoolP512r1             1L,3L,36L,3L,3L,2L,8L,1L,1L,13L\n\n#define SN_brainpoolP512t1              \"brainpoolP512t1\"\n#define NID_brainpoolP512t1             934\n#define OBJ_brainpoolP512t1             1L,3L,36L,3L,3L,2L,8L,1L,1L,14L\n\n#define OBJ_x9_63_scheme                1L,3L,133L,16L,840L,63L,0L\n\n#define OBJ_secg_scheme         OBJ_certicom_arc,1L\n\n#define SN_dhSinglePass_stdDH_sha1kdf_scheme            \"dhSinglePass-stdDH-sha1kdf-scheme\"\n#define NID_dhSinglePass_stdDH_sha1kdf_scheme           936\n#define OBJ_dhSinglePass_stdDH_sha1kdf_scheme           OBJ_x9_63_scheme,2L\n\n#define SN_dhSinglePass_stdDH_sha224kdf_scheme          \"dhSinglePass-stdDH-sha224kdf-scheme\"\n#define NID_dhSinglePass_stdDH_sha224kdf_scheme         937\n#define OBJ_dhSinglePass_stdDH_sha224kdf_scheme         OBJ_secg_scheme,11L,0L\n\n#define SN_dhSinglePass_stdDH_sha256kdf_scheme          \"dhSinglePass-stdDH-sha256kdf-scheme\"\n#define NID_dhSinglePass_stdDH_sha256kdf_scheme         938\n#define OBJ_dhSinglePass_stdDH_sha256kdf_scheme         OBJ_secg_scheme,11L,1L\n\n#define SN_dhSinglePass_stdDH_sha384kdf_scheme          \"dhSinglePass-stdDH-sha384kdf-scheme\"\n#define NID_dhSinglePass_stdDH_sha384kdf_scheme         939\n#define OBJ_dhSinglePass_stdDH_sha384kdf_scheme         OBJ_secg_scheme,11L,2L\n\n#define SN_dhSinglePass_stdDH_sha512kdf_scheme          \"dhSinglePass-stdDH-sha512kdf-scheme\"\n#define NID_dhSinglePass_stdDH_sha512kdf_scheme         940\n#define OBJ_dhSinglePass_stdDH_sha512kdf_scheme         OBJ_secg_scheme,11L,3L\n\n#define SN_dhSinglePass_cofactorDH_sha1kdf_scheme               \"dhSinglePass-cofactorDH-sha1kdf-scheme\"\n#define NID_dhSinglePass_cofactorDH_sha1kdf_scheme              941\n#define OBJ_dhSinglePass_cofactorDH_sha1kdf_scheme              OBJ_x9_63_scheme,3L\n\n#define SN_dhSinglePass_cofactorDH_sha224kdf_scheme             \"dhSinglePass-cofactorDH-sha224kdf-scheme\"\n#define NID_dhSinglePass_cofactorDH_sha224kdf_scheme            942\n#define OBJ_dhSinglePass_cofactorDH_sha224kdf_scheme            OBJ_secg_scheme,14L,0L\n\n#define SN_dhSinglePass_cofactorDH_sha256kdf_scheme             \"dhSinglePass-cofactorDH-sha256kdf-scheme\"\n#define NID_dhSinglePass_cofactorDH_sha256kdf_scheme            943\n#define OBJ_dhSinglePass_cofactorDH_sha256kdf_scheme            OBJ_secg_scheme,14L,1L\n\n#define SN_dhSinglePass_cofactorDH_sha384kdf_scheme             \"dhSinglePass-cofactorDH-sha384kdf-scheme\"\n#define NID_dhSinglePass_cofactorDH_sha384kdf_scheme            944\n#define OBJ_dhSinglePass_cofactorDH_sha384kdf_scheme            OBJ_secg_scheme,14L,2L\n\n#define SN_dhSinglePass_cofactorDH_sha512kdf_scheme             \"dhSinglePass-cofactorDH-sha512kdf-scheme\"\n#define NID_dhSinglePass_cofactorDH_sha512kdf_scheme            945\n#define OBJ_dhSinglePass_cofactorDH_sha512kdf_scheme            OBJ_secg_scheme,14L,3L\n\n#define SN_dh_std_kdf           \"dh-std-kdf\"\n#define NID_dh_std_kdf          946\n\n#define SN_dh_cofactor_kdf              \"dh-cofactor-kdf\"\n#define NID_dh_cofactor_kdf             947\n\n#define SN_ct_precert_scts              \"ct_precert_scts\"\n#define LN_ct_precert_scts              \"CT Precertificate SCTs\"\n#define NID_ct_precert_scts             951\n#define OBJ_ct_precert_scts             1L,3L,6L,1L,4L,1L,11129L,2L,4L,2L\n\n#define SN_ct_precert_poison            \"ct_precert_poison\"\n#define LN_ct_precert_poison            \"CT Precertificate Poison\"\n#define NID_ct_precert_poison           952\n#define OBJ_ct_precert_poison           1L,3L,6L,1L,4L,1L,11129L,2L,4L,3L\n\n#define SN_ct_precert_signer            \"ct_precert_signer\"\n#define LN_ct_precert_signer            \"CT Precertificate Signer\"\n#define NID_ct_precert_signer           953\n#define OBJ_ct_precert_signer           1L,3L,6L,1L,4L,1L,11129L,2L,4L,4L\n\n#define SN_ct_cert_scts         \"ct_cert_scts\"\n#define LN_ct_cert_scts         \"CT Certificate SCTs\"\n#define NID_ct_cert_scts                954\n#define OBJ_ct_cert_scts                1L,3L,6L,1L,4L,1L,11129L,2L,4L,5L\n\n#define SN_jurisdictionLocalityName             \"jurisdictionL\"\n#define LN_jurisdictionLocalityName             \"jurisdictionLocalityName\"\n#define NID_jurisdictionLocalityName            955\n#define OBJ_jurisdictionLocalityName            1L,3L,6L,1L,4L,1L,311L,60L,2L,1L,1L\n\n#define SN_jurisdictionStateOrProvinceName              \"jurisdictionST\"\n#define LN_jurisdictionStateOrProvinceName              \"jurisdictionStateOrProvinceName\"\n#define NID_jurisdictionStateOrProvinceName             956\n#define OBJ_jurisdictionStateOrProvinceName             1L,3L,6L,1L,4L,1L,311L,60L,2L,1L,2L\n\n#define SN_jurisdictionCountryName              \"jurisdictionC\"\n#define LN_jurisdictionCountryName              \"jurisdictionCountryName\"\n#define NID_jurisdictionCountryName             957\n#define OBJ_jurisdictionCountryName             1L,3L,6L,1L,4L,1L,311L,60L,2L,1L,3L\n\n#define SN_id_scrypt            \"id-scrypt\"\n#define LN_id_scrypt            \"scrypt\"\n#define NID_id_scrypt           973\n#define OBJ_id_scrypt           1L,3L,6L,1L,4L,1L,11591L,4L,11L\n\n#define SN_tls1_prf             \"TLS1-PRF\"\n#define LN_tls1_prf             \"tls1-prf\"\n#define NID_tls1_prf            1021\n\n#define SN_hkdf         \"HKDF\"\n#define LN_hkdf         \"hkdf\"\n#define NID_hkdf                1036\n\n#define SN_id_pkinit            \"id-pkinit\"\n#define NID_id_pkinit           1031\n#define OBJ_id_pkinit           1L,3L,6L,1L,5L,2L,3L\n\n#define SN_pkInitClientAuth             \"pkInitClientAuth\"\n#define LN_pkInitClientAuth             \"PKINIT Client Auth\"\n#define NID_pkInitClientAuth            1032\n#define OBJ_pkInitClientAuth            OBJ_id_pkinit,4L\n\n#define SN_pkInitKDC            \"pkInitKDC\"\n#define LN_pkInitKDC            \"Signing KDC Response\"\n#define NID_pkInitKDC           1033\n#define OBJ_pkInitKDC           OBJ_id_pkinit,5L\n\n#define SN_X25519               \"X25519\"\n#define NID_X25519              1034\n#define OBJ_X25519              1L,3L,101L,110L\n\n#define SN_X448         \"X448\"\n#define NID_X448                1035\n#define OBJ_X448                1L,3L,101L,111L\n\n#define SN_ED25519              \"ED25519\"\n#define NID_ED25519             1087\n#define OBJ_ED25519             1L,3L,101L,112L\n\n#define SN_ED448                \"ED448\"\n#define NID_ED448               1088\n#define OBJ_ED448               1L,3L,101L,113L\n\n#define SN_kx_rsa               \"KxRSA\"\n#define LN_kx_rsa               \"kx-rsa\"\n#define NID_kx_rsa              1037\n\n#define SN_kx_ecdhe             \"KxECDHE\"\n#define LN_kx_ecdhe             \"kx-ecdhe\"\n#define NID_kx_ecdhe            1038\n\n#define SN_kx_dhe               \"KxDHE\"\n#define LN_kx_dhe               \"kx-dhe\"\n#define NID_kx_dhe              1039\n\n#define SN_kx_ecdhe_psk         \"KxECDHE-PSK\"\n#define LN_kx_ecdhe_psk         \"kx-ecdhe-psk\"\n#define NID_kx_ecdhe_psk                1040\n\n#define SN_kx_dhe_psk           \"KxDHE-PSK\"\n#define LN_kx_dhe_psk           \"kx-dhe-psk\"\n#define NID_kx_dhe_psk          1041\n\n#define SN_kx_rsa_psk           \"KxRSA_PSK\"\n#define LN_kx_rsa_psk           \"kx-rsa-psk\"\n#define NID_kx_rsa_psk          1042\n\n#define SN_kx_psk               \"KxPSK\"\n#define LN_kx_psk               \"kx-psk\"\n#define NID_kx_psk              1043\n\n#define SN_kx_srp               \"KxSRP\"\n#define LN_kx_srp               \"kx-srp\"\n#define NID_kx_srp              1044\n\n#define SN_kx_gost              \"KxGOST\"\n#define LN_kx_gost              \"kx-gost\"\n#define NID_kx_gost             1045\n\n#define SN_kx_any               \"KxANY\"\n#define LN_kx_any               \"kx-any\"\n#define NID_kx_any              1063\n\n#define SN_auth_rsa             \"AuthRSA\"\n#define LN_auth_rsa             \"auth-rsa\"\n#define NID_auth_rsa            1046\n\n#define SN_auth_ecdsa           \"AuthECDSA\"\n#define LN_auth_ecdsa           \"auth-ecdsa\"\n#define NID_auth_ecdsa          1047\n\n#define SN_auth_psk             \"AuthPSK\"\n#define LN_auth_psk             \"auth-psk\"\n#define NID_auth_psk            1048\n\n#define SN_auth_dss             \"AuthDSS\"\n#define LN_auth_dss             \"auth-dss\"\n#define NID_auth_dss            1049\n\n#define SN_auth_gost01          \"AuthGOST01\"\n#define LN_auth_gost01          \"auth-gost01\"\n#define NID_auth_gost01         1050\n\n#define SN_auth_gost12          \"AuthGOST12\"\n#define LN_auth_gost12          \"auth-gost12\"\n#define NID_auth_gost12         1051\n\n#define SN_auth_srp             \"AuthSRP\"\n#define LN_auth_srp             \"auth-srp\"\n#define NID_auth_srp            1052\n\n#define SN_auth_null            \"AuthNULL\"\n#define LN_auth_null            \"auth-null\"\n#define NID_auth_null           1053\n\n#define SN_auth_any             \"AuthANY\"\n#define LN_auth_any             \"auth-any\"\n#define NID_auth_any            1064\n\n#define SN_poly1305             \"Poly1305\"\n#define LN_poly1305             \"poly1305\"\n#define NID_poly1305            1061\n\n#define SN_siphash              \"SipHash\"\n#define LN_siphash              \"siphash\"\n#define NID_siphash             1062\n\n#define SN_ffdhe2048            \"ffdhe2048\"\n#define NID_ffdhe2048           1126\n\n#define SN_ffdhe3072            \"ffdhe3072\"\n#define NID_ffdhe3072           1127\n\n#define SN_ffdhe4096            \"ffdhe4096\"\n#define NID_ffdhe4096           1128\n\n#define SN_ffdhe6144            \"ffdhe6144\"\n#define NID_ffdhe6144           1129\n\n#define SN_ffdhe8192            \"ffdhe8192\"\n#define NID_ffdhe8192           1130\n\n#define SN_ISO_UA               \"ISO-UA\"\n#define NID_ISO_UA              1150\n#define OBJ_ISO_UA              OBJ_member_body,804L\n\n#define SN_ua_pki               \"ua-pki\"\n#define NID_ua_pki              1151\n#define OBJ_ua_pki              OBJ_ISO_UA,2L,1L,1L,1L\n\n#define SN_dstu28147            \"dstu28147\"\n#define LN_dstu28147            \"DSTU Gost 28147-2009\"\n#define NID_dstu28147           1152\n#define OBJ_dstu28147           OBJ_ua_pki,1L,1L,1L\n\n#define SN_dstu28147_ofb                \"dstu28147-ofb\"\n#define LN_dstu28147_ofb                \"DSTU Gost 28147-2009 OFB mode\"\n#define NID_dstu28147_ofb               1153\n#define OBJ_dstu28147_ofb               OBJ_dstu28147,2L\n\n#define SN_dstu28147_cfb                \"dstu28147-cfb\"\n#define LN_dstu28147_cfb                \"DSTU Gost 28147-2009 CFB mode\"\n#define NID_dstu28147_cfb               1154\n#define OBJ_dstu28147_cfb               OBJ_dstu28147,3L\n\n#define SN_dstu28147_wrap               \"dstu28147-wrap\"\n#define LN_dstu28147_wrap               \"DSTU Gost 28147-2009 key wrap\"\n#define NID_dstu28147_wrap              1155\n#define OBJ_dstu28147_wrap              OBJ_dstu28147,5L\n\n#define SN_hmacWithDstu34311            \"hmacWithDstu34311\"\n#define LN_hmacWithDstu34311            \"HMAC DSTU Gost 34311-95\"\n#define NID_hmacWithDstu34311           1156\n#define OBJ_hmacWithDstu34311           OBJ_ua_pki,1L,1L,2L\n\n#define SN_dstu34311            \"dstu34311\"\n#define LN_dstu34311            \"DSTU Gost 34311-95\"\n#define NID_dstu34311           1157\n#define OBJ_dstu34311           OBJ_ua_pki,1L,2L,1L\n\n#define SN_dstu4145le           \"dstu4145le\"\n#define LN_dstu4145le           \"DSTU 4145-2002 little endian\"\n#define NID_dstu4145le          1158\n#define OBJ_dstu4145le          OBJ_ua_pki,1L,3L,1L,1L\n\n#define SN_dstu4145be           \"dstu4145be\"\n#define LN_dstu4145be           \"DSTU 4145-2002 big endian\"\n#define NID_dstu4145be          1159\n#define OBJ_dstu4145be          OBJ_dstu4145le,1L,1L\n\n#define SN_uacurve0             \"uacurve0\"\n#define LN_uacurve0             \"DSTU curve 0\"\n#define NID_uacurve0            1160\n#define OBJ_uacurve0            OBJ_dstu4145le,2L,0L\n\n#define SN_uacurve1             \"uacurve1\"\n#define LN_uacurve1             \"DSTU curve 1\"\n#define NID_uacurve1            1161\n#define OBJ_uacurve1            OBJ_dstu4145le,2L,1L\n\n#define SN_uacurve2             \"uacurve2\"\n#define LN_uacurve2             \"DSTU curve 2\"\n#define NID_uacurve2            1162\n#define OBJ_uacurve2            OBJ_dstu4145le,2L,2L\n\n#define SN_uacurve3             \"uacurve3\"\n#define LN_uacurve3             \"DSTU curve 3\"\n#define NID_uacurve3            1163\n#define OBJ_uacurve3            OBJ_dstu4145le,2L,3L\n\n#define SN_uacurve4             \"uacurve4\"\n#define LN_uacurve4             \"DSTU curve 4\"\n#define NID_uacurve4            1164\n#define OBJ_uacurve4            OBJ_dstu4145le,2L,4L\n\n#define SN_uacurve5             \"uacurve5\"\n#define LN_uacurve5             \"DSTU curve 5\"\n#define NID_uacurve5            1165\n#define OBJ_uacurve5            OBJ_dstu4145le,2L,5L\n\n#define SN_uacurve6             \"uacurve6\"\n#define LN_uacurve6             \"DSTU curve 6\"\n#define NID_uacurve6            1166\n#define OBJ_uacurve6            OBJ_dstu4145le,2L,6L\n\n#define SN_uacurve7             \"uacurve7\"\n#define LN_uacurve7             \"DSTU curve 7\"\n#define NID_uacurve7            1167\n#define OBJ_uacurve7            OBJ_dstu4145le,2L,7L\n\n#define SN_uacurve8             \"uacurve8\"\n#define LN_uacurve8             \"DSTU curve 8\"\n#define NID_uacurve8            1168\n#define OBJ_uacurve8            OBJ_dstu4145le,2L,8L\n\n#define SN_uacurve9             \"uacurve9\"\n#define LN_uacurve9             \"DSTU curve 9\"\n#define NID_uacurve9            1169\n#define OBJ_uacurve9            OBJ_dstu4145le,2L,9L\n"
  },
  {
    "path": "tools/prebuild/openssl/include/openssl/objects.h",
    "content": "/*\n * Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef HEADER_OBJECTS_H\n# define HEADER_OBJECTS_H\n\n# include <openssl/obj_mac.h>\n# include <openssl/bio.h>\n# include <openssl/asn1.h>\n# include <openssl/objectserr.h>\n\n# define OBJ_NAME_TYPE_UNDEF             0x00\n# define OBJ_NAME_TYPE_MD_METH           0x01\n# define OBJ_NAME_TYPE_CIPHER_METH       0x02\n# define OBJ_NAME_TYPE_PKEY_METH         0x03\n# define OBJ_NAME_TYPE_COMP_METH         0x04\n# define OBJ_NAME_TYPE_NUM               0x05\n\n# define OBJ_NAME_ALIAS                  0x8000\n\n# define OBJ_BSEARCH_VALUE_ON_NOMATCH            0x01\n# define OBJ_BSEARCH_FIRST_VALUE_ON_MATCH        0x02\n\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\ntypedef struct obj_name_st {\n    int type;\n    int alias;\n    const char *name;\n    const char *data;\n} OBJ_NAME;\n\n# define         OBJ_create_and_add_object(a,b,c) OBJ_create(a,b,c)\n\nint OBJ_NAME_init(void);\nint OBJ_NAME_new_index(unsigned long (*hash_func) (const char *),\n                       int (*cmp_func) (const char *, const char *),\n                       void (*free_func) (const char *, int, const char *));\nconst char *OBJ_NAME_get(const char *name, int type);\nint OBJ_NAME_add(const char *name, int type, const char *data);\nint OBJ_NAME_remove(const char *name, int type);\nvoid OBJ_NAME_cleanup(int type); /* -1 for everything */\nvoid OBJ_NAME_do_all(int type, void (*fn) (const OBJ_NAME *, void *arg),\n                     void *arg);\nvoid OBJ_NAME_do_all_sorted(int type,\n                            void (*fn) (const OBJ_NAME *, void *arg),\n                            void *arg);\n\nASN1_OBJECT *OBJ_dup(const ASN1_OBJECT *o);\nASN1_OBJECT *OBJ_nid2obj(int n);\nconst char *OBJ_nid2ln(int n);\nconst char *OBJ_nid2sn(int n);\nint OBJ_obj2nid(const ASN1_OBJECT *o);\nASN1_OBJECT *OBJ_txt2obj(const char *s, int no_name);\nint OBJ_obj2txt(char *buf, int buf_len, const ASN1_OBJECT *a, int no_name);\nint OBJ_txt2nid(const char *s);\nint OBJ_ln2nid(const char *s);\nint OBJ_sn2nid(const char *s);\nint OBJ_cmp(const ASN1_OBJECT *a, const ASN1_OBJECT *b);\nconst void *OBJ_bsearch_(const void *key, const void *base, int num, int size,\n                         int (*cmp) (const void *, const void *));\nconst void *OBJ_bsearch_ex_(const void *key, const void *base, int num,\n                            int size,\n                            int (*cmp) (const void *, const void *),\n                            int flags);\n\n# define _DECLARE_OBJ_BSEARCH_CMP_FN(scope, type1, type2, nm)    \\\n  static int nm##_cmp_BSEARCH_CMP_FN(const void *, const void *); \\\n  static int nm##_cmp(type1 const *, type2 const *); \\\n  scope type2 * OBJ_bsearch_##nm(type1 *key, type2 const *base, int num)\n\n# define DECLARE_OBJ_BSEARCH_CMP_FN(type1, type2, cmp)   \\\n  _DECLARE_OBJ_BSEARCH_CMP_FN(static, type1, type2, cmp)\n# define DECLARE_OBJ_BSEARCH_GLOBAL_CMP_FN(type1, type2, nm)     \\\n  type2 * OBJ_bsearch_##nm(type1 *key, type2 const *base, int num)\n\n/*-\n * Unsolved problem: if a type is actually a pointer type, like\n * nid_triple is, then its impossible to get a const where you need\n * it. Consider:\n *\n * typedef int nid_triple[3];\n * const void *a_;\n * const nid_triple const *a = a_;\n *\n * The assignment discards a const because what you really want is:\n *\n * const int const * const *a = a_;\n *\n * But if you do that, you lose the fact that a is an array of 3 ints,\n * which breaks comparison functions.\n *\n * Thus we end up having to cast, sadly, or unpack the\n * declarations. Or, as I finally did in this case, declare nid_triple\n * to be a struct, which it should have been in the first place.\n *\n * Ben, August 2008.\n *\n * Also, strictly speaking not all types need be const, but handling\n * the non-constness means a lot of complication, and in practice\n * comparison routines do always not touch their arguments.\n */\n\n# define IMPLEMENT_OBJ_BSEARCH_CMP_FN(type1, type2, nm)  \\\n  static int nm##_cmp_BSEARCH_CMP_FN(const void *a_, const void *b_)    \\\n      { \\\n      type1 const *a = a_; \\\n      type2 const *b = b_; \\\n      return nm##_cmp(a,b); \\\n      } \\\n  static type2 *OBJ_bsearch_##nm(type1 *key, type2 const *base, int num) \\\n      { \\\n      return (type2 *)OBJ_bsearch_(key, base, num, sizeof(type2), \\\n                                        nm##_cmp_BSEARCH_CMP_FN); \\\n      } \\\n      extern void dummy_prototype(void)\n\n# define IMPLEMENT_OBJ_BSEARCH_GLOBAL_CMP_FN(type1, type2, nm)   \\\n  static int nm##_cmp_BSEARCH_CMP_FN(const void *a_, const void *b_)    \\\n      { \\\n      type1 const *a = a_; \\\n      type2 const *b = b_; \\\n      return nm##_cmp(a,b); \\\n      } \\\n  type2 *OBJ_bsearch_##nm(type1 *key, type2 const *base, int num) \\\n      { \\\n      return (type2 *)OBJ_bsearch_(key, base, num, sizeof(type2), \\\n                                        nm##_cmp_BSEARCH_CMP_FN); \\\n      } \\\n      extern void dummy_prototype(void)\n\n# define OBJ_bsearch(type1,key,type2,base,num,cmp)                              \\\n  ((type2 *)OBJ_bsearch_(CHECKED_PTR_OF(type1,key),CHECKED_PTR_OF(type2,base), \\\n                         num,sizeof(type2),                             \\\n                         ((void)CHECKED_PTR_OF(type1,cmp##_type_1),     \\\n                          (void)CHECKED_PTR_OF(type2,cmp##_type_2),     \\\n                          cmp##_BSEARCH_CMP_FN)))\n\n# define OBJ_bsearch_ex(type1,key,type2,base,num,cmp,flags)                      \\\n  ((type2 *)OBJ_bsearch_ex_(CHECKED_PTR_OF(type1,key),CHECKED_PTR_OF(type2,base), \\\n                         num,sizeof(type2),                             \\\n                         ((void)CHECKED_PTR_OF(type1,cmp##_type_1),     \\\n                          (void)type_2=CHECKED_PTR_OF(type2,cmp##_type_2), \\\n                          cmp##_BSEARCH_CMP_FN)),flags)\n\nint OBJ_new_nid(int num);\nint OBJ_add_object(const ASN1_OBJECT *obj);\nint OBJ_create(const char *oid, const char *sn, const char *ln);\n#if OPENSSL_API_COMPAT < 0x10100000L\n# define OBJ_cleanup() while(0) continue\n#endif\nint OBJ_create_objects(BIO *in);\n\nsize_t OBJ_length(const ASN1_OBJECT *obj);\nconst unsigned char *OBJ_get0_data(const ASN1_OBJECT *obj);\n\nint OBJ_find_sigid_algs(int signid, int *pdig_nid, int *ppkey_nid);\nint OBJ_find_sigid_by_algs(int *psignid, int dig_nid, int pkey_nid);\nint OBJ_add_sigid(int signid, int dig_id, int pkey_id);\nvoid OBJ_sigid_free(void);\n\n\n# ifdef  __cplusplus\n}\n# endif\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/include/openssl/objectserr.h",
    "content": "/*\n * Generated by util/mkerr.pl DO NOT EDIT\n * Copyright 1995-2019 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef HEADER_OBJERR_H\n# define HEADER_OBJERR_H\n\n# ifndef HEADER_SYMHACKS_H\n#  include <openssl/symhacks.h>\n# endif\n\n# ifdef  __cplusplus\nextern \"C\"\n# endif\nint ERR_load_OBJ_strings(void);\n\n/*\n * OBJ function codes.\n */\n# define OBJ_F_OBJ_ADD_OBJECT                             105\n# define OBJ_F_OBJ_ADD_SIGID                              107\n# define OBJ_F_OBJ_CREATE                                 100\n# define OBJ_F_OBJ_DUP                                    101\n# define OBJ_F_OBJ_NAME_NEW_INDEX                         106\n# define OBJ_F_OBJ_NID2LN                                 102\n# define OBJ_F_OBJ_NID2OBJ                                103\n# define OBJ_F_OBJ_NID2SN                                 104\n# define OBJ_F_OBJ_TXT2OBJ                                108\n\n/*\n * OBJ reason codes.\n */\n# define OBJ_R_OID_EXISTS                                 102\n# define OBJ_R_UNKNOWN_NID                                101\n\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/include/openssl/ocsp.h",
    "content": "/*\n * Copyright 2000-2019 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef HEADER_OCSP_H\n# define HEADER_OCSP_H\n\n#include <openssl/opensslconf.h>\n\n/*\n * These definitions are outside the OPENSSL_NO_OCSP guard because although for\n * historical reasons they have OCSP_* names, they can actually be used\n * independently of OCSP. E.g. see RFC5280\n */\n/*-\n *   CRLReason ::= ENUMERATED {\n *        unspecified             (0),\n *        keyCompromise           (1),\n *        cACompromise            (2),\n *        affiliationChanged      (3),\n *        superseded              (4),\n *        cessationOfOperation    (5),\n *        certificateHold         (6),\n *        removeFromCRL           (8) }\n */\n#  define OCSP_REVOKED_STATUS_NOSTATUS               -1\n#  define OCSP_REVOKED_STATUS_UNSPECIFIED             0\n#  define OCSP_REVOKED_STATUS_KEYCOMPROMISE           1\n#  define OCSP_REVOKED_STATUS_CACOMPROMISE            2\n#  define OCSP_REVOKED_STATUS_AFFILIATIONCHANGED      3\n#  define OCSP_REVOKED_STATUS_SUPERSEDED              4\n#  define OCSP_REVOKED_STATUS_CESSATIONOFOPERATION    5\n#  define OCSP_REVOKED_STATUS_CERTIFICATEHOLD         6\n#  define OCSP_REVOKED_STATUS_REMOVEFROMCRL           8\n\n\n# ifndef OPENSSL_NO_OCSP\n\n#  include <openssl/ossl_typ.h>\n#  include <openssl/x509.h>\n#  include <openssl/x509v3.h>\n#  include <openssl/safestack.h>\n#  include <openssl/ocsperr.h>\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n/* Various flags and values */\n\n#  define OCSP_DEFAULT_NONCE_LENGTH       16\n\n#  define OCSP_NOCERTS                    0x1\n#  define OCSP_NOINTERN                   0x2\n#  define OCSP_NOSIGS                     0x4\n#  define OCSP_NOCHAIN                    0x8\n#  define OCSP_NOVERIFY                   0x10\n#  define OCSP_NOEXPLICIT                 0x20\n#  define OCSP_NOCASIGN                   0x40\n#  define OCSP_NODELEGATED                0x80\n#  define OCSP_NOCHECKS                   0x100\n#  define OCSP_TRUSTOTHER                 0x200\n#  define OCSP_RESPID_KEY                 0x400\n#  define OCSP_NOTIME                     0x800\n\ntypedef struct ocsp_cert_id_st OCSP_CERTID;\n\nDEFINE_STACK_OF(OCSP_CERTID)\n\ntypedef struct ocsp_one_request_st OCSP_ONEREQ;\n\nDEFINE_STACK_OF(OCSP_ONEREQ)\n\ntypedef struct ocsp_req_info_st OCSP_REQINFO;\ntypedef struct ocsp_signature_st OCSP_SIGNATURE;\ntypedef struct ocsp_request_st OCSP_REQUEST;\n\n#  define OCSP_RESPONSE_STATUS_SUCCESSFUL           0\n#  define OCSP_RESPONSE_STATUS_MALFORMEDREQUEST     1\n#  define OCSP_RESPONSE_STATUS_INTERNALERROR        2\n#  define OCSP_RESPONSE_STATUS_TRYLATER             3\n#  define OCSP_RESPONSE_STATUS_SIGREQUIRED          5\n#  define OCSP_RESPONSE_STATUS_UNAUTHORIZED         6\n\ntypedef struct ocsp_resp_bytes_st OCSP_RESPBYTES;\n\n#  define V_OCSP_RESPID_NAME 0\n#  define V_OCSP_RESPID_KEY  1\n\nDEFINE_STACK_OF(OCSP_RESPID)\n\ntypedef struct ocsp_revoked_info_st OCSP_REVOKEDINFO;\n\n#  define V_OCSP_CERTSTATUS_GOOD    0\n#  define V_OCSP_CERTSTATUS_REVOKED 1\n#  define V_OCSP_CERTSTATUS_UNKNOWN 2\n\ntypedef struct ocsp_cert_status_st OCSP_CERTSTATUS;\ntypedef struct ocsp_single_response_st OCSP_SINGLERESP;\n\nDEFINE_STACK_OF(OCSP_SINGLERESP)\n\ntypedef struct ocsp_response_data_st OCSP_RESPDATA;\n\ntypedef struct ocsp_basic_response_st OCSP_BASICRESP;\n\ntypedef struct ocsp_crl_id_st OCSP_CRLID;\ntypedef struct ocsp_service_locator_st OCSP_SERVICELOC;\n\n#  define PEM_STRING_OCSP_REQUEST \"OCSP REQUEST\"\n#  define PEM_STRING_OCSP_RESPONSE \"OCSP RESPONSE\"\n\n#  define d2i_OCSP_REQUEST_bio(bp,p) ASN1_d2i_bio_of(OCSP_REQUEST,OCSP_REQUEST_new,d2i_OCSP_REQUEST,bp,p)\n\n#  define d2i_OCSP_RESPONSE_bio(bp,p) ASN1_d2i_bio_of(OCSP_RESPONSE,OCSP_RESPONSE_new,d2i_OCSP_RESPONSE,bp,p)\n\n#  define PEM_read_bio_OCSP_REQUEST(bp,x,cb) (OCSP_REQUEST *)PEM_ASN1_read_bio( \\\n     (char *(*)())d2i_OCSP_REQUEST,PEM_STRING_OCSP_REQUEST, \\\n     bp,(char **)(x),cb,NULL)\n\n#  define PEM_read_bio_OCSP_RESPONSE(bp,x,cb) (OCSP_RESPONSE *)PEM_ASN1_read_bio(\\\n     (char *(*)())d2i_OCSP_RESPONSE,PEM_STRING_OCSP_RESPONSE, \\\n     bp,(char **)(x),cb,NULL)\n\n#  define PEM_write_bio_OCSP_REQUEST(bp,o) \\\n    PEM_ASN1_write_bio((int (*)())i2d_OCSP_REQUEST,PEM_STRING_OCSP_REQUEST,\\\n                        bp,(char *)(o), NULL,NULL,0,NULL,NULL)\n\n#  define PEM_write_bio_OCSP_RESPONSE(bp,o) \\\n    PEM_ASN1_write_bio((int (*)())i2d_OCSP_RESPONSE,PEM_STRING_OCSP_RESPONSE,\\\n                        bp,(char *)(o), NULL,NULL,0,NULL,NULL)\n\n#  define i2d_OCSP_RESPONSE_bio(bp,o) ASN1_i2d_bio_of(OCSP_RESPONSE,i2d_OCSP_RESPONSE,bp,o)\n\n#  define i2d_OCSP_REQUEST_bio(bp,o) ASN1_i2d_bio_of(OCSP_REQUEST,i2d_OCSP_REQUEST,bp,o)\n\n#  define ASN1_BIT_STRING_digest(data,type,md,len) \\\n        ASN1_item_digest(ASN1_ITEM_rptr(ASN1_BIT_STRING),type,data,md,len)\n\n#  define OCSP_CERTSTATUS_dup(cs)\\\n                (OCSP_CERTSTATUS*)ASN1_dup((int(*)())i2d_OCSP_CERTSTATUS,\\\n                (char *(*)())d2i_OCSP_CERTSTATUS,(char *)(cs))\n\nOCSP_CERTID *OCSP_CERTID_dup(OCSP_CERTID *id);\n\nOCSP_RESPONSE *OCSP_sendreq_bio(BIO *b, const char *path, OCSP_REQUEST *req);\nOCSP_REQ_CTX *OCSP_sendreq_new(BIO *io, const char *path, OCSP_REQUEST *req,\n                               int maxline);\nint OCSP_REQ_CTX_nbio(OCSP_REQ_CTX *rctx);\nint OCSP_sendreq_nbio(OCSP_RESPONSE **presp, OCSP_REQ_CTX *rctx);\nOCSP_REQ_CTX *OCSP_REQ_CTX_new(BIO *io, int maxline);\nvoid OCSP_REQ_CTX_free(OCSP_REQ_CTX *rctx);\nvoid OCSP_set_max_response_length(OCSP_REQ_CTX *rctx, unsigned long len);\nint OCSP_REQ_CTX_i2d(OCSP_REQ_CTX *rctx, const ASN1_ITEM *it,\n                     ASN1_VALUE *val);\nint OCSP_REQ_CTX_nbio_d2i(OCSP_REQ_CTX *rctx, ASN1_VALUE **pval,\n                          const ASN1_ITEM *it);\nBIO *OCSP_REQ_CTX_get0_mem_bio(OCSP_REQ_CTX *rctx);\nint OCSP_REQ_CTX_http(OCSP_REQ_CTX *rctx, const char *op, const char *path);\nint OCSP_REQ_CTX_set1_req(OCSP_REQ_CTX *rctx, OCSP_REQUEST *req);\nint OCSP_REQ_CTX_add1_header(OCSP_REQ_CTX *rctx,\n                             const char *name, const char *value);\n\nOCSP_CERTID *OCSP_cert_to_id(const EVP_MD *dgst, const X509 *subject,\n                             const X509 *issuer);\n\nOCSP_CERTID *OCSP_cert_id_new(const EVP_MD *dgst,\n                              const X509_NAME *issuerName,\n                              const ASN1_BIT_STRING *issuerKey,\n                              const ASN1_INTEGER *serialNumber);\n\nOCSP_ONEREQ *OCSP_request_add0_id(OCSP_REQUEST *req, OCSP_CERTID *cid);\n\nint OCSP_request_add1_nonce(OCSP_REQUEST *req, unsigned char *val, int len);\nint OCSP_basic_add1_nonce(OCSP_BASICRESP *resp, unsigned char *val, int len);\nint OCSP_check_nonce(OCSP_REQUEST *req, OCSP_BASICRESP *bs);\nint OCSP_copy_nonce(OCSP_BASICRESP *resp, OCSP_REQUEST *req);\n\nint OCSP_request_set1_name(OCSP_REQUEST *req, X509_NAME *nm);\nint OCSP_request_add1_cert(OCSP_REQUEST *req, X509 *cert);\n\nint OCSP_request_sign(OCSP_REQUEST *req,\n                      X509 *signer,\n                      EVP_PKEY *key,\n                      const EVP_MD *dgst,\n                      STACK_OF(X509) *certs, unsigned long flags);\n\nint OCSP_response_status(OCSP_RESPONSE *resp);\nOCSP_BASICRESP *OCSP_response_get1_basic(OCSP_RESPONSE *resp);\n\nconst ASN1_OCTET_STRING *OCSP_resp_get0_signature(const OCSP_BASICRESP *bs);\nconst X509_ALGOR *OCSP_resp_get0_tbs_sigalg(const OCSP_BASICRESP *bs);\nconst OCSP_RESPDATA *OCSP_resp_get0_respdata(const OCSP_BASICRESP *bs);\nint OCSP_resp_get0_signer(OCSP_BASICRESP *bs, X509 **signer,\n                          STACK_OF(X509) *extra_certs);\n\nint OCSP_resp_count(OCSP_BASICRESP *bs);\nOCSP_SINGLERESP *OCSP_resp_get0(OCSP_BASICRESP *bs, int idx);\nconst ASN1_GENERALIZEDTIME *OCSP_resp_get0_produced_at(const OCSP_BASICRESP* bs);\nconst STACK_OF(X509) *OCSP_resp_get0_certs(const OCSP_BASICRESP *bs);\nint OCSP_resp_get0_id(const OCSP_BASICRESP *bs,\n                      const ASN1_OCTET_STRING **pid,\n                      const X509_NAME **pname);\nint OCSP_resp_get1_id(const OCSP_BASICRESP *bs,\n                      ASN1_OCTET_STRING **pid,\n                      X509_NAME **pname);\n\nint OCSP_resp_find(OCSP_BASICRESP *bs, OCSP_CERTID *id, int last);\nint OCSP_single_get0_status(OCSP_SINGLERESP *single, int *reason,\n                            ASN1_GENERALIZEDTIME **revtime,\n                            ASN1_GENERALIZEDTIME **thisupd,\n                            ASN1_GENERALIZEDTIME **nextupd);\nint OCSP_resp_find_status(OCSP_BASICRESP *bs, OCSP_CERTID *id, int *status,\n                          int *reason,\n                          ASN1_GENERALIZEDTIME **revtime,\n                          ASN1_GENERALIZEDTIME **thisupd,\n                          ASN1_GENERALIZEDTIME **nextupd);\nint OCSP_check_validity(ASN1_GENERALIZEDTIME *thisupd,\n                        ASN1_GENERALIZEDTIME *nextupd, long sec, long maxsec);\n\nint OCSP_request_verify(OCSP_REQUEST *req, STACK_OF(X509) *certs,\n                        X509_STORE *store, unsigned long flags);\n\nint OCSP_parse_url(const char *url, char **phost, char **pport, char **ppath,\n                   int *pssl);\n\nint OCSP_id_issuer_cmp(const OCSP_CERTID *a, const OCSP_CERTID *b);\nint OCSP_id_cmp(const OCSP_CERTID *a, const OCSP_CERTID *b);\n\nint OCSP_request_onereq_count(OCSP_REQUEST *req);\nOCSP_ONEREQ *OCSP_request_onereq_get0(OCSP_REQUEST *req, int i);\nOCSP_CERTID *OCSP_onereq_get0_id(OCSP_ONEREQ *one);\nint OCSP_id_get0_info(ASN1_OCTET_STRING **piNameHash, ASN1_OBJECT **pmd,\n                      ASN1_OCTET_STRING **pikeyHash,\n                      ASN1_INTEGER **pserial, OCSP_CERTID *cid);\nint OCSP_request_is_signed(OCSP_REQUEST *req);\nOCSP_RESPONSE *OCSP_response_create(int status, OCSP_BASICRESP *bs);\nOCSP_SINGLERESP *OCSP_basic_add1_status(OCSP_BASICRESP *rsp,\n                                        OCSP_CERTID *cid,\n                                        int status, int reason,\n                                        ASN1_TIME *revtime,\n                                        ASN1_TIME *thisupd,\n                                        ASN1_TIME *nextupd);\nint OCSP_basic_add1_cert(OCSP_BASICRESP *resp, X509 *cert);\nint OCSP_basic_sign(OCSP_BASICRESP *brsp,\n                    X509 *signer, EVP_PKEY *key, const EVP_MD *dgst,\n                    STACK_OF(X509) *certs, unsigned long flags);\nint OCSP_basic_sign_ctx(OCSP_BASICRESP *brsp,\n                        X509 *signer, EVP_MD_CTX *ctx,\n                        STACK_OF(X509) *certs, unsigned long flags);\nint OCSP_RESPID_set_by_name(OCSP_RESPID *respid, X509 *cert);\nint OCSP_RESPID_set_by_key(OCSP_RESPID *respid, X509 *cert);\nint OCSP_RESPID_match(OCSP_RESPID *respid, X509 *cert);\n\nX509_EXTENSION *OCSP_crlID_new(const char *url, long *n, char *tim);\n\nX509_EXTENSION *OCSP_accept_responses_new(char **oids);\n\nX509_EXTENSION *OCSP_archive_cutoff_new(char *tim);\n\nX509_EXTENSION *OCSP_url_svcloc_new(X509_NAME *issuer, const char **urls);\n\nint OCSP_REQUEST_get_ext_count(OCSP_REQUEST *x);\nint OCSP_REQUEST_get_ext_by_NID(OCSP_REQUEST *x, int nid, int lastpos);\nint OCSP_REQUEST_get_ext_by_OBJ(OCSP_REQUEST *x, const ASN1_OBJECT *obj,\n                                int lastpos);\nint OCSP_REQUEST_get_ext_by_critical(OCSP_REQUEST *x, int crit, int lastpos);\nX509_EXTENSION *OCSP_REQUEST_get_ext(OCSP_REQUEST *x, int loc);\nX509_EXTENSION *OCSP_REQUEST_delete_ext(OCSP_REQUEST *x, int loc);\nvoid *OCSP_REQUEST_get1_ext_d2i(OCSP_REQUEST *x, int nid, int *crit,\n                                int *idx);\nint OCSP_REQUEST_add1_ext_i2d(OCSP_REQUEST *x, int nid, void *value, int crit,\n                              unsigned long flags);\nint OCSP_REQUEST_add_ext(OCSP_REQUEST *x, X509_EXTENSION *ex, int loc);\n\nint OCSP_ONEREQ_get_ext_count(OCSP_ONEREQ *x);\nint OCSP_ONEREQ_get_ext_by_NID(OCSP_ONEREQ *x, int nid, int lastpos);\nint OCSP_ONEREQ_get_ext_by_OBJ(OCSP_ONEREQ *x, const ASN1_OBJECT *obj, int lastpos);\nint OCSP_ONEREQ_get_ext_by_critical(OCSP_ONEREQ *x, int crit, int lastpos);\nX509_EXTENSION *OCSP_ONEREQ_get_ext(OCSP_ONEREQ *x, int loc);\nX509_EXTENSION *OCSP_ONEREQ_delete_ext(OCSP_ONEREQ *x, int loc);\nvoid *OCSP_ONEREQ_get1_ext_d2i(OCSP_ONEREQ *x, int nid, int *crit, int *idx);\nint OCSP_ONEREQ_add1_ext_i2d(OCSP_ONEREQ *x, int nid, void *value, int crit,\n                             unsigned long flags);\nint OCSP_ONEREQ_add_ext(OCSP_ONEREQ *x, X509_EXTENSION *ex, int loc);\n\nint OCSP_BASICRESP_get_ext_count(OCSP_BASICRESP *x);\nint OCSP_BASICRESP_get_ext_by_NID(OCSP_BASICRESP *x, int nid, int lastpos);\nint OCSP_BASICRESP_get_ext_by_OBJ(OCSP_BASICRESP *x, const ASN1_OBJECT *obj,\n                                  int lastpos);\nint OCSP_BASICRESP_get_ext_by_critical(OCSP_BASICRESP *x, int crit,\n                                       int lastpos);\nX509_EXTENSION *OCSP_BASICRESP_get_ext(OCSP_BASICRESP *x, int loc);\nX509_EXTENSION *OCSP_BASICRESP_delete_ext(OCSP_BASICRESP *x, int loc);\nvoid *OCSP_BASICRESP_get1_ext_d2i(OCSP_BASICRESP *x, int nid, int *crit,\n                                  int *idx);\nint OCSP_BASICRESP_add1_ext_i2d(OCSP_BASICRESP *x, int nid, void *value,\n                                int crit, unsigned long flags);\nint OCSP_BASICRESP_add_ext(OCSP_BASICRESP *x, X509_EXTENSION *ex, int loc);\n\nint OCSP_SINGLERESP_get_ext_count(OCSP_SINGLERESP *x);\nint OCSP_SINGLERESP_get_ext_by_NID(OCSP_SINGLERESP *x, int nid, int lastpos);\nint OCSP_SINGLERESP_get_ext_by_OBJ(OCSP_SINGLERESP *x, const ASN1_OBJECT *obj,\n                                   int lastpos);\nint OCSP_SINGLERESP_get_ext_by_critical(OCSP_SINGLERESP *x, int crit,\n                                        int lastpos);\nX509_EXTENSION *OCSP_SINGLERESP_get_ext(OCSP_SINGLERESP *x, int loc);\nX509_EXTENSION *OCSP_SINGLERESP_delete_ext(OCSP_SINGLERESP *x, int loc);\nvoid *OCSP_SINGLERESP_get1_ext_d2i(OCSP_SINGLERESP *x, int nid, int *crit,\n                                   int *idx);\nint OCSP_SINGLERESP_add1_ext_i2d(OCSP_SINGLERESP *x, int nid, void *value,\n                                 int crit, unsigned long flags);\nint OCSP_SINGLERESP_add_ext(OCSP_SINGLERESP *x, X509_EXTENSION *ex, int loc);\nconst OCSP_CERTID *OCSP_SINGLERESP_get0_id(const OCSP_SINGLERESP *x);\n\nDECLARE_ASN1_FUNCTIONS(OCSP_SINGLERESP)\nDECLARE_ASN1_FUNCTIONS(OCSP_CERTSTATUS)\nDECLARE_ASN1_FUNCTIONS(OCSP_REVOKEDINFO)\nDECLARE_ASN1_FUNCTIONS(OCSP_BASICRESP)\nDECLARE_ASN1_FUNCTIONS(OCSP_RESPDATA)\nDECLARE_ASN1_FUNCTIONS(OCSP_RESPID)\nDECLARE_ASN1_FUNCTIONS(OCSP_RESPONSE)\nDECLARE_ASN1_FUNCTIONS(OCSP_RESPBYTES)\nDECLARE_ASN1_FUNCTIONS(OCSP_ONEREQ)\nDECLARE_ASN1_FUNCTIONS(OCSP_CERTID)\nDECLARE_ASN1_FUNCTIONS(OCSP_REQUEST)\nDECLARE_ASN1_FUNCTIONS(OCSP_SIGNATURE)\nDECLARE_ASN1_FUNCTIONS(OCSP_REQINFO)\nDECLARE_ASN1_FUNCTIONS(OCSP_CRLID)\nDECLARE_ASN1_FUNCTIONS(OCSP_SERVICELOC)\n\nconst char *OCSP_response_status_str(long s);\nconst char *OCSP_cert_status_str(long s);\nconst char *OCSP_crl_reason_str(long s);\n\nint OCSP_REQUEST_print(BIO *bp, OCSP_REQUEST *a, unsigned long flags);\nint OCSP_RESPONSE_print(BIO *bp, OCSP_RESPONSE *o, unsigned long flags);\n\nint OCSP_basic_verify(OCSP_BASICRESP *bs, STACK_OF(X509) *certs,\n                      X509_STORE *st, unsigned long flags);\n\n\n#  ifdef  __cplusplus\n}\n#  endif\n# endif\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/include/openssl/ocsperr.h",
    "content": "/*\n * Generated by util/mkerr.pl DO NOT EDIT\n * Copyright 1995-2019 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef HEADER_OCSPERR_H\n# define HEADER_OCSPERR_H\n\n# ifndef HEADER_SYMHACKS_H\n#  include <openssl/symhacks.h>\n# endif\n\n# include <openssl/opensslconf.h>\n\n# ifndef OPENSSL_NO_OCSP\n\n#  ifdef  __cplusplus\nextern \"C\"\n#  endif\nint ERR_load_OCSP_strings(void);\n\n/*\n * OCSP function codes.\n */\n#  define OCSP_F_D2I_OCSP_NONCE                            102\n#  define OCSP_F_OCSP_BASIC_ADD1_STATUS                    103\n#  define OCSP_F_OCSP_BASIC_SIGN                           104\n#  define OCSP_F_OCSP_BASIC_SIGN_CTX                       119\n#  define OCSP_F_OCSP_BASIC_VERIFY                         105\n#  define OCSP_F_OCSP_CERT_ID_NEW                          101\n#  define OCSP_F_OCSP_CHECK_DELEGATED                      106\n#  define OCSP_F_OCSP_CHECK_IDS                            107\n#  define OCSP_F_OCSP_CHECK_ISSUER                         108\n#  define OCSP_F_OCSP_CHECK_VALIDITY                       115\n#  define OCSP_F_OCSP_MATCH_ISSUERID                       109\n#  define OCSP_F_OCSP_PARSE_URL                            114\n#  define OCSP_F_OCSP_REQUEST_SIGN                         110\n#  define OCSP_F_OCSP_REQUEST_VERIFY                       116\n#  define OCSP_F_OCSP_RESPONSE_GET1_BASIC                  111\n#  define OCSP_F_PARSE_HTTP_LINE1                          118\n\n/*\n * OCSP reason codes.\n */\n#  define OCSP_R_CERTIFICATE_VERIFY_ERROR                  101\n#  define OCSP_R_DIGEST_ERR                                102\n#  define OCSP_R_ERROR_IN_NEXTUPDATE_FIELD                 122\n#  define OCSP_R_ERROR_IN_THISUPDATE_FIELD                 123\n#  define OCSP_R_ERROR_PARSING_URL                         121\n#  define OCSP_R_MISSING_OCSPSIGNING_USAGE                 103\n#  define OCSP_R_NEXTUPDATE_BEFORE_THISUPDATE              124\n#  define OCSP_R_NOT_BASIC_RESPONSE                        104\n#  define OCSP_R_NO_CERTIFICATES_IN_CHAIN                  105\n#  define OCSP_R_NO_RESPONSE_DATA                          108\n#  define OCSP_R_NO_REVOKED_TIME                           109\n#  define OCSP_R_NO_SIGNER_KEY                             130\n#  define OCSP_R_PRIVATE_KEY_DOES_NOT_MATCH_CERTIFICATE    110\n#  define OCSP_R_REQUEST_NOT_SIGNED                        128\n#  define OCSP_R_RESPONSE_CONTAINS_NO_REVOCATION_DATA      111\n#  define OCSP_R_ROOT_CA_NOT_TRUSTED                       112\n#  define OCSP_R_SERVER_RESPONSE_ERROR                     114\n#  define OCSP_R_SERVER_RESPONSE_PARSE_ERROR               115\n#  define OCSP_R_SIGNATURE_FAILURE                         117\n#  define OCSP_R_SIGNER_CERTIFICATE_NOT_FOUND              118\n#  define OCSP_R_STATUS_EXPIRED                            125\n#  define OCSP_R_STATUS_NOT_YET_VALID                      126\n#  define OCSP_R_STATUS_TOO_OLD                            127\n#  define OCSP_R_UNKNOWN_MESSAGE_DIGEST                    119\n#  define OCSP_R_UNKNOWN_NID                               120\n#  define OCSP_R_UNSUPPORTED_REQUESTORNAME_TYPE            129\n\n# endif\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/include/openssl/opensslconf-android.h",
    "content": "/*\n * Building OpenSSL for the different architectures of all iOS and tvOS devices requires different settings.\n * In order to be able to use assembly code on all devices, the choice was made to keep optimal settings for all\n * devices and use this intermediate header file to use the proper opensslconf.h file for each architecture.\n\n * See also https://github.com/x2on/OpenSSL-for-iPhone/issues/126 and referenced pull requests\n */\n\n\n#if defined(__arm__)\n#include <openssl/opensslconf_android-arm.h>\n#elif defined(__aarch64__)\n#include <openssl/opensslconf_android-arm64.h>\n#elif defined(__i386__)\n#include <openssl/opensslconf_android-x86_64.h>\n#elif defined(__x86_64__)\n#include <openssl/opensslconf_android64-x86_64.h>\n#else\n# error Unable to determine arch not included in OpenSSL build\n#endif \n"
  },
  {
    "path": "tools/prebuild/openssl/include/openssl/opensslconf-apple.h",
    "content": "/*\n * Building OpenSSL for the different architectures of all iOS and tvOS devices requires different settings.\n * In order to be able to use assembly code on all devices, the choice was made to keep optimal settings for all\n * devices and use this intermediate header file to use the proper opensslconf.h file for each architecture.\n\n * See also https://github.com/x2on/OpenSSL-for-iPhone/issues/126 and referenced pull requests\n */\n\n#include <TargetConditionals.h>\n\n#if TARGET_OS_IOS && TARGET_OS_IPHONE\n# include <openssl/opensslconf_ios_arm64.h>\n#elif TARGET_OS_IOS && TARGET_OS_SIMULATOR && TARGET_CPU_X86_64\n# include <openssl/opensslconf_ios_sim_x86_64.h>\n#elif TARGET_OS_WATCH && TARGET_OS_IPHONE && TARGET_CPU_ARM\n# include <openssl/opensslconf_watchos_armv7k.h>\n#elif TARGET_OS_WATCH && TARGET_OS_IPHONE && TARGET_CPU_ARM64\n# include <openssl/opensslconf_watchos_arm64_32.h>\n#elif TARGET_OS_WATCH && TARGET_OS_SIMULATOR && TARGET_CPU_X86\n# include <openssl/opensslconf_watchos_sim_i386.h>\n#elif TARGET_OS_OSX && TARGET_CPU_X86_64\n# include <openssl/opensslconf_macos_x86_64.h>\n#elif TARGET_OS_OSX && TARGET_CPU_ARM64\n# include <openssl/opensslconf_macos_arm64.h>\n#else\n# error Unable to determine target or target not included in OpenSSL build\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/include/openssl/opensslconf-windows.h",
    "content": "/*\n * Building OpenSSL for the different architectures of all iOS and tvOS devices requires different settings.\n * In order to be able to use assembly code on all devices, the choice was made to keep optimal settings for all\n * devices and use this intermediate header file to use the proper opensslconf.h file for each architecture.\n\n * See also https://github.com/x2on/OpenSSL-for-iPhone/issues/126 and referenced pull requests\n */\n\n// see https://docs.microsoft.com/en-us/cpp/preprocessor/predefined-macros?view=msvc-160\n#if defined(_WIN64)\n#include <openssl/opensslconf_windows-x86_64.h>\n#else\n#include <openssl/opensslconf_windows-x86.h>\n#endif"
  },
  {
    "path": "tools/prebuild/openssl/include/openssl/opensslconf.h",
    "content": "/*\n * Building OpenSSL for the different architectures of all iOS and tvOS devices requires different settings.\n * In order to be able to use assembly code on all devices, the choice was made to keep optimal settings for all\n * devices and use this intermediate header file to use the proper opensslconf.h file for each architecture.\n\n * See also https://github.com/x2on/OpenSSL-for-iPhone/issues/126 and referenced pull requests\n */\n\n#ifdef __APPLE__\n#include <openssl/opensslconf-apple.h>\n#elif defined(__ANDROID__)\n#include <openssl/opensslconf-android.h>\n#elif defined(_WIN32)\n#include <openssl/opensslconf-windows.h>\n#else\n#include <openssl/opensslconf_default.h>\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/include/openssl/opensslconf_android-arm.h",
    "content": "/*\n * WARNING: do not edit!\n * Generated by Makefile from include/openssl/opensslconf.h.in\n *\n * Copyright 2016-2020 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#include <openssl/opensslv.h>\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n#ifdef OPENSSL_ALGORITHM_DEFINES\n# error OPENSSL_ALGORITHM_DEFINES no longer supported\n#endif\n\n/*\n * OpenSSL was configured with the following options:\n */\n\n#ifndef OPENSSL_NO_MD2\n# define OPENSSL_NO_MD2\n#endif\n#ifndef OPENSSL_NO_RC5\n# define OPENSSL_NO_RC5\n#endif\n#ifndef OPENSSL_THREADS\n# define OPENSSL_THREADS\n#endif\n#ifndef OPENSSL_RAND_SEED_OS\n# define OPENSSL_RAND_SEED_OS\n#endif\n#ifndef OPENSSL_NO_AFALGENG\n# define OPENSSL_NO_AFALGENG\n#endif\n#ifndef OPENSSL_NO_ASAN\n# define OPENSSL_NO_ASAN\n#endif\n#ifndef OPENSSL_NO_CRYPTO_MDEBUG\n# define OPENSSL_NO_CRYPTO_MDEBUG\n#endif\n#ifndef OPENSSL_NO_CRYPTO_MDEBUG_BACKTRACE\n# define OPENSSL_NO_CRYPTO_MDEBUG_BACKTRACE\n#endif\n#ifndef OPENSSL_NO_DEVCRYPTOENG\n# define OPENSSL_NO_DEVCRYPTOENG\n#endif\n#ifndef OPENSSL_NO_EC_NISTP_64_GCC_128\n# define OPENSSL_NO_EC_NISTP_64_GCC_128\n#endif\n#ifndef OPENSSL_NO_EGD\n# define OPENSSL_NO_EGD\n#endif\n#ifndef OPENSSL_NO_EXTERNAL_TESTS\n# define OPENSSL_NO_EXTERNAL_TESTS\n#endif\n#ifndef OPENSSL_NO_FUZZ_AFL\n# define OPENSSL_NO_FUZZ_AFL\n#endif\n#ifndef OPENSSL_NO_FUZZ_LIBFUZZER\n# define OPENSSL_NO_FUZZ_LIBFUZZER\n#endif\n#ifndef OPENSSL_NO_HEARTBEATS\n# define OPENSSL_NO_HEARTBEATS\n#endif\n#ifndef OPENSSL_NO_MSAN\n# define OPENSSL_NO_MSAN\n#endif\n#ifndef OPENSSL_NO_SCTP\n# define OPENSSL_NO_SCTP\n#endif\n#ifndef OPENSSL_NO_SSL_TRACE\n# define OPENSSL_NO_SSL_TRACE\n#endif\n#ifndef OPENSSL_NO_SSL3\n# define OPENSSL_NO_SSL3\n#endif\n#ifndef OPENSSL_NO_SSL3_METHOD\n# define OPENSSL_NO_SSL3_METHOD\n#endif\n#ifndef OPENSSL_NO_TESTS\n# define OPENSSL_NO_TESTS\n#endif\n#ifndef OPENSSL_NO_UBSAN\n# define OPENSSL_NO_UBSAN\n#endif\n#ifndef OPENSSL_NO_UNIT_TEST\n# define OPENSSL_NO_UNIT_TEST\n#endif\n#ifndef OPENSSL_NO_WEAK_SSL_CIPHERS\n# define OPENSSL_NO_WEAK_SSL_CIPHERS\n#endif\n#ifndef OPENSSL_NO_DYNAMIC_ENGINE\n# define OPENSSL_NO_DYNAMIC_ENGINE\n#endif\n\n\n/*\n * Sometimes OPENSSSL_NO_xxx ends up with an empty file and some compilers\n * don't like that.  This will hopefully silence them.\n */\n#define NON_EMPTY_TRANSLATION_UNIT static void *dummy = &dummy;\n\n/*\n * Applications should use -DOPENSSL_API_COMPAT=<version> to suppress the\n * declarations of functions deprecated in or before <version>. Otherwise, they\n * still won't see them if the library has been built to disable deprecated\n * functions.\n */\n#ifndef DECLARE_DEPRECATED\n# define DECLARE_DEPRECATED(f)   f;\n# ifdef __GNUC__\n#  if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ > 0)\n#   undef DECLARE_DEPRECATED\n#   define DECLARE_DEPRECATED(f)    f __attribute__ ((deprecated));\n#  endif\n# elif defined(__SUNPRO_C)\n#  if (__SUNPRO_C >= 0x5130)\n#   undef DECLARE_DEPRECATED\n#   define DECLARE_DEPRECATED(f)    f __attribute__ ((deprecated));\n#  endif\n# endif\n#endif\n\n#ifndef OPENSSL_FILE\n# ifdef OPENSSL_NO_FILENAMES\n#  define OPENSSL_FILE \"\"\n#  define OPENSSL_LINE 0\n# else\n#  define OPENSSL_FILE __FILE__\n#  define OPENSSL_LINE __LINE__\n# endif\n#endif\n\n#ifndef OPENSSL_MIN_API\n# define OPENSSL_MIN_API 0\n#endif\n\n#if !defined(OPENSSL_API_COMPAT) || OPENSSL_API_COMPAT < OPENSSL_MIN_API\n# undef OPENSSL_API_COMPAT\n# define OPENSSL_API_COMPAT OPENSSL_MIN_API\n#endif\n\n/*\n * Do not deprecate things to be deprecated in version 1.2.0 before the\n * OpenSSL version number matches.\n */\n#if OPENSSL_VERSION_NUMBER < 0x10200000L\n# define DEPRECATEDIN_1_2_0(f)   f;\n#elif OPENSSL_API_COMPAT < 0x10200000L\n# define DEPRECATEDIN_1_2_0(f)   DECLARE_DEPRECATED(f)\n#else\n# define DEPRECATEDIN_1_2_0(f)\n#endif\n\n#if OPENSSL_API_COMPAT < 0x10100000L\n# define DEPRECATEDIN_1_1_0(f)   DECLARE_DEPRECATED(f)\n#else\n# define DEPRECATEDIN_1_1_0(f)\n#endif\n\n#if OPENSSL_API_COMPAT < 0x10000000L\n# define DEPRECATEDIN_1_0_0(f)   DECLARE_DEPRECATED(f)\n#else\n# define DEPRECATEDIN_1_0_0(f)\n#endif\n\n#if OPENSSL_API_COMPAT < 0x00908000L\n# define DEPRECATEDIN_0_9_8(f)   DECLARE_DEPRECATED(f)\n#else\n# define DEPRECATEDIN_0_9_8(f)\n#endif\n\n/* Generate 80386 code? */\n#undef I386_ONLY\n\n#undef OPENSSL_UNISTD\n#define OPENSSL_UNISTD <unistd.h>\n\n#undef OPENSSL_EXPORT_VAR_AS_FUNCTION\n\n/*\n * The following are cipher-specific, but are part of the public API.\n */\n#if !defined(OPENSSL_SYS_UEFI)\n# define BN_LLONG\n/* Only one for the following should be defined */\n# undef SIXTY_FOUR_BIT_LONG\n# undef SIXTY_FOUR_BIT\n# define THIRTY_TWO_BIT\n#endif\n\n#define RC4_INT unsigned char\n\n#ifdef  __cplusplus\n}\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/include/openssl/opensslconf_android-arm64.h",
    "content": "/*\n * WARNING: do not edit!\n * Generated by Makefile from include/openssl/opensslconf.h.in\n *\n * Copyright 2016-2020 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#include <openssl/opensslv.h>\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n#ifdef OPENSSL_ALGORITHM_DEFINES\n# error OPENSSL_ALGORITHM_DEFINES no longer supported\n#endif\n\n/*\n * OpenSSL was configured with the following options:\n */\n\n#ifndef OPENSSL_NO_MD2\n# define OPENSSL_NO_MD2\n#endif\n#ifndef OPENSSL_NO_RC5\n# define OPENSSL_NO_RC5\n#endif\n#ifndef OPENSSL_THREADS\n# define OPENSSL_THREADS\n#endif\n#ifndef OPENSSL_RAND_SEED_OS\n# define OPENSSL_RAND_SEED_OS\n#endif\n#ifndef OPENSSL_NO_AFALGENG\n# define OPENSSL_NO_AFALGENG\n#endif\n#ifndef OPENSSL_NO_ASAN\n# define OPENSSL_NO_ASAN\n#endif\n#ifndef OPENSSL_NO_CRYPTO_MDEBUG\n# define OPENSSL_NO_CRYPTO_MDEBUG\n#endif\n#ifndef OPENSSL_NO_CRYPTO_MDEBUG_BACKTRACE\n# define OPENSSL_NO_CRYPTO_MDEBUG_BACKTRACE\n#endif\n#ifndef OPENSSL_NO_DEVCRYPTOENG\n# define OPENSSL_NO_DEVCRYPTOENG\n#endif\n#ifndef OPENSSL_NO_EC_NISTP_64_GCC_128\n# define OPENSSL_NO_EC_NISTP_64_GCC_128\n#endif\n#ifndef OPENSSL_NO_EGD\n# define OPENSSL_NO_EGD\n#endif\n#ifndef OPENSSL_NO_EXTERNAL_TESTS\n# define OPENSSL_NO_EXTERNAL_TESTS\n#endif\n#ifndef OPENSSL_NO_FUZZ_AFL\n# define OPENSSL_NO_FUZZ_AFL\n#endif\n#ifndef OPENSSL_NO_FUZZ_LIBFUZZER\n# define OPENSSL_NO_FUZZ_LIBFUZZER\n#endif\n#ifndef OPENSSL_NO_HEARTBEATS\n# define OPENSSL_NO_HEARTBEATS\n#endif\n#ifndef OPENSSL_NO_MSAN\n# define OPENSSL_NO_MSAN\n#endif\n#ifndef OPENSSL_NO_SCTP\n# define OPENSSL_NO_SCTP\n#endif\n#ifndef OPENSSL_NO_SSL_TRACE\n# define OPENSSL_NO_SSL_TRACE\n#endif\n#ifndef OPENSSL_NO_SSL3\n# define OPENSSL_NO_SSL3\n#endif\n#ifndef OPENSSL_NO_SSL3_METHOD\n# define OPENSSL_NO_SSL3_METHOD\n#endif\n#ifndef OPENSSL_NO_TESTS\n# define OPENSSL_NO_TESTS\n#endif\n#ifndef OPENSSL_NO_UBSAN\n# define OPENSSL_NO_UBSAN\n#endif\n#ifndef OPENSSL_NO_UNIT_TEST\n# define OPENSSL_NO_UNIT_TEST\n#endif\n#ifndef OPENSSL_NO_WEAK_SSL_CIPHERS\n# define OPENSSL_NO_WEAK_SSL_CIPHERS\n#endif\n#ifndef OPENSSL_NO_DYNAMIC_ENGINE\n# define OPENSSL_NO_DYNAMIC_ENGINE\n#endif\n\n\n/*\n * Sometimes OPENSSSL_NO_xxx ends up with an empty file and some compilers\n * don't like that.  This will hopefully silence them.\n */\n#define NON_EMPTY_TRANSLATION_UNIT static void *dummy = &dummy;\n\n/*\n * Applications should use -DOPENSSL_API_COMPAT=<version> to suppress the\n * declarations of functions deprecated in or before <version>. Otherwise, they\n * still won't see them if the library has been built to disable deprecated\n * functions.\n */\n#ifndef DECLARE_DEPRECATED\n# define DECLARE_DEPRECATED(f)   f;\n# ifdef __GNUC__\n#  if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ > 0)\n#   undef DECLARE_DEPRECATED\n#   define DECLARE_DEPRECATED(f)    f __attribute__ ((deprecated));\n#  endif\n# elif defined(__SUNPRO_C)\n#  if (__SUNPRO_C >= 0x5130)\n#   undef DECLARE_DEPRECATED\n#   define DECLARE_DEPRECATED(f)    f __attribute__ ((deprecated));\n#  endif\n# endif\n#endif\n\n#ifndef OPENSSL_FILE\n# ifdef OPENSSL_NO_FILENAMES\n#  define OPENSSL_FILE \"\"\n#  define OPENSSL_LINE 0\n# else\n#  define OPENSSL_FILE __FILE__\n#  define OPENSSL_LINE __LINE__\n# endif\n#endif\n\n#ifndef OPENSSL_MIN_API\n# define OPENSSL_MIN_API 0\n#endif\n\n#if !defined(OPENSSL_API_COMPAT) || OPENSSL_API_COMPAT < OPENSSL_MIN_API\n# undef OPENSSL_API_COMPAT\n# define OPENSSL_API_COMPAT OPENSSL_MIN_API\n#endif\n\n/*\n * Do not deprecate things to be deprecated in version 1.2.0 before the\n * OpenSSL version number matches.\n */\n#if OPENSSL_VERSION_NUMBER < 0x10200000L\n# define DEPRECATEDIN_1_2_0(f)   f;\n#elif OPENSSL_API_COMPAT < 0x10200000L\n# define DEPRECATEDIN_1_2_0(f)   DECLARE_DEPRECATED(f)\n#else\n# define DEPRECATEDIN_1_2_0(f)\n#endif\n\n#if OPENSSL_API_COMPAT < 0x10100000L\n# define DEPRECATEDIN_1_1_0(f)   DECLARE_DEPRECATED(f)\n#else\n# define DEPRECATEDIN_1_1_0(f)\n#endif\n\n#if OPENSSL_API_COMPAT < 0x10000000L\n# define DEPRECATEDIN_1_0_0(f)   DECLARE_DEPRECATED(f)\n#else\n# define DEPRECATEDIN_1_0_0(f)\n#endif\n\n#if OPENSSL_API_COMPAT < 0x00908000L\n# define DEPRECATEDIN_0_9_8(f)   DECLARE_DEPRECATED(f)\n#else\n# define DEPRECATEDIN_0_9_8(f)\n#endif\n\n/* Generate 80386 code? */\n#undef I386_ONLY\n\n#undef OPENSSL_UNISTD\n#define OPENSSL_UNISTD <unistd.h>\n\n#undef OPENSSL_EXPORT_VAR_AS_FUNCTION\n\n/*\n * The following are cipher-specific, but are part of the public API.\n */\n#if !defined(OPENSSL_SYS_UEFI)\n# undef BN_LLONG\n/* Only one for the following should be defined */\n# define SIXTY_FOUR_BIT_LONG\n# undef SIXTY_FOUR_BIT\n# undef THIRTY_TWO_BIT\n#endif\n\n#define RC4_INT unsigned char\n\n#ifdef  __cplusplus\n}\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/include/openssl/opensslconf_android-x86_64.h",
    "content": "/*\n * WARNING: do not edit!\n * Generated by Makefile from include/openssl/opensslconf.h.in\n *\n * Copyright 2016-2020 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#include <openssl/opensslv.h>\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n#ifdef OPENSSL_ALGORITHM_DEFINES\n# error OPENSSL_ALGORITHM_DEFINES no longer supported\n#endif\n\n/*\n * OpenSSL was configured with the following options:\n */\n\n#ifndef OPENSSL_NO_MD2\n# define OPENSSL_NO_MD2\n#endif\n#ifndef OPENSSL_NO_RC5\n# define OPENSSL_NO_RC5\n#endif\n#ifndef OPENSSL_THREADS\n# define OPENSSL_THREADS\n#endif\n#ifndef OPENSSL_RAND_SEED_OS\n# define OPENSSL_RAND_SEED_OS\n#endif\n#ifndef OPENSSL_NO_AFALGENG\n# define OPENSSL_NO_AFALGENG\n#endif\n#ifndef OPENSSL_NO_ASAN\n# define OPENSSL_NO_ASAN\n#endif\n#ifndef OPENSSL_NO_CRYPTO_MDEBUG\n# define OPENSSL_NO_CRYPTO_MDEBUG\n#endif\n#ifndef OPENSSL_NO_CRYPTO_MDEBUG_BACKTRACE\n# define OPENSSL_NO_CRYPTO_MDEBUG_BACKTRACE\n#endif\n#ifndef OPENSSL_NO_DEVCRYPTOENG\n# define OPENSSL_NO_DEVCRYPTOENG\n#endif\n#ifndef OPENSSL_NO_EC_NISTP_64_GCC_128\n# define OPENSSL_NO_EC_NISTP_64_GCC_128\n#endif\n#ifndef OPENSSL_NO_EGD\n# define OPENSSL_NO_EGD\n#endif\n#ifndef OPENSSL_NO_EXTERNAL_TESTS\n# define OPENSSL_NO_EXTERNAL_TESTS\n#endif\n#ifndef OPENSSL_NO_FUZZ_AFL\n# define OPENSSL_NO_FUZZ_AFL\n#endif\n#ifndef OPENSSL_NO_FUZZ_LIBFUZZER\n# define OPENSSL_NO_FUZZ_LIBFUZZER\n#endif\n#ifndef OPENSSL_NO_HEARTBEATS\n# define OPENSSL_NO_HEARTBEATS\n#endif\n#ifndef OPENSSL_NO_MSAN\n# define OPENSSL_NO_MSAN\n#endif\n#ifndef OPENSSL_NO_SCTP\n# define OPENSSL_NO_SCTP\n#endif\n#ifndef OPENSSL_NO_SSL_TRACE\n# define OPENSSL_NO_SSL_TRACE\n#endif\n#ifndef OPENSSL_NO_SSL3\n# define OPENSSL_NO_SSL3\n#endif\n#ifndef OPENSSL_NO_SSL3_METHOD\n# define OPENSSL_NO_SSL3_METHOD\n#endif\n#ifndef OPENSSL_NO_TESTS\n# define OPENSSL_NO_TESTS\n#endif\n#ifndef OPENSSL_NO_UBSAN\n# define OPENSSL_NO_UBSAN\n#endif\n#ifndef OPENSSL_NO_UNIT_TEST\n# define OPENSSL_NO_UNIT_TEST\n#endif\n#ifndef OPENSSL_NO_WEAK_SSL_CIPHERS\n# define OPENSSL_NO_WEAK_SSL_CIPHERS\n#endif\n#ifndef OPENSSL_NO_DYNAMIC_ENGINE\n# define OPENSSL_NO_DYNAMIC_ENGINE\n#endif\n\n\n/*\n * Sometimes OPENSSSL_NO_xxx ends up with an empty file and some compilers\n * don't like that.  This will hopefully silence them.\n */\n#define NON_EMPTY_TRANSLATION_UNIT static void *dummy = &dummy;\n\n/*\n * Applications should use -DOPENSSL_API_COMPAT=<version> to suppress the\n * declarations of functions deprecated in or before <version>. Otherwise, they\n * still won't see them if the library has been built to disable deprecated\n * functions.\n */\n#ifndef DECLARE_DEPRECATED\n# define DECLARE_DEPRECATED(f)   f;\n# ifdef __GNUC__\n#  if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ > 0)\n#   undef DECLARE_DEPRECATED\n#   define DECLARE_DEPRECATED(f)    f __attribute__ ((deprecated));\n#  endif\n# elif defined(__SUNPRO_C)\n#  if (__SUNPRO_C >= 0x5130)\n#   undef DECLARE_DEPRECATED\n#   define DECLARE_DEPRECATED(f)    f __attribute__ ((deprecated));\n#  endif\n# endif\n#endif\n\n#ifndef OPENSSL_FILE\n# ifdef OPENSSL_NO_FILENAMES\n#  define OPENSSL_FILE \"\"\n#  define OPENSSL_LINE 0\n# else\n#  define OPENSSL_FILE __FILE__\n#  define OPENSSL_LINE __LINE__\n# endif\n#endif\n\n#ifndef OPENSSL_MIN_API\n# define OPENSSL_MIN_API 0\n#endif\n\n#if !defined(OPENSSL_API_COMPAT) || OPENSSL_API_COMPAT < OPENSSL_MIN_API\n# undef OPENSSL_API_COMPAT\n# define OPENSSL_API_COMPAT OPENSSL_MIN_API\n#endif\n\n/*\n * Do not deprecate things to be deprecated in version 1.2.0 before the\n * OpenSSL version number matches.\n */\n#if OPENSSL_VERSION_NUMBER < 0x10200000L\n# define DEPRECATEDIN_1_2_0(f)   f;\n#elif OPENSSL_API_COMPAT < 0x10200000L\n# define DEPRECATEDIN_1_2_0(f)   DECLARE_DEPRECATED(f)\n#else\n# define DEPRECATEDIN_1_2_0(f)\n#endif\n\n#if OPENSSL_API_COMPAT < 0x10100000L\n# define DEPRECATEDIN_1_1_0(f)   DECLARE_DEPRECATED(f)\n#else\n# define DEPRECATEDIN_1_1_0(f)\n#endif\n\n#if OPENSSL_API_COMPAT < 0x10000000L\n# define DEPRECATEDIN_1_0_0(f)   DECLARE_DEPRECATED(f)\n#else\n# define DEPRECATEDIN_1_0_0(f)\n#endif\n\n#if OPENSSL_API_COMPAT < 0x00908000L\n# define DEPRECATEDIN_0_9_8(f)   DECLARE_DEPRECATED(f)\n#else\n# define DEPRECATEDIN_0_9_8(f)\n#endif\n\n/* Generate 80386 code? */\n#undef I386_ONLY\n\n#undef OPENSSL_UNISTD\n#define OPENSSL_UNISTD <unistd.h>\n\n#undef OPENSSL_EXPORT_VAR_AS_FUNCTION\n\n/*\n * The following are cipher-specific, but are part of the public API.\n */\n#if !defined(OPENSSL_SYS_UEFI)\n# undef BN_LLONG\n/* Only one for the following should be defined */\n# define SIXTY_FOUR_BIT_LONG\n# undef SIXTY_FOUR_BIT\n# undef THIRTY_TWO_BIT\n#endif\n\n#define RC4_INT unsigned int\n\n#ifdef  __cplusplus\n}\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/include/openssl/opensslconf_android64-x86_64.h",
    "content": "/*\n * WARNING: do not edit!\n * Generated by Makefile from include/openssl/opensslconf.h.in\n *\n * Copyright 2016-2020 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#include <openssl/opensslv.h>\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n#ifdef OPENSSL_ALGORITHM_DEFINES\n# error OPENSSL_ALGORITHM_DEFINES no longer supported\n#endif\n\n/*\n * OpenSSL was configured with the following options:\n */\n\n#ifndef OPENSSL_NO_MD2\n# define OPENSSL_NO_MD2\n#endif\n#ifndef OPENSSL_NO_RC5\n# define OPENSSL_NO_RC5\n#endif\n#ifndef OPENSSL_THREADS\n# define OPENSSL_THREADS\n#endif\n#ifndef OPENSSL_RAND_SEED_OS\n# define OPENSSL_RAND_SEED_OS\n#endif\n#ifndef OPENSSL_NO_AFALGENG\n# define OPENSSL_NO_AFALGENG\n#endif\n#ifndef OPENSSL_NO_ASAN\n# define OPENSSL_NO_ASAN\n#endif\n#ifndef OPENSSL_NO_CRYPTO_MDEBUG\n# define OPENSSL_NO_CRYPTO_MDEBUG\n#endif\n#ifndef OPENSSL_NO_CRYPTO_MDEBUG_BACKTRACE\n# define OPENSSL_NO_CRYPTO_MDEBUG_BACKTRACE\n#endif\n#ifndef OPENSSL_NO_DEVCRYPTOENG\n# define OPENSSL_NO_DEVCRYPTOENG\n#endif\n#ifndef OPENSSL_NO_EC_NISTP_64_GCC_128\n# define OPENSSL_NO_EC_NISTP_64_GCC_128\n#endif\n#ifndef OPENSSL_NO_EGD\n# define OPENSSL_NO_EGD\n#endif\n#ifndef OPENSSL_NO_EXTERNAL_TESTS\n# define OPENSSL_NO_EXTERNAL_TESTS\n#endif\n#ifndef OPENSSL_NO_FUZZ_AFL\n# define OPENSSL_NO_FUZZ_AFL\n#endif\n#ifndef OPENSSL_NO_FUZZ_LIBFUZZER\n# define OPENSSL_NO_FUZZ_LIBFUZZER\n#endif\n#ifndef OPENSSL_NO_HEARTBEATS\n# define OPENSSL_NO_HEARTBEATS\n#endif\n#ifndef OPENSSL_NO_MSAN\n# define OPENSSL_NO_MSAN\n#endif\n#ifndef OPENSSL_NO_SCTP\n# define OPENSSL_NO_SCTP\n#endif\n#ifndef OPENSSL_NO_SSL_TRACE\n# define OPENSSL_NO_SSL_TRACE\n#endif\n#ifndef OPENSSL_NO_SSL3\n# define OPENSSL_NO_SSL3\n#endif\n#ifndef OPENSSL_NO_SSL3_METHOD\n# define OPENSSL_NO_SSL3_METHOD\n#endif\n#ifndef OPENSSL_NO_TESTS\n# define OPENSSL_NO_TESTS\n#endif\n#ifndef OPENSSL_NO_UBSAN\n# define OPENSSL_NO_UBSAN\n#endif\n#ifndef OPENSSL_NO_UNIT_TEST\n# define OPENSSL_NO_UNIT_TEST\n#endif\n#ifndef OPENSSL_NO_WEAK_SSL_CIPHERS\n# define OPENSSL_NO_WEAK_SSL_CIPHERS\n#endif\n#ifndef OPENSSL_NO_DYNAMIC_ENGINE\n# define OPENSSL_NO_DYNAMIC_ENGINE\n#endif\n\n\n/*\n * Sometimes OPENSSSL_NO_xxx ends up with an empty file and some compilers\n * don't like that.  This will hopefully silence them.\n */\n#define NON_EMPTY_TRANSLATION_UNIT static void *dummy = &dummy;\n\n/*\n * Applications should use -DOPENSSL_API_COMPAT=<version> to suppress the\n * declarations of functions deprecated in or before <version>. Otherwise, they\n * still won't see them if the library has been built to disable deprecated\n * functions.\n */\n#ifndef DECLARE_DEPRECATED\n# define DECLARE_DEPRECATED(f)   f;\n# ifdef __GNUC__\n#  if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ > 0)\n#   undef DECLARE_DEPRECATED\n#   define DECLARE_DEPRECATED(f)    f __attribute__ ((deprecated));\n#  endif\n# elif defined(__SUNPRO_C)\n#  if (__SUNPRO_C >= 0x5130)\n#   undef DECLARE_DEPRECATED\n#   define DECLARE_DEPRECATED(f)    f __attribute__ ((deprecated));\n#  endif\n# endif\n#endif\n\n#ifndef OPENSSL_FILE\n# ifdef OPENSSL_NO_FILENAMES\n#  define OPENSSL_FILE \"\"\n#  define OPENSSL_LINE 0\n# else\n#  define OPENSSL_FILE __FILE__\n#  define OPENSSL_LINE __LINE__\n# endif\n#endif\n\n#ifndef OPENSSL_MIN_API\n# define OPENSSL_MIN_API 0\n#endif\n\n#if !defined(OPENSSL_API_COMPAT) || OPENSSL_API_COMPAT < OPENSSL_MIN_API\n# undef OPENSSL_API_COMPAT\n# define OPENSSL_API_COMPAT OPENSSL_MIN_API\n#endif\n\n/*\n * Do not deprecate things to be deprecated in version 1.2.0 before the\n * OpenSSL version number matches.\n */\n#if OPENSSL_VERSION_NUMBER < 0x10200000L\n# define DEPRECATEDIN_1_2_0(f)   f;\n#elif OPENSSL_API_COMPAT < 0x10200000L\n# define DEPRECATEDIN_1_2_0(f)   DECLARE_DEPRECATED(f)\n#else\n# define DEPRECATEDIN_1_2_0(f)\n#endif\n\n#if OPENSSL_API_COMPAT < 0x10100000L\n# define DEPRECATEDIN_1_1_0(f)   DECLARE_DEPRECATED(f)\n#else\n# define DEPRECATEDIN_1_1_0(f)\n#endif\n\n#if OPENSSL_API_COMPAT < 0x10000000L\n# define DEPRECATEDIN_1_0_0(f)   DECLARE_DEPRECATED(f)\n#else\n# define DEPRECATEDIN_1_0_0(f)\n#endif\n\n#if OPENSSL_API_COMPAT < 0x00908000L\n# define DEPRECATEDIN_0_9_8(f)   DECLARE_DEPRECATED(f)\n#else\n# define DEPRECATEDIN_0_9_8(f)\n#endif\n\n/* Generate 80386 code? */\n#undef I386_ONLY\n\n#undef OPENSSL_UNISTD\n#define OPENSSL_UNISTD <unistd.h>\n\n#undef OPENSSL_EXPORT_VAR_AS_FUNCTION\n\n/*\n * The following are cipher-specific, but are part of the public API.\n */\n#if !defined(OPENSSL_SYS_UEFI)\n# undef BN_LLONG\n/* Only one for the following should be defined */\n# define SIXTY_FOUR_BIT_LONG\n# undef SIXTY_FOUR_BIT\n# undef THIRTY_TWO_BIT\n#endif\n\n#define RC4_INT unsigned int\n\n#ifdef  __cplusplus\n}\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/include/openssl/opensslconf_catalyst_arm64.h",
    "content": "/*\n * WARNING: do not edit!\n * Generated by Makefile from include/openssl/opensslconf.h.in\n *\n * Copyright 2016-2020 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#include <openssl/opensslv.h>\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n#ifdef OPENSSL_ALGORITHM_DEFINES\n# error OPENSSL_ALGORITHM_DEFINES no longer supported\n#endif\n\n/*\n * OpenSSL was configured with the following options:\n */\n\n#ifndef OPENSSL_SYS_MacOSX\n# define OPENSSL_SYS_MacOSX 1\n#endif\n#define OPENSSL_MIN_API 0x10100000L\n#ifndef OPENSSL_NO_MD2\n# define OPENSSL_NO_MD2\n#endif\n#ifndef OPENSSL_NO_RC5\n# define OPENSSL_NO_RC5\n#endif\n#ifndef OPENSSL_THREADS\n# define OPENSSL_THREADS\n#endif\n#ifndef OPENSSL_RAND_SEED_OS\n# define OPENSSL_RAND_SEED_OS\n#endif\n#ifndef OPENSSL_NO_AFALGENG\n# define OPENSSL_NO_AFALGENG\n#endif\n#ifndef OPENSSL_NO_ASAN\n# define OPENSSL_NO_ASAN\n#endif\n#ifndef OPENSSL_NO_ASYNC\n# define OPENSSL_NO_ASYNC\n#endif\n#ifndef OPENSSL_NO_CRYPTO_MDEBUG\n# define OPENSSL_NO_CRYPTO_MDEBUG\n#endif\n#ifndef OPENSSL_NO_CRYPTO_MDEBUG_BACKTRACE\n# define OPENSSL_NO_CRYPTO_MDEBUG_BACKTRACE\n#endif\n#ifndef OPENSSL_NO_DEPRECATED\n# define OPENSSL_NO_DEPRECATED\n#endif\n#ifndef OPENSSL_NO_DEVCRYPTOENG\n# define OPENSSL_NO_DEVCRYPTOENG\n#endif\n#ifndef OPENSSL_NO_EC_NISTP_64_GCC_128\n# define OPENSSL_NO_EC_NISTP_64_GCC_128\n#endif\n#ifndef OPENSSL_NO_EGD\n# define OPENSSL_NO_EGD\n#endif\n#ifndef OPENSSL_NO_EXTERNAL_TESTS\n# define OPENSSL_NO_EXTERNAL_TESTS\n#endif\n#ifndef OPENSSL_NO_FUZZ_AFL\n# define OPENSSL_NO_FUZZ_AFL\n#endif\n#ifndef OPENSSL_NO_FUZZ_LIBFUZZER\n# define OPENSSL_NO_FUZZ_LIBFUZZER\n#endif\n#ifndef OPENSSL_NO_HEARTBEATS\n# define OPENSSL_NO_HEARTBEATS\n#endif\n#ifndef OPENSSL_NO_MSAN\n# define OPENSSL_NO_MSAN\n#endif\n#ifndef OPENSSL_NO_SCTP\n# define OPENSSL_NO_SCTP\n#endif\n#ifndef OPENSSL_NO_SSL_TRACE\n# define OPENSSL_NO_SSL_TRACE\n#endif\n#ifndef OPENSSL_NO_SSL3\n# define OPENSSL_NO_SSL3\n#endif\n#ifndef OPENSSL_NO_SSL3_METHOD\n# define OPENSSL_NO_SSL3_METHOD\n#endif\n#ifndef OPENSSL_NO_TESTS\n# define OPENSSL_NO_TESTS\n#endif\n#ifndef OPENSSL_NO_UBSAN\n# define OPENSSL_NO_UBSAN\n#endif\n#ifndef OPENSSL_NO_UNIT_TEST\n# define OPENSSL_NO_UNIT_TEST\n#endif\n#ifndef OPENSSL_NO_WEAK_SSL_CIPHERS\n# define OPENSSL_NO_WEAK_SSL_CIPHERS\n#endif\n#ifndef OPENSSL_NO_DYNAMIC_ENGINE\n# define OPENSSL_NO_DYNAMIC_ENGINE\n#endif\n\n\n/*\n * Sometimes OPENSSSL_NO_xxx ends up with an empty file and some compilers\n * don't like that.  This will hopefully silence them.\n */\n#define NON_EMPTY_TRANSLATION_UNIT static void *dummy = &dummy;\n\n/*\n * Applications should use -DOPENSSL_API_COMPAT=<version> to suppress the\n * declarations of functions deprecated in or before <version>. Otherwise, they\n * still won't see them if the library has been built to disable deprecated\n * functions.\n */\n#ifndef DECLARE_DEPRECATED\n# define DECLARE_DEPRECATED(f)   f;\n# ifdef __GNUC__\n#  if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ > 0)\n#   undef DECLARE_DEPRECATED\n#   define DECLARE_DEPRECATED(f)    f __attribute__ ((deprecated));\n#  endif\n# elif defined(__SUNPRO_C)\n#  if (__SUNPRO_C >= 0x5130)\n#   undef DECLARE_DEPRECATED\n#   define DECLARE_DEPRECATED(f)    f __attribute__ ((deprecated));\n#  endif\n# endif\n#endif\n\n#ifndef OPENSSL_FILE\n# ifdef OPENSSL_NO_FILENAMES\n#  define OPENSSL_FILE \"\"\n#  define OPENSSL_LINE 0\n# else\n#  define OPENSSL_FILE __FILE__\n#  define OPENSSL_LINE __LINE__\n# endif\n#endif\n\n#ifndef OPENSSL_MIN_API\n# define OPENSSL_MIN_API 0\n#endif\n\n#if !defined(OPENSSL_API_COMPAT) || OPENSSL_API_COMPAT < OPENSSL_MIN_API\n# undef OPENSSL_API_COMPAT\n# define OPENSSL_API_COMPAT OPENSSL_MIN_API\n#endif\n\n/*\n * Do not deprecate things to be deprecated in version 1.2.0 before the\n * OpenSSL version number matches.\n */\n#if OPENSSL_VERSION_NUMBER < 0x10200000L\n# define DEPRECATEDIN_1_2_0(f)   f;\n#elif OPENSSL_API_COMPAT < 0x10200000L\n# define DEPRECATEDIN_1_2_0(f)   DECLARE_DEPRECATED(f)\n#else\n# define DEPRECATEDIN_1_2_0(f)\n#endif\n\n#if OPENSSL_API_COMPAT < 0x10100000L\n# define DEPRECATEDIN_1_1_0(f)   DECLARE_DEPRECATED(f)\n#else\n# define DEPRECATEDIN_1_1_0(f)\n#endif\n\n#if OPENSSL_API_COMPAT < 0x10000000L\n# define DEPRECATEDIN_1_0_0(f)   DECLARE_DEPRECATED(f)\n#else\n# define DEPRECATEDIN_1_0_0(f)\n#endif\n\n#if OPENSSL_API_COMPAT < 0x00908000L\n# define DEPRECATEDIN_0_9_8(f)   DECLARE_DEPRECATED(f)\n#else\n# define DEPRECATEDIN_0_9_8(f)\n#endif\n\n/* Generate 80386 code? */\n#undef I386_ONLY\n\n#undef OPENSSL_UNISTD\n#define OPENSSL_UNISTD <unistd.h>\n\n#undef OPENSSL_EXPORT_VAR_AS_FUNCTION\n\n/*\n * The following are cipher-specific, but are part of the public API.\n */\n#if !defined(OPENSSL_SYS_UEFI)\n# undef BN_LLONG\n/* Only one for the following should be defined */\n# define SIXTY_FOUR_BIT_LONG\n# undef SIXTY_FOUR_BIT\n# undef THIRTY_TWO_BIT\n#endif\n\n#define RC4_INT unsigned int\n\n#ifdef  __cplusplus\n}\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/include/openssl/opensslconf_catalyst_x86_64.h",
    "content": "/*\n * WARNING: do not edit!\n * Generated by Makefile from include/openssl/opensslconf.h.in\n *\n * Copyright 2016-2020 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#include <openssl/opensslv.h>\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n#ifdef OPENSSL_ALGORITHM_DEFINES\n# error OPENSSL_ALGORITHM_DEFINES no longer supported\n#endif\n\n/*\n * OpenSSL was configured with the following options:\n */\n\n#ifndef OPENSSL_SYS_MacOSX\n# define OPENSSL_SYS_MacOSX 1\n#endif\n#define OPENSSL_MIN_API 0x10100000L\n#ifndef OPENSSL_NO_MD2\n# define OPENSSL_NO_MD2\n#endif\n#ifndef OPENSSL_NO_RC5\n# define OPENSSL_NO_RC5\n#endif\n#ifndef OPENSSL_THREADS\n# define OPENSSL_THREADS\n#endif\n#ifndef OPENSSL_RAND_SEED_OS\n# define OPENSSL_RAND_SEED_OS\n#endif\n#ifndef OPENSSL_NO_AFALGENG\n# define OPENSSL_NO_AFALGENG\n#endif\n#ifndef OPENSSL_NO_ASAN\n# define OPENSSL_NO_ASAN\n#endif\n#ifndef OPENSSL_NO_ASYNC\n# define OPENSSL_NO_ASYNC\n#endif\n#ifndef OPENSSL_NO_CRYPTO_MDEBUG\n# define OPENSSL_NO_CRYPTO_MDEBUG\n#endif\n#ifndef OPENSSL_NO_CRYPTO_MDEBUG_BACKTRACE\n# define OPENSSL_NO_CRYPTO_MDEBUG_BACKTRACE\n#endif\n#ifndef OPENSSL_NO_DEPRECATED\n# define OPENSSL_NO_DEPRECATED\n#endif\n#ifndef OPENSSL_NO_DEVCRYPTOENG\n# define OPENSSL_NO_DEVCRYPTOENG\n#endif\n#ifndef OPENSSL_NO_EC_NISTP_64_GCC_128\n# define OPENSSL_NO_EC_NISTP_64_GCC_128\n#endif\n#ifndef OPENSSL_NO_EGD\n# define OPENSSL_NO_EGD\n#endif\n#ifndef OPENSSL_NO_EXTERNAL_TESTS\n# define OPENSSL_NO_EXTERNAL_TESTS\n#endif\n#ifndef OPENSSL_NO_FUZZ_AFL\n# define OPENSSL_NO_FUZZ_AFL\n#endif\n#ifndef OPENSSL_NO_FUZZ_LIBFUZZER\n# define OPENSSL_NO_FUZZ_LIBFUZZER\n#endif\n#ifndef OPENSSL_NO_HEARTBEATS\n# define OPENSSL_NO_HEARTBEATS\n#endif\n#ifndef OPENSSL_NO_MSAN\n# define OPENSSL_NO_MSAN\n#endif\n#ifndef OPENSSL_NO_SCTP\n# define OPENSSL_NO_SCTP\n#endif\n#ifndef OPENSSL_NO_SSL_TRACE\n# define OPENSSL_NO_SSL_TRACE\n#endif\n#ifndef OPENSSL_NO_SSL3\n# define OPENSSL_NO_SSL3\n#endif\n#ifndef OPENSSL_NO_SSL3_METHOD\n# define OPENSSL_NO_SSL3_METHOD\n#endif\n#ifndef OPENSSL_NO_TESTS\n# define OPENSSL_NO_TESTS\n#endif\n#ifndef OPENSSL_NO_UBSAN\n# define OPENSSL_NO_UBSAN\n#endif\n#ifndef OPENSSL_NO_UNIT_TEST\n# define OPENSSL_NO_UNIT_TEST\n#endif\n#ifndef OPENSSL_NO_WEAK_SSL_CIPHERS\n# define OPENSSL_NO_WEAK_SSL_CIPHERS\n#endif\n#ifndef OPENSSL_NO_DYNAMIC_ENGINE\n# define OPENSSL_NO_DYNAMIC_ENGINE\n#endif\n\n\n/*\n * Sometimes OPENSSSL_NO_xxx ends up with an empty file and some compilers\n * don't like that.  This will hopefully silence them.\n */\n#define NON_EMPTY_TRANSLATION_UNIT static void *dummy = &dummy;\n\n/*\n * Applications should use -DOPENSSL_API_COMPAT=<version> to suppress the\n * declarations of functions deprecated in or before <version>. Otherwise, they\n * still won't see them if the library has been built to disable deprecated\n * functions.\n */\n#ifndef DECLARE_DEPRECATED\n# define DECLARE_DEPRECATED(f)   f;\n# ifdef __GNUC__\n#  if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ > 0)\n#   undef DECLARE_DEPRECATED\n#   define DECLARE_DEPRECATED(f)    f __attribute__ ((deprecated));\n#  endif\n# elif defined(__SUNPRO_C)\n#  if (__SUNPRO_C >= 0x5130)\n#   undef DECLARE_DEPRECATED\n#   define DECLARE_DEPRECATED(f)    f __attribute__ ((deprecated));\n#  endif\n# endif\n#endif\n\n#ifndef OPENSSL_FILE\n# ifdef OPENSSL_NO_FILENAMES\n#  define OPENSSL_FILE \"\"\n#  define OPENSSL_LINE 0\n# else\n#  define OPENSSL_FILE __FILE__\n#  define OPENSSL_LINE __LINE__\n# endif\n#endif\n\n#ifndef OPENSSL_MIN_API\n# define OPENSSL_MIN_API 0\n#endif\n\n#if !defined(OPENSSL_API_COMPAT) || OPENSSL_API_COMPAT < OPENSSL_MIN_API\n# undef OPENSSL_API_COMPAT\n# define OPENSSL_API_COMPAT OPENSSL_MIN_API\n#endif\n\n/*\n * Do not deprecate things to be deprecated in version 1.2.0 before the\n * OpenSSL version number matches.\n */\n#if OPENSSL_VERSION_NUMBER < 0x10200000L\n# define DEPRECATEDIN_1_2_0(f)   f;\n#elif OPENSSL_API_COMPAT < 0x10200000L\n# define DEPRECATEDIN_1_2_0(f)   DECLARE_DEPRECATED(f)\n#else\n# define DEPRECATEDIN_1_2_0(f)\n#endif\n\n#if OPENSSL_API_COMPAT < 0x10100000L\n# define DEPRECATEDIN_1_1_0(f)   DECLARE_DEPRECATED(f)\n#else\n# define DEPRECATEDIN_1_1_0(f)\n#endif\n\n#if OPENSSL_API_COMPAT < 0x10000000L\n# define DEPRECATEDIN_1_0_0(f)   DECLARE_DEPRECATED(f)\n#else\n# define DEPRECATEDIN_1_0_0(f)\n#endif\n\n#if OPENSSL_API_COMPAT < 0x00908000L\n# define DEPRECATEDIN_0_9_8(f)   DECLARE_DEPRECATED(f)\n#else\n# define DEPRECATEDIN_0_9_8(f)\n#endif\n\n/* Generate 80386 code? */\n#undef I386_ONLY\n\n#undef OPENSSL_UNISTD\n#define OPENSSL_UNISTD <unistd.h>\n\n#undef OPENSSL_EXPORT_VAR_AS_FUNCTION\n\n/*\n * The following are cipher-specific, but are part of the public API.\n */\n#if !defined(OPENSSL_SYS_UEFI)\n# undef BN_LLONG\n/* Only one for the following should be defined */\n# define SIXTY_FOUR_BIT_LONG\n# undef SIXTY_FOUR_BIT\n# undef THIRTY_TWO_BIT\n#endif\n\n#define RC4_INT unsigned int\n\n#ifdef  __cplusplus\n}\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/include/openssl/opensslconf_default.h",
    "content": "/*\n * WARNING: do not edit!\n * Generated by Makefile from include/openssl/opensslconf.h.in\n *\n * Copyright 2016-2020 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#include <openssl/opensslv.h>\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n#ifdef OPENSSL_ALGORITHM_DEFINES\n# error OPENSSL_ALGORITHM_DEFINES no longer supported\n#endif\n\n/*\n * OpenSSL was configured with the following options:\n */\n\n#ifndef OPENSSL_NO_MD2\n# define OPENSSL_NO_MD2\n#endif\n#ifndef OPENSSL_NO_RC5\n# define OPENSSL_NO_RC5\n#endif\n#ifndef OPENSSL_THREADS\n# define OPENSSL_THREADS\n#endif\n#ifndef OPENSSL_RAND_SEED_OS\n# define OPENSSL_RAND_SEED_OS\n#endif\n#ifndef OPENSSL_NO_ASAN\n# define OPENSSL_NO_ASAN\n#endif\n#ifndef OPENSSL_NO_CRYPTO_MDEBUG\n# define OPENSSL_NO_CRYPTO_MDEBUG\n#endif\n#ifndef OPENSSL_NO_CRYPTO_MDEBUG_BACKTRACE\n# define OPENSSL_NO_CRYPTO_MDEBUG_BACKTRACE\n#endif\n#ifndef OPENSSL_NO_DEVCRYPTOENG\n# define OPENSSL_NO_DEVCRYPTOENG\n#endif\n#ifndef OPENSSL_NO_EC_NISTP_64_GCC_128\n# define OPENSSL_NO_EC_NISTP_64_GCC_128\n#endif\n#ifndef OPENSSL_NO_EGD\n# define OPENSSL_NO_EGD\n#endif\n#ifndef OPENSSL_NO_EXTERNAL_TESTS\n# define OPENSSL_NO_EXTERNAL_TESTS\n#endif\n#ifndef OPENSSL_NO_FUZZ_AFL\n# define OPENSSL_NO_FUZZ_AFL\n#endif\n#ifndef OPENSSL_NO_FUZZ_LIBFUZZER\n# define OPENSSL_NO_FUZZ_LIBFUZZER\n#endif\n#ifndef OPENSSL_NO_HEARTBEATS\n# define OPENSSL_NO_HEARTBEATS\n#endif\n#ifndef OPENSSL_NO_MSAN\n# define OPENSSL_NO_MSAN\n#endif\n#ifndef OPENSSL_NO_SCTP\n# define OPENSSL_NO_SCTP\n#endif\n#ifndef OPENSSL_NO_SSL_TRACE\n# define OPENSSL_NO_SSL_TRACE\n#endif\n#ifndef OPENSSL_NO_SSL3\n# define OPENSSL_NO_SSL3\n#endif\n#ifndef OPENSSL_NO_SSL3_METHOD\n# define OPENSSL_NO_SSL3_METHOD\n#endif\n#ifndef OPENSSL_NO_UBSAN\n# define OPENSSL_NO_UBSAN\n#endif\n#ifndef OPENSSL_NO_UNIT_TEST\n# define OPENSSL_NO_UNIT_TEST\n#endif\n#ifndef OPENSSL_NO_WEAK_SSL_CIPHERS\n# define OPENSSL_NO_WEAK_SSL_CIPHERS\n#endif\n#ifndef OPENSSL_NO_STATIC_ENGINE\n# define OPENSSL_NO_STATIC_ENGINE\n#endif\n\n\n/*\n * Sometimes OPENSSSL_NO_xxx ends up with an empty file and some compilers\n * don't like that.  This will hopefully silence them.\n */\n#define NON_EMPTY_TRANSLATION_UNIT static void *dummy = &dummy;\n\n/*\n * Applications should use -DOPENSSL_API_COMPAT=<version> to suppress the\n * declarations of functions deprecated in or before <version>. Otherwise, they\n * still won't see them if the library has been built to disable deprecated\n * functions.\n */\n#ifndef DECLARE_DEPRECATED\n# define DECLARE_DEPRECATED(f)   f;\n# ifdef __GNUC__\n#  if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ > 0)\n#   undef DECLARE_DEPRECATED\n#   define DECLARE_DEPRECATED(f)    f __attribute__ ((deprecated));\n#  endif\n# elif defined(__SUNPRO_C)\n#  if (__SUNPRO_C >= 0x5130)\n#   undef DECLARE_DEPRECATED\n#   define DECLARE_DEPRECATED(f)    f __attribute__ ((deprecated));\n#  endif\n# endif\n#endif\n\n#ifndef OPENSSL_FILE\n# ifdef OPENSSL_NO_FILENAMES\n#  define OPENSSL_FILE \"\"\n#  define OPENSSL_LINE 0\n# else\n#  define OPENSSL_FILE __FILE__\n#  define OPENSSL_LINE __LINE__\n# endif\n#endif\n\n#ifndef OPENSSL_MIN_API\n# define OPENSSL_MIN_API 0\n#endif\n\n#if !defined(OPENSSL_API_COMPAT) || OPENSSL_API_COMPAT < OPENSSL_MIN_API\n# undef OPENSSL_API_COMPAT\n# define OPENSSL_API_COMPAT OPENSSL_MIN_API\n#endif\n\n/*\n * Do not deprecate things to be deprecated in version 1.2.0 before the\n * OpenSSL version number matches.\n */\n#if OPENSSL_VERSION_NUMBER < 0x10200000L\n# define DEPRECATEDIN_1_2_0(f)   f;\n#elif OPENSSL_API_COMPAT < 0x10200000L\n# define DEPRECATEDIN_1_2_0(f)   DECLARE_DEPRECATED(f)\n#else\n# define DEPRECATEDIN_1_2_0(f)\n#endif\n\n#if OPENSSL_API_COMPAT < 0x10100000L\n# define DEPRECATEDIN_1_1_0(f)   DECLARE_DEPRECATED(f)\n#else\n# define DEPRECATEDIN_1_1_0(f)\n#endif\n\n#if OPENSSL_API_COMPAT < 0x10000000L\n# define DEPRECATEDIN_1_0_0(f)   DECLARE_DEPRECATED(f)\n#else\n# define DEPRECATEDIN_1_0_0(f)\n#endif\n\n#if OPENSSL_API_COMPAT < 0x00908000L\n# define DEPRECATEDIN_0_9_8(f)   DECLARE_DEPRECATED(f)\n#else\n# define DEPRECATEDIN_0_9_8(f)\n#endif\n\n/* Generate 80386 code? */\n#undef I386_ONLY\n\n#undef OPENSSL_UNISTD\n#define OPENSSL_UNISTD <unistd.h>\n\n#undef OPENSSL_EXPORT_VAR_AS_FUNCTION\n\n/*\n * The following are cipher-specific, but are part of the public API.\n */\n#if !defined(OPENSSL_SYS_UEFI)\n# undef BN_LLONG\n/* Only one for the following should be defined */\n# define SIXTY_FOUR_BIT_LONG\n# undef SIXTY_FOUR_BIT\n# undef THIRTY_TWO_BIT\n#endif\n\n#define RC4_INT unsigned int\n\n#ifdef  __cplusplus\n}\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/include/openssl/opensslconf_ios_arm64.h",
    "content": "/*\n * WARNING: do not edit!\n * Generated by Makefile from include/openssl/opensslconf.h.in\n *\n * Copyright 2016-2020 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#include <openssl/opensslv.h>\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n#ifdef OPENSSL_ALGORITHM_DEFINES\n# error OPENSSL_ALGORITHM_DEFINES no longer supported\n#endif\n\n/*\n * OpenSSL was configured with the following options:\n */\n\n#ifndef OPENSSL_SYS_iOS\n# define OPENSSL_SYS_iOS 1\n#endif\n#ifndef OPENSSL_NO_MD2\n# define OPENSSL_NO_MD2\n#endif\n#ifndef OPENSSL_NO_RC5\n# define OPENSSL_NO_RC5\n#endif\n#ifndef OPENSSL_THREADS\n# define OPENSSL_THREADS\n#endif\n#ifndef OPENSSL_RAND_SEED_OS\n# define OPENSSL_RAND_SEED_OS\n#endif\n#ifndef OPENSSL_NO_AFALGENG\n# define OPENSSL_NO_AFALGENG\n#endif\n#ifndef OPENSSL_NO_ASAN\n# define OPENSSL_NO_ASAN\n#endif\n#ifndef OPENSSL_NO_ASYNC\n# define OPENSSL_NO_ASYNC\n#endif\n#ifndef OPENSSL_NO_CRYPTO_MDEBUG\n# define OPENSSL_NO_CRYPTO_MDEBUG\n#endif\n#ifndef OPENSSL_NO_CRYPTO_MDEBUG_BACKTRACE\n# define OPENSSL_NO_CRYPTO_MDEBUG_BACKTRACE\n#endif\n#ifndef OPENSSL_NO_DEVCRYPTOENG\n# define OPENSSL_NO_DEVCRYPTOENG\n#endif\n#ifndef OPENSSL_NO_EC_NISTP_64_GCC_128\n# define OPENSSL_NO_EC_NISTP_64_GCC_128\n#endif\n#ifndef OPENSSL_NO_EGD\n# define OPENSSL_NO_EGD\n#endif\n#ifndef OPENSSL_NO_EXTERNAL_TESTS\n# define OPENSSL_NO_EXTERNAL_TESTS\n#endif\n#ifndef OPENSSL_NO_FUZZ_AFL\n# define OPENSSL_NO_FUZZ_AFL\n#endif\n#ifndef OPENSSL_NO_FUZZ_LIBFUZZER\n# define OPENSSL_NO_FUZZ_LIBFUZZER\n#endif\n#ifndef OPENSSL_NO_HEARTBEATS\n# define OPENSSL_NO_HEARTBEATS\n#endif\n#ifndef OPENSSL_NO_MSAN\n# define OPENSSL_NO_MSAN\n#endif\n#ifndef OPENSSL_NO_SCTP\n# define OPENSSL_NO_SCTP\n#endif\n#ifndef OPENSSL_NO_SSL_TRACE\n# define OPENSSL_NO_SSL_TRACE\n#endif\n#ifndef OPENSSL_NO_SSL3\n# define OPENSSL_NO_SSL3\n#endif\n#ifndef OPENSSL_NO_SSL3_METHOD\n# define OPENSSL_NO_SSL3_METHOD\n#endif\n#ifndef OPENSSL_NO_TESTS\n# define OPENSSL_NO_TESTS\n#endif\n#ifndef OPENSSL_NO_UBSAN\n# define OPENSSL_NO_UBSAN\n#endif\n#ifndef OPENSSL_NO_UNIT_TEST\n# define OPENSSL_NO_UNIT_TEST\n#endif\n#ifndef OPENSSL_NO_WEAK_SSL_CIPHERS\n# define OPENSSL_NO_WEAK_SSL_CIPHERS\n#endif\n#ifndef OPENSSL_NO_DYNAMIC_ENGINE\n# define OPENSSL_NO_DYNAMIC_ENGINE\n#endif\n\n\n/*\n * Sometimes OPENSSSL_NO_xxx ends up with an empty file and some compilers\n * don't like that.  This will hopefully silence them.\n */\n#define NON_EMPTY_TRANSLATION_UNIT static void *dummy = &dummy;\n\n/*\n * Applications should use -DOPENSSL_API_COMPAT=<version> to suppress the\n * declarations of functions deprecated in or before <version>. Otherwise, they\n * still won't see them if the library has been built to disable deprecated\n * functions.\n */\n#ifndef DECLARE_DEPRECATED\n# define DECLARE_DEPRECATED(f)   f;\n# ifdef __GNUC__\n#  if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ > 0)\n#   undef DECLARE_DEPRECATED\n#   define DECLARE_DEPRECATED(f)    f __attribute__ ((deprecated));\n#  endif\n# elif defined(__SUNPRO_C)\n#  if (__SUNPRO_C >= 0x5130)\n#   undef DECLARE_DEPRECATED\n#   define DECLARE_DEPRECATED(f)    f __attribute__ ((deprecated));\n#  endif\n# endif\n#endif\n\n#ifndef OPENSSL_FILE\n# ifdef OPENSSL_NO_FILENAMES\n#  define OPENSSL_FILE \"\"\n#  define OPENSSL_LINE 0\n# else\n#  define OPENSSL_FILE __FILE__\n#  define OPENSSL_LINE __LINE__\n# endif\n#endif\n\n#ifndef OPENSSL_MIN_API\n# define OPENSSL_MIN_API 0\n#endif\n\n#if !defined(OPENSSL_API_COMPAT) || OPENSSL_API_COMPAT < OPENSSL_MIN_API\n# undef OPENSSL_API_COMPAT\n# define OPENSSL_API_COMPAT OPENSSL_MIN_API\n#endif\n\n/*\n * Do not deprecate things to be deprecated in version 1.2.0 before the\n * OpenSSL version number matches.\n */\n#if OPENSSL_VERSION_NUMBER < 0x10200000L\n# define DEPRECATEDIN_1_2_0(f)   f;\n#elif OPENSSL_API_COMPAT < 0x10200000L\n# define DEPRECATEDIN_1_2_0(f)   DECLARE_DEPRECATED(f)\n#else\n# define DEPRECATEDIN_1_2_0(f)\n#endif\n\n#if OPENSSL_API_COMPAT < 0x10100000L\n# define DEPRECATEDIN_1_1_0(f)   DECLARE_DEPRECATED(f)\n#else\n# define DEPRECATEDIN_1_1_0(f)\n#endif\n\n#if OPENSSL_API_COMPAT < 0x10000000L\n# define DEPRECATEDIN_1_0_0(f)   DECLARE_DEPRECATED(f)\n#else\n# define DEPRECATEDIN_1_0_0(f)\n#endif\n\n#if OPENSSL_API_COMPAT < 0x00908000L\n# define DEPRECATEDIN_0_9_8(f)   DECLARE_DEPRECATED(f)\n#else\n# define DEPRECATEDIN_0_9_8(f)\n#endif\n\n/* Generate 80386 code? */\n#undef I386_ONLY\n\n#undef OPENSSL_UNISTD\n#define OPENSSL_UNISTD <unistd.h>\n\n#undef OPENSSL_EXPORT_VAR_AS_FUNCTION\n\n/*\n * The following are cipher-specific, but are part of the public API.\n */\n#if !defined(OPENSSL_SYS_UEFI)\n# undef BN_LLONG\n/* Only one for the following should be defined */\n# define SIXTY_FOUR_BIT_LONG\n# undef SIXTY_FOUR_BIT\n# undef THIRTY_TWO_BIT\n#endif\n\n#define RC4_INT unsigned char\n\n#ifdef  __cplusplus\n}\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/include/openssl/opensslconf_ios_sim_x86_64.h",
    "content": "/*\n * WARNING: do not edit!\n * Generated by Makefile from include/openssl/opensslconf.h.in\n *\n * Copyright 2016-2020 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#include <openssl/opensslv.h>\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n#ifdef OPENSSL_ALGORITHM_DEFINES\n# error OPENSSL_ALGORITHM_DEFINES no longer supported\n#endif\n\n/*\n * OpenSSL was configured with the following options:\n */\n\n#ifndef OPENSSL_SYS_iOS\n# define OPENSSL_SYS_iOS 1\n#endif\n#ifndef OPENSSL_NO_MD2\n# define OPENSSL_NO_MD2\n#endif\n#ifndef OPENSSL_NO_RC5\n# define OPENSSL_NO_RC5\n#endif\n#ifndef OPENSSL_THREADS\n# define OPENSSL_THREADS\n#endif\n#ifndef OPENSSL_RAND_SEED_OS\n# define OPENSSL_RAND_SEED_OS\n#endif\n#ifndef OPENSSL_NO_AFALGENG\n# define OPENSSL_NO_AFALGENG\n#endif\n#ifndef OPENSSL_NO_ASAN\n# define OPENSSL_NO_ASAN\n#endif\n#ifndef OPENSSL_NO_ASYNC\n# define OPENSSL_NO_ASYNC\n#endif\n#ifndef OPENSSL_NO_CRYPTO_MDEBUG\n# define OPENSSL_NO_CRYPTO_MDEBUG\n#endif\n#ifndef OPENSSL_NO_CRYPTO_MDEBUG_BACKTRACE\n# define OPENSSL_NO_CRYPTO_MDEBUG_BACKTRACE\n#endif\n#ifndef OPENSSL_NO_DEVCRYPTOENG\n# define OPENSSL_NO_DEVCRYPTOENG\n#endif\n#ifndef OPENSSL_NO_EC_NISTP_64_GCC_128\n# define OPENSSL_NO_EC_NISTP_64_GCC_128\n#endif\n#ifndef OPENSSL_NO_EGD\n# define OPENSSL_NO_EGD\n#endif\n#ifndef OPENSSL_NO_EXTERNAL_TESTS\n# define OPENSSL_NO_EXTERNAL_TESTS\n#endif\n#ifndef OPENSSL_NO_FUZZ_AFL\n# define OPENSSL_NO_FUZZ_AFL\n#endif\n#ifndef OPENSSL_NO_FUZZ_LIBFUZZER\n# define OPENSSL_NO_FUZZ_LIBFUZZER\n#endif\n#ifndef OPENSSL_NO_HEARTBEATS\n# define OPENSSL_NO_HEARTBEATS\n#endif\n#ifndef OPENSSL_NO_MSAN\n# define OPENSSL_NO_MSAN\n#endif\n#ifndef OPENSSL_NO_SCTP\n# define OPENSSL_NO_SCTP\n#endif\n#ifndef OPENSSL_NO_SSL_TRACE\n# define OPENSSL_NO_SSL_TRACE\n#endif\n#ifndef OPENSSL_NO_SSL3\n# define OPENSSL_NO_SSL3\n#endif\n#ifndef OPENSSL_NO_SSL3_METHOD\n# define OPENSSL_NO_SSL3_METHOD\n#endif\n#ifndef OPENSSL_NO_TESTS\n# define OPENSSL_NO_TESTS\n#endif\n#ifndef OPENSSL_NO_UBSAN\n# define OPENSSL_NO_UBSAN\n#endif\n#ifndef OPENSSL_NO_UNIT_TEST\n# define OPENSSL_NO_UNIT_TEST\n#endif\n#ifndef OPENSSL_NO_WEAK_SSL_CIPHERS\n# define OPENSSL_NO_WEAK_SSL_CIPHERS\n#endif\n#ifndef OPENSSL_NO_DYNAMIC_ENGINE\n# define OPENSSL_NO_DYNAMIC_ENGINE\n#endif\n\n\n/*\n * Sometimes OPENSSSL_NO_xxx ends up with an empty file and some compilers\n * don't like that.  This will hopefully silence them.\n */\n#define NON_EMPTY_TRANSLATION_UNIT static void *dummy = &dummy;\n\n/*\n * Applications should use -DOPENSSL_API_COMPAT=<version> to suppress the\n * declarations of functions deprecated in or before <version>. Otherwise, they\n * still won't see them if the library has been built to disable deprecated\n * functions.\n */\n#ifndef DECLARE_DEPRECATED\n# define DECLARE_DEPRECATED(f)   f;\n# ifdef __GNUC__\n#  if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ > 0)\n#   undef DECLARE_DEPRECATED\n#   define DECLARE_DEPRECATED(f)    f __attribute__ ((deprecated));\n#  endif\n# elif defined(__SUNPRO_C)\n#  if (__SUNPRO_C >= 0x5130)\n#   undef DECLARE_DEPRECATED\n#   define DECLARE_DEPRECATED(f)    f __attribute__ ((deprecated));\n#  endif\n# endif\n#endif\n\n#ifndef OPENSSL_FILE\n# ifdef OPENSSL_NO_FILENAMES\n#  define OPENSSL_FILE \"\"\n#  define OPENSSL_LINE 0\n# else\n#  define OPENSSL_FILE __FILE__\n#  define OPENSSL_LINE __LINE__\n# endif\n#endif\n\n#ifndef OPENSSL_MIN_API\n# define OPENSSL_MIN_API 0\n#endif\n\n#if !defined(OPENSSL_API_COMPAT) || OPENSSL_API_COMPAT < OPENSSL_MIN_API\n# undef OPENSSL_API_COMPAT\n# define OPENSSL_API_COMPAT OPENSSL_MIN_API\n#endif\n\n/*\n * Do not deprecate things to be deprecated in version 1.2.0 before the\n * OpenSSL version number matches.\n */\n#if OPENSSL_VERSION_NUMBER < 0x10200000L\n# define DEPRECATEDIN_1_2_0(f)   f;\n#elif OPENSSL_API_COMPAT < 0x10200000L\n# define DEPRECATEDIN_1_2_0(f)   DECLARE_DEPRECATED(f)\n#else\n# define DEPRECATEDIN_1_2_0(f)\n#endif\n\n#if OPENSSL_API_COMPAT < 0x10100000L\n# define DEPRECATEDIN_1_1_0(f)   DECLARE_DEPRECATED(f)\n#else\n# define DEPRECATEDIN_1_1_0(f)\n#endif\n\n#if OPENSSL_API_COMPAT < 0x10000000L\n# define DEPRECATEDIN_1_0_0(f)   DECLARE_DEPRECATED(f)\n#else\n# define DEPRECATEDIN_1_0_0(f)\n#endif\n\n#if OPENSSL_API_COMPAT < 0x00908000L\n# define DEPRECATEDIN_0_9_8(f)   DECLARE_DEPRECATED(f)\n#else\n# define DEPRECATEDIN_0_9_8(f)\n#endif\n\n/* Generate 80386 code? */\n#undef I386_ONLY\n\n#undef OPENSSL_UNISTD\n#define OPENSSL_UNISTD <unistd.h>\n\n#undef OPENSSL_EXPORT_VAR_AS_FUNCTION\n\n/*\n * The following are cipher-specific, but are part of the public API.\n */\n#if !defined(OPENSSL_SYS_UEFI)\n# undef BN_LLONG\n/* Only one for the following should be defined */\n# define SIXTY_FOUR_BIT_LONG\n# undef SIXTY_FOUR_BIT\n# undef THIRTY_TWO_BIT\n#endif\n\n#define RC4_INT unsigned int\n\n#ifdef  __cplusplus\n}\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/include/openssl/opensslconf_macos_arm64.h",
    "content": "/*\n * WARNING: do not edit!\n * Generated by Makefile from include/openssl/opensslconf.h.in\n *\n * Copyright 2016-2020 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#include <openssl/opensslv.h>\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n#ifdef OPENSSL_ALGORITHM_DEFINES\n# error OPENSSL_ALGORITHM_DEFINES no longer supported\n#endif\n\n/*\n * OpenSSL was configured with the following options:\n */\n\n#ifndef OPENSSL_SYS_MacOSX\n# define OPENSSL_SYS_MacOSX 1\n#endif\n#ifndef OPENSSL_NO_MD2\n# define OPENSSL_NO_MD2\n#endif\n#ifndef OPENSSL_NO_RC5\n# define OPENSSL_NO_RC5\n#endif\n#ifndef OPENSSL_THREADS\n# define OPENSSL_THREADS\n#endif\n#ifndef OPENSSL_RAND_SEED_OS\n# define OPENSSL_RAND_SEED_OS\n#endif\n#ifndef OPENSSL_NO_AFALGENG\n# define OPENSSL_NO_AFALGENG\n#endif\n#ifndef OPENSSL_NO_ASAN\n# define OPENSSL_NO_ASAN\n#endif\n#ifndef OPENSSL_NO_ASYNC\n# define OPENSSL_NO_ASYNC\n#endif\n#ifndef OPENSSL_NO_CRYPTO_MDEBUG\n# define OPENSSL_NO_CRYPTO_MDEBUG\n#endif\n#ifndef OPENSSL_NO_CRYPTO_MDEBUG_BACKTRACE\n# define OPENSSL_NO_CRYPTO_MDEBUG_BACKTRACE\n#endif\n#ifndef OPENSSL_NO_DEVCRYPTOENG\n# define OPENSSL_NO_DEVCRYPTOENG\n#endif\n#ifndef OPENSSL_NO_EC_NISTP_64_GCC_128\n# define OPENSSL_NO_EC_NISTP_64_GCC_128\n#endif\n#ifndef OPENSSL_NO_EGD\n# define OPENSSL_NO_EGD\n#endif\n#ifndef OPENSSL_NO_EXTERNAL_TESTS\n# define OPENSSL_NO_EXTERNAL_TESTS\n#endif\n#ifndef OPENSSL_NO_FUZZ_AFL\n# define OPENSSL_NO_FUZZ_AFL\n#endif\n#ifndef OPENSSL_NO_FUZZ_LIBFUZZER\n# define OPENSSL_NO_FUZZ_LIBFUZZER\n#endif\n#ifndef OPENSSL_NO_HEARTBEATS\n# define OPENSSL_NO_HEARTBEATS\n#endif\n#ifndef OPENSSL_NO_MSAN\n# define OPENSSL_NO_MSAN\n#endif\n#ifndef OPENSSL_NO_SCTP\n# define OPENSSL_NO_SCTP\n#endif\n#ifndef OPENSSL_NO_SSL_TRACE\n# define OPENSSL_NO_SSL_TRACE\n#endif\n#ifndef OPENSSL_NO_SSL3\n# define OPENSSL_NO_SSL3\n#endif\n#ifndef OPENSSL_NO_SSL3_METHOD\n# define OPENSSL_NO_SSL3_METHOD\n#endif\n#ifndef OPENSSL_NO_TESTS\n# define OPENSSL_NO_TESTS\n#endif\n#ifndef OPENSSL_NO_UBSAN\n# define OPENSSL_NO_UBSAN\n#endif\n#ifndef OPENSSL_NO_UNIT_TEST\n# define OPENSSL_NO_UNIT_TEST\n#endif\n#ifndef OPENSSL_NO_WEAK_SSL_CIPHERS\n# define OPENSSL_NO_WEAK_SSL_CIPHERS\n#endif\n#ifndef OPENSSL_NO_DYNAMIC_ENGINE\n# define OPENSSL_NO_DYNAMIC_ENGINE\n#endif\n\n\n/*\n * Sometimes OPENSSSL_NO_xxx ends up with an empty file and some compilers\n * don't like that.  This will hopefully silence them.\n */\n#define NON_EMPTY_TRANSLATION_UNIT static void *dummy = &dummy;\n\n/*\n * Applications should use -DOPENSSL_API_COMPAT=<version> to suppress the\n * declarations of functions deprecated in or before <version>. Otherwise, they\n * still won't see them if the library has been built to disable deprecated\n * functions.\n */\n#ifndef DECLARE_DEPRECATED\n# define DECLARE_DEPRECATED(f)   f;\n# ifdef __GNUC__\n#  if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ > 0)\n#   undef DECLARE_DEPRECATED\n#   define DECLARE_DEPRECATED(f)    f __attribute__ ((deprecated));\n#  endif\n# elif defined(__SUNPRO_C)\n#  if (__SUNPRO_C >= 0x5130)\n#   undef DECLARE_DEPRECATED\n#   define DECLARE_DEPRECATED(f)    f __attribute__ ((deprecated));\n#  endif\n# endif\n#endif\n\n#ifndef OPENSSL_FILE\n# ifdef OPENSSL_NO_FILENAMES\n#  define OPENSSL_FILE \"\"\n#  define OPENSSL_LINE 0\n# else\n#  define OPENSSL_FILE __FILE__\n#  define OPENSSL_LINE __LINE__\n# endif\n#endif\n\n#ifndef OPENSSL_MIN_API\n# define OPENSSL_MIN_API 0\n#endif\n\n#if !defined(OPENSSL_API_COMPAT) || OPENSSL_API_COMPAT < OPENSSL_MIN_API\n# undef OPENSSL_API_COMPAT\n# define OPENSSL_API_COMPAT OPENSSL_MIN_API\n#endif\n\n/*\n * Do not deprecate things to be deprecated in version 1.2.0 before the\n * OpenSSL version number matches.\n */\n#if OPENSSL_VERSION_NUMBER < 0x10200000L\n# define DEPRECATEDIN_1_2_0(f)   f;\n#elif OPENSSL_API_COMPAT < 0x10200000L\n# define DEPRECATEDIN_1_2_0(f)   DECLARE_DEPRECATED(f)\n#else\n# define DEPRECATEDIN_1_2_0(f)\n#endif\n\n#if OPENSSL_API_COMPAT < 0x10100000L\n# define DEPRECATEDIN_1_1_0(f)   DECLARE_DEPRECATED(f)\n#else\n# define DEPRECATEDIN_1_1_0(f)\n#endif\n\n#if OPENSSL_API_COMPAT < 0x10000000L\n# define DEPRECATEDIN_1_0_0(f)   DECLARE_DEPRECATED(f)\n#else\n# define DEPRECATEDIN_1_0_0(f)\n#endif\n\n#if OPENSSL_API_COMPAT < 0x00908000L\n# define DEPRECATEDIN_0_9_8(f)   DECLARE_DEPRECATED(f)\n#else\n# define DEPRECATEDIN_0_9_8(f)\n#endif\n\n/* Generate 80386 code? */\n#undef I386_ONLY\n\n#undef OPENSSL_UNISTD\n#define OPENSSL_UNISTD <unistd.h>\n\n#undef OPENSSL_EXPORT_VAR_AS_FUNCTION\n\n/*\n * The following are cipher-specific, but are part of the public API.\n */\n#if !defined(OPENSSL_SYS_UEFI)\n# undef BN_LLONG\n/* Only one for the following should be defined */\n# define SIXTY_FOUR_BIT_LONG\n# undef SIXTY_FOUR_BIT\n# undef THIRTY_TWO_BIT\n#endif\n\n#define RC4_INT unsigned int\n\n#ifdef  __cplusplus\n}\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/include/openssl/opensslconf_macos_x86_64.h",
    "content": "/*\n * WARNING: do not edit!\n * Generated by Makefile from include/openssl/opensslconf.h.in\n *\n * Copyright 2016-2020 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#include <openssl/opensslv.h>\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n#ifdef OPENSSL_ALGORITHM_DEFINES\n# error OPENSSL_ALGORITHM_DEFINES no longer supported\n#endif\n\n/*\n * OpenSSL was configured with the following options:\n */\n\n#ifndef OPENSSL_SYS_MacOSX\n# define OPENSSL_SYS_MacOSX 1\n#endif\n#ifndef OPENSSL_NO_MD2\n# define OPENSSL_NO_MD2\n#endif\n#ifndef OPENSSL_NO_RC5\n# define OPENSSL_NO_RC5\n#endif\n#ifndef OPENSSL_THREADS\n# define OPENSSL_THREADS\n#endif\n#ifndef OPENSSL_RAND_SEED_OS\n# define OPENSSL_RAND_SEED_OS\n#endif\n#ifndef OPENSSL_NO_AFALGENG\n# define OPENSSL_NO_AFALGENG\n#endif\n#ifndef OPENSSL_NO_ASAN\n# define OPENSSL_NO_ASAN\n#endif\n#ifndef OPENSSL_NO_ASYNC\n# define OPENSSL_NO_ASYNC\n#endif\n#ifndef OPENSSL_NO_CRYPTO_MDEBUG\n# define OPENSSL_NO_CRYPTO_MDEBUG\n#endif\n#ifndef OPENSSL_NO_CRYPTO_MDEBUG_BACKTRACE\n# define OPENSSL_NO_CRYPTO_MDEBUG_BACKTRACE\n#endif\n#ifndef OPENSSL_NO_DEVCRYPTOENG\n# define OPENSSL_NO_DEVCRYPTOENG\n#endif\n#ifndef OPENSSL_NO_EC_NISTP_64_GCC_128\n# define OPENSSL_NO_EC_NISTP_64_GCC_128\n#endif\n#ifndef OPENSSL_NO_EGD\n# define OPENSSL_NO_EGD\n#endif\n#ifndef OPENSSL_NO_EXTERNAL_TESTS\n# define OPENSSL_NO_EXTERNAL_TESTS\n#endif\n#ifndef OPENSSL_NO_FUZZ_AFL\n# define OPENSSL_NO_FUZZ_AFL\n#endif\n#ifndef OPENSSL_NO_FUZZ_LIBFUZZER\n# define OPENSSL_NO_FUZZ_LIBFUZZER\n#endif\n#ifndef OPENSSL_NO_HEARTBEATS\n# define OPENSSL_NO_HEARTBEATS\n#endif\n#ifndef OPENSSL_NO_MSAN\n# define OPENSSL_NO_MSAN\n#endif\n#ifndef OPENSSL_NO_SCTP\n# define OPENSSL_NO_SCTP\n#endif\n#ifndef OPENSSL_NO_SSL_TRACE\n# define OPENSSL_NO_SSL_TRACE\n#endif\n#ifndef OPENSSL_NO_SSL3\n# define OPENSSL_NO_SSL3\n#endif\n#ifndef OPENSSL_NO_SSL3_METHOD\n# define OPENSSL_NO_SSL3_METHOD\n#endif\n#ifndef OPENSSL_NO_TESTS\n# define OPENSSL_NO_TESTS\n#endif\n#ifndef OPENSSL_NO_UBSAN\n# define OPENSSL_NO_UBSAN\n#endif\n#ifndef OPENSSL_NO_UNIT_TEST\n# define OPENSSL_NO_UNIT_TEST\n#endif\n#ifndef OPENSSL_NO_WEAK_SSL_CIPHERS\n# define OPENSSL_NO_WEAK_SSL_CIPHERS\n#endif\n#ifndef OPENSSL_NO_DYNAMIC_ENGINE\n# define OPENSSL_NO_DYNAMIC_ENGINE\n#endif\n\n\n/*\n * Sometimes OPENSSSL_NO_xxx ends up with an empty file and some compilers\n * don't like that.  This will hopefully silence them.\n */\n#define NON_EMPTY_TRANSLATION_UNIT static void *dummy = &dummy;\n\n/*\n * Applications should use -DOPENSSL_API_COMPAT=<version> to suppress the\n * declarations of functions deprecated in or before <version>. Otherwise, they\n * still won't see them if the library has been built to disable deprecated\n * functions.\n */\n#ifndef DECLARE_DEPRECATED\n# define DECLARE_DEPRECATED(f)   f;\n# ifdef __GNUC__\n#  if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ > 0)\n#   undef DECLARE_DEPRECATED\n#   define DECLARE_DEPRECATED(f)    f __attribute__ ((deprecated));\n#  endif\n# elif defined(__SUNPRO_C)\n#  if (__SUNPRO_C >= 0x5130)\n#   undef DECLARE_DEPRECATED\n#   define DECLARE_DEPRECATED(f)    f __attribute__ ((deprecated));\n#  endif\n# endif\n#endif\n\n#ifndef OPENSSL_FILE\n# ifdef OPENSSL_NO_FILENAMES\n#  define OPENSSL_FILE \"\"\n#  define OPENSSL_LINE 0\n# else\n#  define OPENSSL_FILE __FILE__\n#  define OPENSSL_LINE __LINE__\n# endif\n#endif\n\n#ifndef OPENSSL_MIN_API\n# define OPENSSL_MIN_API 0\n#endif\n\n#if !defined(OPENSSL_API_COMPAT) || OPENSSL_API_COMPAT < OPENSSL_MIN_API\n# undef OPENSSL_API_COMPAT\n# define OPENSSL_API_COMPAT OPENSSL_MIN_API\n#endif\n\n/*\n * Do not deprecate things to be deprecated in version 1.2.0 before the\n * OpenSSL version number matches.\n */\n#if OPENSSL_VERSION_NUMBER < 0x10200000L\n# define DEPRECATEDIN_1_2_0(f)   f;\n#elif OPENSSL_API_COMPAT < 0x10200000L\n# define DEPRECATEDIN_1_2_0(f)   DECLARE_DEPRECATED(f)\n#else\n# define DEPRECATEDIN_1_2_0(f)\n#endif\n\n#if OPENSSL_API_COMPAT < 0x10100000L\n# define DEPRECATEDIN_1_1_0(f)   DECLARE_DEPRECATED(f)\n#else\n# define DEPRECATEDIN_1_1_0(f)\n#endif\n\n#if OPENSSL_API_COMPAT < 0x10000000L\n# define DEPRECATEDIN_1_0_0(f)   DECLARE_DEPRECATED(f)\n#else\n# define DEPRECATEDIN_1_0_0(f)\n#endif\n\n#if OPENSSL_API_COMPAT < 0x00908000L\n# define DEPRECATEDIN_0_9_8(f)   DECLARE_DEPRECATED(f)\n#else\n# define DEPRECATEDIN_0_9_8(f)\n#endif\n\n/* Generate 80386 code? */\n#undef I386_ONLY\n\n#undef OPENSSL_UNISTD\n#define OPENSSL_UNISTD <unistd.h>\n\n#undef OPENSSL_EXPORT_VAR_AS_FUNCTION\n\n/*\n * The following are cipher-specific, but are part of the public API.\n */\n#if !defined(OPENSSL_SYS_UEFI)\n# undef BN_LLONG\n/* Only one for the following should be defined */\n# define SIXTY_FOUR_BIT_LONG\n# undef SIXTY_FOUR_BIT\n# undef THIRTY_TWO_BIT\n#endif\n\n#define RC4_INT unsigned int\n\n#ifdef  __cplusplus\n}\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/include/openssl/opensslconf_watchos_arm64_32.h",
    "content": "/*\n * WARNING: do not edit!\n * Generated by Makefile from include/openssl/opensslconf.h.in\n *\n * Copyright 2016-2020 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#include <openssl/opensslv.h>\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n#ifdef OPENSSL_ALGORITHM_DEFINES\n# error OPENSSL_ALGORITHM_DEFINES no longer supported\n#endif\n\n/*\n * OpenSSL was configured with the following options:\n */\n\n#ifndef OPENSSL_SYS_WatchOS\n# define OPENSSL_SYS_WatchOS 1\n#endif\n#ifndef OPENSSL_NO_MD2\n# define OPENSSL_NO_MD2\n#endif\n#ifndef OPENSSL_NO_RC5\n# define OPENSSL_NO_RC5\n#endif\n#ifndef OPENSSL_THREADS\n# define OPENSSL_THREADS\n#endif\n#ifndef OPENSSL_RAND_SEED_OS\n# define OPENSSL_RAND_SEED_OS\n#endif\n#ifndef OPENSSL_NO_AFALGENG\n# define OPENSSL_NO_AFALGENG\n#endif\n#ifndef OPENSSL_NO_ASAN\n# define OPENSSL_NO_ASAN\n#endif\n#ifndef OPENSSL_NO_ASYNC\n# define OPENSSL_NO_ASYNC\n#endif\n#ifndef OPENSSL_NO_CRYPTO_MDEBUG\n# define OPENSSL_NO_CRYPTO_MDEBUG\n#endif\n#ifndef OPENSSL_NO_CRYPTO_MDEBUG_BACKTRACE\n# define OPENSSL_NO_CRYPTO_MDEBUG_BACKTRACE\n#endif\n#ifndef OPENSSL_NO_DEVCRYPTOENG\n# define OPENSSL_NO_DEVCRYPTOENG\n#endif\n#ifndef OPENSSL_NO_EC_NISTP_64_GCC_128\n# define OPENSSL_NO_EC_NISTP_64_GCC_128\n#endif\n#ifndef OPENSSL_NO_EGD\n# define OPENSSL_NO_EGD\n#endif\n#ifndef OPENSSL_NO_EXTERNAL_TESTS\n# define OPENSSL_NO_EXTERNAL_TESTS\n#endif\n#ifndef OPENSSL_NO_FUZZ_AFL\n# define OPENSSL_NO_FUZZ_AFL\n#endif\n#ifndef OPENSSL_NO_FUZZ_LIBFUZZER\n# define OPENSSL_NO_FUZZ_LIBFUZZER\n#endif\n#ifndef OPENSSL_NO_HEARTBEATS\n# define OPENSSL_NO_HEARTBEATS\n#endif\n#ifndef OPENSSL_NO_MSAN\n# define OPENSSL_NO_MSAN\n#endif\n#ifndef OPENSSL_NO_SCTP\n# define OPENSSL_NO_SCTP\n#endif\n#ifndef OPENSSL_NO_SSL_TRACE\n# define OPENSSL_NO_SSL_TRACE\n#endif\n#ifndef OPENSSL_NO_SSL3\n# define OPENSSL_NO_SSL3\n#endif\n#ifndef OPENSSL_NO_SSL3_METHOD\n# define OPENSSL_NO_SSL3_METHOD\n#endif\n#ifndef OPENSSL_NO_TESTS\n# define OPENSSL_NO_TESTS\n#endif\n#ifndef OPENSSL_NO_UBSAN\n# define OPENSSL_NO_UBSAN\n#endif\n#ifndef OPENSSL_NO_UNIT_TEST\n# define OPENSSL_NO_UNIT_TEST\n#endif\n#ifndef OPENSSL_NO_WEAK_SSL_CIPHERS\n# define OPENSSL_NO_WEAK_SSL_CIPHERS\n#endif\n#ifndef OPENSSL_NO_DYNAMIC_ENGINE\n# define OPENSSL_NO_DYNAMIC_ENGINE\n#endif\n\n\n/*\n * Sometimes OPENSSSL_NO_xxx ends up with an empty file and some compilers\n * don't like that.  This will hopefully silence them.\n */\n#define NON_EMPTY_TRANSLATION_UNIT static void *dummy = &dummy;\n\n/*\n * Applications should use -DOPENSSL_API_COMPAT=<version> to suppress the\n * declarations of functions deprecated in or before <version>. Otherwise, they\n * still won't see them if the library has been built to disable deprecated\n * functions.\n */\n#ifndef DECLARE_DEPRECATED\n# define DECLARE_DEPRECATED(f)   f;\n# ifdef __GNUC__\n#  if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ > 0)\n#   undef DECLARE_DEPRECATED\n#   define DECLARE_DEPRECATED(f)    f __attribute__ ((deprecated));\n#  endif\n# elif defined(__SUNPRO_C)\n#  if (__SUNPRO_C >= 0x5130)\n#   undef DECLARE_DEPRECATED\n#   define DECLARE_DEPRECATED(f)    f __attribute__ ((deprecated));\n#  endif\n# endif\n#endif\n\n#ifndef OPENSSL_FILE\n# ifdef OPENSSL_NO_FILENAMES\n#  define OPENSSL_FILE \"\"\n#  define OPENSSL_LINE 0\n# else\n#  define OPENSSL_FILE __FILE__\n#  define OPENSSL_LINE __LINE__\n# endif\n#endif\n\n#ifndef OPENSSL_MIN_API\n# define OPENSSL_MIN_API 0\n#endif\n\n#if !defined(OPENSSL_API_COMPAT) || OPENSSL_API_COMPAT < OPENSSL_MIN_API\n# undef OPENSSL_API_COMPAT\n# define OPENSSL_API_COMPAT OPENSSL_MIN_API\n#endif\n\n/*\n * Do not deprecate things to be deprecated in version 1.2.0 before the\n * OpenSSL version number matches.\n */\n#if OPENSSL_VERSION_NUMBER < 0x10200000L\n# define DEPRECATEDIN_1_2_0(f)   f;\n#elif OPENSSL_API_COMPAT < 0x10200000L\n# define DEPRECATEDIN_1_2_0(f)   DECLARE_DEPRECATED(f)\n#else\n# define DEPRECATEDIN_1_2_0(f)\n#endif\n\n#if OPENSSL_API_COMPAT < 0x10100000L\n# define DEPRECATEDIN_1_1_0(f)   DECLARE_DEPRECATED(f)\n#else\n# define DEPRECATEDIN_1_1_0(f)\n#endif\n\n#if OPENSSL_API_COMPAT < 0x10000000L\n# define DEPRECATEDIN_1_0_0(f)   DECLARE_DEPRECATED(f)\n#else\n# define DEPRECATEDIN_1_0_0(f)\n#endif\n\n#if OPENSSL_API_COMPAT < 0x00908000L\n# define DEPRECATEDIN_0_9_8(f)   DECLARE_DEPRECATED(f)\n#else\n# define DEPRECATEDIN_0_9_8(f)\n#endif\n\n/* Generate 80386 code? */\n#undef I386_ONLY\n\n#undef OPENSSL_UNISTD\n#define OPENSSL_UNISTD <unistd.h>\n\n#undef OPENSSL_EXPORT_VAR_AS_FUNCTION\n\n/*\n * The following are cipher-specific, but are part of the public API.\n */\n#if !defined(OPENSSL_SYS_UEFI)\n# define BN_LLONG\n/* Only one for the following should be defined */\n# undef SIXTY_FOUR_BIT_LONG\n# undef SIXTY_FOUR_BIT\n# define THIRTY_TWO_BIT\n#endif\n\n#define RC4_INT unsigned char\n\n#ifdef  __cplusplus\n}\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/include/openssl/opensslconf_watchos_armv7k.h",
    "content": "/*\n * WARNING: do not edit!\n * Generated by Makefile from include/openssl/opensslconf.h.in\n *\n * Copyright 2016-2020 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#include <openssl/opensslv.h>\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n#ifdef OPENSSL_ALGORITHM_DEFINES\n# error OPENSSL_ALGORITHM_DEFINES no longer supported\n#endif\n\n/*\n * OpenSSL was configured with the following options:\n */\n\n#ifndef OPENSSL_SYS_WatchOS\n# define OPENSSL_SYS_WatchOS 1\n#endif\n#ifndef OPENSSL_NO_MD2\n# define OPENSSL_NO_MD2\n#endif\n#ifndef OPENSSL_NO_RC5\n# define OPENSSL_NO_RC5\n#endif\n#ifndef OPENSSL_THREADS\n# define OPENSSL_THREADS\n#endif\n#ifndef OPENSSL_RAND_SEED_OS\n# define OPENSSL_RAND_SEED_OS\n#endif\n#ifndef OPENSSL_NO_AFALGENG\n# define OPENSSL_NO_AFALGENG\n#endif\n#ifndef OPENSSL_NO_ASAN\n# define OPENSSL_NO_ASAN\n#endif\n#ifndef OPENSSL_NO_ASYNC\n# define OPENSSL_NO_ASYNC\n#endif\n#ifndef OPENSSL_NO_CRYPTO_MDEBUG\n# define OPENSSL_NO_CRYPTO_MDEBUG\n#endif\n#ifndef OPENSSL_NO_CRYPTO_MDEBUG_BACKTRACE\n# define OPENSSL_NO_CRYPTO_MDEBUG_BACKTRACE\n#endif\n#ifndef OPENSSL_NO_DEVCRYPTOENG\n# define OPENSSL_NO_DEVCRYPTOENG\n#endif\n#ifndef OPENSSL_NO_EC_NISTP_64_GCC_128\n# define OPENSSL_NO_EC_NISTP_64_GCC_128\n#endif\n#ifndef OPENSSL_NO_EGD\n# define OPENSSL_NO_EGD\n#endif\n#ifndef OPENSSL_NO_EXTERNAL_TESTS\n# define OPENSSL_NO_EXTERNAL_TESTS\n#endif\n#ifndef OPENSSL_NO_FUZZ_AFL\n# define OPENSSL_NO_FUZZ_AFL\n#endif\n#ifndef OPENSSL_NO_FUZZ_LIBFUZZER\n# define OPENSSL_NO_FUZZ_LIBFUZZER\n#endif\n#ifndef OPENSSL_NO_HEARTBEATS\n# define OPENSSL_NO_HEARTBEATS\n#endif\n#ifndef OPENSSL_NO_MSAN\n# define OPENSSL_NO_MSAN\n#endif\n#ifndef OPENSSL_NO_SCTP\n# define OPENSSL_NO_SCTP\n#endif\n#ifndef OPENSSL_NO_SSL_TRACE\n# define OPENSSL_NO_SSL_TRACE\n#endif\n#ifndef OPENSSL_NO_SSL3\n# define OPENSSL_NO_SSL3\n#endif\n#ifndef OPENSSL_NO_SSL3_METHOD\n# define OPENSSL_NO_SSL3_METHOD\n#endif\n#ifndef OPENSSL_NO_TESTS\n# define OPENSSL_NO_TESTS\n#endif\n#ifndef OPENSSL_NO_UBSAN\n# define OPENSSL_NO_UBSAN\n#endif\n#ifndef OPENSSL_NO_UNIT_TEST\n# define OPENSSL_NO_UNIT_TEST\n#endif\n#ifndef OPENSSL_NO_WEAK_SSL_CIPHERS\n# define OPENSSL_NO_WEAK_SSL_CIPHERS\n#endif\n#ifndef OPENSSL_NO_DYNAMIC_ENGINE\n# define OPENSSL_NO_DYNAMIC_ENGINE\n#endif\n\n\n/*\n * Sometimes OPENSSSL_NO_xxx ends up with an empty file and some compilers\n * don't like that.  This will hopefully silence them.\n */\n#define NON_EMPTY_TRANSLATION_UNIT static void *dummy = &dummy;\n\n/*\n * Applications should use -DOPENSSL_API_COMPAT=<version> to suppress the\n * declarations of functions deprecated in or before <version>. Otherwise, they\n * still won't see them if the library has been built to disable deprecated\n * functions.\n */\n#ifndef DECLARE_DEPRECATED\n# define DECLARE_DEPRECATED(f)   f;\n# ifdef __GNUC__\n#  if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ > 0)\n#   undef DECLARE_DEPRECATED\n#   define DECLARE_DEPRECATED(f)    f __attribute__ ((deprecated));\n#  endif\n# elif defined(__SUNPRO_C)\n#  if (__SUNPRO_C >= 0x5130)\n#   undef DECLARE_DEPRECATED\n#   define DECLARE_DEPRECATED(f)    f __attribute__ ((deprecated));\n#  endif\n# endif\n#endif\n\n#ifndef OPENSSL_FILE\n# ifdef OPENSSL_NO_FILENAMES\n#  define OPENSSL_FILE \"\"\n#  define OPENSSL_LINE 0\n# else\n#  define OPENSSL_FILE __FILE__\n#  define OPENSSL_LINE __LINE__\n# endif\n#endif\n\n#ifndef OPENSSL_MIN_API\n# define OPENSSL_MIN_API 0\n#endif\n\n#if !defined(OPENSSL_API_COMPAT) || OPENSSL_API_COMPAT < OPENSSL_MIN_API\n# undef OPENSSL_API_COMPAT\n# define OPENSSL_API_COMPAT OPENSSL_MIN_API\n#endif\n\n/*\n * Do not deprecate things to be deprecated in version 1.2.0 before the\n * OpenSSL version number matches.\n */\n#if OPENSSL_VERSION_NUMBER < 0x10200000L\n# define DEPRECATEDIN_1_2_0(f)   f;\n#elif OPENSSL_API_COMPAT < 0x10200000L\n# define DEPRECATEDIN_1_2_0(f)   DECLARE_DEPRECATED(f)\n#else\n# define DEPRECATEDIN_1_2_0(f)\n#endif\n\n#if OPENSSL_API_COMPAT < 0x10100000L\n# define DEPRECATEDIN_1_1_0(f)   DECLARE_DEPRECATED(f)\n#else\n# define DEPRECATEDIN_1_1_0(f)\n#endif\n\n#if OPENSSL_API_COMPAT < 0x10000000L\n# define DEPRECATEDIN_1_0_0(f)   DECLARE_DEPRECATED(f)\n#else\n# define DEPRECATEDIN_1_0_0(f)\n#endif\n\n#if OPENSSL_API_COMPAT < 0x00908000L\n# define DEPRECATEDIN_0_9_8(f)   DECLARE_DEPRECATED(f)\n#else\n# define DEPRECATEDIN_0_9_8(f)\n#endif\n\n/* Generate 80386 code? */\n#undef I386_ONLY\n\n#undef OPENSSL_UNISTD\n#define OPENSSL_UNISTD <unistd.h>\n\n#undef OPENSSL_EXPORT_VAR_AS_FUNCTION\n\n/*\n * The following are cipher-specific, but are part of the public API.\n */\n#if !defined(OPENSSL_SYS_UEFI)\n# define BN_LLONG\n/* Only one for the following should be defined */\n# undef SIXTY_FOUR_BIT_LONG\n# undef SIXTY_FOUR_BIT\n# define THIRTY_TWO_BIT\n#endif\n\n#define RC4_INT unsigned char\n\n#ifdef  __cplusplus\n}\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/include/openssl/opensslconf_watchos_sim_i386.h",
    "content": "/*\n * WARNING: do not edit!\n * Generated by Makefile from include/openssl/opensslconf.h.in\n *\n * Copyright 2016-2020 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#include <openssl/opensslv.h>\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n#ifdef OPENSSL_ALGORITHM_DEFINES\n# error OPENSSL_ALGORITHM_DEFINES no longer supported\n#endif\n\n/*\n * OpenSSL was configured with the following options:\n */\n\n#ifndef OPENSSL_SYS_WatchOS\n# define OPENSSL_SYS_WatchOS 1\n#endif\n#ifndef OPENSSL_NO_MD2\n# define OPENSSL_NO_MD2\n#endif\n#ifndef OPENSSL_NO_RC5\n# define OPENSSL_NO_RC5\n#endif\n#ifndef OPENSSL_THREADS\n# define OPENSSL_THREADS\n#endif\n#ifndef OPENSSL_RAND_SEED_OS\n# define OPENSSL_RAND_SEED_OS\n#endif\n#ifndef OPENSSL_NO_AFALGENG\n# define OPENSSL_NO_AFALGENG\n#endif\n#ifndef OPENSSL_NO_ASAN\n# define OPENSSL_NO_ASAN\n#endif\n#ifndef OPENSSL_NO_ASYNC\n# define OPENSSL_NO_ASYNC\n#endif\n#ifndef OPENSSL_NO_CRYPTO_MDEBUG\n# define OPENSSL_NO_CRYPTO_MDEBUG\n#endif\n#ifndef OPENSSL_NO_CRYPTO_MDEBUG_BACKTRACE\n# define OPENSSL_NO_CRYPTO_MDEBUG_BACKTRACE\n#endif\n#ifndef OPENSSL_NO_DEVCRYPTOENG\n# define OPENSSL_NO_DEVCRYPTOENG\n#endif\n#ifndef OPENSSL_NO_EC_NISTP_64_GCC_128\n# define OPENSSL_NO_EC_NISTP_64_GCC_128\n#endif\n#ifndef OPENSSL_NO_EGD\n# define OPENSSL_NO_EGD\n#endif\n#ifndef OPENSSL_NO_EXTERNAL_TESTS\n# define OPENSSL_NO_EXTERNAL_TESTS\n#endif\n#ifndef OPENSSL_NO_FUZZ_AFL\n# define OPENSSL_NO_FUZZ_AFL\n#endif\n#ifndef OPENSSL_NO_FUZZ_LIBFUZZER\n# define OPENSSL_NO_FUZZ_LIBFUZZER\n#endif\n#ifndef OPENSSL_NO_HEARTBEATS\n# define OPENSSL_NO_HEARTBEATS\n#endif\n#ifndef OPENSSL_NO_MSAN\n# define OPENSSL_NO_MSAN\n#endif\n#ifndef OPENSSL_NO_SCTP\n# define OPENSSL_NO_SCTP\n#endif\n#ifndef OPENSSL_NO_SSL_TRACE\n# define OPENSSL_NO_SSL_TRACE\n#endif\n#ifndef OPENSSL_NO_SSL3\n# define OPENSSL_NO_SSL3\n#endif\n#ifndef OPENSSL_NO_SSL3_METHOD\n# define OPENSSL_NO_SSL3_METHOD\n#endif\n#ifndef OPENSSL_NO_TESTS\n# define OPENSSL_NO_TESTS\n#endif\n#ifndef OPENSSL_NO_UBSAN\n# define OPENSSL_NO_UBSAN\n#endif\n#ifndef OPENSSL_NO_UNIT_TEST\n# define OPENSSL_NO_UNIT_TEST\n#endif\n#ifndef OPENSSL_NO_WEAK_SSL_CIPHERS\n# define OPENSSL_NO_WEAK_SSL_CIPHERS\n#endif\n#ifndef OPENSSL_NO_DYNAMIC_ENGINE\n# define OPENSSL_NO_DYNAMIC_ENGINE\n#endif\n\n\n/*\n * Sometimes OPENSSSL_NO_xxx ends up with an empty file and some compilers\n * don't like that.  This will hopefully silence them.\n */\n#define NON_EMPTY_TRANSLATION_UNIT static void *dummy = &dummy;\n\n/*\n * Applications should use -DOPENSSL_API_COMPAT=<version> to suppress the\n * declarations of functions deprecated in or before <version>. Otherwise, they\n * still won't see them if the library has been built to disable deprecated\n * functions.\n */\n#ifndef DECLARE_DEPRECATED\n# define DECLARE_DEPRECATED(f)   f;\n# ifdef __GNUC__\n#  if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ > 0)\n#   undef DECLARE_DEPRECATED\n#   define DECLARE_DEPRECATED(f)    f __attribute__ ((deprecated));\n#  endif\n# elif defined(__SUNPRO_C)\n#  if (__SUNPRO_C >= 0x5130)\n#   undef DECLARE_DEPRECATED\n#   define DECLARE_DEPRECATED(f)    f __attribute__ ((deprecated));\n#  endif\n# endif\n#endif\n\n#ifndef OPENSSL_FILE\n# ifdef OPENSSL_NO_FILENAMES\n#  define OPENSSL_FILE \"\"\n#  define OPENSSL_LINE 0\n# else\n#  define OPENSSL_FILE __FILE__\n#  define OPENSSL_LINE __LINE__\n# endif\n#endif\n\n#ifndef OPENSSL_MIN_API\n# define OPENSSL_MIN_API 0\n#endif\n\n#if !defined(OPENSSL_API_COMPAT) || OPENSSL_API_COMPAT < OPENSSL_MIN_API\n# undef OPENSSL_API_COMPAT\n# define OPENSSL_API_COMPAT OPENSSL_MIN_API\n#endif\n\n/*\n * Do not deprecate things to be deprecated in version 1.2.0 before the\n * OpenSSL version number matches.\n */\n#if OPENSSL_VERSION_NUMBER < 0x10200000L\n# define DEPRECATEDIN_1_2_0(f)   f;\n#elif OPENSSL_API_COMPAT < 0x10200000L\n# define DEPRECATEDIN_1_2_0(f)   DECLARE_DEPRECATED(f)\n#else\n# define DEPRECATEDIN_1_2_0(f)\n#endif\n\n#if OPENSSL_API_COMPAT < 0x10100000L\n# define DEPRECATEDIN_1_1_0(f)   DECLARE_DEPRECATED(f)\n#else\n# define DEPRECATEDIN_1_1_0(f)\n#endif\n\n#if OPENSSL_API_COMPAT < 0x10000000L\n# define DEPRECATEDIN_1_0_0(f)   DECLARE_DEPRECATED(f)\n#else\n# define DEPRECATEDIN_1_0_0(f)\n#endif\n\n#if OPENSSL_API_COMPAT < 0x00908000L\n# define DEPRECATEDIN_0_9_8(f)   DECLARE_DEPRECATED(f)\n#else\n# define DEPRECATEDIN_0_9_8(f)\n#endif\n\n/* Generate 80386 code? */\n#undef I386_ONLY\n\n#undef OPENSSL_UNISTD\n#define OPENSSL_UNISTD <unistd.h>\n\n#undef OPENSSL_EXPORT_VAR_AS_FUNCTION\n\n/*\n * The following are cipher-specific, but are part of the public API.\n */\n#if !defined(OPENSSL_SYS_UEFI)\n# define BN_LLONG\n/* Only one for the following should be defined */\n# undef SIXTY_FOUR_BIT_LONG\n# undef SIXTY_FOUR_BIT\n# define THIRTY_TWO_BIT\n#endif\n\n#define RC4_INT unsigned char\n\n#ifdef  __cplusplus\n}\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/include/openssl/opensslconf_watchos_sim_x86_64.h",
    "content": "/*\n * WARNING: do not edit!\n * Generated by Makefile from include/openssl/opensslconf.h.in\n *\n * Copyright 2016-2020 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#include <openssl/opensslv.h>\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n#ifdef OPENSSL_ALGORITHM_DEFINES\n# error OPENSSL_ALGORITHM_DEFINES no longer supported\n#endif\n\n/*\n * OpenSSL was configured with the following options:\n */\n\n#ifndef OPENSSL_SYS_iOS\n# define OPENSSL_SYS_iOS 1\n#endif\n#ifndef OPENSSL_NO_MD2\n# define OPENSSL_NO_MD2\n#endif\n#ifndef OPENSSL_NO_RC5\n# define OPENSSL_NO_RC5\n#endif\n#ifndef OPENSSL_THREADS\n# define OPENSSL_THREADS\n#endif\n#ifndef OPENSSL_RAND_SEED_OS\n# define OPENSSL_RAND_SEED_OS\n#endif\n#ifndef OPENSSL_NO_AFALGENG\n# define OPENSSL_NO_AFALGENG\n#endif\n#ifndef OPENSSL_NO_ASAN\n# define OPENSSL_NO_ASAN\n#endif\n#ifndef OPENSSL_NO_ASM\n# define OPENSSL_NO_ASM\n#endif\n#ifndef OPENSSL_NO_ASYNC\n# define OPENSSL_NO_ASYNC\n#endif\n#ifndef OPENSSL_NO_CRYPTO_MDEBUG\n# define OPENSSL_NO_CRYPTO_MDEBUG\n#endif\n#ifndef OPENSSL_NO_CRYPTO_MDEBUG_BACKTRACE\n# define OPENSSL_NO_CRYPTO_MDEBUG_BACKTRACE\n#endif\n#ifndef OPENSSL_NO_DEVCRYPTOENG\n# define OPENSSL_NO_DEVCRYPTOENG\n#endif\n#ifndef OPENSSL_NO_EGD\n# define OPENSSL_NO_EGD\n#endif\n#ifndef OPENSSL_NO_ENGINE\n# define OPENSSL_NO_ENGINE\n#endif\n#ifndef OPENSSL_NO_EXTERNAL_TESTS\n# define OPENSSL_NO_EXTERNAL_TESTS\n#endif\n#ifndef OPENSSL_NO_FUZZ_AFL\n# define OPENSSL_NO_FUZZ_AFL\n#endif\n#ifndef OPENSSL_NO_FUZZ_LIBFUZZER\n# define OPENSSL_NO_FUZZ_LIBFUZZER\n#endif\n#ifndef OPENSSL_NO_HEARTBEATS\n# define OPENSSL_NO_HEARTBEATS\n#endif\n#ifndef OPENSSL_NO_HW\n# define OPENSSL_NO_HW\n#endif\n#ifndef OPENSSL_NO_MSAN\n# define OPENSSL_NO_MSAN\n#endif\n#ifndef OPENSSL_NO_SCTP\n# define OPENSSL_NO_SCTP\n#endif\n#ifndef OPENSSL_NO_SSL_TRACE\n# define OPENSSL_NO_SSL_TRACE\n#endif\n#ifndef OPENSSL_NO_SSL3\n# define OPENSSL_NO_SSL3\n#endif\n#ifndef OPENSSL_NO_SSL3_METHOD\n# define OPENSSL_NO_SSL3_METHOD\n#endif\n#ifndef OPENSSL_NO_UBSAN\n# define OPENSSL_NO_UBSAN\n#endif\n#ifndef OPENSSL_NO_UNIT_TEST\n# define OPENSSL_NO_UNIT_TEST\n#endif\n#ifndef OPENSSL_NO_WEAK_SSL_CIPHERS\n# define OPENSSL_NO_WEAK_SSL_CIPHERS\n#endif\n#ifndef OPENSSL_NO_DYNAMIC_ENGINE\n# define OPENSSL_NO_DYNAMIC_ENGINE\n#endif\n\n\n/*\n * Sometimes OPENSSSL_NO_xxx ends up with an empty file and some compilers\n * don't like that.  This will hopefully silence them.\n */\n#define NON_EMPTY_TRANSLATION_UNIT static void *dummy = &dummy;\n\n/*\n * Applications should use -DOPENSSL_API_COMPAT=<version> to suppress the\n * declarations of functions deprecated in or before <version>. Otherwise, they\n * still won't see them if the library has been built to disable deprecated\n * functions.\n */\n#ifndef DECLARE_DEPRECATED\n# define DECLARE_DEPRECATED(f)   f;\n# ifdef __GNUC__\n#  if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ > 0)\n#   undef DECLARE_DEPRECATED\n#   define DECLARE_DEPRECATED(f)    f __attribute__ ((deprecated));\n#  endif\n# elif defined(__SUNPRO_C)\n#  if (__SUNPRO_C >= 0x5130)\n#   undef DECLARE_DEPRECATED\n#   define DECLARE_DEPRECATED(f)    f __attribute__ ((deprecated));\n#  endif\n# endif\n#endif\n\n#ifndef OPENSSL_FILE\n# ifdef OPENSSL_NO_FILENAMES\n#  define OPENSSL_FILE \"\"\n#  define OPENSSL_LINE 0\n# else\n#  define OPENSSL_FILE __FILE__\n#  define OPENSSL_LINE __LINE__\n# endif\n#endif\n\n#ifndef OPENSSL_MIN_API\n# define OPENSSL_MIN_API 0\n#endif\n\n#if !defined(OPENSSL_API_COMPAT) || OPENSSL_API_COMPAT < OPENSSL_MIN_API\n# undef OPENSSL_API_COMPAT\n# define OPENSSL_API_COMPAT OPENSSL_MIN_API\n#endif\n\n/*\n * Do not deprecate things to be deprecated in version 1.2.0 before the\n * OpenSSL version number matches.\n */\n#if OPENSSL_VERSION_NUMBER < 0x10200000L\n# define DEPRECATEDIN_1_2_0(f)   f;\n#elif OPENSSL_API_COMPAT < 0x10200000L\n# define DEPRECATEDIN_1_2_0(f)   DECLARE_DEPRECATED(f)\n#else\n# define DEPRECATEDIN_1_2_0(f)\n#endif\n\n#if OPENSSL_API_COMPAT < 0x10100000L\n# define DEPRECATEDIN_1_1_0(f)   DECLARE_DEPRECATED(f)\n#else\n# define DEPRECATEDIN_1_1_0(f)\n#endif\n\n#if OPENSSL_API_COMPAT < 0x10000000L\n# define DEPRECATEDIN_1_0_0(f)   DECLARE_DEPRECATED(f)\n#else\n# define DEPRECATEDIN_1_0_0(f)\n#endif\n\n#if OPENSSL_API_COMPAT < 0x00908000L\n# define DEPRECATEDIN_0_9_8(f)   DECLARE_DEPRECATED(f)\n#else\n# define DEPRECATEDIN_0_9_8(f)\n#endif\n\n/* Generate 80386 code? */\n#undef I386_ONLY\n\n#undef OPENSSL_UNISTD\n#define OPENSSL_UNISTD <unistd.h>\n\n#undef OPENSSL_EXPORT_VAR_AS_FUNCTION\n\n/*\n * The following are cipher-specific, but are part of the public API.\n */\n#if !defined(OPENSSL_SYS_UEFI)\n# define BN_LLONG\n/* Only one for the following should be defined */\n# undef SIXTY_FOUR_BIT_LONG\n# undef SIXTY_FOUR_BIT\n# define THIRTY_TWO_BIT\n#endif\n\n#define RC4_INT unsigned char\n\n#ifdef  __cplusplus\n}\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/include/openssl/opensslconf_windows-x86.h",
    "content": "/*\r\n * WARNING: do not edit!\r\n * Generated by makefile from include\\openssl\\opensslconf.h.in\r\n *\r\n * Copyright 2016-2020 The OpenSSL Project Authors. All Rights Reserved.\r\n *\r\n * Licensed under the OpenSSL license (the \"License\").  You may not use\r\n * this file except in compliance with the License.  You can obtain a copy\r\n * in the file LICENSE in the source distribution or at\r\n * https://www.openssl.org/source/license.html\r\n */\r\n\r\n#include <openssl/opensslv.h>\r\n\r\n#ifdef  __cplusplus\r\nextern \"C\" {\r\n#endif\r\n\r\n#ifdef OPENSSL_ALGORITHM_DEFINES\r\n# error OPENSSL_ALGORITHM_DEFINES no longer supported\r\n#endif\r\n\r\n/*\r\n * OpenSSL was configured with the following options:\r\n */\r\n\r\n#ifndef OPENSSL_SYS_WIN32\r\n# define OPENSSL_SYS_WIN32 1\r\n#endif\r\n#ifndef OPENSSL_NO_MD2\r\n# define OPENSSL_NO_MD2\r\n#endif\r\n#ifndef OPENSSL_NO_RC5\r\n# define OPENSSL_NO_RC5\r\n#endif\r\n#ifndef OPENSSL_THREADS\r\n# define OPENSSL_THREADS\r\n#endif\r\n#ifndef OPENSSL_RAND_SEED_OS\r\n# define OPENSSL_RAND_SEED_OS\r\n#endif\r\n#ifndef OPENSSL_NO_AFALGENG\r\n# define OPENSSL_NO_AFALGENG\r\n#endif\r\n#ifndef OPENSSL_NO_ASAN\r\n# define OPENSSL_NO_ASAN\r\n#endif\r\n#ifndef OPENSSL_NO_ASM\r\n# define OPENSSL_NO_ASM\r\n#endif\r\n#ifndef OPENSSL_NO_CRYPTO_MDEBUG\r\n# define OPENSSL_NO_CRYPTO_MDEBUG\r\n#endif\r\n#ifndef OPENSSL_NO_CRYPTO_MDEBUG_BACKTRACE\r\n# define OPENSSL_NO_CRYPTO_MDEBUG_BACKTRACE\r\n#endif\r\n#ifndef OPENSSL_NO_DEVCRYPTOENG\r\n# define OPENSSL_NO_DEVCRYPTOENG\r\n#endif\r\n#ifndef OPENSSL_NO_EC_NISTP_64_GCC_128\r\n# define OPENSSL_NO_EC_NISTP_64_GCC_128\r\n#endif\r\n#ifndef OPENSSL_NO_EGD\r\n# define OPENSSL_NO_EGD\r\n#endif\r\n#ifndef OPENSSL_NO_EXTERNAL_TESTS\r\n# define OPENSSL_NO_EXTERNAL_TESTS\r\n#endif\r\n#ifndef OPENSSL_NO_FUZZ_AFL\r\n# define OPENSSL_NO_FUZZ_AFL\r\n#endif\r\n#ifndef OPENSSL_NO_FUZZ_LIBFUZZER\r\n# define OPENSSL_NO_FUZZ_LIBFUZZER\r\n#endif\r\n#ifndef OPENSSL_NO_HEARTBEATS\r\n# define OPENSSL_NO_HEARTBEATS\r\n#endif\r\n#ifndef OPENSSL_NO_MSAN\r\n# define OPENSSL_NO_MSAN\r\n#endif\r\n#ifndef OPENSSL_NO_SCTP\r\n# define OPENSSL_NO_SCTP\r\n#endif\r\n#ifndef OPENSSL_NO_SSL_TRACE\r\n# define OPENSSL_NO_SSL_TRACE\r\n#endif\r\n#ifndef OPENSSL_NO_SSL3\r\n# define OPENSSL_NO_SSL3\r\n#endif\r\n#ifndef OPENSSL_NO_SSL3_METHOD\r\n# define OPENSSL_NO_SSL3_METHOD\r\n#endif\r\n#ifndef OPENSSL_NO_TESTS\r\n# define OPENSSL_NO_TESTS\r\n#endif\r\n#ifndef OPENSSL_NO_UBSAN\r\n# define OPENSSL_NO_UBSAN\r\n#endif\r\n#ifndef OPENSSL_NO_UNIT_TEST\r\n# define OPENSSL_NO_UNIT_TEST\r\n#endif\r\n#ifndef OPENSSL_NO_WEAK_SSL_CIPHERS\r\n# define OPENSSL_NO_WEAK_SSL_CIPHERS\r\n#endif\r\n#ifndef OPENSSL_NO_DYNAMIC_ENGINE\r\n# define OPENSSL_NO_DYNAMIC_ENGINE\r\n#endif\r\n\r\n\r\n/*\r\n * Sometimes OPENSSSL_NO_xxx ends up with an empty file and some compilers\r\n * don't like that.  This will hopefully silence them.\r\n */\r\n#define NON_EMPTY_TRANSLATION_UNIT static void *dummy = &dummy;\r\n\r\n/*\r\n * Applications should use -DOPENSSL_API_COMPAT=<version> to suppress the\r\n * declarations of functions deprecated in or before <version>. Otherwise, they\r\n * still won't see them if the library has been built to disable deprecated\r\n * functions.\r\n */\r\n#ifndef DECLARE_DEPRECATED\r\n# define DECLARE_DEPRECATED(f)   f;\r\n# ifdef __GNUC__\r\n#  if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ > 0)\r\n#   undef DECLARE_DEPRECATED\r\n#   define DECLARE_DEPRECATED(f)    f __attribute__ ((deprecated));\r\n#  endif\r\n# elif defined(__SUNPRO_C)\r\n#  if (__SUNPRO_C >= 0x5130)\r\n#   undef DECLARE_DEPRECATED\r\n#   define DECLARE_DEPRECATED(f)    f __attribute__ ((deprecated));\r\n#  endif\r\n# endif\r\n#endif\r\n\r\n#ifndef OPENSSL_FILE\r\n# ifdef OPENSSL_NO_FILENAMES\r\n#  define OPENSSL_FILE \"\"\r\n#  define OPENSSL_LINE 0\r\n# else\r\n#  define OPENSSL_FILE __FILE__\r\n#  define OPENSSL_LINE __LINE__\r\n# endif\r\n#endif\r\n\r\n#ifndef OPENSSL_MIN_API\r\n# define OPENSSL_MIN_API 0\r\n#endif\r\n\r\n#if !defined(OPENSSL_API_COMPAT) || OPENSSL_API_COMPAT < OPENSSL_MIN_API\r\n# undef OPENSSL_API_COMPAT\r\n# define OPENSSL_API_COMPAT OPENSSL_MIN_API\r\n#endif\r\n\r\n/*\r\n * Do not deprecate things to be deprecated in version 1.2.0 before the\r\n * OpenSSL version number matches.\r\n */\r\n#if OPENSSL_VERSION_NUMBER < 0x10200000L\r\n# define DEPRECATEDIN_1_2_0(f)   f;\r\n#elif OPENSSL_API_COMPAT < 0x10200000L\r\n# define DEPRECATEDIN_1_2_0(f)   DECLARE_DEPRECATED(f)\r\n#else\r\n# define DEPRECATEDIN_1_2_0(f)\r\n#endif\r\n\r\n#if OPENSSL_API_COMPAT < 0x10100000L\r\n# define DEPRECATEDIN_1_1_0(f)   DECLARE_DEPRECATED(f)\r\n#else\r\n# define DEPRECATEDIN_1_1_0(f)\r\n#endif\r\n\r\n#if OPENSSL_API_COMPAT < 0x10000000L\r\n# define DEPRECATEDIN_1_0_0(f)   DECLARE_DEPRECATED(f)\r\n#else\r\n# define DEPRECATEDIN_1_0_0(f)\r\n#endif\r\n\r\n#if OPENSSL_API_COMPAT < 0x00908000L\r\n# define DEPRECATEDIN_0_9_8(f)   DECLARE_DEPRECATED(f)\r\n#else\r\n# define DEPRECATEDIN_0_9_8(f)\r\n#endif\r\n\r\n/* Generate 80386 code? */\r\n#undef I386_ONLY\r\n\r\n#undef OPENSSL_UNISTD\r\n#define OPENSSL_UNISTD <unistd.h>\r\n\r\n#define OPENSSL_EXPORT_VAR_AS_FUNCTION\r\n\r\n/*\r\n * The following are cipher-specific, but are part of the public API.\r\n */\r\n#if !defined(OPENSSL_SYS_UEFI)\r\n# define BN_LLONG\r\n/* Only one for the following should be defined */\r\n# undef SIXTY_FOUR_BIT_LONG\r\n# undef SIXTY_FOUR_BIT\r\n# define THIRTY_TWO_BIT\r\n#endif\r\n\r\n#define RC4_INT unsigned int\r\n\r\n#ifdef  __cplusplus\r\n}\r\n#endif\r\n"
  },
  {
    "path": "tools/prebuild/openssl/include/openssl/opensslconf_windows-x86_64.h",
    "content": "/*\r\n * WARNING: do not edit!\r\n * Generated by makefile from include\\openssl\\opensslconf.h.in\r\n *\r\n * Copyright 2016-2020 The OpenSSL Project Authors. All Rights Reserved.\r\n *\r\n * Licensed under the OpenSSL license (the \"License\").  You may not use\r\n * this file except in compliance with the License.  You can obtain a copy\r\n * in the file LICENSE in the source distribution or at\r\n * https://www.openssl.org/source/license.html\r\n */\r\n\r\n#include <openssl/opensslv.h>\r\n\r\n#ifdef  __cplusplus\r\nextern \"C\" {\r\n#endif\r\n\r\n#ifdef OPENSSL_ALGORITHM_DEFINES\r\n# error OPENSSL_ALGORITHM_DEFINES no longer supported\r\n#endif\r\n\r\n/*\r\n * OpenSSL was configured with the following options:\r\n */\r\n\r\n#ifndef OPENSSL_SYS_WIN64A\r\n# define OPENSSL_SYS_WIN64A 1\r\n#endif\r\n#ifndef OPENSSL_NO_MD2\r\n# define OPENSSL_NO_MD2\r\n#endif\r\n#ifndef OPENSSL_NO_RC5\r\n# define OPENSSL_NO_RC5\r\n#endif\r\n#ifndef OPENSSL_THREADS\r\n# define OPENSSL_THREADS\r\n#endif\r\n#ifndef OPENSSL_RAND_SEED_OS\r\n# define OPENSSL_RAND_SEED_OS\r\n#endif\r\n#ifndef OPENSSL_NO_AFALGENG\r\n# define OPENSSL_NO_AFALGENG\r\n#endif\r\n#ifndef OPENSSL_NO_ASAN\r\n# define OPENSSL_NO_ASAN\r\n#endif\r\n#ifndef OPENSSL_NO_ASM\r\n# define OPENSSL_NO_ASM\r\n#endif\r\n#ifndef OPENSSL_NO_CRYPTO_MDEBUG\r\n# define OPENSSL_NO_CRYPTO_MDEBUG\r\n#endif\r\n#ifndef OPENSSL_NO_CRYPTO_MDEBUG_BACKTRACE\r\n# define OPENSSL_NO_CRYPTO_MDEBUG_BACKTRACE\r\n#endif\r\n#ifndef OPENSSL_NO_DEVCRYPTOENG\r\n# define OPENSSL_NO_DEVCRYPTOENG\r\n#endif\r\n#ifndef OPENSSL_NO_EC_NISTP_64_GCC_128\r\n# define OPENSSL_NO_EC_NISTP_64_GCC_128\r\n#endif\r\n#ifndef OPENSSL_NO_EGD\r\n# define OPENSSL_NO_EGD\r\n#endif\r\n#ifndef OPENSSL_NO_EXTERNAL_TESTS\r\n# define OPENSSL_NO_EXTERNAL_TESTS\r\n#endif\r\n#ifndef OPENSSL_NO_FUZZ_AFL\r\n# define OPENSSL_NO_FUZZ_AFL\r\n#endif\r\n#ifndef OPENSSL_NO_FUZZ_LIBFUZZER\r\n# define OPENSSL_NO_FUZZ_LIBFUZZER\r\n#endif\r\n#ifndef OPENSSL_NO_HEARTBEATS\r\n# define OPENSSL_NO_HEARTBEATS\r\n#endif\r\n#ifndef OPENSSL_NO_MSAN\r\n# define OPENSSL_NO_MSAN\r\n#endif\r\n#ifndef OPENSSL_NO_SCTP\r\n# define OPENSSL_NO_SCTP\r\n#endif\r\n#ifndef OPENSSL_NO_SSL_TRACE\r\n# define OPENSSL_NO_SSL_TRACE\r\n#endif\r\n#ifndef OPENSSL_NO_SSL3\r\n# define OPENSSL_NO_SSL3\r\n#endif\r\n#ifndef OPENSSL_NO_SSL3_METHOD\r\n# define OPENSSL_NO_SSL3_METHOD\r\n#endif\r\n#ifndef OPENSSL_NO_TESTS\r\n# define OPENSSL_NO_TESTS\r\n#endif\r\n#ifndef OPENSSL_NO_UBSAN\r\n# define OPENSSL_NO_UBSAN\r\n#endif\r\n#ifndef OPENSSL_NO_UNIT_TEST\r\n# define OPENSSL_NO_UNIT_TEST\r\n#endif\r\n#ifndef OPENSSL_NO_WEAK_SSL_CIPHERS\r\n# define OPENSSL_NO_WEAK_SSL_CIPHERS\r\n#endif\r\n#ifndef OPENSSL_NO_DYNAMIC_ENGINE\r\n# define OPENSSL_NO_DYNAMIC_ENGINE\r\n#endif\r\n\r\n\r\n/*\r\n * Sometimes OPENSSSL_NO_xxx ends up with an empty file and some compilers\r\n * don't like that.  This will hopefully silence them.\r\n */\r\n#define NON_EMPTY_TRANSLATION_UNIT static void *dummy = &dummy;\r\n\r\n/*\r\n * Applications should use -DOPENSSL_API_COMPAT=<version> to suppress the\r\n * declarations of functions deprecated in or before <version>. Otherwise, they\r\n * still won't see them if the library has been built to disable deprecated\r\n * functions.\r\n */\r\n#ifndef DECLARE_DEPRECATED\r\n# define DECLARE_DEPRECATED(f)   f;\r\n# ifdef __GNUC__\r\n#  if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ > 0)\r\n#   undef DECLARE_DEPRECATED\r\n#   define DECLARE_DEPRECATED(f)    f __attribute__ ((deprecated));\r\n#  endif\r\n# elif defined(__SUNPRO_C)\r\n#  if (__SUNPRO_C >= 0x5130)\r\n#   undef DECLARE_DEPRECATED\r\n#   define DECLARE_DEPRECATED(f)    f __attribute__ ((deprecated));\r\n#  endif\r\n# endif\r\n#endif\r\n\r\n#ifndef OPENSSL_FILE\r\n# ifdef OPENSSL_NO_FILENAMES\r\n#  define OPENSSL_FILE \"\"\r\n#  define OPENSSL_LINE 0\r\n# else\r\n#  define OPENSSL_FILE __FILE__\r\n#  define OPENSSL_LINE __LINE__\r\n# endif\r\n#endif\r\n\r\n#ifndef OPENSSL_MIN_API\r\n# define OPENSSL_MIN_API 0\r\n#endif\r\n\r\n#if !defined(OPENSSL_API_COMPAT) || OPENSSL_API_COMPAT < OPENSSL_MIN_API\r\n# undef OPENSSL_API_COMPAT\r\n# define OPENSSL_API_COMPAT OPENSSL_MIN_API\r\n#endif\r\n\r\n/*\r\n * Do not deprecate things to be deprecated in version 1.2.0 before the\r\n * OpenSSL version number matches.\r\n */\r\n#if OPENSSL_VERSION_NUMBER < 0x10200000L\r\n# define DEPRECATEDIN_1_2_0(f)   f;\r\n#elif OPENSSL_API_COMPAT < 0x10200000L\r\n# define DEPRECATEDIN_1_2_0(f)   DECLARE_DEPRECATED(f)\r\n#else\r\n# define DEPRECATEDIN_1_2_0(f)\r\n#endif\r\n\r\n#if OPENSSL_API_COMPAT < 0x10100000L\r\n# define DEPRECATEDIN_1_1_0(f)   DECLARE_DEPRECATED(f)\r\n#else\r\n# define DEPRECATEDIN_1_1_0(f)\r\n#endif\r\n\r\n#if OPENSSL_API_COMPAT < 0x10000000L\r\n# define DEPRECATEDIN_1_0_0(f)   DECLARE_DEPRECATED(f)\r\n#else\r\n# define DEPRECATEDIN_1_0_0(f)\r\n#endif\r\n\r\n#if OPENSSL_API_COMPAT < 0x00908000L\r\n# define DEPRECATEDIN_0_9_8(f)   DECLARE_DEPRECATED(f)\r\n#else\r\n# define DEPRECATEDIN_0_9_8(f)\r\n#endif\r\n\r\n/* Generate 80386 code? */\r\n#undef I386_ONLY\r\n\r\n#undef OPENSSL_UNISTD\r\n#define OPENSSL_UNISTD <unistd.h>\r\n\r\n#define OPENSSL_EXPORT_VAR_AS_FUNCTION\r\n\r\n/*\r\n * The following are cipher-specific, but are part of the public API.\r\n */\r\n#if !defined(OPENSSL_SYS_UEFI)\r\n# undef BN_LLONG\r\n/* Only one for the following should be defined */\r\n# undef SIXTY_FOUR_BIT_LONG\r\n# define SIXTY_FOUR_BIT\r\n# undef THIRTY_TWO_BIT\r\n#endif\r\n\r\n#define RC4_INT unsigned int\r\n\r\n#ifdef  __cplusplus\r\n}\r\n#endif\r\n"
  },
  {
    "path": "tools/prebuild/openssl/include/openssl/opensslv.h",
    "content": "/*\n * Copyright 1999-2021 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef HEADER_OPENSSLV_H\n# define HEADER_OPENSSLV_H\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n/*-\n * Numeric release version identifier:\n * MNNFFPPS: major minor fix patch status\n * The status nibble has one of the values 0 for development, 1 to e for betas\n * 1 to 14, and f for release.  The patch level is exactly that.\n * For example:\n * 0.9.3-dev      0x00903000\n * 0.9.3-beta1    0x00903001\n * 0.9.3-beta2-dev 0x00903002\n * 0.9.3-beta2    0x00903002 (same as ...beta2-dev)\n * 0.9.3          0x0090300f\n * 0.9.3a         0x0090301f\n * 0.9.4          0x0090400f\n * 1.2.3z         0x102031af\n *\n * For continuity reasons (because 0.9.5 is already out, and is coded\n * 0x00905100), between 0.9.5 and 0.9.6 the coding of the patch level\n * part is slightly different, by setting the highest bit.  This means\n * that 0.9.5a looks like this: 0x0090581f.  At 0.9.6, we can start\n * with 0x0090600S...\n *\n * (Prior to 0.9.3-dev a different scheme was used: 0.9.2b is 0x0922.)\n * (Prior to 0.9.5a beta1, a different scheme was used: MMNNFFRBB for\n *  major minor fix final patch/beta)\n */\n# define OPENSSL_VERSION_NUMBER  0x101010cfL\n# define OPENSSL_VERSION_TEXT    \"OpenSSL 1.1.1l  24 Aug 2021\"\n\n/*-\n * The macros below are to be used for shared library (.so, .dll, ...)\n * versioning.  That kind of versioning works a bit differently between\n * operating systems.  The most usual scheme is to set a major and a minor\n * number, and have the runtime loader check that the major number is equal\n * to what it was at application link time, while the minor number has to\n * be greater or equal to what it was at application link time.  With this\n * scheme, the version number is usually part of the file name, like this:\n *\n *      libcrypto.so.0.9\n *\n * Some unixen also make a softlink with the major version number only:\n *\n *      libcrypto.so.0\n *\n * On Tru64 and IRIX 6.x it works a little bit differently.  There, the\n * shared library version is stored in the file, and is actually a series\n * of versions, separated by colons.  The rightmost version present in the\n * library when linking an application is stored in the application to be\n * matched at run time.  When the application is run, a check is done to\n * see if the library version stored in the application matches any of the\n * versions in the version string of the library itself.\n * This version string can be constructed in any way, depending on what\n * kind of matching is desired.  However, to implement the same scheme as\n * the one used in the other unixen, all compatible versions, from lowest\n * to highest, should be part of the string.  Consecutive builds would\n * give the following versions strings:\n *\n *      3.0\n *      3.0:3.1\n *      3.0:3.1:3.2\n *      4.0\n *      4.0:4.1\n *\n * Notice how version 4 is completely incompatible with version, and\n * therefore give the breach you can see.\n *\n * There may be other schemes as well that I haven't yet discovered.\n *\n * So, here's the way it works here: first of all, the library version\n * number doesn't need at all to match the overall OpenSSL version.\n * However, it's nice and more understandable if it actually does.\n * The current library version is stored in the macro SHLIB_VERSION_NUMBER,\n * which is just a piece of text in the format \"M.m.e\" (Major, minor, edit).\n * For the sake of Tru64, IRIX, and any other OS that behaves in similar ways,\n * we need to keep a history of version numbers, which is done in the\n * macro SHLIB_VERSION_HISTORY.  The numbers are separated by colons and\n * should only keep the versions that are binary compatible with the current.\n */\n# define SHLIB_VERSION_HISTORY \"\"\n# define SHLIB_VERSION_NUMBER \"1.1\"\n\n\n#ifdef  __cplusplus\n}\n#endif\n#endif                          /* HEADER_OPENSSLV_H */\n"
  },
  {
    "path": "tools/prebuild/openssl/include/openssl/ossl_typ.h",
    "content": "/*\n * Copyright 2001-2018 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef HEADER_OPENSSL_TYPES_H\n# define HEADER_OPENSSL_TYPES_H\n\n#include <limits.h>\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n# include <openssl/e_os2.h>\n\n# ifdef NO_ASN1_TYPEDEFS\n#  define ASN1_INTEGER            ASN1_STRING\n#  define ASN1_ENUMERATED         ASN1_STRING\n#  define ASN1_BIT_STRING         ASN1_STRING\n#  define ASN1_OCTET_STRING       ASN1_STRING\n#  define ASN1_PRINTABLESTRING    ASN1_STRING\n#  define ASN1_T61STRING          ASN1_STRING\n#  define ASN1_IA5STRING          ASN1_STRING\n#  define ASN1_UTCTIME            ASN1_STRING\n#  define ASN1_GENERALIZEDTIME    ASN1_STRING\n#  define ASN1_TIME               ASN1_STRING\n#  define ASN1_GENERALSTRING      ASN1_STRING\n#  define ASN1_UNIVERSALSTRING    ASN1_STRING\n#  define ASN1_BMPSTRING          ASN1_STRING\n#  define ASN1_VISIBLESTRING      ASN1_STRING\n#  define ASN1_UTF8STRING         ASN1_STRING\n#  define ASN1_BOOLEAN            int\n#  define ASN1_NULL               int\n# else\ntypedef struct asn1_string_st ASN1_INTEGER;\ntypedef struct asn1_string_st ASN1_ENUMERATED;\ntypedef struct asn1_string_st ASN1_BIT_STRING;\ntypedef struct asn1_string_st ASN1_OCTET_STRING;\ntypedef struct asn1_string_st ASN1_PRINTABLESTRING;\ntypedef struct asn1_string_st ASN1_T61STRING;\ntypedef struct asn1_string_st ASN1_IA5STRING;\ntypedef struct asn1_string_st ASN1_GENERALSTRING;\ntypedef struct asn1_string_st ASN1_UNIVERSALSTRING;\ntypedef struct asn1_string_st ASN1_BMPSTRING;\ntypedef struct asn1_string_st ASN1_UTCTIME;\ntypedef struct asn1_string_st ASN1_TIME;\ntypedef struct asn1_string_st ASN1_GENERALIZEDTIME;\ntypedef struct asn1_string_st ASN1_VISIBLESTRING;\ntypedef struct asn1_string_st ASN1_UTF8STRING;\ntypedef struct asn1_string_st ASN1_STRING;\ntypedef int ASN1_BOOLEAN;\ntypedef int ASN1_NULL;\n# endif\n\ntypedef struct asn1_object_st ASN1_OBJECT;\n\ntypedef struct ASN1_ITEM_st ASN1_ITEM;\ntypedef struct asn1_pctx_st ASN1_PCTX;\ntypedef struct asn1_sctx_st ASN1_SCTX;\n\n# ifdef _WIN32\n#  undef X509_NAME\n#  undef X509_EXTENSIONS\n#  undef PKCS7_ISSUER_AND_SERIAL\n#  undef PKCS7_SIGNER_INFO\n#  undef OCSP_REQUEST\n#  undef OCSP_RESPONSE\n# endif\n\n# ifdef BIGNUM\n#  undef BIGNUM\n# endif\nstruct dane_st;\ntypedef struct bio_st BIO;\ntypedef struct bignum_st BIGNUM;\ntypedef struct bignum_ctx BN_CTX;\ntypedef struct bn_blinding_st BN_BLINDING;\ntypedef struct bn_mont_ctx_st BN_MONT_CTX;\ntypedef struct bn_recp_ctx_st BN_RECP_CTX;\ntypedef struct bn_gencb_st BN_GENCB;\n\ntypedef struct buf_mem_st BUF_MEM;\n\ntypedef struct evp_cipher_st EVP_CIPHER;\ntypedef struct evp_cipher_ctx_st EVP_CIPHER_CTX;\ntypedef struct evp_md_st EVP_MD;\ntypedef struct evp_md_ctx_st EVP_MD_CTX;\ntypedef struct evp_pkey_st EVP_PKEY;\n\ntypedef struct evp_pkey_asn1_method_st EVP_PKEY_ASN1_METHOD;\n\ntypedef struct evp_pkey_method_st EVP_PKEY_METHOD;\ntypedef struct evp_pkey_ctx_st EVP_PKEY_CTX;\n\ntypedef struct evp_Encode_Ctx_st EVP_ENCODE_CTX;\n\ntypedef struct hmac_ctx_st HMAC_CTX;\n\ntypedef struct dh_st DH;\ntypedef struct dh_method DH_METHOD;\n\ntypedef struct dsa_st DSA;\ntypedef struct dsa_method DSA_METHOD;\n\ntypedef struct rsa_st RSA;\ntypedef struct rsa_meth_st RSA_METHOD;\ntypedef struct rsa_pss_params_st RSA_PSS_PARAMS;\n\ntypedef struct ec_key_st EC_KEY;\ntypedef struct ec_key_method_st EC_KEY_METHOD;\n\ntypedef struct rand_meth_st RAND_METHOD;\ntypedef struct rand_drbg_st RAND_DRBG;\n\ntypedef struct ssl_dane_st SSL_DANE;\ntypedef struct x509_st X509;\ntypedef struct X509_algor_st X509_ALGOR;\ntypedef struct X509_crl_st X509_CRL;\ntypedef struct x509_crl_method_st X509_CRL_METHOD;\ntypedef struct x509_revoked_st X509_REVOKED;\ntypedef struct X509_name_st X509_NAME;\ntypedef struct X509_pubkey_st X509_PUBKEY;\ntypedef struct x509_store_st X509_STORE;\ntypedef struct x509_store_ctx_st X509_STORE_CTX;\n\ntypedef struct x509_object_st X509_OBJECT;\ntypedef struct x509_lookup_st X509_LOOKUP;\ntypedef struct x509_lookup_method_st X509_LOOKUP_METHOD;\ntypedef struct X509_VERIFY_PARAM_st X509_VERIFY_PARAM;\n\ntypedef struct x509_sig_info_st X509_SIG_INFO;\n\ntypedef struct pkcs8_priv_key_info_st PKCS8_PRIV_KEY_INFO;\n\ntypedef struct v3_ext_ctx X509V3_CTX;\ntypedef struct conf_st CONF;\ntypedef struct ossl_init_settings_st OPENSSL_INIT_SETTINGS;\n\ntypedef struct ui_st UI;\ntypedef struct ui_method_st UI_METHOD;\n\ntypedef struct engine_st ENGINE;\ntypedef struct ssl_st SSL;\ntypedef struct ssl_ctx_st SSL_CTX;\n\ntypedef struct comp_ctx_st COMP_CTX;\ntypedef struct comp_method_st COMP_METHOD;\n\ntypedef struct X509_POLICY_NODE_st X509_POLICY_NODE;\ntypedef struct X509_POLICY_LEVEL_st X509_POLICY_LEVEL;\ntypedef struct X509_POLICY_TREE_st X509_POLICY_TREE;\ntypedef struct X509_POLICY_CACHE_st X509_POLICY_CACHE;\n\ntypedef struct AUTHORITY_KEYID_st AUTHORITY_KEYID;\ntypedef struct DIST_POINT_st DIST_POINT;\ntypedef struct ISSUING_DIST_POINT_st ISSUING_DIST_POINT;\ntypedef struct NAME_CONSTRAINTS_st NAME_CONSTRAINTS;\n\ntypedef struct crypto_ex_data_st CRYPTO_EX_DATA;\n\ntypedef struct ocsp_req_ctx_st OCSP_REQ_CTX;\ntypedef struct ocsp_response_st OCSP_RESPONSE;\ntypedef struct ocsp_responder_id_st OCSP_RESPID;\n\ntypedef struct sct_st SCT;\ntypedef struct sct_ctx_st SCT_CTX;\ntypedef struct ctlog_st CTLOG;\ntypedef struct ctlog_store_st CTLOG_STORE;\ntypedef struct ct_policy_eval_ctx_st CT_POLICY_EVAL_CTX;\n\ntypedef struct ossl_store_info_st OSSL_STORE_INFO;\ntypedef struct ossl_store_search_st OSSL_STORE_SEARCH;\n\n#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L && \\\n    defined(INTMAX_MAX) && defined(UINTMAX_MAX)\ntypedef intmax_t ossl_intmax_t;\ntypedef uintmax_t ossl_uintmax_t;\n#else\n/*\n * Not long long, because the C-library can only be expected to provide\n * strtoll(), strtoull() at the same time as intmax_t and strtoimax(),\n * strtoumax().  Since we use these for parsing arguments, we need the\n * conversion functions, not just the sizes.\n */\ntypedef long ossl_intmax_t;\ntypedef unsigned long ossl_uintmax_t;\n#endif\n\n#ifdef  __cplusplus\n}\n#endif\n#endif                          /* def HEADER_OPENSSL_TYPES_H */\n"
  },
  {
    "path": "tools/prebuild/openssl/include/openssl/pem.h",
    "content": "/*\n * Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef HEADER_PEM_H\n# define HEADER_PEM_H\n\n# include <openssl/e_os2.h>\n# include <openssl/bio.h>\n# include <openssl/safestack.h>\n# include <openssl/evp.h>\n# include <openssl/x509.h>\n# include <openssl/pemerr.h>\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n# define PEM_BUFSIZE             1024\n\n# define PEM_STRING_X509_OLD     \"X509 CERTIFICATE\"\n# define PEM_STRING_X509         \"CERTIFICATE\"\n# define PEM_STRING_X509_TRUSTED \"TRUSTED CERTIFICATE\"\n# define PEM_STRING_X509_REQ_OLD \"NEW CERTIFICATE REQUEST\"\n# define PEM_STRING_X509_REQ     \"CERTIFICATE REQUEST\"\n# define PEM_STRING_X509_CRL     \"X509 CRL\"\n# define PEM_STRING_EVP_PKEY     \"ANY PRIVATE KEY\"\n# define PEM_STRING_PUBLIC       \"PUBLIC KEY\"\n# define PEM_STRING_RSA          \"RSA PRIVATE KEY\"\n# define PEM_STRING_RSA_PUBLIC   \"RSA PUBLIC KEY\"\n# define PEM_STRING_DSA          \"DSA PRIVATE KEY\"\n# define PEM_STRING_DSA_PUBLIC   \"DSA PUBLIC KEY\"\n# define PEM_STRING_PKCS7        \"PKCS7\"\n# define PEM_STRING_PKCS7_SIGNED \"PKCS #7 SIGNED DATA\"\n# define PEM_STRING_PKCS8        \"ENCRYPTED PRIVATE KEY\"\n# define PEM_STRING_PKCS8INF     \"PRIVATE KEY\"\n# define PEM_STRING_DHPARAMS     \"DH PARAMETERS\"\n# define PEM_STRING_DHXPARAMS    \"X9.42 DH PARAMETERS\"\n# define PEM_STRING_SSL_SESSION  \"SSL SESSION PARAMETERS\"\n# define PEM_STRING_DSAPARAMS    \"DSA PARAMETERS\"\n# define PEM_STRING_ECDSA_PUBLIC \"ECDSA PUBLIC KEY\"\n# define PEM_STRING_ECPARAMETERS \"EC PARAMETERS\"\n# define PEM_STRING_ECPRIVATEKEY \"EC PRIVATE KEY\"\n# define PEM_STRING_PARAMETERS   \"PARAMETERS\"\n# define PEM_STRING_CMS          \"CMS\"\n\n# define PEM_TYPE_ENCRYPTED      10\n# define PEM_TYPE_MIC_ONLY       20\n# define PEM_TYPE_MIC_CLEAR      30\n# define PEM_TYPE_CLEAR          40\n\n/*\n * These macros make the PEM_read/PEM_write functions easier to maintain and\n * write. Now they are all implemented with either: IMPLEMENT_PEM_rw(...) or\n * IMPLEMENT_PEM_rw_cb(...)\n */\n\n# ifdef OPENSSL_NO_STDIO\n\n#  define IMPLEMENT_PEM_read_fp(name, type, str, asn1) /**/\n#  define IMPLEMENT_PEM_write_fp(name, type, str, asn1) /**/\n#  define IMPLEMENT_PEM_write_fp_const(name, type, str, asn1) /**/\n#  define IMPLEMENT_PEM_write_cb_fp(name, type, str, asn1) /**/\n#  define IMPLEMENT_PEM_write_cb_fp_const(name, type, str, asn1) /**/\n# else\n\n#  define IMPLEMENT_PEM_read_fp(name, type, str, asn1) \\\ntype *PEM_read_##name(FILE *fp, type **x, pem_password_cb *cb, void *u)\\\n{ \\\nreturn PEM_ASN1_read((d2i_of_void *)d2i_##asn1, str,fp,(void **)x,cb,u); \\\n}\n\n#  define IMPLEMENT_PEM_write_fp(name, type, str, asn1) \\\nint PEM_write_##name(FILE *fp, type *x) \\\n{ \\\nreturn PEM_ASN1_write((i2d_of_void *)i2d_##asn1,str,fp,x,NULL,NULL,0,NULL,NULL); \\\n}\n\n#  define IMPLEMENT_PEM_write_fp_const(name, type, str, asn1) \\\nint PEM_write_##name(FILE *fp, const type *x) \\\n{ \\\nreturn PEM_ASN1_write((i2d_of_void *)i2d_##asn1,str,fp,(void *)x,NULL,NULL,0,NULL,NULL); \\\n}\n\n#  define IMPLEMENT_PEM_write_cb_fp(name, type, str, asn1) \\\nint PEM_write_##name(FILE *fp, type *x, const EVP_CIPHER *enc, \\\n             unsigned char *kstr, int klen, pem_password_cb *cb, \\\n                  void *u) \\\n        { \\\n        return PEM_ASN1_write((i2d_of_void *)i2d_##asn1,str,fp,x,enc,kstr,klen,cb,u); \\\n        }\n\n#  define IMPLEMENT_PEM_write_cb_fp_const(name, type, str, asn1) \\\nint PEM_write_##name(FILE *fp, type *x, const EVP_CIPHER *enc, \\\n             unsigned char *kstr, int klen, pem_password_cb *cb, \\\n                  void *u) \\\n        { \\\n        return PEM_ASN1_write((i2d_of_void *)i2d_##asn1,str,fp,x,enc,kstr,klen,cb,u); \\\n        }\n\n# endif\n\n# define IMPLEMENT_PEM_read_bio(name, type, str, asn1) \\\ntype *PEM_read_bio_##name(BIO *bp, type **x, pem_password_cb *cb, void *u)\\\n{ \\\nreturn PEM_ASN1_read_bio((d2i_of_void *)d2i_##asn1, str,bp,(void **)x,cb,u); \\\n}\n\n# define IMPLEMENT_PEM_write_bio(name, type, str, asn1) \\\nint PEM_write_bio_##name(BIO *bp, type *x) \\\n{ \\\nreturn PEM_ASN1_write_bio((i2d_of_void *)i2d_##asn1,str,bp,x,NULL,NULL,0,NULL,NULL); \\\n}\n\n# define IMPLEMENT_PEM_write_bio_const(name, type, str, asn1) \\\nint PEM_write_bio_##name(BIO *bp, const type *x) \\\n{ \\\nreturn PEM_ASN1_write_bio((i2d_of_void *)i2d_##asn1,str,bp,(void *)x,NULL,NULL,0,NULL,NULL); \\\n}\n\n# define IMPLEMENT_PEM_write_cb_bio(name, type, str, asn1) \\\nint PEM_write_bio_##name(BIO *bp, type *x, const EVP_CIPHER *enc, \\\n             unsigned char *kstr, int klen, pem_password_cb *cb, void *u) \\\n        { \\\n        return PEM_ASN1_write_bio((i2d_of_void *)i2d_##asn1,str,bp,x,enc,kstr,klen,cb,u); \\\n        }\n\n# define IMPLEMENT_PEM_write_cb_bio_const(name, type, str, asn1) \\\nint PEM_write_bio_##name(BIO *bp, type *x, const EVP_CIPHER *enc, \\\n             unsigned char *kstr, int klen, pem_password_cb *cb, void *u) \\\n        { \\\n        return PEM_ASN1_write_bio((i2d_of_void *)i2d_##asn1,str,bp,(void *)x,enc,kstr,klen,cb,u); \\\n        }\n\n# define IMPLEMENT_PEM_write(name, type, str, asn1) \\\n        IMPLEMENT_PEM_write_bio(name, type, str, asn1) \\\n        IMPLEMENT_PEM_write_fp(name, type, str, asn1)\n\n# define IMPLEMENT_PEM_write_const(name, type, str, asn1) \\\n        IMPLEMENT_PEM_write_bio_const(name, type, str, asn1) \\\n        IMPLEMENT_PEM_write_fp_const(name, type, str, asn1)\n\n# define IMPLEMENT_PEM_write_cb(name, type, str, asn1) \\\n        IMPLEMENT_PEM_write_cb_bio(name, type, str, asn1) \\\n        IMPLEMENT_PEM_write_cb_fp(name, type, str, asn1)\n\n# define IMPLEMENT_PEM_write_cb_const(name, type, str, asn1) \\\n        IMPLEMENT_PEM_write_cb_bio_const(name, type, str, asn1) \\\n        IMPLEMENT_PEM_write_cb_fp_const(name, type, str, asn1)\n\n# define IMPLEMENT_PEM_read(name, type, str, asn1) \\\n        IMPLEMENT_PEM_read_bio(name, type, str, asn1) \\\n        IMPLEMENT_PEM_read_fp(name, type, str, asn1)\n\n# define IMPLEMENT_PEM_rw(name, type, str, asn1) \\\n        IMPLEMENT_PEM_read(name, type, str, asn1) \\\n        IMPLEMENT_PEM_write(name, type, str, asn1)\n\n# define IMPLEMENT_PEM_rw_const(name, type, str, asn1) \\\n        IMPLEMENT_PEM_read(name, type, str, asn1) \\\n        IMPLEMENT_PEM_write_const(name, type, str, asn1)\n\n# define IMPLEMENT_PEM_rw_cb(name, type, str, asn1) \\\n        IMPLEMENT_PEM_read(name, type, str, asn1) \\\n        IMPLEMENT_PEM_write_cb(name, type, str, asn1)\n\n/* These are the same except they are for the declarations */\n\n# if defined(OPENSSL_NO_STDIO)\n\n#  define DECLARE_PEM_read_fp(name, type) /**/\n#  define DECLARE_PEM_write_fp(name, type) /**/\n#  define DECLARE_PEM_write_fp_const(name, type) /**/\n#  define DECLARE_PEM_write_cb_fp(name, type) /**/\n# else\n\n#  define DECLARE_PEM_read_fp(name, type) \\\n        type *PEM_read_##name(FILE *fp, type **x, pem_password_cb *cb, void *u);\n\n#  define DECLARE_PEM_write_fp(name, type) \\\n        int PEM_write_##name(FILE *fp, type *x);\n\n#  define DECLARE_PEM_write_fp_const(name, type) \\\n        int PEM_write_##name(FILE *fp, const type *x);\n\n#  define DECLARE_PEM_write_cb_fp(name, type) \\\n        int PEM_write_##name(FILE *fp, type *x, const EVP_CIPHER *enc, \\\n             unsigned char *kstr, int klen, pem_password_cb *cb, void *u);\n\n# endif\n\n#  define DECLARE_PEM_read_bio(name, type) \\\n        type *PEM_read_bio_##name(BIO *bp, type **x, pem_password_cb *cb, void *u);\n\n#  define DECLARE_PEM_write_bio(name, type) \\\n        int PEM_write_bio_##name(BIO *bp, type *x);\n\n#  define DECLARE_PEM_write_bio_const(name, type) \\\n        int PEM_write_bio_##name(BIO *bp, const type *x);\n\n#  define DECLARE_PEM_write_cb_bio(name, type) \\\n        int PEM_write_bio_##name(BIO *bp, type *x, const EVP_CIPHER *enc, \\\n             unsigned char *kstr, int klen, pem_password_cb *cb, void *u);\n\n# define DECLARE_PEM_write(name, type) \\\n        DECLARE_PEM_write_bio(name, type) \\\n        DECLARE_PEM_write_fp(name, type)\n# define DECLARE_PEM_write_const(name, type) \\\n        DECLARE_PEM_write_bio_const(name, type) \\\n        DECLARE_PEM_write_fp_const(name, type)\n# define DECLARE_PEM_write_cb(name, type) \\\n        DECLARE_PEM_write_cb_bio(name, type) \\\n        DECLARE_PEM_write_cb_fp(name, type)\n# define DECLARE_PEM_read(name, type) \\\n        DECLARE_PEM_read_bio(name, type) \\\n        DECLARE_PEM_read_fp(name, type)\n# define DECLARE_PEM_rw(name, type) \\\n        DECLARE_PEM_read(name, type) \\\n        DECLARE_PEM_write(name, type)\n# define DECLARE_PEM_rw_const(name, type) \\\n        DECLARE_PEM_read(name, type) \\\n        DECLARE_PEM_write_const(name, type)\n# define DECLARE_PEM_rw_cb(name, type) \\\n        DECLARE_PEM_read(name, type) \\\n        DECLARE_PEM_write_cb(name, type)\ntypedef int pem_password_cb (char *buf, int size, int rwflag, void *userdata);\n\nint PEM_get_EVP_CIPHER_INFO(char *header, EVP_CIPHER_INFO *cipher);\nint PEM_do_header(EVP_CIPHER_INFO *cipher, unsigned char *data, long *len,\n                  pem_password_cb *callback, void *u);\n\nint PEM_read_bio(BIO *bp, char **name, char **header,\n                 unsigned char **data, long *len);\n#   define PEM_FLAG_SECURE             0x1\n#   define PEM_FLAG_EAY_COMPATIBLE     0x2\n#   define PEM_FLAG_ONLY_B64           0x4\nint PEM_read_bio_ex(BIO *bp, char **name, char **header,\n                    unsigned char **data, long *len, unsigned int flags);\nint PEM_bytes_read_bio_secmem(unsigned char **pdata, long *plen, char **pnm,\n                              const char *name, BIO *bp, pem_password_cb *cb,\n                              void *u);\nint PEM_write_bio(BIO *bp, const char *name, const char *hdr,\n                  const unsigned char *data, long len);\nint PEM_bytes_read_bio(unsigned char **pdata, long *plen, char **pnm,\n                       const char *name, BIO *bp, pem_password_cb *cb,\n                       void *u);\nvoid *PEM_ASN1_read_bio(d2i_of_void *d2i, const char *name, BIO *bp, void **x,\n                        pem_password_cb *cb, void *u);\nint PEM_ASN1_write_bio(i2d_of_void *i2d, const char *name, BIO *bp, void *x,\n                       const EVP_CIPHER *enc, unsigned char *kstr, int klen,\n                       pem_password_cb *cb, void *u);\n\nSTACK_OF(X509_INFO) *PEM_X509_INFO_read_bio(BIO *bp, STACK_OF(X509_INFO) *sk,\n                                            pem_password_cb *cb, void *u);\nint PEM_X509_INFO_write_bio(BIO *bp, X509_INFO *xi, EVP_CIPHER *enc,\n                            unsigned char *kstr, int klen,\n                            pem_password_cb *cd, void *u);\n\n#ifndef OPENSSL_NO_STDIO\nint PEM_read(FILE *fp, char **name, char **header,\n             unsigned char **data, long *len);\nint PEM_write(FILE *fp, const char *name, const char *hdr,\n              const unsigned char *data, long len);\nvoid *PEM_ASN1_read(d2i_of_void *d2i, const char *name, FILE *fp, void **x,\n                    pem_password_cb *cb, void *u);\nint PEM_ASN1_write(i2d_of_void *i2d, const char *name, FILE *fp,\n                   void *x, const EVP_CIPHER *enc, unsigned char *kstr,\n                   int klen, pem_password_cb *callback, void *u);\nSTACK_OF(X509_INFO) *PEM_X509_INFO_read(FILE *fp, STACK_OF(X509_INFO) *sk,\n                                        pem_password_cb *cb, void *u);\n#endif\n\nint PEM_SignInit(EVP_MD_CTX *ctx, EVP_MD *type);\nint PEM_SignUpdate(EVP_MD_CTX *ctx, unsigned char *d, unsigned int cnt);\nint PEM_SignFinal(EVP_MD_CTX *ctx, unsigned char *sigret,\n                  unsigned int *siglen, EVP_PKEY *pkey);\n\n/* The default pem_password_cb that's used internally */\nint PEM_def_callback(char *buf, int num, int rwflag, void *userdata);\nvoid PEM_proc_type(char *buf, int type);\nvoid PEM_dek_info(char *buf, const char *type, int len, char *str);\n\n# include <openssl/symhacks.h>\n\nDECLARE_PEM_rw(X509, X509)\nDECLARE_PEM_rw(X509_AUX, X509)\nDECLARE_PEM_rw(X509_REQ, X509_REQ)\nDECLARE_PEM_write(X509_REQ_NEW, X509_REQ)\nDECLARE_PEM_rw(X509_CRL, X509_CRL)\nDECLARE_PEM_rw(PKCS7, PKCS7)\nDECLARE_PEM_rw(NETSCAPE_CERT_SEQUENCE, NETSCAPE_CERT_SEQUENCE)\nDECLARE_PEM_rw(PKCS8, X509_SIG)\nDECLARE_PEM_rw(PKCS8_PRIV_KEY_INFO, PKCS8_PRIV_KEY_INFO)\n# ifndef OPENSSL_NO_RSA\nDECLARE_PEM_rw_cb(RSAPrivateKey, RSA)\nDECLARE_PEM_rw_const(RSAPublicKey, RSA)\nDECLARE_PEM_rw(RSA_PUBKEY, RSA)\n# endif\n# ifndef OPENSSL_NO_DSA\nDECLARE_PEM_rw_cb(DSAPrivateKey, DSA)\nDECLARE_PEM_rw(DSA_PUBKEY, DSA)\nDECLARE_PEM_rw_const(DSAparams, DSA)\n# endif\n# ifndef OPENSSL_NO_EC\nDECLARE_PEM_rw_const(ECPKParameters, EC_GROUP)\nDECLARE_PEM_rw_cb(ECPrivateKey, EC_KEY)\nDECLARE_PEM_rw(EC_PUBKEY, EC_KEY)\n# endif\n# ifndef OPENSSL_NO_DH\nDECLARE_PEM_rw_const(DHparams, DH)\nDECLARE_PEM_write_const(DHxparams, DH)\n# endif\nDECLARE_PEM_rw_cb(PrivateKey, EVP_PKEY)\nDECLARE_PEM_rw(PUBKEY, EVP_PKEY)\n\nint PEM_write_bio_PrivateKey_traditional(BIO *bp, EVP_PKEY *x,\n                                         const EVP_CIPHER *enc,\n                                         unsigned char *kstr, int klen,\n                                         pem_password_cb *cb, void *u);\n\nint PEM_write_bio_PKCS8PrivateKey_nid(BIO *bp, EVP_PKEY *x, int nid,\n                                      char *kstr, int klen,\n                                      pem_password_cb *cb, void *u);\nint PEM_write_bio_PKCS8PrivateKey(BIO *, EVP_PKEY *, const EVP_CIPHER *,\n                                  char *, int, pem_password_cb *, void *);\nint i2d_PKCS8PrivateKey_bio(BIO *bp, EVP_PKEY *x, const EVP_CIPHER *enc,\n                            char *kstr, int klen,\n                            pem_password_cb *cb, void *u);\nint i2d_PKCS8PrivateKey_nid_bio(BIO *bp, EVP_PKEY *x, int nid,\n                                char *kstr, int klen,\n                                pem_password_cb *cb, void *u);\nEVP_PKEY *d2i_PKCS8PrivateKey_bio(BIO *bp, EVP_PKEY **x, pem_password_cb *cb,\n                                  void *u);\n\n# ifndef OPENSSL_NO_STDIO\nint i2d_PKCS8PrivateKey_fp(FILE *fp, EVP_PKEY *x, const EVP_CIPHER *enc,\n                           char *kstr, int klen,\n                           pem_password_cb *cb, void *u);\nint i2d_PKCS8PrivateKey_nid_fp(FILE *fp, EVP_PKEY *x, int nid,\n                               char *kstr, int klen,\n                               pem_password_cb *cb, void *u);\nint PEM_write_PKCS8PrivateKey_nid(FILE *fp, EVP_PKEY *x, int nid,\n                                  char *kstr, int klen,\n                                  pem_password_cb *cb, void *u);\n\nEVP_PKEY *d2i_PKCS8PrivateKey_fp(FILE *fp, EVP_PKEY **x, pem_password_cb *cb,\n                                 void *u);\n\nint PEM_write_PKCS8PrivateKey(FILE *fp, EVP_PKEY *x, const EVP_CIPHER *enc,\n                              char *kstr, int klen, pem_password_cb *cd,\n                              void *u);\n# endif\nEVP_PKEY *PEM_read_bio_Parameters(BIO *bp, EVP_PKEY **x);\nint PEM_write_bio_Parameters(BIO *bp, EVP_PKEY *x);\n\n# ifndef OPENSSL_NO_DSA\nEVP_PKEY *b2i_PrivateKey(const unsigned char **in, long length);\nEVP_PKEY *b2i_PublicKey(const unsigned char **in, long length);\nEVP_PKEY *b2i_PrivateKey_bio(BIO *in);\nEVP_PKEY *b2i_PublicKey_bio(BIO *in);\nint i2b_PrivateKey_bio(BIO *out, EVP_PKEY *pk);\nint i2b_PublicKey_bio(BIO *out, EVP_PKEY *pk);\n#  ifndef OPENSSL_NO_RC4\nEVP_PKEY *b2i_PVK_bio(BIO *in, pem_password_cb *cb, void *u);\nint i2b_PVK_bio(BIO *out, EVP_PKEY *pk, int enclevel,\n                pem_password_cb *cb, void *u);\n#  endif\n# endif\n\n# ifdef  __cplusplus\n}\n# endif\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/include/openssl/pem2.h",
    "content": "/*\n * Copyright 1999-2018 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef HEADER_PEM2_H\n# define HEADER_PEM2_H\n# include <openssl/pemerr.h>\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/include/openssl/pemerr.h",
    "content": "/*\n * Generated by util/mkerr.pl DO NOT EDIT\n * Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef HEADER_PEMERR_H\n# define HEADER_PEMERR_H\n\n# ifndef HEADER_SYMHACKS_H\n#  include <openssl/symhacks.h>\n# endif\n\n# ifdef  __cplusplus\nextern \"C\"\n# endif\nint ERR_load_PEM_strings(void);\n\n/*\n * PEM function codes.\n */\n# define PEM_F_B2I_DSS                                    127\n# define PEM_F_B2I_PVK_BIO                                128\n# define PEM_F_B2I_RSA                                    129\n# define PEM_F_CHECK_BITLEN_DSA                           130\n# define PEM_F_CHECK_BITLEN_RSA                           131\n# define PEM_F_D2I_PKCS8PRIVATEKEY_BIO                    120\n# define PEM_F_D2I_PKCS8PRIVATEKEY_FP                     121\n# define PEM_F_DO_B2I                                     132\n# define PEM_F_DO_B2I_BIO                                 133\n# define PEM_F_DO_BLOB_HEADER                             134\n# define PEM_F_DO_I2B                                     146\n# define PEM_F_DO_PK8PKEY                                 126\n# define PEM_F_DO_PK8PKEY_FP                              125\n# define PEM_F_DO_PVK_BODY                                135\n# define PEM_F_DO_PVK_HEADER                              136\n# define PEM_F_GET_HEADER_AND_DATA                        143\n# define PEM_F_GET_NAME                                   144\n# define PEM_F_I2B_PVK                                    137\n# define PEM_F_I2B_PVK_BIO                                138\n# define PEM_F_LOAD_IV                                    101\n# define PEM_F_PEM_ASN1_READ                              102\n# define PEM_F_PEM_ASN1_READ_BIO                          103\n# define PEM_F_PEM_ASN1_WRITE                             104\n# define PEM_F_PEM_ASN1_WRITE_BIO                         105\n# define PEM_F_PEM_DEF_CALLBACK                           100\n# define PEM_F_PEM_DO_HEADER                              106\n# define PEM_F_PEM_GET_EVP_CIPHER_INFO                    107\n# define PEM_F_PEM_READ                                   108\n# define PEM_F_PEM_READ_BIO                               109\n# define PEM_F_PEM_READ_BIO_DHPARAMS                      141\n# define PEM_F_PEM_READ_BIO_EX                            145\n# define PEM_F_PEM_READ_BIO_PARAMETERS                    140\n# define PEM_F_PEM_READ_BIO_PRIVATEKEY                    123\n# define PEM_F_PEM_READ_DHPARAMS                          142\n# define PEM_F_PEM_READ_PRIVATEKEY                        124\n# define PEM_F_PEM_SIGNFINAL                              112\n# define PEM_F_PEM_WRITE                                  113\n# define PEM_F_PEM_WRITE_BIO                              114\n# define PEM_F_PEM_WRITE_BIO_PRIVATEKEY_TRADITIONAL       147\n# define PEM_F_PEM_WRITE_PRIVATEKEY                       139\n# define PEM_F_PEM_X509_INFO_READ                         115\n# define PEM_F_PEM_X509_INFO_READ_BIO                     116\n# define PEM_F_PEM_X509_INFO_WRITE_BIO                    117\n\n/*\n * PEM reason codes.\n */\n# define PEM_R_BAD_BASE64_DECODE                          100\n# define PEM_R_BAD_DECRYPT                                101\n# define PEM_R_BAD_END_LINE                               102\n# define PEM_R_BAD_IV_CHARS                               103\n# define PEM_R_BAD_MAGIC_NUMBER                           116\n# define PEM_R_BAD_PASSWORD_READ                          104\n# define PEM_R_BAD_VERSION_NUMBER                         117\n# define PEM_R_BIO_WRITE_FAILURE                          118\n# define PEM_R_CIPHER_IS_NULL                             127\n# define PEM_R_ERROR_CONVERTING_PRIVATE_KEY               115\n# define PEM_R_EXPECTING_PRIVATE_KEY_BLOB                 119\n# define PEM_R_EXPECTING_PUBLIC_KEY_BLOB                  120\n# define PEM_R_HEADER_TOO_LONG                            128\n# define PEM_R_INCONSISTENT_HEADER                        121\n# define PEM_R_KEYBLOB_HEADER_PARSE_ERROR                 122\n# define PEM_R_KEYBLOB_TOO_SHORT                          123\n# define PEM_R_MISSING_DEK_IV                             129\n# define PEM_R_NOT_DEK_INFO                               105\n# define PEM_R_NOT_ENCRYPTED                              106\n# define PEM_R_NOT_PROC_TYPE                              107\n# define PEM_R_NO_START_LINE                              108\n# define PEM_R_PROBLEMS_GETTING_PASSWORD                  109\n# define PEM_R_PVK_DATA_TOO_SHORT                         124\n# define PEM_R_PVK_TOO_SHORT                              125\n# define PEM_R_READ_KEY                                   111\n# define PEM_R_SHORT_HEADER                               112\n# define PEM_R_UNEXPECTED_DEK_IV                          130\n# define PEM_R_UNSUPPORTED_CIPHER                         113\n# define PEM_R_UNSUPPORTED_ENCRYPTION                     114\n# define PEM_R_UNSUPPORTED_KEY_COMPONENTS                 126\n# define PEM_R_UNSUPPORTED_PUBLIC_KEY_TYPE                110\n\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/include/openssl/pkcs12.h",
    "content": "/*\n * Copyright 1999-2016 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef HEADER_PKCS12_H\n# define HEADER_PKCS12_H\n\n# include <openssl/bio.h>\n# include <openssl/x509.h>\n# include <openssl/pkcs12err.h>\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n# define PKCS12_KEY_ID   1\n# define PKCS12_IV_ID    2\n# define PKCS12_MAC_ID   3\n\n/* Default iteration count */\n# ifndef PKCS12_DEFAULT_ITER\n#  define PKCS12_DEFAULT_ITER     PKCS5_DEFAULT_ITER\n# endif\n\n# define PKCS12_MAC_KEY_LENGTH 20\n\n# define PKCS12_SALT_LEN 8\n\n/* It's not clear if these are actually needed... */\n# define PKCS12_key_gen PKCS12_key_gen_utf8\n# define PKCS12_add_friendlyname PKCS12_add_friendlyname_utf8\n\n/* MS key usage constants */\n\n# define KEY_EX  0x10\n# define KEY_SIG 0x80\n\ntypedef struct PKCS12_MAC_DATA_st PKCS12_MAC_DATA;\n\ntypedef struct PKCS12_st PKCS12;\n\ntypedef struct PKCS12_SAFEBAG_st PKCS12_SAFEBAG;\n\nDEFINE_STACK_OF(PKCS12_SAFEBAG)\n\ntypedef struct pkcs12_bag_st PKCS12_BAGS;\n\n# define PKCS12_ERROR    0\n# define PKCS12_OK       1\n\n/* Compatibility macros */\n\n#if OPENSSL_API_COMPAT < 0x10100000L\n\n# define M_PKCS12_bag_type PKCS12_bag_type\n# define M_PKCS12_cert_bag_type PKCS12_cert_bag_type\n# define M_PKCS12_crl_bag_type PKCS12_cert_bag_type\n\n# define PKCS12_certbag2x509 PKCS12_SAFEBAG_get1_cert\n# define PKCS12_certbag2scrl PKCS12_SAFEBAG_get1_crl\n# define PKCS12_bag_type PKCS12_SAFEBAG_get_nid\n# define PKCS12_cert_bag_type PKCS12_SAFEBAG_get_bag_nid\n# define PKCS12_x5092certbag PKCS12_SAFEBAG_create_cert\n# define PKCS12_x509crl2certbag PKCS12_SAFEBAG_create_crl\n# define PKCS12_MAKE_KEYBAG PKCS12_SAFEBAG_create0_p8inf\n# define PKCS12_MAKE_SHKEYBAG PKCS12_SAFEBAG_create_pkcs8_encrypt\n\n#endif\n\nDEPRECATEDIN_1_1_0(ASN1_TYPE *PKCS12_get_attr(const PKCS12_SAFEBAG *bag, int attr_nid))\n\nASN1_TYPE *PKCS8_get_attr(PKCS8_PRIV_KEY_INFO *p8, int attr_nid);\nint PKCS12_mac_present(const PKCS12 *p12);\nvoid PKCS12_get0_mac(const ASN1_OCTET_STRING **pmac,\n                     const X509_ALGOR **pmacalg,\n                     const ASN1_OCTET_STRING **psalt,\n                     const ASN1_INTEGER **piter,\n                     const PKCS12 *p12);\n\nconst ASN1_TYPE *PKCS12_SAFEBAG_get0_attr(const PKCS12_SAFEBAG *bag,\n                                          int attr_nid);\nconst ASN1_OBJECT *PKCS12_SAFEBAG_get0_type(const PKCS12_SAFEBAG *bag);\nint PKCS12_SAFEBAG_get_nid(const PKCS12_SAFEBAG *bag);\nint PKCS12_SAFEBAG_get_bag_nid(const PKCS12_SAFEBAG *bag);\n\nX509 *PKCS12_SAFEBAG_get1_cert(const PKCS12_SAFEBAG *bag);\nX509_CRL *PKCS12_SAFEBAG_get1_crl(const PKCS12_SAFEBAG *bag);\nconst STACK_OF(PKCS12_SAFEBAG) *\nPKCS12_SAFEBAG_get0_safes(const PKCS12_SAFEBAG *bag);\nconst PKCS8_PRIV_KEY_INFO *PKCS12_SAFEBAG_get0_p8inf(const PKCS12_SAFEBAG *bag);\nconst X509_SIG *PKCS12_SAFEBAG_get0_pkcs8(const PKCS12_SAFEBAG *bag);\n\nPKCS12_SAFEBAG *PKCS12_SAFEBAG_create_cert(X509 *x509);\nPKCS12_SAFEBAG *PKCS12_SAFEBAG_create_crl(X509_CRL *crl);\nPKCS12_SAFEBAG *PKCS12_SAFEBAG_create0_p8inf(PKCS8_PRIV_KEY_INFO *p8);\nPKCS12_SAFEBAG *PKCS12_SAFEBAG_create0_pkcs8(X509_SIG *p8);\nPKCS12_SAFEBAG *PKCS12_SAFEBAG_create_pkcs8_encrypt(int pbe_nid,\n                                                    const char *pass,\n                                                    int passlen,\n                                                    unsigned char *salt,\n                                                    int saltlen, int iter,\n                                                    PKCS8_PRIV_KEY_INFO *p8inf);\n\nPKCS12_SAFEBAG *PKCS12_item_pack_safebag(void *obj, const ASN1_ITEM *it,\n                                         int nid1, int nid2);\nPKCS8_PRIV_KEY_INFO *PKCS8_decrypt(const X509_SIG *p8, const char *pass,\n                                   int passlen);\nPKCS8_PRIV_KEY_INFO *PKCS12_decrypt_skey(const PKCS12_SAFEBAG *bag,\n                                         const char *pass, int passlen);\nX509_SIG *PKCS8_encrypt(int pbe_nid, const EVP_CIPHER *cipher,\n                        const char *pass, int passlen, unsigned char *salt,\n                        int saltlen, int iter, PKCS8_PRIV_KEY_INFO *p8);\nX509_SIG *PKCS8_set0_pbe(const char *pass, int passlen,\n                        PKCS8_PRIV_KEY_INFO *p8inf, X509_ALGOR *pbe);\nPKCS7 *PKCS12_pack_p7data(STACK_OF(PKCS12_SAFEBAG) *sk);\nSTACK_OF(PKCS12_SAFEBAG) *PKCS12_unpack_p7data(PKCS7 *p7);\nPKCS7 *PKCS12_pack_p7encdata(int pbe_nid, const char *pass, int passlen,\n                             unsigned char *salt, int saltlen, int iter,\n                             STACK_OF(PKCS12_SAFEBAG) *bags);\nSTACK_OF(PKCS12_SAFEBAG) *PKCS12_unpack_p7encdata(PKCS7 *p7, const char *pass,\n                                                  int passlen);\n\nint PKCS12_pack_authsafes(PKCS12 *p12, STACK_OF(PKCS7) *safes);\nSTACK_OF(PKCS7) *PKCS12_unpack_authsafes(const PKCS12 *p12);\n\nint PKCS12_add_localkeyid(PKCS12_SAFEBAG *bag, unsigned char *name,\n                          int namelen);\nint PKCS12_add_friendlyname_asc(PKCS12_SAFEBAG *bag, const char *name,\n                                int namelen);\nint PKCS12_add_friendlyname_utf8(PKCS12_SAFEBAG *bag, const char *name,\n                                 int namelen);\nint PKCS12_add_CSPName_asc(PKCS12_SAFEBAG *bag, const char *name,\n                           int namelen);\nint PKCS12_add_friendlyname_uni(PKCS12_SAFEBAG *bag,\n                                const unsigned char *name, int namelen);\nint PKCS8_add_keyusage(PKCS8_PRIV_KEY_INFO *p8, int usage);\nASN1_TYPE *PKCS12_get_attr_gen(const STACK_OF(X509_ATTRIBUTE) *attrs,\n                               int attr_nid);\nchar *PKCS12_get_friendlyname(PKCS12_SAFEBAG *bag);\nconst STACK_OF(X509_ATTRIBUTE) *\nPKCS12_SAFEBAG_get0_attrs(const PKCS12_SAFEBAG *bag);\nunsigned char *PKCS12_pbe_crypt(const X509_ALGOR *algor,\n                                const char *pass, int passlen,\n                                const unsigned char *in, int inlen,\n                                unsigned char **data, int *datalen,\n                                int en_de);\nvoid *PKCS12_item_decrypt_d2i(const X509_ALGOR *algor, const ASN1_ITEM *it,\n                              const char *pass, int passlen,\n                              const ASN1_OCTET_STRING *oct, int zbuf);\nASN1_OCTET_STRING *PKCS12_item_i2d_encrypt(X509_ALGOR *algor,\n                                           const ASN1_ITEM *it,\n                                           const char *pass, int passlen,\n                                           void *obj, int zbuf);\nPKCS12 *PKCS12_init(int mode);\nint PKCS12_key_gen_asc(const char *pass, int passlen, unsigned char *salt,\n                       int saltlen, int id, int iter, int n,\n                       unsigned char *out, const EVP_MD *md_type);\nint PKCS12_key_gen_uni(unsigned char *pass, int passlen, unsigned char *salt,\n                       int saltlen, int id, int iter, int n,\n                       unsigned char *out, const EVP_MD *md_type);\nint PKCS12_key_gen_utf8(const char *pass, int passlen, unsigned char *salt,\n                        int saltlen, int id, int iter, int n,\n                        unsigned char *out, const EVP_MD *md_type);\nint PKCS12_PBE_keyivgen(EVP_CIPHER_CTX *ctx, const char *pass, int passlen,\n                        ASN1_TYPE *param, const EVP_CIPHER *cipher,\n                        const EVP_MD *md_type, int en_de);\nint PKCS12_gen_mac(PKCS12 *p12, const char *pass, int passlen,\n                   unsigned char *mac, unsigned int *maclen);\nint PKCS12_verify_mac(PKCS12 *p12, const char *pass, int passlen);\nint PKCS12_set_mac(PKCS12 *p12, const char *pass, int passlen,\n                   unsigned char *salt, int saltlen, int iter,\n                   const EVP_MD *md_type);\nint PKCS12_setup_mac(PKCS12 *p12, int iter, unsigned char *salt,\n                     int saltlen, const EVP_MD *md_type);\nunsigned char *OPENSSL_asc2uni(const char *asc, int asclen,\n                               unsigned char **uni, int *unilen);\nchar *OPENSSL_uni2asc(const unsigned char *uni, int unilen);\nunsigned char *OPENSSL_utf82uni(const char *asc, int asclen,\n                                unsigned char **uni, int *unilen);\nchar *OPENSSL_uni2utf8(const unsigned char *uni, int unilen);\n\nDECLARE_ASN1_FUNCTIONS(PKCS12)\nDECLARE_ASN1_FUNCTIONS(PKCS12_MAC_DATA)\nDECLARE_ASN1_FUNCTIONS(PKCS12_SAFEBAG)\nDECLARE_ASN1_FUNCTIONS(PKCS12_BAGS)\n\nDECLARE_ASN1_ITEM(PKCS12_SAFEBAGS)\nDECLARE_ASN1_ITEM(PKCS12_AUTHSAFES)\n\nvoid PKCS12_PBE_add(void);\nint PKCS12_parse(PKCS12 *p12, const char *pass, EVP_PKEY **pkey, X509 **cert,\n                 STACK_OF(X509) **ca);\nPKCS12 *PKCS12_create(const char *pass, const char *name, EVP_PKEY *pkey,\n                      X509 *cert, STACK_OF(X509) *ca, int nid_key, int nid_cert,\n                      int iter, int mac_iter, int keytype);\n\nPKCS12_SAFEBAG *PKCS12_add_cert(STACK_OF(PKCS12_SAFEBAG) **pbags, X509 *cert);\nPKCS12_SAFEBAG *PKCS12_add_key(STACK_OF(PKCS12_SAFEBAG) **pbags,\n                               EVP_PKEY *key, int key_usage, int iter,\n                               int key_nid, const char *pass);\nint PKCS12_add_safe(STACK_OF(PKCS7) **psafes, STACK_OF(PKCS12_SAFEBAG) *bags,\n                    int safe_nid, int iter, const char *pass);\nPKCS12 *PKCS12_add_safes(STACK_OF(PKCS7) *safes, int p7_nid);\n\nint i2d_PKCS12_bio(BIO *bp, PKCS12 *p12);\n# ifndef OPENSSL_NO_STDIO\nint i2d_PKCS12_fp(FILE *fp, PKCS12 *p12);\n# endif\nPKCS12 *d2i_PKCS12_bio(BIO *bp, PKCS12 **p12);\n# ifndef OPENSSL_NO_STDIO\nPKCS12 *d2i_PKCS12_fp(FILE *fp, PKCS12 **p12);\n# endif\nint PKCS12_newpass(PKCS12 *p12, const char *oldpass, const char *newpass);\n\n# ifdef  __cplusplus\n}\n# endif\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/include/openssl/pkcs12err.h",
    "content": "/*\n * Generated by util/mkerr.pl DO NOT EDIT\n * Copyright 1995-2019 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef HEADER_PKCS12ERR_H\n# define HEADER_PKCS12ERR_H\n\n# ifndef HEADER_SYMHACKS_H\n#  include <openssl/symhacks.h>\n# endif\n\n# ifdef  __cplusplus\nextern \"C\"\n# endif\nint ERR_load_PKCS12_strings(void);\n\n/*\n * PKCS12 function codes.\n */\n# define PKCS12_F_OPENSSL_ASC2UNI                         121\n# define PKCS12_F_OPENSSL_UNI2ASC                         124\n# define PKCS12_F_OPENSSL_UNI2UTF8                        127\n# define PKCS12_F_OPENSSL_UTF82UNI                        129\n# define PKCS12_F_PKCS12_CREATE                           105\n# define PKCS12_F_PKCS12_GEN_MAC                          107\n# define PKCS12_F_PKCS12_INIT                             109\n# define PKCS12_F_PKCS12_ITEM_DECRYPT_D2I                 106\n# define PKCS12_F_PKCS12_ITEM_I2D_ENCRYPT                 108\n# define PKCS12_F_PKCS12_ITEM_PACK_SAFEBAG                117\n# define PKCS12_F_PKCS12_KEY_GEN_ASC                      110\n# define PKCS12_F_PKCS12_KEY_GEN_UNI                      111\n# define PKCS12_F_PKCS12_KEY_GEN_UTF8                     116\n# define PKCS12_F_PKCS12_NEWPASS                          128\n# define PKCS12_F_PKCS12_PACK_P7DATA                      114\n# define PKCS12_F_PKCS12_PACK_P7ENCDATA                   115\n# define PKCS12_F_PKCS12_PARSE                            118\n# define PKCS12_F_PKCS12_PBE_CRYPT                        119\n# define PKCS12_F_PKCS12_PBE_KEYIVGEN                     120\n# define PKCS12_F_PKCS12_SAFEBAG_CREATE0_P8INF            112\n# define PKCS12_F_PKCS12_SAFEBAG_CREATE0_PKCS8            113\n# define PKCS12_F_PKCS12_SAFEBAG_CREATE_PKCS8_ENCRYPT     133\n# define PKCS12_F_PKCS12_SETUP_MAC                        122\n# define PKCS12_F_PKCS12_SET_MAC                          123\n# define PKCS12_F_PKCS12_UNPACK_AUTHSAFES                 130\n# define PKCS12_F_PKCS12_UNPACK_P7DATA                    131\n# define PKCS12_F_PKCS12_VERIFY_MAC                       126\n# define PKCS12_F_PKCS8_ENCRYPT                           125\n# define PKCS12_F_PKCS8_SET0_PBE                          132\n\n/*\n * PKCS12 reason codes.\n */\n# define PKCS12_R_CANT_PACK_STRUCTURE                     100\n# define PKCS12_R_CONTENT_TYPE_NOT_DATA                   121\n# define PKCS12_R_DECODE_ERROR                            101\n# define PKCS12_R_ENCODE_ERROR                            102\n# define PKCS12_R_ENCRYPT_ERROR                           103\n# define PKCS12_R_ERROR_SETTING_ENCRYPTED_DATA_TYPE       120\n# define PKCS12_R_INVALID_NULL_ARGUMENT                   104\n# define PKCS12_R_INVALID_NULL_PKCS12_POINTER             105\n# define PKCS12_R_IV_GEN_ERROR                            106\n# define PKCS12_R_KEY_GEN_ERROR                           107\n# define PKCS12_R_MAC_ABSENT                              108\n# define PKCS12_R_MAC_GENERATION_ERROR                    109\n# define PKCS12_R_MAC_SETUP_ERROR                         110\n# define PKCS12_R_MAC_STRING_SET_ERROR                    111\n# define PKCS12_R_MAC_VERIFY_FAILURE                      113\n# define PKCS12_R_PARSE_ERROR                             114\n# define PKCS12_R_PKCS12_ALGOR_CIPHERINIT_ERROR           115\n# define PKCS12_R_PKCS12_CIPHERFINAL_ERROR                116\n# define PKCS12_R_PKCS12_PBE_CRYPT_ERROR                  117\n# define PKCS12_R_UNKNOWN_DIGEST_ALGORITHM                118\n# define PKCS12_R_UNSUPPORTED_PKCS12_MODE                 119\n\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/include/openssl/pkcs7.h",
    "content": "/*\n * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef HEADER_PKCS7_H\n# define HEADER_PKCS7_H\n\n# include <openssl/asn1.h>\n# include <openssl/bio.h>\n# include <openssl/e_os2.h>\n\n# include <openssl/symhacks.h>\n# include <openssl/ossl_typ.h>\n# include <openssl/pkcs7err.h>\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n/*-\nEncryption_ID           DES-CBC\nDigest_ID               MD5\nDigest_Encryption_ID    rsaEncryption\nKey_Encryption_ID       rsaEncryption\n*/\n\ntypedef struct pkcs7_issuer_and_serial_st {\n    X509_NAME *issuer;\n    ASN1_INTEGER *serial;\n} PKCS7_ISSUER_AND_SERIAL;\n\ntypedef struct pkcs7_signer_info_st {\n    ASN1_INTEGER *version;      /* version 1 */\n    PKCS7_ISSUER_AND_SERIAL *issuer_and_serial;\n    X509_ALGOR *digest_alg;\n    STACK_OF(X509_ATTRIBUTE) *auth_attr; /* [ 0 ] */\n    X509_ALGOR *digest_enc_alg;\n    ASN1_OCTET_STRING *enc_digest;\n    STACK_OF(X509_ATTRIBUTE) *unauth_attr; /* [ 1 ] */\n    /* The private key to sign with */\n    EVP_PKEY *pkey;\n} PKCS7_SIGNER_INFO;\n\nDEFINE_STACK_OF(PKCS7_SIGNER_INFO)\n\ntypedef struct pkcs7_recip_info_st {\n    ASN1_INTEGER *version;      /* version 0 */\n    PKCS7_ISSUER_AND_SERIAL *issuer_and_serial;\n    X509_ALGOR *key_enc_algor;\n    ASN1_OCTET_STRING *enc_key;\n    X509 *cert;                 /* get the pub-key from this */\n} PKCS7_RECIP_INFO;\n\nDEFINE_STACK_OF(PKCS7_RECIP_INFO)\n\ntypedef struct pkcs7_signed_st {\n    ASN1_INTEGER *version;      /* version 1 */\n    STACK_OF(X509_ALGOR) *md_algs; /* md used */\n    STACK_OF(X509) *cert;       /* [ 0 ] */\n    STACK_OF(X509_CRL) *crl;    /* [ 1 ] */\n    STACK_OF(PKCS7_SIGNER_INFO) *signer_info;\n    struct pkcs7_st *contents;\n} PKCS7_SIGNED;\n/*\n * The above structure is very very similar to PKCS7_SIGN_ENVELOPE. How about\n * merging the two\n */\n\ntypedef struct pkcs7_enc_content_st {\n    ASN1_OBJECT *content_type;\n    X509_ALGOR *algorithm;\n    ASN1_OCTET_STRING *enc_data; /* [ 0 ] */\n    const EVP_CIPHER *cipher;\n} PKCS7_ENC_CONTENT;\n\ntypedef struct pkcs7_enveloped_st {\n    ASN1_INTEGER *version;      /* version 0 */\n    STACK_OF(PKCS7_RECIP_INFO) *recipientinfo;\n    PKCS7_ENC_CONTENT *enc_data;\n} PKCS7_ENVELOPE;\n\ntypedef struct pkcs7_signedandenveloped_st {\n    ASN1_INTEGER *version;      /* version 1 */\n    STACK_OF(X509_ALGOR) *md_algs; /* md used */\n    STACK_OF(X509) *cert;       /* [ 0 ] */\n    STACK_OF(X509_CRL) *crl;    /* [ 1 ] */\n    STACK_OF(PKCS7_SIGNER_INFO) *signer_info;\n    PKCS7_ENC_CONTENT *enc_data;\n    STACK_OF(PKCS7_RECIP_INFO) *recipientinfo;\n} PKCS7_SIGN_ENVELOPE;\n\ntypedef struct pkcs7_digest_st {\n    ASN1_INTEGER *version;      /* version 0 */\n    X509_ALGOR *md;             /* md used */\n    struct pkcs7_st *contents;\n    ASN1_OCTET_STRING *digest;\n} PKCS7_DIGEST;\n\ntypedef struct pkcs7_encrypted_st {\n    ASN1_INTEGER *version;      /* version 0 */\n    PKCS7_ENC_CONTENT *enc_data;\n} PKCS7_ENCRYPT;\n\ntypedef struct pkcs7_st {\n    /*\n     * The following is non NULL if it contains ASN1 encoding of this\n     * structure\n     */\n    unsigned char *asn1;\n    long length;\n# define PKCS7_S_HEADER  0\n# define PKCS7_S_BODY    1\n# define PKCS7_S_TAIL    2\n    int state;                  /* used during processing */\n    int detached;\n    ASN1_OBJECT *type;\n    /* content as defined by the type */\n    /*\n     * all encryption/message digests are applied to the 'contents', leaving\n     * out the 'type' field.\n     */\n    union {\n        char *ptr;\n        /* NID_pkcs7_data */\n        ASN1_OCTET_STRING *data;\n        /* NID_pkcs7_signed */\n        PKCS7_SIGNED *sign;\n        /* NID_pkcs7_enveloped */\n        PKCS7_ENVELOPE *enveloped;\n        /* NID_pkcs7_signedAndEnveloped */\n        PKCS7_SIGN_ENVELOPE *signed_and_enveloped;\n        /* NID_pkcs7_digest */\n        PKCS7_DIGEST *digest;\n        /* NID_pkcs7_encrypted */\n        PKCS7_ENCRYPT *encrypted;\n        /* Anything else */\n        ASN1_TYPE *other;\n    } d;\n} PKCS7;\n\nDEFINE_STACK_OF(PKCS7)\n\n# define PKCS7_OP_SET_DETACHED_SIGNATURE 1\n# define PKCS7_OP_GET_DETACHED_SIGNATURE 2\n\n# define PKCS7_get_signed_attributes(si) ((si)->auth_attr)\n# define PKCS7_get_attributes(si)        ((si)->unauth_attr)\n\n# define PKCS7_type_is_signed(a) (OBJ_obj2nid((a)->type) == NID_pkcs7_signed)\n# define PKCS7_type_is_encrypted(a) (OBJ_obj2nid((a)->type) == NID_pkcs7_encrypted)\n# define PKCS7_type_is_enveloped(a) (OBJ_obj2nid((a)->type) == NID_pkcs7_enveloped)\n# define PKCS7_type_is_signedAndEnveloped(a) \\\n                (OBJ_obj2nid((a)->type) == NID_pkcs7_signedAndEnveloped)\n# define PKCS7_type_is_data(a)   (OBJ_obj2nid((a)->type) == NID_pkcs7_data)\n# define PKCS7_type_is_digest(a)   (OBJ_obj2nid((a)->type) == NID_pkcs7_digest)\n\n# define PKCS7_set_detached(p,v) \\\n                PKCS7_ctrl(p,PKCS7_OP_SET_DETACHED_SIGNATURE,v,NULL)\n# define PKCS7_get_detached(p) \\\n                PKCS7_ctrl(p,PKCS7_OP_GET_DETACHED_SIGNATURE,0,NULL)\n\n# define PKCS7_is_detached(p7) (PKCS7_type_is_signed(p7) && PKCS7_get_detached(p7))\n\n/* S/MIME related flags */\n\n# define PKCS7_TEXT              0x1\n# define PKCS7_NOCERTS           0x2\n# define PKCS7_NOSIGS            0x4\n# define PKCS7_NOCHAIN           0x8\n# define PKCS7_NOINTERN          0x10\n# define PKCS7_NOVERIFY          0x20\n# define PKCS7_DETACHED          0x40\n# define PKCS7_BINARY            0x80\n# define PKCS7_NOATTR            0x100\n# define PKCS7_NOSMIMECAP        0x200\n# define PKCS7_NOOLDMIMETYPE     0x400\n# define PKCS7_CRLFEOL           0x800\n# define PKCS7_STREAM            0x1000\n# define PKCS7_NOCRL             0x2000\n# define PKCS7_PARTIAL           0x4000\n# define PKCS7_REUSE_DIGEST      0x8000\n# define PKCS7_NO_DUAL_CONTENT   0x10000\n\n/* Flags: for compatibility with older code */\n\n# define SMIME_TEXT      PKCS7_TEXT\n# define SMIME_NOCERTS   PKCS7_NOCERTS\n# define SMIME_NOSIGS    PKCS7_NOSIGS\n# define SMIME_NOCHAIN   PKCS7_NOCHAIN\n# define SMIME_NOINTERN  PKCS7_NOINTERN\n# define SMIME_NOVERIFY  PKCS7_NOVERIFY\n# define SMIME_DETACHED  PKCS7_DETACHED\n# define SMIME_BINARY    PKCS7_BINARY\n# define SMIME_NOATTR    PKCS7_NOATTR\n\n/* CRLF ASCII canonicalisation */\n# define SMIME_ASCIICRLF         0x80000\n\nDECLARE_ASN1_FUNCTIONS(PKCS7_ISSUER_AND_SERIAL)\n\nint PKCS7_ISSUER_AND_SERIAL_digest(PKCS7_ISSUER_AND_SERIAL *data,\n                                   const EVP_MD *type, unsigned char *md,\n                                   unsigned int *len);\n# ifndef OPENSSL_NO_STDIO\nPKCS7 *d2i_PKCS7_fp(FILE *fp, PKCS7 **p7);\nint i2d_PKCS7_fp(FILE *fp, PKCS7 *p7);\n# endif\nPKCS7 *PKCS7_dup(PKCS7 *p7);\nPKCS7 *d2i_PKCS7_bio(BIO *bp, PKCS7 **p7);\nint i2d_PKCS7_bio(BIO *bp, PKCS7 *p7);\nint i2d_PKCS7_bio_stream(BIO *out, PKCS7 *p7, BIO *in, int flags);\nint PEM_write_bio_PKCS7_stream(BIO *out, PKCS7 *p7, BIO *in, int flags);\n\nDECLARE_ASN1_FUNCTIONS(PKCS7_SIGNER_INFO)\nDECLARE_ASN1_FUNCTIONS(PKCS7_RECIP_INFO)\nDECLARE_ASN1_FUNCTIONS(PKCS7_SIGNED)\nDECLARE_ASN1_FUNCTIONS(PKCS7_ENC_CONTENT)\nDECLARE_ASN1_FUNCTIONS(PKCS7_ENVELOPE)\nDECLARE_ASN1_FUNCTIONS(PKCS7_SIGN_ENVELOPE)\nDECLARE_ASN1_FUNCTIONS(PKCS7_DIGEST)\nDECLARE_ASN1_FUNCTIONS(PKCS7_ENCRYPT)\nDECLARE_ASN1_FUNCTIONS(PKCS7)\n\nDECLARE_ASN1_ITEM(PKCS7_ATTR_SIGN)\nDECLARE_ASN1_ITEM(PKCS7_ATTR_VERIFY)\n\nDECLARE_ASN1_NDEF_FUNCTION(PKCS7)\nDECLARE_ASN1_PRINT_FUNCTION(PKCS7)\n\nlong PKCS7_ctrl(PKCS7 *p7, int cmd, long larg, char *parg);\n\nint PKCS7_set_type(PKCS7 *p7, int type);\nint PKCS7_set0_type_other(PKCS7 *p7, int type, ASN1_TYPE *other);\nint PKCS7_set_content(PKCS7 *p7, PKCS7 *p7_data);\nint PKCS7_SIGNER_INFO_set(PKCS7_SIGNER_INFO *p7i, X509 *x509, EVP_PKEY *pkey,\n                          const EVP_MD *dgst);\nint PKCS7_SIGNER_INFO_sign(PKCS7_SIGNER_INFO *si);\nint PKCS7_add_signer(PKCS7 *p7, PKCS7_SIGNER_INFO *p7i);\nint PKCS7_add_certificate(PKCS7 *p7, X509 *x509);\nint PKCS7_add_crl(PKCS7 *p7, X509_CRL *x509);\nint PKCS7_content_new(PKCS7 *p7, int nid);\nint PKCS7_dataVerify(X509_STORE *cert_store, X509_STORE_CTX *ctx,\n                     BIO *bio, PKCS7 *p7, PKCS7_SIGNER_INFO *si);\nint PKCS7_signatureVerify(BIO *bio, PKCS7 *p7, PKCS7_SIGNER_INFO *si,\n                          X509 *x509);\n\nBIO *PKCS7_dataInit(PKCS7 *p7, BIO *bio);\nint PKCS7_dataFinal(PKCS7 *p7, BIO *bio);\nBIO *PKCS7_dataDecode(PKCS7 *p7, EVP_PKEY *pkey, BIO *in_bio, X509 *pcert);\n\nPKCS7_SIGNER_INFO *PKCS7_add_signature(PKCS7 *p7, X509 *x509,\n                                       EVP_PKEY *pkey, const EVP_MD *dgst);\nX509 *PKCS7_cert_from_signer_info(PKCS7 *p7, PKCS7_SIGNER_INFO *si);\nint PKCS7_set_digest(PKCS7 *p7, const EVP_MD *md);\nSTACK_OF(PKCS7_SIGNER_INFO) *PKCS7_get_signer_info(PKCS7 *p7);\n\nPKCS7_RECIP_INFO *PKCS7_add_recipient(PKCS7 *p7, X509 *x509);\nvoid PKCS7_SIGNER_INFO_get0_algs(PKCS7_SIGNER_INFO *si, EVP_PKEY **pk,\n                                 X509_ALGOR **pdig, X509_ALGOR **psig);\nvoid PKCS7_RECIP_INFO_get0_alg(PKCS7_RECIP_INFO *ri, X509_ALGOR **penc);\nint PKCS7_add_recipient_info(PKCS7 *p7, PKCS7_RECIP_INFO *ri);\nint PKCS7_RECIP_INFO_set(PKCS7_RECIP_INFO *p7i, X509 *x509);\nint PKCS7_set_cipher(PKCS7 *p7, const EVP_CIPHER *cipher);\nint PKCS7_stream(unsigned char ***boundary, PKCS7 *p7);\n\nPKCS7_ISSUER_AND_SERIAL *PKCS7_get_issuer_and_serial(PKCS7 *p7, int idx);\nASN1_OCTET_STRING *PKCS7_digest_from_attributes(STACK_OF(X509_ATTRIBUTE) *sk);\nint PKCS7_add_signed_attribute(PKCS7_SIGNER_INFO *p7si, int nid, int type,\n                               void *data);\nint PKCS7_add_attribute(PKCS7_SIGNER_INFO *p7si, int nid, int atrtype,\n                        void *value);\nASN1_TYPE *PKCS7_get_attribute(PKCS7_SIGNER_INFO *si, int nid);\nASN1_TYPE *PKCS7_get_signed_attribute(PKCS7_SIGNER_INFO *si, int nid);\nint PKCS7_set_signed_attributes(PKCS7_SIGNER_INFO *p7si,\n                                STACK_OF(X509_ATTRIBUTE) *sk);\nint PKCS7_set_attributes(PKCS7_SIGNER_INFO *p7si,\n                         STACK_OF(X509_ATTRIBUTE) *sk);\n\nPKCS7 *PKCS7_sign(X509 *signcert, EVP_PKEY *pkey, STACK_OF(X509) *certs,\n                  BIO *data, int flags);\n\nPKCS7_SIGNER_INFO *PKCS7_sign_add_signer(PKCS7 *p7,\n                                         X509 *signcert, EVP_PKEY *pkey,\n                                         const EVP_MD *md, int flags);\n\nint PKCS7_final(PKCS7 *p7, BIO *data, int flags);\nint PKCS7_verify(PKCS7 *p7, STACK_OF(X509) *certs, X509_STORE *store,\n                 BIO *indata, BIO *out, int flags);\nSTACK_OF(X509) *PKCS7_get0_signers(PKCS7 *p7, STACK_OF(X509) *certs,\n                                   int flags);\nPKCS7 *PKCS7_encrypt(STACK_OF(X509) *certs, BIO *in, const EVP_CIPHER *cipher,\n                     int flags);\nint PKCS7_decrypt(PKCS7 *p7, EVP_PKEY *pkey, X509 *cert, BIO *data,\n                  int flags);\n\nint PKCS7_add_attrib_smimecap(PKCS7_SIGNER_INFO *si,\n                              STACK_OF(X509_ALGOR) *cap);\nSTACK_OF(X509_ALGOR) *PKCS7_get_smimecap(PKCS7_SIGNER_INFO *si);\nint PKCS7_simple_smimecap(STACK_OF(X509_ALGOR) *sk, int nid, int arg);\n\nint PKCS7_add_attrib_content_type(PKCS7_SIGNER_INFO *si, ASN1_OBJECT *coid);\nint PKCS7_add0_attrib_signing_time(PKCS7_SIGNER_INFO *si, ASN1_TIME *t);\nint PKCS7_add1_attrib_digest(PKCS7_SIGNER_INFO *si,\n                             const unsigned char *md, int mdlen);\n\nint SMIME_write_PKCS7(BIO *bio, PKCS7 *p7, BIO *data, int flags);\nPKCS7 *SMIME_read_PKCS7(BIO *bio, BIO **bcont);\n\nBIO *BIO_new_PKCS7(BIO *out, PKCS7 *p7);\n\n# ifdef  __cplusplus\n}\n# endif\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/include/openssl/pkcs7err.h",
    "content": "/*\n * Generated by util/mkerr.pl DO NOT EDIT\n * Copyright 1995-2019 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef HEADER_PKCS7ERR_H\n# define HEADER_PKCS7ERR_H\n\n# ifndef HEADER_SYMHACKS_H\n#  include <openssl/symhacks.h>\n# endif\n\n# ifdef  __cplusplus\nextern \"C\"\n# endif\nint ERR_load_PKCS7_strings(void);\n\n/*\n * PKCS7 function codes.\n */\n# define PKCS7_F_DO_PKCS7_SIGNED_ATTRIB                   136\n# define PKCS7_F_PKCS7_ADD0_ATTRIB_SIGNING_TIME           135\n# define PKCS7_F_PKCS7_ADD_ATTRIB_SMIMECAP                118\n# define PKCS7_F_PKCS7_ADD_CERTIFICATE                    100\n# define PKCS7_F_PKCS7_ADD_CRL                            101\n# define PKCS7_F_PKCS7_ADD_RECIPIENT_INFO                 102\n# define PKCS7_F_PKCS7_ADD_SIGNATURE                      131\n# define PKCS7_F_PKCS7_ADD_SIGNER                         103\n# define PKCS7_F_PKCS7_BIO_ADD_DIGEST                     125\n# define PKCS7_F_PKCS7_COPY_EXISTING_DIGEST               138\n# define PKCS7_F_PKCS7_CTRL                               104\n# define PKCS7_F_PKCS7_DATADECODE                         112\n# define PKCS7_F_PKCS7_DATAFINAL                          128\n# define PKCS7_F_PKCS7_DATAINIT                           105\n# define PKCS7_F_PKCS7_DATAVERIFY                         107\n# define PKCS7_F_PKCS7_DECRYPT                            114\n# define PKCS7_F_PKCS7_DECRYPT_RINFO                      133\n# define PKCS7_F_PKCS7_ENCODE_RINFO                       132\n# define PKCS7_F_PKCS7_ENCRYPT                            115\n# define PKCS7_F_PKCS7_FINAL                              134\n# define PKCS7_F_PKCS7_FIND_DIGEST                        127\n# define PKCS7_F_PKCS7_GET0_SIGNERS                       124\n# define PKCS7_F_PKCS7_RECIP_INFO_SET                     130\n# define PKCS7_F_PKCS7_SET_CIPHER                         108\n# define PKCS7_F_PKCS7_SET_CONTENT                        109\n# define PKCS7_F_PKCS7_SET_DIGEST                         126\n# define PKCS7_F_PKCS7_SET_TYPE                           110\n# define PKCS7_F_PKCS7_SIGN                               116\n# define PKCS7_F_PKCS7_SIGNATUREVERIFY                    113\n# define PKCS7_F_PKCS7_SIGNER_INFO_SET                    129\n# define PKCS7_F_PKCS7_SIGNER_INFO_SIGN                   139\n# define PKCS7_F_PKCS7_SIGN_ADD_SIGNER                    137\n# define PKCS7_F_PKCS7_SIMPLE_SMIMECAP                    119\n# define PKCS7_F_PKCS7_VERIFY                             117\n\n/*\n * PKCS7 reason codes.\n */\n# define PKCS7_R_CERTIFICATE_VERIFY_ERROR                 117\n# define PKCS7_R_CIPHER_HAS_NO_OBJECT_IDENTIFIER          144\n# define PKCS7_R_CIPHER_NOT_INITIALIZED                   116\n# define PKCS7_R_CONTENT_AND_DATA_PRESENT                 118\n# define PKCS7_R_CTRL_ERROR                               152\n# define PKCS7_R_DECRYPT_ERROR                            119\n# define PKCS7_R_DIGEST_FAILURE                           101\n# define PKCS7_R_ENCRYPTION_CTRL_FAILURE                  149\n# define PKCS7_R_ENCRYPTION_NOT_SUPPORTED_FOR_THIS_KEY_TYPE 150\n# define PKCS7_R_ERROR_ADDING_RECIPIENT                   120\n# define PKCS7_R_ERROR_SETTING_CIPHER                     121\n# define PKCS7_R_INVALID_NULL_POINTER                     143\n# define PKCS7_R_INVALID_SIGNED_DATA_TYPE                 155\n# define PKCS7_R_NO_CONTENT                               122\n# define PKCS7_R_NO_DEFAULT_DIGEST                        151\n# define PKCS7_R_NO_MATCHING_DIGEST_TYPE_FOUND            154\n# define PKCS7_R_NO_RECIPIENT_MATCHES_CERTIFICATE         115\n# define PKCS7_R_NO_SIGNATURES_ON_DATA                    123\n# define PKCS7_R_NO_SIGNERS                               142\n# define PKCS7_R_OPERATION_NOT_SUPPORTED_ON_THIS_TYPE     104\n# define PKCS7_R_PKCS7_ADD_SIGNATURE_ERROR                124\n# define PKCS7_R_PKCS7_ADD_SIGNER_ERROR                   153\n# define PKCS7_R_PKCS7_DATASIGN                           145\n# define PKCS7_R_PRIVATE_KEY_DOES_NOT_MATCH_CERTIFICATE   127\n# define PKCS7_R_SIGNATURE_FAILURE                        105\n# define PKCS7_R_SIGNER_CERTIFICATE_NOT_FOUND             128\n# define PKCS7_R_SIGNING_CTRL_FAILURE                     147\n# define PKCS7_R_SIGNING_NOT_SUPPORTED_FOR_THIS_KEY_TYPE  148\n# define PKCS7_R_SMIME_TEXT_ERROR                         129\n# define PKCS7_R_UNABLE_TO_FIND_CERTIFICATE               106\n# define PKCS7_R_UNABLE_TO_FIND_MEM_BIO                   107\n# define PKCS7_R_UNABLE_TO_FIND_MESSAGE_DIGEST            108\n# define PKCS7_R_UNKNOWN_DIGEST_TYPE                      109\n# define PKCS7_R_UNKNOWN_OPERATION                        110\n# define PKCS7_R_UNSUPPORTED_CIPHER_TYPE                  111\n# define PKCS7_R_UNSUPPORTED_CONTENT_TYPE                 112\n# define PKCS7_R_WRONG_CONTENT_TYPE                       113\n# define PKCS7_R_WRONG_PKCS7_TYPE                         114\n\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/include/openssl/rand.h",
    "content": "/*\n * Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef HEADER_RAND_H\n# define HEADER_RAND_H\n\n# include <stdlib.h>\n# include <openssl/ossl_typ.h>\n# include <openssl/e_os2.h>\n# include <openssl/randerr.h>\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\nstruct rand_meth_st {\n    int (*seed) (const void *buf, int num);\n    int (*bytes) (unsigned char *buf, int num);\n    void (*cleanup) (void);\n    int (*add) (const void *buf, int num, double randomness);\n    int (*pseudorand) (unsigned char *buf, int num);\n    int (*status) (void);\n};\n\nint RAND_set_rand_method(const RAND_METHOD *meth);\nconst RAND_METHOD *RAND_get_rand_method(void);\n# ifndef OPENSSL_NO_ENGINE\nint RAND_set_rand_engine(ENGINE *engine);\n# endif\n\nRAND_METHOD *RAND_OpenSSL(void);\n\n# if OPENSSL_API_COMPAT < 0x10100000L\n#   define RAND_cleanup() while(0) continue\n# endif\nint RAND_bytes(unsigned char *buf, int num);\nint RAND_priv_bytes(unsigned char *buf, int num);\nDEPRECATEDIN_1_1_0(int RAND_pseudo_bytes(unsigned char *buf, int num))\n\nvoid RAND_seed(const void *buf, int num);\nvoid RAND_keep_random_devices_open(int keep);\n\n# if defined(__ANDROID__) && defined(__NDK_FPABI__)\n__NDK_FPABI__\t/* __attribute__((pcs(\"aapcs\"))) on ARM */\n# endif\nvoid RAND_add(const void *buf, int num, double randomness);\nint RAND_load_file(const char *file, long max_bytes);\nint RAND_write_file(const char *file);\nconst char *RAND_file_name(char *file, size_t num);\nint RAND_status(void);\n\n# ifndef OPENSSL_NO_EGD\nint RAND_query_egd_bytes(const char *path, unsigned char *buf, int bytes);\nint RAND_egd(const char *path);\nint RAND_egd_bytes(const char *path, int bytes);\n# endif\n\nint RAND_poll(void);\n\n# if defined(_WIN32) && (defined(BASETYPES) || defined(_WINDEF_H))\n/* application has to include <windows.h> in order to use these */\nDEPRECATEDIN_1_1_0(void RAND_screen(void))\nDEPRECATEDIN_1_1_0(int RAND_event(UINT, WPARAM, LPARAM))\n# endif\n\n\n#ifdef  __cplusplus\n}\n#endif\n\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/include/openssl/rand_drbg.h",
    "content": "/*\n * Copyright 2017-2018 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef HEADER_DRBG_RAND_H\n# define HEADER_DRBG_RAND_H\n\n# include <time.h>\n# include <openssl/ossl_typ.h>\n# include <openssl/obj_mac.h>\n\n/*\n * RAND_DRBG  flags\n *\n * Note: if new flags are added, the constant `rand_drbg_used_flags`\n *       in drbg_lib.c needs to be updated accordingly.\n */\n\n/* In CTR mode, disable derivation function ctr_df */\n# define RAND_DRBG_FLAG_CTR_NO_DF            0x1\n\n\n# if OPENSSL_API_COMPAT < 0x10200000L\n/* This #define was replaced by an internal constant and should not be used. */\n#  define RAND_DRBG_USED_FLAGS  (RAND_DRBG_FLAG_CTR_NO_DF)\n# endif\n\n/*\n * Default security strength (in the sense of [NIST SP 800-90Ar1])\n *\n * NIST SP 800-90Ar1 supports the strength of the DRBG being smaller than that\n * of the cipher by collecting less entropy. The current DRBG implementation\n * does not take RAND_DRBG_STRENGTH into account and sets the strength of the\n * DRBG to that of the cipher.\n *\n * RAND_DRBG_STRENGTH is currently only used for the legacy RAND\n * implementation.\n *\n * Currently supported ciphers are: NID_aes_128_ctr, NID_aes_192_ctr and\n * NID_aes_256_ctr\n */\n# define RAND_DRBG_STRENGTH             256\n/* Default drbg type */\n# define RAND_DRBG_TYPE                 NID_aes_256_ctr\n/* Default drbg flags */\n# define RAND_DRBG_FLAGS                0\n\n\n# ifdef  __cplusplus\nextern \"C\" {\n# endif\n\n/*\n * Object lifetime functions.\n */\nRAND_DRBG *RAND_DRBG_new(int type, unsigned int flags, RAND_DRBG *parent);\nRAND_DRBG *RAND_DRBG_secure_new(int type, unsigned int flags, RAND_DRBG *parent);\nint RAND_DRBG_set(RAND_DRBG *drbg, int type, unsigned int flags);\nint RAND_DRBG_set_defaults(int type, unsigned int flags);\nint RAND_DRBG_instantiate(RAND_DRBG *drbg,\n                          const unsigned char *pers, size_t perslen);\nint RAND_DRBG_uninstantiate(RAND_DRBG *drbg);\nvoid RAND_DRBG_free(RAND_DRBG *drbg);\n\n/*\n * Object \"use\" functions.\n */\nint RAND_DRBG_reseed(RAND_DRBG *drbg,\n                     const unsigned char *adin, size_t adinlen,\n                     int prediction_resistance);\nint RAND_DRBG_generate(RAND_DRBG *drbg, unsigned char *out, size_t outlen,\n                       int prediction_resistance,\n                       const unsigned char *adin, size_t adinlen);\nint RAND_DRBG_bytes(RAND_DRBG *drbg, unsigned char *out, size_t outlen);\n\nint RAND_DRBG_set_reseed_interval(RAND_DRBG *drbg, unsigned int interval);\nint RAND_DRBG_set_reseed_time_interval(RAND_DRBG *drbg, time_t interval);\n\nint RAND_DRBG_set_reseed_defaults(\n                                  unsigned int master_reseed_interval,\n                                  unsigned int slave_reseed_interval,\n                                  time_t master_reseed_time_interval,\n                                  time_t slave_reseed_time_interval\n                                  );\n\nRAND_DRBG *RAND_DRBG_get0_master(void);\nRAND_DRBG *RAND_DRBG_get0_public(void);\nRAND_DRBG *RAND_DRBG_get0_private(void);\n\n/*\n * EXDATA\n */\n# define RAND_DRBG_get_ex_new_index(l, p, newf, dupf, freef) \\\n    CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_DRBG, l, p, newf, dupf, freef)\nint RAND_DRBG_set_ex_data(RAND_DRBG *drbg, int idx, void *arg);\nvoid *RAND_DRBG_get_ex_data(const RAND_DRBG *drbg, int idx);\n\n/*\n * Callback function typedefs\n */\ntypedef size_t (*RAND_DRBG_get_entropy_fn)(RAND_DRBG *drbg,\n                                           unsigned char **pout,\n                                           int entropy, size_t min_len,\n                                           size_t max_len,\n                                           int prediction_resistance);\ntypedef void (*RAND_DRBG_cleanup_entropy_fn)(RAND_DRBG *ctx,\n                                             unsigned char *out, size_t outlen);\ntypedef size_t (*RAND_DRBG_get_nonce_fn)(RAND_DRBG *drbg, unsigned char **pout,\n                                         int entropy, size_t min_len,\n                                         size_t max_len);\ntypedef void (*RAND_DRBG_cleanup_nonce_fn)(RAND_DRBG *drbg,\n                                           unsigned char *out, size_t outlen);\n\nint RAND_DRBG_set_callbacks(RAND_DRBG *drbg,\n                            RAND_DRBG_get_entropy_fn get_entropy,\n                            RAND_DRBG_cleanup_entropy_fn cleanup_entropy,\n                            RAND_DRBG_get_nonce_fn get_nonce,\n                            RAND_DRBG_cleanup_nonce_fn cleanup_nonce);\n\n\n# ifdef  __cplusplus\n}\n# endif\n\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/include/openssl/randerr.h",
    "content": "/*\n * Generated by util/mkerr.pl DO NOT EDIT\n * Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef HEADER_RANDERR_H\n# define HEADER_RANDERR_H\n\n# include <openssl/symhacks.h>\n\n# ifdef  __cplusplus\nextern \"C\"\n# endif\nint ERR_load_RAND_strings(void);\n\n/*\n * RAND function codes.\n */\n# define RAND_F_DATA_COLLECT_METHOD                       127\n# define RAND_F_DRBG_BYTES                                101\n# define RAND_F_DRBG_GET_ENTROPY                          105\n# define RAND_F_DRBG_SETUP                                117\n# define RAND_F_GET_ENTROPY                               106\n# define RAND_F_RAND_BYTES                                100\n# define RAND_F_RAND_DRBG_ENABLE_LOCKING                  119\n# define RAND_F_RAND_DRBG_GENERATE                        107\n# define RAND_F_RAND_DRBG_GET_ENTROPY                     120\n# define RAND_F_RAND_DRBG_GET_NONCE                       123\n# define RAND_F_RAND_DRBG_INSTANTIATE                     108\n# define RAND_F_RAND_DRBG_NEW                             109\n# define RAND_F_RAND_DRBG_RESEED                          110\n# define RAND_F_RAND_DRBG_RESTART                         102\n# define RAND_F_RAND_DRBG_SET                             104\n# define RAND_F_RAND_DRBG_SET_DEFAULTS                    121\n# define RAND_F_RAND_DRBG_UNINSTANTIATE                   118\n# define RAND_F_RAND_LOAD_FILE                            111\n# define RAND_F_RAND_POOL_ACQUIRE_ENTROPY                 122\n# define RAND_F_RAND_POOL_ADD                             103\n# define RAND_F_RAND_POOL_ADD_BEGIN                       113\n# define RAND_F_RAND_POOL_ADD_END                         114\n# define RAND_F_RAND_POOL_ATTACH                          124\n# define RAND_F_RAND_POOL_BYTES_NEEDED                    115\n# define RAND_F_RAND_POOL_GROW                            125\n# define RAND_F_RAND_POOL_NEW                             116\n# define RAND_F_RAND_PSEUDO_BYTES                         126\n# define RAND_F_RAND_WRITE_FILE                           112\n\n/*\n * RAND reason codes.\n */\n# define RAND_R_ADDITIONAL_INPUT_TOO_LONG                 102\n# define RAND_R_ALREADY_INSTANTIATED                      103\n# define RAND_R_ARGUMENT_OUT_OF_RANGE                     105\n# define RAND_R_CANNOT_OPEN_FILE                          121\n# define RAND_R_DRBG_ALREADY_INITIALIZED                  129\n# define RAND_R_DRBG_NOT_INITIALISED                      104\n# define RAND_R_ENTROPY_INPUT_TOO_LONG                    106\n# define RAND_R_ENTROPY_OUT_OF_RANGE                      124\n# define RAND_R_ERROR_ENTROPY_POOL_WAS_IGNORED            127\n# define RAND_R_ERROR_INITIALISING_DRBG                   107\n# define RAND_R_ERROR_INSTANTIATING_DRBG                  108\n# define RAND_R_ERROR_RETRIEVING_ADDITIONAL_INPUT         109\n# define RAND_R_ERROR_RETRIEVING_ENTROPY                  110\n# define RAND_R_ERROR_RETRIEVING_NONCE                    111\n# define RAND_R_FAILED_TO_CREATE_LOCK                     126\n# define RAND_R_FUNC_NOT_IMPLEMENTED                      101\n# define RAND_R_FWRITE_ERROR                              123\n# define RAND_R_GENERATE_ERROR                            112\n# define RAND_R_INTERNAL_ERROR                            113\n# define RAND_R_IN_ERROR_STATE                            114\n# define RAND_R_NOT_A_REGULAR_FILE                        122\n# define RAND_R_NOT_INSTANTIATED                          115\n# define RAND_R_NO_DRBG_IMPLEMENTATION_SELECTED           128\n# define RAND_R_PARENT_LOCKING_NOT_ENABLED                130\n# define RAND_R_PARENT_STRENGTH_TOO_WEAK                  131\n# define RAND_R_PERSONALISATION_STRING_TOO_LONG           116\n# define RAND_R_PREDICTION_RESISTANCE_NOT_SUPPORTED       133\n# define RAND_R_PRNG_NOT_SEEDED                           100\n# define RAND_R_RANDOM_POOL_OVERFLOW                      125\n# define RAND_R_RANDOM_POOL_UNDERFLOW                     134\n# define RAND_R_REQUEST_TOO_LARGE_FOR_DRBG                117\n# define RAND_R_RESEED_ERROR                              118\n# define RAND_R_SELFTEST_FAILURE                          119\n# define RAND_R_TOO_LITTLE_NONCE_REQUESTED                135\n# define RAND_R_TOO_MUCH_NONCE_REQUESTED                  136\n# define RAND_R_UNSUPPORTED_DRBG_FLAGS                    132\n# define RAND_R_UNSUPPORTED_DRBG_TYPE                     120\n\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/include/openssl/rc2.h",
    "content": "/*\n * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef HEADER_RC2_H\n# define HEADER_RC2_H\n\n# include <openssl/opensslconf.h>\n\n# ifndef OPENSSL_NO_RC2\n# ifdef  __cplusplus\nextern \"C\" {\n# endif\n\ntypedef unsigned int RC2_INT;\n\n# define RC2_ENCRYPT     1\n# define RC2_DECRYPT     0\n\n# define RC2_BLOCK       8\n# define RC2_KEY_LENGTH  16\n\ntypedef struct rc2_key_st {\n    RC2_INT data[64];\n} RC2_KEY;\n\nvoid RC2_set_key(RC2_KEY *key, int len, const unsigned char *data, int bits);\nvoid RC2_ecb_encrypt(const unsigned char *in, unsigned char *out,\n                     RC2_KEY *key, int enc);\nvoid RC2_encrypt(unsigned long *data, RC2_KEY *key);\nvoid RC2_decrypt(unsigned long *data, RC2_KEY *key);\nvoid RC2_cbc_encrypt(const unsigned char *in, unsigned char *out, long length,\n                     RC2_KEY *ks, unsigned char *iv, int enc);\nvoid RC2_cfb64_encrypt(const unsigned char *in, unsigned char *out,\n                       long length, RC2_KEY *schedule, unsigned char *ivec,\n                       int *num, int enc);\nvoid RC2_ofb64_encrypt(const unsigned char *in, unsigned char *out,\n                       long length, RC2_KEY *schedule, unsigned char *ivec,\n                       int *num);\n\n# ifdef  __cplusplus\n}\n# endif\n# endif\n\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/include/openssl/rc4.h",
    "content": "/*\n * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef HEADER_RC4_H\n# define HEADER_RC4_H\n\n# include <openssl/opensslconf.h>\n\n# ifndef OPENSSL_NO_RC4\n# include <stddef.h>\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\ntypedef struct rc4_key_st {\n    RC4_INT x, y;\n    RC4_INT data[256];\n} RC4_KEY;\n\nconst char *RC4_options(void);\nvoid RC4_set_key(RC4_KEY *key, int len, const unsigned char *data);\nvoid RC4(RC4_KEY *key, size_t len, const unsigned char *indata,\n         unsigned char *outdata);\n\n# ifdef  __cplusplus\n}\n# endif\n# endif\n\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/include/openssl/rc5.h",
    "content": "/*\n * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef HEADER_RC5_H\n# define HEADER_RC5_H\n\n# include <openssl/opensslconf.h>\n\n# ifndef OPENSSL_NO_RC5\n# ifdef  __cplusplus\nextern \"C\" {\n# endif\n\n# define RC5_ENCRYPT     1\n# define RC5_DECRYPT     0\n\n# define RC5_32_INT unsigned int\n\n# define RC5_32_BLOCK            8\n# define RC5_32_KEY_LENGTH       16/* This is a default, max is 255 */\n\n/*\n * This are the only values supported.  Tweak the code if you want more The\n * most supported modes will be RC5-32/12/16 RC5-32/16/8\n */\n# define RC5_8_ROUNDS    8\n# define RC5_12_ROUNDS   12\n# define RC5_16_ROUNDS   16\n\ntypedef struct rc5_key_st {\n    /* Number of rounds */\n    int rounds;\n    RC5_32_INT data[2 * (RC5_16_ROUNDS + 1)];\n} RC5_32_KEY;\n\nvoid RC5_32_set_key(RC5_32_KEY *key, int len, const unsigned char *data,\n                    int rounds);\nvoid RC5_32_ecb_encrypt(const unsigned char *in, unsigned char *out,\n                        RC5_32_KEY *key, int enc);\nvoid RC5_32_encrypt(unsigned long *data, RC5_32_KEY *key);\nvoid RC5_32_decrypt(unsigned long *data, RC5_32_KEY *key);\nvoid RC5_32_cbc_encrypt(const unsigned char *in, unsigned char *out,\n                        long length, RC5_32_KEY *ks, unsigned char *iv,\n                        int enc);\nvoid RC5_32_cfb64_encrypt(const unsigned char *in, unsigned char *out,\n                          long length, RC5_32_KEY *schedule,\n                          unsigned char *ivec, int *num, int enc);\nvoid RC5_32_ofb64_encrypt(const unsigned char *in, unsigned char *out,\n                          long length, RC5_32_KEY *schedule,\n                          unsigned char *ivec, int *num);\n\n# ifdef  __cplusplus\n}\n# endif\n# endif\n\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/include/openssl/ripemd.h",
    "content": "/*\n * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef HEADER_RIPEMD_H\n# define HEADER_RIPEMD_H\n\n# include <openssl/opensslconf.h>\n\n#ifndef OPENSSL_NO_RMD160\n# include <openssl/e_os2.h>\n# include <stddef.h>\n# ifdef  __cplusplus\nextern \"C\" {\n# endif\n\n# define RIPEMD160_LONG unsigned int\n\n# define RIPEMD160_CBLOCK        64\n# define RIPEMD160_LBLOCK        (RIPEMD160_CBLOCK/4)\n# define RIPEMD160_DIGEST_LENGTH 20\n\ntypedef struct RIPEMD160state_st {\n    RIPEMD160_LONG A, B, C, D, E;\n    RIPEMD160_LONG Nl, Nh;\n    RIPEMD160_LONG data[RIPEMD160_LBLOCK];\n    unsigned int num;\n} RIPEMD160_CTX;\n\nint RIPEMD160_Init(RIPEMD160_CTX *c);\nint RIPEMD160_Update(RIPEMD160_CTX *c, const void *data, size_t len);\nint RIPEMD160_Final(unsigned char *md, RIPEMD160_CTX *c);\nunsigned char *RIPEMD160(const unsigned char *d, size_t n, unsigned char *md);\nvoid RIPEMD160_Transform(RIPEMD160_CTX *c, const unsigned char *b);\n\n# ifdef  __cplusplus\n}\n# endif\n# endif\n\n\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/include/openssl/rsa.h",
    "content": "/*\n * Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef HEADER_RSA_H\n# define HEADER_RSA_H\n\n# include <openssl/opensslconf.h>\n\n# ifndef OPENSSL_NO_RSA\n# include <openssl/asn1.h>\n# include <openssl/bio.h>\n# include <openssl/crypto.h>\n# include <openssl/ossl_typ.h>\n# if OPENSSL_API_COMPAT < 0x10100000L\n#  include <openssl/bn.h>\n# endif\n# include <openssl/rsaerr.h>\n# ifdef  __cplusplus\nextern \"C\" {\n# endif\n\n/* The types RSA and RSA_METHOD are defined in ossl_typ.h */\n\n# ifndef OPENSSL_RSA_MAX_MODULUS_BITS\n#  define OPENSSL_RSA_MAX_MODULUS_BITS   16384\n# endif\n\n# define OPENSSL_RSA_FIPS_MIN_MODULUS_BITS 1024\n\n# ifndef OPENSSL_RSA_SMALL_MODULUS_BITS\n#  define OPENSSL_RSA_SMALL_MODULUS_BITS 3072\n# endif\n# ifndef OPENSSL_RSA_MAX_PUBEXP_BITS\n\n/* exponent limit enforced for \"large\" modulus only */\n#  define OPENSSL_RSA_MAX_PUBEXP_BITS    64\n# endif\n\n# define RSA_3   0x3L\n# define RSA_F4  0x10001L\n\n/* based on RFC 8017 appendix A.1.2 */\n# define RSA_ASN1_VERSION_DEFAULT        0\n# define RSA_ASN1_VERSION_MULTI          1\n\n# define RSA_DEFAULT_PRIME_NUM           2\n\n# define RSA_METHOD_FLAG_NO_CHECK        0x0001/* don't check pub/private\n                                                * match */\n\n# define RSA_FLAG_CACHE_PUBLIC           0x0002\n# define RSA_FLAG_CACHE_PRIVATE          0x0004\n# define RSA_FLAG_BLINDING               0x0008\n# define RSA_FLAG_THREAD_SAFE            0x0010\n/*\n * This flag means the private key operations will be handled by rsa_mod_exp\n * and that they do not depend on the private key components being present:\n * for example a key stored in external hardware. Without this flag\n * bn_mod_exp gets called when private key components are absent.\n */\n# define RSA_FLAG_EXT_PKEY               0x0020\n\n/*\n * new with 0.9.6j and 0.9.7b; the built-in\n * RSA implementation now uses blinding by\n * default (ignoring RSA_FLAG_BLINDING),\n * but other engines might not need it\n */\n# define RSA_FLAG_NO_BLINDING            0x0080\n# if OPENSSL_API_COMPAT < 0x10100000L\n/*\n * Does nothing. Previously this switched off constant time behaviour.\n */\n#  define RSA_FLAG_NO_CONSTTIME           0x0000\n# endif\n# if OPENSSL_API_COMPAT < 0x00908000L\n/* deprecated name for the flag*/\n/*\n * new with 0.9.7h; the built-in RSA\n * implementation now uses constant time\n * modular exponentiation for secret exponents\n * by default. This flag causes the\n * faster variable sliding window method to\n * be used for all exponents.\n */\n#  define RSA_FLAG_NO_EXP_CONSTTIME RSA_FLAG_NO_CONSTTIME\n# endif\n\n# define EVP_PKEY_CTX_set_rsa_padding(ctx, pad) \\\n        RSA_pkey_ctx_ctrl(ctx, -1, EVP_PKEY_CTRL_RSA_PADDING, pad, NULL)\n\n# define EVP_PKEY_CTX_get_rsa_padding(ctx, ppad) \\\n        RSA_pkey_ctx_ctrl(ctx, -1, EVP_PKEY_CTRL_GET_RSA_PADDING, 0, ppad)\n\n# define EVP_PKEY_CTX_set_rsa_pss_saltlen(ctx, len) \\\n        RSA_pkey_ctx_ctrl(ctx, (EVP_PKEY_OP_SIGN|EVP_PKEY_OP_VERIFY), \\\n                          EVP_PKEY_CTRL_RSA_PSS_SALTLEN, len, NULL)\n/* Salt length matches digest */\n# define RSA_PSS_SALTLEN_DIGEST -1\n/* Verify only: auto detect salt length */\n# define RSA_PSS_SALTLEN_AUTO   -2\n/* Set salt length to maximum possible */\n# define RSA_PSS_SALTLEN_MAX    -3\n/* Old compatible max salt length for sign only */\n# define RSA_PSS_SALTLEN_MAX_SIGN    -2\n\n# define EVP_PKEY_CTX_set_rsa_pss_keygen_saltlen(ctx, len) \\\n        EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_RSA_PSS, EVP_PKEY_OP_KEYGEN, \\\n                          EVP_PKEY_CTRL_RSA_PSS_SALTLEN, len, NULL)\n\n# define EVP_PKEY_CTX_get_rsa_pss_saltlen(ctx, plen) \\\n        RSA_pkey_ctx_ctrl(ctx, (EVP_PKEY_OP_SIGN|EVP_PKEY_OP_VERIFY), \\\n                          EVP_PKEY_CTRL_GET_RSA_PSS_SALTLEN, 0, plen)\n\n# define EVP_PKEY_CTX_set_rsa_keygen_bits(ctx, bits) \\\n        RSA_pkey_ctx_ctrl(ctx, EVP_PKEY_OP_KEYGEN, \\\n                          EVP_PKEY_CTRL_RSA_KEYGEN_BITS, bits, NULL)\n\n# define EVP_PKEY_CTX_set_rsa_keygen_pubexp(ctx, pubexp) \\\n        RSA_pkey_ctx_ctrl(ctx, EVP_PKEY_OP_KEYGEN, \\\n                          EVP_PKEY_CTRL_RSA_KEYGEN_PUBEXP, 0, pubexp)\n\n# define EVP_PKEY_CTX_set_rsa_keygen_primes(ctx, primes) \\\n        RSA_pkey_ctx_ctrl(ctx, EVP_PKEY_OP_KEYGEN, \\\n                          EVP_PKEY_CTRL_RSA_KEYGEN_PRIMES, primes, NULL)\n\n# define  EVP_PKEY_CTX_set_rsa_mgf1_md(ctx, md) \\\n        RSA_pkey_ctx_ctrl(ctx, EVP_PKEY_OP_TYPE_SIG | EVP_PKEY_OP_TYPE_CRYPT, \\\n                          EVP_PKEY_CTRL_RSA_MGF1_MD, 0, (void *)(md))\n\n# define  EVP_PKEY_CTX_set_rsa_pss_keygen_mgf1_md(ctx, md) \\\n        EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_RSA_PSS, EVP_PKEY_OP_KEYGEN, \\\n                          EVP_PKEY_CTRL_RSA_MGF1_MD, 0, (void *)(md))\n\n# define  EVP_PKEY_CTX_set_rsa_oaep_md(ctx, md) \\\n        EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_RSA, EVP_PKEY_OP_TYPE_CRYPT,  \\\n                          EVP_PKEY_CTRL_RSA_OAEP_MD, 0, (void *)(md))\n\n# define  EVP_PKEY_CTX_get_rsa_mgf1_md(ctx, pmd) \\\n        RSA_pkey_ctx_ctrl(ctx, EVP_PKEY_OP_TYPE_SIG | EVP_PKEY_OP_TYPE_CRYPT, \\\n                          EVP_PKEY_CTRL_GET_RSA_MGF1_MD, 0, (void *)(pmd))\n\n# define  EVP_PKEY_CTX_get_rsa_oaep_md(ctx, pmd) \\\n        EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_RSA, EVP_PKEY_OP_TYPE_CRYPT,  \\\n                          EVP_PKEY_CTRL_GET_RSA_OAEP_MD, 0, (void *)(pmd))\n\n# define  EVP_PKEY_CTX_set0_rsa_oaep_label(ctx, l, llen) \\\n        EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_RSA, EVP_PKEY_OP_TYPE_CRYPT,  \\\n                          EVP_PKEY_CTRL_RSA_OAEP_LABEL, llen, (void *)(l))\n\n# define  EVP_PKEY_CTX_get0_rsa_oaep_label(ctx, l) \\\n        EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_RSA, EVP_PKEY_OP_TYPE_CRYPT,  \\\n                          EVP_PKEY_CTRL_GET_RSA_OAEP_LABEL, 0, (void *)(l))\n\n# define  EVP_PKEY_CTX_set_rsa_pss_keygen_md(ctx, md) \\\n        EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_RSA_PSS,  \\\n                          EVP_PKEY_OP_KEYGEN, EVP_PKEY_CTRL_MD,  \\\n                          0, (void *)(md))\n\n# define EVP_PKEY_CTRL_RSA_PADDING       (EVP_PKEY_ALG_CTRL + 1)\n# define EVP_PKEY_CTRL_RSA_PSS_SALTLEN   (EVP_PKEY_ALG_CTRL + 2)\n\n# define EVP_PKEY_CTRL_RSA_KEYGEN_BITS   (EVP_PKEY_ALG_CTRL + 3)\n# define EVP_PKEY_CTRL_RSA_KEYGEN_PUBEXP (EVP_PKEY_ALG_CTRL + 4)\n# define EVP_PKEY_CTRL_RSA_MGF1_MD       (EVP_PKEY_ALG_CTRL + 5)\n\n# define EVP_PKEY_CTRL_GET_RSA_PADDING           (EVP_PKEY_ALG_CTRL + 6)\n# define EVP_PKEY_CTRL_GET_RSA_PSS_SALTLEN       (EVP_PKEY_ALG_CTRL + 7)\n# define EVP_PKEY_CTRL_GET_RSA_MGF1_MD           (EVP_PKEY_ALG_CTRL + 8)\n\n# define EVP_PKEY_CTRL_RSA_OAEP_MD       (EVP_PKEY_ALG_CTRL + 9)\n# define EVP_PKEY_CTRL_RSA_OAEP_LABEL    (EVP_PKEY_ALG_CTRL + 10)\n\n# define EVP_PKEY_CTRL_GET_RSA_OAEP_MD   (EVP_PKEY_ALG_CTRL + 11)\n# define EVP_PKEY_CTRL_GET_RSA_OAEP_LABEL (EVP_PKEY_ALG_CTRL + 12)\n\n# define EVP_PKEY_CTRL_RSA_KEYGEN_PRIMES  (EVP_PKEY_ALG_CTRL + 13)\n\n# define RSA_PKCS1_PADDING       1\n# define RSA_SSLV23_PADDING      2\n# define RSA_NO_PADDING          3\n# define RSA_PKCS1_OAEP_PADDING  4\n# define RSA_X931_PADDING        5\n/* EVP_PKEY_ only */\n# define RSA_PKCS1_PSS_PADDING   6\n\n# define RSA_PKCS1_PADDING_SIZE  11\n\n# define RSA_set_app_data(s,arg)         RSA_set_ex_data(s,0,arg)\n# define RSA_get_app_data(s)             RSA_get_ex_data(s,0)\n\nRSA *RSA_new(void);\nRSA *RSA_new_method(ENGINE *engine);\nint RSA_bits(const RSA *rsa);\nint RSA_size(const RSA *rsa);\nint RSA_security_bits(const RSA *rsa);\n\nint RSA_set0_key(RSA *r, BIGNUM *n, BIGNUM *e, BIGNUM *d);\nint RSA_set0_factors(RSA *r, BIGNUM *p, BIGNUM *q);\nint RSA_set0_crt_params(RSA *r,BIGNUM *dmp1, BIGNUM *dmq1, BIGNUM *iqmp);\nint RSA_set0_multi_prime_params(RSA *r, BIGNUM *primes[], BIGNUM *exps[],\n                                BIGNUM *coeffs[], int pnum);\nvoid RSA_get0_key(const RSA *r,\n                  const BIGNUM **n, const BIGNUM **e, const BIGNUM **d);\nvoid RSA_get0_factors(const RSA *r, const BIGNUM **p, const BIGNUM **q);\nint RSA_get_multi_prime_extra_count(const RSA *r);\nint RSA_get0_multi_prime_factors(const RSA *r, const BIGNUM *primes[]);\nvoid RSA_get0_crt_params(const RSA *r,\n                         const BIGNUM **dmp1, const BIGNUM **dmq1,\n                         const BIGNUM **iqmp);\nint RSA_get0_multi_prime_crt_params(const RSA *r, const BIGNUM *exps[],\n                                    const BIGNUM *coeffs[]);\nconst BIGNUM *RSA_get0_n(const RSA *d);\nconst BIGNUM *RSA_get0_e(const RSA *d);\nconst BIGNUM *RSA_get0_d(const RSA *d);\nconst BIGNUM *RSA_get0_p(const RSA *d);\nconst BIGNUM *RSA_get0_q(const RSA *d);\nconst BIGNUM *RSA_get0_dmp1(const RSA *r);\nconst BIGNUM *RSA_get0_dmq1(const RSA *r);\nconst BIGNUM *RSA_get0_iqmp(const RSA *r);\nconst RSA_PSS_PARAMS *RSA_get0_pss_params(const RSA *r);\nvoid RSA_clear_flags(RSA *r, int flags);\nint RSA_test_flags(const RSA *r, int flags);\nvoid RSA_set_flags(RSA *r, int flags);\nint RSA_get_version(RSA *r);\nENGINE *RSA_get0_engine(const RSA *r);\n\n/* Deprecated version */\nDEPRECATEDIN_0_9_8(RSA *RSA_generate_key(int bits, unsigned long e, void\n                                         (*callback) (int, int, void *),\n                                         void *cb_arg))\n\n/* New version */\nint RSA_generate_key_ex(RSA *rsa, int bits, BIGNUM *e, BN_GENCB *cb);\n/* Multi-prime version */\nint RSA_generate_multi_prime_key(RSA *rsa, int bits, int primes,\n                                 BIGNUM *e, BN_GENCB *cb);\n\nint RSA_X931_derive_ex(RSA *rsa, BIGNUM *p1, BIGNUM *p2, BIGNUM *q1,\n                       BIGNUM *q2, const BIGNUM *Xp1, const BIGNUM *Xp2,\n                       const BIGNUM *Xp, const BIGNUM *Xq1, const BIGNUM *Xq2,\n                       const BIGNUM *Xq, const BIGNUM *e, BN_GENCB *cb);\nint RSA_X931_generate_key_ex(RSA *rsa, int bits, const BIGNUM *e,\n                             BN_GENCB *cb);\n\nint RSA_check_key(const RSA *);\nint RSA_check_key_ex(const RSA *, BN_GENCB *cb);\n        /* next 4 return -1 on error */\nint RSA_public_encrypt(int flen, const unsigned char *from,\n                       unsigned char *to, RSA *rsa, int padding);\nint RSA_private_encrypt(int flen, const unsigned char *from,\n                        unsigned char *to, RSA *rsa, int padding);\nint RSA_public_decrypt(int flen, const unsigned char *from,\n                       unsigned char *to, RSA *rsa, int padding);\nint RSA_private_decrypt(int flen, const unsigned char *from,\n                        unsigned char *to, RSA *rsa, int padding);\nvoid RSA_free(RSA *r);\n/* \"up\" the RSA object's reference count */\nint RSA_up_ref(RSA *r);\n\nint RSA_flags(const RSA *r);\n\nvoid RSA_set_default_method(const RSA_METHOD *meth);\nconst RSA_METHOD *RSA_get_default_method(void);\nconst RSA_METHOD *RSA_null_method(void);\nconst RSA_METHOD *RSA_get_method(const RSA *rsa);\nint RSA_set_method(RSA *rsa, const RSA_METHOD *meth);\n\n/* these are the actual RSA functions */\nconst RSA_METHOD *RSA_PKCS1_OpenSSL(void);\n\nint RSA_pkey_ctx_ctrl(EVP_PKEY_CTX *ctx, int optype, int cmd, int p1, void *p2);\n\nDECLARE_ASN1_ENCODE_FUNCTIONS_const(RSA, RSAPublicKey)\nDECLARE_ASN1_ENCODE_FUNCTIONS_const(RSA, RSAPrivateKey)\n\nstruct rsa_pss_params_st {\n    X509_ALGOR *hashAlgorithm;\n    X509_ALGOR *maskGenAlgorithm;\n    ASN1_INTEGER *saltLength;\n    ASN1_INTEGER *trailerField;\n    /* Decoded hash algorithm from maskGenAlgorithm */\n    X509_ALGOR *maskHash;\n};\n\nDECLARE_ASN1_FUNCTIONS(RSA_PSS_PARAMS)\n\ntypedef struct rsa_oaep_params_st {\n    X509_ALGOR *hashFunc;\n    X509_ALGOR *maskGenFunc;\n    X509_ALGOR *pSourceFunc;\n    /* Decoded hash algorithm from maskGenFunc */\n    X509_ALGOR *maskHash;\n} RSA_OAEP_PARAMS;\n\nDECLARE_ASN1_FUNCTIONS(RSA_OAEP_PARAMS)\n\n# ifndef OPENSSL_NO_STDIO\nint RSA_print_fp(FILE *fp, const RSA *r, int offset);\n# endif\n\nint RSA_print(BIO *bp, const RSA *r, int offset);\n\n/*\n * The following 2 functions sign and verify a X509_SIG ASN1 object inside\n * PKCS#1 padded RSA encryption\n */\nint RSA_sign(int type, const unsigned char *m, unsigned int m_length,\n             unsigned char *sigret, unsigned int *siglen, RSA *rsa);\nint RSA_verify(int type, const unsigned char *m, unsigned int m_length,\n               const unsigned char *sigbuf, unsigned int siglen, RSA *rsa);\n\n/*\n * The following 2 function sign and verify a ASN1_OCTET_STRING object inside\n * PKCS#1 padded RSA encryption\n */\nint RSA_sign_ASN1_OCTET_STRING(int type,\n                               const unsigned char *m, unsigned int m_length,\n                               unsigned char *sigret, unsigned int *siglen,\n                               RSA *rsa);\nint RSA_verify_ASN1_OCTET_STRING(int type, const unsigned char *m,\n                                 unsigned int m_length, unsigned char *sigbuf,\n                                 unsigned int siglen, RSA *rsa);\n\nint RSA_blinding_on(RSA *rsa, BN_CTX *ctx);\nvoid RSA_blinding_off(RSA *rsa);\nBN_BLINDING *RSA_setup_blinding(RSA *rsa, BN_CTX *ctx);\n\nint RSA_padding_add_PKCS1_type_1(unsigned char *to, int tlen,\n                                 const unsigned char *f, int fl);\nint RSA_padding_check_PKCS1_type_1(unsigned char *to, int tlen,\n                                   const unsigned char *f, int fl,\n                                   int rsa_len);\nint RSA_padding_add_PKCS1_type_2(unsigned char *to, int tlen,\n                                 const unsigned char *f, int fl);\nint RSA_padding_check_PKCS1_type_2(unsigned char *to, int tlen,\n                                   const unsigned char *f, int fl,\n                                   int rsa_len);\nint PKCS1_MGF1(unsigned char *mask, long len, const unsigned char *seed,\n               long seedlen, const EVP_MD *dgst);\nint RSA_padding_add_PKCS1_OAEP(unsigned char *to, int tlen,\n                               const unsigned char *f, int fl,\n                               const unsigned char *p, int pl);\nint RSA_padding_check_PKCS1_OAEP(unsigned char *to, int tlen,\n                                 const unsigned char *f, int fl, int rsa_len,\n                                 const unsigned char *p, int pl);\nint RSA_padding_add_PKCS1_OAEP_mgf1(unsigned char *to, int tlen,\n                                    const unsigned char *from, int flen,\n                                    const unsigned char *param, int plen,\n                                    const EVP_MD *md, const EVP_MD *mgf1md);\nint RSA_padding_check_PKCS1_OAEP_mgf1(unsigned char *to, int tlen,\n                                      const unsigned char *from, int flen,\n                                      int num, const unsigned char *param,\n                                      int plen, const EVP_MD *md,\n                                      const EVP_MD *mgf1md);\nint RSA_padding_add_SSLv23(unsigned char *to, int tlen,\n                           const unsigned char *f, int fl);\nint RSA_padding_check_SSLv23(unsigned char *to, int tlen,\n                             const unsigned char *f, int fl, int rsa_len);\nint RSA_padding_add_none(unsigned char *to, int tlen, const unsigned char *f,\n                         int fl);\nint RSA_padding_check_none(unsigned char *to, int tlen,\n                           const unsigned char *f, int fl, int rsa_len);\nint RSA_padding_add_X931(unsigned char *to, int tlen, const unsigned char *f,\n                         int fl);\nint RSA_padding_check_X931(unsigned char *to, int tlen,\n                           const unsigned char *f, int fl, int rsa_len);\nint RSA_X931_hash_id(int nid);\n\nint RSA_verify_PKCS1_PSS(RSA *rsa, const unsigned char *mHash,\n                         const EVP_MD *Hash, const unsigned char *EM,\n                         int sLen);\nint RSA_padding_add_PKCS1_PSS(RSA *rsa, unsigned char *EM,\n                              const unsigned char *mHash, const EVP_MD *Hash,\n                              int sLen);\n\nint RSA_verify_PKCS1_PSS_mgf1(RSA *rsa, const unsigned char *mHash,\n                              const EVP_MD *Hash, const EVP_MD *mgf1Hash,\n                              const unsigned char *EM, int sLen);\n\nint RSA_padding_add_PKCS1_PSS_mgf1(RSA *rsa, unsigned char *EM,\n                                   const unsigned char *mHash,\n                                   const EVP_MD *Hash, const EVP_MD *mgf1Hash,\n                                   int sLen);\n\n#define RSA_get_ex_new_index(l, p, newf, dupf, freef) \\\n    CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_RSA, l, p, newf, dupf, freef)\nint RSA_set_ex_data(RSA *r, int idx, void *arg);\nvoid *RSA_get_ex_data(const RSA *r, int idx);\n\nRSA *RSAPublicKey_dup(RSA *rsa);\nRSA *RSAPrivateKey_dup(RSA *rsa);\n\n/*\n * If this flag is set the RSA method is FIPS compliant and can be used in\n * FIPS mode. This is set in the validated module method. If an application\n * sets this flag in its own methods it is its responsibility to ensure the\n * result is compliant.\n */\n\n# define RSA_FLAG_FIPS_METHOD                    0x0400\n\n/*\n * If this flag is set the operations normally disabled in FIPS mode are\n * permitted it is then the applications responsibility to ensure that the\n * usage is compliant.\n */\n\n# define RSA_FLAG_NON_FIPS_ALLOW                 0x0400\n/*\n * Application has decided PRNG is good enough to generate a key: don't\n * check.\n */\n# define RSA_FLAG_CHECKED                        0x0800\n\nRSA_METHOD *RSA_meth_new(const char *name, int flags);\nvoid RSA_meth_free(RSA_METHOD *meth);\nRSA_METHOD *RSA_meth_dup(const RSA_METHOD *meth);\nconst char *RSA_meth_get0_name(const RSA_METHOD *meth);\nint RSA_meth_set1_name(RSA_METHOD *meth, const char *name);\nint RSA_meth_get_flags(const RSA_METHOD *meth);\nint RSA_meth_set_flags(RSA_METHOD *meth, int flags);\nvoid *RSA_meth_get0_app_data(const RSA_METHOD *meth);\nint RSA_meth_set0_app_data(RSA_METHOD *meth, void *app_data);\nint (*RSA_meth_get_pub_enc(const RSA_METHOD *meth))\n    (int flen, const unsigned char *from,\n     unsigned char *to, RSA *rsa, int padding);\nint RSA_meth_set_pub_enc(RSA_METHOD *rsa,\n                         int (*pub_enc) (int flen, const unsigned char *from,\n                                         unsigned char *to, RSA *rsa,\n                                         int padding));\nint (*RSA_meth_get_pub_dec(const RSA_METHOD *meth))\n    (int flen, const unsigned char *from,\n     unsigned char *to, RSA *rsa, int padding);\nint RSA_meth_set_pub_dec(RSA_METHOD *rsa,\n                         int (*pub_dec) (int flen, const unsigned char *from,\n                                         unsigned char *to, RSA *rsa,\n                                         int padding));\nint (*RSA_meth_get_priv_enc(const RSA_METHOD *meth))\n    (int flen, const unsigned char *from,\n     unsigned char *to, RSA *rsa, int padding);\nint RSA_meth_set_priv_enc(RSA_METHOD *rsa,\n                          int (*priv_enc) (int flen, const unsigned char *from,\n                                           unsigned char *to, RSA *rsa,\n                                           int padding));\nint (*RSA_meth_get_priv_dec(const RSA_METHOD *meth))\n    (int flen, const unsigned char *from,\n     unsigned char *to, RSA *rsa, int padding);\nint RSA_meth_set_priv_dec(RSA_METHOD *rsa,\n                          int (*priv_dec) (int flen, const unsigned char *from,\n                                           unsigned char *to, RSA *rsa,\n                                           int padding));\nint (*RSA_meth_get_mod_exp(const RSA_METHOD *meth))\n    (BIGNUM *r0, const BIGNUM *i, RSA *rsa, BN_CTX *ctx);\nint RSA_meth_set_mod_exp(RSA_METHOD *rsa,\n                         int (*mod_exp) (BIGNUM *r0, const BIGNUM *i, RSA *rsa,\n                                         BN_CTX *ctx));\nint (*RSA_meth_get_bn_mod_exp(const RSA_METHOD *meth))\n    (BIGNUM *r, const BIGNUM *a, const BIGNUM *p,\n     const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx);\nint RSA_meth_set_bn_mod_exp(RSA_METHOD *rsa,\n                            int (*bn_mod_exp) (BIGNUM *r,\n                                               const BIGNUM *a,\n                                               const BIGNUM *p,\n                                               const BIGNUM *m,\n                                               BN_CTX *ctx,\n                                               BN_MONT_CTX *m_ctx));\nint (*RSA_meth_get_init(const RSA_METHOD *meth)) (RSA *rsa);\nint RSA_meth_set_init(RSA_METHOD *rsa, int (*init) (RSA *rsa));\nint (*RSA_meth_get_finish(const RSA_METHOD *meth)) (RSA *rsa);\nint RSA_meth_set_finish(RSA_METHOD *rsa, int (*finish) (RSA *rsa));\nint (*RSA_meth_get_sign(const RSA_METHOD *meth))\n    (int type,\n     const unsigned char *m, unsigned int m_length,\n     unsigned char *sigret, unsigned int *siglen,\n     const RSA *rsa);\nint RSA_meth_set_sign(RSA_METHOD *rsa,\n                      int (*sign) (int type, const unsigned char *m,\n                                   unsigned int m_length,\n                                   unsigned char *sigret, unsigned int *siglen,\n                                   const RSA *rsa));\nint (*RSA_meth_get_verify(const RSA_METHOD *meth))\n    (int dtype, const unsigned char *m,\n     unsigned int m_length, const unsigned char *sigbuf,\n     unsigned int siglen, const RSA *rsa);\nint RSA_meth_set_verify(RSA_METHOD *rsa,\n                        int (*verify) (int dtype, const unsigned char *m,\n                                       unsigned int m_length,\n                                       const unsigned char *sigbuf,\n                                       unsigned int siglen, const RSA *rsa));\nint (*RSA_meth_get_keygen(const RSA_METHOD *meth))\n    (RSA *rsa, int bits, BIGNUM *e, BN_GENCB *cb);\nint RSA_meth_set_keygen(RSA_METHOD *rsa,\n                        int (*keygen) (RSA *rsa, int bits, BIGNUM *e,\n                                       BN_GENCB *cb));\nint (*RSA_meth_get_multi_prime_keygen(const RSA_METHOD *meth))\n    (RSA *rsa, int bits, int primes, BIGNUM *e, BN_GENCB *cb);\nint RSA_meth_set_multi_prime_keygen(RSA_METHOD *meth,\n                                    int (*keygen) (RSA *rsa, int bits,\n                                                   int primes, BIGNUM *e,\n                                                   BN_GENCB *cb));\n\n#  ifdef  __cplusplus\n}\n#  endif\n# endif\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/include/openssl/rsaerr.h",
    "content": "/*\n * Generated by util/mkerr.pl DO NOT EDIT\n * Copyright 1995-2019 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef HEADER_RSAERR_H\n# define HEADER_RSAERR_H\n\n# ifndef HEADER_SYMHACKS_H\n#  include <openssl/symhacks.h>\n# endif\n\n# ifdef  __cplusplus\nextern \"C\"\n# endif\nint ERR_load_RSA_strings(void);\n\n/*\n * RSA function codes.\n */\n# define RSA_F_CHECK_PADDING_MD                           140\n# define RSA_F_ENCODE_PKCS1                               146\n# define RSA_F_INT_RSA_VERIFY                             145\n# define RSA_F_OLD_RSA_PRIV_DECODE                        147\n# define RSA_F_PKEY_PSS_INIT                              165\n# define RSA_F_PKEY_RSA_CTRL                              143\n# define RSA_F_PKEY_RSA_CTRL_STR                          144\n# define RSA_F_PKEY_RSA_SIGN                              142\n# define RSA_F_PKEY_RSA_VERIFY                            149\n# define RSA_F_PKEY_RSA_VERIFYRECOVER                     141\n# define RSA_F_RSA_ALGOR_TO_MD                            156\n# define RSA_F_RSA_BUILTIN_KEYGEN                         129\n# define RSA_F_RSA_CHECK_KEY                              123\n# define RSA_F_RSA_CHECK_KEY_EX                           160\n# define RSA_F_RSA_CMS_DECRYPT                            159\n# define RSA_F_RSA_CMS_VERIFY                             158\n# define RSA_F_RSA_ITEM_VERIFY                            148\n# define RSA_F_RSA_METH_DUP                               161\n# define RSA_F_RSA_METH_NEW                               162\n# define RSA_F_RSA_METH_SET1_NAME                         163\n# define RSA_F_RSA_MGF1_TO_MD                             157\n# define RSA_F_RSA_MULTIP_INFO_NEW                        166\n# define RSA_F_RSA_NEW_METHOD                             106\n# define RSA_F_RSA_NULL                                   124\n# define RSA_F_RSA_NULL_PRIVATE_DECRYPT                   132\n# define RSA_F_RSA_NULL_PRIVATE_ENCRYPT                   133\n# define RSA_F_RSA_NULL_PUBLIC_DECRYPT                    134\n# define RSA_F_RSA_NULL_PUBLIC_ENCRYPT                    135\n# define RSA_F_RSA_OSSL_PRIVATE_DECRYPT                   101\n# define RSA_F_RSA_OSSL_PRIVATE_ENCRYPT                   102\n# define RSA_F_RSA_OSSL_PUBLIC_DECRYPT                    103\n# define RSA_F_RSA_OSSL_PUBLIC_ENCRYPT                    104\n# define RSA_F_RSA_PADDING_ADD_NONE                       107\n# define RSA_F_RSA_PADDING_ADD_PKCS1_OAEP                 121\n# define RSA_F_RSA_PADDING_ADD_PKCS1_OAEP_MGF1            154\n# define RSA_F_RSA_PADDING_ADD_PKCS1_PSS                  125\n# define RSA_F_RSA_PADDING_ADD_PKCS1_PSS_MGF1             152\n# define RSA_F_RSA_PADDING_ADD_PKCS1_TYPE_1               108\n# define RSA_F_RSA_PADDING_ADD_PKCS1_TYPE_2               109\n# define RSA_F_RSA_PADDING_ADD_SSLV23                     110\n# define RSA_F_RSA_PADDING_ADD_X931                       127\n# define RSA_F_RSA_PADDING_CHECK_NONE                     111\n# define RSA_F_RSA_PADDING_CHECK_PKCS1_OAEP               122\n# define RSA_F_RSA_PADDING_CHECK_PKCS1_OAEP_MGF1          153\n# define RSA_F_RSA_PADDING_CHECK_PKCS1_TYPE_1             112\n# define RSA_F_RSA_PADDING_CHECK_PKCS1_TYPE_2             113\n# define RSA_F_RSA_PADDING_CHECK_SSLV23                   114\n# define RSA_F_RSA_PADDING_CHECK_X931                     128\n# define RSA_F_RSA_PARAM_DECODE                           164\n# define RSA_F_RSA_PRINT                                  115\n# define RSA_F_RSA_PRINT_FP                               116\n# define RSA_F_RSA_PRIV_DECODE                            150\n# define RSA_F_RSA_PRIV_ENCODE                            138\n# define RSA_F_RSA_PSS_GET_PARAM                          151\n# define RSA_F_RSA_PSS_TO_CTX                             155\n# define RSA_F_RSA_PUB_DECODE                             139\n# define RSA_F_RSA_SETUP_BLINDING                         136\n# define RSA_F_RSA_SIGN                                   117\n# define RSA_F_RSA_SIGN_ASN1_OCTET_STRING                 118\n# define RSA_F_RSA_VERIFY                                 119\n# define RSA_F_RSA_VERIFY_ASN1_OCTET_STRING               120\n# define RSA_F_RSA_VERIFY_PKCS1_PSS_MGF1                  126\n# define RSA_F_SETUP_TBUF                                 167\n\n/*\n * RSA reason codes.\n */\n# define RSA_R_ALGORITHM_MISMATCH                         100\n# define RSA_R_BAD_E_VALUE                                101\n# define RSA_R_BAD_FIXED_HEADER_DECRYPT                   102\n# define RSA_R_BAD_PAD_BYTE_COUNT                         103\n# define RSA_R_BAD_SIGNATURE                              104\n# define RSA_R_BLOCK_TYPE_IS_NOT_01                       106\n# define RSA_R_BLOCK_TYPE_IS_NOT_02                       107\n# define RSA_R_DATA_GREATER_THAN_MOD_LEN                  108\n# define RSA_R_DATA_TOO_LARGE                             109\n# define RSA_R_DATA_TOO_LARGE_FOR_KEY_SIZE                110\n# define RSA_R_DATA_TOO_LARGE_FOR_MODULUS                 132\n# define RSA_R_DATA_TOO_SMALL                             111\n# define RSA_R_DATA_TOO_SMALL_FOR_KEY_SIZE                122\n# define RSA_R_DIGEST_DOES_NOT_MATCH                      158\n# define RSA_R_DIGEST_NOT_ALLOWED                         145\n# define RSA_R_DIGEST_TOO_BIG_FOR_RSA_KEY                 112\n# define RSA_R_DMP1_NOT_CONGRUENT_TO_D                    124\n# define RSA_R_DMQ1_NOT_CONGRUENT_TO_D                    125\n# define RSA_R_D_E_NOT_CONGRUENT_TO_1                     123\n# define RSA_R_FIRST_OCTET_INVALID                        133\n# define RSA_R_ILLEGAL_OR_UNSUPPORTED_PADDING_MODE        144\n# define RSA_R_INVALID_DIGEST                             157\n# define RSA_R_INVALID_DIGEST_LENGTH                      143\n# define RSA_R_INVALID_HEADER                             137\n# define RSA_R_INVALID_LABEL                              160\n# define RSA_R_INVALID_MESSAGE_LENGTH                     131\n# define RSA_R_INVALID_MGF1_MD                            156\n# define RSA_R_INVALID_MULTI_PRIME_KEY                    167\n# define RSA_R_INVALID_OAEP_PARAMETERS                    161\n# define RSA_R_INVALID_PADDING                            138\n# define RSA_R_INVALID_PADDING_MODE                       141\n# define RSA_R_INVALID_PSS_PARAMETERS                     149\n# define RSA_R_INVALID_PSS_SALTLEN                        146\n# define RSA_R_INVALID_SALT_LENGTH                        150\n# define RSA_R_INVALID_TRAILER                            139\n# define RSA_R_INVALID_X931_DIGEST                        142\n# define RSA_R_IQMP_NOT_INVERSE_OF_Q                      126\n# define RSA_R_KEY_PRIME_NUM_INVALID                      165\n# define RSA_R_KEY_SIZE_TOO_SMALL                         120\n# define RSA_R_LAST_OCTET_INVALID                         134\n# define RSA_R_MISSING_PRIVATE_KEY                        179\n# define RSA_R_MGF1_DIGEST_NOT_ALLOWED                    152\n# define RSA_R_MODULUS_TOO_LARGE                          105\n# define RSA_R_MP_COEFFICIENT_NOT_INVERSE_OF_R            168\n# define RSA_R_MP_EXPONENT_NOT_CONGRUENT_TO_D             169\n# define RSA_R_MP_R_NOT_PRIME                             170\n# define RSA_R_NO_PUBLIC_EXPONENT                         140\n# define RSA_R_NULL_BEFORE_BLOCK_MISSING                  113\n# define RSA_R_N_DOES_NOT_EQUAL_PRODUCT_OF_PRIMES         172\n# define RSA_R_N_DOES_NOT_EQUAL_P_Q                       127\n# define RSA_R_OAEP_DECODING_ERROR                        121\n# define RSA_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE   148\n# define RSA_R_PADDING_CHECK_FAILED                       114\n# define RSA_R_PKCS_DECODING_ERROR                        159\n# define RSA_R_PSS_SALTLEN_TOO_SMALL                      164\n# define RSA_R_P_NOT_PRIME                                128\n# define RSA_R_Q_NOT_PRIME                                129\n# define RSA_R_RSA_OPERATIONS_NOT_SUPPORTED               130\n# define RSA_R_SLEN_CHECK_FAILED                          136\n# define RSA_R_SLEN_RECOVERY_FAILED                       135\n# define RSA_R_SSLV3_ROLLBACK_ATTACK                      115\n# define RSA_R_THE_ASN1_OBJECT_IDENTIFIER_IS_NOT_KNOWN_FOR_THIS_MD 116\n# define RSA_R_UNKNOWN_ALGORITHM_TYPE                     117\n# define RSA_R_UNKNOWN_DIGEST                             166\n# define RSA_R_UNKNOWN_MASK_DIGEST                        151\n# define RSA_R_UNKNOWN_PADDING_TYPE                       118\n# define RSA_R_UNSUPPORTED_ENCRYPTION_TYPE                162\n# define RSA_R_UNSUPPORTED_LABEL_SOURCE                   163\n# define RSA_R_UNSUPPORTED_MASK_ALGORITHM                 153\n# define RSA_R_UNSUPPORTED_MASK_PARAMETER                 154\n# define RSA_R_UNSUPPORTED_SIGNATURE_TYPE                 155\n# define RSA_R_VALUE_MISSING                              147\n# define RSA_R_WRONG_SIGNATURE_LENGTH                     119\n\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/include/openssl/safestack.h",
    "content": "/*\n * Copyright 1999-2019 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef HEADER_SAFESTACK_H\n# define HEADER_SAFESTACK_H\n\n# include <openssl/stack.h>\n# include <openssl/e_os2.h>\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n# define STACK_OF(type) struct stack_st_##type\n\n# define SKM_DEFINE_STACK_OF(t1, t2, t3) \\\n    STACK_OF(t1); \\\n    typedef int (*sk_##t1##_compfunc)(const t3 * const *a, const t3 *const *b); \\\n    typedef void (*sk_##t1##_freefunc)(t3 *a); \\\n    typedef t3 * (*sk_##t1##_copyfunc)(const t3 *a); \\\n    static ossl_unused ossl_inline int sk_##t1##_num(const STACK_OF(t1) *sk) \\\n    { \\\n        return OPENSSL_sk_num((const OPENSSL_STACK *)sk); \\\n    } \\\n    static ossl_unused ossl_inline t2 *sk_##t1##_value(const STACK_OF(t1) *sk, int idx) \\\n    { \\\n        return (t2 *)OPENSSL_sk_value((const OPENSSL_STACK *)sk, idx); \\\n    } \\\n    static ossl_unused ossl_inline STACK_OF(t1) *sk_##t1##_new(sk_##t1##_compfunc compare) \\\n    { \\\n        return (STACK_OF(t1) *)OPENSSL_sk_new((OPENSSL_sk_compfunc)compare); \\\n    } \\\n    static ossl_unused ossl_inline STACK_OF(t1) *sk_##t1##_new_null(void) \\\n    { \\\n        return (STACK_OF(t1) *)OPENSSL_sk_new_null(); \\\n    } \\\n    static ossl_unused ossl_inline STACK_OF(t1) *sk_##t1##_new_reserve(sk_##t1##_compfunc compare, int n) \\\n    { \\\n        return (STACK_OF(t1) *)OPENSSL_sk_new_reserve((OPENSSL_sk_compfunc)compare, n); \\\n    } \\\n    static ossl_unused ossl_inline int sk_##t1##_reserve(STACK_OF(t1) *sk, int n) \\\n    { \\\n        return OPENSSL_sk_reserve((OPENSSL_STACK *)sk, n); \\\n    } \\\n    static ossl_unused ossl_inline void sk_##t1##_free(STACK_OF(t1) *sk) \\\n    { \\\n        OPENSSL_sk_free((OPENSSL_STACK *)sk); \\\n    } \\\n    static ossl_unused ossl_inline void sk_##t1##_zero(STACK_OF(t1) *sk) \\\n    { \\\n        OPENSSL_sk_zero((OPENSSL_STACK *)sk); \\\n    } \\\n    static ossl_unused ossl_inline t2 *sk_##t1##_delete(STACK_OF(t1) *sk, int i) \\\n    { \\\n        return (t2 *)OPENSSL_sk_delete((OPENSSL_STACK *)sk, i); \\\n    } \\\n    static ossl_unused ossl_inline t2 *sk_##t1##_delete_ptr(STACK_OF(t1) *sk, t2 *ptr) \\\n    { \\\n        return (t2 *)OPENSSL_sk_delete_ptr((OPENSSL_STACK *)sk, \\\n                                           (const void *)ptr); \\\n    } \\\n    static ossl_unused ossl_inline int sk_##t1##_push(STACK_OF(t1) *sk, t2 *ptr) \\\n    { \\\n        return OPENSSL_sk_push((OPENSSL_STACK *)sk, (const void *)ptr); \\\n    } \\\n    static ossl_unused ossl_inline int sk_##t1##_unshift(STACK_OF(t1) *sk, t2 *ptr) \\\n    { \\\n        return OPENSSL_sk_unshift((OPENSSL_STACK *)sk, (const void *)ptr); \\\n    } \\\n    static ossl_unused ossl_inline t2 *sk_##t1##_pop(STACK_OF(t1) *sk) \\\n    { \\\n        return (t2 *)OPENSSL_sk_pop((OPENSSL_STACK *)sk); \\\n    } \\\n    static ossl_unused ossl_inline t2 *sk_##t1##_shift(STACK_OF(t1) *sk) \\\n    { \\\n        return (t2 *)OPENSSL_sk_shift((OPENSSL_STACK *)sk); \\\n    } \\\n    static ossl_unused ossl_inline void sk_##t1##_pop_free(STACK_OF(t1) *sk, sk_##t1##_freefunc freefunc) \\\n    { \\\n        OPENSSL_sk_pop_free((OPENSSL_STACK *)sk, (OPENSSL_sk_freefunc)freefunc); \\\n    } \\\n    static ossl_unused ossl_inline int sk_##t1##_insert(STACK_OF(t1) *sk, t2 *ptr, int idx) \\\n    { \\\n        return OPENSSL_sk_insert((OPENSSL_STACK *)sk, (const void *)ptr, idx); \\\n    } \\\n    static ossl_unused ossl_inline t2 *sk_##t1##_set(STACK_OF(t1) *sk, int idx, t2 *ptr) \\\n    { \\\n        return (t2 *)OPENSSL_sk_set((OPENSSL_STACK *)sk, idx, (const void *)ptr); \\\n    } \\\n    static ossl_unused ossl_inline int sk_##t1##_find(STACK_OF(t1) *sk, t2 *ptr) \\\n    { \\\n        return OPENSSL_sk_find((OPENSSL_STACK *)sk, (const void *)ptr); \\\n    } \\\n    static ossl_unused ossl_inline int sk_##t1##_find_ex(STACK_OF(t1) *sk, t2 *ptr) \\\n    { \\\n        return OPENSSL_sk_find_ex((OPENSSL_STACK *)sk, (const void *)ptr); \\\n    } \\\n    static ossl_unused ossl_inline void sk_##t1##_sort(STACK_OF(t1) *sk) \\\n    { \\\n        OPENSSL_sk_sort((OPENSSL_STACK *)sk); \\\n    } \\\n    static ossl_unused ossl_inline int sk_##t1##_is_sorted(const STACK_OF(t1) *sk) \\\n    { \\\n        return OPENSSL_sk_is_sorted((const OPENSSL_STACK *)sk); \\\n    } \\\n    static ossl_unused ossl_inline STACK_OF(t1) * sk_##t1##_dup(const STACK_OF(t1) *sk) \\\n    { \\\n        return (STACK_OF(t1) *)OPENSSL_sk_dup((const OPENSSL_STACK *)sk); \\\n    } \\\n    static ossl_unused ossl_inline STACK_OF(t1) *sk_##t1##_deep_copy(const STACK_OF(t1) *sk, \\\n                                                    sk_##t1##_copyfunc copyfunc, \\\n                                                    sk_##t1##_freefunc freefunc) \\\n    { \\\n        return (STACK_OF(t1) *)OPENSSL_sk_deep_copy((const OPENSSL_STACK *)sk, \\\n                                            (OPENSSL_sk_copyfunc)copyfunc, \\\n                                            (OPENSSL_sk_freefunc)freefunc); \\\n    } \\\n    static ossl_unused ossl_inline sk_##t1##_compfunc sk_##t1##_set_cmp_func(STACK_OF(t1) *sk, sk_##t1##_compfunc compare) \\\n    { \\\n        return (sk_##t1##_compfunc)OPENSSL_sk_set_cmp_func((OPENSSL_STACK *)sk, (OPENSSL_sk_compfunc)compare); \\\n    }\n\n# define DEFINE_SPECIAL_STACK_OF(t1, t2) SKM_DEFINE_STACK_OF(t1, t2, t2)\n# define DEFINE_STACK_OF(t) SKM_DEFINE_STACK_OF(t, t, t)\n# define DEFINE_SPECIAL_STACK_OF_CONST(t1, t2) \\\n            SKM_DEFINE_STACK_OF(t1, const t2, t2)\n# define DEFINE_STACK_OF_CONST(t) SKM_DEFINE_STACK_OF(t, const t, t)\n\n/*-\n * Strings are special: normally an lhash entry will point to a single\n * (somewhat) mutable object. In the case of strings:\n *\n * a) Instead of a single char, there is an array of chars, NUL-terminated.\n * b) The string may have be immutable.\n *\n * So, they need their own declarations. Especially important for\n * type-checking tools, such as Deputy.\n *\n * In practice, however, it appears to be hard to have a const\n * string. For now, I'm settling for dealing with the fact it is a\n * string at all.\n */\ntypedef char *OPENSSL_STRING;\ntypedef const char *OPENSSL_CSTRING;\n\n/*-\n * Confusingly, LHASH_OF(STRING) deals with char ** throughout, but\n * STACK_OF(STRING) is really more like STACK_OF(char), only, as mentioned\n * above, instead of a single char each entry is a NUL-terminated array of\n * chars. So, we have to implement STRING specially for STACK_OF. This is\n * dealt with in the autogenerated macros below.\n */\nDEFINE_SPECIAL_STACK_OF(OPENSSL_STRING, char)\nDEFINE_SPECIAL_STACK_OF_CONST(OPENSSL_CSTRING, char)\n\n/*\n * Similarly, we sometimes use a block of characters, NOT nul-terminated.\n * These should also be distinguished from \"normal\" stacks.\n */\ntypedef void *OPENSSL_BLOCK;\nDEFINE_SPECIAL_STACK_OF(OPENSSL_BLOCK, void)\n\n/*\n * If called without higher optimization (min. -xO3) the Oracle Developer\n * Studio compiler generates code for the defined (static inline) functions\n * above.\n * This would later lead to the linker complaining about missing symbols when\n * this header file is included but the resulting object is not linked against\n * the Crypto library (openssl#6912).\n */\n# ifdef __SUNPRO_C\n#  pragma weak OPENSSL_sk_num\n#  pragma weak OPENSSL_sk_value\n#  pragma weak OPENSSL_sk_new\n#  pragma weak OPENSSL_sk_new_null\n#  pragma weak OPENSSL_sk_new_reserve\n#  pragma weak OPENSSL_sk_reserve\n#  pragma weak OPENSSL_sk_free\n#  pragma weak OPENSSL_sk_zero\n#  pragma weak OPENSSL_sk_delete\n#  pragma weak OPENSSL_sk_delete_ptr\n#  pragma weak OPENSSL_sk_push\n#  pragma weak OPENSSL_sk_unshift\n#  pragma weak OPENSSL_sk_pop\n#  pragma weak OPENSSL_sk_shift\n#  pragma weak OPENSSL_sk_pop_free\n#  pragma weak OPENSSL_sk_insert\n#  pragma weak OPENSSL_sk_set\n#  pragma weak OPENSSL_sk_find\n#  pragma weak OPENSSL_sk_find_ex\n#  pragma weak OPENSSL_sk_sort\n#  pragma weak OPENSSL_sk_is_sorted\n#  pragma weak OPENSSL_sk_dup\n#  pragma weak OPENSSL_sk_deep_copy\n#  pragma weak OPENSSL_sk_set_cmp_func\n# endif /* __SUNPRO_C */\n\n# ifdef  __cplusplus\n}\n# endif\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/include/openssl/seed.h",
    "content": "/*\n * Copyright 2007-2016 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n/*\n * Copyright (c) 2007 KISA(Korea Information Security Agency). All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n * 2. Neither the name of author nor the names of its contributors may\n *    be used to endorse or promote products derived from this software\n *    without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED.  IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n * SUCH DAMAGE.\n */\n\n#ifndef HEADER_SEED_H\n# define HEADER_SEED_H\n\n# include <openssl/opensslconf.h>\n\n# ifndef OPENSSL_NO_SEED\n# include <openssl/e_os2.h>\n# include <openssl/crypto.h>\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n/* look whether we need 'long' to get 32 bits */\n# ifdef AES_LONG\n#  ifndef SEED_LONG\n#   define SEED_LONG 1\n#  endif\n# endif\n\n# include <sys/types.h>\n\n# define SEED_BLOCK_SIZE 16\n# define SEED_KEY_LENGTH 16\n\ntypedef struct seed_key_st {\n# ifdef SEED_LONG\n    unsigned long data[32];\n# else\n    unsigned int data[32];\n# endif\n} SEED_KEY_SCHEDULE;\n\nvoid SEED_set_key(const unsigned char rawkey[SEED_KEY_LENGTH],\n                  SEED_KEY_SCHEDULE *ks);\n\nvoid SEED_encrypt(const unsigned char s[SEED_BLOCK_SIZE],\n                  unsigned char d[SEED_BLOCK_SIZE],\n                  const SEED_KEY_SCHEDULE *ks);\nvoid SEED_decrypt(const unsigned char s[SEED_BLOCK_SIZE],\n                  unsigned char d[SEED_BLOCK_SIZE],\n                  const SEED_KEY_SCHEDULE *ks);\n\nvoid SEED_ecb_encrypt(const unsigned char *in, unsigned char *out,\n                      const SEED_KEY_SCHEDULE *ks, int enc);\nvoid SEED_cbc_encrypt(const unsigned char *in, unsigned char *out, size_t len,\n                      const SEED_KEY_SCHEDULE *ks,\n                      unsigned char ivec[SEED_BLOCK_SIZE], int enc);\nvoid SEED_cfb128_encrypt(const unsigned char *in, unsigned char *out,\n                         size_t len, const SEED_KEY_SCHEDULE *ks,\n                         unsigned char ivec[SEED_BLOCK_SIZE], int *num,\n                         int enc);\nvoid SEED_ofb128_encrypt(const unsigned char *in, unsigned char *out,\n                         size_t len, const SEED_KEY_SCHEDULE *ks,\n                         unsigned char ivec[SEED_BLOCK_SIZE], int *num);\n\n# ifdef  __cplusplus\n}\n# endif\n# endif\n\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/include/openssl/sha.h",
    "content": "/*\n * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef HEADER_SHA_H\n# define HEADER_SHA_H\n\n# include <openssl/e_os2.h>\n# include <stddef.h>\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n/*-\n * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n * ! SHA_LONG has to be at least 32 bits wide.                    !\n * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n */\n# define SHA_LONG unsigned int\n\n# define SHA_LBLOCK      16\n# define SHA_CBLOCK      (SHA_LBLOCK*4)/* SHA treats input data as a\n                                        * contiguous array of 32 bit wide\n                                        * big-endian values. */\n# define SHA_LAST_BLOCK  (SHA_CBLOCK-8)\n# define SHA_DIGEST_LENGTH 20\n\ntypedef struct SHAstate_st {\n    SHA_LONG h0, h1, h2, h3, h4;\n    SHA_LONG Nl, Nh;\n    SHA_LONG data[SHA_LBLOCK];\n    unsigned int num;\n} SHA_CTX;\n\nint SHA1_Init(SHA_CTX *c);\nint SHA1_Update(SHA_CTX *c, const void *data, size_t len);\nint SHA1_Final(unsigned char *md, SHA_CTX *c);\nunsigned char *SHA1(const unsigned char *d, size_t n, unsigned char *md);\nvoid SHA1_Transform(SHA_CTX *c, const unsigned char *data);\n\n# define SHA256_CBLOCK   (SHA_LBLOCK*4)/* SHA-256 treats input data as a\n                                        * contiguous array of 32 bit wide\n                                        * big-endian values. */\n\ntypedef struct SHA256state_st {\n    SHA_LONG h[8];\n    SHA_LONG Nl, Nh;\n    SHA_LONG data[SHA_LBLOCK];\n    unsigned int num, md_len;\n} SHA256_CTX;\n\nint SHA224_Init(SHA256_CTX *c);\nint SHA224_Update(SHA256_CTX *c, const void *data, size_t len);\nint SHA224_Final(unsigned char *md, SHA256_CTX *c);\nunsigned char *SHA224(const unsigned char *d, size_t n, unsigned char *md);\nint SHA256_Init(SHA256_CTX *c);\nint SHA256_Update(SHA256_CTX *c, const void *data, size_t len);\nint SHA256_Final(unsigned char *md, SHA256_CTX *c);\nunsigned char *SHA256(const unsigned char *d, size_t n, unsigned char *md);\nvoid SHA256_Transform(SHA256_CTX *c, const unsigned char *data);\n\n# define SHA224_DIGEST_LENGTH    28\n# define SHA256_DIGEST_LENGTH    32\n# define SHA384_DIGEST_LENGTH    48\n# define SHA512_DIGEST_LENGTH    64\n\n/*\n * Unlike 32-bit digest algorithms, SHA-512 *relies* on SHA_LONG64\n * being exactly 64-bit wide. See Implementation Notes in sha512.c\n * for further details.\n */\n/*\n * SHA-512 treats input data as a\n * contiguous array of 64 bit\n * wide big-endian values.\n */\n# define SHA512_CBLOCK   (SHA_LBLOCK*8)\n# if (defined(_WIN32) || defined(_WIN64)) && !defined(__MINGW32__)\n#  define SHA_LONG64 unsigned __int64\n#  define U64(C)     C##UI64\n# elif defined(__arch64__)\n#  define SHA_LONG64 unsigned long\n#  define U64(C)     C##UL\n# else\n#  define SHA_LONG64 unsigned long long\n#  define U64(C)     C##ULL\n# endif\n\ntypedef struct SHA512state_st {\n    SHA_LONG64 h[8];\n    SHA_LONG64 Nl, Nh;\n    union {\n        SHA_LONG64 d[SHA_LBLOCK];\n        unsigned char p[SHA512_CBLOCK];\n    } u;\n    unsigned int num, md_len;\n} SHA512_CTX;\n\nint SHA384_Init(SHA512_CTX *c);\nint SHA384_Update(SHA512_CTX *c, const void *data, size_t len);\nint SHA384_Final(unsigned char *md, SHA512_CTX *c);\nunsigned char *SHA384(const unsigned char *d, size_t n, unsigned char *md);\nint SHA512_Init(SHA512_CTX *c);\nint SHA512_Update(SHA512_CTX *c, const void *data, size_t len);\nint SHA512_Final(unsigned char *md, SHA512_CTX *c);\nunsigned char *SHA512(const unsigned char *d, size_t n, unsigned char *md);\nvoid SHA512_Transform(SHA512_CTX *c, const unsigned char *data);\n\n#ifdef  __cplusplus\n}\n#endif\n\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/include/openssl/srp.h",
    "content": "/*\n * Copyright 2004-2018 The OpenSSL Project Authors. All Rights Reserved.\n * Copyright (c) 2004, EdelKey Project. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n *\n * Originally written by Christophe Renou and Peter Sylvester,\n * for the EdelKey project.\n */\n\n#ifndef HEADER_SRP_H\n# define HEADER_SRP_H\n\n#include <openssl/opensslconf.h>\n\n#ifndef OPENSSL_NO_SRP\n# include <stdio.h>\n# include <string.h>\n# include <openssl/safestack.h>\n# include <openssl/bn.h>\n# include <openssl/crypto.h>\n\n# ifdef  __cplusplus\nextern \"C\" {\n# endif\n\ntypedef struct SRP_gN_cache_st {\n    char *b64_bn;\n    BIGNUM *bn;\n} SRP_gN_cache;\n\n\nDEFINE_STACK_OF(SRP_gN_cache)\n\ntypedef struct SRP_user_pwd_st {\n    /* Owned by us. */\n    char *id;\n    BIGNUM *s;\n    BIGNUM *v;\n    /* Not owned by us. */\n    const BIGNUM *g;\n    const BIGNUM *N;\n    /* Owned by us. */\n    char *info;\n} SRP_user_pwd;\n\nvoid SRP_user_pwd_free(SRP_user_pwd *user_pwd);\n\nDEFINE_STACK_OF(SRP_user_pwd)\n\ntypedef struct SRP_VBASE_st {\n    STACK_OF(SRP_user_pwd) *users_pwd;\n    STACK_OF(SRP_gN_cache) *gN_cache;\n/* to simulate a user */\n    char *seed_key;\n    const BIGNUM *default_g;\n    const BIGNUM *default_N;\n} SRP_VBASE;\n\n/*\n * Internal structure storing N and g pair\n */\ntypedef struct SRP_gN_st {\n    char *id;\n    const BIGNUM *g;\n    const BIGNUM *N;\n} SRP_gN;\n\nDEFINE_STACK_OF(SRP_gN)\n\nSRP_VBASE *SRP_VBASE_new(char *seed_key);\nvoid SRP_VBASE_free(SRP_VBASE *vb);\nint SRP_VBASE_init(SRP_VBASE *vb, char *verifier_file);\n\n/* This method ignores the configured seed and fails for an unknown user. */\nDEPRECATEDIN_1_1_0(SRP_user_pwd *SRP_VBASE_get_by_user(SRP_VBASE *vb, char *username))\n/* NOTE: unlike in SRP_VBASE_get_by_user, caller owns the returned pointer.*/\nSRP_user_pwd *SRP_VBASE_get1_by_user(SRP_VBASE *vb, char *username);\n\nchar *SRP_create_verifier(const char *user, const char *pass, char **salt,\n                          char **verifier, const char *N, const char *g);\nint SRP_create_verifier_BN(const char *user, const char *pass, BIGNUM **salt,\n                           BIGNUM **verifier, const BIGNUM *N,\n                           const BIGNUM *g);\n\n# define SRP_NO_ERROR 0\n# define SRP_ERR_VBASE_INCOMPLETE_FILE 1\n# define SRP_ERR_VBASE_BN_LIB 2\n# define SRP_ERR_OPEN_FILE 3\n# define SRP_ERR_MEMORY 4\n\n# define DB_srptype      0\n# define DB_srpverifier  1\n# define DB_srpsalt      2\n# define DB_srpid        3\n# define DB_srpgN        4\n# define DB_srpinfo      5\n# undef  DB_NUMBER\n# define DB_NUMBER       6\n\n# define DB_SRP_INDEX    'I'\n# define DB_SRP_VALID    'V'\n# define DB_SRP_REVOKED  'R'\n# define DB_SRP_MODIF    'v'\n\n/* see srp.c */\nchar *SRP_check_known_gN_param(const BIGNUM *g, const BIGNUM *N);\nSRP_gN *SRP_get_default_gN(const char *id);\n\n/* server side .... */\nBIGNUM *SRP_Calc_server_key(const BIGNUM *A, const BIGNUM *v, const BIGNUM *u,\n                            const BIGNUM *b, const BIGNUM *N);\nBIGNUM *SRP_Calc_B(const BIGNUM *b, const BIGNUM *N, const BIGNUM *g,\n                   const BIGNUM *v);\nint SRP_Verify_A_mod_N(const BIGNUM *A, const BIGNUM *N);\nBIGNUM *SRP_Calc_u(const BIGNUM *A, const BIGNUM *B, const BIGNUM *N);\n\n/* client side .... */\nBIGNUM *SRP_Calc_x(const BIGNUM *s, const char *user, const char *pass);\nBIGNUM *SRP_Calc_A(const BIGNUM *a, const BIGNUM *N, const BIGNUM *g);\nBIGNUM *SRP_Calc_client_key(const BIGNUM *N, const BIGNUM *B, const BIGNUM *g,\n                            const BIGNUM *x, const BIGNUM *a, const BIGNUM *u);\nint SRP_Verify_B_mod_N(const BIGNUM *B, const BIGNUM *N);\n\n# define SRP_MINIMAL_N 1024\n\n# ifdef  __cplusplus\n}\n# endif\n# endif\n\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/include/openssl/srtp.h",
    "content": "/*\n * Copyright 2011-2016 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n/*\n * DTLS code by Eric Rescorla <ekr@rtfm.com>\n *\n * Copyright (C) 2006, Network Resonance, Inc. Copyright (C) 2011, RTFM, Inc.\n */\n\n#ifndef HEADER_D1_SRTP_H\n# define HEADER_D1_SRTP_H\n\n# include <openssl/ssl.h>\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n# define SRTP_AES128_CM_SHA1_80 0x0001\n# define SRTP_AES128_CM_SHA1_32 0x0002\n# define SRTP_AES128_F8_SHA1_80 0x0003\n# define SRTP_AES128_F8_SHA1_32 0x0004\n# define SRTP_NULL_SHA1_80      0x0005\n# define SRTP_NULL_SHA1_32      0x0006\n\n/* AEAD SRTP protection profiles from RFC 7714 */\n# define SRTP_AEAD_AES_128_GCM  0x0007\n# define SRTP_AEAD_AES_256_GCM  0x0008\n\n# ifndef OPENSSL_NO_SRTP\n\n__owur int SSL_CTX_set_tlsext_use_srtp(SSL_CTX *ctx, const char *profiles);\n__owur int SSL_set_tlsext_use_srtp(SSL *ssl, const char *profiles);\n\n__owur STACK_OF(SRTP_PROTECTION_PROFILE) *SSL_get_srtp_profiles(SSL *ssl);\n__owur SRTP_PROTECTION_PROFILE *SSL_get_selected_srtp_profile(SSL *s);\n\n# endif\n\n#ifdef  __cplusplus\n}\n#endif\n\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/include/openssl/ssl.h",
    "content": "/*\n * Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved.\n * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved\n * Copyright 2005 Nokia. All rights reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef HEADER_SSL_H\n# define HEADER_SSL_H\n\n# include <openssl/e_os2.h>\n# include <openssl/opensslconf.h>\n# include <openssl/comp.h>\n# include <openssl/bio.h>\n# if OPENSSL_API_COMPAT < 0x10100000L\n#  include <openssl/x509.h>\n#  include <openssl/crypto.h>\n#  include <openssl/buffer.h>\n# endif\n# include <openssl/lhash.h>\n# include <openssl/pem.h>\n# include <openssl/hmac.h>\n# include <openssl/async.h>\n\n# include <openssl/safestack.h>\n# include <openssl/symhacks.h>\n# include <openssl/ct.h>\n# include <openssl/sslerr.h>\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n/* OpenSSL version number for ASN.1 encoding of the session information */\n/*-\n * Version 0 - initial version\n * Version 1 - added the optional peer certificate\n */\n# define SSL_SESSION_ASN1_VERSION 0x0001\n\n# define SSL_MAX_SSL_SESSION_ID_LENGTH           32\n# define SSL_MAX_SID_CTX_LENGTH                  32\n\n# define SSL_MIN_RSA_MODULUS_LENGTH_IN_BYTES     (512/8)\n# define SSL_MAX_KEY_ARG_LENGTH                  8\n# define SSL_MAX_MASTER_KEY_LENGTH               48\n\n/* The maximum number of encrypt/decrypt pipelines we can support */\n# define SSL_MAX_PIPELINES  32\n\n/* text strings for the ciphers */\n\n/* These are used to specify which ciphers to use and not to use */\n\n# define SSL_TXT_LOW             \"LOW\"\n# define SSL_TXT_MEDIUM          \"MEDIUM\"\n# define SSL_TXT_HIGH            \"HIGH\"\n# define SSL_TXT_FIPS            \"FIPS\"\n\n# define SSL_TXT_aNULL           \"aNULL\"\n# define SSL_TXT_eNULL           \"eNULL\"\n# define SSL_TXT_NULL            \"NULL\"\n\n# define SSL_TXT_kRSA            \"kRSA\"\n# define SSL_TXT_kDHr            \"kDHr\"/* this cipher class has been removed */\n# define SSL_TXT_kDHd            \"kDHd\"/* this cipher class has been removed */\n# define SSL_TXT_kDH             \"kDH\"/* this cipher class has been removed */\n# define SSL_TXT_kEDH            \"kEDH\"/* alias for kDHE */\n# define SSL_TXT_kDHE            \"kDHE\"\n# define SSL_TXT_kECDHr          \"kECDHr\"/* this cipher class has been removed */\n# define SSL_TXT_kECDHe          \"kECDHe\"/* this cipher class has been removed */\n# define SSL_TXT_kECDH           \"kECDH\"/* this cipher class has been removed */\n# define SSL_TXT_kEECDH          \"kEECDH\"/* alias for kECDHE */\n# define SSL_TXT_kECDHE          \"kECDHE\"\n# define SSL_TXT_kPSK            \"kPSK\"\n# define SSL_TXT_kRSAPSK         \"kRSAPSK\"\n# define SSL_TXT_kECDHEPSK       \"kECDHEPSK\"\n# define SSL_TXT_kDHEPSK         \"kDHEPSK\"\n# define SSL_TXT_kGOST           \"kGOST\"\n# define SSL_TXT_kSRP            \"kSRP\"\n\n# define SSL_TXT_aRSA            \"aRSA\"\n# define SSL_TXT_aDSS            \"aDSS\"\n# define SSL_TXT_aDH             \"aDH\"/* this cipher class has been removed */\n# define SSL_TXT_aECDH           \"aECDH\"/* this cipher class has been removed */\n# define SSL_TXT_aECDSA          \"aECDSA\"\n# define SSL_TXT_aPSK            \"aPSK\"\n# define SSL_TXT_aGOST94         \"aGOST94\"\n# define SSL_TXT_aGOST01         \"aGOST01\"\n# define SSL_TXT_aGOST12         \"aGOST12\"\n# define SSL_TXT_aGOST           \"aGOST\"\n# define SSL_TXT_aSRP            \"aSRP\"\n\n# define SSL_TXT_DSS             \"DSS\"\n# define SSL_TXT_DH              \"DH\"\n# define SSL_TXT_DHE             \"DHE\"/* same as \"kDHE:-ADH\" */\n# define SSL_TXT_EDH             \"EDH\"/* alias for DHE */\n# define SSL_TXT_ADH             \"ADH\"\n# define SSL_TXT_RSA             \"RSA\"\n# define SSL_TXT_ECDH            \"ECDH\"\n# define SSL_TXT_EECDH           \"EECDH\"/* alias for ECDHE\" */\n# define SSL_TXT_ECDHE           \"ECDHE\"/* same as \"kECDHE:-AECDH\" */\n# define SSL_TXT_AECDH           \"AECDH\"\n# define SSL_TXT_ECDSA           \"ECDSA\"\n# define SSL_TXT_PSK             \"PSK\"\n# define SSL_TXT_SRP             \"SRP\"\n\n# define SSL_TXT_DES             \"DES\"\n# define SSL_TXT_3DES            \"3DES\"\n# define SSL_TXT_RC4             \"RC4\"\n# define SSL_TXT_RC2             \"RC2\"\n# define SSL_TXT_IDEA            \"IDEA\"\n# define SSL_TXT_SEED            \"SEED\"\n# define SSL_TXT_AES128          \"AES128\"\n# define SSL_TXT_AES256          \"AES256\"\n# define SSL_TXT_AES             \"AES\"\n# define SSL_TXT_AES_GCM         \"AESGCM\"\n# define SSL_TXT_AES_CCM         \"AESCCM\"\n# define SSL_TXT_AES_CCM_8       \"AESCCM8\"\n# define SSL_TXT_CAMELLIA128     \"CAMELLIA128\"\n# define SSL_TXT_CAMELLIA256     \"CAMELLIA256\"\n# define SSL_TXT_CAMELLIA        \"CAMELLIA\"\n# define SSL_TXT_CHACHA20        \"CHACHA20\"\n# define SSL_TXT_GOST            \"GOST89\"\n# define SSL_TXT_ARIA            \"ARIA\"\n# define SSL_TXT_ARIA_GCM        \"ARIAGCM\"\n# define SSL_TXT_ARIA128         \"ARIA128\"\n# define SSL_TXT_ARIA256         \"ARIA256\"\n\n# define SSL_TXT_MD5             \"MD5\"\n# define SSL_TXT_SHA1            \"SHA1\"\n# define SSL_TXT_SHA             \"SHA\"/* same as \"SHA1\" */\n# define SSL_TXT_GOST94          \"GOST94\"\n# define SSL_TXT_GOST89MAC       \"GOST89MAC\"\n# define SSL_TXT_GOST12          \"GOST12\"\n# define SSL_TXT_GOST89MAC12     \"GOST89MAC12\"\n# define SSL_TXT_SHA256          \"SHA256\"\n# define SSL_TXT_SHA384          \"SHA384\"\n\n# define SSL_TXT_SSLV3           \"SSLv3\"\n# define SSL_TXT_TLSV1           \"TLSv1\"\n# define SSL_TXT_TLSV1_1         \"TLSv1.1\"\n# define SSL_TXT_TLSV1_2         \"TLSv1.2\"\n\n# define SSL_TXT_ALL             \"ALL\"\n\n/*-\n * COMPLEMENTOF* definitions. These identifiers are used to (de-select)\n * ciphers normally not being used.\n * Example: \"RC4\" will activate all ciphers using RC4 including ciphers\n * without authentication, which would normally disabled by DEFAULT (due\n * the \"!ADH\" being part of default). Therefore \"RC4:!COMPLEMENTOFDEFAULT\"\n * will make sure that it is also disabled in the specific selection.\n * COMPLEMENTOF* identifiers are portable between version, as adjustments\n * to the default cipher setup will also be included here.\n *\n * COMPLEMENTOFDEFAULT does not experience the same special treatment that\n * DEFAULT gets, as only selection is being done and no sorting as needed\n * for DEFAULT.\n */\n# define SSL_TXT_CMPALL          \"COMPLEMENTOFALL\"\n# define SSL_TXT_CMPDEF          \"COMPLEMENTOFDEFAULT\"\n\n/*\n * The following cipher list is used by default. It also is substituted when\n * an application-defined cipher list string starts with 'DEFAULT'.\n * This applies to ciphersuites for TLSv1.2 and below.\n */\n# define SSL_DEFAULT_CIPHER_LIST \"ALL:!COMPLEMENTOFDEFAULT:!eNULL\"\n/* This is the default set of TLSv1.3 ciphersuites */\n# if !defined(OPENSSL_NO_CHACHA) && !defined(OPENSSL_NO_POLY1305)\n#  define TLS_DEFAULT_CIPHERSUITES \"TLS_AES_256_GCM_SHA384:\" \\\n                                   \"TLS_CHACHA20_POLY1305_SHA256:\" \\\n                                   \"TLS_AES_128_GCM_SHA256\"\n# else\n#  define TLS_DEFAULT_CIPHERSUITES \"TLS_AES_256_GCM_SHA384:\" \\\n                                   \"TLS_AES_128_GCM_SHA256\"\n#endif\n/*\n * As of OpenSSL 1.0.0, ssl_create_cipher_list() in ssl/ssl_ciph.c always\n * starts with a reasonable order, and all we have to do for DEFAULT is\n * throwing out anonymous and unencrypted ciphersuites! (The latter are not\n * actually enabled by ALL, but \"ALL:RSA\" would enable some of them.)\n */\n\n/* Used in SSL_set_shutdown()/SSL_get_shutdown(); */\n# define SSL_SENT_SHUTDOWN       1\n# define SSL_RECEIVED_SHUTDOWN   2\n\n#ifdef __cplusplus\n}\n#endif\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n# define SSL_FILETYPE_ASN1       X509_FILETYPE_ASN1\n# define SSL_FILETYPE_PEM        X509_FILETYPE_PEM\n\n/*\n * This is needed to stop compilers complaining about the 'struct ssl_st *'\n * function parameters used to prototype callbacks in SSL_CTX.\n */\ntypedef struct ssl_st *ssl_crock_st;\ntypedef struct tls_session_ticket_ext_st TLS_SESSION_TICKET_EXT;\ntypedef struct ssl_method_st SSL_METHOD;\ntypedef struct ssl_cipher_st SSL_CIPHER;\ntypedef struct ssl_session_st SSL_SESSION;\ntypedef struct tls_sigalgs_st TLS_SIGALGS;\ntypedef struct ssl_conf_ctx_st SSL_CONF_CTX;\ntypedef struct ssl_comp_st SSL_COMP;\n\nSTACK_OF(SSL_CIPHER);\nSTACK_OF(SSL_COMP);\n\n/* SRTP protection profiles for use with the use_srtp extension (RFC 5764)*/\ntypedef struct srtp_protection_profile_st {\n    const char *name;\n    unsigned long id;\n} SRTP_PROTECTION_PROFILE;\n\nDEFINE_STACK_OF(SRTP_PROTECTION_PROFILE)\n\ntypedef int (*tls_session_ticket_ext_cb_fn)(SSL *s, const unsigned char *data,\n                                            int len, void *arg);\ntypedef int (*tls_session_secret_cb_fn)(SSL *s, void *secret, int *secret_len,\n                                        STACK_OF(SSL_CIPHER) *peer_ciphers,\n                                        const SSL_CIPHER **cipher, void *arg);\n\n/* Extension context codes */\n/* This extension is only allowed in TLS */\n#define SSL_EXT_TLS_ONLY                        0x0001\n/* This extension is only allowed in DTLS */\n#define SSL_EXT_DTLS_ONLY                       0x0002\n/* Some extensions may be allowed in DTLS but we don't implement them for it */\n#define SSL_EXT_TLS_IMPLEMENTATION_ONLY         0x0004\n/* Most extensions are not defined for SSLv3 but EXT_TYPE_renegotiate is */\n#define SSL_EXT_SSL3_ALLOWED                    0x0008\n/* Extension is only defined for TLS1.2 and below */\n#define SSL_EXT_TLS1_2_AND_BELOW_ONLY           0x0010\n/* Extension is only defined for TLS1.3 and above */\n#define SSL_EXT_TLS1_3_ONLY                     0x0020\n/* Ignore this extension during parsing if we are resuming */\n#define SSL_EXT_IGNORE_ON_RESUMPTION            0x0040\n#define SSL_EXT_CLIENT_HELLO                    0x0080\n/* Really means TLS1.2 or below */\n#define SSL_EXT_TLS1_2_SERVER_HELLO             0x0100\n#define SSL_EXT_TLS1_3_SERVER_HELLO             0x0200\n#define SSL_EXT_TLS1_3_ENCRYPTED_EXTENSIONS     0x0400\n#define SSL_EXT_TLS1_3_HELLO_RETRY_REQUEST      0x0800\n#define SSL_EXT_TLS1_3_CERTIFICATE              0x1000\n#define SSL_EXT_TLS1_3_NEW_SESSION_TICKET       0x2000\n#define SSL_EXT_TLS1_3_CERTIFICATE_REQUEST      0x4000\n\n/* Typedefs for handling custom extensions */\n\ntypedef int (*custom_ext_add_cb)(SSL *s, unsigned int ext_type,\n                                 const unsigned char **out, size_t *outlen,\n                                 int *al, void *add_arg);\n\ntypedef void (*custom_ext_free_cb)(SSL *s, unsigned int ext_type,\n                                   const unsigned char *out, void *add_arg);\n\ntypedef int (*custom_ext_parse_cb)(SSL *s, unsigned int ext_type,\n                                   const unsigned char *in, size_t inlen,\n                                   int *al, void *parse_arg);\n\n\ntypedef int (*SSL_custom_ext_add_cb_ex)(SSL *s, unsigned int ext_type,\n                                        unsigned int context,\n                                        const unsigned char **out,\n                                        size_t *outlen, X509 *x,\n                                        size_t chainidx,\n                                        int *al, void *add_arg);\n\ntypedef void (*SSL_custom_ext_free_cb_ex)(SSL *s, unsigned int ext_type,\n                                          unsigned int context,\n                                          const unsigned char *out,\n                                          void *add_arg);\n\ntypedef int (*SSL_custom_ext_parse_cb_ex)(SSL *s, unsigned int ext_type,\n                                          unsigned int context,\n                                          const unsigned char *in,\n                                          size_t inlen, X509 *x,\n                                          size_t chainidx,\n                                          int *al, void *parse_arg);\n\n/* Typedef for verification callback */\ntypedef int (*SSL_verify_cb)(int preverify_ok, X509_STORE_CTX *x509_ctx);\n\n/*\n * Some values are reserved until OpenSSL 1.2.0 because they were previously\n * included in SSL_OP_ALL in a 1.1.x release.\n *\n * Reserved value (until OpenSSL 1.2.0)                  0x00000001U\n * Reserved value (until OpenSSL 1.2.0)                  0x00000002U\n */\n/* Allow initial connection to servers that don't support RI */\n# define SSL_OP_LEGACY_SERVER_CONNECT                    0x00000004U\n\n/* Reserved value (until OpenSSL 1.2.0)                  0x00000008U */\n# define SSL_OP_TLSEXT_PADDING                           0x00000010U\n/* Reserved value (until OpenSSL 1.2.0)                  0x00000020U */\n# define SSL_OP_SAFARI_ECDHE_ECDSA_BUG                   0x00000040U\n/*\n * Reserved value (until OpenSSL 1.2.0)                  0x00000080U\n * Reserved value (until OpenSSL 1.2.0)                  0x00000100U\n * Reserved value (until OpenSSL 1.2.0)                  0x00000200U\n */\n\n/* In TLSv1.3 allow a non-(ec)dhe based kex_mode */\n# define SSL_OP_ALLOW_NO_DHE_KEX                         0x00000400U\n\n/*\n * Disable SSL 3.0/TLS 1.0 CBC vulnerability workaround that was added in\n * OpenSSL 0.9.6d.  Usually (depending on the application protocol) the\n * workaround is not needed.  Unfortunately some broken SSL/TLS\n * implementations cannot handle it at all, which is why we include it in\n * SSL_OP_ALL. Added in 0.9.6e\n */\n# define SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS              0x00000800U\n\n/* DTLS options */\n# define SSL_OP_NO_QUERY_MTU                             0x00001000U\n/* Turn on Cookie Exchange (on relevant for servers) */\n# define SSL_OP_COOKIE_EXCHANGE                          0x00002000U\n/* Don't use RFC4507 ticket extension */\n# define SSL_OP_NO_TICKET                                0x00004000U\n# ifndef OPENSSL_NO_DTLS1_METHOD\n/* Use Cisco's \"speshul\" version of DTLS_BAD_VER\n * (only with deprecated DTLSv1_client_method())  */\n#  define SSL_OP_CISCO_ANYCONNECT                        0x00008000U\n# endif\n\n/* As server, disallow session resumption on renegotiation */\n# define SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION   0x00010000U\n/* Don't use compression even if supported */\n# define SSL_OP_NO_COMPRESSION                           0x00020000U\n/* Permit unsafe legacy renegotiation */\n# define SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION        0x00040000U\n/* Disable encrypt-then-mac */\n# define SSL_OP_NO_ENCRYPT_THEN_MAC                      0x00080000U\n\n/*\n * Enable TLSv1.3 Compatibility mode. This is on by default. A future version\n * of OpenSSL may have this disabled by default.\n */\n# define SSL_OP_ENABLE_MIDDLEBOX_COMPAT                  0x00100000U\n\n/* Prioritize Chacha20Poly1305 when client does.\n * Modifies SSL_OP_CIPHER_SERVER_PREFERENCE */\n# define SSL_OP_PRIORITIZE_CHACHA                        0x00200000U\n\n/*\n * Set on servers to choose the cipher according to the server's preferences\n */\n# define SSL_OP_CIPHER_SERVER_PREFERENCE                 0x00400000U\n/*\n * If set, a server will allow a client to issue a SSLv3.0 version number as\n * latest version supported in the premaster secret, even when TLSv1.0\n * (version 3.1) was announced in the client hello. Normally this is\n * forbidden to prevent version rollback attacks.\n */\n# define SSL_OP_TLS_ROLLBACK_BUG                         0x00800000U\n\n/*\n * Switches off automatic TLSv1.3 anti-replay protection for early data. This\n * is a server-side option only (no effect on the client).\n */\n# define SSL_OP_NO_ANTI_REPLAY                           0x01000000U\n\n# define SSL_OP_NO_SSLv3                                 0x02000000U\n# define SSL_OP_NO_TLSv1                                 0x04000000U\n# define SSL_OP_NO_TLSv1_2                               0x08000000U\n# define SSL_OP_NO_TLSv1_1                               0x10000000U\n# define SSL_OP_NO_TLSv1_3                               0x20000000U\n\n# define SSL_OP_NO_DTLSv1                                0x04000000U\n# define SSL_OP_NO_DTLSv1_2                              0x08000000U\n\n# define SSL_OP_NO_SSL_MASK (SSL_OP_NO_SSLv3|\\\n        SSL_OP_NO_TLSv1|SSL_OP_NO_TLSv1_1|SSL_OP_NO_TLSv1_2|SSL_OP_NO_TLSv1_3)\n# define SSL_OP_NO_DTLS_MASK (SSL_OP_NO_DTLSv1|SSL_OP_NO_DTLSv1_2)\n\n/* Disallow all renegotiation */\n# define SSL_OP_NO_RENEGOTIATION                         0x40000000U\n\n/*\n * Make server add server-hello extension from early version of cryptopro\n * draft, when GOST ciphersuite is negotiated. Required for interoperability\n * with CryptoPro CSP 3.x\n */\n# define SSL_OP_CRYPTOPRO_TLSEXT_BUG                     0x80000000U\n\n/*\n * SSL_OP_ALL: various bug workarounds that should be rather harmless.\n * This used to be 0x000FFFFFL before 0.9.7.\n * This used to be 0x80000BFFU before 1.1.1.\n */\n# define SSL_OP_ALL        (SSL_OP_CRYPTOPRO_TLSEXT_BUG|\\\n                            SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS|\\\n                            SSL_OP_LEGACY_SERVER_CONNECT|\\\n                            SSL_OP_TLSEXT_PADDING|\\\n                            SSL_OP_SAFARI_ECDHE_ECDSA_BUG)\n\n/* OBSOLETE OPTIONS: retained for compatibility */\n\n/* Removed from OpenSSL 1.1.0. Was 0x00000001L */\n/* Related to removed SSLv2. */\n# define SSL_OP_MICROSOFT_SESS_ID_BUG                    0x0\n/* Removed from OpenSSL 1.1.0. Was 0x00000002L */\n/* Related to removed SSLv2. */\n# define SSL_OP_NETSCAPE_CHALLENGE_BUG                   0x0\n/* Removed from OpenSSL 0.9.8q and 1.0.0c. Was 0x00000008L */\n/* Dead forever, see CVE-2010-4180 */\n# define SSL_OP_NETSCAPE_REUSE_CIPHER_CHANGE_BUG         0x0\n/* Removed from OpenSSL 1.0.1h and 1.0.2. Was 0x00000010L */\n/* Refers to ancient SSLREF and SSLv2. */\n# define SSL_OP_SSLREF2_REUSE_CERT_TYPE_BUG              0x0\n/* Removed from OpenSSL 1.1.0. Was 0x00000020 */\n# define SSL_OP_MICROSOFT_BIG_SSLV3_BUFFER               0x0\n/* Removed from OpenSSL 0.9.7h and 0.9.8b. Was 0x00000040L */\n# define SSL_OP_MSIE_SSLV2_RSA_PADDING                   0x0\n/* Removed from OpenSSL 1.1.0. Was 0x00000080 */\n/* Ancient SSLeay version. */\n# define SSL_OP_SSLEAY_080_CLIENT_DH_BUG                 0x0\n/* Removed from OpenSSL 1.1.0. Was 0x00000100L */\n# define SSL_OP_TLS_D5_BUG                               0x0\n/* Removed from OpenSSL 1.1.0. Was 0x00000200L */\n# define SSL_OP_TLS_BLOCK_PADDING_BUG                    0x0\n/* Removed from OpenSSL 1.1.0. Was 0x00080000L */\n# define SSL_OP_SINGLE_ECDH_USE                          0x0\n/* Removed from OpenSSL 1.1.0. Was 0x00100000L */\n# define SSL_OP_SINGLE_DH_USE                            0x0\n/* Removed from OpenSSL 1.0.1k and 1.0.2. Was 0x00200000L */\n# define SSL_OP_EPHEMERAL_RSA                            0x0\n/* Removed from OpenSSL 1.1.0. Was 0x01000000L */\n# define SSL_OP_NO_SSLv2                                 0x0\n/* Removed from OpenSSL 1.0.1. Was 0x08000000L */\n# define SSL_OP_PKCS1_CHECK_1                            0x0\n/* Removed from OpenSSL 1.0.1. Was 0x10000000L */\n# define SSL_OP_PKCS1_CHECK_2                            0x0\n/* Removed from OpenSSL 1.1.0. Was 0x20000000L */\n# define SSL_OP_NETSCAPE_CA_DN_BUG                       0x0\n/* Removed from OpenSSL 1.1.0. Was 0x40000000L */\n# define SSL_OP_NETSCAPE_DEMO_CIPHER_CHANGE_BUG          0x0\n\n/*\n * Allow SSL_write(..., n) to return r with 0 < r < n (i.e. report success\n * when just a single record has been written):\n */\n# define SSL_MODE_ENABLE_PARTIAL_WRITE       0x00000001U\n/*\n * Make it possible to retry SSL_write() with changed buffer location (buffer\n * contents must stay the same!); this is not the default to avoid the\n * misconception that non-blocking SSL_write() behaves like non-blocking\n * write():\n */\n# define SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER 0x00000002U\n/*\n * Never bother the application with retries if the transport is blocking:\n */\n# define SSL_MODE_AUTO_RETRY 0x00000004U\n/* Don't attempt to automatically build certificate chain */\n# define SSL_MODE_NO_AUTO_CHAIN 0x00000008U\n/*\n * Save RAM by releasing read and write buffers when they're empty. (SSL3 and\n * TLS only.) Released buffers are freed.\n */\n# define SSL_MODE_RELEASE_BUFFERS 0x00000010U\n/*\n * Send the current time in the Random fields of the ClientHello and\n * ServerHello records for compatibility with hypothetical implementations\n * that require it.\n */\n# define SSL_MODE_SEND_CLIENTHELLO_TIME 0x00000020U\n# define SSL_MODE_SEND_SERVERHELLO_TIME 0x00000040U\n/*\n * Send TLS_FALLBACK_SCSV in the ClientHello. To be set only by applications\n * that reconnect with a downgraded protocol version; see\n * draft-ietf-tls-downgrade-scsv-00 for details. DO NOT ENABLE THIS if your\n * application attempts a normal handshake. Only use this in explicit\n * fallback retries, following the guidance in\n * draft-ietf-tls-downgrade-scsv-00.\n */\n# define SSL_MODE_SEND_FALLBACK_SCSV 0x00000080U\n/*\n * Support Asynchronous operation\n */\n# define SSL_MODE_ASYNC 0x00000100U\n\n/*\n * When using DTLS/SCTP, include the terminating zero in the label\n * used for computing the endpoint-pair shared secret. Required for\n * interoperability with implementations having this bug like these\n * older version of OpenSSL:\n * - OpenSSL 1.0.0 series\n * - OpenSSL 1.0.1 series\n * - OpenSSL 1.0.2 series\n * - OpenSSL 1.1.0 series\n * - OpenSSL 1.1.1 and 1.1.1a\n */\n# define SSL_MODE_DTLS_SCTP_LABEL_LENGTH_BUG 0x00000400U\n\n/* Cert related flags */\n/*\n * Many implementations ignore some aspects of the TLS standards such as\n * enforcing certificate chain algorithms. When this is set we enforce them.\n */\n# define SSL_CERT_FLAG_TLS_STRICT                0x00000001U\n\n/* Suite B modes, takes same values as certificate verify flags */\n# define SSL_CERT_FLAG_SUITEB_128_LOS_ONLY       0x10000\n/* Suite B 192 bit only mode */\n# define SSL_CERT_FLAG_SUITEB_192_LOS            0x20000\n/* Suite B 128 bit mode allowing 192 bit algorithms */\n# define SSL_CERT_FLAG_SUITEB_128_LOS            0x30000\n\n/* Perform all sorts of protocol violations for testing purposes */\n# define SSL_CERT_FLAG_BROKEN_PROTOCOL           0x10000000\n\n/* Flags for building certificate chains */\n/* Treat any existing certificates as untrusted CAs */\n# define SSL_BUILD_CHAIN_FLAG_UNTRUSTED          0x1\n/* Don't include root CA in chain */\n# define SSL_BUILD_CHAIN_FLAG_NO_ROOT            0x2\n/* Just check certificates already there */\n# define SSL_BUILD_CHAIN_FLAG_CHECK              0x4\n/* Ignore verification errors */\n# define SSL_BUILD_CHAIN_FLAG_IGNORE_ERROR       0x8\n/* Clear verification errors from queue */\n# define SSL_BUILD_CHAIN_FLAG_CLEAR_ERROR        0x10\n\n/* Flags returned by SSL_check_chain */\n/* Certificate can be used with this session */\n# define CERT_PKEY_VALID         0x1\n/* Certificate can also be used for signing */\n# define CERT_PKEY_SIGN          0x2\n/* EE certificate signing algorithm OK */\n# define CERT_PKEY_EE_SIGNATURE  0x10\n/* CA signature algorithms OK */\n# define CERT_PKEY_CA_SIGNATURE  0x20\n/* EE certificate parameters OK */\n# define CERT_PKEY_EE_PARAM      0x40\n/* CA certificate parameters OK */\n# define CERT_PKEY_CA_PARAM      0x80\n/* Signing explicitly allowed as opposed to SHA1 fallback */\n# define CERT_PKEY_EXPLICIT_SIGN 0x100\n/* Client CA issuer names match (always set for server cert) */\n# define CERT_PKEY_ISSUER_NAME   0x200\n/* Cert type matches client types (always set for server cert) */\n# define CERT_PKEY_CERT_TYPE     0x400\n/* Cert chain suitable to Suite B */\n# define CERT_PKEY_SUITEB        0x800\n\n# define SSL_CONF_FLAG_CMDLINE           0x1\n# define SSL_CONF_FLAG_FILE              0x2\n# define SSL_CONF_FLAG_CLIENT            0x4\n# define SSL_CONF_FLAG_SERVER            0x8\n# define SSL_CONF_FLAG_SHOW_ERRORS       0x10\n# define SSL_CONF_FLAG_CERTIFICATE       0x20\n# define SSL_CONF_FLAG_REQUIRE_PRIVATE   0x40\n/* Configuration value types */\n# define SSL_CONF_TYPE_UNKNOWN           0x0\n# define SSL_CONF_TYPE_STRING            0x1\n# define SSL_CONF_TYPE_FILE              0x2\n# define SSL_CONF_TYPE_DIR               0x3\n# define SSL_CONF_TYPE_NONE              0x4\n\n/* Maximum length of the application-controlled segment of a a TLSv1.3 cookie */\n# define SSL_COOKIE_LENGTH                       4096\n\n/*\n * Note: SSL[_CTX]_set_{options,mode} use |= op on the previous value, they\n * cannot be used to clear bits.\n */\n\nunsigned long SSL_CTX_get_options(const SSL_CTX *ctx);\nunsigned long SSL_get_options(const SSL *s);\nunsigned long SSL_CTX_clear_options(SSL_CTX *ctx, unsigned long op);\nunsigned long SSL_clear_options(SSL *s, unsigned long op);\nunsigned long SSL_CTX_set_options(SSL_CTX *ctx, unsigned long op);\nunsigned long SSL_set_options(SSL *s, unsigned long op);\n\n# define SSL_CTX_set_mode(ctx,op) \\\n        SSL_CTX_ctrl((ctx),SSL_CTRL_MODE,(op),NULL)\n# define SSL_CTX_clear_mode(ctx,op) \\\n        SSL_CTX_ctrl((ctx),SSL_CTRL_CLEAR_MODE,(op),NULL)\n# define SSL_CTX_get_mode(ctx) \\\n        SSL_CTX_ctrl((ctx),SSL_CTRL_MODE,0,NULL)\n# define SSL_clear_mode(ssl,op) \\\n        SSL_ctrl((ssl),SSL_CTRL_CLEAR_MODE,(op),NULL)\n# define SSL_set_mode(ssl,op) \\\n        SSL_ctrl((ssl),SSL_CTRL_MODE,(op),NULL)\n# define SSL_get_mode(ssl) \\\n        SSL_ctrl((ssl),SSL_CTRL_MODE,0,NULL)\n# define SSL_set_mtu(ssl, mtu) \\\n        SSL_ctrl((ssl),SSL_CTRL_SET_MTU,(mtu),NULL)\n# define DTLS_set_link_mtu(ssl, mtu) \\\n        SSL_ctrl((ssl),DTLS_CTRL_SET_LINK_MTU,(mtu),NULL)\n# define DTLS_get_link_min_mtu(ssl) \\\n        SSL_ctrl((ssl),DTLS_CTRL_GET_LINK_MIN_MTU,0,NULL)\n\n# define SSL_get_secure_renegotiation_support(ssl) \\\n        SSL_ctrl((ssl), SSL_CTRL_GET_RI_SUPPORT, 0, NULL)\n\n# ifndef OPENSSL_NO_HEARTBEATS\n#  define SSL_heartbeat(ssl) \\\n        SSL_ctrl((ssl),SSL_CTRL_DTLS_EXT_SEND_HEARTBEAT,0,NULL)\n# endif\n\n# define SSL_CTX_set_cert_flags(ctx,op) \\\n        SSL_CTX_ctrl((ctx),SSL_CTRL_CERT_FLAGS,(op),NULL)\n# define SSL_set_cert_flags(s,op) \\\n        SSL_ctrl((s),SSL_CTRL_CERT_FLAGS,(op),NULL)\n# define SSL_CTX_clear_cert_flags(ctx,op) \\\n        SSL_CTX_ctrl((ctx),SSL_CTRL_CLEAR_CERT_FLAGS,(op),NULL)\n# define SSL_clear_cert_flags(s,op) \\\n        SSL_ctrl((s),SSL_CTRL_CLEAR_CERT_FLAGS,(op),NULL)\n\nvoid SSL_CTX_set_msg_callback(SSL_CTX *ctx,\n                              void (*cb) (int write_p, int version,\n                                          int content_type, const void *buf,\n                                          size_t len, SSL *ssl, void *arg));\nvoid SSL_set_msg_callback(SSL *ssl,\n                          void (*cb) (int write_p, int version,\n                                      int content_type, const void *buf,\n                                      size_t len, SSL *ssl, void *arg));\n# define SSL_CTX_set_msg_callback_arg(ctx, arg) SSL_CTX_ctrl((ctx), SSL_CTRL_SET_MSG_CALLBACK_ARG, 0, (arg))\n# define SSL_set_msg_callback_arg(ssl, arg) SSL_ctrl((ssl), SSL_CTRL_SET_MSG_CALLBACK_ARG, 0, (arg))\n\n# define SSL_get_extms_support(s) \\\n        SSL_ctrl((s),SSL_CTRL_GET_EXTMS_SUPPORT,0,NULL)\n\n# ifndef OPENSSL_NO_SRP\n\n/* see tls_srp.c */\n__owur int SSL_SRP_CTX_init(SSL *s);\n__owur int SSL_CTX_SRP_CTX_init(SSL_CTX *ctx);\nint SSL_SRP_CTX_free(SSL *ctx);\nint SSL_CTX_SRP_CTX_free(SSL_CTX *ctx);\n__owur int SSL_srp_server_param_with_username(SSL *s, int *ad);\n__owur int SRP_Calc_A_param(SSL *s);\n\n# endif\n\n/* 100k max cert list */\n# define SSL_MAX_CERT_LIST_DEFAULT 1024*100\n\n# define SSL_SESSION_CACHE_MAX_SIZE_DEFAULT      (1024*20)\n\n/*\n * This callback type is used inside SSL_CTX, SSL, and in the functions that\n * set them. It is used to override the generation of SSL/TLS session IDs in\n * a server. Return value should be zero on an error, non-zero to proceed.\n * Also, callbacks should themselves check if the id they generate is unique\n * otherwise the SSL handshake will fail with an error - callbacks can do\n * this using the 'ssl' value they're passed by;\n * SSL_has_matching_session_id(ssl, id, *id_len) The length value passed in\n * is set at the maximum size the session ID can be. In SSLv3/TLSv1 it is 32\n * bytes. The callback can alter this length to be less if desired. It is\n * also an error for the callback to set the size to zero.\n */\ntypedef int (*GEN_SESSION_CB) (SSL *ssl, unsigned char *id,\n                               unsigned int *id_len);\n\n# define SSL_SESS_CACHE_OFF                      0x0000\n# define SSL_SESS_CACHE_CLIENT                   0x0001\n# define SSL_SESS_CACHE_SERVER                   0x0002\n# define SSL_SESS_CACHE_BOTH     (SSL_SESS_CACHE_CLIENT|SSL_SESS_CACHE_SERVER)\n# define SSL_SESS_CACHE_NO_AUTO_CLEAR            0x0080\n/* enough comments already ... see SSL_CTX_set_session_cache_mode(3) */\n# define SSL_SESS_CACHE_NO_INTERNAL_LOOKUP       0x0100\n# define SSL_SESS_CACHE_NO_INTERNAL_STORE        0x0200\n# define SSL_SESS_CACHE_NO_INTERNAL \\\n        (SSL_SESS_CACHE_NO_INTERNAL_LOOKUP|SSL_SESS_CACHE_NO_INTERNAL_STORE)\n\nLHASH_OF(SSL_SESSION) *SSL_CTX_sessions(SSL_CTX *ctx);\n# define SSL_CTX_sess_number(ctx) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_SESS_NUMBER,0,NULL)\n# define SSL_CTX_sess_connect(ctx) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_SESS_CONNECT,0,NULL)\n# define SSL_CTX_sess_connect_good(ctx) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_SESS_CONNECT_GOOD,0,NULL)\n# define SSL_CTX_sess_connect_renegotiate(ctx) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_SESS_CONNECT_RENEGOTIATE,0,NULL)\n# define SSL_CTX_sess_accept(ctx) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_SESS_ACCEPT,0,NULL)\n# define SSL_CTX_sess_accept_renegotiate(ctx) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_SESS_ACCEPT_RENEGOTIATE,0,NULL)\n# define SSL_CTX_sess_accept_good(ctx) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_SESS_ACCEPT_GOOD,0,NULL)\n# define SSL_CTX_sess_hits(ctx) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_SESS_HIT,0,NULL)\n# define SSL_CTX_sess_cb_hits(ctx) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_SESS_CB_HIT,0,NULL)\n# define SSL_CTX_sess_misses(ctx) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_SESS_MISSES,0,NULL)\n# define SSL_CTX_sess_timeouts(ctx) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_SESS_TIMEOUTS,0,NULL)\n# define SSL_CTX_sess_cache_full(ctx) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_SESS_CACHE_FULL,0,NULL)\n\nvoid SSL_CTX_sess_set_new_cb(SSL_CTX *ctx,\n                             int (*new_session_cb) (struct ssl_st *ssl,\n                                                    SSL_SESSION *sess));\nint (*SSL_CTX_sess_get_new_cb(SSL_CTX *ctx)) (struct ssl_st *ssl,\n                                              SSL_SESSION *sess);\nvoid SSL_CTX_sess_set_remove_cb(SSL_CTX *ctx,\n                                void (*remove_session_cb) (struct ssl_ctx_st\n                                                           *ctx,\n                                                           SSL_SESSION *sess));\nvoid (*SSL_CTX_sess_get_remove_cb(SSL_CTX *ctx)) (struct ssl_ctx_st *ctx,\n                                                  SSL_SESSION *sess);\nvoid SSL_CTX_sess_set_get_cb(SSL_CTX *ctx,\n                             SSL_SESSION *(*get_session_cb) (struct ssl_st\n                                                             *ssl,\n                                                             const unsigned char\n                                                             *data, int len,\n                                                             int *copy));\nSSL_SESSION *(*SSL_CTX_sess_get_get_cb(SSL_CTX *ctx)) (struct ssl_st *ssl,\n                                                       const unsigned char *data,\n                                                       int len, int *copy);\nvoid SSL_CTX_set_info_callback(SSL_CTX *ctx,\n                               void (*cb) (const SSL *ssl, int type, int val));\nvoid (*SSL_CTX_get_info_callback(SSL_CTX *ctx)) (const SSL *ssl, int type,\n                                                 int val);\nvoid SSL_CTX_set_client_cert_cb(SSL_CTX *ctx,\n                                int (*client_cert_cb) (SSL *ssl, X509 **x509,\n                                                       EVP_PKEY **pkey));\nint (*SSL_CTX_get_client_cert_cb(SSL_CTX *ctx)) (SSL *ssl, X509 **x509,\n                                                 EVP_PKEY **pkey);\n# ifndef OPENSSL_NO_ENGINE\n__owur int SSL_CTX_set_client_cert_engine(SSL_CTX *ctx, ENGINE *e);\n# endif\nvoid SSL_CTX_set_cookie_generate_cb(SSL_CTX *ctx,\n                                    int (*app_gen_cookie_cb) (SSL *ssl,\n                                                              unsigned char\n                                                              *cookie,\n                                                              unsigned int\n                                                              *cookie_len));\nvoid SSL_CTX_set_cookie_verify_cb(SSL_CTX *ctx,\n                                  int (*app_verify_cookie_cb) (SSL *ssl,\n                                                               const unsigned\n                                                               char *cookie,\n                                                               unsigned int\n                                                               cookie_len));\n\nvoid SSL_CTX_set_stateless_cookie_generate_cb(\n    SSL_CTX *ctx,\n    int (*gen_stateless_cookie_cb) (SSL *ssl,\n                                    unsigned char *cookie,\n                                    size_t *cookie_len));\nvoid SSL_CTX_set_stateless_cookie_verify_cb(\n    SSL_CTX *ctx,\n    int (*verify_stateless_cookie_cb) (SSL *ssl,\n                                       const unsigned char *cookie,\n                                       size_t cookie_len));\n# ifndef OPENSSL_NO_NEXTPROTONEG\n\ntypedef int (*SSL_CTX_npn_advertised_cb_func)(SSL *ssl,\n                                              const unsigned char **out,\n                                              unsigned int *outlen,\n                                              void *arg);\nvoid SSL_CTX_set_next_protos_advertised_cb(SSL_CTX *s,\n                                           SSL_CTX_npn_advertised_cb_func cb,\n                                           void *arg);\n#  define SSL_CTX_set_npn_advertised_cb SSL_CTX_set_next_protos_advertised_cb\n\ntypedef int (*SSL_CTX_npn_select_cb_func)(SSL *s,\n                                          unsigned char **out,\n                                          unsigned char *outlen,\n                                          const unsigned char *in,\n                                          unsigned int inlen,\n                                          void *arg);\nvoid SSL_CTX_set_next_proto_select_cb(SSL_CTX *s,\n                                      SSL_CTX_npn_select_cb_func cb,\n                                      void *arg);\n#  define SSL_CTX_set_npn_select_cb SSL_CTX_set_next_proto_select_cb\n\nvoid SSL_get0_next_proto_negotiated(const SSL *s, const unsigned char **data,\n                                    unsigned *len);\n#  define SSL_get0_npn_negotiated SSL_get0_next_proto_negotiated\n# endif\n\n__owur int SSL_select_next_proto(unsigned char **out, unsigned char *outlen,\n                                 const unsigned char *in, unsigned int inlen,\n                                 const unsigned char *client,\n                                 unsigned int client_len);\n\n# define OPENSSL_NPN_UNSUPPORTED 0\n# define OPENSSL_NPN_NEGOTIATED  1\n# define OPENSSL_NPN_NO_OVERLAP  2\n\n__owur int SSL_CTX_set_alpn_protos(SSL_CTX *ctx, const unsigned char *protos,\n                                   unsigned int protos_len);\n__owur int SSL_set_alpn_protos(SSL *ssl, const unsigned char *protos,\n                               unsigned int protos_len);\ntypedef int (*SSL_CTX_alpn_select_cb_func)(SSL *ssl,\n                                           const unsigned char **out,\n                                           unsigned char *outlen,\n                                           const unsigned char *in,\n                                           unsigned int inlen,\n                                           void *arg);\nvoid SSL_CTX_set_alpn_select_cb(SSL_CTX *ctx,\n                                SSL_CTX_alpn_select_cb_func cb,\n                                void *arg);\nvoid SSL_get0_alpn_selected(const SSL *ssl, const unsigned char **data,\n                            unsigned int *len);\n\n# ifndef OPENSSL_NO_PSK\n/*\n * the maximum length of the buffer given to callbacks containing the\n * resulting identity/psk\n */\n#  define PSK_MAX_IDENTITY_LEN 128\n#  define PSK_MAX_PSK_LEN 256\ntypedef unsigned int (*SSL_psk_client_cb_func)(SSL *ssl,\n                                               const char *hint,\n                                               char *identity,\n                                               unsigned int max_identity_len,\n                                               unsigned char *psk,\n                                               unsigned int max_psk_len);\nvoid SSL_CTX_set_psk_client_callback(SSL_CTX *ctx, SSL_psk_client_cb_func cb);\nvoid SSL_set_psk_client_callback(SSL *ssl, SSL_psk_client_cb_func cb);\n\ntypedef unsigned int (*SSL_psk_server_cb_func)(SSL *ssl,\n                                               const char *identity,\n                                               unsigned char *psk,\n                                               unsigned int max_psk_len);\nvoid SSL_CTX_set_psk_server_callback(SSL_CTX *ctx, SSL_psk_server_cb_func cb);\nvoid SSL_set_psk_server_callback(SSL *ssl, SSL_psk_server_cb_func cb);\n\n__owur int SSL_CTX_use_psk_identity_hint(SSL_CTX *ctx, const char *identity_hint);\n__owur int SSL_use_psk_identity_hint(SSL *s, const char *identity_hint);\nconst char *SSL_get_psk_identity_hint(const SSL *s);\nconst char *SSL_get_psk_identity(const SSL *s);\n# endif\n\ntypedef int (*SSL_psk_find_session_cb_func)(SSL *ssl,\n                                            const unsigned char *identity,\n                                            size_t identity_len,\n                                            SSL_SESSION **sess);\ntypedef int (*SSL_psk_use_session_cb_func)(SSL *ssl, const EVP_MD *md,\n                                           const unsigned char **id,\n                                           size_t *idlen,\n                                           SSL_SESSION **sess);\n\nvoid SSL_set_psk_find_session_callback(SSL *s, SSL_psk_find_session_cb_func cb);\nvoid SSL_CTX_set_psk_find_session_callback(SSL_CTX *ctx,\n                                           SSL_psk_find_session_cb_func cb);\nvoid SSL_set_psk_use_session_callback(SSL *s, SSL_psk_use_session_cb_func cb);\nvoid SSL_CTX_set_psk_use_session_callback(SSL_CTX *ctx,\n                                          SSL_psk_use_session_cb_func cb);\n\n/* Register callbacks to handle custom TLS Extensions for client or server. */\n\n__owur int SSL_CTX_has_client_custom_ext(const SSL_CTX *ctx,\n                                         unsigned int ext_type);\n\n__owur int SSL_CTX_add_client_custom_ext(SSL_CTX *ctx,\n                                         unsigned int ext_type,\n                                         custom_ext_add_cb add_cb,\n                                         custom_ext_free_cb free_cb,\n                                         void *add_arg,\n                                         custom_ext_parse_cb parse_cb,\n                                         void *parse_arg);\n\n__owur int SSL_CTX_add_server_custom_ext(SSL_CTX *ctx,\n                                         unsigned int ext_type,\n                                         custom_ext_add_cb add_cb,\n                                         custom_ext_free_cb free_cb,\n                                         void *add_arg,\n                                         custom_ext_parse_cb parse_cb,\n                                         void *parse_arg);\n\n__owur int SSL_CTX_add_custom_ext(SSL_CTX *ctx, unsigned int ext_type,\n                                  unsigned int context,\n                                  SSL_custom_ext_add_cb_ex add_cb,\n                                  SSL_custom_ext_free_cb_ex free_cb,\n                                  void *add_arg,\n                                  SSL_custom_ext_parse_cb_ex parse_cb,\n                                  void *parse_arg);\n\n__owur int SSL_extension_supported(unsigned int ext_type);\n\n# define SSL_NOTHING            1\n# define SSL_WRITING            2\n# define SSL_READING            3\n# define SSL_X509_LOOKUP        4\n# define SSL_ASYNC_PAUSED       5\n# define SSL_ASYNC_NO_JOBS      6\n# define SSL_CLIENT_HELLO_CB    7\n\n/* These will only be used when doing non-blocking IO */\n# define SSL_want_nothing(s)         (SSL_want(s) == SSL_NOTHING)\n# define SSL_want_read(s)            (SSL_want(s) == SSL_READING)\n# define SSL_want_write(s)           (SSL_want(s) == SSL_WRITING)\n# define SSL_want_x509_lookup(s)     (SSL_want(s) == SSL_X509_LOOKUP)\n# define SSL_want_async(s)           (SSL_want(s) == SSL_ASYNC_PAUSED)\n# define SSL_want_async_job(s)       (SSL_want(s) == SSL_ASYNC_NO_JOBS)\n# define SSL_want_client_hello_cb(s) (SSL_want(s) == SSL_CLIENT_HELLO_CB)\n\n# define SSL_MAC_FLAG_READ_MAC_STREAM 1\n# define SSL_MAC_FLAG_WRITE_MAC_STREAM 2\n\n/*\n * A callback for logging out TLS key material. This callback should log out\n * |line| followed by a newline.\n */\ntypedef void (*SSL_CTX_keylog_cb_func)(const SSL *ssl, const char *line);\n\n/*\n * SSL_CTX_set_keylog_callback configures a callback to log key material. This\n * is intended for debugging use with tools like Wireshark. The cb function\n * should log line followed by a newline.\n */\nvoid SSL_CTX_set_keylog_callback(SSL_CTX *ctx, SSL_CTX_keylog_cb_func cb);\n\n/*\n * SSL_CTX_get_keylog_callback returns the callback configured by\n * SSL_CTX_set_keylog_callback.\n */\nSSL_CTX_keylog_cb_func SSL_CTX_get_keylog_callback(const SSL_CTX *ctx);\n\nint SSL_CTX_set_max_early_data(SSL_CTX *ctx, uint32_t max_early_data);\nuint32_t SSL_CTX_get_max_early_data(const SSL_CTX *ctx);\nint SSL_set_max_early_data(SSL *s, uint32_t max_early_data);\nuint32_t SSL_get_max_early_data(const SSL *s);\nint SSL_CTX_set_recv_max_early_data(SSL_CTX *ctx, uint32_t recv_max_early_data);\nuint32_t SSL_CTX_get_recv_max_early_data(const SSL_CTX *ctx);\nint SSL_set_recv_max_early_data(SSL *s, uint32_t recv_max_early_data);\nuint32_t SSL_get_recv_max_early_data(const SSL *s);\n\n#ifdef __cplusplus\n}\n#endif\n\n# include <openssl/ssl2.h>\n# include <openssl/ssl3.h>\n# include <openssl/tls1.h>      /* This is mostly sslv3 with a few tweaks */\n# include <openssl/dtls1.h>     /* Datagram TLS */\n# include <openssl/srtp.h>      /* Support for the use_srtp extension */\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n/*\n * These need to be after the above set of includes due to a compiler bug\n * in VisualStudio 2015\n */\nDEFINE_STACK_OF_CONST(SSL_CIPHER)\nDEFINE_STACK_OF(SSL_COMP)\n\n/* compatibility */\n# define SSL_set_app_data(s,arg)         (SSL_set_ex_data(s,0,(char *)(arg)))\n# define SSL_get_app_data(s)             (SSL_get_ex_data(s,0))\n# define SSL_SESSION_set_app_data(s,a)   (SSL_SESSION_set_ex_data(s,0, \\\n                                                                  (char *)(a)))\n# define SSL_SESSION_get_app_data(s)     (SSL_SESSION_get_ex_data(s,0))\n# define SSL_CTX_get_app_data(ctx)       (SSL_CTX_get_ex_data(ctx,0))\n# define SSL_CTX_set_app_data(ctx,arg)   (SSL_CTX_set_ex_data(ctx,0, \\\n                                                              (char *)(arg)))\nDEPRECATEDIN_1_1_0(void SSL_set_debug(SSL *s, int debug))\n\n/* TLSv1.3 KeyUpdate message types */\n/* -1 used so that this is an invalid value for the on-the-wire protocol */\n#define SSL_KEY_UPDATE_NONE             -1\n/* Values as defined for the on-the-wire protocol */\n#define SSL_KEY_UPDATE_NOT_REQUESTED     0\n#define SSL_KEY_UPDATE_REQUESTED         1\n\n/*\n * The valid handshake states (one for each type message sent and one for each\n * type of message received). There are also two \"special\" states:\n * TLS = TLS or DTLS state\n * DTLS = DTLS specific state\n * CR/SR = Client Read/Server Read\n * CW/SW = Client Write/Server Write\n *\n * The \"special\" states are:\n * TLS_ST_BEFORE = No handshake has been initiated yet\n * TLS_ST_OK = A handshake has been successfully completed\n */\ntypedef enum {\n    TLS_ST_BEFORE,\n    TLS_ST_OK,\n    DTLS_ST_CR_HELLO_VERIFY_REQUEST,\n    TLS_ST_CR_SRVR_HELLO,\n    TLS_ST_CR_CERT,\n    TLS_ST_CR_CERT_STATUS,\n    TLS_ST_CR_KEY_EXCH,\n    TLS_ST_CR_CERT_REQ,\n    TLS_ST_CR_SRVR_DONE,\n    TLS_ST_CR_SESSION_TICKET,\n    TLS_ST_CR_CHANGE,\n    TLS_ST_CR_FINISHED,\n    TLS_ST_CW_CLNT_HELLO,\n    TLS_ST_CW_CERT,\n    TLS_ST_CW_KEY_EXCH,\n    TLS_ST_CW_CERT_VRFY,\n    TLS_ST_CW_CHANGE,\n    TLS_ST_CW_NEXT_PROTO,\n    TLS_ST_CW_FINISHED,\n    TLS_ST_SW_HELLO_REQ,\n    TLS_ST_SR_CLNT_HELLO,\n    DTLS_ST_SW_HELLO_VERIFY_REQUEST,\n    TLS_ST_SW_SRVR_HELLO,\n    TLS_ST_SW_CERT,\n    TLS_ST_SW_KEY_EXCH,\n    TLS_ST_SW_CERT_REQ,\n    TLS_ST_SW_SRVR_DONE,\n    TLS_ST_SR_CERT,\n    TLS_ST_SR_KEY_EXCH,\n    TLS_ST_SR_CERT_VRFY,\n    TLS_ST_SR_NEXT_PROTO,\n    TLS_ST_SR_CHANGE,\n    TLS_ST_SR_FINISHED,\n    TLS_ST_SW_SESSION_TICKET,\n    TLS_ST_SW_CERT_STATUS,\n    TLS_ST_SW_CHANGE,\n    TLS_ST_SW_FINISHED,\n    TLS_ST_SW_ENCRYPTED_EXTENSIONS,\n    TLS_ST_CR_ENCRYPTED_EXTENSIONS,\n    TLS_ST_CR_CERT_VRFY,\n    TLS_ST_SW_CERT_VRFY,\n    TLS_ST_CR_HELLO_REQ,\n    TLS_ST_SW_KEY_UPDATE,\n    TLS_ST_CW_KEY_UPDATE,\n    TLS_ST_SR_KEY_UPDATE,\n    TLS_ST_CR_KEY_UPDATE,\n    TLS_ST_EARLY_DATA,\n    TLS_ST_PENDING_EARLY_DATA_END,\n    TLS_ST_CW_END_OF_EARLY_DATA,\n    TLS_ST_SR_END_OF_EARLY_DATA\n} OSSL_HANDSHAKE_STATE;\n\n/*\n * Most of the following state values are no longer used and are defined to be\n * the closest equivalent value in the current state machine code. Not all\n * defines have an equivalent and are set to a dummy value (-1). SSL_ST_CONNECT\n * and SSL_ST_ACCEPT are still in use in the definition of SSL_CB_ACCEPT_LOOP,\n * SSL_CB_ACCEPT_EXIT, SSL_CB_CONNECT_LOOP and SSL_CB_CONNECT_EXIT.\n */\n\n# define SSL_ST_CONNECT                  0x1000\n# define SSL_ST_ACCEPT                   0x2000\n\n# define SSL_ST_MASK                     0x0FFF\n\n# define SSL_CB_LOOP                     0x01\n# define SSL_CB_EXIT                     0x02\n# define SSL_CB_READ                     0x04\n# define SSL_CB_WRITE                    0x08\n# define SSL_CB_ALERT                    0x4000/* used in callback */\n# define SSL_CB_READ_ALERT               (SSL_CB_ALERT|SSL_CB_READ)\n# define SSL_CB_WRITE_ALERT              (SSL_CB_ALERT|SSL_CB_WRITE)\n# define SSL_CB_ACCEPT_LOOP              (SSL_ST_ACCEPT|SSL_CB_LOOP)\n# define SSL_CB_ACCEPT_EXIT              (SSL_ST_ACCEPT|SSL_CB_EXIT)\n# define SSL_CB_CONNECT_LOOP             (SSL_ST_CONNECT|SSL_CB_LOOP)\n# define SSL_CB_CONNECT_EXIT             (SSL_ST_CONNECT|SSL_CB_EXIT)\n# define SSL_CB_HANDSHAKE_START          0x10\n# define SSL_CB_HANDSHAKE_DONE           0x20\n\n/* Is the SSL_connection established? */\n# define SSL_in_connect_init(a)          (SSL_in_init(a) && !SSL_is_server(a))\n# define SSL_in_accept_init(a)           (SSL_in_init(a) && SSL_is_server(a))\nint SSL_in_init(const SSL *s);\nint SSL_in_before(const SSL *s);\nint SSL_is_init_finished(const SSL *s);\n\n/*\n * The following 3 states are kept in ssl->rlayer.rstate when reads fail, you\n * should not need these\n */\n# define SSL_ST_READ_HEADER                      0xF0\n# define SSL_ST_READ_BODY                        0xF1\n# define SSL_ST_READ_DONE                        0xF2\n\n/*-\n * Obtain latest Finished message\n *   -- that we sent (SSL_get_finished)\n *   -- that we expected from peer (SSL_get_peer_finished).\n * Returns length (0 == no Finished so far), copies up to 'count' bytes.\n */\nsize_t SSL_get_finished(const SSL *s, void *buf, size_t count);\nsize_t SSL_get_peer_finished(const SSL *s, void *buf, size_t count);\n\n/*\n * use either SSL_VERIFY_NONE or SSL_VERIFY_PEER, the last 3 options are\n * 'ored' with SSL_VERIFY_PEER if they are desired\n */\n# define SSL_VERIFY_NONE                 0x00\n# define SSL_VERIFY_PEER                 0x01\n# define SSL_VERIFY_FAIL_IF_NO_PEER_CERT 0x02\n# define SSL_VERIFY_CLIENT_ONCE          0x04\n# define SSL_VERIFY_POST_HANDSHAKE       0x08\n\n# if OPENSSL_API_COMPAT < 0x10100000L\n#  define OpenSSL_add_ssl_algorithms()   SSL_library_init()\n#  define SSLeay_add_ssl_algorithms()    SSL_library_init()\n# endif\n\n/* More backward compatibility */\n# define SSL_get_cipher(s) \\\n                SSL_CIPHER_get_name(SSL_get_current_cipher(s))\n# define SSL_get_cipher_bits(s,np) \\\n                SSL_CIPHER_get_bits(SSL_get_current_cipher(s),np)\n# define SSL_get_cipher_version(s) \\\n                SSL_CIPHER_get_version(SSL_get_current_cipher(s))\n# define SSL_get_cipher_name(s) \\\n                SSL_CIPHER_get_name(SSL_get_current_cipher(s))\n# define SSL_get_time(a)         SSL_SESSION_get_time(a)\n# define SSL_set_time(a,b)       SSL_SESSION_set_time((a),(b))\n# define SSL_get_timeout(a)      SSL_SESSION_get_timeout(a)\n# define SSL_set_timeout(a,b)    SSL_SESSION_set_timeout((a),(b))\n\n# define d2i_SSL_SESSION_bio(bp,s_id) ASN1_d2i_bio_of(SSL_SESSION,SSL_SESSION_new,d2i_SSL_SESSION,bp,s_id)\n# define i2d_SSL_SESSION_bio(bp,s_id) ASN1_i2d_bio_of(SSL_SESSION,i2d_SSL_SESSION,bp,s_id)\n\nDECLARE_PEM_rw(SSL_SESSION, SSL_SESSION)\n# define SSL_AD_REASON_OFFSET            1000/* offset to get SSL_R_... value\n                                              * from SSL_AD_... */\n/* These alert types are for SSLv3 and TLSv1 */\n# define SSL_AD_CLOSE_NOTIFY             SSL3_AD_CLOSE_NOTIFY\n/* fatal */\n# define SSL_AD_UNEXPECTED_MESSAGE       SSL3_AD_UNEXPECTED_MESSAGE\n/* fatal */\n# define SSL_AD_BAD_RECORD_MAC           SSL3_AD_BAD_RECORD_MAC\n# define SSL_AD_DECRYPTION_FAILED        TLS1_AD_DECRYPTION_FAILED\n# define SSL_AD_RECORD_OVERFLOW          TLS1_AD_RECORD_OVERFLOW\n/* fatal */\n# define SSL_AD_DECOMPRESSION_FAILURE    SSL3_AD_DECOMPRESSION_FAILURE\n/* fatal */\n# define SSL_AD_HANDSHAKE_FAILURE        SSL3_AD_HANDSHAKE_FAILURE\n/* Not for TLS */\n# define SSL_AD_NO_CERTIFICATE           SSL3_AD_NO_CERTIFICATE\n# define SSL_AD_BAD_CERTIFICATE          SSL3_AD_BAD_CERTIFICATE\n# define SSL_AD_UNSUPPORTED_CERTIFICATE  SSL3_AD_UNSUPPORTED_CERTIFICATE\n# define SSL_AD_CERTIFICATE_REVOKED      SSL3_AD_CERTIFICATE_REVOKED\n# define SSL_AD_CERTIFICATE_EXPIRED      SSL3_AD_CERTIFICATE_EXPIRED\n# define SSL_AD_CERTIFICATE_UNKNOWN      SSL3_AD_CERTIFICATE_UNKNOWN\n/* fatal */\n# define SSL_AD_ILLEGAL_PARAMETER        SSL3_AD_ILLEGAL_PARAMETER\n/* fatal */\n# define SSL_AD_UNKNOWN_CA               TLS1_AD_UNKNOWN_CA\n/* fatal */\n# define SSL_AD_ACCESS_DENIED            TLS1_AD_ACCESS_DENIED\n/* fatal */\n# define SSL_AD_DECODE_ERROR             TLS1_AD_DECODE_ERROR\n# define SSL_AD_DECRYPT_ERROR            TLS1_AD_DECRYPT_ERROR\n/* fatal */\n# define SSL_AD_EXPORT_RESTRICTION       TLS1_AD_EXPORT_RESTRICTION\n/* fatal */\n# define SSL_AD_PROTOCOL_VERSION         TLS1_AD_PROTOCOL_VERSION\n/* fatal */\n# define SSL_AD_INSUFFICIENT_SECURITY    TLS1_AD_INSUFFICIENT_SECURITY\n/* fatal */\n# define SSL_AD_INTERNAL_ERROR           TLS1_AD_INTERNAL_ERROR\n# define SSL_AD_USER_CANCELLED           TLS1_AD_USER_CANCELLED\n# define SSL_AD_NO_RENEGOTIATION         TLS1_AD_NO_RENEGOTIATION\n# define SSL_AD_MISSING_EXTENSION        TLS13_AD_MISSING_EXTENSION\n# define SSL_AD_CERTIFICATE_REQUIRED     TLS13_AD_CERTIFICATE_REQUIRED\n# define SSL_AD_UNSUPPORTED_EXTENSION    TLS1_AD_UNSUPPORTED_EXTENSION\n# define SSL_AD_CERTIFICATE_UNOBTAINABLE TLS1_AD_CERTIFICATE_UNOBTAINABLE\n# define SSL_AD_UNRECOGNIZED_NAME        TLS1_AD_UNRECOGNIZED_NAME\n# define SSL_AD_BAD_CERTIFICATE_STATUS_RESPONSE TLS1_AD_BAD_CERTIFICATE_STATUS_RESPONSE\n# define SSL_AD_BAD_CERTIFICATE_HASH_VALUE TLS1_AD_BAD_CERTIFICATE_HASH_VALUE\n/* fatal */\n# define SSL_AD_UNKNOWN_PSK_IDENTITY     TLS1_AD_UNKNOWN_PSK_IDENTITY\n/* fatal */\n# define SSL_AD_INAPPROPRIATE_FALLBACK   TLS1_AD_INAPPROPRIATE_FALLBACK\n# define SSL_AD_NO_APPLICATION_PROTOCOL  TLS1_AD_NO_APPLICATION_PROTOCOL\n# define SSL_ERROR_NONE                  0\n# define SSL_ERROR_SSL                   1\n# define SSL_ERROR_WANT_READ             2\n# define SSL_ERROR_WANT_WRITE            3\n# define SSL_ERROR_WANT_X509_LOOKUP      4\n# define SSL_ERROR_SYSCALL               5/* look at error stack/return\n                                           * value/errno */\n# define SSL_ERROR_ZERO_RETURN           6\n# define SSL_ERROR_WANT_CONNECT          7\n# define SSL_ERROR_WANT_ACCEPT           8\n# define SSL_ERROR_WANT_ASYNC            9\n# define SSL_ERROR_WANT_ASYNC_JOB       10\n# define SSL_ERROR_WANT_CLIENT_HELLO_CB 11\n# define SSL_CTRL_SET_TMP_DH                     3\n# define SSL_CTRL_SET_TMP_ECDH                   4\n# define SSL_CTRL_SET_TMP_DH_CB                  6\n# define SSL_CTRL_GET_CLIENT_CERT_REQUEST        9\n# define SSL_CTRL_GET_NUM_RENEGOTIATIONS         10\n# define SSL_CTRL_CLEAR_NUM_RENEGOTIATIONS       11\n# define SSL_CTRL_GET_TOTAL_RENEGOTIATIONS       12\n# define SSL_CTRL_GET_FLAGS                      13\n# define SSL_CTRL_EXTRA_CHAIN_CERT               14\n# define SSL_CTRL_SET_MSG_CALLBACK               15\n# define SSL_CTRL_SET_MSG_CALLBACK_ARG           16\n/* only applies to datagram connections */\n# define SSL_CTRL_SET_MTU                17\n/* Stats */\n# define SSL_CTRL_SESS_NUMBER                    20\n# define SSL_CTRL_SESS_CONNECT                   21\n# define SSL_CTRL_SESS_CONNECT_GOOD              22\n# define SSL_CTRL_SESS_CONNECT_RENEGOTIATE       23\n# define SSL_CTRL_SESS_ACCEPT                    24\n# define SSL_CTRL_SESS_ACCEPT_GOOD               25\n# define SSL_CTRL_SESS_ACCEPT_RENEGOTIATE        26\n# define SSL_CTRL_SESS_HIT                       27\n# define SSL_CTRL_SESS_CB_HIT                    28\n# define SSL_CTRL_SESS_MISSES                    29\n# define SSL_CTRL_SESS_TIMEOUTS                  30\n# define SSL_CTRL_SESS_CACHE_FULL                31\n# define SSL_CTRL_MODE                           33\n# define SSL_CTRL_GET_READ_AHEAD                 40\n# define SSL_CTRL_SET_READ_AHEAD                 41\n# define SSL_CTRL_SET_SESS_CACHE_SIZE            42\n# define SSL_CTRL_GET_SESS_CACHE_SIZE            43\n# define SSL_CTRL_SET_SESS_CACHE_MODE            44\n# define SSL_CTRL_GET_SESS_CACHE_MODE            45\n# define SSL_CTRL_GET_MAX_CERT_LIST              50\n# define SSL_CTRL_SET_MAX_CERT_LIST              51\n# define SSL_CTRL_SET_MAX_SEND_FRAGMENT          52\n/* see tls1.h for macros based on these */\n# define SSL_CTRL_SET_TLSEXT_SERVERNAME_CB       53\n# define SSL_CTRL_SET_TLSEXT_SERVERNAME_ARG      54\n# define SSL_CTRL_SET_TLSEXT_HOSTNAME            55\n# define SSL_CTRL_SET_TLSEXT_DEBUG_CB            56\n# define SSL_CTRL_SET_TLSEXT_DEBUG_ARG           57\n# define SSL_CTRL_GET_TLSEXT_TICKET_KEYS         58\n# define SSL_CTRL_SET_TLSEXT_TICKET_KEYS         59\n/*# define SSL_CTRL_SET_TLSEXT_OPAQUE_PRF_INPUT    60 */\n/*# define SSL_CTRL_SET_TLSEXT_OPAQUE_PRF_INPUT_CB 61 */\n/*# define SSL_CTRL_SET_TLSEXT_OPAQUE_PRF_INPUT_CB_ARG 62 */\n# define SSL_CTRL_SET_TLSEXT_STATUS_REQ_CB       63\n# define SSL_CTRL_SET_TLSEXT_STATUS_REQ_CB_ARG   64\n# define SSL_CTRL_SET_TLSEXT_STATUS_REQ_TYPE     65\n# define SSL_CTRL_GET_TLSEXT_STATUS_REQ_EXTS     66\n# define SSL_CTRL_SET_TLSEXT_STATUS_REQ_EXTS     67\n# define SSL_CTRL_GET_TLSEXT_STATUS_REQ_IDS      68\n# define SSL_CTRL_SET_TLSEXT_STATUS_REQ_IDS      69\n# define SSL_CTRL_GET_TLSEXT_STATUS_REQ_OCSP_RESP        70\n# define SSL_CTRL_SET_TLSEXT_STATUS_REQ_OCSP_RESP        71\n# define SSL_CTRL_SET_TLSEXT_TICKET_KEY_CB       72\n# define SSL_CTRL_SET_TLS_EXT_SRP_USERNAME_CB    75\n# define SSL_CTRL_SET_SRP_VERIFY_PARAM_CB                76\n# define SSL_CTRL_SET_SRP_GIVE_CLIENT_PWD_CB             77\n# define SSL_CTRL_SET_SRP_ARG            78\n# define SSL_CTRL_SET_TLS_EXT_SRP_USERNAME               79\n# define SSL_CTRL_SET_TLS_EXT_SRP_STRENGTH               80\n# define SSL_CTRL_SET_TLS_EXT_SRP_PASSWORD               81\n# ifndef OPENSSL_NO_HEARTBEATS\n#  define SSL_CTRL_DTLS_EXT_SEND_HEARTBEAT               85\n#  define SSL_CTRL_GET_DTLS_EXT_HEARTBEAT_PENDING        86\n#  define SSL_CTRL_SET_DTLS_EXT_HEARTBEAT_NO_REQUESTS    87\n# endif\n# define DTLS_CTRL_GET_TIMEOUT           73\n# define DTLS_CTRL_HANDLE_TIMEOUT        74\n# define SSL_CTRL_GET_RI_SUPPORT                 76\n# define SSL_CTRL_CLEAR_MODE                     78\n# define SSL_CTRL_SET_NOT_RESUMABLE_SESS_CB      79\n# define SSL_CTRL_GET_EXTRA_CHAIN_CERTS          82\n# define SSL_CTRL_CLEAR_EXTRA_CHAIN_CERTS        83\n# define SSL_CTRL_CHAIN                          88\n# define SSL_CTRL_CHAIN_CERT                     89\n# define SSL_CTRL_GET_GROUPS                     90\n# define SSL_CTRL_SET_GROUPS                     91\n# define SSL_CTRL_SET_GROUPS_LIST                92\n# define SSL_CTRL_GET_SHARED_GROUP               93\n# define SSL_CTRL_SET_SIGALGS                    97\n# define SSL_CTRL_SET_SIGALGS_LIST               98\n# define SSL_CTRL_CERT_FLAGS                     99\n# define SSL_CTRL_CLEAR_CERT_FLAGS               100\n# define SSL_CTRL_SET_CLIENT_SIGALGS             101\n# define SSL_CTRL_SET_CLIENT_SIGALGS_LIST        102\n# define SSL_CTRL_GET_CLIENT_CERT_TYPES          103\n# define SSL_CTRL_SET_CLIENT_CERT_TYPES          104\n# define SSL_CTRL_BUILD_CERT_CHAIN               105\n# define SSL_CTRL_SET_VERIFY_CERT_STORE          106\n# define SSL_CTRL_SET_CHAIN_CERT_STORE           107\n# define SSL_CTRL_GET_PEER_SIGNATURE_NID         108\n# define SSL_CTRL_GET_PEER_TMP_KEY               109\n# define SSL_CTRL_GET_RAW_CIPHERLIST             110\n# define SSL_CTRL_GET_EC_POINT_FORMATS           111\n# define SSL_CTRL_GET_CHAIN_CERTS                115\n# define SSL_CTRL_SELECT_CURRENT_CERT            116\n# define SSL_CTRL_SET_CURRENT_CERT               117\n# define SSL_CTRL_SET_DH_AUTO                    118\n# define DTLS_CTRL_SET_LINK_MTU                  120\n# define DTLS_CTRL_GET_LINK_MIN_MTU              121\n# define SSL_CTRL_GET_EXTMS_SUPPORT              122\n# define SSL_CTRL_SET_MIN_PROTO_VERSION          123\n# define SSL_CTRL_SET_MAX_PROTO_VERSION          124\n# define SSL_CTRL_SET_SPLIT_SEND_FRAGMENT        125\n# define SSL_CTRL_SET_MAX_PIPELINES              126\n# define SSL_CTRL_GET_TLSEXT_STATUS_REQ_TYPE     127\n# define SSL_CTRL_GET_TLSEXT_STATUS_REQ_CB       128\n# define SSL_CTRL_GET_TLSEXT_STATUS_REQ_CB_ARG   129\n# define SSL_CTRL_GET_MIN_PROTO_VERSION          130\n# define SSL_CTRL_GET_MAX_PROTO_VERSION          131\n# define SSL_CTRL_GET_SIGNATURE_NID              132\n# define SSL_CTRL_GET_TMP_KEY                    133\n# define SSL_CERT_SET_FIRST                      1\n# define SSL_CERT_SET_NEXT                       2\n# define SSL_CERT_SET_SERVER                     3\n# define DTLSv1_get_timeout(ssl, arg) \\\n        SSL_ctrl(ssl,DTLS_CTRL_GET_TIMEOUT,0, (void *)(arg))\n# define DTLSv1_handle_timeout(ssl) \\\n        SSL_ctrl(ssl,DTLS_CTRL_HANDLE_TIMEOUT,0, NULL)\n# define SSL_num_renegotiations(ssl) \\\n        SSL_ctrl((ssl),SSL_CTRL_GET_NUM_RENEGOTIATIONS,0,NULL)\n# define SSL_clear_num_renegotiations(ssl) \\\n        SSL_ctrl((ssl),SSL_CTRL_CLEAR_NUM_RENEGOTIATIONS,0,NULL)\n# define SSL_total_renegotiations(ssl) \\\n        SSL_ctrl((ssl),SSL_CTRL_GET_TOTAL_RENEGOTIATIONS,0,NULL)\n# define SSL_CTX_set_tmp_dh(ctx,dh) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_SET_TMP_DH,0,(char *)(dh))\n# define SSL_CTX_set_tmp_ecdh(ctx,ecdh) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_SET_TMP_ECDH,0,(char *)(ecdh))\n# define SSL_CTX_set_dh_auto(ctx, onoff) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_SET_DH_AUTO,onoff,NULL)\n# define SSL_set_dh_auto(s, onoff) \\\n        SSL_ctrl(s,SSL_CTRL_SET_DH_AUTO,onoff,NULL)\n# define SSL_set_tmp_dh(ssl,dh) \\\n        SSL_ctrl(ssl,SSL_CTRL_SET_TMP_DH,0,(char *)(dh))\n# define SSL_set_tmp_ecdh(ssl,ecdh) \\\n        SSL_ctrl(ssl,SSL_CTRL_SET_TMP_ECDH,0,(char *)(ecdh))\n# define SSL_CTX_add_extra_chain_cert(ctx,x509) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_EXTRA_CHAIN_CERT,0,(char *)(x509))\n# define SSL_CTX_get_extra_chain_certs(ctx,px509) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_GET_EXTRA_CHAIN_CERTS,0,px509)\n# define SSL_CTX_get_extra_chain_certs_only(ctx,px509) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_GET_EXTRA_CHAIN_CERTS,1,px509)\n# define SSL_CTX_clear_extra_chain_certs(ctx) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_CLEAR_EXTRA_CHAIN_CERTS,0,NULL)\n# define SSL_CTX_set0_chain(ctx,sk) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_CHAIN,0,(char *)(sk))\n# define SSL_CTX_set1_chain(ctx,sk) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_CHAIN,1,(char *)(sk))\n# define SSL_CTX_add0_chain_cert(ctx,x509) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_CHAIN_CERT,0,(char *)(x509))\n# define SSL_CTX_add1_chain_cert(ctx,x509) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_CHAIN_CERT,1,(char *)(x509))\n# define SSL_CTX_get0_chain_certs(ctx,px509) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_GET_CHAIN_CERTS,0,px509)\n# define SSL_CTX_clear_chain_certs(ctx) \\\n        SSL_CTX_set0_chain(ctx,NULL)\n# define SSL_CTX_build_cert_chain(ctx, flags) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_BUILD_CERT_CHAIN, flags, NULL)\n# define SSL_CTX_select_current_cert(ctx,x509) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_SELECT_CURRENT_CERT,0,(char *)(x509))\n# define SSL_CTX_set_current_cert(ctx, op) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_SET_CURRENT_CERT, op, NULL)\n# define SSL_CTX_set0_verify_cert_store(ctx,st) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_SET_VERIFY_CERT_STORE,0,(char *)(st))\n# define SSL_CTX_set1_verify_cert_store(ctx,st) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_SET_VERIFY_CERT_STORE,1,(char *)(st))\n# define SSL_CTX_set0_chain_cert_store(ctx,st) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_SET_CHAIN_CERT_STORE,0,(char *)(st))\n# define SSL_CTX_set1_chain_cert_store(ctx,st) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_SET_CHAIN_CERT_STORE,1,(char *)(st))\n# define SSL_set0_chain(s,sk) \\\n        SSL_ctrl(s,SSL_CTRL_CHAIN,0,(char *)(sk))\n# define SSL_set1_chain(s,sk) \\\n        SSL_ctrl(s,SSL_CTRL_CHAIN,1,(char *)(sk))\n# define SSL_add0_chain_cert(s,x509) \\\n        SSL_ctrl(s,SSL_CTRL_CHAIN_CERT,0,(char *)(x509))\n# define SSL_add1_chain_cert(s,x509) \\\n        SSL_ctrl(s,SSL_CTRL_CHAIN_CERT,1,(char *)(x509))\n# define SSL_get0_chain_certs(s,px509) \\\n        SSL_ctrl(s,SSL_CTRL_GET_CHAIN_CERTS,0,px509)\n# define SSL_clear_chain_certs(s) \\\n        SSL_set0_chain(s,NULL)\n# define SSL_build_cert_chain(s, flags) \\\n        SSL_ctrl(s,SSL_CTRL_BUILD_CERT_CHAIN, flags, NULL)\n# define SSL_select_current_cert(s,x509) \\\n        SSL_ctrl(s,SSL_CTRL_SELECT_CURRENT_CERT,0,(char *)(x509))\n# define SSL_set_current_cert(s,op) \\\n        SSL_ctrl(s,SSL_CTRL_SET_CURRENT_CERT, op, NULL)\n# define SSL_set0_verify_cert_store(s,st) \\\n        SSL_ctrl(s,SSL_CTRL_SET_VERIFY_CERT_STORE,0,(char *)(st))\n# define SSL_set1_verify_cert_store(s,st) \\\n        SSL_ctrl(s,SSL_CTRL_SET_VERIFY_CERT_STORE,1,(char *)(st))\n# define SSL_set0_chain_cert_store(s,st) \\\n        SSL_ctrl(s,SSL_CTRL_SET_CHAIN_CERT_STORE,0,(char *)(st))\n# define SSL_set1_chain_cert_store(s,st) \\\n        SSL_ctrl(s,SSL_CTRL_SET_CHAIN_CERT_STORE,1,(char *)(st))\n# define SSL_get1_groups(s, glist) \\\n        SSL_ctrl(s,SSL_CTRL_GET_GROUPS,0,(int*)(glist))\n# define SSL_CTX_set1_groups(ctx, glist, glistlen) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_SET_GROUPS,glistlen,(int *)(glist))\n# define SSL_CTX_set1_groups_list(ctx, s) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_SET_GROUPS_LIST,0,(char *)(s))\n# define SSL_set1_groups(s, glist, glistlen) \\\n        SSL_ctrl(s,SSL_CTRL_SET_GROUPS,glistlen,(char *)(glist))\n# define SSL_set1_groups_list(s, str) \\\n        SSL_ctrl(s,SSL_CTRL_SET_GROUPS_LIST,0,(char *)(str))\n# define SSL_get_shared_group(s, n) \\\n        SSL_ctrl(s,SSL_CTRL_GET_SHARED_GROUP,n,NULL)\n# define SSL_CTX_set1_sigalgs(ctx, slist, slistlen) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_SET_SIGALGS,slistlen,(int *)(slist))\n# define SSL_CTX_set1_sigalgs_list(ctx, s) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_SET_SIGALGS_LIST,0,(char *)(s))\n# define SSL_set1_sigalgs(s, slist, slistlen) \\\n        SSL_ctrl(s,SSL_CTRL_SET_SIGALGS,slistlen,(int *)(slist))\n# define SSL_set1_sigalgs_list(s, str) \\\n        SSL_ctrl(s,SSL_CTRL_SET_SIGALGS_LIST,0,(char *)(str))\n# define SSL_CTX_set1_client_sigalgs(ctx, slist, slistlen) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_SET_CLIENT_SIGALGS,slistlen,(int *)(slist))\n# define SSL_CTX_set1_client_sigalgs_list(ctx, s) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_SET_CLIENT_SIGALGS_LIST,0,(char *)(s))\n# define SSL_set1_client_sigalgs(s, slist, slistlen) \\\n        SSL_ctrl(s,SSL_CTRL_SET_CLIENT_SIGALGS,slistlen,(int *)(slist))\n# define SSL_set1_client_sigalgs_list(s, str) \\\n        SSL_ctrl(s,SSL_CTRL_SET_CLIENT_SIGALGS_LIST,0,(char *)(str))\n# define SSL_get0_certificate_types(s, clist) \\\n        SSL_ctrl(s, SSL_CTRL_GET_CLIENT_CERT_TYPES, 0, (char *)(clist))\n# define SSL_CTX_set1_client_certificate_types(ctx, clist, clistlen) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_SET_CLIENT_CERT_TYPES,clistlen, \\\n                     (char *)(clist))\n# define SSL_set1_client_certificate_types(s, clist, clistlen) \\\n        SSL_ctrl(s,SSL_CTRL_SET_CLIENT_CERT_TYPES,clistlen,(char *)(clist))\n# define SSL_get_signature_nid(s, pn) \\\n        SSL_ctrl(s,SSL_CTRL_GET_SIGNATURE_NID,0,pn)\n# define SSL_get_peer_signature_nid(s, pn) \\\n        SSL_ctrl(s,SSL_CTRL_GET_PEER_SIGNATURE_NID,0,pn)\n# define SSL_get_peer_tmp_key(s, pk) \\\n        SSL_ctrl(s,SSL_CTRL_GET_PEER_TMP_KEY,0,pk)\n# define SSL_get_tmp_key(s, pk) \\\n        SSL_ctrl(s,SSL_CTRL_GET_TMP_KEY,0,pk)\n# define SSL_get0_raw_cipherlist(s, plst) \\\n        SSL_ctrl(s,SSL_CTRL_GET_RAW_CIPHERLIST,0,plst)\n# define SSL_get0_ec_point_formats(s, plst) \\\n        SSL_ctrl(s,SSL_CTRL_GET_EC_POINT_FORMATS,0,plst)\n# define SSL_CTX_set_min_proto_version(ctx, version) \\\n        SSL_CTX_ctrl(ctx, SSL_CTRL_SET_MIN_PROTO_VERSION, version, NULL)\n# define SSL_CTX_set_max_proto_version(ctx, version) \\\n        SSL_CTX_ctrl(ctx, SSL_CTRL_SET_MAX_PROTO_VERSION, version, NULL)\n# define SSL_CTX_get_min_proto_version(ctx) \\\n        SSL_CTX_ctrl(ctx, SSL_CTRL_GET_MIN_PROTO_VERSION, 0, NULL)\n# define SSL_CTX_get_max_proto_version(ctx) \\\n        SSL_CTX_ctrl(ctx, SSL_CTRL_GET_MAX_PROTO_VERSION, 0, NULL)\n# define SSL_set_min_proto_version(s, version) \\\n        SSL_ctrl(s, SSL_CTRL_SET_MIN_PROTO_VERSION, version, NULL)\n# define SSL_set_max_proto_version(s, version) \\\n        SSL_ctrl(s, SSL_CTRL_SET_MAX_PROTO_VERSION, version, NULL)\n# define SSL_get_min_proto_version(s) \\\n        SSL_ctrl(s, SSL_CTRL_GET_MIN_PROTO_VERSION, 0, NULL)\n# define SSL_get_max_proto_version(s) \\\n        SSL_ctrl(s, SSL_CTRL_GET_MAX_PROTO_VERSION, 0, NULL)\n\n/* Backwards compatibility, original 1.1.0 names */\n# define SSL_CTRL_GET_SERVER_TMP_KEY \\\n         SSL_CTRL_GET_PEER_TMP_KEY\n# define SSL_get_server_tmp_key(s, pk) \\\n         SSL_get_peer_tmp_key(s, pk)\n\n/*\n * The following symbol names are old and obsolete. They are kept\n * for compatibility reasons only and should not be used anymore.\n */\n# define SSL_CTRL_GET_CURVES           SSL_CTRL_GET_GROUPS\n# define SSL_CTRL_SET_CURVES           SSL_CTRL_SET_GROUPS\n# define SSL_CTRL_SET_CURVES_LIST      SSL_CTRL_SET_GROUPS_LIST\n# define SSL_CTRL_GET_SHARED_CURVE     SSL_CTRL_GET_SHARED_GROUP\n\n# define SSL_get1_curves               SSL_get1_groups\n# define SSL_CTX_set1_curves           SSL_CTX_set1_groups\n# define SSL_CTX_set1_curves_list      SSL_CTX_set1_groups_list\n# define SSL_set1_curves               SSL_set1_groups\n# define SSL_set1_curves_list          SSL_set1_groups_list\n# define SSL_get_shared_curve          SSL_get_shared_group\n\n\n# if OPENSSL_API_COMPAT < 0x10100000L\n/* Provide some compatibility macros for removed functionality. */\n#  define SSL_CTX_need_tmp_RSA(ctx)                0\n#  define SSL_CTX_set_tmp_rsa(ctx,rsa)             1\n#  define SSL_need_tmp_RSA(ssl)                    0\n#  define SSL_set_tmp_rsa(ssl,rsa)                 1\n#  define SSL_CTX_set_ecdh_auto(dummy, onoff)      ((onoff) != 0)\n#  define SSL_set_ecdh_auto(dummy, onoff)          ((onoff) != 0)\n/*\n * We \"pretend\" to call the callback to avoid warnings about unused static\n * functions.\n */\n#  define SSL_CTX_set_tmp_rsa_callback(ctx, cb)    while(0) (cb)(NULL, 0, 0)\n#  define SSL_set_tmp_rsa_callback(ssl, cb)        while(0) (cb)(NULL, 0, 0)\n# endif\n__owur const BIO_METHOD *BIO_f_ssl(void);\n__owur BIO *BIO_new_ssl(SSL_CTX *ctx, int client);\n__owur BIO *BIO_new_ssl_connect(SSL_CTX *ctx);\n__owur BIO *BIO_new_buffer_ssl_connect(SSL_CTX *ctx);\n__owur int BIO_ssl_copy_session_id(BIO *to, BIO *from);\nvoid BIO_ssl_shutdown(BIO *ssl_bio);\n\n__owur int SSL_CTX_set_cipher_list(SSL_CTX *, const char *str);\n__owur SSL_CTX *SSL_CTX_new(const SSL_METHOD *meth);\nint SSL_CTX_up_ref(SSL_CTX *ctx);\nvoid SSL_CTX_free(SSL_CTX *);\n__owur long SSL_CTX_set_timeout(SSL_CTX *ctx, long t);\n__owur long SSL_CTX_get_timeout(const SSL_CTX *ctx);\n__owur X509_STORE *SSL_CTX_get_cert_store(const SSL_CTX *);\nvoid SSL_CTX_set_cert_store(SSL_CTX *, X509_STORE *);\nvoid SSL_CTX_set1_cert_store(SSL_CTX *, X509_STORE *);\n__owur int SSL_want(const SSL *s);\n__owur int SSL_clear(SSL *s);\n\nvoid SSL_CTX_flush_sessions(SSL_CTX *ctx, long tm);\n\n__owur const SSL_CIPHER *SSL_get_current_cipher(const SSL *s);\n__owur const SSL_CIPHER *SSL_get_pending_cipher(const SSL *s);\n__owur int SSL_CIPHER_get_bits(const SSL_CIPHER *c, int *alg_bits);\n__owur const char *SSL_CIPHER_get_version(const SSL_CIPHER *c);\n__owur const char *SSL_CIPHER_get_name(const SSL_CIPHER *c);\n__owur const char *SSL_CIPHER_standard_name(const SSL_CIPHER *c);\n__owur const char *OPENSSL_cipher_name(const char *rfc_name);\n__owur uint32_t SSL_CIPHER_get_id(const SSL_CIPHER *c);\n__owur uint16_t SSL_CIPHER_get_protocol_id(const SSL_CIPHER *c);\n__owur int SSL_CIPHER_get_kx_nid(const SSL_CIPHER *c);\n__owur int SSL_CIPHER_get_auth_nid(const SSL_CIPHER *c);\n__owur const EVP_MD *SSL_CIPHER_get_handshake_digest(const SSL_CIPHER *c);\n__owur int SSL_CIPHER_is_aead(const SSL_CIPHER *c);\n\n__owur int SSL_get_fd(const SSL *s);\n__owur int SSL_get_rfd(const SSL *s);\n__owur int SSL_get_wfd(const SSL *s);\n__owur const char *SSL_get_cipher_list(const SSL *s, int n);\n__owur char *SSL_get_shared_ciphers(const SSL *s, char *buf, int size);\n__owur int SSL_get_read_ahead(const SSL *s);\n__owur int SSL_pending(const SSL *s);\n__owur int SSL_has_pending(const SSL *s);\n# ifndef OPENSSL_NO_SOCK\n__owur int SSL_set_fd(SSL *s, int fd);\n__owur int SSL_set_rfd(SSL *s, int fd);\n__owur int SSL_set_wfd(SSL *s, int fd);\n# endif\nvoid SSL_set0_rbio(SSL *s, BIO *rbio);\nvoid SSL_set0_wbio(SSL *s, BIO *wbio);\nvoid SSL_set_bio(SSL *s, BIO *rbio, BIO *wbio);\n__owur BIO *SSL_get_rbio(const SSL *s);\n__owur BIO *SSL_get_wbio(const SSL *s);\n__owur int SSL_set_cipher_list(SSL *s, const char *str);\n__owur int SSL_CTX_set_ciphersuites(SSL_CTX *ctx, const char *str);\n__owur int SSL_set_ciphersuites(SSL *s, const char *str);\nvoid SSL_set_read_ahead(SSL *s, int yes);\n__owur int SSL_get_verify_mode(const SSL *s);\n__owur int SSL_get_verify_depth(const SSL *s);\n__owur SSL_verify_cb SSL_get_verify_callback(const SSL *s);\nvoid SSL_set_verify(SSL *s, int mode, SSL_verify_cb callback);\nvoid SSL_set_verify_depth(SSL *s, int depth);\nvoid SSL_set_cert_cb(SSL *s, int (*cb) (SSL *ssl, void *arg), void *arg);\n# ifndef OPENSSL_NO_RSA\n__owur int SSL_use_RSAPrivateKey(SSL *ssl, RSA *rsa);\n__owur int SSL_use_RSAPrivateKey_ASN1(SSL *ssl, const unsigned char *d,\n                                      long len);\n# endif\n__owur int SSL_use_PrivateKey(SSL *ssl, EVP_PKEY *pkey);\n__owur int SSL_use_PrivateKey_ASN1(int pk, SSL *ssl, const unsigned char *d,\n                                   long len);\n__owur int SSL_use_certificate(SSL *ssl, X509 *x);\n__owur int SSL_use_certificate_ASN1(SSL *ssl, const unsigned char *d, int len);\n__owur int SSL_use_cert_and_key(SSL *ssl, X509 *x509, EVP_PKEY *privatekey,\n                                STACK_OF(X509) *chain, int override);\n\n\n/* serverinfo file format versions */\n# define SSL_SERVERINFOV1   1\n# define SSL_SERVERINFOV2   2\n\n/* Set serverinfo data for the current active cert. */\n__owur int SSL_CTX_use_serverinfo(SSL_CTX *ctx, const unsigned char *serverinfo,\n                                  size_t serverinfo_length);\n__owur int SSL_CTX_use_serverinfo_ex(SSL_CTX *ctx, unsigned int version,\n                                     const unsigned char *serverinfo,\n                                     size_t serverinfo_length);\n__owur int SSL_CTX_use_serverinfo_file(SSL_CTX *ctx, const char *file);\n\n#ifndef OPENSSL_NO_RSA\n__owur int SSL_use_RSAPrivateKey_file(SSL *ssl, const char *file, int type);\n#endif\n\n__owur int SSL_use_PrivateKey_file(SSL *ssl, const char *file, int type);\n__owur int SSL_use_certificate_file(SSL *ssl, const char *file, int type);\n\n#ifndef OPENSSL_NO_RSA\n__owur int SSL_CTX_use_RSAPrivateKey_file(SSL_CTX *ctx, const char *file,\n                                          int type);\n#endif\n__owur int SSL_CTX_use_PrivateKey_file(SSL_CTX *ctx, const char *file,\n                                       int type);\n__owur int SSL_CTX_use_certificate_file(SSL_CTX *ctx, const char *file,\n                                        int type);\n/* PEM type */\n__owur int SSL_CTX_use_certificate_chain_file(SSL_CTX *ctx, const char *file);\n__owur int SSL_use_certificate_chain_file(SSL *ssl, const char *file);\n__owur STACK_OF(X509_NAME) *SSL_load_client_CA_file(const char *file);\n__owur int SSL_add_file_cert_subjects_to_stack(STACK_OF(X509_NAME) *stackCAs,\n                                               const char *file);\nint SSL_add_dir_cert_subjects_to_stack(STACK_OF(X509_NAME) *stackCAs,\n                                       const char *dir);\n\n# if OPENSSL_API_COMPAT < 0x10100000L\n#  define SSL_load_error_strings() \\\n    OPENSSL_init_ssl(OPENSSL_INIT_LOAD_SSL_STRINGS \\\n                     | OPENSSL_INIT_LOAD_CRYPTO_STRINGS, NULL)\n# endif\n\n__owur const char *SSL_state_string(const SSL *s);\n__owur const char *SSL_rstate_string(const SSL *s);\n__owur const char *SSL_state_string_long(const SSL *s);\n__owur const char *SSL_rstate_string_long(const SSL *s);\n__owur long SSL_SESSION_get_time(const SSL_SESSION *s);\n__owur long SSL_SESSION_set_time(SSL_SESSION *s, long t);\n__owur long SSL_SESSION_get_timeout(const SSL_SESSION *s);\n__owur long SSL_SESSION_set_timeout(SSL_SESSION *s, long t);\n__owur int SSL_SESSION_get_protocol_version(const SSL_SESSION *s);\n__owur int SSL_SESSION_set_protocol_version(SSL_SESSION *s, int version);\n\n__owur const char *SSL_SESSION_get0_hostname(const SSL_SESSION *s);\n__owur int SSL_SESSION_set1_hostname(SSL_SESSION *s, const char *hostname);\nvoid SSL_SESSION_get0_alpn_selected(const SSL_SESSION *s,\n                                    const unsigned char **alpn,\n                                    size_t *len);\n__owur int SSL_SESSION_set1_alpn_selected(SSL_SESSION *s,\n                                          const unsigned char *alpn,\n                                          size_t len);\n__owur const SSL_CIPHER *SSL_SESSION_get0_cipher(const SSL_SESSION *s);\n__owur int SSL_SESSION_set_cipher(SSL_SESSION *s, const SSL_CIPHER *cipher);\n__owur int SSL_SESSION_has_ticket(const SSL_SESSION *s);\n__owur unsigned long SSL_SESSION_get_ticket_lifetime_hint(const SSL_SESSION *s);\nvoid SSL_SESSION_get0_ticket(const SSL_SESSION *s, const unsigned char **tick,\n                             size_t *len);\n__owur uint32_t SSL_SESSION_get_max_early_data(const SSL_SESSION *s);\n__owur int SSL_SESSION_set_max_early_data(SSL_SESSION *s,\n                                          uint32_t max_early_data);\n__owur int SSL_copy_session_id(SSL *to, const SSL *from);\n__owur X509 *SSL_SESSION_get0_peer(SSL_SESSION *s);\n__owur int SSL_SESSION_set1_id_context(SSL_SESSION *s,\n                                       const unsigned char *sid_ctx,\n                                       unsigned int sid_ctx_len);\n__owur int SSL_SESSION_set1_id(SSL_SESSION *s, const unsigned char *sid,\n                               unsigned int sid_len);\n__owur int SSL_SESSION_is_resumable(const SSL_SESSION *s);\n\n__owur SSL_SESSION *SSL_SESSION_new(void);\n__owur SSL_SESSION *SSL_SESSION_dup(SSL_SESSION *src);\nconst unsigned char *SSL_SESSION_get_id(const SSL_SESSION *s,\n                                        unsigned int *len);\nconst unsigned char *SSL_SESSION_get0_id_context(const SSL_SESSION *s,\n                                                 unsigned int *len);\n__owur unsigned int SSL_SESSION_get_compress_id(const SSL_SESSION *s);\n# ifndef OPENSSL_NO_STDIO\nint SSL_SESSION_print_fp(FILE *fp, const SSL_SESSION *ses);\n# endif\nint SSL_SESSION_print(BIO *fp, const SSL_SESSION *ses);\nint SSL_SESSION_print_keylog(BIO *bp, const SSL_SESSION *x);\nint SSL_SESSION_up_ref(SSL_SESSION *ses);\nvoid SSL_SESSION_free(SSL_SESSION *ses);\n__owur int i2d_SSL_SESSION(SSL_SESSION *in, unsigned char **pp);\n__owur int SSL_set_session(SSL *to, SSL_SESSION *session);\nint SSL_CTX_add_session(SSL_CTX *ctx, SSL_SESSION *session);\nint SSL_CTX_remove_session(SSL_CTX *ctx, SSL_SESSION *session);\n__owur int SSL_CTX_set_generate_session_id(SSL_CTX *ctx, GEN_SESSION_CB cb);\n__owur int SSL_set_generate_session_id(SSL *s, GEN_SESSION_CB cb);\n__owur int SSL_has_matching_session_id(const SSL *s,\n                                       const unsigned char *id,\n                                       unsigned int id_len);\nSSL_SESSION *d2i_SSL_SESSION(SSL_SESSION **a, const unsigned char **pp,\n                             long length);\n\n# ifdef HEADER_X509_H\n__owur X509 *SSL_get_peer_certificate(const SSL *s);\n# endif\n\n__owur STACK_OF(X509) *SSL_get_peer_cert_chain(const SSL *s);\n\n__owur int SSL_CTX_get_verify_mode(const SSL_CTX *ctx);\n__owur int SSL_CTX_get_verify_depth(const SSL_CTX *ctx);\n__owur SSL_verify_cb SSL_CTX_get_verify_callback(const SSL_CTX *ctx);\nvoid SSL_CTX_set_verify(SSL_CTX *ctx, int mode, SSL_verify_cb callback);\nvoid SSL_CTX_set_verify_depth(SSL_CTX *ctx, int depth);\nvoid SSL_CTX_set_cert_verify_callback(SSL_CTX *ctx,\n                                      int (*cb) (X509_STORE_CTX *, void *),\n                                      void *arg);\nvoid SSL_CTX_set_cert_cb(SSL_CTX *c, int (*cb) (SSL *ssl, void *arg),\n                         void *arg);\n# ifndef OPENSSL_NO_RSA\n__owur int SSL_CTX_use_RSAPrivateKey(SSL_CTX *ctx, RSA *rsa);\n__owur int SSL_CTX_use_RSAPrivateKey_ASN1(SSL_CTX *ctx, const unsigned char *d,\n                                          long len);\n# endif\n__owur int SSL_CTX_use_PrivateKey(SSL_CTX *ctx, EVP_PKEY *pkey);\n__owur int SSL_CTX_use_PrivateKey_ASN1(int pk, SSL_CTX *ctx,\n                                       const unsigned char *d, long len);\n__owur int SSL_CTX_use_certificate(SSL_CTX *ctx, X509 *x);\n__owur int SSL_CTX_use_certificate_ASN1(SSL_CTX *ctx, int len,\n                                        const unsigned char *d);\n__owur int SSL_CTX_use_cert_and_key(SSL_CTX *ctx, X509 *x509, EVP_PKEY *privatekey,\n                                    STACK_OF(X509) *chain, int override);\n\nvoid SSL_CTX_set_default_passwd_cb(SSL_CTX *ctx, pem_password_cb *cb);\nvoid SSL_CTX_set_default_passwd_cb_userdata(SSL_CTX *ctx, void *u);\npem_password_cb *SSL_CTX_get_default_passwd_cb(SSL_CTX *ctx);\nvoid *SSL_CTX_get_default_passwd_cb_userdata(SSL_CTX *ctx);\nvoid SSL_set_default_passwd_cb(SSL *s, pem_password_cb *cb);\nvoid SSL_set_default_passwd_cb_userdata(SSL *s, void *u);\npem_password_cb *SSL_get_default_passwd_cb(SSL *s);\nvoid *SSL_get_default_passwd_cb_userdata(SSL *s);\n\n__owur int SSL_CTX_check_private_key(const SSL_CTX *ctx);\n__owur int SSL_check_private_key(const SSL *ctx);\n\n__owur int SSL_CTX_set_session_id_context(SSL_CTX *ctx,\n                                          const unsigned char *sid_ctx,\n                                          unsigned int sid_ctx_len);\n\nSSL *SSL_new(SSL_CTX *ctx);\nint SSL_up_ref(SSL *s);\nint SSL_is_dtls(const SSL *s);\n__owur int SSL_set_session_id_context(SSL *ssl, const unsigned char *sid_ctx,\n                                      unsigned int sid_ctx_len);\n\n__owur int SSL_CTX_set_purpose(SSL_CTX *ctx, int purpose);\n__owur int SSL_set_purpose(SSL *ssl, int purpose);\n__owur int SSL_CTX_set_trust(SSL_CTX *ctx, int trust);\n__owur int SSL_set_trust(SSL *ssl, int trust);\n\n__owur int SSL_set1_host(SSL *s, const char *hostname);\n__owur int SSL_add1_host(SSL *s, const char *hostname);\n__owur const char *SSL_get0_peername(SSL *s);\nvoid SSL_set_hostflags(SSL *s, unsigned int flags);\n\n__owur int SSL_CTX_dane_enable(SSL_CTX *ctx);\n__owur int SSL_CTX_dane_mtype_set(SSL_CTX *ctx, const EVP_MD *md,\n                                  uint8_t mtype, uint8_t ord);\n__owur int SSL_dane_enable(SSL *s, const char *basedomain);\n__owur int SSL_dane_tlsa_add(SSL *s, uint8_t usage, uint8_t selector,\n                             uint8_t mtype, unsigned const char *data, size_t dlen);\n__owur int SSL_get0_dane_authority(SSL *s, X509 **mcert, EVP_PKEY **mspki);\n__owur int SSL_get0_dane_tlsa(SSL *s, uint8_t *usage, uint8_t *selector,\n                              uint8_t *mtype, unsigned const char **data,\n                              size_t *dlen);\n/*\n * Bridge opacity barrier between libcrypt and libssl, also needed to support\n * offline testing in test/danetest.c\n */\nSSL_DANE *SSL_get0_dane(SSL *ssl);\n/*\n * DANE flags\n */\nunsigned long SSL_CTX_dane_set_flags(SSL_CTX *ctx, unsigned long flags);\nunsigned long SSL_CTX_dane_clear_flags(SSL_CTX *ctx, unsigned long flags);\nunsigned long SSL_dane_set_flags(SSL *ssl, unsigned long flags);\nunsigned long SSL_dane_clear_flags(SSL *ssl, unsigned long flags);\n\n__owur int SSL_CTX_set1_param(SSL_CTX *ctx, X509_VERIFY_PARAM *vpm);\n__owur int SSL_set1_param(SSL *ssl, X509_VERIFY_PARAM *vpm);\n\n__owur X509_VERIFY_PARAM *SSL_CTX_get0_param(SSL_CTX *ctx);\n__owur X509_VERIFY_PARAM *SSL_get0_param(SSL *ssl);\n\n# ifndef OPENSSL_NO_SRP\nint SSL_CTX_set_srp_username(SSL_CTX *ctx, char *name);\nint SSL_CTX_set_srp_password(SSL_CTX *ctx, char *password);\nint SSL_CTX_set_srp_strength(SSL_CTX *ctx, int strength);\nint SSL_CTX_set_srp_client_pwd_callback(SSL_CTX *ctx,\n                                        char *(*cb) (SSL *, void *));\nint SSL_CTX_set_srp_verify_param_callback(SSL_CTX *ctx,\n                                          int (*cb) (SSL *, void *));\nint SSL_CTX_set_srp_username_callback(SSL_CTX *ctx,\n                                      int (*cb) (SSL *, int *, void *));\nint SSL_CTX_set_srp_cb_arg(SSL_CTX *ctx, void *arg);\n\nint SSL_set_srp_server_param(SSL *s, const BIGNUM *N, const BIGNUM *g,\n                             BIGNUM *sa, BIGNUM *v, char *info);\nint SSL_set_srp_server_param_pw(SSL *s, const char *user, const char *pass,\n                                const char *grp);\n\n__owur BIGNUM *SSL_get_srp_g(SSL *s);\n__owur BIGNUM *SSL_get_srp_N(SSL *s);\n\n__owur char *SSL_get_srp_username(SSL *s);\n__owur char *SSL_get_srp_userinfo(SSL *s);\n# endif\n\n/*\n * ClientHello callback and helpers.\n */\n\n# define SSL_CLIENT_HELLO_SUCCESS 1\n# define SSL_CLIENT_HELLO_ERROR   0\n# define SSL_CLIENT_HELLO_RETRY   (-1)\n\ntypedef int (*SSL_client_hello_cb_fn) (SSL *s, int *al, void *arg);\nvoid SSL_CTX_set_client_hello_cb(SSL_CTX *c, SSL_client_hello_cb_fn cb,\n                                 void *arg);\nint SSL_client_hello_isv2(SSL *s);\nunsigned int SSL_client_hello_get0_legacy_version(SSL *s);\nsize_t SSL_client_hello_get0_random(SSL *s, const unsigned char **out);\nsize_t SSL_client_hello_get0_session_id(SSL *s, const unsigned char **out);\nsize_t SSL_client_hello_get0_ciphers(SSL *s, const unsigned char **out);\nsize_t SSL_client_hello_get0_compression_methods(SSL *s,\n                                                 const unsigned char **out);\nint SSL_client_hello_get1_extensions_present(SSL *s, int **out, size_t *outlen);\nint SSL_client_hello_get0_ext(SSL *s, unsigned int type,\n                              const unsigned char **out, size_t *outlen);\n\nvoid SSL_certs_clear(SSL *s);\nvoid SSL_free(SSL *ssl);\n# ifdef OSSL_ASYNC_FD\n/*\n * Windows application developer has to include windows.h to use these.\n */\n__owur int SSL_waiting_for_async(SSL *s);\n__owur int SSL_get_all_async_fds(SSL *s, OSSL_ASYNC_FD *fds, size_t *numfds);\n__owur int SSL_get_changed_async_fds(SSL *s, OSSL_ASYNC_FD *addfd,\n                                     size_t *numaddfds, OSSL_ASYNC_FD *delfd,\n                                     size_t *numdelfds);\n# endif\n__owur int SSL_accept(SSL *ssl);\n__owur int SSL_stateless(SSL *s);\n__owur int SSL_connect(SSL *ssl);\n__owur int SSL_read(SSL *ssl, void *buf, int num);\n__owur int SSL_read_ex(SSL *ssl, void *buf, size_t num, size_t *readbytes);\n\n# define SSL_READ_EARLY_DATA_ERROR   0\n# define SSL_READ_EARLY_DATA_SUCCESS 1\n# define SSL_READ_EARLY_DATA_FINISH  2\n\n__owur int SSL_read_early_data(SSL *s, void *buf, size_t num,\n                               size_t *readbytes);\n__owur int SSL_peek(SSL *ssl, void *buf, int num);\n__owur int SSL_peek_ex(SSL *ssl, void *buf, size_t num, size_t *readbytes);\n__owur int SSL_write(SSL *ssl, const void *buf, int num);\n__owur int SSL_write_ex(SSL *s, const void *buf, size_t num, size_t *written);\n__owur int SSL_write_early_data(SSL *s, const void *buf, size_t num,\n                                size_t *written);\nlong SSL_ctrl(SSL *ssl, int cmd, long larg, void *parg);\nlong SSL_callback_ctrl(SSL *, int, void (*)(void));\nlong SSL_CTX_ctrl(SSL_CTX *ctx, int cmd, long larg, void *parg);\nlong SSL_CTX_callback_ctrl(SSL_CTX *, int, void (*)(void));\n\n# define SSL_EARLY_DATA_NOT_SENT    0\n# define SSL_EARLY_DATA_REJECTED    1\n# define SSL_EARLY_DATA_ACCEPTED    2\n\n__owur int SSL_get_early_data_status(const SSL *s);\n\n__owur int SSL_get_error(const SSL *s, int ret_code);\n__owur const char *SSL_get_version(const SSL *s);\n\n/* This sets the 'default' SSL version that SSL_new() will create */\n__owur int SSL_CTX_set_ssl_version(SSL_CTX *ctx, const SSL_METHOD *meth);\n\n# ifndef OPENSSL_NO_SSL3_METHOD\nDEPRECATEDIN_1_1_0(__owur const SSL_METHOD *SSLv3_method(void)) /* SSLv3 */\nDEPRECATEDIN_1_1_0(__owur const SSL_METHOD *SSLv3_server_method(void))\nDEPRECATEDIN_1_1_0(__owur const SSL_METHOD *SSLv3_client_method(void))\n# endif\n\n#define SSLv23_method           TLS_method\n#define SSLv23_server_method    TLS_server_method\n#define SSLv23_client_method    TLS_client_method\n\n/* Negotiate highest available SSL/TLS version */\n__owur const SSL_METHOD *TLS_method(void);\n__owur const SSL_METHOD *TLS_server_method(void);\n__owur const SSL_METHOD *TLS_client_method(void);\n\n# ifndef OPENSSL_NO_TLS1_METHOD\nDEPRECATEDIN_1_1_0(__owur const SSL_METHOD *TLSv1_method(void)) /* TLSv1.0 */\nDEPRECATEDIN_1_1_0(__owur const SSL_METHOD *TLSv1_server_method(void))\nDEPRECATEDIN_1_1_0(__owur const SSL_METHOD *TLSv1_client_method(void))\n# endif\n\n# ifndef OPENSSL_NO_TLS1_1_METHOD\nDEPRECATEDIN_1_1_0(__owur const SSL_METHOD *TLSv1_1_method(void)) /* TLSv1.1 */\nDEPRECATEDIN_1_1_0(__owur const SSL_METHOD *TLSv1_1_server_method(void))\nDEPRECATEDIN_1_1_0(__owur const SSL_METHOD *TLSv1_1_client_method(void))\n# endif\n\n# ifndef OPENSSL_NO_TLS1_2_METHOD\nDEPRECATEDIN_1_1_0(__owur const SSL_METHOD *TLSv1_2_method(void)) /* TLSv1.2 */\nDEPRECATEDIN_1_1_0(__owur const SSL_METHOD *TLSv1_2_server_method(void))\nDEPRECATEDIN_1_1_0(__owur const SSL_METHOD *TLSv1_2_client_method(void))\n# endif\n\n# ifndef OPENSSL_NO_DTLS1_METHOD\nDEPRECATEDIN_1_1_0(__owur const SSL_METHOD *DTLSv1_method(void)) /* DTLSv1.0 */\nDEPRECATEDIN_1_1_0(__owur const SSL_METHOD *DTLSv1_server_method(void))\nDEPRECATEDIN_1_1_0(__owur const SSL_METHOD *DTLSv1_client_method(void))\n# endif\n\n# ifndef OPENSSL_NO_DTLS1_2_METHOD\n/* DTLSv1.2 */\nDEPRECATEDIN_1_1_0(__owur const SSL_METHOD *DTLSv1_2_method(void))\nDEPRECATEDIN_1_1_0(__owur const SSL_METHOD *DTLSv1_2_server_method(void))\nDEPRECATEDIN_1_1_0(__owur const SSL_METHOD *DTLSv1_2_client_method(void))\n# endif\n\n__owur const SSL_METHOD *DTLS_method(void); /* DTLS 1.0 and 1.2 */\n__owur const SSL_METHOD *DTLS_server_method(void); /* DTLS 1.0 and 1.2 */\n__owur const SSL_METHOD *DTLS_client_method(void); /* DTLS 1.0 and 1.2 */\n\n__owur size_t DTLS_get_data_mtu(const SSL *s);\n\n__owur STACK_OF(SSL_CIPHER) *SSL_get_ciphers(const SSL *s);\n__owur STACK_OF(SSL_CIPHER) *SSL_CTX_get_ciphers(const SSL_CTX *ctx);\n__owur STACK_OF(SSL_CIPHER) *SSL_get_client_ciphers(const SSL *s);\n__owur STACK_OF(SSL_CIPHER) *SSL_get1_supported_ciphers(SSL *s);\n\n__owur int SSL_do_handshake(SSL *s);\nint SSL_key_update(SSL *s, int updatetype);\nint SSL_get_key_update_type(const SSL *s);\nint SSL_renegotiate(SSL *s);\nint SSL_renegotiate_abbreviated(SSL *s);\n__owur int SSL_renegotiate_pending(const SSL *s);\nint SSL_shutdown(SSL *s);\n__owur int SSL_verify_client_post_handshake(SSL *s);\nvoid SSL_CTX_set_post_handshake_auth(SSL_CTX *ctx, int val);\nvoid SSL_set_post_handshake_auth(SSL *s, int val);\n\n__owur const SSL_METHOD *SSL_CTX_get_ssl_method(const SSL_CTX *ctx);\n__owur const SSL_METHOD *SSL_get_ssl_method(const SSL *s);\n__owur int SSL_set_ssl_method(SSL *s, const SSL_METHOD *method);\n__owur const char *SSL_alert_type_string_long(int value);\n__owur const char *SSL_alert_type_string(int value);\n__owur const char *SSL_alert_desc_string_long(int value);\n__owur const char *SSL_alert_desc_string(int value);\n\nvoid SSL_set0_CA_list(SSL *s, STACK_OF(X509_NAME) *name_list);\nvoid SSL_CTX_set0_CA_list(SSL_CTX *ctx, STACK_OF(X509_NAME) *name_list);\n__owur const STACK_OF(X509_NAME) *SSL_get0_CA_list(const SSL *s);\n__owur const STACK_OF(X509_NAME) *SSL_CTX_get0_CA_list(const SSL_CTX *ctx);\n__owur int SSL_add1_to_CA_list(SSL *ssl, const X509 *x);\n__owur int SSL_CTX_add1_to_CA_list(SSL_CTX *ctx, const X509 *x);\n__owur const STACK_OF(X509_NAME) *SSL_get0_peer_CA_list(const SSL *s);\n\nvoid SSL_set_client_CA_list(SSL *s, STACK_OF(X509_NAME) *name_list);\nvoid SSL_CTX_set_client_CA_list(SSL_CTX *ctx, STACK_OF(X509_NAME) *name_list);\n__owur STACK_OF(X509_NAME) *SSL_get_client_CA_list(const SSL *s);\n__owur STACK_OF(X509_NAME) *SSL_CTX_get_client_CA_list(const SSL_CTX *s);\n__owur int SSL_add_client_CA(SSL *ssl, X509 *x);\n__owur int SSL_CTX_add_client_CA(SSL_CTX *ctx, X509 *x);\n\nvoid SSL_set_connect_state(SSL *s);\nvoid SSL_set_accept_state(SSL *s);\n\n__owur long SSL_get_default_timeout(const SSL *s);\n\n# if OPENSSL_API_COMPAT < 0x10100000L\n#  define SSL_library_init() OPENSSL_init_ssl(0, NULL)\n# endif\n\n__owur char *SSL_CIPHER_description(const SSL_CIPHER *, char *buf, int size);\n__owur STACK_OF(X509_NAME) *SSL_dup_CA_list(const STACK_OF(X509_NAME) *sk);\n\n__owur SSL *SSL_dup(SSL *ssl);\n\n__owur X509 *SSL_get_certificate(const SSL *ssl);\n/*\n * EVP_PKEY\n */\nstruct evp_pkey_st *SSL_get_privatekey(const SSL *ssl);\n\n__owur X509 *SSL_CTX_get0_certificate(const SSL_CTX *ctx);\n__owur EVP_PKEY *SSL_CTX_get0_privatekey(const SSL_CTX *ctx);\n\nvoid SSL_CTX_set_quiet_shutdown(SSL_CTX *ctx, int mode);\n__owur int SSL_CTX_get_quiet_shutdown(const SSL_CTX *ctx);\nvoid SSL_set_quiet_shutdown(SSL *ssl, int mode);\n__owur int SSL_get_quiet_shutdown(const SSL *ssl);\nvoid SSL_set_shutdown(SSL *ssl, int mode);\n__owur int SSL_get_shutdown(const SSL *ssl);\n__owur int SSL_version(const SSL *ssl);\n__owur int SSL_client_version(const SSL *s);\n__owur int SSL_CTX_set_default_verify_paths(SSL_CTX *ctx);\n__owur int SSL_CTX_set_default_verify_dir(SSL_CTX *ctx);\n__owur int SSL_CTX_set_default_verify_file(SSL_CTX *ctx);\n__owur int SSL_CTX_load_verify_locations(SSL_CTX *ctx, const char *CAfile,\n                                         const char *CApath);\n# define SSL_get0_session SSL_get_session/* just peek at pointer */\n__owur SSL_SESSION *SSL_get_session(const SSL *ssl);\n__owur SSL_SESSION *SSL_get1_session(SSL *ssl); /* obtain a reference count */\n__owur SSL_CTX *SSL_get_SSL_CTX(const SSL *ssl);\nSSL_CTX *SSL_set_SSL_CTX(SSL *ssl, SSL_CTX *ctx);\nvoid SSL_set_info_callback(SSL *ssl,\n                           void (*cb) (const SSL *ssl, int type, int val));\nvoid (*SSL_get_info_callback(const SSL *ssl)) (const SSL *ssl, int type,\n                                               int val);\n__owur OSSL_HANDSHAKE_STATE SSL_get_state(const SSL *ssl);\n\nvoid SSL_set_verify_result(SSL *ssl, long v);\n__owur long SSL_get_verify_result(const SSL *ssl);\n__owur STACK_OF(X509) *SSL_get0_verified_chain(const SSL *s);\n\n__owur size_t SSL_get_client_random(const SSL *ssl, unsigned char *out,\n                                    size_t outlen);\n__owur size_t SSL_get_server_random(const SSL *ssl, unsigned char *out,\n                                    size_t outlen);\n__owur size_t SSL_SESSION_get_master_key(const SSL_SESSION *sess,\n                                         unsigned char *out, size_t outlen);\n__owur int SSL_SESSION_set1_master_key(SSL_SESSION *sess,\n                                       const unsigned char *in, size_t len);\nuint8_t SSL_SESSION_get_max_fragment_length(const SSL_SESSION *sess);\n\n#define SSL_get_ex_new_index(l, p, newf, dupf, freef) \\\n    CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_SSL, l, p, newf, dupf, freef)\n__owur int SSL_set_ex_data(SSL *ssl, int idx, void *data);\nvoid *SSL_get_ex_data(const SSL *ssl, int idx);\n#define SSL_SESSION_get_ex_new_index(l, p, newf, dupf, freef) \\\n    CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_SSL_SESSION, l, p, newf, dupf, freef)\n__owur int SSL_SESSION_set_ex_data(SSL_SESSION *ss, int idx, void *data);\nvoid *SSL_SESSION_get_ex_data(const SSL_SESSION *ss, int idx);\n#define SSL_CTX_get_ex_new_index(l, p, newf, dupf, freef) \\\n    CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_SSL_CTX, l, p, newf, dupf, freef)\n__owur int SSL_CTX_set_ex_data(SSL_CTX *ssl, int idx, void *data);\nvoid *SSL_CTX_get_ex_data(const SSL_CTX *ssl, int idx);\n\n__owur int SSL_get_ex_data_X509_STORE_CTX_idx(void);\n\n# define SSL_CTX_sess_set_cache_size(ctx,t) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_SET_SESS_CACHE_SIZE,t,NULL)\n# define SSL_CTX_sess_get_cache_size(ctx) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_GET_SESS_CACHE_SIZE,0,NULL)\n# define SSL_CTX_set_session_cache_mode(ctx,m) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_SET_SESS_CACHE_MODE,m,NULL)\n# define SSL_CTX_get_session_cache_mode(ctx) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_GET_SESS_CACHE_MODE,0,NULL)\n\n# define SSL_CTX_get_default_read_ahead(ctx) SSL_CTX_get_read_ahead(ctx)\n# define SSL_CTX_set_default_read_ahead(ctx,m) SSL_CTX_set_read_ahead(ctx,m)\n# define SSL_CTX_get_read_ahead(ctx) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_GET_READ_AHEAD,0,NULL)\n# define SSL_CTX_set_read_ahead(ctx,m) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_SET_READ_AHEAD,m,NULL)\n# define SSL_CTX_get_max_cert_list(ctx) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_GET_MAX_CERT_LIST,0,NULL)\n# define SSL_CTX_set_max_cert_list(ctx,m) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_SET_MAX_CERT_LIST,m,NULL)\n# define SSL_get_max_cert_list(ssl) \\\n        SSL_ctrl(ssl,SSL_CTRL_GET_MAX_CERT_LIST,0,NULL)\n# define SSL_set_max_cert_list(ssl,m) \\\n        SSL_ctrl(ssl,SSL_CTRL_SET_MAX_CERT_LIST,m,NULL)\n\n# define SSL_CTX_set_max_send_fragment(ctx,m) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_SET_MAX_SEND_FRAGMENT,m,NULL)\n# define SSL_set_max_send_fragment(ssl,m) \\\n        SSL_ctrl(ssl,SSL_CTRL_SET_MAX_SEND_FRAGMENT,m,NULL)\n# define SSL_CTX_set_split_send_fragment(ctx,m) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_SET_SPLIT_SEND_FRAGMENT,m,NULL)\n# define SSL_set_split_send_fragment(ssl,m) \\\n        SSL_ctrl(ssl,SSL_CTRL_SET_SPLIT_SEND_FRAGMENT,m,NULL)\n# define SSL_CTX_set_max_pipelines(ctx,m) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_SET_MAX_PIPELINES,m,NULL)\n# define SSL_set_max_pipelines(ssl,m) \\\n        SSL_ctrl(ssl,SSL_CTRL_SET_MAX_PIPELINES,m,NULL)\n\nvoid SSL_CTX_set_default_read_buffer_len(SSL_CTX *ctx, size_t len);\nvoid SSL_set_default_read_buffer_len(SSL *s, size_t len);\n\n# ifndef OPENSSL_NO_DH\n/* NB: the |keylength| is only applicable when is_export is true */\nvoid SSL_CTX_set_tmp_dh_callback(SSL_CTX *ctx,\n                                 DH *(*dh) (SSL *ssl, int is_export,\n                                            int keylength));\nvoid SSL_set_tmp_dh_callback(SSL *ssl,\n                             DH *(*dh) (SSL *ssl, int is_export,\n                                        int keylength));\n# endif\n\n__owur const COMP_METHOD *SSL_get_current_compression(const SSL *s);\n__owur const COMP_METHOD *SSL_get_current_expansion(const SSL *s);\n__owur const char *SSL_COMP_get_name(const COMP_METHOD *comp);\n__owur const char *SSL_COMP_get0_name(const SSL_COMP *comp);\n__owur int SSL_COMP_get_id(const SSL_COMP *comp);\nSTACK_OF(SSL_COMP) *SSL_COMP_get_compression_methods(void);\n__owur STACK_OF(SSL_COMP) *SSL_COMP_set0_compression_methods(STACK_OF(SSL_COMP)\n                                                             *meths);\n# if OPENSSL_API_COMPAT < 0x10100000L\n#  define SSL_COMP_free_compression_methods() while(0) continue\n# endif\n__owur int SSL_COMP_add_compression_method(int id, COMP_METHOD *cm);\n\nconst SSL_CIPHER *SSL_CIPHER_find(SSL *ssl, const unsigned char *ptr);\nint SSL_CIPHER_get_cipher_nid(const SSL_CIPHER *c);\nint SSL_CIPHER_get_digest_nid(const SSL_CIPHER *c);\nint SSL_bytes_to_cipher_list(SSL *s, const unsigned char *bytes, size_t len,\n                             int isv2format, STACK_OF(SSL_CIPHER) **sk,\n                             STACK_OF(SSL_CIPHER) **scsvs);\n\n/* TLS extensions functions */\n__owur int SSL_set_session_ticket_ext(SSL *s, void *ext_data, int ext_len);\n\n__owur int SSL_set_session_ticket_ext_cb(SSL *s,\n                                         tls_session_ticket_ext_cb_fn cb,\n                                         void *arg);\n\n/* Pre-shared secret session resumption functions */\n__owur int SSL_set_session_secret_cb(SSL *s,\n                                     tls_session_secret_cb_fn session_secret_cb,\n                                     void *arg);\n\nvoid SSL_CTX_set_not_resumable_session_callback(SSL_CTX *ctx,\n                                                int (*cb) (SSL *ssl,\n                                                           int\n                                                           is_forward_secure));\n\nvoid SSL_set_not_resumable_session_callback(SSL *ssl,\n                                            int (*cb) (SSL *ssl,\n                                                       int is_forward_secure));\n\nvoid SSL_CTX_set_record_padding_callback(SSL_CTX *ctx,\n                                         size_t (*cb) (SSL *ssl, int type,\n                                                       size_t len, void *arg));\nvoid SSL_CTX_set_record_padding_callback_arg(SSL_CTX *ctx, void *arg);\nvoid *SSL_CTX_get_record_padding_callback_arg(const SSL_CTX *ctx);\nint SSL_CTX_set_block_padding(SSL_CTX *ctx, size_t block_size);\n\nvoid SSL_set_record_padding_callback(SSL *ssl,\n                                    size_t (*cb) (SSL *ssl, int type,\n                                                  size_t len, void *arg));\nvoid SSL_set_record_padding_callback_arg(SSL *ssl, void *arg);\nvoid *SSL_get_record_padding_callback_arg(const SSL *ssl);\nint SSL_set_block_padding(SSL *ssl, size_t block_size);\n\nint SSL_set_num_tickets(SSL *s, size_t num_tickets);\nsize_t SSL_get_num_tickets(const SSL *s);\nint SSL_CTX_set_num_tickets(SSL_CTX *ctx, size_t num_tickets);\nsize_t SSL_CTX_get_num_tickets(const SSL_CTX *ctx);\n\n# if OPENSSL_API_COMPAT < 0x10100000L\n#  define SSL_cache_hit(s) SSL_session_reused(s)\n# endif\n\n__owur int SSL_session_reused(const SSL *s);\n__owur int SSL_is_server(const SSL *s);\n\n__owur __owur SSL_CONF_CTX *SSL_CONF_CTX_new(void);\nint SSL_CONF_CTX_finish(SSL_CONF_CTX *cctx);\nvoid SSL_CONF_CTX_free(SSL_CONF_CTX *cctx);\nunsigned int SSL_CONF_CTX_set_flags(SSL_CONF_CTX *cctx, unsigned int flags);\n__owur unsigned int SSL_CONF_CTX_clear_flags(SSL_CONF_CTX *cctx,\n                                             unsigned int flags);\n__owur int SSL_CONF_CTX_set1_prefix(SSL_CONF_CTX *cctx, const char *pre);\n\nvoid SSL_CONF_CTX_set_ssl(SSL_CONF_CTX *cctx, SSL *ssl);\nvoid SSL_CONF_CTX_set_ssl_ctx(SSL_CONF_CTX *cctx, SSL_CTX *ctx);\n\n__owur int SSL_CONF_cmd(SSL_CONF_CTX *cctx, const char *cmd, const char *value);\n__owur int SSL_CONF_cmd_argv(SSL_CONF_CTX *cctx, int *pargc, char ***pargv);\n__owur int SSL_CONF_cmd_value_type(SSL_CONF_CTX *cctx, const char *cmd);\n\nvoid SSL_add_ssl_module(void);\nint SSL_config(SSL *s, const char *name);\nint SSL_CTX_config(SSL_CTX *ctx, const char *name);\n\n# ifndef OPENSSL_NO_SSL_TRACE\nvoid SSL_trace(int write_p, int version, int content_type,\n               const void *buf, size_t len, SSL *ssl, void *arg);\n# endif\n\n# ifndef OPENSSL_NO_SOCK\nint DTLSv1_listen(SSL *s, BIO_ADDR *client);\n# endif\n\n# ifndef OPENSSL_NO_CT\n\n/*\n * A callback for verifying that the received SCTs are sufficient.\n * Expected to return 1 if they are sufficient, otherwise 0.\n * May return a negative integer if an error occurs.\n * A connection should be aborted if the SCTs are deemed insufficient.\n */\ntypedef int (*ssl_ct_validation_cb)(const CT_POLICY_EVAL_CTX *ctx,\n                                    const STACK_OF(SCT) *scts, void *arg);\n\n/*\n * Sets a |callback| that is invoked upon receipt of ServerHelloDone to validate\n * the received SCTs.\n * If the callback returns a non-positive result, the connection is terminated.\n * Call this function before beginning a handshake.\n * If a NULL |callback| is provided, SCT validation is disabled.\n * |arg| is arbitrary userdata that will be passed to the callback whenever it\n * is invoked. Ownership of |arg| remains with the caller.\n *\n * NOTE: A side-effect of setting a CT callback is that an OCSP stapled response\n *       will be requested.\n */\nint SSL_set_ct_validation_callback(SSL *s, ssl_ct_validation_cb callback,\n                                   void *arg);\nint SSL_CTX_set_ct_validation_callback(SSL_CTX *ctx,\n                                       ssl_ct_validation_cb callback,\n                                       void *arg);\n#define SSL_disable_ct(s) \\\n        ((void) SSL_set_validation_callback((s), NULL, NULL))\n#define SSL_CTX_disable_ct(ctx) \\\n        ((void) SSL_CTX_set_validation_callback((ctx), NULL, NULL))\n\n/*\n * The validation type enumerates the available behaviours of the built-in SSL\n * CT validation callback selected via SSL_enable_ct() and SSL_CTX_enable_ct().\n * The underlying callback is a static function in libssl.\n */\nenum {\n    SSL_CT_VALIDATION_PERMISSIVE = 0,\n    SSL_CT_VALIDATION_STRICT\n};\n\n/*\n * Enable CT by setting up a callback that implements one of the built-in\n * validation variants.  The SSL_CT_VALIDATION_PERMISSIVE variant always\n * continues the handshake, the application can make appropriate decisions at\n * handshake completion.  The SSL_CT_VALIDATION_STRICT variant requires at\n * least one valid SCT, or else handshake termination will be requested.  The\n * handshake may continue anyway if SSL_VERIFY_NONE is in effect.\n */\nint SSL_enable_ct(SSL *s, int validation_mode);\nint SSL_CTX_enable_ct(SSL_CTX *ctx, int validation_mode);\n\n/*\n * Report whether a non-NULL callback is enabled.\n */\nint SSL_ct_is_enabled(const SSL *s);\nint SSL_CTX_ct_is_enabled(const SSL_CTX *ctx);\n\n/* Gets the SCTs received from a connection */\nconst STACK_OF(SCT) *SSL_get0_peer_scts(SSL *s);\n\n/*\n * Loads the CT log list from the default location.\n * If a CTLOG_STORE has previously been set using SSL_CTX_set_ctlog_store,\n * the log information loaded from this file will be appended to the\n * CTLOG_STORE.\n * Returns 1 on success, 0 otherwise.\n */\nint SSL_CTX_set_default_ctlog_list_file(SSL_CTX *ctx);\n\n/*\n * Loads the CT log list from the specified file path.\n * If a CTLOG_STORE has previously been set using SSL_CTX_set_ctlog_store,\n * the log information loaded from this file will be appended to the\n * CTLOG_STORE.\n * Returns 1 on success, 0 otherwise.\n */\nint SSL_CTX_set_ctlog_list_file(SSL_CTX *ctx, const char *path);\n\n/*\n * Sets the CT log list used by all SSL connections created from this SSL_CTX.\n * Ownership of the CTLOG_STORE is transferred to the SSL_CTX.\n */\nvoid SSL_CTX_set0_ctlog_store(SSL_CTX *ctx, CTLOG_STORE *logs);\n\n/*\n * Gets the CT log list used by all SSL connections created from this SSL_CTX.\n * This will be NULL unless one of the following functions has been called:\n * - SSL_CTX_set_default_ctlog_list_file\n * - SSL_CTX_set_ctlog_list_file\n * - SSL_CTX_set_ctlog_store\n */\nconst CTLOG_STORE *SSL_CTX_get0_ctlog_store(const SSL_CTX *ctx);\n\n# endif /* OPENSSL_NO_CT */\n\n/* What the \"other\" parameter contains in security callback */\n/* Mask for type */\n# define SSL_SECOP_OTHER_TYPE    0xffff0000\n# define SSL_SECOP_OTHER_NONE    0\n# define SSL_SECOP_OTHER_CIPHER  (1 << 16)\n# define SSL_SECOP_OTHER_CURVE   (2 << 16)\n# define SSL_SECOP_OTHER_DH      (3 << 16)\n# define SSL_SECOP_OTHER_PKEY    (4 << 16)\n# define SSL_SECOP_OTHER_SIGALG  (5 << 16)\n# define SSL_SECOP_OTHER_CERT    (6 << 16)\n\n/* Indicated operation refers to peer key or certificate */\n# define SSL_SECOP_PEER          0x1000\n\n/* Values for \"op\" parameter in security callback */\n\n/* Called to filter ciphers */\n/* Ciphers client supports */\n# define SSL_SECOP_CIPHER_SUPPORTED      (1 | SSL_SECOP_OTHER_CIPHER)\n/* Cipher shared by client/server */\n# define SSL_SECOP_CIPHER_SHARED         (2 | SSL_SECOP_OTHER_CIPHER)\n/* Sanity check of cipher server selects */\n# define SSL_SECOP_CIPHER_CHECK          (3 | SSL_SECOP_OTHER_CIPHER)\n/* Curves supported by client */\n# define SSL_SECOP_CURVE_SUPPORTED       (4 | SSL_SECOP_OTHER_CURVE)\n/* Curves shared by client/server */\n# define SSL_SECOP_CURVE_SHARED          (5 | SSL_SECOP_OTHER_CURVE)\n/* Sanity check of curve server selects */\n# define SSL_SECOP_CURVE_CHECK           (6 | SSL_SECOP_OTHER_CURVE)\n/* Temporary DH key */\n# define SSL_SECOP_TMP_DH                (7 | SSL_SECOP_OTHER_PKEY)\n/* SSL/TLS version */\n# define SSL_SECOP_VERSION               (9 | SSL_SECOP_OTHER_NONE)\n/* Session tickets */\n# define SSL_SECOP_TICKET                (10 | SSL_SECOP_OTHER_NONE)\n/* Supported signature algorithms sent to peer */\n# define SSL_SECOP_SIGALG_SUPPORTED      (11 | SSL_SECOP_OTHER_SIGALG)\n/* Shared signature algorithm */\n# define SSL_SECOP_SIGALG_SHARED         (12 | SSL_SECOP_OTHER_SIGALG)\n/* Sanity check signature algorithm allowed */\n# define SSL_SECOP_SIGALG_CHECK          (13 | SSL_SECOP_OTHER_SIGALG)\n/* Used to get mask of supported public key signature algorithms */\n# define SSL_SECOP_SIGALG_MASK           (14 | SSL_SECOP_OTHER_SIGALG)\n/* Use to see if compression is allowed */\n# define SSL_SECOP_COMPRESSION           (15 | SSL_SECOP_OTHER_NONE)\n/* EE key in certificate */\n# define SSL_SECOP_EE_KEY                (16 | SSL_SECOP_OTHER_CERT)\n/* CA key in certificate */\n# define SSL_SECOP_CA_KEY                (17 | SSL_SECOP_OTHER_CERT)\n/* CA digest algorithm in certificate */\n# define SSL_SECOP_CA_MD                 (18 | SSL_SECOP_OTHER_CERT)\n/* Peer EE key in certificate */\n# define SSL_SECOP_PEER_EE_KEY           (SSL_SECOP_EE_KEY | SSL_SECOP_PEER)\n/* Peer CA key in certificate */\n# define SSL_SECOP_PEER_CA_KEY           (SSL_SECOP_CA_KEY | SSL_SECOP_PEER)\n/* Peer CA digest algorithm in certificate */\n# define SSL_SECOP_PEER_CA_MD            (SSL_SECOP_CA_MD | SSL_SECOP_PEER)\n\nvoid SSL_set_security_level(SSL *s, int level);\n__owur int SSL_get_security_level(const SSL *s);\nvoid SSL_set_security_callback(SSL *s,\n                               int (*cb) (const SSL *s, const SSL_CTX *ctx,\n                                          int op, int bits, int nid,\n                                          void *other, void *ex));\nint (*SSL_get_security_callback(const SSL *s)) (const SSL *s,\n                                                const SSL_CTX *ctx, int op,\n                                                int bits, int nid, void *other,\n                                                void *ex);\nvoid SSL_set0_security_ex_data(SSL *s, void *ex);\n__owur void *SSL_get0_security_ex_data(const SSL *s);\n\nvoid SSL_CTX_set_security_level(SSL_CTX *ctx, int level);\n__owur int SSL_CTX_get_security_level(const SSL_CTX *ctx);\nvoid SSL_CTX_set_security_callback(SSL_CTX *ctx,\n                                   int (*cb) (const SSL *s, const SSL_CTX *ctx,\n                                              int op, int bits, int nid,\n                                              void *other, void *ex));\nint (*SSL_CTX_get_security_callback(const SSL_CTX *ctx)) (const SSL *s,\n                                                          const SSL_CTX *ctx,\n                                                          int op, int bits,\n                                                          int nid,\n                                                          void *other,\n                                                          void *ex);\nvoid SSL_CTX_set0_security_ex_data(SSL_CTX *ctx, void *ex);\n__owur void *SSL_CTX_get0_security_ex_data(const SSL_CTX *ctx);\n\n/* OPENSSL_INIT flag 0x010000 reserved for internal use */\n# define OPENSSL_INIT_NO_LOAD_SSL_STRINGS    0x00100000L\n# define OPENSSL_INIT_LOAD_SSL_STRINGS       0x00200000L\n\n# define OPENSSL_INIT_SSL_DEFAULT \\\n        (OPENSSL_INIT_LOAD_SSL_STRINGS | OPENSSL_INIT_LOAD_CRYPTO_STRINGS)\n\nint OPENSSL_init_ssl(uint64_t opts, const OPENSSL_INIT_SETTINGS *settings);\n\n# ifndef OPENSSL_NO_UNIT_TEST\n__owur const struct openssl_ssl_test_functions *SSL_test_functions(void);\n# endif\n\n__owur int SSL_free_buffers(SSL *ssl);\n__owur int SSL_alloc_buffers(SSL *ssl);\n\n/* Status codes passed to the decrypt session ticket callback. Some of these\n * are for internal use only and are never passed to the callback. */\ntypedef int SSL_TICKET_STATUS;\n\n/* Support for ticket appdata */\n/* fatal error, malloc failure */\n# define SSL_TICKET_FATAL_ERR_MALLOC 0\n/* fatal error, either from parsing or decrypting the ticket */\n# define SSL_TICKET_FATAL_ERR_OTHER  1\n/* No ticket present */\n# define SSL_TICKET_NONE             2\n/* Empty ticket present */\n# define SSL_TICKET_EMPTY            3\n/* the ticket couldn't be decrypted */\n# define SSL_TICKET_NO_DECRYPT       4\n/* a ticket was successfully decrypted */\n# define SSL_TICKET_SUCCESS          5\n/* same as above but the ticket needs to be renewed */\n# define SSL_TICKET_SUCCESS_RENEW    6\n\n/* Return codes for the decrypt session ticket callback */\ntypedef int SSL_TICKET_RETURN;\n\n/* An error occurred */\n#define SSL_TICKET_RETURN_ABORT             0\n/* Do not use the ticket, do not send a renewed ticket to the client */\n#define SSL_TICKET_RETURN_IGNORE            1\n/* Do not use the ticket, send a renewed ticket to the client */\n#define SSL_TICKET_RETURN_IGNORE_RENEW      2\n/* Use the ticket, do not send a renewed ticket to the client */\n#define SSL_TICKET_RETURN_USE               3\n/* Use the ticket, send a renewed ticket to the client */\n#define SSL_TICKET_RETURN_USE_RENEW         4\n\ntypedef int (*SSL_CTX_generate_session_ticket_fn)(SSL *s, void *arg);\ntypedef SSL_TICKET_RETURN (*SSL_CTX_decrypt_session_ticket_fn)(SSL *s, SSL_SESSION *ss,\n                                                               const unsigned char *keyname,\n                                                               size_t keyname_length,\n                                                               SSL_TICKET_STATUS status,\n                                                               void *arg);\nint SSL_CTX_set_session_ticket_cb(SSL_CTX *ctx,\n                                  SSL_CTX_generate_session_ticket_fn gen_cb,\n                                  SSL_CTX_decrypt_session_ticket_fn dec_cb,\n                                  void *arg);\nint SSL_SESSION_set1_ticket_appdata(SSL_SESSION *ss, const void *data, size_t len);\nint SSL_SESSION_get0_ticket_appdata(SSL_SESSION *ss, void **data, size_t *len);\n\nextern const char SSL_version_str[];\n\ntypedef unsigned int (*DTLS_timer_cb)(SSL *s, unsigned int timer_us);\n\nvoid DTLS_set_timer_cb(SSL *s, DTLS_timer_cb cb);\n\n\ntypedef int (*SSL_allow_early_data_cb_fn)(SSL *s, void *arg);\nvoid SSL_CTX_set_allow_early_data_cb(SSL_CTX *ctx,\n                                     SSL_allow_early_data_cb_fn cb,\n                                     void *arg);\nvoid SSL_set_allow_early_data_cb(SSL *s,\n                                 SSL_allow_early_data_cb_fn cb,\n                                 void *arg);\n\n# ifdef  __cplusplus\n}\n# endif\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/include/openssl/ssl2.h",
    "content": "/*\n * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef HEADER_SSL2_H\n# define HEADER_SSL2_H\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n# define SSL2_VERSION            0x0002\n\n# define SSL2_MT_CLIENT_HELLO            1\n\n#ifdef  __cplusplus\n}\n#endif\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/include/openssl/ssl3.h",
    "content": "/*\n * Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved.\n * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef HEADER_SSL3_H\n# define HEADER_SSL3_H\n\n# include <openssl/comp.h>\n# include <openssl/buffer.h>\n# include <openssl/evp.h>\n# include <openssl/ssl.h>\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n/*\n * Signalling cipher suite value from RFC 5746\n * (TLS_EMPTY_RENEGOTIATION_INFO_SCSV)\n */\n# define SSL3_CK_SCSV                            0x030000FF\n\n/*\n * Signalling cipher suite value from draft-ietf-tls-downgrade-scsv-00\n * (TLS_FALLBACK_SCSV)\n */\n# define SSL3_CK_FALLBACK_SCSV                   0x03005600\n\n# define SSL3_CK_RSA_NULL_MD5                    0x03000001\n# define SSL3_CK_RSA_NULL_SHA                    0x03000002\n# define SSL3_CK_RSA_RC4_40_MD5                  0x03000003\n# define SSL3_CK_RSA_RC4_128_MD5                 0x03000004\n# define SSL3_CK_RSA_RC4_128_SHA                 0x03000005\n# define SSL3_CK_RSA_RC2_40_MD5                  0x03000006\n# define SSL3_CK_RSA_IDEA_128_SHA                0x03000007\n# define SSL3_CK_RSA_DES_40_CBC_SHA              0x03000008\n# define SSL3_CK_RSA_DES_64_CBC_SHA              0x03000009\n# define SSL3_CK_RSA_DES_192_CBC3_SHA            0x0300000A\n\n# define SSL3_CK_DH_DSS_DES_40_CBC_SHA           0x0300000B\n# define SSL3_CK_DH_DSS_DES_64_CBC_SHA           0x0300000C\n# define SSL3_CK_DH_DSS_DES_192_CBC3_SHA         0x0300000D\n# define SSL3_CK_DH_RSA_DES_40_CBC_SHA           0x0300000E\n# define SSL3_CK_DH_RSA_DES_64_CBC_SHA           0x0300000F\n# define SSL3_CK_DH_RSA_DES_192_CBC3_SHA         0x03000010\n\n# define SSL3_CK_DHE_DSS_DES_40_CBC_SHA          0x03000011\n# define SSL3_CK_EDH_DSS_DES_40_CBC_SHA          SSL3_CK_DHE_DSS_DES_40_CBC_SHA\n# define SSL3_CK_DHE_DSS_DES_64_CBC_SHA          0x03000012\n# define SSL3_CK_EDH_DSS_DES_64_CBC_SHA          SSL3_CK_DHE_DSS_DES_64_CBC_SHA\n# define SSL3_CK_DHE_DSS_DES_192_CBC3_SHA        0x03000013\n# define SSL3_CK_EDH_DSS_DES_192_CBC3_SHA        SSL3_CK_DHE_DSS_DES_192_CBC3_SHA\n# define SSL3_CK_DHE_RSA_DES_40_CBC_SHA          0x03000014\n# define SSL3_CK_EDH_RSA_DES_40_CBC_SHA          SSL3_CK_DHE_RSA_DES_40_CBC_SHA\n# define SSL3_CK_DHE_RSA_DES_64_CBC_SHA          0x03000015\n# define SSL3_CK_EDH_RSA_DES_64_CBC_SHA          SSL3_CK_DHE_RSA_DES_64_CBC_SHA\n# define SSL3_CK_DHE_RSA_DES_192_CBC3_SHA        0x03000016\n# define SSL3_CK_EDH_RSA_DES_192_CBC3_SHA        SSL3_CK_DHE_RSA_DES_192_CBC3_SHA\n\n# define SSL3_CK_ADH_RC4_40_MD5                  0x03000017\n# define SSL3_CK_ADH_RC4_128_MD5                 0x03000018\n# define SSL3_CK_ADH_DES_40_CBC_SHA              0x03000019\n# define SSL3_CK_ADH_DES_64_CBC_SHA              0x0300001A\n# define SSL3_CK_ADH_DES_192_CBC_SHA             0x0300001B\n\n/* a bundle of RFC standard cipher names, generated from ssl3_ciphers[] */\n# define SSL3_RFC_RSA_NULL_MD5                   \"TLS_RSA_WITH_NULL_MD5\"\n# define SSL3_RFC_RSA_NULL_SHA                   \"TLS_RSA_WITH_NULL_SHA\"\n# define SSL3_RFC_RSA_DES_192_CBC3_SHA           \"TLS_RSA_WITH_3DES_EDE_CBC_SHA\"\n# define SSL3_RFC_DHE_DSS_DES_192_CBC3_SHA       \"TLS_DHE_DSS_WITH_3DES_EDE_CBC_SHA\"\n# define SSL3_RFC_DHE_RSA_DES_192_CBC3_SHA       \"TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA\"\n# define SSL3_RFC_ADH_DES_192_CBC_SHA            \"TLS_DH_anon_WITH_3DES_EDE_CBC_SHA\"\n# define SSL3_RFC_RSA_IDEA_128_SHA               \"TLS_RSA_WITH_IDEA_CBC_SHA\"\n# define SSL3_RFC_RSA_RC4_128_MD5                \"TLS_RSA_WITH_RC4_128_MD5\"\n# define SSL3_RFC_RSA_RC4_128_SHA                \"TLS_RSA_WITH_RC4_128_SHA\"\n# define SSL3_RFC_ADH_RC4_128_MD5                \"TLS_DH_anon_WITH_RC4_128_MD5\"\n\n# define SSL3_TXT_RSA_NULL_MD5                   \"NULL-MD5\"\n# define SSL3_TXT_RSA_NULL_SHA                   \"NULL-SHA\"\n# define SSL3_TXT_RSA_RC4_40_MD5                 \"EXP-RC4-MD5\"\n# define SSL3_TXT_RSA_RC4_128_MD5                \"RC4-MD5\"\n# define SSL3_TXT_RSA_RC4_128_SHA                \"RC4-SHA\"\n# define SSL3_TXT_RSA_RC2_40_MD5                 \"EXP-RC2-CBC-MD5\"\n# define SSL3_TXT_RSA_IDEA_128_SHA               \"IDEA-CBC-SHA\"\n# define SSL3_TXT_RSA_DES_40_CBC_SHA             \"EXP-DES-CBC-SHA\"\n# define SSL3_TXT_RSA_DES_64_CBC_SHA             \"DES-CBC-SHA\"\n# define SSL3_TXT_RSA_DES_192_CBC3_SHA           \"DES-CBC3-SHA\"\n\n# define SSL3_TXT_DH_DSS_DES_40_CBC_SHA          \"EXP-DH-DSS-DES-CBC-SHA\"\n# define SSL3_TXT_DH_DSS_DES_64_CBC_SHA          \"DH-DSS-DES-CBC-SHA\"\n# define SSL3_TXT_DH_DSS_DES_192_CBC3_SHA        \"DH-DSS-DES-CBC3-SHA\"\n# define SSL3_TXT_DH_RSA_DES_40_CBC_SHA          \"EXP-DH-RSA-DES-CBC-SHA\"\n# define SSL3_TXT_DH_RSA_DES_64_CBC_SHA          \"DH-RSA-DES-CBC-SHA\"\n# define SSL3_TXT_DH_RSA_DES_192_CBC3_SHA        \"DH-RSA-DES-CBC3-SHA\"\n\n# define SSL3_TXT_DHE_DSS_DES_40_CBC_SHA         \"EXP-DHE-DSS-DES-CBC-SHA\"\n# define SSL3_TXT_DHE_DSS_DES_64_CBC_SHA         \"DHE-DSS-DES-CBC-SHA\"\n# define SSL3_TXT_DHE_DSS_DES_192_CBC3_SHA       \"DHE-DSS-DES-CBC3-SHA\"\n# define SSL3_TXT_DHE_RSA_DES_40_CBC_SHA         \"EXP-DHE-RSA-DES-CBC-SHA\"\n# define SSL3_TXT_DHE_RSA_DES_64_CBC_SHA         \"DHE-RSA-DES-CBC-SHA\"\n# define SSL3_TXT_DHE_RSA_DES_192_CBC3_SHA       \"DHE-RSA-DES-CBC3-SHA\"\n\n/*\n * This next block of six \"EDH\" labels is for backward compatibility with\n * older versions of OpenSSL.  New code should use the six \"DHE\" labels above\n * instead:\n */\n# define SSL3_TXT_EDH_DSS_DES_40_CBC_SHA         \"EXP-EDH-DSS-DES-CBC-SHA\"\n# define SSL3_TXT_EDH_DSS_DES_64_CBC_SHA         \"EDH-DSS-DES-CBC-SHA\"\n# define SSL3_TXT_EDH_DSS_DES_192_CBC3_SHA       \"EDH-DSS-DES-CBC3-SHA\"\n# define SSL3_TXT_EDH_RSA_DES_40_CBC_SHA         \"EXP-EDH-RSA-DES-CBC-SHA\"\n# define SSL3_TXT_EDH_RSA_DES_64_CBC_SHA         \"EDH-RSA-DES-CBC-SHA\"\n# define SSL3_TXT_EDH_RSA_DES_192_CBC3_SHA       \"EDH-RSA-DES-CBC3-SHA\"\n\n# define SSL3_TXT_ADH_RC4_40_MD5                 \"EXP-ADH-RC4-MD5\"\n# define SSL3_TXT_ADH_RC4_128_MD5                \"ADH-RC4-MD5\"\n# define SSL3_TXT_ADH_DES_40_CBC_SHA             \"EXP-ADH-DES-CBC-SHA\"\n# define SSL3_TXT_ADH_DES_64_CBC_SHA             \"ADH-DES-CBC-SHA\"\n# define SSL3_TXT_ADH_DES_192_CBC_SHA            \"ADH-DES-CBC3-SHA\"\n\n# define SSL3_SSL_SESSION_ID_LENGTH              32\n# define SSL3_MAX_SSL_SESSION_ID_LENGTH          32\n\n# define SSL3_MASTER_SECRET_SIZE                 48\n# define SSL3_RANDOM_SIZE                        32\n# define SSL3_SESSION_ID_SIZE                    32\n# define SSL3_RT_HEADER_LENGTH                   5\n\n# define SSL3_HM_HEADER_LENGTH                  4\n\n# ifndef SSL3_ALIGN_PAYLOAD\n /*\n  * Some will argue that this increases memory footprint, but it's not\n  * actually true. Point is that malloc has to return at least 64-bit aligned\n  * pointers, meaning that allocating 5 bytes wastes 3 bytes in either case.\n  * Suggested pre-gaping simply moves these wasted bytes from the end of\n  * allocated region to its front, but makes data payload aligned, which\n  * improves performance:-)\n  */\n#  define SSL3_ALIGN_PAYLOAD                     8\n# else\n#  if (SSL3_ALIGN_PAYLOAD&(SSL3_ALIGN_PAYLOAD-1))!=0\n#   error \"insane SSL3_ALIGN_PAYLOAD\"\n#   undef SSL3_ALIGN_PAYLOAD\n#  endif\n# endif\n\n/*\n * This is the maximum MAC (digest) size used by the SSL library. Currently\n * maximum of 20 is used by SHA1, but we reserve for future extension for\n * 512-bit hashes.\n */\n\n# define SSL3_RT_MAX_MD_SIZE                     64\n\n/*\n * Maximum block size used in all ciphersuites. Currently 16 for AES.\n */\n\n# define SSL_RT_MAX_CIPHER_BLOCK_SIZE            16\n\n# define SSL3_RT_MAX_EXTRA                       (16384)\n\n/* Maximum plaintext length: defined by SSL/TLS standards */\n# define SSL3_RT_MAX_PLAIN_LENGTH                16384\n/* Maximum compression overhead: defined by SSL/TLS standards */\n# define SSL3_RT_MAX_COMPRESSED_OVERHEAD         1024\n\n/*\n * The standards give a maximum encryption overhead of 1024 bytes. In\n * practice the value is lower than this. The overhead is the maximum number\n * of padding bytes (256) plus the mac size.\n */\n# define SSL3_RT_MAX_ENCRYPTED_OVERHEAD        (256 + SSL3_RT_MAX_MD_SIZE)\n# define SSL3_RT_MAX_TLS13_ENCRYPTED_OVERHEAD  256\n\n/*\n * OpenSSL currently only uses a padding length of at most one block so the\n * send overhead is smaller.\n */\n\n# define SSL3_RT_SEND_MAX_ENCRYPTED_OVERHEAD \\\n                        (SSL_RT_MAX_CIPHER_BLOCK_SIZE + SSL3_RT_MAX_MD_SIZE)\n\n/* If compression isn't used don't include the compression overhead */\n\n# ifdef OPENSSL_NO_COMP\n#  define SSL3_RT_MAX_COMPRESSED_LENGTH           SSL3_RT_MAX_PLAIN_LENGTH\n# else\n#  define SSL3_RT_MAX_COMPRESSED_LENGTH   \\\n            (SSL3_RT_MAX_PLAIN_LENGTH+SSL3_RT_MAX_COMPRESSED_OVERHEAD)\n# endif\n# define SSL3_RT_MAX_ENCRYPTED_LENGTH    \\\n            (SSL3_RT_MAX_ENCRYPTED_OVERHEAD+SSL3_RT_MAX_COMPRESSED_LENGTH)\n# define SSL3_RT_MAX_TLS13_ENCRYPTED_LENGTH \\\n            (SSL3_RT_MAX_PLAIN_LENGTH + SSL3_RT_MAX_TLS13_ENCRYPTED_OVERHEAD)\n# define SSL3_RT_MAX_PACKET_SIZE         \\\n            (SSL3_RT_MAX_ENCRYPTED_LENGTH+SSL3_RT_HEADER_LENGTH)\n\n# define SSL3_MD_CLIENT_FINISHED_CONST   \"\\x43\\x4C\\x4E\\x54\"\n# define SSL3_MD_SERVER_FINISHED_CONST   \"\\x53\\x52\\x56\\x52\"\n\n# define SSL3_VERSION                    0x0300\n# define SSL3_VERSION_MAJOR              0x03\n# define SSL3_VERSION_MINOR              0x00\n\n# define SSL3_RT_CHANGE_CIPHER_SPEC      20\n# define SSL3_RT_ALERT                   21\n# define SSL3_RT_HANDSHAKE               22\n# define SSL3_RT_APPLICATION_DATA        23\n# define DTLS1_RT_HEARTBEAT              24\n\n/* Pseudo content types to indicate additional parameters */\n# define TLS1_RT_CRYPTO                  0x1000\n# define TLS1_RT_CRYPTO_PREMASTER        (TLS1_RT_CRYPTO | 0x1)\n# define TLS1_RT_CRYPTO_CLIENT_RANDOM    (TLS1_RT_CRYPTO | 0x2)\n# define TLS1_RT_CRYPTO_SERVER_RANDOM    (TLS1_RT_CRYPTO | 0x3)\n# define TLS1_RT_CRYPTO_MASTER           (TLS1_RT_CRYPTO | 0x4)\n\n# define TLS1_RT_CRYPTO_READ             0x0000\n# define TLS1_RT_CRYPTO_WRITE            0x0100\n# define TLS1_RT_CRYPTO_MAC              (TLS1_RT_CRYPTO | 0x5)\n# define TLS1_RT_CRYPTO_KEY              (TLS1_RT_CRYPTO | 0x6)\n# define TLS1_RT_CRYPTO_IV               (TLS1_RT_CRYPTO | 0x7)\n# define TLS1_RT_CRYPTO_FIXED_IV         (TLS1_RT_CRYPTO | 0x8)\n\n/* Pseudo content types for SSL/TLS header info */\n# define SSL3_RT_HEADER                  0x100\n# define SSL3_RT_INNER_CONTENT_TYPE      0x101\n\n# define SSL3_AL_WARNING                 1\n# define SSL3_AL_FATAL                   2\n\n# define SSL3_AD_CLOSE_NOTIFY             0\n# define SSL3_AD_UNEXPECTED_MESSAGE      10/* fatal */\n# define SSL3_AD_BAD_RECORD_MAC          20/* fatal */\n# define SSL3_AD_DECOMPRESSION_FAILURE   30/* fatal */\n# define SSL3_AD_HANDSHAKE_FAILURE       40/* fatal */\n# define SSL3_AD_NO_CERTIFICATE          41\n# define SSL3_AD_BAD_CERTIFICATE         42\n# define SSL3_AD_UNSUPPORTED_CERTIFICATE 43\n# define SSL3_AD_CERTIFICATE_REVOKED     44\n# define SSL3_AD_CERTIFICATE_EXPIRED     45\n# define SSL3_AD_CERTIFICATE_UNKNOWN     46\n# define SSL3_AD_ILLEGAL_PARAMETER       47/* fatal */\n\n# define TLS1_HB_REQUEST         1\n# define TLS1_HB_RESPONSE        2\n\n\n# define SSL3_CT_RSA_SIGN                        1\n# define SSL3_CT_DSS_SIGN                        2\n# define SSL3_CT_RSA_FIXED_DH                    3\n# define SSL3_CT_DSS_FIXED_DH                    4\n# define SSL3_CT_RSA_EPHEMERAL_DH                5\n# define SSL3_CT_DSS_EPHEMERAL_DH                6\n# define SSL3_CT_FORTEZZA_DMS                    20\n/*\n * SSL3_CT_NUMBER is used to size arrays and it must be large enough to\n * contain all of the cert types defined for *either* SSLv3 and TLSv1.\n */\n# define SSL3_CT_NUMBER                  10\n\n# if defined(TLS_CT_NUMBER)\n#  if TLS_CT_NUMBER != SSL3_CT_NUMBER\n#    error \"SSL/TLS CT_NUMBER values do not match\"\n#  endif\n# endif\n\n/* No longer used as of OpenSSL 1.1.1 */\n# define SSL3_FLAGS_NO_RENEGOTIATE_CIPHERS       0x0001\n\n/* Removed from OpenSSL 1.1.0 */\n# define TLS1_FLAGS_TLS_PADDING_BUG              0x0\n\n# define TLS1_FLAGS_SKIP_CERT_VERIFY             0x0010\n\n/* Set if we encrypt then mac instead of usual mac then encrypt */\n# define TLS1_FLAGS_ENCRYPT_THEN_MAC_READ        0x0100\n# define TLS1_FLAGS_ENCRYPT_THEN_MAC             TLS1_FLAGS_ENCRYPT_THEN_MAC_READ\n\n/* Set if extended master secret extension received from peer */\n# define TLS1_FLAGS_RECEIVED_EXTMS               0x0200\n\n# define TLS1_FLAGS_ENCRYPT_THEN_MAC_WRITE       0x0400\n\n# define TLS1_FLAGS_STATELESS                    0x0800\n\n/* Set if extended master secret extension required on renegotiation */\n# define TLS1_FLAGS_REQUIRED_EXTMS               0x1000\n\n# define SSL3_MT_HELLO_REQUEST                   0\n# define SSL3_MT_CLIENT_HELLO                    1\n# define SSL3_MT_SERVER_HELLO                    2\n# define SSL3_MT_NEWSESSION_TICKET               4\n# define SSL3_MT_END_OF_EARLY_DATA               5\n# define SSL3_MT_ENCRYPTED_EXTENSIONS            8\n# define SSL3_MT_CERTIFICATE                     11\n# define SSL3_MT_SERVER_KEY_EXCHANGE             12\n# define SSL3_MT_CERTIFICATE_REQUEST             13\n# define SSL3_MT_SERVER_DONE                     14\n# define SSL3_MT_CERTIFICATE_VERIFY              15\n# define SSL3_MT_CLIENT_KEY_EXCHANGE             16\n# define SSL3_MT_FINISHED                        20\n# define SSL3_MT_CERTIFICATE_URL                 21\n# define SSL3_MT_CERTIFICATE_STATUS              22\n# define SSL3_MT_SUPPLEMENTAL_DATA               23\n# define SSL3_MT_KEY_UPDATE                      24\n# ifndef OPENSSL_NO_NEXTPROTONEG\n#  define SSL3_MT_NEXT_PROTO                     67\n# endif\n# define SSL3_MT_MESSAGE_HASH                    254\n# define DTLS1_MT_HELLO_VERIFY_REQUEST           3\n\n/* Dummy message type for handling CCS like a normal handshake message */\n# define SSL3_MT_CHANGE_CIPHER_SPEC              0x0101\n\n# define SSL3_MT_CCS                             1\n\n/* These are used when changing over to a new cipher */\n# define SSL3_CC_READ            0x001\n# define SSL3_CC_WRITE           0x002\n# define SSL3_CC_CLIENT          0x010\n# define SSL3_CC_SERVER          0x020\n# define SSL3_CC_EARLY           0x040\n# define SSL3_CC_HANDSHAKE       0x080\n# define SSL3_CC_APPLICATION     0x100\n# define SSL3_CHANGE_CIPHER_CLIENT_WRITE (SSL3_CC_CLIENT|SSL3_CC_WRITE)\n# define SSL3_CHANGE_CIPHER_SERVER_READ  (SSL3_CC_SERVER|SSL3_CC_READ)\n# define SSL3_CHANGE_CIPHER_CLIENT_READ  (SSL3_CC_CLIENT|SSL3_CC_READ)\n# define SSL3_CHANGE_CIPHER_SERVER_WRITE (SSL3_CC_SERVER|SSL3_CC_WRITE)\n\n#ifdef  __cplusplus\n}\n#endif\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/include/openssl/sslerr.h",
    "content": "/*\n * Generated by util/mkerr.pl DO NOT EDIT\n * Copyright 1995-2021 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef HEADER_SSLERR_H\n# define HEADER_SSLERR_H\n\n# ifndef HEADER_SYMHACKS_H\n#  include <openssl/symhacks.h>\n# endif\n\n# ifdef  __cplusplus\nextern \"C\"\n# endif\nint ERR_load_SSL_strings(void);\n\n/*\n * SSL function codes.\n */\n# define SSL_F_ADD_CLIENT_KEY_SHARE_EXT                   438\n# define SSL_F_ADD_KEY_SHARE                              512\n# define SSL_F_BYTES_TO_CIPHER_LIST                       519\n# define SSL_F_CHECK_SUITEB_CIPHER_LIST                   331\n# define SSL_F_CIPHERSUITE_CB                             622\n# define SSL_F_CONSTRUCT_CA_NAMES                         552\n# define SSL_F_CONSTRUCT_KEY_EXCHANGE_TBS                 553\n# define SSL_F_CONSTRUCT_STATEFUL_TICKET                  636\n# define SSL_F_CONSTRUCT_STATELESS_TICKET                 637\n# define SSL_F_CREATE_SYNTHETIC_MESSAGE_HASH              539\n# define SSL_F_CREATE_TICKET_PREQUEL                      638\n# define SSL_F_CT_MOVE_SCTS                               345\n# define SSL_F_CT_STRICT                                  349\n# define SSL_F_CUSTOM_EXT_ADD                             554\n# define SSL_F_CUSTOM_EXT_PARSE                           555\n# define SSL_F_D2I_SSL_SESSION                            103\n# define SSL_F_DANE_CTX_ENABLE                            347\n# define SSL_F_DANE_MTYPE_SET                             393\n# define SSL_F_DANE_TLSA_ADD                              394\n# define SSL_F_DERIVE_SECRET_KEY_AND_IV                   514\n# define SSL_F_DO_DTLS1_WRITE                             245\n# define SSL_F_DO_SSL3_WRITE                              104\n# define SSL_F_DTLS1_BUFFER_RECORD                        247\n# define SSL_F_DTLS1_CHECK_TIMEOUT_NUM                    318\n# define SSL_F_DTLS1_HEARTBEAT                            305\n# define SSL_F_DTLS1_HM_FRAGMENT_NEW                      623\n# define SSL_F_DTLS1_PREPROCESS_FRAGMENT                  288\n# define SSL_F_DTLS1_PROCESS_BUFFERED_RECORDS             424\n# define SSL_F_DTLS1_PROCESS_RECORD                       257\n# define SSL_F_DTLS1_READ_BYTES                           258\n# define SSL_F_DTLS1_READ_FAILED                          339\n# define SSL_F_DTLS1_RETRANSMIT_MESSAGE                   390\n# define SSL_F_DTLS1_WRITE_APP_DATA_BYTES                 268\n# define SSL_F_DTLS1_WRITE_BYTES                          545\n# define SSL_F_DTLSV1_LISTEN                              350\n# define SSL_F_DTLS_CONSTRUCT_CHANGE_CIPHER_SPEC          371\n# define SSL_F_DTLS_CONSTRUCT_HELLO_VERIFY_REQUEST        385\n# define SSL_F_DTLS_GET_REASSEMBLED_MESSAGE               370\n# define SSL_F_DTLS_PROCESS_HELLO_VERIFY                  386\n# define SSL_F_DTLS_RECORD_LAYER_NEW                      635\n# define SSL_F_DTLS_WAIT_FOR_DRY                          592\n# define SSL_F_EARLY_DATA_COUNT_OK                        532\n# define SSL_F_FINAL_EARLY_DATA                           556\n# define SSL_F_FINAL_EC_PT_FORMATS                        485\n# define SSL_F_FINAL_EMS                                  486\n# define SSL_F_FINAL_KEY_SHARE                            503\n# define SSL_F_FINAL_MAXFRAGMENTLEN                       557\n# define SSL_F_FINAL_PSK                                  639\n# define SSL_F_FINAL_RENEGOTIATE                          483\n# define SSL_F_FINAL_SERVER_NAME                          558\n# define SSL_F_FINAL_SIG_ALGS                             497\n# define SSL_F_GET_CERT_VERIFY_TBS_DATA                   588\n# define SSL_F_NSS_KEYLOG_INT                             500\n# define SSL_F_OPENSSL_INIT_SSL                           342\n# define SSL_F_OSSL_STATEM_CLIENT13_READ_TRANSITION       436\n# define SSL_F_OSSL_STATEM_CLIENT13_WRITE_TRANSITION      598\n# define SSL_F_OSSL_STATEM_CLIENT_CONSTRUCT_MESSAGE       430\n# define SSL_F_OSSL_STATEM_CLIENT_POST_PROCESS_MESSAGE    593\n# define SSL_F_OSSL_STATEM_CLIENT_PROCESS_MESSAGE         594\n# define SSL_F_OSSL_STATEM_CLIENT_READ_TRANSITION         417\n# define SSL_F_OSSL_STATEM_CLIENT_WRITE_TRANSITION        599\n# define SSL_F_OSSL_STATEM_SERVER13_READ_TRANSITION       437\n# define SSL_F_OSSL_STATEM_SERVER13_WRITE_TRANSITION      600\n# define SSL_F_OSSL_STATEM_SERVER_CONSTRUCT_MESSAGE       431\n# define SSL_F_OSSL_STATEM_SERVER_POST_PROCESS_MESSAGE    601\n# define SSL_F_OSSL_STATEM_SERVER_POST_WORK               602\n# define SSL_F_OSSL_STATEM_SERVER_PRE_WORK                640\n# define SSL_F_OSSL_STATEM_SERVER_PROCESS_MESSAGE         603\n# define SSL_F_OSSL_STATEM_SERVER_READ_TRANSITION         418\n# define SSL_F_OSSL_STATEM_SERVER_WRITE_TRANSITION        604\n# define SSL_F_PARSE_CA_NAMES                             541\n# define SSL_F_PITEM_NEW                                  624\n# define SSL_F_PQUEUE_NEW                                 625\n# define SSL_F_PROCESS_KEY_SHARE_EXT                      439\n# define SSL_F_READ_STATE_MACHINE                         352\n# define SSL_F_SET_CLIENT_CIPHERSUITE                     540\n# define SSL_F_SRP_GENERATE_CLIENT_MASTER_SECRET          595\n# define SSL_F_SRP_GENERATE_SERVER_MASTER_SECRET          589\n# define SSL_F_SRP_VERIFY_SERVER_PARAM                    596\n# define SSL_F_SSL3_CHANGE_CIPHER_STATE                   129\n# define SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM              130\n# define SSL_F_SSL3_CTRL                                  213\n# define SSL_F_SSL3_CTX_CTRL                              133\n# define SSL_F_SSL3_DIGEST_CACHED_RECORDS                 293\n# define SSL_F_SSL3_DO_CHANGE_CIPHER_SPEC                 292\n# define SSL_F_SSL3_ENC                                   608\n# define SSL_F_SSL3_FINAL_FINISH_MAC                      285\n# define SSL_F_SSL3_FINISH_MAC                            587\n# define SSL_F_SSL3_GENERATE_KEY_BLOCK                    238\n# define SSL_F_SSL3_GENERATE_MASTER_SECRET                388\n# define SSL_F_SSL3_GET_RECORD                            143\n# define SSL_F_SSL3_INIT_FINISHED_MAC                     397\n# define SSL_F_SSL3_OUTPUT_CERT_CHAIN                     147\n# define SSL_F_SSL3_READ_BYTES                            148\n# define SSL_F_SSL3_READ_N                                149\n# define SSL_F_SSL3_SETUP_KEY_BLOCK                       157\n# define SSL_F_SSL3_SETUP_READ_BUFFER                     156\n# define SSL_F_SSL3_SETUP_WRITE_BUFFER                    291\n# define SSL_F_SSL3_WRITE_BYTES                           158\n# define SSL_F_SSL3_WRITE_PENDING                         159\n# define SSL_F_SSL_ADD_CERT_CHAIN                         316\n# define SSL_F_SSL_ADD_CERT_TO_BUF                        319\n# define SSL_F_SSL_ADD_CERT_TO_WPACKET                    493\n# define SSL_F_SSL_ADD_CLIENTHELLO_RENEGOTIATE_EXT        298\n# define SSL_F_SSL_ADD_CLIENTHELLO_TLSEXT                 277\n# define SSL_F_SSL_ADD_CLIENTHELLO_USE_SRTP_EXT           307\n# define SSL_F_SSL_ADD_DIR_CERT_SUBJECTS_TO_STACK         215\n# define SSL_F_SSL_ADD_FILE_CERT_SUBJECTS_TO_STACK        216\n# define SSL_F_SSL_ADD_SERVERHELLO_RENEGOTIATE_EXT        299\n# define SSL_F_SSL_ADD_SERVERHELLO_TLSEXT                 278\n# define SSL_F_SSL_ADD_SERVERHELLO_USE_SRTP_EXT           308\n# define SSL_F_SSL_BAD_METHOD                             160\n# define SSL_F_SSL_BUILD_CERT_CHAIN                       332\n# define SSL_F_SSL_BYTES_TO_CIPHER_LIST                   161\n# define SSL_F_SSL_CACHE_CIPHERLIST                       520\n# define SSL_F_SSL_CERT_ADD0_CHAIN_CERT                   346\n# define SSL_F_SSL_CERT_DUP                               221\n# define SSL_F_SSL_CERT_NEW                               162\n# define SSL_F_SSL_CERT_SET0_CHAIN                        340\n# define SSL_F_SSL_CHECK_PRIVATE_KEY                      163\n# define SSL_F_SSL_CHECK_SERVERHELLO_TLSEXT               280\n# define SSL_F_SSL_CHECK_SRP_EXT_CLIENTHELLO              606\n# define SSL_F_SSL_CHECK_SRVR_ECC_CERT_AND_ALG            279\n# define SSL_F_SSL_CHOOSE_CLIENT_VERSION                  607\n# define SSL_F_SSL_CIPHER_DESCRIPTION                     626\n# define SSL_F_SSL_CIPHER_LIST_TO_BYTES                   425\n# define SSL_F_SSL_CIPHER_PROCESS_RULESTR                 230\n# define SSL_F_SSL_CIPHER_STRENGTH_SORT                   231\n# define SSL_F_SSL_CLEAR                                  164\n# define SSL_F_SSL_CLIENT_HELLO_GET1_EXTENSIONS_PRESENT   627\n# define SSL_F_SSL_COMP_ADD_COMPRESSION_METHOD            165\n# define SSL_F_SSL_CONF_CMD                               334\n# define SSL_F_SSL_CREATE_CIPHER_LIST                     166\n# define SSL_F_SSL_CTRL                                   232\n# define SSL_F_SSL_CTX_CHECK_PRIVATE_KEY                  168\n# define SSL_F_SSL_CTX_ENABLE_CT                          398\n# define SSL_F_SSL_CTX_MAKE_PROFILES                      309\n# define SSL_F_SSL_CTX_NEW                                169\n# define SSL_F_SSL_CTX_SET_ALPN_PROTOS                    343\n# define SSL_F_SSL_CTX_SET_CIPHER_LIST                    269\n# define SSL_F_SSL_CTX_SET_CLIENT_CERT_ENGINE             290\n# define SSL_F_SSL_CTX_SET_CT_VALIDATION_CALLBACK         396\n# define SSL_F_SSL_CTX_SET_SESSION_ID_CONTEXT             219\n# define SSL_F_SSL_CTX_SET_SSL_VERSION                    170\n# define SSL_F_SSL_CTX_SET_TLSEXT_MAX_FRAGMENT_LENGTH     551\n# define SSL_F_SSL_CTX_USE_CERTIFICATE                    171\n# define SSL_F_SSL_CTX_USE_CERTIFICATE_ASN1               172\n# define SSL_F_SSL_CTX_USE_CERTIFICATE_FILE               173\n# define SSL_F_SSL_CTX_USE_PRIVATEKEY                     174\n# define SSL_F_SSL_CTX_USE_PRIVATEKEY_ASN1                175\n# define SSL_F_SSL_CTX_USE_PRIVATEKEY_FILE                176\n# define SSL_F_SSL_CTX_USE_PSK_IDENTITY_HINT              272\n# define SSL_F_SSL_CTX_USE_RSAPRIVATEKEY                  177\n# define SSL_F_SSL_CTX_USE_RSAPRIVATEKEY_ASN1             178\n# define SSL_F_SSL_CTX_USE_RSAPRIVATEKEY_FILE             179\n# define SSL_F_SSL_CTX_USE_SERVERINFO                     336\n# define SSL_F_SSL_CTX_USE_SERVERINFO_EX                  543\n# define SSL_F_SSL_CTX_USE_SERVERINFO_FILE                337\n# define SSL_F_SSL_DANE_DUP                               403\n# define SSL_F_SSL_DANE_ENABLE                            395\n# define SSL_F_SSL_DERIVE                                 590\n# define SSL_F_SSL_DO_CONFIG                              391\n# define SSL_F_SSL_DO_HANDSHAKE                           180\n# define SSL_F_SSL_DUP_CA_LIST                            408\n# define SSL_F_SSL_ENABLE_CT                              402\n# define SSL_F_SSL_GENERATE_PKEY_GROUP                    559\n# define SSL_F_SSL_GENERATE_SESSION_ID                    547\n# define SSL_F_SSL_GET_NEW_SESSION                        181\n# define SSL_F_SSL_GET_PREV_SESSION                       217\n# define SSL_F_SSL_GET_SERVER_CERT_INDEX                  322\n# define SSL_F_SSL_GET_SIGN_PKEY                          183\n# define SSL_F_SSL_HANDSHAKE_HASH                         560\n# define SSL_F_SSL_INIT_WBIO_BUFFER                       184\n# define SSL_F_SSL_KEY_UPDATE                             515\n# define SSL_F_SSL_LOAD_CLIENT_CA_FILE                    185\n# define SSL_F_SSL_LOG_MASTER_SECRET                      498\n# define SSL_F_SSL_LOG_RSA_CLIENT_KEY_EXCHANGE            499\n# define SSL_F_SSL_MODULE_INIT                            392\n# define SSL_F_SSL_NEW                                    186\n# define SSL_F_SSL_NEXT_PROTO_VALIDATE                    565\n# define SSL_F_SSL_PARSE_CLIENTHELLO_RENEGOTIATE_EXT      300\n# define SSL_F_SSL_PARSE_CLIENTHELLO_TLSEXT               302\n# define SSL_F_SSL_PARSE_CLIENTHELLO_USE_SRTP_EXT         310\n# define SSL_F_SSL_PARSE_SERVERHELLO_RENEGOTIATE_EXT      301\n# define SSL_F_SSL_PARSE_SERVERHELLO_TLSEXT               303\n# define SSL_F_SSL_PARSE_SERVERHELLO_USE_SRTP_EXT         311\n# define SSL_F_SSL_PEEK                                   270\n# define SSL_F_SSL_PEEK_EX                                432\n# define SSL_F_SSL_PEEK_INTERNAL                          522\n# define SSL_F_SSL_READ                                   223\n# define SSL_F_SSL_READ_EARLY_DATA                        529\n# define SSL_F_SSL_READ_EX                                434\n# define SSL_F_SSL_READ_INTERNAL                          523\n# define SSL_F_SSL_RENEGOTIATE                            516\n# define SSL_F_SSL_RENEGOTIATE_ABBREVIATED                546\n# define SSL_F_SSL_SCAN_CLIENTHELLO_TLSEXT                320\n# define SSL_F_SSL_SCAN_SERVERHELLO_TLSEXT                321\n# define SSL_F_SSL_SESSION_DUP                            348\n# define SSL_F_SSL_SESSION_NEW                            189\n# define SSL_F_SSL_SESSION_PRINT_FP                       190\n# define SSL_F_SSL_SESSION_SET1_ID                        423\n# define SSL_F_SSL_SESSION_SET1_ID_CONTEXT                312\n# define SSL_F_SSL_SET_ALPN_PROTOS                        344\n# define SSL_F_SSL_SET_CERT                               191\n# define SSL_F_SSL_SET_CERT_AND_KEY                       621\n# define SSL_F_SSL_SET_CIPHER_LIST                        271\n# define SSL_F_SSL_SET_CT_VALIDATION_CALLBACK             399\n# define SSL_F_SSL_SET_FD                                 192\n# define SSL_F_SSL_SET_PKEY                               193\n# define SSL_F_SSL_SET_RFD                                194\n# define SSL_F_SSL_SET_SESSION                            195\n# define SSL_F_SSL_SET_SESSION_ID_CONTEXT                 218\n# define SSL_F_SSL_SET_SESSION_TICKET_EXT                 294\n# define SSL_F_SSL_SET_TLSEXT_MAX_FRAGMENT_LENGTH         550\n# define SSL_F_SSL_SET_WFD                                196\n# define SSL_F_SSL_SHUTDOWN                               224\n# define SSL_F_SSL_SRP_CTX_INIT                           313\n# define SSL_F_SSL_START_ASYNC_JOB                        389\n# define SSL_F_SSL_UNDEFINED_FUNCTION                     197\n# define SSL_F_SSL_UNDEFINED_VOID_FUNCTION                244\n# define SSL_F_SSL_USE_CERTIFICATE                        198\n# define SSL_F_SSL_USE_CERTIFICATE_ASN1                   199\n# define SSL_F_SSL_USE_CERTIFICATE_FILE                   200\n# define SSL_F_SSL_USE_PRIVATEKEY                         201\n# define SSL_F_SSL_USE_PRIVATEKEY_ASN1                    202\n# define SSL_F_SSL_USE_PRIVATEKEY_FILE                    203\n# define SSL_F_SSL_USE_PSK_IDENTITY_HINT                  273\n# define SSL_F_SSL_USE_RSAPRIVATEKEY                      204\n# define SSL_F_SSL_USE_RSAPRIVATEKEY_ASN1                 205\n# define SSL_F_SSL_USE_RSAPRIVATEKEY_FILE                 206\n# define SSL_F_SSL_VALIDATE_CT                            400\n# define SSL_F_SSL_VERIFY_CERT_CHAIN                      207\n# define SSL_F_SSL_VERIFY_CLIENT_POST_HANDSHAKE           616\n# define SSL_F_SSL_WRITE                                  208\n# define SSL_F_SSL_WRITE_EARLY_DATA                       526\n# define SSL_F_SSL_WRITE_EARLY_FINISH                     527\n# define SSL_F_SSL_WRITE_EX                               433\n# define SSL_F_SSL_WRITE_INTERNAL                         524\n# define SSL_F_STATE_MACHINE                              353\n# define SSL_F_TLS12_CHECK_PEER_SIGALG                    333\n# define SSL_F_TLS12_COPY_SIGALGS                         533\n# define SSL_F_TLS13_CHANGE_CIPHER_STATE                  440\n# define SSL_F_TLS13_ENC                                  609\n# define SSL_F_TLS13_FINAL_FINISH_MAC                     605\n# define SSL_F_TLS13_GENERATE_SECRET                      591\n# define SSL_F_TLS13_HKDF_EXPAND                          561\n# define SSL_F_TLS13_RESTORE_HANDSHAKE_DIGEST_FOR_PHA     617\n# define SSL_F_TLS13_SAVE_HANDSHAKE_DIGEST_FOR_PHA        618\n# define SSL_F_TLS13_SETUP_KEY_BLOCK                      441\n# define SSL_F_TLS1_CHANGE_CIPHER_STATE                   209\n# define SSL_F_TLS1_CHECK_DUPLICATE_EXTENSIONS            341\n# define SSL_F_TLS1_ENC                                   401\n# define SSL_F_TLS1_EXPORT_KEYING_MATERIAL                314\n# define SSL_F_TLS1_GET_CURVELIST                         338\n# define SSL_F_TLS1_PRF                                   284\n# define SSL_F_TLS1_SAVE_U16                              628\n# define SSL_F_TLS1_SETUP_KEY_BLOCK                       211\n# define SSL_F_TLS1_SET_GROUPS                            629\n# define SSL_F_TLS1_SET_RAW_SIGALGS                       630\n# define SSL_F_TLS1_SET_SERVER_SIGALGS                    335\n# define SSL_F_TLS1_SET_SHARED_SIGALGS                    631\n# define SSL_F_TLS1_SET_SIGALGS                           632\n# define SSL_F_TLS_CHOOSE_SIGALG                          513\n# define SSL_F_TLS_CLIENT_KEY_EXCHANGE_POST_WORK          354\n# define SSL_F_TLS_COLLECT_EXTENSIONS                     435\n# define SSL_F_TLS_CONSTRUCT_CERTIFICATE_AUTHORITIES      542\n# define SSL_F_TLS_CONSTRUCT_CERTIFICATE_REQUEST          372\n# define SSL_F_TLS_CONSTRUCT_CERT_STATUS                  429\n# define SSL_F_TLS_CONSTRUCT_CERT_STATUS_BODY             494\n# define SSL_F_TLS_CONSTRUCT_CERT_VERIFY                  496\n# define SSL_F_TLS_CONSTRUCT_CHANGE_CIPHER_SPEC           427\n# define SSL_F_TLS_CONSTRUCT_CKE_DHE                      404\n# define SSL_F_TLS_CONSTRUCT_CKE_ECDHE                    405\n# define SSL_F_TLS_CONSTRUCT_CKE_GOST                     406\n# define SSL_F_TLS_CONSTRUCT_CKE_PSK_PREAMBLE             407\n# define SSL_F_TLS_CONSTRUCT_CKE_RSA                      409\n# define SSL_F_TLS_CONSTRUCT_CKE_SRP                      410\n# define SSL_F_TLS_CONSTRUCT_CLIENT_CERTIFICATE           484\n# define SSL_F_TLS_CONSTRUCT_CLIENT_HELLO                 487\n# define SSL_F_TLS_CONSTRUCT_CLIENT_KEY_EXCHANGE          488\n# define SSL_F_TLS_CONSTRUCT_CLIENT_VERIFY                489\n# define SSL_F_TLS_CONSTRUCT_CTOS_ALPN                    466\n# define SSL_F_TLS_CONSTRUCT_CTOS_CERTIFICATE             355\n# define SSL_F_TLS_CONSTRUCT_CTOS_COOKIE                  535\n# define SSL_F_TLS_CONSTRUCT_CTOS_EARLY_DATA              530\n# define SSL_F_TLS_CONSTRUCT_CTOS_EC_PT_FORMATS           467\n# define SSL_F_TLS_CONSTRUCT_CTOS_EMS                     468\n# define SSL_F_TLS_CONSTRUCT_CTOS_ETM                     469\n# define SSL_F_TLS_CONSTRUCT_CTOS_HELLO                   356\n# define SSL_F_TLS_CONSTRUCT_CTOS_KEY_EXCHANGE            357\n# define SSL_F_TLS_CONSTRUCT_CTOS_KEY_SHARE               470\n# define SSL_F_TLS_CONSTRUCT_CTOS_MAXFRAGMENTLEN          549\n# define SSL_F_TLS_CONSTRUCT_CTOS_NPN                     471\n# define SSL_F_TLS_CONSTRUCT_CTOS_PADDING                 472\n# define SSL_F_TLS_CONSTRUCT_CTOS_POST_HANDSHAKE_AUTH     619\n# define SSL_F_TLS_CONSTRUCT_CTOS_PSK                     501\n# define SSL_F_TLS_CONSTRUCT_CTOS_PSK_KEX_MODES           509\n# define SSL_F_TLS_CONSTRUCT_CTOS_RENEGOTIATE             473\n# define SSL_F_TLS_CONSTRUCT_CTOS_SCT                     474\n# define SSL_F_TLS_CONSTRUCT_CTOS_SERVER_NAME             475\n# define SSL_F_TLS_CONSTRUCT_CTOS_SESSION_TICKET          476\n# define SSL_F_TLS_CONSTRUCT_CTOS_SIG_ALGS                477\n# define SSL_F_TLS_CONSTRUCT_CTOS_SRP                     478\n# define SSL_F_TLS_CONSTRUCT_CTOS_STATUS_REQUEST          479\n# define SSL_F_TLS_CONSTRUCT_CTOS_SUPPORTED_GROUPS        480\n# define SSL_F_TLS_CONSTRUCT_CTOS_SUPPORTED_VERSIONS      481\n# define SSL_F_TLS_CONSTRUCT_CTOS_USE_SRTP                482\n# define SSL_F_TLS_CONSTRUCT_CTOS_VERIFY                  358\n# define SSL_F_TLS_CONSTRUCT_ENCRYPTED_EXTENSIONS         443\n# define SSL_F_TLS_CONSTRUCT_END_OF_EARLY_DATA            536\n# define SSL_F_TLS_CONSTRUCT_EXTENSIONS                   447\n# define SSL_F_TLS_CONSTRUCT_FINISHED                     359\n# define SSL_F_TLS_CONSTRUCT_HELLO_REQUEST                373\n# define SSL_F_TLS_CONSTRUCT_HELLO_RETRY_REQUEST          510\n# define SSL_F_TLS_CONSTRUCT_KEY_UPDATE                   517\n# define SSL_F_TLS_CONSTRUCT_NEW_SESSION_TICKET           428\n# define SSL_F_TLS_CONSTRUCT_NEXT_PROTO                   426\n# define SSL_F_TLS_CONSTRUCT_SERVER_CERTIFICATE           490\n# define SSL_F_TLS_CONSTRUCT_SERVER_HELLO                 491\n# define SSL_F_TLS_CONSTRUCT_SERVER_KEY_EXCHANGE          492\n# define SSL_F_TLS_CONSTRUCT_STOC_ALPN                    451\n# define SSL_F_TLS_CONSTRUCT_STOC_CERTIFICATE             374\n# define SSL_F_TLS_CONSTRUCT_STOC_COOKIE                  613\n# define SSL_F_TLS_CONSTRUCT_STOC_CRYPTOPRO_BUG           452\n# define SSL_F_TLS_CONSTRUCT_STOC_DONE                    375\n# define SSL_F_TLS_CONSTRUCT_STOC_EARLY_DATA              531\n# define SSL_F_TLS_CONSTRUCT_STOC_EARLY_DATA_INFO         525\n# define SSL_F_TLS_CONSTRUCT_STOC_EC_PT_FORMATS           453\n# define SSL_F_TLS_CONSTRUCT_STOC_EMS                     454\n# define SSL_F_TLS_CONSTRUCT_STOC_ETM                     455\n# define SSL_F_TLS_CONSTRUCT_STOC_HELLO                   376\n# define SSL_F_TLS_CONSTRUCT_STOC_KEY_EXCHANGE            377\n# define SSL_F_TLS_CONSTRUCT_STOC_KEY_SHARE               456\n# define SSL_F_TLS_CONSTRUCT_STOC_MAXFRAGMENTLEN          548\n# define SSL_F_TLS_CONSTRUCT_STOC_NEXT_PROTO_NEG          457\n# define SSL_F_TLS_CONSTRUCT_STOC_PSK                     504\n# define SSL_F_TLS_CONSTRUCT_STOC_RENEGOTIATE             458\n# define SSL_F_TLS_CONSTRUCT_STOC_SERVER_NAME             459\n# define SSL_F_TLS_CONSTRUCT_STOC_SESSION_TICKET          460\n# define SSL_F_TLS_CONSTRUCT_STOC_STATUS_REQUEST          461\n# define SSL_F_TLS_CONSTRUCT_STOC_SUPPORTED_GROUPS        544\n# define SSL_F_TLS_CONSTRUCT_STOC_SUPPORTED_VERSIONS      611\n# define SSL_F_TLS_CONSTRUCT_STOC_USE_SRTP                462\n# define SSL_F_TLS_EARLY_POST_PROCESS_CLIENT_HELLO        521\n# define SSL_F_TLS_FINISH_HANDSHAKE                       597\n# define SSL_F_TLS_GET_MESSAGE_BODY                       351\n# define SSL_F_TLS_GET_MESSAGE_HEADER                     387\n# define SSL_F_TLS_HANDLE_ALPN                            562\n# define SSL_F_TLS_HANDLE_STATUS_REQUEST                  563\n# define SSL_F_TLS_PARSE_CERTIFICATE_AUTHORITIES          566\n# define SSL_F_TLS_PARSE_CLIENTHELLO_TLSEXT               449\n# define SSL_F_TLS_PARSE_CTOS_ALPN                        567\n# define SSL_F_TLS_PARSE_CTOS_COOKIE                      614\n# define SSL_F_TLS_PARSE_CTOS_EARLY_DATA                  568\n# define SSL_F_TLS_PARSE_CTOS_EC_PT_FORMATS               569\n# define SSL_F_TLS_PARSE_CTOS_EMS                         570\n# define SSL_F_TLS_PARSE_CTOS_KEY_SHARE                   463\n# define SSL_F_TLS_PARSE_CTOS_MAXFRAGMENTLEN              571\n# define SSL_F_TLS_PARSE_CTOS_POST_HANDSHAKE_AUTH         620\n# define SSL_F_TLS_PARSE_CTOS_PSK                         505\n# define SSL_F_TLS_PARSE_CTOS_PSK_KEX_MODES               572\n# define SSL_F_TLS_PARSE_CTOS_RENEGOTIATE                 464\n# define SSL_F_TLS_PARSE_CTOS_SERVER_NAME                 573\n# define SSL_F_TLS_PARSE_CTOS_SESSION_TICKET              574\n# define SSL_F_TLS_PARSE_CTOS_SIG_ALGS                    575\n# define SSL_F_TLS_PARSE_CTOS_SIG_ALGS_CERT               615\n# define SSL_F_TLS_PARSE_CTOS_SRP                         576\n# define SSL_F_TLS_PARSE_CTOS_STATUS_REQUEST              577\n# define SSL_F_TLS_PARSE_CTOS_SUPPORTED_GROUPS            578\n# define SSL_F_TLS_PARSE_CTOS_USE_SRTP                    465\n# define SSL_F_TLS_PARSE_STOC_ALPN                        579\n# define SSL_F_TLS_PARSE_STOC_COOKIE                      534\n# define SSL_F_TLS_PARSE_STOC_EARLY_DATA                  538\n# define SSL_F_TLS_PARSE_STOC_EARLY_DATA_INFO             528\n# define SSL_F_TLS_PARSE_STOC_EC_PT_FORMATS               580\n# define SSL_F_TLS_PARSE_STOC_KEY_SHARE                   445\n# define SSL_F_TLS_PARSE_STOC_MAXFRAGMENTLEN              581\n# define SSL_F_TLS_PARSE_STOC_NPN                         582\n# define SSL_F_TLS_PARSE_STOC_PSK                         502\n# define SSL_F_TLS_PARSE_STOC_RENEGOTIATE                 448\n# define SSL_F_TLS_PARSE_STOC_SCT                         564\n# define SSL_F_TLS_PARSE_STOC_SERVER_NAME                 583\n# define SSL_F_TLS_PARSE_STOC_SESSION_TICKET              584\n# define SSL_F_TLS_PARSE_STOC_STATUS_REQUEST              585\n# define SSL_F_TLS_PARSE_STOC_SUPPORTED_VERSIONS          612\n# define SSL_F_TLS_PARSE_STOC_USE_SRTP                    446\n# define SSL_F_TLS_POST_PROCESS_CLIENT_HELLO              378\n# define SSL_F_TLS_POST_PROCESS_CLIENT_KEY_EXCHANGE       384\n# define SSL_F_TLS_PREPARE_CLIENT_CERTIFICATE             360\n# define SSL_F_TLS_PROCESS_AS_HELLO_RETRY_REQUEST         610\n# define SSL_F_TLS_PROCESS_CERTIFICATE_REQUEST            361\n# define SSL_F_TLS_PROCESS_CERT_STATUS                    362\n# define SSL_F_TLS_PROCESS_CERT_STATUS_BODY               495\n# define SSL_F_TLS_PROCESS_CERT_VERIFY                    379\n# define SSL_F_TLS_PROCESS_CHANGE_CIPHER_SPEC             363\n# define SSL_F_TLS_PROCESS_CKE_DHE                        411\n# define SSL_F_TLS_PROCESS_CKE_ECDHE                      412\n# define SSL_F_TLS_PROCESS_CKE_GOST                       413\n# define SSL_F_TLS_PROCESS_CKE_PSK_PREAMBLE               414\n# define SSL_F_TLS_PROCESS_CKE_RSA                        415\n# define SSL_F_TLS_PROCESS_CKE_SRP                        416\n# define SSL_F_TLS_PROCESS_CLIENT_CERTIFICATE             380\n# define SSL_F_TLS_PROCESS_CLIENT_HELLO                   381\n# define SSL_F_TLS_PROCESS_CLIENT_KEY_EXCHANGE            382\n# define SSL_F_TLS_PROCESS_ENCRYPTED_EXTENSIONS           444\n# define SSL_F_TLS_PROCESS_END_OF_EARLY_DATA              537\n# define SSL_F_TLS_PROCESS_FINISHED                       364\n# define SSL_F_TLS_PROCESS_HELLO_REQ                      507\n# define SSL_F_TLS_PROCESS_HELLO_RETRY_REQUEST            511\n# define SSL_F_TLS_PROCESS_INITIAL_SERVER_FLIGHT          442\n# define SSL_F_TLS_PROCESS_KEY_EXCHANGE                   365\n# define SSL_F_TLS_PROCESS_KEY_UPDATE                     518\n# define SSL_F_TLS_PROCESS_NEW_SESSION_TICKET             366\n# define SSL_F_TLS_PROCESS_NEXT_PROTO                     383\n# define SSL_F_TLS_PROCESS_SERVER_CERTIFICATE             367\n# define SSL_F_TLS_PROCESS_SERVER_DONE                    368\n# define SSL_F_TLS_PROCESS_SERVER_HELLO                   369\n# define SSL_F_TLS_PROCESS_SKE_DHE                        419\n# define SSL_F_TLS_PROCESS_SKE_ECDHE                      420\n# define SSL_F_TLS_PROCESS_SKE_PSK_PREAMBLE               421\n# define SSL_F_TLS_PROCESS_SKE_SRP                        422\n# define SSL_F_TLS_PSK_DO_BINDER                          506\n# define SSL_F_TLS_SCAN_CLIENTHELLO_TLSEXT                450\n# define SSL_F_TLS_SETUP_HANDSHAKE                        508\n# define SSL_F_USE_CERTIFICATE_CHAIN_FILE                 220\n# define SSL_F_WPACKET_INTERN_INIT_LEN                    633\n# define SSL_F_WPACKET_START_SUB_PACKET_LEN__             634\n# define SSL_F_WRITE_STATE_MACHINE                        586\n\n/*\n * SSL reason codes.\n */\n# define SSL_R_APPLICATION_DATA_AFTER_CLOSE_NOTIFY        291\n# define SSL_R_APP_DATA_IN_HANDSHAKE                      100\n# define SSL_R_ATTEMPT_TO_REUSE_SESSION_IN_DIFFERENT_CONTEXT 272\n# define SSL_R_AT_LEAST_TLS_1_0_NEEDED_IN_FIPS_MODE       143\n# define SSL_R_AT_LEAST_TLS_1_2_NEEDED_IN_SUITEB_MODE     158\n# define SSL_R_BAD_CHANGE_CIPHER_SPEC                     103\n# define SSL_R_BAD_CIPHER                                 186\n# define SSL_R_BAD_DATA                                   390\n# define SSL_R_BAD_DATA_RETURNED_BY_CALLBACK              106\n# define SSL_R_BAD_DECOMPRESSION                          107\n# define SSL_R_BAD_DH_VALUE                               102\n# define SSL_R_BAD_DIGEST_LENGTH                          111\n# define SSL_R_BAD_EARLY_DATA                             233\n# define SSL_R_BAD_ECC_CERT                               304\n# define SSL_R_BAD_ECPOINT                                306\n# define SSL_R_BAD_EXTENSION                              110\n# define SSL_R_BAD_HANDSHAKE_LENGTH                       332\n# define SSL_R_BAD_HANDSHAKE_STATE                        236\n# define SSL_R_BAD_HELLO_REQUEST                          105\n# define SSL_R_BAD_HRR_VERSION                            263\n# define SSL_R_BAD_KEY_SHARE                              108\n# define SSL_R_BAD_KEY_UPDATE                             122\n# define SSL_R_BAD_LEGACY_VERSION                         292\n# define SSL_R_BAD_LENGTH                                 271\n# define SSL_R_BAD_PACKET                                 240\n# define SSL_R_BAD_PACKET_LENGTH                          115\n# define SSL_R_BAD_PROTOCOL_VERSION_NUMBER                116\n# define SSL_R_BAD_PSK                                    219\n# define SSL_R_BAD_PSK_IDENTITY                           114\n# define SSL_R_BAD_RECORD_TYPE                            443\n# define SSL_R_BAD_RSA_ENCRYPT                            119\n# define SSL_R_BAD_SIGNATURE                              123\n# define SSL_R_BAD_SRP_A_LENGTH                           347\n# define SSL_R_BAD_SRP_PARAMETERS                         371\n# define SSL_R_BAD_SRTP_MKI_VALUE                         352\n# define SSL_R_BAD_SRTP_PROTECTION_PROFILE_LIST           353\n# define SSL_R_BAD_SSL_FILETYPE                           124\n# define SSL_R_BAD_VALUE                                  384\n# define SSL_R_BAD_WRITE_RETRY                            127\n# define SSL_R_BINDER_DOES_NOT_VERIFY                     253\n# define SSL_R_BIO_NOT_SET                                128\n# define SSL_R_BLOCK_CIPHER_PAD_IS_WRONG                  129\n# define SSL_R_BN_LIB                                     130\n# define SSL_R_CALLBACK_FAILED                            234\n# define SSL_R_CANNOT_CHANGE_CIPHER                       109\n# define SSL_R_CA_DN_LENGTH_MISMATCH                      131\n# define SSL_R_CA_KEY_TOO_SMALL                           397\n# define SSL_R_CA_MD_TOO_WEAK                             398\n# define SSL_R_CCS_RECEIVED_EARLY                         133\n# define SSL_R_CERTIFICATE_VERIFY_FAILED                  134\n# define SSL_R_CERT_CB_ERROR                              377\n# define SSL_R_CERT_LENGTH_MISMATCH                       135\n# define SSL_R_CIPHERSUITE_DIGEST_HAS_CHANGED             218\n# define SSL_R_CIPHER_CODE_WRONG_LENGTH                   137\n# define SSL_R_CIPHER_OR_HASH_UNAVAILABLE                 138\n# define SSL_R_CLIENTHELLO_TLSEXT                         226\n# define SSL_R_COMPRESSED_LENGTH_TOO_LONG                 140\n# define SSL_R_COMPRESSION_DISABLED                       343\n# define SSL_R_COMPRESSION_FAILURE                        141\n# define SSL_R_COMPRESSION_ID_NOT_WITHIN_PRIVATE_RANGE    307\n# define SSL_R_COMPRESSION_LIBRARY_ERROR                  142\n# define SSL_R_CONNECTION_TYPE_NOT_SET                    144\n# define SSL_R_CONTEXT_NOT_DANE_ENABLED                   167\n# define SSL_R_COOKIE_GEN_CALLBACK_FAILURE                400\n# define SSL_R_COOKIE_MISMATCH                            308\n# define SSL_R_CUSTOM_EXT_HANDLER_ALREADY_INSTALLED       206\n# define SSL_R_DANE_ALREADY_ENABLED                       172\n# define SSL_R_DANE_CANNOT_OVERRIDE_MTYPE_FULL            173\n# define SSL_R_DANE_NOT_ENABLED                           175\n# define SSL_R_DANE_TLSA_BAD_CERTIFICATE                  180\n# define SSL_R_DANE_TLSA_BAD_CERTIFICATE_USAGE            184\n# define SSL_R_DANE_TLSA_BAD_DATA_LENGTH                  189\n# define SSL_R_DANE_TLSA_BAD_DIGEST_LENGTH                192\n# define SSL_R_DANE_TLSA_BAD_MATCHING_TYPE                200\n# define SSL_R_DANE_TLSA_BAD_PUBLIC_KEY                   201\n# define SSL_R_DANE_TLSA_BAD_SELECTOR                     202\n# define SSL_R_DANE_TLSA_NULL_DATA                        203\n# define SSL_R_DATA_BETWEEN_CCS_AND_FINISHED              145\n# define SSL_R_DATA_LENGTH_TOO_LONG                       146\n# define SSL_R_DECRYPTION_FAILED                          147\n# define SSL_R_DECRYPTION_FAILED_OR_BAD_RECORD_MAC        281\n# define SSL_R_DH_KEY_TOO_SMALL                           394\n# define SSL_R_DH_PUBLIC_VALUE_LENGTH_IS_WRONG            148\n# define SSL_R_DIGEST_CHECK_FAILED                        149\n# define SSL_R_DTLS_MESSAGE_TOO_BIG                       334\n# define SSL_R_DUPLICATE_COMPRESSION_ID                   309\n# define SSL_R_ECC_CERT_NOT_FOR_SIGNING                   318\n# define SSL_R_ECDH_REQUIRED_FOR_SUITEB_MODE              374\n# define SSL_R_EE_KEY_TOO_SMALL                           399\n# define SSL_R_EMPTY_SRTP_PROTECTION_PROFILE_LIST         354\n# define SSL_R_ENCRYPTED_LENGTH_TOO_LONG                  150\n# define SSL_R_ERROR_IN_RECEIVED_CIPHER_LIST              151\n# define SSL_R_ERROR_SETTING_TLSA_BASE_DOMAIN             204\n# define SSL_R_EXCEEDS_MAX_FRAGMENT_SIZE                  194\n# define SSL_R_EXCESSIVE_MESSAGE_SIZE                     152\n# define SSL_R_EXTENSION_NOT_RECEIVED                     279\n# define SSL_R_EXTRA_DATA_IN_MESSAGE                      153\n# define SSL_R_EXT_LENGTH_MISMATCH                        163\n# define SSL_R_FAILED_TO_INIT_ASYNC                       405\n# define SSL_R_FRAGMENTED_CLIENT_HELLO                    401\n# define SSL_R_GOT_A_FIN_BEFORE_A_CCS                     154\n# define SSL_R_HTTPS_PROXY_REQUEST                        155\n# define SSL_R_HTTP_REQUEST                               156\n# define SSL_R_ILLEGAL_POINT_COMPRESSION                  162\n# define SSL_R_ILLEGAL_SUITEB_DIGEST                      380\n# define SSL_R_INAPPROPRIATE_FALLBACK                     373\n# define SSL_R_INCONSISTENT_COMPRESSION                   340\n# define SSL_R_INCONSISTENT_EARLY_DATA_ALPN               222\n# define SSL_R_INCONSISTENT_EARLY_DATA_SNI                231\n# define SSL_R_INCONSISTENT_EXTMS                         104\n# define SSL_R_INSUFFICIENT_SECURITY                      241\n# define SSL_R_INVALID_ALERT                              205\n# define SSL_R_INVALID_CCS_MESSAGE                        260\n# define SSL_R_INVALID_CERTIFICATE_OR_ALG                 238\n# define SSL_R_INVALID_COMMAND                            280\n# define SSL_R_INVALID_COMPRESSION_ALGORITHM              341\n# define SSL_R_INVALID_CONFIG                             283\n# define SSL_R_INVALID_CONFIGURATION_NAME                 113\n# define SSL_R_INVALID_CONTEXT                            282\n# define SSL_R_INVALID_CT_VALIDATION_TYPE                 212\n# define SSL_R_INVALID_KEY_UPDATE_TYPE                    120\n# define SSL_R_INVALID_MAX_EARLY_DATA                     174\n# define SSL_R_INVALID_NULL_CMD_NAME                      385\n# define SSL_R_INVALID_SEQUENCE_NUMBER                    402\n# define SSL_R_INVALID_SERVERINFO_DATA                    388\n# define SSL_R_INVALID_SESSION_ID                         999\n# define SSL_R_INVALID_SRP_USERNAME                       357\n# define SSL_R_INVALID_STATUS_RESPONSE                    328\n# define SSL_R_INVALID_TICKET_KEYS_LENGTH                 325\n# define SSL_R_LENGTH_MISMATCH                            159\n# define SSL_R_LENGTH_TOO_LONG                            404\n# define SSL_R_LENGTH_TOO_SHORT                           160\n# define SSL_R_LIBRARY_BUG                                274\n# define SSL_R_LIBRARY_HAS_NO_CIPHERS                     161\n# define SSL_R_MISSING_DSA_SIGNING_CERT                   165\n# define SSL_R_MISSING_ECDSA_SIGNING_CERT                 381\n# define SSL_R_MISSING_FATAL                              256\n# define SSL_R_MISSING_PARAMETERS                         290\n# define SSL_R_MISSING_PSK_KEX_MODES_EXTENSION            310\n# define SSL_R_MISSING_RSA_CERTIFICATE                    168\n# define SSL_R_MISSING_RSA_ENCRYPTING_CERT                169\n# define SSL_R_MISSING_RSA_SIGNING_CERT                   170\n# define SSL_R_MISSING_SIGALGS_EXTENSION                  112\n# define SSL_R_MISSING_SIGNING_CERT                       221\n# define SSL_R_MISSING_SRP_PARAM                          358\n# define SSL_R_MISSING_SUPPORTED_GROUPS_EXTENSION         209\n# define SSL_R_MISSING_TMP_DH_KEY                         171\n# define SSL_R_MISSING_TMP_ECDH_KEY                       311\n# define SSL_R_MIXED_HANDSHAKE_AND_NON_HANDSHAKE_DATA     293\n# define SSL_R_NOT_ON_RECORD_BOUNDARY                     182\n# define SSL_R_NOT_REPLACING_CERTIFICATE                  289\n# define SSL_R_NOT_SERVER                                 284\n# define SSL_R_NO_APPLICATION_PROTOCOL                    235\n# define SSL_R_NO_CERTIFICATES_RETURNED                   176\n# define SSL_R_NO_CERTIFICATE_ASSIGNED                    177\n# define SSL_R_NO_CERTIFICATE_SET                         179\n# define SSL_R_NO_CHANGE_FOLLOWING_HRR                    214\n# define SSL_R_NO_CIPHERS_AVAILABLE                       181\n# define SSL_R_NO_CIPHERS_SPECIFIED                       183\n# define SSL_R_NO_CIPHER_MATCH                            185\n# define SSL_R_NO_CLIENT_CERT_METHOD                      331\n# define SSL_R_NO_COMPRESSION_SPECIFIED                   187\n# define SSL_R_NO_COOKIE_CALLBACK_SET                     287\n# define SSL_R_NO_GOST_CERTIFICATE_SENT_BY_PEER           330\n# define SSL_R_NO_METHOD_SPECIFIED                        188\n# define SSL_R_NO_PEM_EXTENSIONS                          389\n# define SSL_R_NO_PRIVATE_KEY_ASSIGNED                    190\n# define SSL_R_NO_PROTOCOLS_AVAILABLE                     191\n# define SSL_R_NO_RENEGOTIATION                           339\n# define SSL_R_NO_REQUIRED_DIGEST                         324\n# define SSL_R_NO_SHARED_CIPHER                           193\n# define SSL_R_NO_SHARED_GROUPS                           410\n# define SSL_R_NO_SHARED_SIGNATURE_ALGORITHMS             376\n# define SSL_R_NO_SRTP_PROFILES                           359\n# define SSL_R_NO_SUITABLE_KEY_SHARE                      101\n# define SSL_R_NO_SUITABLE_SIGNATURE_ALGORITHM            118\n# define SSL_R_NO_VALID_SCTS                              216\n# define SSL_R_NO_VERIFY_COOKIE_CALLBACK                  403\n# define SSL_R_NULL_SSL_CTX                               195\n# define SSL_R_NULL_SSL_METHOD_PASSED                     196\n# define SSL_R_OCSP_CALLBACK_FAILURE                      294\n# define SSL_R_OLD_SESSION_CIPHER_NOT_RETURNED            197\n# define SSL_R_OLD_SESSION_COMPRESSION_ALGORITHM_NOT_RETURNED 344\n# define SSL_R_OVERFLOW_ERROR                             237\n# define SSL_R_PACKET_LENGTH_TOO_LONG                     198\n# define SSL_R_PARSE_TLSEXT                               227\n# define SSL_R_PATH_TOO_LONG                              270\n# define SSL_R_PEER_DID_NOT_RETURN_A_CERTIFICATE          199\n# define SSL_R_PEM_NAME_BAD_PREFIX                        391\n# define SSL_R_PEM_NAME_TOO_SHORT                         392\n# define SSL_R_PIPELINE_FAILURE                           406\n# define SSL_R_POST_HANDSHAKE_AUTH_ENCODING_ERR           278\n# define SSL_R_PRIVATE_KEY_MISMATCH                       288\n# define SSL_R_PROTOCOL_IS_SHUTDOWN                       207\n# define SSL_R_PSK_IDENTITY_NOT_FOUND                     223\n# define SSL_R_PSK_NO_CLIENT_CB                           224\n# define SSL_R_PSK_NO_SERVER_CB                           225\n# define SSL_R_READ_BIO_NOT_SET                           211\n# define SSL_R_READ_TIMEOUT_EXPIRED                       312\n# define SSL_R_RECORD_LENGTH_MISMATCH                     213\n# define SSL_R_RECORD_TOO_SMALL                           298\n# define SSL_R_RENEGOTIATE_EXT_TOO_LONG                   335\n# define SSL_R_RENEGOTIATION_ENCODING_ERR                 336\n# define SSL_R_RENEGOTIATION_MISMATCH                     337\n# define SSL_R_REQUEST_PENDING                            285\n# define SSL_R_REQUEST_SENT                               286\n# define SSL_R_REQUIRED_CIPHER_MISSING                    215\n# define SSL_R_REQUIRED_COMPRESSION_ALGORITHM_MISSING     342\n# define SSL_R_SCSV_RECEIVED_WHEN_RENEGOTIATING           345\n# define SSL_R_SCT_VERIFICATION_FAILED                    208\n# define SSL_R_SERVERHELLO_TLSEXT                         275\n# define SSL_R_SESSION_ID_CONTEXT_UNINITIALIZED           277\n# define SSL_R_SHUTDOWN_WHILE_IN_INIT                     407\n# define SSL_R_SIGNATURE_ALGORITHMS_ERROR                 360\n# define SSL_R_SIGNATURE_FOR_NON_SIGNING_CERTIFICATE      220\n# define SSL_R_SRP_A_CALC                                 361\n# define SSL_R_SRTP_COULD_NOT_ALLOCATE_PROFILES           362\n# define SSL_R_SRTP_PROTECTION_PROFILE_LIST_TOO_LONG      363\n# define SSL_R_SRTP_UNKNOWN_PROTECTION_PROFILE            364\n# define SSL_R_SSL3_EXT_INVALID_MAX_FRAGMENT_LENGTH       232\n# define SSL_R_SSL3_EXT_INVALID_SERVERNAME                319\n# define SSL_R_SSL3_EXT_INVALID_SERVERNAME_TYPE           320\n# define SSL_R_SSL3_SESSION_ID_TOO_LONG                   300\n# define SSL_R_SSLV3_ALERT_BAD_CERTIFICATE                1042\n# define SSL_R_SSLV3_ALERT_BAD_RECORD_MAC                 1020\n# define SSL_R_SSLV3_ALERT_CERTIFICATE_EXPIRED            1045\n# define SSL_R_SSLV3_ALERT_CERTIFICATE_REVOKED            1044\n# define SSL_R_SSLV3_ALERT_CERTIFICATE_UNKNOWN            1046\n# define SSL_R_SSLV3_ALERT_DECOMPRESSION_FAILURE          1030\n# define SSL_R_SSLV3_ALERT_HANDSHAKE_FAILURE              1040\n# define SSL_R_SSLV3_ALERT_ILLEGAL_PARAMETER              1047\n# define SSL_R_SSLV3_ALERT_NO_CERTIFICATE                 1041\n# define SSL_R_SSLV3_ALERT_UNEXPECTED_MESSAGE             1010\n# define SSL_R_SSLV3_ALERT_UNSUPPORTED_CERTIFICATE        1043\n# define SSL_R_SSL_COMMAND_SECTION_EMPTY                  117\n# define SSL_R_SSL_COMMAND_SECTION_NOT_FOUND              125\n# define SSL_R_SSL_CTX_HAS_NO_DEFAULT_SSL_VERSION         228\n# define SSL_R_SSL_HANDSHAKE_FAILURE                      229\n# define SSL_R_SSL_LIBRARY_HAS_NO_CIPHERS                 230\n# define SSL_R_SSL_NEGATIVE_LENGTH                        372\n# define SSL_R_SSL_SECTION_EMPTY                          126\n# define SSL_R_SSL_SECTION_NOT_FOUND                      136\n# define SSL_R_SSL_SESSION_ID_CALLBACK_FAILED             301\n# define SSL_R_SSL_SESSION_ID_CONFLICT                    302\n# define SSL_R_SSL_SESSION_ID_CONTEXT_TOO_LONG            273\n# define SSL_R_SSL_SESSION_ID_HAS_BAD_LENGTH              303\n# define SSL_R_SSL_SESSION_ID_TOO_LONG                    408\n# define SSL_R_SSL_SESSION_VERSION_MISMATCH               210\n# define SSL_R_STILL_IN_INIT                              121\n# define SSL_R_TLSV13_ALERT_CERTIFICATE_REQUIRED          1116\n# define SSL_R_TLSV13_ALERT_MISSING_EXTENSION             1109\n# define SSL_R_TLSV1_ALERT_ACCESS_DENIED                  1049\n# define SSL_R_TLSV1_ALERT_DECODE_ERROR                   1050\n# define SSL_R_TLSV1_ALERT_DECRYPTION_FAILED              1021\n# define SSL_R_TLSV1_ALERT_DECRYPT_ERROR                  1051\n# define SSL_R_TLSV1_ALERT_EXPORT_RESTRICTION             1060\n# define SSL_R_TLSV1_ALERT_INAPPROPRIATE_FALLBACK         1086\n# define SSL_R_TLSV1_ALERT_INSUFFICIENT_SECURITY          1071\n# define SSL_R_TLSV1_ALERT_INTERNAL_ERROR                 1080\n# define SSL_R_TLSV1_ALERT_NO_RENEGOTIATION               1100\n# define SSL_R_TLSV1_ALERT_PROTOCOL_VERSION               1070\n# define SSL_R_TLSV1_ALERT_RECORD_OVERFLOW                1022\n# define SSL_R_TLSV1_ALERT_UNKNOWN_CA                     1048\n# define SSL_R_TLSV1_ALERT_USER_CANCELLED                 1090\n# define SSL_R_TLSV1_BAD_CERTIFICATE_HASH_VALUE           1114\n# define SSL_R_TLSV1_BAD_CERTIFICATE_STATUS_RESPONSE      1113\n# define SSL_R_TLSV1_CERTIFICATE_UNOBTAINABLE             1111\n# define SSL_R_TLSV1_UNRECOGNIZED_NAME                    1112\n# define SSL_R_TLSV1_UNSUPPORTED_EXTENSION                1110\n# define SSL_R_TLS_HEARTBEAT_PEER_DOESNT_ACCEPT           365\n# define SSL_R_TLS_HEARTBEAT_PENDING                      366\n# define SSL_R_TLS_ILLEGAL_EXPORTER_LABEL                 367\n# define SSL_R_TLS_INVALID_ECPOINTFORMAT_LIST             157\n# define SSL_R_TOO_MANY_KEY_UPDATES                       132\n# define SSL_R_TOO_MANY_WARN_ALERTS                       409\n# define SSL_R_TOO_MUCH_EARLY_DATA                        164\n# define SSL_R_UNABLE_TO_FIND_ECDH_PARAMETERS             314\n# define SSL_R_UNABLE_TO_FIND_PUBLIC_KEY_PARAMETERS       239\n# define SSL_R_UNABLE_TO_LOAD_SSL3_MD5_ROUTINES           242\n# define SSL_R_UNABLE_TO_LOAD_SSL3_SHA1_ROUTINES          243\n# define SSL_R_UNEXPECTED_CCS_MESSAGE                     262\n# define SSL_R_UNEXPECTED_END_OF_EARLY_DATA               178\n# define SSL_R_UNEXPECTED_MESSAGE                         244\n# define SSL_R_UNEXPECTED_RECORD                          245\n# define SSL_R_UNINITIALIZED                              276\n# define SSL_R_UNKNOWN_ALERT_TYPE                         246\n# define SSL_R_UNKNOWN_CERTIFICATE_TYPE                   247\n# define SSL_R_UNKNOWN_CIPHER_RETURNED                    248\n# define SSL_R_UNKNOWN_CIPHER_TYPE                        249\n# define SSL_R_UNKNOWN_CMD_NAME                           386\n# define SSL_R_UNKNOWN_COMMAND                            139\n# define SSL_R_UNKNOWN_DIGEST                             368\n# define SSL_R_UNKNOWN_KEY_EXCHANGE_TYPE                  250\n# define SSL_R_UNKNOWN_PKEY_TYPE                          251\n# define SSL_R_UNKNOWN_PROTOCOL                           252\n# define SSL_R_UNKNOWN_SSL_VERSION                        254\n# define SSL_R_UNKNOWN_STATE                              255\n# define SSL_R_UNSAFE_LEGACY_RENEGOTIATION_DISABLED       338\n# define SSL_R_UNSOLICITED_EXTENSION                      217\n# define SSL_R_UNSUPPORTED_COMPRESSION_ALGORITHM          257\n# define SSL_R_UNSUPPORTED_ELLIPTIC_CURVE                 315\n# define SSL_R_UNSUPPORTED_PROTOCOL                       258\n# define SSL_R_UNSUPPORTED_SSL_VERSION                    259\n# define SSL_R_UNSUPPORTED_STATUS_TYPE                    329\n# define SSL_R_USE_SRTP_NOT_NEGOTIATED                    369\n# define SSL_R_VERSION_TOO_HIGH                           166\n# define SSL_R_VERSION_TOO_LOW                            396\n# define SSL_R_WRONG_CERTIFICATE_TYPE                     383\n# define SSL_R_WRONG_CIPHER_RETURNED                      261\n# define SSL_R_WRONG_CURVE                                378\n# define SSL_R_WRONG_SIGNATURE_LENGTH                     264\n# define SSL_R_WRONG_SIGNATURE_SIZE                       265\n# define SSL_R_WRONG_SIGNATURE_TYPE                       370\n# define SSL_R_WRONG_SSL_VERSION                          266\n# define SSL_R_WRONG_VERSION_NUMBER                       267\n# define SSL_R_X509_LIB                                   268\n# define SSL_R_X509_VERIFICATION_SETUP_PROBLEMS           269\n\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/include/openssl/stack.h",
    "content": "/*\n * Copyright 1995-2017 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef HEADER_STACK_H\n# define HEADER_STACK_H\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\ntypedef struct stack_st OPENSSL_STACK; /* Use STACK_OF(...) instead */\n\ntypedef int (*OPENSSL_sk_compfunc)(const void *, const void *);\ntypedef void (*OPENSSL_sk_freefunc)(void *);\ntypedef void *(*OPENSSL_sk_copyfunc)(const void *);\n\nint OPENSSL_sk_num(const OPENSSL_STACK *);\nvoid *OPENSSL_sk_value(const OPENSSL_STACK *, int);\n\nvoid *OPENSSL_sk_set(OPENSSL_STACK *st, int i, const void *data);\n\nOPENSSL_STACK *OPENSSL_sk_new(OPENSSL_sk_compfunc cmp);\nOPENSSL_STACK *OPENSSL_sk_new_null(void);\nOPENSSL_STACK *OPENSSL_sk_new_reserve(OPENSSL_sk_compfunc c, int n);\nint OPENSSL_sk_reserve(OPENSSL_STACK *st, int n);\nvoid OPENSSL_sk_free(OPENSSL_STACK *);\nvoid OPENSSL_sk_pop_free(OPENSSL_STACK *st, void (*func) (void *));\nOPENSSL_STACK *OPENSSL_sk_deep_copy(const OPENSSL_STACK *,\n                                    OPENSSL_sk_copyfunc c,\n                                    OPENSSL_sk_freefunc f);\nint OPENSSL_sk_insert(OPENSSL_STACK *sk, const void *data, int where);\nvoid *OPENSSL_sk_delete(OPENSSL_STACK *st, int loc);\nvoid *OPENSSL_sk_delete_ptr(OPENSSL_STACK *st, const void *p);\nint OPENSSL_sk_find(OPENSSL_STACK *st, const void *data);\nint OPENSSL_sk_find_ex(OPENSSL_STACK *st, const void *data);\nint OPENSSL_sk_push(OPENSSL_STACK *st, const void *data);\nint OPENSSL_sk_unshift(OPENSSL_STACK *st, const void *data);\nvoid *OPENSSL_sk_shift(OPENSSL_STACK *st);\nvoid *OPENSSL_sk_pop(OPENSSL_STACK *st);\nvoid OPENSSL_sk_zero(OPENSSL_STACK *st);\nOPENSSL_sk_compfunc OPENSSL_sk_set_cmp_func(OPENSSL_STACK *sk,\n                                            OPENSSL_sk_compfunc cmp);\nOPENSSL_STACK *OPENSSL_sk_dup(const OPENSSL_STACK *st);\nvoid OPENSSL_sk_sort(OPENSSL_STACK *st);\nint OPENSSL_sk_is_sorted(const OPENSSL_STACK *st);\n\n# if OPENSSL_API_COMPAT < 0x10100000L\n#  define _STACK OPENSSL_STACK\n#  define sk_num OPENSSL_sk_num\n#  define sk_value OPENSSL_sk_value\n#  define sk_set OPENSSL_sk_set\n#  define sk_new OPENSSL_sk_new\n#  define sk_new_null OPENSSL_sk_new_null\n#  define sk_free OPENSSL_sk_free\n#  define sk_pop_free OPENSSL_sk_pop_free\n#  define sk_deep_copy OPENSSL_sk_deep_copy\n#  define sk_insert OPENSSL_sk_insert\n#  define sk_delete OPENSSL_sk_delete\n#  define sk_delete_ptr OPENSSL_sk_delete_ptr\n#  define sk_find OPENSSL_sk_find\n#  define sk_find_ex OPENSSL_sk_find_ex\n#  define sk_push OPENSSL_sk_push\n#  define sk_unshift OPENSSL_sk_unshift\n#  define sk_shift OPENSSL_sk_shift\n#  define sk_pop OPENSSL_sk_pop\n#  define sk_zero OPENSSL_sk_zero\n#  define sk_set_cmp_func OPENSSL_sk_set_cmp_func\n#  define sk_dup OPENSSL_sk_dup\n#  define sk_sort OPENSSL_sk_sort\n#  define sk_is_sorted OPENSSL_sk_is_sorted\n# endif\n\n#ifdef  __cplusplus\n}\n#endif\n\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/include/openssl/store.h",
    "content": "/*\n * Copyright 2016-2019 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef HEADER_OSSL_STORE_H\n# define HEADER_OSSL_STORE_H\n\n# include <stdarg.h>\n# include <openssl/ossl_typ.h>\n# include <openssl/pem.h>\n# include <openssl/storeerr.h>\n\n# ifdef  __cplusplus\nextern \"C\" {\n# endif\n\n/*-\n *  The main OSSL_STORE functions.\n *  ------------------------------\n *\n *  These allow applications to open a channel to a resource with supported\n *  data (keys, certs, crls, ...), read the data a piece at a time and decide\n *  what to do with it, and finally close.\n */\n\ntypedef struct ossl_store_ctx_st OSSL_STORE_CTX;\n\n/*\n * Typedef for the OSSL_STORE_INFO post processing callback.  This can be used\n * to massage the given OSSL_STORE_INFO, or to drop it entirely (by returning\n * NULL).\n */\ntypedef OSSL_STORE_INFO *(*OSSL_STORE_post_process_info_fn)(OSSL_STORE_INFO *,\n                                                            void *);\n\n/*\n * Open a channel given a URI.  The given UI method will be used any time the\n * loader needs extra input, for example when a password or pin is needed, and\n * will be passed the same user data every time it's needed in this context.\n *\n * Returns a context reference which represents the channel to communicate\n * through.\n */\nOSSL_STORE_CTX *OSSL_STORE_open(const char *uri, const UI_METHOD *ui_method,\n                                void *ui_data,\n                                OSSL_STORE_post_process_info_fn post_process,\n                                void *post_process_data);\n\n/*\n * Control / fine tune the OSSL_STORE channel.  |cmd| determines what is to be\n * done, and depends on the underlying loader (use OSSL_STORE_get0_scheme to\n * determine which loader is used), except for common commands (see below).\n * Each command takes different arguments.\n */\nint OSSL_STORE_ctrl(OSSL_STORE_CTX *ctx, int cmd, ... /* args */);\nint OSSL_STORE_vctrl(OSSL_STORE_CTX *ctx, int cmd, va_list args);\n\n/*\n * Common ctrl commands that different loaders may choose to support.\n */\n/* int on = 0 or 1; STORE_ctrl(ctx, STORE_C_USE_SECMEM, &on); */\n# define OSSL_STORE_C_USE_SECMEM      1\n/* Where custom commands start */\n# define OSSL_STORE_C_CUSTOM_START    100\n\n/*\n * Read one data item (a key, a cert, a CRL) that is supported by the OSSL_STORE\n * functionality, given a context.\n * Returns a OSSL_STORE_INFO pointer, from which OpenSSL typed data can be\n * extracted with OSSL_STORE_INFO_get0_PKEY(), OSSL_STORE_INFO_get0_CERT(), ...\n * NULL is returned on error, which may include that the data found at the URI\n * can't be figured out for certain or is ambiguous.\n */\nOSSL_STORE_INFO *OSSL_STORE_load(OSSL_STORE_CTX *ctx);\n\n/*\n * Check if end of data (end of file) is reached\n * Returns 1 on end, 0 otherwise.\n */\nint OSSL_STORE_eof(OSSL_STORE_CTX *ctx);\n\n/*\n * Check if an error occurred\n * Returns 1 if it did, 0 otherwise.\n */\nint OSSL_STORE_error(OSSL_STORE_CTX *ctx);\n\n/*\n * Close the channel\n * Returns 1 on success, 0 on error.\n */\nint OSSL_STORE_close(OSSL_STORE_CTX *ctx);\n\n\n/*-\n *  Extracting OpenSSL types from and creating new OSSL_STORE_INFOs\n *  ---------------------------------------------------------------\n */\n\n/*\n * Types of data that can be ossl_stored in a OSSL_STORE_INFO.\n * OSSL_STORE_INFO_NAME is typically found when getting a listing of\n * available \"files\" / \"tokens\" / what have you.\n */\n# define OSSL_STORE_INFO_NAME           1   /* char * */\n# define OSSL_STORE_INFO_PARAMS         2   /* EVP_PKEY * */\n# define OSSL_STORE_INFO_PKEY           3   /* EVP_PKEY * */\n# define OSSL_STORE_INFO_CERT           4   /* X509 * */\n# define OSSL_STORE_INFO_CRL            5   /* X509_CRL * */\n\n/*\n * Functions to generate OSSL_STORE_INFOs, one function for each type we\n * support having in them, as well as a generic constructor.\n *\n * In all cases, ownership of the object is transferred to the OSSL_STORE_INFO\n * and will therefore be freed when the OSSL_STORE_INFO is freed.\n */\nOSSL_STORE_INFO *OSSL_STORE_INFO_new_NAME(char *name);\nint OSSL_STORE_INFO_set0_NAME_description(OSSL_STORE_INFO *info, char *desc);\nOSSL_STORE_INFO *OSSL_STORE_INFO_new_PARAMS(EVP_PKEY *params);\nOSSL_STORE_INFO *OSSL_STORE_INFO_new_PKEY(EVP_PKEY *pkey);\nOSSL_STORE_INFO *OSSL_STORE_INFO_new_CERT(X509 *x509);\nOSSL_STORE_INFO *OSSL_STORE_INFO_new_CRL(X509_CRL *crl);\n\n/*\n * Functions to try to extract data from a OSSL_STORE_INFO.\n */\nint OSSL_STORE_INFO_get_type(const OSSL_STORE_INFO *info);\nconst char *OSSL_STORE_INFO_get0_NAME(const OSSL_STORE_INFO *info);\nchar *OSSL_STORE_INFO_get1_NAME(const OSSL_STORE_INFO *info);\nconst char *OSSL_STORE_INFO_get0_NAME_description(const OSSL_STORE_INFO *info);\nchar *OSSL_STORE_INFO_get1_NAME_description(const OSSL_STORE_INFO *info);\nEVP_PKEY *OSSL_STORE_INFO_get0_PARAMS(const OSSL_STORE_INFO *info);\nEVP_PKEY *OSSL_STORE_INFO_get1_PARAMS(const OSSL_STORE_INFO *info);\nEVP_PKEY *OSSL_STORE_INFO_get0_PKEY(const OSSL_STORE_INFO *info);\nEVP_PKEY *OSSL_STORE_INFO_get1_PKEY(const OSSL_STORE_INFO *info);\nX509 *OSSL_STORE_INFO_get0_CERT(const OSSL_STORE_INFO *info);\nX509 *OSSL_STORE_INFO_get1_CERT(const OSSL_STORE_INFO *info);\nX509_CRL *OSSL_STORE_INFO_get0_CRL(const OSSL_STORE_INFO *info);\nX509_CRL *OSSL_STORE_INFO_get1_CRL(const OSSL_STORE_INFO *info);\n\nconst char *OSSL_STORE_INFO_type_string(int type);\n\n/*\n * Free the OSSL_STORE_INFO\n */\nvoid OSSL_STORE_INFO_free(OSSL_STORE_INFO *info);\n\n\n/*-\n *  Functions to construct a search URI from a base URI and search criteria\n *  -----------------------------------------------------------------------\n */\n\n/* OSSL_STORE search types */\n# define OSSL_STORE_SEARCH_BY_NAME              1 /* subject in certs, issuer in CRLs */\n# define OSSL_STORE_SEARCH_BY_ISSUER_SERIAL     2\n# define OSSL_STORE_SEARCH_BY_KEY_FINGERPRINT   3\n# define OSSL_STORE_SEARCH_BY_ALIAS             4\n\n/* To check what search types the scheme handler supports */\nint OSSL_STORE_supports_search(OSSL_STORE_CTX *ctx, int search_type);\n\n/* Search term constructors */\n/*\n * The input is considered to be owned by the caller, and must therefore\n * remain present throughout the lifetime of the returned OSSL_STORE_SEARCH\n */\nOSSL_STORE_SEARCH *OSSL_STORE_SEARCH_by_name(X509_NAME *name);\nOSSL_STORE_SEARCH *OSSL_STORE_SEARCH_by_issuer_serial(X509_NAME *name,\n                                                      const ASN1_INTEGER\n                                                      *serial);\nOSSL_STORE_SEARCH *OSSL_STORE_SEARCH_by_key_fingerprint(const EVP_MD *digest,\n                                                        const unsigned char\n                                                        *bytes, size_t len);\nOSSL_STORE_SEARCH *OSSL_STORE_SEARCH_by_alias(const char *alias);\n\n/* Search term destructor */\nvoid OSSL_STORE_SEARCH_free(OSSL_STORE_SEARCH *search);\n\n/* Search term accessors */\nint OSSL_STORE_SEARCH_get_type(const OSSL_STORE_SEARCH *criterion);\nX509_NAME *OSSL_STORE_SEARCH_get0_name(OSSL_STORE_SEARCH *criterion);\nconst ASN1_INTEGER *OSSL_STORE_SEARCH_get0_serial(const OSSL_STORE_SEARCH\n                                                  *criterion);\nconst unsigned char *OSSL_STORE_SEARCH_get0_bytes(const OSSL_STORE_SEARCH\n                                                  *criterion, size_t *length);\nconst char *OSSL_STORE_SEARCH_get0_string(const OSSL_STORE_SEARCH *criterion);\nconst EVP_MD *OSSL_STORE_SEARCH_get0_digest(const OSSL_STORE_SEARCH *criterion);\n\n/*\n * Add search criterion and expected return type (which can be unspecified)\n * to the loading channel.  This MUST happen before the first OSSL_STORE_load().\n */\nint OSSL_STORE_expect(OSSL_STORE_CTX *ctx, int expected_type);\nint OSSL_STORE_find(OSSL_STORE_CTX *ctx, OSSL_STORE_SEARCH *search);\n\n\n/*-\n *  Function to register a loader for the given URI scheme.\n *  -------------------------------------------------------\n *\n *  The loader receives all the main components of an URI except for the\n *  scheme.\n */\n\ntypedef struct ossl_store_loader_st OSSL_STORE_LOADER;\nOSSL_STORE_LOADER *OSSL_STORE_LOADER_new(ENGINE *e, const char *scheme);\nconst ENGINE *OSSL_STORE_LOADER_get0_engine(const OSSL_STORE_LOADER *loader);\nconst char *OSSL_STORE_LOADER_get0_scheme(const OSSL_STORE_LOADER *loader);\n/* struct ossl_store_loader_ctx_st is defined differently by each loader */\ntypedef struct ossl_store_loader_ctx_st OSSL_STORE_LOADER_CTX;\ntypedef OSSL_STORE_LOADER_CTX *(*OSSL_STORE_open_fn)(const OSSL_STORE_LOADER\n                                                     *loader,\n                                                     const char *uri,\n                                                     const UI_METHOD *ui_method,\n                                                     void *ui_data);\nint OSSL_STORE_LOADER_set_open(OSSL_STORE_LOADER *loader,\n                               OSSL_STORE_open_fn open_function);\ntypedef int (*OSSL_STORE_ctrl_fn)(OSSL_STORE_LOADER_CTX *ctx, int cmd,\n                                  va_list args);\nint OSSL_STORE_LOADER_set_ctrl(OSSL_STORE_LOADER *loader,\n                               OSSL_STORE_ctrl_fn ctrl_function);\ntypedef int (*OSSL_STORE_expect_fn)(OSSL_STORE_LOADER_CTX *ctx, int expected);\nint OSSL_STORE_LOADER_set_expect(OSSL_STORE_LOADER *loader,\n                                 OSSL_STORE_expect_fn expect_function);\ntypedef int (*OSSL_STORE_find_fn)(OSSL_STORE_LOADER_CTX *ctx,\n                                  OSSL_STORE_SEARCH *criteria);\nint OSSL_STORE_LOADER_set_find(OSSL_STORE_LOADER *loader,\n                               OSSL_STORE_find_fn find_function);\ntypedef OSSL_STORE_INFO *(*OSSL_STORE_load_fn)(OSSL_STORE_LOADER_CTX *ctx,\n                                               const UI_METHOD *ui_method,\n                                               void *ui_data);\nint OSSL_STORE_LOADER_set_load(OSSL_STORE_LOADER *loader,\n                               OSSL_STORE_load_fn load_function);\ntypedef int (*OSSL_STORE_eof_fn)(OSSL_STORE_LOADER_CTX *ctx);\nint OSSL_STORE_LOADER_set_eof(OSSL_STORE_LOADER *loader,\n                              OSSL_STORE_eof_fn eof_function);\ntypedef int (*OSSL_STORE_error_fn)(OSSL_STORE_LOADER_CTX *ctx);\nint OSSL_STORE_LOADER_set_error(OSSL_STORE_LOADER *loader,\n                                OSSL_STORE_error_fn error_function);\ntypedef int (*OSSL_STORE_close_fn)(OSSL_STORE_LOADER_CTX *ctx);\nint OSSL_STORE_LOADER_set_close(OSSL_STORE_LOADER *loader,\n                                OSSL_STORE_close_fn close_function);\nvoid OSSL_STORE_LOADER_free(OSSL_STORE_LOADER *loader);\n\nint OSSL_STORE_register_loader(OSSL_STORE_LOADER *loader);\nOSSL_STORE_LOADER *OSSL_STORE_unregister_loader(const char *scheme);\n\n/*-\n *  Functions to list STORE loaders\n *  -------------------------------\n */\nint OSSL_STORE_do_all_loaders(void (*do_function) (const OSSL_STORE_LOADER\n                                                   *loader, void *do_arg),\n                              void *do_arg);\n\n# ifdef  __cplusplus\n}\n# endif\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/include/openssl/storeerr.h",
    "content": "/*\n * Generated by util/mkerr.pl DO NOT EDIT\n * Copyright 1995-2019 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef HEADER_OSSL_STOREERR_H\n# define HEADER_OSSL_STOREERR_H\n\n# ifndef HEADER_SYMHACKS_H\n#  include <openssl/symhacks.h>\n# endif\n\n# ifdef  __cplusplus\nextern \"C\"\n# endif\nint ERR_load_OSSL_STORE_strings(void);\n\n/*\n * OSSL_STORE function codes.\n */\n# define OSSL_STORE_F_FILE_CTRL                           129\n# define OSSL_STORE_F_FILE_FIND                           138\n# define OSSL_STORE_F_FILE_GET_PASS                       118\n# define OSSL_STORE_F_FILE_LOAD                           119\n# define OSSL_STORE_F_FILE_LOAD_TRY_DECODE                124\n# define OSSL_STORE_F_FILE_NAME_TO_URI                    126\n# define OSSL_STORE_F_FILE_OPEN                           120\n# define OSSL_STORE_F_OSSL_STORE_ATTACH_PEM_BIO           127\n# define OSSL_STORE_F_OSSL_STORE_EXPECT                   130\n# define OSSL_STORE_F_OSSL_STORE_FILE_ATTACH_PEM_BIO_INT  128\n# define OSSL_STORE_F_OSSL_STORE_FIND                     131\n# define OSSL_STORE_F_OSSL_STORE_GET0_LOADER_INT          100\n# define OSSL_STORE_F_OSSL_STORE_INFO_GET1_CERT           101\n# define OSSL_STORE_F_OSSL_STORE_INFO_GET1_CRL            102\n# define OSSL_STORE_F_OSSL_STORE_INFO_GET1_NAME           103\n# define OSSL_STORE_F_OSSL_STORE_INFO_GET1_NAME_DESCRIPTION 135\n# define OSSL_STORE_F_OSSL_STORE_INFO_GET1_PARAMS         104\n# define OSSL_STORE_F_OSSL_STORE_INFO_GET1_PKEY           105\n# define OSSL_STORE_F_OSSL_STORE_INFO_NEW_CERT            106\n# define OSSL_STORE_F_OSSL_STORE_INFO_NEW_CRL             107\n# define OSSL_STORE_F_OSSL_STORE_INFO_NEW_EMBEDDED        123\n# define OSSL_STORE_F_OSSL_STORE_INFO_NEW_NAME            109\n# define OSSL_STORE_F_OSSL_STORE_INFO_NEW_PARAMS          110\n# define OSSL_STORE_F_OSSL_STORE_INFO_NEW_PKEY            111\n# define OSSL_STORE_F_OSSL_STORE_INFO_SET0_NAME_DESCRIPTION 134\n# define OSSL_STORE_F_OSSL_STORE_INIT_ONCE                112\n# define OSSL_STORE_F_OSSL_STORE_LOADER_NEW               113\n# define OSSL_STORE_F_OSSL_STORE_OPEN                     114\n# define OSSL_STORE_F_OSSL_STORE_OPEN_INT                 115\n# define OSSL_STORE_F_OSSL_STORE_REGISTER_LOADER_INT      117\n# define OSSL_STORE_F_OSSL_STORE_SEARCH_BY_ALIAS          132\n# define OSSL_STORE_F_OSSL_STORE_SEARCH_BY_ISSUER_SERIAL  133\n# define OSSL_STORE_F_OSSL_STORE_SEARCH_BY_KEY_FINGERPRINT 136\n# define OSSL_STORE_F_OSSL_STORE_SEARCH_BY_NAME           137\n# define OSSL_STORE_F_OSSL_STORE_UNREGISTER_LOADER_INT    116\n# define OSSL_STORE_F_TRY_DECODE_PARAMS                   121\n# define OSSL_STORE_F_TRY_DECODE_PKCS12                   122\n# define OSSL_STORE_F_TRY_DECODE_PKCS8ENCRYPTED           125\n\n/*\n * OSSL_STORE reason codes.\n */\n# define OSSL_STORE_R_AMBIGUOUS_CONTENT_TYPE              107\n# define OSSL_STORE_R_BAD_PASSWORD_READ                   115\n# define OSSL_STORE_R_ERROR_VERIFYING_PKCS12_MAC          113\n# define OSSL_STORE_R_FINGERPRINT_SIZE_DOES_NOT_MATCH_DIGEST 121\n# define OSSL_STORE_R_INVALID_SCHEME                      106\n# define OSSL_STORE_R_IS_NOT_A                            112\n# define OSSL_STORE_R_LOADER_INCOMPLETE                   116\n# define OSSL_STORE_R_LOADING_STARTED                     117\n# define OSSL_STORE_R_NOT_A_CERTIFICATE                   100\n# define OSSL_STORE_R_NOT_A_CRL                           101\n# define OSSL_STORE_R_NOT_A_KEY                           102\n# define OSSL_STORE_R_NOT_A_NAME                          103\n# define OSSL_STORE_R_NOT_PARAMETERS                      104\n# define OSSL_STORE_R_PASSPHRASE_CALLBACK_ERROR           114\n# define OSSL_STORE_R_PATH_MUST_BE_ABSOLUTE               108\n# define OSSL_STORE_R_SEARCH_ONLY_SUPPORTED_FOR_DIRECTORIES 119\n# define OSSL_STORE_R_UI_PROCESS_INTERRUPTED_OR_CANCELLED 109\n# define OSSL_STORE_R_UNREGISTERED_SCHEME                 105\n# define OSSL_STORE_R_UNSUPPORTED_CONTENT_TYPE            110\n# define OSSL_STORE_R_UNSUPPORTED_OPERATION               118\n# define OSSL_STORE_R_UNSUPPORTED_SEARCH_TYPE             120\n# define OSSL_STORE_R_URI_AUTHORITY_UNSUPPORTED           111\n\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/include/openssl/symhacks.h",
    "content": "/*\n * Copyright 1999-2018 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef HEADER_SYMHACKS_H\n# define HEADER_SYMHACKS_H\n\n# include <openssl/e_os2.h>\n\n/* Case insensitive linking causes problems.... */\n# if defined(OPENSSL_SYS_VMS)\n#  undef ERR_load_CRYPTO_strings\n#  define ERR_load_CRYPTO_strings                 ERR_load_CRYPTOlib_strings\n#  undef OCSP_crlID_new\n#  define OCSP_crlID_new                          OCSP_crlID2_new\n\n#  undef d2i_ECPARAMETERS\n#  define d2i_ECPARAMETERS                        d2i_UC_ECPARAMETERS\n#  undef i2d_ECPARAMETERS\n#  define i2d_ECPARAMETERS                        i2d_UC_ECPARAMETERS\n#  undef d2i_ECPKPARAMETERS\n#  define d2i_ECPKPARAMETERS                      d2i_UC_ECPKPARAMETERS\n#  undef i2d_ECPKPARAMETERS\n#  define i2d_ECPKPARAMETERS                      i2d_UC_ECPKPARAMETERS\n\n/* This one clashes with CMS_data_create */\n#  undef cms_Data_create\n#  define cms_Data_create                         priv_cms_Data_create\n\n# endif\n\n#endif                          /* ! defined HEADER_VMS_IDHACKS_H */\n"
  },
  {
    "path": "tools/prebuild/openssl/include/openssl/tls1.h",
    "content": "/*\n * Copyright 1995-2019 The OpenSSL Project Authors. All Rights Reserved.\n * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved\n * Copyright 2005 Nokia. All rights reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef HEADER_TLS1_H\n# define HEADER_TLS1_H\n\n# include <openssl/buffer.h>\n# include <openssl/x509.h>\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n/* Default security level if not overridden at config time */\n# ifndef OPENSSL_TLS_SECURITY_LEVEL\n#  define OPENSSL_TLS_SECURITY_LEVEL 1\n# endif\n\n# define TLS1_VERSION                    0x0301\n# define TLS1_1_VERSION                  0x0302\n# define TLS1_2_VERSION                  0x0303\n# define TLS1_3_VERSION                  0x0304\n# define TLS_MAX_VERSION                 TLS1_3_VERSION\n\n/* Special value for method supporting multiple versions */\n# define TLS_ANY_VERSION                 0x10000\n\n# define TLS1_VERSION_MAJOR              0x03\n# define TLS1_VERSION_MINOR              0x01\n\n# define TLS1_1_VERSION_MAJOR            0x03\n# define TLS1_1_VERSION_MINOR            0x02\n\n# define TLS1_2_VERSION_MAJOR            0x03\n# define TLS1_2_VERSION_MINOR            0x03\n\n# define TLS1_get_version(s) \\\n        ((SSL_version(s) >> 8) == TLS1_VERSION_MAJOR ? SSL_version(s) : 0)\n\n# define TLS1_get_client_version(s) \\\n        ((SSL_client_version(s) >> 8) == TLS1_VERSION_MAJOR ? SSL_client_version(s) : 0)\n\n# define TLS1_AD_DECRYPTION_FAILED       21\n# define TLS1_AD_RECORD_OVERFLOW         22\n# define TLS1_AD_UNKNOWN_CA              48/* fatal */\n# define TLS1_AD_ACCESS_DENIED           49/* fatal */\n# define TLS1_AD_DECODE_ERROR            50/* fatal */\n# define TLS1_AD_DECRYPT_ERROR           51\n# define TLS1_AD_EXPORT_RESTRICTION      60/* fatal */\n# define TLS1_AD_PROTOCOL_VERSION        70/* fatal */\n# define TLS1_AD_INSUFFICIENT_SECURITY   71/* fatal */\n# define TLS1_AD_INTERNAL_ERROR          80/* fatal */\n# define TLS1_AD_INAPPROPRIATE_FALLBACK  86/* fatal */\n# define TLS1_AD_USER_CANCELLED          90\n# define TLS1_AD_NO_RENEGOTIATION        100\n/* TLSv1.3 alerts */\n# define TLS13_AD_MISSING_EXTENSION      109 /* fatal */\n# define TLS13_AD_CERTIFICATE_REQUIRED   116 /* fatal */\n/* codes 110-114 are from RFC3546 */\n# define TLS1_AD_UNSUPPORTED_EXTENSION   110\n# define TLS1_AD_CERTIFICATE_UNOBTAINABLE 111\n# define TLS1_AD_UNRECOGNIZED_NAME       112\n# define TLS1_AD_BAD_CERTIFICATE_STATUS_RESPONSE 113\n# define TLS1_AD_BAD_CERTIFICATE_HASH_VALUE 114\n# define TLS1_AD_UNKNOWN_PSK_IDENTITY    115/* fatal */\n# define TLS1_AD_NO_APPLICATION_PROTOCOL 120 /* fatal */\n\n/* ExtensionType values from RFC3546 / RFC4366 / RFC6066 */\n# define TLSEXT_TYPE_server_name                 0\n# define TLSEXT_TYPE_max_fragment_length         1\n# define TLSEXT_TYPE_client_certificate_url      2\n# define TLSEXT_TYPE_trusted_ca_keys             3\n# define TLSEXT_TYPE_truncated_hmac              4\n# define TLSEXT_TYPE_status_request              5\n/* ExtensionType values from RFC4681 */\n# define TLSEXT_TYPE_user_mapping                6\n/* ExtensionType values from RFC5878 */\n# define TLSEXT_TYPE_client_authz                7\n# define TLSEXT_TYPE_server_authz                8\n/* ExtensionType values from RFC6091 */\n# define TLSEXT_TYPE_cert_type           9\n\n/* ExtensionType values from RFC4492 */\n/*\n * Prior to TLSv1.3 the supported_groups extension was known as\n * elliptic_curves\n */\n# define TLSEXT_TYPE_supported_groups            10\n# define TLSEXT_TYPE_elliptic_curves             TLSEXT_TYPE_supported_groups\n# define TLSEXT_TYPE_ec_point_formats            11\n\n\n/* ExtensionType value from RFC5054 */\n# define TLSEXT_TYPE_srp                         12\n\n/* ExtensionType values from RFC5246 */\n# define TLSEXT_TYPE_signature_algorithms        13\n\n/* ExtensionType value from RFC5764 */\n# define TLSEXT_TYPE_use_srtp    14\n\n/* ExtensionType value from RFC5620 */\n# define TLSEXT_TYPE_heartbeat   15\n\n/* ExtensionType value from RFC7301 */\n# define TLSEXT_TYPE_application_layer_protocol_negotiation 16\n\n/*\n * Extension type for Certificate Transparency\n * https://tools.ietf.org/html/rfc6962#section-3.3.1\n */\n# define TLSEXT_TYPE_signed_certificate_timestamp    18\n\n/*\n * ExtensionType value for TLS padding extension.\n * http://tools.ietf.org/html/draft-agl-tls-padding\n */\n# define TLSEXT_TYPE_padding     21\n\n/* ExtensionType value from RFC7366 */\n# define TLSEXT_TYPE_encrypt_then_mac    22\n\n/* ExtensionType value from RFC7627 */\n# define TLSEXT_TYPE_extended_master_secret      23\n\n/* ExtensionType value from RFC4507 */\n# define TLSEXT_TYPE_session_ticket              35\n\n/* As defined for TLS1.3 */\n# define TLSEXT_TYPE_psk                         41\n# define TLSEXT_TYPE_early_data                  42\n# define TLSEXT_TYPE_supported_versions          43\n# define TLSEXT_TYPE_cookie                      44\n# define TLSEXT_TYPE_psk_kex_modes               45\n# define TLSEXT_TYPE_certificate_authorities     47\n# define TLSEXT_TYPE_post_handshake_auth         49\n# define TLSEXT_TYPE_signature_algorithms_cert   50\n# define TLSEXT_TYPE_key_share                   51\n\n/* Temporary extension type */\n# define TLSEXT_TYPE_renegotiate                 0xff01\n\n# ifndef OPENSSL_NO_NEXTPROTONEG\n/* This is not an IANA defined extension number */\n#  define TLSEXT_TYPE_next_proto_neg              13172\n# endif\n\n/* NameType value from RFC3546 */\n# define TLSEXT_NAMETYPE_host_name 0\n/* status request value from RFC3546 */\n# define TLSEXT_STATUSTYPE_ocsp 1\n\n/* ECPointFormat values from RFC4492 */\n# define TLSEXT_ECPOINTFORMAT_first                      0\n# define TLSEXT_ECPOINTFORMAT_uncompressed               0\n# define TLSEXT_ECPOINTFORMAT_ansiX962_compressed_prime  1\n# define TLSEXT_ECPOINTFORMAT_ansiX962_compressed_char2  2\n# define TLSEXT_ECPOINTFORMAT_last                       2\n\n/* Signature and hash algorithms from RFC5246 */\n# define TLSEXT_signature_anonymous                      0\n# define TLSEXT_signature_rsa                            1\n# define TLSEXT_signature_dsa                            2\n# define TLSEXT_signature_ecdsa                          3\n# define TLSEXT_signature_gostr34102001                  237\n# define TLSEXT_signature_gostr34102012_256              238\n# define TLSEXT_signature_gostr34102012_512              239\n\n/* Total number of different signature algorithms */\n# define TLSEXT_signature_num                            7\n\n# define TLSEXT_hash_none                                0\n# define TLSEXT_hash_md5                                 1\n# define TLSEXT_hash_sha1                                2\n# define TLSEXT_hash_sha224                              3\n# define TLSEXT_hash_sha256                              4\n# define TLSEXT_hash_sha384                              5\n# define TLSEXT_hash_sha512                              6\n# define TLSEXT_hash_gostr3411                           237\n# define TLSEXT_hash_gostr34112012_256                   238\n# define TLSEXT_hash_gostr34112012_512                   239\n\n/* Total number of different digest algorithms */\n\n# define TLSEXT_hash_num                                 10\n\n/* Flag set for unrecognised algorithms */\n# define TLSEXT_nid_unknown                              0x1000000\n\n/* ECC curves */\n\n# define TLSEXT_curve_P_256                              23\n# define TLSEXT_curve_P_384                              24\n\n/* OpenSSL value to disable maximum fragment length extension */\n# define TLSEXT_max_fragment_length_DISABLED    0\n/* Allowed values for max fragment length extension */\n# define TLSEXT_max_fragment_length_512         1\n# define TLSEXT_max_fragment_length_1024        2\n# define TLSEXT_max_fragment_length_2048        3\n# define TLSEXT_max_fragment_length_4096        4\n\nint SSL_CTX_set_tlsext_max_fragment_length(SSL_CTX *ctx, uint8_t mode);\nint SSL_set_tlsext_max_fragment_length(SSL *ssl, uint8_t mode);\n\n# define TLSEXT_MAXLEN_host_name 255\n\n__owur const char *SSL_get_servername(const SSL *s, const int type);\n__owur int SSL_get_servername_type(const SSL *s);\n/*\n * SSL_export_keying_material exports a value derived from the master secret,\n * as specified in RFC 5705. It writes |olen| bytes to |out| given a label and\n * optional context. (Since a zero length context is allowed, the |use_context|\n * flag controls whether a context is included.) It returns 1 on success and\n * 0 or -1 otherwise.\n */\n__owur int SSL_export_keying_material(SSL *s, unsigned char *out, size_t olen,\n                                      const char *label, size_t llen,\n                                      const unsigned char *context,\n                                      size_t contextlen, int use_context);\n\n/*\n * SSL_export_keying_material_early exports a value derived from the\n * early exporter master secret, as specified in\n * https://tools.ietf.org/html/draft-ietf-tls-tls13-23. It writes\n * |olen| bytes to |out| given a label and optional context. It\n * returns 1 on success and 0 otherwise.\n */\n__owur int SSL_export_keying_material_early(SSL *s, unsigned char *out,\n                                            size_t olen, const char *label,\n                                            size_t llen,\n                                            const unsigned char *context,\n                                            size_t contextlen);\n\nint SSL_get_peer_signature_type_nid(const SSL *s, int *pnid);\nint SSL_get_signature_type_nid(const SSL *s, int *pnid);\n\nint SSL_get_sigalgs(SSL *s, int idx,\n                    int *psign, int *phash, int *psignandhash,\n                    unsigned char *rsig, unsigned char *rhash);\n\nint SSL_get_shared_sigalgs(SSL *s, int idx,\n                           int *psign, int *phash, int *psignandhash,\n                           unsigned char *rsig, unsigned char *rhash);\n\n__owur int SSL_check_chain(SSL *s, X509 *x, EVP_PKEY *pk, STACK_OF(X509) *chain);\n\n# define SSL_set_tlsext_host_name(s,name) \\\n        SSL_ctrl(s,SSL_CTRL_SET_TLSEXT_HOSTNAME,TLSEXT_NAMETYPE_host_name,\\\n                (void *)name)\n\n# define SSL_set_tlsext_debug_callback(ssl, cb) \\\n        SSL_callback_ctrl(ssl,SSL_CTRL_SET_TLSEXT_DEBUG_CB,\\\n                (void (*)(void))cb)\n\n# define SSL_set_tlsext_debug_arg(ssl, arg) \\\n        SSL_ctrl(ssl,SSL_CTRL_SET_TLSEXT_DEBUG_ARG,0,arg)\n\n# define SSL_get_tlsext_status_type(ssl) \\\n        SSL_ctrl(ssl,SSL_CTRL_GET_TLSEXT_STATUS_REQ_TYPE,0,NULL)\n\n# define SSL_set_tlsext_status_type(ssl, type) \\\n        SSL_ctrl(ssl,SSL_CTRL_SET_TLSEXT_STATUS_REQ_TYPE,type,NULL)\n\n# define SSL_get_tlsext_status_exts(ssl, arg) \\\n        SSL_ctrl(ssl,SSL_CTRL_GET_TLSEXT_STATUS_REQ_EXTS,0,arg)\n\n# define SSL_set_tlsext_status_exts(ssl, arg) \\\n        SSL_ctrl(ssl,SSL_CTRL_SET_TLSEXT_STATUS_REQ_EXTS,0,arg)\n\n# define SSL_get_tlsext_status_ids(ssl, arg) \\\n        SSL_ctrl(ssl,SSL_CTRL_GET_TLSEXT_STATUS_REQ_IDS,0,arg)\n\n# define SSL_set_tlsext_status_ids(ssl, arg) \\\n        SSL_ctrl(ssl,SSL_CTRL_SET_TLSEXT_STATUS_REQ_IDS,0,arg)\n\n# define SSL_get_tlsext_status_ocsp_resp(ssl, arg) \\\n        SSL_ctrl(ssl,SSL_CTRL_GET_TLSEXT_STATUS_REQ_OCSP_RESP,0,arg)\n\n# define SSL_set_tlsext_status_ocsp_resp(ssl, arg, arglen) \\\n        SSL_ctrl(ssl,SSL_CTRL_SET_TLSEXT_STATUS_REQ_OCSP_RESP,arglen,arg)\n\n# define SSL_CTX_set_tlsext_servername_callback(ctx, cb) \\\n        SSL_CTX_callback_ctrl(ctx,SSL_CTRL_SET_TLSEXT_SERVERNAME_CB,\\\n                (void (*)(void))cb)\n\n# define SSL_TLSEXT_ERR_OK 0\n# define SSL_TLSEXT_ERR_ALERT_WARNING 1\n# define SSL_TLSEXT_ERR_ALERT_FATAL 2\n# define SSL_TLSEXT_ERR_NOACK 3\n\n# define SSL_CTX_set_tlsext_servername_arg(ctx, arg) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_SET_TLSEXT_SERVERNAME_ARG,0,arg)\n\n# define SSL_CTX_get_tlsext_ticket_keys(ctx, keys, keylen) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_GET_TLSEXT_TICKET_KEYS,keylen,keys)\n# define SSL_CTX_set_tlsext_ticket_keys(ctx, keys, keylen) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_SET_TLSEXT_TICKET_KEYS,keylen,keys)\n\n# define SSL_CTX_get_tlsext_status_cb(ssl, cb) \\\n        SSL_CTX_ctrl(ssl,SSL_CTRL_GET_TLSEXT_STATUS_REQ_CB,0,(void *)cb)\n# define SSL_CTX_set_tlsext_status_cb(ssl, cb) \\\n        SSL_CTX_callback_ctrl(ssl,SSL_CTRL_SET_TLSEXT_STATUS_REQ_CB,\\\n                (void (*)(void))cb)\n\n# define SSL_CTX_get_tlsext_status_arg(ssl, arg) \\\n        SSL_CTX_ctrl(ssl,SSL_CTRL_GET_TLSEXT_STATUS_REQ_CB_ARG,0,arg)\n# define SSL_CTX_set_tlsext_status_arg(ssl, arg) \\\n        SSL_CTX_ctrl(ssl,SSL_CTRL_SET_TLSEXT_STATUS_REQ_CB_ARG,0,arg)\n\n# define SSL_CTX_set_tlsext_status_type(ssl, type) \\\n        SSL_CTX_ctrl(ssl,SSL_CTRL_SET_TLSEXT_STATUS_REQ_TYPE,type,NULL)\n\n# define SSL_CTX_get_tlsext_status_type(ssl) \\\n        SSL_CTX_ctrl(ssl,SSL_CTRL_GET_TLSEXT_STATUS_REQ_TYPE,0,NULL)\n\n# define SSL_CTX_set_tlsext_ticket_key_cb(ssl, cb) \\\n        SSL_CTX_callback_ctrl(ssl,SSL_CTRL_SET_TLSEXT_TICKET_KEY_CB,\\\n                (void (*)(void))cb)\n\n# ifndef OPENSSL_NO_HEARTBEATS\n#  define SSL_DTLSEXT_HB_ENABLED                   0x01\n#  define SSL_DTLSEXT_HB_DONT_SEND_REQUESTS        0x02\n#  define SSL_DTLSEXT_HB_DONT_RECV_REQUESTS        0x04\n#  define SSL_get_dtlsext_heartbeat_pending(ssl) \\\n        SSL_ctrl(ssl,SSL_CTRL_GET_DTLS_EXT_HEARTBEAT_PENDING,0,NULL)\n#  define SSL_set_dtlsext_heartbeat_no_requests(ssl, arg) \\\n        SSL_ctrl(ssl,SSL_CTRL_SET_DTLS_EXT_HEARTBEAT_NO_REQUESTS,arg,NULL)\n\n#  if OPENSSL_API_COMPAT < 0x10100000L\n#   define SSL_CTRL_TLS_EXT_SEND_HEARTBEAT \\\n        SSL_CTRL_DTLS_EXT_SEND_HEARTBEAT\n#   define SSL_CTRL_GET_TLS_EXT_HEARTBEAT_PENDING \\\n        SSL_CTRL_GET_DTLS_EXT_HEARTBEAT_PENDING\n#   define SSL_CTRL_SET_TLS_EXT_HEARTBEAT_NO_REQUESTS \\\n        SSL_CTRL_SET_DTLS_EXT_HEARTBEAT_NO_REQUESTS\n#   define SSL_TLSEXT_HB_ENABLED \\\n        SSL_DTLSEXT_HB_ENABLED\n#   define SSL_TLSEXT_HB_DONT_SEND_REQUESTS \\\n        SSL_DTLSEXT_HB_DONT_SEND_REQUESTS\n#   define SSL_TLSEXT_HB_DONT_RECV_REQUESTS \\\n        SSL_DTLSEXT_HB_DONT_RECV_REQUESTS\n#   define SSL_get_tlsext_heartbeat_pending(ssl) \\\n        SSL_get_dtlsext_heartbeat_pending(ssl)\n#   define SSL_set_tlsext_heartbeat_no_requests(ssl, arg) \\\n        SSL_set_dtlsext_heartbeat_no_requests(ssl,arg)\n#  endif\n# endif\n\n/* PSK ciphersuites from 4279 */\n# define TLS1_CK_PSK_WITH_RC4_128_SHA                    0x0300008A\n# define TLS1_CK_PSK_WITH_3DES_EDE_CBC_SHA               0x0300008B\n# define TLS1_CK_PSK_WITH_AES_128_CBC_SHA                0x0300008C\n# define TLS1_CK_PSK_WITH_AES_256_CBC_SHA                0x0300008D\n# define TLS1_CK_DHE_PSK_WITH_RC4_128_SHA                0x0300008E\n# define TLS1_CK_DHE_PSK_WITH_3DES_EDE_CBC_SHA           0x0300008F\n# define TLS1_CK_DHE_PSK_WITH_AES_128_CBC_SHA            0x03000090\n# define TLS1_CK_DHE_PSK_WITH_AES_256_CBC_SHA            0x03000091\n# define TLS1_CK_RSA_PSK_WITH_RC4_128_SHA                0x03000092\n# define TLS1_CK_RSA_PSK_WITH_3DES_EDE_CBC_SHA           0x03000093\n# define TLS1_CK_RSA_PSK_WITH_AES_128_CBC_SHA            0x03000094\n# define TLS1_CK_RSA_PSK_WITH_AES_256_CBC_SHA            0x03000095\n\n/* PSK ciphersuites from 5487 */\n# define TLS1_CK_PSK_WITH_AES_128_GCM_SHA256             0x030000A8\n# define TLS1_CK_PSK_WITH_AES_256_GCM_SHA384             0x030000A9\n# define TLS1_CK_DHE_PSK_WITH_AES_128_GCM_SHA256         0x030000AA\n# define TLS1_CK_DHE_PSK_WITH_AES_256_GCM_SHA384         0x030000AB\n# define TLS1_CK_RSA_PSK_WITH_AES_128_GCM_SHA256         0x030000AC\n# define TLS1_CK_RSA_PSK_WITH_AES_256_GCM_SHA384         0x030000AD\n# define TLS1_CK_PSK_WITH_AES_128_CBC_SHA256             0x030000AE\n# define TLS1_CK_PSK_WITH_AES_256_CBC_SHA384             0x030000AF\n# define TLS1_CK_PSK_WITH_NULL_SHA256                    0x030000B0\n# define TLS1_CK_PSK_WITH_NULL_SHA384                    0x030000B1\n# define TLS1_CK_DHE_PSK_WITH_AES_128_CBC_SHA256         0x030000B2\n# define TLS1_CK_DHE_PSK_WITH_AES_256_CBC_SHA384         0x030000B3\n# define TLS1_CK_DHE_PSK_WITH_NULL_SHA256                0x030000B4\n# define TLS1_CK_DHE_PSK_WITH_NULL_SHA384                0x030000B5\n# define TLS1_CK_RSA_PSK_WITH_AES_128_CBC_SHA256         0x030000B6\n# define TLS1_CK_RSA_PSK_WITH_AES_256_CBC_SHA384         0x030000B7\n# define TLS1_CK_RSA_PSK_WITH_NULL_SHA256                0x030000B8\n# define TLS1_CK_RSA_PSK_WITH_NULL_SHA384                0x030000B9\n\n/* NULL PSK ciphersuites from RFC4785 */\n# define TLS1_CK_PSK_WITH_NULL_SHA                       0x0300002C\n# define TLS1_CK_DHE_PSK_WITH_NULL_SHA                   0x0300002D\n# define TLS1_CK_RSA_PSK_WITH_NULL_SHA                   0x0300002E\n\n/* AES ciphersuites from RFC3268 */\n# define TLS1_CK_RSA_WITH_AES_128_SHA                    0x0300002F\n# define TLS1_CK_DH_DSS_WITH_AES_128_SHA                 0x03000030\n# define TLS1_CK_DH_RSA_WITH_AES_128_SHA                 0x03000031\n# define TLS1_CK_DHE_DSS_WITH_AES_128_SHA                0x03000032\n# define TLS1_CK_DHE_RSA_WITH_AES_128_SHA                0x03000033\n# define TLS1_CK_ADH_WITH_AES_128_SHA                    0x03000034\n# define TLS1_CK_RSA_WITH_AES_256_SHA                    0x03000035\n# define TLS1_CK_DH_DSS_WITH_AES_256_SHA                 0x03000036\n# define TLS1_CK_DH_RSA_WITH_AES_256_SHA                 0x03000037\n# define TLS1_CK_DHE_DSS_WITH_AES_256_SHA                0x03000038\n# define TLS1_CK_DHE_RSA_WITH_AES_256_SHA                0x03000039\n# define TLS1_CK_ADH_WITH_AES_256_SHA                    0x0300003A\n\n/* TLS v1.2 ciphersuites */\n# define TLS1_CK_RSA_WITH_NULL_SHA256                    0x0300003B\n# define TLS1_CK_RSA_WITH_AES_128_SHA256                 0x0300003C\n# define TLS1_CK_RSA_WITH_AES_256_SHA256                 0x0300003D\n# define TLS1_CK_DH_DSS_WITH_AES_128_SHA256              0x0300003E\n# define TLS1_CK_DH_RSA_WITH_AES_128_SHA256              0x0300003F\n# define TLS1_CK_DHE_DSS_WITH_AES_128_SHA256             0x03000040\n\n/* Camellia ciphersuites from RFC4132 */\n# define TLS1_CK_RSA_WITH_CAMELLIA_128_CBC_SHA           0x03000041\n# define TLS1_CK_DH_DSS_WITH_CAMELLIA_128_CBC_SHA        0x03000042\n# define TLS1_CK_DH_RSA_WITH_CAMELLIA_128_CBC_SHA        0x03000043\n# define TLS1_CK_DHE_DSS_WITH_CAMELLIA_128_CBC_SHA       0x03000044\n# define TLS1_CK_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA       0x03000045\n# define TLS1_CK_ADH_WITH_CAMELLIA_128_CBC_SHA           0x03000046\n\n/* TLS v1.2 ciphersuites */\n# define TLS1_CK_DHE_RSA_WITH_AES_128_SHA256             0x03000067\n# define TLS1_CK_DH_DSS_WITH_AES_256_SHA256              0x03000068\n# define TLS1_CK_DH_RSA_WITH_AES_256_SHA256              0x03000069\n# define TLS1_CK_DHE_DSS_WITH_AES_256_SHA256             0x0300006A\n# define TLS1_CK_DHE_RSA_WITH_AES_256_SHA256             0x0300006B\n# define TLS1_CK_ADH_WITH_AES_128_SHA256                 0x0300006C\n# define TLS1_CK_ADH_WITH_AES_256_SHA256                 0x0300006D\n\n/* Camellia ciphersuites from RFC4132 */\n# define TLS1_CK_RSA_WITH_CAMELLIA_256_CBC_SHA           0x03000084\n# define TLS1_CK_DH_DSS_WITH_CAMELLIA_256_CBC_SHA        0x03000085\n# define TLS1_CK_DH_RSA_WITH_CAMELLIA_256_CBC_SHA        0x03000086\n# define TLS1_CK_DHE_DSS_WITH_CAMELLIA_256_CBC_SHA       0x03000087\n# define TLS1_CK_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA       0x03000088\n# define TLS1_CK_ADH_WITH_CAMELLIA_256_CBC_SHA           0x03000089\n\n/* SEED ciphersuites from RFC4162 */\n# define TLS1_CK_RSA_WITH_SEED_SHA                       0x03000096\n# define TLS1_CK_DH_DSS_WITH_SEED_SHA                    0x03000097\n# define TLS1_CK_DH_RSA_WITH_SEED_SHA                    0x03000098\n# define TLS1_CK_DHE_DSS_WITH_SEED_SHA                   0x03000099\n# define TLS1_CK_DHE_RSA_WITH_SEED_SHA                   0x0300009A\n# define TLS1_CK_ADH_WITH_SEED_SHA                       0x0300009B\n\n/* TLS v1.2 GCM ciphersuites from RFC5288 */\n# define TLS1_CK_RSA_WITH_AES_128_GCM_SHA256             0x0300009C\n# define TLS1_CK_RSA_WITH_AES_256_GCM_SHA384             0x0300009D\n# define TLS1_CK_DHE_RSA_WITH_AES_128_GCM_SHA256         0x0300009E\n# define TLS1_CK_DHE_RSA_WITH_AES_256_GCM_SHA384         0x0300009F\n# define TLS1_CK_DH_RSA_WITH_AES_128_GCM_SHA256          0x030000A0\n# define TLS1_CK_DH_RSA_WITH_AES_256_GCM_SHA384          0x030000A1\n# define TLS1_CK_DHE_DSS_WITH_AES_128_GCM_SHA256         0x030000A2\n# define TLS1_CK_DHE_DSS_WITH_AES_256_GCM_SHA384         0x030000A3\n# define TLS1_CK_DH_DSS_WITH_AES_128_GCM_SHA256          0x030000A4\n# define TLS1_CK_DH_DSS_WITH_AES_256_GCM_SHA384          0x030000A5\n# define TLS1_CK_ADH_WITH_AES_128_GCM_SHA256             0x030000A6\n# define TLS1_CK_ADH_WITH_AES_256_GCM_SHA384             0x030000A7\n\n/* CCM ciphersuites from RFC6655 */\n# define TLS1_CK_RSA_WITH_AES_128_CCM                    0x0300C09C\n# define TLS1_CK_RSA_WITH_AES_256_CCM                    0x0300C09D\n# define TLS1_CK_DHE_RSA_WITH_AES_128_CCM                0x0300C09E\n# define TLS1_CK_DHE_RSA_WITH_AES_256_CCM                0x0300C09F\n# define TLS1_CK_RSA_WITH_AES_128_CCM_8                  0x0300C0A0\n# define TLS1_CK_RSA_WITH_AES_256_CCM_8                  0x0300C0A1\n# define TLS1_CK_DHE_RSA_WITH_AES_128_CCM_8              0x0300C0A2\n# define TLS1_CK_DHE_RSA_WITH_AES_256_CCM_8              0x0300C0A3\n# define TLS1_CK_PSK_WITH_AES_128_CCM                    0x0300C0A4\n# define TLS1_CK_PSK_WITH_AES_256_CCM                    0x0300C0A5\n# define TLS1_CK_DHE_PSK_WITH_AES_128_CCM                0x0300C0A6\n# define TLS1_CK_DHE_PSK_WITH_AES_256_CCM                0x0300C0A7\n# define TLS1_CK_PSK_WITH_AES_128_CCM_8                  0x0300C0A8\n# define TLS1_CK_PSK_WITH_AES_256_CCM_8                  0x0300C0A9\n# define TLS1_CK_DHE_PSK_WITH_AES_128_CCM_8              0x0300C0AA\n# define TLS1_CK_DHE_PSK_WITH_AES_256_CCM_8              0x0300C0AB\n\n/* CCM ciphersuites from RFC7251 */\n# define TLS1_CK_ECDHE_ECDSA_WITH_AES_128_CCM            0x0300C0AC\n# define TLS1_CK_ECDHE_ECDSA_WITH_AES_256_CCM            0x0300C0AD\n# define TLS1_CK_ECDHE_ECDSA_WITH_AES_128_CCM_8          0x0300C0AE\n# define TLS1_CK_ECDHE_ECDSA_WITH_AES_256_CCM_8          0x0300C0AF\n\n/* TLS 1.2 Camellia SHA-256 ciphersuites from RFC5932 */\n# define TLS1_CK_RSA_WITH_CAMELLIA_128_CBC_SHA256                0x030000BA\n# define TLS1_CK_DH_DSS_WITH_CAMELLIA_128_CBC_SHA256             0x030000BB\n# define TLS1_CK_DH_RSA_WITH_CAMELLIA_128_CBC_SHA256             0x030000BC\n# define TLS1_CK_DHE_DSS_WITH_CAMELLIA_128_CBC_SHA256            0x030000BD\n# define TLS1_CK_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA256            0x030000BE\n# define TLS1_CK_ADH_WITH_CAMELLIA_128_CBC_SHA256                0x030000BF\n\n# define TLS1_CK_RSA_WITH_CAMELLIA_256_CBC_SHA256                0x030000C0\n# define TLS1_CK_DH_DSS_WITH_CAMELLIA_256_CBC_SHA256             0x030000C1\n# define TLS1_CK_DH_RSA_WITH_CAMELLIA_256_CBC_SHA256             0x030000C2\n# define TLS1_CK_DHE_DSS_WITH_CAMELLIA_256_CBC_SHA256            0x030000C3\n# define TLS1_CK_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA256            0x030000C4\n# define TLS1_CK_ADH_WITH_CAMELLIA_256_CBC_SHA256                0x030000C5\n\n/* ECC ciphersuites from RFC4492 */\n# define TLS1_CK_ECDH_ECDSA_WITH_NULL_SHA                0x0300C001\n# define TLS1_CK_ECDH_ECDSA_WITH_RC4_128_SHA             0x0300C002\n# define TLS1_CK_ECDH_ECDSA_WITH_DES_192_CBC3_SHA        0x0300C003\n# define TLS1_CK_ECDH_ECDSA_WITH_AES_128_CBC_SHA         0x0300C004\n# define TLS1_CK_ECDH_ECDSA_WITH_AES_256_CBC_SHA         0x0300C005\n\n# define TLS1_CK_ECDHE_ECDSA_WITH_NULL_SHA               0x0300C006\n# define TLS1_CK_ECDHE_ECDSA_WITH_RC4_128_SHA            0x0300C007\n# define TLS1_CK_ECDHE_ECDSA_WITH_DES_192_CBC3_SHA       0x0300C008\n# define TLS1_CK_ECDHE_ECDSA_WITH_AES_128_CBC_SHA        0x0300C009\n# define TLS1_CK_ECDHE_ECDSA_WITH_AES_256_CBC_SHA        0x0300C00A\n\n# define TLS1_CK_ECDH_RSA_WITH_NULL_SHA                  0x0300C00B\n# define TLS1_CK_ECDH_RSA_WITH_RC4_128_SHA               0x0300C00C\n# define TLS1_CK_ECDH_RSA_WITH_DES_192_CBC3_SHA          0x0300C00D\n# define TLS1_CK_ECDH_RSA_WITH_AES_128_CBC_SHA           0x0300C00E\n# define TLS1_CK_ECDH_RSA_WITH_AES_256_CBC_SHA           0x0300C00F\n\n# define TLS1_CK_ECDHE_RSA_WITH_NULL_SHA                 0x0300C010\n# define TLS1_CK_ECDHE_RSA_WITH_RC4_128_SHA              0x0300C011\n# define TLS1_CK_ECDHE_RSA_WITH_DES_192_CBC3_SHA         0x0300C012\n# define TLS1_CK_ECDHE_RSA_WITH_AES_128_CBC_SHA          0x0300C013\n# define TLS1_CK_ECDHE_RSA_WITH_AES_256_CBC_SHA          0x0300C014\n\n# define TLS1_CK_ECDH_anon_WITH_NULL_SHA                 0x0300C015\n# define TLS1_CK_ECDH_anon_WITH_RC4_128_SHA              0x0300C016\n# define TLS1_CK_ECDH_anon_WITH_DES_192_CBC3_SHA         0x0300C017\n# define TLS1_CK_ECDH_anon_WITH_AES_128_CBC_SHA          0x0300C018\n# define TLS1_CK_ECDH_anon_WITH_AES_256_CBC_SHA          0x0300C019\n\n/* SRP ciphersuites from RFC 5054 */\n# define TLS1_CK_SRP_SHA_WITH_3DES_EDE_CBC_SHA           0x0300C01A\n# define TLS1_CK_SRP_SHA_RSA_WITH_3DES_EDE_CBC_SHA       0x0300C01B\n# define TLS1_CK_SRP_SHA_DSS_WITH_3DES_EDE_CBC_SHA       0x0300C01C\n# define TLS1_CK_SRP_SHA_WITH_AES_128_CBC_SHA            0x0300C01D\n# define TLS1_CK_SRP_SHA_RSA_WITH_AES_128_CBC_SHA        0x0300C01E\n# define TLS1_CK_SRP_SHA_DSS_WITH_AES_128_CBC_SHA        0x0300C01F\n# define TLS1_CK_SRP_SHA_WITH_AES_256_CBC_SHA            0x0300C020\n# define TLS1_CK_SRP_SHA_RSA_WITH_AES_256_CBC_SHA        0x0300C021\n# define TLS1_CK_SRP_SHA_DSS_WITH_AES_256_CBC_SHA        0x0300C022\n\n/* ECDH HMAC based ciphersuites from RFC5289 */\n# define TLS1_CK_ECDHE_ECDSA_WITH_AES_128_SHA256         0x0300C023\n# define TLS1_CK_ECDHE_ECDSA_WITH_AES_256_SHA384         0x0300C024\n# define TLS1_CK_ECDH_ECDSA_WITH_AES_128_SHA256          0x0300C025\n# define TLS1_CK_ECDH_ECDSA_WITH_AES_256_SHA384          0x0300C026\n# define TLS1_CK_ECDHE_RSA_WITH_AES_128_SHA256           0x0300C027\n# define TLS1_CK_ECDHE_RSA_WITH_AES_256_SHA384           0x0300C028\n# define TLS1_CK_ECDH_RSA_WITH_AES_128_SHA256            0x0300C029\n# define TLS1_CK_ECDH_RSA_WITH_AES_256_SHA384            0x0300C02A\n\n/* ECDH GCM based ciphersuites from RFC5289 */\n# define TLS1_CK_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256     0x0300C02B\n# define TLS1_CK_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384     0x0300C02C\n# define TLS1_CK_ECDH_ECDSA_WITH_AES_128_GCM_SHA256      0x0300C02D\n# define TLS1_CK_ECDH_ECDSA_WITH_AES_256_GCM_SHA384      0x0300C02E\n# define TLS1_CK_ECDHE_RSA_WITH_AES_128_GCM_SHA256       0x0300C02F\n# define TLS1_CK_ECDHE_RSA_WITH_AES_256_GCM_SHA384       0x0300C030\n# define TLS1_CK_ECDH_RSA_WITH_AES_128_GCM_SHA256        0x0300C031\n# define TLS1_CK_ECDH_RSA_WITH_AES_256_GCM_SHA384        0x0300C032\n\n/* ECDHE PSK ciphersuites from RFC5489 */\n# define TLS1_CK_ECDHE_PSK_WITH_RC4_128_SHA              0x0300C033\n# define TLS1_CK_ECDHE_PSK_WITH_3DES_EDE_CBC_SHA         0x0300C034\n# define TLS1_CK_ECDHE_PSK_WITH_AES_128_CBC_SHA          0x0300C035\n# define TLS1_CK_ECDHE_PSK_WITH_AES_256_CBC_SHA          0x0300C036\n\n# define TLS1_CK_ECDHE_PSK_WITH_AES_128_CBC_SHA256       0x0300C037\n# define TLS1_CK_ECDHE_PSK_WITH_AES_256_CBC_SHA384       0x0300C038\n\n/* NULL PSK ciphersuites from RFC4785 */\n# define TLS1_CK_ECDHE_PSK_WITH_NULL_SHA                 0x0300C039\n# define TLS1_CK_ECDHE_PSK_WITH_NULL_SHA256              0x0300C03A\n# define TLS1_CK_ECDHE_PSK_WITH_NULL_SHA384              0x0300C03B\n\n/* Camellia-CBC ciphersuites from RFC6367 */\n# define TLS1_CK_ECDHE_ECDSA_WITH_CAMELLIA_128_CBC_SHA256 0x0300C072\n# define TLS1_CK_ECDHE_ECDSA_WITH_CAMELLIA_256_CBC_SHA384 0x0300C073\n# define TLS1_CK_ECDH_ECDSA_WITH_CAMELLIA_128_CBC_SHA256  0x0300C074\n# define TLS1_CK_ECDH_ECDSA_WITH_CAMELLIA_256_CBC_SHA384  0x0300C075\n# define TLS1_CK_ECDHE_RSA_WITH_CAMELLIA_128_CBC_SHA256   0x0300C076\n# define TLS1_CK_ECDHE_RSA_WITH_CAMELLIA_256_CBC_SHA384   0x0300C077\n# define TLS1_CK_ECDH_RSA_WITH_CAMELLIA_128_CBC_SHA256    0x0300C078\n# define TLS1_CK_ECDH_RSA_WITH_CAMELLIA_256_CBC_SHA384    0x0300C079\n\n# define TLS1_CK_PSK_WITH_CAMELLIA_128_CBC_SHA256         0x0300C094\n# define TLS1_CK_PSK_WITH_CAMELLIA_256_CBC_SHA384         0x0300C095\n# define TLS1_CK_DHE_PSK_WITH_CAMELLIA_128_CBC_SHA256     0x0300C096\n# define TLS1_CK_DHE_PSK_WITH_CAMELLIA_256_CBC_SHA384     0x0300C097\n# define TLS1_CK_RSA_PSK_WITH_CAMELLIA_128_CBC_SHA256     0x0300C098\n# define TLS1_CK_RSA_PSK_WITH_CAMELLIA_256_CBC_SHA384     0x0300C099\n# define TLS1_CK_ECDHE_PSK_WITH_CAMELLIA_128_CBC_SHA256   0x0300C09A\n# define TLS1_CK_ECDHE_PSK_WITH_CAMELLIA_256_CBC_SHA384   0x0300C09B\n\n/* draft-ietf-tls-chacha20-poly1305-03 */\n# define TLS1_CK_ECDHE_RSA_WITH_CHACHA20_POLY1305         0x0300CCA8\n# define TLS1_CK_ECDHE_ECDSA_WITH_CHACHA20_POLY1305       0x0300CCA9\n# define TLS1_CK_DHE_RSA_WITH_CHACHA20_POLY1305           0x0300CCAA\n# define TLS1_CK_PSK_WITH_CHACHA20_POLY1305               0x0300CCAB\n# define TLS1_CK_ECDHE_PSK_WITH_CHACHA20_POLY1305         0x0300CCAC\n# define TLS1_CK_DHE_PSK_WITH_CHACHA20_POLY1305           0x0300CCAD\n# define TLS1_CK_RSA_PSK_WITH_CHACHA20_POLY1305           0x0300CCAE\n\n/* TLS v1.3 ciphersuites */\n# define TLS1_3_CK_AES_128_GCM_SHA256                     0x03001301\n# define TLS1_3_CK_AES_256_GCM_SHA384                     0x03001302\n# define TLS1_3_CK_CHACHA20_POLY1305_SHA256               0x03001303\n# define TLS1_3_CK_AES_128_CCM_SHA256                     0x03001304\n# define TLS1_3_CK_AES_128_CCM_8_SHA256                   0x03001305\n\n/* Aria ciphersuites from RFC6209 */\n# define TLS1_CK_RSA_WITH_ARIA_128_GCM_SHA256             0x0300C050\n# define TLS1_CK_RSA_WITH_ARIA_256_GCM_SHA384             0x0300C051\n# define TLS1_CK_DHE_RSA_WITH_ARIA_128_GCM_SHA256         0x0300C052\n# define TLS1_CK_DHE_RSA_WITH_ARIA_256_GCM_SHA384         0x0300C053\n# define TLS1_CK_DH_RSA_WITH_ARIA_128_GCM_SHA256          0x0300C054\n# define TLS1_CK_DH_RSA_WITH_ARIA_256_GCM_SHA384          0x0300C055\n# define TLS1_CK_DHE_DSS_WITH_ARIA_128_GCM_SHA256         0x0300C056\n# define TLS1_CK_DHE_DSS_WITH_ARIA_256_GCM_SHA384         0x0300C057\n# define TLS1_CK_DH_DSS_WITH_ARIA_128_GCM_SHA256          0x0300C058\n# define TLS1_CK_DH_DSS_WITH_ARIA_256_GCM_SHA384          0x0300C059\n# define TLS1_CK_DH_anon_WITH_ARIA_128_GCM_SHA256         0x0300C05A\n# define TLS1_CK_DH_anon_WITH_ARIA_256_GCM_SHA384         0x0300C05B\n# define TLS1_CK_ECDHE_ECDSA_WITH_ARIA_128_GCM_SHA256     0x0300C05C\n# define TLS1_CK_ECDHE_ECDSA_WITH_ARIA_256_GCM_SHA384     0x0300C05D\n# define TLS1_CK_ECDH_ECDSA_WITH_ARIA_128_GCM_SHA256      0x0300C05E\n# define TLS1_CK_ECDH_ECDSA_WITH_ARIA_256_GCM_SHA384      0x0300C05F\n# define TLS1_CK_ECDHE_RSA_WITH_ARIA_128_GCM_SHA256       0x0300C060\n# define TLS1_CK_ECDHE_RSA_WITH_ARIA_256_GCM_SHA384       0x0300C061\n# define TLS1_CK_ECDH_RSA_WITH_ARIA_128_GCM_SHA256        0x0300C062\n# define TLS1_CK_ECDH_RSA_WITH_ARIA_256_GCM_SHA384        0x0300C063\n# define TLS1_CK_PSK_WITH_ARIA_128_GCM_SHA256             0x0300C06A\n# define TLS1_CK_PSK_WITH_ARIA_256_GCM_SHA384             0x0300C06B\n# define TLS1_CK_DHE_PSK_WITH_ARIA_128_GCM_SHA256         0x0300C06C\n# define TLS1_CK_DHE_PSK_WITH_ARIA_256_GCM_SHA384         0x0300C06D\n# define TLS1_CK_RSA_PSK_WITH_ARIA_128_GCM_SHA256         0x0300C06E\n# define TLS1_CK_RSA_PSK_WITH_ARIA_256_GCM_SHA384         0x0300C06F\n\n/* a bundle of RFC standard cipher names, generated from ssl3_ciphers[] */\n# define TLS1_RFC_RSA_WITH_AES_128_SHA                   \"TLS_RSA_WITH_AES_128_CBC_SHA\"\n# define TLS1_RFC_DHE_DSS_WITH_AES_128_SHA               \"TLS_DHE_DSS_WITH_AES_128_CBC_SHA\"\n# define TLS1_RFC_DHE_RSA_WITH_AES_128_SHA               \"TLS_DHE_RSA_WITH_AES_128_CBC_SHA\"\n# define TLS1_RFC_ADH_WITH_AES_128_SHA                   \"TLS_DH_anon_WITH_AES_128_CBC_SHA\"\n# define TLS1_RFC_RSA_WITH_AES_256_SHA                   \"TLS_RSA_WITH_AES_256_CBC_SHA\"\n# define TLS1_RFC_DHE_DSS_WITH_AES_256_SHA               \"TLS_DHE_DSS_WITH_AES_256_CBC_SHA\"\n# define TLS1_RFC_DHE_RSA_WITH_AES_256_SHA               \"TLS_DHE_RSA_WITH_AES_256_CBC_SHA\"\n# define TLS1_RFC_ADH_WITH_AES_256_SHA                   \"TLS_DH_anon_WITH_AES_256_CBC_SHA\"\n# define TLS1_RFC_RSA_WITH_NULL_SHA256                   \"TLS_RSA_WITH_NULL_SHA256\"\n# define TLS1_RFC_RSA_WITH_AES_128_SHA256                \"TLS_RSA_WITH_AES_128_CBC_SHA256\"\n# define TLS1_RFC_RSA_WITH_AES_256_SHA256                \"TLS_RSA_WITH_AES_256_CBC_SHA256\"\n# define TLS1_RFC_DHE_DSS_WITH_AES_128_SHA256            \"TLS_DHE_DSS_WITH_AES_128_CBC_SHA256\"\n# define TLS1_RFC_DHE_RSA_WITH_AES_128_SHA256            \"TLS_DHE_RSA_WITH_AES_128_CBC_SHA256\"\n# define TLS1_RFC_DHE_DSS_WITH_AES_256_SHA256            \"TLS_DHE_DSS_WITH_AES_256_CBC_SHA256\"\n# define TLS1_RFC_DHE_RSA_WITH_AES_256_SHA256            \"TLS_DHE_RSA_WITH_AES_256_CBC_SHA256\"\n# define TLS1_RFC_ADH_WITH_AES_128_SHA256                \"TLS_DH_anon_WITH_AES_128_CBC_SHA256\"\n# define TLS1_RFC_ADH_WITH_AES_256_SHA256                \"TLS_DH_anon_WITH_AES_256_CBC_SHA256\"\n# define TLS1_RFC_RSA_WITH_AES_128_GCM_SHA256            \"TLS_RSA_WITH_AES_128_GCM_SHA256\"\n# define TLS1_RFC_RSA_WITH_AES_256_GCM_SHA384            \"TLS_RSA_WITH_AES_256_GCM_SHA384\"\n# define TLS1_RFC_DHE_RSA_WITH_AES_128_GCM_SHA256        \"TLS_DHE_RSA_WITH_AES_128_GCM_SHA256\"\n# define TLS1_RFC_DHE_RSA_WITH_AES_256_GCM_SHA384        \"TLS_DHE_RSA_WITH_AES_256_GCM_SHA384\"\n# define TLS1_RFC_DHE_DSS_WITH_AES_128_GCM_SHA256        \"TLS_DHE_DSS_WITH_AES_128_GCM_SHA256\"\n# define TLS1_RFC_DHE_DSS_WITH_AES_256_GCM_SHA384        \"TLS_DHE_DSS_WITH_AES_256_GCM_SHA384\"\n# define TLS1_RFC_ADH_WITH_AES_128_GCM_SHA256            \"TLS_DH_anon_WITH_AES_128_GCM_SHA256\"\n# define TLS1_RFC_ADH_WITH_AES_256_GCM_SHA384            \"TLS_DH_anon_WITH_AES_256_GCM_SHA384\"\n# define TLS1_RFC_RSA_WITH_AES_128_CCM                   \"TLS_RSA_WITH_AES_128_CCM\"\n# define TLS1_RFC_RSA_WITH_AES_256_CCM                   \"TLS_RSA_WITH_AES_256_CCM\"\n# define TLS1_RFC_DHE_RSA_WITH_AES_128_CCM               \"TLS_DHE_RSA_WITH_AES_128_CCM\"\n# define TLS1_RFC_DHE_RSA_WITH_AES_256_CCM               \"TLS_DHE_RSA_WITH_AES_256_CCM\"\n# define TLS1_RFC_RSA_WITH_AES_128_CCM_8                 \"TLS_RSA_WITH_AES_128_CCM_8\"\n# define TLS1_RFC_RSA_WITH_AES_256_CCM_8                 \"TLS_RSA_WITH_AES_256_CCM_8\"\n# define TLS1_RFC_DHE_RSA_WITH_AES_128_CCM_8             \"TLS_DHE_RSA_WITH_AES_128_CCM_8\"\n# define TLS1_RFC_DHE_RSA_WITH_AES_256_CCM_8             \"TLS_DHE_RSA_WITH_AES_256_CCM_8\"\n# define TLS1_RFC_PSK_WITH_AES_128_CCM                   \"TLS_PSK_WITH_AES_128_CCM\"\n# define TLS1_RFC_PSK_WITH_AES_256_CCM                   \"TLS_PSK_WITH_AES_256_CCM\"\n# define TLS1_RFC_DHE_PSK_WITH_AES_128_CCM               \"TLS_DHE_PSK_WITH_AES_128_CCM\"\n# define TLS1_RFC_DHE_PSK_WITH_AES_256_CCM               \"TLS_DHE_PSK_WITH_AES_256_CCM\"\n# define TLS1_RFC_PSK_WITH_AES_128_CCM_8                 \"TLS_PSK_WITH_AES_128_CCM_8\"\n# define TLS1_RFC_PSK_WITH_AES_256_CCM_8                 \"TLS_PSK_WITH_AES_256_CCM_8\"\n# define TLS1_RFC_DHE_PSK_WITH_AES_128_CCM_8             \"TLS_PSK_DHE_WITH_AES_128_CCM_8\"\n# define TLS1_RFC_DHE_PSK_WITH_AES_256_CCM_8             \"TLS_PSK_DHE_WITH_AES_256_CCM_8\"\n# define TLS1_RFC_ECDHE_ECDSA_WITH_AES_128_CCM           \"TLS_ECDHE_ECDSA_WITH_AES_128_CCM\"\n# define TLS1_RFC_ECDHE_ECDSA_WITH_AES_256_CCM           \"TLS_ECDHE_ECDSA_WITH_AES_256_CCM\"\n# define TLS1_RFC_ECDHE_ECDSA_WITH_AES_128_CCM_8         \"TLS_ECDHE_ECDSA_WITH_AES_128_CCM_8\"\n# define TLS1_RFC_ECDHE_ECDSA_WITH_AES_256_CCM_8         \"TLS_ECDHE_ECDSA_WITH_AES_256_CCM_8\"\n# define TLS1_3_RFC_AES_128_GCM_SHA256                   \"TLS_AES_128_GCM_SHA256\"\n# define TLS1_3_RFC_AES_256_GCM_SHA384                   \"TLS_AES_256_GCM_SHA384\"\n# define TLS1_3_RFC_CHACHA20_POLY1305_SHA256             \"TLS_CHACHA20_POLY1305_SHA256\"\n# define TLS1_3_RFC_AES_128_CCM_SHA256                   \"TLS_AES_128_CCM_SHA256\"\n# define TLS1_3_RFC_AES_128_CCM_8_SHA256                 \"TLS_AES_128_CCM_8_SHA256\"\n# define TLS1_RFC_ECDHE_ECDSA_WITH_NULL_SHA              \"TLS_ECDHE_ECDSA_WITH_NULL_SHA\"\n# define TLS1_RFC_ECDHE_ECDSA_WITH_DES_192_CBC3_SHA      \"TLS_ECDHE_ECDSA_WITH_3DES_EDE_CBC_SHA\"\n# define TLS1_RFC_ECDHE_ECDSA_WITH_AES_128_CBC_SHA       \"TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA\"\n# define TLS1_RFC_ECDHE_ECDSA_WITH_AES_256_CBC_SHA       \"TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA\"\n# define TLS1_RFC_ECDHE_RSA_WITH_NULL_SHA                \"TLS_ECDHE_RSA_WITH_NULL_SHA\"\n# define TLS1_RFC_ECDHE_RSA_WITH_DES_192_CBC3_SHA        \"TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA\"\n# define TLS1_RFC_ECDHE_RSA_WITH_AES_128_CBC_SHA         \"TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA\"\n# define TLS1_RFC_ECDHE_RSA_WITH_AES_256_CBC_SHA         \"TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA\"\n# define TLS1_RFC_ECDH_anon_WITH_NULL_SHA                \"TLS_ECDH_anon_WITH_NULL_SHA\"\n# define TLS1_RFC_ECDH_anon_WITH_DES_192_CBC3_SHA        \"TLS_ECDH_anon_WITH_3DES_EDE_CBC_SHA\"\n# define TLS1_RFC_ECDH_anon_WITH_AES_128_CBC_SHA         \"TLS_ECDH_anon_WITH_AES_128_CBC_SHA\"\n# define TLS1_RFC_ECDH_anon_WITH_AES_256_CBC_SHA         \"TLS_ECDH_anon_WITH_AES_256_CBC_SHA\"\n# define TLS1_RFC_ECDHE_ECDSA_WITH_AES_128_SHA256        \"TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256\"\n# define TLS1_RFC_ECDHE_ECDSA_WITH_AES_256_SHA384        \"TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384\"\n# define TLS1_RFC_ECDHE_RSA_WITH_AES_128_SHA256          \"TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256\"\n# define TLS1_RFC_ECDHE_RSA_WITH_AES_256_SHA384          \"TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384\"\n# define TLS1_RFC_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256    \"TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256\"\n# define TLS1_RFC_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384    \"TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384\"\n# define TLS1_RFC_ECDHE_RSA_WITH_AES_128_GCM_SHA256      \"TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256\"\n# define TLS1_RFC_ECDHE_RSA_WITH_AES_256_GCM_SHA384      \"TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384\"\n# define TLS1_RFC_PSK_WITH_NULL_SHA                      \"TLS_PSK_WITH_NULL_SHA\"\n# define TLS1_RFC_DHE_PSK_WITH_NULL_SHA                  \"TLS_DHE_PSK_WITH_NULL_SHA\"\n# define TLS1_RFC_RSA_PSK_WITH_NULL_SHA                  \"TLS_RSA_PSK_WITH_NULL_SHA\"\n# define TLS1_RFC_PSK_WITH_3DES_EDE_CBC_SHA              \"TLS_PSK_WITH_3DES_EDE_CBC_SHA\"\n# define TLS1_RFC_PSK_WITH_AES_128_CBC_SHA               \"TLS_PSK_WITH_AES_128_CBC_SHA\"\n# define TLS1_RFC_PSK_WITH_AES_256_CBC_SHA               \"TLS_PSK_WITH_AES_256_CBC_SHA\"\n# define TLS1_RFC_DHE_PSK_WITH_3DES_EDE_CBC_SHA          \"TLS_DHE_PSK_WITH_3DES_EDE_CBC_SHA\"\n# define TLS1_RFC_DHE_PSK_WITH_AES_128_CBC_SHA           \"TLS_DHE_PSK_WITH_AES_128_CBC_SHA\"\n# define TLS1_RFC_DHE_PSK_WITH_AES_256_CBC_SHA           \"TLS_DHE_PSK_WITH_AES_256_CBC_SHA\"\n# define TLS1_RFC_RSA_PSK_WITH_3DES_EDE_CBC_SHA          \"TLS_RSA_PSK_WITH_3DES_EDE_CBC_SHA\"\n# define TLS1_RFC_RSA_PSK_WITH_AES_128_CBC_SHA           \"TLS_RSA_PSK_WITH_AES_128_CBC_SHA\"\n# define TLS1_RFC_RSA_PSK_WITH_AES_256_CBC_SHA           \"TLS_RSA_PSK_WITH_AES_256_CBC_SHA\"\n# define TLS1_RFC_PSK_WITH_AES_128_GCM_SHA256            \"TLS_PSK_WITH_AES_128_GCM_SHA256\"\n# define TLS1_RFC_PSK_WITH_AES_256_GCM_SHA384            \"TLS_PSK_WITH_AES_256_GCM_SHA384\"\n# define TLS1_RFC_DHE_PSK_WITH_AES_128_GCM_SHA256        \"TLS_DHE_PSK_WITH_AES_128_GCM_SHA256\"\n# define TLS1_RFC_DHE_PSK_WITH_AES_256_GCM_SHA384        \"TLS_DHE_PSK_WITH_AES_256_GCM_SHA384\"\n# define TLS1_RFC_RSA_PSK_WITH_AES_128_GCM_SHA256        \"TLS_RSA_PSK_WITH_AES_128_GCM_SHA256\"\n# define TLS1_RFC_RSA_PSK_WITH_AES_256_GCM_SHA384        \"TLS_RSA_PSK_WITH_AES_256_GCM_SHA384\"\n# define TLS1_RFC_PSK_WITH_AES_128_CBC_SHA256            \"TLS_PSK_WITH_AES_128_CBC_SHA256\"\n# define TLS1_RFC_PSK_WITH_AES_256_CBC_SHA384            \"TLS_PSK_WITH_AES_256_CBC_SHA384\"\n# define TLS1_RFC_PSK_WITH_NULL_SHA256                   \"TLS_PSK_WITH_NULL_SHA256\"\n# define TLS1_RFC_PSK_WITH_NULL_SHA384                   \"TLS_PSK_WITH_NULL_SHA384\"\n# define TLS1_RFC_DHE_PSK_WITH_AES_128_CBC_SHA256        \"TLS_DHE_PSK_WITH_AES_128_CBC_SHA256\"\n# define TLS1_RFC_DHE_PSK_WITH_AES_256_CBC_SHA384        \"TLS_DHE_PSK_WITH_AES_256_CBC_SHA384\"\n# define TLS1_RFC_DHE_PSK_WITH_NULL_SHA256               \"TLS_DHE_PSK_WITH_NULL_SHA256\"\n# define TLS1_RFC_DHE_PSK_WITH_NULL_SHA384               \"TLS_DHE_PSK_WITH_NULL_SHA384\"\n# define TLS1_RFC_RSA_PSK_WITH_AES_128_CBC_SHA256        \"TLS_RSA_PSK_WITH_AES_128_CBC_SHA256\"\n# define TLS1_RFC_RSA_PSK_WITH_AES_256_CBC_SHA384        \"TLS_RSA_PSK_WITH_AES_256_CBC_SHA384\"\n# define TLS1_RFC_RSA_PSK_WITH_NULL_SHA256               \"TLS_RSA_PSK_WITH_NULL_SHA256\"\n# define TLS1_RFC_RSA_PSK_WITH_NULL_SHA384               \"TLS_RSA_PSK_WITH_NULL_SHA384\"\n# define TLS1_RFC_ECDHE_PSK_WITH_3DES_EDE_CBC_SHA        \"TLS_ECDHE_PSK_WITH_3DES_EDE_CBC_SHA\"\n# define TLS1_RFC_ECDHE_PSK_WITH_AES_128_CBC_SHA         \"TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA\"\n# define TLS1_RFC_ECDHE_PSK_WITH_AES_256_CBC_SHA         \"TLS_ECDHE_PSK_WITH_AES_256_CBC_SHA\"\n# define TLS1_RFC_ECDHE_PSK_WITH_AES_128_CBC_SHA256      \"TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA256\"\n# define TLS1_RFC_ECDHE_PSK_WITH_AES_256_CBC_SHA384      \"TLS_ECDHE_PSK_WITH_AES_256_CBC_SHA384\"\n# define TLS1_RFC_ECDHE_PSK_WITH_NULL_SHA                \"TLS_ECDHE_PSK_WITH_NULL_SHA\"\n# define TLS1_RFC_ECDHE_PSK_WITH_NULL_SHA256             \"TLS_ECDHE_PSK_WITH_NULL_SHA256\"\n# define TLS1_RFC_ECDHE_PSK_WITH_NULL_SHA384             \"TLS_ECDHE_PSK_WITH_NULL_SHA384\"\n# define TLS1_RFC_SRP_SHA_WITH_3DES_EDE_CBC_SHA          \"TLS_SRP_SHA_WITH_3DES_EDE_CBC_SHA\"\n# define TLS1_RFC_SRP_SHA_RSA_WITH_3DES_EDE_CBC_SHA      \"TLS_SRP_SHA_RSA_WITH_3DES_EDE_CBC_SHA\"\n# define TLS1_RFC_SRP_SHA_DSS_WITH_3DES_EDE_CBC_SHA      \"TLS_SRP_SHA_DSS_WITH_3DES_EDE_CBC_SHA\"\n# define TLS1_RFC_SRP_SHA_WITH_AES_128_CBC_SHA           \"TLS_SRP_SHA_WITH_AES_128_CBC_SHA\"\n# define TLS1_RFC_SRP_SHA_RSA_WITH_AES_128_CBC_SHA       \"TLS_SRP_SHA_RSA_WITH_AES_128_CBC_SHA\"\n# define TLS1_RFC_SRP_SHA_DSS_WITH_AES_128_CBC_SHA       \"TLS_SRP_SHA_DSS_WITH_AES_128_CBC_SHA\"\n# define TLS1_RFC_SRP_SHA_WITH_AES_256_CBC_SHA           \"TLS_SRP_SHA_WITH_AES_256_CBC_SHA\"\n# define TLS1_RFC_SRP_SHA_RSA_WITH_AES_256_CBC_SHA       \"TLS_SRP_SHA_RSA_WITH_AES_256_CBC_SHA\"\n# define TLS1_RFC_SRP_SHA_DSS_WITH_AES_256_CBC_SHA       \"TLS_SRP_SHA_DSS_WITH_AES_256_CBC_SHA\"\n# define TLS1_RFC_DHE_RSA_WITH_CHACHA20_POLY1305         \"TLS_DHE_RSA_WITH_CHACHA20_POLY1305_SHA256\"\n# define TLS1_RFC_ECDHE_RSA_WITH_CHACHA20_POLY1305       \"TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256\"\n# define TLS1_RFC_ECDHE_ECDSA_WITH_CHACHA20_POLY1305     \"TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256\"\n# define TLS1_RFC_PSK_WITH_CHACHA20_POLY1305             \"TLS_PSK_WITH_CHACHA20_POLY1305_SHA256\"\n# define TLS1_RFC_ECDHE_PSK_WITH_CHACHA20_POLY1305       \"TLS_ECDHE_PSK_WITH_CHACHA20_POLY1305_SHA256\"\n# define TLS1_RFC_DHE_PSK_WITH_CHACHA20_POLY1305         \"TLS_DHE_PSK_WITH_CHACHA20_POLY1305_SHA256\"\n# define TLS1_RFC_RSA_PSK_WITH_CHACHA20_POLY1305         \"TLS_RSA_PSK_WITH_CHACHA20_POLY1305_SHA256\"\n# define TLS1_RFC_RSA_WITH_CAMELLIA_128_CBC_SHA256       \"TLS_RSA_WITH_CAMELLIA_128_CBC_SHA256\"\n# define TLS1_RFC_DHE_DSS_WITH_CAMELLIA_128_CBC_SHA256   \"TLS_DHE_DSS_WITH_CAMELLIA_128_CBC_SHA256\"\n# define TLS1_RFC_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA256   \"TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA256\"\n# define TLS1_RFC_ADH_WITH_CAMELLIA_128_CBC_SHA256       \"TLS_DH_anon_WITH_CAMELLIA_128_CBC_SHA256\"\n# define TLS1_RFC_RSA_WITH_CAMELLIA_256_CBC_SHA256       \"TLS_RSA_WITH_CAMELLIA_256_CBC_SHA256\"\n# define TLS1_RFC_DHE_DSS_WITH_CAMELLIA_256_CBC_SHA256   \"TLS_DHE_DSS_WITH_CAMELLIA_256_CBC_SHA256\"\n# define TLS1_RFC_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA256   \"TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA256\"\n# define TLS1_RFC_ADH_WITH_CAMELLIA_256_CBC_SHA256       \"TLS_DH_anon_WITH_CAMELLIA_256_CBC_SHA256\"\n# define TLS1_RFC_RSA_WITH_CAMELLIA_256_CBC_SHA          \"TLS_RSA_WITH_CAMELLIA_256_CBC_SHA\"\n# define TLS1_RFC_DHE_DSS_WITH_CAMELLIA_256_CBC_SHA      \"TLS_DHE_DSS_WITH_CAMELLIA_256_CBC_SHA\"\n# define TLS1_RFC_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA      \"TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA\"\n# define TLS1_RFC_ADH_WITH_CAMELLIA_256_CBC_SHA          \"TLS_DH_anon_WITH_CAMELLIA_256_CBC_SHA\"\n# define TLS1_RFC_RSA_WITH_CAMELLIA_128_CBC_SHA          \"TLS_RSA_WITH_CAMELLIA_128_CBC_SHA\"\n# define TLS1_RFC_DHE_DSS_WITH_CAMELLIA_128_CBC_SHA      \"TLS_DHE_DSS_WITH_CAMELLIA_128_CBC_SHA\"\n# define TLS1_RFC_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA      \"TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA\"\n# define TLS1_RFC_ADH_WITH_CAMELLIA_128_CBC_SHA          \"TLS_DH_anon_WITH_CAMELLIA_128_CBC_SHA\"\n# define TLS1_RFC_ECDHE_ECDSA_WITH_CAMELLIA_128_CBC_SHA256 \"TLS_ECDHE_ECDSA_WITH_CAMELLIA_128_CBC_SHA256\"\n# define TLS1_RFC_ECDHE_ECDSA_WITH_CAMELLIA_256_CBC_SHA384 \"TLS_ECDHE_ECDSA_WITH_CAMELLIA_256_CBC_SHA384\"\n# define TLS1_RFC_ECDHE_RSA_WITH_CAMELLIA_128_CBC_SHA256 \"TLS_ECDHE_RSA_WITH_CAMELLIA_128_CBC_SHA256\"\n# define TLS1_RFC_ECDHE_RSA_WITH_CAMELLIA_256_CBC_SHA384 \"TLS_ECDHE_RSA_WITH_CAMELLIA_256_CBC_SHA384\"\n# define TLS1_RFC_PSK_WITH_CAMELLIA_128_CBC_SHA256       \"TLS_PSK_WITH_CAMELLIA_128_CBC_SHA256\"\n# define TLS1_RFC_PSK_WITH_CAMELLIA_256_CBC_SHA384       \"TLS_PSK_WITH_CAMELLIA_256_CBC_SHA384\"\n# define TLS1_RFC_DHE_PSK_WITH_CAMELLIA_128_CBC_SHA256   \"TLS_DHE_PSK_WITH_CAMELLIA_128_CBC_SHA256\"\n# define TLS1_RFC_DHE_PSK_WITH_CAMELLIA_256_CBC_SHA384   \"TLS_DHE_PSK_WITH_CAMELLIA_256_CBC_SHA384\"\n# define TLS1_RFC_RSA_PSK_WITH_CAMELLIA_128_CBC_SHA256   \"TLS_RSA_PSK_WITH_CAMELLIA_128_CBC_SHA256\"\n# define TLS1_RFC_RSA_PSK_WITH_CAMELLIA_256_CBC_SHA384   \"TLS_RSA_PSK_WITH_CAMELLIA_256_CBC_SHA384\"\n# define TLS1_RFC_ECDHE_PSK_WITH_CAMELLIA_128_CBC_SHA256 \"TLS_ECDHE_PSK_WITH_CAMELLIA_128_CBC_SHA256\"\n# define TLS1_RFC_ECDHE_PSK_WITH_CAMELLIA_256_CBC_SHA384 \"TLS_ECDHE_PSK_WITH_CAMELLIA_256_CBC_SHA384\"\n# define TLS1_RFC_RSA_WITH_SEED_SHA                      \"TLS_RSA_WITH_SEED_CBC_SHA\"\n# define TLS1_RFC_DHE_DSS_WITH_SEED_SHA                  \"TLS_DHE_DSS_WITH_SEED_CBC_SHA\"\n# define TLS1_RFC_DHE_RSA_WITH_SEED_SHA                  \"TLS_DHE_RSA_WITH_SEED_CBC_SHA\"\n# define TLS1_RFC_ADH_WITH_SEED_SHA                      \"TLS_DH_anon_WITH_SEED_CBC_SHA\"\n# define TLS1_RFC_ECDHE_PSK_WITH_RC4_128_SHA             \"TLS_ECDHE_PSK_WITH_RC4_128_SHA\"\n# define TLS1_RFC_ECDH_anon_WITH_RC4_128_SHA             \"TLS_ECDH_anon_WITH_RC4_128_SHA\"\n# define TLS1_RFC_ECDHE_ECDSA_WITH_RC4_128_SHA           \"TLS_ECDHE_ECDSA_WITH_RC4_128_SHA\"\n# define TLS1_RFC_ECDHE_RSA_WITH_RC4_128_SHA             \"TLS_ECDHE_RSA_WITH_RC4_128_SHA\"\n# define TLS1_RFC_PSK_WITH_RC4_128_SHA                   \"TLS_PSK_WITH_RC4_128_SHA\"\n# define TLS1_RFC_RSA_PSK_WITH_RC4_128_SHA               \"TLS_RSA_PSK_WITH_RC4_128_SHA\"\n# define TLS1_RFC_DHE_PSK_WITH_RC4_128_SHA               \"TLS_DHE_PSK_WITH_RC4_128_SHA\"\n# define TLS1_RFC_RSA_WITH_ARIA_128_GCM_SHA256           \"TLS_RSA_WITH_ARIA_128_GCM_SHA256\"\n# define TLS1_RFC_RSA_WITH_ARIA_256_GCM_SHA384           \"TLS_RSA_WITH_ARIA_256_GCM_SHA384\"\n# define TLS1_RFC_DHE_RSA_WITH_ARIA_128_GCM_SHA256       \"TLS_DHE_RSA_WITH_ARIA_128_GCM_SHA256\"\n# define TLS1_RFC_DHE_RSA_WITH_ARIA_256_GCM_SHA384       \"TLS_DHE_RSA_WITH_ARIA_256_GCM_SHA384\"\n# define TLS1_RFC_DH_RSA_WITH_ARIA_128_GCM_SHA256        \"TLS_DH_RSA_WITH_ARIA_128_GCM_SHA256\"\n# define TLS1_RFC_DH_RSA_WITH_ARIA_256_GCM_SHA384        \"TLS_DH_RSA_WITH_ARIA_256_GCM_SHA384\"\n# define TLS1_RFC_DHE_DSS_WITH_ARIA_128_GCM_SHA256       \"TLS_DHE_DSS_WITH_ARIA_128_GCM_SHA256\"\n# define TLS1_RFC_DHE_DSS_WITH_ARIA_256_GCM_SHA384       \"TLS_DHE_DSS_WITH_ARIA_256_GCM_SHA384\"\n# define TLS1_RFC_DH_DSS_WITH_ARIA_128_GCM_SHA256        \"TLS_DH_DSS_WITH_ARIA_128_GCM_SHA256\"\n# define TLS1_RFC_DH_DSS_WITH_ARIA_256_GCM_SHA384        \"TLS_DH_DSS_WITH_ARIA_256_GCM_SHA384\"\n# define TLS1_RFC_DH_anon_WITH_ARIA_128_GCM_SHA256       \"TLS_DH_anon_WITH_ARIA_128_GCM_SHA256\"\n# define TLS1_RFC_DH_anon_WITH_ARIA_256_GCM_SHA384       \"TLS_DH_anon_WITH_ARIA_256_GCM_SHA384\"\n# define TLS1_RFC_ECDHE_ECDSA_WITH_ARIA_128_GCM_SHA256   \"TLS_ECDHE_ECDSA_WITH_ARIA_128_GCM_SHA256\"\n# define TLS1_RFC_ECDHE_ECDSA_WITH_ARIA_256_GCM_SHA384   \"TLS_ECDHE_ECDSA_WITH_ARIA_256_GCM_SHA384\"\n# define TLS1_RFC_ECDH_ECDSA_WITH_ARIA_128_GCM_SHA256    \"TLS_ECDH_ECDSA_WITH_ARIA_128_GCM_SHA256\"\n# define TLS1_RFC_ECDH_ECDSA_WITH_ARIA_256_GCM_SHA384    \"TLS_ECDH_ECDSA_WITH_ARIA_256_GCM_SHA384\"\n# define TLS1_RFC_ECDHE_RSA_WITH_ARIA_128_GCM_SHA256     \"TLS_ECDHE_RSA_WITH_ARIA_128_GCM_SHA256\"\n# define TLS1_RFC_ECDHE_RSA_WITH_ARIA_256_GCM_SHA384     \"TLS_ECDHE_RSA_WITH_ARIA_256_GCM_SHA384\"\n# define TLS1_RFC_ECDH_RSA_WITH_ARIA_128_GCM_SHA256      \"TLS_ECDH_RSA_WITH_ARIA_128_GCM_SHA256\"\n# define TLS1_RFC_ECDH_RSA_WITH_ARIA_256_GCM_SHA384      \"TLS_ECDH_RSA_WITH_ARIA_256_GCM_SHA384\"\n# define TLS1_RFC_PSK_WITH_ARIA_128_GCM_SHA256           \"TLS_PSK_WITH_ARIA_128_GCM_SHA256\"\n# define TLS1_RFC_PSK_WITH_ARIA_256_GCM_SHA384           \"TLS_PSK_WITH_ARIA_256_GCM_SHA384\"\n# define TLS1_RFC_DHE_PSK_WITH_ARIA_128_GCM_SHA256       \"TLS_DHE_PSK_WITH_ARIA_128_GCM_SHA256\"\n# define TLS1_RFC_DHE_PSK_WITH_ARIA_256_GCM_SHA384       \"TLS_DHE_PSK_WITH_ARIA_256_GCM_SHA384\"\n# define TLS1_RFC_RSA_PSK_WITH_ARIA_128_GCM_SHA256       \"TLS_RSA_PSK_WITH_ARIA_128_GCM_SHA256\"\n# define TLS1_RFC_RSA_PSK_WITH_ARIA_256_GCM_SHA384       \"TLS_RSA_PSK_WITH_ARIA_256_GCM_SHA384\"\n\n\n/*\n * XXX Backward compatibility alert: Older versions of OpenSSL gave some DHE\n * ciphers names with \"EDH\" instead of \"DHE\".  Going forward, we should be\n * using DHE everywhere, though we may indefinitely maintain aliases for\n * users or configurations that used \"EDH\"\n */\n# define TLS1_TXT_DHE_DSS_WITH_RC4_128_SHA               \"DHE-DSS-RC4-SHA\"\n\n# define TLS1_TXT_PSK_WITH_NULL_SHA                      \"PSK-NULL-SHA\"\n# define TLS1_TXT_DHE_PSK_WITH_NULL_SHA                  \"DHE-PSK-NULL-SHA\"\n# define TLS1_TXT_RSA_PSK_WITH_NULL_SHA                  \"RSA-PSK-NULL-SHA\"\n\n/* AES ciphersuites from RFC3268 */\n# define TLS1_TXT_RSA_WITH_AES_128_SHA                   \"AES128-SHA\"\n# define TLS1_TXT_DH_DSS_WITH_AES_128_SHA                \"DH-DSS-AES128-SHA\"\n# define TLS1_TXT_DH_RSA_WITH_AES_128_SHA                \"DH-RSA-AES128-SHA\"\n# define TLS1_TXT_DHE_DSS_WITH_AES_128_SHA               \"DHE-DSS-AES128-SHA\"\n# define TLS1_TXT_DHE_RSA_WITH_AES_128_SHA               \"DHE-RSA-AES128-SHA\"\n# define TLS1_TXT_ADH_WITH_AES_128_SHA                   \"ADH-AES128-SHA\"\n\n# define TLS1_TXT_RSA_WITH_AES_256_SHA                   \"AES256-SHA\"\n# define TLS1_TXT_DH_DSS_WITH_AES_256_SHA                \"DH-DSS-AES256-SHA\"\n# define TLS1_TXT_DH_RSA_WITH_AES_256_SHA                \"DH-RSA-AES256-SHA\"\n# define TLS1_TXT_DHE_DSS_WITH_AES_256_SHA               \"DHE-DSS-AES256-SHA\"\n# define TLS1_TXT_DHE_RSA_WITH_AES_256_SHA               \"DHE-RSA-AES256-SHA\"\n# define TLS1_TXT_ADH_WITH_AES_256_SHA                   \"ADH-AES256-SHA\"\n\n/* ECC ciphersuites from RFC4492 */\n# define TLS1_TXT_ECDH_ECDSA_WITH_NULL_SHA               \"ECDH-ECDSA-NULL-SHA\"\n# define TLS1_TXT_ECDH_ECDSA_WITH_RC4_128_SHA            \"ECDH-ECDSA-RC4-SHA\"\n# define TLS1_TXT_ECDH_ECDSA_WITH_DES_192_CBC3_SHA       \"ECDH-ECDSA-DES-CBC3-SHA\"\n# define TLS1_TXT_ECDH_ECDSA_WITH_AES_128_CBC_SHA        \"ECDH-ECDSA-AES128-SHA\"\n# define TLS1_TXT_ECDH_ECDSA_WITH_AES_256_CBC_SHA        \"ECDH-ECDSA-AES256-SHA\"\n\n# define TLS1_TXT_ECDHE_ECDSA_WITH_NULL_SHA              \"ECDHE-ECDSA-NULL-SHA\"\n# define TLS1_TXT_ECDHE_ECDSA_WITH_RC4_128_SHA           \"ECDHE-ECDSA-RC4-SHA\"\n# define TLS1_TXT_ECDHE_ECDSA_WITH_DES_192_CBC3_SHA      \"ECDHE-ECDSA-DES-CBC3-SHA\"\n# define TLS1_TXT_ECDHE_ECDSA_WITH_AES_128_CBC_SHA       \"ECDHE-ECDSA-AES128-SHA\"\n# define TLS1_TXT_ECDHE_ECDSA_WITH_AES_256_CBC_SHA       \"ECDHE-ECDSA-AES256-SHA\"\n\n# define TLS1_TXT_ECDH_RSA_WITH_NULL_SHA                 \"ECDH-RSA-NULL-SHA\"\n# define TLS1_TXT_ECDH_RSA_WITH_RC4_128_SHA              \"ECDH-RSA-RC4-SHA\"\n# define TLS1_TXT_ECDH_RSA_WITH_DES_192_CBC3_SHA         \"ECDH-RSA-DES-CBC3-SHA\"\n# define TLS1_TXT_ECDH_RSA_WITH_AES_128_CBC_SHA          \"ECDH-RSA-AES128-SHA\"\n# define TLS1_TXT_ECDH_RSA_WITH_AES_256_CBC_SHA          \"ECDH-RSA-AES256-SHA\"\n\n# define TLS1_TXT_ECDHE_RSA_WITH_NULL_SHA                \"ECDHE-RSA-NULL-SHA\"\n# define TLS1_TXT_ECDHE_RSA_WITH_RC4_128_SHA             \"ECDHE-RSA-RC4-SHA\"\n# define TLS1_TXT_ECDHE_RSA_WITH_DES_192_CBC3_SHA        \"ECDHE-RSA-DES-CBC3-SHA\"\n# define TLS1_TXT_ECDHE_RSA_WITH_AES_128_CBC_SHA         \"ECDHE-RSA-AES128-SHA\"\n# define TLS1_TXT_ECDHE_RSA_WITH_AES_256_CBC_SHA         \"ECDHE-RSA-AES256-SHA\"\n\n# define TLS1_TXT_ECDH_anon_WITH_NULL_SHA                \"AECDH-NULL-SHA\"\n# define TLS1_TXT_ECDH_anon_WITH_RC4_128_SHA             \"AECDH-RC4-SHA\"\n# define TLS1_TXT_ECDH_anon_WITH_DES_192_CBC3_SHA        \"AECDH-DES-CBC3-SHA\"\n# define TLS1_TXT_ECDH_anon_WITH_AES_128_CBC_SHA         \"AECDH-AES128-SHA\"\n# define TLS1_TXT_ECDH_anon_WITH_AES_256_CBC_SHA         \"AECDH-AES256-SHA\"\n\n/* PSK ciphersuites from RFC 4279 */\n# define TLS1_TXT_PSK_WITH_RC4_128_SHA                   \"PSK-RC4-SHA\"\n# define TLS1_TXT_PSK_WITH_3DES_EDE_CBC_SHA              \"PSK-3DES-EDE-CBC-SHA\"\n# define TLS1_TXT_PSK_WITH_AES_128_CBC_SHA               \"PSK-AES128-CBC-SHA\"\n# define TLS1_TXT_PSK_WITH_AES_256_CBC_SHA               \"PSK-AES256-CBC-SHA\"\n\n# define TLS1_TXT_DHE_PSK_WITH_RC4_128_SHA               \"DHE-PSK-RC4-SHA\"\n# define TLS1_TXT_DHE_PSK_WITH_3DES_EDE_CBC_SHA          \"DHE-PSK-3DES-EDE-CBC-SHA\"\n# define TLS1_TXT_DHE_PSK_WITH_AES_128_CBC_SHA           \"DHE-PSK-AES128-CBC-SHA\"\n# define TLS1_TXT_DHE_PSK_WITH_AES_256_CBC_SHA           \"DHE-PSK-AES256-CBC-SHA\"\n# define TLS1_TXT_RSA_PSK_WITH_RC4_128_SHA               \"RSA-PSK-RC4-SHA\"\n# define TLS1_TXT_RSA_PSK_WITH_3DES_EDE_CBC_SHA          \"RSA-PSK-3DES-EDE-CBC-SHA\"\n# define TLS1_TXT_RSA_PSK_WITH_AES_128_CBC_SHA           \"RSA-PSK-AES128-CBC-SHA\"\n# define TLS1_TXT_RSA_PSK_WITH_AES_256_CBC_SHA           \"RSA-PSK-AES256-CBC-SHA\"\n\n/* PSK ciphersuites from RFC 5487 */\n# define TLS1_TXT_PSK_WITH_AES_128_GCM_SHA256            \"PSK-AES128-GCM-SHA256\"\n# define TLS1_TXT_PSK_WITH_AES_256_GCM_SHA384            \"PSK-AES256-GCM-SHA384\"\n# define TLS1_TXT_DHE_PSK_WITH_AES_128_GCM_SHA256        \"DHE-PSK-AES128-GCM-SHA256\"\n# define TLS1_TXT_DHE_PSK_WITH_AES_256_GCM_SHA384        \"DHE-PSK-AES256-GCM-SHA384\"\n# define TLS1_TXT_RSA_PSK_WITH_AES_128_GCM_SHA256        \"RSA-PSK-AES128-GCM-SHA256\"\n# define TLS1_TXT_RSA_PSK_WITH_AES_256_GCM_SHA384        \"RSA-PSK-AES256-GCM-SHA384\"\n\n# define TLS1_TXT_PSK_WITH_AES_128_CBC_SHA256            \"PSK-AES128-CBC-SHA256\"\n# define TLS1_TXT_PSK_WITH_AES_256_CBC_SHA384            \"PSK-AES256-CBC-SHA384\"\n# define TLS1_TXT_PSK_WITH_NULL_SHA256                   \"PSK-NULL-SHA256\"\n# define TLS1_TXT_PSK_WITH_NULL_SHA384                   \"PSK-NULL-SHA384\"\n\n# define TLS1_TXT_DHE_PSK_WITH_AES_128_CBC_SHA256        \"DHE-PSK-AES128-CBC-SHA256\"\n# define TLS1_TXT_DHE_PSK_WITH_AES_256_CBC_SHA384        \"DHE-PSK-AES256-CBC-SHA384\"\n# define TLS1_TXT_DHE_PSK_WITH_NULL_SHA256               \"DHE-PSK-NULL-SHA256\"\n# define TLS1_TXT_DHE_PSK_WITH_NULL_SHA384               \"DHE-PSK-NULL-SHA384\"\n\n# define TLS1_TXT_RSA_PSK_WITH_AES_128_CBC_SHA256        \"RSA-PSK-AES128-CBC-SHA256\"\n# define TLS1_TXT_RSA_PSK_WITH_AES_256_CBC_SHA384        \"RSA-PSK-AES256-CBC-SHA384\"\n# define TLS1_TXT_RSA_PSK_WITH_NULL_SHA256               \"RSA-PSK-NULL-SHA256\"\n# define TLS1_TXT_RSA_PSK_WITH_NULL_SHA384               \"RSA-PSK-NULL-SHA384\"\n\n/* SRP ciphersuite from RFC 5054 */\n# define TLS1_TXT_SRP_SHA_WITH_3DES_EDE_CBC_SHA          \"SRP-3DES-EDE-CBC-SHA\"\n# define TLS1_TXT_SRP_SHA_RSA_WITH_3DES_EDE_CBC_SHA      \"SRP-RSA-3DES-EDE-CBC-SHA\"\n# define TLS1_TXT_SRP_SHA_DSS_WITH_3DES_EDE_CBC_SHA      \"SRP-DSS-3DES-EDE-CBC-SHA\"\n# define TLS1_TXT_SRP_SHA_WITH_AES_128_CBC_SHA           \"SRP-AES-128-CBC-SHA\"\n# define TLS1_TXT_SRP_SHA_RSA_WITH_AES_128_CBC_SHA       \"SRP-RSA-AES-128-CBC-SHA\"\n# define TLS1_TXT_SRP_SHA_DSS_WITH_AES_128_CBC_SHA       \"SRP-DSS-AES-128-CBC-SHA\"\n# define TLS1_TXT_SRP_SHA_WITH_AES_256_CBC_SHA           \"SRP-AES-256-CBC-SHA\"\n# define TLS1_TXT_SRP_SHA_RSA_WITH_AES_256_CBC_SHA       \"SRP-RSA-AES-256-CBC-SHA\"\n# define TLS1_TXT_SRP_SHA_DSS_WITH_AES_256_CBC_SHA       \"SRP-DSS-AES-256-CBC-SHA\"\n\n/* Camellia ciphersuites from RFC4132 */\n# define TLS1_TXT_RSA_WITH_CAMELLIA_128_CBC_SHA          \"CAMELLIA128-SHA\"\n# define TLS1_TXT_DH_DSS_WITH_CAMELLIA_128_CBC_SHA       \"DH-DSS-CAMELLIA128-SHA\"\n# define TLS1_TXT_DH_RSA_WITH_CAMELLIA_128_CBC_SHA       \"DH-RSA-CAMELLIA128-SHA\"\n# define TLS1_TXT_DHE_DSS_WITH_CAMELLIA_128_CBC_SHA      \"DHE-DSS-CAMELLIA128-SHA\"\n# define TLS1_TXT_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA      \"DHE-RSA-CAMELLIA128-SHA\"\n# define TLS1_TXT_ADH_WITH_CAMELLIA_128_CBC_SHA          \"ADH-CAMELLIA128-SHA\"\n\n# define TLS1_TXT_RSA_WITH_CAMELLIA_256_CBC_SHA          \"CAMELLIA256-SHA\"\n# define TLS1_TXT_DH_DSS_WITH_CAMELLIA_256_CBC_SHA       \"DH-DSS-CAMELLIA256-SHA\"\n# define TLS1_TXT_DH_RSA_WITH_CAMELLIA_256_CBC_SHA       \"DH-RSA-CAMELLIA256-SHA\"\n# define TLS1_TXT_DHE_DSS_WITH_CAMELLIA_256_CBC_SHA      \"DHE-DSS-CAMELLIA256-SHA\"\n# define TLS1_TXT_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA      \"DHE-RSA-CAMELLIA256-SHA\"\n# define TLS1_TXT_ADH_WITH_CAMELLIA_256_CBC_SHA          \"ADH-CAMELLIA256-SHA\"\n\n/* TLS 1.2 Camellia SHA-256 ciphersuites from RFC5932 */\n# define TLS1_TXT_RSA_WITH_CAMELLIA_128_CBC_SHA256               \"CAMELLIA128-SHA256\"\n# define TLS1_TXT_DH_DSS_WITH_CAMELLIA_128_CBC_SHA256            \"DH-DSS-CAMELLIA128-SHA256\"\n# define TLS1_TXT_DH_RSA_WITH_CAMELLIA_128_CBC_SHA256            \"DH-RSA-CAMELLIA128-SHA256\"\n# define TLS1_TXT_DHE_DSS_WITH_CAMELLIA_128_CBC_SHA256           \"DHE-DSS-CAMELLIA128-SHA256\"\n# define TLS1_TXT_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA256           \"DHE-RSA-CAMELLIA128-SHA256\"\n# define TLS1_TXT_ADH_WITH_CAMELLIA_128_CBC_SHA256               \"ADH-CAMELLIA128-SHA256\"\n\n# define TLS1_TXT_RSA_WITH_CAMELLIA_256_CBC_SHA256               \"CAMELLIA256-SHA256\"\n# define TLS1_TXT_DH_DSS_WITH_CAMELLIA_256_CBC_SHA256            \"DH-DSS-CAMELLIA256-SHA256\"\n# define TLS1_TXT_DH_RSA_WITH_CAMELLIA_256_CBC_SHA256            \"DH-RSA-CAMELLIA256-SHA256\"\n# define TLS1_TXT_DHE_DSS_WITH_CAMELLIA_256_CBC_SHA256           \"DHE-DSS-CAMELLIA256-SHA256\"\n# define TLS1_TXT_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA256           \"DHE-RSA-CAMELLIA256-SHA256\"\n# define TLS1_TXT_ADH_WITH_CAMELLIA_256_CBC_SHA256               \"ADH-CAMELLIA256-SHA256\"\n\n# define TLS1_TXT_PSK_WITH_CAMELLIA_128_CBC_SHA256               \"PSK-CAMELLIA128-SHA256\"\n# define TLS1_TXT_PSK_WITH_CAMELLIA_256_CBC_SHA384               \"PSK-CAMELLIA256-SHA384\"\n# define TLS1_TXT_DHE_PSK_WITH_CAMELLIA_128_CBC_SHA256           \"DHE-PSK-CAMELLIA128-SHA256\"\n# define TLS1_TXT_DHE_PSK_WITH_CAMELLIA_256_CBC_SHA384           \"DHE-PSK-CAMELLIA256-SHA384\"\n# define TLS1_TXT_RSA_PSK_WITH_CAMELLIA_128_CBC_SHA256           \"RSA-PSK-CAMELLIA128-SHA256\"\n# define TLS1_TXT_RSA_PSK_WITH_CAMELLIA_256_CBC_SHA384           \"RSA-PSK-CAMELLIA256-SHA384\"\n# define TLS1_TXT_ECDHE_PSK_WITH_CAMELLIA_128_CBC_SHA256         \"ECDHE-PSK-CAMELLIA128-SHA256\"\n# define TLS1_TXT_ECDHE_PSK_WITH_CAMELLIA_256_CBC_SHA384         \"ECDHE-PSK-CAMELLIA256-SHA384\"\n\n/* SEED ciphersuites from RFC4162 */\n# define TLS1_TXT_RSA_WITH_SEED_SHA                      \"SEED-SHA\"\n# define TLS1_TXT_DH_DSS_WITH_SEED_SHA                   \"DH-DSS-SEED-SHA\"\n# define TLS1_TXT_DH_RSA_WITH_SEED_SHA                   \"DH-RSA-SEED-SHA\"\n# define TLS1_TXT_DHE_DSS_WITH_SEED_SHA                  \"DHE-DSS-SEED-SHA\"\n# define TLS1_TXT_DHE_RSA_WITH_SEED_SHA                  \"DHE-RSA-SEED-SHA\"\n# define TLS1_TXT_ADH_WITH_SEED_SHA                      \"ADH-SEED-SHA\"\n\n/* TLS v1.2 ciphersuites */\n# define TLS1_TXT_RSA_WITH_NULL_SHA256                   \"NULL-SHA256\"\n# define TLS1_TXT_RSA_WITH_AES_128_SHA256                \"AES128-SHA256\"\n# define TLS1_TXT_RSA_WITH_AES_256_SHA256                \"AES256-SHA256\"\n# define TLS1_TXT_DH_DSS_WITH_AES_128_SHA256             \"DH-DSS-AES128-SHA256\"\n# define TLS1_TXT_DH_RSA_WITH_AES_128_SHA256             \"DH-RSA-AES128-SHA256\"\n# define TLS1_TXT_DHE_DSS_WITH_AES_128_SHA256            \"DHE-DSS-AES128-SHA256\"\n# define TLS1_TXT_DHE_RSA_WITH_AES_128_SHA256            \"DHE-RSA-AES128-SHA256\"\n# define TLS1_TXT_DH_DSS_WITH_AES_256_SHA256             \"DH-DSS-AES256-SHA256\"\n# define TLS1_TXT_DH_RSA_WITH_AES_256_SHA256             \"DH-RSA-AES256-SHA256\"\n# define TLS1_TXT_DHE_DSS_WITH_AES_256_SHA256            \"DHE-DSS-AES256-SHA256\"\n# define TLS1_TXT_DHE_RSA_WITH_AES_256_SHA256            \"DHE-RSA-AES256-SHA256\"\n# define TLS1_TXT_ADH_WITH_AES_128_SHA256                \"ADH-AES128-SHA256\"\n# define TLS1_TXT_ADH_WITH_AES_256_SHA256                \"ADH-AES256-SHA256\"\n\n/* TLS v1.2 GCM ciphersuites from RFC5288 */\n# define TLS1_TXT_RSA_WITH_AES_128_GCM_SHA256            \"AES128-GCM-SHA256\"\n# define TLS1_TXT_RSA_WITH_AES_256_GCM_SHA384            \"AES256-GCM-SHA384\"\n# define TLS1_TXT_DHE_RSA_WITH_AES_128_GCM_SHA256        \"DHE-RSA-AES128-GCM-SHA256\"\n# define TLS1_TXT_DHE_RSA_WITH_AES_256_GCM_SHA384        \"DHE-RSA-AES256-GCM-SHA384\"\n# define TLS1_TXT_DH_RSA_WITH_AES_128_GCM_SHA256         \"DH-RSA-AES128-GCM-SHA256\"\n# define TLS1_TXT_DH_RSA_WITH_AES_256_GCM_SHA384         \"DH-RSA-AES256-GCM-SHA384\"\n# define TLS1_TXT_DHE_DSS_WITH_AES_128_GCM_SHA256        \"DHE-DSS-AES128-GCM-SHA256\"\n# define TLS1_TXT_DHE_DSS_WITH_AES_256_GCM_SHA384        \"DHE-DSS-AES256-GCM-SHA384\"\n# define TLS1_TXT_DH_DSS_WITH_AES_128_GCM_SHA256         \"DH-DSS-AES128-GCM-SHA256\"\n# define TLS1_TXT_DH_DSS_WITH_AES_256_GCM_SHA384         \"DH-DSS-AES256-GCM-SHA384\"\n# define TLS1_TXT_ADH_WITH_AES_128_GCM_SHA256            \"ADH-AES128-GCM-SHA256\"\n# define TLS1_TXT_ADH_WITH_AES_256_GCM_SHA384            \"ADH-AES256-GCM-SHA384\"\n\n/* CCM ciphersuites from RFC6655 */\n# define TLS1_TXT_RSA_WITH_AES_128_CCM                   \"AES128-CCM\"\n# define TLS1_TXT_RSA_WITH_AES_256_CCM                   \"AES256-CCM\"\n# define TLS1_TXT_DHE_RSA_WITH_AES_128_CCM               \"DHE-RSA-AES128-CCM\"\n# define TLS1_TXT_DHE_RSA_WITH_AES_256_CCM               \"DHE-RSA-AES256-CCM\"\n\n# define TLS1_TXT_RSA_WITH_AES_128_CCM_8                 \"AES128-CCM8\"\n# define TLS1_TXT_RSA_WITH_AES_256_CCM_8                 \"AES256-CCM8\"\n# define TLS1_TXT_DHE_RSA_WITH_AES_128_CCM_8             \"DHE-RSA-AES128-CCM8\"\n# define TLS1_TXT_DHE_RSA_WITH_AES_256_CCM_8             \"DHE-RSA-AES256-CCM8\"\n\n# define TLS1_TXT_PSK_WITH_AES_128_CCM                   \"PSK-AES128-CCM\"\n# define TLS1_TXT_PSK_WITH_AES_256_CCM                   \"PSK-AES256-CCM\"\n# define TLS1_TXT_DHE_PSK_WITH_AES_128_CCM               \"DHE-PSK-AES128-CCM\"\n# define TLS1_TXT_DHE_PSK_WITH_AES_256_CCM               \"DHE-PSK-AES256-CCM\"\n\n# define TLS1_TXT_PSK_WITH_AES_128_CCM_8                 \"PSK-AES128-CCM8\"\n# define TLS1_TXT_PSK_WITH_AES_256_CCM_8                 \"PSK-AES256-CCM8\"\n# define TLS1_TXT_DHE_PSK_WITH_AES_128_CCM_8             \"DHE-PSK-AES128-CCM8\"\n# define TLS1_TXT_DHE_PSK_WITH_AES_256_CCM_8             \"DHE-PSK-AES256-CCM8\"\n\n/* CCM ciphersuites from RFC7251 */\n# define TLS1_TXT_ECDHE_ECDSA_WITH_AES_128_CCM       \"ECDHE-ECDSA-AES128-CCM\"\n# define TLS1_TXT_ECDHE_ECDSA_WITH_AES_256_CCM       \"ECDHE-ECDSA-AES256-CCM\"\n# define TLS1_TXT_ECDHE_ECDSA_WITH_AES_128_CCM_8     \"ECDHE-ECDSA-AES128-CCM8\"\n# define TLS1_TXT_ECDHE_ECDSA_WITH_AES_256_CCM_8     \"ECDHE-ECDSA-AES256-CCM8\"\n\n/* ECDH HMAC based ciphersuites from RFC5289 */\n# define TLS1_TXT_ECDHE_ECDSA_WITH_AES_128_SHA256    \"ECDHE-ECDSA-AES128-SHA256\"\n# define TLS1_TXT_ECDHE_ECDSA_WITH_AES_256_SHA384    \"ECDHE-ECDSA-AES256-SHA384\"\n# define TLS1_TXT_ECDH_ECDSA_WITH_AES_128_SHA256     \"ECDH-ECDSA-AES128-SHA256\"\n# define TLS1_TXT_ECDH_ECDSA_WITH_AES_256_SHA384     \"ECDH-ECDSA-AES256-SHA384\"\n# define TLS1_TXT_ECDHE_RSA_WITH_AES_128_SHA256      \"ECDHE-RSA-AES128-SHA256\"\n# define TLS1_TXT_ECDHE_RSA_WITH_AES_256_SHA384      \"ECDHE-RSA-AES256-SHA384\"\n# define TLS1_TXT_ECDH_RSA_WITH_AES_128_SHA256       \"ECDH-RSA-AES128-SHA256\"\n# define TLS1_TXT_ECDH_RSA_WITH_AES_256_SHA384       \"ECDH-RSA-AES256-SHA384\"\n\n/* ECDH GCM based ciphersuites from RFC5289 */\n# define TLS1_TXT_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256    \"ECDHE-ECDSA-AES128-GCM-SHA256\"\n# define TLS1_TXT_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384    \"ECDHE-ECDSA-AES256-GCM-SHA384\"\n# define TLS1_TXT_ECDH_ECDSA_WITH_AES_128_GCM_SHA256     \"ECDH-ECDSA-AES128-GCM-SHA256\"\n# define TLS1_TXT_ECDH_ECDSA_WITH_AES_256_GCM_SHA384     \"ECDH-ECDSA-AES256-GCM-SHA384\"\n# define TLS1_TXT_ECDHE_RSA_WITH_AES_128_GCM_SHA256      \"ECDHE-RSA-AES128-GCM-SHA256\"\n# define TLS1_TXT_ECDHE_RSA_WITH_AES_256_GCM_SHA384      \"ECDHE-RSA-AES256-GCM-SHA384\"\n# define TLS1_TXT_ECDH_RSA_WITH_AES_128_GCM_SHA256       \"ECDH-RSA-AES128-GCM-SHA256\"\n# define TLS1_TXT_ECDH_RSA_WITH_AES_256_GCM_SHA384       \"ECDH-RSA-AES256-GCM-SHA384\"\n\n/* TLS v1.2 PSK GCM ciphersuites from RFC5487 */\n# define TLS1_TXT_PSK_WITH_AES_128_GCM_SHA256            \"PSK-AES128-GCM-SHA256\"\n# define TLS1_TXT_PSK_WITH_AES_256_GCM_SHA384            \"PSK-AES256-GCM-SHA384\"\n\n/* ECDHE PSK ciphersuites from RFC 5489 */\n# define TLS1_TXT_ECDHE_PSK_WITH_RC4_128_SHA               \"ECDHE-PSK-RC4-SHA\"\n# define TLS1_TXT_ECDHE_PSK_WITH_3DES_EDE_CBC_SHA          \"ECDHE-PSK-3DES-EDE-CBC-SHA\"\n# define TLS1_TXT_ECDHE_PSK_WITH_AES_128_CBC_SHA           \"ECDHE-PSK-AES128-CBC-SHA\"\n# define TLS1_TXT_ECDHE_PSK_WITH_AES_256_CBC_SHA           \"ECDHE-PSK-AES256-CBC-SHA\"\n\n# define TLS1_TXT_ECDHE_PSK_WITH_AES_128_CBC_SHA256        \"ECDHE-PSK-AES128-CBC-SHA256\"\n# define TLS1_TXT_ECDHE_PSK_WITH_AES_256_CBC_SHA384        \"ECDHE-PSK-AES256-CBC-SHA384\"\n\n# define TLS1_TXT_ECDHE_PSK_WITH_NULL_SHA                  \"ECDHE-PSK-NULL-SHA\"\n# define TLS1_TXT_ECDHE_PSK_WITH_NULL_SHA256               \"ECDHE-PSK-NULL-SHA256\"\n# define TLS1_TXT_ECDHE_PSK_WITH_NULL_SHA384               \"ECDHE-PSK-NULL-SHA384\"\n\n/* Camellia-CBC ciphersuites from RFC6367 */\n# define TLS1_TXT_ECDHE_ECDSA_WITH_CAMELLIA_128_CBC_SHA256 \"ECDHE-ECDSA-CAMELLIA128-SHA256\"\n# define TLS1_TXT_ECDHE_ECDSA_WITH_CAMELLIA_256_CBC_SHA384 \"ECDHE-ECDSA-CAMELLIA256-SHA384\"\n# define TLS1_TXT_ECDH_ECDSA_WITH_CAMELLIA_128_CBC_SHA256  \"ECDH-ECDSA-CAMELLIA128-SHA256\"\n# define TLS1_TXT_ECDH_ECDSA_WITH_CAMELLIA_256_CBC_SHA384  \"ECDH-ECDSA-CAMELLIA256-SHA384\"\n# define TLS1_TXT_ECDHE_RSA_WITH_CAMELLIA_128_CBC_SHA256   \"ECDHE-RSA-CAMELLIA128-SHA256\"\n# define TLS1_TXT_ECDHE_RSA_WITH_CAMELLIA_256_CBC_SHA384   \"ECDHE-RSA-CAMELLIA256-SHA384\"\n# define TLS1_TXT_ECDH_RSA_WITH_CAMELLIA_128_CBC_SHA256    \"ECDH-RSA-CAMELLIA128-SHA256\"\n# define TLS1_TXT_ECDH_RSA_WITH_CAMELLIA_256_CBC_SHA384    \"ECDH-RSA-CAMELLIA256-SHA384\"\n\n/* draft-ietf-tls-chacha20-poly1305-03 */\n# define TLS1_TXT_ECDHE_RSA_WITH_CHACHA20_POLY1305         \"ECDHE-RSA-CHACHA20-POLY1305\"\n# define TLS1_TXT_ECDHE_ECDSA_WITH_CHACHA20_POLY1305       \"ECDHE-ECDSA-CHACHA20-POLY1305\"\n# define TLS1_TXT_DHE_RSA_WITH_CHACHA20_POLY1305           \"DHE-RSA-CHACHA20-POLY1305\"\n# define TLS1_TXT_PSK_WITH_CHACHA20_POLY1305               \"PSK-CHACHA20-POLY1305\"\n# define TLS1_TXT_ECDHE_PSK_WITH_CHACHA20_POLY1305         \"ECDHE-PSK-CHACHA20-POLY1305\"\n# define TLS1_TXT_DHE_PSK_WITH_CHACHA20_POLY1305           \"DHE-PSK-CHACHA20-POLY1305\"\n# define TLS1_TXT_RSA_PSK_WITH_CHACHA20_POLY1305           \"RSA-PSK-CHACHA20-POLY1305\"\n\n/* Aria ciphersuites from RFC6209 */\n# define TLS1_TXT_RSA_WITH_ARIA_128_GCM_SHA256             \"ARIA128-GCM-SHA256\"\n# define TLS1_TXT_RSA_WITH_ARIA_256_GCM_SHA384             \"ARIA256-GCM-SHA384\"\n# define TLS1_TXT_DHE_RSA_WITH_ARIA_128_GCM_SHA256         \"DHE-RSA-ARIA128-GCM-SHA256\"\n# define TLS1_TXT_DHE_RSA_WITH_ARIA_256_GCM_SHA384         \"DHE-RSA-ARIA256-GCM-SHA384\"\n# define TLS1_TXT_DH_RSA_WITH_ARIA_128_GCM_SHA256          \"DH-RSA-ARIA128-GCM-SHA256\"\n# define TLS1_TXT_DH_RSA_WITH_ARIA_256_GCM_SHA384          \"DH-RSA-ARIA256-GCM-SHA384\"\n# define TLS1_TXT_DHE_DSS_WITH_ARIA_128_GCM_SHA256         \"DHE-DSS-ARIA128-GCM-SHA256\"\n# define TLS1_TXT_DHE_DSS_WITH_ARIA_256_GCM_SHA384         \"DHE-DSS-ARIA256-GCM-SHA384\"\n# define TLS1_TXT_DH_DSS_WITH_ARIA_128_GCM_SHA256          \"DH-DSS-ARIA128-GCM-SHA256\"\n# define TLS1_TXT_DH_DSS_WITH_ARIA_256_GCM_SHA384          \"DH-DSS-ARIA256-GCM-SHA384\"\n# define TLS1_TXT_DH_anon_WITH_ARIA_128_GCM_SHA256         \"ADH-ARIA128-GCM-SHA256\"\n# define TLS1_TXT_DH_anon_WITH_ARIA_256_GCM_SHA384         \"ADH-ARIA256-GCM-SHA384\"\n# define TLS1_TXT_ECDHE_ECDSA_WITH_ARIA_128_GCM_SHA256     \"ECDHE-ECDSA-ARIA128-GCM-SHA256\"\n# define TLS1_TXT_ECDHE_ECDSA_WITH_ARIA_256_GCM_SHA384     \"ECDHE-ECDSA-ARIA256-GCM-SHA384\"\n# define TLS1_TXT_ECDH_ECDSA_WITH_ARIA_128_GCM_SHA256      \"ECDH-ECDSA-ARIA128-GCM-SHA256\"\n# define TLS1_TXT_ECDH_ECDSA_WITH_ARIA_256_GCM_SHA384      \"ECDH-ECDSA-ARIA256-GCM-SHA384\"\n# define TLS1_TXT_ECDHE_RSA_WITH_ARIA_128_GCM_SHA256       \"ECDHE-ARIA128-GCM-SHA256\"\n# define TLS1_TXT_ECDHE_RSA_WITH_ARIA_256_GCM_SHA384       \"ECDHE-ARIA256-GCM-SHA384\"\n# define TLS1_TXT_ECDH_RSA_WITH_ARIA_128_GCM_SHA256        \"ECDH-ARIA128-GCM-SHA256\"\n# define TLS1_TXT_ECDH_RSA_WITH_ARIA_256_GCM_SHA384        \"ECDH-ARIA256-GCM-SHA384\"\n# define TLS1_TXT_PSK_WITH_ARIA_128_GCM_SHA256             \"PSK-ARIA128-GCM-SHA256\"\n# define TLS1_TXT_PSK_WITH_ARIA_256_GCM_SHA384             \"PSK-ARIA256-GCM-SHA384\"\n# define TLS1_TXT_DHE_PSK_WITH_ARIA_128_GCM_SHA256         \"DHE-PSK-ARIA128-GCM-SHA256\"\n# define TLS1_TXT_DHE_PSK_WITH_ARIA_256_GCM_SHA384         \"DHE-PSK-ARIA256-GCM-SHA384\"\n# define TLS1_TXT_RSA_PSK_WITH_ARIA_128_GCM_SHA256         \"RSA-PSK-ARIA128-GCM-SHA256\"\n# define TLS1_TXT_RSA_PSK_WITH_ARIA_256_GCM_SHA384         \"RSA-PSK-ARIA256-GCM-SHA384\"\n\n# define TLS_CT_RSA_SIGN                 1\n# define TLS_CT_DSS_SIGN                 2\n# define TLS_CT_RSA_FIXED_DH             3\n# define TLS_CT_DSS_FIXED_DH             4\n# define TLS_CT_ECDSA_SIGN               64\n# define TLS_CT_RSA_FIXED_ECDH           65\n# define TLS_CT_ECDSA_FIXED_ECDH         66\n# define TLS_CT_GOST01_SIGN              22\n# define TLS_CT_GOST12_SIGN              238\n# define TLS_CT_GOST12_512_SIGN          239\n\n/*\n * when correcting this number, correct also SSL3_CT_NUMBER in ssl3.h (see\n * comment there)\n */\n# define TLS_CT_NUMBER                   10\n\n# if defined(SSL3_CT_NUMBER)\n#  if TLS_CT_NUMBER != SSL3_CT_NUMBER\n#    error \"SSL/TLS CT_NUMBER values do not match\"\n#  endif\n# endif\n\n# define TLS1_FINISH_MAC_LENGTH          12\n\n# define TLS_MD_MAX_CONST_SIZE                   22\n# define TLS_MD_CLIENT_FINISH_CONST              \"client finished\"\n# define TLS_MD_CLIENT_FINISH_CONST_SIZE         15\n# define TLS_MD_SERVER_FINISH_CONST              \"server finished\"\n# define TLS_MD_SERVER_FINISH_CONST_SIZE         15\n# define TLS_MD_KEY_EXPANSION_CONST              \"key expansion\"\n# define TLS_MD_KEY_EXPANSION_CONST_SIZE         13\n# define TLS_MD_CLIENT_WRITE_KEY_CONST           \"client write key\"\n# define TLS_MD_CLIENT_WRITE_KEY_CONST_SIZE      16\n# define TLS_MD_SERVER_WRITE_KEY_CONST           \"server write key\"\n# define TLS_MD_SERVER_WRITE_KEY_CONST_SIZE      16\n# define TLS_MD_IV_BLOCK_CONST                   \"IV block\"\n# define TLS_MD_IV_BLOCK_CONST_SIZE              8\n# define TLS_MD_MASTER_SECRET_CONST              \"master secret\"\n# define TLS_MD_MASTER_SECRET_CONST_SIZE         13\n# define TLS_MD_EXTENDED_MASTER_SECRET_CONST     \"extended master secret\"\n# define TLS_MD_EXTENDED_MASTER_SECRET_CONST_SIZE        22\n\n# ifdef CHARSET_EBCDIC\n#  undef TLS_MD_CLIENT_FINISH_CONST\n/*\n * client finished\n */\n#  define TLS_MD_CLIENT_FINISH_CONST    \"\\x63\\x6c\\x69\\x65\\x6e\\x74\\x20\\x66\\x69\\x6e\\x69\\x73\\x68\\x65\\x64\"\n\n#  undef TLS_MD_SERVER_FINISH_CONST\n/*\n * server finished\n */\n#  define TLS_MD_SERVER_FINISH_CONST    \"\\x73\\x65\\x72\\x76\\x65\\x72\\x20\\x66\\x69\\x6e\\x69\\x73\\x68\\x65\\x64\"\n\n#  undef TLS_MD_SERVER_WRITE_KEY_CONST\n/*\n * server write key\n */\n#  define TLS_MD_SERVER_WRITE_KEY_CONST \"\\x73\\x65\\x72\\x76\\x65\\x72\\x20\\x77\\x72\\x69\\x74\\x65\\x20\\x6b\\x65\\x79\"\n\n#  undef TLS_MD_KEY_EXPANSION_CONST\n/*\n * key expansion\n */\n#  define TLS_MD_KEY_EXPANSION_CONST    \"\\x6b\\x65\\x79\\x20\\x65\\x78\\x70\\x61\\x6e\\x73\\x69\\x6f\\x6e\"\n\n#  undef TLS_MD_CLIENT_WRITE_KEY_CONST\n/*\n * client write key\n */\n#  define TLS_MD_CLIENT_WRITE_KEY_CONST \"\\x63\\x6c\\x69\\x65\\x6e\\x74\\x20\\x77\\x72\\x69\\x74\\x65\\x20\\x6b\\x65\\x79\"\n\n#  undef TLS_MD_SERVER_WRITE_KEY_CONST\n/*\n * server write key\n */\n#  define TLS_MD_SERVER_WRITE_KEY_CONST \"\\x73\\x65\\x72\\x76\\x65\\x72\\x20\\x77\\x72\\x69\\x74\\x65\\x20\\x6b\\x65\\x79\"\n\n#  undef TLS_MD_IV_BLOCK_CONST\n/*\n * IV block\n */\n#  define TLS_MD_IV_BLOCK_CONST         \"\\x49\\x56\\x20\\x62\\x6c\\x6f\\x63\\x6b\"\n\n#  undef TLS_MD_MASTER_SECRET_CONST\n/*\n * master secret\n */\n#  define TLS_MD_MASTER_SECRET_CONST    \"\\x6d\\x61\\x73\\x74\\x65\\x72\\x20\\x73\\x65\\x63\\x72\\x65\\x74\"\n#  undef TLS_MD_EXTENDED_MASTER_SECRET_CONST\n/*\n * extended master secret\n */\n#  define TLS_MD_EXTENDED_MASTER_SECRET_CONST    \"\\x65\\x78\\x74\\x65\\x6e\\x64\\x65\\x64\\x20\\x6d\\x61\\x73\\x74\\x65\\x72\\x20\\x73\\x65\\x63\\x72\\x65\\x74\"\n# endif\n\n/* TLS Session Ticket extension struct */\nstruct tls_session_ticket_ext_st {\n    unsigned short length;\n    void *data;\n};\n\n#ifdef  __cplusplus\n}\n#endif\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/include/openssl/ts.h",
    "content": "/*\n * Copyright 2006-2018 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef HEADER_TS_H\n# define HEADER_TS_H\n\n# include <openssl/opensslconf.h>\n\n# ifndef OPENSSL_NO_TS\n# include <openssl/symhacks.h>\n# include <openssl/buffer.h>\n# include <openssl/evp.h>\n# include <openssl/bio.h>\n# include <openssl/asn1.h>\n# include <openssl/safestack.h>\n# include <openssl/rsa.h>\n# include <openssl/dsa.h>\n# include <openssl/dh.h>\n# include <openssl/tserr.h>\n# ifdef  __cplusplus\nextern \"C\" {\n# endif\n\n# include <openssl/x509.h>\n# include <openssl/x509v3.h>\n\ntypedef struct TS_msg_imprint_st TS_MSG_IMPRINT;\ntypedef struct TS_req_st TS_REQ;\ntypedef struct TS_accuracy_st TS_ACCURACY;\ntypedef struct TS_tst_info_st TS_TST_INFO;\n\n/* Possible values for status. */\n# define TS_STATUS_GRANTED                       0\n# define TS_STATUS_GRANTED_WITH_MODS             1\n# define TS_STATUS_REJECTION                     2\n# define TS_STATUS_WAITING                       3\n# define TS_STATUS_REVOCATION_WARNING            4\n# define TS_STATUS_REVOCATION_NOTIFICATION       5\n\n/* Possible values for failure_info. */\n# define TS_INFO_BAD_ALG                 0\n# define TS_INFO_BAD_REQUEST             2\n# define TS_INFO_BAD_DATA_FORMAT         5\n# define TS_INFO_TIME_NOT_AVAILABLE      14\n# define TS_INFO_UNACCEPTED_POLICY       15\n# define TS_INFO_UNACCEPTED_EXTENSION    16\n# define TS_INFO_ADD_INFO_NOT_AVAILABLE  17\n# define TS_INFO_SYSTEM_FAILURE          25\n\n\ntypedef struct TS_status_info_st TS_STATUS_INFO;\ntypedef struct ESS_issuer_serial ESS_ISSUER_SERIAL;\ntypedef struct ESS_cert_id ESS_CERT_ID;\ntypedef struct ESS_signing_cert ESS_SIGNING_CERT;\n\nDEFINE_STACK_OF(ESS_CERT_ID)\n\ntypedef struct ESS_cert_id_v2_st ESS_CERT_ID_V2;\ntypedef struct ESS_signing_cert_v2_st ESS_SIGNING_CERT_V2;\n\nDEFINE_STACK_OF(ESS_CERT_ID_V2)\n\ntypedef struct TS_resp_st TS_RESP;\n\nTS_REQ *TS_REQ_new(void);\nvoid TS_REQ_free(TS_REQ *a);\nint i2d_TS_REQ(const TS_REQ *a, unsigned char **pp);\nTS_REQ *d2i_TS_REQ(TS_REQ **a, const unsigned char **pp, long length);\n\nTS_REQ *TS_REQ_dup(TS_REQ *a);\n\n#ifndef OPENSSL_NO_STDIO\nTS_REQ *d2i_TS_REQ_fp(FILE *fp, TS_REQ **a);\nint i2d_TS_REQ_fp(FILE *fp, TS_REQ *a);\n#endif\nTS_REQ *d2i_TS_REQ_bio(BIO *fp, TS_REQ **a);\nint i2d_TS_REQ_bio(BIO *fp, TS_REQ *a);\n\nTS_MSG_IMPRINT *TS_MSG_IMPRINT_new(void);\nvoid TS_MSG_IMPRINT_free(TS_MSG_IMPRINT *a);\nint i2d_TS_MSG_IMPRINT(const TS_MSG_IMPRINT *a, unsigned char **pp);\nTS_MSG_IMPRINT *d2i_TS_MSG_IMPRINT(TS_MSG_IMPRINT **a,\n                                   const unsigned char **pp, long length);\n\nTS_MSG_IMPRINT *TS_MSG_IMPRINT_dup(TS_MSG_IMPRINT *a);\n\n#ifndef OPENSSL_NO_STDIO\nTS_MSG_IMPRINT *d2i_TS_MSG_IMPRINT_fp(FILE *fp, TS_MSG_IMPRINT **a);\nint i2d_TS_MSG_IMPRINT_fp(FILE *fp, TS_MSG_IMPRINT *a);\n#endif\nTS_MSG_IMPRINT *d2i_TS_MSG_IMPRINT_bio(BIO *bio, TS_MSG_IMPRINT **a);\nint i2d_TS_MSG_IMPRINT_bio(BIO *bio, TS_MSG_IMPRINT *a);\n\nTS_RESP *TS_RESP_new(void);\nvoid TS_RESP_free(TS_RESP *a);\nint i2d_TS_RESP(const TS_RESP *a, unsigned char **pp);\nTS_RESP *d2i_TS_RESP(TS_RESP **a, const unsigned char **pp, long length);\nTS_TST_INFO *PKCS7_to_TS_TST_INFO(PKCS7 *token);\nTS_RESP *TS_RESP_dup(TS_RESP *a);\n\n#ifndef OPENSSL_NO_STDIO\nTS_RESP *d2i_TS_RESP_fp(FILE *fp, TS_RESP **a);\nint i2d_TS_RESP_fp(FILE *fp, TS_RESP *a);\n#endif\nTS_RESP *d2i_TS_RESP_bio(BIO *bio, TS_RESP **a);\nint i2d_TS_RESP_bio(BIO *bio, TS_RESP *a);\n\nTS_STATUS_INFO *TS_STATUS_INFO_new(void);\nvoid TS_STATUS_INFO_free(TS_STATUS_INFO *a);\nint i2d_TS_STATUS_INFO(const TS_STATUS_INFO *a, unsigned char **pp);\nTS_STATUS_INFO *d2i_TS_STATUS_INFO(TS_STATUS_INFO **a,\n                                   const unsigned char **pp, long length);\nTS_STATUS_INFO *TS_STATUS_INFO_dup(TS_STATUS_INFO *a);\n\nTS_TST_INFO *TS_TST_INFO_new(void);\nvoid TS_TST_INFO_free(TS_TST_INFO *a);\nint i2d_TS_TST_INFO(const TS_TST_INFO *a, unsigned char **pp);\nTS_TST_INFO *d2i_TS_TST_INFO(TS_TST_INFO **a, const unsigned char **pp,\n                             long length);\nTS_TST_INFO *TS_TST_INFO_dup(TS_TST_INFO *a);\n\n#ifndef OPENSSL_NO_STDIO\nTS_TST_INFO *d2i_TS_TST_INFO_fp(FILE *fp, TS_TST_INFO **a);\nint i2d_TS_TST_INFO_fp(FILE *fp, TS_TST_INFO *a);\n#endif\nTS_TST_INFO *d2i_TS_TST_INFO_bio(BIO *bio, TS_TST_INFO **a);\nint i2d_TS_TST_INFO_bio(BIO *bio, TS_TST_INFO *a);\n\nTS_ACCURACY *TS_ACCURACY_new(void);\nvoid TS_ACCURACY_free(TS_ACCURACY *a);\nint i2d_TS_ACCURACY(const TS_ACCURACY *a, unsigned char **pp);\nTS_ACCURACY *d2i_TS_ACCURACY(TS_ACCURACY **a, const unsigned char **pp,\n                             long length);\nTS_ACCURACY *TS_ACCURACY_dup(TS_ACCURACY *a);\n\nESS_ISSUER_SERIAL *ESS_ISSUER_SERIAL_new(void);\nvoid ESS_ISSUER_SERIAL_free(ESS_ISSUER_SERIAL *a);\nint i2d_ESS_ISSUER_SERIAL(const ESS_ISSUER_SERIAL *a, unsigned char **pp);\nESS_ISSUER_SERIAL *d2i_ESS_ISSUER_SERIAL(ESS_ISSUER_SERIAL **a,\n                                         const unsigned char **pp,\n                                         long length);\nESS_ISSUER_SERIAL *ESS_ISSUER_SERIAL_dup(ESS_ISSUER_SERIAL *a);\n\nESS_CERT_ID *ESS_CERT_ID_new(void);\nvoid ESS_CERT_ID_free(ESS_CERT_ID *a);\nint i2d_ESS_CERT_ID(const ESS_CERT_ID *a, unsigned char **pp);\nESS_CERT_ID *d2i_ESS_CERT_ID(ESS_CERT_ID **a, const unsigned char **pp,\n                             long length);\nESS_CERT_ID *ESS_CERT_ID_dup(ESS_CERT_ID *a);\n\nESS_SIGNING_CERT *ESS_SIGNING_CERT_new(void);\nvoid ESS_SIGNING_CERT_free(ESS_SIGNING_CERT *a);\nint i2d_ESS_SIGNING_CERT(const ESS_SIGNING_CERT *a, unsigned char **pp);\nESS_SIGNING_CERT *d2i_ESS_SIGNING_CERT(ESS_SIGNING_CERT **a,\n                                       const unsigned char **pp, long length);\nESS_SIGNING_CERT *ESS_SIGNING_CERT_dup(ESS_SIGNING_CERT *a);\n\nESS_CERT_ID_V2 *ESS_CERT_ID_V2_new(void);\nvoid ESS_CERT_ID_V2_free(ESS_CERT_ID_V2 *a);\nint i2d_ESS_CERT_ID_V2(const ESS_CERT_ID_V2 *a, unsigned char **pp);\nESS_CERT_ID_V2 *d2i_ESS_CERT_ID_V2(ESS_CERT_ID_V2 **a,\n                                   const unsigned char **pp, long length);\nESS_CERT_ID_V2 *ESS_CERT_ID_V2_dup(ESS_CERT_ID_V2 *a);\n\nESS_SIGNING_CERT_V2 *ESS_SIGNING_CERT_V2_new(void);\nvoid ESS_SIGNING_CERT_V2_free(ESS_SIGNING_CERT_V2 *a);\nint i2d_ESS_SIGNING_CERT_V2(const ESS_SIGNING_CERT_V2 *a, unsigned char **pp);\nESS_SIGNING_CERT_V2 *d2i_ESS_SIGNING_CERT_V2(ESS_SIGNING_CERT_V2 **a,\n                                             const unsigned char **pp,\n                                             long length);\nESS_SIGNING_CERT_V2 *ESS_SIGNING_CERT_V2_dup(ESS_SIGNING_CERT_V2 *a);\n\nint TS_REQ_set_version(TS_REQ *a, long version);\nlong TS_REQ_get_version(const TS_REQ *a);\n\nint TS_STATUS_INFO_set_status(TS_STATUS_INFO *a, int i);\nconst ASN1_INTEGER *TS_STATUS_INFO_get0_status(const TS_STATUS_INFO *a);\n\nconst STACK_OF(ASN1_UTF8STRING) *\nTS_STATUS_INFO_get0_text(const TS_STATUS_INFO *a);\n\nconst ASN1_BIT_STRING *\nTS_STATUS_INFO_get0_failure_info(const TS_STATUS_INFO *a);\n\nint TS_REQ_set_msg_imprint(TS_REQ *a, TS_MSG_IMPRINT *msg_imprint);\nTS_MSG_IMPRINT *TS_REQ_get_msg_imprint(TS_REQ *a);\n\nint TS_MSG_IMPRINT_set_algo(TS_MSG_IMPRINT *a, X509_ALGOR *alg);\nX509_ALGOR *TS_MSG_IMPRINT_get_algo(TS_MSG_IMPRINT *a);\n\nint TS_MSG_IMPRINT_set_msg(TS_MSG_IMPRINT *a, unsigned char *d, int len);\nASN1_OCTET_STRING *TS_MSG_IMPRINT_get_msg(TS_MSG_IMPRINT *a);\n\nint TS_REQ_set_policy_id(TS_REQ *a, const ASN1_OBJECT *policy);\nASN1_OBJECT *TS_REQ_get_policy_id(TS_REQ *a);\n\nint TS_REQ_set_nonce(TS_REQ *a, const ASN1_INTEGER *nonce);\nconst ASN1_INTEGER *TS_REQ_get_nonce(const TS_REQ *a);\n\nint TS_REQ_set_cert_req(TS_REQ *a, int cert_req);\nint TS_REQ_get_cert_req(const TS_REQ *a);\n\nSTACK_OF(X509_EXTENSION) *TS_REQ_get_exts(TS_REQ *a);\nvoid TS_REQ_ext_free(TS_REQ *a);\nint TS_REQ_get_ext_count(TS_REQ *a);\nint TS_REQ_get_ext_by_NID(TS_REQ *a, int nid, int lastpos);\nint TS_REQ_get_ext_by_OBJ(TS_REQ *a, const ASN1_OBJECT *obj, int lastpos);\nint TS_REQ_get_ext_by_critical(TS_REQ *a, int crit, int lastpos);\nX509_EXTENSION *TS_REQ_get_ext(TS_REQ *a, int loc);\nX509_EXTENSION *TS_REQ_delete_ext(TS_REQ *a, int loc);\nint TS_REQ_add_ext(TS_REQ *a, X509_EXTENSION *ex, int loc);\nvoid *TS_REQ_get_ext_d2i(TS_REQ *a, int nid, int *crit, int *idx);\n\n/* Function declarations for TS_REQ defined in ts/ts_req_print.c */\n\nint TS_REQ_print_bio(BIO *bio, TS_REQ *a);\n\n/* Function declarations for TS_RESP defined in ts/ts_resp_utils.c */\n\nint TS_RESP_set_status_info(TS_RESP *a, TS_STATUS_INFO *info);\nTS_STATUS_INFO *TS_RESP_get_status_info(TS_RESP *a);\n\n/* Caller loses ownership of PKCS7 and TS_TST_INFO objects. */\nvoid TS_RESP_set_tst_info(TS_RESP *a, PKCS7 *p7, TS_TST_INFO *tst_info);\nPKCS7 *TS_RESP_get_token(TS_RESP *a);\nTS_TST_INFO *TS_RESP_get_tst_info(TS_RESP *a);\n\nint TS_TST_INFO_set_version(TS_TST_INFO *a, long version);\nlong TS_TST_INFO_get_version(const TS_TST_INFO *a);\n\nint TS_TST_INFO_set_policy_id(TS_TST_INFO *a, ASN1_OBJECT *policy_id);\nASN1_OBJECT *TS_TST_INFO_get_policy_id(TS_TST_INFO *a);\n\nint TS_TST_INFO_set_msg_imprint(TS_TST_INFO *a, TS_MSG_IMPRINT *msg_imprint);\nTS_MSG_IMPRINT *TS_TST_INFO_get_msg_imprint(TS_TST_INFO *a);\n\nint TS_TST_INFO_set_serial(TS_TST_INFO *a, const ASN1_INTEGER *serial);\nconst ASN1_INTEGER *TS_TST_INFO_get_serial(const TS_TST_INFO *a);\n\nint TS_TST_INFO_set_time(TS_TST_INFO *a, const ASN1_GENERALIZEDTIME *gtime);\nconst ASN1_GENERALIZEDTIME *TS_TST_INFO_get_time(const TS_TST_INFO *a);\n\nint TS_TST_INFO_set_accuracy(TS_TST_INFO *a, TS_ACCURACY *accuracy);\nTS_ACCURACY *TS_TST_INFO_get_accuracy(TS_TST_INFO *a);\n\nint TS_ACCURACY_set_seconds(TS_ACCURACY *a, const ASN1_INTEGER *seconds);\nconst ASN1_INTEGER *TS_ACCURACY_get_seconds(const TS_ACCURACY *a);\n\nint TS_ACCURACY_set_millis(TS_ACCURACY *a, const ASN1_INTEGER *millis);\nconst ASN1_INTEGER *TS_ACCURACY_get_millis(const TS_ACCURACY *a);\n\nint TS_ACCURACY_set_micros(TS_ACCURACY *a, const ASN1_INTEGER *micros);\nconst ASN1_INTEGER *TS_ACCURACY_get_micros(const TS_ACCURACY *a);\n\nint TS_TST_INFO_set_ordering(TS_TST_INFO *a, int ordering);\nint TS_TST_INFO_get_ordering(const TS_TST_INFO *a);\n\nint TS_TST_INFO_set_nonce(TS_TST_INFO *a, const ASN1_INTEGER *nonce);\nconst ASN1_INTEGER *TS_TST_INFO_get_nonce(const TS_TST_INFO *a);\n\nint TS_TST_INFO_set_tsa(TS_TST_INFO *a, GENERAL_NAME *tsa);\nGENERAL_NAME *TS_TST_INFO_get_tsa(TS_TST_INFO *a);\n\nSTACK_OF(X509_EXTENSION) *TS_TST_INFO_get_exts(TS_TST_INFO *a);\nvoid TS_TST_INFO_ext_free(TS_TST_INFO *a);\nint TS_TST_INFO_get_ext_count(TS_TST_INFO *a);\nint TS_TST_INFO_get_ext_by_NID(TS_TST_INFO *a, int nid, int lastpos);\nint TS_TST_INFO_get_ext_by_OBJ(TS_TST_INFO *a, const ASN1_OBJECT *obj,\n                               int lastpos);\nint TS_TST_INFO_get_ext_by_critical(TS_TST_INFO *a, int crit, int lastpos);\nX509_EXTENSION *TS_TST_INFO_get_ext(TS_TST_INFO *a, int loc);\nX509_EXTENSION *TS_TST_INFO_delete_ext(TS_TST_INFO *a, int loc);\nint TS_TST_INFO_add_ext(TS_TST_INFO *a, X509_EXTENSION *ex, int loc);\nvoid *TS_TST_INFO_get_ext_d2i(TS_TST_INFO *a, int nid, int *crit, int *idx);\n\n/*\n * Declarations related to response generation, defined in ts/ts_resp_sign.c.\n */\n\n/* Optional flags for response generation. */\n\n/* Don't include the TSA name in response. */\n# define TS_TSA_NAME             0x01\n\n/* Set ordering to true in response. */\n# define TS_ORDERING             0x02\n\n/*\n * Include the signer certificate and the other specified certificates in\n * the ESS signing certificate attribute beside the PKCS7 signed data.\n * Only the signer certificates is included by default.\n */\n# define TS_ESS_CERT_ID_CHAIN    0x04\n\n/* Forward declaration. */\nstruct TS_resp_ctx;\n\n/* This must return a unique number less than 160 bits long. */\ntypedef ASN1_INTEGER *(*TS_serial_cb) (struct TS_resp_ctx *, void *);\n\n/*\n * This must return the seconds and microseconds since Jan 1, 1970 in the sec\n * and usec variables allocated by the caller. Return non-zero for success\n * and zero for failure.\n */\ntypedef int (*TS_time_cb) (struct TS_resp_ctx *, void *, long *sec,\n                           long *usec);\n\n/*\n * This must process the given extension. It can modify the TS_TST_INFO\n * object of the context. Return values: !0 (processed), 0 (error, it must\n * set the status info/failure info of the response).\n */\ntypedef int (*TS_extension_cb) (struct TS_resp_ctx *, X509_EXTENSION *,\n                                void *);\n\ntypedef struct TS_resp_ctx TS_RESP_CTX;\n\nDEFINE_STACK_OF_CONST(EVP_MD)\n\n/* Creates a response context that can be used for generating responses. */\nTS_RESP_CTX *TS_RESP_CTX_new(void);\nvoid TS_RESP_CTX_free(TS_RESP_CTX *ctx);\n\n/* This parameter must be set. */\nint TS_RESP_CTX_set_signer_cert(TS_RESP_CTX *ctx, X509 *signer);\n\n/* This parameter must be set. */\nint TS_RESP_CTX_set_signer_key(TS_RESP_CTX *ctx, EVP_PKEY *key);\n\nint TS_RESP_CTX_set_signer_digest(TS_RESP_CTX *ctx,\n                                  const EVP_MD *signer_digest);\nint TS_RESP_CTX_set_ess_cert_id_digest(TS_RESP_CTX *ctx, const EVP_MD *md);\n\n/* This parameter must be set. */\nint TS_RESP_CTX_set_def_policy(TS_RESP_CTX *ctx, const ASN1_OBJECT *def_policy);\n\n/* No additional certs are included in the response by default. */\nint TS_RESP_CTX_set_certs(TS_RESP_CTX *ctx, STACK_OF(X509) *certs);\n\n/*\n * Adds a new acceptable policy, only the default policy is accepted by\n * default.\n */\nint TS_RESP_CTX_add_policy(TS_RESP_CTX *ctx, const ASN1_OBJECT *policy);\n\n/*\n * Adds a new acceptable message digest. Note that no message digests are\n * accepted by default. The md argument is shared with the caller.\n */\nint TS_RESP_CTX_add_md(TS_RESP_CTX *ctx, const EVP_MD *md);\n\n/* Accuracy is not included by default. */\nint TS_RESP_CTX_set_accuracy(TS_RESP_CTX *ctx,\n                             int secs, int millis, int micros);\n\n/*\n * Clock precision digits, i.e. the number of decimal digits: '0' means sec,\n * '3' msec, '6' usec, and so on. Default is 0.\n */\nint TS_RESP_CTX_set_clock_precision_digits(TS_RESP_CTX *ctx,\n                                           unsigned clock_precision_digits);\n/* At most we accept usec precision. */\n# define TS_MAX_CLOCK_PRECISION_DIGITS   6\n\n/* Maximum status message length */\n# define TS_MAX_STATUS_LENGTH   (1024 * 1024)\n\n/* No flags are set by default. */\nvoid TS_RESP_CTX_add_flags(TS_RESP_CTX *ctx, int flags);\n\n/* Default callback always returns a constant. */\nvoid TS_RESP_CTX_set_serial_cb(TS_RESP_CTX *ctx, TS_serial_cb cb, void *data);\n\n/* Default callback uses the gettimeofday() and gmtime() system calls. */\nvoid TS_RESP_CTX_set_time_cb(TS_RESP_CTX *ctx, TS_time_cb cb, void *data);\n\n/*\n * Default callback rejects all extensions. The extension callback is called\n * when the TS_TST_INFO object is already set up and not signed yet.\n */\n/* FIXME: extension handling is not tested yet. */\nvoid TS_RESP_CTX_set_extension_cb(TS_RESP_CTX *ctx,\n                                  TS_extension_cb cb, void *data);\n\n/* The following methods can be used in the callbacks. */\nint TS_RESP_CTX_set_status_info(TS_RESP_CTX *ctx,\n                                int status, const char *text);\n\n/* Sets the status info only if it is still TS_STATUS_GRANTED. */\nint TS_RESP_CTX_set_status_info_cond(TS_RESP_CTX *ctx,\n                                     int status, const char *text);\n\nint TS_RESP_CTX_add_failure_info(TS_RESP_CTX *ctx, int failure);\n\n/* The get methods below can be used in the extension callback. */\nTS_REQ *TS_RESP_CTX_get_request(TS_RESP_CTX *ctx);\n\nTS_TST_INFO *TS_RESP_CTX_get_tst_info(TS_RESP_CTX *ctx);\n\n/*\n * Creates the signed TS_TST_INFO and puts it in TS_RESP.\n * In case of errors it sets the status info properly.\n * Returns NULL only in case of memory allocation/fatal error.\n */\nTS_RESP *TS_RESP_create_response(TS_RESP_CTX *ctx, BIO *req_bio);\n\n/*\n * Declarations related to response verification,\n * they are defined in ts/ts_resp_verify.c.\n */\n\nint TS_RESP_verify_signature(PKCS7 *token, STACK_OF(X509) *certs,\n                             X509_STORE *store, X509 **signer_out);\n\n/* Context structure for the generic verify method. */\n\n/* Verify the signer's certificate and the signature of the response. */\n# define TS_VFY_SIGNATURE        (1u << 0)\n/* Verify the version number of the response. */\n# define TS_VFY_VERSION          (1u << 1)\n/* Verify if the policy supplied by the user matches the policy of the TSA. */\n# define TS_VFY_POLICY           (1u << 2)\n/*\n * Verify the message imprint provided by the user. This flag should not be\n * specified with TS_VFY_DATA.\n */\n# define TS_VFY_IMPRINT          (1u << 3)\n/*\n * Verify the message imprint computed by the verify method from the user\n * provided data and the MD algorithm of the response. This flag should not\n * be specified with TS_VFY_IMPRINT.\n */\n# define TS_VFY_DATA             (1u << 4)\n/* Verify the nonce value. */\n# define TS_VFY_NONCE            (1u << 5)\n/* Verify if the TSA name field matches the signer certificate. */\n# define TS_VFY_SIGNER           (1u << 6)\n/* Verify if the TSA name field equals to the user provided name. */\n# define TS_VFY_TSA_NAME         (1u << 7)\n\n/* You can use the following convenience constants. */\n# define TS_VFY_ALL_IMPRINT      (TS_VFY_SIGNATURE       \\\n                                 | TS_VFY_VERSION       \\\n                                 | TS_VFY_POLICY        \\\n                                 | TS_VFY_IMPRINT       \\\n                                 | TS_VFY_NONCE         \\\n                                 | TS_VFY_SIGNER        \\\n                                 | TS_VFY_TSA_NAME)\n# define TS_VFY_ALL_DATA         (TS_VFY_SIGNATURE       \\\n                                 | TS_VFY_VERSION       \\\n                                 | TS_VFY_POLICY        \\\n                                 | TS_VFY_DATA          \\\n                                 | TS_VFY_NONCE         \\\n                                 | TS_VFY_SIGNER        \\\n                                 | TS_VFY_TSA_NAME)\n\ntypedef struct TS_verify_ctx TS_VERIFY_CTX;\n\nint TS_RESP_verify_response(TS_VERIFY_CTX *ctx, TS_RESP *response);\nint TS_RESP_verify_token(TS_VERIFY_CTX *ctx, PKCS7 *token);\n\n/*\n * Declarations related to response verification context,\n */\nTS_VERIFY_CTX *TS_VERIFY_CTX_new(void);\nvoid TS_VERIFY_CTX_init(TS_VERIFY_CTX *ctx);\nvoid TS_VERIFY_CTX_free(TS_VERIFY_CTX *ctx);\nvoid TS_VERIFY_CTX_cleanup(TS_VERIFY_CTX *ctx);\nint TS_VERIFY_CTX_set_flags(TS_VERIFY_CTX *ctx, int f);\nint TS_VERIFY_CTX_add_flags(TS_VERIFY_CTX *ctx, int f);\nBIO *TS_VERIFY_CTX_set_data(TS_VERIFY_CTX *ctx, BIO *b);\nunsigned char *TS_VERIFY_CTX_set_imprint(TS_VERIFY_CTX *ctx,\n                                         unsigned char *hexstr, long len);\nX509_STORE *TS_VERIFY_CTX_set_store(TS_VERIFY_CTX *ctx, X509_STORE *s);\nSTACK_OF(X509) *TS_VERIFY_CTS_set_certs(TS_VERIFY_CTX *ctx, STACK_OF(X509) *certs);\n\n/*-\n * If ctx is NULL, it allocates and returns a new object, otherwise\n * it returns ctx. It initialises all the members as follows:\n * flags = TS_VFY_ALL_IMPRINT & ~(TS_VFY_TSA_NAME | TS_VFY_SIGNATURE)\n * certs = NULL\n * store = NULL\n * policy = policy from the request or NULL if absent (in this case\n *      TS_VFY_POLICY is cleared from flags as well)\n * md_alg = MD algorithm from request\n * imprint, imprint_len = imprint from request\n * data = NULL\n * nonce, nonce_len = nonce from the request or NULL if absent (in this case\n *      TS_VFY_NONCE is cleared from flags as well)\n * tsa_name = NULL\n * Important: after calling this method TS_VFY_SIGNATURE should be added!\n */\nTS_VERIFY_CTX *TS_REQ_to_TS_VERIFY_CTX(TS_REQ *req, TS_VERIFY_CTX *ctx);\n\n/* Function declarations for TS_RESP defined in ts/ts_resp_print.c */\n\nint TS_RESP_print_bio(BIO *bio, TS_RESP *a);\nint TS_STATUS_INFO_print_bio(BIO *bio, TS_STATUS_INFO *a);\nint TS_TST_INFO_print_bio(BIO *bio, TS_TST_INFO *a);\n\n/* Common utility functions defined in ts/ts_lib.c */\n\nint TS_ASN1_INTEGER_print_bio(BIO *bio, const ASN1_INTEGER *num);\nint TS_OBJ_print_bio(BIO *bio, const ASN1_OBJECT *obj);\nint TS_ext_print_bio(BIO *bio, const STACK_OF(X509_EXTENSION) *extensions);\nint TS_X509_ALGOR_print_bio(BIO *bio, const X509_ALGOR *alg);\nint TS_MSG_IMPRINT_print_bio(BIO *bio, TS_MSG_IMPRINT *msg);\n\n/*\n * Function declarations for handling configuration options, defined in\n * ts/ts_conf.c\n */\n\nX509 *TS_CONF_load_cert(const char *file);\nSTACK_OF(X509) *TS_CONF_load_certs(const char *file);\nEVP_PKEY *TS_CONF_load_key(const char *file, const char *pass);\nconst char *TS_CONF_get_tsa_section(CONF *conf, const char *section);\nint TS_CONF_set_serial(CONF *conf, const char *section, TS_serial_cb cb,\n                       TS_RESP_CTX *ctx);\n#ifndef OPENSSL_NO_ENGINE\nint TS_CONF_set_crypto_device(CONF *conf, const char *section,\n                              const char *device);\nint TS_CONF_set_default_engine(const char *name);\n#endif\nint TS_CONF_set_signer_cert(CONF *conf, const char *section,\n                            const char *cert, TS_RESP_CTX *ctx);\nint TS_CONF_set_certs(CONF *conf, const char *section, const char *certs,\n                      TS_RESP_CTX *ctx);\nint TS_CONF_set_signer_key(CONF *conf, const char *section,\n                           const char *key, const char *pass,\n                           TS_RESP_CTX *ctx);\nint TS_CONF_set_signer_digest(CONF *conf, const char *section,\n                               const char *md, TS_RESP_CTX *ctx);\nint TS_CONF_set_def_policy(CONF *conf, const char *section,\n                           const char *policy, TS_RESP_CTX *ctx);\nint TS_CONF_set_policies(CONF *conf, const char *section, TS_RESP_CTX *ctx);\nint TS_CONF_set_digests(CONF *conf, const char *section, TS_RESP_CTX *ctx);\nint TS_CONF_set_accuracy(CONF *conf, const char *section, TS_RESP_CTX *ctx);\nint TS_CONF_set_clock_precision_digits(CONF *conf, const char *section,\n                                       TS_RESP_CTX *ctx);\nint TS_CONF_set_ordering(CONF *conf, const char *section, TS_RESP_CTX *ctx);\nint TS_CONF_set_tsa_name(CONF *conf, const char *section, TS_RESP_CTX *ctx);\nint TS_CONF_set_ess_cert_id_chain(CONF *conf, const char *section,\n                                  TS_RESP_CTX *ctx);\nint TS_CONF_set_ess_cert_id_digest(CONF *conf, const char *section,\n                                      TS_RESP_CTX *ctx);\n\n#  ifdef  __cplusplus\n}\n#  endif\n# endif\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/include/openssl/tserr.h",
    "content": "/*\n * Generated by util/mkerr.pl DO NOT EDIT\n * Copyright 1995-2019 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef HEADER_TSERR_H\n# define HEADER_TSERR_H\n\n# ifndef HEADER_SYMHACKS_H\n#  include <openssl/symhacks.h>\n# endif\n\n# include <openssl/opensslconf.h>\n\n# ifndef OPENSSL_NO_TS\n\n#  ifdef  __cplusplus\nextern \"C\"\n#  endif\nint ERR_load_TS_strings(void);\n\n/*\n * TS function codes.\n */\n#  define TS_F_DEF_SERIAL_CB                               110\n#  define TS_F_DEF_TIME_CB                                 111\n#  define TS_F_ESS_ADD_SIGNING_CERT                        112\n#  define TS_F_ESS_ADD_SIGNING_CERT_V2                     147\n#  define TS_F_ESS_CERT_ID_NEW_INIT                        113\n#  define TS_F_ESS_CERT_ID_V2_NEW_INIT                     156\n#  define TS_F_ESS_SIGNING_CERT_NEW_INIT                   114\n#  define TS_F_ESS_SIGNING_CERT_V2_NEW_INIT                157\n#  define TS_F_INT_TS_RESP_VERIFY_TOKEN                    149\n#  define TS_F_PKCS7_TO_TS_TST_INFO                        148\n#  define TS_F_TS_ACCURACY_SET_MICROS                      115\n#  define TS_F_TS_ACCURACY_SET_MILLIS                      116\n#  define TS_F_TS_ACCURACY_SET_SECONDS                     117\n#  define TS_F_TS_CHECK_IMPRINTS                           100\n#  define TS_F_TS_CHECK_NONCES                             101\n#  define TS_F_TS_CHECK_POLICY                             102\n#  define TS_F_TS_CHECK_SIGNING_CERTS                      103\n#  define TS_F_TS_CHECK_STATUS_INFO                        104\n#  define TS_F_TS_COMPUTE_IMPRINT                          145\n#  define TS_F_TS_CONF_INVALID                             151\n#  define TS_F_TS_CONF_LOAD_CERT                           153\n#  define TS_F_TS_CONF_LOAD_CERTS                          154\n#  define TS_F_TS_CONF_LOAD_KEY                            155\n#  define TS_F_TS_CONF_LOOKUP_FAIL                         152\n#  define TS_F_TS_CONF_SET_DEFAULT_ENGINE                  146\n#  define TS_F_TS_GET_STATUS_TEXT                          105\n#  define TS_F_TS_MSG_IMPRINT_SET_ALGO                     118\n#  define TS_F_TS_REQ_SET_MSG_IMPRINT                      119\n#  define TS_F_TS_REQ_SET_NONCE                            120\n#  define TS_F_TS_REQ_SET_POLICY_ID                        121\n#  define TS_F_TS_RESP_CREATE_RESPONSE                     122\n#  define TS_F_TS_RESP_CREATE_TST_INFO                     123\n#  define TS_F_TS_RESP_CTX_ADD_FAILURE_INFO                124\n#  define TS_F_TS_RESP_CTX_ADD_MD                          125\n#  define TS_F_TS_RESP_CTX_ADD_POLICY                      126\n#  define TS_F_TS_RESP_CTX_NEW                             127\n#  define TS_F_TS_RESP_CTX_SET_ACCURACY                    128\n#  define TS_F_TS_RESP_CTX_SET_CERTS                       129\n#  define TS_F_TS_RESP_CTX_SET_DEF_POLICY                  130\n#  define TS_F_TS_RESP_CTX_SET_SIGNER_CERT                 131\n#  define TS_F_TS_RESP_CTX_SET_STATUS_INFO                 132\n#  define TS_F_TS_RESP_GET_POLICY                          133\n#  define TS_F_TS_RESP_SET_GENTIME_WITH_PRECISION          134\n#  define TS_F_TS_RESP_SET_STATUS_INFO                     135\n#  define TS_F_TS_RESP_SET_TST_INFO                        150\n#  define TS_F_TS_RESP_SIGN                                136\n#  define TS_F_TS_RESP_VERIFY_SIGNATURE                    106\n#  define TS_F_TS_TST_INFO_SET_ACCURACY                    137\n#  define TS_F_TS_TST_INFO_SET_MSG_IMPRINT                 138\n#  define TS_F_TS_TST_INFO_SET_NONCE                       139\n#  define TS_F_TS_TST_INFO_SET_POLICY_ID                   140\n#  define TS_F_TS_TST_INFO_SET_SERIAL                      141\n#  define TS_F_TS_TST_INFO_SET_TIME                        142\n#  define TS_F_TS_TST_INFO_SET_TSA                         143\n#  define TS_F_TS_VERIFY                                   108\n#  define TS_F_TS_VERIFY_CERT                              109\n#  define TS_F_TS_VERIFY_CTX_NEW                           144\n\n/*\n * TS reason codes.\n */\n#  define TS_R_BAD_PKCS7_TYPE                              132\n#  define TS_R_BAD_TYPE                                    133\n#  define TS_R_CANNOT_LOAD_CERT                            137\n#  define TS_R_CANNOT_LOAD_KEY                             138\n#  define TS_R_CERTIFICATE_VERIFY_ERROR                    100\n#  define TS_R_COULD_NOT_SET_ENGINE                        127\n#  define TS_R_COULD_NOT_SET_TIME                          115\n#  define TS_R_DETACHED_CONTENT                            134\n#  define TS_R_ESS_ADD_SIGNING_CERT_ERROR                  116\n#  define TS_R_ESS_ADD_SIGNING_CERT_V2_ERROR               139\n#  define TS_R_ESS_SIGNING_CERTIFICATE_ERROR               101\n#  define TS_R_INVALID_NULL_POINTER                        102\n#  define TS_R_INVALID_SIGNER_CERTIFICATE_PURPOSE          117\n#  define TS_R_MESSAGE_IMPRINT_MISMATCH                    103\n#  define TS_R_NONCE_MISMATCH                              104\n#  define TS_R_NONCE_NOT_RETURNED                          105\n#  define TS_R_NO_CONTENT                                  106\n#  define TS_R_NO_TIME_STAMP_TOKEN                         107\n#  define TS_R_PKCS7_ADD_SIGNATURE_ERROR                   118\n#  define TS_R_PKCS7_ADD_SIGNED_ATTR_ERROR                 119\n#  define TS_R_PKCS7_TO_TS_TST_INFO_FAILED                 129\n#  define TS_R_POLICY_MISMATCH                             108\n#  define TS_R_PRIVATE_KEY_DOES_NOT_MATCH_CERTIFICATE      120\n#  define TS_R_RESPONSE_SETUP_ERROR                        121\n#  define TS_R_SIGNATURE_FAILURE                           109\n#  define TS_R_THERE_MUST_BE_ONE_SIGNER                    110\n#  define TS_R_TIME_SYSCALL_ERROR                          122\n#  define TS_R_TOKEN_NOT_PRESENT                           130\n#  define TS_R_TOKEN_PRESENT                               131\n#  define TS_R_TSA_NAME_MISMATCH                           111\n#  define TS_R_TSA_UNTRUSTED                               112\n#  define TS_R_TST_INFO_SETUP_ERROR                        123\n#  define TS_R_TS_DATASIGN                                 124\n#  define TS_R_UNACCEPTABLE_POLICY                         125\n#  define TS_R_UNSUPPORTED_MD_ALGORITHM                    126\n#  define TS_R_UNSUPPORTED_VERSION                         113\n#  define TS_R_VAR_BAD_VALUE                               135\n#  define TS_R_VAR_LOOKUP_FAILURE                          136\n#  define TS_R_WRONG_CONTENT_TYPE                          114\n\n# endif\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/include/openssl/txt_db.h",
    "content": "/*\n * Copyright 1995-2017 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef HEADER_TXT_DB_H\n# define HEADER_TXT_DB_H\n\n# include <openssl/opensslconf.h>\n# include <openssl/bio.h>\n# include <openssl/safestack.h>\n# include <openssl/lhash.h>\n\n# define DB_ERROR_OK                     0\n# define DB_ERROR_MALLOC                 1\n# define DB_ERROR_INDEX_CLASH            2\n# define DB_ERROR_INDEX_OUT_OF_RANGE     3\n# define DB_ERROR_NO_INDEX               4\n# define DB_ERROR_INSERT_INDEX_CLASH     5\n# define DB_ERROR_WRONG_NUM_FIELDS       6\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\ntypedef OPENSSL_STRING *OPENSSL_PSTRING;\nDEFINE_SPECIAL_STACK_OF(OPENSSL_PSTRING, OPENSSL_STRING)\n\ntypedef struct txt_db_st {\n    int num_fields;\n    STACK_OF(OPENSSL_PSTRING) *data;\n    LHASH_OF(OPENSSL_STRING) **index;\n    int (**qual) (OPENSSL_STRING *);\n    long error;\n    long arg1;\n    long arg2;\n    OPENSSL_STRING *arg_row;\n} TXT_DB;\n\nTXT_DB *TXT_DB_read(BIO *in, int num);\nlong TXT_DB_write(BIO *out, TXT_DB *db);\nint TXT_DB_create_index(TXT_DB *db, int field, int (*qual) (OPENSSL_STRING *),\n                        OPENSSL_LH_HASHFUNC hash, OPENSSL_LH_COMPFUNC cmp);\nvoid TXT_DB_free(TXT_DB *db);\nOPENSSL_STRING *TXT_DB_get_by_index(TXT_DB *db, int idx,\n                                    OPENSSL_STRING *value);\nint TXT_DB_insert(TXT_DB *db, OPENSSL_STRING *value);\n\n#ifdef  __cplusplus\n}\n#endif\n\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/include/openssl/ui.h",
    "content": "/*\n * Copyright 2001-2018 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef HEADER_UI_H\n# define HEADER_UI_H\n\n# include <openssl/opensslconf.h>\n\n# if OPENSSL_API_COMPAT < 0x10100000L\n#  include <openssl/crypto.h>\n# endif\n# include <openssl/safestack.h>\n# include <openssl/pem.h>\n# include <openssl/ossl_typ.h>\n# include <openssl/uierr.h>\n\n/* For compatibility reasons, the macro OPENSSL_NO_UI is currently retained */\n# if OPENSSL_API_COMPAT < 0x10200000L\n#  ifdef OPENSSL_NO_UI_CONSOLE\n#   define OPENSSL_NO_UI\n#  endif\n# endif\n\n# ifdef  __cplusplus\nextern \"C\" {\n# endif\n\n/*\n * All the following functions return -1 or NULL on error and in some cases\n * (UI_process()) -2 if interrupted or in some other way cancelled. When\n * everything is fine, they return 0, a positive value or a non-NULL pointer,\n * all depending on their purpose.\n */\n\n/* Creators and destructor.   */\nUI *UI_new(void);\nUI *UI_new_method(const UI_METHOD *method);\nvoid UI_free(UI *ui);\n\n/*-\n   The following functions are used to add strings to be printed and prompt\n   strings to prompt for data.  The names are UI_{add,dup}_<function>_string\n   and UI_{add,dup}_input_boolean.\n\n   UI_{add,dup}_<function>_string have the following meanings:\n        add     add a text or prompt string.  The pointers given to these\n                functions are used verbatim, no copying is done.\n        dup     make a copy of the text or prompt string, then add the copy\n                to the collection of strings in the user interface.\n        <function>\n                The function is a name for the functionality that the given\n                string shall be used for.  It can be one of:\n                        input   use the string as data prompt.\n                        verify  use the string as verification prompt.  This\n                                is used to verify a previous input.\n                        info    use the string for informational output.\n                        error   use the string for error output.\n   Honestly, there's currently no difference between info and error for the\n   moment.\n\n   UI_{add,dup}_input_boolean have the same semantics for \"add\" and \"dup\",\n   and are typically used when one wants to prompt for a yes/no response.\n\n   All of the functions in this group take a UI and a prompt string.\n   The string input and verify addition functions also take a flag argument,\n   a buffer for the result to end up with, a minimum input size and a maximum\n   input size (the result buffer MUST be large enough to be able to contain\n   the maximum number of characters).  Additionally, the verify addition\n   functions takes another buffer to compare the result against.\n   The boolean input functions take an action description string (which should\n   be safe to ignore if the expected user action is obvious, for example with\n   a dialog box with an OK button and a Cancel button), a string of acceptable\n   characters to mean OK and to mean Cancel.  The two last strings are checked\n   to make sure they don't have common characters.  Additionally, the same\n   flag argument as for the string input is taken, as well as a result buffer.\n   The result buffer is required to be at least one byte long.  Depending on\n   the answer, the first character from the OK or the Cancel character strings\n   will be stored in the first byte of the result buffer.  No NUL will be\n   added, so the result is *not* a string.\n\n   On success, the all return an index of the added information.  That index\n   is useful when retrieving results with UI_get0_result(). */\nint UI_add_input_string(UI *ui, const char *prompt, int flags,\n                        char *result_buf, int minsize, int maxsize);\nint UI_dup_input_string(UI *ui, const char *prompt, int flags,\n                        char *result_buf, int minsize, int maxsize);\nint UI_add_verify_string(UI *ui, const char *prompt, int flags,\n                         char *result_buf, int minsize, int maxsize,\n                         const char *test_buf);\nint UI_dup_verify_string(UI *ui, const char *prompt, int flags,\n                         char *result_buf, int minsize, int maxsize,\n                         const char *test_buf);\nint UI_add_input_boolean(UI *ui, const char *prompt, const char *action_desc,\n                         const char *ok_chars, const char *cancel_chars,\n                         int flags, char *result_buf);\nint UI_dup_input_boolean(UI *ui, const char *prompt, const char *action_desc,\n                         const char *ok_chars, const char *cancel_chars,\n                         int flags, char *result_buf);\nint UI_add_info_string(UI *ui, const char *text);\nint UI_dup_info_string(UI *ui, const char *text);\nint UI_add_error_string(UI *ui, const char *text);\nint UI_dup_error_string(UI *ui, const char *text);\n\n/* These are the possible flags.  They can be or'ed together. */\n/* Use to have echoing of input */\n# define UI_INPUT_FLAG_ECHO              0x01\n/*\n * Use a default password.  Where that password is found is completely up to\n * the application, it might for example be in the user data set with\n * UI_add_user_data().  It is not recommended to have more than one input in\n * each UI being marked with this flag, or the application might get\n * confused.\n */\n# define UI_INPUT_FLAG_DEFAULT_PWD       0x02\n\n/*-\n * The user of these routines may want to define flags of their own.  The core\n * UI won't look at those, but will pass them on to the method routines.  They\n * must use higher bits so they don't get confused with the UI bits above.\n * UI_INPUT_FLAG_USER_BASE tells which is the lowest bit to use.  A good\n * example of use is this:\n *\n *    #define MY_UI_FLAG1       (0x01 << UI_INPUT_FLAG_USER_BASE)\n *\n*/\n# define UI_INPUT_FLAG_USER_BASE 16\n\n/*-\n * The following function helps construct a prompt.  object_desc is a\n * textual short description of the object, for example \"pass phrase\",\n * and object_name is the name of the object (might be a card name or\n * a file name.\n * The returned string shall always be allocated on the heap with\n * OPENSSL_malloc(), and need to be free'd with OPENSSL_free().\n *\n * If the ui_method doesn't contain a pointer to a user-defined prompt\n * constructor, a default string is built, looking like this:\n *\n *       \"Enter {object_desc} for {object_name}:\"\n *\n * So, if object_desc has the value \"pass phrase\" and object_name has\n * the value \"foo.key\", the resulting string is:\n *\n *       \"Enter pass phrase for foo.key:\"\n*/\nchar *UI_construct_prompt(UI *ui_method,\n                          const char *object_desc, const char *object_name);\n\n/*\n * The following function is used to store a pointer to user-specific data.\n * Any previous such pointer will be returned and replaced.\n *\n * For callback purposes, this function makes a lot more sense than using\n * ex_data, since the latter requires that different parts of OpenSSL or\n * applications share the same ex_data index.\n *\n * Note that the UI_OpenSSL() method completely ignores the user data. Other\n * methods may not, however.\n */\nvoid *UI_add_user_data(UI *ui, void *user_data);\n/*\n * Alternatively, this function is used to duplicate the user data.\n * This uses the duplicator method function.  The destroy function will\n * be used to free the user data in this case.\n */\nint UI_dup_user_data(UI *ui, void *user_data);\n/* We need a user data retrieving function as well.  */\nvoid *UI_get0_user_data(UI *ui);\n\n/* Return the result associated with a prompt given with the index i. */\nconst char *UI_get0_result(UI *ui, int i);\nint UI_get_result_length(UI *ui, int i);\n\n/* When all strings have been added, process the whole thing. */\nint UI_process(UI *ui);\n\n/*\n * Give a user interface parameterised control commands.  This can be used to\n * send down an integer, a data pointer or a function pointer, as well as be\n * used to get information from a UI.\n */\nint UI_ctrl(UI *ui, int cmd, long i, void *p, void (*f) (void));\n\n/* The commands */\n/*\n * Use UI_CONTROL_PRINT_ERRORS with the value 1 to have UI_process print the\n * OpenSSL error stack before printing any info or added error messages and\n * before any prompting.\n */\n# define UI_CTRL_PRINT_ERRORS            1\n/*\n * Check if a UI_process() is possible to do again with the same instance of\n * a user interface.  This makes UI_ctrl() return 1 if it is redoable, and 0\n * if not.\n */\n# define UI_CTRL_IS_REDOABLE             2\n\n/* Some methods may use extra data */\n# define UI_set_app_data(s,arg)         UI_set_ex_data(s,0,arg)\n# define UI_get_app_data(s)             UI_get_ex_data(s,0)\n\n# define UI_get_ex_new_index(l, p, newf, dupf, freef) \\\n    CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_UI, l, p, newf, dupf, freef)\nint UI_set_ex_data(UI *r, int idx, void *arg);\nvoid *UI_get_ex_data(UI *r, int idx);\n\n/* Use specific methods instead of the built-in one */\nvoid UI_set_default_method(const UI_METHOD *meth);\nconst UI_METHOD *UI_get_default_method(void);\nconst UI_METHOD *UI_get_method(UI *ui);\nconst UI_METHOD *UI_set_method(UI *ui, const UI_METHOD *meth);\n\n# ifndef OPENSSL_NO_UI_CONSOLE\n\n/* The method with all the built-in thingies */\nUI_METHOD *UI_OpenSSL(void);\n\n# endif\n\n/*\n * NULL method.  Literally does nothing, but may serve as a placeholder\n * to avoid internal default.\n */\nconst UI_METHOD *UI_null(void);\n\n/* ---------- For method writers ---------- */\n/*-\n   A method contains a number of functions that implement the low level\n   of the User Interface.  The functions are:\n\n        an opener       This function starts a session, maybe by opening\n                        a channel to a tty, or by opening a window.\n        a writer        This function is called to write a given string,\n                        maybe to the tty, maybe as a field label in a\n                        window.\n        a flusher       This function is called to flush everything that\n                        has been output so far.  It can be used to actually\n                        display a dialog box after it has been built.\n        a reader        This function is called to read a given prompt,\n                        maybe from the tty, maybe from a field in a\n                        window.  Note that it's called with all string\n                        structures, not only the prompt ones, so it must\n                        check such things itself.\n        a closer        This function closes the session, maybe by closing\n                        the channel to the tty, or closing the window.\n\n   All these functions are expected to return:\n\n        0       on error.\n        1       on success.\n        -1      on out-of-band events, for example if some prompting has\n                been canceled (by pressing Ctrl-C, for example).  This is\n                only checked when returned by the flusher or the reader.\n\n   The way this is used, the opener is first called, then the writer for all\n   strings, then the flusher, then the reader for all strings and finally the\n   closer.  Note that if you want to prompt from a terminal or other command\n   line interface, the best is to have the reader also write the prompts\n   instead of having the writer do it.  If you want to prompt from a dialog\n   box, the writer can be used to build up the contents of the box, and the\n   flusher to actually display the box and run the event loop until all data\n   has been given, after which the reader only grabs the given data and puts\n   them back into the UI strings.\n\n   All method functions take a UI as argument.  Additionally, the writer and\n   the reader take a UI_STRING.\n*/\n\n/*\n * The UI_STRING type is the data structure that contains all the needed info\n * about a string or a prompt, including test data for a verification prompt.\n */\ntypedef struct ui_string_st UI_STRING;\nDEFINE_STACK_OF(UI_STRING)\n\n/*\n * The different types of strings that are currently supported. This is only\n * needed by method authors.\n */\nenum UI_string_types {\n    UIT_NONE = 0,\n    UIT_PROMPT,                 /* Prompt for a string */\n    UIT_VERIFY,                 /* Prompt for a string and verify */\n    UIT_BOOLEAN,                /* Prompt for a yes/no response */\n    UIT_INFO,                   /* Send info to the user */\n    UIT_ERROR                   /* Send an error message to the user */\n};\n\n/* Create and manipulate methods */\nUI_METHOD *UI_create_method(const char *name);\nvoid UI_destroy_method(UI_METHOD *ui_method);\nint UI_method_set_opener(UI_METHOD *method, int (*opener) (UI *ui));\nint UI_method_set_writer(UI_METHOD *method,\n                         int (*writer) (UI *ui, UI_STRING *uis));\nint UI_method_set_flusher(UI_METHOD *method, int (*flusher) (UI *ui));\nint UI_method_set_reader(UI_METHOD *method,\n                         int (*reader) (UI *ui, UI_STRING *uis));\nint UI_method_set_closer(UI_METHOD *method, int (*closer) (UI *ui));\nint UI_method_set_data_duplicator(UI_METHOD *method,\n                                  void *(*duplicator) (UI *ui, void *ui_data),\n                                  void (*destructor)(UI *ui, void *ui_data));\nint UI_method_set_prompt_constructor(UI_METHOD *method,\n                                     char *(*prompt_constructor) (UI *ui,\n                                                                  const char\n                                                                  *object_desc,\n                                                                  const char\n                                                                  *object_name));\nint UI_method_set_ex_data(UI_METHOD *method, int idx, void *data);\nint (*UI_method_get_opener(const UI_METHOD *method)) (UI *);\nint (*UI_method_get_writer(const UI_METHOD *method)) (UI *, UI_STRING *);\nint (*UI_method_get_flusher(const UI_METHOD *method)) (UI *);\nint (*UI_method_get_reader(const UI_METHOD *method)) (UI *, UI_STRING *);\nint (*UI_method_get_closer(const UI_METHOD *method)) (UI *);\nchar *(*UI_method_get_prompt_constructor(const UI_METHOD *method))\n    (UI *, const char *, const char *);\nvoid *(*UI_method_get_data_duplicator(const UI_METHOD *method)) (UI *, void *);\nvoid (*UI_method_get_data_destructor(const UI_METHOD *method)) (UI *, void *);\nconst void *UI_method_get_ex_data(const UI_METHOD *method, int idx);\n\n/*\n * The following functions are helpers for method writers to access relevant\n * data from a UI_STRING.\n */\n\n/* Return type of the UI_STRING */\nenum UI_string_types UI_get_string_type(UI_STRING *uis);\n/* Return input flags of the UI_STRING */\nint UI_get_input_flags(UI_STRING *uis);\n/* Return the actual string to output (the prompt, info or error) */\nconst char *UI_get0_output_string(UI_STRING *uis);\n/*\n * Return the optional action string to output (the boolean prompt\n * instruction)\n */\nconst char *UI_get0_action_string(UI_STRING *uis);\n/* Return the result of a prompt */\nconst char *UI_get0_result_string(UI_STRING *uis);\nint UI_get_result_string_length(UI_STRING *uis);\n/*\n * Return the string to test the result against.  Only useful with verifies.\n */\nconst char *UI_get0_test_string(UI_STRING *uis);\n/* Return the required minimum size of the result */\nint UI_get_result_minsize(UI_STRING *uis);\n/* Return the required maximum size of the result */\nint UI_get_result_maxsize(UI_STRING *uis);\n/* Set the result of a UI_STRING. */\nint UI_set_result(UI *ui, UI_STRING *uis, const char *result);\nint UI_set_result_ex(UI *ui, UI_STRING *uis, const char *result, int len);\n\n/* A couple of popular utility functions */\nint UI_UTIL_read_pw_string(char *buf, int length, const char *prompt,\n                           int verify);\nint UI_UTIL_read_pw(char *buf, char *buff, int size, const char *prompt,\n                    int verify);\nUI_METHOD *UI_UTIL_wrap_read_pem_callback(pem_password_cb *cb, int rwflag);\n\n\n# ifdef  __cplusplus\n}\n# endif\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/include/openssl/uierr.h",
    "content": "/*\n * Generated by util/mkerr.pl DO NOT EDIT\n * Copyright 1995-2019 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef HEADER_UIERR_H\n# define HEADER_UIERR_H\n\n# ifndef HEADER_SYMHACKS_H\n#  include <openssl/symhacks.h>\n# endif\n\n# ifdef  __cplusplus\nextern \"C\"\n# endif\nint ERR_load_UI_strings(void);\n\n/*\n * UI function codes.\n */\n# define UI_F_CLOSE_CONSOLE                               115\n# define UI_F_ECHO_CONSOLE                                116\n# define UI_F_GENERAL_ALLOCATE_BOOLEAN                    108\n# define UI_F_GENERAL_ALLOCATE_PROMPT                     109\n# define UI_F_NOECHO_CONSOLE                              117\n# define UI_F_OPEN_CONSOLE                                114\n# define UI_F_UI_CONSTRUCT_PROMPT                         121\n# define UI_F_UI_CREATE_METHOD                            112\n# define UI_F_UI_CTRL                                     111\n# define UI_F_UI_DUP_ERROR_STRING                         101\n# define UI_F_UI_DUP_INFO_STRING                          102\n# define UI_F_UI_DUP_INPUT_BOOLEAN                        110\n# define UI_F_UI_DUP_INPUT_STRING                         103\n# define UI_F_UI_DUP_USER_DATA                            118\n# define UI_F_UI_DUP_VERIFY_STRING                        106\n# define UI_F_UI_GET0_RESULT                              107\n# define UI_F_UI_GET_RESULT_LENGTH                        119\n# define UI_F_UI_NEW_METHOD                               104\n# define UI_F_UI_PROCESS                                  113\n# define UI_F_UI_SET_RESULT                               105\n# define UI_F_UI_SET_RESULT_EX                            120\n\n/*\n * UI reason codes.\n */\n# define UI_R_COMMON_OK_AND_CANCEL_CHARACTERS             104\n# define UI_R_INDEX_TOO_LARGE                             102\n# define UI_R_INDEX_TOO_SMALL                             103\n# define UI_R_NO_RESULT_BUFFER                            105\n# define UI_R_PROCESSING_ERROR                            107\n# define UI_R_RESULT_TOO_LARGE                            100\n# define UI_R_RESULT_TOO_SMALL                            101\n# define UI_R_SYSASSIGN_ERROR                             109\n# define UI_R_SYSDASSGN_ERROR                             110\n# define UI_R_SYSQIOW_ERROR                               111\n# define UI_R_UNKNOWN_CONTROL_COMMAND                     106\n# define UI_R_UNKNOWN_TTYGET_ERRNO_VALUE                  108\n# define UI_R_USER_DATA_DUPLICATION_UNSUPPORTED           112\n\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/include/openssl/whrlpool.h",
    "content": "/*\n * Copyright 2005-2016 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef HEADER_WHRLPOOL_H\n# define HEADER_WHRLPOOL_H\n\n#include <openssl/opensslconf.h>\n\n# ifndef OPENSSL_NO_WHIRLPOOL\n# include <openssl/e_os2.h>\n# include <stddef.h>\n# ifdef __cplusplus\nextern \"C\" {\n# endif\n\n# define WHIRLPOOL_DIGEST_LENGTH (512/8)\n# define WHIRLPOOL_BBLOCK        512\n# define WHIRLPOOL_COUNTER       (256/8)\n\ntypedef struct {\n    union {\n        unsigned char c[WHIRLPOOL_DIGEST_LENGTH];\n        /* double q is here to ensure 64-bit alignment */\n        double q[WHIRLPOOL_DIGEST_LENGTH / sizeof(double)];\n    } H;\n    unsigned char data[WHIRLPOOL_BBLOCK / 8];\n    unsigned int bitoff;\n    size_t bitlen[WHIRLPOOL_COUNTER / sizeof(size_t)];\n} WHIRLPOOL_CTX;\n\nint WHIRLPOOL_Init(WHIRLPOOL_CTX *c);\nint WHIRLPOOL_Update(WHIRLPOOL_CTX *c, const void *inp, size_t bytes);\nvoid WHIRLPOOL_BitUpdate(WHIRLPOOL_CTX *c, const void *inp, size_t bits);\nint WHIRLPOOL_Final(unsigned char *md, WHIRLPOOL_CTX *c);\nunsigned char *WHIRLPOOL(const void *inp, size_t bytes, unsigned char *md);\n\n# ifdef __cplusplus\n}\n# endif\n# endif\n\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/include/openssl/x509.h",
    "content": "/*\n * Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved.\n * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef HEADER_X509_H\n# define HEADER_X509_H\n\n# include <openssl/e_os2.h>\n# include <openssl/ossl_typ.h>\n# include <openssl/symhacks.h>\n# include <openssl/buffer.h>\n# include <openssl/evp.h>\n# include <openssl/bio.h>\n# include <openssl/asn1.h>\n# include <openssl/safestack.h>\n# include <openssl/ec.h>\n\n# if OPENSSL_API_COMPAT < 0x10100000L\n#  include <openssl/rsa.h>\n#  include <openssl/dsa.h>\n#  include <openssl/dh.h>\n# endif\n\n# include <openssl/sha.h>\n# include <openssl/x509err.h>\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n\n/* Flags for X509_get_signature_info() */\n/* Signature info is valid */\n# define X509_SIG_INFO_VALID     0x1\n/* Signature is suitable for TLS use */\n# define X509_SIG_INFO_TLS       0x2\n\n# define X509_FILETYPE_PEM       1\n# define X509_FILETYPE_ASN1      2\n# define X509_FILETYPE_DEFAULT   3\n\n# define X509v3_KU_DIGITAL_SIGNATURE     0x0080\n# define X509v3_KU_NON_REPUDIATION       0x0040\n# define X509v3_KU_KEY_ENCIPHERMENT      0x0020\n# define X509v3_KU_DATA_ENCIPHERMENT     0x0010\n# define X509v3_KU_KEY_AGREEMENT         0x0008\n# define X509v3_KU_KEY_CERT_SIGN         0x0004\n# define X509v3_KU_CRL_SIGN              0x0002\n# define X509v3_KU_ENCIPHER_ONLY         0x0001\n# define X509v3_KU_DECIPHER_ONLY         0x8000\n# define X509v3_KU_UNDEF                 0xffff\n\nstruct X509_algor_st {\n    ASN1_OBJECT *algorithm;\n    ASN1_TYPE *parameter;\n} /* X509_ALGOR */ ;\n\ntypedef STACK_OF(X509_ALGOR) X509_ALGORS;\n\ntypedef struct X509_val_st {\n    ASN1_TIME *notBefore;\n    ASN1_TIME *notAfter;\n} X509_VAL;\n\ntypedef struct X509_sig_st X509_SIG;\n\ntypedef struct X509_name_entry_st X509_NAME_ENTRY;\n\nDEFINE_STACK_OF(X509_NAME_ENTRY)\n\nDEFINE_STACK_OF(X509_NAME)\n\n# define X509_EX_V_NETSCAPE_HACK         0x8000\n# define X509_EX_V_INIT                  0x0001\ntypedef struct X509_extension_st X509_EXTENSION;\n\ntypedef STACK_OF(X509_EXTENSION) X509_EXTENSIONS;\n\nDEFINE_STACK_OF(X509_EXTENSION)\n\ntypedef struct x509_attributes_st X509_ATTRIBUTE;\n\nDEFINE_STACK_OF(X509_ATTRIBUTE)\n\ntypedef struct X509_req_info_st X509_REQ_INFO;\n\ntypedef struct X509_req_st X509_REQ;\n\ntypedef struct x509_cert_aux_st X509_CERT_AUX;\n\ntypedef struct x509_cinf_st X509_CINF;\n\nDEFINE_STACK_OF(X509)\n\n/* This is used for a table of trust checking functions */\n\ntypedef struct x509_trust_st {\n    int trust;\n    int flags;\n    int (*check_trust) (struct x509_trust_st *, X509 *, int);\n    char *name;\n    int arg1;\n    void *arg2;\n} X509_TRUST;\n\nDEFINE_STACK_OF(X509_TRUST)\n\n/* standard trust ids */\n\n# define X509_TRUST_DEFAULT      0 /* Only valid in purpose settings */\n\n# define X509_TRUST_COMPAT       1\n# define X509_TRUST_SSL_CLIENT   2\n# define X509_TRUST_SSL_SERVER   3\n# define X509_TRUST_EMAIL        4\n# define X509_TRUST_OBJECT_SIGN  5\n# define X509_TRUST_OCSP_SIGN    6\n# define X509_TRUST_OCSP_REQUEST 7\n# define X509_TRUST_TSA          8\n\n/* Keep these up to date! */\n# define X509_TRUST_MIN          1\n# define X509_TRUST_MAX          8\n\n/* trust_flags values */\n# define X509_TRUST_DYNAMIC      (1U << 0)\n# define X509_TRUST_DYNAMIC_NAME (1U << 1)\n/* No compat trust if self-signed, preempts \"DO_SS\" */\n# define X509_TRUST_NO_SS_COMPAT (1U << 2)\n/* Compat trust if no explicit accepted trust EKUs */\n# define X509_TRUST_DO_SS_COMPAT (1U << 3)\n/* Accept \"anyEKU\" as a wildcard trust OID */\n# define X509_TRUST_OK_ANY_EKU   (1U << 4)\n\n/* check_trust return codes */\n\n# define X509_TRUST_TRUSTED      1\n# define X509_TRUST_REJECTED     2\n# define X509_TRUST_UNTRUSTED    3\n\n/* Flags for X509_print_ex() */\n\n# define X509_FLAG_COMPAT                0\n# define X509_FLAG_NO_HEADER             1L\n# define X509_FLAG_NO_VERSION            (1L << 1)\n# define X509_FLAG_NO_SERIAL             (1L << 2)\n# define X509_FLAG_NO_SIGNAME            (1L << 3)\n# define X509_FLAG_NO_ISSUER             (1L << 4)\n# define X509_FLAG_NO_VALIDITY           (1L << 5)\n# define X509_FLAG_NO_SUBJECT            (1L << 6)\n# define X509_FLAG_NO_PUBKEY             (1L << 7)\n# define X509_FLAG_NO_EXTENSIONS         (1L << 8)\n# define X509_FLAG_NO_SIGDUMP            (1L << 9)\n# define X509_FLAG_NO_AUX                (1L << 10)\n# define X509_FLAG_NO_ATTRIBUTES         (1L << 11)\n# define X509_FLAG_NO_IDS                (1L << 12)\n\n/* Flags specific to X509_NAME_print_ex() */\n\n/* The field separator information */\n\n# define XN_FLAG_SEP_MASK        (0xf << 16)\n\n# define XN_FLAG_COMPAT          0/* Traditional; use old X509_NAME_print */\n# define XN_FLAG_SEP_COMMA_PLUS  (1 << 16)/* RFC2253 ,+ */\n# define XN_FLAG_SEP_CPLUS_SPC   (2 << 16)/* ,+ spaced: more readable */\n# define XN_FLAG_SEP_SPLUS_SPC   (3 << 16)/* ;+ spaced */\n# define XN_FLAG_SEP_MULTILINE   (4 << 16)/* One line per field */\n\n# define XN_FLAG_DN_REV          (1 << 20)/* Reverse DN order */\n\n/* How the field name is shown */\n\n# define XN_FLAG_FN_MASK         (0x3 << 21)\n\n# define XN_FLAG_FN_SN           0/* Object short name */\n# define XN_FLAG_FN_LN           (1 << 21)/* Object long name */\n# define XN_FLAG_FN_OID          (2 << 21)/* Always use OIDs */\n# define XN_FLAG_FN_NONE         (3 << 21)/* No field names */\n\n# define XN_FLAG_SPC_EQ          (1 << 23)/* Put spaces round '=' */\n\n/*\n * This determines if we dump fields we don't recognise: RFC2253 requires\n * this.\n */\n\n# define XN_FLAG_DUMP_UNKNOWN_FIELDS (1 << 24)\n\n# define XN_FLAG_FN_ALIGN        (1 << 25)/* Align field names to 20\n                                           * characters */\n\n/* Complete set of RFC2253 flags */\n\n# define XN_FLAG_RFC2253 (ASN1_STRFLGS_RFC2253 | \\\n                        XN_FLAG_SEP_COMMA_PLUS | \\\n                        XN_FLAG_DN_REV | \\\n                        XN_FLAG_FN_SN | \\\n                        XN_FLAG_DUMP_UNKNOWN_FIELDS)\n\n/* readable oneline form */\n\n# define XN_FLAG_ONELINE (ASN1_STRFLGS_RFC2253 | \\\n                        ASN1_STRFLGS_ESC_QUOTE | \\\n                        XN_FLAG_SEP_CPLUS_SPC | \\\n                        XN_FLAG_SPC_EQ | \\\n                        XN_FLAG_FN_SN)\n\n/* readable multiline form */\n\n# define XN_FLAG_MULTILINE (ASN1_STRFLGS_ESC_CTRL | \\\n                        ASN1_STRFLGS_ESC_MSB | \\\n                        XN_FLAG_SEP_MULTILINE | \\\n                        XN_FLAG_SPC_EQ | \\\n                        XN_FLAG_FN_LN | \\\n                        XN_FLAG_FN_ALIGN)\n\nDEFINE_STACK_OF(X509_REVOKED)\n\ntypedef struct X509_crl_info_st X509_CRL_INFO;\n\nDEFINE_STACK_OF(X509_CRL)\n\ntypedef struct private_key_st {\n    int version;\n    /* The PKCS#8 data types */\n    X509_ALGOR *enc_algor;\n    ASN1_OCTET_STRING *enc_pkey; /* encrypted pub key */\n    /* When decrypted, the following will not be NULL */\n    EVP_PKEY *dec_pkey;\n    /* used to encrypt and decrypt */\n    int key_length;\n    char *key_data;\n    int key_free;               /* true if we should auto free key_data */\n    /* expanded version of 'enc_algor' */\n    EVP_CIPHER_INFO cipher;\n} X509_PKEY;\n\ntypedef struct X509_info_st {\n    X509 *x509;\n    X509_CRL *crl;\n    X509_PKEY *x_pkey;\n    EVP_CIPHER_INFO enc_cipher;\n    int enc_len;\n    char *enc_data;\n} X509_INFO;\n\nDEFINE_STACK_OF(X509_INFO)\n\n/*\n * The next 2 structures and their 8 routines are used to manipulate Netscape's\n * spki structures - useful if you are writing a CA web page\n */\ntypedef struct Netscape_spkac_st {\n    X509_PUBKEY *pubkey;\n    ASN1_IA5STRING *challenge;  /* challenge sent in atlas >= PR2 */\n} NETSCAPE_SPKAC;\n\ntypedef struct Netscape_spki_st {\n    NETSCAPE_SPKAC *spkac;      /* signed public key and challenge */\n    X509_ALGOR sig_algor;\n    ASN1_BIT_STRING *signature;\n} NETSCAPE_SPKI;\n\n/* Netscape certificate sequence structure */\ntypedef struct Netscape_certificate_sequence {\n    ASN1_OBJECT *type;\n    STACK_OF(X509) *certs;\n} NETSCAPE_CERT_SEQUENCE;\n\n/*- Unused (and iv length is wrong)\ntypedef struct CBCParameter_st\n        {\n        unsigned char iv[8];\n        } CBC_PARAM;\n*/\n\n/* Password based encryption structure */\n\ntypedef struct PBEPARAM_st {\n    ASN1_OCTET_STRING *salt;\n    ASN1_INTEGER *iter;\n} PBEPARAM;\n\n/* Password based encryption V2 structures */\n\ntypedef struct PBE2PARAM_st {\n    X509_ALGOR *keyfunc;\n    X509_ALGOR *encryption;\n} PBE2PARAM;\n\ntypedef struct PBKDF2PARAM_st {\n/* Usually OCTET STRING but could be anything */\n    ASN1_TYPE *salt;\n    ASN1_INTEGER *iter;\n    ASN1_INTEGER *keylength;\n    X509_ALGOR *prf;\n} PBKDF2PARAM;\n\n#ifndef OPENSSL_NO_SCRYPT\ntypedef struct SCRYPT_PARAMS_st {\n    ASN1_OCTET_STRING *salt;\n    ASN1_INTEGER *costParameter;\n    ASN1_INTEGER *blockSize;\n    ASN1_INTEGER *parallelizationParameter;\n    ASN1_INTEGER *keyLength;\n} SCRYPT_PARAMS;\n#endif\n\n#ifdef  __cplusplus\n}\n#endif\n\n# include <openssl/x509_vfy.h>\n# include <openssl/pkcs7.h>\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n# define X509_EXT_PACK_UNKNOWN   1\n# define X509_EXT_PACK_STRING    2\n\n# define         X509_extract_key(x)     X509_get_pubkey(x)/*****/\n# define         X509_REQ_extract_key(a) X509_REQ_get_pubkey(a)\n# define         X509_name_cmp(a,b)      X509_NAME_cmp((a),(b))\n\nvoid X509_CRL_set_default_method(const X509_CRL_METHOD *meth);\nX509_CRL_METHOD *X509_CRL_METHOD_new(int (*crl_init) (X509_CRL *crl),\n                                     int (*crl_free) (X509_CRL *crl),\n                                     int (*crl_lookup) (X509_CRL *crl,\n                                                        X509_REVOKED **ret,\n                                                        ASN1_INTEGER *ser,\n                                                        X509_NAME *issuer),\n                                     int (*crl_verify) (X509_CRL *crl,\n                                                        EVP_PKEY *pk));\nvoid X509_CRL_METHOD_free(X509_CRL_METHOD *m);\n\nvoid X509_CRL_set_meth_data(X509_CRL *crl, void *dat);\nvoid *X509_CRL_get_meth_data(X509_CRL *crl);\n\nconst char *X509_verify_cert_error_string(long n);\n\nint X509_verify(X509 *a, EVP_PKEY *r);\n\nint X509_REQ_verify(X509_REQ *a, EVP_PKEY *r);\nint X509_CRL_verify(X509_CRL *a, EVP_PKEY *r);\nint NETSCAPE_SPKI_verify(NETSCAPE_SPKI *a, EVP_PKEY *r);\n\nNETSCAPE_SPKI *NETSCAPE_SPKI_b64_decode(const char *str, int len);\nchar *NETSCAPE_SPKI_b64_encode(NETSCAPE_SPKI *x);\nEVP_PKEY *NETSCAPE_SPKI_get_pubkey(NETSCAPE_SPKI *x);\nint NETSCAPE_SPKI_set_pubkey(NETSCAPE_SPKI *x, EVP_PKEY *pkey);\n\nint NETSCAPE_SPKI_print(BIO *out, NETSCAPE_SPKI *spki);\n\nint X509_signature_dump(BIO *bp, const ASN1_STRING *sig, int indent);\nint X509_signature_print(BIO *bp, const X509_ALGOR *alg,\n                         const ASN1_STRING *sig);\n\nint X509_sign(X509 *x, EVP_PKEY *pkey, const EVP_MD *md);\nint X509_sign_ctx(X509 *x, EVP_MD_CTX *ctx);\n# ifndef OPENSSL_NO_OCSP\nint X509_http_nbio(OCSP_REQ_CTX *rctx, X509 **pcert);\n# endif\nint X509_REQ_sign(X509_REQ *x, EVP_PKEY *pkey, const EVP_MD *md);\nint X509_REQ_sign_ctx(X509_REQ *x, EVP_MD_CTX *ctx);\nint X509_CRL_sign(X509_CRL *x, EVP_PKEY *pkey, const EVP_MD *md);\nint X509_CRL_sign_ctx(X509_CRL *x, EVP_MD_CTX *ctx);\n# ifndef OPENSSL_NO_OCSP\nint X509_CRL_http_nbio(OCSP_REQ_CTX *rctx, X509_CRL **pcrl);\n# endif\nint NETSCAPE_SPKI_sign(NETSCAPE_SPKI *x, EVP_PKEY *pkey, const EVP_MD *md);\n\nint X509_pubkey_digest(const X509 *data, const EVP_MD *type,\n                       unsigned char *md, unsigned int *len);\nint X509_digest(const X509 *data, const EVP_MD *type,\n                unsigned char *md, unsigned int *len);\nint X509_CRL_digest(const X509_CRL *data, const EVP_MD *type,\n                    unsigned char *md, unsigned int *len);\nint X509_REQ_digest(const X509_REQ *data, const EVP_MD *type,\n                    unsigned char *md, unsigned int *len);\nint X509_NAME_digest(const X509_NAME *data, const EVP_MD *type,\n                     unsigned char *md, unsigned int *len);\n\n# ifndef OPENSSL_NO_STDIO\nX509 *d2i_X509_fp(FILE *fp, X509 **x509);\nint i2d_X509_fp(FILE *fp, X509 *x509);\nX509_CRL *d2i_X509_CRL_fp(FILE *fp, X509_CRL **crl);\nint i2d_X509_CRL_fp(FILE *fp, X509_CRL *crl);\nX509_REQ *d2i_X509_REQ_fp(FILE *fp, X509_REQ **req);\nint i2d_X509_REQ_fp(FILE *fp, X509_REQ *req);\n#  ifndef OPENSSL_NO_RSA\nRSA *d2i_RSAPrivateKey_fp(FILE *fp, RSA **rsa);\nint i2d_RSAPrivateKey_fp(FILE *fp, RSA *rsa);\nRSA *d2i_RSAPublicKey_fp(FILE *fp, RSA **rsa);\nint i2d_RSAPublicKey_fp(FILE *fp, RSA *rsa);\nRSA *d2i_RSA_PUBKEY_fp(FILE *fp, RSA **rsa);\nint i2d_RSA_PUBKEY_fp(FILE *fp, RSA *rsa);\n#  endif\n#  ifndef OPENSSL_NO_DSA\nDSA *d2i_DSA_PUBKEY_fp(FILE *fp, DSA **dsa);\nint i2d_DSA_PUBKEY_fp(FILE *fp, DSA *dsa);\nDSA *d2i_DSAPrivateKey_fp(FILE *fp, DSA **dsa);\nint i2d_DSAPrivateKey_fp(FILE *fp, DSA *dsa);\n#  endif\n#  ifndef OPENSSL_NO_EC\nEC_KEY *d2i_EC_PUBKEY_fp(FILE *fp, EC_KEY **eckey);\nint i2d_EC_PUBKEY_fp(FILE *fp, EC_KEY *eckey);\nEC_KEY *d2i_ECPrivateKey_fp(FILE *fp, EC_KEY **eckey);\nint i2d_ECPrivateKey_fp(FILE *fp, EC_KEY *eckey);\n#  endif\nX509_SIG *d2i_PKCS8_fp(FILE *fp, X509_SIG **p8);\nint i2d_PKCS8_fp(FILE *fp, X509_SIG *p8);\nPKCS8_PRIV_KEY_INFO *d2i_PKCS8_PRIV_KEY_INFO_fp(FILE *fp,\n                                                PKCS8_PRIV_KEY_INFO **p8inf);\nint i2d_PKCS8_PRIV_KEY_INFO_fp(FILE *fp, PKCS8_PRIV_KEY_INFO *p8inf);\nint i2d_PKCS8PrivateKeyInfo_fp(FILE *fp, EVP_PKEY *key);\nint i2d_PrivateKey_fp(FILE *fp, EVP_PKEY *pkey);\nEVP_PKEY *d2i_PrivateKey_fp(FILE *fp, EVP_PKEY **a);\nint i2d_PUBKEY_fp(FILE *fp, EVP_PKEY *pkey);\nEVP_PKEY *d2i_PUBKEY_fp(FILE *fp, EVP_PKEY **a);\n# endif\n\nX509 *d2i_X509_bio(BIO *bp, X509 **x509);\nint i2d_X509_bio(BIO *bp, X509 *x509);\nX509_CRL *d2i_X509_CRL_bio(BIO *bp, X509_CRL **crl);\nint i2d_X509_CRL_bio(BIO *bp, X509_CRL *crl);\nX509_REQ *d2i_X509_REQ_bio(BIO *bp, X509_REQ **req);\nint i2d_X509_REQ_bio(BIO *bp, X509_REQ *req);\n#  ifndef OPENSSL_NO_RSA\nRSA *d2i_RSAPrivateKey_bio(BIO *bp, RSA **rsa);\nint i2d_RSAPrivateKey_bio(BIO *bp, RSA *rsa);\nRSA *d2i_RSAPublicKey_bio(BIO *bp, RSA **rsa);\nint i2d_RSAPublicKey_bio(BIO *bp, RSA *rsa);\nRSA *d2i_RSA_PUBKEY_bio(BIO *bp, RSA **rsa);\nint i2d_RSA_PUBKEY_bio(BIO *bp, RSA *rsa);\n#  endif\n#  ifndef OPENSSL_NO_DSA\nDSA *d2i_DSA_PUBKEY_bio(BIO *bp, DSA **dsa);\nint i2d_DSA_PUBKEY_bio(BIO *bp, DSA *dsa);\nDSA *d2i_DSAPrivateKey_bio(BIO *bp, DSA **dsa);\nint i2d_DSAPrivateKey_bio(BIO *bp, DSA *dsa);\n#  endif\n#  ifndef OPENSSL_NO_EC\nEC_KEY *d2i_EC_PUBKEY_bio(BIO *bp, EC_KEY **eckey);\nint i2d_EC_PUBKEY_bio(BIO *bp, EC_KEY *eckey);\nEC_KEY *d2i_ECPrivateKey_bio(BIO *bp, EC_KEY **eckey);\nint i2d_ECPrivateKey_bio(BIO *bp, EC_KEY *eckey);\n#  endif\nX509_SIG *d2i_PKCS8_bio(BIO *bp, X509_SIG **p8);\nint i2d_PKCS8_bio(BIO *bp, X509_SIG *p8);\nPKCS8_PRIV_KEY_INFO *d2i_PKCS8_PRIV_KEY_INFO_bio(BIO *bp,\n                                                 PKCS8_PRIV_KEY_INFO **p8inf);\nint i2d_PKCS8_PRIV_KEY_INFO_bio(BIO *bp, PKCS8_PRIV_KEY_INFO *p8inf);\nint i2d_PKCS8PrivateKeyInfo_bio(BIO *bp, EVP_PKEY *key);\nint i2d_PrivateKey_bio(BIO *bp, EVP_PKEY *pkey);\nEVP_PKEY *d2i_PrivateKey_bio(BIO *bp, EVP_PKEY **a);\nint i2d_PUBKEY_bio(BIO *bp, EVP_PKEY *pkey);\nEVP_PKEY *d2i_PUBKEY_bio(BIO *bp, EVP_PKEY **a);\n\nX509 *X509_dup(X509 *x509);\nX509_ATTRIBUTE *X509_ATTRIBUTE_dup(X509_ATTRIBUTE *xa);\nX509_EXTENSION *X509_EXTENSION_dup(X509_EXTENSION *ex);\nX509_CRL *X509_CRL_dup(X509_CRL *crl);\nX509_REVOKED *X509_REVOKED_dup(X509_REVOKED *rev);\nX509_REQ *X509_REQ_dup(X509_REQ *req);\nX509_ALGOR *X509_ALGOR_dup(X509_ALGOR *xn);\nint X509_ALGOR_set0(X509_ALGOR *alg, ASN1_OBJECT *aobj, int ptype,\n                    void *pval);\nvoid X509_ALGOR_get0(const ASN1_OBJECT **paobj, int *pptype,\n                     const void **ppval, const X509_ALGOR *algor);\nvoid X509_ALGOR_set_md(X509_ALGOR *alg, const EVP_MD *md);\nint X509_ALGOR_cmp(const X509_ALGOR *a, const X509_ALGOR *b);\nint X509_ALGOR_copy(X509_ALGOR *dest, const X509_ALGOR *src);\n\nX509_NAME *X509_NAME_dup(X509_NAME *xn);\nX509_NAME_ENTRY *X509_NAME_ENTRY_dup(X509_NAME_ENTRY *ne);\n\nint X509_cmp_time(const ASN1_TIME *s, time_t *t);\nint X509_cmp_current_time(const ASN1_TIME *s);\nASN1_TIME *X509_time_adj(ASN1_TIME *s, long adj, time_t *t);\nASN1_TIME *X509_time_adj_ex(ASN1_TIME *s,\n                            int offset_day, long offset_sec, time_t *t);\nASN1_TIME *X509_gmtime_adj(ASN1_TIME *s, long adj);\n\nconst char *X509_get_default_cert_area(void);\nconst char *X509_get_default_cert_dir(void);\nconst char *X509_get_default_cert_file(void);\nconst char *X509_get_default_cert_dir_env(void);\nconst char *X509_get_default_cert_file_env(void);\nconst char *X509_get_default_private_dir(void);\n\nX509_REQ *X509_to_X509_REQ(X509 *x, EVP_PKEY *pkey, const EVP_MD *md);\nX509 *X509_REQ_to_X509(X509_REQ *r, int days, EVP_PKEY *pkey);\n\nDECLARE_ASN1_FUNCTIONS(X509_ALGOR)\nDECLARE_ASN1_ENCODE_FUNCTIONS(X509_ALGORS, X509_ALGORS, X509_ALGORS)\nDECLARE_ASN1_FUNCTIONS(X509_VAL)\n\nDECLARE_ASN1_FUNCTIONS(X509_PUBKEY)\n\nint X509_PUBKEY_set(X509_PUBKEY **x, EVP_PKEY *pkey);\nEVP_PKEY *X509_PUBKEY_get0(X509_PUBKEY *key);\nEVP_PKEY *X509_PUBKEY_get(X509_PUBKEY *key);\nint X509_get_pubkey_parameters(EVP_PKEY *pkey, STACK_OF(X509) *chain);\nlong X509_get_pathlen(X509 *x);\nint i2d_PUBKEY(EVP_PKEY *a, unsigned char **pp);\nEVP_PKEY *d2i_PUBKEY(EVP_PKEY **a, const unsigned char **pp, long length);\n# ifndef OPENSSL_NO_RSA\nint i2d_RSA_PUBKEY(RSA *a, unsigned char **pp);\nRSA *d2i_RSA_PUBKEY(RSA **a, const unsigned char **pp, long length);\n# endif\n# ifndef OPENSSL_NO_DSA\nint i2d_DSA_PUBKEY(DSA *a, unsigned char **pp);\nDSA *d2i_DSA_PUBKEY(DSA **a, const unsigned char **pp, long length);\n# endif\n# ifndef OPENSSL_NO_EC\nint i2d_EC_PUBKEY(EC_KEY *a, unsigned char **pp);\nEC_KEY *d2i_EC_PUBKEY(EC_KEY **a, const unsigned char **pp, long length);\n# endif\n\nDECLARE_ASN1_FUNCTIONS(X509_SIG)\nvoid X509_SIG_get0(const X509_SIG *sig, const X509_ALGOR **palg,\n                   const ASN1_OCTET_STRING **pdigest);\nvoid X509_SIG_getm(X509_SIG *sig, X509_ALGOR **palg,\n                   ASN1_OCTET_STRING **pdigest);\n\nDECLARE_ASN1_FUNCTIONS(X509_REQ_INFO)\nDECLARE_ASN1_FUNCTIONS(X509_REQ)\n\nDECLARE_ASN1_FUNCTIONS(X509_ATTRIBUTE)\nX509_ATTRIBUTE *X509_ATTRIBUTE_create(int nid, int atrtype, void *value);\n\nDECLARE_ASN1_FUNCTIONS(X509_EXTENSION)\nDECLARE_ASN1_ENCODE_FUNCTIONS(X509_EXTENSIONS, X509_EXTENSIONS, X509_EXTENSIONS)\n\nDECLARE_ASN1_FUNCTIONS(X509_NAME_ENTRY)\n\nDECLARE_ASN1_FUNCTIONS(X509_NAME)\n\nint X509_NAME_set(X509_NAME **xn, X509_NAME *name);\n\nDECLARE_ASN1_FUNCTIONS(X509_CINF)\n\nDECLARE_ASN1_FUNCTIONS(X509)\nDECLARE_ASN1_FUNCTIONS(X509_CERT_AUX)\n\n#define X509_get_ex_new_index(l, p, newf, dupf, freef) \\\n    CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_X509, l, p, newf, dupf, freef)\nint X509_set_ex_data(X509 *r, int idx, void *arg);\nvoid *X509_get_ex_data(X509 *r, int idx);\nint i2d_X509_AUX(X509 *a, unsigned char **pp);\nX509 *d2i_X509_AUX(X509 **a, const unsigned char **pp, long length);\n\nint i2d_re_X509_tbs(X509 *x, unsigned char **pp);\n\nint X509_SIG_INFO_get(const X509_SIG_INFO *siginf, int *mdnid, int *pknid,\n                      int *secbits, uint32_t *flags);\nvoid X509_SIG_INFO_set(X509_SIG_INFO *siginf, int mdnid, int pknid,\n                       int secbits, uint32_t flags);\n\nint X509_get_signature_info(X509 *x, int *mdnid, int *pknid, int *secbits,\n                            uint32_t *flags);\n\nvoid X509_get0_signature(const ASN1_BIT_STRING **psig,\n                         const X509_ALGOR **palg, const X509 *x);\nint X509_get_signature_nid(const X509 *x);\n\nint X509_trusted(const X509 *x);\nint X509_alias_set1(X509 *x, const unsigned char *name, int len);\nint X509_keyid_set1(X509 *x, const unsigned char *id, int len);\nunsigned char *X509_alias_get0(X509 *x, int *len);\nunsigned char *X509_keyid_get0(X509 *x, int *len);\nint (*X509_TRUST_set_default(int (*trust) (int, X509 *, int))) (int, X509 *,\n                                                                int);\nint X509_TRUST_set(int *t, int trust);\nint X509_add1_trust_object(X509 *x, const ASN1_OBJECT *obj);\nint X509_add1_reject_object(X509 *x, const ASN1_OBJECT *obj);\nvoid X509_trust_clear(X509 *x);\nvoid X509_reject_clear(X509 *x);\n\nSTACK_OF(ASN1_OBJECT) *X509_get0_trust_objects(X509 *x);\nSTACK_OF(ASN1_OBJECT) *X509_get0_reject_objects(X509 *x);\n\nDECLARE_ASN1_FUNCTIONS(X509_REVOKED)\nDECLARE_ASN1_FUNCTIONS(X509_CRL_INFO)\nDECLARE_ASN1_FUNCTIONS(X509_CRL)\n\nint X509_CRL_add0_revoked(X509_CRL *crl, X509_REVOKED *rev);\nint X509_CRL_get0_by_serial(X509_CRL *crl,\n                            X509_REVOKED **ret, ASN1_INTEGER *serial);\nint X509_CRL_get0_by_cert(X509_CRL *crl, X509_REVOKED **ret, X509 *x);\n\nX509_PKEY *X509_PKEY_new(void);\nvoid X509_PKEY_free(X509_PKEY *a);\n\nDECLARE_ASN1_FUNCTIONS(NETSCAPE_SPKI)\nDECLARE_ASN1_FUNCTIONS(NETSCAPE_SPKAC)\nDECLARE_ASN1_FUNCTIONS(NETSCAPE_CERT_SEQUENCE)\n\nX509_INFO *X509_INFO_new(void);\nvoid X509_INFO_free(X509_INFO *a);\nchar *X509_NAME_oneline(const X509_NAME *a, char *buf, int size);\n\nint ASN1_verify(i2d_of_void *i2d, X509_ALGOR *algor1,\n                ASN1_BIT_STRING *signature, char *data, EVP_PKEY *pkey);\n\nint ASN1_digest(i2d_of_void *i2d, const EVP_MD *type, char *data,\n                unsigned char *md, unsigned int *len);\n\nint ASN1_sign(i2d_of_void *i2d, X509_ALGOR *algor1,\n              X509_ALGOR *algor2, ASN1_BIT_STRING *signature,\n              char *data, EVP_PKEY *pkey, const EVP_MD *type);\n\nint ASN1_item_digest(const ASN1_ITEM *it, const EVP_MD *type, void *data,\n                     unsigned char *md, unsigned int *len);\n\nint ASN1_item_verify(const ASN1_ITEM *it, X509_ALGOR *algor1,\n                     ASN1_BIT_STRING *signature, void *data, EVP_PKEY *pkey);\n\nint ASN1_item_sign(const ASN1_ITEM *it, X509_ALGOR *algor1,\n                   X509_ALGOR *algor2, ASN1_BIT_STRING *signature, void *data,\n                   EVP_PKEY *pkey, const EVP_MD *type);\nint ASN1_item_sign_ctx(const ASN1_ITEM *it, X509_ALGOR *algor1,\n                       X509_ALGOR *algor2, ASN1_BIT_STRING *signature,\n                       void *asn, EVP_MD_CTX *ctx);\n\nlong X509_get_version(const X509 *x);\nint X509_set_version(X509 *x, long version);\nint X509_set_serialNumber(X509 *x, ASN1_INTEGER *serial);\nASN1_INTEGER *X509_get_serialNumber(X509 *x);\nconst ASN1_INTEGER *X509_get0_serialNumber(const X509 *x);\nint X509_set_issuer_name(X509 *x, X509_NAME *name);\nX509_NAME *X509_get_issuer_name(const X509 *a);\nint X509_set_subject_name(X509 *x, X509_NAME *name);\nX509_NAME *X509_get_subject_name(const X509 *a);\nconst ASN1_TIME * X509_get0_notBefore(const X509 *x);\nASN1_TIME *X509_getm_notBefore(const X509 *x);\nint X509_set1_notBefore(X509 *x, const ASN1_TIME *tm);\nconst ASN1_TIME *X509_get0_notAfter(const X509 *x);\nASN1_TIME *X509_getm_notAfter(const X509 *x);\nint X509_set1_notAfter(X509 *x, const ASN1_TIME *tm);\nint X509_set_pubkey(X509 *x, EVP_PKEY *pkey);\nint X509_up_ref(X509 *x);\nint X509_get_signature_type(const X509 *x);\n\n# if OPENSSL_API_COMPAT < 0x10100000L\n#  define X509_get_notBefore X509_getm_notBefore\n#  define X509_get_notAfter X509_getm_notAfter\n#  define X509_set_notBefore X509_set1_notBefore\n#  define X509_set_notAfter X509_set1_notAfter\n#endif\n\n\n/*\n * This one is only used so that a binary form can output, as in\n * i2d_X509_PUBKEY(X509_get_X509_PUBKEY(x), &buf)\n */\nX509_PUBKEY *X509_get_X509_PUBKEY(const X509 *x);\nconst STACK_OF(X509_EXTENSION) *X509_get0_extensions(const X509 *x);\nvoid X509_get0_uids(const X509 *x, const ASN1_BIT_STRING **piuid,\n                    const ASN1_BIT_STRING **psuid);\nconst X509_ALGOR *X509_get0_tbs_sigalg(const X509 *x);\n\nEVP_PKEY *X509_get0_pubkey(const X509 *x);\nEVP_PKEY *X509_get_pubkey(X509 *x);\nASN1_BIT_STRING *X509_get0_pubkey_bitstr(const X509 *x);\nint X509_certificate_type(const X509 *x, const EVP_PKEY *pubkey);\n\nlong X509_REQ_get_version(const X509_REQ *req);\nint X509_REQ_set_version(X509_REQ *x, long version);\nX509_NAME *X509_REQ_get_subject_name(const X509_REQ *req);\nint X509_REQ_set_subject_name(X509_REQ *req, X509_NAME *name);\nvoid X509_REQ_get0_signature(const X509_REQ *req, const ASN1_BIT_STRING **psig,\n                             const X509_ALGOR **palg);\nvoid X509_REQ_set0_signature(X509_REQ *req, ASN1_BIT_STRING *psig);\nint X509_REQ_set1_signature_algo(X509_REQ *req, X509_ALGOR *palg);\nint X509_REQ_get_signature_nid(const X509_REQ *req);\nint i2d_re_X509_REQ_tbs(X509_REQ *req, unsigned char **pp);\nint X509_REQ_set_pubkey(X509_REQ *x, EVP_PKEY *pkey);\nEVP_PKEY *X509_REQ_get_pubkey(X509_REQ *req);\nEVP_PKEY *X509_REQ_get0_pubkey(X509_REQ *req);\nX509_PUBKEY *X509_REQ_get_X509_PUBKEY(X509_REQ *req);\nint X509_REQ_extension_nid(int nid);\nint *X509_REQ_get_extension_nids(void);\nvoid X509_REQ_set_extension_nids(int *nids);\nSTACK_OF(X509_EXTENSION) *X509_REQ_get_extensions(X509_REQ *req);\nint X509_REQ_add_extensions_nid(X509_REQ *req, STACK_OF(X509_EXTENSION) *exts,\n                                int nid);\nint X509_REQ_add_extensions(X509_REQ *req, STACK_OF(X509_EXTENSION) *exts);\nint X509_REQ_get_attr_count(const X509_REQ *req);\nint X509_REQ_get_attr_by_NID(const X509_REQ *req, int nid, int lastpos);\nint X509_REQ_get_attr_by_OBJ(const X509_REQ *req, const ASN1_OBJECT *obj,\n                             int lastpos);\nX509_ATTRIBUTE *X509_REQ_get_attr(const X509_REQ *req, int loc);\nX509_ATTRIBUTE *X509_REQ_delete_attr(X509_REQ *req, int loc);\nint X509_REQ_add1_attr(X509_REQ *req, X509_ATTRIBUTE *attr);\nint X509_REQ_add1_attr_by_OBJ(X509_REQ *req,\n                              const ASN1_OBJECT *obj, int type,\n                              const unsigned char *bytes, int len);\nint X509_REQ_add1_attr_by_NID(X509_REQ *req,\n                              int nid, int type,\n                              const unsigned char *bytes, int len);\nint X509_REQ_add1_attr_by_txt(X509_REQ *req,\n                              const char *attrname, int type,\n                              const unsigned char *bytes, int len);\n\nint X509_CRL_set_version(X509_CRL *x, long version);\nint X509_CRL_set_issuer_name(X509_CRL *x, X509_NAME *name);\nint X509_CRL_set1_lastUpdate(X509_CRL *x, const ASN1_TIME *tm);\nint X509_CRL_set1_nextUpdate(X509_CRL *x, const ASN1_TIME *tm);\nint X509_CRL_sort(X509_CRL *crl);\nint X509_CRL_up_ref(X509_CRL *crl);\n\n# if OPENSSL_API_COMPAT < 0x10100000L\n#  define X509_CRL_set_lastUpdate X509_CRL_set1_lastUpdate\n#  define X509_CRL_set_nextUpdate X509_CRL_set1_nextUpdate\n#endif\n\nlong X509_CRL_get_version(const X509_CRL *crl);\nconst ASN1_TIME *X509_CRL_get0_lastUpdate(const X509_CRL *crl);\nconst ASN1_TIME *X509_CRL_get0_nextUpdate(const X509_CRL *crl);\nDEPRECATEDIN_1_1_0(ASN1_TIME *X509_CRL_get_lastUpdate(X509_CRL *crl))\nDEPRECATEDIN_1_1_0(ASN1_TIME *X509_CRL_get_nextUpdate(X509_CRL *crl))\nX509_NAME *X509_CRL_get_issuer(const X509_CRL *crl);\nconst STACK_OF(X509_EXTENSION) *X509_CRL_get0_extensions(const X509_CRL *crl);\nSTACK_OF(X509_REVOKED) *X509_CRL_get_REVOKED(X509_CRL *crl);\nvoid X509_CRL_get0_signature(const X509_CRL *crl, const ASN1_BIT_STRING **psig,\n                             const X509_ALGOR **palg);\nint X509_CRL_get_signature_nid(const X509_CRL *crl);\nint i2d_re_X509_CRL_tbs(X509_CRL *req, unsigned char **pp);\n\nconst ASN1_INTEGER *X509_REVOKED_get0_serialNumber(const X509_REVOKED *x);\nint X509_REVOKED_set_serialNumber(X509_REVOKED *x, ASN1_INTEGER *serial);\nconst ASN1_TIME *X509_REVOKED_get0_revocationDate(const X509_REVOKED *x);\nint X509_REVOKED_set_revocationDate(X509_REVOKED *r, ASN1_TIME *tm);\nconst STACK_OF(X509_EXTENSION) *\nX509_REVOKED_get0_extensions(const X509_REVOKED *r);\n\nX509_CRL *X509_CRL_diff(X509_CRL *base, X509_CRL *newer,\n                        EVP_PKEY *skey, const EVP_MD *md, unsigned int flags);\n\nint X509_REQ_check_private_key(X509_REQ *x509, EVP_PKEY *pkey);\n\nint X509_check_private_key(const X509 *x509, const EVP_PKEY *pkey);\nint X509_chain_check_suiteb(int *perror_depth,\n                            X509 *x, STACK_OF(X509) *chain,\n                            unsigned long flags);\nint X509_CRL_check_suiteb(X509_CRL *crl, EVP_PKEY *pk, unsigned long flags);\nSTACK_OF(X509) *X509_chain_up_ref(STACK_OF(X509) *chain);\n\nint X509_issuer_and_serial_cmp(const X509 *a, const X509 *b);\nunsigned long X509_issuer_and_serial_hash(X509 *a);\n\nint X509_issuer_name_cmp(const X509 *a, const X509 *b);\nunsigned long X509_issuer_name_hash(X509 *a);\n\nint X509_subject_name_cmp(const X509 *a, const X509 *b);\nunsigned long X509_subject_name_hash(X509 *x);\n\n# ifndef OPENSSL_NO_MD5\nunsigned long X509_issuer_name_hash_old(X509 *a);\nunsigned long X509_subject_name_hash_old(X509 *x);\n# endif\n\nint X509_cmp(const X509 *a, const X509 *b);\nint X509_NAME_cmp(const X509_NAME *a, const X509_NAME *b);\nunsigned long X509_NAME_hash(X509_NAME *x);\nunsigned long X509_NAME_hash_old(X509_NAME *x);\n\nint X509_CRL_cmp(const X509_CRL *a, const X509_CRL *b);\nint X509_CRL_match(const X509_CRL *a, const X509_CRL *b);\nint X509_aux_print(BIO *out, X509 *x, int indent);\n# ifndef OPENSSL_NO_STDIO\nint X509_print_ex_fp(FILE *bp, X509 *x, unsigned long nmflag,\n                     unsigned long cflag);\nint X509_print_fp(FILE *bp, X509 *x);\nint X509_CRL_print_fp(FILE *bp, X509_CRL *x);\nint X509_REQ_print_fp(FILE *bp, X509_REQ *req);\nint X509_NAME_print_ex_fp(FILE *fp, const X509_NAME *nm, int indent,\n                          unsigned long flags);\n# endif\n\nint X509_NAME_print(BIO *bp, const X509_NAME *name, int obase);\nint X509_NAME_print_ex(BIO *out, const X509_NAME *nm, int indent,\n                       unsigned long flags);\nint X509_print_ex(BIO *bp, X509 *x, unsigned long nmflag,\n                  unsigned long cflag);\nint X509_print(BIO *bp, X509 *x);\nint X509_ocspid_print(BIO *bp, X509 *x);\nint X509_CRL_print_ex(BIO *out, X509_CRL *x, unsigned long nmflag);\nint X509_CRL_print(BIO *bp, X509_CRL *x);\nint X509_REQ_print_ex(BIO *bp, X509_REQ *x, unsigned long nmflag,\n                      unsigned long cflag);\nint X509_REQ_print(BIO *bp, X509_REQ *req);\n\nint X509_NAME_entry_count(const X509_NAME *name);\nint X509_NAME_get_text_by_NID(X509_NAME *name, int nid, char *buf, int len);\nint X509_NAME_get_text_by_OBJ(X509_NAME *name, const ASN1_OBJECT *obj,\n                              char *buf, int len);\n\n/*\n * NOTE: you should be passing -1, not 0 as lastpos. The functions that use\n * lastpos, search after that position on.\n */\nint X509_NAME_get_index_by_NID(X509_NAME *name, int nid, int lastpos);\nint X509_NAME_get_index_by_OBJ(X509_NAME *name, const ASN1_OBJECT *obj,\n                               int lastpos);\nX509_NAME_ENTRY *X509_NAME_get_entry(const X509_NAME *name, int loc);\nX509_NAME_ENTRY *X509_NAME_delete_entry(X509_NAME *name, int loc);\nint X509_NAME_add_entry(X509_NAME *name, const X509_NAME_ENTRY *ne,\n                        int loc, int set);\nint X509_NAME_add_entry_by_OBJ(X509_NAME *name, const ASN1_OBJECT *obj, int type,\n                               const unsigned char *bytes, int len, int loc,\n                               int set);\nint X509_NAME_add_entry_by_NID(X509_NAME *name, int nid, int type,\n                               const unsigned char *bytes, int len, int loc,\n                               int set);\nX509_NAME_ENTRY *X509_NAME_ENTRY_create_by_txt(X509_NAME_ENTRY **ne,\n                                               const char *field, int type,\n                                               const unsigned char *bytes,\n                                               int len);\nX509_NAME_ENTRY *X509_NAME_ENTRY_create_by_NID(X509_NAME_ENTRY **ne, int nid,\n                                               int type,\n                                               const unsigned char *bytes,\n                                               int len);\nint X509_NAME_add_entry_by_txt(X509_NAME *name, const char *field, int type,\n                               const unsigned char *bytes, int len, int loc,\n                               int set);\nX509_NAME_ENTRY *X509_NAME_ENTRY_create_by_OBJ(X509_NAME_ENTRY **ne,\n                                               const ASN1_OBJECT *obj, int type,\n                                               const unsigned char *bytes,\n                                               int len);\nint X509_NAME_ENTRY_set_object(X509_NAME_ENTRY *ne, const ASN1_OBJECT *obj);\nint X509_NAME_ENTRY_set_data(X509_NAME_ENTRY *ne, int type,\n                             const unsigned char *bytes, int len);\nASN1_OBJECT *X509_NAME_ENTRY_get_object(const X509_NAME_ENTRY *ne);\nASN1_STRING * X509_NAME_ENTRY_get_data(const X509_NAME_ENTRY *ne);\nint X509_NAME_ENTRY_set(const X509_NAME_ENTRY *ne);\n\nint X509_NAME_get0_der(X509_NAME *nm, const unsigned char **pder,\n                       size_t *pderlen);\n\nint X509v3_get_ext_count(const STACK_OF(X509_EXTENSION) *x);\nint X509v3_get_ext_by_NID(const STACK_OF(X509_EXTENSION) *x,\n                          int nid, int lastpos);\nint X509v3_get_ext_by_OBJ(const STACK_OF(X509_EXTENSION) *x,\n                          const ASN1_OBJECT *obj, int lastpos);\nint X509v3_get_ext_by_critical(const STACK_OF(X509_EXTENSION) *x,\n                               int crit, int lastpos);\nX509_EXTENSION *X509v3_get_ext(const STACK_OF(X509_EXTENSION) *x, int loc);\nX509_EXTENSION *X509v3_delete_ext(STACK_OF(X509_EXTENSION) *x, int loc);\nSTACK_OF(X509_EXTENSION) *X509v3_add_ext(STACK_OF(X509_EXTENSION) **x,\n                                         X509_EXTENSION *ex, int loc);\n\nint X509_get_ext_count(const X509 *x);\nint X509_get_ext_by_NID(const X509 *x, int nid, int lastpos);\nint X509_get_ext_by_OBJ(const X509 *x, const ASN1_OBJECT *obj, int lastpos);\nint X509_get_ext_by_critical(const X509 *x, int crit, int lastpos);\nX509_EXTENSION *X509_get_ext(const X509 *x, int loc);\nX509_EXTENSION *X509_delete_ext(X509 *x, int loc);\nint X509_add_ext(X509 *x, X509_EXTENSION *ex, int loc);\nvoid *X509_get_ext_d2i(const X509 *x, int nid, int *crit, int *idx);\nint X509_add1_ext_i2d(X509 *x, int nid, void *value, int crit,\n                      unsigned long flags);\n\nint X509_CRL_get_ext_count(const X509_CRL *x);\nint X509_CRL_get_ext_by_NID(const X509_CRL *x, int nid, int lastpos);\nint X509_CRL_get_ext_by_OBJ(const X509_CRL *x, const ASN1_OBJECT *obj,\n                            int lastpos);\nint X509_CRL_get_ext_by_critical(const X509_CRL *x, int crit, int lastpos);\nX509_EXTENSION *X509_CRL_get_ext(const X509_CRL *x, int loc);\nX509_EXTENSION *X509_CRL_delete_ext(X509_CRL *x, int loc);\nint X509_CRL_add_ext(X509_CRL *x, X509_EXTENSION *ex, int loc);\nvoid *X509_CRL_get_ext_d2i(const X509_CRL *x, int nid, int *crit, int *idx);\nint X509_CRL_add1_ext_i2d(X509_CRL *x, int nid, void *value, int crit,\n                          unsigned long flags);\n\nint X509_REVOKED_get_ext_count(const X509_REVOKED *x);\nint X509_REVOKED_get_ext_by_NID(const X509_REVOKED *x, int nid, int lastpos);\nint X509_REVOKED_get_ext_by_OBJ(const X509_REVOKED *x, const ASN1_OBJECT *obj,\n                                int lastpos);\nint X509_REVOKED_get_ext_by_critical(const X509_REVOKED *x, int crit,\n                                     int lastpos);\nX509_EXTENSION *X509_REVOKED_get_ext(const X509_REVOKED *x, int loc);\nX509_EXTENSION *X509_REVOKED_delete_ext(X509_REVOKED *x, int loc);\nint X509_REVOKED_add_ext(X509_REVOKED *x, X509_EXTENSION *ex, int loc);\nvoid *X509_REVOKED_get_ext_d2i(const X509_REVOKED *x, int nid, int *crit,\n                               int *idx);\nint X509_REVOKED_add1_ext_i2d(X509_REVOKED *x, int nid, void *value, int crit,\n                              unsigned long flags);\n\nX509_EXTENSION *X509_EXTENSION_create_by_NID(X509_EXTENSION **ex,\n                                             int nid, int crit,\n                                             ASN1_OCTET_STRING *data);\nX509_EXTENSION *X509_EXTENSION_create_by_OBJ(X509_EXTENSION **ex,\n                                             const ASN1_OBJECT *obj, int crit,\n                                             ASN1_OCTET_STRING *data);\nint X509_EXTENSION_set_object(X509_EXTENSION *ex, const ASN1_OBJECT *obj);\nint X509_EXTENSION_set_critical(X509_EXTENSION *ex, int crit);\nint X509_EXTENSION_set_data(X509_EXTENSION *ex, ASN1_OCTET_STRING *data);\nASN1_OBJECT *X509_EXTENSION_get_object(X509_EXTENSION *ex);\nASN1_OCTET_STRING *X509_EXTENSION_get_data(X509_EXTENSION *ne);\nint X509_EXTENSION_get_critical(const X509_EXTENSION *ex);\n\nint X509at_get_attr_count(const STACK_OF(X509_ATTRIBUTE) *x);\nint X509at_get_attr_by_NID(const STACK_OF(X509_ATTRIBUTE) *x, int nid,\n                           int lastpos);\nint X509at_get_attr_by_OBJ(const STACK_OF(X509_ATTRIBUTE) *sk,\n                           const ASN1_OBJECT *obj, int lastpos);\nX509_ATTRIBUTE *X509at_get_attr(const STACK_OF(X509_ATTRIBUTE) *x, int loc);\nX509_ATTRIBUTE *X509at_delete_attr(STACK_OF(X509_ATTRIBUTE) *x, int loc);\nSTACK_OF(X509_ATTRIBUTE) *X509at_add1_attr(STACK_OF(X509_ATTRIBUTE) **x,\n                                           X509_ATTRIBUTE *attr);\nSTACK_OF(X509_ATTRIBUTE) *X509at_add1_attr_by_OBJ(STACK_OF(X509_ATTRIBUTE)\n                                                  **x, const ASN1_OBJECT *obj,\n                                                  int type,\n                                                  const unsigned char *bytes,\n                                                  int len);\nSTACK_OF(X509_ATTRIBUTE) *X509at_add1_attr_by_NID(STACK_OF(X509_ATTRIBUTE)\n                                                  **x, int nid, int type,\n                                                  const unsigned char *bytes,\n                                                  int len);\nSTACK_OF(X509_ATTRIBUTE) *X509at_add1_attr_by_txt(STACK_OF(X509_ATTRIBUTE)\n                                                  **x, const char *attrname,\n                                                  int type,\n                                                  const unsigned char *bytes,\n                                                  int len);\nvoid *X509at_get0_data_by_OBJ(const STACK_OF(X509_ATTRIBUTE) *x,\n                              const ASN1_OBJECT *obj, int lastpos, int type);\nX509_ATTRIBUTE *X509_ATTRIBUTE_create_by_NID(X509_ATTRIBUTE **attr, int nid,\n                                             int atrtype, const void *data,\n                                             int len);\nX509_ATTRIBUTE *X509_ATTRIBUTE_create_by_OBJ(X509_ATTRIBUTE **attr,\n                                             const ASN1_OBJECT *obj,\n                                             int atrtype, const void *data,\n                                             int len);\nX509_ATTRIBUTE *X509_ATTRIBUTE_create_by_txt(X509_ATTRIBUTE **attr,\n                                             const char *atrname, int type,\n                                             const unsigned char *bytes,\n                                             int len);\nint X509_ATTRIBUTE_set1_object(X509_ATTRIBUTE *attr, const ASN1_OBJECT *obj);\nint X509_ATTRIBUTE_set1_data(X509_ATTRIBUTE *attr, int attrtype,\n                             const void *data, int len);\nvoid *X509_ATTRIBUTE_get0_data(X509_ATTRIBUTE *attr, int idx, int atrtype,\n                               void *data);\nint X509_ATTRIBUTE_count(const X509_ATTRIBUTE *attr);\nASN1_OBJECT *X509_ATTRIBUTE_get0_object(X509_ATTRIBUTE *attr);\nASN1_TYPE *X509_ATTRIBUTE_get0_type(X509_ATTRIBUTE *attr, int idx);\n\nint EVP_PKEY_get_attr_count(const EVP_PKEY *key);\nint EVP_PKEY_get_attr_by_NID(const EVP_PKEY *key, int nid, int lastpos);\nint EVP_PKEY_get_attr_by_OBJ(const EVP_PKEY *key, const ASN1_OBJECT *obj,\n                             int lastpos);\nX509_ATTRIBUTE *EVP_PKEY_get_attr(const EVP_PKEY *key, int loc);\nX509_ATTRIBUTE *EVP_PKEY_delete_attr(EVP_PKEY *key, int loc);\nint EVP_PKEY_add1_attr(EVP_PKEY *key, X509_ATTRIBUTE *attr);\nint EVP_PKEY_add1_attr_by_OBJ(EVP_PKEY *key,\n                              const ASN1_OBJECT *obj, int type,\n                              const unsigned char *bytes, int len);\nint EVP_PKEY_add1_attr_by_NID(EVP_PKEY *key,\n                              int nid, int type,\n                              const unsigned char *bytes, int len);\nint EVP_PKEY_add1_attr_by_txt(EVP_PKEY *key,\n                              const char *attrname, int type,\n                              const unsigned char *bytes, int len);\n\nint X509_verify_cert(X509_STORE_CTX *ctx);\n\n/* lookup a cert from a X509 STACK */\nX509 *X509_find_by_issuer_and_serial(STACK_OF(X509) *sk, X509_NAME *name,\n                                     ASN1_INTEGER *serial);\nX509 *X509_find_by_subject(STACK_OF(X509) *sk, X509_NAME *name);\n\nDECLARE_ASN1_FUNCTIONS(PBEPARAM)\nDECLARE_ASN1_FUNCTIONS(PBE2PARAM)\nDECLARE_ASN1_FUNCTIONS(PBKDF2PARAM)\n#ifndef OPENSSL_NO_SCRYPT\nDECLARE_ASN1_FUNCTIONS(SCRYPT_PARAMS)\n#endif\n\nint PKCS5_pbe_set0_algor(X509_ALGOR *algor, int alg, int iter,\n                         const unsigned char *salt, int saltlen);\n\nX509_ALGOR *PKCS5_pbe_set(int alg, int iter,\n                          const unsigned char *salt, int saltlen);\nX509_ALGOR *PKCS5_pbe2_set(const EVP_CIPHER *cipher, int iter,\n                           unsigned char *salt, int saltlen);\nX509_ALGOR *PKCS5_pbe2_set_iv(const EVP_CIPHER *cipher, int iter,\n                              unsigned char *salt, int saltlen,\n                              unsigned char *aiv, int prf_nid);\n\n#ifndef OPENSSL_NO_SCRYPT\nX509_ALGOR *PKCS5_pbe2_set_scrypt(const EVP_CIPHER *cipher,\n                                  const unsigned char *salt, int saltlen,\n                                  unsigned char *aiv, uint64_t N, uint64_t r,\n                                  uint64_t p);\n#endif\n\nX509_ALGOR *PKCS5_pbkdf2_set(int iter, unsigned char *salt, int saltlen,\n                             int prf_nid, int keylen);\n\n/* PKCS#8 utilities */\n\nDECLARE_ASN1_FUNCTIONS(PKCS8_PRIV_KEY_INFO)\n\nEVP_PKEY *EVP_PKCS82PKEY(const PKCS8_PRIV_KEY_INFO *p8);\nPKCS8_PRIV_KEY_INFO *EVP_PKEY2PKCS8(EVP_PKEY *pkey);\n\nint PKCS8_pkey_set0(PKCS8_PRIV_KEY_INFO *priv, ASN1_OBJECT *aobj,\n                    int version, int ptype, void *pval,\n                    unsigned char *penc, int penclen);\nint PKCS8_pkey_get0(const ASN1_OBJECT **ppkalg,\n                    const unsigned char **pk, int *ppklen,\n                    const X509_ALGOR **pa, const PKCS8_PRIV_KEY_INFO *p8);\n\nconst STACK_OF(X509_ATTRIBUTE) *\nPKCS8_pkey_get0_attrs(const PKCS8_PRIV_KEY_INFO *p8);\nint PKCS8_pkey_add1_attr_by_NID(PKCS8_PRIV_KEY_INFO *p8, int nid, int type,\n                                const unsigned char *bytes, int len);\n\nint X509_PUBKEY_set0_param(X509_PUBKEY *pub, ASN1_OBJECT *aobj,\n                           int ptype, void *pval,\n                           unsigned char *penc, int penclen);\nint X509_PUBKEY_get0_param(ASN1_OBJECT **ppkalg,\n                           const unsigned char **pk, int *ppklen,\n                           X509_ALGOR **pa, X509_PUBKEY *pub);\n\nint X509_check_trust(X509 *x, int id, int flags);\nint X509_TRUST_get_count(void);\nX509_TRUST *X509_TRUST_get0(int idx);\nint X509_TRUST_get_by_id(int id);\nint X509_TRUST_add(int id, int flags, int (*ck) (X509_TRUST *, X509 *, int),\n                   const char *name, int arg1, void *arg2);\nvoid X509_TRUST_cleanup(void);\nint X509_TRUST_get_flags(const X509_TRUST *xp);\nchar *X509_TRUST_get0_name(const X509_TRUST *xp);\nint X509_TRUST_get_trust(const X509_TRUST *xp);\n\n# ifdef  __cplusplus\n}\n# endif\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/include/openssl/x509_vfy.h",
    "content": "/*\n * Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef HEADER_X509_VFY_H\n# define HEADER_X509_VFY_H\n\n/*\n * Protect against recursion, x509.h and x509_vfy.h each include the other.\n */\n# ifndef HEADER_X509_H\n#  include <openssl/x509.h>\n# endif\n\n# include <openssl/opensslconf.h>\n# include <openssl/lhash.h>\n# include <openssl/bio.h>\n# include <openssl/crypto.h>\n# include <openssl/symhacks.h>\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n/*-\nSSL_CTX -> X509_STORE\n                -> X509_LOOKUP\n                        ->X509_LOOKUP_METHOD\n                -> X509_LOOKUP\n                        ->X509_LOOKUP_METHOD\n\nSSL     -> X509_STORE_CTX\n                ->X509_STORE\n\nThe X509_STORE holds the tables etc for verification stuff.\nA X509_STORE_CTX is used while validating a single certificate.\nThe X509_STORE has X509_LOOKUPs for looking up certs.\nThe X509_STORE then calls a function to actually verify the\ncertificate chain.\n*/\n\ntypedef enum {\n    X509_LU_NONE = 0,\n    X509_LU_X509, X509_LU_CRL\n} X509_LOOKUP_TYPE;\n\n#if OPENSSL_API_COMPAT < 0x10100000L\n#define X509_LU_RETRY   -1\n#define X509_LU_FAIL    0\n#endif\n\nDEFINE_STACK_OF(X509_LOOKUP)\nDEFINE_STACK_OF(X509_OBJECT)\nDEFINE_STACK_OF(X509_VERIFY_PARAM)\n\nint X509_STORE_set_depth(X509_STORE *store, int depth);\n\ntypedef int (*X509_STORE_CTX_verify_cb)(int, X509_STORE_CTX *);\ntypedef int (*X509_STORE_CTX_verify_fn)(X509_STORE_CTX *);\ntypedef int (*X509_STORE_CTX_get_issuer_fn)(X509 **issuer,\n                                            X509_STORE_CTX *ctx, X509 *x);\ntypedef int (*X509_STORE_CTX_check_issued_fn)(X509_STORE_CTX *ctx,\n                                              X509 *x, X509 *issuer);\ntypedef int (*X509_STORE_CTX_check_revocation_fn)(X509_STORE_CTX *ctx);\ntypedef int (*X509_STORE_CTX_get_crl_fn)(X509_STORE_CTX *ctx,\n                                         X509_CRL **crl, X509 *x);\ntypedef int (*X509_STORE_CTX_check_crl_fn)(X509_STORE_CTX *ctx, X509_CRL *crl);\ntypedef int (*X509_STORE_CTX_cert_crl_fn)(X509_STORE_CTX *ctx,\n                                          X509_CRL *crl, X509 *x);\ntypedef int (*X509_STORE_CTX_check_policy_fn)(X509_STORE_CTX *ctx);\ntypedef STACK_OF(X509) *(*X509_STORE_CTX_lookup_certs_fn)(X509_STORE_CTX *ctx,\n                                                          X509_NAME *nm);\ntypedef STACK_OF(X509_CRL) *(*X509_STORE_CTX_lookup_crls_fn)(X509_STORE_CTX *ctx,\n                                                             X509_NAME *nm);\ntypedef int (*X509_STORE_CTX_cleanup_fn)(X509_STORE_CTX *ctx);\n\n\nvoid X509_STORE_CTX_set_depth(X509_STORE_CTX *ctx, int depth);\n\n# define X509_STORE_CTX_set_app_data(ctx,data) \\\n        X509_STORE_CTX_set_ex_data(ctx,0,data)\n# define X509_STORE_CTX_get_app_data(ctx) \\\n        X509_STORE_CTX_get_ex_data(ctx,0)\n\n# define X509_L_FILE_LOAD        1\n# define X509_L_ADD_DIR          2\n\n# define X509_LOOKUP_load_file(x,name,type) \\\n                X509_LOOKUP_ctrl((x),X509_L_FILE_LOAD,(name),(long)(type),NULL)\n\n# define X509_LOOKUP_add_dir(x,name,type) \\\n                X509_LOOKUP_ctrl((x),X509_L_ADD_DIR,(name),(long)(type),NULL)\n\n# define         X509_V_OK                                       0\n# define         X509_V_ERR_UNSPECIFIED                          1\n# define         X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT            2\n# define         X509_V_ERR_UNABLE_TO_GET_CRL                    3\n# define         X509_V_ERR_UNABLE_TO_DECRYPT_CERT_SIGNATURE     4\n# define         X509_V_ERR_UNABLE_TO_DECRYPT_CRL_SIGNATURE      5\n# define         X509_V_ERR_UNABLE_TO_DECODE_ISSUER_PUBLIC_KEY   6\n# define         X509_V_ERR_CERT_SIGNATURE_FAILURE               7\n# define         X509_V_ERR_CRL_SIGNATURE_FAILURE                8\n# define         X509_V_ERR_CERT_NOT_YET_VALID                   9\n# define         X509_V_ERR_CERT_HAS_EXPIRED                     10\n# define         X509_V_ERR_CRL_NOT_YET_VALID                    11\n# define         X509_V_ERR_CRL_HAS_EXPIRED                      12\n# define         X509_V_ERR_ERROR_IN_CERT_NOT_BEFORE_FIELD       13\n# define         X509_V_ERR_ERROR_IN_CERT_NOT_AFTER_FIELD        14\n# define         X509_V_ERR_ERROR_IN_CRL_LAST_UPDATE_FIELD       15\n# define         X509_V_ERR_ERROR_IN_CRL_NEXT_UPDATE_FIELD       16\n# define         X509_V_ERR_OUT_OF_MEM                           17\n# define         X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT          18\n# define         X509_V_ERR_SELF_SIGNED_CERT_IN_CHAIN            19\n# define         X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY    20\n# define         X509_V_ERR_UNABLE_TO_VERIFY_LEAF_SIGNATURE      21\n# define         X509_V_ERR_CERT_CHAIN_TOO_LONG                  22\n# define         X509_V_ERR_CERT_REVOKED                         23\n# define         X509_V_ERR_INVALID_CA                           24\n# define         X509_V_ERR_PATH_LENGTH_EXCEEDED                 25\n# define         X509_V_ERR_INVALID_PURPOSE                      26\n# define         X509_V_ERR_CERT_UNTRUSTED                       27\n# define         X509_V_ERR_CERT_REJECTED                        28\n/* These are 'informational' when looking for issuer cert */\n# define         X509_V_ERR_SUBJECT_ISSUER_MISMATCH              29\n# define         X509_V_ERR_AKID_SKID_MISMATCH                   30\n# define         X509_V_ERR_AKID_ISSUER_SERIAL_MISMATCH          31\n# define         X509_V_ERR_KEYUSAGE_NO_CERTSIGN                 32\n# define         X509_V_ERR_UNABLE_TO_GET_CRL_ISSUER             33\n# define         X509_V_ERR_UNHANDLED_CRITICAL_EXTENSION         34\n# define         X509_V_ERR_KEYUSAGE_NO_CRL_SIGN                 35\n# define         X509_V_ERR_UNHANDLED_CRITICAL_CRL_EXTENSION     36\n# define         X509_V_ERR_INVALID_NON_CA                       37\n# define         X509_V_ERR_PROXY_PATH_LENGTH_EXCEEDED           38\n# define         X509_V_ERR_KEYUSAGE_NO_DIGITAL_SIGNATURE        39\n# define         X509_V_ERR_PROXY_CERTIFICATES_NOT_ALLOWED       40\n# define         X509_V_ERR_INVALID_EXTENSION                    41\n# define         X509_V_ERR_INVALID_POLICY_EXTENSION             42\n# define         X509_V_ERR_NO_EXPLICIT_POLICY                   43\n# define         X509_V_ERR_DIFFERENT_CRL_SCOPE                  44\n# define         X509_V_ERR_UNSUPPORTED_EXTENSION_FEATURE        45\n# define         X509_V_ERR_UNNESTED_RESOURCE                    46\n# define         X509_V_ERR_PERMITTED_VIOLATION                  47\n# define         X509_V_ERR_EXCLUDED_VIOLATION                   48\n# define         X509_V_ERR_SUBTREE_MINMAX                       49\n/* The application is not happy */\n# define         X509_V_ERR_APPLICATION_VERIFICATION             50\n# define         X509_V_ERR_UNSUPPORTED_CONSTRAINT_TYPE          51\n# define         X509_V_ERR_UNSUPPORTED_CONSTRAINT_SYNTAX        52\n# define         X509_V_ERR_UNSUPPORTED_NAME_SYNTAX              53\n# define         X509_V_ERR_CRL_PATH_VALIDATION_ERROR            54\n/* Another issuer check debug option */\n# define         X509_V_ERR_PATH_LOOP                            55\n/* Suite B mode algorithm violation */\n# define         X509_V_ERR_SUITE_B_INVALID_VERSION              56\n# define         X509_V_ERR_SUITE_B_INVALID_ALGORITHM            57\n# define         X509_V_ERR_SUITE_B_INVALID_CURVE                58\n# define         X509_V_ERR_SUITE_B_INVALID_SIGNATURE_ALGORITHM  59\n# define         X509_V_ERR_SUITE_B_LOS_NOT_ALLOWED              60\n# define         X509_V_ERR_SUITE_B_CANNOT_SIGN_P_384_WITH_P_256 61\n/* Host, email and IP check errors */\n# define         X509_V_ERR_HOSTNAME_MISMATCH                    62\n# define         X509_V_ERR_EMAIL_MISMATCH                       63\n# define         X509_V_ERR_IP_ADDRESS_MISMATCH                  64\n/* DANE TLSA errors */\n# define         X509_V_ERR_DANE_NO_MATCH                        65\n/* security level errors */\n# define         X509_V_ERR_EE_KEY_TOO_SMALL                     66\n# define         X509_V_ERR_CA_KEY_TOO_SMALL                     67\n# define         X509_V_ERR_CA_MD_TOO_WEAK                       68\n/* Caller error */\n# define         X509_V_ERR_INVALID_CALL                         69\n/* Issuer lookup error */\n# define         X509_V_ERR_STORE_LOOKUP                         70\n/* Certificate transparency */\n# define         X509_V_ERR_NO_VALID_SCTS                        71\n\n# define         X509_V_ERR_PROXY_SUBJECT_NAME_VIOLATION         72\n/* OCSP status errors */\n# define         X509_V_ERR_OCSP_VERIFY_NEEDED                   73  /* Need OCSP verification */\n# define         X509_V_ERR_OCSP_VERIFY_FAILED                   74  /* Couldn't verify cert through OCSP */\n# define         X509_V_ERR_OCSP_CERT_UNKNOWN                    75  /* Certificate wasn't recognized by the OCSP responder */\n# define         X509_V_ERR_SIGNATURE_ALGORITHM_MISMATCH         76\n# define         X509_V_ERR_NO_ISSUER_PUBLIC_KEY                 77\n# define         X509_V_ERR_UNSUPPORTED_SIGNATURE_ALGORITHM      78\n# define         X509_V_ERR_EC_KEY_EXPLICIT_PARAMS               79\n\n/* Certificate verify flags */\n\n# if OPENSSL_API_COMPAT < 0x10100000L\n#  define X509_V_FLAG_CB_ISSUER_CHECK             0x0   /* Deprecated */\n# endif\n/* Use check time instead of current time */\n# define X509_V_FLAG_USE_CHECK_TIME              0x2\n/* Lookup CRLs */\n# define X509_V_FLAG_CRL_CHECK                   0x4\n/* Lookup CRLs for whole chain */\n# define X509_V_FLAG_CRL_CHECK_ALL               0x8\n/* Ignore unhandled critical extensions */\n# define X509_V_FLAG_IGNORE_CRITICAL             0x10\n/* Disable workarounds for broken certificates */\n# define X509_V_FLAG_X509_STRICT                 0x20\n/* Enable proxy certificate validation */\n# define X509_V_FLAG_ALLOW_PROXY_CERTS           0x40\n/* Enable policy checking */\n# define X509_V_FLAG_POLICY_CHECK                0x80\n/* Policy variable require-explicit-policy */\n# define X509_V_FLAG_EXPLICIT_POLICY             0x100\n/* Policy variable inhibit-any-policy */\n# define X509_V_FLAG_INHIBIT_ANY                 0x200\n/* Policy variable inhibit-policy-mapping */\n# define X509_V_FLAG_INHIBIT_MAP                 0x400\n/* Notify callback that policy is OK */\n# define X509_V_FLAG_NOTIFY_POLICY               0x800\n/* Extended CRL features such as indirect CRLs, alternate CRL signing keys */\n# define X509_V_FLAG_EXTENDED_CRL_SUPPORT        0x1000\n/* Delta CRL support */\n# define X509_V_FLAG_USE_DELTAS                  0x2000\n/* Check self-signed CA signature */\n# define X509_V_FLAG_CHECK_SS_SIGNATURE          0x4000\n/* Use trusted store first */\n# define X509_V_FLAG_TRUSTED_FIRST               0x8000\n/* Suite B 128 bit only mode: not normally used */\n# define X509_V_FLAG_SUITEB_128_LOS_ONLY         0x10000\n/* Suite B 192 bit only mode */\n# define X509_V_FLAG_SUITEB_192_LOS              0x20000\n/* Suite B 128 bit mode allowing 192 bit algorithms */\n# define X509_V_FLAG_SUITEB_128_LOS              0x30000\n/* Allow partial chains if at least one certificate is in trusted store */\n# define X509_V_FLAG_PARTIAL_CHAIN               0x80000\n/*\n * If the initial chain is not trusted, do not attempt to build an alternative\n * chain. Alternate chain checking was introduced in 1.1.0. Setting this flag\n * will force the behaviour to match that of previous versions.\n */\n# define X509_V_FLAG_NO_ALT_CHAINS               0x100000\n/* Do not check certificate/CRL validity against current time */\n# define X509_V_FLAG_NO_CHECK_TIME               0x200000\n\n# define X509_VP_FLAG_DEFAULT                    0x1\n# define X509_VP_FLAG_OVERWRITE                  0x2\n# define X509_VP_FLAG_RESET_FLAGS                0x4\n# define X509_VP_FLAG_LOCKED                     0x8\n# define X509_VP_FLAG_ONCE                       0x10\n\n/* Internal use: mask of policy related options */\n# define X509_V_FLAG_POLICY_MASK (X509_V_FLAG_POLICY_CHECK \\\n                                | X509_V_FLAG_EXPLICIT_POLICY \\\n                                | X509_V_FLAG_INHIBIT_ANY \\\n                                | X509_V_FLAG_INHIBIT_MAP)\n\nint X509_OBJECT_idx_by_subject(STACK_OF(X509_OBJECT) *h, X509_LOOKUP_TYPE type,\n                               X509_NAME *name);\nX509_OBJECT *X509_OBJECT_retrieve_by_subject(STACK_OF(X509_OBJECT) *h,\n                                             X509_LOOKUP_TYPE type,\n                                             X509_NAME *name);\nX509_OBJECT *X509_OBJECT_retrieve_match(STACK_OF(X509_OBJECT) *h,\n                                        X509_OBJECT *x);\nint X509_OBJECT_up_ref_count(X509_OBJECT *a);\nX509_OBJECT *X509_OBJECT_new(void);\nvoid X509_OBJECT_free(X509_OBJECT *a);\nX509_LOOKUP_TYPE X509_OBJECT_get_type(const X509_OBJECT *a);\nX509 *X509_OBJECT_get0_X509(const X509_OBJECT *a);\nint X509_OBJECT_set1_X509(X509_OBJECT *a, X509 *obj);\nX509_CRL *X509_OBJECT_get0_X509_CRL(X509_OBJECT *a);\nint X509_OBJECT_set1_X509_CRL(X509_OBJECT *a, X509_CRL *obj);\nX509_STORE *X509_STORE_new(void);\nvoid X509_STORE_free(X509_STORE *v);\nint X509_STORE_lock(X509_STORE *ctx);\nint X509_STORE_unlock(X509_STORE *ctx);\nint X509_STORE_up_ref(X509_STORE *v);\nSTACK_OF(X509_OBJECT) *X509_STORE_get0_objects(X509_STORE *v);\n\nSTACK_OF(X509) *X509_STORE_CTX_get1_certs(X509_STORE_CTX *st, X509_NAME *nm);\nSTACK_OF(X509_CRL) *X509_STORE_CTX_get1_crls(X509_STORE_CTX *st, X509_NAME *nm);\nint X509_STORE_set_flags(X509_STORE *ctx, unsigned long flags);\nint X509_STORE_set_purpose(X509_STORE *ctx, int purpose);\nint X509_STORE_set_trust(X509_STORE *ctx, int trust);\nint X509_STORE_set1_param(X509_STORE *ctx, X509_VERIFY_PARAM *pm);\nX509_VERIFY_PARAM *X509_STORE_get0_param(X509_STORE *ctx);\n\nvoid X509_STORE_set_verify(X509_STORE *ctx, X509_STORE_CTX_verify_fn verify);\n#define X509_STORE_set_verify_func(ctx, func) \\\n            X509_STORE_set_verify((ctx),(func))\nvoid X509_STORE_CTX_set_verify(X509_STORE_CTX *ctx,\n                               X509_STORE_CTX_verify_fn verify);\nX509_STORE_CTX_verify_fn X509_STORE_get_verify(X509_STORE *ctx);\nvoid X509_STORE_set_verify_cb(X509_STORE *ctx,\n                              X509_STORE_CTX_verify_cb verify_cb);\n# define X509_STORE_set_verify_cb_func(ctx,func) \\\n            X509_STORE_set_verify_cb((ctx),(func))\nX509_STORE_CTX_verify_cb X509_STORE_get_verify_cb(X509_STORE *ctx);\nvoid X509_STORE_set_get_issuer(X509_STORE *ctx,\n                               X509_STORE_CTX_get_issuer_fn get_issuer);\nX509_STORE_CTX_get_issuer_fn X509_STORE_get_get_issuer(X509_STORE *ctx);\nvoid X509_STORE_set_check_issued(X509_STORE *ctx,\n                                 X509_STORE_CTX_check_issued_fn check_issued);\nX509_STORE_CTX_check_issued_fn X509_STORE_get_check_issued(X509_STORE *ctx);\nvoid X509_STORE_set_check_revocation(X509_STORE *ctx,\n                                     X509_STORE_CTX_check_revocation_fn check_revocation);\nX509_STORE_CTX_check_revocation_fn X509_STORE_get_check_revocation(X509_STORE *ctx);\nvoid X509_STORE_set_get_crl(X509_STORE *ctx,\n                            X509_STORE_CTX_get_crl_fn get_crl);\nX509_STORE_CTX_get_crl_fn X509_STORE_get_get_crl(X509_STORE *ctx);\nvoid X509_STORE_set_check_crl(X509_STORE *ctx,\n                              X509_STORE_CTX_check_crl_fn check_crl);\nX509_STORE_CTX_check_crl_fn X509_STORE_get_check_crl(X509_STORE *ctx);\nvoid X509_STORE_set_cert_crl(X509_STORE *ctx,\n                             X509_STORE_CTX_cert_crl_fn cert_crl);\nX509_STORE_CTX_cert_crl_fn X509_STORE_get_cert_crl(X509_STORE *ctx);\nvoid X509_STORE_set_check_policy(X509_STORE *ctx,\n                                 X509_STORE_CTX_check_policy_fn check_policy);\nX509_STORE_CTX_check_policy_fn X509_STORE_get_check_policy(X509_STORE *ctx);\nvoid X509_STORE_set_lookup_certs(X509_STORE *ctx,\n                                 X509_STORE_CTX_lookup_certs_fn lookup_certs);\nX509_STORE_CTX_lookup_certs_fn X509_STORE_get_lookup_certs(X509_STORE *ctx);\nvoid X509_STORE_set_lookup_crls(X509_STORE *ctx,\n                                X509_STORE_CTX_lookup_crls_fn lookup_crls);\n#define X509_STORE_set_lookup_crls_cb(ctx, func) \\\n    X509_STORE_set_lookup_crls((ctx), (func))\nX509_STORE_CTX_lookup_crls_fn X509_STORE_get_lookup_crls(X509_STORE *ctx);\nvoid X509_STORE_set_cleanup(X509_STORE *ctx,\n                            X509_STORE_CTX_cleanup_fn cleanup);\nX509_STORE_CTX_cleanup_fn X509_STORE_get_cleanup(X509_STORE *ctx);\n\n#define X509_STORE_get_ex_new_index(l, p, newf, dupf, freef) \\\n    CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_X509_STORE, l, p, newf, dupf, freef)\nint X509_STORE_set_ex_data(X509_STORE *ctx, int idx, void *data);\nvoid *X509_STORE_get_ex_data(X509_STORE *ctx, int idx);\n\nX509_STORE_CTX *X509_STORE_CTX_new(void);\n\nint X509_STORE_CTX_get1_issuer(X509 **issuer, X509_STORE_CTX *ctx, X509 *x);\n\nvoid X509_STORE_CTX_free(X509_STORE_CTX *ctx);\nint X509_STORE_CTX_init(X509_STORE_CTX *ctx, X509_STORE *store,\n                        X509 *x509, STACK_OF(X509) *chain);\nvoid X509_STORE_CTX_set0_trusted_stack(X509_STORE_CTX *ctx, STACK_OF(X509) *sk);\nvoid X509_STORE_CTX_cleanup(X509_STORE_CTX *ctx);\n\nX509_STORE *X509_STORE_CTX_get0_store(X509_STORE_CTX *ctx);\nX509 *X509_STORE_CTX_get0_cert(X509_STORE_CTX *ctx);\nSTACK_OF(X509)* X509_STORE_CTX_get0_untrusted(X509_STORE_CTX *ctx);\nvoid X509_STORE_CTX_set0_untrusted(X509_STORE_CTX *ctx, STACK_OF(X509) *sk);\nvoid X509_STORE_CTX_set_verify_cb(X509_STORE_CTX *ctx,\n                                  X509_STORE_CTX_verify_cb verify);\nX509_STORE_CTX_verify_cb X509_STORE_CTX_get_verify_cb(X509_STORE_CTX *ctx);\nX509_STORE_CTX_verify_fn X509_STORE_CTX_get_verify(X509_STORE_CTX *ctx);\nX509_STORE_CTX_get_issuer_fn X509_STORE_CTX_get_get_issuer(X509_STORE_CTX *ctx);\nX509_STORE_CTX_check_issued_fn X509_STORE_CTX_get_check_issued(X509_STORE_CTX *ctx);\nX509_STORE_CTX_check_revocation_fn X509_STORE_CTX_get_check_revocation(X509_STORE_CTX *ctx);\nX509_STORE_CTX_get_crl_fn X509_STORE_CTX_get_get_crl(X509_STORE_CTX *ctx);\nX509_STORE_CTX_check_crl_fn X509_STORE_CTX_get_check_crl(X509_STORE_CTX *ctx);\nX509_STORE_CTX_cert_crl_fn X509_STORE_CTX_get_cert_crl(X509_STORE_CTX *ctx);\nX509_STORE_CTX_check_policy_fn X509_STORE_CTX_get_check_policy(X509_STORE_CTX *ctx);\nX509_STORE_CTX_lookup_certs_fn X509_STORE_CTX_get_lookup_certs(X509_STORE_CTX *ctx);\nX509_STORE_CTX_lookup_crls_fn X509_STORE_CTX_get_lookup_crls(X509_STORE_CTX *ctx);\nX509_STORE_CTX_cleanup_fn X509_STORE_CTX_get_cleanup(X509_STORE_CTX *ctx);\n\n#if OPENSSL_API_COMPAT < 0x10100000L\n# define X509_STORE_CTX_get_chain X509_STORE_CTX_get0_chain\n# define X509_STORE_CTX_set_chain X509_STORE_CTX_set0_untrusted\n# define X509_STORE_CTX_trusted_stack X509_STORE_CTX_set0_trusted_stack\n# define X509_STORE_get_by_subject X509_STORE_CTX_get_by_subject\n# define X509_STORE_get1_certs X509_STORE_CTX_get1_certs\n# define X509_STORE_get1_crls X509_STORE_CTX_get1_crls\n/* the following macro is misspelled; use X509_STORE_get1_certs instead */\n# define X509_STORE_get1_cert X509_STORE_CTX_get1_certs\n/* the following macro is misspelled; use X509_STORE_get1_crls instead */\n# define X509_STORE_get1_crl X509_STORE_CTX_get1_crls\n#endif\n\nX509_LOOKUP *X509_STORE_add_lookup(X509_STORE *v, X509_LOOKUP_METHOD *m);\nX509_LOOKUP_METHOD *X509_LOOKUP_hash_dir(void);\nX509_LOOKUP_METHOD *X509_LOOKUP_file(void);\n\ntypedef int (*X509_LOOKUP_ctrl_fn)(X509_LOOKUP *ctx, int cmd, const char *argc,\n                                   long argl, char **ret);\ntypedef int (*X509_LOOKUP_get_by_subject_fn)(X509_LOOKUP *ctx,\n                                             X509_LOOKUP_TYPE type,\n                                             X509_NAME *name,\n                                             X509_OBJECT *ret);\ntypedef int (*X509_LOOKUP_get_by_issuer_serial_fn)(X509_LOOKUP *ctx,\n                                                   X509_LOOKUP_TYPE type,\n                                                   X509_NAME *name,\n                                                   ASN1_INTEGER *serial,\n                                                   X509_OBJECT *ret);\ntypedef int (*X509_LOOKUP_get_by_fingerprint_fn)(X509_LOOKUP *ctx,\n                                                 X509_LOOKUP_TYPE type,\n                                                 const unsigned char* bytes,\n                                                 int len,\n                                                 X509_OBJECT *ret);\ntypedef int (*X509_LOOKUP_get_by_alias_fn)(X509_LOOKUP *ctx,\n                                           X509_LOOKUP_TYPE type,\n                                           const char *str,\n                                           int len,\n                                           X509_OBJECT *ret);\n\nX509_LOOKUP_METHOD *X509_LOOKUP_meth_new(const char *name);\nvoid X509_LOOKUP_meth_free(X509_LOOKUP_METHOD *method);\n\nint X509_LOOKUP_meth_set_new_item(X509_LOOKUP_METHOD *method,\n                                  int (*new_item) (X509_LOOKUP *ctx));\nint (*X509_LOOKUP_meth_get_new_item(const X509_LOOKUP_METHOD* method))\n    (X509_LOOKUP *ctx);\n\nint X509_LOOKUP_meth_set_free(X509_LOOKUP_METHOD *method,\n                              void (*free_fn) (X509_LOOKUP *ctx));\nvoid (*X509_LOOKUP_meth_get_free(const X509_LOOKUP_METHOD* method))\n    (X509_LOOKUP *ctx);\n\nint X509_LOOKUP_meth_set_init(X509_LOOKUP_METHOD *method,\n                              int (*init) (X509_LOOKUP *ctx));\nint (*X509_LOOKUP_meth_get_init(const X509_LOOKUP_METHOD* method))\n    (X509_LOOKUP *ctx);\n\nint X509_LOOKUP_meth_set_shutdown(X509_LOOKUP_METHOD *method,\n                                  int (*shutdown) (X509_LOOKUP *ctx));\nint (*X509_LOOKUP_meth_get_shutdown(const X509_LOOKUP_METHOD* method))\n    (X509_LOOKUP *ctx);\n\nint X509_LOOKUP_meth_set_ctrl(X509_LOOKUP_METHOD *method,\n                              X509_LOOKUP_ctrl_fn ctrl_fn);\nX509_LOOKUP_ctrl_fn X509_LOOKUP_meth_get_ctrl(const X509_LOOKUP_METHOD *method);\n\nint X509_LOOKUP_meth_set_get_by_subject(X509_LOOKUP_METHOD *method,\n                                        X509_LOOKUP_get_by_subject_fn fn);\nX509_LOOKUP_get_by_subject_fn X509_LOOKUP_meth_get_get_by_subject(\n    const X509_LOOKUP_METHOD *method);\n\nint X509_LOOKUP_meth_set_get_by_issuer_serial(X509_LOOKUP_METHOD *method,\n    X509_LOOKUP_get_by_issuer_serial_fn fn);\nX509_LOOKUP_get_by_issuer_serial_fn X509_LOOKUP_meth_get_get_by_issuer_serial(\n    const X509_LOOKUP_METHOD *method);\n\nint X509_LOOKUP_meth_set_get_by_fingerprint(X509_LOOKUP_METHOD *method,\n    X509_LOOKUP_get_by_fingerprint_fn fn);\nX509_LOOKUP_get_by_fingerprint_fn X509_LOOKUP_meth_get_get_by_fingerprint(\n    const X509_LOOKUP_METHOD *method);\n\nint X509_LOOKUP_meth_set_get_by_alias(X509_LOOKUP_METHOD *method,\n                                      X509_LOOKUP_get_by_alias_fn fn);\nX509_LOOKUP_get_by_alias_fn X509_LOOKUP_meth_get_get_by_alias(\n    const X509_LOOKUP_METHOD *method);\n\n\nint X509_STORE_add_cert(X509_STORE *ctx, X509 *x);\nint X509_STORE_add_crl(X509_STORE *ctx, X509_CRL *x);\n\nint X509_STORE_CTX_get_by_subject(X509_STORE_CTX *vs, X509_LOOKUP_TYPE type,\n                                  X509_NAME *name, X509_OBJECT *ret);\nX509_OBJECT *X509_STORE_CTX_get_obj_by_subject(X509_STORE_CTX *vs,\n                                               X509_LOOKUP_TYPE type,\n                                               X509_NAME *name);\n\nint X509_LOOKUP_ctrl(X509_LOOKUP *ctx, int cmd, const char *argc,\n                     long argl, char **ret);\n\nint X509_load_cert_file(X509_LOOKUP *ctx, const char *file, int type);\nint X509_load_crl_file(X509_LOOKUP *ctx, const char *file, int type);\nint X509_load_cert_crl_file(X509_LOOKUP *ctx, const char *file, int type);\n\nX509_LOOKUP *X509_LOOKUP_new(X509_LOOKUP_METHOD *method);\nvoid X509_LOOKUP_free(X509_LOOKUP *ctx);\nint X509_LOOKUP_init(X509_LOOKUP *ctx);\nint X509_LOOKUP_by_subject(X509_LOOKUP *ctx, X509_LOOKUP_TYPE type,\n                           X509_NAME *name, X509_OBJECT *ret);\nint X509_LOOKUP_by_issuer_serial(X509_LOOKUP *ctx, X509_LOOKUP_TYPE type,\n                                 X509_NAME *name, ASN1_INTEGER *serial,\n                                 X509_OBJECT *ret);\nint X509_LOOKUP_by_fingerprint(X509_LOOKUP *ctx, X509_LOOKUP_TYPE type,\n                               const unsigned char *bytes, int len,\n                               X509_OBJECT *ret);\nint X509_LOOKUP_by_alias(X509_LOOKUP *ctx, X509_LOOKUP_TYPE type,\n                         const char *str, int len, X509_OBJECT *ret);\nint X509_LOOKUP_set_method_data(X509_LOOKUP *ctx, void *data);\nvoid *X509_LOOKUP_get_method_data(const X509_LOOKUP *ctx);\nX509_STORE *X509_LOOKUP_get_store(const X509_LOOKUP *ctx);\nint X509_LOOKUP_shutdown(X509_LOOKUP *ctx);\n\nint X509_STORE_load_locations(X509_STORE *ctx,\n                              const char *file, const char *dir);\nint X509_STORE_set_default_paths(X509_STORE *ctx);\n\n#define X509_STORE_CTX_get_ex_new_index(l, p, newf, dupf, freef) \\\n    CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_X509_STORE_CTX, l, p, newf, dupf, freef)\nint X509_STORE_CTX_set_ex_data(X509_STORE_CTX *ctx, int idx, void *data);\nvoid *X509_STORE_CTX_get_ex_data(X509_STORE_CTX *ctx, int idx);\nint X509_STORE_CTX_get_error(X509_STORE_CTX *ctx);\nvoid X509_STORE_CTX_set_error(X509_STORE_CTX *ctx, int s);\nint X509_STORE_CTX_get_error_depth(X509_STORE_CTX *ctx);\nvoid X509_STORE_CTX_set_error_depth(X509_STORE_CTX *ctx, int depth);\nX509 *X509_STORE_CTX_get_current_cert(X509_STORE_CTX *ctx);\nvoid X509_STORE_CTX_set_current_cert(X509_STORE_CTX *ctx, X509 *x);\nX509 *X509_STORE_CTX_get0_current_issuer(X509_STORE_CTX *ctx);\nX509_CRL *X509_STORE_CTX_get0_current_crl(X509_STORE_CTX *ctx);\nX509_STORE_CTX *X509_STORE_CTX_get0_parent_ctx(X509_STORE_CTX *ctx);\nSTACK_OF(X509) *X509_STORE_CTX_get0_chain(X509_STORE_CTX *ctx);\nSTACK_OF(X509) *X509_STORE_CTX_get1_chain(X509_STORE_CTX *ctx);\nvoid X509_STORE_CTX_set_cert(X509_STORE_CTX *c, X509 *x);\nvoid X509_STORE_CTX_set0_verified_chain(X509_STORE_CTX *c, STACK_OF(X509) *sk);\nvoid X509_STORE_CTX_set0_crls(X509_STORE_CTX *c, STACK_OF(X509_CRL) *sk);\nint X509_STORE_CTX_set_purpose(X509_STORE_CTX *ctx, int purpose);\nint X509_STORE_CTX_set_trust(X509_STORE_CTX *ctx, int trust);\nint X509_STORE_CTX_purpose_inherit(X509_STORE_CTX *ctx, int def_purpose,\n                                   int purpose, int trust);\nvoid X509_STORE_CTX_set_flags(X509_STORE_CTX *ctx, unsigned long flags);\nvoid X509_STORE_CTX_set_time(X509_STORE_CTX *ctx, unsigned long flags,\n                             time_t t);\n\nX509_POLICY_TREE *X509_STORE_CTX_get0_policy_tree(X509_STORE_CTX *ctx);\nint X509_STORE_CTX_get_explicit_policy(X509_STORE_CTX *ctx);\nint X509_STORE_CTX_get_num_untrusted(X509_STORE_CTX *ctx);\n\nX509_VERIFY_PARAM *X509_STORE_CTX_get0_param(X509_STORE_CTX *ctx);\nvoid X509_STORE_CTX_set0_param(X509_STORE_CTX *ctx, X509_VERIFY_PARAM *param);\nint X509_STORE_CTX_set_default(X509_STORE_CTX *ctx, const char *name);\n\n/*\n * Bridge opacity barrier between libcrypt and libssl, also needed to support\n * offline testing in test/danetest.c\n */\nvoid X509_STORE_CTX_set0_dane(X509_STORE_CTX *ctx, SSL_DANE *dane);\n#define DANE_FLAG_NO_DANE_EE_NAMECHECKS (1L << 0)\n\n/* X509_VERIFY_PARAM functions */\n\nX509_VERIFY_PARAM *X509_VERIFY_PARAM_new(void);\nvoid X509_VERIFY_PARAM_free(X509_VERIFY_PARAM *param);\nint X509_VERIFY_PARAM_inherit(X509_VERIFY_PARAM *to,\n                              const X509_VERIFY_PARAM *from);\nint X509_VERIFY_PARAM_set1(X509_VERIFY_PARAM *to,\n                           const X509_VERIFY_PARAM *from);\nint X509_VERIFY_PARAM_set1_name(X509_VERIFY_PARAM *param, const char *name);\nint X509_VERIFY_PARAM_set_flags(X509_VERIFY_PARAM *param,\n                                unsigned long flags);\nint X509_VERIFY_PARAM_clear_flags(X509_VERIFY_PARAM *param,\n                                  unsigned long flags);\nunsigned long X509_VERIFY_PARAM_get_flags(X509_VERIFY_PARAM *param);\nint X509_VERIFY_PARAM_set_purpose(X509_VERIFY_PARAM *param, int purpose);\nint X509_VERIFY_PARAM_set_trust(X509_VERIFY_PARAM *param, int trust);\nvoid X509_VERIFY_PARAM_set_depth(X509_VERIFY_PARAM *param, int depth);\nvoid X509_VERIFY_PARAM_set_auth_level(X509_VERIFY_PARAM *param, int auth_level);\ntime_t X509_VERIFY_PARAM_get_time(const X509_VERIFY_PARAM *param);\nvoid X509_VERIFY_PARAM_set_time(X509_VERIFY_PARAM *param, time_t t);\nint X509_VERIFY_PARAM_add0_policy(X509_VERIFY_PARAM *param,\n                                  ASN1_OBJECT *policy);\nint X509_VERIFY_PARAM_set1_policies(X509_VERIFY_PARAM *param,\n                                    STACK_OF(ASN1_OBJECT) *policies);\n\nint X509_VERIFY_PARAM_set_inh_flags(X509_VERIFY_PARAM *param,\n                                    uint32_t flags);\nuint32_t X509_VERIFY_PARAM_get_inh_flags(const X509_VERIFY_PARAM *param);\n\nint X509_VERIFY_PARAM_set1_host(X509_VERIFY_PARAM *param,\n                                const char *name, size_t namelen);\nint X509_VERIFY_PARAM_add1_host(X509_VERIFY_PARAM *param,\n                                const char *name, size_t namelen);\nvoid X509_VERIFY_PARAM_set_hostflags(X509_VERIFY_PARAM *param,\n                                     unsigned int flags);\nunsigned int X509_VERIFY_PARAM_get_hostflags(const X509_VERIFY_PARAM *param);\nchar *X509_VERIFY_PARAM_get0_peername(X509_VERIFY_PARAM *);\nvoid X509_VERIFY_PARAM_move_peername(X509_VERIFY_PARAM *, X509_VERIFY_PARAM *);\nint X509_VERIFY_PARAM_set1_email(X509_VERIFY_PARAM *param,\n                                 const char *email, size_t emaillen);\nint X509_VERIFY_PARAM_set1_ip(X509_VERIFY_PARAM *param,\n                              const unsigned char *ip, size_t iplen);\nint X509_VERIFY_PARAM_set1_ip_asc(X509_VERIFY_PARAM *param,\n                                  const char *ipasc);\n\nint X509_VERIFY_PARAM_get_depth(const X509_VERIFY_PARAM *param);\nint X509_VERIFY_PARAM_get_auth_level(const X509_VERIFY_PARAM *param);\nconst char *X509_VERIFY_PARAM_get0_name(const X509_VERIFY_PARAM *param);\n\nint X509_VERIFY_PARAM_add0_table(X509_VERIFY_PARAM *param);\nint X509_VERIFY_PARAM_get_count(void);\nconst X509_VERIFY_PARAM *X509_VERIFY_PARAM_get0(int id);\nconst X509_VERIFY_PARAM *X509_VERIFY_PARAM_lookup(const char *name);\nvoid X509_VERIFY_PARAM_table_cleanup(void);\n\n/* Non positive return values are errors */\n#define X509_PCY_TREE_FAILURE  -2 /* Failure to satisfy explicit policy */\n#define X509_PCY_TREE_INVALID  -1 /* Inconsistent or invalid extensions */\n#define X509_PCY_TREE_INTERNAL  0 /* Internal error, most likely malloc */\n\n/*\n * Positive return values form a bit mask, all but the first are internal to\n * the library and don't appear in results from X509_policy_check().\n */\n#define X509_PCY_TREE_VALID     1 /* The policy tree is valid */\n#define X509_PCY_TREE_EMPTY     2 /* The policy tree is empty */\n#define X509_PCY_TREE_EXPLICIT  4 /* Explicit policy required */\n\nint X509_policy_check(X509_POLICY_TREE **ptree, int *pexplicit_policy,\n                      STACK_OF(X509) *certs,\n                      STACK_OF(ASN1_OBJECT) *policy_oids, unsigned int flags);\n\nvoid X509_policy_tree_free(X509_POLICY_TREE *tree);\n\nint X509_policy_tree_level_count(const X509_POLICY_TREE *tree);\nX509_POLICY_LEVEL *X509_policy_tree_get0_level(const X509_POLICY_TREE *tree,\n                                               int i);\n\nSTACK_OF(X509_POLICY_NODE) *X509_policy_tree_get0_policies(const\n                                                           X509_POLICY_TREE\n                                                           *tree);\n\nSTACK_OF(X509_POLICY_NODE) *X509_policy_tree_get0_user_policies(const\n                                                                X509_POLICY_TREE\n                                                                *tree);\n\nint X509_policy_level_node_count(X509_POLICY_LEVEL *level);\n\nX509_POLICY_NODE *X509_policy_level_get0_node(X509_POLICY_LEVEL *level,\n                                              int i);\n\nconst ASN1_OBJECT *X509_policy_node_get0_policy(const X509_POLICY_NODE *node);\n\nSTACK_OF(POLICYQUALINFO) *X509_policy_node_get0_qualifiers(const\n                                                           X509_POLICY_NODE\n                                                           *node);\nconst X509_POLICY_NODE *X509_policy_node_get0_parent(const X509_POLICY_NODE\n                                                     *node);\n\n#ifdef  __cplusplus\n}\n#endif\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/include/openssl/x509err.h",
    "content": "/*\n * Generated by util/mkerr.pl DO NOT EDIT\n * Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef HEADER_X509ERR_H\n# define HEADER_X509ERR_H\n\n# include <openssl/symhacks.h>\n\n# ifdef  __cplusplus\nextern \"C\"\n# endif\nint ERR_load_X509_strings(void);\n\n/*\n * X509 function codes.\n */\n# define X509_F_ADD_CERT_DIR                              100\n# define X509_F_BUILD_CHAIN                               106\n# define X509_F_BY_FILE_CTRL                              101\n# define X509_F_CHECK_NAME_CONSTRAINTS                    149\n# define X509_F_CHECK_POLICY                              145\n# define X509_F_DANE_I2D                                  107\n# define X509_F_DIR_CTRL                                  102\n# define X509_F_GET_CERT_BY_SUBJECT                       103\n# define X509_F_I2D_X509_AUX                              151\n# define X509_F_LOOKUP_CERTS_SK                           152\n# define X509_F_NETSCAPE_SPKI_B64_DECODE                  129\n# define X509_F_NETSCAPE_SPKI_B64_ENCODE                  130\n# define X509_F_NEW_DIR                                   153\n# define X509_F_X509AT_ADD1_ATTR                          135\n# define X509_F_X509V3_ADD_EXT                            104\n# define X509_F_X509_ATTRIBUTE_CREATE_BY_NID              136\n# define X509_F_X509_ATTRIBUTE_CREATE_BY_OBJ              137\n# define X509_F_X509_ATTRIBUTE_CREATE_BY_TXT              140\n# define X509_F_X509_ATTRIBUTE_GET0_DATA                  139\n# define X509_F_X509_ATTRIBUTE_SET1_DATA                  138\n# define X509_F_X509_CHECK_PRIVATE_KEY                    128\n# define X509_F_X509_CRL_DIFF                             105\n# define X509_F_X509_CRL_METHOD_NEW                       154\n# define X509_F_X509_CRL_PRINT_FP                         147\n# define X509_F_X509_EXTENSION_CREATE_BY_NID              108\n# define X509_F_X509_EXTENSION_CREATE_BY_OBJ              109\n# define X509_F_X509_GET_PUBKEY_PARAMETERS                110\n# define X509_F_X509_LOAD_CERT_CRL_FILE                   132\n# define X509_F_X509_LOAD_CERT_FILE                       111\n# define X509_F_X509_LOAD_CRL_FILE                        112\n# define X509_F_X509_LOOKUP_METH_NEW                      160\n# define X509_F_X509_LOOKUP_NEW                           155\n# define X509_F_X509_NAME_ADD_ENTRY                       113\n# define X509_F_X509_NAME_CANON                           156\n# define X509_F_X509_NAME_ENTRY_CREATE_BY_NID             114\n# define X509_F_X509_NAME_ENTRY_CREATE_BY_TXT             131\n# define X509_F_X509_NAME_ENTRY_SET_OBJECT                115\n# define X509_F_X509_NAME_ONELINE                         116\n# define X509_F_X509_NAME_PRINT                           117\n# define X509_F_X509_OBJECT_NEW                           150\n# define X509_F_X509_PRINT_EX_FP                          118\n# define X509_F_X509_PUBKEY_DECODE                        148\n# define X509_F_X509_PUBKEY_GET                           161\n# define X509_F_X509_PUBKEY_GET0                          119\n# define X509_F_X509_PUBKEY_SET                           120\n# define X509_F_X509_REQ_CHECK_PRIVATE_KEY                144\n# define X509_F_X509_REQ_PRINT_EX                         121\n# define X509_F_X509_REQ_PRINT_FP                         122\n# define X509_F_X509_REQ_TO_X509                          123\n# define X509_F_X509_STORE_ADD_CERT                       124\n# define X509_F_X509_STORE_ADD_CRL                        125\n# define X509_F_X509_STORE_ADD_LOOKUP                     157\n# define X509_F_X509_STORE_CTX_GET1_ISSUER                146\n# define X509_F_X509_STORE_CTX_INIT                       143\n# define X509_F_X509_STORE_CTX_NEW                        142\n# define X509_F_X509_STORE_CTX_PURPOSE_INHERIT            134\n# define X509_F_X509_STORE_NEW                            158\n# define X509_F_X509_TO_X509_REQ                          126\n# define X509_F_X509_TRUST_ADD                            133\n# define X509_F_X509_TRUST_SET                            141\n# define X509_F_X509_VERIFY_CERT                          127\n# define X509_F_X509_VERIFY_PARAM_NEW                     159\n\n/*\n * X509 reason codes.\n */\n# define X509_R_AKID_MISMATCH                             110\n# define X509_R_BAD_SELECTOR                              133\n# define X509_R_BAD_X509_FILETYPE                         100\n# define X509_R_BASE64_DECODE_ERROR                       118\n# define X509_R_CANT_CHECK_DH_KEY                         114\n# define X509_R_CERT_ALREADY_IN_HASH_TABLE                101\n# define X509_R_CRL_ALREADY_DELTA                         127\n# define X509_R_CRL_VERIFY_FAILURE                        131\n# define X509_R_IDP_MISMATCH                              128\n# define X509_R_INVALID_ATTRIBUTES                        138\n# define X509_R_INVALID_DIRECTORY                         113\n# define X509_R_INVALID_FIELD_NAME                        119\n# define X509_R_INVALID_TRUST                             123\n# define X509_R_ISSUER_MISMATCH                           129\n# define X509_R_KEY_TYPE_MISMATCH                         115\n# define X509_R_KEY_VALUES_MISMATCH                       116\n# define X509_R_LOADING_CERT_DIR                          103\n# define X509_R_LOADING_DEFAULTS                          104\n# define X509_R_METHOD_NOT_SUPPORTED                      124\n# define X509_R_NAME_TOO_LONG                             134\n# define X509_R_NEWER_CRL_NOT_NEWER                       132\n# define X509_R_NO_CERTIFICATE_FOUND                      135\n# define X509_R_NO_CERTIFICATE_OR_CRL_FOUND               136\n# define X509_R_NO_CERT_SET_FOR_US_TO_VERIFY              105\n# define X509_R_NO_CRL_FOUND                              137\n# define X509_R_NO_CRL_NUMBER                             130\n# define X509_R_PUBLIC_KEY_DECODE_ERROR                   125\n# define X509_R_PUBLIC_KEY_ENCODE_ERROR                   126\n# define X509_R_SHOULD_RETRY                              106\n# define X509_R_UNABLE_TO_FIND_PARAMETERS_IN_CHAIN        107\n# define X509_R_UNABLE_TO_GET_CERTS_PUBLIC_KEY            108\n# define X509_R_UNKNOWN_KEY_TYPE                          117\n# define X509_R_UNKNOWN_NID                               109\n# define X509_R_UNKNOWN_PURPOSE_ID                        121\n# define X509_R_UNKNOWN_TRUST_ID                          120\n# define X509_R_UNSUPPORTED_ALGORITHM                     111\n# define X509_R_WRONG_LOOKUP_TYPE                         112\n# define X509_R_WRONG_TYPE                                122\n\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/include/openssl/x509v3.h",
    "content": "/*\n * Copyright 1999-2021 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef HEADER_X509V3_H\n# define HEADER_X509V3_H\n\n# include <openssl/bio.h>\n# include <openssl/x509.h>\n# include <openssl/conf.h>\n# include <openssl/x509v3err.h>\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/* Forward reference */\nstruct v3_ext_method;\nstruct v3_ext_ctx;\n\n/* Useful typedefs */\n\ntypedef void *(*X509V3_EXT_NEW)(void);\ntypedef void (*X509V3_EXT_FREE) (void *);\ntypedef void *(*X509V3_EXT_D2I)(void *, const unsigned char **, long);\ntypedef int (*X509V3_EXT_I2D) (void *, unsigned char **);\ntypedef STACK_OF(CONF_VALUE) *\n    (*X509V3_EXT_I2V) (const struct v3_ext_method *method, void *ext,\n                       STACK_OF(CONF_VALUE) *extlist);\ntypedef void *(*X509V3_EXT_V2I)(const struct v3_ext_method *method,\n                                struct v3_ext_ctx *ctx,\n                                STACK_OF(CONF_VALUE) *values);\ntypedef char *(*X509V3_EXT_I2S)(const struct v3_ext_method *method,\n                                void *ext);\ntypedef void *(*X509V3_EXT_S2I)(const struct v3_ext_method *method,\n                                struct v3_ext_ctx *ctx, const char *str);\ntypedef int (*X509V3_EXT_I2R) (const struct v3_ext_method *method, void *ext,\n                               BIO *out, int indent);\ntypedef void *(*X509V3_EXT_R2I)(const struct v3_ext_method *method,\n                                struct v3_ext_ctx *ctx, const char *str);\n\n/* V3 extension structure */\n\nstruct v3_ext_method {\n    int ext_nid;\n    int ext_flags;\n/* If this is set the following four fields are ignored */\n    ASN1_ITEM_EXP *it;\n/* Old style ASN1 calls */\n    X509V3_EXT_NEW ext_new;\n    X509V3_EXT_FREE ext_free;\n    X509V3_EXT_D2I d2i;\n    X509V3_EXT_I2D i2d;\n/* The following pair is used for string extensions */\n    X509V3_EXT_I2S i2s;\n    X509V3_EXT_S2I s2i;\n/* The following pair is used for multi-valued extensions */\n    X509V3_EXT_I2V i2v;\n    X509V3_EXT_V2I v2i;\n/* The following are used for raw extensions */\n    X509V3_EXT_I2R i2r;\n    X509V3_EXT_R2I r2i;\n    void *usr_data;             /* Any extension specific data */\n};\n\ntypedef struct X509V3_CONF_METHOD_st {\n    char *(*get_string) (void *db, const char *section, const char *value);\n    STACK_OF(CONF_VALUE) *(*get_section) (void *db, const char *section);\n    void (*free_string) (void *db, char *string);\n    void (*free_section) (void *db, STACK_OF(CONF_VALUE) *section);\n} X509V3_CONF_METHOD;\n\n/* Context specific info */\nstruct v3_ext_ctx {\n# define CTX_TEST 0x1\n# define X509V3_CTX_REPLACE 0x2\n    int flags;\n    X509 *issuer_cert;\n    X509 *subject_cert;\n    X509_REQ *subject_req;\n    X509_CRL *crl;\n    X509V3_CONF_METHOD *db_meth;\n    void *db;\n/* Maybe more here */\n};\n\ntypedef struct v3_ext_method X509V3_EXT_METHOD;\n\nDEFINE_STACK_OF(X509V3_EXT_METHOD)\n\n/* ext_flags values */\n# define X509V3_EXT_DYNAMIC      0x1\n# define X509V3_EXT_CTX_DEP      0x2\n# define X509V3_EXT_MULTILINE    0x4\n\ntypedef BIT_STRING_BITNAME ENUMERATED_NAMES;\n\ntypedef struct BASIC_CONSTRAINTS_st {\n    int ca;\n    ASN1_INTEGER *pathlen;\n} BASIC_CONSTRAINTS;\n\ntypedef struct PKEY_USAGE_PERIOD_st {\n    ASN1_GENERALIZEDTIME *notBefore;\n    ASN1_GENERALIZEDTIME *notAfter;\n} PKEY_USAGE_PERIOD;\n\ntypedef struct otherName_st {\n    ASN1_OBJECT *type_id;\n    ASN1_TYPE *value;\n} OTHERNAME;\n\ntypedef struct EDIPartyName_st {\n    ASN1_STRING *nameAssigner;\n    ASN1_STRING *partyName;\n} EDIPARTYNAME;\n\ntypedef struct GENERAL_NAME_st {\n# define GEN_OTHERNAME   0\n# define GEN_EMAIL       1\n# define GEN_DNS         2\n# define GEN_X400        3\n# define GEN_DIRNAME     4\n# define GEN_EDIPARTY    5\n# define GEN_URI         6\n# define GEN_IPADD       7\n# define GEN_RID         8\n    int type;\n    union {\n        char *ptr;\n        OTHERNAME *otherName;   /* otherName */\n        ASN1_IA5STRING *rfc822Name;\n        ASN1_IA5STRING *dNSName;\n        ASN1_TYPE *x400Address;\n        X509_NAME *directoryName;\n        EDIPARTYNAME *ediPartyName;\n        ASN1_IA5STRING *uniformResourceIdentifier;\n        ASN1_OCTET_STRING *iPAddress;\n        ASN1_OBJECT *registeredID;\n        /* Old names */\n        ASN1_OCTET_STRING *ip;  /* iPAddress */\n        X509_NAME *dirn;        /* dirn */\n        ASN1_IA5STRING *ia5;    /* rfc822Name, dNSName,\n                                 * uniformResourceIdentifier */\n        ASN1_OBJECT *rid;       /* registeredID */\n        ASN1_TYPE *other;       /* x400Address */\n    } d;\n} GENERAL_NAME;\n\ntypedef struct ACCESS_DESCRIPTION_st {\n    ASN1_OBJECT *method;\n    GENERAL_NAME *location;\n} ACCESS_DESCRIPTION;\n\ntypedef STACK_OF(ACCESS_DESCRIPTION) AUTHORITY_INFO_ACCESS;\n\ntypedef STACK_OF(ASN1_OBJECT) EXTENDED_KEY_USAGE;\n\ntypedef STACK_OF(ASN1_INTEGER) TLS_FEATURE;\n\nDEFINE_STACK_OF(GENERAL_NAME)\ntypedef STACK_OF(GENERAL_NAME) GENERAL_NAMES;\nDEFINE_STACK_OF(GENERAL_NAMES)\n\nDEFINE_STACK_OF(ACCESS_DESCRIPTION)\n\ntypedef struct DIST_POINT_NAME_st {\n    int type;\n    union {\n        GENERAL_NAMES *fullname;\n        STACK_OF(X509_NAME_ENTRY) *relativename;\n    } name;\n/* If relativename then this contains the full distribution point name */\n    X509_NAME *dpname;\n} DIST_POINT_NAME;\n/* All existing reasons */\n# define CRLDP_ALL_REASONS       0x807f\n\n# define CRL_REASON_NONE                         -1\n# define CRL_REASON_UNSPECIFIED                  0\n# define CRL_REASON_KEY_COMPROMISE               1\n# define CRL_REASON_CA_COMPROMISE                2\n# define CRL_REASON_AFFILIATION_CHANGED          3\n# define CRL_REASON_SUPERSEDED                   4\n# define CRL_REASON_CESSATION_OF_OPERATION       5\n# define CRL_REASON_CERTIFICATE_HOLD             6\n# define CRL_REASON_REMOVE_FROM_CRL              8\n# define CRL_REASON_PRIVILEGE_WITHDRAWN          9\n# define CRL_REASON_AA_COMPROMISE                10\n\nstruct DIST_POINT_st {\n    DIST_POINT_NAME *distpoint;\n    ASN1_BIT_STRING *reasons;\n    GENERAL_NAMES *CRLissuer;\n    int dp_reasons;\n};\n\ntypedef STACK_OF(DIST_POINT) CRL_DIST_POINTS;\n\nDEFINE_STACK_OF(DIST_POINT)\n\nstruct AUTHORITY_KEYID_st {\n    ASN1_OCTET_STRING *keyid;\n    GENERAL_NAMES *issuer;\n    ASN1_INTEGER *serial;\n};\n\n/* Strong extranet structures */\n\ntypedef struct SXNET_ID_st {\n    ASN1_INTEGER *zone;\n    ASN1_OCTET_STRING *user;\n} SXNETID;\n\nDEFINE_STACK_OF(SXNETID)\n\ntypedef struct SXNET_st {\n    ASN1_INTEGER *version;\n    STACK_OF(SXNETID) *ids;\n} SXNET;\n\ntypedef struct NOTICEREF_st {\n    ASN1_STRING *organization;\n    STACK_OF(ASN1_INTEGER) *noticenos;\n} NOTICEREF;\n\ntypedef struct USERNOTICE_st {\n    NOTICEREF *noticeref;\n    ASN1_STRING *exptext;\n} USERNOTICE;\n\ntypedef struct POLICYQUALINFO_st {\n    ASN1_OBJECT *pqualid;\n    union {\n        ASN1_IA5STRING *cpsuri;\n        USERNOTICE *usernotice;\n        ASN1_TYPE *other;\n    } d;\n} POLICYQUALINFO;\n\nDEFINE_STACK_OF(POLICYQUALINFO)\n\ntypedef struct POLICYINFO_st {\n    ASN1_OBJECT *policyid;\n    STACK_OF(POLICYQUALINFO) *qualifiers;\n} POLICYINFO;\n\ntypedef STACK_OF(POLICYINFO) CERTIFICATEPOLICIES;\n\nDEFINE_STACK_OF(POLICYINFO)\n\ntypedef struct POLICY_MAPPING_st {\n    ASN1_OBJECT *issuerDomainPolicy;\n    ASN1_OBJECT *subjectDomainPolicy;\n} POLICY_MAPPING;\n\nDEFINE_STACK_OF(POLICY_MAPPING)\n\ntypedef STACK_OF(POLICY_MAPPING) POLICY_MAPPINGS;\n\ntypedef struct GENERAL_SUBTREE_st {\n    GENERAL_NAME *base;\n    ASN1_INTEGER *minimum;\n    ASN1_INTEGER *maximum;\n} GENERAL_SUBTREE;\n\nDEFINE_STACK_OF(GENERAL_SUBTREE)\n\nstruct NAME_CONSTRAINTS_st {\n    STACK_OF(GENERAL_SUBTREE) *permittedSubtrees;\n    STACK_OF(GENERAL_SUBTREE) *excludedSubtrees;\n};\n\ntypedef struct POLICY_CONSTRAINTS_st {\n    ASN1_INTEGER *requireExplicitPolicy;\n    ASN1_INTEGER *inhibitPolicyMapping;\n} POLICY_CONSTRAINTS;\n\n/* Proxy certificate structures, see RFC 3820 */\ntypedef struct PROXY_POLICY_st {\n    ASN1_OBJECT *policyLanguage;\n    ASN1_OCTET_STRING *policy;\n} PROXY_POLICY;\n\ntypedef struct PROXY_CERT_INFO_EXTENSION_st {\n    ASN1_INTEGER *pcPathLengthConstraint;\n    PROXY_POLICY *proxyPolicy;\n} PROXY_CERT_INFO_EXTENSION;\n\nDECLARE_ASN1_FUNCTIONS(PROXY_POLICY)\nDECLARE_ASN1_FUNCTIONS(PROXY_CERT_INFO_EXTENSION)\n\nstruct ISSUING_DIST_POINT_st {\n    DIST_POINT_NAME *distpoint;\n    int onlyuser;\n    int onlyCA;\n    ASN1_BIT_STRING *onlysomereasons;\n    int indirectCRL;\n    int onlyattr;\n};\n\n/* Values in idp_flags field */\n/* IDP present */\n# define IDP_PRESENT     0x1\n/* IDP values inconsistent */\n# define IDP_INVALID     0x2\n/* onlyuser true */\n# define IDP_ONLYUSER    0x4\n/* onlyCA true */\n# define IDP_ONLYCA      0x8\n/* onlyattr true */\n# define IDP_ONLYATTR    0x10\n/* indirectCRL true */\n# define IDP_INDIRECT    0x20\n/* onlysomereasons present */\n# define IDP_REASONS     0x40\n\n# define X509V3_conf_err(val) ERR_add_error_data(6, \\\n                        \"section:\", (val)->section, \\\n                        \",name:\", (val)->name, \",value:\", (val)->value)\n\n# define X509V3_set_ctx_test(ctx) \\\n                        X509V3_set_ctx(ctx, NULL, NULL, NULL, NULL, CTX_TEST)\n# define X509V3_set_ctx_nodb(ctx) (ctx)->db = NULL;\n\n# define EXT_BITSTRING(nid, table) { nid, 0, ASN1_ITEM_ref(ASN1_BIT_STRING), \\\n                        0,0,0,0, \\\n                        0,0, \\\n                        (X509V3_EXT_I2V)i2v_ASN1_BIT_STRING, \\\n                        (X509V3_EXT_V2I)v2i_ASN1_BIT_STRING, \\\n                        NULL, NULL, \\\n                        table}\n\n# define EXT_IA5STRING(nid) { nid, 0, ASN1_ITEM_ref(ASN1_IA5STRING), \\\n                        0,0,0,0, \\\n                        (X509V3_EXT_I2S)i2s_ASN1_IA5STRING, \\\n                        (X509V3_EXT_S2I)s2i_ASN1_IA5STRING, \\\n                        0,0,0,0, \\\n                        NULL}\n\n# define EXT_END { -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}\n\n/* X509_PURPOSE stuff */\n\n# define EXFLAG_BCONS            0x1\n# define EXFLAG_KUSAGE           0x2\n# define EXFLAG_XKUSAGE          0x4\n# define EXFLAG_NSCERT           0x8\n\n# define EXFLAG_CA               0x10\n/* Really self issued not necessarily self signed */\n# define EXFLAG_SI               0x20\n# define EXFLAG_V1               0x40\n# define EXFLAG_INVALID          0x80\n/* EXFLAG_SET is set to indicate that some values have been precomputed */\n# define EXFLAG_SET              0x100\n# define EXFLAG_CRITICAL         0x200\n# define EXFLAG_PROXY            0x400\n\n# define EXFLAG_INVALID_POLICY   0x800\n# define EXFLAG_FRESHEST         0x1000\n# define EXFLAG_SS               0x2000 /* cert is apparently self-signed */\n\n# define EXFLAG_NO_FINGERPRINT   0x100000\n\n# define KU_DIGITAL_SIGNATURE    0x0080\n# define KU_NON_REPUDIATION      0x0040\n# define KU_KEY_ENCIPHERMENT     0x0020\n# define KU_DATA_ENCIPHERMENT    0x0010\n# define KU_KEY_AGREEMENT        0x0008\n# define KU_KEY_CERT_SIGN        0x0004\n# define KU_CRL_SIGN             0x0002\n# define KU_ENCIPHER_ONLY        0x0001\n# define KU_DECIPHER_ONLY        0x8000\n\n# define NS_SSL_CLIENT           0x80\n# define NS_SSL_SERVER           0x40\n# define NS_SMIME                0x20\n# define NS_OBJSIGN              0x10\n# define NS_SSL_CA               0x04\n# define NS_SMIME_CA             0x02\n# define NS_OBJSIGN_CA           0x01\n# define NS_ANY_CA               (NS_SSL_CA|NS_SMIME_CA|NS_OBJSIGN_CA)\n\n# define XKU_SSL_SERVER          0x1\n# define XKU_SSL_CLIENT          0x2\n# define XKU_SMIME               0x4\n# define XKU_CODE_SIGN           0x8\n# define XKU_SGC                 0x10\n# define XKU_OCSP_SIGN           0x20\n# define XKU_TIMESTAMP           0x40\n# define XKU_DVCS                0x80\n# define XKU_ANYEKU              0x100\n\n# define X509_PURPOSE_DYNAMIC    0x1\n# define X509_PURPOSE_DYNAMIC_NAME       0x2\n\ntypedef struct x509_purpose_st {\n    int purpose;\n    int trust;                  /* Default trust ID */\n    int flags;\n    int (*check_purpose) (const struct x509_purpose_st *, const X509 *, int);\n    char *name;\n    char *sname;\n    void *usr_data;\n} X509_PURPOSE;\n\n# define X509_PURPOSE_SSL_CLIENT         1\n# define X509_PURPOSE_SSL_SERVER         2\n# define X509_PURPOSE_NS_SSL_SERVER      3\n# define X509_PURPOSE_SMIME_SIGN         4\n# define X509_PURPOSE_SMIME_ENCRYPT      5\n# define X509_PURPOSE_CRL_SIGN           6\n# define X509_PURPOSE_ANY                7\n# define X509_PURPOSE_OCSP_HELPER        8\n# define X509_PURPOSE_TIMESTAMP_SIGN     9\n\n# define X509_PURPOSE_MIN                1\n# define X509_PURPOSE_MAX                9\n\n/* Flags for X509V3_EXT_print() */\n\n# define X509V3_EXT_UNKNOWN_MASK         (0xfL << 16)\n/* Return error for unknown extensions */\n# define X509V3_EXT_DEFAULT              0\n/* Print error for unknown extensions */\n# define X509V3_EXT_ERROR_UNKNOWN        (1L << 16)\n/* ASN1 parse unknown extensions */\n# define X509V3_EXT_PARSE_UNKNOWN        (2L << 16)\n/* BIO_dump unknown extensions */\n# define X509V3_EXT_DUMP_UNKNOWN         (3L << 16)\n\n/* Flags for X509V3_add1_i2d */\n\n# define X509V3_ADD_OP_MASK              0xfL\n# define X509V3_ADD_DEFAULT              0L\n# define X509V3_ADD_APPEND               1L\n# define X509V3_ADD_REPLACE              2L\n# define X509V3_ADD_REPLACE_EXISTING     3L\n# define X509V3_ADD_KEEP_EXISTING        4L\n# define X509V3_ADD_DELETE               5L\n# define X509V3_ADD_SILENT               0x10\n\nDEFINE_STACK_OF(X509_PURPOSE)\n\nDECLARE_ASN1_FUNCTIONS(BASIC_CONSTRAINTS)\n\nDECLARE_ASN1_FUNCTIONS(SXNET)\nDECLARE_ASN1_FUNCTIONS(SXNETID)\n\nint SXNET_add_id_asc(SXNET **psx, const char *zone, const char *user, int userlen);\nint SXNET_add_id_ulong(SXNET **psx, unsigned long lzone, const char *user,\n                       int userlen);\nint SXNET_add_id_INTEGER(SXNET **psx, ASN1_INTEGER *izone, const char *user,\n                         int userlen);\n\nASN1_OCTET_STRING *SXNET_get_id_asc(SXNET *sx, const char *zone);\nASN1_OCTET_STRING *SXNET_get_id_ulong(SXNET *sx, unsigned long lzone);\nASN1_OCTET_STRING *SXNET_get_id_INTEGER(SXNET *sx, ASN1_INTEGER *zone);\n\nDECLARE_ASN1_FUNCTIONS(AUTHORITY_KEYID)\n\nDECLARE_ASN1_FUNCTIONS(PKEY_USAGE_PERIOD)\n\nDECLARE_ASN1_FUNCTIONS(GENERAL_NAME)\nGENERAL_NAME *GENERAL_NAME_dup(GENERAL_NAME *a);\nint GENERAL_NAME_cmp(GENERAL_NAME *a, GENERAL_NAME *b);\n\nASN1_BIT_STRING *v2i_ASN1_BIT_STRING(X509V3_EXT_METHOD *method,\n                                     X509V3_CTX *ctx,\n                                     STACK_OF(CONF_VALUE) *nval);\nSTACK_OF(CONF_VALUE) *i2v_ASN1_BIT_STRING(X509V3_EXT_METHOD *method,\n                                          ASN1_BIT_STRING *bits,\n                                          STACK_OF(CONF_VALUE) *extlist);\nchar *i2s_ASN1_IA5STRING(X509V3_EXT_METHOD *method, ASN1_IA5STRING *ia5);\nASN1_IA5STRING *s2i_ASN1_IA5STRING(X509V3_EXT_METHOD *method,\n                                   X509V3_CTX *ctx, const char *str);\n\nSTACK_OF(CONF_VALUE) *i2v_GENERAL_NAME(X509V3_EXT_METHOD *method,\n                                       GENERAL_NAME *gen,\n                                       STACK_OF(CONF_VALUE) *ret);\nint GENERAL_NAME_print(BIO *out, GENERAL_NAME *gen);\n\nDECLARE_ASN1_FUNCTIONS(GENERAL_NAMES)\n\nSTACK_OF(CONF_VALUE) *i2v_GENERAL_NAMES(X509V3_EXT_METHOD *method,\n                                        GENERAL_NAMES *gen,\n                                        STACK_OF(CONF_VALUE) *extlist);\nGENERAL_NAMES *v2i_GENERAL_NAMES(const X509V3_EXT_METHOD *method,\n                                 X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *nval);\n\nDECLARE_ASN1_FUNCTIONS(OTHERNAME)\nDECLARE_ASN1_FUNCTIONS(EDIPARTYNAME)\nint OTHERNAME_cmp(OTHERNAME *a, OTHERNAME *b);\nvoid GENERAL_NAME_set0_value(GENERAL_NAME *a, int type, void *value);\nvoid *GENERAL_NAME_get0_value(const GENERAL_NAME *a, int *ptype);\nint GENERAL_NAME_set0_othername(GENERAL_NAME *gen,\n                                ASN1_OBJECT *oid, ASN1_TYPE *value);\nint GENERAL_NAME_get0_otherName(const GENERAL_NAME *gen,\n                                ASN1_OBJECT **poid, ASN1_TYPE **pvalue);\n\nchar *i2s_ASN1_OCTET_STRING(X509V3_EXT_METHOD *method,\n                            const ASN1_OCTET_STRING *ia5);\nASN1_OCTET_STRING *s2i_ASN1_OCTET_STRING(X509V3_EXT_METHOD *method,\n                                         X509V3_CTX *ctx, const char *str);\n\nDECLARE_ASN1_FUNCTIONS(EXTENDED_KEY_USAGE)\nint i2a_ACCESS_DESCRIPTION(BIO *bp, const ACCESS_DESCRIPTION *a);\n\nDECLARE_ASN1_ALLOC_FUNCTIONS(TLS_FEATURE)\n\nDECLARE_ASN1_FUNCTIONS(CERTIFICATEPOLICIES)\nDECLARE_ASN1_FUNCTIONS(POLICYINFO)\nDECLARE_ASN1_FUNCTIONS(POLICYQUALINFO)\nDECLARE_ASN1_FUNCTIONS(USERNOTICE)\nDECLARE_ASN1_FUNCTIONS(NOTICEREF)\n\nDECLARE_ASN1_FUNCTIONS(CRL_DIST_POINTS)\nDECLARE_ASN1_FUNCTIONS(DIST_POINT)\nDECLARE_ASN1_FUNCTIONS(DIST_POINT_NAME)\nDECLARE_ASN1_FUNCTIONS(ISSUING_DIST_POINT)\n\nint DIST_POINT_set_dpname(DIST_POINT_NAME *dpn, X509_NAME *iname);\n\nint NAME_CONSTRAINTS_check(X509 *x, NAME_CONSTRAINTS *nc);\nint NAME_CONSTRAINTS_check_CN(X509 *x, NAME_CONSTRAINTS *nc);\n\nDECLARE_ASN1_FUNCTIONS(ACCESS_DESCRIPTION)\nDECLARE_ASN1_FUNCTIONS(AUTHORITY_INFO_ACCESS)\n\nDECLARE_ASN1_ITEM(POLICY_MAPPING)\nDECLARE_ASN1_ALLOC_FUNCTIONS(POLICY_MAPPING)\nDECLARE_ASN1_ITEM(POLICY_MAPPINGS)\n\nDECLARE_ASN1_ITEM(GENERAL_SUBTREE)\nDECLARE_ASN1_ALLOC_FUNCTIONS(GENERAL_SUBTREE)\n\nDECLARE_ASN1_ITEM(NAME_CONSTRAINTS)\nDECLARE_ASN1_ALLOC_FUNCTIONS(NAME_CONSTRAINTS)\n\nDECLARE_ASN1_ALLOC_FUNCTIONS(POLICY_CONSTRAINTS)\nDECLARE_ASN1_ITEM(POLICY_CONSTRAINTS)\n\nGENERAL_NAME *a2i_GENERAL_NAME(GENERAL_NAME *out,\n                               const X509V3_EXT_METHOD *method,\n                               X509V3_CTX *ctx, int gen_type,\n                               const char *value, int is_nc);\n\n# ifdef HEADER_CONF_H\nGENERAL_NAME *v2i_GENERAL_NAME(const X509V3_EXT_METHOD *method,\n                               X509V3_CTX *ctx, CONF_VALUE *cnf);\nGENERAL_NAME *v2i_GENERAL_NAME_ex(GENERAL_NAME *out,\n                                  const X509V3_EXT_METHOD *method,\n                                  X509V3_CTX *ctx, CONF_VALUE *cnf,\n                                  int is_nc);\nvoid X509V3_conf_free(CONF_VALUE *val);\n\nX509_EXTENSION *X509V3_EXT_nconf_nid(CONF *conf, X509V3_CTX *ctx, int ext_nid,\n                                     const char *value);\nX509_EXTENSION *X509V3_EXT_nconf(CONF *conf, X509V3_CTX *ctx, const char *name,\n                                 const char *value);\nint X509V3_EXT_add_nconf_sk(CONF *conf, X509V3_CTX *ctx, const char *section,\n                            STACK_OF(X509_EXTENSION) **sk);\nint X509V3_EXT_add_nconf(CONF *conf, X509V3_CTX *ctx, const char *section,\n                         X509 *cert);\nint X509V3_EXT_REQ_add_nconf(CONF *conf, X509V3_CTX *ctx, const char *section,\n                             X509_REQ *req);\nint X509V3_EXT_CRL_add_nconf(CONF *conf, X509V3_CTX *ctx, const char *section,\n                             X509_CRL *crl);\n\nX509_EXTENSION *X509V3_EXT_conf_nid(LHASH_OF(CONF_VALUE) *conf,\n                                    X509V3_CTX *ctx, int ext_nid,\n                                    const char *value);\nX509_EXTENSION *X509V3_EXT_conf(LHASH_OF(CONF_VALUE) *conf, X509V3_CTX *ctx,\n                                const char *name, const char *value);\nint X509V3_EXT_add_conf(LHASH_OF(CONF_VALUE) *conf, X509V3_CTX *ctx,\n                        const char *section, X509 *cert);\nint X509V3_EXT_REQ_add_conf(LHASH_OF(CONF_VALUE) *conf, X509V3_CTX *ctx,\n                            const char *section, X509_REQ *req);\nint X509V3_EXT_CRL_add_conf(LHASH_OF(CONF_VALUE) *conf, X509V3_CTX *ctx,\n                            const char *section, X509_CRL *crl);\n\nint X509V3_add_value_bool_nf(const char *name, int asn1_bool,\n                             STACK_OF(CONF_VALUE) **extlist);\nint X509V3_get_value_bool(const CONF_VALUE *value, int *asn1_bool);\nint X509V3_get_value_int(const CONF_VALUE *value, ASN1_INTEGER **aint);\nvoid X509V3_set_nconf(X509V3_CTX *ctx, CONF *conf);\nvoid X509V3_set_conf_lhash(X509V3_CTX *ctx, LHASH_OF(CONF_VALUE) *lhash);\n# endif\n\nchar *X509V3_get_string(X509V3_CTX *ctx, const char *name, const char *section);\nSTACK_OF(CONF_VALUE) *X509V3_get_section(X509V3_CTX *ctx, const char *section);\nvoid X509V3_string_free(X509V3_CTX *ctx, char *str);\nvoid X509V3_section_free(X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *section);\nvoid X509V3_set_ctx(X509V3_CTX *ctx, X509 *issuer, X509 *subject,\n                    X509_REQ *req, X509_CRL *crl, int flags);\n\nint X509V3_add_value(const char *name, const char *value,\n                     STACK_OF(CONF_VALUE) **extlist);\nint X509V3_add_value_uchar(const char *name, const unsigned char *value,\n                           STACK_OF(CONF_VALUE) **extlist);\nint X509V3_add_value_bool(const char *name, int asn1_bool,\n                          STACK_OF(CONF_VALUE) **extlist);\nint X509V3_add_value_int(const char *name, const ASN1_INTEGER *aint,\n                         STACK_OF(CONF_VALUE) **extlist);\nchar *i2s_ASN1_INTEGER(X509V3_EXT_METHOD *meth, const ASN1_INTEGER *aint);\nASN1_INTEGER *s2i_ASN1_INTEGER(X509V3_EXT_METHOD *meth, const char *value);\nchar *i2s_ASN1_ENUMERATED(X509V3_EXT_METHOD *meth, const ASN1_ENUMERATED *aint);\nchar *i2s_ASN1_ENUMERATED_TABLE(X509V3_EXT_METHOD *meth,\n                                const ASN1_ENUMERATED *aint);\nint X509V3_EXT_add(X509V3_EXT_METHOD *ext);\nint X509V3_EXT_add_list(X509V3_EXT_METHOD *extlist);\nint X509V3_EXT_add_alias(int nid_to, int nid_from);\nvoid X509V3_EXT_cleanup(void);\n\nconst X509V3_EXT_METHOD *X509V3_EXT_get(X509_EXTENSION *ext);\nconst X509V3_EXT_METHOD *X509V3_EXT_get_nid(int nid);\nint X509V3_add_standard_extensions(void);\nSTACK_OF(CONF_VALUE) *X509V3_parse_list(const char *line);\nvoid *X509V3_EXT_d2i(X509_EXTENSION *ext);\nvoid *X509V3_get_d2i(const STACK_OF(X509_EXTENSION) *x, int nid, int *crit,\n                     int *idx);\n\nX509_EXTENSION *X509V3_EXT_i2d(int ext_nid, int crit, void *ext_struc);\nint X509V3_add1_i2d(STACK_OF(X509_EXTENSION) **x, int nid, void *value,\n                    int crit, unsigned long flags);\n\n#if OPENSSL_API_COMPAT < 0x10100000L\n/* The new declarations are in crypto.h, but the old ones were here. */\n# define hex_to_string OPENSSL_buf2hexstr\n# define string_to_hex OPENSSL_hexstr2buf\n#endif\n\nvoid X509V3_EXT_val_prn(BIO *out, STACK_OF(CONF_VALUE) *val, int indent,\n                        int ml);\nint X509V3_EXT_print(BIO *out, X509_EXTENSION *ext, unsigned long flag,\n                     int indent);\n#ifndef OPENSSL_NO_STDIO\nint X509V3_EXT_print_fp(FILE *out, X509_EXTENSION *ext, int flag, int indent);\n#endif\nint X509V3_extensions_print(BIO *out, const char *title,\n                            const STACK_OF(X509_EXTENSION) *exts,\n                            unsigned long flag, int indent);\n\nint X509_check_ca(X509 *x);\nint X509_check_purpose(X509 *x, int id, int ca);\nint X509_supported_extension(X509_EXTENSION *ex);\nint X509_PURPOSE_set(int *p, int purpose);\nint X509_check_issued(X509 *issuer, X509 *subject);\nint X509_check_akid(X509 *issuer, AUTHORITY_KEYID *akid);\nvoid X509_set_proxy_flag(X509 *x);\nvoid X509_set_proxy_pathlen(X509 *x, long l);\nlong X509_get_proxy_pathlen(X509 *x);\n\nuint32_t X509_get_extension_flags(X509 *x);\nuint32_t X509_get_key_usage(X509 *x);\nuint32_t X509_get_extended_key_usage(X509 *x);\nconst ASN1_OCTET_STRING *X509_get0_subject_key_id(X509 *x);\nconst ASN1_OCTET_STRING *X509_get0_authority_key_id(X509 *x);\nconst GENERAL_NAMES *X509_get0_authority_issuer(X509 *x);\nconst ASN1_INTEGER *X509_get0_authority_serial(X509 *x);\n\nint X509_PURPOSE_get_count(void);\nX509_PURPOSE *X509_PURPOSE_get0(int idx);\nint X509_PURPOSE_get_by_sname(const char *sname);\nint X509_PURPOSE_get_by_id(int id);\nint X509_PURPOSE_add(int id, int trust, int flags,\n                     int (*ck) (const X509_PURPOSE *, const X509 *, int),\n                     const char *name, const char *sname, void *arg);\nchar *X509_PURPOSE_get0_name(const X509_PURPOSE *xp);\nchar *X509_PURPOSE_get0_sname(const X509_PURPOSE *xp);\nint X509_PURPOSE_get_trust(const X509_PURPOSE *xp);\nvoid X509_PURPOSE_cleanup(void);\nint X509_PURPOSE_get_id(const X509_PURPOSE *);\n\nSTACK_OF(OPENSSL_STRING) *X509_get1_email(X509 *x);\nSTACK_OF(OPENSSL_STRING) *X509_REQ_get1_email(X509_REQ *x);\nvoid X509_email_free(STACK_OF(OPENSSL_STRING) *sk);\nSTACK_OF(OPENSSL_STRING) *X509_get1_ocsp(X509 *x);\n/* Flags for X509_check_* functions */\n\n/*\n * Always check subject name for host match even if subject alt names present\n */\n# define X509_CHECK_FLAG_ALWAYS_CHECK_SUBJECT    0x1\n/* Disable wildcard matching for dnsName fields and common name. */\n# define X509_CHECK_FLAG_NO_WILDCARDS    0x2\n/* Wildcards must not match a partial label. */\n# define X509_CHECK_FLAG_NO_PARTIAL_WILDCARDS 0x4\n/* Allow (non-partial) wildcards to match multiple labels. */\n# define X509_CHECK_FLAG_MULTI_LABEL_WILDCARDS 0x8\n/* Constraint verifier subdomain patterns to match a single labels. */\n# define X509_CHECK_FLAG_SINGLE_LABEL_SUBDOMAINS 0x10\n/* Never check the subject CN */\n# define X509_CHECK_FLAG_NEVER_CHECK_SUBJECT    0x20\n/*\n * Match reference identifiers starting with \".\" to any sub-domain.\n * This is a non-public flag, turned on implicitly when the subject\n * reference identity is a DNS name.\n */\n# define _X509_CHECK_FLAG_DOT_SUBDOMAINS 0x8000\n\nint X509_check_host(X509 *x, const char *chk, size_t chklen,\n                    unsigned int flags, char **peername);\nint X509_check_email(X509 *x, const char *chk, size_t chklen,\n                     unsigned int flags);\nint X509_check_ip(X509 *x, const unsigned char *chk, size_t chklen,\n                  unsigned int flags);\nint X509_check_ip_asc(X509 *x, const char *ipasc, unsigned int flags);\n\nASN1_OCTET_STRING *a2i_IPADDRESS(const char *ipasc);\nASN1_OCTET_STRING *a2i_IPADDRESS_NC(const char *ipasc);\nint X509V3_NAME_from_section(X509_NAME *nm, STACK_OF(CONF_VALUE) *dn_sk,\n                             unsigned long chtype);\n\nvoid X509_POLICY_NODE_print(BIO *out, X509_POLICY_NODE *node, int indent);\nDEFINE_STACK_OF(X509_POLICY_NODE)\n\n#ifndef OPENSSL_NO_RFC3779\ntypedef struct ASRange_st {\n    ASN1_INTEGER *min, *max;\n} ASRange;\n\n# define ASIdOrRange_id          0\n# define ASIdOrRange_range       1\n\ntypedef struct ASIdOrRange_st {\n    int type;\n    union {\n        ASN1_INTEGER *id;\n        ASRange *range;\n    } u;\n} ASIdOrRange;\n\ntypedef STACK_OF(ASIdOrRange) ASIdOrRanges;\nDEFINE_STACK_OF(ASIdOrRange)\n\n# define ASIdentifierChoice_inherit              0\n# define ASIdentifierChoice_asIdsOrRanges        1\n\ntypedef struct ASIdentifierChoice_st {\n    int type;\n    union {\n        ASN1_NULL *inherit;\n        ASIdOrRanges *asIdsOrRanges;\n    } u;\n} ASIdentifierChoice;\n\ntypedef struct ASIdentifiers_st {\n    ASIdentifierChoice *asnum, *rdi;\n} ASIdentifiers;\n\nDECLARE_ASN1_FUNCTIONS(ASRange)\nDECLARE_ASN1_FUNCTIONS(ASIdOrRange)\nDECLARE_ASN1_FUNCTIONS(ASIdentifierChoice)\nDECLARE_ASN1_FUNCTIONS(ASIdentifiers)\n\ntypedef struct IPAddressRange_st {\n    ASN1_BIT_STRING *min, *max;\n} IPAddressRange;\n\n# define IPAddressOrRange_addressPrefix  0\n# define IPAddressOrRange_addressRange   1\n\ntypedef struct IPAddressOrRange_st {\n    int type;\n    union {\n        ASN1_BIT_STRING *addressPrefix;\n        IPAddressRange *addressRange;\n    } u;\n} IPAddressOrRange;\n\ntypedef STACK_OF(IPAddressOrRange) IPAddressOrRanges;\nDEFINE_STACK_OF(IPAddressOrRange)\n\n# define IPAddressChoice_inherit                 0\n# define IPAddressChoice_addressesOrRanges       1\n\ntypedef struct IPAddressChoice_st {\n    int type;\n    union {\n        ASN1_NULL *inherit;\n        IPAddressOrRanges *addressesOrRanges;\n    } u;\n} IPAddressChoice;\n\ntypedef struct IPAddressFamily_st {\n    ASN1_OCTET_STRING *addressFamily;\n    IPAddressChoice *ipAddressChoice;\n} IPAddressFamily;\n\ntypedef STACK_OF(IPAddressFamily) IPAddrBlocks;\nDEFINE_STACK_OF(IPAddressFamily)\n\nDECLARE_ASN1_FUNCTIONS(IPAddressRange)\nDECLARE_ASN1_FUNCTIONS(IPAddressOrRange)\nDECLARE_ASN1_FUNCTIONS(IPAddressChoice)\nDECLARE_ASN1_FUNCTIONS(IPAddressFamily)\n\n/*\n * API tag for elements of the ASIdentifer SEQUENCE.\n */\n# define V3_ASID_ASNUM   0\n# define V3_ASID_RDI     1\n\n/*\n * AFI values, assigned by IANA.  It'd be nice to make the AFI\n * handling code totally generic, but there are too many little things\n * that would need to be defined for other address families for it to\n * be worth the trouble.\n */\n# define IANA_AFI_IPV4   1\n# define IANA_AFI_IPV6   2\n\n/*\n * Utilities to construct and extract values from RFC3779 extensions,\n * since some of the encodings (particularly for IP address prefixes\n * and ranges) are a bit tedious to work with directly.\n */\nint X509v3_asid_add_inherit(ASIdentifiers *asid, int which);\nint X509v3_asid_add_id_or_range(ASIdentifiers *asid, int which,\n                                ASN1_INTEGER *min, ASN1_INTEGER *max);\nint X509v3_addr_add_inherit(IPAddrBlocks *addr,\n                            const unsigned afi, const unsigned *safi);\nint X509v3_addr_add_prefix(IPAddrBlocks *addr,\n                           const unsigned afi, const unsigned *safi,\n                           unsigned char *a, const int prefixlen);\nint X509v3_addr_add_range(IPAddrBlocks *addr,\n                          const unsigned afi, const unsigned *safi,\n                          unsigned char *min, unsigned char *max);\nunsigned X509v3_addr_get_afi(const IPAddressFamily *f);\nint X509v3_addr_get_range(IPAddressOrRange *aor, const unsigned afi,\n                          unsigned char *min, unsigned char *max,\n                          const int length);\n\n/*\n * Canonical forms.\n */\nint X509v3_asid_is_canonical(ASIdentifiers *asid);\nint X509v3_addr_is_canonical(IPAddrBlocks *addr);\nint X509v3_asid_canonize(ASIdentifiers *asid);\nint X509v3_addr_canonize(IPAddrBlocks *addr);\n\n/*\n * Tests for inheritance and containment.\n */\nint X509v3_asid_inherits(ASIdentifiers *asid);\nint X509v3_addr_inherits(IPAddrBlocks *addr);\nint X509v3_asid_subset(ASIdentifiers *a, ASIdentifiers *b);\nint X509v3_addr_subset(IPAddrBlocks *a, IPAddrBlocks *b);\n\n/*\n * Check whether RFC 3779 extensions nest properly in chains.\n */\nint X509v3_asid_validate_path(X509_STORE_CTX *);\nint X509v3_addr_validate_path(X509_STORE_CTX *);\nint X509v3_asid_validate_resource_set(STACK_OF(X509) *chain,\n                                      ASIdentifiers *ext,\n                                      int allow_inheritance);\nint X509v3_addr_validate_resource_set(STACK_OF(X509) *chain,\n                                      IPAddrBlocks *ext, int allow_inheritance);\n\n#endif                         /* OPENSSL_NO_RFC3779 */\n\nDEFINE_STACK_OF(ASN1_STRING)\n\n/*\n * Admission Syntax\n */\ntypedef struct NamingAuthority_st NAMING_AUTHORITY;\ntypedef struct ProfessionInfo_st PROFESSION_INFO;\ntypedef struct Admissions_st ADMISSIONS;\ntypedef struct AdmissionSyntax_st ADMISSION_SYNTAX;\nDECLARE_ASN1_FUNCTIONS(NAMING_AUTHORITY)\nDECLARE_ASN1_FUNCTIONS(PROFESSION_INFO)\nDECLARE_ASN1_FUNCTIONS(ADMISSIONS)\nDECLARE_ASN1_FUNCTIONS(ADMISSION_SYNTAX)\nDEFINE_STACK_OF(ADMISSIONS)\nDEFINE_STACK_OF(PROFESSION_INFO)\ntypedef STACK_OF(PROFESSION_INFO) PROFESSION_INFOS;\n\nconst ASN1_OBJECT *NAMING_AUTHORITY_get0_authorityId(\n    const NAMING_AUTHORITY *n);\nconst ASN1_IA5STRING *NAMING_AUTHORITY_get0_authorityURL(\n    const NAMING_AUTHORITY *n);\nconst ASN1_STRING *NAMING_AUTHORITY_get0_authorityText(\n    const NAMING_AUTHORITY *n);\nvoid NAMING_AUTHORITY_set0_authorityId(NAMING_AUTHORITY *n,\n    ASN1_OBJECT* namingAuthorityId);\nvoid NAMING_AUTHORITY_set0_authorityURL(NAMING_AUTHORITY *n,\n    ASN1_IA5STRING* namingAuthorityUrl);\nvoid NAMING_AUTHORITY_set0_authorityText(NAMING_AUTHORITY *n,\n    ASN1_STRING* namingAuthorityText);\n\nconst GENERAL_NAME *ADMISSION_SYNTAX_get0_admissionAuthority(\n    const ADMISSION_SYNTAX *as);\nvoid ADMISSION_SYNTAX_set0_admissionAuthority(\n    ADMISSION_SYNTAX *as, GENERAL_NAME *aa);\nconst STACK_OF(ADMISSIONS) *ADMISSION_SYNTAX_get0_contentsOfAdmissions(\n    const ADMISSION_SYNTAX *as);\nvoid ADMISSION_SYNTAX_set0_contentsOfAdmissions(\n    ADMISSION_SYNTAX *as, STACK_OF(ADMISSIONS) *a);\nconst GENERAL_NAME *ADMISSIONS_get0_admissionAuthority(const ADMISSIONS *a);\nvoid ADMISSIONS_set0_admissionAuthority(ADMISSIONS *a, GENERAL_NAME *aa);\nconst NAMING_AUTHORITY *ADMISSIONS_get0_namingAuthority(const ADMISSIONS *a);\nvoid ADMISSIONS_set0_namingAuthority(ADMISSIONS *a, NAMING_AUTHORITY *na);\nconst PROFESSION_INFOS *ADMISSIONS_get0_professionInfos(const ADMISSIONS *a);\nvoid ADMISSIONS_set0_professionInfos(ADMISSIONS *a, PROFESSION_INFOS *pi);\nconst ASN1_OCTET_STRING *PROFESSION_INFO_get0_addProfessionInfo(\n    const PROFESSION_INFO *pi);\nvoid PROFESSION_INFO_set0_addProfessionInfo(\n    PROFESSION_INFO *pi, ASN1_OCTET_STRING *aos);\nconst NAMING_AUTHORITY *PROFESSION_INFO_get0_namingAuthority(\n    const PROFESSION_INFO *pi);\nvoid PROFESSION_INFO_set0_namingAuthority(\n    PROFESSION_INFO *pi, NAMING_AUTHORITY *na);\nconst STACK_OF(ASN1_STRING) *PROFESSION_INFO_get0_professionItems(\n    const PROFESSION_INFO *pi);\nvoid PROFESSION_INFO_set0_professionItems(\n    PROFESSION_INFO *pi, STACK_OF(ASN1_STRING) *as);\nconst STACK_OF(ASN1_OBJECT) *PROFESSION_INFO_get0_professionOIDs(\n    const PROFESSION_INFO *pi);\nvoid PROFESSION_INFO_set0_professionOIDs(\n    PROFESSION_INFO *pi, STACK_OF(ASN1_OBJECT) *po);\nconst ASN1_PRINTABLESTRING *PROFESSION_INFO_get0_registrationNumber(\n    const PROFESSION_INFO *pi);\nvoid PROFESSION_INFO_set0_registrationNumber(\n    PROFESSION_INFO *pi, ASN1_PRINTABLESTRING *rn);\n\n# ifdef  __cplusplus\n}\n# endif\n#endif\n"
  },
  {
    "path": "tools/prebuild/openssl/include/openssl/x509v3err.h",
    "content": "/*\n * Generated by util/mkerr.pl DO NOT EDIT\n * Copyright 1995-2021 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef HEADER_X509V3ERR_H\n# define HEADER_X509V3ERR_H\n\n# ifndef HEADER_SYMHACKS_H\n#  include <openssl/symhacks.h>\n# endif\n\n# ifdef  __cplusplus\nextern \"C\"\n# endif\nint ERR_load_X509V3_strings(void);\n\n/*\n * X509V3 function codes.\n */\n# define X509V3_F_A2I_GENERAL_NAME                        164\n# define X509V3_F_ADDR_VALIDATE_PATH_INTERNAL             166\n# define X509V3_F_ASIDENTIFIERCHOICE_CANONIZE             161\n# define X509V3_F_ASIDENTIFIERCHOICE_IS_CANONICAL         162\n# define X509V3_F_BIGNUM_TO_STRING                        167\n# define X509V3_F_COPY_EMAIL                              122\n# define X509V3_F_COPY_ISSUER                             123\n# define X509V3_F_DO_DIRNAME                              144\n# define X509V3_F_DO_EXT_I2D                              135\n# define X509V3_F_DO_EXT_NCONF                            151\n# define X509V3_F_GNAMES_FROM_SECTNAME                    156\n# define X509V3_F_I2S_ASN1_ENUMERATED                     121\n# define X509V3_F_I2S_ASN1_IA5STRING                      149\n# define X509V3_F_I2S_ASN1_INTEGER                        120\n# define X509V3_F_I2V_AUTHORITY_INFO_ACCESS               138\n# define X509V3_F_I2V_AUTHORITY_KEYID                     173\n# define X509V3_F_LEVEL_ADD_NODE                          168\n# define X509V3_F_NOTICE_SECTION                          132\n# define X509V3_F_NREF_NOS                                133\n# define X509V3_F_POLICY_CACHE_CREATE                     169\n# define X509V3_F_POLICY_CACHE_NEW                        170\n# define X509V3_F_POLICY_DATA_NEW                         171\n# define X509V3_F_POLICY_SECTION                          131\n# define X509V3_F_PROCESS_PCI_VALUE                       150\n# define X509V3_F_R2I_CERTPOL                             130\n# define X509V3_F_R2I_PCI                                 155\n# define X509V3_F_S2I_ASN1_IA5STRING                      100\n# define X509V3_F_S2I_ASN1_INTEGER                        108\n# define X509V3_F_S2I_ASN1_OCTET_STRING                   112\n# define X509V3_F_S2I_SKEY_ID                             115\n# define X509V3_F_SET_DIST_POINT_NAME                     158\n# define X509V3_F_SXNET_ADD_ID_ASC                        125\n# define X509V3_F_SXNET_ADD_ID_INTEGER                    126\n# define X509V3_F_SXNET_ADD_ID_ULONG                      127\n# define X509V3_F_SXNET_GET_ID_ASC                        128\n# define X509V3_F_SXNET_GET_ID_ULONG                      129\n# define X509V3_F_TREE_INIT                               172\n# define X509V3_F_V2I_ASIDENTIFIERS                       163\n# define X509V3_F_V2I_ASN1_BIT_STRING                     101\n# define X509V3_F_V2I_AUTHORITY_INFO_ACCESS               139\n# define X509V3_F_V2I_AUTHORITY_KEYID                     119\n# define X509V3_F_V2I_BASIC_CONSTRAINTS                   102\n# define X509V3_F_V2I_CRLD                                134\n# define X509V3_F_V2I_EXTENDED_KEY_USAGE                  103\n# define X509V3_F_V2I_GENERAL_NAMES                       118\n# define X509V3_F_V2I_GENERAL_NAME_EX                     117\n# define X509V3_F_V2I_IDP                                 157\n# define X509V3_F_V2I_IPADDRBLOCKS                        159\n# define X509V3_F_V2I_ISSUER_ALT                          153\n# define X509V3_F_V2I_NAME_CONSTRAINTS                    147\n# define X509V3_F_V2I_POLICY_CONSTRAINTS                  146\n# define X509V3_F_V2I_POLICY_MAPPINGS                     145\n# define X509V3_F_V2I_SUBJECT_ALT                         154\n# define X509V3_F_V2I_TLS_FEATURE                         165\n# define X509V3_F_V3_GENERIC_EXTENSION                    116\n# define X509V3_F_X509V3_ADD1_I2D                         140\n# define X509V3_F_X509V3_ADD_LEN_VALUE                    174\n# define X509V3_F_X509V3_ADD_VALUE                        105\n# define X509V3_F_X509V3_EXT_ADD                          104\n# define X509V3_F_X509V3_EXT_ADD_ALIAS                    106\n# define X509V3_F_X509V3_EXT_I2D                          136\n# define X509V3_F_X509V3_EXT_NCONF                        152\n# define X509V3_F_X509V3_GET_SECTION                      142\n# define X509V3_F_X509V3_GET_STRING                       143\n# define X509V3_F_X509V3_GET_VALUE_BOOL                   110\n# define X509V3_F_X509V3_PARSE_LIST                       109\n# define X509V3_F_X509_PURPOSE_ADD                        137\n# define X509V3_F_X509_PURPOSE_SET                        141\n\n/*\n * X509V3 reason codes.\n */\n# define X509V3_R_BAD_IP_ADDRESS                          118\n# define X509V3_R_BAD_OBJECT                              119\n# define X509V3_R_BN_DEC2BN_ERROR                         100\n# define X509V3_R_BN_TO_ASN1_INTEGER_ERROR                101\n# define X509V3_R_DIRNAME_ERROR                           149\n# define X509V3_R_DISTPOINT_ALREADY_SET                   160\n# define X509V3_R_DUPLICATE_ZONE_ID                       133\n# define X509V3_R_ERROR_CONVERTING_ZONE                   131\n# define X509V3_R_ERROR_CREATING_EXTENSION                144\n# define X509V3_R_ERROR_IN_EXTENSION                      128\n# define X509V3_R_EXPECTED_A_SECTION_NAME                 137\n# define X509V3_R_EXTENSION_EXISTS                        145\n# define X509V3_R_EXTENSION_NAME_ERROR                    115\n# define X509V3_R_EXTENSION_NOT_FOUND                     102\n# define X509V3_R_EXTENSION_SETTING_NOT_SUPPORTED         103\n# define X509V3_R_EXTENSION_VALUE_ERROR                   116\n# define X509V3_R_ILLEGAL_EMPTY_EXTENSION                 151\n# define X509V3_R_INCORRECT_POLICY_SYNTAX_TAG             152\n# define X509V3_R_INVALID_ASNUMBER                        162\n# define X509V3_R_INVALID_ASRANGE                         163\n# define X509V3_R_INVALID_BOOLEAN_STRING                  104\n# define X509V3_R_INVALID_EXTENSION_STRING                105\n# define X509V3_R_INVALID_INHERITANCE                     165\n# define X509V3_R_INVALID_IPADDRESS                       166\n# define X509V3_R_INVALID_MULTIPLE_RDNS                   161\n# define X509V3_R_INVALID_NAME                            106\n# define X509V3_R_INVALID_NULL_ARGUMENT                   107\n# define X509V3_R_INVALID_NULL_NAME                       108\n# define X509V3_R_INVALID_NULL_VALUE                      109\n# define X509V3_R_INVALID_NUMBER                          140\n# define X509V3_R_INVALID_NUMBERS                         141\n# define X509V3_R_INVALID_OBJECT_IDENTIFIER               110\n# define X509V3_R_INVALID_OPTION                          138\n# define X509V3_R_INVALID_POLICY_IDENTIFIER               134\n# define X509V3_R_INVALID_PROXY_POLICY_SETTING            153\n# define X509V3_R_INVALID_PURPOSE                         146\n# define X509V3_R_INVALID_SAFI                            164\n# define X509V3_R_INVALID_SECTION                         135\n# define X509V3_R_INVALID_SYNTAX                          143\n# define X509V3_R_ISSUER_DECODE_ERROR                     126\n# define X509V3_R_MISSING_VALUE                           124\n# define X509V3_R_NEED_ORGANIZATION_AND_NUMBERS           142\n# define X509V3_R_NO_CONFIG_DATABASE                      136\n# define X509V3_R_NO_ISSUER_CERTIFICATE                   121\n# define X509V3_R_NO_ISSUER_DETAILS                       127\n# define X509V3_R_NO_POLICY_IDENTIFIER                    139\n# define X509V3_R_NO_PROXY_CERT_POLICY_LANGUAGE_DEFINED   154\n# define X509V3_R_NO_PUBLIC_KEY                           114\n# define X509V3_R_NO_SUBJECT_DETAILS                      125\n# define X509V3_R_OPERATION_NOT_DEFINED                   148\n# define X509V3_R_OTHERNAME_ERROR                         147\n# define X509V3_R_POLICY_LANGUAGE_ALREADY_DEFINED         155\n# define X509V3_R_POLICY_PATH_LENGTH                      156\n# define X509V3_R_POLICY_PATH_LENGTH_ALREADY_DEFINED      157\n# define X509V3_R_POLICY_WHEN_PROXY_LANGUAGE_REQUIRES_NO_POLICY 159\n# define X509V3_R_SECTION_NOT_FOUND                       150\n# define X509V3_R_UNABLE_TO_GET_ISSUER_DETAILS            122\n# define X509V3_R_UNABLE_TO_GET_ISSUER_KEYID              123\n# define X509V3_R_UNKNOWN_BIT_STRING_ARGUMENT             111\n# define X509V3_R_UNKNOWN_EXTENSION                       129\n# define X509V3_R_UNKNOWN_EXTENSION_NAME                  130\n# define X509V3_R_UNKNOWN_OPTION                          120\n# define X509V3_R_UNSUPPORTED_OPTION                      117\n# define X509V3_R_UNSUPPORTED_TYPE                        167\n# define X509V3_R_USER_TOO_LONG                           132\n\n#endif\n"
  },
  {
    "path": "tools/prebuild/zlib/include/zconf.h",
    "content": "/* zconf.h -- configuration of the zlib compression library\n * Copyright (C) 1995-2016 Jean-loup Gailly, Mark Adler\n * For conditions of distribution and use, see copyright notice in zlib.h\n */\n\n/* @(#) $Id$ */\n\n#ifndef ZCONF_H\n#define ZCONF_H\n\n#ifndef _WIN32\n#define Z_HAVE_UNISTD_H\n#endif\n\n/*\n * If you *really* need a unique prefix for all types and library functions,\n * compile with -DZ_PREFIX. The \"standard\" zlib should be compiled without it.\n * Even better than compiling with -DZ_PREFIX would be to use configure to set\n * this permanently in zconf.h using \"./configure --zprefix\".\n */\n#ifdef Z_PREFIX     /* may be set to #if 1 by ./configure */\n#  define Z_PREFIX_SET\n\n/* all linked symbols and init macros */\n#  define _dist_code            z__dist_code\n#  define _length_code          z__length_code\n#  define _tr_align             z__tr_align\n#  define _tr_flush_bits        z__tr_flush_bits\n#  define _tr_flush_block       z__tr_flush_block\n#  define _tr_init              z__tr_init\n#  define _tr_stored_block      z__tr_stored_block\n#  define _tr_tally             z__tr_tally\n#  define adler32               z_adler32\n#  define adler32_combine       z_adler32_combine\n#  define adler32_combine64     z_adler32_combine64\n#  define adler32_z             z_adler32_z\n#  ifndef Z_SOLO\n#    define compress              z_compress\n#    define compress2             z_compress2\n#    define compressBound         z_compressBound\n#  endif\n#  define crc32                 z_crc32\n#  define crc32_combine         z_crc32_combine\n#  define crc32_combine64       z_crc32_combine64\n#  define crc32_z               z_crc32_z\n#  define deflate               z_deflate\n#  define deflateBound          z_deflateBound\n#  define deflateCopy           z_deflateCopy\n#  define deflateEnd            z_deflateEnd\n#  define deflateGetDictionary  z_deflateGetDictionary\n#  define deflateInit           z_deflateInit\n#  define deflateInit2          z_deflateInit2\n#  define deflateInit2_         z_deflateInit2_\n#  define deflateInit_          z_deflateInit_\n#  define deflateParams         z_deflateParams\n#  define deflatePending        z_deflatePending\n#  define deflatePrime          z_deflatePrime\n#  define deflateReset          z_deflateReset\n#  define deflateResetKeep      z_deflateResetKeep\n#  define deflateSetDictionary  z_deflateSetDictionary\n#  define deflateSetHeader      z_deflateSetHeader\n#  define deflateTune           z_deflateTune\n#  define deflate_copyright     z_deflate_copyright\n#  define get_crc_table         z_get_crc_table\n#  ifndef Z_SOLO\n#    define gz_error              z_gz_error\n#    define gz_intmax             z_gz_intmax\n#    define gz_strwinerror        z_gz_strwinerror\n#    define gzbuffer              z_gzbuffer\n#    define gzclearerr            z_gzclearerr\n#    define gzclose               z_gzclose\n#    define gzclose_r             z_gzclose_r\n#    define gzclose_w             z_gzclose_w\n#    define gzdirect              z_gzdirect\n#    define gzdopen               z_gzdopen\n#    define gzeof                 z_gzeof\n#    define gzerror               z_gzerror\n#    define gzflush               z_gzflush\n#    define gzfread               z_gzfread\n#    define gzfwrite              z_gzfwrite\n#    define gzgetc                z_gzgetc\n#    define gzgetc_               z_gzgetc_\n#    define gzgets                z_gzgets\n#    define gzoffset              z_gzoffset\n#    define gzoffset64            z_gzoffset64\n#    define gzopen                z_gzopen\n#    define gzopen64              z_gzopen64\n#    ifdef _WIN32\n#      define gzopen_w              z_gzopen_w\n#    endif\n#    define gzprintf              z_gzprintf\n#    define gzputc                z_gzputc\n#    define gzputs                z_gzputs\n#    define gzread                z_gzread\n#    define gzrewind              z_gzrewind\n#    define gzseek                z_gzseek\n#    define gzseek64              z_gzseek64\n#    define gzsetparams           z_gzsetparams\n#    define gztell                z_gztell\n#    define gztell64              z_gztell64\n#    define gzungetc              z_gzungetc\n#    define gzvprintf             z_gzvprintf\n#    define gzwrite               z_gzwrite\n#  endif\n#  define inflate               z_inflate\n#  define inflateBack           z_inflateBack\n#  define inflateBackEnd        z_inflateBackEnd\n#  define inflateBackInit       z_inflateBackInit\n#  define inflateBackInit_      z_inflateBackInit_\n#  define inflateCodesUsed      z_inflateCodesUsed\n#  define inflateCopy           z_inflateCopy\n#  define inflateEnd            z_inflateEnd\n#  define inflateGetDictionary  z_inflateGetDictionary\n#  define inflateGetHeader      z_inflateGetHeader\n#  define inflateInit           z_inflateInit\n#  define inflateInit2          z_inflateInit2\n#  define inflateInit2_         z_inflateInit2_\n#  define inflateInit_          z_inflateInit_\n#  define inflateMark           z_inflateMark\n#  define inflatePrime          z_inflatePrime\n#  define inflateReset          z_inflateReset\n#  define inflateReset2         z_inflateReset2\n#  define inflateResetKeep      z_inflateResetKeep\n#  define inflateSetDictionary  z_inflateSetDictionary\n#  define inflateSync           z_inflateSync\n#  define inflateSyncPoint      z_inflateSyncPoint\n#  define inflateUndermine      z_inflateUndermine\n#  define inflateValidate       z_inflateValidate\n#  define inflate_copyright     z_inflate_copyright\n#  define inflate_fast          z_inflate_fast\n#  define inflate_table         z_inflate_table\n#  ifndef Z_SOLO\n#    define uncompress            z_uncompress\n#    define uncompress2           z_uncompress2\n#  endif\n#  define zError                z_zError\n#  ifndef Z_SOLO\n#    define zcalloc               z_zcalloc\n#    define zcfree                z_zcfree\n#  endif\n#  define zlibCompileFlags      z_zlibCompileFlags\n#  define zlibVersion           z_zlibVersion\n\n/* all zlib typedefs in zlib.h and zconf.h */\n#  define Byte                  z_Byte\n#  define Bytef                 z_Bytef\n#  define alloc_func            z_alloc_func\n#  define charf                 z_charf\n#  define free_func             z_free_func\n#  ifndef Z_SOLO\n#    define gzFile                z_gzFile\n#  endif\n#  define gz_header             z_gz_header\n#  define gz_headerp            z_gz_headerp\n#  define in_func               z_in_func\n#  define intf                  z_intf\n#  define out_func              z_out_func\n#  define uInt                  z_uInt\n#  define uIntf                 z_uIntf\n#  define uLong                 z_uLong\n#  define uLongf                z_uLongf\n#  define voidp                 z_voidp\n#  define voidpc                z_voidpc\n#  define voidpf                z_voidpf\n\n/* all zlib structs in zlib.h and zconf.h */\n#  define gz_header_s           z_gz_header_s\n#  define internal_state        z_internal_state\n\n#endif\n\n#if defined(__MSDOS__) && !defined(MSDOS)\n#  define MSDOS\n#endif\n#if (defined(OS_2) || defined(__OS2__)) && !defined(OS2)\n#  define OS2\n#endif\n#if defined(_WINDOWS) && !defined(WINDOWS)\n#  define WINDOWS\n#endif\n#if defined(_WIN32) || defined(_WIN32_WCE) || defined(__WIN32__)\n#  ifndef WIN32\n#    define WIN32\n#  endif\n#endif\n#if (defined(MSDOS) || defined(OS2) || defined(WINDOWS)) && !defined(WIN32)\n#  if !defined(__GNUC__) && !defined(__FLAT__) && !defined(__386__)\n#    ifndef SYS16BIT\n#      define SYS16BIT\n#    endif\n#  endif\n#endif\n\n/*\n * Compile with -DMAXSEG_64K if the alloc function cannot allocate more\n * than 64k bytes at a time (needed on systems with 16-bit int).\n */\n#ifdef SYS16BIT\n#  define MAXSEG_64K\n#endif\n#ifdef MSDOS\n#  define UNALIGNED_OK\n#endif\n\n#ifdef __STDC_VERSION__\n#  ifndef STDC\n#    define STDC\n#  endif\n#  if __STDC_VERSION__ >= 199901L\n#    ifndef STDC99\n#      define STDC99\n#    endif\n#  endif\n#endif\n#if !defined(STDC) && (defined(__STDC__) || defined(__cplusplus))\n#  define STDC\n#endif\n#if !defined(STDC) && (defined(__GNUC__) || defined(__BORLANDC__))\n#  define STDC\n#endif\n#if !defined(STDC) && (defined(MSDOS) || defined(WINDOWS) || defined(WIN32))\n#  define STDC\n#endif\n#if !defined(STDC) && (defined(OS2) || defined(__HOS_AIX__))\n#  define STDC\n#endif\n\n#if defined(__OS400__) && !defined(STDC)    /* iSeries (formerly AS/400). */\n#  define STDC\n#endif\n\n#ifndef STDC\n#  ifndef const /* cannot use !defined(STDC) && !defined(const) on Mac */\n#    define const       /* note: need a more gentle solution here */\n#  endif\n#endif\n\n#if defined(ZLIB_CONST) && !defined(z_const)\n#  define z_const const\n#else\n#  define z_const\n#endif\n\n#ifdef Z_SOLO\n   typedef unsigned long z_size_t;\n#else\n#  define z_longlong long long\n#  if defined(NO_SIZE_T)\n     typedef unsigned NO_SIZE_T z_size_t;\n#  elif defined(STDC)\n#    include <stddef.h>\n     typedef size_t z_size_t;\n#  else\n     typedef unsigned long z_size_t;\n#  endif\n#  undef z_longlong\n#endif\n\n/* Maximum value for memLevel in deflateInit2 */\n#ifndef MAX_MEM_LEVEL\n#  ifdef MAXSEG_64K\n#    define MAX_MEM_LEVEL 8\n#  else\n#    define MAX_MEM_LEVEL 9\n#  endif\n#endif\n\n/* Maximum value for windowBits in deflateInit2 and inflateInit2.\n * WARNING: reducing MAX_WBITS makes minigzip unable to extract .gz files\n * created by gzip. (Files created by minigzip can still be extracted by\n * gzip.)\n */\n#ifndef MAX_WBITS\n#  define MAX_WBITS   15 /* 32K LZ77 window */\n#endif\n\n/* The memory requirements for deflate are (in bytes):\n            (1 << (windowBits+2)) +  (1 << (memLevel+9))\n that is: 128K for windowBits=15  +  128K for memLevel = 8  (default values)\n plus a few kilobytes for small objects. For example, if you want to reduce\n the default memory requirements from 256K to 128K, compile with\n     make CFLAGS=\"-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7\"\n Of course this will generally degrade compression (there's no free lunch).\n\n   The memory requirements for inflate are (in bytes) 1 << windowBits\n that is, 32K for windowBits=15 (default value) plus about 7 kilobytes\n for small objects.\n*/\n\n                        /* Type declarations */\n\n#ifndef OF /* function prototypes */\n#  ifdef STDC\n#    define OF(args)  args\n#  else\n#    define OF(args)  ()\n#  endif\n#endif\n\n#ifndef Z_ARG /* function prototypes for stdarg */\n#  if defined(STDC) || defined(Z_HAVE_STDARG_H)\n#    define Z_ARG(args)  args\n#  else\n#    define Z_ARG(args)  ()\n#  endif\n#endif\n\n/* The following definitions for FAR are needed only for MSDOS mixed\n * model programming (small or medium model with some far allocations).\n * This was tested only with MSC; for other MSDOS compilers you may have\n * to define NO_MEMCPY in zutil.h.  If you don't need the mixed model,\n * just define FAR to be empty.\n */\n#ifdef SYS16BIT\n#  if defined(M_I86SM) || defined(M_I86MM)\n     /* MSC small or medium model */\n#    define SMALL_MEDIUM\n#    ifdef _MSC_VER\n#      define FAR _far\n#    else\n#      define FAR far\n#    endif\n#  endif\n#  if (defined(__SMALL__) || defined(__MEDIUM__))\n     /* Turbo C small or medium model */\n#    define SMALL_MEDIUM\n#    ifdef __BORLANDC__\n#      define FAR _far\n#    else\n#      define FAR far\n#    endif\n#  endif\n#endif\n\n#if defined(WINDOWS) || defined(WIN32)\n   /* If building or using zlib as a DLL, define ZLIB_DLL.\n    * This is not mandatory, but it offers a little performance increase.\n    */\n#  ifdef ZLIB_DLL\n#    if defined(WIN32) && (!defined(__BORLANDC__) || (__BORLANDC__ >= 0x500))\n#      ifdef ZLIB_INTERNAL\n#        define ZEXTERN extern __declspec(dllexport)\n#      else\n#        define ZEXTERN extern __declspec(dllimport)\n#      endif\n#    endif\n#  endif  /* ZLIB_DLL */\n   /* If building or using zlib with the WINAPI/WINAPIV calling convention,\n    * define ZLIB_WINAPI.\n    * Caution: the standard ZLIB1.DLL is NOT compiled using ZLIB_WINAPI.\n    */\n#  ifdef ZLIB_WINAPI\n#    ifdef FAR\n#      undef FAR\n#    endif\n#    include <windows.h>\n     /* No need for _export, use ZLIB.DEF instead. */\n     /* For complete Windows compatibility, use WINAPI, not __stdcall. */\n#    define ZEXPORT WINAPI\n#    ifdef WIN32\n#      define ZEXPORTVA WINAPIV\n#    else\n#      define ZEXPORTVA FAR CDECL\n#    endif\n#  endif\n#endif\n\n#if defined (__BEOS__)\n#  ifdef ZLIB_DLL\n#    ifdef ZLIB_INTERNAL\n#      define ZEXPORT   __declspec(dllexport)\n#      define ZEXPORTVA __declspec(dllexport)\n#    else\n#      define ZEXPORT   __declspec(dllimport)\n#      define ZEXPORTVA __declspec(dllimport)\n#    endif\n#  endif\n#endif\n\n#ifndef ZEXTERN\n#  define ZEXTERN extern\n#endif\n#ifndef ZEXPORT\n#  define ZEXPORT\n#endif\n#ifndef ZEXPORTVA\n#  define ZEXPORTVA\n#endif\n\n#ifndef FAR\n#  define FAR\n#endif\n\n#if !defined(__MACTYPES__)\ntypedef unsigned char  Byte;  /* 8 bits */\n#endif\ntypedef unsigned int   uInt;  /* 16 bits or more */\ntypedef unsigned long  uLong; /* 32 bits or more */\n\n#ifdef SMALL_MEDIUM\n   /* Borland C/C++ and some old MSC versions ignore FAR inside typedef */\n#  define Bytef Byte FAR\n#else\n   typedef Byte  FAR Bytef;\n#endif\ntypedef char  FAR charf;\ntypedef int   FAR intf;\ntypedef uInt  FAR uIntf;\ntypedef uLong FAR uLongf;\n\n#ifdef STDC\n   typedef void const *voidpc;\n   typedef void FAR   *voidpf;\n   typedef void       *voidp;\n#else\n   typedef Byte const *voidpc;\n   typedef Byte FAR   *voidpf;\n   typedef Byte       *voidp;\n#endif\n\n#if !defined(Z_U4) && !defined(Z_SOLO) && defined(STDC)\n#  include <limits.h>\n#  if (UINT_MAX == 0xffffffffUL)\n#    define Z_U4 unsigned\n#  elif (ULONG_MAX == 0xffffffffUL)\n#    define Z_U4 unsigned long\n#  elif (USHRT_MAX == 0xffffffffUL)\n#    define Z_U4 unsigned short\n#  endif\n#endif\n\n#ifdef Z_U4\n   typedef Z_U4 z_crc_t;\n#else\n   typedef unsigned long z_crc_t;\n#endif\n\n#ifdef HAVE_UNISTD_H    /* may be set to #if 1 by ./configure */\n#  define Z_HAVE_UNISTD_H\n#endif\n\n#ifdef HAVE_STDARG_H    /* may be set to #if 1 by ./configure */\n#  define Z_HAVE_STDARG_H\n#endif\n\n#ifdef STDC\n#  ifndef Z_SOLO\n#    include <sys/types.h>      /* for off_t */\n#  endif\n#endif\n\n#if defined(STDC) || defined(Z_HAVE_STDARG_H)\n#  ifndef Z_SOLO\n#    include <stdarg.h>         /* for va_list */\n#  endif\n#endif\n\n#ifdef _WIN32\n#  ifndef Z_SOLO\n#    include <stddef.h>         /* for wchar_t */\n#  endif\n#endif\n\n/* a little trick to accommodate both \"#define _LARGEFILE64_SOURCE\" and\n * \"#define _LARGEFILE64_SOURCE 1\" as requesting 64-bit operations, (even\n * though the former does not conform to the LFS document), but considering\n * both \"#undef _LARGEFILE64_SOURCE\" and \"#define _LARGEFILE64_SOURCE 0\" as\n * equivalently requesting no 64-bit operations\n */\n#if defined(_LARGEFILE64_SOURCE) && -_LARGEFILE64_SOURCE - -1 == 1\n#  undef _LARGEFILE64_SOURCE\n#endif\n\n#if defined(__WATCOMC__) && !defined(Z_HAVE_UNISTD_H)\n#  define Z_HAVE_UNISTD_H\n#endif\n#ifndef Z_SOLO\n#  if defined(Z_HAVE_UNISTD_H) || defined(_LARGEFILE64_SOURCE)\n#    include <unistd.h>         /* for SEEK_*, off_t, and _LFS64_LARGEFILE */\n#    ifdef VMS\n#      include <unixio.h>       /* for off_t */\n#    endif\n#    ifndef z_off_t\n#      define z_off_t off_t\n#    endif\n#  endif\n#endif\n\n#if defined(_LFS64_LARGEFILE) && _LFS64_LARGEFILE-0\n#  define Z_LFS64\n#endif\n\n#if defined(_LARGEFILE64_SOURCE) && defined(Z_LFS64)\n#  define Z_LARGE64\n#endif\n\n#if defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS-0 == 64 && defined(Z_LFS64)\n#  define Z_WANT64\n#endif\n\n#if !defined(SEEK_SET) && !defined(Z_SOLO)\n#  define SEEK_SET        0       /* Seek from beginning of file.  */\n#  define SEEK_CUR        1       /* Seek from current position.  */\n#  define SEEK_END        2       /* Set file pointer to EOF plus \"offset\" */\n#endif\n\n#ifndef z_off_t\n#  define z_off_t long\n#endif\n\n#if !defined(_WIN32) && defined(Z_LARGE64)\n#  define z_off64_t off64_t\n#else\n#  if defined(_WIN32) && !defined(__GNUC__) && !defined(Z_SOLO)\n#    define z_off64_t __int64\n#  else\n#    define z_off64_t z_off_t\n#  endif\n#endif\n\n/* MVS linker does not support external names larger than 8 bytes */\n#if defined(__MVS__)\n  #pragma map(deflateInit_,\"DEIN\")\n  #pragma map(deflateInit2_,\"DEIN2\")\n  #pragma map(deflateEnd,\"DEEND\")\n  #pragma map(deflateBound,\"DEBND\")\n  #pragma map(inflateInit_,\"ININ\")\n  #pragma map(inflateInit2_,\"ININ2\")\n  #pragma map(inflateEnd,\"INEND\")\n  #pragma map(inflateSync,\"INSY\")\n  #pragma map(inflateSetDictionary,\"INSEDI\")\n  #pragma map(compressBound,\"CMBND\")\n  #pragma map(inflate_table,\"INTABL\")\n  #pragma map(inflate_fast,\"INFA\")\n  #pragma map(inflate_copyright,\"INCOPY\")\n#endif\n\n#endif /* ZCONF_H */\n"
  },
  {
    "path": "tools/prebuild/zlib/include/zlib.h",
    "content": "/* zlib.h -- interface of the 'zlib' general purpose compression library\n  version 1.2.11, January 15th, 2017\n\n  Copyright (C) 1995-2017 Jean-loup Gailly and Mark Adler\n\n  This software is provided 'as-is', without any express or implied\n  warranty.  In no event will the authors be held liable for any damages\n  arising from the use of this software.\n\n  Permission is granted to anyone to use this software for any purpose,\n  including commercial applications, and to alter it and redistribute it\n  freely, subject to the following restrictions:\n\n  1. The origin of this software must not be misrepresented; you must not\n     claim that you wrote the original software. If you use this software\n     in a product, an acknowledgment in the product documentation would be\n     appreciated but is not required.\n  2. Altered source versions must be plainly marked as such, and must not be\n     misrepresented as being the original software.\n  3. This notice may not be removed or altered from any source distribution.\n\n  Jean-loup Gailly        Mark Adler\n  jloup@gzip.org          madler@alumni.caltech.edu\n\n\n  The data format used by the zlib library is described by RFCs (Request for\n  Comments) 1950 to 1952 in the files http://tools.ietf.org/html/rfc1950\n  (zlib format), rfc1951 (deflate format) and rfc1952 (gzip format).\n*/\n\n#ifndef ZLIB_H\n#define ZLIB_H\n\n#include \"zconf.h\"\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n#define ZLIB_VERSION \"1.2.11\"\n#define ZLIB_VERNUM 0x12b0\n#define ZLIB_VER_MAJOR 1\n#define ZLIB_VER_MINOR 2\n#define ZLIB_VER_REVISION 11\n#define ZLIB_VER_SUBREVISION 0\n\n/*\n    The 'zlib' compression library provides in-memory compression and\n  decompression functions, including integrity checks of the uncompressed data.\n  This version of the library supports only one compression method (deflation)\n  but other algorithms will be added later and will have the same stream\n  interface.\n\n    Compression can be done in a single step if the buffers are large enough,\n  or can be done by repeated calls of the compression function.  In the latter\n  case, the application must provide more input and/or consume the output\n  (providing more output space) before each call.\n\n    The compressed data format used by default by the in-memory functions is\n  the zlib format, which is a zlib wrapper documented in RFC 1950, wrapped\n  around a deflate stream, which is itself documented in RFC 1951.\n\n    The library also supports reading and writing files in gzip (.gz) format\n  with an interface similar to that of stdio using the functions that start\n  with \"gz\".  The gzip format is different from the zlib format.  gzip is a\n  gzip wrapper, documented in RFC 1952, wrapped around a deflate stream.\n\n    This library can optionally read and write gzip and raw deflate streams in\n  memory as well.\n\n    The zlib format was designed to be compact and fast for use in memory\n  and on communications channels.  The gzip format was designed for single-\n  file compression on file systems, has a larger header than zlib to maintain\n  directory information, and uses a different, slower check method than zlib.\n\n    The library does not install any signal handler.  The decoder checks\n  the consistency of the compressed data, so the library should never crash\n  even in the case of corrupted input.\n*/\n\ntypedef voidpf (*alloc_func) OF((voidpf opaque, uInt items, uInt size));\ntypedef void   (*free_func)  OF((voidpf opaque, voidpf address));\n\nstruct internal_state;\n\ntypedef struct z_stream_s {\n    z_const Bytef *next_in;     /* next input byte */\n    uInt     avail_in;  /* number of bytes available at next_in */\n    uLong    total_in;  /* total number of input bytes read so far */\n\n    Bytef    *next_out; /* next output byte will go here */\n    uInt     avail_out; /* remaining free space at next_out */\n    uLong    total_out; /* total number of bytes output so far */\n\n    z_const char *msg;  /* last error message, NULL if no error */\n    struct internal_state FAR *state; /* not visible by applications */\n\n    alloc_func zalloc;  /* used to allocate the internal state */\n    free_func  zfree;   /* used to free the internal state */\n    voidpf     opaque;  /* private data object passed to zalloc and zfree */\n\n    int     data_type;  /* best guess about the data type: binary or text\n                           for deflate, or the decoding state for inflate */\n    uLong   adler;      /* Adler-32 or CRC-32 value of the uncompressed data */\n    uLong   reserved;   /* reserved for future use */\n} z_stream;\n\ntypedef z_stream FAR *z_streamp;\n\n/*\n     gzip header information passed to and from zlib routines.  See RFC 1952\n  for more details on the meanings of these fields.\n*/\ntypedef struct gz_header_s {\n    int     text;       /* true if compressed data believed to be text */\n    uLong   time;       /* modification time */\n    int     xflags;     /* extra flags (not used when writing a gzip file) */\n    int     os;         /* operating system */\n    Bytef   *extra;     /* pointer to extra field or Z_NULL if none */\n    uInt    extra_len;  /* extra field length (valid if extra != Z_NULL) */\n    uInt    extra_max;  /* space at extra (only when reading header) */\n    Bytef   *name;      /* pointer to zero-terminated file name or Z_NULL */\n    uInt    name_max;   /* space at name (only when reading header) */\n    Bytef   *comment;   /* pointer to zero-terminated comment or Z_NULL */\n    uInt    comm_max;   /* space at comment (only when reading header) */\n    int     hcrc;       /* true if there was or will be a header crc */\n    int     done;       /* true when done reading gzip header (not used\n                           when writing a gzip file) */\n} gz_header;\n\ntypedef gz_header FAR *gz_headerp;\n\n/*\n     The application must update next_in and avail_in when avail_in has dropped\n   to zero.  It must update next_out and avail_out when avail_out has dropped\n   to zero.  The application must initialize zalloc, zfree and opaque before\n   calling the init function.  All other fields are set by the compression\n   library and must not be updated by the application.\n\n     The opaque value provided by the application will be passed as the first\n   parameter for calls of zalloc and zfree.  This can be useful for custom\n   memory management.  The compression library attaches no meaning to the\n   opaque value.\n\n     zalloc must return Z_NULL if there is not enough memory for the object.\n   If zlib is used in a multi-threaded application, zalloc and zfree must be\n   thread safe.  In that case, zlib is thread-safe.  When zalloc and zfree are\n   Z_NULL on entry to the initialization function, they are set to internal\n   routines that use the standard library functions malloc() and free().\n\n     On 16-bit systems, the functions zalloc and zfree must be able to allocate\n   exactly 65536 bytes, but will not be required to allocate more than this if\n   the symbol MAXSEG_64K is defined (see zconf.h).  WARNING: On MSDOS, pointers\n   returned by zalloc for objects of exactly 65536 bytes *must* have their\n   offset normalized to zero.  The default allocation function provided by this\n   library ensures this (see zutil.c).  To reduce memory requirements and avoid\n   any allocation of 64K objects, at the expense of compression ratio, compile\n   the library with -DMAX_WBITS=14 (see zconf.h).\n\n     The fields total_in and total_out can be used for statistics or progress\n   reports.  After compression, total_in holds the total size of the\n   uncompressed data and may be saved for use by the decompressor (particularly\n   if the decompressor wants to decompress everything in a single step).\n*/\n\n                        /* constants */\n\n#define Z_NO_FLUSH      0\n#define Z_PARTIAL_FLUSH 1\n#define Z_SYNC_FLUSH    2\n#define Z_FULL_FLUSH    3\n#define Z_FINISH        4\n#define Z_BLOCK         5\n#define Z_TREES         6\n/* Allowed flush values; see deflate() and inflate() below for details */\n\n#define Z_OK            0\n#define Z_STREAM_END    1\n#define Z_NEED_DICT     2\n#define Z_ERRNO        (-1)\n#define Z_STREAM_ERROR (-2)\n#define Z_DATA_ERROR   (-3)\n#define Z_MEM_ERROR    (-4)\n#define Z_BUF_ERROR    (-5)\n#define Z_VERSION_ERROR (-6)\n/* Return codes for the compression/decompression functions. Negative values\n * are errors, positive values are used for special but normal events.\n */\n\n#define Z_NO_COMPRESSION         0\n#define Z_BEST_SPEED             1\n#define Z_BEST_COMPRESSION       9\n#define Z_DEFAULT_COMPRESSION  (-1)\n/* compression levels */\n\n#define Z_FILTERED            1\n#define Z_HUFFMAN_ONLY        2\n#define Z_RLE                 3\n#define Z_FIXED               4\n#define Z_DEFAULT_STRATEGY    0\n/* compression strategy; see deflateInit2() below for details */\n\n#define Z_BINARY   0\n#define Z_TEXT     1\n#define Z_ASCII    Z_TEXT   /* for compatibility with 1.2.2 and earlier */\n#define Z_UNKNOWN  2\n/* Possible values of the data_type field for deflate() */\n\n#define Z_DEFLATED   8\n/* The deflate compression method (the only one supported in this version) */\n\n#define Z_NULL  0  /* for initializing zalloc, zfree, opaque */\n\n#define zlib_version zlibVersion()\n/* for compatibility with versions < 1.0.2 */\n\n\n                        /* basic functions */\n\nZEXTERN const char * ZEXPORT zlibVersion OF((void));\n/* The application can compare zlibVersion and ZLIB_VERSION for consistency.\n   If the first character differs, the library code actually used is not\n   compatible with the zlib.h header file used by the application.  This check\n   is automatically made by deflateInit and inflateInit.\n */\n\n/*\nZEXTERN int ZEXPORT deflateInit OF((z_streamp strm, int level));\n\n     Initializes the internal stream state for compression.  The fields\n   zalloc, zfree and opaque must be initialized before by the caller.  If\n   zalloc and zfree are set to Z_NULL, deflateInit updates them to use default\n   allocation functions.\n\n     The compression level must be Z_DEFAULT_COMPRESSION, or between 0 and 9:\n   1 gives best speed, 9 gives best compression, 0 gives no compression at all\n   (the input data is simply copied a block at a time).  Z_DEFAULT_COMPRESSION\n   requests a default compromise between speed and compression (currently\n   equivalent to level 6).\n\n     deflateInit returns Z_OK if success, Z_MEM_ERROR if there was not enough\n   memory, Z_STREAM_ERROR if level is not a valid compression level, or\n   Z_VERSION_ERROR if the zlib library version (zlib_version) is incompatible\n   with the version assumed by the caller (ZLIB_VERSION).  msg is set to null\n   if there is no error message.  deflateInit does not perform any compression:\n   this will be done by deflate().\n*/\n\n\nZEXTERN int ZEXPORT deflate OF((z_streamp strm, int flush));\n/*\n    deflate compresses as much data as possible, and stops when the input\n  buffer becomes empty or the output buffer becomes full.  It may introduce\n  some output latency (reading input without producing any output) except when\n  forced to flush.\n\n    The detailed semantics are as follows.  deflate performs one or both of the\n  following actions:\n\n  - Compress more input starting at next_in and update next_in and avail_in\n    accordingly.  If not all input can be processed (because there is not\n    enough room in the output buffer), next_in and avail_in are updated and\n    processing will resume at this point for the next call of deflate().\n\n  - Generate more output starting at next_out and update next_out and avail_out\n    accordingly.  This action is forced if the parameter flush is non zero.\n    Forcing flush frequently degrades the compression ratio, so this parameter\n    should be set only when necessary.  Some output may be provided even if\n    flush is zero.\n\n    Before the call of deflate(), the application should ensure that at least\n  one of the actions is possible, by providing more input and/or consuming more\n  output, and updating avail_in or avail_out accordingly; avail_out should\n  never be zero before the call.  The application can consume the compressed\n  output when it wants, for example when the output buffer is full (avail_out\n  == 0), or after each call of deflate().  If deflate returns Z_OK and with\n  zero avail_out, it must be called again after making room in the output\n  buffer because there might be more output pending. See deflatePending(),\n  which can be used if desired to determine whether or not there is more ouput\n  in that case.\n\n    Normally the parameter flush is set to Z_NO_FLUSH, which allows deflate to\n  decide how much data to accumulate before producing output, in order to\n  maximize compression.\n\n    If the parameter flush is set to Z_SYNC_FLUSH, all pending output is\n  flushed to the output buffer and the output is aligned on a byte boundary, so\n  that the decompressor can get all input data available so far.  (In\n  particular avail_in is zero after the call if enough output space has been\n  provided before the call.) Flushing may degrade compression for some\n  compression algorithms and so it should be used only when necessary.  This\n  completes the current deflate block and follows it with an empty stored block\n  that is three bits plus filler bits to the next byte, followed by four bytes\n  (00 00 ff ff).\n\n    If flush is set to Z_PARTIAL_FLUSH, all pending output is flushed to the\n  output buffer, but the output is not aligned to a byte boundary.  All of the\n  input data so far will be available to the decompressor, as for Z_SYNC_FLUSH.\n  This completes the current deflate block and follows it with an empty fixed\n  codes block that is 10 bits long.  This assures that enough bytes are output\n  in order for the decompressor to finish the block before the empty fixed\n  codes block.\n\n    If flush is set to Z_BLOCK, a deflate block is completed and emitted, as\n  for Z_SYNC_FLUSH, but the output is not aligned on a byte boundary, and up to\n  seven bits of the current block are held to be written as the next byte after\n  the next deflate block is completed.  In this case, the decompressor may not\n  be provided enough bits at this point in order to complete decompression of\n  the data provided so far to the compressor.  It may need to wait for the next\n  block to be emitted.  This is for advanced applications that need to control\n  the emission of deflate blocks.\n\n    If flush is set to Z_FULL_FLUSH, all output is flushed as with\n  Z_SYNC_FLUSH, and the compression state is reset so that decompression can\n  restart from this point if previous compressed data has been damaged or if\n  random access is desired.  Using Z_FULL_FLUSH too often can seriously degrade\n  compression.\n\n    If deflate returns with avail_out == 0, this function must be called again\n  with the same value of the flush parameter and more output space (updated\n  avail_out), until the flush is complete (deflate returns with non-zero\n  avail_out).  In the case of a Z_FULL_FLUSH or Z_SYNC_FLUSH, make sure that\n  avail_out is greater than six to avoid repeated flush markers due to\n  avail_out == 0 on return.\n\n    If the parameter flush is set to Z_FINISH, pending input is processed,\n  pending output is flushed and deflate returns with Z_STREAM_END if there was\n  enough output space.  If deflate returns with Z_OK or Z_BUF_ERROR, this\n  function must be called again with Z_FINISH and more output space (updated\n  avail_out) but no more input data, until it returns with Z_STREAM_END or an\n  error.  After deflate has returned Z_STREAM_END, the only possible operations\n  on the stream are deflateReset or deflateEnd.\n\n    Z_FINISH can be used in the first deflate call after deflateInit if all the\n  compression is to be done in a single step.  In order to complete in one\n  call, avail_out must be at least the value returned by deflateBound (see\n  below).  Then deflate is guaranteed to return Z_STREAM_END.  If not enough\n  output space is provided, deflate will not return Z_STREAM_END, and it must\n  be called again as described above.\n\n    deflate() sets strm->adler to the Adler-32 checksum of all input read\n  so far (that is, total_in bytes).  If a gzip stream is being generated, then\n  strm->adler will be the CRC-32 checksum of the input read so far.  (See\n  deflateInit2 below.)\n\n    deflate() may update strm->data_type if it can make a good guess about\n  the input data type (Z_BINARY or Z_TEXT).  If in doubt, the data is\n  considered binary.  This field is only for information purposes and does not\n  affect the compression algorithm in any manner.\n\n    deflate() returns Z_OK if some progress has been made (more input\n  processed or more output produced), Z_STREAM_END if all input has been\n  consumed and all output has been produced (only when flush is set to\n  Z_FINISH), Z_STREAM_ERROR if the stream state was inconsistent (for example\n  if next_in or next_out was Z_NULL or the state was inadvertently written over\n  by the application), or Z_BUF_ERROR if no progress is possible (for example\n  avail_in or avail_out was zero).  Note that Z_BUF_ERROR is not fatal, and\n  deflate() can be called again with more input and more output space to\n  continue compressing.\n*/\n\n\nZEXTERN int ZEXPORT deflateEnd OF((z_streamp strm));\n/*\n     All dynamically allocated data structures for this stream are freed.\n   This function discards any unprocessed input and does not flush any pending\n   output.\n\n     deflateEnd returns Z_OK if success, Z_STREAM_ERROR if the\n   stream state was inconsistent, Z_DATA_ERROR if the stream was freed\n   prematurely (some input or output was discarded).  In the error case, msg\n   may be set but then points to a static string (which must not be\n   deallocated).\n*/\n\n\n/*\nZEXTERN int ZEXPORT inflateInit OF((z_streamp strm));\n\n     Initializes the internal stream state for decompression.  The fields\n   next_in, avail_in, zalloc, zfree and opaque must be initialized before by\n   the caller.  In the current version of inflate, the provided input is not\n   read or consumed.  The allocation of a sliding window will be deferred to\n   the first call of inflate (if the decompression does not complete on the\n   first call).  If zalloc and zfree are set to Z_NULL, inflateInit updates\n   them to use default allocation functions.\n\n     inflateInit returns Z_OK if success, Z_MEM_ERROR if there was not enough\n   memory, Z_VERSION_ERROR if the zlib library version is incompatible with the\n   version assumed by the caller, or Z_STREAM_ERROR if the parameters are\n   invalid, such as a null pointer to the structure.  msg is set to null if\n   there is no error message.  inflateInit does not perform any decompression.\n   Actual decompression will be done by inflate().  So next_in, and avail_in,\n   next_out, and avail_out are unused and unchanged.  The current\n   implementation of inflateInit() does not process any header information --\n   that is deferred until inflate() is called.\n*/\n\n\nZEXTERN int ZEXPORT inflate OF((z_streamp strm, int flush));\n/*\n    inflate decompresses as much data as possible, and stops when the input\n  buffer becomes empty or the output buffer becomes full.  It may introduce\n  some output latency (reading input without producing any output) except when\n  forced to flush.\n\n  The detailed semantics are as follows.  inflate performs one or both of the\n  following actions:\n\n  - Decompress more input starting at next_in and update next_in and avail_in\n    accordingly.  If not all input can be processed (because there is not\n    enough room in the output buffer), then next_in and avail_in are updated\n    accordingly, and processing will resume at this point for the next call of\n    inflate().\n\n  - Generate more output starting at next_out and update next_out and avail_out\n    accordingly.  inflate() provides as much output as possible, until there is\n    no more input data or no more space in the output buffer (see below about\n    the flush parameter).\n\n    Before the call of inflate(), the application should ensure that at least\n  one of the actions is possible, by providing more input and/or consuming more\n  output, and updating the next_* and avail_* values accordingly.  If the\n  caller of inflate() does not provide both available input and available\n  output space, it is possible that there will be no progress made.  The\n  application can consume the uncompressed output when it wants, for example\n  when the output buffer is full (avail_out == 0), or after each call of\n  inflate().  If inflate returns Z_OK and with zero avail_out, it must be\n  called again after making room in the output buffer because there might be\n  more output pending.\n\n    The flush parameter of inflate() can be Z_NO_FLUSH, Z_SYNC_FLUSH, Z_FINISH,\n  Z_BLOCK, or Z_TREES.  Z_SYNC_FLUSH requests that inflate() flush as much\n  output as possible to the output buffer.  Z_BLOCK requests that inflate()\n  stop if and when it gets to the next deflate block boundary.  When decoding\n  the zlib or gzip format, this will cause inflate() to return immediately\n  after the header and before the first block.  When doing a raw inflate,\n  inflate() will go ahead and process the first block, and will return when it\n  gets to the end of that block, or when it runs out of data.\n\n    The Z_BLOCK option assists in appending to or combining deflate streams.\n  To assist in this, on return inflate() always sets strm->data_type to the\n  number of unused bits in the last byte taken from strm->next_in, plus 64 if\n  inflate() is currently decoding the last block in the deflate stream, plus\n  128 if inflate() returned immediately after decoding an end-of-block code or\n  decoding the complete header up to just before the first byte of the deflate\n  stream.  The end-of-block will not be indicated until all of the uncompressed\n  data from that block has been written to strm->next_out.  The number of\n  unused bits may in general be greater than seven, except when bit 7 of\n  data_type is set, in which case the number of unused bits will be less than\n  eight.  data_type is set as noted here every time inflate() returns for all\n  flush options, and so can be used to determine the amount of currently\n  consumed input in bits.\n\n    The Z_TREES option behaves as Z_BLOCK does, but it also returns when the\n  end of each deflate block header is reached, before any actual data in that\n  block is decoded.  This allows the caller to determine the length of the\n  deflate block header for later use in random access within a deflate block.\n  256 is added to the value of strm->data_type when inflate() returns\n  immediately after reaching the end of the deflate block header.\n\n    inflate() should normally be called until it returns Z_STREAM_END or an\n  error.  However if all decompression is to be performed in a single step (a\n  single call of inflate), the parameter flush should be set to Z_FINISH.  In\n  this case all pending input is processed and all pending output is flushed;\n  avail_out must be large enough to hold all of the uncompressed data for the\n  operation to complete.  (The size of the uncompressed data may have been\n  saved by the compressor for this purpose.)  The use of Z_FINISH is not\n  required to perform an inflation in one step.  However it may be used to\n  inform inflate that a faster approach can be used for the single inflate()\n  call.  Z_FINISH also informs inflate to not maintain a sliding window if the\n  stream completes, which reduces inflate's memory footprint.  If the stream\n  does not complete, either because not all of the stream is provided or not\n  enough output space is provided, then a sliding window will be allocated and\n  inflate() can be called again to continue the operation as if Z_NO_FLUSH had\n  been used.\n\n     In this implementation, inflate() always flushes as much output as\n  possible to the output buffer, and always uses the faster approach on the\n  first call.  So the effects of the flush parameter in this implementation are\n  on the return value of inflate() as noted below, when inflate() returns early\n  when Z_BLOCK or Z_TREES is used, and when inflate() avoids the allocation of\n  memory for a sliding window when Z_FINISH is used.\n\n     If a preset dictionary is needed after this call (see inflateSetDictionary\n  below), inflate sets strm->adler to the Adler-32 checksum of the dictionary\n  chosen by the compressor and returns Z_NEED_DICT; otherwise it sets\n  strm->adler to the Adler-32 checksum of all output produced so far (that is,\n  total_out bytes) and returns Z_OK, Z_STREAM_END or an error code as described\n  below.  At the end of the stream, inflate() checks that its computed Adler-32\n  checksum is equal to that saved by the compressor and returns Z_STREAM_END\n  only if the checksum is correct.\n\n    inflate() can decompress and check either zlib-wrapped or gzip-wrapped\n  deflate data.  The header type is detected automatically, if requested when\n  initializing with inflateInit2().  Any information contained in the gzip\n  header is not retained unless inflateGetHeader() is used.  When processing\n  gzip-wrapped deflate data, strm->adler32 is set to the CRC-32 of the output\n  produced so far.  The CRC-32 is checked against the gzip trailer, as is the\n  uncompressed length, modulo 2^32.\n\n    inflate() returns Z_OK if some progress has been made (more input processed\n  or more output produced), Z_STREAM_END if the end of the compressed data has\n  been reached and all uncompressed output has been produced, Z_NEED_DICT if a\n  preset dictionary is needed at this point, Z_DATA_ERROR if the input data was\n  corrupted (input stream not conforming to the zlib format or incorrect check\n  value, in which case strm->msg points to a string with a more specific\n  error), Z_STREAM_ERROR if the stream structure was inconsistent (for example\n  next_in or next_out was Z_NULL, or the state was inadvertently written over\n  by the application), Z_MEM_ERROR if there was not enough memory, Z_BUF_ERROR\n  if no progress was possible or if there was not enough room in the output\n  buffer when Z_FINISH is used.  Note that Z_BUF_ERROR is not fatal, and\n  inflate() can be called again with more input and more output space to\n  continue decompressing.  If Z_DATA_ERROR is returned, the application may\n  then call inflateSync() to look for a good compression block if a partial\n  recovery of the data is to be attempted.\n*/\n\n\nZEXTERN int ZEXPORT inflateEnd OF((z_streamp strm));\n/*\n     All dynamically allocated data structures for this stream are freed.\n   This function discards any unprocessed input and does not flush any pending\n   output.\n\n     inflateEnd returns Z_OK if success, or Z_STREAM_ERROR if the stream state\n   was inconsistent.\n*/\n\n\n                        /* Advanced functions */\n\n/*\n    The following functions are needed only in some special applications.\n*/\n\n/*\nZEXTERN int ZEXPORT deflateInit2 OF((z_streamp strm,\n                                     int  level,\n                                     int  method,\n                                     int  windowBits,\n                                     int  memLevel,\n                                     int  strategy));\n\n     This is another version of deflateInit with more compression options.  The\n   fields next_in, zalloc, zfree and opaque must be initialized before by the\n   caller.\n\n     The method parameter is the compression method.  It must be Z_DEFLATED in\n   this version of the library.\n\n     The windowBits parameter is the base two logarithm of the window size\n   (the size of the history buffer).  It should be in the range 8..15 for this\n   version of the library.  Larger values of this parameter result in better\n   compression at the expense of memory usage.  The default value is 15 if\n   deflateInit is used instead.\n\n     For the current implementation of deflate(), a windowBits value of 8 (a\n   window size of 256 bytes) is not supported.  As a result, a request for 8\n   will result in 9 (a 512-byte window).  In that case, providing 8 to\n   inflateInit2() will result in an error when the zlib header with 9 is\n   checked against the initialization of inflate().  The remedy is to not use 8\n   with deflateInit2() with this initialization, or at least in that case use 9\n   with inflateInit2().\n\n     windowBits can also be -8..-15 for raw deflate.  In this case, -windowBits\n   determines the window size.  deflate() will then generate raw deflate data\n   with no zlib header or trailer, and will not compute a check value.\n\n     windowBits can also be greater than 15 for optional gzip encoding.  Add\n   16 to windowBits to write a simple gzip header and trailer around the\n   compressed data instead of a zlib wrapper.  The gzip header will have no\n   file name, no extra data, no comment, no modification time (set to zero), no\n   header crc, and the operating system will be set to the appropriate value,\n   if the operating system was determined at compile time.  If a gzip stream is\n   being written, strm->adler is a CRC-32 instead of an Adler-32.\n\n     For raw deflate or gzip encoding, a request for a 256-byte window is\n   rejected as invalid, since only the zlib header provides a means of\n   transmitting the window size to the decompressor.\n\n     The memLevel parameter specifies how much memory should be allocated\n   for the internal compression state.  memLevel=1 uses minimum memory but is\n   slow and reduces compression ratio; memLevel=9 uses maximum memory for\n   optimal speed.  The default value is 8.  See zconf.h for total memory usage\n   as a function of windowBits and memLevel.\n\n     The strategy parameter is used to tune the compression algorithm.  Use the\n   value Z_DEFAULT_STRATEGY for normal data, Z_FILTERED for data produced by a\n   filter (or predictor), Z_HUFFMAN_ONLY to force Huffman encoding only (no\n   string match), or Z_RLE to limit match distances to one (run-length\n   encoding).  Filtered data consists mostly of small values with a somewhat\n   random distribution.  In this case, the compression algorithm is tuned to\n   compress them better.  The effect of Z_FILTERED is to force more Huffman\n   coding and less string matching; it is somewhat intermediate between\n   Z_DEFAULT_STRATEGY and Z_HUFFMAN_ONLY.  Z_RLE is designed to be almost as\n   fast as Z_HUFFMAN_ONLY, but give better compression for PNG image data.  The\n   strategy parameter only affects the compression ratio but not the\n   correctness of the compressed output even if it is not set appropriately.\n   Z_FIXED prevents the use of dynamic Huffman codes, allowing for a simpler\n   decoder for special applications.\n\n     deflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough\n   memory, Z_STREAM_ERROR if any parameter is invalid (such as an invalid\n   method), or Z_VERSION_ERROR if the zlib library version (zlib_version) is\n   incompatible with the version assumed by the caller (ZLIB_VERSION).  msg is\n   set to null if there is no error message.  deflateInit2 does not perform any\n   compression: this will be done by deflate().\n*/\n\nZEXTERN int ZEXPORT deflateSetDictionary OF((z_streamp strm,\n                                             const Bytef *dictionary,\n                                             uInt  dictLength));\n/*\n     Initializes the compression dictionary from the given byte sequence\n   without producing any compressed output.  When using the zlib format, this\n   function must be called immediately after deflateInit, deflateInit2 or\n   deflateReset, and before any call of deflate.  When doing raw deflate, this\n   function must be called either before any call of deflate, or immediately\n   after the completion of a deflate block, i.e. after all input has been\n   consumed and all output has been delivered when using any of the flush\n   options Z_BLOCK, Z_PARTIAL_FLUSH, Z_SYNC_FLUSH, or Z_FULL_FLUSH.  The\n   compressor and decompressor must use exactly the same dictionary (see\n   inflateSetDictionary).\n\n     The dictionary should consist of strings (byte sequences) that are likely\n   to be encountered later in the data to be compressed, with the most commonly\n   used strings preferably put towards the end of the dictionary.  Using a\n   dictionary is most useful when the data to be compressed is short and can be\n   predicted with good accuracy; the data can then be compressed better than\n   with the default empty dictionary.\n\n     Depending on the size of the compression data structures selected by\n   deflateInit or deflateInit2, a part of the dictionary may in effect be\n   discarded, for example if the dictionary is larger than the window size\n   provided in deflateInit or deflateInit2.  Thus the strings most likely to be\n   useful should be put at the end of the dictionary, not at the front.  In\n   addition, the current implementation of deflate will use at most the window\n   size minus 262 bytes of the provided dictionary.\n\n     Upon return of this function, strm->adler is set to the Adler-32 value\n   of the dictionary; the decompressor may later use this value to determine\n   which dictionary has been used by the compressor.  (The Adler-32 value\n   applies to the whole dictionary even if only a subset of the dictionary is\n   actually used by the compressor.) If a raw deflate was requested, then the\n   Adler-32 value is not computed and strm->adler is not set.\n\n     deflateSetDictionary returns Z_OK if success, or Z_STREAM_ERROR if a\n   parameter is invalid (e.g.  dictionary being Z_NULL) or the stream state is\n   inconsistent (for example if deflate has already been called for this stream\n   or if not at a block boundary for raw deflate).  deflateSetDictionary does\n   not perform any compression: this will be done by deflate().\n*/\n\nZEXTERN int ZEXPORT deflateGetDictionary OF((z_streamp strm,\n                                             Bytef *dictionary,\n                                             uInt  *dictLength));\n/*\n     Returns the sliding dictionary being maintained by deflate.  dictLength is\n   set to the number of bytes in the dictionary, and that many bytes are copied\n   to dictionary.  dictionary must have enough space, where 32768 bytes is\n   always enough.  If deflateGetDictionary() is called with dictionary equal to\n   Z_NULL, then only the dictionary length is returned, and nothing is copied.\n   Similary, if dictLength is Z_NULL, then it is not set.\n\n     deflateGetDictionary() may return a length less than the window size, even\n   when more than the window size in input has been provided. It may return up\n   to 258 bytes less in that case, due to how zlib's implementation of deflate\n   manages the sliding window and lookahead for matches, where matches can be\n   up to 258 bytes long. If the application needs the last window-size bytes of\n   input, then that would need to be saved by the application outside of zlib.\n\n     deflateGetDictionary returns Z_OK on success, or Z_STREAM_ERROR if the\n   stream state is inconsistent.\n*/\n\nZEXTERN int ZEXPORT deflateCopy OF((z_streamp dest,\n                                    z_streamp source));\n/*\n     Sets the destination stream as a complete copy of the source stream.\n\n     This function can be useful when several compression strategies will be\n   tried, for example when there are several ways of pre-processing the input\n   data with a filter.  The streams that will be discarded should then be freed\n   by calling deflateEnd.  Note that deflateCopy duplicates the internal\n   compression state which can be quite large, so this strategy is slow and can\n   consume lots of memory.\n\n     deflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not\n   enough memory, Z_STREAM_ERROR if the source stream state was inconsistent\n   (such as zalloc being Z_NULL).  msg is left unchanged in both source and\n   destination.\n*/\n\nZEXTERN int ZEXPORT deflateReset OF((z_streamp strm));\n/*\n     This function is equivalent to deflateEnd followed by deflateInit, but\n   does not free and reallocate the internal compression state.  The stream\n   will leave the compression level and any other attributes that may have been\n   set unchanged.\n\n     deflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source\n   stream state was inconsistent (such as zalloc or state being Z_NULL).\n*/\n\nZEXTERN int ZEXPORT deflateParams OF((z_streamp strm,\n                                      int level,\n                                      int strategy));\n/*\n     Dynamically update the compression level and compression strategy.  The\n   interpretation of level and strategy is as in deflateInit2().  This can be\n   used to switch between compression and straight copy of the input data, or\n   to switch to a different kind of input data requiring a different strategy.\n   If the compression approach (which is a function of the level) or the\n   strategy is changed, and if any input has been consumed in a previous\n   deflate() call, then the input available so far is compressed with the old\n   level and strategy using deflate(strm, Z_BLOCK).  There are three approaches\n   for the compression levels 0, 1..3, and 4..9 respectively.  The new level\n   and strategy will take effect at the next call of deflate().\n\n     If a deflate(strm, Z_BLOCK) is performed by deflateParams(), and it does\n   not have enough output space to complete, then the parameter change will not\n   take effect.  In this case, deflateParams() can be called again with the\n   same parameters and more output space to try again.\n\n     In order to assure a change in the parameters on the first try, the\n   deflate stream should be flushed using deflate() with Z_BLOCK or other flush\n   request until strm.avail_out is not zero, before calling deflateParams().\n   Then no more input data should be provided before the deflateParams() call.\n   If this is done, the old level and strategy will be applied to the data\n   compressed before deflateParams(), and the new level and strategy will be\n   applied to the the data compressed after deflateParams().\n\n     deflateParams returns Z_OK on success, Z_STREAM_ERROR if the source stream\n   state was inconsistent or if a parameter was invalid, or Z_BUF_ERROR if\n   there was not enough output space to complete the compression of the\n   available input data before a change in the strategy or approach.  Note that\n   in the case of a Z_BUF_ERROR, the parameters are not changed.  A return\n   value of Z_BUF_ERROR is not fatal, in which case deflateParams() can be\n   retried with more output space.\n*/\n\nZEXTERN int ZEXPORT deflateTune OF((z_streamp strm,\n                                    int good_length,\n                                    int max_lazy,\n                                    int nice_length,\n                                    int max_chain));\n/*\n     Fine tune deflate's internal compression parameters.  This should only be\n   used by someone who understands the algorithm used by zlib's deflate for\n   searching for the best matching string, and even then only by the most\n   fanatic optimizer trying to squeeze out the last compressed bit for their\n   specific input data.  Read the deflate.c source code for the meaning of the\n   max_lazy, good_length, nice_length, and max_chain parameters.\n\n     deflateTune() can be called after deflateInit() or deflateInit2(), and\n   returns Z_OK on success, or Z_STREAM_ERROR for an invalid deflate stream.\n */\n\nZEXTERN uLong ZEXPORT deflateBound OF((z_streamp strm,\n                                       uLong sourceLen));\n/*\n     deflateBound() returns an upper bound on the compressed size after\n   deflation of sourceLen bytes.  It must be called after deflateInit() or\n   deflateInit2(), and after deflateSetHeader(), if used.  This would be used\n   to allocate an output buffer for deflation in a single pass, and so would be\n   called before deflate().  If that first deflate() call is provided the\n   sourceLen input bytes, an output buffer allocated to the size returned by\n   deflateBound(), and the flush value Z_FINISH, then deflate() is guaranteed\n   to return Z_STREAM_END.  Note that it is possible for the compressed size to\n   be larger than the value returned by deflateBound() if flush options other\n   than Z_FINISH or Z_NO_FLUSH are used.\n*/\n\nZEXTERN int ZEXPORT deflatePending OF((z_streamp strm,\n                                       unsigned *pending,\n                                       int *bits));\n/*\n     deflatePending() returns the number of bytes and bits of output that have\n   been generated, but not yet provided in the available output.  The bytes not\n   provided would be due to the available output space having being consumed.\n   The number of bits of output not provided are between 0 and 7, where they\n   await more bits to join them in order to fill out a full byte.  If pending\n   or bits are Z_NULL, then those values are not set.\n\n     deflatePending returns Z_OK if success, or Z_STREAM_ERROR if the source\n   stream state was inconsistent.\n */\n\nZEXTERN int ZEXPORT deflatePrime OF((z_streamp strm,\n                                     int bits,\n                                     int value));\n/*\n     deflatePrime() inserts bits in the deflate output stream.  The intent\n   is that this function is used to start off the deflate output with the bits\n   leftover from a previous deflate stream when appending to it.  As such, this\n   function can only be used for raw deflate, and must be used before the first\n   deflate() call after a deflateInit2() or deflateReset().  bits must be less\n   than or equal to 16, and that many of the least significant bits of value\n   will be inserted in the output.\n\n     deflatePrime returns Z_OK if success, Z_BUF_ERROR if there was not enough\n   room in the internal buffer to insert the bits, or Z_STREAM_ERROR if the\n   source stream state was inconsistent.\n*/\n\nZEXTERN int ZEXPORT deflateSetHeader OF((z_streamp strm,\n                                         gz_headerp head));\n/*\n     deflateSetHeader() provides gzip header information for when a gzip\n   stream is requested by deflateInit2().  deflateSetHeader() may be called\n   after deflateInit2() or deflateReset() and before the first call of\n   deflate().  The text, time, os, extra field, name, and comment information\n   in the provided gz_header structure are written to the gzip header (xflag is\n   ignored -- the extra flags are set according to the compression level).  The\n   caller must assure that, if not Z_NULL, name and comment are terminated with\n   a zero byte, and that if extra is not Z_NULL, that extra_len bytes are\n   available there.  If hcrc is true, a gzip header crc is included.  Note that\n   the current versions of the command-line version of gzip (up through version\n   1.3.x) do not support header crc's, and will report that it is a \"multi-part\n   gzip file\" and give up.\n\n     If deflateSetHeader is not used, the default gzip header has text false,\n   the time set to zero, and os set to 255, with no extra, name, or comment\n   fields.  The gzip header is returned to the default state by deflateReset().\n\n     deflateSetHeader returns Z_OK if success, or Z_STREAM_ERROR if the source\n   stream state was inconsistent.\n*/\n\n/*\nZEXTERN int ZEXPORT inflateInit2 OF((z_streamp strm,\n                                     int  windowBits));\n\n     This is another version of inflateInit with an extra parameter.  The\n   fields next_in, avail_in, zalloc, zfree and opaque must be initialized\n   before by the caller.\n\n     The windowBits parameter is the base two logarithm of the maximum window\n   size (the size of the history buffer).  It should be in the range 8..15 for\n   this version of the library.  The default value is 15 if inflateInit is used\n   instead.  windowBits must be greater than or equal to the windowBits value\n   provided to deflateInit2() while compressing, or it must be equal to 15 if\n   deflateInit2() was not used.  If a compressed stream with a larger window\n   size is given as input, inflate() will return with the error code\n   Z_DATA_ERROR instead of trying to allocate a larger window.\n\n     windowBits can also be zero to request that inflate use the window size in\n   the zlib header of the compressed stream.\n\n     windowBits can also be -8..-15 for raw inflate.  In this case, -windowBits\n   determines the window size.  inflate() will then process raw deflate data,\n   not looking for a zlib or gzip header, not generating a check value, and not\n   looking for any check values for comparison at the end of the stream.  This\n   is for use with other formats that use the deflate compressed data format\n   such as zip.  Those formats provide their own check values.  If a custom\n   format is developed using the raw deflate format for compressed data, it is\n   recommended that a check value such as an Adler-32 or a CRC-32 be applied to\n   the uncompressed data as is done in the zlib, gzip, and zip formats.  For\n   most applications, the zlib format should be used as is.  Note that comments\n   above on the use in deflateInit2() applies to the magnitude of windowBits.\n\n     windowBits can also be greater than 15 for optional gzip decoding.  Add\n   32 to windowBits to enable zlib and gzip decoding with automatic header\n   detection, or add 16 to decode only the gzip format (the zlib format will\n   return a Z_DATA_ERROR).  If a gzip stream is being decoded, strm->adler is a\n   CRC-32 instead of an Adler-32.  Unlike the gunzip utility and gzread() (see\n   below), inflate() will not automatically decode concatenated gzip streams.\n   inflate() will return Z_STREAM_END at the end of the gzip stream.  The state\n   would need to be reset to continue decoding a subsequent gzip stream.\n\n     inflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough\n   memory, Z_VERSION_ERROR if the zlib library version is incompatible with the\n   version assumed by the caller, or Z_STREAM_ERROR if the parameters are\n   invalid, such as a null pointer to the structure.  msg is set to null if\n   there is no error message.  inflateInit2 does not perform any decompression\n   apart from possibly reading the zlib header if present: actual decompression\n   will be done by inflate().  (So next_in and avail_in may be modified, but\n   next_out and avail_out are unused and unchanged.) The current implementation\n   of inflateInit2() does not process any header information -- that is\n   deferred until inflate() is called.\n*/\n\nZEXTERN int ZEXPORT inflateSetDictionary OF((z_streamp strm,\n                                             const Bytef *dictionary,\n                                             uInt  dictLength));\n/*\n     Initializes the decompression dictionary from the given uncompressed byte\n   sequence.  This function must be called immediately after a call of inflate,\n   if that call returned Z_NEED_DICT.  The dictionary chosen by the compressor\n   can be determined from the Adler-32 value returned by that call of inflate.\n   The compressor and decompressor must use exactly the same dictionary (see\n   deflateSetDictionary).  For raw inflate, this function can be called at any\n   time to set the dictionary.  If the provided dictionary is smaller than the\n   window and there is already data in the window, then the provided dictionary\n   will amend what's there.  The application must insure that the dictionary\n   that was used for compression is provided.\n\n     inflateSetDictionary returns Z_OK if success, Z_STREAM_ERROR if a\n   parameter is invalid (e.g.  dictionary being Z_NULL) or the stream state is\n   inconsistent, Z_DATA_ERROR if the given dictionary doesn't match the\n   expected one (incorrect Adler-32 value).  inflateSetDictionary does not\n   perform any decompression: this will be done by subsequent calls of\n   inflate().\n*/\n\nZEXTERN int ZEXPORT inflateGetDictionary OF((z_streamp strm,\n                                             Bytef *dictionary,\n                                             uInt  *dictLength));\n/*\n     Returns the sliding dictionary being maintained by inflate.  dictLength is\n   set to the number of bytes in the dictionary, and that many bytes are copied\n   to dictionary.  dictionary must have enough space, where 32768 bytes is\n   always enough.  If inflateGetDictionary() is called with dictionary equal to\n   Z_NULL, then only the dictionary length is returned, and nothing is copied.\n   Similary, if dictLength is Z_NULL, then it is not set.\n\n     inflateGetDictionary returns Z_OK on success, or Z_STREAM_ERROR if the\n   stream state is inconsistent.\n*/\n\nZEXTERN int ZEXPORT inflateSync OF((z_streamp strm));\n/*\n     Skips invalid compressed data until a possible full flush point (see above\n   for the description of deflate with Z_FULL_FLUSH) can be found, or until all\n   available input is skipped.  No output is provided.\n\n     inflateSync searches for a 00 00 FF FF pattern in the compressed data.\n   All full flush points have this pattern, but not all occurrences of this\n   pattern are full flush points.\n\n     inflateSync returns Z_OK if a possible full flush point has been found,\n   Z_BUF_ERROR if no more input was provided, Z_DATA_ERROR if no flush point\n   has been found, or Z_STREAM_ERROR if the stream structure was inconsistent.\n   In the success case, the application may save the current current value of\n   total_in which indicates where valid compressed data was found.  In the\n   error case, the application may repeatedly call inflateSync, providing more\n   input each time, until success or end of the input data.\n*/\n\nZEXTERN int ZEXPORT inflateCopy OF((z_streamp dest,\n                                    z_streamp source));\n/*\n     Sets the destination stream as a complete copy of the source stream.\n\n     This function can be useful when randomly accessing a large stream.  The\n   first pass through the stream can periodically record the inflate state,\n   allowing restarting inflate at those points when randomly accessing the\n   stream.\n\n     inflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not\n   enough memory, Z_STREAM_ERROR if the source stream state was inconsistent\n   (such as zalloc being Z_NULL).  msg is left unchanged in both source and\n   destination.\n*/\n\nZEXTERN int ZEXPORT inflateReset OF((z_streamp strm));\n/*\n     This function is equivalent to inflateEnd followed by inflateInit,\n   but does not free and reallocate the internal decompression state.  The\n   stream will keep attributes that may have been set by inflateInit2.\n\n     inflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source\n   stream state was inconsistent (such as zalloc or state being Z_NULL).\n*/\n\nZEXTERN int ZEXPORT inflateReset2 OF((z_streamp strm,\n                                      int windowBits));\n/*\n     This function is the same as inflateReset, but it also permits changing\n   the wrap and window size requests.  The windowBits parameter is interpreted\n   the same as it is for inflateInit2.  If the window size is changed, then the\n   memory allocated for the window is freed, and the window will be reallocated\n   by inflate() if needed.\n\n     inflateReset2 returns Z_OK if success, or Z_STREAM_ERROR if the source\n   stream state was inconsistent (such as zalloc or state being Z_NULL), or if\n   the windowBits parameter is invalid.\n*/\n\nZEXTERN int ZEXPORT inflatePrime OF((z_streamp strm,\n                                     int bits,\n                                     int value));\n/*\n     This function inserts bits in the inflate input stream.  The intent is\n   that this function is used to start inflating at a bit position in the\n   middle of a byte.  The provided bits will be used before any bytes are used\n   from next_in.  This function should only be used with raw inflate, and\n   should be used before the first inflate() call after inflateInit2() or\n   inflateReset().  bits must be less than or equal to 16, and that many of the\n   least significant bits of value will be inserted in the input.\n\n     If bits is negative, then the input stream bit buffer is emptied.  Then\n   inflatePrime() can be called again to put bits in the buffer.  This is used\n   to clear out bits leftover after feeding inflate a block description prior\n   to feeding inflate codes.\n\n     inflatePrime returns Z_OK if success, or Z_STREAM_ERROR if the source\n   stream state was inconsistent.\n*/\n\nZEXTERN long ZEXPORT inflateMark OF((z_streamp strm));\n/*\n     This function returns two values, one in the lower 16 bits of the return\n   value, and the other in the remaining upper bits, obtained by shifting the\n   return value down 16 bits.  If the upper value is -1 and the lower value is\n   zero, then inflate() is currently decoding information outside of a block.\n   If the upper value is -1 and the lower value is non-zero, then inflate is in\n   the middle of a stored block, with the lower value equaling the number of\n   bytes from the input remaining to copy.  If the upper value is not -1, then\n   it is the number of bits back from the current bit position in the input of\n   the code (literal or length/distance pair) currently being processed.  In\n   that case the lower value is the number of bytes already emitted for that\n   code.\n\n     A code is being processed if inflate is waiting for more input to complete\n   decoding of the code, or if it has completed decoding but is waiting for\n   more output space to write the literal or match data.\n\n     inflateMark() is used to mark locations in the input data for random\n   access, which may be at bit positions, and to note those cases where the\n   output of a code may span boundaries of random access blocks.  The current\n   location in the input stream can be determined from avail_in and data_type\n   as noted in the description for the Z_BLOCK flush parameter for inflate.\n\n     inflateMark returns the value noted above, or -65536 if the provided\n   source stream state was inconsistent.\n*/\n\nZEXTERN int ZEXPORT inflateGetHeader OF((z_streamp strm,\n                                         gz_headerp head));\n/*\n     inflateGetHeader() requests that gzip header information be stored in the\n   provided gz_header structure.  inflateGetHeader() may be called after\n   inflateInit2() or inflateReset(), and before the first call of inflate().\n   As inflate() processes the gzip stream, head->done is zero until the header\n   is completed, at which time head->done is set to one.  If a zlib stream is\n   being decoded, then head->done is set to -1 to indicate that there will be\n   no gzip header information forthcoming.  Note that Z_BLOCK or Z_TREES can be\n   used to force inflate() to return immediately after header processing is\n   complete and before any actual data is decompressed.\n\n     The text, time, xflags, and os fields are filled in with the gzip header\n   contents.  hcrc is set to true if there is a header CRC.  (The header CRC\n   was valid if done is set to one.) If extra is not Z_NULL, then extra_max\n   contains the maximum number of bytes to write to extra.  Once done is true,\n   extra_len contains the actual extra field length, and extra contains the\n   extra field, or that field truncated if extra_max is less than extra_len.\n   If name is not Z_NULL, then up to name_max characters are written there,\n   terminated with a zero unless the length is greater than name_max.  If\n   comment is not Z_NULL, then up to comm_max characters are written there,\n   terminated with a zero unless the length is greater than comm_max.  When any\n   of extra, name, or comment are not Z_NULL and the respective field is not\n   present in the header, then that field is set to Z_NULL to signal its\n   absence.  This allows the use of deflateSetHeader() with the returned\n   structure to duplicate the header.  However if those fields are set to\n   allocated memory, then the application will need to save those pointers\n   elsewhere so that they can be eventually freed.\n\n     If inflateGetHeader is not used, then the header information is simply\n   discarded.  The header is always checked for validity, including the header\n   CRC if present.  inflateReset() will reset the process to discard the header\n   information.  The application would need to call inflateGetHeader() again to\n   retrieve the header from the next gzip stream.\n\n     inflateGetHeader returns Z_OK if success, or Z_STREAM_ERROR if the source\n   stream state was inconsistent.\n*/\n\n/*\nZEXTERN int ZEXPORT inflateBackInit OF((z_streamp strm, int windowBits,\n                                        unsigned char FAR *window));\n\n     Initialize the internal stream state for decompression using inflateBack()\n   calls.  The fields zalloc, zfree and opaque in strm must be initialized\n   before the call.  If zalloc and zfree are Z_NULL, then the default library-\n   derived memory allocation routines are used.  windowBits is the base two\n   logarithm of the window size, in the range 8..15.  window is a caller\n   supplied buffer of that size.  Except for special applications where it is\n   assured that deflate was used with small window sizes, windowBits must be 15\n   and a 32K byte window must be supplied to be able to decompress general\n   deflate streams.\n\n     See inflateBack() for the usage of these routines.\n\n     inflateBackInit will return Z_OK on success, Z_STREAM_ERROR if any of\n   the parameters are invalid, Z_MEM_ERROR if the internal state could not be\n   allocated, or Z_VERSION_ERROR if the version of the library does not match\n   the version of the header file.\n*/\n\ntypedef unsigned (*in_func) OF((void FAR *,\n                                z_const unsigned char FAR * FAR *));\ntypedef int (*out_func) OF((void FAR *, unsigned char FAR *, unsigned));\n\nZEXTERN int ZEXPORT inflateBack OF((z_streamp strm,\n                                    in_func in, void FAR *in_desc,\n                                    out_func out, void FAR *out_desc));\n/*\n     inflateBack() does a raw inflate with a single call using a call-back\n   interface for input and output.  This is potentially more efficient than\n   inflate() for file i/o applications, in that it avoids copying between the\n   output and the sliding window by simply making the window itself the output\n   buffer.  inflate() can be faster on modern CPUs when used with large\n   buffers.  inflateBack() trusts the application to not change the output\n   buffer passed by the output function, at least until inflateBack() returns.\n\n     inflateBackInit() must be called first to allocate the internal state\n   and to initialize the state with the user-provided window buffer.\n   inflateBack() may then be used multiple times to inflate a complete, raw\n   deflate stream with each call.  inflateBackEnd() is then called to free the\n   allocated state.\n\n     A raw deflate stream is one with no zlib or gzip header or trailer.\n   This routine would normally be used in a utility that reads zip or gzip\n   files and writes out uncompressed files.  The utility would decode the\n   header and process the trailer on its own, hence this routine expects only\n   the raw deflate stream to decompress.  This is different from the default\n   behavior of inflate(), which expects a zlib header and trailer around the\n   deflate stream.\n\n     inflateBack() uses two subroutines supplied by the caller that are then\n   called by inflateBack() for input and output.  inflateBack() calls those\n   routines until it reads a complete deflate stream and writes out all of the\n   uncompressed data, or until it encounters an error.  The function's\n   parameters and return types are defined above in the in_func and out_func\n   typedefs.  inflateBack() will call in(in_desc, &buf) which should return the\n   number of bytes of provided input, and a pointer to that input in buf.  If\n   there is no input available, in() must return zero -- buf is ignored in that\n   case -- and inflateBack() will return a buffer error.  inflateBack() will\n   call out(out_desc, buf, len) to write the uncompressed data buf[0..len-1].\n   out() should return zero on success, or non-zero on failure.  If out()\n   returns non-zero, inflateBack() will return with an error.  Neither in() nor\n   out() are permitted to change the contents of the window provided to\n   inflateBackInit(), which is also the buffer that out() uses to write from.\n   The length written by out() will be at most the window size.  Any non-zero\n   amount of input may be provided by in().\n\n     For convenience, inflateBack() can be provided input on the first call by\n   setting strm->next_in and strm->avail_in.  If that input is exhausted, then\n   in() will be called.  Therefore strm->next_in must be initialized before\n   calling inflateBack().  If strm->next_in is Z_NULL, then in() will be called\n   immediately for input.  If strm->next_in is not Z_NULL, then strm->avail_in\n   must also be initialized, and then if strm->avail_in is not zero, input will\n   initially be taken from strm->next_in[0 ..  strm->avail_in - 1].\n\n     The in_desc and out_desc parameters of inflateBack() is passed as the\n   first parameter of in() and out() respectively when they are called.  These\n   descriptors can be optionally used to pass any information that the caller-\n   supplied in() and out() functions need to do their job.\n\n     On return, inflateBack() will set strm->next_in and strm->avail_in to\n   pass back any unused input that was provided by the last in() call.  The\n   return values of inflateBack() can be Z_STREAM_END on success, Z_BUF_ERROR\n   if in() or out() returned an error, Z_DATA_ERROR if there was a format error\n   in the deflate stream (in which case strm->msg is set to indicate the nature\n   of the error), or Z_STREAM_ERROR if the stream was not properly initialized.\n   In the case of Z_BUF_ERROR, an input or output error can be distinguished\n   using strm->next_in which will be Z_NULL only if in() returned an error.  If\n   strm->next_in is not Z_NULL, then the Z_BUF_ERROR was due to out() returning\n   non-zero.  (in() will always be called before out(), so strm->next_in is\n   assured to be defined if out() returns non-zero.)  Note that inflateBack()\n   cannot return Z_OK.\n*/\n\nZEXTERN int ZEXPORT inflateBackEnd OF((z_streamp strm));\n/*\n     All memory allocated by inflateBackInit() is freed.\n\n     inflateBackEnd() returns Z_OK on success, or Z_STREAM_ERROR if the stream\n   state was inconsistent.\n*/\n\nZEXTERN uLong ZEXPORT zlibCompileFlags OF((void));\n/* Return flags indicating compile-time options.\n\n    Type sizes, two bits each, 00 = 16 bits, 01 = 32, 10 = 64, 11 = other:\n     1.0: size of uInt\n     3.2: size of uLong\n     5.4: size of voidpf (pointer)\n     7.6: size of z_off_t\n\n    Compiler, assembler, and debug options:\n     8: ZLIB_DEBUG\n     9: ASMV or ASMINF -- use ASM code\n     10: ZLIB_WINAPI -- exported functions use the WINAPI calling convention\n     11: 0 (reserved)\n\n    One-time table building (smaller code, but not thread-safe if true):\n     12: BUILDFIXED -- build static block decoding tables when needed\n     13: DYNAMIC_CRC_TABLE -- build CRC calculation tables when needed\n     14,15: 0 (reserved)\n\n    Library content (indicates missing functionality):\n     16: NO_GZCOMPRESS -- gz* functions cannot compress (to avoid linking\n                          deflate code when not needed)\n     17: NO_GZIP -- deflate can't write gzip streams, and inflate can't detect\n                    and decode gzip streams (to avoid linking crc code)\n     18-19: 0 (reserved)\n\n    Operation variations (changes in library functionality):\n     20: PKZIP_BUG_WORKAROUND -- slightly more permissive inflate\n     21: FASTEST -- deflate algorithm with only one, lowest compression level\n     22,23: 0 (reserved)\n\n    The sprintf variant used by gzprintf (zero is best):\n     24: 0 = vs*, 1 = s* -- 1 means limited to 20 arguments after the format\n     25: 0 = *nprintf, 1 = *printf -- 1 means gzprintf() not secure!\n     26: 0 = returns value, 1 = void -- 1 means inferred string length returned\n\n    Remainder:\n     27-31: 0 (reserved)\n */\n\n#ifndef Z_SOLO\n\n                        /* utility functions */\n\n/*\n     The following utility functions are implemented on top of the basic\n   stream-oriented functions.  To simplify the interface, some default options\n   are assumed (compression level and memory usage, standard memory allocation\n   functions).  The source code of these utility functions can be modified if\n   you need special options.\n*/\n\nZEXTERN int ZEXPORT compress OF((Bytef *dest,   uLongf *destLen,\n                                 const Bytef *source, uLong sourceLen));\n/*\n     Compresses the source buffer into the destination buffer.  sourceLen is\n   the byte length of the source buffer.  Upon entry, destLen is the total size\n   of the destination buffer, which must be at least the value returned by\n   compressBound(sourceLen).  Upon exit, destLen is the actual size of the\n   compressed data.  compress() is equivalent to compress2() with a level\n   parameter of Z_DEFAULT_COMPRESSION.\n\n     compress returns Z_OK if success, Z_MEM_ERROR if there was not\n   enough memory, Z_BUF_ERROR if there was not enough room in the output\n   buffer.\n*/\n\nZEXTERN int ZEXPORT compress2 OF((Bytef *dest,   uLongf *destLen,\n                                  const Bytef *source, uLong sourceLen,\n                                  int level));\n/*\n     Compresses the source buffer into the destination buffer.  The level\n   parameter has the same meaning as in deflateInit.  sourceLen is the byte\n   length of the source buffer.  Upon entry, destLen is the total size of the\n   destination buffer, which must be at least the value returned by\n   compressBound(sourceLen).  Upon exit, destLen is the actual size of the\n   compressed data.\n\n     compress2 returns Z_OK if success, Z_MEM_ERROR if there was not enough\n   memory, Z_BUF_ERROR if there was not enough room in the output buffer,\n   Z_STREAM_ERROR if the level parameter is invalid.\n*/\n\nZEXTERN uLong ZEXPORT compressBound OF((uLong sourceLen));\n/*\n     compressBound() returns an upper bound on the compressed size after\n   compress() or compress2() on sourceLen bytes.  It would be used before a\n   compress() or compress2() call to allocate the destination buffer.\n*/\n\nZEXTERN int ZEXPORT uncompress OF((Bytef *dest,   uLongf *destLen,\n                                   const Bytef *source, uLong sourceLen));\n/*\n     Decompresses the source buffer into the destination buffer.  sourceLen is\n   the byte length of the source buffer.  Upon entry, destLen is the total size\n   of the destination buffer, which must be large enough to hold the entire\n   uncompressed data.  (The size of the uncompressed data must have been saved\n   previously by the compressor and transmitted to the decompressor by some\n   mechanism outside the scope of this compression library.) Upon exit, destLen\n   is the actual size of the uncompressed data.\n\n     uncompress returns Z_OK if success, Z_MEM_ERROR if there was not\n   enough memory, Z_BUF_ERROR if there was not enough room in the output\n   buffer, or Z_DATA_ERROR if the input data was corrupted or incomplete.  In\n   the case where there is not enough room, uncompress() will fill the output\n   buffer with the uncompressed data up to that point.\n*/\n\nZEXTERN int ZEXPORT uncompress2 OF((Bytef *dest,   uLongf *destLen,\n                                    const Bytef *source, uLong *sourceLen));\n/*\n     Same as uncompress, except that sourceLen is a pointer, where the\n   length of the source is *sourceLen.  On return, *sourceLen is the number of\n   source bytes consumed.\n*/\n\n                        /* gzip file access functions */\n\n/*\n     This library supports reading and writing files in gzip (.gz) format with\n   an interface similar to that of stdio, using the functions that start with\n   \"gz\".  The gzip format is different from the zlib format.  gzip is a gzip\n   wrapper, documented in RFC 1952, wrapped around a deflate stream.\n*/\n\ntypedef struct gzFile_s *gzFile;    /* semi-opaque gzip file descriptor */\n\n/*\nZEXTERN gzFile ZEXPORT gzopen OF((const char *path, const char *mode));\n\n     Opens a gzip (.gz) file for reading or writing.  The mode parameter is as\n   in fopen (\"rb\" or \"wb\") but can also include a compression level (\"wb9\") or\n   a strategy: 'f' for filtered data as in \"wb6f\", 'h' for Huffman-only\n   compression as in \"wb1h\", 'R' for run-length encoding as in \"wb1R\", or 'F'\n   for fixed code compression as in \"wb9F\".  (See the description of\n   deflateInit2 for more information about the strategy parameter.)  'T' will\n   request transparent writing or appending with no compression and not using\n   the gzip format.\n\n     \"a\" can be used instead of \"w\" to request that the gzip stream that will\n   be written be appended to the file.  \"+\" will result in an error, since\n   reading and writing to the same gzip file is not supported.  The addition of\n   \"x\" when writing will create the file exclusively, which fails if the file\n   already exists.  On systems that support it, the addition of \"e\" when\n   reading or writing will set the flag to close the file on an execve() call.\n\n     These functions, as well as gzip, will read and decode a sequence of gzip\n   streams in a file.  The append function of gzopen() can be used to create\n   such a file.  (Also see gzflush() for another way to do this.)  When\n   appending, gzopen does not test whether the file begins with a gzip stream,\n   nor does it look for the end of the gzip streams to begin appending.  gzopen\n   will simply append a gzip stream to the existing file.\n\n     gzopen can be used to read a file which is not in gzip format; in this\n   case gzread will directly read from the file without decompression.  When\n   reading, this will be detected automatically by looking for the magic two-\n   byte gzip header.\n\n     gzopen returns NULL if the file could not be opened, if there was\n   insufficient memory to allocate the gzFile state, or if an invalid mode was\n   specified (an 'r', 'w', or 'a' was not provided, or '+' was provided).\n   errno can be checked to determine if the reason gzopen failed was that the\n   file could not be opened.\n*/\n\nZEXTERN gzFile ZEXPORT gzdopen OF((int fd, const char *mode));\n/*\n     gzdopen associates a gzFile with the file descriptor fd.  File descriptors\n   are obtained from calls like open, dup, creat, pipe or fileno (if the file\n   has been previously opened with fopen).  The mode parameter is as in gzopen.\n\n     The next call of gzclose on the returned gzFile will also close the file\n   descriptor fd, just like fclose(fdopen(fd, mode)) closes the file descriptor\n   fd.  If you want to keep fd open, use fd = dup(fd_keep); gz = gzdopen(fd,\n   mode);.  The duplicated descriptor should be saved to avoid a leak, since\n   gzdopen does not close fd if it fails.  If you are using fileno() to get the\n   file descriptor from a FILE *, then you will have to use dup() to avoid\n   double-close()ing the file descriptor.  Both gzclose() and fclose() will\n   close the associated file descriptor, so they need to have different file\n   descriptors.\n\n     gzdopen returns NULL if there was insufficient memory to allocate the\n   gzFile state, if an invalid mode was specified (an 'r', 'w', or 'a' was not\n   provided, or '+' was provided), or if fd is -1.  The file descriptor is not\n   used until the next gz* read, write, seek, or close operation, so gzdopen\n   will not detect if fd is invalid (unless fd is -1).\n*/\n\nZEXTERN int ZEXPORT gzbuffer OF((gzFile file, unsigned size));\n/*\n     Set the internal buffer size used by this library's functions.  The\n   default buffer size is 8192 bytes.  This function must be called after\n   gzopen() or gzdopen(), and before any other calls that read or write the\n   file.  The buffer memory allocation is always deferred to the first read or\n   write.  Three times that size in buffer space is allocated.  A larger buffer\n   size of, for example, 64K or 128K bytes will noticeably increase the speed\n   of decompression (reading).\n\n     The new buffer size also affects the maximum length for gzprintf().\n\n     gzbuffer() returns 0 on success, or -1 on failure, such as being called\n   too late.\n*/\n\nZEXTERN int ZEXPORT gzsetparams OF((gzFile file, int level, int strategy));\n/*\n     Dynamically update the compression level or strategy.  See the description\n   of deflateInit2 for the meaning of these parameters.  Previously provided\n   data is flushed before the parameter change.\n\n     gzsetparams returns Z_OK if success, Z_STREAM_ERROR if the file was not\n   opened for writing, Z_ERRNO if there is an error writing the flushed data,\n   or Z_MEM_ERROR if there is a memory allocation error.\n*/\n\nZEXTERN int ZEXPORT gzread OF((gzFile file, voidp buf, unsigned len));\n/*\n     Reads the given number of uncompressed bytes from the compressed file.  If\n   the input file is not in gzip format, gzread copies the given number of\n   bytes into the buffer directly from the file.\n\n     After reaching the end of a gzip stream in the input, gzread will continue\n   to read, looking for another gzip stream.  Any number of gzip streams may be\n   concatenated in the input file, and will all be decompressed by gzread().\n   If something other than a gzip stream is encountered after a gzip stream,\n   that remaining trailing garbage is ignored (and no error is returned).\n\n     gzread can be used to read a gzip file that is being concurrently written.\n   Upon reaching the end of the input, gzread will return with the available\n   data.  If the error code returned by gzerror is Z_OK or Z_BUF_ERROR, then\n   gzclearerr can be used to clear the end of file indicator in order to permit\n   gzread to be tried again.  Z_OK indicates that a gzip stream was completed\n   on the last gzread.  Z_BUF_ERROR indicates that the input file ended in the\n   middle of a gzip stream.  Note that gzread does not return -1 in the event\n   of an incomplete gzip stream.  This error is deferred until gzclose(), which\n   will return Z_BUF_ERROR if the last gzread ended in the middle of a gzip\n   stream.  Alternatively, gzerror can be used before gzclose to detect this\n   case.\n\n     gzread returns the number of uncompressed bytes actually read, less than\n   len for end of file, or -1 for error.  If len is too large to fit in an int,\n   then nothing is read, -1 is returned, and the error state is set to\n   Z_STREAM_ERROR.\n*/\n\nZEXTERN z_size_t ZEXPORT gzfread OF((voidp buf, z_size_t size, z_size_t nitems,\n                                     gzFile file));\n/*\n     Read up to nitems items of size size from file to buf, otherwise operating\n   as gzread() does.  This duplicates the interface of stdio's fread(), with\n   size_t request and return types.  If the library defines size_t, then\n   z_size_t is identical to size_t.  If not, then z_size_t is an unsigned\n   integer type that can contain a pointer.\n\n     gzfread() returns the number of full items read of size size, or zero if\n   the end of the file was reached and a full item could not be read, or if\n   there was an error.  gzerror() must be consulted if zero is returned in\n   order to determine if there was an error.  If the multiplication of size and\n   nitems overflows, i.e. the product does not fit in a z_size_t, then nothing\n   is read, zero is returned, and the error state is set to Z_STREAM_ERROR.\n\n     In the event that the end of file is reached and only a partial item is\n   available at the end, i.e. the remaining uncompressed data length is not a\n   multiple of size, then the final partial item is nevetheless read into buf\n   and the end-of-file flag is set.  The length of the partial item read is not\n   provided, but could be inferred from the result of gztell().  This behavior\n   is the same as the behavior of fread() implementations in common libraries,\n   but it prevents the direct use of gzfread() to read a concurrently written\n   file, reseting and retrying on end-of-file, when size is not 1.\n*/\n\nZEXTERN int ZEXPORT gzwrite OF((gzFile file,\n                                voidpc buf, unsigned len));\n/*\n     Writes the given number of uncompressed bytes into the compressed file.\n   gzwrite returns the number of uncompressed bytes written or 0 in case of\n   error.\n*/\n\nZEXTERN z_size_t ZEXPORT gzfwrite OF((voidpc buf, z_size_t size,\n                                      z_size_t nitems, gzFile file));\n/*\n     gzfwrite() writes nitems items of size size from buf to file, duplicating\n   the interface of stdio's fwrite(), with size_t request and return types.  If\n   the library defines size_t, then z_size_t is identical to size_t.  If not,\n   then z_size_t is an unsigned integer type that can contain a pointer.\n\n     gzfwrite() returns the number of full items written of size size, or zero\n   if there was an error.  If the multiplication of size and nitems overflows,\n   i.e. the product does not fit in a z_size_t, then nothing is written, zero\n   is returned, and the error state is set to Z_STREAM_ERROR.\n*/\n\nZEXTERN int ZEXPORTVA gzprintf Z_ARG((gzFile file, const char *format, ...));\n/*\n     Converts, formats, and writes the arguments to the compressed file under\n   control of the format string, as in fprintf.  gzprintf returns the number of\n   uncompressed bytes actually written, or a negative zlib error code in case\n   of error.  The number of uncompressed bytes written is limited to 8191, or\n   one less than the buffer size given to gzbuffer().  The caller should assure\n   that this limit is not exceeded.  If it is exceeded, then gzprintf() will\n   return an error (0) with nothing written.  In this case, there may also be a\n   buffer overflow with unpredictable consequences, which is possible only if\n   zlib was compiled with the insecure functions sprintf() or vsprintf()\n   because the secure snprintf() or vsnprintf() functions were not available.\n   This can be determined using zlibCompileFlags().\n*/\n\nZEXTERN int ZEXPORT gzputs OF((gzFile file, const char *s));\n/*\n     Writes the given null-terminated string to the compressed file, excluding\n   the terminating null character.\n\n     gzputs returns the number of characters written, or -1 in case of error.\n*/\n\nZEXTERN char * ZEXPORT gzgets OF((gzFile file, char *buf, int len));\n/*\n     Reads bytes from the compressed file until len-1 characters are read, or a\n   newline character is read and transferred to buf, or an end-of-file\n   condition is encountered.  If any characters are read or if len == 1, the\n   string is terminated with a null character.  If no characters are read due\n   to an end-of-file or len < 1, then the buffer is left untouched.\n\n     gzgets returns buf which is a null-terminated string, or it returns NULL\n   for end-of-file or in case of error.  If there was an error, the contents at\n   buf are indeterminate.\n*/\n\nZEXTERN int ZEXPORT gzputc OF((gzFile file, int c));\n/*\n     Writes c, converted to an unsigned char, into the compressed file.  gzputc\n   returns the value that was written, or -1 in case of error.\n*/\n\nZEXTERN int ZEXPORT gzgetc OF((gzFile file));\n/*\n     Reads one byte from the compressed file.  gzgetc returns this byte or -1\n   in case of end of file or error.  This is implemented as a macro for speed.\n   As such, it does not do all of the checking the other functions do.  I.e.\n   it does not check to see if file is NULL, nor whether the structure file\n   points to has been clobbered or not.\n*/\n\nZEXTERN int ZEXPORT gzungetc OF((int c, gzFile file));\n/*\n     Push one character back onto the stream to be read as the first character\n   on the next read.  At least one character of push-back is allowed.\n   gzungetc() returns the character pushed, or -1 on failure.  gzungetc() will\n   fail if c is -1, and may fail if a character has been pushed but not read\n   yet.  If gzungetc is used immediately after gzopen or gzdopen, at least the\n   output buffer size of pushed characters is allowed.  (See gzbuffer above.)\n   The pushed character will be discarded if the stream is repositioned with\n   gzseek() or gzrewind().\n*/\n\nZEXTERN int ZEXPORT gzflush OF((gzFile file, int flush));\n/*\n     Flushes all pending output into the compressed file.  The parameter flush\n   is as in the deflate() function.  The return value is the zlib error number\n   (see function gzerror below).  gzflush is only permitted when writing.\n\n     If the flush parameter is Z_FINISH, the remaining data is written and the\n   gzip stream is completed in the output.  If gzwrite() is called again, a new\n   gzip stream will be started in the output.  gzread() is able to read such\n   concatenated gzip streams.\n\n     gzflush should be called only when strictly necessary because it will\n   degrade compression if called too often.\n*/\n\n/*\nZEXTERN z_off_t ZEXPORT gzseek OF((gzFile file,\n                                   z_off_t offset, int whence));\n\n     Sets the starting position for the next gzread or gzwrite on the given\n   compressed file.  The offset represents a number of bytes in the\n   uncompressed data stream.  The whence parameter is defined as in lseek(2);\n   the value SEEK_END is not supported.\n\n     If the file is opened for reading, this function is emulated but can be\n   extremely slow.  If the file is opened for writing, only forward seeks are\n   supported; gzseek then compresses a sequence of zeroes up to the new\n   starting position.\n\n     gzseek returns the resulting offset location as measured in bytes from\n   the beginning of the uncompressed stream, or -1 in case of error, in\n   particular if the file is opened for writing and the new starting position\n   would be before the current position.\n*/\n\nZEXTERN int ZEXPORT    gzrewind OF((gzFile file));\n/*\n     Rewinds the given file. This function is supported only for reading.\n\n     gzrewind(file) is equivalent to (int)gzseek(file, 0L, SEEK_SET)\n*/\n\n/*\nZEXTERN z_off_t ZEXPORT    gztell OF((gzFile file));\n\n     Returns the starting position for the next gzread or gzwrite on the given\n   compressed file.  This position represents a number of bytes in the\n   uncompressed data stream, and is zero when starting, even if appending or\n   reading a gzip stream from the middle of a file using gzdopen().\n\n     gztell(file) is equivalent to gzseek(file, 0L, SEEK_CUR)\n*/\n\n/*\nZEXTERN z_off_t ZEXPORT gzoffset OF((gzFile file));\n\n     Returns the current offset in the file being read or written.  This offset\n   includes the count of bytes that precede the gzip stream, for example when\n   appending or when using gzdopen() for reading.  When reading, the offset\n   does not include as yet unused buffered input.  This information can be used\n   for a progress indicator.  On error, gzoffset() returns -1.\n*/\n\nZEXTERN int ZEXPORT gzeof OF((gzFile file));\n/*\n     Returns true (1) if the end-of-file indicator has been set while reading,\n   false (0) otherwise.  Note that the end-of-file indicator is set only if the\n   read tried to go past the end of the input, but came up short.  Therefore,\n   just like feof(), gzeof() may return false even if there is no more data to\n   read, in the event that the last read request was for the exact number of\n   bytes remaining in the input file.  This will happen if the input file size\n   is an exact multiple of the buffer size.\n\n     If gzeof() returns true, then the read functions will return no more data,\n   unless the end-of-file indicator is reset by gzclearerr() and the input file\n   has grown since the previous end of file was detected.\n*/\n\nZEXTERN int ZEXPORT gzdirect OF((gzFile file));\n/*\n     Returns true (1) if file is being copied directly while reading, or false\n   (0) if file is a gzip stream being decompressed.\n\n     If the input file is empty, gzdirect() will return true, since the input\n   does not contain a gzip stream.\n\n     If gzdirect() is used immediately after gzopen() or gzdopen() it will\n   cause buffers to be allocated to allow reading the file to determine if it\n   is a gzip file.  Therefore if gzbuffer() is used, it should be called before\n   gzdirect().\n\n     When writing, gzdirect() returns true (1) if transparent writing was\n   requested (\"wT\" for the gzopen() mode), or false (0) otherwise.  (Note:\n   gzdirect() is not needed when writing.  Transparent writing must be\n   explicitly requested, so the application already knows the answer.  When\n   linking statically, using gzdirect() will include all of the zlib code for\n   gzip file reading and decompression, which may not be desired.)\n*/\n\nZEXTERN int ZEXPORT    gzclose OF((gzFile file));\n/*\n     Flushes all pending output if necessary, closes the compressed file and\n   deallocates the (de)compression state.  Note that once file is closed, you\n   cannot call gzerror with file, since its structures have been deallocated.\n   gzclose must not be called more than once on the same file, just as free\n   must not be called more than once on the same allocation.\n\n     gzclose will return Z_STREAM_ERROR if file is not valid, Z_ERRNO on a\n   file operation error, Z_MEM_ERROR if out of memory, Z_BUF_ERROR if the\n   last read ended in the middle of a gzip stream, or Z_OK on success.\n*/\n\nZEXTERN int ZEXPORT gzclose_r OF((gzFile file));\nZEXTERN int ZEXPORT gzclose_w OF((gzFile file));\n/*\n     Same as gzclose(), but gzclose_r() is only for use when reading, and\n   gzclose_w() is only for use when writing or appending.  The advantage to\n   using these instead of gzclose() is that they avoid linking in zlib\n   compression or decompression code that is not used when only reading or only\n   writing respectively.  If gzclose() is used, then both compression and\n   decompression code will be included the application when linking to a static\n   zlib library.\n*/\n\nZEXTERN const char * ZEXPORT gzerror OF((gzFile file, int *errnum));\n/*\n     Returns the error message for the last error which occurred on the given\n   compressed file.  errnum is set to zlib error number.  If an error occurred\n   in the file system and not in the compression library, errnum is set to\n   Z_ERRNO and the application may consult errno to get the exact error code.\n\n     The application must not modify the returned string.  Future calls to\n   this function may invalidate the previously returned string.  If file is\n   closed, then the string previously returned by gzerror will no longer be\n   available.\n\n     gzerror() should be used to distinguish errors from end-of-file for those\n   functions above that do not distinguish those cases in their return values.\n*/\n\nZEXTERN void ZEXPORT gzclearerr OF((gzFile file));\n/*\n     Clears the error and end-of-file flags for file.  This is analogous to the\n   clearerr() function in stdio.  This is useful for continuing to read a gzip\n   file that is being written concurrently.\n*/\n\n#endif /* !Z_SOLO */\n\n                        /* checksum functions */\n\n/*\n     These functions are not related to compression but are exported\n   anyway because they might be useful in applications using the compression\n   library.\n*/\n\nZEXTERN uLong ZEXPORT adler32 OF((uLong adler, const Bytef *buf, uInt len));\n/*\n     Update a running Adler-32 checksum with the bytes buf[0..len-1] and\n   return the updated checksum.  If buf is Z_NULL, this function returns the\n   required initial value for the checksum.\n\n     An Adler-32 checksum is almost as reliable as a CRC-32 but can be computed\n   much faster.\n\n   Usage example:\n\n     uLong adler = adler32(0L, Z_NULL, 0);\n\n     while (read_buffer(buffer, length) != EOF) {\n       adler = adler32(adler, buffer, length);\n     }\n     if (adler != original_adler) error();\n*/\n\nZEXTERN uLong ZEXPORT adler32_z OF((uLong adler, const Bytef *buf,\n                                    z_size_t len));\n/*\n     Same as adler32(), but with a size_t length.\n*/\n\n/*\nZEXTERN uLong ZEXPORT adler32_combine OF((uLong adler1, uLong adler2,\n                                          z_off_t len2));\n\n     Combine two Adler-32 checksums into one.  For two sequences of bytes, seq1\n   and seq2 with lengths len1 and len2, Adler-32 checksums were calculated for\n   each, adler1 and adler2.  adler32_combine() returns the Adler-32 checksum of\n   seq1 and seq2 concatenated, requiring only adler1, adler2, and len2.  Note\n   that the z_off_t type (like off_t) is a signed integer.  If len2 is\n   negative, the result has no meaning or utility.\n*/\n\nZEXTERN uLong ZEXPORT crc32   OF((uLong crc, const Bytef *buf, uInt len));\n/*\n     Update a running CRC-32 with the bytes buf[0..len-1] and return the\n   updated CRC-32.  If buf is Z_NULL, this function returns the required\n   initial value for the crc.  Pre- and post-conditioning (one's complement) is\n   performed within this function so it shouldn't be done by the application.\n\n   Usage example:\n\n     uLong crc = crc32(0L, Z_NULL, 0);\n\n     while (read_buffer(buffer, length) != EOF) {\n       crc = crc32(crc, buffer, length);\n     }\n     if (crc != original_crc) error();\n*/\n\nZEXTERN uLong ZEXPORT crc32_z OF((uLong adler, const Bytef *buf,\n                                  z_size_t len));\n/*\n     Same as crc32(), but with a size_t length.\n*/\n\n/*\nZEXTERN uLong ZEXPORT crc32_combine OF((uLong crc1, uLong crc2, z_off_t len2));\n\n     Combine two CRC-32 check values into one.  For two sequences of bytes,\n   seq1 and seq2 with lengths len1 and len2, CRC-32 check values were\n   calculated for each, crc1 and crc2.  crc32_combine() returns the CRC-32\n   check value of seq1 and seq2 concatenated, requiring only crc1, crc2, and\n   len2.\n*/\n\n\n                        /* various hacks, don't look :) */\n\n/* deflateInit and inflateInit are macros to allow checking the zlib version\n * and the compiler's view of z_stream:\n */\nZEXTERN int ZEXPORT deflateInit_ OF((z_streamp strm, int level,\n                                     const char *version, int stream_size));\nZEXTERN int ZEXPORT inflateInit_ OF((z_streamp strm,\n                                     const char *version, int stream_size));\nZEXTERN int ZEXPORT deflateInit2_ OF((z_streamp strm, int  level, int  method,\n                                      int windowBits, int memLevel,\n                                      int strategy, const char *version,\n                                      int stream_size));\nZEXTERN int ZEXPORT inflateInit2_ OF((z_streamp strm, int  windowBits,\n                                      const char *version, int stream_size));\nZEXTERN int ZEXPORT inflateBackInit_ OF((z_streamp strm, int windowBits,\n                                         unsigned char FAR *window,\n                                         const char *version,\n                                         int stream_size));\n#ifdef Z_PREFIX_SET\n#  define z_deflateInit(strm, level) \\\n          deflateInit_((strm), (level), ZLIB_VERSION, (int)sizeof(z_stream))\n#  define z_inflateInit(strm) \\\n          inflateInit_((strm), ZLIB_VERSION, (int)sizeof(z_stream))\n#  define z_deflateInit2(strm, level, method, windowBits, memLevel, strategy) \\\n          deflateInit2_((strm),(level),(method),(windowBits),(memLevel),\\\n                        (strategy), ZLIB_VERSION, (int)sizeof(z_stream))\n#  define z_inflateInit2(strm, windowBits) \\\n          inflateInit2_((strm), (windowBits), ZLIB_VERSION, \\\n                        (int)sizeof(z_stream))\n#  define z_inflateBackInit(strm, windowBits, window) \\\n          inflateBackInit_((strm), (windowBits), (window), \\\n                           ZLIB_VERSION, (int)sizeof(z_stream))\n#else\n#  define deflateInit(strm, level) \\\n          deflateInit_((strm), (level), ZLIB_VERSION, (int)sizeof(z_stream))\n#  define inflateInit(strm) \\\n          inflateInit_((strm), ZLIB_VERSION, (int)sizeof(z_stream))\n#  define deflateInit2(strm, level, method, windowBits, memLevel, strategy) \\\n          deflateInit2_((strm),(level),(method),(windowBits),(memLevel),\\\n                        (strategy), ZLIB_VERSION, (int)sizeof(z_stream))\n#  define inflateInit2(strm, windowBits) \\\n          inflateInit2_((strm), (windowBits), ZLIB_VERSION, \\\n                        (int)sizeof(z_stream))\n#  define inflateBackInit(strm, windowBits, window) \\\n          inflateBackInit_((strm), (windowBits), (window), \\\n                           ZLIB_VERSION, (int)sizeof(z_stream))\n#endif\n\n#ifndef Z_SOLO\n\n/* gzgetc() macro and its supporting function and exposed data structure.  Note\n * that the real internal state is much larger than the exposed structure.\n * This abbreviated structure exposes just enough for the gzgetc() macro.  The\n * user should not mess with these exposed elements, since their names or\n * behavior could change in the future, perhaps even capriciously.  They can\n * only be used by the gzgetc() macro.  You have been warned.\n */\nstruct gzFile_s {\n    unsigned have;\n    unsigned char *next;\n    z_off64_t pos;\n};\nZEXTERN int ZEXPORT gzgetc_ OF((gzFile file));  /* backward compatibility */\n#ifdef Z_PREFIX_SET\n#  undef z_gzgetc\n#  define z_gzgetc(g) \\\n          ((g)->have ? ((g)->have--, (g)->pos++, *((g)->next)++) : (gzgetc)(g))\n#else\n#  define gzgetc(g) \\\n          ((g)->have ? ((g)->have--, (g)->pos++, *((g)->next)++) : (gzgetc)(g))\n#endif\n\n/* provide 64-bit offset functions if _LARGEFILE64_SOURCE defined, and/or\n * change the regular functions to 64 bits if _FILE_OFFSET_BITS is 64 (if\n * both are true, the application gets the *64 functions, and the regular\n * functions are changed to 64 bits) -- in case these are set on systems\n * without large file support, _LFS64_LARGEFILE must also be true\n */\n#ifdef Z_LARGE64\n   ZEXTERN gzFile ZEXPORT gzopen64 OF((const char *, const char *));\n   ZEXTERN z_off64_t ZEXPORT gzseek64 OF((gzFile, z_off64_t, int));\n   ZEXTERN z_off64_t ZEXPORT gztell64 OF((gzFile));\n   ZEXTERN z_off64_t ZEXPORT gzoffset64 OF((gzFile));\n   ZEXTERN uLong ZEXPORT adler32_combine64 OF((uLong, uLong, z_off64_t));\n   ZEXTERN uLong ZEXPORT crc32_combine64 OF((uLong, uLong, z_off64_t));\n#endif\n\n#if !defined(ZLIB_INTERNAL) && defined(Z_WANT64)\n#  ifdef Z_PREFIX_SET\n#    define z_gzopen z_gzopen64\n#    define z_gzseek z_gzseek64\n#    define z_gztell z_gztell64\n#    define z_gzoffset z_gzoffset64\n#    define z_adler32_combine z_adler32_combine64\n#    define z_crc32_combine z_crc32_combine64\n#  else\n#    define gzopen gzopen64\n#    define gzseek gzseek64\n#    define gztell gztell64\n#    define gzoffset gzoffset64\n#    define adler32_combine adler32_combine64\n#    define crc32_combine crc32_combine64\n#  endif\n#  ifndef Z_LARGE64\n     ZEXTERN gzFile ZEXPORT gzopen64 OF((const char *, const char *));\n     ZEXTERN z_off_t ZEXPORT gzseek64 OF((gzFile, z_off_t, int));\n     ZEXTERN z_off_t ZEXPORT gztell64 OF((gzFile));\n     ZEXTERN z_off_t ZEXPORT gzoffset64 OF((gzFile));\n     ZEXTERN uLong ZEXPORT adler32_combine64 OF((uLong, uLong, z_off_t));\n     ZEXTERN uLong ZEXPORT crc32_combine64 OF((uLong, uLong, z_off_t));\n#  endif\n#else\n   ZEXTERN gzFile ZEXPORT gzopen OF((const char *, const char *));\n   ZEXTERN z_off_t ZEXPORT gzseek OF((gzFile, z_off_t, int));\n   ZEXTERN z_off_t ZEXPORT gztell OF((gzFile));\n   ZEXTERN z_off_t ZEXPORT gzoffset OF((gzFile));\n   ZEXTERN uLong ZEXPORT adler32_combine OF((uLong, uLong, z_off_t));\n   ZEXTERN uLong ZEXPORT crc32_combine OF((uLong, uLong, z_off_t));\n#endif\n\n#else /* Z_SOLO */\n\n   ZEXTERN uLong ZEXPORT adler32_combine OF((uLong, uLong, z_off_t));\n   ZEXTERN uLong ZEXPORT crc32_combine OF((uLong, uLong, z_off_t));\n\n#endif /* !Z_SOLO */\n\n/* undocumented functions */\nZEXTERN const char   * ZEXPORT zError           OF((int));\nZEXTERN int            ZEXPORT inflateSyncPoint OF((z_streamp));\nZEXTERN const z_crc_t FAR * ZEXPORT get_crc_table    OF((void));\nZEXTERN int            ZEXPORT inflateUndermine OF((z_streamp, int));\nZEXTERN int            ZEXPORT inflateValidate OF((z_streamp, int));\nZEXTERN unsigned long  ZEXPORT inflateCodesUsed OF ((z_streamp));\nZEXTERN int            ZEXPORT inflateResetKeep OF((z_streamp));\nZEXTERN int            ZEXPORT deflateResetKeep OF((z_streamp));\n#if (defined(_WIN32) || defined(__CYGWIN__)) && !defined(Z_SOLO)\nZEXTERN gzFile         ZEXPORT gzopen_w OF((const wchar_t *path,\n                                            const char *mode));\n#endif\n#if defined(STDC) || defined(Z_HAVE_STDARG_H)\n#  ifndef Z_SOLO\nZEXTERN int            ZEXPORTVA gzvprintf Z_ARG((gzFile file,\n                                                  const char *format,\n                                                  va_list va));\n#  endif\n#endif\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* ZLIB_H */\n"
  },
  {
    "path": "tools/templates/.swiftlint.yml",
    "content": "disabled_rules:\n  - fallthrough\n  - cyclomatic_complexity\n  - file_length\n  - function_parameter_count\n  - todo\n  - function_body_length\n  - type_body_length\n  - nesting\n  - generic_type_name\n  - identifier_name\n  - type_name\n  - line_length\n  - force_cast"
  },
  {
    "path": "tools/templates/archive/archive.sh",
    "content": "#!/usr/make\n\n# prepare source\nworking_directory=`pwd`\ncodesnippets_zip=\"$working_directory\"/codesnippets.zip\nxctemplates_zip=\"$working_directory\"/xctemplates.zip\n\ncd \"$working_directory\"/../codesnippets && zip -r \"$codesnippets_zip\" * && cd \"$working_directory\"\ncd \"$working_directory\"/../xctemplates && zip -r \"$xctemplates_zip\" * && cd \"$working_directory\"\n"
  },
  {
    "path": "tools/templates/codesnippets/WCDB.ColumnCodableClass.Data.swift.codesnippet",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">\n<plist version=\"1.0\">\n<dict>\n\t<key>IDECodeSnippetCompletionPrefix</key>\n\t<string>ColumnCodable Data Class</string>\n\t<key>IDECodeSnippetCompletionScopes</key>\n\t<array>\n\t\t<string>All</string>\n\t</array>\n\t<key>IDECodeSnippetContents</key>\n\t<string>class &lt;#Class name#&gt;: WCDB.ColumnCodable, WCDB.LiteralValueConvertible, WCDB.ExpressionCanBeOperated {\n\tstatic var columnType: ColumnType {\n\t\treturn .BLOB\n\t}\n    \n    required init?(with value: WCDB.Value) {\n    \t&lt;#init with value.dataValue#&gt;\n    }\n    \n    func archivedValue() -&gt; WCDB.Value {\n        return WCDB.Value(&lt;#Data#&gt;)\n    }\n}\n</string>\n\t<key>IDECodeSnippetIdentifier</key>\n\t<string>BD03E1A2-9D1B-432B-B7B8-4AD3BC19023C</string>\n\t<key>IDECodeSnippetLanguage</key>\n\t<string>Xcode.SourceCodeLanguage.Swift</string>\n\t<key>IDECodeSnippetTitle</key>\n\t<string>ColumnCodable Data Snippet</string>\n\t<key>IDECodeSnippetUserSnippet</key>\n\t<true/>\n\t<key>IDECodeSnippetVersion</key>\n\t<integer>0</integer>\n</dict>\n</plist>\n"
  },
  {
    "path": "tools/templates/codesnippets/WCDB.ColumnCodableClass.Double.swift.codesnippet",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">\n<plist version=\"1.0\">\n<dict>\n\t<key>IDECodeSnippetCompletionPrefix</key>\n\t<string>ColumnCodable Double Class</string>\n\t<key>IDECodeSnippetCompletionScopes</key>\n\t<array>\n\t\t<string>All</string>\n\t</array>\n\t<key>IDECodeSnippetContents</key>\n\t<string>class &lt;#Class name#&gt;: WCDB.ColumnCodable, WCDB.LiteralValueConvertible, WCDB.ExpressionCanBeOperated {\n\tstatic var columnType: ColumnType {\n\t\treturn .float\n\t}\n    \n    required init?(with value: WCDB.Value) {\n    \t&lt;#init with value.doubleValue#&gt;\n    }\n    \n    func archivedValue() -&gt; WCDB.Value {\n        return WCDB.Value(&lt;#Double#&gt;)\n    }\n}\n</string>\n\t<key>IDECodeSnippetIdentifier</key>\n\t<string>BD03E1A2-9D1B-432B-B7B8-4AD3BC19023C</string>\n\t<key>IDECodeSnippetLanguage</key>\n\t<string>Xcode.SourceCodeLanguage.Swift</string>\n\t<key>IDECodeSnippetTitle</key>\n\t<string>ColumnCodable Double Snippet</string>\n\t<key>IDECodeSnippetUserSnippet</key>\n\t<true/>\n\t<key>IDECodeSnippetVersion</key>\n\t<integer>0</integer>\n</dict>\n</plist>\n"
  },
  {
    "path": "tools/templates/codesnippets/WCDB.ColumnCodableClass.Int32.swift.codesnippet",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">\n<plist version=\"1.0\">\n<dict>\n\t<key>IDECodeSnippetCompletionPrefix</key>\n\t<string>ColumnCodable Int32 Class</string>\n\t<key>IDECodeSnippetCompletionScopes</key>\n\t<array>\n\t\t<string>All</string>\n\t</array>\n\t<key>IDECodeSnippetContents</key>\n\t<string>class &lt;#Class name#&gt;: WCDB.ColumnCodable, WCDB.LiteralValueConvertible, WCDB.ExpressionCanBeOperated {\n\tstatic var columnType: ColumnType {\n\t\treturn .integer32\n\t}\n    \n    required init?(with value: WCDB.Value) {\n    \t&lt;#init with value.int32Value#&gt;\n    }\n    \n    func archivedValue() -&gt; WCDB.Value {\n        return WCDB.Value(&lt;#Int32#&gt;)\n    }\n}\n</string>\n\t<key>IDECodeSnippetIdentifier</key>\n\t<string>BD03E1A2-9D1B-432B-B7B8-4AD3BC19023C</string>\n\t<key>IDECodeSnippetLanguage</key>\n\t<string>Xcode.SourceCodeLanguage.Swift</string>\n\t<key>IDECodeSnippetTitle</key>\n\t<string>ColumnCodable Int32 Snippet</string>\n\t<key>IDECodeSnippetUserSnippet</key>\n\t<true/>\n\t<key>IDECodeSnippetVersion</key>\n\t<integer>0</integer>\n</dict>\n</plist>\n"
  },
  {
    "path": "tools/templates/codesnippets/WCDB.ColumnCodableClass.Int64.swift.codesnippet",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">\n<plist version=\"1.0\">\n<dict>\n\t<key>IDECodeSnippetCompletionPrefix</key>\n\t<string>ColumnCodable Int64 Class</string>\n\t<key>IDECodeSnippetCompletionScopes</key>\n\t<array>\n\t\t<string>All</string>\n\t</array>\n\t<key>IDECodeSnippetContents</key>\n\t<string>class &lt;#Class name#&gt;: WCDB.ColumnCodable, WCDB.LiteralValueConvertible, WCDB.ExpressionCanBeOperated {\n\tstatic var columnType: ColumnType {\n\t\treturn .integer64\n\t}\n    \n    required init?(with value: WCDB.Value) {\n    \t&lt;#init with value.int64Value#&gt;\n    }\n    \n    func archivedValue() -&gt; WCDB.Value {\n        return WCDB.Value(&lt;#Int64#&gt;)\n    }\n}\n</string>\n\t<key>IDECodeSnippetIdentifier</key>\n\t<string>BD03E1A2-9D1B-432B-B7B8-4AD3BC19023C</string>\n\t<key>IDECodeSnippetLanguage</key>\n\t<string>Xcode.SourceCodeLanguage.Swift</string>\n\t<key>IDECodeSnippetTitle</key>\n\t<string>ColumnCodable Int64 Snippet</string>\n\t<key>IDECodeSnippetUserSnippet</key>\n\t<true/>\n\t<key>IDECodeSnippetVersion</key>\n\t<integer>0</integer>\n</dict>\n</plist>\n"
  },
  {
    "path": "tools/templates/codesnippets/WCDB.ColumnCodableClass.String.swift.codesnippet",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">\n<plist version=\"1.0\">\n<dict>\n\t<key>IDECodeSnippetCompletionPrefix</key>\n\t<string>ColumnCodable String Class</string>\n\t<key>IDECodeSnippetCompletionScopes</key>\n\t<array>\n\t\t<string>All</string>\n\t</array>\n\t<key>IDECodeSnippetContents</key>\n\t<string>class &lt;#Class name#&gt;: WCDB.ColumnCodable, WCDB.LiteralValueConvertible, WCDB.ExpressionCanBeOperated {\n\tstatic var columnType: ColumnType {\n\t\treturn .text\n\t}\n    \n    required init?(with value: WCDB.Value) {\n    \t&lt;#init with value.stringValue#&gt;\n    }\n    \n    func archivedValue() -&gt; WCDB.Value {\n        return WCDB.Value(&lt;#String#&gt;)\n    }\n}\n</string>\n\t<key>IDECodeSnippetIdentifier</key>\n\t<string>BD03E1A2-9D1B-432B-B7B8-4AD3BC19023C</string>\n\t<key>IDECodeSnippetLanguage</key>\n\t<string>Xcode.SourceCodeLanguage.Swift</string>\n\t<key>IDECodeSnippetTitle</key>\n\t<string>ColumnCodable String Snippet</string>\n\t<key>IDECodeSnippetUserSnippet</key>\n\t<true/>\n\t<key>IDECodeSnippetVersion</key>\n\t<integer>0</integer>\n</dict>\n</plist>\n"
  },
  {
    "path": "tools/templates/codesnippets/WCDB.TableCodableClass.swift.codesnippet",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">\n<plist version=\"1.0\">\n<dict>\n\t<key>IDECodeSnippetCompletionPrefix</key>\n\t<string>TableCodableClass</string>\n\t<key>IDECodeSnippetCompletionScopes</key>\n\t<array>\n\t\t<string>All</string>\n\t</array>\n\t<key>IDECodeSnippetContents</key>\n\t<string>class &lt;#Class name#&gt;: WCDB.TableCodable {\n    //Your own properties\n        var variable1: Int = 0\n    var variable2: String? // Optional if it would be nil in some WCDB selection.\n    var variable3: Double? // Optional if it would be nil in some WCDB selection.\n    let invalid: Int = 0 // An initialized constant property is not allowed.\n    let unbound: Date? = nil\n        \n    enum CodingKeys: String, CodingTableKey {\n        typealias Root = Temp;\n        \n        //List the properties which should be bound to table.\n        case variable1 = \"custom_name\"\n        case variable2\n        case variable3\n        \n        static let objectRelationalMapping = TableBinding(CodingKeys.self) {\n            //Column constraints for primary key, unique, not null, default value and so on. It is optional.\n            //BindColumnConstraint(.variable1, isPrimary: true, isAutoIncrement: true)\n            //BindColumnConstraint(.variable2, isUnique: true)\n            \n            //Index bindings. It is optional.\n            //BindIndex(.variable2, namedWith: \"_index\")\n            \n            //Table constraints for multi-primary, multi-unique and so on. It is optional.\n            //BindMultiPrimary(.variable2, .variable3)\n            \n            //Virtual table binding for FTS and so on. It is optional.\n            //BindVirtualTable(withModule: .FTS5, and: BuiltinTokenizer.Verbatim)\n        }\n    }\n    \n    //Properties below are needed when the primary key is auto-increment.\n    //var isAutoIncrement: Bool = false\n    //var lastInsertedRowID: Int64 = 0\n}</string>\n\t<key>IDECodeSnippetIdentifier</key>\n\t<string>4A806509-68C8-4F42-9E3F-0AB87DCA7ED7</string>\n\t<key>IDECodeSnippetLanguage</key>\n\t<string>Xcode.SourceCodeLanguage.Swift</string>\n\t<key>IDECodeSnippetTitle</key>\n\t<string>TableCodable Snippet</string>\n\t<key>IDECodeSnippetUserSnippet</key>\n\t<true/>\n\t<key>IDECodeSnippetVersion</key>\n\t<integer>2</integer>\n</dict>\n</plist>\n"
  },
  {
    "path": "tools/templates/install.sh",
    "content": "#!/usr/make\n\n# prepare source\ncodesnippets_zip=codesnippets.zip\nxctemplates_zip=xctemplates.zip\n\nlocal_codesnippets_zip=`pwd`/archive/$codesnippets_zip\nlocal_xctemplates_zip=`pwd`/archive/$xctemplates_zip\n\nremote_url=\"https://raw.githubusercontent.com/Tencent/wcdb/master/tools/templates/archive\"\ntemp_directory=`mktemp -d`\n\nif [ ! -f \"$local_codesnippets_zip\" ]; then\n    # fetch remote codesnippets zip    \n    remote_codesnippets_zip=$remote_url/$codesnippets_zip\n    local_codesnippets_zip=$temp_directory/$codesnippets_zip\n    curl $remote_codesnippets_zip -o $local_codesnippets_zip -s\n    echo \"fetch $remote_codesnippets_zip to $local_codesnippets_zip\"\nfi\n\nif [ ! -f \"$local_xctemplates_zip\" ]; then\n    # fetch remote xctemplates zip    \n    remote_xctemplates_zip=$remote_url/$xctemplates_zip\n    local_xctemplates_zip=$temp_directory/$xctemplates_zip\n    curl $remote_xctemplates_zip -o $local_xctemplates_zip -s\n    echo \"fetch $remote_xctemplates_zip to $local_xctemplates_zip\"    \nfi\n\ntemplates=~/Library/Developer/Xcode/Templates\n\ntarget_templates=\"$templates\"/File\\ Templates/\ntarget_codesnippets=~/Library/Developer/Xcode/UserData/CodeSnippets/\n\n# handle unexpected issue\nif [ -f \"$templates\" ] ;\nthen\n    rm \"$templates\"\nfi;\nif [ -h \"$target_templates\" ] ;\nthen\n    rm \"$target_templates\"\nfi;\nrm -f \"$target_codesnippets\"/WCDB.*\nrm -fr \"$target_templates\"/WCDB\n\ninstall() {\n    source_zip=\"$1\"\n    target=\"$2\"\n    mkdir -p \"$target\"\n    unzip -o -q \"$source_zip\" -d \"$target\"\n}\n\n# install code templates\ninstall \"$local_xctemplates_zip\" \"$target_templates\"\necho \"Code templates is installed at $target_templates\"\n\n# install codesnippets\ninstall \"$local_codesnippets_zip\" \"$target_codesnippets\"\necho \"Code snippets is installed at $target_codesnippets\"\n"
  },
  {
    "path": "tools/templates/xctemplates/WCDB/ColumnCodable.xctemplate/Objective-CData/___FILEBASENAME___+WCTColumnCoding.h",
    "content": "//___FILEHEADER___\n\n#import \"___VARIABLE_productName___.h\"\n#import <WCDB/WCDB.h>\n\n@interface ___VARIABLE_productName___ (WCTColumnCoding) <WCTColumnCoding>\n\n@end\n"
  },
  {
    "path": "tools/templates/xctemplates/WCDB/ColumnCodable.xctemplate/Objective-CData/___FILEBASENAME___+WCTColumnCoding.mm",
    "content": "//___FILEHEADER___\n\n#import \"___VARIABLE_productName___+WCTColumnCoding.h\"\n\n@implementation ___VARIABLE_productName___ (WCTColumnCoding)\n\n+ (instancetype)unarchiveWithWCTValue:(NSData *)value\n{\n    return /* <#Unarchive ___VARIABLE_productName___ From NSData *#> */;\n}\n\n- (NSData *)archivedWCTValue\n{\n    return /* <#Archive ___VARIABLE_productName___ To NSData *#> */;\n}\n\n+ (WCTColumnType)columnType\n{\n    return WCTColumnTypeData;\n}\n\n@end\n"
  },
  {
    "path": "tools/templates/xctemplates/WCDB/ColumnCodable.xctemplate/Objective-CDouble/___FILEBASENAME___+WCTColumnCoding.h",
    "content": "//___FILEHEADER___\n\n#import \"___VARIABLE_productName___.h\"\n#import <WCDB/WCDB.h>\n\n@interface ___VARIABLE_productName___ (WCTColumnCoding) <WCTColumnCoding>\n\n@end\n"
  },
  {
    "path": "tools/templates/xctemplates/WCDB/ColumnCodable.xctemplate/Objective-CDouble/___FILEBASENAME___+WCTColumnCoding.mm",
    "content": "//___FILEHEADER___\n\n#import \"___VARIABLE_productName___+WCTColumnCoding.h\"\n\n@implementation ___VARIABLE_productName___ (WCTColumnCoding)\n\n+ (instancetype)unarchiveWithWCTValue:(NSNumber *)value\n{\n    return /* <#Unarchive ___VARIABLE_productName___ From NSNumber *#> */;\n}\n\n- (NSNumber *)archivedWCTValue\n{\n    return /* <#Archive ___VARIABLE_productName___ To NSNumber *#> */;\n}\n\n+ (WCTColumnType)columnType\n{\n    return WCTColumnTypeDouble;\n}\n\n@end\n"
  },
  {
    "path": "tools/templates/xctemplates/WCDB/ColumnCodable.xctemplate/Objective-CInteger32/___FILEBASENAME___+WCTColumnCoding.h",
    "content": "//___FILEHEADER___\n\n#import \"___VARIABLE_productName___.h\"\n#import <WCDB/WCDB.h>\n\n@interface ___VARIABLE_productName___ (WCTColumnCoding) <WCTColumnCoding>\n\n@end\n"
  },
  {
    "path": "tools/templates/xctemplates/WCDB/ColumnCodable.xctemplate/Objective-CInteger32/___FILEBASENAME___+WCTColumnCoding.mm",
    "content": "//___FILEHEADER___\n\n#import \"___VARIABLE_productName___+WCTColumnCoding.h\"\n\n@implementation ___VARIABLE_productName___ (WCTColumnCoding)\n\n+ (instancetype)unarchiveWithWCTValue:(NSNumber *)value\n{\n    return /* <#Unarchive ___VARIABLE_productName___ From NSNumber *#> */;\n}\n\n- (NSNumber *)archivedWCTValue\n{\n    return /* <#Archive ___VARIABLE_productName___ To NSNumber *#> */;\n}\n\n+ (WCTColumnType)columnType\n{\n    return WCTColumnTypeInteger32;\n}\n\n@end\n"
  },
  {
    "path": "tools/templates/xctemplates/WCDB/ColumnCodable.xctemplate/Objective-CInteger64/___FILEBASENAME___+WCTColumnCoding.h",
    "content": "//___FILEHEADER___\n\n#import \"___VARIABLE_productName___.h\"\n#import <WCDB/WCDB.h>\n\n@interface ___VARIABLE_productName___ (WCTColumnCoding) <WCTColumnCoding>\n\n@end\n"
  },
  {
    "path": "tools/templates/xctemplates/WCDB/ColumnCodable.xctemplate/Objective-CInteger64/___FILEBASENAME___+WCTColumnCoding.mm",
    "content": "//___FILEHEADER___\n\n#import \"___VARIABLE_productName___+WCTColumnCoding.h\"\n\n@implementation ___VARIABLE_productName___ (WCTColumnCoding)\n\n+ (instancetype)unarchiveWithWCTValue:(NSNumber *)value\n{\n    return /* <#Unarchive ___VARIABLE_productName___ From NSNumber *#> */;\n}\n\n- (NSNumber *)archivedWCTValue\n{\n    return /* <#Archive ___VARIABLE_productName___ To NSNumber *#> */;\n}\n\n+ (WCTColumnType)columnType\n{\n    return WCTColumnTypeInteger64;\n}\n\n@end\n"
  },
  {
    "path": "tools/templates/xctemplates/WCDB/ColumnCodable.xctemplate/Objective-CString/___FILEBASENAME___+WCTColumnCoding.h",
    "content": "//___FILEHEADER___\n\n#import \"___VARIABLE_productName___.h\"\n#import <WCDB/WCDB.h>\n\n@interface ___VARIABLE_productName___ (WCTColumnCoding) <WCTColumnCoding>\n\n@end\n"
  },
  {
    "path": "tools/templates/xctemplates/WCDB/ColumnCodable.xctemplate/Objective-CString/___FILEBASENAME___+WCTColumnCoding.mm",
    "content": "//___FILEHEADER___\n\n#import \"___VARIABLE_productName___+WCTColumnCoding.h\"\n\n@implementation ___VARIABLE_productName___ (WCTColumnCoding)\n\n+ (instancetype)unarchiveWithWCTValue:(NSString *)value\n{\n    return /* <#Unarchive ___VARIABLE_productName___ From NSString *#> */;\n}\n\n- (NSString *)archivedWCTValue\n{\n    return /* <#Archive ___VARIABLE_productName___ To NSString *#> */;\n}\n\n+ (WCTColumnType)columnType\n{\n    return WCTColumnTypeString;\n}\n\n@end\n"
  },
  {
    "path": "tools/templates/xctemplates/WCDB/ColumnCodable.xctemplate/SwiftData/___FILEBASENAME___.swift",
    "content": "// ___FILEHEADER___\n\nimport Foundation\nimport WCDB\n\nclass ___VARIABLE_productName___: WCDB.ColumnCodable, WCDB.LiteralValueConvertible {\n    static var columnType: ColumnType {\n        return .BLOB\n    }\n\n    required init?(with value: WCDB.Value) {\n\t\t/* <#Init ___VARIABLE_productName___ From value.dataValue#> */\n    }\n\n    func archivedValue() -> WCDB.Value {\n        return WCDB.Value(<#Data#>)\n    }\n}\n"
  },
  {
    "path": "tools/templates/xctemplates/WCDB/ColumnCodable.xctemplate/SwiftDouble/___FILEBASENAME___.swift",
    "content": "// ___FILEHEADER___\n\nimport Foundation\nimport WCDB\n\nclass ___VARIABLE_productName___: WCDB.ColumnCodable, WCDB.LiteralValueConvertible {\n    static var columnType: ColumnType {\n        return .float\n    }\n\n    required init?(with value: WCDB.Value) {\n        /* Init ___VARIABLE_productName___ From value.doubleValue */\n    }\n\n    func archivedValue() -> WCDB.Value {\n        return WCDB.Value(<#Double#>)\n    }\n}\n"
  },
  {
    "path": "tools/templates/xctemplates/WCDB/ColumnCodable.xctemplate/SwiftInteger32/___FILEBASENAME___.swift",
    "content": "// ___FILEHEADER___\n\nimport Foundation\nimport WCDB\n\nclass ___VARIABLE_productName___: WCDB.ColumnCodable, WCDB.LiteralValueConvertible {\n    static var columnType: ColumnType {\n        return .integer32\n    }\n\n    required init?(with value: WCDB.Value) {\n        /* Init ___VARIABLE_productName___ From value.int32Value */\n    }\n\n    func archivedValue() -> WCDB.Value {\n        return WCDB.Value(<#Int32#>)\n    }\n}\n"
  },
  {
    "path": "tools/templates/xctemplates/WCDB/ColumnCodable.xctemplate/SwiftInteger64/___FILEBASENAME___.swift",
    "content": "// ___FILEHEADER___\n\nimport Foundation\nimport WCDB\n\nclass ___VARIABLE_productName___: WCDB.ColumnCodable, WCDB.LiteralValueConvertible {\n    static var columnType: ColumnType {\n        return .BLOB\n    }\n\n    required init?(with value: WCDB.Value) {\n        /* Init ___VARIABLE_productName___ From value.int64Value */\n    }\n\n    func archivedValue() -> WCDB.Value {\n        return WCDB.Value(<#Int64#>)\n    }\n}\n"
  },
  {
    "path": "tools/templates/xctemplates/WCDB/ColumnCodable.xctemplate/SwiftString/___FILEBASENAME___.swift",
    "content": "// ___FILEHEADER___\n\nimport Foundation\nimport WCDB\n\nclass ___VARIABLE_productName___: WCDB.ColumnCodable, WCDB.LiteralValueConvertible {\n    static var columnType: ColumnType {\n        return .text\n    }\n\n    required init?(with value: WCDB.Value) {\n        /* Init ___VARIABLE_productName___ From value.stringValue */\n    }\n\n    func archivedValue() -> WCDB.Value {\n        return WCDB.Value(<#String#>)\n    }\n}\n"
  },
  {
    "path": "tools/templates/xctemplates/WCDB/ColumnCodable.xctemplate/TemplateInfo.plist",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">\n<plist version=\"1.0\">\n<dict>\n\t<key>Kind</key>\n\t<string>Xcode.IDEFoundation.TextSubstitutionFileTemplateKind</string>\n\t<key>Description</key>\n\t<string>Column Codable</string>\n\t<key>Summary</key>\n\t<string>Column Codable</string>\n\t<key>SortOrder</key>\n\t<string>1</string>\n\t<key>DefaultCompletionName</key>\n\t<string>MyClass</string>\n\t<key>Platforms</key>\n\t<array>\n\t\t<string>com.apple.platform.macosx</string>\n\t\t<string>com.apple.platform.iphoneos</string>\n\t</array>\n\t<key>Options</key>\n\t<array>\n\t\t<dict>\n\t\t\t<key>Identifier</key>\n\t\t\t<string>productName</string>\n\t\t\t<key>Required</key>\n\t\t\t<true/>\n\t\t\t<key>Name</key>\n\t\t\t<string>Class</string>\n\t\t\t<key>Description</key>\n\t\t\t<string>Class</string>\n\t\t\t<key>Type</key>\n\t\t\t<string>text</string>\n\t\t\t<key>NotPersisted</key>\n\t\t\t<true/>\n\t\t</dict>\n\t\t<dict>\n\t\t\t<key>Identifier</key>\n\t\t\t<string>languageChoice</string>\n\t\t\t<key>Required</key>\n\t\t\t<true/>\n\t\t\t<key>Name</key>\n\t\t\t<string>Language:</string>\n\t\t\t<key>Description</key>\n\t\t\t<string>The implementation language</string>\n\t\t\t<key>Type</key>\n\t\t\t<string>popup</string>\n\t\t\t<key>Default</key>\n\t\t\t<string>Objective-C</string>\n\t\t\t<key>Values</key>\n\t\t\t<array>\n\t\t\t\t<string>Objective-C</string>\n\t\t\t\t<string>Swift</string>\n\t\t\t</array>\n\t\t\t<key>AllowedTypes</key>\n\t\t\t<dict>\n\t\t\t\t<key>Objective-C</key>\n\t\t\t\t<array>\n\t\t\t\t\t<string>public.objective-c-plus-plus-source</string>\n\t\t\t\t</array>\n\t\t\t\t<key>Swift</key>\n\t\t\t\t<array>\n\t\t\t\t\t<string>public.swift-source</string>\n\t\t\t\t</array>\n\t\t\t</dict>\n\t\t</dict>\n\t\t<dict>\n\t\t\t<key>Identifier</key>\n\t\t\t<string>DataType</string>\n\t\t\t<key>Required</key>\n\t\t\t<true/>\n\t\t\t<key>Name</key>\n\t\t\t<string>Type In DataBase</string>\n\t\t\t<key>Description</key>\n\t\t\t<string>Type In DataBase</string>\n\t\t\t<key>Type</key>\n\t\t\t<string>popup</string>\n\t\t\t<key>Default</key>\n\t\t\t<string>Integer32</string>\n\t\t\t<key>Values</key>\n\t\t\t<array>\n\t\t\t\t<string>Integer32</string>\n\t\t\t\t<string>Integer64</string>\n\t\t\t\t<string>Double</string>\n\t\t\t\t<string>String</string>\n\t\t\t\t<string>Data</string>\n\t\t\t</array>\n\t\t</dict>\n\t</array>\n</dict>\n</plist>\n"
  },
  {
    "path": "tools/templates/xctemplates/WCDB/TableCodable.xctemplate/Objective-C/___FILEBASENAME___+WCTTableCoding.h",
    "content": "//___FILEHEADER___\n\n#import \"___VARIABLE_productName___.h\"\n#import <WCDB/WCDB.h>\n\n@interface ___VARIABLE_productName___ (WCTTableCoding) <WCTTableCoding>\n\n/*\nWCDB_PROPERTY(<#property1#>)\nWCDB_PROPERTY(<#property2#>)\nWCDB_PROPERTY(<#property3#>)\nWCDB_PROPERTY(<#property4#>)\nWCDB_PROPERTY(<#.........#>)\n */\n\n@end\n"
  },
  {
    "path": "tools/templates/xctemplates/WCDB/TableCodable.xctemplate/Objective-C/___FILEBASENAME___.h",
    "content": "//___FILEHEADER___\n\n#import <Foundation/Foundation.h>\n\n@interface ___VARIABLE_productName___ : NSObject\n\n/*\n // An ORM type can be any C types or any ObjC classes which conforms to NSCoding or WCTColumnCoding protocol.\n // An ORM property must contains a setter which can be private\n@property (nonatomic, retain) NSString *<#property1#>;\n@property (nonatomic, assign) NSInteger <#property2#>;\n@property (nonatomic, assign) float <#property3#>;\n@property (nonatomic, strong) NSArray *<#property4#>;\n@property (nonatomic, readonly) NSDate *<#..........#>;\n */\n\n@end\n"
  },
  {
    "path": "tools/templates/xctemplates/WCDB/TableCodable.xctemplate/Objective-C/___FILEBASENAME___.mm",
    "content": "//___FILEHEADER___\n\n#import \"___VARIABLE_productName___+WCTTableCoding.h\"\n#import \"___VARIABLE_productName___.h\"\n#import <WCDB/WCDB.h>\n\n@implementation ___VARIABLE_productName___\n\n/*\nWCDB_IMPLEMENTATION(___VARIABLE_productName___)\nWCDB_SYNTHESIZE(<#property1#>)\nWCDB_SYNTHESIZE(<#property2#>)\nWCDB_SYNTHESIZE(<#property3#>)\nWCDB_SYNTHESIZE(<#property4#>)\nWCDB_SYNTHESIZE_COLUMN(<#property5#>, \"<#column name#>\")   // Custom column name\n\nWCDB_PRIMARY_AUTO_INCREMENT(<#property#>)\n\nWCDB_INDEX(<#_index_subfix#>, <#property#>)\n */\n\n@end\n"
  },
  {
    "path": "tools/templates/xctemplates/WCDB/TableCodable.xctemplate/Swift/___FILEBASENAME___.swift",
    "content": "// ___FILEHEADER___\n\nimport Foundation\nimport WCDB\n\nclass ___VARIABLE_productName___: WCDB.TableCodable {\n    // Your own properties\n    var variable1: Int = 0\n    var variable2: String? // Optional if it would be nil in some WCDB selection.\n    var variable3: Double? // Optional if it would be nil in some WCDB selection.\n    let invalid: Int = 0 // An initialized constant property is not allowed.\n    let unbound: Date? = nil\n\n    enum CodingKeys: String, CodingTableKey {\n        typealias Root = ___VARIABLE_productName___\n\n        // List the properties which should be bound to table.\n        case variable1 = \"custom_name\"\n        case variable2\n        case variable3\n\n        static let objectRelationalMapping = TableBinding(CodingKeys.self) {\n            // Column constraints for primary key, unique, not null, default value and so on. It is optional.\n            // BindColumnConstraint(.variable1, isPrimary: true, isAutoIncrement: true)\n            // BindColumnConstraint(.variable2, isUnique: true)\n\n            // Index bindings. It is optional.\n            // BindIndex(.variable2, namedWith: \"_index\")\n\n            // Table constraints for multi-primary, multi-unique and so on. It is optional.\n            // BindMultiPrimary(.variable2, .variable3)\n\n            // Virtual table binding for FTS and so on. It is optional.\n            // BindVirtualTable(withModule: .FTS5, and: BuiltinTokenizer.Verbatim)\n        }\n    }\n\n    // Properties below are needed when the primary key is auto-increment.\n    // var isAutoIncrement: Bool = false\n    // var lastInsertedRowID: Int64 = 0\n}\n"
  },
  {
    "path": "tools/templates/xctemplates/WCDB/TableCodable.xctemplate/TemplateInfo.plist",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">\n<plist version=\"1.0\">\n<dict>\n\t<key>Kind</key>\n\t<string>Xcode.IDEFoundation.TextSubstitutionFileTemplateKind</string>\n\t<key>Description</key>\n\t<string>Table Codable Template.</string>\n\t<key>Summary</key>\n\t<string>Table Codable Template.</string>\n\t<key>SortOrder</key>\n\t<string>1</string>\n\t<key>DefaultCompletionName</key>\n\t<string>MyClass</string>\n\t<key>Platforms</key>\n\t<array>\n\t\t<string>com.apple.platform.macosx</string>\n\t\t<string>com.apple.platform.iphoneos</string>\n\t</array>\n\t<key>Options</key>\n\t<array>\n\t\t<dict>\n\t\t\t<key>Identifier</key>\n\t\t\t<string>productName</string>\n\t\t\t<key>Required</key>\n\t\t\t<true/>\n\t\t\t<key>Name</key>\n\t\t\t<string>Class</string>\n\t\t\t<key>Description</key>\n\t\t\t<string>Class</string>\n\t\t\t<key>Type</key>\n\t\t\t<string>text</string>\n\t\t\t<key>NotPersisted</key>\n\t\t\t<true/>\n\t\t</dict>\n\t\t<dict>\n\t\t\t<key>Identifier</key>\n\t\t\t<string>languageChoice</string>\n\t\t\t<key>Required</key>\n\t\t\t<true/>\n\t\t\t<key>Name</key>\n\t\t\t<string>Language:</string>\n\t\t\t<key>Description</key>\n\t\t\t<string>The implementation language</string>\n\t\t\t<key>Type</key>\n\t\t\t<string>popup</string>\n\t\t\t<key>Default</key>\n\t\t\t<string>Objective-C</string>\n\t\t\t<key>Values</key>\n\t\t\t<array>\n\t\t\t\t<string>Objective-C</string>\n\t\t\t\t<string>Swift</string>\n\t\t\t</array>\n\t\t\t<key>AllowedTypes</key>\n\t\t\t<dict>\n\t\t\t\t<key>Objective-C</key>\n\t\t\t\t<array>\n\t\t\t\t\t<string>public.objective-c-plus-plus-source</string>\n\t\t\t\t</array>\n\t\t\t\t<key>Swift</key>\n\t\t\t\t<array>\n\t\t\t\t\t<string>public.swift-source</string>\n\t\t\t\t</array>\n\t\t\t</dict>\n\t\t</dict>\n\t</array>\n</dict>\n</plist>\n"
  },
  {
    "path": "tools/templates/xctemplates/WCDB/Tokenizer.xctemplate/Objective-C/___FILEBASENAME___Tokenizer.h",
    "content": "//___FILEHEADER___\n\n#import <Foundation/Foundation.h>\n#import <WCDB/WCDB.h>\n\nclass ___VARIABLE_productName___Tokenizer final : public WCDB::AbstractFTSTokenizer {\npublic:\n    ___VARIABLE_productName___Tokenizer(const char *const *azArg,\n                                        int nArg,\n                                        void *pCtx /* pCtx is only used in FTS5 */);\n    ~___VARIABLE_productName___Tokenizer();\n\n    void loadInput(const char *pText,\n                   int nText,\n                   int flags /* flags is only used in FTS5 */) override final;\n\n    int nextToken(const char **ppToken,\n                  int *nToken,\n                  int *iStart,\n                  int *iEnd,\n                  int *tflags,   //tflags is only used in FTS5\n                  int *iPosition //iPosition is only used in FTS3/4\n                  ) override final;\n};\n"
  },
  {
    "path": "tools/templates/xctemplates/WCDB/Tokenizer.xctemplate/Objective-C/___FILEBASENAME___Tokenizer.mm",
    "content": "//___FILEHEADER___\n\n#import \"___VARIABLE_productName___Tokenizer.h\"\n\n#pragma mark - Tokenizer Cursor Info\n___VARIABLE_productName___Tokenizer::___VARIABLE_productName___Tokenizer(const char *const *azArg,\n                                                                         int nArg,\n                                                                         void *pCtx /* pCtx is only used in FTS5 */)\n: WCDB::AbstractFTSTokenizer(azArg, nArg, pCtx)\n{\n}\n\n___VARIABLE_productName___Tokenizer::~___VARIABLE_productName___Tokenizer()\n{\n}\n\nvoid ___VARIABLE_productName___Tokenizer::loadInput(const char *pText,\n                                                    int nText,\n                                                    int flags) // flags is only used in FTS5\n{\n}\n\nint ___VARIABLE_productName___Tokenizer::nextToken(const char **ppToken,\n                                                   int *nToken,\n                                                   int *iStart,\n                                                   int *iEnd,\n                                                   int *tflags,    //tflags is only used in FTS5\n                                                   int *iPosition) //iPosition is only used in FTS3/4\n{\n    if (/* done */) {\n        return WCTErrorCodeDone;\n    }\n    return WCTErrorCodeOK;\n}\n"
  },
  {
    "path": "tools/templates/xctemplates/WCDB/Tokenizer.xctemplate/Swift/___FILEBASENAME___.swift",
    "content": "// ___FILEHEADER___\n\nimport Foundation\nimport WCDB\n\nclass ___VARIABLE_productName___: WCDB.Tokenizer {\n\n    required init(args: [String]) {\n    }\n\n    func load(input: UnsafePointer<Int8>?, length: Int, flags: Int/* flags is only used in FTS5 */) {\n    }\n\n    func nextToken(ppToken: UnsafeMutablePointer<UnsafePointer<Int8>?>,\n                   pnBytes: UnsafeMutablePointer<Int32>,\n                   piStart: UnsafeMutablePointer<Int32>,\n                   piEnd: UnsafeMutablePointer<Int32>,\n                   pFlags: UnsafeMutablePointer<Int32>?,// pFlags is only used in FTS5\n                   piPosition: UnsafeMutablePointer<Int32>?// iPosition is only used in FTS3/4\n    ) -> WCDB.TokenizerErrorCode {\n        if /* done */ {\n            return .Done\n        }\n        return.OK\n    }\n}\n"
  },
  {
    "path": "tools/templates/xctemplates/WCDB/Tokenizer.xctemplate/TemplateInfo.plist",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">\n<plist version=\"1.0\">\n<dict>\n\t<key>Kind</key>\n\t<string>Xcode.IDEFoundation.TextSubstitutionFileTemplateKind</string>\n\t<key>Description</key>\n\t<string>Tokenizer Template.</string>\n\t<key>Summary</key>\n\t<string>Tokenizer Template.</string>\n\t<key>SortOrder</key>\n\t<string>1</string>\n\t<key>DefaultCompletionName</key>\n\t<string>MyTokenizer</string>\n\t<key>Platforms</key>\n\t<array>\n\t\t<string>com.apple.platform.macosx</string>\n\t\t<string>com.apple.platform.iphoneos</string>\n\t</array>\n\t<key>Options</key>\n\t<array>\n\t\t<dict>\n\t\t\t<key>Identifier</key>\n\t\t\t<string>productName</string>\n\t\t\t<key>Required</key>\n\t\t\t<true/>\n\t\t\t<key>Name</key>\n\t\t\t<string>Class</string>\n\t\t\t<key>Description</key>\n\t\t\t<string>Class</string>\n\t\t\t<key>Type</key>\n\t\t\t<string>text</string>\n\t\t\t<key>NotPersisted</key>\n\t\t\t<true/>\n\t\t</dict>\n\t\t<dict>\n\t\t\t<key>Identifier</key>\n\t\t\t<string>languageChoice</string>\n\t\t\t<key>Required</key>\n\t\t\t<true/>\n\t\t\t<key>Name</key>\n\t\t\t<string>Language:</string>\n\t\t\t<key>Description</key>\n\t\t\t<string>The implementation language</string>\n\t\t\t<key>Type</key>\n\t\t\t<string>popup</string>\n\t\t\t<key>Default</key>\n\t\t\t<string>Objective-C</string>\n\t\t\t<key>Values</key>\n\t\t\t<array>\n\t\t\t\t<string>Objective-C</string>\n\t\t\t\t<string>Swift</string>\n\t\t\t</array>\n\t\t\t<key>AllowedTypes</key>\n\t\t\t<dict>\n\t\t\t\t<key>Objective-C</key>\n\t\t\t\t<array>\n\t\t\t\t\t<string>public.objective-c-plus-plus-source</string>\n\t\t\t\t</array>\n\t\t\t\t<key>Swift</key>\n\t\t\t\t<array>\n\t\t\t\t\t<string>public.swift-source</string>\n\t\t\t\t</array>\n\t\t\t</dict>\n\t\t</dict>\n\t</array>\n</dict>\n</plist>\n"
  },
  {
    "path": "tools/version/build.sh",
    "content": "#!/bin/bash\n\nshowUsage() {\n    echo \"\"\"\\\n  USAGE: bash $0 \n       -p/--platform iOS/macOS/watchOS\n       -l/--language All/ObjC/Swift/Cpp\n       [-c/--configuration Debug/Release]: Default to Release.\n       [-d/--destination destination]: Default to current directory.\n       [--test]: Enable test.\n       [--disable-bitcode]: Use bitcode if not specified.\n       [--static-framework]: Produce dynamic framework if not specified.\n       [--pretty]: Use \\`xcpretty\\` if available.\n       [--zstd]: Use Zstd\n       [--wechat]: For WeChat.\n       [--universal]: Build universal library for macOS.\n\"\"\"\n}\n\nScriptDir=$( cd \"$( dirname \"${BASH_SOURCE[0]}\" )\" && pwd )\nroot=\"$ScriptDir\"/../../\n\ndeclare platform\ndeclare language\ndestination=\".\"\nenable_bitcode=true\nstatic_framework=false\nconfiguration=Release\npretty=false\naction=build\nzstd=0\nwechat=false\nuniversal=false\n\nwhile [[ $# -gt 0 ]]\ndo\nkey=\"$1\"\ncase \"$key\" in\n    -l|--language)\n    language=\"$2\"\n    shift\n    shift\n    ;;\n    -p|--platform)\n    platform=\"$2\"\n    shift\n    shift\n    ;;\n    -d|--destination)\n    destination=\"$2\"\n    shift\n    shift\n    ;;\n    --test)\n    action=test\n    shift\n    shift\n    ;;\n    -c|--configuration)\n    configuration=\"$2\"\n    shift\n    shift\n    ;;\n    --disable-bitcode)\n    enable_bitcode=false\n    shift\n    ;;\n    --static-framework)\n    static_framework=true\n    shift\n    ;;\n    --pretty)\n    pretty=true\n    shift\n    ;;\n    --zstd)\n    zstd=1\n    shift\n    ;;\n    --wechat)\n    wechat=true\n    shift\n    ;;\n    --universal)\n    universal=true\n    shift\n    ;;\n    -h|--help)\n    showUsage\n    exit 0\n    ;;\n    *)\n    showUsage\n    exit 1\n    ;;\nesac\ndone\n\nproject=\"$root\"/src/WCDB.xcodeproj\nderivedData=\"$destination\"/derivedData\nproducts=\"$derivedData\"/Build/Products\n\nif $universal; then\n    if [ \"$platform\" != \"macOS\" ]; then\n        echo 'Universal library is only supported with macOS.'\n        exit 1\n    fi\nfi\n\ndeclare settingsPrameter\nif $static_framework; then\n    settingsPrameter+=\"--static-framework \"\nfi\nif $enable_bitcode; then\n    settingsPrameter+=\"--enable-bitcode \"\nfi\nif $wechat; then\n    settingsPrameter+=\"--wechat \"\nfi\n\nsettings=`bash $ScriptDir/settings.sh $settingsPrameter`\n\ndeclare target\ndeclare scheme\ncase \"$language\" in\n    All)\n        target=WCDB\n        scheme=WCDB\n    ;;\n    ObjC)\n        target=WCDBObjc\n        scheme=WCDBObjc\n    ;;\n    Swift)\n        target=WCDBSwift\n        scheme=WCDBSwift\n    ;;\n    Cpp)\n        target=WCDBCpp\n        scheme=WCDBCpp\n    ;;\n    *)\n        echo 'Language should be All/ObjC/Swift/Cpp.'\n        showUsage\n        exit 1\n    ;;\nesac\nplatformBasedParameters=()\ncase \"$platform\" in\n    iOS)\n        platformBasedParameters+=('product=\"$products/$configuration-iphoneos/$target.framework\" sdk=iphoneos arch=\"arm64\"')\n        platformBasedParameters+=('product=\"$products/$configuration-iphonesimulator/$target.framework\" sdk=iphonesimulator arch=x86_64')\n    ;;\n    macOS)\n        macosArchs='x86_64'\n        if $universal; then\n        \tmacosArchs='x86_64 -arch arm64'\n        fi\n        platformBasedParameters+=('product=\"$products/$configuration/$target.framework\" sdk=macosx arch=$macosArchs')\n    ;;\n    watchOS)\n        platformBasedParameters+=('product=\"$products/$configuration-watchos/$target.framework\" sdk=watchos arch=\"arm64_32 -arch arm64\"')\n        platformBasedParameters+=('product=\"$products/$configuration-watchsimulator/$target.framework\" sdk=watchsimulator arch=\"x86_64\"')\n    ;;\n    *)\n        echo 'Platform should be either iOS, macOS or watchOS.'\n        showUsage\n        exit 1\n    ;;\nesac\n\n# build\necho \"Building $version ...\"\necho \"    Action: ${action}\"\necho \"    Language: ${language}\"\necho \"    Platform: ${platform}\"\necho \"    Configuration: ${configuration}\"\necho \"    Destination: ${destination}\"\necho \"    Bitcode: ${enable_bitcode}\"\necho \"    Static: ${static_framework}\"\necho \"    Pretty: ${pretty}\"\necho \"\"\n\nif [ -d \"$derivedData\" ]\nthen\n    rm -r \"$derivedData\"\nfi\ndeclare template\nmachos=()\nproductsDir=()\nfor platformBasedParameter in \"${platformBasedParameters[@]}\"; do\n    eval \"$platformBasedParameter\"\n    machos+=( \"$product/$target\" )\n    productsDir+=( $product )\n    if [ -z \"$template\" ]; then\n        template=\"$product\"\n    fi\n    builder=\"xcrun xcodebuild -arch $arch -scheme $scheme -project $project -configuration $configuration -derivedDataPath $derivedData -sdk $sdk WCDB_USE_ZSTD=$zstd $settings $action\"\n    if { $static_framework && $wechat; } || !$zstd; then\n        # skip zstd\n        if [ \"$platform\" = \"iOS\" ]; then\n          builder+=\" OTHER_LDFLAGS=\"-framework UIKit\"\"\n        elif [ \"$platform\" = \"macOS\" ]; then\n          builder+=\" OTHER_LDFLAGS=\"-framework Cocoa\"\"\n        else\n          builder+=\" OTHER_LDFLAGS=\"\"\"\n        fi\n    fi\n    if $pretty; then\n        if type xcpretty > /dev/null; then\n            builder+=\" | xcpretty\"\n        fi\n    fi\n    if ! eval \"$builder\"; then\n        echo \"Build failed.\"\n        exit 1\n    fi\ndone\n\n# copy to destination\noutput=\"$destination\"/\"$target.framework\"\nif [ -d \"$output\" ]\nthen\n    rm -r \"$output\"\nfi\nif ! cp -R \"$template\" \"$destination\"; then\n    echo \"Copy frameworks failed.\"\n    exit 1\nfi\n\nif (( ${#machos[@]} > 1 )); then\n    if ! xcrun lipo -create \"${machos[@]}\" -output \"$output/$target\"; then\n        echo \"Lipo mach-o failed.\"\n        exit 1\n    fi\n    for product in \"${productsDir[@]}\"; do\n        if ! cp -Rf \"$product/Modules\" \"$output\"; then\n            echo \"Copy Modules $product/Modules failed.\"\n            exit 1\n        fi\n    done\nfi\necho \"Output at $output\"\n"
  },
  {
    "path": "tools/version/build_xcframework.sh",
    "content": "#!/usr/bin/env bash\n\nset -euo pipefail\n\nusage() {\n    cat <<'EOF'\nUsage: xcframework.sh --scheme <SCHEME> [options]\n\nOptions:\n  --scheme <SCHEME>           Target scheme to build. Required. (WCDB | WCDBCpp | WCDBObjc | WCDBSwift)\n  --configuration <CONFIG>    Build configuration. Default: Release.\n  --project <PATH>            Path to the .xcodeproj (relative to this script or absolute). Default: src/WCDB.xcodeproj\n  --output <DIR>              Output directory (relative to this script or absolute). Default: <script_dir>/build\n  --platforms <LIST...>       Platforms to build: ios ios-simulator macos macos-catalyst all. Default: all\n  --no-xcframework            Skip xcframework creation.\n  --xcbeautify                Pipe build output through xcbeautify.\n  -h, --help                  Show this help message.\nEOF\n}\n\nScriptDir=$(cd \"$(dirname \"${BASH_SOURCE[0]}\")\" && pwd)\nRoot=$(cd \"$ScriptDir/../..\" && pwd)\n\nscheme=\"\"\nconfiguration=\"Release\"\nproject=\"src/WCDB.xcodeproj\"\noutput=\"$ScriptDir/build\"\nplatforms=()\nno_xcframework=0\nuse_xcbeautify=0\n\nwhile [[ $# -gt 0 ]]; do\n    case \"$1\" in\n        --scheme)\n            [[ $# -lt 2 ]] && { echo \"Missing value for --scheme\" >&2; usage; exit 1; }\n            scheme=\"$2\"\n            shift 2\n            ;;\n        --configuration)\n            [[ $# -lt 2 ]] && { echo \"Missing value for --configuration\" >&2; usage; exit 1; }\n            configuration=\"$2\"\n            shift 2\n            ;;\n        --project)\n            [[ $# -lt 2 ]] && { echo \"Missing value for --project\" >&2; usage; exit 1; }\n            project=\"$2\"\n            shift 2\n            ;;\n        --output)\n            [[ $# -lt 2 ]] && { echo \"Missing value for --output\" >&2; usage; exit 1; }\n            output=\"$2\"\n            shift 2\n            ;;\n        --platforms)\n            platforms=()\n            shift\n            while [[ $# -gt 0 && \"$1\" != --* ]]; do\n                platforms+=(\"$1\")\n                shift\n            done\n            ;;\n        --no-xcframework)\n            no_xcframework=1\n            shift\n            ;;\n        --xcbeautify)\n            use_xcbeautify=1\n            shift\n            ;;\n        -h|--help)\n            usage\n            exit 0\n            ;;\n        *)\n            echo \"Unknown argument: $1\" >&2\n            usage\n            exit 1\n            ;;\n    esac\ndone\n\nif [[ -z \"$scheme\" ]]; then\n    echo \"Error: --scheme is required.\" >&2\n    usage\n    exit 1\nfi\n\ncase \"$scheme\" in\n    WCDB|WCDBCpp|WCDBObjc|WCDBSwift) ;;\n    *)\n        echo \"Unknown scheme: $scheme\" >&2\n        exit 1\n        ;;\nesac\n\nif [[ ${#platforms[@]} -eq 0 ]]; then\n    platforms=(\"all\")\nfi\n\nresolve_path() {\n    local path=\"$1\"\n    if [[ \"$path\" == /* ]]; then\n        printf \"%s\" \"$path\"\n    else\n        printf \"%s/%s\" \"$Root\" \"$path\"\n    fi\n}\n\nget_destination() {\n    case \"$1\" in\n        ios) echo \"generic/platform=iOS,name=Any iOS Device\" ;;\n        ios-simulator) echo \"generic/platform=iOS Simulator\" ;;\n        macos) echo \"generic/platform=macOS,name=Any Mac\" ;;\n        macos-catalyst) echo \"generic/platform=macOS,variant=Mac Catalyst,name=Any Mac\" ;;\n        *)\n            echo \"Invalid platform: $1\" >&2\n            exit 1\n            ;;\n    esac\n}\n\nget_extra_args() {\n    case \"$1\" in\n        WCDBSwift) echo \"BUILD_LIBRARY_FOR_DISTRIBUTION=YES\" ;;\n        *) echo \"\" ;;\n    esac\n}\n\nis_valid_platform() {\n    case \"$1\" in\n        ios|ios-simulator|macos|macos-catalyst|all) return 0 ;;\n        *) return 1 ;;\n    esac\n}\n\nfor platform in \"${platforms[@]}\"; do\n    if ! is_valid_platform \"$platform\"; then\n        echo \"Invalid platform: $platform\" >&2\n        exit 1\n    fi\ndone\n\nif [[ $use_xcbeautify -eq 1 ]] && ! command -v xcbeautify >/dev/null 2>&1; then\n    echo \"xcbeautify not found in PATH.\" >&2\n    exit 1\nfi\n\nproject_file=$(resolve_path \"$project\")\nbuild_out_dir=$(resolve_path \"$output\")\narchives_dir=\"$build_out_dir/archives\"\nxcframeworks_dir=\"$build_out_dir/xcframeworks\"\n\nrun_command() {\n    local cmd=(\"$@\")\n    printf \"\\n[cmd] %s\\n\\n\" \"${cmd[*]}\"\n    \"${cmd[@]}\"\n}\n\ncreate_xcframework() {\n    local output_dir=\"$1\"\n    local framework_name=\"$2\"\n\n    local cmd=(xcodebuild -create-xcframework)\n    local archive\n    for archive in \"${archives[@]}\"; do\n        cmd+=(-archive \"$archive\" -framework \"${framework_name}.framework\")\n    done\n\n    mkdir -p \"$output_dir\"\n    local output_path=\"$output_dir/${framework_name}.xcframework\"\n    if [[ -d \"$output_path\" ]]; then\n        printf \"[*] Removing existing xcframework: %s\\n\" \"$output_path\"\n        rm -rf \"$output_path\"\n    fi\n\n    cmd+=(-output \"$output_path\")\n    run_command \"${cmd[@]}\"\n    printf \"\\n✅ Created XCFramework: %s\\n\" \"$output_path\"\n}\n\nstart_time=$(date +%s)\n\nprintf \"[*] SCRIPT_DIR: %s\\n\" \"$ScriptDir\"\nprintf \"[*] REPO_ROOT_DIR: %s\\n\" \"$Root\"\nprintf \"[*] XCODE_PROJECT_FILE: %s\\n\" \"$project_file\"\nprintf \"[*] BUILD_OUT_DIR: %s\\n\" \"$build_out_dir\"\nprintf \"[*] BUILD_ARCHIVES_DIR: %s\\n\\n\" \"$archives_dir\"\n\nmkdir -p \"$archives_dir\"\narchives=()\n\ndefault_platform_order=(ios ios-simulator macos macos-catalyst)\ncontains_all=0\nfor platform in \"${platforms[@]}\"; do\n    if [[ \"$platform\" == \"all\" ]]; then\n        contains_all=1\n        break\n    fi\ndone\n\nif [[ $contains_all -eq 1 ]]; then\n    build_platforms=(\"${default_platform_order[@]}\")\nelse\n    build_platforms=(\"${platforms[@]}\")\nfi\n\nfor platform in \"${build_platforms[@]}\"; do\n    destination=$(get_destination \"$platform\")\n    printf \"\\n🚧 Building %s (%s)...\\n\" \"$scheme\" \"$platform\"\n\n    archive_base=\"${archives_dir}/${scheme}-${platform}\"\n    archive_path=\"${archive_base}.xcarchive\"\n    rm -rf \"$archive_path\"\n\n    cmd=(xcodebuild archive\n        -project \"$project_file\"\n        -scheme \"$scheme\"\n        -configuration \"$configuration\"\n        -destination \"$destination\"\n        -archivePath \"$archive_base\"\n        SKIP_INSTALL=NO)\n\n    extra_arg=$(get_extra_args \"$scheme\")\n    if [[ -n \"$extra_arg\" ]]; then\n        cmd+=(\"$extra_arg\")\n    fi\n\n    if [[ $use_xcbeautify -eq 1 ]]; then\n        printf \"\\n[cmd] %s\\n\\n\" \"${cmd[*]}\"\n        if ! \"${cmd[@]}\" | xcbeautify; then\n            echo \"Command failed: ${cmd[*]}\" >&2\n            exit 1\n        fi\n    else\n        run_command \"${cmd[@]}\"\n    fi\n\n    archives+=(\"$archive_path\")\ndone\n\nif [[ $no_xcframework -eq 1 ]]; then\n    printf \"\\n⚙️ Skipped XCFramework creation (--no-xcframework).\\n\"\nelse\n    if [[ ${#archives[@]} -eq 0 ]]; then\n        echo \"No archives created. Aborting.\" >&2\n        exit 1\n    fi\n    printf \"\\n🧩 Creating XCFramework for %s ...\\n\" \"$scheme\"\n    mkdir -p \"$xcframeworks_dir\"\n    create_xcframework \"$xcframeworks_dir\" \"$scheme\"\nfi\n\nend_time=$(date +%s)\nelapsed=$((end_time - start_time))\nmins=$((elapsed / 60))\nsecs=$((elapsed % 60))\n\nprintf \"\\n⏱ Total elapsed time: %d min %d sec (%d s)\\n\" \"$mins\" \"$secs\" \"$elapsed\"\n\n"
  },
  {
    "path": "tools/version/bump.sh",
    "content": "#!/bin/bash\n\nusage() {\n    echo \"Usage: bash $0 -v/--version version\"\n}\n\nversion=\"\"\n\nwhile [[ $# -gt 0 ]]\ndo\nkey=\"$1\"\ncase \"$key\" in\n    -v|--version)\n    version=\"$2\"\n    shift\n    shift\n    ;;\n    *)\n    usage\n    exit 1\n    ;;\nesac\ndone\n\nroot=`git rev-parse --show-toplevel`\n\nif [ -z \"$version\" -a \"$version\" != \" \" ]; then\n    echo \"Version is not specified.\"\n    usage\n    exit 1\nfi\n\necho \"Bumping $version ...\"\n\n# Root Version\necho \"$version\" > \"$root\"/VERSION\ngit add \"$root\"/VERSION\n\n# Xcconfig\nsed -i '' \"s/MARKETING_VERSION = .*/MARKETING_VERSION = $version/\" \"$root\"/src/support/WCDB.xcconfig\ngit add \"$root\"/src/support/WCDB.xcconfig\n\ngit commit -m \"Bump $version\"\n"
  },
  {
    "path": "tools/version/settings.sh",
    "content": "#!/bin/bash\n\nshowUsage() {\n    echo \"\"\"\\\n  USAGE: bash $0 \n       [--enable-bitcode]: Disable bitcode if not specified.\n       [--static-framework]: Produce dynamic framework if not specified.\n       [--wechat]: For WeChat.\n\"\"\"\n}\nwechat=false\nzstd=false\nenable_bitcode=false\nstatic_framework=false\n\nwhile [[ $# -gt 0 ]]\ndo\nkey=\"$1\"\ncase \"$key\" in\n    --enable-bitcode)\n    enable_bitcode=true\n    shift\n    ;;\n    --static-framework)\n    static_framework=true\n    shift\n    ;;\n    --wechat)\n    wechat=true\n    shift\n    ;;\n    -h|--help)\n    showUsage\n    exit 0\n    ;;\n    *)\n    showUsage\n    exit 1\n    ;;\nesac\ndone\n\nScriptDir=$( cd \"$( dirname \"${BASH_SOURCE[0]}\" )\" && pwd )\nroot=\"$ScriptDir\"/../../\n# version\ntimestamp=`date +\"%Y-%m-%d %H:%M:%S UTC%z\"`\nversion=`cat $root/VERSION`\n\npreprocessor=\"\\$\\(inherited\\)\"\npreprocessor+=\"\\ WCDB_VERSION=\\\\\\\"\\\"${version}\\\\\\\"\\\"\"\nif $wechat; then\n    preprocessor+=\"\\ WCDB_WECHAT_IOS=1\"\nfi\npreprocessor+=\"\\ WCDB_BUILD=\\\\\\\"\\\"${timestamp}\\\\\\\"\\\"\"\n\nsettings=(ONLY_ACTIVE_ARCH=NO CODE_SIGNING_REQUIRED=NO CODE_SIGN_IDENTITY= SKIP_INSTALL=YES GCC_INSTRUMENT_PROGRAM_FLOW_ARCS=NO CLANG_ENABLE_CODE_COVERAGE=NO ENABLE_TESTABILITY=NO GCC_PREPROCESSOR_DEFINITIONS=${preprocessor})\nif $wechat; then\n    settings+=(DEPLOYMENT_POSTPROCESSING=NO)\nfi\nif $static_framework; then\n    settings+=(MACH_O_TYPE=staticlib STRIP_STYLE=debugging LLVM_LTO=NO STRIP_INSTALLED_PRODUCT=NO DEPLOYMENT_POSTPROCESSING=NO)\nfi\nif ! $enable_bitcode; then\n    settings+=(ENABLE_BITCODE=NO)\nfi\necho ${settings[@]}\n"
  }
]